claude-flow-novice 2.0.3 → 2.0.4
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/dist/src/cli/commands/guidance.js +487 -668
- package/dist/src/cli/commands/index-validate.js +18 -29
- package/dist/src/cli/commands/mcp-troubleshoot.js +230 -282
- package/dist/src/cli/commands/neural-goal-init.js +92 -125
- package/dist/src/cli/commands/swarm-exec.js +317 -393
- package/dist/src/cli/commands/swarm.js +1 -1
- package/dist/src/cli/commands/validate-framework.js +983 -1100
- package/dist/src/cli/commands/validate.js +144 -223
- package/dist/src/cli/simple-commands/__tests__/agent.test.js +265 -277
- package/dist/src/cli/simple-commands/__tests__/memory.test.js +6 -7
- package/dist/src/cli/simple-commands/__tests__/swarm.test.js +373 -356
- package/dist/src/cli/simple-commands/__tests__/task.test.js +6 -7
- package/dist/src/cli/simple-commands/agent.js +157 -193
- package/dist/src/cli/simple-commands/analysis.js +336 -446
- package/dist/src/cli/simple-commands/automation-executor.js +1095 -1339
- package/dist/src/cli/simple-commands/automation.js +481 -469
- package/dist/src/cli/simple-commands/batch-manager.js +261 -313
- package/dist/src/cli/simple-commands/claude-telemetry.js +241 -267
- package/dist/src/cli/simple-commands/claude-track.js +68 -90
- package/dist/src/cli/simple-commands/concurrent-display.js +266 -320
- package/dist/src/cli/simple-commands/config.js +245 -290
- package/dist/src/cli/simple-commands/coordination.js +182 -234
- package/dist/src/cli/simple-commands/enhanced-ui-views.js +812 -615
- package/dist/src/cli/simple-commands/enhanced-webui-complete.js +922 -981
- package/dist/src/cli/simple-commands/fix-hook-variables.js +274 -294
- package/dist/src/cli/simple-commands/github/gh-coordinator.js +378 -457
- package/dist/src/cli/simple-commands/github/github-api.js +535 -574
- package/dist/src/cli/simple-commands/github/init.js +276 -303
- package/dist/src/cli/simple-commands/github.js +222 -247
- package/dist/src/cli/simple-commands/goal.js +51 -63
- package/dist/src/cli/simple-commands/hive-mind/auto-save-middleware.js +208 -278
- package/dist/src/cli/simple-commands/hive-mind/communication.js +601 -696
- package/dist/src/cli/simple-commands/hive-mind/core.js +907 -979
- package/dist/src/cli/simple-commands/hive-mind/db-optimizer.js +406 -655
- package/dist/src/cli/simple-commands/hive-mind/mcp-wrapper.js +1125 -1245
- package/dist/src/cli/simple-commands/hive-mind/memory.js +854 -1090
- package/dist/src/cli/simple-commands/hive-mind/performance-optimizer.js +459 -574
- package/dist/src/cli/simple-commands/hive-mind/performance-test.js +263 -347
- package/dist/src/cli/simple-commands/hive-mind/queen.js +727 -768
- package/dist/src/cli/simple-commands/hive-mind/session-manager.js +745 -1049
- package/dist/src/cli/simple-commands/hive-mind-optimize.js +227 -283
- package/dist/src/cli/simple-commands/hive-mind-wizard.js +174 -217
- package/dist/src/cli/simple-commands/hive-mind.js +1842 -2283
- package/dist/src/cli/simple-commands/hive.js +90 -79
- package/dist/src/cli/simple-commands/hook-safety.js +431 -521
- package/dist/src/cli/simple-commands/hooks/session-start-soul.js +203 -254
- package/dist/src/cli/simple-commands/hooks.js +1064 -1204
- package/dist/src/cli/simple-commands/init/agent-copier.js +294 -319
- package/dist/src/cli/simple-commands/init/batch-init.js +496 -562
- package/dist/src/cli/simple-commands/init/claude-commands/claude-flow-commands.js +13 -19
- package/dist/src/cli/simple-commands/init/claude-commands/optimized-claude-flow-commands.js +13 -19
- package/dist/src/cli/simple-commands/init/claude-commands/optimized-slash-commands.js +61 -88
- package/dist/src/cli/simple-commands/init/claude-commands/optimized-sparc-commands.js +125 -150
- package/dist/src/cli/simple-commands/init/claude-commands/slash-commands.js +42 -49
- package/dist/src/cli/simple-commands/init/claude-commands/sparc-commands.js +43 -61
- package/dist/src/cli/simple-commands/init/copy-revised-templates.js +141 -147
- package/dist/src/cli/simple-commands/init/executable-wrapper.js +31 -44
- package/dist/src/cli/simple-commands/init/gitignore-updater.js +64 -90
- package/dist/src/cli/simple-commands/init/help.js +104 -107
- package/dist/src/cli/simple-commands/init/hive-mind-init.js +509 -528
- package/dist/src/cli/simple-commands/init/index.js +1510 -1759
- package/dist/src/cli/simple-commands/init/performance-monitor.js +234 -317
- package/dist/src/cli/simple-commands/init/rollback/backup-manager.js +441 -504
- package/dist/src/cli/simple-commands/init/rollback/index.js +289 -364
- package/dist/src/cli/simple-commands/init/rollback/recovery-manager.js +652 -728
- package/dist/src/cli/simple-commands/init/rollback/rollback-executor.js +416 -481
- package/dist/src/cli/simple-commands/init/rollback/state-tracker.js +369 -448
- package/dist/src/cli/simple-commands/init/sparc/roo-readme.js +1 -2
- package/dist/src/cli/simple-commands/init/sparc/roomodes-config.js +122 -99
- package/dist/src/cli/simple-commands/init/sparc/workflows.js +32 -37
- package/dist/src/cli/simple-commands/init/sparc-structure.js +55 -62
- package/dist/src/cli/simple-commands/init/template-copier.js +421 -533
- package/dist/src/cli/simple-commands/init/templates/coordination-md.js +3 -6
- package/dist/src/cli/simple-commands/init/templates/enhanced-templates.js +344 -318
- package/dist/src/cli/simple-commands/init/templates/github-safe-enhanced.js +173 -218
- package/dist/src/cli/simple-commands/init/templates/github-safe.js +65 -75
- package/dist/src/cli/simple-commands/init/templates/memory-bank-md.js +3 -6
- package/dist/src/cli/simple-commands/init/templates/readme-files.js +2 -4
- package/dist/src/cli/simple-commands/init/templates/safe-hook-patterns.js +187 -230
- package/dist/src/cli/simple-commands/init/templates/sparc-modes.js +53 -80
- package/dist/src/cli/simple-commands/init/templates/verification-claude-md.js +101 -85
- package/dist/src/cli/simple-commands/init/validation/config-validator.js +283 -330
- package/dist/src/cli/simple-commands/init/validation/health-checker.js +495 -561
- package/dist/src/cli/simple-commands/init/validation/index.js +302 -358
- package/dist/src/cli/simple-commands/init/validation/mode-validator.js +308 -359
- package/dist/src/cli/simple-commands/init/validation/post-init-validator.js +389 -366
- package/dist/src/cli/simple-commands/init/validation/pre-init-validator.js +270 -268
- package/dist/src/cli/simple-commands/init/validation/test-runner.js +427 -447
- package/dist/src/cli/simple-commands/init.js +1 -2
- package/dist/src/cli/simple-commands/mcp-health.js +131 -158
- package/dist/src/cli/simple-commands/mcp-integration-layer.js +533 -634
- package/dist/src/cli/simple-commands/mcp.js +345 -400
- package/dist/src/cli/simple-commands/memory-consolidation.js +426 -537
- package/dist/src/cli/simple-commands/memory.js +247 -311
- package/dist/src/cli/simple-commands/migrate-hooks.js +39 -46
- package/dist/src/cli/simple-commands/monitor.js +294 -363
- package/dist/src/cli/simple-commands/neural.js +51 -65
- package/dist/src/cli/simple-commands/pair-autofix-only.js +538 -662
- package/dist/src/cli/simple-commands/pair-basic.js +528 -656
- package/dist/src/cli/simple-commands/pair-old.js +430 -543
- package/dist/src/cli/simple-commands/pair-working.js +615 -751
- package/dist/src/cli/simple-commands/pair.js +615 -751
- package/dist/src/cli/simple-commands/performance-hooks.js +83 -111
- package/dist/src/cli/simple-commands/performance-metrics.js +348 -433
- package/dist/src/cli/simple-commands/process-ui-enhanced.js +708 -787
- package/dist/src/cli/simple-commands/process-ui.js +230 -254
- package/dist/src/cli/simple-commands/realtime-update-system.js +525 -611
- package/dist/src/cli/simple-commands/sparc/architecture.js +1704 -1530
- package/dist/src/cli/simple-commands/sparc/commands.js +438 -516
- package/dist/src/cli/simple-commands/sparc/completion.js +1224 -1481
- package/dist/src/cli/simple-commands/sparc/coordinator.js +913 -978
- package/dist/src/cli/simple-commands/sparc/index.js +241 -298
- package/dist/src/cli/simple-commands/sparc/phase-base.js +314 -390
- package/dist/src/cli/simple-commands/sparc/pseudocode.js +965 -869
- package/dist/src/cli/simple-commands/sparc/refinement.js +980 -1273
- package/dist/src/cli/simple-commands/sparc/specification.js +559 -645
- package/dist/src/cli/simple-commands/sparc-modes/architect.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/ask.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/code.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/debug.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/devops.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/docs-writer.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/generic.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/index.js +47 -55
- package/dist/src/cli/simple-commands/sparc-modes/integration.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/mcp.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/monitoring.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/optimization.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/security-review.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/sparc-orchestrator.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/spec-pseudocode.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/supabase-admin.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/swarm.js +101 -87
- package/dist/src/cli/simple-commands/sparc-modes/tdd.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/tutorial.js +1 -1
- package/dist/src/cli/simple-commands/sparc.js +465 -493
- package/dist/src/cli/simple-commands/start-ui.js +108 -132
- package/dist/src/cli/simple-commands/start-wrapper.js +240 -268
- package/dist/src/cli/simple-commands/start.js +1 -1
- package/dist/src/cli/simple-commands/status.js +254 -275
- package/dist/src/cli/simple-commands/stream-chain-clean.js +128 -171
- package/dist/src/cli/simple-commands/stream-chain-fixed.js +61 -82
- package/dist/src/cli/simple-commands/stream-chain-real.js +267 -331
- package/dist/src/cli/simple-commands/stream-chain-working.js +211 -263
- package/dist/src/cli/simple-commands/stream-chain.js +260 -318
- package/dist/src/cli/simple-commands/stream-processor.js +290 -315
- package/dist/src/cli/simple-commands/swarm-executor.js +189 -222
- package/dist/src/cli/simple-commands/swarm-metrics-integration.js +208 -300
- package/dist/src/cli/simple-commands/swarm-ui.js +623 -703
- package/dist/src/cli/simple-commands/swarm-webui-integration.js +258 -286
- package/dist/src/cli/simple-commands/swarm.js +887 -1082
- package/dist/src/cli/simple-commands/task.js +161 -206
- package/dist/src/cli/simple-commands/timestamp-fix.js +59 -89
- package/dist/src/cli/simple-commands/token-tracker.js +258 -316
- package/dist/src/cli/simple-commands/tool-execution-framework.js +433 -519
- package/dist/src/cli/simple-commands/train-and-stream.js +275 -331
- package/dist/src/cli/simple-commands/training-pipeline.js +619 -725
- package/dist/src/cli/simple-commands/training.js +170 -227
- package/dist/src/cli/simple-commands/verification-hooks.js +261 -284
- package/dist/src/cli/simple-commands/verification-integration.js +389 -417
- package/dist/src/cli/simple-commands/verification-training-integration.js +486 -606
- package/dist/src/cli/simple-commands/verification.js +493 -513
- package/dist/src/cli/simple-commands/web-server.js +766 -836
- package/dist/src/cli/simple-commands/webui-validator.js +106 -124
- package/dist/src/coordination/event-bus/demo-wasm-integration.js +212 -251
- package/dist/src/coordination/event-bus/qe-event-bus.js +608 -748
- package/dist/src/coordination/event-bus/qe-event-bus.test.js +379 -454
- package/dist/src/coordination/iteration-tracker.js +363 -454
- package/dist/src/enterprise/analytics-manager.js +1135 -0
- package/dist/src/enterprise/audit-manager.js +1115 -0
- package/dist/src/enterprise/cloud-manager.js +891 -0
- package/dist/src/enterprise/deployment-manager.js +966 -0
- package/dist/src/enterprise/index.js +6 -0
- package/dist/src/enterprise/project-manager.js +584 -0
- package/dist/src/enterprise/security-manager.js +991 -0
- package/dist/src/index.js +1 -1
- package/dist/src/mcp/DEPRECATED.js +46 -60
- package/dist/src/mcp/fixes/mcp-error-fixes.js +115 -134
- package/dist/src/mcp/implementations/agent-tracker.js +114 -128
- package/dist/src/mcp/implementations/daa-tools.js +292 -350
- package/dist/src/mcp/implementations/workflow-tools.js +329 -361
- package/dist/src/mcp/mcp-config-manager.js +1183 -1331
- package/dist/src/mcp/mcp-server-novice-simplified.js +11 -17
- package/dist/src/mcp/mcp-server-novice.js +11 -17
- package/dist/src/mcp/mcp-server-sdk.js +11 -17
- package/dist/src/mcp/mcp-server.js +1620 -1484
- package/dist/src/mcp/ruv-swarm-wrapper.js +209 -239
- package/dist/src/memory/advanced-serializer.js +609 -589
- package/dist/src/memory/enhanced-examples.js +220 -305
- package/dist/src/memory/enhanced-memory.js +295 -336
- package/dist/src/memory/enhanced-session-serializer.js +408 -492
- package/dist/src/memory/fallback-memory-system.js +900 -1021
- package/dist/src/memory/fallback-store.js +93 -131
- package/dist/src/memory/high-performance-serialization.js +592 -730
- package/dist/src/memory/in-memory-store.js +161 -213
- package/dist/src/memory/index.js +123 -157
- package/dist/src/memory/lock-free-structures.js +578 -764
- package/dist/src/memory/memory-mapped-persistence.js +585 -766
- package/dist/src/memory/memory-pressure-manager.js +569 -707
- package/dist/src/memory/migration.js +358 -445
- package/dist/src/memory/shared-memory.js +641 -768
- package/dist/src/memory/sqlite-store.js +245 -325
- package/dist/src/memory/sqlite-wrapper.js +122 -151
- package/dist/src/memory/swarm-memory.js +470 -603
- package/dist/src/memory/test-example.js +126 -134
- package/dist/src/memory/ultra-fast-memory-store.js +622 -821
- package/dist/src/memory/unified-memory-manager.js +356 -437
- package/dist/src/migration/index.js +92 -0
- package/dist/src/migration/logger.js +121 -0
- package/dist/src/migration/migration-analyzer.js +268 -0
- package/dist/src/migration/migration-runner.js +522 -0
- package/dist/src/migration/migration-validator.js +285 -0
- package/dist/src/migration/progress-reporter.js +150 -0
- package/dist/src/migration/rollback-manager.js +321 -0
- package/dist/src/migration/tests/migration-system.test.js +7 -0
- package/dist/src/migration/types.js +3 -0
- package/dist/src/swarm/CodeRefactoringSwarm.js +777 -952
- package/dist/src/swarm/__tests__/integration.test.js +227 -0
- package/dist/src/swarm/__tests__/prompt-copier.test.js +344 -0
- package/dist/src/swarm/advanced-orchestrator.js +1095 -0
- package/dist/src/swarm/claude-code-interface.js +961 -0
- package/dist/src/swarm/claude-flow-executor.js +229 -0
- package/dist/src/swarm/consensus-coordinator.js +475 -0
- package/dist/src/swarm/coordinator.js +2993 -0
- package/dist/src/swarm/direct-executor.js +1180 -0
- package/dist/src/swarm/error-recovery/advanced-error-detection.js +691 -0
- package/dist/src/swarm/error-recovery/automated-recovery-workflows.js +998 -0
- package/dist/src/swarm/error-recovery/error-recovery-coordinator.js +1197 -0
- package/dist/src/swarm/error-recovery/recovery-monitoring.js +772 -0
- package/dist/src/swarm/error-recovery/resilience-architecture.js +714 -0
- package/dist/src/swarm/error-recovery/self-healing-mechanisms.js +1319 -0
- package/dist/src/swarm/error-recovery/test-error-recovery-effectiveness.js +808 -0
- package/dist/src/swarm/executor-v2.js +322 -0
- package/dist/src/swarm/executor.js +815 -0
- package/dist/src/swarm/hive-mind-integration.js +703 -0
- package/dist/src/swarm/index.js +41 -0
- package/dist/src/swarm/json-output-aggregator.js +267 -0
- package/dist/src/swarm/large-scale-coordinator.js +542 -0
- package/dist/src/swarm/mcp-integration-wrapper.js +628 -0
- package/dist/src/swarm/memory.js +1117 -0
- package/dist/src/swarm/optimizations/__tests__/optimization.test.js +348 -0
- package/dist/src/swarm/optimizations/async-file-manager.js +285 -0
- package/dist/src/swarm/optimizations/circular-buffer.js +162 -0
- package/dist/src/swarm/optimizations/connection-pool.js +244 -0
- package/dist/src/swarm/optimizations/index.js +28 -0
- package/dist/src/swarm/optimizations/optimized-executor.js +320 -0
- package/dist/src/swarm/optimizations/ttl-map.js +234 -0
- package/dist/src/swarm/prompt-cli.js +200 -0
- package/dist/src/swarm/prompt-copier-enhanced.js +202 -0
- package/dist/src/swarm/prompt-copier.js +381 -0
- package/dist/src/swarm/prompt-manager.js +295 -0
- package/dist/src/swarm/prompt-utils.js +310 -0
- package/dist/src/swarm/result-aggregator.js +718 -0
- package/dist/src/swarm/sparc-executor.js +1568 -0
- package/dist/src/swarm/strategies/auto.js +758 -0
- package/dist/src/swarm/strategies/base.js +128 -0
- package/dist/src/swarm/strategies/research.js +914 -0
- package/dist/src/swarm/strategies/strategy-metrics-patch.js +2 -0
- package/dist/src/swarm/types.js +52 -0
- package/dist/src/swarm/workers/copy-worker.js +56 -0
- package/dist/src/utils/__tests__/github-cli-safety-wrapper.test.js +332 -400
- package/dist/src/utils/github-cli-safe.js +56 -64
- package/dist/src/utils/github-cli-safety-wrapper.js +451 -546
- package/dist/src/utils/npx-isolated-cache.js +104 -119
- package/dist/src/utils/preference-manager.js +622 -652
- package/dist/src/utils/timezone-utils.js +86 -105
- package/dist/src/validators/epic-config-schema.js +214 -0
- package/dist/src/validators/index.js +10 -0
- package/dist/src/validators/swarm-init-validator.js +259 -0
- package/dist/src/validators/todowrite-batching-validator.js +215 -0
- package/dist/src/validators/todowrite-integration.js +187 -0
- package/package.json +2 -2
|
@@ -2,688 +2,587 @@
|
|
|
2
2
|
* MCP Integration Layer for Web UI
|
|
3
3
|
* Provides comprehensive integration with all Claude-Flow MCP tools
|
|
4
4
|
* Supports real-time updates, error handling, and result streaming
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { compat } from '../runtime-detector.js';
|
|
8
|
-
|
|
9
|
-
export class MCPIntegrationLayer {
|
|
10
|
-
constructor(ui) {
|
|
11
|
-
this.ui = ui;
|
|
12
|
-
this.activeTools = new Map();
|
|
13
|
-
this.resultCache = new Map();
|
|
14
|
-
this.subscriptions = new Set();
|
|
15
|
-
this.retryQueue = new Map();
|
|
16
|
-
this.maxRetries = 3;
|
|
17
|
-
this.retryDelay = 1000;
|
|
18
|
-
|
|
19
|
-
// Tool categories for better organization
|
|
20
|
-
this.toolCategories = {
|
|
21
|
-
// Swarm Coordination Tools (12)
|
|
22
|
-
swarm: [
|
|
23
|
-
'swarm_init',
|
|
24
|
-
'agent_spawn',
|
|
25
|
-
'task_orchestrate',
|
|
26
|
-
'swarm_status',
|
|
27
|
-
'agent_list',
|
|
28
|
-
'agent_metrics',
|
|
29
|
-
'swarm_monitor',
|
|
30
|
-
'topology_optimize',
|
|
31
|
-
'load_balance',
|
|
32
|
-
'coordination_sync',
|
|
33
|
-
'swarm_scale',
|
|
34
|
-
'swarm_destroy',
|
|
35
|
-
],
|
|
36
|
-
|
|
37
|
-
// Neural Network Tools (15)
|
|
38
|
-
neural: [
|
|
39
|
-
'neural_status',
|
|
40
|
-
'neural_train',
|
|
41
|
-
'neural_patterns',
|
|
42
|
-
'neural_predict',
|
|
43
|
-
'model_load',
|
|
44
|
-
'model_save',
|
|
45
|
-
'wasm_optimize',
|
|
46
|
-
'inference_run',
|
|
47
|
-
'pattern_recognize',
|
|
48
|
-
'cognitive_analyze',
|
|
49
|
-
'learning_adapt',
|
|
50
|
-
'neural_compress',
|
|
51
|
-
'ensemble_create',
|
|
52
|
-
'transfer_learn',
|
|
53
|
-
'neural_explain',
|
|
54
|
-
],
|
|
55
|
-
|
|
56
|
-
// Memory & Persistence Tools (12)
|
|
57
|
-
memory: [
|
|
58
|
-
'memory_usage',
|
|
59
|
-
'memory_search',
|
|
60
|
-
'memory_persist',
|
|
61
|
-
'memory_namespace',
|
|
62
|
-
'memory_backup',
|
|
63
|
-
'memory_restore',
|
|
64
|
-
'memory_compress',
|
|
65
|
-
'memory_sync',
|
|
66
|
-
'cache_manage',
|
|
67
|
-
'state_snapshot',
|
|
68
|
-
'context_restore',
|
|
69
|
-
'memory_analytics',
|
|
70
|
-
],
|
|
71
|
-
|
|
72
|
-
// Analysis & Monitoring Tools (13)
|
|
73
|
-
analysis: [
|
|
74
|
-
'performance_report',
|
|
75
|
-
'bottleneck_analyze',
|
|
76
|
-
'token_usage',
|
|
77
|
-
'task_status',
|
|
78
|
-
'task_results',
|
|
79
|
-
'benchmark_run',
|
|
80
|
-
'metrics_collect',
|
|
81
|
-
'trend_analysis',
|
|
82
|
-
'cost_analysis',
|
|
83
|
-
'quality_assess',
|
|
84
|
-
'error_analysis',
|
|
85
|
-
'usage_stats',
|
|
86
|
-
'health_check',
|
|
87
|
-
],
|
|
88
|
-
|
|
89
|
-
// Workflow & Automation Tools (11)
|
|
90
|
-
workflow: [
|
|
91
|
-
'workflow_create',
|
|
92
|
-
'sparc_mode',
|
|
93
|
-
'workflow_execute',
|
|
94
|
-
'workflow_export',
|
|
95
|
-
'automation_setup',
|
|
96
|
-
'pipeline_create',
|
|
97
|
-
'scheduler_manage',
|
|
98
|
-
'trigger_setup',
|
|
99
|
-
'workflow_template',
|
|
100
|
-
'batch_process',
|
|
101
|
-
'parallel_execute',
|
|
102
|
-
],
|
|
103
|
-
|
|
104
|
-
// GitHub Integration Tools (8)
|
|
105
|
-
github: [
|
|
106
|
-
'github_repo_analyze',
|
|
107
|
-
'github_pr_manage',
|
|
108
|
-
'github_issue_track',
|
|
109
|
-
'github_release_coord',
|
|
110
|
-
'github_workflow_auto',
|
|
111
|
-
'github_code_review',
|
|
112
|
-
'github_sync_coord',
|
|
113
|
-
'github_metrics',
|
|
114
|
-
],
|
|
115
|
-
|
|
116
|
-
// DAA (Dynamic Agent Architecture) Tools (8)
|
|
117
|
-
daa: [
|
|
118
|
-
'daa_agent_create',
|
|
119
|
-
'daa_capability_match',
|
|
120
|
-
'daa_resource_alloc',
|
|
121
|
-
'daa_lifecycle_manage',
|
|
122
|
-
'daa_communication',
|
|
123
|
-
'daa_consensus',
|
|
124
|
-
'daa_fault_tolerance',
|
|
125
|
-
'daa_optimization',
|
|
126
|
-
],
|
|
127
|
-
|
|
128
|
-
// System & Utilities Tools (6+)
|
|
129
|
-
system: [
|
|
130
|
-
'terminal_execute',
|
|
131
|
-
'config_manage',
|
|
132
|
-
'features_detect',
|
|
133
|
-
'security_scan',
|
|
134
|
-
'backup_create',
|
|
135
|
-
'restore_system',
|
|
136
|
-
'log_analysis',
|
|
137
|
-
'diagnostic_run',
|
|
138
|
-
],
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
this.initializeIntegration();
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
5
|
+
*/ export class MCPIntegrationLayer {
|
|
6
|
+
/**
|
|
145
7
|
* Initialize MCP integration
|
|
146
|
-
*/
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
} catch (error) {
|
|
164
|
-
this.ui.addLog('error', `Failed to initialize MCP integration: ${error.message}`);
|
|
165
|
-
this.useMockMode = true;
|
|
8
|
+
*/ async initializeIntegration() {
|
|
9
|
+
try {
|
|
10
|
+
// Check if MCP tools are available
|
|
11
|
+
const mcpAvailable = await this.checkMCPAvailability();
|
|
12
|
+
if (!mcpAvailable) {
|
|
13
|
+
this.ui.addLog('warning', 'MCP tools not available - using mock implementations');
|
|
14
|
+
this.useMockMode = true;
|
|
15
|
+
}
|
|
16
|
+
// Initialize tool monitoring
|
|
17
|
+
this.startToolMonitoring();
|
|
18
|
+
// Setup event handlers
|
|
19
|
+
this.setupEventHandlers();
|
|
20
|
+
this.ui.addLog('success', 'MCP Integration Layer initialized successfully');
|
|
21
|
+
} catch (error) {
|
|
22
|
+
this.ui.addLog('error', `Failed to initialize MCP integration: ${error.message}`);
|
|
23
|
+
this.useMockMode = true;
|
|
24
|
+
}
|
|
166
25
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
/**
|
|
26
|
+
/**
|
|
170
27
|
* Check if MCP tools are available
|
|
171
|
-
*/
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
28
|
+
*/ async checkMCPAvailability() {
|
|
29
|
+
try {
|
|
30
|
+
// Try to access a simple MCP tool
|
|
31
|
+
const result = await this.executeToolDirect('features_detect', {});
|
|
32
|
+
return result && result.success;
|
|
33
|
+
} catch (error) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
179
36
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
/**
|
|
37
|
+
/**
|
|
183
38
|
* Execute MCP tool with full error handling and retry logic
|
|
184
|
-
*/
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
39
|
+
*/ async executeTool(toolName, parameters = {}, options = {}) {
|
|
40
|
+
const executionId = `exec_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
41
|
+
try {
|
|
42
|
+
// Store execution info
|
|
43
|
+
this.activeTools.set(executionId, {
|
|
44
|
+
toolName,
|
|
45
|
+
parameters,
|
|
46
|
+
startTime: Date.now(),
|
|
47
|
+
status: 'running',
|
|
48
|
+
progress: 0
|
|
49
|
+
});
|
|
50
|
+
// Notify UI of execution start
|
|
51
|
+
this.notifyUI('tool_start', {
|
|
52
|
+
executionId,
|
|
53
|
+
toolName
|
|
54
|
+
});
|
|
55
|
+
// Execute with retry logic
|
|
56
|
+
const result = await this.executeWithRetry(toolName, parameters, options);
|
|
57
|
+
// Cache successful results
|
|
58
|
+
if (result.success) {
|
|
59
|
+
this.cacheResult(toolName, parameters, result);
|
|
60
|
+
}
|
|
61
|
+
// Update execution status
|
|
62
|
+
this.activeTools.set(executionId, {
|
|
63
|
+
...this.activeTools.get(executionId),
|
|
64
|
+
status: 'completed',
|
|
65
|
+
result,
|
|
66
|
+
endTime: Date.now()
|
|
67
|
+
});
|
|
68
|
+
// Notify UI of completion
|
|
69
|
+
this.notifyUI('tool_complete', {
|
|
70
|
+
executionId,
|
|
71
|
+
toolName,
|
|
72
|
+
result
|
|
73
|
+
});
|
|
74
|
+
return {
|
|
75
|
+
executionId,
|
|
76
|
+
result
|
|
77
|
+
};
|
|
78
|
+
} catch (error) {
|
|
79
|
+
// Update execution status
|
|
80
|
+
this.activeTools.set(executionId, {
|
|
81
|
+
...this.activeTools.get(executionId),
|
|
82
|
+
status: 'failed',
|
|
83
|
+
error: error.message,
|
|
84
|
+
endTime: Date.now()
|
|
85
|
+
});
|
|
86
|
+
// Notify UI of error
|
|
87
|
+
this.notifyUI('tool_error', {
|
|
88
|
+
executionId,
|
|
89
|
+
toolName,
|
|
90
|
+
error: error.message
|
|
91
|
+
});
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
234
94
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
/**
|
|
95
|
+
/**
|
|
238
96
|
* Execute tool with retry logic
|
|
239
|
-
*/
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
97
|
+
*/ async executeWithRetry(toolName, parameters, options) {
|
|
98
|
+
const maxRetries = options.maxRetries || this.maxRetries;
|
|
99
|
+
let lastError;
|
|
100
|
+
for(let attempt = 0; attempt <= maxRetries; attempt++){
|
|
101
|
+
try {
|
|
102
|
+
if (attempt > 0) {
|
|
103
|
+
// Wait before retry
|
|
104
|
+
await this.delay(this.retryDelay * Math.pow(2, attempt - 1));
|
|
105
|
+
this.ui.addLog('info', `Retrying ${toolName} (attempt ${attempt + 1}/${maxRetries + 1})`);
|
|
106
|
+
}
|
|
107
|
+
const result = await this.executeToolDirect(toolName, parameters);
|
|
108
|
+
return result;
|
|
109
|
+
} catch (error) {
|
|
110
|
+
lastError = error;
|
|
111
|
+
this.ui.addLog('warning', `Tool ${toolName} failed on attempt ${attempt + 1}: ${error.message}`);
|
|
112
|
+
}
|
|
250
113
|
}
|
|
251
|
-
|
|
252
|
-
const result = await this.executeToolDirect(toolName, parameters);
|
|
253
|
-
return result;
|
|
254
|
-
} catch (error) {
|
|
255
|
-
lastError = error;
|
|
256
|
-
this.ui.addLog(
|
|
257
|
-
'warning',
|
|
258
|
-
`Tool ${toolName} failed on attempt ${attempt + 1}: ${error.message}`,
|
|
259
|
-
);
|
|
260
|
-
}
|
|
114
|
+
throw new Error(`Tool ${toolName} failed after ${maxRetries + 1} attempts: ${lastError.message}`);
|
|
261
115
|
}
|
|
262
|
-
|
|
263
|
-
throw new Error(
|
|
264
|
-
`Tool ${toolName} failed after ${maxRetries + 1} attempts: ${lastError.message}`,
|
|
265
|
-
);
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
/**
|
|
116
|
+
/**
|
|
269
117
|
* Execute tool directly (with or without MCP)
|
|
270
|
-
*/
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
} catch (error) {
|
|
284
|
-
throw new Error(`MCP tool execution failed: ${error.message}`);
|
|
118
|
+
*/ async executeToolDirect(toolName, parameters) {
|
|
119
|
+
if (this.useMockMode) {
|
|
120
|
+
return this.executeMockTool(toolName, parameters);
|
|
121
|
+
}
|
|
122
|
+
try {
|
|
123
|
+
// Use the mcp__claude-flow__ tools that are available
|
|
124
|
+
const mcpToolName = `mcp__claude-flow__${toolName}`;
|
|
125
|
+
// Check if we have this tool available (would need to be passed from the calling context)
|
|
126
|
+
// For now, simulate execution
|
|
127
|
+
return this.executeMockTool(toolName, parameters);
|
|
128
|
+
} catch (error) {
|
|
129
|
+
throw new Error(`MCP tool execution failed: ${error.message}`);
|
|
130
|
+
}
|
|
285
131
|
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
/**
|
|
132
|
+
/**
|
|
289
133
|
* Execute mock tool for demonstration and fallback
|
|
290
|
-
*/
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
134
|
+
*/ async executeMockTool(toolName, parameters) {
|
|
135
|
+
// Simulate processing time
|
|
136
|
+
await this.delay(Math.random() * 1000 + 500);
|
|
137
|
+
// Generate realistic mock responses based on tool type
|
|
138
|
+
switch(toolName){
|
|
139
|
+
case 'swarm_init':
|
|
140
|
+
return {
|
|
141
|
+
success: true,
|
|
142
|
+
swarmId: `swarm_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
|
|
143
|
+
topology: parameters.topology || 'hierarchical',
|
|
144
|
+
maxAgents: parameters.maxAgents || 8,
|
|
145
|
+
strategy: parameters.strategy || 'auto',
|
|
146
|
+
status: 'initialized',
|
|
147
|
+
timestamp: new Date().toISOString()
|
|
148
|
+
};
|
|
149
|
+
case 'neural_train':
|
|
150
|
+
const epochs = parameters.epochs || 50;
|
|
151
|
+
const accuracy = Math.min(0.65 + epochs / 100 * 0.3 + Math.random() * 0.05, 0.98);
|
|
152
|
+
return {
|
|
153
|
+
success: true,
|
|
154
|
+
modelId: `model_${parameters.pattern_type || 'general'}_${Date.now()}`,
|
|
155
|
+
pattern_type: parameters.pattern_type || 'coordination',
|
|
156
|
+
epochs,
|
|
157
|
+
accuracy,
|
|
158
|
+
training_time: 2 + epochs * 0.08,
|
|
159
|
+
status: 'completed',
|
|
160
|
+
timestamp: new Date().toISOString()
|
|
161
|
+
};
|
|
162
|
+
case 'memory_usage':
|
|
163
|
+
if (parameters.action === 'store') {
|
|
164
|
+
return {
|
|
165
|
+
success: true,
|
|
166
|
+
action: 'store',
|
|
167
|
+
key: parameters.key,
|
|
168
|
+
namespace: parameters.namespace || 'default',
|
|
169
|
+
stored: true,
|
|
170
|
+
timestamp: new Date().toISOString()
|
|
171
|
+
};
|
|
172
|
+
} else if (parameters.action === 'retrieve') {
|
|
173
|
+
return {
|
|
174
|
+
success: true,
|
|
175
|
+
action: 'retrieve',
|
|
176
|
+
key: parameters.key,
|
|
177
|
+
value: `Mock value for ${parameters.key}`,
|
|
178
|
+
namespace: parameters.namespace || 'default',
|
|
179
|
+
timestamp: new Date().toISOString()
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
break;
|
|
183
|
+
case 'performance_report':
|
|
184
|
+
return {
|
|
185
|
+
success: true,
|
|
186
|
+
timeframe: parameters.timeframe || '24h',
|
|
187
|
+
format: parameters.format || 'summary',
|
|
188
|
+
metrics: {
|
|
189
|
+
tasks_executed: Math.floor(Math.random() * 200) + 50,
|
|
190
|
+
success_rate: Math.random() * 0.2 + 0.8,
|
|
191
|
+
avg_execution_time: Math.random() * 10 + 5,
|
|
192
|
+
agents_spawned: Math.floor(Math.random() * 50) + 10,
|
|
193
|
+
memory_efficiency: Math.random() * 0.3 + 0.7,
|
|
194
|
+
neural_events: Math.floor(Math.random() * 100) + 20
|
|
195
|
+
},
|
|
196
|
+
timestamp: new Date().toISOString()
|
|
197
|
+
};
|
|
198
|
+
default:
|
|
199
|
+
return {
|
|
200
|
+
success: true,
|
|
201
|
+
tool: toolName,
|
|
202
|
+
message: `Mock execution of ${toolName}`,
|
|
203
|
+
parameters,
|
|
204
|
+
timestamp: new Date().toISOString()
|
|
205
|
+
};
|
|
341
206
|
}
|
|
342
|
-
break;
|
|
343
|
-
|
|
344
|
-
case 'performance_report':
|
|
345
|
-
return {
|
|
346
|
-
success: true,
|
|
347
|
-
timeframe: parameters.timeframe || '24h',
|
|
348
|
-
format: parameters.format || 'summary',
|
|
349
|
-
metrics: {
|
|
350
|
-
tasks_executed: Math.floor(Math.random() * 200) + 50,
|
|
351
|
-
success_rate: Math.random() * 0.2 + 0.8,
|
|
352
|
-
avg_execution_time: Math.random() * 10 + 5,
|
|
353
|
-
agents_spawned: Math.floor(Math.random() * 50) + 10,
|
|
354
|
-
memory_efficiency: Math.random() * 0.3 + 0.7,
|
|
355
|
-
neural_events: Math.floor(Math.random() * 100) + 20,
|
|
356
|
-
},
|
|
357
|
-
timestamp: new Date().toISOString(),
|
|
358
|
-
};
|
|
359
|
-
|
|
360
|
-
default:
|
|
361
|
-
return {
|
|
362
|
-
success: true,
|
|
363
|
-
tool: toolName,
|
|
364
|
-
message: `Mock execution of ${toolName}`,
|
|
365
|
-
parameters,
|
|
366
|
-
timestamp: new Date().toISOString(),
|
|
367
|
-
};
|
|
368
207
|
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
/**
|
|
208
|
+
/**
|
|
372
209
|
* Execute multiple tools in parallel
|
|
373
|
-
*/
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
return Promise.allSettled(promises);
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
/**
|
|
210
|
+
*/ async executeToolsParallel(toolExecutions) {
|
|
211
|
+
const promises = toolExecutions.map(({ toolName, parameters, options })=>this.executeTool(toolName, parameters, options));
|
|
212
|
+
return Promise.allSettled(promises);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
383
215
|
* Execute tools in batch with progress tracking
|
|
384
|
-
*/
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
216
|
+
*/ async executeToolsBatch(toolExecutions, progressCallback) {
|
|
217
|
+
const results = [];
|
|
218
|
+
const total = toolExecutions.length;
|
|
219
|
+
for(let i = 0; i < total; i++){
|
|
220
|
+
const { toolName, parameters, options } = toolExecutions[i];
|
|
221
|
+
try {
|
|
222
|
+
const result = await this.executeTool(toolName, parameters, options);
|
|
223
|
+
results.push({
|
|
224
|
+
success: true,
|
|
225
|
+
result
|
|
226
|
+
});
|
|
227
|
+
if (progressCallback) {
|
|
228
|
+
progressCallback({
|
|
229
|
+
completed: i + 1,
|
|
230
|
+
total,
|
|
231
|
+
progress: (i + 1) / total * 100,
|
|
232
|
+
currentTool: toolName
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
} catch (error) {
|
|
236
|
+
results.push({
|
|
237
|
+
success: false,
|
|
238
|
+
error: error.message
|
|
239
|
+
});
|
|
240
|
+
}
|
|
403
241
|
}
|
|
404
|
-
|
|
405
|
-
results.push({ success: false, error: error.message });
|
|
406
|
-
}
|
|
242
|
+
return results;
|
|
407
243
|
}
|
|
408
|
-
|
|
409
|
-
return results;
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
/**
|
|
244
|
+
/**
|
|
413
245
|
* Cache tool results for performance
|
|
414
|
-
*/
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
this.cleanExpiredCache();
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
/**
|
|
246
|
+
*/ cacheResult(toolName, parameters, result) {
|
|
247
|
+
const cacheKey = this.generateCacheKey(toolName, parameters);
|
|
248
|
+
const ttl = this.getCacheTTL(toolName);
|
|
249
|
+
this.resultCache.set(cacheKey, {
|
|
250
|
+
result,
|
|
251
|
+
timestamp: Date.now(),
|
|
252
|
+
ttl
|
|
253
|
+
});
|
|
254
|
+
// Clean expired cache entries
|
|
255
|
+
this.cleanExpiredCache();
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
430
258
|
* Get cached result if available and not expired
|
|
431
|
-
*/
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
return null;
|
|
259
|
+
*/ getCachedResult(toolName, parameters) {
|
|
260
|
+
const cacheKey = this.generateCacheKey(toolName, parameters);
|
|
261
|
+
const cached = this.resultCache.get(cacheKey);
|
|
262
|
+
if (!cached) return null;
|
|
263
|
+
const age = Date.now() - cached.timestamp;
|
|
264
|
+
if (age > cached.ttl) {
|
|
265
|
+
this.resultCache.delete(cacheKey);
|
|
266
|
+
return null;
|
|
267
|
+
}
|
|
268
|
+
return cached.result;
|
|
442
269
|
}
|
|
443
|
-
|
|
444
|
-
return cached.result;
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
/**
|
|
270
|
+
/**
|
|
448
271
|
* Generate cache key for tool execution
|
|
449
|
-
*/
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
/**
|
|
272
|
+
*/ generateCacheKey(toolName, parameters) {
|
|
273
|
+
return `${toolName}_${JSON.stringify(parameters)}`;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
455
276
|
* Get cache TTL based on tool type
|
|
456
|
-
*/
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
return ttlMap[toolName] || 60000; // Default 1 minute
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
/**
|
|
277
|
+
*/ getCacheTTL(toolName) {
|
|
278
|
+
// Different tools have different cache lifetimes
|
|
279
|
+
const ttlMap = {
|
|
280
|
+
// Fast changing data - short TTL
|
|
281
|
+
swarm_status: 5000,
|
|
282
|
+
agent_metrics: 10000,
|
|
283
|
+
performance_report: 30000,
|
|
284
|
+
// Slow changing data - medium TTL
|
|
285
|
+
memory_usage: 60000,
|
|
286
|
+
system_status: 120000,
|
|
287
|
+
// Static data - long TTL
|
|
288
|
+
features_detect: 300000,
|
|
289
|
+
config_manage: 600000
|
|
290
|
+
};
|
|
291
|
+
return ttlMap[toolName] || 60000; // Default 1 minute
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
478
294
|
* Clean expired cache entries
|
|
479
|
-
*/
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
295
|
+
*/ cleanExpiredCache() {
|
|
296
|
+
const now = Date.now();
|
|
297
|
+
for (const [key, cached] of this.resultCache.entries()){
|
|
298
|
+
if (now - cached.timestamp > cached.ttl) {
|
|
299
|
+
this.resultCache.delete(key);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
486
302
|
}
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
/**
|
|
303
|
+
/**
|
|
490
304
|
* Get tools by category
|
|
491
|
-
*/
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
/**
|
|
305
|
+
*/ getToolsByCategory(category) {
|
|
306
|
+
return this.toolCategories[category] || [];
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
497
309
|
* Get all available tool categories
|
|
498
|
-
*/
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
/**
|
|
310
|
+
*/ getToolCategories() {
|
|
311
|
+
return Object.keys(this.toolCategories);
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
504
314
|
* Get tool execution status
|
|
505
|
-
*/
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
/**
|
|
315
|
+
*/ getExecutionStatus(executionId) {
|
|
316
|
+
return this.activeTools.get(executionId);
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
511
319
|
* Cancel tool execution
|
|
512
|
-
*/
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
320
|
+
*/ async cancelExecution(executionId) {
|
|
321
|
+
const execution = this.activeTools.get(executionId);
|
|
322
|
+
if (execution && execution.status === 'running') {
|
|
323
|
+
execution.status = 'cancelled';
|
|
324
|
+
this.notifyUI('tool_cancelled', {
|
|
325
|
+
executionId
|
|
326
|
+
});
|
|
327
|
+
}
|
|
518
328
|
}
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
/**
|
|
329
|
+
/**
|
|
522
330
|
* Start monitoring active tools
|
|
523
|
-
*/
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
/**
|
|
331
|
+
*/ startToolMonitoring() {
|
|
332
|
+
setInterval(()=>{
|
|
333
|
+
this.updateToolProgress();
|
|
334
|
+
this.cleanCompletedExecutions();
|
|
335
|
+
}, 1000);
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
532
338
|
* Update progress for running tools
|
|
533
|
-
*/
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
339
|
+
*/ updateToolProgress() {
|
|
340
|
+
for (const [executionId, execution] of this.activeTools.entries()){
|
|
341
|
+
if (execution.status === 'running') {
|
|
342
|
+
const elapsed = Date.now() - execution.startTime;
|
|
343
|
+
// Estimate progress based on elapsed time (simplified)
|
|
344
|
+
const estimatedDuration = this.getEstimatedDuration(execution.toolName);
|
|
345
|
+
execution.progress = Math.min(elapsed / estimatedDuration * 100, 95);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
542
348
|
}
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
/**
|
|
349
|
+
/**
|
|
546
350
|
* Get estimated duration for tool execution
|
|
547
|
-
*/
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
/**
|
|
351
|
+
*/ getEstimatedDuration(toolName) {
|
|
352
|
+
const durationMap = {
|
|
353
|
+
neural_train: 30000,
|
|
354
|
+
performance_report: 5000,
|
|
355
|
+
swarm_init: 2000,
|
|
356
|
+
memory_backup: 10000
|
|
357
|
+
};
|
|
358
|
+
return durationMap[toolName] || 3000; // Default 3 seconds
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
560
361
|
* Clean completed executions older than 1 hour
|
|
561
|
-
*/
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
362
|
+
*/ cleanCompletedExecutions() {
|
|
363
|
+
const oneHourAgo = Date.now() - 3600000;
|
|
364
|
+
for (const [executionId, execution] of this.activeTools.entries()){
|
|
365
|
+
if (execution.endTime && execution.endTime < oneHourAgo) {
|
|
366
|
+
this.activeTools.delete(executionId);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
568
369
|
}
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
/**
|
|
370
|
+
/**
|
|
572
371
|
* Setup event handlers for real-time updates
|
|
573
|
-
*/
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
372
|
+
*/ setupEventHandlers() {
|
|
373
|
+
// Monitor system events that might affect tool execution
|
|
374
|
+
if (typeof process !== 'undefined') {
|
|
375
|
+
process.on('SIGINT', ()=>{
|
|
376
|
+
this.handleShutdown();
|
|
377
|
+
});
|
|
378
|
+
}
|
|
580
379
|
}
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
/**
|
|
380
|
+
/**
|
|
584
381
|
* Handle system shutdown
|
|
585
|
-
*/
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
382
|
+
*/ handleShutdown() {
|
|
383
|
+
// Cancel all running executions
|
|
384
|
+
for (const [executionId, execution] of this.activeTools.entries()){
|
|
385
|
+
if (execution.status === 'running') {
|
|
386
|
+
this.cancelExecution(executionId);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
592
389
|
}
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
/**
|
|
390
|
+
/**
|
|
596
391
|
* Notify UI of events
|
|
597
|
-
*/
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
}
|
|
392
|
+
*/ notifyUI(eventType, data) {
|
|
393
|
+
if (this.ui && typeof this.ui.addLog === 'function') {
|
|
394
|
+
const message = this.formatEventMessage(eventType, data);
|
|
395
|
+
const level = this.getEventLevel(eventType);
|
|
396
|
+
this.ui.addLog(level, message);
|
|
397
|
+
}
|
|
398
|
+
// Notify subscribers
|
|
399
|
+
for (const callback of this.subscriptions){
|
|
400
|
+
try {
|
|
401
|
+
callback(eventType, data);
|
|
402
|
+
} catch (error) {
|
|
403
|
+
console.error('Error in event subscription:', error);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
612
406
|
}
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
/**
|
|
407
|
+
/**
|
|
616
408
|
* Format event message for UI
|
|
617
|
-
*/
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
409
|
+
*/ formatEventMessage(eventType, data) {
|
|
410
|
+
switch(eventType){
|
|
411
|
+
case 'tool_start':
|
|
412
|
+
return `Started ${data.toolName} (ID: ${data.executionId})`;
|
|
413
|
+
case 'tool_complete':
|
|
414
|
+
return `Completed ${data.toolName} successfully`;
|
|
415
|
+
case 'tool_error':
|
|
416
|
+
return `Failed ${data.toolName}: ${data.error}`;
|
|
417
|
+
case 'tool_cancelled':
|
|
418
|
+
return `Cancelled execution ${data.executionId}`;
|
|
419
|
+
default:
|
|
420
|
+
return `Event: ${eventType}`;
|
|
421
|
+
}
|
|
630
422
|
}
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
/**
|
|
423
|
+
/**
|
|
634
424
|
* Get event level for logging
|
|
635
|
-
*/
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
425
|
+
*/ getEventLevel(eventType) {
|
|
426
|
+
switch(eventType){
|
|
427
|
+
case 'tool_complete':
|
|
428
|
+
return 'success';
|
|
429
|
+
case 'tool_error':
|
|
430
|
+
return 'error';
|
|
431
|
+
case 'tool_cancelled':
|
|
432
|
+
return 'warning';
|
|
433
|
+
default:
|
|
434
|
+
return 'info';
|
|
435
|
+
}
|
|
646
436
|
}
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
/**
|
|
437
|
+
/**
|
|
650
438
|
* Subscribe to events
|
|
651
|
-
*/
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
/**
|
|
439
|
+
*/ subscribe(callback) {
|
|
440
|
+
this.subscriptions.add(callback);
|
|
441
|
+
return ()=>this.subscriptions.delete(callback);
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
658
444
|
* Get comprehensive status
|
|
659
|
-
*/
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
activeExecutions: running,
|
|
674
|
-
completedExecutions: completed,
|
|
675
|
-
failedExecutions: failed,
|
|
676
|
-
cacheSize: this.resultCache.size,
|
|
677
|
-
totalTools: Object.values(this.toolCategories).flat().length,
|
|
678
|
-
};
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
/**
|
|
445
|
+
*/ getStatus() {
|
|
446
|
+
const running = Array.from(this.activeTools.values()).filter((e)=>e.status === 'running').length;
|
|
447
|
+
const completed = Array.from(this.activeTools.values()).filter((e)=>e.status === 'completed').length;
|
|
448
|
+
const failed = Array.from(this.activeTools.values()).filter((e)=>e.status === 'failed').length;
|
|
449
|
+
return {
|
|
450
|
+
mcpAvailable: !this.useMockMode,
|
|
451
|
+
activeExecutions: running,
|
|
452
|
+
completedExecutions: completed,
|
|
453
|
+
failedExecutions: failed,
|
|
454
|
+
cacheSize: this.resultCache.size,
|
|
455
|
+
totalTools: Object.values(this.toolCategories).flat().length
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
682
459
|
* Utility delay function
|
|
683
|
-
*/
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
460
|
+
*/ delay(ms) {
|
|
461
|
+
return new Promise((resolve)=>setTimeout(resolve, ms));
|
|
462
|
+
}
|
|
463
|
+
constructor(ui){
|
|
464
|
+
this.ui = ui;
|
|
465
|
+
this.activeTools = new Map();
|
|
466
|
+
this.resultCache = new Map();
|
|
467
|
+
this.subscriptions = new Set();
|
|
468
|
+
this.retryQueue = new Map();
|
|
469
|
+
this.maxRetries = 3;
|
|
470
|
+
this.retryDelay = 1000;
|
|
471
|
+
// Tool categories for better organization
|
|
472
|
+
this.toolCategories = {
|
|
473
|
+
// Swarm Coordination Tools (12)
|
|
474
|
+
swarm: [
|
|
475
|
+
'swarm_init',
|
|
476
|
+
'agent_spawn',
|
|
477
|
+
'task_orchestrate',
|
|
478
|
+
'swarm_status',
|
|
479
|
+
'agent_list',
|
|
480
|
+
'agent_metrics',
|
|
481
|
+
'swarm_monitor',
|
|
482
|
+
'topology_optimize',
|
|
483
|
+
'load_balance',
|
|
484
|
+
'coordination_sync',
|
|
485
|
+
'swarm_scale',
|
|
486
|
+
'swarm_destroy'
|
|
487
|
+
],
|
|
488
|
+
// Neural Network Tools (15)
|
|
489
|
+
neural: [
|
|
490
|
+
'neural_status',
|
|
491
|
+
'neural_train',
|
|
492
|
+
'neural_patterns',
|
|
493
|
+
'neural_predict',
|
|
494
|
+
'model_load',
|
|
495
|
+
'model_save',
|
|
496
|
+
'wasm_optimize',
|
|
497
|
+
'inference_run',
|
|
498
|
+
'pattern_recognize',
|
|
499
|
+
'cognitive_analyze',
|
|
500
|
+
'learning_adapt',
|
|
501
|
+
'neural_compress',
|
|
502
|
+
'ensemble_create',
|
|
503
|
+
'transfer_learn',
|
|
504
|
+
'neural_explain'
|
|
505
|
+
],
|
|
506
|
+
// Memory & Persistence Tools (12)
|
|
507
|
+
memory: [
|
|
508
|
+
'memory_usage',
|
|
509
|
+
'memory_search',
|
|
510
|
+
'memory_persist',
|
|
511
|
+
'memory_namespace',
|
|
512
|
+
'memory_backup',
|
|
513
|
+
'memory_restore',
|
|
514
|
+
'memory_compress',
|
|
515
|
+
'memory_sync',
|
|
516
|
+
'cache_manage',
|
|
517
|
+
'state_snapshot',
|
|
518
|
+
'context_restore',
|
|
519
|
+
'memory_analytics'
|
|
520
|
+
],
|
|
521
|
+
// Analysis & Monitoring Tools (13)
|
|
522
|
+
analysis: [
|
|
523
|
+
'performance_report',
|
|
524
|
+
'bottleneck_analyze',
|
|
525
|
+
'token_usage',
|
|
526
|
+
'task_status',
|
|
527
|
+
'task_results',
|
|
528
|
+
'benchmark_run',
|
|
529
|
+
'metrics_collect',
|
|
530
|
+
'trend_analysis',
|
|
531
|
+
'cost_analysis',
|
|
532
|
+
'quality_assess',
|
|
533
|
+
'error_analysis',
|
|
534
|
+
'usage_stats',
|
|
535
|
+
'health_check'
|
|
536
|
+
],
|
|
537
|
+
// Workflow & Automation Tools (11)
|
|
538
|
+
workflow: [
|
|
539
|
+
'workflow_create',
|
|
540
|
+
'sparc_mode',
|
|
541
|
+
'workflow_execute',
|
|
542
|
+
'workflow_export',
|
|
543
|
+
'automation_setup',
|
|
544
|
+
'pipeline_create',
|
|
545
|
+
'scheduler_manage',
|
|
546
|
+
'trigger_setup',
|
|
547
|
+
'workflow_template',
|
|
548
|
+
'batch_process',
|
|
549
|
+
'parallel_execute'
|
|
550
|
+
],
|
|
551
|
+
// GitHub Integration Tools (8)
|
|
552
|
+
github: [
|
|
553
|
+
'github_repo_analyze',
|
|
554
|
+
'github_pr_manage',
|
|
555
|
+
'github_issue_track',
|
|
556
|
+
'github_release_coord',
|
|
557
|
+
'github_workflow_auto',
|
|
558
|
+
'github_code_review',
|
|
559
|
+
'github_sync_coord',
|
|
560
|
+
'github_metrics'
|
|
561
|
+
],
|
|
562
|
+
// DAA (Dynamic Agent Architecture) Tools (8)
|
|
563
|
+
daa: [
|
|
564
|
+
'daa_agent_create',
|
|
565
|
+
'daa_capability_match',
|
|
566
|
+
'daa_resource_alloc',
|
|
567
|
+
'daa_lifecycle_manage',
|
|
568
|
+
'daa_communication',
|
|
569
|
+
'daa_consensus',
|
|
570
|
+
'daa_fault_tolerance',
|
|
571
|
+
'daa_optimization'
|
|
572
|
+
],
|
|
573
|
+
// System & Utilities Tools (6+)
|
|
574
|
+
system: [
|
|
575
|
+
'terminal_execute',
|
|
576
|
+
'config_manage',
|
|
577
|
+
'features_detect',
|
|
578
|
+
'security_scan',
|
|
579
|
+
'backup_create',
|
|
580
|
+
'restore_system',
|
|
581
|
+
'log_analysis',
|
|
582
|
+
'diagnostic_run'
|
|
583
|
+
]
|
|
584
|
+
};
|
|
585
|
+
this.initializeIntegration();
|
|
586
|
+
}
|
|
687
587
|
}
|
|
688
|
-
|
|
689
588
|
export default MCPIntegrationLayer;
|