Documentation Index
Fetch the complete documentation index at: https://docs.m4trix.dev/llms.txt
Use this file to discover all available pages before exploring further.
SSE (Server-Sent Events)
m4trix uses SSE for streaming agent responses to HTTP clients. When agents emit events to a channel withsink.httpStream(), those events are streamed as SSE.
How It Works
- Client sends a POST with a JSON payload.
expose()publishes a start event to the main channel.- Agents run and emit events to the client channel.
- Events are streamed as SSE to the response.
Response Format
Consuming in the Browser
fetch with ReadableStream for POST:
WebSocket
m4trix focuses on SSE (request → stream response). For bidirectional WebSocket, you would need to adapt the event plane or use a separate WebSocket layer. TheuseSocketConversation hook in @m4trix/react can work with WebSocket backends when your server exposes a compatible protocol.
Backpressure
The HTTP stream sink respects backpressure: if the client is slow to consume, the underlying stream will backpressure. For LLM streams, emitting chunk-by-chunk naturally paces the flow.Chunking
When streaming LLM output, emit each token or logical chunk as a separate event:Pump from @m4trix/stream — see Streaming, Sinks & Adapters.