Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

feat(agents): add Grok as a builtin

enes4866e261eb37
diff --git a/src/shared/agents/config.capabilities.test.ts b/src/shared/agents/config.capabilities.test.ts
index 085830836..8f8299d69 100644
--- a/src/shared/agents/config.capabilities.test.ts
+++ b/src/shared/agents/config.capabilities.test.ts
@@ -69,3 +69,33 @@ describe('createdAgentId', () => {
expect(createdAgentId({ tags: 'claude' })).toBeUndefined()
})
})
+
+/**
+ * Grok arrives with spawn + resume and nothing else, which is the registry's own design for a new
+ * agent ("a custom agent is in no list, so it automatically gets only spawn + terminal-title +
+ * process status"). Hooks, context links and canvas control each need per-agent machinery that has
+ * not been written for it — an installer, a transcript parser, a discovery file — and claiming any
+ * of them here would light badges that never update and offer menu items that do nothing.
+ */
+describe('grok capabilities', () => {
+ it('is a builtin with a launch command and a colour', () => {
+ expect(BUILTIN_AGENT_IDS).toContain('grok')
+ expect(AGENT_CONFIG.grok.launchCmd).toBe('grok')
+ expect(AGENT_CONFIG.grok.label).toBe('Grok')
+ })
+
+ it('takes its prompt through stdin, because a bare positional is REJECTED by the CLI', () => {
+ // `grok "explain this"` → "error: unrecognized subcommand": its usage is
+ // `grok [OPTIONS] [COMMAND]`, so a bare word parses as a subcommand. `-p/--single` prints one
+ // answer and exits, so it is not an interactive session either. That leaves the TUI.
+ expect(AGENT_CONFIG.grok.promptInjectionMode).toBe('stdin-after-start')
+ })
+
+ it('claims resume and nothing beyond it', () => {
+ expect(canResume('grok')).toBe(true)
+ expect(hasHooks('grok')).toBe(false)
+ expect(canContextLink('grok')).toBe(false)
+ expect(canBranch('grok')).toBe(false)
+ expect(canControlCanvas('grok')).toBe(false)
+ })
+})
diff --git a/src/shared/agents/config.ts b/src/shared/agents/config.ts
index 3d4badbdf..69d734a96 100644
--- a/src/shared/agents/config.ts
+++ b/src/shared/agents/config.ts
@@ -2,7 +2,7 @@
// Design: an open AgentId string, a declarative config record, and
// capabilities expressed as const membership lists (not a capability object).
-export type BuiltinAgentId = 'claude' | 'codex' | 'gemini' | 'opencode'
+export type BuiltinAgentId = 'claude' | 'codex' | 'gemini' | 'opencode' | 'grok'
// Open type — custom agents are any string ('custom:<uuid>'). Never restrict the set.
export type AgentId = BuiltinAgentId | (string & {})
@@ -16,7 +16,13 @@ export interface AgentConfig {
expectedProcess: string
}
-export const BUILTIN_AGENT_IDS: readonly BuiltinAgentId[] = ['claude', 'codex', 'gemini', 'opencode']
+export const BUILTIN_AGENT_IDS: readonly BuiltinAgentId[] = [
+ 'claude',
+ 'codex',
+ 'gemini',
+ 'opencode',
+ 'grok'
+]
export const AGENT_CONFIG: Record<BuiltinAgentId, AgentConfig> = {
claude: {
@@ -48,13 +54,25 @@ export const AGENT_CONFIG: Record<BuiltinAgentId, AgentConfig> = {
// through --prompt (see createAgentNode's flag-prompt branch).
promptInjectionMode: 'flag-prompt',
expectedProcess: 'opencode'
+ },
+ grok: {
+ label: 'Grok',
+ color: '#64748b',
+ launchCmd: 'grok',
+ // NOT `argv`, and this was checked against the binary rather than assumed: `grok "prompt"`
+ // is rejected outright ("error: unrecognized subcommand"), because the CLI's usage is
+ // `grok [OPTIONS] [COMMAND]` and a bare word is read as a subcommand. Its `-p/--single`
+ // prints one answer and EXITS, so it is not an interactive node either. That leaves typing
+ // the prompt into the TUI after it starts — the same shape gemini needs.
+ promptInjectionMode: 'stdin-after-start',
+ expectedProcess: 'grok'
}
}
// Capabilities = const membership lists. A custom agent is in no list, so it
// automatically gets only spawn + terminal-title + process status.
export const AGENT_HOOK_TARGETS = ['claude', 'codex', 'gemini', 'opencode'] as const
-export const RESUMABLE_AGENTS = ['claude', 'codex', 'gemini', 'opencode'] as const
+export const RESUMABLE_AGENTS = ['claude', 'codex', 'gemini', 'opencode', 'grok'] as const
export const SUBAGENT_CAPABLE = ['claude'] as const
export const RECURRING_CAPABLE = ['claude'] as const // /loop, /schedule, /cron
export const BRANCH_CAPABLE = ['claude'] as const
@@ -139,6 +157,7 @@ export function resumeCommand(id: AgentId, sessionId: string): string | null {
return `opencode --session ${sid}`
case 'claude':
case 'gemini':
+ case 'grok':
return `${id} --resume ${sid}`
default:
return null
diff --git a/src/shared/agents/resume.test.ts b/src/shared/agents/resume.test.ts
index aa3c7865f..bbaf381a5 100644
--- a/src/shared/agents/resume.test.ts
+++ b/src/shared/agents/resume.test.ts
@@ -37,3 +37,14 @@ describe('resumeCommand', () => {
expect(resumeCommand('opencode', 'x; rm -rf /')).toBeNull()
})
})
+
+/**
+ * Grok's entry was read off the SHIPPED BINARY (`@xai-official/grok`, `grok --help`) rather than
+ * from a README or from the shape of the agents beside it — `-r, --resume [<SESSION_ID>]`, the same
+ * spelling claude and gemini use, which is why it shares their branch instead of getting its own.
+ */
+describe('resumeCommand — grok', () => {
+ it('builds grok resume', () => {
+ expect(resumeCommand('grok', 'abc-123')).toBe('grok --resume abc-123')
+ })
+})