@@ -57,45 +57,22 @@ function buildCodexMcpOverrides(servers: McpServerConfig[]): string[] {
5757}
5858
5959function normalizeLegacyCodexArgs ( args : string [ ] ) : string [ ] {
60- let needsBypass = false ;
6160 const preserved : string [ ] = [ ] ;
6261
6362 for ( let i = 0 ; i < args . length ; i ++ ) {
6463 const arg = args [ i ] ! ;
6564 if ( arg === "--dangerously-bypass-approvals-and-sandbox" ) {
66- needsBypass = true ;
65+ preserved . push ( arg ) ;
6766 continue ;
6867 }
6968 if ( arg === "--ask-for-approval" ) {
7069 const value = args [ i + 1 ] ;
71- if ( value === "never" ) {
72- needsBypass = true ;
73- i ++ ;
74- continue ;
75- }
76- }
77- preserved . push ( arg ) ;
78- }
79-
80- if ( ! needsBypass ) {
81- return preserved ;
82- }
83-
84- const normalized : string [ ] = [ ] ;
85- for ( let i = 0 ; i < preserved . length ; i ++ ) {
86- const arg = preserved [ i ] ! ;
87- if ( arg === "--full-auto" ) {
88- continue ;
89- }
90- if ( arg === "--sandbox" ) {
91- i ++ ; // drop the sandbox value as well; bypass supersedes sandbox selection
70+ if ( typeof value === "string" ) i ++ ;
9271 continue ;
9372 }
94- normalized . push ( arg ) ;
73+ preserved . push ( arg ) ;
9574 }
96-
97- normalized . push ( "--dangerously-bypass-approvals-and-sandbox" ) ;
98- return normalized ;
75+ return preserved ;
9976}
10077
10178export class CodexCliAdapter extends BaseProcessAdapter {
@@ -163,17 +140,18 @@ export class CodexCliAdapter extends BaseProcessAdapter {
163140 task . capabilities . includes ( WorkerCapability . RUN_COMMANDS ) ||
164141 task . capabilities . includes ( WorkerCapability . RUN_TESTS ) ;
165142 const hasBypass = args . includes ( "--dangerously-bypass-approvals-and-sandbox" ) ;
143+ const hasSandbox = args . includes ( "--sandbox" ) || args . includes ( "-s" ) ;
144+ const hasFullAuto = args . includes ( "--full-auto" ) ;
166145
167146 if ( hasBypass ) {
168147 // Current Codex CLI bypass mode already implies no sandbox / no approvals.
169148 } else if ( hasWrite && hasRunCommands ) {
170149 // Low-friction sandboxed auto execution.
171- if ( ! args . includes ( "--full-auto" ) ) {
150+ if ( ! hasFullAuto && ! hasSandbox ) {
172151 args . push ( "--full-auto" ) ;
173152 }
174153 } else {
175154 // Stay sandboxed and align with capability intent.
176- const hasSandbox = args . includes ( "--sandbox" ) || args . includes ( "-s" ) ;
177155 if ( ! hasSandbox ) {
178156 args . push ( "--sandbox" , hasWrite ? "workspace-write" : "read-only" ) ;
179157 }
0 commit comments