jac-sv-streaming

Implements SSE streaming endpoints in Jac using generators, report, and browser fetch consumption.

Updated Jul 26, 2026
One-click install
npx skills add https://github.com/PMN123/trapdoor --skill jac-sv-streaming-pmn123
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: jac-sv-streaming
Source: https://github.com/PMN123/trapdoor/tree/main/.agents/skills/jac-sv-streaming
Command: npx skills add https://github.com/PMN123/trapdoor --skill jac-sv-streaming-pmn123

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Standard Jac endpoints return one buffered response, which fails when results must arrive incrementally. This Skill shows how to build server-sent event (SSE) streaming endpoints in Jac so clients receive each chunk the moment it is produced. ## Core Features & Use Cases - Generator-based streaming endpoints: Define a def:pub endpoint that returns a Generator and uses report stream() so each yield becomes one SSE frame. - Server-to-server pass-through: Forward a remote streaming endpoint frame-by-frame through a gateway without buffering, using sv import and re-yielding. - Browser consumption: Read SSE frames with raw fetch and getReader, buffering partial frames and parsing JSON-encoded data: payloads. - Use Case: Build a live narration or progress feed where a Jac backend streams tokens or status updates to a web client in real time instead of waiting for the full result. ## Quick Start Use the jac-sv-streaming skill to create a streaming Jac endpoint that yields progress updates and consume it from the browser with fetch.

Frequently Asked Questions about jac-sv-streaming

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a streaming endpoint in Jac?▼

Define a def:pub function with a Generator return type, build a nested generator that yields each chunk, and call report stream() instead of return. Each yield is sent immediately as one SSE frame with a JSON-encoded data payload.

How do I consume a Jac SSE stream in the browser?▼

Use a raw fetch POST to /function/<name> and read frames with resp.body.getReader(), since RPC stubs buffer the whole response. Buffer incoming text, split frames on blank lines, and JSON.parse each data: payload.

Why does my Jac streaming endpoint return 404 or 405?▼

A raw-fetch stream has no client RPC stub, so manifest-driven self-registration never sees it. Import the streaming function at the top level of the entry module (main.jac) in server context to register it.

Can I forward a stream between two Jac servers?▼

Yes. When another server module sv imports the provider, calling its streaming endpoint returns a live generator. Iterate over it and re-yield each chunk from your own reported generator for unbuffered frame-in/frame-out forwarding.

Why does my Jac stream arrive as one buffered response?▼

Buffering happens if you use return instead of report stream(), omit the Generator return type, or collapse the stream with list(). The endpoint must report a generator so each yield flushes as its own SSE frame.