/** * Wire helpers for PiRpcAgentRunner (pi-rpc-runner.ts): the JSONL decoder, * the command encoder, assistant-text extraction, and the duck-typed child * process seam tests drive with a fake. */ import type { AgentRunArgs } from './agent-runner-types.js'; /** 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). Splits on LF only, as pi docs/json.md * requires (U+2028/U+2029 are valid inside JSON strings). */ export declare class JsonlDecoder { private buf; feed(chunk: string): Record[]; } /** A client→server RPC command (pi docs/rpc-commands.md). */ export interface PiRpcCommand { type: string; message?: string; id?: string; } /** Encode a client→server RPC command as one LF-terminated JSON line. */ export declare function encodePiRpcCommand(cmd: PiRpcCommand): string; /** Assistant-visible text of a message's `content`: text blocks joined with * '\n'; `thinking` and `toolCall` blocks are dropped. */ export declare function extractPiRpcText(message: { content?: unknown; }): string; /** The subset of a spawned child process this runner needs — duck-typed so * tests can supply an EventEmitter-backed fake and exercise the whole * turn-completion state machine without a real `pi` binary. */ export interface PiRpcProcess { stdin: { write(data: string): void; /** Optional so the test fakes stay minimal; the real ChildProcess has it. */ on?(event: 'error', cb: (err: Error) => void): 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; }, runArgs: Pick) => PiRpcProcess; /** Spawns through the process-group helper, so under `--access full` the * returned `kill` (the watchdogs, the caller's abort, the final cleanup) * signals pi's whole process tree, like the `--mode json` runner. */ export declare const defaultSpawnPiRpc: SpawnPiRpc; //# sourceMappingURL=pi-rpc-runner-io.d.ts.map