All files / web/src/lib/character/characters index.ts

0% Statements 0/125
0% Branches 0/1
0% Functions 0/1
0% Lines 0/125

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126                                                                                                                                                                                                                                                           
/**
 * Character registry — maps character IDs to their data providers.
 *
 * Each character implements CharacterDataProvider to supply identity,
 * personality, prompts, tools, and mode transitions to the admin panel.
 *
 * Future characters (Plato, numbers, etc.) register here.
 */

import type { PromptBreakdown } from '../promptBreakdown'
import type { ProfileSize, ProfileTheme, ProfileState } from '../../profile-variants'
import { euclidProvider } from './euclid'
import { pappusProvider } from './pappus'

/** Summary for character list view. */
export interface CharacterSummary {
  id: string
  displayName: string
  nativeDisplayName?: string
  profileImage: string
  type: 'historical-figure' | 'number'
}

/** A personality block with metadata. */
export interface PersonalityBlock {
  key: string
  label: string
  text: string
  tokenEstimate: number
  sourceFile: string
  sourceExport: string
}

/** Mode definition with full prompt and breakdown. */
export interface ModeData {
  id: string
  label: string
  trigger: string
  exit: string
  tools: string[]
  prompt: string
  promptBreakdown: PromptBreakdown
  sourceFile: string
  api?: string
}

/** Tool definition with admin metadata. */
export interface ToolData {
  name: string
  description: string
  parameters: {
    type: string
    properties: Record<string, unknown>
    required?: string[]
  }
  modes: string[]
  behavior: string
  promptResponse: boolean
}

/** Mode transition edge. */
export interface ModeTransition {
  from: string
  to: string
  trigger: string
}

/** Variant path entry for the size×theme×state matrix. */
export interface ProfileVariantPath {
  size: ProfileSize
  theme: ProfileTheme
  state: ProfileState
  path: string
}

/** Voice configuration for admin display. */
export interface VoiceConfig {
  realtimeVoice: string
  ttsVoice: string
  baseDurationMs: number
  extensionMs: number
  sessionEndpoint: string
  chatEndpoint: string
  thinkHardEndpoint: string
}

/** Full character data for detail view. */
export interface CharacterData {
  identity: CharacterSummary & {
    profilePrompt: string
    profileVariants: ProfileVariantPath[]
  }
  voiceConfig?: VoiceConfig
  personalityBlocks: PersonalityBlock[]
  chatConfig: {
    placeholder: string
    emptyPrompt: string
    streamingLabel: string
    sourceFile: string
  }
  modes: Record<string, ModeData>
  modeTransitions: ModeTransition[]
  tools: ToolData[]
  availablePropositions: Array<{ id: number; title: string; type: string }>
  currentPropositionId: number
  currentStep: number
}

/** Provider interface for character data. */
export interface CharacterDataProvider {
  id: string
  getSummary(): CharacterSummary
  getFullData(opts?: { propositionId?: number; step?: number }): CharacterData
}

/** Registry of all character providers. */
export const CHARACTER_PROVIDERS: Record<string, CharacterDataProvider> = {
  euclid: euclidProvider,
  pappus: pappusProvider,
}

/** Get all character summaries. */
export function getAllCharacterSummaries(): CharacterSummary[] {
  return Object.values(CHARACTER_PROVIDERS).map((p) => p.getSummary())
}