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

@delphi-ai/multi-tenant-chat

v0.1.0

Published

Multi-tenant runtime manager for the Vercel Chat SDK

Readme

@delphi-ai/multi-tenant-chat

Multi-tenant runtime manager for the Vercel Chat SDK. Manages per-connection Chat instances with lazy creation, LRU eviction, and AsyncLocalStorage-based connection context.

Install

# From GitHub (until published to npm)
pnpm add github:delphi-ai/multi-tenant-chat

# Peer dependency
pnpm add chat

Usage

import { MultiTenantChat, type ChatConnection } from "@delphi-ai/multi-tenant-chat";

interface MyConnection extends ChatConnection {
  ownerId: string;
}

const manager = new MultiTenantChat<MyConnection>({
  async resolveConnection({ platform, connectionKey, request }) {
    // Look up connection from your database
    return { id: connectionKey, platform, ownerId: "user-123" };
  },

  async resolveCredentials(connection) {
    // Return platform-specific credentials
    return { botToken: "xoxb-..." };
  },

  state: yourStateAdapter,

  platforms: {
    slack: (credentials) => createSlackAdapter(credentials),
    telegram: (credentials) => createTelegramAdapter(credentials),
  },

  async onDirectMessage(ctx, thread, message) {
    await thread.post("Hello from multi-tenant chat!");
  },
});

// In your webhook handler:
export async function POST(request: Request) {
  return manager.handleWebhook(request, {
    platform: "telegram",
    connectionKey: "connection-id",
  });
}

API

MultiTenantChat<T extends ChatConnection>

Main class that manages per-connection Chat instances.

Config:

  • resolveConnection — resolve a connection from platform + key + request
  • resolveCredentials — return credentials for a connection
  • state — a StateAdapter (shared across all connections, keys are auto-prefixed)
  • platforms — map of platform name to adapter factory
  • onDirectMessage / onMention / onSubscribedMessage — message handlers
  • onError — global error handler
  • runtimeCacheMax — max cached Chat instances (default 1000)

Methods:

  • handleWebhook(request, { platform, connectionKey }) — route a webhook to the correct Chat instance
  • destroyRuntime(connectionId) — tear down a cached runtime

getConnection<T>()

Retrieve the current connection from AsyncLocalStorage context (inside a handler).

createPrefixedState(base, prefix)

Wrap any StateAdapter with per-connection key namespacing.

RuntimeCache

LRU cache of live Chat instances with lazy creation and eviction.

License

MIT