agentic-qe 1.0.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/analysis/code-analyzer.md +209 -0
- package/.claude/agents/analysis/code-review/analyze-code-quality.md +180 -0
- package/.claude/agents/architecture/system-design/arch-system-design.md +156 -0
- package/.claude/agents/base-template-generator.md +42 -0
- package/.claude/agents/consensus/byzantine-coordinator.md +63 -0
- package/.claude/agents/consensus/crdt-synchronizer.md +997 -0
- package/.claude/agents/consensus/gossip-coordinator.md +63 -0
- package/.claude/agents/consensus/performance-benchmarker.md +851 -0
- package/.claude/agents/consensus/quorum-manager.md +823 -0
- package/.claude/agents/consensus/raft-manager.md +63 -0
- package/.claude/agents/consensus/security-manager.md +622 -0
- package/.claude/agents/core/coder.md +266 -0
- package/.claude/agents/core/planner.md +168 -0
- package/.claude/agents/core/researcher.md +190 -0
- package/.claude/agents/core/reviewer.md +326 -0
- package/.claude/agents/core/tester.md +319 -0
- package/.claude/agents/data/ml/data-ml-model.md +193 -0
- package/.claude/agents/development/backend/dev-backend-api.md +142 -0
- package/.claude/agents/devops/ci-cd/ops-cicd-github.md +164 -0
- package/.claude/agents/documentation/api-docs/docs-api-openapi.md +174 -0
- package/.claude/agents/flow-nexus/app-store.md +88 -0
- package/.claude/agents/flow-nexus/authentication.md +69 -0
- package/.claude/agents/flow-nexus/challenges.md +81 -0
- package/.claude/agents/flow-nexus/neural-network.md +88 -0
- package/.claude/agents/flow-nexus/payments.md +83 -0
- package/.claude/agents/flow-nexus/sandbox.md +76 -0
- package/.claude/agents/flow-nexus/swarm.md +76 -0
- package/.claude/agents/flow-nexus/user-tools.md +96 -0
- package/.claude/agents/flow-nexus/workflow.md +84 -0
- package/.claude/agents/github/code-review-swarm.md +538 -0
- package/.claude/agents/github/github-modes.md +173 -0
- package/.claude/agents/github/issue-tracker.md +319 -0
- package/.claude/agents/github/multi-repo-swarm.md +553 -0
- package/.claude/agents/github/pr-manager.md +191 -0
- package/.claude/agents/github/project-board-sync.md +509 -0
- package/.claude/agents/github/release-manager.md +367 -0
- package/.claude/agents/github/release-swarm.md +583 -0
- package/.claude/agents/github/repo-architect.md +398 -0
- package/.claude/agents/github/swarm-issue.md +573 -0
- package/.claude/agents/github/swarm-pr.md +428 -0
- package/.claude/agents/github/sync-coordinator.md +452 -0
- package/.claude/agents/github/workflow-automation.md +635 -0
- package/.claude/agents/goal/code-goal-planner.md +446 -0
- package/.claude/agents/goal/goal-planner.md +168 -0
- package/.claude/agents/hive-mind/collective-intelligence-coordinator.md +130 -0
- package/.claude/agents/hive-mind/queen-coordinator.md +203 -0
- package/.claude/agents/hive-mind/scout-explorer.md +242 -0
- package/.claude/agents/hive-mind/swarm-memory-manager.md +193 -0
- package/.claude/agents/hive-mind/worker-specialist.md +217 -0
- package/.claude/agents/neural/safla-neural.md +74 -0
- package/.claude/agents/optimization/benchmark-suite.md +665 -0
- package/.claude/agents/optimization/load-balancer.md +431 -0
- package/.claude/agents/optimization/performance-monitor.md +672 -0
- package/.claude/agents/optimization/resource-allocator.md +674 -0
- package/.claude/agents/optimization/topology-optimizer.md +808 -0
- package/.claude/agents/qe-api-contract-validator.md +1088 -0
- package/.claude/agents/qe-chaos-engineer.md +736 -0
- package/.claude/agents/qe-coverage-analyzer.md +282 -0
- package/.claude/agents/qe-deployment-readiness.md +1109 -0
- package/.claude/agents/qe-flaky-test-hunter.md +1121 -0
- package/.claude/agents/qe-fleet-commander.md +641 -0
- package/.claude/agents/qe-performance-tester.md +354 -0
- package/.claude/agents/qe-production-intelligence.md +1162 -0
- package/.claude/agents/qe-quality-gate.md +294 -0
- package/.claude/agents/qe-regression-risk-analyzer.md +947 -0
- package/.claude/agents/qe-requirements-validator.md +691 -0
- package/.claude/agents/qe-security-scanner.md +430 -0
- package/.claude/agents/qe-test-data-architect.md +1007 -0
- package/.claude/agents/qe-test-executor.md +365 -0
- package/.claude/agents/qe-test-generator.md +332 -0
- package/.claude/agents/qe-visual-tester.md +754 -0
- package/.claude/agents/sparc/architecture.md +472 -0
- package/.claude/agents/sparc/pseudocode.md +318 -0
- package/.claude/agents/sparc/refinement.md +525 -0
- package/.claude/agents/sparc/specification.md +276 -0
- package/.claude/agents/specialized/mobile/spec-mobile-react-native.md +226 -0
- package/.claude/agents/swarm/adaptive-coordinator.md +396 -0
- package/.claude/agents/swarm/hierarchical-coordinator.md +327 -0
- package/.claude/agents/swarm/mesh-coordinator.md +392 -0
- package/.claude/agents/templates/automation-smart-agent.md +205 -0
- package/.claude/agents/templates/coordinator-swarm-init.md +105 -0
- package/.claude/agents/templates/github-pr-manager.md +177 -0
- package/.claude/agents/templates/implementer-sparc-coder.md +259 -0
- package/.claude/agents/templates/memory-coordinator.md +187 -0
- package/.claude/agents/templates/migration-plan.md +746 -0
- package/.claude/agents/templates/orchestrator-task.md +139 -0
- package/.claude/agents/templates/performance-analyzer.md +199 -0
- package/.claude/agents/templates/sparc-coordinator.md +183 -0
- package/.claude/agents/testing/unit/tdd-london-swarm.md +244 -0
- package/.claude/agents/testing/validation/production-validator.md +395 -0
- package/.claude/aqe-fleet.json +47 -0
- package/.claude/commands/README.md +106 -0
- package/.claude/commands/agents/README.md +10 -0
- package/.claude/commands/agents/agent-capabilities.md +21 -0
- package/.claude/commands/agents/agent-coordination.md +28 -0
- package/.claude/commands/agents/agent-spawning.md +28 -0
- package/.claude/commands/agents/agent-types.md +26 -0
- package/.claude/commands/analysis/COMMAND_COMPLIANCE_REPORT.md +54 -0
- package/.claude/commands/analysis/README.md +9 -0
- package/.claude/commands/analysis/bottleneck-detect.md +162 -0
- package/.claude/commands/analysis/performance-bottlenecks.md +59 -0
- package/.claude/commands/analysis/performance-report.md +25 -0
- package/.claude/commands/analysis/token-efficiency.md +45 -0
- package/.claude/commands/analysis/token-usage.md +25 -0
- package/.claude/commands/aqe-analyze.md +344 -0
- package/.claude/commands/aqe-benchmark.md +466 -0
- package/.claude/commands/aqe-chaos.md +443 -0
- package/.claude/commands/aqe-execute.md +322 -0
- package/.claude/commands/aqe-fleet-status.md +431 -0
- package/.claude/commands/aqe-generate.md +301 -0
- package/.claude/commands/aqe-optimize.md +361 -0
- package/.claude/commands/aqe-report.md +411 -0
- package/.claude/commands/automation/README.md +9 -0
- package/.claude/commands/automation/auto-agent.md +122 -0
- package/.claude/commands/automation/self-healing.md +106 -0
- package/.claude/commands/automation/session-memory.md +90 -0
- package/.claude/commands/automation/smart-agents.md +73 -0
- package/.claude/commands/automation/smart-spawn.md +25 -0
- package/.claude/commands/automation/workflow-select.md +25 -0
- package/.claude/commands/coordination/README.md +9 -0
- package/.claude/commands/coordination/agent-spawn.md +25 -0
- package/.claude/commands/coordination/init.md +44 -0
- package/.claude/commands/coordination/orchestrate.md +43 -0
- package/.claude/commands/coordination/spawn.md +45 -0
- package/.claude/commands/coordination/swarm-init.md +85 -0
- package/.claude/commands/coordination/task-orchestrate.md +25 -0
- package/.claude/commands/flow-nexus/app-store.md +124 -0
- package/.claude/commands/flow-nexus/challenges.md +120 -0
- package/.claude/commands/flow-nexus/login-registration.md +65 -0
- package/.claude/commands/flow-nexus/neural-network.md +134 -0
- package/.claude/commands/flow-nexus/payments.md +116 -0
- package/.claude/commands/flow-nexus/sandbox.md +83 -0
- package/.claude/commands/flow-nexus/swarm.md +87 -0
- package/.claude/commands/flow-nexus/user-tools.md +152 -0
- package/.claude/commands/flow-nexus/workflow.md +115 -0
- package/.claude/commands/github/README.md +11 -0
- package/.claude/commands/github/code-review-swarm.md +514 -0
- package/.claude/commands/github/code-review.md +25 -0
- package/.claude/commands/github/github-modes.md +147 -0
- package/.claude/commands/github/github-swarm.md +121 -0
- package/.claude/commands/github/issue-tracker.md +292 -0
- package/.claude/commands/github/issue-triage.md +25 -0
- package/.claude/commands/github/multi-repo-swarm.md +519 -0
- package/.claude/commands/github/pr-enhance.md +26 -0
- package/.claude/commands/github/pr-manager.md +170 -0
- package/.claude/commands/github/project-board-sync.md +471 -0
- package/.claude/commands/github/release-manager.md +338 -0
- package/.claude/commands/github/release-swarm.md +544 -0
- package/.claude/commands/github/repo-analyze.md +25 -0
- package/.claude/commands/github/repo-architect.md +367 -0
- package/.claude/commands/github/swarm-issue.md +482 -0
- package/.claude/commands/github/swarm-pr.md +285 -0
- package/.claude/commands/github/sync-coordinator.md +301 -0
- package/.claude/commands/github/workflow-automation.md +442 -0
- package/.claude/commands/hive-mind/README.md +17 -0
- package/.claude/commands/hive-mind/hive-mind-consensus.md +8 -0
- package/.claude/commands/hive-mind/hive-mind-init.md +18 -0
- package/.claude/commands/hive-mind/hive-mind-memory.md +8 -0
- package/.claude/commands/hive-mind/hive-mind-metrics.md +8 -0
- package/.claude/commands/hive-mind/hive-mind-resume.md +8 -0
- package/.claude/commands/hive-mind/hive-mind-sessions.md +8 -0
- package/.claude/commands/hive-mind/hive-mind-spawn.md +21 -0
- package/.claude/commands/hive-mind/hive-mind-status.md +8 -0
- package/.claude/commands/hive-mind/hive-mind-stop.md +8 -0
- package/.claude/commands/hive-mind/hive-mind-wizard.md +8 -0
- package/.claude/commands/hive-mind/hive-mind.md +27 -0
- package/.claude/commands/hooks/README.md +11 -0
- package/.claude/commands/hooks/overview.md +132 -0
- package/.claude/commands/hooks/post-edit.md +117 -0
- package/.claude/commands/hooks/post-task.md +112 -0
- package/.claude/commands/hooks/pre-edit.md +113 -0
- package/.claude/commands/hooks/pre-task.md +111 -0
- package/.claude/commands/hooks/session-end.md +118 -0
- package/.claude/commands/hooks/setup.md +103 -0
- package/.claude/commands/memory/README.md +9 -0
- package/.claude/commands/memory/memory-persist.md +25 -0
- package/.claude/commands/memory/memory-search.md +25 -0
- package/.claude/commands/memory/memory-usage.md +25 -0
- package/.claude/commands/memory/neural.md +47 -0
- package/.claude/commands/memory/usage.md +46 -0
- package/.claude/commands/monitoring/README.md +9 -0
- package/.claude/commands/monitoring/agent-metrics.md +25 -0
- package/.claude/commands/monitoring/agents.md +44 -0
- package/.claude/commands/monitoring/real-time-view.md +25 -0
- package/.claude/commands/monitoring/status.md +46 -0
- package/.claude/commands/monitoring/swarm-monitor.md +25 -0
- package/.claude/commands/optimization/README.md +9 -0
- package/.claude/commands/optimization/auto-topology.md +62 -0
- package/.claude/commands/optimization/cache-manage.md +25 -0
- package/.claude/commands/optimization/parallel-execute.md +25 -0
- package/.claude/commands/optimization/parallel-execution.md +50 -0
- package/.claude/commands/optimization/topology-optimize.md +25 -0
- package/.claude/commands/pair/commands.md +546 -0
- package/.claude/commands/pair/config.md +510 -0
- package/.claude/commands/pair/examples.md +512 -0
- package/.claude/commands/pair/modes.md +348 -0
- package/.claude/commands/pair/session.md +407 -0
- package/.claude/commands/pair/start.md +209 -0
- package/.claude/commands/sparc/analyzer.md +52 -0
- package/.claude/commands/sparc/architect.md +53 -0
- package/.claude/commands/sparc/batch-executor.md +54 -0
- package/.claude/commands/sparc/coder.md +54 -0
- package/.claude/commands/sparc/debugger.md +54 -0
- package/.claude/commands/sparc/designer.md +53 -0
- package/.claude/commands/sparc/documenter.md +54 -0
- package/.claude/commands/sparc/innovator.md +54 -0
- package/.claude/commands/sparc/memory-manager.md +54 -0
- package/.claude/commands/sparc/optimizer.md +54 -0
- package/.claude/commands/sparc/orchestrator.md +132 -0
- package/.claude/commands/sparc/researcher.md +54 -0
- package/.claude/commands/sparc/reviewer.md +54 -0
- package/.claude/commands/sparc/sparc-modes.md +174 -0
- package/.claude/commands/sparc/swarm-coordinator.md +54 -0
- package/.claude/commands/sparc/tdd.md +54 -0
- package/.claude/commands/sparc/tester.md +54 -0
- package/.claude/commands/sparc/workflow-manager.md +54 -0
- package/.claude/commands/stream-chain/pipeline.md +121 -0
- package/.claude/commands/stream-chain/run.md +70 -0
- package/.claude/commands/swarm/README.md +15 -0
- package/.claude/commands/swarm/analysis.md +95 -0
- package/.claude/commands/swarm/development.md +96 -0
- package/.claude/commands/swarm/examples.md +168 -0
- package/.claude/commands/swarm/maintenance.md +102 -0
- package/.claude/commands/swarm/optimization.md +117 -0
- package/.claude/commands/swarm/research.md +136 -0
- package/.claude/commands/swarm/swarm-analysis.md +8 -0
- package/.claude/commands/swarm/swarm-background.md +8 -0
- package/.claude/commands/swarm/swarm-init.md +19 -0
- package/.claude/commands/swarm/swarm-modes.md +8 -0
- package/.claude/commands/swarm/swarm-monitor.md +8 -0
- package/.claude/commands/swarm/swarm-spawn.md +19 -0
- package/.claude/commands/swarm/swarm-status.md +8 -0
- package/.claude/commands/swarm/swarm-strategies.md +8 -0
- package/.claude/commands/swarm/swarm.md +27 -0
- package/.claude/commands/swarm/testing.md +131 -0
- package/.claude/commands/training/README.md +9 -0
- package/.claude/commands/training/model-update.md +25 -0
- package/.claude/commands/training/neural-patterns.md +74 -0
- package/.claude/commands/training/neural-train.md +25 -0
- package/.claude/commands/training/pattern-learn.md +25 -0
- package/.claude/commands/training/specialization.md +63 -0
- package/.claude/commands/truth/start.md +143 -0
- package/.claude/commands/verify/check.md +50 -0
- package/.claude/commands/verify/start.md +128 -0
- package/.claude/commands/workflows/README.md +9 -0
- package/.claude/commands/workflows/development.md +78 -0
- package/.claude/commands/workflows/research.md +63 -0
- package/.claude/commands/workflows/workflow-create.md +25 -0
- package/.claude/commands/workflows/workflow-execute.md +25 -0
- package/.claude/commands/workflows/workflow-export.md +25 -0
- package/.claude/helpers/checkpoint-manager.sh +251 -0
- package/.claude/helpers/github-safe.js +106 -0
- package/.claude/helpers/github-setup.sh +28 -0
- package/.claude/helpers/quick-start.sh +19 -0
- package/.claude/helpers/setup-mcp.sh +18 -0
- package/.claude/helpers/standard-checkpoint-hooks.sh +179 -0
- package/.claude/settings.json +114 -0
- package/.claude/settings.local.json +10 -0
- package/CONTRIBUTING.md +897 -0
- package/LICENSE +21 -0
- package/README.md +632 -0
- package/bin/aqe +959 -0
- package/config/fleet.yaml +50 -0
- package/dist/agents/ApiContractValidatorAgent.d.ts +222 -0
- package/dist/agents/ApiContractValidatorAgent.d.ts.map +1 -0
- package/dist/agents/ApiContractValidatorAgent.js +787 -0
- package/dist/agents/ApiContractValidatorAgent.js.map +1 -0
- package/dist/agents/BaseAgent.d.ts +147 -0
- package/dist/agents/BaseAgent.d.ts.map +1 -0
- package/dist/agents/BaseAgent.js +374 -0
- package/dist/agents/BaseAgent.js.map +1 -0
- package/dist/agents/CoverageAnalyzerAgent.d.ts +103 -0
- package/dist/agents/CoverageAnalyzerAgent.d.ts.map +1 -0
- package/dist/agents/CoverageAnalyzerAgent.js +466 -0
- package/dist/agents/CoverageAnalyzerAgent.js.map +1 -0
- package/dist/agents/DeploymentReadinessAgent.d.ts +244 -0
- package/dist/agents/DeploymentReadinessAgent.d.ts.map +1 -0
- package/dist/agents/DeploymentReadinessAgent.js +974 -0
- package/dist/agents/DeploymentReadinessAgent.js.map +1 -0
- package/dist/agents/FlakyTestHunterAgent.d.ts +172 -0
- package/dist/agents/FlakyTestHunterAgent.d.ts.map +1 -0
- package/dist/agents/FlakyTestHunterAgent.js +867 -0
- package/dist/agents/FlakyTestHunterAgent.js.map +1 -0
- package/dist/agents/FleetCommanderAgent.d.ts +154 -0
- package/dist/agents/FleetCommanderAgent.d.ts.map +1 -0
- package/dist/agents/FleetCommanderAgent.js +924 -0
- package/dist/agents/FleetCommanderAgent.js.map +1 -0
- package/dist/agents/PerformanceTesterAgent.d.ts +194 -0
- package/dist/agents/PerformanceTesterAgent.d.ts.map +1 -0
- package/dist/agents/PerformanceTesterAgent.js +972 -0
- package/dist/agents/PerformanceTesterAgent.js.map +1 -0
- package/dist/agents/ProductionIntelligenceAgent.d.ts +224 -0
- package/dist/agents/ProductionIntelligenceAgent.d.ts.map +1 -0
- package/dist/agents/ProductionIntelligenceAgent.js +856 -0
- package/dist/agents/ProductionIntelligenceAgent.js.map +1 -0
- package/dist/agents/QualityAnalyzerAgent.d.ts +67 -0
- package/dist/agents/QualityAnalyzerAgent.d.ts.map +1 -0
- package/dist/agents/QualityAnalyzerAgent.js +453 -0
- package/dist/agents/QualityAnalyzerAgent.js.map +1 -0
- package/dist/agents/QualityGateAgent.d.ts +104 -0
- package/dist/agents/QualityGateAgent.d.ts.map +1 -0
- package/dist/agents/QualityGateAgent.js +522 -0
- package/dist/agents/QualityGateAgent.js.map +1 -0
- package/dist/agents/RegressionRiskAnalyzerAgent.d.ts +274 -0
- package/dist/agents/RegressionRiskAnalyzerAgent.d.ts.map +1 -0
- package/dist/agents/RegressionRiskAnalyzerAgent.js +1076 -0
- package/dist/agents/RegressionRiskAnalyzerAgent.js.map +1 -0
- package/dist/agents/RequirementsValidatorAgent.d.ts +195 -0
- package/dist/agents/RequirementsValidatorAgent.d.ts.map +1 -0
- package/dist/agents/RequirementsValidatorAgent.js +992 -0
- package/dist/agents/RequirementsValidatorAgent.js.map +1 -0
- package/dist/agents/SecurityScannerAgent.d.ts +126 -0
- package/dist/agents/SecurityScannerAgent.d.ts.map +1 -0
- package/dist/agents/SecurityScannerAgent.js +695 -0
- package/dist/agents/SecurityScannerAgent.js.map +1 -0
- package/dist/agents/TestDataArchitectAgent.d.ts +452 -0
- package/dist/agents/TestDataArchitectAgent.d.ts.map +1 -0
- package/dist/agents/TestDataArchitectAgent.js +1346 -0
- package/dist/agents/TestDataArchitectAgent.js.map +1 -0
- package/dist/agents/TestExecutorAgent.d.ts +101 -0
- package/dist/agents/TestExecutorAgent.d.ts.map +1 -0
- package/dist/agents/TestExecutorAgent.js +730 -0
- package/dist/agents/TestExecutorAgent.js.map +1 -0
- package/dist/agents/TestGeneratorAgent.d.ts +109 -0
- package/dist/agents/TestGeneratorAgent.d.ts.map +1 -0
- package/dist/agents/TestGeneratorAgent.js +450 -0
- package/dist/agents/TestGeneratorAgent.js.map +1 -0
- package/dist/agents/index.d.ts +51 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +738 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/cli/commands/analyze.d.ts +32 -0
- package/dist/cli/commands/analyze.d.ts.map +1 -0
- package/dist/cli/commands/analyze.js +764 -0
- package/dist/cli/commands/analyze.js.map +1 -0
- package/dist/cli/commands/fleet.d.ts +36 -0
- package/dist/cli/commands/fleet.d.ts.map +1 -0
- package/dist/cli/commands/fleet.js +745 -0
- package/dist/cli/commands/fleet.js.map +1 -0
- package/dist/cli/commands/generate.d.ts +24 -0
- package/dist/cli/commands/generate.d.ts.map +1 -0
- package/dist/cli/commands/generate.js +424 -0
- package/dist/cli/commands/generate.js.map +1 -0
- package/dist/cli/commands/init.d.ts +17 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +570 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/run.d.ts +25 -0
- package/dist/cli/commands/run.d.ts.map +1 -0
- package/dist/cli/commands/run.js +558 -0
- package/dist/cli/commands/run.js.map +1 -0
- package/dist/cli/index-spec.d.ts +3 -0
- package/dist/cli/index-spec.d.ts.map +1 -0
- package/dist/cli/index-spec.js +154 -0
- package/dist/cli/index-spec.js.map +1 -0
- package/dist/cli/index-working.d.ts +7 -0
- package/dist/cli/index-working.d.ts.map +1 -0
- package/dist/cli/index-working.js +470 -0
- package/dist/cli/index-working.js.map +1 -0
- package/dist/cli/index.d.ts +9 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +174 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/core/Agent.d.ts +189 -0
- package/dist/core/Agent.d.ts.map +1 -0
- package/dist/core/Agent.js +288 -0
- package/dist/core/Agent.js.map +1 -0
- package/dist/core/EventBus.d.ts +40 -0
- package/dist/core/EventBus.d.ts.map +1 -0
- package/dist/core/EventBus.js +114 -0
- package/dist/core/EventBus.js.map +1 -0
- package/dist/core/FleetManager.d.ts +219 -0
- package/dist/core/FleetManager.d.ts.map +1 -0
- package/dist/core/FleetManager.js +354 -0
- package/dist/core/FleetManager.js.map +1 -0
- package/dist/core/MemoryManager.d.ts +119 -0
- package/dist/core/MemoryManager.d.ts.map +1 -0
- package/dist/core/MemoryManager.js +460 -0
- package/dist/core/MemoryManager.js.map +1 -0
- package/dist/core/Task.d.ts +264 -0
- package/dist/core/Task.d.ts.map +1 -0
- package/dist/core/Task.js +397 -0
- package/dist/core/Task.js.map +1 -0
- package/dist/core/coverage-analyzer.d.ts +50 -0
- package/dist/core/coverage-analyzer.d.ts.map +1 -0
- package/dist/core/coverage-analyzer.js +146 -0
- package/dist/core/coverage-analyzer.js.map +1 -0
- package/dist/core/index.d.ts +14 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +20 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/quality-gate.d.ts +81 -0
- package/dist/core/quality-gate.d.ts.map +1 -0
- package/dist/core/quality-gate.js +254 -0
- package/dist/core/quality-gate.js.map +1 -0
- package/dist/coverage/coverage-collector.d.ts +62 -0
- package/dist/coverage/coverage-collector.d.ts.map +1 -0
- package/dist/coverage/coverage-collector.js +61 -0
- package/dist/coverage/coverage-collector.js.map +1 -0
- package/dist/coverage/coverage-reporter.d.ts +42 -0
- package/dist/coverage/coverage-reporter.d.ts.map +1 -0
- package/dist/coverage/coverage-reporter.js +53 -0
- package/dist/coverage/coverage-reporter.js.map +1 -0
- package/dist/index.d.ts +89 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +142 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/handlers/agent-spawn.d.ts +72 -0
- package/dist/mcp/handlers/agent-spawn.d.ts.map +1 -0
- package/dist/mcp/handlers/agent-spawn.js +255 -0
- package/dist/mcp/handlers/agent-spawn.js.map +1 -0
- package/dist/mcp/handlers/base-handler.d.ts +53 -0
- package/dist/mcp/handlers/base-handler.d.ts.map +1 -0
- package/dist/mcp/handlers/base-handler.js +77 -0
- package/dist/mcp/handlers/base-handler.js.map +1 -0
- package/dist/mcp/handlers/fleet-init.d.ts +55 -0
- package/dist/mcp/handlers/fleet-init.d.ts.map +1 -0
- package/dist/mcp/handlers/fleet-init.js +149 -0
- package/dist/mcp/handlers/fleet-init.js.map +1 -0
- package/dist/mcp/handlers/fleet-status.d.ts +103 -0
- package/dist/mcp/handlers/fleet-status.d.ts.map +1 -0
- package/dist/mcp/handlers/fleet-status.js +244 -0
- package/dist/mcp/handlers/fleet-status.js.map +1 -0
- package/dist/mcp/handlers/optimize-tests.d.ts +219 -0
- package/dist/mcp/handlers/optimize-tests.d.ts.map +1 -0
- package/dist/mcp/handlers/optimize-tests.js +532 -0
- package/dist/mcp/handlers/optimize-tests.js.map +1 -0
- package/dist/mcp/handlers/predict-defects.d.ts +194 -0
- package/dist/mcp/handlers/predict-defects.d.ts.map +1 -0
- package/dist/mcp/handlers/predict-defects.js +721 -0
- package/dist/mcp/handlers/predict-defects.js.map +1 -0
- package/dist/mcp/handlers/quality-analyze.d.ts +273 -0
- package/dist/mcp/handlers/quality-analyze.d.ts.map +1 -0
- package/dist/mcp/handlers/quality-analyze.js +702 -0
- package/dist/mcp/handlers/quality-analyze.js.map +1 -0
- package/dist/mcp/handlers/task-orchestrate.d.ts +152 -0
- package/dist/mcp/handlers/task-orchestrate.d.ts.map +1 -0
- package/dist/mcp/handlers/task-orchestrate.js +629 -0
- package/dist/mcp/handlers/task-orchestrate.js.map +1 -0
- package/dist/mcp/handlers/test-execute.d.ts +132 -0
- package/dist/mcp/handlers/test-execute.d.ts.map +1 -0
- package/dist/mcp/handlers/test-execute.js +436 -0
- package/dist/mcp/handlers/test-execute.js.map +1 -0
- package/dist/mcp/handlers/test-generate.d.ts +107 -0
- package/dist/mcp/handlers/test-generate.d.ts.map +1 -0
- package/dist/mcp/handlers/test-generate.js +437 -0
- package/dist/mcp/handlers/test-generate.js.map +1 -0
- package/dist/mcp/server.d.ts +99 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +214 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/services/AgentRegistry.d.ts +191 -0
- package/dist/mcp/services/AgentRegistry.d.ts.map +1 -0
- package/dist/mcp/services/AgentRegistry.js +403 -0
- package/dist/mcp/services/AgentRegistry.js.map +1 -0
- package/dist/mcp/services/HookExecutor.d.ts +165 -0
- package/dist/mcp/services/HookExecutor.d.ts.map +1 -0
- package/dist/mcp/services/HookExecutor.js +327 -0
- package/dist/mcp/services/HookExecutor.js.map +1 -0
- package/dist/mcp/start.d.ts +7 -0
- package/dist/mcp/start.d.ts.map +1 -0
- package/dist/mcp/start.js +35 -0
- package/dist/mcp/start.js.map +1 -0
- package/dist/mcp/tools.d.ts +81 -0
- package/dist/mcp/tools.d.ts.map +1 -0
- package/dist/mcp/tools.js +471 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/optimization/sublinear-solver.d.ts +72 -0
- package/dist/optimization/sublinear-solver.d.ts.map +1 -0
- package/dist/optimization/sublinear-solver.js +263 -0
- package/dist/optimization/sublinear-solver.js.map +1 -0
- package/dist/scripts/verifyComplexity.d.ts +8 -0
- package/dist/scripts/verifyComplexity.d.ts.map +1 -0
- package/dist/scripts/verifyComplexity.js +56 -0
- package/dist/scripts/verifyComplexity.js.map +1 -0
- package/dist/types/api-contract.types.d.ts +273 -0
- package/dist/types/api-contract.types.d.ts.map +1 -0
- package/dist/types/api-contract.types.js +18 -0
- package/dist/types/api-contract.types.js.map +1 -0
- package/dist/types/errors.d.ts +104 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/errors.js +226 -0
- package/dist/types/errors.js.map +1 -0
- package/dist/types/events.d.ts +101 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/events.js +6 -0
- package/dist/types/events.js.map +1 -0
- package/dist/types/index.d.ts +570 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +131 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/Config.d.ts +128 -0
- package/dist/utils/Config.d.ts.map +1 -0
- package/dist/utils/Config.js +232 -0
- package/dist/utils/Config.js.map +1 -0
- package/dist/utils/Database.d.ts +112 -0
- package/dist/utils/Database.d.ts.map +1 -0
- package/dist/utils/Database.js +352 -0
- package/dist/utils/Database.js.map +1 -0
- package/dist/utils/Logger.d.ts +58 -0
- package/dist/utils/Logger.d.ts.map +1 -0
- package/dist/utils/Logger.js +125 -0
- package/dist/utils/Logger.js.map +1 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +14 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/sublinear/coverageOptimizer.d.ts +84 -0
- package/dist/utils/sublinear/coverageOptimizer.d.ts.map +1 -0
- package/dist/utils/sublinear/coverageOptimizer.js +415 -0
- package/dist/utils/sublinear/coverageOptimizer.js.map +1 -0
- package/dist/utils/sublinear/index.d.ts +50 -0
- package/dist/utils/sublinear/index.d.ts.map +1 -0
- package/dist/utils/sublinear/index.js +390 -0
- package/dist/utils/sublinear/index.js.map +1 -0
- package/dist/utils/sublinear/matrixSolver.d.ts +132 -0
- package/dist/utils/sublinear/matrixSolver.d.ts.map +1 -0
- package/dist/utils/sublinear/matrixSolver.js +642 -0
- package/dist/utils/sublinear/matrixSolver.js.map +1 -0
- package/dist/utils/sublinear/temporalPredictor.d.ts +195 -0
- package/dist/utils/sublinear/temporalPredictor.d.ts.map +1 -0
- package/dist/utils/sublinear/temporalPredictor.js +474 -0
- package/dist/utils/sublinear/temporalPredictor.js.map +1 -0
- package/dist/utils/sublinear/testSelector.d.ts +81 -0
- package/dist/utils/sublinear/testSelector.d.ts.map +1 -0
- package/dist/utils/sublinear/testSelector.js +303 -0
- package/dist/utils/sublinear/testSelector.js.map +1 -0
- package/package.json +131 -0
|
@@ -0,0 +1,924 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* FleetCommanderAgent - Hierarchical fleet coordinator for 50+ agent orchestration
|
|
4
|
+
*
|
|
5
|
+
* Responsibilities:
|
|
6
|
+
* - Agent lifecycle management (spawn, monitor, terminate)
|
|
7
|
+
* - Resource optimization (CPU, memory, I/O allocation)
|
|
8
|
+
* - Topology management (hierarchical, mesh, hybrid, adaptive)
|
|
9
|
+
* - Conflict resolution (resource contention, deadlocks)
|
|
10
|
+
* - Load balancing (sublinear scheduling algorithms)
|
|
11
|
+
* - Fault tolerance (failure detection and recovery)
|
|
12
|
+
* - Auto-scaling (demand-based agent pool management)
|
|
13
|
+
* - Performance monitoring (fleet-wide metrics)
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.FleetCommanderAgent = void 0;
|
|
17
|
+
const BaseAgent_1 = require("./BaseAgent");
|
|
18
|
+
const types_1 = require("../types");
|
|
19
|
+
class FleetCommanderAgent extends BaseAgent_1.BaseAgent {
|
|
20
|
+
constructor(config) {
|
|
21
|
+
super({
|
|
22
|
+
id: config.id || `fleet-commander-${Date.now()}`,
|
|
23
|
+
type: types_1.QEAgentType.FLEET_COMMANDER,
|
|
24
|
+
capabilities: [
|
|
25
|
+
{
|
|
26
|
+
name: 'agent-lifecycle-management',
|
|
27
|
+
version: '2.0.0',
|
|
28
|
+
description: 'Spawn, monitor, coordinate, and terminate QE agents'
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'resource-allocation',
|
|
32
|
+
version: '2.0.0',
|
|
33
|
+
description: 'Optimize CPU, memory, and I/O resource distribution'
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'topology-optimization',
|
|
37
|
+
version: '2.0.0',
|
|
38
|
+
description: 'Dynamically adjust coordination topologies'
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: 'conflict-resolution',
|
|
42
|
+
version: '2.0.0',
|
|
43
|
+
description: 'Resolve resource conflicts and deadlocks'
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: 'load-balancing',
|
|
47
|
+
version: '2.0.0',
|
|
48
|
+
description: 'Sublinear scheduling and workload distribution'
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: 'fault-tolerance',
|
|
52
|
+
version: '2.0.0',
|
|
53
|
+
description: 'Failure detection and recovery'
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'auto-scaling',
|
|
57
|
+
version: '2.0.0',
|
|
58
|
+
description: 'Demand-based agent pool scaling'
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: 'performance-monitoring',
|
|
62
|
+
version: '2.0.0',
|
|
63
|
+
description: 'Fleet-wide metrics and optimization'
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
context: config.context,
|
|
67
|
+
memoryStore: config.memoryStore,
|
|
68
|
+
eventBus: config.eventBus
|
|
69
|
+
});
|
|
70
|
+
this.agentPools = new Map();
|
|
71
|
+
this.resourceAllocations = new Map();
|
|
72
|
+
this.activeConflicts = new Map();
|
|
73
|
+
this.scalingHistory = [];
|
|
74
|
+
this.agentHealthChecks = new Map();
|
|
75
|
+
this.workloadQueue = [];
|
|
76
|
+
this.fleetMetrics = {
|
|
77
|
+
totalAgents: 0,
|
|
78
|
+
activeAgents: 0,
|
|
79
|
+
idleAgents: 0,
|
|
80
|
+
busyAgents: 0,
|
|
81
|
+
failedAgents: 0,
|
|
82
|
+
avgCpuUtilization: 0,
|
|
83
|
+
avgMemoryUtilization: 0,
|
|
84
|
+
totalTasksCompleted: 0,
|
|
85
|
+
avgTaskCompletionTime: 0,
|
|
86
|
+
failureRate: 0,
|
|
87
|
+
throughput: 0
|
|
88
|
+
};
|
|
89
|
+
this.config = {
|
|
90
|
+
topology: 'hierarchical',
|
|
91
|
+
maxAgents: 50,
|
|
92
|
+
agentPools: {
|
|
93
|
+
[types_1.QEAgentType.TEST_GENERATOR]: { min: 2, max: 10, priority: 'high' },
|
|
94
|
+
[types_1.QEAgentType.TEST_EXECUTOR]: { min: 3, max: 15, priority: 'critical' },
|
|
95
|
+
[types_1.QEAgentType.COVERAGE_ANALYZER]: { min: 1, max: 5, priority: 'high' },
|
|
96
|
+
[types_1.QEAgentType.QUALITY_GATE]: { min: 1, max: 3, priority: 'medium' },
|
|
97
|
+
[types_1.QEAgentType.QUALITY_ANALYZER]: { min: 1, max: 5, priority: 'medium' },
|
|
98
|
+
[types_1.QEAgentType.PERFORMANCE_TESTER]: { min: 1, max: 5, priority: 'medium' },
|
|
99
|
+
[types_1.QEAgentType.SECURITY_SCANNER]: { min: 1, max: 3, priority: 'high' }
|
|
100
|
+
},
|
|
101
|
+
resourceLimits: {
|
|
102
|
+
cpuPerAgent: 0.5,
|
|
103
|
+
memoryPerAgent: '512MB',
|
|
104
|
+
maxConcurrent: 20
|
|
105
|
+
},
|
|
106
|
+
autoScaling: {
|
|
107
|
+
enabled: true,
|
|
108
|
+
scaleUpThreshold: 0.85,
|
|
109
|
+
scaleDownThreshold: 0.30,
|
|
110
|
+
cooldownPeriod: 60000
|
|
111
|
+
},
|
|
112
|
+
faultTolerance: {
|
|
113
|
+
heartbeatInterval: 5000,
|
|
114
|
+
heartbeatTimeout: 15000,
|
|
115
|
+
maxRetries: 3
|
|
116
|
+
},
|
|
117
|
+
...config
|
|
118
|
+
};
|
|
119
|
+
this.topologyState = {
|
|
120
|
+
mode: this.config.topology,
|
|
121
|
+
nodes: 0,
|
|
122
|
+
connections: 0,
|
|
123
|
+
efficiency: 1.0,
|
|
124
|
+
lastChanged: new Date()
|
|
125
|
+
};
|
|
126
|
+
this.initializeAgentPools();
|
|
127
|
+
}
|
|
128
|
+
// ============================================================================
|
|
129
|
+
// BaseAgent Abstract Methods Implementation
|
|
130
|
+
// ============================================================================
|
|
131
|
+
async initializeComponents() {
|
|
132
|
+
console.log(`[FleetCommander] Initializing fleet coordination for ${this.config.maxAgents} agents`);
|
|
133
|
+
// Register event handlers for fleet coordination
|
|
134
|
+
this.registerEventHandler({
|
|
135
|
+
eventType: 'agent.spawned',
|
|
136
|
+
handler: async (event) => {
|
|
137
|
+
await this.handleAgentSpawned(event.data);
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
this.registerEventHandler({
|
|
141
|
+
eventType: 'agent.terminated',
|
|
142
|
+
handler: async (event) => {
|
|
143
|
+
await this.handleAgentTerminated(event.data);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
this.registerEventHandler({
|
|
147
|
+
eventType: 'agent.error',
|
|
148
|
+
handler: async (event) => {
|
|
149
|
+
await this.handleAgentError(event.data);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
this.registerEventHandler({
|
|
153
|
+
eventType: 'task:submitted',
|
|
154
|
+
handler: async (event) => {
|
|
155
|
+
await this.handleTaskSubmitted(event.data);
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
this.registerEventHandler({
|
|
159
|
+
eventType: 'task:completed',
|
|
160
|
+
handler: async (event) => {
|
|
161
|
+
await this.handleTaskCompleted(event.data);
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
// Start heartbeat monitoring (only in production, not in tests)
|
|
165
|
+
if (this.config.faultTolerance?.heartbeatInterval && process.env.NODE_ENV !== 'test') {
|
|
166
|
+
this.startHeartbeatMonitoring();
|
|
167
|
+
}
|
|
168
|
+
// Start auto-scaling monitor (only in production, not in tests)
|
|
169
|
+
if (this.config.autoScaling?.enabled && process.env.NODE_ENV !== 'test') {
|
|
170
|
+
this.startAutoScalingMonitor();
|
|
171
|
+
}
|
|
172
|
+
// Store initial topology
|
|
173
|
+
await this.storeSharedMemory('topology', this.topologyState);
|
|
174
|
+
await this.memoryStore.store('aqe/fleet/topology', this.topologyState);
|
|
175
|
+
console.log('[FleetCommander] Initialization complete');
|
|
176
|
+
}
|
|
177
|
+
async performTask(task) {
|
|
178
|
+
console.log(`[FleetCommander] Performing task: ${task.type}`);
|
|
179
|
+
switch (task.type) {
|
|
180
|
+
case 'fleet-initialize':
|
|
181
|
+
return await this.initializeFleet(task.payload);
|
|
182
|
+
case 'agent-spawn':
|
|
183
|
+
return await this.spawnAgents(task.payload);
|
|
184
|
+
case 'agent-terminate':
|
|
185
|
+
return await this.terminateAgent(task.payload);
|
|
186
|
+
case 'topology-change':
|
|
187
|
+
return await this.changeTopology(task.payload);
|
|
188
|
+
case 'rebalance-load':
|
|
189
|
+
return await this.rebalanceWorkload(task.payload);
|
|
190
|
+
case 'resolve-conflict':
|
|
191
|
+
return await this.resolveConflict(task.payload);
|
|
192
|
+
case 'fleet-status':
|
|
193
|
+
return await this.getFleetStatus();
|
|
194
|
+
case 'fleet-metrics':
|
|
195
|
+
return await this.getFleetMetrics();
|
|
196
|
+
case 'scale-pool':
|
|
197
|
+
return await this.scaleAgentPool(task.payload);
|
|
198
|
+
case 'recover-agent':
|
|
199
|
+
return await this.recoverAgent(task.payload);
|
|
200
|
+
default:
|
|
201
|
+
throw new Error(`Unknown task type: ${task.type}`);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
async loadKnowledge() {
|
|
205
|
+
console.log('[FleetCommander] Loading fleet knowledge from memory');
|
|
206
|
+
try {
|
|
207
|
+
// Restore topology state
|
|
208
|
+
const savedTopology = await this.memoryStore.retrieve('aqe/fleet/topology');
|
|
209
|
+
if (savedTopology) {
|
|
210
|
+
this.topologyState = savedTopology;
|
|
211
|
+
}
|
|
212
|
+
// Restore agent pool status
|
|
213
|
+
const savedPools = await this.memoryStore.retrieve('aqe/fleet/agents/pools');
|
|
214
|
+
if (savedPools) {
|
|
215
|
+
this.agentPools = new Map(Object.entries(savedPools));
|
|
216
|
+
}
|
|
217
|
+
// Restore resource allocations
|
|
218
|
+
const savedAllocations = await this.memoryStore.retrieve('aqe/fleet/resources/allocation');
|
|
219
|
+
if (savedAllocations) {
|
|
220
|
+
this.resourceAllocations = new Map(Object.entries(savedAllocations));
|
|
221
|
+
}
|
|
222
|
+
// Restore metrics
|
|
223
|
+
const savedMetrics = await this.memoryStore.retrieve('aqe/fleet/metrics/performance');
|
|
224
|
+
if (savedMetrics) {
|
|
225
|
+
this.fleetMetrics = { ...this.fleetMetrics, ...savedMetrics };
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
catch (error) {
|
|
229
|
+
console.warn('[FleetCommander] Could not restore full state, using defaults:', error);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
async cleanup() {
|
|
233
|
+
console.log('[FleetCommander] Cleaning up fleet resources');
|
|
234
|
+
// Clear timers
|
|
235
|
+
if (this.heartbeatMonitorInterval) {
|
|
236
|
+
clearInterval(this.heartbeatMonitorInterval);
|
|
237
|
+
this.heartbeatMonitorInterval = undefined;
|
|
238
|
+
}
|
|
239
|
+
if (this.autoScalingMonitorInterval) {
|
|
240
|
+
clearInterval(this.autoScalingMonitorInterval);
|
|
241
|
+
this.autoScalingMonitorInterval = undefined;
|
|
242
|
+
}
|
|
243
|
+
// Save current state
|
|
244
|
+
await this.memoryStore.store('aqe/fleet/topology', this.topologyState);
|
|
245
|
+
await this.memoryStore.store('aqe/fleet/agents/pools', Object.fromEntries(this.agentPools));
|
|
246
|
+
await this.memoryStore.store('aqe/fleet/resources/allocation', Object.fromEntries(this.resourceAllocations));
|
|
247
|
+
await this.memoryStore.store('aqe/fleet/metrics/performance', this.fleetMetrics);
|
|
248
|
+
// Clear active conflicts
|
|
249
|
+
this.activeConflicts.clear();
|
|
250
|
+
this.agentHealthChecks.clear();
|
|
251
|
+
this.workloadQueue = [];
|
|
252
|
+
}
|
|
253
|
+
// ============================================================================
|
|
254
|
+
// Fleet Initialization
|
|
255
|
+
// ============================================================================
|
|
256
|
+
async initializeFleet(config) {
|
|
257
|
+
console.log('[FleetCommander] Initializing fleet with config:', config);
|
|
258
|
+
const results = {
|
|
259
|
+
topology: this.topologyState.mode,
|
|
260
|
+
poolsInitialized: [],
|
|
261
|
+
totalAgents: 0,
|
|
262
|
+
status: 'success'
|
|
263
|
+
};
|
|
264
|
+
// Initialize agent pools based on configuration
|
|
265
|
+
for (const [agentType, poolConfig] of Object.entries(this.config.agentPools || {})) {
|
|
266
|
+
const pool = poolConfig;
|
|
267
|
+
// Spawn minimum required agents for each pool
|
|
268
|
+
for (let i = 0; i < pool.min; i++) {
|
|
269
|
+
await this.requestAgentSpawn(agentType, pool.priority);
|
|
270
|
+
results.totalAgents++;
|
|
271
|
+
}
|
|
272
|
+
results.poolsInitialized.push(agentType);
|
|
273
|
+
}
|
|
274
|
+
// Store initialization results
|
|
275
|
+
await this.memoryStore.store('aqe/fleet/initialization', {
|
|
276
|
+
timestamp: new Date(),
|
|
277
|
+
config: this.config,
|
|
278
|
+
results
|
|
279
|
+
});
|
|
280
|
+
return results;
|
|
281
|
+
}
|
|
282
|
+
initializeAgentPools() {
|
|
283
|
+
for (const [agentType, poolConfig] of Object.entries(this.config.agentPools || {})) {
|
|
284
|
+
this.agentPools.set(agentType, {
|
|
285
|
+
type: agentType,
|
|
286
|
+
active: 0,
|
|
287
|
+
idle: 0,
|
|
288
|
+
busy: 0,
|
|
289
|
+
failed: 0,
|
|
290
|
+
minSize: poolConfig.min,
|
|
291
|
+
maxSize: poolConfig.max,
|
|
292
|
+
priority: poolConfig.priority,
|
|
293
|
+
utilization: 0
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
// ============================================================================
|
|
298
|
+
// Agent Lifecycle Management
|
|
299
|
+
// ============================================================================
|
|
300
|
+
async spawnAgents(payload) {
|
|
301
|
+
const { type, count = 1, config = {} } = payload;
|
|
302
|
+
const spawnedAgents = [];
|
|
303
|
+
console.log(`[FleetCommander] Spawning ${count} agent(s) of type ${type}`);
|
|
304
|
+
const poolStatus = this.agentPools.get(type);
|
|
305
|
+
if (!poolStatus) {
|
|
306
|
+
throw new Error(`Unknown agent type: ${type}`);
|
|
307
|
+
}
|
|
308
|
+
// Check if we can spawn more agents
|
|
309
|
+
const totalActive = poolStatus.active + poolStatus.busy;
|
|
310
|
+
if (totalActive + count > poolStatus.maxSize) {
|
|
311
|
+
throw new Error(`Cannot spawn ${count} agents: would exceed max pool size of ${poolStatus.maxSize}`);
|
|
312
|
+
}
|
|
313
|
+
// Check total fleet limit
|
|
314
|
+
if (this.fleetMetrics.totalAgents + count > (this.config.maxAgents || 50)) {
|
|
315
|
+
throw new Error(`Cannot spawn ${count} agents: would exceed fleet limit of ${this.config.maxAgents}`);
|
|
316
|
+
}
|
|
317
|
+
for (let i = 0; i < count; i++) {
|
|
318
|
+
const agentId = await this.requestAgentSpawn(type, poolStatus.priority, config);
|
|
319
|
+
spawnedAgents.push(agentId);
|
|
320
|
+
}
|
|
321
|
+
// Update pool status
|
|
322
|
+
poolStatus.active += count;
|
|
323
|
+
poolStatus.idle += count;
|
|
324
|
+
this.agentPools.set(type, poolStatus);
|
|
325
|
+
// Update fleet metrics
|
|
326
|
+
this.fleetMetrics.totalAgents += count;
|
|
327
|
+
this.fleetMetrics.activeAgents += count;
|
|
328
|
+
this.fleetMetrics.idleAgents += count;
|
|
329
|
+
return {
|
|
330
|
+
type,
|
|
331
|
+
spawnedCount: count,
|
|
332
|
+
agentIds: spawnedAgents,
|
|
333
|
+
poolStatus: { ...poolStatus }
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
async terminateAgent(payload) {
|
|
337
|
+
const { agentId } = payload;
|
|
338
|
+
console.log(`[FleetCommander] Terminating agent ${agentId}`);
|
|
339
|
+
// Remove resource allocation
|
|
340
|
+
const allocation = this.resourceAllocations.get(agentId);
|
|
341
|
+
if (allocation) {
|
|
342
|
+
this.resourceAllocations.delete(agentId);
|
|
343
|
+
}
|
|
344
|
+
// Remove health check
|
|
345
|
+
this.agentHealthChecks.delete(agentId);
|
|
346
|
+
// Emit termination event
|
|
347
|
+
this.emitEvent('agent.terminate-request', { agentId }, 'high');
|
|
348
|
+
return { agentId, terminated: true };
|
|
349
|
+
}
|
|
350
|
+
async handleAgentSpawned(data) {
|
|
351
|
+
const { agentId, type } = data;
|
|
352
|
+
console.log(`[FleetCommander] Agent spawned: ${agentId} (${type})`);
|
|
353
|
+
// Initialize health check
|
|
354
|
+
this.agentHealthChecks.set(agentId, new Date());
|
|
355
|
+
// Allocate resources
|
|
356
|
+
const allocation = await this.allocateResources(agentId, type);
|
|
357
|
+
this.resourceAllocations.set(agentId, allocation);
|
|
358
|
+
// Update topology
|
|
359
|
+
this.topologyState.nodes++;
|
|
360
|
+
await this.updateTopologyConnections();
|
|
361
|
+
// Store in memory
|
|
362
|
+
await this.memoryStore.store(`aqe/fleet/agents/${agentId}`, {
|
|
363
|
+
id: agentId,
|
|
364
|
+
type,
|
|
365
|
+
status: types_1.AgentStatus.ACTIVE,
|
|
366
|
+
spawnedAt: new Date(),
|
|
367
|
+
allocation
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
async handleAgentTerminated(data) {
|
|
371
|
+
const { agentId } = data;
|
|
372
|
+
console.log(`[FleetCommander] Agent terminated: ${agentId}`);
|
|
373
|
+
// Find agent type and update pool
|
|
374
|
+
const agentData = await this.memoryStore.retrieve(`aqe/fleet/agents/${agentId}`);
|
|
375
|
+
if (agentData) {
|
|
376
|
+
const poolStatus = this.agentPools.get(agentData.type);
|
|
377
|
+
if (poolStatus) {
|
|
378
|
+
poolStatus.active = Math.max(0, poolStatus.active - 1);
|
|
379
|
+
poolStatus.idle = Math.max(0, poolStatus.idle - 1);
|
|
380
|
+
this.agentPools.set(agentData.type, poolStatus);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
// Update fleet metrics
|
|
384
|
+
this.fleetMetrics.totalAgents = Math.max(0, this.fleetMetrics.totalAgents - 1);
|
|
385
|
+
this.fleetMetrics.activeAgents = Math.max(0, this.fleetMetrics.activeAgents - 1);
|
|
386
|
+
// Remove from memory
|
|
387
|
+
await this.memoryStore.delete(`aqe/fleet/agents/${agentId}`);
|
|
388
|
+
// Update topology
|
|
389
|
+
this.topologyState.nodes = Math.max(0, this.topologyState.nodes - 1);
|
|
390
|
+
}
|
|
391
|
+
async handleAgentError(data) {
|
|
392
|
+
const { agentId, error } = data;
|
|
393
|
+
console.error(`[FleetCommander] Agent error: ${agentId}`, error);
|
|
394
|
+
// Update fleet metrics
|
|
395
|
+
this.fleetMetrics.failedAgents++;
|
|
396
|
+
// Attempt recovery
|
|
397
|
+
await this.recoverAgent({ agentId });
|
|
398
|
+
}
|
|
399
|
+
// ============================================================================
|
|
400
|
+
// Resource Allocation
|
|
401
|
+
// ============================================================================
|
|
402
|
+
async allocateResources(agentId, agentType) {
|
|
403
|
+
const poolConfig = this.config.agentPools?.[agentType];
|
|
404
|
+
const priority = poolConfig?.priority || 'medium';
|
|
405
|
+
const allocation = {
|
|
406
|
+
agentId,
|
|
407
|
+
cpu: this.config.resourceLimits?.cpuPerAgent || 0.5,
|
|
408
|
+
memory: this.config.resourceLimits?.memoryPerAgent || '512MB',
|
|
409
|
+
priority,
|
|
410
|
+
allocated: true
|
|
411
|
+
};
|
|
412
|
+
// Check for resource conflicts
|
|
413
|
+
const hasConflict = await this.detectResourceConflict(allocation);
|
|
414
|
+
if (hasConflict) {
|
|
415
|
+
await this.resolveConflict({
|
|
416
|
+
type: 'resource-contention',
|
|
417
|
+
agents: [agentId],
|
|
418
|
+
allocation
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
return allocation;
|
|
422
|
+
}
|
|
423
|
+
async detectResourceConflict(allocation) {
|
|
424
|
+
// Calculate total resource usage
|
|
425
|
+
let totalCpu = allocation.cpu;
|
|
426
|
+
let totalMemory = this.parseMemory(allocation.memory);
|
|
427
|
+
for (const alloc of this.resourceAllocations.values()) {
|
|
428
|
+
totalCpu += alloc.cpu;
|
|
429
|
+
totalMemory += this.parseMemory(alloc.memory);
|
|
430
|
+
}
|
|
431
|
+
// Check if we exceed limits
|
|
432
|
+
const maxConcurrent = this.config.resourceLimits?.maxConcurrent || 20;
|
|
433
|
+
const cpuLimit = maxConcurrent * (this.config.resourceLimits?.cpuPerAgent || 0.5);
|
|
434
|
+
const memoryLimit = maxConcurrent * this.parseMemory(this.config.resourceLimits?.memoryPerAgent || '512MB');
|
|
435
|
+
return totalCpu > cpuLimit || totalMemory > memoryLimit;
|
|
436
|
+
}
|
|
437
|
+
parseMemory(memStr) {
|
|
438
|
+
const match = memStr.match(/^(\d+)(MB|GB)$/);
|
|
439
|
+
if (!match)
|
|
440
|
+
return 512;
|
|
441
|
+
const value = parseInt(match[1], 10);
|
|
442
|
+
const unit = match[2];
|
|
443
|
+
return unit === 'GB' ? value * 1024 : value;
|
|
444
|
+
}
|
|
445
|
+
// ============================================================================
|
|
446
|
+
// Topology Management
|
|
447
|
+
// ============================================================================
|
|
448
|
+
async changeTopology(payload) {
|
|
449
|
+
const { mode } = payload;
|
|
450
|
+
console.log(`[FleetCommander] Changing topology from ${this.topologyState.mode} to ${mode}`);
|
|
451
|
+
const oldMode = this.topologyState.mode;
|
|
452
|
+
this.topologyState.mode = mode;
|
|
453
|
+
this.topologyState.lastChanged = new Date();
|
|
454
|
+
// Recalculate connections based on new topology
|
|
455
|
+
await this.updateTopologyConnections();
|
|
456
|
+
// Broadcast topology change
|
|
457
|
+
this.emitEvent('fleet.topology-changed', {
|
|
458
|
+
oldMode,
|
|
459
|
+
newMode: mode,
|
|
460
|
+
reason: 'manual-change',
|
|
461
|
+
timestamp: new Date()
|
|
462
|
+
}, 'high');
|
|
463
|
+
// Store in memory
|
|
464
|
+
await this.memoryStore.store('aqe/fleet/topology', this.topologyState);
|
|
465
|
+
return {
|
|
466
|
+
oldMode,
|
|
467
|
+
newMode: mode,
|
|
468
|
+
nodes: this.topologyState.nodes,
|
|
469
|
+
connections: this.topologyState.connections,
|
|
470
|
+
efficiency: this.topologyState.efficiency
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
async updateTopologyConnections() {
|
|
474
|
+
const n = this.topologyState.nodes;
|
|
475
|
+
switch (this.topologyState.mode) {
|
|
476
|
+
case 'hierarchical':
|
|
477
|
+
// Tree structure: n-1 connections
|
|
478
|
+
this.topologyState.connections = Math.max(0, n - 1);
|
|
479
|
+
this.topologyState.efficiency = 1.0;
|
|
480
|
+
break;
|
|
481
|
+
case 'mesh':
|
|
482
|
+
// Full mesh: n*(n-1)/2 connections
|
|
483
|
+
this.topologyState.connections = n > 1 ? (n * (n - 1)) / 2 : 0;
|
|
484
|
+
this.topologyState.efficiency = n > 1 ? 0.9 : 1.0;
|
|
485
|
+
break;
|
|
486
|
+
case 'hybrid':
|
|
487
|
+
// Combination: hierarchical + some mesh connections
|
|
488
|
+
this.topologyState.connections = Math.max(0, n - 1) + Math.floor(n / 2);
|
|
489
|
+
this.topologyState.efficiency = 0.95;
|
|
490
|
+
break;
|
|
491
|
+
case 'adaptive':
|
|
492
|
+
// Adaptive based on load
|
|
493
|
+
this.topologyState.connections = this.calculateAdaptiveConnections(n);
|
|
494
|
+
this.topologyState.efficiency = this.calculateTopologyEfficiency();
|
|
495
|
+
break;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
calculateAdaptiveConnections(nodes) {
|
|
499
|
+
const utilization = this.calculateFleetUtilization();
|
|
500
|
+
if (utilization < 0.3) {
|
|
501
|
+
// Low utilization: hierarchical
|
|
502
|
+
return Math.max(0, nodes - 1);
|
|
503
|
+
}
|
|
504
|
+
else if (utilization < 0.7) {
|
|
505
|
+
// Medium utilization: hybrid
|
|
506
|
+
return Math.max(0, nodes - 1) + Math.floor(nodes / 2);
|
|
507
|
+
}
|
|
508
|
+
else {
|
|
509
|
+
// High utilization: mesh
|
|
510
|
+
return nodes > 1 ? (nodes * (nodes - 1)) / 2 : 0;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
calculateTopologyEfficiency() {
|
|
514
|
+
const utilization = this.calculateFleetUtilization();
|
|
515
|
+
const mode = this.topologyState.mode;
|
|
516
|
+
if (mode === 'adaptive') {
|
|
517
|
+
// Efficiency varies with utilization
|
|
518
|
+
return 1.0 - (utilization * 0.1);
|
|
519
|
+
}
|
|
520
|
+
return this.topologyState.efficiency;
|
|
521
|
+
}
|
|
522
|
+
// ============================================================================
|
|
523
|
+
// Load Balancing
|
|
524
|
+
// ============================================================================
|
|
525
|
+
async rebalanceWorkload(payload) {
|
|
526
|
+
console.log('[FleetCommander] Rebalancing workload across fleet');
|
|
527
|
+
const rebalancingStrategy = await this.calculateRebalancingStrategy();
|
|
528
|
+
// Apply load balancing
|
|
529
|
+
for (const [agentType, targetUtilization] of Object.entries(rebalancingStrategy)) {
|
|
530
|
+
const poolStatus = this.agentPools.get(agentType);
|
|
531
|
+
if (poolStatus) {
|
|
532
|
+
poolStatus.utilization = targetUtilization;
|
|
533
|
+
this.agentPools.set(agentType, poolStatus);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
// Store results
|
|
537
|
+
await this.memoryStore.store('aqe/fleet/load-balancing', {
|
|
538
|
+
timestamp: new Date(),
|
|
539
|
+
strategy: rebalancingStrategy,
|
|
540
|
+
fleetUtilization: this.calculateFleetUtilization()
|
|
541
|
+
});
|
|
542
|
+
return {
|
|
543
|
+
strategy: rebalancingStrategy,
|
|
544
|
+
fleetUtilization: this.calculateFleetUtilization(),
|
|
545
|
+
timestamp: new Date()
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
async calculateRebalancingStrategy() {
|
|
549
|
+
const strategy = {};
|
|
550
|
+
const targetUtilization = 0.75;
|
|
551
|
+
for (const [agentType, poolStatus] of this.agentPools.entries()) {
|
|
552
|
+
const currentUtilization = poolStatus.utilization || 0;
|
|
553
|
+
// Use sublinear algorithm to calculate optimal utilization
|
|
554
|
+
const optimalUtilization = this.optimizeUtilization(currentUtilization, targetUtilization);
|
|
555
|
+
strategy[agentType] = optimalUtilization;
|
|
556
|
+
}
|
|
557
|
+
return strategy;
|
|
558
|
+
}
|
|
559
|
+
optimizeUtilization(current, target) {
|
|
560
|
+
// Simple convergence to target (in real implementation, use sublinear algorithms)
|
|
561
|
+
const delta = target - current;
|
|
562
|
+
return current + (delta * 0.5);
|
|
563
|
+
}
|
|
564
|
+
calculateFleetUtilization() {
|
|
565
|
+
const totalAgents = this.fleetMetrics.totalAgents;
|
|
566
|
+
const busyAgents = this.fleetMetrics.busyAgents;
|
|
567
|
+
return totalAgents > 0 ? busyAgents / totalAgents : 0;
|
|
568
|
+
}
|
|
569
|
+
// ============================================================================
|
|
570
|
+
// Conflict Resolution
|
|
571
|
+
// ============================================================================
|
|
572
|
+
async resolveConflict(payload) {
|
|
573
|
+
const { type, agents, severity = 'medium', allocation } = payload;
|
|
574
|
+
console.log(`[FleetCommander] Resolving ${type} conflict involving ${agents.length} agent(s)`);
|
|
575
|
+
const conflictId = `conflict-${Date.now()}`;
|
|
576
|
+
const conflict = {
|
|
577
|
+
type,
|
|
578
|
+
agents,
|
|
579
|
+
severity,
|
|
580
|
+
strategy: this.selectResolutionStrategy(type, severity),
|
|
581
|
+
resolved: false,
|
|
582
|
+
timestamp: new Date()
|
|
583
|
+
};
|
|
584
|
+
this.activeConflicts.set(conflictId, conflict);
|
|
585
|
+
let resolution;
|
|
586
|
+
switch (type) {
|
|
587
|
+
case 'resource-contention':
|
|
588
|
+
resolution = await this.resolveResourceContention(agents, allocation);
|
|
589
|
+
break;
|
|
590
|
+
case 'deadlock':
|
|
591
|
+
resolution = await this.resolveDeadlock(agents);
|
|
592
|
+
break;
|
|
593
|
+
case 'priority-conflict':
|
|
594
|
+
resolution = await this.resolvePriorityConflict(agents);
|
|
595
|
+
break;
|
|
596
|
+
default:
|
|
597
|
+
throw new Error(`Unknown conflict type: ${type}`);
|
|
598
|
+
}
|
|
599
|
+
conflict.resolved = true;
|
|
600
|
+
this.activeConflicts.set(conflictId, conflict);
|
|
601
|
+
// Store resolution
|
|
602
|
+
await this.memoryStore.store(`aqe/fleet/conflicts/${conflictId}`, conflict);
|
|
603
|
+
return {
|
|
604
|
+
conflictId,
|
|
605
|
+
...conflict,
|
|
606
|
+
resolution
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
selectResolutionStrategy(type, severity) {
|
|
610
|
+
if (type === 'resource-contention') {
|
|
611
|
+
return severity === 'critical' ? 'priority-weighted' : 'fair-share';
|
|
612
|
+
}
|
|
613
|
+
else if (type === 'deadlock') {
|
|
614
|
+
return 'timeout-based';
|
|
615
|
+
}
|
|
616
|
+
else if (type === 'priority-conflict') {
|
|
617
|
+
return 'priority-queue';
|
|
618
|
+
}
|
|
619
|
+
return 'default';
|
|
620
|
+
}
|
|
621
|
+
async resolveResourceContention(agents, allocation) {
|
|
622
|
+
// Priority-weighted resource allocation
|
|
623
|
+
const agentAllocations = await Promise.all(agents.map(async (agentId) => {
|
|
624
|
+
const agentData = await this.memoryStore.retrieve(`aqe/fleet/agents/${agentId}`);
|
|
625
|
+
return {
|
|
626
|
+
agentId,
|
|
627
|
+
priority: agentData?.allocation?.priority || 'medium'
|
|
628
|
+
};
|
|
629
|
+
}));
|
|
630
|
+
// Sort by priority
|
|
631
|
+
const priorityOrder = { critical: 4, high: 3, medium: 2, low: 1 };
|
|
632
|
+
agentAllocations.sort((a, b) => priorityOrder[b.priority] - priorityOrder[a.priority]);
|
|
633
|
+
return {
|
|
634
|
+
strategy: 'priority-weighted',
|
|
635
|
+
allocation: agentAllocations[0].agentId,
|
|
636
|
+
deferred: agentAllocations.slice(1).map(a => a.agentId)
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
async resolveDeadlock(agents) {
|
|
640
|
+
// Select victim (lowest priority agent) and abort
|
|
641
|
+
const victim = agents[0]; // Simplified: select first agent
|
|
642
|
+
console.log(`[FleetCommander] Breaking deadlock by aborting agent ${victim}`);
|
|
643
|
+
// Terminate victim agent
|
|
644
|
+
await this.terminateAgent({ agentId: victim });
|
|
645
|
+
return {
|
|
646
|
+
strategy: 'timeout-based',
|
|
647
|
+
victim,
|
|
648
|
+
action: 'abort-and-retry'
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
async resolvePriorityConflict(agents) {
|
|
652
|
+
// Use priority queue to order execution
|
|
653
|
+
return {
|
|
654
|
+
strategy: 'priority-queue',
|
|
655
|
+
executionOrder: agents
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
// ============================================================================
|
|
659
|
+
// Auto-Scaling
|
|
660
|
+
// ============================================================================
|
|
661
|
+
async scaleAgentPool(payload) {
|
|
662
|
+
const { type, action, count = 1 } = payload;
|
|
663
|
+
console.log(`[FleetCommander] ${action} agent pool ${type} by ${count}`);
|
|
664
|
+
if (action === 'scale-up') {
|
|
665
|
+
return await this.spawnAgents({ type, count });
|
|
666
|
+
}
|
|
667
|
+
else {
|
|
668
|
+
return await this.scaleDownPool(type, count);
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
async scaleDownPool(agentType, count) {
|
|
672
|
+
const poolStatus = this.agentPools.get(agentType);
|
|
673
|
+
if (!poolStatus) {
|
|
674
|
+
throw new Error(`Unknown agent type: ${agentType}`);
|
|
675
|
+
}
|
|
676
|
+
// Ensure we don't go below minimum
|
|
677
|
+
const currentActive = poolStatus.active + poolStatus.busy;
|
|
678
|
+
const targetCount = Math.max(poolStatus.minSize, currentActive - count);
|
|
679
|
+
const terminateCount = currentActive - targetCount;
|
|
680
|
+
if (terminateCount <= 0) {
|
|
681
|
+
return { type: agentType, terminatedCount: 0, reason: 'minimum-pool-size' };
|
|
682
|
+
}
|
|
683
|
+
// Find idle agents to terminate
|
|
684
|
+
const terminatedAgents = [];
|
|
685
|
+
// In real implementation, query for idle agents and terminate them
|
|
686
|
+
return {
|
|
687
|
+
type: agentType,
|
|
688
|
+
terminatedCount: terminateCount,
|
|
689
|
+
agentIds: terminatedAgents
|
|
690
|
+
};
|
|
691
|
+
}
|
|
692
|
+
startAutoScalingMonitor() {
|
|
693
|
+
this.autoScalingMonitorInterval = setInterval(async () => {
|
|
694
|
+
if (this.status !== types_1.AgentStatus.ACTIVE)
|
|
695
|
+
return;
|
|
696
|
+
const decision = await this.makeScalingDecision();
|
|
697
|
+
if (decision.action !== 'no-action') {
|
|
698
|
+
this.scalingHistory.push(decision);
|
|
699
|
+
await this.scaleAgentPool({
|
|
700
|
+
type: decision.agentType,
|
|
701
|
+
action: decision.action,
|
|
702
|
+
count: Math.abs(decision.targetCount - decision.currentCount)
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
}, this.config.autoScaling?.cooldownPeriod || 60000);
|
|
706
|
+
}
|
|
707
|
+
async makeScalingDecision() {
|
|
708
|
+
const utilization = this.calculateFleetUtilization();
|
|
709
|
+
const scaleUpThreshold = this.config.autoScaling?.scaleUpThreshold || 0.85;
|
|
710
|
+
const scaleDownThreshold = this.config.autoScaling?.scaleDownThreshold || 0.30;
|
|
711
|
+
// Determine which pool needs scaling
|
|
712
|
+
let targetPool = null;
|
|
713
|
+
let maxUtilization = 0;
|
|
714
|
+
for (const [agentType, poolStatus] of this.agentPools.entries()) {
|
|
715
|
+
if (poolStatus.utilization > maxUtilization) {
|
|
716
|
+
maxUtilization = poolStatus.utilization;
|
|
717
|
+
targetPool = agentType;
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
if (!targetPool) {
|
|
721
|
+
return {
|
|
722
|
+
action: 'no-action',
|
|
723
|
+
agentType: '',
|
|
724
|
+
currentCount: 0,
|
|
725
|
+
targetCount: 0,
|
|
726
|
+
reason: 'no-pools-available',
|
|
727
|
+
timestamp: new Date()
|
|
728
|
+
};
|
|
729
|
+
}
|
|
730
|
+
const poolStatus = this.agentPools.get(targetPool);
|
|
731
|
+
const currentCount = poolStatus.active + poolStatus.busy;
|
|
732
|
+
if (utilization > scaleUpThreshold && currentCount < poolStatus.maxSize) {
|
|
733
|
+
return {
|
|
734
|
+
action: 'scale-up',
|
|
735
|
+
agentType: targetPool,
|
|
736
|
+
currentCount,
|
|
737
|
+
targetCount: Math.min(currentCount + 2, poolStatus.maxSize),
|
|
738
|
+
reason: `utilization-high:${utilization.toFixed(2)}`,
|
|
739
|
+
timestamp: new Date()
|
|
740
|
+
};
|
|
741
|
+
}
|
|
742
|
+
else if (utilization < scaleDownThreshold && currentCount > poolStatus.minSize) {
|
|
743
|
+
return {
|
|
744
|
+
action: 'scale-down',
|
|
745
|
+
agentType: targetPool,
|
|
746
|
+
currentCount,
|
|
747
|
+
targetCount: Math.max(currentCount - 1, poolStatus.minSize),
|
|
748
|
+
reason: `utilization-low:${utilization.toFixed(2)}`,
|
|
749
|
+
timestamp: new Date()
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
return {
|
|
753
|
+
action: 'no-action',
|
|
754
|
+
agentType: targetPool,
|
|
755
|
+
currentCount,
|
|
756
|
+
targetCount: currentCount,
|
|
757
|
+
reason: `utilization-optimal:${utilization.toFixed(2)}`,
|
|
758
|
+
timestamp: new Date()
|
|
759
|
+
};
|
|
760
|
+
}
|
|
761
|
+
// ============================================================================
|
|
762
|
+
// Fault Tolerance
|
|
763
|
+
// ============================================================================
|
|
764
|
+
startHeartbeatMonitoring() {
|
|
765
|
+
this.heartbeatMonitorInterval = setInterval(async () => {
|
|
766
|
+
if (this.status !== types_1.AgentStatus.ACTIVE)
|
|
767
|
+
return;
|
|
768
|
+
const now = new Date();
|
|
769
|
+
const timeout = this.config.faultTolerance?.heartbeatTimeout || 15000;
|
|
770
|
+
for (const [agentId, lastHeartbeat] of this.agentHealthChecks.entries()) {
|
|
771
|
+
const elapsed = now.getTime() - lastHeartbeat.getTime();
|
|
772
|
+
if (elapsed > timeout) {
|
|
773
|
+
console.warn(`[FleetCommander] Agent ${agentId} heartbeat timeout`);
|
|
774
|
+
await this.handleAgentFailure(agentId);
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
}, this.config.faultTolerance?.heartbeatInterval || 5000);
|
|
778
|
+
}
|
|
779
|
+
async handleAgentFailure(agentId) {
|
|
780
|
+
console.error(`[FleetCommander] Agent failure detected: ${agentId}`);
|
|
781
|
+
// Update metrics
|
|
782
|
+
this.fleetMetrics.failedAgents++;
|
|
783
|
+
// Attempt recovery
|
|
784
|
+
await this.recoverAgent({ agentId });
|
|
785
|
+
}
|
|
786
|
+
async recoverAgent(payload) {
|
|
787
|
+
const { agentId } = payload;
|
|
788
|
+
console.log(`[FleetCommander] Attempting to recover agent ${agentId}`);
|
|
789
|
+
const agentData = await this.memoryStore.retrieve(`aqe/fleet/agents/${agentId}`);
|
|
790
|
+
if (!agentData) {
|
|
791
|
+
return { agentId, recovered: false, reason: 'agent-not-found' };
|
|
792
|
+
}
|
|
793
|
+
const maxRetries = this.config.faultTolerance?.maxRetries || 3;
|
|
794
|
+
let attempt = 0;
|
|
795
|
+
while (attempt < maxRetries) {
|
|
796
|
+
try {
|
|
797
|
+
// Try to respawn the agent
|
|
798
|
+
const result = await this.spawnAgents({
|
|
799
|
+
type: agentData.type,
|
|
800
|
+
count: 1,
|
|
801
|
+
config: agentData.allocation
|
|
802
|
+
});
|
|
803
|
+
return {
|
|
804
|
+
agentId,
|
|
805
|
+
recovered: true,
|
|
806
|
+
newAgentId: result.agentIds[0],
|
|
807
|
+
attempts: attempt + 1
|
|
808
|
+
};
|
|
809
|
+
}
|
|
810
|
+
catch (error) {
|
|
811
|
+
attempt++;
|
|
812
|
+
console.error(`[FleetCommander] Recovery attempt ${attempt} failed:`, error);
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
return {
|
|
816
|
+
agentId,
|
|
817
|
+
recovered: false,
|
|
818
|
+
reason: 'max-retries-exceeded',
|
|
819
|
+
attempts: maxRetries
|
|
820
|
+
};
|
|
821
|
+
}
|
|
822
|
+
// ============================================================================
|
|
823
|
+
// Task Management
|
|
824
|
+
// ============================================================================
|
|
825
|
+
async handleTaskSubmitted(data) {
|
|
826
|
+
const task = data.task || data;
|
|
827
|
+
this.workloadQueue.push(task);
|
|
828
|
+
// Analyze workload and potentially trigger scaling
|
|
829
|
+
if (this.workloadQueue.length > 10) {
|
|
830
|
+
const decision = await this.makeScalingDecision();
|
|
831
|
+
if (decision.action === 'scale-up') {
|
|
832
|
+
await this.scaleAgentPool({
|
|
833
|
+
type: decision.agentType,
|
|
834
|
+
action: 'scale-up'
|
|
835
|
+
});
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
async handleTaskCompleted(data) {
|
|
840
|
+
// Update metrics
|
|
841
|
+
this.fleetMetrics.totalTasksCompleted++;
|
|
842
|
+
// Remove from queue
|
|
843
|
+
const index = this.workloadQueue.findIndex(t => t.id === data.taskId);
|
|
844
|
+
if (index !== -1) {
|
|
845
|
+
this.workloadQueue.splice(index, 1);
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
// ============================================================================
|
|
849
|
+
// Status & Metrics
|
|
850
|
+
// ============================================================================
|
|
851
|
+
async getFleetStatus() {
|
|
852
|
+
return {
|
|
853
|
+
fleetId: this.agentId.id,
|
|
854
|
+
status: 'operational',
|
|
855
|
+
topology: this.topologyState.mode,
|
|
856
|
+
totalAgents: this.fleetMetrics.totalAgents,
|
|
857
|
+
activeAgents: this.fleetMetrics.activeAgents,
|
|
858
|
+
agentPools: Object.fromEntries(Array.from(this.agentPools.entries()).map(([type, status]) => [
|
|
859
|
+
type,
|
|
860
|
+
{
|
|
861
|
+
active: status.active,
|
|
862
|
+
idle: status.idle,
|
|
863
|
+
busy: status.busy,
|
|
864
|
+
failed: status.failed,
|
|
865
|
+
utilization: `${(status.utilization * 100).toFixed(1)}%`
|
|
866
|
+
}
|
|
867
|
+
])),
|
|
868
|
+
resourceUtilization: {
|
|
869
|
+
cpu: `${(this.fleetMetrics.avgCpuUtilization * 100).toFixed(1)}%`,
|
|
870
|
+
memory: `${(this.fleetMetrics.avgMemoryUtilization * 100).toFixed(1)}%`
|
|
871
|
+
},
|
|
872
|
+
workloadQueue: this.workloadQueue.length,
|
|
873
|
+
activeConflicts: this.activeConflicts.size,
|
|
874
|
+
timestamp: new Date()
|
|
875
|
+
};
|
|
876
|
+
}
|
|
877
|
+
async getFleetMetrics() {
|
|
878
|
+
// Calculate real-time metrics
|
|
879
|
+
this.fleetMetrics.avgCpuUtilization = this.calculateFleetUtilization();
|
|
880
|
+
this.fleetMetrics.avgMemoryUtilization = this.calculateFleetUtilization() * 0.8; // Approximation
|
|
881
|
+
if (this.fleetMetrics.totalTasksCompleted > 0) {
|
|
882
|
+
this.fleetMetrics.throughput = this.fleetMetrics.totalTasksCompleted /
|
|
883
|
+
((Date.now() - this.agentId.created.getTime()) / 3600000); // tasks per hour
|
|
884
|
+
}
|
|
885
|
+
if (this.fleetMetrics.totalTasksCompleted > 0) {
|
|
886
|
+
this.fleetMetrics.failureRate = this.fleetMetrics.failedAgents /
|
|
887
|
+
this.fleetMetrics.totalTasksCompleted;
|
|
888
|
+
}
|
|
889
|
+
// Store metrics
|
|
890
|
+
await this.memoryStore.store('aqe/fleet/metrics/performance', this.fleetMetrics);
|
|
891
|
+
return { ...this.fleetMetrics };
|
|
892
|
+
}
|
|
893
|
+
// ============================================================================
|
|
894
|
+
// Helper Methods
|
|
895
|
+
// ============================================================================
|
|
896
|
+
async requestAgentSpawn(type, priority, config = {}) {
|
|
897
|
+
const agentId = `${type}-${Date.now()}-${Math.random().toString(36).substring(7)}`;
|
|
898
|
+
// Emit spawn request event
|
|
899
|
+
this.emitEvent('agent.spawn-request', {
|
|
900
|
+
agentId,
|
|
901
|
+
type,
|
|
902
|
+
priority,
|
|
903
|
+
config
|
|
904
|
+
}, 'high');
|
|
905
|
+
return agentId;
|
|
906
|
+
}
|
|
907
|
+
/**
|
|
908
|
+
* Get current fleet commander status with detailed metrics
|
|
909
|
+
*/
|
|
910
|
+
async getDetailedStatus() {
|
|
911
|
+
return {
|
|
912
|
+
...this.getStatus(),
|
|
913
|
+
fleetMetrics: await this.getFleetMetrics(),
|
|
914
|
+
topology: this.topologyState,
|
|
915
|
+
agentPools: Object.fromEntries(this.agentPools),
|
|
916
|
+
resourceAllocations: Object.fromEntries(this.resourceAllocations),
|
|
917
|
+
activeConflicts: Object.fromEntries(this.activeConflicts),
|
|
918
|
+
workloadQueueSize: this.workloadQueue.length,
|
|
919
|
+
scalingHistory: this.scalingHistory.slice(-10) // Last 10 scaling decisions
|
|
920
|
+
};
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
exports.FleetCommanderAgent = FleetCommanderAgent;
|
|
924
|
+
//# sourceMappingURL=FleetCommanderAgent.js.map
|