Add a standalone codex-exec-server executable (#57589)

## What changed

Extract executor startup into `codex-exec-server-cli`, shared by `codex exec-server` and the new standalone binary. Preserve executor arguments, authentication, configuration overrides, and sandbox helper dispatch across both entry points.

Build the standalone binary with `cargo build -p codex-exec-server-cli --bin codex-exec-server` and run it with `codex-exec-server --listen stdio`.

## Testing

Add standalone CLI parsing and help coverage, plus an integration test for version reporting, stdio initialization, filesystem reads, process execution, and sandbox helper re-execution when supported.

GitOrigin-RevId: ab3a81c6b91b6f45e4d72d8add2e01af8372e97f
This commit is contained in:
Dmitriy Kovalenko
2026-10-27 23:13:53 +00:00
committed by copyberry
parent 37f199dab1
commit a9ea49e78b
25 changed files with 1090 additions and 579 deletions
+33
View File
@@ -101,6 +101,39 @@ fn parse_toml_value(raw: &str) -> Result<Value, toml::de::Error> {
.ok_or_else(|| SerdeError::custom("missing sentinel key"))
}
/// Collects config overrides across command boundaries in argument order.
///
/// Clap keeps the deepest global argument's values instead of appending across
/// scopes. Reparse with local config arguments after validating the typed CLI.
pub fn collect_config_overrides(
command: clap::Command,
args: impl IntoIterator<Item = impl Into<std::ffi::OsString> + Clone>,
) -> Result<CliConfigOverrides, clap::Error> {
let matches = localize_config_arg(command).try_get_matches_from(args)?;
let raw_overrides = std::iter::successors(Some(&matches), |scope| {
scope.subcommand().map(|(_, child)| child)
})
.filter_map(|scope| scope.get_many::<String>("raw_overrides"))
.flatten()
.cloned()
.collect();
Ok(CliConfigOverrides { raw_overrides })
}
fn localize_config_arg(mut command: clap::Command) -> clap::Command {
use clap::CommandFactory;
if !command
.get_arguments()
.any(|arg| arg.get_id() == "raw_overrides")
{
command = command.args(CliConfigOverrides::command().get_arguments().cloned());
}
command
.mut_arg("raw_overrides", |arg| arg.global(false))
.mut_subcommands(localize_config_arg)
}
#[cfg(test)]
mod tests {
use super::*;
+1
View File
@@ -8,6 +8,7 @@ mod shared_options;
pub use approval_mode_cli_arg::ApprovalModeCliArg;
pub use codex_protocol::config_types::ProfileV2Name;
pub use config_override::CliConfigOverrides;
pub use config_override::collect_config_overrides;
pub use format_env_display::format_env_display;
pub use resume_command::resume_command;
pub use resume_command::resume_hint;