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]>
24 lines
824 B
TypeScript
24 lines
824 B
TypeScript
import BunSQLite from "@moduletrace/bun-sqlite";
|
|
import type { BUN_SQLITE_COBBLE_BOT_MESSAGES } from "@/db/types/db";
|
|
|
|
type Params = {
|
|
chatroom_id: number | string;
|
|
};
|
|
|
|
/**
|
|
* Every message in a chatroom, from every bot in it, oldest first. Rooms
|
|
* are short (the coordinator's turns are capped), so they're read whole.
|
|
*/
|
|
export default async function grabChatroomMessages({ chatroom_id }: Params): Promise<BUN_SQLITE_COBBLE_BOT_MESSAGES[]> {
|
|
return (
|
|
(
|
|
await BunSQLite.sql<BUN_SQLITE_COBBLE_BOT_MESSAGES>({
|
|
sql: `SELECT m.* FROM bot_messages m JOIN bot_sessions s ON s.id = m.session_id
|
|
WHERE s.chatroom_id = ?
|
|
ORDER BY m.created_at ASC, m.id ASC`,
|
|
values: [chatroom_id],
|
|
})
|
|
).payload || []
|
|
);
|
|
}
|