Skip to content

an open-source alternative to the dots, bots and muses of the world, run an office of claude code/codex like agents on your laptop, sandboxes or anywhere, uses your existing subscriptions

feat(grok): add first-class provider

Vyapak Goyal78fabbbf3cf5
diff --git a/README.md b/README.md
index a4c12f52..a8fe736a 100644
--- a/README.md
+++ b/README.md
@@ -94,8 +94,8 @@ terminal/event plane, and [`DESIGN.md`](./DESIGN.md) for the visual system.
| Area | What works today |
|---|---|
-| **Real terminals** | Spawn Claude Code, Antigravity (`agy` / Gemini), OpenAI Codex (GPT), Kimi Code, or a custom command in a `node-pty` PTY. Full read/write/resize/kill, live streaming over IPC, multi-agent. |
-| **Multi-provider hive** | Claude Code, Antigravity, and Codex workers can all participate in the same hive. Claude uses native hooks; Antigravity gets a native `agy-hook` bridge; Codex receives the protocol as its initial prompt and participates through inbox/outbox routing. |
+| **Real terminals** | Spawn Claude Code, Antigravity (`agy` / Gemini), OpenAI Codex (GPT), xAI Grok, Kimi Code, or a custom command in a `node-pty` PTY. Full read/write/resize/kill, live streaming over IPC, multi-agent. |
+| **Multi-provider hive** | Claude Code, Antigravity, Codex, and Grok workers can all participate in the same hive. Claude uses native hooks; the other first-class providers receive protocol injection plus lifecycle-hook bridges for safe routing. |
| **The hive** | On-disk multi-agent layer: per-agent identity + long-term memory, atomic-file mailboxes, a shared blackboard, append-only event log, single-committer git. |
| **GOD orchestrator** | An always-on supervisor agent that adjudicates traffic, routes tasks, scribes the blackboard, and escalates only critical items to you. |
| **Memory layer** | Markdown-first long-term memory per agent, mined into a shared semantic palace for instant recall; searchable from the UI. Degrades gracefully when the index isn't installed. |
@@ -129,7 +129,7 @@ terminal/event plane, and [`DESIGN.md`](./DESIGN.md) for the visual system.
| **Avatar states** | Avatars reflect real work — including new v0.2.0 states for *compacting* (context compaction) and *looping* (circuit-breaker intervention), on top of crisper HiDPI floor text and high-contrast speech bubbles. |
> [!NOTE]
-> **Status: v0.2.7 — voice, memory, floors & polish.** Building on the multi-provider floor — Claude Code, Antigravity (Gemini via `agy`), and OpenAI Codex all work as first-class hive participants (Antigravity via a native `agy-hook` bridge, Codex via lifecycle-hook parity plus protocol injection and provider-agnostic inbox/outbox routing) — v0.2.4→v0.2.7 add: **Free Flow voice dictation** (hold Option to talk; Groq Whisper transcribes straight into the composer), an opt-in **enterprise Knowledge Graph** agents query for ranked passages from your own documents/policies/context, **multi-window "floors"** (isolated offices with per-PTY routing), a **richer message composer** with file & image attachments, **agent session resume** across restarts (with a per-agent *Restart & Continue* button), **drag-a-file-onto-the-terminal** path injection, and **Slack/webhook triggers** that pipe a channel straight into Michael's queue. Everything from v0.2.0–v0.2.3 — observability, circuit breaker, durable persistence, context gauges, Command Center, task kanban, GitHub/CI integration, threaded conversations, desktop notifications, agent archival, and the dedicated Schedules tab — remains functional and shipping. macOS (signed), Windows, and Linux builds are available on the releases page.
+> **Status: v0.2.7 — voice, memory, floors & polish.** Building on the multi-provider floor — Claude Code, Antigravity (Gemini via `agy`), OpenAI Codex, and xAI Grok all work as first-class hive participants through native or provider-specific lifecycle hooks, protocol injection, and provider-agnostic inbox/outbox routing — v0.2.4→v0.2.7 add: **Free Flow voice dictation** (hold Option to talk; Groq Whisper transcribes straight into the composer), an opt-in **enterprise Knowledge Graph** agents query for ranked passages from your own documents/policies/context, **multi-window "floors"** (isolated offices with per-PTY routing), a **richer message composer** with file & image attachments, **agent session resume** across restarts (with a per-agent *Restart & Continue* button), **drag-a-file-onto-the-terminal** path injection, and **Slack/webhook triggers** that pipe a channel straight into Michael's queue. Everything from v0.2.0–v0.2.3 — observability, circuit breaker, durable persistence, context gauges, Command Center, task kanban, GitHub/CI integration, threaded conversations, desktop notifications, agent archival, and the dedicated Schedules tab — remains functional and shipping. macOS (signed), Windows, and Linux builds are available on the releases page.
## Getting started
@@ -143,7 +143,7 @@ terminal/event plane, and [`DESIGN.md`](./DESIGN.md) for the visual system.
```
- At least one supported terminal-agent CLI on your `PATH`: **[Claude Code](https://claude.com/claude-code)**
(`claude`, the default command), **Antigravity** (`agy`, Gemini), **OpenAI Codex** (`codex`),
- or **Kimi Code** (`kimi`).
+ **xAI Grok** (`grok`), or **Kimi Code** (`kimi`).
Claude uses native hooks, Antigravity uses the `agy-hook` bridge, and Codex participates through
initial-prompt protocol injection plus inbox/outbox routing.
- *Optional:* the semantic memory index for instant cross-session recall (the app works without it —
@@ -261,7 +261,7 @@ Shipped in **v0.2.0–v0.2.7**:
- [x] **Memory reflection** — the MemoryReflector summarizes and bounds per-agent memory over time to prevent unbounded growth.
- [x] **Persistence** — SQLite-backed durable store for window bounds + history across restarts, plus a durable cost ledger and persisted session IDs.
- [x] **Hook-driven avatars** — broadened hook→station coverage and caged the synthetic demo loop, with new *compacting* and *looping* avatar states.
-- [x] **Multi-provider floor** — Claude Code, Antigravity (`agy` / Gemini), and OpenAI Codex can participate in the same hive (Codex reaches full hive parity via a native lifecycle-hook bridge).
+- [x] **Multi-provider floor** — Claude Code, Antigravity (`agy` / Gemini), OpenAI Codex, and xAI Grok can participate in the same hive through native or provider-specific lifecycle-hook bridges.
- [x] **Dedicated Schedules tab** — recurring missions and the adaptive heartbeat have their own Command Center tab.
- [x] **Tunnelmole ingress** — Slack and generic webhook public URLs use tunnelmole instead of localtunnel.
- [x] **Voice dictation (Free Flow)** — hold Option to talk; Groq Whisper transcribes speech straight into the message composer (gated on a Groq key, encrypted at rest).
@@ -274,7 +274,7 @@ Shipped in **v0.2.0–v0.2.7**:
Next up:
- [ ] **More chat integrations** — Telegram and richer chat bridges that pipe a channel straight into Michael's queue (and route his replies back out), so you can run the floor from your phone.
-- [ ] **More provider CLIs** — extend the provider layer beyond Claude Code, Antigravity, and Codex.
+- [ ] **More provider CLIs** — extend the provider layer beyond Claude Code, Antigravity, Codex, and Grok.
- [ ] **Realtime Michael** — a low-latency realtime LLM channel for quick, snappy back-and-forth with the orchestrator, alongside the async terminal.
- [ ] **Fuller avatar coverage** — push the remaining station visits and tool-bubbles to be driven 100% by real Claude Code hook events.
- [ ] **Durable layout & command history** — extend persistence to agent layout and per-session command history.
diff --git a/src/main/hive.ts b/src/main/hive.ts
index 5b2b537d..ff2551fa 100644
--- a/src/main/hive.ts
+++ b/src/main/hive.ts
@@ -327,7 +327,8 @@ export class HiveManager {
const claudeProvider = isClaudeProvider(meta.provider ?? 'claude');
- // Non-hive-aware providers (Antigravity's `agy`, OpenAI's `codex`) don't
+ // Non-hive-aware providers (Antigravity's `agy`, OpenAI's `codex`, xAI's
+ // `grok`) don't
// understand Claude Code's flags (no `--append-system-prompt`, no telemetry,
// no `--settings`). Instead: (1) the hive identity+protocol rides in as the
// session's INITIAL prompt — the closest thing to `--append-system-prompt`
@@ -338,14 +339,14 @@ export class HiveManager {
//
// How the prompt rides in differs by CLI:
// - agy takes it under a flag (`agy -i "<prompt>"`) → push [flag, prompt].
- // - codex takes it POSITIONALLY (`codex "<prompt>"`, no flag) → push the
+ // - codex/grok take it POSITIONALLY (`codex|grok "<prompt>"`) → push the
// bare prompt as a trailing arg (node-pty passes argv literally, so it
// arrives as one positional argument after codex's own flags).
if (!isHiveAwareProvider(meta.provider)) {
const preset = providerPreset(meta.provider ?? 'claude');
const flag = preset.initialPromptFlag;
const prompt = this.injectedPrompt(meta, dir, root, opts.semanticMemory ?? false, opts.knowledgeGraph ?? false);
- // Both agy and codex expose a Claude-style lifecycle-hook surface, so each
+ // agy, codex, and grok expose a Claude-style lifecycle-hook surface, so each
// gets the SAME live status + Stop→inbox-drain Claude does — selected by the
// preset's `hookBridge`. agy needs a translating shim (its hook stdin/stdout
// shape differs from Claude's); codex reuses the Claude `cth-hook` shim
@@ -370,6 +371,7 @@ export class HiveManager {
// never fire. Must precede the positional prompt.
preArgs.push('--dangerously-bypass-hook-trust');
}
+ else if (bridge === 'grok') this.installGrokHooks();
} catch (e) { console.error(`[hive] install ${bridge} hooks failed:`, e); }
}
}
@@ -934,6 +936,48 @@ export class HiveManager {
return home;
}
+ /** Grok lifecycle-hook bridge → live hive status, session capture, guarded
+ * inbox delivery, and operator gates for `grok` workers.
+ *
+ * Grok supports the same hook events and decision vocabulary as Claude Code,
+ * but its stdin payload uses camelCase keys. A small adapter normalizes those
+ * keys to HookServer's Claude-shaped contract. The hook is installed in the
+ * user's global Grok hook directory because global hooks are trusted and
+ * Grok sessions/resume stay in the user's normal GROK_HOME. The adapter is
+ * strictly scoped by AGENT_ID, so ordinary Grok sessions exit without doing
+ * anything. Best-effort and idempotent. */
+ private installGrokHooks(): void {
+ const root = this.root();
+ if (!root) return;
+ try {
+ const shim = join(root, 'bin', 'grok-hook.cjs');
+ mkdirSync(join(root, 'bin'), { recursive: true });
+ writeFileSync(shim, GROK_HOOK_SHIM, 'utf8');
+ const tool = (matcher?: string) => ({
+ ...(matcher ? { matcher } : {}),
+ // Let Grok apply its event-aware defaults (5s normally, 600s for Stop).
+ hooks: [{ type: 'command', command: `node ${shim}` }]
+ });
+ const hooks = {
+ PreToolUse: [tool('.*')],
+ PostToolUse: [tool('.*')],
+ Stop: [tool()],
+ SubagentStop: [tool('.*')],
+ SessionStart: [tool('.*')],
+ UserPromptSubmit: [tool()],
+ PreCompact: [tool('.*')],
+ PostCompact: [tool('.*')]
+ };
+ const hookDir = join(homedir(), '.grok', 'hooks');
+ mkdirSync(hookDir, { recursive: true });
+ writeFileSync(
+ join(hookDir, 'munder-hive.json'),
+ JSON.stringify({ hooks }, null, 2),
+ 'utf8'
+ );
+ } catch (e) { console.error('[hive] installGrokHooks failed:', e); }
+ }
+
/** Write the live fleet snapshot Michael reads (`fleet.json`, gitignored).
* Best-effort — called from a timer, must never throw. */
writeFleetSnapshot(snapshot: unknown): void {
@@ -1272,3 +1316,77 @@ process.stdin.on('end', () => {
} catch (_) { process.exit(0); }
});
`;
+
+// ─── grok-hook shim (written to <hive>/bin/grok-hook.cjs) ───────────────────
+// Grok's lifecycle events and decisions are Claude-compatible, but the wire
+// payload is camelCase and uses snake_case event values. Normalize the input for
+// HookServer and translate its Claude-style permission denial into Grok's direct
+// decision form. Scoped by AGENT_ID so the trusted global hook is inert outside
+// Munder-spawned workers.
+const GROK_HOOK_SHIM = `#!/usr/bin/env node
+'use strict';
+const net = require('net');
+const agentId = process.env.AGENT_ID || null;
+let data = '';
+process.stdin.setEncoding('utf8');
+process.stdin.on('data', (d) => { data += d; });
+process.stdin.on('end', () => {
+ const sock = process.env.HIVE_SOCK;
+ if (!agentId || !sock) { process.exit(0); }
+ let grok = {};
+ try { grok = JSON.parse(data || '{}'); } catch (_) {}
+ const names = {
+ pre_tool_use: 'PreToolUse',
+ post_tool_use: 'PostToolUse',
+ post_tool_use_failure: 'PostToolUseFailure',
+ permission_denied: 'PermissionDenied',
+ stop: 'Stop',
+ stop_failure: 'StopFailure',
+ session_start: 'SessionStart',
+ session_end: 'SessionEnd',
+ user_prompt_submit: 'UserPromptSubmit',
+ notification: 'Notification',
+ subagent_start: 'SubagentStart',
+ subagent_stop: 'SubagentStop',
+ pre_compact: 'PreCompact',
+ post_compact: 'PostCompact'
+ };
+ const payload = {
+ hook_event_name: names[grok.hookEventName] || grok.hookEventName || 'Unknown',
+ agent_id: agentId,
+ session_id: grok.sessionId,
+ cwd: grok.cwd || grok.workspaceRoot,
+ tool_name: grok.toolName,
+ tool_input: grok.toolInput,
+ stop_hook_active: grok.stopHookActive,
+ prompt: grok.prompt,
+ source: grok.source,
+ notification_type: grok.notificationType,
+ message: grok.message
+ };
+ let resp = '';
+ const done = () => {
+ let out = null;
+ try {
+ const r = JSON.parse(resp || '{}');
+ if (r.continue === false) out = { continue: false, stopReason: r.stopReason };
+ else if (r.decision === 'block') out = { decision: 'block', reason: r.reason };
+ else if (r.hookSpecificOutput && r.hookSpecificOutput.permissionDecision === 'deny') {
+ out = { decision: 'deny', reason: r.hookSpecificOutput.permissionDecisionReason };
+ } else if (r.hookSpecificOutput && r.hookSpecificOutput.additionalContext) {
+ out = r;
+ }
+ } catch (_) {}
+ if (out) { try { process.stdout.write(JSON.stringify(out)); } catch (_) {} }
+ process.exit(0);
+ };
+ try {
+ const c = net.createConnection(sock, () => c.write(JSON.stringify(payload) + '\\n'));
+ c.setEncoding('utf8');
+ c.on('data', (d) => { resp += d; });
+ c.on('end', done);
+ c.on('error', () => process.exit(0));
+ setTimeout(() => process.exit(0), 5000).unref();
+ } catch (_) { process.exit(0); }
+});
+`;
diff --git a/src/main/index.ts b/src/main/index.ts
index 20135bd4..3cac3f47 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -1546,7 +1546,7 @@ ipcMain.handle('pty:spawn', async (evt, opts: SpawnOptions & {
return { ok: false, error: 'invalid SpawnOptions' };
}
// Which CLI is this? Explicit wins; else inferred from the binary
- // (claude/codex/agy). Non-Claude providers skip every Claude-only spawn step
+ // (claude/codex/grok/agy). Non-Claude providers skip every Claude-only spawn step
// below. Persist the resolved provider onto opts (+ hive meta) so the registry
// record and downstream provider-aware steps agree on one value.
const provider = inferAgentProvider(opts.command, opts.provider ?? opts.hive?.provider);
@@ -1671,8 +1671,8 @@ ipcMain.handle('pty:spawn', async (evt, opts: SpawnOptions & {
opts.args = args;
}
// Idempotent session resume on respawn (#6.6a) — provider-aware: Claude
- // `--resume <sid>`, Antigravity `--conversation <id>`. The recorded session id
- // comes from hook payloads (agy's conversationId flows through the bridge), so
+ // `--resume <sid>`, Grok `--resume <sid>`, Antigravity `--conversation <id>`.
+ // The recorded session id comes from hook payloads, so
// a restored worker continues its prior CLI session. Only when requested AND a
// prior id exists for this agent.
// Claude resume — incl. transcript seeding + only-attach-when-present — is
diff --git a/src/preload/index.ts b/src/preload/index.ts
index 7fe04945..9e48d978 100644
--- a/src/preload/index.ts
+++ b/src/preload/index.ts
@@ -7,7 +7,7 @@ declare const __APP_VERSION__: string;
export interface HiveAgentMeta {
id: string;
name: string;
- /** Which CLI this agent runs on (claude/codex/antigravity/custom); defaults claude. */
+ /** Which CLI this agent runs on (claude/codex/grok/antigravity/custom); defaults claude. */
provider?: AgentProvider;
role?: string;
capabilities?: string[];
@@ -115,7 +115,7 @@ export interface SpawnPtyOptions {
/** When true (and cwd is a git repo), spawn the agent in its own git worktree. */
isolate?: boolean;
/** When true, continue the agent's prior CLI session if one was recorded
- * (provider-aware: Claude `--resume`, Antigravity `--conversation`). For
+ * (provider-aware: Claude/Grok `--resume`, Antigravity `--conversation`). For
* Claude the main process looks up the session id from the hive registry and
* seeds its transcript into the cwd's project dir (#1 — restore on restart). */
resume?: boolean;
diff --git a/src/renderer/src/components/AddAgentModal.tsx b/src/renderer/src/components/AddAgentModal.tsx
index b2022747..562ed6ff 100644
--- a/src/renderer/src/components/AddAgentModal.tsx
+++ b/src/renderer/src/components/AddAgentModal.tsx
@@ -261,11 +261,13 @@ export function AddAgentModal({ onClose, config }: AddAgentModalProps) {
? 'Spawn the Antigravity CLI (agy) with a Gemini model'
: p.id === 'codex'
? 'Spawn Codex with GPT models and provider-native auto permissions'
- : p.id === 'kimi'
- ? 'Spawn Kimi Code with K3/K2.7 and provider-native auto permissions'
- : p.id === 'custom'
- ? 'Run any command — no Claude-only flags'
- : p.label
+ : p.id === 'grok'
+ ? 'Spawn Grok with Grok 4.5 and provider-native auto permissions'
+ : p.id === 'kimi'
+ ? 'Spawn Kimi Code with K3/K2.7 and provider-native auto permissions'
+ : p.id === 'custom'
+ ? 'Run any command — no Claude-only flags'
+ : p.label
}
style={{
padding: '3px 8px 1px',
@@ -319,11 +321,13 @@ export function AddAgentModal({ onClose, config }: AddAgentModalProps) {
? 'agy'
: provider === 'codex'
? 'codex'
- : provider === 'kimi'
- ? 'kimi'
- : provider === 'custom'
- ? 'your-agent-cli'
- : 'claude'
+ : provider === 'grok'
+ ? 'grok'
+ : provider === 'kimi'
+ ? 'kimi'
+ : provider === 'custom'
+ ? 'your-agent-cli'
+ : 'claude'
}
style={{ ...inputStyle, fontFamily: 'var(--cth-font-mono)' }}
/>
diff --git a/src/renderer/src/store/config.ts b/src/renderer/src/store/config.ts
index a94f7c68..d48ef230 100644
--- a/src/renderer/src/store/config.ts
+++ b/src/renderer/src/store/config.ts
@@ -136,6 +136,12 @@ export const CODEX_MODELS: ModelOption[] = [
{ id: 'gpt-5.6-luna', label: 'GPT-5.6 Luna' }
];
+/** Models reported by the installed Grok CLI (`grok models`). */
+export const GROK_MODELS: ModelOption[] = [
+ { id: undefined, label: 'default' },
+ { id: 'grok-4.5', label: 'Grok 4.5' }
+];
+
/** Managed Kimi Code aliases accepted by `kimi --model <alias>`. */
export const KIMI_MODELS: ModelOption[] = [
{ id: undefined, label: 'default' },
@@ -159,6 +165,7 @@ export function tokenizeCommand(command: string): string[] {
export function modelsForProvider(provider: AgentProvider): ModelOption[] {
switch (provider) {
case 'codex': return CODEX_MODELS;
+ case 'grok': return GROK_MODELS;
case 'kimi': return KIMI_MODELS;
case 'antigravity': return ANTIGRAVITY_MODELS;
case 'claude': return AGENT_MODELS;
@@ -208,7 +215,7 @@ export function buildSpawnCommand(
): string {
const preset = providerPreset(provider);
// Claude keeps the user's configured defaultCommand; custom falls back to it
- // too; every other provider (codex, kimi, agy) uses its preset binary so the app
+ // too; every other provider (codex, grok, kimi, agy) uses its preset binary so the app
// works even without Claude installed.
const base =
provider === 'claude'
@@ -224,7 +231,8 @@ export function buildSpawnCommand(
cmd = `${cmd} ${preset.modelFlag} ${m}`;
}
// Auto (skip-permissions) mode appends each provider's own flag — Claude's
- // bypassPermissions, Codex's dangerous bypass, Kimi's auto, or agy's skip flag.
+ // bypassPermissions, Codex's dangerous bypass, Grok's always-approve, Kimi's
+ // auto, or agy's skip flag.
if (config.autoMode && preset.autoFlag) cmd = `${cmd} ${preset.autoFlag}`;
return cmd;
}
diff --git a/src/shared/agentProvider.ts b/src/shared/agentProvider.ts
index bdfe6231..e3e837bc 100644
--- a/src/shared/agentProvider.ts
+++ b/src/shared/agentProvider.ts
@@ -1,7 +1,8 @@
/**
* Agent providers — the CLI a worker runs on. The app is no longer Claude-only:
* a worker can run Claude Code, the OpenAI Codex CLI (`codex`), Kimi Code
- * (`kimi`), the Antigravity CLI (`agy`, Gemini models), or any custom command.
+ * (`kimi`), xAI Grok (`grok`), the Antigravity CLI (`agy`, Gemini models), or
+ * any custom command.
* Each provider declares how to build its spawn command (model/auto-mode flags) and
* whether it accepts the hive's Claude-specific identity injection
* (`--append-system-prompt` + `--settings`).
@@ -14,8 +15,9 @@
import type { CmdGroup } from './claudeCommands';
import { COMMAND_GROUPS as CLAUDE_COMMAND_GROUPS } from './claudeCommands';
import { CODEX_COMMAND_GROUPS } from './codexCommands';
+import { GROK_COMMAND_GROUPS } from './grokCommands';
-export type AgentProvider = 'claude' | 'codex' | 'kimi' | 'antigravity' | 'custom';
+export type AgentProvider = 'claude' | 'codex' | 'grok' | 'kimi' | 'antigravity' | 'custom';
export interface AgentProviderPreset {
id: AgentProvider;
@@ -48,18 +50,20 @@ export interface AgentProviderPreset {
* the same live status that Claude gets from `--settings`:
* - 'agy' → installAgyHooks() writes ~/.gemini/.../hooks.json (translating
* shim, because agy's stdin/stdout shape differs from Claude's).
- * - 'codex' → installCodexHooks() writes a per-agent CODEX_HOME/hooks.json and
+ * - 'codex' → installCodexHooks() writes a per-agent CODEX_HOME config and
* reuses the Claude `cth-hook` shim verbatim (Codex's hook payload
* + response contract are already Claude-shaped).
+ * - 'grok' → installGrokHooks() installs an AGENT_ID-scoped adapter for
+ * Grok's camelCase lifecycle payloads.
* Claude leaves this undefined (it uses its native `--settings` path, gated by
* hiveAware); `custom` leaves it undefined (no bridge → no hooks). This is the
* single switch hive.ensureAgent dispatches on to wire the bridge. */
- hookBridge?: 'agy' | 'codex';
+ hookBridge?: 'agy' | 'codex' | 'grok';
/** Whether the router may DELIVER inbox mail to this provider (vs bouncing it
* to the god). Requires lifecycle status so the renderer can deliver only at a
- * safe idle prompt: Claude natively, Antigravity/Codex via their hookBridge.
+ * safe idle prompt: Claude natively, Antigravity/Codex/Grok via hook bridges.
* A hookless custom provider cannot expose safe-idle state, so mail bounces.
- * Distinct from hiveAware: agy/codex are NOT hiveAware (no Claude injection)
+ * Distinct from hiveAware: agy/codex/grok are NOT hiveAware (no Claude injection)
* but CAN receive inbox via their bridge. */
canReceiveInbox: boolean;
/** For non-hive-aware CLIs that still take an INITIAL prompt to orient the
@@ -130,6 +134,27 @@ export const AGENT_PROVIDER_PRESETS: AgentProviderPreset[] = [
resumeFlag: undefined,
resumeSubcommand: 'resume'
},
+ {
+ id: 'grok',
+ label: 'Grok · xAI',
+ defaultCommand: 'grok',
+ commandGroups: GROK_COMMAND_GROUPS,
+ // Grok documents bypassPermissions as the CLI/config spelling of its
+ // always-approve mode. Deny rules and lifecycle gates still take precedence.
+ autoModeFlag: '--permission-mode bypassPermissions',
+ autoFlag: '--permission-mode bypassPermissions',
+ supportsModel: true,
+ modelFlag: '--model',
+ hiveAware: false,
+ // Grok supports Claude-compatible lifecycle events but sends camelCase
+ // payloads. The bridge normalizes them before forwarding to HookServer.
+ hookBridge: 'grok',
+ canReceiveInbox: true,
+ // `grok [PROMPT]` accepts the initial hive protocol as a positional prompt.
+ positionalInitialPrompt: true,
+ // Grok resumes interactively with `grok --resume <session-id-or-title>`.
+ resumeFlag: '--resume'
+ },
{
id: 'kimi',
label: 'Kimi Code',
@@ -179,6 +204,7 @@ export function isAgentProvider(value: unknown): value is AgentProvider {
return (
value === 'claude' ||
value === 'codex' ||
+ value === 'grok' ||
value === 'kimi' ||
value === 'antigravity' ||
value === 'custom'
@@ -223,6 +249,7 @@ export function inferAgentProvider(command: string | undefined, explicit?: unkno
if (normalized) return normalized;
const bin = commandBinary(command);
if (bin === 'codex') return 'codex';
+ if (bin === 'grok') return 'grok';
if (bin === 'kimi') return 'kimi';
if (bin === 'agy' || bin === 'antigravity') return 'antigravity';
if (bin === 'claude' || !bin) return 'claude';
diff --git a/src/shared/grokCommands.ts b/src/shared/grokCommands.ts
new file mode 100644
index 00000000..3caa2b0c
--- /dev/null
+++ b/src/shared/grokCommands.ts
@@ -0,0 +1,37 @@
+/**
+ * Command reference for the xAI Grok CLI.
+ *
+ * Kept in the same shape as the Claude/Codex references so the Command Center
+ * and generated hive command guide can render provider-native commands.
+ */
+import type { CmdGroup } from './claudeCommands';
+
+export const GROK_COMMAND_GROUPS: CmdGroup[] = [
+ {
+ title: 'SESSION',
+ items: [
+ { cmd: '/new', kind: 'slash', desc: 'Start a fresh session and clear the current context.' },
+ { cmd: '/load', kind: 'slash', desc: 'Load a previous workspace session.', usage: '/load [workspace] [session]' },
+ { cmd: '/compact', kind: 'slash', desc: 'Compact conversation history while retaining the important working context.', usage: '/compact keep the current task and next step' },
+ { cmd: 'grok --resume <session-id>', kind: 'cli', desc: 'Resume an existing Grok session by ID or title.' }
+ ]
+ },
+ {
+ title: 'MODELS & PERMISSIONS',
+ items: [
+ { cmd: '/model', kind: 'slash', desc: 'Switch the model used by the current session.' },
+ { cmd: 'grok --model grok-4.5', kind: 'cli', desc: 'Launch Grok with the Grok 4.5 coding model.' },
+ { cmd: '/always-approve', kind: 'slash', desc: 'Toggle automatic approval of tool executions.' },
+ { cmd: 'grok --permission-mode bypassPermissions', kind: 'cli', desc: 'Launch in always-approve mode. Munder uses this when Auto Mode is on.' }
+ ]
+ },
+ {
+ title: 'TOOLS & WORKFLOW',
+ items: [
+ { cmd: '/rewind', kind: 'slash', desc: 'Rewind to a previous prompt and restore its file state.' },
+ { cmd: '/hooks-list', kind: 'slash', desc: 'Show lifecycle hooks active in this session.' },
+ { cmd: '/skills', kind: 'slash', desc: 'List or load installed skills.' },
+ { cmd: '/multiline', kind: 'slash', desc: 'Toggle multiline prompt entry.' }
+ ]
+ }
+];
diff --git a/src/shared/providerAutomation.ts b/src/shared/providerAutomation.ts
index 3f48d469..f147a6eb 100644
--- a/src/shared/providerAutomation.ts
+++ b/src/shared/providerAutomation.ts
@@ -13,6 +13,9 @@ export function compactionCommandForProvider(provider: AgentProvider): string |
// Codex treats trailing text differently across CLI releases. Its stable
// automation form is the bare slash command.
return '/compact';
+ case 'grok':
+ // Grok supports `/compact [context]`, including a focus instruction.
+ return `/compact ${COMPACTION_FOCUS}`;
case 'kimi':
// Kimi Code documents `/compact [<instruction>]`, so preserve the task
// focus in its supported optional instruction.
@@ -45,6 +48,7 @@ export function remoteControlCommandForProvider(
export function terminalReadySettleMs(provider: AgentProvider): number {
switch (provider) {
case 'kimi': return 650;
+ case 'grok': return 500;
case 'codex': return 500;
default: return 400;
}
diff --git a/test/provider-automation.test.cjs b/test/provider-automation.test.cjs
index b12249cd..21f3b2e5 100644
--- a/test/provider-automation.test.cjs
+++ b/test/provider-automation.test.cjs
@@ -15,10 +15,12 @@ const {
test('each provider receives only its supported compaction syntax', () => {
const claude = compactionCommandForProvider('claude');
const codex = compactionCommandForProvider('codex');
+ const grok = compactionCommandForProvider('grok');
const kimi = compactionCommandForProvider('kimi');
assert.match(claude, /^\/compact Summarise exactly/);
assert.equal(codex, '/compact');
+ assert.match(grok, /^\/compact Summarise exactly/);
assert.match(kimi, /^\/compact Summarise exactly/);
assert.equal(compactionCommandForProvider('antigravity'), null);
assert.equal(compactionCommandForProvider('custom'), null);
@@ -28,12 +30,14 @@ test('each provider receives only its supported compaction syntax', () => {
test('Claude alone receives a remote-control slash command', () => {
assert.equal(remoteControlCommandForProvider('claude', 'Michael'), '/remote-control Michael');
assert.equal(remoteControlCommandForProvider('codex', 'Jim'), null);
+ assert.equal(remoteControlCommandForProvider('grok', 'Grok'), null);
assert.equal(remoteControlCommandForProvider('kimi', 'Pam'), null);
});
test('provider readiness policies allow each TUI to settle', () => {
assert.equal(terminalReadySettleMs('claude'), 400);
assert.equal(terminalReadySettleMs('codex'), 500);
+ assert.equal(terminalReadySettleMs('grok'), 500);
assert.equal(terminalReadySettleMs('kimi'), 650);
});
diff --git a/test/provider-config.test.cjs b/test/provider-config.test.cjs
index e761f1c8..a0aaaf06 100644
--- a/test/provider-config.test.cjs
+++ b/test/provider-config.test.cjs
@@ -30,6 +30,19 @@ test('Kimi is a first-class inferred provider with autonomous defaults', () => {
assert.equal(preset.positionalInitialPrompt, undefined);
});
+test('Grok is a first-class inferred provider with hooks, resume, and always-approve', () => {
+ assert.equal(isAgentProvider('grok'), true);
+ assert.equal(inferAgentProvider('/Users/test/.local/bin/grok --model grok-4.5'), 'grok');
+ const preset = providerPreset('grok');
+ assert.equal(preset.defaultCommand, 'grok');
+ assert.equal(preset.autoFlag, '--permission-mode bypassPermissions');
+ assert.equal(preset.supportsModel, true);
+ assert.equal(preset.canReceiveInbox, true);
+ assert.equal(preset.hookBridge, 'grok');
+ assert.equal(preset.positionalInitialPrompt, true);
+ assert.equal(preset.resumeFlag, '--resume');
+});
+
test('provider commands use matching models and equivalent bypass modes', () => {
assert.equal(
buildSpawnCommand(autoConfig, 'claude-sonnet-5', 'claude'),
@@ -39,6 +52,10 @@ test('provider commands use matching models and equivalent bypass modes', () =>
buildSpawnCommand(autoConfig, 'gpt-5.6-sol', 'codex'),
'codex --model gpt-5.6-sol --dangerously-bypass-approvals-and-sandbox'
);
+ assert.equal(
+ buildSpawnCommand(autoConfig, 'grok-4.5', 'grok'),
+ 'grok --model grok-4.5 --permission-mode bypassPermissions'
+ );
assert.equal(
buildSpawnCommand(autoConfig, 'kimi-code/k3', 'kimi'),
'kimi --model kimi-code/k3 --auto'
@@ -54,6 +71,10 @@ test('model picker options stay provider-specific', () => {
modelsForProvider('codex').map((model) => model.id),
[undefined, 'gpt-5.6-sol', 'gpt-5.6-terra', 'gpt-5.6-luna']
);
+ assert.deepEqual(
+ modelsForProvider('grok').map((model) => model.id),
+ [undefined, 'grok-4.5']
+ );
assert.deepEqual(
modelsForProvider('kimi').map((model) => model.id),
[
@@ -82,10 +103,10 @@ test('Command Center model choices round-trip provider and model', () => {
test('God only sees providers that can drain hive inbox messages', () => {
assert.deepEqual(
modelProvidersForAgent(true).map((preset) => preset.id),
- ['claude', 'codex', 'antigravity']
+ ['claude', 'codex', 'grok', 'antigravity']
);
assert.deepEqual(
modelProvidersForAgent(false).map((preset) => preset.id),
- ['claude', 'codex', 'kimi', 'antigravity']
+ ['claude', 'codex', 'grok', 'kimi', 'antigravity']
);
});