@webex/contact-center 3.12.0-next.9 → 3.12.0-task-refactor.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. package/AGENTS.md +438 -0
  2. package/ai-docs/README.md +131 -0
  3. package/ai-docs/RULES.md +455 -0
  4. package/ai-docs/patterns/event-driven-patterns.md +485 -0
  5. package/ai-docs/patterns/testing-patterns.md +480 -0
  6. package/ai-docs/patterns/typescript-patterns.md +365 -0
  7. package/ai-docs/templates/README.md +102 -0
  8. package/ai-docs/templates/documentation/create-agents-md.md +240 -0
  9. package/ai-docs/templates/documentation/create-architecture-md.md +295 -0
  10. package/ai-docs/templates/existing-service/bug-fix.md +254 -0
  11. package/ai-docs/templates/existing-service/feature-enhancement.md +450 -0
  12. package/ai-docs/templates/new-method/00-master.md +80 -0
  13. package/ai-docs/templates/new-method/01-requirements.md +232 -0
  14. package/ai-docs/templates/new-method/02-implementation.md +295 -0
  15. package/ai-docs/templates/new-method/03-tests.md +201 -0
  16. package/ai-docs/templates/new-method/04-validation.md +141 -0
  17. package/ai-docs/templates/new-service/00-master.md +109 -0
  18. package/ai-docs/templates/new-service/01-pre-questions.md +159 -0
  19. package/ai-docs/templates/new-service/02-code-generation.md +346 -0
  20. package/ai-docs/templates/new-service/03-integration.md +178 -0
  21. package/ai-docs/templates/new-service/04-test-generation.md +205 -0
  22. package/ai-docs/templates/new-service/05-validation.md +145 -0
  23. package/dist/cc.js +65 -123
  24. package/dist/cc.js.map +1 -1
  25. package/dist/constants.js +13 -2
  26. package/dist/constants.js.map +1 -1
  27. package/dist/index.js +13 -5
  28. package/dist/index.js.map +1 -1
  29. package/dist/metrics/behavioral-events.js +26 -13
  30. package/dist/metrics/behavioral-events.js.map +1 -1
  31. package/dist/metrics/constants.js +7 -6
  32. package/dist/metrics/constants.js.map +1 -1
  33. package/dist/services/ApiAiAssistant.js +0 -3
  34. package/dist/services/ApiAiAssistant.js.map +1 -1
  35. package/dist/services/config/Util.js +2 -3
  36. package/dist/services/config/Util.js.map +1 -1
  37. package/dist/services/config/types.js +16 -14
  38. package/dist/services/config/types.js.map +1 -1
  39. package/dist/services/constants.js +0 -1
  40. package/dist/services/constants.js.map +1 -1
  41. package/dist/services/core/Err.js.map +1 -1
  42. package/dist/services/core/Utils.js +79 -55
  43. package/dist/services/core/Utils.js.map +1 -1
  44. package/dist/services/core/aqm-reqs.js +17 -92
  45. package/dist/services/core/aqm-reqs.js.map +1 -1
  46. package/dist/services/core/websocket/WebSocketManager.js +5 -25
  47. package/dist/services/core/websocket/WebSocketManager.js.map +1 -1
  48. package/dist/services/core/websocket/types.js.map +1 -1
  49. package/dist/services/index.js +1 -2
  50. package/dist/services/index.js.map +1 -1
  51. package/dist/services/task/Task.js +644 -0
  52. package/dist/services/task/Task.js.map +1 -0
  53. package/dist/services/task/TaskFactory.js +45 -0
  54. package/dist/services/task/TaskFactory.js.map +1 -0
  55. package/dist/services/task/TaskManager.js +556 -532
  56. package/dist/services/task/TaskManager.js.map +1 -1
  57. package/dist/services/task/TaskUtils.js +132 -28
  58. package/dist/services/task/TaskUtils.js.map +1 -1
  59. package/dist/services/task/constants.js +7 -6
  60. package/dist/services/task/constants.js.map +1 -1
  61. package/dist/services/task/dialer.js +0 -51
  62. package/dist/services/task/dialer.js.map +1 -1
  63. package/dist/services/task/digital/Digital.js +77 -0
  64. package/dist/services/task/digital/Digital.js.map +1 -0
  65. package/dist/services/task/state-machine/TaskStateMachine.js +634 -0
  66. package/dist/services/task/state-machine/TaskStateMachine.js.map +1 -0
  67. package/dist/services/task/state-machine/actions.js +366 -0
  68. package/dist/services/task/state-machine/actions.js.map +1 -0
  69. package/dist/services/task/state-machine/constants.js +139 -0
  70. package/dist/services/task/state-machine/constants.js.map +1 -0
  71. package/dist/services/task/state-machine/guards.js +256 -0
  72. package/dist/services/task/state-machine/guards.js.map +1 -0
  73. package/dist/services/task/state-machine/index.js +53 -0
  74. package/dist/services/task/state-machine/index.js.map +1 -0
  75. package/dist/services/task/state-machine/types.js +54 -0
  76. package/dist/services/task/state-machine/types.js.map +1 -0
  77. package/dist/services/task/state-machine/uiControlsComputer.js +369 -0
  78. package/dist/services/task/state-machine/uiControlsComputer.js.map +1 -0
  79. package/dist/services/task/taskDataNormalizer.js +99 -0
  80. package/dist/services/task/taskDataNormalizer.js.map +1 -0
  81. package/dist/services/task/types.js +157 -18
  82. package/dist/services/task/types.js.map +1 -1
  83. package/dist/services/task/voice/Voice.js +1031 -0
  84. package/dist/services/task/voice/Voice.js.map +1 -0
  85. package/dist/services/task/voice/WebRTC.js +149 -0
  86. package/dist/services/task/voice/WebRTC.js.map +1 -0
  87. package/dist/types/cc.d.ts +4 -33
  88. package/dist/types/constants.d.ts +13 -2
  89. package/dist/types/index.d.ts +11 -5
  90. package/dist/types/metrics/constants.d.ts +5 -3
  91. package/dist/types/services/ApiAiAssistant.d.ts +1 -1
  92. package/dist/types/services/config/types.d.ts +97 -25
  93. package/dist/types/services/core/Err.d.ts +0 -2
  94. package/dist/types/services/core/Utils.d.ts +25 -23
  95. package/dist/types/services/core/aqm-reqs.d.ts +0 -49
  96. package/dist/types/services/core/websocket/WebSocketManager.d.ts +1 -1
  97. package/dist/types/services/core/websocket/connection-service.d.ts +0 -1
  98. package/dist/types/services/core/websocket/types.d.ts +1 -1
  99. package/dist/types/services/index.d.ts +1 -1
  100. package/dist/types/services/task/Task.d.ts +146 -0
  101. package/dist/types/services/task/TaskFactory.d.ts +12 -0
  102. package/dist/types/services/task/TaskUtils.d.ts +39 -8
  103. package/dist/types/services/task/constants.d.ts +5 -4
  104. package/dist/types/services/task/dialer.d.ts +0 -15
  105. package/dist/types/services/task/digital/Digital.d.ts +22 -0
  106. package/dist/types/services/task/state-machine/TaskStateMachine.d.ts +906 -0
  107. package/dist/types/services/task/state-machine/actions.d.ts +8 -0
  108. package/dist/types/services/task/state-machine/constants.d.ts +91 -0
  109. package/dist/types/services/task/state-machine/guards.d.ts +78 -0
  110. package/dist/types/services/task/state-machine/index.d.ts +13 -0
  111. package/dist/types/services/task/state-machine/types.d.ts +256 -0
  112. package/dist/types/services/task/state-machine/uiControlsComputer.d.ts +9 -0
  113. package/dist/types/services/task/taskDataNormalizer.d.ts +10 -0
  114. package/dist/types/services/task/types.d.ts +539 -88
  115. package/dist/types/services/task/voice/Voice.d.ts +183 -0
  116. package/dist/types/services/task/voice/WebRTC.d.ts +53 -0
  117. package/dist/types/types.d.ts +68 -0
  118. package/dist/types/webex.d.ts +1 -0
  119. package/dist/types.js +70 -0
  120. package/dist/types.js.map +1 -1
  121. package/dist/webex.js +14 -2
  122. package/dist/webex.js.map +1 -1
  123. package/package.json +14 -11
  124. package/src/cc.ts +91 -177
  125. package/src/constants.ts +13 -2
  126. package/src/index.ts +14 -5
  127. package/src/metrics/ai-docs/AGENTS.md +348 -0
  128. package/src/metrics/ai-docs/ARCHITECTURE.md +336 -0
  129. package/src/metrics/behavioral-events.ts +28 -14
  130. package/src/metrics/constants.ts +7 -8
  131. package/src/services/ApiAiAssistant.ts +2 -4
  132. package/src/services/agent/ai-docs/AGENTS.md +238 -0
  133. package/src/services/agent/ai-docs/ARCHITECTURE.md +302 -0
  134. package/src/services/ai-docs/AGENTS.md +384 -0
  135. package/src/services/config/Util.ts +2 -3
  136. package/src/services/config/ai-docs/AGENTS.md +253 -0
  137. package/src/services/config/ai-docs/ARCHITECTURE.md +424 -0
  138. package/src/services/config/types.ts +108 -20
  139. package/src/services/constants.ts +0 -1
  140. package/src/services/core/Err.ts +0 -1
  141. package/src/services/core/Utils.ts +90 -67
  142. package/src/services/core/ai-docs/AGENTS.md +379 -0
  143. package/src/services/core/ai-docs/ARCHITECTURE.md +696 -0
  144. package/src/services/core/aqm-reqs.ts +22 -100
  145. package/src/services/core/websocket/WebSocketManager.ts +4 -23
  146. package/src/services/core/websocket/types.ts +1 -1
  147. package/src/services/index.ts +1 -2
  148. package/src/services/task/Task.ts +785 -0
  149. package/src/services/task/TaskFactory.ts +55 -0
  150. package/src/services/task/TaskManager.ts +567 -633
  151. package/src/services/task/TaskUtils.ts +175 -31
  152. package/src/services/task/ai-docs/AGENTS.md +448 -0
  153. package/src/services/task/ai-docs/ARCHITECTURE.md +573 -0
  154. package/src/services/task/constants.ts +5 -4
  155. package/src/services/task/dialer.ts +1 -56
  156. package/src/services/task/digital/Digital.ts +95 -0
  157. package/src/services/task/state-machine/TaskStateMachine.ts +793 -0
  158. package/src/services/task/state-machine/actions.ts +409 -0
  159. package/src/services/task/state-machine/ai-docs/AGENTS.md +495 -0
  160. package/src/services/task/state-machine/ai-docs/ARCHITECTURE.md +1135 -0
  161. package/src/services/task/state-machine/constants.ts +150 -0
  162. package/src/services/task/state-machine/guards.ts +295 -0
  163. package/src/services/task/state-machine/index.ts +28 -0
  164. package/src/services/task/state-machine/types.ts +228 -0
  165. package/src/services/task/state-machine/uiControlsComputer.ts +529 -0
  166. package/src/services/task/taskDataNormalizer.ts +137 -0
  167. package/src/services/task/types.ts +641 -95
  168. package/src/services/task/voice/Voice.ts +1255 -0
  169. package/src/services/task/voice/WebRTC.ts +187 -0
  170. package/src/types.ts +88 -5
  171. package/src/utils/AGENTS.md +276 -0
  172. package/src/webex.js +2 -0
  173. package/test/unit/spec/cc.ts +59 -142
  174. package/test/unit/spec/logger-proxy.ts +70 -0
  175. package/test/unit/spec/services/ApiAiAssistant.ts +17 -0
  176. package/test/unit/spec/services/config/index.ts +26 -55
  177. package/test/unit/spec/services/core/Utils.ts +103 -52
  178. package/test/unit/spec/services/core/websocket/WebSocketManager.ts +48 -112
  179. package/test/unit/spec/services/core/websocket/connection-service.ts +5 -4
  180. package/test/unit/spec/services/task/AutoWrapup.ts +63 -0
  181. package/test/unit/spec/services/task/Task.ts +416 -0
  182. package/test/unit/spec/services/task/TaskFactory.ts +62 -0
  183. package/test/unit/spec/services/task/TaskManager.ts +781 -1735
  184. package/test/unit/spec/services/task/TaskUtils.ts +125 -0
  185. package/test/unit/spec/services/task/dialer.ts +112 -198
  186. package/test/unit/spec/services/task/digital/Digital.ts +105 -0
  187. package/test/unit/spec/services/task/state-machine/TaskStateMachine.ts +473 -0
  188. package/test/unit/spec/services/task/state-machine/guards.ts +288 -0
  189. package/test/unit/spec/services/task/state-machine/types.ts +18 -0
  190. package/test/unit/spec/services/task/state-machine/uiControlsComputer.ts +147 -0
  191. package/test/unit/spec/services/task/taskTestUtils.ts +87 -0
  192. package/test/unit/spec/services/task/voice/Voice.ts +587 -0
  193. package/test/unit/spec/services/task/voice/WebRTC.ts +242 -0
  194. package/umd/contact-center.min.js +2 -2
  195. package/umd/contact-center.min.js.map +1 -1
  196. package/dist/services/task/index.js +0 -1525
  197. package/dist/services/task/index.js.map +0 -1
  198. package/dist/types/services/task/index.d.ts +0 -650
  199. package/src/services/task/index.ts +0 -1801
  200. package/test/unit/spec/services/task/index.ts +0 -2184
@@ -1,6 +1,4 @@
1
- /// <reference types="node" />
2
- import { CallId } from '@webex/calling/dist/types/common/types';
3
- import EventEmitter from 'events';
1
+ import { TaskEventPayload } from './state-machine';
4
2
  import { Msg } from '../core/GlobalTypes';
5
3
  import AutoWrapup from './AutoWrapup';
6
4
  /**
@@ -8,6 +6,10 @@ import AutoWrapup from './AutoWrapup';
8
6
  * @public
9
7
  */
10
8
  export type TaskId = string;
9
+ /**
10
+ * Unique identifier for a call in the Webex calling system
11
+ */
12
+ export type CallId = string;
11
13
  /**
12
14
  * Defines the valid destination types for routing tasks within the contact center
13
15
  * Used to specify where a task should be directed
@@ -77,6 +79,22 @@ export declare const MEDIA_CHANNEL: {
77
79
  * @public
78
80
  */
79
81
  export type MEDIA_CHANNEL = Enum<typeof MEDIA_CHANNEL>;
82
+ /**
83
+ * Supported task channel types for UI control configuration
84
+ */
85
+ export declare const TASK_CHANNEL_TYPE: {
86
+ readonly VOICE: "voice";
87
+ readonly DIGITAL: "digital";
88
+ };
89
+ export type TaskChannelType = Enum<typeof TASK_CHANNEL_TYPE>;
90
+ /**
91
+ * Voice channel variants that toggle PSTN/WebRTC specific behaviors
92
+ */
93
+ export declare const VOICE_VARIANT: {
94
+ readonly PSTN: "pstn";
95
+ readonly WEBRTC: "webrtc";
96
+ };
97
+ export type VoiceVariant = Enum<typeof VOICE_VARIANT>;
80
98
  /**
81
99
  * Enumeration of all task-related events that can occur in the contact center system
82
100
  * These events represent different states and actions in the task lifecycle
@@ -181,6 +199,10 @@ export declare enum TASK_EVENTS {
181
199
  * ```
182
200
  */
183
201
  TASK_CONSULT_QUEUE_FAILED = "task:consultQueueFailed",
202
+ /**
203
+ * Triggered whenever task UI controls are recalculated
204
+ */
205
+ TASK_UI_CONTROLS_UPDATED = "task:ui-controls-updated",
184
206
  /**
185
207
  * Triggered when a consultation request is accepted
186
208
  * @example
@@ -258,6 +280,16 @@ export declare enum TASK_EVENTS {
258
280
  * ```
259
281
  */
260
282
  TASK_WRAPPEDUP = "task:wrappedup",
283
+ /**
284
+ * Triggered when recording is started
285
+ * @example
286
+ * ```typescript
287
+ * task.on(TASK_EVENTS.TASK_RECORDING_STARTED, (task: ITask) => {
288
+ * console.log('Recording started:', task.data.interactionId);
289
+ * });
290
+ * ```
291
+ */
292
+ TASK_RECORDING_STARTED = "task:recordingStarted",
261
293
  /**
262
294
  * Triggered when recording is paused
263
295
  * @example
@@ -471,6 +503,40 @@ export declare enum TASK_EVENTS {
471
503
  * ```
472
504
  */
473
505
  TASK_PARTICIPANT_LEFT_FAILED = "task:participantLeftFailed",
506
+ /**
507
+ * Triggered when agent initiates exit from conference
508
+ * @example
509
+ * ```typescript
510
+ * task.on(TASK_EVENTS.TASK_EXIT_CONFERENCE, (task: ITask) => {
511
+ * console.log('Exiting conference:', task.data.interactionId);
512
+ * // Handle conference exit initiation
513
+ * });
514
+ * ```
515
+ */
516
+ TASK_EXIT_CONFERENCE = "task:exitConference",
517
+ /**
518
+ * Triggered when agent initiates conference transfer
519
+ * @example
520
+ * ```typescript
521
+ * task.on(TASK_EVENTS.TASK_TRANSFER_CONFERENCE, (task: ITask) => {
522
+ * console.log('Transferring conference:', task.data.interactionId);
523
+ * // Handle conference transfer initiation
524
+ * });
525
+ * ```
526
+ */
527
+ TASK_TRANSFER_CONFERENCE = "task:transferConference",
528
+ /**
529
+ * Triggered when agent switches between consult call and main call.
530
+ * Use task.uiControls to determine current state and button visibility.
531
+ * @example
532
+ * ```typescript
533
+ * task.on(TASK_EVENTS.TASK_SWITCH_CALL, (task: ITask) => {
534
+ * console.log('Call switched:', task.data.interactionId);
535
+ * // Update UI based on task.uiControls.main.switch / task.uiControls.consult.switch
536
+ * });
537
+ * ```
538
+ */
539
+ TASK_SWITCH_CALL = "task:switchCall",
474
540
  /**
475
541
  * Triggered when a contact is merged
476
542
  * @example
@@ -492,24 +558,146 @@ export declare enum TASK_EVENTS {
492
558
  * });
493
559
  * ```
494
560
  */
495
- TASK_POST_CALL_ACTIVITY = "task:postCallActivity",
496
- /**
497
- * Triggered when a campaign preview contact is offered to the agent
498
- * @example
499
- * ```typescript
500
- * task.on(TASK_EVENTS.TASK_CAMPAIGN_PREVIEW_RESERVATION, (data: AgentContact) => {
501
- * console.log('Campaign preview contact received:', data.interactionId);
502
- * // Handle campaign preview reservation
503
- * });
504
- * ```
505
- */
506
- TASK_CAMPAIGN_PREVIEW_RESERVATION = "task:campaignPreviewReservation"
561
+ TASK_POST_CALL_ACTIVITY = "task:postCallActivity"
507
562
  }
508
563
  /**
509
564
  * Represents a customer interaction within the contact center system
510
565
  * Contains comprehensive details about an ongoing customer interaction
511
566
  * @public
512
567
  */
568
+ export interface CallAssociatedDatum {
569
+ /** Whether the field can be edited by the agent */
570
+ agentEditable: boolean;
571
+ /** Whether the field is visible to the agent */
572
+ agentViewable: boolean;
573
+ /** Display name for the field */
574
+ displayName: string;
575
+ /** Whether the field is global */
576
+ global: boolean;
577
+ /** Whether the field is secure */
578
+ isSecure: boolean;
579
+ /** Internal field name */
580
+ name: string;
581
+ /** Whether the field is reportable */
582
+ reportable: boolean;
583
+ /** Secure key identifier */
584
+ secureKeyId: string;
585
+ /** Secure key version */
586
+ secureKeyVersion: number;
587
+ /** Data type of the field */
588
+ type: string;
589
+ /** Field value */
590
+ value: string;
591
+ }
592
+ export type CallAssociatedData = Record<string, CallAssociatedDatum>;
593
+ export type CallAssociatedDetails = Record<string, string>;
594
+ export interface FlowParameter {
595
+ /** Parameter name */
596
+ name?: string;
597
+ /** Additional qualifier */
598
+ qualifier?: string;
599
+ /** Description of the parameter */
600
+ description?: string;
601
+ /** Data type of the value */
602
+ valueDataType?: string;
603
+ /** Value associated with the parameter */
604
+ value?: string;
605
+ }
606
+ export interface InteractionParticipant {
607
+ /** Unique participant identifier */
608
+ id: string;
609
+ /** Participant type label used by backend */
610
+ pType: string;
611
+ /** Friendly participant type */
612
+ type: string;
613
+ /** Whether the participant has joined */
614
+ hasJoined: boolean;
615
+ /** Whether the participant has left */
616
+ hasLeft: boolean;
617
+ /** Whether the participant is still in pre-dial */
618
+ isInPredial: boolean;
619
+ /** Optional caller identifier */
620
+ callerId?: string | null;
621
+ /** Whether auto-answer is enabled */
622
+ autoAnswerEnabled?: boolean;
623
+ /** Backchannel/bnr details */
624
+ bnrDetails?: unknown;
625
+ /** Channel identifier for the participant */
626
+ channelId?: string;
627
+ /** Current consult state */
628
+ consultState?: string | null;
629
+ /** Timestamp when consult started */
630
+ consultTimestamp?: number | null;
631
+ /** Current participant state */
632
+ currentState?: string | null;
633
+ /** Timestamp of the current state */
634
+ currentStateTimestamp?: number | null;
635
+ /** Device call identifier */
636
+ deviceCallId?: string | null;
637
+ /** Device identifier */
638
+ deviceId?: string | null;
639
+ /** Device type (AGENT_DN, BROWSER, etc.) */
640
+ deviceType?: string | null;
641
+ /** Dial number associated with participant */
642
+ dn?: string | null;
643
+ /** Whether participant is currently consulted */
644
+ isConsulted?: boolean;
645
+ /** Whether participant offer is active */
646
+ isOffered?: boolean;
647
+ /** Whether participant is in wrap-up */
648
+ isWrapUp?: boolean;
649
+ /** Whether participant completed wrap-up */
650
+ isWrappedUp?: boolean;
651
+ /** Timestamp of when participant joined */
652
+ joinTimestamp?: number | null;
653
+ /** Last updated timestamp */
654
+ lastUpdated?: number | null;
655
+ /** Friendly name of participant */
656
+ name?: string | null;
657
+ /** Queue identifier associated with participant */
658
+ queueId?: string;
659
+ /** Queue manager identifier */
660
+ queueMgrId?: string;
661
+ /** Session identifier */
662
+ sessionId?: string;
663
+ /** Site identifier */
664
+ siteId?: string;
665
+ /** Skill identifier */
666
+ skillId?: string | null;
667
+ /** Skill name */
668
+ skillName?: string | null;
669
+ /** Skill list for participant */
670
+ skills?: string[];
671
+ /** Team identifier */
672
+ teamId?: string;
673
+ /** Team name */
674
+ teamName?: string;
675
+ /** Timestamp for wrap-up */
676
+ wrapUpTimestamp?: number | null;
677
+ /** Additional metadata */
678
+ [key: string]: unknown;
679
+ }
680
+ export type InteractionParticipants = Record<string, InteractionParticipant>;
681
+ /**
682
+ * Media entry type from interaction.media
683
+ * Used for media state tracking in consult and conference scenarios
684
+ */
685
+ export type MediaEntry = {
686
+ /** Unique identifier for the media resource */
687
+ mediaResourceId: string;
688
+ /** Type of media channel */
689
+ mediaType: MEDIA_CHANNEL;
690
+ /** Media manager handling this media */
691
+ mediaMgr: string;
692
+ /** List of participant identifiers */
693
+ participants: string[];
694
+ /** Type of media (e.g., 'mainCall', 'consult') */
695
+ mType: string;
696
+ /** Indicates if media is on hold */
697
+ isHold: boolean;
698
+ /** Timestamp when media was put on hold */
699
+ holdTimestamp: number | null;
700
+ };
513
701
  export type Interaction = {
514
702
  /** Indicates if the interaction is managed by Flow Control */
515
703
  isFcManaged: boolean;
@@ -524,7 +712,11 @@ export type Interaction = {
524
712
  /** Current virtual team handling the interaction */
525
713
  currentVTeam: string;
526
714
  /** List of participants in the interaction */
527
- participants: any;
715
+ participants: InteractionParticipants;
716
+ /** Detailed call associated data */
717
+ callAssociatedData?: CallAssociatedData;
718
+ /** Simplified call associated key/value pairs */
719
+ callAssociatedDetails?: CallAssociatedDetails;
528
720
  /** Unique identifier for the interaction */
529
721
  interactionId: string;
530
722
  /** Organization identifier */
@@ -533,7 +725,18 @@ export type Interaction = {
533
725
  createdTimestamp?: number;
534
726
  /** Indicates if wrap-up assistance is enabled */
535
727
  isWrapUpAssist?: boolean;
536
- /** Detailed call processing information and metadata */
728
+ /** Identifier of parent interaction if applicable */
729
+ parentInteractionId?: string;
730
+ /** Indicates if media is forked for this interaction */
731
+ isMediaForked?: boolean;
732
+ /** Retroactive flow properties returned by backend */
733
+ flowProperties?: Record<string, unknown> | null;
734
+ /** Media specific properties returned by backend */
735
+ mediaProperties?: Record<string, unknown> | null;
736
+ /**
737
+ * Detailed call processing information and metadata.
738
+ * Mirrors the callProcessingDetails section described in Webex Contact Center Agent Contact payloads.
739
+ */
537
740
  callProcessingDetails: {
538
741
  /** Name of the Queue Manager handling this interaction */
539
742
  QMgrName: string;
@@ -551,20 +754,24 @@ export type Interaction = {
551
754
  QueueId: string;
552
755
  /** Virtual team identifier */
553
756
  vteamId: string;
554
- /** Indicates if pause/resume functionality is enabled */
555
- pauseResumeEnabled?: string;
757
+ /** Agent capability for pause/resume on this interaction */
758
+ pauseResumeEnabled?: boolean;
556
759
  /** Duration of pause in seconds */
557
760
  pauseDuration?: string;
558
- /** Indicates if the interaction is currently paused */
559
- isPaused?: string;
560
- /** Indicates if recording is in progress */
561
- recordInProgress?: string;
562
- /** Indicates if recording has started */
563
- recordingStarted?: string;
761
+ /** Legacy pause indicator (recordInProgress=false is the active pause signal) */
762
+ isPaused?: boolean;
763
+ /** Recording is actively capturing audio right now */
764
+ recordInProgress?: boolean;
765
+ /** Recording was started for this interaction (may be paused) */
766
+ recordingStarted?: boolean;
767
+ /** Customer geographic region */
768
+ customerRegion?: string;
769
+ /** Flow tag identifier */
770
+ flowTagId?: string;
564
771
  /** Indicates if Consult to Queue is in progress */
565
- ctqInProgress?: string;
772
+ ctqInProgress?: boolean;
566
773
  /** Indicates if outdial transfer to queue is enabled */
567
- outdialTransferToQueueEnabled?: string;
774
+ outdialTransferToQueueEnabled?: boolean;
568
775
  /** IVR conversation transcript */
569
776
  convIvrTranscript?: string;
570
777
  /** Customer's name */
@@ -654,56 +861,54 @@ export type Interaction = {
654
861
  };
655
862
  /** Main interaction identifier for related interactions */
656
863
  mainInteractionId?: string;
864
+ /** Timestamp when interaction entered queue */
865
+ queuedTimestamp?: number | null;
657
866
  /** Media-specific information for the interaction */
658
- media: Record<string, {
659
- /** Unique identifier for the media resource */
660
- mediaResourceId: string;
661
- /** Type of media channel */
662
- mediaType: MEDIA_CHANNEL;
663
- /** Media manager handling this media */
664
- mediaMgr: string;
665
- /** List of participant identifiers */
666
- participants: string[];
667
- /** Type of media */
668
- mType: string;
669
- /** Indicates if media is on hold */
670
- isHold: boolean;
671
- /** Timestamp when media was put on hold */
672
- holdTimestamp: number | null;
673
- }>;
867
+ media: Record<string, MediaEntry>;
674
868
  /** Owner of the interaction */
675
869
  owner: string;
676
870
  /** Primary media channel for the interaction */
677
- mediaChannel: MEDIA_CHANNEL;
871
+ mediaChannel: string;
678
872
  /** Direction information for the contact */
679
873
  contactDirection: {
680
874
  type: string;
681
875
  };
682
876
  /** Type of outbound interaction */
683
877
  outboundType?: string;
878
+ /** Optional workflow manager identifier */
879
+ workflowManager?: string | null;
684
880
  /** Parameters passed through the call flow */
685
- callFlowParams: Record<string, {
686
- /** Name of the parameter */
687
- name: string;
688
- /** Qualifier for the parameter */
689
- qualifier: string;
690
- /** Description of the parameter */
691
- description: string;
692
- /** Data type of the parameter value */
693
- valueDataType: string;
694
- /** Value of the parameter */
695
- value: string;
696
- }>;
881
+ callFlowParams?: Record<string, FlowParameter>;
697
882
  };
698
883
  /**
699
- * Task payload containing detailed information about a contact center task
700
- * This structure encapsulates all relevant data for task management
884
+ * Task payload mirroring the Agent Contact event payload from Webex Contact Center
885
+ * (developer.webex.com). Arrives on AGENT_* websocket events and is the source of truth
886
+ * for UI/state machine updates.
701
887
  * @public
702
888
  */
889
+ export type RealtimeTranscription = {
890
+ agentId: string;
891
+ orgId: string;
892
+ notifType: string;
893
+ notifDetails: {
894
+ actionEvent: string;
895
+ };
896
+ data: {
897
+ role: 'AGENT' | 'CALLER';
898
+ utteranceId: string;
899
+ conversationId: string;
900
+ publishTimestamp: number;
901
+ messageId: string;
902
+ isFinal: boolean;
903
+ languageCode: string;
904
+ orgId: string;
905
+ content: string;
906
+ };
907
+ };
703
908
  export type TaskData = {
704
- /** Unique identifier for the media resource handling this task */
909
+ /** Primary media resource identifier for the active leg (matches interaction.media[].mediaResourceId) */
705
910
  mediaResourceId: string;
706
- /** Type of event that triggered this task data */
911
+ /** Agent event name from the websocket stream (e.g., AGENT_CONTACT_ASSIGNED) */
707
912
  eventType: string;
708
913
  /** Timestamp when the event occurred */
709
914
  eventTime?: number;
@@ -713,7 +918,7 @@ export type TaskData = {
713
918
  destAgentId: string;
714
919
  /** Unique tracking identifier for the task */
715
920
  trackingId: string;
716
- /** Media resource identifier for consultation operations */
921
+ /** Media resource identifier for consultation leg when present */
717
922
  consultMediaResourceId: string;
718
923
  /** Detailed interaction information */
719
924
  interaction: Interaction;
@@ -725,7 +930,7 @@ export type TaskData = {
725
930
  toOwner?: boolean;
726
931
  /** Identifier for child interaction in consult/transfer scenarios */
727
932
  childInteractionId?: string;
728
- /** Unique identifier for the interaction */
933
+ /** Interaction/contact identifier from backend (same as interaction.interactionId) */
729
934
  interactionId: string;
730
935
  /** Organization identifier */
731
936
  orgId: string;
@@ -735,7 +940,7 @@ export type TaskData = {
735
940
  queueMgr: string;
736
941
  /** Name of the queue where task is queued */
737
942
  queueName?: string;
738
- /** Type of the task */
943
+ /** Task/interaction type returned by the platform (routing/monitoring/etc.) */
739
944
  type: string;
740
945
  /** Timeout value for RONA (Redirection on No Answer) in seconds */
741
946
  ronaTimeout?: number;
@@ -771,11 +976,93 @@ export type TaskData = {
771
976
  reservedAgentChannelId?: string;
772
977
  /** Indicates if wrap-up is required for this task */
773
978
  wrapUpRequired?: boolean;
979
+ /**
980
+ * Current consultation status derived from state machine
981
+ * Values: CONSULT_INITIATED, CONSULT_ACCEPTED, BEING_CONSULTED,
982
+ * BEING_CONSULTED_ACCEPTED, CONNECTED, CONFERENCE, CONSULT_COMPLETED
983
+ */
984
+ consultStatus?: string;
985
+ /**
986
+ * Indicates if consultation is in progress (state machine: CONSULTING)
987
+ */
988
+ isConsultInProgress?: boolean;
989
+ /**
990
+ * Indicates if the task is incoming for the active agent
991
+ */
992
+ isIncomingTask?: boolean;
993
+ /**
994
+ * Indicates if the task is on hold (state machine: HELD)
995
+ */
996
+ isOnHold?: boolean;
997
+ /**
998
+ * Indicates if customer is currently in the call
999
+ * Derived from participants in main media
1000
+ */
1001
+ isCustomerInCall?: boolean;
1002
+ /**
1003
+ * Count of conference participants (agents only)
1004
+ * Used for determining if max participants reached
1005
+ */
1006
+ conferenceParticipantsCount?: number;
1007
+ /**
1008
+ * Indicates if this is a secondary agent (consulted party)
1009
+ */
1010
+ isSecondaryAgent?: boolean;
1011
+ /**
1012
+ * Indicates if this is a secondary EP-DN agent (telephony consult to external)
1013
+ */
1014
+ isSecondaryEpDnAgent?: boolean;
1015
+ /**
1016
+ * Task state for MPC (Multi-Party Conference) scenarios
1017
+ * Maps participant consultState to task state
1018
+ */
1019
+ mpcState?: string;
774
1020
  /** Indicates if auto-answer is in progress for this task */
775
1021
  isAutoAnswering?: boolean;
776
1022
  /** Indicates if wrap-up is required for this task */
777
1023
  agentsPendingWrapUp?: string[];
778
1024
  };
1025
+ export type TaskUIControlState = {
1026
+ isVisible: boolean;
1027
+ isEnabled: boolean;
1028
+ };
1029
+ /**
1030
+ * UI control representation for a single interaction leg.
1031
+ */
1032
+ export type InteractionUIControls = {
1033
+ accept: TaskUIControlState;
1034
+ decline: TaskUIControlState;
1035
+ hold: TaskUIControlState;
1036
+ transfer: TaskUIControlState;
1037
+ consult: TaskUIControlState;
1038
+ end: TaskUIControlState;
1039
+ recording: TaskUIControlState;
1040
+ mute: TaskUIControlState;
1041
+ consultTransfer: TaskUIControlState;
1042
+ endConsult: TaskUIControlState;
1043
+ conference: TaskUIControlState;
1044
+ exitConference: TaskUIControlState;
1045
+ transferConference: TaskUIControlState;
1046
+ mergeToConference: TaskUIControlState;
1047
+ wrapup: TaskUIControlState;
1048
+ switch: TaskUIControlState;
1049
+ };
1050
+ export type TaskUILeg = 'main' | 'consult';
1051
+ /**
1052
+ * UI controls surfaced to task consumers.
1053
+ * Consumers should read controls from the per-leg surfaces and use `activeLeg`
1054
+ * to determine which one is currently interactive.
1055
+ */
1056
+ export type TaskUIControls = {
1057
+ main: InteractionUIControls;
1058
+ consult: InteractionUIControls;
1059
+ activeLeg: TaskUILeg;
1060
+ };
1061
+ /**
1062
+ * Helper class for managing task action control state
1063
+ * Tracks visibility and enabled state for task actions that can be executed
1064
+ * @public
1065
+ */
779
1066
  /**
780
1067
  * Type representing an agent contact message within the contact center system
781
1068
  * Contains comprehensive interaction and task related details for agent operations
@@ -986,6 +1273,14 @@ export type TransferPayload = {
986
1273
  /** Type of the transfer destination */
987
1274
  destinationType: DestinationType;
988
1275
  };
1276
+ /**
1277
+ * Options for configuring transfer behavior
1278
+ * @public
1279
+ */
1280
+ export type TransferOptions = {
1281
+ /** Additional transfer configuration options */
1282
+ [key: string]: unknown;
1283
+ };
989
1284
  /**
990
1285
  * API payload for ending a consultation
991
1286
  * This is the actual payload that is sent to the developer API
@@ -1057,17 +1352,6 @@ export type DialerPayload = {
1057
1352
  /** The Outdial ANI number that will be used while making a call to the customer. */
1058
1353
  origin: string;
1059
1354
  };
1060
- /**
1061
- * Payload for campaign preview contact operations (accept, skip, remove)
1062
- * @public
1063
- */
1064
- export type PreviewContactPayload = {
1065
- /** The interaction ID from the campaign reservation */
1066
- interactionId: string;
1067
- /** The campaign name (not a UUID). Available from the reservation event at
1068
- * `task.data.interaction.callProcessingDetails.campaignId` or `task.data.campaignId`. */
1069
- campaignId: string;
1070
- };
1071
1355
  /**
1072
1356
  * Data structure for cleaning up contact resources
1073
1357
  * @public
@@ -1101,6 +1385,19 @@ export type ContactCleanupData = {
1101
1385
  type: string;
1102
1386
  };
1103
1387
  };
1388
+ /**
1389
+ * Boolean-like fields in callProcessingDetails that may arrive as strings.
1390
+ * Used by taskDataNormalizer to coerce payloads to actual booleans.
1391
+ */
1392
+ export type CallProcessingBooleanKey = 'recordingStarted' | 'recordInProgress' | 'isPaused' | 'pauseResumeEnabled' | 'ctqInProgress' | 'outdialTransferToQueueEnabled' | 'taskToBeSelfServiced' | 'CONTINUE_RECORDING_ON_TRANSFER' | 'isParked' | 'participantInviteTimeout' | 'checkAgentAvailability';
1393
+ /**
1394
+ * Interaction-level boolean fields that may arrive as strings from backend payloads.
1395
+ */
1396
+ export type InteractionBooleanKey = 'isFcManaged' | 'isMediaForked' | 'isTerminated';
1397
+ /**
1398
+ * Participant boolean fields that may arrive as strings and need normalization.
1399
+ */
1400
+ export type ParticipantBooleanKey = 'autoAnswerEnabled' | 'hasJoined' | 'hasLeft' | 'isConsulted' | 'isInPredial' | 'isOffered' | 'isWrapUp' | 'isWrappedUp';
1104
1401
  /**
1105
1402
  * Response type for task public methods
1106
1403
  * Can be an {@link AgentContact} object containing updated task state,
@@ -1108,11 +1405,32 @@ export type ContactCleanupData = {
1108
1405
  * @public
1109
1406
  */
1110
1407
  export type TaskResponse = AgentContact | Error | void;
1408
+ /**
1409
+ * Payload shape used by consult conference helper utilities.
1410
+ */
1411
+ export type consultConferencePayloadData = {
1412
+ agentId?: string;
1413
+ destinationType?: string;
1414
+ destAgentId?: string;
1415
+ };
1416
+ /**
1417
+ * Minimal event-emitter contract exposed to SDK consumers.
1418
+ * Defined here so that consumers do NOT need `@types/node` in their tsconfig.
1419
+ * The runtime Task class still extends Node's EventEmitter (via ampersand-events),
1420
+ * which satisfies this interface at runtime.
1421
+ * @public
1422
+ */
1423
+ export interface IEventEmitter {
1424
+ on(event: string, listener: (...args: any[]) => void): this;
1425
+ off(event: string, listener: (...args: any[]) => void): this;
1426
+ once(event: string, listener: (...args: any[]) => void): this;
1427
+ emit(event: string, ...args: any[]): boolean;
1428
+ }
1111
1429
  /**
1112
1430
  * Interface for managing task-related operations in the contact center
1113
- * Extends EventEmitter to support event-driven task updates
1431
+ * Extends IEventEmitter to support event-driven task updates
1114
1432
  */
1115
- export interface ITask extends EventEmitter {
1433
+ export interface ITask extends IEventEmitter {
1116
1434
  /**
1117
1435
  * Event data received in the Contact Center events.
1118
1436
  * Contains detailed task information including interaction details, media resources,
@@ -1129,6 +1447,13 @@ export interface ITask extends EventEmitter {
1129
1447
  * as defined in {@link AutoWrapup}
1130
1448
  */
1131
1449
  autoWrapup?: AutoWrapup;
1450
+ /**
1451
+ * Latest UI controls derived from the state machine.
1452
+ * Each control has `isVisible` and `isEnabled` flags computed from current task state.
1453
+ * Subscribe to {@link TASK_EVENTS.TASK_UI_CONTROLS_UPDATED} for change notifications.
1454
+ */
1455
+ readonly uiControls: TaskUIControls;
1456
+ state?: any;
1132
1457
  /**
1133
1458
  * Cancels the auto-wrapup timer for the task.
1134
1459
  * This method stops the auto-wrapup process if it is currently active.
@@ -1148,7 +1473,7 @@ export interface ITask extends EventEmitter {
1148
1473
  * @returns Updated task instance
1149
1474
  * @ignore
1150
1475
  */
1151
- updateTaskData(newData: TaskData): ITask;
1476
+ updateTaskData(newData: TaskData): void;
1152
1477
  /**
1153
1478
  * Answers or accepts an incoming task.
1154
1479
  * Once accepted, the task will be assigned to the agent and trigger a {@link TASK_EVENTS.TASK_ASSIGNED} event.
@@ -1269,17 +1594,7 @@ export interface ITask extends EventEmitter {
1269
1594
  * await task.transfer({ to: "queueId", destinationType: "queue" });
1270
1595
  * ```
1271
1596
  */
1272
- transfer(transferPayload: TransferPayLoad): Promise<TaskResponse>;
1273
- /**
1274
- * Transfers the task after consultation.
1275
- * @param consultTransferPayload - Details for consult transfer (optional)
1276
- * @returns Promise<TaskResponse>
1277
- * @example
1278
- * ```typescript
1279
- * await task.consultTransfer({ to: "agentId", destinationType: "agent" });
1280
- * ```
1281
- */
1282
- consultTransfer(consultTransferPayload?: ConsultTransferPayLoad): Promise<TaskResponse>;
1597
+ transfer(transferPayload: TransferPayLoad, options?: TransferOptions): Promise<TaskResponse>;
1283
1598
  /**
1284
1599
  * Initiates a consult conference (merge consult call with main call).
1285
1600
  * @returns Promise<TaskResponse>
@@ -1307,6 +1622,18 @@ export interface ITask extends EventEmitter {
1307
1622
  * ```
1308
1623
  */
1309
1624
  transferConference(): Promise<TaskResponse>;
1625
+ /**
1626
+ * Toggles between consult call and main call during consulting.
1627
+ * If on consult leg, switches to main call (holds consult).
1628
+ * If on main call, switches to consult (resumes consult).
1629
+ * Only available when in CONSULTING state.
1630
+ * @returns Promise<TaskResponse>
1631
+ * @example
1632
+ * ```typescript
1633
+ * await task.switchCall();
1634
+ * ```
1635
+ */
1636
+ switchCall(): Promise<TaskResponse>;
1310
1637
  /**
1311
1638
  * Toggles mute/unmute for the local audio stream during a WebRTC task.
1312
1639
  * @returns Promise<void>
@@ -1317,3 +1644,127 @@ export interface ITask extends EventEmitter {
1317
1644
  */
1318
1645
  toggleMute(): Promise<void>;
1319
1646
  }
1647
+ /**
1648
+ * Interface for managing digital channel task operations in the contact center
1649
+ * Digital channels (chat, email, social, SMS) have a simpler interface than voice
1650
+ * Extends ITask but overrides updateTaskData to return IDigital
1651
+ * @public
1652
+ */
1653
+ export interface IDigital extends Omit<ITask, 'updateTaskData'> {
1654
+ /**
1655
+ * Updates the task data
1656
+ * @param newData - Updated task data
1657
+ * @param shouldOverwrite - Whether to completely replace existing data
1658
+ * @returns Updated Digital task instance
1659
+ */
1660
+ updateTaskData(newData: TaskData, shouldOverwrite?: boolean): IDigital;
1661
+ }
1662
+ /**
1663
+ * Interface for managing voice/telephony task operations in the contact center
1664
+ * Extends ITask with voice-specific functionality for hold/resume operations
1665
+ * @public
1666
+ */
1667
+ export interface IVoice extends ITask {
1668
+ /**
1669
+ * Toggles hold/resume state for a voice task.
1670
+ * If the task is currently on hold, it will be resumed.
1671
+ * If the task is active, it will be placed on hold.
1672
+ * @returns Promise<TaskResponse>
1673
+ * @example
1674
+ * ```typescript
1675
+ * await voiceTask.holdResume();
1676
+ * ```
1677
+ */
1678
+ holdResume(): Promise<TaskResponse>;
1679
+ }
1680
+ /**
1681
+ * Configuration options for voice task UI controls
1682
+ */
1683
+ export type VoiceUIControlOptions = {
1684
+ isEndTaskEnabled?: boolean;
1685
+ isEndConsultEnabled?: boolean;
1686
+ voiceVariant?: VoiceVariant;
1687
+ isRecordingEnabled?: boolean;
1688
+ };
1689
+ /**
1690
+ * Participant information for UI display
1691
+ */
1692
+ export type Participant = {
1693
+ id: string;
1694
+ name?: string;
1695
+ pType?: string;
1696
+ };
1697
+ /**
1698
+ * @deprecated Use Participant instead
1699
+ */
1700
+ export type TaskAccessorParticipant = Participant;
1701
+ export interface IWebRTC extends IVoice {
1702
+ /**
1703
+ * This method is used to mute/unmute the call.
1704
+ * @returns Promise<void>
1705
+ * @example
1706
+ * ```typescript
1707
+ * task.toggleMute();
1708
+ * ```
1709
+ */
1710
+ toggleMute(): Promise<void>;
1711
+ /**
1712
+ * Decline the incoming task for Browser Login
1713
+ *
1714
+ * @example
1715
+ * ```
1716
+ * task.decline();
1717
+ * ```
1718
+ */
1719
+ decline(): Promise<TaskResponse>;
1720
+ /**
1721
+ * This method is used to unregister the web call listeners.
1722
+ * @returns void
1723
+ * @example
1724
+ * ```typescript
1725
+ * task.unregisterWebCallListeners();
1726
+ * ```
1727
+ */
1728
+ unregisterWebCallListeners(): void;
1729
+ }
1730
+ export type WebSocketPayload = TaskData & {
1731
+ type: string;
1732
+ mediaResourceId?: string;
1733
+ reason?: string;
1734
+ /**
1735
+ * Optional real-time transcript chunk payload.
1736
+ * Present on REAL_TIME_TRANSCRIPTION notifications.
1737
+ */
1738
+ data?: RealtimeTranscription['data'];
1739
+ };
1740
+ export type WebSocketMessage = {
1741
+ keepalive?: 'true' | 'false' | boolean;
1742
+ type?: string;
1743
+ data: WebSocketPayload;
1744
+ };
1745
+ /**
1746
+ * Actions to be performed after handling an event
1747
+ *
1748
+ * These actions represent TaskManager-level concerns (task collection lifecycle,
1749
+ * resource cleanup) rather than task-level state machine concerns. The separation
1750
+ * ensures proper responsibility:
1751
+ * - TaskManager: Collection management, metrics, cleanup
1752
+ * - State Machine: Task state transitions, event emissions, UI controls
1753
+ */
1754
+ export interface TaskEventActions {
1755
+ task?: ITask;
1756
+ }
1757
+ /**
1758
+ * Context for processing an event
1759
+ *
1760
+ * Contains all information needed to process a WebSocket event:
1761
+ * - Event type and payload from the backend
1762
+ * - Task instance (if exists)
1763
+ * - Pre-mapped state machine event (if applicable)
1764
+ */
1765
+ export interface EventContext {
1766
+ eventType: string;
1767
+ payload: WebSocketPayload;
1768
+ task?: ITask;
1769
+ stateMachineEvent?: TaskEventPayload | null;
1770
+ }