declare enum PostSessionStatus { WAITING = "waiting", READY = "ready", IN_PROGRESS = "in_progress", FINISHED = "finished" } declare enum CheckInStatus { CONFIRMED = "confirmed", EXITED = "exited", PENDING = "pending", REQUESTED = "requested", SKIPPED = "skipped", TIMED_OUT = "timed_out" } declare enum ProviderType { UJET = "ujet_conversations", TWILIO = "twilio_conversations", NEXMO = "nexmo_conversations", MOCK = "mock" } /** * Stable identifiers for the channel.type values returned in MenuChannel. * Use these constants rather than raw string literals so renames are safe. */ declare enum ChannelType { INBOUND_CALL = "inbound_call", VOICEMAIL = "voicemail" } /** * Chat wire-protocol vocabulary shared by every provider. Values are the * strings on the wire — the server and the agent app match them verbatim. */ declare enum MessageType { TEXT = "text", NOTI = "noti", SERVER_MESSAGE = "server_message", TYPING = "typing", PREVIEW = "preview", TRANSLATION_UPDATE = "translation_update" } /** `event` values carried by a `noti` message. */ declare enum NotiEvent { MEMBER_JOINED = "memberJoined", MEMBER_LEFT = "memberLeft", CHAT_ENDED = "chatEnded", CHAT_DISMISSED = "chatDismissed", TASK_VA_STARTED = "taskVaStarted", TASK_VA_FINISHED = "taskVaFinished", TASK_VA_FAILED = "taskVaFailed", ESCALATION_STARTED = "escalationStarted", ESCALATION_ACCEPTED = "escalationAccepted", ESCALATION_FAILED = "escalationFailed", CHECK_IN_REQUIRED = "checkInRequired", CHECK_IN_TIMED_OUT = "checkInTimedOut", COBROWSE_REQUESTED_FROM_AGENT = "cobrowseRequestedFromAgent", COBROWSE_REQUESTED_FROM_END_USER = "cobrowseRequestedFromEndUser" } /** Participant kinds — the prefix of a `-` identity and the `$userType` of a message. */ declare enum UserType { END_USER = "end_user", USER = "user", VIRTUAL_AGENT = "virtual_agent", SYSTEM = "system" } declare function toIdentity(userType: UserType, id: number | string): string; interface LanguageOption { lang: string; name: string; localeName?: string; } interface CompanyResponse { name: string; subdomain: string; support_email: string; languages: LanguageOption[]; action_tracking: boolean; email_transcripts: boolean; message_preview: boolean; email_enhancement: boolean; display_history: boolean; use_recording: boolean; use_web: boolean; cobrowse_domain?: string; } interface MenuChannel { enabled: boolean; type: string; menu_id: number; collect_email: boolean; recording_option?: RecordingOption; deflected?: boolean; deflection_type?: string; [key: string]: unknown; } interface MenuItem { id: number; name?: string; enabled: boolean; redirection?: { option: string; data: string; }; children?: MenuItem[]; channels: MenuChannel[]; deflection?: { enabled: boolean; type: string; }; hidden: boolean; } interface MenuResponse { menus: MenuItem[]; direct: { key: boolean; user: boolean; key_id: number | null; }; } interface WaitTimeResponse { chat: number; voice_call: number; } interface HumanAgent { id: number; name: string; avatar_url: string; first_name: string; last_name: string; status?: string; } interface VirtualAgent { id: number; name: string; avatar_url: string; status?: string; } interface ChatResponse { id: number; lang: string; status: string; status_text: string; created_at: string; features: string[]; menus: { id: number; name: string; }[]; provider_type: string; csat_settings: { enabled: boolean; feedback_enabled: boolean; }; survey_enabled: boolean; region?: string; provider_channel_id?: string; transcript_requested_count?: number; agent?: HumanAgent; virtual_agent?: VirtualAgent; external_agent?: VirtualAgent; all_agents: HumanAgent[]; all_virtual_agents: VirtualAgent[]; redaction_enabled: boolean; agent_incoming_ha_enabled: boolean; end_user?: { id: number; identifier?: string | null; }; post_session_required?: boolean; post_session_opt_in_required?: boolean; post_session_transfer_status?: string; check_in_status?: CheckInStatus; /** Whether a task virtual agent is active on the chat; only on the single-chat read, and absent on older servers. */ task_virtual_agent_active?: boolean | undefined; } interface CallApiResponse { created_at: string; id: number; lang: string; selected_menu: { id: number; }; menus: { id: number; name: string; }[]; recording_permitted: boolean; scheduled_at?: string; status: string; survey_enabled: boolean; type: string; } interface CallResponse extends Omit { menu_id: number; } interface EmailResponse { attachment_count: number; id: number; fail_reason: string; status: string; type: string; } interface FileTypeItem { description: string; extension: string; } interface GenerateTranscriptResponse { chat_transcript_id: number; status: string; } interface ChatDocumentItem { media_id: number; url: string; } /** Attachment pairing key: a provider-assigned sequence number, or a `{type}-{media_id}` string. */ type AttachmentKey = number | string; /** @deprecated Renamed — use {@link AttachmentKey}. */ type MediaIndex = AttachmentKey; interface MessageResponse { $index: AttachmentKey; $sid: string; $timestamp: Date; $userId: number; $userType: string; buttons?: { title: string; }[]; content?: string; document?: { url: string; }; event?: string; file?: File; groupMessageId?: number; media_id?: number; message?: { messages: string[]; type: any; }; server_message_id?: number; title?: string; type: string; unredacted?: string; client_message_id?: string | undefined; redaction_ref?: number | undefined; signature?: string; form?: { id: number; form_type: string; name: string; title: string; subtitle: string; external_form_id: string; smart_action_id: number; image: string; }; visible?: boolean; reason?: string; [key: string]: unknown; } /** GET /chats/:id/messages/:redaction_ref/original — only the requester's own messages resolve. */ interface ChatMessageOriginalResponse { redaction_ref: number; content: string; type: string; media_id?: number | undefined; } interface PdfStatusResponse { body?: File; failed_reason?: string; status: string; } interface ChatTaskMessageResponse { content: any; id: number; participant_id: number; task_va_id: number; } interface ChatHistoryItem { assigned_at: string; comm_id: number; comm_type: string; entries: MessageResponse[]; timezone: string; [key: string]: unknown; } interface ChatHistoryResponse { chats: ChatHistoryItem[]; missing_chat_ids: number[]; pagination: { next_page: number; per_page: number; }; } interface UserProfile { email?: string; identifier?: string; name?: string; } interface TriggerMessage { lang: string; text: string; } interface TriggerItem { id: number; keywords_excluded?: string[]; keywords_excluded_or?: string[][]; keywords_included?: string[]; keywords_included_or?: string[][]; lang?: string; menu_id: number; messages: TriggerMessage[]; page_visit_count: number; stay_time: number; visitor_type: string; } interface ChatSurveyResponse { id?: number; lang?: string; questions: QuestionItem[]; sign_off_display_text: string; } interface QuestionItem { display_text: string; id: number; is_csat?: boolean; name?: string; position?: number; type: 'csat' | 'star' | 'free-form' | 'scale' | 'enumeration'; valid_answers?: { key: string; value: string; }[]; } interface ChatDeflectionResponse { email: boolean; enabled: boolean; external_deflection_links: { enabled: boolean; ids: number[]; }; keep_waiting: boolean; threshold: number; } interface ChatDeflectionResponse { enabled: boolean; threshold: number; email: boolean; keep_waiting: boolean; external_deflection_links: { enabled: boolean; ids: number[]; }; } interface CheckInResponse { chat_id: number; check_in_status: CheckInStatus; check_in_at?: string; } interface ChatMessageResponse { content: string; timestamp: string; } interface ServerAuthResponse { error?: number; message?: any; auth_token?: string; log_proxy_auth_token?: string; log_proxy_url?: string; } interface FeatureFlagsResponse { 'advanced-call-scheduling': boolean; 'consumer-agent-pdf'?: boolean; 'web-sdk-instant-voice'?: boolean; } type RecordingPermission = 'recording_permission_not_asked' | 'recording_permission_granted' | 'recording_permission_denied'; type RecordingOption = 'record_never' | 'record_always' | 'record_ask_user'; type ServerVoiceCallStatus = 'scheduled' | 'queued' | 'assigned' | 'connecting' | 'connected' | 'va_assigned' | 'va_connected' | 'reconnecting' | 'switching' | 'voicemail' | 'finished' | 'failed' | 'recovered' | 'canceled' | 'timeout'; type VoiceCallStatus = 'idle' | 'queued' | 'connecting' | 'connected' | 'interrupted' | 'ended' | 'error'; /** The set of smart-action types the server can request. */ type SmartActionType = 'text' | 'verification' | 'photo' | 'screenshot' | 'video' | 'cobrowse'; /** * Media smart-action subtypes — the three `SmartActionType` values that * route through `client.voiceCall.uploadMediaForSmartAction` (versus text / * verification / cobrowse). Exported so consumers passing the media type * along — for example dialog components that branch on the smart action — * can use the union without re-declaring it. */ type SmartActionMediaType = 'photo' | 'screenshot' | 'video'; interface SmartActionResponse { id: number; type: SmartActionType; sub_type?: string; status: string; number_of_photos?: number | null; } interface VoiceCallResponse { id: number; status: ServerVoiceCallStatus; type: 'WebInboundCall'; features: string[]; region?: string; created_at: string; fail_reason: string | null; csat_settings: { enabled: boolean; post_in_crm: boolean; feedback_enabled: boolean; time_to_leave_feedback: number; webhook_url: string | null; }; recording_permitted: boolean; survey_enabled: boolean; agent: HumanAgent | null; virtual_agent: VirtualAgent | null; participants: HumanAgent[]; smart_actions?: SmartActionResponse[]; recording_permission?: RecordingPermission; recording_option?: RecordingOption; wait_estimation?: number; lang: string; menus: { id: number; name: string; }[]; selected_menu: { id: number; name: string; }; custom_data?: Record; } interface RequestReturn { headers: Record; data: any; } interface LogData { loglevel: string; timestamp: string; application: string; sdk_version: string; device_uuid: string; tenant: string; company_id: string; location_url: string; channel: string; message: string; data: any; tracker_id?: string; } interface LogHistoryData { date: string; channel: string; level: string; args: any[]; } interface ClientEvent { name: string; payload: { lang: string; menu_id: number; [key: string]: unknown; }; } interface MessageRequest { type: string; content?: string; [key: string]: unknown; } interface ChatRequest { lang?: string; trigger_id?: string; ticket_id?: string; email?: string; greeting?: string; cobrowsable?: boolean; custom_data?: { signed?: string; unsigned?: Record; }; } interface MenusRoutingInputs { initialMessage?: string | undefined; customData?: Record | undefined; signedCustomData?: string | undefined; } interface EscalateRequest { force_escalate: boolean; menu_id: number; lang: string; } interface CobrowseRequest { code: string; from: string; nonce: string; } interface RateRequest { rating: number; feedback: string; } interface SurveyAnswers { [id: string]: number | string; } interface ChatEndUserEventRequest { event: { name: string; payload: Record; }; end_user_name?: string; } interface CallRequest { phone_number: string; lang?: string; scheduled_at?: string; ticket_id?: string; email?: string; recording_permission?: RecordingPermission; custom_data?: { signed?: string; unsigned?: Record; }; reschedule_call_id?: number; } interface EmailRequest { name?: string; email: string; content: string; lang?: string; files?: File[]; recaptcha?: string; } interface FormData { signature: string; data: { smart_action_id: number; id: number; uri: string; }; } interface ChatMessageRequest { message: { content: string; timestamp: string; client_message_id?: string | undefined; }; } interface CheckInVisibilityStateRequest { widget_minimized?: boolean; tab_inactive?: boolean; } interface CheckInModalStateRequest { modal_type: 'check_in'; } interface GetTimeSlotsRequest { lang?: string; rescheduleCallId?: number; } interface CustomFormPayload { smart_action_id: number; form_response: { question_id: number; value: string | string[] | boolean; }[]; } interface VoiceCallRequest { lang?: string; ticket_id?: string; email?: string; recording_permission?: RecordingPermission; custom_data?: { signed?: string; unsigned?: Record; }; cobrowsable?: boolean; voicemail_reason?: string; } type RequestMethod = (url: string, options: RequestInit | Record) => Promise; type EventHandler = (data: any) => void; type IssueChatTokenMethod = () => Promise<{ identity: string; token: string; }>; type LoggerHandler = (channel: string, level: string, ...args: any[]) => void; type GetServerMessage = (chatId: number, messageId: number) => Promise; interface TokenResponse { token: string; } interface ClientOption { companyId: string; authenticate: () => Promise; tenant?: string; host?: string; lang?: string; bridge?: string; version?: string; cobrowse?: CobrowseOption; [key: string]: unknown; } interface ConnectOption { companyId: string; location: string; host: string; version: string; lang: string; cobrowse: boolean; bridge: string; bridgeOrigin: string; modules: string[]; } interface ConnectRequest { type: string; callbackId?: string; data?: any; } interface ConnectResult { type?: string; result?: any; } interface ConnectCallback { type: string; request: string; callbackId?: string; result?: any; error?: any; } interface CobrowseMessages { confirmSessionTitle: string; confirmSessionContent: string; confirmRemoteControlTitle: string; confirmRemoteControlContent: string; confirmFullDeviceTitle: string; confirmFullDeviceContent: string; allowText: string; denyText: string; endSessionText: string; } interface CobrowseOption { enabled?: boolean; lang?: string; messages?: CobrowseMessages; root?: Element; api?: string; license?: string; trustedOrigins?: string[]; template?: string; confirmSessionTemplate?: string; confirmRemoteControlTemplate?: string; confirmFullDeviceTemplate?: string; sessionControlsTemplate?: string; capabilities?: string[]; registration?: boolean; redactedViews?: string[]; unredactedViews?: string[]; instance?: any; confirmSession?: () => Promise; confirmRemoteControl?: () => Promise; confirmFullDevice?: () => Promise; showSessionControls?: () => void; hideSessionControls?: () => void; } type SendStatus = 'sending' | 'sent' | 'failed' | 'discarded'; type SendFailureReason = 'timeout' | 'disconnected' | 'chat_ended' | 'rejected' | 'upload_failed'; interface SendFailure { readonly reason: SendFailureReason; /** * Whether the SDK resends on its own; always false once the message is `failed`. A manual retry is allowed * for every reason but chat_ended. */ readonly retryable: boolean; } interface OutgoingMessageStatusBase { readonly client_message_id: string; readonly status: SendStatus; /** When the user pressed send, or Retry. */ readonly $timestamp: Date; /** 1 for the first send, +1 for every automatic or manual resend. */ readonly attempt: number; readonly error?: SendFailure | undefined; } interface OutgoingTextStatus extends OutgoingMessageStatusBase { readonly type: 'text'; readonly content: string; } interface OutgoingFileStatus extends OutgoingMessageStatusBase { readonly type: 'photo' | 'video' | 'document' | 'file'; /** The File passed to sendFileMessage; pairs the status with the preview shown for it. */ readonly file: File; /** Set once the upload is done; an automatic resend publishes it again without uploading. */ readonly media_id?: number | undefined; } type OutgoingMessageStatus = OutgoingTextStatus | OutgoingFileStatus; declare class EventManager { private handlers; addEventListener(eventName: string, handler: EventHandler): void; triggerEvent(eventName: string, data?: any): void; removeEventListener(eventName: string, handler: EventHandler): void; destroy(): void; } /** A page of stored conversation messages, newest first. */ interface UjetConversationMessageItem { message_id: string; data: Record; user: string; published_at: string; /** Aggregated translation_update payloads for this row, when any exist. */ attributes?: unknown; } interface UjetConversationHistoryQuery { limit?: number; /** `next_cursor` from the previous page, or the oldest `message_id` seen. */ before?: string; } interface UjetConversationHistoryResponse { messages: UjetConversationMessageItem[]; next_cursor: string | null; has_more: boolean; last_published_at: string | null; last_persisted_at: string | null; /** Set when a publish has not been persisted yet; re-query after this delay. */ retry_after_ms: number | null; } /** * Backend-derived capabilities a provider cannot obtain on its own. Twilio's * vendor SDK supplied all of these itself and needed only `issueChatToken`; * a generic pub/sub client needs the address, the credential and the history * endpoint handed to it. * * The channel id is deliberately absent: it is assigned asynchronously after * the chat is created, so keeping it out lets a context be built before one * exists — it arrives later as the `join(sid)` argument instead. Everything * else is per-chat, `fetchHistory` included; it reads the history of the chat * the context was built for. */ interface ProviderContext { /** * A token that will still be valid at the far end of the caller's next hop. * Pass `forceRefresh` after a rejected connection so a token that merely * looks fresh is not offered again. */ getAuthToken: (forceRefresh?: boolean) => Promise; wsUrl: string; fetchHistory: (query: UjetConversationHistoryQuery) => Promise; /** Synchronous risk-flag read; absent means every flag reads on (fail-open, ARC-BE-0505). */ isRiskFlagEnabled?: ((flagName: string) => boolean) | undefined; } declare abstract class BaseProvider { static type: string; private audio; issueChatToken: IssueChatTokenMethod; identity: string; channelId: string; region?: string; inTask: boolean; muted: boolean; /** Undefined for providers whose backend needs supply no context. */ providerContext?: ProviderContext; events: EventManager; constructor(events: EventManager, state: ChatResponse, issueChatToken: IssueChatTokenMethod, providerContext?: ProviderContext); /** * Re-establish a connection the transport could not recover by itself. * Providers whose vendor SDK owns reconnection leave this alone. */ reconnect(): Promise; ping(): void; /** * Cleanup audio resources by removing event listeners. * Should be called by subclasses in their destroy() method. */ protected cleanupAudio(): void; on(eventName: string, handler: EventHandler): void; off(eventName: string, handler: EventHandler): void; /** * Whether sends can go through the outbox: the echo carries the sent `client_message_id` back, and * publishTracked() rejects with errors classifySendError() can tell apart. A provider that has it also * emits SEND_READY_EVENT whenever the transport comes back. */ get tracksSends(): boolean; /** Whether a publish can go out right now; only read when tracksSends. */ get canPublish(): boolean; /** One publish attempt for the outbox, rejecting when the message does not go out; only called when tracksSends. */ publishTracked(_message: MessageRequest): Promise; /** The key a file send's echo carries as `$index`, for pairing its File; '' when there is none. */ attachmentKeyOf(_message: MessageRequest): AttachmentKey; trackInTask(message: MessageResponse): void; abstract create(): Promise; abstract destroy(): Promise; abstract join(sid: string): Promise; abstract preview(text: string | undefined): Promise; abstract fetchMessages(files: { [index: AttachmentKey]: File; }): Promise; abstract sendMessage(message: MessageRequest): Promise; abstract startTyping(): void; abstract stopTyping(): void; abstract registerConversationEvents(): void; } declare function addProviderType(Provider: typeof BaseProvider): void; interface ChatHooks { leaveChat?: () => Promise; leaveChatBeacon?: () => void; isRiskFlagEnabled?: (flagName: string) => boolean; /** Ownership-checked lookup of a redacted message's original; rejects with `{ status }` on HTTP errors. */ fetchMessageOriginal?: (redactionRef: number) => Promise; /** The server's current task-VA state for this chat; undefined when the server does not report it. */ fetchTaskVaActive?: (() => Promise) | undefined; } declare class Chat { private provider; private store; private globalEvents; state: ChatResponse | null; connected: boolean; allowSkipVirtualAgent: boolean; inEscalation: boolean; private events; private cachedFiles; private hooks; private originals; private cacheOwner; private restoredMessages; private nextTrackedSweepAt; private destroying; private leaveSent; private beaconAttempted; private connecting; private connectEnd; private outbox; private sendTrackingReleased; private newestSid; private sendFloors; private sentAwaitingEcho; private pairedEchoIds; private sentFiles; private taskStateResync; private readonly onTaskStateSignal; constructor(state: ChatResponse, issueChatToken: IssueChatTokenMethod, hooks?: ChatHooks, providerContext?: ProviderContext); private handleConnectionEnded; private endConnection; get id(): number; get menuId(): number; get channelId(): string; get lang(): string; get virtual(): boolean; get muted(): boolean; set muted(muted: boolean); get agent(): VirtualAgent | HumanAgent; get allAgents(): { virtual: VirtualAgent[]; human: HumanAgent[]; }; get userIdentity(): string; /** * The end user's participant id, from the chat payload (both providers) and * the provider token identity (`end_user-`). Either alone is enough; * when both are known they must agree. null when neither is known or they * disagree — ownership then cannot be established and nothing is restored. */ get ownUserId(): number | null; private get ownerConflict(); private get payloadOwnerId(); private get providerOwnerId(); get status(): string; get postSessionStatus(): string; get statusText(): string; get cobrowsable(): boolean; get ongoing(): boolean; get assigned(): boolean; get dismissed(): boolean; get ended(): boolean; get transcriptCount(): number; get createdAt(): string; get inTask(): boolean; get feedbackType(): 'survey' | 'rate' | 'none'; get optInRequired(): boolean; get postSessionRequired(): boolean; get postSessionInProgress(): boolean; get checkInStatus(): CheckInStatus | null; set checkInStatus(newStatus: CheckInStatus | null); update(state: ChatResponse): void; on(eventName: string, handler: EventHandler): void; off(eventName: string, handler: EventHandler): void; connect(): Promise; disconnect(): Promise; private sendLeave; leaveBeacon(): void; resetBeaconState(): void; /** * Narrowed on the way out for the same reason as `Client.sendFileMessage`; * `chat` is public too. Pairing still uses the provider's wide key. */ sendMessage(message: MessageRequest, file?: File): Promise; /** Messages sent through the outbox and not confirmed yet, oldest first; empty when nothing is tracked. */ get outgoingMessages(): readonly OutgoingMessageStatus[]; private saveSentFile; private statusOf; /** * The File of the tracked send an own media echo answers — by client_message_id, or by media_id for an echo * without it — saved under the echo's key, so the live path and a later history page show the same preview. */ private pairSentFile; private sentFileByMediaId; /** * Confirms the tracked send an echo answers. An own text or media echo that matches a held message but * carries no client_message_id means echoes cannot be paired on this chat: the oldest match that was handed * to the transport is confirmed, and tracking stops instead of failing a message the agent may already have. * The echo is given that send's client_message_id, so listeners pair it by id as the SDK did. */ private settleOwnEcho; /** * An own echo without the id that comes after its send was reported `sent` (the ack came first, or release() * ended it) gets that send's id too, by the same checks, so listeners still pair it by id. */ private pairLateEcho; private givePairedId; private awaitEcho; private forgetSent; /** Whether the message was published after this send was queued. With nothing seen before the send, any is. */ private isAfterSend; private noteSid; preview(text: string | undefined): Promise; fetchMessages(): Promise; /** * Re-binds the cache to the live owner and returns the owner to judge * messages by. On a change — payload end_user, provider identity, or a move * between the two — everything remembered for the previous owner is dropped * and every original already shown is taken back, before any of it can be * read for the new one. Metadata that is merely absent (an update without * end_user on a provider that carries no identity) is not a change: the * established owner stands until a different one, or a conflict, appears. */ private syncCacheOwner; private rebindCacheOwner; private revokeOriginals; private trackRestored; private surfacesSubscriptionEnd; private settleEndedConnect; private localOriginalCacheEnabled; private sanitizesInboundPaths; private inboundSanitizer; /** * Joins the original onto `message.unredacted` for the end user's own * redacted text: local cache → in-band `unredacted` → (returns true) a * redaction_ref lookup. Another end user's in-band original is dropped so * the userType-only render check cannot expose it. Agent and system * messages are left alone. * * @returns whether a store lookup is still needed for this message */ private restoreOwnOriginal; /** * Puts an original onto `message.unredacted` — through the same sanitizer * the masked content went through, since the widget renders it as HTML — * and tracks the message for revocation. False when there was nothing * usable to show; a rejected original is removed rather than kept raw. */ private applyOriginal; private lookupOwnOriginal; startTyping(): void; stopTyping(): void; saveMedia(index: AttachmentKey, file: File): void; destroy(): Promise; private startTaskStateResync; clearMediaStore(): Promise; private triggerEvent; private registerProviderEvents; private registerMessageEvents; } /** Thrown when a message send is attempted after the chat has already ended. */ declare class ChatEndedError extends Error { static readonly CODE = "CHAT_ENDED"; readonly code = "CHAT_ENDED"; /** Chat status at the time of the rejected send (e.g. 'finished', 'timeout'). */ readonly status?: string; constructor(status?: string); } /** Which side turned the authentication down. */ type RefusedBy = 'client' | 'server'; /** * Thrown when authentication was refused rather than merely failing in * passing. Retrying with the same credentials will not succeed, so callers * should surface the failure instead of backing off. Transient failures * (network, bridge round-trip) reject with their original error. */ declare class UnauthorizedError extends Error { static readonly CODE = "UNAUTHORIZED"; readonly code = "UNAUTHORIZED"; /** * `client` — the integrator's `authenticate()` callback rejected, which is * how a signed-out end user reaches us. `server` — UJET declined the token * the callback produced. */ readonly refusedBy: RefusedBy; constructor(message: string, refusedBy: RefusedBy, options?: { cause?: unknown; }); } declare global { interface Window { webkitIndexedDB: IDBFactory; mozIndexedDB: IDBFactory; OIndexedDB: IDBFactory; msIndexedDB: IDBFactory; } } declare class MediaStore { private db; private store; save(index: AttachmentKey, file: File): Promise; getAll(): Promise<{ index: AttachmentKey; file: File; }[]>; getAllFiles(): Promise<{ [index: AttachmentKey]: File; }>; clear(): Promise; } /** Return type of `VoiceCall.feedbackType` — which post-call UX (if any) to show. */ type VoiceFeedbackType = 'survey' | 'rate' | 'none'; /** * Opaque server-side reference returned by {@link VoiceCall.prepareMediaUpload} * and consumed by {@link VoiceCall.submitMediaRefsForSmartAction}. `kind` * carries the originating media type so submit can reject cross-type misuse * (e.g. submitting a video ref under a photo SmartAction). */ type MediaRef = { readonly ref: string; readonly kind: SmartActionMediaType; }; declare class VoiceCall { /** Backing field for the read-only `state` accessor; mutated by the SDK. */ protected _state: VoiceCallResponse; private _publicState; private setInternalState; /** * Server-side call state. Exposed as `Readonly` so consumers cannot mutate * top-level fields. Raw `status` is omitted from this view — use * `call.status` for the curated 7-state form, or `call.serverStatus()` to * read the raw `ServerVoiceCallStatus` explicitly. */ get state(): Readonly>; /** * Raw server status escape hatch. Prefer `call.status` (curated). The raw * value is intentionally exposed so consumers can test against the full * `ServerVoiceCallStatus` union when curated `VoiceCallStatus` is too coarse. */ serverStatus(): ServerVoiceCallStatus; private keepAlive; private stateMachine; private handledSmartActionIds; private smartActionQueue; private get currentSmartActionId(); private currentCobrowseSmartActionId; private recordingPermissionAsked; private speakerOn; private cobrowseStarter; private resolveStartedAtFromState; private setStatus; private teardownActiveResources; /** Server-assigned voice call id. */ get id(): number; /** Curated lifecycle status (mapped from raw server status). */ get status(): VoiceCallStatus; /** Current peer (human or virtual). Human takes priority once escalated. */ get agent(): HumanAgent | VirtualAgent | null; /** Seconds elapsed since the media leg connected (server-anchored). */ get duration(): number; /** * Post-call feedback type configured for this call. * * Precedence: `'survey'` > `'rate'` > `'none'`. If both `survey_enabled` * and `csat_settings.enabled` are true on the call, survey wins (the * customer-configured questionnaire is richer than a numeric rating). * `'none'` means the consumer should skip any post-call UX and return * straight to the launcher. */ get feedbackType(): VoiceFeedbackType; /** Toggle mute on the local microphone. Idempotent. */ mute(on: boolean): void; /** True when the local microphone is muted. */ isMuted(): boolean; /** * Returns the remote audio MediaStream (human agent or virtual agent). * Null after the call ends or before media is connected. */ getRemoteAudioStream(): MediaStream | null; /** * True when the runtime can programmatically switch the audio output (e.g. * loudspeaker vs earpiece). iOS Safari returns false; consumers should hide * the speaker toggle UI when this is false. */ isSpeakerSupported(): boolean; /** True when the call audio is currently routed to a loudspeaker output. */ isSpeakerOn(): boolean; /** * Switch the audio output between loudspeaker (true) and the default * earpiece/system output (false). On platforms where output-device selection * is not supported, only the internal flag is updated (visual-only toggle). * * @throws {ProviderError} when `on=true` but no loudspeaker output device is * available on a platform that supports output-device selection. */ setSpeakerOn(on: boolean): Promise; /** Confirm the recording-consent prompt (server records the call). */ grantRecording(): Promise; /** Decline the recording-consent prompt (server skips recording). */ denyRecording(): Promise; /** * Generate a cobrowse code so an agent can join the user's screen for this * voice call. Throws if cobrowse is not enabled on the Client (see the * `cobrowse` option). */ startCobrowse(lang?: string, from?: string): Promise; /** Submit a text response to an agent-pushed text SmartAction. */ submitTextSmartAction(smartActionId: number, text: string): Promise; /** Confirm an agent-pushed verification SmartAction (user said yes). */ confirmVerificationSmartAction(smartActionId: number): Promise; /** Cancel any active SmartAction (user dismissed the dialog). */ cancelSmartAction(smartActionId: number): Promise; /** Upload media files (photo / screenshot / video) for a SmartAction. */ uploadMediaForSmartAction(smartActionId: number, files: File[], type: 'photo' | 'screenshot' | 'video'): Promise; /** * Upload one media file in advance (used by the widget's mobile background-upload * path). Returns an opaque server-side reference. Caller passes the references * collected this way into {@link submitMediaRefsForSmartAction}. Pass an * AbortSignal to cancel an in-flight upload (e.g. user closed the picker * dialog mid-transfer). */ prepareMediaUpload(file: File, type: SmartActionMediaType, signal?: AbortSignal): Promise; /** * Register pre-uploaded media refs (from {@link prepareMediaUpload}) against an * active SmartAction. Used by the mobile background-upload path; desktop continues * to use {@link uploadMediaForSmartAction}. * * Each {@link MediaRef} carries its `kind` so callers cannot accidentally * submit a video ref under a photo SmartAction. The method throws * {@link SmartActionError} if any ref's `kind` doesn't match `type`. */ submitMediaRefsForSmartAction(smartActionId: number, type: SmartActionMediaType, refs: readonly MediaRef[]): Promise; protected registerProviderEvents(): void; protected fetchAndUpdateState(): Promise; private handleProviderMessage; private handleSmartActionRequested; private handleSmartActionResolved; private handleStatusChanged; private sendProviderMessage; private markSmartActionHandled; private resolveSmartAction; } declare const VOICE_EVENTS: { readonly STATUS_CHANGED: "voice.statusChanged"; readonly RECONNECTING: "voice.reconnecting"; readonly RECONNECTED: "voice.reconnected"; readonly ERROR: "voice.error"; readonly SMART_ACTION_REQUESTED: "voice.smartActionRequested"; readonly SMART_ACTION_RESOLVED: "voice.smartActionResolved"; readonly COBROWSE_REQUESTED: "voice.cobrowseRequested"; readonly COBROWSE_RESOLVED: "voice.cobrowseResolved"; readonly RECORDING_PERMISSION_REQUIRED: "voice.recordingPermissionRequired"; readonly MIC_PERMISSION_REQUIRED: "voice.micPermissionRequired"; readonly CONNECTION_QUALITY: "voice.connectionQuality"; }; /** Extract a human-readable message from an `unknown` caught value. */ declare const getErrorMessage: (err: unknown) => string; /** Cross-realm-safe fallback for `err instanceof VoiceCallError` checks. */ declare const hasErrorCode: (err: unknown, code: VoiceErrorCode) => boolean; /** Extract an HTTP-style numeric `status` from an `unknown` caught value. */ declare const getErrorStatus: (err: unknown) => number | undefined; /** Base class for all voice-related errors. Carries a stable string `code`. */ declare class VoiceCallError extends Error { readonly code: VoiceErrorCode; constructor(message: string, code: VoiceErrorCode, cause?: unknown); } /** End user already has a call in progress on this device. */ declare class CallInProgressError extends VoiceCallError { static readonly CODE = "CALL_IN_PROGRESS"; constructor(message?: string); } /** Inbound voice channel is disabled for this menu. */ declare class InboundDisabledError extends VoiceCallError { static readonly CODE = "INBOUND_DISABLED"; constructor(message?: string); } /** Tenant is currently outside its configured operation hours. */ declare class OperationHoursError extends VoiceCallError { static readonly CODE = "OPERATION_HOURS"; constructor(message?: string); } /** Inbound voice feature flag is off for this tenant. */ declare class FeatureNotEnabledError extends VoiceCallError { static readonly CODE = "FEATURE_NOT_ENABLED"; constructor(message?: string); } /** Mic unavailable at call start — wraps any getUserMedia rejection; inspect `cause` to distinguish. */ declare class MicPermissionDeniedError extends VoiceCallError { static readonly CODE = "MIC_PERMISSION_DENIED"; constructor(message?: string, cause?: unknown); } /** Caller invoked a method that requires an active voice call but none exists. */ declare class NoActiveVoiceCallError extends VoiceCallError { static readonly CODE = "NO_ACTIVE_VOICE_CALL"; constructor(message?: string); } /** Another tab already holds the voice tab lock. */ declare class AnotherTabVoiceCallError extends VoiceCallError { static readonly CODE = "ANOTHER_TAB_VOICE_CALL"; constructor(message?: string); } /** Underlying voice provider (e.g., Twilio Device/Call) failed. */ declare class ProviderError extends VoiceCallError { static readonly CODE = "PROVIDER_ERROR"; constructor(message: string, cause?: unknown); } /** Smart action submit / cancel / update / upload failed (server error or missing client method). */ declare class SmartActionError extends VoiceCallError { static readonly CODE = "SMART_ACTION_ERROR"; /** Server message when the agent ends a smart action before the user responds. */ static readonly ENDED_MESSAGE = "smart action is already ended"; constructor(message: string, cause?: unknown); /** True when the underlying failure was the agent-ended-already case. */ get isAlreadyEnded(): boolean; } /** Unrecognized voice subsystem failure (network timeout, transient server error). */ declare class UnknownVoiceError extends VoiceCallError { static readonly CODE = "UNKNOWN_VOICE_ERROR"; constructor(message: string, cause?: unknown); } /** * True when the error indicates the call cannot start now due to tenant / * menu / company / concurrency constraints — outside operation hours, * inbound disabled, feature flag off, or another call in progress. * MenuFoot uses this to show an after-hours message instead of an error UI. */ declare const isAfterHoursError: (err: unknown) => boolean; /** Union of all stable error codes thrown by the voice subsystem. */ type VoiceErrorCode = typeof CallInProgressError.CODE | typeof InboundDisabledError.CODE | typeof OperationHoursError.CODE | typeof FeatureNotEnabledError.CODE | typeof MicPermissionDeniedError.CODE | typeof NoActiveVoiceCallError.CODE | typeof AnotherTabVoiceCallError.CODE | typeof ProviderError.CODE | typeof SmartActionError.CODE | typeof UnknownVoiceError.CODE; interface VoiceStatusChangedEvent { id: number; status: VoiceCallStatus; prevStatus?: VoiceCallStatus; } interface VoiceErrorEvent { id: number; error: VoiceCallError; } /** Emitted on a non-cobrowse smart action request. `smartAction.type` is never 'cobrowse'. */ interface VoiceSmartActionRequestedEvent { smartAction: Readonly; }>; } interface VoiceSmartActionResolvedEvent { smartActionId: number; } /** Emitted on a cobrowse smart action request. `smartAction.type` is always 'cobrowse'. */ interface VoiceCobrowseRequestedEvent { smartAction: Readonly; }>; } interface VoiceCobrowseResolvedEvent { smartActionId: number; } interface VoiceRecordingPermissionRequiredEvent { id: number; } /** Result of `client.checkMicPermission()`. `'unknown'` when the Permissions * API or the `microphone` descriptor is unsupported (e.g. iOS Safari). */ type MicPermissionState = 'granted' | 'denied' | 'prompt' | 'unknown'; type ConnectionQualityLevel = 'good' | 'degraded'; /** Normalized, provider-agnostic quality issues. Twilio warning names are * mapped to these inside TwilioVoiceProvider — raw Twilio names never leak. */ type ConnectionQualityWarning = 'high-latency' | 'jitter' | 'packet-loss' | 'low-quality'; interface VoiceConnectionQualityEvent { level: ConnectionQualityLevel; warnings: ConnectionQualityWarning[]; } declare class Client { VERSION: string; options: ClientOption; private communicator; private methods; private events; request: RequestMethod; chat: Chat; private _cobrowse; private _voiceCall; private _voiceTabLock; private redactionSendQueue; private fileSendQueue; private noCryptoLogged; private _rehydratePromise; private onPageHide?; private onPageShow?; constructor(options: ClientOption); private registerUnloadHandlers; private unregisterUnloadHandlers; get deviceId(): string; get user(): UserProfile; get lang(): string; set lang(lang: string); get cobrowse(): any; get cobrowseEnabled(): boolean; destroy(): void; /** * Teardown for a client that was constructed but never owned the page's * session — the widget's duplicate-init guard (WEB-4194). Skips the voice * teardown `destroy()` runs, because `ujet:voice` and the multi-tab lock * are page-wide and belong to the instance that started the call. */ destroyDuplicate(): void; private releaseVoiceTabLock; /** Voice event payload signatures — overloads for `client.on`/`off`. */ on(event: typeof VOICE_EVENTS.STATUS_CHANGED, handler: (payload: VoiceStatusChangedEvent) => void): void; on(event: typeof VOICE_EVENTS.RECONNECTING, handler: () => void): void; on(event: typeof VOICE_EVENTS.RECONNECTED, handler: () => void): void; on(event: typeof VOICE_EVENTS.ERROR, handler: (payload: VoiceErrorEvent) => void): void; on(event: typeof VOICE_EVENTS.SMART_ACTION_REQUESTED, handler: (payload: VoiceSmartActionRequestedEvent) => void): void; on(event: typeof VOICE_EVENTS.SMART_ACTION_RESOLVED, handler: (payload: VoiceSmartActionResolvedEvent) => void): void; on(event: typeof VOICE_EVENTS.COBROWSE_REQUESTED, handler: (payload: VoiceCobrowseRequestedEvent) => void): void; on(event: typeof VOICE_EVENTS.COBROWSE_RESOLVED, handler: (payload: VoiceCobrowseResolvedEvent) => void): void; on(event: typeof VOICE_EVENTS.RECORDING_PERMISSION_REQUIRED, handler: (payload: VoiceRecordingPermissionRequiredEvent) => void): void; on(event: typeof VOICE_EVENTS.MIC_PERMISSION_REQUIRED, handler: () => void): void; on(event: typeof VOICE_EVENTS.CONNECTION_QUALITY, handler: (payload: VoiceConnectionQualityEvent) => void): void; on(eventName: string, handler: EventHandler): void; off(event: typeof VOICE_EVENTS.STATUS_CHANGED, handler: (payload: VoiceStatusChangedEvent) => void): void; off(event: typeof VOICE_EVENTS.RECONNECTING, handler: () => void): void; off(event: typeof VOICE_EVENTS.RECONNECTED, handler: () => void): void; off(event: typeof VOICE_EVENTS.ERROR, handler: (payload: VoiceErrorEvent) => void): void; off(event: typeof VOICE_EVENTS.SMART_ACTION_REQUESTED, handler: (payload: VoiceSmartActionRequestedEvent) => void): void; off(event: typeof VOICE_EVENTS.SMART_ACTION_RESOLVED, handler: (payload: VoiceSmartActionResolvedEvent) => void): void; off(event: typeof VOICE_EVENTS.COBROWSE_REQUESTED, handler: (payload: VoiceCobrowseRequestedEvent) => void): void; off(event: typeof VOICE_EVENTS.COBROWSE_RESOLVED, handler: (payload: VoiceCobrowseResolvedEvent) => void): void; off(event: typeof VOICE_EVENTS.RECORDING_PERMISSION_REQUIRED, handler: (payload: VoiceRecordingPermissionRequiredEvent) => void): void; off(event: typeof VOICE_EVENTS.MIC_PERMISSION_REQUIRED, handler: () => void): void; off(event: typeof VOICE_EVENTS.CONNECTION_QUALITY, handler: (payload: VoiceConnectionQualityEvent) => void): void; off(eventName: string, handler: EventHandler): void; /** * Non-prompting read of the microphone permission state. Never calls * getUserMedia, so it does NOT trigger the browser permission dialog. * Returns 'unknown' when the Permissions API / 'microphone' descriptor is * unsupported (iOS Safari, older browsers) — callers should then rely on the * `voice.micPermissionRequired` event / the thrown MicPermissionDeniedError. */ checkMicPermission(): Promise; getCompany(): Promise; getFeatureFlags(): Promise; runTrigger(cb: (trigger: TriggerItem) => void): Promise; trackClientEvents(events: ClientEvent[]): Promise; getProhibitedFileTypes(): Promise; getMenus(key?: string, lang?: string, routing?: MenusRoutingInputs): Promise; cancelMenuPolling(): void; getCustomFormData(formId: string): Promise; submitCustomForm(payload: CustomFormPayload): Promise; getAfterHourMessage(lang?: string): Promise; getTimeSlots(menuId: number | string, options?: GetTimeSlotsRequest): Promise; /** * @deprecated Use getTimeSlots(menuId, options) instead to avoid parameter ambiguity */ getTimeSlots(menuId: number | string, lang?: string): Promise; fetchTimeSlotAvailability(menuId: number | string, lang?: string): Promise; getWaitTimes(menuId: number | string, lang?: string): Promise; verifyForm(data: FormData): Promise; createCall(menuId: number | string, data: CallRequest): Promise; loadCall(callId: number | string): Promise; cancelCall(callId: number | string): Promise; createEmail(menuId: number | string, data: EmailRequest): Promise; createChat(menuId: number | string, data?: ChatRequest): Promise; loadChat(chatId: number | string): Promise; resumeChat(chatId: number | string): Promise; loadOngoingChat(): Promise; private _doLoadOngoingChat; restoreCobrowseSession(): Promise; finishChat(): Promise; updatePostSession(postSessionStatus: PostSessionStatus, optInSelection?: boolean): Promise; destroyChat(): Promise; /** Active voice call instance, or null when no call is in progress. */ get voiceCall(): VoiceCall | null; /** * Returns true when localStorage holds a pending refresh-restore entry. * Not cached — invocation is a sync I/O check. */ hasStoredVoiceCall(): boolean; /** * Start a new inbound voice call for the given menu. * * @throws CallInProgressError if another voice call is already active in * this session. * @throws MicPermissionDeniedError if the browser denies microphone access. * @throws AnotherTabVoiceCallError if another tab already holds the voice * tab lock. * @throws InboundDisabledError if inbound voice is disabled for the menu. * @throws OperationHoursError if the menu is outside its operation hours. * @throws FeatureNotEnabledError if the company doesn't have the voice * feature enabled. * @throws VoiceCallError (code 'UNKNOWN_VOICE_ERROR') as a generic * fallback for unrecognized server / transient failures. */ startVoiceCall(menuId: number | string, options?: VoiceCallRequest): Promise; /** * Restore a voice call after a page refresh. Resolves to the call instance * when an active call exists on the server, or null when no recoverable call * is found (no stored entry, or the call has already terminated). * * @throws AnotherTabVoiceCallError if another tab already holds the voice * tab lock. * @throws Network/server errors are propagated; HTTP 404 is treated as * "no recoverable call" and resolves to null. */ loadVoiceCall(callId?: number | string): Promise; /** * End the active call but keep the VoiceCall instance + tab lock alive * so the widget can show post-call UI (rate/survey). For full teardown * including storage cleanup, call destroyVoiceCall(). */ endVoiceCall(): Promise; /** * Escalate the active VA voice call to a human-agent queue. Server validates * the transition (only valid during a VA-routed call); SDK does not gate. * * @throws NoActiveVoiceCallError if no voice call is active. */ escalateVoiceCall(): Promise; /** * Release all resources for the active voice call. Hangs up the call first * if it's still ongoing, then tears down provider, timers, and event * listeners, and clears the localStorage entry. */ destroyVoiceCall(): Promise; getChatDeflection(): Promise; sendChatTranscripts(emails: string[]): Promise; downloadChatTranscript(): Promise; getPdfStatus(id: number): Promise; getChatSurvey(): Promise; sendChatSurvey(answers: SurveyAnswers): Promise; sendChatRate(data: RateRequest): Promise; /** * Submit a CSAT rating for the active voice call (feedbackType === 'rate'). * * @throws NoActiveVoiceCallError if no voice call is active. */ rateVoiceCall(data: RateRequest): Promise; /** * Fetch the post-call survey definition (feedbackType === 'survey'). * * @throws NoActiveVoiceCallError if no voice call is active. */ getVoiceCallSurvey(): Promise; /** * Submit answers to the post-call survey (feedbackType === 'survey'). * * @throws NoActiveVoiceCallError if no voice call is active. */ submitVoiceCallSurvey(answers: SurveyAnswers): Promise; escalateChat(data?: EscalateRequest): Promise; trackChatEscalation(escalationId: number, channel: string): Promise; trackChatEndUserEvent(data: ChatEndUserEventRequest): Promise; getChatHistory(page?: number): Promise; fetchMessages(): Promise; private sanitizeFetchedMessages; /** * On a chat that tracks sends, the upload is done once and its response goes through the outbox: status * events follow, carrying this `file`, and a resend or retry publishes the same response without uploading * again. An upload failure is unchanged. */ sendFileMessage(file: File): Promise; /** * Resolves with the message's client_message_id when the SDK tracks it: status events follow for that id. * `undefined` means the SDK isn't tracking the message; it is not a failure. */ sendTextMessage(rawContent: string): Promise; private warnNoCrypto; /** Sends a `failed` message again with the same id. False for an unknown id, a message not `failed`, or an ended chat. */ retryMessage(clientMessageId: string): boolean; /** Removes a `failed` message; its last status is `discarded`. False when there is no such message. */ discardMessage(clientMessageId: string): boolean; sendPreviewMessage(content: string): Promise; private isRedactionAgentEnabled; createCobrowseCode(lang?: string, customData?: Record): Promise; startCobrowse(from?: string): Promise; getMessageAttachment(message: MessageResponse): Promise; checkIn(): Promise; exitCheckIn(): Promise; notifyCheckInState(data: CheckInVisibilityStateRequest): Promise; rejoinChat(): Promise; trackCheckInEvent(): Promise; getLogs(): Promise<{ bridgeLogs: LogHistoryData[]; rootLogs: LogHistoryData[]; }>; printLogs(): Promise; private updateCheckIn; private initializeCobrowse; private registerOngoingChat; } declare class CircularBuffer { private buffer; private writeIndex; private size; private readonly capacity; constructor(capacity: number); push(item: T): void; toArray(): T[]; clear(): void; } declare class Logger { static logHandlers: LoggerHandler[]; static logHistory: CircularBuffer; static addHandler(handler: LoggerHandler): void; static printLogHistoryData(log: LogHistoryData): void; static consoleLog(channel: string, level: string, ...args: any[]): void; private channel; constructor(channel: string); debug(...args: any[]): void; info(...args: any[]): void; warn(...args: any[]): void; error(...args: any[]): void; private log; } declare const isMobilePlatform: () => boolean; declare const ENVIRONMENT: string; declare const VERSION: string; declare const OPTIONS: { companyId: string; tenant: string; trackerId: string; deviceId: string; application: string; version: string; }; type VoiceProviderMessageType = 'smart_action_requested' | 'smart_action_resolved' | 'recording_permission_required' | 'status_changed' | 'smart_action_notified' | 'smart_action_response' | 'recording_permission'; type IssueVoiceTokenMethod = () => Promise<{ token: string; identity: string; }>; interface VoiceProviderMessage { type: VoiceProviderMessageType; data?: Record; } declare abstract class BaseVoiceProvider { static type: string; protected events: EventManager; protected state: VoiceCallResponse; protected issueVoiceToken: IssueVoiceTokenMethod; constructor(events: EventManager, state: VoiceCallResponse, issueVoiceToken: IssueVoiceTokenMethod); /** * Dial the carrier and prepare the media leg. * * Contract: * - Resolve only after the transport reaches a state where it can emit * `INTERNAL_VOICE_EVENTS.CONNECTED` (`'voice:internal:connected'`) on its * own. The CONNECTED event is what drives `VoiceCall.status` from * `connecting` to `connected` / `va_connected`; without it, the call * stays in pre-connect state forever. * - Emit CONNECTED no later than the carrier's handshake completes (Twilio * does this on `Device.connect`'s `accept` event). If your transport * takes longer than a few seconds to reach the bridge, surface progress * via your own status messages — don't delay CONNECTED past actual * media-leg readiness. * - On failure, throw a `ProviderError` (or subclass) so the SDK can route * it through `VOICE_EVENTS.ERROR` with a typed shape. */ abstract create(): Promise; /** * Fully tear down provider resources (device, listeners, audio context). * Called once per provider instance; subsequent calls are no-ops. * After destroy(), the provider MUST NOT emit further events. */ abstract destroy(): Promise; /** * Toggle the local microphone mute state. * * Contract: * - Idempotent — repeated calls with the same boolean MUST be no-ops. The * SDK and consumers may call `mute(true)` multiple times (focus * restoration, refresh re-apply); do not assume each call flips state. * - Synchronous. The state change MUST be observable via `isMuted()` on * the next event-loop tick. */ abstract mute(on: boolean): void; abstract isMuted(): boolean; abstract isOutputSelectionSupported(): boolean; abstract getAvailableOutputDevices(): MediaDeviceInfo[]; abstract setOutputDevice(deviceId: string): Promise; /** * Disconnect the active call leg. * MUST emit the internal disconnected event (`'voice:internal:disconnected'`) * before resolving. Idempotent: calling on a non-active provider still emits it. * * @remarks The wire-format string `'voice:internal:disconnected'` IS the * stable contract — provider authors should emit this literal via * `this.events.triggerEvent(...)`. We do not export a named constant for * the SDK-provider boundary; the literal is intentionally the public * contract surface so providers don't take an import dependency on the * SDK's internal event-name module. */ abstract hangup(): Promise; getRemoteStream(): MediaStream | null; sendMessage(message: VoiceProviderMessage): string | null; } /** * Concrete (newable) constructor signature for provider implementations. * BaseVoiceProvider is abstract so `typeof BaseVoiceProvider` cannot be `new`-ed directly. * * `type` MUST be a non-empty string — it's the registry key used by * `addVoiceProviderType()` / `getVoiceProviderType()` to dispatch incoming * `voip_provider` values from the server to the right provider class. */ type VoiceProviderConstructor = (new (events: EventManager, state: VoiceCallResponse, issueVoiceToken: IssueVoiceTokenMethod) => BaseVoiceProvider) & { type: string; }; declare const addVoiceProviderType: (Provider: VoiceProviderConstructor) => void; declare const getVoiceProviderType: (type: string) => VoiceProviderConstructor | undefined; declare const RISK_FLAG_EVENTS: { readonly UPDATED: "riskFlagsUpdated"; }; declare const COBROWSE_EVENTS: { readonly LOADED: "cobrowse.loaded"; readonly UPDATED: "cobrowse.updated"; readonly ENDED: "cobrowse.ended"; }; type CobrowseEvent = (typeof COBROWSE_EVENTS)[keyof typeof COBROWSE_EVENTS]; export { AnotherTabVoiceCallError, type AttachmentKey, BaseProvider, BaseVoiceProvider, COBROWSE_EVENTS, type CallApiResponse, CallInProgressError, type CallRequest, type CallResponse, ChannelType, Chat, type ChatDeflectionResponse, type ChatDocumentItem, type ChatEndUserEventRequest, ChatEndedError, type ChatHistoryItem, type ChatHistoryResponse, type ChatMessageOriginalResponse, type ChatMessageRequest, type ChatMessageResponse, type ChatRequest, type ChatResponse, type ChatSurveyResponse, type ChatTaskMessageResponse, type CheckInModalStateRequest, type CheckInResponse, CheckInStatus, type CheckInVisibilityStateRequest, Client, type ClientEvent, type ClientOption, type CobrowseEvent, type CobrowseMessages, type CobrowseOption, type CobrowseRequest, type CompanyResponse, type ConnectCallback, type ConnectOption, type ConnectRequest, type ConnectResult, type ConnectionQualityLevel, type ConnectionQualityWarning, type CustomFormPayload, ENVIRONMENT, type EmailRequest, type EmailResponse, type EscalateRequest, type EventHandler, EventManager, type FeatureFlagsResponse, FeatureNotEnabledError, type FileTypeItem, type FormData, type GenerateTranscriptResponse, type GetServerMessage, type GetTimeSlotsRequest, type HumanAgent, InboundDisabledError, type IssueChatTokenMethod, type IssueVoiceTokenMethod, type LanguageOption, type LogData, type LogHistoryData, Logger, type LoggerHandler, type MediaIndex, type MediaRef, MediaStore, type MenuChannel, type MenuItem, type MenuResponse, type MenusRoutingInputs, type MessageRequest, type MessageResponse, MessageType, MicPermissionDeniedError, type MicPermissionState, NoActiveVoiceCallError, NotiEvent, OPTIONS, OperationHoursError, type OutgoingFileStatus, type OutgoingMessageStatus, type OutgoingTextStatus, type PdfStatusResponse, PostSessionStatus, type ProviderContext, ProviderError, ProviderType, type QuestionItem, RISK_FLAG_EVENTS, type RateRequest, type RecordingOption, type RecordingPermission, type RefusedBy, type RequestMethod, type RequestReturn, type SendFailure, type SendFailureReason, type SendStatus, type ServerAuthResponse, type ServerVoiceCallStatus, SmartActionError, type SmartActionMediaType, type SmartActionResponse, type SmartActionType, type SurveyAnswers, type TokenResponse, type TriggerItem, type TriggerMessage, type UjetConversationHistoryQuery, type UjetConversationHistoryResponse, type UjetConversationMessageItem, UnauthorizedError, UnknownVoiceError, type UserProfile, UserType, VERSION, VOICE_EVENTS, type VirtualAgent, VoiceCall, VoiceCallError, type VoiceCallRequest, type VoiceCallResponse, type VoiceCallStatus, type VoiceCobrowseRequestedEvent, type VoiceCobrowseResolvedEvent, type VoiceConnectionQualityEvent, type VoiceErrorCode, type VoiceErrorEvent, type VoiceFeedbackType, type VoiceProviderConstructor, type VoiceProviderMessage, type VoiceProviderMessageType, type VoiceRecordingPermissionRequiredEvent, type VoiceSmartActionRequestedEvent, type VoiceSmartActionResolvedEvent, type VoiceStatusChangedEvent, type WaitTimeResponse, addProviderType, addVoiceProviderType, getErrorMessage, getErrorStatus, getVoiceProviderType, hasErrorCode, isAfterHoursError, isMobilePlatform, toIdentity };