interface PiContentBlock { type?: string; text?: string; } export interface PiUsage { input?: number; output?: number; cacheRead?: number; cacheWrite?: number; /** Per assistant message, priced from pi's model catalog (docs/json.md). */ cost?: { total?: number; }; } interface PiMessage { role?: string; content?: PiContentBlock[] | string; usage?: PiUsage; stopReason?: string; errorMessage?: string; } export interface PiEvent { type?: string; /** `session` header (first --mode json record): the session id. */ id?: string; message?: PiMessage; toolName?: string; toolCallId?: string; args?: unknown; result?: unknown; isError?: boolean; willRetry?: boolean; success?: boolean; finalError?: string; assistantMessageEvent?: { type?: string; contentIndex?: number; delta?: unknown; }; } /** Per-assistant-message token usage (all four counts are siblings). */ export interface PiMessageUsage { input: number; output: number; cacheRead: number; cacheWrite: number; /** usage.cost.total, when pi priced the message. */ cost?: number; } /** * One parsed pi event, normalized for incremental consumption. * - assistantText: the raw (fences intact) text blocks of an assistant * message_end, joined with '\n', present only when non-empty. * - assistantEnd: that assistant message_end's usage and stop reason. * - assistantStart: an assistant message_start (resets delta indices). * - textDelta: a text_delta (thinking/toolcall deltas are never text). * - toolStart/toolEnd: tool_execution_start/end, paired by toolCallId. * - agentEnd: `willRetry` undefined = a pre-0.8x pi that has no * agent_settled, so the agent_end is final. */ export interface PiParsedLine { sessionId?: string; assistantText?: string; assistantStart?: boolean; assistantEnd?: { usage: PiMessageUsage; stopReason?: string; errorMessage?: string; }; textDelta?: { index: number; delta: string; }; toolStart?: { id: string; name: string; input: unknown; }; toolEnd?: { id: string; output: unknown; isError: boolean; }; turnStart?: boolean; agentEnd?: { willRetry?: boolean; }; retryStart?: boolean; retryEnd?: { success: boolean; finalError?: string; }; settled?: boolean; } /** Assistant text blocks of a message, joined with '\n'. */ export declare function piMessageText(message: { content?: unknown; } | undefined): string; /** Usage of one assistant message in pi's own field names. */ export declare function piMessageUsage(usage: PiUsage | undefined): PiMessageUsage; /** Normalize one decoded pi event (either mode). */ export declare function parsePiEvent(ev: PiEvent): PiParsedLine | null; /** Pure per-line parser — shared by parsePiEvents (batch, used by tests * against fixture lines) and streamTurn (incremental, used at runtime). */ export declare function parsePiLine(line: string): PiParsedLine | null; /** Pure JSON-event parser — exported for unit testing against fixture lines * (pi-runner.test.ts). Usage is summed over assistant messages. */ export declare function parsePiEvents(lines: string[]): { texts: string[]; rawTexts: string[]; inputTokens: number; outputTokens: number; cacheReadTokens: number; cacheWriteTokens: number; costUsd?: number; }; export {}; //# sourceMappingURL=pi-runner-parse.d.ts.map