Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Docs: bot to bot across servers

Bugfixer 23ad31a0d2165
diff --git a/docs/bot-api.md b/docs/bot-api.md
index ba73602167..a634b7daa1 100644
--- a/docs/bot-api.md
+++ b/docs/bot-api.md
@@ -134,3 +134,56 @@ allowances, no tools.
Each call is kept with the bot's API settings and shown on the card (count, last
call, recent calls) to those who can manage the key. Refused calls roll up into
one row per burst. Neither ever holds the key.
+
+## Bot to bot across servers
+
+A bot on one OpenMausBot server can hand work to a bot on another, over
+Tailscale, a LAN or the internet, through that bot's Bot API. Its owner turns on
+**Bot API** for the bot there and gives you the address and key from its card.
+
+On your server, an admin saves it in Settings → You and your bots → **Teammates
+on other servers** (Advanced): a name, the address (the whole Bot API address
+from the card, or the server's address and the bot id) and the key.
+
+- The address is https anywhere. Plain http only works for this computer or
+ a private network (a LAN address, Tailscale's 100.x or `*.ts.net`,
+ `*.local`), the same rule as the command line's `--url`
+ ([headless-cli.md](headless-cli.md)); such a name must resolve to a private
+ address. Link-local, cloud metadata and reserved addresses are
+ refused, for typed addresses and for whatever a name resolves to, on every
+ connection.
+- The key stays on this server alone, in `remote-teammates.json` in the data
+ folder (mode 600). It is never shown, listed, logged or put in a prompt, and
+ it goes only to the saved address: redirects are not followed.
+- **Test** checks the key without starting anything on the other server, and
+ isn't counted as one of its calls. It says in words what is wrong: the server
+ can't be reached, the key is wrong (make a new one there and save it again),
+ the call was refused, the server is busy, or the address isn't a Bot API.
+- **Remove** asks first, then forgets the key.
+
+Your bots then see it in `list_bots` as `remote-<id>`, on another server, and
+hand it work with `coordinate_bots`, by that id or its name (a bot on this
+server with the same name wins):
+
+- The brief goes once, with secrets taken out, marked as coming from a bot on
+ another OpenMausBot server. The asking bot reads that thread at 30, 60 and then
+ every 120 seconds, and waits as long as the other server's `retry-after` says
+ (up to five minutes). If it keeps answering busy or can't be reached (more
+ than five times), or gives any other error, the hand-off ends with the
+ reason. Work that was sent is never sent again, also not after a restart:
+ the thread it went to is kept in `remote-teammate-work.json` (mode 600) until
+ the result is in, at most 30 days.
+- More work in the same conversation goes on in the same thread there, so the
+ other bot has the context; `thread: "new"` starts a new one. If the other
+ server no longer has that thread, the work starts a new one.
+- The reply resumes the asking bot as information from that bot, never as the
+ person's approval. If the other bot stops for an approval, only its own owner
+ can give it in their app, and the asking bot is told so.
+- Rooms, `answers`, `post`, `ownThread`, files and a `consult` with
+ `reply: "none"` don't reach another server; the call says why. Work started
+ from outside (a webhook or a guest) can't use a teammate on another server.
+
+On the other server it is an ordinary Bot API call: confined, at Ask and with no
+tools (see [What a call may do](#what-a-call-may-do)), unless its owner marks
+the key **Acts as me**. Its limits hold too: ten calls a minute for the key, and
+no Bot API on a Cloud's Starter plan.
diff --git a/docs/runtime-contract.md b/docs/runtime-contract.md
index 82d6d6b3f8..16cad6e136 100644
--- a/docs/runtime-contract.md
+++ b/docs/runtime-contract.md
@@ -120,6 +120,7 @@ Engine drivers declare capabilities (`server/runtime/capabilities.ts`): `resume`
Every turn that may hand work on, whatever started it, gets the same tools:
- `coordinate_bots(bot_ids, message, reason?, rework?, thread?: "standing" | "new" | "<thread id>", reply?: "resume" | "none", consult?: true, done_when?, answers?)`. `thread: "new"` opens a new thread on the teammate, and a thread id sends to a thread the sender opened on that teammate earlier (a receipt's `threadId`, or `list_threads`), refused with where ids come from for any other, except that a Chief that manages the teammate may name a thread it did not open where the teammate's turn waits on a question card to the person (in words, not one only the person can answer): the message answers it for the person, the turn runs on with `@<Chief> answered for the person: …`, the card names the Chief, and the person's own answer still replaces it. The Chief's turns list such questions (bot, thread id, question). A Chief turn with no person behind it (a webhook, a routine, a guest) neither lists nor answers them, and a question in work an outside event started stays the person's; `reply: "none"` is a one-way notice that is never awaited; `consult: true` asks a question that the teammate answers from what it knows, acting on nothing, and the asker is resumed with the answer. `answers: "<assignment id>"` makes the message the answer to that teammate work's open question (parked, or a question card its turn waits on) instead of new work, whoever sends it; refused, with the reason, when that work no longer asks. A message to a teammate from the very turn that was resumed with its question answers it too. **What the bot that handed work on sends to the thread that work runs in goes into that work**, outside a room, whatever its level and whichever of its turns sends it: where the work waits on a question (parked on `NEEDS INPUT:`, or a question card its turn waits on; never a sign-in or another card only the person can act on) the message answers it, and the work runs on with `@<bot> answered: "…"` and reports once, to the turn that handed it out; where the work is running, the message is handed to that running turn (`steer`), which reads it at its next step as a person's line sent mid-turn is, and is shown in that thread as the sender's; the work's one result still comes back once. Only when the engine cannot take a message mid-turn does it run next, as new work. Work handed out in the sending turn itself stays apart: a second assignment is its own. A consultation, and a message to a room, never go into other work. A parked question waits on its own clock, which never runs out unless a host sets one (§6): it is answered, or its work is stopped.
+- A teammate on another server (saved in Settings, see [Bot API: bot to bot across servers](bot-api.md#bot-to-bot-across-servers)) is listed by `list_bots` as `remote-<id>` and takes `coordinate_bots` work through its Bot API; its reply resumes the sender as information from that bot.
- `assignment_status(id?)`: read-only; one assignment's status, outcome and result, or everything this conversation still waits on. External runtimes long-poll it; it never blocks a bot.
- `usage_limits` reads each AI account's percent used, reset time and when that was checked, read-only: no credential, address or account id, an `unknown` status for no data and `unsupported` for an AI that reports no limits. A turn sees only accounts its audience may read, and a guest-driven turn is refused.
- `start_thread` (on yourself) takes an optional `model_selection` (ids from the read-only `list_models`) and `report_back`: with it the thread is an assignment of the bot's own, and its result resumes the opener like a teammate's.
diff --git a/skills/openmausbot-docs/SKILL.md b/skills/openmausbot-docs/SKILL.md
index 0d4d51c76e..eeb1e3b843 100644
--- a/skills/openmausbot-docs/SKILL.md
+++ b/skills/openmausbot-docs/SKILL.md
@@ -58,7 +58,7 @@ a hand edit races the next save.
| What a bot remembers between tasks | `memory.md` |
| Timing, cron, time zones, paused and done routines | `routine-schedules.md` |
| The daily brief, and the checks that run before it | `proactive-routines.md` |
-| Letting an app or a script message one bot | `bot-api.md` |
+| Letting an app or a script message one bot, or a bot on another server | `bot-api.md` |
| Letting a script drive the whole server | `headless-cli.md` |
| Which model picks between bots, and whose key decides | `decision-model.md` |
| How a bot chooses a tool | `tool-selection.md` |