Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
A guest's question still reaches the owner's inbox, labelled, and the guest's conversation stays confined
milind-soni2f0f279740ad
diff --git a/server/host/outside-fence.test.ts b/server/host/outside-fence.test.tsindex 722f45848b..aeb44e7232 100644--- a/server/host/outside-fence.test.ts+++ b/server/host/outside-fence.test.ts@@ -4,7 +4,7 @@ import { OUTSIDE_REFUSAL, outsideRouteRefused } from "./outside-fence.ts";describe("what a confined turn reaches of OpenMausBot's own routes", () => {it("refuses what runs or starts something with no person deciding", () => {- for (const path of ["vm-exec", "fill-login", "create-room", "computer/select", "phone/claim", "device/mcp", "people/message", "pages/publish", "pages/unpublish", "request-credential", "request-sign-in", "threads/abc/close"]) {+ for (const path of ["vm-exec", "fill-login", "create-room", "computer/select", "phone/claim", "device/mcp", "pages/publish", "pages/unpublish", "request-credential", "request-sign-in", "threads/abc/close"]) {expect(outsideRouteRefused("POST", `/api/internal/${path}`), path).toBe(true);}});diff --git a/server/host/outside-fence.ts b/server/host/outside-fence.tsindex cf29bb11b4..97fad3526d 100644--- a/server/host/outside-fence.ts+++ b/server/host/outside-fence.ts@@ -11,6 +11,8 @@ const EXACT: ReadonlySet<string> = new Set(["POST /api/internal/tool-result","POST /api/internal/options-card","POST /api/internal/escalate",+ // In its own conversation, where a place's inbox labels a guest's words and keeps them from the owner's; a team refuses it.+ "POST /api/internal/people/message","POST /api/internal/attach-file","POST /api/internal/voice-note","GET /api/internal/agents",diff --git a/server/host/team-messages.ts b/server/host/team-messages.tsindex d8243f330f..9a1ad91ad9 100644--- a/server/host/team-messages.ts+++ b/server/host/team-messages.ts@@ -25,6 +25,7 @@ import type { BotRecord, GroupRecord, Message, Store, StoreChange } from "../stoimport type { TeamPeople } from "../team-people.ts";import { currentTimeZone } from "../time-zone.ts";import { loadMemory } from "../workspace.ts";+import { OUTSIDE_REFUSAL } from "./outside-fence.ts";import type { PlaceInbox } from "./place-inbox.ts";import { createPersonInbox, type Delivery, type Item, type Passed, type PersonInbox, type PersonInboxDeps } from "./person-inbox.ts";import { createRepresentative, type RepresentativeDeps } from "./representative.ts";@@ -319,6 +320,7 @@ export function createTeamMessages(deps: TeamMessagesDeps) {return ctx.json(ctx.res, sent.status, sent.status === 200 ? { text: sent.text } : { error: sent.text });}if (!team || !deps.people) return ctx.json(ctx.res, 404, { error: "Passing a message to a person works only on a team's Cloud." });+ if (deps.confined?.(ctx.threadId)) return ctx.json(ctx.res, 403, { error: OUTSIDE_REFUSAL });const body = bodySchema.safeParse(await ctx.readBody());if (!body.success) return ctx.json(ctx.res, 400, { error: `message_person needs to (a teammate's name or email) and message (up to ${MESSAGE_PERSON_MAX} characters).` });const passed = pass(ctx.botId, ctx.threadId, body.data.to, body.data.message);diff --git a/server/place-inbox.e2e.test.ts b/server/place-inbox.e2e.test.tsindex c0af6b2c9e..3db7bc7281 100644--- a/server/place-inbox.e2e.test.ts+++ b/server/place-inbox.e2e.test.ts@@ -201,7 +201,8 @@ describe("on a Cloud someone else once used", () => {const owners = await h.thread(zed.id, "My work");h.script(zed.id,{ key: "G1", match: ["G1-GO"], timeoutMs: 120_000, steps: [{ server: "agents", tool: "message_person", arguments: { message: "For the guest" } }, { server: "ogb", tool: "ask_user", arguments: { question: "Guest's question?", choices: ["A", "B"] }, capture: { answer: "([\\s\\S]+)" } }], reply: "G1: {{answer}}" },- { key: "G2", match: ["G2-GO"], timeoutMs: 120_000, steps: [{ server: "ogb", tool: "ask_user", arguments: { question: "Owner's question?", choices: ["A", "B"] }, capture: { answer: "([\\s\\S]+)" } }], reply: "G2: {{answer}}" });+ { key: "G2", match: ["G2-GO"], timeoutMs: 120_000, steps: [{ server: "ogb", tool: "ask_user", arguments: { question: "Owner's question?", choices: ["A", "B"] }, capture: { answer: "([\\s\\S]+)" } }], reply: "G2: {{answer}}" },+ { key: "G3", match: ["G3-GO"], reply: "G3 done" });markLeftBehind(join(fx.root, "cloud", ".openmausbot"), { threadIds: [theirs] });await fx.relaunch({ cloud: {} });@@ -216,5 +217,13 @@ describe("on a Cloud someone else once used", () => {expect((await h.messages(theirs)).some((line) => line.text === "For the guest"), "the bot did send it").toBe(true);expect(rows.some((row) => row.text === "For the guest"), "a guest's news isn't the owner's").toBe(false);expect((await h.notes()).some((note) => note.body === "For the guest")).toBe(false);+ // The owner's answer reaches the guest's turn, and the guest's conversation stays confined after it.+ const answered = await fx.onCloud("POST", `/api/threads/${theirs}/respond`, { requestId: guests.card!.requestId, behavior: "answer", message: "A" });+ expect(answered.status, JSON.stringify(answered.body)).toBe(200);+ await until(async () => (await h.messages(theirs)).some((line) => line.text === "G1: A"), "the guest's turn to go on");+ await h.say(zed.id, theirs, "G3-GO");+ await until(() => h.turns(zed.id).some((turn) => turn.planKey === "G3"), "a later turn in the guest's conversation");+ const restricted = (key: string) => (h.turns(zed.id).find((turn) => turn.planKey === key) as { restricted?: boolean } | undefined)?.restricted;+ expect([restricted("G1"), restricted("G3")]).toEqual([true, true]);}, hostTimeout(420_000));});