@webex/contact-center 3.12.0-next.13 → 3.12.0-next.130

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 (312) hide show
  1. package/.sdd/manifest.json +884 -0
  2. package/AGENTS.md +94 -0
  3. package/ai-docs/ARCHITECTURE.md +168 -0
  4. package/ai-docs/CONTRACTS.md +53 -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 +52 -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 +382 -0
  17. package/ai-docs/features/consult-transfer-list-policy/spec/feature-spec.md +362 -0
  18. package/ai-docs/features/contact-owner-change-refactor.md +78 -0
  19. package/ai-docs/features/generated-spec-conformance-fidelity-remediation/spec/feature-spec.md +117 -0
  20. package/ai-docs/features/residual-warning-coverage-completion/spec/feature-spec.md +203 -0
  21. package/ai-docs/features/validator-code-fidelity-drift-fix/spec/feature-spec.md +315 -0
  22. package/ai-docs/patterns/event-driven-patterns.md +485 -0
  23. package/ai-docs/patterns/testing-patterns.md +480 -0
  24. package/ai-docs/patterns/typescript-patterns.md +365 -0
  25. package/ai-docs/templates/README.md +102 -0
  26. package/ai-docs/templates/documentation/create-agents-md.md +240 -0
  27. package/ai-docs/templates/documentation/create-architecture-md.md +295 -0
  28. package/ai-docs/templates/existing-service/bug-fix.md +254 -0
  29. package/ai-docs/templates/existing-service/feature-enhancement.md +450 -0
  30. package/ai-docs/templates/new-method/00-master.md +80 -0
  31. package/ai-docs/templates/new-method/01-requirements.md +232 -0
  32. package/ai-docs/templates/new-method/02-implementation.md +295 -0
  33. package/ai-docs/templates/new-method/03-tests.md +201 -0
  34. package/ai-docs/templates/new-method/04-validation.md +141 -0
  35. package/ai-docs/templates/new-service/00-master.md +109 -0
  36. package/ai-docs/templates/new-service/01-pre-questions.md +159 -0
  37. package/ai-docs/templates/new-service/02-code-generation.md +346 -0
  38. package/ai-docs/templates/new-service/03-integration.md +178 -0
  39. package/ai-docs/templates/new-service/04-test-generation.md +205 -0
  40. package/ai-docs/templates/new-service/05-validation.md +145 -0
  41. package/dist/cc.js +971 -42
  42. package/dist/cc.js.map +1 -1
  43. package/dist/config.js +13 -0
  44. package/dist/config.js.map +1 -1
  45. package/dist/constants.js +31 -3
  46. package/dist/constants.js.map +1 -1
  47. package/dist/index.js +45 -15
  48. package/dist/index.js.map +1 -1
  49. package/dist/metrics/MetricsManager.js +16 -0
  50. package/dist/metrics/MetricsManager.js.map +1 -1
  51. package/dist/metrics/behavioral-events.js +205 -0
  52. package/dist/metrics/behavioral-events.js.map +1 -1
  53. package/dist/metrics/constants.js +48 -4
  54. package/dist/metrics/constants.js.map +1 -1
  55. package/dist/services/AddressBook.js +18 -15
  56. package/dist/services/AddressBook.js.map +1 -1
  57. package/dist/services/AnswerCallOnWebexService.js +202 -0
  58. package/dist/services/AnswerCallOnWebexService.js.map +1 -0
  59. package/dist/services/ApiAiAssistant.js +269 -9
  60. package/dist/services/ApiAiAssistant.js.map +1 -1
  61. package/dist/services/EntryPoint.js +46 -68
  62. package/dist/services/EntryPoint.js.map +1 -1
  63. package/dist/services/Queue.js +27 -22
  64. package/dist/services/Queue.js.map +1 -1
  65. package/dist/services/UserPreference.js +427 -0
  66. package/dist/services/UserPreference.js.map +1 -0
  67. package/dist/services/WebexCrossClientService.js +222 -0
  68. package/dist/services/WebexCrossClientService.js.map +1 -0
  69. package/dist/services/WxAppTelephonyMercurySync.js +108 -0
  70. package/dist/services/WxAppTelephonyMercurySync.js.map +1 -0
  71. package/dist/services/config/Util.js +11 -4
  72. package/dist/services/config/Util.js.map +1 -1
  73. package/dist/services/config/constants.js +41 -7
  74. package/dist/services/config/constants.js.map +1 -1
  75. package/dist/services/config/index.js +51 -0
  76. package/dist/services/config/index.js.map +1 -1
  77. package/dist/services/config/types.js +57 -12
  78. package/dist/services/config/types.js.map +1 -1
  79. package/dist/services/core/Err.js.map +1 -1
  80. package/dist/services/core/Utils.js +111 -32
  81. package/dist/services/core/Utils.js.map +1 -1
  82. package/dist/services/core/WebexRequest.js +6 -2
  83. package/dist/services/core/WebexRequest.js.map +1 -1
  84. package/dist/services/core/aqm-reqs.js +28 -14
  85. package/dist/services/core/aqm-reqs.js.map +1 -1
  86. package/dist/services/core/types.js.map +1 -1
  87. package/dist/services/core/websocket/WebSocketManager.js +2 -1
  88. package/dist/services/core/websocket/WebSocketManager.js.map +1 -1
  89. package/dist/services/core/websocket/types.js.map +1 -1
  90. package/dist/services/index.js +1 -1
  91. package/dist/services/index.js.map +1 -1
  92. package/dist/services/task/Task.js +754 -0
  93. package/dist/services/task/Task.js.map +1 -0
  94. package/dist/services/task/TaskFactory.js +49 -0
  95. package/dist/services/task/TaskFactory.js.map +1 -0
  96. package/dist/services/task/TaskManager.js +1172 -521
  97. package/dist/services/task/TaskManager.js.map +1 -1
  98. package/dist/services/task/TaskUtils.js +211 -27
  99. package/dist/services/task/TaskUtils.js.map +1 -1
  100. package/dist/services/task/WebexCallingUtils.js +70 -0
  101. package/dist/services/task/WebexCallingUtils.js.map +1 -0
  102. package/dist/services/task/constants.js +12 -2
  103. package/dist/services/task/constants.js.map +1 -1
  104. package/dist/services/task/contact.js +29 -0
  105. package/dist/services/task/contact.js.map +1 -1
  106. package/dist/services/task/dialer.js +78 -0
  107. package/dist/services/task/dialer.js.map +1 -1
  108. package/dist/services/task/digital/Digital.js +78 -0
  109. package/dist/services/task/digital/Digital.js.map +1 -0
  110. package/dist/services/task/state-machine/TaskStateMachine.js +982 -0
  111. package/dist/services/task/state-machine/TaskStateMachine.js.map +1 -0
  112. package/dist/services/task/state-machine/actions.js +572 -0
  113. package/dist/services/task/state-machine/actions.js.map +1 -0
  114. package/dist/services/task/state-machine/constants.js +161 -0
  115. package/dist/services/task/state-machine/constants.js.map +1 -0
  116. package/dist/services/task/state-machine/guards.js +379 -0
  117. package/dist/services/task/state-machine/guards.js.map +1 -0
  118. package/dist/services/task/state-machine/index.js +53 -0
  119. package/dist/services/task/state-machine/index.js.map +1 -0
  120. package/dist/services/task/state-machine/types.js +54 -0
  121. package/dist/services/task/state-machine/types.js.map +1 -0
  122. package/dist/services/task/state-machine/uiControlsComputer.js +703 -0
  123. package/dist/services/task/state-machine/uiControlsComputer.js.map +1 -0
  124. package/dist/services/task/taskDataNormalizer.js +99 -0
  125. package/dist/services/task/taskDataNormalizer.js.map +1 -0
  126. package/dist/services/task/types.js +228 -5
  127. package/dist/services/task/types.js.map +1 -1
  128. package/dist/services/task/voice/Voice.js +1485 -0
  129. package/dist/services/task/voice/Voice.js.map +1 -0
  130. package/dist/services/task/voice/WebRTC.js +152 -0
  131. package/dist/services/task/voice/WebRTC.js.map +1 -0
  132. package/dist/services/task/voice/wxAppVoiceMethods.js +354 -0
  133. package/dist/services/task/voice/wxAppVoiceMethods.js.map +1 -0
  134. package/dist/services/wxAppDiagnosticLogging.js +122 -0
  135. package/dist/services/wxAppDiagnosticLogging.js.map +1 -0
  136. package/dist/services/wxAppTelephonyUtils.js +19 -0
  137. package/dist/services/wxAppTelephonyUtils.js.map +1 -0
  138. package/dist/types/cc.d.ts +193 -6
  139. package/dist/types/config.d.ts +13 -0
  140. package/dist/types/constants.d.ts +29 -1
  141. package/dist/types/index.d.ts +35 -8
  142. package/dist/types/metrics/MetricsManager.d.ts +6 -0
  143. package/dist/types/metrics/constants.d.ts +43 -1
  144. package/dist/types/services/AddressBook.d.ts +2 -1
  145. package/dist/types/services/AnswerCallOnWebexService.d.ts +38 -0
  146. package/dist/types/services/ApiAiAssistant.d.ts +56 -5
  147. package/dist/types/services/EntryPoint.d.ts +7 -5
  148. package/dist/types/services/Queue.d.ts +5 -3
  149. package/dist/types/services/UserPreference.d.ts +118 -0
  150. package/dist/types/services/WebexCrossClientService.d.ts +32 -0
  151. package/dist/types/services/WxAppTelephonyMercurySync.d.ts +28 -0
  152. package/dist/types/services/config/constants.d.ts +34 -5
  153. package/dist/types/services/config/types.d.ts +197 -12
  154. package/dist/types/services/core/Err.d.ts +6 -0
  155. package/dist/types/services/core/Utils.d.ts +35 -13
  156. package/dist/types/services/core/WebexRequest.d.ts +1 -0
  157. package/dist/types/services/core/types.d.ts +2 -0
  158. package/dist/types/services/core/websocket/WebSocketManager.d.ts +1 -0
  159. package/dist/types/services/core/websocket/types.d.ts +1 -1
  160. package/dist/types/services/index.d.ts +1 -1
  161. package/dist/types/services/task/Task.d.ts +175 -0
  162. package/dist/types/services/task/TaskFactory.d.ts +13 -0
  163. package/dist/types/services/task/TaskUtils.d.ts +48 -2
  164. package/dist/types/services/task/WebexCallingUtils.d.ts +11 -0
  165. package/dist/types/services/task/constants.d.ts +10 -0
  166. package/dist/types/services/task/contact.d.ts +4 -0
  167. package/dist/types/services/task/dialer.d.ts +30 -0
  168. package/dist/types/services/task/digital/Digital.d.ts +22 -0
  169. package/dist/types/services/task/state-machine/TaskStateMachine.d.ts +1442 -0
  170. package/dist/types/services/task/state-machine/actions.d.ts +10 -0
  171. package/dist/types/services/task/state-machine/constants.d.ts +107 -0
  172. package/dist/types/services/task/state-machine/guards.d.ts +103 -0
  173. package/dist/types/services/task/state-machine/index.d.ts +13 -0
  174. package/dist/types/services/task/state-machine/types.d.ts +277 -0
  175. package/dist/types/services/task/state-machine/uiControlsComputer.d.ts +9 -0
  176. package/dist/types/services/task/taskDataNormalizer.d.ts +10 -0
  177. package/dist/types/services/task/types.d.ts +680 -66
  178. package/dist/types/services/task/voice/Voice.d.ts +227 -0
  179. package/dist/types/services/task/voice/WebRTC.d.ts +53 -0
  180. package/dist/types/services/task/voice/wxAppVoiceMethods.d.ts +55 -0
  181. package/dist/types/services/wxAppDiagnosticLogging.d.ts +51 -0
  182. package/dist/types/services/wxAppTelephonyUtils.d.ts +5 -0
  183. package/dist/types/types.d.ts +205 -9
  184. package/dist/types/utils/PageCache.d.ts +20 -3
  185. package/dist/types/webex.d.ts +1 -0
  186. package/dist/types.js +162 -4
  187. package/dist/types.js.map +1 -1
  188. package/dist/utils/PageCache.js +19 -5
  189. package/dist/utils/PageCache.js.map +1 -1
  190. package/dist/webex.js +22 -2
  191. package/dist/webex.js.map +1 -1
  192. package/package.json +16 -12
  193. package/src/cc.ts +1289 -112
  194. package/src/config.ts +13 -0
  195. package/src/constants.ts +29 -1
  196. package/src/index.ts +36 -5
  197. package/src/metrics/MetricsManager.ts +16 -0
  198. package/src/metrics/ai-docs/AGENTS.md +350 -0
  199. package/src/metrics/ai-docs/ARCHITECTURE.md +338 -0
  200. package/src/metrics/ai-docs/metrics-spec.md +921 -0
  201. package/src/metrics/behavioral-events.ts +212 -0
  202. package/src/metrics/constants.ts +52 -4
  203. package/src/services/AddressBook.ts +17 -6
  204. package/src/services/AnswerCallOnWebexService.ts +239 -0
  205. package/src/services/ApiAiAssistant.ts +356 -9
  206. package/src/services/EntryPoint.ts +59 -60
  207. package/src/services/Queue.ts +29 -12
  208. package/src/services/UserPreference.ts +509 -0
  209. package/src/services/WebexCrossClientService.ts +293 -0
  210. package/src/services/WxAppTelephonyMercurySync.ts +142 -0
  211. package/src/services/agent/ai-docs/AGENTS.md +240 -0
  212. package/src/services/agent/ai-docs/ARCHITECTURE.md +304 -0
  213. package/src/services/agent/ai-docs/agent-spec.md +505 -0
  214. package/src/services/ai-docs/AGENTS.md +386 -0
  215. package/src/services/ai-docs/services-spec.md +505 -0
  216. package/src/services/config/Util.ts +12 -3
  217. package/src/services/config/ai-docs/AGENTS.md +255 -0
  218. package/src/services/config/ai-docs/ARCHITECTURE.md +426 -0
  219. package/src/services/config/ai-docs/config-spec.md +686 -0
  220. package/src/services/config/constants.ts +46 -6
  221. package/src/services/config/index.ts +65 -0
  222. package/src/services/config/types.ts +197 -13
  223. package/src/services/core/Err.ts +3 -0
  224. package/src/services/core/Utils.ts +127 -37
  225. package/src/services/core/WebexRequest.ts +3 -1
  226. package/src/services/core/ai-docs/AGENTS.md +381 -0
  227. package/src/services/core/ai-docs/ARCHITECTURE.md +698 -0
  228. package/src/services/core/ai-docs/core-spec.md +787 -0
  229. package/src/services/core/aqm-reqs.ts +30 -15
  230. package/src/services/core/types.ts +2 -0
  231. package/src/services/core/websocket/WebSocketManager.ts +2 -0
  232. package/src/services/core/websocket/types.ts +1 -1
  233. package/src/services/index.ts +1 -1
  234. package/src/services/task/Task.ts +908 -0
  235. package/src/services/task/TaskFactory.ts +60 -0
  236. package/src/services/task/TaskManager.ts +1419 -608
  237. package/src/services/task/TaskUtils.ts +303 -25
  238. package/src/services/task/WebexCallingUtils.ts +136 -0
  239. package/src/services/task/ai-docs/AGENTS.md +457 -0
  240. package/src/services/task/ai-docs/ARCHITECTURE.md +595 -0
  241. package/src/services/task/ai-docs/task-spec.md +1474 -0
  242. package/src/services/task/constants.ts +10 -0
  243. package/src/services/task/contact.ts +30 -0
  244. package/src/services/task/dialer.ts +80 -0
  245. package/src/services/task/digital/Digital.ts +97 -0
  246. package/src/services/task/state-machine/TaskStateMachine.ts +1320 -0
  247. package/src/services/task/state-machine/actions.ts +741 -0
  248. package/src/services/task/state-machine/ai-docs/AGENTS.md +460 -0
  249. package/src/services/task/state-machine/ai-docs/ARCHITECTURE.md +1156 -0
  250. package/src/services/task/state-machine/ai-docs/task-state-machine-spec.md +2247 -0
  251. package/src/services/task/state-machine/constants.ts +172 -0
  252. package/src/services/task/state-machine/guards.ts +442 -0
  253. package/src/services/task/state-machine/index.ts +28 -0
  254. package/src/services/task/state-machine/types.ts +258 -0
  255. package/src/services/task/state-machine/uiControlsComputer.ts +1135 -0
  256. package/src/services/task/taskDataNormalizer.ts +137 -0
  257. package/src/services/task/types.ts +819 -70
  258. package/src/services/task/voice/Voice.ts +1851 -0
  259. package/src/services/task/voice/WebRTC.ts +191 -0
  260. package/src/services/task/voice/wxAppVoiceMethods.ts +516 -0
  261. package/src/services/wxAppDiagnosticLogging.ts +174 -0
  262. package/src/services/wxAppTelephonyUtils.ts +14 -0
  263. package/src/types.ts +262 -11
  264. package/src/utils/AGENTS.md +289 -0
  265. package/src/utils/PageCache.ts +38 -5
  266. package/src/utils/ai-docs/utils-spec.md +391 -0
  267. package/src/webex.js +10 -0
  268. package/test/unit/spec/cc.ts +2210 -119
  269. package/test/unit/spec/logger-proxy.ts +70 -0
  270. package/test/unit/spec/metrics/MetricsManager.ts +25 -0
  271. package/test/unit/spec/metrics/behavioral-events.ts +60 -0
  272. package/test/unit/spec/services/AddressBook.ts +37 -6
  273. package/test/unit/spec/services/AnswerCallOnWebexService.ts +264 -0
  274. package/test/unit/spec/services/ApiAiAssistant.ts +311 -21
  275. package/test/unit/spec/services/EntryPoint.ts +87 -40
  276. package/test/unit/spec/services/Queue.ts +123 -12
  277. package/test/unit/spec/services/UserPreference.ts +401 -0
  278. package/test/unit/spec/services/WebCallingService.ts +7 -1
  279. package/test/unit/spec/services/WebexCrossClientService.ts +467 -0
  280. package/test/unit/spec/services/WxAppTelephonyMercurySync.ts +136 -0
  281. package/test/unit/spec/services/config/Util.ts +129 -0
  282. package/test/unit/spec/services/config/index.ts +97 -29
  283. package/test/unit/spec/services/core/Utils.ts +425 -8
  284. package/test/unit/spec/services/core/WebexRequest.ts +3 -1
  285. package/test/unit/spec/services/core/aqm-reqs.ts +113 -1
  286. package/test/unit/spec/services/core/websocket/WebSocketManager.ts +66 -40
  287. package/test/unit/spec/services/task/AutoWrapup.ts +63 -0
  288. package/test/unit/spec/services/task/Task.ts +745 -0
  289. package/test/unit/spec/services/task/TaskFactory.ts +99 -0
  290. package/test/unit/spec/services/task/TaskManager.ts +2518 -1494
  291. package/test/unit/spec/services/task/TaskUtils.ts +235 -0
  292. package/test/unit/spec/services/task/WebexCallingUtils.ts +153 -0
  293. package/test/unit/spec/services/task/contact.ts +33 -0
  294. package/test/unit/spec/services/task/dialer.ts +190 -0
  295. package/test/unit/spec/services/task/digital/Digital.ts +105 -0
  296. package/test/unit/spec/services/task/state-machine/TaskStateMachine.ts +4060 -0
  297. package/test/unit/spec/services/task/state-machine/guards.ts +839 -0
  298. package/test/unit/spec/services/task/state-machine/types.ts +18 -0
  299. package/test/unit/spec/services/task/state-machine/uiControlsComputer.ts +3101 -0
  300. package/test/unit/spec/services/task/taskTestUtils.ts +87 -0
  301. package/test/unit/spec/services/task/voice/Voice.ts +2061 -0
  302. package/test/unit/spec/services/task/voice/WebRTC.ts +235 -0
  303. package/test/unit/spec/services/task/voice/wxAppVoiceMethods.ts +603 -0
  304. package/test/unit/spec/services/wxAppDiagnosticLogging.ts +143 -0
  305. package/test/unit/spec/wellnessSampleUtils.ts +288 -0
  306. package/umd/contact-center.min.js +2 -2
  307. package/umd/contact-center.min.js.map +1 -1
  308. package/dist/services/task/index.js +0 -1525
  309. package/dist/services/task/index.js.map +0 -1
  310. package/dist/types/services/task/index.d.ts +0 -650
  311. package/src/services/task/index.ts +0 -1801
  312. package/test/unit/spec/services/task/index.ts +0 -2184
@@ -1,7 +1,9 @@
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';
6
+ import type {CollaborationAccess} from '../config/types';
5
7
 
6
8
  /**
7
9
  * Unique identifier for a task in the contact center system
@@ -9,6 +11,11 @@ import AutoWrapup from './AutoWrapup';
9
11
  */
10
12
  export type TaskId = string;
11
13
 
14
+ /**
15
+ * Unique identifier for a call in the Webex calling system
16
+ */
17
+ export type CallId = string;
18
+
12
19
  /**
13
20
  * Helper type for creating enum-like objects with type safety
14
21
  * @internal
@@ -27,7 +34,7 @@ export const DESTINATION_TYPE = {
27
34
  DIALNUMBER: 'dialNumber',
28
35
  /** Route task to a specific agent */
29
36
  AGENT: 'agent',
30
- /** Route task to an entry point (supported only for consult operations) */
37
+ /** Route task to an entry point */
31
38
  ENTRYPOINT: 'entryPoint',
32
39
  };
33
40
 
@@ -61,6 +68,17 @@ export const CONSULT_TRANSFER_DESTINATION_TYPE = {
61
68
  */
62
69
  export type ConsultTransferDestinationType = Enum<typeof CONSULT_TRANSFER_DESTINATION_TYPE>;
63
70
 
71
+ /**
72
+ * Agent-profile policy used by the task state machine to derive consult/transfer destinations.
73
+ * @internal
74
+ */
75
+ export type ConsultTransferDestinationConfig = {
76
+ allowConsultToQueue: boolean;
77
+ accessQueue?: CollaborationAccess;
78
+ accessEntryPoint?: CollaborationAccess;
79
+ accessBuddyTeam?: CollaborationAccess;
80
+ };
81
+
64
82
  /**
65
83
  * Defines all supported media channel types for customer interactions
66
84
  * These represent the different ways customers can communicate with agents
@@ -90,6 +108,26 @@ export const MEDIA_CHANNEL = {
90
108
  */
91
109
  export type MEDIA_CHANNEL = Enum<typeof MEDIA_CHANNEL>;
92
110
 
111
+ /**
112
+ * Supported task channel types for UI control configuration
113
+ */
114
+ export const TASK_CHANNEL_TYPE = {
115
+ VOICE: 'voice',
116
+ DIGITAL: 'digital',
117
+ } as const;
118
+
119
+ export type TaskChannelType = Enum<typeof TASK_CHANNEL_TYPE>;
120
+
121
+ /**
122
+ * Voice channel variants that toggle PSTN/WebRTC specific behaviors
123
+ */
124
+ export const VOICE_VARIANT = {
125
+ PSTN: 'pstn',
126
+ WEBRTC: 'webrtc',
127
+ } as const;
128
+
129
+ export type VoiceVariant = Enum<typeof VOICE_VARIANT>;
130
+
93
131
  /**
94
132
  * Enumeration of all task-related events that can occur in the contact center system
95
133
  * These events represent different states and actions in the task lifecycle
@@ -203,6 +241,16 @@ export enum TASK_EVENTS {
203
241
  */
204
242
  TASK_CONSULT_QUEUE_FAILED = 'task:consultQueueFailed',
205
243
 
244
+ /**
245
+ * Triggered whenever task UI controls are recalculated
246
+ */
247
+ TASK_UI_CONTROLS_UPDATED = 'task:ui-controls-updated',
248
+
249
+ /**
250
+ * Triggered when wxApp mute state changes from Webex App (Mercury sync or call details).
251
+ */
252
+ TASK_WXAPP_MUTE_STATE_UPDATED = 'task:wxapp-mute-state-updated',
253
+
206
254
  /**
207
255
  * Triggered when a consultation request is accepted
208
256
  * @example
@@ -287,6 +335,24 @@ export enum TASK_EVENTS {
287
335
  */
288
336
  TASK_WRAPPEDUP = 'task:wrappedup',
289
337
 
338
+ /**
339
+ * Triggered when the task state machine reaches a final state and resources should be cleaned up.
340
+ * Used internally by TaskManager to perform collection/call cleanup.
341
+ * @internal
342
+ */
343
+ TASK_CLEANUP = 'task:cleanup',
344
+
345
+ /**
346
+ * Triggered when recording is started
347
+ * @example
348
+ * ```typescript
349
+ * task.on(TASK_EVENTS.TASK_RECORDING_STARTED, (task: ITask) => {
350
+ * console.log('Recording started:', task.data.interactionId);
351
+ * });
352
+ * ```
353
+ */
354
+ TASK_RECORDING_STARTED = 'task:recordingStarted',
355
+
290
356
  /**
291
357
  * Triggered when recording is paused
292
358
  * @example
@@ -519,6 +585,43 @@ export enum TASK_EVENTS {
519
585
  */
520
586
  TASK_PARTICIPANT_LEFT_FAILED = 'task:participantLeftFailed',
521
587
 
588
+ /**
589
+ * Triggered when agent initiates exit from conference
590
+ * @example
591
+ * ```typescript
592
+ * task.on(TASK_EVENTS.TASK_EXIT_CONFERENCE, (task: ITask) => {
593
+ * console.log('Exiting conference:', task.data.interactionId);
594
+ * // Handle conference exit initiation
595
+ * });
596
+ * ```
597
+ */
598
+ TASK_EXIT_CONFERENCE = 'task:exitConference',
599
+
600
+ /**
601
+ * Triggered when agent initiates conference transfer
602
+ * @example
603
+ * ```typescript
604
+ * task.on(TASK_EVENTS.TASK_TRANSFER_CONFERENCE, (task: ITask) => {
605
+ * console.log('Transferring conference:', task.data.interactionId);
606
+ * // Handle conference transfer initiation
607
+ * });
608
+ * ```
609
+ */
610
+ TASK_TRANSFER_CONFERENCE = 'task:transferConference',
611
+
612
+ /**
613
+ * Triggered when agent switches between consult call and main call.
614
+ * Use task.uiControls to determine current state and button visibility.
615
+ * @example
616
+ * ```typescript
617
+ * task.on(TASK_EVENTS.TASK_SWITCH_CALL, (task: ITask) => {
618
+ * console.log('Call switched:', task.data.interactionId);
619
+ * // Update UI based on task.uiControls.main.switch / task.uiControls.consult.switch
620
+ * });
621
+ * ```
622
+ */
623
+ TASK_SWITCH_CALL = 'task:switchCall',
624
+
522
625
  /**
523
626
  * Triggered when a contact is merged
524
627
  * @example
@@ -543,6 +646,17 @@ export enum TASK_EVENTS {
543
646
  */
544
647
  TASK_POST_CALL_ACTIVITY = 'task:postCallActivity',
545
648
 
649
+ /**
650
+ * Triggered when a multi-login task update should hydrate SDK instances without Mobius registration.
651
+ * @example
652
+ * ```typescript
653
+ * task.on(TASK_EVENTS.TASK_MULTI_LOGIN_HYDRATE, (task: ITask) => {
654
+ * console.log('Multi-login hydrate:', task.data.interactionId);
655
+ * });
656
+ * ```
657
+ */
658
+ TASK_MULTI_LOGIN_HYDRATE = 'task:multiLoginHydrate',
659
+
546
660
  /**
547
661
  * Triggered when a campaign preview contact is offered to the agent
548
662
  * @example
@@ -554,6 +668,54 @@ export enum TASK_EVENTS {
554
668
  * ```
555
669
  */
556
670
  TASK_CAMPAIGN_PREVIEW_RESERVATION = 'task:campaignPreviewReservation',
671
+
672
+ /**
673
+ * Triggered when accepting a campaign preview contact fails
674
+ * @example
675
+ * ```typescript
676
+ * task.on(TASK_EVENTS.TASK_CAMPAIGN_PREVIEW_ACCEPT_FAILED, (task: ITask) => {
677
+ * console.log('Campaign preview accept failed:', task.data.interactionId);
678
+ * // Handle accept failure
679
+ * });
680
+ * ```
681
+ */
682
+ TASK_CAMPAIGN_PREVIEW_ACCEPT_FAILED = 'task:campaignPreviewAcceptFailed',
683
+
684
+ /**
685
+ * Triggered when skipping a campaign preview contact fails
686
+ * @example
687
+ * ```typescript
688
+ * task.on(TASK_EVENTS.TASK_CAMPAIGN_PREVIEW_SKIP_FAILED, (task: ITask) => {
689
+ * console.log('Campaign preview skip failed:', task.data.interactionId);
690
+ * // Handle skip failure
691
+ * });
692
+ * ```
693
+ */
694
+ TASK_CAMPAIGN_PREVIEW_SKIP_FAILED = 'task:campaignPreviewSkipFailed',
695
+
696
+ /**
697
+ * Triggered when removing a campaign preview contact fails
698
+ * @example
699
+ * ```typescript
700
+ * task.on(TASK_EVENTS.TASK_CAMPAIGN_PREVIEW_REMOVE_FAILED, (task: ITask) => {
701
+ * console.log('Campaign preview remove failed:', task.data.interactionId);
702
+ * // Handle remove failure
703
+ * });
704
+ * ```
705
+ */
706
+ TASK_CAMPAIGN_PREVIEW_REMOVE_FAILED = 'task:campaignPreviewRemoveFailed',
707
+
708
+ /**
709
+ * Triggered when a campaign contact is updated (e.g., after skip or remove, when the next contact is offered)
710
+ * @example
711
+ * ```typescript
712
+ * task.on(TASK_EVENTS.TASK_CAMPAIGN_CONTACT_UPDATED, (task: ITask) => {
713
+ * console.log('Campaign contact updated:', task.data.interactionId);
714
+ * // Handle updated campaign contact (e.g., display next contact)
715
+ * });
716
+ * ```
717
+ */
718
+ TASK_CAMPAIGN_CONTACT_UPDATED = 'task:campaignContactUpdated',
557
719
  }
558
720
 
559
721
  /**
@@ -561,6 +723,146 @@ export enum TASK_EVENTS {
561
723
  * Contains comprehensive details about an ongoing customer interaction
562
724
  * @public
563
725
  */
726
+ export interface CallAssociatedDatum {
727
+ /** Whether the field can be edited by the agent */
728
+ agentEditable: boolean;
729
+ /** Whether the field is visible to the agent */
730
+ agentViewable: boolean;
731
+ /** Display name for the field */
732
+ displayName: string;
733
+ /** Whether the field is global */
734
+ global: boolean;
735
+ /** Whether the field is secure */
736
+ isSecure: boolean;
737
+ /** Internal field name */
738
+ name: string;
739
+ /** Whether the field is reportable */
740
+ reportable: boolean;
741
+ /** Secure key identifier */
742
+ secureKeyId: string;
743
+ /** Secure key version */
744
+ secureKeyVersion: number;
745
+ /** Data type of the field */
746
+ type: string;
747
+ /** Field value */
748
+ value: string;
749
+ }
750
+
751
+ export type CallAssociatedData = Record<string, CallAssociatedDatum>;
752
+
753
+ export type CallAssociatedDetails = Record<string, string>;
754
+
755
+ export interface FlowParameter {
756
+ /** Parameter name */
757
+ name?: string;
758
+ /** Additional qualifier */
759
+ qualifier?: string;
760
+ /** Description of the parameter */
761
+ description?: string;
762
+ /** Data type of the value */
763
+ valueDataType?: string;
764
+ /** Value associated with the parameter */
765
+ value?: string;
766
+ }
767
+
768
+ export interface InteractionParticipant {
769
+ /** Unique participant identifier */
770
+ id: string;
771
+ /** Participant type label used by backend */
772
+ pType: string;
773
+ /** Friendly participant type */
774
+ type: string;
775
+ /** Whether the participant has joined */
776
+ hasJoined: boolean;
777
+ /** Whether the participant has left */
778
+ hasLeft: boolean;
779
+ /** Whether the participant is still in pre-dial */
780
+ isInPredial: boolean;
781
+ /** Optional caller identifier */
782
+ callerId?: string | null;
783
+ /** Whether auto-answer is enabled */
784
+ autoAnswerEnabled?: boolean;
785
+ /** Backchannel/bnr details */
786
+ bnrDetails?: unknown;
787
+ /** Channel identifier for the participant */
788
+ channelId?: string;
789
+ /** Current consult state */
790
+ consultState?: string | null;
791
+ /** Timestamp when consult started */
792
+ consultTimestamp?: number | null;
793
+ /** Current participant state */
794
+ currentState?: string | null;
795
+ /** Timestamp of the current state */
796
+ currentStateTimestamp?: number | null;
797
+ /** Device call identifier */
798
+ deviceCallId?: string | null;
799
+ /** Device identifier */
800
+ deviceId?: string | null;
801
+ /** Device type (AGENT_DN, BROWSER, etc.) */
802
+ deviceType?: string | null;
803
+ /** Dial number associated with participant */
804
+ dn?: string | null;
805
+ /** Whether participant is currently consulted */
806
+ isConsulted?: boolean;
807
+ /** Whether participant offer is active */
808
+ isOffered?: boolean;
809
+ /** Whether participant is in wrap-up */
810
+ isWrapUp?: boolean;
811
+ /** Whether participant completed wrap-up */
812
+ isWrappedUp?: boolean;
813
+ /** Timestamp of when participant joined */
814
+ joinTimestamp?: number | null;
815
+ /** Last updated timestamp */
816
+ lastUpdated?: number | null;
817
+ /** Friendly name of participant */
818
+ name?: string | null;
819
+ /** Queue identifier associated with participant */
820
+ queueId?: string;
821
+ /** Queue manager identifier */
822
+ queueMgrId?: string;
823
+ /** Session identifier */
824
+ sessionId?: string;
825
+ /** Site identifier */
826
+ siteId?: string;
827
+ /** Skill identifier */
828
+ skillId?: string | null;
829
+ /** Skill name */
830
+ skillName?: string | null;
831
+ /** Skill list for participant */
832
+ skills?: string[];
833
+ /** Team identifier */
834
+ teamId?: string;
835
+ /** Team name */
836
+ teamName?: string;
837
+ /** Timestamp for wrap-up */
838
+ wrapUpTimestamp?: number | null;
839
+ /** Additional metadata */
840
+ [key: string]: unknown;
841
+ }
842
+
843
+ export type InteractionParticipants = Record<string, InteractionParticipant>;
844
+
845
+ /**
846
+ * Media entry type from interaction.media
847
+ * Used for media state tracking in consult and conference scenarios
848
+ */
849
+ export type MediaEntry = {
850
+ /** Unique identifier for the media resource */
851
+ mediaResourceId: string;
852
+ /** Type of media channel */
853
+ mediaType: MEDIA_CHANNEL;
854
+ /** Media manager handling this media */
855
+ mediaMgr: string;
856
+ /** List of participant identifiers */
857
+ participants: string[];
858
+ /** Type of media (e.g., 'mainCall', 'consult') */
859
+ mType: string;
860
+ /** Indicates if media is on hold */
861
+ isHold: boolean;
862
+ /** Timestamp when media was put on hold */
863
+ holdTimestamp: number | null;
864
+ };
865
+
564
866
  export type Interaction = {
565
867
  /** Indicates if the interaction is managed by Flow Control */
566
868
  isFcManaged: boolean;
@@ -575,7 +877,11 @@ export type Interaction = {
575
877
  /** Current virtual team handling the interaction */
576
878
  currentVTeam: string;
577
879
  /** List of participants in the interaction */
578
- participants: any; // TODO: Define specific participant type
880
+ participants: InteractionParticipants;
881
+ /** Detailed call associated data */
882
+ callAssociatedData?: CallAssociatedData;
883
+ /** Simplified call associated key/value pairs */
884
+ callAssociatedDetails?: CallAssociatedDetails;
579
885
  /** Unique identifier for the interaction */
580
886
  interactionId: string;
581
887
  /** Organization identifier */
@@ -584,7 +890,18 @@ export type Interaction = {
584
890
  createdTimestamp?: number;
585
891
  /** Indicates if wrap-up assistance is enabled */
586
892
  isWrapUpAssist?: boolean;
587
- /** Detailed call processing information and metadata */
893
+ /** Identifier of parent interaction if applicable */
894
+ parentInteractionId?: string;
895
+ /** Indicates if media is forked for this interaction */
896
+ isMediaForked?: boolean;
897
+ /** Retroactive flow properties returned by backend */
898
+ flowProperties?: Record<string, unknown> | null;
899
+ /** Media specific properties returned by backend */
900
+ mediaProperties?: Record<string, unknown> | null;
901
+ /**
902
+ * Detailed call processing information and metadata.
903
+ * Mirrors the callProcessingDetails section described in Webex Contact Center Agent Contact payloads.
904
+ */
588
905
  callProcessingDetails: {
589
906
  /** Name of the Queue Manager handling this interaction */
590
907
  QMgrName: string;
@@ -602,20 +919,24 @@ export type Interaction = {
602
919
  QueueId: string;
603
920
  /** Virtual team identifier */
604
921
  vteamId: string;
605
- /** Indicates if pause/resume functionality is enabled */
606
- pauseResumeEnabled?: string;
922
+ /** Agent capability for pause/resume on this interaction */
923
+ pauseResumeEnabled?: boolean;
607
924
  /** Duration of pause in seconds */
608
925
  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;
926
+ /** Legacy pause indicator (recordInProgress=false is the active pause signal) */
927
+ isPaused?: boolean;
928
+ /** Recording is actively capturing audio right now */
929
+ recordInProgress?: boolean;
930
+ /** Recording was started for this interaction (may be paused) */
931
+ recordingStarted?: boolean;
932
+ /** Customer geographic region */
933
+ customerRegion?: string;
934
+ /** Flow tag identifier */
935
+ flowTagId?: string;
615
936
  /** Indicates if Consult to Queue is in progress */
616
- ctqInProgress?: string;
937
+ ctqInProgress?: boolean;
617
938
  /** Indicates if outdial transfer to queue is enabled */
618
- outdialTransferToQueueEnabled?: string;
939
+ outdialTransferToQueueEnabled?: boolean;
619
940
  /** IVR conversation transcript */
620
941
  convIvrTranscript?: string;
621
942
  /** Customer's name */
@@ -702,64 +1023,67 @@ export type Interaction = {
702
1023
  fcDesktopView?: string;
703
1024
  /** Agent ID who initiated the outdial call */
704
1025
  outdialAgentId?: string;
1026
+ /** Indicates if the customer has left the call during an active consult */
1027
+ hasCustomerLeft?: string;
1028
+ /** Indicates if the skip action is disabled for campaign preview contacts */
1029
+ campaignPreviewSkipDisabled?: string;
1030
+ /** Indicates if the remove action is disabled for campaign preview contacts */
1031
+ campaignPreviewRemoveDisabled?: string;
1032
+ /** Auto-action to perform when campaign preview offer times out (ACCEPT, SKIP, REMOVE) */
1033
+ campaignPreviewAutoAction?: string;
1034
+ /** Timestamp (ms) when the campaign preview offer expires */
1035
+ campaignPreviewOfferTimeout?: string;
705
1036
  };
706
1037
  /** Main interaction identifier for related interactions */
707
1038
  mainInteractionId?: string;
1039
+ /** Timestamp when interaction entered queue */
1040
+ queuedTimestamp?: number | null;
708
1041
  /** 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
- >;
1042
+ media: Record<string, MediaEntry>;
728
1043
  /** Owner of the interaction */
729
1044
  owner: string;
730
1045
  /** Primary media channel for the interaction */
731
- mediaChannel: MEDIA_CHANNEL;
1046
+ mediaChannel: string;
732
1047
  /** Direction information for the contact */
733
1048
  contactDirection: {type: string};
734
1049
  /** Type of outbound interaction */
735
1050
  outboundType?: string;
1051
+ /** Optional workflow manager identifier */
1052
+ workflowManager?: string | null;
736
1053
  /** 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
- >;
1054
+ callFlowParams?: Record<string, FlowParameter>;
752
1055
  };
753
1056
 
754
1057
  /**
755
- * Task payload containing detailed information about a contact center task
756
- * This structure encapsulates all relevant data for task management
1058
+ * Task payload mirroring the Agent Contact event payload from Webex Contact Center
1059
+ * (developer.webex.com). Arrives on AGENT_* websocket events and is the source of truth
1060
+ * for UI/state machine updates.
757
1061
  * @public
758
1062
  */
1063
+ export type RealtimeTranscription = {
1064
+ agentId: string;
1065
+ orgId: string;
1066
+ notifType: string;
1067
+ notifDetails: {
1068
+ actionEvent: string;
1069
+ };
1070
+ data: {
1071
+ role: 'AGENT' | 'CALLER';
1072
+ utteranceId: string;
1073
+ conversationId: string;
1074
+ publishTimestamp: number;
1075
+ messageId: string;
1076
+ isFinal: boolean;
1077
+ languageCode: string;
1078
+ orgId: string;
1079
+ content: string;
1080
+ };
1081
+ };
1082
+
759
1083
  export type TaskData = {
760
- /** Unique identifier for the media resource handling this task */
1084
+ /** Primary media resource identifier for the active leg (matches interaction.media[].mediaResourceId) */
761
1085
  mediaResourceId: string;
762
- /** Type of event that triggered this task data */
1086
+ /** Agent event name from the websocket stream (e.g., AGENT_CONTACT_ASSIGNED) */
763
1087
  eventType: string;
764
1088
  /** Timestamp when the event occurred */
765
1089
  eventTime?: number;
@@ -769,7 +1093,7 @@ export type TaskData = {
769
1093
  destAgentId: string;
770
1094
  /** Unique tracking identifier for the task */
771
1095
  trackingId: string;
772
- /** Media resource identifier for consultation operations */
1096
+ /** Media resource identifier for consultation leg when present */
773
1097
  consultMediaResourceId: string;
774
1098
  /** Detailed interaction information */
775
1099
  interaction: Interaction;
@@ -781,7 +1105,7 @@ export type TaskData = {
781
1105
  toOwner?: boolean;
782
1106
  /** Identifier for child interaction in consult/transfer scenarios */
783
1107
  childInteractionId?: string;
784
- /** Unique identifier for the interaction */
1108
+ /** Interaction/contact identifier from backend (same as interaction.interactionId) */
785
1109
  interactionId: string;
786
1110
  /** Organization identifier */
787
1111
  orgId: string;
@@ -791,7 +1115,7 @@ export type TaskData = {
791
1115
  queueMgr: string;
792
1116
  /** Name of the queue where task is queued */
793
1117
  queueName?: string;
794
- /** Type of the task */
1118
+ /** Task/interaction type returned by the platform (routing/monitoring/etc.) */
795
1119
  type: string;
796
1120
  /** Timeout value for RONA (Redirection on No Answer) in seconds */
797
1121
  ronaTimeout?: number;
@@ -827,12 +1151,130 @@ export type TaskData = {
827
1151
  reservedAgentChannelId?: string;
828
1152
  /** Indicates if wrap-up is required for this task */
829
1153
  wrapUpRequired?: boolean;
1154
+ /** SDK-internal: skip task:outdialFailed when non-wxApp agent-terminated outdial still needs wrapup */
1155
+ suppressOutdialFailedPopup?: boolean;
1156
+
1157
+ /**
1158
+ * Current consultation status derived from state machine
1159
+ * Values: CONSULT_INITIATED, CONSULT_ACCEPTED, BEING_CONSULTED,
1160
+ * BEING_CONSULTED_ACCEPTED, CONNECTED, CONFERENCE, CONSULT_COMPLETED
1161
+ */
1162
+ consultStatus?: string;
1163
+
1164
+ /**
1165
+ * Indicates if consultation is in progress (state machine: CONSULTING)
1166
+ */
1167
+ isConsultInProgress?: boolean;
1168
+
1169
+ /**
1170
+ * Indicates if the task is incoming for the active agent
1171
+ */
1172
+ isIncomingTask?: boolean;
1173
+
1174
+ /**
1175
+ * Indicates if the task is on hold (state machine: HELD)
1176
+ */
1177
+ isOnHold?: boolean;
1178
+
1179
+ /**
1180
+ * Indicates if customer is currently in the call
1181
+ * Derived from participants in main media
1182
+ */
1183
+ isCustomerInCall?: boolean;
1184
+
1185
+ /**
1186
+ * Count of conference participants (agents only)
1187
+ * Used for determining if max participants reached
1188
+ */
1189
+ conferenceParticipantsCount?: number;
1190
+
1191
+ /**
1192
+ * Indicates if this is a secondary agent (consulted party)
1193
+ */
1194
+ isSecondaryAgent?: boolean;
1195
+
1196
+ /**
1197
+ * Indicates if this is a secondary EP-DN agent (telephony consult to external)
1198
+ */
1199
+ isSecondaryEpDnAgent?: boolean;
1200
+
1201
+ /**
1202
+ * Task state for MPC (Multi-Party Conference) scenarios
1203
+ * Maps participant consultState to task state
1204
+ */
1205
+ mpcState?: string;
830
1206
  /** Indicates if auto-answer is in progress for this task */
831
1207
  isAutoAnswering?: boolean;
832
1208
  /** Indicates if wrap-up is required for this task */
833
1209
  agentsPendingWrapUp?: string[];
834
1210
  };
835
1211
 
1212
+ export type TaskUIControlState = {
1213
+ isVisible: boolean;
1214
+ isEnabled: boolean;
1215
+ };
1216
+
1217
+ /**
1218
+ * UI control representation for a single interaction leg.
1219
+ */
1220
+ export type InteractionUIControls = {
1221
+ accept: TaskUIControlState;
1222
+ decline: TaskUIControlState;
1223
+ hold: TaskUIControlState;
1224
+ transfer: TaskUIControlState;
1225
+ consult: TaskUIControlState;
1226
+ end: TaskUIControlState;
1227
+ recording: TaskUIControlState;
1228
+ mute: TaskUIControlState;
1229
+ consultTransfer: TaskUIControlState;
1230
+ endConsult: TaskUIControlState;
1231
+ conference: TaskUIControlState;
1232
+ exitConference: TaskUIControlState;
1233
+ transferConference: TaskUIControlState;
1234
+ mergeToConference: TaskUIControlState;
1235
+ wrapup: TaskUIControlState;
1236
+ switch: TaskUIControlState;
1237
+ keypad?: TaskUIControlState;
1238
+ };
1239
+
1240
+ /** Options for {@link ITask.toggleMute} — wxApp engaged calls use `muted` for target state. */
1241
+ export type TaskToggleMuteOptions = {
1242
+ muted?: boolean;
1243
+ lineOwnerId?: string;
1244
+ };
1245
+
1246
+ /** Options for {@link ITask.transmitDtmf} — wxApp engaged in-call DTMF. */
1247
+ export type TaskTransmitDtmfOptions = {
1248
+ dtmf: string;
1249
+ lineOwnerId?: string;
1250
+ };
1251
+
1252
+ export type TaskUILeg = 'main' | 'consult';
1253
+
1254
+ /**
1255
+ * UI controls surfaced to task consumers.
1256
+ * Consumers should read controls from the per-leg surfaces and use `activeLeg`
1257
+ * to determine which one is currently interactive.
1258
+ */
1259
+ export type TaskUIControls = {
1260
+ main: InteractionUIControls;
1261
+ consult: InteractionUIControls;
1262
+ activeLeg: TaskUILeg;
1263
+ /**
1264
+ * Ordered destination categories available for each action.
1265
+ * The first category is the default for consumers that render a destination picker.
1266
+ */
1267
+ consultTransferDestinations: {
1268
+ consult: ConsultTransferDestinationType[];
1269
+ transfer: ConsultTransferDestinationType[];
1270
+ };
1271
+ };
1272
+
1273
+ /**
1274
+ * Helper class for managing task action control state
1275
+ * Tracks visibility and enabled state for task actions that can be executed
1276
+ * @public
1277
+ */
836
1278
  /**
837
1279
  * Type representing an agent contact message within the contact center system
838
1280
  * Contains comprehensive interaction and task related details for agent operations
@@ -1054,6 +1496,15 @@ export type TransferPayload = {
1054
1496
  destinationType: DestinationType;
1055
1497
  };
1056
1498
 
1499
+ /**
1500
+ * Options for configuring transfer behavior
1501
+ * @public
1502
+ */
1503
+ export type TransferOptions = {
1504
+ /** Additional transfer configuration options */
1505
+ [key: string]: unknown;
1506
+ };
1507
+
1057
1508
  /**
1058
1509
  * API payload for ending a consultation
1059
1510
  * This is the actual payload that is sent to the developer API
@@ -1175,6 +1626,41 @@ export type ContactCleanupData = {
1175
1626
  };
1176
1627
  };
1177
1628
 
1629
+ /**
1630
+ * Boolean-like fields in callProcessingDetails that may arrive as strings.
1631
+ * Used by taskDataNormalizer to coerce payloads to actual booleans.
1632
+ */
1633
+ export type CallProcessingBooleanKey =
1634
+ | 'recordingStarted'
1635
+ | 'recordInProgress'
1636
+ | 'isPaused'
1637
+ | 'pauseResumeEnabled'
1638
+ | 'ctqInProgress'
1639
+ | 'outdialTransferToQueueEnabled'
1640
+ | 'taskToBeSelfServiced'
1641
+ | 'CONTINUE_RECORDING_ON_TRANSFER'
1642
+ | 'isParked'
1643
+ | 'participantInviteTimeout'
1644
+ | 'checkAgentAvailability';
1645
+
1646
+ /**
1647
+ * Interaction-level boolean fields that may arrive as strings from backend payloads.
1648
+ */
1649
+ export type InteractionBooleanKey = 'isFcManaged' | 'isMediaForked' | 'isTerminated';
1650
+
1651
+ /**
1652
+ * Participant boolean fields that may arrive as strings and need normalization.
1653
+ */
1654
+ export type ParticipantBooleanKey =
1655
+ | 'autoAnswerEnabled'
1656
+ | 'hasJoined'
1657
+ | 'hasLeft'
1658
+ | 'isConsulted'
1659
+ | 'isInPredial'
1660
+ | 'isOffered'
1661
+ | 'isWrapUp'
1662
+ | 'isWrappedUp';
1663
+
1178
1664
  /**
1179
1665
  * Response type for task public methods
1180
1666
  * Can be an {@link AgentContact} object containing updated task state,
@@ -1183,11 +1669,47 @@ export type ContactCleanupData = {
1183
1669
  */
1184
1670
  export type TaskResponse = AgentContact | Error | void;
1185
1671
 
1672
+ /**
1673
+ * Request payload for removing a supported participant from an active conference.
1674
+ * @public
1675
+ */
1676
+ export type DropConferenceParticipantPayload = {
1677
+ /** Participant identifier supplied by the current task roster. */
1678
+ participantId: string;
1679
+ };
1680
+
1681
+ /**
1682
+ * Payload shape used by consult conference helper utilities.
1683
+ */
1684
+ export type consultConferencePayloadData = {
1685
+ agentId?: string;
1686
+ destinationType?: string;
1687
+ destAgentId?: string;
1688
+ };
1689
+
1690
+ /**
1691
+ * Minimal event-emitter contract exposed to SDK consumers.
1692
+ * Defined here so that consumers do NOT need `@types/node` in their tsconfig.
1693
+ * The runtime Task class still extends Node's EventEmitter (via ampersand-events),
1694
+ * which satisfies this interface at runtime.
1695
+ * @public
1696
+ */
1697
+ export interface IEventEmitter {
1698
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1699
+ on(event: string, listener: (...args: any[]) => void): this;
1700
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1701
+ off(event: string, listener: (...args: any[]) => void): this;
1702
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1703
+ once(event: string, listener: (...args: any[]) => void): this;
1704
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1705
+ emit(event: string, ...args: any[]): boolean;
1706
+ }
1707
+
1186
1708
  /**
1187
1709
  * Interface for managing task-related operations in the contact center
1188
- * Extends EventEmitter to support event-driven task updates
1710
+ * Extends IEventEmitter to support event-driven task updates
1189
1711
  */
1190
- export interface ITask extends EventEmitter {
1712
+ export interface ITask extends IEventEmitter {
1191
1713
  /**
1192
1714
  * Event data received in the Contact Center events.
1193
1715
  * Contains detailed task information including interaction details, media resources,
@@ -1207,6 +1729,59 @@ export interface ITask extends EventEmitter {
1207
1729
  */
1208
1730
  autoWrapup?: AutoWrapup;
1209
1731
 
1732
+ /**
1733
+ * Latest UI controls derived from the state machine.
1734
+ * Each control has `isVisible` and `isEnabled` flags computed from current task state.
1735
+ * Subscribe to {@link TASK_EVENTS.TASK_UI_CONTROLS_UPDATED} for change notifications.
1736
+ */
1737
+ readonly uiControls: TaskUIControls;
1738
+
1739
+ /**
1740
+ * Update wxApp thick-client answer flag at runtime.
1741
+ * Voice tasks override to refresh uiControls; other channel types no-op.
1742
+ * @internal
1743
+ */
1744
+ setEnableWxBetterTogether(enabled: boolean): void;
1745
+
1746
+ /**
1747
+ * Apply wxApp mute state from Mercury sync or call-details fetch.
1748
+ * @internal
1749
+ */
1750
+ applyWxAppMuteStateFromSync(incomingCallId: string, muted: boolean): void;
1751
+
1752
+ /**
1753
+ * Current wxApp mute state for engaged telephony (Voice tasks only).
1754
+ */
1755
+ getWxAppMuted?(): boolean;
1756
+
1757
+ /**
1758
+ * Re-seed wxApp mute from GET telephony/calls/{callId}. Resolves to muted state when known.
1759
+ */
1760
+ syncWxAppMuteFromCallDetails?(): Promise<boolean | undefined>;
1761
+
1762
+ /**
1763
+ * State machine instance for managing task state transitions and derived properties.
1764
+ * The state machine handles:
1765
+ * - State transitions (IDLE → OFFERED → CONNECTED → HELD, etc.)
1766
+ * - Derived properties (canHold, canResume, isConsulted, etc.)
1767
+ * - Action availability based on current state
1768
+ *
1769
+ * This is part of the migration from manual state management to centralized state machine.
1770
+ * During the transition period, both the old setUIControls() and state machine coexist.
1771
+ *
1772
+ * @see createTaskStateMachine
1773
+ * @internal
1774
+ */
1775
+ stateMachineService?: AnyActorRef;
1776
+ state?: any;
1777
+
1778
+ /**
1779
+ * Helper method to send events to the state machine.
1780
+ * This is part of the migration to XState.
1781
+ * @internal
1782
+ */
1783
+ sendStateMachineEvent: (event: TaskEventPayload) => void;
1784
+
1210
1785
  /**
1211
1786
  * Cancels the auto-wrapup timer for the task.
1212
1787
  * This method stops the auto-wrapup process if it is currently active.
@@ -1228,7 +1803,7 @@ export interface ITask extends EventEmitter {
1228
1803
  * @returns Updated task instance
1229
1804
  * @ignore
1230
1805
  */
1231
- updateTaskData(newData: TaskData): ITask;
1806
+ updateTaskData(newData: TaskData): void;
1232
1807
 
1233
1808
  /**
1234
1809
  * Answers or accepts an incoming task.
@@ -1360,28 +1935,29 @@ export interface ITask extends EventEmitter {
1360
1935
  * await task.transfer({ to: "queueId", destinationType: "queue" });
1361
1936
  * ```
1362
1937
  */
1363
- transfer(transferPayload: TransferPayLoad): Promise<TaskResponse>;
1938
+ transfer(transferPayload: TransferPayLoad, options?: TransferOptions): Promise<TaskResponse>;
1364
1939
 
1365
1940
  /**
1366
- * Transfers the task after consultation.
1367
- * @param consultTransferPayload - Details for consult transfer (optional)
1941
+ * Initiates a consult conference (merge consult call with main call).
1368
1942
  * @returns Promise<TaskResponse>
1369
1943
  * @example
1370
1944
  * ```typescript
1371
- * await task.consultTransfer({ to: "agentId", destinationType: "agent" });
1945
+ * await task.consultConference();
1372
1946
  * ```
1373
1947
  */
1374
- consultTransfer(consultTransferPayload?: ConsultTransferPayLoad): Promise<TaskResponse>;
1948
+ consultConference(): Promise<TaskResponse>;
1375
1949
 
1376
1950
  /**
1377
- * Initiates a consult conference (merge consult call with main call).
1951
+ * Removes a supported participant from the active conference.
1952
+ * Resolves after the correlated ParticipantLeftConference routing event.
1953
+ * @param payload - Participant identifier to remove
1378
1954
  * @returns Promise<TaskResponse>
1379
1955
  * @example
1380
1956
  * ```typescript
1381
- * await task.consultConference();
1957
+ * await task.dropConferenceParticipant({participantId: 'participant-id'});
1382
1958
  * ```
1383
1959
  */
1384
- consultConference(): Promise<TaskResponse>;
1960
+ dropConferenceParticipant(payload: DropConferenceParticipantPayload): Promise<TaskResponse>;
1385
1961
 
1386
1962
  /**
1387
1963
  * Exits from an ongoing conference.
@@ -1404,12 +1980,185 @@ export interface ITask extends EventEmitter {
1404
1980
  transferConference(): Promise<TaskResponse>;
1405
1981
 
1406
1982
  /**
1407
- * Toggles mute/unmute for the local audio stream during a WebRTC task.
1983
+ * Toggles between consult call and main call during consulting.
1984
+ * If on consult leg, switches to main call (holds consult).
1985
+ * If on main call, switches to consult (resumes consult).
1986
+ * Only available when in CONSULTING state.
1987
+ * @returns Promise<TaskResponse>
1988
+ * @example
1989
+ * ```typescript
1990
+ * await task.switchCall();
1991
+ * ```
1992
+ */
1993
+ switchCall(): Promise<TaskResponse>;
1994
+
1995
+ /**
1996
+ * Toggles mute/unmute for the active call.
1997
+ * WebRTC tasks toggle the local stream; wxApp engaged tasks route to telephony mute REST when
1998
+ * `enableWxBetterTogether` is active.
1999
+ * @param options - Optional target mute state (`muted`) for wxApp; ignored for WebRTC toggle.
1408
2000
  * @returns Promise<void>
1409
2001
  * @example
1410
2002
  * ```typescript
1411
2003
  * await task.toggleMute();
2004
+ * await task.toggleMute({ muted: true });
2005
+ * ```
2006
+ */
2007
+ toggleMute(options?: TaskToggleMuteOptions): Promise<void>;
2008
+
2009
+ /**
2010
+ * Sends in-call DTMF tones for wxApp engaged telephony tasks when `enableWxBetterTogether` is active.
2011
+ * @param options - DTMF digit(s) and optional shared-line owner id.
2012
+ * @returns Promise<void>
2013
+ * @example
2014
+ * ```typescript
2015
+ * await task.transmitDtmf({ dtmf: '5' });
2016
+ * ```
2017
+ */
2018
+ transmitDtmf(options: TaskTransmitDtmfOptions): Promise<void>;
2019
+ }
2020
+
2021
+ /**
2022
+ * Interface for managing digital channel task operations in the contact center
2023
+ * Digital channels (chat, email, social, SMS) have a simpler interface than voice
2024
+ * Extends ITask but overrides updateTaskData to return IDigital
2025
+ * @public
2026
+ */
2027
+ export interface IDigital extends Omit<ITask, 'updateTaskData'> {
2028
+ /**
2029
+ * Updates the task data
2030
+ * @param newData - Updated task data
2031
+ * @param shouldOverwrite - Whether to completely replace existing data
2032
+ * @returns Updated Digital task instance
2033
+ */
2034
+ updateTaskData(newData: TaskData, shouldOverwrite?: boolean): IDigital;
2035
+ }
2036
+
2037
+ /**
2038
+ * Interface for managing voice/telephony task operations in the contact center
2039
+ * Extends ITask with voice-specific functionality for hold/resume operations
2040
+ * @public
2041
+ */
2042
+ export interface IVoice extends ITask {
2043
+ /**
2044
+ * Toggles hold/resume state for a voice task.
2045
+ * If the task is currently on hold, it will be resumed.
2046
+ * If the task is active, it will be placed on hold.
2047
+ * @returns Promise<TaskResponse>
2048
+ * @example
2049
+ * ```typescript
2050
+ * await voiceTask.holdResume();
2051
+ * ```
2052
+ */
2053
+ holdResume(): Promise<TaskResponse>;
2054
+ /** @see wxAppVoiceMethods — WXCC-6026 */
2055
+ isWebexAppCallingOffer(): boolean;
2056
+ /** @see wxAppVoiceMethods — WXCC-6026 */
2057
+ getCallingDeviceDetails(): import('./WebexCallingUtils').WebexCallingDeviceDetails | undefined;
2058
+ /** @see wxAppVoiceMethods — WXCC-6026 */
2059
+ getWebexCallingCallId(): string | null;
2060
+ }
2061
+
2062
+ /**
2063
+ * Configuration options for voice task UI controls
2064
+ */
2065
+ export type VoiceUIControlOptions = {
2066
+ isEndTaskEnabled?: boolean;
2067
+ isEndConsultEnabled?: boolean;
2068
+ voiceVariant?: VoiceVariant;
2069
+ isRecordingEnabled?: boolean;
2070
+ enableWxBetterTogether?: boolean;
2071
+ consultTransferConfig?: ConsultTransferDestinationConfig;
2072
+ answerCallOnWebexService?: import('../AnswerCallOnWebexService').default;
2073
+ };
2074
+
2075
+ /**
2076
+ * Participant information for UI display
2077
+ */
2078
+ export type Participant = {
2079
+ id: string;
2080
+ name?: string;
2081
+ pType?: string;
2082
+ };
2083
+
2084
+ /**
2085
+ * @deprecated Use Participant instead
2086
+ */
2087
+ export type TaskAccessorParticipant = Participant;
2088
+
2089
+ export interface IWebRTC extends IVoice {
2090
+ /**
2091
+ * This method is used to mute/unmute the call.
2092
+ * @returns Promise<void>
2093
+ * @example
2094
+ * ```typescript
2095
+ * task.toggleMute();
2096
+ * ```
2097
+ */
2098
+ toggleMute(options?: TaskToggleMuteOptions): Promise<void>;
2099
+ /**
2100
+ * Decline the incoming task for Browser Login
2101
+ *
2102
+ * @example
2103
+ * ```
2104
+ * task.decline();
1412
2105
  * ```
1413
2106
  */
1414
- toggleMute(): Promise<void>;
2107
+ decline(): Promise<TaskResponse>;
2108
+ /**
2109
+ * This method is used to unregister the web call listeners.
2110
+ * @returns void
2111
+ * @example
2112
+ * ```typescript
2113
+ * task.unregisterWebCallListeners();
2114
+ * ```
2115
+ */
2116
+ unregisterWebCallListeners(): void;
2117
+ }
2118
+
2119
+ export type WebSocketPayload = TaskData & {
2120
+ type: string;
2121
+ mediaResourceId?: string;
2122
+ reason?: string;
2123
+ /** ContactEnded: party that ended the contact (e.g. 'Agent', 'Customer') */
2124
+ terminatingParty?: string;
2125
+ /**
2126
+ * Optional real-time transcript chunk payload.
2127
+ * Present on REAL_TIME_TRANSCRIPTION notifications.
2128
+ */
2129
+ data?: RealtimeTranscription['data'];
2130
+ };
2131
+
2132
+ export type WebSocketMessage = {
2133
+ keepalive?: 'true' | 'false' | boolean;
2134
+ type?: string;
2135
+ data: WebSocketPayload;
2136
+ };
2137
+
2138
+ /**
2139
+ * Actions to be performed after handling an event
2140
+ *
2141
+ * These actions represent TaskManager-level concerns (task collection lifecycle,
2142
+ * resource cleanup) rather than task-level state machine concerns. The separation
2143
+ * ensures proper responsibility:
2144
+ * - TaskManager: Collection management, metrics, cleanup
2145
+ * - State Machine: Task state transitions, event emissions, UI controls
2146
+ */
2147
+ export interface TaskEventActions {
2148
+ task?: ITask;
2149
+ }
2150
+
2151
+ /**
2152
+ * Context for processing an event
2153
+ *
2154
+ * Contains all information needed to process a WebSocket event:
2155
+ * - Event type and payload from the backend
2156
+ * - Task instance (if exists)
2157
+ * - Pre-mapped state machine event (if applicable)
2158
+ */
2159
+ export interface EventContext {
2160
+ eventType: string;
2161
+ payload: WebSocketPayload;
2162
+ task?: ITask;
2163
+ stateMachineEvent?: TaskEventPayload | null;
1415
2164
  }