Expand description
App-server v2 protocol types for the Codex CLI.
These types represent the JSON-RPC request parameters, response payloads,
and notification bodies used by codex app-server. All wire types use
camelCase field names via #[serde(rename_all = "camelCase")].
§Organization
- Request/Response pairs —
ThreadStartParams/ThreadStartResponse,TurnStartParams/TurnStartResponse, etc. - Server notifications — Structs like
TurnCompletedNotification,AgentMessageDeltaNotificationthat can be deserialized from theparamsfield of aServerMessage::Notification - Approval flow types —
CommandExecutionApprovalParamsandFileChangeApprovalParamsfor server-to-client requests that need a response - Method constants — The
methodsmodule contains all JSON-RPC method name strings
§Parsing notifications
use codex_codes::protocol::{methods, TurnCompletedNotification};
use serde_json::Value;
fn handle_notification(method: &str, params: Option<Value>) {
if method == methods::TURN_COMPLETED {
if let Some(p) = params {
let notif: TurnCompletedNotification = serde_json::from_value(p).unwrap();
println!("Turn {} completed", notif.turn_id);
}
}
}Modules§
- methods
- JSON-RPC method names used by the app-server protocol.
Structs§
- Agent
Message Delta Notification item/agentMessage/deltanotification.- Client
Info - Client info sent during the
initializehandshake. - CmdOutput
Delta Notification item/commandExecution/outputDeltanotification.- Command
Execution Approval Params - Parameters for
item/commandExecution/requestApproval(server → client). - Command
Execution Approval Response - Response for
item/commandExecution/requestApproval. - Error
Notification errornotification.- File
Change Approval Params - Parameters for
item/fileChange/requestApproval(server → client). - File
Change Approval Response - Response for
item/fileChange/requestApproval. - File
Change Output Delta Notification item/fileChange/outputDeltanotification.- Initialize
Capabilities - Client capabilities negotiated during
initialize. - Initialize
Params - Parameters for the
initializerequest. - Initialize
Response - Response from the
initializerequest. - Item
Completed Notification item/completednotification.- Item
Started Notification item/startednotification.- Reasoning
Delta Notification item/reasoning/summaryTextDeltanotification.- Thread
Archive Params - Parameters for
thread/archive. - Thread
Archive Response - Response from
thread/archive. - Thread
Info - Thread metadata returned inside a
ThreadStartResponse. - Thread
Start Params - Parameters for
thread/start. - Thread
Start Response - Response from
thread/start. - Thread
Started Notification thread/startednotification.- Thread
Status Changed Notification thread/status/changednotification.- Thread
Token Usage Updated Notification thread/tokenUsage/updatednotification.- Token
Usage - Cumulative token usage for a thread.
- Turn
- A completed turn with its items and final status.
- Turn
Completed Notification turn/completednotification.- Turn
Error - Error information from a failed turn.
- Turn
Interrupt Params - Parameters for
turn/interrupt. - Turn
Interrupt Response - Response from
turn/interrupt. - Turn
Start Params - Parameters for
turn/start. - Turn
Start Response - Response from
turn/start. - Turn
Started Notification turn/startednotification.
Enums§
- Command
Approval Decision - Decision for command execution approval.
- File
Change Approval Decision - Decision for file change approval.
- Server
Message - An incoming message from the app-server that the client should handle.
- Thread
Status - Status of a thread, sent via
ThreadStatusChangedNotification. - Turn
Status - Status of a turn within a
Turn. - User
Input - User input sent as part of a
TurnStartParams.