import type { PipelineBus } from "./pipeline-bus.js"; import type { StartIdleTimeoutPacket, StopIdleTimeoutPacket } from "./packets.js"; import { type Scheduler } from "./scheduler.js"; export interface IdleTimeoutConfig { /** Base duration before triggering idle behavior (ms). Default: 15000 */ durationMs: number; /** * Number of consecutive timeouts before disconnecting. * 0 = never disconnect (just inject messages repeatedly). * Default: 3 */ maxConsecutive: number; /** * Messages to inject at each consecutive idle. * Index 0 = first timeout, index 1 = second timeout, etc. * If more timeouts occur than messages, the last message repeats. * Default: ["Are you still there?", "I'll end this call soon."] */ escalationMessages: string[]; /** * Whether to disconnect the session after maxConsecutive is reached. * If false, the maxConsecutive counter stops incrementing and the * last escalation message repeats indefinitely. * Default: true */ disconnectAfterMax: boolean; } export declare const DEFAULT_IDLE_TIMEOUT_CONFIG: IdleTimeoutConfig; export declare class IdleTimeoutManager { private timerScheduled; private count; private readonly config; private readonly bus; private currentContextId; private readonly scheduler; constructor(bus: PipelineBus, config?: Partial, scheduler?: Scheduler); /** Set the current turn context ID (used for injected message context). */ setContextId(id: string): void; /** Start (or restart) the idle timeout timer. */ start(): void; /** * Stop the idle timeout timer. * @param resetCount — If true, resets the consecutive idle counter. * Use true when the user actively engages (speaks or types). * Use false for system-driven stops (e.g., TTS still playing). */ stop(resetCount: boolean): void; /** * Extend the current timer by a duration (e.g., TTS audio playback time). * Stops the current timer and restarts with the remaining time + extension. */ extend(ms: number): void; /** Clean up — stop timer without side effects. */ dispose(): void; private clearTimer; /** * Resolve a non-empty context id for injected idle turns. If no turn context has been seen yet * (e.g. the idle timer fired before the first user turn completed), synthesize a stable one — * an empty contextId propagates downstream and is rejected by providers that validate it * (e.g. Cartesia TTS: "context_id must be alphanumeric/_/-"). */ private ensureContextId; private onTimeout; /** Handle a StartIdleTimeoutPacket from the bus. */ handleStart(pkt: StartIdleTimeoutPacket): void; /** Handle a StopIdleTimeoutPacket from the bus. */ handleStop(pkt: StopIdleTimeoutPacket): void; } //# sourceMappingURL=idle-timeout.d.ts.map