npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@rein-ai/server

v1.0.0

Published

HTTP server for the rein platform

Readme

@rein-ai/server

Rein server with artifact persistence (SQLite) and SSE streaming for all connections.

Programmatic API

import { createServer } from "@rein-ai/server";

const server = await createServer({ port: 4800 });
// server.port — actual port (useful if port: 0 was passed)
// server.store — SessionStore instance
// server.createSession(id, project?) — create a session
// server.getSession(id) — get a session by ID
// server.getSessions({ project? }) — list sessions
// server.close() — stop the server

Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | port | number | 0 | Port to listen on (0 = OS-assigned) | | bootstrapTimeout | number | 180000 | Ms before bootstrapping sessions are removed | | store | SessionStore | SQLite | Custom store implementation | | dbPath | string | in-memory | Path to SQLite database file |

HTTP Routes

Sessions

| Method | Path | Description | |--------|------|-------------| | GET | /sessions | List all sessions | | GET | /sessions?project=x | List sessions filtered by project | | GET | /sessions/:id | Get a single session | | POST | /sessions/:id | Create a session | | DELETE | /sessions/:id | Remove a session |

Session record:

{
  "id": "uuid",
  "status": "bootstrapping | live | idle | disconnected",
  "summary": "string | null",
  "project": "string | null",
  "createdAt": 1234567890,
  "lastHeartbeat": 1234567890
}

Commands

| Method | Path | Description | |--------|------|-------------| | POST | /sessions/:id/commands | Send a command to the sandbox |

Command body:

{ "type": "prompt", "text": "fix the bug" }
{ "type": "abort" }

Returns 202 on success, 409 if no sandbox is connected, 404 if session not found.

Events (from sandbox)

| Method | Path | Description | |--------|------|-------------| | POST | /sessions/:id/events | Sandbox posts a ReinEvent |

Event body: Any valid ReinEvent JSON (e.g. { "type": "text_delta", "delta": "..." }).

Returns 202 on success, 404 if session not found. Events are processed through the reducer and published as artifact updates to SSE clients.

Artifacts

| Method | Path | Description | |--------|------|-------------| | GET | /sessions/:id/artifacts | Get all artifacts for a session |

Returns a JSON array of artifact objects ordered by sequence number.

SSE Endpoints

Artifact stream — GET /sessions/:id/stream

Streams artifact events for a single session. On connect, sends the full artifact history as snapshots, then live events.

Reconnection: Send Last-Event-ID header with the last received sequence number. The server resends artifacts from that point.

Events:

| Event | When | Data | |-------|------|------| | artifact_snapshot | On connect (history replay) | { artifact: Artifact } | | artifact_created | New artifact | { artifact: Artifact } | | artifact_updated | Artifact field changed | { seq, field, append?, set? } |

Each event includes an id field set to the artifact's sequence number.

Session stream — GET /sessions/stream

Streams session-level state changes. On connect, sends all current sessions as snapshots, then live events.

Filtering: Add ?project=x to only receive events for sessions matching that project.

Events:

| Event | When | Data | |-------|------|------| | session_snapshot | On connect (one per session) | { session: SessionRecord } | | session_created | New session created | { session: SessionRecord } | | session_updated | Status or summary changed | { id, fields: { status?, summary? } } | | session_removed | Session deleted or timed out | { id } |

Heartbeat-only updates are not broadcast.

Command stream — GET /sessions/:id/commands

SSE endpoint for sandbox (agent) connections. Opening this stream marks the session as "live". Commands sent by clients via POST /sessions/:id/commands are delivered here.

Events:

| Event | When | Data | |-------|------|------| | command | Client sends a command | { type: "prompt", text: "..." } or { type: "abort" } |

Connection lifecycle:

  • Connect: session status → "live"
  • Disconnect: session status → "disconnected" (if was "live" or "idle")
  • If a new sandbox connects while one exists, the old connection is closed

Architecture

Clients (CLI, web)          Sandbox (agent)
      │                           │
      │ SSE + POST                │ SSE + POST
      │                           │
      ▼                           ▼
┌──────────────────────────────────────┐
│              Server                  │
│                                      │
│  HTTP routes    SSE streams          │
│  Reducer        Persistence          │
│                                      │
│         SessionStore (SQLite)        │
│         EventEmitter (pub/sub)       │
└──────────────────────────────────────┘