Expand description
A tightly typed Rust interface for the OpenAI Codex CLI JSON protocol.
This crate provides type-safe representations of the Codex CLI’s JSONL output,
mirroring the structure of the official TypeScript SDK (@openai/codex-sdk).
§Message Types
The protocol uses two primary discriminated unions:
ThreadEvent— Events emitted during thread execution (thread/turn/item lifecycle)ThreadItem— Data items representing agent actions (messages, commands, file changes, etc.)
§Configuration Types
ThreadOptions— Per-thread settings (model, sandbox mode, approval policy)ApprovalMode,SandboxMode,ModelReasoningEffort,WebSearchMode— Typed enums
§Example
use codex_codes::{ThreadEvent, ThreadItem};
let json = r#"{"type":"thread.started","thread_id":"th_abc"}"#;
let event: ThreadEvent = serde_json::from_str(json).unwrap();Structs§
- Agent
Message Item - An agent message item containing text output.
- Command
Execution Item - A command execution item.
- Error
Item - An error item.
- File
Change Item - A file change item representing one or more file modifications.
- File
Update Change - A single file update within a file change item.
- Item
Completed Event - Event indicating an item has completed.
- Item
Started Event - Event indicating an item has started processing.
- Item
Updated Event - Event indicating an item has been updated.
- McpTool
Call Error - Error from an MCP tool call.
- McpTool
Call Item - An MCP tool call item.
- McpTool
Call Result - Result of an MCP tool call.
- Reasoning
Item - A reasoning item containing the model’s chain-of-thought.
- Thread
Error - Error information from a thread.
- Thread
Error Event - A thread-level error event.
- Thread
Options - Per-thread options controlling model, sandbox, and behavior.
- Thread
Started Event - Event indicating a thread has started.
- Todo
Item - A single todo entry within a todo list.
- Todo
List Item - A todo list item.
- Turn
Completed Event - Event indicating a turn has completed successfully.
- Turn
Failed Event - Event indicating a turn has failed.
- Turn
Started Event - Event indicating a turn has started.
- Usage
- Token usage statistics for a completed turn.
- WebSearch
Item - A web search item.
Enums§
- Approval
Mode - Approval mode for tool execution.
- Command
Execution Status - Status of a command execution.
- McpTool
Call Status - Status of an MCP tool call.
- Model
Reasoning Effort - Model reasoning effort level.
- Patch
Apply Status - Status of a patch apply operation.
- Patch
Change Kind - Kind of patch change applied to a file.
- Sandbox
Mode - Sandbox mode controlling file system access.
- Thread
Event - All possible events emitted during a Codex thread execution.
- Thread
Item - All possible thread item types emitted by the Codex CLI.
- WebSearch
Mode - Web search mode.