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, 19:45 UTC
fix(server): standalone Codex is checked against the native release channel (#34910)
Julius Marminge committed
Nov 12, 2026 at 00:08 UTC
5fb9ee5c424f230f554139f4a80de378062d2ac3
2 files changed
+114
-2
apps/server/src/provider/Drivers/CodexDriver.test.ts
+81
@@ -481,6 +481,87 @@ it.layer(layerTest)("CodexDriver", (it) => {
481
}).pipe(Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, noSpawn), Effect.scoped),
482
);
483
484
+ // regression: #23937 `codex update` installs the native channel's release, which can lag npm.
485
+ it.effect.skipIf(windowsHost)(
486
+ "does not advertise npm's latest Codex to a standalone install",
487
+ () =>
488
+ Effect.gen(function* () {
489
+ const fs = yield* FileSystem.FileSystem;
490
+ const tempDir = yield* fs
491
+ .makeTempDirectoryScoped({ prefix: "t3-codex-driver-" })
492
+ .pipe(Effect.flatMap((directory) => fs.realPath(directory)));
493
+ const home = NodePath.join(tempDir, "codex-home");
494
+ const binaryPath = NodePath.join(home, "packages", "standalone", "current", "bin", "codex");
495
+ yield* fs.makeDirectory(NodePath.dirname(binaryPath), { recursive: true });
496
+ yield* fs.writeFileString(binaryPath, "#!/bin/sh\n");
497
+ yield* fs.chmod(binaryPath, 0o755);
498
+ // npm's latest tag is ahead of the native channel, as during a staggered release.
499
+ const npmView = ChildProcessSpawner.make((command) => {
500
+ if (!ChildProcess.isStandardCommand(command) || command.args[0] !== "view") {
501
+ return Effect.die("Version lookup must not run a provider or updater");
502
+ }
503
+ return Effect.succeed(
504
+ ChildProcessSpawner.makeHandle({
505
+ pid: ChildProcessSpawner.ProcessId(1),
506
+ exitCode: Effect.succeed(ChildProcessSpawner.ExitCode(0)),
507
+ isRunning: Effect.succeed(false),
508
+ kill: () => Effect.void,
509
+ unref: Effect.succeed(Effect.void),
510
+ stdin: Sink.drain,
511
+ stdout: Stream.encodeText(Stream.make('"0.164.0"')),
512
+ stderr: Stream.empty,
513
+ all: Stream.empty,
514
+ getInputFd: () => Sink.drain,
515
+ getOutputFd: () => Stream.empty,
516
+ }),
517
+ );
518
+ });
519
+ const instance = yield* CodexDriver.create({
520
+ instanceId: ProviderInstanceId.make("codex-standalone-latest"),
521
+ displayName: "Codex standalone",
522
+ enabled: false,
523
+ environment: [],
524
+ config: { ...CodexDriver.defaultConfig(), binaryPath, homePath: home },
525
+ }).pipe(
526
+ Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, npmView),
527
+ Effect.provideService(
528
+ HttpClient.HttpClient,
529
+ HttpClient.make((request) =>
530
+ Effect.succeed(
531
+ HttpClientResponse.fromWeb(
532
+ request,
533
+ request.url === "https://releases.openai.com/codex/channels/latest"
534
+ ? Response.json({ tag_name: "rust-v0.163.0", assets: [] })
535
+ : new Response(null, { status: 404 }),
536
+ ),
537
+ ),
538
+ ),
539
+ ),
540
+ );
541
+ const capabilities = yield* instance.snapshot.resolveMaintenance();
542
+ expect(capabilities.update?.lockKey).toBe("codex-native");
543
+
544
+ const latestVersion = yield* resolveLatestProviderVersion(capabilities).pipe(
545
+ Effect.provideServiceEffect(
546
+ ProviderLatestVersions.ProviderLatestVersions,
547
+ ProviderLatestVersions.make(),
548
+ ),
549
+ );
550
+ expect(latestVersion).toBe("0.163.0");
551
+ expect(
552
+ createProviderVersionAdvisory({
553
+ driver: CodexDriver.driverKind,
554
+ currentVersion: "0.163.0",
555
+ latestVersion,
556
+ maintenanceCapabilities: capabilities,
557
+ }).status,
558
+ ).not.toBe("behind_latest");
559
+ }).pipe(
560
+ Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, noSpawn),
561
+ Effect.scoped,
562
+ ),
563
+ );
564
+
565
it.effect("uses each instance's environment CODEX_HOME for continuation", () =>
566
Effect.gen(function* () {
567
const fs = yield* FileSystem.FileSystem;
apps/server/src/provider/Drivers/CodexDriver.ts
+33
-2
@@ -5,10 +5,11 @@ import type * as Signature from "effect/crypto/Signature";
5
import * as Duration from "effect/Duration";
6
import * as Effect from "effect/Effect";
7
import * as FileSystem from "effect/FileSystem";
8
+import * as Option from "effect/Option";
9
import * as Path from "effect/Path";
10
import * as Schema from "effect/Schema";
11
import * as Stream from "effect/Stream";
11
-import { HttpClient } from "effect/http";
12
+import { HttpClient, HttpClientResponse } from "effect/http";
13
import { ChildProcessSpawner } from "effect/process";
14
15
import type * as CodexUsageHistory from "../../usage/CodexUsageHistory.ts";
@@ -42,6 +43,7 @@ import {
43
makeCachedProviderMaintenanceResolution,
44
makePackageManagedProviderMaintenanceResolver,
45
resolveProviderMaintenanceCapabilitiesEffect,
46
+ type ProviderMaintenanceCapabilities,
47
} from "@t3tools/provider-core/server/maintenanceResolver";
48
import {
49
haveProviderSnapshotSettingsChanged,
@@ -98,6 +100,31 @@ function makeCodexMaintenanceResolver(sharedHomePath: string) {
100
});
101
}
102
103
+// `codex update` installs this channel's release, which can lag npm's latest tag.
104
+const CODEX_NATIVE_CHANNEL = "https://releases.openai.com/codex/channels/latest";
105
+const CodexNativeRelease = Schema.Struct({ tag_name: Schema.String });
106
+
107
+function withCodexNativeLatestVersion(
108
+ capabilities: ProviderMaintenanceCapabilities,
109
+ http: HttpClient.HttpClient,
110
+): ProviderMaintenanceCapabilities {
111
+ if (capabilities.update?.lockKey !== `${DRIVER_KIND}-native`) return capabilities;
112
+ return {
113
+ ...capabilities,
114
+ latestVersion: null,
115
+ latestVersionCacheKey: CODEX_NATIVE_CHANNEL,
116
+ lookupLatestVersion: http.get(CODEX_NATIVE_CHANNEL).pipe(
117
+ Effect.flatMap(HttpClientResponse.filterStatusOk),
118
+ Effect.flatMap((response) => response.json),
119
+ Effect.flatMap(Schema.decodeUnknownEffect(CodexNativeRelease)),
120
+ Effect.map((release) => /^rust-v(\d+\.\d+\.\d+)$/.exec(release.tag_name)?.[1] ?? null),
121
+ Effect.timeoutOption("4 seconds"),
122
+ Effect.map(Option.getOrNull),
123
+ Effect.orElseSucceed(() => null),
124
+ ),
125
+ };
126
+}
127
+
128
export type CodexDriverEnv =
129
| CodexAdapterV2DriverEnv
130
| ProviderHost.ProviderHost
@@ -192,7 +219,7 @@ export const CodexDriver: ProviderDriver<
219
binaryPath: expandHomePath(config.binaryPath, yield* HostProcess.HomeDirectory),
220
homePath: homeLayout.effectiveHomePath ?? "",
221
} satisfies CodexSettings;
195
- const resolveMaintenance = yield* makeCachedProviderMaintenanceResolution(
222
+ const resolveInstallation = yield* makeCachedProviderMaintenanceResolution(
223
resolveProviderMaintenanceCapabilitiesEffect(
224
makeCodexMaintenanceResolver(homeLayout.sharedHomePath),
225
{
@@ -205,6 +232,10 @@ export const CodexDriver: ProviderDriver<
232
Effect.provideService(Path.Path, pathService),
233
),
234
);
235
+ const resolveMaintenance: typeof resolveInstallation = (options) =>
236
+ resolveInstallation(options).pipe(
237
+ Effect.map((capabilities) => withCodexNativeLatestVersion(capabilities, httpClient)),
238
+ );
239
240
const orchestrationAdapter = yield* createCodexAdapterV2(
241
{