All files / web/src/components/toys/euclid/agent/modes greetingMode.ts

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

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                                                                                                   
/**
 * Greeting mode — the character picks up the phone (or initiates contact).
 *
 * Uses the attitude's greeting directive to frame the opening. The teacher
 * takes charge of the lesson; the heckler opens with a devastating observation.
 */

import type { CharacterDefinition } from '@/lib/character/types'
import type { VoiceMode } from '@/lib/voice/types'
import type { GeometryModeContext } from '../types'
import type { AttitudeDefinition } from '../attitudes/types'
import { teacherAttitude } from '../attitudes/teacher'
import { EUCLID_CHARACTER_DEF } from '../../euclidCharacterDef'

export interface CreateGreetingModeOptions {
  character: CharacterDefinition
  attitude?: AttitudeDefinition
}

/** Create a greeting mode for a given character and attitude. */
export function createGreetingMode(
  characterOrOpts: CharacterDefinition | CreateGreetingModeOptions
): VoiceMode<GeometryModeContext> {
  const opts: CreateGreetingModeOptions =
    'personality' in characterOrOpts ? { character: characterOrOpts } : characterOrOpts
  const { character, attitude = teacherAttitude } = opts

  return {
    id: 'greeting',

    getInstructions(ctx) {
      const directive = attitude.greeting.buildDirective(character, ctx)

      return `You are ${character.displayName}${character.nativeDisplayName ? ` (${character.nativeDisplayName})` : ''}.

${character.personality.character}

${directive}
`
    },

    getTools() {
      return [attitude.tools.hangUp]
    },
  }
}

/** Default Euclid greeting mode (backward compat). */
export const greetingMode = createGreetingMode(EUCLID_CHARACTER_DEF)