/** * PRI-419 §M1 — L2 agent tool contract (core, pure logic). * * Defines the read-only tools the dreamer L2 agent loop can call, plus the context * interface that injects the in-process PD read-models. 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. * * Read-only-by-construction (ADR-0014 amendment §B.2): the injected store interface * (PdL2ArtifactReader) exposes ONLY getter/list methods — there is physically no write * capability to invoke. The beforeToolCall whitelist in the adapter is a second line * of defense, not the primary boundary. * * Tool set (dreamer, Phase 1): * - read_principles : core axioms (T-01..T-10) + active internalized principles * - read_artifact : a predecessor pipeline artifact by id or source task id * - submit_output : the model's final DreamerOutputV1 submission (self-built; * pi-agent-core has no built-in submit_output). Its parameter * schema is the typebox DreamerOutputV1 redeclaration (§M6). * * The submit_output tool does NOT terminate the loop via `terminate` (that is * unreliable — agent-loop uses .every() over the whole tool batch). Loop termination * is driven by shouldStopAfterTurn detecting the captured output (see L2AgentLoopAdapter §M3). */ import type { AgentTool } from '@earendil-works/pi-agent-core'; import { DreamerOutputV1Typebox } from './dreamer-output-typebox.js'; /** Shape returned by both reader methods (reused to avoid repeating the inline literal). */ interface ArtifactSummary { artifactId: string; artifactKind: string; sourceTaskId: string; contentJson: string; createdAt: string; } /** Read-only view of the artifact store used by read_artifact. */ export interface PdL2ArtifactReader { getArtifactById(artifactId: string): Promise; listBySourceTaskId(sourceTaskId: string): Promise; } /** Read-only view of the internalized-principle ledger used by read_principles. */ export interface PdL2PrincipleReader { /** Returns active internalized principles (id + statement). Empty if none/missing. */ listActivePrinciples(): Promise<{ id: string; statement: string; }[]>; } export { DreamerOutputV1Typebox as SubmitOutputSchema }; export interface L2OutputCapture { output: unknown | null; } export interface PdL2ToolContext { /** Read-only artifact store (predecessor pipeline artifacts). */ artifactReader: PdL2ArtifactReader; /** Read-only internalized-principle ledger. */ principleReader: PdL2PrincipleReader; /** The capture container the submit_output tool writes into. */ outputCapture: L2OutputCapture; /** Telemetry sink: called once per tool execution (toolName + ok/error). */ onToolExecution?: (info: { toolName: string; ok: boolean; error?: string; }) => void; } /** * Build the dreamer L2 tool set bound to an injected context. * * Returns AgentTool[] suitable for assignment to AgentContext.tools. Tools are * read-only by construction: they only call getter/list methods on the injected readers and * write the final answer into the outputCapture (which the adapter owns). */ export declare function buildDreamerL2Tools(ctx: PdL2ToolContext): AgentTool[]; /** Allow-list of tool names the dreamer L2 loop may execute (defense-in-depth for beforeToolCall). */ export declare const DREAMER_L2_TOOL_WHITELIST: ReadonlySet; //# sourceMappingURL=agent-tool-contract.d.ts.map