Skip to content
Open
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
25 changes: 19 additions & 6 deletions apps/server/src/provider/antigravityAuthSupport.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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" },
Expand Down Expand Up @@ -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", () => {
Expand Down
11 changes: 8 additions & 3 deletions apps/server/src/provider/antigravityAuthSupport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
Loading