Repository navigation
Detect agy CLI in Antigravity provider on Windows (#282) - #333
Merged
Merged
Conversation
The Antigravity provider never matched the agy.exe CLI because detect_process_info only matched language_server.exe / *language_server_windows* and required --csrf_token on the command line. agy.exe hosts the same local language server in-process with no CSRF flag, so it could never match and --source cli fell through to the same local-probe log line. - Match agy / agy.exe / antigravity-cli in process discovery (PowerShell query and parse_process_info), reusing the existing listening_ports_for_pid / find_api_port plumbing. - Allow an empty CSRF token for CLI matches: send the quota request without the X-Codeium-Csrf-Token header when the matched process is the agy CLI, and keep requiring the header for the desktop IDE/app server. - Make --source cli actually route to the local probe (it was already the only path, but now the log line reflects the CLI source); --source oauth is surfaced as UnsupportedSource instead of silently probing locally. - Preserve desktop IDE detection (language_server.exe path unchanged); IDE matches are preferred over the tokenless CLI when both run, mirroring upstream process-kind precedence. - Add unit tests for agy.exe process matching, empty CSRF behavior, IDE-vs-CLI precedence, and is_agy_cli_command accept/reject cases. Fixes #282
…g, extract tests Thermo-nuclear review fixes for PR #333: 1. Cache is_agy_cli_command regexes with LazyLock instead of recompiling on every call. Matches the canonical pattern in redactor.rs/curl_capture.rs and the project rs-lazylock rule. 2. Simplify fetch_usage SourceMode logging: the match-on-source-mode with a catch-all arm was redundant branching since auto and cli both resolve to the same local probe. Replaced with a single debug log. 3. Extract the test module to tests.rs, bringing mod.rs from 1033 to 758 lines (under the 1k threshold). Matches the cost_pricing.rs #[path] pattern already used in the codebase.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Antigravity provider on Windows never detected the
agy.exeCLI, even when it was running and listening.detect_process_info()only matched processes named*language_server_windows*/language_server.exe(the desktop IDE's child) and required--csrf_tokenon the command line.agy.exeserves the same local language server in-process with no CSRF flag, so it could never match — and--source cli/oauthstill logged "Fetching Antigravity usage via local probe".This ports the upstream
agyCLI source so quota renders when only the CLI is running.Behavior changes
agy/agy.exe/antigravity-cli(PowerShellGet-CimInstancequery andparse_process_info), reusing the existinglistening_ports_for_pid()/find_api_port()plumbing unchanged.agyCLI, the quota request is sent without theX-Codeium-Csrf-Tokenheader; the desktop IDE/app server keeps requiring it. This matches the reporter's evidence thatagy's quota endpoint answers with no CSRF token.--source clinow routes to the local probe with an accurate log line ("via CLI (agy) probe");--source oauthis surfaced asUnsupportedSourceinstead of silently probing locally (no remote OAuth path is ported yet).language_server.exe/*language_server_windows*matching is unchanged, and IDE matches are preferred over the tokenless CLI when both are running, mirroring upstream's process-kind precedence.How it works
ProcessSourceenum (Ide|Cli) onProcessInforecords which kind of process was matched.is_agy_cli_command()classifies a command line as theagyCLI (bareagy,agy.exe, orantigravity-cli/antigravity_cli), with a leading path separator so unrelated names likenotantigravity-clidon't match.parse_process_info()returns the first IDE match (CSRF-protected) or, if none, the first CLI match (empty CSRF). The request builder conditionally attaches the CSRF header based onsource.Commands run
Tests added (8)
detects_agy_exe_cli_process_with_empty_csrf— agy.exe with no--csrf_token→source=Cli, empty token.detects_bare_agy_command— bareagyname.detects_antigravity_cli_command—antigravity-clipackage name.ide_match_preferred_over_agy_cli_when_both_running— IDE wins when both run.agy_cli_matches_when_only_cli_running— CLI matches when it's the only match.non_antigravity_process_without_csrf_is_not_matched— unrelated tokenless process rejected.is_agy_cli_command_matches_known_names/is_agy_cli_command_rejects_unrelated_names.Notes
rust/src/providers/antigravity/mod.rs— no cross-provider branching (per AGENTS.md).tracing; no secrets/tokens logged. The CSRF token value is only used to build the header, never logged.--source clirouting, which unblocks quota rendering when anagysession is already open.Fixes #282