Expand description
Codex live calls (internal/client/codex/live): the WebRTC SDP bootstrap request to the ChatGPT realtime calls endpoint, its sideband and standard Realtime WebSockets, and hangup.
Request shaping ports live.go, client_secret.go and websocket.go byte for byte,
including Go’s error texts; expected values come from
tests/fixtures/codex_live/vectors.json, generated by running the Go functions. Routes,
client secrets and call state live in cpa-server’s realtime module.
Structs§
- Call
- A call request on its way upstream.
- Dial
Error - A failed upstream WebSocket dial.
- Endpoints
- Where live requests go. Tests point both at local mocks.
- Handshake
Response - A non-101 handshake answer, its body capped like gorilla’s.
- Live
Socket - A connected upstream WebSocket.
- Live
Target - The credential and client context of one live upstream exchange.
- Secret
Request clientSecretCreateRequestasjson.Unmarshaldecodes it: the rawsession(empty when absent) andexpires_after(Nonewhen absent or null).Noneis any decode error; Go answers every one with the same message.
Enums§
- Body
Error readLimitedBodyoutcome.- Session
Error - Why a client-secret session was refused.
- Shape
Error - Why a call request could not be shaped.
- Sideband
- The three sideband URL shapes (
sidebandStyle).
Constants§
- API_
BASE defaultSidebandAPIBaseURL: sideband, standard Realtime WebSocket and hangup.- CALL_
URL upstreamCallURL.- DEFAULT_
MODEL defaultLiveModel.- DEFAULT_
STANDARD_ MODEL defaultStandardRealtimeModel.- MAX_
BODY maxBodySize: call requests, upstream responses and rejected handshakes.- MAX_
WS_ MESSAGE - Largest relayed WebSocket message.
- PROTOCOL_
HEADERS liveProtocolHeaders: client headers forwarded to every live upstream request.
Functions§
- apply_
client_ secret applyClientSecretCallSession: the ephemeral key’s session replaces the request’s.- bearer_
token bearerToken: the trimmed token after a case-insensitiveBearer.- call_
id_ from_ location callIDFromLocation: a bare ID,?call_id=, or the last segment afterliveorcalls.- call_
response_ headers callResponseHeaders: what request logs keep of a live upstream response.- client_
secret_ lifetime clientSecretLifetime: ten minutes by default, else 10 s to 2 h fromcreated_at.- codex_
model codexRealtimeModel: OpenAI Realtime model names map to the Codex live model.- decode_
secret_ request - direct_
headers directRealtimeHeaders: noOpenAI-Alpha, andOriginatordefaults to Codex Desktop.- direct_
url directRealtimeURL.- http_
base realtimeHTTPBaseURL: where hangup goes.- http_
url websocketHTTPURL:ws→http,wss→https.- model_
from_ json modelFromJSON:session.model, elsemodel, trimmed; empty when Go’s decode intostruct{Model; Session struct{Model}}fails at all.- normalize_
client_ secret_ session normalizeClientSecretSession: the session shown to the client and the one sent upstream (Codex model), both as Go’smap[string]anymarshals them.- prepare
prepareCallRequest: multipart SDP + session becomes{"sdp","session"}JSON; any other body passes through with its model (defaultgpt-live-1-codex).- protocol_
headers protocolHeaders: the forwarded client headers, canonical names, every value.- read_
limited readLimitedBody: at mostMAX_BODYbytes, keeping what arrived on error.- redact_
sdp - A request log copy of a live body without SDP ICE credentials: each
a=ice-ufrag:anda=ice-pwd:value becomes[REDACTED], whether the SDP is raw, a multipart field or a JSON string. Go logs these bodies unchanged. - replace_
sdp replaceCallRequestSDP: the relay’s own offer replaces the client’s.- request_
sdp callRequestSDP: the client’s offer, for the media relay.- response_
sdp callResponseSDP: the upstream answer, JSON-wrapped or raw.- rewrite_
model rewriteCallRequestModel: the upstream model replacessession.model, or a top-levelmodelwhen there is no session. Returns the upstream model.- session_
response realtimeSessionResponse: the client session withid,objectandexpires_at.- session_
update realtimeSessionUpdate: the key’s session minus the fields asession.updatemay not carry.- sideband_
url buildSidebandURL.- valid_
call_ id callIDPattern:^[A-Za-z0-9_-]{1,128}$.