feat: bot inbox (#77)

* feat: bot inbox

* feat: unified header

* fix: missing tool_call usage

* feat: add group name in header
This commit is contained in:
Acbox Liu
2026-02-22 01:27:24 +08:00
committed by GitHub
parent 2c6b5e5565
commit c591af14b0
42 changed files with 3367 additions and 260 deletions
+15
View File
@@ -121,6 +121,7 @@ CREATE TABLE IF NOT EXISTS bots (
max_context_tokens INTEGER NOT NULL DEFAULT 0,
language TEXT NOT NULL DEFAULT 'auto',
allow_guest BOOLEAN NOT NULL DEFAULT false,
max_inbox_items INTEGER NOT NULL DEFAULT 50,
chat_model_id UUID REFERENCES models(id) ON DELETE SET NULL,
memory_model_id UUID REFERENCES models(id) ON DELETE SET NULL,
embedding_model_id UUID REFERENCES models(id) ON DELETE SET NULL,
@@ -390,3 +391,17 @@ CREATE TABLE IF NOT EXISTS bot_history_message_assets (
CREATE INDEX IF NOT EXISTS idx_message_assets_message_id ON bot_history_message_assets(message_id);
-- bot_inbox: per-bot message inbox for non-mentioned group messages, emails, etc.
CREATE TABLE IF NOT EXISTS bot_inbox (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
bot_id UUID NOT NULL REFERENCES bots(id) ON DELETE CASCADE,
source TEXT NOT NULL DEFAULT '',
content JSONB NOT NULL DEFAULT '{}'::jsonb,
is_read BOOLEAN NOT NULL DEFAULT FALSE,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
read_at TIMESTAMPTZ
);
CREATE INDEX IF NOT EXISTS idx_bot_inbox_bot_unread ON bot_inbox(bot_id, created_at DESC) WHERE is_read = FALSE;
CREATE INDEX IF NOT EXISTS idx_bot_inbox_bot_created ON bot_inbox(bot_id, created_at DESC);
+8
View File
@@ -0,0 +1,8 @@
-- 0011_add_inbox (down)
-- Remove bot_inbox table and max_inbox_items column.
DROP INDEX IF EXISTS idx_bot_inbox_bot_created;
DROP INDEX IF EXISTS idx_bot_inbox_bot_unread;
DROP TABLE IF EXISTS bot_inbox;
ALTER TABLE bots DROP COLUMN IF EXISTS max_inbox_items;
+17
View File
@@ -0,0 +1,17 @@
-- 0011_add_inbox
-- Add bot_inbox table and max_inbox_items setting to bots.
ALTER TABLE bots ADD COLUMN IF NOT EXISTS max_inbox_items INTEGER NOT NULL DEFAULT 50;
CREATE TABLE IF NOT EXISTS bot_inbox (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
bot_id UUID NOT NULL REFERENCES bots(id) ON DELETE CASCADE,
source TEXT NOT NULL DEFAULT '',
content JSONB NOT NULL DEFAULT '{}'::jsonb,
is_read BOOLEAN NOT NULL DEFAULT FALSE,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
read_at TIMESTAMPTZ
);
CREATE INDEX IF NOT EXISTS idx_bot_inbox_bot_unread ON bot_inbox(bot_id, created_at DESC) WHERE is_read = FALSE;
CREATE INDEX IF NOT EXISTS idx_bot_inbox_bot_created ON bot_inbox(bot_id, created_at DESC);