@@ -389,6 +389,7 @@ describe("bridgeCodexAppServerStartOptions", () => {
389389 await applyCodexAppServerAuthProfile ( {
390390 client : { request } as never ,
391391 agentDir,
392+ startOptions : createStartOptions ( ) ,
392393 } ) ;
393394
394395 expect ( request ) . toHaveBeenNthCalledWith ( 1 , "account/read" , { refreshToken : false } ) ;
@@ -415,6 +416,7 @@ describe("bridgeCodexAppServerStartOptions", () => {
415416 await applyCodexAppServerAuthProfile ( {
416417 client : { request } as never ,
417418 agentDir,
419+ startOptions : createStartOptions ( ) ,
418420 } ) ;
419421
420422 expect ( request ) . toHaveBeenNthCalledWith ( 1 , "account/read" , { refreshToken : false } ) ;
@@ -443,6 +445,7 @@ describe("bridgeCodexAppServerStartOptions", () => {
443445 await applyCodexAppServerAuthProfile ( {
444446 client : { request } as never ,
445447 agentDir,
448+ startOptions : createStartOptions ( ) ,
446449 } ) ;
447450
448451 expect ( request ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -465,6 +468,7 @@ describe("bridgeCodexAppServerStartOptions", () => {
465468 await applyCodexAppServerAuthProfile ( {
466469 client : { request } as never ,
467470 agentDir,
471+ startOptions : createStartOptions ( ) ,
468472 } ) ;
469473
470474 expect ( request ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -474,6 +478,32 @@ describe("bridgeCodexAppServerStartOptions", () => {
474478 }
475479 } ) ;
476480
481+ it ( "does not send env API-key fallback to websocket app-server connections" , async ( ) => {
482+ const agentDir = await fs . mkdtemp ( path . join ( os . tmpdir ( ) , "openclaw-codex-app-server-" ) ) ;
483+ const request = vi . fn ( async ( method : string ) => {
484+ if ( method === "account/read" ) {
485+ return { account : null , requiresOpenaiAuth : true } ;
486+ }
487+ return { type : "apiKey" } ;
488+ } ) ;
489+ vi . stubEnv ( "CODEX_API_KEY" , "codex-env-api-key" ) ;
490+ vi . stubEnv ( "OPENAI_API_KEY" , "openai-env-api-key" ) ;
491+ try {
492+ await applyCodexAppServerAuthProfile ( {
493+ client : { request } as never ,
494+ agentDir,
495+ startOptions : createStartOptions ( {
496+ transport : "websocket" ,
497+ url : "ws://127.0.0.1:1455" ,
498+ } ) ,
499+ } ) ;
500+
501+ expect ( request ) . not . toHaveBeenCalled ( ) ;
502+ } finally {
503+ await fs . rm ( agentDir , { recursive : true , force : true } ) ;
504+ }
505+ } ) ;
506+
477507 it ( "applies an OpenAI Codex token profile backed by a secret ref" , async ( ) => {
478508 const agentDir = await fs . mkdtemp ( path . join ( os . tmpdir ( ) , "openclaw-codex-app-server-" ) ) ;
479509 const request = vi . fn ( async ( ) => ( { type : "chatgptAuthTokens" } ) ) ;
0 commit comments