AbstractProtecteddoneProtected ReadonlymessageProtected ReadonlyrequestProtectedterminalProtected ReadonlytoDispose this object.
ProtectedhandleDelivers a part to the consumer. Parts arriving after the iterator is done (e.g. from a tool handler that finishes after cancellation or after the consumer abandoned the iteration) are dropped.
NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places.
Terminates the iteration when the consumer abandons it, be it by breaking out of a for await loop or
by that loop exiting with an error. Without this, the producer would keep requesting completions,
executing tool calls and buffering parts that nobody will ever read.
Base class for async iterators that deliver LanguageModelStreamResponseParts produced asynchronously from some upstream source. It implements the producer/consumer queue: subclasses push parts via handleIncoming as they arrive and signal completion by setting terminalError (for failures) and/or calling dispose. Parts produced before the consumer asks for them are buffered, and requests made before parts are available are queued.