/** A speech segment boundary, separate from its text. Safe to import in server code. */ export declare const VOICE_TEXT_FLUSH: Readonly<{ type: 'voice-text-flush'; }>; export type VoiceReplyChunk = string | typeof VOICE_TEXT_FLUSH; export type VoiceOutcome = 'completed' | 'interrupted' | 'cancelled' | 'failed'; export interface VoiceTurnIdentity { /** The triggering user message ID, or a generated ID for speech without user input. */ turnId: string; /** Unique for each generation, including speculative attempts and retries. */ attemptId: string; } export interface VoiceToolTiming { toolCallId: string; toolName: string; /** Observed at the bridge, relative to generation start. Not server execution time. */ startedAtMs: number; durationMs?: number; } export interface VoiceGenerationMetrics extends VoiceTurnIdentity { version: 1; phase: 'generation'; outcome: VoiceOutcome; /** Unix epoch milliseconds, for trace correlation. Durations use a monotonic clock. */ startedAt: number; durationMs: number; /** First text sent toward TTS; can include tool-feedback filler. */ firstTextMs?: number; tools: VoiceToolTiming[]; } export interface VoiceSpeechMetrics { version: 1; phase: 'speech'; turnId: string; attemptId?: string; speechId: string; outcome: VoiceOutcome; measurement: 'server-playout'; /** Epoch milliseconds. Absent when LiveKit has no aligned timing. */ speechStartedAt?: number; speechEndedAt?: number; /** User speech end to first output audio. Includes filler; not browser receipt. */ firstAudioMs?: number; /** User speech end to completed output. Omitted for interrupted/cancelled/failed speech. */ completionMs?: number; } export type VoiceTurnMetrics = VoiceGenerationMetrics | VoiceSpeechMetrics; export type VoiceTurnMetricsHook = (metrics: VoiceTurnMetrics) => void | Promise; export interface VoiceSpeechResult extends VoiceSpeechMetrics { /** LiveKit's committed playback transcript, potentially partial or estimated. Not proof of hearing. */ playedText?: string; transcriptSource: 'livekit' | 'unavailable'; } export type VoiceSpeechCompleteHook = (result: VoiceSpeechResult) => void | Promise; /** Observer failures must never break speech or delay the audio path. */ export declare function notifyVoiceObserver(hook: ((value: T) => void | Promise) | undefined, value: T): void; export declare const VOICE_TURN_METADATA = "mastra.voice.turn"; export declare const VOICE_FLUSH_METADATA = "mastra.voice.flush"; /** Internal per-attempt clock; never mixes durations from different machines. */ export declare function createGenerationMetrics(identity: VoiceTurnIdentity, hook?: VoiceTurnMetricsHook): { text(): void; toolStart(tool: { toolCallId: string; toolName: string; }): void; toolEnd(id: string): void; end(outcome: VoiceOutcome): void; }; //# sourceMappingURL=turn-metrics.d.ts.map