@webex/contact-center 3.12.0-next.9 → 3.12.0-task-refactor.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.
- package/AGENTS.md +438 -0
- package/ai-docs/README.md +131 -0
- package/ai-docs/RULES.md +455 -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 +65 -123
- package/dist/cc.js.map +1 -1
- package/dist/constants.js +13 -2
- package/dist/constants.js.map +1 -1
- package/dist/index.js +13 -5
- package/dist/index.js.map +1 -1
- package/dist/metrics/behavioral-events.js +26 -13
- package/dist/metrics/behavioral-events.js.map +1 -1
- package/dist/metrics/constants.js +7 -6
- package/dist/metrics/constants.js.map +1 -1
- package/dist/services/ApiAiAssistant.js +0 -3
- package/dist/services/ApiAiAssistant.js.map +1 -1
- package/dist/services/config/Util.js +2 -3
- package/dist/services/config/Util.js.map +1 -1
- package/dist/services/config/types.js +16 -14
- package/dist/services/config/types.js.map +1 -1
- package/dist/services/constants.js +0 -1
- package/dist/services/constants.js.map +1 -1
- package/dist/services/core/Err.js.map +1 -1
- package/dist/services/core/Utils.js +79 -55
- package/dist/services/core/Utils.js.map +1 -1
- package/dist/services/core/aqm-reqs.js +17 -92
- package/dist/services/core/aqm-reqs.js.map +1 -1
- package/dist/services/core/websocket/WebSocketManager.js +5 -25
- package/dist/services/core/websocket/WebSocketManager.js.map +1 -1
- package/dist/services/core/websocket/types.js.map +1 -1
- package/dist/services/index.js +1 -2
- package/dist/services/index.js.map +1 -1
- package/dist/services/task/Task.js +644 -0
- package/dist/services/task/Task.js.map +1 -0
- package/dist/services/task/TaskFactory.js +45 -0
- package/dist/services/task/TaskFactory.js.map +1 -0
- package/dist/services/task/TaskManager.js +570 -535
- package/dist/services/task/TaskManager.js.map +1 -1
- package/dist/services/task/TaskUtils.js +132 -28
- package/dist/services/task/TaskUtils.js.map +1 -1
- package/dist/services/task/constants.js +7 -6
- package/dist/services/task/constants.js.map +1 -1
- package/dist/services/task/dialer.js +0 -51
- package/dist/services/task/dialer.js.map +1 -1
- package/dist/services/task/digital/Digital.js +77 -0
- package/dist/services/task/digital/Digital.js.map +1 -0
- package/dist/services/task/state-machine/TaskStateMachine.js +634 -0
- package/dist/services/task/state-machine/TaskStateMachine.js.map +1 -0
- package/dist/services/task/state-machine/actions.js +372 -0
- package/dist/services/task/state-machine/actions.js.map +1 -0
- package/dist/services/task/state-machine/constants.js +139 -0
- package/dist/services/task/state-machine/constants.js.map +1 -0
- package/dist/services/task/state-machine/guards.js +263 -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 +377 -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 +157 -18
- package/dist/services/task/types.js.map +1 -1
- package/dist/services/task/voice/Voice.js +1031 -0
- package/dist/services/task/voice/Voice.js.map +1 -0
- package/dist/services/task/voice/WebRTC.js +149 -0
- package/dist/services/task/voice/WebRTC.js.map +1 -0
- package/dist/types/cc.d.ts +4 -33
- package/dist/types/constants.d.ts +13 -2
- package/dist/types/index.d.ts +11 -5
- package/dist/types/metrics/constants.d.ts +5 -3
- package/dist/types/services/ApiAiAssistant.d.ts +1 -1
- package/dist/types/services/config/types.d.ts +97 -25
- package/dist/types/services/core/Err.d.ts +0 -2
- package/dist/types/services/core/Utils.d.ts +25 -23
- package/dist/types/services/core/aqm-reqs.d.ts +0 -49
- package/dist/types/services/core/websocket/WebSocketManager.d.ts +1 -1
- package/dist/types/services/core/websocket/connection-service.d.ts +0 -1
- package/dist/types/services/core/websocket/types.d.ts +1 -1
- package/dist/types/services/index.d.ts +1 -1
- package/dist/types/services/task/Task.d.ts +146 -0
- package/dist/types/services/task/TaskFactory.d.ts +12 -0
- package/dist/types/services/task/TaskUtils.d.ts +39 -8
- package/dist/types/services/task/constants.d.ts +5 -4
- package/dist/types/services/task/dialer.d.ts +0 -15
- package/dist/types/services/task/digital/Digital.d.ts +22 -0
- package/dist/types/services/task/state-machine/TaskStateMachine.d.ts +906 -0
- package/dist/types/services/task/state-machine/actions.d.ts +8 -0
- package/dist/types/services/task/state-machine/constants.d.ts +91 -0
- package/dist/types/services/task/state-machine/guards.d.ts +78 -0
- package/dist/types/services/task/state-machine/index.d.ts +13 -0
- package/dist/types/services/task/state-machine/types.d.ts +256 -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 +539 -88
- package/dist/types/services/task/voice/Voice.d.ts +183 -0
- package/dist/types/services/task/voice/WebRTC.d.ts +53 -0
- package/dist/types/types.d.ts +68 -0
- package/dist/types/webex.d.ts +1 -0
- package/dist/types.js +70 -0
- package/dist/types.js.map +1 -1
- package/dist/webex.js +14 -2
- package/dist/webex.js.map +1 -1
- package/package.json +14 -11
- package/src/cc.ts +91 -177
- package/src/constants.ts +13 -2
- package/src/index.ts +14 -5
- package/src/metrics/ai-docs/AGENTS.md +348 -0
- package/src/metrics/ai-docs/ARCHITECTURE.md +336 -0
- package/src/metrics/behavioral-events.ts +28 -14
- package/src/metrics/constants.ts +7 -8
- package/src/services/ApiAiAssistant.ts +2 -4
- package/src/services/agent/ai-docs/AGENTS.md +238 -0
- package/src/services/agent/ai-docs/ARCHITECTURE.md +302 -0
- package/src/services/ai-docs/AGENTS.md +384 -0
- package/src/services/config/Util.ts +2 -3
- package/src/services/config/ai-docs/AGENTS.md +253 -0
- package/src/services/config/ai-docs/ARCHITECTURE.md +424 -0
- package/src/services/config/types.ts +108 -20
- package/src/services/constants.ts +0 -1
- package/src/services/core/Err.ts +0 -1
- package/src/services/core/Utils.ts +90 -67
- package/src/services/core/ai-docs/AGENTS.md +379 -0
- package/src/services/core/ai-docs/ARCHITECTURE.md +696 -0
- package/src/services/core/aqm-reqs.ts +22 -100
- package/src/services/core/websocket/WebSocketManager.ts +4 -23
- package/src/services/core/websocket/types.ts +1 -1
- package/src/services/index.ts +1 -2
- package/src/services/task/Task.ts +785 -0
- package/src/services/task/TaskFactory.ts +55 -0
- package/src/services/task/TaskManager.ts +579 -633
- package/src/services/task/TaskUtils.ts +175 -31
- package/src/services/task/ai-docs/AGENTS.md +448 -0
- package/src/services/task/ai-docs/ARCHITECTURE.md +573 -0
- package/src/services/task/constants.ts +5 -4
- package/src/services/task/dialer.ts +1 -56
- package/src/services/task/digital/Digital.ts +95 -0
- package/src/services/task/state-machine/TaskStateMachine.ts +793 -0
- package/src/services/task/state-machine/actions.ts +422 -0
- package/src/services/task/state-machine/ai-docs/AGENTS.md +495 -0
- package/src/services/task/state-machine/ai-docs/ARCHITECTURE.md +1135 -0
- package/src/services/task/state-machine/constants.ts +150 -0
- package/src/services/task/state-machine/guards.ts +303 -0
- package/src/services/task/state-machine/index.ts +28 -0
- package/src/services/task/state-machine/types.ts +228 -0
- package/src/services/task/state-machine/uiControlsComputer.ts +542 -0
- package/src/services/task/taskDataNormalizer.ts +137 -0
- package/src/services/task/types.ts +641 -95
- package/src/services/task/voice/Voice.ts +1255 -0
- package/src/services/task/voice/WebRTC.ts +187 -0
- package/src/types.ts +88 -5
- package/src/utils/AGENTS.md +276 -0
- package/src/webex.js +2 -0
- package/test/unit/spec/cc.ts +59 -142
- package/test/unit/spec/logger-proxy.ts +70 -0
- package/test/unit/spec/services/ApiAiAssistant.ts +17 -0
- package/test/unit/spec/services/config/index.ts +26 -55
- package/test/unit/spec/services/core/Utils.ts +103 -52
- package/test/unit/spec/services/core/websocket/WebSocketManager.ts +48 -112
- package/test/unit/spec/services/core/websocket/connection-service.ts +5 -4
- package/test/unit/spec/services/task/AutoWrapup.ts +63 -0
- package/test/unit/spec/services/task/Task.ts +416 -0
- package/test/unit/spec/services/task/TaskFactory.ts +62 -0
- package/test/unit/spec/services/task/TaskManager.ts +781 -1735
- package/test/unit/spec/services/task/TaskUtils.ts +125 -0
- package/test/unit/spec/services/task/dialer.ts +112 -198
- package/test/unit/spec/services/task/digital/Digital.ts +105 -0
- package/test/unit/spec/services/task/state-machine/TaskStateMachine.ts +473 -0
- package/test/unit/spec/services/task/state-machine/guards.ts +288 -0
- package/test/unit/spec/services/task/state-machine/types.ts +18 -0
- package/test/unit/spec/services/task/state-machine/uiControlsComputer.ts +147 -0
- package/test/unit/spec/services/task/taskTestUtils.ts +87 -0
- package/test/unit/spec/services/task/voice/Voice.ts +587 -0
- package/test/unit/spec/services/task/voice/WebRTC.ts +242 -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/dist/types/services/task/index.d.ts +0 -650
- package/src/services/task/index.ts +0 -1801
- package/test/unit/spec/services/task/index.ts +0 -2184
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
# Services Layer - AI Agent Guide
|
|
2
|
+
|
|
3
|
+
> **Scope Authority**: This is the authoritative documentation for the **Services** orchestration layer. It describes how all service modules are composed, instantiated, and how they interact. For task routing, critical rules, and code generation workflows, see the [root orchestrator AGENTS.md](../../../AGENTS.md).
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Purpose
|
|
8
|
+
|
|
9
|
+
The `src/services/` directory is the service layer of the `@webex/contact-center` SDK. It sits between the public plugin class (`cc.ts`) and the backend APIs/WebSocket. Every backend interaction — HTTP requests, WebSocket messages, agent operations, task lifecycle, configuration fetching — flows through this layer.
|
|
10
|
+
|
|
11
|
+
### Scenarios this document resolves
|
|
12
|
+
|
|
13
|
+
- Understanding service composition and which service owns which responsibility
|
|
14
|
+
- Determining the correct instantiation/bootstrap order for services
|
|
15
|
+
- Tracing request flow from `cc.ts` through services to the backend
|
|
16
|
+
- Choosing between AqmReqs and direct REST patterns for a new method
|
|
17
|
+
- Adding a new data service (AddressBook/Queue/EntryPoint pattern)
|
|
18
|
+
- Adding a new AqmReqs method to agent, task, or dialer factories
|
|
19
|
+
- Routing to the correct service-level docs for task/agent/config/core changes
|
|
20
|
+
- Clarifying what the Services singleton creates vs what `cc.ts` creates
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## When to Load This Document
|
|
25
|
+
|
|
26
|
+
Load this services-layer guide when:
|
|
27
|
+
- Understanding **how services are composed** or **instantiation order**
|
|
28
|
+
- Adding a **new data service** (follow AddressBook/Queue/EntryPoint pattern)
|
|
29
|
+
- Adding a **new AqmReqs method** (follow agent/contact factory pattern)
|
|
30
|
+
- Debugging **cross-service interactions** or **bootstrap failures**
|
|
31
|
+
- Understanding the **request/response flow** (AqmReqs vs direct REST)
|
|
32
|
+
|
|
33
|
+
For implementation details within a specific service, follow the links in the [Service Routing table](#service-routing-scope-level-ai-docs).
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## File Structure
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
src/services/
|
|
41
|
+
├── index.ts # Services singleton — composes all services
|
|
42
|
+
├── constants.ts # Shared constants (gateway id, API paths, WebRTC domains/prefixes, timeout, method-name constants)
|
|
43
|
+
├── ai-docs/
|
|
44
|
+
│ └── AGENTS.md # THIS FILE — services layer orchestrator
|
|
45
|
+
│
|
|
46
|
+
├── agent/ # Agent operations service
|
|
47
|
+
│ ├── index.ts # routingAgent factory — stationLogin, stateChange, logout, buddyAgents
|
|
48
|
+
│ ├── types.ts # Agent types: StateChange, Logout, AGENT_EVENTS, LoginOption
|
|
49
|
+
│ └── ai-docs/ # Agent-specific documentation
|
|
50
|
+
│ ├── AGENTS.md
|
|
51
|
+
│ └── ARCHITECTURE.md
|
|
52
|
+
│
|
|
53
|
+
├── task/ # Task management service
|
|
54
|
+
│ ├── TaskManager.ts # Task lifecycle manager — creates/destroys Task instances
|
|
55
|
+
│ ├── Task.ts # Individual task — hold, transfer, conference, wrapup
|
|
56
|
+
│ ├── TaskFactory.ts # Creates Task with config flags
|
|
57
|
+
│ ├── contact.ts # routingContact factory — task operations via AqmReqs
|
|
58
|
+
│ ├── dialer.ts # aqmDialer factory — outbound dialing
|
|
59
|
+
│ ├── AutoWrapup.ts # Auto wrapup timer handler
|
|
60
|
+
│ ├── TaskUtils.ts # Task utility functions
|
|
61
|
+
│ ├── taskDataNormalizer.ts # Normalizes task data from events
|
|
62
|
+
│ ├── types.ts # Task types: ITask, TASK_EVENTS, TaskResponse
|
|
63
|
+
│ ├── constants.ts # Task constants
|
|
64
|
+
│ ├── voice/ # Voice-specific task handling
|
|
65
|
+
│ │ ├── Voice.ts # Voice task operations
|
|
66
|
+
│ │ └── WebRTC.ts # WebRTC-specific voice operations
|
|
67
|
+
│ ├── digital/ # Digital channel task handling
|
|
68
|
+
│ │ └── Digital.ts # Digital task operations
|
|
69
|
+
│ ├── state-machine/ # XState-based task state machine
|
|
70
|
+
│ │ ├── TaskStateMachine.ts # State machine definition
|
|
71
|
+
│ │ ├── index.ts # Barrel export for state machine public API
|
|
72
|
+
│ │ ├── constants.ts # TaskState, TaskEvent enums
|
|
73
|
+
│ │ ├── types.ts # TaskContext type
|
|
74
|
+
│ │ ├── guards.ts # State transition guards
|
|
75
|
+
│ │ ├── actions.ts # State transition actions
|
|
76
|
+
│ │ ├── uiControlsComputer.ts # Computes UI controls from state
|
|
77
|
+
│ │ └── ai-docs/ # State machine documentation
|
|
78
|
+
│ │ ├── AGENTS.md
|
|
79
|
+
│ │ └── ARCHITECTURE.md
|
|
80
|
+
│ └── ai-docs/ # Task-specific documentation
|
|
81
|
+
│ ├── AGENTS.md
|
|
82
|
+
│ └── ARCHITECTURE.md
|
|
83
|
+
│
|
|
84
|
+
├── config/ # Configuration service
|
|
85
|
+
│ ├── index.ts # AgentConfigService — getAgentConfig(), profile aggregation
|
|
86
|
+
│ ├── Util.ts # parseAgentConfigs, getFilterAuxCodes, helper functions
|
|
87
|
+
│ ├── types.ts # CC_EVENTS, Profile, CC_AGENT_EVENTS, CC_TASK_EVENTS
|
|
88
|
+
│ ├── constants.ts # endPointMap (API URL builders), pagination defaults
|
|
89
|
+
│ └── ai-docs/ # Config-specific documentation
|
|
90
|
+
│ ├── AGENTS.md
|
|
91
|
+
│ └── ARCHITECTURE.md
|
|
92
|
+
│
|
|
93
|
+
├── core/ # Core infrastructure
|
|
94
|
+
│ ├── WebexRequest.ts # HTTP client singleton — request(), uploadLogs()
|
|
95
|
+
│ ├── aqm-reqs.ts # AqmReqs — HTTP request + WebSocket notification correlation
|
|
96
|
+
│ ├── Utils.ts # getErrorDetails, generateTaskErrorObject, isValidDialNumber
|
|
97
|
+
│ ├── Err.ts # Err.Details error class with structured metadata
|
|
98
|
+
│ ├── GlobalTypes.ts # Msg<T>, Failure, AugmentedError, TaskError
|
|
99
|
+
│ ├── types.ts # Req, Conf, Res types for AqmReqs
|
|
100
|
+
│ ├── constants.ts # Core constants
|
|
101
|
+
│ ├── websocket/
|
|
102
|
+
│ │ ├── WebSocketManager.ts # WebSocket connection handler
|
|
103
|
+
│ │ ├── connection-service.ts # Connection lifecycle, reconnection, keepalive
|
|
104
|
+
│ │ └── types.ts # WebSocket types
|
|
105
|
+
│ └── ai-docs/ # Core-specific documentation
|
|
106
|
+
│ ├── AGENTS.md
|
|
107
|
+
│ └── ARCHITECTURE.md
|
|
108
|
+
│
|
|
109
|
+
├── AddressBook.ts # Address book entries — getEntries() with pagination/cache
|
|
110
|
+
├── EntryPoint.ts # Entry points — getEntryPoints() with pagination/cache
|
|
111
|
+
├── Queue.ts # Queues — getQueues() with pagination/cache
|
|
112
|
+
└── WebCallingService.ts # WebRTC calling — register/deregister line, answer/mute/decline
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Note: The `src/utils/` folder (sibling to `src/services/`) contains shared utilities like [`PageCache.ts`](../../utils/PageCache.ts) which provides generic pagination caching with `BaseSearchParams`, `PaginatedResponse`, and `PaginationMeta` types used by all data services.
|
|
116
|
+
|
|
117
|
+
### Shared Constants (`src/services/constants.ts`)
|
|
118
|
+
|
|
119
|
+
Use [`constants.ts`](../constants.ts) as the canonical source for service-level naming and routing constants:
|
|
120
|
+
- `WCC_API_GATEWAY` — service identifier used by `WebexRequest` calls
|
|
121
|
+
- `SUBSCRIBE_API`, `LOGIN_API`, `STATE_CHANGE_API` — common API path constants
|
|
122
|
+
- `WEB_RTC_PREFIX` — path prefix for WebRTC-related endpoints
|
|
123
|
+
- `WEBSOCKET_EVENT_TIMEOUT` — default notification correlation timeout (`20000` ms)
|
|
124
|
+
- `DEFAULT_RTMS_DOMAIN`, `WCC_CALLING_RTMS_DOMAIN` — RTMS/WebRTC domain constants
|
|
125
|
+
- `METHODS` — method name constants used by `WebCallingService`
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## Key Capabilities
|
|
130
|
+
|
|
131
|
+
| Capability | Owner | Description |
|
|
132
|
+
|---|---|---|
|
|
133
|
+
| **Service Singleton** | [`index.ts`](../index.ts) | Central `Services` class that instantiates and provides access to all service modules via `Services.getInstance()` |
|
|
134
|
+
| **Agent Operations** | [`agent/`](../agent/index.ts) | Station login/logout, state changes, buddy agents — uses AqmReqs factory pattern |
|
|
135
|
+
| **Task Management** | [`task/`](../task/TaskManager.ts) | Task lifecycle (accept, hold, transfer, conference, wrapup), Task state machine, contact operations, outbound dialing |
|
|
136
|
+
| **Configuration** | [`config/`](../config/index.ts) | Agent profile aggregation from 8+ API endpoints, org settings, teams, aux codes, dial plans |
|
|
137
|
+
| **Core Infrastructure** | [`core/`](../core/WebexRequest.ts) | HTTP requests (`WebexRequest`), WebSocket management (`WebSocketManager`), connection lifecycle (`ConnectionService`), AQM request/response correlation (`AqmReqs`), error handling (`Utils`, `Err`) |
|
|
138
|
+
| **Data Services** | [`AddressBook.ts`](../AddressBook.ts), [`Queue.ts`](../Queue.ts), [`EntryPoint.ts`](../EntryPoint.ts) | Standalone REST-based data services with pagination and caching for address books, queues, and entry points |
|
|
139
|
+
| **Utilities** | [`src/utils/PageCache.ts`](../../utils/PageCache.ts) | Shared `PageCache<T>` generic class for pagination caching, plus `BaseSearchParams`, `PaginatedResponse`, and `PaginationMeta` types used by all data services |
|
|
140
|
+
| **WebRTC Calling** | [`WebCallingService.ts`](../WebCallingService.ts) | Browser-based voice calling via `@webex/calling`, line registration, call answer/mute/decline |
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## Service Routing (Scope-Level ai-docs)
|
|
145
|
+
|
|
146
|
+
Each service folder contains its own `ai-docs/` with detailed documentation. **Always load the relevant service docs before making changes.**
|
|
147
|
+
|
|
148
|
+
| Service | Scope / Keywords | AGENTS.md | ARCHITECTURE.md |
|
|
149
|
+
|---------|-----------------|-----------|-----------------|
|
|
150
|
+
| **Agent** | login, logout, state change, buddy agents, station, RONA | [`agent/ai-docs/AGENTS.md`](../agent/ai-docs/AGENTS.md) | [`agent/ai-docs/ARCHITECTURE.md`](../agent/ai-docs/ARCHITECTURE.md) |
|
|
151
|
+
| **Task** | task, hold, transfer, conference, wrapup, outdial, consult, accept, decline, state machine, XState, task states, guards, actions | [`task/ai-docs/AGENTS.md`](../task/ai-docs/AGENTS.md) | [`task/ai-docs/ARCHITECTURE.md`](../task/ai-docs/ARCHITECTURE.md) |
|
|
152
|
+
| **Config** | profile, register, teams, aux codes, desktop profile, org settings, dial plan | [`config/ai-docs/AGENTS.md`](../config/ai-docs/AGENTS.md) | [`config/ai-docs/ARCHITECTURE.md`](../config/ai-docs/ARCHITECTURE.md) |
|
|
153
|
+
| **Core** | websocket, HTTP, connection, reconnect, aqm, utils, errors, keepalive | [`core/ai-docs/AGENTS.md`](../core/ai-docs/AGENTS.md) | [`core/ai-docs/ARCHITECTURE.md`](../core/ai-docs/ARCHITECTURE.md) |
|
|
154
|
+
|
|
155
|
+
> **Note**: The task state machine (`task/state-machine/`) is part of the Task service, not a separate service. Its dedicated docs live at [`task/state-machine/ai-docs/AGENTS.md`](../task/state-machine/ai-docs/AGENTS.md) and [`ARCHITECTURE.md`](../task/state-machine/ai-docs/ARCHITECTURE.md). Load these when working on state transitions, guards, or actions.
|
|
156
|
+
|
|
157
|
+
**Data services** (AddressBook, Queue, EntryPoint) do not have dedicated ai-docs. Read their source files directly — they follow shared REST/pagination/caching patterns documented in [`ai-docs/patterns/typescript-patterns.md`](../../../ai-docs/patterns/typescript-patterns.md).
|
|
158
|
+
|
|
159
|
+
**WebCallingService** also has no dedicated ai-docs, but it follows a different pattern: EventEmitter-based call lifecycle orchestration around `@webex/calling` (`createClient`, line registration/deregistration, `ICall` events), `callTaskMap` tracking, and async registration flows with timeout handling. Read [`WebCallingService.ts`](../WebCallingService.ts) directly when changing browser calling behavior.
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## Architecture Overview
|
|
164
|
+
|
|
165
|
+
### How cc.ts Uses the Services Layer
|
|
166
|
+
|
|
167
|
+
The `ContactCenter` plugin class (`cc.ts`) is the **only public entry point**. It delegates all backend work to the services layer:
|
|
168
|
+
|
|
169
|
+
```
|
|
170
|
+
ContactCenter (cc.ts) — public API surface
|
|
171
|
+
│
|
|
172
|
+
├── WebexRequest.getInstance({webex}) ← initialized FIRST (singleton)
|
|
173
|
+
├── Services.getInstance({webex, connectionConfig}) ← initialized SECOND (singleton)
|
|
174
|
+
│ │
|
|
175
|
+
│ ├── WebSocketManager ← real-time message transport
|
|
176
|
+
│ ├── AqmReqs ← HTTP request + WebSocket notification correlation
|
|
177
|
+
│ ├── ConnectionService ← WebSocket lifecycle, reconnection, keepalive
|
|
178
|
+
│ ├── AgentConfigService (config) ← profile aggregation via REST APIs
|
|
179
|
+
│ ├── routingAgent (agent) ← agent operations via AqmReqs factory
|
|
180
|
+
│ ├── routingContact (contact) ← task/contact operations via AqmReqs factory
|
|
181
|
+
│ └── aqmDialer (dialer) ← outbound dialing via AqmReqs factory
|
|
182
|
+
│
|
|
183
|
+
├── TaskManager ← task lifecycle, created during register()
|
|
184
|
+
├── WebCallingService ← WebRTC calling, created during register() (line registration is conditional)
|
|
185
|
+
├── AddressBook ← REST data service, created during register()
|
|
186
|
+
├── EntryPoint ← REST data service, created during register()
|
|
187
|
+
├── Queue ← REST data service, created during register()
|
|
188
|
+
└── MetricsManager.getInstance({webex}) ← telemetry singleton
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Bootstrap Order (Critical)
|
|
192
|
+
|
|
193
|
+
Understanding the instantiation order is essential — getting it wrong causes runtime errors:
|
|
194
|
+
|
|
195
|
+
1. **`WebexRequest.getInstance({webex})`** — Must be called first. The singleton HTTP client that all services depend on.
|
|
196
|
+
2. **`Services.getInstance({webex, connectionConfig})`** — Creates `WebSocketManager`, `AqmReqs`, `ConnectionService`, `AgentConfigService`, `routingAgent`, `routingContact`, `aqmDialer`.
|
|
197
|
+
3. **`WebCallingService`** — Created during `register()` for calling lifecycle management. `registerWebCallingLine()` is later invoked conditionally for `loginOption === 'BROWSER'`.
|
|
198
|
+
4. **`MetricsManager.getInstance({webex})`** — Telemetry singleton.
|
|
199
|
+
5. **`TaskManager`** — Created during `register()` and wired to services/WebSocket.
|
|
200
|
+
6. **Data services** (`AddressBook`, `EntryPoint`, `Queue`) — Created during `register()`.
|
|
201
|
+
|
|
202
|
+
### Request/Response Flow Pattern
|
|
203
|
+
|
|
204
|
+
There are two distinct patterns used across services:
|
|
205
|
+
|
|
206
|
+
#### Pattern 1: AqmReqs (Agent + Task operations)
|
|
207
|
+
|
|
208
|
+
Used by `routingAgent`, `routingContact`, and `aqmDialer`. This pattern sends an HTTP REST request to the backend and waits for a correlated WebSocket notification:
|
|
209
|
+
|
|
210
|
+
```
|
|
211
|
+
cc.ts method call
|
|
212
|
+
→ services.agent.methodName({data}) (or services.contact / services.dialer)
|
|
213
|
+
→ AqmReqs.req() sends HTTP request (via WebexRequest.request())
|
|
214
|
+
→ Backend REST API processes
|
|
215
|
+
→ Backend sends WebSocket notification (success or failure)
|
|
216
|
+
→ AqmReqs correlates notification to pending request
|
|
217
|
+
→ Promise resolves/rejects
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Key detail: **The HTTP request goes directly to the backend. The WebSocket only carries the notification back.** This is NOT request-over-WebSocket.
|
|
221
|
+
|
|
222
|
+
#### Pattern 2: Direct REST (Config + Data services)
|
|
223
|
+
|
|
224
|
+
Used by `AgentConfigService`, `AddressBook`, `Queue`, `EntryPoint`. These make direct HTTP calls and return the response:
|
|
225
|
+
|
|
226
|
+
```
|
|
227
|
+
cc.ts method call
|
|
228
|
+
→ service.method()
|
|
229
|
+
→ WebexRequest.request({service, resource, method})
|
|
230
|
+
→ Backend REST API
|
|
231
|
+
→ Response returned directly
|
|
232
|
+
→ Promise resolves/rejects
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## Services Singleton (index.ts)
|
|
238
|
+
|
|
239
|
+
The `Services` class is the central composition root. It uses a singleton pattern:
|
|
240
|
+
|
|
241
|
+
```typescript
|
|
242
|
+
const services = Services.getInstance({
|
|
243
|
+
webex: this.$webex,
|
|
244
|
+
connectionConfig: subscribeRequest,
|
|
245
|
+
});
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### What Services creates in its constructor
|
|
249
|
+
|
|
250
|
+
| Component | How Created | Purpose |
|
|
251
|
+
|---|---|---|
|
|
252
|
+
| `webSocketManager` | `new WebSocketManager({webex})` | WebSocket transport for real-time messages |
|
|
253
|
+
| `aqmReq` (internal) | `new AqmReqs(webSocketManager)` | Correlates HTTP requests with WebSocket notifications |
|
|
254
|
+
| `config` | `new AgentConfigService()` | REST-based profile aggregation |
|
|
255
|
+
| `agent` | `routingAgent(aqmReq)` | Agent operations factory |
|
|
256
|
+
| `contact` | `routingContact(aqmReq)` | Task/contact operations factory |
|
|
257
|
+
| `dialer` | `aqmDialer(aqmReq)` | Outbound dialing factory |
|
|
258
|
+
| `connectionService` | `new ConnectionService({webSocketManager, subscribeRequest})` | WebSocket lifecycle management |
|
|
259
|
+
|
|
260
|
+
### What Services does NOT create
|
|
261
|
+
|
|
262
|
+
- `WebexRequest` — initialized by `cc.ts` before `Services.getInstance()`
|
|
263
|
+
- `TaskManager` — created by `cc.ts` during `register()`
|
|
264
|
+
- `WebCallingService` — created by `cc.ts` during `register()` (line registration is conditional on `loginOption === 'BROWSER'`)
|
|
265
|
+
- `AddressBook`, `EntryPoint`, `Queue` — created by `cc.ts` during `register()`
|
|
266
|
+
- `MetricsManager` — independent singleton initialized by `cc.ts`
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
## Data Services Pattern (AddressBook, Queue, EntryPoint)
|
|
271
|
+
|
|
272
|
+
These three services share an identical pattern. Use any one as a reference when creating similar services:
|
|
273
|
+
|
|
274
|
+
| Aspect | Pattern |
|
|
275
|
+
|---|---|
|
|
276
|
+
| **Class structure** | Standalone class with `WebexRequest`, `WebexSDK`, `MetricsManager`, `PageCache` |
|
|
277
|
+
| **Constructor** | `constructor(webex: WebexSDK)` — gets singletons via `.getInstance()` |
|
|
278
|
+
| **HTTP calls** | `this.webexRequest.request({service: WCC_API_GATEWAY, resource, method: HTTP_METHODS.GET})` |
|
|
279
|
+
| **Endpoints** | Uses `endPointMap` functions from `config/constants.ts` to build URL paths |
|
|
280
|
+
| **Pagination** | Query params with `page`, `pageSize`; uses `PageCache` for caching |
|
|
281
|
+
| **Caching** | `PageCache<T>` — caches pages for simple pagination, bypasses cache for search/filter |
|
|
282
|
+
| **Metrics** | `timeEvent` on API call start, `trackEvent` on success/failure |
|
|
283
|
+
| **Logging** | `LoggerProxy` with `{module: 'ClassName', method: 'methodName'}` context |
|
|
284
|
+
| **Error handling** | try/catch with `LoggerProxy.error` + `metricsManager.trackEvent` for failures, then re-throw so callers receive the error |
|
|
285
|
+
|
|
286
|
+
Reference files:
|
|
287
|
+
- [`AddressBook.ts`](../AddressBook.ts) — includes `addressBookId` parameter
|
|
288
|
+
- [`Queue.ts`](../Queue.ts) — includes additional query params (sortBy, sortOrder, etc.)
|
|
289
|
+
- [`EntryPoint.ts`](../EntryPoint.ts) — simplest example
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
## AqmReqs Factory Pattern (Agent + Task operations)
|
|
294
|
+
|
|
295
|
+
Agent and task operations use a factory pattern where each method is defined as a `routing.req()` call:
|
|
296
|
+
|
|
297
|
+
```typescript
|
|
298
|
+
export default function routingAgent(routing: AqmReqs) {
|
|
299
|
+
return {
|
|
300
|
+
stationLogin: routing.req((p: {data: LoginPayload}) => ({
|
|
301
|
+
url: '/v1/agents/login',
|
|
302
|
+
host: WCC_API_GATEWAY,
|
|
303
|
+
data: p.data,
|
|
304
|
+
err: createErrDetailsObject,
|
|
305
|
+
notifSuccess: { bind: {...}, msg: {} as SuccessType },
|
|
306
|
+
notifFail: { bind: {...}, errId: 'Service.aqm.agent.stationLogin' },
|
|
307
|
+
})),
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
Key points:
|
|
313
|
+
- `url` + `host` define the HTTP endpoint
|
|
314
|
+
- `data` is the request body (POST by default, GET if no data)
|
|
315
|
+
- `notifSuccess.bind` specifies which WebSocket event type indicates success
|
|
316
|
+
- `notifFail.bind` specifies which WebSocket event type indicates failure
|
|
317
|
+
- `errId` maps to an `Err.Details` error identifier
|
|
318
|
+
- The returned function is a `Promise` that resolves when the correlated WebSocket notification arrives
|
|
319
|
+
|
|
320
|
+
Reference files:
|
|
321
|
+
- [`agent/index.ts`](../agent/index.ts) — agent operations
|
|
322
|
+
- [`task/contact.ts`](../task/contact.ts) — task operations
|
|
323
|
+
- [`task/dialer.ts`](../task/dialer.ts) — outbound dialing
|
|
324
|
+
|
|
325
|
+
---
|
|
326
|
+
|
|
327
|
+
## Cross-Service Dependencies
|
|
328
|
+
|
|
329
|
+
```
|
|
330
|
+
cc.ts
|
|
331
|
+
├─ uses → Services.agent (stationLogin, stateChange, logout, buddyAgents)
|
|
332
|
+
├─ uses → Services.config (getAgentConfig)
|
|
333
|
+
├─ uses → Services.contact (task operations, forwarded through TaskManager/Task)
|
|
334
|
+
├─ uses → Services.dialer (startOutdial)
|
|
335
|
+
├─ uses → Services.webSocketManager (message listener for event routing)
|
|
336
|
+
├─ uses → Services.connectionService (connection lifecycle events)
|
|
337
|
+
├─ uses → WebexRequest (uploadLogs)
|
|
338
|
+
├─ uses → TaskManager (task lifecycle, created during register())
|
|
339
|
+
├─ uses → WebCallingService (WebRTC, created during register(); line registration is conditional on BROWSER login)
|
|
340
|
+
├─ uses → AddressBook (address book queries)
|
|
341
|
+
├─ uses → EntryPoint (entry point queries)
|
|
342
|
+
└─ uses → Queue (queue queries)
|
|
343
|
+
|
|
344
|
+
TaskManager
|
|
345
|
+
├─ uses → Services.contact (task operations via AqmReqs)
|
|
346
|
+
├─ uses → Services.dialer (outbound dialing)
|
|
347
|
+
├─ uses → Services.config (config flags)
|
|
348
|
+
└─ creates → Task instances (each with its own state machine)
|
|
349
|
+
|
|
350
|
+
AgentConfigService (config)
|
|
351
|
+
└─ uses → WebexRequest (direct REST calls for profile data)
|
|
352
|
+
|
|
353
|
+
AqmReqs
|
|
354
|
+
├─ uses → WebexRequest (sends HTTP requests)
|
|
355
|
+
└─ uses → WebSocketManager (listens for correlated notifications)
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
---
|
|
359
|
+
|
|
360
|
+
## Event Flow Through Services
|
|
361
|
+
|
|
362
|
+
WebSocket messages are fanned out to multiple independent listeners on `WebSocketManager`:
|
|
363
|
+
|
|
364
|
+
```
|
|
365
|
+
CC Backend
|
|
366
|
+
→ WebSocket message arrives at WebSocketManager
|
|
367
|
+
→ WebSocketManager emits 'message'
|
|
368
|
+
→ AqmReqs listener (`aqm-reqs.ts`) — correlates pending request notifications
|
|
369
|
+
→ cc.ts listener (`cc.ts`) — handles plugin-level events:
|
|
370
|
+
→ Agent events use `this.emit(...)` (EventEmitter API)
|
|
371
|
+
→ Task notifications use `this.trigger(...)` (WebexPlugin API)
|
|
372
|
+
→ TaskManager listener (`TaskManager.ts`) — processes task events for task lifecycle/state
|
|
373
|
+
→ ConnectionService listener (`connection-service.ts`) — processes connection/keepalive events
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
---
|
|
377
|
+
|
|
378
|
+
## Related
|
|
379
|
+
|
|
380
|
+
- [Root orchestrator AGENTS.md](../../../AGENTS.md) — task classification, critical rules, templates
|
|
381
|
+
- [ai-docs/RULES.md](../../../ai-docs/RULES.md) — coding standards
|
|
382
|
+
- [ai-docs/patterns/](../../../ai-docs/patterns/) — TypeScript, testing, and event patterns
|
|
383
|
+
- [types.ts](../../types.ts) — public type definitions
|
|
384
|
+
- [cc.ts](../../cc.ts) — main plugin class (public API surface)
|
|
@@ -185,7 +185,7 @@ function parseAgentConfigs(profileData: {
|
|
|
185
185
|
|
|
186
186
|
const defaultWrapUpData = getDefaultWrapUpCode(wrapupCodes);
|
|
187
187
|
const aiFeature: AIFeatureFlags | undefined =
|
|
188
|
-
aiFeatureFlags?.data
|
|
188
|
+
aiFeatureFlags?.data?.length > 0 ? aiFeatureFlags.data[0] : undefined;
|
|
189
189
|
|
|
190
190
|
const finalData = {
|
|
191
191
|
teams: teamData,
|
|
@@ -210,7 +210,6 @@ function parseAgentConfigs(profileData: {
|
|
|
210
210
|
siteId: userData.siteId,
|
|
211
211
|
enterpriseId: orgInfoData.tenantId,
|
|
212
212
|
tenantTimezone: orgInfoData.timezone,
|
|
213
|
-
environment: orgInfoData.environment,
|
|
214
213
|
privacyShieldVisible: tenantData.privacyShieldVisible,
|
|
215
214
|
organizationIdleCodes: [], // TODO: for supervisor, getOrgFilteredIdleCodes(auxCodes, false),
|
|
216
215
|
idleCodesAccess: agentProfileData.accessIdleCode as 'ALL' | 'SPECIFIC',
|
|
@@ -233,7 +232,7 @@ function parseAgentConfigs(profileData: {
|
|
|
233
232
|
isAgentAvailableAfterOutdial: agentProfileData.agentAvailableAfterOutdial,
|
|
234
233
|
outDialEp: agentProfileData.outdialEntryPointId,
|
|
235
234
|
isCampaignManagementEnabled: orgSettingsData.campaignManagerEnabled,
|
|
236
|
-
|
|
235
|
+
isEndTaskEnabled: tenantData.endCallEnabled,
|
|
237
236
|
isEndConsultEnabled: tenantData.endConsultEnabled,
|
|
238
237
|
callVariablesSuppressed: tenantData.callVariablesSuppressed,
|
|
239
238
|
agentDbId: userData.dbId,
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
# Config Service - AI Agent Guide
|
|
2
|
+
|
|
3
|
+
> **Purpose**: Fetch and aggregate agent configuration data from multiple API endpoints to build the AgentProfile.
|
|
4
|
+
>
|
|
5
|
+
> **Scope Authority**: This is the authoritative documentation for the **Config** service scope. See [Root AGENTS.md](../../../../AGENTS.md) for the orchestrator and cross-scope rules.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
The Config Service is an **internal service** that builds the comprehensive AgentProfile (`Profile` type) by:
|
|
12
|
+
1. Fetching user data
|
|
13
|
+
2. Fetching desktop profile
|
|
14
|
+
3. Fetching teams
|
|
15
|
+
4. Fetching aux codes (idle/wrapup codes)
|
|
16
|
+
5. Fetching organization settings
|
|
17
|
+
6. Aggregating all data into a single AgentProfile
|
|
18
|
+
|
|
19
|
+
The AgentProfile is the central configuration object required for an agent to operate within the contact center. It is built during the registration flow (`cc.register()`) and contains all the data an agent needs: identity, team assignments, dial plans, aux codes, login options, and feature flags. Once constructed, the AgentProfile is stored on the `ContactCenter` plugin instance as `this.agentConfig` and is used by other services (Agent, Task) throughout the session.
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## File Structure
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
services/config/
|
|
28
|
+
├── index.ts # AgentConfigService class
|
|
29
|
+
├── types.ts # Profile, CC_EVENTS, types
|
|
30
|
+
├── constants.ts # API endpoints, defaults
|
|
31
|
+
├── Util.ts # parseAgentConfigs helper
|
|
32
|
+
└── ai-docs/
|
|
33
|
+
├── AGENTS.md # Usage documentation
|
|
34
|
+
└── ARCHITECTURE.md # This file
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Quick Usage
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
// Config service is used internally during the registration flow.
|
|
43
|
+
// Inside cc.ts → connectWebsocket(), after WebSocket connection is established:
|
|
44
|
+
const agentId = data.agentId;
|
|
45
|
+
const orgId = this.$webex.credentials.getOrgId();
|
|
46
|
+
this.agentConfig = await this.services.config.getAgentConfig(orgId, agentId);
|
|
47
|
+
|
|
48
|
+
// The returned AgentProfile contains all agent configuration:
|
|
49
|
+
LoggerProxy.info(`Agent ID: ${this.agentConfig.agentId}`, {
|
|
50
|
+
module: 'cc',
|
|
51
|
+
method: 'connectWebsocket',
|
|
52
|
+
});
|
|
53
|
+
LoggerProxy.info(`Teams: ${this.agentConfig.teams}`, {
|
|
54
|
+
module: 'cc',
|
|
55
|
+
method: 'connectWebsocket',
|
|
56
|
+
});
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Key Capabilities
|
|
62
|
+
|
|
63
|
+
- **AgentProfile Aggregation**: Combines data from 8+ API endpoints
|
|
64
|
+
- **Aux Codes Fetching**: Gets all idle and wrapup codes with pagination
|
|
65
|
+
- **Team Data**: Retrieves agent's team assignments
|
|
66
|
+
- **Dial Plan**: Fetches number transformation rules
|
|
67
|
+
- **Outdial ANI**: Retrieves outbound caller ID options (standalone, publicly exposed via `cc.ts`)
|
|
68
|
+
- **Multimedia Profile**: Fetches channel capacity and blending config (standalone, not yet publicly exposed)
|
|
69
|
+
- **Paginated Data Access**: `getListOfTeams` and `getListOfAuxCodes` support custom pagination independent of profile building
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## AgentProfile Object (Key Fields)
|
|
74
|
+
|
|
75
|
+
The AgentProfile is defined as the [`Profile`](../types.ts) type. This is not an exhaustive list — see [`types.ts`](../types.ts) for the full 50+ field definition. Key fields:
|
|
76
|
+
|
|
77
|
+
| Field | Type | Description |
|
|
78
|
+
|-------|------|-------------|
|
|
79
|
+
| `agentId` | string | Unique agent identifier |
|
|
80
|
+
| `agentName` | string | Display name |
|
|
81
|
+
| `agentMailId` | string | Email address |
|
|
82
|
+
| `teams` | [`TeamList[]`](../types.ts) | Assigned teams (runtime data from `getAllTeams()` — `Profile` type declares `Team[]` but actual objects are `TeamList` with `id`, `name`, `teamType`, `siteId`, etc.) |
|
|
83
|
+
| `defaultDn` | string | Default dial number |
|
|
84
|
+
| `idleCodes` | [`Entity[]`](../types.ts) | Available idle codes |
|
|
85
|
+
| `wrapupCodes` | [`Entity[]`](../types.ts) | Available wrapup codes |
|
|
86
|
+
| `webRtcEnabled` | boolean | WebRTC calling enabled |
|
|
87
|
+
| `loginVoiceOptions` | [`LoginOption[]`](../types.ts) | Available login types |
|
|
88
|
+
| `dialPlan` | [`DialPlan`](../types.ts) | Number transformation rules |
|
|
89
|
+
| `isOutboundEnabledForAgent` | boolean | Outbound calling allowed |
|
|
90
|
+
| `outDialEp` | string | Outbound entry point ID |
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## Data Aggregation Flow
|
|
95
|
+
|
|
96
|
+
The following diagram shows how `getAgentConfig` orchestrates multiple API calls and combines their results into the AgentProfile via `parseAgentConfigs()`:
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
getUserUsingCI ────────────┐
|
|
100
|
+
│
|
|
101
|
+
getOrgInfo ────────────────┤
|
|
102
|
+
│
|
|
103
|
+
getOrganizationSetting ────┤
|
|
104
|
+
│
|
|
105
|
+
getTenantData ─────────────┤
|
|
106
|
+
│
|
|
107
|
+
getURLMapping ─────────────┼──► parseAgentConfigs() ──► AgentProfile
|
|
108
|
+
│
|
|
109
|
+
getAllAuxCodes ─────────────┤
|
|
110
|
+
│
|
|
111
|
+
getDesktopProfileById ─────┤
|
|
112
|
+
│
|
|
113
|
+
getSiteInfo ───────────────┤ (computes multimediaProfileId)
|
|
114
|
+
│
|
|
115
|
+
getAllTeams ────────────────┤
|
|
116
|
+
│
|
|
117
|
+
getDialPlanData ───────────┘
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## API Methods (Internal)
|
|
123
|
+
|
|
124
|
+
### `getAgentConfig(orgId, agentId)`
|
|
125
|
+
|
|
126
|
+
Main method that aggregates all configuration data into the AgentProfile.
|
|
127
|
+
|
|
128
|
+
**Returns**: `Promise<Profile>`
|
|
129
|
+
|
|
130
|
+
**Flow**:
|
|
131
|
+
1. Fetch user data (`getUserUsingCI`)
|
|
132
|
+
2. Fetch org info (`getOrgInfo`), settings (`getOrganizationSetting`), tenant data (`getTenantData`) in parallel
|
|
133
|
+
3. Fetch aux codes with pagination (`getAllAuxCodes`)
|
|
134
|
+
4. Fetch desktop profile (`getDesktopProfileById`), site info (`getSiteInfo`)
|
|
135
|
+
5. Fetch dial plan if enabled (`getDialPlanData`)
|
|
136
|
+
6. Fetch teams (`getAllTeams`)
|
|
137
|
+
7. Parse and combine all data (`parseAgentConfigs`)
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Standalone APIs (Not Part of AgentProfile Building)
|
|
142
|
+
|
|
143
|
+
These methods exist in `AgentConfigService` but are **not** part of the `getAgentConfig()` aggregation flow. They can be used independently by applications.
|
|
144
|
+
|
|
145
|
+
| Method | Status | Returns | Description |
|
|
146
|
+
|--------|--------|---------|-------------|
|
|
147
|
+
| `getOutdialAniEntries(orgId, params)` | **Publicly exposed** via `cc.getOutdialAniEntries()` | `OutdialAniEntriesResponse` | Fetch outbound ANI entries for caller ID selection. Supports pagination and search via [`OutdialAniParams`](../types.ts). |
|
|
148
|
+
| `getMultimediaProfileById(orgId, multimediaProfileId)` | **Not exposed, never called** | `MultimediaProfileResponse` | Fetch channel capacities (chat, email, telephony, social) and blending config. Available but unused anywhere. |
|
|
149
|
+
| `getListOfTeams(orgId, page, pageSize, filter)` | Used internally by `getAllTeams()` | `ListTeamsResponse` | Single-page team fetch with pagination metadata. Useful for custom pagination. |
|
|
150
|
+
| `getListOfAuxCodes(orgId, page, pageSize, filter, attributes)` | Used internally by `getAllAuxCodes()` | `ListAuxCodesResponse` | Single-page aux code fetch with pagination metadata. Useful for custom pagination. |
|
|
151
|
+
|
|
152
|
+
Additionally, the following endpoints are defined in `constants.ts` `endPointMap` but are consumed by separate service classes, not by `AgentConfigService`:
|
|
153
|
+
|
|
154
|
+
| Endpoint | Used By | Description |
|
|
155
|
+
|----------|---------|-------------|
|
|
156
|
+
| `queueList` | [`Queue.ts`](../../Queue.ts) | Fetch contact service queues |
|
|
157
|
+
| `entryPointList` | [`EntryPoint.ts`](../../EntryPoint.ts) | Fetch entry points |
|
|
158
|
+
| `addressBookEntries` | [`AddressBook.ts`](../../AddressBook.ts) | Fetch address book entries |
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## Key Types
|
|
163
|
+
|
|
164
|
+
Types used by the config service, all defined in [`types.ts`](../types.ts):
|
|
165
|
+
|
|
166
|
+
| Type | Description |
|
|
167
|
+
|------|-------------|
|
|
168
|
+
| `Profile` | Final aggregated agent config returned by `getAgentConfig()` |
|
|
169
|
+
| `AgentResponse` | Raw response from `getUserUsingCI()` — agent metadata, teamIds, siteId, agentProfileId |
|
|
170
|
+
| `DesktopProfileResponse` | Desktop profile settings — layout, dial plan, login options |
|
|
171
|
+
| `TeamList` | Team record from API — `id`, `name`, `teamType`, `siteId`, `multiMediaProfileId` |
|
|
172
|
+
| `ListTeamsResponse` | Paginated wrapper around `TeamList[]` with `meta` for pagination |
|
|
173
|
+
| `OrgInfo` | Organization info — `tenantId`, timezone |
|
|
174
|
+
| `OrgSettings` | Org feature flags — `webRtcEnabled`, `sensitiveDataMaskingEnabled` |
|
|
175
|
+
| `TenantData` | Tenant-level config — inactivity timeout, `forceDefaultDn`, `outdialEnabled` |
|
|
176
|
+
| `SiteInfo` | Site config — `id`, `name`, `multimediaProfileId` |
|
|
177
|
+
| `URLMapping` | External URL mapping — `id`, `name`, `url` |
|
|
178
|
+
| `MultimediaProfileResponse` | Multimedia profile — channel capacities and settings |
|
|
179
|
+
| `AuxCode` | Auxiliary code record — `id`, `name`, `description`, `workTypeCode` |
|
|
180
|
+
| `ListAuxCodesResponse` | Paginated wrapper around `AuxCode[]` with `meta` |
|
|
181
|
+
| `DialPlanEntity` | Dial plan rule — regex pattern, prefix, strip digits |
|
|
182
|
+
| `Entity` | Basic entity info — `isSystem`, `name`, `id`, `description` |
|
|
183
|
+
| `WrapupData` | Wrap-up config — auto-wrapup settings, available wrapup codes |
|
|
184
|
+
| `OutdialAniParams` | Parameters for `getOutdialAniEntries()` — ANI ID, pagination, filtering |
|
|
185
|
+
| `Team` | Simplified team shape in `Profile` — `teamId`, `teamName`, `desktopLayoutId` |
|
|
186
|
+
|
|
187
|
+
## Events (CC_EVENTS)
|
|
188
|
+
|
|
189
|
+
The config service defines event constants used throughout the SDK:
|
|
190
|
+
|
|
191
|
+
| Event Category | Examples |
|
|
192
|
+
|----------------|----------|
|
|
193
|
+
| Agent Events | WELCOME, AGENT_LOGOUT, AGENT_STATE_CHANGE |
|
|
194
|
+
| Task Events | AGENT_CONTACT, AGENT_OFFER_CONTACT, CONTACT_ENDED |
|
|
195
|
+
| Login Events | AGENT_STATION_LOGIN_SUCCESS, AGENT_STATION_LOGIN_FAILED |
|
|
196
|
+
|
|
197
|
+
See [`types.ts`](../types.ts) for complete list.
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## Types Defined
|
|
202
|
+
|
|
203
|
+
Key types in `services/config/types.ts`:
|
|
204
|
+
|
|
205
|
+
| Type | Description |
|
|
206
|
+
|------|-------------|
|
|
207
|
+
| `Profile` | Complete AgentProfile |
|
|
208
|
+
| `CC_EVENTS` | All event constants |
|
|
209
|
+
| `CC_AGENT_EVENTS` | Agent-specific events |
|
|
210
|
+
| `CC_TASK_EVENTS` | Task-specific events |
|
|
211
|
+
| `AuxCode` | Idle/wrapup code definition |
|
|
212
|
+
| `Team` | Team configuration |
|
|
213
|
+
| `DesktopProfileResponse` | Desktop profile settings |
|
|
214
|
+
| `LoginOption` | Login types (BROWSER, EXTENSION, AGENT_DN) |
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## Error Handling
|
|
219
|
+
|
|
220
|
+
All API methods within the config service throw errors on failure. Since `getAgentConfig` calls multiple sub-APIs (`getUserUsingCI`, `getOrgInfo`, `getOrganizationSetting`, `getTenantData`, `getAllAuxCodes`, `getDesktopProfileById`, `getAllTeams`, `getDialPlanData`, etc.) and awaits them via `Promise.all`, **a failure in any single sub-API will cause the entire AgentProfile fetch to fail**. There is no partial profile — either all data is successfully fetched and aggregated, or the operation throws.
|
|
221
|
+
|
|
222
|
+
```typescript
|
|
223
|
+
try {
|
|
224
|
+
const profile = await this.services.config.getAgentConfig(orgId, agentId);
|
|
225
|
+
} catch (error) {
|
|
226
|
+
LoggerProxy.error(`Config fetch failed: ${error}`, {
|
|
227
|
+
module: 'ConfigService',
|
|
228
|
+
method: 'getAgentConfig',
|
|
229
|
+
});
|
|
230
|
+
throw error;
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## Usage in cc.ts
|
|
237
|
+
|
|
238
|
+
```typescript
|
|
239
|
+
// In register() -> connectWebsocket()
|
|
240
|
+
const agentId = data.agentId;
|
|
241
|
+
const orgId = this.$webex.credentials.getOrgId();
|
|
242
|
+
this.agentConfig = await this.services.config.getAgentConfig(orgId, agentId);
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
## Related
|
|
248
|
+
|
|
249
|
+
- [Root AGENTS.md](../../../../AGENTS.md) - Orchestrator and cross-scope rules
|
|
250
|
+
- [ARCHITECTURE.md](ARCHITECTURE.md) - Technical deep-dive
|
|
251
|
+
- [types.ts](../types.ts) - Type definitions
|
|
252
|
+
- [Util.ts](../Util.ts) - AgentProfile parsing utilities
|
|
253
|
+
- [constants.ts](../constants.ts) - API endpoints
|