fix(server): use the correct installer for provider updates #6436
Closedettoc00(GitHub profile, opens in a new tab)wants to merge 25 commits into
main fromrefs/pull/6436/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
- apps/server/src/provider/providerMaintenance.ts line 596OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -403,4 +593,4 @@403593 }): ServerProviderVersionAdvisory {404594 const capabilities =405595 input.maintenanceCapabilities ?? makeManualProviderMaintenanceCapabilities(input.driver);406- const latestVersion = input.latestVersion ?? null;596+ const latestVersion = input.latestVersion ?? capabilities.latestVersion ?? null;apps/server/src/provider/providerMaintenanceRunner.ts line 384OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -342,0 +364,21 @@364+ const freshUpdate = freshCapabilities.update;365+ if (366+ !freshUpdate ||367+ (capabilities.identityKey !== null &&368+ capabilities.identityKey !== undefined &&369+ freshCapabilities.identityKey !== capabilities.identityKey)370+ ) {371+ return yield* finish(372+ makeUpdateState({373+ status: "failed",374+ startedAt,375+ finishedAt: yield* nowIso,376+ message: "Provider installation changed. Refresh and try again.",377+ }),378+ );379+ }380+381+ if (382+ freshCapabilities.identityKey !== null &&383+ freshCapabilities.identityKey !== undefined &&384+ !/^(?:[A-Za-z]:[\\/]|\/)/.test(freshUpdate.executable)apps/server/src/provider/maintenance/definition.ts lines 117 to 118OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +98,21 @@98+99+export interface InstallationCatalog {100+ readonly installations: ReadonlyArray<AnyInstallationDefinition>;101+ readonly fallbacks: ReadonlyArray<AnyInstallationDefinition>;102+}103+104+export function installationIdentity(input: Readonly<Record<string, string | null>>): string {105+ const canonical = Object.fromEntries(106+ Object.entries(input)107+ .sort(([left], [right]) => left.localeCompare(right))108+ .map(([key, value]) => [key, value ?? ""]),109+ );110+ return NodeCrypto.createHash("sha256")111+ .update(`t3-provider-maintenance-v1\0${JSON.stringify(canonical)}`, "utf8")112+ .digest("hex");113+}114+115+export function canonicalPath(path: string, platform: NodeJS.Platform): string {116+ const pathApi = platform === "win32" ? NodePath.win32 : NodePath.posix;117+ const normalized = pathApi.normalize(pathApi.resolve(path)).replaceAll("\\", "/");118+ return platform === "win32" ? normalized.toLowerCase() : normalized;
- apps/server/src/provider/Services/ProviderRegistry.ts lines 55 to 59Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -57,3 +57,8 @@5757 provider: ProviderDriverKind,5858 ) => Effect.Effect<ProviderMaintenanceCapabilities>;595960+ /** Resolve ownership again from the active executable immediately before update. */61+ readonly resolveProviderMaintenanceCapabilitiesForInstance?: (62+ instanceId: ProviderInstanceId,63+ provider: ProviderDriverKind,64+ ) => Effect.Effect<ProviderMaintenanceCapabilities>;apps/server/src/provider/providerMaintenance.ts lines 52 to 57OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -36,3 +46,12 @@3646 }).pipe(Config.map(compactEnv));37473848 const readCommandLookupEnv = CommandLookupEnvConfig.pipe(Effect.orElseSucceed(() => ({})));49+const MAINTENANCE_PROBE_MAX_BYTES = 64_000;50+51+const runMaintenanceProbe = Effect.fn("runMaintenanceProbe")(function* (input: {52+ readonly spawner: ChildProcessSpawner.ChildProcessSpawner["Service"];53+ readonly executable: string;54+ readonly args: ReadonlyArray<string>;55+ readonly environment: NodeJS.ProcessEnv;56+ readonly fileSystem: FileSystem.FileSystem;57+ readonly path: Path.Path;apps/server/src/provider/providerMaintenance.ts lines 549 to 549OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -375,0 +529,21 @@529+ binaryPath,530+ isBareCommand: !hasPathSeparator(binaryPath),531+ resolvedCommandPath,532+ realCommandPath,533+ environment: env,534+ platform,535+ readTextFile: (path) =>536+ path537+ ? fileSystem.readFileString(path).pipe(538+ Effect.map(Option.some),539+ Effect.orElseSucceed(() => Option.none()),540+ Effect.map(Option.getOrNull),541+ )542+ : Effect.succeed(null),543+ realPath: (path) => fileSystem.realPath(path).pipe(Effect.orElseSucceed(() => path)),544+ resolveCommand: (command) =>545+ resolveCommandPath(command, { env }).pipe(546+ Effect.provideService(FileSystem.FileSystem, fileSystem),547+ Effect.provideService(Path.Path, pathService),548+ Effect.map(Option.some),549+ Effect.catchTag("CommandResolutionError", () => Effect.succeed(Option.none())),
- apps/server/src/provider/maintenance/catalogs.ts lines 193 to 193OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +173,21 @@173+type NodeManager = (typeof nodeManagers)[number];174+interface NodeEvidence {175+ readonly manager: NodeManager;176+ readonly executable: string;177+ readonly root: string;178+ readonly currentVersion: string | null;179+}180+181+function detectNodePackage(input: ProviderMaintenanceDefinitionInput, manager: NodeManager) {182+ return Effect.fn(`detect-${manager.id}`)(function* (context: InstallationContext) {183+ const observed = normalize(184+ context,185+ context.realCommandPath ?? context.resolvedCommandPath ?? context.binaryPath,186+ );187+ const wrapper = yield* context.readTextFile(context.resolvedCommandPath ?? "");188+ let root =189+ packageRoot(observed, input.packageName) ??190+ packageRootFromWrapper(context, wrapper, context.resolvedCommandPath, input.packageName);191+ if (!root && manager.id !== "bun") return notMatched;192+ const executable = yield* context.resolveCommand(manager.command);193+ if (!executable) return notMatched;apps/server/src/provider/providerMaintenance.ts line 575OutdatedResolvedby ettoc00(GitHub profile, opens in a new tab)@@ -385,4 +572,4 @@385572 if (!input.latestVersion) {386573 return { status: "unknown", message: null };387574 }388- if (compareSemverVersions(input.currentVersion, input.latestVersion) < 0) {575+ if (compareMaintenanceVersions(input.currentVersion, input.latestVersion) === -1) {apps/server/src/provider/maintenance/catalogs.ts lines 672 to 675OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +655,21 @@655+ }),656+ resolve: Effect.fn("resolve-winget")(function* (evidence, context) {657+ const show = yield* context.run(658+ evidence.executable,659+ [660+ "show",661+ "--id",662+ packageId,663+ "--exact",664+ "--source",665+ evidence.source,666+ "--versions",667+ "--accept-source-agreements",668+ "--disable-interactivity",669+ ],670+ context.environment,671+ );672+ const latest =673+ (show?.stdout.match(/\b\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?\b/g) ?? [])674+ .map(normalizeMaintenanceVersion)675+ .find((value): value is string => value !== null) ?? null;
- apps/server/src/provider/Layers/ProviderRegistry.ts line 502OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -496,7 +496,7 @@496496 return yield* refreshOneSource(providerSource);497497 });498498499- const getProviderMaintenanceCapabilitiesForInstance = Effect.fn(500- "getProviderMaintenanceCapabilitiesForInstance",499+ const resolveProviderMaintenanceCapabilitiesForInstance = Effect.fn(500+ "resolveProviderMaintenanceCapabilitiesForInstance",501501 )(function* (instanceId: ProviderInstanceId, provider: ProviderDriverKind) {502502 const instance = Array.from((yield* Ref.get(liveSubsRef)).values()).find(apps/server/src/provider/maintenance/catalogs.ts lines 106 to 106OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +86,21 @@86+}87+88+function packageRoot(path: string, packageName: string): string | null {89+ const normalized = path.replaceAll("\\", "/");90+ const needle = `/node_modules/${packageName}/`;91+ const index = normalized.toLowerCase().lastIndexOf(needle.toLowerCase());92+ return index < 0 ? null : normalized.slice(0, index + needle.length - 1);93+}94+95+function packageRootFromWrapper(96+ context: InstallationContext,97+ wrapper: string | null,98+ wrapperPath: string | null,99+ packageName: string,100+): string | null {101+ if (!wrapper || !wrapperPath) return null;102+ const path = pathApi(context);103+ const embedded = packageRoot(wrapper, packageName);104+ if (embedded && path.isAbsolute(embedded)) return embedded;105+ const normalized = wrapper.replaceAll("\\", "/");106+ const packageSuffix = `/node_modules/${packageName}`;apps/server/src/provider/maintenance/version.ts line 23OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +3,21 @@3+const COMPARABLE_SEMVER =4+ /^(?:v)?(0|[1-9]\d*)(?:\.(0|[1-9]\d*))?(?:\.(0|[1-9]\d*))?(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;5+6+interface ParsedSemver {7+ readonly major: number;8+ readonly minor: number;9+ readonly patch: number;10+ readonly prerelease: ReadonlyArray<string>;11+}12+13+export function normalizeMaintenanceVersion(value: string | null | undefined): string | null {14+ const trimmed = value?.trim();15+ if (!trimmed || !FULL_SEMVER.test(trimmed)) return null;16+ return trimmed.startsWith("v") ? trimmed.slice(1) : trimmed;17+}18+19+function parse(value: string): ParsedSemver | null {20+ const match = COMPARABLE_SEMVER.exec(value);21+ return match22+ ? {23+ major: Number(match[1]),
- apps/server/src/provider/Drivers/ClaudeDriver.ts lines 137 to 145OutdatedResolvedby ettoc00(GitHub profile, opens in a new tab)@@ -131,7 +134,12 @@131134 instanceId,132135 });133136 const effectiveConfig = { ...config, enabled } satisfies ClaudeSettings;134- const maintenanceCapabilities = yield* resolveProviderMaintenanceCapabilitiesEffect(UPDATE, {137+ const resolveMaintenance = resolveProviderMaintenanceCapabilitiesEffect(UPDATE, {135138 binaryPath: effectiveConfig.binaryPath,136139 env: processEnv,137- });140+ }).pipe(141+ Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),142+ Effect.provideService(FileSystem.FileSystem, fileSystem),143+ Effect.provideService(Path.Path, path),144+ );145+ const maintenanceCapabilities = yield* resolveMaintenance;apps/server/src/provider/maintenance/catalogs.ts lines 229 to 262Resolvedby ettoc00(GitHub profile, opens in a new tab)@@ -0,0 +151,21 @@151+ rootArgs: ["pm", "bin", "-g"],152+ latestArgs: (name: string) => ["pm", "view", name, "version"],153+ updateArgs: (name: string) => ["install", "-g", `${name}@latest`],154+ },155+ {156+ id: "pnpm",157+ label: "pnpm",158+ command: "pnpm",159+ rootArgs: ["root", "-g"],160+ latestArgs: (name: string) => ["view", `${name}@latest`, "version", "--json"],161+ updateArgs: (name: string) => ["add", "-g", `${name}@latest`],162+ },163+ {164+ id: "npm",165+ label: "npm",166+ command: "npm",167+ rootArgs: ["root", "-g"],168+ latestArgs: (name: string) => ["view", `${name}@latest`, "version", "--json"],169+ updateArgs: (name: string) => ["install", "-g", `${name}@latest`],170+ },171+] as const;apps/server/src/provider/maintenance/catalogs.ts lines 422 to 459OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -0,0 +439,21 @@439+ }440+ const install = json(441+ yield* context.readTextFile(442+ pathApi(context).join(root, "apps", app, "current", "install.json"),443+ ),444+ );445+ const manifest = json(446+ yield* context.readTextFile(447+ pathApi(context).join(root, "apps", app, "current", "manifest.json"),448+ ),449+ );450+ if (!install || !manifest) return undetermined("Scoop metadata is unreadable.");451+ const bucket = text(install.bucket);452+ if (!bucket) return undetermined("Scoop bucket provenance is unavailable.");453+ const executable = yield* context.resolveCommand("scoop");454+ if (!executable) return undetermined("Scoop is unavailable.");455+ const executablePath = normalize(context, executable);456+ const managerMarker = "/shims/";457+ const managerIndex = executablePath.lastIndexOf(managerMarker);458+ if (managerIndex < 0) return undetermined("The owning Scoop root is unavailable.");459+ const managerRoot = executable.replaceAll("\\", "/").slice(0, managerIndex);apps/server/src/provider/providerMaintenance.ts lines 550 to 555Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -446,3 +637,6 @@446637 export const resolveLatestProviderVersion = Effect.fn("resolveLatestProviderVersion")(function* (447638 maintenanceCapabilities: ProviderMaintenanceCapabilities,448639 ) {640+ if (maintenanceCapabilities.latestVersion !== undefined) {641+ return maintenanceCapabilities.latestVersion;642+ }apps/server/src/provider/providerMaintenanceRunner.ts lines 386 to 400Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -342,0 +374,21 @@374+ startedAt,375+ finishedAt: yield* nowIso,376+ message: "Provider installation changed. Refresh and try again.",377+ }),378+ );379+ }380+381+ if (382+ freshCapabilities.identityKey !== null &&383+ freshCapabilities.identityKey !== undefined &&384+ !/^(?:[A-Za-z]:[\\/]|\/)/.test(freshUpdate.executable)385+ ) {386+ return yield* finish(387+ makeUpdateState({388+ status: "failed",389+ startedAt,390+ finishedAt: yield* nowIso,391+ message: "Provider update executable could not be verified.",392+ }),393+ );394+ }apps/server/src/provider/providerMaintenanceRunner.ts lines 402 to 406Resolvedby ettoc00(GitHub profile, opens in a new tab)@@ -342,0 +380,21 @@380+381+ if (382+ freshCapabilities.identityKey !== null &&383+ freshCapabilities.identityKey !== undefined &&384+ !/^(?:[A-Za-z]:[\\/]|\/)/.test(freshUpdate.executable)385+ ) {386+ return yield* finish(387+ makeUpdateState({388+ status: "failed",389+ startedAt,390+ finishedAt: yield* nowIso,391+ message: "Provider update executable could not be verified.",392+ }),393+ );394+ }395+396+ const result = yield* runMaintenanceCommand(397+ freshUpdate.executable,398+ freshUpdate.args,399+ freshUpdate.environment,400+ );
- apps/server/src/provider/maintenance/version.ts lines 1 to 4OutdatedResolvedby ettoc00(GitHub profile, opens in a new tab)@@ -0,0 +1,4 @@1+const FULL_SEMVER =2+ /^(?:v)?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;3+const COMPARABLE_SEMVER =4+ /^(?:v)?(0|[1-9]\d*)(?:\.(0|[1-9]\d*))?(?:\.(0|[1-9]\d*))?(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;apps/server/src/provider/maintenance/version.ts lines 11 to 61Resolvedby ettoc00(GitHub profile, opens in a new tab)@@ -0,0 +36,21 @@36+ const a = left[index];37+ const b = right[index];38+ if (a === undefined || b === undefined) return a === b ? 0 : a === undefined ? -1 : 1;39+ if (a === b) continue;40+ const aNumeric = /^\d+$/.test(a);41+ const bNumeric = /^\d+$/.test(b);42+ if (aNumeric && bNumeric) return Number(a) < Number(b) ? -1 : 1;43+ if (aNumeric !== bNumeric) return aNumeric ? -1 : 1;44+ return a < b ? -1 : 1;45+ }46+ return 0;47+}48+49+export function compareMaintenanceVersions(left: string, right: string): number | null {50+ const a = parse(left);51+ const b = parse(right);52+ if (!a || !b) return null;53+ for (const key of ["major", "minor", "patch"] as const) {54+ if (a[key] !== b[key]) return a[key] < b[key] ? -1 : 1;55+ }56+ return comparePrerelease(a.prerelease, b.prerelease);apps/server/src/provider/maintenance/version.ts lines 23 to 25OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -0,0 +5,21 @@5+6+interface ParsedSemver {7+ readonly major: number;8+ readonly minor: number;9+ readonly patch: number;10+ readonly prerelease: ReadonlyArray<string>;11+}12+13+export function normalizeMaintenanceVersion(value: string | null | undefined): string | null {14+ const trimmed = value?.trim();15+ if (!trimmed || !FULL_SEMVER.test(trimmed)) return null;16+ return trimmed.startsWith("v") ? trimmed.slice(1) : trimmed;17+}18+19+function parse(value: string): ParsedSemver | null {20+ const match = COMPARABLE_SEMVER.exec(value);21+ return match22+ ? {23+ major: Number(match[1]),24+ minor: Number(match[2] ?? 0),25+ patch: Number(match[3] ?? 0),apps/server/src/provider/providerMaintenanceRunner.test.ts line 349Resolvedby ettoc00(GitHub profile, opens in a new tab)@@ -251,0 +285,21 @@285+ assert.strictEqual(result.providers[0]?.updateState?.status, "failed");286+ assert.strictEqual(287+ result.providers[0]?.updateState?.message,288+ "Provider installation changed. Refresh and try again.",289+ );290+ }).pipe(291+ Effect.provide(292+ Layer.mergeAll(293+ NonWindowsPlatform,294+ latestVersionHttpClient("0.0.0"),295+ mockSpawnerLayer(() => {296+ spawnCount += 1;297+ return {};298+ }),299+ ),300+ ),301+ );302+ });303+304+ it.effect("accepts a verified update executable on a Windows UNC share", () => {305+ const calls: Array<{ command: string; args: ReadonlyArray<string> }> = [];
- apps/server/src/provider/maintenance/catalogs.ts line 596Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +380,21 @@380+ );381+ const info = json(infoProbe?.stdout ?? null);382+ if (!infoProbe || infoProbe.exitCode !== 0 || !info) {383+ return undetermined("Homebrew formula metadata is unavailable.");384+ }385+ const formulaInfo = records(info.formulae)[0];386+ const caskInfo = records(info.casks)[0];387+ const versions = formulaInfo?.versions;388+ const stable =389+ typeof versions === "object" && versions !== null && !Array.isArray(versions)390+ ? text((versions as Record<string, unknown>).stable)391+ : null;392+ const installedFormula = records(formulaInfo?.installed)[0];393+ const installedCask = Array.isArray(caskInfo?.installed) ? text(caskInfo.installed[0]) : null;394+ const currentVersion = normalizeMaintenanceVersion(395+ text(installedFormula?.version) ?? installedCask,396+ );397+ if (!currentVersion) return undetermined("Homebrew installed version is unavailable.");398+ return matched({399+ executable,400+ prefix,
- apps/server/src/provider/maintenance/version.ts lines 14 to 14OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +1,14 @@1+const FULL_SEMVER =2+ /^(?:v)?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;3+const COMPARABLE_SEMVER =4+ /^(?:v)?(0|[1-9]\d*)(?:\.(0|[1-9]\d*))?(?:\.(0|[1-9]\d*))?(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;5+6+interface ParsedSemver {7+ readonly major: bigint;8+ readonly minor: bigint;9+ readonly patch: bigint;10+ readonly prerelease: ReadonlyArray<string>;11+}12+13+function hasValidPrerelease(value: string): boolean {14+ const prerelease = value.match(/-(?<prerelease>[^+]+)(?:\+|$)/)?.groups?.prerelease;
ettoc00(GitHub profile, opens in a new tab) changed the title
- apps/server/src/provider/providerMaintenance.ts line 585OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -395,4 +582,4 @@395582 if (!input.latestVersion) {396583 return { status: "unknown", message: null };397584 }398- if (compareSemverVersions(input.currentVersion, input.latestVersion) < 0) {585+ if (compareMaintenanceVersions(input.currentVersion, input.latestVersion) === -1) {apps/server/src/provider/maintenance/catalogs.ts line 368OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +348,21 @@348+ if (!marker) return normalized;349+ const markerIndex = lower.indexOf(marker);350+ const formulaStart = markerIndex + marker.length;351+ const formulaEnd = normalized.indexOf("/", formulaStart);352+ return formulaEnd < 0 ? normalized : normalized.slice(0, formulaEnd);353+}354+355+function homebrewDefinition(input: ProviderMaintenanceDefinitionInput) {356+ return defineInstallation<{357+ executable: string;358+ prefix: string;359+ currentVersion: string | null;360+ latestVersion: string | null;361+ }>({362+ id: `${input.provider}-homebrew`,363+ detect: Effect.fn("detect-homebrew")(function* (context) {364+ if (!input.homebrewFormula) return notMatched;365+ const observed = normalize(context, context.realCommandPath ?? context.binaryPath);366+ const observedLower = observed.toLowerCase();367+ if (!observedLower.includes("/cellar/") && !observedLower.includes("/caskroom/")) {368+ return notMatched;
- apps/server/src/provider/Drivers/GrokDriver.ts line 61Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -48,0 +43,21 @@43+44+function isGrokNativeCommandPath(commandPath: string): boolean {45+ const normalized = normalizeCommandPath(commandPath);46+ return (47+ normalized.endsWith("/.grok/bin/grok") || normalized.endsWith("/.grok/bin/grok.exe")48+ );49+}50+51+const UPDATE = makeProviderMaintenanceResolver({52+ provider: DRIVER_KIND,53+ packageName: "@xai-official/grok",54+ homebrewFormula: null,55+ nativeUpdate: {56+ executable: "grok",57+ args: ["update"],58+ lockKey: "grok-native",59+ isCommandPath: isGrokNativeCommandPath,60+ },61+ executableName: "grok",62+ instructionsUrl: "https://docs.x.ai/build/overview",63+});
- apps/server/src/provider/Drivers/GrokDriver.ts lines 51 to 63OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -48,0 +43,21 @@43+44+function isGrokNativeCommandPath(commandPath: string): boolean {45+ const normalized = normalizeCommandPath(commandPath);46+ return (47+ normalized.endsWith("/.grok/bin/grok") || normalized.endsWith("/.grok/bin/grok.exe")48+ );49+}50+51+const UPDATE = makeProviderMaintenanceResolver({52+ provider: DRIVER_KIND,53+ packageName: "@xai-official/grok",54+ homebrewFormula: null,55+ nativeUpdate: {56+ executable: "grok",57+ args: ["update"],58+ lockKey: "grok-native",59+ isCommandPath: isGrokNativeCommandPath,60+ },61+ executableName: "grok",62+ instructionsUrl: "https://docs.x.ai/build/overview",63+});
- apps/server/src/provider/maintenance/catalogs.ts lines 152 to 162OutdatedResolvedby ettoc00(GitHub profile, opens in a new tab)@@ -0,0 +142,21 @@142+ return normalized.includes(prefix) && !normalized.includes(`${prefix}/`);143+}144+145+const npmGlobalUpdateArgs = (packageName: string) => [146+ "install",147+ "-g",148+ `--allow-scripts=${packageName}`,149+ `${packageName}@latest`,150+];151+152+function npmGlobalPrefix(context: InstallationContext, packageRoot: string) {153+ const normalizedRoot = normalize(context, packageRoot);154+ if (context.platform === "win32") {155+ const marker = "/node_modules/";156+ const markerIndex = normalizedRoot.lastIndexOf(marker);157+ return markerIndex > 0 ? packageRoot.replaceAll("\\", "/").slice(0, markerIndex) : null;158+ }159+ const marker = "/lib/node_modules/";160+ const markerIndex = normalizedRoot.lastIndexOf(marker);161+ return markerIndex > 0 ? packageRoot.replaceAll("\\", "/").slice(0, markerIndex) : null;162+}apps/server/src/provider/maintenance/catalogs.ts lines 890 to 902Resolvedby ettoc00(GitHub profile, opens in a new tab)@@ -0,0 +735,21 @@735+ const show = yield* context.run(736+ evidence.executable,737+ [738+ "show",739+ "--id",740+ packageId,741+ "--exact",742+ "--source",743+ evidence.source,744+ "--versions",745+ "--accept-source-agreements",746+ "--disable-interactivity",747+ ],748+ context.environment,749+ );750+ const latest =751+ show && show.exitCode === 0752+ ? ((show.stdout.match(/\b\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?\b/g) ?? [])753+ .map(normalizeMaintenanceVersion)754+ .find((value): value is string => value !== null) ?? null)755+ : null;
- apps/server/src/provider/maintenance/catalogs.ts line 547OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +527,21 @@527+ const manifest = json(528+ yield* context.readTextFile(529+ pathApi(context).join(root, "apps", app, "current", "manifest.json"),530+ ),531+ );532+ if (!install || !manifest) return undetermined("Scoop metadata is unreadable.");533+ const bucket = text(install.bucket);534+ if (!bucket) return undetermined("Scoop bucket provenance is unavailable.");535+ const executable = yield* context.resolveCommand("scoop");536+ if (!executable) return undetermined("Scoop is unavailable.");537+ const slashExecutable = executable.replaceAll("\\", "/");538+ const executablePath = slashExecutable.toLowerCase();539+ const managerMarker = "/shims/";540+ const managerIndex = executablePath.lastIndexOf(managerMarker);541+ if (managerIndex < 0) return undetermined("The owning Scoop root is unavailable.");542+ const managerRoot = slashExecutable.slice(0, managerIndex);543+ let global = !within(context, executable, root);544+ if (global) {545+ const globalProbe = yield* context.run(546+ executable,547+ ["config", "SCOOP_GLOBAL"],
- apps/server/src/provider/maintenance/catalogs.ts line 677Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +553,21 @@553+ yield* context.readTextFile(554+ pathApi(context).join(root, "apps", app, "current", "install.json"),555+ ),556+ );557+ const manifest = json(558+ yield* context.readTextFile(559+ pathApi(context).join(root, "apps", app, "current", "manifest.json"),560+ ),561+ );562+ if (!install || !manifest) return undetermined("Scoop metadata is unreadable.");563+ const bucket = text(install.bucket);564+ if (!bucket) return undetermined("Scoop bucket provenance is unavailable.");565+ const executable = yield* context.resolveCommand("scoop");566+ if (!executable) return undetermined("Scoop is unavailable.");567+ const slashExecutable = executable.replaceAll("\\", "/");568+ const executablePath = slashExecutable.toLowerCase();569+ const managerMarker = "/shims/";570+ const managerIndex = executablePath.lastIndexOf(managerMarker);571+ if (managerIndex < 0) return undetermined("The owning Scoop root is unavailable.");572+ const managerRoot = slashExecutable.slice(0, managerIndex);573+ const global = !within(context, executable, root);
- apps/server/src/provider/maintenance/catalogs.ts line 160OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +140,21 @@140+ const normalized = wrapper.replaceAll("\\", "/").toLowerCase();141+ const prefix = `/node_modules/${packageName.toLowerCase()}`;142+ return normalized.includes(prefix) && !normalized.includes(`${prefix}/`);143+}144+145+const npmGlobalUpdateArgs = (packageName: string) => [146+ "install",147+ "-g",148+ `--allow-scripts=${packageName}`,149+ `${packageName}@latest`,150+];151+152+function npmGlobalPrefix(context: InstallationContext, packageRoot: string) {153+ const slashRoot = packageRoot.replaceAll("\\", "/");154+ const comparableRoot = context.platform === "win32" ? slashRoot.toLowerCase() : slashRoot;155+ if (context.platform === "win32") {156+ const marker = "/node_modules/";157+ const markerIndex = comparableRoot.lastIndexOf(marker);158+ return markerIndex > 0 ? slashRoot.slice(0, markerIndex) : null;159+ }160+ const marker = "/lib/node_modules/";apps/server/src/provider/Drivers/GrokDriver.ts line 131OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -102,7 +117,15 @@102117 continuationGroupKey: continuationIdentity.continuationKey,103118 });104119 const effectiveConfig = { ...config, enabled } satisfies GrokSettings;105- const maintenanceCapabilities = yield* resolveProviderMaintenanceCapabilitiesEffect(UPDATE, {106- binaryPath: effectiveConfig.binaryPath,107- env: processEnv,108- });120+ const resolveMaintenance = resolveProviderMaintenanceCapabilitiesEffect(121+ GrokMaintenanceResolver,122+ {123+ binaryPath: effectiveConfig.binaryPath,124+ env: processEnv,125+ },126+ ).pipe(127+ Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),128+ Effect.provideService(FileSystem.FileSystem, fileSystem),129+ Effect.provideService(Path.Path, pathService),130+ );131+ const maintenanceCapabilities = yield* resolveMaintenance;
- apps/web/src/components/settings/ProviderSettingsPanel.tsx lines 728 to 728Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -729 +728 @@729728 (provider) =>apps/web/src/components/settings/providerStatus.ts lines 106 to 115Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -94,10 +94,20 @@9494 advisory: ServerProviderVersionAdvisory | undefined,9595 ): {96+ readonly title: string;9697 readonly detail: string;9798 readonly updateCommand: string | null;9899 readonly emphasis: "normal" | "strong";99100 } | null {100- if (!advisory || advisory.status === "current" || advisory.status === "unknown") {101+ if (!advisory || advisory.status === "current") {101102 return null;102103 }103104105+ if (advisory.status === "unknown") {106+ return advisory.canUpdate && advisory.updateCommand107+ ? {108+ title: "Check for updates",109+ detail: "Run the verified installer update, then T3 Code will check the version again.",110+ updateCommand: advisory.updateCommand,111+ emphasis: "normal" as const,112+ }113+ : null;
Sign in to join this conversation.


Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
5bf59f20-fcf7-4d66-b7b4-572a3c6f6344You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Note
Reviews paused#
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
reviews.auto_review.auto_pause_after_reviewed_commitssetting.Use the following commands to manage reviews:
@coderabbitai resumeto resume automatic reviews.@coderabbitai reviewto trigger a single review.Use the checkboxes below for quick actions:
📝 Walkthrough
Walkthrough#
Provider maintenance now resolves installations through shared catalogs, exposes dynamic capabilities, and verifies installation identity before and after updates. Claude, Codex, OpenCode, and Grok use provider-specific metadata with the generic resolver. Provider settings support update actions for unknown version status.
Changes#
Provider maintenance lifecycle
apps/server/src/provider/maintenance/definition.ts,apps/server/src/provider/maintenance/version.ts,apps/server/src/provider/maintenance/resolver.tsapps/server/src/provider/maintenance/catalogs.ts,apps/server/src/provider/maintenance/catalogs.test.tsapps/server/src/provider/providerMaintenance.ts,apps/server/src/provider/providerMaintenance.test.tsapps/server/src/provider/Services/*,apps/server/src/provider/Layers/ProviderRegistry.ts,apps/server/src/provider/makeManagedServerProvider.ts,apps/server/src/provider/Drivers/*,apps/server/src/provider/testUtils/providerRegistryMock.ts,apps/server/src/server.test.tsapps/server/src/provider/providerMaintenanceRunner.ts,apps/server/src/provider/providerMaintenanceRunner.test.tsapps/web/src/components/ProviderUpdateLaunchNotification.logic.ts,apps/web/src/components/settings/ProviderSettingsPanel.tsx,apps/web/src/components/settings/providerStatus.ts,apps/web/src/components/settings/ProviderInstanceCard.tsx,apps/web/src/components/settings/*test*Estimated code review effort: 4 (Complex) | ~60 minutes
Merge Risk: 🟠 High · up to
54cbeThis change routes provider updates through installer ownership checks, but the current head still has a test file that cannot compile, a Cursor update path without identity verification, and cancellation handling that can delay or bypass probe timeouts; several version and installer edge cases can also hide or misclassify updates. The PR is not merge-ready until these issues are fixed or explicitly accepted.
Suggested reviewers:
hey-jj,juliusmarmingeSequence Diagram(s)#
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)#
✅ Passed checks (4 passed)
Full details: Description check
Explanation
The description clearly explains the problem, implementation, scope, risks, related issues, validation, and UI impact. It is mostly complete, although it does not use the template's exact Why, UI Changes, or Checklist headings and does not include screenshots.
✨ Finishing Touches
🧪 Generate unit tests (beta)
Warning
Your free Security trial is over. An organization admin can activate Security or dismiss this notice.
Comment `@coderabbitai help` to get the list of available commands.