processSSEStream
High-level helper that drives an agent SSE Response through callbacks.
import { processSSEStream } from 'flowstack-sdk'The highest-level streaming helper: pass a streaming Response and a set of callbacks and processSSEStream parses the stream and invokes the matching callback for each event. Use it when you prefer callbacks over manually iterating parseSSEStream.
Signature
await processSSEStream(response, callbacks)Parameters
| Param | Type | Notes | Description |
|---|---|---|---|
response | Response | required | A streaming fetch Response from an agent stream. |
callbacks.onContent | (text: string) => void | — | Called for each content chunk. |
callbacks.onToolStart | (tool) => void | — | Called when the agent starts a tool. |
callbacks.onDone | () => void | — | Called when the stream completes. |
Returns
| Field | Type | Description |
|---|---|---|
result | Promise<void> | Resolves when the stream is fully processed. |
Examples
Process a stream with callbacks
await processSSEStream(response, {
onContent: (text) => appendMessage(text),
onToolStart: (tool) => showToolIndicator(tool),
onDone: () => finalize(),
});See also
parseSSEStream · parseSSELine · useAgent · post-stream
Source: README.md#streaming-utilities · Also available in llms-full.txt and registry.json.