Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
import { afterEach, describe, expect, it, vi } from "vitest";
import { routineDateTime, routineRunLabel, routineRunTone, routineRunsOn } from "./routine-display";
import { setLocale } from "./i18n";
import type { RoutineRun } from "./routines";
describe("where a routine runs", () => {
it("on the Cloud, every routine runs on schedule even when the person's computer is off", () => {
expect(routineRunsOn({ roomGoal: false, cloudHome: true })).toEqual({
label: "The Cloud", hint: "Runs on schedule, even when your computer is off.",
});
expect(routineRunsOn({ roomGoal: false, runOn: "cloud", cloudHome: true })).toEqual({
label: "Cloud desktop", hint: "Runs the whole job on the bot's cloud desktop, even when your computer is off.",
});
expect(routineRunsOn({ roomGoal: false, computer: "cloud", cloudHome: true })).toEqual({
label: "The bot's cloud desktop", hint: "Runs on schedule, even when your computer is off.",
});
expect(routineRunsOn({ roomGoal: true, cloudHome: true })).toEqual({
label: "The Cloud, with the whole group", hint: "Runs on schedule, even when your computer is off.",
});
expect(routineRunsOn({ roomGoal: false, computer: "vm", cloudHome: true }).label).toBe("The Cloud");
});
it("on a desktop, a routine starts while MausBot is open there", () => {
expect(routineRunsOn({ roomGoal: false, cloudHome: false })).toEqual({
label: "This computer", hint: "Starts while MausBot is open here.",
});
expect(routineRunsOn({ roomGoal: false, runOn: "cloud", cloudHome: false })).toEqual({
label: "Cloud desktop", hint: "Runs the whole job on the bot's cloud desktop while MausBot is open.",
});
expect(routineRunsOn({ roomGoal: false, computer: "vm", cloudHome: false }).label).toBe("The bot's private desktop");
expect(routineRunsOn({ roomGoal: true, cloudHome: false }).label).toBe("This computer, with the whole group");
});
it("never names Boat or a cloud runner", () => {
for (const cloudHome of [true, false]) {
for (const input of [{ runOn: "cloud" }, { computer: "cloud" }, {}]) {
const { label, hint } = routineRunsOn({ roomGoal: false, cloudHome, ...input });
expect(`${label} ${hint}`).not.toMatch(/boat|runner|VM\b/i);
}
}
});
});
describe("a routine's date and time", () => {
const at = new Date(2026, 9, 23, 6, 0).getTime();
afterEach(() => {
vi.unstubAllGlobals();
setLocale("en");
});
it("stays exactly as before in English, whatever the browser's region", () => {
for (const region of ["en-US", "en-GB"]) {
vi.stubGlobal("navigator", { language: region });
setLocale("en");
expect(routineDateTime(at), region).toBe(new Date(at).toLocaleString("en", { month: "short", day: "numeric", hour: "numeric", minute: "2-digit" }));
}
});
it("writes two-digit 24-hour times in pt-BR", () => {
setLocale("pt-br");
expect(routineDateTime(at)).toMatch(/06:00$/);
});
});
describe("a run's status", () => {
const run = (patch: Partial<RoutineRun>) => ({ id: "r", routineId: "x", routineName: "Brief", botId: "b", status: "failed", manual: false, scheduledFor: 0, createdAt: 0, ...patch }) as RoutineRun;
it("reads partly done, in the waiting colour, when only a step failed after the reply came back", () => {
expect(routineRunLabel(run({ partial: true }))).toBe("Partly done");
expect(routineRunTone(run({ partial: true }))).toBe("text-warning");
expect(routineRunLabel(run({ partial: true, retried: "failed" }))).toBe("Retried after a failure · Partly done");
});
it("still reads failed, in red, for any other failure", () => {
expect(routineRunLabel(run({}))).toBe("Failed");
expect(routineRunTone(run({}))).toBe("text-danger");
expect(routineRunLabel(run({ status: "completed", partial: true }))).toBe("Completed");
});
it("reads a completed run that kept its failing step partly done, in the waiting colour", () => {
expect(routineRunLabel(run({ status: "completed", partial: true, error: "Stopped because the tool call “read_file” failed." }))).toBe("Partly done");
expect(routineRunTone(run({ status: "completed", partial: true, error: "Stopped because the tool call “read_file” failed." }))).toBe("text-warning");
expect(routineRunLabel(run({ status: "completed", partial: true }))).toBe("Completed");
});
});
describe("a routine that keeps its chat's computer", () => {
it("shows that computer, over the bot's Works on setting, and says it is set for the routine", () => {
const kept = (computer: "local" | "vm" | "cloud" | "browser", cloudHome = false) => routineRunsOn({ roomGoal: false, computer: "cloud", kept: computer, cloudHome });
const hint = "Set for this routine: a run that starts a new conversation uses it, one that continues a conversation keeps that conversation's computer. Change it in Edit.";
expect(kept("vm")).toEqual({ label: "The bot's private desktop", hint });
expect(kept("local")).toEqual({ label: "This computer", hint });
expect(kept("browser")).toEqual({ label: "The built-in browser", hint });
expect(kept("cloud", true)).toEqual({ label: "The bot's cloud desktop", hint });
expect(kept("vm", true)).toEqual({ label: "The bot's private desktop", hint });
expect(routineRunsOn({ roomGoal: false, runOn: "cloud", kept: "vm", cloudHome: false }).label).toBe("Cloud desktop");
});
});