AnyBot: first commit of the working desktop app
Rust/egui rebuild of Grok Bot as of 2026-11-04: chat with streaming
providers (xAI, OpenAI, Claude, Gemini, OpenRouter, OpenCode Go, Ollama,
custom), tools and approvals, the bot's Docker computer, computer use on
macOS / Linux X11 / Wayland, AnyBot's browser with a full DevTools-based
toolset, the encrypted vault, pinned grid and sidebar sections, Markdown
with Mermaid diagrams, phone access through the relay, and the Linux
build and test scripts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha3oEtWeHh58zA7ErHa
2026-11-04 08:51:51 +00:00
|
|
|
|
# AnyBot 帳號伺服器(薄後端)
|
|
|
|
|
|
|
|
|
|
|
|
帳號伺服器是一個很小的程式,放在一台一直開著、有網址的主機上。它負責四件事:
|
|
|
|
|
|
|
|
|
|
|
|
1. **帳號**:帳號和密碼。密碼只存雜湊值。
|
|
|
|
|
|
2. **轉送**:手機打開網址、登入後,伺服器把手機的要求轉給你的 AnyBot。
|
|
|
|
|
|
- 你的 AnyBot 會主動連到伺服器,所以電腦不用開放任何連接埠,也不用固定 IP。
|
|
|
|
|
|
3. **裝置**:記住帳號裡有哪幾台 AnyBot,以及每台在線還是離線。
|
|
|
|
|
|
- 同一個帳號的 AnyBot 可以互相操作(裝置連結)。
|
|
|
|
|
|
4. **備份和通知**:
|
|
|
|
|
|
- 每天收一份加密備份。金鑰由你的密碼產生,伺服器自己打不開。
|
|
|
|
|
|
- Bot 需要你允許、或你不在時做完事,會推播通知到手機。
|
|
|
|
|
|
|
|
|
|
|
|
Bot 的大腦不在帳號伺服器上,而在 AnyBot 裡,所以伺服器很輕,最小的主機就夠用。
|
|
|
|
|
|
|
|
|
|
|
|
## 三種用法
|
|
|
|
|
|
|
|
|
|
|
|
| 用法 | AnyBot 跑在哪 | 手機能做什麼 | 電腦要開著嗎 |
|
|
|
|
|
|
|---|---|---|---|
|
|
|
|
|
|
| A. 只用 Mac | Mac 上的 AnyBot(有視窗) | 聊天、核准、看 Bot 的電腦、看你的 Mac(要先打開) | Mac 要開著、不能睡 |
|
|
|
|
|
|
| B. 一直開著的 Mac | Mac mini 跑 `anybot --serve`(不開視窗) | 同上 | 那台 Mac mini 開著就好 |
|
|
|
|
|
|
| C. 雲端主機 | Linux 主機跑 `anybot --serve` 加上 Bot 的電腦 | 同上,例行任務、觸發、訊息管道 24 小時運作 | 不用;Mac 開著時,Bot 還能透過裝置連結操作你的 Mac |
|
|
|
|
|
|
|
|
|
|
|
|
## 架設帳號伺服器(用法 A、B)
|
|
|
|
|
|
|
|
|
|
|
|
需要準備:
|
|
|
|
|
|
|
|
|
|
|
|
- 一台有 Docker 的小主機;
|
|
|
|
|
|
- 一個網域,DNS 指到這台主機。
|
|
|
|
|
|
|
|
|
|
|
|
步驟:
|
|
|
|
|
|
|
|
|
|
|
|
1. 把整個 `app/` 資料夾放到主機上。
|
|
|
|
|
|
2. 編輯 `relay/Caddyfile`,把 `anybot.example.com` 換成你的網域。
|
|
|
|
|
|
3. 在 `relay/` 資料夾執行 `docker compose up -d`。Caddy 會自動申請並更新 HTTPS 憑證。
|
|
|
|
|
|
4. 手機打開 `https://你的網域`,按「還沒有帳號?建立一個」。
|
|
|
|
|
|
- 第一個帳號一定可以建立。之後要讓別人註冊,在 `docker-compose.yml` 設定 `ANYBOT_RELAY_INVITE` 邀請碼。
|
|
|
|
|
|
5. 在 Mac 上打開 AnyBot › 設定 › 手機與帳號,填伺服器網址、帳號、密碼,按「登入」。
|
|
|
|
|
|
|
|
|
|
|
|
不用 Docker 的話,可以直接編譯成一個執行檔:
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
cd relay && cargo build --release
|
|
|
|
|
|
./target/release/anybot-relay --port 8080 --data /var/lib/anybot-relay
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
這樣啟動之後,前面要再自己接一層 HTTPS,例如 Caddy 或 nginx。
|
|
|
|
|
|
|
|
|
|
|
|
### 環境變數
|
|
|
|
|
|
|
|
|
|
|
|
| 變數 | 用途 |
|
|
|
|
|
|
|---|---|
|
|
|
|
|
|
| `ANYBOT_RELAY_INVITE` | 第二個以後的帳號要填的邀請碼。空白表示不開放註冊 |
|
|
|
|
|
|
| `ANYBOT_RELAY_CONTACT` | 推播服務需要的聯絡方式,例如 `mailto:你@你的網域` 或 `https://你的網域` |
|
|
|
|
|
|
| `ANYBOT_RELAY_PUBLIC_URL` | 對外的網址,例如 `https://anybot.你的網域`。Bot 發布網站後,會拿這個組成網址告訴你 |
|
Bug sweep: gates, relay 2FA, Windows input, snapshots, encodings
Permissions and reach
- a file leaving a computer passes the same questions as reading it;
"looking" shell commands that do more than look ask first
- a symlink out of the work/sealed folder counts as outside it
(real paths, not just lexical ones); the search walk skips links
- web_fetch and skill_install read the public web only: localhost, the
LAN and cloud metadata are refused, at every redirect
- preview shows a file without running it; browser_upload may ask
- vault: logins no longer match across shared suffixes (pages.dev,
com.tw, ...); registrable_domain knows public suffixes
- axwrite: found elements are retained (use-after-free)
Relay
- replacing or turning off 2FA needs the current code (rate-limited);
new recovery codes only count once enrollment is verified
- a removed computer loses its socket and its `call` access
- a site name taken by another account answers 409
- RELAY_TRUST_PROXY: the login lock counts the caller's address, not
the proxy's (compose files and README)
- httpd: half a body is not a request
Desktop
- sign-in, join and restore work with 2FA on (code field; --serve reads
ANYBOT_ACCOUNT_CODE; the setup wizard points to a pairing code)
- Windows: text was typed twice; modifiers are held through click, drag
and scroll; horizontal scroll; screen control is no longer refused
- a recording that hits the limit is transcribed, not thrown away
- bot's computer: a new home volume restores the snapshot; a snapshot
is read through before the home is wiped; a failed volume removal
stops reset/restore
- events of a stopped turn no longer land in the next one; each channel
message gets a turn of its own
- saving a bot's settings keeps what it got meanwhile (three-way merge);
a save file that cannot be read is kept
- pages in Big5/GBK/Shift_JIS are read in their own encoding
(encoding_rs); osascript output past 64 KB no longer stalls
- pick_tab keeps a job's own non-http tab; pictures larger than the
texture limit are fitted; the auto-update time field takes typing
- skills live in <data>/skills; memories are unnumbered in the prompt;
the phone may skillify and skill_install
CI
- the test step fails when the tests fail (it piped into tail)
Tests: anybot 268 passed, 27 ignored; relay 16 passed; clippy unchanged.
Not run: Windows on a real machine (win.rs type-checked alone), the
Docker paths of the bot's computer, the live accessibility writes.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-10 03:46:17 +00:00
|
|
|
|
| `RELAY_TRUST_PROXY` | 前面有反向代理(Caddy、nginx、`tailscale serve`)時設成 `1`:登入失敗的鎖定會依代理回報的來源位址計算。沒設的話,所有人都算成代理的位址,任何人連續輸錯密碼就會把那個帳號鎖住。只有在外部連不到這個連接埠、只能經過代理時才設(附的 `docker-compose.yml` 已經設好) |
|
AnyBot: first commit of the working desktop app
Rust/egui rebuild of Grok Bot as of 2026-11-04: chat with streaming
providers (xAI, OpenAI, Claude, Gemini, OpenRouter, OpenCode Go, Ollama,
custom), tools and approvals, the bot's Docker computer, computer use on
macOS / Linux X11 / Wayland, AnyBot's browser with a full DevTools-based
toolset, the encrypted vault, pinned grid and sidebar sections, Markdown
with Mermaid diagrams, phone access through the relay, and the Linux
build and test scripts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha3oEtWeHh58zA7ErHa
2026-11-04 08:51:51 +00:00
|
|
|
|
| `PORT` | 連接埠,預設 8080,也可以用 `--port` 指定 |
|
|
|
|
|
|
|
|
|
|
|
|
## 家裡的電腦加 Tailscale(不用網域)
|
|
|
|
|
|
|
|
|
|
|
|
1. 帳號伺服器只開在這台 Mac 自己(127.0.0.1:8780),再由 Tailscale serve 加上 HTTPS,變成 `https://mac-mini.tailbcc3a6.ts.net`,只有你 Tailscale 網路裡的裝置連得到。
|
|
|
|
|
|
- 要先在 Tailscale 管理頁打開 HTTPS 和 Serve,再執行 `tailscale serve --bg 8780`。
|
|
|
|
|
|
- Mac 版 Tailscale 只能轉給這台電腦自己的位址。
|
|
|
|
|
|
2. 開機自動啟動:設定檔是 `deploy/mac/com.anybot.relay.plist`,裡面有安裝指令。
|
|
|
|
|
|
3. AnyBot 設定 › 手機與帳號:伺服器填 `https://mac-mini.tailbcc3a6.ts.net`。
|
|
|
|
|
|
4. iPhone:打開 Tailscale,用 Safari 打開同一個網址,登入,再按「分享 › 加入主畫面」。從主畫面打開後,在「⋯ › 開啟通知」打開推播。
|
|
|
|
|
|
5. 驗證過:用 Chrome 訂閱推播,伺服器加密後經 Google 的推播服務送達,瀏覽器解開並顯示通知。
|
|
|
|
|
|
|
|
|
|
|
|
## 全部放在雲端(用法 C)
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
cd deploy/server
|
|
|
|
|
|
cp .env.example .env # 填帳號、密碼和 AI 金鑰
|
|
|
|
|
|
# 編輯 ../../relay/Caddyfile 換成你的網域
|
|
|
|
|
|
docker compose up -d
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
這會在一台主機上啟動三樣東西:
|
|
|
|
|
|
|
|
|
|
|
|
- 帳號伺服器;
|
|
|
|
|
|
- 處理 HTTPS 的 Caddy;
|
|
|
|
|
|
- 不開視窗的 AnyBot。Bot 的電腦會用主機的 Docker 建立。
|
|
|
|
|
|
|
|
|
|
|
|
第一次啟動的注意事項:
|
|
|
|
|
|
|
|
|
|
|
|
- 帳號還不存在時,AnyBot 每 30 秒重試一次。這時用手機建立帳號就好。
|
|
|
|
|
|
- `.env` 裡設 `ANYBOT_RELAY_INVITE` 邀請碼,第一個帳號才不會被別人先搶走。
|
|
|
|
|
|
- `ANYBOT_RESTORE_FROM_ACCOUNT=1`:第一次啟動時,從 Mac 最新的備份接手 Bot、聊天、例行任務和金鑰。
|
|
|
|
|
|
|
|
|
|
|
|
主機規格:Bot 的電腦裡有 Chromium,建議至少 2 GB 記憶體。
|
|
|
|
|
|
|
|
|
|
|
|
## 一直開著的 Mac(用法 B)
|
|
|
|
|
|
|
|
|
|
|
|
1. 先在 AnyBot 視窗裡登入帳號。
|
|
|
|
|
|
2. 關掉視窗版。
|
|
|
|
|
|
3. 依照 `deploy/mac/com.anybot.serve.plist` 裡的說明,把它放進 `~/Library/LaunchAgents/`。
|
|
|
|
|
|
|
|
|
|
|
|
也可以直接用指令啟動:
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
ANYBOT_PHONE_PASSWORD=至少八個字 anybot --serve
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
這樣同一個網路裡的手機就能直接連,不用帳號伺服器。
|
|
|
|
|
|
|
|
|
|
|
|
## 團隊
|
|
|
|
|
|
|
|
|
|
|
|
在 AnyBot 設定 › 手機與帳號 › 分享給團隊,把這台 AnyBot 分享給伺服器上的其他帳號:
|
|
|
|
|
|
|
|
|
|
|
|
- **成員**:可以聊天、附加檔案。
|
|
|
|
|
|
- **管理員**:另外可以核准、停止、看和操作畫面。
|
|
|
|
|
|
|
|
|
|
|
|
對方要先在同一台伺服器建立帳號,需要邀請碼。
|
|
|
|
|
|
|
|
|
|
|
|
## 安全
|
|
|
|
|
|
|
|
|
|
|
|
- **密碼**:用 PBKDF2-SHA256 存(12 萬輪)。登入失敗太多次會暫停。
|
|
|
|
|
|
- **登入憑證和電腦金鑰**:都只存雜湊值。
|
|
|
|
|
|
- **手機能碰到的範圍**:只能碰到自己帳號裡的 AnyBot。帳號之間的操作(裝置連結)只開放給同一個帳號的 AnyBot,手機碰不到。
|
|
|
|
|
|
- **你的 Mac**:要在 Mac 的「手機與帳號」設定裡打開,手機才能看或操作 Mac 本身的螢幕;裝置連結也一樣。兩者預設都關閉。
|
|
|
|
|
|
- Bot 透過裝置連結做的每個動作,照樣依權限規則詢問你,手機上也能核准。
|
|
|
|
|
|
- **備份**:在你的電腦上用 AES-256-GCM 加密後才上傳。
|
|
|
|
|
|
|
|
|
|
|
|
## 測試
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
cd relay && cargo test --release
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
測試涵蓋:
|
|
|
|
|
|
|
|
|
|
|
|
- 註冊、登入、轉送、離線狀態、備份;
|
|
|
|
|
|
- 登入憑證不以明文儲存;
|
|
|
|
|
|
- 推播內容的加密和簽章。
|