Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/constants.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
6 changes: 4 additions & 2 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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<string, string> = {
// 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",
Expand Down
25 changes: 25 additions & 0 deletions src/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)", () => {
Expand Down
12 changes: 11 additions & 1 deletion src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 = (
Expand Down
16 changes: 16 additions & 0 deletions src/plugin/request.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,22 @@ it("removes x-api-key header", () => {
expect(result.streaming).toBe(false);
});

it("uses the CLI requestId shape agent/<conversation>/<ms>/<turn>/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",
Expand Down
5 changes: 4 additions & 1 deletion src/plugin/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/<conversation>/<turn-ms>/<turn>/1`.
// The backend accepts the older `agent-<uuid>`, 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
Expand Down