/** * Streaming Stdout Protocol * * Event types emitted by pi child processes: * - session: session metadata * - agent_start: agent initialization * - turn_start: turn beginning * - message_start: message beginning * - message_end: message completed * - message_update: streaming delta * - thinking_start / thinking_delta: reasoning tokens * - text_delta: content tokens * * See core2/snapshot.ts for the Fork Snapshot Protocol (session state serialization). */ import type { Message } from "@earendil-works/pi-ai"; /** * Drain the accumulated streaming text buffer and return it. * Updates the last-emitted word count for threshold tracking. */ export declare function drainStreamingText(result: object): string; /** * Update the EMA-smoothed tokens-per-second based on a new sample. * Called from emitUpdate() with the estimated output tokens since last emit. * Accumulates tokens in pendingTokens and only computes a rate when * MIN_TPS_SAMPLE_MS has elapsed. Applies MAX_INSTANT_TPS cap before EMA. */ export declare function updateSmoothedTps(result: object, estimatedTokens: number): void; /** * Return the current EMA-smoothed tokens-per-second value. */ export declare function drainSmoothedTps(result: object): number; export interface CtxState { baseline: number; streamingChars: number; } /** * Lazily initialize ctx baseline tracking state on the result object. * Returns an accessor object backed by a WeakMap so frozen/sealed * objects do not throw. */ export declare function getCtxState(result: object): CtxState; /** * Drain the accumulated tool call token estimate and return it. * Returns 0 when no tool calls have been estimated. */ export declare function drainToolCallEstimate(result: object): number; /** * Drain the current streaming estimate and return estimated output tokens. * Returns 0 when no streaming has occurred. */ export declare function drainStreamingEstimate(result: object): number; /** * Return the estimated context tokens: last known real totalTokens (baseline) * plus any additional output tokens estimated since that baseline was set. * Returns 0 before the first message_end when no baseline exists yet, * in which case the caller should fall back to the streaming output estimate. */ export declare function drainCtxEstimate(result: object): number; export declare function stableStringify(value: unknown, seen?: WeakSet): string; export interface FlowResult { messages: Message[]; model?: string; stopReason?: string; exitCode?: number; stderr?: string; errorMessage?: string; usage?: { input: number; output: number; cacheRead: number; cacheWrite: number; cost: number; totalTokens?: number; turns: number; toolCalls: number; smoothedTps?: number; contextTokens: number; }; sawAgentEnd?: boolean; streamingText?: string; } export declare function processFlowJsonLine(line: string, result: FlowResult): boolean; export declare function getFlowFinalText(messages: Message[]): string; export declare function getFlowSummaryText(result?: FlowResult | null, options?: { toolContext?: boolean; }): string; //# sourceMappingURL=runner-events.d.ts.map