Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

fix(antigravity): align identity protocol and behavior with official AM

ivan_yakimkincababfe58a8f
diff --git a/open-sse/executors/antigravity.ts b/open-sse/executors/antigravity.ts
index a5ed157cf6..85656098d3 100644
--- a/open-sse/executors/antigravity.ts
+++ b/open-sse/executors/antigravity.ts
@@ -757,10 +757,19 @@ export class AntigravityExecutor extends BaseExecutor {
);
}
+ const getChunkedOrFixedBody = (bodyStr: string) => {
+ if (stream) {
+ return (async function* () {
+ yield new TextEncoder().encode(bodyStr);
+ })();
+ }
+ return bodyStr;
+ };
+
let response = await fetch(url, {
method: "POST",
headers: finalHeaders,
- body: serializedRequest.bodyString,
+ body: getChunkedOrFixedBody(serializedRequest.bodyString),
signal,
});
@@ -771,7 +780,7 @@ export class AntigravityExecutor extends BaseExecutor {
response = await fetch(url, {
method: "POST",
headers: retryHeaders,
- body: serializedRequest.bodyString,
+ body: getChunkedOrFixedBody(serializedRequest.bodyString),
signal,
});
finalHeaders = retryHeaders;
@@ -840,7 +849,7 @@ export class AntigravityExecutor extends BaseExecutor {
const creditsResp = await fetch(url, {
method: "POST",
headers: finalCreditsHeaders,
- body: serializedCreditsRequest.bodyString,
+ body: getChunkedOrFixedBody(serializedCreditsRequest.bodyString),
signal,
});
if (creditsResp.ok || creditsResp.status !== HTTP_STATUS.RATE_LIMITED) {
diff --git a/open-sse/services/antigravityIdentity.ts b/open-sse/services/antigravityIdentity.ts
index a0bb1d902a..e3992eb250 100644
--- a/open-sse/services/antigravityIdentity.ts
+++ b/open-sse/services/antigravityIdentity.ts
@@ -83,18 +83,25 @@ export function getAntigravitySessionId(
);
}
+import os from "node:os";
+
+const STABLE_MACHINE_ID = crypto
+ .createHash("sha256")
+ .update(`omniroute:machine_id:${os.hostname()}`)
+ .digest("hex");
+
+const FORMATTED_MACHINE_ID = [
+ STABLE_MACHINE_ID.slice(0, 8),
+ STABLE_MACHINE_ID.slice(8, 12),
+ STABLE_MACHINE_ID.slice(12, 16),
+ STABLE_MACHINE_ID.slice(16, 20),
+ STABLE_MACHINE_ID.slice(20, 32),
+].join("-");
+
export function deriveAntigravityMachineId(
- credentials?: AntigravityCredentialsLike | null
+ _credentials?: AntigravityCredentialsLike | null
): string {
- const key = getAntigravityAccountKey(credentials) || PROCESS_SESSION_ID;
- const hex = crypto.createHash("sha256").update(`antigravity:${key}`).digest("hex");
- return [
- hex.slice(0, 8),
- hex.slice(8, 12),
- hex.slice(12, 16),
- hex.slice(16, 20),
- hex.slice(20, 32),
- ].join("-");
+ return FORMATTED_MACHINE_ID;
}
export function getAntigravityVscodeSessionId(): string {
diff --git a/open-sse/translator/request/openai-to-gemini.ts b/open-sse/translator/request/openai-to-gemini.ts
index 2f362ddb73..58d0cbdb51 100644
--- a/open-sse/translator/request/openai-to-gemini.ts
+++ b/open-sse/translator/request/openai-to-gemini.ts
@@ -136,6 +136,27 @@ function extractClientThoughtSignature(toolCall: unknown): string | null {
return typeof signature === "string" && signature.length > 0 ? signature : null;
}
+function deepCleanUndefined(value: unknown, depth = 0): void {
+ if (depth > 10 || !value || typeof value !== "object") {
+ return;
+ }
+ if (Array.isArray(value)) {
+ for (const item of value) {
+ deepCleanUndefined(item, depth + 1);
+ }
+ } else {
+ const obj = value as Record<string, unknown>;
+ for (const key of Object.keys(obj)) {
+ const val = obj[key];
+ if (typeof val === "string" && val === "[undefined]") {
+ delete obj[key];
+ } else {
+ deepCleanUndefined(val, depth + 1);
+ }
+ }
+ }
+}
+
function applyAntigravityGenerationDefaults(generationConfig: GeminiGenerationConfig) {
const config = { ...generationConfig };
if (config.topK === undefined) {
@@ -359,8 +380,9 @@ function openaiToGeminiBase(model, body, stream, toolNameOptions: GeminiToolName
...toolNameOptions,
toolNameMap,
});
- if (geminiTools) {
+ if (geminiTools && geminiTools.length > 0) {
result.tools = geminiTools;
+ result.toolConfig = { functionCallingConfig: { mode: "VALIDATED" } };
}
// Convert response_format to Gemini's responseMimeType/responseSchema
@@ -384,6 +406,8 @@ function openaiToGeminiBase(model, body, stream, toolNameOptions: GeminiToolName
result._toolNameMap = changedToolNameMap;
}
+ deepCleanUndefined(result);
+
return result;
}