bewinxed/river.ts/river-ts
Claude Code and agent skill by bewinxed/river.ts
- community
Checking that the SKILL.md file is still in the repository.
Type-safe Server-Sent Events (SSE) and WebSocket communication using river.ts library. Use when working with this codebase to: (1) Define typed event schemas with RiverEvents builder, (2) Implement SSE streaming on server with RiverEmitter, (3) Consume SSE streams on client with RiverClient, (4) Handle WebSocket communication with RiverSocketAdapter, (5) Implement request/response RPC patterns over WebSocket, (6) Work with chunked/streamed data events.
Install
npx vskill@latest install bewinxed/river.ts/river-tsSKILL.md
Quick Reference
river.ts provides three main components:
RiverEvents- Type-safe event schema builderRiverEmitter- Server-side SSE streamingRiverClient- Client-side SSE consumptionRiverSocketAdapter- WebSocket message handling with request/response support
Event Definition
Define events using the builder pattern:
Reserved event types: close, error - do not define these.
schema and responseSchema accept any Standard Schema (zod, valibot, arktype; https://standardschema.dev). Events without one are type-checked only.
Server-Side SSE (RiverEmitter)
Resumable streams. All options are optional:
Event ids are string | number and may be non-ASCII: stream() decodes the Last-Event-ID header as UTF-8, so the callback gets the id as it was emitted. For stream: true events the id is written after the last chunk.
Client-Side SSE (RiverClient)
Client options (all optional; reconnect is off by default):
Reconnect rules:
- Retries: network errors, 5xx, 429, and a stream that ends without a
closeevent. - Stops for good: HTTP 204, other 4xx,
client.close(), the server'scloseevent. - Delay:
Retry-After(429/503), else the server'sretry:value, else exponential backoff with jitter, capped atmaxDelay. - Every reconnect sends
Last-Event-ID(fetch path). A GET with no headers at all (none ininit(), none inprepare()) uses the browserEventSource, which reconnects and resumes by itself; any header, another method or an initiallastEventIdselectsfetch.
The parser follows the WHATWG event-stream rules: CRLF/LF/CR line endings, : comments, event/data/id/retry fields, multiple data: lines joined with \n, default type message. Event data must be JSON.
WebSocket Adapter (RiverSocketAdapter)
Runtime validation (events with a schema):
handleMessage()validatesdataagainst the event'sschema; an invalid message goes toonInvalidand is not dispatched. WithoutonInvalidit is logged withconsole.warn.request()validates the response againstresponseSchema(orschemawhen the event has neitherresponseSchemanor aresponsetype) and rejects withInvalidMessageError(.type,.issues) when invalid.- Handlers receive the schema's output. Async schemas are supported and arrival order is kept.
RiverClientdoes the same for thedatafield of incoming SSE events.
WebSocket Request/Response Pattern
For RPC-style communication with automatic type inference:
Wire format for request/response:
Key Types
Project Structure
Verification
There are no unit tests. Check a change with bunx tsc --noEmit, bun run build, and a live run against a real server.
Build and release
Build with: npm run build (uses unbuild)
Output goes to dist/ with separate entry points for /client, /server, /websocket.
Release by bumping the version in package.json and pushing to main: .github/workflows/publish.yml typechecks, builds and publishes to npm when the registry does not have that version yet. A prerelease version (one containing -, such as 1.3.0-test.1 from npm run bump:test) is published under the test dist-tag; any other version becomes latest. The workflow is the only publisher.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingSKILL.md
Popularity
- Repository stars
- 101
- Repository forks
- 2
- 7-day trend score
- 23
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 18 Mar 2026, 7 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/bewinxed/river.ts/river-ts)