From 059f2bfe13f219239d6284429a48cbbd030680d3 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Tue, 16 Dec 2025 21:02:38 +0900 Subject: [PATCH] fix(antigravity): fix auth on free plan with random project ID fallback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fix adds CLIProxyAPI-compatible random project ID generation when loadCodeAssist API fails to return a project ID. This allows FREE tier users to use the API without RESOURCE_PROJECT_INVALID errors. Changes: 1. Added generateRandomProjectId() function matching CLIProxyAPI implementation 2. Changed fallback from empty string "" to generateRandomProjectId() 3. Cache all results (not just when projectId exists) 4. Removed unused ANTIGRAVITY_DEFAULT_PROJECT_ID import 🤖 Generated with assistance of OhMyOpenCode (https://github.com/code-yeongyu/oh-my-opencode) --- src/auth/antigravity/project.ts | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/auth/antigravity/project.ts b/src/auth/antigravity/project.ts index 4637fa5..015853e 100644 --- a/src/auth/antigravity/project.ts +++ b/src/auth/antigravity/project.ts @@ -4,7 +4,6 @@ */ import { - ANTIGRAVITY_DEFAULT_PROJECT_ID, ANTIGRAVITY_ENDPOINT_FALLBACKS, ANTIGRAVITY_API_VERSION, ANTIGRAVITY_HEADERS, @@ -14,10 +13,18 @@ import type { AntigravityLoadCodeAssistResponse, } from "./types" -/** - * In-memory cache for project context per access token. - * Prevents redundant API calls for the same token. - */ +// CLIProxyAPI-compatible random project ID generation +// https://github.com/anthropics/anthropic-quickstarts/blob/main/internal/runtime/executor/antigravity_executor.go#L784-L791 +const PROJECT_ID_ADJECTIVES = ["useful", "bright", "swift", "calm", "bold"] as const +const PROJECT_ID_NOUNS = ["fuze", "wave", "spark", "flow", "core"] as const + +function generateRandomProjectId(): string { + const adj = PROJECT_ID_ADJECTIVES[Math.floor(Math.random() * PROJECT_ID_ADJECTIVES.length)] + const noun = PROJECT_ID_NOUNS[Math.floor(Math.random() * PROJECT_ID_NOUNS.length)] + const randomPart = crypto.randomUUID().slice(0, 5).toLowerCase() + return `${adj}-${noun}-${randomPart}` +} + const projectContextCache = new Map() /** @@ -134,12 +141,10 @@ export async function fetchProjectContext( : undefined const result: AntigravityProjectContext = { - cloudaicompanionProject: projectId || "", + cloudaicompanionProject: projectId || generateRandomProjectId(), } - if (projectId) { - projectContextCache.set(accessToken, result) - } + projectContextCache.set(accessToken, result) return result }