Something went wrong. Try again.
small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546import type { HistoryEntry, Session } from '../api';
export type AgentBubbleRole = 'subagent' | 'agent';
type MailUserBlock = { mail?: { senderId: string | null; external: boolean; answer: boolean; } | null; turnType?: HistoryEntry['turn_type'];};
/** * Classifies a `user` block for chat bubble placement and tinting: null for * the person or non-agent triggers, `'subagent'` for a descendant of this * session, or `'agent'` for a sibling, parent, or other agent. */export function agentBubbleRole( block: MailUserBlock, sessionId: string, knownSessions: ReadonlyMap<string, Session>,): AgentBubbleRole | null { const mail = block.mail; if (mail?.external) return null; if (!mail && block.turnType !== 'agent') return null;
if (mail?.answer) return 'subagent';
const senderId = mail?.senderId; if (!senderId) return 'agent'; const sender = knownSessions.get(senderId); if (!sender) return 'agent';
const seen = new Set<string>([sender.id]); let parentId = sender.parent_id; while (parentId) { if (parentId === sessionId) return 'subagent'; if (seen.has(parentId)) break; seen.add(parentId); parentId = knownSessions.get(parentId)?.parent_id ?? null; }
return 'agent';}