Go to file
王性驊 4506cc149b Clippy is clean on macOS and Linux, for the app and the relay
Every warning `cargo clippy --all-targets` gave (50 on macOS, 8 more only on
Linux, 1 in the relay), fixed without changing what anything does:
- long types get a name (Peer, Members, Imported, Joining, Mention, Stream…);
- the two big enum variants are boxed (the vault's login plan, joining an
  account);
- a test now waits for the copy it relaunched (it left a zombie behind);
- a hint's format had a dead `if` whose two branches were both "";
- the rest is what clippy suggests: sort_by_key, as_chunks, is_none_or,
  is_multiple_of, while let, from_ref, next_back, struct init, no casts to
  the same type.

Checked: cargo test (177 macOS, 181 Linux), relay tests (11), remote_e2e
28/28, and the live Linux test (X11; Wayland clicks, keys, Chinese typing,
scroll and screenshots).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha2RVfSYmrhqNnqx9Z4
2026-11-07 10:10:28 +08:00
.gitea/workflows Release builds on Gitea Actions: macOS app, Ubuntu, headless Linux, server 2026-11-04 22:07:46 +08:00
box Bot 的電腦 can run under gVisor: its own kernel, Chromium's sandbox back on 2026-11-07 00:03:25 +08:00
deploy Checked by using it: tests stay off the real box, gVisor scripts run clean, times are the person's 2026-11-07 00:19:56 +08:00
docs Each job works on its own tabs; a Lima VM the box lives in is started when it's down 2026-11-07 00:50:29 +08:00
fonts AnyBot: first commit of the working desktop app 2026-11-04 16:51:51 +08:00
icons Remove what nothing uses and keep one copy of what was written several times 2026-11-05 23:21:47 +08:00
mobile The phone page does what the desktop does, laid out like it 2026-11-07 03:05:12 +08:00
relay Clippy is clean on macOS and Linux, for the app and the relay 2026-11-07 10:10:28 +08:00
src Clippy is clean on macOS and Linux, for the app and the relay 2026-11-07 10:10:28 +08:00
.dockerignore AnyBot: first commit of the working desktop app 2026-11-04 16:51:51 +08:00
.gitignore Release builds on Gitea Actions: macOS app, Ubuntu, headless Linux, server 2026-11-04 22:07:46 +08:00
Cargo.lock People watch and help on the bots' computer through VNC (noVNC), carried by the account server 2026-11-05 23:05:44 +08:00
Cargo.toml People watch and help on the bots' computer through VNC (noVNC), carried by the account server 2026-11-05 23:05:44 +08:00
FEATURES.md The phone page does what the desktop does, laid out like it 2026-11-07 03:05:12 +08:00
GROK_BOT_FEATURES.md AnyBot: first commit of the working desktop app 2026-11-04 16:51:51 +08:00
GROK_BOT_TOKENS.md AnyBot: first commit of the working desktop app 2026-11-04 16:51:51 +08:00
MECHANICS.md AnyBot: first commit of the working desktop app 2026-11-04 16:51:51 +08:00
Makefile Bots do a planned sequence in one step; the box's screen settles by what it shows; no login is ever the only copy 2026-11-06 09:47:37 +08:00
ORIGINAL_FEATURES.md AnyBot: first commit of the working desktop app 2026-11-04 16:51:51 +08:00
README.md Docs: 頁面, Tailscale servers, no-questions install, hands' virtual screen and updates 2026-11-05 08:35:47 +08:00
install.sh Demo recording keeps its last events off the UI thread; dialogs, screensaver probe and installer traps fixed 2026-11-05 15:48:22 +08:00
mechanics.json AnyBot: first commit of the working desktop app 2026-11-04 16:51:51 +08:00

README.md

AnyBot

你自己的 AI Bot。可以聊天,也能幫你動手做事:處理檔案、執行指令、操作瀏覽器和螢幕、跑例行任務。

  • 每個 Bot 可以用不同的 AI:xAI Grok、OpenAI、Claude、Gemini、OpenRouter、OpenCode Go、Ollama(本機),或任何 OpenAI 相容的服務
  • 桌面 App(macOS、Linux)+手機網頁版(可加到主畫面、收通知)
  • 多台電腦一起用:一台當大腦,其他電腦當它的手腳

安裝

先決定你要裝哪一種,複製那一行到終端機執行就好。需要的東西(系統套件、Rust、Docker)腳本會自己裝。

我要… 在哪台執行 指令
桌面 App Mac、有螢幕的 Linux curl -fsSL https://code.30cm.net/daniel.w/AnyBot/raw/branch/main/install.sh | sh
架伺服器(帳號伺服器+大腦+HTTPS) 有網域的 Linux 主機 curl -fsSL https://code.30cm.net/daniel.w/AnyBot/raw/branch/main/install.sh | sh -s -- server
加一台電腦當手腳 任何 Linux(有沒有螢幕都可以) 在 AnyBot 按「加一台電腦」,貼上它給你的那一行

想先看腳本做什麼:install.sh。它只會裝 AnyBot 需要的套件,程式裝在你的使用者資料夾(不用 root),原始碼放在 ~/AnyBot。

第一次要多久? 腳本會在你的電腦上編譯,第一次大約 5–15 分鐘(看電腦快慢),之後更新只要 1–2 分鐘。


開始使用

只用一台電腦

  1. 裝好桌面 App,打開。
  2. 設定 › 模型,貼上你的 API 金鑰(例如 xAI、OpenAI)。
  3. 開始聊天。

手機和多台電腦一起用

     手機(網頁)          筆電(螢幕)         沒螢幕的 Linux(手腳)
          \                    |                     /
           └──────── 帳號伺服器(每台都連過來)─────────┘
                               |
                大腦:Bot、聊天、記憶、例行任務都在這裡

步驟 1:架伺服器(只做一次)

需要:一台 Linux 主機(2 GB 以上記憶體),加上一個網域(A 紀錄指到這台、80 和 443 埠打開)或 Tailscale(不用網域,只有你的裝置連得到)。

curl -fsSL https://code.30cm.net/daniel.w/AnyBot/raw/branch/main/install.sh | sh -s -- server

只會問三件事:網址(網域或 Tailscale)、帳號、密碼。它會自動裝 Docker、申請 HTTPS 憑證、建立帳號、啟動大腦。完成畫面會告訴你網址。

沒有伺服器?也可以先拿一台 Mac 當大腦,見 docs/multi-device.md(做法 B)。

步驟 2:手機:用瀏覽器打開你的網址並登入,再「加入主畫面」。

步驟 3:其他電腦

  • 有螢幕的電腦:裝好桌面 App,到 設定 › 一般 › 手機與帳號 登入,在「大腦」那一欄選伺服器。

  • 沒螢幕的 Linux:在手機 AnyBot 右上角按「⋯ › 加一台電腦」(或在電腦的 設定 › 一般 › 手機與帳號),會出現一行像這樣的指令:

    curl -fsSL https://code.30cm.net/daniel.w/AnyBot/raw/branch/main/install.sh | sh -s -- hands https://你的網域 482913
    

    貼到那台電腦執行,就會自動裝好、接上大腦,之後開機也會自動執行。不用帳號密碼,這組碼 10 分鐘內有效、只能用一次。


更新和移除

要做什麼 指令
更新桌面 App 或手腳 再執行一次安裝的那一行
更新伺服器 在伺服器上 cd ~/AnyBot && make server,選「用現有設定,更新並重新啟動」
移除程式 cd ~/AnyBot && make uninstall(你的 Bot 和聊天會留著)
停掉手腳 systemctl --user disable --now anybot

出問題時

先執行這個,它會告訴你缺什麼:

cd ~/AnyBot && make doctor
看到 怎麼辦
編譯到一半被中斷、Killed 或 signal: 9 記憶體不夠。加 2 GB swap 再試:sudo fallocate -l 2G /swapfile && sudo chmod 600 /swapfile && sudo mkswap /swapfile && sudo swapon /swapfile
Rust 太舊 或 requires rustc 1.95 rustup update stable。用 apt 裝的 rustc 太舊,請改用 rustup
alsa 或 pkg-config 找不到 少了系統套件,執行 make deps
伺服器的網址連不到 網域是不是指到這台?80、443 埠有沒有被防火牆擋?cd ~/AnyBot/deploy/server && docker compose logs caddy
大腦登不進帳號 cd ~/AnyBot/deploy/server && docker compose logs anybot
Mac 說「無法驗證開發者」 對 AnyBot 按右鍵 › 打開,只有第一次需要
手機上看到「大腦目前離線」 大腦那台關機、睡眠,或 AnyBot 沒開。詳見 docs/multi-device.md 的「連不上時」

還是不行:把 make doctor 的結果和錯誤訊息的最後幾行貼給維護的人。


自己從原始碼建置

適合想改程式的人。一般使用請用上面的一行安裝。

git clone https://code.30cm.net/daniel.w/AnyBot.git
cd AnyBot
make deps       # 裝好系統套件和 Rust(只要一次;Linux 會問 sudo 密碼)
make            # 建置
make install    # 安裝:Mac → ~/Applications/AnyBot.app;Linux → ~/.local/bin/anybot 和應用程式選單
指令 做什麼
make run 不安裝,直接打開
make test 跑測試
make doctor 檢查這台缺什麼
make serve 不開視窗執行(一直開著的電腦)
make setup 把這台接到你的大腦(終端機裡的引導畫面)
make server 在這台架伺服器(同上面的 install.sh server)
make dist 打包發行檔到 dist/
make help 列出全部

需要:Rust 1.95 以上、C 編譯器、git;Linux 另外需要 pkg-config 和 ALSA 開發套件(libasound2-dev)。make deps 會全部裝好。各平台細節:docs/install.md。


部署方式

方式 用在 說明
Docker Compose(預設) 伺服器 install.sh server 用的就是它:帳號伺服器、大腦、Caddy(自動 HTTPS)三個容器,資料放在 Docker 磁碟區,重開機自動啟動。用 Tailscale 網址時不開 Caddy,改由 tailscale serve 提供 HTTPS。設定檔:deploy/server/docker-compose.yml
免問安裝(腳本、Ansible…) 伺服器 答案用環境變數給:ANYBOT_SETUP_USER=me ANYBOT_SETUP_PASSWORD=… [ANYBOT_SETUP_DOMAIN=網域] sh install.sh server;不給網域時用這台的 Tailscale 網址
Portainer、Coolify、Dokploy… 已經在用這些管理工具的伺服器 它們都吃標準的 docker-compose.yml:把 repo 加進去、指定 deploy/server/docker-compose.yml、在環境變數填 ANYBOT_USER、ANYBOT_PASSWORD、ANYBOT_RELAY_PUBLIC_URL。若工具自己處理 HTTPS,就拿掉 caddy 那一段,把網域導到 relay 的 8080 埠
systemd(使用者服務) 手腳、沒螢幕的 Linux 大腦 anybot setup 會自動建立 anybot.service;登出後也要繼續跑:sudo loginctl enable-linger $USER
launchd Mac 當大腦或帳號伺服器 見 docs/multi-device.md
Gitea Actions 推 tag 自動打包發行檔 見 docs/release.md

不需要另外架資料庫:資料是幾個 JSON 檔,寫入時不會寫一半。要備份伺服器,備份 Docker 磁碟區 server_relay-data、server_anybot-data 就好。


文件

文件 內容
docs/install.md 安裝細節:各平台需求、手動步驟、常見問題
docs/multi-device.md 大腦、手腳、螢幕:怎麼架、怎麼接、連不上時看什麼
docs/architecture.md 技術架構:程式分層、資料存放、安全設計
docs/protocol.md 帳號伺服器的介面與長連線格式
docs/release.md 打包和自動建置
FEATURES.md 所有功能

專案結構

install.sh      一鍵安裝(桌面 App、手腳、伺服器)
src/            AnyBot:桌面 App、無視窗模式、anybot setup
relay/          帳號伺服器
mobile/         手機網頁
box/            Bot 自己的電腦(Docker 容器)
deploy/         各平台的安裝和部署檔:mac/、linux/、server/、ci/
docs/           技術文件