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]>
26 lines
949 B
TypeScript
26 lines
949 B
TypeScript
import { grabChatroomKeepDays, grabChatroomMaxPerPlace } from "../app-settings/grab-chatroom-retention";
|
|
import deleteChatroomRows from "./delete-chatroom-rows";
|
|
import pruneChatroomsSql from "./prune-chatrooms-sql";
|
|
|
|
type Params = {
|
|
/**
|
|
* Only this place: a workspace, or (null) bots' own chats. Left out,
|
|
* every place.
|
|
*/
|
|
workspace_id?: number | null;
|
|
};
|
|
|
|
/**
|
|
* Deletes the rooms past the install's retention (`pruneChatroomsSql`):
|
|
* closed rooms older than `grabChatroomKeepDays`, and the oldest closed
|
|
* ones once a place holds more than `grabChatroomMaxPerPlace`. Returns the
|
|
* ids deleted.
|
|
*/
|
|
export default async function pruneChatrooms({ workspace_id }: Params = {}) {
|
|
const cutoff = Date.now() - (await grabChatroomKeepDays()) * 24 * 60 * 60 * 1000;
|
|
|
|
return await deleteChatroomRows({
|
|
rooms: pruneChatroomsSql({ cutoff, max_per_place: await grabChatroomMaxPerPlace(), workspace_id }),
|
|
});
|
|
}
|