import { t as ToolBinding } from "../shared-BIYAGyxd.js"; import { t as CreateToolsOptions } from "../shared-g0aFrtd0.js"; //#region src/tools/pi-ai/bindings.d.ts /** * Structurally compatible with `AgentTool` from * `@earendil-works/pi-agent-core`, declared locally so pi is not a * build-time dependency. */ interface PiAgentTool { name: string; description: string; parameters: object; /** Repairs raw arguments before they are validated, as pi's agent loop does. */ prepareArguments?: (args: unknown) => unknown; execute(toolCallId: string, params: unknown, signal?: AbortSignal): Promise; } /** Structurally compatible with `AgentToolResult` from `@earendil-works/pi-agent-core`. */ interface PiAgentToolResult { content: readonly (PiToolResultContent | { type: string; })[]; details?: unknown; structuredContent?: unknown; isError?: boolean; } /** The tool call a validator receives, shaped like pi-ai's `ToolCall`. */ interface PiToolCallRequest { type: "toolCall"; id: string; name: string; arguments: Record; } /** Options for {@link forPiTools}. */ interface ForPiToolsOptions { /** * Checks a call's arguments against the tool's schema and returns the * ones to run with. Pass pi-ai's `validateToolArguments` so code is * held to the same check as the model. Without it, arguments reach * the tool unchecked. */ validate?: (tool: T, call: PiToolCallRequest) => unknown; /** * The names of the tools that only read, which may run on a read-only * backend. pi tools do not say whether they write, so every other tool * is refused there. `createPiTools` tools need no list: `read`, `ls`, * `find`, and `grep` are marked already. */ readOnly?: readonly string[]; } /** * Bindings for {@link createToolBindings} from pi tools. * * Each call runs the way pi's agent loop runs a model's call: * `prepareArguments` first, then `validate`, then `execute` with a fresh * call id and the call's abort signal. A failure in any step rejects the * call. A result the tool marks `isError` resolves with `isError: true`. * * @param tools - Executable pi tools, a function returning them, or the * result of `createPiTools`. * @param options - The validator to check arguments with. * @returns A function returning the bindings, called each time a * backend connects. */ declare function forPiTools(tools: readonly T[] | (() => readonly T[]), options?: ForPiToolsOptions): () => ToolBinding[]; declare function forPiTools(tools: CreatePiToolsResult): () => ToolBinding[]; //#endregion //#region src/tools/pi-ai/index.d.ts interface ToolCallContext { abortSignal?: AbortSignal; } /** Structurally compatible with `Tool` from `@earendil-works/pi-ai`, declared locally so pi is not a build-time dependency. */ interface PiTool { name: string; description: string; parameters: PiJSONSchema; constrainedSampling?: { type: "json_schema"; strict: "prefer" | "require"; }; } interface PiJSONSchema { type: "object"; properties?: Record; required?: string[]; [key: string]: unknown; } /** One tool call as pi reports it on a `toolcall_end` event. */ interface PiToolCall { id: string; name: string; arguments?: unknown; } type PiToolResultContent = { type: "text"; text: string; } | { type: "image"; data: string; mimeType: string; }; /** A tool result minus the routing fields (`toolCallId`, `toolName`, `timestamp`), which the caller owns. */ interface PiToolResult { content: PiToolResultContent[]; isError: boolean; details?: unknown; } interface CreatePiToolsResult { tools: PiTool[]; execute: (call: PiToolCall, context?: ToolCallContext) => Promise; } declare function createPiTools(options: CreatePiToolsOptions): CreatePiToolsResult; interface CreatePiToolsOptions extends CreateToolsOptions, PiDeclarationOptions {} interface PiDeclarationOptions { /** * `"prefer"` (default) falls back to ordinary tool calling where the * provider cannot enforce a schema; `"require"` fails the request * instead, so it suits only a pinned model known to support it. */ constrainedSampling?: "prefer" | "require" | false; } //#endregion export { CreatePiToolsOptions, CreatePiToolsResult, type ForPiToolsOptions, type PiAgentTool, type PiAgentToolResult, PiDeclarationOptions, PiJSONSchema, PiTool, PiToolCall, type PiToolCallRequest, PiToolResult, PiToolResultContent, ToolCallContext, createPiTools, forPiTools }; //# sourceMappingURL=pi-ai.d.ts.map