The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 13:30 UTC
fix(server): recognize Windows Volta provider installs (#36917)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Wout Stiens committed
Nov 14, 2026 at 22:07 UTC
74f02db077e80cfa26d76450f91b90e993f7b640
4 files changed
+161
-24
docs/internals/providers.md
+5
-4
@@ -85,10 +85,11 @@ and npm are proven by the real path (symlinks followed): a versioned keg or cask
85
`brew --prefix`, or `<prefix>/lib/node_modules/<pkg>/` (Windows: the shim beside `node_modules`).
86
Native installer layouts and the global directories of pnpm, Bun, Yarn, and Vite+ may match on
87
either the resolved path or its real target, since those installers place real files or their own
88
-symlinks there. Volta is proven by its `volta-shim` link plus the package's image directory. When
89
-nothing is proven, Pi's and Grok's own updaters (`pi update --self`, `grok update`) run instead,
90
-because each detects its installer itself; the runner's version check catches an updater that exits
91
-0 without updating. Claude, Codex, and OpenCode updaters only act on their own native layout, so
88
+symlinks there. Volta is proven by the package's image directory plus either its `volta-shim` link
89
+or, on Windows, the exact cmd or bash forwarding script Volta generates; a custom script that merely
90
+calls `volta run` does not qualify. When nothing is proven, Pi's and Grok's own updaters
91
+(`pi update --self`, `grok update`) run instead, because each detects its installer itself; the
92
+runner's version check catches an updater that exits 0 without updating. Claude, Codex, and OpenCode updaters only act on their own native layout, so
93
those providers stay manual-only unless that layout is proven. Mise is checked
94
first, since a `mise x` wrapper can sit at a native installer's path, and `MISE_DATA_DIR` can put
95
installs anywhere, so `mise which` is asked whenever mise is on `PATH`. Each driver names its fixed
packages/provider-core/src/server/maintenanceResolver.test.ts
+49
@@ -2495,6 +2495,55 @@ it.layer(
2495
}),
2496
);
2497
2498
+ it.effect.each([
2499
+ { name: "Volta's script shim", script: "@echo off\r\nvolta run %~n0 %*\r\n", owned: true },
2500
+ {
2501
+ name: "a fixed-target wrapper",
2502
+ script: '#!/bin/bash\nvolta run node /other/opencode/index.js "$@"\n',
2503
+ owned: false,
2504
+ },
2505
+ {
2506
+ name: "an unreachable forwarding line",
2507
+ script: "@echo off\r\nexit /b 0\r\nvolta run %~n0 %*\r\n",
2508
+ owned: false,
2509
+ },
2510
+ {
2511
+ name: "Volta's bash shim without a final newline",
2512
+ script: '#!/bin/bash\nvolta run "$(basename $0)" "$@"',
2513
+ owned: true,
2514
+ },
2515
+ ])(
2516
+ "updates Windows Volta installs from $name only when Volta has the package",
2517
+ ({ script, owned }) =>
2518
+ Effect.gen(function* () {
2519
+ const voltaHome = NodePath.join(yield* makeTempDir("t3-volta-windows"), "Volta");
2520
+ const shim = NodePath.join(voltaHome, "bin", "package-tool.CMD");
2521
+ NodeFS.mkdirSync(NodePath.dirname(shim), { recursive: true });
2522
+ NodeFS.writeFileSync(shim, script);
2523
+ const resolve = resolveProviderMaintenanceCapabilitiesEffect(packageToolUpdate, {
2524
+ binaryPath: shim,
2525
+ env: { PATH: "" },
2526
+ }).pipe(
2527
+ Effect.provideService(HostProcess.Platform, "win32"),
2528
+ Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, noSpawn),
2529
+ );
2530
+
2531
+ expect((yield* resolve).update).toBeNull();
2532
+ NodeFS.mkdirSync(
2533
+ NodePath.join(voltaHome, "tools", "image", "packages", "@example", "package-tool"),
2534
+ { recursive: true },
2535
+ );
2536
+ expect((yield* resolve).update).toEqual(
2537
+ owned
2538
+ ? expect.objectContaining({
2539
+ command: "volta install @example/package-tool@latest",
2540
+ lockKey: "volta",
2541
+ })
2542
+ : null,
2543
+ );
2544
+ }),
2545
+ );
2546
+
2547
it.effect.skipIf(windowsHost)("upgrades with the keg's own brew when brew is not on PATH", () =>
2548
Effect.gen(function* () {
2549
const tempDir = yield* makeTempDir("t3-homebrew-keg-brew");
packages/provider-core/src/server/maintenanceResolver.ts
+28
-20
@@ -39,7 +39,7 @@ import * as ProviderLatestVersions from "./ProviderLatestVersions.ts";
39
const LATEST_VERSION_TIMEOUT_MS = 4_000;
40
const PROBE_TIMEOUT_MS = 10_000;
41
const PROBE_MAX_BYTES = 256 * 1_024;
42
-const MISE_WRAPPER_MAX_BYTES = 16 * 1_024;
42
+const WRAPPER_SCRIPT_MAX_BYTES = 16 * 1_024;
43
const PROVIDER_UPDATE_ACTION_TOAST_MESSAGE = "Install the update now or review provider settings.";
44
45
const MAINTENANCE_CAPABILITIES_CACHE_TTL = Duration.hours(1);
@@ -1067,20 +1067,21 @@ export const resolveHomebrewProviderMaintenance = Effect.fn("resolveHomebrewProv
1067
},
1068
);
1069
1070
-const isMiseWrapperScript = Effect.fn("isMiseWrapperScript")(function* (
1071
- context: ProviderMaintenanceResolutionContext,
1072
-) {
1070
+/** The command's text when it is small enough to be a wrapper script, else "". */
1071
+const readWrapperScript = Effect.fn("readWrapperScript")(function* (commandPath: string) {
1072
const fileSystem = yield* FileSystem.FileSystem;
1074
- const size = yield* fileSystem.stat(context.realCommandPath).pipe(
1073
+ const size = yield* fileSystem.stat(commandPath).pipe(
1074
Effect.map((info) => Number(info.size)),
1075
Effect.orElseSucceed(() => Infinity),
1076
);
1078
- if (size > MISE_WRAPPER_MAX_BYTES) {
1079
- return false;
1080
- }
1081
- const script = yield* fileSystem
1082
- .readFileString(context.realCommandPath)
1083
- .pipe(Effect.orElseSucceed(() => ""));
1077
+ if (size > WRAPPER_SCRIPT_MAX_BYTES) return "";
1078
+ return yield* fileSystem.readFileString(commandPath).pipe(Effect.orElseSucceed(() => ""));
1079
+});
1080
+
1081
+const isMiseWrapperScript = Effect.fn("isMiseWrapperScript")(function* (
1082
+ context: ProviderMaintenanceResolutionContext,
1083
+) {
1084
+ const script = yield* readWrapperScript(context.realCommandPath);
1085
return script.startsWith("#!") && /\bmise\s+(?:x|exec)\b/.test(script);
1086
});
1087
@@ -1108,22 +1109,29 @@ const resolveMacPortsOwner = Effect.fn("resolveMacPortsOwner")(function* (
1109
return /^[\w.+-]+$/.test(name) ? name : "";
1110
});
1111
1111
-// Volta bin links only identify its shim; the package image proves ownership.
1112
+// Volta bin entries only identify its shim; the package image proves ownership.
1113
+// POSIX links point at `volta-shim`; Windows Volta 2 writes `volta run %~n0 %*` scripts.
1114
const isVoltaPackageInstall = Effect.fn("isVoltaPackageInstall")(function* (
1115
context: ProviderMaintenanceResolutionContext,
1116
packageName: string,
1117
) {
1118
const path = yield* Path.Path;
1117
- if (
1118
- path.basename(normalizeCommandPath(context.realCommandPath)).replace(/\.exe$/, "") !==
1119
- "volta-shim"
1120
- ) {
1121
- return false;
1122
- }
1119
+ const fileSystem = yield* FileSystem.FileSystem;
1120
const voltaHome = path.dirname(path.dirname(context.resolvedCommandPath));
1121
const packageDir = path.join(voltaHome, "tools", "image", "packages", ...packageName.split("/"));
1125
- const fileSystem = yield* FileSystem.FileSystem;
1126
- return yield* fileSystem.exists(packageDir).pipe(Effect.orElseSucceed(() => false));
1122
+ if (!(yield* fileSystem.exists(packageDir).pipe(Effect.orElseSucceed(() => false)))) {
1123
+ return false;
1124
+ }
1125
+ if (/^volta-shim(?:\.exe)?$/.test(path.basename(normalizeCommandPath(context.realCommandPath)))) {
1126
+ return true;
1127
+ }
1128
+ const script = (yield* readWrapperScript(context.realCommandPath))
1129
+ .replace(/\r\n/g, "\n")
1130
+ .replace(/\n$/, "");
1131
+ return (
1132
+ script === "@echo off\nvolta run %~n0 %*" ||
1133
+ script === '#!/bin/bash\nvolta run "$(basename $0)" "$@"'
1134
+ );
1135
});
1136
1137
const resolveNpmGlobalPrefix = Effect.fn("resolveNpmGlobalPrefix")(function* (
scripts/scenarios/volta-script-shim-offers-volta-update.e2e.ts
new
+79
@@ -0,0 +1,79 @@
1
+import { expect } from "e2e";
2
+import * as Effect from "effect/Effect";
3
+import * as FileSystem from "effect/FileSystem";
4
+import * as Path from "effect/Path";
5
+import * as Schema from "effect/Schema";
6
+
7
+import { T3_HOME } from "../e2e.config.ts";
8
+import { runPromise, test, WEB } from "./t3.ts";
9
+
10
+// Windows Volta 2 writes `bin/<tool>` scripts that run `volta run`, not links to `volta-shim`.
11
+// The fake `volta` only reports a version, so nothing installs or reaches a model. The latest
12
+// version comes from npm's registry through the host's npm, which the server finds first on PATH.
13
+const VOLTA_SCRIPT_SHIM = '#!/bin/bash\nvolta run "$(basename $0)" "$@"\n';
14
+const FAKE_VOLTA = '#!/bin/sh\n[ "$1 $3" = "run --version" ] && echo 2.1.2 && exit 0\nexit 1\n';
15
+
16
+const SettingsJson = Schema.fromJsonString(
17
+ Schema.StructWithRest(
18
+ Schema.Struct({ providerInstances: Schema.Record(Schema.String, Schema.Unknown) }),
19
+ [Schema.Record(Schema.String, Schema.Unknown)],
20
+ ),
21
+);
22
+
23
+const decodeSettings = Schema.decodeEffect(SettingsJson);
24
+const encodeSettings = Schema.encodeEffect(SettingsJson);
25
+
26
+const installVoltaOpenCode = Effect.gen(function* () {
27
+ const fs = yield* FileSystem.FileSystem;
28
+ const path = yield* Path.Path;
29
+ const voltaHome = path.join(T3_HOME, "Volta");
30
+ const shim = path.join(voltaHome, "bin", "opencode");
31
+ const executable = (file: string, text: string) =>
32
+ fs
33
+ .makeDirectory(path.dirname(file), { recursive: true })
34
+ .pipe(Effect.andThen(fs.writeFileString(file, text)), Effect.andThen(fs.chmod(file, 0o755)));
35
+ yield* executable(shim, VOLTA_SCRIPT_SHIM);
36
+ yield* fs.makeDirectory(path.join(voltaHome, "tools", "image", "packages", "@opencode", "cli"), {
37
+ recursive: true,
38
+ });
39
+ // The scenario home's `bin` is on the server's PATH.
40
+ yield* executable(path.join(T3_HOME, "bin", "volta"), FAKE_VOLTA);
41
+
42
+ const settingsPath = path.join(T3_HOME, "userdata", "settings.json");
43
+ const settings = yield* decodeSettings(yield* fs.readFileString(settingsPath));
44
+ const opencode = { driver: "opencode", enabled: true, config: { binaryPath: shim } };
45
+ yield* fs.writeFileString(
46
+ settingsPath,
47
+ yield* encodeSettings({
48
+ ...settings,
49
+ providerInstances: { ...settings.providerInstances, opencode },
50
+ }),
51
+ );
52
+});
53
+
54
+test(
55
+ "OpenCode installed through a Volta script shim offers a Volta update",
56
+ WEB,
57
+ async ({ t3, app, browser, screen }) => {
58
+ await browser.emulateMedia({ colorScheme: "dark" });
59
+ await t3.project("demo");
60
+ await runPromise(installVoltaOpenCode);
61
+ await t3.open("/settings/providers?instanceId=opencode");
62
+
63
+ // The list row and the detail header both carry the button; take the header's.
64
+ const details = screen.getByRole("button", /view details/).last();
65
+ await expect(details).toBeVisible({ timeout: 60_000 });
66
+ await details.tap();
67
+ await expect(screen.getByRole("dialog", "Update available")).toBeVisible();
68
+ // Capture the settled popover, not its fade-in.
69
+ await browser.evaluate(() => {
70
+ const popover = document.querySelector('[role="dialog"][aria-label="Update available"]');
71
+ for (const animation of popover?.getAnimations({ subtree: true }) ?? []) {
72
+ if (Number.isFinite(animation.effect?.getComputedTiming().endTime)) animation.finish();
73
+ }
74
+ return null;
75
+ });
76
+ await app.screenshot("update-details");
77
+ await expect(screen.getByText("volta install @opencode/cli@latest")).toBeVisible();
78
+ },
79
+);