Skip to content

feat: add Grok as first-class harness#138

Open
khaliqgant wants to merge 3 commits into
mainfrom
claude/grok-harness-support
Open

feat: add Grok as first-class harness#138
khaliqgant wants to merge 3 commits into
mainfrom
claude/grok-harness-support

Conversation

@khaliqgant
Copy link
Copy Markdown
Member

@khaliqgant khaliqgant commented Jun 7, 2026

What this PR does

  • Adds Grok (xAI) as a first-class harness alongside Claude, Codex, and OpenCode across all enumeration points: type definitions, burn stamping, proactive agent types/editor, cloud agent picker, spawn dialogs, toolbar, and icons
  • GrokIcon SVG added to AgentIcons.tsx (xAI X-shape mark)
  • Default models: grok-build, grok-composer-2.5-fast
  • Empty-state spawn buttons updated to 3-column grid (Claude / Codex / Grok)

Why Grok is PTY-only (intentional)

Grok runs the grok CLI in a pseudo-terminal — the same as Codex before its app-server. This is intentional: xAI has not shipped a structured output mode equivalent to Claude's --output-format stream-json or Codex's app-server event stream.

Grok headless support is tracked in issue #141. Once relay confirms compatibility with Grok's --output-format streaming-json, Grok can be added to the headless list in #139/#140 and structured rendering can follow the same pattern as Claude/Codex.

How this differs from #139/#140

PRs #139 and #140 move Claude, Codex, and OpenCode off PTY onto relay's headless transport (no PTY process created). Grok stays PTY here because there is no structured output alternative available from xAI yet.

Deferred


Generated by Claude Code

Wires Grok (xAI) across all harness enumeration points so it has
the same unified UI experience as Claude and Codex: type definitions,
burn stamping, proactive agent types and editor, cloud agent picker,
spawn dialogs, toolbar, icons, and empty-state quick-spawn buttons.

Note: Grok is PTY-based — no structured output mode is available yet.
Structured rendering (equivalent to Claude stream-json / Codex
app-server) is deferred pending xAI shipping a JSON output interface.

https://claude.ai/code/session_01KXU1uAUwx3L82TMLnAmU4z
@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Jun 7, 2026

Your free trial PR review limit of 300 PRs has been reached. Please upgrade your plan to continue using CodeAnt AI.

@gemini-code-assist
Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 7, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds support for a new agent harness grok across the Pear application. Type definitions are updated in shared, main process, and renderer code to recognize grok as a valid harness value alongside claude, codex, and opencode. Backend validation and harness inference logic incorporate the new value. Frontend components gain a Grok icon asset and UI buttons for agent creation and spawning, with grid layouts adjusted to accommodate the additional option.

Changes

Grok Harness Support

Layer / File(s) Summary
Harness Type Definitions
src/main/proactive-agent.types.ts, src/shared/types/ipc.ts, src/renderer/src/lib/spawn-agent.ts
ProactiveAgentHarness and SpawnAgentCli type unions are extended to include 'grok' as a valid harness value across shared, main process, and renderer scopes.
Backend Harness Recognition and Validation
src/main/proactive-agent.ts, src/main/proactive-agent.bundle.ts, src/main/broker.ts, src/main/burn-spawn-hook.ts
HARNESSES validation allows grok, error messages reference it, proactive agent bundles accept it, CLI preflight skips augmented-PATH for grok, and harness inference maps grok launcher names to the grok harness value.
Grok Icon Component and Registry
src/renderer/src/components/common/AgentIcons.tsx
New GrokIcon component is exported and registered in AGENT_ICON_COMPONENTS alongside existing icon mappings, enabling grok icon resolution across UI components.
Agent Creation UI Integration
src/renderer/src/components/proactive/ProactiveAgentCard.tsx, src/renderer/src/components/proactive/ProactiveAgentEditor.tsx, src/renderer/src/components/agents/CloudAgentPicker.tsx
Proactive agent types accept grok, editor model options include grok model IDs and a harness dropdown option, and cloud picker adds grok to HARNESS_OPTIONS and maps xai/x.ai to the grok CLI with default model grok-build.
Agent Spawn Buttons and Quick Actions
src/renderer/src/components/common/AgentToolbar.tsx, src/renderer/src/components/sidebar/SpawnAgentDialog.tsx, src/renderer/src/components/terminal/TerminalPane.tsx
Toolbar, spawn dialog, and terminal pane each gain a grok agent button with GrokIcon; grid layouts expand from 2 to 3 columns; terminal button includes click handling, disabled state logic, and dynamic labels matching existing spawn button behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A new grok joins the agent's parade,
Type contracts aligned, foundations laid,
Preflight paths checked, icons displayed,
Buttons and models, no code dismayed,
The warren grows wider—let grok be weighed! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding Grok as a first-class harness alongside Claude and Codex, which is confirmed by the comprehensive modifications across type definitions, UI components, and agent systems throughout the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The PR description clearly explains what the changes do: adding Grok as a first-class harness alongside Claude, Codex, and OpenCode, with details on implementation, design choices, and deferred work.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/grok-harness-support

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/burn-spawn-hook.ts (1)

84-92: ⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Grok is inferred but still coerced to Claude in burn stamping paths.

Line 91 adds 'grok' as an inferred harness, but Grok currently falls through to the unknown-launcher fallback that writes pending stamps as harness: 'claude'. That creates harness misattribution in burn data. The same coercion pattern also exists in src/main/broker.ts child-lineage stamping logic, so both paths should be aligned in the same change.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/burn-spawn-hook.ts` around lines 84 - 92, The inferHarness function
currently recognizes 'grok' but downstream burn-stamp writing still coerces
unknown launchers to 'claude', causing misattribution; update the burn-stamping
path so it uses the actual inferHarness result (or explicitly maps 'grok' to
'grok') instead of forcing 'claude', and make the same change in the
child-lineage stamping logic in src/main/broker.ts so both use the same harness
value (ensure you reference inferHarness and the burn-stamp/write-pending-stamp
code paths in broker.ts and replace the hardcoded 'claude' fallback with the
inferred harness or explicit 'grok' mapping).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/renderer/src/components/proactive/ProactiveAgentEditor.tsx`:
- Around line 90-95: The MODEL_OPTIONS constant in ProactiveAgentEditor.tsx
contains Grok entries that don't match xAI docs; either confirm these internal
aliases are supported or update the grok array to use the documented model IDs
(e.g., replace 'grok-build' with 'grok-build-0.1' and replace
'grok-composer-2.5-fast' with the documented composer ID such as
'grok-composer-0.1' or the correct public identifier); ensure the change is
applied to the MODEL_OPTIONS constant so downstream selection code uses valid
xAI model IDs or documented internal aliases.

---

Outside diff comments:
In `@src/main/burn-spawn-hook.ts`:
- Around line 84-92: The inferHarness function currently recognizes 'grok' but
downstream burn-stamp writing still coerces unknown launchers to 'claude',
causing misattribution; update the burn-stamping path so it uses the actual
inferHarness result (or explicitly maps 'grok' to 'grok') instead of forcing
'claude', and make the same change in the child-lineage stamping logic in
src/main/broker.ts so both use the same harness value (ensure you reference
inferHarness and the burn-stamp/write-pending-stamp code paths in broker.ts and
replace the hardcoded 'claude' fallback with the inferred harness or explicit
'grok' mapping).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 75cea760-5d8c-43f2-8e5e-050b5caffdd3

📥 Commits

Reviewing files that changed from the base of the PR and between 89eec3a and dc7d3df.

📒 Files selected for processing (14)
  • src/main/broker.ts
  • src/main/burn-spawn-hook.ts
  • src/main/proactive-agent.bundle.ts
  • src/main/proactive-agent.ts
  • src/main/proactive-agent.types.ts
  • src/renderer/src/components/agents/CloudAgentPicker.tsx
  • src/renderer/src/components/common/AgentIcons.tsx
  • src/renderer/src/components/common/AgentToolbar.tsx
  • src/renderer/src/components/proactive/ProactiveAgentCard.tsx
  • src/renderer/src/components/proactive/ProactiveAgentEditor.tsx
  • src/renderer/src/components/sidebar/SpawnAgentDialog.tsx
  • src/renderer/src/components/terminal/TerminalPane.tsx
  • src/renderer/src/lib/spawn-agent.ts
  • src/shared/types/ipc.ts

Comment thread src/renderer/src/components/proactive/ProactiveAgentEditor.tsx
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 14 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread src/main/burn-spawn-hook.ts Outdated
@agent-relay-code
Copy link
Copy Markdown
Contributor

Reviewed the checked-out PR artifacts, which identify the workspace as PR #139 despite the prompt saying #138.

Changed in the workspace:

  • Updated package-lock.json to match the Agent Relay 8.3.0 dependency bump.
  • Addressed Cubic’s headless attach finding in src/main/broker.ts: runtime tracking is session-scoped and learned from listAgents, with a regression in src/main/broker.test.ts.
  • Addressed Cubic’s renderer findings:
    • agent-store.ts now validates event.runtime before storing it.
    • TerminalPane.tsx now lets opacity fade before hiding inactive panes.

Verification passed:

  • npm run build
  • npm test - 88 tests
  • npx vitest run src/main/broker.test.ts - 35 tests

I did not print READY because GitHub reports PR #139 as mergeable_state: unstable, and I cannot verify all required checks are complete and passing from the available status data.

@agent-relay-code
Copy link
Copy Markdown
Contributor

⚠️ pr-reviewer did not push — the PR branch advanced during the review, so fixes were withheld to avoid overwriting newer commits. Re-trigger the review once the branch settles. The notes below are advisory and were not pushed.

Reviewed the checked-out PR artifacts, which identify the workspace as PR #139 despite the prompt saying #138.

Changed in the workspace:

  • Updated package-lock.json to match the Agent Relay 8.3.0 dependency bump.
  • Addressed Cubic’s headless attach finding in src/main/broker.ts: runtime tracking is session-scoped and learned from listAgents, with a regression in src/main/broker.test.ts.
  • Addressed Cubic’s renderer findings:
    • agent-store.ts now validates event.runtime before storing it.
    • TerminalPane.tsx now lets opacity fade before hiding inactive panes.

Verification passed:

  • npm run build
  • npm test - 88 tests
  • npx vitest run src/main/broker.test.ts - 35 tests

I did not print READY because GitHub reports PR #139 as mergeable_state: unstable, and I cannot verify all required checks are complete and passing from the available status data.

@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Jun 7, 2026

Your free trial PR review limit of 300 PRs has been reached. Please upgrade your plan to continue using CodeAnt AI.

@agent-relay-code
Copy link
Copy Markdown
Contributor

pr-reviewer applied fixes — committed and pushed 6837735 to this PR. The notes below describe what changed.

Reviewed and fixed one PR issue: src/main/burn-spawn-hook.ts was classifying grok as a known RelayBurn harness, but the installed @relayburn/sdk PendingStampHarness type does not accept grok. I removed that classification so Grok spawns stay on the existing fallback path instead of producing SDK-invalid burn pending stamps.

Validation run:

  • node --experimental-strip-types --no-warnings --test src/main/__tests__/burn-spawn-hook.test.ts passed
  • npm test passed, 88 tests
  • npm run build passed
  • npm run verify:mcp-resources-drift passed
  • npx tsc --build --pretty false still has unrelated existing repo type-check failures, but the Grok/PendingStampHarness errors are gone after the fix

I did not verify remote CI status, mergeability, or GitHub review state from here.

@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Jun 7, 2026

Your free trial PR review limit of 300 PRs has been reached. Please upgrade your plan to continue using CodeAnt AI.

@agent-relay-code
Copy link
Copy Markdown
Contributor

Updated the Grok model defaults to documented xAI model IDs:

I validated the burn-stamping review comment against the current checkout and did not change it: @relayburn/sdk still types pending stamp harnesses as only claude | codex | opencode, and inferHarness intentionally leaves grok as unknown so it uses the existing SDK-compatible fallback.

Verification passed locally:

  • npm test passed, 88 tests
  • npm run build passed
  • npm run verify:mcp-resources-drift passed

Remote status data available through the connector only shows CodeRabbit: success; I could not verify complete required CI status or mergeability, so I am not printing READY.

Sources used for model validation: xAI docs for Grok Build 0.1 and Models.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants