Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
import { createElement } from "react";
import { renderToStaticMarkup } from "react-dom/server";
import { afterEach, expect, it } from "vitest";
import type { Bot } from "@/state/store";
import { setTeamPeople, teamBotName } from "@/state/team-people";
import { BotPickerList } from "./BotPickerList";
const helper = (id: string, person: string) => ({ id, threadId: `t-${id}`, name: "MausBot", title: "", description: "", notifications: true, color: "green", unread: false,
messages: [], modelSelection: { instanceId: "x", model: "x" }, defaultBot: { person } }) as unknown as Bot;
const bots = [helper("mine", "[email protected]"), helper("ada", "[email protected]"), helper("ben", "[email protected]")];
const olive = { email: "[email protected]", name: "Olive", role: "owner", you: true as const };
const team = { people: [olive, { email: "[email protected]", name: "Ada", role: "member" }, { email: "[email protected]", name: "Ben", role: "admin" }], me: olive, admin: true, needsYou: [] };
afterEach(() => setTeamPeople(null));
it("names each teammate's MausBot for its person in a picker, and the viewer's own as it is", () => {
setTeamPeople(team);
const html = renderToStaticMarkup(createElement(BotPickerList, { bots, picked: new Set<string>(), onToggle: () => {}, emptyHint: "" }));
expect(html.match(/role="checkbox" aria-label="[^"]*"/g)?.map((match) => match.slice(match.indexOf("aria-label")))).toEqual(['aria-label="MausBot"', 'aria-label="MausBot · Ada"', 'aria-label="MausBot · Ben"']);
});
it("names a MausBot whose person is not in the list by their address", () => {
expect(teamBotName(helper("x", "[email protected]"), team)).toBe("MausBot · Dan Smith");
expect(teamBotName({ name: "Scout" }, team)).toBe("Scout");
});
it("leaves names alone off a team", () => {
const html = renderToStaticMarkup(createElement(BotPickerList, { bots, picked: new Set<string>(), onToggle: () => {}, emptyHint: "" }));
expect(html).not.toContain("·");
});