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,318 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checkpoint Compressor - Multi-layer compression for state snapshots
|
|
3
|
+
*
|
|
4
|
+
* Compression Strategy:
|
|
5
|
+
* 1. Structural compression (MessagePack binary encoding)
|
|
6
|
+
* 2. Delta encoding (reference previous checkpoints)
|
|
7
|
+
* 3. Deduplication (shared data structures)
|
|
8
|
+
* 4. Gzip final pass
|
|
9
|
+
*
|
|
10
|
+
* Target: ≥60% compression ratio
|
|
11
|
+
*
|
|
12
|
+
* @module coordination/v2/checkpoints/checkpoint-compressor
|
|
13
|
+
*/ import { gzip, gunzip } from 'zlib';
|
|
14
|
+
import { promisify } from 'util';
|
|
15
|
+
import * as msgpack from 'msgpack-lite';
|
|
16
|
+
import { createHash } from 'crypto';
|
|
17
|
+
const gzipAsync = promisify(gzip);
|
|
18
|
+
const gunzipAsync = promisify(gunzip);
|
|
19
|
+
/**
|
|
20
|
+
* Checkpoint Compressor - Multi-layer compression engine
|
|
21
|
+
*/ export class CheckpointCompressor {
|
|
22
|
+
previousCheckpoints = new Map();
|
|
23
|
+
maxPreviousCheckpoints = 10;
|
|
24
|
+
minCompressionRatio = 0.6;
|
|
25
|
+
/**
|
|
26
|
+
* Compress checkpoint data with multi-layer strategy
|
|
27
|
+
*
|
|
28
|
+
* @param data - State snapshot to compress
|
|
29
|
+
* @param sessionId - Session identifier for delta compression
|
|
30
|
+
* @param previousCheckpointId - Optional reference for delta compression
|
|
31
|
+
* @returns Compression result with metrics
|
|
32
|
+
*/ async compress(data, sessionId, previousCheckpointId) {
|
|
33
|
+
const uncompressedData = JSON.stringify(data);
|
|
34
|
+
const uncompressedSize = Buffer.byteLength(uncompressedData, 'utf8');
|
|
35
|
+
// Try delta compression if previous checkpoint available
|
|
36
|
+
if (previousCheckpointId && this.previousCheckpoints.has(previousCheckpointId)) {
|
|
37
|
+
const deltaResult = await this.compressWithDelta(data, sessionId, previousCheckpointId, uncompressedSize);
|
|
38
|
+
if (deltaResult.compressionRatio >= this.minCompressionRatio) {
|
|
39
|
+
return deltaResult;
|
|
40
|
+
}
|
|
41
|
+
// Fall back to full compression if delta didn't achieve target
|
|
42
|
+
console.warn(`Delta compression ratio ${deltaResult.compressionRatio.toFixed(2)} below target ${this.minCompressionRatio}, using full compression`);
|
|
43
|
+
}
|
|
44
|
+
// Full compression: MessagePack + deduplication + gzip
|
|
45
|
+
return this.compressFull(data, sessionId, uncompressedSize);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Decompress checkpoint data
|
|
49
|
+
*
|
|
50
|
+
* @param compressedBuffer - Compressed data buffer
|
|
51
|
+
* @param compressionStrategy - Strategy used for compression
|
|
52
|
+
* @param referenceCheckpointId - Reference checkpoint for delta decompression
|
|
53
|
+
* @returns Decompressed data
|
|
54
|
+
*/ async decompress(compressedBuffer, compressionStrategy, referenceCheckpointId) {
|
|
55
|
+
const startTime = performance.now();
|
|
56
|
+
if (compressionStrategy === 'delta' && referenceCheckpointId) {
|
|
57
|
+
const data = await this.decompressDelta(compressedBuffer, referenceCheckpointId);
|
|
58
|
+
return {
|
|
59
|
+
data,
|
|
60
|
+
latencyMs: performance.now() - startTime
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
// Full decompression: gunzip + MessagePack decode
|
|
64
|
+
const data = await this.decompressFull(compressedBuffer);
|
|
65
|
+
return {
|
|
66
|
+
data,
|
|
67
|
+
latencyMs: performance.now() - startTime
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Full compression: MessagePack + gzip (with small data optimization)
|
|
72
|
+
*/ async compressFull(data, sessionId, uncompressedSize) {
|
|
73
|
+
// Step 1: Deduplication (extract shared structures)
|
|
74
|
+
const deduplicated = this.deduplicateData(data);
|
|
75
|
+
// Step 2: MessagePack encoding (structural compression)
|
|
76
|
+
const msgpackBuffer = msgpack.encode(deduplicated);
|
|
77
|
+
// Step 3: Gzip compression (skip for tiny data to avoid overhead)
|
|
78
|
+
let compressedBuffer;
|
|
79
|
+
if (msgpackBuffer.length < 256) {
|
|
80
|
+
// For small data, gzip overhead exceeds savings - use MessagePack only
|
|
81
|
+
compressedBuffer = msgpackBuffer;
|
|
82
|
+
} else {
|
|
83
|
+
// For larger data, apply gzip with maximum compression
|
|
84
|
+
compressedBuffer = await gzipAsync(msgpackBuffer, {
|
|
85
|
+
level: 9
|
|
86
|
+
});
|
|
87
|
+
// Fallback: if gzip made it bigger, use MessagePack only
|
|
88
|
+
if (compressedBuffer.length > msgpackBuffer.length) {
|
|
89
|
+
compressedBuffer = msgpackBuffer;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const compressedSize = compressedBuffer.length;
|
|
93
|
+
const compressionRatio = 1 - compressedSize / uncompressedSize;
|
|
94
|
+
// Store for potential delta compression
|
|
95
|
+
this.storePreviousCheckpoint(sessionId, data);
|
|
96
|
+
return {
|
|
97
|
+
compressedBuffer,
|
|
98
|
+
uncompressedSize,
|
|
99
|
+
compressedSize,
|
|
100
|
+
compressionRatio,
|
|
101
|
+
strategy: 'full'
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Delta compression: Encode differences from previous checkpoint
|
|
106
|
+
*/ async compressWithDelta(data, sessionId, previousCheckpointId, uncompressedSize) {
|
|
107
|
+
const previousData = this.previousCheckpoints.get(previousCheckpointId);
|
|
108
|
+
if (!previousData) {
|
|
109
|
+
// Fallback to full compression
|
|
110
|
+
return this.compressFull(data, sessionId, uncompressedSize);
|
|
111
|
+
}
|
|
112
|
+
// Calculate delta (differences only)
|
|
113
|
+
const delta = this.calculateDelta(previousData, data);
|
|
114
|
+
// Compress delta with MessagePack + gzip
|
|
115
|
+
const msgpackBuffer = msgpack.encode({
|
|
116
|
+
_delta: true,
|
|
117
|
+
_reference: previousCheckpointId,
|
|
118
|
+
changes: delta
|
|
119
|
+
});
|
|
120
|
+
const compressedBuffer = await gzipAsync(msgpackBuffer, {
|
|
121
|
+
level: 9
|
|
122
|
+
});
|
|
123
|
+
const compressedSize = compressedBuffer.length;
|
|
124
|
+
const compressionRatio = 1 - compressedSize / uncompressedSize;
|
|
125
|
+
// Store for future delta compression
|
|
126
|
+
this.storePreviousCheckpoint(sessionId, data);
|
|
127
|
+
return {
|
|
128
|
+
compressedBuffer,
|
|
129
|
+
uncompressedSize,
|
|
130
|
+
compressedSize,
|
|
131
|
+
compressionRatio,
|
|
132
|
+
strategy: 'delta',
|
|
133
|
+
referenceCheckpointId: previousCheckpointId
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Decompress full checkpoint
|
|
138
|
+
*/ async decompressFull(compressedBuffer) {
|
|
139
|
+
// Step 1: Gunzip
|
|
140
|
+
const msgpackBuffer = await gunzipAsync(compressedBuffer);
|
|
141
|
+
// Step 2: MessagePack decode
|
|
142
|
+
const data = msgpack.decode(msgpackBuffer);
|
|
143
|
+
return data;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Decompress delta checkpoint
|
|
147
|
+
*/ async decompressDelta(compressedBuffer, referenceCheckpointId) {
|
|
148
|
+
const previousData = this.previousCheckpoints.get(referenceCheckpointId);
|
|
149
|
+
if (!previousData) {
|
|
150
|
+
throw new Error(`Reference checkpoint ${referenceCheckpointId} not found for delta decompression`);
|
|
151
|
+
}
|
|
152
|
+
// Decompress delta
|
|
153
|
+
const msgpackBuffer = await gunzipAsync(compressedBuffer);
|
|
154
|
+
const deltaPackage = msgpack.decode(msgpackBuffer);
|
|
155
|
+
if (!deltaPackage._delta) {
|
|
156
|
+
throw new Error('Invalid delta checkpoint format');
|
|
157
|
+
}
|
|
158
|
+
// Apply delta to previous data
|
|
159
|
+
const reconstructed = this.applyDelta(previousData, deltaPackage.changes);
|
|
160
|
+
return reconstructed;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Calculate delta between previous and current data
|
|
164
|
+
*/ calculateDelta(previous, current) {
|
|
165
|
+
const delta = {};
|
|
166
|
+
// Find added/modified keys
|
|
167
|
+
for (const [key, value] of Object.entries(current)){
|
|
168
|
+
const previousValue = previous[key];
|
|
169
|
+
if (previousValue === undefined) {
|
|
170
|
+
// New key
|
|
171
|
+
delta[key] = {
|
|
172
|
+
_op: 'add',
|
|
173
|
+
value
|
|
174
|
+
};
|
|
175
|
+
} else if (JSON.stringify(previousValue) !== JSON.stringify(value)) {
|
|
176
|
+
// Modified key
|
|
177
|
+
if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
|
|
178
|
+
// Nested object - recurse
|
|
179
|
+
delta[key] = {
|
|
180
|
+
_op: 'modify',
|
|
181
|
+
delta: this.calculateDelta(previousValue, value)
|
|
182
|
+
};
|
|
183
|
+
} else {
|
|
184
|
+
// Primitive or array - replace
|
|
185
|
+
delta[key] = {
|
|
186
|
+
_op: 'replace',
|
|
187
|
+
value
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
// Find deleted keys
|
|
193
|
+
for (const key of Object.keys(previous)){
|
|
194
|
+
if (!(key in current)) {
|
|
195
|
+
delta[key] = {
|
|
196
|
+
_op: 'delete'
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return delta;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Apply delta to reconstruct current data from previous
|
|
204
|
+
*/ applyDelta(previous, delta) {
|
|
205
|
+
const result = {
|
|
206
|
+
...previous
|
|
207
|
+
};
|
|
208
|
+
for (const [key, change] of Object.entries(delta)){
|
|
209
|
+
const op = change._op;
|
|
210
|
+
if (op === 'add' || op === 'replace') {
|
|
211
|
+
result[key] = change.value;
|
|
212
|
+
} else if (op === 'delete') {
|
|
213
|
+
delete result[key];
|
|
214
|
+
} else if (op === 'modify') {
|
|
215
|
+
result[key] = this.applyDelta(previous[key], change.delta);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return result;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Deduplicate data structures (extract shared patterns)
|
|
222
|
+
*/ deduplicateData(data) {
|
|
223
|
+
const sharedStructures = new Map();
|
|
224
|
+
const deduplicatedData = this.deduplicateRecursive(data, sharedStructures);
|
|
225
|
+
// Only wrap if deduplication found shared structures
|
|
226
|
+
if (sharedStructures.size > 0) {
|
|
227
|
+
return {
|
|
228
|
+
_deduplicated: true,
|
|
229
|
+
_shared: Array.from(sharedStructures.entries()),
|
|
230
|
+
data: deduplicatedData
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
// No shared structures found, return original
|
|
234
|
+
return deduplicatedData;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Recursive deduplication helper
|
|
238
|
+
*/ deduplicateRecursive(obj, sharedStructures, depth = 0) {
|
|
239
|
+
if (depth > 10 || obj === null || typeof obj !== 'object') {
|
|
240
|
+
return obj;
|
|
241
|
+
}
|
|
242
|
+
// For arrays - detect repeated patterns
|
|
243
|
+
if (Array.isArray(obj)) {
|
|
244
|
+
if (obj.length > 3) {
|
|
245
|
+
// Check if all items are identical
|
|
246
|
+
const firstItemStr = JSON.stringify(obj[0]);
|
|
247
|
+
const allIdentical = obj.every((item)=>JSON.stringify(item) === firstItemStr);
|
|
248
|
+
if (allIdentical && obj.length > 5) {
|
|
249
|
+
// Store pattern and return reference
|
|
250
|
+
const hash = this.hashObject(obj[0]);
|
|
251
|
+
if (!sharedStructures.has(hash)) {
|
|
252
|
+
sharedStructures.set(hash, obj[0]);
|
|
253
|
+
}
|
|
254
|
+
return {
|
|
255
|
+
_repeat: obj.length,
|
|
256
|
+
_ref: hash
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return obj.map((item)=>this.deduplicateRecursive(item, sharedStructures, depth + 1));
|
|
261
|
+
}
|
|
262
|
+
// For objects - check for duplicate structures
|
|
263
|
+
const hash = this.hashObject(obj);
|
|
264
|
+
const existingStructures = Array.from(sharedStructures.keys());
|
|
265
|
+
// Find if this exact structure already exists
|
|
266
|
+
for (const existingHash of existingStructures){
|
|
267
|
+
const existing = sharedStructures.get(existingHash);
|
|
268
|
+
if (JSON.stringify(existing) === JSON.stringify(obj)) {
|
|
269
|
+
return {
|
|
270
|
+
_ref: existingHash
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
// New structure - recurse into properties
|
|
275
|
+
const deduplicated = {};
|
|
276
|
+
for (const [key, value] of Object.entries(obj)){
|
|
277
|
+
deduplicated[key] = this.deduplicateRecursive(value, sharedStructures, depth + 1);
|
|
278
|
+
}
|
|
279
|
+
return deduplicated;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Hash object for deduplication
|
|
283
|
+
*/ hashObject(obj) {
|
|
284
|
+
const json = JSON.stringify(obj, Object.keys(obj || {}).sort());
|
|
285
|
+
return createHash('sha256').update(json).digest('hex').substring(0, 8);
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Store previous checkpoint for delta compression
|
|
289
|
+
*/ storePreviousCheckpoint(sessionId, data) {
|
|
290
|
+
const checkpointId = `${sessionId}-${Date.now()}`;
|
|
291
|
+
this.previousCheckpoints.set(checkpointId, data);
|
|
292
|
+
// Maintain LRU cache
|
|
293
|
+
if (this.previousCheckpoints.size > this.maxPreviousCheckpoints) {
|
|
294
|
+
const oldestKey = Array.from(this.previousCheckpoints.keys())[0];
|
|
295
|
+
this.previousCheckpoints.delete(oldestKey);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Clear compression cache
|
|
300
|
+
*/ clearCache() {
|
|
301
|
+
this.previousCheckpoints.clear();
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Get compression statistics
|
|
305
|
+
*/ getStats() {
|
|
306
|
+
let totalSize = 0;
|
|
307
|
+
const values = Array.from(this.previousCheckpoints.values());
|
|
308
|
+
for (const data of values){
|
|
309
|
+
totalSize += Buffer.byteLength(JSON.stringify(data), 'utf8');
|
|
310
|
+
}
|
|
311
|
+
return {
|
|
312
|
+
cachedCheckpoints: this.previousCheckpoints.size,
|
|
313
|
+
cacheMemoryMB: totalSize / (1024 * 1024)
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
//# sourceMappingURL=checkpoint-compressor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../src/coordination/archives/v2-sdk-typescript/v2/checkpoints/checkpoint-compressor.ts"],"names":["gzip","gunzip","promisify","msgpack","createHash","gzipAsync","gunzipAsync","CheckpointCompressor","previousCheckpoints","Map","maxPreviousCheckpoints","minCompressionRatio","compress","data","sessionId","previousCheckpointId","uncompressedData","JSON","stringify","uncompressedSize","Buffer","byteLength","has","deltaResult","compressWithDelta","compressionRatio","console","warn","toFixed","compressFull","decompress","compressedBuffer","compressionStrategy","referenceCheckpointId","startTime","performance","now","decompressDelta","latencyMs","decompressFull","deduplicated","deduplicateData","msgpackBuffer","encode","length","level","compressedSize","storePreviousCheckpoint","strategy","previousData","get","delta","calculateDelta","_delta","_reference","changes","decode","Error","deltaPackage","reconstructed","applyDelta","previous","current","key","value","Object","entries","previousValue","undefined","_op","Array","isArray","keys","result","change","op","sharedStructures","deduplicatedData","deduplicateRecursive","size","_deduplicated","_shared","from","obj","depth","firstItemStr","allIdentical","every","item","hash","hashObject","set","_repeat","_ref","map","existingStructures","existingHash","existing","json","sort","update","digest","substring","checkpointId","Date","oldestKey","delete","clearCache","clear","getStats","totalSize","values","cachedCheckpoints","cacheMemoryMB"],"mappings":"AAAA;;;;;;;;;;;;CAYC,GAED,SAASA,IAAI,EAAEC,MAAM,QAAQ,OAAO;AACpC,SAASC,SAAS,QAAQ,OAAO;AACjC,YAAYC,aAAa,eAAe;AACxC,SAASC,UAAU,QAAQ,SAAS;AAEpC,MAAMC,YAAYH,UAAUF;AAC5B,MAAMM,cAAcJ,UAAUD;AAoC9B;;CAEC,GACD,OAAO,MAAMM;IACHC,sBAAwD,IAAIC,MAAM;IACzDC,yBAAyB,GAAG;IAC5BC,sBAAsB,IAAI;IAE3C;;;;;;;GAOC,GACD,MAAMC,SACJC,IAAyB,EACzBC,SAAiB,EACjBC,oBAA6B,EACD;QAC5B,MAAMC,mBAAmBC,KAAKC,SAAS,CAACL;QACxC,MAAMM,mBAAmBC,OAAOC,UAAU,CAACL,kBAAkB;QAE7D,yDAAyD;QACzD,IAAID,wBAAwB,IAAI,CAACP,mBAAmB,CAACc,GAAG,CAACP,uBAAuB;YAC9E,MAAMQ,cAAc,MAAM,IAAI,CAACC,iBAAiB,CAC9CX,MACAC,WACAC,sBACAI;YAGF,IAAII,YAAYE,gBAAgB,IAAI,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M,CAACF,MAAMG,MAAM,CAAC,OAAOC,SAAS,CAAC,GAAG;IACtE;IAEA;;GAEC,GACD,AAAQvD,wBAAwBjC,SAAiB,EAAED,IAAyB,EAAQ;QAClF,MAAM0F,eAAe,GAAGzF,UAAU,CAAC,EAAE0F,KAAKpE,GAAG,IAAI;QACjD,IAAI,CAAC5B,mBAAmB,CAACmF,GAAG,CAACY,cAAc1F;QAE3C,qBAAqB;QACrB,IAAI,IAAI,CAACL,mBAAmB,CAACuE,IAAI,GAAG,IAAI,CAACrE,sBAAsB,EAAE;YAC/D,MAAM+F,YAAYnC,MAAMY,IAAI,CAAC,IAAI,CAAC1E,mBAAmB,CAACgE,IAAI,GAAG,CAAC,EAAE;YAChE,IAAI,CAAChE,mBAAmB,CAACkG,MAAM,CAACD;QAClC;IACF;IAEA;;GAEC,GACDE,aAAmB;QACjB,IAAI,CAACnG,mBAAmB,CAACoG,KAAK;IAChC;IAEA;;GAEC,GACDC,WAGE;QACA,IAAIC,YAAY;QAChB,MAAMC,SAASzC,MAAMY,IAAI,CAAC,IAAI,CAAC1E,mBAAmB,CAACuG,MAAM;QACzD,KAAK,MAAMlG,QAAQkG,OAAQ;YACzBD,aAAa1F,OAAOC,UAAU,CAACJ,KAAKC,SAAS,CAACL,OAAO;QACvD;QAEA,OAAO;YACLmG,mBAAmB,IAAI,CAACxG,mBAAmB,CAACuE,IAAI;YAChDkC,eAAeH,YAAa,CAAA,OAAO,IAAG;QACxC;IACF;AACF"}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Coordination V2 - Completion Detection Interface
|
|
3
|
+
*
|
|
4
|
+
* Base interface for detecting swarm completion with event-driven architecture.
|
|
5
|
+
* Integrates with State Machine and Message Bus for real-time completion tracking.
|
|
6
|
+
*
|
|
7
|
+
* Performance targets:
|
|
8
|
+
* - Detection latency: <1000ms for 20-agent swarm
|
|
9
|
+
* - Event-driven (no polling)
|
|
10
|
+
* - Zero false positives
|
|
11
|
+
*
|
|
12
|
+
* @module coordination/v2/completion/completion-detector
|
|
13
|
+
*/ import { EventEmitter } from 'node:events';
|
|
14
|
+
import { AgentState } from '../../shared/core/agent-state.js';
|
|
15
|
+
import { LamportClock } from './lamport-clock.js';
|
|
16
|
+
/**
|
|
17
|
+
* Base CompletionDetector interface
|
|
18
|
+
*
|
|
19
|
+
* Provides core completion detection functionality with:
|
|
20
|
+
* - Event-driven architecture (completion:detected, completion:failed)
|
|
21
|
+
* - State Machine integration for agent state tracking
|
|
22
|
+
* - Message Bus integration for real-time updates
|
|
23
|
+
* - Checkpoint creation on completion
|
|
24
|
+
* - Validation and metrics tracking
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const detector = new HierarchicalCompletionDetector(
|
|
29
|
+
* stateMachine,
|
|
30
|
+
* messageBroker,
|
|
31
|
+
* checkpointManager,
|
|
32
|
+
* { autoCheckpoint: true }
|
|
33
|
+
* );
|
|
34
|
+
*
|
|
35
|
+
* detector.on('completion:detected', (result) => {
|
|
36
|
+
* console.log(`Swarm ${result.swarmId} completed!`);
|
|
37
|
+
* });
|
|
38
|
+
*
|
|
39
|
+
* const result = await detector.detectCompletion('swarm-1');
|
|
40
|
+
* if (result.completed) {
|
|
41
|
+
* console.log(`Checkpoint: ${result.checkpointId}`);
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*/ export class CompletionDetector extends EventEmitter {
|
|
45
|
+
stateMachine;
|
|
46
|
+
messageBroker;
|
|
47
|
+
checkpointManager;
|
|
48
|
+
config;
|
|
49
|
+
metrics;
|
|
50
|
+
detectionLatencies;
|
|
51
|
+
lamportClock;
|
|
52
|
+
constructor(stateMachine, messageBroker, checkpointManager, config){
|
|
53
|
+
super();
|
|
54
|
+
this.stateMachine = stateMachine;
|
|
55
|
+
this.messageBroker = messageBroker;
|
|
56
|
+
this.checkpointManager = checkpointManager;
|
|
57
|
+
this.config = {
|
|
58
|
+
autoCheckpoint: config?.autoCheckpoint ?? true,
|
|
59
|
+
enableValidation: config?.enableValidation ?? true,
|
|
60
|
+
maxDetectionLatencyMs: config?.maxDetectionLatencyMs ?? 1000,
|
|
61
|
+
enableLogging: config?.enableLogging ?? true
|
|
62
|
+
};
|
|
63
|
+
this.metrics = {
|
|
64
|
+
totalDetections: 0,
|
|
65
|
+
successfulDetections: 0,
|
|
66
|
+
failedDetections: 0,
|
|
67
|
+
averageLatencyMs: 0,
|
|
68
|
+
p99LatencyMs: 0,
|
|
69
|
+
totalCheckpointsCreated: 0
|
|
70
|
+
};
|
|
71
|
+
this.detectionLatencies = [];
|
|
72
|
+
this.lamportClock = new LamportClock();
|
|
73
|
+
// Subscribe to state machine events for real-time tracking
|
|
74
|
+
this.stateMachine.on('state:transition', this.handleStateTransition.bind(this));
|
|
75
|
+
if (this.config.enableLogging) {
|
|
76
|
+
this.log('CompletionDetector initialized', {
|
|
77
|
+
strategy: this.getStrategy(),
|
|
78
|
+
autoCheckpoint: this.config.autoCheckpoint,
|
|
79
|
+
enableValidation: this.config.enableValidation
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Create checkpoint on completion
|
|
85
|
+
*
|
|
86
|
+
* @param swarmId - Swarm identifier
|
|
87
|
+
* @param agentStates - Final agent states
|
|
88
|
+
* @returns Checkpoint ID
|
|
89
|
+
*/ async createCompletionCheckpoint(swarmId, agentStates) {
|
|
90
|
+
if (!this.config.autoCheckpoint) {
|
|
91
|
+
throw new Error('Auto-checkpoint disabled');
|
|
92
|
+
}
|
|
93
|
+
const lamportTimestamp = this.lamportClock.tick();
|
|
94
|
+
const physicalTime = Date.now();
|
|
95
|
+
const sessionId = `swarm-${swarmId}`;
|
|
96
|
+
// Create state snapshot with both Lamport and physical timestamps
|
|
97
|
+
const stateSnapshot = {
|
|
98
|
+
swarmId,
|
|
99
|
+
lamportTimestamp,
|
|
100
|
+
physicalTime,
|
|
101
|
+
completionTime: physicalTime,
|
|
102
|
+
agentStates: Object.fromEntries(agentStates),
|
|
103
|
+
totalAgents: agentStates.size,
|
|
104
|
+
completedAgents: Array.from(agentStates.values()).filter((state)=>state === AgentState.COMPLETED).length
|
|
105
|
+
};
|
|
106
|
+
// Create checkpoint with first completed agent or swarm ID
|
|
107
|
+
const firstAgent = Array.from(agentStates.keys())[0] || `agent-${swarmId}`;
|
|
108
|
+
const messageUUID = `completion-${swarmId}-${lamportTimestamp}`;
|
|
109
|
+
const checkpointId = await this.checkpointManager.createCheckpoint(sessionId, firstAgent, messageUUID, AgentState.COMPLETED, stateSnapshot, {
|
|
110
|
+
reason: `Swarm completion: ${swarmId}`,
|
|
111
|
+
autoCheckpoint: true,
|
|
112
|
+
context: {
|
|
113
|
+
lamportTimestamp,
|
|
114
|
+
physicalTime: new Date(physicalTime).toISOString(),
|
|
115
|
+
strategy: this.getStrategy()
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
this.metrics.totalCheckpointsCreated++;
|
|
119
|
+
if (this.config.enableLogging) {
|
|
120
|
+
this.log('Completion checkpoint created', {
|
|
121
|
+
swarmId,
|
|
122
|
+
checkpointId,
|
|
123
|
+
agentCount: agentStates.size
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return checkpointId;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Update metrics after detection
|
|
130
|
+
*/ updateMetrics(latencyMs, success) {
|
|
131
|
+
this.metrics.totalDetections++;
|
|
132
|
+
if (success) {
|
|
133
|
+
this.metrics.successfulDetections++;
|
|
134
|
+
} else {
|
|
135
|
+
this.metrics.failedDetections++;
|
|
136
|
+
}
|
|
137
|
+
this.detectionLatencies.push(latencyMs);
|
|
138
|
+
// Keep only last 1000 samples
|
|
139
|
+
if (this.detectionLatencies.length > 1000) {
|
|
140
|
+
this.detectionLatencies.shift();
|
|
141
|
+
}
|
|
142
|
+
// Update average latency
|
|
143
|
+
this.metrics.averageLatencyMs = (this.metrics.averageLatencyMs * (this.metrics.totalDetections - 1) + latencyMs) / this.metrics.totalDetections;
|
|
144
|
+
// Update p99 latency
|
|
145
|
+
if (this.detectionLatencies.length > 0) {
|
|
146
|
+
const sorted = [
|
|
147
|
+
...this.detectionLatencies
|
|
148
|
+
].sort((a, b)=>a - b);
|
|
149
|
+
const p99Index = Math.floor(sorted.length * 0.99);
|
|
150
|
+
this.metrics.p99LatencyMs = sorted[p99Index] || sorted[sorted.length - 1];
|
|
151
|
+
}
|
|
152
|
+
// Warn if exceeding latency threshold
|
|
153
|
+
if (latencyMs > this.config.maxDetectionLatencyMs) {
|
|
154
|
+
this.log('Detection latency exceeded threshold', {
|
|
155
|
+
latencyMs: latencyMs.toFixed(2),
|
|
156
|
+
threshold: this.config.maxDetectionLatencyMs,
|
|
157
|
+
p99: this.metrics.p99LatencyMs.toFixed(2)
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Get completion metrics
|
|
163
|
+
*/ getMetrics() {
|
|
164
|
+
return {
|
|
165
|
+
...this.metrics
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Reset metrics (for testing)
|
|
170
|
+
*/ resetMetrics() {
|
|
171
|
+
this.metrics.totalDetections = 0;
|
|
172
|
+
this.metrics.successfulDetections = 0;
|
|
173
|
+
this.metrics.failedDetections = 0;
|
|
174
|
+
this.metrics.averageLatencyMs = 0;
|
|
175
|
+
this.metrics.p99LatencyMs = 0;
|
|
176
|
+
this.metrics.totalCheckpointsCreated = 0;
|
|
177
|
+
this.detectionLatencies.length = 0;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Emit completion detected event
|
|
181
|
+
*/ emitCompletionDetected(result) {
|
|
182
|
+
this.emit('completion:detected', result);
|
|
183
|
+
if (this.config.enableLogging) {
|
|
184
|
+
this.log('Completion detected', {
|
|
185
|
+
swarmId: result.swarmId,
|
|
186
|
+
completedCount: result.completedCount,
|
|
187
|
+
totalCount: result.totalCount,
|
|
188
|
+
latencyMs: result.latencyMs.toFixed(2),
|
|
189
|
+
checkpointId: result.checkpointId
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Emit completion failed event
|
|
195
|
+
*/ emitCompletionFailed(swarmId, error) {
|
|
196
|
+
this.emit('completion:failed', {
|
|
197
|
+
swarmId,
|
|
198
|
+
error
|
|
199
|
+
});
|
|
200
|
+
if (this.config.enableLogging) {
|
|
201
|
+
this.log('Completion detection failed', {
|
|
202
|
+
swarmId,
|
|
203
|
+
error: error.message
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Internal logging helper
|
|
209
|
+
*/ log(message, data) {
|
|
210
|
+
if (!this.config.enableLogging) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
const logData = {
|
|
214
|
+
timestamp: new Date().toISOString(),
|
|
215
|
+
strategy: this.getStrategy(),
|
|
216
|
+
...data
|
|
217
|
+
};
|
|
218
|
+
console.log(`[CompletionDetector:${this.getStrategy()}] ${message}`, logData);
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Cleanup detector resources
|
|
222
|
+
*/ async cleanup() {
|
|
223
|
+
this.stateMachine.removeListener('state:transition', this.handleStateTransition.bind(this));
|
|
224
|
+
this.removeAllListeners();
|
|
225
|
+
if (this.config.enableLogging) {
|
|
226
|
+
this.log('CompletionDetector cleanup complete', {
|
|
227
|
+
totalDetections: this.metrics.totalDetections,
|
|
228
|
+
averageLatencyMs: this.metrics.averageLatencyMs.toFixed(2)
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
//# sourceMappingURL=completion-detector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../src/coordination/archives/v2-sdk-typescript/v2/completion/completion-detector.ts"],"names":["EventEmitter","AgentState","LamportClock","CompletionDetector","stateMachine","messageBroker","checkpointManager","config","metrics","detectionLatencies","lamportClock","autoCheckpoint","enableValidation","maxDetectionLatencyMs","enableLogging","totalDetections","successfulDetections","failedDetections","averageLatencyMs","p99LatencyMs","totalCheckpointsCreated","on","handleStateTransition","bind","log","strategy","getStrategy","createCompletionCheckpoint","swarmId","agentStates","Error","lamportTimestamp","tick","physicalTime","Date","now","sessionId","stateSnapshot","completionTime","Object","fromEntries","totalAgents","size","completedAgents","Array","from","values","filter","state","COMPLETED","length","firstAgent","keys","messageUUID","checkpointId","createCheckpoint","reason","context","toISOString","agentCount","updateMetrics","latencyMs","success","push","shift","sorted","sort","a","b","p99Index","Math","floor","toFixed","threshold","p99","getMetrics","resetMetrics","emitCompletionDetected","result","emit","completedCount","totalCount","emitCompletionFailed","error","message","data","logData","timestamp","console","cleanup","removeListener","removeAllListeners"],"mappings":"AAAA;;;;;;;;;;;;CAYC,GAED,SAASA,YAAY,QAAQ,cAAc;AAC3C,SAASC,UAAU,QAAQ,mCAAmC;AAI9D,SAASC,YAAY,QAAQ,qBAAqB;AAkJlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BC,GACD,OAAO,MAAeC,2BAA2BH;IAC5BI,aAA2B;IAC3BC,cAA6B;IAC7BC,kBAAqC;IACrCC,OAA2C;IAC3CC,QAA2B;IAC3BC,mBAA6B;IAC7BC,aAA2B;IAE9C,YACEN,YAA0B,EAC1BC,aAA4B,EAC5BC,iBAAoC,EACpCC,MAAiC,CACjC;QACA,KAAK;QAEL,IAAI,CAACH,YAAY,GAAGA;QACpB,IAAI,CAACC,aAAa,GAAGA;QACrB,IAAI,CAACC,iBAAiB,GAAGA;QAEzB,IAAI,CAACC,MAAM,GAAG;YACZI,gBAAgBJ,QAAQI,kBAAkB;YAC1CC,kBAAkBL,QAAQK,oBAAoB;YAC9CC,uBAAuBN,QAAQM,yBAAyB;YACxDC,eAAeP,QAAQO,iBAAiB;QAC1C;QAEA,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