EventStreamAdapter class
Adapter for converting streams of SSE messages to typed AG-UI events.
This class provides utilities to:
- Convert SSE message streams to typed event streams
- Handle partial messages and buffering
- Filter and transform events
- Handle errors gracefully
Constructors
- EventStreamAdapter({EventDecoder? decoder, int maxDataCodeUnits = kSseDefaultMaxDataCodeUnits})
- Creates a new stream adapter with an optional custom decoder.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- maxDataCodeUnits → int
-
Maximum number of UTF-16 code units accepted per SSE data block and
per raw-input buffer in fromRawSseStream. Matches
SseParser's default of 8 MiB (8 × 1 048 576 code units) so both SSE paths enforce the same bound. A misbehaving server that streamsdata:without a blank-line terminator can otherwise grow fromRawSseStream's internal buffers without bound.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
adaptJsonToEvents(
dynamic jsonData) → List< BaseEvent> - Adapts JSON data to AG-UI events.
-
fromRawSseStream(
Stream< String> rawStream, {bool skipInvalidEvents = false, void onError(Object error, StackTrace stackTrace)?}) → Stream<BaseEvent> - Converts a stream of raw SSE strings to typed AG-UI events.
-
fromSseStream(
Stream< SseMessage> sseStream, {bool skipInvalidEvents = false, void onError(Object error, StackTrace stackTrace)?}) → Stream<BaseEvent> - Converts a stream of SSE messages to a stream of typed AG-UI events.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
accumulateTextMessages(
Stream< BaseEvent> eventStream, {int maxOpenGroups = 0}) → Stream<String> - Accumulates user-visible text message content into complete messages.
-
filterByType<
T extends BaseEvent> (Stream< BaseEvent> eventStream) → Stream<T> - Filters a stream of events to only include specific event types.
-
groupRelatedEvents(
Stream< BaseEvent> eventStream, {int maxOpenGroups = 0}) → Stream<List< BaseEvent> > - Groups related events together.