import type { CodexBridgeEvent, CodexDrainResult } from './codex-transcript.js'; import { encodeGrokCwd } from './grok-paths.js'; import type { ResumableSession } from '../adapters/cli/types.js'; export type GrokBridgeEvent = CodexBridgeEvent; export type GrokDrainResult = CodexDrainResult; /** Locate updates.jsonl for a session id, optionally scoped to cwd. */ export declare function findGrokUpdatesBySessionId(sessionId: string, cwd?: string): string | undefined; export declare function findGrokSummaryBySessionId(sessionId: string, cwd?: string): string | undefined; /** True when a session dir with summary.json exists (resume preflight). */ export declare function grokSessionExists(sessionId: string, cwd?: string): boolean | undefined; /** True when the session DIRECTORY exists in any cwd bucket — regardless of * summary.json. Grok creates the dir (with summary.json) at TUI startup and * REFUSES `--session-id ` when the dir already exists ("Session ID is * already in use", exit 1) — so a fresh spawn must probe the dir itself, not * the resume preflight's summary.json. */ export declare function grokSessionDirExists(sessionId: string, cwd?: string): boolean; /** Extract the grok session id from any path under the sessions root — used * by the worker to detect a `/new` / `/clear` / `/resume` rotation (new * session id at the same pid) and re-attach the bridge. */ export declare function grokSessionIdFromPath(path: string): string | undefined; /** Bind a live Grok pid to its session via open fds (Linux /proc or lsof). */ export declare function findGrokSessionByPid(pid: number): { sessionId: string; updatesPath: string; } | undefined; /** * Increment-read updates.jsonl. Agent chunks of the CURRENT contiguous group * are buffered. A non-message event (tool_call / thought / hook) while a * group is buffered **drops that group immediately** and advances the offset * (narration cannot become the final answer — codex final_answer parity). * The next agent chunk starts a fresh group; `turn_completed` always emits a * terminal `assistant_final` event, with whatever group is still buffered as * its (possibly empty) text. If the file ends mid-group, newOffset * rewinds to the group's first chunk so the next poll re-reads it (queue * dedups by uuid). */ export declare function drainGrokUpdates(path: string, fromOffset: number): GrokDrainResult; /** Current file size helper for submit-verify baseByte. */ export declare function grokFileSize(path: string): number; /** * Scan the bucket-level prompt_history.jsonl from `fromByte` for a submit * whose `prompt` equals `expectedText` (modulo newline normalisation — the * composer stores multi-line input verbatim with `\n`). prompt_history is * written AT SUBMIT TIME even while a turn is running (verified 0.2.93), so * this confirms busy-turn type-ahead submits that updates.jsonl (dequeue-time * user events) cannot. Returns the owning session id when found. * * Concurrent safety: the file is cwd-bucket shared. Two workers in the same * repo can append identical prompt text under different session_ids. Callers * MUST pass `preferSessionId` (from {@link findGrokSessionByPid} of their * CLI pid) so we never claim another worker's line. Without a prefer id we * only accept a match when all matching lines agree on a single session_id * (or have no id); ambiguous multi-sid hits fail closed. */ export declare function matchGrokPromptAppend(path: string, fromByte: number, expectedText: string, opts?: { preferSessionId?: string; }): { found: boolean; cliSessionId?: string; }; /** * Discover resumable Grok sessions for `/adopt` import. * Most-recent first, capped to `limit`, excluding live ids. */ export declare function discoverGrokSessions(limit: number, exclude?: ReadonlySet): Promise; /** Encode helper re-export for adapters that need the bucket name. */ export { encodeGrokCwd }; //# sourceMappingURL=grok-transcript.d.ts.map