@webex/contact-center 3.12.0-webex-services-ready.4 → 3.13.0

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 +19 -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 +50 -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 +757 -22
  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 +23 -2
  14. package/dist/constants.js.map +1 -1
  15. package/dist/index.js +34 -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 +10 -2
  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 +51 -18
  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 +102 -8
  101. package/dist/types/config.d.ts +7 -0
  102. package/dist/types/constants.d.ts +21 -0
  103. package/dist/types/index.d.ts +34 -15
  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 +146 -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 +80 -13
  141. package/dist/types/utils/PageCache.d.ts +20 -3
  142. package/dist/types.js +54 -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 +969 -38
  150. package/src/config.ts +7 -0
  151. package/src/constants.ts +24 -0
  152. package/src/index.ts +39 -10
  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 +16 -2
  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 +10 -10
  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 +140 -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 +108 -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 +3408 -152
  217. package/test/unit/spec/index.ts +885 -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 +38 -0
  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
@@ -3,6 +3,7 @@
3
3
  */
4
4
 
5
5
  import {
6
+ CONSULT_TRANSFER_DESTINATION_TYPE,
6
7
  InteractionUIControls,
7
8
  TASK_CHANNEL_TYPE,
8
9
  TaskData,
@@ -11,6 +12,10 @@ import {
11
12
  VOICE_VARIANT,
12
13
  } from '../types';
13
14
  import {TaskContext, UIControlConfig} from './types';
15
+ import {
16
+ getWebexCallingDeviceDetailsForAgent,
17
+ isWxAppEngagedForControls,
18
+ } from '../WebexCallingUtils';
14
19
  import {TaskState, MAX_PARTICIPANTS_IN_MULTIPARTY_CONFERENCE, INTERACTION_STATE} from './constants';
15
20
  import {
16
21
  getIsCustomerInCall,
@@ -20,11 +25,41 @@ import {
20
25
  getIsConsultedAgentForControls,
21
26
  getServerHoldStateForControls,
22
27
  } from '../TaskUtils';
28
+ import {INBOUND_DIRECTION, OUTDIAL_DIRECTION} from '../../../constants';
29
+ import {COLLABORATION_ACCESS} from '../../config/constants';
30
+
31
+ type DestinationControls = TaskUIControls['consultTransferDestinations'];
23
32
 
24
33
  const DISABLED = {isVisible: false, isEnabled: false} as const;
25
34
  const VISIBLE_ENABLED = {isVisible: true, isEnabled: true} as const;
26
35
  const VISIBLE_DISABLED = {isVisible: true, isEnabled: false} as const;
27
36
 
37
+ /** wxApp telephony controls live on the main leg only (mute/keypad via wxApp APIs). */
38
+ function withWxAppTelephonyControls(
39
+ controls: InteractionUIControls,
40
+ isWxAppEngaged: boolean,
41
+ currentLeg: TaskUILeg,
42
+ isWrappingUp: boolean
43
+ ): InteractionUIControls {
44
+ if (!isWxAppEngaged || isWrappingUp) {
45
+ return controls;
46
+ }
47
+
48
+ if (currentLeg === 'main') {
49
+ return {
50
+ ...controls,
51
+ mute: VISIBLE_ENABLED,
52
+ keypad: VISIBLE_ENABLED,
53
+ };
54
+ }
55
+
56
+ return {
57
+ ...controls,
58
+ mute: DISABLED,
59
+ keypad: DISABLED,
60
+ };
61
+ }
62
+
28
63
  function getDefaultInteractionUIControls(): InteractionUIControls {
29
64
  return {
30
65
  accept: DISABLED,
@@ -43,18 +78,24 @@ function getDefaultInteractionUIControls(): InteractionUIControls {
43
78
  transferConference: DISABLED,
44
79
  mergeToConference: DISABLED,
45
80
  switch: DISABLED,
81
+ keypad: DISABLED,
46
82
  };
47
83
  }
48
84
 
49
85
  function createTaskUIControls(
50
86
  main: InteractionUIControls,
51
87
  consult: InteractionUIControls,
52
- activeLeg: TaskUILeg
88
+ activeLeg: TaskUILeg,
89
+ consultTransferDestinations: DestinationControls = {
90
+ consult: [],
91
+ transfer: [],
92
+ }
53
93
  ): TaskUIControls {
54
94
  return {
55
95
  main,
56
96
  consult,
57
97
  activeLeg,
98
+ consultTransferDestinations,
58
99
  };
59
100
  }
60
101
 
@@ -66,6 +107,53 @@ export function getDefaultUIControls(): TaskUIControls {
66
107
  );
67
108
  }
68
109
 
110
+ function getConsultTransferDestinations(
111
+ config: UIControlConfig,
112
+ taskData?: TaskData | null
113
+ ): DestinationControls {
114
+ const destinationConfig = config.consultTransferConfig;
115
+ if (!destinationConfig) {
116
+ return {consult: [], transfer: []};
117
+ }
118
+
119
+ const isVoice = config.channelType === TASK_CHANNEL_TYPE.VOICE;
120
+ const interaction = taskData?.interaction;
121
+ const direction = interaction?.contactDirection?.type?.toUpperCase();
122
+ const destinations: DestinationControls = {
123
+ consult: [],
124
+ transfer: [],
125
+ };
126
+
127
+ if (destinationConfig.accessBuddyTeam?.toUpperCase() !== COLLABORATION_ACCESS.NONE) {
128
+ destinations.consult.push(CONSULT_TRANSFER_DESTINATION_TYPE.AGENT);
129
+ destinations.transfer.push(CONSULT_TRANSFER_DESTINATION_TYPE.AGENT);
130
+ }
131
+
132
+ if (destinationConfig.accessQueue?.toUpperCase() !== COLLABORATION_ACCESS.NONE) {
133
+ const canConsultQueue = !isVoice || destinationConfig.allowConsultToQueue;
134
+ const canTransferQueue =
135
+ !isVoice ||
136
+ direction === INBOUND_DIRECTION ||
137
+ (direction === OUTDIAL_DIRECTION &&
138
+ interaction?.callProcessingDetails?.outdialTransferToQueueEnabled === true);
139
+
140
+ if (canConsultQueue) destinations.consult.push(CONSULT_TRANSFER_DESTINATION_TYPE.QUEUE);
141
+ if (canTransferQueue) destinations.transfer.push(CONSULT_TRANSFER_DESTINATION_TYPE.QUEUE);
142
+ }
143
+
144
+ if (isVoice) {
145
+ destinations.consult.push(CONSULT_TRANSFER_DESTINATION_TYPE.DIALNUMBER);
146
+ destinations.transfer.push(CONSULT_TRANSFER_DESTINATION_TYPE.DIALNUMBER);
147
+
148
+ if (destinationConfig.accessEntryPoint?.toUpperCase() !== COLLABORATION_ACCESS.NONE) {
149
+ destinations.consult.push(CONSULT_TRANSFER_DESTINATION_TYPE.ENTRYPOINT);
150
+ destinations.transfer.push(CONSULT_TRANSFER_DESTINATION_TYPE.ENTRYPOINT);
151
+ }
152
+ }
153
+
154
+ return destinations;
155
+ }
156
+
69
157
  /** Consult media must exist on the interaction payload, not only as a stale resource id. */
70
158
  function hasConsultMediaInInteraction(
71
159
  interaction: TaskData['interaction'] | undefined,
@@ -134,6 +222,23 @@ function computeVoiceInteractionUIControls(
134
222
  interaction && mainCallId ? getConferenceParticipantsCount(interaction, mainCallId) : 0;
135
223
  const maxParticipants = participantCount >= MAX_PARTICIPANTS_IN_MULTIPARTY_CONFERENCE;
136
224
  const selfAgentId = config.agentId ?? taskData?.agentId;
225
+ const enableWxBetterTogether = config.enableWxBetterTogether ?? false;
226
+ const wxAppDeviceDetails = enableWxBetterTogether
227
+ ? getWebexCallingDeviceDetailsForAgent(selfAgentId, interaction?.participants)
228
+ : undefined;
229
+ const isWxAppParticipant = enableWxBetterTogether && wxAppDeviceDetails?.deviceType === 'wxApp';
230
+ const isWxAppOffer =
231
+ isWxAppParticipant && Boolean(wxAppDeviceDetails) && state === TaskState.OFFERED;
232
+ const isWxAppInboundOffer = isWxAppOffer && !isOutdial;
233
+ const isWxAppOutdialOffer = isWxAppOffer && isOutdial;
234
+ const wxAppAnswerPending = config.wxAppAnswerPending ?? false;
235
+ const wxAppAcceptInFlight = config.wxAppAcceptInFlight ?? false;
236
+ const isWxAppEngaged = isWxAppEngagedForControls(
237
+ enableWxBetterTogether,
238
+ selfAgentId,
239
+ interaction?.participants,
240
+ state
241
+ );
137
242
  const consultInProgress = getIsConsultInProgressForConferenceControls(
138
243
  interaction,
139
244
  mainCallId,
@@ -376,37 +481,52 @@ function computeVoiceInteractionUIControls(
376
481
  ? VISIBLE_ENABLED
377
482
  : DISABLED;
378
483
 
379
- return {
380
- ...getDefaultInteractionUIControls(),
381
- hold: VISIBLE_ENABLED,
382
- transfer: VISIBLE_ENABLED,
383
- consult: VISIBLE_ENABLED,
384
- recording: recordingControl,
385
- end: VISIBLE_DISABLED,
386
- };
484
+ return withWxAppTelephonyControls(
485
+ {
486
+ ...getDefaultInteractionUIControls(),
487
+ hold: VISIBLE_ENABLED,
488
+ transfer: VISIBLE_ENABLED,
489
+ consult: VISIBLE_ENABLED,
490
+ recording: recordingControl,
491
+ end: VISIBLE_DISABLED,
492
+ },
493
+ isWxAppEngaged,
494
+ currentLeg,
495
+ isWrappingUp
496
+ );
387
497
  }
388
498
 
389
499
  if (isConsultRequestedPhase && !isEpDnPendingConferenceMergeUi) {
390
500
  if (currentLeg === 'main') {
391
- return {
392
- ...getDefaultInteractionUIControls(),
393
- transfer: shouldHideBlindTransferForEpDnPendingConferenceMerge
394
- ? DISABLED
395
- : VISIBLE_DISABLED,
396
- conference: VISIBLE_DISABLED,
397
- end: VISIBLE_DISABLED,
398
- };
501
+ return withWxAppTelephonyControls(
502
+ {
503
+ ...getDefaultInteractionUIControls(),
504
+ transfer: shouldHideBlindTransferForEpDnPendingConferenceMerge
505
+ ? DISABLED
506
+ : VISIBLE_DISABLED,
507
+ conference: VISIBLE_DISABLED,
508
+ end: VISIBLE_DISABLED,
509
+ },
510
+ isWxAppEngaged,
511
+ currentLeg,
512
+ isWrappingUp
513
+ );
399
514
  }
400
515
 
401
516
  if (currentLeg === 'consult') {
402
- return {
403
- ...getDefaultInteractionUIControls(),
404
- endConsult: VISIBLE_ENABLED,
405
- switch: VISIBLE_DISABLED,
406
- transfer: VISIBLE_DISABLED,
407
- transferConference: inConference ? VISIBLE_DISABLED : DISABLED,
408
- mergeToConference: VISIBLE_DISABLED,
409
- };
517
+ return withWxAppTelephonyControls(
518
+ {
519
+ ...getDefaultInteractionUIControls(),
520
+ endConsult: VISIBLE_ENABLED,
521
+ switch: VISIBLE_DISABLED,
522
+ transfer: VISIBLE_DISABLED,
523
+ transferConference: inConference ? VISIBLE_DISABLED : DISABLED,
524
+ mergeToConference: VISIBLE_DISABLED,
525
+ },
526
+ isWxAppEngaged,
527
+ currentLeg,
528
+ isWrappingUp
529
+ );
410
530
  }
411
531
  }
412
532
 
@@ -415,11 +535,24 @@ function computeVoiceInteractionUIControls(
415
535
  // Desktop/WebRTC + inbound: accept enabled (agent manually accepts)
416
536
  // Desktop/WebRTC + outdial: accept disabled (auto-answer handles it; Widgets show "Accept" disabled)
417
537
  // Extension mode (non-WebRTC): accept disabled (Widgets show "Ringing...")
418
- accept:
419
- state === TaskState.OFFERED && !interaction?.isTerminated
420
- ? {isVisible: true, isEnabled: isWebrtc && !isOutdial}
421
- : DISABLED,
538
+ accept: (() => {
539
+ if (isWxAppInboundOffer) {
540
+ return wxAppAcceptInFlight || wxAppAnswerPending ? VISIBLE_DISABLED : VISIBLE_ENABLED;
541
+ }
542
+ if (isWxAppOutdialOffer) {
543
+ return wxAppAcceptInFlight || wxAppAnswerPending ? VISIBLE_DISABLED : VISIBLE_ENABLED;
544
+ }
545
+ if (state === TaskState.OFFERED && !interaction?.isTerminated) {
546
+ return {isVisible: true, isEnabled: isWebrtc && !isOutdial};
547
+ }
548
+
549
+ return DISABLED;
550
+ })(),
422
551
  decline: (() => {
552
+ if (wxAppAcceptInFlight) return VISIBLE_DISABLED;
553
+ if (wxAppAnswerPending && isWxAppInboundOffer) return VISIBLE_DISABLED;
554
+ if (isWxAppInboundOffer) return VISIBLE_ENABLED;
555
+ if (isWxAppOutdialOffer) return VISIBLE_ENABLED;
423
556
  if (!isWebrtc || state !== TaskState.OFFERED || interaction?.isTerminated) return DISABLED;
424
557
 
425
558
  return isOutdial ? VISIBLE_DISABLED : VISIBLE_ENABLED;
@@ -447,8 +580,11 @@ function computeVoiceInteractionUIControls(
447
580
  return canHold ? VISIBLE_ENABLED : VISIBLE_DISABLED;
448
581
  })(),
449
582
 
450
- // Mute: WebRTC only, active calls; hidden entirely during wrapup
583
+ // Mute: WebRTC or wxApp engaged calls; hidden entirely during wrapup
451
584
  mute: (() => {
585
+ if (isWxAppEngaged && !isWrappingUp) {
586
+ return currentLeg === 'main' ? VISIBLE_ENABLED : DISABLED;
587
+ }
452
588
  if (!isWebrtc) return DISABLED;
453
589
  if (isWrappingUp) return DISABLED;
454
590
  if (isEpDnPostCallCustomerLeft && inConference) return VISIBLE_DISABLED;
@@ -712,6 +848,14 @@ function computeVoiceInteractionUIControls(
712
848
 
713
849
  return DISABLED;
714
850
  })(),
851
+
852
+ keypad: (() => {
853
+ if (isWxAppEngaged && !isWrappingUp) {
854
+ return currentLeg === 'main' ? VISIBLE_ENABLED : DISABLED;
855
+ }
856
+
857
+ return DISABLED;
858
+ })(),
715
859
  };
716
860
  }
717
861
 
@@ -743,6 +887,7 @@ function computeDigitalInteractionUIControls(
743
887
  transferConference: DISABLED,
744
888
  mergeToConference: DISABLED,
745
889
  switch: DISABLED,
890
+ keypad: DISABLED,
746
891
  };
747
892
  }
748
893
 
@@ -896,6 +1041,11 @@ export function computeUIControls(
896
1041
  return getDefaultUIControls();
897
1042
  }
898
1043
 
1044
+ const consultTransferDestinations = getConsultTransferDestinations(
1045
+ context.uiControlConfig,
1046
+ fallbackTaskData ?? context.taskData
1047
+ );
1048
+
899
1049
  switch (context.uiControlConfig.channelType) {
900
1050
  case TASK_CHANNEL_TYPE.VOICE: {
901
1051
  const {hasConsultLeg, activeLeg, mainState, consultState} = getVoiceLegState(
@@ -922,13 +1072,19 @@ export function computeUIControls(
922
1072
  )
923
1073
  : getDefaultInteractionUIControls();
924
1074
 
925
- return createTaskUIControls(mainControls, consultControls, activeLeg);
1075
+ return createTaskUIControls(
1076
+ mainControls,
1077
+ consultControls,
1078
+ activeLeg,
1079
+ consultTransferDestinations
1080
+ );
926
1081
  }
927
1082
  case TASK_CHANNEL_TYPE.DIGITAL:
928
1083
  return createTaskUIControls(
929
1084
  computeDigitalInteractionUIControls(currentState, context, fallbackTaskData),
930
1085
  getDefaultInteractionUIControls(),
931
- 'main'
1086
+ 'main',
1087
+ consultTransferDestinations
932
1088
  );
933
1089
  default:
934
1090
  return getDefaultUIControls();
@@ -947,6 +1103,16 @@ function haveInteractionUIControlsChanged(
947
1103
  });
948
1104
  }
949
1105
 
1106
+ function haveDestinationListChanged(
1107
+ previous: DestinationControls['consult'],
1108
+ next: DestinationControls['consult']
1109
+ ): boolean {
1110
+ return (
1111
+ previous.length !== next.length ||
1112
+ previous.some((destination, index) => destination !== next[index])
1113
+ );
1114
+ }
1115
+
950
1116
  export function haveUIControlsChanged(
951
1117
  previous: TaskUIControls | undefined,
952
1118
  next: TaskUIControls
@@ -955,6 +1121,14 @@ export function haveUIControlsChanged(
955
1121
 
956
1122
  return (
957
1123
  previous.activeLeg !== next.activeLeg ||
1124
+ haveDestinationListChanged(
1125
+ previous.consultTransferDestinations.consult,
1126
+ next.consultTransferDestinations.consult
1127
+ ) ||
1128
+ haveDestinationListChanged(
1129
+ previous.consultTransferDestinations.transfer,
1130
+ next.consultTransferDestinations.transfer
1131
+ ) ||
958
1132
  haveInteractionUIControlsChanged(previous.main, next.main) ||
959
1133
  haveInteractionUIControlsChanged(previous.consult, next.consult)
960
1134
  );