jac-sv-streaming

Implement SSE streaming endpoints in Jac using generator functions and report stream().

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Standard Jac function endpoints return one buffered response, which fails when an endpoint must deliver incremental results like progress updates, live feeds, or token-by-token output. This Skill provides the exact patterns for streaming Server-Sent Events from Jac endpoints, forwarding streams between services, and consuming them in the browser. ## Core Features & Use Cases - SSE endpoint streaming: Build a nested generator inside a def:pub endpoint and report stream() so each yield leaves the server as one SSE frame the moment it happens. - Service-to-service pass-through: Forward a live remote generator frame-by-frame through a gateway endpoint without buffering, using sv import and re-yielding each chunk. - Browser stream consumption: Read SSE frames with raw fetch and ReadableStream in Jac client code, buffering partial frames and parsing JSON-encoded data: payloads. - Use Case: You need an endpoint that narrates progress of a long-running job to a web UI in real time. Use this Skill to write the streaming endpoint, register it in the entry module, and consume it from the browser without RPC stubs. ## Quick Start Ask the AI to write a Jac streaming endpoint that yields incremental chunks with report stream() and show how to 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 stream responses from a Jac function endpoint?▼

Define a nested generator inside a def:pub endpoint whose return type is Generator, then call report stream() instead of return. Each yield is sent immediately as one SSE frame, and the stream closes with an event: end frame.

How to consume a streaming endpoint in the browser with Jac?▼

RPC stubs cannot consume streams, so use a raw fetch against /function/<name> and read frames from resp.body.getReader(). Buffer chunks, split on blank-line separators, and JSON.parse each data: payload, accumulating into a local variable before assigning reactive state.

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 the route.

Can I forward a stream between two Jac server modules?▼

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

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

Buffering happens when the endpoint uses return instead of report stream(), the return type is not Generator, or the caller collapses the generator with list(). The gateway endpoint must itself report a generator to preserve incremental delivery.