import type { ContextUsage } from '../../core/types/agent-types.js'; import type { NormalizedEvent } from '../normalize/event-types.js'; interface PIPendingCompletion { numTurns: number; totalCostUsd: number | null; error: string | null; } export interface PIEventParserState { /** Set on first successful bootstrap response; also serves as the session_started dedup sentinel. */ sessionId: string | null; /** Path of the most recent Write() call to a plan directory. Cleared on new session. */ pendingPlanPath: string | null; /** True while agent is in plan mode (between enter_plan_mode and exit_plan_mode). */ inPlanMode: boolean; /** toolCallId of the pending enter_plan_mode call; used to correlate tool_execution_end. */ pendingEnterPlanModeId: string | null; /** Cumulative turn count; incremented on each message_end to drive turn_progress. */ turnProgressCount: number; /** Low-level PI runs accumulated until agent_settled closes the Cortex turn. */ pendingCompletion: PIPendingCompletion; } export declare function createPIEventParserState(): PIEventParserState; /** * Translate one raw PI rpc stdout line (JSONL) to zero or more NormalizedEvents. * * Bootstrap dedup: state.sessionId is the sentinel. The parser sets it on first emission and * returns [] on subsequent bootstrap hits (Option A per Plan Review N2H-3). * * Dropped events (return []): turn_start, turn_end, message_start, agent_start, * queue_update, compaction_end, auto_retry_start/end, successful unrelated response, * message_update without text_delta, fire-and-forget extension_ui_request. * message_end emits a turn_progress heartbeat (non-terminal, state.turnProgressCount++). * compaction_start emits a context_compacted event (user notification); compaction_end is dropped * to avoid a duplicate notice. */ export declare function piRpcLineToNormalized(line: string, state: PIEventParserState): NormalizedEvent[]; /** Validate a get_session_stats payload for both event and control-call consumers. */ export declare function piContextUsageFromStats(data: unknown): ContextUsage | null; export {};