claude-flow-novice 1.6.1 → 1.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/agents/cfn-loop/product-owner.md +54 -4
- package/.claude/commands/cfn-claude-sync.md +303 -0
- package/.claude/commands/cfn-loop-epic.md +290 -0
- package/.claude/commands/cfn-loop-single.md +168 -0
- package/.claude/commands/cfn-loop-sprints.md +384 -0
- package/.claude/commands/cfn-loop.md +180 -0
- package/.claude/commands/metrics-summary.md +58 -0
- package/.claude/commands/parse-epic.md +357 -0
- package/.claude/settings.json +5 -4
- package/.claude/settings.local.json +9 -2
- package/.claude-flow-novice/.claude/agents/cfn-loop/product-owner.md +792 -0
- package/.claude-flow-novice/dist/mcp/server.js +21 -2
- package/.claude-flow-novice/dist/src/api/auth-service.js +84 -38
- package/.claude-flow-novice/dist/src/api/auth-service.js.map +1 -1
- package/.claude-flow-novice/dist/src/api/claude-client.js +138 -3
- package/.claude-flow-novice/dist/src/api/claude-client.js.map +1 -1
- package/.claude-flow-novice/dist/src/cfn-loop/phase-orchestrator-example.js +1 -1
- package/.claude-flow-novice/dist/src/cfn-loop/scope-control.js +247 -0
- package/.claude-flow-novice/dist/src/cfn-loop/scope-control.js.map +1 -0
- package/.claude-flow-novice/dist/src/cli/commands/swarm.js +32 -15
- package/.claude-flow-novice/dist/src/cli/commands/swarm.js.map +1 -1
- package/.claude-flow-novice/dist/src/cli/commands/transparency.js +455 -0
- package/.claude-flow-novice/dist/src/cli/commands/transparency.js.map +1 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/CLAUDE.md +129 -13
- package/.claude-flow-novice/dist/src/components/visualizations/index.js +9 -0
- package/.claude-flow-novice/dist/src/components/visualizations/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/adapters/v1-coordinator-adapter.js +462 -0
- package/.claude-flow-novice/dist/src/coordination/adapters/v1-coordinator-adapter.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/config-translator.js +248 -0
- package/.claude-flow-novice/dist/src/coordination/config-translator.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/coordination-toggle.js +287 -0
- package/.claude-flow-novice/dist/src/coordination/coordination-toggle.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/distributed-consensus.js +68 -9
- package/.claude-flow-novice/dist/src/coordination/distributed-consensus.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/feature-flags.js +166 -0
- package/.claude-flow-novice/dist/src/coordination/feature-flags.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/queen-agent.js +18 -4
- package/.claude-flow-novice/dist/src/coordination/queen-agent.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/role-assignment.js +6 -110
- package/.claude-flow-novice/dist/src/coordination/role-assignment.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/v2/cache/artifact-cache-optimizer.js +632 -0
- package/.claude-flow-novice/dist/src/coordination/v2/cache/artifact-cache-optimizer.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/cache/index.js +11 -0
- package/.claude-flow-novice/dist/src/coordination/v2/cache/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/checkpoints/checkpoint-compressor.js +318 -0
- package/.claude-flow-novice/dist/src/coordination/v2/checkpoints/checkpoint-compressor.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/coordinators/cascading-shutdown.example.js +364 -0
- package/.claude-flow-novice/dist/src/coordination/v2/coordinators/cascading-shutdown.example.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/coordinators/cascading-shutdown.js +492 -0
- package/.claude-flow-novice/dist/src/coordination/v2/coordinators/cascading-shutdown.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/coordinators/hierarchical-coordinator.js +786 -0
- package/.claude-flow-novice/dist/src/coordination/v2/coordinators/hierarchical-coordinator.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/coordinators/index.js +16 -0
- package/.claude-flow-novice/dist/src/coordination/v2/coordinators/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/coordinators/parent-child-manager.js +342 -0
- package/.claude-flow-novice/dist/src/coordination/v2/coordinators/parent-child-manager.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/coordinators/swarm-coordinator-v2.js +601 -0
- package/.claude-flow-novice/dist/src/coordination/v2/coordinators/swarm-coordinator-v2.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/core/help-request-metrics.js +211 -0
- package/.claude-flow-novice/dist/src/coordination/v2/core/help-request-metrics.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/core/index.js +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/core/index.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/v2/core/message-broker.js +365 -6
- package/.claude-flow-novice/dist/src/coordination/v2/core/message-broker.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/v2/core/resource-manager-safe.js +478 -0
- package/.claude-flow-novice/dist/src/coordination/v2/core/resource-manager-safe.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/core/state-machine-config.js +5 -2
- package/.claude-flow-novice/dist/src/coordination/v2/core/state-machine-config.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/v2/core/state-machine.js +189 -0
- package/.claude-flow-novice/dist/src/coordination/v2/core/state-machine.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/v2/deadlock/deadlock-detector.js +424 -0
- package/.claude-flow-novice/dist/src/coordination/v2/deadlock/deadlock-detector.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/deadlock/index.js +9 -0
- package/.claude-flow-novice/dist/src/coordination/v2/deadlock/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/deadlock/resource-manager.js +669 -0
- package/.claude-flow-novice/dist/src/coordination/v2/deadlock/resource-manager.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/artifact-storage.js +451 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/artifact-storage.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/cycle-detector.js +271 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/cycle-detector.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-graph.js +335 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-graph.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-manager.js +439 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-manager.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-request.js +92 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-request.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/index.js +21 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/topological-sort.js +223 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/topological-sort.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-coordinator.js +436 -0
- package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-coordinator.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-matcher.js +278 -0
- package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-matcher.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-request-handler.js +317 -0
- package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-request-handler.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-request.js +273 -0
- package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-request.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/help-system/index.js +15 -0
- package/.claude-flow-novice/dist/src/coordination/v2/help-system/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/help-system/waiting-agent-pool.js +512 -0
- package/.claude-flow-novice/dist/src/coordination/v2/help-system/waiting-agent-pool.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/index.js +6 -0
- package/.claude-flow-novice/dist/src/coordination/v2/index.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/v2/integration/help-deadlock-integration.js +557 -0
- package/.claude-flow-novice/dist/src/coordination/v2/integration/help-deadlock-integration.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/integration/index.js +14 -0
- package/.claude-flow-novice/dist/src/coordination/v2/integration/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/integration/message-bus-completion-integration.example.js +212 -0
- package/.claude-flow-novice/dist/src/coordination/v2/integration/message-bus-completion-integration.example.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/integration/message-bus-completion-integration.js +552 -0
- package/.claude-flow-novice/dist/src/coordination/v2/integration/message-bus-completion-integration.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/memory/dependency-storage.js +367 -0
- package/.claude-flow-novice/dist/src/coordination/v2/memory/dependency-storage.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/memory/index.js +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/memory/index.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/channel.js +371 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/channel.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/dependency-channel.js +355 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/dependency-channel.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/help-channel.js +424 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/help-channel.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/index.js +16 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/state-channel.js +295 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/state-channel.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/task-channel.js +411 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/task-channel.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/index.js +14 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-bus.js +387 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-bus.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-persistence.js +589 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-persistence.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-router.js +444 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-router.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/checkpoint-manager.js +29 -8
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/checkpoint-manager.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/help-coordinator.js +470 -0
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/help-coordinator.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/hierarchical-background-integration.js +450 -0
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/hierarchical-background-integration.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/index.js +5 -0
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/index.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/multi-level-control.js +545 -0
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/multi-level-control.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/query-controller.js +44 -0
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/query-controller.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/query-message-integration.js +415 -0
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/query-message-integration.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/session-pool-optimizer.js +615 -0
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/session-pool-optimizer.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/security/payload-validator.js +259 -0
- package/.claude-flow-novice/dist/src/coordination/v2/security/payload-validator.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/transparency/index.js +17 -0
- package/.claude-flow-novice/dist/src/coordination/v2/transparency/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/transparency/transparency-integration.js +357 -0
- package/.claude-flow-novice/dist/src/coordination/v2/transparency/transparency-integration.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/transparency/transparency-system.js +679 -0
- package/.claude-flow-novice/dist/src/coordination/v2/transparency/transparency-system.js.map +1 -0
- package/.claude-flow-novice/dist/src/core/agent-manager.js +30 -0
- package/.claude-flow-novice/dist/src/core/agent-manager.js.map +1 -1
- package/.claude-flow-novice/dist/src/mcp/server.js +21 -2
- package/.claude-flow-novice/dist/src/mcp/server.js.map +1 -1
- package/.claude-flow-novice/dist/src/monitoring/apm/apm-integration.js +719 -0
- package/.claude-flow-novice/dist/src/monitoring/apm/apm-integration.js.map +1 -0
- package/.claude-flow-novice/dist/src/monitoring/apm/datadog-collector.js +363 -0
- package/.claude-flow-novice/dist/src/monitoring/apm/datadog-collector.js.map +1 -0
- package/.claude-flow-novice/dist/src/monitoring/apm/index.js +97 -0
- package/.claude-flow-novice/dist/src/monitoring/apm/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/monitoring/apm/newrelic-collector.js +384 -0
- package/.claude-flow-novice/dist/src/monitoring/apm/newrelic-collector.js.map +1 -0
- package/.claude-flow-novice/dist/src/monitoring/apm/performance-optimizer.js +612 -0
- package/.claude-flow-novice/dist/src/monitoring/apm/performance-optimizer.js.map +1 -0
- package/.claude-flow-novice/dist/src/monitoring/metrics-collector.js +282 -0
- package/.claude-flow-novice/dist/src/monitoring/metrics-collector.js.map +1 -0
- package/.claude-flow-novice/dist/src/observability/metrics-counter.js +268 -0
- package/.claude-flow-novice/dist/src/observability/metrics-counter.js.map +1 -0
- package/.claude-flow-novice/dist/src/observability/metrics-storage.js +265 -0
- package/.claude-flow-novice/dist/src/observability/metrics-storage.js.map +1 -0
- package/.claude-flow-novice/dist/src/observability/telemetry.js +26 -0
- package/.claude-flow-novice/dist/src/observability/telemetry.js.map +1 -1
- package/.claude-flow-novice/dist/src/providers/tiered-router.js +64 -10
- package/.claude-flow-novice/dist/src/providers/tiered-router.js.map +1 -1
- package/.claude-flow-novice/dist/src/providers/zai-provider.js +196 -97
- package/.claude-flow-novice/dist/src/providers/zai-provider.js.map +1 -1
- package/.claude-flow-novice/dist/src/slash-commands/cfn-claude-sync.js +533 -0
- package/.claude-flow-novice/dist/src/slash-commands/index.js +5 -0
- package/.claude-flow-novice/dist/src/slash-commands/metrics-summary-class.js +74 -0
- package/.claude-flow-novice/dist/src/slash-commands/metrics-summary.js +335 -0
- package/.claude-flow-novice/dist/src/slash-commands/register-all-commands.js +12 -0
- package/.claude-flow-novice/dist/src/verification/checkpoint-compression-demo.js +96 -0
- package/.claude-flow-novice/dist/src/verification/checkpoint-compression-demo.js.map +1 -0
- package/.claude-flow-novice/dist/src/verification/checkpoint-compression.js +406 -0
- package/.claude-flow-novice/dist/src/verification/checkpoint-compression.js.map +1 -0
- package/.claude-flow-novice/dist/src/verification/checkpoint-manager.js +35 -5
- package/.claude-flow-novice/dist/src/verification/checkpoint-manager.js.map +1 -1
- package/.claude-flow-novice/dist/src/web/api/apm-routes.js +355 -0
- package/.claude-flow-novice/dist/src/web/api/apm-routes.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/api/config/api-config.js +186 -0
- package/.claude-flow-novice/dist/src/web/api/config/api-config.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/api/middleware/auth.js +205 -0
- package/.claude-flow-novice/dist/src/web/api/middleware/auth.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/api/middleware/cache.js +262 -0
- package/.claude-flow-novice/dist/src/web/api/middleware/cache.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/api/middleware/error-handler.js +250 -0
- package/.claude-flow-novice/dist/src/web/api/middleware/error-handler.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/api/middleware/request-logger.js +217 -0
- package/.claude-flow-novice/dist/src/web/api/middleware/request-logger.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/api/middleware/validation.js +325 -0
- package/.claude-flow-novice/dist/src/web/api/middleware/validation.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/api/routes/events.js +465 -0
- package/.claude-flow-novice/dist/src/web/api/routes/events.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/api/routes/hierarchy.js +302 -0
- package/.claude-flow-novice/dist/src/web/api/routes/hierarchy.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/api/routes/index.js +14 -0
- package/.claude-flow-novice/dist/src/web/api/routes/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/api/routes/metrics.js +561 -0
- package/.claude-flow-novice/dist/src/web/api/routes/metrics.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/api/routes/status.js +450 -0
- package/.claude-flow-novice/dist/src/web/api/routes/status.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/api/server.js +451 -0
- package/.claude-flow-novice/dist/src/web/api/server.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/dashboard/hooks/useWebSocket.js +385 -0
- package/.claude-flow-novice/dist/src/web/dashboard/hooks/useWebSocket.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/dashboard/index.js +87 -0
- package/.claude-flow-novice/dist/src/web/dashboard/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/dashboard/types.js +6 -0
- package/.claude-flow-novice/dist/src/web/dashboard/types.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/frontend/src/utils/security.js +425 -0
- package/.claude-flow-novice/dist/src/web/frontend/src/utils/security.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/security/security-middleware.js +379 -0
- package/.claude-flow-novice/dist/src/web/security/security-middleware.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/websocket/apm-websocket-handler.js +441 -0
- package/.claude-flow-novice/dist/src/web/websocket/apm-websocket-handler.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/websocket/websocket-manager.js +255 -1
- package/.claude-flow-novice/dist/src/web/websocket/websocket-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/AGENT_PERFORMANCE_GUIDELINES.md +88 -0
- package/CLAUDE.md +60 -3
- package/MEMORY_LEAK_ROOT_CAUSE.md +149 -0
- package/README.md +27 -0
- package/config/hooks/post-edit-pipeline.js +36 -2
- package/examples/metrics-counter-demo.ts +106 -0
- package/examples/persistent-metrics-demo.ts +83 -0
- package/examples/phase-5-multi-level-control.ts +282 -0
- package/examples/session-pool-optimizer-example.ts +311 -0
- package/package.json +18 -4
- package/scripts/check-routing-stats.cjs +122 -0
- package/scripts/monitor-loop.sh +65 -0
- package/scripts/monitor-memory.sh +47 -0
- package/scripts/monitor.py +43 -0
- package/scripts/pre-publish-validation.cjs +212 -0
- package/scripts/test-provider-routing.cjs +228 -0
- package/scripts/test-routing-telemetry.cjs +147 -0
- package/scripts/test-zai-10k.cjs +81 -0
- package/scripts/test-zai-api.cjs +191 -0
- package/scripts/test-zai-diagnostic.cjs +151 -0
- package/scripts/test-zai-final.cjs +128 -0
- package/scripts/test-zai-with-env.cjs +85 -0
- package/scripts/validate-coordination-cli.js +69 -0
- package/scripts/validate-coordination-toggle-integration.cjs +501 -0
- package/src/cli/simple-commands/init/templates/CLAUDE.md +29 -0
- package/src/observability/metrics-counter.ts +347 -0
- package/src/observability/metrics-storage.ts +356 -0
- package/src/observability/telemetry.ts +658 -0
- package/src/slash-commands/cfn-claude-sync.js +533 -0
- package/src/slash-commands/index.js +5 -0
- package/src/slash-commands/metrics-summary-class.js +74 -0
- package/src/slash-commands/metrics-summary.js +335 -0
- package/src/slash-commands/register-all-commands.js +12 -0
|
@@ -0,0 +1,492 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Coordination V2 - Cascading Shutdown Coordinator
|
|
3
|
+
*
|
|
4
|
+
* Hierarchical shutdown coordination with top-down notification and bottom-up completion.
|
|
5
|
+
* Implements graceful termination with resource cleanup at all levels.
|
|
6
|
+
*
|
|
7
|
+
* Performance targets:
|
|
8
|
+
* - Complete hierarchy shutdown: <1s for 20 agents
|
|
9
|
+
* - Top-down notification: <100ms per level
|
|
10
|
+
* - Bottom-up aggregation: <200ms total
|
|
11
|
+
* - Resource cleanup: 100% coverage
|
|
12
|
+
*
|
|
13
|
+
* Features:
|
|
14
|
+
* - Top-down shutdown notification (root → leaves)
|
|
15
|
+
* - Bottom-up completion aggregation (leaves → root)
|
|
16
|
+
* - Graceful resource cleanup (connections, files, processes)
|
|
17
|
+
* - Integration with Phase 4 hierarchical completion detection
|
|
18
|
+
* - Emergency shutdown support
|
|
19
|
+
* - Shutdown checkpoint creation
|
|
20
|
+
*
|
|
21
|
+
* @module coordination/v2/coordinators/cascading-shutdown
|
|
22
|
+
*/ import { EventEmitter } from 'events';
|
|
23
|
+
/**
|
|
24
|
+
* CascadingShutdown - Top-down shutdown with bottom-up completion
|
|
25
|
+
*
|
|
26
|
+
* Implements hierarchical shutdown coordination:
|
|
27
|
+
* 1. Top-down: Notify all levels from root → leaves
|
|
28
|
+
* 2. Parallel: Each level executes shutdown simultaneously
|
|
29
|
+
* 3. Bottom-up: Aggregate completion from leaves → root
|
|
30
|
+
* 4. Cleanup: Resource cleanup at each level
|
|
31
|
+
* 5. Checkpoint: Optional checkpoint creation
|
|
32
|
+
*
|
|
33
|
+
* Shutdown flow:
|
|
34
|
+
* - Level 0 (root) initiates shutdown
|
|
35
|
+
* - Notify Level 1 agents → Notify Level 2 agents → ... → Notify Level N agents
|
|
36
|
+
* - Level N agents complete → Level N-1 aggregates → ... → Level 0 completes
|
|
37
|
+
* - Children complete before parents (bottom-up guarantee)
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* const cascadingShutdown = new CascadingShutdown(
|
|
42
|
+
* hierarchicalDetector,
|
|
43
|
+
* {
|
|
44
|
+
* maxShutdownTimeMs: 10000,
|
|
45
|
+
* createShutdownCheckpoints: true,
|
|
46
|
+
* enableResourceCleanup: true
|
|
47
|
+
* }
|
|
48
|
+
* );
|
|
49
|
+
*
|
|
50
|
+
* // Register hierarchy
|
|
51
|
+
* cascadingShutdown.registerHierarchy('swarm-1', 'coordinator-0', [
|
|
52
|
+
* { agentId: 'coordinator-0', level: 0, childIds: ['agent-1', 'agent-2'] },
|
|
53
|
+
* { agentId: 'agent-1', level: 1, parentId: 'coordinator-0' },
|
|
54
|
+
* { agentId: 'agent-2', level: 1, parentId: 'coordinator-0' }
|
|
55
|
+
* ]);
|
|
56
|
+
*
|
|
57
|
+
* // Initiate shutdown from root
|
|
58
|
+
* const result = await cascadingShutdown.initiateShutdown('coordinator-0', 'Task completed');
|
|
59
|
+
*
|
|
60
|
+
* console.log(`Shutdown ${result.totalAgents} agents in ${result.totalLatencyMs}ms`);
|
|
61
|
+
* ```
|
|
62
|
+
*/ export class CascadingShutdown extends EventEmitter {
|
|
63
|
+
hierarchies = new Map();
|
|
64
|
+
hierarchicalDetector;
|
|
65
|
+
config;
|
|
66
|
+
shutdownInProgress = new Set();
|
|
67
|
+
resourceCleanupHandlers = new Map();
|
|
68
|
+
constructor(hierarchicalDetector, config){
|
|
69
|
+
super();
|
|
70
|
+
this.hierarchicalDetector = hierarchicalDetector;
|
|
71
|
+
this.config = {
|
|
72
|
+
maxShutdownTimeMs: 10000,
|
|
73
|
+
createShutdownCheckpoints: true,
|
|
74
|
+
enableResourceCleanup: true,
|
|
75
|
+
notificationTimeoutMs: 100,
|
|
76
|
+
completionTimeoutMs: 200,
|
|
77
|
+
enableEmergencyMode: true,
|
|
78
|
+
agentGracePeriodMs: 500,
|
|
79
|
+
...config
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Register hierarchy for shutdown coordination
|
|
84
|
+
*
|
|
85
|
+
* @param swarmId - Swarm identifier
|
|
86
|
+
* @param rootCoordinatorId - Root coordinator agent ID (Level 0)
|
|
87
|
+
* @param nodes - Hierarchy node definitions
|
|
88
|
+
*/ registerHierarchy(swarmId, rootCoordinatorId, nodes) {
|
|
89
|
+
const hierarchyNodes = new Map();
|
|
90
|
+
// Build hierarchy nodes
|
|
91
|
+
for (const node of nodes){
|
|
92
|
+
hierarchyNodes.set(node.agentId, {
|
|
93
|
+
agentId: node.agentId,
|
|
94
|
+
level: node.level,
|
|
95
|
+
parentId: node.parentId,
|
|
96
|
+
childIds: node.childIds || [],
|
|
97
|
+
shutdownStatus: 'pending',
|
|
98
|
+
resources: node.resources || [],
|
|
99
|
+
sessionId: node.sessionId
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
// Ensure root coordinator exists
|
|
103
|
+
if (!hierarchyNodes.has(rootCoordinatorId)) {
|
|
104
|
+
hierarchyNodes.set(rootCoordinatorId, {
|
|
105
|
+
agentId: rootCoordinatorId,
|
|
106
|
+
level: 0,
|
|
107
|
+
childIds: [],
|
|
108
|
+
shutdownStatus: 'pending',
|
|
109
|
+
resources: []
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
// Build parent-child relationships if not provided
|
|
113
|
+
const nodesArray2 = Array.from(hierarchyNodes.values());
|
|
114
|
+
for (const node of nodesArray2){
|
|
115
|
+
if (node.parentId && hierarchyNodes.has(node.parentId)) {
|
|
116
|
+
const parent = hierarchyNodes.get(node.parentId);
|
|
117
|
+
if (!parent.childIds.includes(node.agentId)) {
|
|
118
|
+
parent.childIds.push(node.agentId);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
this.hierarchies.set(swarmId, hierarchyNodes);
|
|
123
|
+
const nodesArray = Array.from(hierarchyNodes.values());
|
|
124
|
+
this.emit('hierarchy:registered', {
|
|
125
|
+
swarmId,
|
|
126
|
+
rootCoordinatorId,
|
|
127
|
+
totalAgents: hierarchyNodes.size,
|
|
128
|
+
maxDepth: Math.max(...nodesArray.map((n)=>n.level))
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Register resource cleanup handler for specific resource type
|
|
133
|
+
*
|
|
134
|
+
* @param resourceType - Type of resource to handle
|
|
135
|
+
* @param handler - Cleanup handler function
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```typescript
|
|
139
|
+
* cascadingShutdown.registerResourceCleanup('connection', async (resource) => {
|
|
140
|
+
* await closeConnection(resource.id);
|
|
141
|
+
* });
|
|
142
|
+
* ```
|
|
143
|
+
*/ registerResourceCleanup(resourceType, handler) {
|
|
144
|
+
this.resourceCleanupHandlers.set(resourceType, handler);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Initiate cascading shutdown from root coordinator
|
|
148
|
+
*
|
|
149
|
+
* Performance target: <1s for 20-agent hierarchy
|
|
150
|
+
*
|
|
151
|
+
* Process:
|
|
152
|
+
* 1. Top-down notification (root → leaves)
|
|
153
|
+
* 2. Parallel shutdown execution at each level
|
|
154
|
+
* 3. Bottom-up completion aggregation (leaves → root)
|
|
155
|
+
* 4. Resource cleanup at all levels
|
|
156
|
+
*
|
|
157
|
+
* @param rootCoordinatorId - Root coordinator to initiate from
|
|
158
|
+
* @param reason - Shutdown reason
|
|
159
|
+
* @param swarmId - Optional swarm ID (auto-detect if omitted)
|
|
160
|
+
* @returns Promise resolving to CascadingShutdownResult
|
|
161
|
+
*/ async initiateShutdown(rootCoordinatorId, reason = 'Cascading shutdown initiated', swarmId) {
|
|
162
|
+
const startTime = Date.now();
|
|
163
|
+
// Find swarm containing root coordinator
|
|
164
|
+
const targetSwarmId = swarmId || this.findSwarmByAgent(rootCoordinatorId);
|
|
165
|
+
if (!targetSwarmId) {
|
|
166
|
+
throw new Error(`Root coordinator ${rootCoordinatorId} not found in any hierarchy`);
|
|
167
|
+
}
|
|
168
|
+
const hierarchy = this.hierarchies.get(targetSwarmId);
|
|
169
|
+
if (!hierarchy) {
|
|
170
|
+
throw new Error(`Hierarchy not found for swarm ${targetSwarmId}`);
|
|
171
|
+
}
|
|
172
|
+
const rootNode = hierarchy.get(rootCoordinatorId);
|
|
173
|
+
if (!rootNode) {
|
|
174
|
+
throw new Error(`Root coordinator ${rootCoordinatorId} not found in hierarchy`);
|
|
175
|
+
}
|
|
176
|
+
// Check if shutdown already in progress
|
|
177
|
+
if (this.shutdownInProgress.has(targetSwarmId)) {
|
|
178
|
+
throw new Error(`Shutdown already in progress for swarm ${targetSwarmId}`);
|
|
179
|
+
}
|
|
180
|
+
this.shutdownInProgress.add(targetSwarmId);
|
|
181
|
+
const hierarchyArray = Array.from(hierarchy.values());
|
|
182
|
+
const shutdownResult = {
|
|
183
|
+
rootCoordinatorId,
|
|
184
|
+
success: true,
|
|
185
|
+
totalAgents: hierarchy.size,
|
|
186
|
+
successfulShutdowns: 0,
|
|
187
|
+
failedShutdowns: 0,
|
|
188
|
+
maxDepth: Math.max(...hierarchyArray.map((n)=>n.level)),
|
|
189
|
+
totalLatencyMs: 0,
|
|
190
|
+
notificationLatencyMs: 0,
|
|
191
|
+
aggregationLatencyMs: 0,
|
|
192
|
+
totalResourcesCleaned: 0,
|
|
193
|
+
agentResults: [],
|
|
194
|
+
shutdownAt: new Date(),
|
|
195
|
+
reason
|
|
196
|
+
};
|
|
197
|
+
this.emit('shutdown:started', {
|
|
198
|
+
rootCoordinatorId,
|
|
199
|
+
swarmId: targetSwarmId,
|
|
200
|
+
totalAgents: hierarchy.size,
|
|
201
|
+
reason
|
|
202
|
+
});
|
|
203
|
+
try {
|
|
204
|
+
// Step 1: Top-down shutdown notification (root → leaves)
|
|
205
|
+
const notificationStartTime = Date.now();
|
|
206
|
+
await this.notifyShutdownTopDown(hierarchy, rootCoordinatorId);
|
|
207
|
+
shutdownResult.notificationLatencyMs = Date.now() - notificationStartTime;
|
|
208
|
+
// Step 2: Bottom-up completion aggregation (leaves → root)
|
|
209
|
+
const aggregationStartTime = Date.now();
|
|
210
|
+
shutdownResult.agentResults = await this.aggregateCompletionBottomUp(hierarchy, rootCoordinatorId, reason);
|
|
211
|
+
shutdownResult.aggregationLatencyMs = Date.now() - aggregationStartTime;
|
|
212
|
+
// Calculate metrics
|
|
213
|
+
shutdownResult.successfulShutdowns = shutdownResult.agentResults.filter((r)=>r.success).length;
|
|
214
|
+
shutdownResult.failedShutdowns = shutdownResult.agentResults.filter((r)=>!r.success).length;
|
|
215
|
+
shutdownResult.totalResourcesCleaned = shutdownResult.agentResults.reduce((sum, r)=>sum + r.resourcesCleaned, 0);
|
|
216
|
+
shutdownResult.success = shutdownResult.failedShutdowns === 0;
|
|
217
|
+
shutdownResult.totalLatencyMs = Date.now() - startTime;
|
|
218
|
+
// Performance warning if exceeds target
|
|
219
|
+
if (shutdownResult.totalLatencyMs > 1000 && hierarchy.size <= 20) {
|
|
220
|
+
console.warn(`[CascadingShutdown] Shutdown latency ${shutdownResult.totalLatencyMs}ms exceeds 1s target for ${hierarchy.size} agents`);
|
|
221
|
+
}
|
|
222
|
+
this.emit('shutdown:completed', shutdownResult);
|
|
223
|
+
return shutdownResult;
|
|
224
|
+
} catch (error) {
|
|
225
|
+
shutdownResult.success = false;
|
|
226
|
+
shutdownResult.totalLatencyMs = Date.now() - startTime;
|
|
227
|
+
this.emit('shutdown:failed', {
|
|
228
|
+
error: error instanceof Error ? error.message : String(error),
|
|
229
|
+
result: shutdownResult
|
|
230
|
+
});
|
|
231
|
+
throw error;
|
|
232
|
+
} finally{
|
|
233
|
+
this.shutdownInProgress.delete(targetSwarmId);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Emergency shutdown - immediate termination without checkpoints
|
|
238
|
+
*
|
|
239
|
+
* @param rootCoordinatorId - Root coordinator to shutdown
|
|
240
|
+
* @param reason - Emergency reason
|
|
241
|
+
* @returns Promise resolving when emergency shutdown complete
|
|
242
|
+
*/ async emergencyShutdown(rootCoordinatorId, reason) {
|
|
243
|
+
this.emit('shutdown:emergency', {
|
|
244
|
+
rootCoordinatorId,
|
|
245
|
+
reason
|
|
246
|
+
});
|
|
247
|
+
// Disable checkpoints and resource cleanup for speed
|
|
248
|
+
const originalCheckpointConfig = this.config.createShutdownCheckpoints;
|
|
249
|
+
const originalCleanupConfig = this.config.enableResourceCleanup;
|
|
250
|
+
this.config.createShutdownCheckpoints = false;
|
|
251
|
+
this.config.enableResourceCleanup = false;
|
|
252
|
+
try {
|
|
253
|
+
return await this.initiateShutdown(rootCoordinatorId, `EMERGENCY: ${reason}`);
|
|
254
|
+
} finally{
|
|
255
|
+
this.config.createShutdownCheckpoints = originalCheckpointConfig;
|
|
256
|
+
this.config.enableResourceCleanup = originalCleanupConfig;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Top-down shutdown notification (root → leaves)
|
|
261
|
+
*
|
|
262
|
+
* Notifies all agents in hierarchy using BFS level-by-level traversal.
|
|
263
|
+
* Target: <100ms per level notification.
|
|
264
|
+
*
|
|
265
|
+
* @param hierarchy - Hierarchy nodes map
|
|
266
|
+
* @param rootId - Root agent to start from
|
|
267
|
+
*/ async notifyShutdownTopDown(hierarchy, rootId) {
|
|
268
|
+
const queue = [
|
|
269
|
+
rootId
|
|
270
|
+
];
|
|
271
|
+
const visited = new Set();
|
|
272
|
+
while(queue.length > 0){
|
|
273
|
+
const levelSize = queue.length;
|
|
274
|
+
const levelStartTime = Date.now();
|
|
275
|
+
const notificationPromises = [];
|
|
276
|
+
// Process entire level in parallel
|
|
277
|
+
for(let i = 0; i < levelSize; i++){
|
|
278
|
+
const agentId = queue.shift();
|
|
279
|
+
if (visited.has(agentId)) continue;
|
|
280
|
+
visited.add(agentId);
|
|
281
|
+
const node = hierarchy.get(agentId);
|
|
282
|
+
if (!node) continue;
|
|
283
|
+
// Notify this agent
|
|
284
|
+
notificationPromises.push(this.notifyAgent(node));
|
|
285
|
+
// Add children to queue for next level
|
|
286
|
+
queue.push(...node.childIds);
|
|
287
|
+
}
|
|
288
|
+
// Wait for level notifications to complete
|
|
289
|
+
await Promise.all(notificationPromises);
|
|
290
|
+
const levelLatency = Date.now() - levelStartTime;
|
|
291
|
+
if (levelLatency > this.config.notificationTimeoutMs) {
|
|
292
|
+
console.warn(`[CascadingShutdown] Level notification latency ${levelLatency}ms exceeds ${this.config.notificationTimeoutMs}ms target`);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Notify single agent of shutdown
|
|
298
|
+
*
|
|
299
|
+
* @param node - Node to notify
|
|
300
|
+
*/ async notifyAgent(node) {
|
|
301
|
+
node.shutdownStatus = 'notified';
|
|
302
|
+
node.notifiedAt = Date.now();
|
|
303
|
+
this.emit('agent:notified', {
|
|
304
|
+
agentId: node.agentId,
|
|
305
|
+
level: node.level,
|
|
306
|
+
timestamp: node.notifiedAt
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Bottom-up completion aggregation (leaves → root)
|
|
311
|
+
*
|
|
312
|
+
* Aggregates completion from leaf nodes up to root.
|
|
313
|
+
* Children complete before parents (guaranteed bottom-up order).
|
|
314
|
+
*
|
|
315
|
+
* Target: <200ms total aggregation time.
|
|
316
|
+
*
|
|
317
|
+
* @param hierarchy - Hierarchy nodes map
|
|
318
|
+
* @param rootId - Root agent to aggregate to
|
|
319
|
+
* @param reason - Shutdown reason
|
|
320
|
+
* @returns Array of AgentShutdownResult
|
|
321
|
+
*/ async aggregateCompletionBottomUp(hierarchy, rootId, reason) {
|
|
322
|
+
const results = [];
|
|
323
|
+
// DFS post-order traversal (children before parent)
|
|
324
|
+
const processNode = async (agentId)=>{
|
|
325
|
+
const node = hierarchy.get(agentId);
|
|
326
|
+
if (!node) return;
|
|
327
|
+
// First, process all children (recursive)
|
|
328
|
+
await Promise.all(node.childIds.map((childId)=>processNode(childId)));
|
|
329
|
+
// Then, shutdown this node (after children complete)
|
|
330
|
+
const result = await this.shutdownAgent(node, reason);
|
|
331
|
+
results.push(result);
|
|
332
|
+
};
|
|
333
|
+
await processNode(rootId);
|
|
334
|
+
return results;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Shutdown single agent with resource cleanup
|
|
338
|
+
*
|
|
339
|
+
* @param node - Node to shutdown
|
|
340
|
+
* @param reason - Shutdown reason
|
|
341
|
+
* @returns AgentShutdownResult
|
|
342
|
+
*/ async shutdownAgent(node, reason) {
|
|
343
|
+
const notificationLatency = node.notifiedAt ? Date.now() - node.notifiedAt : 0;
|
|
344
|
+
const startTime = Date.now();
|
|
345
|
+
const result = {
|
|
346
|
+
agentId: node.agentId,
|
|
347
|
+
level: node.level,
|
|
348
|
+
success: false,
|
|
349
|
+
notificationLatencyMs: notificationLatency,
|
|
350
|
+
completionLatencyMs: 0,
|
|
351
|
+
resourcesCleaned: 0,
|
|
352
|
+
resourcesFailed: 0
|
|
353
|
+
};
|
|
354
|
+
try {
|
|
355
|
+
node.shutdownStatus = 'completing';
|
|
356
|
+
// Step 1: Create shutdown checkpoint if enabled
|
|
357
|
+
if (this.config.createShutdownCheckpoints) {
|
|
358
|
+
// Checkpoint creation would integrate with Phase 4 checkpoint manager
|
|
359
|
+
// For now, we track the intention
|
|
360
|
+
node.checkpointId = `shutdown-${node.agentId}-${Date.now()}`;
|
|
361
|
+
result.checkpointId = node.checkpointId;
|
|
362
|
+
}
|
|
363
|
+
// Step 2: Resource cleanup
|
|
364
|
+
if (this.config.enableResourceCleanup && node.resources.length > 0) {
|
|
365
|
+
const cleanupResults = await this.cleanupResources(node);
|
|
366
|
+
result.resourcesCleaned = cleanupResults.filter((r)=>r.cleaned).length;
|
|
367
|
+
result.resourcesFailed = cleanupResults.filter((r)=>!r.cleaned).length;
|
|
368
|
+
}
|
|
369
|
+
// Step 3: Mark as completed
|
|
370
|
+
node.shutdownStatus = 'completed';
|
|
371
|
+
node.completedAt = Date.now();
|
|
372
|
+
result.success = true;
|
|
373
|
+
result.completionLatencyMs = Date.now() - startTime;
|
|
374
|
+
this.emit('agent:shutdown', result);
|
|
375
|
+
} catch (error) {
|
|
376
|
+
result.success = false;
|
|
377
|
+
result.error = error instanceof Error ? error.message : String(error);
|
|
378
|
+
result.completionLatencyMs = Date.now() - startTime;
|
|
379
|
+
this.emit('agent:shutdown-failed', result);
|
|
380
|
+
}
|
|
381
|
+
return result;
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Cleanup resources for agent
|
|
385
|
+
*
|
|
386
|
+
* @param node - Node with resources to cleanup
|
|
387
|
+
* @returns Array of cleaned ResourceDescriptor
|
|
388
|
+
*/ async cleanupResources(node) {
|
|
389
|
+
const cleanupPromises = node.resources.map(async (resource)=>{
|
|
390
|
+
try {
|
|
391
|
+
const handler = this.resourceCleanupHandlers.get(resource.type);
|
|
392
|
+
if (handler) {
|
|
393
|
+
await handler(resource);
|
|
394
|
+
}
|
|
395
|
+
resource.cleaned = true;
|
|
396
|
+
this.emit('resource:cleaned', {
|
|
397
|
+
agentId: node.agentId,
|
|
398
|
+
resourceType: resource.type,
|
|
399
|
+
resourceId: resource.id
|
|
400
|
+
});
|
|
401
|
+
} catch (error) {
|
|
402
|
+
resource.cleaned = false;
|
|
403
|
+
resource.error = error instanceof Error ? error.message : String(error);
|
|
404
|
+
this.emit('resource:cleanup-failed', {
|
|
405
|
+
agentId: node.agentId,
|
|
406
|
+
resourceType: resource.type,
|
|
407
|
+
resourceId: resource.id,
|
|
408
|
+
error: resource.error
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
return resource;
|
|
412
|
+
});
|
|
413
|
+
return Promise.all(cleanupPromises);
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Find swarm containing specific agent
|
|
417
|
+
*
|
|
418
|
+
* @param agentId - Agent to search for
|
|
419
|
+
* @returns Swarm ID or undefined if not found
|
|
420
|
+
*/ findSwarmByAgent(agentId) {
|
|
421
|
+
const entriesArray = Array.from(this.hierarchies.entries());
|
|
422
|
+
for (const [swarmId, hierarchy] of entriesArray){
|
|
423
|
+
if (hierarchy.has(agentId)) {
|
|
424
|
+
return swarmId;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
return undefined;
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* Check if shutdown is in progress for swarm
|
|
431
|
+
*
|
|
432
|
+
* @param swarmId - Swarm to check
|
|
433
|
+
* @returns True if shutdown in progress
|
|
434
|
+
*/ isShutdownInProgress(swarmId) {
|
|
435
|
+
return this.shutdownInProgress.has(swarmId);
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Get shutdown status for agent
|
|
439
|
+
*
|
|
440
|
+
* @param agentId - Agent to query
|
|
441
|
+
* @returns Shutdown status or undefined if not found
|
|
442
|
+
*/ getShutdownStatus(agentId) {
|
|
443
|
+
const hierarchiesArray = Array.from(this.hierarchies.values());
|
|
444
|
+
for (const hierarchy of hierarchiesArray){
|
|
445
|
+
const node = hierarchy.get(agentId);
|
|
446
|
+
if (node) {
|
|
447
|
+
return node.shutdownStatus;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
return undefined;
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Get shutdown configuration
|
|
454
|
+
*/ getConfig() {
|
|
455
|
+
return {
|
|
456
|
+
...this.config
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Unregister hierarchy
|
|
461
|
+
*
|
|
462
|
+
* @param swarmId - Swarm to unregister
|
|
463
|
+
* @returns True if unregistered, false if not found
|
|
464
|
+
*/ unregisterHierarchy(swarmId) {
|
|
465
|
+
return this.hierarchies.delete(swarmId);
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* Cleanup coordinator resources
|
|
469
|
+
*/ async cleanup() {
|
|
470
|
+
// Shutdown all registered hierarchies
|
|
471
|
+
const hierarchiesArray = Array.from(this.hierarchies.entries());
|
|
472
|
+
const shutdownPromises = hierarchiesArray.map(async ([swarmId, hierarchy])=>{
|
|
473
|
+
const hierarchyArray = Array.from(hierarchy.values());
|
|
474
|
+
const rootNode = hierarchyArray.find((n)=>n.level === 0);
|
|
475
|
+
if (rootNode) {
|
|
476
|
+
try {
|
|
477
|
+
await this.initiateShutdown(rootNode.agentId, 'Coordinator cleanup', swarmId);
|
|
478
|
+
} catch (error) {
|
|
479
|
+
console.error(`Failed to shutdown swarm ${swarmId}:`, error);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
});
|
|
483
|
+
await Promise.all(shutdownPromises);
|
|
484
|
+
// Clear all state
|
|
485
|
+
this.hierarchies.clear();
|
|
486
|
+
this.shutdownInProgress.clear();
|
|
487
|
+
this.resourceCleanupHandlers.clear();
|
|
488
|
+
this.emit('coordinator:cleanup');
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
//# sourceMappingURL=cascading-shutdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/coordination/v2/coordinators/cascading-shutdown.ts"],"names":["EventEmitter","CascadingShutdown","hierarchies","Map","hierarchicalDetector","config","shutdownInProgress","Set","resourceCleanupHandlers","maxShutdownTimeMs","createShutdownCheckpoints","enableResourceCleanup","notificationTimeoutMs","completionTimeoutMs","enableEmergencyMode","agentGracePeriodMs","registerHierarchy","swarmId","rootCoordinatorId","nodes","hierarchyNodes","node","set","agentId","level","parentId","childIds","shutdownStatus","resources","sessionId","has","nodesArray2","Array","from","values","parent","get","includes","push","nodesArray","emit","totalAgents","size","maxDepth","Math","max","map","n","registerResourceCleanup","resourceType","handler","initiateShutdown","reason","startTime","Date","now","targetSwarmId","findSwarmByAgent","Error","hierarchy","rootNode","add","hierarchyArray","shutdownResult","success","successfulShutdowns","failedShutdowns","totalLatencyMs","notificationLatencyMs","aggregationLatencyMs","totalResourcesCleaned","agentResults","shutdownAt","notificationStartTime","notifyShutdownTopDown","aggregationStartTime","aggregateCompletionBottomUp","filter","r","length","reduce","sum","resourcesCleaned","console","warn","error","message","String","result","delete","emergencyShutdown","originalCheckpointConfig","originalCleanupConfig","rootId","queue","visited","levelSize","levelStartTime","notificationPromises","i","shift","notifyAgent","Promise","all","levelLatency","notifiedAt","timestamp","results","processNode","childId","shutdownAgent","notificationLatency","completionLatencyMs","resourcesFailed","checkpointId","cleanupResults","cleanupResources","cleaned","completedAt","cleanupPromises","resource","type","resourceId","id","entriesArray","entries","undefined","isShutdownInProgress","getShutdownStatus","hierarchiesArray","getConfig","unregisterHierarchy","cleanup","shutdownPromises","find","clear"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;CAqBC,GAED,SAASA,YAAY,QAAQ,SAAS;AAsKtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuCC,GACD,OAAO,MAAMC,0BAA0BD;IAC7BE,cAAsD,IAAIC,MAAM;IAChEC,qBAAsD;IACtDC,OAAgC;IAChCC,qBAAkC,IAAIC,MAAM;IAC5CC,0BAA+D,IAAIL,MAAM;IAEjF,YACEC,oBAAqD,EACrDC,MAAyC,CACzC;QACA,KAAK;QAEL,IAAI,CAACD,oBAAoB,GAAGA;QAC5B,IAAI,CAACC,MAAM,GAAG;YACZI,mBAAmB;YACnBC,2BAA2B;YAC3BC,uBAAuB;YACvBC,uBAAuB;YACvBC,qBAAqB;YACrBC,qBAAqB;YACrBC,oBAAoB;YACpB,GAAGV,MAAM;QACX;IACF;IAEA;;;;;;GAMC,GACDW,kBACEC,OAAe,EACfC,iBAAyB,EACzBC,KAOE,EACI;QACN,MAAMC,iBAAiB,IAA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