codex_app_server_sdk.transport¶
transport
¶
StdioTransport
¶
Bases: Transport
JSON-RPC transport over a subprocess stdin/stdout pipe.
__init__(command, *, cwd=None, env=None, connect_timeout=30.0)
¶
Configure stdio transport.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command
|
Sequence[str]
|
Command argv used to start the app-server process. |
required |
cwd
|
str | None
|
Optional subprocess working directory. |
None
|
env
|
Mapping[str, str] | None
|
Optional environment overrides for subprocess. |
None
|
connect_timeout
|
float
|
Timeout for subprocess creation. |
30.0
|
close()
async
¶
Terminate subprocess and release handles.
connect()
async
¶
Start subprocess if not already running.
recv()
async
¶
Read one JSON line from subprocess stdout.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Parsed JSON payload. |
Raises:
| Type | Description |
|---|---|
CodexTransportError
|
If transport is disconnected, closed, or emits invalid JSON. |
send(payload)
async
¶
Write one JSON line to subprocess stdin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
Mapping[str, Any]
|
JSON-serializable request/response/notification payload. |
required |
Raises:
| Type | Description |
|---|---|
CodexTransportError
|
If transport is disconnected or write fails. |
Transport
¶
Bases: ABC
Abstract transport interface for JSON-RPC message exchange.
WebSocketTransport
¶
Bases: Transport
JSON-RPC transport over a websocket connection.
__init__(url, *, headers=None, connect_timeout=30.0)
¶
Configure websocket transport.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
Websocket endpoint URL. |
required |
headers
|
Mapping[str, str] | None
|
Optional request headers, including auth. |
None
|
connect_timeout
|
float
|
Timeout for websocket handshake. |
30.0
|
close()
async
¶
Close websocket connection.
connect()
async
¶
Open websocket if not already connected.
recv()
async
¶
Receive and decode one websocket frame as JSON.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Parsed JSON payload. |
Raises:
| Type | Description |
|---|---|
CodexTransportError
|
If transport is disconnected, read fails, or frame payload is invalid JSON. |
send(payload)
async
¶
Send one JSON text frame over websocket.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
Mapping[str, Any]
|
JSON-serializable request/response/notification payload. |
required |
Raises:
| Type | Description |
|---|---|
CodexTransportError
|
If transport is disconnected or write fails. |