codex/commands/
exec_server.rs1use tokio::process::Command;
2
3use crate::{
4 builder::{apply_cli_overrides, resolve_cli_overrides},
5 process::spawn_with_retry,
6 CodexClient, CodexError, ExecServerRequest,
7};
8
9impl CodexClient {
10 pub fn start_exec_server(
12 &self,
13 request: ExecServerRequest,
14 ) -> Result<tokio::process::Child, CodexError> {
15 let ExecServerRequest {
16 listen,
17 working_dir,
18 overrides,
19 } = request;
20
21 let resolved_overrides =
22 resolve_cli_overrides(&self.cli_overrides, &overrides, self.model.as_deref());
23
24 let mut command = Command::new(self.command_env.binary_path());
25 command
26 .stdin(std::process::Stdio::piped())
27 .stdout(std::process::Stdio::piped())
28 .stderr(std::process::Stdio::piped())
29 .kill_on_drop(true)
30 .current_dir(self.sandbox_working_dir(working_dir)?);
31
32 apply_cli_overrides(&mut command, &resolved_overrides, true);
33 command.arg("exec-server");
34
35 if let Some(listen) = listen {
36 command.arg("--listen").arg(listen);
37 }
38
39 self.command_env.apply(&mut command)?;
40
41 spawn_with_retry(&mut command, self.command_env.binary_path())
42 }
43}