/** * Parses the result of a Pi `--mode json` run. * * Pi emits a JSONL event stream (one JSON object per line): `session`, * `agent_start`, `message_start`, `message_update`, `message_end`, `turn_*`, * and finally `agent_end`. The `agent_end` event carries the full `messages` * array. We read the result from there — the last assistant message — and * ignore the streaming noise. * * This module is pure (no I/O) so it is unit-tested directly. */ export interface PiUsage { totalTokens: number; cost: number; } export interface PiResult { text: string; stopReason: string | undefined; usage: PiUsage; } /** * Parses a Pi JSONL event stream into a structured result. * * @throws if the stream contains no `agent_end` event (the run did not * complete — a stuck or killed worker). */ export declare function parsePiResult(jsonl: string): PiResult;