Files
seal-use/skills/seal-use/references/cli.md
T
gitea 081ff0f8aa Refactor material-pack: [附件] column prefix + @ dir annotation + strict path validation
- Replace filename-heuristic attachment matching with explicit [附件] column declaration
- AttachmentGroup replaces MaterialAttachmentEntry: uses paths[] instead of entries[]
- parseMaterialWorkbook now exports DeclaredAttachment and full Parsed type including
  documentAttachments, expenseAttachments, personAttachments per row
- buildAttachmentPlans enforces strict bidirectional validation:
  1. Every Excel [附件] path must exist in ZIP
  2. Every ZIP file must be declared in some [附件] column
- validateDocIdDirectories now strips @annotation suffix when matching documentIds
- injectAttachmentPlan updated to work with new AttachmentGroup.paths API
- pushMaterialPack iterates group.paths for uploads, adding stderr diagnostics
- Key deduplication applied at parse time (deduplicateKeys)
- Tests updated: [附件] column fixtures, bidirectional validation error tests,
  @ annotation matching test, preview injection test
- Skill docs updated: Material Pack Workflow section in references/cli.md
- Version bumped to 0.10.12
2026-09-07 18:26:21 +08:00

19 KiB

Seal Use CLI Reference

Run from any directory after installing the global CLI:

seal-use <command>

Enterprise config lookup:

  • If SEAL_USE_ENTERPRISES_DIR is set, only that directory is loaded.
  • Otherwise ./enterprises and ~/.config/seal-use/enterprises are merged.
  • User-level configs override same-ID local configs.

Enterprise selection is stateless by default. Commands that access an enterprise require --corp <corpId> unless stateful mode is explicitly enabled:

seal-use config mode stateful --corp <corpId>
seal-use corps switch <corpId>
seal-use config mode stateless

The global mode is stored in ~/.config/seal-use/config.json; set SEAL_USE_CONFIG_FILE to override that path. The legacy current-corp file is not read.

Stream & Exit Code Contract

  • stdout: Pure, deterministic JSON for machine/Agent parsing.
  • stderr: Diagnostics, probing logs, and Next-Step Command Suggestions (e.g. 👉 Next action: ...).
  • Exit Code: 0 on success, non-zero (e.g. 1) on failure to trigger Agent error self-remediation.

Top-Level Commands

seal-use version
seal-use config paths
seal-use config get
seal-use config mode <stateful|stateless> [--corp <corpId>]
seal-use config test-dir [<path>|--clear]
seal-use config lint <enable|disable|status> [--linter <name>] [--min-score <score>]
seal-use rules pull [--corp <corpId>] [--version <id|num|latest>] [--out <file>]
seal-use rules lint [--file <path>] [--corp <corpId>] [--linter <name|path>] [--version <num>] [--code <code>] [--min-score <score>] [--summary]
seal-use rules push [--file <path>] [--corp <corpId>] [--publish] [--version-name <name>] [--dry-run|--yes]
seal-use service <start|stop|restart|status|logs> [--port 8787] [--host 127.0.0.1] [--lines 50]
seal-use http [--port 8787] [--host 127.0.0.1]
seal-use serve [--port 8787]
seal-use update
seal-use tools list
seal-use corps list [--corp <corpId>]
seal-use corps current [--corp <corpId>]
seal-use corps switch <corpId>
seal-use corps add-hose --json '{"name":"企业名称","domain":"https://app.ekuaibao.com","appKey":"...","appSecurity":"...","proxyStaffBizId":"corpId:staffId"}'
seal-use corps add-seal --json '{"sealUrl":"https://tenant.sealai.cc","token":"seal-bearer-token"}'
seal-use corps add-link <https://.../web/thirdparty.html?...> [--name <customName>] [--overwrite]
seal-use auth diagnose [--corp <corpId>]
seal-use auth hose-link [--corp <corpId>] [--expire 7200]
seal-use delegation list [--corp <corpId>]
seal-use delegation create [--note <note>] [--from-link <url>] [--corp <corpId>]
seal-use delegation revoke <tokenId> [--corp <corpId>]
seal-use users create --name <name> --phone <phone> [--dept <deptId>] [--corp <corpId>]
seal-use users reset-password <userId> [--corp <corpId>]
seal-use users get <userId> [--corp <corpId>]
seal-use users delete <userId> [--corp <corpId>]
seal-use llm config [--corp <corpId>]
seal-use llm providers [--corp <corpId>]
seal-use permissions available [--corp <corpId>]
seal-use permissions configs [--corp <corpId>]
seal-use billing status [--corp <corpId>]
seal-use billing plans [--corp <corpId>]
seal-use billing features [--corp <corpId>]
seal-use webhook list [--query <text>] [--show-secret] [--corp <corpId>]
seal-use webhook get|find <idOrName> [--show-secret] [--corp <corpId>]
seal-use webhook add --name <name> --result-url <url> [--mode assisted|semi_automatic|fully_automatic] [--auto-approval-rate 60] [--secret <secret>] [--corp <corpId>]
seal-use webhook update <idOrName> [--name <name>] [--result-url <url>] [--mode assisted|semi_automatic|fully_automatic] [--auto-approval-rate 60] [--secret <secret>|--rotate-secret] [--corp <corpId>]
seal-use webhook delete <idOrName> --yes [--corp <corpId>]
seal-use deploy hosecloud requirements [--corp <corpId>]
seal-use deploy hosecloud list [--corp <corpId>]
seal-use deploy hosecloud get [<sign-key>] [--corp <corpId>]
seal-use deploy hosecloud status [--corp <corpId>]
seal-use deploy hosecloud configure --json '{...}' [--corp <corpId>]
seal-use deploy hosecloud sync [<sign-key>] [--auto] [--corp <corpId>]
seal-use preference get [--corp <corpId>]
seal-use preference decision update --json '{"explicitApprove":"..."}' [--corp <corpId>]
seal-use preference thinking-depth set --default <medium|high> [--corp <corpId>]
seal-use preference thinking-depth policies list [--corp <corpId>]
seal-use preference thinking-depth policies upsert --json '{...}' [--corp <corpId>]
seal-use preference thinking-depth policies remove <policyId> [--corp <corpId>]
seal-use source config [--corp <corpId>]
seal-use tool <toolName> [--corp <corpId>] [--json '{"key":"value"}']
seal-use approval-runs summary --corp <corpId> [--date YYYY-MM-DD] [--timezone Asia/Shanghai]
seal-use approval-runs stats --corp <corpId> [--since 3months] [--dedupe-by sourceDocumentSN|sourceDocumentId|id]
seal-use approval-runs count --corp <corpId> [--status APPROVED]
seal-use approval-runs export --corp <corpId> [--start <YYYY-MM-DD|ms>] [--end <YYYY-MM-DD|ms>] [--limit <n>] [--downloads] [--out <file>]
seal-use approval-runs search --corp <corpId> [--query text] [--limit 20] [--includeBridge true]
seal-use approval-runs get <recordId> --corp <corpId> [--fields metadata|document.fields,result.summary] [--output-file file.json]
seal-use approval-runs attachments <recordId> --corp <corpId>
seal-use approval-runs attachments download <recordId> [--all] [--name <name>] [--out-dir <dir>] --corp <corpId>
seal-use approval-runs result <recordId> --corp <corpId> [--summary]
seal-use approval-runs url --corp <corpId>
seal-use approval-runs url <recordId> --corp <corpId>
seal-use approval-runs url --sourceDocumentSN <sourceDocumentSN> --corp <corpId>
seal-use approval-runs bridge --corp <corpId> [--sourceDocumentSN <sourceDocumentSN>]
seal-use simulation batch-records <batchId> --corp <corpId>
seal-use simulation create --mode hosecloud --flow-ids "B26017701,B26022501" [--reject-node 财务] [--thinking-depth default|medium|high] [--skip-invoice-generation|--skip-invoice-generation false] --corp <corpId>
seal-use simulation create --mode material_pack --package-ids <materialPackageId> [--template-id conference_reimbursement_v1] [--schema-config file.json] --corp <corpId>
seal-use simulation create --source-system weaver --request-ids "req-01,req-02" --corp <corpId>
seal-use simulation wait <batchId> [--timeout 10m] [--poll-interval 2s] --corp <corpId>
seal-use simulation clean <batchId> --corp <corpId>
seal-use simulation specifications [--integration <sign-key>] --corp <corpId>
seal-use simulation list [--limit 50] --corp <corpId>
seal-use simulation get <batchId> --corp <corpId>
seal-use simulation templates --corp <corpId>
seal-use simulation integrations --corp <corpId>
seal-use simulation package-upload <材料包.zip> --corp <corpId>

CLI Command Overview

seal-use version returns:

{
  "name": "seal-use",
  "version": "<package version>"
}

seal-use service <start|stop|restart|status|logs> manages the persistent background service daemon with embedded HTTP server (serving /docs, /openapi.json, and POST /api/cli). status returns the PID, version, host, port, active HTTP URL, state directory, PID file, and log file.

seal-use update updates the git checkout, runs bun install, and restarts the local service if it was running.

Identity and session:

  • seal-use auth diagnose --corp <corpId>
  • seal-use corps list
  • seal-use corps current

Approval rule maintenance:

  • seal-use rules count [--corp <corpId>]
  • seal-use rules list --summary [--corp <corpId>]
  • seal-use rules pull [--corp <corpId>] [--version <id|num|latest>] [--out <file>]
  • seal-use rules lint [--file <path>] [--corp <corpId>] [--linter <name|path>] [--version <num>] [--code <code>] [--min-score <score>] [--summary]
  • seal-use rules push [--file <path>] [--corp <corpId>] [--publish] [--version-name <name>] [--dry-run|--yes]
  • seal-use rules clear [--corp <corpId>] [--dry-run|--yes]

Approval run lightweight queries:

  • seal-use approval-runs get <recordId> --corp <corpId> --fields metadata
  • seal-use approval-runs get <recordId> --corp <corpId> --summary
  • seal-use approval-runs pick --corp <corpId> --sn <单号> --batch <batchId> --latest
  • seal-use approval-runs document-summary <recordId> --corp <corpId>
  • seal-use approval-runs cited-rules <recordId> --corp <corpId>
  • seal-use approval-runs get <recordId> --corp <corpId> --fields document.fields,result.summary
  • seal-use approval-runs attachments <recordId> --corp <corpId> --summary
  • seal-use approval-runs attachments download <recordId> [--all] [--name <name>] [--out-dir <dir>] --corp <corpId>
  • seal-use approval-runs result <recordId> --corp <corpId> --summary

Approval knowledge documents & style:

  • seal-use rules get --corp <corpId> --version <number> --code '#0038'
  • seal-use rules get --corp <corpId> --record-id <recordId> --runtime-id rule-205

Webhook integrations:

  • seal-use webhook ready [<材料包.zip|信息表.xlsx>] [--corp <corpId>]
  • seal-use webhook status [<材料包.zip|信息表.xlsx>] [--corp <corpId>]
  • seal-use webhook list [--query <text>] [--show-secret] [--corp <corpId>]
  • seal-use webhook get|find <idOrName> [--show-secret] [--corp <corpId>]
  • seal-use webhook add --name <name> --result-url <url> [--mode assisted|semi_automatic|fully_automatic] [--auto-approval-rate 60] [--secret <secret>] [--corp <corpId>]
  • seal-use webhook update <idOrName> [--name <name>] [--result-url <url>] [--mode assisted|semi_automatic|fully_automatic] [--auto-approval-rate 60] [--secret <secret>|--rotate-secret] [--corp <corpId>]
  • seal-use webhook delete <idOrName> --yes [--corp <corpId>]
  • seal-use webhook material-pack preview <材料包.zip|信息表.xlsx> --corp <corpId>
  • seal-use webhook material-pack push <材料包.zip|信息表.xlsx> [--webhook <idOrName>] --corp <corpId>

Webhook writes read the current AI approval config and POST the merged full config back to api/v1/agent/ai-approval/config, preserving non-Webhook integrations. List/get mask secret by default; add returns the generated secret once.

Approval runs, simulations, and Langfuse bridge:

  • seal-use approval-runs search --corp <corpId> [--query <text>] [--limit 20]
  • seal-use approval-runs summary --corp <corpId> [--date YYYY-MM-DD] [--timezone Asia/Shanghai]
  • seal-use approval-runs bridge --corp <corpId> [--sourceDocumentSN <sn>]
  • seal-use simulation create --mode hosecloud --flow-ids ... --corp <corpId>
  • seal-use simulation wait <batchId> --corp <corpId>
  • seal-use simulation clean <batchId> --corp <corpId>
  • seal-use simulation list --corp <corpId>
  • seal-use simulation get <batchId> --corp <corpId>
  • seal-use simulation batch-records <batchId> --corp <corpId>
  • seal-use simulation templates --corp <corpId>
  • seal-use simulation integrations --corp <corpId>

Common Examples

Add and verify a Hose enterprise:

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

Force-write a Hose config without verification:

seal-use corps add-hose --json '{"name":"企业名称","domain":"https://app.ekuaibao.com","appKey":"...","appSecurity":"...","proxyStaffBizId":"corpId:staffId","force":true}'

Diagnose auth failures:

seal-use auth diagnose --corp <corpId>

The diagnostic stages are hose.openapi, hose.provisional, seal.sso, and seal.whoami. Tokens are omitted from output.

Search approval content:

seal-use tool seal_approval_search --corp <corpId> --json '{"keywords":["关键词"],"matchMode":"any","maxResults":20}'

Get aggregated approval context:

seal-use tool seal_approval_context_get --corp <corpId> --json '{"documentLimit":20}'

Create a draft approval rule:

seal-use tool seal_approval_rule_create --corp <corpId> --json '{"description":"规则描述","scope":"适用场景","strictness":"SHOULD_FOLLOW"}'

Update an approval document:

seal-use tool seal_approval_document_update --corp <corpId> --json '{"documentId":"doc-id","content":"Markdown 内容"}'

Summarize one local date:

seal-use approval-runs summary --corp <corpId> --date 2026-06-09 --timezone Asia/Shanghai --limit 100

Find a run and include Langfuse bridge rows:

seal-use approval-runs search --corp <corpId> --query <sourceDocumentSN> --limit 20 --includeBridge true

Resolve Langfuse trace/session hints:

seal-use approval-runs bridge --corp <corpId> --sourceDocumentSN <sourceDocumentSN>

模拟测试批次(模拟发布闭环)创建与查询:

# 合思指定单号: 创建批次(响应只含 batchId)
seal-use simulation create --mode hosecloud --flow-ids "B26017701,B26022501" --reject-node 财务 --thinking-depth medium --skip-invoice-generation --corp <corpId>
# 材料包导入: 先上传材料包 ZIP(服务端解析并返回 schemaConfig), 再用返回的 id 发起
seal-use simulation package-upload 测试材料包.zip --corp <corpId>
seal-use simulation create --mode material_pack --package-ids <materialPackageId> --template-id conference_reimbursement_v1 --schema-config schema.json --corp <corpId>
# 预留: 其他模式参数通过 --json 透传(如时间范围 startTime/endTime)
seal-use simulation create --mode hosecloud --flow-ids "B26017701" --json '{"startTime":0,"endTime":0}' --corp <corpId>
# 创建后轮询批次状态与记录
seal-use simulation list --limit 50 --corp <corpId>
seal-use simulation get <batchId> --corp <corpId>
seal-use simulation batch-records <batchId> --corp <corpId>
seal-use simulation templates --corp <corpId>
seal-use simulation integrations --corp <corpId>

Write Operation Payloads

Create a rule:

{
  "description": "规则描述",
  "scope": "适用场景",
  "strictness": "MUST_FOLLOW | SHOULD_FOLLOW | SUGGESTION"
}

Update a rule:

{
  "ruleId": "rule-id",
  "description": "可选",
  "scope": "可选",
  "strictness": "SHOULD_FOLLOW"
}

Publish a rule version:

{
  "versionName": "版本名称"
}

Create a document:

{
  "title": "标题",
  "purpose": "用途",
  "content": "Markdown 内容",
  "contentType": "text/markdown",
  "status": "可选",
  "scenarios": ["场景"],
  "tags": ["标签"]
}

Update a document:

{
  "documentId": "doc-id",
  "title": "可选",
  "purpose": "可选",
  "content": "可选",
  "enabled": true,
  "scenarios": ["可选"],
  "tags": ["可选"]
}

Update style preferences:

{
  "tone": "可选",
  "language": "可选",
  "detailLevel": "可选",
  "outputFormat": "可选",
  "examples": ["可选"],
  "prohibitedPhrases": ["可选"],
  "customInstructions": "可选"
}

Material Pack Workflow

A material pack (材料包) is a ZIP file that bundles an Excel information sheet (信息表.xlsx) with attachments organised by document ID. It is the primary input to the Webhook-based AI approval ingestion pipeline.

ZIP structure convention

材料包.zip
├── 信息表.xlsx                         ← must exist at ZIP root
├── BX20260826003/                      ← root dir name = documentId (or documentId@annotation)
│   ├── 合同协议/
│   │   └── 采购合同.pdf
│   └── 支付凭证/
│       └── 支付宝交易明细.pdf
└── BX20260826004@重新提交v2/           ← @annotation is stripped when matching documentId
    └── 发票/
        └── 增值税专用发票.pdf
  • The root directory name must equal the documentId OR start with documentId@ (the @ separates an optional annotation ignored during matching).
  • 信息表.xlsx at the ZIP root is the only file not associated with any document directory.

Excel column convention

Column type Naming Purpose
Regular column Any header (e.g. 会议编号, 总金额) Standard document fields
Attachment column Header starts with [附件] (e.g. [附件]合同协议) Declares attached files for this row
  • The [附件] prefix is stripped to produce the field label sent to Seal.
  • The cell value contains full ZIP-relative path(s) to the declared files (multiple paths separated by newline, comma, or semicolon).
  • Example: column [附件]合同协议, cell value BX20260826003/合同协议/采购合同.pdf

Sheet → document level mapping

Excel sheet Maps to
First sheet (main / 会议) Root document categoryFields
费用明细表 (has 报销金额 column) Per-row entries in mingxi_list
劳务明细 (has 姓名 column) Per-person entries in daoshi_list

Strict bidirectional validation

Before pushing or previewing, the system enforces:

  1. Excel → ZIP: Every path declared in an [附件] column cell must exist as a ZIP entry. Error: Excel 声明的附件路径在 ZIP 中不存在: <path>
  2. ZIP → Excel: Every ZIP file (excluding 信息表.xlsx) must be declared in at least one [附件] column. Error: ZIP 中的文件未在 Excel 任何 [附件] 列中声明: <path>
  3. documentId ↔ ZIP root: Every documentId in the Excel main sheet must have a matching ZIP root dir (exact match or documentId@annotation). Errors: Excel 会议编号「X」在 ZIP 中找不到对应的根目录... / ZIP 根目录对应的编号「X」在信息表中找不到对应的会议编号

All validation errors are collected and reported together in a single MaterialPackValidationError.

CLI usage

# Check environment readiness and optionally pre-validate the material pack
seal-use webhook ready [--file <pack.zip>] [--corp <corpId>]

# Dry-run: local parse & validation only, no network calls, returns preview JSON
seal-use webhook material-pack preview <pack.zip> --corp <corpId>

# Upload attachments and push documents via inbound Webhook
seal-use webhook material-pack push <pack.zip> [--webhook <nameOrId>] --corp <corpId>
# When there is exactly one webhook channel, --webhook can be omitted (auto-locked)

Error messages reference

Error message Meaning Fix
Excel 声明的附件路径在 ZIP 中不存在: <path> Cell value references a file not in ZIP Add the file to ZIP at exactly that path
ZIP 中的文件未在 Excel 任何 [附件] 列中声明: <path> ZIP contains a file not referenced by any [附件] column Add an [附件] column entry or remove the file from ZIP
Excel 会议编号「X」在 ZIP 中找不到对应的根目录 No ZIP root dir matches documentId X Rename the ZIP folder to match the documentId
ZIP 根目录对应的编号「X」在信息表中找不到 ZIP folder has no matching documentId in Excel Remove the folder or add the document to Excel
ZIP 根目录缺少信息表.xlsx No 信息表.xlsx found at ZIP root Add the Excel file to the ZIP root
附件上传失败 <status> Network/server error during file upload Check webhook URL, secret, and server availability

Failure Handling

  • CLI commands are short-lived processes. In-memory auth/search caches only live for that single process. Use seal-use service restart after updates so the optional local service picks up new code.
  • If no run is found by sourceDocumentSN, retry with sourceDocumentId or a broader query.
  • If date-based summaries look wrong, pass --timezone Asia/Shanghai and an explicit --date.
  • If langfuseTraceId is missing, use langfuseSessionFallback.
  • If a write operation fails, report the raw JSON error and do not retry with guessed payloads.