UNPKG

assistant-stream

Version:

Streaming utilities for AI assistants

26 lines (25 loc) • 736 B
import { createSSEEventDecoder } from "./SSEEventDecoder.js"; // src/core/utils/stream/SSEEventDecoderStream.ts var SSEEventDecoderStream = class extends TransformStream { constructor(options = {}) { const decoder = createSSEEventDecoder({ ...options, trailing: "drop" }, options.stopAfter); const normalize = (event) => ({ ...event, event: event.event || "message" }); super({ transform(chunk, controller) { for (const event of decoder.push(chunk)) controller.enqueue(normalize(event)); }, flush(controller) { const event = decoder.flush(); if (event) controller.enqueue(normalize(event)); } }); } }; export { SSEEventDecoderStream }; //# sourceMappingURL=SSEEventDecoderStream.js.map