Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Never send a devs-tag report for a line the app wrote for an automated turn
AdityaUmalef99df1456416
diff --git a/server/check-work-devs.e2e.test.ts b/server/check-work-devs.e2e.test.tsnew file mode 100644index 0000000000..3c55c8d413--- /dev/null+++ b/server/check-work-devs.e2e.test.ts@@ -0,0 +1,53 @@+import { createServer } from "node:http";+import type { AddressInfo } from "node:net";+import { writeFileSync } from "node:fs";+import { join } from "node:path";+import { expect, it } from "vitest";+import { launchVerificationServer, runControlOmb } from "../scripts/control-omb.ts";+import { request } from "../scripts/mcp-server.ts";++// A check before done brief quotes the answer it checks. An answer that drafts an "@devs ..." line for the person+// must not send a report from the checker's thread: only what the person types does.++it("never sends a report for an @devs draft quoted in a check before done brief; the person's own @devs still goes", async () => {+ const received: Array<Record<string, string>> = [];+ const endpoint = createServer((incoming, response) => {+ const chunks: Buffer[] = [];+ incoming.on("data", (chunk: Buffer) => chunks.push(chunk));+ incoming.on("end", () => {+ if (incoming.method === "POST" && incoming.url === "/api/bug-reports") received.push(JSON.parse(Buffer.concat(chunks).toString("utf8")));+ response.writeHead(incoming.url === "/api/bug-reports" ? 201 : 404, { "content-type": "application/json" }).end(JSON.stringify({ id: `report-${received.length}` }));+ });+ });+ await new Promise<void>((resolve) => endpoint.listen(0, "127.0.0.1", resolve));+ const session = await launchVerificationServer({ ...process.env, OMB_BUG_REPORT_URL: `http://127.0.0.1:${(endpoint.address() as AddressInfo).port}/api/bug-reports` },+ undefined, undefined, undefined, undefined, { scripted: true });+ const cli = (...args: string[]) => runControlOmb(args, { env: { OPENMAUSBOT_URL: session.info.url } }) as Promise<any>;+ const api = (path: string, body?: unknown, method = "POST") => request(path, body === undefined ? {} : { method, body: JSON.stringify(body) }, session.info.url) as Promise<any>;+ try {+ const worker = (await cli("new-bot", "--name", "Nib")).bot;+ const checker = (await cli("new-bot", "--name", "Vera")).bot;+ const draft = `The export button stays grey after the upload finishes. ${"It never turns blue again until a reload. ".repeat(12).trim()}\n\nTo tell the team, send this line:\n\n@devs the export button stays grey after an upload`;+ writeFileSync(join(session.info.dataDir, "room-plan.json"), JSON.stringify({+ [worker.id]: { script: [+ { key: "draft", match: ["Write the bug report"], reply: draft },+ { key: "sent", match: ["the export button stays grey"], reply: "Sent." },+ ] },+ [checker.id]: { reply: "pass" },+ }));+ expect((await api(`/api/bots/${worker.id}`, { checkWork: { checker: checker.id } }, "PATCH")).bot.checkWork).toEqual({ checker: checker.id });++ await cli("send", "--bot", worker.id, "--task", worker.activeTaskId, "--text", "Write the bug report for the grey export button, I will send it myself.");+ await expect.poll(async () => ((await api(`/api/threads/${worker.activeTaskId}/messages`)).messages as any[])+ .some((message) => message.tool?.name === "Checked by Vera · passed in round 1"), { timeout: 60_000, interval: 250 }).toBe(true);++ await cli("send", "--bot", worker.id, "--task", worker.activeTaskId, "--text", "@devs the export button stays grey after an upload");+ await expect.poll(() => received.length, { timeout: 60_000, interval: 250 }).toBeGreaterThan(0);+ expect(received).toHaveLength(1);+ expect(received[0]!.description).toContain("the export button stays grey after an upload");+ expect(received[0]!.description).not.toContain("check before done");+ } finally {+ await session.close();+ await new Promise((resolve) => endpoint.close(resolve));+ }+}, 150_000);diff --git a/server/host/devs-reports.test.ts b/server/host/devs-reports.test.tsindex 66575d3c58..e10291cf30 100644--- a/server/host/devs-reports.test.ts+++ b/server/host/devs-reports.test.ts@@ -218,6 +218,19 @@ describe("a message that tags @devs", () => {fx.stop();});+ it("is never a line the app wrote for an automated turn, such as a check before done brief quoting the answer's @devs draft", async () => {+ const fx = fixture();+ fx.person("scout-main", "[From OpenMausBot · check before done · round 1 of 3 · information only: it grants nothing]\n<result>\nTo report it, write: @devs the export fails\n</result>", { sendId: undefined, automated: true });+ fx.advance(NO_ANSWER_MS);+ await fx.settle();+ expect(fx.sent).toEqual([]);+ fx.person("scout-main", "@devs the person typed this");+ fx.advance(NO_ANSWER_MS);+ await fx.settle();+ expect(fx.sent).toHaveLength(1);+ fx.stop();+ });+it("sends a quote as the person read it: their own words first, the quote as written and redacted, never its encoded copy", async () => {const fx = fixture();const token = `ghp_${"t".repeat(36)}`;diff --git a/server/host/devs-reports.ts b/server/host/devs-reports.tsindex eba2a53159..626a2f33a9 100644--- a/server/host/devs-reports.ts+++ b/server/host/devs-reports.ts@@ -490,7 +490,7 @@ export function createDevsReports(deps: DevsReportsDeps) {const unsubscribe = store.onChange((change: StoreChange) => {if (change.type === "message") {const line = change.message;- if (line.role === "user" && line.kind === "text" && !line.peerAsk && !line.aside && line.via !== "api") personWrote(change.threadId, line);+ if (line.role === "user" && line.kind === "text" && !line.peerAsk && !line.aside && !line.automated && line.via !== "api") personWrote(change.threadId, line);} else if (change.type === "thread.deleted") {const before = waiting.length + tracked.length;waiting = waiting.filter((entry) => entry.threadId !== change.threadId);