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,282 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 5 - Sprint 5.2: Multi-Level Agent Control Example
|
|
3
|
+
*
|
|
4
|
+
* Demonstrates pause/inject/resume from Level 0 to any child level
|
|
5
|
+
*
|
|
6
|
+
* @module examples/phase-5-multi-level-control
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { QueryController } from '../src/coordination/v2/sdk/query-controller.js';
|
|
10
|
+
import { HierarchicalCoordinator } from '../src/agents/hierarchical-coordinator.js';
|
|
11
|
+
import {
|
|
12
|
+
MultiLevelController,
|
|
13
|
+
InjectedCommandType,
|
|
14
|
+
createMultiLevelControllerWithHierarchy,
|
|
15
|
+
} from '../src/coordination/v2/sdk/multi-level-control.js';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Example: Multi-Level Agent Control
|
|
19
|
+
*
|
|
20
|
+
* Scenario:
|
|
21
|
+
* - Level 0: Supervisor (top-level coordinator)
|
|
22
|
+
* - Level 1: Team Leads (2 agents)
|
|
23
|
+
* - Level 2: Workers (3 agents under Team Lead A)
|
|
24
|
+
*
|
|
25
|
+
* Demonstrates:
|
|
26
|
+
* - Level 0 pauses any agent at any level
|
|
27
|
+
* - Level 0 injects commands to modify agent state/tasks
|
|
28
|
+
* - Level 0 resumes agents with commands applied
|
|
29
|
+
* - <100ms latency for all control operations
|
|
30
|
+
*/
|
|
31
|
+
async function multiLevelControlExample() {
|
|
32
|
+
console.log('=== Phase 5 - Sprint 5.2: Multi-Level Agent Control Example ===\n');
|
|
33
|
+
|
|
34
|
+
// Step 1: Initialize QueryController (Phase 0)
|
|
35
|
+
console.log('Step 1: Initialize QueryController for pause/resume...');
|
|
36
|
+
const queryController = new QueryController({
|
|
37
|
+
maxConcurrentAgents: 20,
|
|
38
|
+
defaultTokenBudget: 10000,
|
|
39
|
+
enableDynamicAllocation: true,
|
|
40
|
+
});
|
|
41
|
+
await queryController.initialize();
|
|
42
|
+
console.log('✓ QueryController initialized\n');
|
|
43
|
+
|
|
44
|
+
// Step 2: Initialize HierarchicalCoordinator (Phase 5)
|
|
45
|
+
console.log('Step 2: Initialize HierarchicalCoordinator for hierarchy management...');
|
|
46
|
+
const hierarchicalCoordinator = new HierarchicalCoordinator({
|
|
47
|
+
maxDepth: 10,
|
|
48
|
+
maxChildrenPerNode: 10,
|
|
49
|
+
enableDependencyTracking: true,
|
|
50
|
+
});
|
|
51
|
+
await hierarchicalCoordinator.initialize();
|
|
52
|
+
console.log('✓ HierarchicalCoordinator initialized\n');
|
|
53
|
+
|
|
54
|
+
// Step 3: Create Multi-Level Controller (Sprint 5.2)
|
|
55
|
+
console.log('Step 3: Create MultiLevelController integration layer...');
|
|
56
|
+
const multiLevelController = createMultiLevelControllerWithHierarchy(
|
|
57
|
+
queryController,
|
|
58
|
+
hierarchicalCoordinator,
|
|
59
|
+
{
|
|
60
|
+
maxControlLatencyMs: 100, // <100ms target
|
|
61
|
+
enableCommandQueue: true,
|
|
62
|
+
maxQueuedCommands: 50,
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
console.log('✓ MultiLevelController created\n');
|
|
66
|
+
|
|
67
|
+
// Step 4: Build 3-Level Agent Hierarchy
|
|
68
|
+
console.log('Step 4: Build 3-level agent hierarchy...');
|
|
69
|
+
|
|
70
|
+
// Level 0: Supervisor
|
|
71
|
+
const supervisor = await queryController.spawnAgent({
|
|
72
|
+
agentId: 'supervisor',
|
|
73
|
+
type: 'coordinator',
|
|
74
|
+
priority: 10,
|
|
75
|
+
metadata: { role: 'Level 0 Supervisor' },
|
|
76
|
+
});
|
|
77
|
+
await hierarchicalCoordinator.registerAgent(
|
|
78
|
+
'supervisor',
|
|
79
|
+
{
|
|
80
|
+
name: 'Supervisor',
|
|
81
|
+
type: 'coordinator',
|
|
82
|
+
level: 0,
|
|
83
|
+
status: 'ready',
|
|
84
|
+
capabilities: ['coordination', 'hierarchy-control'],
|
|
85
|
+
},
|
|
86
|
+
undefined // No parent (root)
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
// Level 1: Team Leads
|
|
90
|
+
const teamLeadA = await queryController.spawnAgent({
|
|
91
|
+
agentId: 'team-lead-a',
|
|
92
|
+
type: 'coordinator',
|
|
93
|
+
priority: 8,
|
|
94
|
+
metadata: { role: 'Team Lead A' },
|
|
95
|
+
});
|
|
96
|
+
await hierarchicalCoordinator.registerAgent(
|
|
97
|
+
'team-lead-a',
|
|
98
|
+
{
|
|
99
|
+
name: 'Team Lead A',
|
|
100
|
+
type: 'coordinator',
|
|
101
|
+
level: 1,
|
|
102
|
+
status: 'ready',
|
|
103
|
+
capabilities: ['coordination', 'task-delegation'],
|
|
104
|
+
},
|
|
105
|
+
'supervisor' // Parent: supervisor
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
const teamLeadB = await queryController.spawnAgent({
|
|
109
|
+
agentId: 'team-lead-b',
|
|
110
|
+
type: 'coordinator',
|
|
111
|
+
priority: 8,
|
|
112
|
+
metadata: { role: 'Team Lead B' },
|
|
113
|
+
});
|
|
114
|
+
await hierarchicalCoordinator.registerAgent(
|
|
115
|
+
'team-lead-b',
|
|
116
|
+
{
|
|
117
|
+
name: 'Team Lead B',
|
|
118
|
+
type: 'coordinator',
|
|
119
|
+
level: 1,
|
|
120
|
+
status: 'ready',
|
|
121
|
+
capabilities: ['coordination', 'task-delegation'],
|
|
122
|
+
},
|
|
123
|
+
'supervisor'
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
// Level 2: Workers (under Team Lead A)
|
|
127
|
+
const workerA1 = await queryController.spawnAgent({
|
|
128
|
+
agentId: 'worker-a1',
|
|
129
|
+
type: 'worker',
|
|
130
|
+
priority: 5,
|
|
131
|
+
metadata: { role: 'Worker A1' },
|
|
132
|
+
});
|
|
133
|
+
await hierarchicalCoordinator.registerAgent(
|
|
134
|
+
'worker-a1',
|
|
135
|
+
{
|
|
136
|
+
name: 'Worker A1',
|
|
137
|
+
type: 'worker',
|
|
138
|
+
level: 2,
|
|
139
|
+
status: 'ready',
|
|
140
|
+
capabilities: ['code-generation', 'testing'],
|
|
141
|
+
},
|
|
142
|
+
'team-lead-a'
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
const workerA2 = await queryController.spawnAgent({
|
|
146
|
+
agentId: 'worker-a2',
|
|
147
|
+
type: 'worker',
|
|
148
|
+
priority: 5,
|
|
149
|
+
metadata: { role: 'Worker A2' },
|
|
150
|
+
});
|
|
151
|
+
await hierarchicalCoordinator.registerAgent(
|
|
152
|
+
'worker-a2',
|
|
153
|
+
{
|
|
154
|
+
name: 'Worker A2',
|
|
155
|
+
type: 'worker',
|
|
156
|
+
level: 2,
|
|
157
|
+
status: 'ready',
|
|
158
|
+
capabilities: ['documentation', 'review'],
|
|
159
|
+
},
|
|
160
|
+
'team-lead-a'
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
console.log('✓ Hierarchy built:');
|
|
164
|
+
console.log(' - Level 0: Supervisor');
|
|
165
|
+
console.log(' - Level 1: Team Lead A, Team Lead B');
|
|
166
|
+
console.log(' - Level 2: Worker A1, Worker A2\n');
|
|
167
|
+
|
|
168
|
+
// Step 5: Demonstrate Multi-Level Control Operations
|
|
169
|
+
console.log('Step 5: Multi-Level Control Operations\n');
|
|
170
|
+
|
|
171
|
+
// Operation 1: Level 0 pauses Level 2 agent
|
|
172
|
+
console.log('Operation 1: Supervisor (L0) pauses Worker A1 (L2)...');
|
|
173
|
+
const pauseResult = await multiLevelController.pauseChildAgent(
|
|
174
|
+
'supervisor',
|
|
175
|
+
'worker-a1',
|
|
176
|
+
'Supervisor directive: pause for configuration update'
|
|
177
|
+
);
|
|
178
|
+
console.log(`✓ Paused: ${pauseResult.success}`);
|
|
179
|
+
console.log(` - Agent: ${pauseResult.agentId} (Level ${pauseResult.level})`);
|
|
180
|
+
console.log(` - Latency: ${pauseResult.latencyMs.toFixed(2)}ms (<100ms target)\n`);
|
|
181
|
+
|
|
182
|
+
// Operation 2: Level 0 injects commands to paused agent
|
|
183
|
+
console.log('Operation 2: Supervisor (L0) injects commands to Worker A1 (L2)...');
|
|
184
|
+
|
|
185
|
+
const stateInjection = await multiLevelController.injectCommand(
|
|
186
|
+
'supervisor',
|
|
187
|
+
'worker-a1',
|
|
188
|
+
InjectedCommandType.STATE_UPDATE,
|
|
189
|
+
{ state: 'working' },
|
|
190
|
+
false
|
|
191
|
+
);
|
|
192
|
+
console.log(`✓ Injected STATE_UPDATE: ${stateInjection.success} (${stateInjection.latencyMs.toFixed(2)}ms)`);
|
|
193
|
+
|
|
194
|
+
const taskInjection = await multiLevelController.injectCommand(
|
|
195
|
+
'supervisor',
|
|
196
|
+
'worker-a1',
|
|
197
|
+
InjectedCommandType.TASK_UPDATE,
|
|
198
|
+
{
|
|
199
|
+
task: 'Implement authentication module',
|
|
200
|
+
taskId: 'task-auth-001',
|
|
201
|
+
deadline: '2025-10-15',
|
|
202
|
+
},
|
|
203
|
+
false
|
|
204
|
+
);
|
|
205
|
+
console.log(`✓ Injected TASK_UPDATE: ${taskInjection.success} (${taskInjection.latencyMs.toFixed(2)}ms)`);
|
|
206
|
+
|
|
207
|
+
const priorityInjection = await multiLevelController.injectCommand(
|
|
208
|
+
'supervisor',
|
|
209
|
+
'worker-a1',
|
|
210
|
+
InjectedCommandType.PRIORITY_UPDATE,
|
|
211
|
+
{ priority: 9 },
|
|
212
|
+
false
|
|
213
|
+
);
|
|
214
|
+
console.log(`✓ Injected PRIORITY_UPDATE: ${priorityInjection.success} (${priorityInjection.latencyMs.toFixed(2)}ms)`);
|
|
215
|
+
|
|
216
|
+
const queuedCount = multiLevelController.getQueuedCommandsCount('worker-a1');
|
|
217
|
+
console.log(` - Queued commands: ${queuedCount}\n`);
|
|
218
|
+
|
|
219
|
+
// Operation 3: Level 0 resumes agent with commands applied
|
|
220
|
+
console.log('Operation 3: Supervisor (L0) resumes Worker A1 (L2)...');
|
|
221
|
+
const resumeResult = await multiLevelController.resumeChildAgent('supervisor', 'worker-a1');
|
|
222
|
+
console.log(`✓ Resumed: ${resumeResult.success}`);
|
|
223
|
+
console.log(` - Commands applied: ${resumeResult.data?.appliedCommands}`);
|
|
224
|
+
console.log(` - Latency: ${resumeResult.latencyMs.toFixed(2)}ms\n`);
|
|
225
|
+
|
|
226
|
+
// Verify commands were applied
|
|
227
|
+
const workerSession = await queryController.getAgentSession('worker-a1');
|
|
228
|
+
console.log('✓ Verification:');
|
|
229
|
+
console.log(` - Worker A1 state: ${workerSession.state}`);
|
|
230
|
+
console.log(` - Worker A1 priority: ${workerSession.priority}`);
|
|
231
|
+
console.log(` - Injected commands: ${workerSession.metadata.injectedCommands?.length ?? 0}\n`);
|
|
232
|
+
|
|
233
|
+
// Operation 4: Cascade pause to all Team Lead A's children
|
|
234
|
+
console.log('Operation 4: Supervisor (L0) cascades pause to all Team Lead A children...');
|
|
235
|
+
const cascadeResults = await multiLevelController.cascadeControlOperation('team-lead-a', 'pause');
|
|
236
|
+
console.log(`✓ Cascade pause completed: ${cascadeResults.length} agents affected`);
|
|
237
|
+
for (const result of cascadeResults) {
|
|
238
|
+
console.log(
|
|
239
|
+
` - ${result.agentId} (L${result.level}): ${result.success ? 'Paused' : 'Failed'} (${result.latencyMs.toFixed(2)}ms)`
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
console.log('');
|
|
243
|
+
|
|
244
|
+
// Operation 5: Cascade resume
|
|
245
|
+
console.log('Operation 5: Supervisor (L0) cascades resume to all Team Lead A children...');
|
|
246
|
+
const resumeCascade = await multiLevelController.cascadeControlOperation('team-lead-a', 'resume');
|
|
247
|
+
console.log(`✓ Cascade resume completed: ${resumeCascade.length} agents resumed\n`);
|
|
248
|
+
|
|
249
|
+
// Step 6: Show Final Metrics
|
|
250
|
+
console.log('Step 6: Control Operation Metrics');
|
|
251
|
+
const metrics = multiLevelController.getMetrics();
|
|
252
|
+
console.log(` - Total pauses: ${metrics.totalPauses}`);
|
|
253
|
+
console.log(` - Total injections: ${metrics.totalInjections}`);
|
|
254
|
+
console.log(` - Total resumes: ${metrics.totalResumes}`);
|
|
255
|
+
console.log(` - Average latency: ${metrics.averageControlLatencyMs.toFixed(2)}ms`);
|
|
256
|
+
console.log(` - Max latency: ${metrics.maxControlLatencyMs.toFixed(2)}ms`);
|
|
257
|
+
console.log(` - Within <100ms target: ${metrics.withinTarget ? 'YES ✓' : 'NO ✗'}\n`);
|
|
258
|
+
|
|
259
|
+
// Cleanup
|
|
260
|
+
console.log('Cleanup...');
|
|
261
|
+
await multiLevelController.cleanup();
|
|
262
|
+
await hierarchicalCoordinator.shutdown();
|
|
263
|
+
await queryController.cleanup();
|
|
264
|
+
console.log('✓ All components cleaned up\n');
|
|
265
|
+
|
|
266
|
+
console.log('=== Multi-Level Control Example Complete ===');
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// Run example
|
|
270
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
271
|
+
multiLevelControlExample()
|
|
272
|
+
.then(() => {
|
|
273
|
+
console.log('\n✓ Example completed successfully');
|
|
274
|
+
process.exit(0);
|
|
275
|
+
})
|
|
276
|
+
.catch((error) => {
|
|
277
|
+
console.error('\n✗ Example failed:', error);
|
|
278
|
+
process.exit(1);
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export { multiLevelControlExample };
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Pool Optimizer - Usage Examples
|
|
3
|
+
*
|
|
4
|
+
* Demonstrates how to use the SessionPoolOptimizer for managing
|
|
5
|
+
* 50+ concurrent agent sessions with efficient resource management.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { SessionPoolOptimizer } from '../src/coordination/v2/sdk/session-pool-optimizer.js';
|
|
9
|
+
import type { SessionRequest, PoolMetrics } from '../src/coordination/v2/sdk/session-pool-optimizer.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Example 1: Basic Session Pool Setup
|
|
13
|
+
*/
|
|
14
|
+
async function basicPoolSetup() {
|
|
15
|
+
console.log('=== Example 1: Basic Session Pool Setup ===\n');
|
|
16
|
+
|
|
17
|
+
// Initialize pool with default configuration
|
|
18
|
+
const pool = new SessionPoolOptimizer({
|
|
19
|
+
maxPoolSize: 60,
|
|
20
|
+
minPoolSize: 10,
|
|
21
|
+
autoScaleThreshold: 80,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
await pool.initialize();
|
|
25
|
+
|
|
26
|
+
// Acquire session for an agent
|
|
27
|
+
const session = await pool.acquireSession({
|
|
28
|
+
agentId: 'agent-1',
|
|
29
|
+
priority: 8,
|
|
30
|
+
metadata: { task: 'feature-development' },
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
console.log(`Session acquired: ${session.sessionId}`);
|
|
34
|
+
console.log(`Agent ID: ${session.agentId}`);
|
|
35
|
+
console.log(`Priority: ${session.metadata.priority}`);
|
|
36
|
+
|
|
37
|
+
// Release session
|
|
38
|
+
await pool.releaseSession(session.sessionId);
|
|
39
|
+
console.log('Session released back to pool\n');
|
|
40
|
+
|
|
41
|
+
await pool.shutdown();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Example 2: Handling 50+ Concurrent Agents
|
|
46
|
+
*/
|
|
47
|
+
async function handleConcurrentAgents() {
|
|
48
|
+
console.log('=== Example 2: Handling 50+ Concurrent Agents ===\n');
|
|
49
|
+
|
|
50
|
+
const pool = new SessionPoolOptimizer({
|
|
51
|
+
maxPoolSize: 70,
|
|
52
|
+
minPoolSize: 15,
|
|
53
|
+
throttleLimit: 10,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
await pool.initialize();
|
|
57
|
+
|
|
58
|
+
// Simulate 55 concurrent agents
|
|
59
|
+
const agentRequests: SessionRequest[] = [];
|
|
60
|
+
for (let i = 0; i < 55; i++) {
|
|
61
|
+
agentRequests.push({
|
|
62
|
+
agentId: `concurrent-agent-${i}`,
|
|
63
|
+
priority: Math.floor(Math.random() * 10),
|
|
64
|
+
metadata: { index: i },
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Acquire sessions concurrently
|
|
69
|
+
console.log('Acquiring 55 sessions concurrently...');
|
|
70
|
+
const sessions = await Promise.all(
|
|
71
|
+
agentRequests.map((req) => pool.acquireSession(req))
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
const metrics = pool.getMetrics();
|
|
75
|
+
console.log(`\nPool Metrics:`);
|
|
76
|
+
console.log(`- Current pool size: ${metrics.currentPoolSize}`);
|
|
77
|
+
console.log(`- Active sessions: ${metrics.activeSessions}`);
|
|
78
|
+
console.log(`- Utilization: ${metrics.utilizationPercent.toFixed(1)}%`);
|
|
79
|
+
console.log(`- Auto-scale events: ${metrics.autoScaleEvents}`);
|
|
80
|
+
|
|
81
|
+
// Release all sessions
|
|
82
|
+
await Promise.all(sessions.map((s) => pool.releaseSession(s.sessionId)));
|
|
83
|
+
console.log('\nAll sessions released\n');
|
|
84
|
+
|
|
85
|
+
await pool.shutdown();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Example 3: Session Reuse and Efficiency
|
|
90
|
+
*/
|
|
91
|
+
async function sessionReuseExample() {
|
|
92
|
+
console.log('=== Example 3: Session Reuse and Efficiency ===\n');
|
|
93
|
+
|
|
94
|
+
const pool = new SessionPoolOptimizer({
|
|
95
|
+
maxPoolSize: 30,
|
|
96
|
+
minPoolSize: 5,
|
|
97
|
+
enableReuse: true,
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
await pool.initialize();
|
|
101
|
+
|
|
102
|
+
// Create and release sessions
|
|
103
|
+
const session1 = await pool.acquireSession({
|
|
104
|
+
agentId: 'agent-reuse-1',
|
|
105
|
+
priority: 5,
|
|
106
|
+
});
|
|
107
|
+
console.log(`Session 1 created: ${session1.sessionId}`);
|
|
108
|
+
await pool.releaseSession(session1.sessionId);
|
|
109
|
+
|
|
110
|
+
// Acquire new session (should reuse idle session)
|
|
111
|
+
const session2 = await pool.acquireSession({
|
|
112
|
+
agentId: 'agent-reuse-2',
|
|
113
|
+
priority: 6,
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
const metrics = pool.getMetrics();
|
|
117
|
+
console.log(`\nReuse Statistics:`);
|
|
118
|
+
console.log(`- Total sessions created: ${metrics.totalCreated}`);
|
|
119
|
+
console.log(`- Total reuses: ${metrics.totalReuses}`);
|
|
120
|
+
console.log(`- Idle sessions: ${metrics.idleSessions}`);
|
|
121
|
+
|
|
122
|
+
await pool.releaseSession(session2.sessionId);
|
|
123
|
+
await pool.shutdown();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Example 4: Health Checks and Auto-Recovery
|
|
128
|
+
*/
|
|
129
|
+
async function healthCheckExample() {
|
|
130
|
+
console.log('\n=== Example 4: Health Checks and Auto-Recovery ===\n');
|
|
131
|
+
|
|
132
|
+
const pool = new SessionPoolOptimizer({
|
|
133
|
+
maxPoolSize: 25,
|
|
134
|
+
minPoolSize: 5,
|
|
135
|
+
healthCheckIntervalMs: 5000, // 5 seconds
|
|
136
|
+
enableAutoRecovery: true,
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
await pool.initialize();
|
|
140
|
+
|
|
141
|
+
// Listen for health check events
|
|
142
|
+
pool.on('health:checked', (event) => {
|
|
143
|
+
console.log(`Health Check: ${event.healthyCount}/${event.totalChecked} healthy (${event.passRate.toFixed(1)}%)`);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// Create some sessions
|
|
147
|
+
await pool.acquireSession({ agentId: 'health-agent-1', priority: 5 });
|
|
148
|
+
await pool.acquireSession({ agentId: 'health-agent-2', priority: 6 });
|
|
149
|
+
|
|
150
|
+
console.log('Waiting for health checks...');
|
|
151
|
+
await new Promise((resolve) => setTimeout(resolve, 6000));
|
|
152
|
+
|
|
153
|
+
const metrics = pool.getMetrics();
|
|
154
|
+
console.log(`\nHealth Metrics:`);
|
|
155
|
+
console.log(`- Health check pass rate: ${metrics.healthCheckPassRate.toFixed(1)}%`);
|
|
156
|
+
console.log(`- Unhealthy sessions: ${metrics.unhealthySessions}`);
|
|
157
|
+
|
|
158
|
+
await pool.shutdown();
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Example 5: Session Pinning for Critical Sessions
|
|
163
|
+
*/
|
|
164
|
+
async function sessionPinningExample() {
|
|
165
|
+
console.log('\n=== Example 5: Session Pinning for Critical Sessions ===\n');
|
|
166
|
+
|
|
167
|
+
const pool = new SessionPoolOptimizer({
|
|
168
|
+
maxPoolSize: 20,
|
|
169
|
+
minPoolSize: 5,
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
await pool.initialize();
|
|
173
|
+
|
|
174
|
+
// Acquire critical session
|
|
175
|
+
const criticalSession = await pool.acquireSession({
|
|
176
|
+
agentId: 'critical-agent',
|
|
177
|
+
priority: 10,
|
|
178
|
+
metadata: { critical: true },
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
// Pin session to prevent eviction
|
|
182
|
+
pool.pinSession(criticalSession.sessionId);
|
|
183
|
+
console.log(`Critical session pinned: ${criticalSession.sessionId}`);
|
|
184
|
+
|
|
185
|
+
const session = pool.getSession(criticalSession.sessionId);
|
|
186
|
+
console.log(`Is pinned: ${session?.metadata.isPinned}`);
|
|
187
|
+
|
|
188
|
+
// Later, unpin when no longer critical
|
|
189
|
+
pool.unpinSession(criticalSession.sessionId);
|
|
190
|
+
console.log('Session unpinned\n');
|
|
191
|
+
|
|
192
|
+
await pool.releaseSession(criticalSession.sessionId);
|
|
193
|
+
await pool.shutdown();
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Example 6: Metrics Monitoring
|
|
198
|
+
*/
|
|
199
|
+
async function metricsMonitoringExample() {
|
|
200
|
+
console.log('=== Example 6: Metrics Monitoring ===\n');
|
|
201
|
+
|
|
202
|
+
const pool = new SessionPoolOptimizer({
|
|
203
|
+
maxPoolSize: 40,
|
|
204
|
+
minPoolSize: 10,
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
await pool.initialize();
|
|
208
|
+
|
|
209
|
+
// Create workload
|
|
210
|
+
for (let i = 0; i < 15; i++) {
|
|
211
|
+
await pool.acquireSession({
|
|
212
|
+
agentId: `metrics-agent-${i}`,
|
|
213
|
+
priority: Math.floor(Math.random() * 10),
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const metrics = pool.getMetrics();
|
|
218
|
+
|
|
219
|
+
console.log('Pool Metrics Dashboard:');
|
|
220
|
+
console.log('========================');
|
|
221
|
+
console.log(`Pool Size: ${metrics.currentPoolSize} (max: 40)`);
|
|
222
|
+
console.log(`Active Sessions: ${metrics.activeSessions}`);
|
|
223
|
+
console.log(`Idle Sessions: ${metrics.idleSessions}`);
|
|
224
|
+
console.log(`Utilization: ${metrics.utilizationPercent.toFixed(1)}%`);
|
|
225
|
+
console.log(`\nLifetime Statistics:`);
|
|
226
|
+
console.log(`Total Created: ${metrics.totalCreated}`);
|
|
227
|
+
console.log(`Total Evicted: ${metrics.totalEvicted}`);
|
|
228
|
+
console.log(`Total Reuses: ${metrics.totalReuses}`);
|
|
229
|
+
console.log(`Avg Lifetime: ${(metrics.averageLifetimeMs / 1000).toFixed(2)}s`);
|
|
230
|
+
console.log(`\nPerformance:`);
|
|
231
|
+
console.log(`Request Rate: ${metrics.requestRate} req/s`);
|
|
232
|
+
console.log(`Health Pass Rate: ${metrics.healthCheckPassRate.toFixed(1)}%`);
|
|
233
|
+
console.log(`Auto-scale Events: ${metrics.autoScaleEvents}\n`);
|
|
234
|
+
|
|
235
|
+
await pool.shutdown();
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Example 7: Event-Driven Architecture
|
|
240
|
+
*/
|
|
241
|
+
async function eventDrivenExample() {
|
|
242
|
+
console.log('=== Example 7: Event-Driven Architecture ===\n');
|
|
243
|
+
|
|
244
|
+
const pool = new SessionPoolOptimizer({
|
|
245
|
+
maxPoolSize: 30,
|
|
246
|
+
minPoolSize: 8,
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
// Set up event listeners
|
|
250
|
+
pool.on('session:created', (event) => {
|
|
251
|
+
console.log(`✓ Session created: ${event.sessionId} for ${event.agentId}`);
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
pool.on('session:reused', (event) => {
|
|
255
|
+
console.log(`♻️ Session reused: ${event.sessionId} for ${event.agentId}`);
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
pool.on('session:released', (event) => {
|
|
259
|
+
console.log(`↓ Session released: ${event.sessionId}`);
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
pool.on('pool:autoscaled', (event) => {
|
|
263
|
+
console.log(`📈 Pool auto-scaled: ${event.previousSize} → ${event.newSize}`);
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
await pool.initialize();
|
|
267
|
+
|
|
268
|
+
// Trigger events
|
|
269
|
+
const session1 = await pool.acquireSession({ agentId: 'event-agent-1', priority: 7 });
|
|
270
|
+
await pool.releaseSession(session1.sessionId);
|
|
271
|
+
|
|
272
|
+
const session2 = await pool.acquireSession({ agentId: 'event-agent-2', priority: 8 });
|
|
273
|
+
await pool.releaseSession(session2.sessionId);
|
|
274
|
+
|
|
275
|
+
console.log('');
|
|
276
|
+
await pool.shutdown();
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Run all examples
|
|
281
|
+
*/
|
|
282
|
+
async function runAllExamples() {
|
|
283
|
+
try {
|
|
284
|
+
await basicPoolSetup();
|
|
285
|
+
await handleConcurrentAgents();
|
|
286
|
+
await sessionReuseExample();
|
|
287
|
+
await healthCheckExample();
|
|
288
|
+
await sessionPinningExample();
|
|
289
|
+
await metricsMonitoringExample();
|
|
290
|
+
await eventDrivenExample();
|
|
291
|
+
|
|
292
|
+
console.log('✅ All examples completed successfully!');
|
|
293
|
+
} catch (error) {
|
|
294
|
+
console.error('❌ Example failed:', error);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// Run examples if executed directly
|
|
299
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
300
|
+
runAllExamples();
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
export {
|
|
304
|
+
basicPoolSetup,
|
|
305
|
+
handleConcurrentAgents,
|
|
306
|
+
sessionReuseExample,
|
|
307
|
+
healthCheckExample,
|
|
308
|
+
sessionPinningExample,
|
|
309
|
+
metricsMonitoringExample,
|
|
310
|
+
eventDrivenExample,
|
|
311
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-flow-novice",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.3",
|
|
4
4
|
"description": "Standalone Claude Flow for beginners - AI agent orchestration made easy with enhanced TDD testing pipeline. Enhanced init command creates complete agent system, MCP configuration with 30 essential tools, and automated hooks with single-file testing, real-time coverage analysis, and advanced validation. Fully standalone with zero external dependencies, complete project setup in one command.",
|
|
5
5
|
"mcpName": "io.github.ruvnet/claude-flow",
|
|
6
6
|
"main": ".claude-flow-novice/dist/index.js",
|
|
@@ -205,13 +205,16 @@
|
|
|
205
205
|
"src/npx/",
|
|
206
206
|
"src/language/",
|
|
207
207
|
"src/hooks/",
|
|
208
|
+
"src/observability/",
|
|
208
209
|
"examples/",
|
|
209
210
|
"wiki/",
|
|
210
211
|
"CLAUDE.md",
|
|
211
212
|
"README.md",
|
|
212
213
|
"README-NPM.md",
|
|
213
214
|
"LICENSE",
|
|
214
|
-
"CHANGELOG.md"
|
|
215
|
+
"CHANGELOG.md",
|
|
216
|
+
"AGENT_PERFORMANCE_GUIDELINES.md",
|
|
217
|
+
"MEMORY_LEAK_ROOT_CAUSE.md"
|
|
215
218
|
],
|
|
216
219
|
"exports": {
|
|
217
220
|
".": "./.claude-flow-novice/dist/index.js",
|
|
@@ -229,6 +232,9 @@
|
|
|
229
232
|
"./slash-commands/parse-epic": "./.claude-flow-novice/dist/src/slash-commands/parse-epic.js",
|
|
230
233
|
"./slash-commands/custom-routing-activate": "./.claude-flow-novice/dist/src/slash-commands/custom-routing-activate.js",
|
|
231
234
|
"./slash-commands/custom-routing-deactivate": "./.claude-flow-novice/dist/src/slash-commands/custom-routing-deactivate.js",
|
|
235
|
+
"./slash-commands/metrics-summary": "./.claude-flow-novice/dist/src/slash-commands/metrics-summary.js",
|
|
236
|
+
"./observability/metrics-counter": "./.claude-flow-novice/dist/src/observability/metrics-counter.js",
|
|
237
|
+
"./observability/metrics-storage": "./.claude-flow-novice/dist/src/observability/metrics-storage.js",
|
|
232
238
|
"./providers": "./.claude-flow-novice/dist/src/providers/index.js",
|
|
233
239
|
"./providers/zai": "./.claude-flow-novice/dist/src/providers/zai-provider.js",
|
|
234
240
|
"./providers/tiered-router": "./.claude-flow-novice/dist/src/providers/tiered-router.js",
|
|
@@ -241,11 +247,15 @@
|
|
|
241
247
|
"dependencies": {
|
|
242
248
|
"@anthropic-ai/claude-agent-sdk": "^0.1.1",
|
|
243
249
|
"@modelcontextprotocol/sdk": "^1.18.2",
|
|
250
|
+
"@types/bcrypt": "^6.0.0",
|
|
251
|
+
"@types/express-rate-limit": "^5.1.3",
|
|
244
252
|
"@types/msgpack-lite": "^0.1.11",
|
|
245
253
|
"@types/msgpack5": "^3.4.6",
|
|
254
|
+
"@types/winston": "^2.4.4",
|
|
246
255
|
"ajv": "^8.17.1",
|
|
247
256
|
"ajv-formats": "^3.0.1",
|
|
248
257
|
"async-mutex": "^0.5.0",
|
|
258
|
+
"bcrypt": "^6.0.0",
|
|
249
259
|
"better-sqlite3": "^12.4.1",
|
|
250
260
|
"boxen": "^8.0.1",
|
|
251
261
|
"chalk": "^4.1.2",
|
|
@@ -253,11 +263,14 @@
|
|
|
253
263
|
"commander": "^13.1.0",
|
|
254
264
|
"compression": "^1.7.4",
|
|
255
265
|
"cors": "^2.8.5",
|
|
266
|
+
"express-rate-limit": "^8.1.0",
|
|
256
267
|
"fs-extra": "^11.2.0",
|
|
257
268
|
"glob": "^11.0.0",
|
|
258
|
-
"helmet": "^7.
|
|
269
|
+
"helmet": "^7.2.0",
|
|
259
270
|
"inquirer": "^12.9.6",
|
|
260
271
|
"isomorphic-dompurify": "^2.28.0",
|
|
272
|
+
"jsonwebtoken": "^9.0.2",
|
|
273
|
+
"limiter": "^3.0.0",
|
|
261
274
|
"lru-cache": "^11.2.2",
|
|
262
275
|
"msgpack-lite": "^0.1.26",
|
|
263
276
|
"msgpack5": "^6.0.2",
|
|
@@ -266,6 +279,7 @@
|
|
|
266
279
|
"socket.io": "^4.8.1",
|
|
267
280
|
"table": "^6.8.0",
|
|
268
281
|
"uuid": "^13.0.0",
|
|
282
|
+
"winston": "^3.18.3",
|
|
269
283
|
"ws": "^8.14.0",
|
|
270
284
|
"yaml": "^2.8.1",
|
|
271
285
|
"zod": "^3.25.76"
|
|
@@ -281,7 +295,7 @@
|
|
|
281
295
|
"@swc/core": "^1.13.19",
|
|
282
296
|
"@types/blessed": "^0.1.25",
|
|
283
297
|
"@types/commander": "^2.12.0",
|
|
284
|
-
"@types/cors": "^2.8.
|
|
298
|
+
"@types/cors": "^2.8.19",
|
|
285
299
|
"@types/express": "^4.17.21",
|
|
286
300
|
"@types/figlet": "^1.7.0",
|
|
287
301
|
"@types/fs-extra": "^11.0.4",
|