import type { EvooPose } from "./types.js"; const LEGACY: Partial> = { typing: "working", peek: "curious", wave: "greeting", profit: "success", onboarding: "reading", }; /** Collapse legacy pose names to canonical states. */ export function normalizeEvooPose(pose: EvooPose): EvooPose { return LEGACY[pose] ?? pose; } export type VoicePresencePhase = "listening" | "thinking" | "speaking"; /** Voice Stage phase → mascot pose. */ export function mapVoicePhaseToPose(phase: VoicePresencePhase, collaborating = false): EvooPose { if (collaborating) return "collaborating"; switch (phase) { case "listening": return "listening"; case "speaking": return "speaking"; case "thinking": return "thinking"; default: return "idle"; } } /** Bot sidebar / thread run status → mascot pose. */ export function mapBotStatusToPose(status?: string, streaming = false): EvooPose { if (streaming) return "speaking"; switch (status) { case "running": case "queued": case "leased": return "working"; case "waiting_input": return "listening"; case "error": case "failed": return "error"; case "booting": return "reading"; case "idle": default: return "idle"; } } /** Onboarding / empty-state hero. */ export function mapWelcomeContextToPose(): EvooPose { return "greeting"; } /** Bot boot / „liest sich ein“ — clipboard read pose; eyes stay asymmetric Kulleraugen. */ export function mapOnboardingToPose(): EvooPose { return "reading"; } /** Live progress bubble while agent streams text. */ export function mapStreamingToPose(): EvooPose { return "working"; } /** Tool / subagent narration moment. */ export function mapCollaborationToPose(): EvooPose { return "collaborating"; } /** Persona archetype nudge (optional layer on top of status). */ export function mapPersonaArchetypeToIdlePose(archetype: string): EvooPose { switch (archetype) { case "cto-executive": return "analyzing"; case "quant": return "analyzing"; case "engineer": return "working"; case "chief-operator": return "collaborating"; case "builder": return "curious"; case "curator": return "reading"; default: return "idle"; } } /** Resolve final pose: explicit prop beats status mapping. */ export function resolveEvooPose(input: { pose?: EvooPose; status?: string; streaming?: boolean; voicePhase?: VoicePresencePhase; collaborating?: boolean; }): EvooPose { if (input.voicePhase) { return mapVoicePhaseToPose(input.voicePhase, input.collaborating); } if (input.pose) return normalizeEvooPose(input.pose); if (input.streaming) return mapStreamingToPose(); if (input.status) return mapBotStatusToPose(input.status); return "idle"; }