@webex/contact-center 3.12.0-llmrefactor.12 → 3.12.0-llmrefactor.14

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 (107) hide show
  1. package/.sdd/manifest.json +6 -5
  2. package/ai-docs/CONTRACTS.md +8 -0
  3. package/ai-docs/SERVICE_STATE.md +4 -0
  4. package/ai-docs/contact-center-spec.md +26 -3
  5. package/ai-docs/features/contact-owner-change-refactor.md +78 -0
  6. package/dist/cc.js +202 -9
  7. package/dist/cc.js.map +1 -1
  8. package/dist/constants.js +5 -1
  9. package/dist/constants.js.map +1 -1
  10. package/dist/index.js +25 -10
  11. package/dist/index.js.map +1 -1
  12. package/dist/metrics/behavioral-events.js +6 -0
  13. package/dist/metrics/behavioral-events.js.map +1 -1
  14. package/dist/metrics/constants.js +6 -0
  15. package/dist/metrics/constants.js.map +1 -1
  16. package/dist/services/AnswerCallOnWebexService.js +4 -4
  17. package/dist/services/AnswerCallOnWebexService.js.map +1 -1
  18. package/dist/services/ApiAiAssistant.js +116 -1
  19. package/dist/services/ApiAiAssistant.js.map +1 -1
  20. package/dist/services/WebexCrossClientService.js +5 -2
  21. package/dist/services/WebexCrossClientService.js.map +1 -1
  22. package/dist/services/WxAppTelephonyMercurySync.js +6 -3
  23. package/dist/services/WxAppTelephonyMercurySync.js.map +1 -1
  24. package/dist/services/config/Util.js +5 -1
  25. package/dist/services/config/Util.js.map +1 -1
  26. package/dist/services/config/constants.js +10 -1
  27. package/dist/services/config/constants.js.map +1 -1
  28. package/dist/services/config/index.js +51 -0
  29. package/dist/services/config/index.js.map +1 -1
  30. package/dist/services/config/types.js +4 -3
  31. package/dist/services/config/types.js.map +1 -1
  32. package/dist/services/core/Utils.js +5 -1
  33. package/dist/services/core/Utils.js.map +1 -1
  34. package/dist/services/task/TaskFactory.js +1 -0
  35. package/dist/services/task/TaskFactory.js.map +1 -1
  36. package/dist/services/task/TaskManager.js +50 -58
  37. package/dist/services/task/TaskManager.js.map +1 -1
  38. package/dist/services/task/types.js.map +1 -1
  39. package/dist/services/task/voice/Voice.js +63 -44
  40. package/dist/services/task/voice/Voice.js.map +1 -1
  41. package/dist/services/task/voice/wxAppOfferObservability.js +145 -0
  42. package/dist/services/task/voice/wxAppOfferObservability.js.map +1 -0
  43. package/dist/services/task/voice/wxAppVoiceMethods.js +52 -11
  44. package/dist/services/task/voice/wxAppVoiceMethods.js.map +1 -1
  45. package/dist/services/wxAppDiagnosticLogging.js +50 -13
  46. package/dist/services/wxAppDiagnosticLogging.js.map +1 -1
  47. package/dist/types/cc.d.ts +21 -1
  48. package/dist/types/constants.d.ts +4 -0
  49. package/dist/types/index.d.ts +11 -1
  50. package/dist/types/metrics/constants.d.ts +6 -0
  51. package/dist/types/services/ApiAiAssistant.d.ts +35 -2
  52. package/dist/types/services/config/constants.d.ts +5 -0
  53. package/dist/types/services/config/types.d.ts +15 -2
  54. package/dist/types/services/core/Utils.d.ts +2 -0
  55. package/dist/types/services/task/types.d.ts +2 -0
  56. package/dist/types/services/task/voice/Voice.d.ts +15 -2
  57. package/dist/types/services/task/voice/wxAppOfferObservability.d.ts +39 -0
  58. package/dist/types/services/task/voice/wxAppVoiceMethods.d.ts +19 -6
  59. package/dist/types/services/wxAppDiagnosticLogging.d.ts +12 -0
  60. package/dist/types/types.d.ts +56 -1
  61. package/dist/types.js +39 -2
  62. package/dist/types.js.map +1 -1
  63. package/dist/webex.js +9 -1
  64. package/dist/webex.js.map +1 -1
  65. package/package.json +9 -9
  66. package/src/cc.ts +294 -25
  67. package/src/constants.ts +4 -0
  68. package/src/index.ts +11 -0
  69. package/src/metrics/ai-docs/metrics-spec.md +61 -20
  70. package/src/metrics/behavioral-events.ts +6 -0
  71. package/src/metrics/constants.ts +6 -0
  72. package/src/services/AnswerCallOnWebexService.ts +4 -4
  73. package/src/services/ApiAiAssistant.ts +153 -1
  74. package/src/services/WebexCrossClientService.ts +7 -2
  75. package/src/services/WxAppTelephonyMercurySync.ts +3 -3
  76. package/src/services/ai-docs/services-spec.md +11 -3
  77. package/src/services/config/Util.ts +6 -0
  78. package/src/services/config/ai-docs/config-spec.md +14 -3
  79. package/src/services/config/constants.ts +12 -0
  80. package/src/services/config/index.ts +65 -0
  81. package/src/services/config/types.ts +13 -2
  82. package/src/services/core/Utils.ts +4 -0
  83. package/src/services/task/TaskFactory.ts +1 -0
  84. package/src/services/task/TaskManager.ts +85 -87
  85. package/src/services/task/ai-docs/task-spec.md +7 -3
  86. package/src/services/task/types.ts +16 -0
  87. package/src/services/task/voice/Voice.ts +74 -52
  88. package/src/services/task/voice/wxAppOfferObservability.ts +204 -0
  89. package/src/services/task/voice/wxAppVoiceMethods.ts +83 -24
  90. package/src/services/wxAppDiagnosticLogging.ts +135 -23
  91. package/src/types.ts +65 -0
  92. package/src/webex.js +8 -0
  93. package/test/unit/spec/cc.ts +469 -19
  94. package/test/unit/spec/services/ApiAiAssistant.ts +134 -2
  95. package/test/unit/spec/services/WebexCrossClientService.ts +45 -3
  96. package/test/unit/spec/services/WxAppTelephonyMercurySync.ts +1 -1
  97. package/test/unit/spec/services/config/Util.ts +44 -0
  98. package/test/unit/spec/services/config/index.ts +68 -0
  99. package/test/unit/spec/services/task/TaskManager.ts +214 -3
  100. package/test/unit/spec/services/task/state-machine/TaskStateMachine.ts +33 -0
  101. package/test/unit/spec/services/task/voice/Voice.ts +10 -51
  102. package/test/unit/spec/services/task/voice/wxAppOfferObservability.ts +361 -0
  103. package/test/unit/spec/services/task/voice/wxAppVoiceMethods.ts +121 -5
  104. package/test/unit/spec/services/wxAppDiagnosticLogging.ts +44 -8
  105. package/test/unit/spec/wellnessSampleUtils.ts +288 -0
  106. package/umd/contact-center.min.js +2 -2
  107. package/umd/contact-center.min.js.map +1 -1
@@ -31,16 +31,54 @@ export function callIdSuffix(callId: string | null | undefined): string | undefi
31
31
  return callId.length <= 8 ? callId : callId.slice(-8);
32
32
  }
33
33
 
34
- function logWxApp(message: string, method: string, data: WxAppLogData): void {
35
- LoggerProxy.info(`${WXAPP_LOG_PREFIX} ${message}`, {
34
+ function formatLogSuffix(data: WxAppLogData, keys?: string[]): string {
35
+ const entries = keys
36
+ ? keys.map((key) => [key, data[key]] as const)
37
+ : Object.entries(data).filter(([key]) => key !== 'feature' && key !== 'event');
38
+
39
+ const parts = entries
40
+ .filter(([, value]) => value !== undefined && value !== null && value !== '')
41
+ .map(([key, value]) => `${key}=${String(value)}`);
42
+
43
+ return parts.length > 0 ? ` ${parts.join(' ')}` : '';
44
+ }
45
+
46
+ function logWxApp(
47
+ message: string,
48
+ method: string,
49
+ data: WxAppLogData,
50
+ suffixKeys?: string[]
51
+ ): void {
52
+ const suffix = formatLogSuffix(data, suffixKeys);
53
+ LoggerProxy.log(`${WXAPP_LOG_PREFIX} ${message}${suffix}`, {
54
+ module: 'wxAppDiagnosticLogging',
55
+ method,
56
+ data: {feature: WXAPP_LOG_FEATURE, ...data},
57
+ });
58
+ }
59
+
60
+ function logWxAppWarn(
61
+ message: string,
62
+ method: string,
63
+ data: WxAppLogData,
64
+ suffixKeys?: string[]
65
+ ): void {
66
+ const suffix = formatLogSuffix(data, suffixKeys);
67
+ LoggerProxy.warn(`${WXAPP_LOG_PREFIX} ${message}${suffix}`, {
36
68
  module: 'wxAppDiagnosticLogging',
37
69
  method,
38
70
  data: {feature: WXAPP_LOG_FEATURE, ...data},
39
71
  });
40
72
  }
41
73
 
42
- function logWxAppError(message: string, method: string, data: WxAppLogData): void {
43
- LoggerProxy.error(`${WXAPP_LOG_PREFIX} ${message}`, {
74
+ function logWxAppError(
75
+ message: string,
76
+ method: string,
77
+ data: WxAppLogData,
78
+ suffixKeys?: string[]
79
+ ): void {
80
+ const suffix = formatLogSuffix(data, suffixKeys);
81
+ LoggerProxy.error(`${WXAPP_LOG_PREFIX} ${message}${suffix}`, {
44
82
  module: 'wxAppDiagnosticLogging',
45
83
  method,
46
84
  data: {feature: WXAPP_LOG_FEATURE, ...data},
@@ -56,7 +94,7 @@ export function logWxAppSessionReadiness(params: {
56
94
  telephonyTaskType: 'Voice' | 'WebRTC' | 'unknown';
57
95
  skipReason?: WxAppSessionSkipReason;
58
96
  }): void {
59
- logWxApp('session readiness', 'logWxAppSessionReadiness', {
97
+ const data: WxAppLogData = {
60
98
  event: 'session_readiness',
61
99
  enableWxBetterTogether: params.enableWxBetterTogether,
62
100
  loginOption: params.loginOption,
@@ -65,7 +103,16 @@ export function logWxAppSessionReadiness(params: {
65
103
  mercurySubscribed: params.mercurySubscribed,
66
104
  telephonyTaskType: params.telephonyTaskType,
67
105
  skipReason: params.skipReason,
68
- });
106
+ };
107
+
108
+ logWxApp('session readiness', 'logWxAppSessionReadiness', data, [
109
+ 'usersubPublished',
110
+ 'mercurySubscribed',
111
+ 'loginOption',
112
+ 'enableWxBetterTogether',
113
+ 'telephonyTaskType',
114
+ 'skipReason',
115
+ ]);
69
116
  }
70
117
 
71
118
  export function deriveWxAppAcceptReason(params: {
@@ -111,8 +158,10 @@ export function logWxAppOfferDecision(params: {
111
158
  acceptReason: WxAppAcceptReason;
112
159
  wxAppParticipantDeviceType?: string;
113
160
  hasDeviceCallId: boolean;
161
+ hasDeviceId?: boolean;
162
+ usersubPublished?: boolean;
114
163
  }): void {
115
- logWxApp('offer decision', 'logWxAppOfferDecision', {
164
+ const data: WxAppLogData = {
116
165
  event: 'offer_decision',
117
166
  interactionId: params.interactionId,
118
167
  acceptVisible: params.acceptVisible,
@@ -120,7 +169,51 @@ export function logWxAppOfferDecision(params: {
120
169
  acceptReason: params.acceptReason,
121
170
  wxAppParticipantDeviceType: params.wxAppParticipantDeviceType,
122
171
  hasDeviceCallId: params.hasDeviceCallId,
123
- });
172
+ hasDeviceId: params.hasDeviceId,
173
+ usersubPublished: params.usersubPublished,
174
+ };
175
+
176
+ logWxApp('offer decision', 'logWxAppOfferDecision', data, [
177
+ 'acceptReason',
178
+ 'hasDeviceCallId',
179
+ 'hasDeviceId',
180
+ 'usersubPublished',
181
+ 'interactionId',
182
+ 'acceptVisible',
183
+ 'acceptEnabled',
184
+ ]);
185
+ }
186
+
187
+ export function logWxAppOfferParticipantMismatch(params: {
188
+ interactionId: string;
189
+ usersubPublished: boolean;
190
+ hasDeviceCallId: boolean;
191
+ hasDeviceId: boolean;
192
+ participantDeviceType?: string;
193
+ acceptVisible: boolean;
194
+ acceptEnabled: boolean;
195
+ acceptReason: WxAppAcceptReason;
196
+ }): void {
197
+ const data: WxAppLogData = {
198
+ event: 'participant_fields_mismatch',
199
+ interactionId: params.interactionId,
200
+ usersubPublished: params.usersubPublished,
201
+ hasDeviceCallId: params.hasDeviceCallId,
202
+ hasDeviceId: params.hasDeviceId,
203
+ participantDeviceType: params.participantDeviceType ?? 'missing',
204
+ acceptVisible: params.acceptVisible,
205
+ acceptEnabled: params.acceptEnabled,
206
+ acceptReason: params.acceptReason,
207
+ };
208
+
209
+ logWxAppWarn('participant fields mismatch', 'logWxAppOfferParticipantMismatch', data, [
210
+ 'usersubPublished',
211
+ 'hasDeviceCallId',
212
+ 'hasDeviceId',
213
+ 'acceptReason',
214
+ 'interactionId',
215
+ 'participantDeviceType',
216
+ ]);
124
217
  }
125
218
 
126
219
  export function logWxAppTelephonyAction(params: {
@@ -142,18 +235,32 @@ export function logWxAppTelephonyAction(params: {
142
235
  };
143
236
 
144
237
  if (params.phase === 'failed') {
145
- logWxAppError(`telephony ${params.action} ${params.phase}`, 'logWxAppTelephonyAction', payload);
238
+ logWxAppError(
239
+ `telephony ${params.action} ${params.phase}`,
240
+ 'logWxAppTelephonyAction',
241
+ payload,
242
+ ['interactionId', 'trackingId', 'httpStatus', 'failureReason']
243
+ );
146
244
  } else {
147
- logWxApp(`telephony ${params.action} ${params.phase}`, 'logWxAppTelephonyAction', payload);
245
+ logWxApp(`telephony ${params.action} ${params.phase}`, 'logWxAppTelephonyAction', payload, [
246
+ 'interactionId',
247
+ 'action',
248
+ 'phase',
249
+ ]);
148
250
  }
149
251
  }
150
252
 
151
253
  export function logWxAppValidationFailure(reason: string, interactionId?: string): void {
152
- logWxAppError('validation failed', 'logWxAppValidationFailure', {
153
- event: 'validation_failed',
154
- reason,
155
- interactionId,
156
- });
254
+ logWxAppError(
255
+ 'validation failed',
256
+ 'logWxAppValidationFailure',
257
+ {
258
+ event: 'validation_failed',
259
+ reason,
260
+ interactionId,
261
+ },
262
+ ['reason', 'interactionId']
263
+ );
157
264
  }
158
265
 
159
266
  export function logWxAppMercuryMuteSync(params: {
@@ -163,12 +270,17 @@ export function logWxAppMercuryMuteSync(params: {
163
270
  interactionId?: string;
164
271
  dropReason?: string;
165
272
  }): void {
166
- logWxApp(`mercury mute sync ${params.phase}`, 'logWxAppMercuryMuteSync', {
167
- event: 'mercury_mute_sync',
168
- phase: params.phase,
169
- muted: params.muted,
170
- callIdSuffix: params.callIdSuffix,
171
- interactionId: params.interactionId,
172
- dropReason: params.dropReason,
173
- });
273
+ logWxApp(
274
+ `mercury mute sync ${params.phase}`,
275
+ 'logWxAppMercuryMuteSync',
276
+ {
277
+ event: 'mercury_mute_sync',
278
+ phase: params.phase,
279
+ muted: params.muted,
280
+ callIdSuffix: params.callIdSuffix,
281
+ interactionId: params.interactionId,
282
+ dropReason: params.dropReason,
283
+ },
284
+ ['phase', 'muted', 'callIdSuffix', 'interactionId', 'dropReason']
285
+ );
174
286
  }
package/src/types.ts CHANGED
@@ -8,6 +8,7 @@ import * as Agent from './services/agent/types';
8
8
  import * as Contact from './services/task/types';
9
9
  import {
10
10
  AIFeatureFlags,
11
+ Entity,
11
12
  Profile,
12
13
  CreateUserPreferenceRequest,
13
14
  UpdateUserPreferenceRequest,
@@ -419,6 +420,9 @@ export interface IContactCenter {
419
420
  * cc.register().then(profile => { ... });
420
421
  */
421
422
  register(): Promise<Profile>;
423
+
424
+ /** Returns the system-managed WellbeingBreak idle code for the registered session. */
425
+ getWellbeingBreakIdleCode(): Promise<Entity>;
422
426
  }
423
427
 
424
428
  /**
@@ -614,6 +618,8 @@ export type ConfigFlags = {
614
618
  isRecordingEnabled?: boolean;
615
619
  /** Whether wxApp thick-client answer controls/APIs are enabled (WXCC-6026) */
616
620
  enableWxBetterTogether?: boolean;
621
+ /** Read-only observability: live usersub answer-calls-on-wxcc state for wxApp offer diagnostics. */
622
+ getWxAppUsersubPublished?: () => boolean;
617
623
  };
618
624
 
619
625
  /**
@@ -945,6 +951,63 @@ export type RealTimeAssistanceUserActionParams = {
945
951
  languageCode?: string;
946
952
  };
947
953
 
954
+ /**
955
+ * Wellness notification actions delivered by the Contact Center notification service.
956
+ * @public
957
+ */
958
+ export const WELLNESS_BREAK_NOTIFICATION_ACTIONS = {
959
+ PROVIDE_WELLNESS_BREAK: 'PROVIDE_WELLNESS_BREAK',
960
+ SUGGEST_WELLNESS_BREAK: 'SUGGEST_WELLNESS_BREAK',
961
+ WELLNESS_BREAK_NOT_ALLOWED: 'WELLNESS_BREAK_NOT_ALLOWED',
962
+ } as const;
963
+
964
+ /** Union of supported wellness notification actions. @public */
965
+ export type WellnessBreakNotificationAction = Enum<typeof WELLNESS_BREAK_NOTIFICATION_ACTIONS>;
966
+
967
+ /**
968
+ * Agent actions accepted by the wellness action API.
969
+ * @public
970
+ */
971
+ export const WELLNESS_BREAK_USER_ACTIONS = {
972
+ REQUESTED: 'REQUESTED',
973
+ ACCEPTED: 'ACCEPTED',
974
+ REJECTED: 'REJECTED',
975
+ NO_RESPONSE: 'NO_RESPONSE',
976
+ } as const;
977
+
978
+ /** Union of supported wellness action API values. @public */
979
+ export type WellnessBreakUserAction = Enum<typeof WELLNESS_BREAK_USER_ACTIONS>;
980
+
981
+ /**
982
+ * Validated, agent-scoped wellness notification emitted by Contact Center.
983
+ * @public
984
+ */
985
+ export interface WellnessBreakEvent {
986
+ /** Agent identifier */
987
+ agentId: string;
988
+ /** Organization identifier */
989
+ orgId: string;
990
+ /** Session identifier supplied by the notification; it may differ from the consumer's active session */
991
+ agentSessionId: string;
992
+ /** Backend wellness action */
993
+ actionEvent: WellnessBreakNotificationAction;
994
+ /** Optional untrusted plain-text message supplied by the backend */
995
+ actionText?: string;
996
+ /** Optional normalized interaction diagnostic */
997
+ interactionId?: string;
998
+ /** Notification diagnostic only; never an action-request correlation identifier */
999
+ trackingId?: string;
1000
+ }
1001
+
1002
+ /**
1003
+ * Parameters for responding to a backend-provided wellness offer.
1004
+ * @public
1005
+ */
1006
+ export interface RespondToWellnessBreakParams {
1007
+ /** Agent response; REQUESTED is available only through requestWellnessBreak */
1008
+ action: Exclude<WellnessBreakUserAction, typeof WELLNESS_BREAK_USER_ACTIONS.REQUESTED>;
1009
+ }
1010
+
948
1011
  /**
949
1012
  * Supported AI Assistant event categories.
950
1013
  * @public
@@ -994,6 +1057,8 @@ export const AIAssistantEventName = {
994
1057
  SUGGESTED_RESPONSES_DIGITAL: 'SUGGESTED_RESPONSES_DIGITAL',
995
1058
  /** User action on a suggested response adaptive card */
996
1059
  SUGGESTED_RESPONSES_USER_ACTION: 'SUGGESTED_RESPONSES_USER_ACTION',
1060
+ /** Agent Wellness Break request/response action */
1061
+ WELLNESS_BREAK_ACTION: 'WellnessBreakAction',
997
1062
  } as const;
998
1063
 
999
1064
  /**
package/src/webex.js CHANGED
@@ -9,6 +9,8 @@ import '@webex/internal-plugin-support';
9
9
  import './index';
10
10
 
11
11
  import config from './webex-config';
12
+ import {CC_AGENT_EVENTS} from './services/config/types';
13
+ import {WELLNESS_BREAK_NOTIFICATION_ACTIONS, WELLNESS_BREAK_USER_ACTIONS} from './types';
12
14
 
13
15
  export * from './index';
14
16
 
@@ -30,6 +32,12 @@ const Webex = WebexCore.extend({
30
32
  version: PACKAGE_VERSION,
31
33
  });
32
34
 
35
+ // The standalone UMD bundle exports the Webex constructor as its default value. Attach the
36
+ // public agent-event contract so browser samples can use the same constants as module consumers.
37
+ Webex.CC_AGENT_EVENTS = CC_AGENT_EVENTS;
38
+ Webex.WELLNESS_BREAK_NOTIFICATION_ACTIONS = WELLNESS_BREAK_NOTIFICATION_ACTIONS;
39
+ Webex.WELLNESS_BREAK_USER_ACTIONS = WELLNESS_BREAK_USER_ACTIONS;
40
+
33
41
  /**
34
42
  * Initializes a new Webex instance with merged configuration.
35
43
  *