346 lines
19 KiB
Markdown
346 lines
19 KiB
Markdown
# seal-home
|
|
|
|
Bun + TypeScript CLI and optional local service for pulling Seal enterprise approval context from provider credentials.
|
|
|
|
The first provider is Hose/合思: `key`, `password`, `corpId`, `staffId`, and an optional Hose domain. The provider exchanges those credentials for a Seal enterprise session, then the Seal domain tools can read and maintain approval rules, approval documents, and approval style preferences.
|
|
|
|
Seal-native enterprise pages can be added with a Seal Bearer token. The older `direct` source remains available for existing configs that already provide a Seal Bearer token.
|
|
|
|
## Quick Install (Standalone Binary)
|
|
|
|
No Node.js, Bun, or external runtime required. Run the one-line installer for macOS and Linux:
|
|
|
|
```bash
|
|
# 国内高速安装(Gitea 镜像源,免代理、秒级完成)
|
|
curl -fsSL https://git.ying-qing.cn/gitea/seal-home/raw/branch/master/scripts/install.sh | bash
|
|
|
|
# Global / GitHub Direct
|
|
curl -fsSL https://raw.githubusercontent.com/yunyingk/seal-home/master/scripts/install.sh | bash
|
|
```
|
|
|
|
Or download the native binary directly from [GitHub Releases](https://github.com/yunyingk/seal-home/releases/latest) or [Gitea Releases](https://git.ying-qing.cn/gitea/seal-home/releases):
|
|
|
|
- **macOS (Apple Silicon)**: `curl -fsSL https://github.com/yunyingk/seal-home/releases/latest/download/seal-home-darwin-arm64 -o /usr/local/bin/seal-home && chmod +x /usr/local/bin/seal-home`
|
|
- **macOS (Intel)**: `curl -fsSL https://github.com/yunyingk/seal-home/releases/latest/download/seal-home-darwin-x64 -o /usr/local/bin/seal-home && chmod +x /usr/local/bin/seal-home`
|
|
- **Linux (x86_64)**: `curl -fsSL https://github.com/yunyingk/seal-home/releases/latest/download/seal-home-linux-x64 -o /usr/local/bin/seal-home && chmod +x /usr/local/bin/seal-home`
|
|
- **Linux (ARM64)**: `curl -fsSL https://github.com/yunyingk/seal-home/releases/latest/download/seal-home-linux-arm64 -o /usr/local/bin/seal-home && chmod +x /usr/local/bin/seal-home`
|
|
- **Windows (x64)**: Download `seal-home-windows-x64.zip` from Releases and extract `seal-home-windows-x64.exe`.
|
|
|
|
After installation:
|
|
|
|
```bash
|
|
seal-home version # Check version
|
|
seal-home skill install # Install Agent skill to ~/.agents/skills/seal-home
|
|
seal-home mcp-config # Print .mcp.json snippet for Cursor / Claude Desktop / Codex
|
|
seal-home update # Future self-update directly from GitHub Release
|
|
```
|
|
|
|
## Source Setup & Development
|
|
|
|
For local development from source with Bun:
|
|
|
|
For an already-authenticated Seal-native source, use `seal-home corps add-seal` or copy `enterprises/example.seal.json`. Existing `direct` configs remain supported via `enterprises/example.direct.json`.
|
|
|
|
## Public Usage
|
|
|
|
This repository is intended to be published as a macOS local agent toolkit. Users run the global `seal-home` CLI on their own machine with their own enterprise credentials. Do not deploy it as a shared public service without adding authentication, tenant isolation, credential storage, audit logging, and write-operation controls.
|
|
|
|
Install the global CLI from a checkout:
|
|
|
|
```bash
|
|
git clone <repo-url>
|
|
cd seal-home
|
|
bun install
|
|
npm link
|
|
seal-home version
|
|
```
|
|
|
|
`npm link` creates a symlink from `/opt/homebrew/lib/node_modules/seal-home` → your local checkout. The `seal-home` binary on PATH then runs source files directly via bun — **no reinstall needed after editing source code**.
|
|
|
|
> ⚠️ **Do NOT use `npm install -g .`** for development. That copies files into the global node_modules directory and the copy becomes stale as soon as you edit the source. Always use `npm link` so edits take effect immediately.
|
|
|
|
To verify the symlink is in place (and not a stale copy):
|
|
|
|
```bash
|
|
ls -la $(dirname $(which seal-home))/../lib/node_modules/seal-home
|
|
# Should show: seal-home -> ../../../../Users/<you>/Code/seal-home
|
|
```
|
|
|
|
If it shows a plain directory instead of a symlink, re-run `npm link` from the repo root.
|
|
|
|
Create a user-level Hose enterprise config that works from any directory:
|
|
|
|
```bash
|
|
mkdir -p ~/.config/seal-home/enterprises
|
|
seal-home corps add-hose --json '{"name":"企业名称","domain":"https://app.ekuaibao.com","appKey":"...","appSecurity":"...","proxyStaffBizId":"corpId:staffId"}'
|
|
seal-home auth diagnose --corp <corpId>
|
|
seal-home tools list
|
|
```
|
|
|
|
`corps add-hose` verifies by default before writing the config. It uses the Hose OpenAPI credential response to derive the corporation ID, then checks provisional auth, Seal SSO, and Seal `whoami`. Pass `"force":true` or `"verify":false` only when you intentionally want to write a config that may fail later.
|
|
|
|
Create a user-level Seal-native enterprise config from an already signed-in Seal Home page:
|
|
|
|
```bash
|
|
seal-home corps add-seal --json '{"sealUrl":"https://tenant.staging.sealai.cc","token":"seal-bearer-token"}'
|
|
seal-home auth diagnose --corp tenant
|
|
```
|
|
|
|
`corps add-seal` verifies `/api/v1/auth/me` by default and writes the tenant slug, tenant ID, tenant name, and provider user ID into local config metadata. Pass `"force":true` or `"verify":false` only when writing an offline config intentionally.
|
|
|
|
For custom config locations, set `SEAL_HOME_ENTERPRISES_DIR` to a directory containing non-example `*.json` enterprise config files.
|
|
|
|
Update an existing checkout:
|
|
|
|
```bash
|
|
seal-home update
|
|
```
|
|
|
|
`seal-home update` runs `git pull --ff-only`, installs dependencies, and restarts the local service if it was running.
|
|
|
|
Because `npm link` makes the global command a symlink into your checkout, **updating the checkout is sufficient** — no reinstall step required. The symlink continues to point to the updated source.
|
|
|
|
Local enterprise config files are ignored by git:
|
|
|
|
```text
|
|
enterprises/*.json
|
|
!enterprises/example.*.json
|
|
```
|
|
|
|
The canonical plugin skill lives at `skills/seal-home`; `.agents/skills/seal-home` is a workspace symlink to the same files. Install or copy that folder into a Codex skills directory when you want Codex to invoke the workflow as `$seal-home`.
|
|
|
|
## ZCode Plugin
|
|
|
|
The repository is also a ZCode plugin. Install `seal-home` from the `yingqing-plugins` marketplace in **Settings → Plugin Management**, or add this repository as a local plugin directory while developing. The plugin provides the `skills/seal-home` skill and an optional MCP server.
|
|
|
|
The `seal_cli` MCP tool is disabled by default. Open the plugin detail page and enable **启用 MCP 服务** in the configuration section, then reconnect the plugin MCP server; this exposes the tool. When the option is off, the MCP process can complete the protocol handshake but does not register any tools. The tool accepts the same command syntax as the global CLI, including `version` and `seal-home version`.
|
|
|
|
For a standalone compiled CLI, build and run the binary from a checkout:
|
|
|
|
```bash
|
|
bun run build:binary
|
|
./dist/bin/seal-home version
|
|
```
|
|
|
|
## CLI
|
|
|
|
Use the CLI from skills, shell scripts, or agents. CLI intentionally keeps the full fine-grained tool list available through `seal-home tool <toolName>`.
|
|
|
|
```bash
|
|
seal-home version
|
|
seal-home config paths
|
|
seal-home config get
|
|
seal-home config mode stateless
|
|
seal-home config mode stateful --corp <corpId>
|
|
seal-home tools list
|
|
seal-home corps list
|
|
seal-home auth diagnose --corp <corpId>
|
|
seal-home approval-runs summary --corp <corpId> --date 2026-06-08 --timezone Asia/Shanghai
|
|
seal-home tool seal_approval_runs_summary --corp <corpId> --json '{"date":"2026-06-08","timezone":"Asia/Shanghai"}'
|
|
```
|
|
|
|
CLI output is JSON on stdout. Errors are written to stderr.
|
|
|
|
Enterprise config lookup:
|
|
|
|
- If `SEAL_HOME_ENTERPRISES_DIR` is set, only that directory is loaded.
|
|
- Otherwise `./enterprises` and `~/.config/seal-home/enterprises` are merged.
|
|
- User-level configs override same-ID configs from `./enterprises`.
|
|
|
|
Global enterprise selection is stateless by default. Its configuration is stored in
|
|
`~/.config/seal-home/config.json` (override with `SEAL_HOME_CONFIG_FILE`). In stateless mode,
|
|
every command that accesses an enterprise must receive `--corp <corpId>`; no `current-corp` file
|
|
or first-config fallback is used. Run `seal-home config mode stateful --corp <corpId>` to enable
|
|
a default enterprise, then `seal-home corps switch <corpId>` to change it. Run
|
|
`seal-home config mode stateless` to require explicit enterprise selection again.
|
|
|
|
Use `seal-home auth diagnose --corp <corpId>` when login fails in stateless mode. It reports four stages without printing tokens: `hose.openapi`, `hose.provisional`, `seal.sso`, and `seal.whoami`. A failed stage points to whether the problem is Hose app credentials, staff authorization, Seal SSO/tenant reachability, or Seal user/session access.
|
|
|
|
## Wrapped API Documentation
|
|
|
|
The OpenAPI source under `openapi/` describes the planned HTTP contract for a seal-home wrapped API. The current implementation exposes the MCP server over stdio and does not listen on the OpenAPI server URL. It is intentionally not the raw downstream Seal API: endpoints are named around seal-home concepts such as corps, auth diagnosis, approval context, run summaries, document URLs, and Langfuse bridge hints.
|
|
|
|
Source files are split by domain:
|
|
|
|
```text
|
|
openapi/openapi.yaml
|
|
openapi/paths/
|
|
openapi/components/
|
|
```
|
|
|
|
Generate a single tool-friendly JSON file:
|
|
|
|
```bash
|
|
bun run openapi:bundle
|
|
```
|
|
|
|
The generated file is written to `dist/openapi.json`. Treat `openapi/*.yaml` as the editable source of truth and `dist/openapi.json` as generated output for Swagger UI, Scalar, client generators, or agents.
|
|
|
|
## Local Service
|
|
|
|
For macOS users who want a long-lived local background process and a simple restart point after updates:
|
|
|
|
```bash
|
|
seal-home service start
|
|
seal-home service status
|
|
seal-home service restart
|
|
seal-home service stop
|
|
```
|
|
|
|
Service state is stored under `~/.config/seal-home/`:
|
|
|
|
- `service.pid`
|
|
- `service.log`
|
|
|
|
The service is intentionally local and currently acts as a lifecycle wrapper for a long-lived stdio/MCP process; it does not expose the HTTP/OpenAPI contract. It is useful as a stable process lifecycle for future warmed caches and update/restart workflows; normal CLI commands still work without it.
|
|
|
|
## Enterprise Config
|
|
|
|
```json
|
|
{
|
|
"id": "corp-id",
|
|
"name": "企业名称",
|
|
"seal": {
|
|
"url": "https://corp-id.sealai.cc",
|
|
"endpoints": {
|
|
"approvalStylePreferences": "api/v1/agent/ai-approval/config"
|
|
}
|
|
},
|
|
"source": {
|
|
"type": "hose",
|
|
"domain": "https://app.ekuaibao.com",
|
|
"key": "hose-app-key",
|
|
"password": "hose-app-security",
|
|
"staffId": "hose-staff-id",
|
|
"corpId": "hose-corp-id"
|
|
},
|
|
"auth": {
|
|
"refreshTtl": 300
|
|
}
|
|
}
|
|
```
|
|
|
|
## Developer MCP Notes
|
|
|
|
Most users do not need MCP. The public/shared path is the global `seal-home` CLI plus the optional local service.
|
|
|
|
The MCP server advertises exactly one tool, `seal_cli`:
|
|
|
|
```json
|
|
{
|
|
"command": "version"
|
|
}
|
|
```
|
|
|
|
It runs the same CLI dispatcher as the global binary, so read operations, write operations, `config`, `service`, and `update` remain available. Write-operation confirmations and explicit enterprise-ID rules continue to be defined by this skill.
|
|
|
|
## CLI Tools
|
|
|
|
These tools remain available to the CLI:
|
|
|
|
- `seal_source_config`: resolve current Seal enterprise config from the configured source.
|
|
- `seal_approval_runs_search`: search approval run history and optional bridge rows.
|
|
- `seal_session_get`: current Seal Bearer session and expiration.
|
|
- `seal_approval_rules_list`: current draft approval rules. Use `{"countOnly":true}` or `{"fields":["id"],"limit":0}` to return only `{"count":...}`; use `fields` for lightweight projections when rule descriptions are not needed.
|
|
- `seal_approval_rule_create`, `seal_approval_rule_update`, `seal_approval_rule_delete`: maintain approval rules.
|
|
- `seal_approval_rule_versions_list`, `seal_approval_rule_version_publish`: read and publish rule versions.
|
|
- `seal_approval_rule_get`: fetch one rule from a published version by `versionNumber` plus `code` such as `#0038`, or by `recordId` plus `runtimeId` such as `rule-205`.
|
|
- `seal_approval_documents_list`, `seal_approval_document_get`, `seal_approval_document_create`, `seal_approval_document_update`: maintain approval documents.
|
|
- `seal_approval_style_preferences_get`, `seal_approval_style_preferences_update`: read and update approval style preferences.
|
|
- `seal_approval_runs_summary`: summarize approval runs by local date and timezone. Use this for daily questions such as "what approval records did Tawen have today"; it returns status/task-mode counts and compact records.
|
|
- `seal_approval_run_get`: fetch one approval run. Pass `summary:true` or `fields` such as `"metadata"` or `"document.fields,result.summary"` to avoid returning full document, pipeline, and AI output payloads.
|
|
- `seal_approval_run_pick`: locate likely approval run records by document number, batch, latest flag, and optional field projection.
|
|
- `seal_approval_run_cited_rules_get`: extract rules cited or matched by the AI result, including runtime ID/code, version, scope, strictness, analysis, result, and findings when present.
|
|
- `seal_approval_run_document_summary_get`: return key document fields, invoice/attachment summary, AI result, and manual result.
|
|
- `seal_approval_run_attachments_get`: return attachment and invoice file metadata for one run without the full document or rule result; use `summary:true` for the smallest list.
|
|
- `seal_approval_run_result_get`: return one run result, with `{"summary":true}` for decision, summary, risk point count, matched rule count, trace ID, and record ID only.
|
|
- `seal_approval_run_url_get`: return the Hose enterprise assist URL, optionally with the original document URL for an approval run by `recordId`, `sourceDocumentSN`, or `sourceDocumentId`.
|
|
- `seal_simulation_batch_records_get`: read records from one simulation batch via `api/v1/simulation/batch/{batchId}/records`.
|
|
- `seal_approval_run_langfuse_bridge_get`: resolve approval run records to Langfuse lookup hints. It prefers `sourceExtendData._langfuseTraceId`; if that is missing, it returns `hosecloud-{sourceDocumentSN}` as the session fallback.
|
|
|
|
For rule list commands, prefer `seal-home rules count --corp <corpId>` or `seal-home rules list --corp <corpId> --summary` before requesting full rule descriptions. `seal-home rules list` protects large outputs and asks for `--summary`, `--count`, or explicit `--full` when the response would be too large.
|
|
|
|
For test tenants that need a clean slate before importing another rule set, use `seal-home rules clear --corp <corpId> --dry-run` first, then `seal-home rules clear --corp <corpId> --yes` to delete the current draft rules and verify the remaining count.
|
|
|
|
For approval run detail commands, prefer the same commands with explicit `--corp <corpId>`—for example `seal-home approval-runs pick --corp <corpId> --sn <单号> --latest` or `seal-home approval-runs get <recordId> --corp <corpId> --summary`—before requesting the full record. CLI JSON output is protected by a 200KB default limit; use `--output-file` for large payloads or `--full` only when the full response is intentional. Hose provisional auth links are available with `seal-home auth hose-link --corp <corpId> --expire 7200`, which returns the unredacted `getProvisionalAuth` URL.
|
|
|
|
## Approval Run To Langfuse Bridge
|
|
|
|
Seal approval runs and simulation batch records are treated as two views over the same run data:
|
|
|
|
- `api/v1/approvals` is the total approval run list. Use it for history search by time, status, task mode, source document SN, or source document ID.
|
|
- `api/v1/simulation/batch/{batchId}/records` is the detail list for one simulation batch. Use it when the user is already looking at a simulation batch.
|
|
|
|
The useful join fields for Langfuse work are:
|
|
|
|
- `sourceDocumentSN`
|
|
- `sourceDocumentId`
|
|
- `tenantId`
|
|
- `agentId`
|
|
- approval run `id`
|
|
- `sourceExtendData._langfuseTraceId`
|
|
- `sourceExtendData.simulation_batch_id`
|
|
|
|
When `_langfuseTraceId` exists, downstream tools should fetch the trace directly. When it is absent, use `hosecloud-{sourceDocumentSN}` as the Langfuse session fallback.
|
|
|
|
## Engineering Notes
|
|
|
|
- Prefer Bun-native commands in this repository: `bun run check`, `bun test`, and `seal-home ...`. `npm run check` may work, but Bun is the project runtime and lockfile owner.
|
|
- Keep CLI entry points thin. Shared behavior belongs in `src/core` and `src/domains`; `src/cli.ts` should only handle command parsing, process lifecycle, and JSON output.
|
|
- Do not print diagnostic text to stdout from the MCP server. MCP uses stdout as the protocol stream; use stderr for server diagnostics.
|
|
- Keep the MCP exported surface to the single `seal_cli` router; command knowledge belongs in this skill and its focused references.
|
|
- Prefer CLI or script processing for large tool responses. For daily approval questions, call `seal-home approval-runs summary --corp <corpId> ...` instead of reading long `seal_approval_runs_search` output manually.
|
|
- Keep broad search tools compact by default. Add explicit opt-in flags such as `includeBridge` for verbose fields that are useful only in deeper debugging.
|
|
- When Seal API timestamp filters are uncertain, filter again in tool code by `createdAt` and explicit timezone before presenting date-based answers.
|
|
|
|
## Release & Publishing
|
|
|
|
The project includes automated version bumping and CI dual-publishing workflows to simplify releases.
|
|
|
|
### 1. One-Command Version Bump (`bun run bump`)
|
|
|
|
Use `bun run bump` to automatically synchronize version numbers across all manifests, OpenAPI specs, and bundled assets in one step:
|
|
|
|
```bash
|
|
# Bump patch version (e.g. 0.8.1 -> 0.8.2)
|
|
bun run bump patch
|
|
|
|
# Bump minor version (e.g. 0.8.1 -> 0.9.0)
|
|
bun run bump minor
|
|
|
|
# Bump major version (e.g. 0.8.1 -> 1.0.0)
|
|
bun run bump major
|
|
|
|
# Or specify an exact target version
|
|
bun run bump 0.8.5
|
|
```
|
|
|
|
**What `bun run bump` handles automatically:**
|
|
1. Updates `"version"` in `package.json`;
|
|
2. Updates `"version"` in `.zcode-plugin/plugin.json`;
|
|
3. Updates `version`, `short-description`, and title in `skills/seal-home/SKILL.md`;
|
|
4. Updates `version` in `openapi/openapi.yaml`;
|
|
5. Rebuilds OpenAPI spec (`dist/openapi.json`) and MCP plugin bundle (`dist/mcp/server.js`);
|
|
6. Prints the exact `git commit` and `git tag` commands ready to execute.
|
|
|
|
### 2. Tag & Dual-Publish Workflow
|
|
|
|
1. Update `CHANGELOG.md` with the new version notes;
|
|
2. Run test suite:
|
|
```bash
|
|
bun test && bun run check
|
|
```
|
|
3. Commit and push the annotated tag:
|
|
```bash
|
|
git commit -am "Release vX.Y.Z: ..."
|
|
git tag -a vX.Y.Z -m "🚀 版本更新文案与主要特性说明"
|
|
git push origin master --tags && git push home master --tags
|
|
```
|
|
|
|
**CI Automation Pipeline:**
|
|
- GitHub Actions triggers automatically upon pushing a `v*` tag;
|
|
- Cross-compiles standalone binaries for 5 target platforms (macOS Apple Silicon/Intel, Linux x86_64/ARM64, Windows x64) in under 60 seconds;
|
|
- Automatically extracts your Git tag annotation message and appends commit changelogs (`--generate-notes`);
|
|
- Simultaneously publishes release packages to **[GitHub Releases](https://github.com/yunyingk/seal-home/releases)** and **[Gitea Releases](https://git.ying-qing.cn/gitea/seal-home/releases)** for global and mainland China high-speed downloads.
|
|
|