Rename the internal tool registry to capability registry

This commit is contained in:
gitea committed 2026-09-30 14:47:51 +08:00
1 parent f8b2b2ecde
commit bc9256a9d9
41 files changed
+470 -452

No files matched your search

+7 -7
View File
@@ -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<ReturnType<typeof createSealClient>>,
corp: CorpConfig,
params: Record<string, unknown>,
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<ReturnType<typeof createSealClient>>,
corp: CorpConfig,
params: Record<string, unknown>
) {
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 });
}