import type { CliAdapter } from './types.js'; /** * Adapter for xAI Grok Build TUI (`grok`). * * Binary: `grok` (install: curl -fsSL https://x.ai/cli/install.sh | bash). * State: `$GROK_HOME` (default `~/.grok`) — auth, sessions// * /, skills, hooks, session_search.sqlite. All paths below go * through grok-paths helpers so a custom GROK_HOME stays consistent * between the spawned CLI and the worker's watchers. * * ## Session model (verified on grok 0.2.93) * - botmux `sessionId` is already a UUID (`randomUUID()`), valid for * `grok --session-id` on fresh spawns. * - The session dir (summary.json + updates.jsonl) is created at TUI * STARTUP, before any prompt. `--session-id ` REFUSES an id whose dir * already exists ("Session ID is already in use", exit 1), so a fresh * spawn probes the dir and omits the flag when present (otherwise the * worker's tier-2 resume→fresh fallback would crash-loop on the same * UUID). Grok then mints its own id; writeInput's submit verify * recaptures it as cliSessionId. * - Resume: `--resume `; preflight via * `checkResumeTargetExists` against `summary.json`. A positional initial * prompt IS honored on resume spawns (verified), so no * `initialPromptArgsIgnoredOnResume`. * * ## Type-ahead * Grok's interactive TUI accepts mid-turn Enter as a follow-up. Although its * UI describes this as queued, 0.2.99 transcripts can contain multiple * `user_message_chunk`s before one `turn_completed` (active-turn merge). * `supportsTypeAhead: true` remains useful for ordinary IM turns and * CodexBridgeQueue's HOL-block-drop attributes the one merged final to the * newest matching turn. Durable deliveries are explicitly excluded from * type-ahead on both sides by the worker's queue policy, so an exact receipt * can never be merged away. * Multi-line input via tmux `send-keys -l` is safe: grok treats a literal * `\n` as a soft newline inside the composer, NOT as submit (verified — * no bracketed paste needed, unlike codex). * * ## Status / bridge * Bridge source of truth: per-session `updates.jsonl` * (`user_message_chunk` / `agent_message_chunk` + `turn_completed`), * drained via `drainGrokUpdates`. Submit VERIFY uses the bucket-level * `prompt_history.jsonl` instead: it is appended AT SUBMIT TIME even while * a turn is running, whereas updates.jsonl records a parked type-ahead * message only at DEQUEUE time — polling it would spuriously fail every * busy-turn submit (codex's history.jsonl plays the same role there). * Ready gate: global `$GROK_HOME/hooks/botmux-session-ready.json` * SessionStart → `botmux session-ready` (`injectsReadyHook`). * * ## Session context / system prompt * Grok's append flag is `--rules` (docs: alias of Claude's * `--append-system-prompt`). Full replace is `--system-prompt-override` — * too aggressive for botmux (would drop Grok's default agent prompt). We * set `injectsSessionContext` and push `buildBotmuxSystemPromptText` via * `--rules`, same contract as Claude's `--append-system-prompt` path * (session-manager then omits inline //). * * ## Skills * Interactive TUI does **not** accept `--plugin-dir` (agent-only / headless). * Built-ins use global `$GROK_HOME/skills` with global|prompt|off modes. * With injectsSessionContext, prompt/off catalogs ride on `--rules` * (genius pattern) rather than the per-message envelope. * * ## Plan mode * Claude disallows EnterPlanMode/ExitPlanMode for Feishu UX (blocking * approval). Grok's TUI equivalent is `--no-plan`. * * ## Sandbox * `authPaths: [$GROK_HOME]` (directory) — grok keeps SQLite DBs there * (session_search.sqlite, worktrees.db); under the deny-by-default file sandbox * a path not in authPaths doesn't exist, so they'd be unreachable / lack fcntl * locks. */ export declare function createGrokAdapter(pathOverride?: string): CliAdapter; export declare const create: typeof createGrokAdapter; //# sourceMappingURL=grok.d.ts.map