claude-flow-novice 1.6.4 → 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.local.json +2 -1
- 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/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/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/providers/provider-manager.js +36 -3
- package/.claude-flow-novice/dist/src/providers/provider-manager.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-shm +0 -0
- package/.claude-flow-novice/metrics.db-wal +0 -0
- package/package.json +2 -2
- package/scripts/monitoring/alert-monitor.sh +220 -0
- package/scripts/monitoring/view-alerts.sh +307 -0
- package/scripts/test-zai-api.cjs +2 -2
- package/src/slash-commands/parse-epic.js +1 -1
|
@@ -0,0 +1,740 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Coordination V2 - QueryController
|
|
3
|
+
*
|
|
4
|
+
* Implements zero-cost agent pausing, resume-from-checkpoint, and dynamic resource allocation.
|
|
5
|
+
*
|
|
6
|
+
* @module coordination/v2/sdk/query-controller
|
|
7
|
+
*/ import { EventEmitter } from 'node:events';
|
|
8
|
+
import { Logger } from '../../../core/logger.js';
|
|
9
|
+
import { generateId } from '../../../utils/helpers.js';
|
|
10
|
+
import { HelpCoordinator } from '../help-system/help-coordinator.js';
|
|
11
|
+
import { AgentState as AgentStateEnum } from '../../shared/core/agent-state.js';
|
|
12
|
+
/**
|
|
13
|
+
* QueryController - Manages agent lifecycle with zero-cost pause/resume
|
|
14
|
+
*
|
|
15
|
+
* Features:
|
|
16
|
+
* - Pause agents mid-execution with zero token cost
|
|
17
|
+
* - Resume from exact message UUID checkpoint
|
|
18
|
+
* - Dynamic resource allocation (pause low-priority agents)
|
|
19
|
+
* - Event-driven resume triggers
|
|
20
|
+
* - Idle agent token consumption = 0
|
|
21
|
+
*/ export class QueryController extends EventEmitter {
|
|
22
|
+
logger;
|
|
23
|
+
config;
|
|
24
|
+
sessions;
|
|
25
|
+
checkpoints;
|
|
26
|
+
resourceAllocations;
|
|
27
|
+
metrics;
|
|
28
|
+
agents;
|
|
29
|
+
coordinatorMetrics;
|
|
30
|
+
ready;
|
|
31
|
+
startTime;
|
|
32
|
+
/** Help coordinator for agent helper registration */ helpCoordinator;
|
|
33
|
+
constructor(config = {}){
|
|
34
|
+
super();
|
|
35
|
+
this.logger = new Logger({
|
|
36
|
+
level: 'info',
|
|
37
|
+
format: 'text',
|
|
38
|
+
destination: 'console'
|
|
39
|
+
});
|
|
40
|
+
this.config = {
|
|
41
|
+
maxConcurrentAgents: config.maxConcurrentAgents ?? 10,
|
|
42
|
+
defaultTokenBudget: config.defaultTokenBudget ?? 10000,
|
|
43
|
+
pauseTimeoutMs: config.pauseTimeoutMs ?? 5000,
|
|
44
|
+
resumeTimeoutMs: config.resumeTimeoutMs ?? 5000,
|
|
45
|
+
enableDynamicAllocation: config.enableDynamicAllocation ?? true
|
|
46
|
+
};
|
|
47
|
+
this.sessions = new Map();
|
|
48
|
+
this.checkpoints = new Map();
|
|
49
|
+
this.resourceAllocations = new Map();
|
|
50
|
+
this.metrics = this.initializeMetrics();
|
|
51
|
+
this.agents = new Map();
|
|
52
|
+
this.coordinatorMetrics = this.initializeCoordinatorMetrics();
|
|
53
|
+
this.ready = false;
|
|
54
|
+
this.startTime = Date.now();
|
|
55
|
+
// Initialize help coordinator for agent helper registration
|
|
56
|
+
this.helpCoordinator = new HelpCoordinator();
|
|
57
|
+
this.logger.info('QueryController initialized', {
|
|
58
|
+
maxConcurrentAgents: this.config.maxConcurrentAgents,
|
|
59
|
+
enableDynamicAllocation: this.config.enableDynamicAllocation
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Register agent session for query control
|
|
64
|
+
*/ registerSession(agentId, sessionId, priority = 5) {
|
|
65
|
+
const session = {
|
|
66
|
+
sessionId,
|
|
67
|
+
agentId,
|
|
68
|
+
state: 'idle',
|
|
69
|
+
isPaused: false,
|
|
70
|
+
checkpoints: [],
|
|
71
|
+
priority,
|
|
72
|
+
metadata: {}
|
|
73
|
+
};
|
|
74
|
+
this.sessions.set(sessionId, session);
|
|
75
|
+
this.checkpoints.set(sessionId, []);
|
|
76
|
+
this.resourceAllocations.set(agentId, {
|
|
77
|
+
agentId,
|
|
78
|
+
priority,
|
|
79
|
+
tokenBudget: this.config.defaultTokenBudget,
|
|
80
|
+
currentUsage: 0,
|
|
81
|
+
paused: false
|
|
82
|
+
});
|
|
83
|
+
// Also create agent entry for ICoordinator compatibility
|
|
84
|
+
const agent = {
|
|
85
|
+
agentId,
|
|
86
|
+
sessionId,
|
|
87
|
+
type: 'unknown',
|
|
88
|
+
state: 'idle',
|
|
89
|
+
isPaused: false,
|
|
90
|
+
priority,
|
|
91
|
+
session,
|
|
92
|
+
metadata: {}
|
|
93
|
+
};
|
|
94
|
+
this.agents.set(agentId, agent);
|
|
95
|
+
this.logger.debug('Session registered', {
|
|
96
|
+
agentId,
|
|
97
|
+
sessionId,
|
|
98
|
+
priority
|
|
99
|
+
});
|
|
100
|
+
return session;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Interrupt agent mid-execution (zero token cost)
|
|
104
|
+
* Pauses agent and creates checkpoint for resumption
|
|
105
|
+
*/ async interrupt(sessionId, reason = 'Manual interrupt') {
|
|
106
|
+
const startTime = Date.now();
|
|
107
|
+
const session = this.sessions.get(sessionId);
|
|
108
|
+
if (!session) {
|
|
109
|
+
throw new Error(`Session ${sessionId} not found`);
|
|
110
|
+
}
|
|
111
|
+
if (session.isPaused) {
|
|
112
|
+
this.logger.warn('Session already paused', {
|
|
113
|
+
sessionId
|
|
114
|
+
});
|
|
115
|
+
return {
|
|
116
|
+
success: false,
|
|
117
|
+
sessionId,
|
|
118
|
+
agentId: session.agentId,
|
|
119
|
+
pausedAt: new Date(),
|
|
120
|
+
checkpoint: session.checkpoints[session.checkpoints.length - 1],
|
|
121
|
+
latencyMs: Date.now() - startTime
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
// Create checkpoint at current message UUID
|
|
125
|
+
const checkpoint = {
|
|
126
|
+
id: generateId('checkpoint'),
|
|
127
|
+
sessionId,
|
|
128
|
+
agentId: session.agentId,
|
|
129
|
+
messageUUID: session.currentMessageUUID ?? generateId('msg'),
|
|
130
|
+
state: session.state,
|
|
131
|
+
timestamp: new Date(),
|
|
132
|
+
metadata: {
|
|
133
|
+
reason,
|
|
134
|
+
autoCheckpoint: false,
|
|
135
|
+
context: {
|
|
136
|
+
...session.metadata
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
// Update session state
|
|
141
|
+
session.isPaused = true;
|
|
142
|
+
session.checkpoints.push(checkpoint);
|
|
143
|
+
// Store checkpoint
|
|
144
|
+
const checkpointList = this.checkpoints.get(sessionId) ?? [];
|
|
145
|
+
checkpointList.push(checkpoint);
|
|
146
|
+
this.checkpoints.set(sessionId, checkpointList);
|
|
147
|
+
// Update resource allocation
|
|
148
|
+
const allocation = this.resourceAllocations.get(session.agentId);
|
|
149
|
+
if (allocation) {
|
|
150
|
+
allocation.paused = true;
|
|
151
|
+
}
|
|
152
|
+
// Update agent isPaused state for ICoordinator compatibility
|
|
153
|
+
const agent = this.agents.get(session.agentId);
|
|
154
|
+
if (agent) {
|
|
155
|
+
agent.isPaused = true;
|
|
156
|
+
}
|
|
157
|
+
const latencyMs = Math.max(Date.now() - startTime, 0.001); // Ensure non-zero for metrics
|
|
158
|
+
// Update metrics
|
|
159
|
+
this.metrics.totalPauses++;
|
|
160
|
+
this.metrics.averagePauseLatencyMs = (this.metrics.averagePauseLatencyMs * (this.metrics.totalPauses - 1) + latencyMs) / this.metrics.totalPauses;
|
|
161
|
+
this.metrics.idleAgents++;
|
|
162
|
+
const result = {
|
|
163
|
+
success: true,
|
|
164
|
+
sessionId,
|
|
165
|
+
agentId: session.agentId,
|
|
166
|
+
pausedAt: checkpoint.timestamp,
|
|
167
|
+
checkpoint,
|
|
168
|
+
latencyMs
|
|
169
|
+
};
|
|
170
|
+
this.logger.info('Agent paused', {
|
|
171
|
+
agentId: session.agentId,
|
|
172
|
+
sessionId,
|
|
173
|
+
latencyMs,
|
|
174
|
+
checkpointId: checkpoint.id
|
|
175
|
+
});
|
|
176
|
+
this.emit('agent:paused', result);
|
|
177
|
+
return result;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Resume agent from exact checkpoint
|
|
181
|
+
* Restores agent state from messageUUID with <50ms latency
|
|
182
|
+
*/ async resumeSessionAt(sessionId, messageUUID, reason = 'Manual resume') {
|
|
183
|
+
const startTime = Date.now();
|
|
184
|
+
const session = this.sessions.get(sessionId);
|
|
185
|
+
if (!session) {
|
|
186
|
+
throw new Error(`Session ${sessionId} not found`);
|
|
187
|
+
}
|
|
188
|
+
if (!session.isPaused) {
|
|
189
|
+
this.logger.warn('Session not paused', {
|
|
190
|
+
sessionId
|
|
191
|
+
});
|
|
192
|
+
return {
|
|
193
|
+
success: false,
|
|
194
|
+
sessionId,
|
|
195
|
+
agentId: session.agentId,
|
|
196
|
+
resumedAt: new Date(),
|
|
197
|
+
latencyMs: Date.now() - startTime
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
// Find checkpoint to resume from
|
|
201
|
+
let checkpoint;
|
|
202
|
+
if (messageUUID) {
|
|
203
|
+
checkpoint = session.checkpoints.find((cp)=>cp.messageUUID === messageUUID);
|
|
204
|
+
if (!checkpoint) {
|
|
205
|
+
throw new Error(`Checkpoint with messageUUID ${messageUUID} not found`);
|
|
206
|
+
}
|
|
207
|
+
} else {
|
|
208
|
+
// Use latest checkpoint
|
|
209
|
+
checkpoint = session.checkpoints[session.checkpoints.length - 1];
|
|
210
|
+
}
|
|
211
|
+
// Restore session state from checkpoint
|
|
212
|
+
session.isPaused = false;
|
|
213
|
+
session.state = checkpoint.state;
|
|
214
|
+
session.currentMessageUUID = checkpoint.messageUUID;
|
|
215
|
+
session.metadata = {
|
|
216
|
+
...checkpoint.metadata.context
|
|
217
|
+
};
|
|
218
|
+
// Update resource allocation
|
|
219
|
+
const allocation = this.resourceAllocations.get(session.agentId);
|
|
220
|
+
if (allocation) {
|
|
221
|
+
allocation.paused = false;
|
|
222
|
+
}
|
|
223
|
+
// Update agent isPaused state for ICoordinator compatibility
|
|
224
|
+
const agent = this.agents.get(session.agentId);
|
|
225
|
+
if (agent) {
|
|
226
|
+
agent.isPaused = false;
|
|
227
|
+
}
|
|
228
|
+
const latencyMs = Math.max(Date.now() - startTime, 0.001); // Ensure non-zero for metrics
|
|
229
|
+
// Update metrics
|
|
230
|
+
this.metrics.totalResumes++;
|
|
231
|
+
this.metrics.averageResumeLatencyMs = (this.metrics.averageResumeLatencyMs * (this.metrics.totalResumes - 1) + latencyMs) / this.metrics.totalResumes;
|
|
232
|
+
this.metrics.idleAgents = Math.max(0, this.metrics.idleAgents - 1);
|
|
233
|
+
const result = {
|
|
234
|
+
success: true,
|
|
235
|
+
sessionId,
|
|
236
|
+
agentId: session.agentId,
|
|
237
|
+
resumedAt: new Date(),
|
|
238
|
+
resumedFromCheckpoint: checkpoint,
|
|
239
|
+
latencyMs
|
|
240
|
+
};
|
|
241
|
+
this.logger.info('Agent resumed', {
|
|
242
|
+
agentId: session.agentId,
|
|
243
|
+
sessionId,
|
|
244
|
+
latencyMs,
|
|
245
|
+
checkpointId: checkpoint.id,
|
|
246
|
+
messageUUID: checkpoint.messageUUID
|
|
247
|
+
});
|
|
248
|
+
this.emit('agent:resumed', result);
|
|
249
|
+
return result;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Dynamic resource allocation - pause low-priority agents
|
|
253
|
+
* Frees up resources for high-priority agents
|
|
254
|
+
*/ async pauseLowPriorityAgents(priorityThreshold) {
|
|
255
|
+
const results = [];
|
|
256
|
+
for (const [sessionId, session] of this.sessions.entries()){
|
|
257
|
+
if (session.priority < priorityThreshold && !session.isPaused) {
|
|
258
|
+
try {
|
|
259
|
+
const result = await this.interrupt(sessionId, `Dynamic allocation: priority ${session.priority} < threshold ${priorityThreshold}`);
|
|
260
|
+
results.push(result);
|
|
261
|
+
// Estimate token savings
|
|
262
|
+
const allocation = this.resourceAllocations.get(session.agentId);
|
|
263
|
+
if (allocation) {
|
|
264
|
+
this.metrics.tokensSaved += allocation.tokenBudget - allocation.currentUsage;
|
|
265
|
+
}
|
|
266
|
+
} catch (error) {
|
|
267
|
+
this.logger.error('Failed to pause low-priority agent', {
|
|
268
|
+
sessionId,
|
|
269
|
+
error: error instanceof Error ? error.message : String(error)
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
this.logger.info('Dynamic allocation completed', {
|
|
275
|
+
agentsPaused: results.length,
|
|
276
|
+
priorityThreshold,
|
|
277
|
+
tokensSaved: this.metrics.tokensSaved
|
|
278
|
+
});
|
|
279
|
+
return results;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Event-driven resume trigger
|
|
283
|
+
* Resumes agents based on external events (dependency resolution, help requests, etc.)
|
|
284
|
+
*/ async handleResumeTrigger(trigger) {
|
|
285
|
+
this.logger.debug('Resume trigger received', trigger);
|
|
286
|
+
// Find paused agent by ID
|
|
287
|
+
let targetSession;
|
|
288
|
+
for (const session of this.sessions.values()){
|
|
289
|
+
if (session.agentId === trigger.agentId && session.isPaused) {
|
|
290
|
+
targetSession = session;
|
|
291
|
+
break;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
if (!targetSession) {
|
|
295
|
+
this.logger.warn('No paused session found for trigger', {
|
|
296
|
+
agentId: trigger.agentId,
|
|
297
|
+
triggerType: trigger.type
|
|
298
|
+
});
|
|
299
|
+
return null;
|
|
300
|
+
}
|
|
301
|
+
const reason = `Event trigger: ${trigger.type}`;
|
|
302
|
+
const result = await this.resumeSessionAt(targetSession.sessionId, undefined, reason);
|
|
303
|
+
this.emit('resume:triggered', {
|
|
304
|
+
trigger,
|
|
305
|
+
result
|
|
306
|
+
});
|
|
307
|
+
return result;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Get query control metrics (legacy method)
|
|
311
|
+
*/ getQueryControlMetrics() {
|
|
312
|
+
return {
|
|
313
|
+
...this.metrics
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Get all paused sessions (legacy method)
|
|
318
|
+
*/ getPausedSessions() {
|
|
319
|
+
return Array.from(this.sessions.values()).filter((s)=>s.isPaused);
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Get active sessions (legacy method)
|
|
323
|
+
*/ getActiveSessions() {
|
|
324
|
+
return Array.from(this.sessions.values()).filter((s)=>!s.isPaused);
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Check if agent is paused
|
|
328
|
+
*/ isPaused(sessionId) {
|
|
329
|
+
const session = this.sessions.get(sessionId);
|
|
330
|
+
return session?.isPaused ?? false;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Get checkpoint history for session
|
|
334
|
+
*/ getCheckpoints(sessionId) {
|
|
335
|
+
return this.checkpoints.get(sessionId) ?? [];
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Get resource allocation for agent
|
|
339
|
+
*/ getResourceAllocation(agentId) {
|
|
340
|
+
return this.resourceAllocations.get(agentId);
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Update token usage for agent (internal synchronous method)
|
|
344
|
+
*/ updateTokenUsageInternal(agentId, tokensUsed) {
|
|
345
|
+
const allocation = this.resourceAllocations.get(agentId);
|
|
346
|
+
if (allocation) {
|
|
347
|
+
allocation.currentUsage += tokensUsed;
|
|
348
|
+
// Auto-pause if exceeding budget
|
|
349
|
+
if (allocation.currentUsage > allocation.tokenBudget && !allocation.paused) {
|
|
350
|
+
this.logger.warn('Agent exceeding token budget', {
|
|
351
|
+
agentId,
|
|
352
|
+
current: allocation.currentUsage,
|
|
353
|
+
budget: allocation.tokenBudget
|
|
354
|
+
});
|
|
355
|
+
// Find session and pause
|
|
356
|
+
for (const session of this.sessions.values()){
|
|
357
|
+
if (session.agentId === agentId && !session.isPaused) {
|
|
358
|
+
this.interrupt(session.sessionId, 'Token budget exceeded').catch((err)=>{
|
|
359
|
+
this.logger.error('Auto-pause failed', {
|
|
360
|
+
agentId,
|
|
361
|
+
error: err
|
|
362
|
+
});
|
|
363
|
+
});
|
|
364
|
+
break;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Get help coordinator instance for external access
|
|
372
|
+
*/ getHelpCoordinator() {
|
|
373
|
+
return this.helpCoordinator;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Cleanup - terminate all sessions
|
|
377
|
+
*/ async cleanup() {
|
|
378
|
+
this.logger.info('Cleaning up query controller', {
|
|
379
|
+
totalSessions: this.sessions.size,
|
|
380
|
+
pausedAgents: this.getPausedSessions().length
|
|
381
|
+
});
|
|
382
|
+
// Clear help coordinator
|
|
383
|
+
this.helpCoordinator.clear();
|
|
384
|
+
this.sessions.clear();
|
|
385
|
+
this.checkpoints.clear();
|
|
386
|
+
this.resourceAllocations.clear();
|
|
387
|
+
this.agents.clear();
|
|
388
|
+
this.removeAllListeners();
|
|
389
|
+
this.ready = false;
|
|
390
|
+
}
|
|
391
|
+
// ===========================
|
|
392
|
+
// ICoordinator Implementation
|
|
393
|
+
// ===========================
|
|
394
|
+
/**
|
|
395
|
+
* Initialize coordinator - ICoordinator interface
|
|
396
|
+
*/ async initialize() {
|
|
397
|
+
this.logger.info('Initializing QueryController coordinator');
|
|
398
|
+
// Coordinator is ready after construction
|
|
399
|
+
this.ready = true;
|
|
400
|
+
this.startTime = Date.now();
|
|
401
|
+
this.emit('coordinator:initialized');
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Check if coordinator is ready - ICoordinator interface
|
|
405
|
+
*/ isReady() {
|
|
406
|
+
return this.ready;
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Spawn agent - ICoordinator interface
|
|
410
|
+
*/ async spawnAgent(config) {
|
|
411
|
+
if (!this.ready) {
|
|
412
|
+
throw new Error('Coordinator not initialized. Call initialize() first.');
|
|
413
|
+
}
|
|
414
|
+
if (this.agents.size >= this.config.maxConcurrentAgents) {
|
|
415
|
+
throw new Error(`Maximum concurrent agents (${this.config.maxConcurrentAgents}) reached`);
|
|
416
|
+
}
|
|
417
|
+
const sessionId = config.sessionId ?? generateId('session');
|
|
418
|
+
const agentId = config.agentId;
|
|
419
|
+
const priority = config.priority ?? 5;
|
|
420
|
+
const tokenBudget = config.tokenBudget ?? this.config.defaultTokenBudget;
|
|
421
|
+
// Register session
|
|
422
|
+
const session = this.registerSession(agentId, sessionId, priority);
|
|
423
|
+
// Create agent instance
|
|
424
|
+
const agent = {
|
|
425
|
+
agentId,
|
|
426
|
+
sessionId,
|
|
427
|
+
type: config.type,
|
|
428
|
+
state: config.initialState ?? 'idle',
|
|
429
|
+
isPaused: false,
|
|
430
|
+
priority,
|
|
431
|
+
session,
|
|
432
|
+
metadata: config.metadata ?? {}
|
|
433
|
+
};
|
|
434
|
+
// Store agent
|
|
435
|
+
this.agents.set(agentId, agent);
|
|
436
|
+
// Register as helper if capabilities provided
|
|
437
|
+
if (config.metadata?.capabilities && Array.isArray(config.metadata.capabilities)) {
|
|
438
|
+
const agentProfile = {
|
|
439
|
+
agentId,
|
|
440
|
+
type: config.type,
|
|
441
|
+
state: agent.state,
|
|
442
|
+
capabilities: config.metadata.capabilities,
|
|
443
|
+
priority,
|
|
444
|
+
workload: 0.0,
|
|
445
|
+
metadata: config.metadata
|
|
446
|
+
};
|
|
447
|
+
this.helpCoordinator.registerAgent(agentProfile);
|
|
448
|
+
this.logger.debug('Agent registered as helper', {
|
|
449
|
+
agentId,
|
|
450
|
+
capabilities: config.metadata.capabilities.map((c)=>c.name)
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
// Update coordinator metrics
|
|
454
|
+
this.coordinatorMetrics.totalAgentsSpawned++;
|
|
455
|
+
this.coordinatorMetrics.activeAgents++;
|
|
456
|
+
this.logger.info('Agent spawned', {
|
|
457
|
+
agentId,
|
|
458
|
+
type: config.type,
|
|
459
|
+
priority,
|
|
460
|
+
tokenBudget
|
|
461
|
+
});
|
|
462
|
+
this.emit('agent:spawned', agent);
|
|
463
|
+
return agent;
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Pause agent - ICoordinator interface
|
|
467
|
+
*/ async pauseAgent(agentId, reason) {
|
|
468
|
+
const agent = this.agents.get(agentId);
|
|
469
|
+
if (!agent) {
|
|
470
|
+
throw new Error(`Agent ${agentId} not found`);
|
|
471
|
+
}
|
|
472
|
+
if (agent.isPaused) {
|
|
473
|
+
this.logger.warn('Agent already paused', {
|
|
474
|
+
agentId
|
|
475
|
+
});
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
// Use existing interrupt method
|
|
479
|
+
await this.interrupt(agent.sessionId, reason ?? 'Manual pause');
|
|
480
|
+
// Update agent state
|
|
481
|
+
agent.isPaused = true;
|
|
482
|
+
// Update help coordinator state
|
|
483
|
+
this.helpCoordinator.updateAgentState(agentId, AgentStateEnum.PAUSED);
|
|
484
|
+
// Update coordinator metrics
|
|
485
|
+
this.coordinatorMetrics.activeAgents--;
|
|
486
|
+
this.coordinatorMetrics.pausedAgents++;
|
|
487
|
+
}
|
|
488
|
+
/**
|
|
489
|
+
* Resume agent - ICoordinator interface
|
|
490
|
+
*/ async resumeAgent(agentId, checkpointId, messageUUID) {
|
|
491
|
+
const agent = this.agents.get(agentId);
|
|
492
|
+
if (!agent) {
|
|
493
|
+
throw new Error(`Agent ${agentId} not found`);
|
|
494
|
+
}
|
|
495
|
+
if (!agent.isPaused) {
|
|
496
|
+
this.logger.warn('Agent not paused', {
|
|
497
|
+
agentId
|
|
498
|
+
});
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
// Use existing resumeSessionAt method
|
|
502
|
+
await this.resumeSessionAt(agent.sessionId, messageUUID, 'Resume from coordinator');
|
|
503
|
+
// Update agent state
|
|
504
|
+
agent.isPaused = false;
|
|
505
|
+
// Update help coordinator state (resumed agents go to IDLE or WORKING)
|
|
506
|
+
this.helpCoordinator.updateAgentState(agentId, agent.state);
|
|
507
|
+
// Update coordinator metrics
|
|
508
|
+
this.coordinatorMetrics.pausedAgents--;
|
|
509
|
+
this.coordinatorMetrics.activeAgents++;
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* Terminate agent - ICoordinator interface
|
|
513
|
+
*/ async terminateAgent(agentId, reason) {
|
|
514
|
+
const agent = this.agents.get(agentId);
|
|
515
|
+
if (!agent) {
|
|
516
|
+
throw new Error(`Agent ${agentId} not found`);
|
|
517
|
+
}
|
|
518
|
+
// Create final checkpoint before termination
|
|
519
|
+
if (!agent.isPaused) {
|
|
520
|
+
await this.createCheckpoint(agentId, `Termination: ${reason ?? 'Manual termination'}`);
|
|
521
|
+
}
|
|
522
|
+
// Unregister helper if registered
|
|
523
|
+
this.helpCoordinator.unregisterAgent(agentId);
|
|
524
|
+
this.logger.debug('Agent unregistered from help coordinator', {
|
|
525
|
+
agentId
|
|
526
|
+
});
|
|
527
|
+
// Remove agent
|
|
528
|
+
this.agents.delete(agentId);
|
|
529
|
+
// Remove session
|
|
530
|
+
this.sessions.delete(agent.sessionId);
|
|
531
|
+
// Update coordinator metrics
|
|
532
|
+
if (agent.isPaused) {
|
|
533
|
+
this.coordinatorMetrics.pausedAgents--;
|
|
534
|
+
} else {
|
|
535
|
+
this.coordinatorMetrics.activeAgents--;
|
|
536
|
+
}
|
|
537
|
+
this.coordinatorMetrics.totalTerminations++;
|
|
538
|
+
this.logger.info('Agent terminated', {
|
|
539
|
+
agentId,
|
|
540
|
+
reason
|
|
541
|
+
});
|
|
542
|
+
this.emit('agent:terminated', {
|
|
543
|
+
agentId,
|
|
544
|
+
reason
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* Get agent state - ICoordinator interface
|
|
549
|
+
*/ async getAgentState(agentId) {
|
|
550
|
+
const agent = this.agents.get(agentId);
|
|
551
|
+
if (!agent) {
|
|
552
|
+
throw new Error(`Agent ${agentId} not found`);
|
|
553
|
+
}
|
|
554
|
+
return agent.state;
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* Get agent session - ICoordinator interface
|
|
558
|
+
*/ async getAgentSession(agentId) {
|
|
559
|
+
const agent = this.agents.get(agentId);
|
|
560
|
+
if (!agent) {
|
|
561
|
+
throw new Error(`Agent ${agentId} not found`);
|
|
562
|
+
}
|
|
563
|
+
const session = this.sessions.get(agent.sessionId);
|
|
564
|
+
if (!session) {
|
|
565
|
+
throw new Error(`Session ${agent.sessionId} not found`);
|
|
566
|
+
}
|
|
567
|
+
return session;
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* Create checkpoint - ICoordinator interface
|
|
571
|
+
*/ async createCheckpoint(agentId, reason, metadata) {
|
|
572
|
+
const startTime = Date.now();
|
|
573
|
+
const agent = this.agents.get(agentId);
|
|
574
|
+
if (!agent) {
|
|
575
|
+
throw new Error(`Agent ${agentId} not found`);
|
|
576
|
+
}
|
|
577
|
+
const session = this.sessions.get(agent.sessionId);
|
|
578
|
+
if (!session) {
|
|
579
|
+
throw new Error(`Session ${agent.sessionId} not found`);
|
|
580
|
+
}
|
|
581
|
+
const checkpoint = {
|
|
582
|
+
id: generateId('checkpoint'),
|
|
583
|
+
sessionId: agent.sessionId,
|
|
584
|
+
agentId,
|
|
585
|
+
messageUUID: session.currentMessageUUID ?? generateId('msg'),
|
|
586
|
+
state: agent.state,
|
|
587
|
+
timestamp: new Date(),
|
|
588
|
+
metadata: {
|
|
589
|
+
reason: reason ?? 'Manual checkpoint',
|
|
590
|
+
autoCheckpoint: false,
|
|
591
|
+
context: metadata
|
|
592
|
+
}
|
|
593
|
+
};
|
|
594
|
+
// Store checkpoint in session
|
|
595
|
+
session.checkpoints.push(checkpoint);
|
|
596
|
+
// Store in checkpoints map
|
|
597
|
+
const checkpointList = this.checkpoints.get(agent.sessionId) ?? [];
|
|
598
|
+
checkpointList.push(checkpoint);
|
|
599
|
+
this.checkpoints.set(agent.sessionId, checkpointList);
|
|
600
|
+
const latencyMs = Date.now() - startTime;
|
|
601
|
+
// Update coordinator metrics
|
|
602
|
+
this.coordinatorMetrics.totalCheckpoints++;
|
|
603
|
+
this.coordinatorMetrics.averageCheckpointTimeMs = (this.coordinatorMetrics.averageCheckpointTimeMs * (this.coordinatorMetrics.totalCheckpoints - 1) + latencyMs) / this.coordinatorMetrics.totalCheckpoints;
|
|
604
|
+
this.logger.debug('Checkpoint created', {
|
|
605
|
+
agentId,
|
|
606
|
+
checkpointId: checkpoint.id,
|
|
607
|
+
latencyMs
|
|
608
|
+
});
|
|
609
|
+
this.emit('checkpoint:created', checkpoint);
|
|
610
|
+
return checkpoint;
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* Restore checkpoint - ICoordinator interface
|
|
614
|
+
*/ async restoreCheckpoint(checkpointId) {
|
|
615
|
+
const startTime = Date.now();
|
|
616
|
+
// Find checkpoint across all sessions
|
|
617
|
+
let foundCheckpoint;
|
|
618
|
+
let foundSessionId;
|
|
619
|
+
for (const [sessionId, checkpoints] of this.checkpoints.entries()){
|
|
620
|
+
const checkpoint = checkpoints.find((cp)=>cp.id === checkpointId);
|
|
621
|
+
if (checkpoint) {
|
|
622
|
+
foundCheckpoint = checkpoint;
|
|
623
|
+
foundSessionId = sessionId;
|
|
624
|
+
break;
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
if (!foundCheckpoint || !foundSessionId) {
|
|
628
|
+
throw new Error(`Checkpoint ${checkpointId} not found`);
|
|
629
|
+
}
|
|
630
|
+
const agent = this.agents.get(foundCheckpoint.agentId);
|
|
631
|
+
if (!agent) {
|
|
632
|
+
throw new Error(`Agent ${foundCheckpoint.agentId} not found for checkpoint`);
|
|
633
|
+
}
|
|
634
|
+
// Resume from checkpoint
|
|
635
|
+
await this.resumeSessionAt(foundSessionId, foundCheckpoint.messageUUID);
|
|
636
|
+
// Update agent state
|
|
637
|
+
agent.state = foundCheckpoint.state;
|
|
638
|
+
agent.isPaused = false;
|
|
639
|
+
const latencyMs = Date.now() - startTime;
|
|
640
|
+
// Update coordinator metrics
|
|
641
|
+
this.coordinatorMetrics.totalRestores++;
|
|
642
|
+
this.coordinatorMetrics.averageRestoreTimeMs = (this.coordinatorMetrics.averageRestoreTimeMs * (this.coordinatorMetrics.totalRestores - 1) + latencyMs) / this.coordinatorMetrics.totalRestores;
|
|
643
|
+
// Update p99 (simplified - use max of avg and current)
|
|
644
|
+
this.coordinatorMetrics.p99RestoreTimeMs = Math.max(this.coordinatorMetrics.p99RestoreTimeMs, latencyMs);
|
|
645
|
+
this.logger.info('Checkpoint restored', {
|
|
646
|
+
checkpointId,
|
|
647
|
+
agentId: agent.agentId,
|
|
648
|
+
latencyMs
|
|
649
|
+
});
|
|
650
|
+
this.emit('checkpoint:restored', {
|
|
651
|
+
checkpoint: foundCheckpoint,
|
|
652
|
+
agent
|
|
653
|
+
});
|
|
654
|
+
return agent;
|
|
655
|
+
}
|
|
656
|
+
/**
|
|
657
|
+
* List checkpoints - ICoordinator interface
|
|
658
|
+
*/ async listCheckpoints(agentId, limit) {
|
|
659
|
+
const agent = this.agents.get(agentId);
|
|
660
|
+
if (!agent) {
|
|
661
|
+
throw new Error(`Agent ${agentId} not found`);
|
|
662
|
+
}
|
|
663
|
+
const checkpoints = this.checkpoints.get(agent.sessionId) ?? [];
|
|
664
|
+
// Sort by timestamp descending (newest first)
|
|
665
|
+
const sorted = [
|
|
666
|
+
...checkpoints
|
|
667
|
+
].sort((a, b)=>b.timestamp.getTime() - a.timestamp.getTime());
|
|
668
|
+
// Apply limit if specified
|
|
669
|
+
return limit ? sorted.slice(0, limit) : sorted;
|
|
670
|
+
}
|
|
671
|
+
/**
|
|
672
|
+
* Get coordinator metrics - ICoordinator interface (overrides existing getMetrics)
|
|
673
|
+
* Includes both CoordinatorMetrics and legacy QueryControlMetrics fields
|
|
674
|
+
*/ getMetrics() {
|
|
675
|
+
// Update uptime
|
|
676
|
+
this.coordinatorMetrics.uptimeMs = Date.now() - this.startTime;
|
|
677
|
+
// Sync metrics from QueryControlMetrics
|
|
678
|
+
this.coordinatorMetrics.tokensSaved = this.metrics.tokensSaved;
|
|
679
|
+
// Return merged metrics for backward compatibility
|
|
680
|
+
return {
|
|
681
|
+
...this.coordinatorMetrics,
|
|
682
|
+
...this.metrics
|
|
683
|
+
};
|
|
684
|
+
}
|
|
685
|
+
/**
|
|
686
|
+
* Get active agents - ICoordinator interface (overrides existing)
|
|
687
|
+
*/ getActiveAgents() {
|
|
688
|
+
return Array.from(this.agents.values()).filter((agent)=>!agent.isPaused);
|
|
689
|
+
}
|
|
690
|
+
/**
|
|
691
|
+
* Get paused agents - ICoordinator interface (overrides existing)
|
|
692
|
+
*/ getPausedAgents() {
|
|
693
|
+
return Array.from(this.agents.values()).filter((agent)=>agent.isPaused);
|
|
694
|
+
}
|
|
695
|
+
/**
|
|
696
|
+
* Update token usage - ICoordinator interface
|
|
697
|
+
*/ async updateTokenUsage(agentId, tokensUsed) {
|
|
698
|
+
// Delegate to existing synchronous method
|
|
699
|
+
this.updateTokenUsageInternal(agentId, tokensUsed);
|
|
700
|
+
// Update coordinator metrics
|
|
701
|
+
this.coordinatorMetrics.totalTokensUsed += tokensUsed;
|
|
702
|
+
// Update help coordinator workload (tokens used / budget)
|
|
703
|
+
const allocation = this.resourceAllocations.get(agentId);
|
|
704
|
+
if (allocation) {
|
|
705
|
+
const workload = Math.min(1.0, allocation.currentUsage / allocation.tokenBudget);
|
|
706
|
+
this.helpCoordinator.updateAgentWorkload(agentId, workload);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
// ===========================
|
|
710
|
+
// Private Helpers
|
|
711
|
+
// ===========================
|
|
712
|
+
initializeMetrics() {
|
|
713
|
+
return {
|
|
714
|
+
totalPauses: 0,
|
|
715
|
+
totalResumes: 0,
|
|
716
|
+
averagePauseLatencyMs: 0,
|
|
717
|
+
averageResumeLatencyMs: 0,
|
|
718
|
+
tokensSaved: 0,
|
|
719
|
+
idleAgents: 0
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
initializeCoordinatorMetrics() {
|
|
723
|
+
return {
|
|
724
|
+
totalAgentsSpawned: 0,
|
|
725
|
+
activeAgents: 0,
|
|
726
|
+
pausedAgents: 0,
|
|
727
|
+
totalTerminations: 0,
|
|
728
|
+
totalCheckpoints: 0,
|
|
729
|
+
totalRestores: 0,
|
|
730
|
+
averageCheckpointTimeMs: 0,
|
|
731
|
+
averageRestoreTimeMs: 0,
|
|
732
|
+
p99RestoreTimeMs: 0,
|
|
733
|
+
tokensSaved: 0,
|
|
734
|
+
totalTokensUsed: 0,
|
|
735
|
+
uptimeMs: 0
|
|
736
|
+
};
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
//# sourceMappingURL=query-controller.js.map
|