Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(moves): an arriving MausBot keeps off the crown of any Chief here when the used MausBot stays
AdityaUmalec195b35434bf
diff --git a/server/cloud-send-kinds.ts b/server/cloud-send-kinds.tsindex cc947dcd45..22d7fbf6fc 100644--- a/server/cloud-send-kinds.ts+++ b/server/cloud-send-kinds.ts@@ -293,9 +293,11 @@ function applyBotFields(deps: MoveKindsDeps, id: string, raw: unknown, source: Aif (Object.hasOwn(fields, "chiefOfStaff") && fields.chiefOfStaff !== true) patch.chiefOfStaff = fields.chiefOfStaff ?? undefined;if (fields.chiefOfStaff === true) delete patch.hidden;deps.store.patchBot(id, patch);- // A MausBot arriving where the person's own MausBot stays (takeArrivingDefaultBot) doesn't take that one's crown, also- // when a later pass sends its Chief fields without its MausBot mark (`source.defaultBot`).- if (fields.chiefOfStaff === true && !((fields.defaultBot || source.defaultBot) && keptDefaultBot(deps.store, id)?.chiefOfStaff)) {+ // A MausBot arriving where the person's own MausBot stays (takeArrivingDefaultBot) doesn't take the crown from this+ // place's Chief, whichever bot that is, also when a later pass sends its Chief fields without its MausBot mark.+ const keepsCrown = (fields.defaultBot || source.defaultBot) && keptDefaultBot(deps.store, id)+ && deps.store.bots.some((other) => other.id !== id && other.chiefOfStaff);+ if (fields.chiefOfStaff === true && !keepsCrown) {deps.store.setChiefOfStaff(id);if (patch.managedSections) deps.store.patchBot(id, { managedSections: patch.managedSections });}@@ -382,7 +384,6 @@ async function adopt(deps: MoveKindsDeps, kind: Kind, id: string, raw: unknown,const putSchema = z.object({ v: z.literal(1), key: z.string().max(200), dataDir: z.string().min(1).max(4096), record: z.unknown(), runs: z.array(z.unknown()).max(2_000).optional(),computer: z.string().max(120).optional(), sourceDefault: z.boolean().optional() });-/** What the computer a bot comes from says of it: its name, and whether the bot is the MausBot there. */type ArrivingSource = { computer?: string; defaultBot?: boolean };/** This computer's name as a person knows it, which a MausBot that moves away is named for when the place it goes keeps its own. */diff --git a/server/default-bot.test.ts b/server/default-bot.test.tsindex 256ff7491a..846bff15a7 100644--- a/server/default-bot.test.ts+++ b/server/default-bot.test.ts@@ -319,7 +319,13 @@ describe("MausBot, every person's helper", () => {expect(await arrive(cloud, chief.id, { chiefOfStaff: true, managedSections: ["General"] }, "Amit's MacBook", { sourceDefault: true })).toBe(200);expect(cloud.bots.filter((bot) => bot.chiefOfStaff).map((bot) => bot.id)).toEqual([theirs.id]);expect(placeMausBots(cloud).map((bot) => bot.id)).toEqual([theirs.id]);- // A Chief that is not a MausBot still takes the crown, as before.+ // Nor from a Chief here that is not the MausBot.+ const lee = cloud.createBot({ name: "Lee" }, { id: "cloud-lee-000008", seedMessages: false });+ cloud.setChiefOfStaff(lee.id);+ const third = cloud.createBot({ name: "MausBot" }, { id: "desk-maus-000009", seedMessages: false });+ expect(await arrive(cloud, third.id, fields({ defaultBot: {}, chiefOfStaff: true, managedSections: ["General"] }), "Amit's MacBook")).toBe(200);+ expect(cloud.bots.filter((bot) => bot.chiefOfStaff).map((bot) => bot.id)).toEqual([lee.id]);+ // A Chief that is not a MausBot takes the crown.const ada = cloud.createBot({ name: "Ada" }, { id: "desk-ada-000007", seedMessages: false });expect(await arrive(cloud, ada.id, { chiefOfStaff: true }, "Amit's MacBook")).toBe(200);expect(cloud.bots.filter((bot) => bot.chiefOfStaff).map((bot) => bot.id)).toEqual([ada.id]);