/** * opencode native tool calls → matched `tool_use`/`tool_result` * AgentMessages (coder mode on every runtime, plan MM3; contract §4). * * opencode reports every native tool call as a `type:"tool"` message part * on the SSE stream (`message.part.updated`), re-sent as its `state` * advances `pending → running → completed | error` (ToolPart/ToolState in * @opencode-ai/sdk's types.gen.d.ts). `callID` is stable across those * updates, so it is the id both halves carry — ToolActivityTracker * (tool-activity.ts) pairs start and end by it, which is what makes this * runtime's fidelity "full". * * - `pending` is skipped: its `input` is still being streamed (`raw`). * - `running` yields the start, with the input translated to the * contract's canonical keys and a `kind`. * - `completed`/`error` yields the end (plus the start first, when the * call finished before a `running` update was ever seen). * * The original tool name stays in `tool`; `kind` and the canonical `input` * are what a caller renders from. */ import type { AgentMessage } from './agent-runner.js'; import type { ToolKind } from './tool-kind.js'; type Input = Record; /** * `apply_patch`'s `patchText` (`*** Begin Patch` … `*** End Patch`) → * contract `patch` files. Each `*** Add/Update/Delete File: ` header * starts a file; the lines up to the next header are its diff. */ export declare function parsePatchText(text: string): Array<{ file_path: string; action: 'add' | 'update' | 'delete'; diff?: string; }>; /** * One opencode tool call → contract kind + canonical input. `mcpServers` * are the served instance's MCP server names (`client.mcp.status()`); an * unknown tool whose id starts with one of them (sanitized, then `_`) is * that server's tool. Anything else keeps its raw input as `other`. */ export declare function canonicalOpencodeTool(tool: string, input: Input, mcpServers?: readonly string[]): { kind: ToolKind; input: Input; }; /** * Turns the stream of `type:"tool"` part updates into at most one start and * one end per call. Stateful per runner run (a call's updates may span * rounds only in theory; ids are unique per session either way). */ export declare class OpencodeToolParts { private sessionId; private started; private ended; mcpServers: string[]; constructor(sessionId: string); /** `part` is a `message.part.updated` part with `type === "tool"`. */ onPart(part: any): AgentMessage[]; } export {}; //# sourceMappingURL=opencode-runner-tools.d.ts.map