First-class multi-tenant runtime for per-connection bots

オープン
#563 コメント 2 件 リアクション 1 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
30/100
issue の種類
機能追加
明瞭さ
説明が足りない
活発さ
静か
技術スタック
typescript
領域
api, backend

調査の方向性

まず github.com/delphi-ai/multi-tenant-chat のリファレンス実装を読み、SDK の webhook および Chat runtime のエントリーポイントと比較します。webhook ごとに接続が解決され、runtime が認証情報と状態を分離し、handler が接続コンテキストを受け取り、LRU eviction がテストでカバーされれば、作業は完了です。

索引モデルが issue の本文から書いたものです。

説明

enhancement
Problem Statement

The Chat SDK assumes one bot identity and one credential set per process. In a SaaS product, each customer connects their own Telegram bot, SMS number, or WhatsApp sender. We need many isolated bot runtimes on shared webhook routes without running one process per connection.

Proposed Solution

Add a built-in multi-tenant mode (or official helper) that:

  1. Resolves a connection from platform + connectionKey on each webhook
  2. Lazily creates a Chat instance per connection with its own adapter credentials
  3. Prefixes shared state keys so thread/subscription state does not collide
  4. Exposes connection context in message handlers (e.g. via AsyncLocalStorage)
  5. Caches runtimes with LRU eviction

Handlers would receive (ctx, thread, message) where ctx.connection identifies the tenant.

Alternatives Considered
  • One global Chat and swap credentials per request: not safe for concurrent webhooks
  • One Chat singleton per connection: too much memory at scale
  • External wrapper package: works today, but belongs in the SDK long term

We ship option 3 as @delphi-ai/multi-tenant-chat until upstream support exists.

Use Case

Priority

Critical

Contribution
  • I am willing to help implement this feature
Additional Context

We already built and use this pattern. Reference implementation: https://github.com/delphi-ai/multi-tenant-chat.

主要言語
TypeScript
スター
2.5k
フォーク
355
平均マージ
2日 15時間
マージ済み PR(30日)
42

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

vercel/chat のほかの issue

vercel/chat の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。