codexus
codexus is a Rust wrapper around the local codex app-server, the stdio JSON-RPC backend started by the codex CLI.
Repository identity:
- repository and crate:
codexus - Rust import path:
codexus - current crate version:
1.0.0
The project is intentionally layered so callers can start with one prompt and move down only when they need more control.
| Layer | Entry point | Use when |
|---|---|---|
| 1 | quick_run, quick_run_with_profile |
One prompt with safe defaults |
| 2 | Workflow, WorkflowConfig |
Repeated runs in one working directory |
| 3 | runtime::{Client, Session} |
Explicit session lifecycle and typed config |
| 4 | automation::{spawn, AutomationSpec} |
Recurring turns on one prepared Session |
| 5 | AppServer |
Generic low-level JSON-RPC bridge |
| 6 | runtime::Runtime or raw JSON-RPC |
Full runtime control and live events |
Release Status
codexus is currently positioned as an inventory-driven runtime wrapper over codex app-server.
- Good fit: typed runtime helpers, generated method inventory, raw JSON-RPC escape hatch, and release-gated local integration.
- Not yet true: full product-spec parity for every typed protocol contract surface.
For the current deployment audit and remaining parity gaps, see docs/RELEASE_READINESS.md.
Protocol Layer
codexus::protocol is the generated Layer 2 inventory and method-spec surface. It is the canonical source of truth for method constants, protocol inventory, and stability metadata generated from the vendored upstream snapshot.
Current limitation:
- Layer 2 currently models protocol params and results as
serde_json::Value. - Richer typed request and response models live in
codexus::runtime.
use ;
// Enumerate the full protocol surface at runtime
let inv = inventory;
println!;
println!;
println!;
// All wire method name constants
assert_eq!;
Regenerate from the checked-in protocol inputs:
Install
Requires codex CLI >= 0.104.0 on $PATH.
Published crate:
[]
= "1.0.0"
= { = "1", = ["macros", "rt-multi-thread"] }
Workspace path:
[]
= { = "crates/codexus-core" }
Release Prep
Minimum release verification:
Package dry run:
Safe Defaults
All high-level entry points share the same baseline unless you opt out:
| Setting | Default |
|---|---|
| approval | never |
| sandbox | read-only |
| effort | medium |
| timeout | 120s |
| privileged escalation | false |
Privileged execution must be enabled explicitly. Tool-use hooks do not bypass sandbox or approval policy.
Quick Start
Human path — one-shot prompt
use quick_run;
async
Human path — reusable workflow
use ;
async
Human path — explicit client and session
use ;
async
Human path — scoped streaming
use ;
async
Session::ask_wait(prompt) is the convenience path for ask_stream(...).finish().await when you do not need manual event handling.
Human path — automation
use ;
use ;
use ;
async
Automation contract:
- one prepared
Sessionper runner - fixed
Durationcadence only - one turn in flight at a time
- missed ticks collapse into one next eligible run
- any
PromptRunErroris terminal - no cron parsing, persistence, or restart recovery in 1.0
Agent path — typed protocol bridge
For agents that need complete protocol control, use AppServer::request_typed<M>() with generated specs:
use AppServer;
use ;
use ClientConfig;
use json;
async
Raw escape hatch for custom or experimental methods:
let result = server
.request_json_unchecked
.await?;
Public Modules
| Module | Role |
|---|---|
codexus |
root convenience surface |
codexus::protocol |
generated protocol inventory, method specs, and bridge contracts |
codexus::runtime |
typed runtime, sessions, approvals, transport, hooks, metrics |
codexus::automation |
session-scoped recurring prompt runner |
codexus::plugin |
hook traits and hook-side contracts |
codexus::web |
higher-order web bridge over runtime sessions and approvals |
codexus::artifact |
higher-order artifact domain over runtime threads and stores |
Root crate exports:
quick_run,quick_run_with_profile,QuickRunErrorWorkflow,WorkflowConfigAppServerHookMatcher,FilteredPreHook,FilteredPostHook,ShellCommandHookautomation,plugin,protocol,runtime,web,artifact
Runtime Contracts
- High-level builders stay intentionally smaller than raw upstream payloads.
- Stable upstream fields graduate into the generated protocol layer first.
- Experimental or custom methods remain available through raw JSON-RPC and the generic
AppServerbridge. - Validation is strict in typed paths and only relaxed when callers explicitly choose raw mode.
- Unknown server requests are queued for approval rather than auto-declined.
Hooks
Hooks let you intercept lifecycle phases without forking the runtime call path.
Phases:
PreRun,PostRunPreSessionStart,PostSessionStartPreTurn,PostTurnPreToolUse,PostToolUse
Key rules:
- pre-hooks can mutate or block
- post-hooks observe outcomes and issue reports
- tool-use hooks run inside approval-gated command/file-change handling
- hook logic sits on top of sandbox and approval policy, not instead of it
Documentation
docs/API_REFERENCE.md: public API and contract referencedocs/REPO_CLEANUP_GUIDE.md: simple cleanup and placement rulesdocs/RELEASE_READINESS.md: current deployment-readiness audit and blockersdocs/specs/product-spec.md: current product specdocs/TEST_TREE.md: test layers and release-gate boundaries
Quality Gates
Opt-in real-server tests:
CODEX_RUNTIME_REAL_SERVER_APPROVED=1 \
License
MIT