import type { VoiceCallConfig } from "../config.js"; import type { VoiceCallProvider } from "../providers/base.js"; import type { CallId, CallRecord } from "../types.js"; export type TranscriptWaiter = { resolve: (text: string) => void; reject: (err: Error) => void; timeout: NodeJS.Timeout; turnToken?: string; }; export type CallManagerRuntimeState = { activeCalls: Map; providerCallIdMap: Map; processedEventIds: Set; /** Provider call IDs we already sent a reject hangup for; avoids duplicate hangup calls. */ rejectedProviderCallIds: Set; }; export type CallManagerRuntimeDeps = { provider: VoiceCallProvider | null; config: VoiceCallConfig; storePath: string; webhookUrl: string | null; }; export type CallManagerTransientState = { activeTurnCalls: Set; transcriptWaiters: Map; maxDurationTimers: Map; }; export type CallManagerHooks = { /** Optional runtime hook invoked after an event transitions a call into answered state. */ onCallAnswered?: (call: CallRecord) => void; }; export type CallManagerContext = CallManagerRuntimeState & CallManagerRuntimeDeps & CallManagerTransientState & CallManagerHooks;