claude-flow-novice 2.0.4 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (496) hide show
  1. package/dist/src/cli/commands/guidance.js +668 -487
  2. package/dist/src/cli/commands/index-validate.js +29 -18
  3. package/dist/src/cli/commands/mcp-troubleshoot.js +282 -230
  4. package/dist/src/cli/commands/neural-goal-init.js +125 -92
  5. package/dist/src/cli/commands/swarm-exec.js +393 -317
  6. package/dist/src/cli/commands/validate-framework.js +1100 -983
  7. package/dist/src/cli/commands/validate.js +223 -144
  8. package/dist/src/cli/main.js +1 -1
  9. package/dist/src/cli/simple-commands/__tests__/agent.test.js +277 -265
  10. package/dist/src/cli/simple-commands/__tests__/memory.test.js +7 -6
  11. package/dist/src/cli/simple-commands/__tests__/swarm.test.js +356 -373
  12. package/dist/src/cli/simple-commands/__tests__/task.test.js +7 -6
  13. package/dist/src/cli/simple-commands/agent.js +193 -157
  14. package/dist/src/cli/simple-commands/analysis.js +446 -336
  15. package/dist/src/cli/simple-commands/automation-executor.js +1339 -1095
  16. package/dist/src/cli/simple-commands/automation.js +469 -481
  17. package/dist/src/cli/simple-commands/batch-manager.js +313 -261
  18. package/dist/src/cli/simple-commands/claude-telemetry.js +267 -241
  19. package/dist/src/cli/simple-commands/claude-track.js +90 -68
  20. package/dist/src/cli/simple-commands/concurrent-display.js +320 -266
  21. package/dist/src/cli/simple-commands/config.js +290 -245
  22. package/dist/src/cli/simple-commands/coordination.js +234 -182
  23. package/dist/src/cli/simple-commands/enhanced-ui-views.js +615 -812
  24. package/dist/src/cli/simple-commands/enhanced-webui-complete.js +981 -922
  25. package/dist/src/cli/simple-commands/fix-hook-variables.js +294 -274
  26. package/dist/src/cli/simple-commands/github/gh-coordinator.js +457 -378
  27. package/dist/src/cli/simple-commands/github/github-api.js +574 -535
  28. package/dist/src/cli/simple-commands/github/init.js +303 -276
  29. package/dist/src/cli/simple-commands/github.js +247 -222
  30. package/dist/src/cli/simple-commands/goal.js +63 -51
  31. package/dist/src/cli/simple-commands/hive-mind/auto-save-middleware.js +278 -208
  32. package/dist/src/cli/simple-commands/hive-mind/communication.js +696 -601
  33. package/dist/src/cli/simple-commands/hive-mind/core.js +979 -907
  34. package/dist/src/cli/simple-commands/hive-mind/db-optimizer.js +655 -406
  35. package/dist/src/cli/simple-commands/hive-mind/mcp-wrapper.js +1245 -1125
  36. package/dist/src/cli/simple-commands/hive-mind/memory.js +1090 -854
  37. package/dist/src/cli/simple-commands/hive-mind/performance-optimizer.js +574 -459
  38. package/dist/src/cli/simple-commands/hive-mind/performance-test.js +347 -263
  39. package/dist/src/cli/simple-commands/hive-mind/queen.js +768 -727
  40. package/dist/src/cli/simple-commands/hive-mind/session-manager.js +1049 -745
  41. package/dist/src/cli/simple-commands/hive-mind-optimize.js +283 -227
  42. package/dist/src/cli/simple-commands/hive-mind-wizard.js +217 -174
  43. package/dist/src/cli/simple-commands/hive-mind.js +2282 -1841
  44. package/dist/src/cli/simple-commands/hive.js +79 -90
  45. package/dist/src/cli/simple-commands/hook-safety.js +521 -431
  46. package/dist/src/cli/simple-commands/hooks/session-start-soul.js +254 -203
  47. package/dist/src/cli/simple-commands/hooks.js +1204 -1064
  48. package/dist/src/cli/simple-commands/init/agent-copier.js +319 -294
  49. package/dist/src/cli/simple-commands/init/batch-init.js +562 -496
  50. package/dist/src/cli/simple-commands/init/claude-commands/claude-flow-commands.js +19 -13
  51. package/dist/src/cli/simple-commands/init/claude-commands/optimized-claude-flow-commands.js +19 -13
  52. package/dist/src/cli/simple-commands/init/claude-commands/optimized-slash-commands.js +88 -61
  53. package/dist/src/cli/simple-commands/init/claude-commands/optimized-sparc-commands.js +150 -125
  54. package/dist/src/cli/simple-commands/init/claude-commands/slash-commands.js +49 -42
  55. package/dist/src/cli/simple-commands/init/claude-commands/sparc-commands.js +61 -43
  56. package/dist/src/cli/simple-commands/init/copy-revised-templates.js +147 -141
  57. package/dist/src/cli/simple-commands/init/executable-wrapper.js +44 -31
  58. package/dist/src/cli/simple-commands/init/gitignore-updater.js +90 -64
  59. package/dist/src/cli/simple-commands/init/help.js +107 -104
  60. package/dist/src/cli/simple-commands/init/hive-mind-init.js +528 -509
  61. package/dist/src/cli/simple-commands/init/index.js +1759 -1510
  62. package/dist/src/cli/simple-commands/init/performance-monitor.js +317 -234
  63. package/dist/src/cli/simple-commands/init/rollback/backup-manager.js +504 -441
  64. package/dist/src/cli/simple-commands/init/rollback/index.js +364 -289
  65. package/dist/src/cli/simple-commands/init/rollback/recovery-manager.js +728 -652
  66. package/dist/src/cli/simple-commands/init/rollback/rollback-executor.js +481 -416
  67. package/dist/src/cli/simple-commands/init/rollback/state-tracker.js +448 -369
  68. package/dist/src/cli/simple-commands/init/sparc/roo-readme.js +2 -1
  69. package/dist/src/cli/simple-commands/init/sparc/roomodes-config.js +99 -122
  70. package/dist/src/cli/simple-commands/init/sparc/workflows.js +37 -32
  71. package/dist/src/cli/simple-commands/init/sparc-structure.js +62 -55
  72. package/dist/src/cli/simple-commands/init/template-copier.js +533 -421
  73. package/dist/src/cli/simple-commands/init/templates/coordination-md.js +6 -3
  74. package/dist/src/cli/simple-commands/init/templates/enhanced-templates.js +318 -344
  75. package/dist/src/cli/simple-commands/init/templates/github-safe-enhanced.js +218 -173
  76. package/dist/src/cli/simple-commands/init/templates/github-safe.js +75 -65
  77. package/dist/src/cli/simple-commands/init/templates/memory-bank-md.js +6 -3
  78. package/dist/src/cli/simple-commands/init/templates/readme-files.js +4 -2
  79. package/dist/src/cli/simple-commands/init/templates/safe-hook-patterns.js +230 -187
  80. package/dist/src/cli/simple-commands/init/templates/sparc-modes.js +80 -53
  81. package/dist/src/cli/simple-commands/init/templates/verification-claude-md.js +85 -101
  82. package/dist/src/cli/simple-commands/init/validation/config-validator.js +330 -283
  83. package/dist/src/cli/simple-commands/init/validation/health-checker.js +561 -495
  84. package/dist/src/cli/simple-commands/init/validation/index.js +358 -302
  85. package/dist/src/cli/simple-commands/init/validation/mode-validator.js +359 -308
  86. package/dist/src/cli/simple-commands/init/validation/post-init-validator.js +366 -389
  87. package/dist/src/cli/simple-commands/init/validation/pre-init-validator.js +268 -270
  88. package/dist/src/cli/simple-commands/init/validation/test-runner.js +447 -427
  89. package/dist/src/cli/simple-commands/init.js +2 -1
  90. package/dist/src/cli/simple-commands/mcp-health.js +158 -131
  91. package/dist/src/cli/simple-commands/mcp-integration-layer.js +634 -533
  92. package/dist/src/cli/simple-commands/mcp.js +400 -345
  93. package/dist/src/cli/simple-commands/memory-consolidation.js +537 -426
  94. package/dist/src/cli/simple-commands/memory.js +311 -247
  95. package/dist/src/cli/simple-commands/migrate-hooks.js +46 -39
  96. package/dist/src/cli/simple-commands/monitor.js +363 -294
  97. package/dist/src/cli/simple-commands/neural.js +65 -51
  98. package/dist/src/cli/simple-commands/pair-autofix-only.js +662 -538
  99. package/dist/src/cli/simple-commands/pair-basic.js +656 -528
  100. package/dist/src/cli/simple-commands/pair-old.js +543 -430
  101. package/dist/src/cli/simple-commands/pair-working.js +751 -615
  102. package/dist/src/cli/simple-commands/pair.js +751 -615
  103. package/dist/src/cli/simple-commands/performance-hooks.js +111 -83
  104. package/dist/src/cli/simple-commands/performance-metrics.js +433 -348
  105. package/dist/src/cli/simple-commands/process-ui-enhanced.js +787 -708
  106. package/dist/src/cli/simple-commands/process-ui.js +254 -230
  107. package/dist/src/cli/simple-commands/realtime-update-system.js +611 -525
  108. package/dist/src/cli/simple-commands/sparc/architecture.js +1530 -1704
  109. package/dist/src/cli/simple-commands/sparc/commands.js +516 -438
  110. package/dist/src/cli/simple-commands/sparc/completion.js +1481 -1224
  111. package/dist/src/cli/simple-commands/sparc/coordinator.js +978 -913
  112. package/dist/src/cli/simple-commands/sparc/index.js +298 -241
  113. package/dist/src/cli/simple-commands/sparc/phase-base.js +390 -314
  114. package/dist/src/cli/simple-commands/sparc/pseudocode.js +869 -965
  115. package/dist/src/cli/simple-commands/sparc/refinement.js +1273 -980
  116. package/dist/src/cli/simple-commands/sparc/specification.js +645 -559
  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 +55 -47
  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 +87 -101
  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 +493 -465
  137. package/dist/src/cli/simple-commands/start-ui.js +132 -108
  138. package/dist/src/cli/simple-commands/start-wrapper.js +268 -240
  139. package/dist/src/cli/simple-commands/start.js +1 -1
  140. package/dist/src/cli/simple-commands/status.js +275 -254
  141. package/dist/src/cli/simple-commands/stream-chain-clean.js +171 -128
  142. package/dist/src/cli/simple-commands/stream-chain-fixed.js +82 -61
  143. package/dist/src/cli/simple-commands/stream-chain-real.js +331 -267
  144. package/dist/src/cli/simple-commands/stream-chain-working.js +263 -211
  145. package/dist/src/cli/simple-commands/stream-chain.js +318 -260
  146. package/dist/src/cli/simple-commands/stream-processor.js +315 -290
  147. package/dist/src/cli/simple-commands/swarm-executor.js +222 -189
  148. package/dist/src/cli/simple-commands/swarm-metrics-integration.js +300 -208
  149. package/dist/src/cli/simple-commands/swarm-ui.js +703 -623
  150. package/dist/src/cli/simple-commands/swarm-webui-integration.js +286 -258
  151. package/dist/src/cli/simple-commands/swarm.js +1082 -887
  152. package/dist/src/cli/simple-commands/task.js +206 -161
  153. package/dist/src/cli/simple-commands/timestamp-fix.js +89 -59
  154. package/dist/src/cli/simple-commands/token-tracker.js +316 -258
  155. package/dist/src/cli/simple-commands/tool-execution-framework.js +519 -433
  156. package/dist/src/cli/simple-commands/train-and-stream.js +331 -275
  157. package/dist/src/cli/simple-commands/training-pipeline.js +725 -619
  158. package/dist/src/cli/simple-commands/training.js +227 -170
  159. package/dist/src/cli/simple-commands/verification-hooks.js +284 -261
  160. package/dist/src/cli/simple-commands/verification-integration.js +417 -389
  161. package/dist/src/cli/simple-commands/verification-training-integration.js +606 -486
  162. package/dist/src/cli/simple-commands/verification.js +513 -493
  163. package/dist/src/cli/simple-commands/web-server.js +836 -766
  164. package/dist/src/cli/simple-commands/webui-validator.js +124 -106
  165. package/dist/src/coordination/byzantine-memory-channels.js +25 -1
  166. package/dist/src/coordination/event-bus/demo-wasm-integration.js +251 -212
  167. package/dist/src/coordination/event-bus/qe-event-bus.js +748 -608
  168. package/dist/src/coordination/event-bus/qe-event-bus.test.js +454 -379
  169. package/dist/src/coordination/iteration-tracker.js +454 -363
  170. package/dist/src/index.js +384 -35
  171. package/dist/src/mcp/DEPRECATED.js +60 -46
  172. package/dist/src/mcp/fixes/mcp-error-fixes.js +134 -115
  173. package/dist/src/mcp/implementations/agent-tracker.js +128 -114
  174. package/dist/src/mcp/implementations/daa-tools.js +350 -292
  175. package/dist/src/mcp/implementations/workflow-tools.js +361 -329
  176. package/dist/src/mcp/mcp-config-manager.js +1331 -1183
  177. package/dist/src/mcp/mcp-server-novice-simplified.js +17 -11
  178. package/dist/src/mcp/mcp-server-novice.js +17 -11
  179. package/dist/src/mcp/mcp-server-sdk.js +17 -11
  180. package/dist/src/mcp/mcp-server.js +1484 -1620
  181. package/dist/src/mcp/ruv-swarm-wrapper.js +239 -209
  182. package/dist/src/memory/advanced-serializer.js +589 -609
  183. package/dist/src/memory/enhanced-examples.js +305 -220
  184. package/dist/src/memory/enhanced-memory.js +336 -295
  185. package/dist/src/memory/enhanced-session-serializer.js +492 -408
  186. package/dist/src/memory/fallback-memory-system.js +1021 -900
  187. package/dist/src/memory/fallback-store.js +131 -93
  188. package/dist/src/memory/high-performance-serialization.js +730 -592
  189. package/dist/src/memory/in-memory-store.js +213 -161
  190. package/dist/src/memory/index.js +157 -123
  191. package/dist/src/memory/lock-free-structures.js +764 -578
  192. package/dist/src/memory/memory-mapped-persistence.js +766 -585
  193. package/dist/src/memory/memory-pressure-manager.js +707 -569
  194. package/dist/src/memory/migration.js +445 -358
  195. package/dist/src/memory/shared-memory.js +768 -641
  196. package/dist/src/memory/sqlite-store.js +325 -245
  197. package/dist/src/memory/sqlite-wrapper.js +151 -122
  198. package/dist/src/memory/swarm-memory.js +603 -470
  199. package/dist/src/memory/test-example.js +134 -126
  200. package/dist/src/memory/ultra-fast-memory-store.js +821 -622
  201. package/dist/src/memory/unified-memory-manager.js +437 -356
  202. package/dist/src/swarm/CodeRefactoringSwarm.js +952 -777
  203. package/dist/src/utils/__tests__/github-cli-safety-wrapper.test.js +400 -332
  204. package/dist/src/utils/error-handler.js +2 -36
  205. package/dist/src/utils/github-cli-safe.js +64 -56
  206. package/dist/src/utils/github-cli-safety-wrapper.js +546 -451
  207. package/dist/src/utils/npx-isolated-cache.js +119 -104
  208. package/dist/src/utils/preference-manager.js +652 -622
  209. package/dist/src/utils/timezone-utils.js +105 -86
  210. package/dist/src/web/api/apm-routes.js +353 -0
  211. package/dist/src/web/api/config/api-config.js +184 -0
  212. package/dist/src/web/api/middleware/auth.js +203 -0
  213. package/dist/src/web/api/middleware/cache.js +273 -0
  214. package/dist/src/web/api/middleware/error-handler.js +257 -0
  215. package/dist/src/web/api/middleware/request-logger.js +215 -0
  216. package/dist/src/web/api/middleware/validation.js +323 -0
  217. package/dist/src/web/api/routes/events.js +463 -0
  218. package/dist/src/web/api/routes/hierarchy.js +300 -0
  219. package/dist/src/web/api/routes/index.js +12 -0
  220. package/dist/src/web/api/routes/metrics.js +559 -0
  221. package/dist/src/web/api/routes/parallel-status.js +359 -0
  222. package/dist/src/web/api/routes/status.js +448 -0
  223. package/dist/src/web/api/server.js +462 -0
  224. package/dist/src/web/dashboard/hooks/useWebSocket.js +383 -0
  225. package/dist/src/web/dashboard/index.js +85 -0
  226. package/dist/src/web/dashboard/realtime/CustomSyncManager.js +439 -0
  227. package/dist/src/web/dashboard/realtime/NativeWebSocketManager.js +323 -0
  228. package/dist/src/web/dashboard/realtime/PerformanceBenchmark.js +527 -0
  229. package/dist/src/web/dashboard/realtime/RealtimeCommunicationManager.js +474 -0
  230. package/dist/src/web/dashboard/realtime/RealtimeServer.js +666 -0
  231. package/dist/src/web/dashboard/realtime/SSEManager.js +426 -0
  232. package/dist/src/web/dashboard/types.js +4 -0
  233. package/dist/src/web/messaging/agent-status-tracker.js +453 -0
  234. package/dist/src/web/messaging/human-intervention-system.js +305 -0
  235. package/dist/src/web/messaging/message-filter.js +302 -0
  236. package/dist/src/web/messaging/swarm-message-router.js +324 -0
  237. package/dist/src/web/messaging/transparency-logger.js +421 -0
  238. package/dist/src/web/portal-server.js +460 -0
  239. package/dist/src/web/server.js +322 -0
  240. package/dist/src/web/websocket/apm-websocket-handler.js +453 -0
  241. package/dist/src/web/websocket/websocket-manager.js +780 -0
  242. package/package.json +5 -3
  243. package/dist/src/cli/minimal-main.js +0 -22
  244. package/dist/src/enterprise/analytics-manager.js +0 -1135
  245. package/dist/src/enterprise/audit-manager.js +0 -1115
  246. package/dist/src/enterprise/cloud-manager.js +0 -891
  247. package/dist/src/enterprise/deployment-manager.js +0 -966
  248. package/dist/src/enterprise/index.js +0 -6
  249. package/dist/src/enterprise/project-manager.js +0 -584
  250. package/dist/src/enterprise/security-manager.js +0 -991
  251. package/dist/src/migration/index.js +0 -92
  252. package/dist/src/migration/logger.js +0 -121
  253. package/dist/src/migration/migration-analyzer.js +0 -268
  254. package/dist/src/migration/migration-runner.js +0 -522
  255. package/dist/src/migration/migration-validator.js +0 -285
  256. package/dist/src/migration/progress-reporter.js +0 -150
  257. package/dist/src/migration/rollback-manager.js +0 -321
  258. package/dist/src/migration/tests/migration-system.test.js +0 -7
  259. package/dist/src/migration/types.js +0 -3
  260. package/dist/src/swarm/__tests__/integration.test.js +0 -227
  261. package/dist/src/swarm/__tests__/prompt-copier.test.js +0 -344
  262. package/dist/src/swarm/advanced-orchestrator.js +0 -1095
  263. package/dist/src/swarm/claude-code-interface.js +0 -961
  264. package/dist/src/swarm/claude-flow-executor.js +0 -229
  265. package/dist/src/swarm/consensus-coordinator.js +0 -475
  266. package/dist/src/swarm/coordinator.js +0 -2993
  267. package/dist/src/swarm/direct-executor.js +0 -1180
  268. package/dist/src/swarm/error-recovery/advanced-error-detection.js +0 -691
  269. package/dist/src/swarm/error-recovery/automated-recovery-workflows.js +0 -998
  270. package/dist/src/swarm/error-recovery/error-recovery-coordinator.js +0 -1197
  271. package/dist/src/swarm/error-recovery/recovery-monitoring.js +0 -772
  272. package/dist/src/swarm/error-recovery/resilience-architecture.js +0 -714
  273. package/dist/src/swarm/error-recovery/self-healing-mechanisms.js +0 -1319
  274. package/dist/src/swarm/error-recovery/test-error-recovery-effectiveness.js +0 -808
  275. package/dist/src/swarm/executor-v2.js +0 -322
  276. package/dist/src/swarm/executor.js +0 -815
  277. package/dist/src/swarm/hive-mind-integration.js +0 -703
  278. package/dist/src/swarm/index.js +0 -41
  279. package/dist/src/swarm/json-output-aggregator.js +0 -267
  280. package/dist/src/swarm/large-scale-coordinator.js +0 -542
  281. package/dist/src/swarm/mcp-integration-wrapper.js +0 -628
  282. package/dist/src/swarm/memory.js +0 -1117
  283. package/dist/src/swarm/optimizations/__tests__/optimization.test.js +0 -348
  284. package/dist/src/swarm/optimizations/async-file-manager.js +0 -285
  285. package/dist/src/swarm/optimizations/circular-buffer.js +0 -162
  286. package/dist/src/swarm/optimizations/connection-pool.js +0 -244
  287. package/dist/src/swarm/optimizations/index.js +0 -28
  288. package/dist/src/swarm/optimizations/optimized-executor.js +0 -320
  289. package/dist/src/swarm/optimizations/ttl-map.js +0 -234
  290. package/dist/src/swarm/prompt-cli.js +0 -200
  291. package/dist/src/swarm/prompt-copier-enhanced.js +0 -202
  292. package/dist/src/swarm/prompt-copier.js +0 -381
  293. package/dist/src/swarm/prompt-manager.js +0 -295
  294. package/dist/src/swarm/prompt-utils.js +0 -310
  295. package/dist/src/swarm/result-aggregator.js +0 -718
  296. package/dist/src/swarm/sparc-executor.js +0 -1568
  297. package/dist/src/swarm/strategies/auto.js +0 -758
  298. package/dist/src/swarm/strategies/base.js +0 -128
  299. package/dist/src/swarm/strategies/research.js +0 -914
  300. package/dist/src/swarm/strategies/strategy-metrics-patch.js +0 -2
  301. package/dist/src/swarm/types.js +0 -52
  302. package/dist/src/swarm/workers/copy-worker.js +0 -56
  303. package/dist/src/validators/epic-config-schema.js +0 -214
  304. package/dist/src/validators/index.js +0 -10
  305. package/dist/src/validators/swarm-init-validator.js +0 -259
  306. package/dist/src/validators/todowrite-batching-validator.js +0 -215
  307. package/dist/src/validators/todowrite-integration.js +0 -187
  308. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/documentSymbols/browser/documentSymbols.js +0 -23
  309. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/dropOrPasteInto/browser/copyPasteContribution.js +0 -57
  310. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/dropOrPasteInto/browser/copyPasteController.js +0 -401
  311. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/dropOrPasteInto/browser/defaultProviders.js +0 -181
  312. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/dropOrPasteInto/browser/dropIntoEditorContribution.js +0 -44
  313. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/dropOrPasteInto/browser/dropIntoEditorController.js +0 -157
  314. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/dropOrPasteInto/browser/edit.js +0 -71
  315. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/editorState/browser/editorState.js +0 -112
  316. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/find/browser/findController.js +0 -990
  317. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/find/browser/findDecorations.js +0 -296
  318. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/find/browser/findModel.js +0 -488
  319. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/find/browser/findOptionsWidget.js +0 -138
  320. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/find/browser/findState.js +0 -243
  321. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/find/browser/findWidget.js +0 -1177
  322. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/folding/browser/folding.js +0 -1093
  323. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/folding/browser/foldingDecorations.js +0 -133
  324. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/folding/browser/foldingModel.js +0 -538
  325. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/folding/browser/foldingRanges.js +0 -351
  326. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/fontZoom/browser/fontZoom.js +0 -49
  327. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/format/browser/format.js +0 -360
  328. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/format/browser/formatActions.js +0 -263
  329. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/format/browser/formattingEdit.js +0 -54
  330. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/gotoSymbol/browser/link/clickLinkGesture.js +0 -149
  331. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/hover/browser/contentHover.js +0 -874
  332. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/inlineCompletions/browser/commandIds.js +0 -7
  333. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/inlineCompletions/browser/commands.js +0 -199
  334. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/linesOperations/browser/copyLinesCommand.js +0 -70
  335. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/quickAccess/browser/commandsQuickAccess.js +0 -26
  336. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/quickAccess/browser/editorNavigationQuickAccess.js +0 -153
  337. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/readOnlyMessage/browser/contribution.js +0 -33
  338. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/semanticTokens/browser/documentSemanticTokens.js +0 -354
  339. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/smartSelect/browser/bracketSelections.js +0 -146
  340. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/suggest/browser/completionModel.js +0 -224
  341. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/contrib/unicodeHighlighter/browser/bannerController.js +0 -119
  342. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/edcore.main.js +0 -14
  343. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/editor.all.js +0 -63
  344. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/editor.api.js +0 -55
  345. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/editor.main.js +0 -7
  346. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/editor.worker.js +0 -25
  347. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/editor/standalone/browser/colorizer.js +0 -118
  348. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/language/css/css.worker.js +0 -36869
  349. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/language/css/cssMode.js +0 -2035
  350. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/accessibility/browser/accessibilityService.js +0 -88
  351. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/accessibility/common/accessibility.js +0 -9
  352. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/action/common/action.js +0 -7
  353. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/action/common/actionCommonCategories.js +0 -13
  354. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/actionWidget/browser/actionList.js +0 -276
  355. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/actionWidget/browser/actionWidget.js +0 -248
  356. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/actionWidget/common/actionWidget.js +0 -5
  357. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/actions/common/actions.js +0 -409
  358. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/audioCues/browser/audioCueService.js +0 -176
  359. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/clipboard/browser/clipboardService.js +0 -141
  360. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/clipboard/common/clipboardService.js +0 -6
  361. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/commands/common/commands.js +0 -80
  362. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/configuration/common/configuration.js +0 -86
  363. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/configuration/common/configurationModels.js +0 -554
  364. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/configuration/common/configurationRegistry.js +0 -317
  365. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/configuration/common/configurations.js +0 -41
  366. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextkey/browser/contextKeyService.js +0 -432
  367. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextkey/common/contextkey.js +0 -1547
  368. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextkey/common/contextkeys.js +0 -18
  369. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextview/browser/contextMenuHandler.js +0 -124
  370. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextview/browser/contextMenuService.js +0 -101
  371. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextview/browser/contextView.js +0 -7
  372. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/contextview/browser/contextViewService.js +0 -72
  373. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/dialogs/common/dialogs.js +0 -2
  374. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/dnd/browser/dnd.js +0 -36
  375. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/editor/common/editor.js +0 -17
  376. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/environment/common/environment.js +0 -2
  377. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/extensions/common/extensions.js +0 -47
  378. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/files/common/files.js +0 -9
  379. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/history/browser/contextScopedHistoryWidget.js +0 -105
  380. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/instantiation/common/descriptors.js +0 -11
  381. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/instantiation/common/extensions.js +0 -15
  382. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/keybinding/common/abstractKeybindingService.js +0 -277
  383. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/keybinding/common/baseResolvedKeybinding.js +0 -53
  384. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/quickinput/browser/commandsQuickAccess.js +0 -354
  385. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/theme/browser/defaultStyles.js +0 -162
  386. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/esm/vs/platform/theme/common/colorRegistry.js +0 -482
  387. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/abap/abap.js +0 -10
  388. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/apex/apex.js +0 -10
  389. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/azcli/azcli.js +0 -10
  390. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/bat/bat.js +0 -10
  391. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/bicep/bicep.js +0 -11
  392. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/cameligo/cameligo.js +0 -10
  393. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/clojure/clojure.js +0 -10
  394. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/coffee/coffee.js +0 -10
  395. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/cpp/cpp.js +0 -10
  396. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/csharp/csharp.js +0 -10
  397. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/csp/csp.js +0 -10
  398. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/css/css.js +0 -12
  399. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/cypher/cypher.js +0 -10
  400. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/dart/dart.js +0 -10
  401. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/dockerfile/dockerfile.js +0 -10
  402. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/ecl/ecl.js +0 -10
  403. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/elixir/elixir.js +0 -10
  404. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/basic-languages/flow9/flow9.js +0 -10
  405. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.js +0 -745
  406. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.de.js +0 -31
  407. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.es.js +0 -31
  408. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.fr.js +0 -29
  409. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.it.js +0 -29
  410. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.ja.js +0 -31
  411. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.js +0 -29
  412. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.ko.js +0 -29
  413. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.ru.js +0 -31
  414. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.zh-cn.js +0 -31
  415. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/editor/editor.main.nls.zh-tw.js +0 -29
  416. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/language/css/cssMode.js +0 -13
  417. package/dist/src/web/frontend/node_modules/.monaco-editor-MndU045b/min/vs/language/css/cssWorker.js +0 -81
  418. package/dist/src/web/frontend/node_modules/.multicast-dns-iKseM9bB/cli.js +0 -64
  419. package/dist/src/web/frontend/node_modules/.multicast-dns-iKseM9bB/example.js +0 -36
  420. package/dist/src/web/frontend/node_modules/.multicast-dns-iKseM9bB/index.js +0 -205
  421. package/dist/src/web/frontend/node_modules/.multicast-dns-iKseM9bB/test.js +0 -260
  422. package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/async/index.browser.js +0 -34
  423. package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/async/index.js +0 -35
  424. package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/async/index.native.js +0 -26
  425. package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/index.browser.js +0 -34
  426. package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/index.js +0 -45
  427. package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/nanoid.js +0 -1
  428. package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/non-secure/index.js +0 -21
  429. package/dist/src/web/frontend/node_modules/.nanoid-PAMEV9Hd/url-alphabet/index.js +0 -3
  430. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/bin/nodemon.js +0 -16
  431. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/cli/index.js +0 -49
  432. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/cli/parse.js +0 -230
  433. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/config/command.js +0 -43
  434. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/config/defaults.js +0 -34
  435. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/config/exec.js +0 -234
  436. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/config/index.js +0 -93
  437. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/config/load.js +0 -225
  438. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/help/index.js +0 -27
  439. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/index.js +0 -1
  440. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/monitor/index.js +0 -4
  441. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/monitor/match.js +0 -287
  442. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/monitor/run.js +0 -562
  443. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/monitor/signals.js +0 -34
  444. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/monitor/watch.js +0 -244
  445. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/nodemon.js +0 -317
  446. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/rules/add.js +0 -89
  447. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/rules/index.js +0 -53
  448. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/rules/parse.js +0 -43
  449. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/spawn.js +0 -74
  450. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/utils/bus.js +0 -44
  451. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/utils/clone.js +0 -40
  452. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/utils/colour.js +0 -26
  453. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/utils/index.js +0 -103
  454. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/utils/log.js +0 -82
  455. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/utils/merge.js +0 -47
  456. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/lib/version.js +0 -100
  457. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/node_modules/brace-expansion/index.js +0 -201
  458. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/node_modules/has-flag/index.js +0 -8
  459. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/node_modules/minimatch/minimatch.js +0 -947
  460. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/node_modules/supports-color/browser.js +0 -5
  461. package/dist/src/web/frontend/node_modules/.nodemon-QcvNKhKT/node_modules/supports-color/index.js +0 -131
  462. package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/bin/pidtree.js +0 -128
  463. package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/index.js +0 -49
  464. package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/lib/bin.js +0 -61
  465. package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/lib/get.js +0 -45
  466. package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/lib/pidtree.js +0 -104
  467. package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/lib/ps.js +0 -47
  468. package/dist/src/web/frontend/node_modules/.pidtree-icfat3SQ/lib/wmic.js +0 -49
  469. package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/doc.js +0 -1270
  470. package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/acorn.js +0 -15
  471. package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/angular.js +0 -2
  472. package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/babel.js +0 -15
  473. package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/estree.js +0 -36
  474. package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/flow.js +0 -19
  475. package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/glimmer.js +0 -29
  476. package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/graphql.js +0 -29
  477. package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/html.js +0 -22
  478. package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/markdown.js +0 -63
  479. package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/meriyah.js +0 -4
  480. package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/postcss.js +0 -54
  481. package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/typescript.js +0 -20
  482. package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/plugins/yaml.js +0 -160
  483. package/dist/src/web/frontend/node_modules/.prettier-ApZm3b7s/standalone.js +0 -34
  484. package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/bin/react-scripts.js +0 -58
  485. package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/env.js +0 -112
  486. package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/getHttpsConfig.js +0 -74
  487. package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/jest/babelTransform.js +0 -37
  488. package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/jest/cssTransform.js +0 -22
  489. package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/jest/fileTransform.js +0 -40
  490. package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/modules.js +0 -142
  491. package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/paths.js +0 -153
  492. package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/webpack/persistentCache/createEnvironmentHash.js +0 -9
  493. package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/webpack.config.js +0 -796
  494. package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/config/webpackDevServer.config.js +0 -135
  495. package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/scripts/build.js +0 -225
  496. package/dist/src/web/frontend/node_modules/.react-scripts-OTANyoRb/scripts/eject.js +0 -340
@@ -1,188 +1,250 @@
1
1
  /**
2
2
  * Collective Memory System for Hive Mind
3
3
  * Shared knowledge base and learning system
4
- */ import EventEmitter from "events";
5
- import Database from "better-sqlite3";
6
- import path from "path";
7
- import { performance } from "perf_hooks";
4
+ */
5
+
6
+ import EventEmitter from 'events';
7
+ import Database from 'better-sqlite3';
8
+ import path from 'path';
9
+ import { performance } from 'perf_hooks';
10
+ import { Worker } from 'worker_threads';
11
+
8
12
  /**
9
13
  * Memory types and their characteristics
10
- */ const MEMORY_TYPES = {
11
- knowledge: {
12
- priority: 1,
13
- ttl: null,
14
- compress: false
15
- },
16
- context: {
17
- priority: 2,
18
- ttl: 3600000,
19
- compress: false
20
- },
21
- task: {
22
- priority: 3,
23
- ttl: 1800000,
24
- compress: true
25
- },
26
- result: {
27
- priority: 2,
28
- ttl: null,
29
- compress: true
30
- },
31
- error: {
32
- priority: 1,
33
- ttl: 86400000,
34
- compress: false
35
- },
36
- metric: {
37
- priority: 3,
38
- ttl: 3600000,
39
- compress: true
40
- },
41
- consensus: {
42
- priority: 1,
43
- ttl: null,
44
- compress: false
45
- },
46
- system: {
47
- priority: 1,
48
- ttl: null,
49
- compress: false
50
- }
14
+ */
15
+ const MEMORY_TYPES = {
16
+ knowledge: { priority: 1, ttl: null, compress: false },
17
+ context: { priority: 2, ttl: 3600000, compress: false }, // 1 hour
18
+ task: { priority: 3, ttl: 1800000, compress: true }, // 30 minutes
19
+ result: { priority: 2, ttl: null, compress: true },
20
+ error: { priority: 1, ttl: 86400000, compress: false }, // 24 hours
21
+ metric: { priority: 3, ttl: 3600000, compress: true }, // 1 hour
22
+ consensus: { priority: 1, ttl: null, compress: false },
23
+ system: { priority: 1, ttl: null, compress: false },
51
24
  };
25
+
52
26
  /**
53
27
  * Memory Pool for object reuse
54
- */ let MemoryPool = class MemoryPool {
55
- acquire() {
56
- if (this.pool.length > 0) {
57
- this.reused++;
58
- return this.pool.pop();
59
- }
60
- this.allocated++;
61
- return this.createFn();
62
- }
63
- release(obj) {
64
- if (this.pool.length < this.maxSize) {
65
- this.resetFn(obj);
66
- this.pool.push(obj);
67
- }
68
- }
69
- getStats() {
70
- return {
71
- poolSize: this.pool.length,
72
- allocated: this.allocated,
73
- reused: this.reused,
74
- reuseRate: this.reused / (this.allocated + this.reused) * 100
75
- };
28
+ */
29
+ class MemoryPool {
30
+ constructor(createFn, resetFn, maxSize = 1000) {
31
+ this.createFn = createFn;
32
+ this.resetFn = resetFn;
33
+ this.maxSize = maxSize;
34
+ this.pool = [];
35
+ this.allocated = 0;
36
+ this.reused = 0;
37
+ }
38
+
39
+ acquire() {
40
+ if (this.pool.length > 0) {
41
+ this.reused++;
42
+ return this.pool.pop();
76
43
  }
77
- constructor(createFn, resetFn, maxSize = 1000){
78
- this.createFn = createFn;
79
- this.resetFn = resetFn;
80
- this.maxSize = maxSize;
81
- this.pool = [];
82
- this.allocated = 0;
83
- this.reused = 0;
44
+ this.allocated++;
45
+ return this.createFn();
46
+ }
47
+
48
+ release(obj) {
49
+ if (this.pool.length < this.maxSize) {
50
+ this.resetFn(obj);
51
+ this.pool.push(obj);
84
52
  }
85
- };
53
+ }
54
+
55
+ getStats() {
56
+ return {
57
+ poolSize: this.pool.length,
58
+ allocated: this.allocated,
59
+ reused: this.reused,
60
+ reuseRate: (this.reused / (this.allocated + this.reused)) * 100,
61
+ };
62
+ }
63
+ }
64
+
86
65
  /**
87
66
  * Optimized LRU Cache with memory pressure handling
88
- */ let OptimizedLRUCache = class OptimizedLRUCache {
89
- get(key) {
90
- if (this.cache.has(key)) {
91
- const value = this.cache.get(key);
92
- // Move to end (most recently used)
93
- this.cache.delete(key);
94
- this.cache.set(key, value);
95
- this.hits++;
96
- return value.data;
97
- }
98
- this.misses++;
99
- return null;
67
+ */
68
+ class OptimizedLRUCache {
69
+ constructor(maxSize = 1000, maxMemoryMB = 50) {
70
+ this.maxSize = maxSize;
71
+ this.maxMemory = maxMemoryMB * 1024 * 1024;
72
+ this.cache = new Map();
73
+ this.currentMemory = 0;
74
+ this.hits = 0;
75
+ this.misses = 0;
76
+ this.evictions = 0;
77
+ }
78
+
79
+ get(key) {
80
+ if (this.cache.has(key)) {
81
+ const value = this.cache.get(key);
82
+ // Move to end (most recently used)
83
+ this.cache.delete(key);
84
+ this.cache.set(key, value);
85
+ this.hits++;
86
+ return value.data;
100
87
  }
101
- set(key, data) {
102
- const size = this._estimateSize(data);
103
- // Check memory pressure
104
- if (this.currentMemory + size > this.maxMemory) {
105
- this._evictByMemoryPressure(size);
106
- }
107
- // Check size limit
108
- if (this.cache.size >= this.maxSize) {
109
- this._evictLRU();
110
- }
111
- const entry = {
112
- data,
113
- size,
114
- timestamp: Date.now()
115
- };
116
- this.cache.set(key, entry);
117
- this.currentMemory += size;
118
- }
119
- _estimateSize(obj) {
120
- return JSON.stringify(obj).length * 2; // Rough estimate
88
+ this.misses++;
89
+ return null;
90
+ }
91
+
92
+ set(key, data) {
93
+ const size = this._estimateSize(data);
94
+
95
+ // Check memory pressure
96
+ if (this.currentMemory + size > this.maxMemory) {
97
+ this._evictByMemoryPressure(size);
121
98
  }
122
- _evictLRU() {
123
- const firstKey = this.cache.keys().next().value;
124
- if (firstKey) {
125
- const entry = this.cache.get(firstKey);
126
- this.cache.delete(firstKey);
127
- this.currentMemory -= entry.size;
128
- this.evictions++;
129
- }
99
+
100
+ // Check size limit
101
+ if (this.cache.size >= this.maxSize) {
102
+ this._evictLRU();
130
103
  }
131
- _evictByMemoryPressure(neededSize) {
132
- while(this.currentMemory + neededSize > this.maxMemory && this.cache.size > 0){
133
- this._evictLRU();
134
- }
104
+
105
+ const entry = {
106
+ data,
107
+ size,
108
+ timestamp: Date.now(),
109
+ };
110
+
111
+ this.cache.set(key, entry);
112
+ this.currentMemory += size;
113
+ }
114
+
115
+ _estimateSize(obj) {
116
+ return JSON.stringify(obj).length * 2; // Rough estimate
117
+ }
118
+
119
+ _evictLRU() {
120
+ const firstKey = this.cache.keys().next().value;
121
+ if (firstKey) {
122
+ const entry = this.cache.get(firstKey);
123
+ this.cache.delete(firstKey);
124
+ this.currentMemory -= entry.size;
125
+ this.evictions++;
135
126
  }
136
- forEach(callback) {
137
- this.cache.forEach((entry, key)=>{
138
- callback(entry, key);
139
- });
127
+ }
128
+
129
+ _evictByMemoryPressure(neededSize) {
130
+ while (this.currentMemory + neededSize > this.maxMemory && this.cache.size > 0) {
131
+ this._evictLRU();
140
132
  }
141
- delete(key) {
142
- if (this.cache.has(key)) {
143
- const entry = this.cache.get(key);
144
- this.cache.delete(key);
145
- this.currentMemory -= entry.size;
146
- return true;
147
- }
148
- return false;
133
+ }
134
+
135
+ forEach(callback) {
136
+ this.cache.forEach((entry, key) => {
137
+ callback(entry, key);
138
+ });
139
+ }
140
+
141
+ delete(key) {
142
+ if (this.cache.has(key)) {
143
+ const entry = this.cache.get(key);
144
+ this.cache.delete(key);
145
+ this.currentMemory -= entry.size;
146
+ return true;
149
147
  }
150
- getStats() {
151
- return {
152
- size: this.cache.size,
153
- memoryUsage: this.currentMemory,
154
- hitRate: this.hits / (this.hits + this.misses) * 100,
155
- evictions: this.evictions
156
- };
157
- }
158
- constructor(maxSize = 1000, maxMemoryMB = 50){
159
- this.maxSize = maxSize;
160
- this.maxMemory = maxMemoryMB * 1024 * 1024;
161
- this.cache = new Map();
162
- this.currentMemory = 0;
163
- this.hits = 0;
164
- this.misses = 0;
165
- this.evictions = 0;
166
- }
167
- };
148
+ return false;
149
+ }
150
+
151
+ getStats() {
152
+ return {
153
+ size: this.cache.size,
154
+ memoryUsage: this.currentMemory,
155
+ hitRate: (this.hits / (this.hits + this.misses)) * 100,
156
+ evictions: this.evictions,
157
+ };
158
+ }
159
+ }
160
+
168
161
  /**
169
162
  * Optimized CollectiveMemory class with advanced memory management
170
- */ export class CollectiveMemory extends EventEmitter {
171
- /**
163
+ */
164
+ export class CollectiveMemory extends EventEmitter {
165
+ constructor(config = {}) {
166
+ super();
167
+
168
+ /** @type {import('better-sqlite3').Database | null} */
169
+ this.db = null;
170
+
171
+ this.config = {
172
+ swarmId: config.swarmId,
173
+ maxSize: config.maxSize || 100, // MB
174
+ dbPath: config.dbPath || path.join(process.cwd(), '.hive-mind', 'hive.db'),
175
+ compressionThreshold: config.compressionThreshold || 1024, // bytes
176
+ gcInterval: config.gcInterval || 300000, // 5 minutes
177
+ cacheSize: config.cacheSize || 1000,
178
+ cacheMemoryMB: config.cacheMemoryMB || 50,
179
+ enablePooling: config.enablePooling !== false,
180
+ enableAsyncOperations: config.enableAsyncOperations !== false,
181
+ ...config,
182
+ };
183
+
184
+ this.state = {
185
+ totalSize: 0,
186
+ entryCount: 0,
187
+ compressionRatio: 1,
188
+ lastGC: Date.now(),
189
+ accessPatterns: new Map(),
190
+ performanceMetrics: {
191
+ queryTimes: [],
192
+ avgQueryTime: 0,
193
+ cacheHitRate: 0,
194
+ memoryEfficiency: 0,
195
+ },
196
+ };
197
+
198
+ this.gcTimer = null;
199
+
200
+ // Optimized cache with LRU eviction
201
+ this.cache = new OptimizedLRUCache(this.config.cacheSize, this.config.cacheMemoryMB);
202
+
203
+ // Memory pools for frequently created objects
204
+ this.pools = {
205
+ queryResults: new MemoryPool(
206
+ () => ({ results: [], metadata: {} }),
207
+ (obj) => {
208
+ obj.results.length = 0;
209
+ Object.keys(obj.metadata).forEach((k) => delete obj.metadata[k]);
210
+ },
211
+ ),
212
+ memoryEntries: new MemoryPool(
213
+ () => ({ id: '', key: '', value: '', metadata: {} }),
214
+ (obj) => {
215
+ obj.id = obj.key = obj.value = '';
216
+ Object.keys(obj.metadata).forEach((k) => delete obj.metadata[k]);
217
+ },
218
+ ),
219
+ };
220
+
221
+ // Prepared statements for better performance
222
+ this.statements = new Map();
223
+
224
+ // Background worker for heavy operations
225
+ this.backgroundWorker = null;
226
+
227
+ this._initialize();
228
+ }
229
+
230
+ /**
172
231
  * Initialize collective memory with optimizations
173
- */ _initialize() {
174
- try {
175
- // Open database connection with optimizations
176
- this.db = new Database(this.config.dbPath);
177
- // Performance optimizations
178
- this.db.pragma('journal_mode = WAL');
179
- this.db.pragma('synchronous = NORMAL');
180
- this.db.pragma('cache_size = -64000'); // 64MB cache
181
- this.db.pragma('temp_store = MEMORY');
182
- this.db.pragma('mmap_size = 268435456'); // 256MB memory mapping
183
- this.db.pragma('optimize');
184
- // Ensure table exists with optimized schema
185
- this.db.exec(`
232
+ */
233
+ _initialize() {
234
+ try {
235
+ // Open database connection with optimizations
236
+ this.db = new Database(this.config.dbPath);
237
+
238
+ // Performance optimizations
239
+ this.db.pragma('journal_mode = WAL');
240
+ this.db.pragma('synchronous = NORMAL');
241
+ this.db.pragma('cache_size = -64000'); // 64MB cache
242
+ this.db.pragma('temp_store = MEMORY');
243
+ this.db.pragma('mmap_size = 268435456'); // 256MB memory mapping
244
+ this.db.pragma('optimize');
245
+
246
+ // Ensure table exists with optimized schema
247
+ this.db.exec(`
186
248
  CREATE TABLE IF NOT EXISTS collective_memory (
187
249
  id TEXT PRIMARY KEY,
188
250
  swarm_id TEXT NOT NULL,
@@ -221,61 +283,90 @@ import { performance } from "perf_hooks";
221
283
  FROM collective_memory
222
284
  GROUP BY swarm_id, type;
223
285
  `);
224
- // Prepare optimized statements
225
- this._prepareStatements();
226
- // Load initial statistics
227
- this._updateStatistics();
228
- // Start background optimization processes
229
- this._startOptimizationTimers();
230
- // Initialize background worker for heavy operations
231
- if (this.config.enableAsyncOperations) {
232
- this._initializeBackgroundWorker();
233
- }
234
- this.emit('memory:initialized', {
235
- swarmId: this.config.swarmId,
236
- optimizations: {
237
- pooling: this.config.enablePooling,
238
- asyncOps: this.config.enableAsyncOperations,
239
- cacheSize: this.config.cacheSize
240
- }
241
- });
242
- } catch (error) {
243
- this.emit('error', error);
244
- throw error;
245
- }
286
+
287
+ // Prepare optimized statements
288
+ this._prepareStatements();
289
+
290
+ // Load initial statistics
291
+ this._updateStatistics();
292
+
293
+ // Start background optimization processes
294
+ this._startOptimizationTimers();
295
+
296
+ // Initialize background worker for heavy operations
297
+ if (this.config.enableAsyncOperations) {
298
+ this._initializeBackgroundWorker();
299
+ }
300
+
301
+ this.emit('memory:initialized', {
302
+ swarmId: this.config.swarmId,
303
+ optimizations: {
304
+ pooling: this.config.enablePooling,
305
+ asyncOps: this.config.enableAsyncOperations,
306
+ cacheSize: this.config.cacheSize,
307
+ },
308
+ });
309
+ } catch (error) {
310
+ this.emit('error', error);
311
+ throw error;
246
312
  }
247
- /**
313
+ }
314
+
315
+ /**
248
316
  * Prepare optimized SQL statements
249
- */ _prepareStatements() {
250
- this.statements.set('insert', this.db.prepare(`
317
+ */
318
+ _prepareStatements() {
319
+ this.statements.set(
320
+ 'insert',
321
+ this.db.prepare(`
251
322
  INSERT OR REPLACE INTO collective_memory
252
323
  (id, swarm_id, key, value, type, confidence, created_by, compressed, size)
253
324
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
254
- `));
255
- this.statements.set('update', this.db.prepare(`
325
+ `),
326
+ );
327
+
328
+ this.statements.set(
329
+ 'update',
330
+ this.db.prepare(`
256
331
  UPDATE collective_memory
257
332
  SET value = ?, accessed_at = strftime('%s','now'), access_count = access_count + 1,
258
333
  compressed = ?, size = ?
259
334
  WHERE swarm_id = ? AND key = ?
260
- `));
261
- this.statements.set('select', this.db.prepare(`
335
+ `),
336
+ );
337
+
338
+ this.statements.set(
339
+ 'select',
340
+ this.db.prepare(`
262
341
  SELECT value, type, compressed, confidence, access_count
263
342
  FROM collective_memory
264
343
  WHERE swarm_id = ? AND key = ?
265
- `));
266
- this.statements.set('updateAccess', this.db.prepare(`
344
+ `),
345
+ );
346
+
347
+ this.statements.set(
348
+ 'updateAccess',
349
+ this.db.prepare(`
267
350
  UPDATE collective_memory
268
351
  SET accessed_at = strftime('%s','now'), access_count = access_count + 1
269
352
  WHERE swarm_id = ? AND key = ?
270
- `));
271
- this.statements.set('searchByPattern', this.db.prepare(`
353
+ `),
354
+ );
355
+
356
+ this.statements.set(
357
+ 'searchByPattern',
358
+ this.db.prepare(`
272
359
  SELECT key, type, confidence, created_at, accessed_at, access_count
273
360
  FROM collective_memory
274
361
  WHERE swarm_id = ? AND key LIKE ? AND confidence >= ?
275
362
  ORDER BY access_count DESC, confidence DESC
276
363
  LIMIT ?
277
- `));
278
- this.statements.set('getStats', this.db.prepare(`
364
+ `),
365
+ );
366
+
367
+ this.statements.set(
368
+ 'getStats',
369
+ this.db.prepare(`
279
370
  SELECT
280
371
  COUNT(*) as count,
281
372
  SUM(size) as totalSize,
@@ -284,191 +375,270 @@ import { performance } from "perf_hooks";
284
375
  AVG(access_count) as avgAccess
285
376
  FROM collective_memory
286
377
  WHERE swarm_id = ?
287
- `));
288
- this.statements.set('deleteExpired', this.db.prepare(`
378
+ `),
379
+ );
380
+
381
+ this.statements.set(
382
+ 'deleteExpired',
383
+ this.db.prepare(`
289
384
  DELETE FROM collective_memory
290
385
  WHERE swarm_id = ? AND type = ? AND (strftime('%s','now') - accessed_at) > ?
291
- `));
292
- this.statements.set('getLRU', this.db.prepare(`
386
+ `),
387
+ );
388
+
389
+ this.statements.set(
390
+ 'getLRU',
391
+ this.db.prepare(`
293
392
  SELECT id, size FROM collective_memory
294
393
  WHERE swarm_id = ? AND type NOT IN ('system', 'consensus')
295
394
  ORDER BY accessed_at ASC, access_count ASC
296
395
  LIMIT ?
297
- `));
298
- }
299
- /**
396
+ `),
397
+ );
398
+ }
399
+
400
+ /**
300
401
  * Start optimization timers
301
- */ _startOptimizationTimers() {
302
- // Main garbage collection
303
- this.gcTimer = setInterval(()=>this._garbageCollect(), this.config.gcInterval);
304
- // Database optimization
305
- this.optimizeTimer = setInterval(()=>this._optimizeDatabase(), 1800000); // 30 minutes
306
- // Cache cleanup
307
- this.cacheTimer = setInterval(()=>this._optimizeCache(), 60000); // 1 minute
308
- // Performance monitoring
309
- this.metricsTimer = setInterval(()=>this._updatePerformanceMetrics(), 30000); // 30 seconds
310
- }
311
- /**
402
+ */
403
+ _startOptimizationTimers() {
404
+ // Main garbage collection
405
+ this.gcTimer = setInterval(() => this._garbageCollect(), this.config.gcInterval);
406
+
407
+ // Database optimization
408
+ this.optimizeTimer = setInterval(() => this._optimizeDatabase(), 1800000); // 30 minutes
409
+
410
+ // Cache cleanup
411
+ this.cacheTimer = setInterval(() => this._optimizeCache(), 60000); // 1 minute
412
+
413
+ // Performance monitoring
414
+ this.metricsTimer = setInterval(() => this._updatePerformanceMetrics(), 30000); // 30 seconds
415
+ }
416
+
417
+ /**
312
418
  * Initialize background worker for heavy operations
313
- */ _initializeBackgroundWorker() {
314
- // Note: In production, this would initialize a proper Worker
315
- // For now, we'll use async operations
316
- this.backgroundQueue = [];
317
- this.backgroundProcessing = false;
318
- }
319
- /**
419
+ */
420
+ _initializeBackgroundWorker() {
421
+ // Note: In production, this would initialize a proper Worker
422
+ // For now, we'll use async operations
423
+ this.backgroundQueue = [];
424
+ this.backgroundProcessing = false;
425
+ }
426
+
427
+ /**
320
428
  * Store data in collective memory
321
- */ async store(key, value, type = 'knowledge', metadata = {}) {
322
- try {
323
- const serialized = JSON.stringify(value);
324
- const size = Buffer.byteLength(serialized);
325
- const shouldCompress = size > this.config.compressionThreshold && MEMORY_TYPES[type]?.compress;
326
- let storedValue = serialized;
327
- let compressed = 0;
328
- if (shouldCompress) {
329
- // In production, use proper compression like zlib
330
- // For now, we'll just mark it as compressed
331
- compressed = 1;
332
- }
333
- const id = `${this.config.swarmId}-${key}-${Date.now()}`;
334
- // Check if key already exists
335
- const existing = this.db.prepare(`
429
+ */
430
+ async store(key, value, type = 'knowledge', metadata = {}) {
431
+ try {
432
+ const serialized = JSON.stringify(value);
433
+ const size = Buffer.byteLength(serialized);
434
+ const shouldCompress =
435
+ size > this.config.compressionThreshold && MEMORY_TYPES[type]?.compress;
436
+
437
+ let storedValue = serialized;
438
+ let compressed = 0;
439
+
440
+ if (shouldCompress) {
441
+ // In production, use proper compression like zlib
442
+ // For now, we'll just mark it as compressed
443
+ compressed = 1;
444
+ }
445
+
446
+ const id = `${this.config.swarmId}-${key}-${Date.now()}`;
447
+
448
+ // Check if key already exists
449
+ const existing = this.db
450
+ .prepare(
451
+ `
336
452
  SELECT id FROM collective_memory
337
453
  WHERE swarm_id = ? AND key = ?
338
- `).get(this.config.swarmId, key);
339
- if (existing) {
340
- // Update existing entry
341
- this.db.prepare(`
454
+ `,
455
+ )
456
+ .get(this.config.swarmId, key);
457
+
458
+ if (existing) {
459
+ // Update existing entry
460
+ this.db
461
+ .prepare(
462
+ `
342
463
  UPDATE collective_memory
343
464
  SET value = ?, type = ?, confidence = ?,
344
465
  accessed_at = CURRENT_TIMESTAMP, access_count = access_count + 1,
345
466
  compressed = ?, size = ?
346
467
  WHERE swarm_id = ? AND key = ?
347
- `).run(storedValue, type, metadata.confidence || 1.0, compressed, size, this.config.swarmId, key);
348
- } else {
349
- // Insert new entry
350
- this.db.prepare(`
468
+ `,
469
+ )
470
+ .run(
471
+ storedValue,
472
+ type,
473
+ metadata.confidence || 1.0,
474
+ compressed,
475
+ size,
476
+ this.config.swarmId,
477
+ key,
478
+ );
479
+ } else {
480
+ // Insert new entry
481
+ this.db
482
+ .prepare(
483
+ `
351
484
  INSERT INTO collective_memory
352
485
  (id, swarm_id, key, value, type, confidence, created_by, compressed, size)
353
486
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
354
- `).run(id, this.config.swarmId, key, storedValue, type, metadata.confidence || 1.0, metadata.createdBy || 'system', compressed, size);
355
- }
356
- // Update cache
357
- this.cache.set(key, {
358
- value,
359
- type,
360
- timestamp: Date.now(),
361
- size
362
- });
363
- // Check memory limits
364
- this._checkMemoryLimits();
365
- // Track access pattern
366
- this._trackAccess(key, 'write');
367
- this.emit('memory:stored', {
368
- key,
369
- type,
370
- size
371
- });
372
- return {
373
- success: true,
374
- id,
375
- size
376
- };
377
- } catch (error) {
378
- this.emit('error', error);
379
- throw error;
380
- }
487
+ `,
488
+ )
489
+ .run(
490
+ id,
491
+ this.config.swarmId,
492
+ key,
493
+ storedValue,
494
+ type,
495
+ metadata.confidence || 1.0,
496
+ metadata.createdBy || 'system',
497
+ compressed,
498
+ size,
499
+ );
500
+ }
501
+
502
+ // Update cache
503
+ this.cache.set(key, {
504
+ value,
505
+ type,
506
+ timestamp: Date.now(),
507
+ size,
508
+ });
509
+
510
+ // Check memory limits
511
+ this._checkMemoryLimits();
512
+
513
+ // Track access pattern
514
+ this._trackAccess(key, 'write');
515
+
516
+ this.emit('memory:stored', { key, type, size });
517
+
518
+ return { success: true, id, size };
519
+ } catch (error) {
520
+ this.emit('error', error);
521
+ throw error;
381
522
  }
382
- /**
523
+ }
524
+
525
+ /**
383
526
  * Retrieve data from collective memory
384
- */ async retrieve(key) {
385
- try {
386
- // Check cache first
387
- if (this.cache.has(key)) {
388
- const cached = this.cache.get(key);
389
- this._trackAccess(key, 'cache_hit');
390
- return cached.value;
391
- }
392
- // Query database
393
- const result = this.db.prepare(`
527
+ */
528
+ async retrieve(key) {
529
+ try {
530
+ // Check cache first
531
+ if (this.cache.has(key)) {
532
+ const cached = this.cache.get(key);
533
+ this._trackAccess(key, 'cache_hit');
534
+ return cached.value;
535
+ }
536
+
537
+ // Query database
538
+ const result = this.db
539
+ .prepare(
540
+ `
394
541
  SELECT value, type, compressed, confidence
395
542
  FROM collective_memory
396
543
  WHERE swarm_id = ? AND key = ?
397
- `).get(this.config.swarmId, key);
398
- if (!result) {
399
- this._trackAccess(key, 'miss');
400
- return null;
401
- }
402
- // Update access statistics
403
- this.db.prepare(`
544
+ `,
545
+ )
546
+ .get(this.config.swarmId, key);
547
+
548
+ if (!result) {
549
+ this._trackAccess(key, 'miss');
550
+ return null;
551
+ }
552
+
553
+ // Update access statistics
554
+ this.db
555
+ .prepare(
556
+ `
404
557
  UPDATE collective_memory
405
558
  SET accessed_at = CURRENT_TIMESTAMP,
406
559
  access_count = access_count + 1
407
560
  WHERE swarm_id = ? AND key = ?
408
- `).run(this.config.swarmId, key);
409
- // Decompress if needed
410
- let value = result.value;
411
- if (result.compressed) {
412
- // In production, decompress here
413
- }
414
- // Parse JSON
415
- const parsed = JSON.parse(value);
416
- // Add to cache
417
- this.cache.set(key, {
418
- value: parsed,
419
- type: result.type,
420
- timestamp: Date.now(),
421
- confidence: result.confidence
422
- });
423
- this._trackAccess(key, 'read');
424
- return parsed;
425
- } catch (error) {
426
- this.emit('error', error);
427
- throw error;
428
- }
561
+ `,
562
+ )
563
+ .run(this.config.swarmId, key);
564
+
565
+ // Decompress if needed
566
+ let value = result.value;
567
+ if (result.compressed) {
568
+ // In production, decompress here
569
+ }
570
+
571
+ // Parse JSON
572
+ const parsed = JSON.parse(value);
573
+
574
+ // Add to cache
575
+ this.cache.set(key, {
576
+ value: parsed,
577
+ type: result.type,
578
+ timestamp: Date.now(),
579
+ confidence: result.confidence,
580
+ });
581
+
582
+ this._trackAccess(key, 'read');
583
+
584
+ return parsed;
585
+ } catch (error) {
586
+ this.emit('error', error);
587
+ throw error;
429
588
  }
430
- /**
589
+ }
590
+
591
+ /**
431
592
  * Search collective memory
432
- */ async search(pattern, options = {}) {
433
- try {
434
- const limit = options.limit || 50;
435
- const type = options.type || null;
436
- const minConfidence = options.minConfidence || 0;
437
- let query = `
593
+ */
594
+ async search(pattern, options = {}) {
595
+ try {
596
+ const limit = options.limit || 50;
597
+ const type = options.type || null;
598
+ const minConfidence = options.minConfidence || 0;
599
+
600
+ let query = `
438
601
  SELECT key, type, confidence, created_at, accessed_at, access_count
439
602
  FROM collective_memory
440
603
  WHERE swarm_id = ?
441
604
  AND key LIKE ?
442
605
  AND confidence >= ?
443
606
  `;
444
- const params = [
445
- this.config.swarmId,
446
- `%${pattern}%`,
447
- minConfidence
448
- ];
449
- if (type) {
450
- query += ' AND type = ?';
451
- params.push(type);
452
- }
453
- query += ' ORDER BY access_count DESC, confidence DESC LIMIT ?';
454
- params.push(limit);
455
- const results = this.db.prepare(query).all(...params);
456
- this._trackAccess(`search:${pattern}`, 'search');
457
- return results;
458
- } catch (error) {
459
- this.emit('error', error);
460
- throw error;
461
- }
607
+
608
+ const params = [this.config.swarmId, `%${pattern}%`, minConfidence];
609
+
610
+ if (type) {
611
+ query += ' AND type = ?';
612
+ params.push(type);
613
+ }
614
+
615
+ query += ' ORDER BY access_count DESC, confidence DESC LIMIT ?';
616
+ params.push(limit);
617
+
618
+ const results = this.db.prepare(query).all(...params);
619
+
620
+ this._trackAccess(`search:${pattern}`, 'search');
621
+
622
+ return results;
623
+ } catch (error) {
624
+ this.emit('error', error);
625
+ throw error;
462
626
  }
463
- /**
627
+ }
628
+
629
+ /**
464
630
  * Get related memories using association
465
- */ async getRelated(key, limit = 10) {
466
- try {
467
- // Get the original memory
468
- const original = await this.retrieve(key);
469
- if (!original) return [];
470
- // Simple association: find memories accessed around the same time
471
- const result = this.db.prepare(`
631
+ */
632
+ async getRelated(key, limit = 10) {
633
+ try {
634
+ // Get the original memory
635
+ const original = await this.retrieve(key);
636
+ if (!original) return [];
637
+
638
+ // Simple association: find memories accessed around the same time
639
+ const result = this.db
640
+ .prepare(
641
+ `
472
642
  SELECT m1.key, m1.type, m1.confidence, m1.access_count
473
643
  FROM collective_memory m1
474
644
  JOIN collective_memory m2 ON m1.swarm_id = m2.swarm_id
@@ -478,250 +648,315 @@ import { performance } from "perf_hooks";
478
648
  AND ABS(julianday(m1.accessed_at) - julianday(m2.accessed_at)) < 0.01
479
649
  ORDER BY m1.confidence DESC, m1.access_count DESC
480
650
  LIMIT ?
481
- `).all(key, key, this.config.swarmId, limit);
482
- return result;
483
- } catch (error) {
484
- this.emit('error', error);
485
- throw error;
486
- }
651
+ `,
652
+ )
653
+ .all(key, key, this.config.swarmId, limit);
654
+
655
+ return result;
656
+ } catch (error) {
657
+ this.emit('error', error);
658
+ throw error;
487
659
  }
488
- /**
660
+ }
661
+
662
+ /**
489
663
  * Build associations between memories
490
- */ async associate(key1, key2, strength = 1.0) {
491
- try {
492
- // Store bidirectional association
493
- await this.store(`assoc:${key1}:${key2}`, {
494
- from: key1,
495
- to: key2,
496
- strength,
497
- created: Date.now()
498
- }, 'system');
499
- await this.store(`assoc:${key2}:${key1}`, {
500
- from: key2,
501
- to: key1,
502
- strength,
503
- created: Date.now()
504
- }, 'system');
505
- this.emit('memory:associated', {
506
- key1,
507
- key2,
508
- strength
509
- });
510
- } catch (error) {
511
- this.emit('error', error);
512
- throw error;
513
- }
664
+ */
665
+ async associate(key1, key2, strength = 1.0) {
666
+ try {
667
+ // Store bidirectional association
668
+ await this.store(
669
+ `assoc:${key1}:${key2}`,
670
+ {
671
+ from: key1,
672
+ to: key2,
673
+ strength,
674
+ created: Date.now(),
675
+ },
676
+ 'system',
677
+ );
678
+
679
+ await this.store(
680
+ `assoc:${key2}:${key1}`,
681
+ {
682
+ from: key2,
683
+ to: key1,
684
+ strength,
685
+ created: Date.now(),
686
+ },
687
+ 'system',
688
+ );
689
+
690
+ this.emit('memory:associated', { key1, key2, strength });
691
+ } catch (error) {
692
+ this.emit('error', error);
693
+ throw error;
514
694
  }
515
- /**
695
+ }
696
+
697
+ /**
516
698
  * Consolidate similar memories
517
- */ async consolidate() {
518
- try {
519
- // Find similar memories
520
- const memories = this.db.prepare(`
699
+ */
700
+ async consolidate() {
701
+ try {
702
+ // Find similar memories
703
+ const memories = this.db
704
+ .prepare(
705
+ `
521
706
  SELECT key, value, type, confidence, access_count
522
707
  FROM collective_memory
523
708
  WHERE swarm_id = ?
524
709
  AND type IN ('knowledge', 'result')
525
710
  ORDER BY created_at DESC
526
711
  LIMIT 1000
527
- `).all(this.config.swarmId);
528
- const consolidated = new Map();
529
- // Group by similarity (simple implementation)
530
- memories.forEach((memory)=>{
531
- const value = JSON.parse(memory.value);
532
- const category = this._categorizeMemory(value);
533
- if (!consolidated.has(category)) {
534
- consolidated.set(category, []);
535
- }
536
- consolidated.get(category).push({
537
- ...memory,
538
- value
539
- });
540
- });
541
- // Merge similar memories
542
- let mergeCount = 0;
543
- consolidated.forEach((group, category)=>{
544
- if (group.length > 1) {
545
- const merged = this._mergeMemories(group);
546
- // Store merged memory
547
- this.store(`consolidated:${category}`, merged, 'knowledge', {
548
- confidence: merged.confidence,
549
- createdBy: 'consolidation'
550
- });
551
- mergeCount++;
552
- }
553
- });
554
- this.emit('memory:consolidated', {
555
- categories: consolidated.size,
556
- merged: mergeCount
557
- });
558
- return {
559
- categories: consolidated.size,
560
- merged: mergeCount
561
- };
562
- } catch (error) {
563
- this.emit('error', error);
564
- throw error;
712
+ `,
713
+ )
714
+ .all(this.config.swarmId);
715
+
716
+ const consolidated = new Map();
717
+
718
+ // Group by similarity (simple implementation)
719
+ memories.forEach((memory) => {
720
+ const value = JSON.parse(memory.value);
721
+ const category = this._categorizeMemory(value);
722
+
723
+ if (!consolidated.has(category)) {
724
+ consolidated.set(category, []);
565
725
  }
726
+
727
+ consolidated.get(category).push({
728
+ ...memory,
729
+ value,
730
+ });
731
+ });
732
+
733
+ // Merge similar memories
734
+ let mergeCount = 0;
735
+ consolidated.forEach((group, category) => {
736
+ if (group.length > 1) {
737
+ const merged = this._mergeMemories(group);
738
+
739
+ // Store merged memory
740
+ this.store(`consolidated:${category}`, merged, 'knowledge', {
741
+ confidence: merged.confidence,
742
+ createdBy: 'consolidation',
743
+ });
744
+
745
+ mergeCount++;
746
+ }
747
+ });
748
+
749
+ this.emit('memory:consolidated', { categories: consolidated.size, merged: mergeCount });
750
+
751
+ return { categories: consolidated.size, merged: mergeCount };
752
+ } catch (error) {
753
+ this.emit('error', error);
754
+ throw error;
566
755
  }
567
- /**
756
+ }
757
+
758
+ /**
568
759
  * Categorize memory for consolidation
569
- */ _categorizeMemory(value) {
570
- // Simple categorization based on content
571
- if (typeof value === 'string') {
572
- return 'text';
573
- }
574
- if (typeof value === 'object') {
575
- const keys = Object.keys(value).sort().join(':');
576
- return `object:${keys.substring(0, 50)}`;
577
- }
578
- return 'other';
760
+ */
761
+ _categorizeMemory(value) {
762
+ // Simple categorization based on content
763
+ if (typeof value === 'string') {
764
+ return 'text';
579
765
  }
580
- /**
581
- * Merge similar memories
582
- */ _mergeMemories(memories) {
583
- // Calculate weighted average confidence
584
- let totalWeight = 0;
585
- let weightedConfidence = 0;
586
- const mergedValue = {};
587
- memories.forEach((memory)=>{
588
- const weight = memory.access_count + 1;
589
- totalWeight += weight;
590
- weightedConfidence += memory.confidence * weight;
591
- // Merge values (simple implementation)
592
- if (typeof memory.value === 'object') {
593
- Object.assign(mergedValue, memory.value);
594
- }
595
- });
596
- return {
597
- value: mergedValue,
598
- confidence: weightedConfidence / totalWeight,
599
- sourceCount: memories.length
600
- };
766
+
767
+ if (typeof value === 'object') {
768
+ const keys = Object.keys(value).sort().join(':');
769
+ return `object:${keys.substring(0, 50)}`;
601
770
  }
602
- /**
771
+
772
+ return 'other';
773
+ }
774
+
775
+ /**
776
+ * Merge similar memories
777
+ */
778
+ _mergeMemories(memories) {
779
+ // Calculate weighted average confidence
780
+ let totalWeight = 0;
781
+ let weightedConfidence = 0;
782
+ const mergedValue = {};
783
+
784
+ memories.forEach((memory) => {
785
+ const weight = memory.access_count + 1;
786
+ totalWeight += weight;
787
+ weightedConfidence += memory.confidence * weight;
788
+
789
+ // Merge values (simple implementation)
790
+ if (typeof memory.value === 'object') {
791
+ Object.assign(mergedValue, memory.value);
792
+ }
793
+ });
794
+
795
+ return {
796
+ value: mergedValue,
797
+ confidence: weightedConfidence / totalWeight,
798
+ sourceCount: memories.length,
799
+ };
800
+ }
801
+
802
+ /**
603
803
  * Garbage collection
604
- */ _garbageCollect() {
605
- try {
606
- const now = Date.now();
607
- let deletedCount = 0;
608
- // Delete expired memories based on TTL
609
- Object.entries(MEMORY_TYPES).forEach(([type, config])=>{
610
- if (config.ttl) {
611
- const result = this.db.prepare(`
804
+ */
805
+ _garbageCollect() {
806
+ try {
807
+ const now = Date.now();
808
+ let deletedCount = 0;
809
+
810
+ // Delete expired memories based on TTL
811
+ Object.entries(MEMORY_TYPES).forEach(([type, config]) => {
812
+ if (config.ttl) {
813
+ const result = this.db
814
+ .prepare(
815
+ `
612
816
  DELETE FROM collective_memory
613
817
  WHERE swarm_id = ?
614
818
  AND type = ?
615
819
  AND (julianday('now') - julianday(accessed_at)) * 86400000 > ?
616
- `).run(this.config.swarmId, type, config.ttl);
617
- deletedCount += result.changes;
618
- }
619
- });
620
- // Clear old cache entries
621
- const cacheTimeout = 300000; // 5 minutes
622
- this.cache.forEach((value, key)=>{
623
- if (now - value.timestamp > cacheTimeout) {
624
- this.cache.delete(key);
625
- }
626
- });
627
- // Update statistics
628
- this._updateStatistics();
629
- this.state.lastGC = now;
630
- if (deletedCount > 0) {
631
- this.emit('memory:gc', {
632
- deleted: deletedCount,
633
- cacheSize: this.cache.size
634
- });
635
- }
636
- } catch (error) {
637
- this.emit('error', error);
820
+ `,
821
+ )
822
+ .run(this.config.swarmId, type, config.ttl);
823
+
824
+ deletedCount += result.changes;
638
825
  }
826
+ });
827
+
828
+ // Clear old cache entries
829
+ const cacheTimeout = 300000; // 5 minutes
830
+ this.cache.forEach((value, key) => {
831
+ if (now - value.timestamp > cacheTimeout) {
832
+ this.cache.delete(key);
833
+ }
834
+ });
835
+
836
+ // Update statistics
837
+ this._updateStatistics();
838
+
839
+ this.state.lastGC = now;
840
+
841
+ if (deletedCount > 0) {
842
+ this.emit('memory:gc', { deleted: deletedCount, cacheSize: this.cache.size });
843
+ }
844
+ } catch (error) {
845
+ this.emit('error', error);
639
846
  }
640
- /**
847
+ }
848
+
849
+ /**
641
850
  * Check memory limits and evict if necessary
642
- */ _checkMemoryLimits() {
643
- if (this.state.totalSize > this.config.maxSize * 1024 * 1024) {
644
- // Evict least recently used memories
645
- const toEvict = this.db.prepare(`
851
+ */
852
+ _checkMemoryLimits() {
853
+ if (this.state.totalSize > this.config.maxSize * 1024 * 1024) {
854
+ // Evict least recently used memories
855
+ const toEvict = this.db
856
+ .prepare(
857
+ `
646
858
  SELECT id, size FROM collective_memory
647
859
  WHERE swarm_id = ?
648
860
  AND type NOT IN ('system', 'consensus')
649
861
  ORDER BY accessed_at ASC, access_count ASC
650
862
  LIMIT 100
651
- `).all(this.config.swarmId);
652
- let freedSize = 0;
653
- toEvict.forEach((memory)=>{
654
- this.db.prepare('DELETE FROM collective_memory WHERE id = ?').run(memory.id);
655
- freedSize += memory.size;
656
- });
657
- this.emit('memory:evicted', {
658
- count: toEvict.length,
659
- freedSize
660
- });
661
- }
863
+ `,
864
+ )
865
+ .all(this.config.swarmId);
866
+
867
+ let freedSize = 0;
868
+ toEvict.forEach((memory) => {
869
+ this.db.prepare('DELETE FROM collective_memory WHERE id = ?').run(memory.id);
870
+ freedSize += memory.size;
871
+ });
872
+
873
+ this.emit('memory:evicted', { count: toEvict.length, freedSize });
662
874
  }
663
- /**
875
+ }
876
+
877
+ /**
664
878
  * Optimize database performance
665
- */ _optimizeDatabase() {
666
- try {
667
- // Run database optimization
668
- this.db.pragma('optimize');
669
- this.db.pragma('analysis_limit=1000');
670
- this.db.exec('ANALYZE');
671
- // Update database statistics
672
- this._updateStatistics();
673
- this.emit('database:optimized');
674
- } catch (error) {
675
- this.emit('error', error);
676
- }
879
+ */
880
+ _optimizeDatabase() {
881
+ try {
882
+ // Run database optimization
883
+ this.db.pragma('optimize');
884
+ this.db.pragma('analysis_limit=1000');
885
+ this.db.exec('ANALYZE');
886
+
887
+ // Update database statistics
888
+ this._updateStatistics();
889
+
890
+ this.emit('database:optimized');
891
+ } catch (error) {
892
+ this.emit('error', error);
677
893
  }
678
- /**
894
+ }
895
+
896
+ /**
679
897
  * Optimize cache performance
680
- */ _optimizeCache() {
681
- try {
682
- const now = Date.now();
683
- const cacheTimeout = 300000; // 5 minutes
684
- // Clear expired cache entries
685
- if (this.cache.cache) {
686
- this.cache.cache.forEach((value, key)=>{
687
- if (now - value.timestamp > cacheTimeout) {
688
- this.cache.cache.delete(key);
689
- }
690
- });
691
- }
692
- this.emit('cache:optimized', {
693
- size: this.cache.cache ? this.cache.cache.size : 0
694
- });
695
- } catch (error) {
696
- this.emit('error', error);
697
- }
898
+ */
899
+ _optimizeCache() {
900
+ try {
901
+ const now = Date.now();
902
+ const cacheTimeout = 300000; // 5 minutes
903
+
904
+ // Clear expired cache entries
905
+ if (this.cache.cache) {
906
+ this.cache.cache.forEach((value, key) => {
907
+ if (now - value.timestamp > cacheTimeout) {
908
+ this.cache.cache.delete(key);
909
+ }
910
+ });
911
+ }
912
+
913
+ this.emit('cache:optimized', {
914
+ size: this.cache.cache ? this.cache.cache.size : 0,
915
+ });
916
+ } catch (error) {
917
+ this.emit('error', error);
698
918
  }
699
- /**
919
+ }
920
+
921
+ /**
700
922
  * Update performance metrics
701
- */ _updatePerformanceMetrics() {
702
- try {
703
- // Calculate cache hit rate
704
- const cacheStats = this.cache.getStats();
705
- this.state.performanceMetrics.cacheHitRate = cacheStats.hitRate || 0;
706
- // Calculate memory efficiency
707
- this.state.performanceMetrics.memoryEfficiency = this.state.totalSize / (this.config.maxSize * 1024 * 1024) * 100;
708
- // Update average query time if we have recent measurements
709
- if (this.state.performanceMetrics.queryTimes.length > 0) {
710
- this.state.performanceMetrics.avgQueryTime = this.state.performanceMetrics.queryTimes.reduce((sum, time)=>sum + time, 0) / this.state.performanceMetrics.queryTimes.length;
711
- // Keep only recent query times (last 100)
712
- if (this.state.performanceMetrics.queryTimes.length > 100) {
713
- this.state.performanceMetrics.queryTimes = this.state.performanceMetrics.queryTimes.slice(-100);
714
- }
715
- }
716
- this.emit('metrics:updated', this.state.performanceMetrics);
717
- } catch (error) {
718
- this.emit('error', error);
923
+ */
924
+ _updatePerformanceMetrics() {
925
+ try {
926
+ // Calculate cache hit rate
927
+ const cacheStats = this.cache.getStats();
928
+ this.state.performanceMetrics.cacheHitRate = cacheStats.hitRate || 0;
929
+
930
+ // Calculate memory efficiency
931
+ this.state.performanceMetrics.memoryEfficiency =
932
+ (this.state.totalSize / (this.config.maxSize * 1024 * 1024)) * 100;
933
+
934
+ // Update average query time if we have recent measurements
935
+ if (this.state.performanceMetrics.queryTimes.length > 0) {
936
+ this.state.performanceMetrics.avgQueryTime =
937
+ this.state.performanceMetrics.queryTimes.reduce((sum, time) => sum + time, 0) /
938
+ this.state.performanceMetrics.queryTimes.length;
939
+
940
+ // Keep only recent query times (last 100)
941
+ if (this.state.performanceMetrics.queryTimes.length > 100) {
942
+ this.state.performanceMetrics.queryTimes =
943
+ this.state.performanceMetrics.queryTimes.slice(-100);
719
944
  }
945
+ }
946
+
947
+ this.emit('metrics:updated', this.state.performanceMetrics);
948
+ } catch (error) {
949
+ this.emit('error', error);
720
950
  }
721
- /**
951
+ }
952
+
953
+ /**
722
954
  * Update memory statistics
723
- */ _updateStatistics() {
724
- const stats = this.db.prepare(`
955
+ */
956
+ _updateStatistics() {
957
+ const stats = this.db
958
+ .prepare(
959
+ `
725
960
  SELECT
726
961
  COUNT(*) as count,
727
962
  SUM(size) as totalSize,
@@ -729,328 +964,329 @@ import { performance } from "perf_hooks";
729
964
  SUM(compressed) as compressedCount
730
965
  FROM collective_memory
731
966
  WHERE swarm_id = ?
732
- `).get(this.config.swarmId);
733
- this.state.entryCount = stats.count || 0;
734
- this.state.totalSize = stats.totalSize || 0;
735
- this.state.avgConfidence = stats.avgConfidence || 1.0;
736
- if (stats.compressedCount > 0) {
737
- // Estimate compression ratio
738
- this.state.compressionRatio = 0.6; // Assume 40% compression
739
- }
967
+ `,
968
+ )
969
+ .get(this.config.swarmId);
970
+
971
+ this.state.entryCount = stats.count || 0;
972
+ this.state.totalSize = stats.totalSize || 0;
973
+ this.state.avgConfidence = stats.avgConfidence || 1.0;
974
+
975
+ if (stats.compressedCount > 0) {
976
+ // Estimate compression ratio
977
+ this.state.compressionRatio = 0.6; // Assume 40% compression
740
978
  }
741
- /**
979
+ }
980
+
981
+ /**
742
982
  * Track access patterns
743
- */ _trackAccess(key, operation) {
744
- const pattern = this.state.accessPatterns.get(key) || {
745
- reads: 0,
746
- writes: 0,
747
- searches: 0,
748
- cacheHits: 0,
749
- misses: 0,
750
- lastAccess: Date.now()
751
- };
752
- switch(operation){
753
- case 'read':
754
- pattern.reads++;
755
- break;
756
- case 'write':
757
- pattern.writes++;
758
- break;
759
- case 'search':
760
- pattern.searches++;
761
- break;
762
- case 'cache_hit':
763
- pattern.cacheHits++;
764
- break;
765
- case 'miss':
766
- pattern.misses++;
767
- break;
768
- }
769
- pattern.lastAccess = Date.now();
770
- this.state.accessPatterns.set(key, pattern);
771
- // Keep access patterns size limited
772
- if (this.state.accessPatterns.size > 1000) {
773
- // Remove oldest entries
774
- const sorted = Array.from(this.state.accessPatterns.entries()).sort((a, b)=>a[1].lastAccess - b[1].lastAccess);
775
- sorted.slice(0, 100).forEach(([key])=>{
776
- this.state.accessPatterns.delete(key);
777
- });
778
- }
983
+ */
984
+ _trackAccess(key, operation) {
985
+ const pattern = this.state.accessPatterns.get(key) || {
986
+ reads: 0,
987
+ writes: 0,
988
+ searches: 0,
989
+ cacheHits: 0,
990
+ misses: 0,
991
+ lastAccess: Date.now(),
992
+ };
993
+
994
+ switch (operation) {
995
+ case 'read':
996
+ pattern.reads++;
997
+ break;
998
+ case 'write':
999
+ pattern.writes++;
1000
+ break;
1001
+ case 'search':
1002
+ pattern.searches++;
1003
+ break;
1004
+ case 'cache_hit':
1005
+ pattern.cacheHits++;
1006
+ break;
1007
+ case 'miss':
1008
+ pattern.misses++;
1009
+ break;
779
1010
  }
780
- /**
781
- * Get enhanced memory statistics
782
- */ getStatistics() {
783
- return {
784
- swarmId: this.config.swarmId,
785
- entryCount: this.state.entryCount,
786
- totalSize: this.state.totalSize,
787
- maxSize: this.config.maxSize * 1024 * 1024,
788
- utilizationPercent: this.state.totalSize / (this.config.maxSize * 1024 * 1024) * 100,
789
- avgConfidence: this.state.avgConfidence,
790
- compressionRatio: this.state.compressionRatio,
791
- cacheSize: this.cache.cache ? this.cache.cache.size : 0,
792
- lastGC: new Date(this.state.lastGC).toISOString(),
793
- accessPatterns: this.state.accessPatterns.size,
794
- optimization: {
795
- cacheOptimized: true,
796
- poolingEnabled: this.config.enablePooling,
797
- asyncOperations: this.config.enableAsyncOperations,
798
- compressionRatio: this.state.compressionRatio,
799
- performanceMetrics: this.state.performanceMetrics
800
- }
801
- };
1011
+
1012
+ pattern.lastAccess = Date.now();
1013
+ this.state.accessPatterns.set(key, pattern);
1014
+
1015
+ // Keep access patterns size limited
1016
+ if (this.state.accessPatterns.size > 1000) {
1017
+ // Remove oldest entries
1018
+ const sorted = Array.from(this.state.accessPatterns.entries()).sort(
1019
+ (a, b) => a[1].lastAccess - b[1].lastAccess,
1020
+ );
1021
+
1022
+ sorted.slice(0, 100).forEach(([key]) => {
1023
+ this.state.accessPatterns.delete(key);
1024
+ });
802
1025
  }
803
- /**
1026
+ }
1027
+
1028
+ /**
1029
+ * Get enhanced memory statistics
1030
+ */
1031
+ getStatistics() {
1032
+ return {
1033
+ swarmId: this.config.swarmId,
1034
+ entryCount: this.state.entryCount,
1035
+ totalSize: this.state.totalSize,
1036
+ maxSize: this.config.maxSize * 1024 * 1024,
1037
+ utilizationPercent: (this.state.totalSize / (this.config.maxSize * 1024 * 1024)) * 100,
1038
+ avgConfidence: this.state.avgConfidence,
1039
+ compressionRatio: this.state.compressionRatio,
1040
+ cacheSize: this.cache.cache ? this.cache.cache.size : 0,
1041
+ lastGC: new Date(this.state.lastGC).toISOString(),
1042
+ accessPatterns: this.state.accessPatterns.size,
1043
+ optimization: {
1044
+ cacheOptimized: true,
1045
+ poolingEnabled: this.config.enablePooling,
1046
+ asyncOperations: this.config.enableAsyncOperations,
1047
+ compressionRatio: this.state.compressionRatio,
1048
+ performanceMetrics: this.state.performanceMetrics,
1049
+ },
1050
+ };
1051
+ }
1052
+
1053
+ /**
804
1054
  * Export memory snapshot
805
- */ async exportSnapshot(filepath) {
806
- try {
807
- const memories = this.db.prepare(`
1055
+ */
1056
+ async exportSnapshot(filepath) {
1057
+ try {
1058
+ const memories = this.db
1059
+ .prepare(
1060
+ `
808
1061
  SELECT * FROM collective_memory
809
1062
  WHERE swarm_id = ?
810
1063
  ORDER BY created_at DESC
811
- `).all(this.config.swarmId);
812
- const snapshot = {
813
- swarmId: this.config.swarmId,
814
- timestamp: new Date().toISOString(),
815
- statistics: this.getStatistics(),
816
- memories: memories.map((m)=>({
817
- ...m,
818
- value: JSON.parse(m.value)
819
- }))
820
- };
821
- // In production, write to file
822
- // For now, return the snapshot
823
- this.emit('memory:exported', {
824
- count: memories.length
825
- });
826
- return snapshot;
827
- } catch (error) {
828
- this.emit('error', error);
829
- throw error;
830
- }
1064
+ `,
1065
+ )
1066
+ .all(this.config.swarmId);
1067
+
1068
+ const snapshot = {
1069
+ swarmId: this.config.swarmId,
1070
+ timestamp: new Date().toISOString(),
1071
+ statistics: this.getStatistics(),
1072
+ memories: memories.map((m) => ({
1073
+ ...m,
1074
+ value: JSON.parse(m.value),
1075
+ })),
1076
+ };
1077
+
1078
+ // In production, write to file
1079
+ // For now, return the snapshot
1080
+ this.emit('memory:exported', { count: memories.length });
1081
+
1082
+ return snapshot;
1083
+ } catch (error) {
1084
+ this.emit('error', error);
1085
+ throw error;
831
1086
  }
832
- /**
1087
+ }
1088
+
1089
+ /**
833
1090
  * Import memory snapshot
834
- */ async importSnapshot(snapshot) {
835
- try {
836
- let imported = 0;
837
- for (const memory of snapshot.memories){
838
- await this.store(memory.key, memory.value, memory.type, {
839
- confidence: memory.confidence,
840
- createdBy: memory.created_by
841
- });
842
- imported++;
843
- }
844
- this.emit('memory:imported', {
845
- count: imported
846
- });
847
- return {
848
- imported
849
- };
850
- } catch (error) {
851
- this.emit('error', error);
852
- throw error;
853
- }
1091
+ */
1092
+ async importSnapshot(snapshot) {
1093
+ try {
1094
+ let imported = 0;
1095
+
1096
+ for (const memory of snapshot.memories) {
1097
+ await this.store(memory.key, memory.value, memory.type, {
1098
+ confidence: memory.confidence,
1099
+ createdBy: memory.created_by,
1100
+ });
1101
+ imported++;
1102
+ }
1103
+
1104
+ this.emit('memory:imported', { count: imported });
1105
+
1106
+ return { imported };
1107
+ } catch (error) {
1108
+ this.emit('error', error);
1109
+ throw error;
854
1110
  }
855
- /**
1111
+ }
1112
+
1113
+ /**
856
1114
  * Enhanced shutdown with cleanup
857
- */ close() {
858
- // Clear all timers
859
- if (this.gcTimer) clearInterval(this.gcTimer);
860
- if (this.optimizeTimer) clearInterval(this.optimizeTimer);
861
- if (this.cacheTimer) clearInterval(this.cacheTimer);
862
- if (this.metricsTimer) clearInterval(this.metricsTimer);
863
- // Final optimization before closing
864
- try {
865
- this.db.pragma('optimize');
866
- } catch (error) {
867
- // Ignore errors during shutdown
868
- }
869
- // Close database
870
- if (this.db) {
871
- this.db.close();
872
- }
873
- // Clear memory pools
874
- if (this.config.enablePooling) {
875
- Object.values(this.pools).forEach((pool)=>{
876
- pool.pool.length = 0;
877
- });
878
- }
879
- const finalStats = {
880
- cacheStats: this.cache.getStats ? this.cache.getStats() : {},
881
- poolStats: this.config.enablePooling ? {
882
- queryResults: this.pools.queryResults.getStats(),
883
- memoryEntries: this.pools.memoryEntries.getStats()
884
- } : null,
885
- performanceMetrics: this.state.performanceMetrics
886
- };
887
- this.emit('memory:closed', finalStats);
1115
+ */
1116
+ close() {
1117
+ // Clear all timers
1118
+ if (this.gcTimer) clearInterval(this.gcTimer);
1119
+ if (this.optimizeTimer) clearInterval(this.optimizeTimer);
1120
+ if (this.cacheTimer) clearInterval(this.cacheTimer);
1121
+ if (this.metricsTimer) clearInterval(this.metricsTimer);
1122
+
1123
+ // Final optimization before closing
1124
+ try {
1125
+ this.db.pragma('optimize');
1126
+ } catch (error) {
1127
+ // Ignore errors during shutdown
888
1128
  }
889
- /**
890
- * Get comprehensive memory analytics
891
- */ getAnalytics() {
892
- return {
893
- basic: this.getStatistics(),
894
- performance: this.state.performanceMetrics,
895
- cache: this.cache.getStats ? this.cache.getStats() : {},
896
- pools: this.config.enablePooling ? {
897
- queryResults: this.pools.queryResults.getStats(),
898
- memoryEntries: this.pools.memoryEntries.getStats()
899
- } : null,
900
- database: {
901
- fragmentation: this.db.pragma('freelist_count'),
902
- pageSize: this.db.pragma('page_size'),
903
- cacheSize: this.db.pragma('cache_size')
904
- }
905
- };
1129
+
1130
+ // Close database
1131
+ if (this.db) {
1132
+ this.db.close();
1133
+ }
1134
+
1135
+ // Clear memory pools
1136
+ if (this.config.enablePooling) {
1137
+ Object.values(this.pools).forEach((pool) => {
1138
+ pool.pool.length = 0;
1139
+ });
906
1140
  }
907
- /**
1141
+
1142
+ const finalStats = {
1143
+ cacheStats: this.cache.getStats ? this.cache.getStats() : {},
1144
+ poolStats: this.config.enablePooling
1145
+ ? {
1146
+ queryResults: this.pools.queryResults.getStats(),
1147
+ memoryEntries: this.pools.memoryEntries.getStats(),
1148
+ }
1149
+ : null,
1150
+ performanceMetrics: this.state.performanceMetrics,
1151
+ };
1152
+
1153
+ this.emit('memory:closed', finalStats);
1154
+ }
1155
+
1156
+ /**
1157
+ * Get comprehensive memory analytics
1158
+ */
1159
+ getAnalytics() {
1160
+ return {
1161
+ basic: this.getStatistics(),
1162
+ performance: this.state.performanceMetrics,
1163
+ cache: this.cache.getStats ? this.cache.getStats() : {},
1164
+ pools: this.config.enablePooling
1165
+ ? {
1166
+ queryResults: this.pools.queryResults.getStats(),
1167
+ memoryEntries: this.pools.memoryEntries.getStats(),
1168
+ }
1169
+ : null,
1170
+ database: {
1171
+ fragmentation: this.db.pragma('freelist_count'),
1172
+ pageSize: this.db.pragma('page_size'),
1173
+ cacheSize: this.db.pragma('cache_size'),
1174
+ },
1175
+ };
1176
+ }
1177
+
1178
+ /**
908
1179
  * Memory health check
909
- */ async healthCheck() {
910
- const analytics = this.getAnalytics();
911
- const health = {
912
- status: 'healthy',
913
- issues: [],
914
- recommendations: []
915
- };
916
- // Check cache hit rate
917
- if (analytics.cache.hitRate < 50) {
918
- health.issues.push('Low cache hit rate');
919
- health.recommendations.push('Consider increasing cache size');
920
- }
921
- // Check memory usage
922
- if (analytics.basic.utilizationPercent > 90) {
923
- health.status = 'warning';
924
- health.issues.push('High memory utilization');
925
- health.recommendations.push('Consider increasing max memory or running garbage collection');
926
- }
927
- // Check query performance
928
- if (analytics.performance.avgQueryTime > 100) {
929
- health.issues.push('Slow query performance');
930
- health.recommendations.push('Consider database optimization or indexing');
931
- }
932
- return health;
1180
+ */
1181
+ async healthCheck() {
1182
+ const analytics = this.getAnalytics();
1183
+ const health = {
1184
+ status: 'healthy',
1185
+ issues: [],
1186
+ recommendations: [],
1187
+ };
1188
+
1189
+ // Check cache hit rate
1190
+ if (analytics.cache.hitRate < 50) {
1191
+ health.issues.push('Low cache hit rate');
1192
+ health.recommendations.push('Consider increasing cache size');
933
1193
  }
934
- constructor(config = {}){
935
- super();
936
- /** @type {import('better-sqlite3').Database | null} */ this.db = null;
937
- this.config = {
938
- swarmId: config.swarmId,
939
- maxSize: config.maxSize || 100,
940
- dbPath: config.dbPath || path.join(process.cwd(), '.hive-mind', 'hive.db'),
941
- compressionThreshold: config.compressionThreshold || 1024,
942
- gcInterval: config.gcInterval || 300000,
943
- cacheSize: config.cacheSize || 1000,
944
- cacheMemoryMB: config.cacheMemoryMB || 50,
945
- enablePooling: config.enablePooling !== false,
946
- enableAsyncOperations: config.enableAsyncOperations !== false,
947
- ...config
948
- };
949
- this.state = {
950
- totalSize: 0,
951
- entryCount: 0,
952
- compressionRatio: 1,
953
- lastGC: Date.now(),
954
- accessPatterns: new Map(),
955
- performanceMetrics: {
956
- queryTimes: [],
957
- avgQueryTime: 0,
958
- cacheHitRate: 0,
959
- memoryEfficiency: 0
960
- }
961
- };
962
- this.gcTimer = null;
963
- // Optimized cache with LRU eviction
964
- this.cache = new OptimizedLRUCache(this.config.cacheSize, this.config.cacheMemoryMB);
965
- // Memory pools for frequently created objects
966
- this.pools = {
967
- queryResults: new MemoryPool(()=>({
968
- results: [],
969
- metadata: {}
970
- }), (obj)=>{
971
- obj.results.length = 0;
972
- Object.keys(obj.metadata).forEach((k)=>delete obj.metadata[k]);
973
- }),
974
- memoryEntries: new MemoryPool(()=>({
975
- id: '',
976
- key: '',
977
- value: '',
978
- metadata: {}
979
- }), (obj)=>{
980
- obj.id = obj.key = obj.value = '';
981
- Object.keys(obj.metadata).forEach((k)=>delete obj.metadata[k]);
982
- })
983
- };
984
- // Prepared statements for better performance
985
- this.statements = new Map();
986
- // Background worker for heavy operations
987
- this.backgroundWorker = null;
988
- this._initialize();
1194
+
1195
+ // Check memory usage
1196
+ if (analytics.basic.utilizationPercent > 90) {
1197
+ health.status = 'warning';
1198
+ health.issues.push('High memory utilization');
1199
+ health.recommendations.push('Consider increasing max memory or running garbage collection');
989
1200
  }
1201
+
1202
+ // Check query performance
1203
+ if (analytics.performance.avgQueryTime > 100) {
1204
+ health.issues.push('Slow query performance');
1205
+ health.recommendations.push('Consider database optimization or indexing');
1206
+ }
1207
+
1208
+ return health;
1209
+ }
990
1210
  }
1211
+
991
1212
  /**
992
1213
  * Memory optimization utilities
993
- */ export class MemoryOptimizer {
994
- static async optimizeCollectiveMemory(memory) {
995
- const startTime = performance.now();
996
- // Run comprehensive optimization
997
- await memory._optimizeDatabase();
998
- memory._optimizeCache();
999
- memory._garbageCollect();
1000
- const duration = performance.now() - startTime;
1001
- return {
1002
- duration,
1003
- analytics: memory.getAnalytics(),
1004
- health: await memory.healthCheck()
1005
- };
1214
+ */
1215
+ export class MemoryOptimizer {
1216
+ static async optimizeCollectiveMemory(memory) {
1217
+ const startTime = performance.now();
1218
+
1219
+ // Run comprehensive optimization
1220
+ await memory._optimizeDatabase();
1221
+ memory._optimizeCache();
1222
+ memory._garbageCollect();
1223
+
1224
+ const duration = performance.now() - startTime;
1225
+
1226
+ return {
1227
+ duration,
1228
+ analytics: memory.getAnalytics(),
1229
+ health: await memory.healthCheck(),
1230
+ };
1231
+ }
1232
+
1233
+ static calculateOptimalCacheSize(memoryStats, accessPatterns) {
1234
+ const avgEntrySize = memoryStats.totalSize / memoryStats.entryCount;
1235
+ const hotKeys = Array.from(accessPatterns.entries())
1236
+ .sort((a, b) => b[1] - a[1])
1237
+ .slice(0, Math.min(1000, memoryStats.entryCount * 0.2));
1238
+
1239
+ const optimalCacheEntries = hotKeys.length * 1.2; // 20% buffer
1240
+ const optimalCacheMemoryMB = (optimalCacheEntries * avgEntrySize) / (1024 * 1024);
1241
+
1242
+ return {
1243
+ entries: Math.ceil(optimalCacheEntries),
1244
+ memoryMB: Math.ceil(optimalCacheMemoryMB),
1245
+ efficiency: (hotKeys.length / memoryStats.entryCount) * 100,
1246
+ };
1247
+ }
1248
+
1249
+ static generateOptimizationReport(analytics) {
1250
+ const report = {
1251
+ timestamp: new Date().toISOString(),
1252
+ summary: {},
1253
+ recommendations: [],
1254
+ metrics: analytics,
1255
+ };
1256
+
1257
+ // Performance summary
1258
+ report.summary.avgQueryTime = analytics.performance.avgQueryTime;
1259
+ report.summary.cacheHitRate = analytics.cache.hitRate || 0;
1260
+ report.summary.memoryEfficiency = analytics.cache.memoryUsage / (1024 * 1024);
1261
+
1262
+ // Generate recommendations
1263
+ if ((analytics.cache.hitRate || 0) < 70) {
1264
+ report.recommendations.push({
1265
+ type: 'cache',
1266
+ priority: 'high',
1267
+ description: 'Increase cache size to improve hit rate',
1268
+ impact: 'Reduce database queries by up to 30%',
1269
+ });
1006
1270
  }
1007
- static calculateOptimalCacheSize(memoryStats, accessPatterns) {
1008
- const avgEntrySize = memoryStats.totalSize / memoryStats.entryCount;
1009
- const hotKeys = Array.from(accessPatterns.entries()).sort((a, b)=>b[1] - a[1]).slice(0, Math.min(1000, memoryStats.entryCount * 0.2));
1010
- const optimalCacheEntries = hotKeys.length * 1.2; // 20% buffer
1011
- const optimalCacheMemoryMB = optimalCacheEntries * avgEntrySize / (1024 * 1024);
1012
- return {
1013
- entries: Math.ceil(optimalCacheEntries),
1014
- memoryMB: Math.ceil(optimalCacheMemoryMB),
1015
- efficiency: hotKeys.length / memoryStats.entryCount * 100
1016
- };
1271
+
1272
+ if (analytics.performance.avgQueryTime > 50) {
1273
+ report.recommendations.push({
1274
+ type: 'database',
1275
+ priority: 'medium',
1276
+ description: 'Optimize database indexes and run ANALYZE',
1277
+ impact: 'Improve query performance by 20-40%',
1278
+ });
1017
1279
  }
1018
- static generateOptimizationReport(analytics) {
1019
- const report = {
1020
- timestamp: new Date().toISOString(),
1021
- summary: {},
1022
- recommendations: [],
1023
- metrics: analytics
1024
- };
1025
- // Performance summary
1026
- report.summary.avgQueryTime = analytics.performance.avgQueryTime;
1027
- report.summary.cacheHitRate = analytics.cache.hitRate || 0;
1028
- report.summary.memoryEfficiency = analytics.cache.memoryUsage / (1024 * 1024);
1029
- // Generate recommendations
1030
- if ((analytics.cache.hitRate || 0) < 70) {
1031
- report.recommendations.push({
1032
- type: 'cache',
1033
- priority: 'high',
1034
- description: 'Increase cache size to improve hit rate',
1035
- impact: 'Reduce database queries by up to 30%'
1036
- });
1037
- }
1038
- if (analytics.performance.avgQueryTime > 50) {
1039
- report.recommendations.push({
1040
- type: 'database',
1041
- priority: 'medium',
1042
- description: 'Optimize database indexes and run ANALYZE',
1043
- impact: 'Improve query performance by 20-40%'
1044
- });
1045
- }
1046
- if (analytics.pools?.queryResults?.reuseRate < 50) {
1047
- report.recommendations.push({
1048
- type: 'pooling',
1049
- priority: 'low',
1050
- description: 'Increase object pool sizes for better reuse',
1051
- impact: 'Reduce garbage collection pressure'
1052
- });
1053
- }
1054
- return report;
1280
+
1281
+ if (analytics.pools?.queryResults?.reuseRate < 50) {
1282
+ report.recommendations.push({
1283
+ type: 'pooling',
1284
+ priority: 'low',
1285
+ description: 'Increase object pool sizes for better reuse',
1286
+ impact: 'Reduce garbage collection pressure',
1287
+ });
1055
1288
  }
1289
+
1290
+ return report;
1291
+ }
1056
1292
  }