@@ -78,6 +78,7 @@ import { validateApiKey, authenticateToken, authenticateWebSocket } from './midd
7878import { IS_PLATFORM } from './constants/config.js' ;
7979import { enqueueTelemetryEvent } from './telemetry.js' ;
8080import { resolveCursorCliCommand , isCursorLoginCommand , isGeminiLoginCommand , normalizeCursorLoginCommand } from './utils/cursorCommand.js' ;
81+ import { buildCodexCliEnv , codexCommandForShell } from './utils/codexCli.js' ;
8182import { getGeminiApiKeyForUser , withGeminiApiKeyEnv } from './utils/geminiApiKey.js' ;
8283import {
8384 DEFAULT_BACKEND_PORT ,
@@ -2031,18 +2032,18 @@ function handleShellConnection(ws) {
20312032 }
20322033 }
20332034 } else if ( provider === 'codex' ) {
2034- // Use codex command
2035+ const codexCommand = codexCommandForShell ( process . env , os . platform ( ) ) ;
20352036 if ( os . platform ( ) === 'win32' ) {
20362037 if ( hasSession && sessionId ) {
2037- shellCommand = `Set-Location -Path "${ projectPath } "; codex resume ${ sessionId } ; if ($LASTEXITCODE -ne 0) { codex }` ;
2038+ shellCommand = `Set-Location -Path "${ projectPath } "; ${ codexCommand } resume ${ sessionId } ; if ($LASTEXITCODE -ne 0) { ${ codexCommand } }` ;
20382039 } else {
2039- shellCommand = `Set-Location -Path "${ projectPath } "; codex ` ;
2040+ shellCommand = `Set-Location -Path "${ projectPath } "; ${ codexCommand } ` ;
20402041 }
20412042 } else {
20422043 if ( hasSession && sessionId ) {
2043- shellCommand = `cd "${ projectPath } " && codex resume ${ sessionId } || codex ` ;
2044+ shellCommand = `cd "${ projectPath } " && ${ codexCommand } resume ${ sessionId } || ${ codexCommand } ` ;
20442045 } else {
2045- shellCommand = `cd "${ projectPath } " && codex ` ;
2046+ shellCommand = `cd "${ projectPath } " && ${ codexCommand } ` ;
20462047 }
20472048 }
20482049 } else if ( provider === 'gemini' ) {
@@ -2112,7 +2113,9 @@ function handleShellConnection(ws) {
21122113 cols : termCols ,
21132114 rows : termRows ,
21142115 cwd : spawnCwd ,
2115- env : buildEmbeddedShellEnv ( process . env )
2116+ env : provider === 'codex'
2117+ ? buildEmbeddedShellEnv ( buildCodexCliEnv ( process . env ) )
2118+ : buildEmbeddedShellEnv ( process . env )
21162119 } ) ;
21172120
21182121 console . log ( '🟢 Shell process started with PTY, PID:' , shellProcess . pid ) ;
0 commit comments