Member Junction
    Preparing search index...

    Interface IxAIRealtimeConnection

    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 extends OpenAIRealtimeEmitter): the driver only ever uses on, off, send, and close. 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 IOpenAIRealtimeConnection because 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.

    interface IxAIRealtimeConnection {
        socket?: { addEventListener(type: "close", listener: () => void): void };
        close(props?: { code: number; reason: string }): void;
        off(event: "event", listener: (event: RealtimeServerEvent) => void): void;
        off(event: "error", listener: (error: OpenAIRealtimeError) => void): void;
        on(event: "event", listener: (event: RealtimeServerEvent) => void): void;
        on(event: "error", listener: (error: OpenAIRealtimeError) => void): void;
        send(event: RealtimeClientEvent): void;
    }
    Index

    Properties

    Methods

    Properties

    socket?: { addEventListener(type: "close", listener: () => void): void }

    Optional 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.

    Methods

    • Removes a previously-registered listener. See IxAIRealtimeConnection.on re: return type.

      Parameters

      • event: "event"
      • listener: (event: RealtimeServerEvent) => void

      Returns void

    • Removes a previously-registered error listener.

      Parameters

      • event: "error"
      • listener: (error: OpenAIRealtimeError) => void

      Returns void

    • 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.

      Parameters

      • event: "event"
      • listener: (event: RealtimeServerEvent) => void

      Returns void

    • 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.

      Parameters

      • event: "error"
      • listener: (error: OpenAIRealtimeError) => void

      Returns void