@@ -481,6 +481,87 @@ it.layer(layerTest)("CodexDriver", (it) => {
481481 } ) . pipe ( Effect . provideService ( ChildProcessSpawner . ChildProcessSpawner , noSpawn ) , Effect . scoped ) ,
482482 ) ;
483483
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+
484565 it . effect ( "uses each instance's environment CODEX_HOME for continuation" , ( ) =>
485566 Effect . gen ( function * ( ) {
486567 const fs = yield * FileSystem . FileSystem ;
0 commit comments