claude-flow-novice 1.6.3 → 1.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/commands/parse-epic.js +180 -0
- package/.claude/settings.json +12 -2
- package/.claude/settings.local.json +4 -2
- package/.claude-flow-novice/dist/mcp/mcp-server-novice.js +37 -2
- package/.claude-flow-novice/dist/mcp/transports/base.js +5 -0
- package/.claude-flow-novice/dist/mcp/transports/base.js.map +1 -0
- package/.claude-flow-novice/dist/mcp/transports/http.js +414 -0
- package/.claude-flow-novice/dist/mcp/transports/http.js.map +1 -0
- package/.claude-flow-novice/dist/mcp/transports/stdio.js +217 -0
- package/.claude-flow-novice/dist/mcp/transports/stdio.js.map +1 -0
- package/.claude-flow-novice/dist/src/cli/commands/parse-epic.js +129 -0
- package/.claude-flow-novice/dist/src/cli/commands/parse-epic.js.map +1 -0
- package/.claude-flow-novice/dist/src/cli/index.js +3 -0
- package/.claude-flow-novice/dist/src/cli/index.js.map +1 -1
- package/.claude-flow-novice/dist/src/cli/utils/epic-parser.js +266 -0
- package/.claude-flow-novice/dist/src/cli/utils/epic-parser.js.map +1 -0
- package/.claude-flow-novice/dist/src/communication/message-bus.js +105 -2
- package/.claude-flow-novice/dist/src/communication/message-bus.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/adapters/v1-coordinator-adapter.js +1 -1
- package/.claude-flow-novice/dist/src/coordination/adapters/v1-coordinator-adapter.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/cache/artifact-cache-optimizer.js +632 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/cache/artifact-cache-optimizer.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/cache/index.js +11 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/cache/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/checkpoints/checkpoint-compressor.js +318 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/checkpoints/checkpoint-compressor.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/completion-detector.js +234 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/completion-detector.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/hierarchical-detector.js +347 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/hierarchical-detector.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/index.js +13 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/lamport-clock.js +173 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/lamport-clock.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/mesh-detector.js +526 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/mesh-detector.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/sdk-completion-detector.js +443 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/sdk-completion-detector.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/swarm-shutdown.js +366 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/swarm-shutdown.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinator-factory.js +287 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinator-factory.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/cascading-shutdown.example.js +364 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/cascading-shutdown.example.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/cascading-shutdown.js +492 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/cascading-shutdown.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/hierarchical-coordinator.js +786 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/hierarchical-coordinator.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/index.js +16 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/parent-child-manager.js +342 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/parent-child-manager.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/swarm-coordinator-v2.js +601 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/swarm-coordinator-v2.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/agent-state.js +9 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/agent-state.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dead-letter-queue.js +413 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dead-letter-queue.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-graph.js +471 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-graph.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-node.js +379 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-node.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-resolver.js +335 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-resolver.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/help-request-metrics.js +211 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/help-request-metrics.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/index.js +33 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message-broker.js +920 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message-broker.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message-router.js +385 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message-router.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message.js +138 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/resource-manager-safe.js +478 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/resource-manager-safe.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-machine-config.js +358 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-machine-config.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-machine.js +588 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-machine.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-transition.js +153 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-transition.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/task-scheduler.js +360 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/task-scheduler.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/topic-manager.js +337 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/topic-manager.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/deadlock-detector.js +424 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/deadlock-detector.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/index.js +9 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/resource-manager.js +669 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/resource-manager.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/artifact-storage.js +451 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/artifact-storage.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/cycle-detector.js +271 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/cycle-detector.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-graph.js +335 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-graph.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-manager.js +439 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-manager.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-request.js +92 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-request.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/index.js +21 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/topological-sort.js +223 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/topological-sort.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-coordinator.js +436 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-coordinator.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-matcher.js +278 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-matcher.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-request-handler.js +317 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-request-handler.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-request.js +273 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-request.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/index.js +15 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/waiting-agent-pool.js +512 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/waiting-agent-pool.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/index.js +67 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/help-deadlock-integration.js +557 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/help-deadlock-integration.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/index.js +14 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/message-bus-completion-integration.example.js +212 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/message-bus-completion-integration.example.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/message-bus-completion-integration.js +552 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/message-bus-completion-integration.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/state-machine-integration.js +635 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/state-machine-integration.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/IArtifactStorage.js +28 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/IArtifactStorage.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/ICoordinator.js +9 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/ICoordinator.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/ISessionStore.js +25 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/ISessionStore.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/index.js +14 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/artifact-adapter.js +308 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/artifact-adapter.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/completion-storage.js +439 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/completion-storage.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/dependency-graph-storage.js +540 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/dependency-graph-storage.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/dependency-storage.js +367 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/dependency-storage.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/index.js +14 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/message-storage.js +518 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/message-storage.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/state-storage.js +377 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/state-storage.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channel.js +371 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channel.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/dependency-channel.js +355 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/dependency-channel.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/help-channel.js +424 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/help-channel.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/index.js +16 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/state-channel.js +295 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/state-channel.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/task-channel.js +411 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/task-channel.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/index.js +14 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-bus.js +387 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-bus.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-persistence.js +589 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-persistence.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-router.js +444 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-router.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/artifact-storage.js +560 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/artifact-storage.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/background-orchestrator.js +335 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/background-orchestrator.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/bash-output-monitor.js +104 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/bash-output-monitor.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/checkpoint-manager.js +847 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/checkpoint-manager.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/help-coordinator.js +470 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/help-coordinator.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/hierarchical-background-integration.js +450 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/hierarchical-background-integration.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/index.js +13 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/message-bus-integration.js +625 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/message-bus-integration.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/multi-level-control.js +545 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/multi-level-control.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/query-controller.js +740 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/query-controller.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/query-message-integration.js +415 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/query-message-integration.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/session-pool-optimizer.js +615 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/session-pool-optimizer.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/state-machine-integration.js +547 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/state-machine-integration.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/state-sdk-integration.js +342 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/state-sdk-integration.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/security/payload-validator.js +259 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/security/payload-validator.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/framework-registry.js +273 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/framework-registry.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/index.js +8 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/truth-config-manager.js +310 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/truth-config-manager.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/truth-validator.js +218 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/truth-validator.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/types/sdk.js +9 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/types/sdk.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/index.js +6 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/priority-queue.js +145 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/priority-queue.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/sdk-helpers.js +122 -0
- package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/sdk-helpers.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/config-translator.js +17 -43
- package/.claude-flow-novice/dist/src/coordination/config-translator.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/coordination-toggle.js +34 -76
- package/.claude-flow-novice/dist/src/coordination/coordination-toggle.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/index.js +3 -0
- package/.claude-flow-novice/dist/src/coordination/index.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/shared/core/agent-state.js +172 -0
- package/.claude-flow-novice/dist/src/coordination/shared/core/agent-state.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/shared/core/index.js +7 -0
- package/.claude-flow-novice/dist/src/coordination/shared/core/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/shared/index.js +19 -0
- package/.claude-flow-novice/dist/src/coordination/shared/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/shared/interfaces/ICoordinator.js +24 -0
- package/.claude-flow-novice/dist/src/coordination/shared/interfaces/ICoordinator.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/shared/interfaces/index.js +7 -0
- package/.claude-flow-novice/dist/src/coordination/shared/interfaces/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/shared/message-broker.js +920 -0
- package/.claude-flow-novice/dist/src/coordination/shared/message-broker.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/shared/message.js +138 -0
- package/.claude-flow-novice/dist/src/coordination/shared/message.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/shared/security/payload-validator.js +259 -0
- package/.claude-flow-novice/dist/src/coordination/shared/security/payload-validator.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/shared/transparency/index.js +17 -0
- package/.claude-flow-novice/dist/src/coordination/shared/transparency/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/shared/transparency/interfaces/transparency-system.js +19 -0
- package/.claude-flow-novice/dist/src/coordination/shared/transparency/interfaces/transparency-system.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/shared/transparency/transparency-integration.js +357 -0
- package/.claude-flow-novice/dist/src/coordination/shared/transparency/transparency-integration.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/shared/transparency/transparency-system.js +679 -0
- package/.claude-flow-novice/dist/src/coordination/shared/transparency/transparency-system.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/shared/types/index.js +7 -0
- package/.claude-flow-novice/dist/src/coordination/shared/types/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/shared/types/sdk.js +10 -0
- package/.claude-flow-novice/dist/src/coordination/shared/types/sdk.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v1-transparency/interfaces/v1-transparency-system.js +12 -0
- package/.claude-flow-novice/dist/src/coordination/v1-transparency/interfaces/v1-transparency-system.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v1-transparency/v1-to-v2-bridge.js +433 -0
- package/.claude-flow-novice/dist/src/coordination/v1-transparency/v1-to-v2-bridge.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v1-transparency/v1-transparency-adapter.js +1468 -0
- package/.claude-flow-novice/dist/src/coordination/v1-transparency/v1-transparency-adapter.js.map +1 -0
- package/.claude-flow-novice/dist/src/feature-flags/core/FeatureFlagManager.js +52 -2
- package/.claude-flow-novice/dist/src/feature-flags/core/FeatureFlagManager.js.map +1 -1
- package/.claude-flow-novice/dist/src/mcp/mcp-server-novice.js +37 -2
- package/.claude-flow-novice/dist/src/mcp/session-manager.js +3 -1
- package/.claude-flow-novice/dist/src/mcp/session-manager.js.map +1 -1
- package/.claude-flow-novice/dist/src/monitoring/apm/apm-integration.js +5 -0
- package/.claude-flow-novice/dist/src/monitoring/apm/apm-integration.js.map +1 -1
- package/.claude-flow-novice/dist/src/providers/provider-manager.js +41 -6
- package/.claude-flow-novice/dist/src/providers/provider-manager.js.map +1 -1
- package/.claude-flow-novice/dist/src/providers/tiered-router.js +9 -17
- package/.claude-flow-novice/dist/src/providers/tiered-router.js.map +1 -1
- package/.claude-flow-novice/dist/src/utils/markdown-sanitizer.js +65 -41
- package/.claude-flow-novice/dist/src/utils/markdown-sanitizer.js.map +1 -1
- package/.claude-flow-novice/dist/src/web/api/server.js +1 -1
- package/.claude-flow-novice/dist/src/web/api/server.js.map +1 -1
- package/.claude-flow-novice/dist/src/workflows/progressive-rollout-manager.js +30 -0
- package/.claude-flow-novice/dist/src/workflows/progressive-rollout-manager.js.map +1 -1
- package/.claude-flow-novice/metrics.db +0 -0
- package/.claude-flow-novice/metrics.db-shm +0 -0
- package/.claude-flow-novice/metrics.db-wal +0 -0
- package/CLAUDE.md +72 -0
- package/config/hooks/post-edit-pipeline.js +68 -118
- package/config/hooks/pre-tool-memory-safety.js +209 -0
- package/package.json +7 -4
- package/scripts/cleanup-idle-sessions.sh +59 -0
- package/scripts/monitoring/alert-monitor.sh +220 -0
- package/scripts/monitoring/view-alerts.sh +307 -0
- package/scripts/test-provider-routing.cjs +7 -9
- package/scripts/test-zai-api.cjs +2 -2
- package/src/slash-commands/parse-epic.js +1 -1
- package/wiki/Provider-Routing.md +57 -69
- package/MEMORY_LEAK_ROOT_CAUSE.md +0 -149
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../src/coordination/archives/v2-sdk-typescript/v2/core/message-broker.ts"],"names":["EventEmitter","RateLimiter","MessagePriority","MessageUtils","DeliverySemantics","PayloadValidator","MessageBrokerError","Error","message","name","PriorityQueue","items","enqueue","item","push","sort","a","b","priority","dequeue","shift","peek","length","size","clear","MessageBroker","emitter","subscriptions","pendingRequests","messageQueue","config","stats","processing","subscriptionCounter","senderQueueSizes","deadLetterQueue","rateLimiters","rateLimiterCleanupInterval","payloadValidator","agentSubscriptions","subscriptionCleanupInterval","setMaxListeners","Map","maxQueueSize","maxQueueSizePerSender","enableDeadLetterQueue","priorityEvictionThreshold","defaultRequestTimeout","enableStats","maxConcurrency","maxSubscriptions","maxSubscriptionsPerAgent","subscriptionTTL","cleanupIntervalMs","authorizationProvider","rateLimit","maxMessagesPerSecond","maxBurstSize","strategy","undefined","payloadValidation","totalPublished","totalDelivered","totalFailed","totalSubscriptions","messagesByTopic","messagesByPriority","avgDeliveryTime","startRateLimiterCleanup","startSubscriptionCleanup","subscribe","topic","validateTopicName","handler","subscriberId","agentSubs","get","Set","authorized","canSubscribe","subscriptionId","Date","now","internalSub","id","createdAt","filter","expiresAt","has","set","topicSubs","add","unsubscribe","Array","from","keys","subs","index","findIndex","sub","splice","delete","publish","validateConfig","validationResult","validate","payload","valid","emit","errors","senderId","join","sanitizedPayload","sanitize","allowed","checkRateLimit","currentSenderSize","process","env","DEBUG_MESSAGE_BROKER","console","log","evictionThreshold","Math","floor","messagePriority","normalizePriority","evicted","evictLowPriorityMessages","queueSize","evictedMessages","threshold","generateMessageId","timestamp","replyTo","correlationId","recipientId","deliverySemantics","AT_LEAST_ONCE","metadata","processQueue","catch","error","broadcast","request","options","generateCorrelationId","timeout","NORMAL","replyTopic","Promise","resolve","reject","timeoutId","setTimeout","expectedSender","resolved","clearTimeout","reply","success","createReply","hasHandlers","hasMatchingHandlers","deliverMessage","senderSize","topicPattern","matchesTopic","startTime","matchingHandlers","cleanupExpiredSubscriptions","pendingRequest","warn","subscription","deliveryTime","getStats","resetStats","getSubscriptions","result","values","getQueueSize","getPendingRequestCount","includes","validTopicPattern","test","limiter","tokensPerInterval","interval","fireImmediately","remainingTokens","removeTokens","setInterval","entries","toKeep","slice","forEach","key","value","incomingPriority","lowestIndex","lowestPriority","i","candidate","getDeadLetterQueueSize","getRateLimiterCount","getDeadLetterMessages","count","clearDeadLetterQueue","cleanupInterval","expiredCount","validSubs","pending","clearInterval","removeAllListeners","shutdown","onError","on"],"mappings":"AAAA;;;;;;;;;;;CAWC,GAED,SAASA,YAAY,QAAQ,SAAS;AACtC,SAASC,WAAW,QAAQ,UAAU;AACtC,SAIEC,eAAe,EAEfC,YAAY,EAMZC,iBAAiB,QACZ,eAAe;AACtB,SAASC,gBAAgB,QAA+B,mCAAmC;AAE3F;;CAEC,GACD,OAAO,MAAMC,2BAA2BC;IACtC,YAAYC,OAAe,CAAE;QAC3B,KAAK,CAACA;QACN,IAAI,CAACC,IAAI,GAAG;IACd;AACF;AA6BA;;CAEC,GACD,IAAA,AAAMC,gBAAN,MAAMA;IACIC,QAAa,EAAE,CAAC;IAExBC,QAAQC,IAAO,EAAQ;QACrB,IAAI,CAACF,KAAK,CAACG,IAAI,CAACD;QAChB,IAAI,CAACF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e,kBAAkB,CAACf,KAAK;QAE7B,mCAAmC;QACnC,IAAI,CAACY,YAAY,CAACZ,KAAK;QACvB,IAAI,IAAI,CAACa,0BAA0B,EAAE;YACnC8K,cAAc,IAAI,CAAC9K,0BAA0B;YAC7C,IAAI,CAACA,0BAA0B,GAAGsB;QACpC;QAEA,mDAAmD;QACnD,IAAI,IAAI,CAACnB,2BAA2B,EAAE;YACpC2K,cAAc,IAAI,CAAC3K,2BAA2B;YAC9C,IAAI,CAACA,2BAA2B,GAAGmB;QACrC;QAEA,IAAI,CAAC5B,KAAK,CAACiC,kBAAkB,GAAG;QAChC,IAAI,CAACtC,OAAO,CAAC0L,kBAAkB;IACjC;IAEA;;;;;;GAMC,GACD,MAAMC,SAASlE,UAAkB,IAAI,EAAiB;QACpD,MAAMoB,YAAYtF,KAAKC,GAAG;QAE1B,0BAA0B;QAC1B,MAAO,IAAI,CAACrD,YAAY,CAACP,MAAM,GAAG,KAAK2D,KAAKC,GAAG,KAAKqF,YAAYpB,QAAS;YACvE,MAAM,IAAIG,QAAQC,CAAAA,UAAWG,WAAWH,SAAS;QACnD;QAEA,IAAI,CAAC/H,KAAK;IACZ;IAEA;;;;GAIC,GACD8L,QAAQ7I,OAA6B,EAAQ;QAC3C,IAAI,CAAC/C,OAAO,CAAC6L,EAAE,CAAC,SAAS9I;IAC3B;AACF"}
|
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Coordination V2 - Message Router
|
|
3
|
+
*
|
|
4
|
+
* Routes messages to topics based on patterns with priority-based delivery.
|
|
5
|
+
* Integrates with TopicManager for efficient pattern matching and
|
|
6
|
+
* PriorityQueue for ordered message delivery.
|
|
7
|
+
*
|
|
8
|
+
* Features:
|
|
9
|
+
* - Priority-based routing (0-10 scale, higher = more urgent)
|
|
10
|
+
* - Dead letter queue for failed deliveries
|
|
11
|
+
* - Message filtering and transformation
|
|
12
|
+
* - Subscription-based delivery with handlers
|
|
13
|
+
* - Delivery statistics and monitoring
|
|
14
|
+
*
|
|
15
|
+
* @module coordination/v2/core/message-router
|
|
16
|
+
*/ import { TopicManager } from './topic-manager.js';
|
|
17
|
+
import { PriorityQueue } from '../utils/priority-queue.js';
|
|
18
|
+
import { MessageUtils } from './message.js';
|
|
19
|
+
/**
|
|
20
|
+
* Message Router - Priority-based message routing with topic pattern matching.
|
|
21
|
+
*
|
|
22
|
+
* Routes messages to subscribed handlers based on topic patterns, with
|
|
23
|
+
* priority-based delivery ordering and dead letter queue for failures.
|
|
24
|
+
*
|
|
25
|
+
* Performance:
|
|
26
|
+
* - publish(): O(log n) for priority queue + O(log m) for topic matching
|
|
27
|
+
* - subscribe(): O(p) where p is pattern length
|
|
28
|
+
* - route(): O(k * h) where k is matched subscriptions, h is handler execution
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const router = new MessageRouter();
|
|
33
|
+
*
|
|
34
|
+
* // Subscribe to topics
|
|
35
|
+
* const sub = router.subscribe({
|
|
36
|
+
* topic: 'task.*',
|
|
37
|
+
* handler: async (msg) => {
|
|
38
|
+
* console.log('Task message:', msg.payload);
|
|
39
|
+
* }
|
|
40
|
+
* });
|
|
41
|
+
*
|
|
42
|
+
* // Publish messages
|
|
43
|
+
* await router.publish({
|
|
44
|
+
* topic: 'task.completed',
|
|
45
|
+
* payload: { taskId: '123', result: 'success' },
|
|
46
|
+
* priority: MessagePriority.HIGH
|
|
47
|
+
* });
|
|
48
|
+
*
|
|
49
|
+
* // Process message queue
|
|
50
|
+
* await router.processQueue();
|
|
51
|
+
* ```
|
|
52
|
+
*/ export class MessageRouter {
|
|
53
|
+
/** Topic pattern manager */ topicManager;
|
|
54
|
+
/** Priority queue for message ordering */ messageQueue;
|
|
55
|
+
/** Subscription handlers by ID */ handlers;
|
|
56
|
+
/** Dead letter queue for failed deliveries */ deadLetterQueue;
|
|
57
|
+
/** Router configuration */ config;
|
|
58
|
+
/** Statistics tracking */ stats;
|
|
59
|
+
/** Next subscription ID counter */ nextSubscriptionId;
|
|
60
|
+
/** Processing lock to prevent concurrent queue processing */ isProcessing;
|
|
61
|
+
constructor(config = {}){
|
|
62
|
+
this.topicManager = new TopicManager();
|
|
63
|
+
this.messageQueue = new PriorityQueue();
|
|
64
|
+
this.handlers = new Map();
|
|
65
|
+
this.deadLetterQueue = [];
|
|
66
|
+
this.config = {
|
|
67
|
+
maxDeadLetterQueueSize: config.maxDeadLetterQueueSize ?? 1000,
|
|
68
|
+
maxDeliveryAttempts: config.maxDeliveryAttempts ?? 3,
|
|
69
|
+
asyncHandlers: config.asyncHandlers ?? true,
|
|
70
|
+
handlerTimeout: config.handlerTimeout ?? 30000
|
|
71
|
+
};
|
|
72
|
+
this.stats = {
|
|
73
|
+
totalPublished: 0,
|
|
74
|
+
totalDelivered: 0,
|
|
75
|
+
totalFailed: 0,
|
|
76
|
+
deliveryTimes: [],
|
|
77
|
+
messagesByTopic: new Map(),
|
|
78
|
+
messagesByPriority: new Map()
|
|
79
|
+
};
|
|
80
|
+
this.nextSubscriptionId = 1;
|
|
81
|
+
this.isProcessing = false;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Publishes a message to the router.
|
|
85
|
+
* Message is added to priority queue for ordered delivery.
|
|
86
|
+
*
|
|
87
|
+
* @param config - Message configuration
|
|
88
|
+
* @returns Created message object
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* const message = await router.publish({
|
|
93
|
+
* topic: 'agent.status',
|
|
94
|
+
* payload: { agentId: 'agent-1', status: 'online' },
|
|
95
|
+
* priority: MessagePriority.NORMAL
|
|
96
|
+
* });
|
|
97
|
+
* ```
|
|
98
|
+
*/ publish(config) {
|
|
99
|
+
// Validate message configuration
|
|
100
|
+
MessageUtils.validateConfig(config);
|
|
101
|
+
// Create message
|
|
102
|
+
const message = {
|
|
103
|
+
id: MessageUtils.generateMessageId(),
|
|
104
|
+
topic: config.topic,
|
|
105
|
+
payload: config.payload,
|
|
106
|
+
priority: MessageUtils.normalizePriority(config.priority),
|
|
107
|
+
timestamp: Date.now(),
|
|
108
|
+
replyTo: config.replyTo,
|
|
109
|
+
correlationId: config.correlationId,
|
|
110
|
+
senderId: config.senderId,
|
|
111
|
+
recipientId: config.recipientId,
|
|
112
|
+
deliverySemantics: config.deliverySemantics,
|
|
113
|
+
metadata: config.metadata
|
|
114
|
+
};
|
|
115
|
+
// Add to priority queue
|
|
116
|
+
this.messageQueue.enqueue(message, message.priority);
|
|
117
|
+
// Update statistics
|
|
118
|
+
this.stats.totalPublished++;
|
|
119
|
+
this.stats.messagesByTopic.set(message.topic, (this.stats.messagesByTopic.get(message.topic) ?? 0) + 1);
|
|
120
|
+
this.stats.messagesByPriority.set(message.priority, (this.stats.messagesByPriority.get(message.priority) ?? 0) + 1);
|
|
121
|
+
return message;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Subscribes a handler to a topic pattern.
|
|
125
|
+
*
|
|
126
|
+
* @param config - Subscription configuration
|
|
127
|
+
* @returns Subscription handle
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```typescript
|
|
131
|
+
* const subscription = router.subscribe({
|
|
132
|
+
* topic: 'task.*.completed',
|
|
133
|
+
* handler: async (message) => {
|
|
134
|
+
* console.log('Task completed:', message.payload);
|
|
135
|
+
* },
|
|
136
|
+
* priority: 10
|
|
137
|
+
* });
|
|
138
|
+
* ```
|
|
139
|
+
*/ subscribe(config) {
|
|
140
|
+
const subscriptionId = `sub-${this.nextSubscriptionId++}`;
|
|
141
|
+
// Register pattern with topic manager
|
|
142
|
+
const topicId = this.topicManager.register(config.topic);
|
|
143
|
+
// Store handler
|
|
144
|
+
this.handlers.set(topicId, {
|
|
145
|
+
id: subscriptionId,
|
|
146
|
+
pattern: config.topic,
|
|
147
|
+
handler: config.handler,
|
|
148
|
+
priority: config.priority ?? 0,
|
|
149
|
+
processedCount: 0,
|
|
150
|
+
errorCount: 0,
|
|
151
|
+
createdAt: Date.now()
|
|
152
|
+
});
|
|
153
|
+
return {
|
|
154
|
+
id: subscriptionId,
|
|
155
|
+
topic: config.topic,
|
|
156
|
+
createdAt: Date.now(),
|
|
157
|
+
unsubscribe: ()=>this.unsubscribe(topicId)
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Unsubscribes a handler by topic ID.
|
|
162
|
+
*
|
|
163
|
+
* @param topicId - Topic registration ID
|
|
164
|
+
*/ unsubscribe(topicId) {
|
|
165
|
+
this.topicManager.deregister(topicId);
|
|
166
|
+
this.handlers.delete(topicId);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Processes the message queue, delivering messages to handlers.
|
|
170
|
+
* Messages are processed in priority order (highest priority first).
|
|
171
|
+
*
|
|
172
|
+
* @returns Number of messages processed
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```typescript
|
|
176
|
+
* const processed = await router.processQueue();
|
|
177
|
+
* console.log(`Processed ${processed} messages`);
|
|
178
|
+
* ```
|
|
179
|
+
*/ async processQueue() {
|
|
180
|
+
// Prevent concurrent processing
|
|
181
|
+
if (this.isProcessing) {
|
|
182
|
+
return 0;
|
|
183
|
+
}
|
|
184
|
+
this.isProcessing = true;
|
|
185
|
+
let processedCount = 0;
|
|
186
|
+
try {
|
|
187
|
+
while(!this.messageQueue.isEmpty()){
|
|
188
|
+
const message = this.messageQueue.dequeue();
|
|
189
|
+
if (!message) break;
|
|
190
|
+
await this.routeMessage(message);
|
|
191
|
+
processedCount++;
|
|
192
|
+
}
|
|
193
|
+
} finally{
|
|
194
|
+
this.isProcessing = false;
|
|
195
|
+
}
|
|
196
|
+
return processedCount;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Routes a single message to matching handlers.
|
|
200
|
+
*
|
|
201
|
+
* @param message - Message to route
|
|
202
|
+
*/ async routeMessage(message) {
|
|
203
|
+
const startTime = performance.now();
|
|
204
|
+
try {
|
|
205
|
+
// Find matching subscriptions
|
|
206
|
+
const matchedTopicIds = this.topicManager.match(message.topic);
|
|
207
|
+
if (matchedTopicIds.length === 0) {
|
|
208
|
+
// No handlers, message is dropped (consider logging)
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
// Get handlers and sort by priority (highest first)
|
|
212
|
+
const matchedHandlers = matchedTopicIds.map((id)=>this.handlers.get(id)).filter((h)=>h !== undefined).sort((a, b)=>b.priority - a.priority);
|
|
213
|
+
// Deliver to handlers
|
|
214
|
+
const deliveryPromises = matchedHandlers.map((handler)=>this.deliverToHandler(message, handler));
|
|
215
|
+
if (this.config.asyncHandlers) {
|
|
216
|
+
await Promise.allSettled(deliveryPromises);
|
|
217
|
+
} else {
|
|
218
|
+
for (const promise of deliveryPromises){
|
|
219
|
+
await promise;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
// Update statistics
|
|
223
|
+
this.stats.totalDelivered++;
|
|
224
|
+
const deliveryTime = performance.now() - startTime;
|
|
225
|
+
this.stats.deliveryTimes.push(deliveryTime);
|
|
226
|
+
// Keep only last 1000 delivery times for stats
|
|
227
|
+
if (this.stats.deliveryTimes.length > 1000) {
|
|
228
|
+
this.stats.deliveryTimes.shift();
|
|
229
|
+
}
|
|
230
|
+
} catch (error) {
|
|
231
|
+
this.stats.totalFailed++;
|
|
232
|
+
this.addToDeadLetterQueue(message, error, []);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Delivers a message to a specific handler.
|
|
237
|
+
*
|
|
238
|
+
* @param message - Message to deliver
|
|
239
|
+
* @param handler - Handler to deliver to
|
|
240
|
+
*/ async deliverToHandler(message, handler) {
|
|
241
|
+
try {
|
|
242
|
+
// Create timeout promise
|
|
243
|
+
const timeoutPromise = new Promise((_, reject)=>{
|
|
244
|
+
setTimeout(()=>reject(new Error(`Handler timeout after ${this.config.handlerTimeout}ms`)), this.config.handlerTimeout);
|
|
245
|
+
});
|
|
246
|
+
// Race handler execution against timeout
|
|
247
|
+
await Promise.race([
|
|
248
|
+
handler.handler(message),
|
|
249
|
+
timeoutPromise
|
|
250
|
+
]);
|
|
251
|
+
handler.processedCount++;
|
|
252
|
+
} catch (error) {
|
|
253
|
+
handler.errorCount++;
|
|
254
|
+
this.addToDeadLetterQueue(message, error, [
|
|
255
|
+
handler.id
|
|
256
|
+
]);
|
|
257
|
+
throw error;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Adds a message to the dead letter queue.
|
|
262
|
+
*
|
|
263
|
+
* @param message - Failed message
|
|
264
|
+
* @param error - Delivery error
|
|
265
|
+
* @param failedSubscriptions - Subscription IDs that failed
|
|
266
|
+
*/ addToDeadLetterQueue(message, error, failedSubscriptions) {
|
|
267
|
+
// Check if queue is full
|
|
268
|
+
if (this.deadLetterQueue.length >= this.config.maxDeadLetterQueueSize) {
|
|
269
|
+
// Remove oldest message (FIFO)
|
|
270
|
+
this.deadLetterQueue.shift();
|
|
271
|
+
}
|
|
272
|
+
this.deadLetterQueue.push({
|
|
273
|
+
message,
|
|
274
|
+
error,
|
|
275
|
+
attempts: 1,
|
|
276
|
+
timestamp: Date.now(),
|
|
277
|
+
failedSubscriptions
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Gets all messages in the dead letter queue.
|
|
282
|
+
*
|
|
283
|
+
* @returns Array of dead letter messages
|
|
284
|
+
*/ getDeadLetterQueue() {
|
|
285
|
+
return [
|
|
286
|
+
...this.deadLetterQueue
|
|
287
|
+
];
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Clears the dead letter queue.
|
|
291
|
+
*/ clearDeadLetterQueue() {
|
|
292
|
+
this.deadLetterQueue = [];
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Retries a message from the dead letter queue.
|
|
296
|
+
*
|
|
297
|
+
* @param messageId - ID of message to retry
|
|
298
|
+
* @returns True if message was found and requeued
|
|
299
|
+
*/ retryDeadLetterMessage(messageId) {
|
|
300
|
+
const index = this.deadLetterQueue.findIndex((dlm)=>dlm.message.id === messageId);
|
|
301
|
+
if (index === -1) {
|
|
302
|
+
return false;
|
|
303
|
+
}
|
|
304
|
+
const [deadLetter] = this.deadLetterQueue.splice(index, 1);
|
|
305
|
+
// Check if we've exceeded max attempts
|
|
306
|
+
if (deadLetter.attempts >= this.config.maxDeliveryAttempts) {
|
|
307
|
+
// Put it back (max retries exceeded)
|
|
308
|
+
this.deadLetterQueue.push(deadLetter);
|
|
309
|
+
return false;
|
|
310
|
+
}
|
|
311
|
+
// Increment attempts and requeue
|
|
312
|
+
deadLetter.attempts++;
|
|
313
|
+
this.messageQueue.enqueue(deadLetter.message, deadLetter.message.priority);
|
|
314
|
+
return true;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Gets router statistics.
|
|
318
|
+
*
|
|
319
|
+
* @returns Statistics object
|
|
320
|
+
*/ getStats() {
|
|
321
|
+
const avgDeliveryTime = this.stats.deliveryTimes.length > 0 ? this.stats.deliveryTimes.reduce((sum, t)=>sum + t, 0) / this.stats.deliveryTimes.length : 0;
|
|
322
|
+
const messagesByTopic = {};
|
|
323
|
+
for (const [topic, count] of Array.from(this.stats.messagesByTopic.entries())){
|
|
324
|
+
messagesByTopic[topic] = count;
|
|
325
|
+
}
|
|
326
|
+
const messagesByPriority = {};
|
|
327
|
+
for (const [priority, count] of Array.from(this.stats.messagesByPriority.entries())){
|
|
328
|
+
messagesByPriority[priority] = count;
|
|
329
|
+
}
|
|
330
|
+
const handlerStats = Array.from(this.handlers.values()).map((handler)=>({
|
|
331
|
+
id: handler.id,
|
|
332
|
+
pattern: handler.pattern,
|
|
333
|
+
processedCount: handler.processedCount,
|
|
334
|
+
errorCount: handler.errorCount
|
|
335
|
+
}));
|
|
336
|
+
return {
|
|
337
|
+
totalPublished: this.stats.totalPublished,
|
|
338
|
+
totalDelivered: this.stats.totalDelivered,
|
|
339
|
+
totalFailed: this.stats.totalFailed,
|
|
340
|
+
totalSubscriptions: this.handlers.size,
|
|
341
|
+
messagesByTopic,
|
|
342
|
+
messagesByPriority,
|
|
343
|
+
avgDeliveryTime,
|
|
344
|
+
deadLetterQueueSize: this.deadLetterQueue.length,
|
|
345
|
+
totalFailedDeliveries: this.deadLetterQueue.length,
|
|
346
|
+
handlerStats
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Gets the current queue size.
|
|
351
|
+
*
|
|
352
|
+
* @returns Number of messages in queue
|
|
353
|
+
*/ getQueueSize() {
|
|
354
|
+
return this.messageQueue.size();
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Clears all messages from the queue.
|
|
358
|
+
*/ clearQueue() {
|
|
359
|
+
this.messageQueue.clear();
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Resets all statistics.
|
|
363
|
+
*/ resetStats() {
|
|
364
|
+
this.stats = {
|
|
365
|
+
totalPublished: 0,
|
|
366
|
+
totalDelivered: 0,
|
|
367
|
+
totalFailed: 0,
|
|
368
|
+
deliveryTimes: [],
|
|
369
|
+
messagesByTopic: new Map(),
|
|
370
|
+
messagesByPriority: new Map()
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Clears all subscriptions, messages, and statistics.
|
|
375
|
+
*/ clear() {
|
|
376
|
+
this.topicManager.clear();
|
|
377
|
+
this.handlers.clear();
|
|
378
|
+
this.messageQueue.clear();
|
|
379
|
+
this.deadLetterQueue = [];
|
|
380
|
+
this.resetStats();
|
|
381
|
+
this.nextSubscriptionId = 1;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
//# sourceMappingURL=message-router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../src/coordination/archives/v2-sdk-typescript/v2/core/message-router.ts"],"names":["TopicManager","PriorityQueue","MessageUtils","MessageRouter","topicManager","messageQueue","handlers","deadLetterQueue","config","stats","nextSubscriptionId","isProcessing","Map","maxDeadLetterQueueSize","maxDeliveryAttempts","asyncHandlers","handlerTimeout","totalPublished","totalDelivered","totalFailed","deliveryTimes","messagesByTopic","messagesByPriority","publish","validateConfig","message","id","generateMessageId","topic","payload","priority","normalizePriority","timestamp","Date","now","replyTo","correlationId","senderId","recipientId","deliverySemantics","metadata","enqueue","set","get","subscribe","subscriptionId","topicId","register","pattern","handler","processedCount","errorCount","createdAt","unsubscribe","deregister","delete","processQueue","isEmpty","dequeue","routeMessage","startTime","performance","matchedTopicIds","match","length","matchedHandlers","map","filter","h","undefined","sort","a","b","deliveryPromises","deliverToHandler","Promise","allSettled","promise","deliveryTime","push","shift","error","addToDeadLetterQueue","timeoutPromise","_","reject","setTimeout","Error","race","failedSubscriptions","attempts","getDeadLetterQueue","clearDeadLetterQueue","retryDeadLetterMessage","messageId","index","findIndex","dlm","deadLetter","splice","getStats","avgDeliveryTime","reduce","sum","t","count","Array","from","entries","handlerStats","values","totalSubscriptions","size","deadLetterQueueSize","totalFailedDeliveries","getQueueSize","clearQueue","clear","resetStats"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,YAAY,QAAQ,qBAAqB;AAClD,SAASC,aAAa,QAAQ,6BAA6B;AAC3D,SAMEC,YAAY,QAGP,eAAe;AAoFtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiCC,GACD,OAAO,MAAMC;IACX,0BAA0B,GAC1B,AAAQC,aAA2B;IAEnC,wCAAwC,GACxC,AAAQC,aAAqC;IAE7C,gCAAgC,GAChC,AAAQC,SAA2C;IAEnD,4CAA4C,GAC5C,AAAQC,gBAAqC;IAE7C,yBAAyB,GACzB,AAAQC,OAA+B;IAEvC,wBAAwB,GACxB,AAAQC,MAON;IAEF,iCAAiC,GACjC,AAAQC,mBAA2B;IAEnC,2DAA2D,GAC3D,AAAQC,aAAsB;IAE9B,YAAYH,SAAuB,CAAC,CAAC,CAAE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I,CAAC+G,UAAU;QACf,IAAI,CAAC5G,kBAAkB,GAAG;IAC5B;AACF"}
|
package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message.js
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Coordination V2 - Message Interface and Types
|
|
3
|
+
*
|
|
4
|
+
* Defines the core message structure for the message bus, supporting
|
|
5
|
+
* pub/sub, request/reply, and broadcast communication patterns.
|
|
6
|
+
*
|
|
7
|
+
* @module coordination/v2/core/message
|
|
8
|
+
*/ /**
|
|
9
|
+
* Message priority levels (0-10 scale).
|
|
10
|
+
* Higher values indicate more urgent messages.
|
|
11
|
+
*/ export var MessagePriority = /*#__PURE__*/ function(MessagePriority) {
|
|
12
|
+
/** Critical system messages (10) */ MessagePriority[MessagePriority["CRITICAL"] = 10] = "CRITICAL";
|
|
13
|
+
/** High priority operational messages (8) */ MessagePriority[MessagePriority["HIGH"] = 8] = "HIGH";
|
|
14
|
+
/** Normal priority messages (5) - default */ MessagePriority[MessagePriority["NORMAL"] = 5] = "NORMAL";
|
|
15
|
+
/** Low priority background messages (2) */ MessagePriority[MessagePriority["LOW"] = 2] = "LOW";
|
|
16
|
+
/** Informational/logging messages (0) */ MessagePriority[MessagePriority["INFORMATIONAL"] = 0] = "INFORMATIONAL";
|
|
17
|
+
return MessagePriority;
|
|
18
|
+
}({});
|
|
19
|
+
/**
|
|
20
|
+
* Message delivery semantics.
|
|
21
|
+
*/ export var DeliverySemantics = /*#__PURE__*/ function(DeliverySemantics) {
|
|
22
|
+
/** At-least-once delivery (default) */ DeliverySemantics["AT_LEAST_ONCE"] = "at-least-once";
|
|
23
|
+
/** At-most-once delivery (fire-and-forget) */ DeliverySemantics["AT_MOST_ONCE"] = "at-most-once";
|
|
24
|
+
/** Exactly-once delivery (requires deduplication) */ DeliverySemantics["EXACTLY_ONCE"] = "exactly-once";
|
|
25
|
+
return DeliverySemantics;
|
|
26
|
+
}({});
|
|
27
|
+
/**
|
|
28
|
+
* Message validation error.
|
|
29
|
+
*/ export class MessageValidationError extends Error {
|
|
30
|
+
messageId;
|
|
31
|
+
constructor(message, messageId){
|
|
32
|
+
super(message), this.messageId = messageId;
|
|
33
|
+
this.name = 'MessageValidationError';
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Utility functions for message validation and creation.
|
|
38
|
+
*/ export class MessageUtils {
|
|
39
|
+
/**
|
|
40
|
+
* Validates a message configuration.
|
|
41
|
+
*
|
|
42
|
+
* @param config - Message configuration to validate
|
|
43
|
+
* @throws {MessageValidationError} If configuration is invalid
|
|
44
|
+
*/ static validateConfig(config) {
|
|
45
|
+
if (!config.topic || typeof config.topic !== 'string') {
|
|
46
|
+
throw new MessageValidationError('Message topic must be a non-empty string');
|
|
47
|
+
}
|
|
48
|
+
if (config.payload === undefined || config.payload === null) {
|
|
49
|
+
throw new MessageValidationError('Message payload is required');
|
|
50
|
+
}
|
|
51
|
+
if (config.priority !== undefined) {
|
|
52
|
+
if (typeof config.priority !== 'number' || isNaN(config.priority)) {
|
|
53
|
+
throw new MessageValidationError('Priority must be a valid number');
|
|
54
|
+
}
|
|
55
|
+
if (config.priority < 0 || config.priority > 10) {
|
|
56
|
+
throw new MessageValidationError('Priority must be between 0 and 10');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (config.replyTo !== undefined && typeof config.replyTo !== 'string') {
|
|
60
|
+
throw new MessageValidationError('Reply-to must be a string');
|
|
61
|
+
}
|
|
62
|
+
if (config.correlationId !== undefined && typeof config.correlationId !== 'string') {
|
|
63
|
+
throw new MessageValidationError('Correlation ID must be a string');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Normalizes priority to valid range (0-10).
|
|
68
|
+
*
|
|
69
|
+
* @param priority - Priority value to normalize
|
|
70
|
+
* @returns Normalized priority
|
|
71
|
+
*/ static normalizePriority(priority) {
|
|
72
|
+
if (priority === undefined || priority === null) {
|
|
73
|
+
return 5;
|
|
74
|
+
}
|
|
75
|
+
if (typeof priority !== 'number' || isNaN(priority)) {
|
|
76
|
+
return 5;
|
|
77
|
+
}
|
|
78
|
+
return Math.max(0, Math.min(10, Math.round(priority)));
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Generates a unique message ID.
|
|
82
|
+
*
|
|
83
|
+
* @returns UUID v4 string
|
|
84
|
+
*/ static generateMessageId() {
|
|
85
|
+
return `msg-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Generates a unique correlation ID.
|
|
89
|
+
*
|
|
90
|
+
* @returns UUID v4 string
|
|
91
|
+
*/ static generateCorrelationId() {
|
|
92
|
+
return `corr-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Checks if a topic matches a topic pattern (supports wildcards).
|
|
96
|
+
*
|
|
97
|
+
* @param topic - Actual message topic
|
|
98
|
+
* @param pattern - Topic pattern (supports * and **)
|
|
99
|
+
* @returns True if topic matches pattern
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```typescript
|
|
103
|
+
* MessageUtils.matchesTopic('task.completed', 'task.*'); // true
|
|
104
|
+
* MessageUtils.matchesTopic('agent.status.online', 'agent.**'); // true
|
|
105
|
+
* MessageUtils.matchesTopic('task.failed', 'task.completed'); // false
|
|
106
|
+
* ```
|
|
107
|
+
*/ static matchesTopic(topic, pattern) {
|
|
108
|
+
if (pattern === '*' || pattern === '**') {
|
|
109
|
+
return true; // Match all
|
|
110
|
+
}
|
|
111
|
+
if (!pattern.includes('*')) {
|
|
112
|
+
return topic === pattern; // Exact match
|
|
113
|
+
}
|
|
114
|
+
// Convert pattern to regex
|
|
115
|
+
const regexPattern = pattern.replace(/\./g, '\\.').replace(/\*\*/g, '.*').replace(/\*/g, '[^.]*');
|
|
116
|
+
const regex = new RegExp(`^${regexPattern}$`);
|
|
117
|
+
return regex.test(topic);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Creates a reply message from a request.
|
|
121
|
+
*
|
|
122
|
+
* @param request - Original request message
|
|
123
|
+
* @param payload - Reply payload
|
|
124
|
+
* @param success - Success status (default: true)
|
|
125
|
+
* @param error - Error message if failed
|
|
126
|
+
* @returns Reply object
|
|
127
|
+
*/ static createReply(request, payload, success = true, error) {
|
|
128
|
+
return {
|
|
129
|
+
correlationId: request.correlationId || request.id,
|
|
130
|
+
payload,
|
|
131
|
+
success,
|
|
132
|
+
error,
|
|
133
|
+
timestamp: Date.now()
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
//# sourceMappingURL=message.js.map
|
package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../src/coordination/archives/v2-sdk-typescript/v2/core/message.ts"],"names":["MessagePriority","DeliverySemantics","MessageValidationError","Error","message","messageId","name","MessageUtils","validateConfig","config","topic","payload","undefined","priority","isNaN","replyTo","correlationId","normalizePriority","Math","max","min","round","generateMessageId","Date","now","random","toString","substr","generateCorrelationId","matchesTopic","pattern","includes","regexPattern","replace","regex","RegExp","test","createReply","request","success","error","id","timestamp"],"mappings":"AAAA;;;;;;;CAOC,GAED;;;CAGC,GACD,OAAO,IAAA,AAAKA,yCAAAA;IACV,kCAAkC;IAGlC,2CAA2C;IAG3C,2CAA2C;IAG3C,yCAAyC;IAGzC,uCAAuC;WAb7BA;MAeX;AAED;;CAEC,GACD,OAAO,IAAA,AAAKC,2CAAAA;IACV,qCAAqC;IAGrC,4CAA4C;IAG5C,mDAAmD;WAPzCA;MASX;AA2FD;;CAEC,GACD,OAAO,MAAMC,+BAA+BC;;IAC1C,YAAYC,OAAe,EAAE,AAAgBC,SAAkB,CAAE;QAC/D,KAAK,CA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