bazilion 0.2.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,40 @@
1
+ -- Telegram integration columns. Step 1 of the docs/telegram.md plan adds the
2
+ -- schema only; the bot singleton, polling loop, and routing helpers land in
3
+ -- subsequent steps. None of these columns are populated yet — they sit empty
4
+ -- until the live bot in Step 2 starts persisting topic ids on first traffic.
5
+ --
6
+ -- agents.telegram_topic_id — forum-topic message_thread_id; one topic per
7
+ -- agent. Partial unique index below allows
8
+ -- multiple NULLs (unbound agents) but enforces
9
+ -- one-to-one once an id is written.
10
+ -- agents.telegram_topic_name_locked — sticky bit set when a human renames the
11
+ -- topic in Telegram; once set, bazilion stops
12
+ -- propagating agent/group renames to that topic.
13
+ -- agents.telegram_icon_emoji — per-agent override of the profile-derived
14
+ -- custom-emoji sticker id. Lookup at topic
15
+ -- creation: agents.* → profiles.* → null.
16
+ -- Survives topic delete + recreate, unlike
17
+ -- a customization that only lived in Telegram.
18
+ -- groups.telegram_icon_color — Telegram's 6-color enum slot allocated to
19
+ -- this group on first-traffic. Red is reserved
20
+ -- for the service chat, so groups round-robin
21
+ -- over the remaining 5.
22
+ -- profiles.telegram_icon_emoji — curated default sticker id from
23
+ -- getForumTopicIconStickers, per built-in
24
+ -- profile. Seeded for built-ins, NULL for
25
+ -- custom profiles (which render color-only).
26
+
27
+ ALTER TABLE agents ADD COLUMN telegram_topic_id INTEGER;
28
+ ALTER TABLE agents ADD COLUMN telegram_topic_name_locked INTEGER NOT NULL DEFAULT 0;
29
+ ALTER TABLE agents ADD COLUMN telegram_icon_emoji TEXT;
30
+
31
+ ALTER TABLE groups ADD COLUMN telegram_icon_color INTEGER;
32
+
33
+ ALTER TABLE profiles ADD COLUMN telegram_icon_emoji TEXT;
34
+
35
+ -- Partial unique index: enforces one-to-one mapping between agents and topic
36
+ -- ids without blocking many unbound agents (SQLite treats NULLs as distinct
37
+ -- in unique indexes, but being explicit avoids surprise if that ever changes).
38
+ CREATE UNIQUE INDEX IF NOT EXISTS idx_agents_telegram_topic_id
39
+ ON agents(telegram_topic_id)
40
+ WHERE telegram_topic_id IS NOT NULL;
@@ -0,0 +1,17 @@
1
+ -- Per-agent Telegram outbound-mirror verbosity.
2
+ --
3
+ -- 'minimal' (default): mirror only the assistant's final message text to
4
+ -- the agent's bound forum topic. Cleanest conversation
5
+ -- feel; what most operators want.
6
+ -- 'verbose': also mirror short tool-call summary lines so the
7
+ -- topic shows the agent's reasoning steps. Helpful
8
+ -- while iterating on a misbehaving agent; noisy in
9
+ -- steady state.
10
+ --
11
+ -- The column has no effect on agents without a bound topic. Step 6 picks
12
+ -- the value up when materializing each ChatFrame; Step 7's CLI + web UI
13
+ -- surfaces let operators flip it per-agent.
14
+
15
+ ALTER TABLE agents
16
+ ADD COLUMN telegram_mirror_mode TEXT NOT NULL DEFAULT 'minimal'
17
+ CHECK (telegram_mirror_mode IN ('minimal','verbose'));
@@ -0,0 +1,15 @@
1
+ -- Per-group Telegram forum-topic name template.
2
+ --
3
+ -- NULL (default): bazilion composes topic names the built-in way — bare
4
+ -- agent.name for the `default` group, "<group.slug> › <agent.name>" for every
5
+ -- other group (see lib/telegram/naming.ts:topicNameFor).
6
+ -- Non-NULL: an explicit template rendered with the tokens {agent.name},
7
+ -- {group.name}, {group.slug}. Must contain {agent.name} so each agent in the
8
+ -- group still gets a distinct topic title. Validated on write
9
+ -- (lib/telegram/naming.ts:validateTopicNameFormat).
10
+ --
11
+ -- Changing the template re-renders every bound, non-locked topic in the group
12
+ -- via editForumTopic (lib/telegram/topic-rename.ts:syncGroupTopicNames). Topics
13
+ -- a human has renamed (telegram_topic_name_locked = 1) are left untouched.
14
+
15
+ ALTER TABLE groups ADD COLUMN telegram_topic_name_format TEXT;
@@ -0,0 +1,18 @@
1
+ -- Per-user Telegram allowlist (Phase 7).
2
+ --
3
+ -- Bootstrap model: TOFU (trust-on-first-use). While this table is empty the
4
+ -- bot is open; the first user to message it is auto-added as 'owner' and
5
+ -- enforcement begins immediately after. Scope: FLAT — an allowlisted user can
6
+ -- do everything (commands + agent chat); anyone not on the list is ignored.
7
+ --
8
+ -- role: 'owner' can manage the allowlist (/allow, /deny) and cannot be removed;
9
+ -- 'member' can use the bot but not manage who else can. At least one owner must
10
+ -- always remain (enforced in the repo + routes).
11
+
12
+ CREATE TABLE IF NOT EXISTS telegram_allowed_users (
13
+ user_id INTEGER PRIMARY KEY,
14
+ username TEXT,
15
+ label TEXT,
16
+ role TEXT NOT NULL DEFAULT 'member' CHECK (role IN ('owner','member')),
17
+ added_at INTEGER NOT NULL
18
+ );
@@ -0,0 +1,30 @@
1
+ -- MCP (Model Context Protocol) servers.
2
+ --
3
+ -- Each row is one configured server the daemon connects to as an MCP client.
4
+ -- Tools discovered on it (`tools/list`) are namespaced `mcp__<name>__<tool>`
5
+ -- and injected into agent turns. v0.4.0 scopes servers globally — every agent
6
+ -- sees the tools of every enabled server.
7
+ --
8
+ -- Transports:
9
+ -- stdio — local subprocess (`command` + JSON `args`); inherits the daemon's
10
+ -- merged secrets env, so a server needing e.g. GITHUB_TOKEN picks it
11
+ -- up from the normal secrets table.
12
+ -- http — Streamable-HTTP endpoint at `url`.
13
+ -- sse — SSE endpoint at `url`.
14
+ --
15
+ -- Bearer auth for http/sse is NOT stored here: the token lives in the encrypted
16
+ -- `secrets` table under key `MCP_TOKEN_<id>`; `has_auth` records whether one is
17
+ -- set so the UI/API can show it without decrypting.
18
+
19
+ CREATE TABLE IF NOT EXISTS mcp_servers (
20
+ id TEXT PRIMARY KEY,
21
+ name TEXT NOT NULL UNIQUE,
22
+ transport TEXT NOT NULL CHECK (transport IN ('stdio','http','sse')),
23
+ command TEXT,
24
+ args TEXT NOT NULL DEFAULT '[]',
25
+ url TEXT,
26
+ has_auth INTEGER NOT NULL DEFAULT 0,
27
+ enabled INTEGER NOT NULL DEFAULT 1,
28
+ created_at INTEGER NOT NULL,
29
+ updated_at INTEGER NOT NULL
30
+ );