/** * Parsers for the two cline wire formats this runner reads. * * `cline --json` (NDJSON on stdout, one `{ts, type, ...}` per line; shapes * from cline 3.0.65's own source + live error-path captures, 2026-09-29): * {type:"hook_event", hookEventName:"agent_start"|"agent_error", taskId, ...} * {type:"agent_event", event: AgentEvent} where AgentEvent is * content_start {contentType:"text", text: } (one per delta) * content_start {contentType:"reasoning"|"tool", toolName, toolCallId, input} * content_update {contentType:"tool", toolCallId, update} * content_end {contentType:"text", text: } * content_end {contentType:"tool", toolName, toolCallId, output, error?, durationMs} * iteration_start {iteration} / iteration_end * usage {inputTokens, ..., totalInputTokens, totalOutputTokens, * totalCacheReadTokens, totalCacheWriteTokens, totalCost} * notice / done / error {error:{name,message,stack}, errorClass, recoverable} * (a subagent's events carry a non-null parentAgentId) * {type:"run_result", finishReason: completed|max_iterations|aborted| * mistake_limit|error, iterations, usage, aggregateUsage?, text, model} * {type:"run_aborted" | "run_abort_requested", ...} * Captured live (no credentials, so the error path): * {"type":"agent_event","event":{"type":"error","error":{"name":"Error", * "message":"Anthropic API key is missing. ..."},"errorClass":"unknown", * "recoverable":false,"iteration":1}} * {"type":"run_result","finishReason":"error","iterations":1,"usage":{ * "inputTokens":0,"outputTokens":0,"cacheReadTokens":0,"cacheWriteTokens":0, * "totalCost":0},"aggregateUsage":{...},"durationMs":52,"text":"...","model":{...}} * * ACP (`cline --acp`, JSON-RPC 2.0 over stdio): `session/update` * notifications — agent_message_chunk / agent_thought_chunk {content:{text}}, * tool_call {toolCallId, kind, rawInput, title}, tool_call_update * {toolCallId, status: completed|failed, rawOutput}. No usage, no iteration * events (cline's acp/session-updates.ts drops both). */ import type { ClineEvent, ClineUsage } from './cline-runner-types.js'; /** A cline usage object (`run_result.usage`, history `metadata.usage`). */ export declare function toUsage(v: unknown): ClineUsage | undefined; export interface ParsedJsonLine { events: ClineEvent[]; /** Top-level `iteration_start` number. */ iteration?: number; /** Running totals from a top-level `usage` event. */ usage?: ClineUsage; /** An unrecoverable `error` event's message. */ error?: string; result?: { finishReason: string; usage?: ClineUsage; text?: string; }; } /** Stateful `cline --json` line parser: text arrives one `content_start` * chunk at a time and is released as one block at its `content_end`. */ export declare class ClineJsonParser { private text; feed(line: string): ParsedJsonLine; /** Release any text still buffered (a block whose content_end never came). */ flush(into: ClineEvent[]): void; } /** The message of a JSON diagnostic cline writes to stderr * (`{"type":"error","message":...}`), last one wins. */ export declare function stderrErrorMessage(stderr: string): string | undefined; /** One ACP `session/update` payload → normalized events. `text` chunks are * returned separately so the caller can join them into blocks. */ export declare function parseAcpUpdate(update: unknown): { textChunk?: string; thought?: boolean; toolStart?: { id: string; acpKind: unknown; rawInput: unknown; title: unknown; }; toolEnd?: { id: string; failed: boolean; output: unknown; }; }; //# sourceMappingURL=cline-runner-parse.d.ts.map