Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(team): keep crowns as they are on main, and leave a member's MausBot uncrowned

milind-soni2ecdcd4b2e30
diff --git a/docs/team-cloud.md b/docs/team-cloud.md
index b5ff788be7..4a23d9cf7a 100644
--- a/docs/team-cloud.md
+++ b/docs/team-cloud.md
@@ -354,22 +354,16 @@ one notification about it (live and in the feed). The card itself stays in its c
may answer it, and says "Asking Ada"; the asked person may answer it too, there or from their inbox. Routing decides only
whose inbox a bot's own asks reach; who may chat with the bot is its sharing's (below).
-**MausBot is the person's Chief.** On a team each member's own MausBot is crowned as their Chief when they first arrive
-(`ensureDefaultBot`), and the app shows it as MausBot, with no crown and no "Chief of Staff" (`wearsCrown` in
-`shared/default-bot.ts`). Its authority is exactly the bots that person owns, in every department, and bots that person
-owns answer only to it. Being crowned gives it nothing past that: a Chief's tools still follow its member's role
-(`server/chief-level.ts`: an Owner's or Admin's, never a User's), and it takes nothing team-wide (it is never the place's
-proactive bot, gets no place-wide notice, is no Chief in a backup or a package, and appoints no other Chief). A failure of
-one of their bots reaches them in their inbox rather than as a turn of their MausBot. Its reach stays what the audience
-rule below allows: a MausBot only its person sees reaches no bot everyone sees.
-
-No other bot someone owns is crowned beside it: `PATCH /api/bots/<id>` with `chiefOfStaff: true` answers 403 in plain words,
-`POST /api/bots` creates the bot uncrowned with that line as a warning (`server/host/team-crown.ts`), and the app offers no
-Make Chief of Staff, no Chief card and no "Also in charge of" departments on a team. A bot nobody owns can still be its
-department's Chief, as on any other server, through the API. A crown given to an owned bot earlier stays as it is, with the
-inbox it holds: that person's Chief has the authority above and their incidents come to it, into a notices chat of their
-own ("Problems to look at"; a notice from someone else's private chat goes to that person instead); their MausBot is not
-crowned, and moving a Chief to someone who has one is refused.
+**One Chief of Staff per person.** A crowned bot that someone owns is that person's Chief; a team has at most one per
+person (crowning a second hands the role over, and moving a Chief to someone who has one is refused). Its authority is
+exactly the bots that person owns, in every department: they are its team in its roster, their incidents and
+escalations come to it (into a notices chat of the person's own, "Problems to look at"; a notice from someone else's
+private chat goes to that person instead), and it retries their threads and changes their setup. The person's private
+chat with it is their inbox (below). A crowned bot nobody owns stays its department's Chief, as on any other server.
+The app offers no crown on a team, so this is reached only through the API (`PATCH /api/bots/<id>` with `chiefOfStaff`).
+
+**A member's MausBot is not crowned.** It is theirs alone, and the audience rule below keeps a bot only one person sees
+from reaching a bot everyone sees (`sameAudience`), so today it cannot hand work to the team's shared bots.
**Every bot reaches every bot.** Departments are folders, not walls. Any bot can ask, hand work to or @mention any
other bot on the team, in any department, someone's Chief included, with nothing to set up (`canReach` in
@@ -448,10 +442,10 @@ allow, folders), where it runs, its department, whom it answers to or directs, c
## One inbox per person
Everything addressed to a person reaches one place, their **inbox** (`server/host/person-inbox.ts`): their own private
-chat with their own MausBot (every member gets one; a Chief of Staff they crowned before MausBot became the Chief keeps
-it instead). It is the chat that bot opens to for them (`WireTask.inbox`, sent to its person alone): the one their brief
-was in, else their newest own chat with that bot, else a new one, "Inbox". It never moves. Nothing is turned on: every
-member of a team has one, and off a team none exists. The app shows the inbox as one list, newest first, with a dot on
+chat with their own MausBot (every member gets one; a Chief of Staff of their own, crowned through the API or before the
+app stopped offering it, holds it instead). It is the chat that bot opens to for them (`WireTask.inbox`, sent to its
+person alone): the one their brief was in, else their newest own chat with that bot, else a new one, "Inbox". Nothing is
+turned on: every member of a team has one, and off a team none exists. The app shows the inbox as one list, newest first, with a dot on
each line that waits on the person; a line marked done leaves the list (its `tab` on the wire stays "needs-you",
"info" or "done" as before).
diff --git a/server/bot-overview.ts b/server/bot-overview.ts
index 9a4620cd41..7f435a0bf0 100644
--- a/server/bot-overview.ts
+++ b/server/bot-overview.ts
@@ -1,4 +1,3 @@
-import { wearsCrown } from "../shared/default-bot.ts";
import type { BotRecord } from "./store.ts";
import type { Routine } from "./routines.ts";
import type { RoutineRequestSchedule } from "../shared/routine-request.ts";
@@ -228,7 +227,7 @@ function reachesLines(facts: OverviewFacts): string[] {
? "Talks only to the bots chosen for it."
: peers === 1 ? "Can talk to the other bot." : `Can talk to all ${peers} other bots, in any department.`);
}
- if (wearsCrown(facts.bot)) lines.push("Coordinates its department as Chief of Staff.");
+ if (facts.bot.chiefOfStaff) lines.push("Coordinates its department as Chief of Staff.");
if (facts.bot.chiefOfStaff && facts.bot.managedSections?.length) {
lines.push(`Also in charge of these departments: ${facts.bot.managedSections.map(name => name || "General").join(", ")}.`);
}
diff --git a/server/chief-level.ts b/server/chief-level.ts
index c4cf76fb8a..e9e6490037 100644
--- a/server/chief-level.ts
+++ b/server/chief-level.ts
@@ -16,12 +16,12 @@ export function readTeamRolesWith(resolver: TeamRoleOf): void {
* escalations, who answers a room) stays with `chiefOfStaff`. */
export function chiefLevel(bot: ({ chiefOfStaff?: boolean } & DefaultBotFields) | null | undefined): boolean {
if (!bot) return false;
- const person = bot.defaultBot?.person?.trim().toLowerCase();
- if (person) {
- const role = roleOf(person);
- return role === "owner" || role === "admin";
- }
- return bot.chiefOfStaff === true || Boolean(bot.defaultBot);
+ if (bot.chiefOfStaff === true) return true;
+ if (!bot.defaultBot) return false;
+ const person = bot.defaultBot.person?.trim().toLowerCase();
+ if (!person) return true;
+ const role = roleOf(person);
+ return role === "owner" || role === "admin";
}
type RoleBot = ({ chiefOfStaff?: boolean } & DefaultBotFields) | null | undefined;
diff --git a/server/chief-of-staff.ts b/server/chief-of-staff.ts
index 49bbfe25cf..d80fc03872 100644
--- a/server/chief-of-staff.ts
+++ b/server/chief-of-staff.ts
@@ -1,4 +1,3 @@
-import { wearsCrown } from "../shared/default-bot.ts";
import { botOwner, nameFromEmail } from "../shared/bot-owner.ts";
import { canManage, hasAuthority, peerName, renderRoster, reachablePeers, type RosterMember } from "./peer-roster.ts"; import { chiefLevel } from "./chief-level.ts";
import type { TaskRecord } from "./store.ts";
@@ -56,7 +55,7 @@ export function chiefOfStaffSystemPrompt(
? "Use list_bots or list_room_targets for the live reachable roster. Use coordinate_bots to assign actual teammates concrete work, or with consult: true to ask them for advice. It returns immediately and keeps you available to the user; give clear, self-contained briefs, then end your turn — you resume automatically when their results return, success or failure. Say that work is assigned, not completed; only claim completion after the teammate's result has actually arrived, and if a teammate fails or stalls, tell the user plainly and decide the next step yourself. Leads can coordinate their own specialists. Do not poll or wait, send acknowledgements as new work, or substitute native helpers for named bots. On return, verify the requested outcome, resolve decisions within the user's scope, request concrete corrections with rework=true when necessary, and return one consolidated answer. Consultations are advice, not proof that work or tests ran. A refusal from coordinate_bots means nothing was sent: fix what it names (usually the id — copy it from list_bots or your roster; a unique teammate name also works) and retry, and never describe a handoff the tool did not accept."
: "Your current engine cannot contact teammates. Be honest about that limitation and ask the user to choose a delegation-compatible engine before promising coordinated work.";
- const isChief = !chief?.defaultBot || wearsCrown(chief);
+ const isChief = !chief?.defaultBot || chief.chiefOfStaff === true;
return [
isChief
? person
diff --git a/server/cloud-health.ts b/server/cloud-health.ts
index 0a8884c5ad..bbff27e3cc 100644
--- a/server/cloud-health.ts
+++ b/server/cloud-health.ts
@@ -47,7 +47,7 @@ const FIXED_CAUSES: ReadonlyArray<[RegExp, string]> = [
[/^no activity for \d+ minutes — the turn was stopped$/, "stalled"],
[/^turn interrupted — OpenMausBot restarted$/, "restart"],
[/could not start — /, "could_not_start"],
- [/^the incident could not reach /, "incident_undelivered"],
+ [/^the problem report could not reach /, "incident_undelivered"],
[/^could not deliver approval to the provider/, "approval_undelivered"],
[/^Canonical event history is incomplete/, "event_log"],
];
diff --git a/server/cloud-team-inbox.e2e.test.ts b/server/cloud-team-inbox.e2e.test.ts
index fbcc40ad37..f21c6b43a5 100644
--- a/server/cloud-team-inbox.e2e.test.ts
+++ b/server/cloud-team-inbox.e2e.test.ts
@@ -161,7 +161,8 @@ beforeAll(async () => {
return created.body.bot as Bot;
};
scout = await create({ name: "Scout" });
- chief = (await bots(ben)).find((one) => (one as { defaultBot?: { person?: string } }).defaultBot?.person === BEN.email)!;
+ chief = await create({ name: "Ben's Chief", reportsTo: BEN.email });
+ expect((await team.as(cleo, "PATCH", `/api/bots/${chief.id}`, { chiefOfStaff: true })).status).toBe(200);
reporter = await create({ name: "Reporter", reportsTo: BEN.email });
expect((await team.as(cleo, "PATCH", `/api/bots/${reporter.id}`, { approvalMode: "ask" })).status).toBe(200);
cleoThread = await newThread(cleo, scout, "Cleo and Scout");
diff --git a/server/cloud-team-open-reach.e2e.test.ts b/server/cloud-team-open-reach.e2e.test.ts
index dd9ee036db..f8fab6bc2c 100644
--- a/server/cloud-team-open-reach.e2e.test.ts
+++ b/server/cloud-team-open-reach.e2e.test.ts
@@ -54,7 +54,8 @@ beforeAll(async () => {
scout = await create({ name: "Scout", title: "Support agent", section: "Support", reportsTo: BOB.email });
quill = await create({ name: "Quill", title: "Support writer", section: "Support", reportsTo: BOB.email });
bolt = await create({ name: "Bolt", title: "Developer", section: "Dev", reportsTo: OLIVE.email });
- chief = ((await team.as(olive, "GET", "/api/bots?messages=0")).body.bots as Array<Bot & { chiefOfStaff?: boolean; defaultBot?: unknown }>).find((one) => one.chiefOfStaff && !one.defaultBot)!;
+ chief = await create({ name: "Bob's Chief", reportsTo: BOB.email });
+ expect((await team.as(olive, "PATCH", `/api/bots/${chief.id}`, { chiefOfStaff: true })).status).toBe(200);
const made = await team.as(olive, "POST", "/api/groups", { name: "Launch", memberIds: [scout.id, bolt.id], section: "Support",
setup: { bulletin: "", defaultResponder: { kind: "member", botId: scout.id } } });
expect(made.status, JSON.stringify(made.body)).toBe(201);
@@ -113,6 +114,21 @@ it("lets Scout, in Bob's private chat, ask Bolt in another department and brings
expect((await messages(olive, bobsChat)).status).toBe(404);
}, hostTimeout(120_000));
+it("keeps Bob's Chief supervising only Bob's bots, while it can reach Bolt too", async () => {
+ const before = turns().length;
+ const sent = await team.as(bob, "POST", `/api/bots/${chief.id}/messages`, { text: "Who is on my side?", threadId: chief.threadId });
+ expect(sent.status, JSON.stringify(sent.body)).toBe(202);
+ await expect.poll(() => turns().length, { timeout: 30_000 }).toBeGreaterThan(before);
+ await expect.poll(settled, { timeout: 20_000 }).toBe(true);
+ const system = turns().filter((turn) => turn.botId === chief.id).at(-1)!.system;
+ const [, mine = "", others = ""] = system.split(/Bots that report to Bob \(your team\):|Other bots you can reach \(they report to someone else\):/);
+ expect(mine).toContain("Scout");
+ expect(mine).toContain("Quill");
+ expect(mine).not.toContain("Bolt");
+ expect(others).toContain("Bolt");
+ expect(system).toContain("Reaching a bot gives you no authority over it");
+}, hostTimeout(90_000));
+
it("never carries Bob's private chat into a room, by a hand-off or a post", async () => {
const sent = await team.as(bob, "POST", `/api/bots/${scout.id}/messages`, { text: "Post that in the Launch room too", threadId: bobsChat });
expect(sent.status, JSON.stringify(sent.body)).toBe(202);
diff --git a/server/cloud-team-owners.e2e.test.ts b/server/cloud-team-owners.e2e.test.ts
index 2d90b25f2e..5f3202c222 100644
--- a/server/cloud-team-owners.e2e.test.ts
+++ b/server/cloud-team-owners.e2e.test.ts
@@ -2,7 +2,7 @@
// Claude CLI asking real question and approval cards through the permission socket, and each person's Needs you,
// notifications, Chief of Staff and inbox. It proves the routing and the audience rule, not a model's judgement.
import { randomBytes, randomUUID } from "node:crypto";
-import { readFileSync, rmSync, writeFileSync } from "node:fs";
+import { existsSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { connect, type Socket } from "node:net";
import { join } from "node:path";
import { afterAll, beforeAll, expect, it } from "vitest";
@@ -188,22 +188,47 @@ it("lets the member who owns a bot hand it over, and nobody else but an Admin",
expect(await asked(bob)).toContain("Which landing page should I rewrite?");
}, hostTimeout(30_000));
-it("makes each person's MausBot their Chief, crowns no other bot someone owns, and keeps the department's own Chief", async () => {
- const ownOf = async (token: string, email: string) => (await bots(token)).find((one) => (one as { defaultBot?: { person?: string } }).defaultBot?.person === email)!;
- for (const [token, email] of [[ada, ADA.email], [bob, BOB.email]] as const) expect((await ownOf(token, email)).chiefOfStaff).toBe(true);
- const second = await create(ada, { name: "Ada's Chief", reportsTo: ADA.email });
- const refused = await team.as(ada, "PATCH", `/api/bots/${second.id}`, { chiefOfStaff: true });
- expect(refused.status).toBe(403);
- expect(refused.body.error).toBe("Ada's Chief can't be made a Chief of Staff on a team: each person's own MausBot already looks after their bots and holds their inbox.");
- const made = await team.as(ada, "POST", "/api/bots", { name: "Also a Chief?", reportsTo: ADA.email, settings: { chiefOfStaff: true } });
- expect(made.status, JSON.stringify(made.body)).toBe(201);
- expect(made.body.bot.chiefOfStaff).toBeFalsy();
- const department = (await bots(olive)).find((one) => one.chiefOfStaff && !one.reportsTo && !one.createdBy && !(one as { defaultBot?: unknown }).defaultBot)!;
- expect(department).toBeTruthy();
- // Bob's MausBot is his Chief, so a Chief handed to him would be his second.
- const handed = await team.as(ada, "PUT", `/api/bots/${department.id}/reports-to`, { email: BOB.email });
- expect(handed.status).toBe(409);
- expect(handed.body.error).toContain("Bob already has a Chief of Staff");
+let bobsChief: Bot;
+
+it("gives each person a Chief of Staff of their own whose team is the bots that report to them, while it can reach every bot", async () => {
+ const adasChief = await create(ada, { name: "Ada's Chief", reportsTo: ADA.email });
+ bobsChief = await create(ada, { name: "Bob's Chief", reportsTo: BOB.email });
+ for (const chief of [adasChief, bobsChief]) expect((await team.as(ada, "PATCH", `/api/bots/${chief.id}`, { chiefOfStaff: true })).status).toBe(200);
+ // Both crowned in General beside the department's own Chief, which nobody owns.
+ const crowned = (await bots(olive)).filter((one) => one.chiefOfStaff);
+ expect(crowned.filter((one) => one.reportsTo).map((one) => one.name).sort()).toEqual(["Ada's Chief", "Bob's Chief"]);
+ expect(crowned.filter((one) => !one.reportsTo && !one.createdBy)).toHaveLength(1);
+ // Bob's Chief reported to Ada would be her second.
+ const second = await team.as(ada, "PUT", `/api/bots/${bobsChief.id}/reports-to`, { email: ADA.email });
+ expect(second.status).toBe(409);
+ expect(second.body.error).toContain("Ada already has a Chief of Staff");
+
+ const prompt = async (token: string, chief: Bot) => {
+ rmSync(join(team.home, "dump.json"), { force: true });
+ expect((await team.as(token, "POST", `/api/bots/${chief.id}/messages`, { text: "Who is on my side?", threadId: chief.threadId })).status).toBe(202);
+ await expect.poll(() => existsSync(join(team.home, "dump.json")), { timeout: 20_000 }).toBe(true);
+ await expect.poll(() => busy(chief.id), { timeout: 20_000 }).toBe(false);
+ return JSON.parse(readFileSync(join(team.home, "dump.json"), "utf8")).systemPrompt as string;
+ };
+ // Each Chief's own team, then everyone else it can reach.
+ const split = (text: string, person: string) => {
+ const [, mine = "", others = ""] = text.split(new RegExp(`Bots that report to ${person} \\(your team\\):|Other bots you can reach \\(they report to someone else\\):`));
+ return { mine, others };
+ };
+ const adasPrompt = await prompt(ada, adasChief);
+ expect(adasPrompt).toContain("You are Ada's assistant and Chief of Staff");
+ const adas = split(adasPrompt, "Ada");
+ expect(adas.mine).toContain("Tech Lead");
+ expect(adas.mine).not.toMatch(/\bFox\b|\bOwl\b/);
+ expect(adas.others).toMatch(/\bFox\b/);
+ expect(adas.others).toMatch(/\bOwl\b/);
+ const bobsPrompt = await prompt(bob, bobsChief);
+ expect(bobsPrompt).toContain("You are Bob's assistant and Chief of Staff");
+ const bobs = split(bobsPrompt, "Bob");
+ expect(bobs.mine).toMatch(/\bFox\b/);
+ expect(bobs.mine).toMatch(/\bOwl\b/);
+ expect(bobs.mine).not.toContain("Tech Lead");
+ expect(bobs.others).toContain("Tech Lead");
}, hostTimeout(90_000));
it("keeps a member's private chat theirs: its asks reach only them, never the bot's owner, an Admin, or the owner's inbox", async () => {
diff --git a/server/default-bot.test.ts b/server/default-bot.test.ts
index 0a998cb729..d04969059c 100644
--- a/server/default-bot.test.ts
+++ b/server/default-bot.test.ts
@@ -1,7 +1,4 @@
-import { wearsCrown } from "../shared/default-bot.ts";
-import { chiefForBot } from "./incidents.ts";
-import { canManage, canReach, hasAuthority } from "./peer-roster.ts";
-import { mainChief } from "./host/proactive-owner.ts";
+import { canManage, canReach } from "./peer-roster.ts";
import { readFileSync, rmSync, writeFileSync } from "node:fs";
import { join } from "node:path";
import { afterEach, beforeEach, describe, expect, it } from "vitest";
@@ -49,61 +46,14 @@ describe("MausBot, every person's helper", () => {
expect(intros(again, maus)).toHaveLength(1);
});
- describe("a member's MausBot on a Team Cloud", () => {
- const ada = "[email protected]", ROLES = { ada: "admin", ben: "member" } as const;
- const place = () => { const store = new Store(selection); store.seedIfEmpty({ defaultBot: false }); return store; };
- const member = (store: Store, person: string) => ensureDefaultBot(store, { dataDir: DATA_DIR, person, team: "Acme" })!;
-
- it("is crowned as its person's Chief, with no other Chief's crown touched, and only once", () => {
- const store = place();
- const department = store.bots.find((bot) => bot.chiefOfStaff)!;
- const own = member(store, ada);
- expect(own).toMatchObject({ chiefOfStaff: true, defaultBot: { person: ada } });
- expect(store.bot(department.id)?.chiefOfStaff).toBe(true);
- expect(member(store, ada).id).toBe(own.id);
- });
-
- it("leaves a Chief the person already has alone, and crowns an existing MausBot of someone who has none", () => {
- const store = place();
- const chief = store.createBot({ name: "Ada's Chief", reportsTo: ada } as never);
- store.setChiefOfStaff(chief.id);
- expect(member(store, ada).chiefOfStaff).toBeFalsy();
- expect(store.bot(chief.id)?.chiefOfStaff).toBe(true);
- const before = member(store, "[email protected]");
- store.patchBot(before.id, { chiefOfStaff: undefined });
- expect(member(store, "[email protected]").chiefOfStaff).toBe(true);
- });
-
- it("never holds a Chief's powers through the crown: only through its member's role", () => {
- const store = place();
- const own = member(store, ada), bens = member(store, "[email protected]");
- readTeamRolesWith((email) => ROLES[email.split("@")[0] as keyof typeof ROLES] ?? null);
- expect(chiefLevel(own), "an Admin's").toBe(true);
- expect(chiefLevel(bens), "a User's, crowned").toBe(false);
- readTeamRolesWith(() => null);
- expect(chiefLevel(own), "with no role known").toBe(false);
- });
-
- it("takes nothing team-wide: not the place's main Chief, not another bot's problems, not a backup's Chief", () => {
- const store = new Store(selection);
- store.seedIfEmpty({ defaultBot: false });
- const department = store.bots.find((bot) => bot.chiefOfStaff)!;
- store.setChiefOfStaff(null, department.section);
- const own = member(store, ada);
- expect(mainChief(store), "not the place's proactive bot").toBeNull();
- expect(chiefForBot(store.bots, { id: "fox", name: "Fox", reportsTo: ada }), "its person hears of a failure in their inbox instead").toBeNull();
- expect(wearsCrown(own)).toBe(false);
- expect(wearsCrown({ chiefOfStaff: true })).toBe(true);
- });
-
- it("reaches no bot everyone sees, even one its person owns: the audience rule, which a crown does not change", () => {
- const store = place();
- const own = member(store, ada);
- const fox = store.createBot({ name: "Fox", reportsTo: ada } as never);
- expect(hasAuthority(own, fox), "it answers to their Chief").toBe(true);
- expect(canReach(own, fox)).toBe(false);
- expect(canManage(own, fox)).toBe(false);
- });
+ it("leaves a Team Cloud member's MausBot uncrowned: it reaches no bot everyone sees, so a crown would promise work it can't hand on", () => {
+ const store = new Store(selection);
+ store.seedIfEmpty({ defaultBot: false });
+ const own = ensureDefaultBot(store, { dataDir: DATA_DIR, person: "[email protected]", team: "Acme" })!;
+ expect(own.chiefOfStaff).toBeFalsy();
+ const fox = store.createBot({ name: "Fox", reportsTo: "[email protected]" } as never);
+ expect(canReach(own, fox)).toBe(false);
+ expect(canManage(own, fox)).toBe(false);
});
it("gives an existing install without one a MausBot once on update, beside its Chief, which stays exactly as it was", () => {
@@ -280,7 +230,7 @@ describe("MausBot, every person's helper", () => {
expect(ensureDefaultBot(store, { dataDir: DATA_DIR, person: "[email protected]", team: "Acme" })?.id).toBe(ada.id);
expect(ada).toMatchObject({ name: "MausBot", defaultBot: { person: "[email protected]" }, visibility: { people: ["[email protected]"] } });
expect(bea).toMatchObject({ defaultBot: { person: "[email protected]" }, visibility: { people: ["[email protected]"] } });
- expect(ada.chiefOfStaff, "its person's Chief, without saying so in its intro").toBe(true);
+ expect(ada.chiefOfStaff).toBeFalsy();
expect(intros(store, ada)[0]?.text).toContain("On Acme, I'm here for you and look after your own bots.");
expect(intros(store, ada)[0]?.text).not.toContain("keep an eye on your day");
expect(store.bots).toHaveLength(3);
diff --git a/server/default-bot.ts b/server/default-bot.ts
index a150860f22..f264728c49 100644
--- a/server/default-bot.ts
+++ b/server/default-bot.ts
@@ -2,7 +2,6 @@ import { existsSync, readFileSync } from "node:fs";
import { join } from "node:path";
import { writeFileAtomic } from "./atomic.ts";
-import { botOwner } from "../shared/bot-owner.ts";
import { DEFAULT_BOT_COLOR, DEFAULT_BOT_NAME, defaultBotPerson } from "../shared/default-bot.ts";
import { takeImportName } from "../shared/import-name.ts";
import type { BotRecord, Message, Store } from "./store.ts";
@@ -119,7 +118,7 @@ export function ensureDefaultBot(store: DefaultBotStore, options: { dataDir: str
for (const extra of marked.slice(1)) store.patchBot(extra.id, { defaultBot: undefined, sidebarHidden: undefined });
if (marked[0]) {
remember(options.dataDir, person, marked[0].id);
- return crownedForMember(store, marked[0], person);
+ return marked[0];
}
if (Object.hasOwn(ledger(options.dataDir), person)) return null;
const adoptable = person ? undefined : seededMausBot(store.bots);
@@ -133,14 +132,7 @@ export function ensureDefaultBot(store: DefaultBotStore, options: { dataDir: str
bot = createDefaultBot(store, { person, team: options.team, chief });
}
remember(options.dataDir, person, bot.id);
- return crownedForMember(store, bot, person);
-}
-
-/** On a Team Cloud a member's MausBot is their Chief; a Chief they already have keeps the role and their inbox. */
-function crownedForMember(store: DefaultBotStore, bot: BotRecord, person: string): BotRecord {
- if (!person || bot.chiefOfStaff || store.bots.some((other) => other.chiefOfStaff && botOwner(other) === person)) return bot;
- store.setChiefOfStaff(bot.id);
- return store.bot(bot.id) ?? bot;
+ return bot;
}
/** A move brought this place's MausBot from another computer: it becomes the one MausBot here, and the one this place
diff --git a/server/host/chief-notices-retry.test.ts b/server/host/chief-notices-retry.test.ts
index d338cd0423..6c6a1a96be 100644
--- a/server/host/chief-notices-retry.test.ts
+++ b/server/host/chief-notices-retry.test.ts
@@ -218,6 +218,14 @@ describe("a run stopped to free memory", () => {
});
describe("the person's line about an incident", () => {
+ it("lands in a notices chat older versions named Team incidents, rather than opening a second one", () => {
+ const f = fixture();
+ f.chief.tasks.push({ threadId: "old-notices", title: "Team incidents" });
+ f.notices.reportIncident({ kind: "stalled", bot: f.ada as never, threadId: "ada-job", detail: "" });
+ expect(f.store.messagesFor("old-notices").some((line) => line.kind === "activity")).toBe(true);
+ expect(f.chief.tasks.map((task) => task.title)).toEqual(["Team incidents"]);
+ });
+
it("is in the language of the person whose work failed, while the Chief's report stays English", () => {
const f = fixture({ threadLanguage: (threadId) => (threadId === "ada-job" ? "de" : undefined) });
f.notices.reportIncident({ kind: "stalled", bot: f.ada as never, threadId: "ada-job", detail: "" });
diff --git a/server/host/member-own-bot.test.ts b/server/host/member-own-bot.test.ts
deleted file mode 100644
index 06bdad747b..0000000000
--- a/server/host/member-own-bot.test.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-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/host/member-own-bot.ts b/server/host/member-own-bot.ts
index 4953f920c4..2794082943 100644
--- a/server/host/member-own-bot.ts
+++ b/server/host/member-own-bot.ts
@@ -42,12 +42,11 @@ export function createMemberOwnBot(deps: MemberOwnBotDeps) {
const store = deps.store();
const bot = store.bot(botId);
if (!bot) return false;
- const { defaultBot, sidebarHidden, chiefOfStaff } = bot;
- store.patchBot(botId, { defaultBot: undefined, sidebarHidden: undefined, chiefOfStaff: undefined });
+ store.patchBot(botId, { defaultBot: undefined, sidebarHidden: undefined });
const result = await deps.deleteBot(botId).catch((error: unknown) => ({ status: 500, body: { error: error instanceof Error ? error.message : String(error) } }));
if (result.status < 400) return true;
console.warn(`team member left: could not delete their MausBot ${botId}: ${result.body.error ?? result.status}`);
- if (store.bot(botId)) store.patchBot(botId, { defaultBot, sidebarHidden, chiefOfStaff });
+ if (store.bot(botId)) store.patchBot(botId, { defaultBot: bot.defaultBot, sidebarHidden: bot.sidebarHidden });
return false;
},
};
diff --git a/server/host/proactive-owner.ts b/server/host/proactive-owner.ts
index a520c82855..13ee0264d0 100644
--- a/server/host/proactive-owner.ts
+++ b/server/host/proactive-owner.ts
@@ -1,12 +1,12 @@
// The one answer to "which bot is proactive here": it owns the "Keep an eye on my day" routine, the brief and the
// suggestion to add a helper-model key. That is the place's MausBot, shown in the sidebar or not, and the main Chief of
// Staff only where there is no MausBot. Every such decision goes through this function.
-import { defaultBotPerson, wearsCrown } from "../../shared/default-bot.ts";
+import { defaultBotPerson } from "../../shared/default-bot.ts";
import { sectionKey, type BotRecord, type Store } from "../store.ts";
/** The Chief of the whole workspace, or the first Chief there is. */
export function mainChief(store: Pick<Store, "bots">): BotRecord | null {
- const chiefs = store.bots.filter((bot) => wearsCrown(bot) && !bot.hidden);
+ const chiefs = store.bots.filter((bot) => bot.chiefOfStaff && !bot.hidden);
return chiefs.find((bot) => sectionKey(bot.section) === "") ?? chiefs[0] ?? null;
}
diff --git a/server/host/routine-holds-host.test.ts b/server/host/routine-holds-host.test.ts
index f50ab08ddf..0182280158 100644
--- a/server/host/routine-holds-host.test.ts
+++ b/server/host/routine-holds-host.test.ts
@@ -13,8 +13,7 @@ const START = Date.parse("2026-10-30T06:00:00Z");
const HOUR = 60 * 60_000;
type Line = { threadId: string; name: string };
-/** A Cloud home's routines and bots: the owner's Chief, a teammate's later one, a member's own crowned MausBot, which a
- * place-wide notice never reaches, and a bot that is no Chief. */
+/** A Cloud home's routines and bots: the owner's Chief, a teammate's later one, and a bot that is no Chief. */
function world(dataDir?: string) {
const dir = dataDir ?? mkdtempSync(join(tmpdir(), "omb-routine-holds-host-"));
if (!dataDir) dirs.push(dir);
@@ -25,7 +24,6 @@ function world(dataDir?: string) {
const routines = new RoutineManager({ file: join(dir, "routines.json"), now: () => now, botState: () => "ready", createTask: () => ({ threadId: "run" }), startTurn: async () => {} });
const bots = [
{ id: "ops", name: "Ops", threadId: "ops-main", createdAt: 1 },
- { id: "bens", name: "MausBot", threadId: "bens-main", createdAt: 0, chiefOfStaff: true, defaultBot: { person: "[email protected]" } },
{ id: "chief-2", name: "Second", threadId: "chief-2-main", createdAt: 3, chiefOfStaff: true },
{ id: "chief", name: "MausBot", threadId: "chief-main", createdAt: 2, chiefOfStaff: true, defaultBot: {} },
];
diff --git a/server/host/routine-holds-host.ts b/server/host/routine-holds-host.ts
index 5557e7c3f2..3dc2166ef4 100644
--- a/server/host/routine-holds-host.ts
+++ b/server/host/routine-holds-host.ts
@@ -4,7 +4,6 @@
// Admin's signed request, routes/cloud-signed.ts). What was last read is kept in routine-holds.json, so a restart neither
// frees nor pauses anything before the engines are read again. A cause that begins and pauses routines writes one quiet
// line in the owner's Chief's chat; nothing else is sent, so nobody who left is messaged.
-import { wearsCrown } from "../../shared/default-bot.ts";
import { readFileSync } from "node:fs";
import { join } from "node:path";
import type { RoutineHoldCause } from "../../shared/routines.ts";
@@ -63,7 +62,7 @@ export function createRoutineHoldsHost(deps: RoutineHoldsHostDeps) {
/** The owner's Chief: the place's own one, else the first made (a Team Cloud's founder's). */
function tell(line: string): void {
- const chief = deps.store.bots.filter((bot) => !bot.hidden && wearsCrown(bot))
+ const chief = deps.store.bots.filter((bot) => !bot.hidden && bot.chiefOfStaff)
.sort((a, b) => Number(Boolean(b.defaultBot)) - Number(Boolean(a.defaultBot)) || a.createdAt - b.createdAt)[0];
if (chief) deps.store.appendMessage(chief.threadId, { role: "bot", kind: "activity", tool: { name: `notice: ${line}`, ok: true } });
}
diff --git a/server/host/team-crown.test.ts b/server/host/team-crown.test.ts
deleted file mode 100644
index a6ffe9c169..0000000000
--- a/server/host/team-crown.test.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import { describe, expect, it } from "vitest";
-
-import { teamCrownRefusal } from "./team-crown.ts";
-
-const ada = "[email protected]";
-
-describe("crowning a Chief of Staff on a team", () => {
- it("refuses any other bot someone owns, and says why in plain words", () => {
- expect(teamCrownRefusal(true, { name: "Payroll", createdBy: ada }, { chiefOfStaff: true }))
- .toBe("Payroll can't be made a Chief of Staff on a team: each person's own MausBot already looks after their bots and holds their inbox.");
- expect(teamCrownRefusal(true, { name: "Scout", reportsTo: ada }, { chiefOfStaff: true })).toMatch(/can't be made a Chief of Staff/);
- });
-
- it("lets a bot nobody owns be its department's Chief and a MausBot its person's, leaves an earlier crown alone, and ignores every other patch", () => {
- expect(teamCrownRefusal(true, { name: "Ops", section: "Ops" }, { chiefOfStaff: true })).toBeNull();
- expect(teamCrownRefusal(true, { name: "MausBot", defaultBot: { person: ada } }, { chiefOfStaff: true }), "the person's own MausBot is their Chief").toBeNull();
- expect(teamCrownRefusal(true, { name: "Payroll", createdBy: ada, chiefOfStaff: true }, { chiefOfStaff: true })).toBeNull();
- expect(teamCrownRefusal(true, { name: "Payroll", createdBy: ada }, { chiefOfStaff: false })).toBeNull();
- expect(teamCrownRefusal(true, { name: "Payroll", createdBy: ada }, { title: "Lead" })).toBeNull();
- expect(teamCrownRefusal(true, null, { chiefOfStaff: true })).toBeNull();
- });
-
- it("applies nowhere but a team", () => {
- expect(teamCrownRefusal(false, { name: "Payroll", createdBy: ada }, { chiefOfStaff: true })).toBeNull();
- });
-});
diff --git a/server/host/team-crown.ts b/server/host/team-crown.ts
deleted file mode 100644
index 1df8b90be4..0000000000
--- a/server/host/team-crown.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-// On a Team Cloud a person's own MausBot is their Chief and holds their inbox, so no other bot someone owns is crowned
-// beside it; a bot nobody owns can still be its department's Chief. A crown given before this rule stays as it is.
-import { botOwner, type OwnedBot } from "../../shared/bot-owner.ts";
-
-/** Why this PATCH may not crown `bot` on a team, or null. */
-export function teamCrownRefusal(team: boolean, bot: (OwnedBot & { name: string; chiefOfStaff?: boolean }) | null, body: Record<string, unknown>): string | null {
- if (!team || body.chiefOfStaff !== true || !bot || bot.chiefOfStaff || bot.defaultBot?.person || !botOwner(bot)) return null;
- return `${bot.name} can't be made a Chief of Staff on a team: each person's own MausBot already looks after their bots and holds their inbox.`;
-}
diff --git a/server/incidents.e2e.test.ts b/server/incidents.e2e.test.ts
index 7308f3d9f1..b4b7ded301 100644
--- a/server/incidents.e2e.test.ts
+++ b/server/incidents.e2e.test.ts
@@ -501,7 +501,7 @@ it("tells the person of a failure whose report waited and was then refused", asy
await api("PUT", "/api/config", { budgets: { monthlyUsd: 0.005 } });
writeFileSync(file(incidents, "gate"), "finish");
await expect.poll(async () => (await messages(incidents)).some((m) =>
- (m.tool?.name ?? "").startsWith("error: the incident could not reach Clive — this workspace has reached its monthly spend limit")), { timeout: 20_000 }).toBe(true);
+ (m.tool?.name ?? "").startsWith("error: the problem report could not reach Clive — this workspace has reached its monthly spend limit")), { timeout: 20_000 }).toBe(true);
const sent = await watch.sent(chief.id);
expect(sent.filter((push: any) => push.kind === "incident")).toEqual([expect.objectContaining({
botId: ben.id, threadId: ben.activeTaskId, title: "Ben hit a problem",
diff --git a/server/incidents.ts b/server/incidents.ts
index 1e7075983b..8b5cdef938 100644
--- a/server/incidents.ts
+++ b/server/incidents.ts
@@ -1,4 +1,3 @@
-import { wearsCrown } from "../shared/default-bot.ts";
import type { WireMessage as Message } from "../shared/wire.ts";
import { withoutDeliveredNote } from "./peer-provenance.ts";
import { botOwner } from "../shared/bot-owner.ts";
@@ -16,7 +15,6 @@ export interface IncidentBot {
createdBy?: string;
reportsTo?: string;
hidden?: boolean;
- defaultBot?: { person?: string };
}
export interface Incident {
@@ -38,7 +36,7 @@ const sectionKey = (section?: string): string => section?.trim() || "";
export function chiefForBot<T extends IncidentBot>(bots: readonly T[], bot: IncidentBot): T | null {
if (bot.chiefOfStaff) return null;
- const chiefs = bots.filter((candidate) => wearsCrown(candidate) && !candidate.hidden && candidate.id !== bot.id);
+ const chiefs = bots.filter((candidate) => candidate.chiefOfStaff && !candidate.hidden && candidate.id !== bot.id);
// A bot someone owns on a Team Cloud has their Chief or none; the department's Chief is not its person's.
const owner = botOwner(bot);
if (owner) return chiefs.find((chief) => botOwner(chief) === owner) ?? null;
diff --git a/server/index.ts b/server/index.ts
index b2e93942fb..f78b673724 100644
--- a/server/index.ts
+++ b/server/index.ts
@@ -115,7 +115,7 @@ import { vpsLeftBehindNotice } from "./cloud-backend.ts";
import * as composio from "./composio.ts";
import { connectorCallFromFrame, connectorRefusalText, connectorScopeRefusalText, connectorUnrecognizedText, evaluateConnectorTools } from "./connector-verdict.ts";
import { connectorCardDescription, connectorCardText, signInCardText } from "./connector-card-text.ts";
-import { wearsCrown } from "../shared/default-bot.ts"; import { chiefOfStaffSystemPrompt } from "./chief-of-staff.ts"; import { chiefLevel, readTeamRolesWith } from "./chief-level.ts"; import { defaultBotRefusal, ensureDefaultBot } from "./default-bot.ts";
+import { chiefOfStaffSystemPrompt } from "./chief-of-staff.ts"; import { chiefLevel, readTeamRolesWith } from "./chief-level.ts"; import { defaultBotRefusal, ensureDefaultBot } from "./default-bot.ts";
import { buildRecall, recallRooms, recallThreadIds, withRecalled } from "./recall.ts";
import { hostTimeZone, takesTurnClock, turnClockLine, withTurnClock } from "./turn-clock.ts";
import { createMemoryUpkeep, dreamConversations, upkeepEnabled } from "./memory-upkeep.ts";
@@ -8491,7 +8491,7 @@ async function beginTurn(
const prompt = buildSystemPrompt(persona, liveBot?.soul ?? bot.soul ?? "", [
{ id: "user-profile", label: "About the user", text: userProfileSystemPrompt(teamHost.profileFor(threadId, cfg.profile)) }, { id: "people", label: "People", text: teamMessages.prompt(bot.id, threadId, Boolean(integrations.agents)) },
{ id: "setup", label: "Setup", text: setupSystemPrompt(setupMode, {
- skills: skillAuthoring, chief: wearsCrown(liveBot ?? bot),
+ skills: skillAuthoring, chief: Boolean((liveBot ?? bot).chiefOfStaff),
cwd: liveBot?.cwd ?? bot.cwd,
connectedApps: setupConnectedApps(bot, instance.adapter.capabilities.composioMcp === true, Boolean(integrations.composio)),
}) },
diff --git a/server/package-export.ts b/server/package-export.ts
index 4cc67585b0..a0e88c08e3 100644
--- a/server/package-export.ts
+++ b/server/package-export.ts
@@ -1,4 +1,3 @@
-import { wearsCrown } from "../shared/default-bot.ts";
import { parseBotPackage, type BotPackageDefinition, type BotPackagePlaybook, type BotPackageSkill, type ParsedBotPackage } from "./bot-package.ts";
import type { DefaultsPreset, PublishedLibrary } from "./presets.ts";
import type { PublishedTeam } from "./published-teams.ts";
@@ -240,7 +239,7 @@ export function createBotPackageExport(input: {
requirements: { apps: [...requirements.values()], capabilities: [] },
agents,
};
- const chief = bots.find(wearsCrown);
+ const chief = bots.find((bot) => bot.chiefOfStaff);
if (chief) definition.chiefOfStaff = idToKey.get(chief.id)!;
if (rooms.length) definition.rooms = rooms;
if (routines.length) definition.routines = routines;
@@ -651,7 +650,7 @@ export function createTeamPackageExport(input: TeamExportInput): TeamExportResul
}];
});
- const chief = bots.find(wearsCrown);
+ const chief = bots.find((bot) => bot.chiefOfStaff);
const brief = input.brief?.trim() ? input.brief : undefined;
const definition: PackageDefinition = {
id: packageId,
diff --git a/server/question-cards.e2e.test.ts b/server/question-cards.e2e.test.ts
index d843aa0bf5..9bf4028ba1 100644
--- a/server/question-cards.e2e.test.ts
+++ b/server/question-cards.e2e.test.ts
@@ -9,7 +9,6 @@ import { existsSync, readFileSync, writeFileSync } from "node:fs";
import { join } from "node:path";
import { afterAll, beforeAll, expect, it } from "vitest";
import { launchCloudSendFixture, type CloudSendFixture, type CloudTeamFixture } from "../scripts/testing/cloud-send-fixture.ts";
-import { chiefCrownedEarlier } from "./testing/team-earlier-chief.ts";
import { hostTimeout } from "./testing/host-timeout.ts";
const CLEO = { email: "[email protected]", role: "owner" as const };
@@ -113,7 +112,8 @@ beforeAll(async () => {
expect(created.status, JSON.stringify(created.body)).toBe(201);
return created.body.bot as Bot;
};
- scout = await chiefCrownedEarlier<Bot>(team, cleo, "Scout", CLEO.email);
+ scout = await create({ name: "Scout", reportsTo: CLEO.email });
+ expect((await team.as(cleo, "PATCH", `/api/bots/${scout.id}`, { chiefOfStaff: true })).status).toBe(200);
ledger = await create({ name: "Ledger", reportsTo: CLEO.email });
// Questions reach the person on "Ask me first"; at Full access, the default, the requesting bot decides them instead.
for (const bot of [scout, ledger]) expect((await team.as(cleo, "PATCH", `/api/bots/${bot.id}`, { approvalMode: "ask", applyToAllThreads: true })).status).toBe(200);
diff --git a/server/question-routing.e2e.test.ts b/server/question-routing.e2e.test.ts
index e8448b4c49..ff116c806e 100644
--- a/server/question-routing.e2e.test.ts
+++ b/server/question-routing.e2e.test.ts
@@ -12,7 +12,6 @@ import { join } from "node:path";
import { afterAll, beforeAll, describe, expect, it } from "vitest";
import { launchCloudSendFixture, type CloudSendFixture, type CloudTeamFixture } from "../scripts/testing/cloud-send-fixture.ts";
import { removeTempDir } from "./testing/cleanup.ts";
-import { chiefCrownedEarlier } from "./testing/team-earlier-chief.ts";
import { hostTimeout } from "./testing/host-timeout.ts";
const MARCO = { email: "[email protected]", role: "owner" as const };
@@ -87,7 +86,8 @@ beforeAll(async () => {
expect(created.status, JSON.stringify(created.body)).toBe(201);
return created.body.bot as Bot;
};
- fuchs = await chiefCrownedEarlier<Bot>(team, marco, "Fuchs", MARCO.email);
+ fuchs = await create({ name: "Fuchs", reportsTo: MARCO.email });
+ expect((await team.as(marco, "PATCH", `/api/bots/${fuchs.id}`, { chiefOfStaff: true })).status).toBe(200);
dachs = await create({ name: "Dachs", reportsTo: MARCO.email });
otter = await create({ name: "Otter", reportsTo: MARCO.email });
expect((await team.as(marco, "PATCH", `/api/bots/${dachs.id}`, { computer: "browser" })).status).toBe(200);
diff --git a/server/routes/bot-patch.test.ts b/server/routes/bot-patch.test.ts
index dd6a855c9d..d93bb0a884 100644
--- a/server/routes/bot-patch.test.ts
+++ b/server/routes/bot-patch.test.ts
@@ -40,7 +40,7 @@ beforeEach(() => {
lifecycleBusy.mockReturnValue(false);
});
-function fixture({ team = false } = {}) {
+function fixture() {
const store = new Store(() => sonnet);
const bot = store.createBot({ name: "Scout" });
const cfg = { vps: { sshAlias: "production-vps" } } as AppConfig;
@@ -58,7 +58,6 @@ function fixture({ team = false } = {}) {
routines: () => null,
// A member's session may chat with this bot: the level that still can't move it or change what it may do.
levelOf: () => "chat",
- team,
} as unknown as BotPatchRouteDeps;
const handler = createBotPatchRoutes(deps);
const patch = async (botId: string, body: Record<string, unknown>, as: { auth?: RequestAuth; headers?: Record<string, string> } = {}) => {
@@ -325,30 +324,3 @@ describe("PATCH /api/bots/:id phoneApps", () => {
expect(store.bot(bot.id)?.phoneApps).toBeUndefined();
});
});
-
-describe("PATCH /api/bots/:id chiefOfStaff on a team", () => {
- it("refuses to crown a bot someone owns, crowns a department's own bot, and leaves an earlier crown alone", async () => {
- const { store, bot, patch } = fixture({ team: true });
- store.patchBot(bot.id, { createdBy: "[email protected]" });
- const owned = await patch(bot.id, { chiefOfStaff: true });
- expect(owned.status).toBe(403);
- expect(owned.body.error).toBe("Scout can't be made a Chief of Staff on a team: each person's own MausBot already looks after their bots and holds their inbox.");
- expect(store.bot(bot.id)?.chiefOfStaff).toBeFalsy();
-
- const department = store.createBot({ name: "Ops", section: "Ops" });
- expect((await patch(department.id, { chiefOfStaff: true })).status).toBe(200);
- expect(store.bot(department.id)?.chiefOfStaff).toBe(true);
-
- store.patchBot(bot.id, { chiefOfStaff: true });
- expect((await patch(bot.id, { chiefOfStaff: true, title: "Lead" })).status).toBe(200);
- expect((await patch(bot.id, { chiefOfStaff: false })).status).toBe(200);
- expect(store.bot(bot.id)?.chiefOfStaff).toBe(false);
- });
-
- it("crowns an owned bot anywhere but a team", async () => {
- const { store, bot, patch } = fixture();
- store.patchBot(bot.id, { createdBy: "[email protected]" });
- expect((await patch(bot.id, { chiefOfStaff: true })).status).toBe(200);
- expect(store.bot(bot.id)?.chiefOfStaff).toBe(true);
- });
-});
diff --git a/server/routes/bot-patch.ts b/server/routes/bot-patch.ts
index 6c31f4f490..1c61f8e60f 100644
--- a/server/routes/bot-patch.ts
+++ b/server/routes/bot-patch.ts
@@ -25,7 +25,7 @@ import type { MemoryUpkeep } from "../memory-upkeep.ts";
import { phoneAppsFor } from "../phones/access.ts";
import { profileSnapshot } from "../profile-revision.ts";
import { recordProfileChange } from "../profile-versions.ts";
-import { memberBotPatchViolation, requestSource, type RequestAuth } from "../request-auth.ts"; import { defaultBotPatchRefusal, ownsDefaultBot } from "../default-bot.ts"; import { teamCrownRefusal } from "../host/team-crown.ts";
+import { memberBotPatchViolation, requestSource, type RequestAuth } from "../request-auth.ts"; import { defaultBotPatchRefusal, ownsDefaultBot } from "../default-bot.ts";
import type { RoutineManager } from "../routines.ts";
import type { SessionRegistry } from "../sessions.ts";
import { parseConnectorTools } from "../connector-tools.ts";
@@ -381,7 +381,6 @@ export function createBotPatchRoutes(deps: BotPatchRouteDeps): RouteHandler {
if (body.chiefOfStaff !== undefined && typeof body.chiefOfStaff !== "boolean") {
return json(res, 400, { error: "chiefOfStaff must be true or false" });
}
- const crownRefused = teamCrownRefusal(deps.team, existingBot, body); if (crownRefused) return json(res, 403, { error: crownRefused });
if (body.cloudBackend !== undefined) {
const backendError = cloudBackendChangeError(Boolean(existingBot?.busy), activeVpsThreads.has(m[1]));
if (backendError) return json(res, 409, { error: backendError });
diff --git a/server/routes/bots-create.ts b/server/routes/bots-create.ts
index 553ab7dbe0..f6d62a2bea 100644
--- a/server/routes/bots-create.ts
+++ b/server/routes/bots-create.ts
@@ -1,4 +1,3 @@
-import { teamCrownRefusal } from "../host/team-crown.ts";
import type { WireBot } from "../../shared/wire.ts";
import { freshLook } from "../bot-look.ts";
import { validateBotCwd } from "../bot-cwd.ts";
@@ -243,9 +242,7 @@ export function createBotCreateRoutes(deps: BotCreateRouteDeps): RouteHandler {
}
// Creation is complete: activation errors must not invite a duplicate retry or delete a bot whose routine may have run.
const warnings: string[] = [];
- const crownRefused = settings.chiefOfStaff ? teamCrownRefusal(Boolean(deps.team), bot, { chiefOfStaff: true }) : null;
- if (crownRefused) warnings.push(crownRefused);
- else if (settings.chiefOfStaff) {
+ if (settings.chiefOfStaff) {
try {
store.patchBot(bot.id, { managedSections: settings.managedSections ?? [] });
store.setChiefOfStaff(bot.id);
diff --git a/server/routine-delegation.e2e.test.ts b/server/routine-delegation.e2e.test.ts
index dbc27ddfc5..4a3194aa4e 100644
--- a/server/routine-delegation.e2e.test.ts
+++ b/server/routine-delegation.e2e.test.ts
@@ -111,7 +111,7 @@ describe("routine delegation through the isolated harness", () => {
const { receipts } = await delegate(run.threadId);
finish(run.threadId);
await expect.poll(async () => (await runState(run.id))?.status, { timeout: 15_000 }).toBe("waiting");
- expect((await runState(run.id)).attention).toContain("delegated");
+ expect((await runState(run.id)).attention).toContain("handed on");
expect((await runState(run.id)).finishedAt).toBeUndefined();
const work = await awaitPeerWork(run.threadId);
expect(work).toMatchObject({ id: receipts[0].requestId, status: "queued", mode: "work", reply: "resume", text: "Produce the fixture report." });
diff --git a/server/store.ts b/server/store.ts
index c729970546..1f839ce68b 100644
--- a/server/store.ts
+++ b/server/store.ts
@@ -5,7 +5,7 @@ import { OwnedFile, writeFileAtomic } from "./atomic.ts"; import { saveSoon } fr
import { commitRegistryChange, keptRevocation, saveRegistryFor, touchesPermissions } from "./registry-save.ts";
import { parseToolScope, toolScopeWidens } from "../shared/tool-scope.ts"; import { grantScopedApps } from "../shared/connector-scopes.ts";
import { reorderStable } from "../shared/bot-order.ts";
-import { botOwner, chiefConflict, chiefScope, ownerEmail } from "../shared/bot-owner.ts"; import { wearsCrown } from "../shared/default-bot.ts";
+import { botOwner, chiefConflict, chiefScope, ownerEmail } from "../shared/bot-owner.ts";
import { ensureSections, readSections, changeEmptySection } from "./section-context.ts";
import type { TeamComputers } from "./team-computers.ts";
import { removeBotFolder, soulFile, soulHash, writeSoulMirror } from "./bot-folder.ts";
@@ -1393,7 +1393,7 @@ export class Store {
if (chief.lastTeamSetupReceipt?.requestId === request.requestId) return chief.lastTeamSetupReceipt.result;
const managedSections = [...new Set([...(chief.managedSections ?? []), ...request.newTeams])];
if (managedSections.length > 100 || managedSections.some((name) => name.trim() !== name || name.length > 60) ||
- request.newTeams.some((name) => !name) || (request.newTeams.length && !wearsCrown(chief))) throw new Error("Invalid reviewed Chief team scope");
+ request.newTeams.some((name) => !name) || (request.newTeams.length && !chief.chiefOfStaff)) throw new Error("Invalid reviewed Chief team scope");
const nextBots = [...this.bots];
const changed: BotRecord[] = [];
for (const operation of request.operations) {
diff --git a/server/team-backup.test.ts b/server/team-backup.test.ts
index a14513323e..72185853ce 100644
--- a/server/team-backup.test.ts
+++ b/server/team-backup.test.ts
@@ -5,7 +5,6 @@ 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";
@@ -61,15 +60,6 @@ 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-backup.ts b/server/team-backup.ts
index 00181aa0a6..1d06bd1fed 100644
--- a/server/team-backup.ts
+++ b/server/team-backup.ts
@@ -1,4 +1,3 @@
-import { wearsCrown } from "../shared/default-bot.ts";
import { newId, type ModelSelection } from "./contracts.ts";
import { botBodyId } from "../shared/bot-body.ts";
import { takeImportName } from "../shared/import-name.ts";
@@ -107,7 +106,7 @@ export function createTeamBackup(store: Store, routines: Routine[], name: string
section: bot.section, color: bot.color,
mascotExpression: bot.mascotExpression ?? undefined, mascotBody: bot.mascotBody ?? undefined,
mascotFaceColor: bot.mascotFaceColor ?? undefined,
- chiefOfStaff: wearsCrown(bot), hidden: Boolean(bot.hidden), playbooks: bot.playbooks ?? [],
+ chiefOfStaff: Boolean(bot.chiefOfStaff), hidden: Boolean(bot.hidden), playbooks: bot.playbooks ?? [],
// Grants travel so the team's shape survives, but the import still lands every bot grant-less.
...(bot.connectorTools ? { connectorTools: structuredClone(bot.connectorTools) } : {}),
...(bot.toolScope !== undefined ? { toolScope: structuredClone(bot.toolScope) } : {}),
diff --git a/server/team-setup-requests.test.ts b/server/team-setup-requests.test.ts
index 3ea4a0cdcd..24507e7098 100644
--- a/server/team-setup-requests.test.ts
+++ b/server/team-setup-requests.test.ts
@@ -1,4 +1,3 @@
-import { readTeamRolesWith } from "./chief-level.ts";
import { describe, expect, it, vi } from "vitest";
import { mkdtempSync } from "node:fs";
import { tmpdir } from "node:os";
@@ -65,17 +64,6 @@ 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.chief.defaultBot = { person: "[email protected]" };
- readTeamRolesWith(() => "admin");
- try {
- expect(() => h.propose([{ action: "update", botId: h.peer.id, fields: { chiefOfStaff: true } }])).toThrow(/Only the Chief of Staff changes who the Chief is/);
- } finally {
- readTeamRolesWith(() => null);
- }
- });
-
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);
diff --git a/server/team-setup-requests.ts b/server/team-setup-requests.ts
index 7ba6a884a3..2a910a7318 100644
--- a/server/team-setup-requests.ts
+++ b/server/team-setup-requests.ts
@@ -1,4 +1,3 @@
-import { wearsCrown } from "../shared/default-bot.ts";
import { createHash } from "node:crypto";
import { botOwner, chiefScope } from "../shared/bot-owner.ts";
import { z } from "zod";
@@ -162,7 +161,7 @@ export class TeamSetupRequestService {
if (this.options.targetBusy(target.id, sourceThreadId) && (confirming || target.id !== chief.id)) throw new TeamSetupError(`Stop @${target.name}'s work before changing its setup`, 409);
}
const fields = this.fields(operation.fields, target ?? undefined);
- if (fields.chiefOfStaff !== undefined && !wearsCrown(chief)) throw new TeamSetupError(`Only the Chief of Staff changes who the Chief is; ${chief.name} doesn't.`, 403);
+ if (fields.chiefOfStaff !== undefined && !chief.chiefOfStaff) throw new TeamSetupError(`Only the Chief of Staff changes who the Chief is; ${chief.name} doesn't.`, 403);
if (confirming && target) this.options.validateChange?.(target, fields);
const destination = fields.section ?? target?.section ?? chief.section;
if (!allowed(destination)) throw new TeamSetupError("The destination team is outside this Chief's authorized scope", 403);
diff --git a/server/testing/team-earlier-chief.ts b/server/testing/team-earlier-chief.ts
deleted file mode 100644
index ac62dd04f9..0000000000
--- a/server/testing/team-earlier-chief.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import { readFileSync } from "node:fs";
-import { join } from "node:path";
-
-import type { CloudTeamFixture } from "../../scripts/testing/cloud-send-fixture.ts";
-
-/** A person's own Chief from before their MausBot became it: a crown no route gives a bot someone owns any more, reached
- * by handing them the team's own Chief before their first look at the bots makes their MausBot. */
-export async function chiefCrownedEarlier<T>(team: CloudTeamFixture, token: string, name: string, email: string): Promise<T> {
- const bots = JSON.parse(readFileSync(join(team.home, ".openmausbot", "bots.json"), "utf8")) as Array<{ id: string; chiefOfStaff?: boolean }>;
- const chief = bots.find((bot) => bot.chiefOfStaff)!;
- const renamed = await team.as(token, "PATCH", `/api/bots/${chief.id}`, { name });
- if (renamed.status !== 200) throw new Error(`rename: ${JSON.stringify(renamed.body)}`);
- const handed = await team.as(token, "PUT", `/api/bots/${chief.id}/reports-to`, { email });
- if (handed.status !== 200) throw new Error(`hand over: ${JSON.stringify(handed.body)}`);
- return handed.body.bot as T;
-}
diff --git a/shared/default-bot.ts b/shared/default-bot.ts
index f445545c2b..bf619e1bd0 100644
--- a/shared/default-bot.ts
+++ b/shared/default-bot.ts
@@ -28,10 +28,6 @@ export interface HelperIntroField extends HelperFollowupField {
export const defaultBotPerson = (bot: DefaultBotFields): string => bot.defaultBot?.person?.trim().toLowerCase() ?? "";
-/** A Chief of Staff people see as one: a Team Cloud member's MausBot is its person's Chief without the title, the
- * team-wide notices or the place's proactive work. */
-export const wearsCrown = (bot: DefaultBotFields & { chiefOfStaff?: boolean }): boolean => Boolean(bot.chiefOfStaff) && !defaultBotPerson(bot);
-
/** The MausBot a viewer sees as theirs: their own on a Team Cloud (by email), else the place's. */
export function viewersDefaultBot<T extends DefaultBotFields>(bots: readonly T[], email?: string | null): T | undefined {
const person = email?.trim().toLowerCase() ?? "";
diff --git a/src/components/BotRole.tsx b/src/components/BotRole.tsx
index 33410dbbbf..675dcf0b0b 100644
--- a/src/components/BotRole.tsx
+++ b/src/components/BotRole.tsx
@@ -1,4 +1,3 @@
-import { wearsCrown } from "../../shared/default-bot";
import { Crown } from "lucide-react";
import { t } from "@/lib/i18n";
import type { Bot } from "@/state/store";
@@ -13,9 +12,9 @@ export function SidebarBotRole({ role }: { role: string }) {
);
}
-export function ChatHeadRole({ bot }: { bot: Pick<Bot, "title" | "chiefOfStaff" | "defaultBot"> }) {
+export function ChatHeadRole({ bot }: { bot: Pick<Bot, "title" | "chiefOfStaff"> }) {
const role = bot.title.trim();
- const repeatsChiefBadge = wearsCrown(bot) && role.toLocaleLowerCase() === t("chat.chiefOfStaff").toLocaleLowerCase();
+ const repeatsChiefBadge = bot.chiefOfStaff && role.toLocaleLowerCase() === t("chat.chiefOfStaff").toLocaleLowerCase();
if (!role || repeatsChiefBadge) return null;
return (
<span data-chathead-role className="flex min-w-0 max-w-fit grow basis-0">
@@ -25,7 +24,7 @@ export function ChatHeadRole({ bot }: { bot: Pick<Bot, "title" | "chiefOfStaff"
}
export function chiefOfStaffBadge(bot: Bot) {
- if (!wearsCrown(bot)) return null;
+ if (!bot.chiefOfStaff) return null;
return (
<span title={t("chat.chiefOfStaff")} className="flex shrink-0 items-center gap-1 whitespace-nowrap rounded-full bg-accent/12 px-2 py-0.5 text-[11px] font-medium text-accent @max-4xl/chathead:px-1.5">
<Crown size={11} aria-hidden="true" /> <span className="@max-4xl/chathead:sr-only">{t("chat.chiefOfStaff")}</span>
diff --git a/src/components/HelperIntro.tsx b/src/components/HelperIntro.tsx
index f45deb76d2..9295fae329 100644
--- a/src/components/HelperIntro.tsx
+++ b/src/components/HelperIntro.tsx
@@ -1,4 +1,3 @@
-import { wearsCrown } from "../../shared/default-bot";
import { X } from "lucide-react";
import { t } from "@/lib/i18n";
@@ -40,7 +39,7 @@ function AdvancedHelperIntro({ botId, threadId, message, answered }: IntroProps)
<div className="w-fit max-w-[min(var(--chat-bubble-max),var(--chat-bubble-pct))] rounded-2xl bg-card px-4 py-2.5 text-[15px] leading-relaxed text-ink">
<p className="font-medium">{t("helperIntro.title", { name })}</p>
<p className="mt-1">{t("helperIntro.body")}</p>
- {bot && wearsCrown(bot) ? <p className="mt-1">{t("helperIntro.chief")}</p> : bot?.defaultBot && !bot.defaultBot.person && <p className="mt-1">{t("helperIntro.watch")}</p>}
+ {bot?.chiefOfStaff ? <p className="mt-1">{t("helperIntro.chief")}</p> : bot?.defaultBot && !bot.defaultBot.person && <p className="mt-1">{t("helperIntro.watch")}</p>}
{team && <p className="mt-1">{t("helperIntro.team", { team })}</p>}
{!answered && <p className="mt-1 text-ink-secondary">{t("helperIntro.try")}</p>}
</div>
diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx
index ba0bf93622..e092661a5e 100644
--- a/src/components/Sidebar.tsx
+++ b/src/components/Sidebar.tsx
@@ -1,4 +1,3 @@
-import { wearsCrown } from "../../shared/default-bot";
import { OrganizationIdentity } from "./OrganizationIdentity";
import { memo, useCallback, useEffect, useMemo, useRef, useState, type CSSProperties, type Dispatch } from "react";
import { createPortal } from "react-dom";
@@ -715,7 +714,7 @@ export const BotListItem = memo(function BotListItem(props: BotRowProps) {
const visible = useVisibleMessages(bot);
const last = lastNonReceipt(visible);
const title = bot.title.trim();
- const details = [title, wearsCrown(bot) ? t("sidebar.bot.chiefOfStaff") : ""].filter(Boolean);
+ const details = [title, bot.chiefOfStaff ? t("sidebar.bot.chiefOfStaff") : ""].filter(Boolean);
const rowClass = cn(
"flex w-full items-center rounded-xl text-left transition-colors duration-150", SIMPLE_ROW_FOCUS,
iconOnly
@@ -758,7 +757,7 @@ export const BotListItem = memo(function BotListItem(props: BotRowProps) {
className={cn("absolute -right-0.5 -bottom-0.5 rounded-full border-2 border-panel bg-accent", iconOnly ? "size-3" : "size-2.5")} />}
{!simpleRow && !teammateWait && !waiting && !working && queued && <span data-testid="queued-dot" role="status" aria-label={t("task.queued")} title={t("task.queued")}
className={cn("absolute -right-0.5 -bottom-0.5 rounded-full border-2 border-panel bg-ink-secondary", iconOnly ? "size-3" : "size-2.5")} />}
- {wearsCrown(bot) && (iconOnly || simpleRow) && (
+ {bot.chiefOfStaff && (iconOnly || simpleRow) && (
<span className="absolute -left-1 -top-1 flex rounded-full bg-raised p-[3px]">
<Crown size={11} strokeWidth={2.25} className="shrink-0 text-accent" role="img" aria-label={t("sidebar.bot.chiefOfStaff")} data-testid="chief-crown">
<title>{t("sidebar.bot.chiefOfStaff")}</title>
@@ -795,7 +794,7 @@ export const BotListItem = memo(function BotListItem(props: BotRowProps) {
className="truncate"
inputClassName={cn("w-full rounded bg-inset px-1 py-0.5", simpleRow ? "text-[14px] font-medium" : "text-[15px] font-semibold")}
/>
- {!simpleList && wearsCrown(bot) && !renaming && (
+ {!simpleList && bot.chiefOfStaff && !renaming && (
<Crown size={13} strokeWidth={2.25} className="shrink-0 text-accent" role="img" aria-label={t("sidebar.bot.chiefOfStaff")} data-testid="chief-crown">
<title>{t("sidebar.bot.chiefOfStaff")}</title>
</Crown>
@@ -864,7 +863,7 @@ export const BotListItem = memo(function BotListItem(props: BotRowProps) {
!renaming && iconOnly
? deleting
? t("sidebar.bot.deletingAria", { name: bot.name })
- : `${bot.name}${bot.title?.trim() ? ` · ${bot.title.trim()}` : ""}${wearsCrown(bot) ? ` · ${t("sidebar.bot.chiefOfStaff")}` : ""}${onLiveCall ? ` · ${t("call.live.badge")}` : ""}${waiting ? ` · ${t("sidebar.preview.waiting")}` : working ? ` · ${t("chat.activity.working")}` : teammateWait ? ` · ${t("sidebar.preview.waitingOnTeammate")}` : queued ? ` · ${t("task.queued")}` : ""}${unread ? ` · ${t("task.unread")}` : ""}`
+ : `${bot.name}${bot.title?.trim() ? ` · ${bot.title.trim()}` : ""}${bot.chiefOfStaff ? ` · ${t("sidebar.bot.chiefOfStaff")}` : ""}${onLiveCall ? ` · ${t("call.live.badge")}` : ""}${waiting ? ` · ${t("sidebar.preview.waiting")}` : working ? ` · ${t("chat.activity.working")}` : teammateWait ? ` · ${t("sidebar.preview.waitingOnTeammate")}` : queued ? ` · ${t("task.queued")}` : ""}${unread ? ` · ${t("task.unread")}` : ""}`
: undefined
}
aria-busy={deleting || undefined} aria-keyshortcuts={drag ? "Alt+ArrowUp Alt+ArrowDown" : undefined}
diff --git a/src/components/SidebarTiles.tsx b/src/components/SidebarTiles.tsx
index 34c2a70c2f..903e88212a 100644
--- a/src/components/SidebarTiles.tsx
+++ b/src/components/SidebarTiles.tsx
@@ -1,4 +1,3 @@
-import { wearsCrown } from "../../shared/default-bot";
import { Crown, Loader2, Phone } from "lucide-react";
import { memo, useLayoutEffect, useRef, useState, type KeyboardEvent, type MouseEvent } from "react";
@@ -36,7 +35,7 @@ export const SidebarBotTile = memo(function SidebarBotTile({ primary = false, dr
const onLiveCall = liveBadgeFor(bot.id, liveMedia, liveCall);
const tooltip = botTooltip(bot, instances);
const status = waiting ? t("sidebar.preview.waiting") : working ? t("chat.activity.working") : teammateWait ? t("sidebar.preview.waitingOnTeammate") : queued ? t("task.queued") : "";
- const label = [bot.name, wearsCrown(bot) ? t("sidebar.bot.chiefOfStaff") : "", onLiveCall ? t("call.live.badge") : "", status, unread ? t("task.unread") : ""].filter(Boolean).join(" · ");
+ const label = [bot.name, bot.chiefOfStaff ? t("sidebar.bot.chiefOfStaff") : "", onLiveCall ? t("call.live.badge") : "", status, unread ? t("task.unread") : ""].filter(Boolean).join(" · ");
const reorder = pinnedCircleDragHandlers(bot.id, { drag, dragging, prevId, nextId });
const open = () => openBot(dispatch, bot, showThreads);
const rename = (name: string) => {
@@ -90,7 +89,7 @@ export const SidebarBotTile = memo(function SidebarBotTile({ primary = false, dr
motionKey={mascotMotion?.nonce ?? 0}
animated={working || noticing || (mascotMotion?.kind ?? "none") !== "none"}
/>
- {primary && wearsCrown(bot) && (
+ {primary && bot.chiefOfStaff && (
<span data-testid="chief-badge" className={cn("absolute -bottom-px -right-px flex size-4 items-center justify-center rounded-full bg-[#E8993A] text-white", RING)}>
<Crown size={10} strokeWidth={1.5} fill="currentColor" aria-hidden="true" />
</span>
diff --git a/src/components/SimpleHelperIntro.tsx b/src/components/SimpleHelperIntro.tsx
index 64f53192a2..d8b180375b 100644
--- a/src/components/SimpleHelperIntro.tsx
+++ b/src/components/SimpleHelperIntro.tsx
@@ -1,4 +1,3 @@
-import { wearsCrown } from "../../shared/default-bot";
import { useEffect, useRef, useState } from "react";
import { cn } from "@/lib/cn";
@@ -117,7 +116,7 @@ export function SimpleHelperIntro({ botId, threadId, message, answered, followup
const bot = state.bots.find((candidate) => candidate.id === botId);
const team = bot?.defaultBot?.person ? state.config?.team?.name : undefined;
const person = greetingName(state.config?.profile?.name) || undefined;
- const lines = introLines({ name: bot?.name ?? "MausBot", chief: Boolean(bot && wearsCrown(bot)), person, team });
+ const lines = introLines({ name: bot?.name ?? "MausBot", chief: Boolean(bot?.chiefOfStaff), person, team });
const look = useLookAround(!answered);
const ai = thinksWith(bot, state.instances);
diff --git a/src/components/TeamCanvas.tsx b/src/components/TeamCanvas.tsx
index 44490c99f2..6890813764 100644
--- a/src/components/TeamCanvas.tsx
+++ b/src/components/TeamCanvas.tsx
@@ -1,4 +1,3 @@
-import { wearsCrown } from "../../shared/default-bot";
import { useCallback, useEffect, useMemo, useRef, useState, type PointerEvent as ReactPointerEvent } from "react";
import { ArrowRight, BookOpen, Brain, Crown, MessageCircle, Minus, Monitor, MoreHorizontal, Pencil, Plus, Trash2, Users } from "lucide-react";
import { api, openBot, useStore, type Bot } from "@/state/store";
@@ -61,8 +60,8 @@ function BotCard({ bot, selected, moving, connected, tagged = false, sent, onCom
<BotAvatar bot={bot} size={38} motion="none" motionKey={0} animated={false} />
<span className="min-w-0 flex-1">
<span className="flex items-center gap-1.5"><span className="truncate text-[14px] font-semibold">{name}</span>
- {wearsCrown(bot) && <Crown size={12} className="shrink-0 text-warning" aria-label={t("chat.chiefOfStaff")} />}</span>
- <span className="mt-1 block truncate text-[11px] text-ink-secondary">{bot.title || (wearsCrown(bot) ? t("chat.chiefOfStaff") : t("canvas.bot"))}</span>
+ {bot.chiefOfStaff && <Crown size={12} className="shrink-0 text-warning" aria-label={t("chat.chiefOfStaff")} />}</span>
+ <span className="mt-1 block truncate text-[11px] text-ink-secondary">{bot.title || (bot.chiefOfStaff ? t("chat.chiefOfStaff") : t("canvas.bot"))}</span>
</span>
</button>
<div className="flex h-[43px] items-center gap-1 border-t border-hairline/30 px-2">
diff --git a/src/components/TeamOrgChart.tsx b/src/components/TeamOrgChart.tsx
index 30f762d3f4..c05bf0822b 100644
--- a/src/components/TeamOrgChart.tsx
+++ b/src/components/TeamOrgChart.tsx
@@ -1,6 +1,5 @@
// The Team map's "Who looks after what" on a Team Cloud: people across the top, each with the bots they look after by
// department. Dragging a bot onto a person, or its button, changes who looks after it (`reportsTo`).
-import { wearsCrown } from "../../shared/default-bot";
import { useMemo, useState, useSyncExternalStore, type DragEvent } from "react";
import { Crown, UserRound } from "lucide-react";
import { cn } from "@/lib/cn";
@@ -47,7 +46,7 @@ function BotRow({ bot, team, onDragStart }: { bot: Bot; team: TeamPeople; onDrag
className={cn("group flex items-center gap-2 rounded-lg border border-hairline/40 bg-card px-2 py-1.5", movable && "cursor-grab active:cursor-grabbing")}>
<BotAvatar bot={bot} size={24} motion="none" motionKey={0} animated={false} />
<span className="min-w-0 flex-1 truncate text-[13px] text-ink">{bot.name}</span>
- {wearsCrown(bot) && <Crown size={12} className="shrink-0 text-accent" aria-label={t("orgChart.chief")} />}
+ {bot.chiefOfStaff && <Crown size={12} className="shrink-0 text-accent" aria-label={t("orgChart.chief")} />}
{movable && <button type="button" aria-label={t("lookedAfter.change", { bot: bot.name })} title={t("lookedAfter.change", { bot: bot.name })}
onClick={(event) => {
const rect = event.currentTarget.getBoundingClientRect();
diff --git a/src/components/bot-panel/PanelHero.tsx b/src/components/bot-panel/PanelHero.tsx
index 36b8b89e37..b440c9b27b 100644
--- a/src/components/bot-panel/PanelHero.tsx
+++ b/src/components/bot-panel/PanelHero.tsx
@@ -1,4 +1,3 @@
-import { wearsCrown } from "../../../shared/default-bot";
import { useEffect, useRef, useState, type KeyboardEvent } from "react";
import { Crown, Pencil } from "lucide-react";
@@ -88,7 +87,7 @@ export function PanelHero({ bot, activeState, patch, editorOpen, onToggleEditor
>
<Pencil size={20} />
</span>
- {wearsCrown(bot) && (
+ {bot.chiefOfStaff && (
<span data-panel-chief title={t("chat.chiefOfStaff")} className="absolute -bottom-0.5 -right-0.5 flex size-[22px] items-center justify-center rounded-full bg-accent text-accent-ink ring-[3px] ring-app">
<Crown size={12} aria-hidden="true" />
<span className="sr-only">{t("chat.chiefOfStaff")}</span>
diff --git a/src/components/bot-settings/PermissionsSection.test.ts b/src/components/bot-settings/PermissionsSection.test.ts
index b9250cd15b..ca9f98b5d1 100644
--- a/src/components/bot-settings/PermissionsSection.test.ts
+++ b/src/components/bot-settings/PermissionsSection.test.ts
@@ -9,6 +9,8 @@ vi.mock("@/lib/use-owner-or-admin", () => ({ useOwnerOrAdmin: () => false }));
const { BotEditorStore, initialState } = await import("@/state/store");
const { PermissionsSection } = await import("./PermissionsSection");
+const { setTeamPeople } = await import("@/state/team-people");
+const { t } = await import("@/lib/i18n");
type Derived = Parameters<typeof PermissionsSection>[0]["derived"];
const base: Bot = {
@@ -84,6 +86,21 @@ describe("Full access in bot settings", () => {
});
});
+describe("on a team", () => {
+ const chief: Bot = { ...base, chiefOfStaff: true, managedSections: ["Sales"] };
+ afterEach(() => setTeamPeople(null));
+
+ it("offers no Chief of Staff card and no departments to be in charge of; off a team both stay", () => {
+ render(chief);
+ expect(host.textContent).toContain(t("permissions.chief.title"));
+ expect(host.textContent).toContain(t("botAccess.teams.title"));
+ setTeamPeople({ people: [], me: null, admin: true, needsYou: [] });
+ render(chief);
+ expect(host.textContent).not.toContain(t("permissions.chief.title"));
+ expect(host.textContent).not.toContain(t("botAccess.teams.title"));
+ });
+});
+
describe("PermissionsSection parts", () => {
it("leaves Chief of Staff and peer checks out of a page that asks only for approvals", () => {
const derived = {
diff --git a/src/lib/team-org-chart.ts b/src/lib/team-org-chart.ts
index 3ba8993415..2b20366b56 100644
--- a/src/lib/team-org-chart.ts
+++ b/src/lib/team-org-chart.ts
@@ -1,10 +1,9 @@
// "Who reports to whom" on a Team Cloud: one column per person, each with their Chief of Staff and the bots that report
// to them grouped by department, and a column for bots nobody owns yet.
-import { wearsCrown } from "../../shared/default-bot";
import { botOwner, nameFromEmail } from "../../shared/bot-owner";
import type { TeamPerson } from "@/state/team-people";
-export interface OrgBot { id: string; name: string; hidden?: boolean; section?: string; chiefOfStaff?: boolean; createdBy?: string; reportsTo?: string; defaultBot?: { person?: string } }
+export interface OrgBot { id: string; name: string; hidden?: boolean; section?: string; chiefOfStaff?: boolean; createdBy?: string; reportsTo?: string }
export interface OrgDepartment<T extends OrgBot> { key: string; bots: T[] }
export interface OrgColumn<T extends OrgBot> { person: TeamPerson | null; chief: T | null; departments: OrgDepartment<T>[] }
@@ -27,7 +26,7 @@ export function buildOrgChart<T extends OrgBot>(bots: readonly T[], people: read
const ordered = [...people, ...unlisted].sort((a, b) => Number(Boolean(b.you)) - Number(Boolean(a.you)));
const columns: OrgColumn<T>[] = ordered.map((person) => {
const own = shown.filter((bot) => botOwner(bot) === person.email);
- const chief = own.find(wearsCrown) ?? null;
+ const chief = own.find((bot) => bot.chiefOfStaff) ?? null;
return { person, chief, departments: departmentsOf(own.filter((bot) => bot !== chief)) };
});
const unowned = shown.filter((bot) => !botOwner(bot));