From d9a6c37b9e5b4cc35a18b5915f96acb49eaa5f52 Mon Sep 17 00:00:00 2001 From: "yihan6.li" Date: Wed, 25 Nov 2026 13:14:45 +0900 Subject: [PATCH] fix(server): Antigravity 1.5.16 keeps Google sign-ins in profile file storage agy 1.5.16 checks probeDarwinKeychainUnlocked() inside sshDetector.Detect on macOS, so setting SSH_CONNECTION alone no longer bypasses an unlocked login keychain. Set AGY_CLI_FORCE_FILE_TOKEN_STORAGE=1 alongside SSH_CONNECTION for oauth-personal instances and strip ambient values in removedEnvironmentKeys. --- .../provider/antigravityAuthSupport.test.ts | 25 ++++++++++++++----- .../src/provider/antigravityAuthSupport.ts | 11 +++++--- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/apps/server/src/provider/antigravityAuthSupport.test.ts b/apps/server/src/provider/antigravityAuthSupport.test.ts index ca759ef80a72f..0ed22fb63f3d3 100644 --- a/apps/server/src/provider/antigravityAuthSupport.test.ts +++ b/apps/server/src/provider/antigravityAuthSupport.test.ts @@ -72,6 +72,7 @@ describe("Antigravity process environment", () => { GEMINI_HOME: "/shared-gemini-home", gemini_home: "/alias-shared-home", AGY_ACP_FORCE_FILE_STORAGE: "0", + agy_cli_force_file_token_storage: "0", agy_cli_disable_auto_update: "0", BROWSER: "open-real-browser", browser: "another-real-browser", @@ -99,6 +100,7 @@ describe("Antigravity process environment", () => { HOME: "/home/developer", PATH: "/usr/bin", CUSTOM_SETTING: "keep-this", + AGY_CLI_FORCE_FILE_TOKEN_STORAGE: "1", SSH_CONNECTION: "127.0.0.1 0 127.0.0.1 0", GEMINI_HOME: profile.geminiHome, AGY_ACP_FORCE_FILE_STORAGE: "1", @@ -112,7 +114,11 @@ describe("Antigravity process environment", () => { }); it("passes only the configured method's credential and keeps the GCP pair out of the environment", () => { - const baseEnv = { PATH: "/usr/bin", GOOGLE_API_KEY: "ambient-key" }; + const baseEnv = { + PATH: "/usr/bin", + GOOGLE_API_KEY: "ambient-key", + AGY_CLI_FORCE_FILE_TOKEN_STORAGE: "1", + }; const spawnFor = (auth: AntigravityAuthConfig) => buildAntigravityAcpSpawnInput({ installation: { executablePath: "/usr/bin/agy" }, @@ -151,11 +157,18 @@ describe("Antigravity process environment", () => { expect(business.GOOGLE_API_KEY).toBeUndefined(); // Only the Google account method has the `--login` sign-in that works without the keyring. - for (const env of [geminiKey, vertexKey, business]) expect(env.SSH_CONNECTION).toBeUndefined(); - expect( - spawnFor({ authMethod: "oauth-personal", apiKey: "", gcpProject: "", gcpLocation: "" }) - .SSH_CONNECTION, - ).toBe("127.0.0.1 0 127.0.0.1 0"); + for (const env of [geminiKey, vertexKey, business]) { + expect(env.SSH_CONNECTION).toBeUndefined(); + expect(env.AGY_CLI_FORCE_FILE_TOKEN_STORAGE).toBeUndefined(); + } + const personal = spawnFor({ + authMethod: "oauth-personal", + apiKey: "", + gcpProject: "", + gcpLocation: "", + }); + expect(personal.SSH_CONNECTION).toBe("127.0.0.1 0 127.0.0.1 0"); + expect(personal.AGY_CLI_FORCE_FILE_TOKEN_STORAGE).toBe("1"); }); it("isolates TEMP and TMP to the profile directory on Windows", () => { diff --git a/apps/server/src/provider/antigravityAuthSupport.ts b/apps/server/src/provider/antigravityAuthSupport.ts index 8edd875839773..e62c75d9790e5 100644 --- a/apps/server/src/provider/antigravityAuthSupport.ts +++ b/apps/server/src/provider/antigravityAuthSupport.ts @@ -73,6 +73,7 @@ const removedEnvironmentKeys = new Set([ "AGY_ACP_ENABLE_OAUTH", "GEMINI_HOME", "AGY_ACP_FORCE_FILE_STORAGE", + "AGY_CLI_FORCE_FILE_TOKEN_STORAGE", "AGY_CLI_DISABLE_AUTO_UPDATE", "BROWSER", "PYTHONUNBUFFERED", @@ -227,10 +228,14 @@ function antigravityEnvironment( baseEnv.SSL_CERT_DIR === undefined ? { SSL_CERT_FILE: profile.caBundlePath } : {}), - // The 1.5 CLI ignores AGY_ACP_FORCE_FILE_STORAGE and keeps Google sign-ins in one OS keyring - // entry for every profile, unless it believes it runs over SSH. Sign-in then uses `--login`. + // The 1.5 CLI ignores AGY_ACP_FORCE_FILE_STORAGE: 1.5.16+ honors + // AGY_CLI_FORCE_FILE_TOKEN_STORAGE (and no longer bypasses an unlocked macOS keychain on SSH), + // while earlier 1.5.x builds still rely on SSH_CONNECTION. Sign-in then uses `--login`. ...(auth.authMethod === "oauth-personal" - ? { SSH_CONNECTION: baseEnv.SSH_CONNECTION || "127.0.0.1 0 127.0.0.1 0" } + ? { + AGY_CLI_FORCE_FILE_TOKEN_STORAGE: "1", + SSH_CONNECTION: baseEnv.SSH_CONNECTION || "127.0.0.1 0 127.0.0.1 0", + } : {}), GEMINI_HOME: profile.geminiHome, AGY_ACP_FORCE_FILE_STORAGE: "1",