A worker asks for another bot's help with ask_crew. The coordinator reads the request, asks the right bot (in a workspace, only its members), and sends the answer back into the asking bot's conversation, waking it. Each exchange is kept as a read-only chatroom: listed in the main rail after the workspaces, or in the workspace's rail for requests made there, with live status rows for each bot while it's open and a Stop button. Room sessions are hidden from every conversation list, other bots' words reach the model fenced as data, and turns, nesting and open rooms are capped. Closed rooms are pruned after a retention period and past a cap per place (Settings > General). Co-Authored-By: Claude Opus 5.5 <[email protected]>
49 lines
1.7 KiB
TypeScript
49 lines
1.7 KiB
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import chatroomTurns from "./chatroom-turns";
|
|
|
|
const names = new Map([
|
|
[1, "Coordinator"],
|
|
[3, "Ada"],
|
|
[5, "Ben"],
|
|
]);
|
|
|
|
describe("chatroomTurns", () => {
|
|
test("the coordinator's messages are its own turns; every other bot's is fenced data", () => {
|
|
const turns = chatroomTurns({
|
|
messages: [
|
|
{ bot_id: 3, text: "**Specs**\n\nI need the API specs." },
|
|
{ bot_id: 1, text: "Asking Ben." },
|
|
{ bot_id: 5, text: "Here they are." },
|
|
],
|
|
coordinator_id: 1,
|
|
requester_id: 3,
|
|
names,
|
|
});
|
|
|
|
expect(turns.map((turn) => turn.role)).toEqual(["user", "assistant", "user"]);
|
|
expect(turns[0]?.content).toContain("[From Ada (bot 3), who asked, passed on by the app.");
|
|
expect(turns[1]?.content).toBe("Asking Ben.");
|
|
expect(turns[2]?.content).toContain("[From Ben (bot 5), passed on by the app.");
|
|
expect(turns[2]?.content).toContain("```\nHere they are.\n```");
|
|
});
|
|
|
|
test("neighbouring turns from one side are joined and the room starts with the request", () => {
|
|
const turns = chatroomTurns({
|
|
messages: [
|
|
{ bot_id: 1, text: "Stray note." },
|
|
{ bot_id: 3, text: "Request." },
|
|
{ bot_id: 5, text: "Answer." },
|
|
{ bot_id: 1, text: "" },
|
|
],
|
|
coordinator_id: 1,
|
|
requester_id: 3,
|
|
names,
|
|
});
|
|
|
|
expect(turns).toHaveLength(1);
|
|
expect(turns[0]?.role).toBe("user");
|
|
expect(String(turns[0]?.content)).toContain("Request.");
|
|
expect(String(turns[0]?.content)).toContain("Answer.");
|
|
});
|
|
});
|