@agentplat/streaming
v1.3.0
Published
Framework-neutral SSE helpers for AgentPlat runtime streams.
Readme
@agentplat/streaming
Server-Sent Events helpers for normalized AgentStreamEvent streams. The
package depends on Web Standards and small structural Node response types; it
does not depend on Next.js, Express or Hono.
Installation (developer preview)
Install the coordinated preview explicitly:
npm install @agentplat/streaming@nextKeep all @agentplat/* packages on the same release version. npm's default
latest tag can point to an older preview. See the
release channels
for distribution status and version selection.
Next.js App Router
import { toNextSseResponse } from "@agentplat/streaming";
return toNextSseResponse(request, (signal) =>
session.stream({ input: scenario, signal }),
);Web Response (Hono and other Fetch-compatible frameworks)
import { streamToSSE } from "@agentplat/streaming";
return streamToSSE(runtime.stream(agent, input, context), {
signal: request.signal,
});Express-style response
import { pipeSSE } from "@agentplat/streaming";
await pipeSSE(runtime.stream(agent, input, context), response);Browser parser
import type { MultiAgentSessionEvent } from "@agentplat/framework";
import { parseAgentSseStream } from "@agentplat/streaming";
for await (const envelope of parseAgentSseStream<MultiAgentSessionEvent>(
response.body,
{ signal },
)) {
// Envelope v1 is parsed and its sequence is validated.
}The wire envelope is versioned and includes a monotonic sequence number. Do not send credentials or secrets in runtime stream event payloads.
For callback-style UI integration, use subscribeAgentSse(response, { onEvent,
onError, signal }). It uses the same parser and rethrows malformed or failed
streams after invoking onError.
