diff --git a/apps/server/src/provider/AntigravityInstallation.test.ts b/apps/server/src/provider/AntigravityInstallation.test.ts index 5dcd840991f83..9b890d8b18418 100644 --- a/apps/server/src/provider/AntigravityInstallation.test.ts +++ b/apps/server/src/provider/AntigravityInstallation.test.ts @@ -1084,6 +1084,151 @@ 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("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"; + 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..c7ef50023d802 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; @@ -1219,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( @@ -1242,127 +1261,139 @@ 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, + }; + }), + ), ); }); - 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 asset = yield* eligibleAsset(releaseAsset); + const installed = yield* resolve().pipe(Effect.option); + const reuse = + Option.isSome(installed) && + installed.value.source === "managed" && + preferInstalled(installed.value.version!, asset) + ? 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 +1547,19 @@ 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: 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 b3b68d46e8ba8..a9737828c7a94 100644 --- a/apps/server/src/provider/AntigravityProvider.ts +++ b/apps/server/src/provider/AntigravityProvider.ts @@ -31,10 +31,12 @@ import { DeferringFailedCheck, makeManagedServerProvider, } from "@t3tools/provider-core/server/managedProvider"; +import { makeManualOnlyProviderMaintenanceCapabilities } from "@t3tools/provider-core/server/maintenanceResolver"; import { - makeManualOnlyProviderMaintenanceCapabilities, - type ProviderMaintenanceCapabilities, -} from "@t3tools/provider-core/server/maintenanceResolver"; + haveProviderSnapshotSettingsChanged, + makeProviderSnapshotSettingsSource, +} from "@t3tools/provider-core/server/snapshotSettings"; +import type { ManagedServerProvider } from "@t3tools/provider-core/server/snapshot"; import { buildServerProvider, isCommandMissingCause, @@ -170,7 +172,8 @@ interface AntigravityProviderOptions { readonly supportsTextGeneration: Effect.Effect; readonly probeUsage?: Effect.Effect; readonly clearUsage?: Effect.Effect; - readonly maintenanceCapabilities?: ProviderMaintenanceCapabilities; + readonly resolveMaintenance?: ManagedServerProvider["resolveMaintenance"]; + readonly releaseChanges?: Stream.Stream; readonly auth?: { readonly type: string; readonly label: string }; } @@ -369,21 +372,31 @@ 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 resolveMaintenance = + options.resolveMaintenance ?? (() => Effect.succeed(manualMaintenance)); + 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: () => Effect.succeed(maintenanceCapabilities), - getSettings: Effect.succeed(settings), - streamSettings: Stream.empty, - haveSettingsChanged: () => false, + // The health probe already resolves the executable and records its ownership. + resolveMaintenance: () => resolveMaintenance(), + 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)), ), @@ -552,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 3c0135f419c66..ea71743461515 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"; @@ -28,10 +33,12 @@ 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"; 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 +63,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 +85,20 @@ 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; + 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; const path = yield* Path.Path; const config = yield* ServerConfig.ServerConfig; @@ -156,6 +187,13 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* ( const layerInstallation = Layer.mock(AntigravityInstallation.AntigravityInstallation)({ managedDirectory: root, + state: SubscriptionRef.get(installState), + changes: SubscriptionRef.changes(installState), + 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( resolveProviderCompatibility( @@ -241,6 +279,20 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* ( }).pipe( Effect.provide(layerInstallation), 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, + })), + ), + changes: SubscriptionRef.changes(serverSettings), + }, + }), ); const refresh = instance.refreshModels; if (!refresh) return yield* Effect.die("Antigravity does not expose model refresh."); @@ -272,6 +324,9 @@ const makeHarness = Effect.fn("makeAntigravityDriverHarness")(function* ( second, signedOut, controls, + installState, + serverSettings, + checkedForUpdate, acquisitions, releases, launches, @@ -303,6 +358,7 @@ const layerDeps = ServerConfig.layerTest(process.cwd(), { ), ), Layer.provideMerge(ModelManifest.layerTest), + Layer.provideMerge(ProviderLatestVersions.layer), Layer.provideMerge(IdAllocator.layer), Layer.provideMerge(McpProviderSessions.layer), ); @@ -312,6 +368,130 @@ 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("awaits the release only when explicitly checking for updates", () => + 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 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)).toBe("1.5.13"); + expect((yield* h.instance.snapshot.refresh).versionAdvisory).toMatchObject({ + status: "behind_latest", + latestVersion: "1.5.13", + }); + }), + ); + + it.effect("clears a published update when update checks are disabled", () => + Effect.gen(function* () { + 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( + Stream.filter((snapshot) => snapshot.versionAdvisory?.status === "unknown"), + Stream.runHead, + Effect.forkScoped({ startImmediately: true }), + ); + updatesEnabled = false; + 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", () => @@ -694,6 +874,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/Drivers/AntigravityDriver.ts b/apps/server/src/provider/Drivers/AntigravityDriver.ts index 3d426785813c3..e48c400320166 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, @@ -19,6 +20,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 +57,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 { + enrichProviderSnapshotWithVersionAdvisory, + makeManualOnlyProviderMaintenanceCapabilities, + type ProviderMaintenanceCapabilities, +} from "@t3tools/provider-core/server/maintenanceResolver"; import { removeAntigravitySessionFiles, retireAntigravityRuntimeTempDirs, @@ -103,6 +110,7 @@ function refreshFailureDetail(cause: unknown) { export type AntigravityDriverEnv = | AntigravityInstallation.AntigravityInstallation | ProviderHost.ProviderHost + | ProviderLatestVersions.ProviderLatestVersions | ChildProcessSpawner.ChildProcessSpawner | Digest.Digest | SecureRandom.SecureRandom @@ -199,10 +207,59 @@ export const AntigravityDriver: ProviderDriver< accentColor, continuationGroupKey: continuationIdentity.continuationKey, }); - const classifyModels = (draft: ServerProviderDraft) => - currentCatalog.pipe( - Effect.map((catalog) => stampIdentity(ModelCatalog.applyModelCatalog(draft, catalog))), + const manualMaintenance = makeManualOnlyProviderMaintenanceCapabilities({ + provider: DRIVER, + packageName: null, + }); + // Keep ownership from the last executable resolution so snapshot enrichment avoids disk I/O. + const usesManagedRuntime = yield* Ref.make(false); + const latestVersions = yield* ProviderLatestVersions.ProviderLatestVersions; + const updateChecksEnabled = host.settings.get.pipe( + Effect.map((current) => current.enableProviderUpdateChecks), + Effect.orElseSucceed(() => false), + ); + 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)); + yield* Ref.set(usesManagedRuntime, executable?.source === "managed"); + } + if (!(yield* Ref.get(usesManagedRuntime))) return manualMaintenance; + const install = yield* installation.state; + return { + provider: DRIVER, + packageName: null, + update: null, + 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), + }; + }, + ); + 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, @@ -530,6 +587,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 +598,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 +629,12 @@ export const AntigravityDriver: ProviderDriver< const provider = yield* makeAntigravityProvider(settings, { 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, 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/providerInstallation.test.ts b/apps/server/src/provider/providerInstallation.test.ts index 76cb5904193da..a4650381883ac 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"; @@ -59,6 +60,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]; @@ -75,6 +77,20 @@ 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 }; + 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), Layer.mock(ProviderInstanceRegistry.ProviderInstanceRegistry)({ @@ -119,14 +135,20 @@ 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))), + startOperation: () => startOperation, 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 +301,85 @@ 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("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 471c97b820547..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"; @@ -31,12 +32,28 @@ 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 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, ) => Effect.Effect; @@ -153,39 +170,90 @@ 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( - (state) => - state.operationId !== started.operationId || - state.phase === "succeeded" || - state.phase === "failed" || - state.phase === "cancelled", - ), + 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; }); + const run = Effect.fn("ProviderInstallation.run")(function* ( + input: ProviderSetupInput, + onProgress: (message: string) => Effect.Effect, + expectedVersion?: string, + ) { + const { driver } = yield* requireInstance(input.instanceId, "install", true); + if (driver !== ANTIGRAVITY) { + return yield* new ProviderSetupError({ + instanceId: input.instanceId, + operation: "install", + detail: "Managed updates are not available for this provider instance.", + }); + } + 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* ( input: ProviderInstallCancelInput, ) { @@ -249,7 +317,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.test.ts b/apps/server/src/provider/providerMaintenanceRunner.test.ts index 985347a66e96b..c73682888f513 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,192 @@ 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("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 014aa67c26df0..6d0759e02b924 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", @@ -502,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, ); @@ -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", @@ -550,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", ); @@ -587,12 +593,30 @@ 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. + if (candidateVersion === null) { + return yield* new ServerProviderUpdateError({ + provider, + reason: + "Could not determine which provider version to install. Check for updates and try again.", + }); + } + yield* providerInstallation.run( + { instanceId }, + setRunningMessage, + candidateVersion, + ); + 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 +683,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.test.ts b/apps/web/src/components/ProviderUpdateLaunchNotification.logic.test.ts index 764a76ba74f12..9118bfbf9ad2a 100644 --- a/apps/web/src/components/ProviderUpdateLaunchNotification.logic.test.ts +++ b/apps/web/src/components/ProviderUpdateLaunchNotification.logic.test.ts @@ -130,6 +130,28 @@ 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(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", () => { const candidate = updateCandidate({ driver: driver("codex"), diff --git a/apps/web/src/components/ProviderUpdateLaunchNotification.logic.ts b/apps/web/src/components/ProviderUpdateLaunchNotification.logic.ts index 9c94c4854d0c3..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 ); } @@ -171,10 +169,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 +178,15 @@ export function hasOneClickUpdateProviderCandidate( return false; } - const updateCommands = new Set(); + // 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)) { 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..5a5744078aefb 100644 --- a/docs/internals/providers.md +++ b/docs/internals/providers.md @@ -116,6 +116,14 @@ 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. 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 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..97faa4c5c3841 100644 --- a/docs/user/providers-antigravity.md +++ b/docs/user/providers-antigravity.md @@ -58,9 +58,12 @@ 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 -are enabled. Installing or reinstalling also checks that channel. Updates keep -your profile and existing runtime available if the new release fails validation. +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. 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 start on an older runtime: update the managed runtime here, or update the executable diff --git a/packages/provider-core/src/server/maintenance.ts b/packages/provider-core/src/server/maintenance.ts index 9d2a63c5bfbe3..fd0a6e1f8fd7e 100644 --- a/packages/provider-core/src/server/maintenance.ts +++ b/packages/provider-core/src/server/maintenance.ts @@ -5,6 +5,15 @@ 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; + /** 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; /** 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,