Add a multiplexed stdio transport to the exec server (#65115)

## Why

Plain stdio serves one JSON-RPC connection and shuts down when it closes,
so clients cannot run concurrent sessions or reconnect to resume a
detached session over the same stdin/stdout pair.

## What changed

Add `--listen stdio-mux` to serve multiple independent newline-delimited
JSON-RPC connections over one HTTP/2 connection on stdin and stdout.
Each `CONNECT` stream to `rpc.local` carries one JSON-RPC connection.
A client can half-close the request to detach, wait for response EOF,
then open a fresh stream and initialize with `resumeSessionId` before
the session expires.

## Testing

Add tests for concurrent sessions, immediate resume after response EOF,
session expiry, and recovery after a stream reset while another stream
stays usable. Cover shutdown with a full input queue and verify that a
failed stdio write unblocks response senders.

GitOrigin-RevId: cdb9638f8b69671a50f44e3eca4dd9059f5bdcd1
This commit is contained in:
hesham-oai
2026-12-02 00:14:30 +00:00
committed by copyberry
parent 33811295ff
commit 5d32c09b5b
11 changed files with 405 additions and 72 deletions
+1 -1
View File
@@ -67,7 +67,7 @@ pub struct ExecServerCommand {
)]
request_dispatch_mode: codex_exec_server::RequestDispatchMode,
/// Transport endpoint URL. Supported values: `ws://IP:PORT` (default), `stdio`, `stdio://`.
/// Transport endpoint URL. Supported values: `ws://IP:PORT` (default), `stdio`, `stdio://`, `stdio-mux`.
#[arg(long = "listen", value_name = "URL")]
listen: Option<String>,
@@ -55,7 +55,7 @@ Options:
--listen <URL>
Transport endpoint URL. Supported values: `ws://IP:PORT` (default),
`stdio`, `stdio://`
`stdio`, `stdio://`, `stdio-mux`
--ws-auth <MODE>
Authentication mode for incoming WebSocket connections