Docs / utilities / processSSEStream

processSSEStream

utility

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

ParamTypeNotesDescription
responseResponserequiredA streaming fetch Response from an agent stream.
callbacks.onContent(text: string) => voidCalled for each content chunk.
callbacks.onToolStart(tool) => voidCalled when the agent starts a tool.
callbacks.onDone() => voidCalled when the stream completes.

Returns

FieldTypeDescription
resultPromise<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.