gitea a189f49223 Group core utility modules into util, skill, and update
Move duration, redact, runtime, secure-file, and semver under core/util; embedded-skill and skill-version under core/skill; update-cache under core/update. Move the dev-override test next to the script it covers, and update the embedded-skill generator output path and regenerated manifest. No behavior change.
2026-11-19 16:31:50 +08:00

seal-use

CI Release Bun Version License: MIT

Bun + TypeScript CLI for pulling Seal enterprise approval context from provider credentials.

The first provider is Hose/合思: appKey, appSecurity, 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.

An incoming Hose/合思 thirdparty.html assistance link can be imported directly; the CLI exchanges its temporary token through Seal SSO, verifies the tenant, and stores the Hose web-session source (closeToken plus staffId). The Seal Bearer is runtime-only.

Quick Install (Standalone Binary)

No Node.js, Bun, or external runtime required. Run the one-line installer:

# macOS & Linux (Bash)
# 国内高速安装(Gitea 镜像源,免代理、秒级完成)
curl -fsSL https://git.ying-qing.cn/gitea/seal-use/raw/branch/main/scripts/install.sh | bash

# Global / GitHub Direct
curl -fsSL https://raw.githubusercontent.com/yunyingk/seal-use/main/scripts/install.sh | bash
# Windows (PowerShell)
# 国内高速安装(Gitea 镜像源,免代理、秒级完成)
irm https://git.ying-qing.cn/gitea/seal-use/raw/branch/main/scripts/install.ps1 | iex

# Global / GitHub Direct
irm https://raw.githubusercontent.com/yunyingk/seal-use/main/scripts/install.ps1 | iex

Or download the native binary directly from GitHub Releases or Gitea Releases:

  • macOS (Apple Silicon): curl -fsSL https://github.com/yunyingk/seal-use/releases/latest/download/seal-use-darwin-arm64 -o /usr/local/bin/seal-use && chmod +x /usr/local/bin/seal-use
  • macOS (Intel): curl -fsSL https://github.com/yunyingk/seal-use/releases/latest/download/seal-use-darwin-x64 -o /usr/local/bin/seal-use && chmod +x /usr/local/bin/seal-use
  • Linux (x86_64): curl -fsSL https://github.com/yunyingk/seal-use/releases/latest/download/seal-use-linux-x64 -o /usr/local/bin/seal-use && chmod +x /usr/local/bin/seal-use
  • Linux (ARM64): curl -fsSL https://github.com/yunyingk/seal-use/releases/latest/download/seal-use-linux-arm64 -o /usr/local/bin/seal-use && chmod +x /usr/local/bin/seal-use
  • Windows (x64): One-liner via PowerShell above, or download seal-use-windows-x64.zip from Releases and extract seal-use-windows-x64.exe.

After installation:

seal-use version          # Check version
seal-use skill install    # Install Agent skill to ~/.agents/skills/seal-use
seal-use mcp-config       # Print an MCP server snippet (for Cursor / Claude Desktop / Codex)
seal-use update           # Self-update (release binary or source checkout)

Source Setup & Development

For local development from source with Bun:

For an already-authenticated Seal-native source, use seal-use corps add-seal-bearer.

Public Usage

This repository is intended to be published as a macOS local agent toolkit. Users run the global seal-use 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:

git clone <repo-url>
cd seal-use
bun install
npm link
seal-use version

npm link creates a symlink from the global npm package directory (npm root -g) to your local checkout. The seal-use 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):

ls -la $(dirname $(which seal-use))/../lib/node_modules/seal-use
# Should show: seal-use -> ../../../../Users/<you>/Code/seal-use

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:

mkdir -p ~/.config/seal-use/enterprises
seal-use corps add-hose-persistent --json '{"name":"企业名称","domain":"https://app.ekuaibao.com","appKey":"...","appSecurity":"...","proxyStaffBizId":"corpId:staffId"}'
seal-use auth diagnose --corp <corpId>
seal-use corps list

corps add-hose-persistent 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 Use page:

seal-use corps add-seal-bearer --json '{"sealUrl":"https://tenant.staging.sealai.cc","token":"seal-bearer-token"}'
seal-use auth diagnose --corp tenant

corps add-seal-bearer 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.

短期 Seal 配置会同时记录 expiresIn(秒数 TTL)和 expiresAt(UTC 秒精度,例如 2026-09-22T05:30:00Z);Hose 持久化配置则以 source.type: "hose" 和 appKey/appSecurity 表示,不写入这两个会话过期字段。

When the Agent receives a cURL copied from an authenticated Hose page, it first attempts to extract durable OpenAPI credentials. If that is not possible, it can import the normalized Hose web session and retain its closeToken plus staffId; Seal access is exchanged at runtime:

seal-use corps add-hose-web-session --json '{"baseUrl":"https://wx2.ekuaibao.com","corpId":"...","accessToken":"..."}'

The Hose accessToken is not a Seal Bearer Token and must not be passed to add-seal-bearer directly. add-hose-web-session stores it as a Hose closeToken together with the Hose staffId; Seal Bearer is obtained only as a runtime SSO session. It does not create or persist Hose OpenAPI credentials.

Import a Hose/合思 assistance link when you do not have OpenAPI app credentials:

seal-use corps add-link "https://wx2.ekuaibao.com/web/thirdparty.html?accessToken=<temporary-token>&ekbCorpId=<corpId>&pageType=home" [--name "企业名称"]

The command accepts HTTPS links from the supported Hose domains, verifies the Seal tenant with /api/v1/auth/me, and writes a Hose source with closeToken and staffId. The incoming token is never printed. Use --overwrite to replace an existing config explicitly.

To generate a Seal delegation link directly from the same incoming Hose link without saving a config:

seal-use auth link --from-link "https://wx2.ekuaibao.com/web/thirdparty.html?accessToken=<temporary-token>&ekbCorpId=<corpId>&pageType=home" --note "客户支持"

The link is treated as a credential and is not echoed by the CLI; only the generated delegation result is returned.

For custom config locations, set SEAL_USE_ENTERPRISES_DIR to a directory containing non-example *.json enterprise config files.

Update an existing checkout:

seal-use update

seal-use update adapts to how it was installed: from a source checkout it runs git pull --ff-only and refreshes dependencies with bun install; a standalone binary downloads the matching GitHub Release asset and replaces itself.

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.

Enterprise configs live only in the global directory ~/.config/seal-use/enterprises (legacy fallback ~/.config/seal-home/enterprises); the project tree carries none.

The canonical plugin skill lives at skills/seal-use. There is no in-repo .agents/skills/seal-use symlink; run seal-use skill install (or seal-use skill install --dir <target>) to place it in a Codex skills directory such as ~/.agents/skills/seal-use when you want Codex to invoke the workflow as $seal-use. The installer includes the full embedded manifest, including report references sourced outside that folder; manually copying only the skill folder omits those references.

Governance Documentation

Three layers of documentation serve distinct audiences and boundaries, each validated by mechanical gates in scripts/governance/:

  • README.md — the user/evaluator entry point. High-level overview, quick installation, architecture, and governance outline (bun run verify:readme).
  • AGENTS.md — the developer contract. How contributors (human or agent) change this codebase: module boundaries, CLI stream/exit-code protocol, testing, release rules (bun run verify:agents-md).
  • skills/seal-use/SKILL.md — the user/agent routing hub. How an agent session uses the shipped skill: bootstrap, credential boundaries, and the terminal ## 参考文档路由 table that routes intents to skills/seal-use/references/*.md, which stay the single source of truth for operational detail (bun run verify:skill-md).
  • Subdirectory readmes — <dir>.readme.md. The root keeps README.md; every other README carries its directory name as a prefix, such as src/src.readme.md and host-infra/host-infra.readme.md (bun run verify:readme-naming).

Workflow rules live in .agents/rules/*.md; the root AGENTS.md indexes them and carries the enforced contract. Engineering and governance scripts live under scripts/, partitioned into scripts/governance/ (automated gates) and root build/release pipelines.

ZCode Plugin

The repository is also a ZCode plugin. Install seal-use from the yingqing-plugins marketplace in Settings → Plugin Management, or add this repository as a local plugin directory while developing. The plugin ships the skills/seal-use skill; it has no MCP surface. For MCP locally, paste the snippet from seal-use mcp-config into your host — it starts seal-use mcp with SEAL_USE_MCP_ENABLED=true, which the server needs before it exposes any tool.

The plugin exposes no MCP tools. The seal_use / seal_use_write tools exist only on the local MCP server started by seal-use mcp (or by whatever host consumes the mcp-config snippet), where they accept the same command syntax as the global CLI.

For a standalone compiled CLI, build and run the binary from a checkout:

bun run build:binary
./dist/bin/seal-use version

CLI

Use the CLI from skills, shell scripts, or agents. Domain commands such as seal-use approval-runs ..., seal-use rules ..., and seal-use documents ... wrap the shared capability registry, so the CLI, the HTTP adapter, and the MCP server all end up running the same capability handler with the same validation.

seal-use version
seal-use config paths
seal-use config get
seal-use config mode stateless
seal-use config mode stateful --corp <corpId>
seal-use corps list
seal-use auth diagnose --corp <corpId>
seal-use approval-runs summary --corp <corpId> --date 2026-06-08 --timezone Asia/Shanghai

CLI output is JSON on stdout. Errors are written to stderr.

Enterprise config lookup:

  • If SEAL_USE_ENTERPRISES_DIR is set, only that directory is loaded.
  • Otherwise the test directory (seal-use config test-dir) and ~/.config/seal-use/enterprises are merged; a ./enterprises folder in the working directory is not read unless an env var points at it.
  • A user-level config overrides a same-ID config from the test directory.

Global enterprise selection is stateless by default. Its configuration is stored in ~/.config/seal-use/config.json (override with SEAL_USE_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-use config mode stateful --corp <corpId> to enable a default enterprise, then seal-use corps switch <corpId> to change it. Run seal-use config mode stateless to require explicit enterprise selection again.

Use seal-use 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.

Enterprise Config

{
  "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",
    "appKey": "hose-app-key",
    "appSecurity": "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-use CLI.

One registry, two doors

Shared approval behavior lives in the business modules under src/domains/seal/; the capability registry under src/domains/seal/capabilities/ dispatches it (src/domains/seal/capabilities.ts re-exports the registry). Two surfaces enter the same handlers, each with its own naming:

Surface Entry Naming
CLI (primary) seal-use <area> <verb> via runCapability Kebab verbs: seal-use context, seal-use rules get
Local MCP server seal_use / seal_use_write gateways that execute a CLI command string Gateway names only — the registry IDs are the allow-list, never advertised as tools

Internally, capability IDs are camelCase (for example sealApprovalContextGet): they are dispatch IDs inside the codebase and they are not MCP tool names — no MCP client will ever see them in tools/list. If you are reading code and an internal capability ID looks like it should be an MCP tool, that instinct is the trap this note exists to prevent; check src/server.ts for the actual (two-gateway) MCP surface.

The MCP server exposes two tools — and only when SEAL_USE_MCP_ENABLED=true, which is what the seal-use mcp-config snippet carries; without that flag tools/list answers with an empty list:

  • seal_use runs read-only commands and refuses anything that mutates tenant state, self-updates, or starts a server.
  • seal_use_write runs the same dispatcher with mutating commands available; confirm the exact command with the user before calling it.

Both take the command as a string:

{
  "command": "version"
}

Both run the same CLI dispatcher as the global binary, so config and update behave exactly as they do on the command line. Write-operation confirmations and explicit enterprise-ID rules continue to be defined by this skill.

CLI-First Architecture

Seal implementations and their tests are grouped by feature: src/domains/seal/rules/ owns local rule files, diffs, mappings, version snapshots, recoding and confirmation tickets; approval-runs/ owns record export and attachments; insight/ owns insight export; replay/ owns Webhook/Hose replay and environment guards; outbound/ owns downstream pushes; enterprise/ owns Seal onboarding and identity resolution; search/ owns cross-resource search; and testing/ owns test-enterprise synchronization. Existing reports/, linter/, material-pack/, doctor/ and regression/ stay separate. Only shared API/types and the capability export remain at the domain root.

All Agent and automation capabilities are accessed through standard seal-use <command> CLI invocations (or through the seal_use / seal_use_write MCP tools passing the command string). Internal domain services output pure, parseable JSON on stdout, with human diagnostics and suggestions routed to stderr.

Key CLI command groups:

  • seal-use corps ...: enterprise tenant management, onboarding, switching, and assistance link intake.
  • seal-use auth ...: authentication diagnostics and Hose provisional authorization links.
  • seal-use rules ...: rule listing, workspace pull/push, offline linting, version publishing, and clearing.
  • seal-use approval-runs ...: run history search, summary by date, detail extraction, attachment inspection & download, cited rules, and Langfuse trace bridge.
  • seal-use simulation ...: test simulation batch creation, polling wait, specifications, and cleanup.
  • seal-use deploy ...: HoseCloud review node requirement inspection, status check, configuration, and sync.
  • seal-use preference ...: decision preferences and thinking depth policies.
  • seal-use webhook ...: webhook integration CRUD and material pack testing.

For rule list commands, prefer seal-use rules count --corp <corpId> or seal-use rules list --corp <corpId> --summary before requesting full rule descriptions. seal-use 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-use rules clear --corp <corpId> --dry-run first, then seal-use rules clear --corp <corpId> --yes to delete the current draft rules and verify the remaining count.

To compact draft rule numbers from 0000, run seal-use rules recode --corp <corpId>. The first call returns an impact preview and an enterprise/environment/draft-bound one-use credential (exit 10), without executing the recode. Inspect the preview, then run the returned nextCommand separately; the credential expires after five minutes, and --yes cannot bypass it. --dry-run only previews. The server determines ordering, and every rule can change number; the verified per-rule mapping is returned after execution. Recode does not publish a version; old rule numbers must be interpreted with their published version. Clearing and test synchronization reset numbering only after verifying an empty draft.

For approval run detail commands, prefer the same commands with explicit --corp <corpId>—for example seal-use approval-runs pick --corp <corpId> --sn <单号> --latest or seal-use 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-use auth hose-link --corp <corpId> --expire 7200, which returns the unredacted getProvisionalAuth URL. For a raw Hose OpenAPI access token from persisted appKey/appSecurity, run seal-use auth hose-openapi-token --corp <corpId>; stdout returns token, expiresAt, and cached, and --force skips the local cache to mint a new token.

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-use .... 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 seal_use (read-only) and seal_use_write (mutating) pair; 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-use approval-runs summary --corp <corpId> ... instead of reading long approval-runs search output manually.
  • Keep broad search tools compact by default. Add explicit opt-in flags such as include-bridge 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:

# 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-use/SKILL.md;
  4. Prints the exact git commit and git tag commands ready to execute.

2. Tag & Publish Workflow

  1. Run the automated protected-branch release wizard:
    bun run release patch
    
    Or manually merge the release PR to main, fast-forward local main, and push the annotated tag to origin:
    git tag -a vX.Y.Z -m "🚀 版本更新文案与主要特性说明"
    git push origin refs/tags/vX.Y.Z
    

CI & Promotion Pipeline:

  • GitHub Actions triggers automatically upon pushing a v* tag to origin;
  • Cross-compiles standalone binaries for 5 target platforms (macOS Apple Silicon/Intel, Linux x86_64/ARM64, Windows x64) and publishes them to GitHub Releases;
  • WSL seal-use-release-sync.timer polls the latest GitHub Release and promotes all assets to Gitea Releases (host-infra/host-infra.readme.md).
S
Description
No description provided
Readme MIT
44 MiB
0 Stars 1 Watchers 0 Forks
v0.11.23
Latest
2026-11-19 17:59:50 +08:00
Languages
TypeScript 97.8%
Shell 1.2%
JavaScript 0.5%
PowerShell 0.4%