@webex/contact-center 3.12.0-next.9 → 3.12.0-next.90

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 (229) hide show
  1. package/.sdd/manifest.json +876 -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 +265 -29
  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 +17 -1
  44. package/dist/constants.js.map +1 -1
  45. package/dist/index.js +20 -5
  46. package/dist/index.js.map +1 -1
  47. package/dist/metrics/behavioral-events.js +101 -0
  48. package/dist/metrics/behavioral-events.js.map +1 -1
  49. package/dist/metrics/constants.js +25 -4
  50. package/dist/metrics/constants.js.map +1 -1
  51. package/dist/services/ApiAiAssistant.js +153 -8
  52. package/dist/services/ApiAiAssistant.js.map +1 -1
  53. package/dist/services/UserPreference.js +427 -0
  54. package/dist/services/UserPreference.js.map +1 -0
  55. package/dist/services/config/Util.js +3 -3
  56. package/dist/services/config/Util.js.map +1 -1
  57. package/dist/services/config/constants.js +23 -2
  58. package/dist/services/config/constants.js.map +1 -1
  59. package/dist/services/config/types.js +49 -9
  60. package/dist/services/config/types.js.map +1 -1
  61. package/dist/services/core/Err.js.map +1 -1
  62. package/dist/services/core/Utils.js +107 -32
  63. package/dist/services/core/Utils.js.map +1 -1
  64. package/dist/services/core/websocket/WebSocketManager.js +2 -1
  65. package/dist/services/core/websocket/WebSocketManager.js.map +1 -1
  66. package/dist/services/core/websocket/types.js.map +1 -1
  67. package/dist/services/index.js +1 -1
  68. package/dist/services/index.js.map +1 -1
  69. package/dist/services/task/Task.js +688 -0
  70. package/dist/services/task/Task.js.map +1 -0
  71. package/dist/services/task/TaskFactory.js +45 -0
  72. package/dist/services/task/TaskFactory.js.map +1 -0
  73. package/dist/services/task/TaskManager.js +728 -527
  74. package/dist/services/task/TaskManager.js.map +1 -1
  75. package/dist/services/task/TaskUtils.js +162 -26
  76. package/dist/services/task/TaskUtils.js.map +1 -1
  77. package/dist/services/task/constants.js +9 -2
  78. package/dist/services/task/constants.js.map +1 -1
  79. package/dist/services/task/dialer.js +78 -0
  80. package/dist/services/task/dialer.js.map +1 -1
  81. package/dist/services/task/digital/Digital.js +77 -0
  82. package/dist/services/task/digital/Digital.js.map +1 -0
  83. package/dist/services/task/state-machine/TaskStateMachine.js +837 -0
  84. package/dist/services/task/state-machine/TaskStateMachine.js.map +1 -0
  85. package/dist/services/task/state-machine/actions.js +543 -0
  86. package/dist/services/task/state-machine/actions.js.map +1 -0
  87. package/dist/services/task/state-machine/constants.js +161 -0
  88. package/dist/services/task/state-machine/constants.js.map +1 -0
  89. package/dist/services/task/state-machine/guards.js +340 -0
  90. package/dist/services/task/state-machine/guards.js.map +1 -0
  91. package/dist/services/task/state-machine/index.js +53 -0
  92. package/dist/services/task/state-machine/index.js.map +1 -0
  93. package/dist/services/task/state-machine/types.js +54 -0
  94. package/dist/services/task/state-machine/types.js.map +1 -0
  95. package/dist/services/task/state-machine/uiControlsComputer.js +553 -0
  96. package/dist/services/task/state-machine/uiControlsComputer.js.map +1 -0
  97. package/dist/services/task/taskDataNormalizer.js +99 -0
  98. package/dist/services/task/taskDataNormalizer.js.map +1 -0
  99. package/dist/services/task/types.js +212 -4
  100. package/dist/services/task/types.js.map +1 -1
  101. package/dist/services/task/voice/Voice.js +1042 -0
  102. package/dist/services/task/voice/Voice.js.map +1 -0
  103. package/dist/services/task/voice/WebRTC.js +149 -0
  104. package/dist/services/task/voice/WebRTC.js.map +1 -0
  105. package/dist/types/cc.d.ts +94 -1
  106. package/dist/types/config.d.ts +6 -0
  107. package/dist/types/constants.d.ts +17 -1
  108. package/dist/types/index.d.ts +21 -6
  109. package/dist/types/metrics/constants.d.ts +21 -1
  110. package/dist/types/services/ApiAiAssistant.d.ts +22 -4
  111. package/dist/types/services/UserPreference.d.ts +118 -0
  112. package/dist/types/services/config/constants.d.ts +21 -0
  113. package/dist/types/services/config/types.d.ts +171 -10
  114. package/dist/types/services/core/Err.d.ts +4 -0
  115. package/dist/types/services/core/Utils.d.ts +33 -13
  116. package/dist/types/services/core/websocket/WebSocketManager.d.ts +1 -0
  117. package/dist/types/services/core/websocket/types.d.ts +1 -1
  118. package/dist/types/services/index.d.ts +1 -1
  119. package/dist/types/services/task/Task.d.ts +157 -0
  120. package/dist/types/services/task/TaskFactory.d.ts +12 -0
  121. package/dist/types/services/task/TaskUtils.d.ts +46 -2
  122. package/dist/types/services/task/constants.d.ts +7 -0
  123. package/dist/types/services/task/dialer.d.ts +30 -0
  124. package/dist/types/services/task/digital/Digital.d.ts +22 -0
  125. package/dist/types/services/task/state-machine/TaskStateMachine.d.ts +1144 -0
  126. package/dist/types/services/task/state-machine/actions.d.ts +10 -0
  127. package/dist/types/services/task/state-machine/constants.d.ts +107 -0
  128. package/dist/types/services/task/state-machine/guards.d.ts +90 -0
  129. package/dist/types/services/task/state-machine/index.d.ts +13 -0
  130. package/dist/types/services/task/state-machine/types.d.ts +267 -0
  131. package/dist/types/services/task/state-machine/uiControlsComputer.d.ts +9 -0
  132. package/dist/types/services/task/taskDataNormalizer.d.ts +10 -0
  133. package/dist/types/services/task/types.d.ts +603 -66
  134. package/dist/types/services/task/voice/Voice.d.ts +184 -0
  135. package/dist/types/services/task/voice/WebRTC.d.ts +53 -0
  136. package/dist/types/types.d.ts +135 -0
  137. package/dist/types/webex.d.ts +1 -0
  138. package/dist/types.js +118 -2
  139. package/dist/types.js.map +1 -1
  140. package/dist/webex.js +14 -2
  141. package/dist/webex.js.map +1 -1
  142. package/package.json +15 -12
  143. package/src/cc.ts +329 -30
  144. package/src/config.ts +6 -0
  145. package/src/constants.ts +17 -1
  146. package/src/index.ts +23 -5
  147. package/src/metrics/ai-docs/AGENTS.md +350 -0
  148. package/src/metrics/ai-docs/ARCHITECTURE.md +338 -0
  149. package/src/metrics/ai-docs/metrics-spec.md +854 -0
  150. package/src/metrics/behavioral-events.ts +106 -0
  151. package/src/metrics/constants.ts +27 -4
  152. package/src/services/ApiAiAssistant.ts +203 -8
  153. package/src/services/UserPreference.ts +509 -0
  154. package/src/services/agent/ai-docs/AGENTS.md +240 -0
  155. package/src/services/agent/ai-docs/ARCHITECTURE.md +304 -0
  156. package/src/services/agent/ai-docs/agent-spec.md +504 -0
  157. package/src/services/ai-docs/AGENTS.md +386 -0
  158. package/src/services/ai-docs/services-spec.md +492 -0
  159. package/src/services/config/Util.ts +3 -3
  160. package/src/services/config/ai-docs/AGENTS.md +255 -0
  161. package/src/services/config/ai-docs/ARCHITECTURE.md +426 -0
  162. package/src/services/config/ai-docs/config-spec.md +669 -0
  163. package/src/services/config/constants.ts +25 -1
  164. package/src/services/config/types.ts +174 -11
  165. package/src/services/core/Err.ts +2 -0
  166. package/src/services/core/Utils.ts +123 -37
  167. package/src/services/core/ai-docs/AGENTS.md +381 -0
  168. package/src/services/core/ai-docs/ARCHITECTURE.md +698 -0
  169. package/src/services/core/ai-docs/core-spec.md +783 -0
  170. package/src/services/core/websocket/WebSocketManager.ts +2 -0
  171. package/src/services/core/websocket/types.ts +1 -1
  172. package/src/services/index.ts +1 -1
  173. package/src/services/task/Task.ts +837 -0
  174. package/src/services/task/TaskFactory.ts +55 -0
  175. package/src/services/task/TaskManager.ts +739 -614
  176. package/src/services/task/TaskUtils.ts +205 -25
  177. package/src/services/task/ai-docs/AGENTS.md +457 -0
  178. package/src/services/task/ai-docs/ARCHITECTURE.md +594 -0
  179. package/src/services/task/ai-docs/task-spec.md +1319 -0
  180. package/src/services/task/constants.ts +7 -0
  181. package/src/services/task/dialer.ts +80 -0
  182. package/src/services/task/digital/Digital.ts +95 -0
  183. package/src/services/task/state-machine/TaskStateMachine.ts +1077 -0
  184. package/src/services/task/state-machine/actions.ts +685 -0
  185. package/src/services/task/state-machine/ai-docs/AGENTS.md +458 -0
  186. package/src/services/task/state-machine/ai-docs/ARCHITECTURE.md +1137 -0
  187. package/src/services/task/state-machine/ai-docs/task-state-machine-spec.md +2115 -0
  188. package/src/services/task/state-machine/constants.ts +172 -0
  189. package/src/services/task/state-machine/guards.ts +406 -0
  190. package/src/services/task/state-machine/index.ts +28 -0
  191. package/src/services/task/state-machine/types.ts +241 -0
  192. package/src/services/task/state-machine/uiControlsComputer.ts +867 -0
  193. package/src/services/task/taskDataNormalizer.ts +137 -0
  194. package/src/services/task/types.ts +710 -71
  195. package/src/services/task/voice/Voice.ts +1267 -0
  196. package/src/services/task/voice/WebRTC.ts +187 -0
  197. package/src/types.ts +166 -2
  198. package/src/utils/AGENTS.md +278 -0
  199. package/src/utils/ai-docs/utils-spec.md +381 -0
  200. package/src/webex.js +2 -0
  201. package/test/unit/spec/cc.ts +343 -23
  202. package/test/unit/spec/logger-proxy.ts +70 -0
  203. package/test/unit/spec/services/ApiAiAssistant.ts +178 -20
  204. package/test/unit/spec/services/UserPreference.ts +401 -0
  205. package/test/unit/spec/services/WebCallingService.ts +7 -1
  206. package/test/unit/spec/services/config/index.ts +30 -30
  207. package/test/unit/spec/services/core/Utils.ts +425 -8
  208. package/test/unit/spec/services/core/websocket/WebSocketManager.ts +66 -40
  209. package/test/unit/spec/services/task/AutoWrapup.ts +63 -0
  210. package/test/unit/spec/services/task/Task.ts +477 -0
  211. package/test/unit/spec/services/task/TaskFactory.ts +62 -0
  212. package/test/unit/spec/services/task/TaskManager.ts +834 -1704
  213. package/test/unit/spec/services/task/TaskUtils.ts +206 -0
  214. package/test/unit/spec/services/task/dialer.ts +190 -0
  215. package/test/unit/spec/services/task/digital/Digital.ts +105 -0
  216. package/test/unit/spec/services/task/state-machine/TaskStateMachine.ts +1825 -0
  217. package/test/unit/spec/services/task/state-machine/guards.ts +479 -0
  218. package/test/unit/spec/services/task/state-machine/types.ts +18 -0
  219. package/test/unit/spec/services/task/state-machine/uiControlsComputer.ts +2020 -0
  220. package/test/unit/spec/services/task/taskTestUtils.ts +87 -0
  221. package/test/unit/spec/services/task/voice/Voice.ts +631 -0
  222. package/test/unit/spec/services/task/voice/WebRTC.ts +235 -0
  223. package/umd/contact-center.min.js +2 -2
  224. package/umd/contact-center.min.js.map +1 -1
  225. package/dist/services/task/index.js +0 -1525
  226. package/dist/services/task/index.js.map +0 -1
  227. package/dist/types/services/task/index.d.ts +0 -650
  228. package/src/services/task/index.ts +0 -1801
  229. package/test/unit/spec/services/task/index.ts +0 -2184
@@ -0,0 +1,41 @@
1
+ # Review-Check Catalog — @webex/contact-center
2
+
3
+ > Run by a runtime different from the generator. Findings remain drafts until explicitly published.
4
+
5
+ ## Core checks (always run)
6
+
7
+ | # | Check | What it verifies | Severity if it fails |
8
+ |---|---|---|---|
9
+ | C1 | Spec-currency + WHAT/WHY | Specs/docs and code land together; every requirement states WHAT and WHY | Blocking |
10
+ | C2 | Contract correctness | Provides/Requires and public API/event/type deltas are complete | Blocking |
11
+ | C3 | Code-vs-spec match | Signatures, flows, states, timeouts, and architecture match code | Blocking |
12
+ | C4 | Test adequacy | Positive/negative cases and 85% package threshold | Important |
13
+ | C5 | Error handling/input validation | Structured failures, tracking ids, validation, no swallowed errors | Important |
14
+ | C6 | Security baseline | Host auth, no secrets/sensitive logs, safe transport mapping | Blocking |
15
+
16
+ ## Coverage-conditional checks (run by the touched module's manifest coverage state)
17
+
18
+ | # | Check | When it applies | What it verifies | Severity |
19
+ |---|---|---|---|---|
20
+ | K1 | Regression guard | Partial module or modified/removed guarantee | Characterization and invariants | Blocking |
21
+ | K2 | Grounding | Partial module | Stable file-path evidence; code cross-check | Important |
22
+ | K3 | Drift threshold | Any tracked module | Drift remains within policy | Important |
23
+ | K4 | Coverage-state accuracy | Promotion/demotion | Status matches evidence | Medium |
24
+
25
+ ## Cross-cutting checks
26
+
27
+ | # | Check | What it verifies | Severity |
28
+ |---|---|---|---|
29
+ | X1 | Cross-runtime review | Validator differs from Codex generator | Blocking |
30
+ | X2 | Observability | LoggerProxy/metrics adequate; no sensitive logging | Medium |
31
+ | X3 | Rollout safety | Defaults, compatibility, rollback/recovery safe | Important |
32
+
33
+ ## How the set is selected
34
+
35
+ 1. Run all six core checks.
36
+ 2. Add K1–K4 for current Partial modules.
37
+ 3. Add X1–X3 for high-risk, contract, security, state, transport, or autonomous changes.
38
+
39
+ ## Output
40
+
41
+ - Compliance matrix, severity-sorted findings, and Pass / Pass-with-warnings / Blocked verdict. Draft only.
@@ -0,0 +1,444 @@
1
+ # Rules — @webex/contact-center
2
+
3
+ > Start here → root [`AGENTS.md`](../AGENTS.md) · router [`SPEC_INDEX.md`](SPEC_INDEX.md) · system [`ARCHITECTURE.md`](ARCHITECTURE.md). These rules are extracted from current package code and reviewed package documentation.
4
+
5
+ ## Coverage Map (which docs/specs to trust)
6
+ | Module | Manifest coverage state | What it means here |
7
+ |---|---|---|
8
+ | `src` | Partial | Existing docs help, but code must be cross-checked until migration, coverage, and validation pass. |
9
+ | `src/metrics` | Partial | Existing docs help, but code must be cross-checked until migration, coverage, and validation pass. |
10
+ | `src/services` | Partial | Existing docs help, but code must be cross-checked until migration, coverage, and validation pass. |
11
+ | `src/services/agent` | Partial | Existing docs help, but code must be cross-checked until migration, coverage, and validation pass. |
12
+ | `src/services/config` | Partial | Existing docs help, but code must be cross-checked until migration, coverage, and validation pass. |
13
+ | `src/services/core` | Partial | Existing docs help, but code must be cross-checked until migration, coverage, and validation pass. |
14
+ | `src/services/task` | Partial | Existing docs help, but code must be cross-checked until migration, coverage, and validation pass. |
15
+ | `src/services/task/state-machine` | Partial | Existing docs help, but code must be cross-checked until migration, coverage, and validation pass. |
16
+ | `src/utils` | Partial | Existing docs help, but code must be cross-checked until migration, coverage, and validation pass. |
17
+
18
+ ## Autonomy & Ask-First
19
+ - **May proceed:** read-only inspection and approved low-risk documentation maintenance.
20
+ - **Ask first / plan + confirm:** code changes, public contract changes, state-machine changes, security-sensitive work, or new dependencies.
21
+ - **Never without explicit human approval:** push, publish, deploy, delete, or post externally.
22
+
23
+ Before submitting code:
24
+
25
+ - [ ] All public APIs have JSDoc with `@public`, `@param`, `@returns`, `@example`
26
+
27
+ - [ ] LoggerProxy used for all logging with module/method context
28
+
29
+ - [ ] MetricsManager tracks success/failure for all operations
30
+
31
+ - [ ] Error handling follows `getErrorDetails` pattern
32
+
33
+ - [ ] No `console.log` or `console.error`
34
+
35
+ - [ ] No hardcoded credentials or sensitive data
36
+
37
+ - [ ] Event constants used (not string literals)
38
+
39
+ - [ ] Types exported appropriately
40
+
41
+ - [ ] Unit tests added/updated
42
+
43
+ - [ ] No `any` types without justification
44
+
45
+ ## Naming
46
+ - Use PascalCase classes/files, camelCase methods, SCREAMING_SNAKE_CASE constants, and typed event constants from their owning module.
47
+
48
+ > **Purpose**: Defines the coding standards, conventions, and architectural rules that all code in `@webex/contact-center` must follow.
49
+
50
+ - TypeScript strict mode is enabled
51
+
52
+ - Avoid `any` type unless absolutely necessary (document justification with `// eslint-disable-line`)
53
+
54
+ - Prefer `unknown` over `any` for unknown types
55
+
56
+ - All public APIs must have explicit return types
57
+
58
+ | Element | Convention | Example |
59
+ |---|---|---|
60
+ | Classes | PascalCase | `ContactCenter`, `TaskManager` |
61
+
62
+ | Element | Convention | Example |
63
+ |---|---|---|
64
+ | Interfaces | PascalCase with `I` prefix for contracts | `IContactCenter`, `ITask`, `IVoice` |
65
+
66
+ | Element | Convention | Example |
67
+ |---|---|---|
68
+ | Types | PascalCase | `SetStateResponse`, `BuddyAgentsResponse` |
69
+
70
+ | Element | Convention | Example |
71
+ |---|---|---|
72
+ | Enums/Constants | SCREAMING_SNAKE_CASE | `CC_EVENTS`, `METRIC_EVENT_NAMES` |
73
+
74
+ | Element | Convention | Example |
75
+ |---|---|---|
76
+ | Methods | camelCase | `stationLogin`, `setAgentState` |
77
+
78
+ | Element | Convention | Example |
79
+ |---|---|---|
80
+ | Private properties | camelCase with `$` prefix for SDK references | `$webex`, `$config` |
81
+
82
+ | Element | Convention | Example |
83
+ |---|---|---|
84
+ | Regular private | camelCase | `agentConfig`, `eventEmitter` |
85
+
86
+ | Element | Convention | Example |
87
+ |---|---|---|
88
+ | Module constants | SCREAMING_SNAKE_CASE | `CC_FILE`, `READY` |
89
+
90
+ - Component files: `PascalCase.ts` (e.g., `TaskManager.ts`, `WebSocketManager.ts`)
91
+
92
+ - Type files: `types.ts` in service folders
93
+
94
+ - Constant files: `constants.ts` in service folders
95
+
96
+ - Index files: `index.ts` for exports
97
+
98
+ All public methods and types must have comprehensive JSDoc:
99
+
100
+ Use `@private` or `@ignore` tag:
101
+
102
+ ```typescript
103
+ /**
104
+ * Internal utility function.
105
+ * @private
106
+ * @ignore
107
+ */
108
+ private helperMethod(): void {
109
+ // implementation
110
+ }
111
+ ```
112
+
113
+ ```typescript
114
+ /**
115
+ * Description of what this type represents.
116
+ * @public
117
+ */
118
+ export type MyType = {
119
+ /** Description of this field */
120
+ fieldName: string;
121
+ /** Optional field description */
122
+ optionalField?: number;
123
+ };
124
+ ```
125
+
126
+ Add new events to `src/metrics/constants.ts`:
127
+
128
+ ```typescript
129
+ export const METRIC_EVENT_NAMES = {
130
+ // Existing events...
131
+ NEW_OPERATION_SUCCESS: 'new operation success',
132
+ NEW_OPERATION_FAILED: 'new operation failed',
133
+ } as const;
134
+ ```
135
+
136
+ - **TypeScript patterns**: [`patterns/typescript-patterns.md`](patterns/typescript-patterns.md)
137
+
138
+ - **Testing patterns**: [`patterns/testing-patterns.md`](patterns/testing-patterns.md)
139
+
140
+ - **Event patterns**: [`patterns/event-driven-patterns.md`](patterns/event-driven-patterns.md)
141
+
142
+ ## Logging
143
+ - Use LoggerProxy with module/method context and tracking identifiers; never use console logging in implementation or log credentials/sensitive data.
144
+
145
+ ```typescript
146
+ // ✅ REQUIRED pattern
147
+ import LoggerProxy from '../../logger-proxy';
148
+
149
+ LoggerProxy.info('Starting operation', {
150
+ module: 'ModuleName',
151
+ method: 'methodName',
152
+ });
153
+ ```
154
+
155
+ | Level | Use Case | Example |
156
+ |---|---|---|
157
+ | `trace` | Detailed debugging | Entry/exit of complex functions |
158
+
159
+ | Level | Use Case | Example |
160
+ |---|---|---|
161
+ | `log` | General information | Operation completed successfully |
162
+
163
+ | Level | Use Case | Example |
164
+ |---|---|---|
165
+ | `info` | Important milestones | Starting registration, login |
166
+
167
+ | Level | Use Case | Example |
168
+ |---|---|---|
169
+ | `warn` | Potential issues | Deprecated usage, fallback behavior |
170
+
171
+ | Level | Use Case | Example |
172
+ |---|---|---|
173
+ | `error` | Failures | API errors, exceptions |
174
+
175
+ ```typescript
176
+ // All log calls MUST include module and method
177
+ {
178
+ module: 'FileName', // Required: Class/file name
179
+ method: 'methodName', // Required: Current method name
180
+ trackingId?: string, // Optional: Request correlation ID
181
+ interactionId?: string, // Optional: Task/call ID
182
+ data?: object, // Optional: Additional context
183
+ error?: Error, // Optional: Error object for error logs
184
+ }
185
+ ```
186
+
187
+ Never log sensitive data:
188
+
189
+ ```typescript
190
+ // ❌ WRONG
191
+ LoggerProxy.log(`User token: ${token}`);
192
+
193
+ // ✅ CORRECT
194
+ LoggerProxy.log('Token received', {
195
+ module: 'Auth',
196
+ method: 'login',
197
+ // No sensitive data in logs
198
+ });
199
+ ```
200
+
201
+ ## Error Handling
202
+ - Preserve structured backend details and tracking ids through shared Core helpers; never swallow failures or synthesize success.
203
+
204
+ ```typescript
205
+ import {getErrorDetails} from './services/core/Utils';
206
+ import {Failure} from './services/core/GlobalTypes';
207
+
208
+ try {
209
+ const result = await this.riskyOperation();
210
+ return result;
211
+ } catch (error) {
212
+ const failure = error.details as Failure;
213
+
214
+ // 1. Track failure metrics
215
+ this.metricsManager.trackEvent(
216
+ METRIC_EVENT_NAMES.OPERATION_FAILED,
217
+ MetricsManager.getCommonTrackingFieldForAQMResponseFailed(failure),
218
+ ['operational']
219
+ );
220
+
221
+ // 2. Get detailed error (logs automatically)
222
+ const {error: detailedError} = getErrorDetails(
223
+ error,
224
+ 'methodName',
225
+ 'ModuleName'
226
+ );
227
+
228
+ // 3. Throw augmented error
229
+ throw detailedError;
230
+ }
231
+ ```
232
+
233
+ ```typescript
234
+ // ❌ WRONG - silently swallowing errors
235
+ try {
236
+ await riskyOperation();
237
+ } catch (error) {
238
+ // doing nothing
239
+ }
240
+
241
+ // ✅ CORRECT - at minimum log the error
242
+ try {
243
+ await riskyOperation();
244
+ } catch (error) {
245
+ LoggerProxy.error(`Operation failed: ${error}`, {
246
+ module: 'ModuleName',
247
+ method: 'methodName',
248
+ });
249
+ throw error;
250
+ }
251
+ ```
252
+
253
+ ## Imports / Dependencies
254
+ - External packages first, then package types/constants, service imports, local utilities, and type-only imports. New runtime dependencies require approval.
255
+
256
+ Services use singleton pattern via `Services` class:
257
+
258
+ ```typescript
259
+ // Access services through Services singleton
260
+ this.services = Services.getInstance({
261
+ webex: this.$webex,
262
+ connectionConfig: this.getConnectionConfig(),
263
+ });
264
+
265
+ // Use services
266
+ await this.services.agent.stationLogin({data});
267
+ await this.services.config.getAgentConfig(orgId, agentId);
268
+ ```
269
+
270
+ Agent/contact services use factory pattern:
271
+
272
+ ```typescript
273
+ // services/agent/index.ts
274
+ export default function routingAgent(routing: AqmReqs) {
275
+ return {
276
+ methodName: routing.req((p: {data: ParamType}) => ({
277
+ url: '/v1/endpoint',
278
+ host: WCC_API_GATEWAY,
279
+ data: p.data,
280
+ err: createErrDetailsObject,
281
+ method: HTTP_METHODS.POST, // Optional, defaults to POST
282
+ notifSuccess: {
283
+ bind: {
284
+ type: CC_EVENTS.SUCCESS_EVENT,
285
+ data: {type: CC_EVENTS.SUCCESS_EVENT},
286
+ },
287
+ msg: {} as SuccessType,
288
+ },
289
+ notifFail: {
290
+ bind: {
291
+ type: CC_EVENTS.FAIL_EVENT,
292
+ data: {type: CC_EVENTS.FAIL_EVENT},
293
+ },
294
+ errId: 'Service.aqm.agent.methodName',
295
+ },
296
+ })),
297
+ };
298
+ }
299
+ ```
300
+
301
+ 1. External packages (`@webex/*`, `events`, `uuid`)
302
+
303
+ 2. Internal absolute imports (types, constants)
304
+
305
+ 3. Relative imports (local files)
306
+
307
+ ```typescript
308
+ // 1. External
309
+ import {WebexPlugin} from '@webex/webex-core';
310
+ import EventEmitter from 'events';
311
+ import {v4 as uuidv4} from 'uuid';
312
+
313
+ // 2. Internal types/constants
314
+ import {WebexSDK, CCPluginConfig, AgentLogin} from './types';
315
+ import {READY, CC_FILE, METHODS} from './constants';
316
+
317
+ // 3. Relative imports
318
+ import Services from './services';
319
+ import LoggerProxy from './logger-proxy';
320
+ import {getErrorDetails} from './services/core/Utils';
321
+ ```
322
+
323
+ - Public types: Export from `src/types.ts`
324
+
325
+ - Internal types: Export from service-level `types.ts`
326
+
327
+ - Services: Use default export for main class, named exports for types
328
+
329
+ ## Testing
330
+ - Mirror source paths under `test/unit/spec/`; cover positive and negative behavior and retain the 85% global coverage threshold.
331
+
332
+ For full testing patterns including test file location, MockWebex setup, singleton mocking, LoggerProxy mocking, and test structure, see [`patterns/testing-patterns.md`](patterns/testing-patterns.md).
333
+
334
+ ## Security
335
+ - Credentials come from the host Webex SDK; validate inputs, use authenticated service routing, and follow `SECURITY.md`.
336
+
337
+ Never commit:
338
+
339
+ - API keys, tokens, secrets
340
+
341
+ - Passwords or authentication data
342
+
343
+ - Private keys or certificates
344
+
345
+ ## Spec-Currency & Drift Thresholds
346
+ - Update specs/docs in the same change as behavior, contracts, state, events, or public types.
347
+ - Partial modules require code cross-checking and characterization before risky changes.
348
+
349
+ ## Secrets Policy
350
+ - No hardcoded secrets, tokens, keys, or connection strings; never log them.
351
+
352
+ ## Concurrency & Async
353
+ - Preserve listener identity for cleanup, avoid blocking the event loop, maintain AQM correlation/timeouts, and keep metrics non-blocking.
354
+
355
+ ```typescript
356
+ // Start timing at method entry
357
+ this.metricsManager.timeEvent([
358
+ METRIC_EVENT_NAMES.SUCCESS_EVENT,
359
+ METRIC_EVENT_NAMES.FAILED_EVENT,
360
+ ]);
361
+
362
+ // Track on success
363
+ this.metricsManager.trackEvent(
364
+ METRIC_EVENT_NAMES.SUCCESS_EVENT,
365
+ {
366
+ ...MetricsManager.getCommonTrackingFieldForAQMResponse(response),
367
+ // Add operation-specific fields
368
+ },
369
+ ['behavioral', 'operational']
370
+ );
371
+
372
+ // Track on failure (in catch block)
373
+ this.metricsManager.trackEvent(
374
+ METRIC_EVENT_NAMES.FAILED_EVENT,
375
+ {
376
+ ...MetricsManager.getCommonTrackingFieldForAQMResponseFailed(failure),
377
+ },
378
+ ['behavioral', 'operational']
379
+ );
380
+ ```
381
+
382
+ Define events as const objects with `as const`:
383
+
384
+ ```typescript
385
+ export const MY_EVENTS = {
386
+ SUCCESS: 'MySuccess',
387
+ FAILED: 'MyFailed',
388
+ } as const;
389
+
390
+ // Extract union type
391
+ type Enum<T extends Record<string, unknown>> = T[keyof T];
392
+ export type MY_EVENTS = Enum<typeof MY_EVENTS>;
393
+ ```
394
+
395
+ Always use event constants:
396
+
397
+ ```typescript
398
+ import {AGENT_EVENTS} from './services/agent/types';
399
+
400
+ // ✅ CORRECT
401
+ this.emit(AGENT_EVENTS.AGENT_STATE_CHANGE, eventData);
402
+
403
+ // ❌ WRONG
404
+ this.emit('stateChange', eventData);
405
+ ```
406
+
407
+ Always use async/await over raw Promises:
408
+
409
+ ```typescript
410
+ // ✅ CORRECT
411
+ public async fetchData(): Promise<Data> {
412
+ const result = await this.service.getData();
413
+ return result;
414
+ }
415
+
416
+ // ❌ AVOID (when possible)
417
+ public fetchData(): Promise<Data> {
418
+ return this.service.getData().then(result => result);
419
+ }
420
+ ```
421
+
422
+ Always clean up resources:
423
+
424
+ ```typescript
425
+ public async deregister(): Promise<void> {
426
+ // Remove event listeners
427
+ this.taskManager.off(TASK_EVENTS.TASK_INCOMING, this.handleIncomingTask);
428
+ this.services.webSocketManager.off('message', this.handleWebsocketMessage);
429
+
430
+ // Close connections
431
+ if (!this.services.webSocketManager.isSocketClosed) {
432
+ this.services.webSocketManager.close(false, 'Reason');
433
+ }
434
+
435
+ // Clear state
436
+ this.agentConfig = null;
437
+ }
438
+ ```
439
+
440
+ ## Strict-Compliance Mode
441
+ - In rigorous SDD runs, stop on unresolved questionnaire facts, source-fidelity failures, template-conformance blockers, or validator findings. Generated specs require review by the manifest-configured independent runtime.
442
+
443
+ ## Maintenance
444
+ - Add a rule when a review correction recurs; remove duplication when tooling enforces it. Patterns remain in `patterns/`.
@@ -0,0 +1,52 @@
1
+ # Security Baseline — @webex/contact-center
2
+
3
+ > Start here → root [`AGENTS.md`](../AGENTS.md) · router [`SPEC_INDEX.md`](SPEC_INDEX.md) · system [`ARCHITECTURE.md`](ARCHITECTURE.md).
4
+
5
+ ## Trust Boundaries
6
+
7
+ | Boundary | Untrusted side | Trusted side | What is enforced at the crossing |
8
+ |---|---|---|---|
9
+ | Exported SDK methods | Host application input | ContactCenter/module methods | Typed inputs, runtime validation where implemented, typed errors |
10
+ | REST construction | SDK data | Webex request/service routing | Host credentials, service identifier, method/path/payload mapping |
11
+ | WebSocket parsing | Remote messages | ContactCenter/Task/AqmReqs | JSON parsing, event-type mapping, correlation/guards |
12
+ | Logs/metrics | Runtime data | Remote observability systems | Context selection and no credential/sensitive-data logging |
13
+
14
+ ## Authentication & Authorization Model
15
+
16
+ - **Authentication:** supplied and maintained by the host Webex SDK (`src/services/core/WebexRequest.ts`).
17
+ - **Authorization:** remote WCC services enforce tenant/agent permissions; this package must not bypass host service routing.
18
+ - **Default posture:** no standalone credentials or local authorization store.
19
+
20
+ ## Secret & Credential Handling
21
+
22
+ - Secrets source and injection: host Webex SDK/runtime configuration; never source code.
23
+ - Rotation: owned by the host credential system and remote services.
24
+ - **Hard rule:** never commit or log secrets, tokens, keys, or connection strings.
25
+
26
+ ## Data Classification & Handling
27
+
28
+ | Data class | Examples | Storage rule | Logging rule | In transit |
29
+ |---|---|---|---|---|
30
+ | Identity/PII | agent id/name/email, dial number | ephemeral client memory; remote system of record | do not log raw sensitive values | host-resolved HTTPS/WSS |
31
+ | Interaction data | task/customer/call metadata | ephemeral task state; remote system of record | use tracking/interaction ids, minimize payloads | HTTPS/WSS/WebRTC |
32
+ | Credentials | access tokens/service auth | host-owned only | never log | HTTPS/WSS |
33
+
34
+ ## Input Validation & Output Encoding Posture
35
+
36
+ - Validate public inputs before request construction; use typed constants and endpoint builders; never concatenate credentials or executable commands.
37
+
38
+ ## Transport & Headers
39
+
40
+ - Authenticated requests use the Webex SDK service catalog and HTTPS. Realtime traffic uses host-resolved WSS; header/environment behavior is owned by `src/services/core/WebexRequest.ts` and the host request layer.
41
+
42
+ ## Known Sensitive Areas & Accepted Risks
43
+
44
+ | Area | Risk | Mitigation / why accepted | Owner |
45
+ |---|---|---|---|
46
+ | Log upload | Runtime context could contain sensitive values | Shared error helpers upload only approved diagnostic context; never add credentials/payload dumps | Contact Center maintainers |
47
+ | WebSocket event parsing | Malformed/unexpected remote data | Parse defensively, map known event constants, ignore/reject invalid transitions | Core/Task maintainers |
48
+ | Public dial/contact inputs | PII and external numbers | Validate and avoid logging raw values | Contact Center maintainers |
49
+
50
+ ## Reporting & Review
51
+
52
+ - Security-sensitive changes require package-owner review and independent SDD validation. Report vulnerabilities through the repository's documented Cisco security/support process.
@@ -0,0 +1,48 @@
1
+ # Service State (living) — @webex/contact-center
2
+
3
+ > Start here → root [`AGENTS.md`](../AGENTS.md) · router [`SPEC_INDEX.md`](SPEC_INDEX.md) · system [`ARCHITECTURE.md`](ARCHITECTURE.md). Read before adding a surface.
4
+
5
+ ## Current Events
6
+
7
+ | Event / topic | Direction | Producer/consumer | Payload ref |
8
+ |---|---|---|---|
9
+ | `agent:*` | publish | ContactCenter → application | `src/services/agent/types.ts` |
10
+ | `task:*` | publish | Task/TaskManager → application | `src/services/task/types.ts` |
11
+ | `CC_EVENTS` | consume | WCC WebSocket → Core/ContactCenter/Task/AqmReqs | `src/services/config/types.ts` |
12
+ | realtime transcript/suggestion | consume/publish | RTD WebSocket → owning Task | `src/services/task/TaskManager.ts` |
13
+
14
+ ## Data Stores
15
+
16
+ | Store | Purpose | Owned by this service? |
17
+ |---|---|---|
18
+ | In-memory PageCache Map | temporary paginated lookup reuse | ephemeral only; yes for cache entries |
19
+ | Remote WCC stores | agent/task/config domain state | no |
20
+
21
+ ## External Dependencies
22
+
23
+ | Dependency | Used for | Timeout / retry | Circuit breaker / fallback |
24
+ |---|---|---|---|
25
+ | WCC API gateway | agent/task/config/data operations | operation/AQM timeouts | propagate structured failure |
26
+ | WCC WebSocket/RTD | realtime events and completion | reconnect and recovery timers | reconnect/silent relogin/restore failure |
27
+ | Webex Calling | BROWSER call lifecycle | async registration/call timeouts | emit/rethrow calling failure |
28
+ | Webex metrics | telemetry | nonblocking queued submission | log/drop without breaking product flow |
29
+
30
+ ## Key Metrics & Performance Targets
31
+
32
+ | Signal | Target | Where measured |
33
+ |---|---|---|
34
+ | Unit coverage | 85% branches/functions/lines/statements | package Jest configuration |
35
+ | Operation duration/success/failure | no local numeric SLO routed | MetricsManager event taxonomy |
36
+ | Connection recovery | explicit 8s disconnect, 5s retry, configured restore timeout | Core constants/ConnectionService |
37
+
38
+ ## Feature Flags (current)
39
+
40
+ | Flag/config | Gates | Current default | Owner | Safe to remove when |
41
+ |---|---|---|---|---|
42
+ | `allowAutomatedRelogin` | silent relogin after recovery | config-defined | ContactCenter | replacement recovery contract exists |
43
+ | `webRtcEnabled` / login option | browser calling path | remote profile | Config/WCC | remote contract removed |
44
+ | task UI/config flags | task controls and operations | profile/config-defined | Task/Config | owning behavior removed |
45
+
46
+ ## Maintenance
47
+
48
+ - Update the relevant row in the same change as any surface, dependency, timeout, metric, or flag.
@@ -0,0 +1,65 @@
1
+ # Spec Index — @webex/contact-center
2
+
3
+ > Start here → root [`AGENTS.md`](../AGENTS.md). This router mirrors `.sdd/manifest.json`; system overview: [`ARCHITECTURE.md`](ARCHITECTURE.md).
4
+
5
+ ## Module Registry
6
+
7
+ | Module | Responsibility | Manifest coverage state | Start here |
8
+ |---|---|---|---|
9
+ | `src` | Own the published Webex Contact Center SDK plugin surface, registration lifecycle, public method delegation, and application-facing event routing. | Partial | `ai-docs/contact-center-spec.md` |
10
+ | `src/metrics` | Own timing, taxonomy, queuing, payload preparation, and submission for Contact Center behavioral, operational, and business telemetry. | Partial | `src/metrics/ai-docs/metrics-spec.md` |
11
+ | `src/services` | Own composition and bootstrap order for backend request, realtime, data, and WebRTC service collaborators. | Partial | `src/services/ai-docs/services-spec.md` |
12
+ | `src/services/agent` | Own agent login, logout, state-change, buddy-agent, device-update, and silent-relogin request contracts. | Partial | `src/services/agent/ai-docs/agent-spec.md` |
13
+ | `src/services/config` | Own retrieval and aggregation of remote organization, agent, team, profile, auxiliary-code, dial-plan, and feature configuration. | Partial | `src/services/config/ai-docs/config-spec.md` |
14
+ | `src/services/core` | Own authenticated HTTP, realtime WebSocket lifecycle, AQM request correlation, reconnect/keepalive behavior, and shared error normalization. | Partial | `src/services/core/ai-docs/core-spec.md` |
15
+ | `src/services/task` | Own task creation, media-specific behavior, call-control operations, lifecycle orchestration, task events, and integration with the task state machine. | Partial | `src/services/task/ai-docs/task-spec.md` |
16
+ | `src/services/task/state-machine` | Own deterministic task lifecycle states, transition guards/actions, typed internal events, and state-derived UI-control availability. | Partial | `src/services/task/state-machine/ai-docs/task-state-machine-spec.md` |
17
+ | `src/utils` | Own shared pagination contracts and the bounded in-memory page cache used by Contact Center data services. | Partial | `src/utils/ai-docs/utils-spec.md` |
18
+
19
+ ## Task Routing
20
+
21
+ | If the task is… | Load |
22
+ |---|---|
23
+ | Understanding the package | `ARCHITECTURE.md` |
24
+ | Working in a module | That module's specification from the registry |
25
+ | Changing exported APIs/events/types | `CONTRACTS.md`, Contact Center spec, and owning module spec |
26
+ | Changing task state | Task and Task State Machine specs |
27
+ | Changing transport/recovery | Core spec and `SECURITY.md` |
28
+ | New feature or defect | Run lifecycle intake against the affected module specs |
29
+
30
+ ## Intake Routing
31
+
32
+ ```text
33
+ New feature / bug / contract change → lifecycle intake questionnaire → feature spec/design
34
+ New module → update module registry + module spec + contracts
35
+ Doc/spec backfill → reconcile target → conformance → coverage → independent validation
36
+ ```
37
+
38
+ ## Incident History
39
+
40
+ | INC id | Date | Module | One-line | Link |
41
+ |---|---|---|---|---|
42
+ | None routed | 2026-07-07 | N/A | No incident/RCA source was supplied during onboarding. | N/A |
43
+
44
+ ## Phase-Based Loading Protocol
45
+
46
+ | Phase | Load |
47
+ |---|---|
48
+ | Orient | AGENTS.md + this file |
49
+ | Specify | relevant module specs + questionnaire |
50
+ | Build | selected module specs + RULES/patterns |
51
+ | Verify | independent validation and coverage evidence |
52
+
53
+ ## Spec Registry
54
+
55
+ | Doc | Location | Purpose |
56
+ |---|---|---|
57
+ | Patterns | `patterns/` | Existing implementation conventions |
58
+ | Rules | `RULES.md` | Enforceable do/don't constraints |
59
+ | Glossary | `GLOSSARY.md` | Domain language |
60
+ | Security | `SECURITY.md` | Trust boundaries and sensitive-data rules |
61
+ | Contracts | `CONTRACTS.md` | Public/export/event/dependency index |
62
+ | Service state | `SERVICE_STATE.md` | Current as-built surfaces/dependencies/flags |
63
+ | Getting started | `GETTING_STARTED.md` | Build/test loop |
64
+ | Decision records | `adr/` | Durable architecture decisions |
65
+ | Review catalog | `REVIEW_CHECKLIST.md` | Review gates |