@webex/contact-center 3.12.0-webex-services-ready.4 → 3.13.0-next.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 (250) hide show
  1. package/.sdd/manifest.json +24 -13
  2. package/ai-docs/ARCHITECTURE.md +1 -1
  3. package/ai-docs/CONTRACTS.md +21 -3
  4. package/ai-docs/SECURITY.md +1 -1
  5. package/ai-docs/SERVICE_STATE.md +4 -0
  6. package/ai-docs/contact-center-spec.md +53 -6
  7. package/ai-docs/features/consult-transfer-list-policy/spec/feature-spec.md +362 -0
  8. package/ai-docs/features/contact-owner-change-refactor.md +78 -0
  9. package/dist/cc.js +816 -26
  10. package/dist/cc.js.map +1 -1
  11. package/dist/config.js +7 -0
  12. package/dist/config.js.map +1 -1
  13. package/dist/constants.js +29 -2
  14. package/dist/constants.js.map +1 -1
  15. package/dist/index.js +66 -12
  16. package/dist/index.js.map +1 -1
  17. package/dist/metrics/MetricsManager.js +16 -0
  18. package/dist/metrics/MetricsManager.js.map +1 -1
  19. package/dist/metrics/behavioral-events.js +110 -0
  20. package/dist/metrics/behavioral-events.js.map +1 -1
  21. package/dist/metrics/constants.js +33 -0
  22. package/dist/metrics/constants.js.map +1 -1
  23. package/dist/services/AddressBook.js +18 -15
  24. package/dist/services/AddressBook.js.map +1 -1
  25. package/dist/services/AnswerCallOnWebexService.js +202 -0
  26. package/dist/services/AnswerCallOnWebexService.js.map +1 -0
  27. package/dist/services/ApiAiAssistant.js +221 -11
  28. package/dist/services/ApiAiAssistant.js.map +1 -1
  29. package/dist/services/EntryPoint.js +46 -68
  30. package/dist/services/EntryPoint.js.map +1 -1
  31. package/dist/services/Queue.js +27 -22
  32. package/dist/services/Queue.js.map +1 -1
  33. package/dist/services/WebCallingService.js +287 -37
  34. package/dist/services/WebCallingService.js.map +1 -1
  35. package/dist/services/WebexCrossClientService.js +225 -0
  36. package/dist/services/WebexCrossClientService.js.map +1 -0
  37. package/dist/services/WxAppTelephonyMercurySync.js +111 -0
  38. package/dist/services/WxAppTelephonyMercurySync.js.map +1 -0
  39. package/dist/services/config/Util.js +46 -46
  40. package/dist/services/config/Util.js.map +1 -1
  41. package/dist/services/config/constants.js +34 -77
  42. package/dist/services/config/constants.js.map +1 -1
  43. package/dist/services/config/index.js +100 -226
  44. package/dist/services/config/index.js.map +1 -1
  45. package/dist/services/config/types.js +55 -35
  46. package/dist/services/config/types.js.map +1 -1
  47. package/dist/services/constants.js +11 -1
  48. package/dist/services/constants.js.map +1 -1
  49. package/dist/services/core/Err.js.map +1 -1
  50. package/dist/services/core/Utils.js +25 -1
  51. package/dist/services/core/Utils.js.map +1 -1
  52. package/dist/services/core/WebexRequest.js +6 -2
  53. package/dist/services/core/WebexRequest.js.map +1 -1
  54. package/dist/services/core/aqm-reqs.js +17 -11
  55. package/dist/services/core/aqm-reqs.js.map +1 -1
  56. package/dist/services/core/constants.js +9 -1
  57. package/dist/services/core/constants.js.map +1 -1
  58. package/dist/services/core/types.js.map +1 -1
  59. package/dist/services/core/websocket/WebSocketManager.js +17 -1
  60. package/dist/services/core/websocket/WebSocketManager.js.map +1 -1
  61. package/dist/services/task/Task.js +275 -8
  62. package/dist/services/task/Task.js.map +1 -1
  63. package/dist/services/task/TaskFactory.js +11 -6
  64. package/dist/services/task/TaskFactory.js.map +1 -1
  65. package/dist/services/task/TaskManager.js +590 -42
  66. package/dist/services/task/TaskManager.js.map +1 -1
  67. package/dist/services/task/TaskUtils.js +11 -1
  68. package/dist/services/task/TaskUtils.js.map +1 -1
  69. package/dist/services/task/WebexCallingUtils.js +70 -0
  70. package/dist/services/task/WebexCallingUtils.js.map +1 -0
  71. package/dist/services/task/constants.js +14 -2
  72. package/dist/services/task/constants.js.map +1 -1
  73. package/dist/services/task/contact.js +29 -0
  74. package/dist/services/task/contact.js.map +1 -1
  75. package/dist/services/task/digital/Digital.js +4 -3
  76. package/dist/services/task/digital/Digital.js.map +1 -1
  77. package/dist/services/task/state-machine/TaskStateMachine.js +162 -53
  78. package/dist/services/task/state-machine/TaskStateMachine.js.map +1 -1
  79. package/dist/services/task/state-machine/actions.js +6 -1
  80. package/dist/services/task/state-machine/actions.js.map +1 -1
  81. package/dist/services/task/state-machine/guards.js +7 -10
  82. package/dist/services/task/state-machine/guards.js.map +1 -1
  83. package/dist/services/task/state-machine/types.js.map +1 -1
  84. package/dist/services/task/state-machine/uiControlsComputer.js +118 -18
  85. package/dist/services/task/state-machine/uiControlsComputer.js.map +1 -1
  86. package/dist/services/task/types.js +47 -1
  87. package/dist/services/task/types.js.map +1 -1
  88. package/dist/services/task/voice/Voice.js +477 -17
  89. package/dist/services/task/voice/Voice.js.map +1 -1
  90. package/dist/services/task/voice/WebRTC.js +6 -3
  91. package/dist/services/task/voice/WebRTC.js.map +1 -1
  92. package/dist/services/task/voice/wxAppOfferObservability.js +145 -0
  93. package/dist/services/task/voice/wxAppOfferObservability.js.map +1 -0
  94. package/dist/services/task/voice/wxAppVoiceMethods.js +395 -0
  95. package/dist/services/task/voice/wxAppVoiceMethods.js.map +1 -0
  96. package/dist/services/wxAppDiagnosticLogging.js +159 -0
  97. package/dist/services/wxAppDiagnosticLogging.js.map +1 -0
  98. package/dist/services/wxAppTelephonyUtils.js +19 -0
  99. package/dist/services/wxAppTelephonyUtils.js.map +1 -0
  100. package/dist/types/cc.d.ts +127 -9
  101. package/dist/types/config.d.ts +7 -0
  102. package/dist/types/constants.d.ts +23 -0
  103. package/dist/types/index.d.ts +38 -17
  104. package/dist/types/metrics/MetricsManager.d.ts +6 -0
  105. package/dist/types/metrics/constants.d.ts +31 -0
  106. package/dist/types/services/AddressBook.d.ts +2 -1
  107. package/dist/types/services/AnswerCallOnWebexService.d.ts +38 -0
  108. package/dist/types/services/ApiAiAssistant.d.ts +48 -4
  109. package/dist/types/services/EntryPoint.d.ts +7 -5
  110. package/dist/types/services/Queue.d.ts +5 -3
  111. package/dist/types/services/WebexCrossClientService.d.ts +32 -0
  112. package/dist/types/services/WxAppTelephonyMercurySync.d.ts +28 -0
  113. package/dist/types/services/config/Util.d.ts +4 -8
  114. package/dist/types/services/config/constants.d.ts +28 -76
  115. package/dist/types/services/config/index.d.ts +16 -64
  116. package/dist/types/services/config/types.d.ts +150 -173
  117. package/dist/types/services/constants.d.ts +9 -0
  118. package/dist/types/services/core/Err.d.ts +2 -0
  119. package/dist/types/services/core/Utils.d.ts +10 -0
  120. package/dist/types/services/core/WebexRequest.d.ts +1 -0
  121. package/dist/types/services/core/constants.d.ts +7 -0
  122. package/dist/types/services/core/types.d.ts +2 -0
  123. package/dist/types/services/task/Task.d.ts +34 -5
  124. package/dist/types/services/task/TaskFactory.d.ts +4 -2
  125. package/dist/types/services/task/TaskUtils.d.ts +6 -0
  126. package/dist/types/services/task/WebexCallingUtils.d.ts +11 -0
  127. package/dist/types/services/task/constants.d.ts +12 -0
  128. package/dist/types/services/task/contact.d.ts +4 -0
  129. package/dist/types/services/task/digital/Digital.d.ts +4 -3
  130. package/dist/types/services/task/state-machine/TaskStateMachine.d.ts +304 -56
  131. package/dist/types/services/task/state-machine/guards.d.ts +6 -5
  132. package/dist/types/services/task/state-machine/types.d.ts +9 -1
  133. package/dist/types/services/task/types.d.ts +192 -5
  134. package/dist/types/services/task/voice/Voice.d.ts +68 -11
  135. package/dist/types/services/task/voice/WebRTC.d.ts +5 -4
  136. package/dist/types/services/task/voice/wxAppOfferObservability.d.ts +39 -0
  137. package/dist/types/services/task/voice/wxAppVoiceMethods.d.ts +68 -0
  138. package/dist/types/services/wxAppDiagnosticLogging.d.ts +63 -0
  139. package/dist/types/services/wxAppTelephonyUtils.d.ts +5 -0
  140. package/dist/types/types.d.ts +125 -13
  141. package/dist/types/utils/PageCache.d.ts +20 -3
  142. package/dist/types.js +90 -8
  143. package/dist/types.js.map +1 -1
  144. package/dist/utils/PageCache.js +19 -5
  145. package/dist/utils/PageCache.js.map +1 -1
  146. package/dist/webex.js +9 -1
  147. package/dist/webex.js.map +1 -1
  148. package/package.json +10 -9
  149. package/src/cc.ts +1047 -48
  150. package/src/config.ts +7 -0
  151. package/src/constants.ts +36 -0
  152. package/src/index.ts +49 -11
  153. package/src/metrics/MetricsManager.ts +16 -0
  154. package/src/metrics/ai-docs/metrics-spec.md +138 -21
  155. package/src/metrics/behavioral-events.ts +112 -0
  156. package/src/metrics/constants.ts +36 -0
  157. package/src/services/AddressBook.ts +17 -6
  158. package/src/services/AnswerCallOnWebexService.ts +239 -0
  159. package/src/services/ApiAiAssistant.ts +297 -13
  160. package/src/services/EntryPoint.ts +59 -60
  161. package/src/services/Queue.ts +29 -12
  162. package/src/services/WebCallingService.ts +362 -40
  163. package/src/services/WebexCrossClientService.ts +298 -0
  164. package/src/services/WxAppTelephonyMercurySync.ts +142 -0
  165. package/src/services/agent/ai-docs/AGENTS.md +1 -1
  166. package/src/services/agent/ai-docs/agent-spec.md +1 -0
  167. package/src/services/ai-docs/AGENTS.md +11 -11
  168. package/src/services/ai-docs/services-spec.md +25 -5
  169. package/src/services/config/Util.ts +52 -82
  170. package/src/services/config/ai-docs/AGENTS.md +35 -40
  171. package/src/services/config/ai-docs/ARCHITECTURE.md +90 -103
  172. package/src/services/config/ai-docs/config-spec.md +132 -132
  173. package/src/services/config/constants.ts +39 -85
  174. package/src/services/config/index.ts +116 -277
  175. package/src/services/config/types.ts +145 -195
  176. package/src/services/constants.ts +10 -0
  177. package/src/services/core/Err.ts +1 -0
  178. package/src/services/core/Utils.ts +28 -0
  179. package/src/services/core/WebexRequest.ts +3 -1
  180. package/src/services/core/ai-docs/core-spec.md +25 -11
  181. package/src/services/core/aqm-reqs.ts +18 -12
  182. package/src/services/core/constants.ts +8 -0
  183. package/src/services/core/types.ts +33 -1
  184. package/src/services/core/websocket/WebSocketManager.ts +26 -2
  185. package/src/services/task/Task.ts +386 -12
  186. package/src/services/task/TaskFactory.ts +33 -6
  187. package/src/services/task/TaskManager.ts +857 -41
  188. package/src/services/task/TaskUtils.ts +13 -0
  189. package/src/services/task/WebexCallingUtils.ts +136 -0
  190. package/src/services/task/ai-docs/ARCHITECTURE.md +1 -0
  191. package/src/services/task/ai-docs/task-spec.md +190 -8
  192. package/src/services/task/constants.ts +13 -0
  193. package/src/services/task/contact.ts +30 -0
  194. package/src/services/task/digital/Digital.ts +11 -4
  195. package/src/services/task/state-machine/TaskStateMachine.ts +235 -81
  196. package/src/services/task/state-machine/actions.ts +5 -2
  197. package/src/services/task/state-machine/ai-docs/AGENTS.md +6 -4
  198. package/src/services/task/state-machine/ai-docs/ARCHITECTURE.md +35 -16
  199. package/src/services/task/state-machine/ai-docs/task-state-machine-spec.md +103 -33
  200. package/src/services/task/state-machine/guards.ts +7 -10
  201. package/src/services/task/state-machine/types.ts +16 -1
  202. package/src/services/task/state-machine/uiControlsComputer.ts +206 -32
  203. package/src/services/task/types.ts +269 -4
  204. package/src/services/task/voice/Voice.ts +625 -17
  205. package/src/services/task/voice/WebRTC.ts +11 -4
  206. package/src/services/task/voice/wxAppOfferObservability.ts +204 -0
  207. package/src/services/task/voice/wxAppVoiceMethods.ts +575 -0
  208. package/src/services/wxAppDiagnosticLogging.ts +286 -0
  209. package/src/services/wxAppTelephonyUtils.ts +14 -0
  210. package/src/types.ts +159 -13
  211. package/src/utils/AGENTS.md +21 -10
  212. package/src/utils/PageCache.ts +38 -5
  213. package/src/utils/ai-docs/utils-spec.md +21 -11
  214. package/src/webex.js +8 -0
  215. package/test/unit/fixtures/aiSummaryTestUtils.ts +40 -0
  216. package/test/unit/spec/cc.ts +3595 -120
  217. package/test/unit/spec/index.ts +891 -0
  218. package/test/unit/spec/metrics/MetricsManager.ts +25 -0
  219. package/test/unit/spec/metrics/behavioral-events.ts +60 -0
  220. package/test/unit/spec/services/AddressBook.ts +37 -6
  221. package/test/unit/spec/services/AnswerCallOnWebexService.ts +264 -0
  222. package/test/unit/spec/services/ApiAiAssistant.ts +269 -8
  223. package/test/unit/spec/services/EntryPoint.ts +87 -40
  224. package/test/unit/spec/services/Queue.ts +123 -12
  225. package/test/unit/spec/services/WebCallingService.ts +483 -54
  226. package/test/unit/spec/services/WebexCrossClientService.ts +509 -0
  227. package/test/unit/spec/services/WxAppTelephonyMercurySync.ts +136 -0
  228. package/test/unit/spec/services/config/Util.ts +501 -0
  229. package/test/unit/spec/services/config/index.ts +313 -543
  230. package/test/unit/spec/services/core/Utils.ts +22 -0
  231. package/test/unit/spec/services/core/WebexRequest.ts +8 -7
  232. package/test/unit/spec/services/core/aqm-reqs.ts +142 -1
  233. package/test/unit/spec/services/core/websocket/WebSocketManager.ts +64 -14
  234. package/test/unit/spec/services/task/Task.ts +2257 -11
  235. package/test/unit/spec/services/task/TaskFactory.ts +56 -2
  236. package/test/unit/spec/services/task/TaskManager.ts +5559 -1493
  237. package/test/unit/spec/services/task/TaskUtils.ts +72 -0
  238. package/test/unit/spec/services/task/WebexCallingUtils.ts +153 -0
  239. package/test/unit/spec/services/task/contact.ts +33 -0
  240. package/test/unit/spec/services/task/state-machine/TaskStateMachine.ts +1501 -92
  241. package/test/unit/spec/services/task/state-machine/guards.ts +210 -8
  242. package/test/unit/spec/services/task/state-machine/uiControlsComputer.ts +445 -7
  243. package/test/unit/spec/services/task/voice/Voice.ts +1710 -4
  244. package/test/unit/spec/services/task/voice/wxAppOfferObservability.ts +361 -0
  245. package/test/unit/spec/services/task/voice/wxAppVoiceMethods.ts +719 -0
  246. package/test/unit/spec/services/wxAppDiagnosticLogging.ts +179 -0
  247. package/test/unit/spec/wellnessSampleUtils.ts +288 -0
  248. package/typedoc.md +1 -1
  249. package/umd/contact-center.min.js +2 -2
  250. package/umd/contact-center.min.js.map +1 -1
package/dist/cc.js CHANGED
@@ -19,6 +19,10 @@ var _Utils = require("./services/core/Utils");
19
19
  var _types3 = require("./services/config/types");
20
20
  var _TaskManager = _interopRequireDefault(require("./services/task/TaskManager"));
21
21
  var _WebCallingService = _interopRequireDefault(require("./services/WebCallingService"));
22
+ var _AnswerCallOnWebexService = _interopRequireDefault(require("./services/AnswerCallOnWebexService"));
23
+ var _WebexCrossClientService = _interopRequireDefault(require("./services/WebexCrossClientService"));
24
+ var _WxAppTelephonyMercurySync = _interopRequireDefault(require("./services/WxAppTelephonyMercurySync"));
25
+ var _wxAppDiagnosticLogging = require("./services/wxAppDiagnosticLogging");
22
26
  var _types4 = require("./services/task/types");
23
27
  var _MetricsManager = _interopRequireDefault(require("./metrics/MetricsManager"));
24
28
  var _constants4 = require("./metrics/constants");
@@ -36,6 +40,13 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
36
40
  * with Webex Contact Center features through the WebexSDK.
37
41
  */
38
42
 
43
+ /**
44
+ * Typed allow-list of server-controlled websocket event names this SDK re-emits verbatim.
45
+ * Guards against emitting an arbitrary/unknown `data.type` supplied by the websocket payload.
46
+ * @ignore
47
+ */
48
+ const CC_EVENT_ALLOW_LIST = new Set(Object.values(_types3.CC_EVENTS));
49
+
39
50
  /**
40
51
  * The main Contact Center plugin class that enables integration with Webex Contact Center.
41
52
  *
@@ -119,7 +130,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
119
130
  *
120
131
  * // Login with browser-based calling
121
132
  * await cc.stationLogin({
122
- * teamId: profile.teams[0].teamId,
133
+ * teamId: profile.teams[0].id,
123
134
  * loginOption: 'BROWSER'
124
135
  * });
125
136
  *
@@ -185,6 +196,29 @@ class ContactCenter extends _webexCore.WebexPlugin {
185
196
  * @private
186
197
  */
187
198
 
199
+ /**
200
+ * REST telephony for wxApp thick-client answer (WXCC-6026)
201
+ * @private
202
+ */
203
+
204
+ /**
205
+ * usersub cross-client state for Webex App toast suppression
206
+ * @private
207
+ */
208
+
209
+ /**
210
+ * Mercury telephony mute sync for wxApp thick-client answer
211
+ * @private
212
+ */
213
+
214
+ /** True when wxApp mute sync opened Mercury (Extension/DN-only profiles). */
215
+ wxAppMercuryConnectedByCc = false;
216
+
217
+ /** True when wxApp mute sync registered the Webex device. */
218
+ wxAppDeviceRegisteredByCc = false;
219
+ static WXAPP_FALSE_PUBLISH_RETRY_DELAY_MS = 30_000;
220
+ static WXAPP_FALSE_PUBLISH_MAX_RETRIES = 3;
221
+
188
222
  /**
189
223
  * Core service managers for Contact Center operations
190
224
  * Includes agent, connection, and configuration services
@@ -213,6 +247,16 @@ class ContactCenter extends _webexCore.WebexPlugin {
213
247
  * @private
214
248
  */
215
249
 
250
+ /** Current login/relogin session used for agent-scoped wellness validation. */
251
+
252
+ /** Registered-session cache for the system WellbeingBreak idle code. */
253
+
254
+ /** Registration generation that owns the wellness idle-code cache and in-flight lookups. */
255
+ wellnessRegistrationGeneration = 0;
256
+ updateWellnessSession(agentSessionId) {
257
+ this.currentAgentSessionId = agentSessionId;
258
+ }
259
+
216
260
  /**
217
261
  * API instance for managing Webex Contact Center entry points
218
262
  * Provides functionality to fetch entry points with caching support
@@ -345,11 +389,20 @@ class ContactCenter extends _webexCore.WebexPlugin {
345
389
  connectionConfig: this.getConnectionConfig()
346
390
  });
347
391
  this.webCallingService = new _WebCallingService.default(this.$webex);
348
- this.apiAIAssistant = new _ApiAiAssistant.ApiAIAssistant(this.$webex);
392
+ this.webCallingService.on(_types3.VOICE_CONNECTION_EVENTS.STATE_CHANGE, this.handleVoiceConnectionStateChange);
393
+ this.answerCallOnWebexService = new _AnswerCallOnWebexService.default(this.$webex);
394
+ this.webexCrossClientService = new _WebexCrossClientService.default(this.$webex);
395
+ this.wxAppTelephonyMercurySync = new _WxAppTelephonyMercurySync.default(this.$webex);
396
+ this.apiAIAssistant = new _ApiAiAssistant.ApiAIAssistant(this.$webex, () => ({
397
+ isWellnessBreakEnabled: this.agentConfig?.isWellnessBreakEnabled === true,
398
+ agentId: this.agentConfig?.agentId,
399
+ agentSessionId: this.currentAgentSessionId
400
+ }));
349
401
  this.metricsManager = _MetricsManager.default.getInstance({
350
402
  webex: this.$webex
351
403
  });
352
404
  this.taskManager = _TaskManager.default.getTaskManager(this.apiAIAssistant, this.services.contact, this.webCallingService, this.services.webSocketManager, this.services.rtdWebSocketManager);
405
+ this.taskManager.setAnswerCallOnWebexService(this.answerCallOnWebexService);
353
406
  this.incomingTaskListener();
354
407
 
355
408
  // Initialize API instances
@@ -371,6 +424,11 @@ class ContactCenter extends _webexCore.WebexPlugin {
371
424
  // @ts-ignore
372
425
  this.trigger(_types4.TASK_EVENTS.TASK_INCOMING, task);
373
426
  };
427
+ handleVoiceConnectionStateChange = state => {
428
+ // WebexPlugin exposes `trigger` at runtime, though it is missing from its TypeScript types.
429
+ // @ts-ignore
430
+ this.trigger(_types3.VOICE_CONNECTION_EVENTS.STATE_CHANGE, state);
431
+ };
374
432
 
375
433
  /**
376
434
  * Handles task hydration events for updating task data
@@ -411,7 +469,82 @@ class ContactCenter extends _webexCore.WebexPlugin {
411
469
  // @ts-ignore
412
470
  this.trigger(_types4.TASK_EVENTS.TASK_CAMPAIGN_PREVIEW_RESERVATION, task);
413
471
  };
472
+ trackInvalidWellnessEvent(reason) {
473
+ this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.AI_ASSISTANT_WELLNESS_EVENT_INVALID, {
474
+ reason
475
+ }, ['operational']);
476
+ }
477
+ normalizeWellnessBreakEvent(payload) {
478
+ if (this.agentConfig?.isWellnessBreakEnabled !== true) {
479
+ this.trackInvalidWellnessEvent('wellness_disabled');
480
+ return null;
481
+ }
482
+ const notificationData = (0, _Utils.isRecord)(payload.data) ? payload.data : null;
483
+ const notificationDetails = notificationData && (0, _Utils.isRecord)(notificationData.notifDetails) ? notificationData.notifDetails : null;
484
+ const sessionData = notificationData && (0, _Utils.isRecord)(notificationData.data) ? notificationData.data : null;
485
+ const actionEvent = notificationDetails?.actionEvent;
486
+ if (payload.type !== _constants.WELLNESS_BREAK_HANDLER || notificationData?.notifType !== _constants.WELLNESS_BREAK_HANDLER || typeof actionEvent !== 'string') {
487
+ this.trackInvalidWellnessEvent('malformed_wellness_event');
488
+ return null;
489
+ }
490
+ if (!Object.values(_types.WELLNESS_BREAK_NOTIFICATION_ACTIONS).includes(actionEvent)) {
491
+ this.trackInvalidWellnessEvent('unknown_wellness_action');
492
+ return null;
493
+ }
494
+ const agentId = notificationData.agentId;
495
+ const eventOrgId = notificationData.orgId;
496
+ const sessionOrgId = sessionData?.orgId;
497
+ const envelopeOrgId = payload.orgId;
498
+ const agentSessionId = sessionData?.agentSessionId;
499
+ const currentOrgId = this.$webex.credentials.getOrgId();
500
+ if (typeof agentId !== 'string' || typeof eventOrgId !== 'string' || typeof sessionOrgId !== 'string' || typeof envelopeOrgId !== 'string' || typeof agentSessionId !== 'string' || !agentId || !eventOrgId || !sessionOrgId || !envelopeOrgId || !agentSessionId) {
501
+ this.trackInvalidWellnessEvent('missing_wellness_identity');
502
+ return null;
503
+ }
504
+ if (agentId !== this.agentConfig?.agentId || eventOrgId !== currentOrgId || sessionOrgId !== currentOrgId || envelopeOrgId !== currentOrgId) {
505
+ this.trackInvalidWellnessEvent('mismatched_wellness_identity');
506
+ return null;
507
+ }
508
+ const interactionValue = sessionData.interactionId ?? sessionData.InteractionId;
509
+ const actionText = notificationDetails.actionText;
510
+ const trackingId = payload.trackingId;
511
+ return {
512
+ agentId,
513
+ orgId: currentOrgId,
514
+ agentSessionId,
515
+ actionEvent: actionEvent,
516
+ ...(typeof actionText === 'string' ? {
517
+ actionText
518
+ } : {}),
519
+ ...(typeof interactionValue === 'string' ? {
520
+ interactionId: interactionValue
521
+ } : {}),
522
+ ...(typeof trackingId === 'string' ? {
523
+ trackingId
524
+ } : {})
525
+ };
526
+ }
527
+ handleWellnessBreakWebsocketPayload(payload) {
528
+ if (payload.type !== _constants.WELLNESS_BREAK_HANDLER) {
529
+ return false;
530
+ }
531
+ const wellnessEvent = this.normalizeWellnessBreakEvent(payload);
532
+ if (wellnessEvent) {
533
+ // @ts-ignore - WebexPlugin emit is available at runtime but absent from its declaration.
534
+ this.emit(_types3.CC_EVENTS.WELLNESS_BREAK, wellnessEvent);
535
+ }
536
+ return true;
537
+ }
414
538
  handleRTDWebsocketMessage = event => {
539
+ let payload;
540
+ try {
541
+ payload = JSON.parse(event);
542
+ } catch {
543
+ // TaskManager retains its existing malformed RTD message handling.
544
+ }
545
+ if ((0, _Utils.isRecord)(payload) && this.handleWellnessBreakWebsocketPayload(payload)) {
546
+ return;
547
+ }
415
548
  this.taskManager.handleRealtimeWebsocketEvent(event);
416
549
  };
417
550
 
@@ -456,15 +589,17 @@ class ContactCenter extends _webexCore.WebexPlugin {
456
589
  *
457
590
  * console.log('Agent ID:', profile.agentId);
458
591
  * console.log('Default DN:', profile.defaultDn);
459
- * console.log('Teams:', profile.teams.map(t => t.teamId));
592
+ * console.log('Teams:', profile.teams.map(t => t.id));
460
593
  * console.log('WebRTC Enabled:', profile.webRtcEnabled);
461
594
  * console.log('Supported Login Options:', profile.loginVoiceOptions);
462
595
  *
463
596
  * // Now you can proceed with station login, state changes, etc.
464
- * await cc.stationLogin({ teamId: profile.teams[0].teamId, loginOption: 'BROWSER' });
597
+ * await cc.stationLogin({ teamId: profile.teams[0].id, loginOption: 'BROWSER' });
465
598
  * ```
466
599
  */
467
600
  async register() {
601
+ this.wellnessRegistrationGeneration += 1;
602
+ this.wellbeingBreakIdleCode = undefined;
468
603
  _loggerProxy.default.log('Starting CC SDK registration', {
469
604
  module: _constants.CC_FILE,
470
605
  method: _constants.METHODS.REGISTER
@@ -484,7 +619,14 @@ class ContactCenter extends _webexCore.WebexPlugin {
484
619
  module: _constants.CC_FILE,
485
620
  method: _constants.METHODS.REGISTER
486
621
  });
487
- return resp;
622
+
623
+ // Registration can silently restore a station session without emitting a
624
+ // relogin event. Project the active session for consumers that must
625
+ // recover session-scoped state after a page refresh.
626
+ return resp.isAgentLoggedIn && this.currentAgentSessionId ? {
627
+ ...resp,
628
+ agentSessionId: this.currentAgentSessionId
629
+ } : resp;
488
630
  } catch (error) {
489
631
  this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.WEBSOCKET_REGISTER_FAILED, {
490
632
  orgId: error.orgId
@@ -531,8 +673,12 @@ class ContactCenter extends _webexCore.WebexPlugin {
531
673
  *
532
674
  */
533
675
  async deregister() {
676
+ this.wellnessRegistrationGeneration += 1;
677
+ this.wellbeingBreakIdleCode = undefined;
678
+ this.updateWellnessSession();
534
679
  try {
535
680
  this.metricsManager.timeEvent([_constants4.METRIC_EVENT_NAMES.WEBSOCKET_DEREGISTER_SUCCESS, _constants4.METRIC_EVENT_NAMES.WEBSOCKET_DEREGISTER_FAIL]);
681
+ this.taskManager.clearAISummaryState();
536
682
  this.taskManager.off(_types4.TASK_EVENTS.TASK_INCOMING, this.handleIncomingTask);
537
683
  this.taskManager.off(_types4.TASK_EVENTS.TASK_HYDRATE, this.handleTaskHydrate);
538
684
  this.taskManager.off(_types4.TASK_EVENTS.TASK_MULTI_LOGIN_HYDRATE, this.handleTaskMultiLoginHydrate);
@@ -541,6 +687,11 @@ class ContactCenter extends _webexCore.WebexPlugin {
541
687
  this.services.webSocketManager.off('message', this.handleWebsocketMessage);
542
688
  this.services.rtdWebSocketManager.off('message', this.handleRTDWebsocketMessage);
543
689
  this.services.connectionService.off('connectionLost', this.handleConnectionLost);
690
+ const {
691
+ publishError: wxAppPublishError
692
+ } = await this.teardownWxAppLocalState({
693
+ clearInitFlag: true
694
+ });
544
695
  if (this.agentConfig.webRtcEnabled && this.agentConfig.loginVoiceOptions.includes(_types.LoginOption.BROWSER)) {
545
696
  if (this.$webex.internal.mercury.connected) {
546
697
  this.$webex.internal.mercury.off('online');
@@ -565,7 +716,12 @@ class ContactCenter extends _webexCore.WebexPlugin {
565
716
  }
566
717
 
567
718
  // Clear any cached agent configuration
719
+ this.wellbeingBreakIdleCode = undefined;
568
720
  this.agentConfig = null;
721
+ this.updateWellnessSession();
722
+ if (wxAppPublishError) {
723
+ throw wxAppPublishError;
724
+ }
569
725
  _loggerProxy.default.log('Deregistered successfully', {
570
726
  module: _constants.CC_FILE,
571
727
  method: _constants.METHODS.DEREGISTER
@@ -619,6 +775,12 @@ class ContactCenter extends _webexCore.WebexPlugin {
619
775
  * ```
620
776
  */
621
777
  async getBuddyAgents(data) {
778
+ const {
779
+ action,
780
+ state,
781
+ mediaType = 'telephony'
782
+ } = data;
783
+ const buddyAgentState = state ?? (action === 'Transfer' ? _constants2.AGENT_STATE_AVAILABLE : undefined);
622
784
  _loggerProxy.default.info('Fetching buddy agents', {
623
785
  module: _constants.CC_FILE,
624
786
  method: _constants.METHODS.GET_BUDDY_AGENTS
@@ -628,13 +790,16 @@ class ContactCenter extends _webexCore.WebexPlugin {
628
790
  const resp = await this.services.agent.buddyAgents({
629
791
  data: {
630
792
  agentProfileId: this.agentConfig.agentProfileID,
631
- ...data
793
+ mediaType,
794
+ ...(buddyAgentState ? {
795
+ state: buddyAgentState
796
+ } : {})
632
797
  }
633
798
  });
634
799
  this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.FETCH_BUDDY_AGENTS_SUCCESS, {
635
800
  ..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(resp),
636
- mediaType: data.mediaType,
637
- buddyAgentState: data.state,
801
+ mediaType,
802
+ buddyAgentState,
638
803
  buddyAgentCount: resp.data.agentList.length
639
804
  }, ['operational']);
640
805
  _loggerProxy.default.log(`Successfully retrieved ${resp.data.agentList.length} buddy agents`, {
@@ -647,8 +812,8 @@ class ContactCenter extends _webexCore.WebexPlugin {
647
812
  const failureResp = error.details;
648
813
  this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.FETCH_BUDDY_AGENTS_FAILED, {
649
814
  ..._MetricsManager.default.getCommonTrackingFieldForAQMResponseFailed(failureResp),
650
- mediaType: data.mediaType,
651
- buddyAgentState: data.state
815
+ mediaType,
816
+ buddyAgentState
652
817
  }, ['operational']);
653
818
  const {
654
819
  error: detailedError
@@ -685,20 +850,32 @@ class ContactCenter extends _webexCore.WebexPlugin {
685
850
  isEndConsultEnabled: this.agentConfig.isEndConsultEnabled,
686
851
  webRtcEnabled: this.agentConfig.webRtcEnabled,
687
852
  autoWrapup: this.agentConfig.wrapUpData?.wrapUpProps?.autoWrapup ?? false,
688
- aiFeature: this.agentConfig.aiFeature
853
+ aiFeature: this.agentConfig.aiFeature,
854
+ consultTransfer: {
855
+ allowConsultToQueue: this.agentConfig.allowConsultToQueue,
856
+ accessQueue: this.agentConfig.accessQueue,
857
+ accessEntryPoint: this.agentConfig.accessEntryPoint,
858
+ accessBuddyTeam: this.agentConfig.accessBuddyTeam
859
+ },
860
+ enableWxBetterTogether: this.isWxBetterTogetherEnabled(),
861
+ getWxAppUsersubPublished: () => this.webexCrossClientService.isAnswerCallsStateActive()
689
862
  };
690
863
  this.taskManager.setConfigFlags(configFlags);
691
864
  // TODO: Make profile a singleton to make it available throughout app/sdk so we dont need to inject info everywhere
692
865
  this.taskManager.setWrapupData(this.agentConfig.wrapUpData);
693
866
  this.taskManager.setAgentId(this.agentConfig.agentId);
867
+ this.taskManager.setAgentName(this.agentConfig.agentName);
694
868
  this.taskManager.setWebRtcEnabled(this.agentConfig.webRtcEnabled);
695
869
  this.apiAIAssistant.setAIFeatureFlags(this.agentConfig.aiFeature);
870
+ this.wellbeingBreakIdleCode = undefined;
871
+ this.updateWellnessSession();
696
872
 
697
873
  /**
698
874
  * RTD websocket currently supports realtime transcripts and suggested responses.
699
875
  * Extend this condition when additional AI RTD features are introduced.
876
+ * Wellness break notifications also arrive on this websocket.
700
877
  */
701
- if (this.agentConfig.aiFeature?.realtimeTranscripts?.enable || this.agentConfig.aiFeature?.suggestedResponses?.enable) {
878
+ if (this.agentConfig.aiFeature?.realtimeTranscripts?.enable || this.agentConfig.aiFeature?.suggestedResponses?.enable || this.agentConfig.aiFeature?.generatedSummaries?.wrapUpSummariesEnabled === true || this.agentConfig.aiFeature?.generatedSummaries?.consultTransferSummariesEnabled === true || this.agentConfig.isWellnessBreakEnabled) {
702
879
  _loggerProxy.default.info('Connecting to RTD websocket', {
703
880
  module: _constants.CC_FILE,
704
881
  method: _constants.METHODS.CONNECT_WEBSOCKET
@@ -719,7 +896,7 @@ class ContactCenter extends _webexCore.WebexPlugin {
719
896
  });
720
897
  });
721
898
  }
722
- if (this.agentConfig.webRtcEnabled && this.agentConfig.loginVoiceOptions.includes(_types.LoginOption.BROWSER) && !this.isWebRTCRegistrationDisabled()) {
899
+ if (this.agentConfig.loginVoiceOptions.some(loginOption => this.isBrowserVoiceRequired(loginOption))) {
723
900
  try {
724
901
  await this.$webex.internal.mercury.connect();
725
902
  _loggerProxy.default.log('Authentication: webex.internal.mercury.connect successful', {
@@ -748,6 +925,7 @@ class ContactCenter extends _webexCore.WebexPlugin {
748
925
  }
749
926
  return this.agentConfig;
750
927
  } catch (error) {
928
+ this.updateWellnessSession();
751
929
  _loggerProxy.default.error(`Error during register: ${error}`, {
752
930
  module: _constants.CC_FILE,
753
931
  method: _constants.METHODS.CONNECT_WEBSOCKET
@@ -807,13 +985,15 @@ class ContactCenter extends _webexCore.WebexPlugin {
807
985
  throw error;
808
986
  }
809
987
  }
988
+ const deviceId = this.getDeviceId(data.loginOption, data.dialNumber);
810
989
  const loginResponse = await this.services.agent.stationLogin({
811
990
  data: {
812
- dialNumber: data.loginOption === _types.LoginOption.BROWSER ? this.agentConfig.agentId : data.dialNumber,
991
+ // BROWSER DN must be webrtc-{agentId} so VPOP/RTMS do not treat a bare UUID as PSTN.
992
+ dialNumber: data.loginOption === _types.LoginOption.BROWSER ? deviceId : data.dialNumber,
813
993
  teamId: data.teamId,
814
994
  deviceType: data.loginOption,
815
995
  isExtension: data.loginOption === _types.LoginOption.EXTENSION,
816
- deviceId: this.getDeviceId(data.loginOption, data.dialNumber),
996
+ deviceId,
817
997
  roles: [_constants3.AGENT],
818
998
  teamName: _constants.EMPTY_STRING,
819
999
  siteId: _constants.EMPTY_STRING,
@@ -821,7 +1001,9 @@ class ContactCenter extends _webexCore.WebexPlugin {
821
1001
  auxCodeId: _constants.EMPTY_STRING
822
1002
  }
823
1003
  });
824
- if (this.agentConfig.webRtcEnabled && data.loginOption === _types.LoginOption.BROWSER && !this.isWebRTCRegistrationDisabled()) {
1004
+ this.webCallingService.setLoginOption(data.loginOption);
1005
+ this.webCallingService.setBrowserVoiceRequired(this.isBrowserVoiceRequired(data.loginOption));
1006
+ if (this.isBrowserVoiceRequired(data.loginOption)) {
825
1007
  await this.webCallingService.registerWebCallingLine();
826
1008
  } else if (this.agentConfig.webRtcEnabled && data.loginOption === _types.LoginOption.BROWSER && this.isWebRTCRegistrationDisabled()) {
827
1009
  _loggerProxy.default.info('Skipping web calling line registration because disableWebRTCRegistration is enabled', {
@@ -834,6 +1016,7 @@ class ContactCenter extends _webexCore.WebexPlugin {
834
1016
  channelsMap,
835
1017
  ...loginData
836
1018
  } = resp.data;
1019
+ this.updateWellnessSession(resp.data.agentSessionId);
837
1020
  this.agentConfig.currentTeamId = resp.data.teamId;
838
1021
  const response = {
839
1022
  ...loginData,
@@ -845,7 +1028,13 @@ class ContactCenter extends _webexCore.WebexPlugin {
845
1028
  },
846
1029
  notifsTrackingId: resp.trackingId
847
1030
  };
848
- this.webCallingService.setLoginOption(data.loginOption);
1031
+ if (this.agentConfig) {
1032
+ this.agentConfig.deviceType = data.loginOption;
1033
+ if (data.loginOption === _types.LoginOption.AGENT_DN || data.loginOption === _types.LoginOption.EXTENSION) {
1034
+ this.agentConfig.defaultDn = data.dialNumber;
1035
+ this.agentConfig.dn = data.dialNumber;
1036
+ }
1037
+ }
849
1038
  this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.STATION_LOGIN_SUCCESS, {
850
1039
  ..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(resp),
851
1040
  loginType: data.loginOption,
@@ -858,6 +1047,7 @@ class ContactCenter extends _webexCore.WebexPlugin {
858
1047
  method: _constants.METHODS.STATION_LOGIN,
859
1048
  trackingId: resp.trackingId
860
1049
  });
1050
+ await this.ensureWxAppPostStationLogin();
861
1051
  return response;
862
1052
  } catch (error) {
863
1053
  const failure = error.details;
@@ -910,8 +1100,10 @@ class ContactCenter extends _webexCore.WebexPlugin {
910
1100
  logoutReason: data.logoutReason
911
1101
  }, ['behavioral', 'business', 'operational']);
912
1102
  if (this.webCallingService) {
913
- this.webCallingService.deregisterWebCallingLine();
1103
+ await this.webCallingService.deregisterWebCallingLine();
914
1104
  }
1105
+ await this.teardownWxAppLocalState();
1106
+ this.updateWellnessSession();
915
1107
  _loggerProxy.default.log(`Agent station logout completed successfully`, {
916
1108
  module: _constants.CC_FILE,
917
1109
  method: _constants.METHODS.STATION_LOGOUT,
@@ -996,6 +1188,18 @@ class ContactCenter extends _webexCore.WebexPlugin {
996
1188
  });
997
1189
  try {
998
1190
  this.metricsManager.timeEvent([_constants4.METRIC_EVENT_NAMES.AGENT_STATE_CHANGE_SUCCESS, _constants4.METRIC_EVENT_NAMES.AGENT_STATE_CHANGE_FAILED]);
1191
+ if (data.state === _constants2.AGENT_STATE_AVAILABLE && this.webCallingService?.isBrowserVoiceRequired() && !this.webCallingService.isVoiceReady()) {
1192
+ const error = new Error(_types.VOICE_CONNECTION_ERROR.NOT_READY);
1193
+ error.details = {
1194
+ type: 'SDK_VALIDATION_ERROR',
1195
+ orgId: this.$webex.credentials.getOrgId(),
1196
+ trackingId: _constants.EMPTY_STRING,
1197
+ data: {
1198
+ reason: _types.VOICE_CONNECTION_ERROR.NOT_READY
1199
+ }
1200
+ };
1201
+ throw error;
1202
+ }
999
1203
  const agentStatusResponse = await this.services.agent.stateChange({
1000
1204
  data: {
1001
1205
  ...data,
@@ -1005,7 +1209,7 @@ class ContactCenter extends _webexCore.WebexPlugin {
1005
1209
  this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.AGENT_STATE_CHANGE_SUCCESS, {
1006
1210
  ..._MetricsManager.default.getCommonTrackingFieldForAQMResponse(agentStatusResponse),
1007
1211
  requestedState: data.state,
1008
- teamId: this.agentConfig?.teams[0]?.teamId ?? _constants.EMPTY_STRING,
1212
+ teamId: this.agentConfig?.teams[0]?.id ?? _constants.EMPTY_STRING,
1009
1213
  status: agentStatusResponse.data?.status,
1010
1214
  subStatus: agentStatusResponse.data?.subStatus,
1011
1215
  auxCodeId: data.auxCodeId,
@@ -1032,6 +1236,85 @@ class ContactCenter extends _webexCore.WebexPlugin {
1032
1236
  }
1033
1237
  }
1034
1238
 
1239
+ /**
1240
+ * Returns the system-managed `WellbeingBreak` idle code for the current registration.
1241
+ * The value is fetched outside Desktop Profile filtering and cached until deregistration.
1242
+ * @returns The normalized system idle-code entity
1243
+ * @throws Structured Contact Center error when wellness is disabled or the code is unavailable
1244
+ * @example
1245
+ * const idleCode = await webex.cc.getWellbeingBreakIdleCode();
1246
+ * @public
1247
+ */
1248
+ async getWellbeingBreakIdleCode() {
1249
+ const method = _constants.METHODS.GET_WELLBEING_BREAK_IDLE_CODE;
1250
+ try {
1251
+ if (!this.agentConfig?.isWellnessBreakEnabled) {
1252
+ const validationError = new Error('WELLNESS_BREAK_NOT_ENABLED');
1253
+ validationError.details = {
1254
+ type: 'SDK_VALIDATION_ERROR',
1255
+ orgId: this.$webex.credentials.getOrgId(),
1256
+ trackingId: _constants.EMPTY_STRING,
1257
+ data: {
1258
+ reason: 'WELLNESS_BREAK_NOT_ENABLED'
1259
+ }
1260
+ };
1261
+ throw validationError;
1262
+ }
1263
+ if (this.wellbeingBreakIdleCode) {
1264
+ return this.wellbeingBreakIdleCode;
1265
+ }
1266
+ this.metricsManager.timeEvent([_constants4.METRIC_EVENT_NAMES.WELLBEING_BREAK_IDLE_CODE_FETCH_SUCCESS, _constants4.METRIC_EVENT_NAMES.WELLBEING_BREAK_IDLE_CODE_FETCH_FAILED]);
1267
+ const registrationGeneration = this.wellnessRegistrationGeneration;
1268
+ const orgId = this.$webex.credentials.getOrgId();
1269
+ const idleCode = await this.services.config.getWellbeingBreakIdleCode(orgId);
1270
+ if (registrationGeneration !== this.wellnessRegistrationGeneration || orgId !== this.$webex.credentials.getOrgId() || !this.agentConfig?.isWellnessBreakEnabled) {
1271
+ const staleRegistrationError = new Error('WELLNESS_BREAK_REGISTRATION_CHANGED');
1272
+ staleRegistrationError.details = {
1273
+ type: 'SDK_VALIDATION_ERROR',
1274
+ orgId,
1275
+ trackingId: _constants.EMPTY_STRING,
1276
+ data: {
1277
+ reason: 'WELLNESS_BREAK_REGISTRATION_CHANGED'
1278
+ }
1279
+ };
1280
+ throw staleRegistrationError;
1281
+ }
1282
+ this.wellbeingBreakIdleCode = idleCode;
1283
+ this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.WELLBEING_BREAK_IDLE_CODE_FETCH_SUCCESS, {}, ['operational']);
1284
+ return idleCode;
1285
+ } catch (error) {
1286
+ this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.WELLBEING_BREAK_IDLE_CODE_FETCH_FAILED, {
1287
+ reason: error instanceof Error ? error.message : _constants.UNKNOWN_ERROR
1288
+ }, ['operational']);
1289
+ const {
1290
+ error: detailedError
1291
+ } = (0, _Utils.getErrorDetails)(error, method, _constants.CC_FILE);
1292
+ throw detailedError;
1293
+ }
1294
+ }
1295
+
1296
+ /**
1297
+ * Returns the current browser voice connection state.
1298
+ * Subscribe to `voice:connectionStateChange` to receive updates. The snapshot keeps line
1299
+ * registration separate from Mobius socket connectivity and does not represent the Contact
1300
+ * Center WebSocket connection.
1301
+ *
1302
+ * @returns {VoiceConnectionState} Current browser voice status and underlying connection states
1303
+ * @fires voice:connectionStateChange When browser voice availability changes
1304
+ * @public
1305
+ * @example
1306
+ * ```typescript
1307
+ * cc.on('voice:connectionStateChange', onVoiceStateChange);
1308
+ * const state = cc.getVoiceConnectionState();
1309
+ * ```
1310
+ */
1311
+ getVoiceConnectionState() {
1312
+ const state = this.webCallingService?.getVoiceConnectionState();
1313
+ return state ?? {
1314
+ ..._constants.DEFAULT_VOICE_CONNECTION_STATE
1315
+ };
1316
+ }
1317
+
1035
1318
  /**
1036
1319
  * Processes incoming websocket messages and emits corresponding events
1037
1320
  * Handles various event types including agent state changes, login events,
@@ -1041,8 +1324,9 @@ class ContactCenter extends _webexCore.WebexPlugin {
1041
1324
  */
1042
1325
  handleWebsocketMessage = event => {
1043
1326
  const eventData = JSON.parse(event);
1044
- // Re-emit all the events related to agent except keep-alives
1045
- if (!eventData.keepalive && eventData.data && eventData.data.type) {
1327
+ // Re-emit all the events related to agent except keep-alives. Only event names present in
1328
+ // the typed CC_EVENTS allow-list are emitted; unknown/server-injected types are ignored.
1329
+ if (!eventData.keepalive && eventData.data && eventData.data.type && CC_EVENT_ALLOW_LIST.has(eventData.data.type)) {
1046
1330
  // @ts-ignore
1047
1331
  this.emit(eventData.data.type, eventData.data);
1048
1332
  }
@@ -1065,8 +1349,14 @@ class ContactCenter extends _webexCore.WebexPlugin {
1065
1349
  };
1066
1350
  this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.WEBSOCKET_EVENT_RECEIVED, metricsPayload, ['operational']);
1067
1351
  }
1352
+ if (this.handleWellnessBreakWebsocketPayload(eventData)) {
1353
+ return;
1354
+ }
1068
1355
  switch (eventData.type) {
1069
1356
  case _types3.CC_EVENTS.AGENT_MULTI_LOGIN:
1357
+ if (eventData.data?.type === 'AgentMultiLoginCloseSession' && (!eventData.data.agentSessionId || eventData.data.agentSessionId === this.currentAgentSessionId)) {
1358
+ this.updateWellnessSession();
1359
+ }
1070
1360
  // @ts-ignore
1071
1361
  this.emit(_types2.AGENT_EVENTS.AGENT_MULTI_LOGIN, eventData.data);
1072
1362
  break;
@@ -1087,6 +1377,10 @@ class ContactCenter extends _webexCore.WebexPlugin {
1087
1377
  channelsMap,
1088
1378
  ...loginData
1089
1379
  } = eventData.data;
1380
+ this.updateWellnessSession(loginData.agentSessionId);
1381
+ if (loginData.deviceType === _types.LoginOption.EXTENSION || loginData.deviceType === _types.LoginOption.AGENT_DN) {
1382
+ this.webCallingService.setBrowserVoiceRequired(false);
1383
+ }
1090
1384
  const stationLoginData = {
1091
1385
  ...loginData,
1092
1386
  mmProfile: {
@@ -1108,6 +1402,7 @@ class ContactCenter extends _webexCore.WebexPlugin {
1108
1402
  channelsMap,
1109
1403
  ...loginData
1110
1404
  } = eventData.data;
1405
+ this.updateWellnessSession(loginData.agentSessionId);
1111
1406
  const stationReLoginData = {
1112
1407
  ...loginData,
1113
1408
  mmProfile: {
@@ -1120,8 +1415,8 @@ class ContactCenter extends _webexCore.WebexPlugin {
1120
1415
  };
1121
1416
  // @ts-ignore
1122
1417
  this.emit(_types2.AGENT_EVENTS.AGENT_RELOGIN_SUCCESS, stationReLoginData);
1418
+ break;
1123
1419
  }
1124
- break;
1125
1420
  case _types3.CC_EVENTS.AGENT_STATE_CHANGE_SUCCESS:
1126
1421
  // @ts-ignore
1127
1422
  this.emit(_types2.AGENT_EVENTS.AGENT_STATE_CHANGE_SUCCESS, eventData.data);
@@ -1135,6 +1430,9 @@ class ContactCenter extends _webexCore.WebexPlugin {
1135
1430
  this.emit(_types2.AGENT_EVENTS.AGENT_STATION_LOGIN_FAILED, eventData.data);
1136
1431
  break;
1137
1432
  case _types3.CC_EVENTS.AGENT_LOGOUT_SUCCESS:
1433
+ if (!eventData.data.agentSessionId || eventData.data.agentSessionId === this.currentAgentSessionId) {
1434
+ this.updateWellnessSession();
1435
+ }
1138
1436
  // @ts-ignore
1139
1437
  this.emit(_types2.AGENT_EVENTS.AGENT_LOGOUT_SUCCESS, eventData.data);
1140
1438
  break;
@@ -1160,6 +1458,16 @@ class ContactCenter extends _webexCore.WebexPlugin {
1160
1458
  return this.$config?.disableWebRTCRegistration === true;
1161
1459
  }
1162
1460
 
1461
+ /**
1462
+ * Determines whether this local login should register a browser voice line.
1463
+ * @param {LoginOption} loginOption Login device selected for this station login
1464
+ * @returns {boolean} True when browser WebRTC registration is enabled
1465
+ * @private
1466
+ */
1467
+ isBrowserVoiceRequired(loginOption) {
1468
+ return loginOption === _types.LoginOption.BROWSER && this.agentConfig?.webRtcEnabled === true && !this.isWebRTCRegistrationDisabled();
1469
+ }
1470
+
1163
1471
  /**
1164
1472
  * Validates contact-center plugin configuration before service initialization
1165
1473
  * @private
@@ -1170,6 +1478,485 @@ class ContactCenter extends _webexCore.WebexPlugin {
1170
1478
  }
1171
1479
  }
1172
1480
 
1481
+ /**
1482
+ * Whether wxApp thick-client answer is enabled for this SDK instance.
1483
+ * @public
1484
+ */
1485
+ isWxBetterTogetherEnabled() {
1486
+ return this.$config?.enableWxBetterTogether === true;
1487
+ }
1488
+
1489
+ /**
1490
+ * Current station login option (Extension, Dial Number, or Browser/Desktop).
1491
+ * Prefer webCallingService — updated on every stationLogin before wxApp hooks run.
1492
+ * @private
1493
+ */
1494
+ getCurrentStationLoginOption() {
1495
+ return this.webCallingService?.loginOption ?? this.agentConfig?.deviceType;
1496
+ }
1497
+
1498
+ /**
1499
+ * wxApp thick-client answer is supported for Extension and Dial Number station login only —
1500
+ * not Browser/Desktop (WebRTC) login.
1501
+ * @private
1502
+ */
1503
+ assertWxAppStationLoginSupportedForEnable() {
1504
+ const loginOption = this.getCurrentStationLoginOption();
1505
+ if (loginOption !== _types.LoginOption.EXTENSION && loginOption !== _types.LoginOption.AGENT_DN) {
1506
+ throw new Error('setManageWebexCallingInWxcc requires EXTENSION or AGENT_DN station login. Complete station login before enabling.');
1507
+ }
1508
+ }
1509
+
1510
+ /**
1511
+ * Clears runtime wxApp config after logout/deregister so stale flags do not apply on relogin.
1512
+ * @private
1513
+ */
1514
+ resetEnableWxBetterTogetherConfig() {
1515
+ if (this.$config) {
1516
+ this.$config.enableWxBetterTogether = false;
1517
+ }
1518
+ this.taskManager.applyEnableWxBetterTogether(false);
1519
+ }
1520
+
1521
+ /**
1522
+ * Runtime enable/disable for wxApp Better Together (toast suppression + Mercury mute sync).
1523
+ *
1524
+ * **Phase 1 (WXCC-6026 / MMT): NOT part of the public host contract.**
1525
+ * Hosts must set `webexConfig.cc.enableWxBetterTogether` before `webex.init()` / `cc.register()`.
1526
+ * To change the flag after the SDK is initialized, re-init the SDK with the updated config.
1527
+ *
1528
+ * **Supported public read API:** {@link isWxBetterTogetherEnabled}.
1529
+ * **Supported telephony API:** unified `task.accept()`, `task.decline()`, `task.toggleMute()`,
1530
+ * `task.transmitDtmf()` — SDK routes wxApp calls internally when the init flag is active.
1531
+ *
1532
+ * **Production lifecycle does not call this method.** Station login, silent relogin, logout,
1533
+ * and deregister use {@link ensureWxAppPostStationLogin} and {@link teardownWxAppLocalState}
1534
+ * (usersub publish + Mercury subscribe/unsubscribe based on the init flag).
1535
+ *
1536
+ * This setter remains as a **private implementation** for Phase 2 runtime toggle and unit tests.
1537
+ * It updates `$config.enableWxBetterTogether`, TaskManager flags, cross-client usersub
1538
+ * (`answer-calls-on-wxcc`), and Mercury mute sync; rolls back config on publish/connect failure.
1539
+ *
1540
+ * @param enabled - `true` to enable wxApp answer + usersub suppression; `false` to disable and tear down.
1541
+ * @throws When enabling without login, on unsupported BROWSER station login, or when usersub/Mercury init fails.
1542
+ * @internal
1543
+ * @see enableWxBetterTogether (CCPluginConfig init flag)
1544
+ * @see ensureWxAppPostStationLogin
1545
+ * @see teardownWxAppLocalState
1546
+ */
1547
+ async setManageWebexCallingInWxcc(enabled) {
1548
+ if (enabled && !this.$webex.internal.device?.userId) {
1549
+ throw new Error('Cannot publish answer-calls-on-wxcc: user is not logged in');
1550
+ }
1551
+ if (enabled) {
1552
+ this.assertWxAppStationLoginSupportedForEnable();
1553
+ }
1554
+ const previousEnabled = this.isWxBetterTogetherEnabled();
1555
+ if (this.$config) {
1556
+ this.$config.enableWxBetterTogether = enabled;
1557
+ }
1558
+ this.taskManager.applyEnableWxBetterTogether(enabled);
1559
+ let publishedEnable = false;
1560
+ try {
1561
+ if (enabled) {
1562
+ await this.ensureWxAppMercuryAndSubscribe();
1563
+ await this.publishAnswerOnWebexCrossClientState(true);
1564
+ publishedEnable = true;
1565
+ this.taskManager.syncWxAppMuteFromCallDetailsForAllTasks();
1566
+ this.taskManager.refreshWxAppOfferObservabilityForAllTasks();
1567
+ } else {
1568
+ await this.publishAnswerOnWebexCrossClientState(false);
1569
+ this.wxAppTelephonyMercurySync.unsubscribe();
1570
+ await this.releaseWxAppMercuryResources();
1571
+ }
1572
+ } catch (error) {
1573
+ if (publishedEnable) {
1574
+ await this.revertWxAppCrossClientPublish();
1575
+ } else if (enabled) {
1576
+ this.wxAppTelephonyMercurySync.unsubscribe();
1577
+ await this.releaseWxAppMercuryResources();
1578
+ }
1579
+ if (this.$config) {
1580
+ this.$config.enableWxBetterTogether = previousEnabled;
1581
+ }
1582
+ this.taskManager.applyEnableWxBetterTogether(previousEnabled);
1583
+ throw error;
1584
+ }
1585
+ }
1586
+ getWxAppTelephonyTaskType() {
1587
+ const loginOption = this.getCurrentStationLoginOption();
1588
+ if (loginOption === _types.LoginOption.BROWSER) {
1589
+ return 'WebRTC';
1590
+ }
1591
+ if (loginOption === _types.LoginOption.EXTENSION || loginOption === _types.LoginOption.AGENT_DN) {
1592
+ return 'Voice';
1593
+ }
1594
+ return 'unknown';
1595
+ }
1596
+ async ensureWxAppPostStationLogin() {
1597
+ const loginOption = this.getCurrentStationLoginOption();
1598
+ const flagEnabled = this.isWxBetterTogetherEnabled();
1599
+ const telephonyTaskType = this.getWxAppTelephonyTaskType();
1600
+ if (loginOption === _types.LoginOption.BROWSER) {
1601
+ if (flagEnabled) {
1602
+ (0, _wxAppDiagnosticLogging.logWxAppSessionReadiness)({
1603
+ enableWxBetterTogether: true,
1604
+ loginOption,
1605
+ wxAppHooksApplied: false,
1606
+ usersubPublished: false,
1607
+ mercurySubscribed: false,
1608
+ telephonyTaskType,
1609
+ skipReason: 'unsupported_browser_login'
1610
+ });
1611
+ this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.WXAPP_SESSION_SKIPPED, {
1612
+ loginOption,
1613
+ enableWxBetterTogether: true,
1614
+ skipReason: 'unsupported_browser_login'
1615
+ }, ['operational', 'behavioral']);
1616
+ }
1617
+ return;
1618
+ }
1619
+ let publishedEnable = false;
1620
+ let wxAppInitStage = 'mercury';
1621
+ try {
1622
+ if (flagEnabled) {
1623
+ this.metricsManager.timeEvent([_constants4.METRIC_EVENT_NAMES.WXAPP_SESSION_INIT_SUCCESS, _constants4.METRIC_EVENT_NAMES.WXAPP_SESSION_INIT_FAILED]);
1624
+ await this.ensureWxAppMercuryAndSubscribe();
1625
+ wxAppInitStage = 'publish';
1626
+ await this.publishAnswerOnWebexCrossClientState(true);
1627
+ publishedEnable = true;
1628
+ this.taskManager.syncWxAppMuteFromCallDetailsForAllTasks();
1629
+ this.taskManager.refreshWxAppOfferObservabilityForAllTasks();
1630
+ const mercurySubscribed = this.wxAppTelephonyMercurySync.isSubscribed();
1631
+ const usersubPublished = this.webexCrossClientService.isAnswerCallsStateActive();
1632
+ (0, _wxAppDiagnosticLogging.logWxAppSessionReadiness)({
1633
+ enableWxBetterTogether: true,
1634
+ loginOption,
1635
+ wxAppHooksApplied: true,
1636
+ usersubPublished,
1637
+ mercurySubscribed,
1638
+ telephonyTaskType
1639
+ });
1640
+ const sessionInitReady = mercurySubscribed && usersubPublished;
1641
+ if (sessionInitReady) {
1642
+ this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.WXAPP_SESSION_INIT_SUCCESS, {
1643
+ loginOption,
1644
+ enableWxBetterTogether: true,
1645
+ usersubPublished,
1646
+ mercurySubscribed,
1647
+ telephonyTaskType
1648
+ }, ['operational', 'behavioral']);
1649
+ } else {
1650
+ this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.WXAPP_SESSION_INIT_FAILED, {
1651
+ loginOption,
1652
+ enableWxBetterTogether: true,
1653
+ usersubPublished,
1654
+ mercurySubscribed,
1655
+ telephonyTaskType,
1656
+ skipReason: !usersubPublished ? 'usersub_not_published' : 'mercury_not_subscribed'
1657
+ }, ['operational', 'behavioral']);
1658
+ }
1659
+ } else {
1660
+ await this.ensureWxAppDeviceRegistered();
1661
+ await this.publishAnswerOnWebexCrossClientState(false, {
1662
+ force: true
1663
+ });
1664
+ this.webexCrossClientService.teardown();
1665
+ this.wxAppTelephonyMercurySync.unsubscribe();
1666
+ await this.releaseWxAppMercuryResources();
1667
+ (0, _wxAppDiagnosticLogging.logWxAppSessionReadiness)({
1668
+ enableWxBetterTogether: false,
1669
+ loginOption,
1670
+ wxAppHooksApplied: true,
1671
+ usersubPublished: false,
1672
+ mercurySubscribed: false,
1673
+ telephonyTaskType,
1674
+ skipReason: 'flag_disabled'
1675
+ });
1676
+ this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.WXAPP_SESSION_SKIPPED, {
1677
+ loginOption,
1678
+ enableWxBetterTogether: false,
1679
+ skipReason: 'flag_disabled'
1680
+ }, ['operational', 'behavioral']);
1681
+ }
1682
+ } catch (error) {
1683
+ _loggerProxy.default.error(`Failed to initialize wxApp post-station-login: ${error}`, {
1684
+ module: _constants.CC_FILE,
1685
+ method: _constants.METHODS.STATION_LOGIN
1686
+ });
1687
+ if (flagEnabled) {
1688
+ const sessionInitFailureReason = wxAppInitStage === 'mercury' ? 'mercury_subscribe_failed' : 'publish_failed';
1689
+ this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.WXAPP_SESSION_INIT_FAILED, {
1690
+ loginOption,
1691
+ enableWxBetterTogether: true,
1692
+ usersubPublished: this.webexCrossClientService.isAnswerCallsStateActive(),
1693
+ mercurySubscribed: this.wxAppTelephonyMercurySync.isSubscribed(),
1694
+ telephonyTaskType,
1695
+ skipReason: sessionInitFailureReason,
1696
+ error: error instanceof Error ? error.toString() : String(error)
1697
+ }, ['operational', 'behavioral']);
1698
+ (0, _wxAppDiagnosticLogging.logWxAppSessionReadiness)({
1699
+ enableWxBetterTogether: true,
1700
+ loginOption,
1701
+ wxAppHooksApplied: false,
1702
+ usersubPublished: this.webexCrossClientService.isAnswerCallsStateActive(),
1703
+ mercurySubscribed: this.wxAppTelephonyMercurySync.isSubscribed(),
1704
+ telephonyTaskType,
1705
+ skipReason: sessionInitFailureReason
1706
+ });
1707
+ if (publishedEnable) {
1708
+ await this.revertWxAppCrossClientPublish();
1709
+ } else {
1710
+ this.wxAppTelephonyMercurySync.unsubscribe();
1711
+ await this.releaseWxAppMercuryResources();
1712
+ }
1713
+ this.resetEnableWxBetterTogetherConfig();
1714
+ } else {
1715
+ this.scheduleForcedFalsePublishRetry();
1716
+ }
1717
+ }
1718
+ }
1719
+ clearWxAppFalsePublishRetryTimer() {
1720
+ if (this.wxAppFalsePublishRetryTimer) {
1721
+ clearTimeout(this.wxAppFalsePublishRetryTimer);
1722
+ this.wxAppFalsePublishRetryTimer = undefined;
1723
+ }
1724
+ }
1725
+ scheduleForcedFalsePublishRetry(retryAttempt = 0) {
1726
+ this.scheduleFalsePublishRetry(retryAttempt, {
1727
+ requireDisabled: true
1728
+ });
1729
+ }
1730
+
1731
+ /**
1732
+ * Retries compensating false publish after rollback failure, regardless of enabled flag.
1733
+ * @private
1734
+ */
1735
+ scheduleCompensatingFalsePublishRetry(retryAttempt = 0) {
1736
+ this.scheduleFalsePublishRetry(retryAttempt);
1737
+ }
1738
+ scheduleFalsePublishRetry(retryAttempt = 0, options = {}) {
1739
+ if (retryAttempt >= ContactCenter.WXAPP_FALSE_PUBLISH_MAX_RETRIES) {
1740
+ return;
1741
+ }
1742
+ if (options?.requireDisabled && this.isWxBetterTogetherEnabled()) {
1743
+ return;
1744
+ }
1745
+ this.clearWxAppFalsePublishRetryTimer();
1746
+ this.wxAppFalsePublishRetryTimer = setTimeout(async () => {
1747
+ this.wxAppFalsePublishRetryTimer = undefined;
1748
+ if (options?.requireDisabled && this.isWxBetterTogetherEnabled()) {
1749
+ return;
1750
+ }
1751
+ if (!options?.requireDisabled && this.isWxBetterTogetherEnabled() && this.webexCrossClientService.isAnswerCallsStateActive()) {
1752
+ return;
1753
+ }
1754
+ try {
1755
+ await this.ensureWxAppDeviceRegistered();
1756
+ await this.publishAnswerOnWebexCrossClientState(false, {
1757
+ force: true
1758
+ });
1759
+ this.webexCrossClientService.teardown();
1760
+ this.wxAppTelephonyMercurySync.unsubscribe();
1761
+ await this.releaseWxAppMercuryResources();
1762
+ } catch (retryError) {
1763
+ _loggerProxy.default.error(`Failed to retry forced answer-calls-on-wxcc false publish: ${retryError}`, {
1764
+ module: _constants.CC_FILE,
1765
+ method: _constants.METHODS.SET_MANAGE_WEBEX_CALLING_IN_WXCC
1766
+ });
1767
+ this.scheduleFalsePublishRetry(retryAttempt + 1, options);
1768
+ }
1769
+ }, ContactCenter.WXAPP_FALSE_PUBLISH_RETRY_DELAY_MS);
1770
+ }
1771
+
1772
+ /**
1773
+ * Best-effort rollback when usersub true was published but wxApp setup did not complete.
1774
+ * @private
1775
+ */
1776
+ async revertWxAppCrossClientPublish() {
1777
+ try {
1778
+ await this.publishAnswerOnWebexCrossClientState(false, {
1779
+ force: true
1780
+ });
1781
+ } catch (error) {
1782
+ _loggerProxy.default.error(`Failed to publish compensating answer-calls-on-wxcc false during wxApp rollback: ${error}`, {
1783
+ module: _constants.CC_FILE,
1784
+ method: _constants.METHODS.SET_MANAGE_WEBEX_CALLING_IN_WXCC
1785
+ });
1786
+ this.scheduleCompensatingFalsePublishRetry();
1787
+ }
1788
+ this.webexCrossClientService.teardown();
1789
+ this.wxAppTelephonyMercurySync.unsubscribe();
1790
+ await this.releaseWxAppMercuryResources();
1791
+ }
1792
+ async ensureWxAppDeviceRegistered() {
1793
+ const device = this.$webex.internal.device;
1794
+ if (device && !device.registered && device.register) {
1795
+ await device.register();
1796
+ this.wxAppDeviceRegisteredByCc = true;
1797
+ _loggerProxy.default.log('WxApp: device registered for cross-client publish', {
1798
+ module: _constants.CC_FILE,
1799
+ method: _constants.METHODS.ENSURE_WXAPP_MERCURY_CONNECTED
1800
+ });
1801
+ }
1802
+ }
1803
+ async ensureWxAppMercuryConnected() {
1804
+ const mercury = this.$webex.internal.mercury;
1805
+ await this.ensureWxAppDeviceRegistered();
1806
+ if (mercury && !mercury.connected) {
1807
+ await mercury.connect();
1808
+ this.wxAppMercuryConnectedByCc = true;
1809
+ _loggerProxy.default.log('WxApp mute sync: mercury connected', {
1810
+ module: _constants.CC_FILE,
1811
+ method: _constants.METHODS.ENSURE_WXAPP_MERCURY_CONNECTED
1812
+ });
1813
+ }
1814
+ }
1815
+
1816
+ /**
1817
+ * Disconnects Mercury and unregisters the device when wxApp mute sync opened them.
1818
+ * @private
1819
+ */
1820
+ async releaseWxAppMercuryResources() {
1821
+ const mercury = this.$webex.internal.mercury;
1822
+ const device = this.$webex.internal.device;
1823
+ if (this.wxAppMercuryConnectedByCc && mercury?.connected) {
1824
+ try {
1825
+ await mercury.disconnect();
1826
+ this.wxAppMercuryConnectedByCc = false;
1827
+ _loggerProxy.default.log('WxApp mute sync: mercury disconnected', {
1828
+ module: _constants.CC_FILE,
1829
+ method: _constants.METHODS.ENSURE_WXAPP_MERCURY_CONNECTED
1830
+ });
1831
+ } catch (error) {
1832
+ _loggerProxy.default.error(`Failed to disconnect wxApp Mercury: ${error}`, {
1833
+ module: _constants.CC_FILE,
1834
+ method: _constants.METHODS.ENSURE_WXAPP_MERCURY_CONNECTED
1835
+ });
1836
+ }
1837
+ }
1838
+ if (this.wxAppDeviceRegisteredByCc && device?.registered && device.unregister) {
1839
+ try {
1840
+ // @ts-ignore
1841
+ await device.unregister();
1842
+ this.wxAppDeviceRegisteredByCc = false;
1843
+ _loggerProxy.default.log('WxApp mute sync: device unregistered', {
1844
+ module: _constants.CC_FILE,
1845
+ method: _constants.METHODS.ENSURE_WXAPP_MERCURY_CONNECTED
1846
+ });
1847
+ } catch (error) {
1848
+ _loggerProxy.default.error(`Failed to unregister wxApp device: ${error}`, {
1849
+ module: _constants.CC_FILE,
1850
+ method: _constants.METHODS.ENSURE_WXAPP_MERCURY_CONNECTED
1851
+ });
1852
+ }
1853
+ } else if (this.wxAppDeviceRegisteredByCc) {
1854
+ this.wxAppDeviceRegisteredByCc = false;
1855
+ }
1856
+ }
1857
+
1858
+ /**
1859
+ * Clears wxApp runtime state and feature-owned resources. Publish failures are logged;
1860
+ * optional rethrow for deregister when callers need to surface usersub errors.
1861
+ * @private
1862
+ */
1863
+ async teardownWxAppLocalState(options) {
1864
+ this.clearWxAppFalsePublishRetryTimer();
1865
+ let publishError;
1866
+ try {
1867
+ const shouldForceFalsePublish = this.isWxBetterTogetherEnabled() || this.webexCrossClientService.isAnswerCallsStateActive();
1868
+ await this.publishAnswerOnWebexCrossClientState(false, {
1869
+ force: shouldForceFalsePublish
1870
+ });
1871
+ } catch (error) {
1872
+ publishError = error;
1873
+ _loggerProxy.default.error(`Failed to publish answer-calls-on-wxcc false during wxApp teardown: ${error}`, {
1874
+ module: _constants.CC_FILE,
1875
+ method: _constants.METHODS.SET_MANAGE_WEBEX_CALLING_IN_WXCC
1876
+ });
1877
+ }
1878
+ this.webexCrossClientService.teardown();
1879
+ this.wxAppTelephonyMercurySync.unsubscribe();
1880
+ await this.releaseWxAppMercuryResources();
1881
+ if (options?.clearInitFlag) {
1882
+ this.resetEnableWxBetterTogetherConfig();
1883
+ }
1884
+ if (publishError) {
1885
+ this.scheduleCompensatingFalsePublishRetry();
1886
+ }
1887
+ if (options?.rethrowPublishError && publishError) {
1888
+ throw publishError;
1889
+ }
1890
+ return {
1891
+ publishError: publishError ?? undefined
1892
+ };
1893
+ }
1894
+ async ensureWxAppMercuryAndSubscribe() {
1895
+ if (!this.isWxBetterTogetherEnabled()) {
1896
+ return;
1897
+ }
1898
+ if (this.getCurrentStationLoginOption() === _types.LoginOption.BROWSER) {
1899
+ return;
1900
+ }
1901
+ const agentId = this.agentConfig?.agentId;
1902
+ if (!agentId) {
1903
+ _loggerProxy.default.error('Cannot subscribe wxApp mute sync: agentId unavailable', {
1904
+ module: _constants.CC_FILE,
1905
+ method: _constants.METHODS.SYNC_WXAPP_MUTE_FROM_MERCURY
1906
+ });
1907
+ this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.WXAPP_MERCURY_SUBSCRIBE_FAILED, {
1908
+ error: 'agentId unavailable',
1909
+ mercurySubscribed: false
1910
+ }, ['operational', 'behavioral']);
1911
+ return;
1912
+ }
1913
+ try {
1914
+ await this.ensureWxAppMercuryConnected();
1915
+ this.wxAppTelephonyMercurySync.subscribe(agentId, (callId, muted) => {
1916
+ this.taskManager.applyWxAppMuteStateFromSync(callId, muted);
1917
+ });
1918
+ } catch (error) {
1919
+ _loggerProxy.default.error(`Failed to ensure wxApp Mercury mute sync: ${error}`, {
1920
+ module: _constants.CC_FILE,
1921
+ method: _constants.METHODS.SYNC_WXAPP_MUTE_FROM_MERCURY
1922
+ });
1923
+ this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.WXAPP_MERCURY_SUBSCRIBE_FAILED, {
1924
+ error: error instanceof Error ? error.toString() : String(error),
1925
+ mercurySubscribed: false
1926
+ }, ['operational', 'behavioral']);
1927
+ this.wxAppTelephonyMercurySync.unsubscribe();
1928
+ await this.releaseWxAppMercuryResources();
1929
+ throw error;
1930
+ }
1931
+ }
1932
+ async publishAnswerOnWebexCrossClientState(enable, options) {
1933
+ if (enable && !this.isWxBetterTogetherEnabled()) {
1934
+ return;
1935
+ }
1936
+ if (!enable && !options?.force && !this.webexCrossClientService.isAnswerCallsStateActive()) {
1937
+ return;
1938
+ }
1939
+ const userId = this.$webex.internal.device?.userId;
1940
+ if (!userId) {
1941
+ if (enable && this.isWxBetterTogetherEnabled()) {
1942
+ this.metricsManager.trackEvent(_constants4.METRIC_EVENT_NAMES.WXAPP_USERSUB_PUBLISH_FAILED, {
1943
+ enableWxBetterTogether: true,
1944
+ usersubPublished: this.webexCrossClientService.isAnswerCallsStateActive(),
1945
+ skipReason: 'user_id_unavailable',
1946
+ error: 'User ID is unavailable for cross-client publish'
1947
+ }, ['operational', 'behavioral']);
1948
+ }
1949
+ return;
1950
+ }
1951
+ await this.webexCrossClientService.setManageWebexCallingInWxcc(enable, {
1952
+ userId,
1953
+ trackPublishMetrics: true
1954
+ });
1955
+ if (enable) {
1956
+ this.clearWxAppFalsePublishRetryTimer();
1957
+ }
1958
+ }
1959
+
1173
1960
  /**
1174
1961
  * Initializes event listeners for the Contact Center service
1175
1962
  * Sets up handlers for connection state changes and other core events
@@ -1228,6 +2015,7 @@ class ContactCenter extends _webexCore.WebexPlugin {
1228
2015
  });
1229
2016
  try {
1230
2017
  const reLoginResponse = await this.services.agent.reload();
2018
+ this.updateWellnessSession(reLoginResponse.data.agentSessionId);
1231
2019
  const {
1232
2020
  agentId,
1233
2021
  lastStateChangeReason,
@@ -1268,6 +2056,7 @@ class ContactCenter extends _webexCore.WebexPlugin {
1268
2056
  }
1269
2057
  this.agentConfig.lastStateAuxCodeId = auxCodeId;
1270
2058
  this.agentConfig.isAgentLoggedIn = true;
2059
+ await this.ensureWxAppPostStationLogin();
1271
2060
  _loggerProxy.default.log(`Silent relogin process completed successfully with login Option: ${reLoginResponse.data.deviceType} teamId: ${reLoginResponse.data.teamId}`, {
1272
2061
  module: _constants.CC_FILE,
1273
2062
  method: _constants.METHODS.SILENT_RELOGIN,
@@ -1299,6 +2088,7 @@ class ContactCenter extends _webexCore.WebexPlugin {
1299
2088
  */
1300
2089
  async handleDeviceType(deviceType, dn) {
1301
2090
  this.webCallingService.setLoginOption(deviceType);
2091
+ this.webCallingService.setBrowserVoiceRequired(this.isBrowserVoiceRequired(deviceType));
1302
2092
  this.agentConfig.deviceType = deviceType;
1303
2093
  switch (deviceType) {
1304
2094
  case _types.LoginOption.BROWSER:
@@ -1884,8 +2674,8 @@ class ContactCenter extends _webexCore.WebexPlugin {
1884
2674
  }
1885
2675
 
1886
2676
  /**
1887
- * Returns paginated entry points for the organization.
1888
- * Thin wrapper around internal EntryPoint instance.
2677
+ * Returns paginated entry points using the EntryPoint service defaults.
2678
+ * Existing request parameters can override those defaults.
1889
2679
  * @public
1890
2680
  */
1891
2681
  async getEntryPoints(params = {}) {
@@ -1893,8 +2683,8 @@ class ContactCenter extends _webexCore.WebexPlugin {
1893
2683
  }
1894
2684
 
1895
2685
  /**
1896
- * Returns paginated contact service queues for the organization.
1897
- * Thin wrapper around internal Queue instance.
2686
+ * Returns paginated contact service queues using the Queue service defaults.
2687
+ * Existing request parameters can override those defaults.
1898
2688
  * @public
1899
2689
  */
1900
2690
  async getQueues(params = {}) {