Shared SSE (Server-Sent Events) framing utilities.
Handles the transport-level concerns that are identical across all providers using SSE streaming: byte buffering, event boundary splitting, and field extraction.
Provider-specific event handling is NOT in this module — each provider
(or shared parser like Alloy.Provider.OpenAIStream) pattern-matches
on the parsed events returned here.
Summary
Functions
Process a raw chunk of bytes against a buffer.
Build a Req into: stream handler that accumulates SSE events.
Types
Functions
Process a raw chunk of bytes against a buffer.
Returns {complete_events, remaining_buffer} where each event
is a map with :event (may be nil) and :data keys.
@spec req_stream_handler(map(), (map(), sse_event() -> map())) :: ({:data, String.t()}, {term(), term()} -> {:cont, {term(), term()}})
Build a Req into: stream handler that accumulates SSE events.
The handle_event function receives (accumulator, sse_event) and
returns the updated accumulator. The accumulator must contain a
:buffer key (string) for SSE framing state.
The accumulator is stored in resp.private.sse_acc.