import type { LanguageModel } from 'ai'; import type { TurnHandle } from '../types/stream.js'; import type { UserInputContent } from '../runtime/userInput.js'; /** * Simulated-user evaluation: an LLM role-plays a customer persona against a * real runtime, and an LLM judge scores the resulting transcript against a * rubric. This is the pre-deploy gate that scripted turn assertions * (`EvalRunner`) cannot provide — scripted turns test the happy path you * thought of; simulated users find the conversations you didn't. */ export interface SimulatedUserPersona { /** Who the user is, e.g. "a busy parent in Colombo ordering a birthday cake". */ profile: string; /** What they are trying to accomplish — the goal the judge scores against. */ goal: string; /** Behavioral style, e.g. "impatient; sends short fragmented messages; switches topics". */ temperament?: string; /** First user message. Generated from the persona when omitted. */ openingMessage?: string; } export interface SimulatedTranscriptTurn { role: 'user' | 'assistant'; content: string; } export type SimulationEnd = 'goal-met' | 'user-gave-up' | 'max-turns'; export interface SimulationResult { transcript: SimulatedTranscriptTurn[]; turns: number; endedBy: SimulationEnd; sessionId: string; toolsCalled: string[]; escalated: boolean; } /** The runtime surface the simulator drives (satisfied by `Runtime`). */ export interface SimulatableRuntime { run(opts: { sessionId?: string; input?: UserInputContent; }): TurnHandle; } export interface SimulateConversationOptions { runtime: SimulatableRuntime; persona: SimulatedUserPersona; /** Model that plays the user. */ userModel: LanguageModel; /** Max user turns before the simulation stops. Default: 10. */ maxTurns?: number; sessionId?: string; } export declare function simulateConversation(options: SimulateConversationOptions): Promise; export interface JudgeDimension { key: string; description: string; } export declare const DEFAULT_JUDGE_DIMENSIONS: JudgeDimension[]; export interface JudgeVerdict { scores: Record; /** Mean of dimension scores, 1–5. */ overall: number; pass: boolean; summary: string; } export interface CreateJudgeOptions { model: LanguageModel; dimensions?: JudgeDimension[]; /** Minimum mean score (1–5) to pass. Default: 3.5. */ passThreshold?: number; /** Extra domain rules appended to the judge prompt. */ instructions?: string; } export interface ConversationJudge { judge(result: SimulationResult, persona: SimulatedUserPersona): Promise; } export declare function createJudge(options: CreateJudgeOptions): ConversationJudge; export interface SimulationScenario { name: string; persona: SimulatedUserPersona; maxTurns?: number; } export interface SimulationSuiteResult { scenarios: Array<{ name: string; result: SimulationResult; verdict: JudgeVerdict; }>; passed: boolean; passRate: number; } export interface RunSimulationSuiteOptions { runtime: SimulatableRuntime; scenarios: SimulationScenario[]; userModel: LanguageModel; judge: ConversationJudge; } /** Run every scenario and judge each transcript. `passed` is the CI gate. */ export declare function runSimulationSuite(options: RunSimulationSuiteOptions): Promise;