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
6 changes: 6 additions & 0 deletions apps/server/scripts/acp-mock-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ const advertisedAuthMethodId = process.env.T3_ACP_AUTH_METHOD_ID?.trim();
const initializeAuthMethodId =
advertisedAuthMethodId ?? (supportsSessionLifecycle ? "test" : undefined);
const requiresAuthentication = process.env.T3_ACP_REQUIRE_AUTH === "1";
// Antigravity 1.5 answers a signed-out Google `authenticate` by opening the system browser and
// failing once nobody finishes signing in there.
const authenticateSignInTimesOut = process.env.T3_ACP_AUTHENTICATE_SIGN_IN_TIMES_OUT === "1";
const permissionOptionIds = {
allowOnce: "allow-once",
allowAlways: "allow-always",
Expand Down Expand Up @@ -595,6 +598,9 @@ const program = Effect.gen(function* () {
`Mock Antigravity rejected auth method ${request.methodId}.`,
);
}
if (authenticateSignInTimesOut && request.methodId === "oauth-personal") {
return yield* AcpError.AcpRequestError.internalError("Sign-in timed out. Try again.");
}
} else if (advertisedAuthMethodId && request.methodId !== advertisedAuthMethodId) {
return yield* AcpError.AcpRequestError.invalidParams(
`Unknown mock authentication method: ${request.methodId}`,
Expand Down
22 changes: 8 additions & 14 deletions apps/server/src/provider/Drivers/AntigravityDriver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ import * as BackgroundPolicy from "../../background/BackgroundPolicy.ts";
import * as ServerConfig from "../../config.ts";
import * as ServerSettings from "../../serverSettings.ts";
import * as AntigravityInstallation from "../AntigravityInstallation.ts";
import {
ANTIGRAVITY_AUTH_STDOUT_PREFIX,
resolveAntigravityInstanceDirectories,
} from "../antigravityAuthSupport.ts";
import { resolveAntigravityInstanceDirectories } from "../antigravityAuthSupport.ts";
import * as ProviderEventLoggers from "@t3tools/provider-core/server/ProviderEventLoggers";
import * as McpProviderSessions from "@t3tools/provider-core/server/McpProviderSessions";
import * as ModelManifest from "../ModelManifest.ts";
Expand Down Expand Up @@ -98,14 +95,12 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* (
const directory = path.join(root, name);
const executablePath = path.join(directory, "agy");
yield* fs.makeDirectory(directory, { recursive: true });
const authorizationUrl =
"https://accounts.google.com/o/oauth2/v2/auth?response_type=code&redirect_uri=http%3A%2F%2F127.0.0.1%3A51234%2F&state=fixture-state";
yield* fs.writeFileString(
executablePath,
[
"#!/bin/sh",
...(options.loginRequired
? [`printf '%s\\n' ${shellQuote(ANTIGRAVITY_AUTH_STDOUT_PREFIX + authorizationUrl)}`]
? ["export T3_ACP_REQUIRE_AUTH=1", "export T3_ACP_AUTHENTICATE_SIGN_IN_TIMES_OUT=1"]
: []),
...(options.newSessionErrorData === undefined
? []
Expand Down Expand Up @@ -358,17 +353,10 @@ it.layer(layerTest)("AntigravityDriver", (it) => {
const requests = yield* h.readRequests;
expect(requests.map((request) => request.method)).toEqual([
"initialize",
"auth/login",
"session/new",
"initialize",
"auth/login",
"session/new",
]);
expect(
requests
.filter((request) => request.method === "auth/login")
.map((request) => request.params?.methodId),
).toEqual(["oauth-personal", "oauth-personal"]);
expect(
requests
.filter((request) => request.method === "session/new")
Expand Down Expand Up @@ -587,6 +575,12 @@ it.layer(layerTest)("AntigravityDriver", (it) => {
expect(snapshot.supportsTextGeneration).toBe(false);
expect(h.acquisitions).toHaveLength(2);
expect(h.releases).toEqual([h.first.version, h.signedOut.version]);
expect((yield* h.readRequests).map((request) => request.method)).toEqual([
"initialize",
"session/new",
"initialize",
"session/new",
]);
yield* h.assertClosed;
}),
);
Expand Down
10 changes: 8 additions & 2 deletions apps/server/src/provider/acp/AntigravityAcpSupport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,17 @@ export const makeAntigravityAcpRuntime = Effect.fn("makeAntigravityAcpRuntime")(
EffectAcpErrors.AcpError,
SecureRandom.SecureRandom | Scope.Scope
> {
const authMethodId = input.authMethod ?? "oauth-personal";
// The CLI opens the system browser and waits for a signed-out Google `authenticate`. Without a
// caller to show the sign-in, `session/new` reads the stored sign-in or reports it missing.
const backgroundGoogleSession =
authMethodId === "oauth-personal" && input.onAuthorizationUrl === undefined;
const context = yield* Layer.build(
AcpSessionRuntime.layer({
...input,
authMethodId: input.authMethod ?? "oauth-personal",
authenticateEagerly: true,
authMethodId,
authenticateEagerly: !backgroundGoogleSession,
...(backgroundGoogleSession ? { authenticateOnAuthRequired: false } : {}),
resumeMethod: "resume",
cancelBehavior: "wait-for-prompt",
clientInfo: antigravityClientInfo(input.runtimeVersion),
Expand Down
Loading