claude-flow-novice 1.6.1 ā 1.6.2
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 +4 -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/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/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/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/metrics.db +0 -0
- package/.claude-flow-novice/metrics.db-shm +0 -0
- package/.claude-flow-novice/metrics.db-wal +0 -0
- package/CLAUDE.md +29 -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 +15 -3
- package/scripts/check-routing-stats.cjs +122 -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,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.2",
|
|
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,6 +205,7 @@
|
|
|
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",
|
|
@@ -229,6 +230,9 @@
|
|
|
229
230
|
"./slash-commands/parse-epic": "./.claude-flow-novice/dist/src/slash-commands/parse-epic.js",
|
|
230
231
|
"./slash-commands/custom-routing-activate": "./.claude-flow-novice/dist/src/slash-commands/custom-routing-activate.js",
|
|
231
232
|
"./slash-commands/custom-routing-deactivate": "./.claude-flow-novice/dist/src/slash-commands/custom-routing-deactivate.js",
|
|
233
|
+
"./slash-commands/metrics-summary": "./.claude-flow-novice/dist/src/slash-commands/metrics-summary.js",
|
|
234
|
+
"./observability/metrics-counter": "./.claude-flow-novice/dist/src/observability/metrics-counter.js",
|
|
235
|
+
"./observability/metrics-storage": "./.claude-flow-novice/dist/src/observability/metrics-storage.js",
|
|
232
236
|
"./providers": "./.claude-flow-novice/dist/src/providers/index.js",
|
|
233
237
|
"./providers/zai": "./.claude-flow-novice/dist/src/providers/zai-provider.js",
|
|
234
238
|
"./providers/tiered-router": "./.claude-flow-novice/dist/src/providers/tiered-router.js",
|
|
@@ -241,11 +245,15 @@
|
|
|
241
245
|
"dependencies": {
|
|
242
246
|
"@anthropic-ai/claude-agent-sdk": "^0.1.1",
|
|
243
247
|
"@modelcontextprotocol/sdk": "^1.18.2",
|
|
248
|
+
"@types/bcrypt": "^6.0.0",
|
|
249
|
+
"@types/express-rate-limit": "^5.1.3",
|
|
244
250
|
"@types/msgpack-lite": "^0.1.11",
|
|
245
251
|
"@types/msgpack5": "^3.4.6",
|
|
252
|
+
"@types/winston": "^2.4.4",
|
|
246
253
|
"ajv": "^8.17.1",
|
|
247
254
|
"ajv-formats": "^3.0.1",
|
|
248
255
|
"async-mutex": "^0.5.0",
|
|
256
|
+
"bcrypt": "^6.0.0",
|
|
249
257
|
"better-sqlite3": "^12.4.1",
|
|
250
258
|
"boxen": "^8.0.1",
|
|
251
259
|
"chalk": "^4.1.2",
|
|
@@ -253,11 +261,14 @@
|
|
|
253
261
|
"commander": "^13.1.0",
|
|
254
262
|
"compression": "^1.7.4",
|
|
255
263
|
"cors": "^2.8.5",
|
|
264
|
+
"express-rate-limit": "^8.1.0",
|
|
256
265
|
"fs-extra": "^11.2.0",
|
|
257
266
|
"glob": "^11.0.0",
|
|
258
|
-
"helmet": "^7.
|
|
267
|
+
"helmet": "^7.2.0",
|
|
259
268
|
"inquirer": "^12.9.6",
|
|
260
269
|
"isomorphic-dompurify": "^2.28.0",
|
|
270
|
+
"jsonwebtoken": "^9.0.2",
|
|
271
|
+
"limiter": "^3.0.0",
|
|
261
272
|
"lru-cache": "^11.2.2",
|
|
262
273
|
"msgpack-lite": "^0.1.26",
|
|
263
274
|
"msgpack5": "^6.0.2",
|
|
@@ -266,6 +277,7 @@
|
|
|
266
277
|
"socket.io": "^4.8.1",
|
|
267
278
|
"table": "^6.8.0",
|
|
268
279
|
"uuid": "^13.0.0",
|
|
280
|
+
"winston": "^3.18.3",
|
|
269
281
|
"ws": "^8.14.0",
|
|
270
282
|
"yaml": "^2.8.1",
|
|
271
283
|
"zod": "^3.25.76"
|
|
@@ -281,7 +293,7 @@
|
|
|
281
293
|
"@swc/core": "^1.13.19",
|
|
282
294
|
"@types/blessed": "^0.1.25",
|
|
283
295
|
"@types/commander": "^2.12.0",
|
|
284
|
-
"@types/cors": "^2.8.
|
|
296
|
+
"@types/cors": "^2.8.19",
|
|
285
297
|
"@types/express": "^4.17.21",
|
|
286
298
|
"@types/figlet": "^1.7.0",
|
|
287
299
|
"@types/fs-extra": "^11.0.4",
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check Provider Routing Statistics
|
|
3
|
+
*
|
|
4
|
+
* Queries telemetry to show routing breakdown from recent swarm execution
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const { TelemetrySystem, getGlobalTelemetry } = require('../.claude-flow-novice/dist/src/observability/telemetry.js');
|
|
8
|
+
|
|
9
|
+
async function checkRoutingStats() {
|
|
10
|
+
console.log('š Provider Routing Statistics\n');
|
|
11
|
+
console.log('=' .repeat(60));
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
// Get global telemetry instance
|
|
15
|
+
const telemetry = getGlobalTelemetry();
|
|
16
|
+
|
|
17
|
+
// Query provider request metrics
|
|
18
|
+
const providerMetrics = telemetry.getMetrics('provider.request', 300000); // Last 5 minutes
|
|
19
|
+
|
|
20
|
+
if (providerMetrics.length === 0) {
|
|
21
|
+
console.log('\nā ļø No routing metrics found in the last 5 minutes.');
|
|
22
|
+
console.log(' This may be because:');
|
|
23
|
+
console.log(' - Telemetry was initialized in a different process');
|
|
24
|
+
console.log(' - No tiered routing requests were made');
|
|
25
|
+
console.log(' - Metrics have expired (5 min window)');
|
|
26
|
+
console.log('\nTo test routing, run: node scripts/test-routing-telemetry.cjs\n');
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
console.log(`\nā
Found ${providerMetrics.length} routing metrics\n`);
|
|
31
|
+
|
|
32
|
+
// Aggregate by provider
|
|
33
|
+
const providerBreakdown = {};
|
|
34
|
+
const tierBreakdown = {};
|
|
35
|
+
const agentTypeBreakdown = {};
|
|
36
|
+
const sourceBreakdown = {};
|
|
37
|
+
|
|
38
|
+
providerMetrics.forEach(metric => {
|
|
39
|
+
const provider = metric.tags.provider || 'unknown';
|
|
40
|
+
const tier = metric.tags.tier || 'unknown';
|
|
41
|
+
const agentType = metric.tags.agentType || 'unknown';
|
|
42
|
+
const source = metric.tags.source || 'unknown';
|
|
43
|
+
|
|
44
|
+
providerBreakdown[provider] = (providerBreakdown[provider] || 0) + metric.value;
|
|
45
|
+
tierBreakdown[tier] = (tierBreakdown[tier] || 0) + metric.value;
|
|
46
|
+
agentTypeBreakdown[agentType] = (agentTypeBreakdown[agentType] || 0) + metric.value;
|
|
47
|
+
sourceBreakdown[source] = (sourceBreakdown[source] || 0) + metric.value;
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// Display results
|
|
51
|
+
console.log('š BY PROVIDER:');
|
|
52
|
+
console.log('-'.repeat(60));
|
|
53
|
+
Object.entries(providerBreakdown)
|
|
54
|
+
.sort((a, b) => b[1] - a[1])
|
|
55
|
+
.forEach(([provider, count]) => {
|
|
56
|
+
const percentage = ((count / providerMetrics.length) * 100).toFixed(1);
|
|
57
|
+
const providerName = provider === 'custom' ? 'Z.ai (free tier)' :
|
|
58
|
+
provider === 'anthropic' ? 'Anthropic API' : provider;
|
|
59
|
+
console.log(` ${providerName.padEnd(30)} ${count.toString().padStart(3)} requests (${percentage}%)`);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
console.log('\nšÆ BY TIER:');
|
|
63
|
+
console.log('-'.repeat(60));
|
|
64
|
+
Object.entries(tierBreakdown)
|
|
65
|
+
.sort((a, b) => b[1] - a[1])
|
|
66
|
+
.forEach(([tier, count]) => {
|
|
67
|
+
const percentage = ((count / providerMetrics.length) * 100).toFixed(1);
|
|
68
|
+
console.log(` ${tier.padEnd(30)} ${count.toString().padStart(3)} requests (${percentage}%)`);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
console.log('\nš¤ BY AGENT TYPE:');
|
|
72
|
+
console.log('-'.repeat(60));
|
|
73
|
+
Object.entries(agentTypeBreakdown)
|
|
74
|
+
.sort((a, b) => b[1] - a[1])
|
|
75
|
+
.forEach(([agentType, count]) => {
|
|
76
|
+
const percentage = ((count / providerMetrics.length) * 100).toFixed(1);
|
|
77
|
+
console.log(` ${agentType.padEnd(30)} ${count.toString().padStart(3)} requests (${percentage}%)`);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
console.log('\nš BY ROUTING SOURCE:');
|
|
81
|
+
console.log('-'.repeat(60));
|
|
82
|
+
Object.entries(sourceBreakdown)
|
|
83
|
+
.sort((a, b) => b[1] - a[1])
|
|
84
|
+
.forEach(([source, count]) => {
|
|
85
|
+
const percentage = ((count / providerMetrics.length) * 100).toFixed(1);
|
|
86
|
+
console.log(` ${source.padEnd(30)} ${count.toString().padStart(3)} requests (${percentage}%)`);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// Check for subscription metrics
|
|
90
|
+
const subMetrics = telemetry.getMetrics('subscription.usage', 300000);
|
|
91
|
+
if (subMetrics.length > 0) {
|
|
92
|
+
const latestSub = subMetrics[subMetrics.length - 1];
|
|
93
|
+
console.log('\nš SUBSCRIPTION USAGE:');
|
|
94
|
+
console.log('-'.repeat(60));
|
|
95
|
+
console.log(` Used: ${latestSub.value}/${latestSub.tags.limit}`);
|
|
96
|
+
console.log(` Remaining: ${latestSub.tags.remaining}`);
|
|
97
|
+
console.log(` Status: ${latestSub.value >= parseInt(latestSub.tags.limit) ? 'ā ļø LIMIT REACHED' : 'ā
Available'}`);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Throughput analysis
|
|
101
|
+
const throughput = telemetry.getThroughputMetrics('provider.request', 300000);
|
|
102
|
+
console.log('\nā” THROUGHPUT ANALYSIS:');
|
|
103
|
+
console.log('-'.repeat(60));
|
|
104
|
+
console.log(` Total requests: ${throughput.totalRequests}`);
|
|
105
|
+
console.log(` Requests/sec: ${throughput.requestsPerSecond.toFixed(2)}`);
|
|
106
|
+
console.log(` Time window: Last 5 minutes`);
|
|
107
|
+
|
|
108
|
+
console.log('\n' + '='.repeat(60));
|
|
109
|
+
console.log('ā
Routing statistics retrieved successfully\n');
|
|
110
|
+
|
|
111
|
+
} catch (error) {
|
|
112
|
+
console.error('ā Error retrieving routing statistics:', error.message);
|
|
113
|
+
console.error('\nThis may happen if telemetry is not initialized.');
|
|
114
|
+
console.error('Try running a routing test first: node scripts/test-routing-telemetry.cjs\n');
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Run stats check
|
|
119
|
+
checkRoutingStats().catch(err => {
|
|
120
|
+
console.error('Fatal error:', err);
|
|
121
|
+
process.exit(1);
|
|
122
|
+
});
|