agentic-qe 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (863) hide show
  1. package/.claude/agents/qe-api-contract-validator.md +51 -11
  2. package/.claude/agents/qe-chaos-engineer.md +95 -43
  3. package/.claude/agents/qe-coverage-analyzer.md +134 -57
  4. package/.claude/agents/qe-deployment-readiness.md +48 -11
  5. package/.claude/agents/qe-flaky-test-hunter.md +57 -11
  6. package/.claude/agents/qe-fleet-commander.md +106 -49
  7. package/.claude/agents/qe-performance-tester.md +98 -45
  8. package/.claude/agents/qe-production-intelligence.md +48 -11
  9. package/.claude/agents/qe-quality-gate.md +160 -28
  10. package/.claude/agents/qe-regression-risk-analyzer.md +53 -11
  11. package/.claude/agents/qe-requirements-validator.md +48 -11
  12. package/.claude/agents/qe-security-scanner.md +230 -47
  13. package/.claude/agents/qe-test-data-architect.md +49 -11
  14. package/.claude/agents/qe-test-executor.md +59 -55
  15. package/.claude/agents/qe-test-generator.md +222 -48
  16. package/.claude/agents/qe-visual-tester.md +66 -65
  17. package/.claude/aqe-fleet.json +3 -3
  18. package/CHANGELOG.md +376 -0
  19. package/README.md +47 -3
  20. package/dist/agents/ApiContractValidatorAgent.d.ts.map +1 -1
  21. package/dist/agents/ApiContractValidatorAgent.js +1 -1
  22. package/dist/agents/ApiContractValidatorAgent.js.map +1 -1
  23. package/dist/agents/BaseAgent.d.ts +22 -3
  24. package/dist/agents/BaseAgent.d.ts.map +1 -1
  25. package/dist/agents/BaseAgent.js +124 -6
  26. package/dist/agents/BaseAgent.js.map +1 -1
  27. package/dist/agents/CoverageAnalyzerAgent.d.ts +0 -1
  28. package/dist/agents/CoverageAnalyzerAgent.d.ts.map +1 -1
  29. package/dist/agents/CoverageAnalyzerAgent.js +12 -8
  30. package/dist/agents/CoverageAnalyzerAgent.js.map +1 -1
  31. package/dist/agents/QualityAnalyzerAgent.d.ts +0 -1
  32. package/dist/agents/QualityAnalyzerAgent.d.ts.map +1 -1
  33. package/dist/agents/QualityGateAgent.d.ts +0 -1
  34. package/dist/agents/QualityGateAgent.d.ts.map +1 -1
  35. package/dist/agents/RegressionRiskAnalyzerAgent.js +17 -7
  36. package/dist/agents/RegressionRiskAnalyzerAgent.js.map +1 -1
  37. package/dist/agents/SecurityScannerAgent.d.ts +1 -0
  38. package/dist/agents/SecurityScannerAgent.d.ts.map +1 -1
  39. package/dist/agents/SecurityScannerAgent.js +46 -41
  40. package/dist/agents/SecurityScannerAgent.js.map +1 -1
  41. package/dist/agents/TestExecutorAgent.d.ts +1 -1
  42. package/dist/agents/TestExecutorAgent.d.ts.map +1 -1
  43. package/dist/agents/TestExecutorAgent.js +74 -13
  44. package/dist/agents/TestExecutorAgent.js.map +1 -1
  45. package/dist/agents/index.js +2 -2
  46. package/dist/agents/index.js.map +1 -1
  47. package/dist/cli/commands/agent/assign.d.ts +76 -0
  48. package/dist/cli/commands/agent/assign.d.ts.map +1 -0
  49. package/dist/cli/commands/agent/assign.js +290 -0
  50. package/dist/cli/commands/agent/assign.js.map +1 -0
  51. package/dist/cli/commands/agent/attach.d.ts +86 -0
  52. package/dist/cli/commands/agent/attach.d.ts.map +1 -0
  53. package/dist/cli/commands/agent/attach.js +278 -0
  54. package/dist/cli/commands/agent/attach.js.map +1 -0
  55. package/dist/cli/commands/agent/benchmark.d.ts +45 -0
  56. package/dist/cli/commands/agent/benchmark.d.ts.map +1 -0
  57. package/dist/cli/commands/agent/benchmark.js +102 -0
  58. package/dist/cli/commands/agent/benchmark.js.map +1 -0
  59. package/dist/cli/commands/agent/clone.d.ts +20 -0
  60. package/dist/cli/commands/agent/clone.d.ts.map +1 -0
  61. package/dist/cli/commands/agent/clone.js +58 -0
  62. package/dist/cli/commands/agent/clone.js.map +1 -0
  63. package/dist/cli/commands/agent/detach.d.ts +76 -0
  64. package/dist/cli/commands/agent/detach.d.ts.map +1 -0
  65. package/dist/cli/commands/agent/detach.js +260 -0
  66. package/dist/cli/commands/agent/detach.js.map +1 -0
  67. package/dist/cli/commands/agent/index.d.ts +31 -0
  68. package/dist/cli/commands/agent/index.d.ts.map +1 -0
  69. package/dist/cli/commands/agent/index.js +54 -0
  70. package/dist/cli/commands/agent/index.js.map +1 -0
  71. package/dist/cli/commands/agent/inspect.d.ts +110 -0
  72. package/dist/cli/commands/agent/inspect.d.ts.map +1 -0
  73. package/dist/cli/commands/agent/inspect.js +282 -0
  74. package/dist/cli/commands/agent/inspect.js.map +1 -0
  75. package/dist/cli/commands/agent/migrate.d.ts +24 -0
  76. package/dist/cli/commands/agent/migrate.d.ts.map +1 -0
  77. package/dist/cli/commands/agent/migrate.js +80 -0
  78. package/dist/cli/commands/agent/migrate.js.map +1 -0
  79. package/dist/cli/commands/agent/restart.d.ts +71 -0
  80. package/dist/cli/commands/agent/restart.d.ts.map +1 -0
  81. package/dist/cli/commands/agent/restart.js +237 -0
  82. package/dist/cli/commands/agent/restart.js.map +1 -0
  83. package/dist/cli/commands/analyze.js +17 -7
  84. package/dist/cli/commands/analyze.js.map +1 -1
  85. package/dist/cli/commands/config/export.d.ts +15 -0
  86. package/dist/cli/commands/config/export.d.ts.map +1 -0
  87. package/dist/cli/commands/config/export.js +104 -0
  88. package/dist/cli/commands/config/export.js.map +1 -0
  89. package/dist/cli/commands/config/get.d.ts +23 -0
  90. package/dist/cli/commands/config/get.d.ts.map +1 -0
  91. package/dist/cli/commands/config/get.js +129 -0
  92. package/dist/cli/commands/config/get.js.map +1 -0
  93. package/dist/cli/commands/config/import.d.ts +17 -0
  94. package/dist/cli/commands/config/import.d.ts.map +1 -0
  95. package/dist/cli/commands/config/import.js +148 -0
  96. package/dist/cli/commands/config/import.js.map +1 -0
  97. package/dist/cli/commands/config/index.d.ts +18 -0
  98. package/dist/cli/commands/config/index.d.ts.map +1 -0
  99. package/dist/cli/commands/config/index.js +35 -0
  100. package/dist/cli/commands/config/index.js.map +1 -0
  101. package/dist/cli/commands/config/init.d.ts +21 -0
  102. package/dist/cli/commands/config/init.d.ts.map +1 -0
  103. package/dist/cli/commands/config/init.js +181 -0
  104. package/dist/cli/commands/config/init.js.map +1 -0
  105. package/dist/cli/commands/config/list.d.ts +5 -0
  106. package/dist/cli/commands/config/list.d.ts.map +1 -0
  107. package/dist/cli/commands/config/list.js +39 -0
  108. package/dist/cli/commands/config/list.js.map +1 -0
  109. package/dist/cli/commands/config/reset.d.ts +5 -0
  110. package/dist/cli/commands/config/reset.d.ts.map +1 -0
  111. package/dist/cli/commands/config/reset.js +44 -0
  112. package/dist/cli/commands/config/reset.js.map +1 -0
  113. package/dist/cli/commands/config/schema.d.ts +115 -0
  114. package/dist/cli/commands/config/schema.d.ts.map +1 -0
  115. package/dist/cli/commands/config/schema.js +98 -0
  116. package/dist/cli/commands/config/schema.js.map +1 -0
  117. package/dist/cli/commands/config/set.d.ts +19 -0
  118. package/dist/cli/commands/config/set.d.ts.map +1 -0
  119. package/dist/cli/commands/config/set.js +143 -0
  120. package/dist/cli/commands/config/set.js.map +1 -0
  121. package/dist/cli/commands/config/validate.d.ts +23 -0
  122. package/dist/cli/commands/config/validate.d.ts.map +1 -0
  123. package/dist/cli/commands/config/validate.js +165 -0
  124. package/dist/cli/commands/config/validate.js.map +1 -0
  125. package/dist/cli/commands/debug/agent.d.ts +40 -0
  126. package/dist/cli/commands/debug/agent.d.ts.map +1 -0
  127. package/dist/cli/commands/debug/agent.js +184 -0
  128. package/dist/cli/commands/debug/agent.js.map +1 -0
  129. package/dist/cli/commands/debug/diagnostics.d.ts +27 -0
  130. package/dist/cli/commands/debug/diagnostics.d.ts.map +1 -0
  131. package/dist/cli/commands/debug/diagnostics.js +386 -0
  132. package/dist/cli/commands/debug/diagnostics.js.map +1 -0
  133. package/dist/cli/commands/debug/health-check.d.ts +38 -0
  134. package/dist/cli/commands/debug/health-check.d.ts.map +1 -0
  135. package/dist/cli/commands/debug/health-check.js +326 -0
  136. package/dist/cli/commands/debug/health-check.js.map +1 -0
  137. package/dist/cli/commands/debug/index.d.ts +17 -0
  138. package/dist/cli/commands/debug/index.d.ts.map +1 -0
  139. package/dist/cli/commands/debug/index.js +20 -0
  140. package/dist/cli/commands/debug/index.js.map +1 -0
  141. package/dist/cli/commands/debug/profile.d.ts +84 -0
  142. package/dist/cli/commands/debug/profile.d.ts.map +1 -0
  143. package/dist/cli/commands/debug/profile.js +375 -0
  144. package/dist/cli/commands/debug/profile.js.map +1 -0
  145. package/dist/cli/commands/debug/trace.d.ts +40 -0
  146. package/dist/cli/commands/debug/trace.d.ts.map +1 -0
  147. package/dist/cli/commands/debug/trace.js +252 -0
  148. package/dist/cli/commands/debug/trace.js.map +1 -0
  149. package/dist/cli/commands/debug/troubleshoot.d.ts +38 -0
  150. package/dist/cli/commands/debug/troubleshoot.d.ts.map +1 -0
  151. package/dist/cli/commands/debug/troubleshoot.js +324 -0
  152. package/dist/cli/commands/debug/troubleshoot.js.map +1 -0
  153. package/dist/cli/commands/fleet/backup.d.ts +49 -0
  154. package/dist/cli/commands/fleet/backup.d.ts.map +1 -0
  155. package/dist/cli/commands/fleet/backup.js +88 -0
  156. package/dist/cli/commands/fleet/backup.js.map +1 -0
  157. package/dist/cli/commands/fleet/health.d.ts +24 -0
  158. package/dist/cli/commands/fleet/health.d.ts.map +1 -0
  159. package/dist/cli/commands/fleet/health.js +417 -0
  160. package/dist/cli/commands/fleet/health.js.map +1 -0
  161. package/dist/cli/commands/fleet/init.d.ts +11 -0
  162. package/dist/cli/commands/fleet/init.d.ts.map +1 -0
  163. package/dist/cli/commands/fleet/init.js +91 -0
  164. package/dist/cli/commands/fleet/init.js.map +1 -0
  165. package/dist/cli/commands/fleet/logs.d.ts +21 -0
  166. package/dist/cli/commands/fleet/logs.d.ts.map +1 -0
  167. package/dist/cli/commands/fleet/logs.js +266 -0
  168. package/dist/cli/commands/fleet/logs.js.map +1 -0
  169. package/dist/cli/commands/fleet/metrics.d.ts +27 -0
  170. package/dist/cli/commands/fleet/metrics.d.ts.map +1 -0
  171. package/dist/cli/commands/fleet/metrics.js +368 -0
  172. package/dist/cli/commands/fleet/metrics.js.map +1 -0
  173. package/dist/cli/commands/fleet/monitor.d.ts +18 -0
  174. package/dist/cli/commands/fleet/monitor.d.ts.map +1 -0
  175. package/dist/cli/commands/fleet/monitor.js +234 -0
  176. package/dist/cli/commands/fleet/monitor.js.map +1 -0
  177. package/dist/cli/commands/fleet/optimize.d.ts +42 -0
  178. package/dist/cli/commands/fleet/optimize.d.ts.map +1 -0
  179. package/dist/cli/commands/fleet/optimize.js +135 -0
  180. package/dist/cli/commands/fleet/optimize.js.map +1 -0
  181. package/dist/cli/commands/fleet/recover.d.ts +22 -0
  182. package/dist/cli/commands/fleet/recover.d.ts.map +1 -0
  183. package/dist/cli/commands/fleet/recover.js +99 -0
  184. package/dist/cli/commands/fleet/recover.js.map +1 -0
  185. package/dist/cli/commands/fleet/restart.d.ts +18 -0
  186. package/dist/cli/commands/fleet/restart.d.ts.map +1 -0
  187. package/dist/cli/commands/fleet/restart.js +290 -0
  188. package/dist/cli/commands/fleet/restart.js.map +1 -0
  189. package/dist/cli/commands/fleet/scale.d.ts +9 -0
  190. package/dist/cli/commands/fleet/scale.d.ts.map +1 -0
  191. package/dist/cli/commands/fleet/scale.js +77 -0
  192. package/dist/cli/commands/fleet/scale.js.map +1 -0
  193. package/dist/cli/commands/fleet/shutdown.d.ts +19 -0
  194. package/dist/cli/commands/fleet/shutdown.d.ts.map +1 -0
  195. package/dist/cli/commands/fleet/shutdown.js +307 -0
  196. package/dist/cli/commands/fleet/shutdown.js.map +1 -0
  197. package/dist/cli/commands/fleet/status.d.ts +10 -0
  198. package/dist/cli/commands/fleet/status.d.ts.map +1 -0
  199. package/dist/cli/commands/fleet/status.js +97 -0
  200. package/dist/cli/commands/fleet/status.js.map +1 -0
  201. package/dist/cli/commands/fleet/topology.d.ts +23 -0
  202. package/dist/cli/commands/fleet/topology.d.ts.map +1 -0
  203. package/dist/cli/commands/fleet/topology.js +375 -0
  204. package/dist/cli/commands/fleet/topology.js.map +1 -0
  205. package/dist/cli/commands/fleet.d.ts +0 -1
  206. package/dist/cli/commands/fleet.d.ts.map +1 -1
  207. package/dist/cli/commands/fleet.js +35 -58
  208. package/dist/cli/commands/fleet.js.map +1 -1
  209. package/dist/cli/commands/generate.js +17 -7
  210. package/dist/cli/commands/generate.js.map +1 -1
  211. package/dist/cli/commands/init.d.ts.map +1 -1
  212. package/dist/cli/commands/init.js +194 -64
  213. package/dist/cli/commands/init.js.map +1 -1
  214. package/dist/cli/commands/memory/compact.d.ts +19 -0
  215. package/dist/cli/commands/memory/compact.d.ts.map +1 -0
  216. package/dist/cli/commands/memory/compact.js +69 -0
  217. package/dist/cli/commands/memory/compact.js.map +1 -0
  218. package/dist/cli/commands/memory/index.d.ts +9 -0
  219. package/dist/cli/commands/memory/index.d.ts.map +1 -0
  220. package/dist/cli/commands/memory/index.js +24 -0
  221. package/dist/cli/commands/memory/index.js.map +1 -0
  222. package/dist/cli/commands/memory/stats.d.ts +30 -0
  223. package/dist/cli/commands/memory/stats.d.ts.map +1 -0
  224. package/dist/cli/commands/memory/stats.js +73 -0
  225. package/dist/cli/commands/memory/stats.js.map +1 -0
  226. package/dist/cli/commands/memory/vacuum.d.ts +24 -0
  227. package/dist/cli/commands/memory/vacuum.d.ts.map +1 -0
  228. package/dist/cli/commands/memory/vacuum.js +104 -0
  229. package/dist/cli/commands/memory/vacuum.js.map +1 -0
  230. package/dist/cli/commands/monitor/alerts.d.ts +45 -0
  231. package/dist/cli/commands/monitor/alerts.d.ts.map +1 -0
  232. package/dist/cli/commands/monitor/alerts.js +167 -0
  233. package/dist/cli/commands/monitor/alerts.js.map +1 -0
  234. package/dist/cli/commands/monitor/analyze.d.ts +49 -0
  235. package/dist/cli/commands/monitor/analyze.d.ts.map +1 -0
  236. package/dist/cli/commands/monitor/analyze.js +209 -0
  237. package/dist/cli/commands/monitor/analyze.js.map +1 -0
  238. package/dist/cli/commands/monitor/compare.d.ts +38 -0
  239. package/dist/cli/commands/monitor/compare.d.ts.map +1 -0
  240. package/dist/cli/commands/monitor/compare.js +177 -0
  241. package/dist/cli/commands/monitor/compare.js.map +1 -0
  242. package/dist/cli/commands/monitor/dashboard.d.ts +34 -0
  243. package/dist/cli/commands/monitor/dashboard.d.ts.map +1 -0
  244. package/dist/cli/commands/monitor/dashboard.js +157 -0
  245. package/dist/cli/commands/monitor/dashboard.js.map +1 -0
  246. package/dist/cli/commands/monitor/export.d.ts +36 -0
  247. package/dist/cli/commands/monitor/export.d.ts.map +1 -0
  248. package/dist/cli/commands/monitor/export.js +157 -0
  249. package/dist/cli/commands/monitor/export.js.map +1 -0
  250. package/dist/cli/commands/monitor/index.d.ts +11 -0
  251. package/dist/cli/commands/monitor/index.d.ts.map +1 -0
  252. package/dist/cli/commands/monitor/index.js +14 -0
  253. package/dist/cli/commands/monitor/index.js.map +1 -0
  254. package/dist/cli/commands/quality/baseline.d.ts +27 -0
  255. package/dist/cli/commands/quality/baseline.d.ts.map +1 -0
  256. package/dist/cli/commands/quality/baseline.js +124 -0
  257. package/dist/cli/commands/quality/baseline.js.map +1 -0
  258. package/dist/cli/commands/quality/compare.d.ts +36 -0
  259. package/dist/cli/commands/quality/compare.d.ts.map +1 -0
  260. package/dist/cli/commands/quality/compare.js +136 -0
  261. package/dist/cli/commands/quality/compare.js.map +1 -0
  262. package/dist/cli/commands/quality/decision.d.ts +81 -0
  263. package/dist/cli/commands/quality/decision.d.ts.map +1 -0
  264. package/dist/cli/commands/quality/decision.js +317 -0
  265. package/dist/cli/commands/quality/decision.js.map +1 -0
  266. package/dist/cli/commands/quality/gate.d.ts +47 -0
  267. package/dist/cli/commands/quality/gate.d.ts.map +1 -0
  268. package/dist/cli/commands/quality/gate.js +203 -0
  269. package/dist/cli/commands/quality/gate.js.map +1 -0
  270. package/dist/cli/commands/quality/index.d.ts +17 -0
  271. package/dist/cli/commands/quality/index.d.ts.map +1 -0
  272. package/dist/cli/commands/quality/index.js +41 -0
  273. package/dist/cli/commands/quality/index.js.map +1 -0
  274. package/dist/cli/commands/quality/policy.d.ts +57 -0
  275. package/dist/cli/commands/quality/policy.d.ts.map +1 -0
  276. package/dist/cli/commands/quality/policy.js +357 -0
  277. package/dist/cli/commands/quality/policy.js.map +1 -0
  278. package/dist/cli/commands/quality/risk.d.ts +41 -0
  279. package/dist/cli/commands/quality/risk.d.ts.map +1 -0
  280. package/dist/cli/commands/quality/risk.js +253 -0
  281. package/dist/cli/commands/quality/risk.js.map +1 -0
  282. package/dist/cli/commands/quality/trends.d.ts +40 -0
  283. package/dist/cli/commands/quality/trends.d.ts.map +1 -0
  284. package/dist/cli/commands/quality/trends.js +122 -0
  285. package/dist/cli/commands/quality/trends.js.map +1 -0
  286. package/dist/cli/commands/quality/validate.d.ts +44 -0
  287. package/dist/cli/commands/quality/validate.d.ts.map +1 -0
  288. package/dist/cli/commands/quality/validate.js +232 -0
  289. package/dist/cli/commands/quality/validate.js.map +1 -0
  290. package/dist/cli/commands/run.js +17 -7
  291. package/dist/cli/commands/run.js.map +1 -1
  292. package/dist/cli/commands/test/analyze-failures.d.ts +39 -0
  293. package/dist/cli/commands/test/analyze-failures.d.ts.map +1 -0
  294. package/dist/cli/commands/test/analyze-failures.js +113 -0
  295. package/dist/cli/commands/test/analyze-failures.js.map +1 -0
  296. package/dist/cli/commands/test/clean.d.ts +3 -0
  297. package/dist/cli/commands/test/clean.d.ts.map +1 -0
  298. package/dist/cli/commands/test/clean.js +131 -0
  299. package/dist/cli/commands/test/clean.js.map +1 -0
  300. package/dist/cli/commands/test/debug.d.ts +3 -0
  301. package/dist/cli/commands/test/debug.d.ts.map +1 -0
  302. package/dist/cli/commands/test/debug.js +167 -0
  303. package/dist/cli/commands/test/debug.js.map +1 -0
  304. package/dist/cli/commands/test/diff.d.ts +3 -0
  305. package/dist/cli/commands/test/diff.d.ts.map +1 -0
  306. package/dist/cli/commands/test/diff.js +228 -0
  307. package/dist/cli/commands/test/diff.js.map +1 -0
  308. package/dist/cli/commands/test/flakiness.d.ts +32 -0
  309. package/dist/cli/commands/test/flakiness.d.ts.map +1 -0
  310. package/dist/cli/commands/test/flakiness.js +121 -0
  311. package/dist/cli/commands/test/flakiness.js.map +1 -0
  312. package/dist/cli/commands/test/index.d.ts +17 -0
  313. package/dist/cli/commands/test/index.d.ts.map +1 -0
  314. package/dist/cli/commands/test/index.js +45 -0
  315. package/dist/cli/commands/test/index.js.map +1 -0
  316. package/dist/cli/commands/test/mutate.d.ts +29 -0
  317. package/dist/cli/commands/test/mutate.d.ts.map +1 -0
  318. package/dist/cli/commands/test/mutate.js +162 -0
  319. package/dist/cli/commands/test/mutate.js.map +1 -0
  320. package/dist/cli/commands/test/parallel.d.ts +3 -0
  321. package/dist/cli/commands/test/parallel.d.ts.map +1 -0
  322. package/dist/cli/commands/test/parallel.js +115 -0
  323. package/dist/cli/commands/test/parallel.js.map +1 -0
  324. package/dist/cli/commands/test/profile.d.ts +3 -0
  325. package/dist/cli/commands/test/profile.d.ts.map +1 -0
  326. package/dist/cli/commands/test/profile.js +188 -0
  327. package/dist/cli/commands/test/profile.js.map +1 -0
  328. package/dist/cli/commands/test/queue.d.ts +3 -0
  329. package/dist/cli/commands/test/queue.d.ts.map +1 -0
  330. package/dist/cli/commands/test/queue.js +139 -0
  331. package/dist/cli/commands/test/queue.js.map +1 -0
  332. package/dist/cli/commands/test/retry.d.ts +3 -0
  333. package/dist/cli/commands/test/retry.d.ts.map +1 -0
  334. package/dist/cli/commands/test/retry.js +103 -0
  335. package/dist/cli/commands/test/retry.js.map +1 -0
  336. package/dist/cli/commands/test/snapshot.d.ts +3 -0
  337. package/dist/cli/commands/test/snapshot.d.ts.map +1 -0
  338. package/dist/cli/commands/test/snapshot.js +176 -0
  339. package/dist/cli/commands/test/snapshot.js.map +1 -0
  340. package/dist/cli/commands/test/trace.d.ts +3 -0
  341. package/dist/cli/commands/test/trace.d.ts.map +1 -0
  342. package/dist/cli/commands/test/trace.js +169 -0
  343. package/dist/cli/commands/test/trace.js.map +1 -0
  344. package/dist/cli/commands/test/watch.d.ts +3 -0
  345. package/dist/cli/commands/test/watch.d.ts.map +1 -0
  346. package/dist/cli/commands/test/watch.js +129 -0
  347. package/dist/cli/commands/test/watch.js.map +1 -0
  348. package/dist/cli/commands/workflow/cancel.d.ts +55 -0
  349. package/dist/cli/commands/workflow/cancel.d.ts.map +1 -0
  350. package/dist/cli/commands/workflow/cancel.js +330 -0
  351. package/dist/cli/commands/workflow/cancel.js.map +1 -0
  352. package/dist/cli/commands/workflow/index.d.ts +11 -0
  353. package/dist/cli/commands/workflow/index.d.ts.map +1 -0
  354. package/dist/cli/commands/workflow/index.js +20 -0
  355. package/dist/cli/commands/workflow/index.js.map +1 -0
  356. package/dist/cli/commands/workflow/list.d.ts +43 -0
  357. package/dist/cli/commands/workflow/list.d.ts.map +1 -0
  358. package/dist/cli/commands/workflow/list.js +256 -0
  359. package/dist/cli/commands/workflow/list.js.map +1 -0
  360. package/dist/cli/commands/workflow/pause.d.ts +44 -0
  361. package/dist/cli/commands/workflow/pause.d.ts.map +1 -0
  362. package/dist/cli/commands/workflow/pause.js +221 -0
  363. package/dist/cli/commands/workflow/pause.js.map +1 -0
  364. package/dist/cli/index-working.js +17 -7
  365. package/dist/cli/index-working.js.map +1 -1
  366. package/dist/cli/index.js +321 -0
  367. package/dist/cli/index.js.map +1 -1
  368. package/dist/core/Agent.d.ts +0 -1
  369. package/dist/core/Agent.d.ts.map +1 -1
  370. package/dist/core/Agent.js +18 -8
  371. package/dist/core/Agent.js.map +1 -1
  372. package/dist/core/ArtifactWorkflow.d.ts +149 -0
  373. package/dist/core/ArtifactWorkflow.d.ts.map +1 -0
  374. package/dist/core/ArtifactWorkflow.js +357 -0
  375. package/dist/core/ArtifactWorkflow.js.map +1 -0
  376. package/dist/core/EventBus.d.ts +0 -1
  377. package/dist/core/EventBus.d.ts.map +1 -1
  378. package/dist/core/EventBus.js +18 -12
  379. package/dist/core/EventBus.js.map +1 -1
  380. package/dist/core/FleetManager.d.ts +0 -1
  381. package/dist/core/FleetManager.d.ts.map +1 -1
  382. package/dist/core/FleetManager.js +17 -7
  383. package/dist/core/FleetManager.js.map +1 -1
  384. package/dist/core/MemoryManager.d.ts +0 -1
  385. package/dist/core/MemoryManager.d.ts.map +1 -1
  386. package/dist/core/Task.d.ts +0 -1
  387. package/dist/core/Task.d.ts.map +1 -1
  388. package/dist/core/coordination/BlackboardCoordination.d.ts +43 -0
  389. package/dist/core/coordination/BlackboardCoordination.d.ts.map +1 -0
  390. package/dist/core/coordination/BlackboardCoordination.js +95 -0
  391. package/dist/core/coordination/BlackboardCoordination.js.map +1 -0
  392. package/dist/core/coordination/ConsensusGating.d.ts +52 -0
  393. package/dist/core/coordination/ConsensusGating.d.ts.map +1 -0
  394. package/dist/core/coordination/ConsensusGating.js +137 -0
  395. package/dist/core/coordination/ConsensusGating.js.map +1 -0
  396. package/dist/core/coordination/GOAPCoordination.d.ts +78 -0
  397. package/dist/core/coordination/GOAPCoordination.d.ts.map +1 -0
  398. package/dist/core/coordination/GOAPCoordination.js +178 -0
  399. package/dist/core/coordination/GOAPCoordination.js.map +1 -0
  400. package/dist/core/coordination/OODACoordination.d.ts +98 -0
  401. package/dist/core/coordination/OODACoordination.d.ts.map +1 -0
  402. package/dist/core/coordination/OODACoordination.js +207 -0
  403. package/dist/core/coordination/OODACoordination.js.map +1 -0
  404. package/dist/core/coordination/index.d.ts +19 -0
  405. package/dist/core/coordination/index.d.ts.map +1 -0
  406. package/dist/core/coordination/index.js +22 -0
  407. package/dist/core/coordination/index.js.map +1 -0
  408. package/dist/core/events/QEEventBus.d.ts +61 -0
  409. package/dist/core/events/QEEventBus.d.ts.map +1 -0
  410. package/dist/core/events/QEEventBus.js +109 -0
  411. package/dist/core/events/QEEventBus.js.map +1 -0
  412. package/dist/core/events/index.d.ts +7 -0
  413. package/dist/core/events/index.d.ts.map +1 -0
  414. package/dist/core/events/index.js +25 -0
  415. package/dist/core/events/index.js.map +1 -0
  416. package/dist/core/events/types.d.ts +72 -0
  417. package/dist/core/events/types.d.ts.map +1 -0
  418. package/dist/core/events/types.js +6 -0
  419. package/dist/core/events/types.js.map +1 -0
  420. package/dist/core/hooks/RollbackManager.d.ts +90 -0
  421. package/dist/core/hooks/RollbackManager.d.ts.map +1 -0
  422. package/dist/core/hooks/RollbackManager.js +224 -0
  423. package/dist/core/hooks/RollbackManager.js.map +1 -0
  424. package/dist/core/hooks/VerificationHookManager.d.ts +133 -0
  425. package/dist/core/hooks/VerificationHookManager.d.ts.map +1 -0
  426. package/dist/core/hooks/VerificationHookManager.js +293 -0
  427. package/dist/core/hooks/VerificationHookManager.js.map +1 -0
  428. package/dist/core/hooks/checkers/ConfigurationChecker.d.ts +31 -0
  429. package/dist/core/hooks/checkers/ConfigurationChecker.d.ts.map +1 -0
  430. package/dist/core/hooks/checkers/ConfigurationChecker.js +98 -0
  431. package/dist/core/hooks/checkers/ConfigurationChecker.js.map +1 -0
  432. package/dist/core/hooks/checkers/EnvironmentChecker.d.ts +23 -0
  433. package/dist/core/hooks/checkers/EnvironmentChecker.d.ts.map +1 -0
  434. package/dist/core/hooks/checkers/EnvironmentChecker.js +103 -0
  435. package/dist/core/hooks/checkers/EnvironmentChecker.js.map +1 -0
  436. package/dist/core/hooks/checkers/PermissionChecker.d.ts +26 -0
  437. package/dist/core/hooks/checkers/PermissionChecker.d.ts.map +1 -0
  438. package/dist/core/hooks/checkers/PermissionChecker.js +146 -0
  439. package/dist/core/hooks/checkers/PermissionChecker.js.map +1 -0
  440. package/dist/core/hooks/checkers/ResourceChecker.d.ts +24 -0
  441. package/dist/core/hooks/checkers/ResourceChecker.d.ts.map +1 -0
  442. package/dist/core/hooks/checkers/ResourceChecker.js +107 -0
  443. package/dist/core/hooks/checkers/ResourceChecker.js.map +1 -0
  444. package/dist/core/hooks/checkers/index.d.ts +12 -0
  445. package/dist/core/hooks/checkers/index.d.ts.map +1 -0
  446. package/dist/core/hooks/checkers/index.js +15 -0
  447. package/dist/core/hooks/checkers/index.js.map +1 -0
  448. package/dist/core/hooks/index.d.ts +16 -0
  449. package/dist/core/hooks/index.d.ts.map +1 -0
  450. package/dist/core/hooks/index.js +34 -0
  451. package/dist/core/hooks/index.js.map +1 -0
  452. package/dist/core/hooks/validators/CoverageValidator.d.ts +38 -0
  453. package/dist/core/hooks/validators/CoverageValidator.d.ts.map +1 -0
  454. package/dist/core/hooks/validators/CoverageValidator.js +68 -0
  455. package/dist/core/hooks/validators/CoverageValidator.js.map +1 -0
  456. package/dist/core/hooks/validators/OutputValidator.d.ts +19 -0
  457. package/dist/core/hooks/validators/OutputValidator.d.ts.map +1 -0
  458. package/dist/core/hooks/validators/OutputValidator.js +57 -0
  459. package/dist/core/hooks/validators/OutputValidator.js.map +1 -0
  460. package/dist/core/hooks/validators/PerformanceValidator.d.ts +39 -0
  461. package/dist/core/hooks/validators/PerformanceValidator.d.ts.map +1 -0
  462. package/dist/core/hooks/validators/PerformanceValidator.js +97 -0
  463. package/dist/core/hooks/validators/PerformanceValidator.js.map +1 -0
  464. package/dist/core/hooks/validators/QualityValidator.d.ts +32 -0
  465. package/dist/core/hooks/validators/QualityValidator.d.ts.map +1 -0
  466. package/dist/core/hooks/validators/QualityValidator.js +71 -0
  467. package/dist/core/hooks/validators/QualityValidator.js.map +1 -0
  468. package/dist/core/hooks/validators/index.d.ts +12 -0
  469. package/dist/core/hooks/validators/index.d.ts.map +1 -0
  470. package/dist/core/hooks/validators/index.js +15 -0
  471. package/dist/core/hooks/validators/index.js.map +1 -0
  472. package/dist/core/index.d.ts +2 -0
  473. package/dist/core/index.d.ts.map +1 -1
  474. package/dist/core/index.js +3 -1
  475. package/dist/core/index.js.map +1 -1
  476. package/dist/core/memory/AccessControl.d.ts +139 -0
  477. package/dist/core/memory/AccessControl.d.ts.map +1 -0
  478. package/dist/core/memory/AccessControl.js +269 -0
  479. package/dist/core/memory/AccessControl.js.map +1 -0
  480. package/dist/core/memory/CompressionManager.d.ts +85 -0
  481. package/dist/core/memory/CompressionManager.d.ts.map +1 -0
  482. package/dist/core/memory/CompressionManager.js +237 -0
  483. package/dist/core/memory/CompressionManager.js.map +1 -0
  484. package/dist/core/memory/EncryptionManager.d.ts +86 -0
  485. package/dist/core/memory/EncryptionManager.d.ts.map +1 -0
  486. package/dist/core/memory/EncryptionManager.js +223 -0
  487. package/dist/core/memory/EncryptionManager.js.map +1 -0
  488. package/dist/core/memory/EnhancedSwarmMemoryManager.d.ts +91 -0
  489. package/dist/core/memory/EnhancedSwarmMemoryManager.d.ts.map +1 -0
  490. package/dist/core/memory/EnhancedSwarmMemoryManager.js +226 -0
  491. package/dist/core/memory/EnhancedSwarmMemoryManager.js.map +1 -0
  492. package/dist/core/memory/SwarmMemoryManager.d.ts +295 -0
  493. package/dist/core/memory/SwarmMemoryManager.d.ts.map +1 -0
  494. package/dist/core/memory/SwarmMemoryManager.js +1417 -0
  495. package/dist/core/memory/SwarmMemoryManager.js.map +1 -0
  496. package/dist/core/memory/VersionHistory.d.ts +88 -0
  497. package/dist/core/memory/VersionHistory.d.ts.map +1 -0
  498. package/dist/core/memory/VersionHistory.js +249 -0
  499. package/dist/core/memory/VersionHistory.js.map +1 -0
  500. package/dist/core/memory/index.d.ts +11 -0
  501. package/dist/core/memory/index.d.ts.map +1 -0
  502. package/dist/core/memory/index.js +18 -0
  503. package/dist/core/memory/index.js.map +1 -0
  504. package/dist/coverage/coverage-collector.d.ts +63 -8
  505. package/dist/coverage/coverage-collector.d.ts.map +1 -1
  506. package/dist/coverage/coverage-collector.js +364 -14
  507. package/dist/coverage/coverage-collector.js.map +1 -1
  508. package/dist/coverage/coverage-reporter.d.ts +48 -11
  509. package/dist/coverage/coverage-reporter.d.ts.map +1 -1
  510. package/dist/coverage/coverage-reporter.js +434 -14
  511. package/dist/coverage/coverage-reporter.js.map +1 -1
  512. package/dist/mcp/handlers/advanced/api-breaking-changes.d.ts +7 -0
  513. package/dist/mcp/handlers/advanced/api-breaking-changes.d.ts.map +1 -0
  514. package/dist/mcp/handlers/advanced/api-breaking-changes.js +216 -0
  515. package/dist/mcp/handlers/advanced/api-breaking-changes.js.map +1 -0
  516. package/dist/mcp/handlers/advanced/index.d.ts +10 -0
  517. package/dist/mcp/handlers/advanced/index.d.ts.map +1 -0
  518. package/dist/mcp/handlers/advanced/index.js +19 -0
  519. package/dist/mcp/handlers/advanced/index.js.map +1 -0
  520. package/dist/mcp/handlers/advanced/mutation-test-execute.d.ts +7 -0
  521. package/dist/mcp/handlers/advanced/mutation-test-execute.d.ts.map +1 -0
  522. package/dist/mcp/handlers/advanced/mutation-test-execute.js +229 -0
  523. package/dist/mcp/handlers/advanced/mutation-test-execute.js.map +1 -0
  524. package/dist/mcp/handlers/advanced/production-incident-replay.d.ts +7 -0
  525. package/dist/mcp/handlers/advanced/production-incident-replay.d.ts.map +1 -0
  526. package/dist/mcp/handlers/advanced/production-incident-replay.js +227 -0
  527. package/dist/mcp/handlers/advanced/production-incident-replay.js.map +1 -0
  528. package/dist/mcp/handlers/advanced/production-rum-analyze.d.ts +7 -0
  529. package/dist/mcp/handlers/advanced/production-rum-analyze.d.ts.map +1 -0
  530. package/dist/mcp/handlers/advanced/production-rum-analyze.js +288 -0
  531. package/dist/mcp/handlers/advanced/production-rum-analyze.js.map +1 -0
  532. package/dist/mcp/handlers/advanced/requirements-generate-bdd.d.ts +7 -0
  533. package/dist/mcp/handlers/advanced/requirements-generate-bdd.d.ts.map +1 -0
  534. package/dist/mcp/handlers/advanced/requirements-generate-bdd.js +267 -0
  535. package/dist/mcp/handlers/advanced/requirements-generate-bdd.js.map +1 -0
  536. package/dist/mcp/handlers/advanced/requirements-validate.d.ts +7 -0
  537. package/dist/mcp/handlers/advanced/requirements-validate.d.ts.map +1 -0
  538. package/dist/mcp/handlers/advanced/requirements-validate.js +175 -0
  539. package/dist/mcp/handlers/advanced/requirements-validate.js.map +1 -0
  540. package/dist/mcp/handlers/analysis/coverage-analyze-sublinear-handler.d.ts +10 -0
  541. package/dist/mcp/handlers/analysis/coverage-analyze-sublinear-handler.d.ts.map +1 -0
  542. package/dist/mcp/handlers/analysis/coverage-analyze-sublinear-handler.js +31 -0
  543. package/dist/mcp/handlers/analysis/coverage-analyze-sublinear-handler.js.map +1 -0
  544. package/dist/mcp/handlers/analysis/coverage-gaps-detect-handler.d.ts +14 -0
  545. package/dist/mcp/handlers/analysis/coverage-gaps-detect-handler.d.ts.map +1 -0
  546. package/dist/mcp/handlers/analysis/coverage-gaps-detect-handler.js +55 -0
  547. package/dist/mcp/handlers/analysis/coverage-gaps-detect-handler.js.map +1 -0
  548. package/dist/mcp/handlers/analysis/coverageAnalyzeSublinear.d.ts +35 -0
  549. package/dist/mcp/handlers/analysis/coverageAnalyzeSublinear.d.ts.map +1 -0
  550. package/dist/mcp/handlers/analysis/coverageAnalyzeSublinear.js +162 -0
  551. package/dist/mcp/handlers/analysis/coverageAnalyzeSublinear.js.map +1 -0
  552. package/dist/mcp/handlers/analysis/coverageGapsDetect.d.ts +56 -0
  553. package/dist/mcp/handlers/analysis/coverageGapsDetect.d.ts.map +1 -0
  554. package/dist/mcp/handlers/analysis/coverageGapsDetect.js +203 -0
  555. package/dist/mcp/handlers/analysis/coverageGapsDetect.js.map +1 -0
  556. package/dist/mcp/handlers/analysis/index.d.ts +15 -0
  557. package/dist/mcp/handlers/analysis/index.d.ts.map +1 -0
  558. package/dist/mcp/handlers/analysis/index.js +18 -0
  559. package/dist/mcp/handlers/analysis/index.js.map +1 -0
  560. package/dist/mcp/handlers/analysis/performance-benchmark-run-handler.d.ts +15 -0
  561. package/dist/mcp/handlers/analysis/performance-benchmark-run-handler.d.ts.map +1 -0
  562. package/dist/mcp/handlers/analysis/performance-benchmark-run-handler.js +47 -0
  563. package/dist/mcp/handlers/analysis/performance-benchmark-run-handler.js.map +1 -0
  564. package/dist/mcp/handlers/analysis/performance-monitor-realtime-handler.d.ts +15 -0
  565. package/dist/mcp/handlers/analysis/performance-monitor-realtime-handler.d.ts.map +1 -0
  566. package/dist/mcp/handlers/analysis/performance-monitor-realtime-handler.js +55 -0
  567. package/dist/mcp/handlers/analysis/performance-monitor-realtime-handler.js.map +1 -0
  568. package/dist/mcp/handlers/analysis/performanceBenchmarkRun.d.ts +58 -0
  569. package/dist/mcp/handlers/analysis/performanceBenchmarkRun.d.ts.map +1 -0
  570. package/dist/mcp/handlers/analysis/performanceBenchmarkRun.js +187 -0
  571. package/dist/mcp/handlers/analysis/performanceBenchmarkRun.js.map +1 -0
  572. package/dist/mcp/handlers/analysis/performanceMonitorRealtime.d.ts +58 -0
  573. package/dist/mcp/handlers/analysis/performanceMonitorRealtime.d.ts.map +1 -0
  574. package/dist/mcp/handlers/analysis/performanceMonitorRealtime.js +184 -0
  575. package/dist/mcp/handlers/analysis/performanceMonitorRealtime.js.map +1 -0
  576. package/dist/mcp/handlers/analysis/security-scan-comprehensive-handler.d.ts +15 -0
  577. package/dist/mcp/handlers/analysis/security-scan-comprehensive-handler.d.ts.map +1 -0
  578. package/dist/mcp/handlers/analysis/security-scan-comprehensive-handler.js +70 -0
  579. package/dist/mcp/handlers/analysis/security-scan-comprehensive-handler.js.map +1 -0
  580. package/dist/mcp/handlers/analysis/securityScanComprehensive.d.ts +66 -0
  581. package/dist/mcp/handlers/analysis/securityScanComprehensive.d.ts.map +1 -0
  582. package/dist/mcp/handlers/analysis/securityScanComprehensive.js +299 -0
  583. package/dist/mcp/handlers/analysis/securityScanComprehensive.js.map +1 -0
  584. package/dist/mcp/handlers/chaos/chaos-inject-failure.d.ts +18 -0
  585. package/dist/mcp/handlers/chaos/chaos-inject-failure.d.ts.map +1 -0
  586. package/dist/mcp/handlers/chaos/chaos-inject-failure.js +277 -0
  587. package/dist/mcp/handlers/chaos/chaos-inject-failure.js.map +1 -0
  588. package/dist/mcp/handlers/chaos/chaos-inject-latency.d.ts +18 -0
  589. package/dist/mcp/handlers/chaos/chaos-inject-latency.d.ts.map +1 -0
  590. package/dist/mcp/handlers/chaos/chaos-inject-latency.js +214 -0
  591. package/dist/mcp/handlers/chaos/chaos-inject-latency.js.map +1 -0
  592. package/dist/mcp/handlers/chaos/chaos-resilience-test.d.ts +18 -0
  593. package/dist/mcp/handlers/chaos/chaos-resilience-test.d.ts.map +1 -0
  594. package/dist/mcp/handlers/chaos/chaos-resilience-test.js +429 -0
  595. package/dist/mcp/handlers/chaos/chaos-resilience-test.js.map +1 -0
  596. package/dist/mcp/handlers/chaos/index.d.ts +8 -0
  597. package/dist/mcp/handlers/chaos/index.d.ts.map +1 -0
  598. package/dist/mcp/handlers/chaos/index.js +19 -0
  599. package/dist/mcp/handlers/chaos/index.js.map +1 -0
  600. package/dist/mcp/handlers/coordination/event-emit.d.ts +47 -0
  601. package/dist/mcp/handlers/coordination/event-emit.d.ts.map +1 -0
  602. package/dist/mcp/handlers/coordination/event-emit.js +96 -0
  603. package/dist/mcp/handlers/coordination/event-emit.js.map +1 -0
  604. package/dist/mcp/handlers/coordination/event-subscribe.d.ts +49 -0
  605. package/dist/mcp/handlers/coordination/event-subscribe.d.ts.map +1 -0
  606. package/dist/mcp/handlers/coordination/event-subscribe.js +210 -0
  607. package/dist/mcp/handlers/coordination/event-subscribe.js.map +1 -0
  608. package/dist/mcp/handlers/coordination/index.d.ts +22 -0
  609. package/dist/mcp/handlers/coordination/index.d.ts.map +1 -0
  610. package/dist/mcp/handlers/coordination/index.js +25 -0
  611. package/dist/mcp/handlers/coordination/index.js.map +1 -0
  612. package/dist/mcp/handlers/coordination/task-status.d.ts +75 -0
  613. package/dist/mcp/handlers/coordination/task-status.d.ts.map +1 -0
  614. package/dist/mcp/handlers/coordination/task-status.js +134 -0
  615. package/dist/mcp/handlers/coordination/task-status.js.map +1 -0
  616. package/dist/mcp/handlers/coordination/workflow-checkpoint.d.ts +45 -0
  617. package/dist/mcp/handlers/coordination/workflow-checkpoint.d.ts.map +1 -0
  618. package/dist/mcp/handlers/coordination/workflow-checkpoint.js +114 -0
  619. package/dist/mcp/handlers/coordination/workflow-checkpoint.js.map +1 -0
  620. package/dist/mcp/handlers/coordination/workflow-create.d.ts +71 -0
  621. package/dist/mcp/handlers/coordination/workflow-create.d.ts.map +1 -0
  622. package/dist/mcp/handlers/coordination/workflow-create.js +163 -0
  623. package/dist/mcp/handlers/coordination/workflow-create.js.map +1 -0
  624. package/dist/mcp/handlers/coordination/workflow-execute.d.ts +61 -0
  625. package/dist/mcp/handlers/coordination/workflow-execute.d.ts.map +1 -0
  626. package/dist/mcp/handlers/coordination/workflow-execute.js +160 -0
  627. package/dist/mcp/handlers/coordination/workflow-execute.js.map +1 -0
  628. package/dist/mcp/handlers/coordination/workflow-resume.d.ts +49 -0
  629. package/dist/mcp/handlers/coordination/workflow-resume.d.ts.map +1 -0
  630. package/dist/mcp/handlers/coordination/workflow-resume.js +124 -0
  631. package/dist/mcp/handlers/coordination/workflow-resume.js.map +1 -0
  632. package/dist/mcp/handlers/integration/contract-validate.d.ts +10 -0
  633. package/dist/mcp/handlers/integration/contract-validate.d.ts.map +1 -0
  634. package/dist/mcp/handlers/integration/contract-validate.js +348 -0
  635. package/dist/mcp/handlers/integration/contract-validate.js.map +1 -0
  636. package/dist/mcp/handlers/integration/dependency-check.d.ts +10 -0
  637. package/dist/mcp/handlers/integration/dependency-check.d.ts.map +1 -0
  638. package/dist/mcp/handlers/integration/dependency-check.js +252 -0
  639. package/dist/mcp/handlers/integration/dependency-check.js.map +1 -0
  640. package/dist/mcp/handlers/integration/index.d.ts +9 -0
  641. package/dist/mcp/handlers/integration/index.d.ts.map +1 -0
  642. package/dist/mcp/handlers/integration/index.js +14 -0
  643. package/dist/mcp/handlers/integration/index.js.map +1 -0
  644. package/dist/mcp/handlers/integration/integration-test-orchestrate.d.ts +10 -0
  645. package/dist/mcp/handlers/integration/integration-test-orchestrate.d.ts.map +1 -0
  646. package/dist/mcp/handlers/integration/integration-test-orchestrate.js +241 -0
  647. package/dist/mcp/handlers/integration/integration-test-orchestrate.js.map +1 -0
  648. package/dist/mcp/handlers/memory/artifact-manifest.d.ts +57 -0
  649. package/dist/mcp/handlers/memory/artifact-manifest.d.ts.map +1 -0
  650. package/dist/mcp/handlers/memory/artifact-manifest.js +176 -0
  651. package/dist/mcp/handlers/memory/artifact-manifest.js.map +1 -0
  652. package/dist/mcp/handlers/memory/blackboard-post.d.ts +50 -0
  653. package/dist/mcp/handlers/memory/blackboard-post.d.ts.map +1 -0
  654. package/dist/mcp/handlers/memory/blackboard-post.js +88 -0
  655. package/dist/mcp/handlers/memory/blackboard-post.js.map +1 -0
  656. package/dist/mcp/handlers/memory/blackboard-read.d.ts +33 -0
  657. package/dist/mcp/handlers/memory/blackboard-read.d.ts.map +1 -0
  658. package/dist/mcp/handlers/memory/blackboard-read.js +81 -0
  659. package/dist/mcp/handlers/memory/blackboard-read.js.map +1 -0
  660. package/dist/mcp/handlers/memory/consensus-propose.d.ts +57 -0
  661. package/dist/mcp/handlers/memory/consensus-propose.d.ts.map +1 -0
  662. package/dist/mcp/handlers/memory/consensus-propose.js +99 -0
  663. package/dist/mcp/handlers/memory/consensus-propose.js.map +1 -0
  664. package/dist/mcp/handlers/memory/consensus-vote.d.ts +37 -0
  665. package/dist/mcp/handlers/memory/consensus-vote.d.ts.map +1 -0
  666. package/dist/mcp/handlers/memory/consensus-vote.js +131 -0
  667. package/dist/mcp/handlers/memory/consensus-vote.js.map +1 -0
  668. package/dist/mcp/handlers/memory/memory-backup.d.ts +49 -0
  669. package/dist/mcp/handlers/memory/memory-backup.d.ts.map +1 -0
  670. package/dist/mcp/handlers/memory/memory-backup.js +154 -0
  671. package/dist/mcp/handlers/memory/memory-backup.js.map +1 -0
  672. package/dist/mcp/handlers/memory/memory-query.d.ts +35 -0
  673. package/dist/mcp/handlers/memory/memory-query.d.ts.map +1 -0
  674. package/dist/mcp/handlers/memory/memory-query.js +96 -0
  675. package/dist/mcp/handlers/memory/memory-query.js.map +1 -0
  676. package/dist/mcp/handlers/memory/memory-retrieve.d.ts +32 -0
  677. package/dist/mcp/handlers/memory/memory-retrieve.d.ts.map +1 -0
  678. package/dist/mcp/handlers/memory/memory-retrieve.js +91 -0
  679. package/dist/mcp/handlers/memory/memory-retrieve.js.map +1 -0
  680. package/dist/mcp/handlers/memory/memory-share.d.ts +39 -0
  681. package/dist/mcp/handlers/memory/memory-share.d.ts.map +1 -0
  682. package/dist/mcp/handlers/memory/memory-share.js +96 -0
  683. package/dist/mcp/handlers/memory/memory-share.js.map +1 -0
  684. package/dist/mcp/handlers/memory/memory-store.d.ts +47 -0
  685. package/dist/mcp/handlers/memory/memory-store.d.ts.map +1 -0
  686. package/dist/mcp/handlers/memory/memory-store.js +107 -0
  687. package/dist/mcp/handlers/memory/memory-store.js.map +1 -0
  688. package/dist/mcp/handlers/prediction/deployment-readiness-check.d.ts +157 -0
  689. package/dist/mcp/handlers/prediction/deployment-readiness-check.d.ts.map +1 -0
  690. package/dist/mcp/handlers/prediction/deployment-readiness-check.js +483 -0
  691. package/dist/mcp/handlers/prediction/deployment-readiness-check.js.map +1 -0
  692. package/dist/mcp/handlers/prediction/flaky-test-detect.d.ts +178 -0
  693. package/dist/mcp/handlers/prediction/flaky-test-detect.d.ts.map +1 -0
  694. package/dist/mcp/handlers/prediction/flaky-test-detect.js +438 -0
  695. package/dist/mcp/handlers/prediction/flaky-test-detect.js.map +1 -0
  696. package/dist/mcp/handlers/prediction/index.d.ts +19 -0
  697. package/dist/mcp/handlers/prediction/index.d.ts.map +1 -0
  698. package/dist/mcp/handlers/prediction/index.js +22 -0
  699. package/dist/mcp/handlers/prediction/index.js.map +1 -0
  700. package/dist/mcp/handlers/prediction/predict-defects-ai.d.ts +133 -0
  701. package/dist/mcp/handlers/prediction/predict-defects-ai.d.ts.map +1 -0
  702. package/dist/mcp/handlers/prediction/predict-defects-ai.js +278 -0
  703. package/dist/mcp/handlers/prediction/predict-defects-ai.js.map +1 -0
  704. package/dist/mcp/handlers/prediction/regression-risk-analyze.d.ts +189 -0
  705. package/dist/mcp/handlers/prediction/regression-risk-analyze.d.ts.map +1 -0
  706. package/dist/mcp/handlers/prediction/regression-risk-analyze.js +419 -0
  707. package/dist/mcp/handlers/prediction/regression-risk-analyze.js.map +1 -0
  708. package/dist/mcp/handlers/prediction/visual-test-regression.d.ts +138 -0
  709. package/dist/mcp/handlers/prediction/visual-test-regression.d.ts.map +1 -0
  710. package/dist/mcp/handlers/prediction/visual-test-regression.js +274 -0
  711. package/dist/mcp/handlers/prediction/visual-test-regression.js.map +1 -0
  712. package/dist/mcp/handlers/quality/quality-decision-make.d.ts +104 -0
  713. package/dist/mcp/handlers/quality/quality-decision-make.d.ts.map +1 -0
  714. package/dist/mcp/handlers/quality/quality-decision-make.js +418 -0
  715. package/dist/mcp/handlers/quality/quality-decision-make.js.map +1 -0
  716. package/dist/mcp/handlers/quality/quality-gate-execute.d.ts +160 -0
  717. package/dist/mcp/handlers/quality/quality-gate-execute.d.ts.map +1 -0
  718. package/dist/mcp/handlers/quality/quality-gate-execute.js +424 -0
  719. package/dist/mcp/handlers/quality/quality-gate-execute.js.map +1 -0
  720. package/dist/mcp/handlers/quality/quality-policy-check.d.ts +163 -0
  721. package/dist/mcp/handlers/quality/quality-policy-check.d.ts.map +1 -0
  722. package/dist/mcp/handlers/quality/quality-policy-check.js +465 -0
  723. package/dist/mcp/handlers/quality/quality-policy-check.js.map +1 -0
  724. package/dist/mcp/handlers/quality/quality-risk-assess.d.ts +123 -0
  725. package/dist/mcp/handlers/quality/quality-risk-assess.d.ts.map +1 -0
  726. package/dist/mcp/handlers/quality/quality-risk-assess.js +532 -0
  727. package/dist/mcp/handlers/quality/quality-risk-assess.js.map +1 -0
  728. package/dist/mcp/handlers/quality/quality-validate-metrics.d.ts +117 -0
  729. package/dist/mcp/handlers/quality/quality-validate-metrics.d.ts.map +1 -0
  730. package/dist/mcp/handlers/quality/quality-validate-metrics.js +298 -0
  731. package/dist/mcp/handlers/quality/quality-validate-metrics.js.map +1 -0
  732. package/dist/mcp/handlers/test/index.d.ts +9 -0
  733. package/dist/mcp/handlers/test/index.d.ts.map +1 -0
  734. package/dist/mcp/handlers/test/index.js +25 -0
  735. package/dist/mcp/handlers/test/index.js.map +1 -0
  736. package/dist/mcp/handlers/test/test-coverage-detailed.d.ts +65 -0
  737. package/dist/mcp/handlers/test/test-coverage-detailed.d.ts.map +1 -0
  738. package/dist/mcp/handlers/test/test-coverage-detailed.js +305 -0
  739. package/dist/mcp/handlers/test/test-coverage-detailed.js.map +1 -0
  740. package/dist/mcp/handlers/test/test-execute-parallel.d.ts +39 -0
  741. package/dist/mcp/handlers/test/test-execute-parallel.d.ts.map +1 -0
  742. package/dist/mcp/handlers/test/test-execute-parallel.js +189 -0
  743. package/dist/mcp/handlers/test/test-execute-parallel.js.map +1 -0
  744. package/dist/mcp/handlers/test/test-generate-enhanced.d.ts +40 -0
  745. package/dist/mcp/handlers/test/test-generate-enhanced.d.ts.map +1 -0
  746. package/dist/mcp/handlers/test/test-generate-enhanced.js +240 -0
  747. package/dist/mcp/handlers/test/test-generate-enhanced.js.map +1 -0
  748. package/dist/mcp/handlers/test/test-optimize-sublinear.d.ts +40 -0
  749. package/dist/mcp/handlers/test/test-optimize-sublinear.d.ts.map +1 -0
  750. package/dist/mcp/handlers/test/test-optimize-sublinear.js +223 -0
  751. package/dist/mcp/handlers/test/test-optimize-sublinear.js.map +1 -0
  752. package/dist/mcp/handlers/test/test-report-comprehensive.d.ts +50 -0
  753. package/dist/mcp/handlers/test/test-report-comprehensive.d.ts.map +1 -0
  754. package/dist/mcp/handlers/test/test-report-comprehensive.js +239 -0
  755. package/dist/mcp/handlers/test/test-report-comprehensive.js.map +1 -0
  756. package/dist/mcp/handlers/test-execute.d.ts +0 -2
  757. package/dist/mcp/handlers/test-execute.d.ts.map +1 -1
  758. package/dist/mcp/handlers/test-execute.js +92 -45
  759. package/dist/mcp/handlers/test-execute.js.map +1 -1
  760. package/dist/mcp/server.d.ts +4 -0
  761. package/dist/mcp/server.d.ts.map +1 -1
  762. package/dist/mcp/server.js +92 -3
  763. package/dist/mcp/server.js.map +1 -1
  764. package/dist/mcp/services/AgentRegistry.js +3 -3
  765. package/dist/mcp/services/AgentRegistry.js.map +1 -1
  766. package/dist/mcp/services/HookExecutor.d.ts +44 -5
  767. package/dist/mcp/services/HookExecutor.d.ts.map +1 -1
  768. package/dist/mcp/services/HookExecutor.js +43 -7
  769. package/dist/mcp/services/HookExecutor.js.map +1 -1
  770. package/dist/mcp/tools.d.ts +43 -0
  771. package/dist/mcp/tools.d.ts.map +1 -1
  772. package/dist/mcp/tools.js +1256 -1
  773. package/dist/mcp/tools.js.map +1 -1
  774. package/dist/mcp/types/advanced.d.ts +193 -0
  775. package/dist/mcp/types/advanced.d.ts.map +1 -0
  776. package/dist/mcp/types/advanced.js +7 -0
  777. package/dist/mcp/types/advanced.js.map +1 -0
  778. package/dist/mcp/types/analysis.d.ts +46 -0
  779. package/dist/mcp/types/analysis.d.ts.map +1 -0
  780. package/dist/mcp/types/analysis.js +6 -0
  781. package/dist/mcp/types/analysis.js.map +1 -0
  782. package/dist/mcp/types/chaos.d.ts +343 -0
  783. package/dist/mcp/types/chaos.d.ts.map +1 -0
  784. package/dist/mcp/types/chaos.js +7 -0
  785. package/dist/mcp/types/chaos.js.map +1 -0
  786. package/dist/mcp/types/integration.d.ts +418 -0
  787. package/dist/mcp/types/integration.d.ts.map +1 -0
  788. package/dist/mcp/types/integration.js +7 -0
  789. package/dist/mcp/types/integration.js.map +1 -0
  790. package/dist/types/api-contract.types.js +1 -2
  791. package/dist/types/api-contract.types.js.map +1 -1
  792. package/dist/types/errors.d.ts.map +1 -1
  793. package/dist/types/errors.js +5 -5
  794. package/dist/types/errors.js.map +1 -1
  795. package/dist/types/hook.types.d.ts +147 -0
  796. package/dist/types/hook.types.d.ts.map +1 -0
  797. package/dist/types/hook.types.js +7 -0
  798. package/dist/types/hook.types.js.map +1 -0
  799. package/dist/types/index.d.ts +1 -0
  800. package/dist/types/index.d.ts.map +1 -1
  801. package/dist/types/index.js +16 -0
  802. package/dist/types/index.js.map +1 -1
  803. package/dist/utils/Config.d.ts +6 -2
  804. package/dist/utils/Config.d.ts.map +1 -1
  805. package/dist/utils/Config.js +41 -0
  806. package/dist/utils/Config.js.map +1 -1
  807. package/dist/utils/FakerDataGenerator.d.ts +203 -0
  808. package/dist/utils/FakerDataGenerator.d.ts.map +1 -0
  809. package/dist/utils/FakerDataGenerator.js +379 -0
  810. package/dist/utils/FakerDataGenerator.js.map +1 -0
  811. package/dist/utils/SecurityScanner.d.ts +72 -0
  812. package/dist/utils/SecurityScanner.d.ts.map +1 -0
  813. package/dist/utils/SecurityScanner.js +388 -0
  814. package/dist/utils/SecurityScanner.js.map +1 -0
  815. package/dist/utils/TestFrameworkExecutor.d.ts +146 -0
  816. package/dist/utils/TestFrameworkExecutor.d.ts.map +1 -0
  817. package/dist/utils/TestFrameworkExecutor.js +576 -0
  818. package/dist/utils/TestFrameworkExecutor.js.map +1 -0
  819. package/dist/utils/index.d.ts +2 -0
  820. package/dist/utils/index.d.ts.map +1 -1
  821. package/dist/utils/index.js +3 -1
  822. package/dist/utils/index.js.map +1 -1
  823. package/dist/utils/validation.d.ts +28 -0
  824. package/dist/utils/validation.d.ts.map +1 -0
  825. package/dist/utils/validation.js +56 -0
  826. package/dist/utils/validation.js.map +1 -0
  827. package/package.json +31 -17
  828. package/dist/core/coverage-analyzer.d.ts +0 -50
  829. package/dist/core/coverage-analyzer.d.ts.map +0 -1
  830. package/dist/core/coverage-analyzer.js +0 -146
  831. package/dist/core/coverage-analyzer.js.map +0 -1
  832. package/dist/core/quality-gate.d.ts +0 -81
  833. package/dist/core/quality-gate.d.ts.map +0 -1
  834. package/dist/core/quality-gate.js +0 -254
  835. package/dist/core/quality-gate.js.map +0 -1
  836. package/dist/optimization/sublinear-solver.d.ts +0 -72
  837. package/dist/optimization/sublinear-solver.d.ts.map +0 -1
  838. package/dist/optimization/sublinear-solver.js +0 -263
  839. package/dist/optimization/sublinear-solver.js.map +0 -1
  840. package/dist/scripts/verifyComplexity.d.ts +0 -8
  841. package/dist/scripts/verifyComplexity.d.ts.map +0 -1
  842. package/dist/scripts/verifyComplexity.js +0 -56
  843. package/dist/scripts/verifyComplexity.js.map +0 -1
  844. package/dist/utils/sublinear/coverageOptimizer.d.ts +0 -84
  845. package/dist/utils/sublinear/coverageOptimizer.d.ts.map +0 -1
  846. package/dist/utils/sublinear/coverageOptimizer.js +0 -415
  847. package/dist/utils/sublinear/coverageOptimizer.js.map +0 -1
  848. package/dist/utils/sublinear/index.d.ts +0 -50
  849. package/dist/utils/sublinear/index.d.ts.map +0 -1
  850. package/dist/utils/sublinear/index.js +0 -390
  851. package/dist/utils/sublinear/index.js.map +0 -1
  852. package/dist/utils/sublinear/matrixSolver.d.ts +0 -132
  853. package/dist/utils/sublinear/matrixSolver.d.ts.map +0 -1
  854. package/dist/utils/sublinear/matrixSolver.js +0 -642
  855. package/dist/utils/sublinear/matrixSolver.js.map +0 -1
  856. package/dist/utils/sublinear/temporalPredictor.d.ts +0 -195
  857. package/dist/utils/sublinear/temporalPredictor.d.ts.map +0 -1
  858. package/dist/utils/sublinear/temporalPredictor.js +0 -474
  859. package/dist/utils/sublinear/temporalPredictor.js.map +0 -1
  860. package/dist/utils/sublinear/testSelector.d.ts +0 -81
  861. package/dist/utils/sublinear/testSelector.d.ts.map +0 -1
  862. package/dist/utils/sublinear/testSelector.js +0 -303
  863. package/dist/utils/sublinear/testSelector.js.map +0 -1
@@ -0,0 +1,1417 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.SwarmMemoryManager = void 0;
40
+ const sqlite3_1 = __importDefault(require("sqlite3"));
41
+ const path = __importStar(require("path"));
42
+ const fs = __importStar(require("fs-extra"));
43
+ const AccessControl_1 = require("./AccessControl");
44
+ /**
45
+ * SwarmMemoryManager - Manages persistent memory for agent swarm coordination
46
+ *
47
+ * Features:
48
+ * - SQLite-based persistent storage with 12-table schema
49
+ * - Partitioned key-value store
50
+ * - TTL-based expiration with different policies per table
51
+ * - Hint/blackboard pattern support
52
+ * - Pattern-based retrieval
53
+ * - 5-level access control (private, team, swarm, public, system)
54
+ * - Agent-based permissions (read, write, delete, share)
55
+ * - Event stream tracking (30-day TTL)
56
+ * - Workflow checkpointing (never expires)
57
+ * - Consensus gating (7-day TTL)
58
+ * - Artifact manifests (never expires)
59
+ * - GOAP planning support
60
+ * - OODA loop tracking
61
+ * - Session resumability
62
+ * - Agent lifecycle management
63
+ */
64
+ class SwarmMemoryManager {
65
+ constructor(dbPath = ':memory:') {
66
+ this.db = null;
67
+ this.initialized = false;
68
+ // TTL policy constants (in seconds)
69
+ this.TTL_POLICY = {
70
+ artifacts: 0, // Never expire
71
+ shared: 1800, // 30 minutes
72
+ patterns: 604800, // 7 days
73
+ events: 2592000, // 30 days
74
+ workflow_state: 0, // Never expire
75
+ consensus: 604800 // 7 days
76
+ };
77
+ this.dbPath = dbPath;
78
+ this.accessControl = new AccessControl_1.AccessControl();
79
+ this.aclCache = new Map();
80
+ }
81
+ run(sql, params = []) {
82
+ return new Promise((resolve, reject) => {
83
+ this.db.run(sql, params, (err) => {
84
+ if (err)
85
+ reject(err);
86
+ else
87
+ resolve();
88
+ });
89
+ });
90
+ }
91
+ get(sql, params = []) {
92
+ return new Promise((resolve, reject) => {
93
+ this.db.get(sql, params, (err, row) => {
94
+ if (err)
95
+ reject(err);
96
+ else
97
+ resolve(row);
98
+ });
99
+ });
100
+ }
101
+ all(sql, params = []) {
102
+ return new Promise((resolve, reject) => {
103
+ this.db.all(sql, params, (err, rows) => {
104
+ if (err)
105
+ reject(err);
106
+ else
107
+ resolve((rows || []));
108
+ });
109
+ });
110
+ }
111
+ async initialize() {
112
+ if (this.initialized) {
113
+ return;
114
+ }
115
+ // Ensure directory exists for file-based DB
116
+ if (this.dbPath !== ':memory:') {
117
+ await fs.ensureDir(path.dirname(this.dbPath));
118
+ }
119
+ this.db = new sqlite3_1.default.Database(this.dbPath);
120
+ // Create memory entries table with access control fields
121
+ await this.run(`
122
+ CREATE TABLE IF NOT EXISTS memory_entries (
123
+ key TEXT NOT NULL,
124
+ partition TEXT NOT NULL DEFAULT 'default',
125
+ value TEXT NOT NULL,
126
+ metadata TEXT,
127
+ created_at INTEGER NOT NULL,
128
+ expires_at INTEGER,
129
+ owner TEXT,
130
+ access_level TEXT DEFAULT 'private',
131
+ team_id TEXT,
132
+ swarm_id TEXT,
133
+ PRIMARY KEY (key, partition)
134
+ )
135
+ `);
136
+ // Create ACL table for advanced permissions
137
+ await this.run(`
138
+ CREATE TABLE IF NOT EXISTS memory_acl (
139
+ resource_id TEXT PRIMARY KEY,
140
+ owner TEXT NOT NULL,
141
+ access_level TEXT NOT NULL,
142
+ team_id TEXT,
143
+ swarm_id TEXT,
144
+ granted_permissions TEXT,
145
+ blocked_agents TEXT,
146
+ created_at INTEGER NOT NULL,
147
+ updated_at INTEGER NOT NULL
148
+ )
149
+ `);
150
+ // Create hints table for blackboard pattern
151
+ await this.run(`
152
+ CREATE TABLE IF NOT EXISTS hints (
153
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
154
+ key TEXT NOT NULL,
155
+ value TEXT NOT NULL,
156
+ created_at INTEGER NOT NULL,
157
+ expires_at INTEGER
158
+ )
159
+ `);
160
+ // Table 3: Events (TTL: 30 days)
161
+ await this.run(`
162
+ CREATE TABLE IF NOT EXISTS events (
163
+ id TEXT PRIMARY KEY,
164
+ type TEXT NOT NULL,
165
+ payload TEXT NOT NULL,
166
+ timestamp INTEGER NOT NULL,
167
+ source TEXT NOT NULL,
168
+ ttl INTEGER NOT NULL DEFAULT ${this.TTL_POLICY.events},
169
+ expires_at INTEGER
170
+ )
171
+ `);
172
+ // Table 4: Workflow State (TTL: never expires)
173
+ await this.run(`
174
+ CREATE TABLE IF NOT EXISTS workflow_state (
175
+ id TEXT PRIMARY KEY,
176
+ step TEXT NOT NULL,
177
+ status TEXT NOT NULL,
178
+ checkpoint TEXT NOT NULL,
179
+ sha TEXT NOT NULL,
180
+ ttl INTEGER NOT NULL DEFAULT ${this.TTL_POLICY.workflow_state},
181
+ created_at INTEGER NOT NULL,
182
+ updated_at INTEGER NOT NULL
183
+ )
184
+ `);
185
+ // Table 5: Patterns (TTL: 7 days)
186
+ await this.run(`
187
+ CREATE TABLE IF NOT EXISTS patterns (
188
+ id TEXT PRIMARY KEY,
189
+ pattern TEXT NOT NULL UNIQUE,
190
+ confidence REAL NOT NULL,
191
+ usage_count INTEGER NOT NULL DEFAULT 0,
192
+ metadata TEXT,
193
+ ttl INTEGER NOT NULL DEFAULT ${this.TTL_POLICY.patterns},
194
+ expires_at INTEGER,
195
+ created_at INTEGER NOT NULL
196
+ )
197
+ `);
198
+ // Table 6: Consensus State (TTL: 7 days)
199
+ await this.run(`
200
+ CREATE TABLE IF NOT EXISTS consensus_state (
201
+ id TEXT PRIMARY KEY,
202
+ decision TEXT NOT NULL,
203
+ proposer TEXT NOT NULL,
204
+ votes TEXT NOT NULL,
205
+ quorum INTEGER NOT NULL,
206
+ status TEXT NOT NULL,
207
+ version INTEGER NOT NULL DEFAULT 1,
208
+ ttl INTEGER NOT NULL DEFAULT ${this.TTL_POLICY.consensus},
209
+ expires_at INTEGER,
210
+ created_at INTEGER NOT NULL
211
+ )
212
+ `);
213
+ // Table 7: Performance Metrics
214
+ await this.run(`
215
+ CREATE TABLE IF NOT EXISTS performance_metrics (
216
+ id TEXT PRIMARY KEY,
217
+ metric TEXT NOT NULL,
218
+ value REAL NOT NULL,
219
+ unit TEXT NOT NULL,
220
+ timestamp INTEGER NOT NULL,
221
+ agent_id TEXT
222
+ )
223
+ `);
224
+ // Table 8: Artifacts (TTL: never expires)
225
+ await this.run(`
226
+ CREATE TABLE IF NOT EXISTS artifacts (
227
+ id TEXT PRIMARY KEY,
228
+ kind TEXT NOT NULL,
229
+ path TEXT NOT NULL,
230
+ sha256 TEXT NOT NULL,
231
+ tags TEXT NOT NULL,
232
+ metadata TEXT,
233
+ ttl INTEGER NOT NULL DEFAULT ${this.TTL_POLICY.artifacts},
234
+ created_at INTEGER NOT NULL
235
+ )
236
+ `);
237
+ // Table 9: Sessions (for resumability)
238
+ await this.run(`
239
+ CREATE TABLE IF NOT EXISTS sessions (
240
+ id TEXT PRIMARY KEY,
241
+ mode TEXT NOT NULL,
242
+ state TEXT NOT NULL,
243
+ checkpoints TEXT NOT NULL,
244
+ created_at INTEGER NOT NULL,
245
+ last_resumed INTEGER
246
+ )
247
+ `);
248
+ // Table 10: Agent Registry
249
+ await this.run(`
250
+ CREATE TABLE IF NOT EXISTS agent_registry (
251
+ id TEXT PRIMARY KEY,
252
+ type TEXT NOT NULL,
253
+ capabilities TEXT NOT NULL,
254
+ status TEXT NOT NULL,
255
+ performance TEXT NOT NULL,
256
+ created_at INTEGER NOT NULL,
257
+ updated_at INTEGER NOT NULL
258
+ )
259
+ `);
260
+ // Table 11: GOAP State
261
+ await this.run(`
262
+ CREATE TABLE IF NOT EXISTS goap_goals (
263
+ id TEXT PRIMARY KEY,
264
+ conditions TEXT NOT NULL,
265
+ cost INTEGER NOT NULL,
266
+ priority TEXT,
267
+ created_at INTEGER NOT NULL
268
+ )
269
+ `);
270
+ await this.run(`
271
+ CREATE TABLE IF NOT EXISTS goap_actions (
272
+ id TEXT PRIMARY KEY,
273
+ preconditions TEXT NOT NULL,
274
+ effects TEXT NOT NULL,
275
+ cost INTEGER NOT NULL,
276
+ agent_type TEXT,
277
+ created_at INTEGER NOT NULL
278
+ )
279
+ `);
280
+ await this.run(`
281
+ CREATE TABLE IF NOT EXISTS goap_plans (
282
+ id TEXT PRIMARY KEY,
283
+ goal_id TEXT NOT NULL,
284
+ sequence TEXT NOT NULL,
285
+ total_cost INTEGER NOT NULL,
286
+ created_at INTEGER NOT NULL
287
+ )
288
+ `);
289
+ // Table 12: OODA Cycles
290
+ await this.run(`
291
+ CREATE TABLE IF NOT EXISTS ooda_cycles (
292
+ id TEXT PRIMARY KEY,
293
+ phase TEXT NOT NULL,
294
+ observations TEXT,
295
+ orientation TEXT,
296
+ decision TEXT,
297
+ action TEXT,
298
+ timestamp INTEGER NOT NULL,
299
+ completed INTEGER DEFAULT 0,
300
+ result TEXT
301
+ )
302
+ `);
303
+ // Create indexes for performance
304
+ await this.run(`CREATE INDEX IF NOT EXISTS idx_memory_partition ON memory_entries(partition)`);
305
+ await this.run(`CREATE INDEX IF NOT EXISTS idx_memory_expires ON memory_entries(expires_at)`);
306
+ await this.run(`CREATE INDEX IF NOT EXISTS idx_memory_owner ON memory_entries(owner)`);
307
+ await this.run(`CREATE INDEX IF NOT EXISTS idx_memory_access ON memory_entries(access_level)`);
308
+ await this.run(`CREATE INDEX IF NOT EXISTS idx_hints_key ON hints(key)`);
309
+ await this.run(`CREATE INDEX IF NOT EXISTS idx_hints_expires ON hints(expires_at)`);
310
+ await this.run(`CREATE INDEX IF NOT EXISTS idx_acl_owner ON memory_acl(owner)`);
311
+ await this.run(`CREATE INDEX IF NOT EXISTS idx_events_type ON events(type)`);
312
+ await this.run(`CREATE INDEX IF NOT EXISTS idx_events_source ON events(source)`);
313
+ await this.run(`CREATE INDEX IF NOT EXISTS idx_events_expires ON events(expires_at)`);
314
+ await this.run(`CREATE INDEX IF NOT EXISTS idx_workflow_status ON workflow_state(status)`);
315
+ await this.run(`CREATE INDEX IF NOT EXISTS idx_patterns_confidence ON patterns(confidence)`);
316
+ await this.run(`CREATE INDEX IF NOT EXISTS idx_patterns_expires ON patterns(expires_at)`);
317
+ await this.run(`CREATE INDEX IF NOT EXISTS idx_consensus_status ON consensus_state(status)`);
318
+ await this.run(`CREATE INDEX IF NOT EXISTS idx_consensus_expires ON consensus_state(expires_at)`);
319
+ await this.run(`CREATE INDEX IF NOT EXISTS idx_metrics_metric ON performance_metrics(metric)`);
320
+ await this.run(`CREATE INDEX IF NOT EXISTS idx_metrics_agent ON performance_metrics(agent_id)`);
321
+ await this.run(`CREATE INDEX IF NOT EXISTS idx_artifacts_kind ON artifacts(kind)`);
322
+ await this.run(`CREATE INDEX IF NOT EXISTS idx_agent_status ON agent_registry(status)`);
323
+ await this.run(`CREATE INDEX IF NOT EXISTS idx_ooda_phase ON ooda_cycles(phase)`);
324
+ this.initialized = true;
325
+ }
326
+ async store(key, value, options = {}) {
327
+ if (!this.db) {
328
+ throw new Error('Memory manager not initialized');
329
+ }
330
+ const partition = options.partition || 'default';
331
+ const owner = options.owner || 'system';
332
+ const accessLevel = options.accessLevel || AccessControl_1.AccessLevel.PRIVATE;
333
+ const createdAt = Date.now();
334
+ const expiresAt = options.ttl ? createdAt + (options.ttl * 1000) : null;
335
+ const metadata = options.metadata ? JSON.stringify(options.metadata) : null;
336
+ // Check write permission if updating existing entry
337
+ const existing = await this.get(`SELECT owner, access_level, team_id, swarm_id FROM memory_entries WHERE key = ? AND partition = ?`, [key, partition]);
338
+ if (existing && options.owner) {
339
+ // Verify write permission
340
+ const permCheck = this.accessControl.checkPermission({
341
+ agentId: options.owner,
342
+ resourceOwner: existing.owner,
343
+ accessLevel: existing.access_level,
344
+ permission: AccessControl_1.Permission.WRITE,
345
+ teamId: options.teamId,
346
+ resourceTeamId: existing.team_id,
347
+ swarmId: options.swarmId,
348
+ resourceSwarmId: existing.swarm_id
349
+ });
350
+ if (!permCheck.allowed) {
351
+ throw new AccessControl_1.AccessControlError(`Write denied: ${permCheck.reason}`);
352
+ }
353
+ }
354
+ await this.run(`INSERT OR REPLACE INTO memory_entries
355
+ (key, partition, value, metadata, created_at, expires_at, owner, access_level, team_id, swarm_id)
356
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
357
+ key,
358
+ partition,
359
+ JSON.stringify(value),
360
+ metadata,
361
+ createdAt,
362
+ expiresAt,
363
+ owner,
364
+ accessLevel,
365
+ options.teamId || null,
366
+ options.swarmId || null
367
+ ]);
368
+ }
369
+ async retrieve(key, options = {}) {
370
+ if (!this.db) {
371
+ throw new Error('Memory manager not initialized');
372
+ }
373
+ const partition = options.partition || 'default';
374
+ const now = Date.now();
375
+ let query = `SELECT value, owner, access_level, team_id, swarm_id
376
+ FROM memory_entries WHERE key = ? AND partition = ?`;
377
+ const params = [key, partition];
378
+ if (!options.includeExpired) {
379
+ query += ` AND (expires_at IS NULL OR expires_at > ?)`;
380
+ params.push(now);
381
+ }
382
+ const row = await this.get(query, params);
383
+ if (!row) {
384
+ return null;
385
+ }
386
+ // Check read permission if agentId provided
387
+ if (options.agentId) {
388
+ const permCheck = this.accessControl.checkPermission({
389
+ agentId: options.agentId,
390
+ resourceOwner: row.owner,
391
+ accessLevel: row.access_level,
392
+ permission: AccessControl_1.Permission.READ,
393
+ teamId: options.teamId,
394
+ resourceTeamId: row.team_id,
395
+ swarmId: options.swarmId,
396
+ resourceSwarmId: row.swarm_id,
397
+ isSystemAgent: options.isSystemAgent
398
+ });
399
+ if (!permCheck.allowed) {
400
+ throw new AccessControl_1.AccessControlError(`Read denied: ${permCheck.reason}`);
401
+ }
402
+ }
403
+ return JSON.parse(row.value);
404
+ }
405
+ async query(pattern, options = {}) {
406
+ if (!this.db) {
407
+ throw new Error('Memory manager not initialized');
408
+ }
409
+ const partition = options.partition || 'default';
410
+ const now = Date.now();
411
+ let query = `SELECT key, value, partition, created_at, expires_at, owner, access_level, team_id, swarm_id
412
+ FROM memory_entries
413
+ WHERE partition = ? AND key LIKE ?`;
414
+ const params = [partition, pattern];
415
+ if (!options.includeExpired) {
416
+ query += ` AND (expires_at IS NULL OR expires_at > ?)`;
417
+ params.push(now);
418
+ }
419
+ const rows = await this.all(query, params);
420
+ // Filter by access control if agentId provided
421
+ const filteredRows = options.agentId
422
+ ? rows.filter((row) => {
423
+ const permCheck = this.accessControl.checkPermission({
424
+ agentId: options.agentId,
425
+ resourceOwner: row.owner,
426
+ accessLevel: row.access_level,
427
+ permission: AccessControl_1.Permission.READ,
428
+ teamId: options.teamId,
429
+ resourceTeamId: row.team_id,
430
+ swarmId: options.swarmId,
431
+ resourceSwarmId: row.swarm_id,
432
+ isSystemAgent: options.isSystemAgent
433
+ });
434
+ return permCheck.allowed;
435
+ })
436
+ : rows;
437
+ return filteredRows.map((row) => ({
438
+ key: row.key,
439
+ value: JSON.parse(row.value),
440
+ partition: row.partition,
441
+ createdAt: row.created_at,
442
+ expiresAt: row.expires_at,
443
+ owner: row.owner,
444
+ accessLevel: row.access_level,
445
+ teamId: row.team_id,
446
+ swarmId: row.swarm_id
447
+ }));
448
+ }
449
+ async delete(key, partition = 'default', options = {}) {
450
+ if (!this.db) {
451
+ throw new Error('Memory manager not initialized');
452
+ }
453
+ // Check delete permission if agentId provided
454
+ if (options.agentId) {
455
+ const row = await this.get(`SELECT owner, access_level, team_id, swarm_id FROM memory_entries WHERE key = ? AND partition = ?`, [key, partition]);
456
+ if (row) {
457
+ const permCheck = this.accessControl.checkPermission({
458
+ agentId: options.agentId,
459
+ resourceOwner: row.owner,
460
+ accessLevel: row.access_level,
461
+ permission: AccessControl_1.Permission.DELETE,
462
+ teamId: options.teamId,
463
+ resourceTeamId: row.team_id,
464
+ swarmId: options.swarmId,
465
+ resourceSwarmId: row.swarm_id,
466
+ isSystemAgent: options.isSystemAgent
467
+ });
468
+ if (!permCheck.allowed) {
469
+ throw new AccessControl_1.AccessControlError(`Delete denied: ${permCheck.reason}`);
470
+ }
471
+ }
472
+ }
473
+ await this.run(`DELETE FROM memory_entries WHERE key = ? AND partition = ?`, [key, partition]);
474
+ // Clean up ACL if exists
475
+ const resourceId = `${partition}:${key}`;
476
+ await this.run(`DELETE FROM memory_acl WHERE resource_id = ?`, [resourceId]);
477
+ this.aclCache.delete(resourceId);
478
+ }
479
+ async clear(partition = 'default') {
480
+ if (!this.db) {
481
+ throw new Error('Memory manager not initialized');
482
+ }
483
+ await this.run(`DELETE FROM memory_entries WHERE partition = ?`, [partition]);
484
+ }
485
+ async postHint(hint) {
486
+ if (!this.db) {
487
+ throw new Error('Memory manager not initialized');
488
+ }
489
+ const createdAt = Date.now();
490
+ const expiresAt = hint.ttl ? createdAt + (hint.ttl * 1000) : null;
491
+ await this.run(`INSERT INTO hints (key, value, created_at, expires_at) VALUES (?, ?, ?, ?)`, [hint.key, JSON.stringify(hint.value), createdAt, expiresAt]);
492
+ }
493
+ async readHints(pattern) {
494
+ if (!this.db) {
495
+ throw new Error('Memory manager not initialized');
496
+ }
497
+ const now = Date.now();
498
+ const rows = await this.all(`SELECT key, value, created_at, expires_at
499
+ FROM hints
500
+ WHERE key LIKE ? AND (expires_at IS NULL OR expires_at > ?)
501
+ ORDER BY created_at DESC`, [pattern, now]);
502
+ return rows.map((row) => ({
503
+ key: row.key,
504
+ value: JSON.parse(row.value),
505
+ createdAt: row.created_at,
506
+ expiresAt: row.expires_at
507
+ }));
508
+ }
509
+ async cleanExpired() {
510
+ if (!this.db) {
511
+ throw new Error('Memory manager not initialized');
512
+ }
513
+ const now = Date.now();
514
+ // Clean memory entries
515
+ await this.run(`DELETE FROM memory_entries WHERE expires_at IS NOT NULL AND expires_at <= ?`, [now]);
516
+ // Clean hints
517
+ await this.run(`DELETE FROM hints WHERE expires_at IS NOT NULL AND expires_at <= ?`, [now]);
518
+ // Clean events
519
+ await this.run(`DELETE FROM events WHERE expires_at IS NOT NULL AND expires_at <= ?`, [now]);
520
+ // Clean patterns
521
+ await this.run(`DELETE FROM patterns WHERE expires_at IS NOT NULL AND expires_at <= ?`, [now]);
522
+ // Clean consensus
523
+ await this.run(`DELETE FROM consensus_state WHERE expires_at IS NOT NULL AND expires_at <= ?`, [now]);
524
+ return 0;
525
+ }
526
+ async close() {
527
+ if (this.db) {
528
+ return new Promise((resolve, reject) => {
529
+ this.db.close((err) => {
530
+ if (err)
531
+ reject(err);
532
+ else {
533
+ this.db = null;
534
+ this.initialized = false;
535
+ resolve();
536
+ }
537
+ });
538
+ });
539
+ }
540
+ }
541
+ async stats() {
542
+ if (!this.db) {
543
+ throw new Error('Memory manager not initialized');
544
+ }
545
+ const entriesCount = await this.get(`SELECT COUNT(*) as count FROM memory_entries`);
546
+ const hintsCount = await this.get(`SELECT COUNT(*) as count FROM hints`);
547
+ const eventsCount = await this.get(`SELECT COUNT(*) as count FROM events`);
548
+ const workflowsCount = await this.get(`SELECT COUNT(*) as count FROM workflow_state`);
549
+ const patternsCount = await this.get(`SELECT COUNT(*) as count FROM patterns`);
550
+ const consensusCount = await this.get(`SELECT COUNT(*) as count FROM consensus_state`);
551
+ const metricsCount = await this.get(`SELECT COUNT(*) as count FROM performance_metrics`);
552
+ const artifactsCount = await this.get(`SELECT COUNT(*) as count FROM artifacts`);
553
+ const sessionsCount = await this.get(`SELECT COUNT(*) as count FROM sessions`);
554
+ const agentsCount = await this.get(`SELECT COUNT(*) as count FROM agent_registry`);
555
+ const goapGoalsCount = await this.get(`SELECT COUNT(*) as count FROM goap_goals`);
556
+ const goapActionsCount = await this.get(`SELECT COUNT(*) as count FROM goap_actions`);
557
+ const goapPlansCount = await this.get(`SELECT COUNT(*) as count FROM goap_plans`);
558
+ const oodaCyclesCount = await this.get(`SELECT COUNT(*) as count FROM ooda_cycles`);
559
+ const partitionsResult = await this.all(`SELECT DISTINCT partition FROM memory_entries`);
560
+ const accessLevelsResult = await this.all(`SELECT access_level, COUNT(*) as count FROM memory_entries GROUP BY access_level`);
561
+ const accessLevels = {};
562
+ accessLevelsResult.forEach(row => {
563
+ accessLevels[row.access_level] = row.count;
564
+ });
565
+ return {
566
+ totalEntries: entriesCount?.count || 0,
567
+ totalHints: hintsCount?.count || 0,
568
+ totalEvents: eventsCount?.count || 0,
569
+ totalWorkflows: workflowsCount?.count || 0,
570
+ totalPatterns: patternsCount?.count || 0,
571
+ totalConsensus: consensusCount?.count || 0,
572
+ totalMetrics: metricsCount?.count || 0,
573
+ totalArtifacts: artifactsCount?.count || 0,
574
+ totalSessions: sessionsCount?.count || 0,
575
+ totalAgents: agentsCount?.count || 0,
576
+ totalGOAPGoals: goapGoalsCount?.count || 0,
577
+ totalGOAPActions: goapActionsCount?.count || 0,
578
+ totalGOAPPlans: goapPlansCount?.count || 0,
579
+ totalOODACycles: oodaCyclesCount?.count || 0,
580
+ partitions: partitionsResult.map((row) => row.partition),
581
+ accessLevels
582
+ };
583
+ }
584
+ // ============================================================================
585
+ // Table 3: Events (TTL: 30 days)
586
+ // ============================================================================
587
+ async storeEvent(event) {
588
+ if (!this.db) {
589
+ throw new Error('Memory manager not initialized');
590
+ }
591
+ const id = event.id || `event-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
592
+ const timestamp = event.timestamp || Date.now();
593
+ const ttl = event.ttl !== undefined ? event.ttl : this.TTL_POLICY.events;
594
+ const expiresAt = ttl > 0 ? timestamp + (ttl * 1000) : null;
595
+ await this.run(`INSERT INTO events (id, type, payload, timestamp, source, ttl, expires_at)
596
+ VALUES (?, ?, ?, ?, ?, ?, ?)`, [id, event.type, JSON.stringify(event.payload), timestamp, event.source, ttl, expiresAt]);
597
+ return id;
598
+ }
599
+ async queryEvents(type) {
600
+ if (!this.db) {
601
+ throw new Error('Memory manager not initialized');
602
+ }
603
+ const now = Date.now();
604
+ const rows = await this.all(`SELECT id, type, payload, timestamp, source, ttl
605
+ FROM events
606
+ WHERE type = ? AND (expires_at IS NULL OR expires_at > ?)
607
+ ORDER BY timestamp DESC`, [type, now]);
608
+ return rows.map((row) => ({
609
+ id: row.id,
610
+ type: row.type,
611
+ payload: JSON.parse(row.payload),
612
+ timestamp: row.timestamp,
613
+ source: row.source,
614
+ ttl: row.ttl
615
+ }));
616
+ }
617
+ async getEventsBySource(source) {
618
+ if (!this.db) {
619
+ throw new Error('Memory manager not initialized');
620
+ }
621
+ const now = Date.now();
622
+ const rows = await this.all(`SELECT id, type, payload, timestamp, source, ttl
623
+ FROM events
624
+ WHERE source = ? AND (expires_at IS NULL OR expires_at > ?)
625
+ ORDER BY timestamp DESC`, [source, now]);
626
+ return rows.map((row) => ({
627
+ id: row.id,
628
+ type: row.type,
629
+ payload: JSON.parse(row.payload),
630
+ timestamp: row.timestamp,
631
+ source: row.source,
632
+ ttl: row.ttl
633
+ }));
634
+ }
635
+ // ============================================================================
636
+ // Table 4: Workflow State (TTL: never expires)
637
+ // ============================================================================
638
+ async storeWorkflowState(workflow) {
639
+ if (!this.db) {
640
+ throw new Error('Memory manager not initialized');
641
+ }
642
+ const now = Date.now();
643
+ const ttl = workflow.ttl !== undefined ? workflow.ttl : this.TTL_POLICY.workflow_state;
644
+ await this.run(`INSERT OR REPLACE INTO workflow_state (id, step, status, checkpoint, sha, ttl, created_at, updated_at)
645
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)`, [workflow.id, workflow.step, workflow.status, JSON.stringify(workflow.checkpoint), workflow.sha, ttl, now, now]);
646
+ }
647
+ async getWorkflowState(id) {
648
+ if (!this.db) {
649
+ throw new Error('Memory manager not initialized');
650
+ }
651
+ const row = await this.get(`SELECT id, step, status, checkpoint, sha, ttl, created_at, updated_at
652
+ FROM workflow_state
653
+ WHERE id = ?`, [id]);
654
+ if (!row) {
655
+ throw new Error(`Workflow state not found: ${id}`);
656
+ }
657
+ return {
658
+ id: row.id,
659
+ step: row.step,
660
+ status: row.status,
661
+ checkpoint: JSON.parse(row.checkpoint),
662
+ sha: row.sha,
663
+ ttl: row.ttl,
664
+ createdAt: row.created_at,
665
+ updatedAt: row.updated_at
666
+ };
667
+ }
668
+ async updateWorkflowState(id, updates) {
669
+ if (!this.db) {
670
+ throw new Error('Memory manager not initialized');
671
+ }
672
+ const current = await this.getWorkflowState(id);
673
+ const now = Date.now();
674
+ await this.run(`UPDATE workflow_state
675
+ SET step = ?, status = ?, checkpoint = ?, sha = ?, updated_at = ?
676
+ WHERE id = ?`, [
677
+ updates.step || current.step,
678
+ updates.status || current.status,
679
+ JSON.stringify(updates.checkpoint || current.checkpoint),
680
+ updates.sha || current.sha,
681
+ now,
682
+ id
683
+ ]);
684
+ }
685
+ async queryWorkflowsByStatus(status) {
686
+ if (!this.db) {
687
+ throw new Error('Memory manager not initialized');
688
+ }
689
+ const rows = await this.all(`SELECT id, step, status, checkpoint, sha, ttl, created_at, updated_at
690
+ FROM workflow_state
691
+ WHERE status = ?`, [status]);
692
+ return rows.map((row) => ({
693
+ id: row.id,
694
+ step: row.step,
695
+ status: row.status,
696
+ checkpoint: JSON.parse(row.checkpoint),
697
+ sha: row.sha,
698
+ ttl: row.ttl,
699
+ createdAt: row.created_at,
700
+ updatedAt: row.updated_at
701
+ }));
702
+ }
703
+ // ============================================================================
704
+ // Table 5: Patterns (TTL: 7 days)
705
+ // ============================================================================
706
+ async storePattern(pattern) {
707
+ if (!this.db) {
708
+ throw new Error('Memory manager not initialized');
709
+ }
710
+ const id = pattern.id || `pattern-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
711
+ const now = Date.now();
712
+ const ttl = pattern.ttl !== undefined ? pattern.ttl : this.TTL_POLICY.patterns;
713
+ const expiresAt = ttl > 0 ? now + (ttl * 1000) : null;
714
+ await this.run(`INSERT OR REPLACE INTO patterns (id, pattern, confidence, usage_count, metadata, ttl, expires_at, created_at)
715
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)`, [
716
+ id,
717
+ pattern.pattern,
718
+ pattern.confidence,
719
+ pattern.usageCount,
720
+ pattern.metadata ? JSON.stringify(pattern.metadata) : null,
721
+ ttl,
722
+ expiresAt,
723
+ now
724
+ ]);
725
+ return id;
726
+ }
727
+ async getPattern(patternName) {
728
+ if (!this.db) {
729
+ throw new Error('Memory manager not initialized');
730
+ }
731
+ const now = Date.now();
732
+ const row = await this.get(`SELECT id, pattern, confidence, usage_count, metadata, ttl, created_at
733
+ FROM patterns
734
+ WHERE pattern = ? AND (expires_at IS NULL OR expires_at > ?)`, [patternName, now]);
735
+ if (!row) {
736
+ throw new Error(`Pattern not found: ${patternName}`);
737
+ }
738
+ return {
739
+ id: row.id,
740
+ pattern: row.pattern,
741
+ confidence: row.confidence,
742
+ usageCount: row.usage_count,
743
+ metadata: row.metadata ? JSON.parse(row.metadata) : undefined,
744
+ ttl: row.ttl,
745
+ createdAt: row.created_at
746
+ };
747
+ }
748
+ async incrementPatternUsage(patternName) {
749
+ if (!this.db) {
750
+ throw new Error('Memory manager not initialized');
751
+ }
752
+ await this.run(`UPDATE patterns
753
+ SET usage_count = usage_count + 1
754
+ WHERE pattern = ?`, [patternName]);
755
+ }
756
+ async queryPatternsByConfidence(threshold) {
757
+ if (!this.db) {
758
+ throw new Error('Memory manager not initialized');
759
+ }
760
+ const now = Date.now();
761
+ const rows = await this.all(`SELECT id, pattern, confidence, usage_count, metadata, ttl, created_at
762
+ FROM patterns
763
+ WHERE confidence >= ? AND (expires_at IS NULL OR expires_at > ?)
764
+ ORDER BY confidence DESC`, [threshold, now]);
765
+ return rows.map((row) => ({
766
+ id: row.id,
767
+ pattern: row.pattern,
768
+ confidence: row.confidence,
769
+ usageCount: row.usage_count,
770
+ metadata: row.metadata ? JSON.parse(row.metadata) : undefined,
771
+ ttl: row.ttl,
772
+ createdAt: row.created_at
773
+ }));
774
+ }
775
+ // ============================================================================
776
+ // Table 6: Consensus State (TTL: 7 days)
777
+ // ============================================================================
778
+ async createConsensusProposal(proposal) {
779
+ if (!this.db) {
780
+ throw new Error('Memory manager not initialized');
781
+ }
782
+ const now = Date.now();
783
+ const ttl = proposal.ttl !== undefined ? proposal.ttl : this.TTL_POLICY.consensus;
784
+ const expiresAt = ttl > 0 ? now + (ttl * 1000) : null;
785
+ await this.run(`INSERT INTO consensus_state (id, decision, proposer, votes, quorum, status, version, ttl, expires_at, created_at)
786
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
787
+ proposal.id,
788
+ proposal.decision,
789
+ proposal.proposer,
790
+ JSON.stringify(proposal.votes),
791
+ proposal.quorum,
792
+ proposal.status,
793
+ proposal.version || 1,
794
+ ttl,
795
+ expiresAt,
796
+ now
797
+ ]);
798
+ }
799
+ async getConsensusProposal(id) {
800
+ if (!this.db) {
801
+ throw new Error('Memory manager not initialized');
802
+ }
803
+ const now = Date.now();
804
+ const row = await this.get(`SELECT id, decision, proposer, votes, quorum, status, version, ttl, created_at
805
+ FROM consensus_state
806
+ WHERE id = ? AND (expires_at IS NULL OR expires_at > ?)`, [id, now]);
807
+ if (!row) {
808
+ throw new Error(`Consensus proposal not found: ${id}`);
809
+ }
810
+ return {
811
+ id: row.id,
812
+ decision: row.decision,
813
+ proposer: row.proposer,
814
+ votes: JSON.parse(row.votes),
815
+ quorum: row.quorum,
816
+ status: row.status,
817
+ version: row.version,
818
+ ttl: row.ttl,
819
+ createdAt: row.created_at
820
+ };
821
+ }
822
+ async voteOnConsensus(proposalId, agentId) {
823
+ if (!this.db) {
824
+ throw new Error('Memory manager not initialized');
825
+ }
826
+ const proposal = await this.getConsensusProposal(proposalId);
827
+ if (!proposal.votes.includes(agentId)) {
828
+ proposal.votes.push(agentId);
829
+ }
830
+ const approved = proposal.votes.length >= proposal.quorum;
831
+ if (approved) {
832
+ proposal.status = 'approved';
833
+ }
834
+ await this.run(`UPDATE consensus_state
835
+ SET votes = ?, status = ?
836
+ WHERE id = ?`, [JSON.stringify(proposal.votes), proposal.status, proposalId]);
837
+ return approved;
838
+ }
839
+ async queryConsensusProposals(status) {
840
+ if (!this.db) {
841
+ throw new Error('Memory manager not initialized');
842
+ }
843
+ const now = Date.now();
844
+ const rows = await this.all(`SELECT id, decision, proposer, votes, quorum, status, version, ttl, created_at
845
+ FROM consensus_state
846
+ WHERE status = ? AND (expires_at IS NULL OR expires_at > ?)`, [status, now]);
847
+ return rows.map((row) => ({
848
+ id: row.id,
849
+ decision: row.decision,
850
+ proposer: row.proposer,
851
+ votes: JSON.parse(row.votes),
852
+ quorum: row.quorum,
853
+ status: row.status,
854
+ version: row.version,
855
+ ttl: row.ttl,
856
+ createdAt: row.created_at
857
+ }));
858
+ }
859
+ // ============================================================================
860
+ // Table 7: Performance Metrics
861
+ // ============================================================================
862
+ async storePerformanceMetric(metric) {
863
+ if (!this.db) {
864
+ throw new Error('Memory manager not initialized');
865
+ }
866
+ const id = metric.id || `metric-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
867
+ const timestamp = metric.timestamp || Date.now();
868
+ await this.run(`INSERT INTO performance_metrics (id, metric, value, unit, timestamp, agent_id)
869
+ VALUES (?, ?, ?, ?, ?, ?)`, [id, metric.metric, metric.value, metric.unit, timestamp, metric.agentId || null]);
870
+ return id;
871
+ }
872
+ async queryPerformanceMetrics(metricName) {
873
+ if (!this.db) {
874
+ throw new Error('Memory manager not initialized');
875
+ }
876
+ const rows = await this.all(`SELECT id, metric, value, unit, timestamp, agent_id
877
+ FROM performance_metrics
878
+ WHERE metric = ?
879
+ ORDER BY timestamp DESC`, [metricName]);
880
+ return rows.map((row) => ({
881
+ id: row.id,
882
+ metric: row.metric,
883
+ value: row.value,
884
+ unit: row.unit,
885
+ timestamp: row.timestamp,
886
+ agentId: row.agent_id
887
+ }));
888
+ }
889
+ async getMetricsByAgent(agentId) {
890
+ if (!this.db) {
891
+ throw new Error('Memory manager not initialized');
892
+ }
893
+ const rows = await this.all(`SELECT id, metric, value, unit, timestamp, agent_id
894
+ FROM performance_metrics
895
+ WHERE agent_id = ?
896
+ ORDER BY timestamp DESC`, [agentId]);
897
+ return rows.map((row) => ({
898
+ id: row.id,
899
+ metric: row.metric,
900
+ value: row.value,
901
+ unit: row.unit,
902
+ timestamp: row.timestamp,
903
+ agentId: row.agent_id
904
+ }));
905
+ }
906
+ async getAverageMetric(metricName) {
907
+ if (!this.db) {
908
+ throw new Error('Memory manager not initialized');
909
+ }
910
+ const row = await this.get(`SELECT AVG(value) as avg FROM performance_metrics WHERE metric = ?`, [metricName]);
911
+ return row?.avg || 0;
912
+ }
913
+ // ============================================================================
914
+ // Table 8: Artifacts (TTL: never expires)
915
+ // ============================================================================
916
+ async createArtifact(artifact) {
917
+ if (!this.db) {
918
+ throw new Error('Memory manager not initialized');
919
+ }
920
+ const now = Date.now();
921
+ const ttl = artifact.ttl !== undefined ? artifact.ttl : this.TTL_POLICY.artifacts;
922
+ await this.run(`INSERT INTO artifacts (id, kind, path, sha256, tags, metadata, ttl, created_at)
923
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)`, [
924
+ artifact.id,
925
+ artifact.kind,
926
+ artifact.path,
927
+ artifact.sha256,
928
+ JSON.stringify(artifact.tags),
929
+ artifact.metadata ? JSON.stringify(artifact.metadata) : null,
930
+ ttl,
931
+ now
932
+ ]);
933
+ }
934
+ async getArtifact(id) {
935
+ if (!this.db) {
936
+ throw new Error('Memory manager not initialized');
937
+ }
938
+ const row = await this.get(`SELECT id, kind, path, sha256, tags, metadata, ttl, created_at
939
+ FROM artifacts
940
+ WHERE id = ?`, [id]);
941
+ if (!row) {
942
+ throw new Error(`Artifact not found: ${id}`);
943
+ }
944
+ return {
945
+ id: row.id,
946
+ kind: row.kind,
947
+ path: row.path,
948
+ sha256: row.sha256,
949
+ tags: JSON.parse(row.tags),
950
+ metadata: row.metadata ? JSON.parse(row.metadata) : undefined,
951
+ ttl: row.ttl,
952
+ createdAt: row.created_at
953
+ };
954
+ }
955
+ async queryArtifactsByKind(kind) {
956
+ if (!this.db) {
957
+ throw new Error('Memory manager not initialized');
958
+ }
959
+ const rows = await this.all(`SELECT id, kind, path, sha256, tags, metadata, ttl, created_at
960
+ FROM artifacts
961
+ WHERE kind = ?`, [kind]);
962
+ return rows.map((row) => ({
963
+ id: row.id,
964
+ kind: row.kind,
965
+ path: row.path,
966
+ sha256: row.sha256,
967
+ tags: JSON.parse(row.tags),
968
+ metadata: row.metadata ? JSON.parse(row.metadata) : undefined,
969
+ ttl: row.ttl,
970
+ createdAt: row.created_at
971
+ }));
972
+ }
973
+ async queryArtifactsByTag(tag) {
974
+ if (!this.db) {
975
+ throw new Error('Memory manager not initialized');
976
+ }
977
+ const rows = await this.all(`SELECT id, kind, path, sha256, tags, metadata, ttl, created_at
978
+ FROM artifacts
979
+ WHERE tags LIKE ?`, [`%"${tag}"%`]);
980
+ return rows.map((row) => ({
981
+ id: row.id,
982
+ kind: row.kind,
983
+ path: row.path,
984
+ sha256: row.sha256,
985
+ tags: JSON.parse(row.tags),
986
+ metadata: row.metadata ? JSON.parse(row.metadata) : undefined,
987
+ ttl: row.ttl,
988
+ createdAt: row.created_at
989
+ }));
990
+ }
991
+ // ============================================================================
992
+ // Table 9: Sessions (resumability)
993
+ // ============================================================================
994
+ async createSession(session) {
995
+ if (!this.db) {
996
+ throw new Error('Memory manager not initialized');
997
+ }
998
+ const now = Date.now();
999
+ await this.run(`INSERT INTO sessions (id, mode, state, checkpoints, created_at, last_resumed)
1000
+ VALUES (?, ?, ?, ?, ?, ?)`, [
1001
+ session.id,
1002
+ session.mode,
1003
+ JSON.stringify(session.state),
1004
+ JSON.stringify(session.checkpoints),
1005
+ now,
1006
+ null
1007
+ ]);
1008
+ }
1009
+ async getSession(id) {
1010
+ if (!this.db) {
1011
+ throw new Error('Memory manager not initialized');
1012
+ }
1013
+ const row = await this.get(`SELECT id, mode, state, checkpoints, created_at, last_resumed
1014
+ FROM sessions
1015
+ WHERE id = ?`, [id]);
1016
+ if (!row) {
1017
+ throw new Error(`Session not found: ${id}`);
1018
+ }
1019
+ return {
1020
+ id: row.id,
1021
+ mode: row.mode,
1022
+ state: JSON.parse(row.state),
1023
+ checkpoints: JSON.parse(row.checkpoints),
1024
+ createdAt: row.created_at,
1025
+ lastResumed: row.last_resumed
1026
+ };
1027
+ }
1028
+ async addSessionCheckpoint(sessionId, checkpoint) {
1029
+ if (!this.db) {
1030
+ throw new Error('Memory manager not initialized');
1031
+ }
1032
+ const session = await this.getSession(sessionId);
1033
+ session.checkpoints.push(checkpoint);
1034
+ await this.run(`UPDATE sessions
1035
+ SET checkpoints = ?
1036
+ WHERE id = ?`, [JSON.stringify(session.checkpoints), sessionId]);
1037
+ }
1038
+ async getLatestCheckpoint(sessionId) {
1039
+ const session = await this.getSession(sessionId);
1040
+ return session.checkpoints.length > 0
1041
+ ? session.checkpoints[session.checkpoints.length - 1]
1042
+ : undefined;
1043
+ }
1044
+ async markSessionResumed(sessionId) {
1045
+ if (!this.db) {
1046
+ throw new Error('Memory manager not initialized');
1047
+ }
1048
+ const now = Date.now();
1049
+ await this.run(`UPDATE sessions
1050
+ SET last_resumed = ?
1051
+ WHERE id = ?`, [now, sessionId]);
1052
+ }
1053
+ // ============================================================================
1054
+ // Table 10: Agent Registry
1055
+ // ============================================================================
1056
+ async registerAgent(agent) {
1057
+ if (!this.db) {
1058
+ throw new Error('Memory manager not initialized');
1059
+ }
1060
+ const now = Date.now();
1061
+ await this.run(`INSERT INTO agent_registry (id, type, capabilities, status, performance, created_at, updated_at)
1062
+ VALUES (?, ?, ?, ?, ?, ?, ?)`, [
1063
+ agent.id,
1064
+ agent.type,
1065
+ JSON.stringify(agent.capabilities),
1066
+ agent.status,
1067
+ JSON.stringify(agent.performance),
1068
+ now,
1069
+ now
1070
+ ]);
1071
+ }
1072
+ async getAgent(id) {
1073
+ if (!this.db) {
1074
+ throw new Error('Memory manager not initialized');
1075
+ }
1076
+ const row = await this.get(`SELECT id, type, capabilities, status, performance, created_at, updated_at
1077
+ FROM agent_registry
1078
+ WHERE id = ?`, [id]);
1079
+ if (!row) {
1080
+ throw new Error(`Agent not found: ${id}`);
1081
+ }
1082
+ return {
1083
+ id: row.id,
1084
+ type: row.type,
1085
+ capabilities: JSON.parse(row.capabilities),
1086
+ status: row.status,
1087
+ performance: JSON.parse(row.performance),
1088
+ createdAt: row.created_at,
1089
+ updatedAt: row.updated_at
1090
+ };
1091
+ }
1092
+ async updateAgentStatus(agentId, status) {
1093
+ if (!this.db) {
1094
+ throw new Error('Memory manager not initialized');
1095
+ }
1096
+ const now = Date.now();
1097
+ await this.run(`UPDATE agent_registry
1098
+ SET status = ?, updated_at = ?
1099
+ WHERE id = ?`, [status, now, agentId]);
1100
+ }
1101
+ async queryAgentsByStatus(status) {
1102
+ if (!this.db) {
1103
+ throw new Error('Memory manager not initialized');
1104
+ }
1105
+ const rows = await this.all(`SELECT id, type, capabilities, status, performance, created_at, updated_at
1106
+ FROM agent_registry
1107
+ WHERE status = ?`, [status]);
1108
+ return rows.map((row) => ({
1109
+ id: row.id,
1110
+ type: row.type,
1111
+ capabilities: JSON.parse(row.capabilities),
1112
+ status: row.status,
1113
+ performance: JSON.parse(row.performance),
1114
+ createdAt: row.created_at,
1115
+ updatedAt: row.updated_at
1116
+ }));
1117
+ }
1118
+ async updateAgentPerformance(agentId, performance) {
1119
+ if (!this.db) {
1120
+ throw new Error('Memory manager not initialized');
1121
+ }
1122
+ const now = Date.now();
1123
+ await this.run(`UPDATE agent_registry
1124
+ SET performance = ?, updated_at = ?
1125
+ WHERE id = ?`, [JSON.stringify(performance), now, agentId]);
1126
+ }
1127
+ // ============================================================================
1128
+ // Table 11: GOAP State
1129
+ // ============================================================================
1130
+ async storeGOAPGoal(goal) {
1131
+ if (!this.db) {
1132
+ throw new Error('Memory manager not initialized');
1133
+ }
1134
+ const now = Date.now();
1135
+ await this.run(`INSERT INTO goap_goals (id, conditions, cost, priority, created_at)
1136
+ VALUES (?, ?, ?, ?, ?)`, [goal.id, JSON.stringify(goal.conditions), goal.cost, goal.priority || null, now]);
1137
+ }
1138
+ async getGOAPGoal(id) {
1139
+ if (!this.db) {
1140
+ throw new Error('Memory manager not initialized');
1141
+ }
1142
+ const row = await this.get(`SELECT id, conditions, cost, priority, created_at
1143
+ FROM goap_goals
1144
+ WHERE id = ?`, [id]);
1145
+ if (!row) {
1146
+ throw new Error(`GOAP goal not found: ${id}`);
1147
+ }
1148
+ return {
1149
+ id: row.id,
1150
+ conditions: JSON.parse(row.conditions),
1151
+ cost: row.cost,
1152
+ priority: row.priority,
1153
+ createdAt: row.created_at
1154
+ };
1155
+ }
1156
+ async storeGOAPAction(action) {
1157
+ if (!this.db) {
1158
+ throw new Error('Memory manager not initialized');
1159
+ }
1160
+ const now = Date.now();
1161
+ await this.run(`INSERT INTO goap_actions (id, preconditions, effects, cost, agent_type, created_at)
1162
+ VALUES (?, ?, ?, ?, ?, ?)`, [
1163
+ action.id,
1164
+ JSON.stringify(action.preconditions),
1165
+ JSON.stringify(action.effects),
1166
+ action.cost,
1167
+ action.agentType || null,
1168
+ now
1169
+ ]);
1170
+ }
1171
+ async getGOAPAction(id) {
1172
+ if (!this.db) {
1173
+ throw new Error('Memory manager not initialized');
1174
+ }
1175
+ const row = await this.get(`SELECT id, preconditions, effects, cost, agent_type, created_at
1176
+ FROM goap_actions
1177
+ WHERE id = ?`, [id]);
1178
+ if (!row) {
1179
+ throw new Error(`GOAP action not found: ${id}`);
1180
+ }
1181
+ return {
1182
+ id: row.id,
1183
+ preconditions: JSON.parse(row.preconditions),
1184
+ effects: JSON.parse(row.effects),
1185
+ cost: row.cost,
1186
+ agentType: row.agent_type,
1187
+ createdAt: row.created_at
1188
+ };
1189
+ }
1190
+ async storeGOAPPlan(plan) {
1191
+ if (!this.db) {
1192
+ throw new Error('Memory manager not initialized');
1193
+ }
1194
+ const now = Date.now();
1195
+ await this.run(`INSERT INTO goap_plans (id, goal_id, sequence, total_cost, created_at)
1196
+ VALUES (?, ?, ?, ?, ?)`, [plan.id, plan.goalId, JSON.stringify(plan.sequence), plan.totalCost, now]);
1197
+ }
1198
+ async getGOAPPlan(id) {
1199
+ if (!this.db) {
1200
+ throw new Error('Memory manager not initialized');
1201
+ }
1202
+ const row = await this.get(`SELECT id, goal_id, sequence, total_cost, created_at
1203
+ FROM goap_plans
1204
+ WHERE id = ?`, [id]);
1205
+ if (!row) {
1206
+ throw new Error(`GOAP plan not found: ${id}`);
1207
+ }
1208
+ return {
1209
+ id: row.id,
1210
+ goalId: row.goal_id,
1211
+ sequence: JSON.parse(row.sequence),
1212
+ totalCost: row.total_cost,
1213
+ createdAt: row.created_at
1214
+ };
1215
+ }
1216
+ // ============================================================================
1217
+ // Table 12: OODA Cycles
1218
+ // ============================================================================
1219
+ async storeOODACycle(cycle) {
1220
+ if (!this.db) {
1221
+ throw new Error('Memory manager not initialized');
1222
+ }
1223
+ await this.run(`INSERT INTO ooda_cycles (id, phase, observations, orientation, decision, action, timestamp, completed, result)
1224
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
1225
+ cycle.id,
1226
+ cycle.phase,
1227
+ cycle.observations ? JSON.stringify(cycle.observations) : null,
1228
+ cycle.orientation ? JSON.stringify(cycle.orientation) : null,
1229
+ cycle.decision ? JSON.stringify(cycle.decision) : null,
1230
+ cycle.action ? JSON.stringify(cycle.action) : null,
1231
+ cycle.timestamp,
1232
+ cycle.completed ? 1 : 0,
1233
+ cycle.result ? JSON.stringify(cycle.result) : null
1234
+ ]);
1235
+ }
1236
+ async getOODACycle(id) {
1237
+ if (!this.db) {
1238
+ throw new Error('Memory manager not initialized');
1239
+ }
1240
+ const row = await this.get(`SELECT id, phase, observations, orientation, decision, action, timestamp, completed, result
1241
+ FROM ooda_cycles
1242
+ WHERE id = ?`, [id]);
1243
+ if (!row) {
1244
+ throw new Error(`OODA cycle not found: ${id}`);
1245
+ }
1246
+ return {
1247
+ id: row.id,
1248
+ phase: row.phase,
1249
+ observations: row.observations ? JSON.parse(row.observations) : undefined,
1250
+ orientation: row.orientation ? JSON.parse(row.orientation) : undefined,
1251
+ decision: row.decision ? JSON.parse(row.decision) : undefined,
1252
+ action: row.action ? JSON.parse(row.action) : undefined,
1253
+ timestamp: row.timestamp,
1254
+ completed: row.completed === 1,
1255
+ result: row.result ? JSON.parse(row.result) : undefined
1256
+ };
1257
+ }
1258
+ async updateOODAPhase(cycleId, phase, data) {
1259
+ if (!this.db) {
1260
+ throw new Error('Memory manager not initialized');
1261
+ }
1262
+ const fieldMap = {
1263
+ observe: 'observations',
1264
+ orient: 'orientation',
1265
+ decide: 'decision',
1266
+ act: 'action'
1267
+ };
1268
+ const field = fieldMap[phase];
1269
+ await this.run(`UPDATE ooda_cycles
1270
+ SET phase = ?, ${field} = ?
1271
+ WHERE id = ?`, [phase, JSON.stringify(data), cycleId]);
1272
+ }
1273
+ async completeOODACycle(cycleId, result) {
1274
+ if (!this.db) {
1275
+ throw new Error('Memory manager not initialized');
1276
+ }
1277
+ await this.run(`UPDATE ooda_cycles
1278
+ SET completed = 1, result = ?
1279
+ WHERE id = ?`, [JSON.stringify(result), cycleId]);
1280
+ }
1281
+ async queryOODACyclesByPhase(phase) {
1282
+ if (!this.db) {
1283
+ throw new Error('Memory manager not initialized');
1284
+ }
1285
+ const rows = await this.all(`SELECT id, phase, observations, orientation, decision, action, timestamp, completed, result
1286
+ FROM ooda_cycles
1287
+ WHERE phase = ?`, [phase]);
1288
+ return rows.map((row) => ({
1289
+ id: row.id,
1290
+ phase: row.phase,
1291
+ observations: row.observations ? JSON.parse(row.observations) : undefined,
1292
+ orientation: row.orientation ? JSON.parse(row.orientation) : undefined,
1293
+ decision: row.decision ? JSON.parse(row.decision) : undefined,
1294
+ action: row.action ? JSON.parse(row.action) : undefined,
1295
+ timestamp: row.timestamp,
1296
+ completed: row.completed === 1,
1297
+ result: row.result ? JSON.parse(row.result) : undefined
1298
+ }));
1299
+ }
1300
+ // ACL Management Methods
1301
+ /**
1302
+ * Store ACL for a memory entry
1303
+ */
1304
+ async storeACL(acl) {
1305
+ if (!this.db) {
1306
+ throw new Error('Memory manager not initialized');
1307
+ }
1308
+ const grantedPerms = acl.grantedPermissions ? JSON.stringify(acl.grantedPermissions) : null;
1309
+ const blockedAgents = acl.blockedAgents ? JSON.stringify(acl.blockedAgents) : null;
1310
+ await this.run(`INSERT OR REPLACE INTO memory_acl
1311
+ (resource_id, owner, access_level, team_id, swarm_id, granted_permissions, blocked_agents, created_at, updated_at)
1312
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
1313
+ acl.resourceId,
1314
+ acl.owner,
1315
+ acl.accessLevel,
1316
+ acl.teamId || null,
1317
+ acl.swarmId || null,
1318
+ grantedPerms,
1319
+ blockedAgents,
1320
+ acl.createdAt.getTime(),
1321
+ acl.updatedAt.getTime()
1322
+ ]);
1323
+ this.aclCache.set(acl.resourceId, acl);
1324
+ }
1325
+ /**
1326
+ * Retrieve ACL for a memory entry
1327
+ */
1328
+ async getACL(resourceId) {
1329
+ if (!this.db) {
1330
+ throw new Error('Memory manager not initialized');
1331
+ }
1332
+ // Check cache first
1333
+ if (this.aclCache.has(resourceId)) {
1334
+ return this.aclCache.get(resourceId);
1335
+ }
1336
+ const row = await this.get(`SELECT * FROM memory_acl WHERE resource_id = ?`, [resourceId]);
1337
+ if (!row) {
1338
+ return null;
1339
+ }
1340
+ const acl = {
1341
+ resourceId: row.resource_id,
1342
+ owner: row.owner,
1343
+ accessLevel: row.access_level,
1344
+ teamId: row.team_id,
1345
+ swarmId: row.swarm_id,
1346
+ grantedPermissions: row.granted_permissions ? JSON.parse(row.granted_permissions) : undefined,
1347
+ blockedAgents: row.blocked_agents ? JSON.parse(row.blocked_agents) : undefined,
1348
+ createdAt: new Date(row.created_at),
1349
+ updatedAt: new Date(row.updated_at)
1350
+ };
1351
+ this.aclCache.set(resourceId, acl);
1352
+ return acl;
1353
+ }
1354
+ /**
1355
+ * Update ACL for a memory entry
1356
+ */
1357
+ async updateACL(resourceId, updates) {
1358
+ const existing = await this.getACL(resourceId);
1359
+ if (!existing) {
1360
+ throw new Error(`ACL not found for resource: ${resourceId}`);
1361
+ }
1362
+ const updated = this.accessControl.updateACL(existing, updates);
1363
+ await this.storeACL(updated);
1364
+ }
1365
+ /**
1366
+ * Grant permission to an agent
1367
+ */
1368
+ async grantPermission(resourceId, agentId, permissions) {
1369
+ const existing = await this.getACL(resourceId);
1370
+ if (!existing) {
1371
+ throw new Error(`ACL not found for resource: ${resourceId}`);
1372
+ }
1373
+ const updated = this.accessControl.grantPermission(existing, agentId, permissions);
1374
+ await this.storeACL(updated);
1375
+ }
1376
+ /**
1377
+ * Revoke permission from an agent
1378
+ */
1379
+ async revokePermission(resourceId, agentId, permissions) {
1380
+ const existing = await this.getACL(resourceId);
1381
+ if (!existing) {
1382
+ throw new Error(`ACL not found for resource: ${resourceId}`);
1383
+ }
1384
+ const updated = this.accessControl.revokePermission(existing, agentId, permissions);
1385
+ await this.storeACL(updated);
1386
+ }
1387
+ /**
1388
+ * Block an agent from accessing a resource
1389
+ */
1390
+ async blockAgent(resourceId, agentId) {
1391
+ const existing = await this.getACL(resourceId);
1392
+ if (!existing) {
1393
+ throw new Error(`ACL not found for resource: ${resourceId}`);
1394
+ }
1395
+ const updated = this.accessControl.blockAgent(existing, agentId);
1396
+ await this.storeACL(updated);
1397
+ }
1398
+ /**
1399
+ * Unblock an agent
1400
+ */
1401
+ async unblockAgent(resourceId, agentId) {
1402
+ const existing = await this.getACL(resourceId);
1403
+ if (!existing) {
1404
+ throw new Error(`ACL not found for resource: ${resourceId}`);
1405
+ }
1406
+ const updated = this.accessControl.unblockAgent(existing, agentId);
1407
+ await this.storeACL(updated);
1408
+ }
1409
+ /**
1410
+ * Get access control instance for direct usage
1411
+ */
1412
+ getAccessControl() {
1413
+ return this.accessControl;
1414
+ }
1415
+ }
1416
+ exports.SwarmMemoryManager = SwarmMemoryManager;
1417
+ //# sourceMappingURL=SwarmMemoryManager.js.map