Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ export interface AntigravityAdapterV2Options {
readonly instanceId: ProviderInstanceId;
readonly selfInvocation: SelfInvocation;
readonly makeRuntime: (
input: Omit<AntigravityAcpRuntimeInput, "spawn" | "childProcessSpawner">,
input: Omit<AntigravityAcpRuntimeInput, "spawn" | "childProcessSpawner"> & {
readonly processEnvironment?: NodeJS.ProcessEnv;
},
) => Effect.Effect<
AcpSessionRuntime.AcpSessionRuntime["Service"],
EffectAcpErrors.AcpError | ProviderSetupError,
Expand Down
44 changes: 44 additions & 0 deletions apps/server/src/provider/Drivers/AntigravityDriver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as NodeServices from "@effect/platform-node/NodeServices";
import { expect, it } from "@effect/vitest";
import {
ANTIGRAVITY_DEFAULT_MODEL,
EnvironmentId,
ProviderInstanceId,
ProviderSessionId,
ThreadId,
Expand Down Expand Up @@ -142,6 +143,8 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* (
credentialKeys: ReadonlyArray<string>;
geminiApiKey: string | undefined;
tempDirectory: string | undefined;
acpMcpNode: string | undefined;
threadId: string | undefined;
handle: ChildProcessSpawner.ChildProcessHandle;
}> = [];

Expand Down Expand Up @@ -200,6 +203,8 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* (
geminiApiKey: env("GEMINI_API_KEY"),
tempDirectory:
environment.ANTIGRAVITY_HARNESS_PATH === undefined ? undefined : env("TMPDIR"),
acpMcpNode: env("T3_ACP_MCP_NODE"),
threadId: env("T3CODE_THREAD_ID"),
handle,
});
return handle;
Expand All @@ -214,6 +219,7 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* (
{ name: "PATH", value: instancePath },
{ name: "T3_ACP_ANTIGRAVITY", value: "1" },
{ name: "T3_ACP_REQUEST_LOG_PATH", value: requestLog },
{ name: "T3_ACP_MCP_HTTP", value: "1" },
{ name: "GEMINI_API_KEY", value: "must-not-be-used" },
{ name: "google_api_key", value: "must-not-be-used" },
{ name: "GOOGLE_APPLICATION_CREDENTIALS", value: "/must-not-be-used.json" },
Expand Down Expand Up @@ -447,6 +453,44 @@ it.layer(layerTest)("AntigravityDriver", (it) => {
}),
);

it.effect.skipIf(windowsHost)(
"gives the agent process the ACP MCP terminal fallback environment",
() =>
Effect.gen(function* () {
const h = yield* makeHarness();
yield* h.refresh();
const workspace = yield* h.fs.makeTempDirectoryScoped({ prefix: "t3-ag-mcp-env-" });
const threadId = ThreadId.make("thread-antigravity-mcp-env");
yield* (yield* McpProviderSessions.McpProviderSessions).set({
environmentId: EnvironmentId.make("environment-antigravity-mcp"),
threadId,
providerSessionId: "mcp-session-antigravity",
providerInstanceId: h.instance.instanceId,
endpoint: "http://127.0.0.1:43123/mcp",
authorizationHeader: "Bearer secret-antigravity-token",
browserToolsAvailable: false,
});
const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
runtimeMode: "approval-required",
interactionMode: "default",
cwd: workspace,
});
const modelSelection = { instanceId: h.instance.instanceId, model: "gemini-test-low" };
const session = yield* h.instance.orchestrationAdapter.openSession({
threadId,
providerSessionId: ProviderSessionId.make("provider-session-antigravity-mcp-env"),
modelSelection,
runtimePolicy,
});
yield* session.ensureThread({ threadId, modelSelection, runtimePolicy });

// Antigravity runs shell commands itself (`terminal: false`), so they inherit this env.
const launch = h.launches.at(-1);
expect(launch?.threadId).toBe(threadId);
expect(launch?.acpMcpNode).toBeTruthy();
}),
);

it.effect.skipIf(windowsHost)(
"closes refresh processes and clears account metadata when Google sign-in is required",
() =>
Expand Down
11 changes: 7 additions & 4 deletions apps/server/src/provider/Drivers/AntigravityDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,12 @@ export const AntigravityDriver: ProviderDriver<
Effect.map((catalog) => stampIdentity(ModelCatalog.applyModelCatalog(draft, catalog))),
);

const makeRuntime = Effect.fn("AntigravityDriver.makeRuntime")(function* (
input: Omit<AntigravityAcpRuntimeInput, "spawn" | "childProcessSpawner">,
): Effect.fn.Return<
const makeRuntime = Effect.fn("AntigravityDriver.makeRuntime")(function* ({
processEnvironment: sessionEnvironment,
...input
}: Omit<AntigravityAcpRuntimeInput, "spawn" | "childProcessSpawner"> & {
readonly processEnvironment?: NodeJS.ProcessEnv;
}): Effect.fn.Return<
AcpSessionRuntime.AcpSessionRuntime["Service"],
AcpErrors.AcpError | ProviderSetupError,
Scope.Scope
Expand Down Expand Up @@ -276,7 +279,7 @@ export const AntigravityDriver: ProviderDriver<
installation: executable,
profile,
cwd: input.cwd,
baseEnv: processEnvironment,
baseEnv: { ...processEnvironment, ...sessionEnvironment },
auth,
runtimeTempDirectory,
}),
Expand Down
Loading