import { Activity, Reservation, Supervisor } from "twilio-taskrouter"; import { ITask, IWorker } from "../models"; import { Conference } from "./Conferences"; export declare const ACTION_LOGGED_OUT = "FLEX_ACTION_LOGGED_OUT"; /** * Worker state based on Worker SDK * @interface WorkerState * @property {Map} tasks map of active tasks by reservation SID * @property {Activity} activity current [Activity](https://twilio.github.io/twilio-taskrouter.js/Activity.html) of the worker. * @property {Map} activities map of all [Activities](https://twilio.github.io/twilio-taskrouter.js/Activity.html) instances by SID. * @property {object} attributes attributes of the [Worker](https://twilio.github.io/twilio-taskrouter.js/Worker.html). * @property {IWorker} worker current worker instance. * @category State */ export interface WorkerState { readonly tasks: Map; readonly listener?: WorkerListener; readonly activity: Activity; readonly activities: Map; readonly attributes: any; readonly source?: Supervisor; readonly worker?: IWorker; readonly pausedEmailConversationsMap?: Map; readonly resumedEmailConversationsMap?: Map; readonly priorityPauseList?: Set; } declare const ACTION_INIT_WORKER = "WORKER_INIT"; declare const ACTION_UPDATE = "WORKER_UPDATE"; declare const ACTION_OFFLINE = "WORKER_NETWORK_OFFLINE"; declare const ACTION_ADD_RESERVATION = "WORKER_ADD_RESERVATION"; declare const ACTION_DELETE_RESERVATION = "WORKER_DELETE_RESERVATION"; declare const ACTION_UPDATE_RESERVATION = "WORKER_UPDATE_RESERVATION"; declare const ACTION_UPDATE_PAUSED_CONVERSATION_LIST = "ACTION_UPDATE_PAUSED_CONVERSATION_LIST"; declare const ACTION_REMOVE_RESUMED_EMAIL_CONVERSATION = "ACTION_REMOVE_RESUMED_EMAIL_CONVERSATION"; declare const ACTION_UPDATE_RESUMED_CONVERSATION_MAP = "ACTION_UPDATE_RESUMED_CONVERSATION_MAP"; declare const ACTION_UPDATE_PRIORITY_PAUSE_CONVERSATION_LIST = "ACTION_UPDATE_PRIORITY_PAUSE_CONVERSATION_LIST"; declare const ACTION_REMOVE_PRIORITY_PAUSE_CONVERSATION = "ACTION_REMOVE_PRIORITY_PAUSE_CONVERSATION"; type WorkerStateActionTypes = { type: typeof ACTION_INIT_WORKER; payload: { tasks: Map; listener: WorkerListener; activity: Activity; activities: Map; attributes: any; source: Supervisor; }; } | { type: typeof ACTION_LOGGED_OUT; } | { type: typeof ACTION_UPDATE; payload: WorkerState; } | { type: typeof ACTION_ADD_RESERVATION | typeof ACTION_UPDATE_RESERVATION | typeof ACTION_DELETE_RESERVATION; payload: Reservation; } | { type: typeof ACTION_OFFLINE; payload: WorkerState; } | { type: typeof ACTION_UPDATE_PAUSED_CONVERSATION_LIST; payload: Map; } | { type: typeof ACTION_REMOVE_RESUMED_EMAIL_CONVERSATION; payload: string; } | { type: typeof ACTION_UPDATE_RESUMED_CONVERSATION_MAP; payload: { conversationSid: string; pausedTime: Date; }; } | { type: typeof ACTION_UPDATE_PRIORITY_PAUSE_CONVERSATION_LIST; payload: { conversationSid: string; bulkUpdate: string[]; }; } | { type: typeof ACTION_REMOVE_PRIORITY_PAUSE_CONVERSATION; payload: { conversationSid: string; }; }; export declare function reduce(state?: WorkerState, action?: WorkerStateActionTypes): WorkerState; export declare class Actions { private static previousEndConferenceOnExits; static dispatchWorkerAction(type: string, payload: any): void; static init(worker: Supervisor): void; static addNewTask(): void; static removeReservation(reservation: Pick): void; static addReservation(reservation: Reservation): void; static setCurrentActivity(activitySid: string): Promise; static setCurrentActivityByName(activityName: string): Promise; static updateEndConferenceOnExitForTask(task: ITask, newConference?: Conference): void; static shutdown(): void; static updatePausedConversationList(list: any[]): void; static removeResumedConversation(selectedConversationSid: string): void; static updateResumedConversationMap(conversationSid: string, pausedTime: Date): void; static updatePriorityPausedConversation(conversationSid?: string, bulkUpdate?: Set): void; static removePriorityPausedConversationSid(conversationSid: string): void; } export declare class WorkerListener { private _worker; private _listening; private _reservationListeners; private currentMediaIds; constructor(worker: Supervisor); start(): void; stop(): void; private initAndLoadReservations; private stopAllReservationListeners; private dispatchAction; private stopReservationListeners; private initReservationListeners; private handleActivityUpdated; private makeActivityOffline; private handleAttributesUpdated; private handleWorkerReady; private handleWorkerDisconnected; private handleWorkerError; /** * Attempts to re-register the voice client if it's in an unregistered state. * This handles cases where Chrome's Memory Saver or other browser optimizations * may have disconnected the client. * @returns Promise that resolves when registration completes or rejects if it fails * @private */ private ensureVoiceClientRegistered; private multiTabFallbackAcceptanceTimerMap; private handleDuplicateAgentInConversation; private handleReservationCreated; private handleOutboundReservationCanceled; private handleReservationUpdated; private handlePausedTasks; private shouldSkipTask; private playSound; private handlePlayError; private stopSound; private handleTaskUpdated; isListening(): boolean; } export {};