SseParser class final

The wire→domain boundary of koel_http: a hand-rolled, dependency-free SSE parser that turns a raw byte stream into a typed AgUiEvent stream (AR-8).

parse does the whole job — UTF-8 stream decode (BOM-stripped) → RFC 8895 / WHATWG text/event-stream framing → jsonDecode of each frame's accumulated dataAgUiEvent.fromWire. The SSE frame (the event/data/ id/retry fields) is an internal intermediate; it is never exported, and AG-UI's event type lives in the JSON data payload's type, not the SSE event: line.

Error contract (two-sided):

  • Corrupt data JSON (a FormatException from jsonDecode, or a payload that is not a JSON object) surfaces as ProtocolError(protocolMalformed) on the stream — the FR-A11 wire-sanity boundary, the same mapping DefaultErrorClassifier applies to a FormatException.
  • Well-formed JSON carrying an unrecognized type is not an error: it deserializes to UnknownAgUiEvent via the total AgUiEvent.fromWire (FR-A6). The one-line rule: jsonDecode failing is a ProtocolError; fromWire of a parsed map is never an error.

Stateless and const — all per-call state lives inside parse's generator, so one instance is safely shared across concurrent streams.

Constructors

SseParser()
Const default constructor; the parser holds no per-call state.
const

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
parse(Stream<List<int>> bytes) Stream<AgUiEvent>
Decodes bytes (a text/event-stream byte stream) into the typed AgUiEvents it carries, in wire order.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited