Pixir.Provider.WebSocketClient (pixir v0.1.12)

Copy Markdown View Source

Minimal Responses WebSocket client used by the production Provider connection.

The client intentionally emits the data-only SSE-shaped chunks that the default ChatGPT/Codex reducer already knows how to fold. This keeps that model-event parser in one place while the connection process owns socket lifetime and continuation state. Profiles that require a named event: field must not enable this transport until the adapter projects the JSON type into a matching event name; the initial strict open_responses profile is therefore gated to HTTP/SSE by ResponsesBackend.

Summary

Types

handshake()

@type handshake() :: %{status: integer() | nil, status_line: String.t()}

socket()

@type socket() :: term()

Functions

close(socket)

@spec close(socket() | nil) :: {:ok, :noop | :closed} | {:error, term()}

connect(endpoint, headers, opts \\ [])

@spec connect(String.t(), [{String.t(), String.t()}], keyword()) ::
  {:ok, socket(), binary(), handshake()} | {:error, map()}

ping(socket)

@spec ping(socket()) :: :ok | {:error, term()}

stream(socket, initial_buffer, payload, acc, fun, opts \\ [])

@spec stream(socket(), binary(), map(), acc, (term(), acc -> acc), keyword()) ::
  {:ok, acc, map()} | {:error, map(), acc}
when acc: term()