@webex/contact-center 3.12.0-next.9 → 3.12.0-next.90

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 (229) hide show
  1. package/.sdd/manifest.json +876 -0
  2. package/AGENTS.md +94 -0
  3. package/ai-docs/ARCHITECTURE.md +168 -0
  4. package/ai-docs/CONTRACTS.md +46 -0
  5. package/ai-docs/GETTING_STARTED.md +168 -0
  6. package/ai-docs/GLOSSARY.md +43 -0
  7. package/ai-docs/README.md +138 -0
  8. package/ai-docs/REVIEW_CHECKLIST.md +41 -0
  9. package/ai-docs/RULES.md +444 -0
  10. package/ai-docs/SECURITY.md +52 -0
  11. package/ai-docs/SERVICE_STATE.md +48 -0
  12. package/ai-docs/SPEC_INDEX.md +65 -0
  13. package/ai-docs/adr/0001-spec-source-policy.md +55 -0
  14. package/ai-docs/adr/README.md +8 -0
  15. package/ai-docs/adr/_adr-template.md +31 -0
  16. package/ai-docs/contact-center-spec.md +341 -0
  17. package/ai-docs/features/generated-spec-conformance-fidelity-remediation/spec/feature-spec.md +117 -0
  18. package/ai-docs/features/residual-warning-coverage-completion/spec/feature-spec.md +203 -0
  19. package/ai-docs/features/validator-code-fidelity-drift-fix/spec/feature-spec.md +315 -0
  20. package/ai-docs/patterns/event-driven-patterns.md +485 -0
  21. package/ai-docs/patterns/testing-patterns.md +480 -0
  22. package/ai-docs/patterns/typescript-patterns.md +365 -0
  23. package/ai-docs/templates/README.md +102 -0
  24. package/ai-docs/templates/documentation/create-agents-md.md +240 -0
  25. package/ai-docs/templates/documentation/create-architecture-md.md +295 -0
  26. package/ai-docs/templates/existing-service/bug-fix.md +254 -0
  27. package/ai-docs/templates/existing-service/feature-enhancement.md +450 -0
  28. package/ai-docs/templates/new-method/00-master.md +80 -0
  29. package/ai-docs/templates/new-method/01-requirements.md +232 -0
  30. package/ai-docs/templates/new-method/02-implementation.md +295 -0
  31. package/ai-docs/templates/new-method/03-tests.md +201 -0
  32. package/ai-docs/templates/new-method/04-validation.md +141 -0
  33. package/ai-docs/templates/new-service/00-master.md +109 -0
  34. package/ai-docs/templates/new-service/01-pre-questions.md +159 -0
  35. package/ai-docs/templates/new-service/02-code-generation.md +346 -0
  36. package/ai-docs/templates/new-service/03-integration.md +178 -0
  37. package/ai-docs/templates/new-service/04-test-generation.md +205 -0
  38. package/ai-docs/templates/new-service/05-validation.md +145 -0
  39. package/dist/cc.js +265 -29
  40. package/dist/cc.js.map +1 -1
  41. package/dist/config.js +6 -0
  42. package/dist/config.js.map +1 -1
  43. package/dist/constants.js +17 -1
  44. package/dist/constants.js.map +1 -1
  45. package/dist/index.js +20 -5
  46. package/dist/index.js.map +1 -1
  47. package/dist/metrics/behavioral-events.js +101 -0
  48. package/dist/metrics/behavioral-events.js.map +1 -1
  49. package/dist/metrics/constants.js +25 -4
  50. package/dist/metrics/constants.js.map +1 -1
  51. package/dist/services/ApiAiAssistant.js +153 -8
  52. package/dist/services/ApiAiAssistant.js.map +1 -1
  53. package/dist/services/UserPreference.js +427 -0
  54. package/dist/services/UserPreference.js.map +1 -0
  55. package/dist/services/config/Util.js +3 -3
  56. package/dist/services/config/Util.js.map +1 -1
  57. package/dist/services/config/constants.js +23 -2
  58. package/dist/services/config/constants.js.map +1 -1
  59. package/dist/services/config/types.js +49 -9
  60. package/dist/services/config/types.js.map +1 -1
  61. package/dist/services/core/Err.js.map +1 -1
  62. package/dist/services/core/Utils.js +107 -32
  63. package/dist/services/core/Utils.js.map +1 -1
  64. package/dist/services/core/websocket/WebSocketManager.js +2 -1
  65. package/dist/services/core/websocket/WebSocketManager.js.map +1 -1
  66. package/dist/services/core/websocket/types.js.map +1 -1
  67. package/dist/services/index.js +1 -1
  68. package/dist/services/index.js.map +1 -1
  69. package/dist/services/task/Task.js +688 -0
  70. package/dist/services/task/Task.js.map +1 -0
  71. package/dist/services/task/TaskFactory.js +45 -0
  72. package/dist/services/task/TaskFactory.js.map +1 -0
  73. package/dist/services/task/TaskManager.js +728 -527
  74. package/dist/services/task/TaskManager.js.map +1 -1
  75. package/dist/services/task/TaskUtils.js +162 -26
  76. package/dist/services/task/TaskUtils.js.map +1 -1
  77. package/dist/services/task/constants.js +9 -2
  78. package/dist/services/task/constants.js.map +1 -1
  79. package/dist/services/task/dialer.js +78 -0
  80. package/dist/services/task/dialer.js.map +1 -1
  81. package/dist/services/task/digital/Digital.js +77 -0
  82. package/dist/services/task/digital/Digital.js.map +1 -0
  83. package/dist/services/task/state-machine/TaskStateMachine.js +837 -0
  84. package/dist/services/task/state-machine/TaskStateMachine.js.map +1 -0
  85. package/dist/services/task/state-machine/actions.js +543 -0
  86. package/dist/services/task/state-machine/actions.js.map +1 -0
  87. package/dist/services/task/state-machine/constants.js +161 -0
  88. package/dist/services/task/state-machine/constants.js.map +1 -0
  89. package/dist/services/task/state-machine/guards.js +340 -0
  90. package/dist/services/task/state-machine/guards.js.map +1 -0
  91. package/dist/services/task/state-machine/index.js +53 -0
  92. package/dist/services/task/state-machine/index.js.map +1 -0
  93. package/dist/services/task/state-machine/types.js +54 -0
  94. package/dist/services/task/state-machine/types.js.map +1 -0
  95. package/dist/services/task/state-machine/uiControlsComputer.js +553 -0
  96. package/dist/services/task/state-machine/uiControlsComputer.js.map +1 -0
  97. package/dist/services/task/taskDataNormalizer.js +99 -0
  98. package/dist/services/task/taskDataNormalizer.js.map +1 -0
  99. package/dist/services/task/types.js +212 -4
  100. package/dist/services/task/types.js.map +1 -1
  101. package/dist/services/task/voice/Voice.js +1042 -0
  102. package/dist/services/task/voice/Voice.js.map +1 -0
  103. package/dist/services/task/voice/WebRTC.js +149 -0
  104. package/dist/services/task/voice/WebRTC.js.map +1 -0
  105. package/dist/types/cc.d.ts +94 -1
  106. package/dist/types/config.d.ts +6 -0
  107. package/dist/types/constants.d.ts +17 -1
  108. package/dist/types/index.d.ts +21 -6
  109. package/dist/types/metrics/constants.d.ts +21 -1
  110. package/dist/types/services/ApiAiAssistant.d.ts +22 -4
  111. package/dist/types/services/UserPreference.d.ts +118 -0
  112. package/dist/types/services/config/constants.d.ts +21 -0
  113. package/dist/types/services/config/types.d.ts +171 -10
  114. package/dist/types/services/core/Err.d.ts +4 -0
  115. package/dist/types/services/core/Utils.d.ts +33 -13
  116. package/dist/types/services/core/websocket/WebSocketManager.d.ts +1 -0
  117. package/dist/types/services/core/websocket/types.d.ts +1 -1
  118. package/dist/types/services/index.d.ts +1 -1
  119. package/dist/types/services/task/Task.d.ts +157 -0
  120. package/dist/types/services/task/TaskFactory.d.ts +12 -0
  121. package/dist/types/services/task/TaskUtils.d.ts +46 -2
  122. package/dist/types/services/task/constants.d.ts +7 -0
  123. package/dist/types/services/task/dialer.d.ts +30 -0
  124. package/dist/types/services/task/digital/Digital.d.ts +22 -0
  125. package/dist/types/services/task/state-machine/TaskStateMachine.d.ts +1144 -0
  126. package/dist/types/services/task/state-machine/actions.d.ts +10 -0
  127. package/dist/types/services/task/state-machine/constants.d.ts +107 -0
  128. package/dist/types/services/task/state-machine/guards.d.ts +90 -0
  129. package/dist/types/services/task/state-machine/index.d.ts +13 -0
  130. package/dist/types/services/task/state-machine/types.d.ts +267 -0
  131. package/dist/types/services/task/state-machine/uiControlsComputer.d.ts +9 -0
  132. package/dist/types/services/task/taskDataNormalizer.d.ts +10 -0
  133. package/dist/types/services/task/types.d.ts +603 -66
  134. package/dist/types/services/task/voice/Voice.d.ts +184 -0
  135. package/dist/types/services/task/voice/WebRTC.d.ts +53 -0
  136. package/dist/types/types.d.ts +135 -0
  137. package/dist/types/webex.d.ts +1 -0
  138. package/dist/types.js +118 -2
  139. package/dist/types.js.map +1 -1
  140. package/dist/webex.js +14 -2
  141. package/dist/webex.js.map +1 -1
  142. package/package.json +15 -12
  143. package/src/cc.ts +329 -30
  144. package/src/config.ts +6 -0
  145. package/src/constants.ts +17 -1
  146. package/src/index.ts +23 -5
  147. package/src/metrics/ai-docs/AGENTS.md +350 -0
  148. package/src/metrics/ai-docs/ARCHITECTURE.md +338 -0
  149. package/src/metrics/ai-docs/metrics-spec.md +854 -0
  150. package/src/metrics/behavioral-events.ts +106 -0
  151. package/src/metrics/constants.ts +27 -4
  152. package/src/services/ApiAiAssistant.ts +203 -8
  153. package/src/services/UserPreference.ts +509 -0
  154. package/src/services/agent/ai-docs/AGENTS.md +240 -0
  155. package/src/services/agent/ai-docs/ARCHITECTURE.md +304 -0
  156. package/src/services/agent/ai-docs/agent-spec.md +504 -0
  157. package/src/services/ai-docs/AGENTS.md +386 -0
  158. package/src/services/ai-docs/services-spec.md +492 -0
  159. package/src/services/config/Util.ts +3 -3
  160. package/src/services/config/ai-docs/AGENTS.md +255 -0
  161. package/src/services/config/ai-docs/ARCHITECTURE.md +426 -0
  162. package/src/services/config/ai-docs/config-spec.md +669 -0
  163. package/src/services/config/constants.ts +25 -1
  164. package/src/services/config/types.ts +174 -11
  165. package/src/services/core/Err.ts +2 -0
  166. package/src/services/core/Utils.ts +123 -37
  167. package/src/services/core/ai-docs/AGENTS.md +381 -0
  168. package/src/services/core/ai-docs/ARCHITECTURE.md +698 -0
  169. package/src/services/core/ai-docs/core-spec.md +783 -0
  170. package/src/services/core/websocket/WebSocketManager.ts +2 -0
  171. package/src/services/core/websocket/types.ts +1 -1
  172. package/src/services/index.ts +1 -1
  173. package/src/services/task/Task.ts +837 -0
  174. package/src/services/task/TaskFactory.ts +55 -0
  175. package/src/services/task/TaskManager.ts +739 -614
  176. package/src/services/task/TaskUtils.ts +205 -25
  177. package/src/services/task/ai-docs/AGENTS.md +457 -0
  178. package/src/services/task/ai-docs/ARCHITECTURE.md +594 -0
  179. package/src/services/task/ai-docs/task-spec.md +1319 -0
  180. package/src/services/task/constants.ts +7 -0
  181. package/src/services/task/dialer.ts +80 -0
  182. package/src/services/task/digital/Digital.ts +95 -0
  183. package/src/services/task/state-machine/TaskStateMachine.ts +1077 -0
  184. package/src/services/task/state-machine/actions.ts +685 -0
  185. package/src/services/task/state-machine/ai-docs/AGENTS.md +458 -0
  186. package/src/services/task/state-machine/ai-docs/ARCHITECTURE.md +1137 -0
  187. package/src/services/task/state-machine/ai-docs/task-state-machine-spec.md +2115 -0
  188. package/src/services/task/state-machine/constants.ts +172 -0
  189. package/src/services/task/state-machine/guards.ts +406 -0
  190. package/src/services/task/state-machine/index.ts +28 -0
  191. package/src/services/task/state-machine/types.ts +241 -0
  192. package/src/services/task/state-machine/uiControlsComputer.ts +867 -0
  193. package/src/services/task/taskDataNormalizer.ts +137 -0
  194. package/src/services/task/types.ts +710 -71
  195. package/src/services/task/voice/Voice.ts +1267 -0
  196. package/src/services/task/voice/WebRTC.ts +187 -0
  197. package/src/types.ts +166 -2
  198. package/src/utils/AGENTS.md +278 -0
  199. package/src/utils/ai-docs/utils-spec.md +381 -0
  200. package/src/webex.js +2 -0
  201. package/test/unit/spec/cc.ts +343 -23
  202. package/test/unit/spec/logger-proxy.ts +70 -0
  203. package/test/unit/spec/services/ApiAiAssistant.ts +178 -20
  204. package/test/unit/spec/services/UserPreference.ts +401 -0
  205. package/test/unit/spec/services/WebCallingService.ts +7 -1
  206. package/test/unit/spec/services/config/index.ts +30 -30
  207. package/test/unit/spec/services/core/Utils.ts +425 -8
  208. package/test/unit/spec/services/core/websocket/WebSocketManager.ts +66 -40
  209. package/test/unit/spec/services/task/AutoWrapup.ts +63 -0
  210. package/test/unit/spec/services/task/Task.ts +477 -0
  211. package/test/unit/spec/services/task/TaskFactory.ts +62 -0
  212. package/test/unit/spec/services/task/TaskManager.ts +834 -1704
  213. package/test/unit/spec/services/task/TaskUtils.ts +206 -0
  214. package/test/unit/spec/services/task/dialer.ts +190 -0
  215. package/test/unit/spec/services/task/digital/Digital.ts +105 -0
  216. package/test/unit/spec/services/task/state-machine/TaskStateMachine.ts +1825 -0
  217. package/test/unit/spec/services/task/state-machine/guards.ts +479 -0
  218. package/test/unit/spec/services/task/state-machine/types.ts +18 -0
  219. package/test/unit/spec/services/task/state-machine/uiControlsComputer.ts +2020 -0
  220. package/test/unit/spec/services/task/taskTestUtils.ts +87 -0
  221. package/test/unit/spec/services/task/voice/Voice.ts +631 -0
  222. package/test/unit/spec/services/task/voice/WebRTC.ts +235 -0
  223. package/umd/contact-center.min.js +2 -2
  224. package/umd/contact-center.min.js.map +1 -1
  225. package/dist/services/task/index.js +0 -1525
  226. package/dist/services/task/index.js.map +0 -1
  227. package/dist/types/services/task/index.d.ts +0 -650
  228. package/src/services/task/index.ts +0 -1801
  229. package/test/unit/spec/services/task/index.ts +0 -2184
@@ -1,5 +1,6 @@
1
- import {CallId} from '@webex/calling/dist/types/common/types';
2
- import EventEmitter from 'events';
1
+ /* eslint-disable import/no-cycle */
2
+ import type {AnyActorRef} from 'xstate';
3
+ import {TaskEventPayload} from './state-machine';
3
4
  import {Msg} from '../core/GlobalTypes';
4
5
  import AutoWrapup from './AutoWrapup';
5
6
 
@@ -9,6 +10,11 @@ import AutoWrapup from './AutoWrapup';
9
10
  */
10
11
  export type TaskId = string;
11
12
 
13
+ /**
14
+ * Unique identifier for a call in the Webex calling system
15
+ */
16
+ export type CallId = string;
17
+
12
18
  /**
13
19
  * Helper type for creating enum-like objects with type safety
14
20
  * @internal
@@ -90,6 +96,26 @@ export const MEDIA_CHANNEL = {
90
96
  */
91
97
  export type MEDIA_CHANNEL = Enum<typeof MEDIA_CHANNEL>;
92
98
 
99
+ /**
100
+ * Supported task channel types for UI control configuration
101
+ */
102
+ export const TASK_CHANNEL_TYPE = {
103
+ VOICE: 'voice',
104
+ DIGITAL: 'digital',
105
+ } as const;
106
+
107
+ export type TaskChannelType = Enum<typeof TASK_CHANNEL_TYPE>;
108
+
109
+ /**
110
+ * Voice channel variants that toggle PSTN/WebRTC specific behaviors
111
+ */
112
+ export const VOICE_VARIANT = {
113
+ PSTN: 'pstn',
114
+ WEBRTC: 'webrtc',
115
+ } as const;
116
+
117
+ export type VoiceVariant = Enum<typeof VOICE_VARIANT>;
118
+
93
119
  /**
94
120
  * Enumeration of all task-related events that can occur in the contact center system
95
121
  * These events represent different states and actions in the task lifecycle
@@ -203,6 +229,11 @@ export enum TASK_EVENTS {
203
229
  */
204
230
  TASK_CONSULT_QUEUE_FAILED = 'task:consultQueueFailed',
205
231
 
232
+ /**
233
+ * Triggered whenever task UI controls are recalculated
234
+ */
235
+ TASK_UI_CONTROLS_UPDATED = 'task:ui-controls-updated',
236
+
206
237
  /**
207
238
  * Triggered when a consultation request is accepted
208
239
  * @example
@@ -287,6 +318,24 @@ export enum TASK_EVENTS {
287
318
  */
288
319
  TASK_WRAPPEDUP = 'task:wrappedup',
289
320
 
321
+ /**
322
+ * Triggered when the task state machine reaches a final state and resources should be cleaned up.
323
+ * Used internally by TaskManager to perform collection/call cleanup.
324
+ * @internal
325
+ */
326
+ TASK_CLEANUP = 'task:cleanup',
327
+
328
+ /**
329
+ * Triggered when recording is started
330
+ * @example
331
+ * ```typescript
332
+ * task.on(TASK_EVENTS.TASK_RECORDING_STARTED, (task: ITask) => {
333
+ * console.log('Recording started:', task.data.interactionId);
334
+ * });
335
+ * ```
336
+ */
337
+ TASK_RECORDING_STARTED = 'task:recordingStarted',
338
+
290
339
  /**
291
340
  * Triggered when recording is paused
292
341
  * @example
@@ -519,6 +568,43 @@ export enum TASK_EVENTS {
519
568
  */
520
569
  TASK_PARTICIPANT_LEFT_FAILED = 'task:participantLeftFailed',
521
570
 
571
+ /**
572
+ * Triggered when agent initiates exit from conference
573
+ * @example
574
+ * ```typescript
575
+ * task.on(TASK_EVENTS.TASK_EXIT_CONFERENCE, (task: ITask) => {
576
+ * console.log('Exiting conference:', task.data.interactionId);
577
+ * // Handle conference exit initiation
578
+ * });
579
+ * ```
580
+ */
581
+ TASK_EXIT_CONFERENCE = 'task:exitConference',
582
+
583
+ /**
584
+ * Triggered when agent initiates conference transfer
585
+ * @example
586
+ * ```typescript
587
+ * task.on(TASK_EVENTS.TASK_TRANSFER_CONFERENCE, (task: ITask) => {
588
+ * console.log('Transferring conference:', task.data.interactionId);
589
+ * // Handle conference transfer initiation
590
+ * });
591
+ * ```
592
+ */
593
+ TASK_TRANSFER_CONFERENCE = 'task:transferConference',
594
+
595
+ /**
596
+ * Triggered when agent switches between consult call and main call.
597
+ * Use task.uiControls to determine current state and button visibility.
598
+ * @example
599
+ * ```typescript
600
+ * task.on(TASK_EVENTS.TASK_SWITCH_CALL, (task: ITask) => {
601
+ * console.log('Call switched:', task.data.interactionId);
602
+ * // Update UI based on task.uiControls.main.switch / task.uiControls.consult.switch
603
+ * });
604
+ * ```
605
+ */
606
+ TASK_SWITCH_CALL = 'task:switchCall',
607
+
522
608
  /**
523
609
  * Triggered when a contact is merged
524
610
  * @example
@@ -543,6 +629,17 @@ export enum TASK_EVENTS {
543
629
  */
544
630
  TASK_POST_CALL_ACTIVITY = 'task:postCallActivity',
545
631
 
632
+ /**
633
+ * Triggered when a multi-login task update should hydrate SDK instances without Mobius registration.
634
+ * @example
635
+ * ```typescript
636
+ * task.on(TASK_EVENTS.TASK_MULTI_LOGIN_HYDRATE, (task: ITask) => {
637
+ * console.log('Multi-login hydrate:', task.data.interactionId);
638
+ * });
639
+ * ```
640
+ */
641
+ TASK_MULTI_LOGIN_HYDRATE = 'task:multiLoginHydrate',
642
+
546
643
  /**
547
644
  * Triggered when a campaign preview contact is offered to the agent
548
645
  * @example
@@ -554,6 +651,54 @@ export enum TASK_EVENTS {
554
651
  * ```
555
652
  */
556
653
  TASK_CAMPAIGN_PREVIEW_RESERVATION = 'task:campaignPreviewReservation',
654
+
655
+ /**
656
+ * Triggered when accepting a campaign preview contact fails
657
+ * @example
658
+ * ```typescript
659
+ * task.on(TASK_EVENTS.TASK_CAMPAIGN_PREVIEW_ACCEPT_FAILED, (task: ITask) => {
660
+ * console.log('Campaign preview accept failed:', task.data.interactionId);
661
+ * // Handle accept failure
662
+ * });
663
+ * ```
664
+ */
665
+ TASK_CAMPAIGN_PREVIEW_ACCEPT_FAILED = 'task:campaignPreviewAcceptFailed',
666
+
667
+ /**
668
+ * Triggered when skipping a campaign preview contact fails
669
+ * @example
670
+ * ```typescript
671
+ * task.on(TASK_EVENTS.TASK_CAMPAIGN_PREVIEW_SKIP_FAILED, (task: ITask) => {
672
+ * console.log('Campaign preview skip failed:', task.data.interactionId);
673
+ * // Handle skip failure
674
+ * });
675
+ * ```
676
+ */
677
+ TASK_CAMPAIGN_PREVIEW_SKIP_FAILED = 'task:campaignPreviewSkipFailed',
678
+
679
+ /**
680
+ * Triggered when removing a campaign preview contact fails
681
+ * @example
682
+ * ```typescript
683
+ * task.on(TASK_EVENTS.TASK_CAMPAIGN_PREVIEW_REMOVE_FAILED, (task: ITask) => {
684
+ * console.log('Campaign preview remove failed:', task.data.interactionId);
685
+ * // Handle remove failure
686
+ * });
687
+ * ```
688
+ */
689
+ TASK_CAMPAIGN_PREVIEW_REMOVE_FAILED = 'task:campaignPreviewRemoveFailed',
690
+
691
+ /**
692
+ * Triggered when a campaign contact is updated (e.g., after skip or remove, when the next contact is offered)
693
+ * @example
694
+ * ```typescript
695
+ * task.on(TASK_EVENTS.TASK_CAMPAIGN_CONTACT_UPDATED, (task: ITask) => {
696
+ * console.log('Campaign contact updated:', task.data.interactionId);
697
+ * // Handle updated campaign contact (e.g., display next contact)
698
+ * });
699
+ * ```
700
+ */
701
+ TASK_CAMPAIGN_CONTACT_UPDATED = 'task:campaignContactUpdated',
557
702
  }
558
703
 
559
704
  /**
@@ -561,6 +706,146 @@ export enum TASK_EVENTS {
561
706
  * Contains comprehensive details about an ongoing customer interaction
562
707
  * @public
563
708
  */
709
+ export interface CallAssociatedDatum {
710
+ /** Whether the field can be edited by the agent */
711
+ agentEditable: boolean;
712
+ /** Whether the field is visible to the agent */
713
+ agentViewable: boolean;
714
+ /** Display name for the field */
715
+ displayName: string;
716
+ /** Whether the field is global */
717
+ global: boolean;
718
+ /** Whether the field is secure */
719
+ isSecure: boolean;
720
+ /** Internal field name */
721
+ name: string;
722
+ /** Whether the field is reportable */
723
+ reportable: boolean;
724
+ /** Secure key identifier */
725
+ secureKeyId: string;
726
+ /** Secure key version */
727
+ secureKeyVersion: number;
728
+ /** Data type of the field */
729
+ type: string;
730
+ /** Field value */
731
+ value: string;
732
+ }
733
+
734
+ export type CallAssociatedData = Record<string, CallAssociatedDatum>;
735
+
736
+ export type CallAssociatedDetails = Record<string, string>;
737
+
738
+ export interface FlowParameter {
739
+ /** Parameter name */
740
+ name?: string;
741
+ /** Additional qualifier */
742
+ qualifier?: string;
743
+ /** Description of the parameter */
744
+ description?: string;
745
+ /** Data type of the value */
746
+ valueDataType?: string;
747
+ /** Value associated with the parameter */
748
+ value?: string;
749
+ }
750
+
751
+ export interface InteractionParticipant {
752
+ /** Unique participant identifier */
753
+ id: string;
754
+ /** Participant type label used by backend */
755
+ pType: string;
756
+ /** Friendly participant type */
757
+ type: string;
758
+ /** Whether the participant has joined */
759
+ hasJoined: boolean;
760
+ /** Whether the participant has left */
761
+ hasLeft: boolean;
762
+ /** Whether the participant is still in pre-dial */
763
+ isInPredial: boolean;
764
+ /** Optional caller identifier */
765
+ callerId?: string | null;
766
+ /** Whether auto-answer is enabled */
767
+ autoAnswerEnabled?: boolean;
768
+ /** Backchannel/bnr details */
769
+ bnrDetails?: unknown;
770
+ /** Channel identifier for the participant */
771
+ channelId?: string;
772
+ /** Current consult state */
773
+ consultState?: string | null;
774
+ /** Timestamp when consult started */
775
+ consultTimestamp?: number | null;
776
+ /** Current participant state */
777
+ currentState?: string | null;
778
+ /** Timestamp of the current state */
779
+ currentStateTimestamp?: number | null;
780
+ /** Device call identifier */
781
+ deviceCallId?: string | null;
782
+ /** Device identifier */
783
+ deviceId?: string | null;
784
+ /** Device type (AGENT_DN, BROWSER, etc.) */
785
+ deviceType?: string | null;
786
+ /** Dial number associated with participant */
787
+ dn?: string | null;
788
+ /** Whether participant is currently consulted */
789
+ isConsulted?: boolean;
790
+ /** Whether participant offer is active */
791
+ isOffered?: boolean;
792
+ /** Whether participant is in wrap-up */
793
+ isWrapUp?: boolean;
794
+ /** Whether participant completed wrap-up */
795
+ isWrappedUp?: boolean;
796
+ /** Timestamp of when participant joined */
797
+ joinTimestamp?: number | null;
798
+ /** Last updated timestamp */
799
+ lastUpdated?: number | null;
800
+ /** Friendly name of participant */
801
+ name?: string | null;
802
+ /** Queue identifier associated with participant */
803
+ queueId?: string;
804
+ /** Queue manager identifier */
805
+ queueMgrId?: string;
806
+ /** Session identifier */
807
+ sessionId?: string;
808
+ /** Site identifier */
809
+ siteId?: string;
810
+ /** Skill identifier */
811
+ skillId?: string | null;
812
+ /** Skill name */
813
+ skillName?: string | null;
814
+ /** Skill list for participant */
815
+ skills?: string[];
816
+ /** Team identifier */
817
+ teamId?: string;
818
+ /** Team name */
819
+ teamName?: string;
820
+ /** Timestamp for wrap-up */
821
+ wrapUpTimestamp?: number | null;
822
+ /** Additional metadata */
823
+ [key: string]: unknown;
824
+ }
825
+
826
+ export type InteractionParticipants = Record<string, InteractionParticipant>;
827
+
828
+ /**
829
+ * Media entry type from interaction.media
830
+ * Used for media state tracking in consult and conference scenarios
831
+ */
832
+ export type MediaEntry = {
833
+ /** Unique identifier for the media resource */
834
+ mediaResourceId: string;
835
+ /** Type of media channel */
836
+ mediaType: MEDIA_CHANNEL;
837
+ /** Media manager handling this media */
838
+ mediaMgr: string;
839
+ /** List of participant identifiers */
840
+ participants: string[];
841
+ /** Type of media (e.g., 'mainCall', 'consult') */
842
+ mType: string;
843
+ /** Indicates if media is on hold */
844
+ isHold: boolean;
845
+ /** Timestamp when media was put on hold */
846
+ holdTimestamp: number | null;
847
+ };
848
+
564
849
  export type Interaction = {
565
850
  /** Indicates if the interaction is managed by Flow Control */
566
851
  isFcManaged: boolean;
@@ -575,7 +860,11 @@ export type Interaction = {
575
860
  /** Current virtual team handling the interaction */
576
861
  currentVTeam: string;
577
862
  /** List of participants in the interaction */
578
- participants: any; // TODO: Define specific participant type
863
+ participants: InteractionParticipants;
864
+ /** Detailed call associated data */
865
+ callAssociatedData?: CallAssociatedData;
866
+ /** Simplified call associated key/value pairs */
867
+ callAssociatedDetails?: CallAssociatedDetails;
579
868
  /** Unique identifier for the interaction */
580
869
  interactionId: string;
581
870
  /** Organization identifier */
@@ -584,7 +873,18 @@ export type Interaction = {
584
873
  createdTimestamp?: number;
585
874
  /** Indicates if wrap-up assistance is enabled */
586
875
  isWrapUpAssist?: boolean;
587
- /** Detailed call processing information and metadata */
876
+ /** Identifier of parent interaction if applicable */
877
+ parentInteractionId?: string;
878
+ /** Indicates if media is forked for this interaction */
879
+ isMediaForked?: boolean;
880
+ /** Retroactive flow properties returned by backend */
881
+ flowProperties?: Record<string, unknown> | null;
882
+ /** Media specific properties returned by backend */
883
+ mediaProperties?: Record<string, unknown> | null;
884
+ /**
885
+ * Detailed call processing information and metadata.
886
+ * Mirrors the callProcessingDetails section described in Webex Contact Center Agent Contact payloads.
887
+ */
588
888
  callProcessingDetails: {
589
889
  /** Name of the Queue Manager handling this interaction */
590
890
  QMgrName: string;
@@ -602,20 +902,24 @@ export type Interaction = {
602
902
  QueueId: string;
603
903
  /** Virtual team identifier */
604
904
  vteamId: string;
605
- /** Indicates if pause/resume functionality is enabled */
606
- pauseResumeEnabled?: string;
905
+ /** Agent capability for pause/resume on this interaction */
906
+ pauseResumeEnabled?: boolean;
607
907
  /** Duration of pause in seconds */
608
908
  pauseDuration?: string;
609
- /** Indicates if the interaction is currently paused */
610
- isPaused?: string;
611
- /** Indicates if recording is in progress */
612
- recordInProgress?: string;
613
- /** Indicates if recording has started */
614
- recordingStarted?: string;
909
+ /** Legacy pause indicator (recordInProgress=false is the active pause signal) */
910
+ isPaused?: boolean;
911
+ /** Recording is actively capturing audio right now */
912
+ recordInProgress?: boolean;
913
+ /** Recording was started for this interaction (may be paused) */
914
+ recordingStarted?: boolean;
915
+ /** Customer geographic region */
916
+ customerRegion?: string;
917
+ /** Flow tag identifier */
918
+ flowTagId?: string;
615
919
  /** Indicates if Consult to Queue is in progress */
616
- ctqInProgress?: string;
920
+ ctqInProgress?: boolean;
617
921
  /** Indicates if outdial transfer to queue is enabled */
618
- outdialTransferToQueueEnabled?: string;
922
+ outdialTransferToQueueEnabled?: boolean;
619
923
  /** IVR conversation transcript */
620
924
  convIvrTranscript?: string;
621
925
  /** Customer's name */
@@ -702,64 +1006,67 @@ export type Interaction = {
702
1006
  fcDesktopView?: string;
703
1007
  /** Agent ID who initiated the outdial call */
704
1008
  outdialAgentId?: string;
1009
+ /** Indicates if the customer has left the call during an active consult */
1010
+ hasCustomerLeft?: string;
1011
+ /** Indicates if the skip action is disabled for campaign preview contacts */
1012
+ campaignPreviewSkipDisabled?: string;
1013
+ /** Indicates if the remove action is disabled for campaign preview contacts */
1014
+ campaignPreviewRemoveDisabled?: string;
1015
+ /** Auto-action to perform when campaign preview offer times out (ACCEPT, SKIP, REMOVE) */
1016
+ campaignPreviewAutoAction?: string;
1017
+ /** Timestamp (ms) when the campaign preview offer expires */
1018
+ campaignPreviewOfferTimeout?: string;
705
1019
  };
706
1020
  /** Main interaction identifier for related interactions */
707
1021
  mainInteractionId?: string;
1022
+ /** Timestamp when interaction entered queue */
1023
+ queuedTimestamp?: number | null;
708
1024
  /** Media-specific information for the interaction */
709
- media: Record<
710
- string,
711
- {
712
- /** Unique identifier for the media resource */
713
- mediaResourceId: string;
714
- /** Type of media channel */
715
- mediaType: MEDIA_CHANNEL;
716
- /** Media manager handling this media */
717
- mediaMgr: string;
718
- /** List of participant identifiers */
719
- participants: string[];
720
- /** Type of media */
721
- mType: string;
722
- /** Indicates if media is on hold */
723
- isHold: boolean;
724
- /** Timestamp when media was put on hold */
725
- holdTimestamp: number | null;
726
- }
727
- >;
1025
+ media: Record<string, MediaEntry>;
728
1026
  /** Owner of the interaction */
729
1027
  owner: string;
730
1028
  /** Primary media channel for the interaction */
731
- mediaChannel: MEDIA_CHANNEL;
1029
+ mediaChannel: string;
732
1030
  /** Direction information for the contact */
733
1031
  contactDirection: {type: string};
734
1032
  /** Type of outbound interaction */
735
1033
  outboundType?: string;
1034
+ /** Optional workflow manager identifier */
1035
+ workflowManager?: string | null;
736
1036
  /** Parameters passed through the call flow */
737
- callFlowParams: Record<
738
- string,
739
- {
740
- /** Name of the parameter */
741
- name: string;
742
- /** Qualifier for the parameter */
743
- qualifier: string;
744
- /** Description of the parameter */
745
- description: string;
746
- /** Data type of the parameter value */
747
- valueDataType: string;
748
- /** Value of the parameter */
749
- value: string;
750
- }
751
- >;
1037
+ callFlowParams?: Record<string, FlowParameter>;
752
1038
  };
753
1039
 
754
1040
  /**
755
- * Task payload containing detailed information about a contact center task
756
- * This structure encapsulates all relevant data for task management
1041
+ * Task payload mirroring the Agent Contact event payload from Webex Contact Center
1042
+ * (developer.webex.com). Arrives on AGENT_* websocket events and is the source of truth
1043
+ * for UI/state machine updates.
757
1044
  * @public
758
1045
  */
1046
+ export type RealtimeTranscription = {
1047
+ agentId: string;
1048
+ orgId: string;
1049
+ notifType: string;
1050
+ notifDetails: {
1051
+ actionEvent: string;
1052
+ };
1053
+ data: {
1054
+ role: 'AGENT' | 'CALLER';
1055
+ utteranceId: string;
1056
+ conversationId: string;
1057
+ publishTimestamp: number;
1058
+ messageId: string;
1059
+ isFinal: boolean;
1060
+ languageCode: string;
1061
+ orgId: string;
1062
+ content: string;
1063
+ };
1064
+ };
1065
+
759
1066
  export type TaskData = {
760
- /** Unique identifier for the media resource handling this task */
1067
+ /** Primary media resource identifier for the active leg (matches interaction.media[].mediaResourceId) */
761
1068
  mediaResourceId: string;
762
- /** Type of event that triggered this task data */
1069
+ /** Agent event name from the websocket stream (e.g., AGENT_CONTACT_ASSIGNED) */
763
1070
  eventType: string;
764
1071
  /** Timestamp when the event occurred */
765
1072
  eventTime?: number;
@@ -769,7 +1076,7 @@ export type TaskData = {
769
1076
  destAgentId: string;
770
1077
  /** Unique tracking identifier for the task */
771
1078
  trackingId: string;
772
- /** Media resource identifier for consultation operations */
1079
+ /** Media resource identifier for consultation leg when present */
773
1080
  consultMediaResourceId: string;
774
1081
  /** Detailed interaction information */
775
1082
  interaction: Interaction;
@@ -781,7 +1088,7 @@ export type TaskData = {
781
1088
  toOwner?: boolean;
782
1089
  /** Identifier for child interaction in consult/transfer scenarios */
783
1090
  childInteractionId?: string;
784
- /** Unique identifier for the interaction */
1091
+ /** Interaction/contact identifier from backend (same as interaction.interactionId) */
785
1092
  interactionId: string;
786
1093
  /** Organization identifier */
787
1094
  orgId: string;
@@ -791,7 +1098,7 @@ export type TaskData = {
791
1098
  queueMgr: string;
792
1099
  /** Name of the queue where task is queued */
793
1100
  queueName?: string;
794
- /** Type of the task */
1101
+ /** Task/interaction type returned by the platform (routing/monitoring/etc.) */
795
1102
  type: string;
796
1103
  /** Timeout value for RONA (Redirection on No Answer) in seconds */
797
1104
  ronaTimeout?: number;
@@ -827,12 +1134,107 @@ export type TaskData = {
827
1134
  reservedAgentChannelId?: string;
828
1135
  /** Indicates if wrap-up is required for this task */
829
1136
  wrapUpRequired?: boolean;
1137
+
1138
+ /**
1139
+ * Current consultation status derived from state machine
1140
+ * Values: CONSULT_INITIATED, CONSULT_ACCEPTED, BEING_CONSULTED,
1141
+ * BEING_CONSULTED_ACCEPTED, CONNECTED, CONFERENCE, CONSULT_COMPLETED
1142
+ */
1143
+ consultStatus?: string;
1144
+
1145
+ /**
1146
+ * Indicates if consultation is in progress (state machine: CONSULTING)
1147
+ */
1148
+ isConsultInProgress?: boolean;
1149
+
1150
+ /**
1151
+ * Indicates if the task is incoming for the active agent
1152
+ */
1153
+ isIncomingTask?: boolean;
1154
+
1155
+ /**
1156
+ * Indicates if the task is on hold (state machine: HELD)
1157
+ */
1158
+ isOnHold?: boolean;
1159
+
1160
+ /**
1161
+ * Indicates if customer is currently in the call
1162
+ * Derived from participants in main media
1163
+ */
1164
+ isCustomerInCall?: boolean;
1165
+
1166
+ /**
1167
+ * Count of conference participants (agents only)
1168
+ * Used for determining if max participants reached
1169
+ */
1170
+ conferenceParticipantsCount?: number;
1171
+
1172
+ /**
1173
+ * Indicates if this is a secondary agent (consulted party)
1174
+ */
1175
+ isSecondaryAgent?: boolean;
1176
+
1177
+ /**
1178
+ * Indicates if this is a secondary EP-DN agent (telephony consult to external)
1179
+ */
1180
+ isSecondaryEpDnAgent?: boolean;
1181
+
1182
+ /**
1183
+ * Task state for MPC (Multi-Party Conference) scenarios
1184
+ * Maps participant consultState to task state
1185
+ */
1186
+ mpcState?: string;
830
1187
  /** Indicates if auto-answer is in progress for this task */
831
1188
  isAutoAnswering?: boolean;
832
1189
  /** Indicates if wrap-up is required for this task */
833
1190
  agentsPendingWrapUp?: string[];
834
1191
  };
835
1192
 
1193
+ export type TaskUIControlState = {
1194
+ isVisible: boolean;
1195
+ isEnabled: boolean;
1196
+ };
1197
+
1198
+ /**
1199
+ * UI control representation for a single interaction leg.
1200
+ */
1201
+ export type InteractionUIControls = {
1202
+ accept: TaskUIControlState;
1203
+ decline: TaskUIControlState;
1204
+ hold: TaskUIControlState;
1205
+ transfer: TaskUIControlState;
1206
+ consult: TaskUIControlState;
1207
+ end: TaskUIControlState;
1208
+ recording: TaskUIControlState;
1209
+ mute: TaskUIControlState;
1210
+ consultTransfer: TaskUIControlState;
1211
+ endConsult: TaskUIControlState;
1212
+ conference: TaskUIControlState;
1213
+ exitConference: TaskUIControlState;
1214
+ transferConference: TaskUIControlState;
1215
+ mergeToConference: TaskUIControlState;
1216
+ wrapup: TaskUIControlState;
1217
+ switch: TaskUIControlState;
1218
+ };
1219
+
1220
+ export type TaskUILeg = 'main' | 'consult';
1221
+
1222
+ /**
1223
+ * UI controls surfaced to task consumers.
1224
+ * Consumers should read controls from the per-leg surfaces and use `activeLeg`
1225
+ * to determine which one is currently interactive.
1226
+ */
1227
+ export type TaskUIControls = {
1228
+ main: InteractionUIControls;
1229
+ consult: InteractionUIControls;
1230
+ activeLeg: TaskUILeg;
1231
+ };
1232
+
1233
+ /**
1234
+ * Helper class for managing task action control state
1235
+ * Tracks visibility and enabled state for task actions that can be executed
1236
+ * @public
1237
+ */
836
1238
  /**
837
1239
  * Type representing an agent contact message within the contact center system
838
1240
  * Contains comprehensive interaction and task related details for agent operations
@@ -1054,6 +1456,15 @@ export type TransferPayload = {
1054
1456
  destinationType: DestinationType;
1055
1457
  };
1056
1458
 
1459
+ /**
1460
+ * Options for configuring transfer behavior
1461
+ * @public
1462
+ */
1463
+ export type TransferOptions = {
1464
+ /** Additional transfer configuration options */
1465
+ [key: string]: unknown;
1466
+ };
1467
+
1057
1468
  /**
1058
1469
  * API payload for ending a consultation
1059
1470
  * This is the actual payload that is sent to the developer API
@@ -1175,6 +1586,41 @@ export type ContactCleanupData = {
1175
1586
  };
1176
1587
  };
1177
1588
 
1589
+ /**
1590
+ * Boolean-like fields in callProcessingDetails that may arrive as strings.
1591
+ * Used by taskDataNormalizer to coerce payloads to actual booleans.
1592
+ */
1593
+ export type CallProcessingBooleanKey =
1594
+ | 'recordingStarted'
1595
+ | 'recordInProgress'
1596
+ | 'isPaused'
1597
+ | 'pauseResumeEnabled'
1598
+ | 'ctqInProgress'
1599
+ | 'outdialTransferToQueueEnabled'
1600
+ | 'taskToBeSelfServiced'
1601
+ | 'CONTINUE_RECORDING_ON_TRANSFER'
1602
+ | 'isParked'
1603
+ | 'participantInviteTimeout'
1604
+ | 'checkAgentAvailability';
1605
+
1606
+ /**
1607
+ * Interaction-level boolean fields that may arrive as strings from backend payloads.
1608
+ */
1609
+ export type InteractionBooleanKey = 'isFcManaged' | 'isMediaForked' | 'isTerminated';
1610
+
1611
+ /**
1612
+ * Participant boolean fields that may arrive as strings and need normalization.
1613
+ */
1614
+ export type ParticipantBooleanKey =
1615
+ | 'autoAnswerEnabled'
1616
+ | 'hasJoined'
1617
+ | 'hasLeft'
1618
+ | 'isConsulted'
1619
+ | 'isInPredial'
1620
+ | 'isOffered'
1621
+ | 'isWrapUp'
1622
+ | 'isWrappedUp';
1623
+
1178
1624
  /**
1179
1625
  * Response type for task public methods
1180
1626
  * Can be an {@link AgentContact} object containing updated task state,
@@ -1183,11 +1629,38 @@ export type ContactCleanupData = {
1183
1629
  */
1184
1630
  export type TaskResponse = AgentContact | Error | void;
1185
1631
 
1632
+ /**
1633
+ * Payload shape used by consult conference helper utilities.
1634
+ */
1635
+ export type consultConferencePayloadData = {
1636
+ agentId?: string;
1637
+ destinationType?: string;
1638
+ destAgentId?: string;
1639
+ };
1640
+
1641
+ /**
1642
+ * Minimal event-emitter contract exposed to SDK consumers.
1643
+ * Defined here so that consumers do NOT need `@types/node` in their tsconfig.
1644
+ * The runtime Task class still extends Node's EventEmitter (via ampersand-events),
1645
+ * which satisfies this interface at runtime.
1646
+ * @public
1647
+ */
1648
+ export interface IEventEmitter {
1649
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1650
+ on(event: string, listener: (...args: any[]) => void): this;
1651
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1652
+ off(event: string, listener: (...args: any[]) => void): this;
1653
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1654
+ once(event: string, listener: (...args: any[]) => void): this;
1655
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1656
+ emit(event: string, ...args: any[]): boolean;
1657
+ }
1658
+
1186
1659
  /**
1187
1660
  * Interface for managing task-related operations in the contact center
1188
- * Extends EventEmitter to support event-driven task updates
1661
+ * Extends IEventEmitter to support event-driven task updates
1189
1662
  */
1190
- export interface ITask extends EventEmitter {
1663
+ export interface ITask extends IEventEmitter {
1191
1664
  /**
1192
1665
  * Event data received in the Contact Center events.
1193
1666
  * Contains detailed task information including interaction details, media resources,
@@ -1207,6 +1680,36 @@ export interface ITask extends EventEmitter {
1207
1680
  */
1208
1681
  autoWrapup?: AutoWrapup;
1209
1682
 
1683
+ /**
1684
+ * Latest UI controls derived from the state machine.
1685
+ * Each control has `isVisible` and `isEnabled` flags computed from current task state.
1686
+ * Subscribe to {@link TASK_EVENTS.TASK_UI_CONTROLS_UPDATED} for change notifications.
1687
+ */
1688
+ readonly uiControls: TaskUIControls;
1689
+
1690
+ /**
1691
+ * State machine instance for managing task state transitions and derived properties.
1692
+ * The state machine handles:
1693
+ * - State transitions (IDLE → OFFERED → CONNECTED → HELD, etc.)
1694
+ * - Derived properties (canHold, canResume, isConsulted, etc.)
1695
+ * - Action availability based on current state
1696
+ *
1697
+ * This is part of the migration from manual state management to centralized state machine.
1698
+ * During the transition period, both the old setUIControls() and state machine coexist.
1699
+ *
1700
+ * @see createTaskStateMachine
1701
+ * @internal
1702
+ */
1703
+ stateMachineService?: AnyActorRef;
1704
+ state?: any;
1705
+
1706
+ /**
1707
+ * Helper method to send events to the state machine.
1708
+ * This is part of the migration to XState.
1709
+ * @internal
1710
+ */
1711
+ sendStateMachineEvent: (event: TaskEventPayload) => void;
1712
+
1210
1713
  /**
1211
1714
  * Cancels the auto-wrapup timer for the task.
1212
1715
  * This method stops the auto-wrapup process if it is currently active.
@@ -1228,7 +1731,7 @@ export interface ITask extends EventEmitter {
1228
1731
  * @returns Updated task instance
1229
1732
  * @ignore
1230
1733
  */
1231
- updateTaskData(newData: TaskData): ITask;
1734
+ updateTaskData(newData: TaskData): void;
1232
1735
 
1233
1736
  /**
1234
1737
  * Answers or accepts an incoming task.
@@ -1360,18 +1863,7 @@ export interface ITask extends EventEmitter {
1360
1863
  * await task.transfer({ to: "queueId", destinationType: "queue" });
1361
1864
  * ```
1362
1865
  */
1363
- transfer(transferPayload: TransferPayLoad): Promise<TaskResponse>;
1364
-
1365
- /**
1366
- * Transfers the task after consultation.
1367
- * @param consultTransferPayload - Details for consult transfer (optional)
1368
- * @returns Promise<TaskResponse>
1369
- * @example
1370
- * ```typescript
1371
- * await task.consultTransfer({ to: "agentId", destinationType: "agent" });
1372
- * ```
1373
- */
1374
- consultTransfer(consultTransferPayload?: ConsultTransferPayLoad): Promise<TaskResponse>;
1866
+ transfer(transferPayload: TransferPayLoad, options?: TransferOptions): Promise<TaskResponse>;
1375
1867
 
1376
1868
  /**
1377
1869
  * Initiates a consult conference (merge consult call with main call).
@@ -1403,6 +1895,19 @@ export interface ITask extends EventEmitter {
1403
1895
  */
1404
1896
  transferConference(): Promise<TaskResponse>;
1405
1897
 
1898
+ /**
1899
+ * Toggles between consult call and main call during consulting.
1900
+ * If on consult leg, switches to main call (holds consult).
1901
+ * If on main call, switches to consult (resumes consult).
1902
+ * Only available when in CONSULTING state.
1903
+ * @returns Promise<TaskResponse>
1904
+ * @example
1905
+ * ```typescript
1906
+ * await task.switchCall();
1907
+ * ```
1908
+ */
1909
+ switchCall(): Promise<TaskResponse>;
1910
+
1406
1911
  /**
1407
1912
  * Toggles mute/unmute for the local audio stream during a WebRTC task.
1408
1913
  * @returns Promise<void>
@@ -1413,3 +1918,137 @@ export interface ITask extends EventEmitter {
1413
1918
  */
1414
1919
  toggleMute(): Promise<void>;
1415
1920
  }
1921
+
1922
+ /**
1923
+ * Interface for managing digital channel task operations in the contact center
1924
+ * Digital channels (chat, email, social, SMS) have a simpler interface than voice
1925
+ * Extends ITask but overrides updateTaskData to return IDigital
1926
+ * @public
1927
+ */
1928
+ export interface IDigital extends Omit<ITask, 'updateTaskData'> {
1929
+ /**
1930
+ * Updates the task data
1931
+ * @param newData - Updated task data
1932
+ * @param shouldOverwrite - Whether to completely replace existing data
1933
+ * @returns Updated Digital task instance
1934
+ */
1935
+ updateTaskData(newData: TaskData, shouldOverwrite?: boolean): IDigital;
1936
+ }
1937
+
1938
+ /**
1939
+ * Interface for managing voice/telephony task operations in the contact center
1940
+ * Extends ITask with voice-specific functionality for hold/resume operations
1941
+ * @public
1942
+ */
1943
+ export interface IVoice extends ITask {
1944
+ /**
1945
+ * Toggles hold/resume state for a voice task.
1946
+ * If the task is currently on hold, it will be resumed.
1947
+ * If the task is active, it will be placed on hold.
1948
+ * @returns Promise<TaskResponse>
1949
+ * @example
1950
+ * ```typescript
1951
+ * await voiceTask.holdResume();
1952
+ * ```
1953
+ */
1954
+ holdResume(): Promise<TaskResponse>;
1955
+ }
1956
+
1957
+ /**
1958
+ * Configuration options for voice task UI controls
1959
+ */
1960
+ export type VoiceUIControlOptions = {
1961
+ isEndTaskEnabled?: boolean;
1962
+ isEndConsultEnabled?: boolean;
1963
+ voiceVariant?: VoiceVariant;
1964
+ isRecordingEnabled?: boolean;
1965
+ };
1966
+
1967
+ /**
1968
+ * Participant information for UI display
1969
+ */
1970
+ export type Participant = {
1971
+ id: string;
1972
+ name?: string;
1973
+ pType?: string;
1974
+ };
1975
+
1976
+ /**
1977
+ * @deprecated Use Participant instead
1978
+ */
1979
+ export type TaskAccessorParticipant = Participant;
1980
+
1981
+ export interface IWebRTC extends IVoice {
1982
+ /**
1983
+ * This method is used to mute/unmute the call.
1984
+ * @returns Promise<void>
1985
+ * @example
1986
+ * ```typescript
1987
+ * task.toggleMute();
1988
+ * ```
1989
+ */
1990
+ toggleMute(): Promise<void>;
1991
+ /**
1992
+ * Decline the incoming task for Browser Login
1993
+ *
1994
+ * @example
1995
+ * ```
1996
+ * task.decline();
1997
+ * ```
1998
+ */
1999
+ decline(): Promise<TaskResponse>;
2000
+ /**
2001
+ * This method is used to unregister the web call listeners.
2002
+ * @returns void
2003
+ * @example
2004
+ * ```typescript
2005
+ * task.unregisterWebCallListeners();
2006
+ * ```
2007
+ */
2008
+ unregisterWebCallListeners(): void;
2009
+ }
2010
+
2011
+ export type WebSocketPayload = TaskData & {
2012
+ type: string;
2013
+ mediaResourceId?: string;
2014
+ reason?: string;
2015
+ /**
2016
+ * Optional real-time transcript chunk payload.
2017
+ * Present on REAL_TIME_TRANSCRIPTION notifications.
2018
+ */
2019
+ data?: RealtimeTranscription['data'];
2020
+ };
2021
+
2022
+ export type WebSocketMessage = {
2023
+ keepalive?: 'true' | 'false' | boolean;
2024
+ type?: string;
2025
+ data: WebSocketPayload;
2026
+ };
2027
+
2028
+ /**
2029
+ * Actions to be performed after handling an event
2030
+ *
2031
+ * These actions represent TaskManager-level concerns (task collection lifecycle,
2032
+ * resource cleanup) rather than task-level state machine concerns. The separation
2033
+ * ensures proper responsibility:
2034
+ * - TaskManager: Collection management, metrics, cleanup
2035
+ * - State Machine: Task state transitions, event emissions, UI controls
2036
+ */
2037
+ export interface TaskEventActions {
2038
+ task?: ITask;
2039
+ }
2040
+
2041
+ /**
2042
+ * Context for processing an event
2043
+ *
2044
+ * Contains all information needed to process a WebSocket event:
2045
+ * - Event type and payload from the backend
2046
+ * - Task instance (if exists)
2047
+ * - Pre-mapped state machine event (if applicable)
2048
+ */
2049
+ export interface EventContext {
2050
+ eventType: string;
2051
+ payload: WebSocketPayload;
2052
+ task?: ITask;
2053
+ stateMachineEvent?: TaskEventPayload | null;
2054
+ }