diff --git a/apps/server/scripts/acp-mock-agent.ts b/apps/server/scripts/acp-mock-agent.ts index fe97d392b5d3e..9564129a0b8b5 100644 --- a/apps/server/scripts/acp-mock-agent.ts +++ b/apps/server/scripts/acp-mock-agent.ts @@ -18,7 +18,6 @@ import { beginAcpMockPrompt } from "./acpMockCancellationState.ts"; const requestLogPath = process.env.T3_ACP_REQUEST_LOG_PATH; const antigravityProfile = process.env.T3_ACP_ANTIGRAVITY === "1"; -const harnessFailure = process.env.T3_ACP_ANTIGRAVITY_HARNESS_FAILURE; // GitHub Copilot CLI advertises URL-shaped session mode ids. const copilotModesProfile = process.env.T3_ACP_COPILOT_MODES === "1"; const copilotModeId = (name: string) => @@ -522,16 +521,6 @@ const program = Effect.gen(function* () { }, }); - const writeHarnessFailure = Effect.promise( - () => - new Promise((resolve) => { - process.stderr.write( - "I1022 11:04:37.910207 1865358 local_connection.py:551] harness stderr: Agent run failed: failed to handle call hook response: no pending hook for ID hook_request_2\n", - () => resolve(), - ); - }), - ); - const finishPrompt = ( targetSessionId: string, stopReason: AcpSchema.StopReason, @@ -1055,19 +1044,6 @@ const program = Effect.gen(function* () { ); return {}; } - if ( - harnessFailure === "1" || - harnessFailure === "pending" || - harnessFailure === "after-end-turn" - ) { - if (harnessFailure === "after-end-turn") { - return yield* finishPrompt(requestedSessionId, "end_turn"); - } - yield* writeHarnessFailure; - if (harnessFailure === "pending") return yield* Effect.never; - return yield* finishPrompt(requestedSessionId, "end_turn"); - } - if (clientFsProbePath !== undefined && clientFsProbeLogPath !== undefined) { const probes = [ [ @@ -2210,9 +2186,7 @@ const program = Effect.gen(function* () { typeof params === "object" && params !== null ? Reflect.get(params, "code") : undefined; process.exit(typeof code === "number" ? code : 19); }) - : method === "_test/harness-failure" - ? writeHarnessFailure - : Effect.void, + : Effect.void, ); return yield* Effect.never; diff --git a/apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.ts b/apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.ts index c7b8c6ffaf1b2..9423137bf4601 100644 --- a/apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.ts +++ b/apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.ts @@ -166,156 +166,6 @@ const layerSession = Layer.mergeAll( ), ); -describe("AntigravityAdapterV2 harness recovery", () => { - const recoverHarnessFailure = ( - harnessFailure: "1" | "pending" | "after-end-turn", - firstTurnStatuses: ReadonlyArray<"failed" | "completed">, - ) => { - let terminationCount = 0; - return Effect.gen(function* () { - const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; - const path = yield* Path.Path; - const crypto = yield* SecureRandom.SecureRandom; - const mockAgentPath = yield* path.fromFileUrl( - new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), - ); - const workspace = yield* fileSystem.makeTempDirectoryScoped(); - const requestLogPath = path.join(workspace, "requests.jsonl"); - let processCount = 0; - const firstRuntimeTerminated = yield* Deferred.make(); - let firstRuntime: AcpSessionRuntime.AcpSessionRuntime["Service"] | undefined; - const instanceId = ProviderInstanceId.make("antigravity-recovery-test"); - const adapter = yield* makeAntigravityAdapterV2({ - instanceId, - selfInvocation: yield* resolveSelfInvocation(), - makeRuntime: (input) => - Effect.suspend(() => { - processCount += 1; - const processNumber = processCount; - return makeAntigravityAcpRuntime({ - ...input, - onTermination: (error) => - (input.onTermination?.(error) ?? Effect.void).pipe( - Effect.tap( - Effect.sync(() => { - terminationCount += 1; - }), - ), - Effect.andThen( - processNumber === 1 - ? Deferred.succeed(firstRuntimeTerminated, undefined) - : Effect.void, - ), - ), - childProcessSpawner, - spawn: { - command: process.execPath, - args: [mockAgentPath], - cwd: input.cwd, - env: { - T3_ACP_ANTIGRAVITY: "1", - T3_ACP_REQUEST_LOG_PATH: requestLogPath, - ...(processNumber === 1 - ? { T3_ACP_ANTIGRAVITY_HARNESS_FAILURE: harnessFailure } - : {}), - }, - }, - }).pipe( - Effect.provideService(SecureRandom.SecureRandom, crypto), - Effect.tap((runtime) => - Effect.sync(() => { - if (processNumber === 1) firstRuntime = runtime; - }), - ), - ); - }), - withProcess: (_stop, task) => task, - defaultModel: Effect.undefined, - }); - const threadId = ThreadId.make("thread-antigravity-recovery"); - const modelSelection = { instanceId, model: "gemini-test-low" } as const; - const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({ - runtimeMode: "full-access", - interactionMode: "default", - cwd: workspace, - }); - const session = yield* adapter.openSession({ - threadId, - providerSessionId: ProviderSessionId.make("provider-session-antigravity-recovery"), - modelSelection, - runtimePolicy, - }); - const events = yield* Queue.unbounded(); - yield* session.events.pipe( - Stream.runForEach((event) => Queue.offer(events, event)), - Effect.forkScoped, - ); - const providerThread = yield* session.ensureThread({ - threadId, - modelSelection, - runtimePolicy, - }); - const now = yield* DateTime.now; - const terminal = Stream.fromQueue(events).pipe( - Stream.filter((event) => event.type === "turn.terminal"), - Stream.runHead, - ); - yield* session.startTurn( - makeTurnInput({ threadId, providerThread, instanceId, runtimePolicy, modelSelection, now }), - ); - const first = yield* terminal; - assert.equal(first._tag, "Some"); - if (first._tag === "Some") assert.include(firstTurnStatuses, first.value.status); - if (harnessFailure === "after-end-turn") { - assert.exists(firstRuntime); - yield* firstRuntime!.notify("_test/harness-failure", {}); - } - // The adapter must retire the first process even when end_turn won the race. - yield* Deferred.await(firstRuntimeTerminated); - yield* session.startTurn( - makeTurnInput({ - threadId, - providerThread, - instanceId, - runtimePolicy, - modelSelection, - now, - ordinal: 2, - }), - ); - const completed = yield* terminal; - assert.equal(completed._tag, "Some"); - if (completed._tag === "Some") assert.equal(completed.value.status, "completed"); - assert.equal(processCount, 2); - assert.equal(terminationCount, 1); - const requests = (yield* fileSystem.readFileString(requestLogPath)) - .trim() - .split("\n") - .map((line) => JSON.parse(line) as { method?: string; params?: { sessionId?: string } }); - const resumeRequests = requests.filter((request) => request.method === "session/resume"); - assert.equal(resumeRequests.length, 1); - assert.equal(resumeRequests[0]?.params?.sessionId, "mock-session-1"); - }).pipe( - Effect.provide(layerSession), - Effect.scoped, - Effect.tap(Effect.sync(() => assert.equal(terminationCount, 1))), - ); - }; - - it.live("fails an open turn and resumes its saved session after a harness failure", () => - recoverHarnessFailure("pending", ["failed"]), - ); - - it.live("resumes the saved session after a harness failure races end_turn", () => - recoverHarnessFailure("1", ["failed", "completed"]), - ); - - it.live("resumes in a fresh process when the native failure arrives after end_turn", () => - recoverHarnessFailure("after-end-turn", ["completed"]), - ); -}); - describe("AntigravityAdapterV2 compaction", () => { it.live.each([ { nativeGoals: false, compact: false }, @@ -2029,8 +1879,8 @@ describe("AntigravityAdapterV2 runtime mode ceiling", () => { }); describe("AntigravityAdapterV2 session system prompt", () => { - it.effect.each(["1.4.5", "1.4.1"])( - "carries PR linking once in the %s session setup or once per turn", + it.effect.each(["1.5.0"])( + "carries PR linking once per turn on %s, which does not advertise a system prompt append", (agentVersion) => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; @@ -2148,13 +1998,8 @@ describe("AntigravityAdapterV2 session system prompt", () => { const append = JSON.stringify(sessionNew?.params?._meta ?? null); // Identity stays per turn either way. assert.include(sent, "through the Antigravity harness, as gemini-test-low"); - if (agentVersion === "1.4.5") { - assert.include(append, "pull_request_linking"); - assert.notInclude(sent, ""); - } else { - assert.notInclude(append, "systemPrompt"); - assert.include(sent, ""); - } + assert.notInclude(append, "systemPrompt"); + assert.include(sent, ""); }).pipe(Effect.provide(layerSession)), ); }); diff --git a/apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.ts b/apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.ts index e07e64185d276..7c7c8fd8182aa 100644 --- a/apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.ts +++ b/apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.ts @@ -222,21 +222,12 @@ export function makeAntigravityAcpAdapterFlavor( mcpOverHttp: true, sessionCarriesPullRequestLinking: antigravityAppendsSystemPrompt, makeRuntime, - buildAttachmentPrompt: ({ - text, - attachments, - resolveAttachmentPath, - promptCapabilities, - agentVersion, - currentModel, - }) => + buildAttachmentPrompt: ({ text, attachments, resolveAttachmentPath, promptCapabilities }) => buildAntigravityPrompt({ input: text, attachments, resolveAttachmentPath, promptCapabilities, - agentVersion, - currentModel, }).pipe( Effect.map((blocks) => (text.trim() ? blocks.slice(1) : blocks)), Effect.provideService(FileSystem.FileSystem, options.fileSystem), @@ -297,7 +288,6 @@ export function makeAntigravityAcpAdapterFlavor( requiresSignIn: isAntigravitySignInRequiredError, // Antigravity can leave a prompt open without updates; long tools and approvals pause this. promptInactivityTimeout: "15 minutes", - // 1.4.5 returns the root trajectory's Gemini usageMetadata delta; 1.4.1 returns none. reportsPerTurnPromptUsage: true, geminiPromptUsage: true, ...(profileDirectory === undefined diff --git a/apps/server/src/provider/AntigravityInstallation.test.ts b/apps/server/src/provider/AntigravityInstallation.test.ts index c6d4ec31ac4be..5cd8d029e0340 100644 --- a/apps/server/src/provider/AntigravityInstallation.test.ts +++ b/apps/server/src/provider/AntigravityInstallation.test.ts @@ -1,5 +1,4 @@ import * as NodeCrypto from "@effect/platform-node/NodeCrypto"; -import * as NodePath from "@effect/platform-node/NodePath"; import * as NodeServices from "@effect/platform-node/NodeServices"; import * as Layer from "effect/Layer"; import { expect, it } from "@effect/vitest"; @@ -25,41 +24,24 @@ import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner"; import * as AntigravityInstallation from "./AntigravityInstallation.ts"; import * as ModelManifest from "./ModelManifest.ts"; -import { type AntigravityReleaseAsset } from "./antigravityRelease.ts"; +import { type AntigravityCliReleaseAsset } from "./antigravityCliRelease.ts"; const serverContents = "antigravity runtime\n"; -const harnessContents = "local harness\n"; const previousReleaseId = "1".repeat(64); -const previousVersion = "fixture-old"; +const previousVersion = "1.5.3"; +const assetVersion = "1.5.5"; const encodeJsonString = Schema.encodeSync(Schema.fromJsonString(Schema.Unknown)); - -const zipFixtures = { - complete: - "UEsDBBQAAAAIAAAAIl1zEy/oFAAAABQAAAASAAAAYWd5X2FjcF9zZXJ2ZXIucGFyS8wryUwvSizLLKlUKCoFcnJTuQBQSwMEFAAAAAgAAAAiXV9yAykQAAAADgAAABUAAABsb2NhbGhhcm5lc3NfZXh0ZXJuYWzLyU9OzFHISCzKSy0u5gIAUEsBAhQDFAAAAAgAAAAiXXMTL+gUAAAAFAAAABIAAAAAAAAAAAAAAO2BAAAAAGFneV9hY3Bfc2VydmVyLnBhclBLAQIUAxQAAAAIAAAAIl1fcgMpEAAAAA4AAAAVAAAAAAAAAAAAAADtgUQAAABsb2NhbGhhcm5lc3NfZXh0ZXJuYWxQSwUGAAAAAAIAAgCDAAAAhwAAAAAA", - missingHarness: - "UEsDBBQAAAAIAAAAIl1zEy/oFAAAABQAAAASAAAAYWd5X2FjcF9zZXJ2ZXIucGFyS8wryUwvSizLLKlUKCoFcnJTuQBQSwECFAMUAAAACAAAACJdcxMv6BQAAAAUAAAAEgAAAAAAAAAAAAAA7YEAAAAAYWd5X2FjcF9zZXJ2ZXIucGFyUEsFBgAAAAABAAEAQAAAAEQAAAAAAA==", - duplicate: - "UEsDBBQAAAAIAAAAIl1zEy/oFAAAABQAAAASAAAAYWd5X2FjcF9zZXJ2ZXIucGFyS8wryUwvSizLLKlUKCoFcnJTuQBQSwMEFAAAAAgAAAAiXXMTL+gUAAAAFAAAABIAAABhZ3lfYWNwX3NlcnZlci5wYXJLzCvJTC9KLMssqVQoKgVyclO5AFBLAQIUAxQAAAAIAAAAIl1zEy/oFAAAABQAAAASAAAAAAAAAAAAAADtgQAAAABhZ3lfYWNwX3NlcnZlci5wYXJQSwECFAMUAAAACAAAACJdcxMv6BQAAAAUAAAAEgAAAAAAAAAAAAAA7YFEAAAAYWd5X2FjcF9zZXJ2ZXIucGFyUEsFBgAAAAACAAIAgAAAAIgAAAAAAA==", - traversal: - "UEsDBBQAAAAIAAAAIl1zEy/oFAAAABQAAAAVAAAALi5cYWd5X2FjcF9zZXJ2ZXIucGFyS8wryUwvSizLLKlUKCoFcnJTuQBQSwMEFAAAAAgAAAAiXV9yAykQAAAADgAAABUAAABsb2NhbGhhcm5lc3NfZXh0ZXJuYWzLyU9OzFHISCzKSy0u5gIAUEsBAhQDFAAAAAgAAAAiXXMTL+gUAAAAFAAAABUAAAAAAAAAAAAAAO2BAAAAAC4uXGFneV9hY3Bfc2VydmVyLnBhclBLAQIUAxQAAAAIAAAAIl1fcgMpEAAAAA4AAAAVAAAAAAAAAAAAAADtgUcAAABsb2NhbGhhcm5lc3NfZXh0ZXJuYWxQSwUGAAAAAAIAAgCGAAAAigAAAAAA", - symlink: - "UEsDBBQAAAAIAAAAIl1zEy/oFAAAABQAAAASAAAAYWd5X2FjcF9zZXJ2ZXIucGFyS8wryUwvSizLLKlUKCoFcnJTuQBQSwMEFAAAAAgAAAAiXV9yAykQAAAADgAAABUAAABsb2NhbGhhcm5lc3NfZXh0ZXJuYWzLyU9OzFHISCzKSy0u5gIAUEsBAhQDFAAAAAgAAAAiXXMTL+gUAAAAFAAAABIAAAAAAAAAAAAAAO2BAAAAAGFneV9hY3Bfc2VydmVyLnBhclBLAQIUAxQAAAAIAAAAIl1fcgMpEAAAAA4AAAAVAAAAAAAAAAAAAAD/oUQAAABsb2NhbGhhcm5lc3NfZXh0ZXJuYWxQSwUGAAAAAAIAAgCDAAAAhwAAAAAA", - oversizedMember: - "UEsDBBQAAAAIAAAAIl0WGThFFQAAABUAAAASAAAAYWd5X2FjcF9zZXJ2ZXIucGFyS8wryUwvSizLLKlUKCoFcnJTuSoAUEsDBBQAAAAIAAAAIl1fcgMpEAAAAA4AAAAVAAAAbG9jYWxoYXJuZXNzX2V4dGVybmFsy8lPTsxRyEgsykstLuYCAFBLAQIUAxQAAAAIAAAAIl0WGThFFQAAABUAAAASAAAAAAAAAAAAAADtgQAAAABhZ3lfYWNwX3NlcnZlci5wYXJQSwECFAMUAAAACAAAACJdX3IDKRAAAAAOAAAAFQAAAAAAAAAAAAAA7YFFAAAAbG9jYWxoYXJuZXNzX2V4dGVybmFsUEsFBgAAAAACAAIAgwAAAIgAAAAAAA==", - windows: - "UEsDBBQAAAAIAAAAIl1zEy/oFAAAABQAAAASAAAAYWd5X2FjcF9zZXJ2ZXIuZXhlS8wryUwvSizLLKlUKCoFcnJTuQBQSwMEFAAAAAgAAAAiXV9yAykQAAAADgAAABkAAABsb2NhbGhhcm5lc3NfZXh0ZXJuYWwuZXhly8lPTsxRyEgsykstLuYCAFBLAQIUAxQAAAAIAAAAIl1zEy/oFAAAABQAAAASAAAAAAAAAAAAAADtgQAAAABhZ3lfYWNwX3NlcnZlci5leGVQSwECFAMUAAAACAAAACJdX3IDKRAAAAAOAAAAGQAAAAAAAAAAAAAA7YFEAAAAbG9jYWxoYXJuZXNzX2V4dGVybmFsLmV4ZVBLBQYAAAAAAgACAIcAAACLAAAAAAA=", -}; +// One regular member, `antigravity`, holding serverContents. +const cliTarball = Buffer.from( + "H4sIAAAAAAACE+3RMQ7CQAwEQNe8Ik8wgYj3XIFQCiiOCxK/56CJRA9CYqZZrxsXLpc2n2q5ze0en5LdYZpe2b1n5rhf5+d+m+MuY8j4guXaSu3n4z+V9f9DXXo5HzcBAAAAAAAAAADAz3sA56lbdQAoAAA=", + "base64", +); // Linux platform mocks cannot enforce POSIX exec bits on NTFS; use the host platform. const hostPlatform: NodeJS.Platform = HostProcess.Platform.defaultValue() === "win32" ? "win32" : "linux"; -const completeArchive = Buffer.from( - hostPlatform === "win32" ? zipFixtures.windows : zipFixtures.complete, - "base64", -); -const executableName = hostPlatform === "win32" ? "agy_acp_server.exe" : "agy_acp_server.par"; -const harnessName = - hostPlatform === "win32" ? "localharness_external.exe" : "localharness_external"; +const completeArchive = hostPlatform === "win32" ? Buffer.from(serverContents) : cliTarball; +const executableName = hostPlatform === "win32" ? "agy.exe" : "antigravity"; const releaseAsset = Effect.fn("test.antigravityReleaseAsset")(function* ( archive: Uint8Array = completeArchive, @@ -67,60 +49,51 @@ const releaseAsset = Effect.fn("test.antigravityReleaseAsset")(function* ( ) { const digest = yield* Digest.Digest; return { - version: "fixture-new", - url: "https://dl.google.com/antigravity-test.zip", - sha256: Hex.encode(yield* digest.digest(Digest.sha256, archive).pipe(Effect.orDie)), - archiveBytes: archive.byteLength, - executable: { - name: platform === "win32" ? "agy_acp_server.exe" : "agy_acp_server.par", - bytes: Buffer.byteLength(serverContents), - }, - harness: { - name: platform === "win32" ? "localharness_external.exe" : "localharness_external", - bytes: Buffer.byteLength(harnessContents), - }, - } satisfies AntigravityReleaseAsset; + version: assetVersion, + url: "https://storage.googleapis.com/antigravity-test", + sha512: Hex.encode(yield* digest.digest(Digest.sha512, archive).pipe(Effect.orDie)), + executable: { name: platform === "win32" ? "agy.exe" : "antigravity" }, + format: platform === "win32" ? "executable" : "tar.gz", + } satisfies AntigravityCliReleaseAsset; }); const writeRelease = Effect.fn("test.writeAntigravityRelease")(function* ( managedDirectory: string, - asset: AntigravityReleaseAsset, + release: { readonly releaseId: string; readonly version: string; readonly name: string }, active = true, ) { const fs = yield* FileSystem.FileSystem; const path = yield* Path.Path; - const directory = path.join(managedDirectory, "versions", asset.sha256); + const directory = path.join(managedDirectory, "versions", release.releaseId); yield* fs.makeDirectory(directory, { recursive: true }); - yield* fs.writeFileString(path.join(directory, asset.executable.name), serverContents, { - mode: 0o755, - }); - yield* fs.writeFileString(path.join(directory, asset.harness.name), harnessContents, { - mode: 0o755, - }); + yield* fs.writeFileString(path.join(directory, release.name), serverContents, { mode: 0o755 }); yield* fs.writeFileString( path.join(directory, ".install-complete.json"), encodeJsonString({ - releaseId: asset.sha256, - version: asset.version, - executable: asset.executable, - harness: asset.harness, + releaseId: release.releaseId, + version: release.version, + executable: { name: release.name, bytes: Buffer.byteLength(serverContents) }, }), ); if (active) { yield* fs.writeFileString( path.join(managedDirectory, "active.json"), - encodeJsonString({ releaseId: asset.sha256 }), + encodeJsonString({ releaseId: release.releaseId }), ); } }); +const assetRelease = (asset: AntigravityCliReleaseAsset) => ({ + releaseId: asset.sha512.slice(0, 64), + version: asset.version, + name: asset.executable.name, +}); + interface HarnessOptions { readonly baseDir?: string; - readonly asset?: AntigravityReleaseAsset | null; + readonly asset?: AntigravityCliReleaseAsset | null; readonly archive?: Buffer; readonly body?: Stream.Stream | undefined; - readonly contentLength?: number; - readonly contentEncoding?: string; readonly platform?: NodeJS.Platform; readonly arch?: NodeJS.Architecture; readonly path?: string; @@ -154,9 +127,9 @@ const makeHarness = Effect.fn("test.makeAntigravityInstallation")(function* ( const managedDirectory = path.join(baseDir, "tools", "antigravity-acp", `${platform}-${arch}`); if (options.previous) { yield* writeRelease(managedDirectory, { - ...(yield* releaseAsset(archive, platform)), - sha256: previousReleaseId, + releaseId: previousReleaseId, version: previousVersion, + name: platform === "win32" ? "agy.exe" : "antigravity", }); } const stagingReleased = yield* Deferred.make(); @@ -237,19 +210,7 @@ const makeHarness = Effect.fn("test.makeAntigravityInstallation")(function* ( }), ); } - const response = HttpClientResponse.fromWeb( - request, - new Response(null, { - headers: { - ...(options.contentLength === undefined - ? {} - : { "content-length": String(options.contentLength) }), - ...(options.contentEncoding === undefined - ? {} - : { "content-encoding": options.contentEncoding }), - }, - }), - ); + const response = HttpClientResponse.fromWeb(request, new Response(null)); return Effect.succeed( Object.defineProperty(response, "stream", { value: @@ -286,24 +247,45 @@ const expectPreviousRelease = Effect.fn("test.expectPreviousAntigravityRelease") path.join(installation.managedDirectory, "versions", previousReleaseId), ); expect(yield* fs.readFileString(resolved.executablePath)).toBe(serverContents); - expect(yield* fs.readFileString(resolved.harnessPath!)).toBe(harnessContents); expect((yield* installation.state).installedVersion).toBe(previousVersion); }); it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("Antigravity installation", (it) => { it.effect.each([...new Set(["win32", hostPlatform])] as NodeJS.Platform[])( - "migrates the legacy managed runtime to the native CLI on %s and retains the old release", + "replaces a managed runtime from before the Antigravity CLI on %s", (platform) => Effect.gen(function* () { - const archive = - platform === "win32" - ? Buffer.from(serverContents) - : Buffer.from( - "H4sIAAAAAAACE+3RMQ7CQAwEQNe8Ik8wgYj3XIFQCiiOCxK/56CJRA9CYqZZrxsXLpc2n2q5ze0en5LdYZpe2b1n5rhf5+d+m+MuY8j4guXaSu3n4z+V9f9DXXo5HzcBAAAAAAAAAADAz3sA56lbdQAoAAA=", - "base64", - ); - const { installation, validations, requests, fs, baseDir, stagingReleased } = - yield* makeHarness({ native: true, archive, platform, previous: true }); + const archive = platform === "win32" ? Buffer.from(serverContents) : cliTarball; + const { installation, validations, requests, fs, path, baseDir, stagingReleased } = + yield* makeHarness({ native: true, archive, platform }); + // A 1.4.x install recorded agy_acp_server with its localharness_external sibling. + const legacyId = "2".repeat(64); + const legacyDirectory = path.join(installation.managedDirectory, "versions", legacyId); + yield* fs.makeDirectory(legacyDirectory, { recursive: true }); + yield* fs.writeFileString( + path.join(legacyDirectory, "agy_acp_server.par"), + serverContents, + { + mode: 0o755, + }, + ); + yield* fs.writeFileString( + path.join(legacyDirectory, ".install-complete.json"), + encodeJsonString({ + releaseId: legacyId, + version: "1.4.5", + executable: { name: "agy_acp_server.par", bytes: Buffer.byteLength(serverContents) }, + harness: { name: "localharness_external", bytes: 1 }, + }), + ); + yield* fs.writeFileString( + path.join(installation.managedDirectory, "active.json"), + encodeJsonString({ releaseId: legacyId }), + ); + expect(yield* installation.resolve().pipe(Effect.flip)).toMatchObject({ + operation: "resolve", + detail: expect.stringContaining("Antigravity 1.4.5 predates the Antigravity CLI"), + }); yield* installation.start; expect(yield* terminalState(installation)).toMatchObject({ phase: "succeeded", @@ -311,8 +293,9 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("Antigravity inst }); yield* Deferred.await(stagingReleased); const resolved = yield* installation.resolve(); - expect(resolved).toMatchObject({ source: "managed", version: "1.5.7", harnessPath: null }); - expect(validations[0]?.executable.harnessPath).toBeNull(); + expect(resolved).toMatchObject({ source: "managed", version: "1.5.7" }); + expect(validations).toHaveLength(1); + expect(yield* fs.exists(legacyDirectory)).toBe(false); expect(yield* fs.readFileString(resolved.executablePath)).toBe(serverContents); expect(requests.some((url) => url.includes("/manifests/"))).toBe(true); const restarted = yield* makeHarness({ @@ -524,9 +507,9 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("Antigravity inst url: "https://example.com/agy.exe", }), }, - ])("rejects a native $name and preserves the legacy release", ({ change }) => + ])("rejects a native $name and preserves the previous release", ({ change }) => Effect.gen(function* () { - const { installation, validations } = yield* makeHarness({ + const { installation, validations, requests } = yield* makeHarness({ native: true, nativeManifest: change, archive: Buffer.from(serverContents), @@ -534,9 +517,10 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("Antigravity inst previous: true, }); const result = yield* Effect.result(installation.start); - if (result._tag === "Success") - expect((yield* terminalState(installation)).phase).toBe("failed"); - expect(validations).toEqual([]); + // Without an acceptable release, start re-verifies the installed one. + if (result._tag === "Success") yield* terminalState(installation); + expect(validations.map(({ version }) => version)).not.toContain("1.5.7"); + expect(requests.some((url) => url.startsWith("https://example.com"))).toBe(false); yield* expectPreviousRelease(installation); }), ); @@ -554,7 +538,7 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("Antigravity inst }).pipe(Effect.provideService(HostProcess.IsExecutable, true)), ); - it.effect("verifies both files before activating a streamed download", () => + it.effect("verifies the executable before activating a streamed download", () => Effect.gen(function* () { const enteredValidation = yield* Deferred.make(); const finishValidation = yield* Deferred.make(); @@ -577,59 +561,35 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("Antigravity inst yield* Deferred.await(enteredValidation); yield* expectPreviousRelease(installation); const validation = validations[0]; - expect(validation?.version).toBe("fixture-new"); + expect(validation?.version).toBe(assetVersion); if (!validation) return yield* Effect.die("Expected runtime validation."); expect(yield* fs.readFileString(validation.executable.executablePath)).toBe(serverContents); - expect(yield* fs.readFileString(validation.executable.harnessPath!)).toBe(harnessContents); yield* Deferred.succeed(finishValidation, undefined); expect(yield* terminalState(installation)).toMatchObject({ phase: "succeeded", operationId: started.operationId, - downloadedBytes: completeArchive.byteLength, - installedVersion: "fixture-new", + installedVersion: assetVersion, }); yield* Deferred.await(stagingReleased); const selected = yield* installation.resolve(); - expect(selected).toMatchObject({ source: "managed", version: "fixture-new" }); - expect(path.dirname(selected.harnessPath!)).toBe(path.dirname(selected.executablePath)); + expect(selected).toMatchObject({ source: "managed", version: assetVersion }); expect(yield* fs.readFileString(selected.executablePath)).toBe(serverContents); - expect(yield* fs.readFileString(selected.harnessPath!)).toBe(harnessContents); expect(yield* fs.readDirectory(path.join(installation.managedDirectory, "versions"))).toEqual( - [(yield* releaseAsset()).sha256], + [assetRelease(yield* releaseAsset()).releaseId], ); expect(requests).toEqual([(yield* releaseAsset()).url]); }), ); - it.effect("accepts an encoded Content-Length when the body is compressed", () => - Effect.gen(function* () { - // dl.google.com reports the gzip-encoded size; byte and hash checks use the decoded stream. - const { installation, validations } = yield* makeHarness({ - contentLength: completeArchive.byteLength - 1_000, - contentEncoding: "gzip", - }); - yield* installation.start; - const state = yield* terminalState(installation); - expect(state.phase).toBe("succeeded"); - expect(validations).toHaveLength(1); - }), - ); - it.effect.each([ - { name: "checksum mismatch", completeAsset: { sha256: "2".repeat(64) } }, + { name: "checksum mismatch", completeAsset: { sha512: "2".repeat(128) } }, { name: "short download", archive: completeArchive.subarray(0, -1), completeAsset: {} }, { name: "oversized download", archive: Buffer.concat([completeArchive, Buffer.from("extra")]), completeAsset: {}, }, - { name: "wrong Content-Length", contentLength: completeArchive.byteLength + 1 }, - { name: "missing harness", archive: Buffer.from(zipFixtures.missingHarness, "base64") }, - { name: "duplicate executable", archive: Buffer.from(zipFixtures.duplicate, "base64") }, - { name: "path traversal", archive: Buffer.from(zipFixtures.traversal, "base64") }, - { name: "symbolic link", archive: Buffer.from(zipFixtures.symlink, "base64") }, - { name: "oversized member", archive: Buffer.from(zipFixtures.oversizedMember, "base64") }, ])("rejects $name before runtime validation", ({ completeAsset, ...options }) => Effect.gen(function* () { const asset = @@ -700,25 +660,6 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("Antigravity inst }), ); - it.effect.skipIf(HostProcess.Platform.defaultValue() === "win32")( - "refuses a 16 KiB-page linux-arm64 kernel before downloading the runtime", - () => - Effect.gen(function* () { - const realSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const spawner = ChildProcessSpawner.make((command) => - ChildProcess.isStandardCommand(command) && command.command === "getconf" - ? realSpawner.spawn(ChildProcess.make("sh", ["-c", "echo 16384"], command.options)) - : realSpawner.spawn(command), - ); - const { installation, requests } = yield* makeHarness({ arch: "arm64", spawner }); - yield* installation.start; - const state = yield* terminalState(installation); - expect(state.phase).toBe("failed"); - expect(state.message).toMatch(/4 KiB/); - expect(requests).toEqual([]); - }), - ); - it.effect.each(["downloaded", "existing", "concurrent"] as const)( "reports a verification timeout for a %s runtime without changing the active release", (source) => @@ -735,7 +676,7 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("Antigravity inst ...fs, rename: (from, to) => source === "concurrent" && path.basename(path.dirname(to)) === "versions" - ? writeRelease(path.dirname(path.dirname(to)), asset, false).pipe( + ? writeRelease(path.dirname(path.dirname(to)), assetRelease(asset), false).pipe( Effect.provideService(FileSystem.FileSystem, fs), Effect.provideService(Path.Path, path), Effect.andThen( @@ -759,7 +700,7 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("Antigravity inst ), }); if (source === "existing") { - yield* writeRelease(installation.managedDirectory, asset, false); + yield* writeRelease(installation.managedDirectory, assetRelease(asset), false); } yield* installation.start; yield* Deferred.await(entered); @@ -776,97 +717,100 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("Antigravity inst }), ); - it.effect.each(["download", "extract", "active pointer"] as const)( - "preserves the old runtime after an ENOSPC error during %s", - (stage) => - Effect.gen(function* () { - const fs = yield* FileSystem.FileSystem; - const noSpace = PlatformError.systemError({ - _tag: "Unknown", - module: "FileSystem", - method: "write", - description: "ENOSPC: no space left on device", - }); - const fileSystem = FileSystem.FileSystem.of({ + // Windows hosts copy the downloaded executable, so no extraction stream exists there. + it.effect.each( + hostPlatform === "win32" + ? (["download", "active pointer"] as const) + : (["download", "extract", "active pointer"] as const), + )("preserves the old runtime after an ENOSPC error during %s", (stage) => + Effect.gen(function* () { + const fs = yield* FileSystem.FileSystem; + const noSpace = PlatformError.systemError({ + _tag: "Unknown", + module: "FileSystem", + method: "write", + description: "ENOSPC: no space left on device", + }); + const fileSystem = FileSystem.FileSystem.of({ + ...fs, + sink: (target, options) => + (stage === "download" && target.endsWith("download")) || + (stage === "extract" && target.endsWith(executableName)) + ? fs.sink(target, options).pipe(Sink.mapInputEffect(() => Effect.fail(noSpace))) + : fs.sink(target, options), + writeFileString: (target, content, options) => + stage === "active pointer" && target.endsWith("contents.tmp") + ? Effect.fail(noSpace) + : fs.writeFileString(target, content, options), + }); + const { installation, stagingReleased, path } = yield* makeHarness({ + previous: true, + fileSystem, + }); + yield* installation.start; + expect((yield* terminalState(installation)).phase).toBe("failed"); + yield* Deferred.await(stagingReleased); + yield* expectPreviousRelease(installation); + expect( + (yield* fs.readDirectory(path.join(installation.managedDirectory, "versions"))).some( + (name) => name.startsWith(".install-"), + ), + ).toBe(false); + expect(yield* fs.readDirectory(installation.managedDirectory)).toEqual([ + "active.json", + "versions", + ]); + }), + ); + + it.effect.each( + hostPlatform === "win32" + ? (["downloading", "verifying"] as const) + : (["downloading", "extracting", "verifying"] as const), + )("cancels during %s and waits for open resources to close", (phase) => + Effect.gen(function* () { + const fs = yield* FileSystem.FileSystem; + const entered = yield* Deferred.make(); + const release = yield* Deferred.make(); + const interrupted = yield* Deferred.make(); + const barrier = Deferred.succeed(entered, undefined).pipe( + Effect.andThen(Deferred.await(release)), + Effect.onInterrupt(() => Deferred.succeed(interrupted, undefined)), + ); + const { installation, stagingReleased, path, validations } = yield* makeHarness({ + previous: true, + body: + phase === "downloading" + ? Stream.concat( + Stream.make(completeArchive.subarray(0, 31)), + Stream.fromEffect(barrier.pipe(Effect.as(completeArchive.subarray(31)))), + ) + : undefined, + validate: phase === "verifying" ? () => barrier : undefined, + fileSystem: FileSystem.FileSystem.of({ ...fs, sink: (target, options) => - (stage === "download" && target.endsWith("download.zip")) || - (stage === "extract" && target.endsWith(executableName)) - ? fs.sink(target, options).pipe(Sink.mapInputEffect(() => Effect.fail(noSpace))) + phase === "extracting" && target.endsWith(executableName) + ? fs + .sink(target, options) + .pipe(Sink.mapInputEffect((chunk: Uint8Array) => barrier.pipe(Effect.as(chunk)))) : fs.sink(target, options), - writeFileString: (target, content, options) => - stage === "active pointer" && target.endsWith("contents.tmp") - ? Effect.fail(noSpace) - : fs.writeFileString(target, content, options), - }); - const { installation, stagingReleased, path } = yield* makeHarness({ - previous: true, - fileSystem, - }); - yield* installation.start; - expect((yield* terminalState(installation)).phase).toBe("failed"); - yield* Deferred.await(stagingReleased); - yield* expectPreviousRelease(installation); - expect( - (yield* fs.readDirectory(path.join(installation.managedDirectory, "versions"))).some( - (name) => name.startsWith(".install-"), - ), - ).toBe(false); - expect(yield* fs.readDirectory(installation.managedDirectory)).toEqual([ - "active.json", - "versions", - ]); - }), - ); - - it.effect.each(["downloading", "extracting", "verifying"] as const)( - "cancels during %s and waits for open resources to close", - (phase) => - Effect.gen(function* () { - const fs = yield* FileSystem.FileSystem; - const entered = yield* Deferred.make(); - const release = yield* Deferred.make(); - const interrupted = yield* Deferred.make(); - const barrier = Deferred.succeed(entered, undefined).pipe( - Effect.andThen(Deferred.await(release)), - Effect.onInterrupt(() => Deferred.succeed(interrupted, undefined)), - ); - const { installation, stagingReleased, path, validations } = yield* makeHarness({ - previous: true, - body: - phase === "downloading" - ? Stream.concat( - Stream.make(completeArchive.subarray(0, 31)), - Stream.fromEffect(barrier.pipe(Effect.as(completeArchive.subarray(31)))), - ) - : undefined, - validate: phase === "verifying" ? () => barrier : undefined, - fileSystem: FileSystem.FileSystem.of({ - ...fs, - sink: (target, options) => - phase === "extracting" && target.endsWith(executableName) - ? fs - .sink(target, options) - .pipe( - Sink.mapInputEffect((chunk: Uint8Array) => barrier.pipe(Effect.as(chunk))), - ) - : fs.sink(target, options), - }), - }); - const started = yield* installation.start; - yield* Deferred.await(entered); - expect((yield* installation.state).phase).toBe(phase); - expect( - (yield* installation.cancel(started.operationId ?? "missing-operation-id")).phase, - ).toBe("cancelled"); - yield* Deferred.await(interrupted); - yield* Deferred.await(stagingReleased); - yield* expectPreviousRelease(installation); - expect(validations).toHaveLength(phase === "verifying" ? 1 : 0); - expect( - yield* fs.readDirectory(path.join(installation.managedDirectory, "versions")), - ).toEqual([previousReleaseId]); - }), + }), + }); + const started = yield* installation.start; + yield* Deferred.await(entered); + expect((yield* installation.state).phase).toBe(phase); + expect( + (yield* installation.cancel(started.operationId ?? "missing-operation-id")).phase, + ).toBe("cancelled"); + yield* Deferred.await(interrupted); + yield* Deferred.await(stagingReleased); + yield* expectPreviousRelease(installation); + expect(validations).toHaveLength(phase === "verifying" ? 1 : 0); + expect(yield* fs.readDirectory(path.join(installation.managedDirectory, "versions"))).toEqual( + [previousReleaseId], + ); + }), ); it.effect.each([ @@ -925,7 +869,7 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("Antigravity inst expect(yield* installation.state).toMatchObject({ operationId: first.operationId, phase: "succeeded", - installedVersion: "fixture-new", + installedVersion: assetVersion, }); const current = testCase.restart ? yield* installation.start : first; if (testCase.restart) yield* Deferred.await(nextValidationStarted); @@ -936,15 +880,15 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("Antigravity inst expect(yield* installation.state).toMatchObject({ operationId: current.operationId, phase: testCase.restart ? "verifying" : "succeeded", - installedVersion: "fixture-new", + installedVersion: assetVersion, }); - expect((yield* installation.resolve()).version).toBe("fixture-new"); + expect((yield* installation.resolve()).version).toBe(assetVersion); yield* Deferred.succeed(releaseNextValidation, undefined); expect(yield* terminalState(installation)).toMatchObject({ operationId: current.operationId, phase: "succeeded", - installedVersion: "fixture-new", + installedVersion: assetVersion, }); }).pipe( Effect.ensuring( @@ -1000,66 +944,9 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("Antigravity inst }), ); - // A simulated Mac install needs POSIX execute bits, which Windows files lack. - it.effect.skipIf(HostProcess.Platform.defaultValue() === "win32")( - "re-signs the Intel Mac runtime ad hoc and records the signed sizes", - () => - Effect.gen(function* () { - const fs = yield* FileSystem.FileSystem; - const signed: Array> = []; - const spawner = ChildProcessSpawner.make((command) => - Effect.gen(function* () { - if (!ChildProcess.isStandardCommand(command)) - return yield* Effect.die("Unexpected spawn."); - const args = command.args.map(String); - signed.push([String(command.command), ...args]); - // codesign rewrites the signature, which changes each file's size. - for (const file of args.slice(3)) { - yield* fs.writeFileString(file, "signature", { flag: "a" }); - } - return ChildProcessSpawner.makeHandle({ - pid: ChildProcessSpawner.ProcessId(900_000_301), - exitCode: Effect.succeed(ChildProcessSpawner.ExitCode(0)), - isRunning: Effect.succeed(false), - kill: () => Effect.void, - unref: Effect.succeed(Effect.void), - stdin: Sink.drain, - stdout: Stream.empty, - stderr: Stream.empty, - all: Stream.empty, - getInputFd: () => Sink.drain, - getOutputFd: () => Stream.empty, - }); - }).pipe(Effect.orDie), - ); - const { installation, validations } = yield* makeHarness({ - platform: "darwin", - arch: "x64", - spawner, - }); - yield* installation.start; - expect((yield* terminalState(installation)).phase).toBe("succeeded"); - const validated = validations[0]?.executable; - expect(signed).toEqual([ - [ - "/usr/bin/codesign", - "--force", - "--sign", - "-", - validated?.executablePath, - validated?.harnessPath, - ], - ]); - const selected = yield* installation.resolve(); - expect(yield* fs.readFileString(selected.executablePath)).toBe( - `${serverContents}signature`, - ); - }), - ); - // The mocked Linux PATH walk needs POSIX paths; Windows temp paths contain colons. it.effect.skipIf(HostProcess.Platform.defaultValue() === "win32")( - "accepts the agy CLI without a harness sibling but still requires one for other binaries", + "accepts only the agy CLI as a custom or PATH executable", () => Effect.gen(function* () { const fs = yield* FileSystem.FileSystem; @@ -1082,21 +969,17 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("Antigravity inst expect(yield* installation.resolve(cli)).toMatchObject({ executablePath: cli, - harnessPath: null, source: "override", version: null, }); expect(yield* installation.resolve(alias)).toMatchObject({ executablePath: alias, - harnessPath: null, }); expect(yield* installation.resolve("agy", { PATH: cliDirectory })).toMatchObject({ executablePath: alias, - harnessPath: null, }); expect(yield* installation.resolve(undefined, { PATH: cliDirectory })).toMatchObject({ executablePath: alias, - harnessPath: null, source: "path", }); expect(yield* installation.resolve(other).pipe(Effect.flip)).toMatchObject({ @@ -1111,7 +994,6 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("Antigravity inst yield* fs.symlink(mise, path.join(shims, "agy")); expect(yield* installation.resolve("agy", { PATH: shims })).toMatchObject({ executablePath: path.join(shims, "agy"), - harnessPath: null, }); const { installation: windows } = yield* makeHarness({ baseDir, platform: "win32" }); @@ -1120,7 +1002,6 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("Antigravity inst yield* fs.makeDirectory(windowsDirectory); yield* fs.writeFileString(path.join(windowsDirectory, name), "cli"); const selected = yield* windows.resolve("agy", { PATH: `"${windowsDirectory}"` }); - expect(selected.harnessPath).toBeNull(); expect((yield* fs.realPath(selected.executablePath)).toLowerCase()).toBe( (yield* fs.realPath(path.join(windowsDirectory, name))).toLowerCase(), ); @@ -1139,11 +1020,9 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("Antigravity inst .makeTempDirectoryScoped({ prefix: "t3-agy-path-test-" }) .pipe(Effect.flatMap((directory) => fs.realPath(directory))); const externalDirectory = path.join(baseDir, "external"); - const externalExecutable = path.join(externalDirectory, executableName); - const externalHarness = path.join(externalDirectory, harnessName); + const externalExecutable = path.join(externalDirectory, "agy"); yield* fs.makeDirectory(externalDirectory); - yield* fs.writeFileString(externalExecutable, "external server", { mode: 0o755 }); - yield* fs.writeFileString(externalHarness, "external harness", { mode: 0o755 }); + yield* fs.writeFileString(externalExecutable, "external cli", { mode: 0o755 }); const { installation } = yield* makeHarness({ baseDir, path: externalDirectory, @@ -1159,25 +1038,18 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("Antigravity inst source: "override", managedVersionDirectory: null, }); - expect(yield* installation.resolve(executableName)).toMatchObject({ - source: "override", - }); + expect(yield* installation.resolve("agy")).toMatchObject({ source: "override" }); expect( yield* installation - .resolve(`~/external/${executableName}`) + .resolve("~/external/agy") .pipe(Effect.provideService(HostProcess.HomeDirectory, baseDir)), ).toMatchObject({ source: "override", executablePath: externalExecutable }); - yield* fs.remove(externalHarness); - expect(yield* installation.resolve(externalExecutable).pipe(Effect.flip)).toMatchObject({ - operation: "resolve", - }); expect( yield* installation.resolve(path.join(baseDir, "missing")).pipe(Effect.flip), ).toMatchObject({ operation: "resolve", }); yield* expectPreviousRelease(installation); - yield* fs.writeFileString(externalHarness, "external harness", { mode: 0o755 }); yield* installation.remove(); expect(yield* installation.resolve()).toMatchObject({ source: "path", @@ -1194,149 +1066,11 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("Antigravity inst executablePath: externalExecutable, }); expect( - yield* isolated.installation.resolve(executableName, { PATH: externalDirectory }), + yield* isolated.installation.resolve("agy", { PATH: externalDirectory }), ).toMatchObject({ source: "override", executablePath: externalExecutable }); - - const incompleteDirectory = path.join(baseDir, "incomplete"); - yield* fs.makeDirectory(incompleteDirectory); - yield* fs.writeFileString(path.join(incompleteDirectory, executableName), "no harness", { - mode: 0o755, - }); - const shadowedPath = { PATH: `${incompleteDirectory}:${externalDirectory}` }; - expect(yield* isolated.installation.resolve(undefined, shadowedPath)).toMatchObject({ - source: "path", - executablePath: externalExecutable, - }); - expect(yield* isolated.installation.resolve(executableName, shadowedPath)).toMatchObject({ - source: "override", - executablePath: externalExecutable, - }); }), ); - it.effect("pairs a Windows launcher script with the helper beside the executable it runs", () => - Effect.gen(function* () { - const fs = yield* FileSystem.FileSystem; - const path = yield* Path.Path; - const baseDir = yield* fs - .makeTempDirectoryScoped({ prefix: "t3-agy-launcher-$$-test-" }) - .pipe(Effect.flatMap((directory) => fs.realPath(directory))); - const runtimeDirectory = path.join(baseDir, "runtime (x64)"); - const launcherDirectory = path.join(baseDir, "launchers"); - const runtimeExecutable = path.join(runtimeDirectory, "agy_acp_server.exe"); - const runtimeHarness = path.join(runtimeDirectory, "localharness_external.exe"); - yield* fs.makeDirectory(runtimeDirectory); - yield* fs.makeDirectory(launcherDirectory); - yield* fs.writeFileString(runtimeExecutable, "external server"); - yield* fs.writeFileString(runtimeHarness, "external harness"); - const { installation } = yield* makeHarness({ baseDir, platform: "win32", previous: true }); - const writeLauncher = Effect.fn("test.writeAntigravityLauncher")(function* ( - name: string, - launch: string, - ) { - const launcher = path.join(launcherDirectory, name); - yield* fs.writeFileString( - launcher, - `@echo off\r\nrem Runtime launcher\r\n:: Keep environment setup\r\nset AGY_EXTRA=1\r\n${launch} %*\r\nexit /b\r\n`, - ); - return launcher; - }); - - const absolute = yield* writeLauncher("agy.cmd", `"${runtimeExecutable}"`); - expect(yield* installation.resolve(absolute)).toMatchObject({ - executablePath: absolute, - harnessPath: runtimeHarness, - source: "override", - managedVersionDirectory: null, - }); - const quoted = yield* writeLauncher( - "quoted.cmd", - `set "PATH=C:\\Program Files (x86)\\SDK;%PATH%"\r\n"${runtimeExecutable}"`, - ); - expect(yield* installation.resolve(quoted)).toMatchObject({ - executablePath: quoted, - harnessPath: runtimeHarness, - }); - const relative = yield* writeLauncher( - "relative.BAT", - `"%~dp0../runtime (x64)/agy_acp_server.exe"`, - ); - expect(yield* installation.resolve(relative)).toMatchObject({ - executablePath: relative, - harnessPath: runtimeHarness, - }); - - const managed = yield* installation.resolve(); - const intoManaged = yield* writeLauncher("managed.cmd", `"${managed.executablePath}"`); - expect(yield* installation.resolve(intoManaged)).toMatchObject({ - executablePath: intoManaged, - harnessPath: managed.harnessPath, - version: previousVersion, - managedVersionDirectory: managed.managedVersionDirectory, - }); - expect(yield* installation.remove([intoManaged]).pipe(Effect.flip)).toMatchObject({ - operation: "remove", - }); - - const ambiguous = yield* writeLauncher( - "ambiguous.cmd", - `"${managed.executablePath}" --version\r\n"${runtimeExecutable}"`, - ); - expect(yield* installation.resolve(ambiguous).pipe(Effect.flip)).toMatchObject({ - operation: "resolve", - }); - - for (const [name, launch] of [ - ["comment.cmd", `rem Previous runtime: "${runtimeExecutable}"\r\n"%AGY_TARGET%"`], - ["label-comment.cmd", `:: "${runtimeExecutable}"\r\n"%AGY_TARGET%"`], - ["echo.cmd", `echo "${runtimeExecutable}"`], - [ - "conditional.cmd", - `if defined AGY_TARGET "%AGY_TARGET%" %* & exit /b\r\n"${runtimeExecutable}"`, - ], - ["early-exit.cmd", `exit /b\r\n"${runtimeExecutable}"`], - ["continued-set.cmd", `set IGNORED=1^\r\n"${runtimeExecutable}"`], - [ - "chained-comment.cmd", - `rem setup & "${managed.executablePath}"\r\n"${runtimeExecutable}"`, - ], - ["chained.cmd", `"${runtimeExecutable}" --version && "%AGY_TARGET%"`], - ["unquoted-parens.cmd", `set PATH=C:\\Program Files (x86)\\SDK\r\n"${runtimeExecutable}"`], - [ - "quoted-chained.cmd", - `set "PATH=C:\\Program Files (x86)" & "${managed.executablePath}"\r\n"${runtimeExecutable}"`, - ], - ["quoted-redirect.cmd", `set "AGY_MODE=1" > nul\r\n"${runtimeExecutable}"`], - ["quoted-block.cmd", `(set "AGY_MODE=1")\r\n"${runtimeExecutable}"`], - ["quoted-expansion.cmd", `set Q="\r\nset "X=%Q%&exit /b&rem ()"\r\n"${runtimeExecutable}"`], - ] as const) { - const uncertain = yield* writeLauncher(name, launch); - expect(yield* installation.resolve(uncertain).pipe(Effect.flip)).toMatchObject({ - operation: "resolve", - }); - } - - const win32 = yield* Path.Path.pipe(Effect.provide(NodePath.layerWin32)); - const serverOnC: Path.Path = { - ...win32, - resolve: (...segments) => win32.resolve("C:\\t3", ...segments), - }; - const launcherOnD = "D:\\launchers\\agy.cmd"; - for (const [written, expected] of [ - ["\\runtime\\agy_acp_server.exe", null], - ["C:runtime\\agy_acp_server.exe", null], - ["%~dp0runtime\\agy_acp_server.exe", "D:\\launchers\\runtime\\agy_acp_server.exe"], - ["\\\\server\\share\\agy_acp_server.exe", "\\\\server\\share\\agy_acp_server.exe"], - ["D:/runtime/agy_acp_server.exe", "D:\\runtime\\agy_acp_server.exe"], - ["//server/share/agy_acp_server.exe", "\\\\server\\share\\agy_acp_server.exe"], - ] as const) { - expect(AntigravityInstallation.launcherTargetPath(serverOnC, launcherOnD, written)).toBe( - expected, - ); - } - }), - ); - it.effect("keeps leased releases available while new sessions resolve the new release", () => Effect.gen(function* () { const manifestEntered = yield* Deferred.make(); @@ -1380,13 +1114,10 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("Antigravity inst Effect.gen(function* () { const { installation, baseDir, fs, path } = yield* makeHarness({ previous: true }); const previous = yield* installation.resolve(); - yield* fs.remove(previous.harnessPath!); + yield* fs.remove(previous.executablePath); const externalDirectory = path.join(baseDir, "external"); yield* fs.makeDirectory(externalDirectory); - yield* fs.writeFileString(path.join(externalDirectory, executableName), "external server", { - mode: 0o755, - }); - yield* fs.writeFileString(path.join(externalDirectory, harnessName), "external harness", { + yield* fs.writeFileString(path.join(externalDirectory, "agy"), "external cli", { mode: 0o755, }); const restarted = yield* makeHarness({ baseDir, path: externalDirectory }); @@ -1407,7 +1138,7 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("Antigravity inst yield* restarted.installation.start; expect(yield* terminalState(restarted.installation)).toMatchObject({ phase: "succeeded", - installedVersion: "fixture-new", + installedVersion: assetVersion, canRemove: true, }); yield* Deferred.await(restarted.stagingReleased); @@ -1425,11 +1156,9 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("Antigravity inst const profileDirectory = path.join(baseDir, "providers", "antigravity", "profile"); yield* fs.makeDirectory(externalDirectory); yield* fs.makeDirectory(profileDirectory, { recursive: true }); - const externalExecutable = path.join(externalDirectory, executableName); - const externalHarness = path.join(externalDirectory, harnessName); + const externalExecutable = path.join(externalDirectory, "agy"); const profilePath = path.join(profileDirectory, "preferences.json"); - yield* fs.writeFileString(externalExecutable, "external server", { mode: 0o755 }); - yield* fs.writeFileString(externalHarness, "external harness", { mode: 0o755 }); + yield* fs.writeFileString(externalExecutable, "external cli", { mode: 0o755 }); yield* fs.writeFileString(profilePath, "{}"); expect( yield* installation.remove([managed.executablePath]).pipe(Effect.flip), @@ -1443,8 +1172,7 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("Antigravity inst operationId: null, installedVersion: null, }); - expect(yield* fs.readFileString(externalExecutable)).toBe("external server"); - expect(yield* fs.readFileString(externalHarness)).toBe("external harness"); + expect(yield* fs.readFileString(externalExecutable)).toBe("external cli"); expect(yield* fs.readFileString(profilePath)).toBe("{}"); }), ); @@ -1455,7 +1183,7 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("Antigravity inst Effect.gen(function* () { const fs = yield* FileSystem.FileSystem; const path = yield* Path.Path; - const archive = Buffer.from(zipFixtures.windows, "base64"); + const archive = Buffer.from(serverContents); const asset = yield* releaseAsset(archive, "win32"); let denyPointerRename = true; const renameTargets: string[] = []; @@ -1481,7 +1209,7 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("Antigravity inst }, }), }); - yield* writeRelease(installation.managedDirectory, asset, false); + yield* writeRelease(installation.managedDirectory, assetRelease(asset), false); yield* installation.start; expect((yield* terminalState(installation)).phase).toBe("failed"); yield* expectPreviousRelease(installation); @@ -1490,7 +1218,7 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("Antigravity inst denyPointerRename = false; yield* installation.start; expect((yield* terminalState(installation)).phase).toBe("succeeded"); - expect((yield* installation.resolve()).version).toBe("fixture-new"); + expect((yield* installation.resolve()).version).toBe(assetVersion); expect(requests).toEqual([]); expect(validations).toHaveLength(2); expect(renameTargets).toEqual([ @@ -1504,7 +1232,7 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("Antigravity inst Effect.gen(function* () { const fs = yield* FileSystem.FileSystem; const path = yield* Path.Path; - const archive = Buffer.from(zipFixtures.windows, "base64"); + const archive = Buffer.from(serverContents); const releaseRenameDenied = yield* Deferred.make(); let releaseRenameDenials = 3; const { installation } = yield* makeHarness({ @@ -1543,9 +1271,9 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("Antigravity inst yield* TestClock.adjust("30 seconds"); expect(yield* Fiber.join(terminal)).toMatchObject({ phase: "succeeded", - installedVersion: "fixture-new", + installedVersion: assetVersion, }); - expect((yield* installation.resolve()).version).toBe("fixture-new"); + expect((yield* installation.resolve()).version).toBe(assetVersion); }), ); diff --git a/apps/server/src/provider/AntigravityInstallation.ts b/apps/server/src/provider/AntigravityInstallation.ts index 0953323e2dbc5..a51b4f25d9e35 100644 --- a/apps/server/src/provider/AntigravityInstallation.ts +++ b/apps/server/src/provider/AntigravityInstallation.ts @@ -4,8 +4,11 @@ import * as ModelManifest from "./ModelManifest.ts"; import { resolveProviderCompatibility } from "./providerCompatibility.ts"; import { cliArchiveTarCommand } from "@t3tools/shared/cliRelease"; import { compareSemverVersions } from "@t3tools/shared/semver"; -import * as EffectNodeStream from "@effect/platform-node/NodeStream"; -import { ProviderDriverKind, type ProviderInstallState } from "@t3tools/contracts"; +import { + ProviderDriverKind, + type ProviderInstallState, + type ServerProviderCompatibilityAdvisory, +} from "@t3tools/contracts"; import * as HostProcess from "@t3tools/shared/HostProcess"; import { resolveNodeExecutable, nodeRuntimeUnavailableMessage } from "@t3tools/shared/nodeRuntime"; import { resolveCommandPath } from "@t3tools/shared/shell"; @@ -42,13 +45,11 @@ import { parseAntigravityCliRelease, type AntigravityCliReleaseAsset, } from "./antigravityCliRelease.ts"; -import { openZipArchive } from "../zipArchive.ts"; import { makeAntigravityAcpRuntime } from "./acp/AntigravityAcpSupport.ts"; import { buildAntigravityAcpSpawnInput, prepareAntigravityProfile, } from "./antigravityAuthSupport.ts"; -import { type AntigravityReleaseAsset } from "./antigravityRelease.ts"; const DRIVER = ProviderDriverKind.make("antigravity"); const DOWNLOAD_TIMEOUT = "45 minutes"; @@ -59,29 +60,15 @@ const UPDATE_CHECK_INTERVAL = 60 * 60 * 1000; const FREE_SPACE_MARGIN = 256 * 1024 * 1024; const RECORD_MAX_BYTES = 8 * 1024; const RELEASE_RECORD = ".install-complete.json"; -const LAUNCHER_SETUP = - /^[\s@]*(?:|::[^&|<>]*|rem(?:\s[^&|<>]*|$)|set\s+"[^"=&|<>]+=[^"&|<>]*"\s*|(?:echo|set|setlocal|endlocal)(?:\s[^&|<>()]*)?)$/iu; -const LAUNCHER_COMMAND = - /^[\s@]*(?:"([^"]*agy_acp_server\.exe)"|([^\s"&|<>()@]*agy_acp_server\.exe))(?:\s[^&|<>()]*)?$/iu; const LARGE_PAGE_KERNEL_MESSAGE = "Google's linux-arm64 Antigravity runtime needs a kernel with 4 KiB memory pages, and this kernel uses larger pages (as on Asahi Linux or Raspberry Pi 5). Use a remote environment or a custom Antigravity executable."; -// The launcher runs in the project directory, so a target like `\x\agy_acp_server.exe` -// whose drive comes from the working directory may not be the file resolved here. -export const launcherTargetPath = (path: Path.Path, launcher: string, written: string) => { - const target = written.replace(/%~dp0/giu, () => `${path.dirname(launcher)}${path.sep}`); - if (/[%!]/u.test(target)) return null; - const resolved = path.resolve(target); - return path.parse(path.normalize(target)).root === path.parse(resolved).root ? resolved : null; -}; - const ReleaseId = Schema.String.check(Schema.isPattern(/^[a-f0-9]{64}$/u)); const ActiveRelease = Schema.Struct({ releaseId: ReleaseId }); const InstalledRelease = Schema.Struct({ releaseId: ReleaseId, version: Schema.String, executable: Schema.Struct({ name: Schema.String, bytes: Schema.Number }), - harness: Schema.NullOr(Schema.Struct({ name: Schema.String, bytes: Schema.Number })), }); type InstalledRelease = typeof InstalledRelease.Type; const encodeActiveRelease = Schema.encodeEffect(Schema.fromJsonString(ActiveRelease)); @@ -104,8 +91,6 @@ const isAcpProcessExitedError = Schema.is(EffectAcpErrors.AcpProcessExitedError) export interface AntigravityExecutable { readonly executablePath: string; - /** Null for the `agy` CLI, which embeds the harness and runs as `agy acp`. */ - readonly harnessPath: string | null; readonly source: "override" | "managed" | "path"; readonly version: string | null; readonly managedVersionDirectory: string | null; @@ -122,6 +107,9 @@ interface AntigravityInstallationService { binaryPath?: string, environment?: NodeJS.ProcessEnv, ) => Effect.Effect; + readonly compatibility: ( + version: string, + ) => Effect.Effect; readonly start: Effect.Effect; readonly cancel: ( operationId: string, @@ -156,7 +144,7 @@ export class AntigravityInstallation extends Context.Service< export interface AntigravityInstallationOptions { readonly baseDir: string; - readonly releaseAsset?: AntigravityReleaseAsset | AntigravityCliReleaseAsset | null; + readonly releaseAsset?: AntigravityCliReleaseAsset | null; readonly updateChecksEnabled?: Effect.Effect; readonly validate?: ( executable: AntigravityExecutable, @@ -174,13 +162,6 @@ const installationError = (operation: string, detail: string, cause?: unknown) = const wrapFailure = (operation: string, detail: string) => (cause: unknown) => isInstallationError(cause) ? cause : installationError(operation, detail, cause); -function executableNames(platform: NodeJS.Platform) { - return platform === "win32" - ? { executable: "agy_acp_server.exe", harness: "localharness_external.exe" } - : { executable: "agy_acp_server.par", harness: "localharness_external" }; -} - -/** Antigravity CLI 1.5.0+ serves ACP itself (`agy acp`), so it has no `localharness_external` sibling. */ function isAntigravityCli(...candidates: ReadonlyArray) { return candidates.some((candidate) => /^(?:agy|antigravity)(?:\.(?:exe|cmd|bat))?$/iu.test(candidate.split(/[\\/]/u).at(-1) ?? ""), @@ -211,7 +192,7 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma options.releaseAsset === undefined ? antigravityCliTarget(platform, arch) !== null : options.releaseAsset !== null; - const names = executableNames(platform); + const cliExecutableName = platform === "win32" ? "agy.exe" : "antigravity"; const managedDirectory = path.join( options.baseDir, "tools", @@ -240,24 +221,28 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma operationId: null, phase: "idle", downloadedBytes: 0, - totalBytes: - releaseAsset !== null && "archiveBytes" in releaseAsset ? releaseAsset.archiveBytes : null, + totalBytes: null, version: releaseAsset?.version ?? null, installedVersion: null, canRemove: false, message: null, }); - const isWithdrawn = Effect.fn("AntigravityInstallation.isWithdrawn")(function* (version: string) { + const compatibility = Effect.fn("AntigravityInstallation.compatibility")(function* ( + version: string, + ) { const manifest = yield* manifestService.current; - const status = ( + return ( resolveProviderCompatibility(manifest.compatibility, DRIVER, version) ?? resolveProviderCompatibility( ModelManifest.BUNDLED_MODEL_MANIFEST.compatibility, DRIVER, version, ) - )?.status; + ); + }); + const isWithdrawn = Effect.fn("AntigravityInstallation.isWithdrawn")(function* (version: string) { + const status = (yield* compatibility(version))?.status; return status === "broken" || status === "unsupported"; }); const ensureEligible = Effect.fn("AntigravityInstallation.ensureEligible")(function* ( @@ -303,22 +288,21 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma ) { const directory = path.join(versionsDirectory, releaseId); const record = yield* readRecord(path.join(directory, RELEASE_RECORD), InstalledRelease); + if (record.releaseId === releaseId && record.executable.name !== cliExecutableName) { + return yield* installationError( + "resolve", + `Antigravity ${record.version} predates the Antigravity CLI and no longer works with this T3 Code release. Update it in Antigravity setup.`, + ); + } if ( record.releaseId !== releaseId || - (record.harness === null - ? record.executable.name !== (platform === "win32" ? "agy.exe" : "antigravity") - : record.executable.name !== names.executable || record.harness.name !== names.harness) || !Number.isSafeInteger(record.executable.bytes) || record.executable.bytes <= 0 || - (record.harness !== null && - (!Number.isSafeInteger(record.harness.bytes) || record.harness.bytes <= 0)) || !record.version.trim() || !(yield* executableFile( path.join(directory, record.executable.name), record.executable.bytes, - )) || - (record.harness !== null && - !(yield* executableFile(path.join(directory, record.harness.name), record.harness.bytes))) + )) ) { return yield* installationError( "resolve", @@ -327,69 +311,32 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma } return { executablePath: path.join(directory, record.executable.name), - harnessPath: record.harness === null ? null : path.join(directory, record.harness.name), source: "managed", version: record.version, managedVersionDirectory: directory, } satisfies AntigravityExecutable; }); - // Infer helper pairing only from a plain launcher with one literal executable path. - const launcherTarget = Effect.fn("AntigravityInstallation.launcherTarget")(function* ( - launcher: string, - ) { - if (platform !== "win32" || !/\.(?:bat|cmd)$/iu.test(launcher)) return null; - const contents = yield* fs.readFileString(launcher); - const targets = new Set(); - for (const line of contents.split(/\r?\n/u)) { - if (line.includes("^")) return null; - if (/^[\s@]*exit(?:\s+\/b)?(?:\s+-?\d+)?\s*$/iu.test(line)) break; - if (LAUNCHER_SETUP.test(line)) continue; - const match = LAUNCHER_COMMAND.exec(line); - if (!match) return null; - const target = launcherTargetPath(path, launcher, match[1] ?? match[2] ?? ""); - if (target === null) return null; - targets.add(target); - } - const [target] = targets; - if (targets.size !== 1 || !target || !(yield* executableFile(target))) return null; - return yield* fs.realPath(target); - }); - const fromExternal = Effect.fn("AntigravityInstallation.fromExternal")(function* ( candidate: string, source: "override" | "path", ) { if (!(yield* executableFile(candidate))) return null; const executablePath = yield* fs.realPath(candidate); - const launched = yield* launcherTarget(executablePath); const realVersions = yield* fs.realPath(versionsDirectory).pipe(Effect.option); - const directory = path.dirname(launched ?? executablePath); + const directory = path.dirname(executablePath); if ( Option.isSome(realVersions) && path.dirname(directory) === realVersions.value && /^[a-f0-9]{64}$/u.test(path.basename(directory)) ) { const installed = yield* completedRelease(path.basename(directory)); - return launched === null - ? { ...installed, source } - : { ...installed, executablePath, source }; + return { ...installed, source }; } // Keep launcher symlinks intact: version-manager shims dispatch by their invoked name. - if (launched === null && isAntigravityCli(candidate, executablePath)) { - return { - executablePath: candidate, - harnessPath: null, - source, - version: null, - managedVersionDirectory: null, - } satisfies AntigravityExecutable; - } - const harnessPath = path.join(directory, names.harness); - if (!(yield* executableFile(harnessPath))) return null; + if (!isAntigravityCli(candidate, executablePath)) return null; return { - executablePath, - harnessPath, + executablePath: candidate, source, version: null, managedVersionDirectory: null, @@ -404,7 +351,7 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma Effect.provideService(Path.Path, path), ); - // Resolve per PATH entry so an executable without its harness falls through to later entries. + // Resolve per PATH entry so a candidate that is not the CLI falls through to later entries. const commandCandidates = Effect.fn("AntigravityInstallation.commandCandidates")(function* ( command: string, processEnvironment = environment, @@ -438,7 +385,7 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma } return yield* installationError( "resolve", - "The custom Antigravity executable is missing or not executable, or it needs a localharness_external sibling. The agy CLI does not.", + "The custom Antigravity executable is missing or not executable, or it is not the agy CLI.", ); } if (yield* fs.exists(activePath)) { @@ -451,11 +398,9 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma ); return installed; } - for (const command of [names.executable, "agy"]) { - for (const candidate of yield* commandCandidates(command, processEnvironment)) { - const selected = yield* fromExternal(candidate, "path"); - if (selected) return selected; - } + for (const candidate of yield* commandCandidates("agy", processEnvironment)) { + const selected = yield* fromExternal(candidate, "path"); + if (selected) return selected; } return yield* installationError( "resolve", @@ -549,11 +494,8 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma }); const initialized = yield* runtime.initialize(); if ( - (executable.harnessPath === null - ? initialized.agentInfo?.name !== "Antigravity ACP Server" - : initialized.agentInfo?.name !== "antigravity-acp") || + initialized.agentInfo?.name !== "Antigravity ACP Server" || initialized.agentInfo?.version !== expectedVersion || - // Antigravity 1.1.1 may report protocol 2 with legacy ACP; choose wire format from the response shape. (initialized.protocolVersion !== 1 && initialized.protocolVersion !== 2) || initialized.agentCapabilities?.loadSession !== true || !initialized.agentCapabilities.sessionCapabilities?.resume || @@ -599,12 +541,10 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma ); const install = Effect.fn("AntigravityInstallation.install")( - function* (asset: AntigravityReleaseAsset | AntigravityCliReleaseAsset) { + function* (asset: AntigravityCliReleaseAsset) { yield* ensureEligible(asset.version); - const cli = "sha512" in asset; - // Existing installation records use 64-character IDs, including native SHA-512 prefixes. - const releaseId = cli ? asset.sha512.slice(0, 64) : asset.sha256; - const archiveBytes = cli ? null : asset.archiveBytes; + // Release IDs are 64 hex characters, so a release is named by its SHA-512's prefix. + const releaseId = asset.sha512.slice(0, 64); yield* resolveNodeExecutable("Antigravity", environment).pipe( Effect.provideService(FileSystem.FileSystem, fs), Effect.provideService(Path.Path, path), @@ -613,18 +553,6 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma installationError("verify", nodeRuntimeUnavailableMessage("Antigravity"), cause), ), ); - if (!cli && platform === "linux" && arch === "arm64") { - const pageSize = yield* spawner - .string(ChildProcess.make("getconf", ["PAGESIZE"], { stdin: "ignore", stderr: "ignore" })) - .pipe( - Effect.map((output) => Number(output.trim())), - Effect.timeout("5 seconds"), - Effect.orElseSucceed(() => Number.NaN), - ); - if (pageSize > 4096) { - return yield* installationError("download", LARGE_PAGE_KERNEL_MESSAGE); - } - } const report = (phase: ProviderInstallState["phase"], message: string | null) => SubscriptionRef.update(state, (current) => ({ ...current, phase, message })); yield* fs.makeDirectory(versionsDirectory, { recursive: true }); @@ -683,9 +611,7 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma try: () => NodeFSP.statfs(versionsDirectory, { bigint: true }), catch: (cause) => installationError("download", "Could not check free disk space.", cause), }).pipe(Effect.option); - const required = cli - ? MAX_DOWNLOAD_BYTES + MAX_EXECUTABLE_BYTES + FREE_SPACE_MARGIN - : asset.archiveBytes + asset.executable.bytes + asset.harness.bytes + FREE_SPACE_MARGIN; + const required = MAX_DOWNLOAD_BYTES + MAX_EXECUTABLE_BYTES + FREE_SPACE_MARGIN; if ( Option.isSome(available) && available.value.bavail * available.value.bsize < BigInt(required) @@ -699,36 +625,21 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma directory: versionsDirectory, prefix: ".install-", }); - const archivePath = path.join(staging, "download.zip"); + const archivePath = path.join(staging, "download"); const pairDirectory = path.join(staging, "runtime"); yield* fs.makeDirectory(pairDirectory); - const hash = NodeCrypto.createHash(cli ? "sha512" : "sha256"); + const hash = NodeCrypto.createHash("sha512"); let downloadedBytes = 0; let lastProgressAt = yield* Clock.currentTimeMillis; yield* Effect.gen(function* () { const response = yield* http .execute(HttpClientRequest.get(asset.url)) .pipe(Effect.flatMap(HttpClientResponse.filterStatusOk)); - // dl.google.com may gzip the zip: content-length is encoded, while byte/hash checks use decoded data. - const contentLength = response.headers["content-length"]; - const contentEncoding = response.headers["content-encoding"]?.trim().toLowerCase(); - const identityBody = contentEncoding === undefined || contentEncoding === "identity"; - if ( - identityBody && - contentLength !== undefined && - archiveBytes !== null && - Number(contentLength) !== archiveBytes - ) { - return yield* installationError( - "download", - "The Antigravity download size did not match the pinned release.", - ); - } yield* response.stream.pipe( Stream.tap((chunk) => Effect.gen(function* () { downloadedBytes += chunk.byteLength; - if (downloadedBytes > (archiveBytes ?? MAX_DOWNLOAD_BYTES)) { + if (downloadedBytes > MAX_DOWNLOAD_BYTES) { return yield* installationError( "download", "The Antigravity download exceeded its allowed size.", @@ -736,7 +647,7 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma } hash.update(chunk); const now = yield* Clock.currentTimeMillis; - if (now - lastProgressAt >= 250 || downloadedBytes === archiveBytes) { + if (now - lastProgressAt >= 250) { lastProgressAt = now; yield* SubscriptionRef.update(state, (current) => ({ ...current, @@ -759,10 +670,7 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma : cause, ), ); - if ( - (archiveBytes !== null && downloadedBytes !== archiveBytes) || - hash.digest("hex") !== (cli ? asset.sha512 : asset.sha256) - ) { + if (hash.digest("hex") !== asset.sha512) { return yield* installationError( "download", "The Antigravity download failed its size or checksum check. Nothing was installed.", @@ -770,162 +678,57 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma } yield* report("extracting", "Extracting the verified runtime."); - if (cli) { - const executablePath = path.join(pairDirectory, asset.executable.name); - if (asset.format === "executable") { - yield* fs.copyFile(archivePath, executablePath); - } else { - const tar = cliArchiveTarCommand(platform, environment); - const list = yield* spawner.string(ChildProcess.make(tar, ["-tzf", archivePath])); - const types = yield* spawner.string(ChildProcess.make(tar, ["-tvzf", archivePath])); - if ( - list.trim() !== asset.executable.name || - types.trim().split(/\r?\n/u).length !== 1 || - !types.startsWith("-") - ) { - return yield* installationError( - "extract", - "The Antigravity archive must contain one regular executable.", - ); - } - yield* Effect.gen(function* () { - const child = yield* spawner.spawn( - ChildProcess.make(tar, ["-xOzf", archivePath, asset.executable.name], { - stdout: "pipe", - stderr: "pipe", - }), - ); - let extractedBytes = 0; - yield* child.stdout.pipe( - Stream.tap((chunk) => - Effect.gen(function* () { - extractedBytes += chunk.byteLength; - if (extractedBytes > MAX_EXECUTABLE_BYTES) - return yield* installationError( - "extract", - "The Antigravity executable exceeded its size limit.", - ); - }), - ), - Stream.run(fs.sink(executablePath, { flag: "wx", mode: 0o700 })), - ); - if ((yield* child.exitCode) !== 0 || extractedBytes === 0) - return yield* installationError( - "extract", - "Could not extract the Antigravity executable.", - ); - }).pipe(Effect.scoped); + const executablePath = path.join(pairDirectory, asset.executable.name); + if (asset.format === "executable") { + yield* fs.copyFile(archivePath, executablePath); + } else { + const tar = cliArchiveTarCommand(platform, environment); + const list = yield* spawner.string(ChildProcess.make(tar, ["-tzf", archivePath])); + const types = yield* spawner.string(ChildProcess.make(tar, ["-tvzf", archivePath])); + if ( + list.trim() !== asset.executable.name || + types.trim().split(/\r?\n/u).length !== 1 || + !types.startsWith("-") + ) { + return yield* installationError( + "extract", + "The Antigravity archive must contain one regular executable.", + ); } - } else yield* Effect.gen(function* () { - const archive = yield* openZipArchive(archivePath, (detail, cause) => - installationError("extract", detail, cause), + const child = yield* spawner.spawn( + ChildProcess.make(tar, ["-xOzf", archivePath, asset.executable.name], { + stdout: "pipe", + stderr: "pipe", + }), ); - if (archive.entryCount !== 2) { - return yield* installationError( - "extract", - "The archive must contain exactly the Antigravity executable and its harness.", - ); - } - const seen = new Set(); - for (;;) { - const entry = yield* archive.next; - if (!entry) break; - const expected = [asset.executable, asset.harness].find( - (file) => file.name === entry.fileName, - ); - const unixType = (entry.externalFileAttributes >>> 16) & 0o170000; - if ( - !expected || - seen.has(entry.fileName) || - entry.fileName.includes("/") || - entry.fileName.includes("\\") || - (unixType !== 0 && unixType !== 0o100000) || - (entry.externalFileAttributes & 0x10) !== 0 || - (entry.generalPurposeBitFlag & 1) !== 0 || - ![0, 8].includes(entry.compressionMethod) || - entry.uncompressedSize !== expected.bytes - ) { - return yield* installationError( - "extract", - "The archive contains an unexpected, unsafe, or incorrectly sized member.", - ); - } - seen.add(entry.fileName); - yield* Effect.gen(function* () { - const readable = yield* archive.streamEntry(entry); - let extractedBytes = 0; - yield* EffectNodeStream.fromReadable({ - evaluate: () => readable, - onError: wrapFailure("extract", "Could not extract the Antigravity runtime."), - }).pipe( - Stream.tap((chunk) => - Effect.gen(function* () { - extractedBytes += chunk.byteLength; - if (extractedBytes > expected.bytes) { - return yield* installationError( - "extract", - "An archive member exceeded its pinned size.", - ); - } - }), - ), - Stream.run( - fs.sink(path.join(pairDirectory, entry.fileName), { flag: "wx", mode: 0o700 }), - ), - ); - if (extractedBytes !== expected.bytes) { - return yield* installationError("extract", "An archive member was truncated."); - } - }).pipe(Effect.scoped); - } - if (!seen.has(asset.executable.name) || !seen.has(asset.harness.name)) { + let extractedBytes = 0; + yield* child.stdout.pipe( + Stream.tap((chunk) => + Effect.gen(function* () { + extractedBytes += chunk.byteLength; + if (extractedBytes > MAX_EXECUTABLE_BYTES) + return yield* installationError( + "extract", + "The Antigravity executable exceeded its size limit.", + ); + }), + ), + Stream.run(fs.sink(executablePath, { flag: "wx", mode: 0o700 })), + ); + if ((yield* child.exitCode) !== 0 || extractedBytes === 0) return yield* installationError( "extract", - "The archive is missing the Antigravity executable or its harness.", + "Could not extract the Antigravity executable.", ); - } }).pipe(Effect.scoped); - yield* fs.remove(archivePath); - const executablePath = path.join(pairDirectory, asset.executable.name); - const harnessPath = cli ? null : path.join(pairDirectory, asset.harness.name); - if (platform !== "win32") { - yield* fs.chmod(executablePath, 0o755); - if (harnessPath !== null) yield* fs.chmod(harnessPath, 0o755); - } - if (!cli && platform === "darwin" && arch === "x64") { - // Google signs the Intel build with the hardened runtime but no JIT entitlement, so - // libffi's writable+executable trampolines spin forever. Re-sign ad hoc after the hash check. - const exitCode = yield* spawner - .spawn( - ChildProcess.make( - "/usr/bin/codesign", - [ - "--force", - "--sign", - "-", - executablePath, - ...(harnessPath === null ? [] : [harnessPath]), - ], - { stdout: "ignore", stderr: "ignore" }, - ), - ) - .pipe( - Effect.flatMap((child) => child.exitCode), - Effect.scoped, - ); - if (exitCode !== 0) { - return yield* installationError( - "extract", - "Could not prepare the Antigravity runtime for this Mac. Check that codesign is available.", - ); - } } + yield* fs.remove(archivePath); + if (platform !== "win32") yield* fs.chmod(executablePath, 0o755); yield* report("verifying", "Checking the downloaded runtime."); yield* validate( { executablePath, - harnessPath, source: "managed", version: asset.version, managedVersionDirectory: pairDirectory, @@ -939,10 +742,6 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma name: asset.executable.name, bytes: Number((yield* fs.stat(executablePath)).size), }, - harness: - cli || harnessPath === null - ? null - : { name: asset.harness.name, bytes: Number((yield* fs.stat(harnessPath)).size) }, }; yield* fs.writeFileString( path.join(pairDirectory, RELEASE_RECORD), @@ -1054,7 +853,6 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma const reuse = Option.isSome(installed) && installed.value.source === "managed" && - installed.value.harnessPath === null && (asset === null || compareSemverVersions(installed.value.version!, asset.version) > 0) ? installed.value : undefined; @@ -1069,7 +867,7 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma operationId, phase: reuse === undefined ? "downloading" : "verifying", downloadedBytes: 0, - totalBytes: asset !== null && "archiveBytes" in asset ? asset.archiveBytes : null, + totalBytes: null, version: reuse?.version ?? asset?.version ?? null, installedVersion: current.installedVersion, canRemove: current.canRemove, @@ -1217,14 +1015,16 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma installedVersion: installed.version, })); }).pipe( - Effect.catch(() => + Effect.catch((cause) => SubscriptionRef.update( state, (current) => ({ ...current, phase: "failed", - message: "The managed Antigravity runtime is incomplete. Remove it and reinstall.", + message: isInstallationError(cause) + ? cause.detail + : "The managed Antigravity runtime is incomplete. Remove it and reinstall.", }) satisfies ProviderInstallState, ), ), @@ -1237,6 +1037,7 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma managedDirectory, resolve, acquire, + compatibility, start, cancel, state: SubscriptionRef.get(state), diff --git a/apps/server/src/provider/AntigravityProvider.test.ts b/apps/server/src/provider/AntigravityProvider.test.ts index da518379487b2..05a9a75cbd92b 100644 --- a/apps/server/src/provider/AntigravityProvider.test.ts +++ b/apps/server/src/provider/AntigravityProvider.test.ts @@ -47,7 +47,7 @@ const initializeResult = { agentInfo: { name: "antigravity-acp", title: "Google Antigravity", - version: "agy_acp_server_20260818_01_RC01", + version: "1.5.12", }, } satisfies EffectAcpSchema.InitializeResponse; @@ -334,7 +334,7 @@ it.layer(layerTest)("Antigravity provider snapshots", (it) => { expect(snapshot).toMatchObject({ installed: true, status: "warning", - version: "agy_acp_server_20260818_01_RC01", + version: "1.5.12", auth: { status: "unknown", ...(auth ? { type: auth.type } : {}) }, message: auth?.type === "gemini-api-key" || auth?.type === "agent-platform" @@ -495,7 +495,7 @@ it.layer(layerTest)("Antigravity provider snapshots", (it) => { ...started, initializeResult: { ...initializeResult, - agentInfo: { ...initializeResult.agentInfo, version: "1.4.0" }, + agentInfo: { ...initializeResult.agentInfo, version: "1.5.13" }, }, }); yield* Ref.set( @@ -505,7 +505,7 @@ it.layer(layerTest)("Antigravity provider snapshots", (it) => { agentInfo: { ...initializeResult.agentInfo, version: "unknown" }, }), ); - expect((yield* harness.provider.snapshot.refresh).version).toBe("1.4.0"); + expect((yield* harness.provider.snapshot.refresh).version).toBe("1.5.13"); }), ); diff --git a/apps/server/src/provider/Drivers/AntigravityDriver.test.ts b/apps/server/src/provider/Drivers/AntigravityDriver.test.ts index 2ee99a6fbbfe3..3c0135f419c66 100644 --- a/apps/server/src/provider/Drivers/AntigravityDriver.test.ts +++ b/apps/server/src/provider/Drivers/AntigravityDriver.test.ts @@ -4,6 +4,7 @@ import { expect, it } from "@effect/vitest"; import { ANTIGRAVITY_DEFAULT_MODEL, EnvironmentId, + ProviderDriverKind, ProviderInstanceId, ProviderSessionId, ThreadId, @@ -32,6 +33,8 @@ import * as McpProviderSessions from "@t3tools/provider-core/server/McpProviderS import * as ModelManifest from "../ModelManifest.ts"; import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator"; import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter"; +import { knownProviderFailureMessage } from "@t3tools/provider-core/server/failure"; +import { resolveProviderCompatibility } from "../providerCompatibility.ts"; import { AntigravityDriver } from "./AntigravityDriver.ts"; import * as ProviderHostLive from "../ProviderHostLive.ts"; import * as ServerSecretStore from "../../auth/ServerSecretStore.ts"; @@ -81,6 +84,7 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* ( const profileDirectory = directories.profile; const instancePath = `${path.join(root, "instance-bin")}:${baseEnv.PATH ?? ""}`; + const agentExecutables = new Set(); const makeExecutable = Effect.fn("AntigravityDriverTest.makeExecutable")(function* ( name: string, options: { @@ -88,11 +92,11 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* ( /** `data` of the agent's "Internal error" response to `session/new`. */ readonly newSessionErrorData?: unknown; readonly initialMode?: string; + readonly agentVersion?: string; } = {}, ) { const directory = path.join(root, name); - const executablePath = path.join(directory, "agy_acp_server.par"); - const harnessPath = path.join(directory, "localharness_external"); + 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"; @@ -111,16 +115,15 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* ( ...(options.initialMode === undefined ? [] : [`export T3_ACP_INITIAL_MODE=${shellQuote(options.initialMode)}`]), + `export T3_ACP_AGENT_VERSION=${shellQuote(options.agentVersion ?? "1.5.12")}`, `exec ${shellQuote(nodePath)} ${shellQuote(mockAgentPath)} "$@"`, "", ].join("\n"), ); - yield* fs.writeFileString(harnessPath, "#!/bin/sh\nexit 99\n"); yield* fs.chmod(executablePath, 0o755); - yield* fs.chmod(harnessPath, 0o755); + agentExecutables.add(executablePath); return { executablePath, - harnessPath, source: "managed", version: name, managedVersionDirectory: directory, @@ -144,7 +147,6 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* ( extendEnv: boolean | undefined; environment: Record; profileDirectory: string | undefined; - harnessPath: string | undefined; forceFileStorage: string | undefined; credentialKeys: ReadonlyArray; geminiApiKey: string | undefined; @@ -154,6 +156,14 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* ( const layerInstallation = Layer.mock(AntigravityInstallation.AntigravityInstallation)({ managedDirectory: root, + compatibility: (version) => + Effect.succeed( + resolveProviderCompatibility( + ModelManifest.BUNDLED_MODEL_MANIFEST.compatibility, + ProviderDriverKind.make("antigravity"), + version, + ), + ), resolve: () => Effect.gen(function* () { if (controls.failResolution) { @@ -200,14 +210,12 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* ( extendEnv: command.options.extendEnv, environment: Object.fromEntries(Object.keys(environment).map((name) => [name, env(name)])), profileDirectory: env("GEMINI_HOME"), - harnessPath: env("ANTIGRAVITY_HARNESS_PATH"), forceFileStorage: env("AGY_ACP_FORCE_FILE_STORAGE"), credentialKeys: Object.keys(environment).filter((key) => blockedCredentialKeys.has(key.toUpperCase()), ), geminiApiKey: env("GEMINI_API_KEY"), - tempDirectory: - environment.ANTIGRAVITY_HARNESS_PATH === undefined ? undefined : env("TMPDIR"), + tempDirectory: agentExecutables.has(command.command) ? env("TMPDIR") : undefined, handle, }); return handle; @@ -227,7 +235,6 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* ( { name: "GOOGLE_APPLICATION_CREDENTIALS", value: "/must-not-be-used.json" }, { name: "GOOGLE_GENAI_USE_VERTEXAI", value: "true" }, { name: "GEMINI_HOME", value: "/must-not-be-used" }, - { name: "ANTIGRAVITY_HARNESS_PATH", value: "/must-not-be-used" }, { name: "BROWSER", value: "must-not-run" }, ...(options.environment ?? []), ].map((variable) => ({ ...variable, sensitive: false })), @@ -329,19 +336,18 @@ it.layer(layerTest)("AntigravityDriver", (it) => { { binaryPath: "", path: h.instancePath }, { binaryPath: "", path: h.instancePath }, ]); - const nativeLaunches = h.launches.filter((launch) => launch.harnessPath !== undefined); - expect(nativeLaunches.map((launch) => launch.command)).toEqual([ + const agentLaunches = h.launches.filter((launch) => launch.tempDirectory !== undefined); + expect(agentLaunches.map((launch) => launch.command)).toEqual([ h.first.executablePath, h.second.executablePath, ]); - expect(nativeLaunches.map((launch) => launch.harnessPath)).toEqual([ - h.first.harnessPath, - h.second.harnessPath, - ]); - for (const launch of nativeLaunches) { + for (const launch of agentLaunches) { expect(launch.args).toEqual([ - ...(hostPlatform === "linux" ? ["--uid="] : []), - "--alsologtostderr", + "acp", + "--gemini-dir", + h.profileDirectory, + "--app-data-dir", + "antigravity-acp", ]); expect(launch.profileDirectory).toBe(h.profileDirectory); expect(launch.forceFileStorage).toBe("1"); @@ -415,10 +421,7 @@ it.layer(layerTest)("AntigravityDriver", (it) => { ]); // The agy CLI rejects `yolo` and `auto_edit`; it stays in `default` and T3 answers its requests. - h.controls.selected = { - ...(yield* h.makeExecutable("runtime cli", { initialMode: "auto_edit" })), - harnessPath: null, - }; + h.controls.selected = yield* h.makeExecutable("runtime cli", { initialMode: "auto_edit" }); for (const runtimeMode of ["full-access", "auto-accept-edits"] as const) { const requestsBefore = (yield* h.readRequests).length; const cliThreadId = ThreadId.make(`thread-antigravity-cli-${runtimeMode}`); @@ -532,6 +535,42 @@ it.layer(layerTest)("AntigravityDriver", (it) => { }), ); + it.effect.skipIf(windowsHost)( + "refuses to open a session on a PATH executable older than 1.5", + () => + Effect.gen(function* () { + const h = yield* makeHarness(); + const old = yield* h.makeExecutable("runtime old", { agentVersion: "1.4.5" }); + h.controls.selected = { ...old, source: "path", version: null }; + const threadId = ThreadId.make("thread-antigravity-old-runtime"); + const modelSelection = { instanceId: h.instance.instanceId, model: "gemini-test-low" }; + const error = yield* Effect.scoped( + Effect.gen(function* () { + const workspace = yield* h.fs.makeTempDirectoryScoped({ prefix: "t3-ag-old-runtime-" }); + const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({ + runtimeMode: "approval-required", + interactionMode: "default", + cwd: workspace, + }); + const session = yield* h.instance.orchestrationAdapter.openSession({ + threadId, + providerSessionId: ProviderSessionId.make("provider-session-antigravity-old-runtime"), + modelSelection, + runtimePolicy, + }); + yield* session.ensureThread({ threadId, modelSelection, runtimePolicy }); + }), + ).pipe(Effect.flip); + const message = `Antigravity 1.4.5 does not work with this T3 Code release. Update the Antigravity executable at ${old.executablePath} to >=1.5.12 <2, then retry.`; + expect(knownProviderFailureMessage(error)).toBe(message); + expect((yield* h.refresh().pipe(Effect.flip)).detail).toBe(message); + const methods = (yield* h.readRequests).map((request) => request.method); + expect(methods).toContain("initialize"); + expect(methods).not.toContain("session/new"); + yield* h.assertClosed; + }), + ); + it.effect.skipIf(windowsHost)( "closes refresh processes and clears account metadata when Google sign-in is required", () => diff --git a/apps/server/src/provider/Drivers/AntigravityDriver.ts b/apps/server/src/provider/Drivers/AntigravityDriver.ts index 2114aec8e5c60..45ec6920499f6 100644 --- a/apps/server/src/provider/Drivers/AntigravityDriver.ts +++ b/apps/server/src/provider/Drivers/AntigravityDriver.ts @@ -18,7 +18,6 @@ import * as Effect from "effect/Effect"; import * as Exit from "effect/Exit"; import * as Fiber from "effect/Fiber"; import * as FileSystem from "effect/FileSystem"; -import * as Option from "effect/Option"; import * as Path from "effect/Path"; import * as Schema from "effect/Schema"; import * as Scope from "effect/Scope"; @@ -84,6 +83,7 @@ const DRIVER = ProviderDriverKind.make("antigravity"); const decodeSettings = Schema.decodeSync(AntigravitySettings); const isNodeRuntimeUnavailableError = Schema.is(NodeRuntimeUnavailableError); const isAcpRequestError = Schema.is(AcpErrors.AcpRequestError); +const isProviderSetupError = Schema.is(ProviderSetupError); const isAcpErrorDetails = Schema.is(Schema.Struct({ details: Schema.String })); const REFRESH_FAILED = "Could not refresh Antigravity models. The previous model list is unchanged."; @@ -313,22 +313,38 @@ export const AntigravityDriver: ProviderDriver< childProcessSpawner: spawner, spawn, }).pipe(Effect.provideService(SecureRandom.SecureRandom, random)); + // A custom or PATH executable has no version until it answers initialize. + const startCompatible = Effect.fn("AntigravityDriver.startCompatible")(function* () { + const version = (yield* runtime.initialize()).agentInfo?.version; + const advisory = version ? yield* installation.compatibility(version) : undefined; + if (advisory?.status === "broken") { + const target = + advisory.recommendedVersion ?? advisory.recommendedRange ?? "a newer version"; + const update = + executable.source === "managed" + ? `Update it in Antigravity setup to ${target}` + : `Update the Antigravity executable at ${executable.executablePath} to ${target}`; + const cause = new ProviderSetupError({ + instanceId, + operation: "runtime", + detail: `Antigravity ${version} does not work with this T3 Code release. ${update}, then retry.`, + }); + return yield* new AcpErrors.AcpTransportError({ detail: cause.detail, cause }); + } + return yield* runtime.start(); + }); return { ...runtime, - ...(executable.harnessPath === null - ? { setMode: (modeId: string) => runtime.setMode(antigravityCliSessionMode(modeId)) } - : {}), + setMode: (modeId: string) => runtime.setMode(antigravityCliSessionMode(modeId)), start: () => - runtime - .start() - .pipe( - Effect.tapError((cause): Effect.Effect => - runtimeInput.onAuthorizationUrl === undefined && - isAntigravitySignInRequiredError(cause) - ? provider.onAuthRequired - : Effect.void, - ), + startCompatible().pipe( + Effect.tapError((cause): Effect.Effect => + runtimeInput.onAuthorizationUrl === undefined && + isAntigravitySignInRequiredError(cause) + ? provider.onAuthRequired + : Effect.void, ), + ), }; }); @@ -382,10 +398,6 @@ export const AntigravityDriver: ProviderDriver< readonly onAuthorizationUrl: (url: string) => Effect.Effect; }) { if (auth.authMethod !== "oauth-personal") return undefined; - const resolved = yield* installation - .resolve(settings.binaryPath, processEnvironment) - .pipe(Effect.option); - if (Option.isSome(resolved) && resolved.value.harnessPath !== null) return undefined; const cwd = yield* fileSystem .makeTempDirectoryScoped({ prefix: "t3-antigravity-login-" }) .pipe( @@ -398,8 +410,7 @@ export const AntigravityDriver: ProviderDriver< }), ), ); - const { executable, spawn } = yield* prepareSpawn(cwd, processEnvironment); - if (executable.harnessPath !== null) return undefined; + const { spawn } = yield* prepareSpawn(cwd, processEnvironment); const failed = (detail: string, cause?: unknown) => new ProviderSetupError({ instanceId, operation: "start", detail, cause }); // Without a display it prints the link only, instead of opening a browser on this machine. @@ -651,7 +662,11 @@ export const AntigravityDriver: ProviderDriver< : cause._tag === "ProviderSetupError" && (cause.operation === "configure" || cause.operation === "start") ? cause.detail - : refreshFailureDetail(cause), + : cause._tag === "AcpTransportError" && + isProviderSetupError(cause.cause) && + cause.cause.operation === "runtime" + ? cause.cause.detail + : refreshFailureDetail(cause), cause, }), ), diff --git a/apps/server/src/provider/ModelManifest.test.ts b/apps/server/src/provider/ModelManifest.test.ts index 0b4c4c062dca5..0aac6b4968a36 100644 --- a/apps/server/src/provider/ModelManifest.test.ts +++ b/apps/server/src/provider/ModelManifest.test.ts @@ -377,6 +377,8 @@ describe("ModelManifest service", () => { for (const stale of [ undatedManifest, { ...REMOTE_MANIFEST, updatedAt: "2000-01-01T00:00:00Z" }, + // The last bundle before Antigravity below 1.5 became broken. + { ...REMOTE_MANIFEST, updatedAt: "2026-11-14T15:58:47Z" }, ]) { yield* fs.writeFileString( cachePath, diff --git a/apps/server/src/provider/ProviderRegistry.test.ts b/apps/server/src/provider/ProviderRegistry.test.ts index 64a9b97f3605a..e4ec16b77dde0 100644 --- a/apps/server/src/provider/ProviderRegistry.test.ts +++ b/apps/server/src/provider/ProviderRegistry.test.ts @@ -2094,7 +2094,7 @@ it.layer( installed: true, auth: { status: "authenticated", type: "oauth-personal", label: "Google account" }, checkedAt: "2026-09-05T00:00:00.000Z", - version: "agy_acp_server_1.1.1", + version: "1.5.12", models: [ { slug: "gemini-3.7-flash-high", diff --git a/apps/server/src/provider/acp/AntigravityAcpSupport.test.ts b/apps/server/src/provider/acp/AntigravityAcpSupport.test.ts index dc755d1e7a5a4..c289043dd4a39 100644 --- a/apps/server/src/provider/acp/AntigravityAcpSupport.test.ts +++ b/apps/server/src/provider/acp/AntigravityAcpSupport.test.ts @@ -5,7 +5,6 @@ import { PROVIDER_SEND_TURN_MAX_IMAGE_BYTES, type ChatAttachment, } from "@t3tools/contracts"; -import * as HostProcess from "@t3tools/shared/HostProcess"; import * as Effect from "effect/Effect"; import * as FileSystem from "effect/FileSystem"; import * as Path from "effect/Path"; @@ -19,7 +18,6 @@ import { antigravityClientInfo, antigravitySessionMeta, buildAntigravityPrompt, - isQualifiedAntigravityRelease, } from "./AntigravityAcpSupport.ts"; const modelConfig = { @@ -60,41 +58,30 @@ function makeModelRuntime( describe("Antigravity release gates", () => { it.each([ - { version: "1.4.1", filter: false, native: false, ownName: false, advertisedAppend: false }, - { version: "1.4.2", filter: true, native: false, ownName: false, advertisedAppend: false }, - { version: "1.4.4", filter: true, native: false, ownName: false, advertisedAppend: false }, - { version: "1.4.5", filter: true, native: true, ownName: false, advertisedAppend: false }, - { version: "1.4.6", filter: false, native: false, ownName: false, advertisedAppend: false }, - { version: "1.5.0", filter: false, native: false, ownName: false, advertisedAppend: false }, - { version: "1.5.1", filter: false, native: false, ownName: true, advertisedAppend: false }, - { version: "1.5.7", filter: false, native: false, ownName: true, advertisedAppend: true }, - { version: "1.3.0", filter: false, native: false, ownName: false, advertisedAppend: false }, - { version: undefined, filter: false, native: false, ownName: false, advertisedAppend: false }, - { version: "unknown", filter: false, native: false, ownName: false, advertisedAppend: false }, + { version: "1.5.0", ownName: false, advertisedAppend: false }, + { version: "1.5.1", ownName: true, advertisedAppend: false }, + { version: "1.5.7", ownName: true, advertisedAppend: true }, + { version: undefined, ownName: false, advertisedAppend: false }, + { version: "unknown", ownName: false, advertisedAppend: false }, ])( - "$version: workflow filter $filter, qualified reads $native, advertised system append $advertisedAppend, own client name $ownName", - ({ version, filter, native, ownName, advertisedAppend }) => { + "$version: advertised system append $advertisedAppend, own client name $ownName", + ({ version, ownName, advertisedAppend }) => { const initialize = { protocolVersion: 1, ...(advertisedAppend ? { agentCapabilities: { _meta: { antigravity: { systemPrompt: { append: true } } } } } : {}), - ...(version === undefined ? {} : { agentInfo: { name: "antigravity-acp", version } }), - }; - // Helpers send no append, so only the workflow filter can apply. - expect(antigravitySessionMeta(initialize)).toEqual( - filter ? { antigravity: { disabledTools: ["run_workflow"] } } : undefined, - ); - const antigravity = { - ...(filter ? { disabledTools: ["run_workflow"] } : {}), - ...(native || advertisedAppend - ? { systemPrompt: { append: "" } } - : {}), + ...(version === undefined + ? {} + : { agentInfo: { name: "Antigravity ACP Server", version } }), }; + // Helpers send no append. + expect(antigravitySessionMeta(initialize)).toBeUndefined(); expect(antigravitySessionMeta(initialize, "")).toEqual( - filter || native || advertisedAppend ? { antigravity } : undefined, + advertisedAppend + ? { antigravity: { systemPrompt: { append: "" } } } + : undefined, ); - expect(isQualifiedAntigravityRelease(version)).toBe(native); expect(antigravityClientInfo(version).name).toBe(ownName ? "t3-code" : "zed"); }, ); @@ -380,89 +367,6 @@ it.layer(NodeServices.layer)("buildAntigravityPrompt", (it) => { }), ); - it.effect.each([ - { - case: "a Gemini model id", - model: { id: "gemini-3.8-flash", name: "Gemini 3.8 Flash" }, - linked: true, - }, - { - case: "an opaque id named Gemini", - model: { id: "agy-model", name: "Gemini 4 Carbon" }, - linked: true, - }, - { case: "an unknown model", model: { id: "agy-custom", name: "Custom" }, linked: false }, - { case: "an unlisted opaque id", model: { id: "agy-custom", name: undefined }, linked: false }, - { case: "an unresolved model", model: undefined, linked: false }, - { - case: "a Claude model", - model: { id: "claude-opus-5-5", name: "Claude Opus 5.5" }, - linked: false, - }, - { - case: "an unqualified runtime", - agentVersion: "1.4.1", - model: { id: "gemini-3.8-flash", name: "Gemini 3.8 Flash" }, - linked: false, - }, - { - case: "a Windows host", - platform: "win32" as const, - model: { id: "gemini-3.8-flash", name: "Gemini 3.8 Flash" }, - linked: false, - }, - { - case: "a clip over 20 MiB", - model: { id: "gemini-3.8-flash", name: "Gemini 3.8 Flash" }, - linked: false, - sizeBytes: 20 * 1024 * 1024 + 1, - }, - ])( - "links an MP4 for $case only when supported", - ({ agentVersion = "1.4.5", platform = "linux", model, linked, ...size }) => - Effect.gen(function* () { - const fixture = yield* makeAttachmentFixture(); - const clip = { - ...textAttachment, - id: "clip", - name: "clip.mp4", - mimeType: "video/mp4", - sizeBytes: 6 * 1024 * 1024, - ...size, - }; - const upload = yield* fixture.write(clip, ""); - yield* fixture.fs.truncate(upload.filePath, clip.sizeBytes); - const prompt = yield* buildAntigravityPrompt({ - input: "What colors appear?", - attachments: [clip], - resolveAttachmentPath: fixture.resolve, - promptCapabilities: { image: true, audio: true, embeddedContext: true }, - agentVersion, - currentModel: model, - }).pipe( - Effect.provideService(HostProcess.Platform, platform), - Effect.provideService(FileSystem.FileSystem, { - ...fixture.fs, - stream: () => Effect.die("Linked video is read by the agent").pipe(Stream.fromEffect), - }), - ); - expect(prompt).toEqual([ - { type: "text", text: "What colors appear?" }, - ...(linked - ? [ - { - type: "resource_link", - uri: upload.uri, - name: "clip.mp4", - mimeType: "video/mp4", - size: clip.sizeBytes, - }, - ] - : []), - ]); - }), - ); - it.effect.each([undefined, {}, { image: false, audio: false, embeddedContext: false }])( "keeps attachments path-only when native prompt capabilities are absent: %s", (promptCapabilities) => diff --git a/apps/server/src/provider/acp/AntigravityAcpSupport.ts b/apps/server/src/provider/acp/AntigravityAcpSupport.ts index 67dff6d07b039..a9c30c1019704 100644 --- a/apps/server/src/provider/acp/AntigravityAcpSupport.ts +++ b/apps/server/src/provider/acp/AntigravityAcpSupport.ts @@ -6,7 +6,6 @@ import { type ProviderSendTurnInput, type RuntimeMode, } from "@t3tools/contracts"; -import * as HostProcess from "@t3tools/shared/HostProcess"; import * as SecureRandom from "effect/crypto/SecureRandom"; import * as Effect from "effect/Effect"; import * as FileSystem from "effect/FileSystem"; @@ -42,10 +41,10 @@ export interface AntigravityAcpRuntimeInput extends Omit< > { readonly childProcessSpawner: ChildProcessSpawner.ChildProcessSpawner["Service"]; readonly onAuthorizationUrl?: (url: string) => Effect.Effect; - /** Serve `fs/read_text_file` for runtimes whose native reader is not qualified. */ + /** Serve `fs/read_text_file` from T3 instead of the agent's native reader. */ readonly clientFileReads?: boolean; readonly clientCapabilities?: AcpSessionRuntime.AcpSessionRuntimeOptions["clientCapabilities"]; - /** The installed version, known before `initialize`; it picks the file reader and client name. */ + /** The installed version, known before `initialize`; it picks the client name. */ readonly runtimeVersion?: string | null; /** Conversational sessions only; helpers and probes leave the system prompt untouched. */ readonly sessionSystemPromptAppend?: string; @@ -65,27 +64,6 @@ function compareVersions(left: ReadonlyArray, right: ReadonlyArray= 0 && - compareVersions(parsed, [1, 4, 5]) <= 0 - ); -} - -/** - * Releases T3 qualified for native range reads and linked video. On 1.4.5 the client-read path - * sends a whole file to serve one line, and the native reader keeps diff edits. - */ -export function isQualifiedAntigravityRelease(version: string | null | undefined): boolean { - return version?.trim() === "1.4.5"; -} - // `agy acp` 1.5.1 offers every model to every ACP client; older runtimes allowlist editors. const OPEN_MODEL_ACCESS_RELEASE = [1, 5, 1] as const; // `agy acp` 1.5.0 steers a running turn with the next prompt; the 1.4 harness queues it. @@ -98,14 +76,9 @@ export const antigravitySteersWithPrompt = ( return parsed !== undefined && compareVersions(parsed, PROMPT_STEERING_RELEASE) >= 0; }; -/** - * 1.4.5 appends `systemPrompt.append` to its system instructions on new, load and resume, and - * keeps none of it between processes, so every activation sends it again. - */ export const antigravityAppendsSystemPrompt = ( initializeResult: EffectAcpSchema.InitializeResponse, ) => { - if (isQualifiedAntigravityRelease(initializeResult.agentInfo?.version)) return true; const extension = initializeResult.agentCapabilities?._meta?.antigravity; return ( Predicate.isObject(extension) && @@ -118,15 +91,9 @@ export function antigravitySessionMeta( initializeResult: EffectAcpSchema.InitializeResponse, systemPromptAppend?: string, ): EffectAcpSchema.NewSessionRequest["_meta"] | undefined { - const antigravity = { - ...(antigravityWritesRunWorkflowSkill(initializeResult.agentInfo?.version) - ? { disabledTools: ["run_workflow"] } - : {}), - ...(systemPromptAppend !== undefined && antigravityAppendsSystemPrompt(initializeResult) - ? { systemPrompt: { append: systemPromptAppend } } - : {}), - }; - return Object.keys(antigravity).length === 0 ? undefined : { antigravity }; + return systemPromptAppend !== undefined && antigravityAppendsSystemPrompt(initializeResult) + ? { antigravity: { systemPrompt: { append: systemPromptAppend } } } + : undefined; } /** Older releases offer non-Gemini models only to allowlisted clients such as Zed. */ @@ -158,8 +125,7 @@ export const makeAntigravityAcpRuntime = Effect.fn("makeAntigravityAcpRuntime")( ...input.clientCapabilities, // Advertising writes swaps the agent's diff edits for whole-file client_edit_file. fs: { - readTextFile: - input.clientFileReads === true && !isQualifiedAntigravityRelease(input.runtimeVersion), + readTextFile: input.clientFileReads === true, writeTextFile: false, }, terminal: false, @@ -321,18 +287,6 @@ const AUDIO_MIME_TYPES = new Set([ "audio/webm", ]); const ANTIGRAVITY_MAX_AUDIO_ATTACHMENT_BYTES = 20 * 1024 * 1024; -// The agent inlines linked video bytes into one model request, so keep it under the inline limit. -const ANTIGRAVITY_MAX_VIDEO_ATTACHMENT_BYTES = 20 * 1024 * 1024; - -/** - * Only Gemini takes video. The evidence is the session's resolved model, so an account default - * counts once the agent reports it; opaque ids such as `agy-model` need a Gemini display name. - */ -function antigravityModelAcceptsVideo( - model: { readonly id: string; readonly name: string | undefined } | undefined, -): boolean { - return model !== undefined && (/^gemini-/i.test(model.id) || /^gemini\b/i.test(model.name ?? "")); -} const TEXT_MIME_TYPES = new Set([ "application/json", "application/ld+json", @@ -402,9 +356,6 @@ export const buildAntigravityPrompt = Effect.fn("buildAntigravityPrompt")(functi attachment: NonNullable[number], ) => string | null; readonly promptCapabilities: EffectAcpSchema.AgentCapabilities["promptCapabilities"]; - /** Linked video needs a runtime whose `resource_link` handling is qualified and a Gemini model. */ - readonly agentVersion?: string | undefined; - readonly currentModel?: { readonly id: string; readonly name: string | undefined } | undefined; }): Effect.fn.Return< ReadonlyArray, EffectAcpErrors.AcpError, @@ -412,8 +363,6 @@ export const buildAntigravityPrompt = Effect.fn("buildAntigravityPrompt")(functi > { const fileSystem = yield* FileSystem.FileSystem; const path = yield* Path.Path; - // The agent runs on this host. - const platform = yield* HostProcess.Platform; const blocks: Array = []; const text = input.input?.trim(); if (text) blocks.push({ type: "text", text }); @@ -429,14 +378,6 @@ export const buildAntigravityPrompt = Effect.fn("buildAntigravityPrompt")(functi const image = attachment.type === "image" && IMAGE_MIME_TYPES.has(mimeType); const audio = attachment.type === "file" && AUDIO_MIME_TYPES.has(mimeType); const pdf = attachment.type === "file" && mimeType === "application/pdf"; - const video = - attachment.type === "file" && - mimeType === "video/mp4" && - isQualifiedAntigravityRelease(input.agentVersion) && - // The agent turns a file URI into a path with unquote(urlparse(uri).path), which drops - // Windows drives and UNC hosts. Keep the saved path there until Google fixes it. - platform !== "win32" && - antigravityModelAcceptsVideo(input.currentModel); const textFile = attachment.type === "file" && (mimeType.startsWith("text/") || @@ -448,9 +389,7 @@ export const buildAntigravityPrompt = Effect.fn("buildAntigravityPrompt")(functi (isPastedText || (audio ? input.promptCapabilities?.audio !== true - : pdf || textFile - ? input.promptCapabilities?.embeddedContext !== true - : !video))); + : !(pdf || textFile) || input.promptCapabilities?.embeddedContext !== true))); const attachmentPath = input.resolveAttachmentPath(attachment); if (!attachmentPath) { return yield* EffectAcpErrors.AcpRequestError.invalidParams( @@ -479,9 +418,7 @@ export const buildAntigravityPrompt = Effect.fn("buildAntigravityPrompt")(functi ? ANTIGRAVITY_MAX_AUDIO_ATTACHMENT_BYTES : pdf ? MAX_TOTAL_ATTACHMENT_BYTES - : video - ? ANTIGRAVITY_MAX_VIDEO_ATTACHMENT_BYTES - : ANTIGRAVITY_MAX_TEXT_ATTACHMENT_BYTES; + : ANTIGRAVITY_MAX_TEXT_ATTACHMENT_BYTES; if ( attachment.type === "file" && (size > limit || totalBytes + size > MAX_TOTAL_ATTACHMENT_BYTES) @@ -500,7 +437,7 @@ export const buildAntigravityPrompt = Effect.fn("buildAntigravityPrompt")(functi EffectAcpErrors.AcpRequestError.invalidParams(`Invalid attachment '${attachment.name}'.`), ), ); - if (pdf || video) { + if (pdf) { blocks.push({ type: "resource_link", uri, name: attachment.name, mimeType, size }); continue; } diff --git a/apps/server/src/provider/antigravityAuthSupport.test.ts b/apps/server/src/provider/antigravityAuthSupport.test.ts index d4e4ed2ddff90..28444db4cbe7b 100644 --- a/apps/server/src/provider/antigravityAuthSupport.test.ts +++ b/apps/server/src/provider/antigravityAuthSupport.test.ts @@ -56,7 +56,7 @@ describe("Antigravity process environment", () => { browserCommand: "managed-browser-helper", }; - it("isolates the profile and harness after merging overrides without changing the base environment", () => { + it("runs `agy acp` with an isolated profile without changing the base environment", () => { const baseEnv = { HOME: "/home/developer", PATH: "/usr/bin", @@ -72,7 +72,6 @@ describe("Antigravity process environment", () => { GEMINI_HOME: "/shared-gemini-home", gemini_home: "/alias-shared-home", AGY_ACP_FORCE_FILE_STORAGE: "0", - ANTIGRAVITY_HARNESS_PATH: "/wrong-version/harness", BROWSER: "open-real-browser", browser: "another-real-browser", PYTHONUNBUFFERED: "0", @@ -83,7 +82,7 @@ describe("Antigravity process environment", () => { }; const original = { ...baseEnv }; const spawn = buildAntigravityAcpSpawnInput({ - installation: { executablePath: "/release/acp", harnessPath: "/release/harness" }, + installation: { executablePath: "/usr/bin/agy" }, profile, cwd: "/project", baseEnv, @@ -91,8 +90,8 @@ describe("Antigravity process environment", () => { expect(baseEnv).toEqual(original); expect(spawn).toEqual({ - command: "/release/acp", - args: ["--uid=", "--alsologtostderr"], + command: "/usr/bin/agy", + args: ["acp", "--gemini-dir", profile.geminiHome, "--app-data-dir", "antigravity-acp"], cwd: "/project", extendEnv: false, env: { @@ -101,7 +100,6 @@ describe("Antigravity process environment", () => { CUSTOM_SETTING: "keep-this", GEMINI_HOME: profile.geminiHome, AGY_ACP_FORCE_FILE_STORAGE: "1", - ANTIGRAVITY_HARNESS_PATH: "/release/harness", BROWSER: profile.browserCommand, PYTHONUNBUFFERED: "1", ELECTRON_RUN_AS_NODE: "1", @@ -110,31 +108,11 @@ describe("Antigravity process environment", () => { }); }); - it("runs the agy CLI as `agy acp` without a harness", () => { - const spawn = buildAntigravityAcpSpawnInput({ - installation: { executablePath: "/usr/bin/agy", harnessPath: null }, - profile, - cwd: "/project", - baseEnv: { PATH: "/usr/bin", ANTIGRAVITY_HARNESS_PATH: "/stale/harness" }, - }); - - expect(spawn.command).toBe("/usr/bin/agy"); - expect(spawn.args).toEqual([ - "acp", - "--gemini-dir", - profile.geminiHome, - "--app-data-dir", - "antigravity-acp", - ]); - expect(spawn.env).not.toHaveProperty("ANTIGRAVITY_HARNESS_PATH"); - expect(spawn.env).toMatchObject({ GEMINI_HOME: profile.geminiHome, PATH: "/usr/bin" }); - }); - 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 spawnFor = (auth: AntigravityAuthConfig) => buildAntigravityAcpSpawnInput({ - installation: { executablePath: "/release/acp", harnessPath: "/release/harness" }, + installation: { executablePath: "/usr/bin/agy" }, profile, cwd: "/project", baseEnv, @@ -180,10 +158,7 @@ describe("Antigravity process environment", () => { browserCommand: "managed-browser-helper", }; const input = { - installation: { - executablePath: "C:\\release\\agy_acp_server.exe", - harnessPath: "C:\\release\\localharness_external.exe", - }, + installation: { executablePath: "C:\\release\\agy.exe" }, profile: windowsProfile, cwd: "C:\\project", baseEnv: { PATH: "C:\\Windows\\system32", TEMP: "C:\\Users\\user\\AppData\\Local\\Temp" }, @@ -442,37 +417,6 @@ describe("Antigravity stdout compatibility", () => { }); describe("Antigravity stderr compatibility", () => { - it.effect.each([ - "I1022 11:04:37.910207 1865358 local_connection.py:551] harness stderr: Agent run failed: failed to handle call hook response: no pending hook for ID hook_request_2", - "E1022 11:04:37.910207 1865358 server.py:5275] Failed to rebuild agent for session native-session; connection unrecoverable", - "E1022 11:04:37.910207 1865358 server.py:5266] Agent connection lost for session native-session after rebuild retry", - ])("retires the transport on a native harness failure: %s", (line) => - Effect.gen(function* () { - const handleStderr = makeAntigravityStderrHandler(); - yield* handleStderr(line.slice(0, 70)); - const error = yield* handleStderr(`${line.slice(70)}\r\n`).pipe(Effect.flip); - expect(error._tag).toBe("AcpTransportError"); - expect(error.message).not.toContain("native-session"); - expect(error.message).not.toContain("hook_request_2"); - }), - ); - - it.effect( - "does not classify task prose or unrelated native warnings as a transport failure", - () => - Effect.gen(function* () { - const handleStderr = makeAntigravityStderrHandler(); - yield* handleStderr("Agent run failed: example from a task\n"); - yield* handleStderr("Agent connection was lost and could not be re-established\n"); - yield* handleStderr( - "I1022 11:04:37.910207 1865358 server.py:5142] Agent connection closed for session native-session; rebuilding agent and retrying the turn once.\n", - ); - yield* handleStderr( - "W1022 11:04:37.910207 1865358 telemetry.py:431] No business auth manager configured\n", - ); - }), - ); - it.effect("forwards fragmented native sign-in URLs from runtime 1.1.1", () => Effect.gen(function* () { const urls: string[] = []; @@ -574,7 +518,7 @@ it.layer(NodeServices.layer)("Antigravity profile preparation", (it) => { }), ); return buildAntigravityAcpSpawnInput({ - installation: { executablePath: "/release/acp", harnessPath: "/release/harness" }, + installation: { executablePath: "/usr/bin/agy" }, profile, cwd: directory, baseEnv, diff --git a/apps/server/src/provider/antigravityAuthSupport.ts b/apps/server/src/provider/antigravityAuthSupport.ts index c7245536a5535..f16b15a522f5d 100644 --- a/apps/server/src/provider/antigravityAuthSupport.ts +++ b/apps/server/src/provider/antigravityAuthSupport.ts @@ -72,7 +72,6 @@ const removedEnvironmentKeys = new Set([ "AGY_ACP_ENABLE_OAUTH", "GEMINI_HOME", "AGY_ACP_FORCE_FILE_STORAGE", - "ANTIGRAVITY_HARNESS_PATH", "BROWSER", "PYTHONUNBUFFERED", "ELECTRON_RUN_AS_NODE", @@ -457,10 +456,7 @@ export const prepareAntigravityProfile = Effect.fn("prepareAntigravityProfile")( }); export function buildAntigravityAcpSpawnInput(input: { - readonly installation: { - readonly executablePath: string; - readonly harnessPath: string | null; - }; + readonly installation: { readonly executablePath: string }; readonly profile: AntigravityProfile; readonly cwd: string; readonly baseEnv?: NodeJS.ProcessEnv; @@ -469,32 +465,21 @@ export function buildAntigravityAcpSpawnInput(input: { }): AcpSessionRuntime.AcpSpawnInput { return { command: input.installation.executablePath, - // The agy CLI has no harness sibling and serves ACP through its `acp` subcommand. - // The harness can survive a failed local agent and return end_turn; its native - // logs are the failure signal, so the transport must receive them. - args: - input.installation.harnessPath === null - ? [ - "acp", - "--gemini-dir", - input.profile.geminiHome, - "--app-data-dir", - // The CLI joins this beneath gemini-dir, including when the value is absolute. - "antigravity-acp", - ] - : [...(input.profile.platform === "linux" ? ["--uid="] : []), "--alsologtostderr"], + args: [ + "acp", + "--gemini-dir", + input.profile.geminiHome, + "--app-data-dir", + // The CLI joins this beneath gemini-dir, including when the value is absolute. + "antigravity-acp", + ], cwd: input.cwd, - env: { - ...antigravityEnvironment( - input.profile, - input.baseEnv ?? process.env, - input.auth ?? ANTIGRAVITY_PERSONAL_AUTH, - input.runtimeTempDirectory, - ), - ...(input.installation.harnessPath === null - ? {} - : { ANTIGRAVITY_HARNESS_PATH: input.installation.harnessPath }), - }, + env: antigravityEnvironment( + input.profile, + input.baseEnv ?? process.env, + input.auth ?? ANTIGRAVITY_PERSONAL_AUTH, + input.runtimeTempDirectory, + ), extendEnv: false, }; } @@ -636,10 +621,6 @@ export function makeAntigravityStdoutTransform( }); } -// glog records from the managed harness after which its ACP process can no longer run a turn. -const ANTIGRAVITY_HARNESS_FAILURE_LOG = - /^[IWEF]\d{4} \d{2}:\d{2}:\d{2}\.\d+ +\d+ (?:local_connection\.py:\d+\] harness stderr: Agent run failed:|server\.py:\d+\] (?:Failed to rebuild agent for session |Agent connection lost for session ))/; - export function makeAntigravityStderrHandler( input: { readonly onAuthorizationUrl?: ( @@ -648,18 +629,10 @@ export function makeAntigravityStderrHandler( } = {}, ) { let pending = ""; - // Untraced: with native logs on stderr this runs for every harness log line. + // Untraced: this runs for every stderr line. const handleLine = Effect.fnUntraced(function* (line: string) { const message = line.endsWith("\r") ? line.slice(0, -1) : line; if (message.length > maxBrowserHelperLineLength) return; - if (ANTIGRAVITY_HARNESS_FAILURE_LOG.test(message)) { - return yield* new AcpErrors.AcpTransportError({ - method: "session/prompt", - detail: - "Antigravity's local agent connection failed. Send a follow-up to resume with a fresh process.", - cause: undefined, - }); - } const url = message.startsWith(ANTIGRAVITY_AUTH_STDOUT_PREFIX) ? Effect.succeed(message.slice(ANTIGRAVITY_AUTH_STDOUT_PREFIX.length)) : message.startsWith(ANTIGRAVITY_AUTH_BROWSER_MARKER) diff --git a/apps/server/src/provider/antigravityRelease.ts b/apps/server/src/provider/antigravityRelease.ts deleted file mode 100644 index 54702d69935fb..0000000000000 --- a/apps/server/src/provider/antigravityRelease.ts +++ /dev/null @@ -1,14 +0,0 @@ -export interface AntigravityReleaseAsset { - readonly version: string; - readonly url: string; - readonly sha256: string; - readonly archiveBytes: number; - readonly executable: { - readonly name: string; - readonly bytes: number; - }; - readonly harness: { - readonly name: string; - readonly bytes: number; - }; -} diff --git a/apps/server/src/provider/managedRelease.ts b/apps/server/src/provider/managedRelease.ts index ca7c55e43b595..2ab75a3d7b325 100644 --- a/apps/server/src/provider/managedRelease.ts +++ b/apps/server/src/provider/managedRelease.ts @@ -1,7 +1,6 @@ import { compareSemverVersions, parseSemver } from "@t3tools/shared/semver"; -// Older pins recorded non-semver versions such as `agy_acp_server_1.1.1`; any -// other release is an update from those. +// A non-semver installed version counts any other release as an update. const isNewer = (candidate: string, current: string) => parseSemver(candidate) && parseSemver(current) ? compareSemverVersions(candidate, current) > 0 diff --git a/apps/server/src/provider/model-manifest.json b/apps/server/src/provider/model-manifest.json index 01727cc2680b0..c719c3755acd4 100644 --- a/apps/server/src/provider/model-manifest.json +++ b/apps/server/src/provider/model-manifest.json @@ -1,6 +1,6 @@ { "version": 1, - "updatedAt": "2026-11-14T15:58:47Z", + "updatedAt": "2026-11-19T00:00:00Z", "compatibility": [ { "driver": "codex", @@ -74,16 +74,24 @@ }, { "driver": "antigravity", - "t3CodeRange": ">=0.0.42", - "recommendedRange": ">=1.5.1 <2", + "t3CodeRange": ">=0.0.42 <0.1.10", + "recommendedRange": "=1.4.5 || =1.4.1", "ranges": [ - { "range": ">=1.5.1 <2", "status": "supported" }, { "range": "=1.4.5", "status": "supported" }, { "range": "=1.4.1", "status": "supported" }, { "range": "=1.3.0", "status": "supported" }, { "range": "=1.1.1", "status": "supported" } ] }, + { + "driver": "antigravity", + "t3CodeRange": ">=0.1.10", + "recommendedRange": ">=1.5.12 <2", + "ranges": [ + { "range": ">=1.5.0 <2", "status": "supported" }, + { "range": "<1.5.0", "status": "broken" } + ] + }, { "driver": "kiro", "t3CodeRange": ">=0.0.46", diff --git a/apps/server/src/provider/providerCompatibility.test.ts b/apps/server/src/provider/providerCompatibility.test.ts index ed722b7c53515..1eaa22920e634 100644 --- a/apps/server/src/provider/providerCompatibility.test.ts +++ b/apps/server/src/provider/providerCompatibility.test.ts @@ -111,42 +111,31 @@ describe("provider compatibility", () => { ); }); - it("recognizes Antigravity semver release tags while keeping dated candidates unknown", () => { + it("marks Antigravity below 1.5 broken and recommends 1.5.12 in the bundled manifest", () => { + const policies = decodeCompatibilityPolicies(bundledManifest.compatibility); const antigravity = ProviderDriverKind.make("antigravity"); - const taggedPolicy = { - ...policy, - driver: antigravity, - ranges: [{ range: "=2.0.0", status: "supported" as const }], - }; - for (const [version, expected] of [ - ["agy_acp_server_2.0.0", "supported"], - ["2.0.0", "supported"], - ["agy_acp_server_2.0.1", "unknown"], - ["agy_acp_server_2.0.0-beta.1", "unknown"], - ["agy_acp_server_20260818_01_RC01", "unknown"], - ] as const) { - assert.strictEqual( - resolveProviderCompatibility([taggedPolicy], antigravity, version)?.status, - expected, - ); + for (const version of [ + "1.1.1", + "1.3.0", + "1.4.1", + "1.4.5", + "1.4.9", + "agy_acp_server_1.4.5", + "1.4.5-beta", + ]) { + const advisory = resolveProviderCompatibility(policies, antigravity, version); + assert.strictEqual(advisory?.status, "broken", version); } + const supported = resolveProviderCompatibility(policies, antigravity, "1.5.11"); + assert.strictEqual(supported?.status, "supported"); + assert.strictEqual(supported?.recommendedRange, ">=1.5.12 <2"); + // Stable releases before 0.1.10 cannot install the CLI, so they keep the policy they shipped with. + assert.strictEqual( + resolveProviderCompatibility(policies, antigravity, "1.4.5", "0.1.9")?.status, + "supported", + ); }); - it.each(["1.4.5", "1.5.7"])( - "supports the legacy and native Antigravity runtime %s in the bundled manifest", - (version) => { - const policies = decodeCompatibilityPolicies(bundledManifest.compatibility); - assert.strictEqual( - resolveProviderCompatibility( - policies, - ProviderDriverKind.make("antigravity"), - `agy_acp_server_${version}`, - )?.status, - "supported", - ); - }, - ); - it("classifies boundaries and treats unlisted versions and release tags as unknown", () => { for (const [version, expected] of [ ["0.9.9", "broken"], @@ -156,7 +145,6 @@ describe("provider compatibility", () => { ["v2.0.0", "supported"], ["3.0.0", "unknown"], ["2.0.0-beta.1", "unknown"], - ["agy_acp_server_20260818_01_RC01", "unknown"], [null, "unknown"], ] as const) { assert.strictEqual(resolveProviderCompatibility([policy], driver, version)?.status, expected); diff --git a/apps/server/src/provider/providerCompatibility.ts b/apps/server/src/provider/providerCompatibility.ts index 69322915f458a..d825eb1b24342 100644 --- a/apps/server/src/provider/providerCompatibility.ts +++ b/apps/server/src/provider/providerCompatibility.ts @@ -65,14 +65,15 @@ export function resolveProviderCompatibility( ); if (!policy) return undefined; const unprefixed = version?.replace(/^v/, ""); - // Strip Cursor build hashes, Google ACP release prefixes and Muse revisions; leave semver prereleases unknown. + // Strip Cursor build hashes and Muse revisions; leave other prereleases unknown. Antigravity + // drops its pre-CLI prefix and prerelease suffix, so a custom launcher below 1.5 resolves broken. const stable = driver === "cursor" ? unprefixed?.replace(/^(\d{4}\.\d{2}\.\d{2})-[a-f0-9]+$/, "$1") - : driver === "antigravity" - ? unprefixed?.replace(/^agy_acp_server_(\d+\.\d+\.\d+)$/, "$1") - : driver === "muse" - ? unprefixed?.replace(/^(\d+\.\d+\.\d+)-R\d+(?:\.\d+)?$/, "$1") + : driver === "muse" + ? unprefixed?.replace(/^(\d+\.\d+\.\d+)-R\d+(?:\.\d+)?$/, "$1") + : driver === "antigravity" + ? unprefixed?.replace(/^(?:agy_acp_server_)?(\d+\.\d+\.\d+)(?:-[0-9A-Za-z.-]+)?$/, "$1") : unprefixed; const status = stable && /^\d+\.\d+\.\d+$/.test(stable) diff --git a/docs/user/providers-antigravity.md b/docs/user/providers-antigravity.md index d8d811bd58f68..1720baa5e6f2e 100644 --- a/docs/user/providers-antigravity.md +++ b/docs/user/providers-antigravity.md @@ -18,23 +18,12 @@ Antigravity setup. ### Sign in from a remote device -With the native CLI, Google finishes on an Antigravity page that shows a code. Paste that -code, or the page's full address, into the code field in the client where you started -sign-in. This works the same from any device. +Google finishes on an Antigravity page that shows a code. Paste that code, or the +page's full address, into the code field in the client where you started sign-in. +This works the same from any device. -With the older 1.4.5 runtime, Google returns to a `127.0.0.1` address. It can finish directly when your browser is -on the environment's machine. From another device, the final page will usually -fail to load because the sign-in listener is on the environment. - -Copy the full return address, including everything after `?`, into the return URL -field in the client where you started sign-in, then choose -**Continue**. Keep the original address; do not replace it with the server's -hostname. Only that T3 Code sign-in session can finish the attempt. If it expires, -retry sign-in and use the new link. - -The return URL contains a temporary sign-in code. Paste it only into the setup -field. A successful callback page alone does not confirm account access; wait for -T3 Code's confirmation. +The code is temporary. Paste it only into the setup field. The page alone does not +confirm account access; wait for T3 Code's confirmation. ### Other sign-in methods @@ -65,9 +54,6 @@ Install [Antigravity CLI](https://antigravity.google/docs/getting-started) on th Set **Binary path** to its `agy` executable and update it yourself. Leave the field blank to use the managed runtime, or a compatible executable on `PATH` if no managed runtime is installed. -On Windows, **Binary path** can also be a `.cmd` or `.bat` script that only sets -variables and then runs `agy_acp_server.exe` by its full path or a `%~dp0`-relative -path; keep `localharness_external.exe` beside that executable. ## Update the managed runtime @@ -76,10 +62,12 @@ is available. T3 checks Google's CLI release channel while provider update check are enabled. Installing or reinstalling also checks that channel. Updates keep your profile and existing runtime available if the new release fails validation. -Updating an older 1.4.5 installation migrates it to the native CLI. You may need to -sign in again after migration. Threads already running finish with their original -runtime; new sessions use the updated release. Custom binary paths keep using the -executable you selected. +T3 needs Antigravity 1.5 or newer and recommends 1.5.12 or newer. Sessions do not +start on an older runtime: update the managed runtime here, or update the executable +a custom binary path or `PATH` points at. You may need to sign in again after +updating from a runtime older than 1.5. Threads already running finish with their +original runtime; new sessions use the updated release. Custom binary paths keep +using the executable you selected. ## Models and threads @@ -118,9 +106,8 @@ Skills for every project go in `~/.gemini/config/skills` or so a skill there only appears when the project itself is your home directory. Antigravity receives images and audio directly, and reads PDFs and text files as -documents. With the managed runtime on macOS and Linux, an MP4 video up to 20 MiB -is sent as video to Gemini models. Other attachments, and videos for other models, are passed as a -saved file path for the agent to inspect with its tools. +documents. Other attachments, including videos, are passed as a saved file path for +the agent to inspect with its tools. ### Subagents @@ -158,8 +145,6 @@ is refused while the runtime is in use. When your Antigravity runtime offers `/goal`, send `/goal` followed by a verifiable objective. Antigravity keeps working until it completes the goal or you cancel it. -If you still use the older 1.4.5 runtime, update Antigravity in provider settings, -then refresh provider status. Use Stop to interrupt a running goal, then ask Antigravity to stop pursuing it before starting more work. Ordinary follow-ups wait until the running turn ends. diff --git a/packages/provider-acp/src/server/adapter.ts b/packages/provider-acp/src/server/adapter.ts index 8b696761742f7..41572dcc0781d 100644 --- a/packages/provider-acp/src/server/adapter.ts +++ b/packages/provider-acp/src/server/adapter.ts @@ -378,9 +378,6 @@ export interface AcpAdapterV2Flavor { readonly attachments: ReadonlyArray; readonly resolveAttachmentPath: (attachment: ChatAttachment) => string | null; readonly promptCapabilities: EffectAcpSchema.AgentCapabilities["promptCapabilities"]; - readonly agentVersion: string | undefined; - /** The session's model after selection, with its display name when the agent lists it. */ - readonly currentModel: { readonly id: string; readonly name: string | undefined } | undefined; }) => Effect.Effect, EffectAcpErrors.AcpError>; readonly promptFailure?: (cause: unknown) => OrchestrationV2ProviderFailure; /** @@ -8833,24 +8830,12 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* ( } if (!flavor.buildAttachmentPrompt) return yield* imageAttachmentBlocks(attachments); const setup = yield* Ref.get(activeSessionSetup); - const modelOption = findModelConfigOption(yield* runtime.getConfigOptions); - const currentModelId = modelOption?.currentValue; return yield* flavor .buildAttachmentPrompt({ text: messageText, attachments, resolveAttachmentPath: host.resolveAttachmentPath, promptCapabilities: setup?.initializeResult.agentCapabilities?.promptCapabilities, - agentVersion: setup?.initializeResult.agentInfo?.version, - currentModel: - typeof currentModelId !== "string" || modelOption === undefined - ? undefined - : { - id: currentModelId, - name: flattenSelectChoices(modelOption.options).find( - (choice) => choice.value === currentModelId, - )?.name, - }, }) .pipe( Effect.mapError(