0xray 4.0.33 → 4.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/.grok-plugin/plugin.json +1 -1
  2. package/.xray/codex.json +12 -4
  3. package/.xray/features.json +1 -1
  4. package/AGENTS-consumer.md +6 -6
  5. package/AGENTS.md +5 -5
  6. package/README.md +2 -2
  7. package/dist/AGENTS.md +5 -5
  8. package/dist/CHANGELOG.md +25 -0
  9. package/dist/README.md +2 -2
  10. package/dist/cli/index.js +2 -5
  11. package/dist/governance/governance-service.js +1 -1
  12. package/dist/integrations/base/README.md +1 -9
  13. package/dist/integrations/base/index.d.ts +0 -1
  14. package/dist/integrations/base/index.js +0 -2
  15. package/dist/integrations/governance/index.js +31 -8
  16. package/dist/integrations/grok/hooks/grok-hook-utils.js +1 -1
  17. package/dist/integrations/grok/hooks/session-start.js +12 -0
  18. package/dist/integrations/hooks/goggles-pipeline.mjs +108 -22
  19. package/dist/integrations/hooks/goggles-planes.json +23 -0
  20. package/dist/integrations/hooks/host-truth.mjs +74 -0
  21. package/dist/integrations/hooks/station-hook-runtime.cjs +3 -0
  22. package/dist/integrations/openclaw/plugin/xray-pre-tool/package.json +1 -1
  23. package/dist/mcps/knowledge-skills/storyteller.server.js +0 -1
  24. package/dist/nucleus/delegation-gate.d.ts +2 -2
  25. package/dist/nucleus/delegation-gate.js +13 -2
  26. package/dist/nucleus/work-freshness.mjs +189 -0
  27. package/dist/processors/implementations/agents-md-validation-processor.js +1 -1
  28. package/docs-site/docs/plates/boot.md +17 -2
  29. package/docs-site/docs/plates/governance.md +3 -2
  30. package/docs-site/docs/plates/index.md +3 -1
  31. package/docs-site/docs/plates/memory-recall.md +26 -35
  32. package/docs-site/docs/plates/orchestration.md +39 -35
  33. package/docs-site/docs/plates/processor.md +34 -36
  34. package/docs-site/docs/plates/reporting.md +3 -8
  35. package/docs-site/docs/plates/routing.md +22 -11
  36. package/package.json +2 -2
  37. package/scripts/foundry/release.mjs +48 -5
  38. package/scripts/mjs/test-consumer-readiness.mjs +1 -0
  39. package/scripts/mjs/test-mcp-functionality.mjs +14 -9
  40. package/scripts/node/basic-security-audit.cjs +0 -1
  41. package/scripts/node/bridge-mcp-wiring.cjs +66 -3
  42. package/scripts/node/postinstall.cjs +1 -1
  43. package/scripts/node/prepare-consumer.cjs +11 -7
  44. package/scripts/node/setup-dev.cjs +18 -26
  45. package/scripts/node/validate-mcp-connectivity.js +2 -1
  46. package/src/integrations/openclaw/plugin/xray-pre-tool/package.json +1 -1
  47. package/src/mcps/knowledge-skills/storyteller.server.ts +0 -1
  48. package/xray/agents_template.md +5 -5
  49. package/xray/codex.json +12 -4
  50. package/xray/features.json +1 -1
  51. package/dist/agents/known-names.d.ts +0 -26
  52. package/dist/agents/known-names.js +0 -72
  53. package/dist/analytics/consent-manager.d.ts +0 -92
  54. package/dist/analytics/consent-manager.js +0 -257
  55. package/dist/benchmark/performance-benchmark.d.ts +0 -103
  56. package/dist/benchmark/performance-benchmark.js +0 -373
  57. package/dist/cli/commands/analytics-disable.d.ts +0 -9
  58. package/dist/cli/commands/analytics-disable.js +0 -72
  59. package/dist/cli/commands/analytics-enable-action.d.ts +0 -8
  60. package/dist/cli/commands/analytics-enable-action.js +0 -82
  61. package/dist/cli/commands/analytics-preview.d.ts +0 -9
  62. package/dist/cli/commands/analytics-preview.js +0 -106
  63. package/dist/cli/commands/analytics-status.d.ts +0 -9
  64. package/dist/cli/commands/analytics-status.js +0 -68
  65. package/dist/cli/commands/enforce.d.ts +0 -12
  66. package/dist/cli/commands/enforce.js +0 -78
  67. package/dist/cli/commands/govern.d.ts +0 -29
  68. package/dist/cli/commands/govern.js +0 -149
  69. package/dist/cli/commands/security-audit.d.ts +0 -23
  70. package/dist/cli/commands/security-audit.js +0 -219
  71. package/dist/cli/server.d.ts +0 -1
  72. package/dist/cli/server.js +0 -147
  73. package/dist/config/routing-mappings.d.ts +0 -26
  74. package/dist/config/routing-mappings.js +0 -151
  75. package/dist/core/bridge.mjs +0 -922
  76. package/dist/core/trace-context.d.ts +0 -12
  77. package/dist/core/trace-context.js +0 -33
  78. package/dist/enforcement/index.d.ts +0 -22
  79. package/dist/enforcement/index.js +0 -40
  80. package/dist/enforcement/loaders/index.d.ts +0 -36
  81. package/dist/enforcement/loaders/index.js +0 -39
  82. package/dist/enforcement/test-auto-healing.d.ts +0 -83
  83. package/dist/enforcement/test-auto-healing.js +0 -325
  84. package/dist/inference/index.d.ts +0 -10
  85. package/dist/inference/index.js +0 -5
  86. package/dist/infrastructure/iac-validator.d.ts +0 -150
  87. package/dist/infrastructure/iac-validator.js +0 -465
  88. package/dist/infrastructure/schemas/cloud-schemas.d.ts +0 -482
  89. package/dist/infrastructure/schemas/cloud-schemas.js +0 -488
  90. package/dist/integrations/base/ExampleIntegration.d.ts +0 -46
  91. package/dist/integrations/base/ExampleIntegration.js +0 -180
  92. package/dist/integrations/enforcement-gate.d.ts +0 -44
  93. package/dist/integrations/enforcement-gate.js +0 -348
  94. package/dist/mcps/connection/connection-manager.d.ts +0 -39
  95. package/dist/mcps/connection/connection-manager.js +0 -79
  96. package/dist/mcps/index.d.ts +0 -17
  97. package/dist/mcps/index.js +0 -65
  98. package/dist/mcps/orchestrator/index.d.ts +0 -6
  99. package/dist/mcps/orchestrator/index.js +0 -5
  100. package/dist/metrics/index.d.ts +0 -6
  101. package/dist/metrics/index.js +0 -6
  102. package/dist/orchestrator/self-direction-activation.d.ts +0 -108
  103. package/dist/orchestrator/self-direction-activation.js +0 -244
  104. package/dist/orchestrator/universal-registry-bridge.d.ts +0 -84
  105. package/dist/orchestrator/universal-registry-bridge.js +0 -246
  106. package/dist/performance/performance-budget-enforcer.d.ts +0 -157
  107. package/dist/performance/performance-budget-enforcer.js +0 -433
  108. package/dist/performance/performance-regression-tester.d.ts +0 -107
  109. package/dist/performance/performance-regression-tester.js +0 -341
  110. package/dist/postprocessor/analysis/CodeChangeAnalyzer.d.ts +0 -11
  111. package/dist/postprocessor/analysis/CodeChangeAnalyzer.js +0 -50
  112. package/dist/postprocessor/config/ProcessorConfigLoader.d.ts +0 -44
  113. package/dist/postprocessor/config/ProcessorConfigLoader.js +0 -16
  114. package/dist/postprocessor/integration.d.ts +0 -156
  115. package/dist/postprocessor/integration.js +0 -194
  116. package/dist/postprocessor/metamorphosis/index.d.ts +0 -2
  117. package/dist/postprocessor/metamorphosis/index.js +0 -1
  118. package/dist/postprocessor/redeploy/RetryHandler.d.ts +0 -49
  119. package/dist/postprocessor/redeploy/RetryHandler.js +0 -118
  120. package/dist/processors/implementations/session-capture-processor.d.ts +0 -14
  121. package/dist/processors/implementations/session-capture-processor.js +0 -37
  122. package/dist/public/XrayService.d.ts +0 -17
  123. package/dist/public/XrayService.js +0 -40
  124. package/dist/public/index.d.ts +0 -4
  125. package/dist/public/index.js +0 -2
  126. package/dist/security/comprehensive-security-audit.d.ts +0 -157
  127. package/dist/security/comprehensive-security-audit.js +0 -1004
  128. package/dist/security/index.d.ts +0 -13
  129. package/dist/security/index.js +0 -13
  130. package/dist/security/security-agent-coordinator.d.ts +0 -71
  131. package/dist/security/security-agent-coordinator.js +0 -203
  132. package/dist/security/security-hardening-system.d.ts +0 -238
  133. package/dist/security/security-hardening-system.js +0 -726
  134. package/dist/security/security-orchestration-layer.d.ts +0 -118
  135. package/dist/security/security-orchestration-layer.js +0 -495
  136. package/dist/testing/memory-regression-suite.d.ts +0 -105
  137. package/dist/testing/memory-regression-suite.js +0 -258
  138. package/dist/tools/assess-complexity-tool.d.ts +0 -28
  139. package/dist/tools/assess-complexity-tool.js +0 -44
  140. package/dist/tools/query-routing-tool.d.ts +0 -17
  141. package/dist/tools/query-routing-tool.js +0 -59
  142. package/dist/utils/batch-operations.d.ts +0 -25
  143. package/dist/utils/batch-operations.js +0 -292
  144. package/dist/utils/task-graph.d.ts +0 -29
  145. package/dist/utils/task-graph.js +0 -106
  146. package/dist/utils/test-template-generator.d.ts +0 -25
  147. package/dist/utils/test-template-generator.js +0 -178
  148. package/dist/utils/token-manager.d.ts +0 -48
  149. package/dist/utils/token-manager.js +0 -163
  150. package/dist/validation/agent-config-validator.d.ts +0 -110
  151. package/dist/validation/agent-config-validator.js +0 -280
  152. package/dist/validation/orchestration-flow-validator.d.ts +0 -87
  153. package/dist/validation/orchestration-flow-validator.js +0 -606
  154. package/src/mcps/connection/connection-manager.ts +0 -91
  155. package/src/mcps/index.ts +0 -80
  156. package/src/mcps/orchestrator/index.ts +0 -29
@@ -1,606 +0,0 @@
1
- /**
2
- * COMPREHENSIVE ORCHESTRATION FLOW VALIDATION SUITE
3
- * Validates the complete end-to-end orchestration pipeline
4
- */
5
- import { XrayOrchestrator } from "../orchestrator/orchestrator.js";
6
- import { enhancedMultiAgentOrchestrator } from "../orchestrator/enhanced-multi-agent-orchestrator.js";
7
- import { XrayStateManager } from "../state/state-manager.js";
8
- import { frameworkLogger } from "../core/framework-logger.js";
9
- import { xrayConfigLoader } from "../core/config-loader.js";
10
- import { createAgentDelegator } from "../delegation/agent-delegator.js";
11
- class OrchestrationFlowValidator {
12
- orchestrator;
13
- stateManager;
14
- agentDelegator;
15
- testResults = new Map();
16
- constructor() {
17
- this.stateManager = new XrayStateManager();
18
- this.agentDelegator = createAgentDelegator(this.stateManager, xrayConfigLoader);
19
- this.orchestrator = new XrayOrchestrator({
20
- maxConcurrentTasks: 5,
21
- conflictResolutionStrategy: "expert_priority",
22
- });
23
- }
24
- /**
25
- * SIMULATION 1: Basic Orchestration Flow
26
- * Tests the fundamental orchestration pipeline
27
- */
28
- async testBasicOrchestrationFlow() {
29
- const startTime = Date.now();
30
- const testName = "Basic Orchestration Flow";
31
- const validationSteps = [];
32
- try {
33
- // Step 1: Initialize orchestrator
34
- validationSteps.push({
35
- step: "Orchestrator Initialization",
36
- success: true,
37
- timestamp: Date.now(),
38
- details: "XrayOrchestrator created successfully",
39
- });
40
- // Step 2: Define simple task
41
- const tasks = [
42
- {
43
- id: "testing-lead",
44
- description: "Design a simple API endpoint",
45
- subagentType: "architect",
46
- priority: "medium",
47
- },
48
- ];
49
- validationSteps.push({
50
- step: "Task Definition",
51
- success: true,
52
- timestamp: Date.now(),
53
- details: `Defined ${tasks.length} task(s)`,
54
- });
55
- // Step 3: Execute orchestration
56
- const results = await this.orchestrator.executeComplexTask("Test basic orchestration", tasks);
57
- validationSteps.push({
58
- step: "Task Execution",
59
- success: results.length === 1,
60
- timestamp: Date.now(),
61
- details: `Executed ${results.length} task(s)`,
62
- });
63
- // Step 4: Validate results
64
- const success = results.every((r) => r.success);
65
- validationSteps.push({
66
- step: "Result Validation",
67
- success,
68
- timestamp: Date.now(),
69
- details: `${results.filter((r) => r.success).length}/${results.length} tasks succeeded`,
70
- });
71
- // Step 5: Check monitoring
72
- const monitoringData = enhancedMultiAgentOrchestrator.getMonitoringInterface();
73
- const hasMonitoring = Object.keys(monitoringData).length > 0;
74
- validationSteps.push({
75
- step: "Monitoring Validation",
76
- success: hasMonitoring,
77
- timestamp: Date.now(),
78
- details: `${Object.keys(monitoringData).length} agents monitored`,
79
- });
80
- const duration = Date.now() - startTime;
81
- const stats = enhancedMultiAgentOrchestrator.getStatistics();
82
- return {
83
- testName,
84
- success: success && hasMonitoring,
85
- duration,
86
- metrics: {
87
- agentsSpawned: stats.totalSpawned,
88
- agentsCompleted: stats.completedAgents,
89
- agentsFailed: stats.failedAgents,
90
- dependenciesResolved: 0,
91
- monitoringUpdates: Object.keys(monitoringData).length,
92
- },
93
- validationSteps,
94
- };
95
- }
96
- catch (error) {
97
- return {
98
- testName,
99
- success: false,
100
- duration: Date.now() - startTime,
101
- error: error instanceof Error ? error.message : String(error),
102
- metrics: {
103
- agentsSpawned: 0,
104
- agentsCompleted: 0,
105
- agentsFailed: 0,
106
- dependenciesResolved: 0,
107
- monitoringUpdates: 0,
108
- },
109
- validationSteps,
110
- };
111
- }
112
- }
113
- /**
114
- * SIMULATION 2: Dependency Management Flow
115
- * Tests complex task dependencies and sequencing
116
- */
117
- async testDependencyManagementFlow() {
118
- const startTime = Date.now();
119
- const testName = "Dependency Management Flow";
120
- const validationSteps = [];
121
- try {
122
- // Define tasks with dependencies
123
- const tasks = [
124
- {
125
- id: "design-phase",
126
- description: "Design system architecture",
127
- subagentType: "architect",
128
- priority: "high",
129
- },
130
- {
131
- id: "validate-design",
132
- description: "Validate design against requirements",
133
- subagentType: "enforcer",
134
- priority: "high",
135
- dependencies: ["design-phase"],
136
- },
137
- {
138
- id: "implement-design",
139
- description: "Implement the validated design",
140
- subagentType: "testing-lead",
141
- priority: "medium",
142
- dependencies: ["design-phase", "validate-design"],
143
- },
144
- ];
145
- validationSteps.push({
146
- step: "Dependency Task Setup",
147
- success: true,
148
- timestamp: Date.now(),
149
- details: `Created ${tasks.length} tasks with ${tasks.filter((t) => t.dependencies).length} dependencies`,
150
- });
151
- // Execute complex orchestration
152
- const results = await this.orchestrator.executeComplexTask("Test dependency management", tasks);
153
- validationSteps.push({
154
- step: "Complex Execution",
155
- success: results.length === 3,
156
- timestamp: Date.now(),
157
- details: `Completed ${results.length} interdependent tasks`,
158
- });
159
- // Validate dependency order was respected
160
- const executionOrder = results.map((r) => r.result?.id).filter(Boolean);
161
- const correctOrder = [
162
- "design-phase",
163
- "validate-design",
164
- "implement-design",
165
- ];
166
- const orderCorrect = JSON.stringify(executionOrder) === JSON.stringify(correctOrder);
167
- validationSteps.push({
168
- step: "Dependency Order Validation",
169
- success: orderCorrect,
170
- timestamp: Date.now(),
171
- details: `Execution order: ${executionOrder.join(" → ")}`,
172
- });
173
- // Check for parallel execution where possible
174
- const monitoringData = enhancedMultiAgentOrchestrator.getMonitoringInterface();
175
- const parallelExecution = Object.keys(monitoringData).length >= 2; // At least 25 agents ran
176
- validationSteps.push({
177
- step: "Parallel Execution Validation",
178
- success: parallelExecution,
179
- timestamp: Date.now(),
180
- details: `${Object.keys(monitoringData).length} agents executed`,
181
- });
182
- const duration = Date.now() - startTime;
183
- const stats = enhancedMultiAgentOrchestrator.getStatistics();
184
- return {
185
- testName,
186
- success: results.every((r) => r.success) && orderCorrect,
187
- duration,
188
- metrics: {
189
- agentsSpawned: stats.totalSpawned,
190
- agentsCompleted: stats.completedAgents,
191
- agentsFailed: stats.failedAgents,
192
- dependenciesResolved: tasks.filter((t) => t.dependencies).length,
193
- monitoringUpdates: Object.keys(monitoringData).length,
194
- },
195
- validationSteps,
196
- };
197
- }
198
- catch (error) {
199
- return {
200
- testName,
201
- success: false,
202
- duration: Date.now() - startTime,
203
- error: error instanceof Error ? error.message : String(error),
204
- metrics: {
205
- agentsSpawned: 0,
206
- agentsCompleted: 0,
207
- agentsFailed: 0,
208
- dependenciesResolved: 0,
209
- monitoringUpdates: 0,
210
- },
211
- validationSteps,
212
- };
213
- }
214
- }
215
- /**
216
- * SIMULATION 3: Error Handling & Recovery Flow
217
- * Tests system resilience and fallback mechanisms
218
- */
219
- async testErrorHandlingFlow() {
220
- const startTime = Date.now();
221
- const testName = "Error Handling & Recovery Flow";
222
- const validationSteps = [];
223
- try {
224
- // Create tasks that will trigger fallback scenarios
225
- const tasks = [
226
- {
227
- id: "reliable-task",
228
- description: "Execute reliable task",
229
- subagentType: "architect",
230
- priority: "medium",
231
- },
232
- {
233
- id: "unreliable-task",
234
- description: "Execute task that may fail",
235
- subagentType: "invalid-agent-type", // This should trigger fallback
236
- priority: "low",
237
- },
238
- ];
239
- validationSteps.push({
240
- step: "Error Scenario Setup",
241
- success: true,
242
- timestamp: Date.now(),
243
- details: "Created tasks with intentional failure scenarios",
244
- });
245
- // Execute with error handling
246
- const results = await this.orchestrator.executeComplexTask("Test error handling and recovery", tasks);
247
- validationSteps.push({
248
- step: "Error Execution",
249
- success: results.length === 2,
250
- timestamp: Date.now(),
251
- details: `Processed ${results.length} tasks with error handling`,
252
- });
253
- // Validate that system continued despite errors
254
- const successfulTasks = results.filter((r) => r.success).length;
255
- const failedTasks = results.filter((r) => !r.success).length;
256
- const gracefulFailure = failedTasks > 0 && successfulTasks > 0;
257
- validationSteps.push({
258
- step: "Graceful Failure Validation",
259
- success: gracefulFailure,
260
- timestamp: Date.now(),
261
- details: `${successfulTasks} succeeded, ${failedTasks} failed gracefully`,
262
- });
263
- // Check monitoring shows both success and failure states
264
- const monitoringData = enhancedMultiAgentOrchestrator.getMonitoringInterface();
265
- const hasCompletedAgents = Object.values(monitoringData).some((agent) => agent.status === "completed");
266
- const hasFailedAgents = Object.values(monitoringData).some((agent) => agent.status === "failed");
267
- validationSteps.push({
268
- step: "Monitoring State Validation",
269
- success: hasCompletedAgents && hasFailedAgents,
270
- timestamp: Date.now(),
271
- details: `Monitoring shows ${hasCompletedAgents ? "completed" : "no completed"} and ${hasFailedAgents ? "failed" : "no failed"} agents`,
272
- });
273
- const duration = Date.now() - startTime;
274
- const stats = enhancedMultiAgentOrchestrator.getStatistics();
275
- return {
276
- testName,
277
- success: gracefulFailure && hasCompletedAgents,
278
- duration,
279
- metrics: {
280
- agentsSpawned: stats.totalSpawned,
281
- agentsCompleted: stats.completedAgents,
282
- agentsFailed: stats.failedAgents,
283
- dependenciesResolved: 0,
284
- monitoringUpdates: Object.keys(monitoringData).length,
285
- },
286
- validationSteps,
287
- };
288
- }
289
- catch (error) {
290
- return {
291
- testName,
292
- success: false,
293
- duration: Date.now() - startTime,
294
- error: error instanceof Error ? error.message : String(error),
295
- metrics: {
296
- agentsSpawned: 0,
297
- agentsCompleted: 0,
298
- agentsFailed: 0,
299
- dependenciesResolved: 0,
300
- monitoringUpdates: 0,
301
- },
302
- validationSteps,
303
- };
304
- }
305
- }
306
- /**
307
- * SIMULATION 4: Performance & Scalability Flow
308
- * Tests system performance under load
309
- */
310
- async testPerformanceFlow() {
311
- const startTime = Date.now();
312
- const testName = "Performance & Scalability Flow";
313
- const validationSteps = [];
314
- try {
315
- // Create multiple concurrent tasks
316
- const taskCount = 5;
317
- const tasks = Array.from({ length: taskCount }, (_, i) => ({
318
- id: `perf-task-${i}`,
319
- description: `Performance test task ${i}`,
320
- subagentType: [
321
- "architect",
322
- "researcher",
323
- "enforcer",
324
- "testing-lead",
325
- "security-auditor",
326
- ][i % 5],
327
- priority: "medium",
328
- }));
329
- validationSteps.push({
330
- step: "Performance Task Setup",
331
- success: true,
332
- timestamp: Date.now(),
333
- details: `Created ${taskCount} concurrent tasks`,
334
- });
335
- // Execute concurrent tasks
336
- const results = await this.orchestrator.executeComplexTask("Test performance and scalability", tasks);
337
- validationSteps.push({
338
- step: "Concurrent Execution",
339
- success: results.length === taskCount,
340
- timestamp: Date.now(),
341
- details: `Executed ${results.length} concurrent tasks`,
342
- });
343
- // Validate performance metrics
344
- const totalDuration = Date.now() - startTime;
345
- const avgTaskDuration = totalDuration / taskCount;
346
- const reasonablePerformance = avgTaskDuration < 10000; // Less than 10 seconds per task
347
- validationSteps.push({
348
- step: "Performance Validation",
349
- success: reasonablePerformance,
350
- timestamp: Date.now(),
351
- details: `Average task duration: ${avgTaskDuration.toFixed(2)}ms`,
352
- });
353
- // Check resource management
354
- const stats = enhancedMultiAgentOrchestrator.getStatistics();
355
- const resourceEfficiency = stats.completedAgents >= taskCount * 0.8; // At least 80% success rate
356
- validationSteps.push({
357
- step: "Resource Management Validation",
358
- success: resourceEfficiency,
359
- timestamp: Date.now(),
360
- details: `${stats.completedAgents}/${taskCount} tasks completed successfully`,
361
- });
362
- const duration = Date.now() - startTime;
363
- return {
364
- testName,
365
- success: reasonablePerformance && resourceEfficiency,
366
- duration,
367
- metrics: {
368
- agentsSpawned: stats.totalSpawned,
369
- agentsCompleted: stats.completedAgents,
370
- agentsFailed: stats.failedAgents,
371
- dependenciesResolved: 0,
372
- monitoringUpdates: taskCount,
373
- },
374
- validationSteps,
375
- };
376
- }
377
- catch (error) {
378
- return {
379
- testName,
380
- success: false,
381
- duration: Date.now() - startTime,
382
- error: error instanceof Error ? error.message : String(error),
383
- metrics: {
384
- agentsSpawned: 0,
385
- agentsCompleted: 0,
386
- agentsFailed: 0,
387
- dependenciesResolved: 0,
388
- monitoringUpdates: 0,
389
- },
390
- validationSteps,
391
- };
392
- }
393
- }
394
- /**
395
- * SIMULATION 5: Monitoring & Cleanup Flow
396
- * Tests the complete monitoring and cleanup lifecycle
397
- */
398
- async testMonitoringCleanupFlow() {
399
- const startTime = Date.now();
400
- const testName = "Monitoring & Cleanup Flow";
401
- const validationSteps = [];
402
- try {
403
- // Execute tasks to generate monitoring data
404
- const tasks = [
405
- {
406
- id: "monitor-test-1",
407
- description: "Test monitoring capabilities",
408
- subagentType: "architect",
409
- priority: "medium",
410
- },
411
- {
412
- id: "monitor-test-2",
413
- description: "Test cleanup mechanisms",
414
- subagentType: "researcher",
415
- priority: "medium",
416
- },
417
- ];
418
- const results = await this.orchestrator.executeComplexTask("Test monitoring and cleanup", tasks);
419
- validationSteps.push({
420
- step: "Monitoring Data Generation",
421
- success: results.length === 2,
422
- timestamp: Date.now(),
423
- details: "Generated monitoring data through task execution",
424
- });
425
- // Validate monitoring interface
426
- const monitoringData = enhancedMultiAgentOrchestrator.getMonitoringInterface();
427
- const hasClickableAgents = Object.values(monitoringData).every((agent) => agent.clickable);
428
- const hasProgressTracking = Object.values(monitoringData).every((agent) => typeof agent.progress === "number");
429
- validationSteps.push({
430
- step: "Monitoring Interface Validation",
431
- success: hasClickableAgents && hasProgressTracking,
432
- timestamp: Date.now(),
433
- details: `Clickable: ${hasClickableAgents}, Progress: ${hasProgressTracking}`,
434
- });
435
- // Test agent cancellation
436
- const agentIds = Object.keys(monitoringData);
437
- if (agentIds.length > 0) {
438
- const agentIdToCancel = agentIds[0];
439
- if (agentIdToCancel) {
440
- const cancelResult = await enhancedMultiAgentOrchestrator.cancelAgent(agentIdToCancel);
441
- validationSteps.push({
442
- step: "Agent Cancellation Test",
443
- success: cancelResult,
444
- timestamp: Date.now(),
445
- details: `Cancelled agent ${agentIdToCancel}: ${cancelResult}`,
446
- });
447
- }
448
- }
449
- // Wait for cleanup to occur
450
- await new Promise((resolve) => setTimeout(resolve, 1000));
451
- // Validate cleanup occurred
452
- const postCleanupStats = enhancedMultiAgentOrchestrator.getStatistics();
453
- const cleanupOccurred = postCleanupStats.activeAgents < 2; // Should have cleaned up cancelled agent
454
- validationSteps.push({
455
- step: "Cleanup Validation",
456
- success: cleanupOccurred,
457
- timestamp: Date.now(),
458
- details: `Active agents after cleanup: ${postCleanupStats.activeAgents}`,
459
- });
460
- const duration = Date.now() - startTime;
461
- const stats = enhancedMultiAgentOrchestrator.getStatistics();
462
- return {
463
- testName,
464
- success: hasClickableAgents && hasProgressTracking && cleanupOccurred,
465
- duration,
466
- metrics: {
467
- agentsSpawned: stats.totalSpawned,
468
- agentsCompleted: stats.completedAgents,
469
- agentsFailed: stats.failedAgents,
470
- dependenciesResolved: 0,
471
- monitoringUpdates: Object.keys(monitoringData).length,
472
- },
473
- validationSteps,
474
- };
475
- }
476
- catch (error) {
477
- return {
478
- testName,
479
- success: false,
480
- duration: Date.now() - startTime,
481
- error: error instanceof Error ? error.message : String(error),
482
- metrics: {
483
- agentsSpawned: 0,
484
- agentsCompleted: 0,
485
- agentsFailed: 0,
486
- dependenciesResolved: 0,
487
- monitoringUpdates: 0,
488
- },
489
- validationSteps,
490
- };
491
- }
492
- }
493
- /**
494
- * Run all orchestration flow validations
495
- */
496
- async runCompleteValidationSuite() {
497
- await frameworkLogger.log("orchestration-flow-validator", "-starting-comprehensive-orchestration-flow-validat", "info", {
498
- message: "🚀 STARTING COMPREHENSIVE ORCHESTRATION FLOW VALIDATION SUITE\n",
499
- });
500
- await frameworkLogger.log("orchestration-flow-validator", "-repeat-70-", "info", { message: "=".repeat(70) });
501
- const tests = [
502
- this.testBasicOrchestrationFlow(),
503
- this.testDependencyManagementFlow(),
504
- this.testErrorHandlingFlow(),
505
- this.testPerformanceFlow(),
506
- this.testMonitoringCleanupFlow(),
507
- ];
508
- const results = await Promise.all(tests);
509
- // Store results
510
- results.forEach((result) => {
511
- this.testResults.set(result.testName, result);
512
- });
513
- // Generate comprehensive report
514
- return this.generateValidationReport(results);
515
- }
516
- /**
517
- * Generate comprehensive validation report
518
- */
519
- generateValidationReport(results) {
520
- const totalTests = results.length;
521
- const passedTests = results.filter((r) => r.success).length;
522
- const failedTests = totalTests - passedTests;
523
- const successRate = (passedTests / totalTests) * 100;
524
- const totalDuration = results.reduce((sum, r) => sum + r.duration, 0);
525
- const avgDuration = totalDuration / totalTests;
526
- const totalAgentsSpawned = results.reduce((sum, r) => sum + r.metrics.agentsSpawned, 0);
527
- const totalAgentsCompleted = results.reduce((sum, r) => sum + r.metrics.agentsCompleted, 0);
528
- const totalDependenciesResolved = results.reduce((sum, r) => sum + r.metrics.dependenciesResolved, 0);
529
- // Validation report output - kept as console.log for user-readable reports
530
- results.forEach((result, index) => {
531
- const status = result.success ? "✅ PASS" : "❌ FAIL";
532
- const duration = result.duration;
533
- const agents = result.metrics.agentsSpawned;
534
- // Test result details - kept as console.log for readability
535
- void frameworkLogger.log("orchestration-flow-validator", "-index-1-result-testname-status-duration-ms-agents", "info", {
536
- message: `${index + 1}. ${result.testName} - ${status} (${duration}ms, ${agents} agents)`,
537
- });
538
- // Show key metrics
539
- void frameworkLogger.log("orchestration-flow-validator", "-metrics-result-metrics-agentscompleted-result-met", "info", {
540
- message: ` Metrics: ${result.metrics.agentsCompleted}/${result.metrics.agentsSpawned} completed, ${result.metrics.dependenciesResolved} deps resolved`,
541
- });
542
- // Show validation steps
543
- result.validationSteps.forEach((step) => {
544
- const stepStatus = step.success ? "✓" : "✗";
545
- void frameworkLogger.log("orchestration-flow-validator", "-stepstatus-step-step-", "info", { message: ` ${stepStatus} ${step.step}` });
546
- });
547
- void frameworkLogger.log("orchestration-flow-validator", "-", "info", {
548
- message: "",
549
- });
550
- });
551
- // Cleanup
552
- enhancedMultiAgentOrchestrator.shutdown();
553
- return {
554
- summary: {
555
- totalTests,
556
- passedTests,
557
- failedTests,
558
- successRate,
559
- totalDuration,
560
- avgDuration,
561
- },
562
- metrics: {
563
- totalAgentsSpawned,
564
- totalAgentsCompleted,
565
- totalDependenciesResolved,
566
- totalMonitoringUpdates: results.reduce((sum, r) => sum + r.metrics.monitoringUpdates, 0),
567
- },
568
- testResults: results,
569
- recommendations: this.generateRecommendations(results),
570
- };
571
- }
572
- /**
573
- * Generate recommendations based on test results
574
- */
575
- generateRecommendations(results) {
576
- const recommendations = [];
577
- const failedTests = results.filter((r) => !r.success);
578
- if (failedTests.length > 0) {
579
- recommendations.push(`Address ${failedTests.length} failing test(s): ${failedTests.map((t) => t.testName).join(", ")}`);
580
- }
581
- const slowTests = results.filter((r) => r.duration > 10000);
582
- if (slowTests.length > 0) {
583
- recommendations.push(`Optimize performance for ${slowTests.length} slow test(s) averaging >10s execution time`);
584
- }
585
- const lowCompletionRate = results.some((r) => r.metrics.agentsCompleted / r.metrics.agentsSpawned < 0.8);
586
- if (lowCompletionRate) {
587
- recommendations.push("Improve agent completion rates - some tests show <80% success rate");
588
- }
589
- if (recommendations.length === 0) {
590
- recommendations.push("All tests passed successfully - orchestration pipeline is fully validated");
591
- }
592
- return recommendations;
593
- }
594
- }
595
- // Export for external use
596
- export { OrchestrationFlowValidator };
597
- // Run validation suite if executed directly
598
- if (import.meta.url === `file://${process.argv[1]}`) {
599
- const validator = new OrchestrationFlowValidator();
600
- validator
601
- .runCompleteValidationSuite()
602
- .then((results) => {
603
- // Validation completion - kept as console.log for user feedback
604
- })
605
- .catch(() => { });
606
- }
@@ -1,91 +0,0 @@
1
- import { IMcpConnection, IServerConfig } from '../types/index.js';
2
- import { McpConnection } from './mcp-connection.js';
3
- import { frameworkLogger } from '../../core/framework-logger.js';
4
-
5
- /**
6
- * Connection Manager
7
- * Manages MCP connection lifecycle and provides centralized access to connections
8
- */
9
- export class ConnectionManager {
10
- private connections: Map<string, IMcpConnection> = new Map();
11
-
12
- /**
13
- * Get or create a connection for a server
14
- * @param config - Server configuration
15
- * @returns Promise resolving to an MCP connection
16
- */
17
- async getConnection(config: IServerConfig): Promise<IMcpConnection> {
18
- const existingConnection = this.connections.get(config.serverName);
19
- if (existingConnection && existingConnection.isConnected) {
20
- return existingConnection;
21
- }
22
-
23
- // If existing connection is disconnected, remove it
24
- if (existingConnection) {
25
- await existingConnection.disconnect();
26
- this.connections.delete(config.serverName);
27
- }
28
-
29
- // Create new connection
30
- const connection = new McpConnection(config);
31
- await connection.connect();
32
- this.connections.set(config.serverName, connection);
33
- return connection;
34
- }
35
-
36
- /**
37
- * Disconnect a specific server
38
- * @param serverName - Name of the server to disconnect
39
- */
40
- async disconnect(serverName: string): Promise<void> {
41
- const connection = this.connections.get(serverName);
42
- if (connection) {
43
- await connection.disconnect();
44
- this.connections.delete(serverName);
45
- }
46
- }
47
-
48
- /**
49
- * Disconnect all managed connections
50
- */
51
- async disconnectAll(): Promise<void> {
52
- const disconnectPromises: Promise<void>[] = [];
53
- for (const [serverName, connection] of this.connections) {
54
- disconnectPromises.push(
55
- connection.disconnect().catch((error) => {
56
- frameworkLogger.log("connection-manager", "disconnect-error", "error", { serverName, error });
57
- })
58
- );
59
- }
60
- await Promise.all(disconnectPromises);
61
- this.connections.clear();
62
- }
63
-
64
- /**
65
- * Check if a connection exists for a server
66
- * @param serverName - Name of the server
67
- * @returns True if connection exists and is connected
68
- */
69
- hasConnection(serverName: string): boolean {
70
- const connection = this.connections.get(serverName);
71
- return connection !== undefined && connection.isConnected;
72
- }
73
-
74
- /**
75
- * Get all connected server names
76
- * @returns Array of server names
77
- */
78
- getConnectedServers(): string[] {
79
- return Array.from(this.connections.entries())
80
- .filter(([, connection]) => connection.isConnected)
81
- .map(([name]) => name);
82
- }
83
-
84
- /**
85
- * Get the number of active connections
86
- * @returns Number of connections
87
- */
88
- getConnectionCount(): number {
89
- return this.getConnectedServers().length;
90
- }
91
- }