/** * PRI-439 §Phase 4 — Artificer L2 agent tool contract (core, pure logic). * * Defines the 4 tools the Artificer L2 agent loop can call, plus the context * interface that injects the sandbox + validator. This file is PURE: it holds * tool definitions (name / description / typebox parameter schema) and a factory * that wires them to an injected context. No I/O, no `node:*` imports. * * Tool set (artificer, PRI-439 Phase 4): * - read_rulecode_spec : returns the RuleCode dialect spec (canonical form, * forbidden patterns, return shape, golden trace rules) * - validate_rulecode : runs STATIC validation (forbidden patterns + return * statement checks + matched=false decision check) on * a code string. No VM, no sandbox. * - replay_rulecode : runs SANDBOX replay of code against a golden trace * using the injected RefinerRuleHostGateDeps. * - submit_rulecode : the model's final ArtificerRuleOutput submission. * Stores into outputCapture; the adapter's * shouldStopAfterTurn detects the capture and stops. * * The submit_rulecode tool does NOT terminate the loop via `terminate` alone * (that is unreliable — agent-loop uses .every() over the whole tool batch, * see l2-agent-loop-adapter.ts header comment). Loop termination is driven by * shouldStopAfterTurn detecting the captured output. * * Boundary: pure logic, no I/O. Lives in core. No `node:*` imports. */ import type { AgentTool } from '@earendil-works/pi-agent-core'; import { ArtificerRuleOutputTypebox } from './artificer-output-typebox.js'; import type { RefinerRuleHostGateDeps } from '../internalization/refiner-rulehost-gate.js'; import type { ArtificerValidator } from '../internalization/artificer-output.js'; export interface ArtificerL2OutputCapture { output: unknown | null; } export interface ArtificerL2ToolContext { /** Sandbox replay deps (real or test double). */ gateDeps: RefinerRuleHostGateDeps; /** Artificer output validator (used by submit_rulecode for runtime validation). */ validator: ArtificerValidator; /** The taskId the loop is running for (lineage consistency check in submit). */ taskId: string; /** The capture container the submit_rulecode tool writes into. */ outputCapture: ArtificerL2OutputCapture; /** Telemetry sink: called once per tool execution (toolName + ok/error). */ onToolExecution?: (info: { toolName: string; ok: boolean; error?: string; }) => void; } export { ArtificerRuleOutputTypebox as SubmitRulecodeSchema }; /** * The RuleCode dialect spec returned by read_rulecode_spec. Pure text so the * model can reference it during the loop. Mirrors the constraints in * ARTIFICER_PROTOCOL_INSTRUCTION + checkForbiddenPatterns + the matched=false * decision rule. * * Exported so the `pd rulecode spec` CLI command (PRI-439 Phase 5) can return * the same canonical text the Artificer L2 agent sees — single source of truth. */ export declare const RULECODE_SPEC_TEXT: string; /** * Build the Artificer L2 tool set bound to an injected context. * * Returns AgentTool[] suitable for assignment to AgentContext.tools. Tools are * read-only by construction (validate/replay do not mutate state; submit writes * only into the adapter-owned outputCapture). */ export declare function buildArtificerL2Tools(ctx: ArtificerL2ToolContext): AgentTool[]; /** Allow-list of tool names the Artificer L2 loop may execute (defense-in-depth for beforeToolCall). */ export declare const ARTIFICER_L2_TOOL_WHITELIST: ReadonlySet; //# sourceMappingURL=artificer-l2-tool-contract.d.ts.map