Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

CodexDriver.test.ts

598 lines24.0 KB

1import * as CodexInstallation from "../CodexInstallation.ts";
2import * as ServerSecretStore from "../../auth/ServerSecretStore.ts";
3import * as ServerEnvironment from "../../environment/ServerEnvironment.ts";
4// @effect-diagnostics nodeBuiltinImport:off
5import * as NodeServices from "@effect/platform-node/NodeServices";
6import * as NodeOS from "node:os";
7import * as NodePath from "node:path";
8import { expect, it } from "@effect/vitest";
9import { EnvironmentId, ProviderInstanceId, ProviderSessionId, ThreadId } from "@t3tools/contracts";
10import { HostProcessPlatform } from "@t3tools/shared/hostProcess";
11import * as Effect from "effect/Effect";
12import * as Deferred from "effect/Deferred";
13import * as Fiber from "effect/Fiber";
14import * as FileSystem from "effect/FileSystem";
15import * as Layer from "effect/Layer";
16import * as Option from "effect/Option";
17import * as PlatformError from "effect/PlatformError";
18import * as Schema from "effect/Schema";
19import * as Sink from "effect/Sink";
20import * as Stream from "effect/Stream";
21import { HttpClient, HttpClientResponse } from "effect/http";
22import * as ChildProcess from "effect/process/ChildProcess";
23import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
24​
25import * as BackgroundPolicy from "../../background/BackgroundPolicy.ts";
26import * as ServerConfig from "../../config.ts";
27import * as ServerSettings from "../../serverSettings.ts";
28import * as ResetCreditCoordinator from "../resetCreditCoordinator.ts";
29import * as ProviderLatestVersions from "@t3tools/provider-core/server/ProviderLatestVersions";
30import * as McpProviderSessions from "@t3tools/provider-core/server/McpProviderSessions";
31import * as ProviderEventLoggers from "@t3tools/provider-core/server/ProviderEventLoggers";
32import * as ModelManifest from "../ModelManifest.ts";
33import {
34 createProviderVersionAdvisory,
35 resolveLatestProviderVersion,
36} from "@t3tools/provider-core/server/maintenanceResolver";
37import { CodexDriver } from "./CodexDriver.ts";
38import * as CodexAdapterV2 from "../../orchestration-v2/Adapters/CodexAdapterV2.ts";
39import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
40import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
41import * as ProviderCredentialStore from "../ProviderCredentialStore.ts";
42import * as ProviderHostLive from "../ProviderHostLive.ts";
43​
44const layerDeps = ServerConfig.layerTest(process.cwd(), {
45 prefix: "t3-codex-driver-maintenance-",
46}).pipe(
47 Layer.provideMerge(NodeServices.layer),
48 Layer.provideMerge(IdAllocator.layer),
49 Layer.provideMerge(McpProviderSessions.layer),
50 Layer.provideMerge(
51 Layer.mock(CodexAdapterV2.CodexAppServerClientFactory)({
52 open: () => Effect.die("Maintenance resolution must not open a Codex session"),
53 }),
54 ),
55 Layer.provideMerge(
56 Layer.mock(CodexInstallation.CodexInstallation)({
57 managedDirectory: "unused-managed-installation",
58 }),
59 ),
60 Layer.provideMerge(Layer.mock(ServerSecretStore.ServerSecretStore)({})),
61 Layer.provideMerge(
62 Layer.succeed(ServerEnvironment.ServerEnvironmentIdentity, {
63 getEnvironmentId: Effect.succeed(EnvironmentId.make("00000000-0000-4000-8000-000000000001")),
64 }),
65 ),
66 Layer.provideMerge(ServerSettings.layerTest()),
67 Layer.provideMerge(ModelManifest.layerTest),
68 Layer.provideMerge(ResetCreditCoordinator.layerTest),
69 Layer.provideMerge(
70 Layer.mock(BackgroundPolicy.BackgroundPolicy)({
71 shouldRunScopeWork: () => Effect.succeed(false),
72 }),
73 ),
74 Layer.provideMerge(
75 Layer.succeed(
76 ProviderEventLoggers.ProviderEventLoggers,
77 ProviderEventLoggers.NoOpProviderEventLoggers,
78 ),
79 ),
80 Layer.provideMerge(ProviderLatestVersions.layer),
81 Layer.provideMerge(
82 Layer.succeed(
83 HttpClient.HttpClient,
84 HttpClient.make(() => Effect.die("Disabled Codex must not make an HTTP request")),
85 ),
86 ),
87);
88const layerTest = ProviderHostLive.layer.pipe(Layer.provideMerge(layerDeps));
89​
90// The `#!/bin/sh` stub below cannot be resolved as an executable on Windows.
91const windowsHost = HostProcessPlatform.defaultValue() === "win32";
92​
93const noSpawn = ChildProcessSpawner.make(() =>
94 Effect.die("Disabled Codex must not spawn a process"),
95);
96const encodeCredentials = Schema.encodeEffect(Schema.fromJsonString(Schema.Unknown));
97​
98it.layer(layerTest)("CodexDriver", (it) => {
99 it.effect("disconnect refreshes a restored managed account while its auth flow is idle", () =>
100 Effect.gen(function* () {
101 const instanceId = ProviderInstanceId.make("restored-managed-account");
102 const credentials = new Map<string, Uint8Array>();
103 const secrets = ServerSecretStore.ServerSecretStore.of({
104 get: (key) => Effect.sync(() => Option.fromUndefinedOr(credentials.get(key))),
105 set: (key, value) =>
106 Effect.sync(() => {
107 credentials.set(key, value);
108 }),
109 remove: (key) =>
110 Effect.sync(() => {
111 credentials.delete(key);
112 }),
113 create: () => Effect.die("unused"),
114 getOrCreateRandom: () => Effect.die("unused"),
115 });
116 yield* Effect.gen(function* () {
117 const store = yield* ProviderCredentialStore.make("codex-chatgpt", instanceId);
118 const json = yield* encodeCredentials({
119 clientId: "oaiapp_test",
120 accessToken: "dummy-owned-access",
121 refreshToken: "dummy-refresh",
122 expiresAt: Number.MAX_SAFE_INTEGER,
123 earliestRefreshAt: null,
124 scopes: ["chatgpt.tokens.use.direct"],
125 subject: "test-user",
126 email: "account@example.test",
127 });
128 yield* store.set(new TextEncoder().encode(json));
129 const executable = {
130 executablePath: "/user/bin/codex",
131 managedVersionDirectory: null,
132 source: "local" as const,
133 version: "0.156.1",
134 };
135 const installation = yield* CodexInstallation.CodexInstallation;
136 const serverConfig = yield* ServerConfig.ServerConfig;
137 const sharedHome = NodePath.join(serverConfig.stateDir, "shared-codex-home");
138 const launches: Array<
139 Parameters<CodexAdapterV2.CodexAppServerClientFactoryShape["open"]>[0]
140 > = [];
141 // Sign-out interrupts an account check that is still resolving the runtime.
142 // Interrupt the two startup checks that way (one is the sign-in listener's);
143 // the disconnect below must still refresh.
144 let interruptedChecks = 0;
145 const startupChecksInterrupted = yield* Deferred.make<void>();
146 const acquire = () =>
147 Effect.suspend(() => {
148 if (interruptedChecks === 2) return Effect.succeed(executable);
149 interruptedChecks += 1;
150 return (
151 interruptedChecks === 2
152 ? Deferred.succeed(startupChecksInterrupted, undefined)
153 : Effect.void
154 ).pipe(Effect.andThen(Effect.interrupt));
155 });
156 const instance = yield* CodexDriver.create({
157 instanceId,
158 displayName: "Restored account",
159 enabled: true,
160 environment: [{ name: "OPENAI_API_KEY", value: "ambient-key", sensitive: true }],
161 config: { ...CodexDriver.defaultConfig(), setupMode: "managed", homePath: sharedHome },
162 }).pipe(
163 Effect.provideService(
164 CodexAdapterV2.CodexAppServerClientFactory,
165 CodexAdapterV2.CodexAppServerClientFactory.of({
166 open: (launch) =>
167 Effect.sync(() => launches.push(launch)).pipe(
168 Effect.andThen(Effect.die("The fixture stops after recording the launch")),
169 ),
170 }),
171 ),
172 Effect.provideService(
173 CodexInstallation.CodexInstallation,
174 CodexInstallation.CodexInstallation.of({
175 ...installation,
176 managedDirectory: "unused-managed-installation",
177 resolve: () => Effect.succeed(executable),
178 acquire,
179 }),
180 ),
181 Effect.provideService(
182 ChildProcessSpawner.ChildProcessSpawner,
183 ChildProcessSpawner.make(() =>
184 Effect.fail(
185 PlatformError.badArgument({
186 module: "ChildProcessSpawner",
187 method: "spawn",
188 description: "The fixture app-server is unavailable",
189 }),
190 ),
191 ),
192 ),
193 );
194 const observedAccount = yield* Deferred.make<void>();
195 const disconnected = yield* instance.snapshot.streamChanges.pipe(
196 Stream.tap((provider) =>
197 provider.auth.status === "authenticated"
198 ? Deferred.succeed(observedAccount, undefined).pipe(Effect.asVoid)
199 : Effect.void,
200 ),
201 Stream.filter((provider) => provider.auth.status === "unauthenticated"),
202 Stream.runHead,
203 Effect.forkScoped,
204 );
205 yield* Deferred.await(startupChecksInterrupted);
206 const restored = yield* instance.snapshot.refresh;
207 expect(restored.auth.email).toBe("account@example.test");
208 expect(restored.runtimePaths?.homePath).toBe(sharedHome);
209 expect(restored.runtimePaths?.shadowHomePath).toContain(
210 `providers/codex/${instanceId}/shadow`,
211 );
212 yield* Deferred.await(observedAccount);
213 // Sessions launch the T3-installed Codex with the account's token, not ambient credentials.
214 const threadId = ThreadId.make("managed-account-thread");
215 yield* instance.orchestrationAdapter
216 .openSession({
217 threadId,
218 providerSessionId: ProviderSessionId.make("managed-account-session"),
219 modelSelection: { instanceId, model: "gpt-5.4" },
220 runtimePolicy: ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
221 runtimeMode: "full-access",
222 interactionMode: "default",
223 cwd: serverConfig.stateDir,
224 }),
225 })
226 .pipe(Effect.scoped, Effect.exit);
227 expect(launches).toHaveLength(1);
228 const launch = launches[0]!;
229 expect(launch.settings.binaryPath).toBe(executable.executablePath);
230 expect(launch.settings.launchArgs).toContain("openai_token_sharing");
231 expect(launch.environment.ACCESS_TOKEN).toBe("dummy-owned-access");
232 expect(launch.environment.OPENAI_API_KEY).toBeUndefined();
233 expect(launch.environment.CODEX_HOME).toBe(launch.settings.homePath);
234 const before = yield* instance.auth!.subscribe("test-owner").pipe(Stream.runHead);
235 expect(Option.getOrThrow(before).phase).toBe("idle");
236 yield* instance.auth!.logout(Effect.void);
237 const after = Option.getOrThrow(yield* Fiber.join(disconnected));
238 expect(after.auth.status).toBe("unauthenticated");
239 expect(after.auth.email).toBeUndefined();
240 expect(after.installed).toBe(true);
241 expect(after.models).toEqual([]);
242 expect(Option.isNone(yield* store.get)).toBe(true);
243 }).pipe(
244 Effect.provideService(ServerSecretStore.ServerSecretStore, secrets),
245 Effect.provideService(
246 HttpClient.HttpClient,
247 HttpClient.make((request) =>
248 Effect.sync(() => {
249 expect([
250 "https://auth.openai.com/.well-known/openid-configuration",
251 "https://auth.openai.com/revoke",
252 "https://api.openai.com/v1/models",
253 ]).toContain(request.url);
254 if (request.url.endsWith("/models"))
255 return HttpClientResponse.fromWeb(request, Response.json({ models: [] }));
256 return HttpClientResponse.fromWeb(
257 request,
258 request.url.endsWith("/revoke")
259 ? new Response(null, { status: 200 })
260 : Response.json({
261 issuer: "https://auth.openai.com",
262 authorization_endpoint: "https://auth.openai.com/api/accounts/authorize",
263 token_endpoint: "https://auth.openai.com/api/accounts/oauth/token",
264 jwks_uri: "https://auth.openai.com/jwks",
265 revocation_endpoint: "https://auth.openai.com/revoke",
266 }),
267 );
268 }),
269 ),
270 ),
271 );
272 }).pipe(Effect.scoped),
273 );
274​
275 it.effect.skipIf(windowsHost)(
276 "runs the standalone updater against the shared home, not the shadow home",
277 () =>
278 Effect.gen(function* () {
279 const fs = yield* FileSystem.FileSystem;
280 const tempDir = yield* fs
281 .makeTempDirectoryScoped({ prefix: "t3-codex-driver-" })
282 .pipe(Effect.flatMap((directory) => fs.realPath(directory)));
283 const sharedHome = NodePath.join(tempDir, "codex-home");
284 const shadowHome = NodePath.join(tempDir, "codex-shadow");
285 const binaryPath = NodePath.join(sharedHome, "packages", "standalone", "bin", "codex");
286 yield* fs.makeDirectory(NodePath.dirname(binaryPath), { recursive: true });
287 yield* fs.writeFileString(binaryPath, "#!/bin/sh\n");
288 yield* fs.chmod(binaryPath, 0o755);
289​
290 const instance = yield* CodexDriver.create({
291 instanceId: ProviderInstanceId.make("codex-shadow"),
292 displayName: "Codex test",
293 enabled: false,
294 environment: [],
295 config: {
296 ...CodexDriver.defaultConfig(),
297 binaryPath,
298 homePath: sharedHome,
299 shadowHomePath: shadowHome,
300 },
301 });
302​
303 const capabilities = yield* instance.snapshot.resolveMaintenance();
304 expect(capabilities.update).toMatchObject({
305 executable: binaryPath,
306 args: ["update"],
307 lockKey: "codex-native",
308 env: { CODEX_HOME: sharedHome },
309 });
310 }).pipe(
311 Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, noSpawn),
312 Effect.scoped,
313 ),
314 );
315​
316 it.effect("stays manual-only when the configured executable does not exist", () =>
317 Effect.gen(function* () {
318 const instance = yield* CodexDriver.create({
319 instanceId: ProviderInstanceId.make("codex-missing"),
320 displayName: "Codex test",
321 enabled: false,
322 environment: [],
323 config: {
324 ...CodexDriver.defaultConfig(),
325 binaryPath: NodePath.join(NodeOS.tmpdir(), "t3-codex-missing", "codex"),
326 },
327 });
328 expect((yield* instance.snapshot.resolveMaintenance()).update).toBeNull();
329 }).pipe(Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, noSpawn), Effect.scoped),
330 );
331​
332 for (const fixture of [
333 {
334 name: "leaves mise npm-backend installations manual-only",
335 installSegments: ["mise", "installs", "npm-openai-codex", "0.110.0"],
336 npmOwned: false,
337 },
338 {
339 name: "leaves mise tool aliases backed by npm manual-only",
340 installSegments: ["mise", "installs", "codex", "0.110.0"],
341 npmOwned: false,
342 },
343 {
344 name: "keeps npm updates for globals in a mise Node installation",
345 installSegments: ["mise", "installs", "node", "24.0.0"],
346 npmOwned: true,
347 },
348 {
349 name: "keeps npm updates for ordinary global installations",
350 installSegments: ["npm-global"],
351 npmOwned: true,
352 },
353 ] as const) {
354 it.effect.skipIf(windowsHost)(fixture.name, () =>
355 Effect.gen(function* () {
356 const fs = yield* FileSystem.FileSystem;
357 const tempDir = yield* fs
358 .makeTempDirectoryScoped({ prefix: "t3-codex-installer-" })
359 .pipe(Effect.flatMap((directory) => fs.realPath(directory)));
360 const installPath = NodePath.join(tempDir, ...fixture.installSegments);
361 const realBinaryPath = NodePath.join(
362 installPath,
363 "lib",
364 "node_modules",
365 "@openai",
366 "codex",
367 "bin",
368 "codex.js",
369 );
370 const binaryPath = NodePath.join(tempDir, "bin", "codex");
371 yield* fs.makeDirectory(NodePath.dirname(realBinaryPath), { recursive: true });
372 yield* fs.makeDirectory(NodePath.dirname(binaryPath), { recursive: true });
373 yield* fs.writeFileString(realBinaryPath, "#!/bin/sh\n");
374 yield* fs.chmod(realBinaryPath, 0o755);
375 yield* fs.symlink(realBinaryPath, binaryPath);
376​
377 const instance = yield* CodexDriver.create({
378 instanceId: ProviderInstanceId.make("codex-installer"),
379 displayName: "Codex installer test",
380 enabled: false,
381 environment: [],
382 config: {
383 ...CodexDriver.defaultConfig(),
384 binaryPath,
385 homePath: NodePath.join(tempDir, "codex-home"),
386 },
387 });
388​
389 const update = (yield* instance.snapshot.resolveMaintenance()).update;
390 if (fixture.npmOwned) {
391 expect(update).toMatchObject({
392 executable: "npm",
393 args: [
394 "install",
395 "-g",
396 "--prefix",
397 installPath,
398 "--allow-scripts=@openai/codex",
399 "@openai/codex@latest",
400 ],
401 });
402 } else {
403 expect(update).toBeNull();
404 }
405 }).pipe(
406 Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, noSpawn),
407 Effect.scoped,
408 ),
409 );
410 }
411​
412 for (const layout of ["direct", "wrapper"] as const) {
413 it.effect.skipIf(windowsHost)(`leaves a mise ${layout} installation manual-only`, () =>
414 Effect.gen(function* () {
415 const fs = yield* FileSystem.FileSystem;
416 const tempDir = yield* fs
417 .makeTempDirectoryScoped({ prefix: `t3-codex-mise-${layout}-` })
418 .pipe(Effect.flatMap((directory) => fs.realPath(directory)));
419 const binaryPath =
420 layout === "direct"
421 ? NodePath.join(tempDir, "mise", "installs", "codex", "0.110.0", "codex")
422 : NodePath.join(tempDir, "omarchy", "bin", "codex");
423 yield* fs.makeDirectory(NodePath.dirname(binaryPath), { recursive: true });
424 yield* fs.writeFileString(
425 binaryPath,
426 layout === "direct"
427 ? "#!/bin/sh\n"
428 : '#!/bin/sh\nmise use -g --quiet "codex" || exit 1\nexec mise x "codex" -- "codex" "$@"\n',
429 );
430 yield* fs.chmod(binaryPath, 0o755);
431​
432 const instance = yield* CodexDriver.create({
433 instanceId: ProviderInstanceId.make(`codex-mise-${layout}`),
434 displayName: "Codex mise test",
435 enabled: false,
436 environment: [],
437 config: {
438 ...CodexDriver.defaultConfig(),
439 binaryPath,
440 homePath: NodePath.join(tempDir, "codex-home"),
441 },
442 });
443​
444 expect((yield* instance.snapshot.resolveMaintenance()).update).toBeNull();
445 }).pipe(
446 Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, noSpawn),
447 Effect.scoped,
448 ),
449 );
450 }
451​
452 it.effect.each([
453 {
454 name: "conventional shim",
455 dataRoot: "mise",
456 commandName: "codex",
457 version: "0.153.4",
458 nodeFirst: false,
459 },
460 {
461 name: "custom data directory",
462 dataRoot: "custom-tool-data",
463 commandName: "codex",
464 version: "0.153.4",
465 nodeFirst: false,
466 },
467 {
468 name: "renamed configured command",
469 dataRoot: "mise",
470 commandName: "custom-codex",
471 version: "0.153.4",
472 nodeFirst: false,
473 },
474 {
475 name: "outdated provider",
476 dataRoot: "mise",
477 commandName: "codex",
478 version: "0.153.3",
479 nodeFirst: false,
480 },
481 {
482 name: "npm before shim",
483 dataRoot: "mise",
484 commandName: "codex",
485 version: "0.153.4",
486 nodeFirst: true,
487 },
488 ])(
489 "does not mistake Homebrew mise for Codex's installer: $name",
490 (fixture) =>
491 Effect.gen(function* () {
492 const fs = yield* FileSystem.FileSystem;
493 const tempDir = yield* fs
494 .makeTempDirectoryScoped({ prefix: "t3-codex-mise-shim-" })
495 .pipe(Effect.flatMap((directory) => fs.realPath(directory)));
496 const brewPrefix = NodePath.join(tempDir, "homebrew");
497 const brewPath = NodePath.join(brewPrefix, "bin", "brew");
498 const misePath = NodePath.join(brewPrefix, "Cellar", "mise", "2026.9.1", "bin", "mise");
499 const shimDir = NodePath.join(tempDir, fixture.dataRoot, "shims");
500 const npmPrefix = NodePath.join(tempDir, "mise", "installs", "node", "24.13.0");
501 const npmBin = NodePath.join(npmPrefix, "bin");
502 const npmEntry = NodePath.join(
503 npmPrefix,
504 "lib",
505 "node_modules",
506 "@openai",
507 "codex",
508 "bin",
509 "codex.js",
510 );
511 for (const file of [brewPath, misePath, npmEntry]) {
512 yield* fs.makeDirectory(NodePath.dirname(file), { recursive: true });
513 yield* fs.writeFileString(file, "#!/bin/sh\n");
514 yield* fs.chmod(file, 0o755);
515 }
516 yield* fs.makeDirectory(shimDir, { recursive: true });
517 yield* fs.makeDirectory(npmBin, { recursive: true });
518 yield* fs.symlink(misePath, NodePath.join(shimDir, fixture.commandName));
519 yield* fs.symlink(npmEntry, NodePath.join(npmBin, fixture.commandName));
520 const lookupPath = [
521 ...(fixture.nodeFirst ? [npmBin, shimDir] : [shimDir, npmBin]),
522 NodePath.dirname(brewPath),
523 ].join(NodePath.delimiter);
524 const probes: Array<ReadonlyArray<string>> = [];
525 const metadataSpawner = ChildProcessSpawner.make((command) => {
526 if (!ChildProcess.isStandardCommand(command) || command.command !== brewPath) {
527 return Effect.die("Provider resolution must not execute a provider or updater");
528 }
529 probes.push(command.args);
530 const stdout =
531 command.args[0] === "--prefix"
532 ? brewPrefix
533 : JSON.stringify({ formulae: [{ versions: { stable: "2026.9.1" } }] });
534 return Effect.succeed(
535 ChildProcessSpawner.makeHandle({
536 pid: ChildProcessSpawner.ProcessId(1),
537 exitCode: Effect.succeed(ChildProcessSpawner.ExitCode(0)),
538 isRunning: Effect.succeed(false),
539 kill: () => Effect.void,
540 unref: Effect.succeed(Effect.void),
541 stdin: Sink.drain,
542 stdout: Stream.encodeText(Stream.make(stdout)),
543 stderr: Stream.empty,
544 all: Stream.empty,
545 getInputFd: () => Sink.drain,
546 getOutputFd: () => Stream.empty,
547 }),
548 );
549 });
550 const instance = yield* CodexDriver.create({
551 instanceId: ProviderInstanceId.make("codex-mise-shim"),
552 displayName: "Codex shim test",
553 enabled: false,
554 environment: [{ name: "PATH", value: lookupPath, sensitive: false }],
555 config: {
556 ...CodexDriver.defaultConfig(),
557 binaryPath: fixture.commandName,
558 homePath: NodePath.join(tempDir, "codex-home"),
559 },
560 }).pipe(Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, metadataSpawner));
561 const capabilities = yield* instance.snapshot.resolveMaintenance();
562 const latestVersion = yield* resolveLatestProviderVersion(capabilities).pipe(
563 Effect.provideServiceEffect(
564 ProviderLatestVersions.ProviderLatestVersions,
565 ProviderLatestVersions.make([["@openai/codex", "0.153.4"]]),
566 ),
567 );
568 expect(probes).toEqual([]);
569 expect(latestVersion).toBe("0.153.4");
570 expect(
571 createProviderVersionAdvisory({
572 driver: CodexDriver.driverKind,
573 currentVersion: fixture.version,
574 latestVersion,
575 maintenanceCapabilities: capabilities,
576 }),
577 ).toMatchObject({
578 status: fixture.version === "0.153.4" ? "current" : "behind_latest",
579 currentVersion: fixture.version,
580 latestVersion: "0.153.4",
581 canUpdate: fixture.nodeFirst,
582 });
583 if (fixture.nodeFirst) {
584 expect(capabilities.update).toMatchObject({
585 executable: "npm",
586 args: expect.arrayContaining([
587 "--prefix",
588 yield* fs.realPath(npmPrefix),
589 "@openai/codex@latest",
590 ]),
591 });
592 } else {
593 expect(capabilities.update).toBeNull();
594 }
595 }).pipe(Effect.scoped),
596 { skip: windowsHost },
597 );
598});