Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Merge origin/main into train/nov16-u3
milind-soni8974caa7080b
diff --cc server/index.test.tsindex 9d7939ceb9,a08e30be41..4cac03cab0--- a/server/index.test.ts+++ b/server/index.test.ts@@@ -9913,7 -9913,7 +9913,7 @@@ describe("harness HTTP API", () =>it("keeps skill authoring on by default and persists an explicit opt-out", async () => {const before = await api("GET", "/api/config");expect(before.status).toBe(200);- expect(before.body.features).toEqual({ browser: false, skillAuthoring: true, skillReview: false, skillReviewSteps: 10, skillsLibrary: false, shareLearnedSkills: "off", showToolCalls: false, sharedComputers: false, claudeUserMcp: false, claudeUserSkills: false, autoRecall: true, roomMemoryCapture: false, parallelRoomJobs: true, llmThreadTitles: true, savedSteps: true, savedStepsHere: process.platform === "darwin", usbPhoneTakeover: false });- expect(before.body.features).toEqual({ browser: false, skillAuthoring: true, skillReview: false, skillReviewSteps: 10, skillsLibrary: false, shareLearnedSkills: "off", showToolCalls: false, sharedComputers: false, claudeUserMcp: false, claudeUserSkills: false, autoRecall: true, roomMemoryCapture: false, parallelRoomJobs: false, savedSteps: true, savedStepsHere: process.platform === "darwin", usbPhoneTakeover: false });++ expect(before.body.features).toEqual({ browser: false, skillAuthoring: true, skillReview: false, skillReviewSteps: 10, skillsLibrary: false, shareLearnedSkills: "off", showToolCalls: false, sharedComputers: false, claudeUserMcp: false, claudeUserSkills: false, autoRecall: true, roomMemoryCapture: false, parallelRoomJobs: true, savedSteps: true, savedStepsHere: process.platform === "darwin", usbPhoneTakeover: false });const untouched = JSON.parse(readFileSync(join(home, ".openmausbot", "config.json"), "utf8"));expect(untouched.features?.skillAuthoring).toBeUndefined();expect(untouched.features?.skillReview).toBeUndefined();@@@ -9923,7 -9923,7 +9923,7 @@@features: { skillAuthoring: false },});expect(saved.status).toBe(200);- expect(saved.body.features).toEqual({ browser: false, skillAuthoring: false, skillReview: false, skillReviewSteps: 10, skillsLibrary: false, shareLearnedSkills: "off", showToolCalls: false, sharedComputers: false, claudeUserMcp: false, claudeUserSkills: false, autoRecall: true, roomMemoryCapture: false, parallelRoomJobs: true, llmThreadTitles: true, savedSteps: true, savedStepsHere: process.platform === "darwin", usbPhoneTakeover: false });- expect(saved.body.features).toEqual({ browser: false, skillAuthoring: false, skillReview: false, skillReviewSteps: 10, skillsLibrary: false, shareLearnedSkills: "off", showToolCalls: false, sharedComputers: false, claudeUserMcp: false, claudeUserSkills: false, autoRecall: true, roomMemoryCapture: false, parallelRoomJobs: false, savedSteps: true, savedStepsHere: process.platform === "darwin", usbPhoneTakeover: false });++ expect(saved.body.features).toEqual({ browser: false, skillAuthoring: false, skillReview: false, skillReviewSteps: 10, skillsLibrary: false, shareLearnedSkills: "off", showToolCalls: false, sharedComputers: false, claudeUserMcp: false, claudeUserSkills: false, autoRecall: true, roomMemoryCapture: false, parallelRoomJobs: true, savedSteps: true, savedStepsHere: process.platform === "darwin", usbPhoneTakeover: false });const disk = JSON.parse(readFileSync(join(home, ".openmausbot", "config.json"), "utf8"));// Earlier browser coverage may have persisted its own toggle: opting out must preserve sibling settings.@@@ -9931,7 -9931,7 +9931,7 @@@const tools = await api("PATCH", "/api/config", { features: { showToolCalls: true } });expect(tools.status).toBe(200);- expect(tools.body.features).toEqual({ browser: false, skillAuthoring: false, skillReview: false, skillReviewSteps: 10, skillsLibrary: false, shareLearnedSkills: "off", showToolCalls: true, sharedComputers: false, claudeUserMcp: false, claudeUserSkills: false, autoRecall: true, roomMemoryCapture: false, parallelRoomJobs: true, llmThreadTitles: true, savedSteps: true, savedStepsHere: process.platform === "darwin", usbPhoneTakeover: false });- expect(tools.body.features).toEqual({ browser: false, skillAuthoring: false, skillReview: false, skillReviewSteps: 10, skillsLibrary: false, shareLearnedSkills: "off", showToolCalls: true, sharedComputers: false, claudeUserMcp: false, claudeUserSkills: false, autoRecall: true, roomMemoryCapture: false, parallelRoomJobs: false, savedSteps: true, savedStepsHere: process.platform === "darwin", usbPhoneTakeover: false });++ expect(tools.body.features).toEqual({ browser: false, skillAuthoring: false, skillReview: false, skillReviewSteps: 10, skillsLibrary: false, shareLearnedSkills: "off", showToolCalls: true, sharedComputers: false, claudeUserMcp: false, claudeUserSkills: false, autoRecall: true, roomMemoryCapture: false, parallelRoomJobs: true, savedSteps: true, savedStepsHere: process.platform === "darwin", usbPhoneTakeover: false });const bot = (await api("POST", "/api/bots", {})).body.bot;try {diff --cc server/routes/bot-patch.test.tsindex c5e43b4688,6b4d651f7a..218eecc65f--- a/server/routes/bot-patch.test.ts+++ b/server/routes/bot-patch.test.ts@@@ -389,33 -392,67 +392,94 @@@ describe("PATCH /api/bots/:id phoneApps});});+describe("PATCH /api/bots/:id while the bot works", () => {+ const owner = { headers: { origin: "http://localhost:5173" } };++ it("saves MCP servers and tool selection for the next turn", async () => {+ const { store, bot, patch } = fixture();+ store.patchBot(bot.id, { mcpServers: ["notes"], busy: true });++ const added = await patch(bot.id, { mcpServers: ["notes", "docs"] }, owner);+ const narrowed = await patch(bot.id, { mcpServers: ["docs"] });+ const scoped = await patch(bot.id, { toolScope: { deny: ["mcp:docs:delete"] } });++ expect([added.status, narrowed.status, scoped.status]).toEqual([200, 200, 200]);+ expect(store.bot(bot.id)?.mcpServers).toEqual(["docs"]);+ expect(store.bot(bot.id)?.toolScope).toEqual({ deny: ["mcp:docs:delete"] });+ });++ it("still refuses a local script that widens MCP servers while any bot works", async () => {+ const { store, bot, patch } = fixture();+ store.patchBot(bot.id, { mcpServers: ["notes"], busy: true });++ const widened = await patch(bot.id, { mcpServers: ["notes", "docs"] });++ expect(widened.status).toBe(409);+ expect(store.bot(bot.id)?.mcpServers).toEqual(["notes"]);+ });+});++ describe("PATCH /api/bots/:id connectorScopes", () => {+ it("refuses a local-API widening while another bot works in a room, and still allows narrowing", async () => {+ let roomBotId = "";+ const { store, bot, patch } = fixture({+ activeGroupTurnForBot: (botId: string) => (botId === roomBotId ? { group: {} as never, threadId: "room-thread" } : null),+ });+ roomBotId = store.createBot({ name: "Room worker" }).id;+ const firstAndSecond: ConnectorScopes = { apps: { gmail: "read" }, accounts: { gmail: ["first", "second"] } };+ const firstOnly: ConnectorScopes = { apps: { gmail: "read" }, accounts: { gmail: ["first"] } };+ store.patchBot(bot.id, { connectorScopes: firstAndSecond });++ const widened = await patch(bot.id, { connectorScopes: { apps: { gmail: "read" }, accounts: { gmail: ["first", "second", "third"] } } });++ expect(widened.status).toBe(409);+ expect(store.bot(bot.id)?.connectorScopes).toEqual(firstAndSecond);++ const narrowed = await patch(bot.id, { connectorScopes: firstOnly });++ expect(narrowed.status).toBe(200);+ expect(store.bot(bot.id)?.connectorScopes).toEqual(firstOnly);+ });++ it("refuses a local-API widening when another bot starts working while the computer change is stopping this one", async () => {+ let otherBotId = "";+ const { store, bot, patch } = fixture({+ interruptAllDirectThreads: async () => { store.patchBot(otherBotId, { busy: true }); },+ routines: () => ({ activeBotRunForBot: () => null }),+ } as unknown as Partial<BotPatchRouteDeps>);+ otherBotId = store.createBot({ name: "Other worker" }).id;+ const firstOnly: ConnectorScopes = { apps: { gmail: "read" }, accounts: { gmail: ["first"] } };+ store.patchBot(bot.id, { computer: "local", connectorScopes: firstOnly });++ const widened = await patch(bot.id, { computer: "off", connectorScopes: { apps: { gmail: "read" }, accounts: { gmail: ["first", "second"] } } });++ expect(widened.status).toBe(409);+ expect(store.bot(bot.id)?.connectorScopes).toEqual(firstOnly);+ });++ it("refuses a local-API narrowing that became a widening after another change while the computer change was stopping this one", async () => {+ let otherBotId = "";+ let botId = "";+ const secondOnly: ConnectorScopes = { apps: { gmail: "read" }, accounts: { gmail: ["second"] } };+ const { store, bot, patch } = fixture({+ interruptAllDirectThreads: async () => {+ store.patchBot(botId, { connectorScopes: secondOnly });+ store.patchBot(otherBotId, { busy: true });+ },+ routines: () => ({ activeBotRunForBot: () => null }),+ } as unknown as Partial<BotPatchRouteDeps>);+ botId = bot.id;+ otherBotId = store.createBot({ name: "Other worker" }).id;+ const firstAndSecond: ConnectorScopes = { apps: { gmail: "read" }, accounts: { gmail: ["first", "second"] } };+ store.patchBot(bot.id, { computer: "local", connectorScopes: firstAndSecond });++ const stale = await patch(bot.id, { computer: "off", connectorScopes: { apps: { gmail: "read" }, accounts: { gmail: ["first"] } } });++ expect(stale.status).toBe(409);+ expect(store.bot(bot.id)?.connectorScopes).toEqual(secondOnly);+ });+ });+describe("PATCH /api/bots/:id mainThreadChoice", () => {it("stores the conversation the person chose, clears it with null, and refuses a routine run or another bot's thread", async () => {const { store, bot, patch } = fixture();diff --cc server/routes/bot-patch.tsindex 8aaca6adef,c080d8e844..db91dadff4--- a/server/routes/bot-patch.ts+++ b/server/routes/bot-patch.ts@@@ -659,7 -657,17 +657,12 @@@ export function createBotPatchRoutes(deif (toolScopeWidens(freshBrowserBot?.toolScope, patch.toolScope) && auth.kind === "loopback" && !DESKTOP_MANAGED && !browserOrigin && store.bots.some((candidate) => candidate.busy)) {return json(res, 409, { error: "A bot is working right now, so this change has to come from the desktop app or a paired device. Try again once every bot is idle." });}- if (freshBrowserBot && JSON.stringify(freshBrowserBot.toolScope) !== JSON.stringify(patch.toolScope)- && (freshBrowserBot.busy || activeGroupTurnForBot(freshBrowserBot.id))) {- return json(res, 409, { error: "Stop this bot's turns before changing its tool selection." });- }}+ if (body.connectorScopes !== undefined && widensConnectorScopes(freshBrowserBot?.connectorScopes, trustPatch.connectorScopes) &&+ auth.kind === "loopback" && !DESKTOP_MANAGED && !browserOrigin &&+ store.bots.some((candidate) => candidate.busy || activeGroupTurnForBot(candidate.id))) {+ return json(res, 409, { error: "A bot is working right now, so this change has to come from the desktop app or a paired device. Try again once every bot is idle." });+ }- // A running turn cannot unmount custom servers; rechecked after the awaits above.if (body.mcpServers !== undefined) {if (auth.kind === "session" && !sessions.isLive(auth.session.id)) {return json(res, 401, { error: "unauthorized: this session has expired or was revoked" });