@webex/contact-center 3.11.0 → 3.12.0-auth-prejoin-fetch.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.sdd/manifest.json +883 -0
- package/AGENTS.md +94 -0
- package/ai-docs/ARCHITECTURE.md +168 -0
- package/ai-docs/CONTRACTS.md +50 -0
- package/ai-docs/GETTING_STARTED.md +168 -0
- package/ai-docs/GLOSSARY.md +43 -0
- package/ai-docs/README.md +138 -0
- package/ai-docs/REVIEW_CHECKLIST.md +41 -0
- package/ai-docs/RULES.md +444 -0
- package/ai-docs/SECURITY.md +52 -0
- package/ai-docs/SERVICE_STATE.md +48 -0
- package/ai-docs/SPEC_INDEX.md +65 -0
- package/ai-docs/adr/0001-spec-source-policy.md +55 -0
- package/ai-docs/adr/README.md +8 -0
- package/ai-docs/adr/_adr-template.md +31 -0
- package/ai-docs/contact-center-spec.md +359 -0
- package/ai-docs/features/consult-transfer-list-policy/spec/feature-spec.md +362 -0
- package/ai-docs/features/generated-spec-conformance-fidelity-remediation/spec/feature-spec.md +117 -0
- package/ai-docs/features/residual-warning-coverage-completion/spec/feature-spec.md +203 -0
- package/ai-docs/features/validator-code-fidelity-drift-fix/spec/feature-spec.md +315 -0
- package/ai-docs/patterns/event-driven-patterns.md +485 -0
- package/ai-docs/patterns/testing-patterns.md +480 -0
- package/ai-docs/patterns/typescript-patterns.md +365 -0
- package/ai-docs/templates/README.md +102 -0
- package/ai-docs/templates/documentation/create-agents-md.md +240 -0
- package/ai-docs/templates/documentation/create-architecture-md.md +295 -0
- package/ai-docs/templates/existing-service/bug-fix.md +254 -0
- package/ai-docs/templates/existing-service/feature-enhancement.md +450 -0
- package/ai-docs/templates/new-method/00-master.md +80 -0
- package/ai-docs/templates/new-method/01-requirements.md +232 -0
- package/ai-docs/templates/new-method/02-implementation.md +295 -0
- package/ai-docs/templates/new-method/03-tests.md +201 -0
- package/ai-docs/templates/new-method/04-validation.md +141 -0
- package/ai-docs/templates/new-service/00-master.md +109 -0
- package/ai-docs/templates/new-service/01-pre-questions.md +159 -0
- package/ai-docs/templates/new-service/02-code-generation.md +346 -0
- package/ai-docs/templates/new-service/03-integration.md +178 -0
- package/ai-docs/templates/new-service/04-test-generation.md +205 -0
- package/ai-docs/templates/new-service/05-validation.md +145 -0
- package/dist/cc.js +818 -59
- package/dist/cc.js.map +1 -1
- package/dist/config.js +13 -0
- package/dist/config.js.map +1 -1
- package/dist/constants.js +31 -3
- package/dist/constants.js.map +1 -1
- package/dist/index.js +27 -5
- package/dist/index.js.map +1 -1
- package/dist/metrics/behavioral-events.js +127 -0
- package/dist/metrics/behavioral-events.js.map +1 -1
- package/dist/metrics/constants.js +34 -3
- package/dist/metrics/constants.js.map +1 -1
- package/dist/services/AddressBook.js +18 -15
- package/dist/services/AddressBook.js.map +1 -1
- package/dist/services/AnswerCallOnWebexService.js +174 -0
- package/dist/services/AnswerCallOnWebexService.js.map +1 -0
- package/dist/services/ApiAiAssistant.js +318 -0
- package/dist/services/ApiAiAssistant.js.map +1 -0
- package/dist/services/EntryPoint.js +46 -68
- package/dist/services/EntryPoint.js.map +1 -1
- package/dist/services/Queue.js +27 -22
- package/dist/services/Queue.js.map +1 -1
- package/dist/services/UserPreference.js +427 -0
- package/dist/services/UserPreference.js.map +1 -0
- package/dist/services/WebexCrossClientService.js +171 -0
- package/dist/services/WebexCrossClientService.js.map +1 -0
- package/dist/services/WxAppTelephonyMercurySync.js +93 -0
- package/dist/services/WxAppTelephonyMercurySync.js.map +1 -0
- package/dist/services/agent/types.js.map +1 -1
- package/dist/services/config/Util.js +11 -4
- package/dist/services/config/Util.js.map +1 -1
- package/dist/services/config/constants.js +45 -8
- package/dist/services/config/constants.js.map +1 -1
- package/dist/services/config/index.js +41 -2
- package/dist/services/config/index.js.map +1 -1
- package/dist/services/config/types.js +70 -8
- package/dist/services/config/types.js.map +1 -1
- package/dist/services/constants.js +27 -1
- package/dist/services/constants.js.map +1 -1
- package/dist/services/core/Err.js.map +1 -1
- package/dist/services/core/Utils.js +122 -25
- package/dist/services/core/Utils.js.map +1 -1
- package/dist/services/core/WebexRequest.js +6 -2
- package/dist/services/core/WebexRequest.js.map +1 -1
- package/dist/services/core/aqm-reqs.js +119 -30
- package/dist/services/core/aqm-reqs.js.map +1 -1
- package/dist/services/core/types.js.map +1 -1
- package/dist/services/core/websocket/WebSocketManager.js +22 -6
- package/dist/services/core/websocket/WebSocketManager.js.map +1 -1
- package/dist/services/core/websocket/connection-service.js +3 -1
- package/dist/services/core/websocket/connection-service.js.map +1 -1
- package/dist/services/core/websocket/types.js.map +1 -1
- package/dist/services/index.js +6 -0
- package/dist/services/index.js.map +1 -1
- package/dist/services/task/Task.js +754 -0
- package/dist/services/task/Task.js.map +1 -0
- package/dist/services/task/TaskFactory.js +49 -0
- package/dist/services/task/TaskFactory.js.map +1 -0
- package/dist/services/task/TaskManager.js +1073 -447
- package/dist/services/task/TaskManager.js.map +1 -1
- package/dist/services/task/TaskUtils.js +220 -23
- package/dist/services/task/TaskUtils.js.map +1 -1
- package/dist/services/task/WebexCallingUtils.js +70 -0
- package/dist/services/task/WebexCallingUtils.js.map +1 -0
- package/dist/services/task/constants.js +26 -2
- package/dist/services/task/constants.js.map +1 -1
- package/dist/services/task/contact.js +29 -0
- package/dist/services/task/contact.js.map +1 -1
- package/dist/services/task/dialer.js +129 -0
- package/dist/services/task/dialer.js.map +1 -1
- package/dist/services/task/digital/Digital.js +78 -0
- package/dist/services/task/digital/Digital.js.map +1 -0
- package/dist/services/task/state-machine/TaskStateMachine.js +971 -0
- package/dist/services/task/state-machine/TaskStateMachine.js.map +1 -0
- package/dist/services/task/state-machine/actions.js +572 -0
- package/dist/services/task/state-machine/actions.js.map +1 -0
- package/dist/services/task/state-machine/constants.js +161 -0
- package/dist/services/task/state-machine/constants.js.map +1 -0
- package/dist/services/task/state-machine/guards.js +409 -0
- package/dist/services/task/state-machine/guards.js.map +1 -0
- package/dist/services/task/state-machine/index.js +53 -0
- package/dist/services/task/state-machine/index.js.map +1 -0
- package/dist/services/task/state-machine/types.js +54 -0
- package/dist/services/task/state-machine/types.js.map +1 -0
- package/dist/services/task/state-machine/uiControlsComputer.js +703 -0
- package/dist/services/task/state-machine/uiControlsComputer.js.map +1 -0
- package/dist/services/task/taskDataNormalizer.js +99 -0
- package/dist/services/task/taskDataNormalizer.js.map +1 -0
- package/dist/services/task/types.js +243 -5
- package/dist/services/task/types.js.map +1 -1
- package/dist/services/task/voice/Voice.js +1380 -0
- package/dist/services/task/voice/Voice.js.map +1 -0
- package/dist/services/task/voice/WebRTC.js +152 -0
- package/dist/services/task/voice/WebRTC.js.map +1 -0
- package/dist/services/task/voice/wxAppVoiceMethods.js +201 -0
- package/dist/services/task/voice/wxAppVoiceMethods.js.map +1 -0
- package/dist/services/wxAppTelephonyUtils.js +19 -0
- package/dist/services/wxAppTelephonyUtils.js.map +1 -0
- package/dist/types/cc.d.ts +967 -0
- package/dist/types/config.d.ts +79 -0
- package/dist/types/constants.d.ts +74 -0
- package/dist/types/index.d.ts +201 -0
- package/dist/types/logger-proxy.d.ts +71 -0
- package/dist/types/metrics/MetricsManager.d.ts +223 -0
- package/dist/types/metrics/behavioral-events.d.ts +29 -0
- package/dist/types/metrics/constants.d.ts +183 -0
- package/dist/types/services/AddressBook.d.ts +75 -0
- package/dist/types/services/AnswerCallOnWebexService.d.ts +37 -0
- package/dist/types/services/ApiAiAssistant.d.ts +49 -0
- package/dist/types/services/EntryPoint.d.ts +69 -0
- package/dist/types/services/Queue.d.ts +78 -0
- package/dist/types/services/UserPreference.d.ts +118 -0
- package/dist/types/services/WebCallingService.d.ts +1 -0
- package/dist/types/services/WebexCrossClientService.d.ts +28 -0
- package/dist/types/services/WxAppTelephonyMercurySync.d.ts +28 -0
- package/dist/types/services/agent/index.d.ts +46 -0
- package/dist/types/services/agent/types.d.ts +413 -0
- package/dist/types/services/config/Util.d.ts +20 -0
- package/dist/types/services/config/constants.d.ts +273 -0
- package/dist/types/services/config/index.d.ts +177 -0
- package/dist/types/services/config/types.d.ts +1381 -0
- package/dist/types/services/constants.d.ts +110 -0
- package/dist/types/services/core/Err.d.ts +127 -0
- package/dist/types/services/core/GlobalTypes.d.ts +58 -0
- package/dist/types/services/core/Utils.d.ts +121 -0
- package/dist/types/services/core/WebexRequest.d.ts +23 -0
- package/dist/types/services/core/aqm-reqs.d.ts +65 -0
- package/dist/types/services/core/constants.d.ts +99 -0
- package/dist/types/services/core/types.d.ts +49 -0
- package/dist/types/services/core/websocket/WebSocketManager.d.ts +36 -0
- package/dist/types/services/core/websocket/connection-service.d.ts +27 -0
- package/dist/types/services/core/websocket/keepalive.worker.d.ts +2 -0
- package/dist/types/services/core/websocket/types.d.ts +37 -0
- package/dist/types/services/index.d.ts +54 -0
- package/dist/types/services/task/AutoWrapup.d.ts +40 -0
- package/dist/types/services/task/Task.d.ts +175 -0
- package/dist/types/services/task/TaskFactory.d.ts +13 -0
- package/dist/types/services/task/TaskManager.d.ts +1 -0
- package/dist/types/services/task/TaskUtils.d.ts +138 -0
- package/dist/types/services/task/WebexCallingUtils.d.ts +11 -0
- package/dist/types/services/task/constants.d.ts +94 -0
- package/dist/types/services/task/contact.d.ts +73 -0
- package/dist/types/services/task/dialer.d.ts +73 -0
- package/dist/types/services/task/digital/Digital.d.ts +22 -0
- package/dist/types/services/task/state-machine/TaskStateMachine.d.ts +1398 -0
- package/dist/types/services/task/state-machine/actions.d.ts +10 -0
- package/dist/types/services/task/state-machine/constants.d.ts +107 -0
- package/dist/types/services/task/state-machine/guards.d.ts +103 -0
- package/dist/types/services/task/state-machine/index.d.ts +13 -0
- package/dist/types/services/task/state-machine/types.d.ts +277 -0
- package/dist/types/services/task/state-machine/uiControlsComputer.d.ts +9 -0
- package/dist/types/services/task/taskDataNormalizer.d.ts +10 -0
- package/dist/types/services/task/types.d.ts +1933 -0
- package/dist/types/services/task/voice/Voice.d.ts +223 -0
- package/dist/types/services/task/voice/WebRTC.d.ts +53 -0
- package/dist/types/services/task/voice/wxAppVoiceMethods.d.ts +52 -0
- package/dist/types/services/wxAppTelephonyUtils.d.ts +5 -0
- package/dist/types/types.d.ts +784 -0
- package/dist/types/utils/PageCache.d.ts +190 -0
- package/dist/types/webex-config.d.ts +53 -0
- package/dist/types/webex.d.ts +8 -0
- package/dist/types.js +137 -3
- package/dist/types.js.map +1 -1
- package/dist/utils/PageCache.js +19 -5
- package/dist/utils/PageCache.js.map +1 -1
- package/dist/webex.js +14 -2
- package/dist/webex.js.map +1 -1
- package/package.json +16 -12
- package/src/cc.ts +983 -60
- package/src/config.ts +13 -0
- package/src/constants.ts +29 -1
- package/src/index.ts +26 -5
- package/src/metrics/ai-docs/AGENTS.md +350 -0
- package/src/metrics/ai-docs/ARCHITECTURE.md +338 -0
- package/src/metrics/ai-docs/metrics-spec.md +860 -0
- package/src/metrics/behavioral-events.ts +134 -0
- package/src/metrics/constants.ts +39 -3
- package/src/services/AddressBook.ts +17 -6
- package/src/services/AnswerCallOnWebexService.ts +206 -0
- package/src/services/ApiAiAssistant.ts +412 -0
- package/src/services/EntryPoint.ts +59 -60
- package/src/services/Queue.ts +29 -12
- package/src/services/UserPreference.ts +509 -0
- package/src/services/WebexCrossClientService.ts +212 -0
- package/src/services/WxAppTelephonyMercurySync.ts +115 -0
- package/src/services/agent/ai-docs/AGENTS.md +240 -0
- package/src/services/agent/ai-docs/ARCHITECTURE.md +304 -0
- package/src/services/agent/ai-docs/agent-spec.md +504 -0
- package/src/services/agent/types.ts +1 -1
- package/src/services/ai-docs/AGENTS.md +386 -0
- package/src/services/ai-docs/services-spec.md +497 -0
- package/src/services/config/Util.ts +13 -2
- package/src/services/config/ai-docs/AGENTS.md +255 -0
- package/src/services/config/ai-docs/ARCHITECTURE.md +426 -0
- package/src/services/config/ai-docs/config-spec.md +675 -0
- package/src/services/config/constants.ts +47 -7
- package/src/services/config/index.ts +45 -1
- package/src/services/config/types.ts +253 -11
- package/src/services/constants.ts +29 -0
- package/src/services/core/Err.ts +4 -0
- package/src/services/core/Utils.ts +143 -30
- package/src/services/core/WebexRequest.ts +3 -1
- package/src/services/core/ai-docs/AGENTS.md +381 -0
- package/src/services/core/ai-docs/ARCHITECTURE.md +698 -0
- package/src/services/core/ai-docs/core-spec.md +787 -0
- package/src/services/core/aqm-reqs.ts +125 -32
- package/src/services/core/types.ts +2 -0
- package/src/services/core/websocket/WebSocketManager.ts +23 -6
- package/src/services/core/websocket/connection-service.ts +5 -1
- package/src/services/core/websocket/types.ts +1 -1
- package/src/services/index.ts +4 -0
- package/src/services/task/Task.ts +908 -0
- package/src/services/task/TaskFactory.ts +60 -0
- package/src/services/task/TaskManager.ts +1291 -513
- package/src/services/task/TaskUtils.ts +314 -24
- package/src/services/task/WebexCallingUtils.ts +136 -0
- package/src/services/task/ai-docs/AGENTS.md +457 -0
- package/src/services/task/ai-docs/ARCHITECTURE.md +595 -0
- package/src/services/task/ai-docs/task-spec.md +1469 -0
- package/src/services/task/constants.ts +26 -0
- package/src/services/task/contact.ts +30 -0
- package/src/services/task/dialer.ts +136 -1
- package/src/services/task/digital/Digital.ts +97 -0
- package/src/services/task/state-machine/TaskStateMachine.ts +1313 -0
- package/src/services/task/state-machine/actions.ts +741 -0
- package/src/services/task/state-machine/ai-docs/AGENTS.md +462 -0
- package/src/services/task/state-machine/ai-docs/ARCHITECTURE.md +1146 -0
- package/src/services/task/state-machine/ai-docs/task-state-machine-spec.md +2209 -0
- package/src/services/task/state-machine/constants.ts +172 -0
- package/src/services/task/state-machine/guards.ts +498 -0
- package/src/services/task/state-machine/index.ts +28 -0
- package/src/services/task/state-machine/types.ts +258 -0
- package/src/services/task/state-machine/uiControlsComputer.ts +1135 -0
- package/src/services/task/taskDataNormalizer.ts +137 -0
- package/src/services/task/types.ts +843 -70
- package/src/services/task/voice/Voice.ts +1720 -0
- package/src/services/task/voice/WebRTC.ts +191 -0
- package/src/services/task/voice/wxAppVoiceMethods.ts +307 -0
- package/src/services/wxAppTelephonyUtils.ts +14 -0
- package/src/types.ts +238 -11
- package/src/utils/AGENTS.md +289 -0
- package/src/utils/PageCache.ts +38 -5
- package/src/utils/ai-docs/utils-spec.md +391 -0
- package/src/webex.js +2 -0
- package/test/unit/spec/cc.ts +1856 -122
- package/test/unit/spec/logger-proxy.ts +70 -0
- package/test/unit/spec/metrics/behavioral-events.ts +18 -0
- package/test/unit/spec/services/AddressBook.ts +37 -6
- package/test/unit/spec/services/AnswerCallOnWebexService.ts +223 -0
- package/test/unit/spec/services/ApiAiAssistant.ts +273 -0
- package/test/unit/spec/services/EntryPoint.ts +87 -40
- package/test/unit/spec/services/Queue.ts +123 -12
- package/test/unit/spec/services/UserPreference.ts +401 -0
- package/test/unit/spec/services/WebCallingService.ts +7 -1
- package/test/unit/spec/services/WebexCrossClientService.ts +261 -0
- package/test/unit/spec/services/WxAppTelephonyMercurySync.ts +113 -0
- package/test/unit/spec/services/config/Util.ts +85 -0
- package/test/unit/spec/services/config/index.ts +85 -29
- package/test/unit/spec/services/core/Utils.ts +481 -2
- package/test/unit/spec/services/core/WebexRequest.ts +3 -1
- package/test/unit/spec/services/core/aqm-reqs.ts +113 -1
- package/test/unit/spec/services/core/websocket/WebSocketManager.ts +137 -41
- package/test/unit/spec/services/core/websocket/connection-service.ts +3 -1
- package/test/unit/spec/services/task/AutoWrapup.ts +63 -0
- package/test/unit/spec/services/task/Task.ts +677 -0
- package/test/unit/spec/services/task/TaskFactory.ts +99 -0
- package/test/unit/spec/services/task/TaskManager.ts +2209 -918
- package/test/unit/spec/services/task/TaskUtils.ts +235 -0
- package/test/unit/spec/services/task/WebexCallingUtils.ts +153 -0
- package/test/unit/spec/services/task/contact.ts +33 -0
- package/test/unit/spec/services/task/dialer.ts +372 -96
- package/test/unit/spec/services/task/digital/Digital.ts +105 -0
- package/test/unit/spec/services/task/state-machine/TaskStateMachine.ts +3433 -0
- package/test/unit/spec/services/task/state-machine/guards.ts +839 -0
- package/test/unit/spec/services/task/state-machine/types.ts +18 -0
- package/test/unit/spec/services/task/state-machine/uiControlsComputer.ts +3101 -0
- package/test/unit/spec/services/task/taskTestUtils.ts +87 -0
- package/test/unit/spec/services/task/voice/Voice.ts +1523 -0
- package/test/unit/spec/services/task/voice/WebRTC.ts +235 -0
- package/test/unit/spec/services/task/voice/wxAppVoiceMethods.ts +459 -0
- package/umd/contact-center.min.js +2 -2
- package/umd/contact-center.min.js.map +1 -1
- package/dist/services/task/index.js +0 -1525
- package/dist/services/task/index.js.map +0 -1
- package/src/services/task/index.ts +0 -1801
- package/test/unit/spec/services/task/index.ts +0 -2184
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# Contact Center SDK - AI Documentation
|
|
2
|
+
|
|
3
|
+
> AI-focused documentation for the `@webex/contact-center` package to enable LLM agents to effectively create, modify, and fix SDK code.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Package Overview
|
|
8
|
+
|
|
9
|
+
The `@webex/contact-center` package is a Webex SDK plugin that provides a TypeScript/JavaScript API for building Contact Center agent applications. It enables:
|
|
10
|
+
|
|
11
|
+
- **Agent Session Management**: Register, login, logout, state changes
|
|
12
|
+
- **Task Handling**: Inbound/outbound calls, chat, transfers, conferences
|
|
13
|
+
- **Real-time Events**: WebSocket-based notifications for agent and task events
|
|
14
|
+
- **Browser-based Calling**: WebRTC integration for browser softphone
|
|
15
|
+
- **Metrics & Diagnostics**: Built-in telemetry and log upload
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Technologies
|
|
20
|
+
|
|
21
|
+
| Technology | Purpose |
|
|
22
|
+
|------------|---------|
|
|
23
|
+
| **TypeScript** | Primary language with strict mode |
|
|
24
|
+
| **WebexPlugin** | Base class from `@webex/webex-core` |
|
|
25
|
+
| **EventEmitter** | Event handling for real-time updates |
|
|
26
|
+
| **WebSocket** | Real-time communication with Contact Center |
|
|
27
|
+
| **WebRTC** | Browser-based calling (via WebCalling) |
|
|
28
|
+
| **Jest** | Unit testing framework |
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Quick Links
|
|
33
|
+
|
|
34
|
+
| Document | Purpose |
|
|
35
|
+
|----------|---------|
|
|
36
|
+
| [AGENTS.md](../AGENTS.md) | **Start here** - Main AI agent orchestrator (at package root) |
|
|
37
|
+
| [SPEC_INDEX.md](SPEC_INDEX.md) | Route work to the owning canonical module specification |
|
|
38
|
+
| [RULES.md](RULES.md) | Coding standards and conventions |
|
|
39
|
+
| [patterns/](patterns/) | Pattern documentation |
|
|
40
|
+
| [templates/](templates/) | Code generation templates |
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## For AI Agents
|
|
45
|
+
|
|
46
|
+
### Starting a Task
|
|
47
|
+
|
|
48
|
+
Start with the root [`AGENTS.md`](../AGENTS.md) for critical repository rules and the developer workflow, then use [`SPEC_INDEX.md`](SPEC_INDEX.md) to classify the task by owning module and open its canonical `*-spec.md`.
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Directory Structure
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
packages/@webex/contact-center/
|
|
56
|
+
├── AGENTS.md # Main orchestrator (start here — at package root)
|
|
57
|
+
└── ai-docs/
|
|
58
|
+
├── README.md # This file
|
|
59
|
+
├── SPEC_INDEX.md # Canonical module router
|
|
60
|
+
├── contact-center-spec.md # Canonical public plugin specification
|
|
61
|
+
├── CONTRACTS.md # Public contract catalog
|
|
62
|
+
├── adr/ # Durable architecture decisions
|
|
63
|
+
├── RULES.md # Coding standards
|
|
64
|
+
├── patterns/ # Pattern documentation
|
|
65
|
+
│ ├── typescript-patterns.md
|
|
66
|
+
│ ├── testing-patterns.md
|
|
67
|
+
│ └── event-driven-patterns.md
|
|
68
|
+
└── templates/ # Code generation templates
|
|
69
|
+
├── README.md
|
|
70
|
+
├── new-service/ # Creating new services
|
|
71
|
+
├── new-method/ # Adding methods
|
|
72
|
+
├── existing-service/ # Bug fixes, features
|
|
73
|
+
└── documentation/ # Doc generation
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Package Commands
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
# Build
|
|
82
|
+
yarn workspace @webex/contact-center build:src
|
|
83
|
+
|
|
84
|
+
# Test unit tests
|
|
85
|
+
yarn workspace @webex/contact-center test:unit
|
|
86
|
+
|
|
87
|
+
# Test specific file
|
|
88
|
+
yarn workspace @webex/contact-center test:unit -- <path_of_test_file>
|
|
89
|
+
|
|
90
|
+
# Lint
|
|
91
|
+
yarn workspace @webex/contact-center test:style
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Service Architecture
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
ContactCenter (cc.ts)
|
|
100
|
+
└── Services (singleton)
|
|
101
|
+
├── agent/ → Agent operations (login, logout, state)
|
|
102
|
+
├── task/ → Task operations (hold, transfer, wrapup)
|
|
103
|
+
│ └── TaskManager → Task lifecycle
|
|
104
|
+
├── config/ → Configuration fetching
|
|
105
|
+
├── core/ → WebSocket, HTTP, utilities
|
|
106
|
+
├── AddressBook → Address book entries
|
|
107
|
+
├── EntryPoint → Entry points
|
|
108
|
+
└── Queue → Queues
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Canonical Module Specifications
|
|
114
|
+
|
|
115
|
+
Use [`SPEC_INDEX.md`](SPEC_INDEX.md) to select the owning module. Each manifest-routed module has one canonical `*-spec.md`; retained module-level `AGENTS.md` and `ARCHITECTURE.md` files are legacy/reference-only migration sources, as recorded in [`ADR-0001`](adr/0001-spec-source-policy.md).
|
|
116
|
+
|
|
117
|
+
| Module | Canonical specification |
|
|
118
|
+
|---|---|
|
|
119
|
+
| Contact Center public plugin | [`contact-center-spec.md`](contact-center-spec.md) |
|
|
120
|
+
| Metrics | [`metrics-spec.md`](../src/metrics/ai-docs/metrics-spec.md) |
|
|
121
|
+
| Services composition | [`services-spec.md`](../src/services/ai-docs/services-spec.md) |
|
|
122
|
+
| Agent | [`agent-spec.md`](../src/services/agent/ai-docs/agent-spec.md) |
|
|
123
|
+
| Config | [`config-spec.md`](../src/services/config/ai-docs/config-spec.md) |
|
|
124
|
+
| Core | [`core-spec.md`](../src/services/core/ai-docs/core-spec.md) |
|
|
125
|
+
| Task | [`task-spec.md`](../src/services/task/ai-docs/task-spec.md) |
|
|
126
|
+
| Task state machine | [`task-state-machine-spec.md`](../src/services/task/state-machine/ai-docs/task-state-machine-spec.md) |
|
|
127
|
+
| Utils | [`utils-spec.md`](../src/utils/ai-docs/utils-spec.md) |
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Contributing to AI Docs
|
|
132
|
+
|
|
133
|
+
When adding new features:
|
|
134
|
+
1. Use [`SPEC_INDEX.md`](SPEC_INDEX.md) to select the owning canonical module specification.
|
|
135
|
+
2. Update that `*-spec.md` with the behavior, source evidence, test evidence, and known gaps.
|
|
136
|
+
3. For exported API, event, or type changes, also update [`CONTRACTS.md`](CONTRACTS.md), the Contact Center specification, and `.sdd/manifest.json` when its routing, coverage, or validation evidence changes.
|
|
137
|
+
4. Add or update [`patterns/`](patterns/) and [`templates/`](templates/) only when their reusable guidance changes.
|
|
138
|
+
5. Update the root [`AGENTS.md`](../AGENTS.md) when task routing or critical rules change. Do not update retained service `AGENTS.md` or `ARCHITECTURE.md` as an independent source of truth.
|
|
@@ -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.
|
package/ai-docs/RULES.md
ADDED
|
@@ -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/participant-drop inputs | PII, external numbers, and participant identifiers | Validate and avoid logging raw values; sensitive AQM operations redact dynamic URLs and raw routing failures | 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.
|