From f5734ede739893a897fae035259c7e4cfd5df5dc Mon Sep 17 00:00:00 2001 From: JoshRob <99092299+JoshRob297@users.noreply.github.com> Date: Fri, 27 Nov 2026 11:01:09 -0600 Subject: [PATCH] fix(client): adopt the agy 1.5.18 signature and its request id shape agy 1.5.18 reports cl=1030252320; the plugin was still emitting the 1.5.17 pair because unknown versions are (correctly) ignored. Add the pair to the same table the version comes from. Also align the body with what the CLI sends today: - requestId uses agent////1 instead of agent- - broaden the ToS suspension patterns to the account-disabled wordings, while keeping project-level IAM denials retryable - log any 403 that matches nothing so a new wording is diagnosable without a proxy capture --- src/constants.test.ts | 13 +++++++++++++ src/constants.ts | 6 ++++-- src/plugin.test.ts | 25 +++++++++++++++++++++++++ src/plugin.ts | 12 +++++++++++- src/plugin/request.test.ts | 16 ++++++++++++++++ src/plugin/request.ts | 5 ++++- 6 files changed, 73 insertions(+), 4 deletions(-) diff --git a/src/constants.test.ts b/src/constants.test.ts index 503a863..a7596cc 100644 --- a/src/constants.test.ts +++ b/src/constants.test.ts @@ -5,9 +5,22 @@ import { ANTIGRAVITY_ENDPOINT_DAILY, ANTIGRAVITY_ENDPOINT_FALLBACKS, ANTIGRAVITY_ENDPOINT_PROD, + ANTIGRAVITY_CLI_VERSION_FALLBACK, + getAntigravityCliUserAgent, + getAntigravityCliBuild, type HeaderSet, } from "./constants.ts"; +describe("CLI client signature", () => { + it("ships the version and build id agy 1.5.18 reports", () => { + expect(ANTIGRAVITY_CLI_VERSION_FALLBACK).toBe("1.5.18"); + expect(getAntigravityCliBuild()).toBe("1030252320"); + expect(getAntigravityCliUserAgent()).toBe( + "antigravity/cli/1.5.18 (aidev_client; os_type=linux; arch=amd64; cl=1030252320; auth_method=consumer)", + ); + }); +}); + describe("ANTIGRAVITY_ENDPOINT_FALLBACKS", () => { it("tries the daily production host first and leaves the sandbox last", () => { expect(ANTIGRAVITY_ENDPOINT_FALLBACKS[0]).toBe("https://daily-cloudcode-pa.googleapis.com"); diff --git a/src/constants.ts b/src/constants.ts index efcf08e..f0b34dd 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -90,7 +90,7 @@ export function setAntigravityVersion(version: string): void { * signature that the backend requires for Gemini 3.7/3.8 Flash. Kept current by * `initAntigravityCliVersion()`; see docs/ANTIGRAVITY_API_SPEC.md. */ -export const ANTIGRAVITY_CLI_VERSION_FALLBACK = "1.5.17"; +export const ANTIGRAVITY_CLI_VERSION_FALLBACK = "1.5.18"; /** * Build id (`cl`) reported by each CLI version in its client signature. @@ -101,8 +101,10 @@ export const ANTIGRAVITY_CLI_VERSION_FALLBACK = "1.5.17"; * version than the one this plugin was written against. */ const ANTIGRAVITY_CLI_BUILDS: Record = { - // Build id taken from the artifact agy itself downloads: + // Build ids taken from the User-Agent each release sends, and cross-checked + // against the artifact the CLI downloads: // antigravity-cli/1.5.17-4823843970351104/linux-x64/cli_linux_x64.tar.gz + "1.5.18": "1030252320", "1.5.17": "4823843970351104", "1.5.14": "1027820220", "1.5.8": "962369648", diff --git a/src/plugin.test.ts b/src/plugin.test.ts index 9322727..40c8aff 100644 --- a/src/plugin.test.ts +++ b/src/plugin.test.ts @@ -284,6 +284,31 @@ describe("extractToSSuspensionReason", () => { const body = JSON.stringify({ error: { code: 429, message: "Individual quota reached" } }); expect(extractToSSuspensionReason(body)).toBeUndefined(); }); + + it("recognizes the account-disabled wording Google has also used", () => { + const body = JSON.stringify({ + error: { + code: 403, + message: "Your account has been suspended. Contact support.", + status: "PERMISSION_DENIED", + }, + }); + + const reason = extractToSSuspensionReason(body); + expect(reason).toContain("account has been suspended"); + }); + + it("does not treat a project-level IAM denial as a suspension", () => { + const body = JSON.stringify({ + error: { + code: 403, + message: "Permission 'cloudaicompanion.instances.completeTask' denied on resource 'projects/rising-fact-p41fc'.", + status: "PERMISSION_DENIED", + }, + }); + + expect(extractToSSuspensionReason(body)).toBeUndefined(); + }); }); describe("verifyAccountAccess (3.3)", () => { diff --git a/src/plugin.ts b/src/plugin.ts index b31eee2..74d2536 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -462,8 +462,12 @@ export function extractToSSuspensionReason(bodyText: string): string | undefined .split("\n") .map((line) => line.trim()) .find((line) => + // Wording seen in production 2026-11-25. /violation of terms of service/i.test(line) || - /service has been disabled in this account/i.test(line), + /service has been disabled in this account/i.test(line) || + // Account-level variants Google has used for the same block. + /(?:account|access)\s+(?:has been|is|was)\s+(?:disabled|suspended)/i.test(line) || + /(?:disabled|suspended)\s+(?:this|the)\s+account/i.test(line), ); if (!match) { return undefined; @@ -2467,6 +2471,12 @@ export const createAntigravityPlugin = (providerId: string) => async ( shouldSwitchAccount = true; break; } + + // Nothing matched: keep the previous retry behaviour, but leave + // the body in the debug log so a new wording is diagnosable + // without a proxy capture. + const bodyPreview = errorBodyText.replace(/\s+/g, " ").slice(0, 200); + pushDebug(`unrecognized-403: ${bodyPreview}`); } const shouldRetryEndpoint = ( diff --git a/src/plugin/request.test.ts b/src/plugin/request.test.ts index 278cd71..8805eb5 100644 --- a/src/plugin/request.test.ts +++ b/src/plugin/request.test.ts @@ -768,6 +768,22 @@ it("removes x-api-key header", () => { expect(result.streaming).toBe(false); }); + it("uses the CLI requestId shape agent////1", () => { + const result = prepareAntigravityRequest( + "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:streamGenerateContent?alt=sse", + { method: "POST", body: JSON.stringify({ contents: [{ role: "user", parts: [{ text: "hi" }] }] }) }, + mockAccessToken, + mockProjectId, + undefined, + "antigravity", + ); + + const body = JSON.parse(result.init.body as string); + expect(body.requestId).toMatch( + /^agent\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/\d{13}\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\/1$/, + ); + }); + it("does not add Claude auto-caching to wrapped request by default", () => { const wrappedBody = { project: "my-project", diff --git a/src/plugin/request.ts b/src/plugin/request.ts index a9f4f7e..f9caa99 100644 --- a/src/plugin/request.ts +++ b/src/plugin/request.ts @@ -1771,7 +1771,10 @@ export function prepareAntigravityRequest( if (headerStyle === "antigravity") { wrappedBody.requestType = "agent"; wrappedBody.userAgent = "antigravity"; - wrappedBody.requestId = "agent-" + crypto.randomUUID(); + // Shape the CLI sends: `agent////1`. + // The backend accepts the older `agent-`, but this is the value + // the official client reports on every turn. + wrappedBody.requestId = `agent/${crypto.randomUUID()}/${Date.now()}/${crypto.randomUUID()}/1`; } if (wrappedBody.request && typeof wrappedBody.request === 'object') { // Use stable session ID for signature caching across multi-turn conversations