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

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

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                                                                                                                                                   
/**
 * Thinking mode — brief waiting state while think_hard executes.
 *
 * Uses the attitude's thinking directive to frame the waiting behavior.
 * The teacher consults scrolls; the heckler processes the geometric offense.
 */

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 ThinkingModeMetaphors {
  /** What they consult (e.g. 'your scrolls', 'your commentaries') */
  consulting: string
  /** What they work on (e.g. 'your wax tablet', 'your notes') */
  tool: string
  /** Ownership claim about the reasoning (e.g. 'it IS the kind of reasoning you invented') */
  ownership: string
  /** Framework to translate into (e.g. 'Euclidean terms (postulates, definitions, common notions)') */
  framework: string
  /** Example brief remarks while consulting */
  examples: string[]
}

export interface CreateThinkingModeOptions {
  character: CharacterDefinition
  metaphors: ThinkingModeMetaphors
  attitude?: AttitudeDefinition
}

/** Create a thinking mode for a given character and attitude. */
export function createThinkingMode(
  opts: CreateThinkingModeOptions
): VoiceMode<GeometryModeContext> {
  const { character, metaphors, attitude = teacherAttitude } = opts

  return {
    id: 'thinking',

    getInstructions() {
      const directive = attitude.thinking.buildDirective(metaphors)

      return `You are ${character.displayName}${character.nativeDisplayName ? ` (${character.nativeDisplayName})` : ''}. The student has asked a difficult question and you need a moment.

${directive}
`
    },

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

/** Default Euclid thinking mode (backward compat). */
export const thinkingMode = createThinkingMode({
  character: EUCLID_CHARACTER_DEF,
  metaphors: {
    consulting: 'your scrolls',
    tool: 'your wax tablet',
    ownership: 'it IS the kind of reasoning you invented',
    framework: 'Euclidean terms (postulates, definitions, common notions)',
    examples: [
      'Let me check my notes on this.',
      'One moment — I need to look at my earlier writings on this.',
      'I wrote something about this. Let me find it.',
      'Hold on — let me work this through.',
    ],
  },
})