Skip to content

🤖 Open-source, local-first alternative to Grok Bot, OpenAI dots and Claude Duet. Your own AI bots on any model: GPT, Claude, Gemini, Grok, DeepSeek, Kimi, GLM and 70+ more through one Modelflare key. Reach them in the app, WeChat or Feishu; they remember you, work in the background, run commands and use your computer. Pay per use.

docs: who can use a bot, and how replies survive restarts

Marla83f19a4842b7
diff --git a/README.md b/README.md
index 728ba9d..267209d 100644
--- a/README.md
+++ b/README.md
@@ -240,6 +240,8 @@ docker exec amb cat /data/ui-token # 然后打开 http://<主机>:3600/?token=
## 🔒 本地优先,也好看
- **数据留在你手里。** 对话、记忆、文件和 API Key 都存放在你的设备上。本地控制台只监听 `127.0.0.1`,桌面版每次启动都会生成新的访问令牌。
+- **只听主人的。** 机器人默认只回应主人(扫码登录的微信、你在应用里设的飞书主人)和你允许的人。其他人发消息只会收到一句提示,不会调用模型;你在信息面板里,或在聊天里回复「同意 编号」放行。
+- **回复不会丢。** 回复先存到本地再发;网络断了会自动重试,应用重启后接着发,发不出去的会在信息面板里告诉你原因。
- **遥测保持关闭。** 内置电脑操作驱动的遥测已关闭,内置网关以关闭自动更新的方式运行。
- **浅色、深色或跟随系统。** 六个机器人角色,眼睛会跟着你的鼠标转。
- **托盘与开机自启。** 关闭窗口会收到托盘;macOS 和 Windows 支持开机自启。
diff --git a/README_en.md b/README_en.md
index ae9ce65..393ce9c 100644
--- a/README_en.md
+++ b/README_en.md
@@ -240,6 +240,8 @@ A bot is more than a chat window: it has a persona, a default model, its own wor
## 🔒 Local-first, and easy on the eyes
- **Your data stays with you.** Conversations, memory, files and API keys are stored on your device. The local console listens on `127.0.0.1` only, and the desktop app generates a fresh access token on every launch.
+- **It answers to you.** By default a bot replies only to its owner (the WeChat account that scanned the QR code, or the Feishu user you mark as owner) and the people you allow. Anyone else gets a one-line notice and no model is called; you let them in from the info panel, or by replying `yes <code>` in chat.
+- **Replies are not lost.** A reply is saved locally before it is sent; network errors are retried, sending resumes after a restart, and anything that cannot be delivered is listed in the info panel with the reason.
- **Telemetry kept off.** Telemetry in the bundled computer-use driver is switched off, and the built-in gateway runs with auto-update disabled.
- **Light, dark or follow the system.** Six bot characters, and their eyes follow your pointer.
- **Tray and autostart.** Close the window to hide to the tray; autostart is available on macOS and Windows.
diff --git a/docs/development.md b/docs/development.md
index 2ad316b..0f755d3 100644
--- a/docs/development.md
+++ b/docs/development.md
@@ -12,7 +12,7 @@
```
src/
- core/ 统一消息类型、会话队列与去重、运行时(/model /reset、流式)、重启后的提醒
+ core/ 统一消息类型、会话队列与去重、运行时(/model /reset、流式)、重启后的提醒、准入(主人 + 允许名单)、持久化出站队列
agent/ 代理模式:DSH 宿主与桥接、审批、权限预设、记忆与上下文管家、生图 / 生视频、电脑操作、Windows PowerShell
prompts/ 交给代理模型的全部提示词:人设、聊天规则、记忆说明、每段第一条消息、技能说明
llm/ OpenAI 兼容客户端(模型接入接口)
@@ -106,7 +106,7 @@ docker exec amb cat /data/ui-token # 打开 http://<主机>:3600/?token=<令
## 界面
- 侧栏:机器人列表(头像 + 名称 + 最近一条消息),+ 新建,右键 重命名 / 删除;左下角账户按钮打开设置(`⌘/Ctrl+,`)。
-- 对话页:顶部悬浮的机器人名称胶囊打开信息面板(`⌘/Ctrl+⇧+I`:渠道、待审批、记忆、最近会话,⚙ 进机器人设置);回复流式显示(Markdown、代码块一键复制),可随时停止(`Esc`);审批与提问以卡片形式出现在对话里;向上翻阅时不会被拉回底部。
+- 对话页:顶部悬浮的机器人名称胶囊打开信息面板(`⌘/Ctrl+⇧+I`:渠道、使用请求、待审批、没发出去的消息、记忆、最近会话,⚙ 进机器人设置);回复流式显示(Markdown、代码块一键复制),可随时停止(`Esc`);审批与提问以卡片形式出现在对话里;向上翻阅时不会被拉回底部。
- 命令面板 `⌘/Ctrl+K`;外观(跟随系统 / 浅色 / 深色)在 设置 → 常规。
- 视觉:中性色与组件改编自 magpie 的界面(MIT),强调色为 Modelflare 荧光黄绿 `#d7ff00`。设计系统说明见 `ui/design/README.md`。
@@ -129,6 +129,24 @@ docker exec amb cat /data/ui-token # 打开 http://<主机>:3600/?token=<令
- **完全权限**:给熟悉风险、嫌审批太多的用户。命令**不经沙箱**,以你的用户身份直接运行,越界操作不再请求批准——它可以读取和修改你电脑上的任何文件,包括 AnyModelBot 自己的数据目录(数据库、渠道令牌、密钥)。只有**递归删除**仍会先问你(同一套审批:微信回复编号、飞书 / 网页卡片):`rm -r` / `-rf` / `--recursive`(含 `sudo`、`xargs`、`sh -c` 里的)、`find -delete`、`git clean`、`rsync --delete`,PowerShell 的 `Remove-Item` / `rm` / `del` / `rd` / `rmdir` 加 `-Recurse`(及其缩写),cmd 的 `rd /s`、`del /s`,`robocopy /MIR`,以及 Python `shutil.rmtree`、Node `fs.rm(…, { recursive })` 等常见写法;命令里点名的脚本文件也会检查。选它时界面会先弹出确认,权限胶囊和设置页用红色标出。
- 这是防误删的保险,不是安全边界:检查的是命令文字,运行时才拼出来的命令(`eval "$(…)"`、`curl … | sh`)和 `make clean`、`npm run clean` 这类构建脚本看不到;拿不准时宁可多问。只在你信任当前模型和任务时开启。
+## 谁能使用机器人
+
+代理跑在你自己的电脑上(甚至可能是完全权限),所以默认**只有主人和你允许的人**能和机器人对话,每个机器人、每个渠道分开算(`src/core/access.ts`):
+
+- **主人**:微信是扫码登录的那个微信;飞书在应用里设——第一个给机器人发消息的人会出现在信息面板的「使用请求」里,点「设为主人」(多半就是你自己)。本机的网页对话不受限制。
+- **其他人**发消息:只收到一句「你还没有被允许使用这个机器人,已通知主人」(同一个人每小时最多一次),不进队列、不调用模型、不花钱。请求出现在信息面板(允许 / 拒绝),也会带 4 位配对码发给主人(每个机器人每小时最多 3 条;主人 24 小时内在那个渠道说过话才发得出去),主人在聊天里回复「同意 1234」/「拒绝 1234」即可。配对码不会和工具审批的编号撞。被拒绝的人之后发什么都不回。
+- 允许名单在 机器人设置 → 谁能使用 里,可以移除(移除后他再发消息会重新申请);`/status` 也会显示。
+- 升级时,已经和机器人有单聊会话的人自动加入允许名单(标为「升级前已在使用」),不会被拦在外面;换一个微信重新扫码时,原来的主人也留在名单里。
+- 群聊:目前没有渠道接入群聊(飞书只处理单聊,微信 iLink 没有群),群消息不受名单限制、保持原样;接入群聊时要在 `access.ts` 里补规则。
+
+## 消息不会丢
+
+最终回复、交付的文件、审批提示和通知先写进本地数据库的出站队列再发送(`src/core/outbox.ts`;流式卡片的中间内容和“正在输入”除外):
+
+- 同一会话按顺序一条一条发;网络或平台临时出错时自动重试(5 秒起,逐步拉长到 5 分钟),渠道没连上时等它连上。
+- 应用退出或崩溃后,重启时接着发,已经发出去的不会再发(长回复分段发,从没发的那段接着发)。每条消息的 id 由收到的那条消息推出来,同一条消息被平台重复投递也只有一个最终回复;只有恰好在发送途中崩溃的那一段可能再发一次——它带着固定的飞书 `uuid`(飞书 1 小时内去重)和微信 `client_id`。
+- 再也发不出去的(微信对方超过 24 小时没说话、本轮 10 条配额用完、等待超过一天、平台多次拒绝)标记出来并写明原因,显示在信息面板的「没发出去的消息」里,也记在诊断信息里。
+
## 电脑操作(Computer Use)
每个机器人可在 机器人设置(信息面板的 ⚙)→ 电脑操作 中开关、选择后端和审批方式;`/status` 与设置页会显示当前后端、是否可用及原因。
diff --git a/docs/development_en.md b/docs/development_en.md
index 70cc113..ea6ddb4 100644
--- a/docs/development_en.md
+++ b/docs/development_en.md
@@ -12,7 +12,7 @@ This guide is for people who want to run AnyModelBot from source, package it, or
```
src/
- core/ shared message types, session queue and dedup, runtime (/model /reset, streaming), the notice after a restart
+ core/ shared message types, session queue and dedup, runtime (/model /reset, streaming), the notice after a restart, admission (owner + allowlist), durable outbox
agent/ agent mode: DSH host and bridge, approvals, permission presets, memory and context steward, image / video generation, computer use, Windows PowerShell
prompts/ every prompt the agent model reads: persona, chat rules, memory guide, a segment's first message, skills
llm/ OpenAI-compatible client (model access interface)
@@ -106,7 +106,7 @@ Inside the container the console listens on 0.0.0.0, so token access is enforced
## Interface
- Sidebar: bot list (avatar + name + latest message), + New, right-click to rename / delete; the account button at the bottom-left opens Settings (`⌘/Ctrl+,`).
-- Chat screen: the floating bot-name pill at the top opens the info panel (`⌘/Ctrl+⇧+I`: channels, pending approvals, memory, recent sessions; ⚙ opens bot settings). Replies stream in (Markdown, one-click copy for code blocks) and can be stopped at any time (`Esc`). Approvals and questions appear as cards in the chat. Scrolling up is never yanked back to the bottom.
+- Chat screen: the floating bot-name pill at the top opens the info panel (`⌘/Ctrl+⇧+I`: channels, requests, pending approvals, undelivered messages, memory, recent sessions; ⚙ opens bot settings). Replies stream in (Markdown, one-click copy for code blocks) and can be stopped at any time (`Esc`). Approvals and questions appear as cards in the chat. Scrolling up is never yanked back to the bottom.
- Command palette `⌘/Ctrl+K`; appearance (system / light / dark) is in Settings → General.
- Visuals: neutrals and components are adapted from magpie's UI (MIT); the accent is Modelflare's fluorescent yellow-green `#d7ff00`. The design system is described in `ui/design/README.md`.
@@ -129,6 +129,24 @@ In agent mode each bot has a file permission preset. Switch it with the permissi
- **Full access**: for users who understand the risk and find approvals too frequent. Commands run **without a sandbox**, directly as your user, and out-of-bounds actions no longer ask — it can read and change any file on your computer, including AnyModelBot's own data directory (database, channel tokens, keys). Only **recursive deletes** still ask first (same approval flow: reply with a number on WeChat, cards on Feishu / web): `rm -r` / `-rf` / `--recursive` (including inside `sudo`, `xargs`, `sh -c`), `find -delete`, `git clean`, `rsync --delete`, PowerShell `Remove-Item` / `rm` / `del` / `rd` / `rmdir` with `-Recurse` (and abbreviations), cmd `rd /s`, `del /s`, `robocopy /MIR`, plus common forms such as Python `shutil.rmtree` and Node `fs.rm(…, { recursive })`; script files named in the command are checked too. Choosing it shows a confirmation first, and the permission pill and settings page mark it in red.
- This is a guard against accidental deletion, not a security boundary: it inspects the command text, so commands assembled at runtime (`eval "$(…)"`, `curl … | sh`) and build scripts such as `make clean` or `npm run clean` are invisible to it; when in doubt it asks. Only enable it when you trust the current model and task.
+## Who can use a bot
+
+The agent runs on your own computer (possibly with full access), so by default **only the owner and people you allow** can talk to a bot, per bot and per channel (`src/core/access.ts`):
+
+- **Owner**: on WeChat, the account that scanned the QR code; on Feishu you set it in the app: the first person who messages the bot shows up under "Requests" in the info panel, click "Make owner" (usually that is you). The local web chat is never restricted.
+- **Anyone else** gets a single line, "you are not allowed to use this bot yet, the owner has been told" (at most once an hour per person); the message is not queued, no model is called and nothing is spent. The request shows in the info panel (allow / deny) and is sent to the owner with a 4-digit pairing code (at most 3 per bot per hour, and only if the owner spoke on that channel in the last 24 hours); the owner replies `同意 1234` / `拒绝 1234` (or `yes 1234` / `no 1234`) in chat. Pairing codes never collide with tool-approval codes. People who were denied get no reply at all.
+- The allowlist is in Bot settings → Who can use; entries can be removed (they can ask again by sending a message). `/status` shows it too.
+- On upgrade, everyone who already had a direct conversation with a bot is put on its allowlist (marked "used before the upgrade"), so nobody is cut off; re-scanning with another WeChat account keeps the previous owner on the list.
+- Group chats: no channel delivers them today (Feishu handles direct messages only, WeChat iLink has no groups), so group messages are left as they were; rules go into `access.ts` when a channel adds groups.
+
+## Replies are not lost
+
+Final replies, delivered files, approval prompts and notices are written to an outbox in the local database before they are sent (`src/core/outbox.ts`; streaming card updates and the typing indicator are not):
+
+- Messages to one conversation go out one at a time, in order. Network or platform errors are retried (from 5 s, backing off to 5 min); a channel that is offline is waited for.
+- After the app quits or crashes, it carries on at the next start, and what was already sent is not sent again (a long reply resumes from the first unsent part). Ids are derived from the incoming message, so a message the platform delivers twice still gets one final reply; only the part that was in flight at the moment of a crash may go out twice, and it carries a fixed Feishu `uuid` (Feishu dedupes for an hour) and WeChat `client_id`.
+- Messages that can no longer be sent (on WeChat the person has not written for 24 hours or the 10-message quota is used up; waiting for more than a day; repeated platform rejections) are marked with the reason, listed in the info panel under "Undelivered messages", and included in the diagnostics.
+
## Computer use
Each bot can turn computer use on or off, choose a backend and an approval mode in Bot settings (⚙ in the info panel) → Computer use; `/status` and the settings page show the current backend, whether it is available, and why not.
diff --git a/docs/privacy.md b/docs/privacy.md
index 2bb8209..8ed7457 100644
--- a/docs/privacy.md
+++ b/docs/privacy.md
@@ -27,6 +27,8 @@
| API Key | 内置网关的隔离配置 `magpie/config/` | 每次模型请求作为鉴权发给 Modelflare | Modelflare |
| 微信登录态与同步游标 | 数据目录内(`weixin/` 等) | 与微信 iLink 接口通信时会 | 腾讯微信 |
| 飞书 App ID / Secret | 数据目录内的配置 | 与飞书开放平台建立长连接时会 | 飞书 |
+| 允许名单与使用请求 | `anymodel.db`:谁能用哪个机器人、陌生人发来的第一条消息(截断,帮你认出是谁) | 不会 | — |
+| 待发送的回复 | `anymodel.db` 的出站队列:没发出去的消息内容和原因(发出去的留 7 天、发不出去的留 30 天后删除) | 发送时会 | 微信 / 飞书 |
| 设置 | `config.json` | 不会 | — |
| 日志 | `logs/app.log`(按大小轮转) | 不会;「复制诊断信息」由你手动复制,密钥已替换成 `***` | — |
| 屏幕截图(电脑操作) | 不长期保存 | 会 | 作为模型请求的一部分,经 Modelflare 发给支持视觉的模型;不会转发到微信或飞书聊天,除非你要求作为文件发送 |
@@ -77,6 +79,7 @@
## 渠道
- 你在微信、飞书里和机器人收发的消息,会经过腾讯、飞书的服务器,受这两个平台各自的隐私政策约束。
+- 默认只有主人和你允许的人能和机器人对话;其他人发来的消息不会交给模型,只登记成使用请求(见 [开发文档](./development.md#谁能使用机器人))。
## 如何删除数据
diff --git a/docs/privacy_en.md b/docs/privacy_en.md
index d707ce9..865e73d 100644
--- a/docs/privacy_en.md
+++ b/docs/privacy_en.md
@@ -27,6 +27,8 @@ This document explains what AnyModelBot stores where, what leaves your device, a
| API key | The gateway's isolated config in `magpie/config/` | As authentication on every model request to Modelflare | Modelflare |
| WeChat sign-in state and sync cursor | Inside the data directory (`weixin/` and others) | When talking to the WeChat iLink API | Tencent WeChat |
| Feishu App ID / Secret | Configuration inside the data directory | When opening the long connection to the Feishu Open Platform | Feishu |
+| Allowlist and access requests | `anymodel.db`: who may use which bot, and the first message a stranger sent (truncated, so you can tell who it is) | No | — |
+| Replies waiting to be sent | `anymodel.db` outbox: unsent message content and the reason (sent ones are deleted after 7 days, undeliverable ones after 30) | When they are sent | WeChat / Feishu |
| Settings | `config.json` | No | — |
| Logs | `logs/app.log` (rotated by size) | No; "Copy diagnostics" is something you copy by hand, with keys replaced by `***` | — |
| Screenshots (computer use) | Not kept long-term | Yes | Sent as part of the model request through Modelflare to a vision-capable model; never forwarded to WeChat or Feishu chats unless you ask for them as files |
@@ -77,6 +79,7 @@ Besides model requests, the app goes online to:
## Channels
- Messages you exchange with a bot on WeChat or Feishu pass through Tencent's or Feishu's servers and are subject to those platforms' privacy policies.
+- By default only the owner and people you allow can talk to a bot; messages from anyone else are not given to a model, only recorded as access requests (see the [developer guide](./development_en.md#who-can-use-a-bot)).
## Deleting your data