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