Add Grok CLI agent support (Beta) - #1190
Conversation
…orage - Add Grok CLI as a beta-supported agent - Implement streaming-json output parser for thought/text/end/error events - Add session storage for local and SSH-remote Grok transcripts - Register Grok capabilities, definitions, and model discovery - Discover models from models_cache.json with CLI fallback - Add Grok-specific error patterns for auth, resume, and model failures - Support batch, resume, read-only, and reasoning-effort flags - Accumulate text deltas when end events carry no response text - Exclude reasoning deltas from tab-name extraction - Document Grok CLI integration and known limitations
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
- Warn in the reasoning-effort description that 'none' is rejected by the default model (grok-4.5) while grok-composer-2.5-fast accepts it - Make getSessionPath() expand macOS /var|/tmp|/etc to the /private realpath form Grok records, so the returned transcript path agrees with what listSessions()/readSessionMessages() resolve - Bound local session-listing fan-out with LOCAL_SESSION_READ_CONCURRENCY so large ~/.grok/sessions folders don't open hundreds of files at once Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- Keep the parser's agent-specific login guidance when auth expires on an SSH remote: StdoutHandler now prefixes the remote-host context instead of replacing the message with a hardcoded "claude login" instruction that misdirects Grok/Codex/Copilot users - Replace em-dashes with spaced hyphens in Grok storage comments and test describe blocks per coding guidelines Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
@ksylvan First off, thank you for this contribution - this is an unusually thorough agent integration. The empirically-verified flag reasoning in I have one blocking item and a couple of nits before I'm happy to approve. Blocking: the SSH auth fix regresses Claude
That premise does not hold. I audited every
Pattern 58 shadows 63 for any real-world message containing "authentication failed". Same story for Net effect on
So the Grok misdirection is genuinely fixed (good catch by Codex), but Claude SSH users trade a correct, actionable command for a generic one. Since The Codex reviewer offered two branches; you took "keep the agent-specific message." I think the other branch is the safer one here: choose the login command by Either way, please extend the new Nits (non-blocking, but I'd like the first one addressed)1. References to a 2. Observation (no action needed, just flagging)The The Grok parser, session storage (the |
Choose the SSH auth re-login command by agentId via AGENT_LOGIN_COMMANDS so Claude keeps "claude login" and Grok gets "grok login", without depending on error-pattern message text or first-match ordering. Strip unreachable Working/ fixture paths from comments/docs, and switch the Grok icon to monochrome ✕ so it does not read as the red error state in the Left Bar.
|
@pedramamini Thanks for the careful review - especially catching the Claude SSH regression. Addressed in Blocking: SSH auth by agentIdAgreed the prefix-and-keep-parser-message approach was the wrong branch. Pattern messages are often generic, and first-match-wins shadows the Claude patterns that do name Took your preferred fix:
Net Claude SSH message is back to the actionable form:
Nits
ObservationNoted on the factory-droid Happy to tweak the login map (e.g. if Factory/OpenCode later grow a known CLI login) in a follow-up. |
|
@pedramamini Hold on this - Fixing the inline Wizard issue
|
Grok had supportsWizard=false and no stream extractors, so /wizard failed with "not supported". Enable the capability, join text deltas (skip thought) for conversation and doc-gen parsing, apply --permission-mode plan during discovery, and cover plan-mode spawn + structured reply parsing in tests.
Fixed with the latest commit |
Grok emits no tool events on streaming-json, so after the first thought the wizard looked frozen while tools (web fetch for GitHub URLs, etc.) ran for minutes. Cap discovery turns, disable web search, ban subagents, keep plan mode + always-approve, and only route isReasoning deltas to thinking-chunk so assistant JSON is not mistaken for finished work. Also accept parseable structured replies on non-zero exits (max-turns).
Plan mode and --disable-web-search blocked the reads and URL fetches discovery needs (e.g. GitHub issue links, package.json). Keep always-approve, max-turns, and no-subagents so silent tool loops cannot freeze the wizard UI forever, and soften the JSON suffix to allow scoped inspect/fetch without implementing.
# Conflicts: # src/__tests__/shared/agentMetadata.test.ts # src/main/process-manager/handlers/StdoutHandler.ts
The rc branch added supportsAdditionalDirectories as a required AgentCapabilities field; the grok entry added on this branch needs it. Conservative default of false since no directory-grant flag is confirmed for the Grok CLI. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
@pedramamini Grok 4.5 self-review using the Code Review Playbook. PR_COMMENT.md |
Harden Grok CLI Beta support after code/security review. No critical blockers; these changes close Major/Minor findings and follow-ups. Stream and thinking UX - StdoutHandler: only isReasoning partials emit thinking-chunk for Grok, Codex, Claude, and OpenCode so answer text does not flood the panel. Factory Droid keeps pre-Grok behavior (all partials); Copilot unchanged. - Soft-succeed CLI JSONL spawns when text streamed and exit is non-zero without a structured error (e.g. max-turns), matching wizard recovery. Parser and errors - Type-guard sessionId and error messages; empty errors no longer invent "Unknown error". - Mid-run non-JSON stderr runs the pattern bank (earlier auth/rate/model feedback). Truncate long unmatched bodies for UI; keep detail on raw. - Drop bare 401/429 auth and rate patterns; multi-token phrases only. - DRY thought/text deltas and AgentError construction. Wizard - Share extractGrokTextFromJsonl and GROK_WIZARD_DISCOVERY_ARGS across inline wizard, onboarding conversationManager, and document generation. - Fix supportsWizard comment (always-approve discovery, not plan mode). - Align modelArgs trim with configOptions.model.argBuilder. Session storage and paths - Validate sessionId before getSessionPath (no path traversal). - Honor GROK_HOME for sessions and models_cache (parity with CODEX_HOME). - Join all <user_query> wrappers; report unexpected SSH stats to Sentry. - Extract shared isExpectedRemoteError for Grok and Copilot storage. - Document raw tool-args JSON string shape for History consumers. Docs and tests - AGENT_SUPPORT: wizard always-approve residual, no noToolsArgs, History is not a scrubbed vault, multi-token auth/rate patterns, GROK_HOME paths. - Tests for parser, storage, error patterns, StdoutHandler, CLI soft-success, grokWizard helpers, remote-error-utils, and onboarding Grok path.
# Conflicts: # src/main/storage/index.ts

Add Grok CLI agent support (Beta)
Summary
Adds full Grok CLI (
grok) support as a Beta agent in Maestro. Integration covers agent definition and capabilities, streaming-json output parsing, session storage (local + SSH), model discovery, error classification, CLI/desktop spawn composition, tab naming, and UI (picker, icon, display names). Behavior is verified against grok v0.2.93 fixtures.Files Changed
Documentation
AGENT_SUPPORT.md— Full Grok CLI section (binary, flags, events, limitations, command patterns).CLAUDE-AGENTS.md/CLAUDE.md— Grok listed as Beta with capability notes.docs/agent-guides/AGENT-INFRA.md—grokadded to agent ID examples.Shared / agent registry
src/shared/agentIds.ts—grokinAGENT_IDS.src/shared/agentMetadata.ts— Display nameGrok CLI; added toBETA_AGENTS.src/shared/agentConstants.ts— Default context window500000(grok-4.5).Agent definition & detection
src/main/agents/definitions.ts— Full definition: batch (-p), YOLO (--always-approve), read-only (--permission-mode plan), resume, cwd, model (-m), reasoning effort, config options.src/main/agents/capabilities.ts— Capabilities (resume, read-only, session storage, streaming, thinking, batch; no usage/cost/image/tools on stream).src/main/agents/detector.ts— Model discovery from~/.grok/models_cache.json, fallback togrok models.Parsers & errors
src/main/parsers/grok-output-parser.ts(new) — Parsesthought/text/end/errorJSONL events.src/main/parsers/error-patterns.ts— Grok patterns (auth, rate limit, context, network, bad model, session not found).src/main/parsers/index.ts,parser-factory.ts— RegisterGrokOutputParser.Session storage
src/main/storage/grok-session-storage.ts(new) — Reads~/.grok/sessions/<percent-encoded-cwd>/<uuid>/(summary.json+chat_history.jsonl); local + SSH; project filtering; tool_result merge; no message-pair delete.src/main/storage/index.ts— Register storage.Spawn / response handling
src/cli/services/agent-spawner.ts— Accumulate non-reasoning partialtextdeltas when the terminal result has no text (Grok’sendevent).src/main/ipc/handlers/tabNaming.ts— IgnoreisReasoningtext when extracting tab names so thought deltas don’t pollute names.UI
src/renderer/components/NewInstanceModal/types.ts—grokinSUPPORTED_AGENTS.src/renderer/constants/agentIcons.ts— Icon✖️.src/renderer/components/UsageDashboard/autoRunTableUtils.ts— Display nameGrok CLI.Tests (new/updated)
Code Changes
Agent definition (spawn flags)
Batch/YOLO use the same boolean flag so clap never sees a repeated
--permission-mode:Typical invocation:
Output parser
Maps Grok’s four stream events:
thought+datatextpartial,isReasoning: truetext+datatextpartialend+sessionIdresult(session ID only; no usage/cost)error+messageerrorNo tool events on stdout; no init event; session ID only on
end.Session storage
~/.grok/sessions/<encodeURIComponent(cwd)>/<session-uuid>/<user_query>wrappers; skips synthetic/<user_info>recordstool_resultinto prior assistanttool_callsby id/private/var↔/varpath normalization for project matchCLI response accumulation
Tab naming
Reason for Changes
Enable Maestro users to run xAI Grok CLI alongside existing agents with the same product surface: batch runs, resume, read-only/plan mode, model + reasoning-effort config, thinking panel, session history (local/SSH), and structured error recovery. Implementation follows established patterns (Copilot-style session dirs, Codex-like batch-only posture) while handling Grok-specific stream and clap constraints.
Impact of Changes
grokis installed.Test Plan
GrokOutputParser(deltas, end/sessionId, errors, exit/stderr resume failures).GrokSessionStorage(list/filter, metadata, pagination, SSH, oversized/malformed, never-prompted).grok modelsfallback + empty).buildAgentArgsdesktop composition (unique flags; read-only strips approve; yolo dedupe).spawnAgent(text accumulation, read-only, resume, stream error).~/.grok/sessionsdata (local and SSH if available).Additional Notes
BETA_AGENTS.batchModeArgs === yoloModeArgs === ['--always-approve']is intentional: clap rejects repeated--permission-mode, and boolean flags dedupe cleanly when yolo + batch both apply.noToolsArgsintentionally omitted: no reliable all-tools-off flag on v0.2.93.401/429) until real unauthenticated/rate-limit log strings are captured; bad-model and bad-resume patterns are fixture-verified.thinking-chunkforisReasoningpartials so Grok answer text does not flood the thinking panel. Factory Droid keeps the pre-Grok behavior of forwarding all non-reasoning partials to the thinking panel (no live regression). Copilot still never uses thinking-chunk.--always-approve+--max-turns 8+--no-subagents(not plan mode), shared viaGROK_WIZARD_DISCOVERY_ARGS. Residual write risk under the turn budget is documented inAGENT_SUPPORT.md.Summary by CodeRabbit