[2/8] Support piped stdin in exec process API (#18086)

## Summary
- Add an explicit stdin mode to process/start.
- Keep normal non-interactive exec stdin closed while allowing
pipe-backed processes.

## Stack
```text
o  #18027 [8/8] Fail exec client operations after disconnect
│
o  #18025 [7/8] Cover MCP stdio tests with executor placement
│
o  #18089 [6/8] Wire remote MCP stdio through executor
│
o  #18088 [5/8] Add executor process transport for MCP stdio
│
o  #18087 [4/8] Abstract MCP stdio server launching
│
o  #18020 [3/8] Add pushed exec process events
│
@  #18086 [2/8] Support piped stdin in exec process API
│
o  #18085 [1/8] Add MCP server environment config
│
o  main
```

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Ahmed Ibrahim
2026-04-16 10:30:10 -07:00
committed by GitHub
parent 6e72f0dbfd
commit 2ca270d08d
9 changed files with 215 additions and 7 deletions

View File

@@ -346,6 +346,7 @@ mod tests {
env_policy: None,
env: Default::default(),
tty: false,
pipe_stdin: false,
arg0: None,
})
.await

View File

@@ -59,6 +59,7 @@ struct RetainedOutputChunk {
struct RunningProcess {
session: ExecCommandSession,
tty: bool,
pipe_stdin: bool,
output: VecDeque<RetainedOutputChunk>,
retained_bytes: usize,
next_seq: u64,
@@ -165,6 +166,15 @@ impl LocalProcess {
TerminalSize::default(),
)
.await
} else if params.pipe_stdin {
codex_utils_pty::spawn_pipe_process(
program,
args,
params.cwd.as_path(),
&env,
&params.arg0,
)
.await
} else {
codex_utils_pty::spawn_pipe_process_no_stdin(
program,
@@ -195,6 +205,7 @@ impl LocalProcess {
ProcessEntry::Running(Box::new(RunningProcess {
session: spawned.session,
tty: params.tty,
pipe_stdin: params.pipe_stdin,
output: VecDeque::new(),
retained_bytes: 0,
next_seq: 1,
@@ -339,7 +350,7 @@ impl LocalProcess {
status: WriteStatus::Starting,
});
};
if !process.tty {
if !process.tty && !process.pipe_stdin {
return Ok(WriteResponse {
status: WriteStatus::StdinClosed,
});
@@ -667,6 +678,7 @@ mod tests {
env_policy: None,
env,
tty: false,
pipe_stdin: false,
arg0: None,
}
}

View File

@@ -69,6 +69,9 @@ pub struct ExecParams {
pub env_policy: Option<ExecEnvPolicy>,
pub env: HashMap<String, String>,
pub tty: bool,
/// Keep non-tty stdin writable through `process/write`.
#[serde(default)]
pub pipe_stdin: bool,
pub arg0: Option<String>,
}

View File

@@ -30,6 +30,7 @@ fn exec_params_with_argv(process_id: &str, argv: Vec<String>) -> ExecParams {
env_policy: None,
env: inherited_path_env(),
tty: false,
pipe_stdin: false,
arg0: None,
}
}

View File

@@ -393,6 +393,7 @@ mod tests {
env_policy: None,
env,
tty: false,
pipe_stdin: false,
arg0: None,
}
}