import type { AnswerCallRequest, CreateCallRequest, CreateCallResponse, DeleteRecordingRequest, DownloadRecordingRequest, EndCallRequest, GetCallRequest, JoinConferenceRequest, ListPhoneNumbersRequest, SendMessageRequest, StartRecordingRequest, StopRecordingRequest, TelephonyCallDetails, TelephonyConferenceJoin, TelephonyMessage, TelephonyRecording, TelephonyRecordingAudio, TelephonyRecordingStarted, TelephonyTransfer, TransferCallRequest, TelephonyConfig, TelephonyMediaStreamEvent, TelephonyOutboundAudioMessage, TelephonyPhoneNumber, TelephonyProvider, TelephonyResponseRequest, TelephonyStatusCallback, TelephonyWebhookResponse, TelephonyWebhookValidationRequest, UpdatePhoneNumberRequest, EndGatherRequest, TelephonyGatherResult } from '../types/telephony.js'; import { type FamilyRuntime } from '../ops/family-telemetry.js'; /** * Routes telephony operations to registered providers: the one a request names, the configured * default, or the first that supports the operation. */ export declare class TelephonyManager { private config; private providers; private readonly telemetry; /** Text messages are a family of their own, so a budget or a rate limit can hold them apart from calls. */ private readonly messaging; constructor(config?: TelephonyConfig, runtime?: FamilyRuntime); /** Registers a provider under a name. Returns the manager, for chaining. */ registerProvider(name: string, provider: TelephonyProvider): this; /** Whether a provider is registered. */ hasProvider(name: string): boolean; /** Every registered provider's name. */ listProviders(): string[]; /** Places an outbound call. */ createCall(request: CreateCallRequest): Promise; /** Builds a webhook response, such as TwiML. */ createWebhookResponse(request: TelephonyResponseRequest): Promise; /** Validates a webhook's signature. */ validateWebhook(request: TelephonyWebhookValidationRequest): Promise; /** Reads a call's details. */ getCall(request: GetCallRequest): Promise; /** Ends a call in progress. */ endCall(request: EndCallRequest): Promise; /** Parses a status callback through the named provider. */ parseStatusCallback(providerName: string, body: string | URLSearchParams | Record): TelephonyStatusCallback | undefined; /** Lists phone numbers. */ listPhoneNumbers(request?: ListPhoneNumbersRequest): Promise; /** Changes where a phone number sends its calls. */ updatePhoneNumber(request: UpdatePhoneNumberRequest): Promise; /** * Answers a call webhook, the same way on every provider: on one answered with markup, such as * Twilio, it renders the response the webhook returns; on one controlled by command, such as * Telnyx, it runs the response as the call's commands, and the webhook returns an empty body. * Either way, return what it resolves to from the webhook. */ answer(request: AnswerCallRequest): Promise; /** Moves a call to another number or SIP address. */ transferCall(request: TransferCallRequest): Promise; /** Puts a call into a conference, created by the first call to join it. */ joinConference(request: JoinConferenceRequest): Promise; /** Starts recording a call. The provider reports the recording once it is ready. */ startRecording(request: StartRecordingRequest): Promise; /** Stops recording a call. */ stopRecording(request: StopRecordingRequest): Promise; /** Parses what a gather collected, speech or keys, through the named provider. */ parseGatherResult(providerName: string, body: string | URLSearchParams | Record): TelephonyGatherResult | undefined; /** * Stops a gather still listening. On a provider whose gather ends by itself, such as Twilio's, * there is nothing to stop, and this resolves at once. */ endGather(request: EndGatherRequest): Promise; /** Parses a finished recording's callback through the named provider. */ parseRecordingCallback(providerName: string, body: string | URLSearchParams | Record): TelephonyRecording | undefined; /** Fetches a recording's audio from the provider that made it. */ downloadRecording(request: DownloadRecordingRequest): Promise; /** Deletes a recording at the provider. */ deleteRecording(request: DeleteRecordingRequest): Promise; /** * Sends a text message: an SMS, or an MMS with media. It runs through the client's lifecycle as a * `messaging` operation, so it is authorized, rate-limited, and audited apart from calls. */ sendMessage(request: SendMessageRequest): Promise; /** Parses a messaging webhook through the named provider: a message received, or a delivery change. */ parseMessageWebhook(providerName: string, body: string | URLSearchParams | Record): TelephonyMessage | undefined; /** Parses a media-stream message through the named provider. */ parseMediaStreamEvent(providerName: string, message: string | Record): TelephonyMediaStreamEvent | undefined; /** Formats outbound audio, a mark, or a clear as the named provider's media-stream message. */ formatAudioMessage(providerName: string, streamId: string, payload: string, options?: { event?: 'media' | 'mark' | 'clear'; markName?: string; }): TelephonyOutboundAudioMessage; /** * Runs one provider API call through the client's lifecycle, wrapping a provider's own error so the * caller always sees a `TelephonyProviderError`. */ private call; private resolveProvider; }