OptionalsocketOptional raw WebSocket surface (present on the real OpenAIRealtimeWebSocket, which exposes
its underlying socket). Used solely to detect UNEXPECTED closure — the SDK emitter has no
close event of its own. The driver feature-detects; fakes may omit it.
Closes the underlying socket.
Optionalprops: { code: number; reason: string }Removes a previously-registered listener. See IxAIRealtimeConnection.on re: return type.
Removes a previously-registered error listener.
Registers a listener for a server event type ('event' for the catch-all firehose).
Return type is void because the driver never uses the chained return value, even though the
SDK's EventEmitter returns this for chaining. A void-returning method is assignable from a
value-returning one, so a real OpenAIRealtimeWebSocket still satisfies this interface.
Registers a listener for connection errors. The SDK routes BOTH transport-level failures
(socket error, unparseable frame, failed send — error.error is undefined) and provider
error server frames (error.error carries the payload) through this channel; the driver
classifies fatality from that distinction.
Sends a client event to the realtime API.
Minimal connection surface the xAIRealtime driver depends on.
This is the injectable seam for testing. It is a structural subset of the SDK's
OpenAIRealtimeWebSocket(which extendsOpenAIRealtimeEmitter): the driver only ever useson,off,send, andclose. Because the driver creates its connection through the overridable OpenAIRealtime.createConnection method, unit tests subclass the driver and return a fake connection implementing this interface — no network and no real WebSocket.The shape is structurally identical to the OpenAI provider's
IOpenAIRealtimeConnectionbecause Grok Voice speaks the same wire protocol; it is redeclared here (not re-exported from the OpenAI provider) to keep this package's public surface self-contained per the no-re-exports rule — structural typing makes the two interchangeable.