Skip to main content

Module messages

Module messages 

Source
Expand description

Typed dispatch for app-server notifications and server-to-client requests.

The Codex app-server speaks JSON-RPC where every message carries a method discriminant alongside a free-form params blob. This module lifts that loose envelope into closed enums — Notification for server-initiated notifications and ServerRequest for server-initiated requests (the approval flow). Each variant wraps a typed param struct from crate::protocol.

The pattern mirrors the [ContentBlock] dispatch in the sibling claude-codes crate: hand-written Serialize/Deserialize impls inspect the discriminant, route known cases through serde_json::from_value into the typed struct, and route unknown methods into an Unknown variant — preserving the raw payload for forward compatibility with future codex versions.

§Typing contract

  • Unknown methods route to Notification::Unknown / ServerRequest::Unknown without error. Encountering one in production typically means the installed Codex CLI is newer than the bindings.
  • Known methods whose payload fails to deserialize do cause an error. If you see one, the typed binding in crate::protocol is out of sync with the wire format and needs to be updated.

Enums§

Notification
A server-to-client notification.
ServerMessage
A message coming from the app-server.
ServerRequest
A server-to-client request that requires a response (approval flow).