import type { InterruptibleEngine, EngineRunOpts, EngineResult, StreamDelta } from "../shared/types.js"; export declare const GROK_SESSIONS_DIR: string; export interface GrokParsedLine { deltas: StreamDelta[]; sessionId?: string; doneText?: string; error?: string; terminal?: boolean; contextTokens?: number; /** A reasoning event: its payload stays dropped, but it marks the end of an answer block. */ reasoning?: boolean; } export declare function grokCliFlags(flags: string[] | undefined): string[]; export declare function buildGrokHeadlessArgs(opts: EngineRunOpts, prompt: string, sessionId: string): string[]; export declare function parseGrokJsonLine(line: string): GrokParsedLine | null; /** * Deltas the HEADLESS engine forwards to the UI for a parsed line, by raw stream. * * The headless engine consumes two streams that are NOT mutually ordered: grok's * stdout (answer text, real-time) and the transcript tail (tool lifecycle only, * lagging stdout by the poll interval). * * Answer text is streamed live from STDOUT so the user sees Grok's real message * type out as it is generated (Grok emits all reasoning first, then the answer text * as one contiguous run, then `end`). The SAME answer also appears in the transcript * as `agent_message_chunk`, so transcript text is dropped here to avoid emitting it * twice — and `resultText` is accumulated from stdout only. The canonical result is * reconciled against the streamed text at completion by identity (see * use-live-session `session:completed`), so a transcript `tool_use` that lands after * the streamed answer no longer renders a duplicate bubble. That identity holds per * ROW, not per turn: a tool card closes the current text row, so `resultText` restarts * there too and stays equal to the last streamed row rather than to the whole turn. * Tool lifecycle + context stream live from the transcript. Reasoning is already * dropped by `parseGrokJsonLine`. */ export declare function grokVisibleDeltas(deltas: StreamDelta[], source: "stdout" | "transcript"): StreamDelta[]; export declare class GrokEngine implements InterruptibleEngine { name: "grok"; private liveProcesses; kill(sessionId: string, reason?: string): void; killAll(): void; /** Batch engine: no warm-PTY reuse, every live process is an in-flight turn. * Nothing idle to recycle on org-reload — no-op. */ killIdle(): void; isAlive(sessionId: string): boolean; run(opts: EngineRunOpts): Promise; private buildCleanEnv; private signalProcess; } //# sourceMappingURL=grok.d.ts.map