import type { AgentMessage, AgentRunArgs, AgentRunner } from './agent-runner.js'; interface PiContentBlock { type: string; text?: string; thinking?: string; id?: string; name?: string; arguments?: Record; } interface PiRpcMessage { content?: PiContentBlock[]; } /** Pure, transport-independent JSONL line decoder — feed it raw string * chunks, get back every complete parsed object found so far (silently * skipping malformed lines rather than throwing, matching this repo's * other subprocess parsers). Exported for unit testing without a real * subprocess. */ export declare class JsonlDecoder { private buf; feed(chunk: string): Record[]; } /** Encode a client→server RPC command as one LF-terminated JSON line. * Exported for unit testing the exact wire format. */ export declare function encodePiRpcCommand(cmd: { type: string; message?: string; id?: string; }): string; /** Extract assistant-visible text and org tool_call fences from a * message_end event's `message.content` array. `thinking` blocks are * dropped (internal reasoning, not meant for the bus); `toolCall` blocks * are pi's own native tool calls, executed autonomously by pi itself — * this runner never sees their results and doesn't need to. Exported for * unit testing against fixture content arrays. */ export declare function extractPiRpcText(message: PiRpcMessage): string; /** The subset of a spawned child process this runner needs — narrower than * node:child_process's real type, and deliberately duck-typed so tests can * supply a fake implementation (an EventEmitter-backed fake process) to * exercise the full turn-completion state machine without a real `pi` * binary. Given the residual protocol-inference risk documented in this * file's header, testing the orchestration logic itself — not just the * pure JSONL/extraction helpers — is the point of this seam. */ export interface PiRpcProcess { stdin: { write(data: string): void; } | null; stdout: { on(event: 'data', cb: (chunk: Buffer) => void): void; } | null; stderr: { on(event: 'data', cb: (chunk: Buffer) => void): void; } | null; on(event: 'close', cb: (code: number | null) => void): void; on(event: 'error', cb: (err: Error) => void): void; kill(signal?: string): void; } export type SpawnPiRpc = (bin: string, args: string[], opts: { cwd: string; env: Record; }) => PiRpcProcess; export declare class PiRpcAgentRunner implements AgentRunner { private piBin?; private spawnFn; constructor(piBin?: string | undefined, spawnFn?: SpawnPiRpc); run(args: AgentRunArgs): AsyncIterable; } export {}; //# sourceMappingURL=pi-rpc-runner.d.ts.map