From 5f13a1f42f62b363e1f0db813f11660aa87d931f Mon Sep 17 00:00:00 2001 From: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Date: Fri, 20 Nov 2026 09:59:58 +0100 Subject: [PATCH 1/9] test(providers): Update all covers the managed Antigravity runtime The driver reports an update for a managed runtime behind the release the installation found, the provider installation runs an install to its end, the update runner updates through it, and the web lists a provider whose update has no command. Co-authored-by: Claude Fable 5.2 --- .../Drivers/AntigravityDriver.test.ts | 103 +++++++++++++++ .../src/provider/providerInstallation.test.ts | 66 +++++++++- .../providerMaintenanceRunner.test.ts | 124 +++++++++++++++++- ...iderUpdateLaunchNotification.logic.test.ts | 20 +++ 4 files changed, 310 insertions(+), 3 deletions(-) diff --git a/apps/server/src/provider/Drivers/AntigravityDriver.test.ts b/apps/server/src/provider/Drivers/AntigravityDriver.test.ts index 3c0135f419c66..b56f8ebd722bb 100644 --- a/apps/server/src/provider/Drivers/AntigravityDriver.test.ts +++ b/apps/server/src/provider/Drivers/AntigravityDriver.test.ts @@ -9,14 +9,19 @@ import { ProviderSessionId, ThreadId, type AntigravitySettings, + type ProviderInstallState, } from "@t3tools/contracts"; import * as HostProcess from "@t3tools/shared/HostProcess"; +import * as Deferred from "effect/Deferred"; import * as Effect from "effect/Effect"; +import * as Fiber from "effect/Fiber"; import * as FileSystem from "effect/FileSystem"; import * as Layer from "effect/Layer"; import * as Path from "effect/Path"; import * as Redacted from "effect/Redacted"; import * as Schema from "effect/Schema"; +import * as Stream from "effect/Stream"; +import * as SubscriptionRef from "effect/SubscriptionRef"; import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner"; import { HttpClient } from "effect/http"; @@ -32,6 +37,7 @@ import * as ProviderEventLoggers from "@t3tools/provider-core/server/ProviderEve import * as McpProviderSessions from "@t3tools/provider-core/server/McpProviderSessions"; import * as ModelManifest from "../ModelManifest.ts"; import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator"; +import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost"; import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter"; import { knownProviderFailureMessage } from "@t3tools/provider-core/server/failure"; import { resolveProviderCompatibility } from "../providerCompatibility.ts"; @@ -56,6 +62,18 @@ const blockedCredentialKeys = new Set([ "GOOGLE_GENAI_USE_VERTEXAI", ]); +const idleInstallState: ProviderInstallState = { + driver: ProviderDriverKind.make("antigravity"), + operationId: null, + phase: "idle", + downloadedBytes: 0, + totalBytes: null, + version: null, + installedVersion: null, + canRemove: false, + message: null, +}; + function shellQuote(value: string): string { return `'${value.replaceAll("'", `'"'"'`)}'`; } @@ -66,8 +84,12 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* ( readonly enabled?: boolean; /** Extra instance variables, such as ones a parent T3 turn already exported. */ readonly environment?: ReadonlyArray<{ readonly name: string; readonly value: string }>; + readonly updateChecks?: boolean; } = {}, ) { + const host = yield* ProviderHost.ProviderHost; + const installState = yield* SubscriptionRef.make(idleInstallState); + const checkedForUpdate = yield* Deferred.make(); const fs = yield* FileSystem.FileSystem; const path = yield* Path.Path; const config = yield* ServerConfig.ServerConfig; @@ -156,6 +178,9 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* ( const layerInstallation = Layer.mock(AntigravityInstallation.AntigravityInstallation)({ managedDirectory: root, + state: SubscriptionRef.get(installState), + changes: SubscriptionRef.changes(installState), + checkForUpdate: Deferred.succeed(checkedForUpdate, undefined).pipe(Effect.asVoid), compatibility: (version) => Effect.succeed( resolveProviderCompatibility( @@ -241,6 +266,18 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* ( }).pipe( Effect.provide(layerInstallation), Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, observedSpawner), + Effect.provideService(ProviderHost.ProviderHost, { + ...host, + settings: { + ...host.settings, + get: host.settings.get.pipe( + Effect.map((settings) => ({ + ...settings, + enableProviderUpdateChecks: options.updateChecks ?? true, + })), + ), + }, + }), ); const refresh = instance.refreshModels; if (!refresh) return yield* Effect.die("Antigravity does not expose model refresh."); @@ -272,6 +309,8 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* ( second, signedOut, controls, + installState, + checkedForUpdate, acquisitions, releases, launches, @@ -312,6 +351,68 @@ const layerTest = ProviderHostLive.layer.pipe( ); it.layer(layerTest)("AntigravityDriver", (it) => { + it.effect.each([ + { + name: "a managed runtime behind the found release", + source: "managed", + latest: "1.5.13", + updateChecks: true, + expected: { status: "behind_latest", latestVersion: "1.5.13", canUpdate: true }, + }, + { + name: "a managed runtime on the found release", + source: "managed", + latest: "runtime 'one", + updateChecks: true, + expected: { status: "current", latestVersion: "runtime 'one", canUpdate: true }, + }, + { + name: "a custom executable", + source: "override", + latest: "1.5.13", + updateChecks: true, + expected: { status: "unknown", latestVersion: null, canUpdate: false }, + }, + { + name: "a managed runtime with update checks off", + source: "managed", + latest: "1.5.13", + updateChecks: false, + expected: { status: "unknown", latestVersion: null, canUpdate: true }, + }, + ] as const)("reports an update for $name", ({ source, latest, updateChecks, expected }) => + Effect.gen(function* () { + const h = yield* makeHarness({ updateChecks }); + h.controls.selected = { ...h.first, source }; + yield* SubscriptionRef.update(h.installState, (state) => ({ ...state, version: latest })); + const snapshot = yield* h.instance.snapshot.refresh; + expect(snapshot.versionAdvisory).toMatchObject({ + ...expected, + currentVersion: "runtime 'one", + updateCommand: null, + }); + // Only the runtime T3 Code installed is checked against Google's releases. + if (source === "managed") yield* Deferred.await(h.checkedForUpdate); + else expect(yield* Deferred.isDone(h.checkedForUpdate)).toBe(false); + }), + ); + + it.effect("publishes the update when the installation finds a newer release", () => + Effect.gen(function* () { + const h = yield* makeHarness(); + yield* h.instance.snapshot.refresh; + const published = yield* h.instance.snapshot.streamChanges.pipe( + Stream.filter((snapshot) => snapshot.versionAdvisory?.status === "behind_latest"), + Stream.runHead, + Effect.forkScoped({ startImmediately: true }), + ); + yield* SubscriptionRef.update(h.installState, (state) => ({ ...state, version: "1.5.13" })); + expect(yield* Fiber.join(published)).toMatchObject({ + value: { versionAdvisory: { latestVersion: "1.5.13", canUpdate: true } }, + }); + }), + ); + it.effect.skipIf(windowsHost)( "refreshes the selected executable and limits form capabilities to chat", () => @@ -694,6 +795,8 @@ it.layer(layerTest)("AntigravityDriver", (it) => { Effect.provide( Layer.mock(AntigravityInstallation.AntigravityInstallation)({ managedDirectory: config.stateDir, + state: Effect.succeed(idleInstallState), + changes: Stream.never, resolve: () => Effect.die("unused"), acquire: () => Effect.die("unused"), }), diff --git a/apps/server/src/provider/providerInstallation.test.ts b/apps/server/src/provider/providerInstallation.test.ts index 76cb5904193da..6099c0f9e80c1 100644 --- a/apps/server/src/provider/providerInstallation.test.ts +++ b/apps/server/src/provider/providerInstallation.test.ts @@ -8,6 +8,7 @@ import { import * as HostProcess from "@t3tools/shared/HostProcess"; import * as Effect from "effect/Effect"; import * as Deferred from "effect/Deferred"; +import * as Fiber from "effect/Fiber"; import * as SubscriptionRef from "effect/SubscriptionRef"; import * as FileSystem from "effect/FileSystem"; import * as Layer from "effect/Layer"; @@ -119,14 +120,19 @@ const makeHarness = Effect.fn("providerInstallation.test.makeHarness")(function* checkForUpdate: Effect.void, start: Effect.sync(() => { calls.push("start"); - return { ...state, operationId: "install-1", phase: "downloading" as const }; + return { + ...state, + operationId: "install-1", + phase: "downloading" as const, + message: "Downloading.", + }; }).pipe(Effect.tap((started) => SubscriptionRef.set(installationState, started))), cancel: () => Effect.sync(() => { calls.push("cancel"); return state; }), - state: Effect.succeed(state), + state: SubscriptionRef.get(installationState), changes: all.some((entry) => entry.refreshModels) ? SubscriptionRef.changes(installationState).pipe( Stream.onStart( @@ -279,6 +285,62 @@ describe("provider installation routing", () => { }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)), ); + const watched = () => Object.assign(instance(), { refreshModels: () => Effect.void }); + const running = { + ...state, + operationId: "install-1", + phase: "downloading", + message: "Downloading.", + } satisfies ProviderInstallState; + + it.effect.each([ + { phase: "succeeded", message: null, error: null }, + { + phase: "failed", + message: "Could not download Antigravity from Google.", + error: "Could not download Antigravity from Google.", + }, + { phase: "cancelled", message: null, error: "The installation did not finish." }, + ] as const)("runs an install until it is $phase", ({ phase, message, error }) => + Effect.gen(function* () { + const harness = yield* makeHarness({ instance: watched() }); + const progress: string[] = []; + const reported = yield* Deferred.make(); + const run = yield* harness.router + .run({ instanceId }, (line) => + Effect.sync(() => progress.push(line)).pipe( + Effect.andThen(Deferred.succeed(reported, undefined)), + ), + ) + .pipe(Effect.result, Effect.forkScoped); + yield* Deferred.await(reported); + // Download progress keeps the message, so it is reported once. + yield* SubscriptionRef.set(harness.installationState, { ...running, downloadedBytes: 1 }); + yield* SubscriptionRef.set(harness.installationState, { ...running, phase, message }); + const result = yield* Fiber.join(run); + assert.deepEqual(progress, ["Downloading."]); + assert.strictEqual(result._tag === "Failure" ? result.failure.detail : null, error); + assert.deepEqual(harness.calls, ["start"]); + }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)), + ); + + it.effect.each([ + { name: "cancels the install it started", joined: false, calls: ["start", "cancel"] }, + { name: "leaves an install it joined running", joined: true, calls: ["start"] }, + ])("an interrupted run $name", ({ joined, calls }) => + Effect.gen(function* () { + const harness = yield* makeHarness({ instance: watched() }); + if (joined) yield* SubscriptionRef.set(harness.installationState, running); + const reported = yield* Deferred.make(); + const run = yield* harness.router + .run({ instanceId }, () => Deferred.succeed(reported, undefined)) + .pipe(Effect.forkScoped); + yield* Deferred.await(reported); + yield* Fiber.interrupt(run); + assert.deepEqual(harness.calls, calls); + }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)), + ); + it.effect("keeps external installs manual without hiding shared install status", () => Effect.gen(function* () { const harness = yield* makeHarness({ diff --git a/apps/server/src/provider/providerMaintenanceRunner.test.ts b/apps/server/src/provider/providerMaintenanceRunner.test.ts index 985347a66e96b..b6cf8e5473c2a 100644 --- a/apps/server/src/provider/providerMaintenanceRunner.test.ts +++ b/apps/server/src/provider/providerMaintenanceRunner.test.ts @@ -6,7 +6,7 @@ import { type ServerProvider, type ServerProviderUpdateState, } from "@t3tools/contracts"; -import { ServerProviderUpdateError } from "@t3tools/contracts"; +import { ProviderSetupError, ServerProviderUpdateError } from "@t3tools/contracts"; import * as Cause from "effect/Cause"; import * as Deferred from "effect/Deferred"; import * as Effect from "effect/Effect"; @@ -29,6 +29,7 @@ import * as ServerSettings from "../serverSettings.ts"; import * as SourceControlProviderRegistry from "../sourceControl/SourceControlProviderRegistry.ts"; import * as TextGeneration from "../textGeneration/TextGeneration.ts"; import * as TextGenerators from "../textGeneration/TextGenerators.ts"; +import * as ProviderInstallation from "./providerInstallation.ts"; import * as ProviderInstallationGate from "./ProviderInstallationGate.ts"; import * as ProviderInstanceRegistry from "./ProviderInstanceRegistry.ts"; import * as ProviderRegistry from "./ProviderRegistry.ts"; @@ -249,6 +250,8 @@ const makeTestRunner = ( })), }, latestVersions: Layer.Layer = ProviderLatestVersions.layer, + runInstall: ProviderInstallation.ProviderInstallation["Service"]["run"] = () => + Effect.die("Only a managed install runs the provider installation."), ) => Effect.service(ProviderMaintenanceRunner.ProviderMaintenanceRunner).pipe( Effect.provide( @@ -264,6 +267,7 @@ const makeTestRunner = ( refreshInBackground: Effect.void, }), latestVersions, + Layer.mock(ProviderInstallation.ProviderInstallation)({ run: runInstall }), // Layers memoize by reference, so a test that provides the gate shares it. ProviderInstallationGate.layer, ), @@ -905,6 +909,124 @@ describe("providerMaintenanceRunner", () => { ); }); + it.effect.each([ + { + name: "updates through the provider installation", + installError: null, + targetVersion: undefined, + installs: 1, + expected: [ + ["running", "Waiting for running provider work to finish."], + ["running", "Downloading."], + ["running", "Verifying the installed version"], + ["succeeded", "Provider updated."], + ], + }, + { + name: "reports why its install failed", + installError: "Could not download Antigravity from Google.", + targetVersion: undefined, + installs: 1, + expected: [ + ["running", "Waiting for running provider work to finish."], + ["running", "Downloading."], + ["failed", "Could not download Antigravity from Google."], + ], + }, + { + name: "cannot install a chosen version", + installError: null, + targetVersion: "1.5.13", + installs: 0, + expected: [ + [ + "failed", + "This version is no longer recommended or this installer cannot install a specific version. Refresh provider settings.", + ], + ], + }, + ])( + "a provider with a managed runtime $name", + ({ installError, targetVersion, installs, expected }) => { + const driver = ProviderDriverKind.make("antigravity"); + const instanceId = ProviderInstanceId.make("antigravity"); + const installed: Array = []; + const commands: Array = []; + return Effect.gen(function* () { + const { registry, updateStatesRef } = yield* makeRegistry( + { ...baseProvider, instanceId, driver, version: "1.5.12" }, + { installedVersionAfterUpdate: "1.5.13" }, + ); + const updater = yield* makeTestRunner( + { + ...registry, + getProviderMaintenanceCapabilitiesForInstance: () => + Effect.succeed({ + provider: driver, + packageName: null, + update: null, + managedInstall: { lockKey: "antigravity-managed" }, + latestVersion: "1.5.13", + }), + }, + undefined, + undefined, + (input, onProgress) => + Effect.gen(function* () { + installed.push(input.instanceId); + yield* onProgress("Downloading."); + if (installError !== null) { + return yield* new ProviderSetupError({ + instanceId: input.instanceId, + operation: "install", + detail: installError, + }); + } + return { + driver, + operationId: "install-1", + phase: "succeeded", + downloadedBytes: 0, + totalBytes: null, + version: "1.5.13", + installedVersion: "1.5.13", + canRemove: true, + message: null, + } as const; + }), + ); + + yield* updater.updateProvider({ + provider: driver, + instanceId, + ...(targetVersion === undefined ? {} : { targetVersion }), + }); + assert.deepStrictEqual( + (yield* Ref.get(updateStatesRef)) + .map((state) => [state.status, state.message]) + .slice(-expected.length), + expected, + ); + assert.deepStrictEqual( + installed, + Array.from({ length: installs }, () => instanceId), + ); + assert.deepStrictEqual(commands, []); + }).pipe( + Effect.provide( + Layer.mergeAll( + layerNonWindowsPlatform, + layerLatestVersionHttpClient("1.5.13"), + layerMockSpawner((command) => { + commands.push(command); + return {}; + }), + ), + ), + ); + }, + ); + it.effect("an interrupted update ends failed instead of running forever", () => { const started = Deferred.makeUnsafe(); return Effect.gen(function* () { diff --git a/apps/web/src/components/ProviderUpdateLaunchNotification.logic.test.ts b/apps/web/src/components/ProviderUpdateLaunchNotification.logic.test.ts index 764a76ba74f12..2215ae8472fcf 100644 --- a/apps/web/src/components/ProviderUpdateLaunchNotification.logic.test.ts +++ b/apps/web/src/components/ProviderUpdateLaunchNotification.logic.test.ts @@ -130,6 +130,26 @@ describe("provider update launch notification logic", () => { ).toBe(true); }); + it("offers one-click updates for a runtime the server installs, which has no command", () => { + const managed = updateCandidate({ driver: driver("antigravity"), updateCommand: null }); + const ownExecutable = provider({ + driver: driver("antigravity"), + instanceId: instanceId("antigravity_custom"), + latestVersion: null, + advisoryStatus: "unknown", + canUpdate: false, + updateCommand: null, + }); + const manualOnly = updateCandidate({ + driver: driver("claudeAgent"), + canUpdate: false, + updateCommand: null, + }); + + expect(canOneClickUpdateProviderCandidate(managed, [managed, ownExecutable])).toBe(true); + expect(canOneClickUpdateProviderCandidate(manualOnly, [manualOnly])).toBe(false); + }); + it("keeps the inline update action available while a provider update is already running", () => { const candidate = updateCandidate({ driver: driver("codex"), From 05f35751a18a993bf19a48f959c7b73ddb841dbd Mon Sep 17 00:00:00 2001 From: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Date: Fri, 20 Nov 2026 10:06:21 +0100 Subject: [PATCH 2/9] fix(providers): Update all includes the managed Antigravity runtime The managed Antigravity runtime reported no update, and a provider could only be updated by a shell command, so Update all never listed it. The Antigravity driver now reports a version advisory for the runtime T3 Code installed, from the release its installation found, and looks for a newer release during its health check. Its maintenance capabilities carry a managed install in place of a command. The update runner runs that through ProviderInstallation, the install the setup section starts, and the web lists a provider whose update has no command. Co-authored-by: Claude Fable 5.2 --- .../src/provider/AntigravityProvider.ts | 20 +++--- .../src/provider/Drivers/AntigravityDriver.ts | 65 ++++++++++++++++++- .../src/provider/providerInstallation.ts | 64 +++++++++++++++--- .../src/provider/providerMaintenanceRunner.ts | 29 ++++++--- .../ProviderUpdateLaunchNotification.logic.ts | 10 ++- docs/internals/providers.md | 5 ++ docs/user/providers-antigravity.md | 3 +- .../provider-core/src/server/maintenance.ts | 5 ++ .../src/server/maintenanceResolver.ts | 4 +- 9 files changed, 165 insertions(+), 40 deletions(-) diff --git a/apps/server/src/provider/AntigravityProvider.ts b/apps/server/src/provider/AntigravityProvider.ts index b3b68d46e8ba8..539cbd31bb1f4 100644 --- a/apps/server/src/provider/AntigravityProvider.ts +++ b/apps/server/src/provider/AntigravityProvider.ts @@ -31,10 +31,8 @@ import { DeferringFailedCheck, makeManagedServerProvider, } from "@t3tools/provider-core/server/managedProvider"; -import { - makeManualOnlyProviderMaintenanceCapabilities, - type ProviderMaintenanceCapabilities, -} from "@t3tools/provider-core/server/maintenanceResolver"; +import { makeManualOnlyProviderMaintenanceCapabilities } from "@t3tools/provider-core/server/maintenanceResolver"; +import type { ManagedServerProvider } from "@t3tools/provider-core/server/snapshot"; import { buildServerProvider, isCommandMissingCause, @@ -170,7 +168,7 @@ interface AntigravityProviderOptions { readonly supportsTextGeneration: Effect.Effect; readonly probeUsage?: Effect.Effect; readonly clearUsage?: Effect.Effect; - readonly maintenanceCapabilities?: ProviderMaintenanceCapabilities; + readonly resolveMaintenance?: ManagedServerProvider["resolveMaintenance"]; readonly auth?: { readonly type: string; readonly label: string }; } @@ -369,14 +367,12 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func return yield* options.stampIdentity(next.draft); }); - const maintenanceCapabilities = - options.maintenanceCapabilities ?? - makeManualOnlyProviderMaintenanceCapabilities({ - provider: ProviderDriverKind.make("antigravity"), - packageName: null, - }); + const manualMaintenance = makeManualOnlyProviderMaintenanceCapabilities({ + provider: ProviderDriverKind.make("antigravity"), + packageName: null, + }); const managed = yield* makeManagedServerProvider({ - resolveMaintenance: () => Effect.succeed(maintenanceCapabilities), + resolveMaintenance: options.resolveMaintenance ?? (() => Effect.succeed(manualMaintenance)), getSettings: Effect.succeed(settings), streamSettings: Stream.empty, haveSettingsChanged: () => false, diff --git a/apps/server/src/provider/Drivers/AntigravityDriver.ts b/apps/server/src/provider/Drivers/AntigravityDriver.ts index 3d426785813c3..5d1f9fb6020e0 100644 --- a/apps/server/src/provider/Drivers/AntigravityDriver.ts +++ b/apps/server/src/provider/Drivers/AntigravityDriver.ts @@ -19,6 +19,7 @@ import * as Exit from "effect/Exit"; import * as Fiber from "effect/Fiber"; import * as FileSystem from "effect/FileSystem"; import * as Path from "effect/Path"; +import * as Ref from "effect/Ref"; import * as Schema from "effect/Schema"; import * as Scope from "effect/Scope"; import * as Stream from "effect/Stream"; @@ -55,6 +56,11 @@ import { } from "../acp/AntigravityAcpSupport.ts"; import type * as AcpSessionRuntime from "@t3tools/provider-acp/server/AcpSessionRuntime"; import type { ServerProviderDraft } from "@t3tools/provider-core/server/snapshotProbe"; +import { + createProviderVersionAdvisory, + makeManualOnlyProviderMaintenanceCapabilities, + type ProviderMaintenanceCapabilities, +} from "@t3tools/provider-core/server/maintenanceResolver"; import { removeAntigravitySessionFiles, retireAntigravityRuntimeTempDirs, @@ -199,9 +205,51 @@ export const AntigravityDriver: ProviderDriver< accentColor, continuationGroupKey: continuationIdentity.continuationKey, }); + const manualMaintenance = makeManualOnlyProviderMaintenanceCapabilities({ + provider: DRIVER, + packageName: null, + }); + // Set by the health check, which resolves the executable. Only the runtime T3 Code + // installed updates from here; a custom or PATH executable stays as its owner left it. + const usesManagedRuntime = yield* Ref.make(false); + const resolveMaintenance = () => + Effect.zipWith( + Ref.get(usesManagedRuntime), + installation.state, + (managed, install): ProviderMaintenanceCapabilities => + managed + ? { + provider: DRIVER, + packageName: null, + update: null, + managedInstall: { lockKey: "antigravity-managed" }, + latestVersion: install.version, + // The installation has picked the release to run, so any other one is behind it. + compareVersions: (current, latest) => (current === latest ? 0 : -1), + } + : manualMaintenance, + ); + const updateChecksEnabled = host.settings.get.pipe( + Effect.map((current) => current.enableProviderUpdateChecks), + Effect.orElseSucceed(() => false), + ); const classifyModels = (draft: ServerProviderDraft) => - currentCatalog.pipe( - Effect.map((catalog) => stampIdentity(ModelCatalog.applyModelCatalog(draft, catalog))), + Effect.all([currentCatalog, resolveMaintenance(), updateChecksEnabled]).pipe( + Effect.map(([catalog, maintenance, checksEnabled]) => + stampIdentity({ + ...ModelCatalog.applyModelCatalog(draft, catalog), + versionAdvisory: createProviderVersionAdvisory({ + driver: DRIVER, + currentVersion: draft.version, + latestVersion: + checksEnabled && draft.enabled && draft.installed + ? (maintenance.latestVersion ?? null) + : null, + checkedAt: draft.checkedAt, + maintenanceCapabilities: maintenance, + }), + }), + ), ); const prepareSpawn = Effect.fn("AntigravityDriver.prepareSpawn")(function* ( @@ -530,6 +578,7 @@ export const AntigravityDriver: ProviderDriver< }); } const executable = yield* installation.resolve(settings.binaryPath, processEnvironment).pipe( + Effect.tapError(() => Ref.set(usesManagedRuntime, false)), Effect.mapError( (cause) => new ProviderSetupError({ @@ -540,6 +589,9 @@ export const AntigravityDriver: ProviderDriver< }), ), ); + yield* Ref.set(usesManagedRuntime, executable.source === "managed"); + // Throttled by the installation; the release it finds is republished below. + if (executable.source === "managed") yield* Effect.forkDetach(installation.checkForUpdate); return { protocolVersion: 1, agentCapabilities: { @@ -568,6 +620,7 @@ export const AntigravityDriver: ProviderDriver< const provider = yield* makeAntigravityProvider(settings, { environment: processEnvironment, stampIdentity: classifyModels, + resolveMaintenance, probe, probeUsage: usage.probe, clearUsage: usage.clear, @@ -588,6 +641,14 @@ export const AntigravityDriver: ProviderDriver< }), ), ); + // The registry keeps the last published snapshot, so a newly found release needs a new one. + yield* installation.changes.pipe( + Stream.map((state) => state.version), + Stream.changes, + Stream.drop(1), + Stream.runForEach(() => provider.snapshot.refresh.pipe(Effect.ignoreCause({ log: true }))), + Effect.forkScoped, + ); const defaultModel = currentCatalog.pipe(Effect.map((catalog) => catalog?.defaultChatModel)); const orchestrationAdapter = yield* makeAntigravityAdapterV2({ instanceId, diff --git a/apps/server/src/provider/providerInstallation.ts b/apps/server/src/provider/providerInstallation.ts index 471c97b820547..6634d1ec051c1 100644 --- a/apps/server/src/provider/providerInstallation.ts +++ b/apps/server/src/provider/providerInstallation.ts @@ -31,12 +31,27 @@ const hasBinaryPath = Schema.is(Schema.Struct({ binaryPath: Schema.String })); const decodeCodexSettings = Schema.decodeUnknownEffect(CodexSettings); const decodeAntigravitySettings = Schema.decodeUnknownEffect(AntigravitySettings); +/** True once the operation ended or another state replaced it. */ +const hasSettled = (operationId: string | null) => (state: ProviderInstallState) => + state.operationId !== operationId || + state.phase === "succeeded" || + state.phase === "failed" || + state.phase === "cancelled"; + export class ProviderInstallation extends Context.Service< ProviderInstallation, { readonly start: ( input: ProviderSetupInput, ) => Effect.Effect; + /** + * Starts an install, or joins the one running, and waits for it. Fails with the install's + * own message unless it succeeds, and cancels an install it started when interrupted. + */ + readonly run: ( + input: ProviderSetupInput, + onProgress: (message: string) => Effect.Effect, + ) => Effect.Effect; readonly cancel: ( input: ProviderInstallCancelInput, ) => Effect.Effect; @@ -164,13 +179,7 @@ const make = Effect.fn("makeProviderInstallation")(function* () { accountCheckOperation = started.operationId; // Installation outlives the request and may finish while every client is disconnected. yield* installation.changes.pipe( - Stream.filter( - (state) => - state.operationId !== started.operationId || - state.phase === "succeeded" || - state.phase === "failed" || - state.phase === "cancelled", - ), + Stream.filter(hasSettled(started.operationId)), Stream.runHead, Effect.flatMap((result) => Option.isSome(result) && @@ -186,6 +195,45 @@ const make = Effect.fn("makeProviderInstallation")(function* () { return started; }); + const run = Effect.fn("ProviderInstallation.run")(function* ( + input: ProviderSetupInput, + onProgress: (message: string) => Effect.Effect, + ) { + const { installation } = yield* requireInstance(input.instanceId, "install", true); + const before = yield* installation.state; + const started = yield* start(input); + const { operationId } = started; + const settled = yield* installation.changes.pipe( + // Download progress changes the state several times a second; report each message once. + Stream.changesWith( + (a, b) => a.operationId === b.operationId && a.phase === b.phase && a.message === b.message, + ), + Stream.tap((state) => + state.message !== null && !hasSettled(operationId)(state) + ? onProgress(state.message) + : Effect.void, + ), + Stream.filter(hasSettled(operationId)), + Stream.runHead, + Effect.onInterrupt(() => + operationId !== null && operationId !== before.operationId + ? installation.cancel(operationId).pipe(Effect.ignore) + : Effect.void, + ), + ); + const final = Option.getOrElse(settled, () => started); + if (final.operationId !== operationId || final.phase !== "succeeded") { + return yield* new ProviderSetupError({ + instanceId: input.instanceId, + operation: "install", + detail: + (final.operationId === operationId ? final.message : null) ?? + "The installation did not finish.", + }); + } + return final; + }); + const cancel = Effect.fn("ProviderInstallation.cancel")(function* ( input: ProviderInstallCancelInput, ) { @@ -249,7 +297,7 @@ const make = Effect.fn("makeProviderInstallation")(function* () { return yield* installation.state; }); - return { start, cancel, subscribe, remove }; + return { start, run, cancel, subscribe, remove }; }); export const layer = Layer.effect(ProviderInstallation, make()); diff --git a/apps/server/src/provider/providerMaintenanceRunner.ts b/apps/server/src/provider/providerMaintenanceRunner.ts index 014aa67c26df0..6e349d45e344b 100644 --- a/apps/server/src/provider/providerMaintenanceRunner.ts +++ b/apps/server/src/provider/providerMaintenanceRunner.ts @@ -24,6 +24,7 @@ import { ChildProcess, ChildProcessSpawner } from "effect/process"; import * as NodeUtil from "node:util"; import * as ModelManifest from "./ModelManifest.ts"; +import * as ProviderInstallation from "./providerInstallation.ts"; import * as ProviderInstallationGate from "./ProviderInstallationGate.ts"; import * as ProviderRegistry from "./ProviderRegistry.ts"; import { makeProviderMaintenanceCommandCoordinator } from "./providerMaintenanceCommandCoordinator.ts"; @@ -324,6 +325,7 @@ export const make = Effect.fn("ProviderMaintenanceRunner.make")(function* () { const httpClient = yield* HttpClient.HttpClient; const latestVersions = yield* ProviderLatestVersions.ProviderLatestVersions; const installationGate = yield* ProviderInstallationGate.ProviderInstallationGate; + const providerInstallation = yield* ProviderInstallation.ProviderInstallation; const runMaintenanceCommand = ( update: ProviderMaintenanceCommandAction, onProgress: (line: string) => Effect.Effect, @@ -350,7 +352,9 @@ export const make = Effect.fn("ProviderMaintenanceRunner.make")(function* () { .getProviderMaintenanceCapabilitiesForInstance(candidate.instanceId, candidate.driver) .pipe( Effect.map((capabilities) => - capabilities.update?.lockKey === lockKey ? [candidate.instanceId] : [], + (capabilities.update ?? capabilities.managedInstall)?.lockKey === lockKey + ? [candidate.instanceId] + : [], ), ), { concurrency: "unbounded" }, @@ -434,7 +438,7 @@ export const make = Effect.fn("ProviderMaintenanceRunner.make")(function* () { instanceId, provider, ); - const update = capabilities.update; + const update = capabilities.update ?? capabilities.managedInstall; if (!update) { return yield* new ServerProviderUpdateError({ provider, @@ -491,7 +495,7 @@ export const make = Effect.fn("ProviderMaintenanceRunner.make")(function* () { provider, { fresh: true }, ); - if (!fresh.update || fresh.update.lockKey !== update.lockKey) { + if ((fresh.update ?? fresh.managedInstall)?.lockKey !== update.lockKey) { return yield* finish( makeUpdateState({ status: "failed", @@ -529,7 +533,7 @@ export const make = Effect.fn("ProviderMaintenanceRunner.make")(function* () { advisory?.recommendedVersion !== targetVersion || advisory.status !== "supported" : advisory?.status === "broken" || advisory?.status === "unsupported"; - if (rejected || !command) { + if (rejected || (!command && fresh.managedInstall === undefined)) { return yield* finish( makeUpdateState({ status: "failed", @@ -587,12 +591,19 @@ export const make = Effect.fn("ProviderMaintenanceRunner.make")(function* () { yield* setRunningMessage("Waiting for running provider work to finish."); const result = yield* installationGate.update( sharingInstances, - setRunningMessage(`Running ${describeCommand(command)}`).pipe( - Effect.andThen(runMaintenanceCommand(command, setRunningMessage)), - ), + Effect.gen(function* () { + if (command === null) { + // A managed install has no command. A failed one fails here with its own + // message, which recordFailedUpdate reports. + yield* providerInstallation.run({ instanceId }, setRunningMessage); + return null; + } + yield* setRunningMessage(`Running ${describeCommand(command)}`); + return yield* runMaintenanceCommand(command, setRunningMessage); + }), ); const finishedAt = yield* nowIso; - if (result.timedOut || result.exitCode !== 0) { + if (command !== null && result !== null && (result.timedOut || result.exitCode !== 0)) { yield* Effect.logWarning("Provider update command failed", { provider, command: describeCommand(command), @@ -659,7 +670,7 @@ export const make = Effect.fn("ProviderMaintenanceRunner.make")(function* () { : needsOpenCodeServerRestart(verifiedProviders) ? OPENCODE_SERVER_RESTART_MESSAGE : "Provider updated.", - output: commandOutput(result), + output: result && commandOutput(result), }), ); }, diff --git a/apps/web/src/components/ProviderUpdateLaunchNotification.logic.ts b/apps/web/src/components/ProviderUpdateLaunchNotification.logic.ts index 9c94c4854d0c3..59bd7228640c2 100644 --- a/apps/web/src/components/ProviderUpdateLaunchNotification.logic.ts +++ b/apps/web/src/components/ProviderUpdateLaunchNotification.logic.ts @@ -171,10 +171,7 @@ export function hasOneClickUpdateProviderCandidate( candidate: ProviderUpdateCandidate, providers: ReadonlyArray, ): boolean { - if ( - candidate.versionAdvisory.canUpdate !== true || - candidate.versionAdvisory.updateCommand === null - ) { + if (candidate.versionAdvisory.canUpdate !== true) { return false; } @@ -183,13 +180,14 @@ export function hasOneClickUpdateProviderCandidate( return false; } - const updateCommands = new Set(); + // A runtime the server installs itself, such as Antigravity's, updates with no command (null). + const updateCommands = new Set(); for (const provider of driverProviders) { if (!isProviderUpdateCandidate(provider)) { continue; } const advisory = provider.versionAdvisory; - if (!advisory || advisory.canUpdate !== true || advisory.updateCommand === null) { + if (!advisory || advisory.canUpdate !== true) { return false; } updateCommands.add(advisory.updateCommand); diff --git a/docs/internals/providers.md b/docs/internals/providers.md index 102bffe4f065c..86ab15bb63322 100644 --- a/docs/internals/providers.md +++ b/docs/internals/providers.md @@ -116,6 +116,11 @@ Ownership is cached per instance and re-read immediately before an update runs. changed since the advisory, and reports success only when the refreshed provider is still installed with a readable, current version. +A runtime T3 Code installs itself, such as Antigravity's, has no command to run. Its capabilities +set `managedInstall` instead, and the runner updates it through +[`ProviderInstallation`](../../apps/server/src/provider/providerInstallation.ts), the same install +its setup section starts, so validation, activation and the model refresh are not repeated here. + ## Protocol traps Codex async questions arrive as notifications and are answered with a new user message. There is diff --git a/docs/user/providers-antigravity.md b/docs/user/providers-antigravity.md index 1720baa5e6f2e..dcec88e74664b 100644 --- a/docs/user/providers-antigravity.md +++ b/docs/user/providers-antigravity.md @@ -58,7 +58,8 @@ Leave the field blank to use the managed runtime, or a compatible executable on ## Update the managed runtime In web or desktop provider settings, choose **Update Antigravity** when an update -is available. T3 checks Google's CLI release channel while provider update checks +is available. **Update all** updates it along with your other providers; an +executable you set a path to stays yours to update. T3 checks Google's CLI release channel while provider update checks are enabled. Installing or reinstalling also checks that channel. Updates keep your profile and existing runtime available if the new release fails validation. diff --git a/packages/provider-core/src/server/maintenance.ts b/packages/provider-core/src/server/maintenance.ts index 9d2a63c5bfbe3..67c58063ed8c1 100644 --- a/packages/provider-core/src/server/maintenance.ts +++ b/packages/provider-core/src/server/maintenance.ts @@ -5,6 +5,11 @@ export interface ProviderMaintenanceCapabilities { readonly provider: ProviderDriverKind; readonly packageName: string | null; readonly update: ProviderMaintenanceCommandAction | null; + /** + * Set, with `update` null, when T3 Code installs the provider's runtime itself: updating is a + * reinstall by the server, with no command to run or show. + */ + readonly managedInstall?: { readonly lockKey: string }; /** undefined defers to npm; null means the installer could not determine the latest version. */ readonly latestVersion?: string | null; /** diff --git a/packages/provider-core/src/server/maintenanceResolver.ts b/packages/provider-core/src/server/maintenanceResolver.ts index b339ea49ae204..6b90536ff49e4 100644 --- a/packages/provider-core/src/server/maintenanceResolver.ts +++ b/packages/provider-core/src/server/maintenanceResolver.ts @@ -1336,7 +1336,7 @@ function deriveVersionAdvisory(input: { return { status: "behind_latest", message: - input.capabilities.update === null + input.capabilities.update === null && input.capabilities.managedInstall === undefined ? manualUpdateMessage(input.latestVersion, input.capabilities.installPath) : PROVIDER_UPDATE_ACTION_TOAST_MESSAGE, }; @@ -1368,7 +1368,7 @@ export function createProviderVersionAdvisory(input: { resolveLatestProviderUpdateAction(capabilities, latestVersion)?.command ?? capabilities.manualCommand ?? null, - canUpdate: capabilities.update !== null, + canUpdate: capabilities.update !== null || capabilities.managedInstall !== undefined, canInstallVersion: makeTargetedProviderUpdateAction(capabilities, "0.0.0") !== null, checkedAt: input.checkedAt ?? null, message: advisory.message, From afd9b235fa1be427070fef17e366164b7df99f95 Mon Sep 17 00:00:00 2001 From: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Date: Fri, 20 Nov 2026 10:08:45 +0100 Subject: [PATCH 3/9] fix(web): the provider card can run an update that has no command The Antigravity card showed its update with nothing to press, because the card's Update now button needed an update command as well. It now needs only an update the server can run, like Update all. Co-authored-by: Claude Fable 5.2 --- apps/server/src/provider/Drivers/AntigravityDriver.test.ts | 2 +- .../ProviderUpdateLaunchNotification.logic.test.ts | 4 +++- .../components/ProviderUpdateLaunchNotification.logic.ts | 7 +++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/apps/server/src/provider/Drivers/AntigravityDriver.test.ts b/apps/server/src/provider/Drivers/AntigravityDriver.test.ts index b56f8ebd722bb..d1cfdc4de2390 100644 --- a/apps/server/src/provider/Drivers/AntigravityDriver.test.ts +++ b/apps/server/src/provider/Drivers/AntigravityDriver.test.ts @@ -380,7 +380,7 @@ it.layer(layerTest)("AntigravityDriver", (it) => { updateChecks: false, expected: { status: "unknown", latestVersion: null, canUpdate: true }, }, - ] as const)("reports an update for $name", ({ source, latest, updateChecks, expected }) => + ] as const)("advises on updating $name", ({ source, latest, updateChecks, expected }) => Effect.gen(function* () { const h = yield* makeHarness({ updateChecks }); h.controls.selected = { ...h.first, source }; diff --git a/apps/web/src/components/ProviderUpdateLaunchNotification.logic.test.ts b/apps/web/src/components/ProviderUpdateLaunchNotification.logic.test.ts index 2215ae8472fcf..ad820d72d5eea 100644 --- a/apps/web/src/components/ProviderUpdateLaunchNotification.logic.test.ts +++ b/apps/web/src/components/ProviderUpdateLaunchNotification.logic.test.ts @@ -130,7 +130,7 @@ describe("provider update launch notification logic", () => { ).toBe(true); }); - it("offers one-click updates for a runtime the server installs, which has no command", () => { + it("offers updates for a runtime the server installs, which has no command", () => { const managed = updateCandidate({ driver: driver("antigravity"), updateCommand: null }); const ownExecutable = provider({ driver: driver("antigravity"), @@ -147,7 +147,9 @@ describe("provider update launch notification logic", () => { }); expect(canOneClickUpdateProviderCandidate(managed, [managed, ownExecutable])).toBe(true); + expect(isProviderSettingsUpdateCandidate(managed)).toBe(true); expect(canOneClickUpdateProviderCandidate(manualOnly, [manualOnly])).toBe(false); + expect(isProviderSettingsUpdateCandidate(manualOnly)).toBe(false); }); it("keeps the inline update action available while a provider update is already running", () => { diff --git a/apps/web/src/components/ProviderUpdateLaunchNotification.logic.ts b/apps/web/src/components/ProviderUpdateLaunchNotification.logic.ts index 59bd7228640c2..11642f62b1f61 100644 --- a/apps/web/src/components/ProviderUpdateLaunchNotification.logic.ts +++ b/apps/web/src/components/ProviderUpdateLaunchNotification.logic.ts @@ -26,7 +26,6 @@ export type ProviderUpdateCandidate = ServerProvider & { export type ProviderSettingsUpdateCandidate = ServerProvider & { readonly versionAdvisory: NonNullable & { readonly canUpdate: true; - readonly updateCommand: string; }; }; @@ -162,8 +161,7 @@ export function isProviderSettingsUpdateCandidate( provider.compatibilityAdvisory?.latestVersionStatus !== "broken" && provider.compatibilityAdvisory?.latestVersionStatus !== "unsupported" && provider.versionAdvisory?.status === "behind_latest" && - provider.versionAdvisory.canUpdate === true && - provider.versionAdvisory.updateCommand !== null + provider.versionAdvisory.canUpdate === true ); } @@ -180,7 +178,8 @@ export function hasOneClickUpdateProviderCandidate( return false; } - // A runtime the server installs itself, such as Antigravity's, updates with no command (null). + // A runtime the server installs itself, such as Antigravity's, updates with no command (null), + // so `canUpdate` alone says the server can run the update. const updateCommands = new Set(); for (const provider of driverProviders) { if (!isProviderUpdateCandidate(provider)) { From 95c77f703219b58da641de4363fe8695513ddbb3 Mon Sep 17 00:00:00 2001 From: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Date: Fri, 20 Nov 2026 10:10:33 +0100 Subject: [PATCH 4/9] test(providers): keep the names of the managed runtime update tests The provider card change renamed two tests it did not need to. Co-authored-by: Claude Fable 5.2 --- apps/server/src/provider/Drivers/AntigravityDriver.test.ts | 2 +- .../components/ProviderUpdateLaunchNotification.logic.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/server/src/provider/Drivers/AntigravityDriver.test.ts b/apps/server/src/provider/Drivers/AntigravityDriver.test.ts index d1cfdc4de2390..b56f8ebd722bb 100644 --- a/apps/server/src/provider/Drivers/AntigravityDriver.test.ts +++ b/apps/server/src/provider/Drivers/AntigravityDriver.test.ts @@ -380,7 +380,7 @@ it.layer(layerTest)("AntigravityDriver", (it) => { updateChecks: false, expected: { status: "unknown", latestVersion: null, canUpdate: true }, }, - ] as const)("advises on updating $name", ({ source, latest, updateChecks, expected }) => + ] as const)("reports an update for $name", ({ source, latest, updateChecks, expected }) => Effect.gen(function* () { const h = yield* makeHarness({ updateChecks }); h.controls.selected = { ...h.first, source }; diff --git a/apps/web/src/components/ProviderUpdateLaunchNotification.logic.test.ts b/apps/web/src/components/ProviderUpdateLaunchNotification.logic.test.ts index ad820d72d5eea..9118bfbf9ad2a 100644 --- a/apps/web/src/components/ProviderUpdateLaunchNotification.logic.test.ts +++ b/apps/web/src/components/ProviderUpdateLaunchNotification.logic.test.ts @@ -130,7 +130,7 @@ describe("provider update launch notification logic", () => { ).toBe(true); }); - it("offers updates for a runtime the server installs, which has no command", () => { + it("offers one-click updates for a runtime the server installs, which has no command", () => { const managed = updateCandidate({ driver: driver("antigravity"), updateCommand: null }); const ownExecutable = provider({ driver: driver("antigravity"), From d31ad58a3a3b985a16ad0cb25bc833c86b572150 Mon Sep 17 00:00:00 2001 From: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Date: Fri, 20 Nov 2026 10:17:51 +0100 Subject: [PATCH 5/9] docs(providers): rewrap the Antigravity update paragraph The Update all sentence left one line far past the paragraph's width. Co-Authored-By: Claude Opus 5.5 --- docs/user/providers-antigravity.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/user/providers-antigravity.md b/docs/user/providers-antigravity.md index dcec88e74664b..187205c666a1d 100644 --- a/docs/user/providers-antigravity.md +++ b/docs/user/providers-antigravity.md @@ -59,9 +59,10 @@ Leave the field blank to use the managed runtime, or a compatible executable on In web or desktop provider settings, choose **Update Antigravity** when an update is available. **Update all** updates it along with your other providers; an -executable you set a path to stays yours to update. T3 checks Google's CLI release channel while provider update checks -are enabled. Installing or reinstalling also checks that channel. Updates keep -your profile and existing runtime available if the new release fails validation. +executable you set a path to stays yours to update. T3 checks Google's CLI +release channel while provider update checks are enabled. Installing or +reinstalling also checks that channel. Updates keep your profile and existing +runtime available if the new release fails validation. 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 From de7a6a91f9dab9ff84806ef4dca60adc0f415459 Mon Sep 17 00:00:00 2001 From: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Date: Fri, 20 Nov 2026 10:38:58 +0100 Subject: [PATCH 6/9] fix(providers): make managed Antigravity updates safe to refresh and cancel Co-authored-by: GPT 6.2 Sol --- .../provider/AntigravityInstallation.test.ts | 72 ++++++ .../src/provider/AntigravityInstallation.ts | 220 ++++++++++-------- .../src/provider/AntigravityProvider.ts | 22 +- .../Drivers/AntigravityDriver.test.ts | 68 +++++- .../src/provider/Drivers/AntigravityDriver.ts | 95 ++++---- .../src/provider/providerInstallation.test.ts | 56 +++-- .../src/provider/providerInstallation.ts | 106 +++++---- .../providerMaintenanceRunner.test.ts | 3 +- .../src/provider/providerMaintenanceRunner.ts | 13 +- docs/internals/providers.md | 3 +- docs/user/providers-antigravity.md | 5 +- 11 files changed, 447 insertions(+), 216 deletions(-) diff --git a/apps/server/src/provider/AntigravityInstallation.test.ts b/apps/server/src/provider/AntigravityInstallation.test.ts index 5dcd840991f83..ff395ba17027f 100644 --- a/apps/server/src/provider/AntigravityInstallation.test.ts +++ b/apps/server/src/provider/AntigravityInstallation.test.ts @@ -1084,6 +1084,78 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("Antigravity inst }), ); + it.effect("reports a join when setup starts during another release lookup", () => + Effect.gen(function* () { + const firstLookup = yield* Deferred.make(); + const resumeLookup = yield* Deferred.make(); + const downloading = yield* Deferred.make(); + let lookups = 0; + const { installation } = yield* makeHarness({ + native: true, + platform: "win32", + archive: Buffer.from(serverContents), + beforeManifest: Effect.suspend(() => + ++lookups === 1 + ? Deferred.succeed(firstLookup, undefined).pipe( + Effect.andThen(Deferred.await(resumeLookup)), + ) + : Effect.void, + ), + body: Stream.fromEffect(Deferred.succeed(downloading, undefined)).pipe( + Stream.flatMap(() => Stream.never), + ), + }); + const starting = yield* installation.startOperation().pipe(Effect.forkScoped); + yield* Deferred.await(firstLookup); + const setup = yield* installation.start; + yield* Deferred.await(downloading); + yield* Deferred.succeed(resumeLookup, undefined); + expect(yield* Fiber.join(starting)).toMatchObject({ + owned: false, + state: { operationId: setup.operationId, phase: "downloading" }, + }); + if (setup.operationId !== null) yield* installation.cancel(setup.operationId); + }), + ); + + it.effect("refreshes within the background throttle and only starts the checked release", () => + Effect.gen(function* () { + let channelVersion = "1.5.12"; + const { installation, requests, stagingReleased } = yield* makeHarness({ + native: true, + platform: "win32", + archive: Buffer.from(serverContents), + nativeManifest: (manifest) => ({ + ...manifest, + version: channelVersion, + url: manifest.url.replace(manifest.version, channelVersion), + }), + }); + yield* installation.checkForUpdate; + expect((yield* installation.state).version).toBe("1.5.12"); + + channelVersion = "1.5.13"; + yield* installation.checkForUpdate; + expect((yield* installation.state).version).toBe("1.5.12"); + yield* installation.refreshUpdate; + expect((yield* installation.state).version).toBe("1.5.13"); + expect(yield* installation.startOperation("1.5.12").pipe(Effect.flip)).toMatchObject({ + operation: "start", + detail: expect.stringContaining("release changed"), + }); + expect((yield* installation.state).operationId).toBeNull(); + expect(requests).toHaveLength(2); + + channelVersion = "1.5.14"; + yield* installation.startOperation("1.5.13"); + expect(yield* terminalState(installation)).toMatchObject({ + phase: "succeeded", + installedVersion: "1.5.13", + }); + yield* Deferred.await(stagingReleased); + }), + ); + it.effect("keeps leased releases available while new sessions resolve the new release", () => Effect.gen(function* () { const manifestEntered = yield* Deferred.make(); diff --git a/apps/server/src/provider/AntigravityInstallation.ts b/apps/server/src/provider/AntigravityInstallation.ts index 569a4a6308756..8690818d6f5ae 100644 --- a/apps/server/src/provider/AntigravityInstallation.ts +++ b/apps/server/src/provider/AntigravityInstallation.ts @@ -113,12 +113,20 @@ interface AntigravityInstallationService { version: string, ) => Effect.Effect; readonly start: Effect.Effect; + /** Reports ownership from the start lock. A checked version must still match the selected release. */ + readonly startOperation: ( + expectedVersion?: string, + ) => Effect.Effect< + { readonly state: ProviderInstallState; readonly owned: boolean }, + AntigravityInstallationError + >; readonly cancel: ( operationId: string, ) => Effect.Effect; readonly state: Effect.Effect; readonly changes: Stream.Stream; readonly checkForUpdate: Effect.Effect; + readonly refreshUpdate: Effect.Effect; readonly remove: ( protectedBinaryPaths?: ReadonlyArray, ) => Effect.Effect; @@ -1265,104 +1273,118 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma ); }); - const start = Effect.gen(function* () { - const current = yield* SubscriptionRef.get(state); - if (isRunning(current)) return current; - yield* refreshRelease(true); - return yield* gate.withPermit( - Effect.gen(function* () { - const current = yield* SubscriptionRef.get(state); - if (isRunning(current)) return current; - if (!supported) { - return yield* installationError( - "start", - `Google does not publish an Antigravity runtime for ${platform}-${arch}. Use a supported remote environment or a custom executable.`, - ); - } - const asset = - releaseAsset !== null && !(yield* isWithdrawn(releaseAsset.version)) - ? releaseAsset - : null; - const installed = yield* resolve().pipe(Effect.option); - const reuse = - Option.isSome(installed) && - installed.value.source === "managed" && - (asset === null || compareSemverVersions(installed.value.version!, asset.version) > 0) - ? installed.value - : undefined; - if (asset === null && reuse === undefined) - return yield* installationError( - "start", - "Could not find a native Antigravity CLI release. Check the network connection and try again.", - ); - const operationId = yield* random.uuidV4(); - const next: ProviderInstallState = { - driver: DRIVER, - operationId, - phase: reuse === undefined ? "downloading" : "verifying", - downloadedBytes: 0, - totalBytes: null, - version: reuse?.version ?? asset?.version ?? null, - installedVersion: current.installedVersion, - canRemove: current.canRemove, - message: + const startOperation = Effect.fn("AntigravityInstallation.startOperation")( + function* (expectedVersion?: string) { + const checkVersion = (version: string | null) => + expectedVersion !== undefined && expectedVersion !== version + ? installationError( + "start", + "The Antigravity release changed. Check for updates and try again.", + ) + : Effect.void; + const current = yield* SubscriptionRef.get(state); + if (expectedVersion === undefined && !isRunning(current)) { + yield* refreshRelease(true).pipe(Effect.interruptible); + } + return yield* gate.withPermit( + Effect.gen(function* () { + const current = yield* SubscriptionRef.get(state); + if (isRunning(current)) { + yield* checkVersion(current.version); + return { state: current, owned: false }; + } + if (!supported) { + return yield* installationError( + "start", + `Google does not publish an Antigravity runtime for ${platform}-${arch}. Use a supported remote environment or a custom executable.`, + ); + } + const offered = releaseAsset; + const asset = offered !== null && !(yield* isWithdrawn(offered.version)) ? offered : null; + const installed = yield* resolve().pipe(Effect.option); + const reuse = + Option.isSome(installed) && + installed.value.source === "managed" && + (asset === null || compareSemverVersions(installed.value.version!, asset.version) > 0) + ? installed.value + : undefined; + if (asset === null && reuse === undefined) + return yield* installationError( + "start", + "Could not find a native Antigravity CLI release. Check the network connection and try again.", + ); + const version = reuse?.version ?? asset?.version ?? null; + yield* checkVersion(version); + const operationId = yield* random.uuidV4(); + const next: ProviderInstallState = { + driver: DRIVER, + operationId, + phase: reuse === undefined ? "downloading" : "verifying", + downloadedBytes: 0, + totalBytes: null, + version, + installedVersion: current.installedVersion, + canRemove: current.canRemove, + message: + reuse === undefined + ? "Downloading Google's official Antigravity runtime." + : "Checking the installed runtime.", + }; + yield* SubscriptionRef.set(state, next); + const work = ( reuse === undefined - ? "Downloading Google's official Antigravity runtime." - : "Checking the installed runtime.", - }; - yield* SubscriptionRef.set(state, next); - const work = ( - reuse === undefined - ? install(asset!) - : validate(reuse, reuse.version!).pipe( - Effect.scoped, - withValidationTimeout, - Effect.andThen(ensureEligible(reuse.version!)), - Effect.andThen( - SubscriptionRef.update(state, (value) => ({ - ...value, - phase: "succeeded" as const, - installedVersion: reuse.version, - message: null, - })), - ), - ) - ).pipe( - Effect.mapError( - wrapFailure("verify", "Could not verify the installed Antigravity runtime."), - ), - Effect.onExit((exit) => - Exit.isFailure(exit) - ? SubscriptionRef.update(state, (value) => { - if (value.operationId !== operationId || value.phase === "succeeded") - return value; - const error = Cause.findErrorOption(exit.cause); - const cancelled = Cause.hasInterruptsOnly(exit.cause); - return { - ...value, - phase: cancelled ? "cancelled" : "failed", - message: cancelled - ? "Installation cancelled. The previous runtime is unchanged." - : Option.isSome(error) - ? error.value.detail - : "Could not finish the Antigravity installation. Check disk space and directory access.", - } satisfies ProviderInstallState; - }) - : Effect.void, - ), - Effect.ignoreCause, - Effect.ensuring( - Effect.sync(() => { - if (running?.operationId === operationId) running = undefined; - }), - ), - ); - const fiber = yield* Effect.forkIn(Effect.interruptible(work), serviceScope); - running = { operationId, fiber }; - return next; - }).pipe(Effect.uninterruptible), - ); - }).pipe(Effect.mapError(wrapFailure("start", "Could not start the Antigravity installation."))); + ? install(asset!) + : validate(reuse, reuse.version!).pipe( + Effect.scoped, + withValidationTimeout, + Effect.andThen(ensureEligible(reuse.version!)), + Effect.andThen( + SubscriptionRef.update(state, (value) => ({ + ...value, + phase: "succeeded" as const, + installedVersion: reuse.version, + message: null, + })), + ), + ) + ).pipe( + Effect.mapError( + wrapFailure("verify", "Could not verify the installed Antigravity runtime."), + ), + Effect.onExit((exit) => + Exit.isFailure(exit) + ? SubscriptionRef.update(state, (value) => { + if (value.operationId !== operationId || value.phase === "succeeded") + return value; + const error = Cause.findErrorOption(exit.cause); + const cancelled = Cause.hasInterruptsOnly(exit.cause); + return { + ...value, + phase: cancelled ? "cancelled" : "failed", + message: cancelled + ? "Installation cancelled. The previous runtime is unchanged." + : Option.isSome(error) + ? error.value.detail + : "Could not finish the Antigravity installation. Check disk space and directory access.", + } satisfies ProviderInstallState; + }) + : Effect.void, + ), + Effect.ignoreCause, + Effect.ensuring( + Effect.sync(() => { + if (running?.operationId === operationId) running = undefined; + }), + ), + ); + const fiber = yield* Effect.forkIn(Effect.interruptible(work), serviceScope); + running = { operationId, fiber }; + return { state: next, owned: true }; + }).pipe(Effect.uninterruptible), + ); + }, + Effect.mapError(wrapFailure("start", "Could not start the Antigravity installation.")), + ); const cancel = Effect.fn("AntigravityInstallation.cancel")(function* (operationId: string) { return yield* gate.withPermit( @@ -1516,11 +1538,13 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma resolve, acquire, compatibility, - start, + start: startOperation().pipe(Effect.map((operation) => operation.state)), + startOperation, cancel, state: SubscriptionRef.get(state), changes: SubscriptionRef.changes(state), checkForUpdate: refreshRelease().pipe(Effect.ignore), + refreshUpdate: refreshRelease(true).pipe(Effect.ignore), remove, }); }); diff --git a/apps/server/src/provider/AntigravityProvider.ts b/apps/server/src/provider/AntigravityProvider.ts index 539cbd31bb1f4..cf786bcbb7d87 100644 --- a/apps/server/src/provider/AntigravityProvider.ts +++ b/apps/server/src/provider/AntigravityProvider.ts @@ -32,6 +32,10 @@ import { makeManagedServerProvider, } from "@t3tools/provider-core/server/managedProvider"; import { makeManualOnlyProviderMaintenanceCapabilities } from "@t3tools/provider-core/server/maintenanceResolver"; +import { + haveProviderSnapshotSettingsChanged, + makeProviderSnapshotSettingsSource, +} from "@t3tools/provider-core/server/snapshotSettings"; import type { ManagedServerProvider } from "@t3tools/provider-core/server/snapshot"; import { buildServerProvider, @@ -169,6 +173,7 @@ interface AntigravityProviderOptions { readonly probeUsage?: Effect.Effect; readonly clearUsage?: Effect.Effect; readonly resolveMaintenance?: ManagedServerProvider["resolveMaintenance"]; + readonly releaseChanges?: Stream.Stream; readonly auth?: { readonly type: string; readonly label: string }; } @@ -371,15 +376,24 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func provider: ProviderDriverKind.make("antigravity"), packageName: null, }); + const snapshotSettings = yield* makeProviderSnapshotSettingsSource(settings); + const metadataChanges = SubscriptionRef.changes(metadata); + const snapshotChanges = options.releaseChanges + ? Stream.merge( + metadataChanges, + options.releaseChanges.pipe(Stream.mapEffect(() => SubscriptionRef.get(metadata))), + ) + : metadataChanges; const managed = yield* makeManagedServerProvider({ resolveMaintenance: options.resolveMaintenance ?? (() => Effect.succeed(manualMaintenance)), - getSettings: Effect.succeed(settings), - streamSettings: Stream.empty, - haveSettingsChanged: () => false, + getSettings: snapshotSettings.getSettings, + streamSettings: snapshotSettings.streamSettings, + haveSettingsChanged: haveProviderSnapshotSettingsChanged, + checkProviderOnSettingsChange: () => false, initialSnapshot: () => getSnapshot, checkProvider: checkProvider(), enrichSnapshot: ({ publishSnapshot }) => - SubscriptionRef.changes(metadata).pipe( + snapshotChanges.pipe( Stream.runForEach((state) => options.stampIdentity(state.draft).pipe(Effect.flatMap(publishSnapshot)), ), diff --git a/apps/server/src/provider/Drivers/AntigravityDriver.test.ts b/apps/server/src/provider/Drivers/AntigravityDriver.test.ts index b56f8ebd722bb..3242289251d4f 100644 --- a/apps/server/src/provider/Drivers/AntigravityDriver.test.ts +++ b/apps/server/src/provider/Drivers/AntigravityDriver.test.ts @@ -33,6 +33,7 @@ import { ANTIGRAVITY_AUTH_STDOUT_PREFIX, resolveAntigravityInstanceDirectories, } from "../antigravityAuthSupport.ts"; +import * as ProviderLatestVersions from "@t3tools/provider-core/server/ProviderLatestVersions"; import * as ProviderEventLoggers from "@t3tools/provider-core/server/ProviderEventLoggers"; import * as McpProviderSessions from "@t3tools/provider-core/server/McpProviderSessions"; import * as ModelManifest from "../ModelManifest.ts"; @@ -85,9 +86,17 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* ( /** Extra instance variables, such as ones a parent T3 turn already exported. */ readonly environment?: ReadonlyArray<{ readonly name: string; readonly value: string }>; readonly updateChecks?: boolean; + readonly awaitServerReady?: Effect.Effect; + readonly refreshUpdate?: ( + state: SubscriptionRef.SubscriptionRef, + ) => Effect.Effect; } = {}, ) { const host = yield* ProviderHost.ProviderHost; + const serverSettings = yield* SubscriptionRef.make({ + ...(yield* host.settings.get), + enableProviderUpdateChecks: options.updateChecks ?? true, + }); const installState = yield* SubscriptionRef.make(idleInstallState); const checkedForUpdate = yield* Deferred.make(); const fs = yield* FileSystem.FileSystem; @@ -180,6 +189,7 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* ( managedDirectory: root, state: SubscriptionRef.get(installState), changes: SubscriptionRef.changes(installState), + refreshUpdate: options.refreshUpdate?.(installState) ?? Effect.void, checkForUpdate: Deferred.succeed(checkedForUpdate, undefined).pipe(Effect.asVoid), compatibility: (version) => Effect.succeed( @@ -268,14 +278,11 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* ( Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, observedSpawner), Effect.provideService(ProviderHost.ProviderHost, { ...host, + ...(options.awaitServerReady ? { awaitServerReady: options.awaitServerReady } : {}), settings: { ...host.settings, - get: host.settings.get.pipe( - Effect.map((settings) => ({ - ...settings, - enableProviderUpdateChecks: options.updateChecks ?? true, - })), - ), + get: SubscriptionRef.get(serverSettings), + changes: SubscriptionRef.changes(serverSettings), }, }), ); @@ -310,6 +317,7 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* ( signedOut, controls, installState, + serverSettings, checkedForUpdate, acquisitions, releases, @@ -342,6 +350,7 @@ const layerDeps = ServerConfig.layerTest(process.cwd(), { ), ), Layer.provideMerge(ModelManifest.layerTest), + Layer.provideMerge(ProviderLatestVersions.layer), Layer.provideMerge(IdAllocator.layer), Layer.provideMerge(McpProviderSessions.layer), ); @@ -413,6 +422,53 @@ it.layer(layerTest)("AntigravityDriver", (it) => { }), ); + it.effect("awaits a release lookup on an explicit refresh", () => + Effect.gen(function* () { + const lookupStarted = yield* Deferred.make(); + const lookupFinished = yield* Deferred.make(); + const h = yield* makeHarness({ + awaitServerReady: Effect.never, + refreshUpdate: (state) => + Deferred.succeed(lookupStarted, undefined).pipe( + Effect.andThen(Deferred.await(lookupFinished)), + Effect.andThen( + SubscriptionRef.update(state, (current) => ({ + ...current, + version: "1.5.13", + })), + ), + ), + }); + const refreshing = yield* h.instance.snapshot.refresh.pipe(Effect.forkScoped); + yield* Deferred.await(lookupStarted); + yield* Deferred.succeed(lookupFinished, undefined); + expect((yield* Fiber.join(refreshing)).versionAdvisory).toMatchObject({ + status: "behind_latest", + latestVersion: "1.5.13", + }); + }), + ); + + it.effect("clears a published update when update checks are disabled", () => + Effect.gen(function* () { + const h = yield* makeHarness({ awaitServerReady: Effect.never }); + yield* SubscriptionRef.update(h.installState, (state) => ({ ...state, version: "1.5.13" })); + expect((yield* h.instance.snapshot.refresh).versionAdvisory?.status).toBe("behind_latest"); + const cleared = yield* h.instance.snapshot.streamChanges.pipe( + Stream.filter((snapshot) => snapshot.versionAdvisory?.status === "unknown"), + Stream.runHead, + Effect.forkScoped({ startImmediately: true }), + ); + yield* SubscriptionRef.update(h.serverSettings, (settings) => ({ + ...settings, + enableProviderUpdateChecks: false, + })); + expect(yield* Fiber.join(cleared)).toMatchObject({ + value: { versionAdvisory: { latestVersion: null } }, + }); + }), + ); + it.effect.skipIf(windowsHost)( "refreshes the selected executable and limits form capabilities to chat", () => diff --git a/apps/server/src/provider/Drivers/AntigravityDriver.ts b/apps/server/src/provider/Drivers/AntigravityDriver.ts index 5d1f9fb6020e0..55c8a0a1d5f34 100644 --- a/apps/server/src/provider/Drivers/AntigravityDriver.ts +++ b/apps/server/src/provider/Drivers/AntigravityDriver.ts @@ -1,3 +1,4 @@ +import * as ProviderLatestVersions from "@t3tools/provider-core/server/ProviderLatestVersions"; import * as McpProviderSessions from "@t3tools/provider-core/server/McpProviderSessions"; import { AntigravitySettings, @@ -57,7 +58,7 @@ import { import type * as AcpSessionRuntime from "@t3tools/provider-acp/server/AcpSessionRuntime"; import type { ServerProviderDraft } from "@t3tools/provider-core/server/snapshotProbe"; import { - createProviderVersionAdvisory, + enrichProviderSnapshotWithVersionAdvisory, makeManualOnlyProviderMaintenanceCapabilities, type ProviderMaintenanceCapabilities, } from "@t3tools/provider-core/server/maintenanceResolver"; @@ -109,6 +110,7 @@ function refreshFailureDetail(cause: unknown) { export type AntigravityDriverEnv = | AntigravityInstallation.AntigravityInstallation | ProviderHost.ProviderHost + | ProviderLatestVersions.ProviderLatestVersions | ChildProcessSpawner.ChildProcessSpawner | Digest.Digest | SecureRandom.SecureRandom @@ -209,48 +211,54 @@ export const AntigravityDriver: ProviderDriver< provider: DRIVER, packageName: null, }); - // Set by the health check, which resolves the executable. Only the runtime T3 Code - // installed updates from here; a custom or PATH executable stays as its owner left it. + // Keep ownership from the last executable resolution so snapshot enrichment avoids disk I/O. const usesManagedRuntime = yield* Ref.make(false); - const resolveMaintenance = () => - Effect.zipWith( - Ref.get(usesManagedRuntime), - installation.state, - (managed, install): ProviderMaintenanceCapabilities => - managed - ? { - provider: DRIVER, - packageName: null, - update: null, - managedInstall: { lockKey: "antigravity-managed" }, - latestVersion: install.version, - // The installation has picked the release to run, so any other one is behind it. - compareVersions: (current, latest) => (current === latest ? 0 : -1), - } - : manualMaintenance, - ); + const latestVersions = yield* ProviderLatestVersions.ProviderLatestVersions; const updateChecksEnabled = host.settings.get.pipe( Effect.map((current) => current.enableProviderUpdateChecks), Effect.orElseSucceed(() => false), ); - const classifyModels = (draft: ServerProviderDraft) => - Effect.all([currentCatalog, resolveMaintenance(), updateChecksEnabled]).pipe( - Effect.map(([catalog, maintenance, checksEnabled]) => - stampIdentity({ - ...ModelCatalog.applyModelCatalog(draft, catalog), - versionAdvisory: createProviderVersionAdvisory({ - driver: DRIVER, - currentVersion: draft.version, - latestVersion: - checksEnabled && draft.enabled && draft.installed - ? (maintenance.latestVersion ?? null) - : null, - checkedAt: draft.checkedAt, - maintenanceCapabilities: maintenance, - }), - }), - ), + const resolveMaintenance = Effect.fn("AntigravityDriver.resolveMaintenance")( + function* (options?: { + readonly fresh?: boolean; + }): Effect.fn.Return { + if (options?.fresh && settings.enabled && !settings.binaryPath) { + const executable = yield* installation + .resolve(settings.binaryPath, processEnvironment) + .pipe(Effect.orElseSucceed(() => null)); + const managed = executable?.source === "managed"; + yield* Ref.set(usesManagedRuntime, managed); + if (managed && (yield* updateChecksEnabled)) yield* installation.refreshUpdate; + } + if (!(yield* Ref.get(usesManagedRuntime))) return manualMaintenance; + const install = yield* installation.state; + return { + provider: DRIVER, + packageName: null, + update: null, + managedInstall: { lockKey: "antigravity-managed" }, + latestVersion: install.version, + // The installer has already chosen between the channel release and the installed version. + compareVersions: (current, latest) => (current === latest ? 0 : -1), + }; + }, + ); + const classifyModels = Effect.fn("AntigravityDriver.classifyModels")(function* ( + draft: ServerProviderDraft, + ) { + const catalog = yield* currentCatalog; + const snapshot = stampIdentity(ModelCatalog.applyModelCatalog(draft, catalog)); + return yield* enrichProviderSnapshotWithVersionAdvisory( + snapshot, + yield* resolveMaintenance(), + { + enableProviderUpdateChecks: yield* updateChecksEnabled, + }, + ).pipe( + Effect.provideService(ProviderLatestVersions.ProviderLatestVersions, latestVersions), + Effect.provideService(HttpClient.HttpClient, httpClient), ); + }); const prepareSpawn = Effect.fn("AntigravityDriver.prepareSpawn")(function* ( cwd: string, @@ -621,6 +629,11 @@ export const AntigravityDriver: ProviderDriver< environment: processEnvironment, stampIdentity: classifyModels, resolveMaintenance, + releaseChanges: installation.changes.pipe( + Stream.map((state) => state.version), + Stream.changes, + Stream.map(() => undefined), + ), probe, probeUsage: usage.probe, clearUsage: usage.clear, @@ -641,14 +654,6 @@ export const AntigravityDriver: ProviderDriver< }), ), ); - // The registry keeps the last published snapshot, so a newly found release needs a new one. - yield* installation.changes.pipe( - Stream.map((state) => state.version), - Stream.changes, - Stream.drop(1), - Stream.runForEach(() => provider.snapshot.refresh.pipe(Effect.ignoreCause({ log: true }))), - Effect.forkScoped, - ); const defaultModel = currentCatalog.pipe(Effect.map((catalog) => catalog?.defaultChatModel)); const orchestrationAdapter = yield* makeAntigravityAdapterV2({ instanceId, diff --git a/apps/server/src/provider/providerInstallation.test.ts b/apps/server/src/provider/providerInstallation.test.ts index 6099c0f9e80c1..52bd0de8e2770 100644 --- a/apps/server/src/provider/providerInstallation.test.ts +++ b/apps/server/src/provider/providerInstallation.test.ts @@ -39,6 +39,13 @@ const state: ProviderInstallState = { message: null, }; +const running = { + ...state, + operationId: "install-1", + phase: "downloading", + message: "Downloading.", +} satisfies ProviderInstallState; + function instance(kind = driver, id = instanceId): ProviderInstance { return { instanceId: id, @@ -60,6 +67,7 @@ function instance(kind = driver, id = instanceId): ProviderInstance { const makeHarness = Effect.fn("providerInstallation.test.makeHarness")(function* ( input: { + beforeInstallStart?: Effect.Effect; instance?: ProviderInstance; others?: ReadonlyArray; settings?: Parameters[0]; @@ -76,6 +84,14 @@ const makeHarness = Effect.fn("providerInstallation.test.makeHarness")(function* const all = [configured, ...(input.others ?? [])]; const refreshedInstances: ProviderInstanceId[] = []; let watches = 0; + const startOperation = Effect.gen(function* () { + calls.push("start"); + yield* input.beforeInstallStart ?? Effect.void; + const current = yield* SubscriptionRef.get(installationState); + if (current.phase === "downloading") return { state: current, owned: false }; + yield* SubscriptionRef.set(installationState, running); + return { state: running, owned: true }; + }); const dependencies = Layer.mergeAll( ServerSettings.layerTest(input.settings), Layer.mock(ProviderInstanceRegistry.ProviderInstanceRegistry)({ @@ -118,15 +134,8 @@ const makeHarness = Effect.fn("providerInstallation.test.makeHarness")(function* Layer.mock(AntigravityInstallation.AntigravityInstallation)({ managedDirectory: "/unused-managed-runtime", checkForUpdate: Effect.void, - start: Effect.sync(() => { - calls.push("start"); - return { - ...state, - operationId: "install-1", - phase: "downloading" as const, - message: "Downloading.", - }; - }).pipe(Effect.tap((started) => SubscriptionRef.set(installationState, started))), + start: startOperation.pipe(Effect.map((operation) => operation.state)), + startOperation: () => startOperation, cancel: () => Effect.sync(() => { calls.push("cancel"); @@ -286,12 +295,6 @@ describe("provider installation routing", () => { ); const watched = () => Object.assign(instance(), { refreshModels: () => Effect.void }); - const running = { - ...state, - operationId: "install-1", - phase: "downloading", - message: "Downloading.", - } satisfies ProviderInstallState; it.effect.each([ { phase: "succeeded", message: null, error: null }, @@ -341,6 +344,29 @@ describe("provider installation routing", () => { }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)), ); + it.effect("leaves a setup install running when it starts during the update's lookup", () => + Effect.gen(function* () { + const lookingUp = yield* Deferred.make(); + const resumeLookup = yield* Deferred.make(); + const reported = yield* Deferred.make(); + const harness = yield* makeHarness({ + instance: watched(), + beforeInstallStart: Deferred.succeed(lookingUp, undefined).pipe( + Effect.andThen(Deferred.await(resumeLookup)), + ), + }); + const run = yield* harness.router + .run({ instanceId }, () => Deferred.succeed(reported, undefined)) + .pipe(Effect.forkScoped); + yield* Deferred.await(lookingUp); + yield* SubscriptionRef.set(harness.installationState, running); + yield* Deferred.succeed(resumeLookup, undefined); + yield* Deferred.await(reported); + yield* Fiber.interrupt(run); + assert.deepEqual(harness.calls, ["start"]); + }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)), + ); + it.effect("keeps external installs manual without hiding shared install status", () => Effect.gen(function* () { const harness = yield* makeHarness({ diff --git a/apps/server/src/provider/providerInstallation.ts b/apps/server/src/provider/providerInstallation.ts index 6634d1ec051c1..30198afdd6707 100644 --- a/apps/server/src/provider/providerInstallation.ts +++ b/apps/server/src/provider/providerInstallation.ts @@ -9,6 +9,7 @@ import { type ProviderSetupInput, } from "@t3tools/contracts"; import { resolveCommandPath } from "@t3tools/shared/shell"; +import * as Exit from "effect/Exit"; import * as Context from "effect/Context"; import * as Effect from "effect/Effect"; import * as Layer from "effect/Layer"; @@ -45,12 +46,13 @@ export class ProviderInstallation extends Context.Service< input: ProviderSetupInput, ) => Effect.Effect; /** - * Starts an install, or joins the one running, and waits for it. Fails with the install's - * own message unless it succeeds, and cancels an install it started when interrupted. + * Starts an Antigravity update or joins the matching operation. Cancels an operation + * this request started when interrupted. */ readonly run: ( input: ProviderSetupInput, onProgress: (message: string) => Effect.Effect, + expectedVersion?: string, ) => Effect.Effect; readonly cancel: ( input: ProviderInstallCancelInput, @@ -168,29 +170,32 @@ const make = Effect.fn("makeProviderInstallation")(function* () { } }); - const start = Effect.fn("ProviderInstallation.start")(function* (input: ProviderSetupInput) { - const { installation, driver } = yield* requireInstance(input.instanceId, "install", true); - const started = yield* installation.start.pipe(Effect.mapError(failure(input.instanceId))); - if ( - driver === ANTIGRAVITY && - started.operationId !== null && - accountCheckOperation !== started.operationId - ) { - accountCheckOperation = started.operationId; + const watchAntigravityInstall = Effect.fn("ProviderInstallation.watchAntigravityInstall")( + function* (instanceId: ProviderInstanceId, operationId: string | null) { + if (operationId === null || accountCheckOperation === operationId) return; + accountCheckOperation = operationId; // Installation outlives the request and may finish while every client is disconnected. - yield* installation.changes.pipe( - Stream.filter(hasSettled(started.operationId)), + yield* antigravityInstallation.changes.pipe( + Stream.filter(hasSettled(operationId)), Stream.runHead, Effect.flatMap((result) => Option.isSome(result) && - result.value.operationId === started.operationId && + result.value.operationId === operationId && result.value.phase === "succeeded" - ? checkManagedRuntimeInstances(input.instanceId) + ? checkManagedRuntimeInstances(instanceId) : Effect.void, ), Effect.ignore({ log: true }), Effect.forkIn(scope), ); + }, + ); + + const start = Effect.fn("ProviderInstallation.start")(function* (input: ProviderSetupInput) { + const { installation, driver } = yield* requireInstance(input.instanceId, "install", true); + const started = yield* installation.start.pipe(Effect.mapError(failure(input.instanceId))); + if (driver === ANTIGRAVITY) { + yield* watchAntigravityInstall(input.instanceId, started.operationId); } return started; }); @@ -198,40 +203,55 @@ const make = Effect.fn("makeProviderInstallation")(function* () { const run = Effect.fn("ProviderInstallation.run")(function* ( input: ProviderSetupInput, onProgress: (message: string) => Effect.Effect, + expectedVersion?: string, ) { - const { installation } = yield* requireInstance(input.instanceId, "install", true); - const before = yield* installation.state; - const started = yield* start(input); - const { operationId } = started; - const settled = yield* installation.changes.pipe( - // Download progress changes the state several times a second; report each message once. - Stream.changesWith( - (a, b) => a.operationId === b.operationId && a.phase === b.phase && a.message === b.message, - ), - Stream.tap((state) => - state.message !== null && !hasSettled(operationId)(state) - ? onProgress(state.message) - : Effect.void, - ), - Stream.filter(hasSettled(operationId)), - Stream.runHead, - Effect.onInterrupt(() => - operationId !== null && operationId !== before.operationId - ? installation.cancel(operationId).pipe(Effect.ignore) - : Effect.void, - ), - ); - const final = Option.getOrElse(settled, () => started); - if (final.operationId !== operationId || final.phase !== "succeeded") { + const { driver } = yield* requireInstance(input.instanceId, "install", true); + if (driver !== ANTIGRAVITY) { return yield* new ProviderSetupError({ instanceId: input.instanceId, operation: "install", - detail: - (final.operationId === operationId ? final.message : null) ?? - "The installation did not finish.", + detail: "Managed updates are not available for this provider instance.", }); } - return final; + return yield* Effect.acquireUseRelease( + antigravityInstallation + .startOperation(expectedVersion) + .pipe(Effect.mapError(failure(input.instanceId))), + ({ state: started }) => + Effect.gen(function* () { + const { operationId } = started; + yield* watchAntigravityInstall(input.instanceId, operationId); + const settled = yield* antigravityInstallation.changes.pipe( + // Download progress changes the state several times a second; report each message once. + Stream.changesWith( + (a, b) => + a.operationId === b.operationId && a.phase === b.phase && a.message === b.message, + ), + Stream.tap((state) => + state.message !== null && !hasSettled(operationId)(state) + ? onProgress(state.message) + : Effect.void, + ), + Stream.filter(hasSettled(operationId)), + Stream.runHead, + ); + const final = Option.getOrElse(settled, () => started); + if (final.operationId !== operationId || final.phase !== "succeeded") { + return yield* new ProviderSetupError({ + instanceId: input.instanceId, + operation: "install", + detail: + (final.operationId === operationId ? final.message : null) ?? + "The installation did not finish.", + }); + } + return final; + }), + ({ state: started, owned }, exit) => + owned && started.operationId !== null && Exit.hasInterrupts(exit) + ? antigravityInstallation.cancel(started.operationId).pipe(Effect.ignore) + : Effect.void, + ); }); const cancel = Effect.fn("ProviderInstallation.cancel")(function* ( diff --git a/apps/server/src/provider/providerMaintenanceRunner.test.ts b/apps/server/src/provider/providerMaintenanceRunner.test.ts index b6cf8e5473c2a..2b2bdd45e9839 100644 --- a/apps/server/src/provider/providerMaintenanceRunner.test.ts +++ b/apps/server/src/provider/providerMaintenanceRunner.test.ts @@ -971,8 +971,9 @@ describe("providerMaintenanceRunner", () => { }, undefined, undefined, - (input, onProgress) => + (input, onProgress, version) => Effect.gen(function* () { + assert.strictEqual(version, "1.5.13"); installed.push(input.instanceId); yield* onProgress("Downloading."); if (installError !== null) { diff --git a/apps/server/src/provider/providerMaintenanceRunner.ts b/apps/server/src/provider/providerMaintenanceRunner.ts index 6e349d45e344b..855da07e31912 100644 --- a/apps/server/src/provider/providerMaintenanceRunner.ts +++ b/apps/server/src/provider/providerMaintenanceRunner.ts @@ -595,7 +595,18 @@ export const make = Effect.fn("ProviderMaintenanceRunner.make")(function* () { if (command === null) { // A managed install has no command. A failed one fails here with its own // message, which recordFailedUpdate reports. - yield* providerInstallation.run({ instanceId }, setRunningMessage); + if (candidateVersion === null) { + return yield* new ServerProviderUpdateError({ + provider, + reason: + "Could not determine the Antigravity release to install. Check for updates and try again.", + }); + } + yield* providerInstallation.run( + { instanceId }, + setRunningMessage, + candidateVersion, + ); return null; } yield* setRunningMessage(`Running ${describeCommand(command)}`); diff --git a/docs/internals/providers.md b/docs/internals/providers.md index 86ab15bb63322..91780cfca9b31 100644 --- a/docs/internals/providers.md +++ b/docs/internals/providers.md @@ -119,7 +119,8 @@ with a readable, current version. A runtime T3 Code installs itself, such as Antigravity's, has no command to run. Its capabilities set `managedInstall` instead, and the runner updates it through [`ProviderInstallation`](../../apps/server/src/provider/providerInstallation.ts), the same install -its setup section starts, so validation, activation and the model refresh are not repeated here. +its setup section starts. The runner passes the version it checked for compatibility, and the +installer refuses if the selected release changed before the install could start. ## Protocol traps diff --git a/docs/user/providers-antigravity.md b/docs/user/providers-antigravity.md index 187205c666a1d..97faa4c5c3841 100644 --- a/docs/user/providers-antigravity.md +++ b/docs/user/providers-antigravity.md @@ -60,8 +60,9 @@ Leave the field blank to use the managed runtime, or a compatible executable on In web or desktop provider settings, choose **Update Antigravity** when an update is available. **Update all** updates it along with your other providers; an executable you set a path to stays yours to update. T3 checks Google's CLI -release channel while provider update checks are enabled. Installing or -reinstalling also checks that channel. Updates keep your profile and existing +release channel while provider update checks are enabled. Use **Check for updates** +to look up the current release immediately. Installing or reinstalling also checks +that channel. Updates keep your profile and existing runtime available if the new release fails validation. T3 needs Antigravity 1.5 or newer and recommends 1.5.12 or newer. Sessions do not From e79249c50bf59506a7f50ff663f8dc4e02d45ffb Mon Sep 17 00:00:00 2001 From: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Date: Fri, 20 Nov 2026 10:40:54 +0100 Subject: [PATCH 7/9] test(providers): preserve the original Antigravity update fixtures Co-authored-by: GPT 6.2 Sol --- .../Drivers/AntigravityDriver.test.ts | 16 +++++++-- .../src/provider/providerInstallation.test.ts | 33 +++++++++++++------ .../providerMaintenanceRunner.test.ts | 3 +- 3 files changed, 38 insertions(+), 14 deletions(-) diff --git a/apps/server/src/provider/Drivers/AntigravityDriver.test.ts b/apps/server/src/provider/Drivers/AntigravityDriver.test.ts index 3242289251d4f..e098aa5420235 100644 --- a/apps/server/src/provider/Drivers/AntigravityDriver.test.ts +++ b/apps/server/src/provider/Drivers/AntigravityDriver.test.ts @@ -281,7 +281,12 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* ( ...(options.awaitServerReady ? { awaitServerReady: options.awaitServerReady } : {}), settings: { ...host.settings, - get: SubscriptionRef.get(serverSettings), + get: host.settings.get.pipe( + Effect.map((settings) => ({ + ...settings, + enableProviderUpdateChecks: options.updateChecks ?? true, + })), + ), changes: SubscriptionRef.changes(serverSettings), }, }), @@ -451,7 +456,13 @@ it.layer(layerTest)("AntigravityDriver", (it) => { it.effect("clears a published update when update checks are disabled", () => Effect.gen(function* () { - const h = yield* makeHarness({ awaitServerReady: Effect.never }); + let updatesEnabled = true; + const h = yield* makeHarness({ + awaitServerReady: Effect.never, + get updateChecks() { + return updatesEnabled; + }, + }); yield* SubscriptionRef.update(h.installState, (state) => ({ ...state, version: "1.5.13" })); expect((yield* h.instance.snapshot.refresh).versionAdvisory?.status).toBe("behind_latest"); const cleared = yield* h.instance.snapshot.streamChanges.pipe( @@ -459,6 +470,7 @@ it.layer(layerTest)("AntigravityDriver", (it) => { Stream.runHead, Effect.forkScoped({ startImmediately: true }), ); + updatesEnabled = false; yield* SubscriptionRef.update(h.serverSettings, (settings) => ({ ...settings, enableProviderUpdateChecks: false, diff --git a/apps/server/src/provider/providerInstallation.test.ts b/apps/server/src/provider/providerInstallation.test.ts index 52bd0de8e2770..a4650381883ac 100644 --- a/apps/server/src/provider/providerInstallation.test.ts +++ b/apps/server/src/provider/providerInstallation.test.ts @@ -39,13 +39,6 @@ const state: ProviderInstallState = { message: null, }; -const running = { - ...state, - operationId: "install-1", - phase: "downloading", - message: "Downloading.", -} satisfies ProviderInstallState; - function instance(kind = driver, id = instanceId): ProviderInstance { return { instanceId: id, @@ -89,8 +82,14 @@ const makeHarness = Effect.fn("providerInstallation.test.makeHarness")(function* yield* input.beforeInstallStart ?? Effect.void; const current = yield* SubscriptionRef.get(installationState); if (current.phase === "downloading") return { state: current, owned: false }; - yield* SubscriptionRef.set(installationState, running); - return { state: running, owned: true }; + const started = { + ...state, + operationId: "install-1", + phase: "downloading", + message: "Downloading.", + } satisfies ProviderInstallState; + yield* SubscriptionRef.set(installationState, started); + return { state: started, owned: true }; }); const dependencies = Layer.mergeAll( ServerSettings.layerTest(input.settings), @@ -134,7 +133,15 @@ const makeHarness = Effect.fn("providerInstallation.test.makeHarness")(function* Layer.mock(AntigravityInstallation.AntigravityInstallation)({ managedDirectory: "/unused-managed-runtime", checkForUpdate: Effect.void, - start: startOperation.pipe(Effect.map((operation) => operation.state)), + start: Effect.sync(() => { + calls.push("start"); + return { + ...state, + operationId: "install-1", + phase: "downloading" as const, + message: "Downloading.", + }; + }).pipe(Effect.tap((started) => SubscriptionRef.set(installationState, started))), startOperation: () => startOperation, cancel: () => Effect.sync(() => { @@ -295,6 +302,12 @@ describe("provider installation routing", () => { ); const watched = () => Object.assign(instance(), { refreshModels: () => Effect.void }); + const running = { + ...state, + operationId: "install-1", + phase: "downloading", + message: "Downloading.", + } satisfies ProviderInstallState; it.effect.each([ { phase: "succeeded", message: null, error: null }, diff --git a/apps/server/src/provider/providerMaintenanceRunner.test.ts b/apps/server/src/provider/providerMaintenanceRunner.test.ts index 2b2bdd45e9839..b6cf8e5473c2a 100644 --- a/apps/server/src/provider/providerMaintenanceRunner.test.ts +++ b/apps/server/src/provider/providerMaintenanceRunner.test.ts @@ -971,9 +971,8 @@ describe("providerMaintenanceRunner", () => { }, undefined, undefined, - (input, onProgress, version) => + (input, onProgress) => Effect.gen(function* () { - assert.strictEqual(version, "1.5.13"); installed.push(input.instanceId); yield* onProgress("Downloading."); if (installError !== null) { From d4fe600482c4cb52053325b82f85cc5826d0b400 Mon Sep 17 00:00:00 2001 From: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Date: Fri, 20 Nov 2026 11:04:01 +0100 Subject: [PATCH 8/9] fix(providers): keep Antigravity release offers current Ignore superseded channel responses, publish the installable fallback for withdrawn releases, and refresh the release once during explicit checks and updates. Co-authored-by: GPT 6.2 Sol --- .../provider/AntigravityInstallation.test.ts | 73 +++++++++++++++++++ .../src/provider/AntigravityInstallation.ts | 67 ++++++++++------- .../src/provider/AntigravityProvider.ts | 7 +- .../Drivers/AntigravityDriver.test.ts | 19 ++++- .../src/provider/Drivers/AntigravityDriver.ts | 9 ++- .../src/provider/ProviderRegistry.test.ts | 33 +++++++-- apps/server/src/provider/ProviderRegistry.ts | 22 ++++-- .../providerMaintenanceRunner.test.ts | 68 +++++++++++++++++ .../src/provider/providerMaintenanceRunner.ts | 18 +++-- docs/internals/providers.md | 2 + .../provider-core/src/server/maintenance.ts | 6 +- 11 files changed, 266 insertions(+), 58 deletions(-) diff --git a/apps/server/src/provider/AntigravityInstallation.test.ts b/apps/server/src/provider/AntigravityInstallation.test.ts index ff395ba17027f..9b890d8b18418 100644 --- a/apps/server/src/provider/AntigravityInstallation.test.ts +++ b/apps/server/src/provider/AntigravityInstallation.test.ts @@ -1118,6 +1118,79 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("Antigravity inst }), ); + it.effect("keeps the explicit offer when an older background lookup finishes last", () => + Effect.gen(function* () { + const backgroundStarted = yield* Deferred.make(); + const finishBackground = yield* Deferred.make(); + let lookups = 0; + let channelVersion = "1.5.13"; + const { installation } = yield* makeHarness({ + native: true, + platform: "win32", + archive: Buffer.from(serverContents), + beforeManifest: Effect.suspend(() => + ++lookups === 1 + ? Deferred.succeed(backgroundStarted, undefined).pipe( + Effect.andThen(Deferred.await(finishBackground)), + ) + : Effect.void, + ), + nativeManifest: (manifest) => ({ + ...manifest, + version: channelVersion, + url: manifest.url.replace(manifest.version, channelVersion), + }), + }); + const background = yield* installation.checkForUpdate.pipe(Effect.forkScoped); + yield* Deferred.await(backgroundStarted); + yield* installation.refreshUpdate; + expect((yield* installation.state).version).toBe("1.5.13"); + + channelVersion = "1.5.12"; + yield* Deferred.succeed(finishBackground, undefined); + yield* Fiber.join(background); + expect((yield* installation.state).version).toBe("1.5.13"); + }), + ); + + it.effect("replaces a withdrawn offer with the eligible installed version", () => + Effect.gen(function* () { + let channelVersion = "1.5.13"; + const { installation } = yield* makeHarness({ + native: true, + platform: "win32", + previous: true, + archive: Buffer.from(serverContents), + nativeManifest: (manifest) => ({ + ...manifest, + version: channelVersion, + url: manifest.url.replace(manifest.version, channelVersion), + }), + manifest: Effect.succeed({ + ...ModelManifest.BUNDLED_MODEL_MANIFEST, + compatibility: [ + { + driver: "antigravity", + t3CodeRange: ">=0.0.42", + ranges: [{ range: "1.5.14", status: "broken" }], + }, + ], + }), + }); + yield* installation.checkForUpdate; + expect((yield* installation.state).version).toBe("1.5.13"); + + channelVersion = "1.5.14"; + yield* installation.refreshUpdate; + expect((yield* installation.state).version).toBe(previousVersion); + yield* installation.startOperation(previousVersion); + expect(yield* terminalState(installation)).toMatchObject({ + phase: "succeeded", + installedVersion: previousVersion, + }); + }), + ); + it.effect("refreshes within the background throttle and only starts the checked release", () => Effect.gen(function* () { let channelVersion = "1.5.12"; diff --git a/apps/server/src/provider/AntigravityInstallation.ts b/apps/server/src/provider/AntigravityInstallation.ts index 8690818d6f5ae..c7ef50023d802 100644 --- a/apps/server/src/provider/AntigravityInstallation.ts +++ b/apps/server/src/provider/AntigravityInstallation.ts @@ -126,7 +126,7 @@ interface AntigravityInstallationService { readonly state: Effect.Effect; readonly changes: Stream.Stream; readonly checkForUpdate: Effect.Effect; - readonly refreshUpdate: Effect.Effect; + readonly refreshUpdate: Effect.Effect; readonly remove: ( protectedBinaryPaths?: ReadonlyArray, ) => Effect.Effect; @@ -1227,16 +1227,27 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma ), ); + const eligibleAsset = Effect.fn("AntigravityInstallation.eligibleAsset")(function* ( + asset: AntigravityCliReleaseAsset | null, + ) { + return asset !== null && !(yield* isWithdrawn(asset.version)) ? asset : null; + }); + const preferInstalled = (version: string, asset: AntigravityCliReleaseAsset | null) => + asset === null || compareSemverVersions(version, asset.version) > 0; + + const updateChecksEnabled = options.updateChecksEnabled ?? Effect.succeed(true); let lastUpdateCheck: number | undefined; + let latestLookup = 0; const refreshRelease = Effect.fn("AntigravityInstallation.refreshRelease")(function* ( explicit = false, ) { if (options.releaseAsset !== undefined || !supported) return; - if (!explicit && !(yield* options.updateChecksEnabled ?? Effect.succeed(true))) return; + if (!explicit && !(yield* updateChecksEnabled)) return; const now = yield* Clock.currentTimeMillis; if (!explicit && lastUpdateCheck !== undefined && now - lastUpdateCheck < UPDATE_CHECK_INTERVAL) return; lastUpdateCheck = now; + const lookup = ++latestLookup; const musl = platform === "linux" && (yield* fs.exists( @@ -1250,26 +1261,25 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma Effect.timeout("10 seconds"), Effect.orElseSucceed(() => null), ); - if (latest === null) return; - if (yield* isWithdrawn(latest.version)) { - releaseAsset = null; - return; - } - releaseAsset = latest; - yield* SubscriptionRef.updateEffect(state, (value) => - isRunning(value) - ? Effect.succeed(value) - : Effect.gen(function* () { - const keepInstalled = - value.installedVersion !== null && - compareSemverVersions(value.installedVersion, latest.version) > 0 && - !(yield* isWithdrawn(value.installedVersion)); - return { - ...value, - version: keepInstalled ? value.installedVersion : latest.version, - totalBytes: null, - }; - }), + if (latest === null || lookup !== latestLookup) return; + yield* gate.withPermit( + SubscriptionRef.updateEffect(state, (value) => + Effect.gen(function* () { + const asset = yield* eligibleAsset(latest); + const keepInstalled = + value.installedVersion !== null && + preferInstalled(value.installedVersion, asset) && + !(yield* isWithdrawn(value.installedVersion)); + if (lookup !== latestLookup) return value; + releaseAsset = asset; + if (isRunning(value)) return value; + return { + ...value, + version: keepInstalled ? value.installedVersion : (asset?.version ?? null), + totalBytes: null, + }; + }), + ), ); }); @@ -1299,13 +1309,12 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma `Google does not publish an Antigravity runtime for ${platform}-${arch}. Use a supported remote environment or a custom executable.`, ); } - const offered = releaseAsset; - const asset = offered !== null && !(yield* isWithdrawn(offered.version)) ? offered : null; + const asset = yield* eligibleAsset(releaseAsset); const installed = yield* resolve().pipe(Effect.option); const reuse = Option.isSome(installed) && installed.value.source === "managed" && - (asset === null || compareSemverVersions(installed.value.version!, asset.version) > 0) + preferInstalled(installed.value.version!, asset) ? installed.value : undefined; if (asset === null && reuse === undefined) @@ -1544,7 +1553,13 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma state: SubscriptionRef.get(state), changes: SubscriptionRef.changes(state), checkForUpdate: refreshRelease().pipe(Effect.ignore), - refreshUpdate: refreshRelease(true).pipe(Effect.ignore), + refreshUpdate: updateChecksEnabled.pipe( + Effect.flatMap((enabled) => + enabled ? refreshRelease(true).pipe(Effect.ignore) : Effect.void, + ), + Effect.andThen(SubscriptionRef.get(state)), + Effect.map((current) => current.version), + ), remove, }); }); diff --git a/apps/server/src/provider/AntigravityProvider.ts b/apps/server/src/provider/AntigravityProvider.ts index cf786bcbb7d87..a9737828c7a94 100644 --- a/apps/server/src/provider/AntigravityProvider.ts +++ b/apps/server/src/provider/AntigravityProvider.ts @@ -376,6 +376,8 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func provider: ProviderDriverKind.make("antigravity"), packageName: null, }); + const resolveMaintenance = + options.resolveMaintenance ?? (() => Effect.succeed(manualMaintenance)); const snapshotSettings = yield* makeProviderSnapshotSettingsSource(settings); const metadataChanges = SubscriptionRef.changes(metadata); const snapshotChanges = options.releaseChanges @@ -385,7 +387,8 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func ) : metadataChanges; const managed = yield* makeManagedServerProvider({ - resolveMaintenance: options.resolveMaintenance ?? (() => Effect.succeed(manualMaintenance)), + // The health probe already resolves the executable and records its ownership. + resolveMaintenance: () => resolveMaintenance(), getSettings: snapshotSettings.getSettings, streamSettings: snapshotSettings.streamSettings, haveSettingsChanged: haveProviderSnapshotSettingsChanged, @@ -562,7 +565,7 @@ export const makeAntigravityProvider = Effect.fn("makeAntigravityProvider")(func }); return { - snapshot: { ...managed, getSnapshot }, + snapshot: { ...managed, getSnapshot, resolveMaintenance }, onSessionStarted, onConfigOptionsUpdated, onAvailableCommands, diff --git a/apps/server/src/provider/Drivers/AntigravityDriver.test.ts b/apps/server/src/provider/Drivers/AntigravityDriver.test.ts index e098aa5420235..ea71743461515 100644 --- a/apps/server/src/provider/Drivers/AntigravityDriver.test.ts +++ b/apps/server/src/provider/Drivers/AntigravityDriver.test.ts @@ -189,7 +189,10 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* ( managedDirectory: root, state: SubscriptionRef.get(installState), changes: SubscriptionRef.changes(installState), - refreshUpdate: options.refreshUpdate?.(installState) ?? Effect.void, + refreshUpdate: (options.refreshUpdate?.(installState) ?? Effect.void).pipe( + Effect.andThen(SubscriptionRef.get(installState)), + Effect.map((state) => state.version), + ), checkForUpdate: Deferred.succeed(checkedForUpdate, undefined).pipe(Effect.asVoid), compatibility: (version) => Effect.succeed( @@ -427,7 +430,7 @@ it.layer(layerTest)("AntigravityDriver", (it) => { }), ); - it.effect("awaits a release lookup on an explicit refresh", () => + it.effect("awaits the release only when explicitly checking for updates", () => Effect.gen(function* () { const lookupStarted = yield* Deferred.make(); const lookupFinished = yield* Deferred.make(); @@ -444,10 +447,18 @@ it.layer(layerTest)("AntigravityDriver", (it) => { ), ), }); - const refreshing = yield* h.instance.snapshot.refresh.pipe(Effect.forkScoped); + const snapshot = yield* h.instance.snapshot.refresh; + expect(yield* Deferred.isDone(lookupStarted)).toBe(false); + expect(snapshot.versionAdvisory?.latestVersion).toBeNull(); + const maintenance = yield* h.instance.snapshot.resolveMaintenance({ fresh: true }); + expect(yield* Deferred.isDone(lookupStarted)).toBe(false); + const check = maintenance.managedInstall?.refreshLatestVersion; + if (check === undefined) throw new Error("Missing managed update check"); + const refreshing = yield* check.pipe(Effect.forkScoped); yield* Deferred.await(lookupStarted); yield* Deferred.succeed(lookupFinished, undefined); - expect((yield* Fiber.join(refreshing)).versionAdvisory).toMatchObject({ + expect(yield* Fiber.join(refreshing)).toBe("1.5.13"); + expect((yield* h.instance.snapshot.refresh).versionAdvisory).toMatchObject({ status: "behind_latest", latestVersion: "1.5.13", }); diff --git a/apps/server/src/provider/Drivers/AntigravityDriver.ts b/apps/server/src/provider/Drivers/AntigravityDriver.ts index 55c8a0a1d5f34..e48c400320166 100644 --- a/apps/server/src/provider/Drivers/AntigravityDriver.ts +++ b/apps/server/src/provider/Drivers/AntigravityDriver.ts @@ -226,9 +226,7 @@ export const AntigravityDriver: ProviderDriver< const executable = yield* installation .resolve(settings.binaryPath, processEnvironment) .pipe(Effect.orElseSucceed(() => null)); - const managed = executable?.source === "managed"; - yield* Ref.set(usesManagedRuntime, managed); - if (managed && (yield* updateChecksEnabled)) yield* installation.refreshUpdate; + yield* Ref.set(usesManagedRuntime, executable?.source === "managed"); } if (!(yield* Ref.get(usesManagedRuntime))) return manualMaintenance; const install = yield* installation.state; @@ -236,7 +234,10 @@ export const AntigravityDriver: ProviderDriver< provider: DRIVER, packageName: null, update: null, - managedInstall: { lockKey: "antigravity-managed" }, + managedInstall: { + lockKey: "antigravity-managed", + refreshLatestVersion: installation.refreshUpdate, + }, latestVersion: install.version, // The installer has already chosen between the channel release and the installed version. compareVersions: (current, latest) => (current === latest ? 0 : -1), diff --git a/apps/server/src/provider/ProviderRegistry.test.ts b/apps/server/src/provider/ProviderRegistry.test.ts index e4ec16b77dde0..a1f27cef592a3 100644 --- a/apps/server/src/provider/ProviderRegistry.test.ts +++ b/apps/server/src/provider/ProviderRegistry.test.ts @@ -2273,12 +2273,16 @@ it.layer( it.effect("invalidates model caches only for an explicit model refresh", () => Effect.gen(function* () { const forceRefreshCalls = yield* Ref.make(0); + const releaseChecks = yield* Ref.make(0); + const refreshLatestVersion = Ref.update(releaseChecks, (count) => count + 1).pipe( + Effect.as("1.5.13"), + ); const manifest = yield* Ref.make(ModelManifest.BUNDLED_MODEL_MANIFEST); const updateEvents = yield* Ref.make>([]); const hookFails = yield* Ref.make(false); - const makeInstance = (name: string) => + const makeInstance = (name: string, kind = "codex") => Effect.gen(function* () { - const driver = ProviderDriverKind.make("codex"); + const driver = ProviderDriverKind.make(kind); const instanceId = ProviderInstanceId.make(name); const provider = { instanceId, @@ -2301,19 +2305,27 @@ it.layer( driverKind: driver, continuationIdentity: { driverKind: driver, - continuationKey: `codex:instance:${name}`, + continuationKey: `${kind}:instance:${name}`, }, displayName: undefined, enabled: true, snapshot: { resolveMaintenance: (options) => Ref.update(maintenanceReads, (reads) => [...reads, options?.fresh === true]).pipe( - Effect.as( - makeManualOnlyProviderMaintenanceCapabilities({ + Effect.as({ + ...makeManualOnlyProviderMaintenanceCapabilities({ provider: driver, - packageName: `${name}-package`, + packageName: kind === "antigravity" ? null : `${name}-package`, }), - ), + ...(kind === "antigravity" && options?.fresh + ? { + managedInstall: { + lockKey: "antigravity-managed", + refreshLatestVersion, + }, + } + : {}), + }), ), getSnapshot: Effect.succeed(provider), refresh: Ref.update(probes, (count) => count + 1).pipe(Effect.as(provider)), @@ -2347,7 +2359,9 @@ it.layer( }); const first = yield* makeInstance("codex_first"); const second = yield* makeInstance("codex_second"); - const instances = [first.instance, second.instance]; + const agiFirst = yield* makeInstance("antigravity_first", "antigravity"); + const agiSecond = yield* makeInstance("antigravity_second", "antigravity"); + const instances = [first.instance, second.instance, agiFirst.instance, agiSecond.instance]; const layerInstanceRegistry = Layer.succeed( ProviderInstanceRegistry.ProviderInstanceRegistry, { @@ -2386,6 +2400,7 @@ it.layer( yield* registry.refreshInstance(first.instance.instanceId); yield* registry.refresh(); assert.strictEqual(yield* Ref.get(forceRefreshCalls), 0); + assert.strictEqual(yield* Ref.get(releaseChecks), 0); assert.strictEqual(yield* Ref.get(first.invalidations), 0); assert.strictEqual(yield* readCachedVersion("codex_first-package"), "1.0.0"); yield* first.takeMaintenanceReads; @@ -2394,12 +2409,14 @@ it.layer( // The instance refresh that follows resolves installer metadata fresh itself. assert.deepStrictEqual(yield* first.takeMaintenanceReads, [false]); assert.strictEqual(yield* Ref.get(forceRefreshCalls), 1); + assert.strictEqual(yield* Ref.get(releaseChecks), 0); assert.strictEqual(yield* Ref.get(first.invalidations), 1); assert.strictEqual(yield* Ref.get(second.invalidations), 0); assert.strictEqual(yield* readCachedVersion("codex_first-package"), "2.0.0"); assert.strictEqual(yield* readCachedVersion("codex_second-package"), "1.0.0"); yield* registry.invalidateModelCaches({}); + assert.strictEqual(yield* Ref.get(releaseChecks), 1); assert.strictEqual(yield* Ref.get(first.invalidations), 2); assert.strictEqual(yield* Ref.get(second.invalidations), 1); assert.strictEqual(yield* readCachedVersion("codex_second-package"), "2.0.0"); diff --git a/apps/server/src/provider/ProviderRegistry.ts b/apps/server/src/provider/ProviderRegistry.ts index 43f57bb99a777..edb22c1576b55 100644 --- a/apps/server/src/provider/ProviderRegistry.ts +++ b/apps/server/src/provider/ProviderRegistry.ts @@ -1289,27 +1289,39 @@ export const layer = Layer.effect( ) { yield* manifestService.forceRefresh; const instances = yield* instanceRegistry.listInstances; - yield* Effect.forEach( + const maintenance = yield* Effect.forEach( instances.filter( (instance) => input.instanceId === undefined || input.instanceId === instance.instanceId, ), (instance) => Effect.gen(function* () { yield* instance.invalidateCaches ?? Effect.void; - // Instance and full refreshes resolve installer metadata fresh - // themselves; a cached workspace refresh needs it resolved here. + // Resolve Antigravity ownership before checking its release channel. Other + // drivers resolve it in the probe that follows, except on a cached workspace refresh. const maintenance = yield* instance.snapshot.resolveMaintenance({ fresh: - input.instanceId !== undefined && input.cwd !== undefined && input.fresh !== true, + instance.driverKind === "antigravity" || + (input.instanceId !== undefined && input.cwd !== undefined && input.fresh !== true), }); yield* Effect.forEach( latestProviderVersionCacheKeys(maintenance), latestVersions.invalidate, { discard: true }, ); + return maintenance; }), - { concurrency: "unbounded", discard: true }, + { concurrency: "unbounded" }, ); + const releaseChecks = new Map>(); + for (const { managedInstall } of maintenance) { + if (managedInstall?.refreshLatestVersion) { + releaseChecks.set(managedInstall.lockKey, managedInstall.refreshLatestVersion); + } + } + yield* Effect.forEach(releaseChecks.values(), (check) => check, { + concurrency: "unbounded", + discard: true, + }); }); const refreshModelCatalog = Effect.fn("ProviderRegistry.refreshModelCatalog")(function* () { diff --git a/apps/server/src/provider/providerMaintenanceRunner.test.ts b/apps/server/src/provider/providerMaintenanceRunner.test.ts index b6cf8e5473c2a..c73682888f513 100644 --- a/apps/server/src/provider/providerMaintenanceRunner.test.ts +++ b/apps/server/src/provider/providerMaintenanceRunner.test.ts @@ -1027,6 +1027,74 @@ describe("providerMaintenanceRunner", () => { }, ); + it.effect("installs the fresh managed offer even if the previous offer was current", () => + Effect.gen(function* () { + const driver = ProviderDriverKind.make("antigravity"); + const instanceId = ProviderInstanceId.make("antigravity"); + const { registry, providersRef, updateStatesRef } = yield* makeRegistry( + { ...baseProvider, instanceId, driver, version: "1.5.12" }, + { installedVersionAfterUpdate: "1.5.13" }, + ); + const offers = yield* Ref.make(0); + const startedVersion = yield* Ref.make(undefined); + const updater = yield* makeTestRunner( + { + ...registry, + refreshInstance: () => + Ref.updateAndGet(providersRef, (providers) => + providers.map((provider) => ({ ...provider, checkedAt: "2026-04-11T00:00:00.000Z" })), + ), + getProviderMaintenanceCapabilitiesForInstance: () => + Ref.get(offers).pipe( + Effect.map((count) => ({ + provider: driver, + packageName: null, + update: null, + managedInstall: { + lockKey: "antigravity-managed", + refreshLatestVersion: Ref.update(offers, (checks) => checks + 1).pipe( + Effect.as("1.5.13"), + ), + }, + latestVersion: count === 0 ? "1.5.12" : "1.5.13", + })), + ), + }, + undefined, + undefined, + (_input, _onProgress, expectedVersion) => + Ref.set(startedVersion, expectedVersion).pipe( + Effect.as({ + driver, + operationId: "install-1", + phase: "succeeded", + downloadedBytes: 0, + totalBytes: null, + version: "1.5.13", + installedVersion: "1.5.13", + canRemove: true, + message: null, + } as const), + ), + ); + + yield* updater.updateProvider({ provider: driver, instanceId }); + assert.strictEqual(yield* Ref.get(startedVersion), "1.5.13"); + assert.strictEqual(yield* Ref.get(offers), 1); + assert.strictEqual((yield* Ref.get(updateStatesRef)).at(-1)?.message, "Provider updated."); + }).pipe( + Effect.provide( + Layer.mergeAll( + layerNonWindowsPlatform, + layerLatestVersionHttpClient("1.5.13"), + layerMockSpawner(() => { + throw new Error("A managed update must not run a command."); + }), + ), + ), + ), + ); + it.effect("an interrupted update ends failed instead of running forever", () => { const started = Deferred.makeUnsafe(); return Effect.gen(function* () { diff --git a/apps/server/src/provider/providerMaintenanceRunner.ts b/apps/server/src/provider/providerMaintenanceRunner.ts index 855da07e31912..6d0759e02b924 100644 --- a/apps/server/src/provider/providerMaintenanceRunner.ts +++ b/apps/server/src/provider/providerMaintenanceRunner.ts @@ -506,20 +506,20 @@ export const make = Effect.fn("ProviderMaintenanceRunner.make")(function* () { ); } - const manifest = yield* manifestService.current; // Check compatibility against what an unpinned command would install now. - const candidateVersion = - targetVersion ?? - (yield* invalidateLatestProviderVersion(fresh).pipe( + const lookupCandidate = + fresh.managedInstall?.refreshLatestVersion ?? + invalidateLatestProviderVersion(fresh).pipe( Effect.andThen(resolveLatestProviderVersion(fresh)), Effect.provideService(HttpClient.HttpClient, httpClient), Effect.provideService( ProviderLatestVersions.ProviderLatestVersions, latestVersions, ), - )); + ); + const candidateVersion = targetVersion ?? (yield* lookupCandidate); const advisory = ModelManifest.providerCompatibility( - manifest, + yield* manifestService.current, provider, candidateVersion, ); @@ -554,7 +554,9 @@ export const make = Effect.fn("ProviderMaintenanceRunner.make")(function* () { const precheck = yield* verifyFromRefresh( providerRegistry.refreshInstance(instanceId), provider, - fresh, + fresh.managedInstall === undefined + ? fresh + : { ...fresh, latestVersion: candidateVersion }, instanceId, "pre-update", ); @@ -599,7 +601,7 @@ export const make = Effect.fn("ProviderMaintenanceRunner.make")(function* () { return yield* new ServerProviderUpdateError({ provider, reason: - "Could not determine the Antigravity release to install. Check for updates and try again.", + "Could not determine which provider version to install. Check for updates and try again.", }); } yield* providerInstallation.run( diff --git a/docs/internals/providers.md b/docs/internals/providers.md index 91780cfca9b31..5a5744078aefb 100644 --- a/docs/internals/providers.md +++ b/docs/internals/providers.md @@ -121,6 +121,8 @@ set `managedInstall` instead, and the runner updates it through [`ProviderInstallation`](../../apps/server/src/provider/providerInstallation.ts), the same install its setup section starts. The runner passes the version it checked for compatibility, and the installer refuses if the selected release changed before the install could start. +Explicit update checks and update runs refresh the Antigravity release offer once per installation. +Routine health checks use the installer's hourly throttle. ## Protocol traps diff --git a/packages/provider-core/src/server/maintenance.ts b/packages/provider-core/src/server/maintenance.ts index 67c58063ed8c1..fd0a6e1f8fd7e 100644 --- a/packages/provider-core/src/server/maintenance.ts +++ b/packages/provider-core/src/server/maintenance.ts @@ -9,7 +9,11 @@ export interface ProviderMaintenanceCapabilities { * Set, with `update` null, when T3 Code installs the provider's runtime itself: updating is a * reinstall by the server, with no command to run or show. */ - readonly managedInstall?: { readonly lockKey: string }; + readonly managedInstall?: { + readonly lockKey: string; + /** Refresh the offer for an explicit check or update. Routine probes use latestVersion. */ + readonly refreshLatestVersion?: Effect.Effect; + }; /** undefined defers to npm; null means the installer could not determine the latest version. */ readonly latestVersion?: string | null; /** From 44ee756a7bc6d40db73d13fcda7b5f33af7502d8 Mon Sep 17 00:00:00 2001 From: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Date: Fri, 20 Nov 2026 11:05:01 +0100 Subject: [PATCH 9/9] chore: credit the models that worked on this change Co-authored-by: Grok 4.7