Repository navigation
feat(antigravity): read usage limits via agy usage --json - #493
Open
Satya-Siba-Nayak wants to merge 1 commit into
Open
Satya-Siba-Nayak wants to merge 1 commit into
Satya-Siba-Nayak wants to merge 1 commit into
Conversation
Contributor
|
Thanks for this, and for the thorough tests. Using the official |
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.
Closes #492.
Summary
Replaces dusk bot's direct Google internal API calls (
v1internal:retrieveUserQuotaSummary,v1internal:fetchAvailableModels,v1internal:loadCodeAssist) and manual Google OAuth token refresh for Antigravity plan usage with Google's officialagy usage --jsonsubcommand (Antigravity CLI1.5.22+).Changes
server/drivers/antigravity-usage.ts(new):agy usage --jsonper Antigravity profile in an isolatedusage-homedirectory (HOME/USERPROFILE) becauseagy usageignoresGEMINI_HOMEand reads$HOME/.gemini/antigravity-cli/antigravity-oauth-token.usage-homeunderwithAntigravitySignInGatewithAGY_CLI_FORCE_FILE_TOKEN_STORAGE=1,AGY_ACP_FORCE_FILE_STORAGE=1,AGY_CLI_DISABLE_AUTO_UPDATE=1, andSSH_CONNECTION, strips foreign Google/Antigravity env vars, and uses the per-instance Windows temp directory + sweep (antigravityTempDir/scheduleAntigravityTempSweep).agy >= 1.5.22(returning"Update Antigravity to 1.5.22 or newer to see usage limits."on older versions or when an unknown-version custom binary rejectsusage) instead of falling back tov1internal:*.usage-hometoken copy when the profile has no stored sign-in.server/drivers/antigravity-acp.ts&server/drivers/antigravity-signin.ts:antigravityUsageHome/antigravityUsageTokenPathand clears the staged usage token copy duringremoveAntigravitySignInandlogoutAntigravity.isRemovedAntigravityEnvKeyandresolveLinuxCaBundle.server/plan-usage-parsers.ts:parseAntigravitySummary,parseAntigravityModels,parseAntigravityPlan, andantigravityWeeklyResetswithparseAntigravityCliUsageforagy usage --json(command.data.groups[].buckets[]).reset_time(<= 0) on untouched buckets tonullso unstarted windows are not pruned as expired.server/plan-usage.ts,server/plan-usage-types.ts,server/plan-usage-credentials.ts,server/plan-usage-renewal.ts:AntigravityUsageProbewith a 5-minute per-profile cache on non-refresh reads (ANTIGRAVITY_USAGE_CACHE_MS) so routine polls do not repeatedly unpack the ~1 GB PyInstaller binary on Windows; explicitrefresh: truebypasses the cache.config.clithroughPlanAccountand includes it in cache keys.cloudcode-pa.googleapis.com/daily-cloudcode-pa.googleapis.comv1internal:*calls,renewAntigravityToken,antigravityUserAgent, and Antigravity's embedded OAuth client credentials from plan usage.server/drivers/antigravity-usage.test.ts(real subprocess execution, env scrubbing, token staging, version gate,unexpected argument "usage", stale token cleanup on sign-out, auth/rate-limit/setup/timeout handling).server/plan-usage.test.ts(CLI usage parser, 5-minute cache vs explicit refresh, transient/auth fallback, zerogoogleapis.comHTTP calls) andserver/drivers/antigravity-signin.test.ts(usage token cleanup on sign-out).Trade-offs & Notes
plantier badges (Pro/Ultra/Free) previously came fromv1internal:loadCodeAssist;parseAntigravityCliUsagereadscommand.data.plan/command.data.tierif present and otherwise returnsnullto avoid calling internal APIs.server/drivers/antigravity-account.ts(display email lookup) is intentionally untouched to keep this PR scoped to plan usage limits.Verification
pnpm typecheckpnpm lint(0 warnings, 0 errors)pnpm exec vitest run server/drivers/antigravity-usage.test.ts server/drivers/antigravity-signin.test.ts server/drivers/antigravity-lifecycle.test.ts server/drivers/antigravity.test.ts server/plan-usage.test.ts server/engine-limits.test.ts server/limit-resets.test.ts scripts/testing/file-size-ratchet.test.ts