Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Team setup (#6128 rework): a bot's MCP servers apply like the plan's other changes
milind-soni20b48d310588
diff --git a/packages/phone-protocol/src/team-setup.ts b/packages/phone-protocol/src/team-setup.tsindex 7f3460a3f9..8975d7963f 100644--- a/packages/phone-protocol/src/team-setup.ts+++ b/packages/phone-protocol/src/team-setup.ts@@ -10,7 +10,7 @@ export interface TeamSetupFields {section?: string;modelSelection?: ModelSelection;chiefOfStaff?: boolean;- /** Update only: the bot's MCP servers by name. Always confirmed by the owner on a card, never applied on its own. */+ /** Update only: the bot's MCP servers by name. Applies like the plan's other changes. */mcpServers?: string[];}@@ -29,7 +29,7 @@ export interface TeamSetupResult {error?: string;}-/** The complete, reviewed operation. It never accepts executable permissions; an MCP server list waits for the owner's card. */+/** The complete, reviewed operation. Of the execution permissions it changes only a bot's MCP server list. */export interface TeamSetupRequest {version: 1;requestId: string;diff --git a/server/drivers/agents-catalog.ts b/server/drivers/agents-catalog.tsindex 2b877eb517..74e6dbdb0b 100644--- a/server/drivers/agents-catalog.ts+++ b/server/drivers/agents-catalog.ts@@ -108,7 +108,8 @@ const TRIGGER_FIELDS_SCHEMA = {} as const;const CHIEF_PROFILE_TARGET = " A Chief of Staff may pass for_bot_id (from list_bots) for a requested change to another bot in its section.";-const APPLIES_OUTCOME = " It applies at once, with an Undo where possible: read the result before saying it did. It never raises another bot's execution permissions.";+const APPLIES_AT_ONCE = " It applies at once, with an Undo where possible: read the result before saying it did.";+const APPLIES_OUTCOME = APPLIES_AT_ONCE + " It never raises another bot's execution permissions.";const TOOL_DEFINITIONS = [@@ -373,7 +374,7 @@ const TOOL_DEFINITIONS = [},{name: "propose_team_setup",- description: "Chief of Staff only: create specialists and change bots' profiles, models, Chiefs and teams as the person asked, all in ONE plan, with exact ids from list_team_setup. One operation per bot, at most 40 (8 new). A new team goes in newTeams with a specialist in this plan; teams you are not authorized for cannot be included. Models change defaults for new threads; an MCP server list always waits for the person; other execution permissions never change." + APPLIES_OUTCOME,+ description: "Chief of Staff only: create specialists and change bots' profiles, models, Chiefs and teams as the person asked, all in ONE plan, with exact ids from list_team_setup. One operation per bot, at most 40 (8 new). A new team goes in newTeams with a specialist in this plan; teams you are not authorized for cannot be included. Models change defaults for new threads; mcpServers sets an existing bot's MCP servers; no other execution permission changes." + APPLIES_AT_ONCE,inputSchema: {type: "object", additionalProperties: false,properties: {diff --git a/server/store.ts b/server/store.tsindex 4c8c09cd5f..56ea4e2eb6 100644--- a/server/store.ts+++ b/server/store.ts@@ -1369,7 +1369,7 @@ export class Store {if (operation.fields.modelSelection) next.tasks = this.withDefaultModel(previous, operation.fields.modelSelection);nextBots[at] = next;}- if (operation.fields.chiefOfStaff === false) delete next.managedSections;+ if (operation.fields.chiefOfStaff === false) delete next.managedSections; if (!Array.isArray(next.mcpServers)) delete next.mcpServers; // Undo's "every enabled server"next.section = sectionKey(next.section) || undefined;if (operation.fields.soul !== undefined) { next.soulHash = soulHash(operation.fields.soul); next.soulDrift = false; }changed.push(next);diff --git a/server/team-setup-requests.test.ts b/server/team-setup-requests.test.tsindex d6e0d5fee9..d2b445b049 100644--- a/server/team-setup-requests.test.ts+++ b/server/team-setup-requests.test.ts@@ -601,21 +601,24 @@ describe("team setup that applies on its own", () => {});describe("a bot's MCP servers in team setup", () => {- it("waits on the owner's card even under Full Access, then applies the list they confirmed", async () => {+ it("applies under Full Access like the plan's other changes, and Undo gives back every enabled server", async () => {const h = harness(); h.autoApply.mockReturnValue("full-access");const response = await h.submit([{ action: "update", botId: h.peer.id, fields: { mcpServers: ["linear", "hindsight", "linear"] } }]);- expect(response).toMatchObject({ applied: false, state: "pending" });+ expect(response).toMatchObject({ applied: true, state: "applied" });expect(response.detail).toContain("MCP servers it can use: every enabled server → linear, hindsight");expect(response.detail).toContain("Other execution permissions are unchanged.");+ expect(h.peer.mcpServers).toEqual(["linear", "hindsight"]);+ expect(await h.service.undo({ botId: h.chief.id, threadId: h.chief.threadId, requestId: response.requestId })).toMatchObject({ state: "undone" });+ expect(Array.isArray(h.apply.mock.calls.at(-1)![0].operations[0].fields.mcpServers)).toBe(false);+ });+ it("waits on the person's card below Full Access, like the plan's other changes, then applies the list they confirmed", async () => {+ const h = harness();+ const response = await h.submit([{ action: "update", botId: h.peer.id, fields: { mcpServers: ["hindsight"] } }]);+ expect(response).toMatchObject({ applied: false, state: "pending" });expect(h.apply).not.toHaveBeenCalled();- expect(h.peer.mcpServers).toBeUndefined();expect(h.messages[0].card?.options).toEqual(["Apply setup", "Cancel"]);expect(await h.resolve(response.requestId)).toMatchObject({ result: { state: "applied" } });- expect(h.peer.mcpServers).toEqual(["linear", "hindsight"]);- });- it("keeps a plan without MCP servers applying on its own", async () => {- const h = harness(); h.autoApply.mockReturnValue("full-access");- expect(await h.submit([{ action: "update", botId: h.peer.id, fields: { title: "Researcher" } }])).toMatchObject({ applied: true });+ expect(h.peer.mcpServers).toEqual(["hindsight"]);});it("cancels when the bot's list changed after the card was shown", async () => {const h = harness();diff --git a/server/team-setup-requests.ts b/server/team-setup-requests.tsindex b6230f3c9f..031eb89f38 100644--- a/server/team-setup-requests.ts+++ b/server/team-setup-requests.ts@@ -31,7 +31,7 @@ const fieldsSchema = z.object({modelSelection: z.object({ instanceId: z.string().trim().min(1), model: z.string().trim().min(1), effort: z.string().optional(), variant: z.string().optional() }).strict().optional(),mcpServers: z.array(z.string()).max(MAX_MCP_SERVERS, `Select at most ${MAX_MCP_SERVERS} MCP servers.`).optional(),}).strict();-/** A Chief may never apply a bot's MCP servers on its own: the owner confirms them on a card. */+/** The card says which execution permission a plan changes when it changes a bot's MCP servers. */const touchesMcp = (request: TeamSetupRequest) => request.operations.some((operation) => operation.fields.mcpServers !== undefined);const planSchema = z.object({reason: z.string().trim().min(1).max(500),@@ -289,10 +289,9 @@ export class TeamSetupRequestService {proposeDeletion(args: DeletionArgs) { return this.card(this.prepareDeletion(args), args.from); }async submit(args: SetupArgs & SubmitAuthority) {- const request = this.prepare(args);- const grant = touchesMcp(request) ? null : this.options.autoApply?.(args.botId, args.threadId) ?? null;- if (grant) return { ...await this.applyImmediately(request, args.from, args.canCommit), appliedBy: grant };- return { ...this.card(request, args.from), applied: false, state: "pending" as const };+ const grant = this.options.autoApply?.(args.botId, args.threadId) ?? null;+ if (grant) return { ...await this.applyImmediately(this.prepare(args), args.from, args.canCommit), appliedBy: grant };+ return { ...this.propose(args), applied: false, state: "pending" as const };}async submitDeletion(args: DeletionArgs & SubmitAuthority) {