Expand description
Lightweight JSON-RPC types for the Codex app-server stdio protocol.
Codex communicates over stdin/stdout using newline-delimited JSON messages.
The protocol is JSON-RPC-like but does not include the "jsonrpc": "2.0" field.
Protocol flow:
- Client sends
initializerequest → server responds with{userAgent} - Client sends
initializednotification (noid) - Client sends
thread/start→ server responds with{thread: {id, ...}, model, ...} - Client sends
turn/startwith{threadId, input}→ server responds + streams events - Events:
turn/started,item/started,item/agentMessage/delta,item/completed,turn/completed
Structs§
- Json
RpcClient Notification - A client-to-server notification (no
id, no response expected). - Json
RpcError - JSON-RPC error object.
- Json
RpcNotification - A server-to-client notification (no
idfield). - Json
RpcRequest - A request (client -> server). Has an
idfor correlation. - Json
RpcResponse - A response (server -> client). Has an
idmatching the request.
Enums§
- Json
RpcMessage - A line from Codex stdout can be either a response (has
id) or a notification (noid).
Constants§
- EVENT_
AGENT_ MESSAGE_ DELTA - A streaming text delta from the agent.
- EVENT_
COMMAND_ OUTPUT_ DELTA - Command execution output delta.
- EVENT_
ERROR - Error notification.
- EVENT_
ITEM_ COMPLETED - An output item has completed.
- EVENT_
ITEM_ STARTED - An output item has started.
- EVENT_
THREAD_ STARTED - Thread has been started/loaded.
- EVENT_
TURN_ COMPLETED - A turn has completed.
- EVENT_
TURN_ STARTED - A turn has started processing.
- METHOD_
INITIALIZE - Initialize handshake.
- METHOD_
INITIALIZED - Client notification sent after initialize response.
- METHOD_
THREAD_ START - Start a new thread (conversation).
- METHOD_
TURN_ INTERRUPT - Interrupt the current turn.
- METHOD_
TURN_ START - Start a new turn within a thread.