@webex/contact-center 3.12.0-next.73 → 3.12.0-next.75

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 (188) hide show
  1. package/AGENTS.md +438 -0
  2. package/ai-docs/README.md +131 -0
  3. package/ai-docs/RULES.md +455 -0
  4. package/ai-docs/patterns/event-driven-patterns.md +485 -0
  5. package/ai-docs/patterns/testing-patterns.md +480 -0
  6. package/ai-docs/patterns/typescript-patterns.md +365 -0
  7. package/ai-docs/templates/README.md +102 -0
  8. package/ai-docs/templates/documentation/create-agents-md.md +240 -0
  9. package/ai-docs/templates/documentation/create-architecture-md.md +295 -0
  10. package/ai-docs/templates/existing-service/bug-fix.md +254 -0
  11. package/ai-docs/templates/existing-service/feature-enhancement.md +450 -0
  12. package/ai-docs/templates/new-method/00-master.md +80 -0
  13. package/ai-docs/templates/new-method/01-requirements.md +232 -0
  14. package/ai-docs/templates/new-method/02-implementation.md +295 -0
  15. package/ai-docs/templates/new-method/03-tests.md +201 -0
  16. package/ai-docs/templates/new-method/04-validation.md +141 -0
  17. package/ai-docs/templates/new-service/00-master.md +109 -0
  18. package/ai-docs/templates/new-service/01-pre-questions.md +159 -0
  19. package/ai-docs/templates/new-service/02-code-generation.md +346 -0
  20. package/ai-docs/templates/new-service/03-integration.md +178 -0
  21. package/ai-docs/templates/new-service/04-test-generation.md +205 -0
  22. package/ai-docs/templates/new-service/05-validation.md +145 -0
  23. package/dist/cc.js +53 -38
  24. package/dist/cc.js.map +1 -1
  25. package/dist/config.js +6 -0
  26. package/dist/config.js.map +1 -1
  27. package/dist/constants.js +14 -1
  28. package/dist/constants.js.map +1 -1
  29. package/dist/index.js +13 -5
  30. package/dist/index.js.map +1 -1
  31. package/dist/metrics/behavioral-events.js +26 -0
  32. package/dist/metrics/behavioral-events.js.map +1 -1
  33. package/dist/metrics/constants.js +9 -3
  34. package/dist/metrics/constants.js.map +1 -1
  35. package/dist/services/ApiAiAssistant.js +74 -3
  36. package/dist/services/ApiAiAssistant.js.map +1 -1
  37. package/dist/services/config/Util.js +2 -2
  38. package/dist/services/config/Util.js.map +1 -1
  39. package/dist/services/config/types.js +25 -9
  40. package/dist/services/config/types.js.map +1 -1
  41. package/dist/services/core/Utils.js +74 -27
  42. package/dist/services/core/Utils.js.map +1 -1
  43. package/dist/services/core/websocket/WebSocketManager.js +2 -1
  44. package/dist/services/core/websocket/WebSocketManager.js.map +1 -1
  45. package/dist/services/core/websocket/types.js.map +1 -1
  46. package/dist/services/index.js +1 -1
  47. package/dist/services/index.js.map +1 -1
  48. package/dist/services/task/Task.js +688 -0
  49. package/dist/services/task/Task.js.map +1 -0
  50. package/dist/services/task/TaskFactory.js +45 -0
  51. package/dist/services/task/TaskFactory.js.map +1 -0
  52. package/dist/services/task/TaskManager.js +725 -612
  53. package/dist/services/task/TaskManager.js.map +1 -1
  54. package/dist/services/task/TaskUtils.js +162 -26
  55. package/dist/services/task/TaskUtils.js.map +1 -1
  56. package/dist/services/task/constants.js +6 -1
  57. package/dist/services/task/constants.js.map +1 -1
  58. package/dist/services/task/digital/Digital.js +77 -0
  59. package/dist/services/task/digital/Digital.js.map +1 -0
  60. package/dist/services/task/state-machine/TaskStateMachine.js +837 -0
  61. package/dist/services/task/state-machine/TaskStateMachine.js.map +1 -0
  62. package/dist/services/task/state-machine/actions.js +543 -0
  63. package/dist/services/task/state-machine/actions.js.map +1 -0
  64. package/dist/services/task/state-machine/constants.js +161 -0
  65. package/dist/services/task/state-machine/constants.js.map +1 -0
  66. package/dist/services/task/state-machine/guards.js +340 -0
  67. package/dist/services/task/state-machine/guards.js.map +1 -0
  68. package/dist/services/task/state-machine/index.js +53 -0
  69. package/dist/services/task/state-machine/index.js.map +1 -0
  70. package/dist/services/task/state-machine/types.js +54 -0
  71. package/dist/services/task/state-machine/types.js.map +1 -0
  72. package/dist/services/task/state-machine/uiControlsComputer.js +553 -0
  73. package/dist/services/task/state-machine/uiControlsComputer.js.map +1 -0
  74. package/dist/services/task/taskDataNormalizer.js +99 -0
  75. package/dist/services/task/taskDataNormalizer.js.map +1 -0
  76. package/dist/services/task/types.js +168 -16
  77. package/dist/services/task/types.js.map +1 -1
  78. package/dist/services/task/voice/Voice.js +1042 -0
  79. package/dist/services/task/voice/Voice.js.map +1 -0
  80. package/dist/services/task/voice/WebRTC.js +149 -0
  81. package/dist/services/task/voice/WebRTC.js.map +1 -0
  82. package/dist/types/cc.d.ts +19 -18
  83. package/dist/types/config.d.ts +6 -0
  84. package/dist/types/constants.d.ts +14 -1
  85. package/dist/types/index.d.ts +11 -5
  86. package/dist/types/metrics/constants.d.ts +7 -1
  87. package/dist/types/services/ApiAiAssistant.d.ts +11 -3
  88. package/dist/types/services/config/types.d.ts +113 -9
  89. package/dist/types/services/core/Utils.d.ts +23 -10
  90. package/dist/types/services/core/websocket/WebSocketManager.d.ts +1 -0
  91. package/dist/types/services/core/websocket/types.d.ts +1 -1
  92. package/dist/types/services/index.d.ts +1 -1
  93. package/dist/types/services/task/Task.d.ts +157 -0
  94. package/dist/types/services/task/TaskFactory.d.ts +12 -0
  95. package/dist/types/services/task/TaskUtils.d.ts +46 -2
  96. package/dist/types/services/task/constants.d.ts +5 -0
  97. package/dist/types/services/task/digital/Digital.d.ts +22 -0
  98. package/dist/types/services/task/state-machine/TaskStateMachine.d.ts +1144 -0
  99. package/dist/types/services/task/state-machine/actions.d.ts +10 -0
  100. package/dist/types/services/task/state-machine/constants.d.ts +107 -0
  101. package/dist/types/services/task/state-machine/guards.d.ts +90 -0
  102. package/dist/types/services/task/state-machine/index.d.ts +13 -0
  103. package/dist/types/services/task/state-machine/types.d.ts +267 -0
  104. package/dist/types/services/task/state-machine/uiControlsComputer.d.ts +9 -0
  105. package/dist/types/services/task/taskDataNormalizer.d.ts +10 -0
  106. package/dist/types/services/task/types.d.ts +551 -78
  107. package/dist/types/services/task/voice/Voice.d.ts +184 -0
  108. package/dist/types/services/task/voice/WebRTC.d.ts +53 -0
  109. package/dist/types/types.d.ts +92 -0
  110. package/dist/types/webex.d.ts +1 -0
  111. package/dist/types.js +85 -0
  112. package/dist/types.js.map +1 -1
  113. package/dist/webex.js +14 -2
  114. package/dist/webex.js.map +1 -1
  115. package/package.json +15 -12
  116. package/src/cc.ts +63 -43
  117. package/src/config.ts +6 -0
  118. package/src/constants.ts +14 -1
  119. package/src/index.ts +14 -5
  120. package/src/metrics/ai-docs/AGENTS.md +348 -0
  121. package/src/metrics/ai-docs/ARCHITECTURE.md +336 -0
  122. package/src/metrics/behavioral-events.ts +28 -0
  123. package/src/metrics/constants.ts +9 -4
  124. package/src/services/ApiAiAssistant.ts +104 -3
  125. package/src/services/agent/ai-docs/AGENTS.md +238 -0
  126. package/src/services/agent/ai-docs/ARCHITECTURE.md +302 -0
  127. package/src/services/ai-docs/AGENTS.md +384 -0
  128. package/src/services/config/Util.ts +2 -2
  129. package/src/services/config/ai-docs/AGENTS.md +253 -0
  130. package/src/services/config/ai-docs/ARCHITECTURE.md +424 -0
  131. package/src/services/config/types.ts +116 -10
  132. package/src/services/core/Utils.ts +85 -34
  133. package/src/services/core/ai-docs/AGENTS.md +379 -0
  134. package/src/services/core/ai-docs/ARCHITECTURE.md +696 -0
  135. package/src/services/core/websocket/WebSocketManager.ts +2 -0
  136. package/src/services/core/websocket/types.ts +1 -1
  137. package/src/services/index.ts +1 -1
  138. package/src/services/task/Task.ts +837 -0
  139. package/src/services/task/TaskFactory.ts +55 -0
  140. package/src/services/task/TaskManager.ts +738 -697
  141. package/src/services/task/TaskUtils.ts +205 -25
  142. package/src/services/task/ai-docs/AGENTS.md +455 -0
  143. package/src/services/task/ai-docs/ARCHITECTURE.md +585 -0
  144. package/src/services/task/constants.ts +5 -0
  145. package/src/services/task/digital/Digital.ts +95 -0
  146. package/src/services/task/state-machine/TaskStateMachine.ts +1077 -0
  147. package/src/services/task/state-machine/actions.ts +685 -0
  148. package/src/services/task/state-machine/ai-docs/AGENTS.md +495 -0
  149. package/src/services/task/state-machine/ai-docs/ARCHITECTURE.md +1135 -0
  150. package/src/services/task/state-machine/constants.ts +172 -0
  151. package/src/services/task/state-machine/guards.ts +406 -0
  152. package/src/services/task/state-machine/index.ts +28 -0
  153. package/src/services/task/state-machine/types.ts +241 -0
  154. package/src/services/task/state-machine/uiControlsComputer.ts +867 -0
  155. package/src/services/task/taskDataNormalizer.ts +137 -0
  156. package/src/services/task/types.ts +654 -85
  157. package/src/services/task/voice/Voice.ts +1267 -0
  158. package/src/services/task/voice/WebRTC.ts +187 -0
  159. package/src/types.ts +112 -1
  160. package/src/utils/AGENTS.md +276 -0
  161. package/src/webex.js +2 -0
  162. package/test/unit/spec/cc.ts +133 -3
  163. package/test/unit/spec/logger-proxy.ts +70 -0
  164. package/test/unit/spec/services/ApiAiAssistant.ts +122 -17
  165. package/test/unit/spec/services/WebCallingService.ts +7 -1
  166. package/test/unit/spec/services/config/index.ts +27 -27
  167. package/test/unit/spec/services/core/Utils.ts +335 -1
  168. package/test/unit/spec/services/core/websocket/WebSocketManager.ts +66 -40
  169. package/test/unit/spec/services/task/AutoWrapup.ts +63 -0
  170. package/test/unit/spec/services/task/Task.ts +477 -0
  171. package/test/unit/spec/services/task/TaskFactory.ts +62 -0
  172. package/test/unit/spec/services/task/TaskManager.ts +821 -1936
  173. package/test/unit/spec/services/task/TaskUtils.ts +206 -0
  174. package/test/unit/spec/services/task/digital/Digital.ts +105 -0
  175. package/test/unit/spec/services/task/state-machine/TaskStateMachine.ts +1825 -0
  176. package/test/unit/spec/services/task/state-machine/guards.ts +479 -0
  177. package/test/unit/spec/services/task/state-machine/types.ts +18 -0
  178. package/test/unit/spec/services/task/state-machine/uiControlsComputer.ts +2020 -0
  179. package/test/unit/spec/services/task/taskTestUtils.ts +87 -0
  180. package/test/unit/spec/services/task/voice/Voice.ts +631 -0
  181. package/test/unit/spec/services/task/voice/WebRTC.ts +235 -0
  182. package/umd/contact-center.min.js +2 -2
  183. package/umd/contact-center.min.js.map +1 -1
  184. package/dist/services/task/index.js +0 -1530
  185. package/dist/services/task/index.js.map +0 -1
  186. package/dist/types/services/task/index.d.ts +0 -650
  187. package/src/services/task/index.ts +0 -1806
  188. package/test/unit/spec/services/task/index.ts +0 -2205
@@ -58,6 +58,8 @@ export declare const CC_TASK_EVENTS: {
58
58
  readonly AGENT_CONFERENCE_TRANSFER_FAILED: "AgentConferenceTransferFailed";
59
59
  /** Event emitted for post-call activity by participant */
60
60
  readonly PARTICIPANT_POST_CALL_ACTIVITY: "ParticipantPostCallActivity";
61
+ /** Event emitted when consulted participant is being moved/transferred */
62
+ readonly CONSULTED_PARTICIPANT_MOVING: "ConsultedParticipantMoving";
61
63
  /** Event emitted when contact is blind transferred */
62
64
  readonly AGENT_BLIND_TRANSFERRED: "AgentBlindTransferred";
63
65
  /** Event emitted when blind transfer fails */
@@ -74,6 +76,8 @@ export declare const CC_TASK_EVENTS: {
74
76
  readonly AGENT_CONSULT_TRANSFER_FAILED: "AgentConsultTransferFailed";
75
77
  /** Event emitted when contact recording is paused */
76
78
  readonly CONTACT_RECORDING_PAUSED: "ContactRecordingPaused";
79
+ /** Event emitted when contact recording is started */
80
+ readonly CONTACT_RECORDING_STARTED: "ContactRecordingStarted";
77
81
  /** Event emitted when pausing contact recording fails */
78
82
  readonly CONTACT_RECORDING_PAUSE_FAILED: "ContactRecordingPauseFailed";
79
83
  /** Event emitted when contact recording is resumed */
@@ -84,6 +88,10 @@ export declare const CC_TASK_EVENTS: {
84
88
  readonly CONTACT_ENDED: "ContactEnded";
85
89
  /** Event emitted when contact is merged */
86
90
  readonly CONTACT_MERGED: "ContactMerged";
91
+ /** Event emitted when contact payload is updated (routing updates) */
92
+ readonly CONTACT_UPDATED: "ContactUpdated";
93
+ /** Event emitted when contact owner changes */
94
+ readonly CONTACT_OWNER_CHANGED: "ContactOwnerChanged";
87
95
  /** Event emitted when ending contact fails */
88
96
  readonly AGENT_CONTACT_END_FAILED: "AgentContactEndFailed";
89
97
  /** Event emitted when agent enters wrap-up state */
@@ -116,6 +124,14 @@ export declare const CC_TASK_EVENTS: {
116
124
  readonly CAMPAIGN_PREVIEW_REMOVE_FAILED: "CampaignPreviewRemoveFailed";
117
125
  /** Event emitted when a real-time transcript chunk is received */
118
126
  readonly REAL_TIME_TRANSCRIPTION: "REAL_TIME_TRANSCRIPTION";
127
+ /** Event emitted when an AI assistant suggested response is available */
128
+ readonly SUGGESTED_RESPONSE: "SUGGESTED_RESPONSE";
129
+ /** Event emitted when backend acknowledges it is listening for more context */
130
+ readonly SUGGESTED_RESPONSE_ACKNOWLEDGE: "SUGGESTED_RESPONSE_ACKNOWLEDGE";
131
+ /** Event emitted when a mid-call summary is available */
132
+ readonly MID_CALL_SUMMARY: "MID_CALL_SUMMARY";
133
+ /** Event emitted when a post-call summary is available */
134
+ readonly POST_CALL_SUMMARY: "POST_CALL_SUMMARY";
119
135
  };
120
136
  /**
121
137
  * Events emitted on Contact Center agent operations
@@ -219,6 +235,8 @@ export declare const CC_EVENTS: {
219
235
  readonly AGENT_CONFERENCE_TRANSFER_FAILED: "AgentConferenceTransferFailed";
220
236
  /** Event emitted for post-call activity by participant */
221
237
  readonly PARTICIPANT_POST_CALL_ACTIVITY: "ParticipantPostCallActivity";
238
+ /** Event emitted when consulted participant is being moved/transferred */
239
+ readonly CONSULTED_PARTICIPANT_MOVING: "ConsultedParticipantMoving";
222
240
  /** Event emitted when contact is blind transferred */
223
241
  readonly AGENT_BLIND_TRANSFERRED: "AgentBlindTransferred";
224
242
  /** Event emitted when blind transfer fails */
@@ -235,6 +253,8 @@ export declare const CC_EVENTS: {
235
253
  readonly AGENT_CONSULT_TRANSFER_FAILED: "AgentConsultTransferFailed";
236
254
  /** Event emitted when contact recording is paused */
237
255
  readonly CONTACT_RECORDING_PAUSED: "ContactRecordingPaused";
256
+ /** Event emitted when contact recording is started */
257
+ readonly CONTACT_RECORDING_STARTED: "ContactRecordingStarted";
238
258
  /** Event emitted when pausing contact recording fails */
239
259
  readonly CONTACT_RECORDING_PAUSE_FAILED: "ContactRecordingPauseFailed";
240
260
  /** Event emitted when contact recording is resumed */
@@ -245,6 +265,10 @@ export declare const CC_EVENTS: {
245
265
  readonly CONTACT_ENDED: "ContactEnded";
246
266
  /** Event emitted when contact is merged */
247
267
  readonly CONTACT_MERGED: "ContactMerged";
268
+ /** Event emitted when contact payload is updated (routing updates) */
269
+ readonly CONTACT_UPDATED: "ContactUpdated";
270
+ /** Event emitted when contact owner changes */
271
+ readonly CONTACT_OWNER_CHANGED: "ContactOwnerChanged";
248
272
  /** Event emitted when ending contact fails */
249
273
  readonly AGENT_CONTACT_END_FAILED: "AgentContactEndFailed";
250
274
  /** Event emitted when agent enters wrap-up state */
@@ -277,6 +301,14 @@ export declare const CC_EVENTS: {
277
301
  readonly CAMPAIGN_PREVIEW_REMOVE_FAILED: "CampaignPreviewRemoveFailed";
278
302
  /** Event emitted when a real-time transcript chunk is received */
279
303
  readonly REAL_TIME_TRANSCRIPTION: "REAL_TIME_TRANSCRIPTION";
304
+ /** Event emitted when an AI assistant suggested response is available */
305
+ readonly SUGGESTED_RESPONSE: "SUGGESTED_RESPONSE";
306
+ /** Event emitted when backend acknowledges it is listening for more context */
307
+ readonly SUGGESTED_RESPONSE_ACKNOWLEDGE: "SUGGESTED_RESPONSE_ACKNOWLEDGE";
308
+ /** Event emitted when a mid-call summary is available */
309
+ readonly MID_CALL_SUMMARY: "MID_CALL_SUMMARY";
310
+ /** Event emitted when a post-call summary is available */
311
+ readonly POST_CALL_SUMMARY: "POST_CALL_SUMMARY";
280
312
  /** Welcome event when agent connects to websocket/backend */
281
313
  readonly WELCOME: "Welcome";
282
314
  /** Event emitted when agent re-login is successful */
@@ -322,6 +354,14 @@ export type WelcomeEvent = {
322
354
  /** ID of the agent that connected */
323
355
  agentId: string;
324
356
  };
357
+ /**
358
+ * Available login options for voice channel access
359
+ * 'AGENT_DN' - Login using agent's DN
360
+ * 'EXTENSION' - Login using extension number
361
+ * 'BROWSER' - Login using browser-based WebRTC
362
+ * @public
363
+ */
364
+ export type LoginOption = 'AGENT_DN' | 'EXTENSION' | 'BROWSER';
325
365
  /**
326
366
  * Response type for welcome events which can be either success or error
327
367
  * @public
@@ -400,6 +440,26 @@ export type AgentResponse = {
400
440
  * Represents the response from getDesktopProfileById method.
401
441
  */
402
442
  export type DesktopProfileResponse = {
443
+ /**
444
+ * Unique identifier of the agent profile configuration.
445
+ */
446
+ id: string;
447
+ /**
448
+ * Display name for the agent profile.
449
+ */
450
+ name: string;
451
+ /**
452
+ * Description of the agent profile.
453
+ */
454
+ description: string;
455
+ /**
456
+ * Parent entity type for the profile (for example ORGANIZATION).
457
+ */
458
+ parentType: string;
459
+ /**
460
+ * Indicates whether screen pop is enabled.
461
+ */
462
+ screenPopup: boolean;
403
463
  /**
404
464
  * Represents the voice options of an agent.
405
465
  */
@@ -432,6 +492,10 @@ export type DesktopProfileResponse = {
432
492
  * Auto wrap-up allowed.
433
493
  */
434
494
  autoWrapUp: boolean;
495
+ /**
496
+ * Whether the agent personal greeting is enabled.
497
+ */
498
+ agentPersonalGreeting: boolean;
435
499
  /**
436
500
  * Auto answer allowed.
437
501
  */
@@ -448,6 +512,30 @@ export type DesktopProfileResponse = {
448
512
  * Allow auto wrap-up extension.
449
513
  */
450
514
  allowAutoWrapUpExtension: boolean;
515
+ /**
516
+ * Access control for queues assigned to the agent (ALL or SPECIFIC).
517
+ */
518
+ accessQueue: string;
519
+ /**
520
+ * Queue identifiers available to the agent when access is SPECIFIC.
521
+ */
522
+ queues: string[];
523
+ /**
524
+ * Access control for entry points assigned to the agent.
525
+ */
526
+ accessEntryPoint: string;
527
+ /**
528
+ * Entry point identifiers available to the agent when access is SPECIFIC.
529
+ */
530
+ entryPoints: string[];
531
+ /**
532
+ * Access control for buddy teams assigned to the agent.
533
+ */
534
+ accessBuddyTeam: string;
535
+ /**
536
+ * Buddy team identifiers available to the agent when access is SPECIFIC.
537
+ */
538
+ buddyTeams: string[];
451
539
  /**
452
540
  * Outdial enabled for the agent.
453
541
  */
@@ -484,6 +572,10 @@ export type DesktopProfileResponse = {
484
572
  * Agent DN validation of the agent.
485
573
  */
486
574
  agentDNValidation: string;
575
+ /**
576
+ * Additional DN validation criteria configured for the agent.
577
+ */
578
+ agentDNValidationCriterions: string[];
487
579
  /**
488
580
  * Dial plans of the agent.
489
581
  */
@@ -512,6 +604,26 @@ export type DesktopProfileResponse = {
512
604
  * State synchronization in Webex enabled or not.
513
605
  */
514
606
  stateSynchronizationWebex: boolean;
607
+ /**
608
+ * Threshold rules configured for the agent profile.
609
+ */
610
+ thresholdRules: Array<Record<string, string | number>>;
611
+ /**
612
+ * Whether the agent profile is currently active.
613
+ */
614
+ active: boolean;
615
+ /**
616
+ * Whether this profile is the system default.
617
+ */
618
+ systemDefault: boolean;
619
+ /**
620
+ * Timestamp when the profile was created.
621
+ */
622
+ createdTime: number;
623
+ /**
624
+ * Timestamp when the profile was last updated.
625
+ */
626
+ lastUpdatedTime: number;
515
627
  };
516
628
  /**
517
629
  * Response containing multimedia profile configuration for an agent
@@ -907,14 +1019,6 @@ export type WrapupData = {
907
1019
  allowCancelAutoWrapup?: boolean;
908
1020
  };
909
1021
  };
910
- /**
911
- * Available login options for voice channel access
912
- * 'AGENT_DN' - Login using agent's DN
913
- * 'EXTENSION' - Login using extension number
914
- * 'BROWSER' - Login using browser-based WebRTC
915
- * @public
916
- */
917
- export type LoginOption = 'AGENT_DN' | 'EXTENSION' | 'BROWSER';
918
1022
  /**
919
1023
  * Team configuration information
920
1024
  * @public
@@ -1082,7 +1186,7 @@ export type Profile = {
1082
1186
  /** Outbound entry point */
1083
1187
  outDialEp: string;
1084
1188
  /** Whether ending calls is enabled */
1085
- isEndCallEnabled: boolean;
1189
+ isEndTaskEnabled: boolean;
1086
1190
  /** Whether ending consultations is enabled */
1087
1191
  isEndConsultEnabled: boolean;
1088
1192
  /** Optional lifecycle manager URL */
@@ -1,7 +1,7 @@
1
1
  import * as Err from './Err';
2
2
  import { LoginOption, WebexRequestPayload } from '../../types';
3
3
  import { Failure, AugmentedError } from './GlobalTypes';
4
- import { TaskData, ConsultTransferPayLoad, Interaction } from '../task/types';
4
+ import { ConsultConferenceData, consultConferencePayloadData, ConsultTransferDestinationType, TaskData, Interaction } from '../task/types';
5
5
  import { DialPlan } from '../config/types';
6
6
  /**
7
7
  * Strips characters defined in the dial plan entry from the input string.
@@ -68,14 +68,6 @@ export declare const generateTaskErrorObject: (error: any, methodName: string, m
68
68
  * @ignore
69
69
  */
70
70
  export declare const createErrDetailsObject: (errObj: WebexRequestPayload) => Err.Details<"Service.reqs.generic.failure">;
71
- /**
72
- * Gets the consulted agent ID from the media object by finding the agent
73
- * in the consult media participants (excluding the current agent).
74
- *
75
- * @param media - The media object from the interaction
76
- * @param agentId - The current agent's ID to exclude from the search
77
- * @returns The consulted agent ID, or empty string if none found
78
- */
79
71
  export declare const getConsultedAgentId: (media: Interaction['media'], agentId: string) => string;
80
72
  /**
81
73
  * Gets the destination agent ID for CBT (Capacity Based Team) scenarios.
@@ -105,4 +97,25 @@ export declare const calculateDestAgentId: (interaction: Interaction, agentId: s
105
97
  * @returns The destination agent ID for determining destination type
106
98
  */
107
99
  export declare const calculateDestType: (interaction: Interaction, agentId: string) => string;
108
- export declare const deriveConsultTransferDestinationType: (taskData?: TaskData) => ConsultTransferPayLoad['destinationType'];
100
+ /**
101
+ * Gets the destination agent ID from participants.
102
+ * Finds a participant who is not the current agent and is an agent type.
103
+ *
104
+ * @param participants - The participants object from interaction
105
+ * @param agentId - The current agent's ID
106
+ * @returns The destination agent ID, or undefined if none found
107
+ */
108
+ export declare const buildConsultConferenceParamData: (dataPassed: consultConferencePayloadData, interactionIdPassed: string) => {
109
+ interactionId: string;
110
+ data: ConsultConferenceData;
111
+ };
112
+ /**
113
+ * Derives the consult transfer destination type based on task data.
114
+ * This function determines the appropriate destination type for a consult transfer
115
+ * by examining the destination type stored in the task data.
116
+ *
117
+ * @param taskData - The task data containing destination information
118
+ * @returns The derived consult transfer destination type
119
+ * @public
120
+ */
121
+ export declare const deriveConsultTransferDestinationType: (taskData: TaskData) => ConsultTransferDestinationType;
@@ -33,3 +33,4 @@ export declare class WebSocketManager extends EventEmitter {
33
33
  private connect;
34
34
  private webSocketOnCloseHandler;
35
35
  }
36
+ export default WebSocketManager;
@@ -1,5 +1,5 @@
1
1
  import { SubscribeRequest } from '../../../types';
2
- import { WebSocketManager } from './WebSocketManager';
2
+ import type WebSocketManager from './WebSocketManager';
3
3
  /**
4
4
  * Options for initializing a connection service.
5
5
  * @typedef ConnectionServiceOptions
@@ -23,7 +23,7 @@ export default class Services {
23
23
  readonly dialer: ReturnType<typeof aqmDialer>;
24
24
  /** WebSocket manager for handling real-time communications */
25
25
  readonly webSocketManager: WebSocketManager;
26
- /** RTD WebSocket manager for handling realtime transcription */
26
+ /** RTD WebSocket manager for handling real-time transcription */
27
27
  readonly rtdWebSocketManager: WebSocketManager;
28
28
  /** Connection service for managing websocket connections */
29
29
  readonly connectionService: ConnectionService;
@@ -0,0 +1,157 @@
1
+ /// <reference types="node" />
2
+ import { EventEmitter } from 'events';
3
+ import type { ActorRefFrom, SnapshotFrom } from 'xstate';
4
+ import { ITask, TaskData, TaskResponse, WrapupPayLoad, TaskId, TransferPayLoad, TASK_EVENTS, TaskUIControls, ConsultEndPayload, ConsultPayload, ConsultTransferPayLoad, ResumeRecordingPayload, CallId } from './types';
5
+ import routingContact from './contact';
6
+ import MetricsManager from '../../metrics/MetricsManager';
7
+ import { TaskState } from './state-machine';
8
+ import type { TaskEventPayload, TaskStateMachine, UIControlConfig, TaskActionsMap, TaskActionArgs } from './state-machine';
9
+ import AutoWrapup from './AutoWrapup';
10
+ import { WrapupData } from '../config/types';
11
+ type UIControlConfigInput = Omit<UIControlConfig, 'channelType'> & {
12
+ channelType?: UIControlConfig['channelType'];
13
+ };
14
+ export default abstract class Task extends EventEmitter implements ITask {
15
+ protected contact: ReturnType<typeof routingContact>;
16
+ protected metricsManager: MetricsManager;
17
+ stateMachineService?: ActorRefFrom<TaskStateMachine>;
18
+ data: TaskData;
19
+ webCallMap: Record<TaskId, CallId>;
20
+ state?: SnapshotFrom<TaskStateMachine>;
21
+ private lastState?;
22
+ protected currentUiControls: TaskUIControls;
23
+ protected uiControlConfig: UIControlConfig;
24
+ protected wrapupData?: WrapupData;
25
+ autoWrapup?: AutoWrapup;
26
+ protected agentId?: string;
27
+ constructor(contact: ReturnType<typeof routingContact>, data: TaskData, uiControlConfig: UIControlConfigInput, wrapupData?: WrapupData, agentId?: string);
28
+ private static resolveChannelType;
29
+ abstract accept(): Promise<TaskResponse>;
30
+ decline(): Promise<TaskResponse>;
31
+ pauseRecording(): Promise<TaskResponse>;
32
+ resumeRecording(resumeRecordingPayload: ResumeRecordingPayload): Promise<TaskResponse>;
33
+ consult(consultPayload: ConsultPayload): Promise<TaskResponse>;
34
+ endConsult(consultEndPayload: ConsultEndPayload): Promise<TaskResponse>;
35
+ consultTransfer(consultTransferPayload?: ConsultTransferPayLoad): Promise<TaskResponse>;
36
+ consultConference(): Promise<TaskResponse>;
37
+ exitConference(): Promise<TaskResponse>;
38
+ transferConference(): Promise<TaskResponse>;
39
+ switchCall(): Promise<TaskResponse>;
40
+ toggleMute(): Promise<void>;
41
+ unregisterWebCallListeners(): void;
42
+ /**
43
+ * Cancel any in-progress auto wrap-up timer.
44
+ * Base implementation just clears the timer reference so subclasses inherit the behavior.
45
+ */
46
+ cancelAutoWrapupTimer(): void;
47
+ hold(): Promise<TaskResponse>;
48
+ resume(): Promise<TaskResponse>;
49
+ holdResume(): Promise<TaskResponse>;
50
+ /**
51
+ * Latest UI controls derived from state machine state and context.
52
+ */
53
+ get uiControls(): TaskUIControls;
54
+ protected updateUiControls(forceEmit?: boolean): void;
55
+ /**
56
+ * Initialize the state machine
57
+ */
58
+ private initializeStateMachine;
59
+ /**
60
+ * Send an event to the state machine
61
+ */
62
+ sendStateMachineEvent(event: TaskEventPayload): void;
63
+ /**
64
+ * Get the current state machine state
65
+ */
66
+ protected getCurrentState(): TaskState | undefined;
67
+ /**
68
+ * Compute UI controls based on current state machine state.
69
+ *
70
+ * @returns UI control states for all task actions
71
+ */
72
+ protected computeUIControls(): TaskUIControls;
73
+ /**
74
+ * Stop the state machine service
75
+ */
76
+ protected stopStateMachine(): void;
77
+ private static extractTaskDataFromEvent;
78
+ private autoAnswerIfNeeded;
79
+ private updateTaskFromEvent;
80
+ protected getStateMachineActionOverrides(): Partial<TaskActionsMap>;
81
+ protected getChannelSpecificActionOverrides(): Partial<TaskActionsMap>;
82
+ protected createEmitSelfAction(taskEvent: TASK_EVENTS, { updateTaskData }?: {
83
+ updateTaskData?: boolean;
84
+ }): ({ event }: TaskActionArgs) => void;
85
+ private getCommonActionOverrides;
86
+ /**
87
+ * Sets up the automatic wrap-up timer if wrap-up is required
88
+ */
89
+ protected setupAutoWrapupTimer(): void;
90
+ /**
91
+ * Cancels the automatic wrap-up timer if it's running
92
+ */
93
+ private reconcileData;
94
+ /**
95
+ *
96
+ * @param methodName - The name of the method that is unsupported
97
+ * @throws Error
98
+ */
99
+ protected unsupportedMethodError(methodName: string): void;
100
+ /**
101
+ * This method is used to update the task data.
102
+ * @param updatedData - TaskData
103
+ * @param shouldOverwrite - boolean
104
+ * @example
105
+ * ```typescript
106
+ * task.updateTaskData(updatedData, true);
107
+ * ```
108
+ */
109
+ updateTaskData(updatedData: TaskData, shouldOverwrite?: boolean): ITask;
110
+ /**
111
+ * The backend sends `interaction.media` and `interaction.participants` as complete snapshots
112
+ * of the current call state. `reconcileData` deep-merges and never removes keys, so entries the
113
+ * backend dropped (e.g. a consult leg's media and consultee participant after the consult ends)
114
+ * linger in `this.data`. That stale data drives incorrect UI controls (e.g. the consult button
115
+ * staying disabled after the consult leg is gone, until a page refresh re-hydrates cleanly).
116
+ * Make only these two snapshot maps authoritative to the incoming payload, leaving every other
117
+ * field on the generic deep-merge path (CAD and other partial updates still merge as before).
118
+ */
119
+ private pruneStaleInteractionMaps;
120
+ /**
121
+ * This is used to blind transfer or vTeam transfer the task
122
+ * @param transferPayload
123
+ * @returns Promise<TaskResponse>
124
+ * @throws Error
125
+ * @example
126
+ * ```typescript
127
+ * const transferPayload = {
128
+ * to: 'myQueueId',
129
+ * destinationType: 'queue',
130
+ * }
131
+ * task.transfer(transferPayload).then(()=>{}).catch(()=>{});
132
+ * ```
133
+ */
134
+ transfer(transferPayload: TransferPayLoad): Promise<TaskResponse>;
135
+ /**
136
+ * This is used to end the task.
137
+ * @returns Promise<TaskResponse>
138
+ * @throws Error
139
+ * @example
140
+ * ```typescript
141
+ * task.end().then(()=>{}).catch(()=>{})
142
+ * ```
143
+ */
144
+ end(): Promise<TaskResponse>;
145
+ /**
146
+ * This is used to wrap up the task.
147
+ * @param wrapupPayload - WrapupPayLoad
148
+ * @returns Promise<TaskResponse>
149
+ * @throws Error
150
+ * @example
151
+ * ```typescript
152
+ * task.wrapup(wrapupPayload).then(()=>{}).catch(()=>{})
153
+ * ```
154
+ */
155
+ wrapup(wrapupPayload: WrapupPayLoad): Promise<TaskResponse>;
156
+ }
157
+ export {};
@@ -0,0 +1,12 @@
1
+ import routingContact from './contact';
2
+ import WebCallingService from '../WebCallingService';
3
+ import Task from './Task';
4
+ import { TaskData } from './types';
5
+ import { ConfigFlags } from '../../types';
6
+ import { WrapupData } from '../config/types';
7
+ export default class TaskFactory {
8
+ /**
9
+ * Creates the correct Task subclass based on mediaType & loginOption
10
+ */
11
+ static createTask(contact: ReturnType<typeof routingContact>, webCallingService: WebCallingService, data: TaskData, configFlags: ConfigFlags, wrapupData?: WrapupData, agentId?: string): Task;
12
+ }
@@ -1,4 +1,30 @@
1
1
  import { Interaction, ITask, TaskData } from './types';
2
+ import { TaskContext } from './state-machine/types';
3
+ /**
4
+ * Checks if the customer is still in the call (not left)
5
+ *
6
+ * @param interaction - The interaction object
7
+ * @param interactionId - The main interaction ID
8
+ * @returns true if customer is in the call
9
+ */
10
+ export declare const getIsCustomerInCall: (interaction: Interaction, interactionId: string) => boolean;
11
+ /**
12
+ * Gets the count of active agent participants in the conference
13
+ * Excludes Customer, Supervisor, and VVA participant types
14
+ *
15
+ * @param interaction - The interaction object
16
+ * @param interactionId - The main interaction ID
17
+ * @returns Number of active agent participants
18
+ */
19
+ export declare const getConferenceParticipantsCount: (interaction: Interaction, interactionId: string) => number;
20
+ /**
21
+ * Determines if a consult is actively in-progress for conference control gating.
22
+ * This is used to disable conference controls (End/Consult) only when a consult leg
23
+ * still exists outside the main call participants.
24
+ */
25
+ export declare const getIsConsultInProgressForConferenceControls: (interaction: Interaction | undefined, mainCallId: string | undefined, selfAgentId: string | undefined) => boolean;
26
+ export declare const getIsConsultedAgentForControls: (taskData: TaskData | null, context: TaskContext, isConsultingState: boolean) => boolean;
27
+ export declare const getServerHoldStateForControls: (context: TaskContext, mainCallId?: string, fallbackTaskData?: TaskData | null) => boolean | undefined;
2
28
  /**
3
29
  * Determines if the given agent is the primary agent (owner) of the task
4
30
  * @param task - The task to check
@@ -22,8 +48,11 @@ export declare const isParticipantInMainInteraction: (task: ITask, agentId: stri
22
48
  export declare const checkParticipantNotInInteraction: (task: ITask, agentId: string) => boolean;
23
49
  /**
24
50
  * Determines if a conference is currently in progress based on the number of active agent participants
25
- * @param TaskData - The payLoad data to check for conference status
51
+ * @param data - The task data to check for conference status
26
52
  * @returns true if there are 2 or more active agent participants in the main call, false otherwise
53
+ *
54
+ * For Agent B (consulted agent), their task's interactionId may be different from the main call.
55
+ * We use mainInteractionId from the interaction if available, otherwise fallback to interactionId.
27
56
  */
28
57
  export declare const getIsConferenceInProgress: (data: TaskData) => boolean;
29
58
  /**
@@ -36,10 +65,15 @@ export declare const isSecondaryAgent: (interaction: Interaction) => boolean;
36
65
  /**
37
66
  * Checks if the current agent is a secondary EP-DN (Entry Point Dial Number) agent.
38
67
  * This is specifically for telephony consultations to external numbers/entry points.
39
- * @param task - The task object containing interaction details
68
+ * @param interaction - The interaction object
40
69
  * @returns true if this is a secondary EP-DN agent in telephony consultation, false otherwise
41
70
  */
42
71
  export declare const isSecondaryEpDnAgent: (interaction: Interaction) => boolean;
72
+ /**
73
+ * Checks if the task belongs to a campaign preview interaction.
74
+ * Campaign preview ContactEnded events are terminal cleanup events and should not trigger wrapup.
75
+ */
76
+ export declare const isCampaignPreviewTask: (taskData?: TaskData | null) => boolean;
43
77
  /**
44
78
  * Checks if auto-answer is enabled for the agent participant
45
79
  * @param interaction - The interaction object
@@ -82,6 +116,16 @@ export declare const hasAgentInitiatedOutdial: (interaction: Interaction, agentI
82
116
  * @returns true if task should be auto-answered, false otherwise
83
117
  */
84
118
  export declare const shouldAutoAnswerTask: (taskData: TaskData, agentId: string, loginOption: string, webRtcEnabled: boolean) => boolean;
119
+ /**
120
+ * Gets the consult media resource ID for switch-call operations.
121
+ * Searches for the consult media leg in the interaction.
122
+ *
123
+ * @param interaction - The interaction object
124
+ * @param consultMediaResourceId - The consult media resource ID from task data
125
+ * @param agentId - Current agent ID
126
+ * @returns The consult media resource ID or undefined
127
+ */
128
+ export declare const getConsultMediaResourceId: (interaction: Interaction | undefined, consultMediaResourceId: string | undefined, agentId: string | undefined) => string | undefined;
85
129
  /**
86
130
  * Checks if a task is a campaign preview reservation that has not yet been accepted.
87
131
  * Campaign preview tasks should not trigger incoming call handling until the agent
@@ -46,6 +46,10 @@ export declare const PRESERVED_TASK_DATA_FIELDS: {
46
46
  * Used by reconcileData method to preserve important task state fields
47
47
  */
48
48
  export declare const KEYS_TO_NOT_DELETE: string[];
49
+ /**
50
+ * Consultation status constants derived from state machine
51
+ * These values are computed and available in task.data.consultStatus
52
+ */
49
53
  export declare const METHODS: {
50
54
  ACCEPT: string;
51
55
  TOGGLE_MUTE: string;
@@ -75,6 +79,7 @@ export declare const METHODS: {
75
79
  GET_TASK_MANAGER: string;
76
80
  SETUP_AUTO_WRAPUP_TIMER: string;
77
81
  CANCEL_AUTO_WRAPUP_TIMER: string;
82
+ REQUEST_REAL_TIME_TRANSCRIPTS: string;
78
83
  };
79
84
  export declare const TRANSCRIPT_EVENT_MAP: {
80
85
  AgentContactAssigned: string;
@@ -0,0 +1,22 @@
1
+ import { IDigital, TaskResponse, TaskData } from '../types';
2
+ import { WrapupData } from '../../config/types';
3
+ import Task from '../Task';
4
+ import routingContact from '../contact';
5
+ export default class Digital extends Task implements IDigital {
6
+ constructor(contact: ReturnType<typeof routingContact>, data: TaskData, wrapupData?: WrapupData, agentId?: string);
7
+ /**
8
+ * Refresh the digital task with the latest backend payload and recompute UI controls.
9
+ */
10
+ updateTaskData(newData: TaskData, shouldOverwrite?: boolean): IDigital;
11
+ /**
12
+ * This is used for incoming digital task accept by agent.
13
+ *
14
+ * @returns Promise<TaskResponse>
15
+ * @throws Error
16
+ * @example
17
+ * ```typescript
18
+ * task.accept().then(()=>{}).catch(()=>{})
19
+ * ```
20
+ */
21
+ accept(): Promise<TaskResponse>;
22
+ }