AnyBot/docs/en/multi-device.md

45 lines
3.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Multi-device: brain, hands, screen (English summary)
Canonical document: [docs/multi-device.md](../multi-device.md) (Chinese).
One AnyBot in your account is the **brain**: it stores every bot, chat, memory and schedule, and does the thinking. Other machines are its **hands** (screen, input, files, browser), phones are web clients. Everything talks through your **account server** (relay); each machine opens an outbound long connection, so nothing needs open ports or a static IP.
| Role | What it is | How to set |
|---|---|---|
| Brain | stores and thinks; keep it always on | logging into the account makes it the brain (default) |
| Screen | a machine with a window: shows and edits the brain's bots, and acts as hands | Settings › General › Phone & account › Brain › “use this as brain” |
| Hands | lets the brain's bots drive this machine | the “Add a computer” one-liner, or `anybot setup` |
| Phone | web app on the relay's URL | sign into the same account |
## Method A — server as relay + brain (recommended)
A Linux host (≥2 GB RAM) plus one of: a **domain** (A record, 80/443; HTTPS certificates issued automatically), a **Tailscale** HTTPS URL (`https://host.tailnet.ts.net`, no ports opened at all), or a **LAN IP** (self-issued, auto-renewed certificate — trust it once on each device; instructions in the Chinese doc).
```sh
curl -fsSL https://code.30cm.net/daniel.w/AnyBot/raw/branch/main/install.sh | sh -s -- server
```
It asks three questions (URL, account, password), installs Docker if needed, gets HTTPS, creates the account, starts the brain. Update later with `cd ~/AnyBot && make server` (“keep settings, update, restart”). Release archives (built by Gitea Actions on `v*` tags) avoid building on the server: download `AnyBot-<ver>-server-<arch>.tar.gz`, unpack, `cd deploy/server && ./setup.sh`.
## Method B — a Mac as the brain (home, Tailscale)
1. `make relay`; install `anybot-relay` under `~/Library/Application Support/AnyBot/relay/` and load `deploy/mac/com.anybot.relay.plist` via `launchctl` (edit the URL inside first).
2. `tailscale serve --bg 8780` → you get `https://mac-mini.tailnet.ts.net`.
3. AnyBot › Settings › General › Phone & account → enter that URL, create the account, sign in. This Mac is now the brain; other devices pair to it like Method A.
## Pairing computers (hands)
“⋯ › Add a computer” on the phone (or Settings on the brain) shows a one-time pairing line like:
```sh
curl -fsSL https://your-domain/…/install.sh | sh -s -- hands https://your-domain 482913
```
The 6-digit code lives 10 minutes, works once, carries no password. The machine installs itself, registers a host token, starts `anybot.service`, and runs at boot (enable `loginctl enable-linger $USER` to keep it running when logged out).
## When a device can't connect
- “Brain offline” → the brain machine is off/asleep, AnyBot isn't running there, or it lost the relay connection (each side keeps an outbound connection; a network change recovers by itself in seconds).
- A hands machine offline → check `systemctl --user status anybot`; re-run the pairing line to re-pair.
- A screen machine keeps a read-only **brain copy** (`brain-copy.json`) so recent chats stay readable while the brain is away.