@@ -5,9 +5,11 @@ import type { AgentStep } from '../agent-runner'
55
66export class CodexRunner implements Runner {
77 private cwd : string
8+ private env : Record < string , string >
89
9- constructor ( cwd : string ) {
10+ constructor ( cwd : string , env : Record < string , string > = { } ) {
1011 this . cwd = cwd
12+ this . env = env
1113 }
1214
1315 async run ( prompt : string ) : Promise < RunnerResult > {
@@ -25,8 +27,12 @@ export class CodexRunner implements Runner {
2527
2628 const child = spawn ( 'codex' , args , {
2729 cwd : this . cwd ,
28- env : process . env ,
29- stdio : [ 'pipe' , 'pipe' , 'pipe' ] ,
30+ env : {
31+ ...process . env ,
32+ ...this . env ,
33+ } ,
34+ // Use 'ignore' for stdin to prevent the CLI from waiting for input
35+ stdio : [ 'ignore' , 'pipe' , 'pipe' ] ,
3036 } )
3137
3238 let stdout = ''
@@ -47,7 +53,10 @@ export class CodexRunner implements Runner {
4753 type : 'text' ,
4854 text : event . content || event . message || '' ,
4955 } )
50- } else if ( event . type === 'function_call' || event . type === 'tool' ) {
56+ } else if (
57+ event . type === 'function_call' ||
58+ event . type === 'tool'
59+ ) {
5160 steps . push ( {
5261 type : 'tool_call' ,
5362 toolName : event . name || event . function ?. name || 'unknown' ,
@@ -111,9 +120,7 @@ export class CodexRunner implements Runner {
111120
112121 if ( code !== 0 ) {
113122 reject (
114- new Error (
115- `Codex CLI exited with code ${ code } . stderr: ${ stderr } ` ,
116- ) ,
123+ new Error ( `Codex CLI exited with code ${ code } . stderr: ${ stderr } ` ) ,
117124 )
118125 return
119126 }
0 commit comments