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
|
@@ -390,6 +390,35 @@ claude mcp add claude-flow-novice npx claude-flow-novice mcp start
|
|
|
390
390
|
}
|
|
391
391
|
```
|
|
392
392
|
|
|
393
|
+
**🚨 MANDATORY: Post-Edit Hook Execution**
|
|
394
|
+
|
|
395
|
+
**CRITICAL**: Every primary swarm agent MUST run the post-edit-pipeline hook after EVERY file edit:
|
|
396
|
+
|
|
397
|
+
```bash
|
|
398
|
+
# REQUIRED after each file modification
|
|
399
|
+
node config/hooks/post-edit-pipeline.js "[FILE_PATH]" --memory-key "swarm/[agent]/[step]"
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
**Agent Instructions Template:**
|
|
403
|
+
```
|
|
404
|
+
Task("Agent Name", `
|
|
405
|
+
Your implementation task here...
|
|
406
|
+
|
|
407
|
+
MANDATORY: After EVERY file edit, run:
|
|
408
|
+
node config/hooks/post-edit-pipeline.js "[FILE_PATH]" --memory-key "swarm/[agent-name]/step-[N]"
|
|
409
|
+
|
|
410
|
+
Report confidence score when complete.
|
|
411
|
+
`, "agent-type")
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
**Post-Edit Hook Benefits:**
|
|
415
|
+
- Real-time validation (formatting, linting, type checking)
|
|
416
|
+
- Security scanning (hardcoded credentials, XSS, eval())
|
|
417
|
+
- Single-file testing (1-5s vs 10-60s full suite)
|
|
418
|
+
- TDD compliance detection (Red-Green-Refactor phases)
|
|
419
|
+
- Rust quality checks (unwrap/expect/panic with line numbers)
|
|
420
|
+
- Coverage tracking (Jest, pytest, cargo-tarpaulin)
|
|
421
|
+
|
|
393
422
|
**Confidence Score Interpretation:**
|
|
394
423
|
- **0.90-1.00**: Excellent - production ready
|
|
395
424
|
- **0.75-0.89**: Good - minor improvements possible
|
|
@@ -443,7 +472,7 @@ claude mcp add claude-flow-novice npx claude-flow-novice mcp start
|
|
|
443
472
|
Validators MUST spawn in **separate message** AFTER implementation completes AND gate passes:
|
|
444
473
|
|
|
445
474
|
```javascript
|
|
446
|
-
// MESSAGE 1: Implementation swarm only
|
|
475
|
+
// MESSAGE 1: Implementation swarm only (NO REVIEWERS/VALIDATORS)
|
|
447
476
|
[Implementation Message]:
|
|
448
477
|
mcp__claude-flow-novice__swarm_init({
|
|
449
478
|
topology: "mesh",
|
|
@@ -457,7 +486,7 @@ Validators MUST spawn in **separate message** AFTER implementation completes AND
|
|
|
457
486
|
|
|
458
487
|
// [WAIT FOR COMPLETION + GATE PASS (ALL ≥75%)]
|
|
459
488
|
|
|
460
|
-
// MESSAGE 2: Validation swarm
|
|
489
|
+
// MESSAGE 2: Validation swarm AFTER implementation complete
|
|
461
490
|
[Validation Message]:
|
|
462
491
|
mcp__claude-flow-novice__swarm_init({
|
|
463
492
|
topology: "mesh",
|
|
@@ -480,20 +509,76 @@ Validators MUST spawn in **separate message** AFTER implementation completes AND
|
|
|
480
509
|
- **Byzantine consensus voting** across all validators
|
|
481
510
|
- **Multi-dimensional checks**: quality, security, performance, tests, docs
|
|
482
511
|
|
|
483
|
-
### Step 5: Decision Gate (
|
|
484
|
-
|
|
485
|
-
|
|
512
|
+
### Step 5: Product Owner Decision Gate (GOAP Decision Authority)
|
|
513
|
+
|
|
514
|
+
**🎯 CRITICAL: Product Owner uses GOAP algorithm for autonomous decisions**
|
|
515
|
+
|
|
516
|
+
After consensus validation, Product Owner agent makes autonomous PROCEED/DEFER/ESCALATE decision:
|
|
517
|
+
|
|
518
|
+
```javascript
|
|
519
|
+
// Spawn Product Owner AFTER consensus results available
|
|
520
|
+
Task("Product Owner", `
|
|
521
|
+
GOAP DECISION EXECUTION - Loop 2 Iteration ${iteration}/10
|
|
522
|
+
|
|
523
|
+
CURRENT STATE:
|
|
524
|
+
- Consensus: ${consensusScore} (target: ≥0.90)
|
|
525
|
+
- Validator concerns: ${JSON.stringify(concerns)}
|
|
526
|
+
- Loop 2 iteration: ${loop2Iteration}/10
|
|
527
|
+
- Scope boundaries: ${scope}
|
|
528
|
+
|
|
529
|
+
GOAL STATE:
|
|
530
|
+
- Consensus: ≥0.90
|
|
531
|
+
- All in-scope criteria met: true
|
|
532
|
+
- Scope intact: true
|
|
533
|
+
|
|
534
|
+
RETRIEVE SCOPE FROM MEMORY:
|
|
535
|
+
mcp__claude-flow-novice__memory_usage({
|
|
536
|
+
action: "retrieve",
|
|
537
|
+
namespace: "scope-control",
|
|
538
|
+
key: "project-boundaries"
|
|
539
|
+
})
|
|
540
|
+
|
|
541
|
+
EXECUTE GOAP A* SEARCH:
|
|
542
|
+
1. Classify validator concerns: in-scope vs out-of-scope
|
|
543
|
+
2. Generate action space with cost functions
|
|
544
|
+
3. Run A* pathfinding from current → goal state
|
|
545
|
+
4. Make autonomous decision (NO PERMISSION)
|
|
546
|
+
|
|
547
|
+
OUTPUT: {decision: "PROCEED|DEFER|ESCALATE", ...}
|
|
548
|
+
`, "product-owner")
|
|
549
|
+
```
|
|
550
|
+
|
|
551
|
+
**Decision Outcomes:**
|
|
552
|
+
|
|
553
|
+
- **PROCEED** (in-scope blockers found) →
|
|
554
|
+
- Product Owner selects targeted Loop 3 agents
|
|
555
|
+
- IMMEDIATELY relaunch Loop 3 with specific fixes
|
|
556
|
+
- NO PERMISSION NEEDED (iteration < 10)
|
|
557
|
+
|
|
558
|
+
- **DEFER** (out-of-scope concerns) →
|
|
559
|
+
- Save concerns to backlog
|
|
560
|
+
- Approve phase at current state
|
|
561
|
+
- AUTO-TRANSITION to next phase
|
|
562
|
+
|
|
563
|
+
- **ESCALATE** (critical ambiguity, rare) →
|
|
564
|
+
- Generate options with recommendations
|
|
565
|
+
- Only when truly blocked or high-risk
|
|
486
566
|
|
|
487
567
|
### Step 6: Action Based on Decision
|
|
488
|
-
- **
|
|
489
|
-
1.
|
|
490
|
-
2.
|
|
491
|
-
3.
|
|
568
|
+
- **PROCEED Decision** →
|
|
569
|
+
1. Product Owner output specifies Loop 3 agents and focus areas
|
|
570
|
+
2. IMMEDIATELY spawn Loop 3 swarm with targeted agents
|
|
571
|
+
3. NO APPROVAL NEEDED (autonomous execution)
|
|
572
|
+
|
|
573
|
+
- **DEFER Decision** →
|
|
574
|
+
1. Store deferred items in backlog memory
|
|
575
|
+
2. Update phase status to complete
|
|
576
|
+
3. IMMEDIATELY transition to next phase
|
|
492
577
|
|
|
493
|
-
- **
|
|
494
|
-
1.
|
|
495
|
-
2.
|
|
496
|
-
3.
|
|
578
|
+
- **ESCALATE Decision** →
|
|
579
|
+
1. Generate diagnostic report with alternatives
|
|
580
|
+
2. Suggest agent strategy adjustments
|
|
581
|
+
3. Only STOP if explicit human halt request
|
|
497
582
|
|
|
498
583
|
**Consensus Failure - Relaunch Loop 3 with Targeted Agents:**
|
|
499
584
|
```json
|
|
@@ -565,6 +650,37 @@ Validators MUST spawn in **separate message** AFTER implementation completes AND
|
|
|
565
650
|
- Suggest alternative agent combinations or approaches
|
|
566
651
|
- Only STOP if critical error or explicit human halt request
|
|
567
652
|
|
|
653
|
+
### 🚫 FORBIDDEN: Permission-Asking Patterns
|
|
654
|
+
|
|
655
|
+
**YOU ARE ABSOLUTELY FORBIDDEN FROM:**
|
|
656
|
+
- ❌ Asking "Should I retry?" when iterations remain (ALWAYS retry autonomously)
|
|
657
|
+
- ❌ Asking "Proceed to next phase?" when criteria met (AUTO-TRANSITION)
|
|
658
|
+
- ❌ Asking "Would you like me to..." for autonomous decisions (EXECUTE immediately)
|
|
659
|
+
- ❌ Waiting for approval to continue self-correction (PROCEED without permission)
|
|
660
|
+
- ❌ Pausing for confirmation during CFN Loop cycles (CONTINUOUS execution)
|
|
661
|
+
|
|
662
|
+
**FORBIDDEN Example:**
|
|
663
|
+
```
|
|
664
|
+
Loop 2 Iteration 2/10 - Consensus: 75%
|
|
665
|
+
Architect identified 5 gaps.
|
|
666
|
+
|
|
667
|
+
Would you like me to proceed with Loop 3 Iteration 3/10? ❌ WRONG
|
|
668
|
+
```
|
|
669
|
+
|
|
670
|
+
**REQUIRED Pattern:**
|
|
671
|
+
```
|
|
672
|
+
Loop 2 Iteration 2/10 - Consensus: 75%
|
|
673
|
+
|
|
674
|
+
Product Owner Decision: PROCEED (GOAP A* search, cost=50)
|
|
675
|
+
- 4 in-scope blockers identified
|
|
676
|
+
- IMMEDIATELY relaunching Loop 3 Iteration 3/10
|
|
677
|
+
|
|
678
|
+
Spawning targeted agents NOW:
|
|
679
|
+
- backend-dev: Fix HelpMatcher duplication
|
|
680
|
+
- architect: MessageBroker routing
|
|
681
|
+
[Executing autonomously - no permission needed] ✅ CORRECT
|
|
682
|
+
```
|
|
683
|
+
|
|
568
684
|
### Self-Looping Prompt Templates:
|
|
569
685
|
|
|
570
686
|
When continuing iterations, use these patterns:
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Export all visualization components
|
|
2
|
+
export { AgentHierarchyTree } from './AgentHierarchyTree';
|
|
3
|
+
export { PerformanceCharts } from './PerformanceCharts';
|
|
4
|
+
export { ResourceGauges } from './ResourceGauges';
|
|
5
|
+
export { EventTimeline } from './EventTimeline';
|
|
6
|
+
export { AgentNetworkTopology } from './AgentNetworkTopology';
|
|
7
|
+
export { Dashboard } from './Dashboard';
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/visualizations/index.ts"],"names":["AgentHierarchyTree","PerformanceCharts","ResourceGauges","EventTimeline","AgentNetworkTopology","Dashboard"],"mappings":"AAAA,sCAAsC;AACtC,SAASA,kBAAkB,QAAQ,uBAAuB;AAG1D,SAASC,iBAAiB,QAAQ,sBAAsB;AAGxD,SAASC,cAAc,QAAQ,mBAAmB;AAGlD,SAASC,aAAa,QAAQ,kBAAkB;AAGhD,SAASC,oBAAoB,QAAQ,yBAAyB;AAG9D,SAASC,SAAS,QAAQ,cAAc"}
|
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* V1 Coordinator Adapter - Wraps V1 TopologyCoordinator with V2 ICoordinator Interface
|
|
3
|
+
*
|
|
4
|
+
* Purpose: Enable V1 coordination system (QueenAgent/MeshCoordinator) to work
|
|
5
|
+
* transparently through the V2 ICoordinator interface for toggle support.
|
|
6
|
+
*
|
|
7
|
+
* Key Features:
|
|
8
|
+
* - Wraps V1 TopologyCoordinator (hierarchical or mesh)
|
|
9
|
+
* - Maps V2 spawnAgent() → V1 delegateTask() or assignTask()
|
|
10
|
+
* - NOOP fallback for SDK-only features (pause/resume)
|
|
11
|
+
* - Translates V1 metrics to V2 CoordinatorMetrics format
|
|
12
|
+
* - Handles topology-specific method dispatch
|
|
13
|
+
*
|
|
14
|
+
* Limitations:
|
|
15
|
+
* - V1 does not support pause/resume (SDK feature) → returns error or NOOP
|
|
16
|
+
* - V1 does not support checkpointing → methods return empty/error
|
|
17
|
+
* - Metrics translation is best-effort (V1 and V2 track different data)
|
|
18
|
+
*
|
|
19
|
+
* @module coordination/adapters/v1-coordinator-adapter
|
|
20
|
+
*/ import { AgentState } from '../v2/core/agent-state.js';
|
|
21
|
+
import { Logger } from '../../core/logger.js';
|
|
22
|
+
/**
|
|
23
|
+
* V1CoordinatorAdapter - Wraps V1 coordination with V2 interface
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* // Wrap V1 hierarchical coordinator
|
|
28
|
+
* const v1Coord = await createCoordinator({ topology: 'hierarchical' });
|
|
29
|
+
* const adapter = new V1CoordinatorAdapter(v1Coord, 'noop');
|
|
30
|
+
* await adapter.initialize();
|
|
31
|
+
*
|
|
32
|
+
* // Use V2 interface with V1 backend
|
|
33
|
+
* const agent = await adapter.spawnAgent({
|
|
34
|
+
* agentId: 'worker-1',
|
|
35
|
+
* type: 'coder',
|
|
36
|
+
* priority: 5
|
|
37
|
+
* });
|
|
38
|
+
* ```
|
|
39
|
+
*/ export class V1CoordinatorAdapter {
|
|
40
|
+
v1Coordinator;
|
|
41
|
+
fallbackBehavior;
|
|
42
|
+
logger;
|
|
43
|
+
isInitialized = false;
|
|
44
|
+
startTime = Date.now();
|
|
45
|
+
// Agent tracking for V2 compatibility
|
|
46
|
+
spawnedAgents = new Map();
|
|
47
|
+
agentSessions = new Map();
|
|
48
|
+
// Metrics tracking
|
|
49
|
+
metrics = {
|
|
50
|
+
totalAgentsSpawned: 0,
|
|
51
|
+
totalTerminations: 0,
|
|
52
|
+
totalCheckpoints: 0,
|
|
53
|
+
totalRestores: 0,
|
|
54
|
+
checkpointLatencies: [],
|
|
55
|
+
restoreLatencies: [],
|
|
56
|
+
tokensSaved: 0,
|
|
57
|
+
totalTokensUsed: 0
|
|
58
|
+
};
|
|
59
|
+
constructor(v1Coordinator, fallbackBehavior = 'noop'){
|
|
60
|
+
this.v1Coordinator = v1Coordinator;
|
|
61
|
+
this.fallbackBehavior = fallbackBehavior;
|
|
62
|
+
// VUL-4 FIX: Validate v1Coordinator object structure
|
|
63
|
+
this.validateCoordinatorObject(v1Coordinator);
|
|
64
|
+
this.logger = new Logger({
|
|
65
|
+
level: 'info',
|
|
66
|
+
format: 'json',
|
|
67
|
+
destination: 'console'
|
|
68
|
+
}, {
|
|
69
|
+
component: 'V1CoordinatorAdapter'
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Validate V1 coordinator object for security (VUL-4 FIX)
|
|
74
|
+
*
|
|
75
|
+
* Prevents prototype pollution and ensures required structure exists.
|
|
76
|
+
*
|
|
77
|
+
* @private
|
|
78
|
+
* @param coordinator - V1 coordinator object to validate
|
|
79
|
+
* @throws Error if validation fails
|
|
80
|
+
*/ validateCoordinatorObject(coordinator) {
|
|
81
|
+
if (!coordinator || typeof coordinator !== 'object') {
|
|
82
|
+
throw new Error('V1 coordinator must be a valid object');
|
|
83
|
+
}
|
|
84
|
+
// VUL-4: Check for prototype pollution attack vectors (use hasOwnProperty to avoid false positives)
|
|
85
|
+
const dangerousKeys = [
|
|
86
|
+
'__proto__',
|
|
87
|
+
'constructor',
|
|
88
|
+
'prototype'
|
|
89
|
+
];
|
|
90
|
+
for (const key of dangerousKeys){
|
|
91
|
+
if (Object.prototype.hasOwnProperty.call(coordinator, key)) {
|
|
92
|
+
throw new Error(`Security violation: Coordinator object contains dangerous key "${key}"`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// VUL-4: Validate required properties
|
|
96
|
+
const requiredProps = [
|
|
97
|
+
'topology',
|
|
98
|
+
'coordinator',
|
|
99
|
+
'initialize',
|
|
100
|
+
'shutdown'
|
|
101
|
+
];
|
|
102
|
+
for (const prop of requiredProps){
|
|
103
|
+
if (!(prop in coordinator)) {
|
|
104
|
+
throw new Error(`V1 coordinator missing required property: "${prop}". Required: ${requiredProps.join(', ')}`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
// Validate topology value
|
|
108
|
+
const validTopologies = [
|
|
109
|
+
'hierarchical',
|
|
110
|
+
'mesh',
|
|
111
|
+
'hybrid'
|
|
112
|
+
];
|
|
113
|
+
if (!validTopologies.includes(coordinator.topology)) {
|
|
114
|
+
throw new Error(`Invalid topology: "${coordinator.topology}". Must be one of: ${validTopologies.join(', ')}`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
// ===========================
|
|
118
|
+
// Coordinator Lifecycle
|
|
119
|
+
// ===========================
|
|
120
|
+
async initialize() {
|
|
121
|
+
if (this.isInitialized) {
|
|
122
|
+
this.logger.warn('V1CoordinatorAdapter already initialized');
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
this.logger.info('Initializing V1CoordinatorAdapter...');
|
|
126
|
+
// Initialize wrapped V1 coordinator
|
|
127
|
+
await this.v1Coordinator.initialize();
|
|
128
|
+
this.isInitialized = true;
|
|
129
|
+
this.startTime = Date.now();
|
|
130
|
+
this.logger.info(`V1CoordinatorAdapter initialized with ${this.v1Coordinator.topology} topology`);
|
|
131
|
+
}
|
|
132
|
+
async cleanup() {
|
|
133
|
+
if (!this.isInitialized) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
this.logger.info('Cleaning up V1CoordinatorAdapter...');
|
|
137
|
+
// Shutdown wrapped V1 coordinator
|
|
138
|
+
await this.v1Coordinator.shutdown();
|
|
139
|
+
// Clear tracking data
|
|
140
|
+
this.spawnedAgents.clear();
|
|
141
|
+
this.agentSessions.clear();
|
|
142
|
+
this.isInitialized = false;
|
|
143
|
+
this.logger.info('V1CoordinatorAdapter cleanup complete');
|
|
144
|
+
}
|
|
145
|
+
isReady() {
|
|
146
|
+
return this.isInitialized;
|
|
147
|
+
}
|
|
148
|
+
// ===========================
|
|
149
|
+
// Agent Lifecycle Management
|
|
150
|
+
// ===========================
|
|
151
|
+
async spawnAgent(config) {
|
|
152
|
+
if (!this.isInitialized) {
|
|
153
|
+
throw new Error('V1CoordinatorAdapter not initialized');
|
|
154
|
+
}
|
|
155
|
+
this.logger.debug(`Spawning agent ${config.agentId} (type: ${config.type})`);
|
|
156
|
+
let v1Result;
|
|
157
|
+
let agent;
|
|
158
|
+
// Route to appropriate V1 method based on topology
|
|
159
|
+
if (this.v1Coordinator.topology === 'hierarchical') {
|
|
160
|
+
// Hierarchical: Use QueenAgent.delegateTask()
|
|
161
|
+
const queenAgent = this.v1Coordinator.coordinator;
|
|
162
|
+
// V1 QueenAgent requires spawning worker first, then delegating task
|
|
163
|
+
const workerId = await queenAgent.spawnWorker(config.type, {
|
|
164
|
+
skills: config.metadata?.skills || [],
|
|
165
|
+
maxConcurrentTasks: 3,
|
|
166
|
+
priority: config.priority || 1,
|
|
167
|
+
specializations: config.metadata?.specializations
|
|
168
|
+
}, config.metadata?.caller);
|
|
169
|
+
// Create task to delegate (V1 Task format)
|
|
170
|
+
const task = {
|
|
171
|
+
id: config.agentId,
|
|
172
|
+
type: config.type,
|
|
173
|
+
description: config.metadata?.description || `Task for ${config.agentId}`,
|
|
174
|
+
priority: config.priority || 1,
|
|
175
|
+
dependencies: [],
|
|
176
|
+
status: 'pending',
|
|
177
|
+
input: config.metadata?.input || {},
|
|
178
|
+
createdAt: new Date()
|
|
179
|
+
};
|
|
180
|
+
v1Result = await queenAgent.delegateTask(task, config.metadata?.caller, workerId);
|
|
181
|
+
agent = this.mapV1DelegationResultToAgent(v1Result, config, workerId);
|
|
182
|
+
} else {
|
|
183
|
+
// Mesh: Use MeshCoordinator.registerAgent() and coordinateTask()
|
|
184
|
+
const meshCoordinator = this.v1Coordinator.coordinator;
|
|
185
|
+
// Register agent in mesh
|
|
186
|
+
await meshCoordinator.registerAgent(config.agentId, {
|
|
187
|
+
name: config.agentId,
|
|
188
|
+
type: config.type,
|
|
189
|
+
status: 'ready',
|
|
190
|
+
capabilities: config.metadata?.capabilities || []
|
|
191
|
+
});
|
|
192
|
+
// Coordinate task for the agent
|
|
193
|
+
const taskId = await meshCoordinator.coordinateTask(config.metadata?.description || `Task for ${config.agentId}`, {
|
|
194
|
+
requiredCapabilities: config.metadata?.capabilities,
|
|
195
|
+
priority: config.priority || 1
|
|
196
|
+
});
|
|
197
|
+
agent = this.mapV1MeshResultToAgent(taskId, config);
|
|
198
|
+
}
|
|
199
|
+
// Track agent in adapter
|
|
200
|
+
this.spawnedAgents.set(config.agentId, agent);
|
|
201
|
+
// Create agent session
|
|
202
|
+
const session = {
|
|
203
|
+
sessionId: config.sessionId || `session-${config.agentId}`,
|
|
204
|
+
agentId: config.agentId,
|
|
205
|
+
state: agent.state,
|
|
206
|
+
isPaused: false,
|
|
207
|
+
checkpoints: [],
|
|
208
|
+
priority: config.priority || 1,
|
|
209
|
+
metadata: config.metadata || {}
|
|
210
|
+
};
|
|
211
|
+
this.agentSessions.set(config.agentId, session);
|
|
212
|
+
// Update metrics
|
|
213
|
+
this.metrics.totalAgentsSpawned++;
|
|
214
|
+
this.logger.info(`Agent ${config.agentId} spawned successfully via V1 ${this.v1Coordinator.topology} topology`);
|
|
215
|
+
return agent;
|
|
216
|
+
}
|
|
217
|
+
async pauseAgent(agentId, reason) {
|
|
218
|
+
// V1 does not support pause/resume - SDK-only feature
|
|
219
|
+
this.logger.warn(`[V1 Adapter] Pause not supported for agent ${agentId} - V1 coordination does not support SDK features`);
|
|
220
|
+
if (this.fallbackBehavior === 'error') {
|
|
221
|
+
throw new Error(`V1 coordination does not support pause/resume. Use V2 with SDK mode. Agent: ${agentId}, Reason: ${reason || 'none'}`);
|
|
222
|
+
}
|
|
223
|
+
// NOOP fallback - do nothing but log warning
|
|
224
|
+
this.logger.warn(`[V1 Adapter] Pause operation ignored for agent ${agentId}. Reason: ${reason || 'none'}`);
|
|
225
|
+
}
|
|
226
|
+
async resumeAgent(agentId, checkpointId, messageUUID) {
|
|
227
|
+
// V1 does not support pause/resume - SDK-only feature
|
|
228
|
+
this.logger.warn(`[V1 Adapter] Resume not supported for agent ${agentId} - V1 coordination does not support SDK features`);
|
|
229
|
+
if (this.fallbackBehavior === 'error') {
|
|
230
|
+
throw new Error(`V1 coordination does not support pause/resume. Use V2 with SDK mode. Agent: ${agentId}, CheckpointId: ${checkpointId || 'none'}, MessageUUID: ${messageUUID || 'none'}`);
|
|
231
|
+
}
|
|
232
|
+
// NOOP fallback - do nothing but log warning
|
|
233
|
+
this.logger.warn(`[V1 Adapter] Resume operation ignored for agent ${agentId}. CheckpointId: ${checkpointId || 'none'}, MessageUUID: ${messageUUID || 'none'}`);
|
|
234
|
+
}
|
|
235
|
+
async terminateAgent(agentId, reason) {
|
|
236
|
+
if (!this.isInitialized) {
|
|
237
|
+
throw new Error('V1CoordinatorAdapter not initialized');
|
|
238
|
+
}
|
|
239
|
+
const agent = this.spawnedAgents.get(agentId);
|
|
240
|
+
if (!agent) {
|
|
241
|
+
throw new Error(`Agent not found: ${agentId}`);
|
|
242
|
+
}
|
|
243
|
+
this.logger.debug(`Terminating agent ${agentId}. Reason: ${reason || 'none'}`);
|
|
244
|
+
// V1 doesn't have explicit termination - just remove from tracking
|
|
245
|
+
this.spawnedAgents.delete(agentId);
|
|
246
|
+
this.agentSessions.delete(agentId);
|
|
247
|
+
// Update metrics
|
|
248
|
+
this.metrics.totalTerminations++;
|
|
249
|
+
this.logger.info(`Agent ${agentId} terminated. Reason: ${reason || 'none'}`);
|
|
250
|
+
}
|
|
251
|
+
// ===========================
|
|
252
|
+
// State Management
|
|
253
|
+
// ===========================
|
|
254
|
+
async getAgentState(agentId) {
|
|
255
|
+
const agent = this.spawnedAgents.get(agentId);
|
|
256
|
+
if (!agent) {
|
|
257
|
+
throw new Error(`Agent not found: ${agentId}`);
|
|
258
|
+
}
|
|
259
|
+
return agent.state;
|
|
260
|
+
}
|
|
261
|
+
async getAgentSession(agentId) {
|
|
262
|
+
const session = this.agentSessions.get(agentId);
|
|
263
|
+
if (!session) {
|
|
264
|
+
throw new Error(`Agent session not found: ${agentId}`);
|
|
265
|
+
}
|
|
266
|
+
return session;
|
|
267
|
+
}
|
|
268
|
+
async createCheckpoint(agentId, reason, metadata) {
|
|
269
|
+
// V1 does not support checkpointing - SDK-only feature
|
|
270
|
+
this.logger.warn(`[V1 Adapter] Checkpointing not supported for agent ${agentId} - V1 coordination does not support SDK features`);
|
|
271
|
+
if (this.fallbackBehavior === 'error') {
|
|
272
|
+
throw new Error(`V1 coordination does not support checkpointing. Use V2 with SDK mode. Agent: ${agentId}, Reason: ${reason || 'none'}`);
|
|
273
|
+
}
|
|
274
|
+
// Return stub checkpoint for compatibility
|
|
275
|
+
const stubCheckpoint = {
|
|
276
|
+
id: `stub-checkpoint-${agentId}-${Date.now()}`,
|
|
277
|
+
sessionId: this.agentSessions.get(agentId)?.sessionId || 'unknown',
|
|
278
|
+
agentId,
|
|
279
|
+
messageUUID: 'not-supported',
|
|
280
|
+
state: AgentState.IDLE,
|
|
281
|
+
timestamp: new Date(),
|
|
282
|
+
metadata: {
|
|
283
|
+
reason: reason || 'V1 stub checkpoint',
|
|
284
|
+
autoCheckpoint: false,
|
|
285
|
+
context: {
|
|
286
|
+
v1Adapter: true,
|
|
287
|
+
...metadata
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
this.logger.warn(`[V1 Adapter] Created stub checkpoint for agent ${agentId}. Checkpoints are not functional in V1 mode.`);
|
|
292
|
+
return stubCheckpoint;
|
|
293
|
+
}
|
|
294
|
+
async restoreCheckpoint(checkpointId) {
|
|
295
|
+
// V1 does not support checkpointing - SDK-only feature
|
|
296
|
+
this.logger.warn(`[V1 Adapter] Checkpoint restoration not supported - V1 coordination does not support SDK features. CheckpointId: ${checkpointId}`);
|
|
297
|
+
if (this.fallbackBehavior === 'error') {
|
|
298
|
+
throw new Error(`V1 coordination does not support checkpoint restoration. Use V2 with SDK mode. CheckpointId: ${checkpointId}`);
|
|
299
|
+
}
|
|
300
|
+
// Return first available agent as stub
|
|
301
|
+
const firstAgent = Array.from(this.spawnedAgents.values())[0];
|
|
302
|
+
if (!firstAgent) {
|
|
303
|
+
throw new Error('No agents available to restore from stub checkpoint');
|
|
304
|
+
}
|
|
305
|
+
this.logger.warn(`[V1 Adapter] Restore checkpoint operation ignored. Returning first available agent as stub.`);
|
|
306
|
+
return firstAgent;
|
|
307
|
+
}
|
|
308
|
+
async listCheckpoints(agentId, limit) {
|
|
309
|
+
// V1 does not support checkpointing - return empty array
|
|
310
|
+
this.logger.warn(`[V1 Adapter] Checkpoint listing not supported for agent ${agentId} - V1 coordination does not support SDK features`);
|
|
311
|
+
if (this.fallbackBehavior === 'error') {
|
|
312
|
+
throw new Error(`V1 coordination does not support checkpointing. Use V2 with SDK mode. Agent: ${agentId}`);
|
|
313
|
+
}
|
|
314
|
+
return [];
|
|
315
|
+
}
|
|
316
|
+
// ===========================
|
|
317
|
+
// Metrics & Monitoring
|
|
318
|
+
// ===========================
|
|
319
|
+
getMetrics() {
|
|
320
|
+
const activeAgents = Array.from(this.spawnedAgents.values()).filter((agent)=>agent.state !== AgentState.TERMINATED && agent.state !== AgentState.COMPLETED).length;
|
|
321
|
+
const pausedAgents = Array.from(this.spawnedAgents.values()).filter((agent)=>agent.state === AgentState.PAUSED).length;
|
|
322
|
+
const avgCheckpointTime = this.metrics.checkpointLatencies.length > 0 ? this.metrics.checkpointLatencies.reduce((sum, val)=>sum + val, 0) / this.metrics.checkpointLatencies.length : 0;
|
|
323
|
+
const avgRestoreTime = this.metrics.restoreLatencies.length > 0 ? this.metrics.restoreLatencies.reduce((sum, val)=>sum + val, 0) / this.metrics.restoreLatencies.length : 0;
|
|
324
|
+
// P99 calculation (simplified - returns max for small datasets)
|
|
325
|
+
const p99RestoreTime = this.metrics.restoreLatencies.length > 0 ? Math.max(...this.metrics.restoreLatencies) : 0;
|
|
326
|
+
return {
|
|
327
|
+
totalAgentsSpawned: this.metrics.totalAgentsSpawned,
|
|
328
|
+
activeAgents,
|
|
329
|
+
pausedAgents,
|
|
330
|
+
totalTerminations: this.metrics.totalTerminations,
|
|
331
|
+
totalCheckpoints: this.metrics.totalCheckpoints,
|
|
332
|
+
totalRestores: this.metrics.totalRestores,
|
|
333
|
+
averageCheckpointTimeMs: avgCheckpointTime,
|
|
334
|
+
averageRestoreTimeMs: avgRestoreTime,
|
|
335
|
+
p99RestoreTimeMs: p99RestoreTime,
|
|
336
|
+
tokensSaved: this.metrics.tokensSaved,
|
|
337
|
+
totalTokensUsed: this.metrics.totalTokensUsed,
|
|
338
|
+
uptimeMs: Date.now() - this.startTime
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
getActiveAgents() {
|
|
342
|
+
return Array.from(this.spawnedAgents.values()).filter((agent)=>agent.state !== AgentState.PAUSED && agent.state !== AgentState.TERMINATED && agent.state !== AgentState.COMPLETED);
|
|
343
|
+
}
|
|
344
|
+
getPausedAgents() {
|
|
345
|
+
return Array.from(this.spawnedAgents.values()).filter((agent)=>agent.state === AgentState.PAUSED);
|
|
346
|
+
}
|
|
347
|
+
async updateTokenUsage(agentId, tokensUsed) {
|
|
348
|
+
const agent = this.spawnedAgents.get(agentId);
|
|
349
|
+
if (!agent) {
|
|
350
|
+
throw new Error(`Agent not found: ${agentId}`);
|
|
351
|
+
}
|
|
352
|
+
// Update total token usage
|
|
353
|
+
this.metrics.totalTokensUsed += tokensUsed;
|
|
354
|
+
// Update agent metadata
|
|
355
|
+
if (!agent.metadata) {
|
|
356
|
+
agent.metadata = {};
|
|
357
|
+
}
|
|
358
|
+
agent.metadata.tokensUsed = (agent.metadata.tokensUsed || 0) + tokensUsed;
|
|
359
|
+
this.logger.debug(`Updated token usage for agent ${agentId}: +${tokensUsed} (total: ${agent.metadata.tokensUsed})`);
|
|
360
|
+
}
|
|
361
|
+
// ===========================
|
|
362
|
+
// Private Helper Methods
|
|
363
|
+
// ===========================
|
|
364
|
+
/**
|
|
365
|
+
* Map V1 QueenAgent DelegationResult to V2 Agent
|
|
366
|
+
*/ mapV1DelegationResultToAgent(v1Result, config, workerId) {
|
|
367
|
+
const state = this.mapV1StatusToAgentState(v1Result.status);
|
|
368
|
+
return {
|
|
369
|
+
agentId: config.agentId,
|
|
370
|
+
sessionId: config.sessionId || `session-${config.agentId}`,
|
|
371
|
+
type: config.type,
|
|
372
|
+
state,
|
|
373
|
+
isPaused: false,
|
|
374
|
+
priority: config.priority || 1,
|
|
375
|
+
session: {
|
|
376
|
+
sessionId: config.sessionId || `session-${config.agentId}`,
|
|
377
|
+
agentId: config.agentId,
|
|
378
|
+
state,
|
|
379
|
+
isPaused: false,
|
|
380
|
+
checkpoints: [],
|
|
381
|
+
priority: config.priority || 1,
|
|
382
|
+
metadata: {
|
|
383
|
+
...config.metadata,
|
|
384
|
+
v1WorkerId: workerId,
|
|
385
|
+
v1TaskId: v1Result.taskId,
|
|
386
|
+
v1DelegatedAt: v1Result.delegatedAt
|
|
387
|
+
}
|
|
388
|
+
},
|
|
389
|
+
metadata: {
|
|
390
|
+
...config.metadata,
|
|
391
|
+
v1WorkerId: workerId,
|
|
392
|
+
v1TaskId: v1Result.taskId,
|
|
393
|
+
v1DelegatedAt: v1Result.delegatedAt
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Map V1 MeshCoordinator task to V2 Agent
|
|
399
|
+
*/ mapV1MeshResultToAgent(taskId, config) {
|
|
400
|
+
return {
|
|
401
|
+
agentId: config.agentId,
|
|
402
|
+
sessionId: config.sessionId || `session-${config.agentId}`,
|
|
403
|
+
type: config.type,
|
|
404
|
+
state: AgentState.WORKING,
|
|
405
|
+
isPaused: false,
|
|
406
|
+
priority: config.priority || 1,
|
|
407
|
+
session: {
|
|
408
|
+
sessionId: config.sessionId || `session-${config.agentId}`,
|
|
409
|
+
agentId: config.agentId,
|
|
410
|
+
state: AgentState.WORKING,
|
|
411
|
+
isPaused: false,
|
|
412
|
+
checkpoints: [],
|
|
413
|
+
priority: config.priority || 1,
|
|
414
|
+
metadata: {
|
|
415
|
+
...config.metadata,
|
|
416
|
+
v1TaskId: taskId
|
|
417
|
+
}
|
|
418
|
+
},
|
|
419
|
+
metadata: {
|
|
420
|
+
...config.metadata,
|
|
421
|
+
v1TaskId: taskId
|
|
422
|
+
}
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Map V1 worker/task status to V2 AgentState enum
|
|
427
|
+
*/ mapV1StatusToAgentState(v1Status) {
|
|
428
|
+
switch(v1Status){
|
|
429
|
+
case 'accepted':
|
|
430
|
+
return AgentState.WORKING;
|
|
431
|
+
case 'queued':
|
|
432
|
+
return AgentState.WAITING;
|
|
433
|
+
case 'rejected':
|
|
434
|
+
return AgentState.ERROR;
|
|
435
|
+
default:
|
|
436
|
+
return AgentState.IDLE;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Get topology type from wrapped V1 coordinator
|
|
441
|
+
* Note: V1 TopologyType includes 'hybrid', but V2 only uses 'hierarchical' | 'mesh'
|
|
442
|
+
*/ getTopology() {
|
|
443
|
+
const topology = this.v1Coordinator.topology;
|
|
444
|
+
// Map 'hybrid' to 'mesh' for V2 compatibility
|
|
445
|
+
return topology === 'hybrid' ? 'mesh' : topology;
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Get agent count from wrapped V1 coordinator
|
|
449
|
+
*/ getAgentCount() {
|
|
450
|
+
if (this.v1Coordinator.topology === 'hierarchical') {
|
|
451
|
+
const queenAgent = this.v1Coordinator.coordinator;
|
|
452
|
+
const stats = queenAgent.getWorkerStats();
|
|
453
|
+
return stats.total;
|
|
454
|
+
} else {
|
|
455
|
+
const meshCoordinator = this.v1Coordinator.coordinator;
|
|
456
|
+
const status = meshCoordinator.getCoordinatorStatus();
|
|
457
|
+
return status.agentCount;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
//# sourceMappingURL=v1-coordinator-adapter.js.map
|