/** * Agent identity palette: a stable display name + accent color per agent. * * Identity colors answer "who is speaking" only (avatar / name / bubble * tint) — they never express task status (spec v2 §3.6). The curated set * reuses the spec §3.6 avatar five-color family plus one neutral slate, so * no tailwind rainbow hues leak into the fusion palette; the default * main-loop agent is neutral `--text-2` slate. */ export const DEFAULT_AGENT_NAME = 'Calliope'; // Fixed identity map (keyed by the raw agent_name the backend emits). const IDENTITIES: Record = { planner: { label: 'Planner', color: '#5b8def' }, // avatar-2 blue 'story-agent': { label: 'Story Agent', color: '#3fb97f' }, // avatar-3 green 'script-agent': { label: 'Script Agent', color: '#e8a33d' }, // avatar-1 amber 'assets-agent': { label: 'Assets Agent', color: '#b98be0' }, // avatar-4 violet 'video-agent': { label: 'Video Agent', color: '#d98e6a' }, // avatar-5 clay 'research-agent': { label: 'Research Agent', color: '#8fa3c8' }, // neutral slate // The five named agents (HEL-613) — the runner stamps their zh names on // named-session replies; colors mirror the spec §2.1 avatar five-set. 剧本创作: { label: '剧本创作', color: '#e8a33d' }, 视觉设计: { label: '视觉设计', color: '#5b8def' }, 分镜设计: { label: '分镜设计', color: '#3fb97f' }, 素材资产: { label: '素材资产', color: '#b98be0' }, 镜头脚本: { label: '镜头脚本', color: '#d98e6a' }, }; // Fallback palette for unknown names (stable hash → deterministic color), // narrowed to the avatar identity family + neutral slate (spec v2 §十.4). const FALLBACK_COLORS = ['#5b8def', '#3fb97f', '#e8a33d', '#b98be0', '#d98e6a', '#8fa3c8']; function hashString(s: string): number { let h = 0; for (let i = 0; i < s.length; i++) { h = (h * 31 + s.charCodeAt(i)) >>> 0; } return h; } /** Neutral slate (--text-2) — the default agent borrows no signal color. */ export const DEFAULT_AGENT_COLOR = '#aab2c5'; export function agentDisplayName(name: string | null | undefined): string { const key = (name || '').trim().toLowerCase(); if (!key) return DEFAULT_AGENT_NAME; return IDENTITIES[key]?.label ?? prettyName(name!); } export function agentColor(name: string | null | undefined): string { const key = (name || '').trim().toLowerCase(); if (!key) return DEFAULT_AGENT_COLOR; const identity = IDENTITIES[key]; if (identity) return identity.color; return FALLBACK_COLORS[hashString(key) % FALLBACK_COLORS.length]; } function prettyName(raw: string): string { // "story-agent" → "Story Agent", "assets-agent" → "Assets Agent" const title = raw .split(/[-_\s]+/) .filter(Boolean) .map((w) => w.charAt(0).toUpperCase() + w.slice(1)) .join(' '); return title || DEFAULT_AGENT_NAME; }