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 data → AgUiEvent.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
dataJSON (a FormatException fromjsonDecode, or a payload that is not a JSON object) surfaces asProtocolError(protocolMalformed)on the stream — the FR-A11 wire-sanity boundary, the same mappingDefaultErrorClassifierapplies to a FormatException. - Well-formed JSON carrying an unrecognized
typeis not an error: it deserializes toUnknownAgUiEventvia the totalAgUiEvent.fromWire(FR-A6). The one-line rule:jsonDecodefailing is aProtocolError;fromWireof 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< bytes) → Stream<int> >AgUiEvent> -
Decodes
bytes(atext/event-streambyte stream) into the typedAgUiEvents it carries, in wire order. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited