diff --git a/AGENTS.md b/AGENTS.md
index 2ab49ce..594c634 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -2,7 +2,7 @@
## Project Structure & Module Organization
-This is a Bun + TypeScript toolkit for the `seal-use` CLI and a local stdio MCP server (`seal-use mcp`). Entry points are `src/cli.ts`, `src/server.ts`, and `src/probe.ts`. Shared config, auth, token, and HTTP code is under `src/core/`. Seal-specific API and tool logic is under `src/domains/seal/`.
+This is a Bun + TypeScript toolkit for the `seal-use` CLI and a local stdio MCP server (`seal-use mcp`). Entry points are `src/cli.ts`, `src/server.ts`, and `src/probe.ts`. Shared config, auth, token, and HTTP code is under `src/core/`. Seal-specific API and logic is under `src/domains/seal/`; the capability registry under `src/domains/seal/capabilities/` holds the shared handlers dispatched by the CLI (`runCapability`), the HTTP adapter (`POST /api/tool/:name`), and the MCP gateways. `seal_*` strings are internal registry identifiers — the MCP surface only ever exposes the `seal_cli` / `seal_cli_write` gateway pair, never these names (see README "One registry, three doors").
The repository doubles as a ZCode plugin: `.zcode-plugin/plugin.json` declares a skills-only plugin manifest and the agent skill lives under `skills/seal-use/`. The plugin ships no MCP surface; the local MCP runs from the CLI (`seal-use mcp`, or the `mcp-config` snippet for Cursor/Claude Desktop). The in-repo `.agents/skills/seal-use` symlink has been dropped; workspace and Codex skill loading use the global `~/.agents/skills/seal-use` copy installed by `seal-use skill install`.
diff --git a/README.md b/README.md
index 6897ac8..b885f10 100644
--- a/README.md
+++ b/README.md
@@ -157,7 +157,7 @@ bun run build:binary
## 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 tool registry, so the CLI, the HTTP adapter, and the MCP server all end up running the same tool handler with the same validation.
+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.
```bash
seal-use version
@@ -255,6 +255,18 @@ The service is intentionally local: `service start` runs the same HTTP adapter a
Most users do not need MCP. The public/shared path is the global `seal-use` CLI plus the optional local service.
+### One registry, three doors
+
+All approval/logic lives once in the capability registry under `src/domains/seal/capabilities/` (`src/domains/seal/capabilities.ts` re-exports it). Three surfaces enter the same handlers, each with its own naming:
+
+| Surface | Entry | Naming |
+| --- | --- | --- |
+| CLI (primary) | `seal-use ` via `runCapability` | Kebab verbs: `seal-use context`, `seal-use rules get` |
+| Local HTTP adapter | `POST /api/tool/:name` via `findSealCapability` | Registry IDs: `seal_approval_context_get` |
+| Local MCP server | `seal_cli` / `seal_cli_write` gateways that execute a CLI command string | Gateway names only — the registry IDs are the allow-list, never advertised as tools |
+
+`seal_*` strings are internal registry identifiers: they are valid as HTTP tool IDs and dispatch IDs, and they are **not** MCP tool names — no MCP client will ever see them in `tools/list`. If you are reading code and a `seal_*` name 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_cli` runs read-only commands and refuses anything that mutates tenant state, self-updates, or starts a server.
diff --git a/src/cli/commands/analytics.ts b/src/cli/commands/analytics.ts
index 3fc5b96..d3da195 100644
--- a/src/cli/commands/analytics.ts
+++ b/src/cli/commands/analytics.ts
@@ -1,7 +1,7 @@
import type { CorpConfig } from "../../core/config/types.js";
import type { createSealClient } from "../../core/http/factory.js";
import { exportInsightReportToExcel } from "../../domains/seal/insight-export.js";
-import { runTool } from "../helpers.js";
+import { runCapability } from "../helpers.js";
import { booleanOption, numberOption, stringOption } from "../parser.js";
import { outputOptions, printJson } from "../printer.js";
import type { ParsedArgs } from "../types.js";
@@ -14,7 +14,7 @@ export async function handleAnalyticsCommand(
args: ParsedArgs
) {
if (action === "insight" || action === "insight-stats" || action === "stats") {
- await runTool(
+ await runCapability(
"seal_insight_stats_get",
client,
corp,
@@ -33,7 +33,7 @@ export async function handleAnalyticsCommand(
if (!tagId) {
throw new Error("Usage: seal-use analytics risks [--start-date ] [--end-date ] [--corp ]");
}
- await runTool(
+ await runCapability(
"seal_insight_risks_by_tag_get",
client,
corp,
@@ -48,7 +48,7 @@ export async function handleAnalyticsCommand(
}
if (action === "performance" || action === "perf") {
- await runTool(
+ await runCapability(
"seal_insight_performance_get",
client,
corp,
@@ -66,7 +66,7 @@ export async function handleAnalyticsCommand(
if (!recordId) {
throw new Error("Usage: seal-use analytics analyze [--corp ]");
}
- await runTool(
+ await runCapability(
"seal_insight_record_analyze",
client,
corp,
diff --git a/src/cli/commands/approval-runs.ts b/src/cli/commands/approval-runs.ts
index 1d0b4bd..b86b0b2 100644
--- a/src/cli/commands/approval-runs.ts
+++ b/src/cli/commands/approval-runs.ts
@@ -6,7 +6,7 @@ import {
downloadApprovalRunAttachments,
extractApprovalRunAttachments
} from "../../domains/seal/attachments.js";
-import { runTool, runToolResult } from "../helpers.js";
+import { runCapability, runCapabilityResult } from "../helpers.js";
import { booleanOption, numberOption, stringOption } from "../parser.js";
import { outputOptions, printJson } from "../printer.js";
import type { ParsedArgs } from "../types.js";
@@ -25,7 +25,7 @@ export async function handleApprovalRunsCommand(
}
if (action === "summary") {
- const result = await runToolResult(
+ const result = await runCapabilityResult(
"seal_approval_runs_summary",
client,
corp,
@@ -54,7 +54,7 @@ export async function handleApprovalRunsCommand(
}
if (action === "stats") {
- const result = (await runToolResult(
+ const result = (await runCapabilityResult(
"seal_approval_runs_stats",
client,
corp,
@@ -86,7 +86,7 @@ export async function handleApprovalRunsCommand(
stringOption(args.options.end) ??
stringOption(args.options.endDate);
- await runTool(
+ await runCapability(
"seal_approval_runs_count",
client,
corp,
@@ -104,7 +104,7 @@ export async function handleApprovalRunsCommand(
}
if (action === "search" || action === "list") {
- await runTool(
+ await runCapability(
"seal_approval_runs_search",
client,
corp,
@@ -133,7 +133,7 @@ export async function handleApprovalRunsCommand(
}
if (action === "bridge") {
- await runTool(
+ await runCapability(
"seal_approval_run_langfuse_bridge_get",
client,
corp,
@@ -152,7 +152,7 @@ export async function handleApprovalRunsCommand(
if (action === "pick") {
const query = maybeName ?? stringOption(args.options.query) ?? stringOption(args.options.sn);
if (!query) throw new Error("Usage: seal-use approval-runs pick --sn ");
- await runTool(
+ await runCapability(
"seal_approval_run_pick",
client,
corp,
@@ -174,7 +174,7 @@ export async function handleApprovalRunsCommand(
const recordId = args.command[2];
if (!recordId) throw new Error("Missing approval run recordId");
if (booleanOption(args.options.flow)) {
- await runTool(
+ await runCapability(
"seal_approval_run_flow_get",
client,
corp,
@@ -183,7 +183,7 @@ export async function handleApprovalRunsCommand(
);
return;
}
- await runTool(
+ await runCapability(
"seal_approval_run_get",
client,
corp,
@@ -200,14 +200,14 @@ export async function handleApprovalRunsCommand(
if (action === "cited-rules") {
const recordId = args.command[2];
if (!recordId) throw new Error("Usage: seal-use approval-runs cited-rules ");
- await runTool("seal_approval_run_cited_rules_get", client, corp, { recordId }, outputOptions(args.options));
+ await runCapability("seal_approval_run_cited_rules_get", client, corp, { recordId }, outputOptions(args.options));
return;
}
if (action === "document-summary") {
const recordId = args.command[2];
if (!recordId) throw new Error("Usage: seal-use approval-runs document-summary ");
- await runTool("seal_approval_run_document_summary_get", client, corp, { recordId }, outputOptions(args.options));
+ await runCapability("seal_approval_run_document_summary_get", client, corp, { recordId }, outputOptions(args.options));
return;
}
@@ -217,7 +217,7 @@ export async function handleApprovalRunsCommand(
if (!recordId && !sn) {
throw new Error("Usage: seal-use approval-runs diagnose |--sn [--full] [--corp ]");
}
- await runTool(
+ await runCapability(
"seal_approval_run_diagnose",
client,
corp,
@@ -316,7 +316,7 @@ export async function handleApprovalRunsCommand(
if (action === "result") {
const recordId = args.command[2];
if (!recordId) throw new Error("Usage: seal-use approval-runs result [--summary]");
- await runTool(
+ await runCapability(
"seal_approval_run_result_get",
client,
corp,
@@ -347,7 +347,7 @@ export async function handleApprovalRunsCommand(
throw new Error("Usage: seal-use approval-runs link [--sn ] [--type seal-result|hose-document] [--auto-login] [--corp ]");
}
- await runTool(
+ await runCapability(
"seal_approval_run_url_get",
client,
corp,
@@ -376,7 +376,7 @@ export async function handleApprovalRunsCommand(
throw new Error("Usage: seal-use approval-runs hose-flow ");
}
- await runTool(
+ await runCapability(
"seal_approval_run_flow_get",
client,
corp,
diff --git a/src/cli/commands/auth.ts b/src/cli/commands/auth.ts
index a77a51f..0fa0489 100644
--- a/src/cli/commands/auth.ts
+++ b/src/cli/commands/auth.ts
@@ -8,7 +8,7 @@ import { createDelegation, getMe } from "../../domains/seal/api.js";
import { booleanOption, numberOption, stringOption } from "../parser.js";
import { outputOptions, printJson, redactSensitiveText } from "../printer.js";
import type { ParsedArgs } from "../types.js";
-import { runTool, runToolResult } from "../helpers.js";
+import { runCapability, runCapabilityResult } from "../helpers.js";
import { extractKeysFromLinkAction, showCorpKeysAction } from "./corps.js";
export async function handleAuthExtractKeysCommand(maybeName: string | undefined, args: ParsedArgs) {
@@ -78,19 +78,19 @@ export async function handleAuthCommand(action: string | undefined, corp: CorpCo
const client = await createSealClient(corp);
if (subAction === "list") {
- await runTool("seal_delegation_list", client, corp, {}, outputOptions(args.options));
+ await runCapability("seal_delegation_list", client, corp, {}, outputOptions(args.options));
return;
}
if (subAction === "revoke") {
const tokenId = args.command[3] ?? stringOption(args.options.tokenId) ?? stringOption(args.options.id);
if (!tokenId) throw new Error("Usage: seal-use auth link revoke ");
- await runTool("seal_delegation_revoke", client, corp, { tokenId }, outputOptions(args.options));
+ await runCapability("seal_delegation_revoke", client, corp, { tokenId }, outputOptions(args.options));
return;
}
const note = stringOption(args.options.note) ?? "CLI generated provisional access link";
- const delegation = await runToolResult(
+ const delegation = await runCapabilityResult(
"seal_delegation_create",
client,
corp,
diff --git a/src/cli/commands/billing.ts b/src/cli/commands/billing.ts
index b7ad6be..7b1bd10 100644
--- a/src/cli/commands/billing.ts
+++ b/src/cli/commands/billing.ts
@@ -1,6 +1,6 @@
import type { CorpConfig } from "../../core/config/types.js";
import type { createSealClient } from "../../core/http/factory.js";
-import { runTool } from "../helpers.js";
+import { runCapability } from "../helpers.js";
import { outputOptions } from "../printer.js";
import type { ParsedArgs } from "../types.js";
@@ -11,17 +11,17 @@ export async function handleBillingCommand(
args: ParsedArgs
) {
if (action === "status" || action === "get") {
- await runTool("seal_billing_status_get", client, corp, {}, outputOptions(args.options));
+ await runCapability("seal_billing_status_get", client, corp, {}, outputOptions(args.options));
return;
}
if (action === "plans") {
- await runTool("seal_billing_plans_list", client, corp, {}, outputOptions(args.options));
+ await runCapability("seal_billing_plans_list", client, corp, {}, outputOptions(args.options));
return;
}
if (action === "features") {
- await runTool("seal_billing_features_list", client, corp, {}, outputOptions(args.options));
+ await runCapability("seal_billing_features_list", client, corp, {}, outputOptions(args.options));
return;
}
diff --git a/src/cli/commands/contacts.ts b/src/cli/commands/contacts.ts
index 9cc4031..3e1765b 100644
--- a/src/cli/commands/contacts.ts
+++ b/src/cli/commands/contacts.ts
@@ -1,6 +1,6 @@
import type { CorpConfig } from "../../core/config/types.js";
import type { createSealClient } from "../../core/http/factory.js";
-import { runTool } from "../helpers.js";
+import { runCapability } from "../helpers.js";
import { outputOptions } from "../printer.js";
import type { ParsedArgs } from "../types.js";
@@ -12,29 +12,29 @@ export async function handleContactsCommand(
args: ParsedArgs
) {
if (action === "sync-time" || action === "last-sync-time") {
- await runTool("seal_contacts_last_sync_time_get", client, corp, {}, outputOptions(args.options));
+ await runCapability("seal_contacts_last_sync_time_get", client, corp, {}, outputOptions(args.options));
return;
}
if (action === "departments" || action === "department") {
if (!maybeName) {
- await runTool("seal_contacts_departments_root_list", client, corp, {}, outputOptions(args.options));
+ await runCapability("seal_contacts_departments_root_list", client, corp, {}, outputOptions(args.options));
return;
}
- await runTool("seal_contacts_department_get", client, corp, { departmentId: maybeName }, outputOptions(args.options));
+ await runCapability("seal_contacts_department_get", client, corp, { departmentId: maybeName }, outputOptions(args.options));
return;
}
if (action === "children" || action === "department-children") {
if (!maybeName) throw new Error("Usage: seal-use contacts children ");
- await runTool("seal_contacts_department_children_list", client, corp, { departmentId: maybeName }, outputOptions(args.options));
+ await runCapability("seal_contacts_department_children_list", client, corp, { departmentId: maybeName }, outputOptions(args.options));
return;
}
if (action === "users" || action === "department-users") {
if (!maybeName) throw new Error("Usage: seal-use contacts users ");
- await runTool("seal_contacts_department_users_list", client, corp, { departmentId: maybeName }, outputOptions(args.options));
+ await runCapability("seal_contacts_department_users_list", client, corp, { departmentId: maybeName }, outputOptions(args.options));
return;
}
diff --git a/src/cli/commands/context.ts b/src/cli/commands/context.ts
index 79ef278..047dd77 100644
--- a/src/cli/commands/context.ts
+++ b/src/cli/commands/context.ts
@@ -1,6 +1,6 @@
import type { CorpConfig } from "../../core/config/types.js";
import type { createSealClient } from "../../core/http/factory.js";
-import { runTool } from "../helpers.js";
+import { runCapability } from "../helpers.js";
import { numberOption, ruleVersionContextOptions, stringOption } from "../parser.js";
import { outputOptions } from "../printer.js";
import type { ParsedArgs } from "../types.js";
@@ -10,7 +10,7 @@ export async function handleContextCommand(
corp: CorpConfig,
args: ParsedArgs
) {
- await runTool(
+ await runCapability(
"seal_approval_context_get",
client,
corp,
diff --git a/src/cli/commands/data.ts b/src/cli/commands/data.ts
index 3c9b29e..7115fe8 100644
--- a/src/cli/commands/data.ts
+++ b/src/cli/commands/data.ts
@@ -1,6 +1,6 @@
import type { CorpConfig } from "../../core/config/types.js";
import type { createSealClient } from "../../core/http/factory.js";
-import { runTool } from "../helpers.js";
+import { runCapability } from "../helpers.js";
import { numberOption, stringOption } from "../parser.js";
import { outputOptions } from "../printer.js";
import type { ParsedArgs } from "../types.js";
@@ -20,12 +20,12 @@ export async function handleDataCommand(
};
if (action === "expenses" || action === "expense") {
- await runTool("seal_expenses_list", client, corp, params, outputOptions(args.options));
+ await runCapability("seal_expenses_list", client, corp, params, outputOptions(args.options));
return;
}
if (action === "invoices" || action === "invoice") {
- await runTool("seal_invoices_list", client, corp, params, outputOptions(args.options));
+ await runCapability("seal_invoices_list", client, corp, params, outputOptions(args.options));
return;
}
diff --git a/src/cli/commands/deploy.ts b/src/cli/commands/deploy.ts
index facc6e6..eb8f02f 100644
--- a/src/cli/commands/deploy.ts
+++ b/src/cli/commands/deploy.ts
@@ -1,7 +1,7 @@
import { readFileSync } from "node:fs";
import type { CorpConfig } from "../../core/config/types.js";
import type { createSealClient } from "../../core/http/factory.js";
-import { runTool } from "../helpers.js";
+import { runCapability } from "../helpers.js";
import { booleanOption, jsonObject, stringOption } from "../parser.js";
import { outputOptions } from "../printer.js";
import type { ParsedArgs } from "../types.js";
@@ -55,12 +55,12 @@ export async function handleDeployCommand(
}
if (action === "requirements") {
- await runTool("seal_deploy_hosecloud_requirements", client, corp, {}, outputOptions(args.options));
+ await runCapability("seal_deploy_hosecloud_requirements", client, corp, {}, outputOptions(args.options));
return;
}
if (action === "list") {
- await runTool("seal_deploy_hosecloud_list", client, corp, {}, outputOptions(args.options));
+ await runCapability("seal_deploy_hosecloud_list", client, corp, {}, outputOptions(args.options));
return;
}
@@ -92,12 +92,12 @@ export async function handleDeployCommand(
: undefined
);
}
- await runTool("seal_deploy_hosecloud_get", client, corp, { signKey }, outputOptions(args.options));
+ await runCapability("seal_deploy_hosecloud_get", client, corp, { signKey }, outputOptions(args.options));
return;
}
if (action === "status") {
- await runTool("seal_deploy_hosecloud_status", client, corp, {}, outputOptions(args.options));
+ await runCapability("seal_deploy_hosecloud_status", client, corp, {}, outputOptions(args.options));
return;
}
@@ -109,7 +109,7 @@ export async function handleDeployCommand(
if (!payload || Object.keys(payload).length === 0) {
throw new Error("Usage: seal-use deploy hosecloud configure --json '{...}' or --input ");
}
- await runTool("seal_deploy_hosecloud_configure", client, corp, {
+ await runCapability("seal_deploy_hosecloud_configure", client, corp, {
...payload,
dryRun: booleanOption(args.options.dryRun) ?? booleanOption(args.options["dry-run"])
}, outputOptions(args.options));
@@ -135,7 +135,7 @@ export async function handleDeployCommand(
if (firstHose && hoseConfigs.length === 1 && autoOpt) {
const singleKey = firstHose.signKey;
console.error(`ℹ️ [auto] 检测到企业仅有 1 个合思配置,已自动选择 (signKey: ${singleKey})`);
- await runTool("seal_deploy_hosecloud_sync", client, corp, { signKey: singleKey }, outputOptions(args.options));
+ await runCapability("seal_deploy_hosecloud_sync", client, corp, { signKey: singleKey }, outputOptions(args.options));
return;
}
@@ -162,7 +162,7 @@ export async function handleDeployCommand(
);
}
- await runTool("seal_deploy_hosecloud_sync", client, corp, { signKey }, outputOptions(args.options));
+ await runCapability("seal_deploy_hosecloud_sync", client, corp, { signKey }, outputOptions(args.options));
return;
}
diff --git a/src/cli/commands/documents.ts b/src/cli/commands/documents.ts
index 634be6d..c0b231c 100644
--- a/src/cli/commands/documents.ts
+++ b/src/cli/commands/documents.ts
@@ -2,7 +2,7 @@ import { readFileSync } from "node:fs";
import type { CorpConfig } from "../../core/config/types.js";
import type { createSealClient } from "../../core/http/factory.js";
import { confirmationRequired } from "../errors.js";
-import { runTool } from "../helpers.js";
+import { runCapability } from "../helpers.js";
import {
booleanOption,
jsonObject,
@@ -38,7 +38,7 @@ export async function handleDocumentsCommand(
const scenarios = splitOption(args.options.scenarios);
const limit = numberOption(args.options.limit);
const offset = numberOption(args.options.offset);
- await runTool(
+ await runCapability(
"seal_approval_documents_list",
client,
corp,
@@ -57,7 +57,7 @@ export async function handleDocumentsCommand(
if (!documentId) {
throw new Error("Usage: seal-use documents get [--corp ]");
}
- await runTool(
+ await runCapability(
"seal_approval_document_get",
client,
corp,
@@ -72,7 +72,7 @@ export async function handleDocumentsCommand(
if (!keyword) {
throw new Error("Usage: seal-use documents search [--maxResults 20] [--corp ]");
}
- await runTool(
+ await runCapability(
"seal_approval_search",
client,
corp,
@@ -120,7 +120,7 @@ export async function handleDocumentsCommand(
);
}
- await runTool(
+ await runCapability(
"seal_approval_document_create",
client,
corp,
@@ -184,7 +184,7 @@ export async function handleDocumentsCommand(
);
}
- await runTool(
+ await runCapability(
"seal_approval_document_update",
client,
corp,
@@ -220,7 +220,7 @@ export async function handleDocumentsCommand(
`seal-use documents delete ${documentId} --corp ${corp.id} --yes`
);
}
- await runTool(
+ await runCapability(
"seal_approval_delete_document",
client,
corp,
diff --git a/src/cli/commands/llm.ts b/src/cli/commands/llm.ts
index a3f91e4..e2571f6 100644
--- a/src/cli/commands/llm.ts
+++ b/src/cli/commands/llm.ts
@@ -1,6 +1,6 @@
import type { CorpConfig } from "../../core/config/types.js";
import type { createSealClient } from "../../core/http/factory.js";
-import { runTool } from "../helpers.js";
+import { runCapability } from "../helpers.js";
import { outputOptions } from "../printer.js";
import type { ParsedArgs } from "../types.js";
@@ -11,12 +11,12 @@ export async function handleLlmCommand(
args: ParsedArgs
) {
if (action === "config" || action === "get") {
- await runTool("seal_llm_config_get", client, corp, {}, outputOptions(args.options));
+ await runCapability("seal_llm_config_get", client, corp, {}, outputOptions(args.options));
return;
}
if (action === "providers" || action === "list") {
- await runTool("seal_llm_providers_list", client, corp, {}, outputOptions(args.options));
+ await runCapability("seal_llm_providers_list", client, corp, {}, outputOptions(args.options));
return;
}
diff --git a/src/cli/commands/permissions.ts b/src/cli/commands/permissions.ts
index 844116e..fc1adb8 100644
--- a/src/cli/commands/permissions.ts
+++ b/src/cli/commands/permissions.ts
@@ -1,6 +1,6 @@
import type { CorpConfig } from "../../core/config/types.js";
import type { createSealClient } from "../../core/http/factory.js";
-import { runTool } from "../helpers.js";
+import { runCapability } from "../helpers.js";
import { outputOptions } from "../printer.js";
import type { ParsedArgs } from "../types.js";
@@ -11,12 +11,12 @@ export async function handlePermissionsCommand(
args: ParsedArgs
) {
if (action === "available") {
- await runTool("seal_permissions_available_list", client, corp, {}, outputOptions(args.options));
+ await runCapability("seal_permissions_available_list", client, corp, {}, outputOptions(args.options));
return;
}
if (action === "configs" || action === "list") {
- await runTool("seal_permissions_configs_list", client, corp, {}, outputOptions(args.options));
+ await runCapability("seal_permissions_configs_list", client, corp, {}, outputOptions(args.options));
return;
}
diff --git a/src/cli/commands/preference.ts b/src/cli/commands/preference.ts
index 980e81f..df8c16f 100644
--- a/src/cli/commands/preference.ts
+++ b/src/cli/commands/preference.ts
@@ -1,7 +1,7 @@
import { readFileSync } from "node:fs";
import type { CorpConfig } from "../../core/config/types.js";
import type { createSealClient } from "../../core/http/factory.js";
-import { runTool } from "../helpers.js";
+import { runCapability } from "../helpers.js";
import { booleanOption, jsonObject, stringOption } from "../parser.js";
import { outputOptions } from "../printer.js";
import type { ParsedArgs } from "../types.js";
@@ -16,7 +16,7 @@ export async function handlePreferenceCommand(
args: ParsedArgs
) {
if (!action || action === "get") {
- await runTool("seal_preference_get", client, corp, {}, outputOptions(args.options));
+ await runCapability("seal_preference_get", client, corp, {}, outputOptions(args.options));
return;
}
@@ -29,7 +29,7 @@ export async function handlePreferenceCommand(
if (!payload || Object.keys(payload).length === 0) {
throw new Error("Usage: seal-use preference decision update --json '{\"explicitApprove\":\"...\"}'");
}
- await runTool("seal_preference_decision_update", client, corp, {
+ await runCapability("seal_preference_decision_update", client, corp, {
...payload,
dryRun: booleanOption(args.options.dryRun) ?? booleanOption(args.options["dry-run"])
}, outputOptions(args.options));
@@ -46,7 +46,7 @@ export async function handlePreferenceCommand(
if (defaultLevel !== "medium" && defaultLevel !== "high") {
throw new Error("Usage: seal-use preference thinking-depth set --default ");
}
- await runTool("seal_preference_thinking_depth_set", client, corp, {
+ await runCapability("seal_preference_thinking_depth_set", client, corp, {
defaultLevel,
dryRun: booleanOption(args.options.dryRun) ?? booleanOption(args.options["dry-run"])
}, outputOptions(args.options));
@@ -55,7 +55,7 @@ export async function handlePreferenceCommand(
if (subAction === "policies") {
if (thirdAction === "list" || !thirdAction) {
- await runTool("seal_preference_thinking_depth_policies_list", client, corp, {}, outputOptions(args.options));
+ await runCapability("seal_preference_thinking_depth_policies_list", client, corp, {}, outputOptions(args.options));
return;
}
@@ -67,7 +67,7 @@ export async function handlePreferenceCommand(
if (!payload || !payload.id || !payload.name) {
throw new Error("Usage: seal-use preference thinking-depth policies upsert --json '{\"id\":\"...\",\"name\":\"...\",\"level\":\"high\"}'");
}
- await runTool("seal_preference_thinking_depth_policies_upsert", client, corp, {
+ await runCapability("seal_preference_thinking_depth_policies_upsert", client, corp, {
...payload,
dryRun: booleanOption(args.options.dryRun) ?? booleanOption(args.options["dry-run"])
}, outputOptions(args.options));
@@ -79,7 +79,7 @@ export async function handlePreferenceCommand(
if (!policyId) {
throw new Error("Usage: seal-use preference thinking-depth policies remove ");
}
- await runTool("seal_preference_thinking_depth_policies_remove", client, corp, {
+ await runCapability("seal_preference_thinking_depth_policies_remove", client, corp, {
policyId,
dryRun: booleanOption(args.options.dryRun) ?? booleanOption(args.options["dry-run"])
}, outputOptions(args.options));
diff --git a/src/cli/commands/rules.ts b/src/cli/commands/rules.ts
index 8b7547c..c6cd4b1 100644
--- a/src/cli/commands/rules.ts
+++ b/src/cli/commands/rules.ts
@@ -7,7 +7,7 @@ import {
PRIMARY_LINTERS_DIR,
OFFICIAL_LINTERS_DIR
} from "../../domains/seal/linter/index.js";
-import { runTool, runToolResult } from "../helpers.js";
+import { runCapability, runCapabilityResult } from "../helpers.js";
import { confirmationRequired } from "../errors.js";
import {
booleanOption,
@@ -62,21 +62,21 @@ export async function handleRulesCommand(
if (action === "count") {
const version = resolveVersionOption(args);
- await runTool("seal_approval_rules_list", client!, corp, { version, countOnly: true }, outputOptions(args.options));
+ await runCapability("seal_approval_rules_list", client!, corp, { version, countOnly: true }, outputOptions(args.options));
return;
}
if (action === "list") {
const version = resolveVersionOption(args);
if (booleanOption(args.options.count)) {
- await runTool("seal_approval_rules_list", client!, corp, { version, countOnly: true }, outputOptions(args.options));
+ await runCapability("seal_approval_rules_list", client!, corp, { version, countOnly: true }, outputOptions(args.options));
return;
}
const limit = numberOption(args.options.limit);
const offset = numberOption(args.options.offset);
if (booleanOption(args.options.summary)) {
- await runTool(
+ await runCapability(
"seal_approval_rules_list",
client!,
corp,
@@ -91,7 +91,7 @@ export async function handleRulesCommand(
return;
}
- const result = await runToolResult("seal_approval_rules_list", client!, corp, { version, limit, offset });
+ const result = await runCapabilityResult("seal_approval_rules_list", client!, corp, { version, limit, offset });
const output = outputOptions(args.options);
protectLargeRuleListOutput(result, output.allowFull === true || Boolean(output.outputFile));
printJson(result, output);
@@ -107,7 +107,7 @@ export async function handleRulesCommand(
`seal-use rules clear --corp ${corp.id} --dry-run`
);
}
- const result = await runToolResult("seal_approval_rules_clear", client!, corp, {
+ const result = await runCapabilityResult("seal_approval_rules_clear", client!, corp, {
dryRun,
recode: booleanOption(args.options.recode)
});
@@ -126,14 +126,14 @@ export async function handleRulesCommand(
}
if (action === "versions") {
- await runTool("seal_approval_rule_versions_list", client!, corp, {}, outputOptions(args.options));
+ await runCapability("seal_approval_rule_versions_list", client!, corp, {}, outputOptions(args.options));
return;
}
if (action === "version") {
const version = resolveVersionOption(args, maybeName);
if (!version) throw new Error("Usage: seal-use rules version ");
- await runTool(
+ await runCapability(
"seal_approval_rule_version_get",
client!,
corp,
@@ -150,7 +150,7 @@ export async function handleRulesCommand(
throw new Error("Usage: seal-use rules diff [--code ] [--full]");
}
const singleSelector = args.command[4];
- await runTool(
+ await runCapability(
"seal_approval_rule_version_diff",
client!,
corp,
@@ -179,7 +179,7 @@ export async function handleRulesCommand(
if (!target) {
throw new Error("Usage: seal-use rules get [--version ] [--record-id ] [--corp ]");
}
- await runTool(
+ await runCapability(
"seal_approval_rule_get",
client!,
corp,
@@ -203,7 +203,7 @@ export async function handleRulesCommand(
if (!description || !scope) {
throw new Error("Usage: seal-use rules create --description --scope [--strictness ] [--description-file ] [--corp ]");
}
- await runTool(
+ await runCapability(
"seal_approval_rule_create",
client!,
corp,
@@ -229,7 +229,7 @@ export async function handleRulesCommand(
if (!ruleId || (description === undefined && scope === undefined && strictness === undefined)) {
throw new Error("Usage: seal-use rules update [--description |--description-file ] [--scope ] [--strictness ] [--corp ]");
}
- await runTool(
+ await runCapability(
"seal_approval_rule_update",
client!,
corp,
@@ -255,7 +255,7 @@ export async function handleRulesCommand(
`seal-use rules delete ${ruleId} --corp ${corp.id} --yes`
);
}
- await runTool(
+ await runCapability(
"seal_approval_rule_delete",
client!,
corp,
@@ -276,7 +276,7 @@ export async function handleRulesCommand(
if (!versionName) {
throw new Error("Usage: seal-use rules publish [--corp ]");
}
- await runTool(
+ await runCapability(
"seal_approval_rule_version_publish",
client!,
corp,
@@ -289,7 +289,7 @@ export async function handleRulesCommand(
if (action === "search") {
const keyword = maybeName ?? stringOption(args.options.query);
if (!keyword) throw new Error("Usage: seal-use rules search [--version ] [--maxResults 20] [--corp ]");
- await runTool(
+ await runCapability(
"seal_approval_search",
client!,
corp,
@@ -312,7 +312,7 @@ export async function handleRulesCommand(
if (action === "pull") {
const version = resolveVersionOption(args, maybeName);
const out = stringOption(args.options.out) ?? stringOption(args.options.file) ?? stringOption(args.options.f);
- await runTool(
+ await runCapability(
"seal_approval_rules_pull",
client!,
corp,
@@ -339,7 +339,7 @@ export async function handleRulesCommand(
);
}
- const result = await runToolResult(
+ const result = await runCapabilityResult(
"seal_approval_rules_push",
client!,
corp,
@@ -367,7 +367,7 @@ export async function handleRulesCommand(
}
if (action === "lint") {
- await runTool(
+ await runCapability(
"seal_approval_rules_lint",
client as Awaited>,
corp,
diff --git a/src/cli/commands/simulation.ts b/src/cli/commands/simulation.ts
index 4edd3f4..3ac1416 100644
--- a/src/cli/commands/simulation.ts
+++ b/src/cli/commands/simulation.ts
@@ -2,7 +2,7 @@ import { existsSync, readFileSync } from "node:fs";
import type { CorpConfig } from "../../core/config/types.js";
import type { createSealClient } from "../../core/http/factory.js";
import { confirmationRequired } from "../errors.js";
-import { runTool, runToolResult } from "../helpers.js";
+import { runCapability, runCapabilityResult } from "../helpers.js";
import {
booleanOption,
jsonObject,
@@ -23,7 +23,7 @@ export async function handleSimulationCommand(
if (action === "batch-records" || action === "records") {
const batchId = maybeName ?? stringOption(args.options.batchId) ?? stringOption(args.options["batch-id"]);
if (!batchId) throw new Error("Usage: seal-use simulation batch-records ");
- await runTool(
+ await runCapability(
"seal_simulation_batch_records_get",
client,
corp,
@@ -66,7 +66,7 @@ export async function handleSimulationCommand(
const wait = booleanOption(args.options.wait) === true;
const noWait = booleanOption(args.options.noWait) ?? booleanOption(args.options["no-wait"]) ?? (wait ? false : true);
- const result = await runToolResult(
+ const result = await runCapabilityResult(
"seal_simulation_batch_create",
client,
corp,
@@ -102,7 +102,7 @@ export async function handleSimulationCommand(
);
if (wait && result && typeof result === "object" && "batchId" in result && typeof result.batchId === "string") {
- await runTool(
+ await runCapability(
"seal_simulation_batch_wait",
client,
corp,
@@ -123,7 +123,7 @@ export async function handleSimulationCommand(
if (action === "wait") {
const batchId = maybeName ?? stringOption(args.options.batchId) ?? stringOption(args.options["batch-id"]);
if (!batchId) throw new Error("Usage: seal-use simulation wait [--timeout 10m] [--poll-interval 2s]");
- await runTool(
+ await runCapability(
"seal_simulation_batch_wait",
client,
corp,
@@ -140,7 +140,7 @@ export async function handleSimulationCommand(
if (action === "status") {
const batchId = maybeName ?? stringOption(args.options.batchId) ?? stringOption(args.options["batch-id"]);
if (!batchId) throw new Error("Usage: seal-use simulation status ");
- await runTool(
+ await runCapability(
"seal_simulation_batch_status",
client,
corp,
@@ -160,7 +160,7 @@ export async function handleSimulationCommand(
`seal-use simulation clean ${batchId} --corp ${corp.id} --yes`
);
}
- await runTool("seal_simulation_batch_clean", client, corp, { batchId }, outputOptions(args.options));
+ await runCapability("seal_simulation_batch_clean", client, corp, { batchId }, outputOptions(args.options));
return;
}
@@ -170,12 +170,12 @@ export async function handleSimulationCommand(
stringOption(args.options.integration) ??
stringOption(args.options.signKey) ??
stringOption(args.options["sign-key"]);
- await runTool("seal_simulation_specifications_list", client, corp, { signKey }, outputOptions(args.options));
+ await runCapability("seal_simulation_specifications_list", client, corp, { signKey }, outputOptions(args.options));
return;
}
if (action === "approval-definitions" || action === "definitions") {
- await runTool(
+ await runCapability(
"seal_simulation_feishu_approval_definitions_list",
client,
corp,
@@ -186,7 +186,7 @@ export async function handleSimulationCommand(
}
if (action === "list") {
- await runTool(
+ await runCapability(
"seal_simulation_batches_list",
client,
corp,
@@ -201,17 +201,17 @@ export async function handleSimulationCommand(
if (action === "get") {
const batchId = maybeName ?? stringOption(args.options.batchId) ?? stringOption(args.options["batch-id"]);
if (!batchId) throw new Error("Usage: seal-use simulation get ");
- await runTool("seal_simulation_batch_get", client, corp, { batchId }, outputOptions(args.options));
+ await runCapability("seal_simulation_batch_get", client, corp, { batchId }, outputOptions(args.options));
return;
}
if (action === "templates") {
- await runTool("seal_simulation_templates_get", client, corp, {}, outputOptions(args.options));
+ await runCapability("seal_simulation_templates_get", client, corp, {}, outputOptions(args.options));
return;
}
if (action === "integrations") {
- await runTool("seal_simulation_integrations_get", client, corp, {}, outputOptions(args.options));
+ await runCapability("seal_simulation_integrations_get", client, corp, {}, outputOptions(args.options));
return;
}
@@ -219,7 +219,7 @@ export async function handleSimulationCommand(
const filePath = maybeName ?? stringOption(args.options.file);
if (!filePath) throw new Error("Usage: seal-use simulation package-upload <材料包.zip>");
if (!existsSync(filePath)) throw new Error(`File not found: ${filePath}`);
- await runTool("seal_simulation_material_package_upload", client, corp, { filePath }, outputOptions(args.options));
+ await runCapability("seal_simulation_material_package_upload", client, corp, { filePath }, outputOptions(args.options));
return;
}
diff --git a/src/cli/commands/users.ts b/src/cli/commands/users.ts
index 0c0cfe1..4441ea0 100644
--- a/src/cli/commands/users.ts
+++ b/src/cli/commands/users.ts
@@ -1,7 +1,7 @@
import type { CorpConfig } from "../../core/config/types.js";
import type { createSealClient } from "../../core/http/factory.js";
import { confirmationRequired } from "../errors.js";
-import { runTool } from "../helpers.js";
+import { runCapability } from "../helpers.js";
import { booleanOption, stringOption } from "../parser.js";
import { outputOptions } from "../printer.js";
import type { ParsedArgs } from "../types.js";
@@ -19,7 +19,7 @@ export async function handleUsersCommand(
if (!name || !phone) throw new Error("Usage: seal-use users create --name --phone [--dept ]");
const deptId = stringOption(args.options.dept) ?? stringOption(args.options.departmentId);
const departmentIds = deptId ? [deptId] : undefined;
- await runTool("seal_user_create", client, corp, { name, phone, departmentIds }, outputOptions(args.options));
+ await runCapability("seal_user_create", client, corp, { name, phone, departmentIds }, outputOptions(args.options));
return;
}
@@ -33,20 +33,20 @@ export async function handleUsersCommand(
`seal-use users reset-password ${userId} --corp ${corp.id} --yes`
);
}
- await runTool("seal_user_reset_password", client, corp, { userId }, outputOptions(args.options));
+ await runCapability("seal_user_reset_password", client, corp, { userId }, outputOptions(args.options));
return;
}
if (action === "search" || action === "list") {
const keyword = maybeName ?? stringOption(args.options.keyword) ?? stringOption(args.options.query) ?? "";
- await runTool("seal_user_search", client, corp, { keyword }, outputOptions(args.options));
+ await runCapability("seal_user_search", client, corp, { keyword }, outputOptions(args.options));
return;
}
if (action === "get") {
const userId = maybeName ?? stringOption(args.options.userId);
if (!userId) throw new Error("Usage: seal-use users get ");
- await runTool("seal_user_get", client, corp, { userId }, outputOptions(args.options));
+ await runCapability("seal_user_get", client, corp, { userId }, outputOptions(args.options));
return;
}
@@ -60,14 +60,14 @@ export async function handleUsersCommand(
`seal-use users delete ${userId} --corp ${corp.id} --yes`
);
}
- await runTool("seal_user_delete", client, corp, { userId }, outputOptions(args.options));
+ await runCapability("seal_user_delete", client, corp, { userId }, outputOptions(args.options));
return;
}
if (action === "activate") {
const userId = maybeName ?? stringOption(args.options.userId);
if (!userId) throw new Error("Usage: seal-use users activate ");
- await runTool("seal_user_activate", client, corp, { userId }, outputOptions(args.options));
+ await runCapability("seal_user_activate", client, corp, { userId }, outputOptions(args.options));
return;
}
@@ -75,7 +75,7 @@ export async function handleUsersCommand(
const userIdOrPhone = maybeName ?? stringOption(args.options.userId) ?? stringOption(args.options.phone);
if (!userIdOrPhone) throw new Error("Usage: seal-use users delegation [--note ]");
const note = stringOption(args.options.note);
- await runTool("seal_user_delegation_create", client, corp, { userIdOrPhone, note }, outputOptions(args.options));
+ await runCapability("seal_user_delegation_create", client, corp, { userIdOrPhone, note }, outputOptions(args.options));
return;
}
diff --git a/src/cli/commands/webhook.ts b/src/cli/commands/webhook.ts
index f705f68..068e71a 100644
--- a/src/cli/commands/webhook.ts
+++ b/src/cli/commands/webhook.ts
@@ -3,7 +3,7 @@ import type { createSealClient } from "../../core/http/factory.js";
import { createSealClient as createNewSealClient } from "../../core/http/factory.js";
import { resolveSealCustomHeaders } from "../../core/http/request-headers.js";
import { existsSync } from "node:fs";
-import { runTool, selectCorp } from "../helpers.js";
+import { runCapability, selectCorp } from "../helpers.js";
import * as api from "../../domains/seal/api.js";
import { findWebhookIntegration } from "../../domains/seal/api.js";
import type { WebhookIntegration } from "../../domains/seal/types.js";
@@ -315,7 +315,7 @@ export async function handleWebhookCommand(
return;
}
if (action === "list") {
- await runTool(
+ await runCapability(
"seal_webhook_list",
client,
corp,
@@ -331,7 +331,7 @@ export async function handleWebhookCommand(
if (action === "get" || action === "find") {
const selector = maybeName ?? stringOption(args.options.selector) ?? stringOption(args.options.id);
if (!selector) throw new Error("Usage: seal-use webhook get [--show-secret]");
- await runTool(
+ await runCapability(
"seal_webhook_get",
client,
corp,
@@ -357,7 +357,7 @@ export async function handleWebhookCommand(
const autoApprovalRate = webhookRateOption(args.options);
const materialPackFilePolicy = materialPackFilePolicyOptions(args.options);
const dryRun = booleanOption(args.options.dryRun) ?? booleanOption(args.options["dry-run"]);
- await runTool(
+ await runCapability(
"seal_webhook_add",
client,
corp,
@@ -405,7 +405,7 @@ export async function handleWebhookCommand(
) {
throw usageError("Webhook update requires at least one field option");
}
- await runTool(
+ await runCapability(
"seal_webhook_update",
client,
corp,
@@ -435,7 +435,7 @@ export async function handleWebhookCommand(
`seal-use webhook delete ${selector} --corp ${corp.id} --yes`
);
}
- await runTool(
+ await runCapability(
"seal_webhook_delete",
client,
corp,
diff --git a/src/cli/helpers.ts b/src/cli/helpers.ts
index c788e96..e4e4bfb 100644
--- a/src/cli/helpers.ts
+++ b/src/cli/helpers.ts
@@ -2,7 +2,7 @@ import { getEnterprisesDirCandidates, loadCorpConfigs, loadGlobalConfig, resolve
import { resolveCorpConfig } from "../core/config/manager.js";
import { recordCorpUsage } from "../core/stats/usage-tracker.js";
import { createSealClient } from "../core/http/factory.js";
-import { sealTools, parseToolParams, type SealTool } from "../domains/seal/tools.js";
+import { sealCapabilities, parseCapabilityParams, type SealCapability } from "../domains/seal/capabilities.js";
import type { CorpConfig, GlobalConfig } from "../core/config/types.js";
import { printJson } from "./printer.js";
import type { OutputOptions } from "./types.js";
@@ -38,23 +38,23 @@ export function globalConfigSummary(config: GlobalConfig = loadGlobalConfig()) {
};
}
-export async function runTool(
+export async function runCapability(
name: string,
client: Awaited>,
corp: CorpConfig,
params: Record,
options: OutputOptions = {}
) {
- printJson(await runToolResult(name, client, corp, params), options);
+ printJson(await runCapabilityResult(name, client, corp, params), options);
}
-export async function runToolResult(
+export async function runCapabilityResult(
name: string,
client: Awaited>,
corp: CorpConfig,
params: Record
) {
- const tool = sealTools.find((item) => item.name === name);
+ const tool = sealCapabilities.find((item) => item.name === name);
if (!tool) throw new Error(`Unknown Seal tool: ${name}`);
const compactParams = Object.fromEntries(
@@ -63,7 +63,7 @@ export async function runToolResult(
// Schema gate: a missing required field or an out-of-range value fails here
// with exit 13 instead of reaching the handler as `undefined` and surfacing
// as an opaque upstream error. Valid params pass through untouched.
- parseToolParams(tool, compactParams);
- const handler = tool.handler as SealTool["handler"];
+ parseCapabilityParams(tool, compactParams);
+ const handler = tool.handler as SealCapability["handler"];
return handler(client, compactParams as never, { corp });
}
diff --git a/src/cli/read-only.test.ts b/src/cli/read-only.test.ts
index 1085410..2a96c5e 100644
--- a/src/cli/read-only.test.ts
+++ b/src/cli/read-only.test.ts
@@ -3,18 +3,18 @@ import { readFileSync, readdirSync } from "node:fs";
import { join } from "node:path";
import { HELP_REGISTRY } from "./help.js";
import { KNOWN_AREAS } from "./runner.js";
-import { SEAL_MUTATING_TOOLS, SEAL_READ_ONLY_TOOLS, sealTools } from "../domains/seal/tools.js";
+import { SEAL_MUTATING_CAPABILITIES, SEAL_READ_ONLY_CAPABILITIES, sealCapabilities } from "../domains/seal/capabilities.js";
import { isReadOnlyCliCommand, listReadOnlyCommands } from "./read-only.js";
describe("CLI read-only classification", () => {
test("the tool registry is classified exhaustively and without overlap", () => {
- const all = sealTools.map((tool) => tool.name);
- const classified = [...SEAL_READ_ONLY_TOOLS, ...SEAL_MUTATING_TOOLS];
+ const all = sealCapabilities.map((tool) => tool.name);
+ const classified = [...SEAL_READ_ONLY_CAPABILITIES, ...SEAL_MUTATING_CAPABILITIES];
// A newly added tool must fail here rather than silently defaulting into either bucket.
expect(classified.slice().sort()).toEqual(all.slice().sort());
- for (const name of SEAL_READ_ONLY_TOOLS) {
- expect({ name, alsoMutating: SEAL_MUTATING_TOOLS.has(name) }).toEqual({ name, alsoMutating: false });
+ for (const name of SEAL_READ_ONLY_CAPABILITIES) {
+ expect({ name, alsoMutating: SEAL_MUTATING_CAPABILITIES.has(name) }).toEqual({ name, alsoMutating: false });
}
});
@@ -142,7 +142,7 @@ describe("CLI read-only classification", () => {
});
// The two classifications are maintained by hand, in different files: the CLI allow-list here and
-// SEAL_READ_ONLY_TOOLS in the tool registry. Nothing stopped them from disagreeing, and they did —
+// SEAL_READ_ONLY_CAPABILITIES in the tool registry. Nothing stopped them from disagreeing, and they did —
// `analytics analyze` was allow-listed while its tool POSTs, and three read-only approval-runs verbs
// were simply missing. This derives one from the other and fails on any new disagreement.
describe("CLI allow-list agrees with the tool registry", () => {
@@ -159,7 +159,7 @@ describe("CLI allow-list agrees with the tool registry", () => {
for (const file of files) {
const area = file.replace(/\.ts$/, "");
const source = readFileSync(join(import.meta.dir, "commands", file), "utf8");
- const pattern = /action === "([a-z0-9-]+)"[\s\S]{0,600}?runTool\(\s*"(seal_[a-z_0-9]+)"/g;
+ const pattern = /action === "([a-z0-9-]+)"[\s\S]{0,600}?runCapability\(\s*"(seal_[a-z_0-9]+)"/g;
let match;
while ((match = pattern.exec(source))) {
pairs.push({ area, action: match[1]!, tool: match[2]! });
@@ -170,7 +170,7 @@ describe("CLI allow-list agrees with the tool registry", () => {
expect(pairs.length).toBeGreaterThan(50);
const disagreements = pairs
- .filter((pair) => SEAL_READ_ONLY_TOOLS.has(pair.tool))
+ .filter((pair) => SEAL_READ_ONLY_CAPABILITIES.has(pair.tool))
.filter((pair) => !UNREACHABLE_CLI_FORMS.has(`${pair.area} ${pair.action}`))
.filter((pair) => !isReadOnlyCliCommand([pair.area, pair.action]))
.map((pair) => `${pair.area} ${pair.action} -> ${pair.tool}`);
diff --git a/src/cli/read-only.ts b/src/cli/read-only.ts
index 0ba16ca..900d2f0 100644
--- a/src/cli/read-only.ts
+++ b/src/cli/read-only.ts
@@ -76,7 +76,7 @@ const READ_ONLY_COMMANDS: Record = {
permissions: ["available", "configs"],
billing: ["status", "plans", "features"],
// `analyze` is deliberately absent: it POSTs and starts an analysis server-side, so it is a
- // mutation despite reading like a query. See SEAL_MUTATING_TOOLS.
+ // mutation despite reading like a query. See SEAL_MUTATING_CAPABILITIES.
analytics: ["insight", "risks", "performance", "export"],
source: ["config"],
skill: ["dump", "status"],
diff --git a/src/domains/seal/tools.test.ts b/src/domains/seal/capabilities.test.ts
similarity index 79%
rename from src/domains/seal/tools.test.ts
rename to src/domains/seal/capabilities.test.ts
index ccc7fea..ca0a402 100644
--- a/src/domains/seal/tools.test.ts
+++ b/src/domains/seal/capabilities.test.ts
@@ -7,9 +7,9 @@ import { join } from "node:path";
import { CorpConfig } from "../../core/config/types.js";
import { CliError } from "../../core/errors.js";
import { saveRuleMappingSnapshot } from "./rule-mapping.js";
-import { buildRulePushPlan, findSealTool, sealTools } from "./tools.js";
+import { buildRulePushPlan, findSealCapability, sealCapabilities } from "./capabilities.js";
-type ToolHandler = (
+type CapabilityHandler = (
client: KyInstance,
params: Record,
context: { corp: CorpConfig }
@@ -30,9 +30,9 @@ afterEach(() => {
}
});
-describe("sealTools", () => {
+describe("sealCapabilities", () => {
test("exposes concrete JSON schemas for parameterized tools", () => {
- const createRule = sealTools.find((tool) => tool.name === "seal_approval_rule_create");
+ const createRule = sealCapabilities.find((tool) => tool.name === "seal_approval_rule_create");
expect(createRule).toBeDefined();
const schema = z.toJSONSchema(createRule!.parameters) as {
@@ -49,35 +49,35 @@ describe("sealTools", () => {
});
test("includes the approval context aggregation tool", () => {
- const tool = sealTools.find((item) => item.name === "seal_approval_context_get");
+ const tool = sealCapabilities.find((item) => item.name === "seal_approval_context_get");
expect(tool).toBeDefined();
});
test("includes the session diagnostic tool", () => {
- const tool = sealTools.find((item) => item.name === "seal_session_get");
+ const tool = sealCapabilities.find((item) => item.name === "seal_session_get");
expect(tool).toBeDefined();
});
test("includes the delegation management tools", () => {
- const listTool = sealTools.find((item) => item.name === "seal_delegation_list");
- const createTool = sealTools.find((item) => item.name === "seal_delegation_create");
- const revokeTool = sealTools.find((item) => item.name === "seal_delegation_revoke");
+ const listTool = sealCapabilities.find((item) => item.name === "seal_delegation_list");
+ const createCapability = sealCapabilities.find((item) => item.name === "seal_delegation_create");
+ const revokeTool = sealCapabilities.find((item) => item.name === "seal_delegation_revoke");
expect(listTool).toBeDefined();
- expect(createTool).toBeDefined();
+ expect(createCapability).toBeDefined();
expect(revokeTool).toBeDefined();
});
test("includes user management tools", () => {
- const createTool = sealTools.find((item) => item.name === "seal_user_create");
- const resetTool = sealTools.find((item) => item.name === "seal_user_reset_password");
- const getTool = sealTools.find((item) => item.name === "seal_user_get");
- const searchTool = sealTools.find((item) => item.name === "seal_user_search");
- const deleteTool = sealTools.find((item) => item.name === "seal_user_delete");
- const activateTool = sealTools.find((item) => item.name === "seal_user_activate");
- const userDelegationTool = sealTools.find((item) => item.name === "seal_user_delegation_create");
+ const createCapability = sealCapabilities.find((item) => item.name === "seal_user_create");
+ const resetTool = sealCapabilities.find((item) => item.name === "seal_user_reset_password");
+ const getTool = sealCapabilities.find((item) => item.name === "seal_user_get");
+ const searchTool = sealCapabilities.find((item) => item.name === "seal_user_search");
+ const deleteTool = sealCapabilities.find((item) => item.name === "seal_user_delete");
+ const activateTool = sealCapabilities.find((item) => item.name === "seal_user_activate");
+ const userDelegationTool = sealCapabilities.find((item) => item.name === "seal_user_delegation_create");
- expect(createTool).toBeDefined();
+ expect(createCapability).toBeDefined();
expect(resetTool).toBeDefined();
expect(getTool).toBeDefined();
expect(searchTool).toBeDefined();
@@ -87,105 +87,105 @@ describe("sealTools", () => {
});
test("includes read-only contacts directory tools", () => {
- expect(sealTools.find((item) => item.name === "seal_contacts_departments_root_list")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_contacts_department_get")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_contacts_department_children_list")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_contacts_department_users_list")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_contacts_last_sync_time_get")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_contacts_departments_root_list")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_contacts_department_get")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_contacts_department_children_list")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_contacts_department_users_list")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_contacts_last_sync_time_get")).toBeDefined();
});
test("includes the read-only insight stats and analytics tools", () => {
- expect(sealTools.find((item) => item.name === "seal_insight_stats_get")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_insight_risks_by_tag_get")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_insight_performance_get")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_insight_record_analyze")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_insight_export")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_insight_stats_get")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_insight_risks_by_tag_get")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_insight_performance_get")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_insight_record_analyze")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_insight_export")).toBeDefined();
});
test("includes read-only financial data tools", () => {
- expect(sealTools.find((item) => item.name === "seal_expenses_list")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_invoices_list")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_expenses_list")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_invoices_list")).toBeDefined();
});
test("includes the Feishu simulation approval definition tool", () => {
- expect(sealTools.find((item) => item.name === "seal_simulation_feishu_approval_definitions_list")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_simulation_feishu_approval_definitions_list")).toBeDefined();
});
test("includes system configuration tools", () => {
- expect(sealTools.find((item) => item.name === "seal_llm_config_get")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_llm_providers_list")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_permissions_available_list")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_permissions_configs_list")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_billing_status_get")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_billing_plans_list")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_billing_features_list")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_llm_config_get")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_llm_providers_list")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_permissions_available_list")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_permissions_configs_list")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_billing_status_get")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_billing_plans_list")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_billing_features_list")).toBeDefined();
});
test("includes Webhook management tools", () => {
- expect(sealTools.find((item) => item.name === "seal_webhook_list")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_webhook_get")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_webhook_add")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_webhook_update")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_webhook_delete")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_webhook_replay")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_webhook_list")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_webhook_get")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_webhook_add")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_webhook_update")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_webhook_delete")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_webhook_replay")).toBeDefined();
});
test("includes deploy hosecloud tools", () => {
- expect(sealTools.find((item) => item.name === "seal_deploy_hosecloud_requirements")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_deploy_hosecloud_list")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_deploy_hosecloud_get")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_deploy_hosecloud_status")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_deploy_hosecloud_configure")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_deploy_hosecloud_sync")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_deploy_hosecloud_requirements")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_deploy_hosecloud_list")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_deploy_hosecloud_get")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_deploy_hosecloud_status")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_deploy_hosecloud_configure")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_deploy_hosecloud_sync")).toBeDefined();
});
test("includes preference and thinking-depth tools", () => {
- expect(sealTools.find((item) => item.name === "seal_preference_get")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_preference_decision_update")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_preference_thinking_depth_set")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_preference_thinking_depth_policies_list")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_preference_thinking_depth_policies_upsert")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_preference_thinking_depth_policies_remove")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_preference_get")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_preference_decision_update")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_preference_thinking_depth_set")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_preference_thinking_depth_policies_list")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_preference_thinking_depth_policies_upsert")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_preference_thinking_depth_policies_remove")).toBeDefined();
});
test("includes simulation wait, clean, specifications tools and approval run stats/count", () => {
- expect(sealTools.find((item) => item.name === "seal_simulation_batch_wait")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_simulation_batch_clean")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_simulation_specifications_list")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_approval_runs_stats")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_approval_runs_count")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_simulation_batch_wait")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_simulation_batch_clean")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_simulation_specifications_list")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_approval_runs_stats")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_approval_runs_count")).toBeDefined();
});
test("includes the approval search tool", () => {
- const tool = sealTools.find((item) => item.name === "seal_approval_search");
+ const tool = sealCapabilities.find((item) => item.name === "seal_approval_search");
expect(tool).toBeDefined();
});
test("approval rules list can return count only", async () => {
- const tool = sealTools.find((item) => item.name === "seal_approval_rules_list");
+ const tool = sealCapabilities.find((item) => item.name === "seal_approval_rules_list");
expect(tool).toBeDefined();
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
const result = await handler(fakeRulesClient(), { countOnly: true }, fakeContext());
expect(result).toEqual({ count: 2 });
});
test("approval rules list treats limit zero as count only", async () => {
- const tool = sealTools.find((item) => item.name === "seal_approval_rules_list");
+ const tool = sealCapabilities.find((item) => item.name === "seal_approval_rules_list");
expect(tool).toBeDefined();
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
const result = await handler(fakeRulesClient(), { fields: ["id"], limit: 0 }, fakeContext());
expect(result).toEqual({ count: 2 });
});
test("approval rules list can project lightweight fields", async () => {
- const tool = sealTools.find((item) => item.name === "seal_approval_rules_list");
+ const tool = sealCapabilities.find((item) => item.name === "seal_approval_rules_list");
expect(tool).toBeDefined();
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
const result = await handler(
fakeRulesClient(),
{ fields: ["id", "code", "status", "strictness", "scope"], limit: 1 },
@@ -206,10 +206,10 @@ describe("sealTools", () => {
});
test("approval rules list renders timestamps in standard Beijing ISO format", async () => {
- const tool = sealTools.find((item) => item.name === "seal_approval_rules_list");
+ const tool = sealCapabilities.find((item) => item.name === "seal_approval_rules_list");
expect(tool).toBeDefined();
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
const full = await handler(fakeRulesClient(), {}, fakeContext()) as {
rules: Array>;
@@ -255,9 +255,9 @@ describe("sealTools", () => {
}]
});
- const tool = sealTools.find((item) => item.name === "seal_approval_rule_get");
+ const tool = sealCapabilities.find((item) => item.name === "seal_approval_rule_get");
expect(tool).toBeDefined();
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
const context = { corp: { ...fakeContext().corp, testCorpId: "t-corp-1" } };
const draft = await handler(fakeRulesClient(), { code: "29" }, context) as Record;
@@ -274,9 +274,9 @@ describe("sealTools", () => {
});
test("approval rule update without --if-unchanged leaves concurrency check absent", async () => {
- const tool = sealTools.find((item) => item.name === "seal_approval_rule_update");
+ const tool = sealCapabilities.find((item) => item.name === "seal_approval_rule_update");
expect(tool).toBeDefined();
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
const result = await handler(
fakeRuleUpdateClient(1780898164536),
{ ruleId: "29", description: "当单据金额超过 5000 元时必须提供发票原件与行程证明。" },
@@ -286,8 +286,8 @@ describe("sealTools", () => {
});
test("approval rule update --if-unchanged rejects when the draft moved on (exit 13)", async () => {
- const tool = sealTools.find((item) => item.name === "seal_approval_rule_update");
- const handler = tool!.handler as ToolHandler;
+ const tool = sealCapabilities.find((item) => item.name === "seal_approval_rule_update");
+ const handler = tool!.handler as CapabilityHandler;
try {
await handler(
fakeRuleUpdateClient(1780898164536),
@@ -302,8 +302,8 @@ describe("sealTools", () => {
});
test("approval rule update --if-unchanged proceeds when the draft is unchanged", async () => {
- const tool = sealTools.find((item) => item.name === "seal_approval_rule_update");
- const handler = tool!.handler as ToolHandler;
+ const tool = sealCapabilities.find((item) => item.name === "seal_approval_rule_update");
+ const handler = tool!.handler as CapabilityHandler;
const result = await handler(
fakeRuleUpdateClient(1780898164536),
{ ruleId: "29", description: "当单据金额超过 5000 元时必须提供发票原件与行程证明。", ifUnchanged: "2026-06-08T13:56:04+08:00" },
@@ -313,9 +313,9 @@ describe("sealTools", () => {
});
test("seal_approval_run_diagnose aggregates document, result, cited rules, and version snapshot", async () => {
- const tool = sealTools.find((item) => item.name === "seal_approval_run_diagnose");
+ const tool = sealCapabilities.find((item) => item.name === "seal_approval_run_diagnose");
expect(tool).toBeDefined();
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
const byRecord = await handler(fakeDiagnoseClient(), { recordId: "run-1" }, fakeContext()) as Record;
expect(byRecord.recordId).toBe("run-1");
@@ -339,11 +339,11 @@ describe("sealTools", () => {
});
test("approval rules clear can dry run without deleting", async () => {
- const tool = sealTools.find((item) => item.name === "seal_approval_rules_clear");
+ const tool = sealCapabilities.find((item) => item.name === "seal_approval_rules_clear");
expect(tool).toBeDefined();
const client = fakeClearRulesClient();
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
const result = await handler(client, { dryRun: true }, fakeContext()) as {
dryRun: boolean;
beforeCount: number;
@@ -361,11 +361,11 @@ describe("sealTools", () => {
});
test("approval rules clear deletes all draft rules", async () => {
- const tool = sealTools.find((item) => item.name === "seal_approval_rules_clear");
+ const tool = sealCapabilities.find((item) => item.name === "seal_approval_rules_clear");
expect(tool).toBeDefined();
const client = fakeClearRulesClient();
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
const result = await handler(client, {}, fakeContext()) as {
dryRun: boolean;
beforeCount: number;
@@ -385,7 +385,7 @@ describe("sealTools", () => {
});
test("preference dry run reads config without patching it", async () => {
- const tool = sealTools.find((item) => item.name === "seal_preference_decision_update");
+ const tool = sealCapabilities.find((item) => item.name === "seal_preference_decision_update");
expect(tool).toBeDefined();
let patched = false;
const client = {
@@ -408,7 +408,7 @@ describe("sealTools", () => {
}
} as unknown as KyInstance;
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
const result = await handler(client, { explicitApprove: "new", dryRun: true }, fakeContext()) as {
preview: boolean;
targetUrl: string;
@@ -503,22 +503,22 @@ describe("sealTools", () => {
});
test("includes approval run Langfuse bridge tools", () => {
- expect(sealTools.find((item) => item.name === "seal_approval_runs_search")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_approval_runs_summary")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_simulation_batch_records_get")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_approval_run_langfuse_bridge_get")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_approval_runs_search")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_approval_runs_summary")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_simulation_batch_records_get")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_approval_run_langfuse_bridge_get")).toBeDefined();
});
- test("can find tools by name in sealTools", () => {
- expect(findSealTool("seal_approval_rule_create")).toBeDefined();
- expect(findSealTool("non_existent_tool")).toBeUndefined();
+ test("can find tools by name in sealCapabilities", () => {
+ expect(findSealCapability("seal_approval_rule_create")).toBeDefined();
+ expect(findSealCapability("non_existent_tool")).toBeUndefined();
});
test("approval run search omits bridge unless requested", async () => {
- const tool = sealTools.find((item) => item.name === "seal_approval_runs_search");
+ const tool = sealCapabilities.find((item) => item.name === "seal_approval_runs_search");
expect(tool).toBeDefined();
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
const result = await handler(fakeApprovalRunsClient(), { limit: 1 }, fakeContext());
expect(result).not.toHaveProperty("bridge");
@@ -526,10 +526,10 @@ describe("sealTools", () => {
});
test("approval run search can filter by extracted human result", async () => {
- const tool = sealTools.find((item) => item.name === "seal_approval_runs_search");
+ const tool = sealCapabilities.find((item) => item.name === "seal_approval_runs_search");
expect(tool).toBeDefined();
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
const result = await handler(
fakeApprovalRunsClient(),
{ humanResult: "驳回", limit: 10 },
@@ -551,11 +551,11 @@ describe("sealTools", () => {
});
test("approval run search maps rejected human result to manual approval status", async () => {
- const tool = sealTools.find((item) => item.name === "seal_approval_runs_search");
+ const tool = sealCapabilities.find((item) => item.name === "seal_approval_runs_search");
expect(tool).toBeDefined();
const requests: string[] = [];
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
await handler(
fakeApprovalRunsClient(requests),
{
@@ -573,11 +573,11 @@ describe("sealTools", () => {
});
test("approval run search forwards query as API search parameter", async () => {
- const tool = sealTools.find((item) => item.name === "seal_approval_runs_search");
+ const tool = sealCapabilities.find((item) => item.name === "seal_approval_runs_search");
expect(tool).toBeDefined();
const requests: string[] = [];
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
await handler(
fakeApprovalRunsClient(requests),
{
@@ -595,10 +595,10 @@ describe("sealTools", () => {
});
test("approval run get returns stable aliases for document concepts", async () => {
- const tool = sealTools.find((item) => item.name === "seal_approval_run_get");
+ const tool = sealCapabilities.find((item) => item.name === "seal_approval_run_get");
expect(tool).toBeDefined();
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
const result = await handler(
fakeApprovalRunsClient(),
{ recordId: "run-1" },
@@ -627,10 +627,10 @@ describe("sealTools", () => {
});
test("approval run get can return selected fields only", async () => {
- const tool = sealTools.find((item) => item.name === "seal_approval_run_get");
+ const tool = sealCapabilities.find((item) => item.name === "seal_approval_run_get");
expect(tool).toBeDefined();
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
const result = await handler(
fakeApprovalRunsClient(),
{ recordId: "run-1", fields: "metadata,document.fields,result.summary" },
@@ -650,10 +650,10 @@ describe("sealTools", () => {
});
test("approval run get can return summary preset", async () => {
- const tool = sealTools.find((item) => item.name === "seal_approval_run_get");
+ const tool = sealCapabilities.find((item) => item.name === "seal_approval_run_get");
expect(tool).toBeDefined();
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
const result = await handler(
fakeApprovalRunsClient(),
{ recordId: "run-1", summary: true },
@@ -666,11 +666,11 @@ describe("sealTools", () => {
});
test("approval run pick supports sn latest and compact candidate fields", async () => {
- const tool = sealTools.find((item) => item.name === "seal_approval_run_pick");
+ const tool = sealCapabilities.find((item) => item.name === "seal_approval_run_pick");
expect(tool).toBeDefined();
const requests: string[] = [];
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
const result = await handler(
fakeApprovalRunsClient(requests),
{ sn: "B26001965", latest: true },
@@ -687,10 +687,10 @@ describe("sealTools", () => {
});
test("approval run attachments extracts compact attachment metadata", async () => {
- const tool = sealTools.find((item) => item.name === "seal_approval_run_attachments_get");
+ const tool = sealCapabilities.find((item) => item.name === "seal_approval_run_attachments_get");
expect(tool).toBeDefined();
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
const result = await handler(
fakeApprovalRunsClient(),
{ recordId: "run-1" },
@@ -713,10 +713,10 @@ describe("sealTools", () => {
});
test("approval run cited rules extracts rule application details", async () => {
- const tool = sealTools.find((item) => item.name === "seal_approval_run_cited_rules_get");
+ const tool = sealCapabilities.find((item) => item.name === "seal_approval_run_cited_rules_get");
expect(tool).toBeDefined();
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
const result = await handler(
fakeApprovalRunsClient(),
{ recordId: "run-1" },
@@ -736,10 +736,10 @@ describe("sealTools", () => {
});
test("approval run document summary returns key fields without raw payload", async () => {
- const tool = sealTools.find((item) => item.name === "seal_approval_run_document_summary_get");
+ const tool = sealCapabilities.find((item) => item.name === "seal_approval_run_document_summary_get");
expect(tool).toBeDefined();
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
const result = await handler(
fakeApprovalRunsClient(),
{ recordId: "run-1" },
@@ -756,10 +756,10 @@ describe("sealTools", () => {
});
test("approval run result can return summary only", async () => {
- const tool = sealTools.find((item) => item.name === "seal_approval_run_result_get");
+ const tool = sealCapabilities.find((item) => item.name === "seal_approval_run_result_get");
expect(tool).toBeDefined();
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
const result = await handler(
fakeApprovalRunsClient(),
{ recordId: "run-1", summary: true },
@@ -782,10 +782,10 @@ describe("sealTools", () => {
});
test("approval run url returns Seal result and Hose document links by recordId", async () => {
- const tool = sealTools.find((item) => item.name === "seal_approval_run_url_get");
+ const tool = sealCapabilities.find((item) => item.name === "seal_approval_run_url_get");
expect(tool).toBeDefined();
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
const result = await handler(
fakeApprovalRunsClient(),
{ recordId: "run-1" },
@@ -822,10 +822,10 @@ describe("sealTools", () => {
});
test("approval run url supports type=hose-document", async () => {
- const tool = sealTools.find((item) => item.name === "seal_approval_run_url_get");
+ const tool = sealCapabilities.find((item) => item.name === "seal_approval_run_url_get");
expect(tool).toBeDefined();
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
const result = await handler(
fakeApprovalRunsClient(),
{ recordId: "run-1", type: "hose-document" },
@@ -846,11 +846,11 @@ describe("sealTools", () => {
});
test("approval run url throws error without a document lookup", async () => {
- const tool = sealTools.find((item) => item.name === "seal_approval_run_url_get");
+ const tool = sealCapabilities.find((item) => item.name === "seal_approval_run_url_get");
expect(tool).toBeDefined();
const requests: string[] = [];
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
await expect(
handler(
fakeApprovalRunsClient(requests),
@@ -862,12 +862,12 @@ describe("sealTools", () => {
});
test("approval run url can resolve by sourceDocumentSN", async () => {
- const tool = sealTools.find((item) => item.name === "seal_approval_run_url_get");
+ const tool = sealCapabilities.find((item) => item.name === "seal_approval_run_url_get");
expect(tool).toBeDefined();
primeHoseEnterpriseUrl("corp-a", "https://app.ekuaibao.com/web/home.html?accessToken=close-token");
const requests: string[] = [];
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
const result = await handler(
fakeApprovalRunsClient(requests),
{ sourceDocumentSN: "B26001965" },
@@ -883,11 +883,11 @@ describe("sealTools", () => {
});
test("approval run url returns auto_login link with identity, expiration, and warning when autoLogin=true", async () => {
- const tool = sealTools.find((item) => item.name === "seal_approval_run_url_get");
+ const tool = sealCapabilities.find((item) => item.name === "seal_approval_run_url_get");
expect(tool).toBeDefined();
primeHoseEnterpriseUrl("corp-a", "https://app.ekuaibao.com/web/home.html?accessToken=close-token");
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
const result = (await handler(
fakeApprovalRunsClient(),
{ recordId: "run-1", autoLogin: true, expiresIn: 3600 },
@@ -912,11 +912,11 @@ describe("sealTools", () => {
});
test("approval run url supports legacy hoseSso=true with explicit hose attribute naming", async () => {
- const tool = sealTools.find((item) => item.name === "seal_approval_run_url_get");
+ const tool = sealCapabilities.find((item) => item.name === "seal_approval_run_url_get");
expect(tool).toBeDefined();
primeHoseEnterpriseUrl("corp-a", "https://app.ekuaibao.com/web/home.html?accessToken=close-token");
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
const result = (await handler(
fakeApprovalRunsClient(),
{ recordId: "run-1", hoseSso: true },
@@ -937,10 +937,10 @@ describe("sealTools", () => {
});
test("approval run url throws clear error when sso=true is used on non-hose enterprise", async () => {
- const tool = sealTools.find((item) => item.name === "seal_approval_run_url_get");
+ const tool = sealCapabilities.find((item) => item.name === "seal_approval_run_url_get");
expect(tool).toBeDefined();
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
await expect(
handler(
fakeApprovalRunsClient(),
@@ -951,10 +951,10 @@ describe("sealTools", () => {
});
test("approval run summary filters by local date and returns compact aggregates", async () => {
- const tool = sealTools.find((item) => item.name === "seal_approval_runs_summary");
+ const tool = sealCapabilities.find((item) => item.name === "seal_approval_runs_summary");
expect(tool).toBeDefined();
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
const result = await handler(
fakeApprovalRunsClient(),
{ date: "2026-06-08", timezone: "Asia/Shanghai", limit: 100 },
@@ -977,10 +977,10 @@ describe("sealTools", () => {
});
test("approval rule get resolves one rule by version and code", async () => {
- const tool = sealTools.find((item) => item.name === "seal_approval_rule_get");
+ const tool = sealCapabilities.find((item) => item.name === "seal_approval_rule_get");
expect(tool).toBeDefined();
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
const result = await handler(
fakeRulesClient(),
{ versionNumber: 16, code: "44" },
@@ -998,9 +998,9 @@ describe("sealTools", () => {
});
test("approval rule get defaults to current draft and handles 0-based codes without +1 offset", async () => {
- const tool = sealTools.find((item) => item.name === "seal_approval_rule_get");
+ const tool = sealCapabilities.find((item) => item.name === "seal_approval_rule_get");
expect(tool).toBeDefined();
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
const client = fakeZeroBasedRulesClient();
// Draft lookup for code 0
@@ -1049,9 +1049,9 @@ describe("sealTools", () => {
});
test("approval run cited-rules extracts and merges result.rulesResult and result.hitRules", async () => {
- const tool = sealTools.find((item) => item.name === "seal_approval_run_cited_rules_get");
+ const tool = sealCapabilities.find((item) => item.name === "seal_approval_run_cited_rules_get");
expect(tool).toBeDefined();
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
const mockClient = {
get: () => ({
@@ -1124,10 +1124,10 @@ describe("sealTools", () => {
});
test("deploy hosecloud configure saves integration and rejects missing customApiUrl", async () => {
- const tool = sealTools.find((item) => item.name === "seal_deploy_hosecloud_configure");
+ const tool = sealCapabilities.find((item) => item.name === "seal_deploy_hosecloud_configure");
expect(tool).toBeDefined();
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
const client = fakeDeployClient();
// 1. Rejects custom environment without customApiUrl
@@ -1165,10 +1165,10 @@ describe("sealTools", () => {
});
test("deploy hosecloud status masks signKey alongside apiKey/apiSecret", async () => {
- const tool = sealTools.find((item) => item.name === "seal_deploy_hosecloud_status");
+ const tool = sealCapabilities.find((item) => item.name === "seal_deploy_hosecloud_status");
expect(tool).toBeDefined();
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
const client = {
get: (url: string) => {
if (url === "api/v1/simulation/integration-status") {
@@ -1208,7 +1208,7 @@ describe("sealTools", () => {
});
test("seal_approval_runs_count supports startDate and endDate and normalizes them", async () => {
- const tool = sealTools.find((item) => item.name === "seal_approval_runs_count");
+ const tool = sealCapabilities.find((item) => item.name === "seal_approval_runs_count");
expect(tool).toBeDefined();
const schema = z.toJSONSchema(tool!.parameters) as {
@@ -1220,7 +1220,7 @@ describe("sealTools", () => {
const requests: string[] = [];
const client = fakeApprovalRunsClient(requests);
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
const res = await handler(
client,
diff --git a/src/domains/seal/capabilities.ts b/src/domains/seal/capabilities.ts
new file mode 100644
index 0000000..7481db3
--- /dev/null
+++ b/src/domains/seal/capabilities.ts
@@ -0,0 +1,3 @@
+// Re-export from modular capabilities/ directory.
+// capabilities.ts was split into domain-specific modules under src/domains/seal/capabilities/.
+export * from "./capabilities/index.js";
diff --git a/src/domains/seal/tools/approval-runs.ts b/src/domains/seal/capabilities/approval-runs.ts
similarity index 99%
rename from src/domains/seal/tools/approval-runs.ts
rename to src/domains/seal/capabilities/approval-runs.ts
index 28eede4..db6d355 100644
--- a/src/domains/seal/tools/approval-runs.ts
+++ b/src/domains/seal/capabilities/approval-runs.ts
@@ -14,7 +14,7 @@ import {
type ApprovalRun
} from "../types.js";
import type {
- ToolContext
+ CapabilityContext
} from "./helpers.js";
import * as helpers from "./helpers.js";
@@ -45,7 +45,7 @@ const {
summarizeRuleVersion
} = helpers;
-export const approvalRunsTools = [
+export const approvalRunsCapabilities = [
{
name: "seal_approval_runs_search",
description: "查询 Seal 审批/审核运行记录总表,并整理合思单据到 Langfuse trace/session 的桥接字段",
@@ -194,7 +194,7 @@ export const approvalRunsTools = [
outputFile?: string;
toDownloads?: boolean;
},
- context: ToolContext
+ context: CapabilityContext
) => exportApprovalRunsToExcel(client, context.corp, params)
},
{
@@ -231,7 +231,7 @@ export const approvalRunsTools = [
handler: async (
client: KyInstance,
params: { target?: string; recordId?: string; sourceDocumentSN?: string },
- context: ToolContext
+ context: CapabilityContext
) => {
const corp = context.corp;
if (corp.source.type !== "hose") {
@@ -456,7 +456,7 @@ export const approvalRunsTools = [
hoseSso?: boolean;
expiresIn?: number;
},
- context: ToolContext
+ context: CapabilityContext
) => {
const hasDocumentLookup = Boolean(params.recordId || params.sourceDocumentSN || params.sourceDocumentId);
if (!hasDocumentLookup) {
@@ -579,7 +579,7 @@ export const approvalRunsTools = [
maxScan?: number;
includeBridge?: boolean;
},
- context: ToolContext
+ context: CapabilityContext
) => {
const query = params.sn ?? params.query;
if (!query) throw new Error("query or sn is required");
@@ -629,7 +629,7 @@ export const approvalRunsTools = [
handler: async (
client: KyInstance,
params: { sn?: string; recordId?: string; full?: boolean },
- context: ToolContext
+ context: CapabilityContext
) => {
if (!params.sn && !params.recordId) {
throw new Error("sn or recordId is required for approval run diagnosis");
diff --git a/src/domains/seal/tools/billing.ts b/src/domains/seal/capabilities/billing.ts
similarity index 97%
rename from src/domains/seal/tools/billing.ts
rename to src/domains/seal/capabilities/billing.ts
index c268c15..432df1b 100644
--- a/src/domains/seal/tools/billing.ts
+++ b/src/domains/seal/capabilities/billing.ts
@@ -2,7 +2,7 @@ import { z } from "zod";
import type { KyInstance } from "ky";
import * as api from "../api.js";
-export const billingTools = [
+export const billingCapabilities = [
{
name: "seal_llm_config_get",
description: "查询当前 Seal 租户的大模型 (LLM) 配置",
diff --git a/src/domains/seal/tools/contacts.ts b/src/domains/seal/capabilities/contacts.ts
similarity index 97%
rename from src/domains/seal/tools/contacts.ts
rename to src/domains/seal/capabilities/contacts.ts
index 8060583..2043665 100644
--- a/src/domains/seal/tools/contacts.ts
+++ b/src/domains/seal/capabilities/contacts.ts
@@ -2,7 +2,7 @@ import { z } from "zod";
import type { KyInstance } from "ky";
import * as api from "../api.js";
-export const contactsTools = [
+export const contactsCapabilities = [
{
name: "seal_contacts_departments_root_list",
description: "列出当前 Seal 租户通讯录的顶级部门",
diff --git a/src/domains/seal/tools/deploy.ts b/src/domains/seal/capabilities/deploy.ts
similarity index 98%
rename from src/domains/seal/tools/deploy.ts
rename to src/domains/seal/capabilities/deploy.ts
index e9f4148..c903ebe 100644
--- a/src/domains/seal/tools/deploy.ts
+++ b/src/domains/seal/capabilities/deploy.ts
@@ -7,7 +7,7 @@ import {
type HosecloudConfigInput
} from "../types.js";
import type {
- ToolContext
+ CapabilityContext
} from "./helpers.js";
import * as helpers from "./helpers.js";
@@ -16,7 +16,7 @@ const {
mutationPreview
} = helpers;
-export const deployTools = [
+export const deployCapabilities = [
{
name: "seal_deploy_hosecloud_requirements",
description: "获取 Seal AI 审批发布到合思费控所需配置字段与说明",
@@ -107,7 +107,7 @@ export const deployTools = [
customApiUrl: z.string().optional(),
dryRun: z.boolean().optional().describe("只返回前后配置 Diff,不执行写入")
}),
- handler: async (client: KyInstance, rawParams: HosecloudConfigInput, context: ToolContext) => {
+ handler: async (client: KyInstance, rawParams: HosecloudConfigInput, context: CapabilityContext) => {
const { dryRun, ...inputParams } = rawParams;
const apiKey = inputParams.apiKey ?? (inputParams as any).appKey;
const apiSecret = inputParams.apiSecret ?? (inputParams as any).appSecurity;
@@ -190,7 +190,7 @@ export const deployTools = [
parameters: z.object({
signKey: z.string().describe("合思集成 sign-key")
}),
- handler: async (client: KyInstance, params: { signKey: string }, context: ToolContext) => {
+ handler: async (client: KyInstance, params: { signKey: string }, context: CapabilityContext) => {
const config = await api.getApprovalStylePreferences(client);
const integration = (config.integrations ?? []).find(
(item: any) => item.type === "hosecloud" && item.signKey === params.signKey
diff --git a/src/domains/seal/tools/helpers.ts b/src/domains/seal/capabilities/helpers.ts
similarity index 99%
rename from src/domains/seal/tools/helpers.ts
rename to src/domains/seal/capabilities/helpers.ts
index 76915c9..89b6770 100644
--- a/src/domains/seal/tools/helpers.ts
+++ b/src/domains/seal/capabilities/helpers.ts
@@ -15,15 +15,15 @@ import type { LocalRuleItem } from "../rules-local.js";
import { loadRuleMappingSnapshot } from "../rule-mapping.js";
import { formatBeijingIso, normalizeBeijingIso } from "../../../core/config/timestamps.js";
-export type ToolContext = {
+export type CapabilityContext = {
corp: CorpConfig;
};
-export type SealToolDefinition = {
+export type SealCapabilityDefinition = {
name: string;
description: string;
parameters: z.ZodType;
- handler: (client: KyInstance, params: never, context: ToolContext) => Promise;
+ handler: (client: KyInstance, params: never, context: CapabilityContext) => Promise;
};
export function presentWebhookIntegration(
@@ -285,7 +285,7 @@ export function redactIntegrationSecrets(integration: Record) {
}
export function mutationPreview(
- context: ToolContext,
+ context: CapabilityContext,
endpoint: string,
before: unknown,
after: unknown,
diff --git a/src/domains/seal/tools/identity.ts b/src/domains/seal/capabilities/identity.ts
similarity index 98%
rename from src/domains/seal/tools/identity.ts
rename to src/domains/seal/capabilities/identity.ts
index 151fe76..31e4606 100644
--- a/src/domains/seal/tools/identity.ts
+++ b/src/domains/seal/capabilities/identity.ts
@@ -3,10 +3,10 @@ import type { KyInstance } from "ky";
import * as api from "../api.js";
import { createSealClientForToken } from "../../../core/http/factory.js";
import type {
- ToolContext
+ CapabilityContext
} from "./helpers.js";
-export const identityTools = [
+export const identityCapabilities = [
{
name: "seal_whoami",
description: "查询当前 Seal 用户身份及租户信息",
@@ -112,7 +112,7 @@ export const identityTools = [
handler: async (
client: KyInstance,
params: { userIdOrPhone: string; note?: string },
- context: ToolContext
+ context: CapabilityContext
) =>
api.createDelegationForUser(
client,
diff --git a/src/domains/seal/tools/index.ts b/src/domains/seal/capabilities/index.ts
similarity index 62%
rename from src/domains/seal/tools/index.ts
rename to src/domains/seal/capabilities/index.ts
index 66b00d9..5215442 100644
--- a/src/domains/seal/tools/index.ts
+++ b/src/domains/seal/capabilities/index.ts
@@ -1,38 +1,44 @@
-import { identityTools } from "./identity.js";
-import { contactsTools } from "./contacts.js";
-import { insightTools } from "./insight.js";
-import { billingTools } from "./billing.js";
-import { rulesTools } from "./rules.js";
-import { webhookTools } from "./webhook.js";
-import { approvalRunsTools } from "./approval-runs.js";
-import { simulationTools } from "./simulation.js";
-import { deployTools } from "./deploy.js";
-import { preferenceTools } from "./preference.js";
+import { identityCapabilities } from "./identity.js";
+import { contactsCapabilities } from "./contacts.js";
+import { insightCapabilities } from "./insight.js";
+import { billingCapabilities } from "./billing.js";
+import { rulesCapabilities } from "./rules.js";
+import { webhookCapabilities } from "./webhook.js";
+import { approvalRunsCapabilities } from "./approval-runs.js";
+import { simulationCapabilities } from "./simulation.js";
+import { deployCapabilities } from "./deploy.js";
+import { preferenceCapabilities } from "./preference.js";
export * from "./helpers.js";
export * from "./validate.js";
-export const sealTools = [
- ...identityTools,
- ...contactsTools,
- ...insightTools,
- ...billingTools,
- ...rulesTools,
- ...webhookTools,
- ...approvalRunsTools,
- ...simulationTools,
- ...deployTools,
- ...preferenceTools
+export const sealCapabilities = [
+ ...identityCapabilities,
+ ...contactsCapabilities,
+ ...insightCapabilities,
+ ...billingCapabilities,
+ ...rulesCapabilities,
+ ...webhookCapabilities,
+ ...approvalRunsCapabilities,
+ ...simulationCapabilities,
+ ...deployCapabilities,
+ ...preferenceCapabilities
];
-export type SealTool = (typeof sealTools)[number];
+export type SealCapability = (typeof sealCapabilities)[number];
/**
- * MCP read/write classification for the tool registry.
+ * Registry naming boundary: these entries are INTERNAL domain capability handlers, NOT MCP tools.
+ * The `seal_*` strings are identifiers for internal dispatch (`runCapability`), the HTTP adapter
+ * (`POST /api/tool/:name`), and the MCP gateway allow-lists below — the MCP server itself only ever
+ * exposes the `seal_cli` / `seal_cli_write` gateway pair and never these names. CLI verbs such as
+ * `seal-use context` are the only human-facing names (see README "One registry, three doors").
*
- * The two sets are exhaustive by construction: `tools.test.ts` asserts they partition `sealTools`
- * exactly, so a newly added tool fails the suite until it is classified here. The read-only MCP tool
- * (`seal_cli`) may only invoke names in {@link SEAL_READ_ONLY_TOOLS}; everything else is reachable
+ * MCP read/write classification for the capability registry.
+ *
+ * The two sets are exhaustive by construction: `capabilities.test.ts` asserts they partition `sealCapabilities`
+ * exactly, so a newly added capability fails the suite until it is classified here. The read-only MCP tool
+ * (`seal_cli`) may only invoke names in {@link SEAL_READ_ONLY_CAPABILITIES}; everything else is reachable
* solely through `seal_cli_write`.
*
* Read-only means it reads tenant state, or writes only a local file. Anything that creates, updates,
@@ -40,7 +46,7 @@ export type SealTool = (typeof sealTools)[number];
* including when it reads like a query. `seal_insight_record_analyze` is the instructive case: it
* sounds like a read but issues a POST that starts an analysis server-side.
*/
-export const SEAL_READ_ONLY_TOOLS: ReadonlySet = new Set([
+export const SEAL_READ_ONLY_CAPABILITIES: ReadonlySet = new Set([
"seal_approval_context_get",
"seal_approval_document_get",
"seal_approval_documents_list",
@@ -111,7 +117,7 @@ export const SEAL_READ_ONLY_TOOLS: ReadonlySet = new Set([
"seal_whoami"
]);
-export const SEAL_MUTATING_TOOLS: ReadonlySet = new Set([
+export const SEAL_MUTATING_CAPABILITIES: ReadonlySet = new Set([
"seal_approval_delete_document",
"seal_approval_document_create",
"seal_approval_document_update",
@@ -146,14 +152,14 @@ export const SEAL_MUTATING_TOOLS: ReadonlySet = new Set([
"seal_webhook_update"
]);
-export function isReadOnlySealTool(name: string): boolean {
- return SEAL_READ_ONLY_TOOLS.has(name);
+export function isReadOnlySealCapability(name: string): boolean {
+ return SEAL_READ_ONLY_CAPABILITIES.has(name);
}
-const sealToolByName = new Map(
- sealTools.map((tool) => [tool.name, tool])
+const sealCapabilityByName = new Map(
+ sealCapabilities.map((tool) => [tool.name, tool])
);
-export function findSealTool(name: string): SealTool | undefined {
- return sealToolByName.get(name);
+export function findSealCapability(name: string): SealCapability | undefined {
+ return sealCapabilityByName.get(name);
}
diff --git a/src/domains/seal/tools/insight.ts b/src/domains/seal/capabilities/insight.ts
similarity index 98%
rename from src/domains/seal/tools/insight.ts
rename to src/domains/seal/capabilities/insight.ts
index 1fe58a2..cf2a376 100644
--- a/src/domains/seal/tools/insight.ts
+++ b/src/domains/seal/capabilities/insight.ts
@@ -3,10 +3,10 @@ import type { KyInstance } from "ky";
import * as api from "../api.js";
import { exportInsightReportToExcel, type InsightExportOptions } from "../insight-export.js";
import type {
- ToolContext
+ CapabilityContext
} from "./helpers.js";
-export const insightTools = [
+export const insightCapabilities = [
{
name: "seal_insight_stats_get",
description: "查询智能洞察风险标签统计及分析状态",
@@ -70,7 +70,7 @@ export const insightTools = [
handler: async (
client: KyInstance,
params: InsightExportOptions,
- context: ToolContext
+ context: CapabilityContext
) => exportInsightReportToExcel(client, context.corp, params)
},
{
diff --git a/src/domains/seal/tools/preference.ts b/src/domains/seal/capabilities/preference.ts
similarity index 95%
rename from src/domains/seal/tools/preference.ts
rename to src/domains/seal/capabilities/preference.ts
index 6b945c4..f2a2c83 100644
--- a/src/domains/seal/tools/preference.ts
+++ b/src/domains/seal/capabilities/preference.ts
@@ -7,7 +7,7 @@ import {
type DecisionPreferences
} from "../types.js";
import type {
- ToolContext
+ CapabilityContext
} from "./helpers.js";
import * as helpers from "./helpers.js";
@@ -15,7 +15,7 @@ const {
mutationPreview
} = helpers;
-export const preferenceTools = [
+export const preferenceCapabilities = [
{
name: "seal_preference_get",
description: "获取当前决策偏好、思考深度偏好与绑定的规则版本",
@@ -39,7 +39,7 @@ export const preferenceTools = [
review: z.string().optional(),
dryRun: z.boolean().optional().describe("只返回前后配置 Diff,不执行写入")
}),
- handler: async (client: KyInstance, params: Partial & { dryRun?: boolean }, context: ToolContext) => {
+ handler: async (client: KyInstance, params: Partial & { dryRun?: boolean }, context: CapabilityContext) => {
const config = (await api.getApprovalStylePreferences(client, context.corp.seal.endpoints.approvalStylePreferences)) as any;
const { dryRun, ...changes } = params;
const updated = {
@@ -63,7 +63,7 @@ export const preferenceTools = [
defaultLevel: z.enum(["medium", "high"]).describe("默认思考深度"),
dryRun: z.boolean().optional().describe("只返回前后配置 Diff,不执行写入")
}),
- handler: async (client: KyInstance, params: { defaultLevel: "medium" | "high"; dryRun?: boolean }, context: ToolContext) => {
+ handler: async (client: KyInstance, params: { defaultLevel: "medium" | "high"; dryRun?: boolean }, context: CapabilityContext) => {
const config = (await api.getApprovalStylePreferences(client, context.corp.seal.endpoints.approvalStylePreferences)) as any;
const updated = {
...config,
@@ -96,7 +96,7 @@ export const preferenceTools = [
parameters: ThinkingPolicySchema.extend({
dryRun: z.boolean().optional().describe("只返回前后配置 Diff,不执行写入")
}),
- handler: async (client: KyInstance, policy: ThinkingPolicy & { dryRun?: boolean }, context: ToolContext) => {
+ handler: async (client: KyInstance, policy: ThinkingPolicy & { dryRun?: boolean }, context: CapabilityContext) => {
const config = (await api.getApprovalStylePreferences(client, context.corp.seal.endpoints.approvalStylePreferences)) as any;
const { dryRun, ...cleanPolicy } = policy;
const existing: ThinkingPolicy[] = config.thinkingDepthPreference?.routingPolicies ?? [];
@@ -124,7 +124,7 @@ export const preferenceTools = [
policyId: z.string().describe("路由策略 ID"),
dryRun: z.boolean().optional().describe("只返回前后配置 Diff,不执行写入")
}),
- handler: async (client: KyInstance, params: { policyId: string; dryRun?: boolean }, context: ToolContext) => {
+ handler: async (client: KyInstance, params: { policyId: string; dryRun?: boolean }, context: CapabilityContext) => {
const config = (await api.getApprovalStylePreferences(client, context.corp.seal.endpoints.approvalStylePreferences)) as any;
const existing: ThinkingPolicy[] = config.thinkingDepthPreference?.routingPolicies ?? [];
const next = existing.filter((item) => item.id !== params.policyId);
diff --git a/src/domains/seal/tools/rules.ts b/src/domains/seal/capabilities/rules.ts
similarity index 98%
rename from src/domains/seal/tools/rules.ts
rename to src/domains/seal/capabilities/rules.ts
index b4bc331..16c39ca 100644
--- a/src/domains/seal/tools/rules.ts
+++ b/src/domains/seal/capabilities/rules.ts
@@ -20,7 +20,7 @@ import {
type RuleSetVersion
} from "../types.js";
import type {
- ToolContext,
+ CapabilityContext,
RuleField
} from "./helpers.js";
import * as helpers from "./helpers.js";
@@ -42,12 +42,12 @@ const {
resolveCrossEnvRuleMapping
} = helpers;
-function attachCrossEnvRule(context: ToolContext, rule: Record) {
+function attachCrossEnvRule(context: CapabilityContext, rule: Record) {
const crossEnv = resolveCrossEnvRuleMapping(context.corp, rule);
return crossEnv ? { ...rule, crossEnv } : rule;
}
-export const rulesTools = [
+export const rulesCapabilities = [
{
name: "seal_approval_rules_list",
description: "列出 Seal 审批规则(默认当前草稿,传 version='latest' 或版本号则列出对应已发布版本);支持 countOnly、fields、limit",
@@ -112,7 +112,7 @@ export const rulesTools = [
handler: async (
client: KyInstance,
params: { dryRun?: boolean; recode?: boolean },
- context: ToolContext
+ context: CapabilityContext
) => {
const before = await api.listApprovalRules(client);
if (params.dryRun) {
@@ -207,7 +207,7 @@ export const rulesTools = [
strictness?: string;
ifUnchanged?: string | number;
},
- context: ToolContext
+ context: CapabilityContext
) => {
let resolvedRuleId = params.ruleId.trim();
const targetCodeNum = parseRuleCodeNumber(resolvedRuleId);
@@ -362,7 +362,7 @@ export const rulesTools = [
full?: boolean;
format?: "unified" | "json";
},
- context: ToolContext
+ context: CapabilityContext
) => {
const fromVersion = hydrateRuleVersionStableIds(context.corp.id, await resolveRuleVersionSelector(client, params.from));
const toVersion = hydrateRuleVersionStableIds(context.corp.id, await resolveRuleVersionSelector(client, params.to));
@@ -393,7 +393,7 @@ export const rulesTools = [
parameters: z.object({
versionName: z.string().describe("版本名称")
}),
- handler: async (client: KyInstance, params: { versionName: string }, context: ToolContext) => {
+ handler: async (client: KyInstance, params: { versionName: string }, context: CapabilityContext) => {
const draft = await api.listApprovalRules(client).catch(() => undefined);
const published = await api.publishApprovalRuleVersion(client, params.versionName);
if (draft) {
@@ -425,7 +425,7 @@ export const rulesTools = [
ruleId?: string;
recordId?: string;
},
- context: ToolContext
+ context: CapabilityContext
) => {
const selector = {
code: params.code,
@@ -490,7 +490,7 @@ export const rulesTools = [
level?: "all" | "error" | "warning";
summary?: boolean;
},
- context: ToolContext
+ context: CapabilityContext
) => {
let targets: RuleLintTarget[] = [];
let versionNumber: number | undefined;
@@ -578,7 +578,7 @@ export const rulesTools = [
version?: string;
out?: string;
},
- context: ToolContext
+ context: CapabilityContext
) => {
const outPath = params.out ?? "./rules.local.json";
let rules: LocalRuleItem[] = [];
@@ -657,7 +657,7 @@ export const rulesTools = [
publish?: boolean;
versionName?: string;
},
- context: ToolContext
+ context: CapabilityContext
) => {
const filePath = params.file ?? "./rules.local.json";
let local: ReturnType;
@@ -890,7 +890,7 @@ export const rulesTools = [
maxChars?: number;
fields?: string[];
},
- context: ToolContext
+ context: CapabilityContext
) => searchApprovalContent(client, context.corp, params)
},
{
@@ -910,7 +910,7 @@ export const rulesTools = [
ruleVersionNumber?: number;
latestRuleVersion?: boolean;
},
- context: ToolContext
+ context: CapabilityContext
) => {
const currentContext = await api.getApprovalContext(client, {
documentLimit: params.documentLimit,
@@ -935,7 +935,7 @@ export const rulesTools = [
name: "seal_approval_style_preferences_get",
description: "获取 Seal 审批风格偏好配置",
parameters: z.object({}),
- handler: async (client: KyInstance, _params: unknown, context: ToolContext) =>
+ handler: async (client: KyInstance, _params: unknown, context: CapabilityContext) =>
api.getApprovalStylePreferences(
client,
context.corp.seal.endpoints.approvalStylePreferences
@@ -956,7 +956,7 @@ export const rulesTools = [
handler: async (
client: KyInstance,
params: Record,
- context: ToolContext
+ context: CapabilityContext
) =>
api.updateApprovalStylePreferences(
client,
diff --git a/src/domains/seal/tools/simulation.ts b/src/domains/seal/capabilities/simulation.ts
similarity index 99%
rename from src/domains/seal/tools/simulation.ts
rename to src/domains/seal/capabilities/simulation.ts
index 3bcc5b3..bb47895 100644
--- a/src/domains/seal/tools/simulation.ts
+++ b/src/domains/seal/capabilities/simulation.ts
@@ -18,7 +18,7 @@ const {
filterRuns
} = helpers;
-export const simulationTools = [
+export const simulationCapabilities = [
{
name: "seal_simulation_feishu_approval_definitions_list",
description: "列出飞书模拟测试可用的审批定义,便于选择 approvalCode",
diff --git a/src/domains/seal/tools/validate.test.ts b/src/domains/seal/capabilities/validate.test.ts
similarity index 83%
rename from src/domains/seal/tools/validate.test.ts
rename to src/domains/seal/capabilities/validate.test.ts
index 86d1399..cea2388 100644
--- a/src/domains/seal/tools/validate.test.ts
+++ b/src/domains/seal/capabilities/validate.test.ts
@@ -1,9 +1,9 @@
import { describe, expect, test } from "bun:test";
import { CliError } from "../../../core/errors.js";
-import { findSealTool, parseToolParams, type SealTool } from "./index.js";
+import { findSealCapability, parseCapabilityParams, type SealCapability } from "./index.js";
-function tool(name: string): SealTool {
- const found = findSealTool(name);
+function tool(name: string): SealCapability {
+ const found = findSealCapability(name);
if (!found) throw new Error(`test fixture missing tool: ${name}`);
return found;
}
@@ -11,7 +11,7 @@ function tool(name: string): SealTool {
/** Asserts rejection and returns the message so tests can check its wording. */
function rejectsWith(toolName: string, params: Record): string {
try {
- parseToolParams(tool(toolName), params);
+ parseCapabilityParams(tool(toolName), params);
} catch (error) {
expect(error).toBeInstanceOf(CliError);
expect((error as CliError).exitCode).toBe(13);
@@ -20,14 +20,14 @@ function rejectsWith(toolName: string, params: Record): string
throw new Error(`expected ${toolName} to reject ${JSON.stringify(params)}`);
}
-describe("parseToolParams", () => {
+describe("parseCapabilityParams", () => {
test("accepts valid params and returns the exact object it was given", () => {
const target = tool("seal_user_create");
const params = { name: "张三", phone: "13800001111", departmentIds: ["d1"] };
// Identity matters: handlers read keys the schema does not declare, so the
// gate must pass its input through, never zod's (stripped) parse output.
- expect(parseToolParams(target, params)).toBe(params);
+ expect(parseCapabilityParams(target, params)).toBe(params);
});
test("names the missing required field instead of letting the handler crash on undefined", () => {
@@ -49,7 +49,7 @@ describe("parseToolParams", () => {
// /v1/* passes url.searchParams through: everything arrives as a string,
// but the schema declares z.number() / z.boolean(). Without coercion every
// REST route would 400 on its own documented query params.
- expect(parseToolParams(target, params)).toBe(params);
+ expect(parseCapabilityParams(target, params)).toBe(params);
expect(params.limit).toBe("50");
expect(params.includeBridge).toBe("true");
});
@@ -63,7 +63,7 @@ describe("parseToolParams", () => {
// `?fields=id,code` on /v1/approval/rules: today the handler receives a
// string and pickRuleFields iterates its characters, returning empty
// objects. Validation splits it so the documented form actually works.
- expect(parseToolParams(tool("seal_approval_rules_list"), { fields: "id,code" })).toEqual({
+ expect(parseCapabilityParams(tool("seal_approval_rules_list"), { fields: "id,code" })).toEqual({
fields: "id,code"
});
expect(rejectsWith("seal_approval_rules_list", { fields: "id,not-a-field" })).toContain("fields");
@@ -73,7 +73,7 @@ describe("parseToolParams", () => {
// z.object is non-strict: an extra HTTP body key is a compatibility
// non-event, not an error. This gate checks declared params only.
const target = tool("seal_approval_runs_search");
- expect(parseToolParams(target, { status: "TERMINATED", corp: "corp-a", stray: 1 })).toBeTypeOf("object");
+ expect(parseCapabilityParams(target, { status: "TERMINATED", corp: "corp-a", stray: 1 })).toBeTypeOf("object");
});
test("lets the legacy credential aliases through to the handler that supports them", () => {
@@ -81,7 +81,7 @@ describe("parseToolParams", () => {
// alongside apiKey/apiSecret; a schema that declared only apiKey as
// required would have blocked that documented path.
expect(() =>
- parseToolParams(tool("seal_deploy_hosecloud_configure"), {
+ parseCapabilityParams(tool("seal_deploy_hosecloud_configure"), {
appKey: "key-1",
appSecurity: "secret-1",
mode: "assisted"
diff --git a/src/domains/seal/tools/validate.ts b/src/domains/seal/capabilities/validate.ts
similarity index 93%
rename from src/domains/seal/tools/validate.ts
rename to src/domains/seal/capabilities/validate.ts
index 3f81fd3..8f38533 100644
--- a/src/domains/seal/tools/validate.ts
+++ b/src/domains/seal/capabilities/validate.ts
@@ -1,13 +1,13 @@
import { z } from "zod";
import { validationError } from "../../../core/errors.js";
-import type { SealTool } from "./index.js";
+import type { SealCapability } from "./index.js";
/**
* Checks one invocation's params against the schema its tool declares, then
* returns the params unchanged.
*
- * Both dispatch paths — `runToolResult` (every CLI command) and
- * `executeSealTool` (`POST /api/tool/:name`, every `/v1/*` route) — used to
+ * Both dispatch paths — `runCapabilityResult` (every CLI command) and
+ * `executeSealCapability` (`POST /api/tool/:name`, every `/v1/*` route) — used to
* hand `params` straight to `handler`, so a required field could be missing, a
* limit could be `999999`, or a typo'd HTTP body key could sail through and
* surface later as an opaque upstream error or a `Cannot read properties of
@@ -29,7 +29,7 @@ import type { SealTool } from "./index.js";
* declares (see {@link coerceWireTypes}) because `/v1/*` query strings arrive
* entirely as strings while the schema says `z.number()`.
*/
-export function parseToolParams(tool: SealTool, params: Record): Record {
+export function parseCapabilityParams(tool: SealCapability, params: Record): Record {
const result = tool.parameters.safeParse(coerceWireTypes(tool.parameters, params));
if (result.success) return params;
diff --git a/src/domains/seal/tools/webhook.ts b/src/domains/seal/capabilities/webhook.ts
similarity index 97%
rename from src/domains/seal/tools/webhook.ts
rename to src/domains/seal/capabilities/webhook.ts
index 014d176..a20dac3 100644
--- a/src/domains/seal/tools/webhook.ts
+++ b/src/domains/seal/capabilities/webhook.ts
@@ -19,7 +19,7 @@ import {
type WebhookMode
} from "../types.js";
import type {
- ToolContext
+ CapabilityContext
} from "./helpers.js";
import * as helpers from "./helpers.js";
@@ -29,7 +29,7 @@ const {
mutationPreview
} = helpers;
-export const webhookTools = [
+export const webhookCapabilities = [
{
name: "seal_webhook_list",
description: "列出当前 Seal 租户的 Webhook 集成,可按 ID、名称或 URL 查找",
@@ -40,7 +40,7 @@ export const webhookTools = [
handler: async (
client: KyInstance,
params: { query?: string; includeSecret?: boolean },
- context: ToolContext
+ context: CapabilityContext
) => {
const integrations = api.filterWebhookIntegrations(
await api.listWebhookIntegrations(
@@ -65,7 +65,7 @@ export const webhookTools = [
handler: async (
client: KyInstance,
params: { selector: string; includeSecret?: boolean },
- context: ToolContext
+ context: CapabilityContext
) => {
const integration = api.findWebhookIntegration(
await api.listWebhookIntegrations(
@@ -100,7 +100,7 @@ export const webhookTools = [
materialPackFilePolicy?: Partial>;
dryRun?: boolean;
},
- context: ToolContext
+ context: CapabilityContext
) => {
const baseUrl = getConfiguredSealBaseUrl(context.corp);
const preview = params.dryRun
@@ -154,7 +154,7 @@ export const webhookTools = [
materialPackFilePolicy?: Partial>;
dryRun?: boolean;
},
- context: ToolContext
+ context: CapabilityContext
) => {
if (params.secret !== undefined && params.rotateSecret) {
throw new Error("Webhook secret and rotateSecret cannot be used together");
@@ -197,7 +197,7 @@ export const webhookTools = [
handler: async (
client: KyInstance,
params: { selector: string; confirm?: boolean; dryRun?: boolean },
- context: ToolContext
+ context: CapabilityContext
) => {
if (!params.confirm && !params.dryRun) {
throw new Error("Refusing to delete Webhook integration without confirm=true");
@@ -256,7 +256,7 @@ export const webhookTools = [
dryRun?: boolean;
force?: boolean;
},
- context: ToolContext
+ context: CapabilityContext
) => {
const selectCorpFn = (id?: string) => {
const corps = loadCorpConfigs();
@@ -312,7 +312,7 @@ export const webhookTools = [
handler: async (
client: KyInstance,
params: { filePath?: string },
- context: ToolContext
+ context: CapabilityContext
) => {
return checkWebhookReadiness(client, context.corp, { filePath: params.filePath });
}
@@ -328,7 +328,7 @@ export const webhookTools = [
handler: async (
client: KyInstance,
params: { filePath: string; mode?: "preview" | "push"; webhook?: string },
- context: ToolContext
+ context: CapabilityContext
) => {
const input = readMaterialPackFile(params.filePath);
if (params.mode !== "push") return previewMaterialPack(input.fileBuffer, input.fileName);
diff --git a/src/domains/seal/rules-local.test.ts b/src/domains/seal/rules-local.test.ts
index 83ff10b..ac92e4a 100644
--- a/src/domains/seal/rules-local.test.ts
+++ b/src/domains/seal/rules-local.test.ts
@@ -8,7 +8,7 @@ import {
saveLocalRulesFile,
localRulesToLintTargets
} from "./rules-local.js";
-import { findSealTool } from "./tools.js";
+import { findSealCapability } from "./capabilities.js";
const tempDirs: string[] = [];
@@ -109,10 +109,10 @@ describe("rules-local offline lint tool integration", () => {
]
});
- const lintTool = findSealTool("seal_approval_rules_lint")!;
- expect(lintTool).toBeDefined();
+ const lintCapability = findSealCapability("seal_approval_rules_lint")!;
+ expect(lintCapability).toBeDefined();
- const result = await lintTool.handler(
+ const result = await lintCapability.handler(
null as any,
{ file: filePath } as any,
{ corp: { id: "test-corp" } } as any
@@ -139,9 +139,9 @@ describe("rules-local offline lint tool integration", () => {
]
});
- const lintTool = findSealTool("seal_approval_rules_lint")!;
+ const lintCapability = findSealCapability("seal_approval_rules_lint")!;
- const result = await lintTool.handler(
+ const result = await lintCapability.handler(
null as any,
{ file: filePath } as any,
{ corp: { id: "test-corp" } } as any
@@ -153,7 +153,7 @@ describe("rules-local offline lint tool integration", () => {
// minScore enforcement
await expect(
- lintTool.handler(
+ lintCapability.handler(
null as any,
{ file: filePath, minScore: 95 } as any,
{ corp: { id: "test-corp" } } as any
diff --git a/src/domains/seal/simulation.test.ts b/src/domains/seal/simulation.test.ts
index 38638ff..18b7a4e 100644
--- a/src/domains/seal/simulation.test.ts
+++ b/src/domains/seal/simulation.test.ts
@@ -11,7 +11,7 @@ import {
listSimulationTemplates,
uploadMaterialPackage
} from "./api.js";
-import { buildSimulationBatchParams, findReusableSimulationBatch, sealTools } from "./tools.js";
+import { buildSimulationBatchParams, findReusableSimulationBatch, sealCapabilities } from "./capabilities.js";
import {
MaterialPackageSchema,
SimulationBatch,
@@ -20,7 +20,7 @@ import {
SimulationTemplateSchema
} from "./types.js";
-type ToolHandler = (
+type CapabilityHandler = (
client: KyInstance,
params: Record,
context: { corp: CorpConfig }
@@ -529,7 +529,7 @@ describe("findReusableSimulationBatch", () => {
describe("simulation tool handlers", () => {
test("create tool resolves signKey automatically and posts the payload", async () => {
- const tool = sealTools.find((item) => item.name === "seal_simulation_batch_create");
+ const tool = sealCapabilities.find((item) => item.name === "seal_simulation_batch_create");
expect(tool).toBeDefined();
let postedBody: Record | undefined;
@@ -555,7 +555,7 @@ describe("simulation tool handlers", () => {
}
} as unknown as KyInstance;
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
const result = await handler(client, {
mode: "hosecloud",
flowIds: ["B26017701"],
@@ -579,7 +579,7 @@ describe("simulation tool handlers", () => {
});
test("create tool reuses a recent identical batch instead of creating a new one", async () => {
- const tool = sealTools.find((item) => item.name === "seal_simulation_batch_create");
+ const tool = sealCapabilities.find((item) => item.name === "seal_simulation_batch_create");
expect(tool).toBeDefined();
let postCalls = 0;
@@ -608,7 +608,7 @@ describe("simulation tool handlers", () => {
}
} as unknown as KyInstance;
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
const result = await handler(client, {
mode: "hosecloud",
flowIds: ["B26017701"]
@@ -625,7 +625,7 @@ describe("simulation tool handlers", () => {
});
test("create tool force bypasses the reuse check", async () => {
- const tool = sealTools.find((item) => item.name === "seal_simulation_batch_create");
+ const tool = sealCapabilities.find((item) => item.name === "seal_simulation_batch_create");
let posted = false;
const client = {
get: (url: string) => {
@@ -652,7 +652,7 @@ describe("simulation tool handlers", () => {
}
} as unknown as KyInstance;
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
const result = await handler(client, {
mode: "hosecloud",
flowIds: ["B26017701"],
@@ -665,7 +665,7 @@ describe("simulation tool handlers", () => {
});
test("create tool creates a new batch when the identical batch is outside the reuse window", async () => {
- const tool = sealTools.find((item) => item.name === "seal_simulation_batch_create");
+ const tool = sealCapabilities.find((item) => item.name === "seal_simulation_batch_create");
let posted = false;
const client = {
get: (url: string) => {
@@ -692,7 +692,7 @@ describe("simulation tool handlers", () => {
}
} as unknown as KyInstance;
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
const result = await handler(client, {
mode: "hosecloud",
flowIds: ["B26017701"]
@@ -703,7 +703,7 @@ describe("simulation tool handlers", () => {
});
test("create tool surface exposes mode, flowIds, and rawParams", () => {
- const tool = sealTools.find((item) => item.name === "seal_simulation_batch_create");
+ const tool = sealCapabilities.find((item) => item.name === "seal_simulation_batch_create");
const { z } = require("zod") as typeof import("zod");
const schema = z.toJSONSchema(tool!.parameters) as { properties?: Record };
expect(Object.keys(schema.properties ?? {})).toEqual(
@@ -712,17 +712,17 @@ describe("simulation tool handlers", () => {
});
test("includes the simulation management tool set", () => {
- expect(sealTools.find((item) => item.name === "seal_simulation_batches_list")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_simulation_batch_get")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_simulation_batch_status")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_simulation_templates_get")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_simulation_integrations_get")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_simulation_batch_records_get")).toBeDefined();
- expect(sealTools.find((item) => item.name === "seal_simulation_material_package_upload")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_simulation_batches_list")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_simulation_batch_get")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_simulation_batch_status")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_simulation_templates_get")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_simulation_integrations_get")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_simulation_batch_records_get")).toBeDefined();
+ expect(sealCapabilities.find((item) => item.name === "seal_simulation_material_package_upload")).toBeDefined();
});
test("status tool performs one non-blocking check and exposes the next action", async () => {
- const tool = sealTools.find((item) => item.name === "seal_simulation_batch_status");
+ const tool = sealCapabilities.find((item) => item.name === "seal_simulation_batch_status");
expect(tool).toBeDefined();
const client = {
@@ -732,7 +732,7 @@ describe("simulation tool handlers", () => {
}
} as unknown as KyInstance;
- const handler = tool!.handler as ToolHandler;
+ const handler = tool!.handler as CapabilityHandler;
const result = await handler(client, { batchId: "batch-1" }, fakeContext()) as Record;
expect(result).toMatchObject({
diff --git a/src/domains/seal/tools.ts b/src/domains/seal/tools.ts
deleted file mode 100644
index 64512f1..0000000
--- a/src/domains/seal/tools.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-// Re-export from modular tools/ directory.
-// tools.ts was split into domain-specific modules under src/domains/seal/tools/.
-export * from "./tools/index.js";
diff --git a/src/http/routes.ts b/src/http/routes.ts
index bb012f7..53e094f 100644
--- a/src/http/routes.ts
+++ b/src/http/routes.ts
@@ -8,17 +8,17 @@ import type { CorpConfig } from "../core/config/types.js";
import { getOpenApiSchema } from "../core/embedded-openapi.js";
import { loadCorpConfigs, loadGlobalConfig } from "../core/config/loader.js";
import { createSealClient } from "../core/http/factory.js";
-import { findSealTool, parseToolParams, type SealTool } from "../domains/seal/tools.js";
+import { findSealCapability, parseCapabilityParams, type SealCapability } from "../domains/seal/capabilities.js";
import { tokenizeCommand } from "../cli/tokenize.js";
import { redactSensitiveText } from "../core/redact.js";
import { CliError, type CliExitCode } from "../core/errors.js";
import { VERSION } from "../version.js";
import { renderDocsHtml } from "./docs.js";
-async function executeSealTool(tool: SealTool, client: KyInstance, params: any, corp: CorpConfig): Promise {
+async function executeSealCapability(tool: SealCapability, client: KyInstance, params: any, corp: CorpConfig): Promise {
// Schema gate for every HTTP caller: a missing required field or bad value
// is a client error (400), not an upstream failure discovered mid-handler.
- parseToolParams(tool, params);
+ parseCapabilityParams(tool, params);
const handler = tool.handler as (client: KyInstance, params: any, context: { corp: CorpConfig }) => Promise;
return handler(client, params, { corp });
}
@@ -153,7 +153,7 @@ export async function handleHttpRequest(req: IncomingMessage, res: ServerRespons
// 5. Generic Tool Invocation endpoint (POST /api/tool/:name)
if (method === "POST" && pathname.startsWith("/api/tool/")) {
const toolName = pathname.slice("/api/tool/".length).trim();
- const tool = findSealTool(toolName);
+ const tool = findSealCapability(toolName);
if (!tool) {
sendError(res, 404, `Tool not found: '${toolName}'`);
return;
@@ -164,16 +164,16 @@ export async function handleHttpRequest(req: IncomingMessage, res: ServerRespons
const params = { ...body };
delete params.corp;
// Fail fast before `selectCorp`, which records usage stats to disk: a
- // request that can never succeed should cause no writes. `executeSealTool`
+ // request that can never succeed should cause no writes. `executeSealCapability`
// performs the same check afterwards — the early call exists purely to
// win this ordering, not to duplicate the guarantee.
- parseToolParams(tool, params);
+ parseCapabilityParams(tool, params);
const corpId = extractCorpId(req, url, body);
const corp = selectCorp(corpId);
const client = await createSealClient(corp);
- const output = await executeSealTool(tool, client, params, corp);
+ const output = await executeSealCapability(tool, client, params, corp);
sendJson(res, 200, output);
return;
}
@@ -226,8 +226,8 @@ async function handleRestV1(
const corpId = extractCorpId(req, url, queryParams);
const corp = selectCorp(corpId);
const client = await createSealClient(corp);
- const tool = findSealTool("seal_whoami")!;
- const data = await executeSealTool(tool, client, {}, corp);
+ const tool = findSealCapability("seal_whoami")!;
+ const data = await executeSealCapability(tool, client, {}, corp);
sendJson(res, 200, data);
return true;
}
@@ -237,8 +237,8 @@ async function handleRestV1(
const corpId = extractCorpId(req, url, queryParams);
const corp = selectCorp(corpId);
const client = await createSealClient(corp);
- const tool = findSealTool("seal_session_get")!;
- const data = await executeSealTool(tool, client, {}, corp);
+ const tool = findSealCapability("seal_session_get")!;
+ const data = await executeSealCapability(tool, client, {}, corp);
sendJson(res, 200, data);
return true;
}
@@ -248,8 +248,8 @@ async function handleRestV1(
const corpId = extractCorpId(req, url, queryParams);
const corp = selectCorp(corpId);
const client = await createSealClient(corp);
- const tool = findSealTool("seal_approval_runs_summary")!;
- const data = await executeSealTool(tool, client, queryParams, corp);
+ const tool = findSealCapability("seal_approval_runs_summary")!;
+ const data = await executeSealCapability(tool, client, queryParams, corp);
sendJson(res, 200, data);
return true;
}
@@ -259,8 +259,8 @@ async function handleRestV1(
const corpId = extractCorpId(req, url, queryParams);
const corp = selectCorp(corpId);
const client = await createSealClient(corp);
- const tool = findSealTool("seal_approval_runs_stats")!;
- const data = await executeSealTool(tool, client, queryParams, corp);
+ const tool = findSealCapability("seal_approval_runs_stats")!;
+ const data = await executeSealCapability(tool, client, queryParams, corp);
sendJson(res, 200, data);
return true;
}
@@ -270,8 +270,8 @@ async function handleRestV1(
const corpId = extractCorpId(req, url, queryParams);
const corp = selectCorp(corpId);
const client = await createSealClient(corp);
- const tool = findSealTool("seal_approval_run_pick")!;
- const data = await executeSealTool(tool, client, queryParams, corp);
+ const tool = findSealCapability("seal_approval_run_pick")!;
+ const data = await executeSealCapability(tool, client, queryParams, corp);
sendJson(res, 200, data);
return true;
}
@@ -281,8 +281,8 @@ async function handleRestV1(
const corpId = extractCorpId(req, url, queryParams);
const corp = selectCorp(corpId);
const client = await createSealClient(corp);
- const tool = findSealTool("seal_approval_run_url_get")!;
- const data = await executeSealTool(tool, client, queryParams, corp);
+ const tool = findSealCapability("seal_approval_run_url_get")!;
+ const data = await executeSealCapability(tool, client, queryParams, corp);
sendJson(res, 200, data);
return true;
}
@@ -299,32 +299,32 @@ async function handleRestV1(
const client = await createSealClient(corp);
if (!sub) {
- const tool = findSealTool("seal_approval_run_get")!;
- const data = await executeSealTool(tool, client, { recordId, ...queryParams }, corp);
+ const tool = findSealCapability("seal_approval_run_get")!;
+ const data = await executeSealCapability(tool, client, { recordId, ...queryParams }, corp);
sendJson(res, 200, data);
return true;
}
if (sub === "attachments") {
- const tool = findSealTool("seal_approval_run_attachments_get")!;
- const data = await executeSealTool(tool, client, { recordId, ...queryParams }, corp);
+ const tool = findSealCapability("seal_approval_run_attachments_get")!;
+ const data = await executeSealCapability(tool, client, { recordId, ...queryParams }, corp);
sendJson(res, 200, data);
return true;
}
if (sub === "cited-rules") {
- const tool = findSealTool("seal_approval_run_cited_rules_get")!;
- const data = await executeSealTool(tool, client, { recordId, ...queryParams }, corp);
+ const tool = findSealCapability("seal_approval_run_cited_rules_get")!;
+ const data = await executeSealCapability(tool, client, { recordId, ...queryParams }, corp);
sendJson(res, 200, data);
return true;
}
if (sub === "document-summary") {
- const tool = findSealTool("seal_approval_run_document_summary_get")!;
- const data = await executeSealTool(tool, client, { recordId, ...queryParams }, corp);
+ const tool = findSealCapability("seal_approval_run_document_summary_get")!;
+ const data = await executeSealCapability(tool, client, { recordId, ...queryParams }, corp);
sendJson(res, 200, data);
return true;
}
if (sub === "result") {
- const tool = findSealTool("seal_approval_run_result_get")!;
- const data = await executeSealTool(tool, client, { recordId, ...queryParams }, corp);
+ const tool = findSealCapability("seal_approval_run_result_get")!;
+ const data = await executeSealCapability(tool, client, { recordId, ...queryParams }, corp);
sendJson(res, 200, data);
return true;
}
@@ -336,8 +336,8 @@ async function handleRestV1(
const corpId = extractCorpId(req, url, queryParams);
const corp = selectCorp(corpId);
const client = await createSealClient(corp);
- const tool = findSealTool("seal_approval_runs_search")!;
- const data = await executeSealTool(
+ const tool = findSealCapability("seal_approval_runs_search")!;
+ const data = await executeSealCapability(
tool,
client,
{
@@ -357,8 +357,8 @@ async function handleRestV1(
const corpId = extractCorpId(req, url, queryParams);
const corp = selectCorp(corpId);
const client = await createSealClient(corp);
- const tool = findSealTool("seal_approval_rules_list")!;
- const data = await executeSealTool(tool, client, queryParams, corp);
+ const tool = findSealCapability("seal_approval_rules_list")!;
+ const data = await executeSealCapability(tool, client, queryParams, corp);
sendJson(res, 200, data);
return true;
}
@@ -368,8 +368,8 @@ async function handleRestV1(
const corpId = extractCorpId(req, url, queryParams);
const corp = selectCorp(corpId);
const client = await createSealClient(corp);
- const tool = findSealTool("seal_simulation_batches_list")!;
- const data = await executeSealTool(tool, client, queryParams, corp);
+ const tool = findSealCapability("seal_simulation_batches_list")!;
+ const data = await executeSealCapability(tool, client, queryParams, corp);
sendJson(res, 200, data);
return true;
}
@@ -380,8 +380,8 @@ async function handleRestV1(
const corpId = extractCorpId(req, url, body);
const corp = selectCorp(corpId);
const client = await createSealClient(corp);
- const tool = findSealTool("seal_simulation_batch_create")!;
- const data = await executeSealTool(tool, client, body, corp);
+ const tool = findSealCapability("seal_simulation_batch_create")!;
+ const data = await executeSealCapability(tool, client, body, corp);
sendJson(res, 200, data);
return true;
}
@@ -394,8 +394,8 @@ async function handleRestV1(
const corpId = extractCorpId(req, url, queryParams);
const corp = selectCorp(corpId);
const client = await createSealClient(corp);
- const tool = findSealTool("seal_simulation_batch_get")!;
- const data = await executeSealTool(tool, client, { batchId }, corp);
+ const tool = findSealCapability("seal_simulation_batch_get")!;
+ const data = await executeSealCapability(tool, client, { batchId }, corp);
sendJson(res, 200, data);
return true;
}
@@ -406,8 +406,8 @@ async function handleRestV1(
const corpId = extractCorpId(req, url, queryParams);
const corp = selectCorp(corpId);
const client = await createSealClient(corp);
- const tool = findSealTool("seal_preference_get")!;
- const data = await executeSealTool(tool, client, {}, corp);
+ const tool = findSealCapability("seal_preference_get")!;
+ const data = await executeSealCapability(tool, client, {}, corp);
sendJson(res, 200, data);
return true;
}
@@ -418,8 +418,8 @@ async function handleRestV1(
const corpId = extractCorpId(req, url, body);
const corp = selectCorp(corpId);
const client = await createSealClient(corp);
- const tool = findSealTool("seal_preference_decision_update")!;
- const data = await executeSealTool(tool, client, body, corp);
+ const tool = findSealCapability("seal_preference_decision_update")!;
+ const data = await executeSealCapability(tool, client, body, corp);
sendJson(res, 200, data);
return true;
}