/** * `structured_output` — terminating tool used to capture a subagent's final result. * * Injected into a workflow agent node only when its output schema requires * structured data. The subagent is instructed * to invoke this tool exactly once with its final result; the tool sets * `terminate: true` so the agent loop stops without paying for an extra * assistant turn. * * Validation is done with ajv (already a xopc dep). pi-agent-core also validates * arguments against `parameters` before calling `execute`, but we re-check here * to (1) surface a clear error message back to the model when the schema is * non-trivial, and (2) avoid trusting the upstream layer's validator strictness. * * Note: the file is named `structured-output-tool.ts` to avoid clashing with the * existing `src/agent/tools/structured-output.ts` (an XML Element builder — a * completely unrelated utility). */ import type { AgentTool } from '@earendil-works/pi-agent-core'; import type { TSchema } from '@sinclair/typebox'; import type { JsonSchema } from './types.js'; export declare const STRUCTURED_OUTPUT_TOOL_NAME = "structured_output"; export interface StructuredOutputCapture { called: boolean; value?: T; } export interface CreateStructuredOutputToolOptions { schema: JsonSchema; capture: StructuredOutputCapture; /** Override the tool name (rarely needed; default `structured_output`). */ name?: string; } export declare function createStructuredOutputTool(options: CreateStructuredOutputToolOptions): AgentTool;