import type { Bot, InboxItem } from "@rakazo/contracts"; /** One item per pending ask message, waiting takeover run, or unread bot thread. */ export function inboxItemKey(item: InboxItem): string { switch (item.kind) { case "ask": case "approval": return `ask:${item.messageId}`; case "takeover": return `takeover:${item.runId}`; case "unread": return `unread:${item.bot.id}`; } } /** * Changes when a bot's run status, unread flag or newest message changes, which is when the * inbox may have changed. The shell already keeps these fresh. */ export function inboxRefreshSignal( bots: readonly Pick[], ): string { return bots.map((bot) => `${bot.id}:${bot.status}:${bot.unread}:${bot.preview}`).join("\n"); }