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.
Files changed (272) hide show
  1. package/dist/src/cli/commands/guidance.js +487 -668
  2. package/dist/src/cli/commands/index-validate.js +18 -29
  3. package/dist/src/cli/commands/mcp-troubleshoot.js +230 -282
  4. package/dist/src/cli/commands/neural-goal-init.js +92 -125
  5. package/dist/src/cli/commands/swarm-exec.js +317 -393
  6. package/dist/src/cli/commands/swarm.js +1 -1
  7. package/dist/src/cli/commands/validate-framework.js +983 -1100
  8. package/dist/src/cli/commands/validate.js +144 -223
  9. package/dist/src/cli/simple-commands/__tests__/agent.test.js +265 -277
  10. package/dist/src/cli/simple-commands/__tests__/memory.test.js +6 -7
  11. package/dist/src/cli/simple-commands/__tests__/swarm.test.js +373 -356
  12. package/dist/src/cli/simple-commands/__tests__/task.test.js +6 -7
  13. package/dist/src/cli/simple-commands/agent.js +157 -193
  14. package/dist/src/cli/simple-commands/analysis.js +336 -446
  15. package/dist/src/cli/simple-commands/automation-executor.js +1095 -1339
  16. package/dist/src/cli/simple-commands/automation.js +481 -469
  17. package/dist/src/cli/simple-commands/batch-manager.js +261 -313
  18. package/dist/src/cli/simple-commands/claude-telemetry.js +241 -267
  19. package/dist/src/cli/simple-commands/claude-track.js +68 -90
  20. package/dist/src/cli/simple-commands/concurrent-display.js +266 -320
  21. package/dist/src/cli/simple-commands/config.js +245 -290
  22. package/dist/src/cli/simple-commands/coordination.js +182 -234
  23. package/dist/src/cli/simple-commands/enhanced-ui-views.js +812 -615
  24. package/dist/src/cli/simple-commands/enhanced-webui-complete.js +922 -981
  25. package/dist/src/cli/simple-commands/fix-hook-variables.js +274 -294
  26. package/dist/src/cli/simple-commands/github/gh-coordinator.js +378 -457
  27. package/dist/src/cli/simple-commands/github/github-api.js +535 -574
  28. package/dist/src/cli/simple-commands/github/init.js +276 -303
  29. package/dist/src/cli/simple-commands/github.js +222 -247
  30. package/dist/src/cli/simple-commands/goal.js +51 -63
  31. package/dist/src/cli/simple-commands/hive-mind/auto-save-middleware.js +208 -278
  32. package/dist/src/cli/simple-commands/hive-mind/communication.js +601 -696
  33. package/dist/src/cli/simple-commands/hive-mind/core.js +907 -979
  34. package/dist/src/cli/simple-commands/hive-mind/db-optimizer.js +406 -655
  35. package/dist/src/cli/simple-commands/hive-mind/mcp-wrapper.js +1125 -1245
  36. package/dist/src/cli/simple-commands/hive-mind/memory.js +854 -1090
  37. package/dist/src/cli/simple-commands/hive-mind/performance-optimizer.js +459 -574
  38. package/dist/src/cli/simple-commands/hive-mind/performance-test.js +263 -347
  39. package/dist/src/cli/simple-commands/hive-mind/queen.js +727 -768
  40. package/dist/src/cli/simple-commands/hive-mind/session-manager.js +745 -1049
  41. package/dist/src/cli/simple-commands/hive-mind-optimize.js +227 -283
  42. package/dist/src/cli/simple-commands/hive-mind-wizard.js +174 -217
  43. package/dist/src/cli/simple-commands/hive-mind.js +1842 -2283
  44. package/dist/src/cli/simple-commands/hive.js +90 -79
  45. package/dist/src/cli/simple-commands/hook-safety.js +431 -521
  46. package/dist/src/cli/simple-commands/hooks/session-start-soul.js +203 -254
  47. package/dist/src/cli/simple-commands/hooks.js +1064 -1204
  48. package/dist/src/cli/simple-commands/init/agent-copier.js +294 -319
  49. package/dist/src/cli/simple-commands/init/batch-init.js +496 -562
  50. package/dist/src/cli/simple-commands/init/claude-commands/claude-flow-commands.js +13 -19
  51. package/dist/src/cli/simple-commands/init/claude-commands/optimized-claude-flow-commands.js +13 -19
  52. package/dist/src/cli/simple-commands/init/claude-commands/optimized-slash-commands.js +61 -88
  53. package/dist/src/cli/simple-commands/init/claude-commands/optimized-sparc-commands.js +125 -150
  54. package/dist/src/cli/simple-commands/init/claude-commands/slash-commands.js +42 -49
  55. package/dist/src/cli/simple-commands/init/claude-commands/sparc-commands.js +43 -61
  56. package/dist/src/cli/simple-commands/init/copy-revised-templates.js +141 -147
  57. package/dist/src/cli/simple-commands/init/executable-wrapper.js +31 -44
  58. package/dist/src/cli/simple-commands/init/gitignore-updater.js +64 -90
  59. package/dist/src/cli/simple-commands/init/help.js +104 -107
  60. package/dist/src/cli/simple-commands/init/hive-mind-init.js +509 -528
  61. package/dist/src/cli/simple-commands/init/index.js +1510 -1759
  62. package/dist/src/cli/simple-commands/init/performance-monitor.js +234 -317
  63. package/dist/src/cli/simple-commands/init/rollback/backup-manager.js +441 -504
  64. package/dist/src/cli/simple-commands/init/rollback/index.js +289 -364
  65. package/dist/src/cli/simple-commands/init/rollback/recovery-manager.js +652 -728
  66. package/dist/src/cli/simple-commands/init/rollback/rollback-executor.js +416 -481
  67. package/dist/src/cli/simple-commands/init/rollback/state-tracker.js +369 -448
  68. package/dist/src/cli/simple-commands/init/sparc/roo-readme.js +1 -2
  69. package/dist/src/cli/simple-commands/init/sparc/roomodes-config.js +122 -99
  70. package/dist/src/cli/simple-commands/init/sparc/workflows.js +32 -37
  71. package/dist/src/cli/simple-commands/init/sparc-structure.js +55 -62
  72. package/dist/src/cli/simple-commands/init/template-copier.js +421 -533
  73. package/dist/src/cli/simple-commands/init/templates/coordination-md.js +3 -6
  74. package/dist/src/cli/simple-commands/init/templates/enhanced-templates.js +344 -318
  75. package/dist/src/cli/simple-commands/init/templates/github-safe-enhanced.js +173 -218
  76. package/dist/src/cli/simple-commands/init/templates/github-safe.js +65 -75
  77. package/dist/src/cli/simple-commands/init/templates/memory-bank-md.js +3 -6
  78. package/dist/src/cli/simple-commands/init/templates/readme-files.js +2 -4
  79. package/dist/src/cli/simple-commands/init/templates/safe-hook-patterns.js +187 -230
  80. package/dist/src/cli/simple-commands/init/templates/sparc-modes.js +53 -80
  81. package/dist/src/cli/simple-commands/init/templates/verification-claude-md.js +101 -85
  82. package/dist/src/cli/simple-commands/init/validation/config-validator.js +283 -330
  83. package/dist/src/cli/simple-commands/init/validation/health-checker.js +495 -561
  84. package/dist/src/cli/simple-commands/init/validation/index.js +302 -358
  85. package/dist/src/cli/simple-commands/init/validation/mode-validator.js +308 -359
  86. package/dist/src/cli/simple-commands/init/validation/post-init-validator.js +389 -366
  87. package/dist/src/cli/simple-commands/init/validation/pre-init-validator.js +270 -268
  88. package/dist/src/cli/simple-commands/init/validation/test-runner.js +427 -447
  89. package/dist/src/cli/simple-commands/init.js +1 -2
  90. package/dist/src/cli/simple-commands/mcp-health.js +131 -158
  91. package/dist/src/cli/simple-commands/mcp-integration-layer.js +533 -634
  92. package/dist/src/cli/simple-commands/mcp.js +345 -400
  93. package/dist/src/cli/simple-commands/memory-consolidation.js +426 -537
  94. package/dist/src/cli/simple-commands/memory.js +247 -311
  95. package/dist/src/cli/simple-commands/migrate-hooks.js +39 -46
  96. package/dist/src/cli/simple-commands/monitor.js +294 -363
  97. package/dist/src/cli/simple-commands/neural.js +51 -65
  98. package/dist/src/cli/simple-commands/pair-autofix-only.js +538 -662
  99. package/dist/src/cli/simple-commands/pair-basic.js +528 -656
  100. package/dist/src/cli/simple-commands/pair-old.js +430 -543
  101. package/dist/src/cli/simple-commands/pair-working.js +615 -751
  102. package/dist/src/cli/simple-commands/pair.js +615 -751
  103. package/dist/src/cli/simple-commands/performance-hooks.js +83 -111
  104. package/dist/src/cli/simple-commands/performance-metrics.js +348 -433
  105. package/dist/src/cli/simple-commands/process-ui-enhanced.js +708 -787
  106. package/dist/src/cli/simple-commands/process-ui.js +230 -254
  107. package/dist/src/cli/simple-commands/realtime-update-system.js +525 -611
  108. package/dist/src/cli/simple-commands/sparc/architecture.js +1704 -1530
  109. package/dist/src/cli/simple-commands/sparc/commands.js +438 -516
  110. package/dist/src/cli/simple-commands/sparc/completion.js +1224 -1481
  111. package/dist/src/cli/simple-commands/sparc/coordinator.js +913 -978
  112. package/dist/src/cli/simple-commands/sparc/index.js +241 -298
  113. package/dist/src/cli/simple-commands/sparc/phase-base.js +314 -390
  114. package/dist/src/cli/simple-commands/sparc/pseudocode.js +965 -869
  115. package/dist/src/cli/simple-commands/sparc/refinement.js +980 -1273
  116. package/dist/src/cli/simple-commands/sparc/specification.js +559 -645
  117. package/dist/src/cli/simple-commands/sparc-modes/architect.js +1 -1
  118. package/dist/src/cli/simple-commands/sparc-modes/ask.js +1 -1
  119. package/dist/src/cli/simple-commands/sparc-modes/code.js +1 -1
  120. package/dist/src/cli/simple-commands/sparc-modes/debug.js +1 -1
  121. package/dist/src/cli/simple-commands/sparc-modes/devops.js +1 -1
  122. package/dist/src/cli/simple-commands/sparc-modes/docs-writer.js +1 -1
  123. package/dist/src/cli/simple-commands/sparc-modes/generic.js +1 -1
  124. package/dist/src/cli/simple-commands/sparc-modes/index.js +47 -55
  125. package/dist/src/cli/simple-commands/sparc-modes/integration.js +1 -1
  126. package/dist/src/cli/simple-commands/sparc-modes/mcp.js +1 -1
  127. package/dist/src/cli/simple-commands/sparc-modes/monitoring.js +1 -1
  128. package/dist/src/cli/simple-commands/sparc-modes/optimization.js +1 -1
  129. package/dist/src/cli/simple-commands/sparc-modes/security-review.js +1 -1
  130. package/dist/src/cli/simple-commands/sparc-modes/sparc-orchestrator.js +1 -1
  131. package/dist/src/cli/simple-commands/sparc-modes/spec-pseudocode.js +1 -1
  132. package/dist/src/cli/simple-commands/sparc-modes/supabase-admin.js +1 -1
  133. package/dist/src/cli/simple-commands/sparc-modes/swarm.js +101 -87
  134. package/dist/src/cli/simple-commands/sparc-modes/tdd.js +1 -1
  135. package/dist/src/cli/simple-commands/sparc-modes/tutorial.js +1 -1
  136. package/dist/src/cli/simple-commands/sparc.js +465 -493
  137. package/dist/src/cli/simple-commands/start-ui.js +108 -132
  138. package/dist/src/cli/simple-commands/start-wrapper.js +240 -268
  139. package/dist/src/cli/simple-commands/start.js +1 -1
  140. package/dist/src/cli/simple-commands/status.js +254 -275
  141. package/dist/src/cli/simple-commands/stream-chain-clean.js +128 -171
  142. package/dist/src/cli/simple-commands/stream-chain-fixed.js +61 -82
  143. package/dist/src/cli/simple-commands/stream-chain-real.js +267 -331
  144. package/dist/src/cli/simple-commands/stream-chain-working.js +211 -263
  145. package/dist/src/cli/simple-commands/stream-chain.js +260 -318
  146. package/dist/src/cli/simple-commands/stream-processor.js +290 -315
  147. package/dist/src/cli/simple-commands/swarm-executor.js +189 -222
  148. package/dist/src/cli/simple-commands/swarm-metrics-integration.js +208 -300
  149. package/dist/src/cli/simple-commands/swarm-ui.js +623 -703
  150. package/dist/src/cli/simple-commands/swarm-webui-integration.js +258 -286
  151. package/dist/src/cli/simple-commands/swarm.js +887 -1082
  152. package/dist/src/cli/simple-commands/task.js +161 -206
  153. package/dist/src/cli/simple-commands/timestamp-fix.js +59 -89
  154. package/dist/src/cli/simple-commands/token-tracker.js +258 -316
  155. package/dist/src/cli/simple-commands/tool-execution-framework.js +433 -519
  156. package/dist/src/cli/simple-commands/train-and-stream.js +275 -331
  157. package/dist/src/cli/simple-commands/training-pipeline.js +619 -725
  158. package/dist/src/cli/simple-commands/training.js +170 -227
  159. package/dist/src/cli/simple-commands/verification-hooks.js +261 -284
  160. package/dist/src/cli/simple-commands/verification-integration.js +389 -417
  161. package/dist/src/cli/simple-commands/verification-training-integration.js +486 -606
  162. package/dist/src/cli/simple-commands/verification.js +493 -513
  163. package/dist/src/cli/simple-commands/web-server.js +766 -836
  164. package/dist/src/cli/simple-commands/webui-validator.js +106 -124
  165. package/dist/src/coordination/event-bus/demo-wasm-integration.js +212 -251
  166. package/dist/src/coordination/event-bus/qe-event-bus.js +608 -748
  167. package/dist/src/coordination/event-bus/qe-event-bus.test.js +379 -454
  168. package/dist/src/coordination/iteration-tracker.js +363 -454
  169. package/dist/src/enterprise/analytics-manager.js +1135 -0
  170. package/dist/src/enterprise/audit-manager.js +1115 -0
  171. package/dist/src/enterprise/cloud-manager.js +891 -0
  172. package/dist/src/enterprise/deployment-manager.js +966 -0
  173. package/dist/src/enterprise/index.js +6 -0
  174. package/dist/src/enterprise/project-manager.js +584 -0
  175. package/dist/src/enterprise/security-manager.js +991 -0
  176. package/dist/src/index.js +1 -1
  177. package/dist/src/mcp/DEPRECATED.js +46 -60
  178. package/dist/src/mcp/fixes/mcp-error-fixes.js +115 -134
  179. package/dist/src/mcp/implementations/agent-tracker.js +114 -128
  180. package/dist/src/mcp/implementations/daa-tools.js +292 -350
  181. package/dist/src/mcp/implementations/workflow-tools.js +329 -361
  182. package/dist/src/mcp/mcp-config-manager.js +1183 -1331
  183. package/dist/src/mcp/mcp-server-novice-simplified.js +11 -17
  184. package/dist/src/mcp/mcp-server-novice.js +11 -17
  185. package/dist/src/mcp/mcp-server-sdk.js +11 -17
  186. package/dist/src/mcp/mcp-server.js +1620 -1484
  187. package/dist/src/mcp/ruv-swarm-wrapper.js +209 -239
  188. package/dist/src/memory/advanced-serializer.js +609 -589
  189. package/dist/src/memory/enhanced-examples.js +220 -305
  190. package/dist/src/memory/enhanced-memory.js +295 -336
  191. package/dist/src/memory/enhanced-session-serializer.js +408 -492
  192. package/dist/src/memory/fallback-memory-system.js +900 -1021
  193. package/dist/src/memory/fallback-store.js +93 -131
  194. package/dist/src/memory/high-performance-serialization.js +592 -730
  195. package/dist/src/memory/in-memory-store.js +161 -213
  196. package/dist/src/memory/index.js +123 -157
  197. package/dist/src/memory/lock-free-structures.js +578 -764
  198. package/dist/src/memory/memory-mapped-persistence.js +585 -766
  199. package/dist/src/memory/memory-pressure-manager.js +569 -707
  200. package/dist/src/memory/migration.js +358 -445
  201. package/dist/src/memory/shared-memory.js +641 -768
  202. package/dist/src/memory/sqlite-store.js +245 -325
  203. package/dist/src/memory/sqlite-wrapper.js +122 -151
  204. package/dist/src/memory/swarm-memory.js +470 -603
  205. package/dist/src/memory/test-example.js +126 -134
  206. package/dist/src/memory/ultra-fast-memory-store.js +622 -821
  207. package/dist/src/memory/unified-memory-manager.js +356 -437
  208. package/dist/src/migration/index.js +92 -0
  209. package/dist/src/migration/logger.js +121 -0
  210. package/dist/src/migration/migration-analyzer.js +268 -0
  211. package/dist/src/migration/migration-runner.js +522 -0
  212. package/dist/src/migration/migration-validator.js +285 -0
  213. package/dist/src/migration/progress-reporter.js +150 -0
  214. package/dist/src/migration/rollback-manager.js +321 -0
  215. package/dist/src/migration/tests/migration-system.test.js +7 -0
  216. package/dist/src/migration/types.js +3 -0
  217. package/dist/src/swarm/CodeRefactoringSwarm.js +777 -952
  218. package/dist/src/swarm/__tests__/integration.test.js +227 -0
  219. package/dist/src/swarm/__tests__/prompt-copier.test.js +344 -0
  220. package/dist/src/swarm/advanced-orchestrator.js +1095 -0
  221. package/dist/src/swarm/claude-code-interface.js +961 -0
  222. package/dist/src/swarm/claude-flow-executor.js +229 -0
  223. package/dist/src/swarm/consensus-coordinator.js +475 -0
  224. package/dist/src/swarm/coordinator.js +2993 -0
  225. package/dist/src/swarm/direct-executor.js +1180 -0
  226. package/dist/src/swarm/error-recovery/advanced-error-detection.js +691 -0
  227. package/dist/src/swarm/error-recovery/automated-recovery-workflows.js +998 -0
  228. package/dist/src/swarm/error-recovery/error-recovery-coordinator.js +1197 -0
  229. package/dist/src/swarm/error-recovery/recovery-monitoring.js +772 -0
  230. package/dist/src/swarm/error-recovery/resilience-architecture.js +714 -0
  231. package/dist/src/swarm/error-recovery/self-healing-mechanisms.js +1319 -0
  232. package/dist/src/swarm/error-recovery/test-error-recovery-effectiveness.js +808 -0
  233. package/dist/src/swarm/executor-v2.js +322 -0
  234. package/dist/src/swarm/executor.js +815 -0
  235. package/dist/src/swarm/hive-mind-integration.js +703 -0
  236. package/dist/src/swarm/index.js +41 -0
  237. package/dist/src/swarm/json-output-aggregator.js +267 -0
  238. package/dist/src/swarm/large-scale-coordinator.js +542 -0
  239. package/dist/src/swarm/mcp-integration-wrapper.js +628 -0
  240. package/dist/src/swarm/memory.js +1117 -0
  241. package/dist/src/swarm/optimizations/__tests__/optimization.test.js +348 -0
  242. package/dist/src/swarm/optimizations/async-file-manager.js +285 -0
  243. package/dist/src/swarm/optimizations/circular-buffer.js +162 -0
  244. package/dist/src/swarm/optimizations/connection-pool.js +244 -0
  245. package/dist/src/swarm/optimizations/index.js +28 -0
  246. package/dist/src/swarm/optimizations/optimized-executor.js +320 -0
  247. package/dist/src/swarm/optimizations/ttl-map.js +234 -0
  248. package/dist/src/swarm/prompt-cli.js +200 -0
  249. package/dist/src/swarm/prompt-copier-enhanced.js +202 -0
  250. package/dist/src/swarm/prompt-copier.js +381 -0
  251. package/dist/src/swarm/prompt-manager.js +295 -0
  252. package/dist/src/swarm/prompt-utils.js +310 -0
  253. package/dist/src/swarm/result-aggregator.js +718 -0
  254. package/dist/src/swarm/sparc-executor.js +1568 -0
  255. package/dist/src/swarm/strategies/auto.js +758 -0
  256. package/dist/src/swarm/strategies/base.js +128 -0
  257. package/dist/src/swarm/strategies/research.js +914 -0
  258. package/dist/src/swarm/strategies/strategy-metrics-patch.js +2 -0
  259. package/dist/src/swarm/types.js +52 -0
  260. package/dist/src/swarm/workers/copy-worker.js +56 -0
  261. package/dist/src/utils/__tests__/github-cli-safety-wrapper.test.js +332 -400
  262. package/dist/src/utils/github-cli-safe.js +56 -64
  263. package/dist/src/utils/github-cli-safety-wrapper.js +451 -546
  264. package/dist/src/utils/npx-isolated-cache.js +104 -119
  265. package/dist/src/utils/preference-manager.js +622 -652
  266. package/dist/src/utils/timezone-utils.js +86 -105
  267. package/dist/src/validators/epic-config-schema.js +214 -0
  268. package/dist/src/validators/index.js +10 -0
  269. package/dist/src/validators/swarm-init-validator.js +259 -0
  270. package/dist/src/validators/todowrite-batching-validator.js +215 -0
  271. package/dist/src/validators/todowrite-integration.js +187 -0
  272. 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
- async initializeIntegration() {
148
- try {
149
- // Check if MCP tools are available
150
- const mcpAvailable = await this.checkMCPAvailability();
151
- if (!mcpAvailable) {
152
- this.ui.addLog('warning', 'MCP tools not available - using mock implementations');
153
- this.useMockMode = true;
154
- }
155
-
156
- // Initialize tool monitoring
157
- this.startToolMonitoring();
158
-
159
- // Setup event handlers
160
- this.setupEventHandlers();
161
-
162
- this.ui.addLog('success', 'MCP Integration Layer initialized successfully');
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
- async checkMCPAvailability() {
173
- try {
174
- // Try to access a simple MCP tool
175
- const result = await this.executeToolDirect('features_detect', {});
176
- return result && result.success;
177
- } catch (error) {
178
- return false;
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
- async executeTool(toolName, parameters = {}, options = {}) {
186
- const executionId = `exec_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
187
-
188
- try {
189
- // Store execution info
190
- this.activeTools.set(executionId, {
191
- toolName,
192
- parameters,
193
- startTime: Date.now(),
194
- status: 'running',
195
- progress: 0,
196
- });
197
-
198
- // Notify UI of execution start
199
- this.notifyUI('tool_start', { executionId, toolName });
200
-
201
- // Execute with retry logic
202
- const result = await this.executeWithRetry(toolName, parameters, options);
203
-
204
- // Cache successful results
205
- if (result.success) {
206
- this.cacheResult(toolName, parameters, result);
207
- }
208
-
209
- // Update execution status
210
- this.activeTools.set(executionId, {
211
- ...this.activeTools.get(executionId),
212
- status: 'completed',
213
- result,
214
- endTime: Date.now(),
215
- });
216
-
217
- // Notify UI of completion
218
- this.notifyUI('tool_complete', { executionId, toolName, result });
219
-
220
- return { executionId, result };
221
- } catch (error) {
222
- // Update execution status
223
- this.activeTools.set(executionId, {
224
- ...this.activeTools.get(executionId),
225
- status: 'failed',
226
- error: error.message,
227
- endTime: Date.now(),
228
- });
229
-
230
- // Notify UI of error
231
- this.notifyUI('tool_error', { executionId, toolName, error: error.message });
232
-
233
- throw error;
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
- async executeWithRetry(toolName, parameters, options) {
241
- const maxRetries = options.maxRetries || this.maxRetries;
242
- let lastError;
243
-
244
- for (let attempt = 0; attempt <= maxRetries; attempt++) {
245
- try {
246
- if (attempt > 0) {
247
- // Wait before retry
248
- await this.delay(this.retryDelay * Math.pow(2, attempt - 1));
249
- this.ui.addLog('info', `Retrying ${toolName} (attempt ${attempt + 1}/${maxRetries + 1})`);
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
- async executeToolDirect(toolName, parameters) {
272
- if (this.useMockMode) {
273
- return this.executeMockTool(toolName, parameters);
274
- }
275
-
276
- try {
277
- // Use the mcp__claude-flow__ tools that are available
278
- const mcpToolName = `mcp__claude-flow__${toolName}`;
279
-
280
- // Check if we have this tool available (would need to be passed from the calling context)
281
- // For now, simulate execution
282
- return this.executeMockTool(toolName, parameters);
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
- async executeMockTool(toolName, parameters) {
292
- // Simulate processing time
293
- await this.delay(Math.random() * 1000 + 500);
294
-
295
- // Generate realistic mock responses based on tool type
296
- switch (toolName) {
297
- case 'swarm_init':
298
- return {
299
- success: true,
300
- swarmId: `swarm_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
301
- topology: parameters.topology || 'hierarchical',
302
- maxAgents: parameters.maxAgents || 8,
303
- strategy: parameters.strategy || 'auto',
304
- status: 'initialized',
305
- timestamp: new Date().toISOString(),
306
- };
307
-
308
- case 'neural_train':
309
- const epochs = parameters.epochs || 50;
310
- const accuracy = Math.min(0.65 + (epochs / 100) * 0.3 + Math.random() * 0.05, 0.98);
311
- return {
312
- success: true,
313
- modelId: `model_${parameters.pattern_type || 'general'}_${Date.now()}`,
314
- pattern_type: parameters.pattern_type || 'coordination',
315
- epochs,
316
- accuracy,
317
- training_time: 2 + epochs * 0.08,
318
- status: 'completed',
319
- timestamp: new Date().toISOString(),
320
- };
321
-
322
- case 'memory_usage':
323
- if (parameters.action === 'store') {
324
- return {
325
- success: true,
326
- action: 'store',
327
- key: parameters.key,
328
- namespace: parameters.namespace || 'default',
329
- stored: true,
330
- timestamp: new Date().toISOString(),
331
- };
332
- } else if (parameters.action === 'retrieve') {
333
- return {
334
- success: true,
335
- action: 'retrieve',
336
- key: parameters.key,
337
- value: `Mock value for ${parameters.key}`,
338
- namespace: parameters.namespace || 'default',
339
- timestamp: new Date().toISOString(),
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
- async executeToolsParallel(toolExecutions) {
375
- const promises = toolExecutions.map(({ toolName, parameters, options }) =>
376
- this.executeTool(toolName, parameters, options),
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
- async executeToolsBatch(toolExecutions, progressCallback) {
386
- const results = [];
387
- const total = toolExecutions.length;
388
-
389
- for (let i = 0; i < total; i++) {
390
- const { toolName, parameters, options } = toolExecutions[i];
391
-
392
- try {
393
- const result = await this.executeTool(toolName, parameters, options);
394
- results.push({ success: true, result });
395
-
396
- if (progressCallback) {
397
- progressCallback({
398
- completed: i + 1,
399
- total,
400
- progress: ((i + 1) / total) * 100,
401
- currentTool: toolName,
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
- } catch (error) {
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
- cacheResult(toolName, parameters, result) {
416
- const cacheKey = this.generateCacheKey(toolName, parameters);
417
- const ttl = this.getCacheTTL(toolName);
418
-
419
- this.resultCache.set(cacheKey, {
420
- result,
421
- timestamp: Date.now(),
422
- ttl,
423
- });
424
-
425
- // Clean expired cache entries
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
- getCachedResult(toolName, parameters) {
433
- const cacheKey = this.generateCacheKey(toolName, parameters);
434
- const cached = this.resultCache.get(cacheKey);
435
-
436
- if (!cached) return null;
437
-
438
- const age = Date.now() - cached.timestamp;
439
- if (age > cached.ttl) {
440
- this.resultCache.delete(cacheKey);
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
- generateCacheKey(toolName, parameters) {
451
- return `${toolName}_${JSON.stringify(parameters)}`;
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
- getCacheTTL(toolName) {
458
- // Different tools have different cache lifetimes
459
- const ttlMap = {
460
- // Fast changing data - short TTL
461
- swarm_status: 5000,
462
- agent_metrics: 10000,
463
- performance_report: 30000,
464
-
465
- // Slow changing data - medium TTL
466
- memory_usage: 60000,
467
- system_status: 120000,
468
-
469
- // Static data - long TTL
470
- features_detect: 300000,
471
- config_manage: 600000,
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
- cleanExpiredCache() {
481
- const now = Date.now();
482
- for (const [key, cached] of this.resultCache.entries()) {
483
- if (now - cached.timestamp > cached.ttl) {
484
- this.resultCache.delete(key);
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
- getToolsByCategory(category) {
493
- return this.toolCategories[category] || [];
494
- }
495
-
496
- /**
305
+ */ getToolsByCategory(category) {
306
+ return this.toolCategories[category] || [];
307
+ }
308
+ /**
497
309
  * Get all available tool categories
498
- */
499
- getToolCategories() {
500
- return Object.keys(this.toolCategories);
501
- }
502
-
503
- /**
310
+ */ getToolCategories() {
311
+ return Object.keys(this.toolCategories);
312
+ }
313
+ /**
504
314
  * Get tool execution status
505
- */
506
- getExecutionStatus(executionId) {
507
- return this.activeTools.get(executionId);
508
- }
509
-
510
- /**
315
+ */ getExecutionStatus(executionId) {
316
+ return this.activeTools.get(executionId);
317
+ }
318
+ /**
511
319
  * Cancel tool execution
512
- */
513
- async cancelExecution(executionId) {
514
- const execution = this.activeTools.get(executionId);
515
- if (execution && execution.status === 'running') {
516
- execution.status = 'cancelled';
517
- this.notifyUI('tool_cancelled', { executionId });
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
- startToolMonitoring() {
525
- setInterval(() => {
526
- this.updateToolProgress();
527
- this.cleanCompletedExecutions();
528
- }, 1000);
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
- updateToolProgress() {
535
- for (const [executionId, execution] of this.activeTools.entries()) {
536
- if (execution.status === 'running') {
537
- const elapsed = Date.now() - execution.startTime;
538
- // Estimate progress based on elapsed time (simplified)
539
- const estimatedDuration = this.getEstimatedDuration(execution.toolName);
540
- execution.progress = Math.min((elapsed / estimatedDuration) * 100, 95);
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
- getEstimatedDuration(toolName) {
549
- const durationMap = {
550
- neural_train: 30000,
551
- performance_report: 5000,
552
- swarm_init: 2000,
553
- memory_backup: 10000,
554
- };
555
-
556
- return durationMap[toolName] || 3000; // Default 3 seconds
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
- cleanCompletedExecutions() {
563
- const oneHourAgo = Date.now() - 3600000;
564
- for (const [executionId, execution] of this.activeTools.entries()) {
565
- if (execution.endTime && execution.endTime < oneHourAgo) {
566
- this.activeTools.delete(executionId);
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
- setupEventHandlers() {
575
- // Monitor system events that might affect tool execution
576
- if (typeof process !== 'undefined') {
577
- process.on('SIGINT', () => {
578
- this.handleShutdown();
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
- handleShutdown() {
587
- // Cancel all running executions
588
- for (const [executionId, execution] of this.activeTools.entries()) {
589
- if (execution.status === 'running') {
590
- this.cancelExecution(executionId);
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
- notifyUI(eventType, data) {
599
- if (this.ui && typeof this.ui.addLog === 'function') {
600
- const message = this.formatEventMessage(eventType, data);
601
- const level = this.getEventLevel(eventType);
602
- this.ui.addLog(level, message);
603
- }
604
-
605
- // Notify subscribers
606
- for (const callback of this.subscriptions) {
607
- try {
608
- callback(eventType, data);
609
- } catch (error) {
610
- console.error('Error in event subscription:', error);
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
- formatEventMessage(eventType, data) {
619
- switch (eventType) {
620
- case 'tool_start':
621
- return `Started ${data.toolName} (ID: ${data.executionId})`;
622
- case 'tool_complete':
623
- return `Completed ${data.toolName} successfully`;
624
- case 'tool_error':
625
- return `Failed ${data.toolName}: ${data.error}`;
626
- case 'tool_cancelled':
627
- return `Cancelled execution ${data.executionId}`;
628
- default:
629
- return `Event: ${eventType}`;
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
- getEventLevel(eventType) {
637
- switch (eventType) {
638
- case 'tool_complete':
639
- return 'success';
640
- case 'tool_error':
641
- return 'error';
642
- case 'tool_cancelled':
643
- return 'warning';
644
- default:
645
- return 'info';
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
- subscribe(callback) {
653
- this.subscriptions.add(callback);
654
- return () => this.subscriptions.delete(callback);
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
- getStatus() {
661
- const running = Array.from(this.activeTools.values()).filter(
662
- (e) => e.status === 'running',
663
- ).length;
664
- const completed = Array.from(this.activeTools.values()).filter(
665
- (e) => e.status === 'completed',
666
- ).length;
667
- const failed = Array.from(this.activeTools.values()).filter(
668
- (e) => e.status === 'failed',
669
- ).length;
670
-
671
- return {
672
- mcpAvailable: !this.useMockMode,
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
- delay(ms) {
685
- return new Promise((resolve) => setTimeout(resolve, ms));
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;