@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.
- package/.sdd/manifest.json +5 -4
- package/ai-docs/ARCHITECTURE.md +1 -1
- package/ai-docs/CONTRACTS.md +5 -1
- package/ai-docs/SECURITY.md +1 -1
- package/ai-docs/contact-center-spec.md +22 -4
- package/ai-docs/features/consult-transfer-list-policy/spec/feature-spec.md +362 -0
- package/dist/cc.js +440 -10
- package/dist/cc.js.map +1 -1
- package/dist/config.js +7 -0
- package/dist/config.js.map +1 -1
- package/dist/constants.js +10 -2
- package/dist/constants.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/metrics/behavioral-events.js +13 -0
- package/dist/metrics/behavioral-events.js.map +1 -1
- package/dist/metrics/constants.js +2 -0
- package/dist/metrics/constants.js.map +1 -1
- package/dist/services/AddressBook.js +18 -15
- package/dist/services/AddressBook.js.map +1 -1
- package/dist/services/AnswerCallOnWebexService.js +174 -0
- package/dist/services/AnswerCallOnWebexService.js.map +1 -0
- package/dist/services/EntryPoint.js +46 -68
- package/dist/services/EntryPoint.js.map +1 -1
- package/dist/services/Queue.js +27 -22
- package/dist/services/Queue.js.map +1 -1
- package/dist/services/WebexCrossClientService.js +171 -0
- package/dist/services/WebexCrossClientService.js.map +1 -0
- package/dist/services/WxAppTelephonyMercurySync.js +93 -0
- package/dist/services/WxAppTelephonyMercurySync.js.map +1 -0
- package/dist/services/config/Util.js +3 -0
- package/dist/services/config/Util.js.map +1 -1
- package/dist/services/config/constants.js +10 -6
- package/dist/services/config/constants.js.map +1 -1
- package/dist/services/config/types.js +4 -0
- package/dist/services/config/types.js.map +1 -1
- package/dist/services/core/Err.js.map +1 -1
- package/dist/services/core/WebexRequest.js +6 -2
- package/dist/services/core/WebexRequest.js.map +1 -1
- package/dist/services/core/aqm-reqs.js +28 -14
- package/dist/services/core/aqm-reqs.js.map +1 -1
- package/dist/services/core/types.js.map +1 -1
- package/dist/services/task/Task.js +73 -7
- package/dist/services/task/Task.js.map +1 -1
- package/dist/services/task/TaskFactory.js +8 -4
- package/dist/services/task/TaskFactory.js.map +1 -1
- package/dist/services/task/TaskManager.js +176 -20
- package/dist/services/task/TaskManager.js.map +1 -1
- package/dist/services/task/WebexCallingUtils.js +70 -0
- package/dist/services/task/WebexCallingUtils.js.map +1 -0
- package/dist/services/task/constants.js +4 -1
- package/dist/services/task/constants.js.map +1 -1
- package/dist/services/task/contact.js +29 -0
- package/dist/services/task/contact.js.map +1 -1
- package/dist/services/task/digital/Digital.js +3 -2
- package/dist/services/task/digital/Digital.js.map +1 -1
- package/dist/services/task/state-machine/TaskStateMachine.js +135 -37
- package/dist/services/task/state-machine/TaskStateMachine.js.map +1 -1
- package/dist/services/task/state-machine/actions.js +6 -1
- package/dist/services/task/state-machine/actions.js.map +1 -1
- package/dist/services/task/state-machine/guards.js +38 -11
- package/dist/services/task/state-machine/guards.js.map +1 -1
- package/dist/services/task/state-machine/types.js.map +1 -1
- package/dist/services/task/state-machine/uiControlsComputer.js +118 -18
- package/dist/services/task/state-machine/uiControlsComputer.js.map +1 -1
- package/dist/services/task/types.js +16 -1
- package/dist/services/task/types.js.map +1 -1
- package/dist/services/task/voice/Voice.js +350 -14
- package/dist/services/task/voice/Voice.js.map +1 -1
- package/dist/services/task/voice/WebRTC.js +4 -1
- package/dist/services/task/voice/WebRTC.js.map +1 -1
- package/dist/services/task/voice/wxAppVoiceMethods.js +201 -0
- package/dist/services/task/voice/wxAppVoiceMethods.js.map +1 -0
- package/dist/services/wxAppTelephonyUtils.js +19 -0
- package/dist/services/wxAppTelephonyUtils.js.map +1 -0
- package/dist/types/cc.d.ts +77 -4
- package/dist/types/config.d.ts +7 -0
- package/dist/types/constants.d.ts +8 -0
- package/dist/types/index.d.ts +3 -1
- package/dist/types/metrics/constants.d.ts +2 -0
- package/dist/types/services/AddressBook.d.ts +2 -1
- package/dist/types/services/AnswerCallOnWebexService.d.ts +37 -0
- package/dist/types/services/EntryPoint.d.ts +7 -5
- package/dist/types/services/Queue.d.ts +5 -3
- package/dist/types/services/WebexCrossClientService.d.ts +28 -0
- package/dist/types/services/WxAppTelephonyMercurySync.d.ts +28 -0
- package/dist/types/services/config/constants.d.ts +8 -5
- package/dist/types/services/config/types.d.ts +17 -4
- package/dist/types/services/core/Err.d.ts +2 -0
- package/dist/types/services/core/WebexRequest.d.ts +1 -0
- package/dist/types/services/core/types.d.ts +2 -0
- package/dist/types/services/task/Task.d.ts +20 -2
- package/dist/types/services/task/TaskFactory.d.ts +2 -1
- package/dist/types/services/task/WebexCallingUtils.d.ts +11 -0
- package/dist/types/services/task/constants.d.ts +3 -0
- package/dist/types/services/task/contact.d.ts +4 -0
- package/dist/types/services/task/digital/Digital.d.ts +2 -2
- package/dist/types/services/task/state-machine/TaskStateMachine.d.ts +260 -56
- package/dist/types/services/task/state-machine/guards.d.ts +6 -5
- package/dist/types/services/task/state-machine/types.d.ts +9 -1
- package/dist/types/services/task/types.d.ts +81 -4
- package/dist/types/services/task/voice/Voice.d.ts +48 -9
- package/dist/types/services/task/voice/WebRTC.d.ts +2 -2
- package/dist/types/services/task/voice/wxAppVoiceMethods.d.ts +52 -0
- package/dist/types/services/wxAppTelephonyUtils.d.ts +5 -0
- package/dist/types/types.d.ts +14 -8
- package/dist/types/utils/PageCache.d.ts +20 -3
- package/dist/types.js +7 -2
- package/dist/types.js.map +1 -1
- package/dist/utils/PageCache.js +19 -5
- package/dist/utils/PageCache.js.map +1 -1
- package/dist/webex.js +1 -1
- package/package.json +1 -1
- package/src/cc.ts +506 -9
- package/src/config.ts +7 -0
- package/src/constants.ts +8 -0
- package/src/index.ts +2 -0
- package/src/metrics/ai-docs/metrics-spec.md +9 -3
- package/src/metrics/behavioral-events.ts +14 -0
- package/src/metrics/constants.ts +2 -0
- package/src/services/AddressBook.ts +17 -6
- package/src/services/AnswerCallOnWebexService.ts +206 -0
- package/src/services/EntryPoint.ts +59 -60
- package/src/services/Queue.ts +29 -12
- package/src/services/WebexCrossClientService.ts +212 -0
- package/src/services/WxAppTelephonyMercurySync.ts +115 -0
- package/src/services/ai-docs/AGENTS.md +10 -10
- package/src/services/ai-docs/services-spec.md +6 -1
- package/src/services/config/Util.ts +3 -0
- package/src/services/config/ai-docs/AGENTS.md +1 -1
- package/src/services/config/ai-docs/ARCHITECTURE.md +2 -2
- package/src/services/config/ai-docs/config-spec.md +6 -0
- package/src/services/config/constants.ts +10 -6
- package/src/services/config/types.ts +16 -4
- package/src/services/core/Err.ts +1 -0
- package/src/services/core/WebexRequest.ts +3 -1
- package/src/services/core/ai-docs/core-spec.md +5 -1
- package/src/services/core/aqm-reqs.ts +30 -15
- package/src/services/core/types.ts +2 -0
- package/src/services/task/Task.ts +79 -8
- package/src/services/task/TaskFactory.ts +8 -3
- package/src/services/task/TaskManager.ts +254 -15
- package/src/services/task/WebexCallingUtils.ts +136 -0
- package/src/services/task/ai-docs/ARCHITECTURE.md +1 -0
- package/src/services/task/ai-docs/task-spec.md +117 -2
- package/src/services/task/constants.ts +3 -0
- package/src/services/task/contact.ts +30 -0
- package/src/services/task/digital/Digital.ts +4 -2
- package/src/services/task/state-machine/TaskStateMachine.ts +210 -63
- package/src/services/task/state-machine/actions.ts +5 -2
- package/src/services/task/state-machine/ai-docs/AGENTS.md +8 -4
- package/src/services/task/state-machine/ai-docs/ARCHITECTURE.md +17 -8
- package/src/services/task/state-machine/ai-docs/task-state-machine-spec.md +46 -22
- package/src/services/task/state-machine/guards.ts +64 -11
- package/src/services/task/state-machine/types.ts +16 -1
- package/src/services/task/state-machine/uiControlsComputer.ts +206 -32
- package/src/services/task/types.ts +114 -4
- package/src/services/task/voice/Voice.ts +462 -12
- package/src/services/task/voice/WebRTC.ts +5 -1
- package/src/services/task/voice/wxAppVoiceMethods.ts +307 -0
- package/src/services/wxAppTelephonyUtils.ts +14 -0
- package/src/types.ts +33 -9
- package/src/utils/AGENTS.md +21 -10
- package/src/utils/PageCache.ts +38 -5
- package/src/utils/ai-docs/utils-spec.md +21 -11
- package/test/unit/spec/cc.ts +1274 -0
- package/test/unit/spec/metrics/behavioral-events.ts +18 -0
- package/test/unit/spec/services/AddressBook.ts +37 -6
- package/test/unit/spec/services/AnswerCallOnWebexService.ts +223 -0
- package/test/unit/spec/services/EntryPoint.ts +87 -40
- package/test/unit/spec/services/Queue.ts +123 -12
- package/test/unit/spec/services/WebexCrossClientService.ts +261 -0
- package/test/unit/spec/services/WxAppTelephonyMercurySync.ts +113 -0
- package/test/unit/spec/services/config/Util.ts +85 -0
- package/test/unit/spec/services/core/WebexRequest.ts +3 -1
- package/test/unit/spec/services/core/aqm-reqs.ts +113 -1
- package/test/unit/spec/services/task/Task.ts +200 -0
- package/test/unit/spec/services/task/TaskFactory.ts +39 -2
- package/test/unit/spec/services/task/TaskManager.ts +653 -1
- package/test/unit/spec/services/task/WebexCallingUtils.ts +153 -0
- package/test/unit/spec/services/task/contact.ts +33 -0
- package/test/unit/spec/services/task/state-machine/TaskStateMachine.ts +854 -72
- package/test/unit/spec/services/task/state-machine/guards.ts +210 -8
- package/test/unit/spec/services/task/state-machine/uiControlsComputer.ts +445 -7
- package/test/unit/spec/services/task/voice/Voice.ts +874 -0
- package/test/unit/spec/services/task/voice/wxAppVoiceMethods.ts +459 -0
- package/umd/contact-center.min.js +2 -2
- package/umd/contact-center.min.js.map +1 -1
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import AnswerCallOnWebexService from '../../AnswerCallOnWebexService';
|
|
2
|
+
import LoggerProxy from '../../../logger-proxy';
|
|
3
|
+
import {METHODS} from '../../../constants';
|
|
4
|
+
import {getErrorDetails} from '../../core/Utils';
|
|
5
|
+
import {TaskData, TaskToggleMuteOptions, TaskTransmitDtmfOptions} from '../types';
|
|
6
|
+
import {TaskState} from '../state-machine';
|
|
7
|
+
import {
|
|
8
|
+
decodedLineOwnerId,
|
|
9
|
+
getWebexCallingDeviceDetailsForAgent,
|
|
10
|
+
WebexCallingDeviceDetails,
|
|
11
|
+
} from '../WebexCallingUtils';
|
|
12
|
+
|
|
13
|
+
type WxAppParticipant = {
|
|
14
|
+
deviceType?: string;
|
|
15
|
+
deviceCallId?: string;
|
|
16
|
+
deviceId?: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type WxAppVoiceDependencies = {
|
|
20
|
+
enableWxBetterTogether: boolean;
|
|
21
|
+
answerCallOnWebexService?: AnswerCallOnWebexService;
|
|
22
|
+
agentId?: string;
|
|
23
|
+
getTaskData: () => TaskData;
|
|
24
|
+
getTaskState: () => TaskState | undefined;
|
|
25
|
+
getWxAppMuted: () => boolean;
|
|
26
|
+
setWxAppMuted: (muted: boolean) => void;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/** @deprecated Use {@link WxAppVoiceDependencies} */
|
|
30
|
+
export type WxAppVoiceDeps = WxAppVoiceDependencies;
|
|
31
|
+
|
|
32
|
+
export type WxAppVoiceLifecycle = {
|
|
33
|
+
setWxAppAcceptInFlight: (inFlight: boolean) => void;
|
|
34
|
+
setWxAppAnswerPending: (pending: boolean) => void;
|
|
35
|
+
resetWxAppMuted: () => void;
|
|
36
|
+
syncWxAppMuteFromCallDetails: () => Promise<boolean | undefined>;
|
|
37
|
+
mapWxAppVoiceError: (error: unknown, method: string) => never;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const isWxAppParticipant = (participant: unknown): participant is WxAppParticipant =>
|
|
41
|
+
(participant as WxAppParticipant)?.deviceType === 'wxApp' &&
|
|
42
|
+
typeof (participant as WxAppParticipant)?.deviceCallId === 'string' &&
|
|
43
|
+
(participant as WxAppParticipant).deviceCallId.trim() !== '' &&
|
|
44
|
+
typeof (participant as WxAppParticipant)?.deviceId === 'string' &&
|
|
45
|
+
(participant as WxAppParticipant).deviceId.trim() !== '';
|
|
46
|
+
|
|
47
|
+
const isOutdialTask = (deps: WxAppVoiceDependencies): boolean =>
|
|
48
|
+
deps.getTaskData()?.interaction?.outboundType === 'OUTDIAL';
|
|
49
|
+
|
|
50
|
+
function getWxAppAgentParticipant(deps: WxAppVoiceDependencies): unknown {
|
|
51
|
+
const taskData = deps.getTaskData();
|
|
52
|
+
const participants = taskData.interaction?.participants;
|
|
53
|
+
const agentId = deps.agentId ?? taskData.agentId;
|
|
54
|
+
|
|
55
|
+
if (!participants || !agentId) {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (participants[agentId]) {
|
|
60
|
+
return participants[agentId];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return Object.values(participants).find(
|
|
64
|
+
(participant) => (participant as {id?: string})?.id === agentId
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function getCallingDeviceDetails(
|
|
69
|
+
deps: WxAppVoiceDependencies
|
|
70
|
+
): WebexCallingDeviceDetails | undefined {
|
|
71
|
+
const taskData = deps.getTaskData();
|
|
72
|
+
const participant = getWxAppAgentParticipant(deps);
|
|
73
|
+
|
|
74
|
+
if (!isWxAppParticipant(participant)) {
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return getWebexCallingDeviceDetailsForAgent(
|
|
79
|
+
deps.agentId ?? taskData.agentId,
|
|
80
|
+
taskData.interaction?.participants
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function isWebexAppCallingOffer(deps: WxAppVoiceDependencies): boolean {
|
|
85
|
+
if (!deps.enableWxBetterTogether) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const state = deps.getTaskState();
|
|
90
|
+
if (state !== TaskState.OFFERED) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const details = getCallingDeviceDetails(deps);
|
|
95
|
+
|
|
96
|
+
return Boolean(details);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Inbound wxApp offer only — outdial decline uses CC routing, not telephony reject. */
|
|
100
|
+
export function isWebexAppInboundCallingOffer(deps: WxAppVoiceDependencies): boolean {
|
|
101
|
+
return isWebexAppCallingOffer(deps) && !isOutdialTask(deps);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export function getWebexCallingCallId(deps: WxAppVoiceDependencies): string | null {
|
|
105
|
+
const state = deps.getTaskState();
|
|
106
|
+
if (
|
|
107
|
+
!state ||
|
|
108
|
+
state === TaskState.OFFERED ||
|
|
109
|
+
state === TaskState.IDLE ||
|
|
110
|
+
state === TaskState.WRAPPING_UP ||
|
|
111
|
+
state === TaskState.TERMINATED ||
|
|
112
|
+
state === TaskState.COMPLETED
|
|
113
|
+
) {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return getCallingDeviceDetails(deps)?.deviceCallId ?? null;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function getWxAppLineOwnerId(deps: WxAppVoiceDependencies): string | undefined {
|
|
121
|
+
const participant = getWxAppAgentParticipant(deps) as {lineOwnerId?: string} | undefined;
|
|
122
|
+
const lineOwnerId = participant?.lineOwnerId;
|
|
123
|
+
|
|
124
|
+
return typeof lineOwnerId === 'string' && lineOwnerId.trim() !== '' ? lineOwnerId : undefined;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function resolveWxAppLineOwnerId(
|
|
128
|
+
deps: WxAppVoiceDependencies,
|
|
129
|
+
override?: string
|
|
130
|
+
): string | undefined {
|
|
131
|
+
if (typeof override === 'string' && override.trim() !== '') {
|
|
132
|
+
return override;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return decodedLineOwnerId(getWxAppLineOwnerId(deps));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function assertWxAppEnabled(deps: WxAppVoiceDependencies): void {
|
|
139
|
+
if (!deps.enableWxBetterTogether) {
|
|
140
|
+
throw new Error('enableWxBetterTogether is disabled');
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (!deps.answerCallOnWebexService) {
|
|
144
|
+
throw new Error('AnswerCallOnWebexService is unavailable');
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export async function acceptOnWebex(
|
|
149
|
+
deps: WxAppVoiceDependencies,
|
|
150
|
+
options?: {lineOwnerId?: string}
|
|
151
|
+
): Promise<void> {
|
|
152
|
+
assertWxAppEnabled(deps);
|
|
153
|
+
|
|
154
|
+
if (!isWebexAppCallingOffer(deps)) {
|
|
155
|
+
throw new Error('Task is not a wxApp calling offer');
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const details = getCallingDeviceDetails(deps);
|
|
159
|
+
if (!details) {
|
|
160
|
+
throw new Error('WxApp calling device details are unavailable');
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
await deps.answerCallOnWebexService.answerCall({
|
|
164
|
+
callId: details.deviceCallId,
|
|
165
|
+
endpointId: details.deviceId,
|
|
166
|
+
lineOwnerId: resolveWxAppLineOwnerId(deps, options?.lineOwnerId),
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export async function rejectOnWebex(
|
|
171
|
+
deps: WxAppVoiceDependencies,
|
|
172
|
+
options?: {lineOwnerId?: string}
|
|
173
|
+
): Promise<void> {
|
|
174
|
+
assertWxAppEnabled(deps);
|
|
175
|
+
|
|
176
|
+
if (!isWebexAppInboundCallingOffer(deps)) {
|
|
177
|
+
throw new Error('Task is not a wxApp inbound calling offer');
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const details = getCallingDeviceDetails(deps);
|
|
181
|
+
if (!details) {
|
|
182
|
+
throw new Error('WxApp calling device details are unavailable');
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
await deps.answerCallOnWebexService.rejectCall({
|
|
186
|
+
callId: details.deviceCallId,
|
|
187
|
+
lineOwnerId: resolveWxAppLineOwnerId(deps, options?.lineOwnerId),
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export async function toggleMuteOnWebex(
|
|
192
|
+
deps: WxAppVoiceDependencies,
|
|
193
|
+
options?: {lineOwnerId?: string; muted?: boolean}
|
|
194
|
+
): Promise<void> {
|
|
195
|
+
assertWxAppEnabled(deps);
|
|
196
|
+
|
|
197
|
+
const callId = getWebexCallingCallId(deps);
|
|
198
|
+
if (!callId) {
|
|
199
|
+
throw new Error('WxApp call ID is unavailable');
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const targetMuted = options?.muted ?? !deps.getWxAppMuted();
|
|
203
|
+
const request = targetMuted
|
|
204
|
+
? deps.answerCallOnWebexService.muteCall.bind(deps.answerCallOnWebexService)
|
|
205
|
+
: deps.answerCallOnWebexService.unmuteCall.bind(deps.answerCallOnWebexService);
|
|
206
|
+
|
|
207
|
+
await request({
|
|
208
|
+
callId,
|
|
209
|
+
lineOwnerId: resolveWxAppLineOwnerId(deps, options?.lineOwnerId),
|
|
210
|
+
});
|
|
211
|
+
deps.setWxAppMuted(targetMuted);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export async function transmitDtmfOnWebex(
|
|
215
|
+
deps: WxAppVoiceDependencies,
|
|
216
|
+
options: {dtmf: string; lineOwnerId?: string}
|
|
217
|
+
): Promise<void> {
|
|
218
|
+
assertWxAppEnabled(deps);
|
|
219
|
+
|
|
220
|
+
const callId = getWebexCallingCallId(deps);
|
|
221
|
+
if (!callId) {
|
|
222
|
+
throw new Error('WxApp call ID is unavailable');
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
LoggerProxy.info('transmitDtmf', {
|
|
226
|
+
module: 'wxAppVoiceMethods',
|
|
227
|
+
method: METHODS.TRANSMIT_DTMF,
|
|
228
|
+
data: {
|
|
229
|
+
callId,
|
|
230
|
+
dtmfLength: options.dtmf.length,
|
|
231
|
+
hasLineOwnerId: Boolean(options.lineOwnerId),
|
|
232
|
+
},
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
await deps.answerCallOnWebexService.transmitDtmf({
|
|
236
|
+
callId,
|
|
237
|
+
dtmf: options.dtmf,
|
|
238
|
+
lineOwnerId: resolveWxAppLineOwnerId(deps, options.lineOwnerId),
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export async function runWxAppAccept(
|
|
243
|
+
deps: WxAppVoiceDependencies,
|
|
244
|
+
lifecycle: WxAppVoiceLifecycle,
|
|
245
|
+
options?: {lineOwnerId?: string}
|
|
246
|
+
): Promise<void> {
|
|
247
|
+
try {
|
|
248
|
+
lifecycle.setWxAppAcceptInFlight(true);
|
|
249
|
+
lifecycle.setWxAppAnswerPending(true);
|
|
250
|
+
await acceptOnWebex(deps, options);
|
|
251
|
+
lifecycle.resetWxAppMuted();
|
|
252
|
+
await lifecycle.syncWxAppMuteFromCallDetails();
|
|
253
|
+
} catch (error) {
|
|
254
|
+
lifecycle.setWxAppAnswerPending(false);
|
|
255
|
+
lifecycle.mapWxAppVoiceError(error, METHODS.ACCEPT);
|
|
256
|
+
} finally {
|
|
257
|
+
lifecycle.setWxAppAcceptInFlight(false);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export async function runWxAppReject(
|
|
262
|
+
deps: WxAppVoiceDependencies,
|
|
263
|
+
lifecycle: WxAppVoiceLifecycle,
|
|
264
|
+
options?: {lineOwnerId?: string}
|
|
265
|
+
): Promise<void> {
|
|
266
|
+
try {
|
|
267
|
+
await rejectOnWebex(deps, options);
|
|
268
|
+
} catch (error) {
|
|
269
|
+
lifecycle.mapWxAppVoiceError(error, METHODS.REJECT);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export async function runWxAppToggleMute(
|
|
274
|
+
deps: WxAppVoiceDependencies,
|
|
275
|
+
lifecycle: WxAppVoiceLifecycle,
|
|
276
|
+
options?: TaskToggleMuteOptions
|
|
277
|
+
): Promise<void> {
|
|
278
|
+
try {
|
|
279
|
+
await toggleMuteOnWebex(deps, options);
|
|
280
|
+
} catch (error) {
|
|
281
|
+
lifecycle.mapWxAppVoiceError(error, METHODS.TOGGLE_MUTE);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export async function runWxAppTransmitDtmf(
|
|
286
|
+
deps: WxAppVoiceDependencies,
|
|
287
|
+
lifecycle: WxAppVoiceLifecycle,
|
|
288
|
+
options: TaskTransmitDtmfOptions
|
|
289
|
+
): Promise<void> {
|
|
290
|
+
try {
|
|
291
|
+
await transmitDtmfOnWebex(deps, options);
|
|
292
|
+
} catch (error) {
|
|
293
|
+
lifecycle.mapWxAppVoiceError(error, METHODS.TRANSMIT_DTMF);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export function mapWxAppVoiceError(error: unknown, method: string, module: string): never {
|
|
298
|
+
if (
|
|
299
|
+
error instanceof Error &&
|
|
300
|
+
(error as Error & {isWxAppTelephonyError?: boolean}).isWxAppTelephonyError
|
|
301
|
+
) {
|
|
302
|
+
throw error;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
const {error: detailedError} = getErrorDetails(error, method, module);
|
|
306
|
+
throw detailedError;
|
|
307
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Expected Hydra responses when mute backfill races call creation (WXCC-6026).
|
|
3
|
+
* These must not be logged as errors — see task-spec wxApp mute backfill guard.
|
|
4
|
+
*/
|
|
5
|
+
export function isWxAppCallNotFoundError(error: unknown): boolean {
|
|
6
|
+
const err = error as {status?: number | string; message?: string};
|
|
7
|
+
if (err?.status === 400 || err?.status === '400') {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const message = String(err?.message ?? error ?? '');
|
|
12
|
+
|
|
13
|
+
return message.includes('Call not found') || message.includes('101002');
|
|
14
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -93,12 +93,19 @@ export type WebexRequestPayload = {
|
|
|
93
93
|
*/
|
|
94
94
|
type Listener = (e: string, data?: unknown) => void;
|
|
95
95
|
|
|
96
|
+
/**
|
|
97
|
+
* Mercury event handler callback.
|
|
98
|
+
* @internal
|
|
99
|
+
* @ignore
|
|
100
|
+
*/
|
|
101
|
+
type MercuryEventHandler = (data?: unknown) => void;
|
|
102
|
+
|
|
96
103
|
/**
|
|
97
104
|
* Event listener removal function type.
|
|
98
105
|
* @internal
|
|
99
106
|
* @ignore
|
|
100
107
|
*/
|
|
101
|
-
type ListenerOff = (e: string) => void;
|
|
108
|
+
type ListenerOff = (e: string, handler?: MercuryEventHandler) => void;
|
|
102
109
|
|
|
103
110
|
/**
|
|
104
111
|
* Service host configuration.
|
|
@@ -163,6 +170,8 @@ export interface CCPluginConfig {
|
|
|
163
170
|
callingClientConfig: CallingClientConfig;
|
|
164
171
|
/** Whether to skip Mobius/WebRTC registration for browser login flows */
|
|
165
172
|
disableWebRTCRegistration?: boolean;
|
|
173
|
+
/** Whether wxApp Better Together (telephony REST + usersub) is enabled at init (WXCC-6026) */
|
|
174
|
+
enableWxBetterTogether?: boolean;
|
|
166
175
|
}
|
|
167
176
|
|
|
168
177
|
/**
|
|
@@ -293,6 +302,12 @@ interface IWebexInternal {
|
|
|
293
302
|
version: string;
|
|
294
303
|
/** Calling behavior configuration */
|
|
295
304
|
callingBehavior: string;
|
|
305
|
+
/** Whether the device is registered with WDM */
|
|
306
|
+
registered?: boolean;
|
|
307
|
+
/** Register the device with WDM */
|
|
308
|
+
register?: () => Promise<void>;
|
|
309
|
+
/** Unregister the device from WDM */
|
|
310
|
+
unregister?: () => Promise<void>;
|
|
296
311
|
};
|
|
297
312
|
/** Presence service */
|
|
298
313
|
presence: unknown;
|
|
@@ -555,18 +570,16 @@ export type RequestBody =
|
|
|
555
570
|
|
|
556
571
|
/**
|
|
557
572
|
* Represents the options to fetch buddy agents for the logged in agent.
|
|
558
|
-
* Buddy agents are other agents who can be consulted or
|
|
573
|
+
* Buddy agents are other agents who can be consulted or transferred to.
|
|
559
574
|
* @public
|
|
560
575
|
* @example
|
|
561
576
|
* const opts: BuddyAgents = { mediaType: 'telephony', state: 'Available' };
|
|
562
|
-
* @ignore
|
|
563
577
|
*/
|
|
564
578
|
export type BuddyAgents = {
|
|
565
579
|
/**
|
|
566
|
-
* The media type channel to filter buddy agents.
|
|
567
|
-
* Determines which channel capability the returned agents must have.
|
|
580
|
+
* The media type channel to filter buddy agents. Defaults to telephony when omitted.
|
|
568
581
|
*/
|
|
569
|
-
mediaType
|
|
582
|
+
mediaType?: 'telephony' | 'chat' | 'social' | 'email';
|
|
570
583
|
|
|
571
584
|
/**
|
|
572
585
|
* Optional filter for agent state.
|
|
@@ -574,6 +587,11 @@ export type BuddyAgents = {
|
|
|
574
587
|
* If omitted, returns both available and idle agents.
|
|
575
588
|
*/
|
|
576
589
|
state?: 'Available' | 'Idle';
|
|
590
|
+
|
|
591
|
+
/**
|
|
592
|
+
* Applies the default state policy for the operation. An explicit state takes precedence.
|
|
593
|
+
*/
|
|
594
|
+
action?: 'Consult' | 'Transfer';
|
|
577
595
|
};
|
|
578
596
|
|
|
579
597
|
/**
|
|
@@ -587,11 +605,15 @@ export type ConfigFlags = {
|
|
|
587
605
|
webRtcEnabled: boolean;
|
|
588
606
|
autoWrapup: boolean;
|
|
589
607
|
aiFeature?: AIFeatureFlags;
|
|
608
|
+
/** Agent-profile policy used to derive task consult/transfer destination controls. */
|
|
609
|
+
consultTransfer?: Contact.ConsultTransferDestinationConfig;
|
|
590
610
|
/**
|
|
591
611
|
* Optional toggle to globally enable/disable recording controls.
|
|
592
612
|
* Falls back to backend hints when omitted.
|
|
593
613
|
*/
|
|
594
614
|
isRecordingEnabled?: boolean;
|
|
615
|
+
/** Whether wxApp thick-client answer controls/APIs are enabled (WXCC-6026) */
|
|
616
|
+
enableWxBetterTogether?: boolean;
|
|
595
617
|
};
|
|
596
618
|
|
|
597
619
|
/**
|
|
@@ -681,10 +703,12 @@ export interface AddressBookEntrySearchParams extends BaseSearchParams {
|
|
|
681
703
|
export interface EntryPointRecord {
|
|
682
704
|
id: string;
|
|
683
705
|
name: string;
|
|
706
|
+
/** Dialled number mapped to this entry point when included in the list response. */
|
|
707
|
+
number?: string;
|
|
684
708
|
description?: string;
|
|
685
|
-
type
|
|
686
|
-
isActive
|
|
687
|
-
orgId
|
|
709
|
+
type?: string;
|
|
710
|
+
isActive?: boolean;
|
|
711
|
+
orgId?: string;
|
|
688
712
|
createdAt?: string;
|
|
689
713
|
updatedAt?: string;
|
|
690
714
|
settings?: Record<string, any>;
|
package/src/utils/AGENTS.md
CHANGED
|
@@ -12,7 +12,7 @@ The utils scope currently provides shared pagination and cache behavior for cont
|
|
|
12
12
|
|
|
13
13
|
- **Typed Pagination Contracts**: Reusable interfaces for response metadata and query params
|
|
14
14
|
- **Generic In-Memory Page Caching**: `PageCache<T>` utility for simple pagination reuse
|
|
15
|
-
- **Cache Safety Rules**: Explicit bypass behavior for
|
|
15
|
+
- **Cache Safety Rules**: Explicit bypass behavior for query variants and enabled result/response-shape flags
|
|
16
16
|
- **Spec-Driven Utility Workflow**: Utility-specific implementation and validation flow documented inline in this file
|
|
17
17
|
|
|
18
18
|
| Component | File | Description |
|
|
@@ -36,7 +36,7 @@ src/utils/
|
|
|
36
36
|
|
|
37
37
|
## PageCache Utility
|
|
38
38
|
|
|
39
|
-
`PageCache<T>` provides a consistent caching model for paginated list APIs. It is optimized for simple page browsing and intentionally bypasses cache for parameterized query cases (`search`, `filter`, `attributes`, `sortBy`).
|
|
39
|
+
`PageCache<T>` provides a consistent caching model for paginated list APIs. It is optimized for simple page browsing and intentionally bypasses cache for parameterized query cases (`search`, `filter`, `attributes`, `sortBy`) and enabled result/response-shape flags (`desktopProfileFilter`, `provisioningView`, `singleObjectResponse`).
|
|
40
40
|
|
|
41
41
|
### Reference Usage
|
|
42
42
|
|
|
@@ -49,8 +49,16 @@ const page = PAGINATION_DEFAULTS.PAGE;
|
|
|
49
49
|
const pageSize = PAGINATION_DEFAULTS.PAGE_SIZE;
|
|
50
50
|
const cacheKey = cache.buildCacheKey(scopeId, page, pageSize);
|
|
51
51
|
|
|
52
|
-
// Include
|
|
53
|
-
const canUseCache = cache.canUseCache({
|
|
52
|
+
// Include every supported result- or response-shape-changing input.
|
|
53
|
+
const canUseCache = cache.canUseCache({
|
|
54
|
+
search,
|
|
55
|
+
filter,
|
|
56
|
+
attributes,
|
|
57
|
+
sortBy,
|
|
58
|
+
desktopProfileFilter,
|
|
59
|
+
provisioningView,
|
|
60
|
+
singleObjectResponse,
|
|
61
|
+
});
|
|
54
62
|
|
|
55
63
|
if (canUseCache) {
|
|
56
64
|
const cachedEntry = cache.getCachedPage(cacheKey);
|
|
@@ -80,7 +88,7 @@ return response;
|
|
|
80
88
|
```mermaid
|
|
81
89
|
graph TD
|
|
82
90
|
A[Request arrives with scopeId/page/pageSize] --> B{canUseCache?}
|
|
83
|
-
B -->|No:
|
|
91
|
+
B -->|No: query variant or enabled result/shape flag| C[Bypass cache and call API]
|
|
84
92
|
B -->|Yes| D[buildCacheKey scopeId:page:pageSize]
|
|
85
93
|
D --> E["getCachedPage(cacheKey)"]
|
|
86
94
|
E -->|Miss| C
|
|
@@ -138,11 +146,14 @@ Contract passed to `canUseCache()`:
|
|
|
138
146
|
- `filter?: string`
|
|
139
147
|
- `attributes?: string`
|
|
140
148
|
- `sortBy?: string`
|
|
149
|
+
- `desktopProfileFilter?: boolean`
|
|
150
|
+
- `provisioningView?: boolean`
|
|
151
|
+
- `singleObjectResponse?: boolean`
|
|
141
152
|
|
|
142
153
|
Behavior note:
|
|
143
154
|
|
|
144
|
-
- Cache bypass is triggered by
|
|
145
|
-
-
|
|
155
|
+
- Cache bypass is triggered by a truthy query variant or enabled result/response-shape flag; an explicit `false` boolean remains cache-compatible because it is semantically equivalent to omission.
|
|
156
|
+
- `sortOrder` is not a `CacheValidationParams` field. A service where it changes the wire order without `sortBy` must pass an effective `sortBy`; Queue normalizes a direction-only request to `sortBy: 'name'` before cache validation.
|
|
146
157
|
|
|
147
158
|
### `BaseSearchParams`
|
|
148
159
|
|
|
@@ -175,8 +186,9 @@ Returns `true` only when all of these are absent:
|
|
|
175
186
|
- `filter`
|
|
176
187
|
- `attributes`
|
|
177
188
|
- `sortBy`
|
|
189
|
+
- `desktopProfileFilter`, `provisioningView`, or `singleObjectResponse` when `true`
|
|
178
190
|
|
|
179
|
-
`
|
|
191
|
+
An explicit `false` boolean remains eligible. `sortOrder` is normalized by the consuming service when it changes the effective wire order; Queue passes `sortBy: 'name'` for a direction-only request.
|
|
180
192
|
|
|
181
193
|
### `buildCacheKey(scopeId: string, page: number, pageSize: number): string`
|
|
182
194
|
|
|
@@ -223,7 +235,6 @@ Current consumers of `PageCache` and defaults:
|
|
|
223
235
|
| Consumer | File | Usage |
|
|
224
236
|
| ----------------------- | ---------------------------------------------------------- | ------------------------------------------------------------ |
|
|
225
237
|
| `AddressBook` | [`../services/AddressBook.ts`](../services/AddressBook.ts) | Caches paged address-book responses |
|
|
226
|
-
| `EntryPoint` | [`../services/EntryPoint.ts`](../services/EntryPoint.ts) | Caches paged entry-point responses |
|
|
227
238
|
| `Queue` | [`../services/Queue.ts`](../services/Queue.ts) | Caches paged queue responses |
|
|
228
239
|
| `Public type contracts` | [`../types.ts`](../types.ts) | Re-exports pagination/search contracts into SDK-facing types |
|
|
229
240
|
|
|
@@ -268,7 +279,7 @@ flowchart TD
|
|
|
268
279
|
- [ ] `canUseCache()` bypass conditions are unchanged or intentionally updated
|
|
269
280
|
- [ ] `totalRecords`/`totalItems` mapping behavior is preserved
|
|
270
281
|
- [ ] Logging still uses `LoggerProxy` with `module` and `method`
|
|
271
|
-
- [ ] AddressBook/
|
|
282
|
+
- [ ] AddressBook/Queue cache integration remains correct; EntryPoint remains explicitly uncached
|
|
272
283
|
|
|
273
284
|
---
|
|
274
285
|
|
package/src/utils/PageCache.ts
CHANGED
|
@@ -97,6 +97,12 @@ export interface CacheValidationParams {
|
|
|
97
97
|
attributes?: string;
|
|
98
98
|
/** Sort by parameter */
|
|
99
99
|
sortBy?: string;
|
|
100
|
+
/** Desktop-profile filtering changes the returned result set */
|
|
101
|
+
desktopProfileFilter?: boolean;
|
|
102
|
+
/** Provisioning-view filtering changes the returned result set */
|
|
103
|
+
provisioningView?: boolean;
|
|
104
|
+
/** Single-object response mode changes the response shape */
|
|
105
|
+
singleObjectResponse?: boolean;
|
|
100
106
|
}
|
|
101
107
|
|
|
102
108
|
/**
|
|
@@ -116,8 +122,18 @@ const DEFAULT_CACHE_TTL_MINUTES = 5;
|
|
|
116
122
|
* // Create a cache instance for a specific data type
|
|
117
123
|
* const cache = new PageCache<AddressBookEntry>('AddressBook');
|
|
118
124
|
*
|
|
119
|
-
* // Check if we can use cache
|
|
120
|
-
* if (
|
|
125
|
+
* // Check if we can use cache for the complete result/response-shape input set
|
|
126
|
+
* if (
|
|
127
|
+
* cache.canUseCache({
|
|
128
|
+
* search,
|
|
129
|
+
* filter,
|
|
130
|
+
* attributes,
|
|
131
|
+
* sortBy,
|
|
132
|
+
* desktopProfileFilter,
|
|
133
|
+
* provisioningView,
|
|
134
|
+
* singleObjectResponse,
|
|
135
|
+
* })
|
|
136
|
+
* ) {
|
|
121
137
|
* const cacheKey = cache.buildCacheKey(orgId, page, pageSize);
|
|
122
138
|
* const cachedPage = cache.getCachedPage(cacheKey);
|
|
123
139
|
*
|
|
@@ -145,15 +161,32 @@ export class PageCache<T> {
|
|
|
145
161
|
|
|
146
162
|
/**
|
|
147
163
|
* Checks if cache can be used for the given parameters.
|
|
148
|
-
* Cache is only used for simple pagination without
|
|
164
|
+
* Cache is only used for simple pagination without query variants or enabled
|
|
165
|
+
* result/response-shape flags.
|
|
149
166
|
* @param {CacheValidationParams} params - Parameters to validate
|
|
150
167
|
* @returns {boolean} True if cache can be used
|
|
151
168
|
* @public
|
|
152
169
|
*/
|
|
153
170
|
public canUseCache(params: CacheValidationParams): boolean {
|
|
154
|
-
const {
|
|
171
|
+
const {
|
|
172
|
+
search,
|
|
173
|
+
filter,
|
|
174
|
+
attributes,
|
|
175
|
+
sortBy,
|
|
176
|
+
desktopProfileFilter,
|
|
177
|
+
provisioningView,
|
|
178
|
+
singleObjectResponse,
|
|
179
|
+
} = params;
|
|
155
180
|
|
|
156
|
-
return
|
|
181
|
+
return (
|
|
182
|
+
!search &&
|
|
183
|
+
!filter &&
|
|
184
|
+
!attributes &&
|
|
185
|
+
!sortBy &&
|
|
186
|
+
!desktopProfileFilter &&
|
|
187
|
+
!provisioningView &&
|
|
188
|
+
!singleObjectResponse
|
|
189
|
+
);
|
|
157
190
|
}
|
|
158
191
|
|
|
159
192
|
/**
|