Skip to content

Commit 8277581

Browse files
fix(providers): allow a separate CLI path for updates
Codex and Claude launchers can configure routing or accounts without owning the underlying CLI installation. Resolving maintenance from the launcher can disable updates or invoke the wrong executable. Add an optional maintenance binary path and resolve installation ownership and update advisories from that CLI. Keep session launch paths, snapshot versions and post-update verification tied to the session executable. Clearing the override restores the existing behavior. Bind Bun global updates to the proven package and binary directories, with an installation-specific lock. Leave unproven installations manual-only.
1 parent 79f1fad commit 8277581

7 files changed

Lines changed: 242 additions & 30 deletions

File tree

‎apps/server/src/provider/Drivers/ClaudeDriver.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ export const ClaudeDriver: ProviderDriver<ClaudeSettings, ClaudeDriverEnv, Path.
147147
const resolveMaintenance = yield* makeCachedProviderMaintenanceResolution(
148148
resolveProviderMaintenanceCapabilitiesEffect(UPDATE, {
149149
binaryPath: effectiveConfig.binaryPath,
150+
maintenanceBinaryPath: config.maintenanceBinaryPath
151+
? expandHomePath(config.maintenanceBinaryPath, yield* HostProcess.HomeDirectory)
152+
: null,
150153
env: processEnv,
151154
}).pipe(
152155
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
@@ -305,6 +308,7 @@ export const ClaudeDriver: ProviderDriver<ClaudeSettings, ClaudeDriverEnv, Path.
305308
Effect.flatMap((maintenanceCapabilities) =>
306309
enrichProviderSnapshotWithVersionAdvisory(snapshot, maintenanceCapabilities, {
307310
enableProviderUpdateChecks: settings.enableProviderUpdateChecks,
311+
useMaintenanceVersion: true,
308312
}),
309313
),
310314
Effect.provideService(HttpClient.HttpClient, httpClient),

‎apps/server/src/provider/Drivers/CodexDriver.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ export const CodexDriver: ProviderDriver<
182182
makeCodexMaintenanceResolver(homeLayout.sharedHomePath),
183183
{
184184
binaryPath: effectiveConfig.binaryPath,
185+
maintenanceBinaryPath: config.maintenanceBinaryPath
186+
? expandHomePath(config.maintenanceBinaryPath, yield* HostProcess.HomeDirectory)
187+
: null,
185188
env: processEnv,
186189
},
187190
).pipe(
@@ -249,6 +252,7 @@ export const CodexDriver: ProviderDriver<
249252
Effect.flatMap((maintenanceCapabilities) =>
250253
enrichProviderSnapshotWithVersionAdvisory(snapshot, maintenanceCapabilities, {
251254
enableProviderUpdateChecks: settings.enableProviderUpdateChecks,
255+
useMaintenanceVersion: true,
252256
}),
253257
),
254258
Effect.provideService(HttpClient.HttpClient, httpClient),

‎docs/user/install.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,11 @@ mise through mise. Cursor and Antigravity update with T3 Code. Homebrew installs
190190
compare against the version Homebrew offers, which can trail the npm release by
191191
a few hours.
192192

193+
If Codex or Claude uses a launcher as its **Binary path**, set **Maintenance binary path**
194+
to the underlying CLI installation in web or desktop Settings. Sessions keep using the
195+
launcher; Update now uses the maintenance installation and still verifies the session
196+
binary's version afterward. Clear the maintenance path to update the session binary again.
197+
193198
Add another provider instance for a separate account or configuration. Each
194199
instance can have its own environment variables, such as API keys or a custom
195200
base URL. Mark secret values as sensitive; after saving, T3 Code does not display

‎packages/contracts/src/settings.ts‎

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,15 @@ export function makeProviderSettingsSchema<const Fields extends Schema.Struct.Fi
626626
);
627627
}
628628

629+
const MaintenanceBinaryPath = Schema.optionalKey(TrimmedString).pipe(
630+
Schema.annotateKey({
631+
title: "Maintenance binary path",
632+
description:
633+
"Underlying CLI to update when Binary path is a launcher. Leave empty to update the session binary.",
634+
providerSettingsForm: { clearWhenEmpty: "omit" },
635+
}),
636+
);
637+
629638
export const CodexSettings = makeProviderSettingsSchema(
630639
{
631640
setupMode: Schema.optionalKey(Schema.Literals(["managed", "existing"])).pipe(
@@ -642,6 +651,7 @@ export const CodexSettings = makeProviderSettingsSchema(
642651
providerSettingsForm: { placeholder: "codex", clearWhenEmpty: "omit" },
643652
}),
644653
),
654+
maintenanceBinaryPath: MaintenanceBinaryPath,
645655
homePath: TrimmedString.pipe(
646656
Schema.withDecodingDefault(Effect.succeed("")),
647657
Schema.annotateKey({
@@ -678,7 +688,7 @@ export const CodexSettings = makeProviderSettingsSchema(
678688
),
679689
},
680690
{
681-
order: ["binaryPath", "homePath", "shadowHomePath", "launchArgs"],
691+
order: ["binaryPath", "maintenanceBinaryPath", "homePath", "shadowHomePath", "launchArgs"],
682692
},
683693
);
684694
export type CodexSettings = typeof CodexSettings.Type;
@@ -718,6 +728,7 @@ export const ClaudeSettings = makeProviderSettingsSchema(
718728
providerSettingsForm: { placeholder: "claude", clearWhenEmpty: "omit" },
719729
}),
720730
),
731+
maintenanceBinaryPath: MaintenanceBinaryPath,
721732
homePath: TrimmedString.pipe(
722733
Schema.withDecodingDefault(Effect.succeed("")),
723734
Schema.annotateKey({
@@ -771,7 +782,14 @@ export const ClaudeSettings = makeProviderSettingsSchema(
771782
),
772783
},
773784
{
774-
order: ["binaryPath", "homePath", "autoCompactWindow", "idleCompaction", "launchArgs"],
785+
order: [
786+
"binaryPath",
787+
"maintenanceBinaryPath",
788+
"homePath",
789+
"autoCompactWindow",
790+
"idleCompaction",
791+
"launchArgs",
792+
],
775793
},
776794
);
777795
export type ClaudeSettings = typeof ClaudeSettings.Type;

‎packages/provider-core/src/server/maintenance.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ export interface ProviderMaintenanceCapabilities {
55
readonly provider: ProviderDriverKind;
66
readonly packageName: string | null;
77
readonly update: ProviderMaintenanceCommandAction | null;
8+
/** Selected maintenance CLI version; never replaces the session snapshot version. */
9+
readonly lookupMaintenanceVersion?: Effect.Effect<string | null>;
810
/** undefined defers to npm; null means the installer could not determine the latest version. */
911
readonly latestVersion?: string | null;
1012
/**

‎packages/provider-core/src/server/maintenanceResolver.test.ts‎

Lines changed: 154 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,74 @@ it.layer(
179179
}),
180180
);
181181

182+
it.effect.each([
183+
{ output: "codex-cli 2.0.0", exitCode: 0, expected: "2.0.0" },
184+
{ output: "2.0.0 (Claude Code)", exitCode: 0, expected: "2.0.0" },
185+
{ output: "unavailable", exitCode: 0, expected: null },
186+
{ output: "codex-cli 2.0.0", exitCode: 1, expected: null },
187+
{ output: "missing executable", exitCode: 0, expected: null, missing: true },
188+
])(
189+
"uses the selected CLI version only for advisories ($output, exit $exitCode)",
190+
(fixture) =>
191+
Effect.gen(function* () {
192+
const tempDir = yield* makeTempDir("t3-maintenance-advisory");
193+
const maintenancePath = NodePath.join(tempDir, ".local", "bin", "native-package-tool");
194+
if (!fixture.missing) writeExecutable(maintenancePath);
195+
let probes = 0;
196+
const capabilities = {
197+
...(yield* resolveProviderMaintenanceCapabilitiesEffect(nativePackageToolUpdate, {
198+
binaryPath: NodePath.join(tempDir, "runtime-launcher"),
199+
maintenanceBinaryPath: maintenancePath,
200+
env: { PATH: "", SELECTED_INSTALL: "fixture" },
201+
}).pipe(
202+
Effect.provideService(
203+
ChildProcessSpawner.ChildProcessSpawner,
204+
stdoutSpawner(
205+
(command, args) => {
206+
expect(command).toBe(maintenancePath);
207+
expect(args).toEqual(["--version"]);
208+
probes++;
209+
return fixture.output;
210+
},
211+
() => fixture.exitCode,
212+
),
213+
),
214+
)),
215+
latestVersion: "3.0.0",
216+
};
217+
const snapshot = {
218+
...installedPackageToolProvider,
219+
version: "3.0.0",
220+
installedVersion: "3.0.0",
221+
};
222+
const enrich = (useMaintenanceVersion: boolean, enableProviderUpdateChecks = true) =>
223+
enrichProviderSnapshotWithVersionAdvisory(snapshot, capabilities, {
224+
enableProviderUpdateChecks,
225+
useMaintenanceVersion,
226+
});
227+
yield* enrich(true, false);
228+
expect(probes).toBe(0);
229+
const verification = yield* enrich(false);
230+
expect(verification.versionAdvisory?.currentVersion).toBe("3.0.0");
231+
expect(probes).toBe(0);
232+
const advisory = yield* enrich(true);
233+
expect(advisory.version).toBe("3.0.0");
234+
expect(advisory.installedVersion).toBe("3.0.0");
235+
expect(advisory.versionAdvisory).toMatchObject({
236+
currentVersion: fixture.expected,
237+
status: fixture.expected ? "behind_latest" : "unknown",
238+
});
239+
expect(probes).toBe(fixture.missing ? 0 : 1);
240+
}).pipe(
241+
Effect.provide(ProviderLatestVersions.layer),
242+
Effect.provideService(
243+
HttpClient.HttpClient,
244+
HttpClient.make(() => Effect.die("fixture latest version must not make an HTTP request")),
245+
),
246+
),
247+
{ skip: windowsHost },
248+
);
249+
182250
it.effect("does not fetch latest provider versions when update checks are disabled", () =>
183251
enrichProviderSnapshotWithVersionAdvisory(
184252
{ ...installedPackageToolProvider, installedVersion: "1.1.0" },
@@ -869,29 +937,100 @@ it.layer(
869937
{ skip: !symlinksSupported || windowsHost },
870938
);
871939

872-
it.effect.skipIf(windowsHost)(
873-
"switches to bun updates when the resolved binary lives in bun's global bin",
940+
it.effect.skipIf(windowsHost || !symlinksSupported)(
941+
"binds bun updates to the selected global installation and rejects unproven ownership",
874942
() =>
875943
Effect.gen(function* () {
876944
const tempDir = yield* makeTempDir("t3-bun-capabilities");
877-
const bunBinDir = NodePath.join(tempDir, ".bun", "bin");
878-
writeExecutable(NodePath.join(bunBinDir, "package-tool"));
879-
880-
const capabilities = yield* resolveProviderMaintenanceCapabilitiesEffect(
881-
packageToolUpdate,
882-
{
883-
binaryPath: "package-tool",
884-
env: { PATH: bunBinDir },
885-
},
886-
).pipe(
887-
Effect.provideService(HostProcess.Platform, "darwin"),
888-
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, noSpawn),
945+
const bunBinDir = NodePath.join(tempDir, "selected", ".bun", "bin");
946+
const globalDir = NodePath.join(tempDir, "selected", ".bun", "install", "global");
947+
const packagePath = NodePath.join(
948+
globalDir,
949+
"node_modules",
950+
"@example",
951+
"package-tool",
952+
"bin",
953+
"package-tool.js",
889954
);
955+
writeExecutable(packagePath);
956+
const maintenancePath = NodePath.join(bunBinDir, "package-tool");
957+
NodeFS.mkdirSync(bunBinDir, { recursive: true });
958+
NodeFS.symlinkSync(packagePath, maintenancePath);
959+
const runtimePath = NodePath.join(tempDir, "default", ".bun", "bin", "package-tool");
960+
writeExecutable(runtimePath);
961+
const env = {
962+
PATH: NodePath.dirname(runtimePath),
963+
BUN_INSTALL_GLOBAL_DIR: NodePath.join(tempDir, "default", ".bun", "install", "global"),
964+
BUN_INSTALL_BIN: NodePath.dirname(runtimePath),
965+
};
966+
967+
const resolve = () =>
968+
resolveProviderMaintenanceCapabilitiesEffect(packageToolUpdate, {
969+
binaryPath: runtimePath,
970+
maintenanceBinaryPath: maintenancePath,
971+
env,
972+
}).pipe(
973+
Effect.provideService(HostProcess.Platform, "darwin"),
974+
Effect.provideService(HostProcess.Environment, env),
975+
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, noSpawn),
976+
);
890977

978+
const capabilities = yield* resolve();
891979
expect(capabilities.update).toMatchObject({
892980
command: "bun i -g @example/package-tool@latest",
893-
lockKey: "bun-global",
981+
lockKey: `bun-global:${normalizeCommandPath(globalDir)}`,
982+
env: { BUN_INSTALL_GLOBAL_DIR: globalDir, BUN_INSTALL_BIN: bunBinDir },
983+
});
984+
expect(makeTargetedProviderUpdateAction(capabilities, "2.0.0")).toMatchObject({
985+
args: ["i", "-g", "@example/[email protected]"],
986+
env: capabilities.update?.env,
987+
});
988+
989+
for (const target of [
990+
NodePath.join(globalDir, "node_modules", "@example", "other-package", "bin", "tool"),
991+
NodePath.join(
992+
tempDir,
993+
"project",
994+
"node_modules",
995+
"@example",
996+
"package-tool",
997+
"bin",
998+
"tool",
999+
),
1000+
maintenancePath,
1001+
]) {
1002+
NodeFS.unlinkSync(maintenancePath);
1003+
writeExecutable(target);
1004+
if (target !== maintenancePath) NodeFS.symlinkSync(target, maintenancePath);
1005+
expect(yield* resolve()).toMatchObject({ update: null, installPath: target });
1006+
}
1007+
}),
1008+
);
1009+
1010+
it.effect.skipIf(windowsHost)(
1011+
"updates the explicit maintenance installation while keeping the runtime wrapper separate",
1012+
() =>
1013+
Effect.gen(function* () {
1014+
const tempDir = yield* makeTempDir("t3-wrapper-maintenance");
1015+
const wrapper = NodePath.join(tempDir, "agentfleet-launcher");
1016+
const nativePath = NodePath.join(tempDir, ".local", "bin", "native-package-tool");
1017+
writeExecutable(wrapper);
1018+
writeExecutable(nativePath);
1019+
const resolve = (maintenanceBinaryPath: string) =>
1020+
resolveProviderMaintenanceCapabilitiesEffect(nativePackageToolUpdate, {
1021+
binaryPath: wrapper,
1022+
maintenanceBinaryPath,
1023+
env: { PATH: "" },
1024+
}).pipe(
1025+
Effect.provideService(HostProcess.Platform, "darwin"),
1026+
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, noSpawn),
1027+
);
1028+
expect((yield* resolve(nativePath)).update).toMatchObject({
1029+
executable: nativePath,
1030+
args: ["update"],
8941031
});
1032+
expect((yield* resolve(NodePath.join(tempDir, "missing"))).update).toBeNull();
1033+
expect((yield* resolve(" ")).update?.executable).toBe(wrapper);
8951034
}),
8961035
);
8971036

0 commit comments

Comments
 (0)