/** Pull a session/thread id out of a parsed event, tolerating the field-name * variants different CLI versions/backends tend to use. */ export declare function extractSessionId(ev: Record): string | undefined; /** Pull assistant-visible text out of a parsed event, tolerating the shape * variants documented (or plausible) for grok's output formats: * - `streaming-messages-json` (what the runner passes): { type: * 'assistant', message: { content: [{type:'text',text}, ...] } } * - codex-style: { type: 'item.completed', item: { type: 'agent_message', text } } * - flat role shape: { role: 'assistant', content: '...' | [{type:'text',text}] } * - flat type shape: { type: 'assistant' | 'message', text: '...' } */ export declare function extractText(ev: Record): string | undefined; /** Pull usage totals out of a parsed event, tolerating openai-ish * (prompt_tokens/completion_tokens) and codex-ish (input_tokens/output_tokens) * field names. */ export declare function extractUsage(ev: Record): { input: number; output: number; } | undefined; /** Pull a fatal error message out of a parsed event, tolerating an * `error`/`turn.failed` event with either a nested `error.message` or a * flat `message` field, and a `streaming-messages-json` result with * `is_error: true` and `errors[]` (e.g. "Not signed in", verified live). */ export declare function extractError(ev: Record): string | undefined; /** Pure NDJSON parser — exported so it can be unit tested against fixture * lines without spawning the real CLI (see grok-runner.test.ts). The * streaming path (grok-runner-stream.ts's streamTurn) parses one line at a * time via the same extract* helpers, so both share the shape-tolerance * logic. */ export declare function parseGrokEvents(lines: string[]): { texts: string[]; rawTexts: string[]; sessionId?: string; inputTokens: number; outputTokens: number; error?: string; }; /** grok's native tool calls (assistant `tool_use` blocks) and their results * (user `tool_result` blocks) in one `streaming-messages-json` event. */ export declare function extractToolBlocks(ev: Record): { toolUses: Array<{ id: string; name: string; input: unknown; }>; toolResults: Array<{ id: string; output: unknown; isError: boolean; }>; }; /** * One parsed grok event, normalized for incremental streaming. * - 'assistant': rawText is one whole assistant text (fences intact) for * end-of-turn tool-call parsing; text is the fence-stripped prose, * present only when non-empty. May also carry `toolUses`. * - 'native': grok's own tool calls/results with no text alongside. * - 'tool': liveness only — the spawn-time yield. */ export interface GrokStreamEvent { kind: 'assistant' | 'native' | 'tool'; text?: string; rawText?: string; toolName?: string; toolUses?: Array<{ id: string; name: string; input: unknown; }>; toolResults?: Array<{ id: string; output: unknown; isError: boolean; }>; sessionId?: string; } //# sourceMappingURL=grok-runner-parse.d.ts.map