@webex/contact-center 3.11.0 → 3.12.0-llmrefactor.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (267) hide show
  1. package/.sdd/manifest.json +882 -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 +379 -50
  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 +22 -2
  44. package/dist/constants.js.map +1 -1
  45. package/dist/index.js +27 -5
  46. package/dist/index.js.map +1 -1
  47. package/dist/metrics/behavioral-events.js +114 -0
  48. package/dist/metrics/behavioral-events.js.map +1 -1
  49. package/dist/metrics/constants.js +32 -3
  50. package/dist/metrics/constants.js.map +1 -1
  51. package/dist/services/ApiAiAssistant.js +318 -0
  52. package/dist/services/ApiAiAssistant.js.map +1 -0
  53. package/dist/services/UserPreference.js +427 -0
  54. package/dist/services/UserPreference.js.map +1 -0
  55. package/dist/services/agent/types.js.map +1 -1
  56. package/dist/services/config/Util.js +8 -4
  57. package/dist/services/config/Util.js.map +1 -1
  58. package/dist/services/config/constants.js +35 -2
  59. package/dist/services/config/constants.js.map +1 -1
  60. package/dist/services/config/index.js +41 -2
  61. package/dist/services/config/index.js.map +1 -1
  62. package/dist/services/config/types.js +66 -8
  63. package/dist/services/config/types.js.map +1 -1
  64. package/dist/services/constants.js +27 -1
  65. package/dist/services/constants.js.map +1 -1
  66. package/dist/services/core/Err.js.map +1 -1
  67. package/dist/services/core/Utils.js +122 -25
  68. package/dist/services/core/Utils.js.map +1 -1
  69. package/dist/services/core/aqm-reqs.js +92 -17
  70. package/dist/services/core/aqm-reqs.js.map +1 -1
  71. package/dist/services/core/websocket/WebSocketManager.js +22 -6
  72. package/dist/services/core/websocket/WebSocketManager.js.map +1 -1
  73. package/dist/services/core/websocket/connection-service.js +3 -1
  74. package/dist/services/core/websocket/connection-service.js.map +1 -1
  75. package/dist/services/core/websocket/types.js.map +1 -1
  76. package/dist/services/index.js +6 -0
  77. package/dist/services/index.js.map +1 -1
  78. package/dist/services/task/Task.js +688 -0
  79. package/dist/services/task/Task.js.map +1 -0
  80. package/dist/services/task/TaskFactory.js +45 -0
  81. package/dist/services/task/TaskFactory.js.map +1 -0
  82. package/dist/services/task/TaskManager.js +751 -457
  83. package/dist/services/task/TaskManager.js.map +1 -1
  84. package/dist/services/task/TaskUtils.js +220 -23
  85. package/dist/services/task/TaskUtils.js.map +1 -1
  86. package/dist/services/task/constants.js +23 -2
  87. package/dist/services/task/constants.js.map +1 -1
  88. package/dist/services/task/dialer.js +129 -0
  89. package/dist/services/task/dialer.js.map +1 -1
  90. package/dist/services/task/digital/Digital.js +77 -0
  91. package/dist/services/task/digital/Digital.js.map +1 -0
  92. package/dist/services/task/state-machine/TaskStateMachine.js +873 -0
  93. package/dist/services/task/state-machine/TaskStateMachine.js.map +1 -0
  94. package/dist/services/task/state-machine/actions.js +567 -0
  95. package/dist/services/task/state-machine/actions.js.map +1 -0
  96. package/dist/services/task/state-machine/constants.js +161 -0
  97. package/dist/services/task/state-machine/constants.js.map +1 -0
  98. package/dist/services/task/state-machine/guards.js +382 -0
  99. package/dist/services/task/state-machine/guards.js.map +1 -0
  100. package/dist/services/task/state-machine/index.js +53 -0
  101. package/dist/services/task/state-machine/index.js.map +1 -0
  102. package/dist/services/task/state-machine/types.js +54 -0
  103. package/dist/services/task/state-machine/types.js.map +1 -0
  104. package/dist/services/task/state-machine/uiControlsComputer.js +603 -0
  105. package/dist/services/task/state-machine/uiControlsComputer.js.map +1 -0
  106. package/dist/services/task/taskDataNormalizer.js +99 -0
  107. package/dist/services/task/taskDataNormalizer.js.map +1 -0
  108. package/dist/services/task/types.js +227 -4
  109. package/dist/services/task/types.js.map +1 -1
  110. package/dist/services/task/voice/Voice.js +1044 -0
  111. package/dist/services/task/voice/Voice.js.map +1 -0
  112. package/dist/services/task/voice/WebRTC.js +149 -0
  113. package/dist/services/task/voice/WebRTC.js.map +1 -0
  114. package/dist/types/cc.d.ts +894 -0
  115. package/dist/types/config.d.ts +72 -0
  116. package/dist/types/constants.d.ts +66 -0
  117. package/dist/types/index.d.ts +199 -0
  118. package/dist/types/logger-proxy.d.ts +71 -0
  119. package/dist/types/metrics/MetricsManager.d.ts +223 -0
  120. package/dist/types/metrics/behavioral-events.d.ts +29 -0
  121. package/dist/types/metrics/constants.d.ts +181 -0
  122. package/dist/types/services/AddressBook.d.ts +74 -0
  123. package/dist/types/services/ApiAiAssistant.d.ts +49 -0
  124. package/dist/types/services/EntryPoint.d.ts +67 -0
  125. package/dist/types/services/Queue.d.ts +76 -0
  126. package/dist/types/services/UserPreference.d.ts +118 -0
  127. package/dist/types/services/WebCallingService.d.ts +1 -0
  128. package/dist/types/services/agent/index.d.ts +46 -0
  129. package/dist/types/services/agent/types.d.ts +413 -0
  130. package/dist/types/services/config/Util.d.ts +20 -0
  131. package/dist/types/services/config/constants.d.ts +270 -0
  132. package/dist/types/services/config/index.d.ts +177 -0
  133. package/dist/types/services/config/types.d.ts +1368 -0
  134. package/dist/types/services/constants.d.ts +110 -0
  135. package/dist/types/services/core/Err.d.ts +125 -0
  136. package/dist/types/services/core/GlobalTypes.d.ts +58 -0
  137. package/dist/types/services/core/Utils.d.ts +121 -0
  138. package/dist/types/services/core/WebexRequest.d.ts +22 -0
  139. package/dist/types/services/core/aqm-reqs.d.ts +65 -0
  140. package/dist/types/services/core/constants.d.ts +99 -0
  141. package/dist/types/services/core/types.d.ts +47 -0
  142. package/dist/types/services/core/websocket/WebSocketManager.d.ts +36 -0
  143. package/dist/types/services/core/websocket/connection-service.d.ts +27 -0
  144. package/dist/types/services/core/websocket/keepalive.worker.d.ts +2 -0
  145. package/dist/types/services/core/websocket/types.d.ts +37 -0
  146. package/dist/types/services/index.d.ts +54 -0
  147. package/dist/types/services/task/AutoWrapup.d.ts +40 -0
  148. package/dist/types/services/task/Task.d.ts +157 -0
  149. package/dist/types/services/task/TaskFactory.d.ts +12 -0
  150. package/dist/types/services/task/TaskManager.d.ts +1 -0
  151. package/dist/types/services/task/TaskUtils.d.ts +138 -0
  152. package/dist/types/services/task/constants.d.ts +91 -0
  153. package/dist/types/services/task/contact.d.ts +69 -0
  154. package/dist/types/services/task/dialer.d.ts +73 -0
  155. package/dist/types/services/task/digital/Digital.d.ts +22 -0
  156. package/dist/types/services/task/state-machine/TaskStateMachine.d.ts +1194 -0
  157. package/dist/types/services/task/state-machine/actions.d.ts +10 -0
  158. package/dist/types/services/task/state-machine/constants.d.ts +107 -0
  159. package/dist/types/services/task/state-machine/guards.d.ts +102 -0
  160. package/dist/types/services/task/state-machine/index.d.ts +13 -0
  161. package/dist/types/services/task/state-machine/types.d.ts +269 -0
  162. package/dist/types/services/task/state-machine/uiControlsComputer.d.ts +9 -0
  163. package/dist/types/services/task/taskDataNormalizer.d.ts +10 -0
  164. package/dist/types/services/task/types.d.ts +1856 -0
  165. package/dist/types/services/task/voice/Voice.d.ts +184 -0
  166. package/dist/types/services/task/voice/WebRTC.d.ts +53 -0
  167. package/dist/types/types.d.ts +778 -0
  168. package/dist/types/utils/PageCache.d.ts +173 -0
  169. package/dist/types/webex-config.d.ts +53 -0
  170. package/dist/types/webex.d.ts +8 -0
  171. package/dist/types.js +130 -1
  172. package/dist/types.js.map +1 -1
  173. package/dist/webex.js +14 -2
  174. package/dist/webex.js.map +1 -1
  175. package/package.json +16 -12
  176. package/src/cc.ts +477 -51
  177. package/src/config.ts +6 -0
  178. package/src/constants.ts +21 -1
  179. package/src/index.ts +24 -5
  180. package/src/metrics/ai-docs/AGENTS.md +350 -0
  181. package/src/metrics/ai-docs/ARCHITECTURE.md +338 -0
  182. package/src/metrics/ai-docs/metrics-spec.md +854 -0
  183. package/src/metrics/behavioral-events.ts +120 -0
  184. package/src/metrics/constants.ts +37 -3
  185. package/src/services/ApiAiAssistant.ts +412 -0
  186. package/src/services/UserPreference.ts +509 -0
  187. package/src/services/agent/ai-docs/AGENTS.md +240 -0
  188. package/src/services/agent/ai-docs/ARCHITECTURE.md +304 -0
  189. package/src/services/agent/ai-docs/agent-spec.md +504 -0
  190. package/src/services/agent/types.ts +1 -1
  191. package/src/services/ai-docs/AGENTS.md +386 -0
  192. package/src/services/ai-docs/services-spec.md +492 -0
  193. package/src/services/config/Util.ts +10 -2
  194. package/src/services/config/ai-docs/AGENTS.md +255 -0
  195. package/src/services/config/ai-docs/ARCHITECTURE.md +426 -0
  196. package/src/services/config/ai-docs/config-spec.md +669 -0
  197. package/src/services/config/constants.ts +37 -1
  198. package/src/services/config/index.ts +45 -1
  199. package/src/services/config/types.ts +241 -11
  200. package/src/services/constants.ts +29 -0
  201. package/src/services/core/Err.ts +3 -0
  202. package/src/services/core/Utils.ts +143 -30
  203. package/src/services/core/ai-docs/AGENTS.md +381 -0
  204. package/src/services/core/ai-docs/ARCHITECTURE.md +698 -0
  205. package/src/services/core/ai-docs/core-spec.md +783 -0
  206. package/src/services/core/aqm-reqs.ts +100 -22
  207. package/src/services/core/websocket/WebSocketManager.ts +23 -6
  208. package/src/services/core/websocket/connection-service.ts +5 -1
  209. package/src/services/core/websocket/types.ts +1 -1
  210. package/src/services/index.ts +4 -0
  211. package/src/services/task/Task.ts +837 -0
  212. package/src/services/task/TaskFactory.ts +55 -0
  213. package/src/services/task/TaskManager.ts +793 -521
  214. package/src/services/task/TaskUtils.ts +314 -24
  215. package/src/services/task/ai-docs/AGENTS.md +457 -0
  216. package/src/services/task/ai-docs/ARCHITECTURE.md +594 -0
  217. package/src/services/task/ai-docs/task-spec.md +1319 -0
  218. package/src/services/task/constants.ts +23 -0
  219. package/src/services/task/dialer.ts +136 -1
  220. package/src/services/task/digital/Digital.ts +95 -0
  221. package/src/services/task/state-machine/TaskStateMachine.ts +1166 -0
  222. package/src/services/task/state-machine/actions.ts +738 -0
  223. package/src/services/task/state-machine/ai-docs/AGENTS.md +458 -0
  224. package/src/services/task/state-machine/ai-docs/ARCHITECTURE.md +1137 -0
  225. package/src/services/task/state-machine/ai-docs/task-state-machine-spec.md +2177 -0
  226. package/src/services/task/state-machine/constants.ts +172 -0
  227. package/src/services/task/state-machine/guards.ts +445 -0
  228. package/src/services/task/state-machine/index.ts +28 -0
  229. package/src/services/task/state-machine/types.ts +243 -0
  230. package/src/services/task/state-machine/uiControlsComputer.ts +961 -0
  231. package/src/services/task/taskDataNormalizer.ts +137 -0
  232. package/src/services/task/types.ts +734 -71
  233. package/src/services/task/voice/Voice.ts +1270 -0
  234. package/src/services/task/voice/WebRTC.ts +187 -0
  235. package/src/types.ts +205 -2
  236. package/src/utils/AGENTS.md +278 -0
  237. package/src/utils/ai-docs/utils-spec.md +381 -0
  238. package/src/webex.js +2 -0
  239. package/test/unit/spec/cc.ts +503 -43
  240. package/test/unit/spec/logger-proxy.ts +70 -0
  241. package/test/unit/spec/services/ApiAiAssistant.ts +273 -0
  242. package/test/unit/spec/services/UserPreference.ts +401 -0
  243. package/test/unit/spec/services/WebCallingService.ts +7 -1
  244. package/test/unit/spec/services/config/index.ts +85 -29
  245. package/test/unit/spec/services/core/Utils.ts +481 -2
  246. package/test/unit/spec/services/core/websocket/WebSocketManager.ts +137 -41
  247. package/test/unit/spec/services/core/websocket/connection-service.ts +3 -1
  248. package/test/unit/spec/services/task/AutoWrapup.ts +63 -0
  249. package/test/unit/spec/services/task/Task.ts +477 -0
  250. package/test/unit/spec/services/task/TaskFactory.ts +62 -0
  251. package/test/unit/spec/services/task/TaskManager.ts +1001 -1003
  252. package/test/unit/spec/services/task/TaskUtils.ts +235 -0
  253. package/test/unit/spec/services/task/dialer.ts +372 -96
  254. package/test/unit/spec/services/task/digital/Digital.ts +105 -0
  255. package/test/unit/spec/services/task/state-machine/TaskStateMachine.ts +2651 -0
  256. package/test/unit/spec/services/task/state-machine/guards.ts +637 -0
  257. package/test/unit/spec/services/task/state-machine/types.ts +18 -0
  258. package/test/unit/spec/services/task/state-machine/uiControlsComputer.ts +2663 -0
  259. package/test/unit/spec/services/task/taskTestUtils.ts +87 -0
  260. package/test/unit/spec/services/task/voice/Voice.ts +649 -0
  261. package/test/unit/spec/services/task/voice/WebRTC.ts +235 -0
  262. package/umd/contact-center.min.js +2 -2
  263. package/umd/contact-center.min.js.map +1 -1
  264. package/dist/services/task/index.js +0 -1525
  265. package/dist/services/task/index.js.map +0 -1
  266. package/src/services/task/index.ts +0 -1801
  267. 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
@@ -542,6 +628,77 @@ export enum TASK_EVENTS {
542
628
  * ```
543
629
  */
544
630
  TASK_POST_CALL_ACTIVITY = 'task:postCallActivity',
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
+
643
+ /**
644
+ * Triggered when a campaign preview contact is offered to the agent
645
+ * @example
646
+ * ```typescript
647
+ * task.on(TASK_EVENTS.TASK_CAMPAIGN_PREVIEW_RESERVATION, (data: AgentContact) => {
648
+ * console.log('Campaign preview contact received:', data.interactionId);
649
+ * // Handle campaign preview reservation
650
+ * });
651
+ * ```
652
+ */
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',
545
702
  }
546
703
 
547
704
  /**
@@ -549,6 +706,146 @@ export enum TASK_EVENTS {
549
706
  * Contains comprehensive details about an ongoing customer interaction
550
707
  * @public
551
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
+
552
849
  export type Interaction = {
553
850
  /** Indicates if the interaction is managed by Flow Control */
554
851
  isFcManaged: boolean;
@@ -563,7 +860,11 @@ export type Interaction = {
563
860
  /** Current virtual team handling the interaction */
564
861
  currentVTeam: string;
565
862
  /** List of participants in the interaction */
566
- 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;
567
868
  /** Unique identifier for the interaction */
568
869
  interactionId: string;
569
870
  /** Organization identifier */
@@ -572,7 +873,18 @@ export type Interaction = {
572
873
  createdTimestamp?: number;
573
874
  /** Indicates if wrap-up assistance is enabled */
574
875
  isWrapUpAssist?: boolean;
575
- /** 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
+ */
576
888
  callProcessingDetails: {
577
889
  /** Name of the Queue Manager handling this interaction */
578
890
  QMgrName: string;
@@ -590,20 +902,24 @@ export type Interaction = {
590
902
  QueueId: string;
591
903
  /** Virtual team identifier */
592
904
  vteamId: string;
593
- /** Indicates if pause/resume functionality is enabled */
594
- pauseResumeEnabled?: string;
905
+ /** Agent capability for pause/resume on this interaction */
906
+ pauseResumeEnabled?: boolean;
595
907
  /** Duration of pause in seconds */
596
908
  pauseDuration?: string;
597
- /** Indicates if the interaction is currently paused */
598
- isPaused?: string;
599
- /** Indicates if recording is in progress */
600
- recordInProgress?: string;
601
- /** Indicates if recording has started */
602
- 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;
603
919
  /** Indicates if Consult to Queue is in progress */
604
- ctqInProgress?: string;
920
+ ctqInProgress?: boolean;
605
921
  /** Indicates if outdial transfer to queue is enabled */
606
- outdialTransferToQueueEnabled?: string;
922
+ outdialTransferToQueueEnabled?: boolean;
607
923
  /** IVR conversation transcript */
608
924
  convIvrTranscript?: string;
609
925
  /** Customer's name */
@@ -690,64 +1006,67 @@ export type Interaction = {
690
1006
  fcDesktopView?: string;
691
1007
  /** Agent ID who initiated the outdial call */
692
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;
693
1019
  };
694
1020
  /** Main interaction identifier for related interactions */
695
1021
  mainInteractionId?: string;
1022
+ /** Timestamp when interaction entered queue */
1023
+ queuedTimestamp?: number | null;
696
1024
  /** Media-specific information for the interaction */
697
- media: Record<
698
- string,
699
- {
700
- /** Unique identifier for the media resource */
701
- mediaResourceId: string;
702
- /** Type of media channel */
703
- mediaType: MEDIA_CHANNEL;
704
- /** Media manager handling this media */
705
- mediaMgr: string;
706
- /** List of participant identifiers */
707
- participants: string[];
708
- /** Type of media */
709
- mType: string;
710
- /** Indicates if media is on hold */
711
- isHold: boolean;
712
- /** Timestamp when media was put on hold */
713
- holdTimestamp: number | null;
714
- }
715
- >;
1025
+ media: Record<string, MediaEntry>;
716
1026
  /** Owner of the interaction */
717
1027
  owner: string;
718
1028
  /** Primary media channel for the interaction */
719
- mediaChannel: MEDIA_CHANNEL;
1029
+ mediaChannel: string;
720
1030
  /** Direction information for the contact */
721
1031
  contactDirection: {type: string};
722
1032
  /** Type of outbound interaction */
723
1033
  outboundType?: string;
1034
+ /** Optional workflow manager identifier */
1035
+ workflowManager?: string | null;
724
1036
  /** Parameters passed through the call flow */
725
- callFlowParams: Record<
726
- string,
727
- {
728
- /** Name of the parameter */
729
- name: string;
730
- /** Qualifier for the parameter */
731
- qualifier: string;
732
- /** Description of the parameter */
733
- description: string;
734
- /** Data type of the parameter value */
735
- valueDataType: string;
736
- /** Value of the parameter */
737
- value: string;
738
- }
739
- >;
1037
+ callFlowParams?: Record<string, FlowParameter>;
740
1038
  };
741
1039
 
742
1040
  /**
743
- * Task payload containing detailed information about a contact center task
744
- * 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.
745
1044
  * @public
746
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
+
747
1066
  export type TaskData = {
748
- /** Unique identifier for the media resource handling this task */
1067
+ /** Primary media resource identifier for the active leg (matches interaction.media[].mediaResourceId) */
749
1068
  mediaResourceId: string;
750
- /** Type of event that triggered this task data */
1069
+ /** Agent event name from the websocket stream (e.g., AGENT_CONTACT_ASSIGNED) */
751
1070
  eventType: string;
752
1071
  /** Timestamp when the event occurred */
753
1072
  eventTime?: number;
@@ -757,7 +1076,7 @@ export type TaskData = {
757
1076
  destAgentId: string;
758
1077
  /** Unique tracking identifier for the task */
759
1078
  trackingId: string;
760
- /** Media resource identifier for consultation operations */
1079
+ /** Media resource identifier for consultation leg when present */
761
1080
  consultMediaResourceId: string;
762
1081
  /** Detailed interaction information */
763
1082
  interaction: Interaction;
@@ -769,7 +1088,7 @@ export type TaskData = {
769
1088
  toOwner?: boolean;
770
1089
  /** Identifier for child interaction in consult/transfer scenarios */
771
1090
  childInteractionId?: string;
772
- /** Unique identifier for the interaction */
1091
+ /** Interaction/contact identifier from backend (same as interaction.interactionId) */
773
1092
  interactionId: string;
774
1093
  /** Organization identifier */
775
1094
  orgId: string;
@@ -779,7 +1098,7 @@ export type TaskData = {
779
1098
  queueMgr: string;
780
1099
  /** Name of the queue where task is queued */
781
1100
  queueName?: string;
782
- /** Type of the task */
1101
+ /** Task/interaction type returned by the platform (routing/monitoring/etc.) */
783
1102
  type: string;
784
1103
  /** Timeout value for RONA (Redirection on No Answer) in seconds */
785
1104
  ronaTimeout?: number;
@@ -815,12 +1134,107 @@ export type TaskData = {
815
1134
  reservedAgentChannelId?: string;
816
1135
  /** Indicates if wrap-up is required for this task */
817
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;
818
1187
  /** Indicates if auto-answer is in progress for this task */
819
1188
  isAutoAnswering?: boolean;
820
1189
  /** Indicates if wrap-up is required for this task */
821
1190
  agentsPendingWrapUp?: string[];
822
1191
  };
823
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
+ */
824
1238
  /**
825
1239
  * Type representing an agent contact message within the contact center system
826
1240
  * Contains comprehensive interaction and task related details for agent operations
@@ -1042,6 +1456,15 @@ export type TransferPayload = {
1042
1456
  destinationType: DestinationType;
1043
1457
  };
1044
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
+
1045
1468
  /**
1046
1469
  * API payload for ending a consultation
1047
1470
  * This is the actual payload that is sent to the developer API
@@ -1117,6 +1540,18 @@ export type DialerPayload = {
1117
1540
  origin: string;
1118
1541
  };
1119
1542
 
1543
+ /**
1544
+ * Payload for campaign preview contact operations (accept, skip, remove)
1545
+ * @public
1546
+ */
1547
+ export type PreviewContactPayload = {
1548
+ /** The interaction ID from the campaign reservation */
1549
+ interactionId: string;
1550
+ /** The campaign name (not a UUID). Available from the reservation event at
1551
+ * `task.data.interaction.callProcessingDetails.campaignId` or `task.data.campaignId`. */
1552
+ campaignId: string;
1553
+ };
1554
+
1120
1555
  /**
1121
1556
  * Data structure for cleaning up contact resources
1122
1557
  * @public
@@ -1151,6 +1586,41 @@ export type ContactCleanupData = {
1151
1586
  };
1152
1587
  };
1153
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
+
1154
1624
  /**
1155
1625
  * Response type for task public methods
1156
1626
  * Can be an {@link AgentContact} object containing updated task state,
@@ -1159,11 +1629,38 @@ export type ContactCleanupData = {
1159
1629
  */
1160
1630
  export type TaskResponse = AgentContact | Error | void;
1161
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
+
1162
1659
  /**
1163
1660
  * Interface for managing task-related operations in the contact center
1164
- * Extends EventEmitter to support event-driven task updates
1661
+ * Extends IEventEmitter to support event-driven task updates
1165
1662
  */
1166
- export interface ITask extends EventEmitter {
1663
+ export interface ITask extends IEventEmitter {
1167
1664
  /**
1168
1665
  * Event data received in the Contact Center events.
1169
1666
  * Contains detailed task information including interaction details, media resources,
@@ -1183,6 +1680,36 @@ export interface ITask extends EventEmitter {
1183
1680
  */
1184
1681
  autoWrapup?: AutoWrapup;
1185
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
+
1186
1713
  /**
1187
1714
  * Cancels the auto-wrapup timer for the task.
1188
1715
  * This method stops the auto-wrapup process if it is currently active.
@@ -1204,7 +1731,7 @@ export interface ITask extends EventEmitter {
1204
1731
  * @returns Updated task instance
1205
1732
  * @ignore
1206
1733
  */
1207
- updateTaskData(newData: TaskData): ITask;
1734
+ updateTaskData(newData: TaskData): void;
1208
1735
 
1209
1736
  /**
1210
1737
  * Answers or accepts an incoming task.
@@ -1336,18 +1863,7 @@ export interface ITask extends EventEmitter {
1336
1863
  * await task.transfer({ to: "queueId", destinationType: "queue" });
1337
1864
  * ```
1338
1865
  */
1339
- transfer(transferPayload: TransferPayLoad): Promise<TaskResponse>;
1340
-
1341
- /**
1342
- * Transfers the task after consultation.
1343
- * @param consultTransferPayload - Details for consult transfer (optional)
1344
- * @returns Promise<TaskResponse>
1345
- * @example
1346
- * ```typescript
1347
- * await task.consultTransfer({ to: "agentId", destinationType: "agent" });
1348
- * ```
1349
- */
1350
- consultTransfer(consultTransferPayload?: ConsultTransferPayLoad): Promise<TaskResponse>;
1866
+ transfer(transferPayload: TransferPayLoad, options?: TransferOptions): Promise<TaskResponse>;
1351
1867
 
1352
1868
  /**
1353
1869
  * Initiates a consult conference (merge consult call with main call).
@@ -1379,6 +1895,19 @@ export interface ITask extends EventEmitter {
1379
1895
  */
1380
1896
  transferConference(): Promise<TaskResponse>;
1381
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
+
1382
1911
  /**
1383
1912
  * Toggles mute/unmute for the local audio stream during a WebRTC task.
1384
1913
  * @returns Promise<void>
@@ -1389,3 +1918,137 @@ export interface ITask extends EventEmitter {
1389
1918
  */
1390
1919
  toggleMute(): Promise<void>;
1391
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
+ }