Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Clarify observed status after failed checks
WAI LOK HO149441651d14
diff --git a/server/cloud-computer-background.test.ts b/server/cloud-computer-background.test.tsindex dee17791e8..4c9cf50c64 100644--- a/server/cloud-computer-background.test.ts+++ b/server/cloud-computer-background.test.ts@@ -82,7 +82,7 @@ describe("background status deadlines", () => {expect(await pending).toMatchObject({ isError: true, content: [{ text: expect.stringContaining("call exec_status again") }] });});- it.each(["finished", "running", "slow", "timeout", "not_found", "server_error", "malformed"] as const)("checks a short wait on a controlled clock: %s", async outcome => {+ it.each(["finished", "running", "late", "slow", "timeout", "not_found", "server_error", "malformed"] as const)("checks a short wait on a controlled clock: %s", async outcome => {vi.useFakeTimers();vi.setSystemTime(new Date("2026-01-01T00:00:00.000Z"));const clock = {@@ -99,7 +99,7 @@ describe("background status deadlines", () => {if (outcome === "slow") return new Promise<Response>(resolve => setTimeout(() => resolve(Response.json({ running: false, exitCode: 3, stdout: "final", stderr: "" })), 400));if (outcome === "not_found" || outcome === "server_error") return Response.json({ message: "unavailable" }, { status: outcome === "not_found" ? 404 : 503 });if (outcome === "malformed") return Response.json({});- if (outcome !== "timeout") return Response.json({ running: outcome === "running", exitCode: 3, stdout: "final", stderr: "" });+ if (outcome !== "timeout") return Response.json({ running: outcome === "running" || (outcome === "late" && Date.now() < Date.parse("2026-01-01T00:00:00.700Z")), exitCode: 3, stdout: "final", stderr: "" });return new Promise<Response>((_resolve, reject) => {init?.signal?.addEventListener("abort", () => reject(init.signal!.reason), { once: true });});@@ -115,13 +115,12 @@ describe("background status deadlines", () => {expect(result).toMatchObject({ status: "running", exitCode: null, stdout: "partial", observedAt: "2026-01-01T00:00:00.000Z", note: expect.stringContaining("may have changed") });} else if (outcome === "not_found" || outcome === "server_error" || outcome === "malformed") {expect(raw.isError).toBe(true);- expect(result).toMatchObject({ error: expect.any(String), lastObserved: { observedAt: "2026-01-01T00:00:00.000Z", stdout: outcome === "server_error" ? "x".repeat(4_000) : "partial", stderr: "", note: expect.stringContaining("may have changed") } });- expect(result.lastObserved.status).toBeUndefined();+ expect(result).toMatchObject({ error: expect.any(String), lastObserved: { processId, status: "running", observedAt: "2026-01-01T00:00:00.000Z", stdout: outcome === "server_error" ? "x".repeat(4_000) : "partial", stderr: "", note: expect.stringContaining("may have changed") } });if (outcome === "server_error") expect(result.lastObserved.outputCut).toContain("Only the end");if (outcome === "not_found") expect(result.error).toContain("no background command");if (outcome === "malformed") expect(result.error).toContain("unreadable answer");} else {- expect(result).toMatchObject({ status: outcome === "running" ? "running" : "finished", exitCode: outcome === "running" ? null : 3, stdout: "final" });+ expect(result).toMatchObject({ status: outcome === "running" || outcome === "late" ? "running" : "finished", exitCode: outcome === "running" || outcome === "late" ? null : 3, stdout: "final" });expect(result.observedAt).toBeUndefined();}});diff --git a/server/cloud-computer-background.ts b/server/cloud-computer-background.tsindex af0a4d13ff..929b783901 100644--- a/server/cloud-computer-background.ts+++ b/server/cloud-computer-background.ts@@ -143,15 +143,15 @@ function describeStatus(processId: string, body: any, observedAt?: number): Clou}));}-function statusError(message: string, last?: { body: any; observedAt: number }): CloudComputerResult {+function statusError(message: string, processId: string, last?: { body: any; observedAt: number }): CloudComputerResult {if (!last) return text(message, true);const stdout = tail(last.body.stdout, STDOUT_TAIL_CHARS), stderr = tail(last.body.stderr, STDERR_TAIL_CHARS);return text(JSON.stringify({error: message,lastObserved: {- observedAt: new Date(last.observedAt).toISOString(), stdout: stdout.text, stderr: stderr.text,+ processId, status: "running", observedAt: new Date(last.observedAt).toISOString(), stdout: stdout.text, stderr: stderr.text,...(stdout.cut || stderr.cut || last.body.stdoutTruncated === true || last.body.stderrTruncated === true ? { outputCut: CUT } : {}),- note: "These outputs were last observed at this time and may have changed.",+ note: "This status and output were last observed at this time and may have changed.",},}), true);}@@ -183,9 +183,9 @@ export async function backgroundStatus(if (deadline?.aborted) return last ? describeStatus(args.process_id, last.body, last.observedAt) : text(STATUS_LATE, true);throw error;}- if (response.status === 404) return statusError(UNKNOWN_PROCESS, last);- if (!response.ok) return statusError(boatErrorMessage(response.status, "Reading the command's status", body, included(cfg)), last);- if (typeof body?.running !== "boolean") return statusError("The cloud computer gave an unreadable answer about this command. Call exec_status again.", last);+ if (response.status === 404) return statusError(UNKNOWN_PROCESS, args.process_id, last);+ if (!response.ok) return statusError(boatErrorMessage(response.status, "Reading the command's status", body, included(cfg)), args.process_id, last);+ if (typeof body?.running !== "boolean") return statusError("The cloud computer gave an unreadable answer about this command. Call exec_status again.", args.process_id, last);if (!body.running) untrack(boxId, processId);const observedAt = clock.now();last = { body, observedAt };diff --git a/server/cloud-computer-tools.test.ts b/server/cloud-computer-tools.test.tsindex 80df7f72ed..66297b6f40 100644--- a/server/cloud-computer-tools.test.ts+++ b/server/cloud-computer-tools.test.ts@@ -48,7 +48,7 @@ const rpc = (request: unknown, gate: { held: boolean; reason?: "person"; blockeddescribe("cloud computer tools", () => {it("lists the same thirteen tools for every engine", async () => {- const listed = await rpc({ method: "tools/list", params: {} }).done as { tools: Array<{ name: string; description: string }> };+ const listed = await rpc({ method: "tools/list", params: {} }).done as { tools: Array<{ name: string; description: string; inputSchema: { properties: Record<string, { description?: string }> } }> };expect(listed.tools.map(tool => tool.name)).toEqual(["screenshot", "get_screen_size", "click", "move", "drag", "type_text", "key_press", "scroll", "open_url", "exec", "exec_status","copy_from_computer", "copy_to_computer",@@ -59,6 +59,8 @@ describe("cloud computer tools", () => {expect(exec.description).toContain("use exec_status with wait_seconds in this turn");expect(exec.description).toContain("check its exit code and output");expect(exec.description).toContain("report the work as unfinished with the process_id");+ const status = listed.tools.find(tool => tool.name === "exec_status")!;+ expect(status.inputSchema.properties.wait_seconds.description).toContain("A running result can arrive before the full interval");});it.each([diff --git a/server/cloud-computer-tools.ts b/server/cloud-computer-tools.tsindex 61793b59d4..545c162dc2 100644--- a/server/cloud-computer-tools.ts+++ b/server/cloud-computer-tools.ts@@ -30,7 +30,7 @@ export const CLOUD_COMPUTER_TOOLS = [}, ["command"]),tool("exec_status", `Check a command started with exec and background: true: running or finished, its exit code, and the end of its stdout and stderr (the last ${STDOUT_TAIL_CHARS.toLocaleString("en-US")} and ${STDERR_TAIL_CHARS.toLocaleString("en-US")} characters).`, {process_id: { type: "string", pattern: PROCESS_ID_PATTERN },- wait_seconds: { type: "integer", minimum: 0, maximum: STATUS_WAIT_MAX_SECONDS, description: "Wait up to this many seconds for the command to finish before answering." },+ wait_seconds: { type: "integer", minimum: 0, maximum: STATUS_WAIT_MAX_SECONDS, description: "Wait up to this many seconds for the command to finish before answering. A running result can arrive before the full interval because the last status read needs time to respond." },}, ["process_id"]),tool("copy_from_computer", "Copy one file of up to 2 GiB from the cloud computer into your working folder, for example to load it with data_load or use it in a page. A file already there is replaced.", {path: { type: "string", minLength: 1, maxLength: 4096, description: "The file on the cloud computer, under /home/user or /tmp." },