agentic-flow 2.0.3 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/agents/test-neural.md +14 -0
- package/.claude/settings.json +9 -133
- package/README.md +624 -1776
- package/dist/.tsbuildinfo +1 -1
- package/dist/billing/mcp/tools.js +0 -1
- package/dist/billing/mcp/tools.js.map +1 -1
- package/dist/cli/commands/hooks.d.ts.map +1 -1
- package/dist/cli/commands/hooks.js +4 -79
- package/dist/cli/commands/hooks.js.map +1 -1
- package/dist/cli-proxy.js +1 -89
- package/dist/cli-proxy.js.map +1 -1
- package/dist/core/agentdb-fast.js +3 -3
- package/dist/core/agentdb-fast.js.map +1 -1
- package/dist/core/agentdb-wrapper-enhanced.d.ts.map +1 -1
- package/dist/core/agentdb-wrapper-enhanced.js +4 -20
- package/dist/core/agentdb-wrapper-enhanced.js.map +1 -1
- package/dist/core/agentdb-wrapper.d.ts +2 -3
- package/dist/core/agentdb-wrapper.d.ts.map +1 -1
- package/dist/core/agentdb-wrapper.js +1 -15
- package/dist/core/agentdb-wrapper.js.map +1 -1
- package/dist/core/attention-native.d.ts +0 -4
- package/dist/core/attention-native.d.ts.map +1 -1
- package/dist/core/attention-native.js +2 -14
- package/dist/core/attention-native.js.map +1 -1
- package/dist/federation/SecurityManager.d.ts +2 -11
- package/dist/federation/SecurityManager.d.ts.map +1 -1
- package/dist/federation/SecurityManager.js +17 -50
- package/dist/federation/SecurityManager.js.map +1 -1
- package/dist/federation/integrations/supabase-adapter-debug.js +3 -3
- package/dist/federation/integrations/supabase-adapter-debug.js.map +1 -1
- package/dist/hooks/swarm-learning-optimizer.js +5 -5
- package/dist/hooks/swarm-learning-optimizer.js.map +1 -1
- package/dist/intelligence/IntelligenceStore.d.ts +26 -35
- package/dist/intelligence/IntelligenceStore.d.ts.map +1 -1
- package/dist/intelligence/IntelligenceStore.js +123 -308
- package/dist/intelligence/IntelligenceStore.js.map +1 -1
- package/dist/intelligence/RuVectorIntelligence.d.ts +1 -26
- package/dist/intelligence/RuVectorIntelligence.d.ts.map +1 -1
- package/dist/intelligence/RuVectorIntelligence.js +10 -49
- package/dist/intelligence/RuVectorIntelligence.js.map +1 -1
- package/dist/intelligence/agent-booster-enhanced.d.ts +0 -1
- package/dist/intelligence/agent-booster-enhanced.d.ts.map +1 -1
- package/dist/intelligence/agent-booster-enhanced.js +3 -24
- package/dist/intelligence/agent-booster-enhanced.js.map +1 -1
- package/dist/intelligence/index.d.ts +3 -29
- package/dist/intelligence/index.d.ts.map +1 -1
- package/dist/intelligence/index.js +3 -13
- package/dist/intelligence/index.js.map +1 -1
- package/dist/mcp/claudeFlowSdkServer.d.ts.map +1 -1
- package/dist/mcp/claudeFlowSdkServer.js +3 -9
- package/dist/mcp/claudeFlowSdkServer.js.map +1 -1
- package/dist/mcp/fastmcp/tools/hooks/intelligence-bridge.js +5 -5
- package/dist/mcp/fastmcp/tools/hooks/intelligence-bridge.js.map +1 -1
- package/dist/mcp/fastmcp/tools/swarm/init.d.ts.map +1 -1
- package/dist/mcp/fastmcp/tools/swarm/init.js +7 -36
- package/dist/mcp/fastmcp/tools/swarm/init.js.map +1 -1
- package/dist/mcp/fastmcp/tools/swarm/spawn.d.ts.map +1 -1
- package/dist/mcp/fastmcp/tools/swarm/spawn.js +8 -47
- package/dist/mcp/fastmcp/tools/swarm/spawn.js.map +1 -1
- package/dist/mcp/tools/agent-booster-tools.d.ts +1 -1
- package/dist/mcp/tools/agent-booster-tools.d.ts.map +1 -1
- package/dist/mcp/tools/agent-booster-tools.js +4 -10
- package/dist/mcp/tools/agent-booster-tools.js.map +1 -1
- package/dist/mcp/tools/sona-tools.d.ts.map +1 -1
- package/dist/mcp/tools/sona-tools.js +0 -6
- package/dist/mcp/tools/sona-tools.js.map +1 -1
- package/dist/optimizations/agent-booster-migration.d.ts.map +1 -1
- package/dist/optimizations/agent-booster-migration.js +2 -5
- package/dist/optimizations/agent-booster-migration.js.map +1 -1
- package/dist/proxy/anthropic-to-openrouter.js.map +1 -1
- package/dist/proxy/anthropic-to-requesty.js.map +1 -1
- package/dist/proxy/quic-proxy.d.ts +1 -0
- package/dist/proxy/quic-proxy.d.ts.map +1 -1
- package/dist/proxy/quic-proxy.js +2 -2
- package/dist/proxy/quic-proxy.js.map +1 -1
- package/dist/reasoningbank/AdvancedMemory.js +1 -1
- package/dist/reasoningbank/AdvancedMemory.js.map +1 -1
- package/dist/reasoningbank/HybridBackend.d.ts.map +1 -1
- package/dist/reasoningbank/HybridBackend.js +5 -2
- package/dist/reasoningbank/HybridBackend.js.map +1 -1
- package/dist/reasoningbank/backend-selector.d.ts +1 -11
- package/dist/reasoningbank/backend-selector.d.ts.map +1 -1
- package/dist/reasoningbank/backend-selector.js +5 -45
- package/dist/reasoningbank/backend-selector.js.map +1 -1
- package/dist/reasoningbank/core/consolidate.d.ts.map +1 -1
- package/dist/reasoningbank/core/consolidate.js +45 -113
- package/dist/reasoningbank/core/consolidate.js.map +1 -1
- package/dist/reasoningbank/index-new.d.ts +6 -1
- package/dist/reasoningbank/index-new.d.ts.map +1 -1
- package/dist/reasoningbank/index-new.js +6 -1
- package/dist/reasoningbank/index-new.js.map +1 -1
- package/dist/reasoningbank/index.d.ts +6 -2
- package/dist/reasoningbank/index.d.ts.map +1 -1
- package/dist/reasoningbank/index.js +6 -2
- package/dist/reasoningbank/index.js.map +1 -1
- package/dist/reasoningbank/utils/embeddings.d.ts +0 -1
- package/dist/reasoningbank/utils/embeddings.d.ts.map +1 -1
- package/dist/reasoningbank/utils/embeddings.js +26 -53
- package/dist/reasoningbank/utils/embeddings.js.map +1 -1
- package/dist/router/index.d.ts +18 -0
- package/dist/router/index.d.ts.map +1 -0
- package/dist/router/index.js +19 -0
- package/dist/router/index.js.map +1 -0
- package/dist/router/providers/onnx-local-optimized.d.ts +0 -2
- package/dist/router/providers/onnx-local-optimized.d.ts.map +1 -1
- package/dist/router/providers/onnx-local-optimized.js +0 -10
- package/dist/router/providers/onnx-local-optimized.js.map +1 -1
- package/dist/router/providers/onnx-local.d.ts +0 -1
- package/dist/router/providers/onnx-local.d.ts.map +1 -1
- package/dist/router/providers/onnx-local.js +5 -22
- package/dist/router/providers/onnx-local.js.map +1 -1
- package/dist/services/embedding-service.js.map +1 -1
- package/dist/services/sona-agent-training.d.ts +0 -1
- package/dist/services/sona-agent-training.d.ts.map +1 -1
- package/dist/services/sona-agent-training.js.map +1 -1
- package/dist/services/sona-agentdb-integration.d.ts.map +1 -1
- package/dist/services/sona-agentdb-integration.js +6 -9
- package/dist/services/sona-agentdb-integration.js.map +1 -1
- package/dist/services/sona-service.d.ts.map +1 -1
- package/dist/services/sona-service.js +5 -6
- package/dist/services/sona-service.js.map +1 -1
- package/dist/utils/cli.d.ts +1 -1
- package/dist/utils/cli.d.ts.map +1 -1
- package/dist/utils/cli.js +0 -21
- package/dist/utils/cli.js.map +1 -1
- package/package.json +7 -19
- package/scripts/postinstall.js +4 -45
- package/.claude/agents/.claude-flow/metrics/agent-metrics.json +0 -1
- package/.claude/agents/.claude-flow/metrics/performance.json +0 -87
- package/.claude/agents/.claude-flow/metrics/task-metrics.json +0 -10
- package/.claude/skills/.claude-flow/metrics/agent-metrics.json +0 -1
- package/.claude/skills/.claude-flow/metrics/performance.json +0 -87
- package/.claude/skills/.claude-flow/metrics/task-metrics.json +0 -10
- package/.claude/skills/agentic-flow-quickstart/skill.md +0 -69
- package/.claude/skills/hooks-automation/skill.md +0 -155
- package/.claude/skills/memory-patterns/skill.md +0 -110
- package/.claude/skills/skill-builder/.claude-flow/metrics/agent-metrics.json +0 -1
- package/.claude/skills/skill-builder/.claude-flow/metrics/performance.json +0 -87
- package/.claude/skills/skill-builder/.claude-flow/metrics/task-metrics.json +0 -10
- package/.claude/skills/sparc-methodology/skill.md +0 -137
- package/.claude/skills/swarm-coordination/skill.md +0 -94
- package/.claude/skills/worker-benchmarks/skill.md +0 -135
- package/.claude/skills/worker-integration/skill.md +0 -154
- package/.claude/statusline.mjs +0 -109
- package/.claude/statusline.sh +0 -71
- package/dist/agentdb/benchmarks/comprehensive-benchmark.js +0 -664
- package/dist/agentdb/benchmarks/frontier-benchmark.js +0 -419
- package/dist/agentdb/benchmarks/reflexion-benchmark.js +0 -370
- package/dist/agentdb/cli/agentdb-cli.js +0 -717
- package/dist/agentdb/controllers/CausalMemoryGraph.js +0 -322
- package/dist/agentdb/controllers/CausalRecall.js +0 -281
- package/dist/agentdb/controllers/EmbeddingService.d.ts +0 -37
- package/dist/agentdb/controllers/EmbeddingService.d.ts.map +0 -1
- package/dist/agentdb/controllers/EmbeddingService.js +0 -119
- package/dist/agentdb/controllers/EmbeddingService.js.map +0 -1
- package/dist/agentdb/controllers/ExplainableRecall.js +0 -387
- package/dist/agentdb/controllers/NightlyLearner.js +0 -382
- package/dist/agentdb/controllers/ReflexionMemory.js +0 -239
- package/dist/agentdb/controllers/SkillLibrary.js +0 -276
- package/dist/agentdb/controllers/frontier-index.js +0 -9
- package/dist/agentdb/controllers/index.js +0 -8
- package/dist/agentdb/optimizations/BatchOperations.js +0 -198
- package/dist/agentdb/optimizations/QueryOptimizer.js +0 -225
- package/dist/agentdb/optimizations/index.js +0 -7
- package/dist/agentdb/tests/frontier-features.test.js +0 -665
- package/dist/benchmarks/embeddings-benchmark.d.ts +0 -38
- package/dist/benchmarks/embeddings-benchmark.d.ts.map +0 -1
- package/dist/benchmarks/embeddings-benchmark.js +0 -282
- package/dist/benchmarks/embeddings-benchmark.js.map +0 -1
- package/dist/cli/commands/embeddings.d.ts +0 -12
- package/dist/cli/commands/embeddings.d.ts.map +0 -1
- package/dist/cli/commands/embeddings.js +0 -386
- package/dist/cli/commands/embeddings.js.map +0 -1
- package/dist/cli/commands/init.d.ts +0 -8
- package/dist/cli/commands/init.d.ts.map +0 -1
- package/dist/cli/commands/init.js +0 -514
- package/dist/cli/commands/init.js.map +0 -1
- package/dist/cli/commands/workers.d.ts +0 -9
- package/dist/cli/commands/workers.d.ts.map +0 -1
- package/dist/cli/commands/workers.js +0 -991
- package/dist/cli/commands/workers.js.map +0 -1
- package/dist/cli/skills-manager.js +0 -1297
- package/dist/cli/update-message.js +0 -175
- package/dist/embeddings/index.d.ts +0 -17
- package/dist/embeddings/index.d.ts.map +0 -1
- package/dist/embeddings/index.js +0 -17
- package/dist/embeddings/index.js.map +0 -1
- package/dist/embeddings/neural-substrate.d.ts +0 -206
- package/dist/embeddings/neural-substrate.d.ts.map +0 -1
- package/dist/embeddings/neural-substrate.js +0 -629
- package/dist/embeddings/neural-substrate.js.map +0 -1
- package/dist/embeddings/optimized-embedder.d.ts +0 -103
- package/dist/embeddings/optimized-embedder.d.ts.map +0 -1
- package/dist/embeddings/optimized-embedder.js +0 -730
- package/dist/embeddings/optimized-embedder.js.map +0 -1
- package/dist/examples/embedding-geometry.d.ts +0 -105
- package/dist/examples/embedding-geometry.d.ts.map +0 -1
- package/dist/examples/embedding-geometry.js +0 -528
- package/dist/examples/embedding-geometry.js.map +0 -1
- package/dist/memory/SharedMemoryPool.d.ts +0 -129
- package/dist/memory/SharedMemoryPool.d.ts.map +0 -1
- package/dist/memory/SharedMemoryPool.js +0 -243
- package/dist/memory/SharedMemoryPool.js.map +0 -1
- package/dist/memory/index.d.ts +0 -8
- package/dist/memory/index.d.ts.map +0 -1
- package/dist/memory/index.js +0 -7
- package/dist/memory/index.js.map +0 -1
- package/dist/proxy/http3-proxy-old.js +0 -331
- package/dist/proxy/proxy/anthropic-to-gemini.js +0 -439
- package/dist/proxy/utils/logger.js +0 -59
- package/dist/reasoningbank/agentdb-adapter.js +0 -125
- package/dist/reasoningbank/core/database.js +0 -250
- package/dist/reasoningbank/core/memory-engine.js +0 -335
- package/dist/swarm/ipfs-swarm.d.ts +0 -265
- package/dist/swarm/ipfs-swarm.d.ts.map +0 -1
- package/dist/swarm/ipfs-swarm.js +0 -508
- package/dist/swarm/ipfs-swarm.js.map +0 -1
- package/dist/swarm/p2p-free-swarm.d.ts +0 -344
- package/dist/swarm/p2p-free-swarm.d.ts.map +0 -1
- package/dist/swarm/p2p-free-swarm.js +0 -603
- package/dist/swarm/p2p-free-swarm.js.map +0 -1
- package/dist/swarm/real-p2p-swarm.d.ts +0 -183
- package/dist/swarm/real-p2p-swarm.d.ts.map +0 -1
- package/dist/swarm/real-p2p-swarm.js +0 -469
- package/dist/swarm/real-p2p-swarm.js.map +0 -1
- package/dist/utils/adaptive-pool-sizing.js +0 -414
- package/dist/utils/agentdbCommands.js +0 -175
- package/dist/utils/circular-rate-limiter.js +0 -391
- package/dist/utils/dynamic-compression.js +0 -298
- package/dist/utils/http2-multiplexing.js +0 -319
- package/dist/utils/index.d.ts +0 -6
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -6
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/lazy-auth.js +0 -311
- package/dist/utils/model-cache.d.ts +0 -61
- package/dist/utils/model-cache.d.ts.map +0 -1
- package/dist/utils/model-cache.js +0 -176
- package/dist/utils/model-cache.js.map +0 -1
- package/dist/utils/server-push.js +0 -251
- package/dist/utils/suppress-warnings.d.ts +0 -19
- package/dist/utils/suppress-warnings.d.ts.map +0 -1
- package/dist/utils/suppress-warnings.js +0 -59
- package/dist/utils/suppress-warnings.js.map +0 -1
- package/dist/utils/zero-copy-buffer.js +0 -286
- package/dist/workers/consolidated-phases.d.ts +0 -40
- package/dist/workers/consolidated-phases.d.ts.map +0 -1
- package/dist/workers/consolidated-phases.js +0 -497
- package/dist/workers/consolidated-phases.js.map +0 -1
- package/dist/workers/custom-worker-config.d.ts +0 -133
- package/dist/workers/custom-worker-config.d.ts.map +0 -1
- package/dist/workers/custom-worker-config.js +0 -215
- package/dist/workers/custom-worker-config.js.map +0 -1
- package/dist/workers/custom-worker-factory.d.ts +0 -89
- package/dist/workers/custom-worker-factory.d.ts.map +0 -1
- package/dist/workers/custom-worker-factory.js +0 -404
- package/dist/workers/custom-worker-factory.js.map +0 -1
- package/dist/workers/dispatch-service.d.ts +0 -123
- package/dist/workers/dispatch-service.d.ts.map +0 -1
- package/dist/workers/dispatch-service.js +0 -1024
- package/dist/workers/dispatch-service.js.map +0 -1
- package/dist/workers/hooks-integration.d.ts +0 -79
- package/dist/workers/hooks-integration.d.ts.map +0 -1
- package/dist/workers/hooks-integration.js +0 -286
- package/dist/workers/hooks-integration.js.map +0 -1
- package/dist/workers/index.d.ts +0 -42
- package/dist/workers/index.d.ts.map +0 -1
- package/dist/workers/index.js +0 -52
- package/dist/workers/index.js.map +0 -1
- package/dist/workers/mcp-tools.d.ts +0 -56
- package/dist/workers/mcp-tools.d.ts.map +0 -1
- package/dist/workers/mcp-tools.js +0 -359
- package/dist/workers/mcp-tools.js.map +0 -1
- package/dist/workers/phase-executors.d.ts +0 -22
- package/dist/workers/phase-executors.d.ts.map +0 -1
- package/dist/workers/phase-executors.js +0 -445
- package/dist/workers/phase-executors.js.map +0 -1
- package/dist/workers/resource-governor.d.ts +0 -75
- package/dist/workers/resource-governor.d.ts.map +0 -1
- package/dist/workers/resource-governor.js +0 -187
- package/dist/workers/resource-governor.js.map +0 -1
- package/dist/workers/ruvector-integration.d.ts +0 -163
- package/dist/workers/ruvector-integration.d.ts.map +0 -1
- package/dist/workers/ruvector-integration.js +0 -543
- package/dist/workers/ruvector-integration.js.map +0 -1
- package/dist/workers/ruvector-native-integration.d.ts +0 -91
- package/dist/workers/ruvector-native-integration.d.ts.map +0 -1
- package/dist/workers/ruvector-native-integration.js +0 -254
- package/dist/workers/ruvector-native-integration.js.map +0 -1
- package/dist/workers/trigger-detector.d.ts +0 -68
- package/dist/workers/trigger-detector.d.ts.map +0 -1
- package/dist/workers/trigger-detector.js +0 -281
- package/dist/workers/trigger-detector.js.map +0 -1
- package/dist/workers/types.d.ts +0 -145
- package/dist/workers/types.d.ts.map +0 -1
- package/dist/workers/types.js +0 -6
- package/dist/workers/types.js.map +0 -1
- package/dist/workers/worker-agent-integration.d.ts +0 -140
- package/dist/workers/worker-agent-integration.d.ts.map +0 -1
- package/dist/workers/worker-agent-integration.js +0 -471
- package/dist/workers/worker-agent-integration.js.map +0 -1
- package/dist/workers/worker-benchmarks.d.ts +0 -88
- package/dist/workers/worker-benchmarks.d.ts.map +0 -1
- package/dist/workers/worker-benchmarks.js +0 -452
- package/dist/workers/worker-benchmarks.js.map +0 -1
- package/dist/workers/worker-registry.d.ts +0 -85
- package/dist/workers/worker-registry.d.ts.map +0 -1
- package/dist/workers/worker-registry.js +0 -547
- package/dist/workers/worker-registry.js.map +0 -1
- package/docs/.claude-flow/metrics/agent-metrics.json +0 -1
- package/docs/.claude-flow/metrics/performance.json +0 -87
- package/docs/.claude-flow/metrics/task-metrics.json +0 -10
- package/docs/embeddings/EMBEDDING_GEOMETRY.md +0 -935
- /package/.claude/agents/analysis/{analyze-code-quality.md → code-review/analyze-code-quality.md} +0 -0
- /package/.claude/agents/architecture/{arch-system-design.md → system-design/arch-system-design.md} +0 -0
- /package/.claude/agents/data/{data-ml-model.md → ml/data-ml-model.md} +0 -0
- /package/.claude/agents/development/{dev-backend-api.md → backend/dev-backend-api.md} +0 -0
- /package/.claude/agents/devops/{ops-cicd-github.md → ci-cd/ops-cicd-github.md} +0 -0
- /package/.claude/agents/documentation/{docs-api-openapi.md → api-docs/docs-api-openapi.md} +0 -0
- /package/.claude/agents/specialized/{spec-mobile-react-native.md → mobile/spec-mobile-react-native.md} +0 -0
- /package/.claude/agents/testing/{tdd-london-swarm.md → unit/tdd-london-swarm.md} +0 -0
- /package/.claude/agents/testing/{production-validator.md → validation/production-validator.md} +0 -0
|
@@ -1,991 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* CLI Commands for Background Workers
|
|
4
|
-
* Provides CLI interface for worker management
|
|
5
|
-
*/
|
|
6
|
-
import { Command } from 'commander';
|
|
7
|
-
import { getWorkerDispatchService, getTriggerDetector, getWorkerRegistry, getResourceGovernor, customWorkerManager, formatWorkerInfo, formatPresetList, WORKER_PRESETS, listPhaseExecutors } from '../../workers/index.js';
|
|
8
|
-
export function createWorkersCommand() {
|
|
9
|
-
const workers = new Command('workers')
|
|
10
|
-
.description('Background worker management - non-blocking tasks that run silently')
|
|
11
|
-
.addHelpCommand(true) // Enable 'workers help <subcommand>'
|
|
12
|
-
.action(() => {
|
|
13
|
-
// Default action when no subcommand provided - show help
|
|
14
|
-
workers.outputHelp();
|
|
15
|
-
});
|
|
16
|
-
// Dispatch command
|
|
17
|
-
workers
|
|
18
|
-
.command('dispatch <prompt>')
|
|
19
|
-
.description('Detect triggers in prompt and dispatch background workers')
|
|
20
|
-
.option('-s, --session <id>', 'Session ID', `session-${Date.now()}`)
|
|
21
|
-
.option('-j, --json', 'Output as JSON')
|
|
22
|
-
.action(async (prompt, options) => {
|
|
23
|
-
try {
|
|
24
|
-
const dispatcher = getWorkerDispatchService();
|
|
25
|
-
const { triggers, workerIds } = await dispatcher.dispatchFromPrompt(prompt, options.session);
|
|
26
|
-
if (options.json) {
|
|
27
|
-
console.log(JSON.stringify({ triggers, workerIds }, null, 2));
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
if (triggers.length === 0) {
|
|
31
|
-
console.log('No triggers detected in prompt');
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
console.log('\n\u26A1 Background Workers Spawned:\n');
|
|
35
|
-
for (let i = 0; i < triggers.length; i++) {
|
|
36
|
-
const trigger = triggers[i];
|
|
37
|
-
const workerId = workerIds[i];
|
|
38
|
-
console.log(` \u2022 ${trigger.keyword}: ${workerId}`);
|
|
39
|
-
if (trigger.topic) {
|
|
40
|
-
console.log(` Topic: "${trigger.topic}"`);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
console.log(`\nUse 'workers status' to monitor progress\n`);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
catch (error) {
|
|
47
|
-
console.error('Error:', error instanceof Error ? error.message : error);
|
|
48
|
-
process.exit(1);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
// Dispatch-prompt command (hook-optimized, silent background dispatch)
|
|
52
|
-
workers
|
|
53
|
-
.command('dispatch-prompt <prompt>')
|
|
54
|
-
.description('Dispatch workers from prompt (hook-optimized, silent)')
|
|
55
|
-
.option('-s, --session <id>', 'Session ID', `session-${Date.now()}`)
|
|
56
|
-
.option('-j, --json', 'Output as JSON')
|
|
57
|
-
.action(async (prompt, options) => {
|
|
58
|
-
try {
|
|
59
|
-
const detector = getTriggerDetector();
|
|
60
|
-
// Fast check if any triggers present
|
|
61
|
-
if (!detector.hasTriggers(prompt)) {
|
|
62
|
-
if (options.json) {
|
|
63
|
-
console.log(JSON.stringify({ dispatched: false, triggers: [], workerIds: [] }));
|
|
64
|
-
}
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
const dispatcher = getWorkerDispatchService();
|
|
68
|
-
const { triggers, workerIds } = await dispatcher.dispatchFromPrompt(prompt, options.session);
|
|
69
|
-
if (options.json) {
|
|
70
|
-
console.log(JSON.stringify({
|
|
71
|
-
dispatched: workerIds.length > 0,
|
|
72
|
-
triggers: triggers.map(t => t.keyword),
|
|
73
|
-
workerIds
|
|
74
|
-
}));
|
|
75
|
-
}
|
|
76
|
-
else if (workerIds.length > 0) {
|
|
77
|
-
// Minimal output for hook context
|
|
78
|
-
console.log(`\u26A1 ${triggers.map(t => t.keyword).join(', ')}`);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
catch {
|
|
82
|
-
// Silent failure for hooks - never block conversation
|
|
83
|
-
if (options.json) {
|
|
84
|
-
console.log(JSON.stringify({ dispatched: false, triggers: [], workerIds: [], error: true }));
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
// Status command
|
|
89
|
-
workers
|
|
90
|
-
.command('status [workerId]')
|
|
91
|
-
.description('Get worker status')
|
|
92
|
-
.option('-s, --session <id>', 'Filter by session')
|
|
93
|
-
.option('-a, --active', 'Show only active workers')
|
|
94
|
-
.option('-j, --json', 'Output as JSON')
|
|
95
|
-
.action(async (workerId, options) => {
|
|
96
|
-
try {
|
|
97
|
-
const registry = getWorkerRegistry();
|
|
98
|
-
const governor = getResourceGovernor();
|
|
99
|
-
if (workerId) {
|
|
100
|
-
// Single worker status
|
|
101
|
-
const worker = registry.get(workerId);
|
|
102
|
-
if (!worker) {
|
|
103
|
-
console.error(`Worker not found: ${workerId}`);
|
|
104
|
-
process.exit(1);
|
|
105
|
-
}
|
|
106
|
-
if (options.json) {
|
|
107
|
-
console.log(JSON.stringify(worker, null, 2));
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
displayWorkerDetails(worker);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
// All workers status
|
|
115
|
-
const workers = options.active
|
|
116
|
-
? registry.getActive(options.session)
|
|
117
|
-
: registry.getAll({ sessionId: options.session, limit: 20 });
|
|
118
|
-
if (options.json) {
|
|
119
|
-
console.log(JSON.stringify(workers, null, 2));
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
displayWorkerDashboard(workers, governor.getStats());
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
catch (error) {
|
|
127
|
-
console.error('Error:', error instanceof Error ? error.message : error);
|
|
128
|
-
process.exit(1);
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
// Cancel command
|
|
132
|
-
workers
|
|
133
|
-
.command('cancel <workerId>')
|
|
134
|
-
.description('Cancel a running worker')
|
|
135
|
-
.action(async (workerId) => {
|
|
136
|
-
try {
|
|
137
|
-
const dispatcher = getWorkerDispatchService();
|
|
138
|
-
const cancelled = dispatcher.cancel(workerId);
|
|
139
|
-
if (cancelled) {
|
|
140
|
-
console.log(`\u2705 Worker ${workerId} cancelled`);
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
console.log(`\u274C Could not cancel ${workerId} - may not be running`);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
catch (error) {
|
|
147
|
-
console.error('Error:', error instanceof Error ? error.message : error);
|
|
148
|
-
process.exit(1);
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
// List triggers command
|
|
152
|
-
workers
|
|
153
|
-
.command('triggers')
|
|
154
|
-
.description('List all available trigger keywords')
|
|
155
|
-
.option('-j, --json', 'Output as JSON')
|
|
156
|
-
.action(async (options) => {
|
|
157
|
-
try {
|
|
158
|
-
const detector = getTriggerDetector();
|
|
159
|
-
const configs = detector.getAllConfigs();
|
|
160
|
-
const stats = detector.getStats();
|
|
161
|
-
if (options.json) {
|
|
162
|
-
const triggers = Array.from(configs.entries()).map(([keyword, config]) => ({
|
|
163
|
-
keyword,
|
|
164
|
-
...config,
|
|
165
|
-
topicExtractor: config.topicExtractor?.source
|
|
166
|
-
}));
|
|
167
|
-
console.log(JSON.stringify({ triggers, cooldowns: stats.cooldowns }, null, 2));
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
console.log('\n\u26A1 Available Background Worker Triggers:\n');
|
|
171
|
-
console.log('\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510');
|
|
172
|
-
console.log('\u2502 Trigger \u2502 Priority \u2502 Description \u2502');
|
|
173
|
-
console.log('\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524');
|
|
174
|
-
Array.from(configs.entries()).forEach(([keyword, config]) => {
|
|
175
|
-
const cooldown = stats.cooldowns[keyword];
|
|
176
|
-
const cooldownStr = cooldown ? ` (${Math.ceil(cooldown / 1000)}s)` : '';
|
|
177
|
-
console.log(`\u2502 ${keyword.padEnd(12)} \u2502 ${config.priority.padEnd(8)} \u2502 ${config.description.slice(0, 38).padEnd(38)} \u2502`);
|
|
178
|
-
});
|
|
179
|
-
console.log('\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n');
|
|
180
|
-
console.log('Usage: Include trigger word in your prompt');
|
|
181
|
-
console.log('Example: "ultralearn how authentication works"\n');
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
catch (error) {
|
|
185
|
-
console.error('Error:', error instanceof Error ? error.message : error);
|
|
186
|
-
process.exit(1);
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
// Stats command
|
|
190
|
-
workers
|
|
191
|
-
.command('stats')
|
|
192
|
-
.description('Get worker statistics')
|
|
193
|
-
.option('-t, --timeframe <period>', 'Timeframe: 1h, 24h, 7d', '24h')
|
|
194
|
-
.option('-j, --json', 'Output as JSON')
|
|
195
|
-
.action(async (options) => {
|
|
196
|
-
try {
|
|
197
|
-
const registry = getWorkerRegistry();
|
|
198
|
-
const governor = getResourceGovernor();
|
|
199
|
-
// Get stats with fallbacks for when db isn't available
|
|
200
|
-
let registryStats = { total: 0, byStatus: {}, byTrigger: {}, avgDuration: 0 };
|
|
201
|
-
try {
|
|
202
|
-
registryStats = registry.getStats(options.timeframe) || registryStats;
|
|
203
|
-
}
|
|
204
|
-
catch {
|
|
205
|
-
// Database not available - use defaults
|
|
206
|
-
}
|
|
207
|
-
let resourceStats = { activeWorkers: 0, memoryUsage: { heapUsed: 0 } };
|
|
208
|
-
try {
|
|
209
|
-
resourceStats = governor.getStats() || resourceStats;
|
|
210
|
-
}
|
|
211
|
-
catch {
|
|
212
|
-
// Resource governor not available
|
|
213
|
-
}
|
|
214
|
-
let availability = { usedSlots: 0, totalSlots: 10 };
|
|
215
|
-
try {
|
|
216
|
-
availability = governor.getAvailability() || availability;
|
|
217
|
-
}
|
|
218
|
-
catch {
|
|
219
|
-
// Availability not available
|
|
220
|
-
}
|
|
221
|
-
const stats = {
|
|
222
|
-
...registryStats,
|
|
223
|
-
resources: resourceStats,
|
|
224
|
-
availability
|
|
225
|
-
};
|
|
226
|
-
if (options.json) {
|
|
227
|
-
console.log(JSON.stringify(stats, null, 2));
|
|
228
|
-
}
|
|
229
|
-
else {
|
|
230
|
-
displayStats(stats, options.timeframe);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
catch (error) {
|
|
234
|
-
console.error('Error:', error instanceof Error ? error.message : error);
|
|
235
|
-
process.exit(1);
|
|
236
|
-
}
|
|
237
|
-
});
|
|
238
|
-
// Results command - view actual analysis data
|
|
239
|
-
workers
|
|
240
|
-
.command('results [workerId]')
|
|
241
|
-
.description('View worker analysis results (files analyzed, patterns found, etc.)')
|
|
242
|
-
.option('-s, --session <id>', 'Filter by session')
|
|
243
|
-
.option('-t, --trigger <type>', 'Filter by trigger type')
|
|
244
|
-
.option('-j, --json', 'Output as JSON')
|
|
245
|
-
.action(async (workerId, options) => {
|
|
246
|
-
try {
|
|
247
|
-
const registry = getWorkerRegistry();
|
|
248
|
-
if (workerId) {
|
|
249
|
-
// Single worker results
|
|
250
|
-
const worker = registry.get(workerId);
|
|
251
|
-
if (!worker) {
|
|
252
|
-
console.error(`Worker not found: ${workerId}`);
|
|
253
|
-
process.exit(1);
|
|
254
|
-
}
|
|
255
|
-
if (options.json) {
|
|
256
|
-
console.log(JSON.stringify({
|
|
257
|
-
workerId: worker.id,
|
|
258
|
-
trigger: worker.trigger,
|
|
259
|
-
topic: worker.topic,
|
|
260
|
-
status: worker.status,
|
|
261
|
-
results: worker.results || {}
|
|
262
|
-
}, null, 2));
|
|
263
|
-
}
|
|
264
|
-
else {
|
|
265
|
-
displayWorkerResults(worker);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
else {
|
|
269
|
-
// All completed workers with results
|
|
270
|
-
const workers = registry.getAll({
|
|
271
|
-
sessionId: options.session,
|
|
272
|
-
status: 'complete',
|
|
273
|
-
limit: 20
|
|
274
|
-
}).filter(w => w.results && Object.keys(w.results).length > 0);
|
|
275
|
-
if (options.trigger) {
|
|
276
|
-
const filtered = workers.filter(w => w.trigger === options.trigger);
|
|
277
|
-
workers.length = 0;
|
|
278
|
-
workers.push(...filtered);
|
|
279
|
-
}
|
|
280
|
-
if (options.json) {
|
|
281
|
-
console.log(JSON.stringify(workers.map(w => ({
|
|
282
|
-
workerId: w.id,
|
|
283
|
-
trigger: w.trigger,
|
|
284
|
-
topic: w.topic,
|
|
285
|
-
results: w.results
|
|
286
|
-
})), null, 2));
|
|
287
|
-
}
|
|
288
|
-
else {
|
|
289
|
-
displayResultsSummary(workers);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
catch (error) {
|
|
294
|
-
console.error('Error:', error instanceof Error ? error.message : error);
|
|
295
|
-
process.exit(1);
|
|
296
|
-
}
|
|
297
|
-
});
|
|
298
|
-
// Cleanup command
|
|
299
|
-
workers
|
|
300
|
-
.command('cleanup')
|
|
301
|
-
.description('Cleanup old worker records')
|
|
302
|
-
.option('-a, --age <hours>', 'Max age in hours', '24')
|
|
303
|
-
.action(async (options) => {
|
|
304
|
-
try {
|
|
305
|
-
const registry = getWorkerRegistry();
|
|
306
|
-
const maxAge = parseInt(options.age) * 60 * 60 * 1000;
|
|
307
|
-
const cleaned = registry.cleanup(maxAge);
|
|
308
|
-
console.log(`\u2705 Cleaned up ${cleaned} old worker records`);
|
|
309
|
-
}
|
|
310
|
-
catch (error) {
|
|
311
|
-
console.error('Error:', error instanceof Error ? error.message : error);
|
|
312
|
-
process.exit(1);
|
|
313
|
-
}
|
|
314
|
-
});
|
|
315
|
-
// ============================================================================
|
|
316
|
-
// Custom Worker Commands
|
|
317
|
-
// ============================================================================
|
|
318
|
-
// List presets command
|
|
319
|
-
workers
|
|
320
|
-
.command('presets')
|
|
321
|
-
.description('List available custom worker presets')
|
|
322
|
-
.option('-j, --json', 'Output as JSON')
|
|
323
|
-
.action(async (options) => {
|
|
324
|
-
try {
|
|
325
|
-
if (options.json) {
|
|
326
|
-
console.log(JSON.stringify(WORKER_PRESETS, null, 2));
|
|
327
|
-
}
|
|
328
|
-
else {
|
|
329
|
-
console.log(formatPresetList());
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
catch (error) {
|
|
333
|
-
console.error('Error:', error instanceof Error ? error.message : error);
|
|
334
|
-
process.exit(1);
|
|
335
|
-
}
|
|
336
|
-
});
|
|
337
|
-
// List phases command
|
|
338
|
-
workers
|
|
339
|
-
.command('phases')
|
|
340
|
-
.description('List available phase executors for custom workers')
|
|
341
|
-
.option('-j, --json', 'Output as JSON')
|
|
342
|
-
.action(async (options) => {
|
|
343
|
-
try {
|
|
344
|
-
const phases = listPhaseExecutors();
|
|
345
|
-
if (options.json) {
|
|
346
|
-
console.log(JSON.stringify({ phases }, null, 2));
|
|
347
|
-
}
|
|
348
|
-
else {
|
|
349
|
-
console.log('\n\u26A1 Available Phase Executors:\n');
|
|
350
|
-
const categories = {
|
|
351
|
-
'Discovery': phases.filter(p => p.includes('discovery')),
|
|
352
|
-
'Analysis': phases.filter(p => p.includes('analysis')),
|
|
353
|
-
'Pattern': phases.filter(p => p.includes('extraction') || p.includes('detection')),
|
|
354
|
-
'Build': phases.filter(p => p.includes('graph')),
|
|
355
|
-
'Learning': phases.filter(p => ['vectorization', 'embedding-generation', 'pattern-storage', 'sona-training'].includes(p)),
|
|
356
|
-
'Output': phases.filter(p => ['summarization', 'report-generation', 'indexing'].includes(p))
|
|
357
|
-
};
|
|
358
|
-
for (const [category, categoryPhases] of Object.entries(categories)) {
|
|
359
|
-
if (categoryPhases.length > 0) {
|
|
360
|
-
console.log(` ${category}:`);
|
|
361
|
-
categoryPhases.forEach(p => console.log(` \u2022 ${p}`));
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
console.log('\nUse these phases in custom worker definitions.\n');
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
catch (error) {
|
|
368
|
-
console.error('Error:', error instanceof Error ? error.message : error);
|
|
369
|
-
process.exit(1);
|
|
370
|
-
}
|
|
371
|
-
});
|
|
372
|
-
// Create custom worker from preset
|
|
373
|
-
workers
|
|
374
|
-
.command('create <name>')
|
|
375
|
-
.description('Create a custom worker from a preset')
|
|
376
|
-
.option('-p, --preset <preset>', 'Preset to use', 'quick-scan')
|
|
377
|
-
.option('-t, --triggers <triggers>', 'Comma-separated trigger keywords')
|
|
378
|
-
.option('-d, --description <desc>', 'Worker description')
|
|
379
|
-
.option('-j, --json', 'Output as JSON')
|
|
380
|
-
.action(async (name, options) => {
|
|
381
|
-
try {
|
|
382
|
-
const triggers = options.triggers?.split(',').map(t => t.trim()) || [name];
|
|
383
|
-
const worker = customWorkerManager.registerPreset(options.preset, {
|
|
384
|
-
name,
|
|
385
|
-
triggers,
|
|
386
|
-
description: options.description
|
|
387
|
-
});
|
|
388
|
-
if (options.json) {
|
|
389
|
-
console.log(JSON.stringify({
|
|
390
|
-
created: true,
|
|
391
|
-
name: worker.definition.name,
|
|
392
|
-
preset: options.preset,
|
|
393
|
-
triggers: [name, ...triggers]
|
|
394
|
-
}, null, 2));
|
|
395
|
-
}
|
|
396
|
-
else {
|
|
397
|
-
console.log(`\n\u2705 Created custom worker: ${name}\n`);
|
|
398
|
-
console.log(formatWorkerInfo(worker));
|
|
399
|
-
console.log(`\nUse trigger "${name}" or any of: ${triggers.join(', ')}\n`);
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
catch (error) {
|
|
403
|
-
console.error('Error:', error instanceof Error ? error.message : error);
|
|
404
|
-
process.exit(1);
|
|
405
|
-
}
|
|
406
|
-
});
|
|
407
|
-
// Run custom worker
|
|
408
|
-
workers
|
|
409
|
-
.command('run <nameOrTrigger>')
|
|
410
|
-
.description('Run a custom worker by name or trigger')
|
|
411
|
-
.option('-t, --topic <topic>', 'Topic to analyze')
|
|
412
|
-
.option('-s, --session <id>', 'Session ID', `session-${Date.now()}`)
|
|
413
|
-
.option('-j, --json', 'Output as JSON')
|
|
414
|
-
.action(async (nameOrTrigger, options) => {
|
|
415
|
-
try {
|
|
416
|
-
const worker = customWorkerManager.get(nameOrTrigger);
|
|
417
|
-
if (!worker) {
|
|
418
|
-
// Check if it's a preset
|
|
419
|
-
if (WORKER_PRESETS[nameOrTrigger]) {
|
|
420
|
-
console.log(`"${nameOrTrigger}" is a preset. Create a worker first:`);
|
|
421
|
-
console.log(` workers create my-worker --preset ${nameOrTrigger}`);
|
|
422
|
-
process.exit(1);
|
|
423
|
-
}
|
|
424
|
-
console.error(`Custom worker not found: ${nameOrTrigger}`);
|
|
425
|
-
console.log('Available workers:', customWorkerManager.list().map(w => w.definition.name).join(', ') || 'none');
|
|
426
|
-
console.log('Available presets:', customWorkerManager.listPresets().join(', '));
|
|
427
|
-
process.exit(1);
|
|
428
|
-
}
|
|
429
|
-
console.log(`\n\u26A1 Running custom worker: ${worker.definition.name}\n`);
|
|
430
|
-
const context = {
|
|
431
|
-
workerId: `custom-${Date.now()}`,
|
|
432
|
-
sessionId: options.session || `session-${Date.now()}`,
|
|
433
|
-
trigger: nameOrTrigger,
|
|
434
|
-
topic: options.topic || null,
|
|
435
|
-
startTime: Date.now(),
|
|
436
|
-
signal: new AbortController().signal,
|
|
437
|
-
onProgress: () => { },
|
|
438
|
-
onMemoryDeposit: () => { }
|
|
439
|
-
};
|
|
440
|
-
const results = await worker.execute(context);
|
|
441
|
-
if (options.json) {
|
|
442
|
-
console.log(JSON.stringify(results, null, 2));
|
|
443
|
-
}
|
|
444
|
-
else {
|
|
445
|
-
console.log(`Status: ${results.success ? '\u2705 Success' : '\u274C Failed'}`);
|
|
446
|
-
console.log(`Files Analyzed: ${results.data.files_analyzed || 0}`);
|
|
447
|
-
console.log(`Patterns Found: ${results.data.patterns_found || 0}`);
|
|
448
|
-
console.log(`Bytes Processed: ${(results.data.bytes_processed / 1024).toFixed(1)} KB`);
|
|
449
|
-
console.log(`Execution Time: ${results.data.executionTimeMs}ms`);
|
|
450
|
-
if (results.data.sample_patterns && Array.isArray(results.data.sample_patterns)) {
|
|
451
|
-
console.log('\nSample Patterns:');
|
|
452
|
-
results.data.sample_patterns.slice(0, 5).forEach((p) => {
|
|
453
|
-
console.log(` \u2022 ${p.slice(0, 80)}`);
|
|
454
|
-
});
|
|
455
|
-
}
|
|
456
|
-
if (results.data.errors && Array.isArray(results.data.errors)) {
|
|
457
|
-
console.log('\nErrors:');
|
|
458
|
-
results.data.errors.forEach((e) => console.log(` \u26A0 ${e}`));
|
|
459
|
-
}
|
|
460
|
-
console.log();
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
catch (error) {
|
|
464
|
-
console.error('Error:', error instanceof Error ? error.message : error);
|
|
465
|
-
process.exit(1);
|
|
466
|
-
}
|
|
467
|
-
});
|
|
468
|
-
// List custom workers
|
|
469
|
-
workers
|
|
470
|
-
.command('custom')
|
|
471
|
-
.description('List registered custom workers')
|
|
472
|
-
.option('-j, --json', 'Output as JSON')
|
|
473
|
-
.action(async (options) => {
|
|
474
|
-
try {
|
|
475
|
-
const workers = customWorkerManager.list();
|
|
476
|
-
if (options.json) {
|
|
477
|
-
console.log(JSON.stringify(workers.map(w => ({
|
|
478
|
-
name: w.definition.name,
|
|
479
|
-
description: w.definition.description,
|
|
480
|
-
triggers: [w.definition.name, ...(w.definition.triggers || [])],
|
|
481
|
-
phases: w.definition.phases.map(p => p.type)
|
|
482
|
-
})), null, 2));
|
|
483
|
-
}
|
|
484
|
-
else {
|
|
485
|
-
if (workers.length === 0) {
|
|
486
|
-
console.log('\nNo custom workers registered.\n');
|
|
487
|
-
console.log('Create one: workers create my-worker --preset quick-scan');
|
|
488
|
-
console.log('Load from config: workers load-config ./workers.yaml\n');
|
|
489
|
-
return;
|
|
490
|
-
}
|
|
491
|
-
console.log(`\n\u26A1 Custom Workers (${workers.length}):\n`);
|
|
492
|
-
for (const worker of workers) {
|
|
493
|
-
console.log(` ${worker.definition.name}`);
|
|
494
|
-
console.log(` ${worker.definition.description}`);
|
|
495
|
-
console.log(` Triggers: ${[worker.definition.name, ...(worker.definition.triggers || [])].join(', ')}`);
|
|
496
|
-
console.log(` Phases: ${worker.definition.phases.map(p => p.type).join(' \u2192 ')}`);
|
|
497
|
-
console.log();
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
catch (error) {
|
|
502
|
-
console.error('Error:', error instanceof Error ? error.message : error);
|
|
503
|
-
process.exit(1);
|
|
504
|
-
}
|
|
505
|
-
});
|
|
506
|
-
// Load custom workers from config file
|
|
507
|
-
workers
|
|
508
|
-
.command('load-config [path]')
|
|
509
|
-
.description('Load custom workers from a YAML/JSON config file')
|
|
510
|
-
.option('-j, --json', 'Output as JSON')
|
|
511
|
-
.action(async (configPath, options) => {
|
|
512
|
-
try {
|
|
513
|
-
const count = await customWorkerManager.loadFromConfig(configPath);
|
|
514
|
-
if (options.json) {
|
|
515
|
-
console.log(JSON.stringify({
|
|
516
|
-
loaded: count,
|
|
517
|
-
workers: customWorkerManager.list().map(w => w.definition.name)
|
|
518
|
-
}, null, 2));
|
|
519
|
-
}
|
|
520
|
-
else {
|
|
521
|
-
if (count === 0) {
|
|
522
|
-
console.log('\nNo config file found.');
|
|
523
|
-
console.log('Expected: workers.yaml, workers.yml, or workers.json');
|
|
524
|
-
console.log('Or specify path: workers load-config ./my-workers.yaml\n');
|
|
525
|
-
return;
|
|
526
|
-
}
|
|
527
|
-
console.log(`\n\u2705 Loaded ${count} custom worker(s)\n`);
|
|
528
|
-
customWorkerManager.list().forEach(w => {
|
|
529
|
-
console.log(` \u2022 ${w.definition.name}: ${w.definition.description}`);
|
|
530
|
-
});
|
|
531
|
-
console.log();
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
catch (error) {
|
|
535
|
-
console.error('Error:', error instanceof Error ? error.message : error);
|
|
536
|
-
process.exit(1);
|
|
537
|
-
}
|
|
538
|
-
});
|
|
539
|
-
// Generate example config
|
|
540
|
-
workers
|
|
541
|
-
.command('init-config')
|
|
542
|
-
.description('Generate an example workers.yaml config file')
|
|
543
|
-
.option('-o, --output <path>', 'Output path', 'workers.yaml')
|
|
544
|
-
.action(async (options) => {
|
|
545
|
-
try {
|
|
546
|
-
const fs = await import('fs/promises');
|
|
547
|
-
const config = customWorkerManager.generateExampleConfig();
|
|
548
|
-
await fs.writeFile(options.output, config);
|
|
549
|
-
console.log(`\n\u2705 Created ${options.output}\n`);
|
|
550
|
-
console.log('Edit the file to customize your workers, then run:');
|
|
551
|
-
console.log(` workers load-config ${options.output}\n`);
|
|
552
|
-
}
|
|
553
|
-
catch (error) {
|
|
554
|
-
console.error('Error:', error instanceof Error ? error.message : error);
|
|
555
|
-
process.exit(1);
|
|
556
|
-
}
|
|
557
|
-
});
|
|
558
|
-
// Inject context command (for hook usage)
|
|
559
|
-
workers
|
|
560
|
-
.command('inject-context <prompt>')
|
|
561
|
-
.description('Search for relevant background worker results to inject as context')
|
|
562
|
-
.option('-s, --session <id>', 'Session ID')
|
|
563
|
-
.option('-j, --json', 'Output as JSON')
|
|
564
|
-
.action(async (prompt, options) => {
|
|
565
|
-
try {
|
|
566
|
-
// Search completed workers for relevant results
|
|
567
|
-
const registry = getWorkerRegistry();
|
|
568
|
-
const completed = registry.getAll({
|
|
569
|
-
sessionId: options.session,
|
|
570
|
-
status: 'complete',
|
|
571
|
-
limit: 50
|
|
572
|
-
});
|
|
573
|
-
// Simple keyword matching for now
|
|
574
|
-
const keywords = prompt.toLowerCase().split(/\s+/).filter(w => w.length > 3);
|
|
575
|
-
const relevant = completed.filter(w => {
|
|
576
|
-
const workerText = `${w.trigger} ${w.topic || ''}`.toLowerCase();
|
|
577
|
-
return keywords.some(kw => workerText.includes(kw));
|
|
578
|
-
});
|
|
579
|
-
if (relevant.length === 0) {
|
|
580
|
-
// No context to inject
|
|
581
|
-
return;
|
|
582
|
-
}
|
|
583
|
-
const context = relevant.slice(0, 3).map(w => ({
|
|
584
|
-
source: 'background-worker',
|
|
585
|
-
type: w.trigger,
|
|
586
|
-
topic: w.topic,
|
|
587
|
-
memoryKeys: w.resultKeys,
|
|
588
|
-
completedAt: w.completedAt
|
|
589
|
-
}));
|
|
590
|
-
if (options.json) {
|
|
591
|
-
console.log(JSON.stringify({ context }, null, 2));
|
|
592
|
-
}
|
|
593
|
-
else {
|
|
594
|
-
console.log('<background-context>');
|
|
595
|
-
console.log(JSON.stringify(context, null, 2));
|
|
596
|
-
console.log('</background-context>');
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
catch (error) {
|
|
600
|
-
// Silent failure for hook usage
|
|
601
|
-
if (options.json) {
|
|
602
|
-
console.log(JSON.stringify({ context: [] }));
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
});
|
|
606
|
-
// ============================================================================
|
|
607
|
-
// Native RuVector Worker Commands
|
|
608
|
-
// ============================================================================
|
|
609
|
-
// Native worker run command
|
|
610
|
-
workers
|
|
611
|
-
.command('native <type>')
|
|
612
|
-
.description('Run native ruvector worker (security, analysis, learning)')
|
|
613
|
-
.option('-p, --path <dir>', 'Working directory', process.cwd())
|
|
614
|
-
.option('-j, --json', 'Output as JSON')
|
|
615
|
-
.action(async (type, options) => {
|
|
616
|
-
try {
|
|
617
|
-
const { nativeRunner, listNativePhases } = await import('../../workers/ruvector-native-integration.js');
|
|
618
|
-
let result;
|
|
619
|
-
switch (type) {
|
|
620
|
-
case 'security':
|
|
621
|
-
result = await nativeRunner.runSecurityScan(options.path);
|
|
622
|
-
break;
|
|
623
|
-
case 'analysis':
|
|
624
|
-
result = await nativeRunner.runFullAnalysis(options.path);
|
|
625
|
-
break;
|
|
626
|
-
case 'learning':
|
|
627
|
-
result = await nativeRunner.runLearning(options.path);
|
|
628
|
-
break;
|
|
629
|
-
case 'phases':
|
|
630
|
-
const phases = listNativePhases();
|
|
631
|
-
if (options.json) {
|
|
632
|
-
console.log(JSON.stringify({ phases }, null, 2));
|
|
633
|
-
}
|
|
634
|
-
else {
|
|
635
|
-
console.log('\n\u26A1 Native RuVector Phases:\n');
|
|
636
|
-
phases.forEach(p => console.log(` \u2022 ${p}`));
|
|
637
|
-
console.log();
|
|
638
|
-
}
|
|
639
|
-
return;
|
|
640
|
-
default:
|
|
641
|
-
console.error(`Unknown native worker type: ${type}`);
|
|
642
|
-
console.log('Available: security, analysis, learning, phases');
|
|
643
|
-
process.exit(1);
|
|
644
|
-
}
|
|
645
|
-
if (options.json) {
|
|
646
|
-
console.log(JSON.stringify(result, null, 2));
|
|
647
|
-
}
|
|
648
|
-
else {
|
|
649
|
-
console.log(`\n\u26A1 Native Worker: ${type}\n`);
|
|
650
|
-
console.log('\u2550'.repeat(50));
|
|
651
|
-
console.log(`Status: ${result.success ? '\u2705 Success' : '\u274C Failed'}`);
|
|
652
|
-
console.log(`Phases: ${result.phases.join(' \u2192 ')}`);
|
|
653
|
-
console.log(`\n\uD83D\uDCCA Metrics:`);
|
|
654
|
-
console.log(` Files Analyzed: ${result.metrics.filesAnalyzed}`);
|
|
655
|
-
console.log(` Patterns Found: ${result.metrics.patternsFound}`);
|
|
656
|
-
console.log(` Embeddings: ${result.metrics.embeddingsGenerated}`);
|
|
657
|
-
console.log(` Vectors Stored: ${result.metrics.vectorsStored}`);
|
|
658
|
-
console.log(` Duration: ${result.metrics.durationMs}ms`);
|
|
659
|
-
if (result.metrics.onnxLatencyMs) {
|
|
660
|
-
console.log(` ONNX Latency: ${result.metrics.onnxLatencyMs}ms`);
|
|
661
|
-
}
|
|
662
|
-
if (result.metrics.throughputOpsPerSec) {
|
|
663
|
-
console.log(` Throughput: ${result.metrics.throughputOpsPerSec.toFixed(1)} ops/s`);
|
|
664
|
-
}
|
|
665
|
-
// Show security findings if present
|
|
666
|
-
if (result.data['security-scan']?.data?.vulnerabilities) {
|
|
667
|
-
const vulns = result.data['security-scan'].data.vulnerabilities;
|
|
668
|
-
const summary = result.data['security-scan'].data.summary;
|
|
669
|
-
console.log(`\n\uD83D\uDD12 Security Findings:`);
|
|
670
|
-
console.log(` High: ${summary?.high || 0} | Medium: ${summary?.medium || 0} | Low: ${summary?.low || 0}`);
|
|
671
|
-
if (vulns.length > 0) {
|
|
672
|
-
console.log('\n Top Issues:');
|
|
673
|
-
vulns.slice(0, 5).forEach((v) => {
|
|
674
|
-
console.log(` \u2022 [${v.severity}] ${v.type} in ${v.file.split('/').pop()}:${v.line}`);
|
|
675
|
-
});
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
// Show complexity if present
|
|
679
|
-
if (result.data['complexity-analysis']?.data?.topFiles) {
|
|
680
|
-
const complexity = result.data['complexity-analysis'].data;
|
|
681
|
-
console.log(`\n\uD83D\uDCC8 Complexity Analysis:`);
|
|
682
|
-
console.log(` Avg Complexity: ${complexity.avgComplexity}`);
|
|
683
|
-
console.log(` Total Lines: ${complexity.totalLines}`);
|
|
684
|
-
}
|
|
685
|
-
console.log('\n' + '\u2550'.repeat(50) + '\n');
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
catch (error) {
|
|
689
|
-
console.error('Error:', error instanceof Error ? error.message : error);
|
|
690
|
-
process.exit(1);
|
|
691
|
-
}
|
|
692
|
-
});
|
|
693
|
-
// ============================================================================
|
|
694
|
-
// Benchmark and Integration Commands
|
|
695
|
-
// ============================================================================
|
|
696
|
-
// Benchmark command
|
|
697
|
-
workers
|
|
698
|
-
.command('benchmark')
|
|
699
|
-
.description('Run worker system performance benchmarks')
|
|
700
|
-
.option('-t, --type <type>', 'Benchmark type: all, trigger-detection, registry, agent-selection, cache, concurrent, memory-keys', 'all')
|
|
701
|
-
.option('-i, --iterations <count>', 'Number of iterations', '1000')
|
|
702
|
-
.option('-j, --json', 'Output as JSON')
|
|
703
|
-
.action(async (options) => {
|
|
704
|
-
try {
|
|
705
|
-
const { workerBenchmarks } = await import('../../workers/worker-benchmarks.js');
|
|
706
|
-
const iterations = parseInt(options.iterations);
|
|
707
|
-
if (options.type === 'all') {
|
|
708
|
-
const suite = await workerBenchmarks.runFullSuite();
|
|
709
|
-
if (options.json) {
|
|
710
|
-
console.log(JSON.stringify(suite, null, 2));
|
|
711
|
-
}
|
|
712
|
-
}
|
|
713
|
-
else {
|
|
714
|
-
let result;
|
|
715
|
-
switch (options.type) {
|
|
716
|
-
case 'trigger-detection':
|
|
717
|
-
result = await workerBenchmarks.benchmarkTriggerDetection(iterations);
|
|
718
|
-
break;
|
|
719
|
-
case 'registry':
|
|
720
|
-
result = await workerBenchmarks.benchmarkRegistryOperations(Math.min(500, iterations));
|
|
721
|
-
break;
|
|
722
|
-
case 'agent-selection':
|
|
723
|
-
result = await workerBenchmarks.benchmarkAgentSelection(iterations);
|
|
724
|
-
break;
|
|
725
|
-
case 'cache':
|
|
726
|
-
result = await workerBenchmarks.benchmarkModelCache(Math.min(100, iterations));
|
|
727
|
-
break;
|
|
728
|
-
case 'concurrent':
|
|
729
|
-
result = await workerBenchmarks.benchmarkConcurrentWorkers(10);
|
|
730
|
-
break;
|
|
731
|
-
case 'memory-keys':
|
|
732
|
-
result = await workerBenchmarks.benchmarkMemoryKeyGeneration(iterations * 5);
|
|
733
|
-
break;
|
|
734
|
-
default:
|
|
735
|
-
console.error(`Unknown benchmark type: ${options.type}`);
|
|
736
|
-
process.exit(1);
|
|
737
|
-
}
|
|
738
|
-
if (options.json) {
|
|
739
|
-
console.log(JSON.stringify(result, null, 2));
|
|
740
|
-
}
|
|
741
|
-
else {
|
|
742
|
-
const status = result.passed ? '\u2705' : '\u274C';
|
|
743
|
-
console.log(`\n${status} ${result.name}`);
|
|
744
|
-
console.log(` Operation: ${result.operation}`);
|
|
745
|
-
console.log(` Count: ${result.count.toLocaleString()}`);
|
|
746
|
-
console.log(` Avg: ${result.avgTimeMs.toFixed(3)}ms | p95: ${result.p95Ms.toFixed(3)}ms`);
|
|
747
|
-
console.log(` Throughput: ${result.throughput.toFixed(0)} ops/s`);
|
|
748
|
-
console.log(` Memory \u0394: ${result.memoryDeltaMB.toFixed(2)}MB\n`);
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
catch (error) {
|
|
753
|
-
console.error('Benchmark error:', error instanceof Error ? error.message : error);
|
|
754
|
-
process.exit(1);
|
|
755
|
-
}
|
|
756
|
-
});
|
|
757
|
-
// Integration stats command
|
|
758
|
-
workers
|
|
759
|
-
.command('integration')
|
|
760
|
-
.description('View worker-agent integration statistics')
|
|
761
|
-
.option('-j, --json', 'Output as JSON')
|
|
762
|
-
.action(async (options) => {
|
|
763
|
-
try {
|
|
764
|
-
const { workerAgentIntegration, getIntegrationStats } = await import('../../workers/worker-agent-integration.js');
|
|
765
|
-
const stats = getIntegrationStats();
|
|
766
|
-
const metrics = workerAgentIntegration.getAgentMetrics();
|
|
767
|
-
if (options.json) {
|
|
768
|
-
console.log(JSON.stringify({ stats, agentMetrics: metrics }, null, 2));
|
|
769
|
-
}
|
|
770
|
-
else {
|
|
771
|
-
console.log('\n\u26A1 Worker-Agent Integration Stats\n');
|
|
772
|
-
console.log('\u2550'.repeat(40));
|
|
773
|
-
console.log(`Total Agents: ${stats.totalAgents}`);
|
|
774
|
-
console.log(`Tracked Agents: ${stats.trackedAgents}`);
|
|
775
|
-
console.log(`Total Feedback: ${stats.totalFeedback}`);
|
|
776
|
-
console.log(`Avg Quality Score: ${stats.avgQualityScore.toFixed(2)}`);
|
|
777
|
-
console.log(`\nModel Cache Stats`);
|
|
778
|
-
console.log('\u2500'.repeat(20));
|
|
779
|
-
console.log(`Hits: ${stats.modelCacheStats.hits.toLocaleString()}`);
|
|
780
|
-
console.log(`Misses: ${stats.modelCacheStats.misses.toLocaleString()}`);
|
|
781
|
-
console.log(`Hit Rate: ${stats.modelCacheStats.hitRate}`);
|
|
782
|
-
if (metrics.length > 0) {
|
|
783
|
-
console.log(`\n\uD83D\uDCCA Agent Performance\n`);
|
|
784
|
-
for (const m of metrics) {
|
|
785
|
-
console.log(` ${m.agentName}:`);
|
|
786
|
-
console.log(` Latency: ${m.avgLatencyMs.toFixed(0)}ms (p95: ${m.p95LatencyMs.toFixed(0)}ms)`);
|
|
787
|
-
console.log(` Success: ${(m.successRate * 100).toFixed(1)}%`);
|
|
788
|
-
console.log(` Quality: ${m.qualityScore.toFixed(2)}`);
|
|
789
|
-
console.log(` Count: ${m.executionCount}`);
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
console.log();
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
catch (error) {
|
|
796
|
-
console.error('Error:', error instanceof Error ? error.message : error);
|
|
797
|
-
process.exit(1);
|
|
798
|
-
}
|
|
799
|
-
});
|
|
800
|
-
// Agent recommendation command
|
|
801
|
-
workers
|
|
802
|
-
.command('agents <trigger>')
|
|
803
|
-
.description('Get recommended agents for a worker trigger')
|
|
804
|
-
.option('-j, --json', 'Output as JSON')
|
|
805
|
-
.action(async (trigger, options) => {
|
|
806
|
-
try {
|
|
807
|
-
const { workerAgentIntegration } = await import('../../workers/worker-agent-integration.js');
|
|
808
|
-
const recommendations = workerAgentIntegration.getRecommendedAgents(trigger);
|
|
809
|
-
const selection = workerAgentIntegration.selectBestAgent(trigger);
|
|
810
|
-
if (options.json) {
|
|
811
|
-
console.log(JSON.stringify({ trigger, recommendations, selection }, null, 2));
|
|
812
|
-
}
|
|
813
|
-
else {
|
|
814
|
-
console.log(`\n\u26A1 Agent Recommendations for "${trigger}"\n`);
|
|
815
|
-
console.log(`Primary Agents: ${recommendations.primary.join(', ') || 'none'}`);
|
|
816
|
-
console.log(`Fallback Agents: ${recommendations.fallback.join(', ') || 'none'}`);
|
|
817
|
-
console.log(`Pipeline: ${recommendations.phases.join(' \u2192 ')}`);
|
|
818
|
-
console.log(`Memory Pattern: ${recommendations.memoryPattern}`);
|
|
819
|
-
console.log(`\n\uD83C\uDFAF Best Selection:`);
|
|
820
|
-
console.log(` Agent: ${selection.agent}`);
|
|
821
|
-
console.log(` Confidence: ${(selection.confidence * 100).toFixed(0)}%`);
|
|
822
|
-
console.log(` Reason: ${selection.reasoning}\n`);
|
|
823
|
-
}
|
|
824
|
-
}
|
|
825
|
-
catch (error) {
|
|
826
|
-
console.error('Error:', error instanceof Error ? error.message : error);
|
|
827
|
-
process.exit(1);
|
|
828
|
-
}
|
|
829
|
-
});
|
|
830
|
-
return workers;
|
|
831
|
-
}
|
|
832
|
-
function displayWorkerDetails(worker) {
|
|
833
|
-
const statusIcon = getStatusIcon(worker.status);
|
|
834
|
-
const duration = worker.completedAt
|
|
835
|
-
? ((worker.completedAt - worker.startedAt) / 1000).toFixed(1)
|
|
836
|
-
: worker.startedAt
|
|
837
|
-
? ((Date.now() - worker.startedAt) / 1000).toFixed(1)
|
|
838
|
-
: '0';
|
|
839
|
-
console.log('\n\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557');
|
|
840
|
-
console.log(`\u2551 ${statusIcon} Worker: ${worker.id.padEnd(30)} \u2551`);
|
|
841
|
-
console.log('\u2560\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2563');
|
|
842
|
-
console.log(`\u2551 Trigger: ${worker.trigger.padEnd(31)} \u2551`);
|
|
843
|
-
if (worker.topic) {
|
|
844
|
-
console.log(`\u2551 Topic: ${worker.topic.slice(0, 33).padEnd(33)} \u2551`);
|
|
845
|
-
}
|
|
846
|
-
console.log(`\u2551 Status: ${worker.status.padEnd(32)} \u2551`);
|
|
847
|
-
console.log(`\u2551 Progress: ${worker.progress}%`.padEnd(42) + ' \u2551');
|
|
848
|
-
if (worker.currentPhase) {
|
|
849
|
-
console.log(`\u2551 Phase: ${worker.currentPhase.padEnd(33)} \u2551`);
|
|
850
|
-
}
|
|
851
|
-
console.log(`\u2551 Duration: ${duration}s`.padEnd(42) + ' \u2551');
|
|
852
|
-
console.log(`\u2551 Memory Deposits: ${worker.memoryDeposits}`.padEnd(42) + ' \u2551');
|
|
853
|
-
if (worker.error) {
|
|
854
|
-
console.log(`\u2551 Error: ${worker.error.slice(0, 33).padEnd(33)} \u2551`);
|
|
855
|
-
}
|
|
856
|
-
console.log('\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D\n');
|
|
857
|
-
}
|
|
858
|
-
function displayWorkerDashboard(workers, resourceStats) {
|
|
859
|
-
console.log('\n\u250C\u2500 Background Workers Dashboard \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510');
|
|
860
|
-
if (workers.length === 0) {
|
|
861
|
-
console.log('\u2502 No workers found \u2502');
|
|
862
|
-
console.log('\u2502 \u2502');
|
|
863
|
-
console.log('\u2502 Use trigger words in prompts: \u2502');
|
|
864
|
-
console.log('\u2502 \u2022 ultralearn <topic> \u2502');
|
|
865
|
-
console.log('\u2502 \u2022 optimize \u2502');
|
|
866
|
-
console.log('\u2502 \u2022 audit <scope> \u2502');
|
|
867
|
-
console.log('\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n');
|
|
868
|
-
return;
|
|
869
|
-
}
|
|
870
|
-
for (const worker of workers) {
|
|
871
|
-
const icon = getStatusIcon(worker.status);
|
|
872
|
-
const progress = worker.status === 'running' ? ` (${worker.progress}%)` : '';
|
|
873
|
-
const line = `\u2502 ${icon} ${worker.trigger.padEnd(12)}: ${worker.status}${progress}`;
|
|
874
|
-
console.log(line.padEnd(42) + '\u2502');
|
|
875
|
-
if (worker.currentPhase) {
|
|
876
|
-
console.log(`\u2502 \u2514\u2500 ${worker.currentPhase}`.padEnd(42) + '\u2502');
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
console.log('\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524');
|
|
880
|
-
console.log(`\u2502 Active: ${resourceStats.activeWorkers}/${10}`.padEnd(42) + '\u2502');
|
|
881
|
-
console.log(`\u2502 Memory: ${(resourceStats.memoryUsage.heapUsed / 1024 / 1024).toFixed(0)}MB`.padEnd(42) + '\u2502');
|
|
882
|
-
console.log('\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n');
|
|
883
|
-
}
|
|
884
|
-
function displayStats(stats, timeframe) {
|
|
885
|
-
console.log(`\n\u26A1 Worker Statistics (${timeframe})\n`);
|
|
886
|
-
console.log(`Total Workers: ${stats.total ?? 0}`);
|
|
887
|
-
console.log(`Average Duration: ${((stats.avgDuration ?? 0) / 1000).toFixed(1)}s`);
|
|
888
|
-
if (stats.byStatus && Object.keys(stats.byStatus).length > 0) {
|
|
889
|
-
console.log('\nBy Status:');
|
|
890
|
-
for (const [status, count] of Object.entries(stats.byStatus)) {
|
|
891
|
-
if (count > 0) {
|
|
892
|
-
console.log(` ${getStatusIcon(status)} ${status}: ${count}`);
|
|
893
|
-
}
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
if (stats.byTrigger && Object.keys(stats.byTrigger).length > 0) {
|
|
897
|
-
console.log('\nBy Trigger:');
|
|
898
|
-
for (const [trigger, count] of Object.entries(stats.byTrigger)) {
|
|
899
|
-
console.log(` \u2022 ${trigger}: ${count}`);
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
console.log('\nResource Availability:');
|
|
903
|
-
const usedSlots = stats.availability?.usedSlots ?? 0;
|
|
904
|
-
const totalSlots = stats.availability?.totalSlots ?? 10;
|
|
905
|
-
const heapUsed = stats.resources?.memoryUsage?.heapUsed ?? 0;
|
|
906
|
-
console.log(` Slots: ${usedSlots}/${totalSlots}`);
|
|
907
|
-
console.log(` Memory: ${(heapUsed / 1024 / 1024).toFixed(0)}MB`);
|
|
908
|
-
console.log();
|
|
909
|
-
}
|
|
910
|
-
function displayWorkerResults(worker) {
|
|
911
|
-
console.log('\n\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557');
|
|
912
|
-
console.log(`\u2551 \uD83D\uDCCA Worker Results: ${worker.trigger.padEnd(27)} \u2551`);
|
|
913
|
-
console.log('\u2560\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2563');
|
|
914
|
-
if (worker.topic) {
|
|
915
|
-
console.log(`\u2551 Topic: ${worker.topic.slice(0, 40).padEnd(40)} \u2551`);
|
|
916
|
-
}
|
|
917
|
-
const results = worker.results || {};
|
|
918
|
-
if (results.files_analyzed !== undefined) {
|
|
919
|
-
console.log(`\u2551 Files Analyzed: ${String(results.files_analyzed).padEnd(31)} \u2551`);
|
|
920
|
-
}
|
|
921
|
-
if (results.patterns_found !== undefined) {
|
|
922
|
-
console.log(`\u2551 Patterns Found: ${String(results.patterns_found).padEnd(31)} \u2551`);
|
|
923
|
-
}
|
|
924
|
-
if (results.bytes_processed !== undefined) {
|
|
925
|
-
const kb = (results.bytes_processed / 1024).toFixed(1);
|
|
926
|
-
console.log(`\u2551 Bytes Processed: ${(kb + ' KB').padEnd(30)} \u2551`);
|
|
927
|
-
}
|
|
928
|
-
// Show sample patterns if available
|
|
929
|
-
if (results.sample_patterns && Array.isArray(results.sample_patterns) && results.sample_patterns.length > 0) {
|
|
930
|
-
console.log('\u2560\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2563');
|
|
931
|
-
console.log('\u2551 Sample Patterns:'.padEnd(49) + ' \u2551');
|
|
932
|
-
for (const pattern of results.sample_patterns.slice(0, 3)) {
|
|
933
|
-
const truncated = String(pattern).slice(0, 45);
|
|
934
|
-
console.log(`\u2551 \u2022 ${truncated.padEnd(42)} \u2551`);
|
|
935
|
-
}
|
|
936
|
-
}
|
|
937
|
-
// Show other results
|
|
938
|
-
const otherKeys = Object.keys(results).filter(k => !['files_analyzed', 'patterns_found', 'bytes_processed', 'sample_patterns', 'topic', 'phases'].includes(k));
|
|
939
|
-
if (otherKeys.length > 0) {
|
|
940
|
-
console.log('\u2560\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2563');
|
|
941
|
-
for (const key of otherKeys.slice(0, 5)) {
|
|
942
|
-
const val = JSON.stringify(results[key]).slice(0, 35);
|
|
943
|
-
console.log(`\u2551 ${key}: ${val.padEnd(45 - key.length)} \u2551`);
|
|
944
|
-
}
|
|
945
|
-
}
|
|
946
|
-
console.log('\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D\n');
|
|
947
|
-
}
|
|
948
|
-
function displayResultsSummary(workers) {
|
|
949
|
-
if (workers.length === 0) {
|
|
950
|
-
console.log('\nNo workers with results found.');
|
|
951
|
-
console.log('Run workers first: agentic-flow workers dispatch "ultralearn authentication"\n');
|
|
952
|
-
return;
|
|
953
|
-
}
|
|
954
|
-
console.log('\n\uD83D\uDCCA Worker Analysis Results\n');
|
|
955
|
-
let totalFiles = 0;
|
|
956
|
-
let totalPatterns = 0;
|
|
957
|
-
let totalBytes = 0;
|
|
958
|
-
for (const worker of workers) {
|
|
959
|
-
const results = worker.results || {};
|
|
960
|
-
const files = results.files_analyzed || 0;
|
|
961
|
-
const patterns = results.patterns_found || 0;
|
|
962
|
-
const bytes = results.bytes_processed || 0;
|
|
963
|
-
totalFiles += files;
|
|
964
|
-
totalPatterns += patterns;
|
|
965
|
-
totalBytes += bytes;
|
|
966
|
-
const topic = worker.topic ? ` "${worker.topic.slice(0, 20)}"` : '';
|
|
967
|
-
console.log(` \u2022 ${worker.trigger}${topic}:`);
|
|
968
|
-
console.log(` ${files} files, ${patterns} patterns, ${(bytes / 1024).toFixed(1)} KB`);
|
|
969
|
-
}
|
|
970
|
-
console.log('\n \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500');
|
|
971
|
-
console.log(` Total: ${totalFiles} files, ${totalPatterns} patterns, ${(totalBytes / 1024).toFixed(1)} KB\n`);
|
|
972
|
-
}
|
|
973
|
-
function getStatusIcon(status) {
|
|
974
|
-
switch (status) {
|
|
975
|
-
case 'complete': return '\u2705';
|
|
976
|
-
case 'running': return '\uD83D\uDD04';
|
|
977
|
-
case 'queued': return '\uD83D\uDCA4';
|
|
978
|
-
case 'failed': return '\u274C';
|
|
979
|
-
case 'cancelled': return '\u23F9\uFE0F';
|
|
980
|
-
case 'timeout': return '\u23F1\uFE0F';
|
|
981
|
-
default: return '\u2022';
|
|
982
|
-
}
|
|
983
|
-
}
|
|
984
|
-
export default createWorkersCommand;
|
|
985
|
-
// CLI entry point when run directly
|
|
986
|
-
const isDirectRun = import.meta.url === `file://${process.argv[1]}`;
|
|
987
|
-
if (isDirectRun) {
|
|
988
|
-
const workers = createWorkersCommand();
|
|
989
|
-
workers.parse(process.argv);
|
|
990
|
-
}
|
|
991
|
-
//# sourceMappingURL=workers.js.map
|