UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

28 lines • 1.19 kB
import { toolSchemaDigest } from "./catalog-digest.js"; export function buildToolCatalog(tools) { const catalog = new Map(); for (const tool of tools) { catalog.set(tool.name, { name: tool.name, description: tool.description, parameters: tool.parameters, ...(tool.outputSchema === undefined ? {} : { outputSchema: tool.outputSchema }), ...(tool.executionMode === undefined ? {} : { executionMode: tool.executionMode }), schemaDigest: toolSchemaDigest(tool), }); } return catalog; } /** * Decides, before any effect, whether a call may run against this catalog. Staleness is per tool: a call * is refused only when its own tool is gone (`tool_unknown`) or its own schema changed (`schema_stale`). */ export function checkCatalogCall(catalog, call) { const entry = catalog.get(call.name); if (entry === undefined) return { ok: false, reason: "tool_unknown", name: call.name }; if (entry.schemaDigest !== call.schemaDigest) return { ok: false, reason: "schema_stale", name: call.name }; return { ok: true, entry }; } //# sourceMappingURL=catalog.js.map