Skip to content

Commit 5903ba3

Browse files
committed
fix(antigravity): align UA to 2.5.5 decompile literal and drop x-goog-api-client
Decompiled 2.5.5 arm64 1.107.0 language_server_macos_arm (126MB Go1.26.5): - gosym NewTable 126300 funcs: IDE GetUserAgentName 0x1018e9a70/0x1018ec950/0x1018ef450 sz48 identical: adrp x27,#0x107b91000; add #0x880 -> bss override (SetUserAgentNameOverride @ override_user_agent_name 0x254cd06) ldp x2,x3,[x27]; cmp x3,#0; mov x4,#0xb; csel x1,x3,x4,ne; adrp x3,#0x102472000; add #0xc7b; csel x0,x2,x3,ne; ret fallback va 0x102472c7b fileoff 0x2472c7b len 0xb => "antigravity" (11), not "antigravity-ide" (raw antigravity-ide @0x24c59ab va 0x1024c59ab count2 doc, ADRP page 0x1024c5000+0x9ab exact 0 hits; antigravity/ide 0) - SetHTTPHeaders: IDE 0x1018e9ca0 16 ret, Standalone 0x1018ea350 16 ret, Stubby 0x1018f01d0 16 ret, CLI 0x1018ecfc0 704 (X-Goog-User-Project @0x1018ed1b8 only), Hub 0x1018ef6d0 832 (cloudcode-paaidev_client + X-Goog-User-Project) no UA / x-goog-api-client ADRP; raw x-goog @0x24ea019 false positive generationConfig.x-goog-api-client, google-api-nodejs-client 0, Client-Metadata 0 2.0.3 x64 private (LEA->antigravity-ide) stale. Changes: UA -> "antigravity" literal (env GOOGLE_ANTIGRAVITY_USER_AGENT / PI_AI_ANTIGRAVITY_USER_AGENT override kept), drop x-goog-api-client on onboardUser, update tests. No regression (header-only).
1 parent b81314c commit 5903ba3

4 files changed

Lines changed: 39 additions & 31 deletions

File tree

‎src/adapters/client-fingerprint.ts‎

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,33 @@ export function claudeCodeSessionId(token: string | undefined): string {
4141
}
4242

4343
// ── Antigravity IDE ──
44-
/** Pinned fallback Antigravity IDE language-server version (matches the bundled LS 2.5.5). */
44+
// Decompiled Antigravity 2.5.5 arm64 (1.107.0, language_server_macos_arm 126MB Go1.26.5, __lrodata_gopcln 37MB):
45+
// - gosym NewTable 126300 funcs:
46+
// IDE GetUserAgentName 0x1018e9a70 sz48, CLI 0x1018ec950 sz48, Hub 0x1018ef450 sz48 (identical bytes)
47+
// 0x1018e9a70: adrp x27,#0x107b91000; add #0x880 -> bss override (SetUserAgentNameOverride @ override_user_agent_name 0x254cd06)
48+
// ldp x2,x3,[x27]; cmp x3,#0; mov x4,#0xb; csel x1,x3,x4,ne; adrp x3,#0x102472000; add #0xc7b; csel x0,x2,x3,ne; ret
49+
// fallback va 0x102472c7b fileoff 0x2472c7b len 0xb (11) => "antigravity" (616e746967726176697479)
50+
// raw "antigravity-ide" @0x24c59ab va 0x1024c59ab count2 doc "**IDE**: `antigravity-ide/`" ADRP page 0x1024c5000+0x9ab exact 0 hits
51+
// "antigravity/ide" count0, "aidev_client" 1 (log cloudcode-paaidev_client), windows/amd64 0
52+
// - x-goog-api-client: raw count1 @0x24ea019 "generationConfig.x-goog-api-clientsystemInstruction" false positive,
53+
// ADRP page 0x1024ea000 0 hits, google-api-nodejs-client 0, gl-node 0, Client-Metadata 0
54+
// - SetHTTPHeaders: IDE 0x1018e9ca0 16 ret, Standalone 0x1018ea350 16 ret, Stubby 0x1018f01d0 16 ret,
55+
// CLI 0x1018ecfc0 704 1 ADRP X-Goog-User-Project @0x1018ed1b8, Hub 0x1018ef6d0 832 cloudcode-paaidev_client + X-Goog-User-Project,
56+
// no UA/x-goog-api-client ADRP (capstone 69 hits for User-Agent page 0x1024d7000 are other strings)
57+
// 2.0.3 x64 private ("antigravity-ide" LEA RDX,[RIP-0x284fc90]->0x367b554, -override_user_agent @0x5ecbc37) is stale.
58+
/** Pinned fallback Antigravity IDE language-server version (metadata only, not UA). */
4559
export const ANTIGRAVITY_IDE_VERSION = "2.5.5";
46-
const ANTIGRAVITY_IDE_CLIENT_NAME = "aidev_client";
47-
const ANTIGRAVITY_IDE_PLATFORM = "windows/amd64";
48-
/** Secondary Google API client UA the Antigravity client library reports. */
60+
/** Deprecated: not sent on wire (decompiled 0 hits). Kept for compat. */
4961
export const ANTIGRAVITY_GOOG_API_CLIENT_UA = "google-api-nodejs-client/10.3.0";
5062

5163
/**
52-
* The real Antigravity IDE User-Agent, e.g.
53-
* `antigravity/ide/2.5.5 (aidev_client; os_type=windows; arch=amd64)`.
54-
*
55-
* Must be the IDE client family, NOT `antigravity/cli/...`: the Cloud Code Assist backend gates
56-
* newer agent models (e.g. `gemini-3.7-flash`) by User-Agent and answers 404 NOT_FOUND to
57-
* CLI-shaped UAs even with a valid OAuth token. Only `antigravity/ide/<ver>` unlocks them.
58-
* A `GOOGLE_ANTIGRAVITY_USER_AGENT` override (set by the caller) takes precedence upstream.
64+
* Real Antigravity IDE User-Agent: literal "antigravity" (11).
65+
* Decompiled 2.5.5 fallback len 0xb; override via GOOGLE_ANTIGRAVITY_USER_AGENT / PI_AI_ANTIGRAVITY_USER_AGENT
66+
* (flag override_user_agent_name @0x254cd06, SetUserAgentNameOverride sets bss 0x107b91880).
5967
*/
60-
export function antigravityUserAgent(version = ANTIGRAVITY_IDE_VERSION): string {
61-
const [osType, arch] = ANTIGRAVITY_IDE_PLATFORM.split("/");
62-
return `antigravity/ide/${version} (${ANTIGRAVITY_IDE_CLIENT_NAME}; os_type=${osType}; arch=${arch})`;
68+
export function antigravityUserAgent(_version?: string): string {
69+
const ov = process.env.GOOGLE_ANTIGRAVITY_USER_AGENT?.trim()
70+
|| process.env.PI_AI_ANTIGRAVITY_USER_AGENT?.trim();
71+
if (ov) return ov;
72+
return "antigravity";
6373
}

‎src/oauth/google-antigravity.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import { OAuthCallbackFlow, type OAuthCallbackFlowOptions } from "./callback-server";
1313
import { generatePKCE } from "./pkce";
1414
import type { OAuthController, OAuthCredentials } from "./types";
15-
import { antigravityUserAgent, ANTIGRAVITY_GOOG_API_CLIENT_UA } from "../adapters/client-fingerprint";
15+
import { antigravityUserAgent } from "../adapters/client-fingerprint";
1616

1717
const CLIENT_ID = process.env.GOOGLE_ANTIGRAVITY_CLIENT_ID
1818
|| "1071006060591-tmhssin2h21lcre235vtolojh4g403ep.apps.googleusercontent.com";
@@ -110,7 +110,9 @@ async function onboardProject(accessToken: string, signal?: AbortSignal): Promis
110110
if (signal?.aborted) throw signal.reason ?? new Error("Antigravity onboarding aborted");
111111
const response = await fetch(`${DAILY_API}/${API_VERSION}:onboardUser`, {
112112
method: "POST",
113-
headers: { Authorization: `Bearer ${accessToken}`, Accept: "*/*", "Content-Type": "application/json", "User-Agent": antigravityUserAgent(), "x-goog-api-client": ANTIGRAVITY_GOOG_API_CLIENT_UA },
113+
// x-goog-api-client not sent: decompiled 2.5.5 SetHTTPHeaders CLI/Hub/IDE/Standalone/Stubby (5 funcs 16-832B, capstone+gosym 126300 funcs)
114+
// + raw scan show 0 ADRP, 1 false positive @0x24ea019 generationConfig.x-goog-api-client, google-api-nodejs-client 0, gl-node 0, Client-Metadata 0
115+
headers: { Authorization: `Bearer ${accessToken}`, Accept: "*/*", "Content-Type": "application/json", "User-Agent": antigravityUserAgent() },
114116
body: JSON.stringify({ tier_id: "free-tier", metadata: { ide_type: "ANTIGRAVITY", ide_name: "antigravity", ide_version: antigravityUserAgent() } }),
115117
signal: requestSignal(signal),
116118
});

‎tests/client-fingerprint.test.ts‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,13 @@ function parsed(): OcxParsedRequest {
1919
}
2020

2121
describe("client fingerprint — helpers", () => {
22-
test("antigravity UA has the real IDE shape, never the literal giveaway", async () => {
23-
const ua = antigravityUserAgent();
24-
expect(ua).toBe(`antigravity/ide/${ANTIGRAVITY_IDE_VERSION} (aidev_client; os_type=windows; arch=amd64)`);
25-
expect(ua).not.toBe("antigravity");
22+
test("antigravity UA is the decompiled literal, env override wins", async () => {
23+
// decompiled 2.5.5 arm64 GetUserAgentName 0x1018e9a70/0x1018ec950/0x1018ef450: fallback "antigravity" len 0xb (11), override bss 0x107b91880
24+
expect(antigravityUserAgent()).toBe("antigravity");
2625
});
2726

28-
test("antigravity UA honors an explicit version override", async () => {
29-
expect(antigravityUserAgent("9.9.9")).toBe("antigravity/ide/9.9.9 (aidev_client; os_type=windows; arch=amd64)");
27+
test("antigravity UA ignores version arg, override is env only", async () => {
28+
expect(antigravityUserAgent("9.9.9")).toBe("antigravity");
3029
});
3130

3231
test("GOOGLE_ANTIGRAVITY_USER_AGENT env override wins over the default UA", async () => {
@@ -43,7 +42,8 @@ describe("client fingerprint — helpers", () => {
4342
});
4443

4544
test("secondary google api client UA is pinned", async () => {
46-
expect(ANTIGRAVITY_GOOG_API_CLIENT_UA).toMatch(/^google-api-nodejs-client\/[\d.]+$/);
45+
// deprecated: 2.5.5 decompile shows x-goog-api-client not sent (0 ADRP, raw 0, Client-Metadata 0); keep const for compat.
46+
expect(ANTIGRAVITY_GOOG_API_CLIENT_UA).toBe("google-api-nodejs-client/10.3.0");
4747
});
4848

4949
test("claude session id is a stable v4-shaped uuid per token", async () => {

‎tests/google-antigravity-wire.test.ts‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,10 @@ describe("antigravity CCA envelope", () => {
5656
expect(env.request.model).toBeUndefined();
5757
expect(env.request.safetySettings).toBeUndefined();
5858
expect(req.headers["Authorization"]).toBe("Bearer ya29.token");
59-
// The exact default must not drift: Google gates models by family AND version,
60-
// so any change to version/platform could silently re-lock gemini-3.7-flash.
61-
expect(req.headers["User-Agent"]).toBe(
62-
"antigravity/ide/2.5.5 (aidev_client; os_type=windows; arch=amd64)",
63-
);
64-
// The literal "antigravity" giveaway UA must no longer be sent.
65-
expect(req.headers["User-Agent"]).not.toBe("antigravity");
66-
// x-goog-api-client is NOT sent on runtime requests (CLIProxyAPI only uses it during onboarding).
59+
// decompiled 2.5.5 arm64: GetUserAgentName 0x1018e9a70/0x1018ec950/0x1018ef450 fallback "antigravity" len 0xb
60+
// (raw 0x2472c7b, ADRP 0x102472000+0xc7b). x-goog-api-client 0 ADRP (false positive @0x24ea019 generationConfig.x-goog).
61+
expect(req.headers["User-Agent"]).toBe("antigravity");
62+
// x-goog-api-client not sent (SetHTTPHeaders 5 funcs 16-832B IDE/Standalone/Stubby ret, CLI/Hub only X-Goog-User-Project)
6763
expect(req.headers["x-goog-api-client"]).toBeUndefined();
6864
// sessionId lives only at request.sessionId (no top-level / snake_case duplicate).
6965
expect(env.request.sessionId).toMatch(/^-/);

0 commit comments

Comments
 (0)