Add a shared sandbox launcher for Linux and macOS (#62353)

## Why

Running each helper through `codex sandbox` keeps a separate Codex
supervisor process alive for each helper. A shared launcher lets one
supervisor manage multiple helpers concurrently.

## What changed

Add a launcher mode that multiplexes helper I/O and exit status over a
newline-delimited JSON protocol on stdin and stdout. Each helper uses
the host sandbox setup with its own configuration and network proxy.
The launcher applies backpressure to helper I/O, drains buffered output
on exit, and stops tracked helpers when the controller disconnects.

## Testing

Add integration coverage for per-helper filesystem isolation, stdin
backpressure, buffered output after helper exit, and controller
disconnect while output is blocked.

GitOrigin-RevId: a7f75fdedbe0928ff5b93a412c7223371d0f321a
This commit is contained in:
Charlie Marsh
2026-11-18 20:14:05 +00:00
committed by copyberry
parent 60fcb1649f
commit 097a8a7439
7 changed files with 939 additions and 1 deletions
+19 -1
View File
@@ -121,6 +121,23 @@ pub async fn run_command_under_linux_sandbox(
codex_linux_sandbox_exe: Option<PathBuf>,
loader_overrides: LoaderOverrides,
) -> anyhow::Result<()> {
let mut launch = start_command_under_linux_sandbox(
command,
codex_linux_sandbox_exe,
loader_overrides,
/*piped*/ false,
)
.await?;
launch.wait_and_exit().await
}
/// Start a Linux sandbox child while retaining the resources required for its lifetime.
pub async fn start_command_under_linux_sandbox(
command: LinuxSandboxCommand,
codex_linux_sandbox_exe: Option<PathBuf>,
loader_overrides: LoaderOverrides,
piped: bool,
) -> anyhow::Result<StartedSandboxChild> {
let LinuxSandboxCommand {
transparent_tcp,
sandbox_state,
@@ -135,7 +152,7 @@ pub async fn run_command_under_linux_sandbox(
&permissions_profile,
include_managed_config,
);
run_command_under_sandbox(
start_command_under_sandbox(
DebugSandboxConfigOptions {
sandbox_state,
permissions_profile,
@@ -149,6 +166,7 @@ pub async fn run_command_under_linux_sandbox(
SandboxType::Linux { transparent_tcp },
/*log_denials*/ false,
&[],
piped,
)
.await
}