Repository navigation
fix(antigravity): install a PreToolUse status hook without deciding tool permissions - #14701
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (9)
Included review availability: Your plan includes up to 10 reviews per rolling hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe change adds Antigravity 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
|
Acknowledged — #12993 is now closed in favor of this PR. The installer-only diagnosis was right; |
…ool permissions Antigravity is the only supported agent with no pre-tool signal, so its panes show a bare "Working" spinner for the whole tool call instead of the live "Working - <tool>(<input>)" readout every other agent gets. The consumer side already handles it — extractAntigravityToolFields and normalizeAntigravityEvent parse PreToolUse (including the `waiting` state for ask_question/ask_permission) and are covered by tests. Only the installer was missing the event. PreToolUse was installed originally and removed in a480e6b (#2501) because the observational `{}` response violates Antigravity's schema and is read as a deny (#2426). Re-add it with the one documented decision that defers to the user's permission config rather than overriding it: - `ask` — "Prompts the user, but respects 'Always Allow' settings." - `allow` — "Automatically allows the tool execution." (would silently auto-approve every tool call Orca observes) The hooks.json guard for a missing managed script previously drained stdin and printed nothing, which is exactly the #2426 deny. Gate events now emit their response from the guard too, so a swept ~/.orca cannot brick tools on a host whose ~/.gemini/config/hooks.json survives. Fixes #12898
…ject The CLI project enumerates its main-side files explicitly, so the extracted module needs an entry alongside its sibling runtime-home-hook-command.ts.
b486d68 to
cdd3e57
Compare
Review statusState: The permission-gate risk, first — because this hook sits on oneAntigravity's
On the decision value. Orca answers What the review loop established otherwise. Antigravity is the only supported agent with no "a tool just started" signal, so its panes show a bare spinner instead of "Working — Read(src/app.ts)". The consumer side was already fully implemented and tested — On declining the identity registry: the reasoning holds on inspection. The recent runtime work (#14634 Cline, #14647 Qwen, #14675 Trae) migrated runtimes onto the declared identity registry because those runtimes were invisible to title-detection vocabulary. Antigravity already has a dedicated Validation — what was and was not doneNot done, and this is the headline gap: there is no live run and no before/after. The Antigravity CLI is not installed on the machine and is not distributed on npm ( The body also flags the right thing for a reviewer who does have Done: 220 passed / 3 skipped (pre-existing win32-only skips) across the antigravity, installer, remote-installer, and listener suites, plus a regression sweep over the nine other agents sharing The new tests execute the generated shell rather than string-matching it: running the installed Platforms: macOS only. Windows wrappers are covered by the Known limits a reviewer should read
SupersededSupersedes #12993 (@innocarpe) — verified CLOSED, so the claim holds. It shares the correct diagnosis and much of the installer structure (credit noted in the body for identifying that only the installer was missing, and for the Windows wrapper plumbing). It is superseded on two specific points: it returns #2501 is explicitly NOT superseded — verified MERGED (@nwparker). It was the correct fix for the constraint as it stood, and this PR keeps its stale-entry cleanup behaviour intact rather than reverting it. Also not in scope: #13626 / STA-1095 (Kilo status + resume) is the other half of this cluster, a different mechanism, deliberately left out; open PR #13990 covers the resume slice. One incidental refactor: |
…ool permissions (stablyai#14701) * fix(antigravity): install a PreToolUse status hook without deciding tool permissions Antigravity is the only supported agent with no pre-tool signal, so its panes show a bare "Working" spinner for the whole tool call instead of the live "Working - <tool>(<input>)" readout every other agent gets. The consumer side already handles it — extractAntigravityToolFields and normalizeAntigravityEvent parse PreToolUse (including the `waiting` state for ask_question/ask_permission) and are covered by tests. Only the installer was missing the event. PreToolUse was installed originally and removed in a480e6b (stablyai#2501) because the observational `{}` response violates Antigravity's schema and is read as a deny (stablyai#2426). Re-add it with the one documented decision that defers to the user's permission config rather than overriding it: - `ask` — "Prompts the user, but respects 'Always Allow' settings." - `allow` — "Automatically allows the tool execution." (would silently auto-approve every tool call Orca observes) The hooks.json guard for a missing managed script previously drained stdin and printed nothing, which is exactly the stablyai#2426 deny. Gate events now emit their response from the guard too, so a swept ~/.orca cannot brick tools on a host whose ~/.gemini/config/hooks.json survives. Fixes stablyai#12898 * fix(antigravity): list posix-hook-command.ts in the CLI typecheck project The CLI project enumerates its main-side files explicitly, so the extracted module needs an entry alongside its sibling runtime-home-hook-command.ts.
…ool permissions (stablyai#14701) * fix(antigravity): install a PreToolUse status hook without deciding tool permissions Antigravity is the only supported agent with no pre-tool signal, so its panes show a bare "Working" spinner for the whole tool call instead of the live "Working - <tool>(<input>)" readout every other agent gets. The consumer side already handles it — extractAntigravityToolFields and normalizeAntigravityEvent parse PreToolUse (including the `waiting` state for ask_question/ask_permission) and are covered by tests. Only the installer was missing the event. PreToolUse was installed originally and removed in a480e6b (stablyai#2501) because the observational `{}` response violates Antigravity's schema and is read as a deny (stablyai#2426). Re-add it with the one documented decision that defers to the user's permission config rather than overriding it: - `ask` — "Prompts the user, but respects 'Always Allow' settings." - `allow` — "Automatically allows the tool execution." (would silently auto-approve every tool call Orca observes) The hooks.json guard for a missing managed script previously drained stdin and printed nothing, which is exactly the stablyai#2426 deny. Gate events now emit their response from the guard too, so a swept ~/.orca cannot brick tools on a host whose ~/.gemini/config/hooks.json survives. Fixes stablyai#12898 * fix(antigravity): list posix-hook-command.ts in the CLI typecheck project The CLI project enumerates its main-side files explicitly, so the extracted module needs an entry alongside its sibling runtime-home-hook-command.ts.
…ool permissions (stablyai#14701) * fix(antigravity): install a PreToolUse status hook without deciding tool permissions Antigravity is the only supported agent with no pre-tool signal, so its panes show a bare "Working" spinner for the whole tool call instead of the live "Working - <tool>(<input>)" readout every other agent gets. The consumer side already handles it — extractAntigravityToolFields and normalizeAntigravityEvent parse PreToolUse (including the `waiting` state for ask_question/ask_permission) and are covered by tests. Only the installer was missing the event. PreToolUse was installed originally and removed in 9a330ef (stablyai#2501) because the observational `{}` response violates Antigravity's schema and is read as a deny (stablyai#2426). Re-add it with the one documented decision that defers to the user's permission config rather than overriding it: - `ask` — "Prompts the user, but respects 'Always Allow' settings." - `allow` — "Automatically allows the tool execution." (would silently auto-approve every tool call Orca observes) The hooks.json guard for a missing managed script previously drained stdin and printed nothing, which is exactly the stablyai#2426 deny. Gate events now emit their response from the guard too, so a swept ~/.orca cannot brick tools on a host whose ~/.gemini/config/hooks.json survives. Fixes stablyai#12898 * fix(antigravity): list posix-hook-command.ts in the CLI typecheck project The CLI project enumerates its main-side files explicitly, so the extracted module needs an entry alongside its sibling runtime-home-hook-command.ts.
ELI5
Every agent Orca supports shows you which tool it's running right now — "Working — Read(src/app.ts)". Antigravity just shows a spinner, because Orca never installed the hook that reports tool starts. This installs it, while making sure Orca doesn't accidentally become the thing that approves your tool calls.
What Changed
PreToolUsestatus hook for Antigravity (local, Windows wrappers, and SSH remote), which is the only pre-tool signal Antigravity emits.{"decision":"ask"}— the one documented decision that defers to the user's own permission config.~/.orcacan't deny every tool call.wrapPosixHookCommandintoposix-hook-command.ts(theoptionsparameter pushedinstaller-utils.tspastmax-lines; per AGENTS.md a disable is not an option).Why
Antigravity is the only supported agent with no "a tool just started" signal (see the table in #12898). The consumer side is already fully implemented and already tested —
extractAntigravityToolFieldsandnormalizeAntigravityEventparsePreToolUse, including thewaitingstate forask_question/ask_permission. It was simply never fed one. This is an installer-side gap only.Why not the identity-frame registry. The recent runtime work (#14634 Cline, #14647 Qwen, #14675 Trae) migrated runtimes onto the declared identity registry, because those runtimes were invisible to title-detection vocabulary. Antigravity is not an identity problem — it already has a dedicated
/hook/antigravityroute and its own normalizer atagent-hook-listener.ts:3251. Its defect is a missing hook event kind. The registry is the right tool for identity and the wrong tool here.Why
askand notallowPreToolUsewas installed when Antigravity support landed (8afdbea2), then removed the next day ina480e6b7/ #2501 because the observational{}response violates Antigravity's schema and is read as a deny — #2426, "Tool call denied by jsonhook__orca-status_PreToolUse_0_0. Can not do any toolcall." That removal was correct given the constraint. The question is which valid response replaces{}.Per Google's hooks docs,
decisionis required onPreToolUseand has five documented values:allowdenyaskforce_askdeny_unless_prior_grantaskis the only value that hands the decision back to the user's configuration: it consults stored grants rather than forcing a prompt (that'sforce_ask) and rather than granting one (that'sallow).allowwould mean Orca silently auto-approves every tool call it observes — on every platform and on SSH hosts — as a side effect of a status feature. Antigravity's permissions engine defaults unconfiguredcommand/mcp/execute_url/ non-workspace file actions to Ask, soallowwould suppress exactly the prompts a default install relies on.The decision value is orthogonal to the status feature: the hook script posts to
/hook/antigravityregardless of what it echoes.allowbuys nothing for the sidebar and only loosens the gate, so there is no tradeoff to make here.Fail-safe when the script is missing
wrapPosixHookCommand's guard existed so "a stale entry at a missing script becomes a silent no-op." Silence is a no-op forPostToolUse/PreInvocation/Stop— but on thePreToolUsegate it is the #2426 deny. This matters because~/.gemini/config/hooks.jsonlives outside Orca and outlives~/.orca: an Orca uninstall, a re-provisioned SSH home, or dotfile sync leaves the entry pointing at nothing. The guard now emits{"decision":"ask"}for gate events, so the worst case is "no status," never "no tools." Non-gate events keep the byte-identical old guard, and this is covered both ways by tests.Linked Issue
Fixes #12898 (STA-3589)
Superseded / related PRs
{"decision":"allow"}. That auto-approves every tool call Orca observes. The PR replaces the comment that warned about this ("returning allow/ask/deny from PreToolUse would change the user's tool permission policy") with "PreToolUse is the only passive status hook with a required allow response" — which is not accurate:allowis not the only valid response, and it is specifically the one that overrides the user's policy.askis documented as respecting it.a480e6b7was the correct fix for the constraint as it stood, and this PR keeps its stale-entry cleanup behavior intact.Visual Proof
N/A — I could not produce a genuine before/after. The Antigravity CLI is not installed on this machine and is not distributed on npm (
@google/antigravity-cli,@google/antigravity,@antigravity/cliall 404), so I could not A/B the sidebar or empirically confirm the runtime's handling of eachdecisionvalue. The behavior claims above come from Google's published hook and permissions docs, quoted verbatim, plus the existing repo history (#2426 →a480e6b7). #12898's author reports an empirical A/B confirming the sidebar goes live the moment aPreToolUsehook is added and stays static without one.Reviewer with
agyinstalled: the one thing worth confirming on real hardware is that{"decision":"ask"}does not introduce a prompt for a tool the user has already allowed. If it does, that is a strong signal the feature needs an explicit opt-in rather than a different decision value —allowis not the fallback.Testing
pnpm exec vitest run --config config/vitest.config.ts src/main/antigravity src/main/agent-hooks/installer-utils.test.ts src/main/agent-hooks/remote-hook-service-installers.test.ts src/shared/agent-hook-listener.test.ts— 220 passed, 3 skipped (pre-existing win32-only skips).Regression sweep over every other agent that shares
wrapPosixHookCommand(devin, droid, copilot, gemini, cursor, codex, grok, command-code, kimi): 14 files, 93 passed.pnpm exec tsc -p config/tsconfig.node.json --noEmit— clean.oxlintandoxfmton changed files — clean.Non-vacuity proof. Reverted
hook-service.tsandinstaller-utils.tstomainwhile keeping the new tests: 9 of them fail, including both executable-behavior tests. Restored, all green.New tests actually execute the generated shell rather than string-matching it:
antigravity-hook.shwithORCA_ANTIGRAVITY_EVENT=PreToolUseand asserts stdout is exactly{"decision":"ask"}\n, exit 0;~/.orca/agent-hooks, then runs the hooks.json command string and asserts it still answers{"decision":"ask"}(the [Bug]: Can not use antigravity cli in orac (ssh) #2426 belt);allow/deny/force_ask/deny_unless_prior_grant.Platforms: exercised on macOS. Windows and SSH paths are covered by unit tests (Windows wrappers via the
withPlatform('win32')harness; SSH via the fake-SFTP remote installer suite, including the new assertion that the remotePreToolUsecommand carries the fallback). Not exercised against a liveagybinary — see Visual Proof.Review
askoverallow. Orca must not widen a user's tool-permission policy as a side effect of a status feature.askdefers;allowgrants. The fallback path also emitsask, so Orca never grants even when its own script is gone..cmd, and the Windows per-event wrapper all gained the same branch. One asymmetry, stated plainly: on Windows the hooks.json command is the bare wrapper path (required by fix(agent-hooks): drain stdin before hook script early exits so agents never hit EPIPE #8430 — Antigravity spawns it as argv[0], so it can't be anif existlauncher), which means a missing wrapper can't be answered inline the way POSIX can. The wrapper answers the gate when the shared core is missing; nothing can answer when the wrapper itself is gone.installRemotenow goes through the same command builder as local, so the fallback is present remotely too, asserted inremote-hook-service-installers.test.ts.wrapPosixHookCommand's new third parameter is optional and the emitted string is byte-identical for all 11 existing callers (asserted). Existing installs reportpartialuntil reinstall, which is the same migration patha480e6b7used in the opposite direction. Stale pre-a480e6b7PreToolUseentries are replaced, not appended.PostToolUse, and the decision is printed before any network work.What remains open
asksemantics are documented, not empirically confirmed on a liveagy— see Visual Proof.PreToolUsehooks return different decisions is undocumented. Orca now always returns the non-deciding value, so it can never be the hook that loosens a user's own gate, but the precedence itself is unverified.Author