A runtime-agnostic Rust workspace serving OpenAI Codex over the
Agent Client Protocol (ACP v1 and v2) by
bridging aither-acp onto codex app-server:
codex-sdk(sdk/) — standalone client SDK forcodex app-server(LF-only NDJSON framing preserving unescapedU+2028/U+2029, JSON-RPC correlation without ajsonrpcwire field, concurrentServerRequestHandler, per-threadIdevent demultiplexing, and optional child process supervision behind theprocessfeature).codex-acp(.) — dual-stack ACP v1/v2 agent server (CodexAgent,CodexSession,serve,serve_stdio) built ontoaither-acpandcodex-sdk.
- Dual-stack ACP v1 and v2 negotiation, capability translation, and state
updates via
aither-acp - Authentication:
chat-gpt,chat-gpt-device-code,api-key, customgateway,auth/logout(logouton v1),_auth/status_updatepush notifications, and legacyauthentication/{status,logout}RPCs - Session lifecycle:
session/{new,load,resume,fork,list,close,delete}, MCP server forwarding (stdio,http,sse), and transcript history replay - Modes (
read-only,workspace-write,agent,agent-full-access) and config options (mode,model,reasoning_effort, booleanfast-mode), plus legacysession/set_model - Streaming agent text, reasoning summaries, plans, tool calls (with diffs, locations, command/file output chunks, and MCP metadata), token usage, and capability-gated notices
- Mid-turn and out-of-prompt approvals (
commandExecution,execCommand,fileChange,applyPatch,permissions),requestUserInput, MCP form/URL elicitations,strictReviewRequiredescalation, and per-session permission memory - Steering (
_session/steering, legacy_codex/session/steering, and v2 concurrent prompt merging) and slash commands (/compact,/status,/logout,/review,/review-branch,/review-commit)
[dependencies]
codex-acp = { git = "https://github.com/May-Agent/codex-acp", branch = "main" }use codex_acp::{CodexAcpConfig, serve_stdio};
#[tokio::main]
async fn main() {
let (_peer, server) = serve_stdio(CodexAcpConfig::new());
server.await;
}use codex_acp::{CodexAcpConfig, ConnectedAppServer, serve};
# async fn example(
# acp_transport: impl codex_acp::aither_acp::Transport + 'static,
# read: impl futures_lite::io::AsyncRead + Unpin + Send + 'static,
# write: impl futures_lite::io::AsyncWrite + Unpin + Send + 'static,
# ) {
let slot = std::sync::Mutex::new(Some((read, write)));
let config = CodexAcpConfig::new()
.default_mode("workspace-write")
.connector(move |_spawn, handler| {
let (r, w) = slot.lock().unwrap().take().expect("connected once");
std::future::ready(Ok(ConnectedAppServer::attach(r, w, handler)))
});
let (_peer, server) = serve(acp_transport, config);
server.await;
# }CodexAcpConfig::codex_path/SpawnConfig::codex_path— explicitcodexexecutable path; falls back toCODEX_PATHand then"codex"onPATH.SpawnConfig::override_config/SpawnConfig::args—-c key=valueoverrides and extra CLI arguments passed tocodex app-server.SpawnConfig::env_var— environment variables (CODEX_API_KEY,OPENAI_API_KEY, etc.) passed to the spawnedcodexprocess.CodexAcpConfig::default_mode— initial session mode ("agent"by default).
cargo fmt --all -- --check
cargo clippy --workspace --all-targets --all-features -- -D warnings
cargo clippy --workspace --all-targets --no-default-features -- -D warnings
cargo nextest run --workspace --all-features --no-tests=pass
cargo nextest run --workspace --no-default-features --no-tests=pass
cargo test --doc --workspace --all-features
RUSTDOCFLAGS="-D warnings" cargo doc --workspace --all-features --no-depsTo run the ignored live integration test against a local codex binary and
provider pool:
CODEX_ACP_POOL_URL=http://127.0.0.1:64395/v1 CODEX_ACP_TEST_MODEL=gpt-6-luna \
cargo nextest run -p codex-acp --test live --run-ignored onlyLicensed under either of Apache-2.0 or MIT at your option.