feat: expose Grok native Always Approve for ACP sessions#2177
Conversation
Grok ACP does not advertise permission modes, so catalog sessions had no Ask / Always Approve picker and blocked on every tool permission card. Wire Paseo modes to Grok's documented controls: launch with `grok agent --always-approve stdio` when Always Approve is selected, toggle via `/always-approve on|off` mid-session, and keep a client-side auto-approve fallback if Grok still emits request_permission. Closes getpaseo#2053
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bc509cd0ae
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| command: [string, ...string[]], | ||
| config: AgentSessionConfig, | ||
| ): [string, ...string[]] { | ||
| return withGrokAlwaysApproveLaunchFlag(command, config.modeId === GROK_ALWAYS_APPROVE_MODE_ID); |
There was a problem hiding this comment.
Preserve explicit Grok approval flags when no mode is set
When modeId is undefined, this passes false and withGrokAlwaysApproveLaunchFlag removes any --always-approve/--yolo that the user already put in the configured command. AgentSessionConfig.modeId is optional, so existing Grok ACP configs such as command: ["grok", "agent", "--always-approve", "stdio"] can now launch as plain grok agent stdio whenever the caller does not explicitly request a mode, causing sessions that previously ran unattended to block on approval prompts. Only strip the flag for an explicit Ask mode, or infer Always Approve from the configured command when no mode was supplied.
Useful? React with 👍 / 👎.
|
| Filename | Overview |
|---|---|
| packages/server/src/server/agent/providers/grok-acp-agent.ts | New file: introduces GrokACPAgentClient, GROK_MODES, resolveGrokSessionCommand, transformGrokSessionResponse, and writeGrokProviderMode — all wiring Paseo permission modes to Grok's native --always-approve / /always-approve controls. Core logic is correct; one edge case in writeGrokProviderMode where ask transitions from non-always-approve states are handled silently. |
| packages/server/src/server/agent/providers/acp-agent.ts | Adds autoApproveModeIds, resolveSessionCommand, and updated sessionResponseTransformer signature; wires all three through ACPAgentClient and ACPAgentSession. The auto-approve fallback in requestPermission has a silent-cancel path (no allow option) that bypasses the permission UI without surfacing feedback to the user. |
| packages/server/src/server/agent/provider-registry.ts | Adds isGrok branch to inject GROK_MODES and route to GrokACPAgentClient for derived providers; imports GROK_ASK_MODE_ID and GROK_MODES from grok-acp-agent.ts so mode definitions stay in one place. |
| packages/server/src/server/agent/providers/generic-acp-agent.ts | Exposes defaultModes, sessionResponseTransformer, resolveSessionCommand, providerModeWriter, beforeModeWriter, and autoApproveModeIds in GenericACPAgentClientOptions and passes them through to ACPAgentClient — a clean passthrough extension. |
| packages/server/src/server/agent/providers/grok-acp-agent.test.ts | New test file with 12 tests covering GROK_MODES shape, withGrokAlwaysApproveLaunchFlag, resolveGrokSessionCommand, transformGrokSessionResponse, deriveModesFromACP integration, writeGrokProviderMode, and the auto-approve fallback. writeGrokProviderMode tests use a recording connection (observable state). Last two integration tests use asInternals to seed sessionId/currentMode private fields. |
| packages/server/src/server/agent/providers/acp-agent.test.ts | Adds two tests for the new attachFallbackModeMetadata path in deriveModesFromACP — verifying icon/colorTier/isUnattended re-attachment by mode ID from fallbackModes. |
Reviews (3): Last reviewed commit: "fix: type GROK_MODES as AgentProviderMod..." | Re-trigger Greptile
GROK_MODES is now the single source for labels, icons, color tiers, and isUnattended. The provider registry reuses that list instead of inlining a duplicate. deriveModesFromACP re-attaches fallback metadata after ACP mode derivation so Always Approve stays unattended for create-config inheritance.
Registry definition.modes requires required icon/colorTier fields. Type the shared Grok mode list as AgentProviderModeDefinition[] so the single-source list typechecks for both registry and session defaultModes.
Summary
grok agent stdio) never advertised permission modes, so Paseo showed no Ask / Always Approve picker and every gated tool call blocked on Accept/Deny.grok agent --always-approve stdio/always-approve on|offrequest_permissionauto-approve fallback for races / older Grok builds~/.grok/config.toml(that is a user-global default, not a per-session control).Closes #2053
Why this shape
Grok ACP
session/newreturnsmodes: null. Permission behavior is controlled by process/session settings (--always-approve,/always-approve, or global config), not ACPsetSessionMode. Verified locally: with ask config,session/request_permissionfires; with--always-approveor/always-approve on, it does not.Security note
Always Approve is marked
isUnattended/ dangerous. It auto-approves potentially destructive shell and file operations for that session only.Test plan
npx vitest run packages/server/src/server/agent/providers/grok-acp-agent.test.ts --bail=1(12/12)