Skip to content

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

10.6 KB
Raw Blame

Team Board

A work layer over a Team Cloud's rooms. A room thread can carry one board item: a title, a state, what it waits for, labels, and which bot may take it. Rooms and threads stay what they are; the item only says where the work in that thread stands. A person sees an item exactly when they can see its room thread.

It is on every Team Cloud, with no switch; anywhere else the routes below answer 404 and the bots have no board tools. An older config.json that still has features.teamBoard loads as before, and the key is dropped.

People never see the word "board". A person asks a bot in a room to split work up (or hands it a goal with clear separate parts); the bot calls board_add, which opens one room thread per piece, and the server hands each ready piece to a free bot of the room and starts that bot's turn in the piece's thread; the bot settles it with its board tools. There is no Board page and nothing to fill in. Repeating items come later.

What people see

A room thread that is an item shows one short status on its row in the room feed and under its title when it is open beside the feed (src/lib/room-work.ts):

State Status
waiting, ready Up next
working Bot working (on the row only while no turn runs: the row's own line says a bot is working while one does)
needs_person Needs you, when the viewer was asked or nobody in particular was; else Needs name
done Done
failed Stopped
cancelled nothing

On a row the status stands where "Closed" would. A room thread whose item waits on a person also shows as waiting on you, as an open card does. A room with no threads yet says, under its empty line, that a bot can split big work into threads. The feed reads GET /api/board?groupId= and follows board.item frames.

What bots are told

Every room turn on a Team Cloud carries one line (ROOM_SPLIT_PROMPT, server/system-prompt.ts): when a person asks to split or share out work, or hands over a goal with clearly separate parts, use board_add; otherwise just answer; never split a small request or a piece you were handed. When someone asks to see the work or where it stands, the bot calls board_list and shows it in the chat with the existing show_html tool, one compact page grouped by the statuses above, and replaces that page by its app_id when asked again; never unasked. No tool was added for it. board_add itself refuses a call from a thread that is already an item, so a bot working one piece cannot turn it into more turns.

The item

BoardItem in shared/board.ts, one per room thread, keyed by its threadId:

Field
title One line, at most 120 characters.
state See below.
needs Thread ids of other items in the same room that must be done first; at most 10, never a loop.
labels At most 12; key of at most 32 of a-z 0-9 _ -, value of at most 80 characters.
forBotId Only this member bot of the room may take it; otherwise any of them.
holder The bot working on it, and since when (while working or needs_person).
attempts Times a bot took it since it was made or reopened.
question What its bot asked a person (while needs_person), and whom.
later When its bot set it aside to look again, and its note (while working).
laterCount Times its bot set it aside since it was made or reopened; at most 20.
result What came of it, at most 2,000 characters.
createdBy The person or bot who made it.

A room holds at most 200 items that are not settled.

States

waiting → ready → working → done | failed | cancelled, with needs_person beside working.

  • A new item is waiting while any need is not done, else ready. A waiting item becomes ready by itself when its last need is done; a failed or cancelled need readies nothing.
  • ready → working: the server gives it to a bot (see Dispatch).
  • working → done, failed, needs_person (the bot asked someone) or back to ready (released, or the turn ended without settling it). needs_person → working when the person replies or the bot picks its question back up (resume), ready when a person or the bot releases it, or cancelled.
  • A person may cancel any open item, mark any open item done, release one waiting on a person, and reopen a settled one (its tries start again from 0, and it waits again if a need is not done). A bot may cancel an open item it made, and withdraw its own question (resume or release).
  • An item that is removed, or whose thread or room is deleted, stops being needed: what waited only on it is ready.

Every other move is refused with 409 board_bad_move. The rules are server/board/state.ts.

Dispatch

server/board/dispatcher.ts, wired in server/board/wiring.ts. It runs on a Team Cloud, whenever the board changes, a bot's state changes, the runtime reports a turn's node changed, and on the shared due-timer.

  • Per bot. A bot runs one room turn at a time and only when idle everywhere. For each ready item, oldest first, the dispatcher picks its forBotId, else the first member bot of the room that is free: not hidden, held, paused, awaiting an approval level, busy anywhere, its engine's account not being changed, and holding no other item it is working on (an item waiting on a person, or set aside, does not count). No free bot: the item stays ready.
  • Caps first. Before a start it checks the monthly spend limit and the usage caps as unattended work (nobody waiting). A refusal pauses every dispatch until the cap resets; no attempt is counted.
  • Model. A bot whose engine is missing is passed over for 10 minutes.
  • The turn. take (attempts + 1), then startGroupTurn in the item's thread with @Bot and the bot as the one mention, as unattended work (trigger: { kind: "bot" }, never the person's own request), from a sender named Handoff with no person behind it. The line carries the item's title, its thread's first line, what each need came to, and how to finish. A start the server refuses hands the item back (or fails it at the third attempt) and waits a minute.
  • The lease is the turn. An item still working, not set aside, whose thread is idle 20 seconds or more after its bot took it, lost its turn: back to ready, or failed with "Stopped after 3 tries" at the third.
  • Restarts. Nothing is started, and no lease is checked, in the first two minutes after the server starts: the runtime re-runs a room turn a restart cut. An item set aside keeps its time across a restart, and a sleeping Cloud wakes for it.
  • Maintenance and moves. It stops with the other timers during maintenance and while the Cloud is moving.
  • Waiting on a person. ask keeps the item's holder and frees the bot. The person's chat line in that thread is addressed to the holder (@Bot is put in front unless it already names it), whoever the room's default responder is, and the item goes back to working. An answer from the person's inbox lands in the thread as the bot's relay line and starts no turn by itself: the item then goes back to working and the holder is started as soon as it is free, with that answer as its line.
  • Set aside. later keeps the item working and its holder, frees the bot, and starts the same bot again at the time with its own note. It counts no attempt. The 21st later on one item fails it.

Bot tools

Listed to every bot of a Team Cloud (OMB_TEAM_BOARD, set from the Team Cloud itself), in chats and in rooms, deferred for Claude; each is in the core tool group. The internal routes are server/routes/board-tools.ts; a confined turn (work from outside) cannot reach them.

  • board_add { room?, items: [{ key, title, brief?, needs?, labels?, for? }] }: 1 to 15 items, each on a new thread of the room (default: the room of the turn), the bot's brief (or the title) as its first line, written as the bot's. needs are keys of the same call or item ids of the room; for is a bot's name in the room. Everything is checked before the first thread opens, so a bad entry leaves nothing behind. Only rooms the bot is a member of, and never from a thread that is already an item.
  • board_list { room?, state? }: the items of the bot's rooms, one line each, at most 60.
  • board_update { item?, move?, text?, person?, minutes?, labels? }: the item of this thread unless item is given. done and failed take text as the result; ask posts text as the bot's line in the thread and puts it in the inbox of person (a teammate's name or email), else of the person who made the item, and keeps their name on the item; later takes minutes (1 to 1,440) and text as the note; release hands it back to ready, and resume takes the bot's own question back to working; both let the holder withdraw a question it no longer needs. labels replaces them. Only the bot holding an item may settle, ask about, set it aside or withdraw its question.

Routes

For every member and admin who is signed in (server/routes/board.ts). Writing needs what writing in the room needs: chat access to each of its bots.

  • GET /api/board[?groupId=] → { items, you }, the ones the caller can see, oldest first; you is the caller's person key, as question.person names whoever was asked.
  • POST /api/board/items { groupId, title, text?, needs?, labels?, forBotId?, threadId? } → 201 { item }. Without threadId it opens a new thread in the room, without making it the room's current one, whose first line is text (or the title), written as the caller's; no bot answers it. With threadId, that thread of the room becomes the item.
  • PATCH /api/board/items/:threadId { move?: "cancel" | "reopen" | "release" | "done", title?, labels?, needs?, forBotId?, result? } → { item }. labels replaces them all; needs changes only before a bot takes the item; forBotId: null lets any member bot take it.
  • DELETE /api/board/items/:threadId removes the item; its thread and everything said there stay.

Errors carry a code: board_bad_input (400), board_not_found (404, also for an item the caller cannot see), board_bad_move, board_exists, board_cycle, board_full (409).

Live frame

{ kind: "board.item", groupId, threadId, item } on every change (item: null when it is removed), sent only to people who can see that room thread.

Storage

board.json in the data folder, written whole and readable only by its owner: { version: 1, items, repeats }. A new file, so older versions simply do not read it. A file that does not parse is an empty board, and an item that does not parse is left out.