agentic-qe 1.9.4 → 2.1.0
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/.claude/agents/qe-api-contract-validator.md +95 -1336
- package/.claude/agents/qe-chaos-engineer.md +152 -1211
- package/.claude/agents/qe-code-complexity.md +144 -707
- package/.claude/agents/qe-coverage-analyzer.md +147 -743
- package/.claude/agents/qe-deployment-readiness.md +143 -1496
- package/.claude/agents/qe-flaky-test-hunter.md +132 -1529
- package/.claude/agents/qe-fleet-commander.md +12 -12
- package/.claude/agents/qe-performance-tester.md +150 -886
- package/.claude/agents/qe-production-intelligence.md +155 -1396
- package/.claude/agents/qe-quality-analyzer.md +6 -6
- package/.claude/agents/qe-quality-gate.md +151 -648
- package/.claude/agents/qe-regression-risk-analyzer.md +132 -1150
- package/.claude/agents/qe-requirements-validator.md +149 -932
- package/.claude/agents/qe-security-scanner.md +157 -797
- package/.claude/agents/qe-test-data-architect.md +96 -1365
- package/.claude/agents/qe-test-executor.md +8 -8
- package/.claude/agents/qe-test-generator.md +145 -1540
- package/.claude/agents/qe-visual-tester.md +153 -1257
- package/.claude/agents/qx-partner.md +248 -0
- package/.claude/agents/subagents/qe-code-reviewer.md +40 -136
- package/.claude/agents/subagents/qe-coverage-gap-analyzer.md +40 -480
- package/.claude/agents/subagents/qe-data-generator.md +41 -125
- package/.claude/agents/subagents/qe-flaky-investigator.md +55 -411
- package/.claude/agents/subagents/qe-integration-tester.md +53 -141
- package/.claude/agents/subagents/qe-performance-validator.md +54 -130
- package/.claude/agents/subagents/qe-security-auditor.md +56 -114
- package/.claude/agents/subagents/qe-test-data-architect-sub.md +57 -548
- package/.claude/agents/subagents/qe-test-implementer.md +58 -551
- package/.claude/agents/subagents/qe-test-refactorer.md +65 -722
- package/.claude/agents/subagents/qe-test-writer.md +63 -726
- package/.claude/skills/accessibility-testing/SKILL.md +144 -692
- package/.claude/skills/agentic-quality-engineering/SKILL.md +176 -529
- package/.claude/skills/api-testing-patterns/SKILL.md +180 -560
- package/.claude/skills/brutal-honesty-review/SKILL.md +113 -603
- package/.claude/skills/bug-reporting-excellence/SKILL.md +116 -517
- package/.claude/skills/chaos-engineering-resilience/SKILL.md +127 -72
- package/.claude/skills/cicd-pipeline-qe-orchestrator/SKILL.md +209 -404
- package/.claude/skills/code-review-quality/SKILL.md +158 -608
- package/.claude/skills/compatibility-testing/SKILL.md +148 -38
- package/.claude/skills/compliance-testing/SKILL.md +132 -63
- package/.claude/skills/consultancy-practices/SKILL.md +114 -446
- package/.claude/skills/context-driven-testing/SKILL.md +117 -381
- package/.claude/skills/contract-testing/SKILL.md +176 -141
- package/.claude/skills/database-testing/SKILL.md +137 -130
- package/.claude/skills/exploratory-testing-advanced/SKILL.md +160 -629
- package/.claude/skills/holistic-testing-pact/SKILL.md +140 -188
- package/.claude/skills/localization-testing/SKILL.md +145 -33
- package/.claude/skills/mobile-testing/SKILL.md +132 -448
- package/.claude/skills/mutation-testing/SKILL.md +147 -41
- package/.claude/skills/performance-testing/SKILL.md +200 -546
- package/.claude/skills/quality-metrics/SKILL.md +164 -519
- package/.claude/skills/refactoring-patterns/SKILL.md +132 -699
- package/.claude/skills/regression-testing/SKILL.md +120 -926
- package/.claude/skills/risk-based-testing/SKILL.md +157 -660
- package/.claude/skills/security-testing/SKILL.md +199 -538
- package/.claude/skills/sherlock-review/SKILL.md +163 -699
- package/.claude/skills/shift-left-testing/SKILL.md +161 -465
- package/.claude/skills/shift-right-testing/SKILL.md +161 -519
- package/.claude/skills/six-thinking-hats/SKILL.md +175 -1110
- package/.claude/skills/skills-manifest.json +683 -0
- package/.claude/skills/tdd-london-chicago/SKILL.md +131 -448
- package/.claude/skills/technical-writing/SKILL.md +103 -154
- package/.claude/skills/test-automation-strategy/SKILL.md +166 -772
- package/.claude/skills/test-data-management/SKILL.md +126 -910
- package/.claude/skills/test-design-techniques/SKILL.md +179 -89
- package/.claude/skills/test-environment-management/SKILL.md +136 -91
- package/.claude/skills/test-reporting-analytics/SKILL.md +169 -92
- package/.claude/skills/testability-scoring/README.md +71 -0
- package/.claude/skills/testability-scoring/SKILL.md +245 -0
- package/.claude/skills/testability-scoring/resources/templates/config.template.js +84 -0
- package/.claude/skills/testability-scoring/resources/templates/testability-scoring.spec.template.js +532 -0
- package/.claude/skills/testability-scoring/scripts/generate-html-report.js +1007 -0
- package/.claude/skills/testability-scoring/scripts/run-assessment.sh +70 -0
- package/.claude/skills/visual-testing-advanced/SKILL.md +155 -78
- package/.claude/skills/xp-practices/SKILL.md +151 -587
- package/CHANGELOG.md +110 -0
- package/README.md +55 -21
- package/dist/agents/QXPartnerAgent.d.ts +146 -0
- package/dist/agents/QXPartnerAgent.d.ts.map +1 -0
- package/dist/agents/QXPartnerAgent.js +1831 -0
- package/dist/agents/QXPartnerAgent.js.map +1 -0
- package/dist/agents/index.d.ts +1 -0
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +82 -2
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/lifecycle/AgentLifecycleManager.d.ts.map +1 -1
- package/dist/agents/lifecycle/AgentLifecycleManager.js +34 -31
- package/dist/agents/lifecycle/AgentLifecycleManager.js.map +1 -1
- package/dist/cli/commands/debug/agent.d.ts.map +1 -1
- package/dist/cli/commands/debug/agent.js +19 -6
- package/dist/cli/commands/debug/agent.js.map +1 -1
- package/dist/cli/commands/debug/health-check.js +20 -7
- package/dist/cli/commands/debug/health-check.js.map +1 -1
- package/dist/cli/commands/init-claude-md-template.d.ts +1 -0
- package/dist/cli/commands/init-claude-md-template.d.ts.map +1 -1
- package/dist/cli/commands/init-claude-md-template.js +18 -3
- package/dist/cli/commands/init-claude-md-template.js.map +1 -1
- package/dist/cli/commands/workflow/cancel.d.ts.map +1 -1
- package/dist/cli/commands/workflow/cancel.js +4 -3
- package/dist/cli/commands/workflow/cancel.js.map +1 -1
- package/dist/cli/commands/workflow/list.d.ts.map +1 -1
- package/dist/cli/commands/workflow/list.js +4 -3
- package/dist/cli/commands/workflow/list.js.map +1 -1
- package/dist/cli/commands/workflow/pause.d.ts.map +1 -1
- package/dist/cli/commands/workflow/pause.js +4 -3
- package/dist/cli/commands/workflow/pause.js.map +1 -1
- package/dist/cli/init/claude-config.d.ts.map +1 -1
- package/dist/cli/init/claude-config.js +3 -8
- package/dist/cli/init/claude-config.js.map +1 -1
- package/dist/cli/init/claude-md.d.ts.map +1 -1
- package/dist/cli/init/claude-md.js +44 -2
- package/dist/cli/init/claude-md.js.map +1 -1
- package/dist/cli/init/database-init.js +1 -1
- package/dist/cli/init/index.d.ts.map +1 -1
- package/dist/cli/init/index.js +13 -6
- package/dist/cli/init/index.js.map +1 -1
- package/dist/cli/init/skills.d.ts.map +1 -1
- package/dist/cli/init/skills.js +2 -1
- package/dist/cli/init/skills.js.map +1 -1
- package/dist/core/SwarmCoordinator.d.ts +180 -0
- package/dist/core/SwarmCoordinator.d.ts.map +1 -0
- package/dist/core/SwarmCoordinator.js +473 -0
- package/dist/core/SwarmCoordinator.js.map +1 -0
- package/dist/core/memory/AgentDBIntegration.d.ts +24 -6
- package/dist/core/memory/AgentDBIntegration.d.ts.map +1 -1
- package/dist/core/memory/AgentDBIntegration.js +66 -10
- package/dist/core/memory/AgentDBIntegration.js.map +1 -1
- package/dist/core/memory/UnifiedMemoryCoordinator.d.ts +341 -0
- package/dist/core/memory/UnifiedMemoryCoordinator.d.ts.map +1 -0
- package/dist/core/memory/UnifiedMemoryCoordinator.js +986 -0
- package/dist/core/memory/UnifiedMemoryCoordinator.js.map +1 -0
- package/dist/core/memory/index.d.ts +5 -0
- package/dist/core/memory/index.d.ts.map +1 -1
- package/dist/core/memory/index.js +23 -1
- package/dist/core/memory/index.js.map +1 -1
- package/dist/core/metrics/MetricsAggregator.d.ts +228 -0
- package/dist/core/metrics/MetricsAggregator.d.ts.map +1 -0
- package/dist/core/metrics/MetricsAggregator.js +482 -0
- package/dist/core/metrics/MetricsAggregator.js.map +1 -0
- package/dist/core/metrics/index.d.ts +5 -0
- package/dist/core/metrics/index.d.ts.map +1 -0
- package/dist/core/metrics/index.js +11 -0
- package/dist/core/metrics/index.js.map +1 -0
- package/dist/core/optimization/SwarmOptimizer.d.ts +190 -0
- package/dist/core/optimization/SwarmOptimizer.d.ts.map +1 -0
- package/dist/core/optimization/SwarmOptimizer.js +648 -0
- package/dist/core/optimization/SwarmOptimizer.js.map +1 -0
- package/dist/core/optimization/index.d.ts +9 -0
- package/dist/core/optimization/index.d.ts.map +1 -0
- package/dist/core/optimization/index.js +25 -0
- package/dist/core/optimization/index.js.map +1 -0
- package/dist/core/optimization/types.d.ts +53 -0
- package/dist/core/optimization/types.d.ts.map +1 -0
- package/dist/core/optimization/types.js +6 -0
- package/dist/core/optimization/types.js.map +1 -0
- package/dist/core/orchestration/AdaptiveScheduler.d.ts +190 -0
- package/dist/core/orchestration/AdaptiveScheduler.d.ts.map +1 -0
- package/dist/core/orchestration/AdaptiveScheduler.js +460 -0
- package/dist/core/orchestration/AdaptiveScheduler.js.map +1 -0
- package/dist/core/orchestration/PriorityQueue.d.ts +54 -0
- package/dist/core/orchestration/PriorityQueue.d.ts.map +1 -0
- package/dist/core/orchestration/PriorityQueue.js +122 -0
- package/dist/core/orchestration/PriorityQueue.js.map +1 -0
- package/dist/core/orchestration/WorkflowOrchestrator.d.ts +189 -0
- package/dist/core/orchestration/WorkflowOrchestrator.d.ts.map +1 -0
- package/dist/core/orchestration/WorkflowOrchestrator.js +845 -0
- package/dist/core/orchestration/WorkflowOrchestrator.js.map +1 -0
- package/dist/core/orchestration/index.d.ts +7 -0
- package/dist/core/orchestration/index.d.ts.map +1 -0
- package/dist/core/orchestration/index.js +11 -0
- package/dist/core/orchestration/index.js.map +1 -0
- package/dist/core/orchestration/types.d.ts +96 -0
- package/dist/core/orchestration/types.d.ts.map +1 -0
- package/dist/core/orchestration/types.js +6 -0
- package/dist/core/orchestration/types.js.map +1 -0
- package/dist/core/recovery/CircuitBreaker.d.ts +176 -0
- package/dist/core/recovery/CircuitBreaker.d.ts.map +1 -0
- package/dist/core/recovery/CircuitBreaker.js +382 -0
- package/dist/core/recovery/CircuitBreaker.js.map +1 -0
- package/dist/core/recovery/RecoveryOrchestrator.d.ts +186 -0
- package/dist/core/recovery/RecoveryOrchestrator.d.ts.map +1 -0
- package/dist/core/recovery/RecoveryOrchestrator.js +476 -0
- package/dist/core/recovery/RecoveryOrchestrator.js.map +1 -0
- package/dist/core/recovery/RetryStrategy.d.ts +127 -0
- package/dist/core/recovery/RetryStrategy.d.ts.map +1 -0
- package/dist/core/recovery/RetryStrategy.js +314 -0
- package/dist/core/recovery/RetryStrategy.js.map +1 -0
- package/dist/core/recovery/index.d.ts +8 -0
- package/dist/core/recovery/index.d.ts.map +1 -0
- package/dist/core/recovery/index.js +27 -0
- package/dist/core/recovery/index.js.map +1 -0
- package/dist/core/skills/DependencyResolver.d.ts +99 -0
- package/dist/core/skills/DependencyResolver.d.ts.map +1 -0
- package/dist/core/skills/DependencyResolver.js +260 -0
- package/dist/core/skills/DependencyResolver.js.map +1 -0
- package/dist/core/skills/DynamicSkillLoader.d.ts +96 -0
- package/dist/core/skills/DynamicSkillLoader.d.ts.map +1 -0
- package/dist/core/skills/DynamicSkillLoader.js +353 -0
- package/dist/core/skills/DynamicSkillLoader.js.map +1 -0
- package/dist/core/skills/ManifestGenerator.d.ts +114 -0
- package/dist/core/skills/ManifestGenerator.d.ts.map +1 -0
- package/dist/core/skills/ManifestGenerator.js +449 -0
- package/dist/core/skills/ManifestGenerator.js.map +1 -0
- package/dist/core/skills/index.d.ts +9 -0
- package/dist/core/skills/index.d.ts.map +1 -0
- package/dist/core/skills/index.js +24 -0
- package/dist/core/skills/index.js.map +1 -0
- package/dist/core/skills/types.d.ts +118 -0
- package/dist/core/skills/types.d.ts.map +1 -0
- package/dist/core/skills/types.js +7 -0
- package/dist/core/skills/types.js.map +1 -0
- package/dist/core/transport/QUICTransport.d.ts +320 -0
- package/dist/core/transport/QUICTransport.d.ts.map +1 -0
- package/dist/core/transport/QUICTransport.js +711 -0
- package/dist/core/transport/QUICTransport.js.map +1 -0
- package/dist/core/transport/index.d.ts +40 -0
- package/dist/core/transport/index.d.ts.map +1 -0
- package/dist/core/transport/index.js +46 -0
- package/dist/core/transport/index.js.map +1 -0
- package/dist/core/transport/quic-loader.d.ts +123 -0
- package/dist/core/transport/quic-loader.d.ts.map +1 -0
- package/dist/core/transport/quic-loader.js +293 -0
- package/dist/core/transport/quic-loader.js.map +1 -0
- package/dist/core/transport/quic.d.ts +154 -0
- package/dist/core/transport/quic.d.ts.map +1 -0
- package/dist/core/transport/quic.js +214 -0
- package/dist/core/transport/quic.js.map +1 -0
- package/dist/mcp/server.d.ts +9 -9
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +1 -2
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/services/AgentRegistry.d.ts.map +1 -1
- package/dist/mcp/services/AgentRegistry.js +4 -1
- package/dist/mcp/services/AgentRegistry.js.map +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/qx.d.ts +429 -0
- package/dist/types/qx.d.ts.map +1 -0
- package/dist/types/qx.js +71 -0
- package/dist/types/qx.js.map +1 -0
- package/dist/visualization/api/RestEndpoints.js +2 -2
- package/dist/visualization/api/RestEndpoints.js.map +1 -1
- package/dist/visualization/api/WebSocketServer.d.ts +44 -0
- package/dist/visualization/api/WebSocketServer.d.ts.map +1 -1
- package/dist/visualization/api/WebSocketServer.js +144 -23
- package/dist/visualization/api/WebSocketServer.js.map +1 -1
- package/dist/visualization/core/DataTransformer.d.ts +10 -0
- package/dist/visualization/core/DataTransformer.d.ts.map +1 -1
- package/dist/visualization/core/DataTransformer.js +60 -5
- package/dist/visualization/core/DataTransformer.js.map +1 -1
- package/dist/visualization/emit-event.d.ts +75 -0
- package/dist/visualization/emit-event.d.ts.map +1 -0
- package/dist/visualization/emit-event.js +213 -0
- package/dist/visualization/emit-event.js.map +1 -0
- package/dist/visualization/index.d.ts +1 -0
- package/dist/visualization/index.d.ts.map +1 -1
- package/dist/visualization/index.js +7 -1
- package/dist/visualization/index.js.map +1 -1
- package/docs/reference/skills.md +63 -1
- package/package.json +16 -58
package/dist/cli/init/skills.js
CHANGED
|
@@ -66,7 +66,7 @@ async function copySkillTemplates(force = false) {
|
|
|
66
66
|
const targetPath = path.join(process.cwd(), '.claude/skills');
|
|
67
67
|
await fs.ensureDir(targetPath);
|
|
68
68
|
// QE-specific skill patterns (NOT claude-flow, github, flow-nexus, agentdb-*, hive-mind, hooks, performance-analysis, reasoningbank-*, sparc-methodology)
|
|
69
|
-
// Total:
|
|
69
|
+
// Total: 41 QE skills (updated from 40 - added testability-scoring contributed by @fndlalit)
|
|
70
70
|
const QE_SKILL_PATTERNS = [
|
|
71
71
|
/^accessibility-testing$/,
|
|
72
72
|
/^agentic-quality-engineering$/,
|
|
@@ -101,6 +101,7 @@ async function copySkillTemplates(force = false) {
|
|
|
101
101
|
/^tdd-london-chicago$/,
|
|
102
102
|
/^technical-writing$/,
|
|
103
103
|
/^test-automation-strategy$/,
|
|
104
|
+
/^testability-scoring$/, // Contributed by @fndlalit - https://github.com/fndlalit
|
|
104
105
|
/^test-data-management$/,
|
|
105
106
|
/^test-design-techniques$/,
|
|
106
107
|
/^test-environment-management$/,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skills.js","sourceRoot":"","sources":["../../../src/cli/init/skills.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMH,
|
|
1
|
+
{"version":3,"file":"skills.js","sourceRoot":"","sources":["../../../src/cli/init/skills.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMH,gDAoGC;AAxGD,kDAA0B;AAC1B,6CAA+B;AAC/B,2CAA6B;AAEtB,KA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AC;YACX,CAAC;QACH,CAAC;aAAM,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;YAC/B,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,cAAc,MAAM,YAAY,CAAC,CAAC,CAAC;IAC3D,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;QAChB,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,iBAAiB,OAAO,wDAAwD,CAAC,CAAC,CAAC;IAC5G,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SwarmCoordinator - Master Orchestration Layer
|
|
3
|
+
*
|
|
4
|
+
* Coordinates SwarmOptimizer, WorkflowOrchestrator, and UnifiedMemoryCoordinator
|
|
5
|
+
* to provide unified swarm management with feedback loops and adaptive optimization.
|
|
6
|
+
*/
|
|
7
|
+
import { EventEmitter } from 'events';
|
|
8
|
+
import { SwarmMemoryManager } from './memory/SwarmMemoryManager.js';
|
|
9
|
+
import { QEEventBus } from './events/QEEventBus.js';
|
|
10
|
+
import { Task, Agent } from './optimization/SwarmOptimizer.js';
|
|
11
|
+
/**
|
|
12
|
+
* Swarm topology types
|
|
13
|
+
*/
|
|
14
|
+
export type SwarmTopology = 'hierarchical' | 'mesh' | 'ring' | 'star' | 'adaptive';
|
|
15
|
+
/**
|
|
16
|
+
* Swarm status
|
|
17
|
+
*/
|
|
18
|
+
export type SwarmStatus = 'initializing' | 'running' | 'paused' | 'degraded' | 'stopped' | 'error';
|
|
19
|
+
/**
|
|
20
|
+
* Coordinator configuration
|
|
21
|
+
*/
|
|
22
|
+
export interface SwarmCoordinatorConfig {
|
|
23
|
+
/** Default topology to use */
|
|
24
|
+
defaultTopology: SwarmTopology;
|
|
25
|
+
/** Maximum agents in swarm */
|
|
26
|
+
maxAgents: number;
|
|
27
|
+
/** Enable automatic optimization */
|
|
28
|
+
autoOptimize: boolean;
|
|
29
|
+
/** Optimization interval in milliseconds */
|
|
30
|
+
optimizationInterval: number;
|
|
31
|
+
/** Enable health monitoring */
|
|
32
|
+
healthMonitoring: boolean;
|
|
33
|
+
/** Health check interval in milliseconds */
|
|
34
|
+
healthCheckInterval: number;
|
|
35
|
+
/** Enable performance feedback loop */
|
|
36
|
+
enableFeedbackLoop: boolean;
|
|
37
|
+
/** Feedback loop interval in milliseconds */
|
|
38
|
+
feedbackInterval: number;
|
|
39
|
+
/** Enable automatic recovery */
|
|
40
|
+
autoRecovery: boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Swarm metrics
|
|
44
|
+
*/
|
|
45
|
+
export interface SwarmMetrics {
|
|
46
|
+
activeAgents: number;
|
|
47
|
+
totalTasks: number;
|
|
48
|
+
completedTasks: number;
|
|
49
|
+
failedTasks: number;
|
|
50
|
+
averageTaskDuration: number;
|
|
51
|
+
throughput: number;
|
|
52
|
+
queueDepth: number;
|
|
53
|
+
memoryUsage: number;
|
|
54
|
+
cpuUtilization: number;
|
|
55
|
+
errorRate: number;
|
|
56
|
+
topology: SwarmTopology;
|
|
57
|
+
uptime: number;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Feedback loop data
|
|
61
|
+
*/
|
|
62
|
+
export interface FeedbackData {
|
|
63
|
+
timestamp: Date;
|
|
64
|
+
metrics: SwarmMetrics;
|
|
65
|
+
optimizerRecommendations: any;
|
|
66
|
+
orchestratorStatus: any;
|
|
67
|
+
memoryHealth: any;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Swarm Coordinator - Master orchestration layer
|
|
71
|
+
*/
|
|
72
|
+
export declare class SwarmCoordinator extends EventEmitter {
|
|
73
|
+
private readonly logger;
|
|
74
|
+
private readonly config;
|
|
75
|
+
private memoryManager;
|
|
76
|
+
private eventBus;
|
|
77
|
+
private optimizer;
|
|
78
|
+
private orchestrator;
|
|
79
|
+
private memoryCoordinator;
|
|
80
|
+
private recoveryOrchestrator;
|
|
81
|
+
private status;
|
|
82
|
+
private currentTopology;
|
|
83
|
+
private agents;
|
|
84
|
+
private startTime;
|
|
85
|
+
private metricsHistory;
|
|
86
|
+
private optimizationTimer?;
|
|
87
|
+
private healthCheckTimer?;
|
|
88
|
+
private feedbackTimer?;
|
|
89
|
+
private taskStats;
|
|
90
|
+
constructor(memoryManager: SwarmMemoryManager, eventBus: QEEventBus, config?: Partial<SwarmCoordinatorConfig>);
|
|
91
|
+
/**
|
|
92
|
+
* Initialize the coordinator and all sub-components
|
|
93
|
+
*/
|
|
94
|
+
initialize(): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Get current swarm status
|
|
97
|
+
*/
|
|
98
|
+
getStatus(): SwarmStatus;
|
|
99
|
+
/**
|
|
100
|
+
* Get current topology
|
|
101
|
+
*/
|
|
102
|
+
getTopology(): SwarmTopology;
|
|
103
|
+
/**
|
|
104
|
+
* Get current metrics
|
|
105
|
+
*/
|
|
106
|
+
getMetrics(): SwarmMetrics;
|
|
107
|
+
/**
|
|
108
|
+
* Register an agent with the swarm
|
|
109
|
+
*/
|
|
110
|
+
registerAgent(agent: Agent): Promise<void>;
|
|
111
|
+
/**
|
|
112
|
+
* Unregister an agent from the swarm
|
|
113
|
+
*/
|
|
114
|
+
unregisterAgent(agentId: string): Promise<void>;
|
|
115
|
+
/**
|
|
116
|
+
* Submit a task for execution
|
|
117
|
+
*/
|
|
118
|
+
submitTask(task: Task): Promise<string>;
|
|
119
|
+
/**
|
|
120
|
+
* Change swarm topology
|
|
121
|
+
*/
|
|
122
|
+
changeTopology(newTopology: SwarmTopology): Promise<void>;
|
|
123
|
+
/**
|
|
124
|
+
* Pause the swarm
|
|
125
|
+
*/
|
|
126
|
+
pause(): Promise<void>;
|
|
127
|
+
/**
|
|
128
|
+
* Resume the swarm
|
|
129
|
+
*/
|
|
130
|
+
resume(): Promise<void>;
|
|
131
|
+
/**
|
|
132
|
+
* Shutdown the coordinator
|
|
133
|
+
*/
|
|
134
|
+
shutdown(): Promise<void>;
|
|
135
|
+
/**
|
|
136
|
+
* Force optimization cycle
|
|
137
|
+
*/
|
|
138
|
+
optimize(): Promise<void>;
|
|
139
|
+
/**
|
|
140
|
+
* Get feedback loop data
|
|
141
|
+
*/
|
|
142
|
+
getFeedbackData(): Promise<FeedbackData>;
|
|
143
|
+
/**
|
|
144
|
+
* Set up event handlers for sub-components
|
|
145
|
+
*/
|
|
146
|
+
private setupEventHandlers;
|
|
147
|
+
/**
|
|
148
|
+
* Start optimization loop
|
|
149
|
+
*/
|
|
150
|
+
private startOptimizationLoop;
|
|
151
|
+
/**
|
|
152
|
+
* Start health monitoring
|
|
153
|
+
*/
|
|
154
|
+
private startHealthMonitoring;
|
|
155
|
+
/**
|
|
156
|
+
* Start feedback loop
|
|
157
|
+
*/
|
|
158
|
+
private startFeedbackLoop;
|
|
159
|
+
/**
|
|
160
|
+
* Stop all timers
|
|
161
|
+
*/
|
|
162
|
+
private stopTimers;
|
|
163
|
+
/**
|
|
164
|
+
* Build workload profile from metrics
|
|
165
|
+
*/
|
|
166
|
+
private buildWorkloadProfile;
|
|
167
|
+
/**
|
|
168
|
+
* Persist current metrics
|
|
169
|
+
*/
|
|
170
|
+
private persistMetrics;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Get or create default coordinator
|
|
174
|
+
*/
|
|
175
|
+
export declare function getSwarmCoordinator(memoryManager?: SwarmMemoryManager, eventBus?: QEEventBus, config?: Partial<SwarmCoordinatorConfig>): Promise<SwarmCoordinator>;
|
|
176
|
+
/**
|
|
177
|
+
* Reset default coordinator (for testing)
|
|
178
|
+
*/
|
|
179
|
+
export declare function resetSwarmCoordinator(): Promise<void>;
|
|
180
|
+
//# sourceMappingURL=SwarmCoordinator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SwarmCoordinator.d.ts","sourceRoot":"","sources":["../../src/core/SwarmCoordinator.ts"],"names":[],"m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
4
|
+
*
|
|
5
|
+
* Coordinates SwarmOptimizer, WorkflowOrchestrator, and UnifiedMemoryCoordinator
|
|
6
|
+
* to provide unified swarm management with feedback loops and adaptive optimization.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.SwarmCoordinator = void 0;
|
|
10
|
+
exports.getSwarmCoordinator = getSwarmCoordinator;
|
|
11
|
+
exports.resetSwarmCoordinator = resetSwarmCoordinator;
|
|
12
|
+
const events_1 = require("events");
|
|
13
|
+
const Logger_js_1 = require("../utils/Logger.js");
|
|
14
|
+
const SwarmOptimizer_js_1 = require("./optimization/SwarmOptimizer.js");
|
|
15
|
+
const WorkflowOrchestrator_js_1 = require("./orchestration/WorkflowOrchestrator.js");
|
|
16
|
+
const UnifiedMemoryCoordinator_js_1 = require("./memory/UnifiedMemoryCoordinator.js");
|
|
17
|
+
const index_js_1 = require("./recovery/index.js");
|
|
18
|
+
// CPU tracking state for utilization calculation
|
|
19
|
+
let lastCpuUsage = process.cpuUsage();
|
|
20
|
+
let lastCpuTime = Date.now();
|
|
21
|
+
/**
|
|
22
|
+
* Calculate current CPU usage percentage
|
|
23
|
+
* Uses process.cpuUsage() delta to compute actual CPU utilization
|
|
24
|
+
*/
|
|
25
|
+
function calculateCpuUsage() {
|
|
26
|
+
const currentCpuUsage = process.cpuUsage(lastCpuUsage);
|
|
27
|
+
const currentTime = Date.now();
|
|
28
|
+
const elapsedMs = currentTime - lastCpuTime;
|
|
29
|
+
if (elapsedMs === 0)
|
|
30
|
+
return 0;
|
|
31
|
+
// Total CPU time used in microseconds (user + system)
|
|
32
|
+
const totalCpuTime = currentCpuUsage.user + currentCpuUsage.system;
|
|
33
|
+
// Convert to percentage: (microseconds / 1000 = ms) / elapsed ms * 100
|
|
34
|
+
const cpuPercent = (totalCpuTime / 1000 / elapsedMs) * 100;
|
|
35
|
+
// Update tracking state for next calculation
|
|
36
|
+
lastCpuUsage = process.cpuUsage();
|
|
37
|
+
lastCpuTime = currentTime;
|
|
38
|
+
// Clamp to 0-1 range (normalized utilization)
|
|
39
|
+
return Math.min(cpuPercent / 100, 1);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Swarm Coordinator - Master orchestration layer
|
|
43
|
+
*/
|
|
44
|
+
class SwarmCoordinator extends events_1.EventEmitter {
|
|
45
|
+
constructor(memoryManager, eventBus, config) {
|
|
46
|
+
super();
|
|
47
|
+
// State
|
|
48
|
+
this.status = 'initializing';
|
|
49
|
+
this.currentTopology = 'hierarchical';
|
|
50
|
+
this.agents = new Map();
|
|
51
|
+
this.startTime = new Date();
|
|
52
|
+
this.metricsHistory = [];
|
|
53
|
+
// Metrics tracking
|
|
54
|
+
this.taskStats = {
|
|
55
|
+
total: 0,
|
|
56
|
+
completed: 0,
|
|
57
|
+
failed: 0,
|
|
58
|
+
durations: [],
|
|
59
|
+
};
|
|
60
|
+
this.logger = Logger_js_1.Logger.getInstance();
|
|
61
|
+
this.memoryManager = memoryManager;
|
|
62
|
+
this.eventBus = eventBus;
|
|
63
|
+
this.config = {
|
|
64
|
+
defaultTopology: 'hierarchical',
|
|
65
|
+
maxAgents: 10,
|
|
66
|
+
autoOptimize: true,
|
|
67
|
+
optimizationInterval: 60000, // 1 minute
|
|
68
|
+
healthMonitoring: true,
|
|
69
|
+
healthCheckInterval: 30000, // 30 seconds
|
|
70
|
+
enableFeedbackLoop: true,
|
|
71
|
+
feedbackInterval: 120000, // 2 minutes
|
|
72
|
+
autoRecovery: true,
|
|
73
|
+
...config,
|
|
74
|
+
};
|
|
75
|
+
// Initialize core components
|
|
76
|
+
this.optimizer = new SwarmOptimizer_js_1.SwarmOptimizer(memoryManager, eventBus);
|
|
77
|
+
this.orchestrator = new WorkflowOrchestrator_js_1.WorkflowOrchestrator(memoryManager, eventBus, this.optimizer);
|
|
78
|
+
this.memoryCoordinator = new UnifiedMemoryCoordinator_js_1.UnifiedMemoryCoordinator();
|
|
79
|
+
this.recoveryOrchestrator = (0, index_js_1.getRecoveryOrchestrator)();
|
|
80
|
+
this.currentTopology = this.config.defaultTopology;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Initialize the coordinator and all sub-components
|
|
84
|
+
*/
|
|
85
|
+
async initialize() {
|
|
86
|
+
this.logger.info('Initializing SwarmCoordinator');
|
|
87
|
+
this.status = 'initializing';
|
|
88
|
+
try {
|
|
89
|
+
// Initialize components in order
|
|
90
|
+
await this.optimizer.initialize();
|
|
91
|
+
await this.orchestrator.initialize();
|
|
92
|
+
await this.memoryCoordinator.initialize();
|
|
93
|
+
// Set up event handlers
|
|
94
|
+
this.setupEventHandlers();
|
|
95
|
+
// Start monitoring if enabled
|
|
96
|
+
if (this.config.autoOptimize) {
|
|
97
|
+
this.startOptimizationLoop();
|
|
98
|
+
}
|
|
99
|
+
if (this.config.healthMonitoring) {
|
|
100
|
+
this.startHealthMonitoring();
|
|
101
|
+
}
|
|
102
|
+
if (this.config.enableFeedbackLoop) {
|
|
103
|
+
this.startFeedbackLoop();
|
|
104
|
+
}
|
|
105
|
+
this.status = 'running';
|
|
106
|
+
this.startTime = new Date();
|
|
107
|
+
this.emit('initialized', { topology: this.currentTopology });
|
|
108
|
+
this.logger.info('SwarmCoordinator initialized successfully');
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
this.status = 'error';
|
|
112
|
+
this.logger.error('Failed to initialize SwarmCoordinator:', error);
|
|
113
|
+
throw error;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Get current swarm status
|
|
118
|
+
*/
|
|
119
|
+
getStatus() {
|
|
120
|
+
return this.status;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Get current topology
|
|
124
|
+
*/
|
|
125
|
+
getTopology() {
|
|
126
|
+
return this.currentTopology;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Get current metrics
|
|
130
|
+
*/
|
|
131
|
+
getMetrics() {
|
|
132
|
+
const avgDuration = this.taskStats.durations.length > 0
|
|
133
|
+
? this.taskStats.durations.reduce((a, b) => a + b, 0) / this.taskStats.durations.length
|
|
134
|
+
: 0;
|
|
135
|
+
const uptime = Date.now() - this.startTime.getTime();
|
|
136
|
+
const throughput = uptime > 0
|
|
137
|
+
? (this.taskStats.completed / (uptime / 1000))
|
|
138
|
+
: 0;
|
|
139
|
+
const errorRate = this.taskStats.total > 0
|
|
140
|
+
? this.taskStats.failed / this.taskStats.total
|
|
141
|
+
: 0;
|
|
142
|
+
// Get queue depth from orchestrator
|
|
143
|
+
const queueDepth = this.orchestrator?.getQueueDepth() ?? 0;
|
|
144
|
+
// Calculate real CPU utilization using process.cpuUsage()
|
|
145
|
+
const cpuUtilization = calculateCpuUsage();
|
|
146
|
+
return {
|
|
147
|
+
activeAgents: this.agents.size,
|
|
148
|
+
totalTasks: this.taskStats.total,
|
|
149
|
+
completedTasks: this.taskStats.completed,
|
|
150
|
+
failedTasks: this.taskStats.failed,
|
|
151
|
+
averageTaskDuration: avgDuration,
|
|
152
|
+
throughput,
|
|
153
|
+
queueDepth,
|
|
154
|
+
memoryUsage: process.memoryUsage().heapUsed,
|
|
155
|
+
cpuUtilization,
|
|
156
|
+
errorRate,
|
|
157
|
+
topology: this.currentTopology,
|
|
158
|
+
uptime,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Register an agent with the swarm
|
|
163
|
+
*/
|
|
164
|
+
async registerAgent(agent) {
|
|
165
|
+
if (this.agents.size >= this.config.maxAgents) {
|
|
166
|
+
throw new Error(`Maximum agent limit (${this.config.maxAgents}) reached`);
|
|
167
|
+
}
|
|
168
|
+
this.agents.set(agent.id, agent);
|
|
169
|
+
this.emit('agent:registered', { agentId: agent.id, type: agent.type });
|
|
170
|
+
this.logger.info(`Agent registered: ${agent.id} (${agent.type})`);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Unregister an agent from the swarm
|
|
174
|
+
*/
|
|
175
|
+
async unregisterAgent(agentId) {
|
|
176
|
+
const agent = this.agents.get(agentId);
|
|
177
|
+
if (agent) {
|
|
178
|
+
this.agents.delete(agentId);
|
|
179
|
+
this.emit('agent:unregistered', { agentId, type: agent.type });
|
|
180
|
+
this.logger.info(`Agent unregistered: ${agentId}`);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Submit a task for execution
|
|
185
|
+
*/
|
|
186
|
+
async submitTask(task) {
|
|
187
|
+
this.taskStats.total++;
|
|
188
|
+
try {
|
|
189
|
+
// Use recovery orchestrator for resilient execution
|
|
190
|
+
const result = await this.recoveryOrchestrator.executeWithRecovery('orchestration', `task:${task.id}`, async () => {
|
|
191
|
+
// Get optimal allocation from optimizer
|
|
192
|
+
const allocation = await this.optimizer.allocateAgents([task], Array.from(this.agents.values()));
|
|
193
|
+
// Execute through orchestrator
|
|
194
|
+
// Note: WorkflowOrchestrator handles actual execution
|
|
195
|
+
return task.id;
|
|
196
|
+
});
|
|
197
|
+
this.emit('task:submitted', { taskId: task.id, priority: task.priority });
|
|
198
|
+
return result;
|
|
199
|
+
}
|
|
200
|
+
catch (error) {
|
|
201
|
+
this.taskStats.failed++;
|
|
202
|
+
throw error;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Change swarm topology
|
|
207
|
+
*/
|
|
208
|
+
async changeTopology(newTopology) {
|
|
209
|
+
if (newTopology === this.currentTopology) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
this.logger.info(`Changing topology: ${this.currentTopology} -> ${newTopology}`);
|
|
213
|
+
const oldTopology = this.currentTopology;
|
|
214
|
+
this.currentTopology = newTopology;
|
|
215
|
+
// Notify all agents of topology change
|
|
216
|
+
this.emit('topology:changed', { from: oldTopology, to: newTopology });
|
|
217
|
+
// Store in memory for persistence
|
|
218
|
+
await this.memoryCoordinator.store('swarm:topology', { topology: newTopology, changedAt: new Date().toISOString() });
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Pause the swarm
|
|
222
|
+
*/
|
|
223
|
+
async pause() {
|
|
224
|
+
this.status = 'paused';
|
|
225
|
+
this.stopTimers();
|
|
226
|
+
this.emit('paused');
|
|
227
|
+
this.logger.info('Swarm paused');
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Resume the swarm
|
|
231
|
+
*/
|
|
232
|
+
async resume() {
|
|
233
|
+
this.status = 'running';
|
|
234
|
+
if (this.config.autoOptimize) {
|
|
235
|
+
this.startOptimizationLoop();
|
|
236
|
+
}
|
|
237
|
+
if (this.config.healthMonitoring) {
|
|
238
|
+
this.startHealthMonitoring();
|
|
239
|
+
}
|
|
240
|
+
if (this.config.enableFeedbackLoop) {
|
|
241
|
+
this.startFeedbackLoop();
|
|
242
|
+
}
|
|
243
|
+
this.emit('resumed');
|
|
244
|
+
this.logger.info('Swarm resumed');
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Shutdown the coordinator
|
|
248
|
+
*/
|
|
249
|
+
async shutdown() {
|
|
250
|
+
this.logger.info('Shutting down SwarmCoordinator');
|
|
251
|
+
this.status = 'stopped';
|
|
252
|
+
this.stopTimers();
|
|
253
|
+
// Persist final metrics
|
|
254
|
+
await this.persistMetrics();
|
|
255
|
+
this.emit('shutdown');
|
|
256
|
+
this.removeAllListeners();
|
|
257
|
+
this.logger.info('SwarmCoordinator shutdown complete');
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Force optimization cycle
|
|
261
|
+
*/
|
|
262
|
+
async optimize() {
|
|
263
|
+
this.logger.debug('Running optimization cycle');
|
|
264
|
+
try {
|
|
265
|
+
// Get current workload profile
|
|
266
|
+
const metrics = this.getMetrics();
|
|
267
|
+
const workloadProfile = this.buildWorkloadProfile(metrics);
|
|
268
|
+
// Get topology recommendation
|
|
269
|
+
const recommendation = await this.optimizer.recommendTopology(workloadProfile);
|
|
270
|
+
// Apply recommendation if different from current
|
|
271
|
+
if (recommendation && recommendation.topology !== this.currentTopology) {
|
|
272
|
+
if (recommendation.confidence > 0.7) {
|
|
273
|
+
await this.changeTopology(recommendation.topology);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
this.emit('optimization:complete', { recommendation, metrics });
|
|
277
|
+
}
|
|
278
|
+
catch (error) {
|
|
279
|
+
this.logger.error('Optimization cycle failed:', error);
|
|
280
|
+
this.emit('optimization:failed', { error });
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Get feedback loop data
|
|
285
|
+
*/
|
|
286
|
+
async getFeedbackData() {
|
|
287
|
+
const metrics = this.getMetrics();
|
|
288
|
+
const memoryHealth = await this.memoryCoordinator.checkHealth();
|
|
289
|
+
// Get latest optimization recommendations from optimizer
|
|
290
|
+
const optimizerRecommendations = this.optimizer?.getLatestRecommendation() ?? null;
|
|
291
|
+
// Get orchestrator status with queue depth and execution info
|
|
292
|
+
const orchestratorStatus = this.orchestrator?.getStatus() ?? { status: 'unknown' };
|
|
293
|
+
return {
|
|
294
|
+
timestamp: new Date(),
|
|
295
|
+
metrics,
|
|
296
|
+
optimizerRecommendations,
|
|
297
|
+
orchestratorStatus,
|
|
298
|
+
memoryHealth: { healthy: memoryHealth },
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Set up event handlers for sub-components
|
|
303
|
+
*/
|
|
304
|
+
setupEventHandlers() {
|
|
305
|
+
// Forward events from sub-components
|
|
306
|
+
this.eventBus.subscribe('agent:completed', (data) => {
|
|
307
|
+
this.taskStats.completed++;
|
|
308
|
+
if (data.duration) {
|
|
309
|
+
this.taskStats.durations.push(data.duration);
|
|
310
|
+
// Keep only last 1000 durations
|
|
311
|
+
if (this.taskStats.durations.length > 1000) {
|
|
312
|
+
this.taskStats.durations = this.taskStats.durations.slice(-1000);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
this.eventBus.subscribe('agent:failed', () => {
|
|
317
|
+
this.taskStats.failed++;
|
|
318
|
+
});
|
|
319
|
+
// Listen for recovery events
|
|
320
|
+
this.recoveryOrchestrator.on('recovery-success', (data) => {
|
|
321
|
+
this.logger.info(`Recovery succeeded for ${data.component}:`, data);
|
|
322
|
+
});
|
|
323
|
+
this.recoveryOrchestrator.on('recovery-failed', (data) => {
|
|
324
|
+
this.logger.warn(`Recovery failed for ${data.component}:`, data);
|
|
325
|
+
if (this.status !== 'degraded') {
|
|
326
|
+
this.status = 'degraded';
|
|
327
|
+
this.emit('status:degraded', { reason: data.error });
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Start optimization loop
|
|
333
|
+
*/
|
|
334
|
+
startOptimizationLoop() {
|
|
335
|
+
this.optimizationTimer = setInterval(() => {
|
|
336
|
+
this.optimize().catch(err => {
|
|
337
|
+
this.logger.error('Optimization loop error:', err);
|
|
338
|
+
});
|
|
339
|
+
}, this.config.optimizationInterval);
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Start health monitoring
|
|
343
|
+
*/
|
|
344
|
+
startHealthMonitoring() {
|
|
345
|
+
this.healthCheckTimer = setInterval(async () => {
|
|
346
|
+
try {
|
|
347
|
+
const memoryHealthy = await this.memoryCoordinator.checkHealth();
|
|
348
|
+
if (!memoryHealthy && this.config.autoRecovery) {
|
|
349
|
+
await this.recoveryOrchestrator.attemptRecovery('memory', new Error('Memory health check failed'));
|
|
350
|
+
}
|
|
351
|
+
this.emit('health:checked', {
|
|
352
|
+
memoryHealthy,
|
|
353
|
+
status: this.status,
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
catch (error) {
|
|
357
|
+
this.logger.error('Health check failed:', error);
|
|
358
|
+
}
|
|
359
|
+
}, this.config.healthCheckInterval);
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Start feedback loop
|
|
363
|
+
*/
|
|
364
|
+
startFeedbackLoop() {
|
|
365
|
+
this.feedbackTimer = setInterval(async () => {
|
|
366
|
+
try {
|
|
367
|
+
const feedbackData = await this.getFeedbackData();
|
|
368
|
+
// Store metrics history
|
|
369
|
+
this.metricsHistory.push(feedbackData.metrics);
|
|
370
|
+
if (this.metricsHistory.length > 100) {
|
|
371
|
+
this.metricsHistory = this.metricsHistory.slice(-100);
|
|
372
|
+
}
|
|
373
|
+
// Persist to memory (24 hours TTL)
|
|
374
|
+
await this.memoryCoordinator.store(`swarm:feedback:${Date.now()}`, feedbackData, 86400000 // 24 hours in ms
|
|
375
|
+
);
|
|
376
|
+
this.emit('feedback:collected', feedbackData);
|
|
377
|
+
}
|
|
378
|
+
catch (error) {
|
|
379
|
+
this.logger.error('Feedback loop error:', error);
|
|
380
|
+
}
|
|
381
|
+
}, this.config.feedbackInterval);
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Stop all timers
|
|
385
|
+
*/
|
|
386
|
+
stopTimers() {
|
|
387
|
+
if (this.optimizationTimer) {
|
|
388
|
+
clearInterval(this.optimizationTimer);
|
|
389
|
+
this.optimizationTimer = undefined;
|
|
390
|
+
}
|
|
391
|
+
if (this.healthCheckTimer) {
|
|
392
|
+
clearInterval(this.healthCheckTimer);
|
|
393
|
+
this.healthCheckTimer = undefined;
|
|
394
|
+
}
|
|
395
|
+
if (this.feedbackTimer) {
|
|
396
|
+
clearInterval(this.feedbackTimer);
|
|
397
|
+
this.feedbackTimer = undefined;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Build workload profile from metrics
|
|
402
|
+
*/
|
|
403
|
+
buildWorkloadProfile(metrics) {
|
|
404
|
+
// Calculate average complexity from multiple factors:
|
|
405
|
+
// 1. Duration factor: normalized task duration (0-1 scale, baseline 5000ms)
|
|
406
|
+
const durationFactor = Math.min(metrics.averageTaskDuration / 5000, 1);
|
|
407
|
+
// 2. Error factor: higher error rates indicate complex/problematic tasks
|
|
408
|
+
const errorFactor = metrics.errorRate;
|
|
409
|
+
// 3. Throughput factor: low throughput relative to agents indicates coordination complexity
|
|
410
|
+
const expectedThroughput = metrics.activeAgents * 0.5; // 0.5 tasks/sec per agent baseline
|
|
411
|
+
const throughputFactor = metrics.activeAgents > 0 && expectedThroughput > 0
|
|
412
|
+
? Math.max(0, 1 - (metrics.throughput / expectedThroughput))
|
|
413
|
+
: 0;
|
|
414
|
+
// 4. Memory factor: high memory usage indicates data-intensive complexity
|
|
415
|
+
const memoryFactor = Math.min(metrics.memoryUsage / 1073741824, 1); // 1GB baseline
|
|
416
|
+
// Weighted average complexity (0-1 scale)
|
|
417
|
+
const averageComplexity = Math.min(1, Math.max(0, durationFactor * 0.4 + // Duration is primary indicator
|
|
418
|
+
errorFactor * 0.2 + // Errors suggest complexity
|
|
419
|
+
throughputFactor * 0.2 + // Low throughput means coordination overhead
|
|
420
|
+
memoryFactor * 0.2 // Memory usage indicates data complexity
|
|
421
|
+
));
|
|
422
|
+
return {
|
|
423
|
+
taskCount: metrics.totalTasks,
|
|
424
|
+
averageComplexity,
|
|
425
|
+
parallelizationPotential: metrics.activeAgents > 1 ? 0.8 : 0.3,
|
|
426
|
+
coordinationNeeds: metrics.activeAgents > 5 ? 0.8 : 0.4,
|
|
427
|
+
memoryIntensity: metrics.memoryUsage > 500000000 ? 0.8 : 0.4, // 500MB threshold
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Persist current metrics
|
|
432
|
+
*/
|
|
433
|
+
async persistMetrics() {
|
|
434
|
+
try {
|
|
435
|
+
await this.memoryCoordinator.store('swarm:metrics:final', {
|
|
436
|
+
metrics: this.getMetrics(),
|
|
437
|
+
history: this.metricsHistory.slice(-20),
|
|
438
|
+
shutdownTime: new Date().toISOString(),
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
catch (error) {
|
|
442
|
+
this.logger.error('Failed to persist metrics:', error);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
exports.SwarmCoordinator = SwarmCoordinator;
|
|
447
|
+
/**
|
|
448
|
+
* Default coordinator instance
|
|
449
|
+
*/
|
|
450
|
+
let defaultCoordinator = null;
|
|
451
|
+
/**
|
|
452
|
+
* Get or create default coordinator
|
|
453
|
+
*/
|
|
454
|
+
async function getSwarmCoordinator(memoryManager, eventBus, config) {
|
|
455
|
+
if (!defaultCoordinator && memoryManager && eventBus) {
|
|
456
|
+
defaultCoordinator = new SwarmCoordinator(memoryManager, eventBus, config);
|
|
457
|
+
await defaultCoordinator.initialize();
|
|
458
|
+
}
|
|
459
|
+
if (!defaultCoordinator) {
|
|
460
|
+
throw new Error('SwarmCoordinator not initialized. Provide memoryManager and eventBus.');
|
|
461
|
+
}
|
|
462
|
+
return defaultCoordinator;
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Reset default coordinator (for testing)
|
|
466
|
+
*/
|
|
467
|
+
async function resetSwarmCoordinator() {
|
|
468
|
+
if (defaultCoordinator) {
|
|
469
|
+
await defaultCoordinator.shutdown();
|
|
470
|
+
defaultCoordinator = null;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
//# sourceMappingURL=SwarmCoordinator.js.map
|