claude-flow-novice 1.6.3 → 1.6.5
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/commands/parse-epic.js +180 -0
- package/.claude/settings.json +12 -2
- package/.claude/settings.local.json +4 -2
- package/.claude-flow-novice/dist/mcp/mcp-server-novice.js +37 -2
- package/.claude-flow-novice/dist/mcp/transports/base.js +5 -0
- package/.claude-flow-novice/dist/mcp/transports/base.js.map +1 -0
- package/.claude-flow-novice/dist/mcp/transports/http.js +414 -0
- package/.claude-flow-novice/dist/mcp/transports/http.js.map +1 -0
- package/.claude-flow-novice/dist/mcp/transports/stdio.js +217 -0
- package/.claude-flow-novice/dist/mcp/transports/stdio.js.map +1 -0
- package/.claude-flow-novice/dist/src/cli/commands/parse-epic.js +129 -0
- package/.claude-flow-novice/dist/src/cli/commands/parse-epic.js.map +1 -0
- package/.claude-flow-novice/dist/src/cli/index.js +3 -0
- package/.claude-flow-novice/dist/src/cli/index.js.map +1 -1
- package/.claude-flow-novice/dist/src/cli/utils/epic-parser.js +266 -0
- package/.claude-flow-novice/dist/src/cli/utils/epic-parser.js.map +1 -0
- package/.claude-flow-novice/dist/src/communication/message-bus.js +105 -2
- package/.claude-flow-novice/dist/src/communication/message-bus.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/adapters/v1-coordinator-adapter.js +1 -1
- package/.claude-flow-novice/dist/src/coordination/adapters/v1-coordinator-adapter.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/cache/artifact-cache-optimizer.js +632 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/cache/artifact-cache-optimizer.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/cache/index.js +11 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/cache/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/checkpoints/checkpoint-compressor.js +318 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/checkpoints/checkpoint-compressor.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/completion-detector.js +234 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/completion-detector.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/hierarchical-detector.js +347 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/hierarchical-detector.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/index.js +13 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/lamport-clock.js +173 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/lamport-clock.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/mesh-detector.js +526 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/mesh-detector.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/sdk-completion-detector.js +443 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/sdk-completion-detector.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/swarm-shutdown.js +366 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/swarm-shutdown.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinator-factory.js +287 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinator-factory.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/cascading-shutdown.example.js +364 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/cascading-shutdown.example.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/cascading-shutdown.js +492 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/cascading-shutdown.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/hierarchical-coordinator.js +786 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/hierarchical-coordinator.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/index.js +16 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/parent-child-manager.js +342 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/parent-child-manager.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/swarm-coordinator-v2.js +601 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/swarm-coordinator-v2.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/agent-state.js +9 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/agent-state.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dead-letter-queue.js +413 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dead-letter-queue.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-graph.js +471 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-graph.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-node.js +379 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-node.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-resolver.js +335 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-resolver.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/help-request-metrics.js +211 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/help-request-metrics.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/index.js +33 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message-broker.js +920 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message-broker.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message-router.js +385 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message-router.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message.js +138 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/resource-manager-safe.js +478 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/resource-manager-safe.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-machine-config.js +358 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-machine-config.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-machine.js +588 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-machine.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-transition.js +153 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-transition.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/task-scheduler.js +360 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/task-scheduler.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/topic-manager.js +337 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/topic-manager.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/deadlock-detector.js +424 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/deadlock-detector.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/index.js +9 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/resource-manager.js +669 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/resource-manager.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/artifact-storage.js +451 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/artifact-storage.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/cycle-detector.js +271 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/cycle-detector.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-graph.js +335 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-graph.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-manager.js +439 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-manager.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-request.js +92 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-request.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/index.js +21 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/topological-sort.js +223 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/topological-sort.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-coordinator.js +436 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-coordinator.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-matcher.js +278 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-matcher.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-request-handler.js +317 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-request-handler.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-request.js +273 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-request.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/index.js +15 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/waiting-agent-pool.js +512 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/waiting-agent-pool.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/index.js +67 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/help-deadlock-integration.js +557 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/help-deadlock-integration.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/index.js +14 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/message-bus-completion-integration.example.js +212 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/message-bus-completion-integration.example.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/message-bus-completion-integration.js +552 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/message-bus-completion-integration.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/state-machine-integration.js +635 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/state-machine-integration.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/IArtifactStorage.js +28 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/IArtifactStorage.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/ICoordinator.js +9 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/ICoordinator.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/ISessionStore.js +25 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/ISessionStore.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/index.js +14 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/artifact-adapter.js +308 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/artifact-adapter.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/completion-storage.js +439 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/completion-storage.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/dependency-graph-storage.js +540 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/dependency-graph-storage.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/dependency-storage.js +367 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/dependency-storage.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/index.js +14 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/message-storage.js +518 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/message-storage.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/state-storage.js +377 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/state-storage.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channel.js +371 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channel.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/dependency-channel.js +355 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/dependency-channel.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/help-channel.js +424 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/help-channel.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/index.js +16 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/state-channel.js +295 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/state-channel.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/task-channel.js +411 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/task-channel.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/index.js +14 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-bus.js +387 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-bus.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-persistence.js +589 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-persistence.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-router.js +444 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-router.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/artifact-storage.js +560 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/artifact-storage.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/background-orchestrator.js +335 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/background-orchestrator.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/bash-output-monitor.js +104 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/bash-output-monitor.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/checkpoint-manager.js +847 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/checkpoint-manager.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/help-coordinator.js +470 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/help-coordinator.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/hierarchical-background-integration.js +450 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/hierarchical-background-integration.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/index.js +13 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/message-bus-integration.js +625 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/message-bus-integration.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/multi-level-control.js +545 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/multi-level-control.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/query-controller.js +740 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/query-controller.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/query-message-integration.js +415 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/query-message-integration.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/session-pool-optimizer.js +615 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/session-pool-optimizer.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/state-machine-integration.js +547 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/state-machine-integration.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/state-sdk-integration.js +342 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/state-sdk-integration.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/security/payload-validator.js +259 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/security/payload-validator.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/framework-registry.js +273 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/framework-registry.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/index.js +8 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/truth-config-manager.js +310 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/truth-config-manager.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/truth-validator.js +218 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/truth-validator.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/types/sdk.js +9 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/types/sdk.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/index.js +6 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/priority-queue.js +145 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/priority-queue.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/sdk-helpers.js +122 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/sdk-helpers.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/config-translator.js +17 -43
- package/.claude-flow-novice/dist/src/coordination/config-translator.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/coordination-toggle.js +34 -76
- package/.claude-flow-novice/dist/src/coordination/coordination-toggle.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/index.js +3 -0
- package/.claude-flow-novice/dist/src/coordination/index.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/shared/core/agent-state.js +172 -0
- package/.claude-flow-novice/dist/src/coordination/shared/core/agent-state.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/shared/core/index.js +7 -0
- package/.claude-flow-novice/dist/src/coordination/shared/core/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/shared/index.js +19 -0
- package/.claude-flow-novice/dist/src/coordination/shared/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/shared/interfaces/ICoordinator.js +24 -0
- package/.claude-flow-novice/dist/src/coordination/shared/interfaces/ICoordinator.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/shared/interfaces/index.js +7 -0
- package/.claude-flow-novice/dist/src/coordination/shared/interfaces/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/shared/message-broker.js +920 -0
- package/.claude-flow-novice/dist/src/coordination/shared/message-broker.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/shared/message.js +138 -0
- package/.claude-flow-novice/dist/src/coordination/shared/message.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/shared/security/payload-validator.js +259 -0
- package/.claude-flow-novice/dist/src/coordination/shared/security/payload-validator.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/shared/transparency/index.js +17 -0
- package/.claude-flow-novice/dist/src/coordination/shared/transparency/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/shared/transparency/interfaces/transparency-system.js +19 -0
- package/.claude-flow-novice/dist/src/coordination/shared/transparency/interfaces/transparency-system.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/shared/transparency/transparency-integration.js +357 -0
- package/.claude-flow-novice/dist/src/coordination/shared/transparency/transparency-integration.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/shared/transparency/transparency-system.js +679 -0
- package/.claude-flow-novice/dist/src/coordination/shared/transparency/transparency-system.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/shared/types/index.js +7 -0
- package/.claude-flow-novice/dist/src/coordination/shared/types/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/shared/types/sdk.js +10 -0
- package/.claude-flow-novice/dist/src/coordination/shared/types/sdk.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v1-transparency/interfaces/v1-transparency-system.js +12 -0
- package/.claude-flow-novice/dist/src/coordination/v1-transparency/interfaces/v1-transparency-system.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v1-transparency/v1-to-v2-bridge.js +433 -0
- package/.claude-flow-novice/dist/src/coordination/v1-transparency/v1-to-v2-bridge.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v1-transparency/v1-transparency-adapter.js +1468 -0
- package/.claude-flow-novice/dist/src/coordination/v1-transparency/v1-transparency-adapter.js.map +1 -0
- package/.claude-flow-novice/dist/src/feature-flags/core/FeatureFlagManager.js +52 -2
- package/.claude-flow-novice/dist/src/feature-flags/core/FeatureFlagManager.js.map +1 -1
- package/.claude-flow-novice/dist/src/mcp/mcp-server-novice.js +37 -2
- package/.claude-flow-novice/dist/src/mcp/session-manager.js +3 -1
- package/.claude-flow-novice/dist/src/mcp/session-manager.js.map +1 -1
- package/.claude-flow-novice/dist/src/monitoring/apm/apm-integration.js +5 -0
- package/.claude-flow-novice/dist/src/monitoring/apm/apm-integration.js.map +1 -1
- package/.claude-flow-novice/dist/src/providers/provider-manager.js +41 -6
- package/.claude-flow-novice/dist/src/providers/provider-manager.js.map +1 -1
- package/.claude-flow-novice/dist/src/providers/tiered-router.js +9 -17
- package/.claude-flow-novice/dist/src/providers/tiered-router.js.map +1 -1
- package/.claude-flow-novice/dist/src/utils/markdown-sanitizer.js +65 -41
- package/.claude-flow-novice/dist/src/utils/markdown-sanitizer.js.map +1 -1
- package/.claude-flow-novice/dist/src/web/api/server.js +1 -1
- package/.claude-flow-novice/dist/src/web/api/server.js.map +1 -1
- package/.claude-flow-novice/dist/src/workflows/progressive-rollout-manager.js +30 -0
- package/.claude-flow-novice/dist/src/workflows/progressive-rollout-manager.js.map +1 -1
- package/.claude-flow-novice/metrics.db +0 -0
- package/.claude-flow-novice/metrics.db-shm +0 -0
- package/.claude-flow-novice/metrics.db-wal +0 -0
- package/CLAUDE.md +72 -0
- package/config/hooks/post-edit-pipeline.js +68 -118
- package/config/hooks/pre-tool-memory-safety.js +209 -0
- package/package.json +7 -4
- package/scripts/cleanup-idle-sessions.sh +59 -0
- package/scripts/monitoring/alert-monitor.sh +220 -0
- package/scripts/monitoring/view-alerts.sh +307 -0
- package/scripts/test-provider-routing.cjs +7 -9
- package/scripts/test-zai-api.cjs +2 -2
- package/src/slash-commands/parse-epic.js +1 -1
- package/wiki/Provider-Routing.md +57 -69
- package/MEMORY_LEAK_ROOT_CAUSE.md +0 -149
|
@@ -0,0 +1,786 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Coordination V2 - Hierarchical Coordinator
|
|
3
|
+
*
|
|
4
|
+
* PM-based hierarchical coordination with multi-level agent hierarchy support.
|
|
5
|
+
* Enables Level 0 coordinator (Claude Code chat) to control all nested levels
|
|
6
|
+
* via pause/inject/resume operations.
|
|
7
|
+
*
|
|
8
|
+
* Features:
|
|
9
|
+
* - Parent-child agent relationship management
|
|
10
|
+
* - Multi-level hierarchy (10+ levels supported)
|
|
11
|
+
* - PM delegates tasks to worker children
|
|
12
|
+
* - Background process orchestration for child agents
|
|
13
|
+
* - Cascading operations (pause, resume, shutdown)
|
|
14
|
+
* - Session forking for parallel worker spawning (<2s for 10 workers)
|
|
15
|
+
*
|
|
16
|
+
* Performance Targets:
|
|
17
|
+
* - Agent spawn time: <2s for 10 hierarchical agents
|
|
18
|
+
* - Parent control latency: <100ms for pause/inject/resume
|
|
19
|
+
* - Nested hierarchy depth: 10+ levels
|
|
20
|
+
* - Checkpoint recovery: <500ms (p99)
|
|
21
|
+
* - Cascading shutdown: <1s for 20 agents
|
|
22
|
+
*
|
|
23
|
+
* @module coordination/v2/coordinators/hierarchical-coordinator
|
|
24
|
+
*/ import { EventEmitter } from 'node:events';
|
|
25
|
+
import { AgentState } from '../../shared/core/agent-state.js';
|
|
26
|
+
import { Logger } from '../../../core/logger.js';
|
|
27
|
+
/**
|
|
28
|
+
* HierarchicalCoordinator
|
|
29
|
+
*
|
|
30
|
+
* Implements PM-based hierarchical coordination pattern:
|
|
31
|
+
* 1. Level 0 coordinator in Claude Code chat (supervisor)
|
|
32
|
+
* 2. Level 1+ agents spawned via background processes
|
|
33
|
+
* 3. PM delegates tasks to worker children
|
|
34
|
+
* 4. Parent can pause/inject/resume any child at any level
|
|
35
|
+
* 5. Cascading operations (pause, resume, shutdown) propagate to descendants
|
|
36
|
+
* 6. Hierarchical completion detection via Phase 4 integration
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const coordinator = new HierarchicalCoordinator(
|
|
41
|
+
* stateMachine,
|
|
42
|
+
* messageBroker,
|
|
43
|
+
* checkpointManager,
|
|
44
|
+
* completionDetector,
|
|
45
|
+
* { swarmId: 'swarm-1', maxDepth: 10 }
|
|
46
|
+
* );
|
|
47
|
+
*
|
|
48
|
+
* await coordinator.initialize();
|
|
49
|
+
*
|
|
50
|
+
* // Spawn root PM
|
|
51
|
+
* const rootPM = await coordinator.spawnProjectManager('pm-root', 0);
|
|
52
|
+
*
|
|
53
|
+
* // Fork worker children from PM
|
|
54
|
+
* const workers = await coordinator.forkWorkers(rootPM.agentId, 5);
|
|
55
|
+
*
|
|
56
|
+
* // Delegate task to worker
|
|
57
|
+
* await coordinator.delegateTask({
|
|
58
|
+
* taskId: 'task-1',
|
|
59
|
+
* description: 'Implement feature X',
|
|
60
|
+
* workerId: workers[0].agentId,
|
|
61
|
+
* pmId: rootPM.agentId,
|
|
62
|
+
* priority: 8
|
|
63
|
+
* });
|
|
64
|
+
* ```
|
|
65
|
+
*/ export class HierarchicalCoordinator extends EventEmitter {
|
|
66
|
+
logger;
|
|
67
|
+
config;
|
|
68
|
+
stateMachine;
|
|
69
|
+
messageBroker;
|
|
70
|
+
checkpointManager;
|
|
71
|
+
completionDetector;
|
|
72
|
+
/** All agents in hierarchy (agentId -> node) */ agents;
|
|
73
|
+
/** Parent-child relationships (childId -> parentId) */ parentRelationships;
|
|
74
|
+
/** Root PM agent ID */ rootPmId;
|
|
75
|
+
/** Performance metrics */ metrics;
|
|
76
|
+
/** Control operation latencies for p99 calculation */ controlLatencies;
|
|
77
|
+
/** Initialized flag */ initialized;
|
|
78
|
+
/** Task subscription for cleanup */ taskSubscription;
|
|
79
|
+
constructor(stateMachine, messageBroker, checkpointManager, completionDetector, config){
|
|
80
|
+
super();
|
|
81
|
+
this.logger = new Logger({
|
|
82
|
+
level: 'info',
|
|
83
|
+
format: 'text',
|
|
84
|
+
destination: 'console'
|
|
85
|
+
});
|
|
86
|
+
this.config = {
|
|
87
|
+
swarmId: config.swarmId,
|
|
88
|
+
maxDepth: config.maxDepth ?? 15,
|
|
89
|
+
maxBranchingFactor: config.maxBranchingFactor ?? 10,
|
|
90
|
+
autoCheckpoint: config.autoCheckpoint ?? true,
|
|
91
|
+
enableBackgroundMonitoring: config.enableBackgroundMonitoring ?? true,
|
|
92
|
+
controlTimeoutMs: config.controlTimeoutMs ?? 5000
|
|
93
|
+
};
|
|
94
|
+
this.stateMachine = stateMachine;
|
|
95
|
+
this.messageBroker = messageBroker;
|
|
96
|
+
this.checkpointManager = checkpointManager;
|
|
97
|
+
this.completionDetector = completionDetector;
|
|
98
|
+
this.agents = new Map();
|
|
99
|
+
this.parentRelationships = new Map();
|
|
100
|
+
this.controlLatencies = [];
|
|
101
|
+
this.initialized = false;
|
|
102
|
+
this.metrics = {
|
|
103
|
+
totalAgentsSpawned: 0,
|
|
104
|
+
totalDelegations: 0,
|
|
105
|
+
totalControlOperations: 0,
|
|
106
|
+
averageControlLatencyMs: 0,
|
|
107
|
+
p99ControlLatencyMs: 0,
|
|
108
|
+
totalCascadingOps: 0,
|
|
109
|
+
averageSpawnTime10Agents: 0,
|
|
110
|
+
checkpointRecoveries: 0,
|
|
111
|
+
averageRecoveryTimeMs: 0
|
|
112
|
+
};
|
|
113
|
+
this.logger.info('HierarchicalCoordinator created', {
|
|
114
|
+
swarmId: this.config.swarmId,
|
|
115
|
+
maxDepth: this.config.maxDepth,
|
|
116
|
+
maxBranchingFactor: this.config.maxBranchingFactor
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Initialize coordinator
|
|
121
|
+
*/ async initialize() {
|
|
122
|
+
if (this.initialized) {
|
|
123
|
+
this.logger.warn('HierarchicalCoordinator already initialized');
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
this.logger.info('Initializing HierarchicalCoordinator', {
|
|
127
|
+
swarmId: this.config.swarmId
|
|
128
|
+
});
|
|
129
|
+
// Subscribe to state machine events
|
|
130
|
+
this.stateMachine.on('state:transition', this.handleStateTransition.bind(this));
|
|
131
|
+
// Subscribe to message broker for task delegation
|
|
132
|
+
this.taskSubscription = await this.messageBroker.subscribe({
|
|
133
|
+
topic: 'task',
|
|
134
|
+
handler: this.handleTaskMessage.bind(this)
|
|
135
|
+
});
|
|
136
|
+
this.initialized = true;
|
|
137
|
+
this.logger.info('HierarchicalCoordinator initialized successfully');
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Spawn Project Manager agent at specified level
|
|
141
|
+
*
|
|
142
|
+
* @param agentId - Unique agent identifier
|
|
143
|
+
* @param level - Hierarchy level (0 = root, 1+ = nested)
|
|
144
|
+
* @param parentId - Parent PM agent ID (undefined for root)
|
|
145
|
+
* @returns Spawned PM agent node
|
|
146
|
+
*/ async spawnProjectManager(agentId, level, parentId) {
|
|
147
|
+
this.validateInitialized();
|
|
148
|
+
this.validateDepth(level);
|
|
149
|
+
const startTime = performance.now();
|
|
150
|
+
// Generate session ID
|
|
151
|
+
const sessionId = `session_${agentId}_${Date.now()}`;
|
|
152
|
+
// Register agent with state machine
|
|
153
|
+
await this.stateMachine.registerAgent(agentId, sessionId, AgentState.IDLE);
|
|
154
|
+
// Create agent node
|
|
155
|
+
const node = {
|
|
156
|
+
agentId,
|
|
157
|
+
type: 'pm',
|
|
158
|
+
state: AgentState.IDLE,
|
|
159
|
+
level,
|
|
160
|
+
parentId,
|
|
161
|
+
childIds: [],
|
|
162
|
+
isProjectManager: true,
|
|
163
|
+
sessionId,
|
|
164
|
+
priority: 10,
|
|
165
|
+
lastUpdated: Date.now(),
|
|
166
|
+
metadata: {
|
|
167
|
+
spawnedAt: new Date(),
|
|
168
|
+
swarmId: this.config.swarmId
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
this.agents.set(agentId, node);
|
|
172
|
+
// Establish parent-child relationship
|
|
173
|
+
if (parentId) {
|
|
174
|
+
this.setParent(agentId, parentId);
|
|
175
|
+
} else {
|
|
176
|
+
// Root PM
|
|
177
|
+
this.rootPmId = agentId;
|
|
178
|
+
}
|
|
179
|
+
this.metrics.totalAgentsSpawned++;
|
|
180
|
+
const spawnLatency = performance.now() - startTime;
|
|
181
|
+
this.logger.info('Project Manager spawned', {
|
|
182
|
+
agentId,
|
|
183
|
+
level,
|
|
184
|
+
parentId,
|
|
185
|
+
sessionId,
|
|
186
|
+
spawnLatencyMs: spawnLatency.toFixed(2)
|
|
187
|
+
});
|
|
188
|
+
this.emit('pm:spawned', {
|
|
189
|
+
agentId,
|
|
190
|
+
level,
|
|
191
|
+
parentId,
|
|
192
|
+
sessionId
|
|
193
|
+
});
|
|
194
|
+
return node;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Fork worker agents from PM session (parallel spawning)
|
|
198
|
+
*
|
|
199
|
+
* @param pmId - Parent PM agent ID
|
|
200
|
+
* @param workerCount - Number of workers to spawn
|
|
201
|
+
* @param workerType - Worker agent type (default: 'worker')
|
|
202
|
+
* @returns Array of spawned worker nodes
|
|
203
|
+
*/ async forkWorkers(pmId, workerCount, workerType = 'worker') {
|
|
204
|
+
this.validateInitialized();
|
|
205
|
+
const pm = this.agents.get(pmId);
|
|
206
|
+
if (!pm) {
|
|
207
|
+
throw new Error(`PM agent ${pmId} not found`);
|
|
208
|
+
}
|
|
209
|
+
if (!pm.isProjectManager) {
|
|
210
|
+
throw new Error(`Agent ${pmId} is not a Project Manager`);
|
|
211
|
+
}
|
|
212
|
+
this.validateBranchingFactor(pm.childIds.length + workerCount);
|
|
213
|
+
this.validateDepth(pm.level + 1);
|
|
214
|
+
const startTime = performance.now();
|
|
215
|
+
// Parallel worker spawning via Promise.all
|
|
216
|
+
const workerPromises = Array.from({
|
|
217
|
+
length: workerCount
|
|
218
|
+
}, async (_, i)=>{
|
|
219
|
+
const workerId = `${pmId}_worker_${i}`;
|
|
220
|
+
const sessionId = `session_${workerId}_${Date.now()}`;
|
|
221
|
+
// Register with state machine
|
|
222
|
+
await this.stateMachine.registerAgent(workerId, sessionId, AgentState.IDLE);
|
|
223
|
+
// Create worker node
|
|
224
|
+
const worker = {
|
|
225
|
+
agentId: workerId,
|
|
226
|
+
type: workerType,
|
|
227
|
+
state: AgentState.IDLE,
|
|
228
|
+
level: pm.level + 1,
|
|
229
|
+
parentId: pmId,
|
|
230
|
+
childIds: [],
|
|
231
|
+
isProjectManager: false,
|
|
232
|
+
sessionId,
|
|
233
|
+
priority: 5,
|
|
234
|
+
lastUpdated: Date.now(),
|
|
235
|
+
metadata: {
|
|
236
|
+
spawnedAt: new Date(),
|
|
237
|
+
swarmId: this.config.swarmId,
|
|
238
|
+
forkIndex: i
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
this.agents.set(workerId, worker);
|
|
242
|
+
this.setParent(workerId, pmId);
|
|
243
|
+
this.metrics.totalAgentsSpawned++;
|
|
244
|
+
return worker;
|
|
245
|
+
});
|
|
246
|
+
const workers = await Promise.all(workerPromises);
|
|
247
|
+
const spawnLatency = performance.now() - startTime;
|
|
248
|
+
// Track 10-agent spawn time for metrics
|
|
249
|
+
if (workerCount === 10) {
|
|
250
|
+
this.metrics.averageSpawnTime10Agents = spawnLatency;
|
|
251
|
+
}
|
|
252
|
+
this.logger.info('Workers forked', {
|
|
253
|
+
pmId,
|
|
254
|
+
workerCount,
|
|
255
|
+
workerType,
|
|
256
|
+
spawnLatencyMs: spawnLatency.toFixed(2),
|
|
257
|
+
target: '2000ms for 10 agents'
|
|
258
|
+
});
|
|
259
|
+
this.emit('workers:forked', {
|
|
260
|
+
pmId,
|
|
261
|
+
workers,
|
|
262
|
+
spawnLatencyMs: spawnLatency
|
|
263
|
+
});
|
|
264
|
+
return workers;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Delegate task from PM to worker
|
|
268
|
+
*
|
|
269
|
+
* @param delegation - Task delegation details
|
|
270
|
+
*/ async delegateTask(delegation) {
|
|
271
|
+
this.validateInitialized();
|
|
272
|
+
const { taskId, workerId, pmId, description, priority } = delegation;
|
|
273
|
+
const pm = this.agents.get(pmId);
|
|
274
|
+
const worker = this.agents.get(workerId);
|
|
275
|
+
if (!pm) {
|
|
276
|
+
throw new Error(`PM agent ${pmId} not found`);
|
|
277
|
+
}
|
|
278
|
+
if (!worker) {
|
|
279
|
+
throw new Error(`Worker agent ${workerId} not found`);
|
|
280
|
+
}
|
|
281
|
+
if (!pm.isProjectManager) {
|
|
282
|
+
throw new Error(`Agent ${pmId} is not a Project Manager`);
|
|
283
|
+
}
|
|
284
|
+
if (worker.parentId !== pmId) {
|
|
285
|
+
throw new Error(`Worker ${workerId} is not a child of PM ${pmId}`);
|
|
286
|
+
}
|
|
287
|
+
const startTime = performance.now();
|
|
288
|
+
// Step 1: Pause worker before injecting task (prevents token waste)
|
|
289
|
+
if (worker.state !== AgentState.PAUSED) {
|
|
290
|
+
await this.pauseChild(pmId, workerId, `Task delegation: ${taskId}`);
|
|
291
|
+
}
|
|
292
|
+
// Step 2: Inject task message into worker session
|
|
293
|
+
await this.messageBroker.publish({
|
|
294
|
+
topic: 'task',
|
|
295
|
+
payload: {
|
|
296
|
+
type: 'task_assignment',
|
|
297
|
+
taskId,
|
|
298
|
+
description,
|
|
299
|
+
priority,
|
|
300
|
+
pmId,
|
|
301
|
+
workerId,
|
|
302
|
+
context: delegation.context,
|
|
303
|
+
deadline: delegation.deadline
|
|
304
|
+
},
|
|
305
|
+
priority,
|
|
306
|
+
senderId: pmId,
|
|
307
|
+
recipientId: workerId
|
|
308
|
+
});
|
|
309
|
+
// Step 3: Transition worker to WORKING state
|
|
310
|
+
await this.stateMachine.transition(workerId, AgentState.WORKING, {
|
|
311
|
+
metadata: {
|
|
312
|
+
taskId,
|
|
313
|
+
pmId,
|
|
314
|
+
taskDescription: description
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
this.metrics.totalDelegations++;
|
|
318
|
+
const delegationLatency = performance.now() - startTime;
|
|
319
|
+
this.logger.info('Task delegated', {
|
|
320
|
+
taskId,
|
|
321
|
+
pmId,
|
|
322
|
+
workerId,
|
|
323
|
+
priority,
|
|
324
|
+
delegationLatencyMs: delegationLatency.toFixed(2)
|
|
325
|
+
});
|
|
326
|
+
this.emit('task:delegated', {
|
|
327
|
+
taskId,
|
|
328
|
+
pmId,
|
|
329
|
+
workerId,
|
|
330
|
+
latencyMs: delegationLatency
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Pause child agent (parent control operation)
|
|
335
|
+
*
|
|
336
|
+
* @param parentId - Parent agent ID
|
|
337
|
+
* @param childId - Child agent ID to pause
|
|
338
|
+
* @param reason - Pause reason
|
|
339
|
+
*/ async pauseChild(parentId, childId, reason) {
|
|
340
|
+
await this.executeParentControl({
|
|
341
|
+
operation: 'pause',
|
|
342
|
+
parentId,
|
|
343
|
+
childId,
|
|
344
|
+
reason
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Resume child agent (parent control operation)
|
|
349
|
+
*
|
|
350
|
+
* @param parentId - Parent agent ID
|
|
351
|
+
* @param childId - Child agent ID to resume
|
|
352
|
+
* @param checkpointId - Optional checkpoint ID to resume from
|
|
353
|
+
* @param reason - Resume reason
|
|
354
|
+
*/ async resumeChild(parentId, childId, checkpointId, reason) {
|
|
355
|
+
await this.executeParentControl({
|
|
356
|
+
operation: 'resume',
|
|
357
|
+
parentId,
|
|
358
|
+
childId,
|
|
359
|
+
checkpointId,
|
|
360
|
+
reason
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Inject message into child session (parent control operation)
|
|
365
|
+
*
|
|
366
|
+
* @param parentId - Parent agent ID
|
|
367
|
+
* @param childId - Child agent ID
|
|
368
|
+
* @param message - Message to inject
|
|
369
|
+
*/ async injectMessageToChild(parentId, childId, message) {
|
|
370
|
+
await this.executeParentControl({
|
|
371
|
+
operation: 'inject',
|
|
372
|
+
parentId,
|
|
373
|
+
childId,
|
|
374
|
+
message
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Execute parent control operation
|
|
379
|
+
*
|
|
380
|
+
* @private
|
|
381
|
+
* @param request - Parent control request
|
|
382
|
+
*/ async executeParentControl(request) {
|
|
383
|
+
this.validateInitialized();
|
|
384
|
+
const { operation, parentId, childId, message, checkpointId, reason } = request;
|
|
385
|
+
const parent = this.agents.get(parentId);
|
|
386
|
+
const child = this.agents.get(childId);
|
|
387
|
+
if (!parent) {
|
|
388
|
+
throw new Error(`Parent agent ${parentId} not found`);
|
|
389
|
+
}
|
|
390
|
+
if (!child) {
|
|
391
|
+
throw new Error(`Child agent ${childId} not found`);
|
|
392
|
+
}
|
|
393
|
+
if (child.parentId !== parentId) {
|
|
394
|
+
throw new Error(`Agent ${childId} is not a child of ${parentId}`);
|
|
395
|
+
}
|
|
396
|
+
const startTime = performance.now();
|
|
397
|
+
try {
|
|
398
|
+
switch(operation){
|
|
399
|
+
case 'pause':
|
|
400
|
+
// Create checkpoint before pausing
|
|
401
|
+
if (this.config.autoCheckpoint) {
|
|
402
|
+
await this.checkpointManager.createCheckpoint(child.sessionId, childId, `control_pause_${Date.now()}`, child.state, {
|
|
403
|
+
currentState: child.state
|
|
404
|
+
}, {
|
|
405
|
+
reason: reason || `Paused by parent ${parentId}`,
|
|
406
|
+
autoCheckpoint: true,
|
|
407
|
+
context: {
|
|
408
|
+
parentId,
|
|
409
|
+
operation
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
// Transition to PAUSED state
|
|
414
|
+
await this.stateMachine.transition(childId, AgentState.PAUSED, {
|
|
415
|
+
metadata: {
|
|
416
|
+
parentId,
|
|
417
|
+
reason,
|
|
418
|
+
operation: 'pause'
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
break;
|
|
422
|
+
case 'resume':
|
|
423
|
+
// Restore from checkpoint if provided
|
|
424
|
+
if (checkpointId) {
|
|
425
|
+
const restoreResult = await this.checkpointManager.restoreCheckpoint(checkpointId);
|
|
426
|
+
if (restoreResult.success) {
|
|
427
|
+
await this.stateMachine.restoreFromCheckpoint(childId, checkpointId);
|
|
428
|
+
this.metrics.checkpointRecoveries++;
|
|
429
|
+
this.metrics.averageRecoveryTimeMs = (this.metrics.averageRecoveryTimeMs * (this.metrics.checkpointRecoveries - 1) + restoreResult.latencyMs) / this.metrics.checkpointRecoveries;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
// Transition to WORKING state
|
|
433
|
+
await this.stateMachine.transition(childId, AgentState.WORKING, {
|
|
434
|
+
metadata: {
|
|
435
|
+
parentId,
|
|
436
|
+
reason,
|
|
437
|
+
operation: 'resume',
|
|
438
|
+
checkpointId
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
break;
|
|
442
|
+
case 'inject':
|
|
443
|
+
// Inject message via message broker
|
|
444
|
+
await this.messageBroker.publish({
|
|
445
|
+
topic: 'control',
|
|
446
|
+
payload: {
|
|
447
|
+
type: 'parent_injection',
|
|
448
|
+
message,
|
|
449
|
+
parentId,
|
|
450
|
+
childId,
|
|
451
|
+
timestamp: Date.now()
|
|
452
|
+
},
|
|
453
|
+
priority: 10,
|
|
454
|
+
senderId: parentId,
|
|
455
|
+
recipientId: childId
|
|
456
|
+
});
|
|
457
|
+
break;
|
|
458
|
+
case 'shutdown':
|
|
459
|
+
// Graceful shutdown: transition to COMPLETED
|
|
460
|
+
await this.stateMachine.transition(childId, AgentState.COMPLETED, {
|
|
461
|
+
metadata: {
|
|
462
|
+
parentId,
|
|
463
|
+
reason: reason || 'Shutdown by parent',
|
|
464
|
+
operation: 'shutdown'
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
break;
|
|
468
|
+
}
|
|
469
|
+
const controlLatency = performance.now() - startTime;
|
|
470
|
+
this.updateControlMetrics(controlLatency);
|
|
471
|
+
this.logger.info('Parent control operation completed', {
|
|
472
|
+
operation,
|
|
473
|
+
parentId,
|
|
474
|
+
childId,
|
|
475
|
+
latencyMs: controlLatency.toFixed(2),
|
|
476
|
+
target: '100ms'
|
|
477
|
+
});
|
|
478
|
+
this.emit('parent:control', {
|
|
479
|
+
operation,
|
|
480
|
+
parentId,
|
|
481
|
+
childId,
|
|
482
|
+
latencyMs: controlLatency,
|
|
483
|
+
success: true
|
|
484
|
+
});
|
|
485
|
+
} catch (error) {
|
|
486
|
+
const controlLatency = performance.now() - startTime;
|
|
487
|
+
this.logger.error('Parent control operation failed', {
|
|
488
|
+
operation,
|
|
489
|
+
parentId,
|
|
490
|
+
childId,
|
|
491
|
+
error: error instanceof Error ? error.message : String(error)
|
|
492
|
+
});
|
|
493
|
+
this.emit('parent:control', {
|
|
494
|
+
operation,
|
|
495
|
+
parentId,
|
|
496
|
+
childId,
|
|
497
|
+
latencyMs: controlLatency,
|
|
498
|
+
success: false,
|
|
499
|
+
error: error instanceof Error ? error.message : String(error)
|
|
500
|
+
});
|
|
501
|
+
throw error;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* Cascade control operation to all descendants
|
|
506
|
+
*
|
|
507
|
+
* @param agentId - Root agent ID
|
|
508
|
+
* @param operation - Control operation to cascade
|
|
509
|
+
*/ async cascadeControl(agentId, operation) {
|
|
510
|
+
this.validateInitialized();
|
|
511
|
+
const agent = this.agents.get(agentId);
|
|
512
|
+
if (!agent) {
|
|
513
|
+
throw new Error(`Agent ${agentId} not found`);
|
|
514
|
+
}
|
|
515
|
+
const startTime = performance.now();
|
|
516
|
+
// Get all descendants (DFS traversal)
|
|
517
|
+
const descendants = this.getAllDescendants(agentId);
|
|
518
|
+
this.logger.info('Cascading control operation', {
|
|
519
|
+
operation,
|
|
520
|
+
rootAgentId: agentId,
|
|
521
|
+
descendantCount: descendants.length
|
|
522
|
+
});
|
|
523
|
+
// Execute operation on all descendants in parallel
|
|
524
|
+
const operationPromises = descendants.map(async (descendant)=>{
|
|
525
|
+
const parent = this.agents.get(descendant.parentId);
|
|
526
|
+
if (!parent) return;
|
|
527
|
+
try {
|
|
528
|
+
await this.executeParentControl({
|
|
529
|
+
operation,
|
|
530
|
+
parentId: descendant.parentId,
|
|
531
|
+
childId: descendant.agentId,
|
|
532
|
+
reason: `Cascaded from ${agentId}`
|
|
533
|
+
});
|
|
534
|
+
} catch (error) {
|
|
535
|
+
this.logger.error('Cascading operation failed for descendant', {
|
|
536
|
+
descendantId: descendant.agentId,
|
|
537
|
+
error: error instanceof Error ? error.message : String(error)
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
});
|
|
541
|
+
await Promise.all(operationPromises);
|
|
542
|
+
this.metrics.totalCascadingOps++;
|
|
543
|
+
const cascadeLatency = performance.now() - startTime;
|
|
544
|
+
this.logger.info('Cascading operation completed', {
|
|
545
|
+
operation,
|
|
546
|
+
rootAgentId: agentId,
|
|
547
|
+
descendantCount: descendants.length,
|
|
548
|
+
cascadeLatencyMs: cascadeLatency.toFixed(2),
|
|
549
|
+
target: operation === 'shutdown' ? '1000ms for 20 agents' : 'N/A'
|
|
550
|
+
});
|
|
551
|
+
this.emit('cascade:completed', {
|
|
552
|
+
operation,
|
|
553
|
+
rootAgentId: agentId,
|
|
554
|
+
descendantCount: descendants.length,
|
|
555
|
+
latencyMs: cascadeLatency
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* Get all descendants of an agent (DFS traversal)
|
|
560
|
+
*
|
|
561
|
+
* @param agentId - Root agent ID
|
|
562
|
+
* @returns Array of descendant nodes
|
|
563
|
+
*/ getAllDescendants(agentId) {
|
|
564
|
+
const descendants = [];
|
|
565
|
+
const visited = new Set();
|
|
566
|
+
const dfs = (currentId)=>{
|
|
567
|
+
const agent = this.agents.get(currentId);
|
|
568
|
+
if (!agent || visited.has(currentId)) return;
|
|
569
|
+
visited.add(currentId);
|
|
570
|
+
for (const childId of agent.childIds){
|
|
571
|
+
const child = this.agents.get(childId);
|
|
572
|
+
if (child) {
|
|
573
|
+
descendants.push(child);
|
|
574
|
+
dfs(childId); // Recursive DFS
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
};
|
|
578
|
+
dfs(agentId);
|
|
579
|
+
return descendants;
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* Set parent-child relationship
|
|
583
|
+
*
|
|
584
|
+
* @private
|
|
585
|
+
* @param childId - Child agent ID
|
|
586
|
+
* @param parentId - Parent agent ID
|
|
587
|
+
*/ setParent(childId, parentId) {
|
|
588
|
+
const parent = this.agents.get(parentId);
|
|
589
|
+
const child = this.agents.get(childId);
|
|
590
|
+
if (!parent) {
|
|
591
|
+
throw new Error(`Parent agent ${parentId} not found`);
|
|
592
|
+
}
|
|
593
|
+
if (!child) {
|
|
594
|
+
throw new Error(`Child agent ${childId} not found`);
|
|
595
|
+
}
|
|
596
|
+
// Update parent's child list
|
|
597
|
+
if (!parent.childIds.includes(childId)) {
|
|
598
|
+
parent.childIds.push(childId);
|
|
599
|
+
}
|
|
600
|
+
// Update child's parent reference
|
|
601
|
+
child.parentId = parentId;
|
|
602
|
+
// Track in parent relationships map
|
|
603
|
+
this.parentRelationships.set(childId, parentId);
|
|
604
|
+
this.logger.debug('Parent-child relationship established', {
|
|
605
|
+
parentId,
|
|
606
|
+
childId,
|
|
607
|
+
parentLevel: parent.level,
|
|
608
|
+
childLevel: child.level
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* Get hierarchy statistics
|
|
613
|
+
*/ getStatistics() {
|
|
614
|
+
const allAgents = Array.from(this.agents.values());
|
|
615
|
+
const pmCount = allAgents.filter((a)=>a.isProjectManager).length;
|
|
616
|
+
const workerCount = allAgents.length - pmCount;
|
|
617
|
+
const depths = allAgents.map((a)=>a.level);
|
|
618
|
+
const maxDepth = depths.length > 0 ? Math.max(...depths) : 0;
|
|
619
|
+
const branchingFactors = allAgents.filter((a)=>a.isProjectManager).map((a)=>a.childIds.length);
|
|
620
|
+
const averageBranchingFactor = branchingFactors.length > 0 ? branchingFactors.reduce((sum, f)=>sum + f, 0) / branchingFactors.length : 0;
|
|
621
|
+
const activeAgents = allAgents.filter((a)=>a.state !== AgentState.PAUSED && a.state !== AgentState.COMPLETED).length;
|
|
622
|
+
const pausedAgents = allAgents.filter((a)=>a.state === AgentState.PAUSED).length;
|
|
623
|
+
const completedAgents = allAgents.filter((a)=>a.state === AgentState.COMPLETED).length;
|
|
624
|
+
return {
|
|
625
|
+
totalAgents: allAgents.length,
|
|
626
|
+
pmCount,
|
|
627
|
+
workerCount,
|
|
628
|
+
maxDepth,
|
|
629
|
+
averageBranchingFactor,
|
|
630
|
+
activeAgents,
|
|
631
|
+
pausedAgents,
|
|
632
|
+
completedAgents
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* Get coordinator metrics
|
|
637
|
+
*/ getMetrics() {
|
|
638
|
+
return {
|
|
639
|
+
...this.metrics
|
|
640
|
+
};
|
|
641
|
+
}
|
|
642
|
+
/**
|
|
643
|
+
* Get agent node by ID
|
|
644
|
+
*/ getAgent(agentId) {
|
|
645
|
+
return this.agents.get(agentId);
|
|
646
|
+
}
|
|
647
|
+
/**
|
|
648
|
+
* Get all agents in hierarchy
|
|
649
|
+
*/ getAllAgents() {
|
|
650
|
+
return Array.from(this.agents.values());
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Get root PM agent
|
|
654
|
+
*/ getRootPM() {
|
|
655
|
+
return this.rootPmId ? this.agents.get(this.rootPmId) : undefined;
|
|
656
|
+
}
|
|
657
|
+
/**
|
|
658
|
+
* Get children of an agent
|
|
659
|
+
*/ getChildren(agentId) {
|
|
660
|
+
const agent = this.agents.get(agentId);
|
|
661
|
+
if (!agent) return [];
|
|
662
|
+
return agent.childIds.map((id)=>this.agents.get(id)).filter((a)=>a !== undefined);
|
|
663
|
+
}
|
|
664
|
+
/**
|
|
665
|
+
* Handle state transition events from state machine
|
|
666
|
+
*
|
|
667
|
+
* @private
|
|
668
|
+
*/ handleStateTransition(event) {
|
|
669
|
+
const { agentId, toState } = event;
|
|
670
|
+
const agent = this.agents.get(agentId);
|
|
671
|
+
if (!agent) return;
|
|
672
|
+
// Update agent state
|
|
673
|
+
agent.state = toState;
|
|
674
|
+
agent.lastUpdated = Date.now();
|
|
675
|
+
this.logger.debug('Agent state updated', {
|
|
676
|
+
agentId,
|
|
677
|
+
newState: toState,
|
|
678
|
+
level: agent.level,
|
|
679
|
+
isProjectManager: agent.isProjectManager
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
683
|
+
* Handle task messages from message broker
|
|
684
|
+
*
|
|
685
|
+
* @private
|
|
686
|
+
*/ async handleTaskMessage(message) {
|
|
687
|
+
const { type, taskId, workerId } = message.payload;
|
|
688
|
+
if (type === 'task_completion') {
|
|
689
|
+
this.logger.info('Task completed', {
|
|
690
|
+
taskId,
|
|
691
|
+
workerId
|
|
692
|
+
});
|
|
693
|
+
// Transition worker to IDLE after task completion
|
|
694
|
+
const worker = this.agents.get(workerId);
|
|
695
|
+
if (worker && worker.state === AgentState.WORKING) {
|
|
696
|
+
await this.stateMachine.transition(workerId, AgentState.IDLE, {
|
|
697
|
+
metadata: {
|
|
698
|
+
taskId,
|
|
699
|
+
reason: 'Task completed'
|
|
700
|
+
}
|
|
701
|
+
});
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
/**
|
|
706
|
+
* Update control operation metrics
|
|
707
|
+
*
|
|
708
|
+
* @private
|
|
709
|
+
*/ updateControlMetrics(latencyMs) {
|
|
710
|
+
this.metrics.totalControlOperations++;
|
|
711
|
+
this.controlLatencies.push(latencyMs);
|
|
712
|
+
// Keep only recent 100 samples for rolling statistics
|
|
713
|
+
if (this.controlLatencies.length > 100) {
|
|
714
|
+
this.controlLatencies = this.controlLatencies.slice(-100);
|
|
715
|
+
}
|
|
716
|
+
// Update average
|
|
717
|
+
this.metrics.averageControlLatencyMs = (this.metrics.averageControlLatencyMs * (this.metrics.totalControlOperations - 1) + latencyMs) / this.metrics.totalControlOperations;
|
|
718
|
+
// Update p99
|
|
719
|
+
if (this.controlLatencies.length > 0) {
|
|
720
|
+
const sorted = [
|
|
721
|
+
...this.controlLatencies
|
|
722
|
+
].sort((a, b)=>a - b);
|
|
723
|
+
const p99Index = Math.floor(sorted.length * 0.99);
|
|
724
|
+
this.metrics.p99ControlLatencyMs = sorted[p99Index] || sorted[sorted.length - 1];
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
/**
|
|
728
|
+
* Validate coordinator is initialized
|
|
729
|
+
*
|
|
730
|
+
* @private
|
|
731
|
+
*/ validateInitialized() {
|
|
732
|
+
if (!this.initialized) {
|
|
733
|
+
throw new Error('HierarchicalCoordinator not initialized. Call initialize() first.');
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
/**
|
|
737
|
+
* Validate hierarchy depth
|
|
738
|
+
*
|
|
739
|
+
* @private
|
|
740
|
+
*/ validateDepth(level) {
|
|
741
|
+
if (level > this.config.maxDepth) {
|
|
742
|
+
throw new Error(`Hierarchy depth ${level} exceeds maximum ${this.config.maxDepth}`);
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
/**
|
|
746
|
+
* Validate branching factor
|
|
747
|
+
*
|
|
748
|
+
* @private
|
|
749
|
+
*/ validateBranchingFactor(childCount) {
|
|
750
|
+
if (childCount > this.config.maxBranchingFactor) {
|
|
751
|
+
throw new Error(`Branching factor ${childCount} exceeds maximum ${this.config.maxBranchingFactor}`);
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
/**
|
|
755
|
+
* Cleanup coordinator and release resources
|
|
756
|
+
*/ async cleanup() {
|
|
757
|
+
this.logger.info('Cleaning up HierarchicalCoordinator', {
|
|
758
|
+
swarmId: this.config.swarmId,
|
|
759
|
+
totalAgents: this.agents.size
|
|
760
|
+
});
|
|
761
|
+
// Cascading shutdown from root PM
|
|
762
|
+
if (this.rootPmId) {
|
|
763
|
+
try {
|
|
764
|
+
await this.cascadeControl(this.rootPmId, 'shutdown');
|
|
765
|
+
} catch (error) {
|
|
766
|
+
this.logger.error('Cascading shutdown failed', {
|
|
767
|
+
error: error instanceof Error ? error.message : String(error)
|
|
768
|
+
});
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
// Unsubscribe from message broker
|
|
772
|
+
if (this.taskSubscription) {
|
|
773
|
+
this.taskSubscription.unsubscribe();
|
|
774
|
+
this.taskSubscription = undefined;
|
|
775
|
+
}
|
|
776
|
+
// Clear state
|
|
777
|
+
this.agents.clear();
|
|
778
|
+
this.parentRelationships.clear();
|
|
779
|
+
this.controlLatencies = [];
|
|
780
|
+
this.initialized = false;
|
|
781
|
+
this.removeAllListeners();
|
|
782
|
+
this.logger.info('HierarchicalCoordinator cleaned up successfully');
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
//# sourceMappingURL=hierarchical-coordinator.js.map
|