@webex/contact-center 3.12.0-next.84 → 3.12.0-next.85
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 +876 -0
- package/AGENTS.md +65 -409
- package/ai-docs/ARCHITECTURE.md +168 -0
- package/ai-docs/CONTRACTS.md +46 -0
- package/ai-docs/GETTING_STARTED.md +168 -0
- package/ai-docs/GLOSSARY.md +43 -0
- package/ai-docs/README.md +25 -18
- package/ai-docs/REVIEW_CHECKLIST.md +41 -0
- package/ai-docs/RULES.md +187 -198
- 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 +341 -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/templates/README.md +1 -1
- package/ai-docs/templates/new-method/04-validation.md +1 -1
- package/ai-docs/templates/new-service/05-validation.md +1 -1
- package/dist/webex.js +1 -1
- package/package.json +1 -1
- package/src/metrics/ai-docs/AGENTS.md +2 -0
- package/src/metrics/ai-docs/ARCHITECTURE.md +2 -0
- package/src/metrics/ai-docs/metrics-spec.md +854 -0
- package/src/services/agent/ai-docs/AGENTS.md +3 -1
- package/src/services/agent/ai-docs/ARCHITECTURE.md +2 -0
- package/src/services/agent/ai-docs/agent-spec.md +504 -0
- package/src/services/ai-docs/AGENTS.md +4 -2
- package/src/services/ai-docs/services-spec.md +492 -0
- package/src/services/config/ai-docs/AGENTS.md +3 -1
- package/src/services/config/ai-docs/ARCHITECTURE.md +2 -0
- package/src/services/config/ai-docs/config-spec.md +669 -0
- package/src/services/core/ai-docs/AGENTS.md +4 -2
- package/src/services/core/ai-docs/ARCHITECTURE.md +2 -0
- package/src/services/core/ai-docs/core-spec.md +783 -0
- package/src/services/task/ai-docs/AGENTS.md +2 -0
- package/src/services/task/ai-docs/ARCHITECTURE.md +11 -2
- package/src/services/task/ai-docs/task-spec.md +1319 -0
- package/src/services/task/state-machine/ai-docs/AGENTS.md +38 -75
- package/src/services/task/state-machine/ai-docs/ARCHITECTURE.md +6 -4
- package/src/services/task/state-machine/ai-docs/task-state-machine-spec.md +2115 -0
- package/src/utils/AGENTS.md +3 -1
- package/src/utils/ai-docs/utils-spec.md +381 -0
- package/umd/contact-center.min.js +2 -2
package/ai-docs/RULES.md
CHANGED
|
@@ -1,74 +1,102 @@
|
|
|
1
|
-
#
|
|
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.
|
|
2
22
|
|
|
3
|
-
|
|
23
|
+
Before submitting code:
|
|
4
24
|
|
|
5
|
-
|
|
25
|
+
- [ ] All public APIs have JSDoc with `@public`, `@param`, `@returns`, `@example`
|
|
6
26
|
|
|
7
|
-
|
|
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.
|
|
8
49
|
|
|
9
|
-
### Strict Mode
|
|
10
50
|
- TypeScript strict mode is enabled
|
|
51
|
+
|
|
11
52
|
- Avoid `any` type unless absolutely necessary (document justification with `// eslint-disable-line`)
|
|
53
|
+
|
|
12
54
|
- Prefer `unknown` over `any` for unknown types
|
|
13
|
-
- All public APIs must have explicit return types
|
|
14
55
|
|
|
15
|
-
|
|
56
|
+
- All public APIs must have explicit return types
|
|
16
57
|
|
|
17
58
|
| Element | Convention | Example |
|
|
18
|
-
|
|
59
|
+
|---|---|---|
|
|
19
60
|
| Classes | PascalCase | `ContactCenter`, `TaskManager` |
|
|
61
|
+
|
|
62
|
+
| Element | Convention | Example |
|
|
63
|
+
|---|---|---|
|
|
20
64
|
| Interfaces | PascalCase with `I` prefix for contracts | `IContactCenter`, `ITask`, `IVoice` |
|
|
65
|
+
|
|
66
|
+
| Element | Convention | Example |
|
|
67
|
+
|---|---|---|
|
|
21
68
|
| Types | PascalCase | `SetStateResponse`, `BuddyAgentsResponse` |
|
|
69
|
+
|
|
70
|
+
| Element | Convention | Example |
|
|
71
|
+
|---|---|---|
|
|
22
72
|
| Enums/Constants | SCREAMING_SNAKE_CASE | `CC_EVENTS`, `METRIC_EVENT_NAMES` |
|
|
73
|
+
|
|
74
|
+
| Element | Convention | Example |
|
|
75
|
+
|---|---|---|
|
|
23
76
|
| Methods | camelCase | `stationLogin`, `setAgentState` |
|
|
77
|
+
|
|
78
|
+
| Element | Convention | Example |
|
|
79
|
+
|---|---|---|
|
|
24
80
|
| Private properties | camelCase with `$` prefix for SDK references | `$webex`, `$config` |
|
|
81
|
+
|
|
82
|
+
| Element | Convention | Example |
|
|
83
|
+
|---|---|---|
|
|
25
84
|
| Regular private | camelCase | `agentConfig`, `eventEmitter` |
|
|
85
|
+
|
|
86
|
+
| Element | Convention | Example |
|
|
87
|
+
|---|---|---|
|
|
26
88
|
| Module constants | SCREAMING_SNAKE_CASE | `CC_FILE`, `READY` |
|
|
27
89
|
|
|
28
|
-
### File Naming
|
|
29
90
|
- Component files: `PascalCase.ts` (e.g., `TaskManager.ts`, `WebSocketManager.ts`)
|
|
30
|
-
- Type files: `types.ts` in service folders
|
|
31
|
-
- Constant files: `constants.ts` in service folders
|
|
32
|
-
- Index files: `index.ts` for exports
|
|
33
91
|
|
|
34
|
-
|
|
92
|
+
- Type files: `types.ts` in service folders
|
|
35
93
|
|
|
36
|
-
|
|
94
|
+
- Constant files: `constants.ts` in service folders
|
|
37
95
|
|
|
38
|
-
|
|
96
|
+
- Index files: `index.ts` for exports
|
|
39
97
|
|
|
40
98
|
All public methods and types must have comprehensive JSDoc:
|
|
41
99
|
|
|
42
|
-
```typescript
|
|
43
|
-
/**
|
|
44
|
-
* Brief description of what this does.
|
|
45
|
-
*
|
|
46
|
-
* @description
|
|
47
|
-
* Longer description if needed with:
|
|
48
|
-
* - Bullet points for features
|
|
49
|
-
* - Multiple lines for clarity
|
|
50
|
-
*
|
|
51
|
-
* @param {ParamType} paramName - Description of the parameter
|
|
52
|
-
* @returns {Promise<ReturnType>} Description of return value
|
|
53
|
-
* @throws {Error} Description of when errors are thrown
|
|
54
|
-
*
|
|
55
|
-
* @public
|
|
56
|
-
*
|
|
57
|
-
* @example
|
|
58
|
-
* ```typescript
|
|
59
|
-
* const result = await cc.methodName({
|
|
60
|
-
* param: 'value',
|
|
61
|
-
* });
|
|
62
|
-
* console.log(result);
|
|
63
|
-
* ```
|
|
64
|
-
*/
|
|
65
|
-
public async methodName(data: ParamType): Promise<ReturnType> {
|
|
66
|
-
// implementation
|
|
67
|
-
}
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
### Private/Internal APIs
|
|
71
|
-
|
|
72
100
|
Use `@private` or `@ignore` tag:
|
|
73
101
|
|
|
74
102
|
```typescript
|
|
@@ -82,8 +110,6 @@ private helperMethod(): void {
|
|
|
82
110
|
}
|
|
83
111
|
```
|
|
84
112
|
|
|
85
|
-
### Type Definitions
|
|
86
|
-
|
|
87
113
|
```typescript
|
|
88
114
|
/**
|
|
89
115
|
* Description of what this type represents.
|
|
@@ -97,11 +123,24 @@ export type MyType = {
|
|
|
97
123
|
};
|
|
98
124
|
```
|
|
99
125
|
|
|
100
|
-
|
|
126
|
+
Add new events to `src/metrics/constants.ts`:
|
|
101
127
|
|
|
102
|
-
|
|
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
|
+
```
|
|
103
135
|
|
|
104
|
-
|
|
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.
|
|
105
144
|
|
|
106
145
|
```typescript
|
|
107
146
|
// ✅ REQUIRED pattern
|
|
@@ -113,17 +152,25 @@ LoggerProxy.info('Starting operation', {
|
|
|
113
152
|
});
|
|
114
153
|
```
|
|
115
154
|
|
|
116
|
-
### Log Levels
|
|
117
|
-
|
|
118
155
|
| Level | Use Case | Example |
|
|
119
|
-
|
|
156
|
+
|---|---|---|
|
|
120
157
|
| `trace` | Detailed debugging | Entry/exit of complex functions |
|
|
158
|
+
|
|
159
|
+
| Level | Use Case | Example |
|
|
160
|
+
|---|---|---|
|
|
121
161
|
| `log` | General information | Operation completed successfully |
|
|
162
|
+
|
|
163
|
+
| Level | Use Case | Example |
|
|
164
|
+
|---|---|---|
|
|
122
165
|
| `info` | Important milestones | Starting registration, login |
|
|
166
|
+
|
|
167
|
+
| Level | Use Case | Example |
|
|
168
|
+
|---|---|---|
|
|
123
169
|
| `warn` | Potential issues | Deprecated usage, fallback behavior |
|
|
124
|
-
| `error` | Failures | API errors, exceptions |
|
|
125
170
|
|
|
126
|
-
|
|
171
|
+
| Level | Use Case | Example |
|
|
172
|
+
|---|---|---|
|
|
173
|
+
| `error` | Failures | API errors, exceptions |
|
|
127
174
|
|
|
128
175
|
```typescript
|
|
129
176
|
// All log calls MUST include module and method
|
|
@@ -137,11 +184,22 @@ LoggerProxy.info('Starting operation', {
|
|
|
137
184
|
}
|
|
138
185
|
```
|
|
139
186
|
|
|
140
|
-
|
|
187
|
+
Never log sensitive data:
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
// ❌ WRONG
|
|
191
|
+
LoggerProxy.log(`User token: ${token}`);
|
|
141
192
|
|
|
142
|
-
|
|
193
|
+
// ✅ CORRECT
|
|
194
|
+
LoggerProxy.log('Token received', {
|
|
195
|
+
module: 'Auth',
|
|
196
|
+
method: 'login',
|
|
197
|
+
// No sensitive data in logs
|
|
198
|
+
});
|
|
199
|
+
```
|
|
143
200
|
|
|
144
|
-
|
|
201
|
+
## Error Handling
|
|
202
|
+
- Preserve structured backend details and tracking ids through shared Core helpers; never swallow failures or synthesize success.
|
|
145
203
|
|
|
146
204
|
```typescript
|
|
147
205
|
import {getErrorDetails} from './services/core/Utils';
|
|
@@ -172,8 +230,6 @@ try {
|
|
|
172
230
|
}
|
|
173
231
|
```
|
|
174
232
|
|
|
175
|
-
### Never Swallow Errors
|
|
176
|
-
|
|
177
233
|
```typescript
|
|
178
234
|
// ❌ WRONG - silently swallowing errors
|
|
179
235
|
try {
|
|
@@ -194,56 +250,8 @@ try {
|
|
|
194
250
|
}
|
|
195
251
|
```
|
|
196
252
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
## Metrics Standards
|
|
200
|
-
|
|
201
|
-
### All Operations Must Track Metrics
|
|
202
|
-
|
|
203
|
-
```typescript
|
|
204
|
-
// Start timing at method entry
|
|
205
|
-
this.metricsManager.timeEvent([
|
|
206
|
-
METRIC_EVENT_NAMES.SUCCESS_EVENT,
|
|
207
|
-
METRIC_EVENT_NAMES.FAILED_EVENT,
|
|
208
|
-
]);
|
|
209
|
-
|
|
210
|
-
// Track on success
|
|
211
|
-
this.metricsManager.trackEvent(
|
|
212
|
-
METRIC_EVENT_NAMES.SUCCESS_EVENT,
|
|
213
|
-
{
|
|
214
|
-
...MetricsManager.getCommonTrackingFieldForAQMResponse(response),
|
|
215
|
-
// Add operation-specific fields
|
|
216
|
-
},
|
|
217
|
-
['behavioral', 'operational']
|
|
218
|
-
);
|
|
219
|
-
|
|
220
|
-
// Track on failure (in catch block)
|
|
221
|
-
this.metricsManager.trackEvent(
|
|
222
|
-
METRIC_EVENT_NAMES.FAILED_EVENT,
|
|
223
|
-
{
|
|
224
|
-
...MetricsManager.getCommonTrackingFieldForAQMResponseFailed(failure),
|
|
225
|
-
},
|
|
226
|
-
['behavioral', 'operational']
|
|
227
|
-
);
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
### Metric Event Naming
|
|
231
|
-
|
|
232
|
-
Add new events to `src/metrics/constants.ts`:
|
|
233
|
-
|
|
234
|
-
```typescript
|
|
235
|
-
export const METRIC_EVENT_NAMES = {
|
|
236
|
-
// Existing events...
|
|
237
|
-
NEW_OPERATION_SUCCESS: 'new operation success',
|
|
238
|
-
NEW_OPERATION_FAILED: 'new operation failed',
|
|
239
|
-
} as const;
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
---
|
|
243
|
-
|
|
244
|
-
## Service Architecture Standards
|
|
245
|
-
|
|
246
|
-
### Singleton Pattern
|
|
253
|
+
## Imports / Dependencies
|
|
254
|
+
- External packages first, then package types/constants, service imports, local utilities, and type-only imports. New runtime dependencies require approval.
|
|
247
255
|
|
|
248
256
|
Services use singleton pattern via `Services` class:
|
|
249
257
|
|
|
@@ -259,8 +267,6 @@ await this.services.agent.stationLogin({data});
|
|
|
259
267
|
await this.services.config.getAgentConfig(orgId, agentId);
|
|
260
268
|
```
|
|
261
269
|
|
|
262
|
-
### Service Factory Pattern
|
|
263
|
-
|
|
264
270
|
Agent/contact services use factory pattern:
|
|
265
271
|
|
|
266
272
|
```typescript
|
|
@@ -292,53 +298,10 @@ export default function routingAgent(routing: AqmReqs) {
|
|
|
292
298
|
}
|
|
293
299
|
```
|
|
294
300
|
|
|
295
|
-
---
|
|
296
|
-
|
|
297
|
-
## Event Standards
|
|
298
|
-
|
|
299
|
-
### Event Constant Objects
|
|
300
|
-
|
|
301
|
-
Define events as const objects with `as const`:
|
|
302
|
-
|
|
303
|
-
```typescript
|
|
304
|
-
export const MY_EVENTS = {
|
|
305
|
-
SUCCESS: 'MySuccess',
|
|
306
|
-
FAILED: 'MyFailed',
|
|
307
|
-
} as const;
|
|
308
|
-
|
|
309
|
-
// Extract union type
|
|
310
|
-
type Enum<T extends Record<string, unknown>> = T[keyof T];
|
|
311
|
-
export type MY_EVENTS = Enum<typeof MY_EVENTS>;
|
|
312
|
-
```
|
|
313
|
-
|
|
314
|
-
### Event Emission
|
|
315
|
-
|
|
316
|
-
Always use event constants:
|
|
317
|
-
|
|
318
|
-
```typescript
|
|
319
|
-
import {AGENT_EVENTS} from './services/agent/types';
|
|
320
|
-
|
|
321
|
-
// ✅ CORRECT
|
|
322
|
-
this.emit(AGENT_EVENTS.AGENT_STATE_CHANGE, eventData);
|
|
323
|
-
|
|
324
|
-
// ❌ WRONG
|
|
325
|
-
this.emit('stateChange', eventData);
|
|
326
|
-
```
|
|
327
|
-
|
|
328
|
-
---
|
|
329
|
-
|
|
330
|
-
## Testing Standards
|
|
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
|
-
---
|
|
335
|
-
|
|
336
|
-
## Import Standards
|
|
337
|
-
|
|
338
|
-
### Import Order
|
|
339
|
-
|
|
340
301
|
1. External packages (`@webex/*`, `events`, `uuid`)
|
|
302
|
+
|
|
341
303
|
2. Internal absolute imports (types, constants)
|
|
304
|
+
|
|
342
305
|
3. Relative imports (local files)
|
|
343
306
|
|
|
344
307
|
```typescript
|
|
@@ -357,44 +320,89 @@ import LoggerProxy from './logger-proxy';
|
|
|
357
320
|
import {getErrorDetails} from './services/core/Utils';
|
|
358
321
|
```
|
|
359
322
|
|
|
360
|
-
### Export Standards
|
|
361
|
-
|
|
362
323
|
- Public types: Export from `src/types.ts`
|
|
324
|
+
|
|
363
325
|
- Internal types: Export from service-level `types.ts`
|
|
326
|
+
|
|
364
327
|
- Services: Use default export for main class, named exports for types
|
|
365
328
|
|
|
366
|
-
|
|
329
|
+
## Testing
|
|
330
|
+
- Mirror source paths under `test/unit/spec/`; cover positive and negative behavior and retain the 85% global coverage threshold.
|
|
367
331
|
|
|
368
|
-
|
|
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).
|
|
369
333
|
|
|
370
|
-
|
|
334
|
+
## Security
|
|
335
|
+
- Credentials come from the host Webex SDK; validate inputs, use authenticated service routing, and follow `SECURITY.md`.
|
|
371
336
|
|
|
372
337
|
Never commit:
|
|
338
|
+
|
|
373
339
|
- API keys, tokens, secrets
|
|
340
|
+
|
|
374
341
|
- Passwords or authentication data
|
|
342
|
+
|
|
375
343
|
- Private keys or certificates
|
|
376
344
|
|
|
377
|
-
|
|
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.
|
|
378
348
|
|
|
379
|
-
|
|
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.
|
|
380
354
|
|
|
381
355
|
```typescript
|
|
382
|
-
//
|
|
383
|
-
|
|
356
|
+
// Start timing at method entry
|
|
357
|
+
this.metricsManager.timeEvent([
|
|
358
|
+
METRIC_EVENT_NAMES.SUCCESS_EVENT,
|
|
359
|
+
METRIC_EVENT_NAMES.FAILED_EVENT,
|
|
360
|
+
]);
|
|
384
361
|
|
|
385
|
-
//
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
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>;
|
|
391
393
|
```
|
|
392
394
|
|
|
393
|
-
|
|
395
|
+
Always use event constants:
|
|
396
|
+
|
|
397
|
+
```typescript
|
|
398
|
+
import {AGENT_EVENTS} from './services/agent/types';
|
|
394
399
|
|
|
395
|
-
|
|
400
|
+
// ✅ CORRECT
|
|
401
|
+
this.emit(AGENT_EVENTS.AGENT_STATE_CHANGE, eventData);
|
|
396
402
|
|
|
397
|
-
|
|
403
|
+
// ❌ WRONG
|
|
404
|
+
this.emit('stateChange', eventData);
|
|
405
|
+
```
|
|
398
406
|
|
|
399
407
|
Always use async/await over raw Promises:
|
|
400
408
|
|
|
@@ -411,8 +419,6 @@ public fetchData(): Promise<Data> {
|
|
|
411
419
|
}
|
|
412
420
|
```
|
|
413
421
|
|
|
414
|
-
### Cleanup on Deregistration
|
|
415
|
-
|
|
416
422
|
Always clean up resources:
|
|
417
423
|
|
|
418
424
|
```typescript
|
|
@@ -431,25 +437,8 @@ public async deregister(): Promise<void> {
|
|
|
431
437
|
}
|
|
432
438
|
```
|
|
433
439
|
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
## Code Review Checklist
|
|
437
|
-
|
|
438
|
-
Before submitting code:
|
|
439
|
-
|
|
440
|
-
- [ ] All public APIs have JSDoc with `@public`, `@param`, `@returns`, `@example`
|
|
441
|
-
- [ ] LoggerProxy used for all logging with module/method context
|
|
442
|
-
- [ ] MetricsManager tracks success/failure for all operations
|
|
443
|
-
- [ ] Error handling follows `getErrorDetails` pattern
|
|
444
|
-
- [ ] No `console.log` or `console.error`
|
|
445
|
-
- [ ] No hardcoded credentials or sensitive data
|
|
446
|
-
- [ ] Event constants used (not string literals)
|
|
447
|
-
- [ ] Types exported appropriately
|
|
448
|
-
- [ ] Unit tests added/updated
|
|
449
|
-
- [ ] No `any` types without justification
|
|
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.
|
|
450
442
|
|
|
451
|
-
##
|
|
452
|
-
|
|
453
|
-
- **TypeScript patterns**: [`patterns/typescript-patterns.md`](patterns/typescript-patterns.md)
|
|
454
|
-
- **Testing patterns**: [`patterns/testing-patterns.md`](patterns/testing-patterns.md)
|
|
455
|
-
- **Event patterns**: [`patterns/event-driven-patterns.md`](patterns/event-driven-patterns.md)
|
|
443
|
+
## Maintenance
|
|
444
|
+
- Add a rule when a review correction recurs; remove duplication when tooling enforces it. Patterns remain in `patterns/`.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Security Baseline — @webex/contact-center
|
|
2
|
+
|
|
3
|
+
> Start here → root [`AGENTS.md`](../AGENTS.md) · router [`SPEC_INDEX.md`](SPEC_INDEX.md) · system [`ARCHITECTURE.md`](ARCHITECTURE.md).
|
|
4
|
+
|
|
5
|
+
## Trust Boundaries
|
|
6
|
+
|
|
7
|
+
| Boundary | Untrusted side | Trusted side | What is enforced at the crossing |
|
|
8
|
+
|---|---|---|---|
|
|
9
|
+
| Exported SDK methods | Host application input | ContactCenter/module methods | Typed inputs, runtime validation where implemented, typed errors |
|
|
10
|
+
| REST construction | SDK data | Webex request/service routing | Host credentials, service identifier, method/path/payload mapping |
|
|
11
|
+
| WebSocket parsing | Remote messages | ContactCenter/Task/AqmReqs | JSON parsing, event-type mapping, correlation/guards |
|
|
12
|
+
| Logs/metrics | Runtime data | Remote observability systems | Context selection and no credential/sensitive-data logging |
|
|
13
|
+
|
|
14
|
+
## Authentication & Authorization Model
|
|
15
|
+
|
|
16
|
+
- **Authentication:** supplied and maintained by the host Webex SDK (`src/services/core/WebexRequest.ts`).
|
|
17
|
+
- **Authorization:** remote WCC services enforce tenant/agent permissions; this package must not bypass host service routing.
|
|
18
|
+
- **Default posture:** no standalone credentials or local authorization store.
|
|
19
|
+
|
|
20
|
+
## Secret & Credential Handling
|
|
21
|
+
|
|
22
|
+
- Secrets source and injection: host Webex SDK/runtime configuration; never source code.
|
|
23
|
+
- Rotation: owned by the host credential system and remote services.
|
|
24
|
+
- **Hard rule:** never commit or log secrets, tokens, keys, or connection strings.
|
|
25
|
+
|
|
26
|
+
## Data Classification & Handling
|
|
27
|
+
|
|
28
|
+
| Data class | Examples | Storage rule | Logging rule | In transit |
|
|
29
|
+
|---|---|---|---|---|
|
|
30
|
+
| Identity/PII | agent id/name/email, dial number | ephemeral client memory; remote system of record | do not log raw sensitive values | host-resolved HTTPS/WSS |
|
|
31
|
+
| Interaction data | task/customer/call metadata | ephemeral task state; remote system of record | use tracking/interaction ids, minimize payloads | HTTPS/WSS/WebRTC |
|
|
32
|
+
| Credentials | access tokens/service auth | host-owned only | never log | HTTPS/WSS |
|
|
33
|
+
|
|
34
|
+
## Input Validation & Output Encoding Posture
|
|
35
|
+
|
|
36
|
+
- Validate public inputs before request construction; use typed constants and endpoint builders; never concatenate credentials or executable commands.
|
|
37
|
+
|
|
38
|
+
## Transport & Headers
|
|
39
|
+
|
|
40
|
+
- Authenticated requests use the Webex SDK service catalog and HTTPS. Realtime traffic uses host-resolved WSS; header/environment behavior is owned by `src/services/core/WebexRequest.ts` and the host request layer.
|
|
41
|
+
|
|
42
|
+
## Known Sensitive Areas & Accepted Risks
|
|
43
|
+
|
|
44
|
+
| Area | Risk | Mitigation / why accepted | Owner |
|
|
45
|
+
|---|---|---|---|
|
|
46
|
+
| Log upload | Runtime context could contain sensitive values | Shared error helpers upload only approved diagnostic context; never add credentials/payload dumps | Contact Center maintainers |
|
|
47
|
+
| WebSocket event parsing | Malformed/unexpected remote data | Parse defensively, map known event constants, ignore/reject invalid transitions | Core/Task maintainers |
|
|
48
|
+
| Public dial/contact inputs | PII and external numbers | Validate and avoid logging raw values | Contact Center maintainers |
|
|
49
|
+
|
|
50
|
+
## Reporting & Review
|
|
51
|
+
|
|
52
|
+
- Security-sensitive changes require package-owner review and independent SDD validation. Report vulnerabilities through the repository's documented Cisco security/support process.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Service State (living) — @webex/contact-center
|
|
2
|
+
|
|
3
|
+
> Start here → root [`AGENTS.md`](../AGENTS.md) · router [`SPEC_INDEX.md`](SPEC_INDEX.md) · system [`ARCHITECTURE.md`](ARCHITECTURE.md). Read before adding a surface.
|
|
4
|
+
|
|
5
|
+
## Current Events
|
|
6
|
+
|
|
7
|
+
| Event / topic | Direction | Producer/consumer | Payload ref |
|
|
8
|
+
|---|---|---|---|
|
|
9
|
+
| `agent:*` | publish | ContactCenter → application | `src/services/agent/types.ts` |
|
|
10
|
+
| `task:*` | publish | Task/TaskManager → application | `src/services/task/types.ts` |
|
|
11
|
+
| `CC_EVENTS` | consume | WCC WebSocket → Core/ContactCenter/Task/AqmReqs | `src/services/config/types.ts` |
|
|
12
|
+
| realtime transcript/suggestion | consume/publish | RTD WebSocket → owning Task | `src/services/task/TaskManager.ts` |
|
|
13
|
+
|
|
14
|
+
## Data Stores
|
|
15
|
+
|
|
16
|
+
| Store | Purpose | Owned by this service? |
|
|
17
|
+
|---|---|---|
|
|
18
|
+
| In-memory PageCache Map | temporary paginated lookup reuse | ephemeral only; yes for cache entries |
|
|
19
|
+
| Remote WCC stores | agent/task/config domain state | no |
|
|
20
|
+
|
|
21
|
+
## External Dependencies
|
|
22
|
+
|
|
23
|
+
| Dependency | Used for | Timeout / retry | Circuit breaker / fallback |
|
|
24
|
+
|---|---|---|---|
|
|
25
|
+
| WCC API gateway | agent/task/config/data operations | operation/AQM timeouts | propagate structured failure |
|
|
26
|
+
| WCC WebSocket/RTD | realtime events and completion | reconnect and recovery timers | reconnect/silent relogin/restore failure |
|
|
27
|
+
| Webex Calling | BROWSER call lifecycle | async registration/call timeouts | emit/rethrow calling failure |
|
|
28
|
+
| Webex metrics | telemetry | nonblocking queued submission | log/drop without breaking product flow |
|
|
29
|
+
|
|
30
|
+
## Key Metrics & Performance Targets
|
|
31
|
+
|
|
32
|
+
| Signal | Target | Where measured |
|
|
33
|
+
|---|---|---|
|
|
34
|
+
| Unit coverage | 85% branches/functions/lines/statements | package Jest configuration |
|
|
35
|
+
| Operation duration/success/failure | no local numeric SLO routed | MetricsManager event taxonomy |
|
|
36
|
+
| Connection recovery | explicit 8s disconnect, 5s retry, configured restore timeout | Core constants/ConnectionService |
|
|
37
|
+
|
|
38
|
+
## Feature Flags (current)
|
|
39
|
+
|
|
40
|
+
| Flag/config | Gates | Current default | Owner | Safe to remove when |
|
|
41
|
+
|---|---|---|---|---|
|
|
42
|
+
| `allowAutomatedRelogin` | silent relogin after recovery | config-defined | ContactCenter | replacement recovery contract exists |
|
|
43
|
+
| `webRtcEnabled` / login option | browser calling path | remote profile | Config/WCC | remote contract removed |
|
|
44
|
+
| task UI/config flags | task controls and operations | profile/config-defined | Task/Config | owning behavior removed |
|
|
45
|
+
|
|
46
|
+
## Maintenance
|
|
47
|
+
|
|
48
|
+
- Update the relevant row in the same change as any surface, dependency, timeout, metric, or flag.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Spec Index — @webex/contact-center
|
|
2
|
+
|
|
3
|
+
> Start here → root [`AGENTS.md`](../AGENTS.md). This router mirrors `.sdd/manifest.json`; system overview: [`ARCHITECTURE.md`](ARCHITECTURE.md).
|
|
4
|
+
|
|
5
|
+
## Module Registry
|
|
6
|
+
|
|
7
|
+
| Module | Responsibility | Manifest coverage state | Start here |
|
|
8
|
+
|---|---|---|---|
|
|
9
|
+
| `src` | Own the published Webex Contact Center SDK plugin surface, registration lifecycle, public method delegation, and application-facing event routing. | Partial | `ai-docs/contact-center-spec.md` |
|
|
10
|
+
| `src/metrics` | Own timing, taxonomy, queuing, payload preparation, and submission for Contact Center behavioral, operational, and business telemetry. | Partial | `src/metrics/ai-docs/metrics-spec.md` |
|
|
11
|
+
| `src/services` | Own composition and bootstrap order for backend request, realtime, data, and WebRTC service collaborators. | Partial | `src/services/ai-docs/services-spec.md` |
|
|
12
|
+
| `src/services/agent` | Own agent login, logout, state-change, buddy-agent, device-update, and silent-relogin request contracts. | Partial | `src/services/agent/ai-docs/agent-spec.md` |
|
|
13
|
+
| `src/services/config` | Own retrieval and aggregation of remote organization, agent, team, profile, auxiliary-code, dial-plan, and feature configuration. | Partial | `src/services/config/ai-docs/config-spec.md` |
|
|
14
|
+
| `src/services/core` | Own authenticated HTTP, realtime WebSocket lifecycle, AQM request correlation, reconnect/keepalive behavior, and shared error normalization. | Partial | `src/services/core/ai-docs/core-spec.md` |
|
|
15
|
+
| `src/services/task` | Own task creation, media-specific behavior, call-control operations, lifecycle orchestration, task events, and integration with the task state machine. | Partial | `src/services/task/ai-docs/task-spec.md` |
|
|
16
|
+
| `src/services/task/state-machine` | Own deterministic task lifecycle states, transition guards/actions, typed internal events, and state-derived UI-control availability. | Partial | `src/services/task/state-machine/ai-docs/task-state-machine-spec.md` |
|
|
17
|
+
| `src/utils` | Own shared pagination contracts and the bounded in-memory page cache used by Contact Center data services. | Partial | `src/utils/ai-docs/utils-spec.md` |
|
|
18
|
+
|
|
19
|
+
## Task Routing
|
|
20
|
+
|
|
21
|
+
| If the task is… | Load |
|
|
22
|
+
|---|---|
|
|
23
|
+
| Understanding the package | `ARCHITECTURE.md` |
|
|
24
|
+
| Working in a module | That module's specification from the registry |
|
|
25
|
+
| Changing exported APIs/events/types | `CONTRACTS.md`, Contact Center spec, and owning module spec |
|
|
26
|
+
| Changing task state | Task and Task State Machine specs |
|
|
27
|
+
| Changing transport/recovery | Core spec and `SECURITY.md` |
|
|
28
|
+
| New feature or defect | Run lifecycle intake against the affected module specs |
|
|
29
|
+
|
|
30
|
+
## Intake Routing
|
|
31
|
+
|
|
32
|
+
```text
|
|
33
|
+
New feature / bug / contract change → lifecycle intake questionnaire → feature spec/design
|
|
34
|
+
New module → update module registry + module spec + contracts
|
|
35
|
+
Doc/spec backfill → reconcile target → conformance → coverage → independent validation
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Incident History
|
|
39
|
+
|
|
40
|
+
| INC id | Date | Module | One-line | Link |
|
|
41
|
+
|---|---|---|---|---|
|
|
42
|
+
| None routed | 2026-07-07 | N/A | No incident/RCA source was supplied during onboarding. | N/A |
|
|
43
|
+
|
|
44
|
+
## Phase-Based Loading Protocol
|
|
45
|
+
|
|
46
|
+
| Phase | Load |
|
|
47
|
+
|---|---|
|
|
48
|
+
| Orient | AGENTS.md + this file |
|
|
49
|
+
| Specify | relevant module specs + questionnaire |
|
|
50
|
+
| Build | selected module specs + RULES/patterns |
|
|
51
|
+
| Verify | independent validation and coverage evidence |
|
|
52
|
+
|
|
53
|
+
## Spec Registry
|
|
54
|
+
|
|
55
|
+
| Doc | Location | Purpose |
|
|
56
|
+
|---|---|---|
|
|
57
|
+
| Patterns | `patterns/` | Existing implementation conventions |
|
|
58
|
+
| Rules | `RULES.md` | Enforceable do/don't constraints |
|
|
59
|
+
| Glossary | `GLOSSARY.md` | Domain language |
|
|
60
|
+
| Security | `SECURITY.md` | Trust boundaries and sensitive-data rules |
|
|
61
|
+
| Contracts | `CONTRACTS.md` | Public/export/event/dependency index |
|
|
62
|
+
| Service state | `SERVICE_STATE.md` | Current as-built surfaces/dependencies/flags |
|
|
63
|
+
| Getting started | `GETTING_STARTED.md` | Build/test loop |
|
|
64
|
+
| Decision records | `adr/` | Durable architecture decisions |
|
|
65
|
+
| Review catalog | `REVIEW_CHECKLIST.md` | Review gates |
|