ai-devkit
ai-devkit copied to clipboard
feat(capacity): integrate Antigravity (agy) subscription quota tracking
Summary
Integrate Antigravity (agy) subscription quota tracking into ai-devkit capacity (and @ai-devkit/agent-manager) so users can view Antigravity usage windows alongside existing providers (codex, claude, devin, openai, anthropic, zai).
Technical Background
1. Primary Method — Modern agy CLI (v1.2.2+ / >= 1.1.11) Non-Interactive JSON Print Mode
agy 1.2.2+ gates its local HTTPS server behind an unexposed CSRF token (401 missing CSRF token), so quota retrieval delegates directly to agy's non-interactive usage report (introduced in agy 1.1.11):
agy -p /usage --output-format json --print-timeout 90s
- Version check: Run
agy --version(cacheable by binary path/mtime/size/inode) to verify>= 1.1.11before running print mode. - Process & environment safeguards:
- Set
AGY_CLI_DISABLE_AUTO_UPDATE=true(must be lowercase literaltrue;1is ignored) so passive probes do not trigger auto-updates. - Run in a private
0700temp directory with a bounded timeout (90s) and output cap (1 MiB), reaping descendant processes on completion, timeout, or cancellation. - Prepend failing
openandxdg-openstubs toPATHand setBROWSERto the stub so silent auth failures cannot unexpectedly launch browser OAuth tabs.
- Set
- Response schema (snake_case JSON):
- Expect
status == "SUCCESS"andcommand.name == "usage". command.data.groups[]: each group hasdisplay_name/name,description, andbuckets[].- Each bucket has
bucket_id/id,display_name/name,remaining_fraction(orremaining.remaining_fraction),reset_time(ISO-8601 or epoch seconds),description(reset prose),disabled, andwindow(cadence).
- Expect
- Quota model:
- Two primary model families: Gemini Models and Claude and GPT models.
- Each family typically exposes 5-hour (session) and weekly buckets (Starter tiers may expose weekly-only buckets; do not fabricate 5-hour windows when absent).
- Note: print reports do not include account email or plan tier.
- Optional account-scoped execution (macOS):
- Stage OAuth tokens into a temporary
0700HOMEat.gemini/antigravity-cli/antigravity-oauth-token(0600) and setSSH_TTYto forceagy's file-based token storage without touching macOS Keychain or the ambient CLI login, verifying the effective access token via Google'suserinfoendpoint afterward.
- Stage OAuth tokens into a temporary
2. Fallback / Alternative Methods (to evaluate during design)
- Legacy
agyCLI (< 1.2.2) &Antigravity.appLocal HTTPS Server:- Connect/gRPC-Web JSON
POSTtohttps://127.0.0.1:<port>withContent-Type: application/json,Connect-Protocol-Version: 1(plusX-Codeium-Csrf-Tokenfor desktop app/IDE; omitted for legacyagy):- Primary:
POST /exa.language_server_pb.LanguageServerService/RetrieveUserQuotaSummary({"forceRefresh": true}) - Fallback 1 (and identity):
POST /exa.language_server_pb.LanguageServerService/GetUserStatus - Fallback 2:
POST /exa.language_server_pb.LanguageServerService/GetCommandModelConfigs- Fallback body:
{"metadata": {"ideName": "antigravity", "extensionName": "antigravity", "ideVersion": "unknown", "locale": "en"}}
- Fallback body:
- Primary:
- Connect/gRPC-Web JSON
- Remote Google OAuth API (Cloud Code):
POSTwithAuthorization: Bearer <accessToken>,Content-Type: application/json, andUser-Agent: antigravity/hub/2.9.1 <darwin|linux>/<arm64|amd64>:POST https://cloudcode-pa.googleapis.com/v1internal:loadCodeAssist(resolve tier/plan & project ID;onboardUserif needed)POST https://daily-cloudcode-pa.googleapis.com/v1internal:retrieveUserQuotaSummary({"project": "<projectId>"})- Fallbacks:
https://cloudcode-pa.googleapis.com/v1internal:fetchAvailableModelsandhttps://cloudcode-pa.googleapis.com/v1internal:retrieveUserQuota
Integration Scope in ai-devkit
packages/agent-manager/src/capacity/: Add Antigravity capacity source/provider and exportgetAntigravityCapacityReport(mapping groups/buckets toCapacityReport&CapacityWindow[]).packages/cli/src/commands/capacity.ts&packages/cli/src/commands/capacity/render.ts: Supportantigravity(andagyalias) inai-devkit capacity [providers...]and render multi-family quota windows cleanly in both table and--jsonoutput.
Acceptance Criteria
- [ ]
ai-devkit capacity antigravityandai-devkit capacity agyreport Antigravity subscription quota in table and--jsonmodes. - [ ]
ai-devkit capacity(no args) includes Antigravity and degrades gracefully whenagyis not installed, below1.1.11, or unauthenticated. - [ ] Probe execution enforces
AGY_CLI_DISABLE_AUTO_UPDATE=true, private0700temp cwd, timeout/output caps, descendant process cleanup, and non-interactive browser stubs (open,xdg-open,BROWSER). - [ ] Multi-family buckets (Gemini Models, Claude and GPT models) and both 5-hour + weekly (and weekly-only Starter tier) windows map accurately to
CapacityWindowwithout fabricating absent windows. - [ ] Unit and integration tests cover version detection, JSON parsing, error/auth states, safeguard environment setup, and CLI rendering.