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]>
23 lines
614 B
TypeScript
23 lines
614 B
TypeScript
import BunSQLite from "@moduletrace/bun-sqlite";
|
|
|
|
type Params = {
|
|
session_id?: number | string | null;
|
|
};
|
|
|
|
/**
|
|
* The chatroom a session is a bot's part of, or null for an ordinary
|
|
* session.
|
|
*/
|
|
export default async function grabSessionChatroomId({ session_id }: Params) {
|
|
if (!session_id) return null;
|
|
|
|
const chatroom_id = (
|
|
await BunSQLite.sql<{ chatroom_id: number | null }>({
|
|
sql: `SELECT chatroom_id FROM bot_sessions WHERE id = ? LIMIT 1`,
|
|
values: [session_id],
|
|
})
|
|
).payload?.[0]?.chatroom_id;
|
|
|
|
return chatroom_id ? Number(chatroom_id) : null;
|
|
}
|