/** * Native tool events for the vendor CLI runners (coder mode on every * runtime, doc/agent-exec-protocol.md §3.2 + plan Contract §4). * * Shared by the subprocess runners the same way kimicode-runner.ts's * classifyStderr already is: each runner parses its own CLI's wire format and * hands the native tool name, id and raw arguments here. This module * - maps the native name to the contract `kind` * (shell|edit|write|read|search|web|mcp|task|todo|patch|other), * - translates the native argument shape to that kind's canonical `input` * keys (a shell call → {command}, an edit → {file_path, old_string, * new_string}, ...), falling back to kind "other" with the raw input when * a required key is missing rather than emitting a half-filled shape, * - builds the rich 'tool_use'/'tool_result' AgentMessages * ToolActivityTracker (tool-activity.ts) turns into matched * tool_activity start/end events: `tool_use_id` + `tool` + `input` is the * same shape ClaudeAgentRunner yields, so the tracker needs no per-runtime * code. `text` stays the tool name, so the org runtime's StateDetector * liveness is unchanged. * * The start message sets `AgentMessage.kind` from tool-kind.ts's name table, * the same one tool-activity.ts falls back to. */ import type { AgentMessage } from './agent-runner.js'; import { type ToolKind } from './tool-kind.js'; export type { ToolKind }; /** Contract kind for a native tool name — the one name table in * tool-kind.ts, which lists these CLIs' own names (agy's run_command, * grok's search_replace, ...). */ export declare function toolKind(name: string): ToolKind; /** * Canonical kind + input for one native tool call (plan Contract §4). The * native name always stays on the message as `tool`; only `input` changes. */ export declare function canonicalTool(name: string, rawInput: unknown): { kind: ToolKind; input: Record; }; /** Text of a tool result in whatever shape the CLI reports it: a string, a * content-block array ({type:'text', text}), or {content: ...}. */ export declare function toolOutputText(out: unknown): string; /** * Per-turn bookkeeping for one runner's native tool calls: builds the rich * start/end messages and pairs them by the CLI's own call id. An end whose * start was never seen (a CLI that reports a finished call in one event) gets * its start synthesized first, so the tracker never sees an orphan end. */ export declare class NativeToolCalls { private open; /** Start message for a newly seen call, or null for a repeated start. */ start(id: string, name: string, rawInput: unknown, sessionId?: string): AgentMessage | null; /** End message(s) for a call; `fallback` names a call whose start never * arrived, `exitCode` a shell call's exit status when the CLI reports it. * Empty when the id is unknown and there is no fallback. */ end(id: string, output: unknown, isError: boolean, sessionId?: string, fallback?: { name: string; rawInput: unknown; }, exitCode?: number): AgentMessage[]; } /** Blocks of one Anthropic-Messages-shaped message (grok * `streaming-messages-json`, qwen `stream-json`): the text, tool_use and * tool_result blocks, each in the shape the runners need. */ export declare function messageBlocks(content: unknown): { text: string; toolUses: Array<{ id: string; name: string; input: unknown; }>; toolResults: Array<{ id: string; output: unknown; isError: boolean; }>; }; //# sourceMappingURL=kimicode-runner-tools.d.ts.map