Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
test(team): pin the backup, setup card and leaving guards around the crown
milind-soni34bc3064b819
diff --git a/server/host/member-own-bot.test.ts b/server/host/member-own-bot.test.tsnew file mode 100644index 0000000000..06bdad747b--- /dev/null+++ b/server/host/member-own-bot.test.ts@@ -0,0 +1,28 @@+import { describe, expect, it } from "vitest";++import type { BotRecord } from "../store.ts";+import { createMemberOwnBot, type MemberOwnBotDeps } from "./member-own-bot.ts";++function world(deleted: { status: number; body: { error?: string } }) {+ const bot = { id: "bens", defaultBot: { person: "[email protected]" }, chiefOfStaff: true, sidebarHidden: true } as unknown as BotRecord;+ let duringDelete: Partial<BotRecord> | null = null;+ const deps = {+ store: () => ({ bot: () => bot, patchBot: (_id: string, patch: Partial<BotRecord>) => Object.assign(bot, patch) }),+ deleteBot: async () => { duringDelete = { ...bot }; return deleted; },+ } as unknown as MemberOwnBotDeps;+ return { bot, own: createMemberOwnBot(deps), duringDelete: () => duringDelete };+}++describe("a member's own MausBot when they leave", () => {+ it("gives up its mark and its crown before it is deleted, so it is never left a department's Chief", async () => {+ const w = world({ status: 200, body: {} });+ expect(await w.own.remove("bens")).toBe(true);+ expect(w.duringDelete()).toMatchObject({ defaultBot: undefined, chiefOfStaff: undefined });+ });++ it("is theirs again, crown included, if it could not be deleted", async () => {+ const w = world({ status: 409, body: { error: "busy" } });+ expect(await w.own.remove("bens")).toBe(false);+ expect(w.bot).toMatchObject({ defaultBot: { person: "[email protected]" }, chiefOfStaff: true, sidebarHidden: true });+ });+});diff --git a/server/team-backup.test.ts b/server/team-backup.test.tsindex 72185853ce..a14513323e 100644--- a/server/team-backup.test.ts+++ b/server/team-backup.test.ts@@ -5,6 +5,7 @@ import { createAgentCard } from "./chat-widgets.ts";import { DATA_DIR } from "./config.ts";import { Store, UNTITLED_TASK } from "./store.ts";import { RoutineManager } from "./routines.ts";+import { ensureDefaultBot } from "./default-bot.ts";import { createTeamBackup, importTeamBackup } from "./team-backup.ts";import { parseTeamBackup } from "../shared/team-backup.ts";import { approvalModeFor } from "../shared/approval-mode.ts";@@ -60,6 +61,15 @@ function fixture() {describe("additive portable team backups", () => {beforeEach(() => rmSync(DATA_DIR, { recursive: true, force: true }));+ it("stays valid on a Team Cloud with several members' crowned MausBots, none of them a Chief in the backup", () => {+ const store = new Store(selection);+ const department = store.createBot({ name: "Clive" });+ store.setChiefOfStaff(department.id);+ for (const person of ["[email protected]", "[email protected]"]) expect(ensureDefaultBot(store, { dataDir: DATA_DIR, person })?.chiefOfStaff).toBe(true);+ const backup = createTeamBackup(store, [], "Acme");+ expect(backup.bots.filter((bot) => bot.chiefOfStaff).map((bot) => bot.name)).toEqual(["Clive"]);+ });+it("carries tool restrictions through backup and import without restoring execution grants", () => {const { store, routines, chief, scout } = fixture();const scope = { allow: ["native:read", "mcp:notes:read"], deny: ["mcp:notes:write"] };diff --git a/server/team-setup-requests.test.ts b/server/team-setup-requests.test.tsindex 24507e7098..c35480f309 100644--- a/server/team-setup-requests.test.ts+++ b/server/team-setup-requests.test.ts@@ -64,6 +64,12 @@ const specialist = (key: string, section: string, modelSelection = { instanceId:fields: { name: key, title: "Specialist", soul: "Finish the assigned work.", section, modelSelection } });describe("reviewed Chief team setup", () => {+ it("never lets a member's crowned MausBot change who the Chief is", () => {+ const h = harness(); h.peer.section = "Engineering";+ h.store.bots[0]!.defaultBot = { person: "[email protected]" };+ expect(() => h.propose([{ action: "update", botId: h.peer.id, fields: { chiefOfStaff: true } }])).toThrow(/Only the Chief of Staff changes who the Chief is/);+ });+it("reviews promotion in an authorized team without changing anything on denial", async () => {const h = harness(); h.peer.section = "Engineering";const before = structuredClone(h.store.bots);