import { normalizeCliArea } from "./area-aliases.js"; import type { ParsedArgs } from "./types.js"; import { usageError } from "../core/errors.js"; export interface CommandOptionHelp { flag: string; description: string; } export interface CommandHelp { name: string; aliases?: string[]; group?: string; summary?: string; usage: string[]; options?: CommandOptionHelp[]; description?: string; } export interface AreaHelp { area: string; title: string; description?: string; groupOrder?: string[]; commands: CommandHelp[]; } export const HELP_REGISTRY: AreaHelp[] = [ { area: "corps", title: "Enterprise and tenant management", description: "Manage enterprise configurations, environment modes, test bindings, and syncing.", groupOrder: ["企业接入", "发现与选择", "企业配置", "测试配对与验证", "Hose 专属能力"], commands: [ { name: "list", group: "发现与选择", summary: "List configured enterprises sorted by 7-day usage frequency", usage: ["seal-use corps list [query] [--all] [--limit ] [--env ] [--strict] [--corp ]"], options: [ { flag: "--all", description: "Display all configured enterprises without the default 10-item limit" }, { flag: "--limit ", description: "Maximum number of enterprises to display (defaults to 10)" }, { flag: "--env ", description: "Filter enterprises by environment ('production' or 'test')" }, { flag: "--strict", description: "Use strict exact substring matching instead of default soft fuzzy search" } ] }, { name: "search", aliases: ["find"], group: "发现与选择", summary: "Search configured enterprises with intelligent soft fuzzy matching", usage: ["seal-use corps search [--env ] [--strict]"], options: [ { flag: "--env ", description: "Filter enterprises by environment ('production' or 'test')" }, { flag: "--strict", description: "Use strict exact substring matching instead of default soft fuzzy search" } ], description: "Searches enterprise ID, name, staff ID, domain, tenant slug, environment, or bindings. Uses soft search by default (case-insensitive, Chinese homophones, front/back nasal vowels, initials, typo/missing letter tolerance)." }, { name: "get", aliases: ["show"], group: "发现与选择", summary: "Get rich details and configuration of an enterprise", usage: ["seal-use corps get "], description: "Retrieves complete enterprise details (URLs, tenant slugs, custom headers/cookies, staff IDs, relations, config file path) with sensitive secrets safely redacted." }, { name: "current", group: "发现与选择", summary: "Show active enterprise in stateful mode", usage: ["seal-use corps current [--corp ]"] }, { name: "switch", group: "发现与选择", summary: "Switch default active enterprise", usage: ["seal-use corps switch "] }, { name: "mark", group: "企业配置", summary: "Mark enterprise environment as production or test", usage: ["seal-use corps mark --env [--confirm]"], options: [ { flag: "--env ", description: "Target environment: 'production' or 'test' (required)" }, { flag: "--confirm", description: "Confirm the environment update (required)" } ], description: "Explicitly updates an enterprise's environment tag. Requires --confirm to prevent accidental changes." }, { name: "rename", group: "企业配置", summary: "Rename an enterprise display name", usage: ["seal-use corps rename --name "], options: [ { flag: "--name ", description: "New human-readable enterprise name (required)" } ], description: "Safely updates the display name of a configured enterprise without modifying underlying files manually." }, { name: "bind-test", group: "测试配对与验证", summary: "Bind a production enterprise to a test enterprise (1-to-1 association)", usage: [ "seal-use corps bind-test [--confirm] [--force]", "seal-use corps bind-test --corp [--confirm] [--force]" ], options: [ { flag: "--confirm", description: "Explicitly confirm binding and tag test environment (required)" }, { flag: "--force", description: "Force re-binding if the production enterprise is already bound" }, { flag: "--corp ", description: "Specify production enterprise ID or name" } ], description: "Establishes a strict 1-to-1 association between a production enterprise and a test enterprise. Automatically marks the test enterprise with environment 'test'." }, { name: "unbind-test", group: "测试配对与验证", summary: "Unbind a production and test enterprise association", usage: ["seal-use corps unbind-test [] [--confirm]"], options: [ { flag: "--confirm", description: "Explicitly confirm unbinding both sides (required)" }, { flag: "--corp ", description: "Specify enterprise ID or name" } ], description: "Removes the 1-to-1 test association from both the production enterprise and the test enterprise." }, { name: "sync-test", group: "测试配对与验证", summary: "Synchronize rules and preferences from production to test enterprise", usage: ["seal-use corps sync-test [] [--dry-run] [--yes] [--version-name ]"], options: [ { flag: "--dry-run", description: "Preview sync diff without making network mutations (default)" }, { flag: "--yes", description: "Execute synchronization and publish new rule version on test enterprise" }, { flag: "--version-name ", description: "Custom version name for published test rule version" }, { flag: "--corp ", description: "Specify production enterprise ID or name" } ], description: "Overwrites test enterprise decision preferences with production preferences, syncs production draft rules to test enterprise, and immediately publishes a new version on the test enterprise. Production rules remain safe in draft state." }, { name: "replay-test", group: "测试配对与验证", summary: "Replay approval records from production enterprise to bound test enterprise via Webhook", usage: [ "seal-use corps replay-test [] [--record-id ] [--sn ] [--limit ] [--status ] [--webhook ] [--sn-suffix ] [--dry-run] [--confirm|--yes] [--force]" ], options: [ { flag: "", description: "Production enterprise ID (default: active enterprise)" }, { flag: "--record-id ", description: "Replay a specific approval run ID" }, { flag: "--sn ", description: "Replay a specific document SN" }, { flag: "--limit ", description: "Batch replay latest N records from production (default: 1)" }, { flag: "--status ", description: "Filter records by status (e.g. completed, failed, rejected)" }, { flag: "--webhook ", description: "Target Webhook integration on test enterprise" }, { flag: "--sn-suffix ", description: "Optional suffix appended to documentSN" }, { flag: "--dry-run", description: "Preview payload without sending" }, { flag: "--confirm, --yes", description: "Confirm live replay and send the payload" }, { flag: "--force", description: "Allow replay without a bound test enterprise or into a non-test target" } ], description: "Pulls production approval records from the production enterprise and replays them into the bound test enterprise's Webhook channel for rule verification." }, { name: "add-hose-persistent", group: "企业接入", summary: "Add a durable Hose/Ekuaibao enterprise configuration", usage: ["seal-use corps add-hose-persistent --json '{\"name\":\"企业名称\",\"domain\":\"https://app.ekuaibao.com\",\"appKey\":\"...\",\"appSecurity\":\"...\",\"proxyStaffBizId\":\"corpId:staffId\"}'"], description: "使用长期 Hose OpenAPI 凭据接入企业并持久化配置。" }, { name: "add-seal-bearer", group: "企业接入", summary: "Add a native Seal enterprise from a Bearer session", usage: ["seal-use corps add-seal-bearer --json '{\"sealUrl\":\"https://tenant.sealai.cc\",\"token\":\"seal-bearer-token\"}'"], description: "使用 Seal Bearer Token 接入原生 Seal 企业。" }, { name: "add-hose-web-session", group: "企业接入", summary: "Import a temporary Hose web session and exchange it for a Seal session", usage: ["seal-use corps add-hose-web-session --json '{\"baseUrl\":\"https://wx2.ekuaibao.com\",\"corpId\":\"...\",\"staffId\":\"...\",\"accessToken\":\"...\"}'"], options: [ { flag: "--name ", description: "Optional custom name for the enterprise" }, { flag: "--domain ", description: "Hose web-session base URL (alias: --base-url)" }, { flag: "--corp-id ", description: "Hose corporation ID" }, { flag: "--staff-id ", description: "Hose web-session staff ID (normally discovered automatically)" }, { flag: "--access-token ", description: "Hose web-session accesstoken" }, { flag: "--overwrite", description: "Overwrite existing enterprise config" }, { flag: "--dry-run", description: "Exchange and verify the session without saving local config" } ], description: "将 Agent 从合思后台 cURL 提取出的 accesstoken 保存为 Hose closeToken,并绑定 corpId/staffId;调用 Seal 能力时再经 Hose→Seal SSO 换取短期 Seal Bearer。不提取或持久化 OpenAPI appKey/appSecurity。" }, { name: "add-link", group: "企业接入", summary: "Import enterprise configuration from a Seal delegation link or Hose assistance link", usage: [ "seal-use corps add-link [--name ] [--elevate-hose] [--app-key ] [--key-id ] [--overwrite] [--dry-run]" ], options: [ { flag: "--name ", description: "Optional custom name for the enterprise" }, { flag: "--dry-run", description: "Preview link resolution and tenant metadata without saving" }, { flag: "--elevate-hose", description: "【明确提权】从合思协助链接提取 OpenAPI 密钥并将临时会话升级为长期标准配置" }, { flag: "--app-key ", description: "企业存在多套密钥时,指定使用的 appKey" }, { flag: "--key-id ", description: "企业存在多套密钥时,指定使用的 keyId" }, { flag: "--overwrite", description: "Overwrite existing enterprise config" } ] }, { name: "probe-hose", group: "Hose 专属能力", summary: "Probe Hose domains and discover enterprise identity", usage: ["seal-use corps probe-hose --json '{\"appKey\":\"...\",\"appSecurity\":\"...\",\"domain\":\"https://...\"}'"], description: "验证合思凭证、探测可用域名并发现企业与角色信息;不写入本地企业配置。" }, { name: "hose-staffs", group: "Hose 专属能力", summary: "Discover Hose staff candidates by role", usage: ["seal-use corps hose-staffs --json '{\"appKey\":\"...\",\"appSecurity\":\"...\",\"role\":\"admin\"}'"], description: "按合思角色查询员工候选;手机号默认脱敏,供 add-hose-persistent 选择管理员。" }, { name: "hose-extract-keys", aliases: ["extract-keys", "extract-key", "extract-hose-keys"], group: "Hose 专属能力", summary: "【合思子域提权】从合思协助链接提取 OpenAPI 开发者密钥 (appKey/appSecurity)", usage: [ "seal-use corps hose-extract-keys [--reveal] [--save] [--app-key ] [--key-id ] [--name ] [--overwrite]" ], options: [ { flag: "--reveal, -r", description: "显式揭示完整 appSecurity 明文(默认脱敏保护)" }, { flag: "--save", description: "【提权升级】将提取到的合思 OpenAPI 密钥保存为长期标准配置" }, { flag: "--app-key ", description: "存在多套密钥时指定使用的 appKey" }, { flag: "--key-id ", description: "存在多套密钥时指定使用的 keyId" }, { flag: "--name ", description: "Custom enterprise name when saving" }, { flag: "--overwrite", description: "Overwrite existing enterprise config" } ], description: "专属于合思 (Hose/合思云/易快报) 子域的能力。利用协助链接中的内部权限读取 OpenAPI 密钥,将临时会话提权为标准开发者凭据。非合思渠道企业不支持。" }, { name: "hose-keys", aliases: ["keys"], group: "Hose 专属能力", summary: "【合思子域】查看企业已配置的合思 OpenAPI 密钥,或从协助链接中提取", usage: [ "seal-use corps hose-keys [ | ] [--reveal] [--save] [--app-key ]" ], options: [ { flag: "--reveal, -r", description: "显式揭示完整 appSecurity 明文(默认脱敏保护)" }, { flag: "--save", description: "从协助链接提取并保存为标准配置" }, { flag: "--app-key ", description: "多套密钥时指定目标 appKey" } ] }, ] }, { area: "rules", title: "Approval rules management", description: "Query, search, edit, publish, version, lint, import, and export approval audit rules. Read commands default to the current draft; pass --version latest (or --version ) to inspect published versions.", commands: [ { name: "count", summary: "Count approval rules (defaults to current draft; pass --version latest for latest published version)", usage: ["seal-use rules count [--version ] [--corp ]"] }, { name: "list", summary: "List approval rules (defaults to current draft; pass --version latest for latest published version)", usage: ["seal-use rules list [--version ] [--summary] [--limit 20] [--offset 0] [--output-file ] [--corp ]"], options: [ { flag: "--version ", description: "Read from a published version instead of current draft ('latest' for latest published version)" }, { flag: "--summary", description: "Output compact summary fields (code, status, strictness, scope, updatedAt)" }, { flag: "--limit ", description: "Number of rules to fetch (default: 20)" }, { flag: "--offset ", description: "Offset index for pagination" }, { flag: "--full", description: "Allow large payloads beyond standard size limits" }, { flag: "--output-file ", description: "Write the complete JSON payload to a file" } ] }, { name: "get", summary: "Get single rule by code (defaults to current draft; pass --version latest or --record-id for published snapshots)", usage: [ "seal-use rules get [--version ] [--record-id ] [--corp ]" ] }, { name: "search", summary: "Search rules by keyword (defaults to current draft; pass --version latest for latest published version)", usage: ["seal-use rules search [--version ] [--maxResults 20] [--corp ]"] }, { name: "create", summary: "Create a new draft approval rule", usage: ["seal-use rules create --description --scope [--strictness ] [--description-file ] [--corp ]"] }, { name: "update", summary: "Update a draft approval rule by code", usage: ["seal-use rules update [--description |--description-file ] [--scope ] [--strictness ] [--corp ]"] }, { name: "delete", summary: "Delete a draft approval rule by code", usage: ["seal-use rules delete --yes [--corp ]"] }, { name: "publish", summary: "Publish current draft rules as a new formal version", usage: ["seal-use rules publish [--corp ]"] }, { name: "versions", summary: "List published rule versions", usage: ["seal-use rules versions [--corp ]"] }, { name: "version", summary: "Inspect a specific published rule version", usage: ["seal-use rules version [--corp ]"] }, { name: "diff", summary: "Compare two published rule versions", usage: ["seal-use rules diff [--code ] [--include-unchanged] [--full] [--corp ]"], options: [ { flag: "--code ", description: "Compare only one rule code" }, { flag: "--include-unchanged", description: "Include unchanged rules in the structured changes list" }, { flag: "--full", description: "Expand an oversized diff; small diffs are returned in full by default" }, { flag: "--format unified|json", description: "Return unified diff text together with structured metadata" } ] }, { name: "lint", summary: "Lint rule text or rule file using builtin or custom linter", usage: ["seal-use rules lint [--file ] [--linter ] [--version ] [--code ] [--min-score ] [--level all|error|warning] [--summary] [--corp ]"] }, { name: "linters", summary: "List available official and custom rule linters and directory locations", usage: ["seal-use rules linters [--corp ]"] }, { name: "pull", summary: "Export rules to local JSON file", usage: ["seal-use rules pull [--version ] [--out ] [--corp ]"] }, { name: "push", summary: "Push rules from local JSON file to enterprise draft space (with step recovery & status check)", usage: [ "seal-use rules push [--file ] [--publish] [--version-name ] [--dry-run|--yes] [--corp ]", "seal-use rules push status [--file ] [--corp ]" ] }, { name: "clear", summary: "Clear all draft rules from enterprise", usage: ["seal-use rules clear [--dry-run|--yes] [--corp ]"] }, { name: "recode", summary: "Preview consecutive rule numbering, then execute with a one-use confirmation code", usage: ["seal-use rules recode [--dry-run] --corp "], description: "首次运行只返回影响预览、一次性凭证和 nextCommand,不执行重排;核对后另一次调用返回的命令才会生效。凭证绑定企业、环境和草稿,5 分钟有效且只能使用一次。--yes/--confirm 不能跳过该流程。--dry-run 只预览,不签发凭证。服务端决定编号顺序,所有规则均可能变号;逐条映射在执行后回读。重排不发布版本;查看旧编号需结合发布版本。" }, { name: "map", summary: "Inspect locally synced production/test rule code mappings", usage: ["seal-use rules map [--version ] [--code ] [--corp ]"] } ] }, { area: "webhook", title: "Webhook integrations and material packs", description: "Manage incoming audit webhooks and upload offline simulation material packs.", commands: [ { name: "ready", summary: "Check readiness of webhook integration and material pack", usage: ["seal-use webhook ready [<材料包.zip>] [--webhook ] [--corp ]"] }, { name: "status", summary: "Check status of webhook integration", usage: ["seal-use webhook status [<材料包.zip>] [--corp ]"] }, { name: "list", summary: "List registered webhook endpoints", usage: ["seal-use webhook list [--query ] [--show-secret] [--corp ]"] }, { name: "get", aliases: ["find"], summary: "Get webhook endpoint details", usage: ["seal-use webhook get|find [--show-secret] [--corp ]"] }, { name: "add", summary: "Register a new webhook endpoint", usage: ["seal-use webhook add --name --result-url [--mode assisted|semi_automatic|fully_automatic] [--auto-approval-rate 60] [--secret ] [--min-file-size 500] [--max-file-size ] [--allowed-extensions <.pdf,.xlsx,...>] [--dry-run] [--corp ]"] }, { name: "update", summary: "Update an existing webhook endpoint", usage: ["seal-use webhook update [--name ] [--result-url ] [--mode assisted|semi_automatic|fully_automatic] [--auto-approval-rate 60] [--secret |--rotate-secret] [--min-file-size ] [--max-file-size ] [--allowed-extensions <.pdf,.xlsx,...>] [--clear-max-file-size] [--dry-run] [--corp ]"] }, { name: "delete", summary: "Delete a webhook endpoint", usage: ["seal-use webhook delete [--yes|--dry-run] [--corp ]"] }, { name: "resource-pack export", summary: "Export online approval records to a local Webhook resource pack ZIP (alias: pack export)", usage: [ "seal-use webhook resource-pack export [--limit ] [--status ] [--output ] [--to-downloads] [--corp ]", "seal-use webhook resource-pack export [--output ] [--corp ]", "seal-use webhook resource-pack export --record-ids [--corp ]" ], options: [ { flag: "", description: "Single approval run record ID to export" }, { flag: "--record-ids ", description: "Comma-separated list of approval run record IDs" }, { flag: "--limit ", description: "Limit number of records to export (default: 10)" }, { flag: "--status ", description: "Filter records by status (e.g. completed, approved)" }, { flag: "--start-date ", description: "Filter records starting from date" }, { flag: "--end-date ", description: "Filter records up to date" }, { flag: "--doc-id-prefix ", description: "Optional prefix prepended to exported documentId/meetingId" }, { flag: "--doc-id-suffix ", description: "Optional suffix appended to exported documentId/meetingId" }, { flag: "--no-attachments", description: "Skip downloading and packaging attachments" }, { flag: "-o, --output ", description: "Target ZIP file path" }, { flag: "--to-downloads", description: "Save directly to ~/Downloads" }, { flag: "--corp ", description: "Source enterprise configuration ID" } ] }, { name: "resource-pack preview", summary: "Inspect and validate a Webhook resource pack ZIP or Excel sheet (alias: pack preview)", usage: ["seal-use webhook resource-pack preview <资源包.zip|信息表.xlsx> [--min-file-size ] [--max-file-size ] [--allowed-extensions <.pdf,.xlsx,...>] [--corp ]"] }, { name: "resource-pack push", summary: "Upload attachments and push documents from a resource pack ZIP to Webhook (alias: pack push)", usage: ["seal-use webhook resource-pack push <资源包.zip|信息表.xlsx> [--webhook ] [--corp ]"] }, { name: "replay", usage: [ "seal-use webhook replay [--webhook ] [--sn-suffix ] [--dry-run] [--yes|--confirm] [--corp ]", "seal-use webhook replay --sn [--webhook ] [--source-corp ] [--target-corp ] [--yes|--confirm]", "seal-use webhook replay --limit [--status ] [--source-corp ] [--target-corp ] [--yes|--confirm]" ], options: [ { flag: "", description: "Approval run record ID to replay" }, { flag: "--sn ", description: "Lookup approval record by source document SN if recordId not given" }, { flag: "--limit ", description: "Batch replay latest N records from source enterprise" }, { flag: "--status ", description: "Filter records by status (e.g. completed, failed, rejected)" }, { flag: "--webhook ", description: "Target Webhook integration (auto-locks if only one exists)" }, { flag: "--source-corp ", description: "Source enterprise where records reside (alias: --prod-corp)" }, { flag: "--target-corp ", description: "Target enterprise where records are pushed (alias: --test-corp)" }, { flag: "--sn-suffix ", description: "Optional suffix appended to documentSN and documentId" }, { flag: "--sn-prefix ", description: "Optional prefix prepended to documentSN and documentId" }, { flag: "--dry-run", description: "Generate and output Webhook payload JSON without sending HTTP request" }, { flag: "--yes, --confirm", description: "Required for live replay; --force only overrides the environment guard" }, { flag: "--force", description: "Allow replaying to a production enterprise" } ], description: "Extracts structured form fields from historical approval records (Webhook or Hose source), sanitizes field types, and pushes documents to the target Webhook channel. Automatically infers 1-to-1 bound test/production enterprise pairs." } ] }, { area: "approval-runs", title: "Approval runs and audit execution records", description: "Inspect live and historical AI approval decisions, cited rules, and attachments.", commands: [ { name: "summary", summary: "Daily summary of approval runs", usage: ["seal-use approval-runs summary [--date YYYY-MM-DD] [--timezone Asia/Shanghai] [--corp ]"] }, { name: "stats", summary: "Statistical aggregation of approval run metrics", usage: ["seal-use approval-runs stats [--since 3months] [--dedupe-by sourceDocumentSN|sourceDocumentId|id] [--corp ]"] }, { name: "count", summary: "Count approval runs filtered by status or time range", usage: ["seal-use approval-runs count [--status APPROVED] [--start ] [--end ] [--corp ]"] }, { name: "export", summary: "Export approval run audit records to Excel workbook. Add --with-flow to include E人工行为 / E人工意见 columns (requires Hose Open API; adds ~30s for large batches).", usage: ["seal-use approval-runs export [--sn ] [--start ] [--end ] [--force] [--status ] [--manual-status ] [--completed-only] [--limit ] [--downloads|--to-downloads] [--with-flow] [--out ] [--corp ]"], options: [ { flag: "--sn, --sns ", description: "Target specific document SNs (comma-separated, e.g. B26002307,B26002144); fast indexed search bypassing full pagination" }, { flag: "--with-flow", description: "Enrich export with Hose human actions and opinions in E人工行为 / E人工意见 columns (rejection 2-B, mid-flow modifications, action emojis)" }, { flag: "--start ", description: "Filter records by start date (YYYY-MM-DD or ms timestamp)" }, { flag: "--end ", description: "Filter records by end date (YYYY-MM-DD or ms timestamp)" }, { flag: "--force", description: "Force export when time range exceeds 180 days" }, { flag: "--status ", description: "Filter by system status (e.g. completed, processing)" }, { flag: "--manual-status ", description: "Filter by manual approval status (e.g. APPROVED, TERMINATED)" }, { flag: "--completed-only", description: "Only export completed approval runs" }, { flag: "--limit ", description: "Maximum number of records to export" }, { flag: "--downloads, --to-downloads", description: "Save exported workbook directly to user's ~/Downloads directory" }, { flag: "--out ", description: "Custom output file path" } ] }, { name: "hose-flow", aliases: ["flow"], summary: "【合思专属】Get Hose approval flow timeline, staff opinions, and align with AI runs", usage: ["seal-use approval-runs hose-flow [--corp ]"] }, { name: "list", aliases: ["search"], summary: "Search approval records by keyword, dates, or decision status", usage: ["seal-use approval-runs list|search [--query text] [--humanResult 驳回] [--manualApprovalStatus TERMINATED] [--startDate ms] [--endDate ms] [--has-extra-risk] [--limit 20] [--includeBridge true] [--corp ]"], options: [ { flag: "--has-extra-risk", description: "Filter the fetched page to records with warning/error in result.otherFindings; info is excluded. Includes extraRisks with titles, levels and descriptions." }, { flag: "--limit ", description: "Records to scan before local filtering (default 50, maximum 100); no automatic pagination to fill matches" }, { flag: "--offset ", description: "Offset in the upstream result set before local filtering" } ] }, { name: "pick", summary: "Locate single approval run by document SN", usage: ["seal-use approval-runs pick --sn [--batch ] [--latest] [--fields recordId,status,aiDecision] [--corp ]"] }, { name: "get", summary: "Get detailed approval record payload", usage: ["seal-use approval-runs get [--summary] [--fields metadata|document.fields,result.summary] [--full] [--output-file file.json] [--corp ]"] }, { name: "cited-rules", summary: "Inspect rules cited by AI in an approval decision", usage: ["seal-use approval-runs cited-rules [--corp ]"] }, { name: "diagnose", summary: "One-shot complaint/document diagnosis: document summary, AI decision, cited rules, rule version snapshot, and Langfuse trace pointer in a single call", usage: ["seal-use approval-runs diagnose |--sn [--full] [--corp ]"], options: [ { flag: "--sn ", description: "Target the run by Hose document SN instead of record ID" }, { flag: "--full", description: "Include the full raw AI result payload instead of the summary" } ] }, { name: "document-summary", summary: "Inspect parsed source document summary", usage: ["seal-use approval-runs document-summary [--corp ]"] }, { name: "attachments", summary: "Inspect and list attachments for approval run", usage: [ "seal-use approval-runs attachments [--summary] [--corp ]", "seal-use approval-runs attachments download [--all] [--name ] [--out-dir ] [--corp ]" ] }, { name: "result", summary: "Get decision result for an approval run", usage: ["seal-use approval-runs result [--summary] [--corp ]"] }, { name: "link", aliases: ["url"], summary: "Get web console link for an approval run (Seal AI audit result or Hose original document)", usage: [ "seal-use approval-runs link [--corp ]", "seal-use approval-runs link --auto-login [--expire 7200] [--corp ]", "seal-use approval-runs link --type hose-document [--corp ]", "seal-use approval-runs link --sn [--auto-login] [--corp ]" ], options: [ { flag: "--type ", description: "Link type: 'seal-result' (Seal AI audit result page, default) or 'hose-document' (Hose original form)" }, { flag: "--auto-login", description: "Generate auto-login ticketed link (for seal-result type, valid for --expire seconds)" }, { flag: "--expire ", description: "Auto-login ticket expiration in seconds (default: 7200)" } ] }, { name: "bridge", summary: "Inspect browser bridge integration payload", usage: ["seal-use approval-runs bridge [--sourceDocumentSN B26001887] [--corp ]"] }, { name: "replay", summary: "Replay approval run record into a Webhook integration", usage: [ "seal-use approval-runs replay [--webhook ] [--sn-suffix ] [--dry-run] [--yes|--confirm] [--corp ]", "seal-use approval-runs replay --sn [--webhook ] [--source-corp ] [--target-corp ] [--yes|--confirm]", "seal-use approval-runs replay --sn --channel hose-outbound [--sign-key ] [--target-corp ] [--dry-run] [--yes|--confirm]", "seal-use approval-runs replay --channel hose-outbound [--sign-key ] [--target-corp ] [--dry-run] [--yes|--confirm]", "seal-use approval-runs replay --limit [--status ] [--source-corp ] [--target-corp ] [--yes|--confirm]" ], options: [ { flag: "", description: "Approval run record ID" }, { flag: "--sn ", description: "Lookup approval record by source document SN" }, { flag: "--channel ", description: "Replay channel: webhook (default) or hose-outbound (Hosecloud official outbound)" }, { flag: "--sign-key ", description: "Target Hose integration signKey for hose-outbound; required when the target has several integrations" }, { flag: "--message-id ", description: "Explicit Hose outbound messageId override" }, { flag: "--rejection-num ", description: "Target specific rejection iteration (0, 1, 2, ...)" }, { flag: "--limit ", description: "Batch replay latest N records" }, { flag: "--status ", description: "Filter records by status" }, { flag: "--webhook ", description: "Target Webhook integration" }, { flag: "--source-corp ", description: "Source enterprise where records reside" }, { flag: "--target-corp ", description: "Target enterprise where records are pushed" }, { flag: "--sn-suffix ", description: "Optional suffix appended to documentSN" }, { flag: "--dry-run", description: "Preview payload without sending" }, { flag: "--yes, --confirm", description: "Required for live replay; --force only overrides environment and pairing guards" } ] } ] }, { area: "report", title: "AI audit accuracy reports (acceptance, go-live, periodic)", description: "Generate AI audit and acceptance reports, export standalone Excel/CSV ledgers, validate local Markdown, and export HTML/PNG/PDF.", commands: [ { name: "ledger", summary: "Export standalone audit run ledger (.xlsx / .csv) with full AI & human opinions", usage: ["seal-use report ledger --start-date --end-date [--templates ] [--limit ] [--out ] [--corp ]"], options: [ { flag: "--start-date ", description: "Statistics start date, YYYY-MM-DD (e.g. 2026-08-12)" }, { flag: "--end-date ", description: "Statistics end date, YYYY-MM-DD (e.g. 2026-09-18)" }, { flag: "--templates ", description: "Comma-separated template whitelist" }, { flag: "--ledger ", description: "Inspect or convert an existing ledger file" }, { flag: "--out ", description: "Output path (.xlsx or .csv); defaults to 台账--.xlsx" }, { flag: "--format ", description: "Export format (default: xlsx, or inferred from --out)" }, { flag: "--limit ", description: "Cap approval-run fetch (alias: --max-runs, default: all records in period, max 100000)" } ], description: "Exports full audit ledger containing recordId, SN, template, AI decisions, full AI opinions & conditions, human results & comments, agreement, and review verdict columns. Agents can freely trim rows/templates and fill verdicts." }, { name: "data", summary: "Extract pure structured report data, metrics, diverged runs, and triggers without templates", usage: ["seal-use report data (--ledger <台账.xlsx> | --start-date --end-date ) [--templates ] [--limit ] [--corp ]"], options: [ { flag: "--start-date ", description: "Statistics start date, YYYY-MM-DD" }, { flag: "--end-date ", description: "Statistics end date, YYYY-MM-DD" }, { flag: "--ledger ", description: "Directly parse an edited Excel/CSV ledger file without remote requests" }, { flag: "--templates ", description: "Comma-separated template whitelist" }, { flag: "--limit ", description: "Cap approval-run detail fetch (alias: --max-runs, default: all records in period, max 100000)" } ], description: "Template-free data pack for Agent authoring: returns performance metrics, formula fractions, template groups, top risk tags, diverged runs with exact triggered conditions, and reviews." }, { name: "template", summary: "Dump or save the built-in report Markdown template", usage: ["seal-use report template [--out ]"], options: [ { flag: "--out ", description: "Save built-in Markdown template directly to a file" } ], description: "Tenant-free local command: returns or saves the built-in monthly.md template so an Agent or user can co-author." }, { name: "chart venn", summary: "Generate dynamic Venn accuracy comparison SVG chart independently", usage: ["seal-use report chart venn --ai --human [--both ] [--out ]"], options: [ { flag: "--ai ", description: "AI accuracy percentage (e.g. 92.08)" }, { flag: "--human ", description: "Human accuracy percentage (e.g. 83.33)" }, { flag: "--both ", description: "Both accurate percentage (e.g. 75.42)" }, { flag: "--out ", description: "Save SVG directly to file" } ], description: "Tenant-free local command: calculates proportions and outputs high-fidelity SVG chart." }, { name: "generate", aliases: ["monthly", "month"], summary: "Fill the audit report template with performance, risk, and approval-run data", usage: ["seal-use report generate (--ledger <台账.xlsx> | --start-date --end-date ) [--templates ] [--out <报告.md>] [--template ] [--report-id ] [--limit ] [--allow-unreviewed] [--corp ]"], options: [ { flag: "--start-date ", description: "Statistics start date, YYYY-MM-DD (e.g. 2026-08-12)" }, { flag: "--end-date ", description: "Statistics end date, YYYY-MM-DD (e.g. 2026-09-18)" }, { flag: "--ledger ", description: "Driven directly by an edited Excel/CSV ledger as the sole source of truth; ignores deleted templates/runs and respects in-place verdicts" }, { flag: "--templates ", description: "Comma-separated template whitelist; filters blocks and ledger at source" }, { flag: "--template ", description: "Custom template Markdown path; defaults to the Git-managed template embedded in the binary" }, { flag: "--out ", description: "Save Markdown plus local images and Excel/CSV ledgers beside the report; stdout stays JSON" }, { flag: "--overwrite", description: "Explicitly permit replacing existing output files" }, { flag: "--report-id ", description: "Custom report id; defaults to RPT--" }, { flag: "--limit ", description: "Cap approval-run detail fetch (alias: --max-runs, default: all records in period, max 100000)" }, { flag: "--allow-unreviewed", description: "Bypass pre-flight adjudication gate to generate draft when unreviewed diverged runs exist" } ], description: "The template is the mutable skin: section headings, tables, and order may change and data demands are inferred from headings. Supports direct ledger-driven generation where user/Agent modifications to templates and rows are strictly respected." }, { name: "validate", summary: "Check a local report's structure, images, totals, and formulas", usage: ["seal-use report validate <报告.md>"], options: [], description: "Local only: no --corp, credentials, or Seal requests. Returns JSON issues; exit 1 if validation fails." }, { name: "render", summary: "Validate and export HTML, full-length PNG, and A4 PDF from local Markdown", usage: ["seal-use report render <报告.md> --out [--format ]"], options: [ { flag: "--out ", description: "Output filename stem; extensions are appended" }, { flag: "--format ", description: "all (default), html, png, or pdf; PNG/PDF also produce HTML" }, { flag: "--width ", description: "PNG viewport width, default 1200 (320–5000)" }, { flag: "--chrome ", description: "Chrome/Chromium executable; otherwise auto-detected" }, { flag: "--no-glossary", description: "Omit the trailing terms definition and calculation standards appendix" }, { flag: "--overwrite", description: "Explicitly permit replacing existing output files after successful rendering" } ], description: "No enterprise login. Validation failure produces JSON issues and no artifacts. Validation and HTML use the bundled runtime; PNG/PDF need Chrome/Chromium. No Python or Pillow required. First use of math fetches and caches KaTeX resources. Markdown parsing is bundled, with no runtime npm/npx dependency." }, { name: "export", summary: "Package Markdown, local 4x assets, self-contained HTML, and PDF into a dedicated directory", usage: ["seal-use report export <报告.md> --out <输出目录> [--format ]"], options: [ { flag: "--out ", description: "Dedicated output directory for the report bundle" }, { flag: "--format ", description: "all (default), html, or pdf" }, { flag: "--width ", description: "PNG viewport width, default 1200" }, { flag: "--chrome ", description: "Chrome/Chromium executable; otherwise auto-detected" }, { flag: "--no-glossary", description: "Omit the trailing terms definition and calculation standards appendix" }, { flag: "--overwrite", description: "Explicitly permit replacing existing output files" } ], description: "Bundles the report into a clean single directory: includes the Markdown with its .md.assets/ companion folder, plus self-contained HTML and print-ready PDF." }, { name: "review set", summary: "Record one human adjudication (who was right: AI or human) for an approval run or document", usage: ["seal-use report review set [--record-id ] [--sn ] --verdict [--note ] [--reviewed-by ] [--corp ]"], options: [ { flag: "--record-id ", description: "Approval run recordId for exact single-run targeting" }, { flag: "--sn ", description: "Document SN to adjudicate" }, { flag: "--verdict ", description: "ai_correct | human_correct | both_correct | both_wrong | undecided (required)" }, { flag: "--note ", description: "Optional adjudication note" }, { flag: "--reviewed-by ", description: "Optional reviewer name for the audit trail" } ], description: "Append-only local JSONL per tenant (~/.config/seal-use/state/reviews/). Supports exact recordId target or SN. Typically adjudicates diverged blocks or overrides specific agreed runs." }, { name: "review list", summary: "List human adjudications recorded for a tenant", usage: ["seal-use report review list [--corp ]"], options: [ { flag: "--corp ", description: "Target enterprise corpId" } ], description: "Reads the local JSONL store and returns all adjudications." }, { name: "review import", summary: "Bulk import adjudications from an edited Excel/CSV ledger file", usage: ["seal-use report review import <台账.xlsx|csv> --corp "], options: [ { flag: "--corp ", description: "Target enterprise corpId" } ], description: "Reads '复核定性裁决', '复核人', and '复核批注说明' columns from the ledger and bulk writes into the local review store." } ] }, { area: "simulation", title: "Simulation testing engine", description: "Execute and analyze offline or HoseCloud batch simulations against approval rules.", commands: [ { name: "batch-records", summary: "Fetch records for a simulation batch", usage: ["seal-use simulation batch-records [--corp ]"] }, { name: "create", summary: "Trigger a simulation batch (reuses an identical batch within the reuse window; defaults to skipping background expense DB extraction)", usage: [ "seal-use simulation create --mode hosecloud --flow-ids \"B26017701,B26022501\" [--wait] [--timeout 10m] [--poll-interval 2s] [--reject-node 财务] [--thinking-depth default|medium|high] [--skip-extract|--extract] [--skip-invoice-generation] [--no-wait] [--force] [--reuse-window 5m] [--corp ]", "seal-use simulation create --mode material_pack --package-ids [--template-id conference_reimbursement_v1] [--schema-config file.json] [--corp ]", "seal-use simulation create --source-system weaver --request-ids \"req-01,req-02\" [--corp ]" ] }, { name: "status", summary: "Check current progress of a simulation batch", usage: ["seal-use simulation status [--corp ]"] }, { name: "wait", summary: "Wait synchronously for simulation batch to finish", usage: ["seal-use simulation wait [--timeout 10m] [--poll-interval 2s] [--corp ]"] }, { name: "clean", summary: "Clean simulation batch records", usage: ["seal-use simulation clean --yes [--corp ]"] }, { name: "specifications", summary: "Query simulation specifications", usage: ["seal-use simulation specifications [--integration ] [--corp ]"] }, { name: "approval-definitions", summary: "Query simulation approval definitions", usage: ["seal-use simulation approval-definitions [--corp ]"] }, { name: "list", summary: "List recent simulation batches", usage: ["seal-use simulation list [--limit 50] [--corp ]"] }, { name: "get", summary: "Get details for simulation batch", usage: ["seal-use simulation get [--corp ]"] }, { name: "templates", summary: "List available simulation templates", usage: ["seal-use simulation templates [--corp ]"] }, { name: "integrations", summary: "List available simulation integrations", usage: ["seal-use simulation integrations [--corp ]"] }, { name: "package-upload", summary: "Upload a simulation material package", usage: ["seal-use simulation package-upload <材料包.zip> [--corp ]"] } ] }, { area: "deploy", title: "Deployment and cloud synchronization", description: "Manage HoseCloud integration configurations and synchronization.", commands: [ { name: "hosecloud requirements", summary: "Check HoseCloud deployment requirements", usage: ["seal-use deploy hosecloud requirements [--corp ]"] }, { name: "hosecloud list", summary: "List HoseCloud deployment targets", usage: ["seal-use deploy hosecloud list [--corp ]"] }, { name: "hosecloud get", summary: "Get HoseCloud deployment details", usage: ["seal-use deploy hosecloud get [--corp ]"] }, { name: "hosecloud status", summary: "Check HoseCloud deployment status", usage: ["seal-use deploy hosecloud status [--corp ]"] }, { name: "hosecloud configure", summary: "Save Hose integration settings in Seal", usage: ["seal-use deploy hosecloud configure --json '{...}' [--dry-run] [--yes|--confirm] [--corp ]"], options: [ { flag: "--dry-run", description: "Preview the configuration diff without saving" }, { flag: "--yes, --confirm", description: "Required to save the integration configuration" } ] }, { name: "hosecloud sync", summary: "Create or update Hose outbound messages and callback URLs", usage: ["seal-use deploy hosecloud sync [] [--auto] [--dry-run] [--yes|--confirm] [--corp ]"], options: [ { flag: "--auto", description: "Select the sole Hose integration; does not confirm synchronization" }, { flag: "--dry-run", description: "Preview the sync request without creating or updating messages" }, { flag: "--yes, --confirm", description: "Required for live synchronization" } ] }, { name: "hosecloud test-outbound", summary: "向合思出站 (outbound) 接口推送测试/重放消息以模拟工作流触发(要求 assisted 模式)", usage: [ "seal-use deploy hosecloud test-outbound [--sign-key ] --flow-id --message-id [--dry-run] [--yes|--confirm] [--corp ]", "seal-use deploy hosecloud test-outbound [--sign-key ] --sn --message-id [--dry-run] [--yes|--confirm] [--corp ]" ], options: [ { flag: "--dry-run", description: "Preview the outbound payload without sending" }, { flag: "--yes, --confirm", description: "Required for live outbound push" } ] } ] }, { area: "hose-ebot", title: "Hose EBot outbound discovery & callback (合思 EBot 出站发现与审批回调)", description: "按单号搜索出站/回调记录、列出出站消息配置(signKey),并执行 EBot 审批回调。", commands: [ { name: "search", summary: "【出站发现·默认入口】按单号搜索出站消息调用记录(只读)", usage: ["seal-use hose-ebot search [--type invoking|callback] [--limit ] [--reveal] [--corp ]"], options: [ { flag: "--type ", description: "筛选记录类型:invoking=出站触发,callback=回调;缺省全部" }, { flag: "--limit ", description: "返回条数上限(默认 20,最大 100)" }, { flag: "--reveal, -r", description: "明文展示记录中的 signKey(默认脱敏)" } ], description: "在合思 CloseAPI 出站消息日志中按单号 (SN) 搜索,返回带唯一 id 的记录列表(INVOKING 出站触发 / CALLBACK 回调),含 flowId/nodeId/messageId/rejectionNum 等回调上下文。" }, { name: "messages", summary: "【出站配置】列出全部出站消息配置,发现 signKey 与回调地址(只读)", usage: ["seal-use hose-ebot messages [--type flow|message] [--reveal] [--corp ]"], options: [ { flag: "--type ", description: "按类型过滤:flow=审批流 EBot 出站,message=完成回调/通知" }, { flag: "--reveal, -r", description: "明文展示 signKey(默认脱敏为 8...4 形式)" } ], description: "经合思 CloseAPI 只读查询本企业全部出站消息配置(messageName、signKey、callbackUrl、enable 等)。signKey 即出站回调地址中的 config_id,可直接用于 'hose-ebot callback'。" }, { name: "callback", summary: "【回调审批】调用合思开放接口执行 EBot 审批回调(同意/驳回/加签)", usage: [ "seal-use hose-ebot callback --flow-id --node-id --action --comment <审批意见> [--sign-key ] [--policy ] [--add-approver-ids ] [--reject-to ] [--resubmit-method ] [--dry-run] [--yes|--confirm] [--corp ]" ], options: [ { flag: "--comment ", description: "审批意见(必填)" }, { flag: "--sign-key ", description: "出站消息签名密钥;缺省时从本企业唯一 Seal 合思集成解析" }, { flag: "--action ", description: "同意 / 驳回 / 前加签 / 后加签(兼容 agree/approve/reject)" }, { flag: "--policy ", description: "会签方式:ALL 会签 / ANY 或签(加签超过一人时必填)" }, { flag: "--add-approver-ids ", description: "前后加签审批人 ID 列表(加签时必填,逗号分隔)" }, { flag: "--reject-to ", description: "驳回目标节点 ID;缺省按 EBot 节点驳回配置" }, { flag: "--resubmit-method ", description: "驳回后重提方式;缺省按 EBot 节点配置" }, { flag: "--dry-run", description: "仅预览回调请求(signKey 脱敏),不执行" }, { flag: "--yes, --confirm", description: "正式执行必需;届时实时换取 accessToken 后回调" } ], description: "调用合思开放接口 POST /api/openapi/v1/approval,向审批流回写 EBot 节点审批结果,成功返回 value.code=204。仅支持 EBot 节点的审批;signKey 可通过 'seal-use hose-ebot messages --reveal' 发现。" } ] }, { area: "preference", title: "Audit preferences and thinking depth", description: "Manage AI decision preferences, strictness, and thinking depth policies.", commands: [ { name: "get", summary: "Get current decision preference configuration", usage: ["seal-use preference get [--corp ]"] }, { name: "decision update", summary: "Update decision preference rules", usage: ["seal-use preference decision update --json '{\"explicitApprove\":\"...\"}' [--dry-run] [--corp ]"] }, { name: "thinking-depth set", summary: "Set default thinking depth", usage: ["seal-use preference thinking-depth set --default [--dry-run] [--corp ]"] }, { name: "thinking-depth policies list", summary: "List thinking depth policies", usage: ["seal-use preference thinking-depth policies list [--corp ]"] }, { name: "thinking-depth policies upsert", summary: "Upsert a thinking depth policy", usage: ["seal-use preference thinking-depth policies upsert --json '{...}' [--dry-run] [--corp ]"] }, { name: "thinking-depth policies remove", summary: "Remove a thinking depth policy", usage: ["seal-use preference thinking-depth policies remove [--dry-run] [--corp ]"] } ] }, { area: "config", title: "CLI and global workspace configuration", description: "Manage configuration paths, stateful/stateless mode, test directory, and rule linter.", commands: [ { name: "paths", summary: "Display active configuration file and directory paths", usage: ["seal-use config paths"] }, { name: "get", aliases: ["status"], summary: "Display current global configuration", usage: ["seal-use config get"] }, { name: "mode", summary: "Configure stateful or stateless CLI operating mode", usage: ["seal-use config mode [--corp ]"] }, { name: "test-dir", aliases: ["test-enterprises-dir"], summary: "Set or clear global test enterprises directory", usage: ["seal-use config test-dir [|--clear]"] }, { name: "lint", summary: "Configure automatic rule linter status and thresholds", usage: ["seal-use config lint [status|enable|disable] [--linter ] [--min-score ]"] } ] }, { area: "auth", title: "Authentication and session diagnostics", description: "Diagnose upstream token status and generate provisional assistance links.", commands: [ { name: "check", summary: "Check auth session and platform connectivity", usage: ["seal-use auth check [--corp ]"] }, { name: "link", summary: "【Seal 审核后台】生成免密登录/委托访问直达链接", usage: [ "seal-use auth link [--note ] [--expire ] [--corp ]", "seal-use auth link --from-link [--note ] [--expire ]" ], options: [ { flag: "--note ", description: "委托授权备注说明(如:演示测试、外部审计)" }, { flag: "--expire, --expires-in ", description: "委托授权有效期,推荐 '7d' 或 '24h'(最大 7 天,兼容秒数并自动向下取整)" }, { flag: "--from-link ", description: "直接由合思协助链接换取 Seal 委托直达链接" } ], description: "生成访问当前企业 Seal AI 智能审核后台 (https://.sealai.cc/delegate) 的免密直达链接。返回实际会话人员 staffName、identityStatus、isAdmin 和 permissions;姓名查询失败时明确标记为未核实。主体作用于 Seal 审核后台。" }, { name: "link list", summary: "【Seal 审核后台】列出当前租户已生效的委托授权令牌 (Delegation Tokens)", usage: ["seal-use auth link list [--corp ]"], description: "查询已在 Seal 平台签发的委托授权记录。若返回 [] 表示当前租户暂无有效委托。" }, { name: "link revoke", summary: "【Seal 审核后台】撤销指定的 Seal 委托授权令牌", usage: ["seal-use auth link revoke [--corp ]"] }, { name: "hose-link", summary: "【合思外部主站】生成免密登录/第三方协助入口链接", usage: ["seal-use auth hose-link [--corp ] [--expire ] [--force]"], options: [ { flag: "--expire, --expires-in ", description: "链接有效时间,推荐 '7d' 或 '2h'(默认 2h,兼容秒数如 7200)" }, { flag: "--force, --refresh, -f", description: "强制向合思 OpenAPI 申请全新临时凭证" } ], description: "专用于合思 (Hose) 来源企业。向合思申请临时 ticket,生成直达外部合思/易快报主站 (https://app.ekuaibao.com/web/thirdparty.html) 的免密登录链接。自动查询绑定员工的 staffName、identityStatus 和 roleNames;未能核实的姓名或角色明确标记为未知。若需生成 Seal 自身的审核后台访问链接,请使用 'seal-use auth link'。" }, { name: "hose-openapi-token", aliases: ["openapi-token", "hose-token"], summary: "【合思】用持久化密钥签发合思 OpenAPI accessToken", usage: ["seal-use auth hose-openapi-token [--corp ] [--force]"], options: [ { flag: "--force, --refresh, -f", description: "跳过本地缓存,强制向合思 OpenAPI 签发全新 token" } ], description: "专用于合思 (Hose) 来源企业。使用已持久化的 appKey/appSecurity 调用 /api/openapi/v1/auth/getAccessToken 换取 OpenAPI accessToken(约 1 小时有效),stdout 输出含 token、expiresAt 与 cached 字段(cached=true 表示复用了本地仍有效的缓存)。" }, { name: "hose-extract-keys", aliases: ["extract-keys", "extract-key", "extract-hose-keys"], summary: "【合思子域提权】从合思协助链接提取 OpenAPI 开发者密钥并可选升级配置", usage: [ "seal-use auth hose-extract-keys [--reveal] [--save] [--app-key ] [--key-id ] [--name ] [--overwrite]" ], options: [ { flag: "--reveal, -r", description: "显式揭示完整 appSecurity 明文(默认脱敏保护)" }, { flag: "--save", description: "【提权升级】直接将提取到的合思 OpenAPI 密钥持久化为标准企业配置" }, { flag: "--app-key ", description: "存在多套密钥时指定使用的 appKey" }, { flag: "--key-id ", description: "存在多套密钥时指定使用的 keyId" } ], description: "专属于合思 (Hose/合思云/易快报) 子域的能力。非合思渠道企业不支持。" }, { name: "hose-keys", aliases: ["keys"], summary: "【合思子域】查看当前企业已配置的合思 OpenAPI 开发者密钥", usage: ["seal-use auth hose-keys [--corp ] [--reveal]"], options: [ { flag: "--reveal, -r", description: "显式揭示完整 appSecurity 明文(默认脱敏保护)" } ], description: "专属于合思 (Hose) 来源企业。原生 Seal 企业不包含 OpenAPI 密钥,不支持此命令。" } ] }, { area: "users", title: "User administration", description: "Manage tenant users, phone credentials, and passwords.", commands: [ { name: "create", summary: "Create a new tenant user", usage: ["seal-use users create --name --phone [--dept ] [--corp ]"] }, { name: "search", summary: "Search tenant users by name or phone", usage: ["seal-use users search [--corp ]"] }, { name: "delegation", summary: "Create delegation token for a specific user", usage: ["seal-use users delegation [--note ] [--expire ] [--corp ]"], options: [ { flag: "--note ", description: "委托授权备注说明" }, { flag: "--expire, --expires-in ", description: "委托授权有效期,推荐 '7d' 或 '24h'(最大 7 天,兼容秒数并自动向下取整)" } ] }, { name: "reset-password", summary: "Reset user password", usage: ["seal-use users reset-password --yes [--corp ]"] }, { name: "get", summary: "Get user details", usage: ["seal-use users get [--corp ]"] }, { name: "delete", summary: "Delete user", usage: ["seal-use users delete --yes [--corp ]"] } ] }, { area: "contacts", title: "Contacts directory", description: "Query organizational departments, child hierarchies, and user mappings.", commands: [ { name: "departments", summary: "List organizational departments", usage: ["seal-use contacts departments [] [--corp ]"] }, { name: "children", summary: "List child departments", usage: ["seal-use contacts children [--corp ]"] }, { name: "users", summary: "List users in department", usage: ["seal-use contacts users [--corp ]"] }, { name: "sync-time", summary: "Get latest contacts synchronization time", usage: ["seal-use contacts sync-time [--corp ]"] } ] }, { area: "data", title: "Expense and invoice data records", description: "Search raw historical expense and invoice data entries.", commands: [ { name: "expenses", summary: "List expenses, or verify expense-store membership by exact document number with --sn", usage: ["seal-use data expenses [--sn |--record-id |--search ] [--start-date ] [--end-date ] [--offset ] [--limit ] [--max-scan ] [--corp ]"] }, { name: "invoices", summary: "Search raw invoice records (also available as 'seal-use invoices')", usage: ["seal-use data invoices [--search ] [--start-date ] [--end-date ] [--offset ] [--limit ] [--full] [--corp ]"] } ] }, { area: "invoices", title: "进项发票查询与溯源", description: "查看已审批单据中出现的进项发票,支持单据关联穿透、跨单据重复占用排查与扁平化业务视图。", commands: [ { name: "list", summary: "分页查询进项发票(默认输出扁平化业务字段,对齐控制台表格)", usage: [ "seal-use invoices [list] [--search ] [--start-date ] [--end-date ] [--offset ] [--limit ] [--full] [--corp ]" ] }, { name: "trace", summary: "穿透溯源指定发票,排查在哪些报销单据中被使用及是否存在跨单重复占用", usage: [ "seal-use invoices trace [--corp ]", "seal-use invoices [--corp ]" ] } ] }, { area: "expenses", title: "费用明细查询", description: "查询历史费用明细;--sn 按单号关联审批记录并核验费用库存在性,区分找到、关联范围内未找到和无法确定。", commands: [ { name: "list", summary: "普通查询分页返回原始记录;--sn 自动翻页核验,--limit 为页大小,--max-scan 默认为 5000", usage: [ "seal-use expenses [list] [--sn |--record-id |--search ] [--start-date ] [--end-date ] [--offset ] [--limit ] [--max-scan ] [--corp ]" ] } ] }, { area: "llm", title: "LLM configuration", description: "Query LLM providers and configuration settings.", commands: [ { name: "config", summary: "Get active LLM configuration", usage: ["seal-use llm config [--corp ]"] }, { name: "providers", summary: "List available LLM providers", usage: ["seal-use llm providers [--corp ]"] } ] }, { area: "permissions", title: "Tenant permissions", description: "Inspect available and configured permissions.", commands: [ { name: "available", summary: "List available permissions", usage: ["seal-use permissions available [--corp ]"] }, { name: "configs", summary: "List active permission configurations", usage: ["seal-use permissions configs [--corp ]"] } ] }, { area: "billing", title: "Subscription and billing plans", description: "Query billing status, feature entitlements, and plan limits.", commands: [ { name: "status", summary: "Query current billing and subscription status", usage: ["seal-use billing status [--corp ]"] }, { name: "plans", summary: "Query available billing plans", usage: ["seal-use billing plans [--corp ]"] }, { name: "features", summary: "Query billing feature toggles", usage: ["seal-use billing features [--corp ]"] } ] }, { area: "analytics", title: "Audit analytics and insights", description: "Query high-level audit analytics and insights.", commands: [ { name: "insight", aliases: ["insight-stats", "stats"], summary: "Query AI audit insights risk-tag statistics and analysis status", usage: ["seal-use analytics insight [--start-date ] [--end-date ] [--limit ] [--corp ]"] }, { name: "risks", aliases: ["risks-by-tag", "tag-risks"], summary: "Query detailed risks and document citations under a specific risk tag", usage: ["seal-use analytics risks [--start-date ] [--end-date ] [--corp ]"] }, { name: "performance", aliases: ["perf"], summary: "Query audit performance metrics (accuracy, automation rate) and Sankey flow", usage: ["seal-use analytics performance [--start-date ] [--end-date ] [--corp ]"] }, { name: "analyze", aliases: ["reanalyze"], summary: "Trigger on-demand smart insight risk analysis for an approval record", usage: ["seal-use analytics analyze [--corp ]"] }, { name: "export", aliases: ["report", "download"], summary: "Export smart insights risk report to high-fidelity Excel workbook", usage: ["seal-use analytics export [--downloads] [--out ] [--start-date ] [--end-date ] [--force] [--limit ] [--corp ]"], options: [ { flag: "--downloads", description: "Save directly to the user's Downloads directory" }, { flag: "--out ", description: "Custom destination file path" }, { flag: "--start-date ", description: "Filter beginning time range" }, { flag: "--end-date ", description: "Filter ending time range" }, { flag: "--force", description: "Force export when time range exceeds 180 days" }, { flag: "--limit ", description: "Maximum risk tags to drill down into" } ] } ] }, { area: "context", title: "Knowledge context and documents", description: "Query uploaded knowledge context and documents.", commands: [ { name: "", summary: "Inspect knowledge context documents", usage: ["seal-use context [--ruleVersion ] [--documentLimit 50] [--corp ]"] } ] }, { area: "source", title: "Data source configurations", description: "Inspect enterprise source system configuration.", commands: [ { name: "config", summary: "Inspect source configuration", usage: ["seal-use source config [--corp ]"] } ] }, { area: "documents", title: "Approval knowledge documents", description: "List, inspect, search, create, update, and delete approval knowledge articles and policy documents.", commands: [ { name: "list", summary: "List knowledge documents; --summary omits body, --fields selects explicit fields", usage: ["seal-use documents list [--summary] [--fields ] [--scenarios ] [--limit 50] [--offset 0] [--corp ]"] }, { name: "get", summary: "Get document JSON, or export exact UTF-8 body plus baseline with --out; --output-file saves JSON", usage: ["seal-use documents get [--out ] [--content-format raw] [--overwrite] [--corp ]"] }, { name: "search", summary: "Search approval knowledge documents by keyword", usage: ["seal-use documents search [--maxResults 20] [--corp ]"] }, { name: "create", summary: "Preview with --dry-run; --yes/--confirm creates and verifies a knowledge document", usage: [ "seal-use documents create --title --purpose <purpose> [--content <text>|--content-file <path>] [--content-format raw] [--allow-empty] [--type <policy|document|video|pdf|feishu_doc>] [--scenarios <audit,fill>] [--tags <tag1,tag2>] [--status <published|draft>] [--dry-run|--yes|--confirm] [--corp <corpId>]" ] }, { name: "update", summary: "Preview changes; confirmed updates check export baseline, snapshot and verify readback", usage: [ "seal-use documents update <documentId> [--title <title>] [--purpose <purpose>] [--content <text>|--content-file <path>] [--content-format raw] [--allow-empty] [--type <policy|document|video|pdf|feishu_doc>] [--enabled <true|false>] [--scenarios <audit,fill>] [--tags <tag1,tag2>] [--status <published|draft>] [--dry-run|--yes|--confirm] [--corp <corpId>]" ] }, { name: "delete", summary: "Preview deletion; --yes/--confirm snapshots the document before deleting it", usage: ["seal-use documents delete <documentId> [--dry-run|--yes|--confirm] [--corp <corpId>]"] } ] }, { area: "update", title: "CLI self-update and release changelogs", description: "Check for new releases, perform self-updates, and view changelogs.", commands: [ { name: "", summary: "Update seal-use to latest or target version", usage: [ "seal-use update [--check] [--force] [--version <v>]", "seal-use update check", "seal-use update changelog [--limit <n>]", "seal-use changelog [--limit <n>]" ] } ] }, { area: "probe", title: "Enterprise connectivity probe", description: "Probe upstream Hose and Seal HTTP connectivity and token validity.", commands: [ { name: "", summary: "Run connectivity probe", usage: ["seal-use probe [<corpId>]"] } ] }, { area: "langfuse", title: "Langfuse trace inspection (read-only)", description: "Inspect Langfuse traces/sessions with the built-in read-only credentials: cache once, then outline → search → observation IO. No tenant or user config required.", commands: [ { name: "check", summary: "Check connectivity of the built-in Langfuse read-only credentials", usage: ["seal-use langfuse check"] }, { name: "cache-refresh", summary: "Fetch one full trace into the local cache for offline inspection", usage: ["seal-use langfuse cache-refresh <traceId> [--trace-id <traceId>]"], options: [{ flag: "--trace-id <id>", description: "Trace id when not given as a positional" }] }, { name: "outline", summary: "Read a compact observation tree with sizes, usage, cost, and optional IO previews", usage: ["seal-use langfuse outline <traceId> [--include-io-preview] [--max-preview-chars <n>] [--full]"], options: [ { flag: "--include-io-preview", description: "Include short input/output previews on the trace and observations" }, { flag: "--max-preview-chars <n>", description: "Preview length per field, 20-5000 (default 160)" }, { flag: "--full", description: "Return full IO instead of previews (large output)" }, { flag: "--refresh-if-missing", description: "Fetch the trace when it is not cached yet" } ] }, { name: "search", summary: "Ranked keyword search inside one cached trace (qrep)", usage: ["seal-use langfuse search <traceId> --query <term1,term2> [--fields input,output] [--max-results <n>]"], options: [ { flag: "--query <terms>", description: "Comma-separated terms; earliest best match wins per field" }, { flag: "--fields <fields>", description: "Comma-separated fields: name,input,output,metadata,userId,sessionId" }, { flag: "--observation-types <types>", description: "Comma-separated observation type filter (e.g. GENERATION,SPAN)" }, { flag: "--metadata <json>", description: "Exact metadata filter as a JSON object" }, { flag: "--max-results <n>", description: "Maximum ranked results, 1-30 (default 10)" }, { flag: "--context-chars <n>", description: "Context around each match, 20-500 (default 120)" }, { flag: "--session-id <id>", description: "Only match when the trace belongs to this session" }, { flag: "--refresh-if-missing", description: "Fetch the trace when it is not cached yet" } ] }, { name: "observation", summary: "Read focused input/output/metadata of one observation", usage: ["seal-use langfuse observation <traceId> <observationId> [--fields input,output] [--max-chars <n>]"], options: [ { flag: "--fields <fields>", description: "Comma-separated fields to read: input,output,metadata (default input,output)" }, { flag: "--max-chars <n>", description: "Per-field character cap, 100-30000 (default 8000)" }, { flag: "--json-path <path>", description: "Read one nested value, e.g. items[0].name" }, { flag: "--full", description: "Raise the cap to 500000 chars (large output)" }, { flag: "--refresh-if-missing", description: "Fetch the trace when it is not cached yet" } ] }, { name: "session", summary: "Read a compact session outline with trace summaries", usage: ["seal-use langfuse session <sessionId> [--trace-limit <n>]"], options: [{ flag: "--trace-limit <n>", description: "Maximum traces to summarize, 1-200 (default 50)" }] }, { name: "observations", summary: "Filter cached observations by name/type/metadata without loading IO", usage: ["seal-use langfuse observations <traceId> [--name-contains <text>] [--type <type>]"], options: [ { flag: "--name-contains <text>", description: "Substring match on observation name" }, { flag: "--type <type>", description: "Exact observation type filter" }, { flag: "--metadata-key <key>", description: "Only observations whose metadata has this key" }, { flag: "--has-input", description: "Only observations with non-empty input" }, { flag: "--has-output", description: "Only observations with non-empty output" }, { flag: "--max-results <n>", description: "Maximum summaries, 1-200 (default 50)" }, { flag: "--refresh-if-missing", description: "Fetch the trace when it is not cached yet" } ] }, { name: "url", summary: "Build the Langfuse UI deep link for one trace", usage: ["seal-use langfuse url <traceId>"] }, { name: "attachment-flow", summary: "Trace text evidence of a file id/name through attachment and review stages", usage: ["seal-use langfuse attachment-flow <traceId> [--file-id <id>] [--file-name <name>]"], options: [ { flag: "--file-id <id>", description: "File id to look for (at least one hint required)" }, { flag: "--file-name <name>", description: "File name to look for (at least one hint required)" }, { flag: "--content-hints <hints>", description: "Comma-separated extra content hints" }, { flag: "--context-chars <n>", description: "Context around each match, 20-500 (default 120)" }, { flag: "--refresh-if-missing", description: "Fetch the trace when it is not cached yet" } ] }, { name: "rule-flow", summary: "Trace text evidence of one rule through matching, parsing, and review stages", usage: ["seal-use langfuse rule-flow <traceId> --rule <规则内容>"], options: [ { flag: "--rule <text>", description: "Rule text to trace (required)" }, { flag: "--rule-hints <hints>", description: "Comma-separated extra rule hints" }, { flag: "--context-chars <n>", description: "Context around each match, 20-500 (default 300)" }, { flag: "--refresh-if-missing", description: "Fetch the trace when it is not cached yet" } ] } ] }, { area: "mcp", title: "Model Context Protocol (MCP) server", description: "Run standalone or stdio MCP server for agent harnesses.", commands: [ { name: "", summary: "Run MCP server or output MCP config", usage: [ "seal-use mcp", "seal-use mcp config", "seal-use mcp-config" ] } ] }, { area: "skill", title: "Agent skill management", description: "Install, dump, or inspect agent skills.", commands: [ { name: "dump", summary: "Dump embedded skill markdown", usage: ["seal-use skill dump"] }, { name: "install", summary: "Install skill to active workspace", usage: ["seal-use skill install [--dir <path>|--local]"] }, { name: "status", summary: "Check skill installation status", usage: ["seal-use skill status"] } ] }, { area: "doctor", title: "System diagnostic and environment health check", description: "Inspects runtime executable, filesystem paths, enterprise assets, and embedded specifications without modifying any files.", commands: [ { name: "", summary: "Run complete system diagnostic health check", usage: ["seal-use doctor [--quiet]"], options: [ { flag: "--quiet", description: "Suppress formatted human dashboard on stderr" } ] }, { name: "guide", aliases: ["doc", "knowledge"], summary: "Read embedded system architecture & directory specification whitepaper", usage: ["seal-use doctor guide"] }, { name: "paths", aliases: ["dirs"], summary: "Inspect core filesystem paths and directory health", usage: ["seal-use doctor paths"] }, { name: "tenant", aliases: ["corp", "enterprise"], summary: "Inspect tenant-level health contract, auth permissions, AI approval quota, and rules state", usage: ["seal-use doctor tenant [--corp <corpId>] [--quiet]"], options: [ { flag: "--corp <corpId>", description: "Enterprise ID or selector to diagnose" }, { flag: "--quiet", description: "Suppress formatted dashboard on stderr" } ] } ] }, { area: "test", title: "Automated test harnesses and rule regression matrix", description: "Run automated regression tests and decision comparison matrix across paired production and test environments.", commands: [ { name: "regression", aliases: ["regress", "matrix"], summary: "Run automated rule regression test matrix against paired test enterprise", usage: ["seal-use test regression [--corp <corpId>] [--samples <N>] [--dry-run] [--fail-on-flips]"], options: [ { flag: "--corp <corpId>", description: "Target test enterprise or production parent (must be paired)" }, { flag: "--samples <N>", description: "Number of historical production runs to replay (default: 10)" }, { flag: "--dry-run", description: "Preview sample documents and verify quota without executing replayed audits" }, { flag: "--fail-on-flips", description: "Exit with non-zero code if any decision flip is detected" }, { flag: "--prod-corp <id>", description: "Explicit production enterprise source for sample documents" }, { flag: "--test-corp <id>", description: "Explicit test enterprise target for replay" }, { flag: "--quiet", description: "Suppress formatted summary dashboard on stderr" } ] } ] } ]; export function extractHelpRequest(args: ParsedArgs): { isHelp: boolean; target: string[] } { const hasHelpOption = Boolean(args.options.help || args.options.h); if (!args.command.length) { return { isHelp: true, target: [] }; } if (args.command[0] === "help") { return { isHelp: true, target: args.command.slice(1) }; } const helpIndex = args.command.indexOf("help"); if (helpIndex !== -1) { const target = args.command.filter((_, idx) => idx !== helpIndex); return { isHelp: true, target }; } if (hasHelpOption) { return { isHelp: true, target: [...args.command] }; } return { isHelp: false, target: [] }; } export function renderHelp(target: string[] = []): string { if (!target.length) { return renderGlobalHelp(); } const rawArea = target[0]; if (!rawArea) { return renderGlobalHelp(); } const rest = target.slice(1); const areaKey = normalizeArea(rawArea); const areaEntry = HELP_REGISTRY.find((entry) => entry.area === areaKey); if (!areaEntry) { throw usageError(`Unknown command: ${target.join(" ")}. Run 'seal-use help' for available commands.`); } if (!rest.length) { return renderAreaHelp(areaEntry); } const actionPath = rest.join(" ").toLowerCase(); const matchedCommand = findCommandInArea(areaEntry, actionPath, rest); if (!matchedCommand) { // 前缀命令(如 `report review` 覆盖 `review set`/`review list`):列出该组子命令而非报错 const groupPrefix = `${actionPath} `; const subcommands = areaEntry.commands.filter((cmd) => cmd.name?.startsWith(groupPrefix)); if (subcommands.length > 0) { return renderAreaHelp({ ...areaEntry, commands: subcommands }); } throw usageError(`Unknown ${areaEntry.area} command: ${rest.join(" ")}. Run 'seal-use ${areaEntry.area} --help' for available commands.`); } return renderCommandHelp(areaEntry, matchedCommand); } function normalizeArea(area: string): string { const lower = normalizeCliArea(area); if (lower === "changelog") return "update"; if (lower === "serve") return "http"; if (lower === "mcp-config") return "mcp"; return lower; } function findCommandInArea(areaEntry: AreaHelp, actionPath: string, rest: string[]): CommandHelp | undefined { const exact = areaEntry.commands.find((cmd) => { if (!cmd.name) return false; if (cmd.name.toLowerCase() === actionPath) return true; if (cmd.aliases?.some((alias) => alias.toLowerCase() === actionPath)) return true; return false; }); if (exact) return exact; const firstToken = rest[0]?.toLowerCase(); if (!firstToken) return undefined; const prefixMatch = areaEntry.commands.find((cmd) => { if (!cmd.name) return false; if (cmd.name.toLowerCase() === firstToken) return true; if (cmd.aliases?.some((alias) => alias.toLowerCase() === firstToken)) return true; return false; }); return prefixMatch; } function renderCommandHelp(areaEntry: AreaHelp, cmd: CommandHelp): string { const lines: string[] = []; const cmdTitle = cmd.name ? `seal-use ${areaEntry.area} ${cmd.name}` : `seal-use ${areaEntry.area}`; const header = cmd.summary ? `${cmdTitle} - ${cmd.summary}` : cmdTitle; lines.push(header); lines.push(""); lines.push("Usage:"); for (const usage of cmd.usage) { lines.push(` ${usage}`); } if (cmd.options && cmd.options.length > 0) { lines.push(""); lines.push("Options:"); const maxFlagLen = Math.max(...cmd.options.map((opt) => opt.flag.length)); for (const opt of cmd.options) { lines.push(` ${opt.flag.padEnd(maxFlagLen + 2)} ${opt.description}`); } } if (cmd.description) { lines.push(""); lines.push("Description:"); lines.push(` ${cmd.description}`); } return lines.join("\n"); } function renderAreaHelp(areaEntry: AreaHelp): string { const lines: string[] = []; lines.push(`seal-use ${areaEntry.area} - ${areaEntry.title}`); if (areaEntry.description) { lines.push(areaEntry.description); } lines.push(""); lines.push("Usage:"); const groupedCommands = new Map<string, CommandHelp[]>(); for (const cmd of areaEntry.commands) { const group = cmd.group ?? ""; const commands = groupedCommands.get(group) ?? []; commands.push(cmd); groupedCommands.set(group, commands); } const orderedGroups = [ ...(areaEntry.groupOrder ?? []), ...[...groupedCommands.keys()].filter((group) => !areaEntry.groupOrder?.includes(group)) ]; for (const group of orderedGroups) { const commands = groupedCommands.get(group); if (!commands) continue; if (group) { lines.push(""); lines.push(`${group}:`); } for (const cmd of commands) { for (const usage of cmd.usage) { lines.push(` ${usage}`); } } } if (areaEntry.commands.some((cmd) => cmd.name)) { lines.push(""); lines.push(`Run 'seal-use ${areaEntry.area} <command> --help' for details on a specific command.`); } return lines.join("\n"); } export function renderGlobalHelp(): string { const lines: string[] = []; lines.push("seal-use CLI"); lines.push(""); lines.push("Usage:"); lines.push(" seal-use version"); for (const area of HELP_REGISTRY) { for (const command of area.commands) { for (const usage of command.usage) { lines.push(` ${usage}`); } } } lines.push(""); lines.push("Run 'seal-use <command> --help' for details on a specific command."); return lines.join("\n"); }