@webex/contact-center 3.12.0-next.72 → 3.12.0-next.74

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 (188) 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 +53 -38
  24. package/dist/cc.js.map +1 -1
  25. package/dist/config.js +6 -0
  26. package/dist/config.js.map +1 -1
  27. package/dist/constants.js +14 -1
  28. package/dist/constants.js.map +1 -1
  29. package/dist/index.js +13 -5
  30. package/dist/index.js.map +1 -1
  31. package/dist/metrics/behavioral-events.js +26 -0
  32. package/dist/metrics/behavioral-events.js.map +1 -1
  33. package/dist/metrics/constants.js +9 -3
  34. package/dist/metrics/constants.js.map +1 -1
  35. package/dist/services/ApiAiAssistant.js +74 -3
  36. package/dist/services/ApiAiAssistant.js.map +1 -1
  37. package/dist/services/config/Util.js +2 -2
  38. package/dist/services/config/Util.js.map +1 -1
  39. package/dist/services/config/types.js +25 -9
  40. package/dist/services/config/types.js.map +1 -1
  41. package/dist/services/core/Utils.js +74 -27
  42. package/dist/services/core/Utils.js.map +1 -1
  43. package/dist/services/core/websocket/WebSocketManager.js +2 -1
  44. package/dist/services/core/websocket/WebSocketManager.js.map +1 -1
  45. package/dist/services/core/websocket/types.js.map +1 -1
  46. package/dist/services/index.js +1 -1
  47. package/dist/services/index.js.map +1 -1
  48. package/dist/services/task/Task.js +688 -0
  49. package/dist/services/task/Task.js.map +1 -0
  50. package/dist/services/task/TaskFactory.js +45 -0
  51. package/dist/services/task/TaskFactory.js.map +1 -0
  52. package/dist/services/task/TaskManager.js +725 -612
  53. package/dist/services/task/TaskManager.js.map +1 -1
  54. package/dist/services/task/TaskUtils.js +162 -26
  55. package/dist/services/task/TaskUtils.js.map +1 -1
  56. package/dist/services/task/constants.js +6 -1
  57. package/dist/services/task/constants.js.map +1 -1
  58. package/dist/services/task/digital/Digital.js +77 -0
  59. package/dist/services/task/digital/Digital.js.map +1 -0
  60. package/dist/services/task/state-machine/TaskStateMachine.js +837 -0
  61. package/dist/services/task/state-machine/TaskStateMachine.js.map +1 -0
  62. package/dist/services/task/state-machine/actions.js +543 -0
  63. package/dist/services/task/state-machine/actions.js.map +1 -0
  64. package/dist/services/task/state-machine/constants.js +161 -0
  65. package/dist/services/task/state-machine/constants.js.map +1 -0
  66. package/dist/services/task/state-machine/guards.js +340 -0
  67. package/dist/services/task/state-machine/guards.js.map +1 -0
  68. package/dist/services/task/state-machine/index.js +53 -0
  69. package/dist/services/task/state-machine/index.js.map +1 -0
  70. package/dist/services/task/state-machine/types.js +54 -0
  71. package/dist/services/task/state-machine/types.js.map +1 -0
  72. package/dist/services/task/state-machine/uiControlsComputer.js +553 -0
  73. package/dist/services/task/state-machine/uiControlsComputer.js.map +1 -0
  74. package/dist/services/task/taskDataNormalizer.js +99 -0
  75. package/dist/services/task/taskDataNormalizer.js.map +1 -0
  76. package/dist/services/task/types.js +168 -16
  77. package/dist/services/task/types.js.map +1 -1
  78. package/dist/services/task/voice/Voice.js +1042 -0
  79. package/dist/services/task/voice/Voice.js.map +1 -0
  80. package/dist/services/task/voice/WebRTC.js +149 -0
  81. package/dist/services/task/voice/WebRTC.js.map +1 -0
  82. package/dist/types/cc.d.ts +19 -18
  83. package/dist/types/config.d.ts +6 -0
  84. package/dist/types/constants.d.ts +14 -1
  85. package/dist/types/index.d.ts +11 -5
  86. package/dist/types/metrics/constants.d.ts +7 -1
  87. package/dist/types/services/ApiAiAssistant.d.ts +11 -3
  88. package/dist/types/services/config/types.d.ts +113 -9
  89. package/dist/types/services/core/Utils.d.ts +23 -10
  90. package/dist/types/services/core/websocket/WebSocketManager.d.ts +1 -0
  91. package/dist/types/services/core/websocket/types.d.ts +1 -1
  92. package/dist/types/services/index.d.ts +1 -1
  93. package/dist/types/services/task/Task.d.ts +157 -0
  94. package/dist/types/services/task/TaskFactory.d.ts +12 -0
  95. package/dist/types/services/task/TaskUtils.d.ts +46 -2
  96. package/dist/types/services/task/constants.d.ts +5 -0
  97. package/dist/types/services/task/digital/Digital.d.ts +22 -0
  98. package/dist/types/services/task/state-machine/TaskStateMachine.d.ts +1144 -0
  99. package/dist/types/services/task/state-machine/actions.d.ts +10 -0
  100. package/dist/types/services/task/state-machine/constants.d.ts +107 -0
  101. package/dist/types/services/task/state-machine/guards.d.ts +90 -0
  102. package/dist/types/services/task/state-machine/index.d.ts +13 -0
  103. package/dist/types/services/task/state-machine/types.d.ts +267 -0
  104. package/dist/types/services/task/state-machine/uiControlsComputer.d.ts +9 -0
  105. package/dist/types/services/task/taskDataNormalizer.d.ts +10 -0
  106. package/dist/types/services/task/types.d.ts +551 -78
  107. package/dist/types/services/task/voice/Voice.d.ts +184 -0
  108. package/dist/types/services/task/voice/WebRTC.d.ts +53 -0
  109. package/dist/types/types.d.ts +92 -0
  110. package/dist/types/webex.d.ts +1 -0
  111. package/dist/types.js +85 -0
  112. package/dist/types.js.map +1 -1
  113. package/dist/webex.js +14 -2
  114. package/dist/webex.js.map +1 -1
  115. package/package.json +15 -12
  116. package/src/cc.ts +63 -43
  117. package/src/config.ts +6 -0
  118. package/src/constants.ts +14 -1
  119. package/src/index.ts +14 -5
  120. package/src/metrics/ai-docs/AGENTS.md +348 -0
  121. package/src/metrics/ai-docs/ARCHITECTURE.md +336 -0
  122. package/src/metrics/behavioral-events.ts +28 -0
  123. package/src/metrics/constants.ts +9 -4
  124. package/src/services/ApiAiAssistant.ts +104 -3
  125. package/src/services/agent/ai-docs/AGENTS.md +238 -0
  126. package/src/services/agent/ai-docs/ARCHITECTURE.md +302 -0
  127. package/src/services/ai-docs/AGENTS.md +384 -0
  128. package/src/services/config/Util.ts +2 -2
  129. package/src/services/config/ai-docs/AGENTS.md +253 -0
  130. package/src/services/config/ai-docs/ARCHITECTURE.md +424 -0
  131. package/src/services/config/types.ts +116 -10
  132. package/src/services/core/Utils.ts +85 -34
  133. package/src/services/core/ai-docs/AGENTS.md +379 -0
  134. package/src/services/core/ai-docs/ARCHITECTURE.md +696 -0
  135. package/src/services/core/websocket/WebSocketManager.ts +2 -0
  136. package/src/services/core/websocket/types.ts +1 -1
  137. package/src/services/index.ts +1 -1
  138. package/src/services/task/Task.ts +837 -0
  139. package/src/services/task/TaskFactory.ts +55 -0
  140. package/src/services/task/TaskManager.ts +738 -697
  141. package/src/services/task/TaskUtils.ts +205 -25
  142. package/src/services/task/ai-docs/AGENTS.md +455 -0
  143. package/src/services/task/ai-docs/ARCHITECTURE.md +585 -0
  144. package/src/services/task/constants.ts +5 -0
  145. package/src/services/task/digital/Digital.ts +95 -0
  146. package/src/services/task/state-machine/TaskStateMachine.ts +1077 -0
  147. package/src/services/task/state-machine/actions.ts +685 -0
  148. package/src/services/task/state-machine/ai-docs/AGENTS.md +495 -0
  149. package/src/services/task/state-machine/ai-docs/ARCHITECTURE.md +1135 -0
  150. package/src/services/task/state-machine/constants.ts +172 -0
  151. package/src/services/task/state-machine/guards.ts +406 -0
  152. package/src/services/task/state-machine/index.ts +28 -0
  153. package/src/services/task/state-machine/types.ts +241 -0
  154. package/src/services/task/state-machine/uiControlsComputer.ts +867 -0
  155. package/src/services/task/taskDataNormalizer.ts +137 -0
  156. package/src/services/task/types.ts +654 -85
  157. package/src/services/task/voice/Voice.ts +1267 -0
  158. package/src/services/task/voice/WebRTC.ts +187 -0
  159. package/src/types.ts +112 -1
  160. package/src/utils/AGENTS.md +276 -0
  161. package/src/webex.js +2 -0
  162. package/test/unit/spec/cc.ts +133 -3
  163. package/test/unit/spec/logger-proxy.ts +70 -0
  164. package/test/unit/spec/services/ApiAiAssistant.ts +122 -17
  165. package/test/unit/spec/services/WebCallingService.ts +7 -1
  166. package/test/unit/spec/services/config/index.ts +27 -27
  167. package/test/unit/spec/services/core/Utils.ts +335 -1
  168. package/test/unit/spec/services/core/websocket/WebSocketManager.ts +66 -40
  169. package/test/unit/spec/services/task/AutoWrapup.ts +63 -0
  170. package/test/unit/spec/services/task/Task.ts +477 -0
  171. package/test/unit/spec/services/task/TaskFactory.ts +62 -0
  172. package/test/unit/spec/services/task/TaskManager.ts +821 -1936
  173. package/test/unit/spec/services/task/TaskUtils.ts +206 -0
  174. package/test/unit/spec/services/task/digital/Digital.ts +105 -0
  175. package/test/unit/spec/services/task/state-machine/TaskStateMachine.ts +1825 -0
  176. package/test/unit/spec/services/task/state-machine/guards.ts +479 -0
  177. package/test/unit/spec/services/task/state-machine/types.ts +18 -0
  178. package/test/unit/spec/services/task/state-machine/uiControlsComputer.ts +2020 -0
  179. package/test/unit/spec/services/task/taskTestUtils.ts +87 -0
  180. package/test/unit/spec/services/task/voice/Voice.ts +631 -0
  181. package/test/unit/spec/services/task/voice/WebRTC.ts +235 -0
  182. package/umd/contact-center.min.js +2 -2
  183. package/umd/contact-center.min.js.map +1 -1
  184. package/dist/services/task/index.js +0 -1530
  185. package/dist/services/task/index.js.map +0 -1
  186. package/dist/types/services/task/index.d.ts +0 -650
  187. package/src/services/task/index.ts +0 -1806
  188. package/test/unit/spec/services/task/index.ts +0 -2205
@@ -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
@@ -493,6 +559,16 @@ export declare enum TASK_EVENTS {
493
559
  * ```
494
560
  */
495
561
  TASK_POST_CALL_ACTIVITY = "task:postCallActivity",
562
+ /**
563
+ * Triggered when a multi-login task update should hydrate SDK instances without Mobius registration.
564
+ * @example
565
+ * ```typescript
566
+ * task.on(TASK_EVENTS.TASK_MULTI_LOGIN_HYDRATE, (task: ITask) => {
567
+ * console.log('Multi-login hydrate:', task.data.interactionId);
568
+ * });
569
+ * ```
570
+ */
571
+ TASK_MULTI_LOGIN_HYDRATE = "task:multiLoginHydrate",
496
572
  /**
497
573
  * Triggered when a campaign preview contact is offered to the agent
498
574
  * @example
@@ -547,25 +623,146 @@ export declare enum TASK_EVENTS {
547
623
  * });
548
624
  * ```
549
625
  */
550
- TASK_CAMPAIGN_CONTACT_UPDATED = "task:campaignContactUpdated",
551
- /**
552
- * Triggered when a we get accept an incoming web call
553
- * This is used to send task data to the instance without mobius registration in case of multi login
554
- * @example
555
- * ```typescript
556
- * task.on(TASK_EVENTS.TASK_MULIT_LOGIN_HYDRATE, (task: ITask) => {
557
- * console.log('Mulit login detected:', task.data.interactionId);
558
- * // Handle mulit login
559
- * });
560
- * ```
561
- */
562
- TASK_MULTI_LOGIN_HYDRATE = "task:multiLoginHydrate"
626
+ TASK_CAMPAIGN_CONTACT_UPDATED = "task:campaignContactUpdated"
563
627
  }
564
628
  /**
565
629
  * Represents a customer interaction within the contact center system
566
630
  * Contains comprehensive details about an ongoing customer interaction
567
631
  * @public
568
632
  */
633
+ export interface CallAssociatedDatum {
634
+ /** Whether the field can be edited by the agent */
635
+ agentEditable: boolean;
636
+ /** Whether the field is visible to the agent */
637
+ agentViewable: boolean;
638
+ /** Display name for the field */
639
+ displayName: string;
640
+ /** Whether the field is global */
641
+ global: boolean;
642
+ /** Whether the field is secure */
643
+ isSecure: boolean;
644
+ /** Internal field name */
645
+ name: string;
646
+ /** Whether the field is reportable */
647
+ reportable: boolean;
648
+ /** Secure key identifier */
649
+ secureKeyId: string;
650
+ /** Secure key version */
651
+ secureKeyVersion: number;
652
+ /** Data type of the field */
653
+ type: string;
654
+ /** Field value */
655
+ value: string;
656
+ }
657
+ export type CallAssociatedData = Record<string, CallAssociatedDatum>;
658
+ export type CallAssociatedDetails = Record<string, string>;
659
+ export interface FlowParameter {
660
+ /** Parameter name */
661
+ name?: string;
662
+ /** Additional qualifier */
663
+ qualifier?: string;
664
+ /** Description of the parameter */
665
+ description?: string;
666
+ /** Data type of the value */
667
+ valueDataType?: string;
668
+ /** Value associated with the parameter */
669
+ value?: string;
670
+ }
671
+ export interface InteractionParticipant {
672
+ /** Unique participant identifier */
673
+ id: string;
674
+ /** Participant type label used by backend */
675
+ pType: string;
676
+ /** Friendly participant type */
677
+ type: string;
678
+ /** Whether the participant has joined */
679
+ hasJoined: boolean;
680
+ /** Whether the participant has left */
681
+ hasLeft: boolean;
682
+ /** Whether the participant is still in pre-dial */
683
+ isInPredial: boolean;
684
+ /** Optional caller identifier */
685
+ callerId?: string | null;
686
+ /** Whether auto-answer is enabled */
687
+ autoAnswerEnabled?: boolean;
688
+ /** Backchannel/bnr details */
689
+ bnrDetails?: unknown;
690
+ /** Channel identifier for the participant */
691
+ channelId?: string;
692
+ /** Current consult state */
693
+ consultState?: string | null;
694
+ /** Timestamp when consult started */
695
+ consultTimestamp?: number | null;
696
+ /** Current participant state */
697
+ currentState?: string | null;
698
+ /** Timestamp of the current state */
699
+ currentStateTimestamp?: number | null;
700
+ /** Device call identifier */
701
+ deviceCallId?: string | null;
702
+ /** Device identifier */
703
+ deviceId?: string | null;
704
+ /** Device type (AGENT_DN, BROWSER, etc.) */
705
+ deviceType?: string | null;
706
+ /** Dial number associated with participant */
707
+ dn?: string | null;
708
+ /** Whether participant is currently consulted */
709
+ isConsulted?: boolean;
710
+ /** Whether participant offer is active */
711
+ isOffered?: boolean;
712
+ /** Whether participant is in wrap-up */
713
+ isWrapUp?: boolean;
714
+ /** Whether participant completed wrap-up */
715
+ isWrappedUp?: boolean;
716
+ /** Timestamp of when participant joined */
717
+ joinTimestamp?: number | null;
718
+ /** Last updated timestamp */
719
+ lastUpdated?: number | null;
720
+ /** Friendly name of participant */
721
+ name?: string | null;
722
+ /** Queue identifier associated with participant */
723
+ queueId?: string;
724
+ /** Queue manager identifier */
725
+ queueMgrId?: string;
726
+ /** Session identifier */
727
+ sessionId?: string;
728
+ /** Site identifier */
729
+ siteId?: string;
730
+ /** Skill identifier */
731
+ skillId?: string | null;
732
+ /** Skill name */
733
+ skillName?: string | null;
734
+ /** Skill list for participant */
735
+ skills?: string[];
736
+ /** Team identifier */
737
+ teamId?: string;
738
+ /** Team name */
739
+ teamName?: string;
740
+ /** Timestamp for wrap-up */
741
+ wrapUpTimestamp?: number | null;
742
+ /** Additional metadata */
743
+ [key: string]: unknown;
744
+ }
745
+ export type InteractionParticipants = Record<string, InteractionParticipant>;
746
+ /**
747
+ * Media entry type from interaction.media
748
+ * Used for media state tracking in consult and conference scenarios
749
+ */
750
+ export type MediaEntry = {
751
+ /** Unique identifier for the media resource */
752
+ mediaResourceId: string;
753
+ /** Type of media channel */
754
+ mediaType: MEDIA_CHANNEL;
755
+ /** Media manager handling this media */
756
+ mediaMgr: string;
757
+ /** List of participant identifiers */
758
+ participants: string[];
759
+ /** Type of media (e.g., 'mainCall', 'consult') */
760
+ mType: string;
761
+ /** Indicates if media is on hold */
762
+ isHold: boolean;
763
+ /** Timestamp when media was put on hold */
764
+ holdTimestamp: number | null;
765
+ };
569
766
  export type Interaction = {
570
767
  /** Indicates if the interaction is managed by Flow Control */
571
768
  isFcManaged: boolean;
@@ -580,7 +777,11 @@ export type Interaction = {
580
777
  /** Current virtual team handling the interaction */
581
778
  currentVTeam: string;
582
779
  /** List of participants in the interaction */
583
- participants: any;
780
+ participants: InteractionParticipants;
781
+ /** Detailed call associated data */
782
+ callAssociatedData?: CallAssociatedData;
783
+ /** Simplified call associated key/value pairs */
784
+ callAssociatedDetails?: CallAssociatedDetails;
584
785
  /** Unique identifier for the interaction */
585
786
  interactionId: string;
586
787
  /** Organization identifier */
@@ -589,7 +790,18 @@ export type Interaction = {
589
790
  createdTimestamp?: number;
590
791
  /** Indicates if wrap-up assistance is enabled */
591
792
  isWrapUpAssist?: boolean;
592
- /** Detailed call processing information and metadata */
793
+ /** Identifier of parent interaction if applicable */
794
+ parentInteractionId?: string;
795
+ /** Indicates if media is forked for this interaction */
796
+ isMediaForked?: boolean;
797
+ /** Retroactive flow properties returned by backend */
798
+ flowProperties?: Record<string, unknown> | null;
799
+ /** Media specific properties returned by backend */
800
+ mediaProperties?: Record<string, unknown> | null;
801
+ /**
802
+ * Detailed call processing information and metadata.
803
+ * Mirrors the callProcessingDetails section described in Webex Contact Center Agent Contact payloads.
804
+ */
593
805
  callProcessingDetails: {
594
806
  /** Name of the Queue Manager handling this interaction */
595
807
  QMgrName: string;
@@ -607,20 +819,24 @@ export type Interaction = {
607
819
  QueueId: string;
608
820
  /** Virtual team identifier */
609
821
  vteamId: string;
610
- /** Indicates if pause/resume functionality is enabled */
611
- pauseResumeEnabled?: string;
822
+ /** Agent capability for pause/resume on this interaction */
823
+ pauseResumeEnabled?: boolean;
612
824
  /** Duration of pause in seconds */
613
825
  pauseDuration?: string;
614
- /** Indicates if the interaction is currently paused */
615
- isPaused?: string;
616
- /** Indicates if recording is in progress */
617
- recordInProgress?: string;
618
- /** Indicates if recording has started */
619
- recordingStarted?: string;
826
+ /** Legacy pause indicator (recordInProgress=false is the active pause signal) */
827
+ isPaused?: boolean;
828
+ /** Recording is actively capturing audio right now */
829
+ recordInProgress?: boolean;
830
+ /** Recording was started for this interaction (may be paused) */
831
+ recordingStarted?: boolean;
832
+ /** Customer geographic region */
833
+ customerRegion?: string;
834
+ /** Flow tag identifier */
835
+ flowTagId?: string;
620
836
  /** Indicates if Consult to Queue is in progress */
621
- ctqInProgress?: string;
837
+ ctqInProgress?: boolean;
622
838
  /** Indicates if outdial transfer to queue is enabled */
623
- outdialTransferToQueueEnabled?: string;
839
+ outdialTransferToQueueEnabled?: boolean;
624
840
  /** IVR conversation transcript */
625
841
  convIvrTranscript?: string;
626
842
  /** Customer's name */
@@ -707,6 +923,8 @@ export type Interaction = {
707
923
  fcDesktopView?: string;
708
924
  /** Agent ID who initiated the outdial call */
709
925
  outdialAgentId?: string;
926
+ /** Indicates if the customer has left the call during an active consult */
927
+ hasCustomerLeft?: string;
710
928
  /** Indicates if the skip action is disabled for campaign preview contacts */
711
929
  campaignPreviewSkipDisabled?: string;
712
930
  /** Indicates if the remove action is disabled for campaign preview contacts */
@@ -718,56 +936,54 @@ export type Interaction = {
718
936
  };
719
937
  /** Main interaction identifier for related interactions */
720
938
  mainInteractionId?: string;
939
+ /** Timestamp when interaction entered queue */
940
+ queuedTimestamp?: number | null;
721
941
  /** Media-specific information for the interaction */
722
- media: Record<string, {
723
- /** Unique identifier for the media resource */
724
- mediaResourceId: string;
725
- /** Type of media channel */
726
- mediaType: MEDIA_CHANNEL;
727
- /** Media manager handling this media */
728
- mediaMgr: string;
729
- /** List of participant identifiers */
730
- participants: string[];
731
- /** Type of media */
732
- mType: string;
733
- /** Indicates if media is on hold */
734
- isHold: boolean;
735
- /** Timestamp when media was put on hold */
736
- holdTimestamp: number | null;
737
- }>;
942
+ media: Record<string, MediaEntry>;
738
943
  /** Owner of the interaction */
739
944
  owner: string;
740
945
  /** Primary media channel for the interaction */
741
- mediaChannel: MEDIA_CHANNEL;
946
+ mediaChannel: string;
742
947
  /** Direction information for the contact */
743
948
  contactDirection: {
744
949
  type: string;
745
950
  };
746
951
  /** Type of outbound interaction */
747
952
  outboundType?: string;
953
+ /** Optional workflow manager identifier */
954
+ workflowManager?: string | null;
748
955
  /** Parameters passed through the call flow */
749
- callFlowParams: Record<string, {
750
- /** Name of the parameter */
751
- name: string;
752
- /** Qualifier for the parameter */
753
- qualifier: string;
754
- /** Description of the parameter */
755
- description: string;
756
- /** Data type of the parameter value */
757
- valueDataType: string;
758
- /** Value of the parameter */
759
- value: string;
760
- }>;
956
+ callFlowParams?: Record<string, FlowParameter>;
761
957
  };
762
958
  /**
763
- * Task payload containing detailed information about a contact center task
764
- * This structure encapsulates all relevant data for task management
959
+ * Task payload mirroring the Agent Contact event payload from Webex Contact Center
960
+ * (developer.webex.com). Arrives on AGENT_* websocket events and is the source of truth
961
+ * for UI/state machine updates.
765
962
  * @public
766
963
  */
964
+ export type RealtimeTranscription = {
965
+ agentId: string;
966
+ orgId: string;
967
+ notifType: string;
968
+ notifDetails: {
969
+ actionEvent: string;
970
+ };
971
+ data: {
972
+ role: 'AGENT' | 'CALLER';
973
+ utteranceId: string;
974
+ conversationId: string;
975
+ publishTimestamp: number;
976
+ messageId: string;
977
+ isFinal: boolean;
978
+ languageCode: string;
979
+ orgId: string;
980
+ content: string;
981
+ };
982
+ };
767
983
  export type TaskData = {
768
- /** Unique identifier for the media resource handling this task */
984
+ /** Primary media resource identifier for the active leg (matches interaction.media[].mediaResourceId) */
769
985
  mediaResourceId: string;
770
- /** Type of event that triggered this task data */
986
+ /** Agent event name from the websocket stream (e.g., AGENT_CONTACT_ASSIGNED) */
771
987
  eventType: string;
772
988
  /** Timestamp when the event occurred */
773
989
  eventTime?: number;
@@ -777,7 +993,7 @@ export type TaskData = {
777
993
  destAgentId: string;
778
994
  /** Unique tracking identifier for the task */
779
995
  trackingId: string;
780
- /** Media resource identifier for consultation operations */
996
+ /** Media resource identifier for consultation leg when present */
781
997
  consultMediaResourceId: string;
782
998
  /** Detailed interaction information */
783
999
  interaction: Interaction;
@@ -789,7 +1005,7 @@ export type TaskData = {
789
1005
  toOwner?: boolean;
790
1006
  /** Identifier for child interaction in consult/transfer scenarios */
791
1007
  childInteractionId?: string;
792
- /** Unique identifier for the interaction */
1008
+ /** Interaction/contact identifier from backend (same as interaction.interactionId) */
793
1009
  interactionId: string;
794
1010
  /** Organization identifier */
795
1011
  orgId: string;
@@ -799,7 +1015,7 @@ export type TaskData = {
799
1015
  queueMgr: string;
800
1016
  /** Name of the queue where task is queued */
801
1017
  queueName?: string;
802
- /** Type of the task */
1018
+ /** Task/interaction type returned by the platform (routing/monitoring/etc.) */
803
1019
  type: string;
804
1020
  /** Timeout value for RONA (Redirection on No Answer) in seconds */
805
1021
  ronaTimeout?: number;
@@ -835,11 +1051,93 @@ export type TaskData = {
835
1051
  reservedAgentChannelId?: string;
836
1052
  /** Indicates if wrap-up is required for this task */
837
1053
  wrapUpRequired?: boolean;
1054
+ /**
1055
+ * Current consultation status derived from state machine
1056
+ * Values: CONSULT_INITIATED, CONSULT_ACCEPTED, BEING_CONSULTED,
1057
+ * BEING_CONSULTED_ACCEPTED, CONNECTED, CONFERENCE, CONSULT_COMPLETED
1058
+ */
1059
+ consultStatus?: string;
1060
+ /**
1061
+ * Indicates if consultation is in progress (state machine: CONSULTING)
1062
+ */
1063
+ isConsultInProgress?: boolean;
1064
+ /**
1065
+ * Indicates if the task is incoming for the active agent
1066
+ */
1067
+ isIncomingTask?: boolean;
1068
+ /**
1069
+ * Indicates if the task is on hold (state machine: HELD)
1070
+ */
1071
+ isOnHold?: boolean;
1072
+ /**
1073
+ * Indicates if customer is currently in the call
1074
+ * Derived from participants in main media
1075
+ */
1076
+ isCustomerInCall?: boolean;
1077
+ /**
1078
+ * Count of conference participants (agents only)
1079
+ * Used for determining if max participants reached
1080
+ */
1081
+ conferenceParticipantsCount?: number;
1082
+ /**
1083
+ * Indicates if this is a secondary agent (consulted party)
1084
+ */
1085
+ isSecondaryAgent?: boolean;
1086
+ /**
1087
+ * Indicates if this is a secondary EP-DN agent (telephony consult to external)
1088
+ */
1089
+ isSecondaryEpDnAgent?: boolean;
1090
+ /**
1091
+ * Task state for MPC (Multi-Party Conference) scenarios
1092
+ * Maps participant consultState to task state
1093
+ */
1094
+ mpcState?: string;
838
1095
  /** Indicates if auto-answer is in progress for this task */
839
1096
  isAutoAnswering?: boolean;
840
1097
  /** Indicates if wrap-up is required for this task */
841
1098
  agentsPendingWrapUp?: string[];
842
1099
  };
1100
+ export type TaskUIControlState = {
1101
+ isVisible: boolean;
1102
+ isEnabled: boolean;
1103
+ };
1104
+ /**
1105
+ * UI control representation for a single interaction leg.
1106
+ */
1107
+ export type InteractionUIControls = {
1108
+ accept: TaskUIControlState;
1109
+ decline: TaskUIControlState;
1110
+ hold: TaskUIControlState;
1111
+ transfer: TaskUIControlState;
1112
+ consult: TaskUIControlState;
1113
+ end: TaskUIControlState;
1114
+ recording: TaskUIControlState;
1115
+ mute: TaskUIControlState;
1116
+ consultTransfer: TaskUIControlState;
1117
+ endConsult: TaskUIControlState;
1118
+ conference: TaskUIControlState;
1119
+ exitConference: TaskUIControlState;
1120
+ transferConference: TaskUIControlState;
1121
+ mergeToConference: TaskUIControlState;
1122
+ wrapup: TaskUIControlState;
1123
+ switch: TaskUIControlState;
1124
+ };
1125
+ export type TaskUILeg = 'main' | 'consult';
1126
+ /**
1127
+ * UI controls surfaced to task consumers.
1128
+ * Consumers should read controls from the per-leg surfaces and use `activeLeg`
1129
+ * to determine which one is currently interactive.
1130
+ */
1131
+ export type TaskUIControls = {
1132
+ main: InteractionUIControls;
1133
+ consult: InteractionUIControls;
1134
+ activeLeg: TaskUILeg;
1135
+ };
1136
+ /**
1137
+ * Helper class for managing task action control state
1138
+ * Tracks visibility and enabled state for task actions that can be executed
1139
+ * @public
1140
+ */
843
1141
  /**
844
1142
  * Type representing an agent contact message within the contact center system
845
1143
  * Contains comprehensive interaction and task related details for agent operations
@@ -1050,6 +1348,14 @@ export type TransferPayload = {
1050
1348
  /** Type of the transfer destination */
1051
1349
  destinationType: DestinationType;
1052
1350
  };
1351
+ /**
1352
+ * Options for configuring transfer behavior
1353
+ * @public
1354
+ */
1355
+ export type TransferOptions = {
1356
+ /** Additional transfer configuration options */
1357
+ [key: string]: unknown;
1358
+ };
1053
1359
  /**
1054
1360
  * API payload for ending a consultation
1055
1361
  * This is the actual payload that is sent to the developer API
@@ -1165,6 +1471,19 @@ export type ContactCleanupData = {
1165
1471
  type: string;
1166
1472
  };
1167
1473
  };
1474
+ /**
1475
+ * Boolean-like fields in callProcessingDetails that may arrive as strings.
1476
+ * Used by taskDataNormalizer to coerce payloads to actual booleans.
1477
+ */
1478
+ export type CallProcessingBooleanKey = 'recordingStarted' | 'recordInProgress' | 'isPaused' | 'pauseResumeEnabled' | 'ctqInProgress' | 'outdialTransferToQueueEnabled' | 'taskToBeSelfServiced' | 'CONTINUE_RECORDING_ON_TRANSFER' | 'isParked' | 'participantInviteTimeout' | 'checkAgentAvailability';
1479
+ /**
1480
+ * Interaction-level boolean fields that may arrive as strings from backend payloads.
1481
+ */
1482
+ export type InteractionBooleanKey = 'isFcManaged' | 'isMediaForked' | 'isTerminated';
1483
+ /**
1484
+ * Participant boolean fields that may arrive as strings and need normalization.
1485
+ */
1486
+ export type ParticipantBooleanKey = 'autoAnswerEnabled' | 'hasJoined' | 'hasLeft' | 'isConsulted' | 'isInPredial' | 'isOffered' | 'isWrapUp' | 'isWrappedUp';
1168
1487
  /**
1169
1488
  * Response type for task public methods
1170
1489
  * Can be an {@link AgentContact} object containing updated task state,
@@ -1172,11 +1491,32 @@ export type ContactCleanupData = {
1172
1491
  * @public
1173
1492
  */
1174
1493
  export type TaskResponse = AgentContact | Error | void;
1494
+ /**
1495
+ * Payload shape used by consult conference helper utilities.
1496
+ */
1497
+ export type consultConferencePayloadData = {
1498
+ agentId?: string;
1499
+ destinationType?: string;
1500
+ destAgentId?: string;
1501
+ };
1502
+ /**
1503
+ * Minimal event-emitter contract exposed to SDK consumers.
1504
+ * Defined here so that consumers do NOT need `@types/node` in their tsconfig.
1505
+ * The runtime Task class still extends Node's EventEmitter (via ampersand-events),
1506
+ * which satisfies this interface at runtime.
1507
+ * @public
1508
+ */
1509
+ export interface IEventEmitter {
1510
+ on(event: string, listener: (...args: any[]) => void): this;
1511
+ off(event: string, listener: (...args: any[]) => void): this;
1512
+ once(event: string, listener: (...args: any[]) => void): this;
1513
+ emit(event: string, ...args: any[]): boolean;
1514
+ }
1175
1515
  /**
1176
1516
  * Interface for managing task-related operations in the contact center
1177
- * Extends EventEmitter to support event-driven task updates
1517
+ * Extends IEventEmitter to support event-driven task updates
1178
1518
  */
1179
- export interface ITask extends EventEmitter {
1519
+ export interface ITask extends IEventEmitter {
1180
1520
  /**
1181
1521
  * Event data received in the Contact Center events.
1182
1522
  * Contains detailed task information including interaction details, media resources,
@@ -1193,6 +1533,13 @@ export interface ITask extends EventEmitter {
1193
1533
  * as defined in {@link AutoWrapup}
1194
1534
  */
1195
1535
  autoWrapup?: AutoWrapup;
1536
+ /**
1537
+ * Latest UI controls derived from the state machine.
1538
+ * Each control has `isVisible` and `isEnabled` flags computed from current task state.
1539
+ * Subscribe to {@link TASK_EVENTS.TASK_UI_CONTROLS_UPDATED} for change notifications.
1540
+ */
1541
+ readonly uiControls: TaskUIControls;
1542
+ state?: any;
1196
1543
  /**
1197
1544
  * Cancels the auto-wrapup timer for the task.
1198
1545
  * This method stops the auto-wrapup process if it is currently active.
@@ -1212,7 +1559,7 @@ export interface ITask extends EventEmitter {
1212
1559
  * @returns Updated task instance
1213
1560
  * @ignore
1214
1561
  */
1215
- updateTaskData(newData: TaskData): ITask;
1562
+ updateTaskData(newData: TaskData): void;
1216
1563
  /**
1217
1564
  * Answers or accepts an incoming task.
1218
1565
  * Once accepted, the task will be assigned to the agent and trigger a {@link TASK_EVENTS.TASK_ASSIGNED} event.
@@ -1333,17 +1680,7 @@ export interface ITask extends EventEmitter {
1333
1680
  * await task.transfer({ to: "queueId", destinationType: "queue" });
1334
1681
  * ```
1335
1682
  */
1336
- transfer(transferPayload: TransferPayLoad): Promise<TaskResponse>;
1337
- /**
1338
- * Transfers the task after consultation.
1339
- * @param consultTransferPayload - Details for consult transfer (optional)
1340
- * @returns Promise<TaskResponse>
1341
- * @example
1342
- * ```typescript
1343
- * await task.consultTransfer({ to: "agentId", destinationType: "agent" });
1344
- * ```
1345
- */
1346
- consultTransfer(consultTransferPayload?: ConsultTransferPayLoad): Promise<TaskResponse>;
1683
+ transfer(transferPayload: TransferPayLoad, options?: TransferOptions): Promise<TaskResponse>;
1347
1684
  /**
1348
1685
  * Initiates a consult conference (merge consult call with main call).
1349
1686
  * @returns Promise<TaskResponse>
@@ -1371,6 +1708,18 @@ export interface ITask extends EventEmitter {
1371
1708
  * ```
1372
1709
  */
1373
1710
  transferConference(): Promise<TaskResponse>;
1711
+ /**
1712
+ * Toggles between consult call and main call during consulting.
1713
+ * If on consult leg, switches to main call (holds consult).
1714
+ * If on main call, switches to consult (resumes consult).
1715
+ * Only available when in CONSULTING state.
1716
+ * @returns Promise<TaskResponse>
1717
+ * @example
1718
+ * ```typescript
1719
+ * await task.switchCall();
1720
+ * ```
1721
+ */
1722
+ switchCall(): Promise<TaskResponse>;
1374
1723
  /**
1375
1724
  * Toggles mute/unmute for the local audio stream during a WebRTC task.
1376
1725
  * @returns Promise<void>
@@ -1381,3 +1730,127 @@ export interface ITask extends EventEmitter {
1381
1730
  */
1382
1731
  toggleMute(): Promise<void>;
1383
1732
  }
1733
+ /**
1734
+ * Interface for managing digital channel task operations in the contact center
1735
+ * Digital channels (chat, email, social, SMS) have a simpler interface than voice
1736
+ * Extends ITask but overrides updateTaskData to return IDigital
1737
+ * @public
1738
+ */
1739
+ export interface IDigital extends Omit<ITask, 'updateTaskData'> {
1740
+ /**
1741
+ * Updates the task data
1742
+ * @param newData - Updated task data
1743
+ * @param shouldOverwrite - Whether to completely replace existing data
1744
+ * @returns Updated Digital task instance
1745
+ */
1746
+ updateTaskData(newData: TaskData, shouldOverwrite?: boolean): IDigital;
1747
+ }
1748
+ /**
1749
+ * Interface for managing voice/telephony task operations in the contact center
1750
+ * Extends ITask with voice-specific functionality for hold/resume operations
1751
+ * @public
1752
+ */
1753
+ export interface IVoice extends ITask {
1754
+ /**
1755
+ * Toggles hold/resume state for a voice task.
1756
+ * If the task is currently on hold, it will be resumed.
1757
+ * If the task is active, it will be placed on hold.
1758
+ * @returns Promise<TaskResponse>
1759
+ * @example
1760
+ * ```typescript
1761
+ * await voiceTask.holdResume();
1762
+ * ```
1763
+ */
1764
+ holdResume(): Promise<TaskResponse>;
1765
+ }
1766
+ /**
1767
+ * Configuration options for voice task UI controls
1768
+ */
1769
+ export type VoiceUIControlOptions = {
1770
+ isEndTaskEnabled?: boolean;
1771
+ isEndConsultEnabled?: boolean;
1772
+ voiceVariant?: VoiceVariant;
1773
+ isRecordingEnabled?: boolean;
1774
+ };
1775
+ /**
1776
+ * Participant information for UI display
1777
+ */
1778
+ export type Participant = {
1779
+ id: string;
1780
+ name?: string;
1781
+ pType?: string;
1782
+ };
1783
+ /**
1784
+ * @deprecated Use Participant instead
1785
+ */
1786
+ export type TaskAccessorParticipant = Participant;
1787
+ export interface IWebRTC extends IVoice {
1788
+ /**
1789
+ * This method is used to mute/unmute the call.
1790
+ * @returns Promise<void>
1791
+ * @example
1792
+ * ```typescript
1793
+ * task.toggleMute();
1794
+ * ```
1795
+ */
1796
+ toggleMute(): Promise<void>;
1797
+ /**
1798
+ * Decline the incoming task for Browser Login
1799
+ *
1800
+ * @example
1801
+ * ```
1802
+ * task.decline();
1803
+ * ```
1804
+ */
1805
+ decline(): Promise<TaskResponse>;
1806
+ /**
1807
+ * This method is used to unregister the web call listeners.
1808
+ * @returns void
1809
+ * @example
1810
+ * ```typescript
1811
+ * task.unregisterWebCallListeners();
1812
+ * ```
1813
+ */
1814
+ unregisterWebCallListeners(): void;
1815
+ }
1816
+ export type WebSocketPayload = TaskData & {
1817
+ type: string;
1818
+ mediaResourceId?: string;
1819
+ reason?: string;
1820
+ /**
1821
+ * Optional real-time transcript chunk payload.
1822
+ * Present on REAL_TIME_TRANSCRIPTION notifications.
1823
+ */
1824
+ data?: RealtimeTranscription['data'];
1825
+ };
1826
+ export type WebSocketMessage = {
1827
+ keepalive?: 'true' | 'false' | boolean;
1828
+ type?: string;
1829
+ data: WebSocketPayload;
1830
+ };
1831
+ /**
1832
+ * Actions to be performed after handling an event
1833
+ *
1834
+ * These actions represent TaskManager-level concerns (task collection lifecycle,
1835
+ * resource cleanup) rather than task-level state machine concerns. The separation
1836
+ * ensures proper responsibility:
1837
+ * - TaskManager: Collection management, metrics, cleanup
1838
+ * - State Machine: Task state transitions, event emissions, UI controls
1839
+ */
1840
+ export interface TaskEventActions {
1841
+ task?: ITask;
1842
+ }
1843
+ /**
1844
+ * Context for processing an event
1845
+ *
1846
+ * Contains all information needed to process a WebSocket event:
1847
+ * - Event type and payload from the backend
1848
+ * - Task instance (if exists)
1849
+ * - Pre-mapped state machine event (if applicable)
1850
+ */
1851
+ export interface EventContext {
1852
+ eventType: string;
1853
+ payload: WebSocketPayload;
1854
+ task?: ITask;
1855
+ stateMachineEvent?: TaskEventPayload | null;
1856
+ }