All files / web/src/components/toys/number-line/talkToNumber/sessionModes index.ts

83.33% Statements 45/54
100% Branches 0/0
0% Functions 0/1
83.33% Lines 45/54

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 551x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x                   1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
/**
 * Session mode registry and resolver.
 *
 * All modes are registered here. resolveMode() returns both instructions
 * and tools for a given mode + context, ready to send via session.update.
 */
 
export type { ModeId, ModeContext, RealtimeTool, AgentMode, SessionActivity } from './types'
 
import type { ModeId, ModeContext, AgentMode, RealtimeTool } from './types'
import { answeringMode } from './answeringMode'
import { familiarizingMode } from './familiarizingMode'
import { defaultMode } from './defaultMode'
import { conferenceMode } from './conferenceMode'
import { explorationMode } from './explorationMode'
import { gameMode } from './gameMode'
import { windingDownMode } from './windingDownMode'
import { farewellMode } from './farewellMode'
import { hangingUpMode } from './hangingUpMode'
 
export const MODE_MAP: Record<ModeId, AgentMode> = {
  answering: answeringMode,
  familiarizing: familiarizingMode,
  default: defaultMode,
  conference: conferenceMode,
  exploration: explorationMode,
  game: gameMode,
  winding_down: windingDownMode,
  farewell: farewellMode,
  hanging_up: hangingUpMode,
}
 
/** Resolve a mode's instructions and tools for the given context. */
export function resolveMode(
  modeId: ModeId,
  ctx: ModeContext
): { instructions: string; tools: RealtimeTool[] } {
  const mode = MODE_MAP[modeId]
  return {
    instructions: mode.getInstructions(ctx),
    tools: mode.getTools(ctx),
  }
}
 
// Re-export individual modes for direct access
export { answeringMode } from './answeringMode'
export { familiarizingMode } from './familiarizingMode'
export { defaultMode } from './defaultMode'
export { conferenceMode } from './conferenceMode'
export { explorationMode } from './explorationMode'
export { gameMode } from './gameMode'
export { windingDownMode } from './windingDownMode'
export { farewellMode } from './farewellMode'
export { hangingUpMode } from './hangingUpMode'