@sema-agent/core
Version:
Stateless, task-oriented AI agent core
69 lines (68 loc) • 4.76 kB
TypeScript
/**
* The STATIC TOOL CATALOG (design/388 §2.1 "静态目录"): one row per built-in / synthetic tool DEFINITION
* core owns — its wire name, the conditions core (or a host scenario factory) mounts it under, the
* `details.type` cards it mints, and its declared FACE (family / axes / contract / path target / rule
* vocabulary / render hints / policy bits).
*
* SINGLE SOURCE, TWO READERS. Each definition module spreads its row's `face` into the `ToolSpec` it
* hands `defineTool` (`...TOOL_FACES.read`), so the face a tool declares at mount time IS the face
* listed here — there is no second declaration to drift. The effect roster (tool-roster.ts) reads every
* axis off the MOUNTED INSTANCE; the static catalog (`describeToolCatalog()`) reads this table without
* an env or a deps object. The conformance gate (test/tool-catalog-conformance.test.ts) proves the two
* agree for every definition it can instantiate; the catalog completeness gate
* (scripts/verify-tool-catalog.mjs) proves every `defineTool` site in src/ that mints a core-owned name
* has a row here that declares a `family` — a missing declaration is a RED gate naming the file, never a
* silent `"other"`.
*
* LEAF MODULE by design: it imports vocabulary types and one leaf constant module only. Every definition
* module and every policy module that derives a name set from the catalog imports THIS file, so a
* dependency from here back into a tool module would be a load-order cycle with a `const` table in it.
*
* Keyed by DEFINITION identity (`id`), not by name — the full and the read-only shell both answer to
* `Bash`; a catalog predicate counts a name as a member when ANY row under that name matches.
*/
import type { ToolCatalogEntry, ToolFaceDeclaration } from "./tool-face.js";
/** The full shell's contract id — declared here (the leaf) and re-exported by fs-bash.ts. */
export declare const FULL_SHELL_CONTRACT_ID = "core.bash@1";
export declare const READONLY_SHELL_CONTRACT_ID = "core.bash_readonly@1";
/** Wire-name constants for definitions that had none (design/388 A-21: literals become references). */
export declare const TASK_CREATE_TOOL_NAME = "TaskCreate";
export declare const TASK_GET_TOOL_NAME = "TaskGet";
export declare const TASK_UPDATE_TOOL_NAME = "TaskUpdate";
export declare const TASK_LIST_TOOL_NAME = "TaskList";
export declare const TODO_WRITE_TOOL_NAME = "TodoWrite";
export declare const REFRESH_MCP_TOOLS_TOOL_NAME = "RefreshMcpTools";
export declare const ARTIFACT_TOOL_NAME = "Artifact";
/**
* Every row. Order is documentation order (hands → delegation → scaffolds → memory → scheduler → host
* scenarios); nothing reads the order.
*/
export declare const TOOL_CATALOG_ENTRIES: readonly ToolCatalogEntry[];
/**
* `details.type` cards the ENGINE mints outside any tool definition — the protocol channels' result
* cards and the fs boundary refusals (minted by the shared safety module on behalf of every fs tool).
*/
export declare const ENGINE_CARDS: Readonly<Record<string, string>>;
/** The declared face of one definition, by definition id — what a definition module spreads into its spec. */
export declare function toolFace(id: string): ToolFaceDeclaration;
/** Definition-id → face, for the modules that spread one (`...TOOL_FACES.read`). Frozen: a face is data. */
export declare const TOOL_FACES: Readonly<Record<string, ToolFaceDeclaration>>;
/**
* The engine's own tool names, once each: every catalog entry the engine mounts itself (`source: "builtin"` — the hands,
* the scaffolds, the memory tools, the background-task tools), whatever face or contract it is mounted under. A host that
* must hand the engine a tool face with NO built-ins (`TaskSpec.excludeTools`, a shell's `--tools ""`) reads this set
* instead of keeping a list of its own: the catalog is the one source, and a name the engine adds later lands here with it.
*/
export declare const ENGINE_BUILTIN_TOOL_NAMES: readonly string[];
/**
* EVERY tool the catalog describes, once per wire name, with the other spellings it answers to — the engine's side of the one
* universe a delegated child's tool-name lists govern (beside the tools the delegation tool hands it and the protocol tools
* its spawning run mounts). The spawn reads this set rather than a list of its own: a definition a catalog row adds later is
* governed the day it lands, whatever band mounts it.
*/
export declare const ENGINE_TOOLS: ReadonlyArray<{
readonly name: string;
readonly aliases?: readonly string[];
}>;
/** Is this name one the engine mounts itself ({@link ENGINE_BUILTIN_TOOL_NAMES})? A caller tool, an MCP tool or a skill tool is not. */
export declare function isEngineBuiltinToolName(name: string): boolean;