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

loreweaver-protocol

v2.3.1

Published

Typed wire-protocol frames and a reconnecting WebSocket client for Loreweaver, the self-hosted AI Game Master / Keeper (protocol v2.3).

Readme

loreweaver-protocol

Typed frames and a reconnecting WebSocket client for the open, versioned wire protocol of Loreweaver — a self-hosted AI Game Master / Keeper for tabletop RPGs. The package version tracks the protocol version (currently v2.3); the protocol document itself lives at docs/protocol.md.

Install

npm install loreweaver-protocol   # or: bun add loreweaver-protocol

What you get

  • FrameType + every frame shape (ServerFrame / ClientFrame unions): welcome, narrative, dice, ui, state, presence, media/audio, the keeper-gated admin_* family, …
  • WsClient — a small reconnecting WebSocket client with per-type frame validation (malformed frames are dropped, never crash a consumer), typed on(FrameType.X, handler) subscriptions, media upload/download helpers, and auto re-join after a drop. The WebSocket carrier is the loopback/test one; the production carrier is Iroh p2p, which shares these exact frame types.
  • stripControlChars — the terminal-safety sanitizer every Loreweaver client runs over server-supplied text (strips C0/C1 escape introducers).
  • A major-version mismatch warningWsClient compares the welcome frame's protocol against PROTOCOL_VERSION and warns once (naming both versions) when the majors differ, so every client built on this package gets the check for free. The pure helpers behind it — protocolMajor, protocolMismatch, protocolMismatchMessage — are exported for clients that do their own connecting.

Usage

import { FrameType, PROTOCOL_VERSION, WsClient } from "loreweaver-protocol"

const client = new WsClient()
await client.connect("ws://127.0.0.1:8787/")
client.join("your-invite-key")

client.on(FrameType.Narrative, (frame) => console.log(frame.speaker, frame.text))
client.on(FrameType.Dice, (frame) => console.log(frame.expr, frame.total, frame.level))
client.sendInput(".ra Spot Hidden")

Versioning

The major version is the compatibility contract; minors within a major are additive, so clients should ignore unknown server frame types and unknown fields. A different major means the two sides may reject or misread each other's frames, so WsClient says so — loudly, once, through console.warn by default:

const client = new WsClient({
  onProtocolMismatch: (message, { client: mine, server }) => {
    banner(message)            // or refuse the session yourself: client.close()
    console.log(mine, server)  // e.g. "2.1", "3.0"
  },
})

It is a warning, not a refusal: the welcome frame is still delivered and the socket stays open. Hanging up (or not) is your call.

License

MIT — see LICENSE.