Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Rooms: let a Chief of Staff open a new thread in a room (#3878) (#4267)
Aditya Umale318a764cb415
diff --git a/server/drivers/agents-aliases.test.ts b/server/drivers/agents-aliases.test.tsindex e3e5c14e30..fcd3328502 100644--- a/server/drivers/agents-aliases.test.ts+++ b/server/drivers/agents-aliases.test.ts@@ -110,7 +110,7 @@ describe("the agents action tools", () => {trigger_info: { list: READ, events: READ },trigger: { create: CHANGE, update: CHANGE, pause: CHANGE, resume: CHANGE, run_now: CHANGE },delete_trigger: { delete: DELETE },- manage_room: { create: CHANGE, add_members: CHANGE, remove_members: CHANGE, set_members: CHANGE, rename: CHANGE, set_bulletin: CHANGE },+ manage_room: { create: CHANGE, add_members: CHANGE, remove_members: CHANGE, set_members: CHANGE, rename: CHANGE, set_bulletin: CHANGE, new_thread: CHANGE },session_search: { search: READ, read: READ },show_widget: { show: CHANGE, update: CHANGE },show_html: { show: CHANGE, update: CHANGE },diff --git a/server/drivers/agents-catalog-goldens/full.tools-list.json b/server/drivers/agents-catalog-goldens/full.tools-list.jsonindex 8d14f681b3..a143518e6c 100644--- a/server/drivers/agents-catalog-goldens/full.tools-list.json+++ b/server/drivers/agents-catalog-goldens/full.tools-list.json@@ -762,7 +762,7 @@},{"name": "manage_room",- "description": "Chiefs only, for rooms in your own department. create a room (was create_room) when the user asks for one (at most four per turn), with active bots from list_bots in any department; you are included automatically as the default responder, and it creates no turns or messages. For a room from list_rooms: rename it, change its bulletin, or add, remove or set members, with any bots you can reach; keep yourself as a member. Busy rooms, pending approvals and team-goal leads are protected. Moving rooms or bots between departments stays with the user; coordinate_bots reaches bots outside a room directly. Follow the tool result under the effective access level; if the change is refused, report the blocker, or ask the user to make the room change, without trying another route.",+ "description": "Chiefs only, for rooms in your own department. create a room (was create_room) when the user asks for one (at most four per turn), with active bots from list_bots in any department; you are included automatically as the default responder, and it creates no turns or messages. For a room from list_rooms: rename it, change its bulletin, add, remove or set members, with any bots you can reach (keep yourself as a member), or open a new thread in it (new_thread, at most four per turn), which becomes the room's current thread. Busy rooms, pending approvals and team-goal leads are protected. Moving rooms or bots between departments stays with the user; coordinate_bots reaches bots outside a room directly. Follow the tool result under the effective access level; if the change is refused, report the blocker, or ask the user to make the room change, without trying another route.","inputSchema": {"type": "object","additionalProperties": false,@@ -775,7 +775,8 @@"remove_members","set_members","rename",- "set_bulletin"+ "set_bulletin",+ "new_thread"],"description": "The change to make."},@@ -786,7 +787,7 @@"name": {"type": "string","maxLength": 100,- "description": "create and rename: the room's display name (e.g. \"Nalamdesk Team\")."+ "description": "create and rename: the room's display name (e.g. \"Nalamdesk Team\"). new_thread: the thread's title (optional)."},"member_bot_ids": {"type": "array",diff --git a/server/drivers/agents-catalog-goldens/profiles.json b/server/drivers/agents-catalog-goldens/profiles.jsonindex 428c251ac4..e2a255c1db 100644--- a/server/drivers/agents-catalog-goldens/profiles.json+++ b/server/drivers/agents-catalog-goldens/profiles.json@@ -1,7 +1,7 @@{"default": {- "bytes": 58250,- "sha256": "629d26916317c8467e7812622571c327bfd537cef204e30799eae8dd156b751e",+ "bytes": 58409,+ "sha256": "9562c453e4685c5ca69ede2fcb7138b2b455aa9a2fdbfa4478f06f5a718a0385","tools": ["tool_result_read","list_room_targets",@@ -50,8 +50,8 @@]},"voice": {- "bytes": 59031,- "sha256": "75b9dd335ba6e4f450146d03c70ec50a462b29ebb7c53127655386221da61efe",+ "bytes": 59190,+ "sha256": "eac49a92507f595d879017cfd47f08361be5f1a5078bd840c08eff1059b74e39","tools": ["tool_result_read","list_room_targets",@@ -101,8 +101,8 @@]},"shared": {- "bytes": 60515,- "sha256": "597957224c42ff4bfdd09c9b45138920f28534ede7baf59054c4c2daf02826e2",+ "bytes": 60674,+ "sha256": "ea942863af945881f8bd250611e8c5d3e575855af399d884381bec9fb1c063cd","tools": ["tool_result_read","list_shared_computers",@@ -153,8 +153,8 @@]},"shared+voice": {- "bytes": 61296,- "sha256": "63346dbadb184c786e1b04c199fe01c574b35a112847a84c9010da1efde9aa37",+ "bytes": 61455,+ "sha256": "ba67957c0cd7f41b2d811efb95e9f301c9a2cd7429cd5649459b2f5ee6f13c59","tools": ["tool_result_read","list_shared_computers",@@ -206,8 +206,8 @@]},"skills": {- "bytes": 61069,- "sha256": "1c6de1d060b3461da67b2bfa39193ce8d0c1b2c6af001205d2fe16cad9ca561c",+ "bytes": 61228,+ "sha256": "44fb483dd17dc7a3207326a08b15a36830277f01e7dec6c5ac99b82c0ad55437","tools": ["tool_result_read","list_room_targets",@@ -258,8 +258,8 @@]},"skills+voice": {- "bytes": 61850,- "sha256": "8e17ae215ef60d9e8d07fd2bb4a98fceb1cc76db52d51b657df5a2ac1c781aef",+ "bytes": 62009,+ "sha256": "562d2e51f73b659a492f121fcc3823a9e017fefb451841d8678b17fdf7c9ce77","tools": ["tool_result_read","list_room_targets",@@ -311,8 +311,8 @@]},"skills+shared": {- "bytes": 63334,- "sha256": "56d92e837cba1a5c95f8f2f9d7352655d469f961d7b609d2910ce57698dd73bd",+ "bytes": 63493,+ "sha256": "050200414b4d840c2dc81783ec45240ef3630a47b9fc77cd64109351614f912d","tools": ["tool_result_read","list_shared_computers",@@ -365,8 +365,8 @@]},"skills+shared+voice": {- "bytes": 64115,- "sha256": "f14ff02fca1b2b6762ac3ed2e652b904bb3a5e836809fd212f5b29085c778b74",+ "bytes": 64274,+ "sha256": "2b1428a64a26703de1ae9b6a1bc8ef3d872aca317f68efccff320ce8068befd9","tools": ["tool_result_read","list_shared_computers",@@ -784,8 +784,8 @@]},"skills+shared+voice+cloud-home": {- "bytes": 63881,- "sha256": "005235764b5e61b1df843e6129e06582ab0a1a1b101171b1223206ab549ae420",+ "bytes": 64040,+ "sha256": "58dbe3d5123035455534cb47be9de9c8f200a56a69a35734c64600a53599c9f3","tools": ["tool_result_read","list_shared_computers",@@ -887,8 +887,8 @@]},"skills+shared+voice+escalations": {- "bytes": 64945,- "sha256": "ecb98a935710b8eaae36e57cff42b1677a2fdae789c5da296b6e4c2652caf381",+ "bytes": 65104,+ "sha256": "cf4ff32466e78a0d325ed21d69e6b718df04e52aa476d4df42bb706f8d74852b","tools": ["tool_result_read","list_shared_computers",@@ -943,8 +943,8 @@]},"skills+shared+voice+escalations+x": {- "bytes": 68784,- "sha256": "57f2cc85dba84ec964138c066ea15fd7bdea07567860a1ad8a4be4765264d062",+ "bytes": 68943,+ "sha256": "802eec8e0474ebeb267b97647389cf9b9faa3be22f837a16a0730a9737dc3dc5","tools": ["tool_result_read","list_shared_computers",@@ -1003,8 +1003,8 @@]},"skills+shared+voice+escalations+x+team": {- "bytes": 69416,- "sha256": "1f0b49ebc53e08d1828ca9ca72e47b172cd8184e6f6cf2227d03f9490926d986",+ "bytes": 69575,+ "sha256": "c62f12910c8534088d25b903ba6f70de139b39d90f722ecb3c1c0221f8974a99","tools": ["tool_result_read","list_shared_computers",@@ -1064,8 +1064,8 @@]},"default+legacy-switches": {- "bytes": 58250,- "sha256": "629d26916317c8467e7812622571c327bfd537cef204e30799eae8dd156b751e",+ "bytes": 58409,+ "sha256": "9562c453e4685c5ca69ede2fcb7138b2b455aa9a2fdbfa4478f06f5a718a0385","tools": ["tool_result_read","list_room_targets",@@ -1114,8 +1114,8 @@]},"default+mausbot": {- "bytes": 58901,- "sha256": "b1a4b34d069475c8320bc116277af0f28dd64a0c38c0976da6ecb3fcd70411e9",+ "bytes": 59060,+ "sha256": "87d17f733fe82f6bfef7e0f1984111b8577756adad03ab176858e7dca428a5ec","tools": ["tool_result_read","list_room_targets",@@ -1166,8 +1166,8 @@]},"skills+shared+voice+mausbot": {- "bytes": 64766,- "sha256": "9924a5382dcb61053fc680328b815f8e5b3e5f322dbf46ca46ec3b252d75cef1",+ "bytes": 64925,+ "sha256": "9be4d6822fd7e63ccb8f8e6392aa7e303c1a16e3b911be2ea5b4edd9bd446358","tools": ["tool_result_read","list_shared_computers",@@ -1223,8 +1223,8 @@]},"default+no-computer-pick": {- "bytes": 57038,- "sha256": "3401b6f1d13953cecb62c6c1b784783597936c01fc1550293460b31d8200b656",+ "bytes": 57197,+ "sha256": "ce30f32b2926cbe267fd259c2ed6e51365d6ffa95b08d98623e215378dfe7167","tools": ["tool_result_read","list_room_targets",@@ -1272,8 +1272,8 @@]},"default+room": {- "bytes": 50120,- "sha256": "9936b6208a3ae004d937db685c249482eaaa61532db10816b2ed8f9af293e7f5",+ "bytes": 50279,+ "sha256": "81c95f17de75b178b06d88400c68d3e3a4e6e1b7cd74629b79b7b5002c1b3fb8","tools": ["tool_result_read","list_room_targets",diff --git a/server/drivers/agents-catalog.ts b/server/drivers/agents-catalog.tsindex ba011986c3..467c57b8b7 100644--- a/server/drivers/agents-catalog.ts+++ b/server/drivers/agents-catalog.ts@@ -429,18 +429,18 @@ const TOOL_DEFINITIONS = [{name: "manage_room",description:- "Chiefs only, for rooms in your own department. create a room (was create_room) when the user asks for one (at most four per turn), with active bots from list_bots in any department; you are included automatically as the default responder, and it creates no turns or messages. For a room from list_rooms: rename it, change its bulletin, or add, remove or set members, with any bots you can reach; keep yourself as a member. Busy rooms, pending approvals and team-goal leads are protected. Moving rooms or bots between departments stays with the user; coordinate_bots reaches bots outside a room directly. Follow the tool result under the effective access level; if the change is refused, report the blocker, or ask the user to make the room change, without trying another route.",+ "Chiefs only, for rooms in your own department. create a room (was create_room) when the user asks for one (at most four per turn), with active bots from list_bots in any department; you are included automatically as the default responder, and it creates no turns or messages. For a room from list_rooms: rename it, change its bulletin, add, remove or set members, with any bots you can reach (keep yourself as a member), or open a new thread in it (new_thread, at most four per turn), which becomes the room's current thread. Busy rooms, pending approvals and team-goal leads are protected. Moving rooms or bots between departments stays with the user; coordinate_bots reaches bots outside a room directly. Follow the tool result under the effective access level; if the change is refused, report the blocker, or ask the user to make the room change, without trying another route.",inputSchema: {type: "object",additionalProperties: false,properties: {action: {type: "string",- enum: ["create", "add_members", "remove_members", "set_members", "rename", "set_bulletin"],+ enum: ["create", "add_members", "remove_members", "set_members", "rename", "set_bulletin", "new_thread"],description: "The change to make.",},room_id: { type: "string", description: "Every action but create: the room's id from list_rooms." },- name: { type: "string", minLength: 1, maxLength: 100, description: "create and rename: the room's display name (e.g. \"Nalamdesk Team\")." },+ name: { type: "string", minLength: 1, maxLength: 100, description: "create and rename: the room's display name (e.g. \"Nalamdesk Team\"). new_thread: the thread's title (optional)." },member_bot_ids: {type: "array",minItems: 1,diff --git a/server/index.test.ts b/server/index.test.tsindex f9094469c5..262094cf5a 100644--- a/server/index.test.ts+++ b/server/index.test.ts@@ -2633,6 +2633,17 @@ describe("harness HTTP API", () => {expect((await manage({ action: "set_bulletin", bulletin: "Updated brief ✓" })).status).toBe(200);const readRoom = async () => (await api("GET", "/api/bots?messages=20")).body.groups.find((group: { id: string }) => group.id === roomId);expect(await readRoom()).toMatchObject({ name: "Renamed room", bulletin: "Updated brief ✓", section, memberIds: [chief.id, peer.id], defaultResponder: { kind: "member", botId: chief.id }, messages: [] });+ const opened = await manage({ action: "new_thread", name: "Launch plan" });+ expect(opened.status).toBe(201);+ expect(opened.body).toMatchObject({ ok: true, title: "Launch plan" });+ expect(opened.body.message).toContain(String(opened.body.threadId));+ expect(await readRoom()).toMatchObject({+ threadId: opened.body.threadId,+ tasks: expect.arrayContaining([expect.objectContaining({ threadId: opened.body.threadId, title: "Launch plan" })]),+ });+ expect((await manage({ action: "new_thread", name: "x".repeat(101) })).status).toBe(400);+ expect((await manage({ action: "new_thread", name: "x".repeat(81) })).status).toBe(400);+ expect((await manage({ action: "new_thread", name: "Line one\nLine two" })).status).toBe(400);for (const memberId of [foreign.id, excluded.id, "missing-bot"]) {expect((await create({ name: "Forbidden room", memberIds: [memberId] })).status).toBe(403);expect((await manage({ action: "add_members", memberIds: [memberId] })).status).toBe(403);@@ -2651,6 +2662,7 @@ describe("harness HTTP API", () => {const otherRoom = (await api("POST", "/api/groups", { name: "Unmanaged room", memberIds, section: roomSection })).body.group;roomIds.push(otherRoom.id);expect((await manage({ roomId: otherRoom.id, action: "rename", name: "Forbidden" })).status).toBe(403);+ expect((await manage({ roomId: otherRoom.id, action: "new_thread" })).status).toBe(403);}expect(await readRoom()).toMatchObject({ name: "Renamed room", bulletin: "Updated brief ✓", memberIds: [chief.id, peer.id] });expect((await api("PATCH", `/api/bots/${second.id}`, { hidden: true })).status).toBe(200);@@ -2658,6 +2670,7 @@ describe("harness HTTP API", () => {expect((await manage({ action: "add_members", memberIds: [second.id] })).status).toBe(403);expect((await api("PATCH", `/api/bots/${chief.id}`, { approvePeerComms: true })).status).toBe(200);expect((await manage({ action: "rename", name: "No review" })).body.error).toMatch(/peer approval is required/);+ expect((await manage({ action: "new_thread" })).status).toBe(403);expect((await create({ name: "No review", memberIds: [peer.id] })).status).toBe(403);expect((await api("PATCH", `/api/bots/${chief.id}`, { approvePeerComms: false })).status).toBe(200);for (let count = 1; count < 4; count += 1) {@@ -2666,6 +2679,8 @@ describe("harness HTTP API", () => {roomIds.push(String(created.body.id));}expect((await create({ name: "Fifth room", memberIds: [peer.id] })).status).toBe(429);+ for (let count = 2; count <= 4; count += 1) expect((await manage({ action: "new_thread" })).status).toBe(201);+ expect((await manage({ action: "new_thread", name: "Fifth thread" })).status).toBe(429);expect((await api("GET", "/api/bots?messages=0")).body.bots.find((bot: { id: string }) => bot.id === foreign.id).section).toBe(`${section} foreign`);expect((await api("PATCH", `/api/bots/${chief.id}`, { modelSelection: { instanceId: "claude", model: "claude-sonnet-5" } })).status).toBe(200);const busyToken = await mintTestCapability(BASE, chief.id, chief.threadId);diff --git a/server/index.ts b/server/index.tsindex ad58a5e009..1055e66d32 100644--- a/server/index.ts+++ b/server/index.ts@@ -1638,6 +1638,7 @@ type InternalCapability = {skillAuthoring: boolean;createdBots: number;createdRooms?: number;+ openedRoomThreads?: number;openedThreads: number;orphanExpiresAt: number;localVmTarget?: LocalVmTarget;@@ -14480,7 +14481,7 @@ const handleRequest = async (req: IncomingMessage, res: ServerResponse) => {}const parsed = z.object({fromBotId: z.string().optional(), fromThreadId: z.string().optional(),- roomId: z.string(), action: z.enum(["add_members", "remove_members", "set_members", "rename", "set_bulletin"]),+ roomId: z.string(), action: z.enum(["add_members", "remove_members", "set_members", "rename", "set_bulletin", "new_thread"]),memberIds: z.array(z.string()).min(1).max(100).optional(),name: z.string().trim().min(1).max(100).optional(), bulletin: z.string().max(12_000).optional(),}).strict().safeParse(body);@@ -14490,6 +14491,23 @@ const handleRequest = async (req: IncomingMessage, res: ServerResponse) => {return json(res, 403, { error: "you can only manage rooms you belong to in your own department, whose members you can all reach; no bot needs adding to get work, since coordinate_bots reaches bots outside the room directly" });}const { action, memberIds, name, bulletin } = parsed.data;+ if (action === "new_thread") {+ // Same as the person's "New thread" in the room: it becomes the room's current thread.+ if ((internalCapability.openedRoomThreads ?? 0) >= 4) {+ return json(res, 429, { error: "you can open at most 4 room threads in one turn" });+ }+ if (phoneSecretSubmissions.hasGroup(room.id)) {+ return json(res, 409, { error: "this room is securely saving a credential — try again when it finishes" });+ }+ if (name !== undefined && (name.length > 80 || !fitsOnOneLine(name))) return json(res, 400, { error: "a new_thread title must fit on one line, at most 80 characters" });+ const task = store.createGroupTask(room.id, name === undefined ? undefined : redactSecretsInText(name));+ if (!task) return json(res, 500, { error: "couldn't open a thread in that room" });+ internalCapability.openedRoomThreads = (internalCapability.openedRoomThreads ?? 0) + 1;+ return json(res, 201, {+ ok: true, threadId: task.threadId, title: task.title,+ message: `Opened thread “${task.title}” [thread: ${task.threadId}] in room “${room.name}”. It is now the room's current thread, so post_to_room for this room and coordinate_bots sent from outside this room go there; coordinate_bots from inside this room stays in that conversation.`,+ });+ }const patch: Record<string, unknown> = {};if (action === "rename") {if (name === undefined) return json(res, 400, { error: "rename requires a name" });