Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Merge #4433 at 353e72afb
milind-soni5d013be2663e
diff --cc docs/cloud-pro.mdindex bdc13124fd,85c777d599..8be2c8a547--- a/docs/cloud-pro.md+++ b/docs/cloud-pro.md@@@ -1124,17 -1107,13 +1124,23 @@@ provider outage. So on a Cloud home (`sbot unless one is saved, and this gate holds the rest. A Starter Cloud runs onethread per bot for what a person or a routine starts; the Admin says so with itssigned `POST /api/cloud/plan` `{"v":1,"tier":"starter"}` (`server/host/cloud-plan-tier.ts`), and a- home it never told has no such limit. What a bot's own turn starts always goes through.+ home it never told has no such limit. What a bot's own turn starts always goes through,+ and a teammate's hand-off never takes that one thread from the person.+- **How many bots a Starter Cloud makes.** Five beside its MausBot, one number in+ `server/host/starter-bot-limit.ts`, from the same signed plan. An archived bot or one+ that moved away takes no room. Making one past it answers `409` with+ `{"code":"bot_limit","error":"…"}` from `POST /api/bots`, `POST /api/teams/import`,+ `POST /api/org-library/add` and a Chief's `create_bot` and `propose_team_setup`; a group that+ doesn't fit is refused whole, before anything is written. The app opens its upgrade popup+ when a create button is pressed with no room, and on that refusal. A bot is never taken away:+ a Cloud over the limit (a downgrade, a move) keeps every one and only making a new one stops.+ A bot arriving with its own id (a move) and a backup restored are never refused. The limit+ lifts as soon as the Admin tells the home its new plan, with no restart.+ - **Who goes first.** The gate only changes the order, never how much it lets in. A+ person's own work goes first: their line, or a turn going on from what they answered.+ Bot work that has waited 5 minutes takes its place by arrival, so it is never starved+ (`server/host/turn-order.ts`). A stop never waits: a line made only of stop words stops+ running work at once in any of the app's languages, and an `@everyone` stop starts no engine on a bot with nothing running.- **OpenCode threads share a process.** Threads whose OpenCode would startthe same way (same login, approval level and settings) run as sessions of one`opencode acp` process, up to six at a time and twelve over its lifediff --cc docs/verification/chat-turns.mdindex 860d6fee99,161b4216c7..bfc541f0c7--- a/docs/verification/chat-turns.md+++ b/docs/verification/chat-turns.md@@@ -288,5 -288,4 +288,5 @@@ engines. What stays one at a time, and- One bot's browser: a call from another thread waits, the row says who has it, and a holder quiet for a minute gives itto the waiter. The holder's next call is refused once, so nothing lands on a page it did not open.- One computer: a turn takes it at its first screen call, not when it starts, and keeps it until it ends.- - Memory on a Linux Cloud: a turn that would run the machine out says "Waiting for memory" and starts by itself.+ - Memory on a Linux Cloud: a turn that would run the machine out says "Waiting for memory" and starts by itself. `OMB_TEST_MEMORY_GATE=1` runs the gate in a fixture on any OS, on the memory `<data dir>/host-memory.json` says; `server/memory-order.e2e.test.ts` shows whose turn goes next.+- A Cloud that just woke: a hand-off starts at once. `OMB_TEST_RESUME_CLOCK=1` lets a fixture move `Date.now()` on as a wake does, by writing milliseconds to `<data dir>/resume-clock-ms`; `server/handoff-wake.e2e.test.ts` uses it.diff --cc scripts/control-omb.tsindex 95d54f67fc,fb208d72bd..11c92a9298--- a/scripts/control-omb.ts+++ b/scripts/control-omb.ts@@@ -215,8 -215,8 +215,10 @@@ export function verificationServerEnvirif (parentEnv.OMB_TEST_APPROVAL_CLOCK === "1") childEnv.OMB_TEST_APPROVAL_CLOCK = "1";// The stall watchdog fires on a marker file, not after 20 minutes of silence.if (parentEnv.OMB_TEST_STALL_CLOCK === "1") childEnv.OMB_TEST_STALL_CLOCK = "1";+ // Date.now() jumps when a marker file says so, as it does when a suspended machine wakes; timers don't.+ if (parentEnv.OMB_TEST_RESUME_CLOCK === "1") childEnv.OMB_TEST_RESUME_CLOCK = "1";+ // The memory gate runs here too, on the memory a fixture file says this machine has.+ if (parentEnv.OMB_TEST_MEMORY_GATE === "1") childEnv.OMB_TEST_MEMORY_GATE = "1";// The first-reply rescue's delay in ms, so a check need not sit through 20 s of silence.if (/^\d{1,6}$/.test(parentEnv.OMB_FIRST_REPLY_NOTICE_MS ?? "")) childEnv.OMB_FIRST_REPLY_NOTICE_MS = parentEnv.OMB_FIRST_REPLY_NOTICE_MS;// How long a tool call may hold the person's message unread, in ms, so a check need not sit through a minute.@@@ -249,7 -249,7 +251,8 @@@ export function verificationServerArgs(...(childEnv.OMB_TEST_DESKTOP_OWNER_TOKEN || childEnv.OMB_TEST_DESKTOP_CUA_CONNECTION ? hook("desktop-parent.mjs") : []),...(childEnv.OMB_TEST_APPROVAL_CLOCK === "1" ? hook("approval-clock-hooks.mjs") : []),...(childEnv.OMB_TEST_STALL_CLOCK === "1" ? hook("stall-clock-hooks.mjs") : []),+ ...(childEnv.OMB_TEST_RESUME_CLOCK === "1" ? hook("resume-clock-hooks.mjs") : []),+ ...(childEnv.OMB_TEST_MEMORY_GATE === "1" ? hook("memory-gate-hooks.mjs") : []),join(ROOT, "server", "index.ts"),];}diff --cc server/index.tsindex 0e618729bf,edea5b2f23..a7e861034c--- a/server/index.ts+++ b/server/index.ts@@@ -2861,10 -2861,10 +2861,10 @@@ const { cloudLendingTurn, cloudLendingRmemoryChangedBySomeoneElse: (botId) => lendingMemory?.reconcile(botId, foreignTurnRunning(botId), { cached: true }).changedBySomeoneElse === true });const actingPeople = createActingPeople({ store, direct: (threadId) => directRequestOwners.get(threadId), roomRun, handed: new HandedPeople(join(DATA_DIR, HANDED_PEOPLE_FILE)) });const computerAsks = CLOUD_PERSONAL ? createComputerAsksHost({ store, notify, lending: sharedComputers, principal: CLOUD_HOME_LENDER, threadBusy, queued: hasQueuedSteeredMessages, continueRequest: startTurn,- refusal: (turn) => sharedComputerPrincipal(turn) ? null : cloudLendingRefusalNotice(turn) ?? "This conversation can't use your computer.", request: (threadId) => directRequestOwners.get(threadId), active: (turn) => internalCapabilityIsActive(turn as InternalCapability) }) : null;+ refusal: (turn) => sharedComputerPrincipal(turn) ? null : cloudLendingRefusalForBot(turn) ?? "This conversation can't use your computer.", request: (threadId) => directRequestOwners.get(threadId), active: (turn) => internalCapabilityIsActive(turn as InternalCapability) }) : null;const { stopThreadForPerson, stopOnTypedCommand, restartForPerson, noteTeammatesLeftRunning } = createPersonStop({store, routines: () => routines, handoffs: () => handoffs, interruptDirectThread, clearUnattended,- stopGoal: (threadId) => oneOnOneGoals.stop(threadId), markStopped: (threadId) => personStops.stop(threadId, liveTurns.running(threadId), directTurnDispatchClaims.has(threadId)),+ stopGoal: (threadId) => oneOnOneGoals.stop(threadId), markStopped: (threadId) => personStops.stop(threadId, liveTurns.running(threadId), directTurnDispatchClaims.has(threadId)), working: (botId, threadId) => threadBusy(botId, threadId) || coordinator.activeDirect(threadId), asking: (threadId) => coordinator.awaitingAnswer(threadId) || Boolean(openPersonCard(threadId)), language: threadLanguage,}); const teamMessages = createTeamMessages({ team: CLOUD_TEAM, dataDir: DATA_DIR, store, people: teamOwners.people, personName: teamHost.personName, audienceOf: teamHost.audienceOf, starters: threadStarters, notify, sees: (person) => visibleTo(person.role === "member" ? { kind: "member", email: person.email } : { kind: "all", email: person.email }), inbox: { askedPerson: teamOwners.routing.askedPerson, changed: (threadId) => { const bot = store.botByThread(threadId); if (bot) broadcast({ kind: "bot", bot: wireBot(bot) }); }, ensureOwnBot: (email) => { ensureDefaultBot(store, { dataDir: DATA_DIR, person: email, team: CLOUD_TEAM?.name ?? null }); }, handedFrom: (threadId) => { const from = delegatorOf(threadId); return from && from.threadId !== threadId ? from.threadId : null; }, continueTurn: relayedTurn({ store, startTurn, state: (botId, threadId) => ({ atCapacity: botAtThreadCapacity(botId, threadId), threadBusy: threadBusy(botId, threadId), groupTurn: roomTurnHolds(activeGroupTurnForBot(botId), threadId, false), parksBehindCoordination: parksBehindCoordination(botId, threadId) }) }), representative: { generate: async (botId, prompt) => (await sideJobs.text("representative", botId)?.generateText(prompt, { timeoutMs: 60_000 })) ?? null, busy: createPersonCalendar({ access: (person) => teamConnections.personApps().includes("googlecalendar") ? teamConnections.people.appsAccess(person) : null, connected: async (access) => (await composio.connectedServices(cfg, access)).googlecalendar?.connected === true, relay: (payload, session, signal, access) => composio.relayMcp(cfg, payload as never, session, undefined, signal, access) }).busy } } });const noAiNotice = createNoAiNotice({ team: CLOUD_TEAM, dataDir: DATA_DIR, people: () => teamOwners.people?.list() ?? [], personName: teamHost.personName, inbox: () => teamMessages.inbox, language: personLanguages.forLine, threadLanguage: conversationLanguage });const botNameClash = createBotNameClash({ store, people: () => teamMessages.people(), profileName: () => cfg.profile?.name });