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

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 (267) hide show
  1. package/.sdd/manifest.json +882 -0
  2. package/AGENTS.md +94 -0
  3. package/ai-docs/ARCHITECTURE.md +168 -0
  4. package/ai-docs/CONTRACTS.md +46 -0
  5. package/ai-docs/GETTING_STARTED.md +168 -0
  6. package/ai-docs/GLOSSARY.md +43 -0
  7. package/ai-docs/README.md +138 -0
  8. package/ai-docs/REVIEW_CHECKLIST.md +41 -0
  9. package/ai-docs/RULES.md +444 -0
  10. package/ai-docs/SECURITY.md +52 -0
  11. package/ai-docs/SERVICE_STATE.md +48 -0
  12. package/ai-docs/SPEC_INDEX.md +65 -0
  13. package/ai-docs/adr/0001-spec-source-policy.md +55 -0
  14. package/ai-docs/adr/README.md +8 -0
  15. package/ai-docs/adr/_adr-template.md +31 -0
  16. package/ai-docs/contact-center-spec.md +341 -0
  17. package/ai-docs/features/generated-spec-conformance-fidelity-remediation/spec/feature-spec.md +117 -0
  18. package/ai-docs/features/residual-warning-coverage-completion/spec/feature-spec.md +203 -0
  19. package/ai-docs/features/validator-code-fidelity-drift-fix/spec/feature-spec.md +315 -0
  20. package/ai-docs/patterns/event-driven-patterns.md +485 -0
  21. package/ai-docs/patterns/testing-patterns.md +480 -0
  22. package/ai-docs/patterns/typescript-patterns.md +365 -0
  23. package/ai-docs/templates/README.md +102 -0
  24. package/ai-docs/templates/documentation/create-agents-md.md +240 -0
  25. package/ai-docs/templates/documentation/create-architecture-md.md +295 -0
  26. package/ai-docs/templates/existing-service/bug-fix.md +254 -0
  27. package/ai-docs/templates/existing-service/feature-enhancement.md +450 -0
  28. package/ai-docs/templates/new-method/00-master.md +80 -0
  29. package/ai-docs/templates/new-method/01-requirements.md +232 -0
  30. package/ai-docs/templates/new-method/02-implementation.md +295 -0
  31. package/ai-docs/templates/new-method/03-tests.md +201 -0
  32. package/ai-docs/templates/new-method/04-validation.md +141 -0
  33. package/ai-docs/templates/new-service/00-master.md +109 -0
  34. package/ai-docs/templates/new-service/01-pre-questions.md +159 -0
  35. package/ai-docs/templates/new-service/02-code-generation.md +346 -0
  36. package/ai-docs/templates/new-service/03-integration.md +178 -0
  37. package/ai-docs/templates/new-service/04-test-generation.md +205 -0
  38. package/ai-docs/templates/new-service/05-validation.md +145 -0
  39. package/dist/cc.js +379 -50
  40. package/dist/cc.js.map +1 -1
  41. package/dist/config.js +6 -0
  42. package/dist/config.js.map +1 -1
  43. package/dist/constants.js +22 -2
  44. package/dist/constants.js.map +1 -1
  45. package/dist/index.js +27 -5
  46. package/dist/index.js.map +1 -1
  47. package/dist/metrics/behavioral-events.js +114 -0
  48. package/dist/metrics/behavioral-events.js.map +1 -1
  49. package/dist/metrics/constants.js +32 -3
  50. package/dist/metrics/constants.js.map +1 -1
  51. package/dist/services/ApiAiAssistant.js +318 -0
  52. package/dist/services/ApiAiAssistant.js.map +1 -0
  53. package/dist/services/UserPreference.js +427 -0
  54. package/dist/services/UserPreference.js.map +1 -0
  55. package/dist/services/agent/types.js.map +1 -1
  56. package/dist/services/config/Util.js +8 -4
  57. package/dist/services/config/Util.js.map +1 -1
  58. package/dist/services/config/constants.js +35 -2
  59. package/dist/services/config/constants.js.map +1 -1
  60. package/dist/services/config/index.js +41 -2
  61. package/dist/services/config/index.js.map +1 -1
  62. package/dist/services/config/types.js +66 -8
  63. package/dist/services/config/types.js.map +1 -1
  64. package/dist/services/constants.js +27 -1
  65. package/dist/services/constants.js.map +1 -1
  66. package/dist/services/core/Err.js.map +1 -1
  67. package/dist/services/core/Utils.js +122 -25
  68. package/dist/services/core/Utils.js.map +1 -1
  69. package/dist/services/core/aqm-reqs.js +92 -17
  70. package/dist/services/core/aqm-reqs.js.map +1 -1
  71. package/dist/services/core/websocket/WebSocketManager.js +22 -6
  72. package/dist/services/core/websocket/WebSocketManager.js.map +1 -1
  73. package/dist/services/core/websocket/connection-service.js +3 -1
  74. package/dist/services/core/websocket/connection-service.js.map +1 -1
  75. package/dist/services/core/websocket/types.js.map +1 -1
  76. package/dist/services/index.js +6 -0
  77. package/dist/services/index.js.map +1 -1
  78. package/dist/services/task/Task.js +688 -0
  79. package/dist/services/task/Task.js.map +1 -0
  80. package/dist/services/task/TaskFactory.js +45 -0
  81. package/dist/services/task/TaskFactory.js.map +1 -0
  82. package/dist/services/task/TaskManager.js +751 -457
  83. package/dist/services/task/TaskManager.js.map +1 -1
  84. package/dist/services/task/TaskUtils.js +220 -23
  85. package/dist/services/task/TaskUtils.js.map +1 -1
  86. package/dist/services/task/constants.js +23 -2
  87. package/dist/services/task/constants.js.map +1 -1
  88. package/dist/services/task/dialer.js +129 -0
  89. package/dist/services/task/dialer.js.map +1 -1
  90. package/dist/services/task/digital/Digital.js +77 -0
  91. package/dist/services/task/digital/Digital.js.map +1 -0
  92. package/dist/services/task/state-machine/TaskStateMachine.js +873 -0
  93. package/dist/services/task/state-machine/TaskStateMachine.js.map +1 -0
  94. package/dist/services/task/state-machine/actions.js +567 -0
  95. package/dist/services/task/state-machine/actions.js.map +1 -0
  96. package/dist/services/task/state-machine/constants.js +161 -0
  97. package/dist/services/task/state-machine/constants.js.map +1 -0
  98. package/dist/services/task/state-machine/guards.js +382 -0
  99. package/dist/services/task/state-machine/guards.js.map +1 -0
  100. package/dist/services/task/state-machine/index.js +53 -0
  101. package/dist/services/task/state-machine/index.js.map +1 -0
  102. package/dist/services/task/state-machine/types.js +54 -0
  103. package/dist/services/task/state-machine/types.js.map +1 -0
  104. package/dist/services/task/state-machine/uiControlsComputer.js +603 -0
  105. package/dist/services/task/state-machine/uiControlsComputer.js.map +1 -0
  106. package/dist/services/task/taskDataNormalizer.js +99 -0
  107. package/dist/services/task/taskDataNormalizer.js.map +1 -0
  108. package/dist/services/task/types.js +227 -4
  109. package/dist/services/task/types.js.map +1 -1
  110. package/dist/services/task/voice/Voice.js +1044 -0
  111. package/dist/services/task/voice/Voice.js.map +1 -0
  112. package/dist/services/task/voice/WebRTC.js +149 -0
  113. package/dist/services/task/voice/WebRTC.js.map +1 -0
  114. package/dist/types/cc.d.ts +894 -0
  115. package/dist/types/config.d.ts +72 -0
  116. package/dist/types/constants.d.ts +66 -0
  117. package/dist/types/index.d.ts +199 -0
  118. package/dist/types/logger-proxy.d.ts +71 -0
  119. package/dist/types/metrics/MetricsManager.d.ts +223 -0
  120. package/dist/types/metrics/behavioral-events.d.ts +29 -0
  121. package/dist/types/metrics/constants.d.ts +181 -0
  122. package/dist/types/services/AddressBook.d.ts +74 -0
  123. package/dist/types/services/ApiAiAssistant.d.ts +49 -0
  124. package/dist/types/services/EntryPoint.d.ts +67 -0
  125. package/dist/types/services/Queue.d.ts +76 -0
  126. package/dist/types/services/UserPreference.d.ts +118 -0
  127. package/dist/types/services/WebCallingService.d.ts +1 -0
  128. package/dist/types/services/agent/index.d.ts +46 -0
  129. package/dist/types/services/agent/types.d.ts +413 -0
  130. package/dist/types/services/config/Util.d.ts +20 -0
  131. package/dist/types/services/config/constants.d.ts +270 -0
  132. package/dist/types/services/config/index.d.ts +177 -0
  133. package/dist/types/services/config/types.d.ts +1368 -0
  134. package/dist/types/services/constants.d.ts +110 -0
  135. package/dist/types/services/core/Err.d.ts +125 -0
  136. package/dist/types/services/core/GlobalTypes.d.ts +58 -0
  137. package/dist/types/services/core/Utils.d.ts +121 -0
  138. package/dist/types/services/core/WebexRequest.d.ts +22 -0
  139. package/dist/types/services/core/aqm-reqs.d.ts +65 -0
  140. package/dist/types/services/core/constants.d.ts +99 -0
  141. package/dist/types/services/core/types.d.ts +47 -0
  142. package/dist/types/services/core/websocket/WebSocketManager.d.ts +36 -0
  143. package/dist/types/services/core/websocket/connection-service.d.ts +27 -0
  144. package/dist/types/services/core/websocket/keepalive.worker.d.ts +2 -0
  145. package/dist/types/services/core/websocket/types.d.ts +37 -0
  146. package/dist/types/services/index.d.ts +54 -0
  147. package/dist/types/services/task/AutoWrapup.d.ts +40 -0
  148. package/dist/types/services/task/Task.d.ts +157 -0
  149. package/dist/types/services/task/TaskFactory.d.ts +12 -0
  150. package/dist/types/services/task/TaskManager.d.ts +1 -0
  151. package/dist/types/services/task/TaskUtils.d.ts +138 -0
  152. package/dist/types/services/task/constants.d.ts +91 -0
  153. package/dist/types/services/task/contact.d.ts +69 -0
  154. package/dist/types/services/task/dialer.d.ts +73 -0
  155. package/dist/types/services/task/digital/Digital.d.ts +22 -0
  156. package/dist/types/services/task/state-machine/TaskStateMachine.d.ts +1194 -0
  157. package/dist/types/services/task/state-machine/actions.d.ts +10 -0
  158. package/dist/types/services/task/state-machine/constants.d.ts +107 -0
  159. package/dist/types/services/task/state-machine/guards.d.ts +102 -0
  160. package/dist/types/services/task/state-machine/index.d.ts +13 -0
  161. package/dist/types/services/task/state-machine/types.d.ts +269 -0
  162. package/dist/types/services/task/state-machine/uiControlsComputer.d.ts +9 -0
  163. package/dist/types/services/task/taskDataNormalizer.d.ts +10 -0
  164. package/dist/types/services/task/types.d.ts +1856 -0
  165. package/dist/types/services/task/voice/Voice.d.ts +184 -0
  166. package/dist/types/services/task/voice/WebRTC.d.ts +53 -0
  167. package/dist/types/types.d.ts +778 -0
  168. package/dist/types/utils/PageCache.d.ts +173 -0
  169. package/dist/types/webex-config.d.ts +53 -0
  170. package/dist/types/webex.d.ts +8 -0
  171. package/dist/types.js +130 -1
  172. package/dist/types.js.map +1 -1
  173. package/dist/webex.js +14 -2
  174. package/dist/webex.js.map +1 -1
  175. package/package.json +16 -12
  176. package/src/cc.ts +477 -51
  177. package/src/config.ts +6 -0
  178. package/src/constants.ts +21 -1
  179. package/src/index.ts +24 -5
  180. package/src/metrics/ai-docs/AGENTS.md +350 -0
  181. package/src/metrics/ai-docs/ARCHITECTURE.md +338 -0
  182. package/src/metrics/ai-docs/metrics-spec.md +854 -0
  183. package/src/metrics/behavioral-events.ts +120 -0
  184. package/src/metrics/constants.ts +37 -3
  185. package/src/services/ApiAiAssistant.ts +412 -0
  186. package/src/services/UserPreference.ts +509 -0
  187. package/src/services/agent/ai-docs/AGENTS.md +240 -0
  188. package/src/services/agent/ai-docs/ARCHITECTURE.md +304 -0
  189. package/src/services/agent/ai-docs/agent-spec.md +504 -0
  190. package/src/services/agent/types.ts +1 -1
  191. package/src/services/ai-docs/AGENTS.md +386 -0
  192. package/src/services/ai-docs/services-spec.md +492 -0
  193. package/src/services/config/Util.ts +10 -2
  194. package/src/services/config/ai-docs/AGENTS.md +255 -0
  195. package/src/services/config/ai-docs/ARCHITECTURE.md +426 -0
  196. package/src/services/config/ai-docs/config-spec.md +669 -0
  197. package/src/services/config/constants.ts +37 -1
  198. package/src/services/config/index.ts +45 -1
  199. package/src/services/config/types.ts +241 -11
  200. package/src/services/constants.ts +29 -0
  201. package/src/services/core/Err.ts +3 -0
  202. package/src/services/core/Utils.ts +143 -30
  203. package/src/services/core/ai-docs/AGENTS.md +381 -0
  204. package/src/services/core/ai-docs/ARCHITECTURE.md +698 -0
  205. package/src/services/core/ai-docs/core-spec.md +783 -0
  206. package/src/services/core/aqm-reqs.ts +100 -22
  207. package/src/services/core/websocket/WebSocketManager.ts +23 -6
  208. package/src/services/core/websocket/connection-service.ts +5 -1
  209. package/src/services/core/websocket/types.ts +1 -1
  210. package/src/services/index.ts +4 -0
  211. package/src/services/task/Task.ts +837 -0
  212. package/src/services/task/TaskFactory.ts +55 -0
  213. package/src/services/task/TaskManager.ts +793 -521
  214. package/src/services/task/TaskUtils.ts +314 -24
  215. package/src/services/task/ai-docs/AGENTS.md +457 -0
  216. package/src/services/task/ai-docs/ARCHITECTURE.md +594 -0
  217. package/src/services/task/ai-docs/task-spec.md +1319 -0
  218. package/src/services/task/constants.ts +23 -0
  219. package/src/services/task/dialer.ts +136 -1
  220. package/src/services/task/digital/Digital.ts +95 -0
  221. package/src/services/task/state-machine/TaskStateMachine.ts +1166 -0
  222. package/src/services/task/state-machine/actions.ts +738 -0
  223. package/src/services/task/state-machine/ai-docs/AGENTS.md +458 -0
  224. package/src/services/task/state-machine/ai-docs/ARCHITECTURE.md +1137 -0
  225. package/src/services/task/state-machine/ai-docs/task-state-machine-spec.md +2177 -0
  226. package/src/services/task/state-machine/constants.ts +172 -0
  227. package/src/services/task/state-machine/guards.ts +445 -0
  228. package/src/services/task/state-machine/index.ts +28 -0
  229. package/src/services/task/state-machine/types.ts +243 -0
  230. package/src/services/task/state-machine/uiControlsComputer.ts +961 -0
  231. package/src/services/task/taskDataNormalizer.ts +137 -0
  232. package/src/services/task/types.ts +734 -71
  233. package/src/services/task/voice/Voice.ts +1270 -0
  234. package/src/services/task/voice/WebRTC.ts +187 -0
  235. package/src/types.ts +205 -2
  236. package/src/utils/AGENTS.md +278 -0
  237. package/src/utils/ai-docs/utils-spec.md +381 -0
  238. package/src/webex.js +2 -0
  239. package/test/unit/spec/cc.ts +503 -43
  240. package/test/unit/spec/logger-proxy.ts +70 -0
  241. package/test/unit/spec/services/ApiAiAssistant.ts +273 -0
  242. package/test/unit/spec/services/UserPreference.ts +401 -0
  243. package/test/unit/spec/services/WebCallingService.ts +7 -1
  244. package/test/unit/spec/services/config/index.ts +85 -29
  245. package/test/unit/spec/services/core/Utils.ts +481 -2
  246. package/test/unit/spec/services/core/websocket/WebSocketManager.ts +137 -41
  247. package/test/unit/spec/services/core/websocket/connection-service.ts +3 -1
  248. package/test/unit/spec/services/task/AutoWrapup.ts +63 -0
  249. package/test/unit/spec/services/task/Task.ts +477 -0
  250. package/test/unit/spec/services/task/TaskFactory.ts +62 -0
  251. package/test/unit/spec/services/task/TaskManager.ts +1001 -1003
  252. package/test/unit/spec/services/task/TaskUtils.ts +235 -0
  253. package/test/unit/spec/services/task/dialer.ts +372 -96
  254. package/test/unit/spec/services/task/digital/Digital.ts +105 -0
  255. package/test/unit/spec/services/task/state-machine/TaskStateMachine.ts +2651 -0
  256. package/test/unit/spec/services/task/state-machine/guards.ts +637 -0
  257. package/test/unit/spec/services/task/state-machine/types.ts +18 -0
  258. package/test/unit/spec/services/task/state-machine/uiControlsComputer.ts +2663 -0
  259. package/test/unit/spec/services/task/taskTestUtils.ts +87 -0
  260. package/test/unit/spec/services/task/voice/Voice.ts +649 -0
  261. package/test/unit/spec/services/task/voice/WebRTC.ts +235 -0
  262. package/umd/contact-center.min.js +2 -2
  263. package/umd/contact-center.min.js.map +1 -1
  264. package/dist/services/task/index.js +0 -1525
  265. package/dist/services/task/index.js.map +0 -1
  266. package/src/services/task/index.ts +0 -1801
  267. package/test/unit/spec/services/task/index.ts +0 -2184
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Post-authentication event name.
3
+ * @type {string}
4
+ * @public
5
+ * @example
6
+ * if (event === POST_AUTH) { ... }
7
+ * @ignore
8
+ */
9
+ export declare const POST_AUTH = "postauth";
10
+ /**
11
+ * API gateway identifier for Webex Contact Center.
12
+ * @type {string}
13
+ * @public
14
+ * @ignore
15
+ */
16
+ export declare const WCC_API_GATEWAY = "wcc-api-gateway";
17
+ /**
18
+ * Domain identifier for WCC Calling RTMS.
19
+ * @type {string}
20
+ * @public
21
+ * @ignore
22
+ */
23
+ export declare const WCC_CALLING_RTMS_DOMAIN = "wcc-calling-rtms-domain";
24
+ /**
25
+ * Default RTMS domain for production use.
26
+ * @type {string}
27
+ * @public
28
+ * @ignore
29
+ */
30
+ export declare const DEFAULT_RTMS_DOMAIN = "rtw.prod-us1.rtmsprod.net";
31
+ /**
32
+ * Timeout in milliseconds for WebSocket events.
33
+ * @type {number}
34
+ * @public
35
+ * @example
36
+ * setTimeout(() => { ... }, WEBSOCKET_EVENT_TIMEOUT);
37
+ * @ignore
38
+ */
39
+ export declare const WEBSOCKET_EVENT_TIMEOUT = 20000;
40
+ /**
41
+ * Agent role identifier.
42
+ * @type {string}
43
+ * @public
44
+ * @ignore
45
+ */
46
+ export declare const AGENT = "agent";
47
+ /**
48
+ * API path for notification subscription.
49
+ * @type {string}
50
+ * @public
51
+ * @ignore
52
+ */
53
+ export declare const SUBSCRIBE_API = "v1/notification/subscribe";
54
+ /**
55
+ * API path for realtime transcription subscription.
56
+ * @type {string}
57
+ * @public
58
+ * @ignore
59
+ */
60
+ export declare const RTD_SUBSCRIBE_API = "v1/realtime/subscribe";
61
+ /**
62
+ * API path for agent login.
63
+ * @type {string}
64
+ * @public
65
+ * @ignore
66
+ */
67
+ export declare const LOGIN_API = "v1/agents/login";
68
+ /**
69
+ * Prefix for WebRTC-related API endpoints.
70
+ * @type {string}
71
+ * @public
72
+ * @ignore
73
+ */
74
+ export declare const WEB_RTC_PREFIX = "webrtc-";
75
+ /**
76
+ * API path for agent session state changes.
77
+ * @type {string}
78
+ * @public
79
+ * @ignore
80
+ */
81
+ export declare const STATE_CHANGE_API = "v1/agents/session/state";
82
+ /**
83
+ * Message for deregistering WebCalling line and cleaning up resources.
84
+ * @type {string}
85
+ * @public
86
+ * @ignore
87
+ */
88
+ export declare const DEREGISTER_WEBCALLING_LINE_MSG = "Deregistering WebCalling line and cleaning up resources";
89
+ export declare const METHODS: {
90
+ SET_LOGIN_OPTION: string;
91
+ HANDLE_MEDIA_EVENT: string;
92
+ HANDLE_DISCONNECT_EVENT: string;
93
+ REGISTER_CALL_LISTENERS: string;
94
+ CLEAN_UP_CALL: string;
95
+ GET_RTMS_DOMAIN: string;
96
+ REGISTER_WEB_CALLING_LINE: string;
97
+ DEREGISTER_WEB_CALLING_LINE: string;
98
+ ANSWER_CALL: string;
99
+ MUTE_UNMUTE_CALL: string;
100
+ IS_CALL_MUTED: string;
101
+ DECLINE_CALL: string;
102
+ MAP_CALL_TO_TASK: string;
103
+ GET_TASK_ID_FOR_CALL: string;
104
+ };
105
+ export declare const AI_ASSISTANT_API_URLS: {
106
+ EVENT: string;
107
+ TRANSCRIPTS_LIST: string;
108
+ };
109
+ export declare const AI_ASSISTANT_BASE_URL_TEMPLATE = "https://api-ai-assistant.%s.ciscoccservice.com";
110
+ export declare const AI_ASSISTANT_ENV_MAP: Record<string, string>;
@@ -0,0 +1,125 @@
1
+ import { WebexRequestPayload } from '../../types';
2
+ import { Failure } from './GlobalTypes';
3
+ /**
4
+ * Err module provides a structured way to handle errors in the Contact Center plugin.
5
+ * @ignore
6
+ */
7
+ export type ErrDetails = {
8
+ status: number;
9
+ type: string;
10
+ trackingId: string;
11
+ };
12
+ export type AgentErrorIds = {
13
+ 'Service.aqm.agent.stationLogin': ErrDetails;
14
+ } | {
15
+ 'Service.aqm.agent.stationLoginFailed': Failure;
16
+ } | {
17
+ 'Service.aqm.agent.stateChange': Failure;
18
+ } | {
19
+ 'Service.aqm.agent.reload': Failure;
20
+ } | {
21
+ 'Service.aqm.agent.logout': Failure;
22
+ } | {
23
+ 'Service.reqs.generic.failure': {
24
+ trackingId: string;
25
+ };
26
+ } | {
27
+ 'Service.aqm.agent.BuddyAgentsRetrieveFailed': Failure;
28
+ };
29
+ export type vteamType = 'inboundqueue' | 'inboundentrypoint' | string;
30
+ export type TaskErrorIds = {
31
+ 'Service.aqm.task.accept': Failure;
32
+ } | {
33
+ 'Service.aqm.task.end': Failure;
34
+ } | {
35
+ 'Service.aqm.task.wrapup': Failure;
36
+ } | {
37
+ 'Service.aqm.task.AgentVteamTransferFailed': Failure;
38
+ } | {
39
+ 'Service.aqm.task.AgentBlindTransferFailedEvent': Failure;
40
+ } | {
41
+ 'Service.aqm.task.AgentConsultTransferFailed': Failure;
42
+ } | {
43
+ 'Service.aqm.task.consult': Failure;
44
+ } | {
45
+ 'Service.aqm.err.trackingId': {
46
+ trackingId: string;
47
+ };
48
+ } | {
49
+ 'Service.aqm.task.consultAccept': Failure;
50
+ } | {
51
+ 'Service.aqm.task.consultConference': Failure;
52
+ } | {
53
+ 'Service.aqm.task.consultEnd': Failure;
54
+ } | {
55
+ 'Service.aqm.task.cancelCtq': Failure;
56
+ } | {
57
+ 'Service.aqm.task.hold': Failure;
58
+ } | {
59
+ 'Service.aqm.task.unHold': Failure;
60
+ } | {
61
+ 'Service.aqm.task.VteamListFailed': Failure;
62
+ } | {
63
+ 'Service.aqm.task.pauseRecording': Failure;
64
+ } | {
65
+ 'Service.aqm.task.resumeRecording': Failure;
66
+ } | {
67
+ 'Service.aqm.dialer.startOutdial': Failure;
68
+ } | {
69
+ 'Service.aqm.dialer.acceptPreviewContact': Failure;
70
+ } | {
71
+ 'Service.aqm.dialer.skipPreviewContact': Failure;
72
+ } | {
73
+ 'Service.aqm.dialer.removePreviewContact': Failure;
74
+ } | {
75
+ 'Service.reqs.generic.failure': {
76
+ trackingId: string;
77
+ };
78
+ };
79
+ export type ReqError = 'Service.aqm.reqs.GenericRequestError' | {
80
+ 'Service.aqm.reqs.Pending': {
81
+ key: string;
82
+ msg: string;
83
+ };
84
+ } | {
85
+ 'Service.aqm.reqs.PendingEvent': {
86
+ key: string;
87
+ };
88
+ } | {
89
+ 'Service.aqm.reqs.Timeout': {
90
+ key: string;
91
+ response: WebexRequestPayload;
92
+ };
93
+ } | {
94
+ 'Service.aqm.reqs.TimeoutEvent': {
95
+ key: string;
96
+ };
97
+ };
98
+ export interface Ids {
99
+ 'Service.aqm.agent': AgentErrorIds;
100
+ 'Service.aqm.reqs': ReqError;
101
+ 'Service.aqm.task': TaskErrorIds;
102
+ }
103
+ export type IdsGlobal = 'system' | 'handle' | 'fallback';
104
+ export type IdsSub = Ids[keyof Ids];
105
+ export type IdsMessage = IdsGlobal | keyof Ids | Exclude<IdsSub, object>;
106
+ export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
107
+ export type FlattenUnion<T> = {
108
+ [K in keyof UnionToIntersection<T>]: K extends keyof T ? T[K] extends any[] ? T[K] : T[K] extends object ? FlattenUnion<T[K]> : T[K] : UnionToIntersection<T>[K];
109
+ };
110
+ export type IdsDetailsType = FlattenUnion<Exclude<IdsSub, string>>;
111
+ export type IdsDetails = keyof IdsDetailsType;
112
+ export type Id = IdsMessage | IdsDetails;
113
+ export declare class Message extends Error {
114
+ readonly id: Id;
115
+ constructor(id: IdsMessage);
116
+ constructor(id: IdsMessage, message: string);
117
+ constructor(id: IdsMessage, errror: Error);
118
+ private isErr;
119
+ }
120
+ export declare class Details<T extends IdsDetails> extends Error {
121
+ readonly id: Id;
122
+ readonly details: IdsDetailsType[T];
123
+ constructor(id: T, details: IdsDetailsType[T]);
124
+ private isErr;
125
+ }
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Generic message interface used throughout the plugin
3
+ * @template T - Type of the data payload (defaults to any)
4
+ * @private
5
+ * @ignore
6
+ */
7
+ export type Msg<T = any> = {
8
+ /** Message/Event type identifier */
9
+ type: string;
10
+ /** Organization identifier */
11
+ orgId: string;
12
+ /** Unique tracking identifier for the message/Event */
13
+ trackingId: string;
14
+ /** Message/Event payload data */
15
+ data: T;
16
+ };
17
+ /**
18
+ * Represents a failure message with specific error details
19
+ * @private
20
+ * @ignore
21
+ */
22
+ export type Failure = Msg<{
23
+ /** Agent identifier associated with the failure */
24
+ agentId: string;
25
+ /** Tracking identifier for the failure event */
26
+ trackingId: string;
27
+ /** Numeric code indicating the reason for failure */
28
+ reasonCode: number;
29
+ /** Organization identifier */
30
+ orgId: string;
31
+ /** Human-readable description of the failure reason */
32
+ reason: string;
33
+ }>;
34
+ /**
35
+ * Represents task API error details in a structured format
36
+ * @public
37
+ */
38
+ export interface TaskError {
39
+ /** Original error object for throwing */
40
+ error: Error;
41
+ /** Unique tracking identifier for correlation */
42
+ trackingId: string;
43
+ /** Detailed error message from the API */
44
+ errorMessage: string;
45
+ /** Type/category of the error (e.g., "Bad Request") */
46
+ errorType: string;
47
+ /** Additional error context data */
48
+ errorData: string;
49
+ /** Numeric reason code */
50
+ reasonCode: number;
51
+ }
52
+ /**
53
+ * An Error object augmented with a flexible data field for additional context.
54
+ * Use this to attach structured data to thrown errors without ts-ignore.
55
+ */
56
+ export interface AugmentedError extends Error {
57
+ data?: Record<string, any>;
58
+ }
@@ -0,0 +1,121 @@
1
+ import * as Err from './Err';
2
+ import { LoginOption, WebexRequestPayload } from '../../types';
3
+ import { Failure, AugmentedError } from './GlobalTypes';
4
+ import { ConsultConferenceData, consultConferencePayloadData, ConsultTransferDestinationType, TaskData, Interaction } from '../task/types';
5
+ import { DialPlan } from '../config/types';
6
+ /**
7
+ * Strips characters defined in the dial plan entry from the input string.
8
+ *
9
+ * @param input - The dial number to sanitize
10
+ * @param strippedChars - String of characters to remove from the input
11
+ * @returns The sanitized input with specified characters removed
12
+ */
13
+ export declare const stripDialPlanChars: (input: string, strippedChars: string) => string;
14
+ /**
15
+ * Validates a dial number against the provided dial plan regex patterns.
16
+ * A number is valid if it matches at least one regex pattern in the dial plans.
17
+ * Skips validation when no dial plan entries are configured, deferring to the server.
18
+ *
19
+ * @param input - The dial number to validate
20
+ * @param dialPlanEntries - Array of dial plan entries containing regex patterns
21
+ * @returns true if the input matches at least one dial plan regex pattern or no entries are configured, false otherwise
22
+ */
23
+ export declare const isValidDialNumber: (input: string, dialPlanEntries: DialPlan['dialPlanEntity']) => boolean;
24
+ export declare const getStationLoginErrorData: (failure: Failure, loginOption: LoginOption) => {
25
+ message: any;
26
+ fieldName: any;
27
+ };
28
+ /**
29
+ * Extracts error details and logs the error. Also uploads logs for the error unless it is a silent relogin agent not found error.
30
+ *
31
+ * @param error - The error object, expected to have a `details` property of type Failure.
32
+ * @param methodName - The name of the method where the error occurred.
33
+ * @param moduleName - The name of the module where the error occurred.
34
+ * @returns An object containing the error instance and the reason string.
35
+ * @public
36
+ * @example
37
+ * const details = getErrorDetails(error, 'fetchData', 'DataModule');
38
+ * if (details.error) { handleError(details.error); }
39
+ * @ignore
40
+ */
41
+ export declare const getErrorDetails: (error: any, methodName: string, moduleName: string) => {
42
+ error: Error;
43
+ reason: string;
44
+ };
45
+ /**
46
+ * Extracts error details from task API errors and logs them. Also uploads logs for the error.
47
+ * This handles the specific error format returned by task API calls.
48
+ *
49
+ * @param error - The error object from task API calls with structure: {id: string, details: {trackingId: string, msg: {...}}}
50
+ * @param methodName - The name of the method where the error occurred.
51
+ * @param moduleName - The name of the module where the error occurred.
52
+ * @returns AugmentedError containing structured error details on err.data for metrics and logging
53
+ * @public
54
+ * @example
55
+ * const taskError = generateTaskErrorObject(error, 'transfer', 'TaskModule');
56
+ * throw taskError.error;
57
+ * @ignore
58
+ */
59
+ export declare const generateTaskErrorObject: (error: any, methodName: string, moduleName: string) => AugmentedError;
60
+ /**
61
+ * Creates an error details object suitable for use with the Err.Details class.
62
+ *
63
+ * @param errObj - The Webex request payload object.
64
+ * @returns An instance of Err.Details with the generic failure message and extracted details.
65
+ * @public
66
+ * @example
67
+ * const errDetails = createErrDetailsObject(webexRequestPayload);
68
+ * @ignore
69
+ */
70
+ export declare const createErrDetailsObject: (errObj: WebexRequestPayload) => Err.Details<"Service.reqs.generic.failure">;
71
+ export declare const getConsultedAgentId: (media: Interaction['media'], agentId: string) => string;
72
+ /**
73
+ * Gets the destination agent ID for CBT (Capacity Based Team) scenarios.
74
+ * CBT refers to teams created in Control Hub with capacity-based routing
75
+ * (as opposed to agent-based routing). This handles cases where the consulted
76
+ * participant is not directly in participants but can be found by matching
77
+ * the dial number (dn).
78
+ *
79
+ * @param interaction - The interaction object
80
+ * @param consultingAgent - The consulting agent identifier
81
+ * @returns The destination agent ID for CBT scenarios, or empty string if none found
82
+ */
83
+ export declare const getDestAgentIdForCBT: (interaction: Interaction, consultingAgent: string) => string;
84
+ /**
85
+ * Calculates the destination agent ID for consult operations.
86
+ *
87
+ * @param interaction - The interaction object
88
+ * @param agentId - The current agent's ID
89
+ * @returns The destination agent ID
90
+ */
91
+ export declare const calculateDestAgentId: (interaction: Interaction, agentId: string) => string;
92
+ /**
93
+ * Calculates the destination agent ID for fetching destination type.
94
+ *
95
+ * @param interaction - The interaction object
96
+ * @param agentId - The current agent's ID
97
+ * @returns The destination agent ID for determining destination type
98
+ */
99
+ export declare const calculateDestType: (interaction: Interaction, agentId: string) => string;
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;
@@ -0,0 +1,22 @@
1
+ import { WebexSDK, HTTP_METHODS, IHttpResponse, RequestBody, UploadLogsResponse, LogsMetaData } from '../../types';
2
+ declare class WebexRequest {
3
+ private webex;
4
+ private static instance;
5
+ static getInstance(options?: {
6
+ webex: WebexSDK;
7
+ }): WebexRequest;
8
+ private constructor();
9
+ request(options: {
10
+ service: string;
11
+ resource: string;
12
+ method: HTTP_METHODS;
13
+ body?: RequestBody;
14
+ }): Promise<IHttpResponse>;
15
+ /**
16
+ * This is used for uploading the logs to backend/mats.
17
+ *
18
+ * @param metaData - meta data to be uploaded.
19
+ */
20
+ uploadLogs(metaData?: LogsMetaData): Promise<UploadLogsResponse>;
21
+ }
22
+ export default WebexRequest;
@@ -0,0 +1,65 @@
1
+ import { Conf, ConfEmpty, Res, ResEmpty } from './types';
2
+ import { WebSocketManager } from './websocket/WebSocketManager';
3
+ export default class AqmReqs {
4
+ private pendingRequests;
5
+ private pendingNotifCancelrequest;
6
+ private webexRequest;
7
+ private webSocketManager;
8
+ constructor(webSocketManager: WebSocketManager);
9
+ /**
10
+ * Creates a request function for an API call with parameters
11
+ * @param c - The configuration for the request
12
+ * @returns A function that makes the API request
13
+ */
14
+ req<TRes, TErr, TReq>(c: Conf<TRes, TErr, TReq>): Res<TRes, TReq>;
15
+ /**
16
+ * Creates a request function for an API call with no parameters
17
+ * @param c - The configuration for the request
18
+ * @returns A function that makes the API request
19
+ */
20
+ reqEmpty<TRes, TErr>(c: ConfEmpty<TRes, TErr>): ResEmpty<TRes>;
21
+ /**
22
+ * Makes an API request
23
+ * @param c - The request configuration
24
+ * @param cbRes - The callback for the response
25
+ * @returns A promise that resolves with the response or rejects with an error
26
+ */
27
+ private makeAPIRequest;
28
+ /**
29
+ * Creates a promise for an API request
30
+ * @param c - The request configuration
31
+ * @param cbRes - The callback for the response
32
+ * @returns A promise that resolves with the response or rejects with an error
33
+ */
34
+ private createPromise;
35
+ /**
36
+ * Converts a bind object to a string representation
37
+ * @param bind - The bind object to convert
38
+ * @returns A string representation of the bind object
39
+ */
40
+ private bindPrint;
41
+ /**
42
+ * Checks if a message matches a bind object
43
+ * @param bind - The bind object to check against
44
+ * @param msg - The message to check
45
+ * @returns True if the message matches the bind object, false otherwise
46
+ */
47
+ private bindCheck;
48
+ /**
49
+ * Checks type-dependent field conditions defined in __typeMap.
50
+ * @param typeMap - The type map to check against
51
+ * @param msg - The message to check
52
+ * @returns True if the message matches the type map, false otherwise
53
+ * The typeMap has the shape:
54
+ * { typeField: "type", conditions: { EventA: { field: value }, EventB: { field: value } } }
55
+ * It reads msg[typeField] to determine which condition set to apply,
56
+ * then verifies all fields in that condition match the message.
57
+ */
58
+ private static typeMapCheck;
59
+ /**
60
+ * Handles incoming messages from the WebSocket (must be a lambda fn)
61
+ * @param msg - The message to handle
62
+ * @returns
63
+ */
64
+ private readonly onMessage;
65
+ }
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Interval in milliseconds for sending keepalive pings to the worker.
3
+ * @ignore
4
+ */
5
+ export declare const KEEPALIVE_WORKER_INTERVAL = 4000;
6
+ /**
7
+ * Delay in milliseconds before resolving notification handlers.
8
+ * @ignore
9
+ */
10
+ export declare const NOTIFS_RESOLVE_DELAY = 1200;
11
+ /**
12
+ * Timeout duration in milliseconds before forcefully closing a WebSocket connection.
13
+ * @ignore
14
+ */
15
+ export declare const CLOSE_SOCKET_TIMEOUT_DURATION = 16000;
16
+ /**
17
+ * API endpoint used for connectivity or health checks.
18
+ * @ignore
19
+ */
20
+ export declare const PING_API_URL = "/health";
21
+ /**
22
+ * Timeout in milliseconds to wait for a welcome message after socket connection.
23
+ * @ignore
24
+ */
25
+ export declare const WELCOME_TIMEOUT = 30000;
26
+ /**
27
+ * Event name used for real-time device (RTD) ping status.
28
+ * @ignore
29
+ */
30
+ export declare const RTD_PING_EVENT = "rtd-online-status";
31
+ /**
32
+ * Timeout in milliseconds for individual HTTP requests.
33
+ * @ignore
34
+ */
35
+ export declare const TIMEOUT_REQ = 20000;
36
+ /**
37
+ * Duration in milliseconds to wait before attempting lost connection recovery.
38
+ * @ignore
39
+ */
40
+ export declare const LOST_CONNECTION_RECOVERY_TIMEOUT = 50000;
41
+ /**
42
+ * Duration in milliseconds after which a WebSocket disconnect is considered allowed or expected.
43
+ * @ignore
44
+ */
45
+ export declare const WS_DISCONNECT_ALLOWED = 8000;
46
+ /**
47
+ * Interval in milliseconds to check for connectivity status.
48
+ * @ignore
49
+ */
50
+ export declare const CONNECTIVITY_CHECK_INTERVAL = 5000;
51
+ /**
52
+ * Timeout in milliseconds for cleanly closing the WebSocket.
53
+ * @ignore
54
+ */
55
+ export declare const CLOSE_SOCKET_TIMEOUT = 16000;
56
+ /**
57
+ * Constants for participant types, destination types, and interaction states
58
+ * @ignore
59
+ */
60
+ export declare const PARTICIPANT_TYPES: {
61
+ /** Participant type for Entry Point Dial Number */
62
+ EP_DN: string;
63
+ /** Participant type for dial number */
64
+ DN: string;
65
+ /** Participant type for Agent */
66
+ AGENT: string;
67
+ };
68
+ /** Interaction state for consultation */
69
+ export declare const STATE_CONSULT = "consult";
70
+ export declare const METHODS: {
71
+ REQUEST: string;
72
+ UPLOAD_LOGS: string;
73
+ GET_ERROR_DETAILS: string;
74
+ GET_COMMON_ERROR_DETAILS: string;
75
+ CREATE_ERR_DETAILS_OBJECT: string;
76
+ REQ: string;
77
+ REQ_EMPTY: string;
78
+ MAKE_API_REQUEST: string;
79
+ CREATE_PROMISE: string;
80
+ BIND_PRINT: string;
81
+ BIND_CHECK: string;
82
+ ON_MESSAGE: string;
83
+ INIT_WEB_SOCKET: string;
84
+ CLOSE: string;
85
+ HANDLE_CONNECTION_LOST: string;
86
+ REGISTER: string;
87
+ CONNECT: string;
88
+ WEB_SOCKET_ON_CLOSE_HANDLER: string;
89
+ SETUP_EVENT_LISTENERS: string;
90
+ DISPATCH_CONNECTION_EVENT: string;
91
+ CS_HANDLE_CONNECTION_LOST: string;
92
+ CLEAR_TIMER_ON_RESTORE_FAILED: string;
93
+ HANDLE_RESTORE_FAILED: string;
94
+ UPDATE_CONNECTION_DATA: string;
95
+ SET_CONNECTION_PROP: string;
96
+ ON_PING: string;
97
+ HANDLE_SOCKET_CLOSE: string;
98
+ ON_SOCKET_CLOSE: string;
99
+ };
@@ -0,0 +1,47 @@
1
+ import { HTTP_METHODS, RequestBody, WebexRequestPayload } from '../../types';
2
+ import * as Err from './Err';
3
+ import { Msg } from './GlobalTypes';
4
+ export type Pending = {
5
+ check: (msg: Msg) => boolean;
6
+ handle: (msg: Msg) => void;
7
+ alternateBind?: string;
8
+ };
9
+ export type BindType = string | string[] | {
10
+ [key: string]: BindType;
11
+ };
12
+ interface Bind {
13
+ type: BindType;
14
+ data?: any;
15
+ }
16
+ export type Timeout = number | 'disabled';
17
+ export type Req<TRes, TErr> = {
18
+ url: string;
19
+ host?: string;
20
+ method?: HTTP_METHODS;
21
+ err?: ((errObj: WebexRequestPayload) => Err.Details<'Service.reqs.generic.failure'>) | Err.IdsMessage | ((e: WebexRequestPayload) => Err.Message | Err.Details<Err.IdsDetails>);
22
+ notifSuccess: {
23
+ bind: Bind;
24
+ msg: TRes;
25
+ };
26
+ notifFail?: {
27
+ bind: Bind;
28
+ errMsg: TErr;
29
+ err: (e: TErr) => Err.Details<Err.IdsDetails>;
30
+ } | {
31
+ bind: Bind;
32
+ errId: Err.IdsDetails;
33
+ };
34
+ data?: RequestBody;
35
+ headers?: Record<string, string>;
36
+ timeout?: Timeout;
37
+ notifCancel?: {
38
+ bind: Bind;
39
+ msg: TRes;
40
+ };
41
+ };
42
+ export type Conf<TRes, TErr, TReq> = (p: TReq) => Req<TRes, TErr>;
43
+ export type ConfEmpty<TRes, TErr> = () => Req<TRes, TErr>;
44
+ export type Res<TRes, TReq> = (p: TReq, cbRes?: CbRes<TRes>) => Promise<TRes>;
45
+ export type ResEmpty<TRes> = (cbRes?: CbRes<TRes>) => Promise<TRes>;
46
+ export type CbRes<TRes> = (res: any) => void | TRes;
47
+ export {};
@@ -0,0 +1,36 @@
1
+ /// <reference types="node" />
2
+ import EventEmitter from 'events';
3
+ import { WebexSDK, SubscribeRequest } from '../../../types';
4
+ import { ConnectionLostDetails } from './types';
5
+ import { WelcomeResponse } from '../../config/types';
6
+ /**
7
+ * WebSocketManager handles the WebSocket connection for Contact Center operations.
8
+ * It manages the connection lifecycle, including registration, reconnection, and message handling.
9
+ * It also utilizes a Web Worker to manage keepalive messages and socket closure.
10
+ * @ignore
11
+ */
12
+ export declare class WebSocketManager extends EventEmitter {
13
+ private websocket;
14
+ shouldReconnect: boolean;
15
+ isSocketClosed: boolean;
16
+ private isWelcomeReceived;
17
+ private url;
18
+ private forceCloseWebSocketOnTimeout;
19
+ private isConnectionLost;
20
+ private webex;
21
+ private welcomePromiseResolve;
22
+ private keepaliveWorker;
23
+ constructor(options: {
24
+ webex: WebexSDK;
25
+ });
26
+ initWebSocket(options: {
27
+ body: SubscribeRequest;
28
+ resource: string;
29
+ }): Promise<WelcomeResponse>;
30
+ close(shouldReconnect: boolean, reason?: string): void;
31
+ handleConnectionLost(event: ConnectionLostDetails): void;
32
+ private register;
33
+ private connect;
34
+ private webSocketOnCloseHandler;
35
+ }
36
+ export default WebSocketManager;