From 32d6ed6a5fe14b23d6e608b3e214b28062a362fb Mon Sep 17 00:00:00 2001 From: Type-Delta Date: Tue, 24 Nov 2026 08:29:28 +0700 Subject: [PATCH] feat(antigravity): add compatible Gemini gateway settings --- FORK.md | 10 + .../src/provider/Drivers/AntigravityDriver.ts | 1 + .../provider/antigravityAuthSupport.test.ts | 37 +++ .../src/provider/antigravityAuthSupport.ts | 13 +- .../settings/AddProviderInstanceDialog.tsx | 9 +- .../settings/CompatibleApiGatewaySection.tsx | 229 ++++++++++-------- .../settings/ProviderInstanceCard.tsx | 10 +- docs/user/providers-antigravity.md | 7 + packages/contracts/src/settings.test.ts | 18 ++ packages/contracts/src/settings.ts | 3 + 10 files changed, 229 insertions(+), 108 deletions(-) diff --git a/FORK.md b/FORK.md index 6ae517de06505..23ad99a0e36e0 100644 --- a/FORK.md +++ b/FORK.md @@ -18,6 +18,16 @@ The rules: - When an ID conflicts from merges, renumber the IDs as needed. - A change that does not alter how the fork differs from upstream (formatting, or an edit to this file) needs no entry. +### DL066 — Antigravity Gemini gateway configuration + +Antigravity provider instances can route Gemini API-key sessions through a configured Gemini-compatible gateway. The provider settings editor exposes the gateway URL, and the server passes it as `GOOGLE_GEMINI_BASE_URL` for the instance's ACP process while keeping ambient gateway values out. Antigravity's existing API key field remains the credential source. OAuth and Agent Platform sessions do not receive the Gemini gateway override because the Antigravity CLI only applies it to Gemini API-key authentication. + +**Implementation evidence:** `packages/contracts/src/settings.ts`, `apps/server/src/provider/antigravityAuthSupport.ts`, `apps/server/src/provider/Drivers/AntigravityDriver.ts`, and `apps/web/src/components/settings/{CompatibleApiGatewaySection,ProviderInstanceCard,AddProviderInstanceDialog}.tsx`. + +**Recorded validation:** Antigravity environment, contracts, and gateway UI tests, plus the integrated web provider-settings verification for the Antigravity gateway flow. + +**Last updated:** 2026-11-24 + ### DL001 — Provider startup and artifact safeguards Windows Claude commands are resolved before the Agent SDK starts a session. The resolver follows npm launcher shims to the installed native executable or JavaScript entry point and preserves explicit executable paths. Provider snapshots and DevTools expose sanitized resolver diagnostics; startup provenance identifies installed web artifacts without exposing command output or environment values. diff --git a/apps/server/src/provider/Drivers/AntigravityDriver.ts b/apps/server/src/provider/Drivers/AntigravityDriver.ts index 6ac9efdf35ad6..1c0699090964a 100644 --- a/apps/server/src/provider/Drivers/AntigravityDriver.ts +++ b/apps/server/src/provider/Drivers/AntigravityDriver.ts @@ -288,6 +288,7 @@ export const AntigravityDriver: ProviderDriver< input, ), auth, + apiGateway: settings.apiGateway, runtimeTempDirectory, }), }).pipe(Effect.provideService(SecureRandom.SecureRandom, random)); diff --git a/apps/server/src/provider/antigravityAuthSupport.test.ts b/apps/server/src/provider/antigravityAuthSupport.test.ts index 832f2961d836a..be9755a3a09b0 100644 --- a/apps/server/src/provider/antigravityAuthSupport.test.ts +++ b/apps/server/src/provider/antigravityAuthSupport.test.ts @@ -63,6 +63,7 @@ describe("Antigravity process environment", () => { google_api_key: "case-insensitive-api-key", GOOGLE_CLOUD_PROJECT: "do-not-use-project", GOOGLE_CLOUD_LOCATION: "do-not-use-location", + GOOGLE_GEMINI_BASE_URL: "https://ambient-gateway.invalid", GOOGLE_APPLICATION_CREDENTIALS: "/credentials.json", GOOGLE_CLOUD_QUOTA_PROJECT: "do-not-use-quota-project", GOOGLE_GENAI_USE_VERTEXAI: "true", @@ -109,6 +110,42 @@ describe("Antigravity process environment", () => { }); }); + it("uses the configured Gemini gateway only for Gemini API-key auth", () => { + const build = (auth: AntigravityAuthConfig) => + buildAntigravityAcpSpawnInput({ + installation: { executablePath: "/release/acp", harnessPath: "/release/harness" }, + profile, + cwd: "/project", + baseEnv: { PATH: "/usr/bin", GOOGLE_GEMINI_BASE_URL: "https://ambient.invalid" }, + auth, + apiGateway: { + enabled: true, + baseUrl: " https://proxy.example/v1beta ", + useCodexCatalog: false, + codexImageGeneration: false, + catalogFormat: "auto", + authMode: "bearer", + }, + }).env ?? {}; + + expect( + build({ + authMethod: "gemini-api-key", + apiKey: "proxy-key", + gcpProject: "", + gcpLocation: "", + }).GOOGLE_GEMINI_BASE_URL, + ).toBe("https://proxy.example/v1beta"); + expect( + build({ + authMethod: "oauth-personal", + apiKey: "", + gcpProject: "", + gcpLocation: "", + }).GOOGLE_GEMINI_BASE_URL, + ).toBeUndefined(); + }); + it("runs the agy CLI as `agy acp` without a harness", () => { const spawn = buildAntigravityAcpSpawnInput({ installation: { executablePath: "/usr/bin/agy", harnessPath: null }, diff --git a/apps/server/src/provider/antigravityAuthSupport.ts b/apps/server/src/provider/antigravityAuthSupport.ts index 8d78a504f9fb5..eadc5a630e9fa 100644 --- a/apps/server/src/provider/antigravityAuthSupport.ts +++ b/apps/server/src/provider/antigravityAuthSupport.ts @@ -1,7 +1,11 @@ // @effect-diagnostics-next-line nodeBuiltinImport:off - Effect's symlink has no type argument, and Windows needs a junction to link without elevation. import * as NodeFSP from "node:fs/promises"; -import type { AntigravityAuthMethod, ProviderInstanceId } from "@t3tools/contracts"; +import type { + AntigravityAuthMethod, + ApiGatewaySettings, + ProviderInstanceId, +} from "@t3tools/contracts"; import * as HostProcess from "@t3tools/shared/HostProcess"; import { resolveNodeExecutable, nodeRuntimeUnavailableMessage } from "@t3tools/shared/nodeRuntime"; import * as Digest from "effect/crypto/Digest"; @@ -60,6 +64,7 @@ const browserPreflightUrl = "https://example.invalid/t3-antigravity-browser-pref const removedEnvironmentKeys = new Set([ "GEMINI_API_KEY", + "GOOGLE_GEMINI_BASE_URL", "GOOGLE_API_KEY", "GOOGLE_APPLICATION_CREDENTIALS", "GOOGLE_CLOUD_PROJECT", @@ -197,6 +202,7 @@ function antigravityEnvironment( profile: AntigravityProfile, baseEnv: NodeJS.ProcessEnv, auth: AntigravityAuthConfig, + apiGateway?: ApiGatewaySettings, runtimeTempDirectory?: string, ) { const environment: NodeJS.ProcessEnv = {}; @@ -213,9 +219,12 @@ function antigravityEnvironment( : {}; // Each launch unpacks about 1 GB; use T3-owned temp so the driver can reclaim files after force-kill. const tempDirectory = runtimeTempDirectory ?? profile.tempDirectory; + const gatewayUrl = + auth.authMethod === "gemini-api-key" && apiGateway?.enabled ? apiGateway.baseUrl.trim() : ""; return { ...environment, ...credential, + ...(gatewayUrl ? { GOOGLE_GEMINI_BASE_URL: gatewayUrl } : {}), ...(profile.caBundlePath !== undefined && baseEnv.SSL_CERT_FILE === undefined && baseEnv.SSL_CERT_DIR === undefined @@ -460,6 +469,7 @@ export function buildAntigravityAcpSpawnInput(input: { readonly cwd: string; readonly baseEnv?: NodeJS.ProcessEnv; readonly auth?: AntigravityAuthConfig; + readonly apiGateway?: ApiGatewaySettings; readonly runtimeTempDirectory?: string; }): AcpSessionRuntime.AcpSpawnInput { return { @@ -484,6 +494,7 @@ export function buildAntigravityAcpSpawnInput(input: { input.profile, input.baseEnv ?? process.env, input.auth ?? ANTIGRAVITY_PERSONAL_AUTH, + input.apiGateway, input.runtimeTempDirectory, ), ...(input.installation.harnessPath === null diff --git a/apps/web/src/components/settings/AddProviderInstanceDialog.tsx b/apps/web/src/components/settings/AddProviderInstanceDialog.tsx index 0139e7c590d3f..534e02c51d749 100644 --- a/apps/web/src/components/settings/AddProviderInstanceDialog.tsx +++ b/apps/web/src/components/settings/AddProviderInstanceDialog.tsx @@ -236,7 +236,8 @@ export function AddProviderInstanceDialog({ const driverSettingsFields = deriveProviderSettingsFields(driverOption); const supportsApiGateway = driver === ProviderDriverKind.make("codex") || - driver === ProviderDriverKind.make("claudeAgent"); + driver === ProviderDriverKind.make("claudeAgent") || + driver === ProviderDriverKind.make("antigravity"); const instanceIdError = validateInstanceId(instanceId, existingIds); const showInstanceIdError = hasAttemptedSubmit && instanceIdError !== null; const identityStep = 1; @@ -739,6 +740,12 @@ export function AddProviderInstanceDialog({ idPrefix={`add-provider-${driver}`} variant="dialog" showCodexOptions={driver === ProviderDriverKind.make("codex")} + showApiKey={driver !== ProviderDriverKind.make("antigravity")} + protocol={ + driver === ProviderDriverKind.make("antigravity") + ? "gemini" + : "openai-anthropic" + } onChange={setGatewayDraft} /> ) : null} diff --git a/apps/web/src/components/settings/CompatibleApiGatewaySection.tsx b/apps/web/src/components/settings/CompatibleApiGatewaySection.tsx index 45da800ce6a34..d84c639464e49 100644 --- a/apps/web/src/components/settings/CompatibleApiGatewaySection.tsx +++ b/apps/web/src/components/settings/CompatibleApiGatewaySection.tsx @@ -214,6 +214,8 @@ interface CompatibleApiGatewaySectionProps { readonly idPrefix: string; readonly variant: "card" | "dialog"; readonly showCodexOptions?: boolean; + readonly showApiKey?: boolean; + readonly protocol?: "openai-anthropic" | "gemini"; readonly onChange: ( nextConfig: Record, nextEnvironment: ReadonlyArray, @@ -274,6 +276,8 @@ export function CompatibleApiGatewaySection({ idPrefix, variant, showCodexOptions = false, + showApiKey = true, + protocol = "openai-anthropic", onChange, }: CompatibleApiGatewaySectionProps) { const [gateway, setGateway] = useState(() => readApiGatewayDraft(value)); @@ -288,6 +292,7 @@ export function CompatibleApiGatewaySection({ } // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- Migrate legacy keys through the settings change callback. useEffect(() => { + if (!showApiKey) return; const configured = readApiGatewayDraft(value).apiKeyEnvironmentVariable; const fingerprint = `${idPrefix}\0${configured}`; if (gatewayMigrationFingerprint.current === fingerprint) return; @@ -297,7 +302,7 @@ export function CompatibleApiGatewaySection({ // oxlint-disable-next-line react/set-state-in-effect -- The legacy key migration publishes through onChange, which must not run during render. setGateway(readApiGatewayDraft(migrated.config)); onChange(migrated.config, migrated.environment); - }, [environment, idPrefix, onChange, value]); + }, [environment, idPrefix, onChange, showApiKey, value]); const validationErrors = validateApiGatewayDraft(gateway); const publish = (patch: Partial) => { @@ -340,7 +345,9 @@ export function CompatibleApiGatewaySection({
Compatible API gateway

- Let T3 discover models and relay their metadata to this provider. + {protocol === "gemini" + ? "Send Antigravity's Gemini API requests through a compatible endpoint." + : "Let T3 discover models and relay their metadata to this provider."}

publish({ baseUrl })} /> - publish({ catalogUrl })} - /> + {protocol === "gemini" ? null : ( + publish({ catalogUrl })} + /> + )} {showCodexOptions ? ( ) : null} -
- - - -
- -
- -
- {variant === "card" ? ( - + + + +
+ )} + + {showApiKey ? ( +
+ +
+ {variant === "card" ? ( + + ) : ( + commitApiKey(event.target.value)} + type="password" + autoComplete="off" + placeholder="API key" + spellCheck={false} + /> + )} + {hasStoredApiKey ? ( + + ) : null} +
+ + {hasStoredApiKey + ? "Stored as a sensitive value. Enter a new key to replace it." + : "Stored as a sensitive value for this provider instance. Leave empty for no authentication."} +
- - {hasStoredApiKey - ? "Stored as a sensitive value. Enter a new key to replace it." - : "Stored as a sensitive value for this provider instance. Leave empty for no authentication."} - -
+ ) : null} ) : null} diff --git a/apps/web/src/components/settings/ProviderInstanceCard.tsx b/apps/web/src/components/settings/ProviderInstanceCard.tsx index 4716253597a89..a0a929a196321 100644 --- a/apps/web/src/components/settings/ProviderInstanceCard.tsx +++ b/apps/web/src/components/settings/ProviderInstanceCard.tsx @@ -973,9 +973,11 @@ export function ProviderInstanceCard({ const supportsApiGateway = (driverKind === ProviderDriverKind.make("codex") && readCodexSetupMode(instance.config) !== "managed") || - driverKind === ProviderDriverKind.make("claudeAgent"); + driverKind === ProviderDriverKind.make("claudeAgent") || + driverKind === ProviderDriverKind.make("antigravity"); const managedGatewayEnvironmentVariable = instance.environment?.find( (variable) => + driverKind !== ProviderDriverKind.make("antigravity") && apiGateway.apiKeyEnvironmentVariable === API_GATEWAY_API_KEY_ENVIRONMENT_VARIABLE && variable.name === API_GATEWAY_API_KEY_ENVIRONMENT_VARIABLE, ); @@ -1500,6 +1502,12 @@ export function ProviderInstanceCard({ idPrefix={`provider-instance-${instanceId}`} variant="card" showCodexOptions={driverKind === ProviderDriverKind.make("codex")} + showApiKey={driverKind !== ProviderDriverKind.make("antigravity")} + protocol={ + driverKind === ProviderDriverKind.make("antigravity") + ? "gemini" + : "openai-anthropic" + } onChange={updateGateway} /> diff --git a/docs/user/providers-antigravity.md b/docs/user/providers-antigravity.md index 8a284a11e782e..06b4ef5c9d0ce 100644 --- a/docs/user/providers-antigravity.md +++ b/docs/user/providers-antigravity.md @@ -49,6 +49,13 @@ ambient `GEMINI_API_KEY` and Google credential variables do not override them. Changing the method stops the instance's sessions. Sign out before replacing an account. +### Use a Gemini-compatible gateway + +When **Sign-in method** is **Gemini API key**, enable **Compatible API gateway** and enter the +gateway URL. T3 passes that URL to Antigravity as `GOOGLE_GEMINI_BASE_URL` and keeps using the +provider's API key. The gateway must accept Gemini `v1beta` model requests and expose the model +IDs Antigravity sends after it separates the thinking level from the model family. + ## Runtime installation Managed installation supports Apple Silicon and Intel macOS, Linux x64 or ARM64 diff --git a/packages/contracts/src/settings.test.ts b/packages/contracts/src/settings.test.ts index ecaadd73c97cd..0803b6b324718 100644 --- a/packages/contracts/src/settings.test.ts +++ b/packages/contracts/src/settings.test.ts @@ -11,6 +11,7 @@ import { ClientSettingsSchema, ClientSettingsPatch, ClientServerSettingsPatch, + AntigravitySettings, ClaudeSettings, CodexSettings, DEFAULT_SERVER_SETTINGS, @@ -44,6 +45,7 @@ const encodeServerSettings = Schema.encodeSync(ServerSettings); const encodeServerSettingsPatch = Schema.encodeSync(ServerSettingsPatch); const decodeClaudeSettings = Schema.decodeUnknownSync(ClaudeSettings); const decodeCodexSettings = Schema.decodeUnknownSync(CodexSettings); +const decodeAntigravitySettings = Schema.decodeUnknownSync(AntigravitySettings); describe("auto resume on usage limit", () => { it("defaults existing settings to enabled", () => { @@ -75,6 +77,22 @@ it("decodes settings containing retired agent access options", () => { }); describe("provider API gateway model settings", () => { + it("accepts a Gemini gateway on Antigravity settings", () => { + const decoded = decodeAntigravitySettings({ + authMethod: "gemini-api-key", + apiKey: "proxy-key", + apiGateway: { enabled: true, baseUrl: " https://gateway.example/v1beta " }, + }); + + expect(decoded.apiGateway).toEqual({ + enabled: true, + baseUrl: "https://gateway.example/v1beta", + useCodexCatalog: false, + codexImageGeneration: false, + catalogFormat: "auto", + authMode: "bearer", + }); + }); it("keeps gateway configuration and manual model metadata per provider instance", () => { const decoded = decodeCodexSettings({ apiGateway: { diff --git a/packages/contracts/src/settings.ts b/packages/contracts/src/settings.ts index 8991e94bf7021..9a15fe7c1e091 100644 --- a/packages/contracts/src/settings.ts +++ b/packages/contracts/src/settings.ts @@ -991,6 +991,9 @@ export const AntigravitySettings = makeProviderSettingsSchema( Schema.withDecodingDefault(Effect.succeed([])), Schema.annotateKey({ providerSettingsForm: { hidden: true } }), ), + apiGateway: Schema.optionalKey(ApiGatewaySettings).pipe( + Schema.annotateKey({ providerSettingsForm: { hidden: true } }), + ), }, { order: ["authMethod", "apiKey", "gcpProject", "gcpLocation", "binaryPath"] }, );