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

@schlessera/brain-ui-server

v0.6.3

Published

brain-kit chat-UI server: Hono app factory, WebSocket turn coordinator, auth (password/passkeys/tailscale/proxy), session catalog, and brain/files/voice routes

Readme

@schlessera/brain-ui-server

The brain-kit chat-UI backend as a library: a Hono app factory that serves the REST API, the authenticated WebSocket, and the agent turn coordinator. The deployment shell owns the process — port, Bun.serve() wiring, SIGTERM, the built client bundle, and the optional PNG/PDF renderer — and injects those pieces through createApp().

Bun-only (bun:sqlite, hono/bun). See engines.

Usage

import { createApp, cancelActiveTurn, closeDb } from "@schlessera/brain-ui-server";

const app = createApp({
  staticRoot: "./client/dist",        // optional: serve a built SPA + fallback
  renderer,                           // optional: { renderPng, renderPdf }
  appName: "Brain UI",                // branding in status copy
  dbPath: process.env.DB_PATH,        // session/passkey SQLite (default ./brain-ui.db)
});

export default {
  port: 3000,
  fetch: app.fetch,
  websocket: app.websocket,
};

One app per process: createApp() configures a process-wide host (WebSocket coordinator, SQLite handle, backend registry) — calling it twice with different options reconfigures the first app rather than creating a second.

What it owns

  • createApp(options) — route mounting order, CORS (split topology via ALLOWED_ORIGINS), the auth guard, and the /ws upgrade (CSWSH origin check
    • cookie/IP auth). Refuses to boot on an unsafe auth configuration.
  • Auth (AUTH_MODE): password (+ passkeys/WebAuthn), tailscale, proxy, none (loopback-only unless explicitly overridden).
  • WebSocket turn coordinator — parallel sessions with per-session turn slots, follow-up queueing, host-owned per-turn timeout/cancellation, and the approval / ask-user / location round-trips. Decomposed into explicit host objects (WsHost, TurnCoordinator, SessionCatalog) under src/ws/.
  • Session catalog — SQLite (WAL) with bundled migrations, applied on first open.
  • Brain routes — search/briefing/stats/list/add plus SSE sync/whatsup, spawning the brain CLI from BRAIN_PATH.
  • Voice — Deepgram token minting and keyterm-cache building from the brain index.
  • Render seamPOST /api/render answers 501 unless the deployment injects a renderer (see @schlessera/brain-render-puppeteer).
  • Model catalog — Anthropic model discovery (via @schlessera/brain-backend-claude) behind GET /api/models, with a server-side hidden set (PUT /api/models/hidden) and a manual POST /api/models/refresh. /api/providers serves the same roster minus the hidden entries; hidden profiles still resolve for sessions pinned to them.

Environment

The package reads the same env contract the brain-ui deployment documents: AUTH_MODE, BRAIN_UI_PASSWORD_HASH, COOKIE_SECRET, TRUST_PROXY, WEBAUTHN_*, BRAIN_PATH, DB_PATH, AGENT_BACKEND, BRAIN_UI_CLAUDE_PROFILES, BRAIN_UI_MODEL_DISCOVERY, BRAIN_UI_MODEL_TTL_HOURS, MAX_CONCURRENT_SESSIONS, DEEPGRAM_API_KEY, VOICE_*, NOMINATIM_*, ALLOWED_ORIGINS. createApp() options win over env where both exist.

Model discovery is on by default and needs no configuration beyond the Claude credential the agent already uses (CLAUDE_CODE_OAUTH_TOKEN or ANTHROPIC_API_KEY). BRAIN_UI_MODEL_DISCOVERY=0 turns it off — leaving the picker to BRAIN_UI_CLAUDE_PROFILES alone — and BRAIN_UI_MODEL_TTL_HOURS (default 24) sets how long a discovered roster is served before a background refresh. It defaults to OFF under a test runner (NODE_ENV=test) so suites don't depend on network access; set the var explicitly to opt in.

Versioning

Versions in lockstep with all @schlessera/brain-* packages.