Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Follow the webhook results chat in the tests; a quoted URL may end a sentence
milind-sonie3299326a08e
diff --git a/server/composio.test.ts b/server/composio.test.tsindex f5c3eddbab..1bddd951cf 100644--- a/server/composio.test.ts+++ b/server/composio.test.ts@@ -1026,7 +1026,7 @@ describe.sequential("Composio Sessions", () => {});it("reads a broker that sends no complete field as complete, and an explicit false as incomplete", async () => {- setManagedBrokerAccess({ url: origin + "/broker", token: "7".repeat(64) });+ setManagedBrokerAccess({ url: origin + "/broker", token: "a".repeat(64) });try {brokerConnectedServicesBody = { services: { gmail: { connected: true, status: "ACTIVE" } } };await expect(connectedServicesInventory({})).resolves.toMatchObject({ complete: true });diff --git a/server/memory-fact-checks.test.ts b/server/memory-fact-checks.test.tsindex d1f09597c2..bb85f04e14 100644--- a/server/memory-fact-checks.test.ts+++ b/server/memory-fact-checks.test.ts@@ -8,7 +8,7 @@ const chats = [person("Anna likes short replies too."),];const quotes = [chats[0]!.lines[0]!.text, chats[1]!.lines[0]!.text];-const check = (text: string, evidence: readonly string[] | undefined = quotes) => checkDreamFacts(text, [1, 2], evidence, chats);+const check = (text: string, evidence: readonly string[] = quotes) => checkDreamFacts(text, [1, 2], evidence, chats);describe("the checks before a dream saves a fact", () => {it("keeps an entry whose numbers, paths and URLs all come from the quotes", () => {@@ -30,7 +30,7 @@ describe("the checks before a dream saves a fact", () => {it("needs one real statement by the person in each cited conversation", () => {expect(check("Anna likes short replies", ["Invented quotation", quotes[1]!])).toBe(false);expect(check("Anna likes short replies", [])).toBe(false);- expect(check("Anna likes short replies", undefined)).toBe(false);+ expect(checkDreamFacts("Anna likes short replies", [1, 2], undefined, chats)).toBe(false);expect(checkDreamFacts("Anna likes tea", [1], ["Anna likes tea"], [{ threadId: "q", lines: [{ by: "bot", text: "Anna likes tea" }] }])).toBe(false);expect(checkDreamFacts("Anna likes tea", [1], ["Anna likes tea"], [person("Suppose Anna likes tea?")])).toBe(false);});diff --git a/server/memory-fact-checks.ts b/server/memory-fact-checks.tsindex df4200063f..929545396f 100644--- a/server/memory-fact-checks.ts+++ b/server/memory-fact-checks.ts@@ -4,7 +4,7 @@ import { redactSecretsInText } from "./redact.ts";const LOCATION = /https?:\/\/[^\s<>[\]()]+|(?:~\/|(?<![\p{L}\p{N}])\/[\p{L}_.]|[A-Za-z]:\\)[^\s<>[\](),;]*/gu;const NUMBER = /\p{N}+(?:[.,:/-]\p{N}+)*%?/gu;-const matches = (text: string, pattern: RegExp) => [...text.matchAll(pattern)].map((m) => m[0].toLowerCase());+const matches = (text: string, pattern: RegExp) => [...text.matchAll(pattern)].map((m) => m[0].toLowerCase().replace(/[.,:;!?'"]+$/u, ""));export function checkDreamFacts(text: string, from: readonly number[], evidence: readonly string[] | undefined, chats: readonly DreamConversation[]): boolean {if (!evidence || evidence.length !== from.length || redactSecretsInText(text) !== text) return false;diff --git a/server/phones.e2e.test.ts b/server/phones.e2e.test.tsindex 547c884bd5..0c654f4616 100644--- a/server/phones.e2e.test.ts+++ b/server/phones.e2e.test.ts@@ -297,12 +297,9 @@ it("a thread a webhook's run opens has no phone; one the owner's turn opens doesit("a conversation an outside event's run reported into loses the phone", async () => {await settle();- // Off a Cloud home an outside event's run reports into the bot's main chat (the one the person asked in last): here a- // new conversation of the owner's, which has the phone until then.- const main = (await api("POST", `/api/bots/${chief.id}/tasks`, { title: "Leads" })).body.task.threadId as string;- const before = await turn({ id: chief.id, threadId: main }, "Anything new today?");+ const own = (await api("POST", `/api/bots/${chief.id}/tasks`, { title: "Leads" })).body.task.threadId as string;+ const before = await turn({ id: chief.id, threadId: own }, "Anything new today?");expect(before.mcpConfig.mcpServers).toHaveProperty(PHONE_MCP_SERVER);- expect((await api("GET", "/api/bots")).body.bots.find((bot: { id: string }) => bot.id === chief.id).mainThreadId).toBe(main);await settle();const digest = await hook("Lead digest");writeFileSync(release, "");@@ -313,12 +310,16 @@ it("a conversation an outside event's run reported into loses the phone", async} finally {rmSync(release, { force: true });}- expect((await runOf(runId)).report.threadId).toBe(main);- expect((await api("GET", `/api/threads/${main}/messages?limit=200`)).body.messages+ const results = (await runOf(runId)).report.threadId as string;+ expect(results).not.toBe(own);+ expect((await api("GET", `/api/threads/${results}/messages?limit=200`)).body.messages.some((line: { automation?: { routineId?: string; trigger?: string } }) => line.automation?.routineId === digest.id && line.automation.trigger === "webhook")).toBe(true);await settle();- const after = await turn({ id: chief.id, threadId: main }, "What did that lead want?");+ const after = await turn({ id: chief.id, threadId: results }, "What did that lead want?");expect(after.mcpConfig.mcpServers[PHONE_MCP_SERVER]).toBeUndefined();+ await settle();+ const untouched = await turn({ id: chief.id, threadId: own }, "Anything else today?");+ expect(untouched.mcpConfig.mcpServers).toHaveProperty(PHONE_MCP_SERVER);}, 90_000);it("a send reaches the phone with no card of OpenMausBot's own in the chat: the person taps Send on the phone", async () => {diff --git a/server/triggers.e2e.test.ts b/server/triggers.e2e.test.tsindex 09495442ac..cf705d12dc 100644--- a/server/triggers.e2e.test.ts+++ b/server/triggers.e2e.test.ts@@ -94,12 +94,16 @@ it("sets up schedule and webhook triggers from chat at Ask, with no confirmationexpect(retry).toMatchObject({ duplicate: true, runId: accepted.runId });await expect.poll(async () => (await api("GET", "/api/routines")).runs.find((run: any) => run.id === accepted.runId)?.status, { timeout: 20_000 }).toBe("completed");- // 4. Each run reports in the conversation that made it as the bot's own line, never as a card per run.+ // 4. A schedule's run reports in the conversation that made it, a webhook's in a chat of its own, each as the bot's own line, never as a card per run.const { run } = await api("POST", `/api/routines/${routineId}/run`, undefined, 201);await expect.poll(async () => (await api("GET", "/api/routines")).runs.find((candidate: any) => candidate.id === run.id)?.status, { timeout: 20_000 }).toBe("completed");expect((await messages()).some((message) => message.kind === "routine.run")).toBe(false);- await expect.poll(async () => (await messages()).filter((message) => message.automation).map((message) => [message.automation.runId, message.text]), { timeout: 20_000 })- .toEqual([[accepted.runId, "Drafted the follow-up."], [run.id, "Drafted the follow-up."]]);+ const reports = async (id: string) => (await api("GET", `/api/threads/${id}/messages?limit=200`)).messages+ .filter((message: any) => message.automation).map((message: any) => [message.automation.runId, message.text]);+ await expect.poll(() => reports(threadId), { timeout: 20_000 }).toEqual([[run.id, "Drafted the follow-up."]]);+ const webhookChat = (await api("GET", "/api/routines")).runs.find((candidate: any) => candidate.id === accepted.runId).resultsThreadId as string;+ expect(webhookChat).not.toBe(threadId);+ await expect.poll(() => reports(webhookChat), { timeout: 20_000 }).toEqual([[accepted.runId, "Drafted the follow-up."]]);// 5. manage_trigger pauses it, at Ask, with no card.const paused = await turn("Pause the morning summary.", [{ tool: "manage_trigger", arguments: { trigger_id: routineId, action: "pause" } }]);