@webex/contact-center 3.12.0-llmrefactor.2 → 3.12.0-llmrefactor.3

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 (187) hide show
  1. package/.sdd/manifest.json +5 -4
  2. package/ai-docs/ARCHITECTURE.md +1 -1
  3. package/ai-docs/CONTRACTS.md +5 -1
  4. package/ai-docs/SECURITY.md +1 -1
  5. package/ai-docs/contact-center-spec.md +22 -4
  6. package/ai-docs/features/consult-transfer-list-policy/spec/feature-spec.md +362 -0
  7. package/dist/cc.js +440 -10
  8. package/dist/cc.js.map +1 -1
  9. package/dist/config.js +7 -0
  10. package/dist/config.js.map +1 -1
  11. package/dist/constants.js +10 -2
  12. package/dist/constants.js.map +1 -1
  13. package/dist/index.js.map +1 -1
  14. package/dist/metrics/behavioral-events.js +13 -0
  15. package/dist/metrics/behavioral-events.js.map +1 -1
  16. package/dist/metrics/constants.js +2 -0
  17. package/dist/metrics/constants.js.map +1 -1
  18. package/dist/services/AddressBook.js +18 -15
  19. package/dist/services/AddressBook.js.map +1 -1
  20. package/dist/services/AnswerCallOnWebexService.js +174 -0
  21. package/dist/services/AnswerCallOnWebexService.js.map +1 -0
  22. package/dist/services/EntryPoint.js +46 -68
  23. package/dist/services/EntryPoint.js.map +1 -1
  24. package/dist/services/Queue.js +27 -22
  25. package/dist/services/Queue.js.map +1 -1
  26. package/dist/services/WebexCrossClientService.js +171 -0
  27. package/dist/services/WebexCrossClientService.js.map +1 -0
  28. package/dist/services/WxAppTelephonyMercurySync.js +93 -0
  29. package/dist/services/WxAppTelephonyMercurySync.js.map +1 -0
  30. package/dist/services/config/Util.js +3 -0
  31. package/dist/services/config/Util.js.map +1 -1
  32. package/dist/services/config/constants.js +10 -6
  33. package/dist/services/config/constants.js.map +1 -1
  34. package/dist/services/config/types.js +4 -0
  35. package/dist/services/config/types.js.map +1 -1
  36. package/dist/services/core/Err.js.map +1 -1
  37. package/dist/services/core/WebexRequest.js +6 -2
  38. package/dist/services/core/WebexRequest.js.map +1 -1
  39. package/dist/services/core/aqm-reqs.js +28 -14
  40. package/dist/services/core/aqm-reqs.js.map +1 -1
  41. package/dist/services/core/types.js.map +1 -1
  42. package/dist/services/task/Task.js +73 -7
  43. package/dist/services/task/Task.js.map +1 -1
  44. package/dist/services/task/TaskFactory.js +8 -4
  45. package/dist/services/task/TaskFactory.js.map +1 -1
  46. package/dist/services/task/TaskManager.js +176 -20
  47. package/dist/services/task/TaskManager.js.map +1 -1
  48. package/dist/services/task/WebexCallingUtils.js +70 -0
  49. package/dist/services/task/WebexCallingUtils.js.map +1 -0
  50. package/dist/services/task/constants.js +4 -1
  51. package/dist/services/task/constants.js.map +1 -1
  52. package/dist/services/task/contact.js +29 -0
  53. package/dist/services/task/contact.js.map +1 -1
  54. package/dist/services/task/digital/Digital.js +3 -2
  55. package/dist/services/task/digital/Digital.js.map +1 -1
  56. package/dist/services/task/state-machine/TaskStateMachine.js +135 -37
  57. package/dist/services/task/state-machine/TaskStateMachine.js.map +1 -1
  58. package/dist/services/task/state-machine/actions.js +6 -1
  59. package/dist/services/task/state-machine/actions.js.map +1 -1
  60. package/dist/services/task/state-machine/guards.js +38 -11
  61. package/dist/services/task/state-machine/guards.js.map +1 -1
  62. package/dist/services/task/state-machine/types.js.map +1 -1
  63. package/dist/services/task/state-machine/uiControlsComputer.js +118 -18
  64. package/dist/services/task/state-machine/uiControlsComputer.js.map +1 -1
  65. package/dist/services/task/types.js +16 -1
  66. package/dist/services/task/types.js.map +1 -1
  67. package/dist/services/task/voice/Voice.js +350 -14
  68. package/dist/services/task/voice/Voice.js.map +1 -1
  69. package/dist/services/task/voice/WebRTC.js +4 -1
  70. package/dist/services/task/voice/WebRTC.js.map +1 -1
  71. package/dist/services/task/voice/wxAppVoiceMethods.js +201 -0
  72. package/dist/services/task/voice/wxAppVoiceMethods.js.map +1 -0
  73. package/dist/services/wxAppTelephonyUtils.js +19 -0
  74. package/dist/services/wxAppTelephonyUtils.js.map +1 -0
  75. package/dist/types/cc.d.ts +77 -4
  76. package/dist/types/config.d.ts +7 -0
  77. package/dist/types/constants.d.ts +8 -0
  78. package/dist/types/index.d.ts +3 -1
  79. package/dist/types/metrics/constants.d.ts +2 -0
  80. package/dist/types/services/AddressBook.d.ts +2 -1
  81. package/dist/types/services/AnswerCallOnWebexService.d.ts +37 -0
  82. package/dist/types/services/EntryPoint.d.ts +7 -5
  83. package/dist/types/services/Queue.d.ts +5 -3
  84. package/dist/types/services/WebexCrossClientService.d.ts +28 -0
  85. package/dist/types/services/WxAppTelephonyMercurySync.d.ts +28 -0
  86. package/dist/types/services/config/constants.d.ts +8 -5
  87. package/dist/types/services/config/types.d.ts +17 -4
  88. package/dist/types/services/core/Err.d.ts +2 -0
  89. package/dist/types/services/core/WebexRequest.d.ts +1 -0
  90. package/dist/types/services/core/types.d.ts +2 -0
  91. package/dist/types/services/task/Task.d.ts +20 -2
  92. package/dist/types/services/task/TaskFactory.d.ts +2 -1
  93. package/dist/types/services/task/WebexCallingUtils.d.ts +11 -0
  94. package/dist/types/services/task/constants.d.ts +3 -0
  95. package/dist/types/services/task/contact.d.ts +4 -0
  96. package/dist/types/services/task/digital/Digital.d.ts +2 -2
  97. package/dist/types/services/task/state-machine/TaskStateMachine.d.ts +260 -56
  98. package/dist/types/services/task/state-machine/guards.d.ts +6 -5
  99. package/dist/types/services/task/state-machine/types.d.ts +9 -1
  100. package/dist/types/services/task/types.d.ts +81 -4
  101. package/dist/types/services/task/voice/Voice.d.ts +48 -9
  102. package/dist/types/services/task/voice/WebRTC.d.ts +2 -2
  103. package/dist/types/services/task/voice/wxAppVoiceMethods.d.ts +52 -0
  104. package/dist/types/services/wxAppTelephonyUtils.d.ts +5 -0
  105. package/dist/types/types.d.ts +14 -8
  106. package/dist/types/utils/PageCache.d.ts +20 -3
  107. package/dist/types.js +7 -2
  108. package/dist/types.js.map +1 -1
  109. package/dist/utils/PageCache.js +19 -5
  110. package/dist/utils/PageCache.js.map +1 -1
  111. package/dist/webex.js +1 -1
  112. package/package.json +1 -1
  113. package/src/cc.ts +506 -9
  114. package/src/config.ts +7 -0
  115. package/src/constants.ts +8 -0
  116. package/src/index.ts +2 -0
  117. package/src/metrics/ai-docs/metrics-spec.md +9 -3
  118. package/src/metrics/behavioral-events.ts +14 -0
  119. package/src/metrics/constants.ts +2 -0
  120. package/src/services/AddressBook.ts +17 -6
  121. package/src/services/AnswerCallOnWebexService.ts +206 -0
  122. package/src/services/EntryPoint.ts +59 -60
  123. package/src/services/Queue.ts +29 -12
  124. package/src/services/WebexCrossClientService.ts +212 -0
  125. package/src/services/WxAppTelephonyMercurySync.ts +115 -0
  126. package/src/services/ai-docs/AGENTS.md +10 -10
  127. package/src/services/ai-docs/services-spec.md +6 -1
  128. package/src/services/config/Util.ts +3 -0
  129. package/src/services/config/ai-docs/AGENTS.md +1 -1
  130. package/src/services/config/ai-docs/ARCHITECTURE.md +2 -2
  131. package/src/services/config/ai-docs/config-spec.md +6 -0
  132. package/src/services/config/constants.ts +10 -6
  133. package/src/services/config/types.ts +16 -4
  134. package/src/services/core/Err.ts +1 -0
  135. package/src/services/core/WebexRequest.ts +3 -1
  136. package/src/services/core/ai-docs/core-spec.md +5 -1
  137. package/src/services/core/aqm-reqs.ts +30 -15
  138. package/src/services/core/types.ts +2 -0
  139. package/src/services/task/Task.ts +79 -8
  140. package/src/services/task/TaskFactory.ts +8 -3
  141. package/src/services/task/TaskManager.ts +254 -15
  142. package/src/services/task/WebexCallingUtils.ts +136 -0
  143. package/src/services/task/ai-docs/ARCHITECTURE.md +1 -0
  144. package/src/services/task/ai-docs/task-spec.md +117 -2
  145. package/src/services/task/constants.ts +3 -0
  146. package/src/services/task/contact.ts +30 -0
  147. package/src/services/task/digital/Digital.ts +4 -2
  148. package/src/services/task/state-machine/TaskStateMachine.ts +210 -63
  149. package/src/services/task/state-machine/actions.ts +5 -2
  150. package/src/services/task/state-machine/ai-docs/AGENTS.md +8 -4
  151. package/src/services/task/state-machine/ai-docs/ARCHITECTURE.md +17 -8
  152. package/src/services/task/state-machine/ai-docs/task-state-machine-spec.md +46 -22
  153. package/src/services/task/state-machine/guards.ts +64 -11
  154. package/src/services/task/state-machine/types.ts +16 -1
  155. package/src/services/task/state-machine/uiControlsComputer.ts +206 -32
  156. package/src/services/task/types.ts +114 -4
  157. package/src/services/task/voice/Voice.ts +462 -12
  158. package/src/services/task/voice/WebRTC.ts +5 -1
  159. package/src/services/task/voice/wxAppVoiceMethods.ts +307 -0
  160. package/src/services/wxAppTelephonyUtils.ts +14 -0
  161. package/src/types.ts +33 -9
  162. package/src/utils/AGENTS.md +21 -10
  163. package/src/utils/PageCache.ts +38 -5
  164. package/src/utils/ai-docs/utils-spec.md +21 -11
  165. package/test/unit/spec/cc.ts +1274 -0
  166. package/test/unit/spec/metrics/behavioral-events.ts +18 -0
  167. package/test/unit/spec/services/AddressBook.ts +37 -6
  168. package/test/unit/spec/services/AnswerCallOnWebexService.ts +223 -0
  169. package/test/unit/spec/services/EntryPoint.ts +87 -40
  170. package/test/unit/spec/services/Queue.ts +123 -12
  171. package/test/unit/spec/services/WebexCrossClientService.ts +261 -0
  172. package/test/unit/spec/services/WxAppTelephonyMercurySync.ts +113 -0
  173. package/test/unit/spec/services/config/Util.ts +85 -0
  174. package/test/unit/spec/services/core/WebexRequest.ts +3 -1
  175. package/test/unit/spec/services/core/aqm-reqs.ts +113 -1
  176. package/test/unit/spec/services/task/Task.ts +200 -0
  177. package/test/unit/spec/services/task/TaskFactory.ts +39 -2
  178. package/test/unit/spec/services/task/TaskManager.ts +653 -1
  179. package/test/unit/spec/services/task/WebexCallingUtils.ts +153 -0
  180. package/test/unit/spec/services/task/contact.ts +33 -0
  181. package/test/unit/spec/services/task/state-machine/TaskStateMachine.ts +854 -72
  182. package/test/unit/spec/services/task/state-machine/guards.ts +210 -8
  183. package/test/unit/spec/services/task/state-machine/uiControlsComputer.ts +445 -7
  184. package/test/unit/spec/services/task/voice/Voice.ts +874 -0
  185. package/test/unit/spec/services/task/voice/wxAppVoiceMethods.ts +459 -0
  186. package/umd/contact-center.min.js +2 -2
  187. package/umd/contact-center.min.js.map +1 -1
@@ -0,0 +1,201 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.acceptOnWebex = acceptOnWebex;
7
+ exports.getCallingDeviceDetails = getCallingDeviceDetails;
8
+ exports.getWebexCallingCallId = getWebexCallingCallId;
9
+ exports.getWxAppLineOwnerId = getWxAppLineOwnerId;
10
+ exports.isWebexAppCallingOffer = isWebexAppCallingOffer;
11
+ exports.isWebexAppInboundCallingOffer = isWebexAppInboundCallingOffer;
12
+ exports.mapWxAppVoiceError = mapWxAppVoiceError;
13
+ exports.rejectOnWebex = rejectOnWebex;
14
+ exports.resolveWxAppLineOwnerId = resolveWxAppLineOwnerId;
15
+ exports.runWxAppAccept = runWxAppAccept;
16
+ exports.runWxAppReject = runWxAppReject;
17
+ exports.runWxAppToggleMute = runWxAppToggleMute;
18
+ exports.runWxAppTransmitDtmf = runWxAppTransmitDtmf;
19
+ exports.toggleMuteOnWebex = toggleMuteOnWebex;
20
+ exports.transmitDtmfOnWebex = transmitDtmfOnWebex;
21
+ var _loggerProxy = _interopRequireDefault(require("../../../logger-proxy"));
22
+ var _constants = require("../../../constants");
23
+ var _Utils = require("../../core/Utils");
24
+ var _stateMachine = require("../state-machine");
25
+ var _WebexCallingUtils = require("../WebexCallingUtils");
26
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
27
+ /** @deprecated Use {@link WxAppVoiceDependencies} */
28
+
29
+ const isWxAppParticipant = participant => participant?.deviceType === 'wxApp' && typeof participant?.deviceCallId === 'string' && participant.deviceCallId.trim() !== '' && typeof participant?.deviceId === 'string' && participant.deviceId.trim() !== '';
30
+ const isOutdialTask = deps => deps.getTaskData()?.interaction?.outboundType === 'OUTDIAL';
31
+ function getWxAppAgentParticipant(deps) {
32
+ const taskData = deps.getTaskData();
33
+ const participants = taskData.interaction?.participants;
34
+ const agentId = deps.agentId ?? taskData.agentId;
35
+ if (!participants || !agentId) {
36
+ return undefined;
37
+ }
38
+ if (participants[agentId]) {
39
+ return participants[agentId];
40
+ }
41
+ return Object.values(participants).find(participant => participant?.id === agentId);
42
+ }
43
+ function getCallingDeviceDetails(deps) {
44
+ const taskData = deps.getTaskData();
45
+ const participant = getWxAppAgentParticipant(deps);
46
+ if (!isWxAppParticipant(participant)) {
47
+ return undefined;
48
+ }
49
+ return (0, _WebexCallingUtils.getWebexCallingDeviceDetailsForAgent)(deps.agentId ?? taskData.agentId, taskData.interaction?.participants);
50
+ }
51
+ function isWebexAppCallingOffer(deps) {
52
+ if (!deps.enableWxBetterTogether) {
53
+ return false;
54
+ }
55
+ const state = deps.getTaskState();
56
+ if (state !== _stateMachine.TaskState.OFFERED) {
57
+ return false;
58
+ }
59
+ const details = getCallingDeviceDetails(deps);
60
+ return Boolean(details);
61
+ }
62
+
63
+ /** Inbound wxApp offer only — outdial decline uses CC routing, not telephony reject. */
64
+ function isWebexAppInboundCallingOffer(deps) {
65
+ return isWebexAppCallingOffer(deps) && !isOutdialTask(deps);
66
+ }
67
+ function getWebexCallingCallId(deps) {
68
+ const state = deps.getTaskState();
69
+ if (!state || state === _stateMachine.TaskState.OFFERED || state === _stateMachine.TaskState.IDLE || state === _stateMachine.TaskState.WRAPPING_UP || state === _stateMachine.TaskState.TERMINATED || state === _stateMachine.TaskState.COMPLETED) {
70
+ return null;
71
+ }
72
+ return getCallingDeviceDetails(deps)?.deviceCallId ?? null;
73
+ }
74
+ function getWxAppLineOwnerId(deps) {
75
+ const participant = getWxAppAgentParticipant(deps);
76
+ const lineOwnerId = participant?.lineOwnerId;
77
+ return typeof lineOwnerId === 'string' && lineOwnerId.trim() !== '' ? lineOwnerId : undefined;
78
+ }
79
+ function resolveWxAppLineOwnerId(deps, override) {
80
+ if (typeof override === 'string' && override.trim() !== '') {
81
+ return override;
82
+ }
83
+ return (0, _WebexCallingUtils.decodedLineOwnerId)(getWxAppLineOwnerId(deps));
84
+ }
85
+ function assertWxAppEnabled(deps) {
86
+ if (!deps.enableWxBetterTogether) {
87
+ throw new Error('enableWxBetterTogether is disabled');
88
+ }
89
+ if (!deps.answerCallOnWebexService) {
90
+ throw new Error('AnswerCallOnWebexService is unavailable');
91
+ }
92
+ }
93
+ async function acceptOnWebex(deps, options) {
94
+ assertWxAppEnabled(deps);
95
+ if (!isWebexAppCallingOffer(deps)) {
96
+ throw new Error('Task is not a wxApp calling offer');
97
+ }
98
+ const details = getCallingDeviceDetails(deps);
99
+ if (!details) {
100
+ throw new Error('WxApp calling device details are unavailable');
101
+ }
102
+ await deps.answerCallOnWebexService.answerCall({
103
+ callId: details.deviceCallId,
104
+ endpointId: details.deviceId,
105
+ lineOwnerId: resolveWxAppLineOwnerId(deps, options?.lineOwnerId)
106
+ });
107
+ }
108
+ async function rejectOnWebex(deps, options) {
109
+ assertWxAppEnabled(deps);
110
+ if (!isWebexAppInboundCallingOffer(deps)) {
111
+ throw new Error('Task is not a wxApp inbound calling offer');
112
+ }
113
+ const details = getCallingDeviceDetails(deps);
114
+ if (!details) {
115
+ throw new Error('WxApp calling device details are unavailable');
116
+ }
117
+ await deps.answerCallOnWebexService.rejectCall({
118
+ callId: details.deviceCallId,
119
+ lineOwnerId: resolveWxAppLineOwnerId(deps, options?.lineOwnerId)
120
+ });
121
+ }
122
+ async function toggleMuteOnWebex(deps, options) {
123
+ assertWxAppEnabled(deps);
124
+ const callId = getWebexCallingCallId(deps);
125
+ if (!callId) {
126
+ throw new Error('WxApp call ID is unavailable');
127
+ }
128
+ const targetMuted = options?.muted ?? !deps.getWxAppMuted();
129
+ const request = targetMuted ? deps.answerCallOnWebexService.muteCall.bind(deps.answerCallOnWebexService) : deps.answerCallOnWebexService.unmuteCall.bind(deps.answerCallOnWebexService);
130
+ await request({
131
+ callId,
132
+ lineOwnerId: resolveWxAppLineOwnerId(deps, options?.lineOwnerId)
133
+ });
134
+ deps.setWxAppMuted(targetMuted);
135
+ }
136
+ async function transmitDtmfOnWebex(deps, options) {
137
+ assertWxAppEnabled(deps);
138
+ const callId = getWebexCallingCallId(deps);
139
+ if (!callId) {
140
+ throw new Error('WxApp call ID is unavailable');
141
+ }
142
+ _loggerProxy.default.info('transmitDtmf', {
143
+ module: 'wxAppVoiceMethods',
144
+ method: _constants.METHODS.TRANSMIT_DTMF,
145
+ data: {
146
+ callId,
147
+ dtmfLength: options.dtmf.length,
148
+ hasLineOwnerId: Boolean(options.lineOwnerId)
149
+ }
150
+ });
151
+ await deps.answerCallOnWebexService.transmitDtmf({
152
+ callId,
153
+ dtmf: options.dtmf,
154
+ lineOwnerId: resolveWxAppLineOwnerId(deps, options.lineOwnerId)
155
+ });
156
+ }
157
+ async function runWxAppAccept(deps, lifecycle, options) {
158
+ try {
159
+ lifecycle.setWxAppAcceptInFlight(true);
160
+ lifecycle.setWxAppAnswerPending(true);
161
+ await acceptOnWebex(deps, options);
162
+ lifecycle.resetWxAppMuted();
163
+ await lifecycle.syncWxAppMuteFromCallDetails();
164
+ } catch (error) {
165
+ lifecycle.setWxAppAnswerPending(false);
166
+ lifecycle.mapWxAppVoiceError(error, _constants.METHODS.ACCEPT);
167
+ } finally {
168
+ lifecycle.setWxAppAcceptInFlight(false);
169
+ }
170
+ }
171
+ async function runWxAppReject(deps, lifecycle, options) {
172
+ try {
173
+ await rejectOnWebex(deps, options);
174
+ } catch (error) {
175
+ lifecycle.mapWxAppVoiceError(error, _constants.METHODS.REJECT);
176
+ }
177
+ }
178
+ async function runWxAppToggleMute(deps, lifecycle, options) {
179
+ try {
180
+ await toggleMuteOnWebex(deps, options);
181
+ } catch (error) {
182
+ lifecycle.mapWxAppVoiceError(error, _constants.METHODS.TOGGLE_MUTE);
183
+ }
184
+ }
185
+ async function runWxAppTransmitDtmf(deps, lifecycle, options) {
186
+ try {
187
+ await transmitDtmfOnWebex(deps, options);
188
+ } catch (error) {
189
+ lifecycle.mapWxAppVoiceError(error, _constants.METHODS.TRANSMIT_DTMF);
190
+ }
191
+ }
192
+ function mapWxAppVoiceError(error, method, module) {
193
+ if (error instanceof Error && error.isWxAppTelephonyError) {
194
+ throw error;
195
+ }
196
+ const {
197
+ error: detailedError
198
+ } = (0, _Utils.getErrorDetails)(error, method, module);
199
+ throw detailedError;
200
+ }
201
+ //# sourceMappingURL=wxAppVoiceMethods.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_loggerProxy","_interopRequireDefault","require","_constants","_Utils","_stateMachine","_WebexCallingUtils","e","__esModule","default","isWxAppParticipant","participant","deviceType","deviceCallId","trim","deviceId","isOutdialTask","deps","getTaskData","interaction","outboundType","getWxAppAgentParticipant","taskData","participants","agentId","undefined","Object","values","find","id","getCallingDeviceDetails","getWebexCallingDeviceDetailsForAgent","isWebexAppCallingOffer","enableWxBetterTogether","state","getTaskState","TaskState","OFFERED","details","Boolean","isWebexAppInboundCallingOffer","getWebexCallingCallId","IDLE","WRAPPING_UP","TERMINATED","COMPLETED","getWxAppLineOwnerId","lineOwnerId","resolveWxAppLineOwnerId","override","decodedLineOwnerId","assertWxAppEnabled","Error","answerCallOnWebexService","acceptOnWebex","options","answerCall","callId","endpointId","rejectOnWebex","rejectCall","toggleMuteOnWebex","targetMuted","muted","getWxAppMuted","request","muteCall","bind","unmuteCall","setWxAppMuted","transmitDtmfOnWebex","LoggerProxy","info","module","method","METHODS","TRANSMIT_DTMF","data","dtmfLength","dtmf","length","hasLineOwnerId","transmitDtmf","runWxAppAccept","lifecycle","setWxAppAcceptInFlight","setWxAppAnswerPending","resetWxAppMuted","syncWxAppMuteFromCallDetails","error","mapWxAppVoiceError","ACCEPT","runWxAppReject","REJECT","runWxAppToggleMute","TOGGLE_MUTE","runWxAppTransmitDtmf","isWxAppTelephonyError","detailedError","getErrorDetails"],"sources":["wxAppVoiceMethods.ts"],"sourcesContent":["import AnswerCallOnWebexService from '../../AnswerCallOnWebexService';\nimport LoggerProxy from '../../../logger-proxy';\nimport {METHODS} from '../../../constants';\nimport {getErrorDetails} from '../../core/Utils';\nimport {TaskData, TaskToggleMuteOptions, TaskTransmitDtmfOptions} from '../types';\nimport {TaskState} from '../state-machine';\nimport {\n decodedLineOwnerId,\n getWebexCallingDeviceDetailsForAgent,\n WebexCallingDeviceDetails,\n} from '../WebexCallingUtils';\n\ntype WxAppParticipant = {\n deviceType?: string;\n deviceCallId?: string;\n deviceId?: string;\n};\n\nexport type WxAppVoiceDependencies = {\n enableWxBetterTogether: boolean;\n answerCallOnWebexService?: AnswerCallOnWebexService;\n agentId?: string;\n getTaskData: () => TaskData;\n getTaskState: () => TaskState | undefined;\n getWxAppMuted: () => boolean;\n setWxAppMuted: (muted: boolean) => void;\n};\n\n/** @deprecated Use {@link WxAppVoiceDependencies} */\nexport type WxAppVoiceDeps = WxAppVoiceDependencies;\n\nexport type WxAppVoiceLifecycle = {\n setWxAppAcceptInFlight: (inFlight: boolean) => void;\n setWxAppAnswerPending: (pending: boolean) => void;\n resetWxAppMuted: () => void;\n syncWxAppMuteFromCallDetails: () => Promise<boolean | undefined>;\n mapWxAppVoiceError: (error: unknown, method: string) => never;\n};\n\nconst isWxAppParticipant = (participant: unknown): participant is WxAppParticipant =>\n (participant as WxAppParticipant)?.deviceType === 'wxApp' &&\n typeof (participant as WxAppParticipant)?.deviceCallId === 'string' &&\n (participant as WxAppParticipant).deviceCallId.trim() !== '' &&\n typeof (participant as WxAppParticipant)?.deviceId === 'string' &&\n (participant as WxAppParticipant).deviceId.trim() !== '';\n\nconst isOutdialTask = (deps: WxAppVoiceDependencies): boolean =>\n deps.getTaskData()?.interaction?.outboundType === 'OUTDIAL';\n\nfunction getWxAppAgentParticipant(deps: WxAppVoiceDependencies): unknown {\n const taskData = deps.getTaskData();\n const participants = taskData.interaction?.participants;\n const agentId = deps.agentId ?? taskData.agentId;\n\n if (!participants || !agentId) {\n return undefined;\n }\n\n if (participants[agentId]) {\n return participants[agentId];\n }\n\n return Object.values(participants).find(\n (participant) => (participant as {id?: string})?.id === agentId\n );\n}\n\nexport function getCallingDeviceDetails(\n deps: WxAppVoiceDependencies\n): WebexCallingDeviceDetails | undefined {\n const taskData = deps.getTaskData();\n const participant = getWxAppAgentParticipant(deps);\n\n if (!isWxAppParticipant(participant)) {\n return undefined;\n }\n\n return getWebexCallingDeviceDetailsForAgent(\n deps.agentId ?? taskData.agentId,\n taskData.interaction?.participants\n );\n}\n\nexport function isWebexAppCallingOffer(deps: WxAppVoiceDependencies): boolean {\n if (!deps.enableWxBetterTogether) {\n return false;\n }\n\n const state = deps.getTaskState();\n if (state !== TaskState.OFFERED) {\n return false;\n }\n\n const details = getCallingDeviceDetails(deps);\n\n return Boolean(details);\n}\n\n/** Inbound wxApp offer only — outdial decline uses CC routing, not telephony reject. */\nexport function isWebexAppInboundCallingOffer(deps: WxAppVoiceDependencies): boolean {\n return isWebexAppCallingOffer(deps) && !isOutdialTask(deps);\n}\n\nexport function getWebexCallingCallId(deps: WxAppVoiceDependencies): string | null {\n const state = deps.getTaskState();\n if (\n !state ||\n state === TaskState.OFFERED ||\n state === TaskState.IDLE ||\n state === TaskState.WRAPPING_UP ||\n state === TaskState.TERMINATED ||\n state === TaskState.COMPLETED\n ) {\n return null;\n }\n\n return getCallingDeviceDetails(deps)?.deviceCallId ?? null;\n}\n\nexport function getWxAppLineOwnerId(deps: WxAppVoiceDependencies): string | undefined {\n const participant = getWxAppAgentParticipant(deps) as {lineOwnerId?: string} | undefined;\n const lineOwnerId = participant?.lineOwnerId;\n\n return typeof lineOwnerId === 'string' && lineOwnerId.trim() !== '' ? lineOwnerId : undefined;\n}\n\nexport function resolveWxAppLineOwnerId(\n deps: WxAppVoiceDependencies,\n override?: string\n): string | undefined {\n if (typeof override === 'string' && override.trim() !== '') {\n return override;\n }\n\n return decodedLineOwnerId(getWxAppLineOwnerId(deps));\n}\n\nfunction assertWxAppEnabled(deps: WxAppVoiceDependencies): void {\n if (!deps.enableWxBetterTogether) {\n throw new Error('enableWxBetterTogether is disabled');\n }\n\n if (!deps.answerCallOnWebexService) {\n throw new Error('AnswerCallOnWebexService is unavailable');\n }\n}\n\nexport async function acceptOnWebex(\n deps: WxAppVoiceDependencies,\n options?: {lineOwnerId?: string}\n): Promise<void> {\n assertWxAppEnabled(deps);\n\n if (!isWebexAppCallingOffer(deps)) {\n throw new Error('Task is not a wxApp calling offer');\n }\n\n const details = getCallingDeviceDetails(deps);\n if (!details) {\n throw new Error('WxApp calling device details are unavailable');\n }\n\n await deps.answerCallOnWebexService.answerCall({\n callId: details.deviceCallId,\n endpointId: details.deviceId,\n lineOwnerId: resolveWxAppLineOwnerId(deps, options?.lineOwnerId),\n });\n}\n\nexport async function rejectOnWebex(\n deps: WxAppVoiceDependencies,\n options?: {lineOwnerId?: string}\n): Promise<void> {\n assertWxAppEnabled(deps);\n\n if (!isWebexAppInboundCallingOffer(deps)) {\n throw new Error('Task is not a wxApp inbound calling offer');\n }\n\n const details = getCallingDeviceDetails(deps);\n if (!details) {\n throw new Error('WxApp calling device details are unavailable');\n }\n\n await deps.answerCallOnWebexService.rejectCall({\n callId: details.deviceCallId,\n lineOwnerId: resolveWxAppLineOwnerId(deps, options?.lineOwnerId),\n });\n}\n\nexport async function toggleMuteOnWebex(\n deps: WxAppVoiceDependencies,\n options?: {lineOwnerId?: string; muted?: boolean}\n): Promise<void> {\n assertWxAppEnabled(deps);\n\n const callId = getWebexCallingCallId(deps);\n if (!callId) {\n throw new Error('WxApp call ID is unavailable');\n }\n\n const targetMuted = options?.muted ?? !deps.getWxAppMuted();\n const request = targetMuted\n ? deps.answerCallOnWebexService.muteCall.bind(deps.answerCallOnWebexService)\n : deps.answerCallOnWebexService.unmuteCall.bind(deps.answerCallOnWebexService);\n\n await request({\n callId,\n lineOwnerId: resolveWxAppLineOwnerId(deps, options?.lineOwnerId),\n });\n deps.setWxAppMuted(targetMuted);\n}\n\nexport async function transmitDtmfOnWebex(\n deps: WxAppVoiceDependencies,\n options: {dtmf: string; lineOwnerId?: string}\n): Promise<void> {\n assertWxAppEnabled(deps);\n\n const callId = getWebexCallingCallId(deps);\n if (!callId) {\n throw new Error('WxApp call ID is unavailable');\n }\n\n LoggerProxy.info('transmitDtmf', {\n module: 'wxAppVoiceMethods',\n method: METHODS.TRANSMIT_DTMF,\n data: {\n callId,\n dtmfLength: options.dtmf.length,\n hasLineOwnerId: Boolean(options.lineOwnerId),\n },\n });\n\n await deps.answerCallOnWebexService.transmitDtmf({\n callId,\n dtmf: options.dtmf,\n lineOwnerId: resolveWxAppLineOwnerId(deps, options.lineOwnerId),\n });\n}\n\nexport async function runWxAppAccept(\n deps: WxAppVoiceDependencies,\n lifecycle: WxAppVoiceLifecycle,\n options?: {lineOwnerId?: string}\n): Promise<void> {\n try {\n lifecycle.setWxAppAcceptInFlight(true);\n lifecycle.setWxAppAnswerPending(true);\n await acceptOnWebex(deps, options);\n lifecycle.resetWxAppMuted();\n await lifecycle.syncWxAppMuteFromCallDetails();\n } catch (error) {\n lifecycle.setWxAppAnswerPending(false);\n lifecycle.mapWxAppVoiceError(error, METHODS.ACCEPT);\n } finally {\n lifecycle.setWxAppAcceptInFlight(false);\n }\n}\n\nexport async function runWxAppReject(\n deps: WxAppVoiceDependencies,\n lifecycle: WxAppVoiceLifecycle,\n options?: {lineOwnerId?: string}\n): Promise<void> {\n try {\n await rejectOnWebex(deps, options);\n } catch (error) {\n lifecycle.mapWxAppVoiceError(error, METHODS.REJECT);\n }\n}\n\nexport async function runWxAppToggleMute(\n deps: WxAppVoiceDependencies,\n lifecycle: WxAppVoiceLifecycle,\n options?: TaskToggleMuteOptions\n): Promise<void> {\n try {\n await toggleMuteOnWebex(deps, options);\n } catch (error) {\n lifecycle.mapWxAppVoiceError(error, METHODS.TOGGLE_MUTE);\n }\n}\n\nexport async function runWxAppTransmitDtmf(\n deps: WxAppVoiceDependencies,\n lifecycle: WxAppVoiceLifecycle,\n options: TaskTransmitDtmfOptions\n): Promise<void> {\n try {\n await transmitDtmfOnWebex(deps, options);\n } catch (error) {\n lifecycle.mapWxAppVoiceError(error, METHODS.TRANSMIT_DTMF);\n }\n}\n\nexport function mapWxAppVoiceError(error: unknown, method: string, module: string): never {\n if (\n error instanceof Error &&\n (error as Error & {isWxAppTelephonyError?: boolean}).isWxAppTelephonyError\n ) {\n throw error;\n }\n\n const {error: detailedError} = getErrorDetails(error, method, module);\n throw detailedError;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AACA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEA,IAAAG,aAAA,GAAAH,OAAA;AACA,IAAAI,kBAAA,GAAAJ,OAAA;AAI8B,SAAAD,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAkB9B;;AAWA,MAAMG,kBAAkB,GAAIC,WAAoB,IAC7CA,WAAW,EAAuBC,UAAU,KAAK,OAAO,IACzD,OAAQD,WAAW,EAAuBE,YAAY,KAAK,QAAQ,IAClEF,WAAW,CAAsBE,YAAY,CAACC,IAAI,CAAC,CAAC,KAAK,EAAE,IAC5D,OAAQH,WAAW,EAAuBI,QAAQ,KAAK,QAAQ,IAC9DJ,WAAW,CAAsBI,QAAQ,CAACD,IAAI,CAAC,CAAC,KAAK,EAAE;AAE1D,MAAME,aAAa,GAAIC,IAA4B,IACjDA,IAAI,CAACC,WAAW,CAAC,CAAC,EAAEC,WAAW,EAAEC,YAAY,KAAK,SAAS;AAE7D,SAASC,wBAAwBA,CAACJ,IAA4B,EAAW;EACvE,MAAMK,QAAQ,GAAGL,IAAI,CAACC,WAAW,CAAC,CAAC;EACnC,MAAMK,YAAY,GAAGD,QAAQ,CAACH,WAAW,EAAEI,YAAY;EACvD,MAAMC,OAAO,GAAGP,IAAI,CAACO,OAAO,IAAIF,QAAQ,CAACE,OAAO;EAEhD,IAAI,CAACD,YAAY,IAAI,CAACC,OAAO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C,aAAa,CAAC;EAC5D;AACF;AAEO,SAASc,kBAAkBA,CAACD,KAAc,EAAEf,MAAc,EAAED,MAAc,EAAS;EACxF,IACEgB,KAAK,YAAYrC,KAAK,IACrBqC,KAAK,CAA+CQ,qBAAqB,EAC1E;IACA,MAAMR,KAAK;EACb;EAEA,MAAM;IAACA,KAAK,EAAES;EAAa,CAAC,GAAG,IAAAC,sBAAe,EAACV,KAAK,EAAEf,MAAM,EAAED,MAAM,CAAC;EACrE,MAAMyB,aAAa;AACrB","ignoreList":[]}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isWxAppCallNotFoundError = isWxAppCallNotFoundError;
7
+ /**
8
+ * Expected Hydra responses when mute backfill races call creation (WXCC-6026).
9
+ * These must not be logged as errors — see task-spec wxApp mute backfill guard.
10
+ */
11
+ function isWxAppCallNotFoundError(error) {
12
+ const err = error;
13
+ if (err?.status === 400 || err?.status === '400') {
14
+ return true;
15
+ }
16
+ const message = String(err?.message ?? error ?? '');
17
+ return message.includes('Call not found') || message.includes('101002');
18
+ }
19
+ //# sourceMappingURL=wxAppTelephonyUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["isWxAppCallNotFoundError","error","err","status","message","String","includes"],"sources":["wxAppTelephonyUtils.ts"],"sourcesContent":["/**\n * Expected Hydra responses when mute backfill races call creation (WXCC-6026).\n * These must not be logged as errors — see task-spec wxApp mute backfill guard.\n */\nexport function isWxAppCallNotFoundError(error: unknown): boolean {\n const err = error as {status?: number | string; message?: string};\n if (err?.status === 400 || err?.status === '400') {\n return true;\n }\n\n const message = String(err?.message ?? error ?? '');\n\n return message.includes('Call not found') || message.includes('101002');\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACO,SAASA,wBAAwBA,CAACC,KAAc,EAAW;EAChE,MAAMC,GAAG,GAAGD,KAAqD;EACjE,IAAIC,GAAG,EAAEC,MAAM,KAAK,GAAG,IAAID,GAAG,EAAEC,MAAM,KAAK,KAAK,EAAE;IAChD,OAAO,IAAI;EACb;EAEA,MAAMC,OAAO,GAAGC,MAAM,CAACH,GAAG,EAAEE,OAAO,IAAIH,KAAK,IAAI,EAAE,CAAC;EAEnD,OAAOG,OAAO,CAACE,QAAQ,CAAC,gBAAgB,CAAC,IAAIF,OAAO,CAACE,QAAQ,CAAC,QAAQ,CAAC;AACzE","ignoreList":[]}
@@ -163,6 +163,28 @@ export default class ContactCenter extends WebexPlugin implements IContactCenter
163
163
  * @private
164
164
  */
165
165
  private webCallingService;
166
+ /**
167
+ * REST telephony for wxApp thick-client answer (WXCC-6026)
168
+ * @private
169
+ */
170
+ private answerCallOnWebexService;
171
+ /**
172
+ * usersub cross-client state for Webex App toast suppression
173
+ * @private
174
+ */
175
+ private webexCrossClientService;
176
+ /**
177
+ * Mercury telephony mute sync for wxApp thick-client answer
178
+ * @private
179
+ */
180
+ private wxAppTelephonyMercurySync;
181
+ /** True when wxApp mute sync opened Mercury (Extension/DN-only profiles). */
182
+ private wxAppMercuryConnectedByCc;
183
+ /** True when wxApp mute sync registered the Webex device. */
184
+ private wxAppDeviceRegisteredByCc;
185
+ private static readonly WXAPP_FALSE_PUBLISH_RETRY_DELAY_MS;
186
+ private static readonly WXAPP_FALSE_PUBLISH_MAX_RETRIES;
187
+ private wxAppFalsePublishRetryTimer?;
166
188
  /**
167
189
  * Core service managers for Contact Center operations
168
190
  * Includes agent, connection, and configuration services
@@ -574,6 +596,57 @@ export default class ContactCenter extends WebexPlugin implements IContactCenter
574
596
  * @private
575
597
  */
576
598
  private validatePluginConfig;
599
+ /**
600
+ * Whether wxApp thick-client answer is enabled for this SDK instance.
601
+ * @public
602
+ */
603
+ isWxBetterTogetherEnabled(): boolean;
604
+ /**
605
+ * Current station login option (Extension, Dial Number, or Browser/Desktop).
606
+ * Prefer webCallingService — updated on every stationLogin before wxApp hooks run.
607
+ * @private
608
+ */
609
+ private getCurrentStationLoginOption;
610
+ /**
611
+ * wxApp thick-client answer is supported for Extension and Dial Number station login only —
612
+ * not Browser/Desktop (WebRTC) login.
613
+ * @private
614
+ */
615
+ private assertWxAppStationLoginSupportedForEnable;
616
+ /**
617
+ * Clears runtime wxApp config after logout/deregister so stale flags do not apply on relogin.
618
+ * @private
619
+ */
620
+ private resetEnableWxBetterTogetherConfig;
621
+ private ensureWxAppPostStationLogin;
622
+ private clearWxAppFalsePublishRetryTimer;
623
+ private scheduleForcedFalsePublishRetry;
624
+ /**
625
+ * Retries compensating false publish after rollback failure, regardless of enabled flag.
626
+ * @private
627
+ */
628
+ private scheduleCompensatingFalsePublishRetry;
629
+ private scheduleFalsePublishRetry;
630
+ /**
631
+ * Best-effort rollback when usersub true was published but wxApp setup did not complete.
632
+ * @private
633
+ */
634
+ private revertWxAppCrossClientPublish;
635
+ private ensureWxAppDeviceRegistered;
636
+ private ensureWxAppMercuryConnected;
637
+ /**
638
+ * Disconnects Mercury and unregisters the device when wxApp mute sync opened them.
639
+ * @private
640
+ */
641
+ private releaseWxAppMercuryResources;
642
+ /**
643
+ * Clears wxApp runtime state and feature-owned resources. Publish failures are logged;
644
+ * optional rethrow for deregister when callers need to surface usersub errors.
645
+ * @private
646
+ */
647
+ private teardownWxAppLocalState;
648
+ private ensureWxAppMercuryAndSubscribe;
649
+ private publishAnswerOnWebexCrossClientState;
577
650
  /**
578
651
  * Initializes event listeners for the Contact Center service
579
652
  * Sets up handlers for connection state changes and other core events
@@ -880,14 +953,14 @@ export default class ContactCenter extends WebexPlugin implements IContactCenter
880
953
  */
881
954
  updateAgentProfile(data: AgentProfileUpdate): Promise<UpdateDeviceTypeResponse>;
882
955
  /**
883
- * Returns paginated entry points for the organization.
884
- * Thin wrapper around internal EntryPoint instance.
956
+ * Returns paginated entry points using the EntryPoint service defaults.
957
+ * Existing request parameters can override those defaults.
885
958
  * @public
886
959
  */
887
960
  getEntryPoints(params?: EntryPointSearchParams): Promise<EntryPointListResponse>;
888
961
  /**
889
- * Returns paginated contact service queues for the organization.
890
- * Thin wrapper around internal Queue instance.
962
+ * Returns paginated contact service queues using the Queue service defaults.
963
+ * Existing request parameters can override those defaults.
891
964
  * @public
892
965
  */
893
966
  getQueues(params?: ContactServiceQueueSearchParams): Promise<ContactServiceQueuesResponse>;
@@ -31,6 +31,13 @@ declare const _default: {
31
31
  * @default false
32
32
  */
33
33
  disableWebRTCRegistration: boolean;
34
+ /**
35
+ * Whether wxApp Better Together is enabled at SDK init.
36
+ * Must be set before SDK init. Default false (WXCC-6026).
37
+ * @type {boolean}
38
+ * @default false
39
+ */
40
+ enableWxBetterTogether: boolean;
34
41
  /**
35
42
  * The type of client making the connection.
36
43
  * @type {string}
@@ -13,6 +13,7 @@ export declare const AQM_REQS_FILE = "aqm-reqs";
13
13
  export declare const WEBEX_REQUEST_FILE = "WebexRequest";
14
14
  export declare const TASK_MANAGER_FILE = "TaskManager";
15
15
  export declare const TASK_FILE = "Task";
16
+ export declare const INBOUND_DIRECTION = "INBOUND";
16
17
  export declare const OUTDIAL_DIRECTION = "OUTBOUND";
17
18
  export declare const ATTRIBUTES: {};
18
19
  export declare const OUTDIAL_MEDIA_TYPE = "telephony";
@@ -50,9 +51,11 @@ export declare const METHODS: {
50
51
  TRANSFER_CALL: string;
51
52
  CONSULT_TRANSFER: string;
52
53
  CONSULT_CONFERENCE: string;
54
+ DROP_CONFERENCE_PARTICIPANT: string;
53
55
  EXIT_CONFERENCE: string;
54
56
  TRANSFER_CONFERENCE: string;
55
57
  TOGGLE_MUTE: string;
58
+ TRANSMIT_DTMF: string;
56
59
  COMPLETE_TRANSFER: string;
57
60
  GET_OUTDIAL_ANI_ENTRIES: string;
58
61
  ACCEPT_PREVIEW_CONTACT: string;
@@ -63,4 +66,9 @@ export declare const METHODS: {
63
66
  GET_REAL_TIME_ASSISTANCE: string;
64
67
  SEND_REAL_TIME_ASSISTANCE_USER_ACTION: string;
65
68
  FETCH_HISTORIC_TRANSCRIPTS: string;
69
+ SET_MANAGE_WEBEX_CALLING_IN_WXCC: string;
70
+ IS_WX_BETTER_TOGETHER_ENABLED: string;
71
+ SYNC_WXAPP_MUTE_FROM_MERCURY: string;
72
+ GET_CALL_DETAILS_ON_WEBEX: string;
73
+ ENSURE_WXAPP_MERCURY_CONNECTED: string;
66
74
  };
@@ -98,7 +98,9 @@ IEventEmitter,
98
98
  /** Task interface */
99
99
  ITask, Interaction, TaskData,
100
100
  /** Task response */
101
- TaskResponse, ConsultPayload, ConsultEndPayload, ConsultTransferPayLoad,
101
+ TaskResponse,
102
+ /** Conference participant drop request */
103
+ DropConferenceParticipantPayload, ConsultPayload, ConsultEndPayload, ConsultTransferPayLoad,
102
104
  /** Dialer payload */
103
105
  DialerPayload, TransferPayLoad, ResumeRecordingPayload, WrapupPayLoad,
104
106
  /** UI control types for task buttons */
@@ -124,6 +124,8 @@ export declare const METRIC_EVENT_NAMES: {
124
124
  readonly TASK_CONFERENCE_TRANSFER_FAILED: "Task Conference Transfer Failed";
125
125
  readonly TASK_CONFERENCE_EXIT_SUCCESS: "Task Conference Exit Success";
126
126
  readonly TASK_CONFERENCE_EXIT_FAILED: "Task Conference Exit Failed";
127
+ readonly TASK_CONFERENCE_PARTICIPANT_DROP_SUCCESS: "Task Conference Participant Drop Success";
128
+ readonly TASK_CONFERENCE_PARTICIPANT_DROP_FAILED: "Task Conference Participant Drop Failed";
127
129
  readonly TASK_SWITCH_CALL_SUCCESS: "Task Switch Call Success";
128
130
  readonly TASK_SWITCH_CALL_FAILED: "Task Switch Call Failed";
129
131
  readonly TASK_OUTDIAL_SUCCESS: "Task Outdial Success";
@@ -52,7 +52,8 @@ export declare class AddressBook {
52
52
  constructor(webex: WebexSDK, getAddressBookId: () => string);
53
53
  /**
54
54
  * Fetches address book entries for a specific address book using the entry API
55
- * @param {AddressBookEntrySearchParams} [params] - Search and pagination parameters including addressBookId
55
+ * @param {AddressBookEntrySearchParams} [params] - Search, pagination, and optional sort parameters
56
+ * including addressBookId. Sorting defaults to name ascending.
56
57
  * @returns {Promise<AddressBookEntriesResponse>} Promise resolving to address book entries
57
58
  * @throws {Error} If the API call fails
58
59
  * @public
@@ -0,0 +1,37 @@
1
+ import { IHttpResponse, WebexSDK } from '../types';
2
+ export type WxAppTelephonyError = Error & {
3
+ isWxAppTelephonyError: true;
4
+ trackingId?: string;
5
+ status?: number | string;
6
+ };
7
+ export type AnswerCallParams = {
8
+ callId: string;
9
+ endpointId: string;
10
+ lineOwnerId?: string;
11
+ };
12
+ export type CallIdParams = {
13
+ callId: string;
14
+ lineOwnerId?: string;
15
+ };
16
+ export type TransmitDtmfParams = CallIdParams & {
17
+ dtmf: string;
18
+ };
19
+ export type CallDetailsResponse = {
20
+ muted?: boolean;
21
+ };
22
+ /**
23
+ * REST telephony client for wxApp thick-client answer (WXCC-6026).
24
+ * Separate from WebCallingService (WebRTC/Mobius).
25
+ */
26
+ export default class AnswerCallOnWebexService {
27
+ private webex;
28
+ constructor(webex: WebexSDK);
29
+ private getTelephonyBaseUrl;
30
+ private telephonyRequest;
31
+ answerCall(params: AnswerCallParams): Promise<IHttpResponse>;
32
+ rejectCall(params: CallIdParams): Promise<IHttpResponse>;
33
+ muteCall(params: CallIdParams): Promise<IHttpResponse>;
34
+ unmuteCall(params: CallIdParams): Promise<IHttpResponse>;
35
+ transmitDtmf(params: TransmitDtmfParams): Promise<IHttpResponse>;
36
+ getCallDetails(params: CallIdParams): Promise<CallDetailsResponse>;
37
+ }
@@ -27,7 +27,7 @@ import type { EntryPointListResponse, EntryPointSearchParams } from '../types';
27
27
  * });
28
28
  *
29
29
  * // Search for specific entry points
30
- * const searchResults = await entryPointAPI.searchEntryPoints({
30
+ * const searchResults = await entryPointAPI.getEntryPoints({
31
31
  * search: 'support',
32
32
  * filter: 'type=="voice"'
33
33
  * });
@@ -37,7 +37,6 @@ export declare class EntryPoint {
37
37
  private webexRequest;
38
38
  private webex;
39
39
  private metricsManager;
40
- private pageCache;
41
40
  /**
42
41
  * Creates an instance of EntryPoint
43
42
  * @param {WebexSDK} webex - The Webex SDK instance
@@ -45,14 +44,17 @@ export declare class EntryPoint {
45
44
  */
46
45
  constructor(webex: WebexSDK);
47
46
  /**
48
- * Fetches entry points for the organization with pagination support
49
- * @param {EntryPointSearchParams} [params] - Search and pagination parameters
47
+ * Fetches entry-point dial-number mappings for the organization with pagination support. By
48
+ * default, returns the agent's desktop-profile-filtered mappings in backend entry-point-name order.
49
+ * Search, filter, attribute, and sort parameters can customize the request while desktop-profile
50
+ * scoping and required mapping fields remain SDK-owned.
51
+ * @param {EntryPointSearchParams} [params] - Search, pagination, and compatible override parameters.
50
52
  * @returns {Promise<EntryPointListResponse>} Promise resolving to paginated entry points
51
53
  * @throws {Error} If the API call fails
52
54
  * @public
53
55
  * @example
54
56
  * ```typescript
55
- * // Get first page of entry points
57
+ * // Get the first page using the default entry-point policy
56
58
  * const response = await entryPointAPI.getEntryPoints();
57
59
  *
58
60
  * // Get specific page with custom page size
@@ -48,14 +48,16 @@ export declare class Queue {
48
48
  */
49
49
  constructor(webex: WebexSDK);
50
50
  /**
51
- * Fetches contact service queues for the organization
52
- * @param {ContactServiceQueueSearchParams} [params] - Search and pagination parameters
51
+ * Fetches contact service queues for the organization. By default, returns active inbound
52
+ * telephony queues in backend name-ascending order using the agent's desktop profile views.
53
+ * Existing filter, sort, and desktop-profile parameters override those defaults.
54
+ * @param {ContactServiceQueueSearchParams} [params] - Search, pagination, and override parameters
53
55
  * @returns {Promise<ContactServiceQueuesResponse>} Promise resolving to contact service queues
54
56
  * @throws {Error} If the API call fails
55
57
  * @public
56
58
  * @example
57
59
  * ```typescript
58
- * // Get all queues with default pagination
60
+ * // Get queues using the default list policy and pagination
59
61
  * const response = await queueAPI.getQueues();
60
62
  *
61
63
  * // Get queues with specific pagination
@@ -0,0 +1,28 @@
1
+ import { WebexSDK } from '../types';
2
+ /**
3
+ * Publishes usersub cross-client state so Webex App suppresses native calling toasts (WXCC-6026).
4
+ */
5
+ export default class WebexCrossClientService {
6
+ private webex;
7
+ private refreshTimer?;
8
+ private refreshRetryTimer?;
9
+ private answerCallsState;
10
+ private appName;
11
+ /** Incremented on teardown/disable to ignore stale refresh timer callbacks. */
12
+ private refreshGeneration;
13
+ constructor(webex: WebexSDK);
14
+ private extractDeviceIdFromUrl;
15
+ private getDeviceUrl;
16
+ private clearRefreshTimer;
17
+ private scheduleRefreshRetry;
18
+ private startRefreshTimer;
19
+ private publishCrossClientState;
20
+ setManageWebexCallingInWxcc(enable: boolean, options?: {
21
+ userId?: string;
22
+ ttl?: number;
23
+ appName?: string;
24
+ }): Promise<void>;
25
+ teardown(): void;
26
+ /** Whether usersub `answer-calls-on-wxcc: true` was successfully published this session. */
27
+ isAnswerCallsStateActive(): boolean;
28
+ }
@@ -0,0 +1,28 @@
1
+ import { WebexSDK } from '../types';
2
+ export declare const TELEPHONY_CALL_MUTED = "event:telephony_calls.muted";
3
+ export declare const TELEPHONY_CALL_UNMUTED = "event:telephony_calls.unmuted";
4
+ export type UpdatedCallMuteStateEvent = {
5
+ data: {
6
+ actorId: string;
7
+ callId: string;
8
+ muted: boolean;
9
+ };
10
+ };
11
+ type MuteChangeHandler = (callId: string, muted: boolean) => void;
12
+ /**
13
+ * Subscribes to Mercury telephony mute/unmute events for wxApp thick-client sync (AD parity).
14
+ */
15
+ export default class WxAppTelephonyMercurySync {
16
+ private webex;
17
+ private subscribedAgentId?;
18
+ private muteChangeHandler?;
19
+ private boundMuteHandler?;
20
+ private boundUnmuteHandler?;
21
+ constructor(webex: WebexSDK);
22
+ private decodeBase64;
23
+ private handleMuteStateEvent;
24
+ subscribe(agentId: string, onMuteChange: MuteChangeHandler): void;
25
+ unsubscribe(): void;
26
+ isSubscribed(): boolean;
27
+ }
28
+ export {};
@@ -1,4 +1,10 @@
1
1
  export declare const DEFAULT_PAGE = 0;
2
+ /** Desktop Profile access levels for collaboration destination categories. */
3
+ export declare const COLLABORATION_ACCESS: {
4
+ readonly ALL: "ALL";
5
+ readonly SPECIFIC: "SPECIFIC";
6
+ readonly NONE: "NONE";
7
+ };
2
8
  /**
3
9
  * Default page size for paginated API requests.
4
10
  * @type {number}
@@ -212,16 +218,13 @@ export declare const endPointMap: {
212
218
  */
213
219
  queueList: (orgId: string, queryParams: string) => string;
214
220
  /**
215
- * Gets the endpoint for entry points list with custom query parameters.
221
+ * Gets the desktop-profile-filtered dial-number mappings used by entry-point destination lists.
216
222
  * @param orgId - Organization ID.
217
223
  * @param queryParams - Query parameters string.
218
224
  * @returns The endpoint URL string.
219
- * @public
220
- * @example
221
- * const url = endPointMap.entryPointList('org123', 'page=0&pageSize=10');
222
225
  * @ignore
223
226
  */
224
- entryPointList: (orgId: string, queryParams: string) => string;
227
+ entryPointDialNumberList: (orgId: string, queryParams: string) => string;
225
228
  /**
226
229
  * Gets the endpoint for address book entries with custom query parameters.
227
230
  * @param orgId - Organization ID.