Skip to content
Closed
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
2 changes: 2 additions & 0 deletions open-sse/services/antigravityHeaderScrub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ const HEADERS_TO_REMOVE = [
// Encoding: Antigravity (Node.js) sends "gzip, deflate, br" by default;
// Electron clients add "zstd" which is a fingerprint mismatch.
"accept-encoding",
// Google Cloud project header — Antigravity backend throws HTTP 403 when present
"x-goog-user-project",
];

/**
Expand Down
12 changes: 12 additions & 0 deletions tests/unit/antigravity-headers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
getAntigravityLoadCodeAssistMetadata,
getAntigravityOAuthUserAgent,
} from "../../open-sse/services/antigravityHeaders.ts";
import { scrubProxyAndFingerprintHeaders } from "../../open-sse/services/antigravityHeaderScrub.ts";
import {
clearAntigravityVersionCaches,
seedAntigravityCliVersionCache,
Expand Down Expand Up @@ -65,12 +66,23 @@ test("IDE and CLI content headers use independent cached versions", () => {
"x-vscode-sessionid",
"X-Goog-Api-Client",
"Client-Metadata",
"x-goog-user-project",
]) {
assert.equal(headers.get(absent), null, `${absent} must be absent from content headers`);
}
}
});

test("scrubProxyAndFingerprintHeaders strips x-goog-user-project header", () => {
const input = {
"Content-Type": "application/json",
"x-goog-user-project": "my-project-123",
Authorization: "Bearer token",
};
const scrubbed = scrubProxyAndFingerprintHeaders(input);
assert.equal(scrubbed["x-goog-user-project"], undefined);
});

test("IDE Node OAuth and onboarding headers use the captured Google Node identity", () => {
seedAntigravityIdeVersionCache("2.1.1");
const headers = new Headers(getAntigravityIdeNodeHeaders("token"));
Expand Down
28 changes: 28 additions & 0 deletions tests/unit/antigravity-tool-config.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import assert from "node:assert/strict";
import test from "node:test";
import { antigravityToOpenAIRequest } from "../../open-sse/translator/request/antigravity-to-openai.ts";

test("antigravityToOpenAIRequest strips toolConfig from translated tools", () => {
const body = {
request: {
contents: [{ role: "user", parts: [{ text: "Hello" }] }],
tools: [
{
functionDeclarations: [
{
name: "get_weather",
description: "Get weather",
parameters: { type: "OBJECT", properties: { location: { type: "STRING" } } }
}
]
}
],
toolConfig: { functionCallingConfig: { mode: "VALIDATED" } }
}
};

const res = antigravityToOpenAIRequest("gemini-2.5-flash", body, false);
assert.equal(res.toolConfig, undefined);
assert.equal(Array.isArray(res.tools), true);
assert.equal(res.tools?.length, 1);
});