agentic-qe 3.14.5 → 3.14.7

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 (494) hide show
  1. package/.claude/skills/skills-manifest.json +1 -1
  2. package/CHANGELOG.md +150 -0
  3. package/assets/skills/skills-manifest.json +1 -1
  4. package/dist/adapters/ag-ui/event-types.d.ts +1 -1
  5. package/dist/audit/witness-chain-hash.d.ts +18 -0
  6. package/dist/audit/witness-chain-hash.js +37 -0
  7. package/dist/audit/witness-chain-repair.d.ts +71 -0
  8. package/dist/audit/witness-chain-repair.js +203 -0
  9. package/dist/audit/witness-chain-verifier.d.ts +152 -0
  10. package/dist/audit/witness-chain-verifier.js +293 -0
  11. package/dist/audit/witness-chain.d.ts +10 -43
  12. package/dist/audit/witness-chain.js +16 -106
  13. package/dist/audit/witness-findings.js +4 -1
  14. package/dist/cli/bundle.js +8 -8
  15. package/dist/cli/chunks/adapter-TVQKH65T.js +2 -0
  16. package/dist/cli/chunks/agent-booster-wasm-AK2W76RG.js +2 -0
  17. package/dist/cli/chunks/{agent-handler-V6CZ7Q6S.js → agent-handler-MGZCWHIY.js} +2 -2
  18. package/dist/cli/chunks/{agent-memory-branch-ZMD6ULC3.js → agent-memory-branch-JZ54MCSP.js} +2 -2
  19. package/dist/cli/chunks/aqe-learning-engine-ULGTVVWE.js +2 -0
  20. package/dist/cli/chunks/{arena-QLSBESC7.js → arena-CUVH3V7H.js} +2 -2
  21. package/dist/cli/chunks/{arena-4UPAEHFT.js → arena-YSWTKBCL.js} +4 -4
  22. package/dist/cli/chunks/audit-LVU76QGA.js +4 -0
  23. package/dist/cli/chunks/base-W42BURDL.js +2 -0
  24. package/dist/cli/chunks/{better-sqlite3-4DSBPDRH.js → better-sqlite3-DB3LOJQU.js} +2 -2
  25. package/dist/cli/chunks/{brain-handler-GBY4EZ4P.js → brain-handler-SD63KOQ6.js} +3 -3
  26. package/dist/cli/chunks/{branch-enumerator-XYBVXCNO.js → branch-enumerator-4MNOPUC7.js} +2 -2
  27. package/dist/cli/chunks/{browser-32F6MREU.js → browser-OLPNTWQE.js} +2 -2
  28. package/dist/cli/chunks/browser-workflow-HKGHFFFT.js +2 -0
  29. package/dist/cli/chunks/{chunk-WLXK2KNU.js → chunk-23CX7JNL.js} +2 -2
  30. package/dist/cli/chunks/{chunk-O3JTQ7N4.js → chunk-25P6JA6V.js} +1 -1
  31. package/dist/cli/chunks/{chunk-DO6EI5KB.js → chunk-2G63VIJE.js} +1 -1
  32. package/dist/cli/chunks/{chunk-G3L5L6YQ.js → chunk-2IMSJ7IO.js} +1 -1
  33. package/dist/cli/chunks/{chunk-RD6TEZ64.js → chunk-36VKMAMN.js} +2 -2
  34. package/dist/cli/chunks/{chunk-KIP6WZGV.js → chunk-3M7J4U74.js} +3 -3
  35. package/dist/cli/chunks/chunk-3QJU4Q4R.js +5 -0
  36. package/dist/cli/chunks/{chunk-2JGEZHWY.js → chunk-4EKV7PHB.js} +2 -2
  37. package/dist/cli/chunks/chunk-4INST4ZL.js +4 -0
  38. package/dist/cli/chunks/{chunk-DPBRWP4J.js → chunk-53BXTTRO.js} +3 -3
  39. package/dist/cli/chunks/chunk-5D7ZFWDS.js +2 -0
  40. package/dist/cli/chunks/{chunk-XLAUGSW7.js → chunk-5FSLMYAC.js} +2 -2
  41. package/dist/cli/chunks/chunk-5GFKTJ65.js +4 -0
  42. package/dist/cli/chunks/{chunk-WOIGKU2N.js → chunk-5U6N4V5M.js} +11 -11
  43. package/dist/cli/chunks/{chunk-PSPKSUF6.js → chunk-6EGS77BB.js} +1 -1
  44. package/dist/cli/chunks/{chunk-QIRL6B3C.js → chunk-6PJPQGF4.js} +2 -2
  45. package/dist/cli/chunks/{chunk-I6X3EGJI.js → chunk-6RD44SCE.js} +1 -1
  46. package/dist/cli/chunks/{chunk-IGBEJ4UJ.js → chunk-74IOEOMH.js} +2 -2
  47. package/dist/cli/chunks/{chunk-E3W6XQ57.js → chunk-77QZHIVX.js} +2 -2
  48. package/dist/cli/chunks/{chunk-R74ZKREV.js → chunk-7EZ2Z2CK.js} +1 -1
  49. package/dist/cli/chunks/{chunk-UTBYJ4RF.js → chunk-7MIOK72I.js} +18 -35
  50. package/dist/cli/chunks/{chunk-URVHZPWY.js → chunk-7QYOTUOX.js} +2 -2
  51. package/dist/cli/chunks/{chunk-K27SU3RE.js → chunk-A2VUCUTT.js} +2 -2
  52. package/dist/cli/chunks/{chunk-2KJQ2UQE.js → chunk-A3DK3XNZ.js} +1 -1
  53. package/dist/cli/chunks/{chunk-5D36YHS3.js → chunk-A5MA7A23.js} +4 -4
  54. package/dist/cli/chunks/{chunk-WJHWH5D2.js → chunk-AEUEMVJK.js} +2 -2
  55. package/dist/cli/chunks/{chunk-6CR4VQBQ.js → chunk-AJUBT4NP.js} +2 -2
  56. package/dist/cli/chunks/chunk-B2YGVSOP.js +27 -0
  57. package/dist/cli/chunks/{chunk-D6OUCB2H.js → chunk-B4I43GE2.js} +2 -2
  58. package/dist/cli/chunks/{chunk-WK7B4B6Y.js → chunk-BD7FEUN3.js} +2 -2
  59. package/dist/cli/chunks/{chunk-OEIQTWQP.js → chunk-BE4KALTE.js} +1 -1
  60. package/dist/cli/chunks/{chunk-JROVR6YS.js → chunk-BEFTQVEW.js} +2 -2
  61. package/dist/cli/chunks/{chunk-HBCGYMQU.js → chunk-BLG7SH4A.js} +1 -1
  62. package/dist/cli/chunks/{chunk-2OMLTYQK.js → chunk-C3FXFU2T.js} +1 -1
  63. package/dist/cli/chunks/{chunk-6A44AOGN.js → chunk-CBONQM5D.js} +2 -2
  64. package/dist/cli/chunks/{chunk-73EI4C2E.js → chunk-CQNMGK6Y.js} +2 -2
  65. package/dist/cli/chunks/{chunk-IIAR5S7Q.js → chunk-CVOQ6ESD.js} +2 -2
  66. package/dist/cli/chunks/{chunk-6TU7FEMD.js → chunk-DOBKEXMJ.js} +1 -1
  67. package/dist/cli/chunks/{chunk-BHFR2EXL.js → chunk-DYTQHRUS.js} +1 -1
  68. package/dist/cli/chunks/{chunk-E4AZXCT5.js → chunk-EADSQN5T.js} +1 -1
  69. package/dist/cli/chunks/{chunk-CYE2TJFV.js → chunk-EGOIIUBD.js} +2 -2
  70. package/dist/cli/chunks/{chunk-DKUBQQFG.js → chunk-EIGRV3J6.js} +2 -2
  71. package/dist/cli/chunks/{chunk-RP2ZKPYV.js → chunk-EJ6MMYLK.js} +1 -1
  72. package/dist/cli/chunks/{chunk-HSVKZ5KI.js → chunk-ENK44A6Q.js} +2 -2
  73. package/dist/cli/chunks/{chunk-67YV75XP.js → chunk-EYXE2XKP.js} +2 -2
  74. package/dist/cli/chunks/{chunk-HYEJJJY3.js → chunk-F2OPFVQH.js} +1 -1
  75. package/dist/cli/chunks/{chunk-XUR2M2WB.js → chunk-FBZC4IGB.js} +2 -2
  76. package/dist/cli/chunks/{chunk-BXVAVFGU.js → chunk-FSSR6WBE.js} +2 -2
  77. package/dist/cli/chunks/{chunk-W2XCZU62.js → chunk-FW4DJ4FJ.js} +1 -1
  78. package/dist/cli/chunks/{chunk-KKHYJF5U.js → chunk-FYPX5WBJ.js} +1 -1
  79. package/dist/cli/chunks/{chunk-K7NJHFLZ.js → chunk-G367W7XR.js} +3 -3
  80. package/dist/cli/chunks/{chunk-IUDWEOLX.js → chunk-GLGKQX2V.js} +2 -2
  81. package/dist/cli/chunks/{chunk-JVQBWYHW.js → chunk-GV4DYPJP.js} +2 -2
  82. package/dist/cli/chunks/{chunk-GTKCGPJZ.js → chunk-GVVFTFMB.js} +2 -2
  83. package/dist/cli/chunks/{chunk-AFEDJ3RU.js → chunk-H5RQPO3X.js} +2 -2
  84. package/dist/cli/chunks/{chunk-4FWTLJEP.js → chunk-HPWWYT67.js} +2 -2
  85. package/dist/cli/chunks/{chunk-G3W6BMVJ.js → chunk-HXXHMLJ5.js} +1 -1
  86. package/dist/cli/chunks/{chunk-NU7UTXMP.js → chunk-HYFQUWNB.js} +2 -2
  87. package/dist/cli/chunks/chunk-HYOPJHHW.js +2 -0
  88. package/dist/cli/chunks/{chunk-6LKDHEBY.js → chunk-HZY42OVU.js} +2 -2
  89. package/dist/cli/chunks/{chunk-C3HQL6S4.js → chunk-IAENZ2DR.js} +2 -2
  90. package/dist/cli/chunks/{chunk-M23ZOZVY.js → chunk-IEJ7ZV3M.js} +1 -1
  91. package/dist/cli/chunks/{chunk-RIZVC4XY.js → chunk-IWFFO6VT.js} +2 -2
  92. package/dist/cli/chunks/chunk-J7AQZLIH.js +21 -0
  93. package/dist/cli/chunks/{chunk-3KDL6QDK.js → chunk-JHJUSSAU.js} +2 -2
  94. package/dist/cli/chunks/{chunk-DLF5BOJD.js → chunk-JOZ47MV6.js} +1 -1
  95. package/dist/cli/chunks/{chunk-ELBZON4V.js → chunk-JZT7BU44.js} +2 -2
  96. package/dist/cli/chunks/{chunk-3DDXWYMO.js → chunk-KD2BLA5Y.js} +1 -1
  97. package/dist/cli/chunks/{chunk-VD5IO5EO.js → chunk-KUHLTVWC.js} +1 -1
  98. package/dist/cli/chunks/{chunk-YDFL445W.js → chunk-LU2EDWQK.js} +2 -2
  99. package/dist/cli/chunks/chunk-LXZMP3VX.js +736 -0
  100. package/dist/cli/chunks/{chunk-3YUB5HER.js → chunk-LY7MFGBD.js} +196 -187
  101. package/dist/cli/chunks/chunk-MM56VPNE.js +180 -0
  102. package/dist/cli/chunks/{chunk-37TUN44F.js → chunk-MNQN7UZX.js} +2 -2
  103. package/dist/cli/chunks/{chunk-7DETTOPZ.js → chunk-MQZ53OR3.js} +2 -2
  104. package/dist/cli/chunks/{chunk-BYG36QC5.js → chunk-MT7UNBZ7.js} +2 -2
  105. package/dist/cli/chunks/{chunk-JES6R5KP.js → chunk-MZB2UV2O.js} +1 -1
  106. package/dist/cli/chunks/{chunk-QZMUXJHZ.js → chunk-MZMG6CUJ.js} +2 -2
  107. package/dist/cli/chunks/chunk-N5XOXPHZ.js +4 -0
  108. package/dist/cli/chunks/{chunk-RD2VGOUH.js → chunk-NBLDBVAW.js} +1 -1
  109. package/dist/cli/chunks/{chunk-HVU64GP5.js → chunk-ND4QTZOL.js} +2 -2
  110. package/dist/cli/chunks/{chunk-SQF6HRXR.js → chunk-NHUGHAY6.js} +1 -1
  111. package/dist/cli/chunks/{chunk-TUSSPKRM.js → chunk-NOHWJOBS.js} +1 -1
  112. package/dist/cli/chunks/{chunk-NVYBM3R4.js → chunk-O5V7RHVG.js} +2 -2
  113. package/dist/cli/chunks/{chunk-6VAZAHQG.js → chunk-O6MO5KMR.js} +2 -2
  114. package/dist/cli/chunks/{chunk-IUHB5GVS.js → chunk-OAZX6WFU.js} +2 -2
  115. package/dist/cli/chunks/{chunk-LSUILON7.js → chunk-OEPNNLR4.js} +1 -1
  116. package/dist/cli/chunks/{chunk-IJHCIXJC.js → chunk-OIDWDGLG.js} +2 -2
  117. package/dist/cli/chunks/{chunk-CPC7FN52.js → chunk-ON2UTP2U.js} +2 -2
  118. package/dist/cli/chunks/{chunk-UJWAWIRV.js → chunk-ONR2NXXD.js} +7 -7
  119. package/dist/cli/chunks/{chunk-7VFY7TUR.js → chunk-OXHF3L2T.js} +2 -2
  120. package/dist/cli/chunks/{chunk-QYOGD2VW.js → chunk-OZGIOKEA.js} +1 -1
  121. package/dist/cli/chunks/{chunk-WJTSY5MC.js → chunk-P2UPYSDJ.js} +1 -1
  122. package/dist/cli/chunks/{chunk-52L77RMG.js → chunk-P7XSPP5D.js} +2 -2
  123. package/dist/cli/chunks/{chunk-M5AEL7IS.js → chunk-PCJQCEBA.js} +2 -2
  124. package/dist/cli/chunks/chunk-PELENDDQ.js +2 -0
  125. package/dist/cli/chunks/{chunk-C3Z4VVHP.js → chunk-PYKY22GC.js} +5 -5
  126. package/dist/cli/chunks/{chunk-AF4XKLXO.js → chunk-Q3NSU24F.js} +2 -2
  127. package/dist/cli/chunks/chunk-Q6NTEICT.js +2 -0
  128. package/dist/cli/chunks/chunk-QFETNCNN.js +12 -0
  129. package/dist/cli/chunks/{chunk-KYA5LARK.js → chunk-QGOWNVVG.js} +1 -1
  130. package/dist/cli/chunks/{chunk-Y5L3ES4L.js → chunk-QPLSYEWJ.js} +2 -2
  131. package/dist/cli/chunks/{chunk-F34OAHOM.js → chunk-QQFQDEUE.js} +2 -2
  132. package/dist/cli/chunks/{chunk-EFV4ADMO.js → chunk-QUORH2MG.js} +55 -79
  133. package/dist/cli/chunks/{chunk-QWUXCG2L.js → chunk-QVH5Y7AP.js} +1 -1
  134. package/dist/cli/chunks/{chunk-I2NENQ44.js → chunk-RC2A4JZ5.js} +2 -2
  135. package/dist/cli/chunks/{chunk-XZSMZHM2.js → chunk-RDGPXENG.js} +2 -2
  136. package/dist/cli/chunks/{chunk-N7H767TP.js → chunk-RKI3IQKQ.js} +2 -2
  137. package/dist/cli/chunks/{chunk-LULD4JV2.js → chunk-RKUAWQOF.js} +2 -2
  138. package/dist/cli/chunks/chunk-RLW25X66.js +2 -0
  139. package/dist/cli/chunks/{chunk-UKGXWW64.js → chunk-ROVZSZCS.js} +3 -3
  140. package/dist/cli/chunks/{chunk-EOR2UT72.js → chunk-RT6O2HW2.js} +2 -2
  141. package/dist/cli/chunks/{chunk-75QJ5HWE.js → chunk-SM2YJ2AL.js} +2 -2
  142. package/dist/cli/chunks/{chunk-KO4FNAUR.js → chunk-SRPLERER.js} +3 -3
  143. package/dist/cli/chunks/{chunk-NRE4NAVA.js → chunk-T77GZF4B.js} +1 -1
  144. package/dist/cli/chunks/{chunk-R6IU3EWP.js → chunk-TFK2AYIN.js} +2 -2
  145. package/dist/cli/chunks/chunk-TW3SR4TS.js +2 -0
  146. package/dist/cli/chunks/{chunk-IYTLXUBO.js → chunk-TXSPBLBT.js} +2 -2
  147. package/dist/cli/chunks/chunk-UA7TDVL7.js +12 -0
  148. package/dist/cli/chunks/{chunk-WX6RRIGW.js → chunk-UBJG3IHT.js} +2 -2
  149. package/dist/cli/chunks/{chunk-NQI7FWCS.js → chunk-UFSVUBTR.js} +2 -2
  150. package/dist/cli/chunks/{chunk-FUNGTIF2.js → chunk-UOI6ULCH.js} +2 -2
  151. package/dist/cli/chunks/{chunk-HVXJC3OC.js → chunk-UYUJT6QO.js} +2 -2
  152. package/dist/cli/chunks/{chunk-KEY43ANX.js → chunk-V5AK56DA.js} +2 -2
  153. package/dist/cli/chunks/{chunk-XFPPERA2.js → chunk-V6RE4YRQ.js} +2 -2
  154. package/dist/cli/chunks/{chunk-DDCIYOGT.js → chunk-VW6FRMLW.js} +2 -2
  155. package/dist/cli/chunks/chunk-VXKWNRGA.js +2 -0
  156. package/dist/cli/chunks/{chunk-CVMNJSCB.js → chunk-VYDVI6FZ.js} +2 -2
  157. package/dist/cli/chunks/{chunk-7JZJJA7U.js → chunk-WF6UISKW.js} +3 -3
  158. package/dist/cli/chunks/{chunk-SQKW3B6B.js → chunk-WIH522AP.js} +1 -1
  159. package/dist/cli/chunks/{chunk-KLTP5IDB.js → chunk-WOV6XI3A.js} +1 -1
  160. package/dist/cli/chunks/{chunk-VTOVWHEM.js → chunk-X7ADKL7T.js} +2 -2
  161. package/dist/cli/chunks/{chunk-SX4JLSLV.js → chunk-XBYQ2BS4.js} +2 -2
  162. package/dist/cli/chunks/{chunk-E4EYPYR3.js → chunk-XL5KIYE3.js} +2 -2
  163. package/dist/cli/chunks/{chunk-3VIXOHMS.js → chunk-XWYELBZS.js} +1 -1
  164. package/dist/cli/chunks/{chunk-YQGPQBCX.js → chunk-XYLQZWF6.js} +2 -2
  165. package/dist/cli/chunks/{chunk-XEZIIQYJ.js → chunk-Y6AKKQIQ.js} +1 -1
  166. package/dist/cli/chunks/{chunk-BJPL6THQ.js → chunk-YMW57PEL.js} +1 -1
  167. package/dist/cli/chunks/{chunk-JSZ663MU.js → chunk-YO4ESCB4.js} +1 -1
  168. package/dist/cli/chunks/{chunk-AMMQOV35.js → chunk-YRHTQZU4.js} +2 -2
  169. package/dist/cli/chunks/chunk-Z4Q5PCRZ.js +65 -0
  170. package/dist/cli/chunks/{chunk-RKOUXVZZ.js → chunk-ZELWDJXT.js} +2 -2
  171. package/dist/cli/chunks/{chunk-QRCIZFNK.js → chunk-ZQZD55MN.js} +2 -2
  172. package/dist/cli/chunks/{chunk-UMGFMKDW.js → chunk-ZS4XVJGV.js} +2 -2
  173. package/dist/cli/chunks/{chunk-6ITZZIQX.js → chunk-ZUB5YOCM.js} +2 -2
  174. package/dist/cli/chunks/chunk-ZUOVNFXK.js +2 -0
  175. package/dist/cli/chunks/{chunk-RGGK6VZ7.js → chunk-ZWEKAEEV.js} +1 -1
  176. package/dist/cli/chunks/{ci-RACDAJMR.js → ci-J3TDK5RA.js} +8 -8
  177. package/dist/cli/chunks/{ci-output-EHRSZBKG.js → ci-output-RLS32FUY.js} +2 -2
  178. package/dist/cli/chunks/{circuit-breaker-GBV7M5XG.js → circuit-breaker-MRCC7WCM.js} +2 -2
  179. package/dist/cli/chunks/claude-flow-setup-LIZCEKDF.js +2 -0
  180. package/dist/cli/chunks/client-3BD2DI4N.js +2 -0
  181. package/dist/cli/chunks/{cline-installer-W4NMXJSG.js → cline-installer-T7H6R2RC.js} +2 -2
  182. package/dist/cli/chunks/{code-JWXJMYXB.js → code-XMBLI7OF.js} +3 -3
  183. package/dist/cli/chunks/{code-index-extractor-RVI2IFTM.js → code-index-extractor-QS7BYLEX.js} +2 -2
  184. package/dist/cli/chunks/{codex-installer-3BORJINH.js → codex-installer-6PGT5FM6.js} +6 -6
  185. package/dist/cli/chunks/{completions-A55NCTAO.js → completions-2A3WRXY2.js} +2 -2
  186. package/dist/cli/chunks/{complexity-analyzer-JCXHGGLY.js → complexity-analyzer-23HOOGJ7.js} +2 -2
  187. package/dist/cli/chunks/{continuedev-installer-PUVFMGYW.js → continuedev-installer-4FSF7B3N.js} +2 -2
  188. package/dist/cli/chunks/{copilot-installer-4DCMYWHB.js → copilot-installer-A5GRQQUU.js} +2 -2
  189. package/dist/cli/chunks/core-handlers-C3H2ZCS2.js +2 -0
  190. package/dist/cli/chunks/{cost-tracker-5TV2GGKY.js → cost-tracker-Z4STQ5VB.js} +2 -2
  191. package/dist/cli/chunks/{coverage-NNWM7TX3.js → coverage-NUPP6KZZ.js} +3 -3
  192. package/dist/cli/chunks/cross-domain-router-JCQ7SWDP.js +2 -0
  193. package/dist/cli/chunks/{cursor-installer-4NCHGJGK.js → cursor-installer-FVJ7ROPJ.js} +2 -2
  194. package/dist/cli/chunks/{daemon-QIKCXKWO.js → daemon-7ZZA2MMN.js} +4 -4
  195. package/dist/cli/chunks/{daemon-T4JO4IXP.js → daemon-D662EX5N.js} +3 -3
  196. package/dist/cli/chunks/{dag-attention-scheduler-RPAAIDAD.js → dag-attention-scheduler-IB4TQ2KA.js} +2 -2
  197. package/dist/cli/chunks/{detect-SBEEVDSN.js → detect-LGLBZN4I.js} +2 -2
  198. package/dist/cli/chunks/{dist-node-ZHI6NCSU.js → dist-node-Z3OL42YE.js} +2 -2
  199. package/dist/cli/chunks/{domain-handler-LBC3GJ7Z.js → domain-handler-L3CLNL7U.js} +2 -2
  200. package/dist/cli/chunks/{domain-plugins-H6IZ5USZ.js → domain-plugins-GQ3V5X6L.js} +2 -2
  201. package/dist/cli/chunks/domain-transfer-MFCI76IY.js +2 -0
  202. package/dist/cli/chunks/dream-FTP33IJB.js +2 -0
  203. package/dist/cli/chunks/{embed-and-insert-pattern-AHTR7CRU.js → embed-and-insert-pattern-UGD6USYH.js} +2 -2
  204. package/dist/cli/chunks/{eval-DZU2KISM.js → eval-3B7UIYGY.js} +2 -2
  205. package/dist/cli/chunks/{experience-capture-middleware-5IQCWKSL.js → experience-capture-middleware-3RQ4NYY3.js} +3 -3
  206. package/dist/cli/chunks/{fast-paths-2KLDUWCY.js → fast-paths-QOSAEPYD.js} +2 -2
  207. package/dist/cli/chunks/{feature-flags-7AC3XDZA.js → feature-flags-3S5TH6P4.js} +2 -2
  208. package/dist/cli/chunks/{feature-flags-N6UAEZY4.js → feature-flags-TLF4NKOH.js} +2 -2
  209. package/dist/cli/chunks/{file-discovery-5SDIW4V2.js → file-discovery-AEVMJRNB.js} +2 -2
  210. package/dist/cli/chunks/{fleet-ZIQCAZ2Y.js → fleet-E6WTXWFL.js} +3 -3
  211. package/dist/cli/chunks/{gnn-wrapper-DUMBZJEV.js → gnn-wrapper-MCKH3AUU.js} +2 -2
  212. package/dist/cli/chunks/{heartbeat-handler-6HVM6ZMR.js → heartbeat-handler-U7XENHRR.js} +4 -4
  213. package/dist/cli/chunks/heartbeat-scheduler-HXBJVJL2.js +2 -0
  214. package/dist/cli/chunks/hnsw-adapter-TU6WG2ME.js +2 -0
  215. package/dist/cli/chunks/hnsw-index-MS5KODD7.js +2 -0
  216. package/dist/cli/chunks/{hnsw-legacy-bridge-5DRL5FLX.js → hnsw-legacy-bridge-5GW4SAEI.js} +2 -2
  217. package/dist/cli/chunks/{hnswlib-node-GW67GTCL.js → hnswlib-node-7BLZBK5T.js} +2 -2
  218. package/dist/cli/chunks/{hooks-QHH6FVO4.js → hooks-F3O2SB6H.js} +10 -10
  219. package/dist/cli/chunks/hybrid-backend-HT45LBHC.js +2 -0
  220. package/dist/cli/chunks/{hypergraph-engine-7XDCCVG2.js → hypergraph-engine-PV4EKXHB.js} +2 -2
  221. package/dist/cli/chunks/{hypergraph-handler-QHF7NOU5.js → hypergraph-handler-VOWO5ZTW.js} +3 -3
  222. package/dist/cli/chunks/impact-analyzer-AP4AGTG5.js +2 -0
  223. package/dist/cli/chunks/{init-handler-5UIVOM7K.js → init-handler-ENJ5ONJX.js} +16 -14
  224. package/dist/cli/chunks/init-wizard-I5DFZUQL.js +2 -0
  225. package/dist/cli/chunks/kernel-MISPSPPA.js +2 -0
  226. package/dist/cli/chunks/{kilocode-installer-TGGV6K5Q.js → kilocode-installer-HNNJOOPE.js} +2 -2
  227. package/dist/cli/chunks/{kiro-installer-4XYBHZWW.js → kiro-installer-UZBIQ3IC.js} +2 -2
  228. package/dist/cli/chunks/knowledge-graph-L26JESGE.js +2 -0
  229. package/dist/cli/chunks/{learning-STE5W6BS.js → learning-YMLCVFUT.js} +3 -3
  230. package/dist/cli/chunks/{llm-router-NKF7J3RI.js → llm-router-YWTARCCT.js} +4 -4
  231. package/dist/cli/chunks/llm-router-service-MWGC43ZA.js +2 -0
  232. package/dist/cli/chunks/{load-B2T77UJQ.js → load-DKE3F3IP.js} +2 -2
  233. package/dist/cli/chunks/load-test-H5ISNNM5.js +2 -0
  234. package/dist/cli/chunks/mcp-5PSGIUCW.js +2 -0
  235. package/dist/cli/chunks/{memory-WRFZKG56.js → memory-3L3O6JMM.js} +5 -5
  236. package/dist/cli/chunks/memory-backend-HWDNOBKW.js +2 -0
  237. package/dist/cli/chunks/memory-handlers-ZFDVQZM5.js +2 -0
  238. package/dist/cli/chunks/multi-model-executor-AEEO7IA4.js +14 -0
  239. package/dist/cli/chunks/{opencode-installer-J36EMQU7.js → opencode-installer-ABBO355U.js} +2 -2
  240. package/dist/cli/chunks/orchestrator-E36Q7MKE.js +393 -0
  241. package/dist/cli/chunks/pattern-null-store-GQP6ICWK.js +2 -0
  242. package/dist/cli/chunks/{pattern-usage-recorder-BVMTWI3E.js → pattern-usage-recorder-H4XKSID4.js} +2 -2
  243. package/dist/cli/chunks/{pipeline-OWAHDUAQ.js → pipeline-BGFEHXIN.js} +2 -2
  244. package/dist/cli/chunks/{platform-ANGBFWBV.js → platform-GK7ZVDJI.js} +2 -2
  245. package/dist/cli/chunks/{plugin-OO7ON2YW.js → plugin-CAH2CKI6.js} +2 -2
  246. package/dist/cli/chunks/{prime-radiant-advanced-wasm-HFG3BXWU.js → prime-radiant-advanced-wasm-M5EYRONA.js} +2 -2
  247. package/dist/cli/chunks/{project-root-LNOYVTYY.js → project-root-BSNZC243.js} +2 -2
  248. package/dist/cli/chunks/protocol-executor-AD5A4DAI.js +2 -0
  249. package/dist/cli/chunks/{protocol-handler-CE3Q6LY4.js → protocol-handler-JDSSC2SF.js} +2 -2
  250. package/dist/cli/chunks/{prove-7XPN53PY.js → prove-ANPTOZJE.js} +2 -2
  251. package/dist/cli/chunks/qe-reasoning-bank-W3Z2PKTR.js +2 -0
  252. package/dist/cli/chunks/{quality-TT23JRFX.js → quality-SXWGYRQR.js} +2 -2
  253. package/dist/cli/chunks/{quality-gate-PPPRP255.js → quality-gate-GYNCA4ZY.js} +3 -3
  254. package/dist/cli/chunks/queen-coordinator-HQRHLIJX.js +2 -0
  255. package/dist/cli/chunks/{real-embeddings-EYNZIFJE.js → real-embeddings-WSRYAOZM.js} +2 -2
  256. package/dist/cli/chunks/{ref-validation-QQR64ZXD.js → ref-validation-AZ3LRWEK.js} +2 -2
  257. package/dist/cli/chunks/{roocode-installer-UIGS7ZJD.js → roocode-installer-2QKGFIEU.js} +2 -2
  258. package/dist/cli/chunks/router-MTP5LH4H.js +2 -0
  259. package/dist/cli/chunks/routing-feedback-GWETVB4L.js +2 -0
  260. package/dist/cli/chunks/{routing-handler-6AENUIRG.js → routing-handler-UYDC5MMD.js} +2 -2
  261. package/dist/cli/chunks/{ruvector-commands-5AWMEV34.js → ruvector-commands-QXADPVEY.js} +2 -2
  262. package/dist/cli/chunks/rvf-dual-writer-4UE5S7WP.js +2 -0
  263. package/dist/cli/chunks/rvf-migration-adapter-PHH3HF4Q.js +2 -0
  264. package/dist/cli/chunks/{rvf-migration-coordinator-NWRJ7C22.js → rvf-migration-coordinator-GD4NBFKT.js} +2 -2
  265. package/dist/cli/chunks/rvf-native-adapter-KTLZBUWV.js +2 -0
  266. package/dist/cli/chunks/{rvf-store-integrity-ISKRP563.js → rvf-store-integrity-7SXG66IL.js} +2 -2
  267. package/dist/cli/chunks/safe-db-FWWGAPVE.js +2 -0
  268. package/dist/cli/chunks/schedule-TPA4V4D5.js +2 -0
  269. package/dist/cli/chunks/scheduler-5ZTEPNDD.js +2 -0
  270. package/dist/cli/chunks/{security-325A7FMB.js → security-YKB622PK.js} +3 -3
  271. package/dist/cli/chunks/shared-rvf-adapter-KMLAV7JK.js +2 -0
  272. package/dist/cli/chunks/{shared-rvf-dual-writer-THFDYS2Z.js → shared-rvf-dual-writer-OYY27DFV.js} +2 -2
  273. package/dist/cli/chunks/sqlite-persistence-HPTT624C.js +2 -0
  274. package/dist/cli/chunks/{standalone-memory-UD4MJ6GZ.js → standalone-memory-2DOABVLC.js} +2 -2
  275. package/dist/cli/chunks/{status-handler-CPFTN4XL.js → status-handler-EXRKETV7.js} +2 -2
  276. package/dist/cli/chunks/{structural-health-2MG2IVBL.js → structural-health-2SKK6DU6.js} +2 -2
  277. package/dist/cli/chunks/sync-DQ2YUNI6.js +2 -0
  278. package/dist/cli/chunks/{sync-EE4VVKOW.js → sync-UW7SX7GO.js} +2 -2
  279. package/dist/cli/chunks/{task-handler-7H5OYJG4.js → task-handler-LYQ6WYUY.js} +2 -2
  280. package/dist/cli/chunks/task-handlers-DIJO232S.js +9 -0
  281. package/dist/cli/chunks/test-WRHZMUCW.js +33 -0
  282. package/dist/cli/chunks/{test-scheduling-CHQ4ZLLJ.js → test-scheduling-HI23RXFK.js} +3 -3
  283. package/dist/cli/chunks/token-bootstrap-23SA6SWZ.js +2 -0
  284. package/dist/cli/chunks/{token-usage-EBXUJNRB.js → token-usage-M7RRDPXO.js} +2 -2
  285. package/dist/cli/chunks/{transformers-ZEKS2OJZ.js → transformers-4TC35KKS.js} +2 -2
  286. package/dist/cli/chunks/tree-sitter-wasm-parser-F4LTKAWD.js +2 -0
  287. package/dist/cli/chunks/{types-KYAA5VLV.js → types-NBXV6LXQ.js} +2 -2
  288. package/dist/cli/chunks/unified-memory-OVFEPRPS.js +2 -0
  289. package/dist/cli/chunks/unified-memory-hnsw-KKRSCZHR.js +2 -0
  290. package/dist/cli/chunks/unified-persistence-7GLR4RI3.js +2 -0
  291. package/dist/cli/chunks/{upgrade-UJBJ5AYM.js → upgrade-4BGOU5RM.js} +2 -2
  292. package/dist/cli/chunks/{validate-RUV6YMWS.js → validate-EDWAR63H.js} +2 -2
  293. package/dist/cli/chunks/{validate-swarm-IVEVMGVM.js → validate-swarm-VI72CPR7.js} +2 -2
  294. package/dist/cli/chunks/visual-security-2FUM5GLI.js +2 -0
  295. package/dist/cli/chunks/{web-tree-sitter-AVWA6HKE.js → web-tree-sitter-Y5XBRQXF.js} +2 -2
  296. package/dist/cli/chunks/{windsurf-installer-DAH7HI2W.js → windsurf-installer-VEX23WAF.js} +2 -2
  297. package/dist/cli/chunks/witness-chain-3YNL6YGY.js +2 -0
  298. package/dist/cli/chunks/witness-chain-MH6GA5L6.js +2 -0
  299. package/dist/cli/chunks/witness-chain-repair-MJZGZRWT.js +2 -0
  300. package/dist/cli/chunks/witness-chain-verifier-TTJYXTBE.js +2 -0
  301. package/dist/cli/chunks/{witness-key-manager-JSTBMG43.js → witness-key-manager-EM6YXYOY.js} +2 -2
  302. package/dist/cli/chunks/{workflow-TWOIA6LZ.js → workflow-2RBDOM7V.js} +4 -4
  303. package/dist/cli/chunks/workflow-orchestrator-H6G65YKU.js +2 -0
  304. package/dist/cli/chunks/wrappers-5OTAVVOV.js +2 -0
  305. package/dist/cli/commands/audit.d.ts +20 -2
  306. package/dist/cli/commands/audit.js +158 -16
  307. package/dist/cli/commands/ci.js +1 -1
  308. package/dist/cli/commands/claude-flow-setup.js +5 -4
  309. package/dist/cli/commands/test.js +18 -3
  310. package/dist/cli/handlers/init-handler.d.ts +2 -0
  311. package/dist/cli/handlers/init-handler.js +8 -2
  312. package/dist/cli/index.js +10 -1
  313. package/dist/coordination/handlers/test-execution-handlers.js +13 -8
  314. package/dist/coordination/index.d.ts +1 -1
  315. package/dist/coordination/queen-event-handlers.js +9 -6
  316. package/dist/coordination/result-saver.js +1 -1
  317. package/dist/coordination/services/index.d.ts +1 -1
  318. package/dist/coordination/services/task-audit-logger.d.ts +38 -13
  319. package/dist/coordination/services/task-audit-logger.js +33 -5
  320. package/dist/coordination/task-executor.d.ts +5 -0
  321. package/dist/coordination/task-executor.js +10 -5
  322. package/dist/domains/test-generation/coordinator.js +6 -5
  323. package/dist/domains/test-generation/interfaces.d.ts +11 -1
  324. package/dist/domains/test-generation/services/behavior-example-validation.d.ts +36 -0
  325. package/dist/domains/test-generation/services/behavior-example-validation.js +89 -0
  326. package/dist/domains/test-generation/services/behavior-examples.d.ts +8 -0
  327. package/dist/domains/test-generation/services/behavior-examples.js +65 -0
  328. package/dist/domains/test-generation/services/test-generator.d.ts +1 -1
  329. package/dist/domains/test-generation/services/test-generator.js +59 -30
  330. package/dist/domains/visual-accessibility/services/axe-core-audit.d.ts +0 -15
  331. package/dist/domains/visual-accessibility/services/axe-core-audit.js +12 -10
  332. package/dist/init/agents-installer.d.ts +4 -0
  333. package/dist/init/agents-installer.js +24 -11
  334. package/dist/init/browser-engine-installer.d.ts +5 -5
  335. package/dist/init/browser-engine-installer.js +28 -6
  336. package/dist/init/codex-installer.js +4 -2
  337. package/dist/init/idempotent-write.d.ts +53 -0
  338. package/dist/init/idempotent-write.js +160 -0
  339. package/dist/init/init-wizard.d.ts +2 -0
  340. package/dist/init/orchestrator.js +1 -0
  341. package/dist/init/phases/05-learning.js +3 -1
  342. package/dist/init/phases/07-hooks.js +32 -16
  343. package/dist/init/phases/08-mcp.js +4 -2
  344. package/dist/init/phases/09-assets.js +8 -18
  345. package/dist/init/phases/10-workers.js +7 -5
  346. package/dist/init/phases/12-verification.js +7 -2
  347. package/dist/init/phases/phase-interface.d.ts +2 -0
  348. package/dist/init/project-analyzer.d.ts +9 -0
  349. package/dist/init/project-analyzer.js +20 -1
  350. package/dist/init/self-configurator.d.ts +5 -3
  351. package/dist/init/self-configurator.js +18 -29
  352. package/dist/init/skills-installer.js +4 -2
  353. package/dist/init/types.d.ts +6 -0
  354. package/dist/init/types.js +20 -24
  355. package/dist/integrations/agentic-flow/reasoning-bank/index.d.ts +2 -5
  356. package/dist/integrations/coherence/coherence-service.js +84 -24
  357. package/dist/integrations/coherence/vote-tally.d.ts +38 -0
  358. package/dist/integrations/coherence/vote-tally.js +39 -0
  359. package/dist/integrations/ruvector/shared-rvf-adapter.d.ts +23 -0
  360. package/dist/integrations/ruvector/shared-rvf-adapter.js +24 -0
  361. package/dist/integrations/vibium/client.d.ts +1 -0
  362. package/dist/integrations/vibium/client.js +24 -11
  363. package/dist/integrations/vibium/runtime.d.ts +14 -0
  364. package/dist/integrations/vibium/runtime.js +94 -0
  365. package/dist/kernel/kernel.js +3 -2
  366. package/dist/kernel/pattern-fts-self-heal.d.ts +63 -0
  367. package/dist/kernel/pattern-fts-self-heal.js +193 -0
  368. package/dist/kernel/process-lifecycle.d.ts +60 -0
  369. package/dist/kernel/process-lifecycle.js +91 -0
  370. package/dist/kernel/unified-memory-schemas.d.ts +15 -1
  371. package/dist/kernel/unified-memory-schemas.js +53 -25
  372. package/dist/kernel/unified-memory.js +31 -34
  373. package/dist/kernel/unified-persistence.js +12 -6
  374. package/dist/learning/experience-capture.d.ts +2 -1
  375. package/dist/learning/experience-capture.js +23 -8
  376. package/dist/learning/pattern-store.d.ts +12 -1
  377. package/dist/learning/pattern-store.js +45 -30
  378. package/dist/learning/qe-patterns.d.ts +12 -0
  379. package/dist/learning/qe-patterns.js +7 -1
  380. package/dist/learning/qe-reasoning-bank.d.ts +1 -0
  381. package/dist/learning/qe-reasoning-bank.js +17 -4
  382. package/dist/learning/real-qe-reasoning-bank.d.ts +9 -4
  383. package/dist/learning/real-qe-reasoning-bank.js +28 -4
  384. package/dist/learning/rvf-pattern-store.js +36 -23
  385. package/dist/learning/sqlite-persistence.d.ts +8 -1
  386. package/dist/learning/sqlite-persistence.js +58 -33
  387. package/dist/logging/console-logger.d.ts +2 -5
  388. package/dist/logging/console-logger.js +10 -46
  389. package/dist/logging/index.d.ts +2 -0
  390. package/dist/logging/index.js +1 -0
  391. package/dist/logging/redaction.d.ts +27 -0
  392. package/dist/logging/redaction.js +170 -0
  393. package/dist/mcp/bundle.js +522 -545
  394. package/dist/mcp/entry.js +52 -6
  395. package/dist/mcp/handlers/core-handlers.js +5 -4
  396. package/dist/mcp/handlers/domain-handler-configs.js +12 -4
  397. package/dist/mcp/handlers/task-handlers.js +11 -7
  398. package/dist/mcp/protocol-server.js +20 -4
  399. package/dist/mcp/services/reasoning-bank-service.d.ts +6 -1
  400. package/dist/mcp/services/reasoning-bank-service.js +5 -1
  401. package/dist/mcp/tools/base.d.ts +9 -2
  402. package/dist/mcp/tools/base.js +7 -0
  403. package/dist/mcp/tools/coherence/consensus.js +51 -2
  404. package/dist/mcp/tools/planning/goap-plan.d.ts +20 -7
  405. package/dist/mcp/tools/planning/goap-plan.js +92 -20
  406. package/dist/mcp/tools/planning/goap-status.d.ts +37 -12
  407. package/dist/mcp/tools/planning/goap-status.js +52 -23
  408. package/dist/mcp/tools/planning/world-state.d.ts +101 -0
  409. package/dist/mcp/tools/planning/world-state.js +274 -0
  410. package/dist/mcp/tools/test-execution/e2e-execute.js +9 -1
  411. package/dist/mcp/tools/test-generation/generate.d.ts +6 -1
  412. package/dist/mcp/tools/test-generation/generate.js +8 -0
  413. package/dist/mcp/types.d.ts +10 -4
  414. package/dist/planning/goap-planner.d.ts +60 -4
  415. package/dist/planning/goap-planner.js +218 -60
  416. package/dist/planning/index.d.ts +1 -1
  417. package/dist/planning/index.js +1 -1
  418. package/dist/planning/plan-executor.d.ts +20 -1
  419. package/dist/planning/plan-executor.js +209 -100
  420. package/dist/planning/types.d.ts +16 -0
  421. package/dist/planning/types.js +17 -0
  422. package/dist/shared/error-utils.d.ts +15 -0
  423. package/dist/shared/error-utils.js +21 -0
  424. package/dist/shared/events/domain-events.d.ts +2 -1
  425. package/package.json +10 -6
  426. package/dist/cli/chunks/adapter-IYC62SXA.js +0 -2
  427. package/dist/cli/chunks/agent-booster-wasm-EDNKP3SP.js +0 -2
  428. package/dist/cli/chunks/aqe-learning-engine-LLOU2IXD.js +0 -2
  429. package/dist/cli/chunks/audit-CVZQMF55.js +0 -3
  430. package/dist/cli/chunks/base-P3Z4IKCT.js +0 -2
  431. package/dist/cli/chunks/browser-workflow-YYHQQ25X.js +0 -2
  432. package/dist/cli/chunks/chunk-3EZ5DR2R.js +0 -21
  433. package/dist/cli/chunks/chunk-5WOSWNDN.js +0 -2
  434. package/dist/cli/chunks/chunk-7CD7PBHY.js +0 -3
  435. package/dist/cli/chunks/chunk-7X7JYWT4.js +0 -27
  436. package/dist/cli/chunks/chunk-CZO4BJG5.js +0 -2
  437. package/dist/cli/chunks/chunk-J27F4NSB.js +0 -2
  438. package/dist/cli/chunks/chunk-J5UNP6W3.js +0 -2
  439. package/dist/cli/chunks/chunk-MI5Q55DG.js +0 -65
  440. package/dist/cli/chunks/chunk-TY5WC3FT.js +0 -12
  441. package/dist/cli/chunks/chunk-UDHVCKGA.js +0 -5
  442. package/dist/cli/chunks/chunk-XQSIRBKT.js +0 -180
  443. package/dist/cli/chunks/chunk-YXP6BKGS.js +0 -730
  444. package/dist/cli/chunks/chunk-ZBABIZ2D.js +0 -2
  445. package/dist/cli/chunks/chunk-ZCWERUYB.js +0 -12
  446. package/dist/cli/chunks/claude-flow-setup-5LVJOFKP.js +0 -2
  447. package/dist/cli/chunks/client-HUVFA5PF.js +0 -2
  448. package/dist/cli/chunks/core-handlers-UEXO3VAA.js +0 -2
  449. package/dist/cli/chunks/cross-domain-router-ODU5IZD6.js +0 -2
  450. package/dist/cli/chunks/domain-transfer-JZA5TMW3.js +0 -2
  451. package/dist/cli/chunks/dream-HE3OX42F.js +0 -2
  452. package/dist/cli/chunks/heartbeat-scheduler-QUIFGGLX.js +0 -2
  453. package/dist/cli/chunks/hnsw-adapter-42KB37KP.js +0 -2
  454. package/dist/cli/chunks/hnsw-index-T2PGO77J.js +0 -2
  455. package/dist/cli/chunks/hybrid-backend-FRNWYRKH.js +0 -2
  456. package/dist/cli/chunks/impact-analyzer-A5QYOYBR.js +0 -2
  457. package/dist/cli/chunks/init-wizard-XBU674YH.js +0 -2
  458. package/dist/cli/chunks/kernel-DV5MTNZD.js +0 -2
  459. package/dist/cli/chunks/knowledge-graph-4ACGVJQK.js +0 -2
  460. package/dist/cli/chunks/llm-router-service-PSMASERT.js +0 -2
  461. package/dist/cli/chunks/load-test-MRUO2VPF.js +0 -2
  462. package/dist/cli/chunks/mcp-JGSFCEMH.js +0 -2
  463. package/dist/cli/chunks/memory-backend-2MPGI6JW.js +0 -2
  464. package/dist/cli/chunks/memory-handlers-XT4HMITB.js +0 -2
  465. package/dist/cli/chunks/multi-model-executor-26Q5BSVG.js +0 -14
  466. package/dist/cli/chunks/orchestrator-D5IFV65I.js +0 -393
  467. package/dist/cli/chunks/pattern-null-store-TGWUL237.js +0 -2
  468. package/dist/cli/chunks/protocol-executor-GEVH5KD6.js +0 -2
  469. package/dist/cli/chunks/qe-reasoning-bank-DJ2JL6QB.js +0 -2
  470. package/dist/cli/chunks/queen-coordinator-F7E3AS26.js +0 -2
  471. package/dist/cli/chunks/router-OZH3QSAU.js +0 -2
  472. package/dist/cli/chunks/routing-feedback-J2E3ADZB.js +0 -2
  473. package/dist/cli/chunks/rvf-dual-writer-HK525Y5Y.js +0 -2
  474. package/dist/cli/chunks/rvf-migration-adapter-Q7FB3BKR.js +0 -2
  475. package/dist/cli/chunks/rvf-native-adapter-5ZRCGUI6.js +0 -2
  476. package/dist/cli/chunks/safe-db-3OYEPVEH.js +0 -2
  477. package/dist/cli/chunks/schedule-AG4C2EIQ.js +0 -2
  478. package/dist/cli/chunks/scheduler-SQS2CZFZ.js +0 -2
  479. package/dist/cli/chunks/shared-rvf-adapter-NFL6QSZ6.js +0 -2
  480. package/dist/cli/chunks/sqlite-persistence-MAKDFSHC.js +0 -2
  481. package/dist/cli/chunks/sync-MBTW5XBF.js +0 -2
  482. package/dist/cli/chunks/task-handlers-NH4GJHCJ.js +0 -9
  483. package/dist/cli/chunks/test-MPHGT4T6.js +0 -33
  484. package/dist/cli/chunks/token-bootstrap-SSDCYEKK.js +0 -2
  485. package/dist/cli/chunks/tree-sitter-wasm-parser-J6ZMAK37.js +0 -2
  486. package/dist/cli/chunks/unified-memory-DDWMC435.js +0 -2
  487. package/dist/cli/chunks/unified-memory-hnsw-4JA7SGBK.js +0 -2
  488. package/dist/cli/chunks/unified-persistence-F6OSNTXY.js +0 -2
  489. package/dist/cli/chunks/vibium-HOGMFJ2Z.js +0 -2
  490. package/dist/cli/chunks/visual-security-25SMBIYT.js +0 -2
  491. package/dist/cli/chunks/witness-chain-PJOQPFUX.js +0 -2
  492. package/dist/cli/chunks/witness-chain-ZW6KKUZU.js +0 -2
  493. package/dist/cli/chunks/workflow-orchestrator-UKSIDM7Q.js +0 -2
  494. package/dist/cli/chunks/wrappers-UR7BLXKV.js +0 -2
@@ -1,5 +1,5 @@
1
- import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.14.5");process.exit(0)}
2
- import{d as j,f as ze}from"./chunk-RKOUXVZZ.js";import{b as I,d as oe}from"./chunk-IJHCIXJC.js";import{a as z,c as He}from"./chunk-NQI7FWCS.js";import{a as H,b as D,c as We}from"./chunk-C3HQL6S4.js";import{a as qe}from"./chunk-J27F4NSB.js";import{c as re}from"./chunk-7CD7PBHY.js";import{a as X,c as ke}from"./chunk-J5UNP6W3.js";import{a as ie,b as je}from"./chunk-HVU64GP5.js";import{a as ae,d as U,e as ce,f as Te}from"./chunk-52L77RMG.js";import{a as b,b as se,e as Be}from"./chunk-CVMNJSCB.js";import{b as R,d as Pe}from"./chunk-JSZ663MU.js";import{createHash as ue}from"node:crypto";function $e(s){let e=Buffer.alloc(8);return e.writeBigUInt64LE(BigInt(s)),e}function Ke(s){return typeof s=="string"?Buffer.from(s,"utf8"):s instanceof Uint8Array?Buffer.from(s):Buffer.from(W(s),"utf8")}function W(s){return s===null||typeof s!="object"?JSON.stringify(s)??"null":Array.isArray(s)?`[${s.map(W).join(",")}]`:`{${Object.keys(s).sort().map(t=>`${JSON.stringify(t)}:${W(s[t])}`).join(",")}}`}function _e(...s){let e=ue("sha256");for(let t of s)e.update(t);return e.digest()}function de(s,e,t){return _e(Ye,s,e,$e(t))}var Ye,Ee,O,le=R(()=>{"use strict";Ye=Buffer.from("ruvector:chain:"),Ee=ue("sha256").update("ruvector-proof-gate-v1").digest();O=class s{seq=0;prev=Ee;chain=[];payloadHashes=[];admit(e){let t=_e(Ke(e)),n=de(this.prev,t,this.seq);this.prev=n,this.chain.push(n),this.payloadHashes.push(t);let a={sequence:this.seq,payloadHash:t.toString("hex"),chainCommitment:n.toString("hex")};return this.seq+=1,a}verifyReceipt(e){return e.sequence>=0&&e.sequence<this.chain.length&&this.chain[e.sequence].toString("hex")===e.chainCommitment}chainRoot(){return this.prev.toString("hex")}get length(){return this.seq}get isEmpty(){return this.seq===0}verifyIntegrity(){if(this.chain.length!==this.payloadHashes.length)return!1;let e=Ee;for(let t=0;t<this.chain.length;t++){if(!de(e,this.payloadHashes[t],t).equals(this.chain[t]))return!1;e=this.chain[t]}return e.equals(this.prev)}toJSON(){return{seq:this.seq,head:this.prev.toString("hex"),chain:this.chain.map(e=>e.toString("hex")),payloadHashes:this.payloadHashes.map(e=>e.toString("hex"))}}static fromJSON(e){let t=new s;t.seq=e.seq,t.prev=Buffer.from(e.head,"hex");for(let n of e.chain)t.chain.push(Buffer.from(n,"hex"));for(let n of e.payloadHashes)t.payloadHashes.push(Buffer.from(n,"hex"));return t}}});function A(s){if(!Y.has(s))throw new Error(`Invalid table name: "${s}" is not in the allowlist`);return s}function ot(s){let e=s.split(".");if(e.length>2)throw new Error(`Invalid SQL identifier: "${s}" has too many parts (max: schema.table)`);for(let t of e)if(!pe.test(t))throw new Error(`Invalid SQL identifier: "${s}" \u2014 part "${t}" does not match pattern ${pe}`);return s}var Y,pe,$=R(()=>{"use strict";Y=new Set(["schema_version","kv_store","vectors","rl_q_values","goap_goals","goap_actions","goap_plans","goap_plan_signatures","concept_nodes","concept_edges","dream_cycles","dream_insights","qe_patterns","qe_pattern_embeddings","qe_pattern_usage","qe_trajectories","embeddings","execution_results","executed_steps","mincut_snapshots","mincut_history","mincut_weak_vertices","mincut_alerts","mincut_healing_actions","mincut_observations","sona_patterns","sona_fisher_matrices","test_outcomes","routing_outcomes","coverage_sessions","patterns","hypergraph_nodes","hypergraph_edges","hypergraph_vertices","hypergraph_hyperedges","hypergraph_edge_vertices","hypergraph_vertex_properties","hypergraph_edge_properties","captured_experiences","experience_applications","witness_chain","witness_chain_receipts","witness_chain_archive","trajectories","trajectory_steps","pattern_evolution_events","pattern_relationships","pattern_versions","learning_daily_snapshots","metrics_outcomes","experience_consolidation_log","qe_pattern_reuse","learning_evidence_manifests","learning_evidence_segments","learning_segment_edges","learning_evidence_admissions","pattern_manifest_lineage","pattern_segment_lineage","qe_agent_co_execution"]);pe=/^[a-z_][a-z0-9_]{0,62}$/});function me(s){s.exec(ge),s.exec(`
1
+ import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.14.7");process.exit(0)}
2
+ import{d as H,f as it}from"./chunk-ZELWDJXT.js";import{b as I,d as ge}from"./chunk-OIDWDGLG.js";import{a as W,c as ot}from"./chunk-UFSVUBTR.js";import{a as Y,b as X,c as at}from"./chunk-IAENZ2DR.js";import{a as Ee,b as de,c as nt}from"./chunk-PELENDDQ.js";import{a as tt}from"./chunk-TW3SR4TS.js";import{e as Te}from"./chunk-5GFKTJ65.js";import{a as O,e as ce}from"./chunk-ZUOVNFXK.js";import{a as le,b as st}from"./chunk-ND4QTZOL.js";import{a as pe,d as F,e as _e,f as me}from"./chunk-P7XSPP5D.js";import{a as y,b as ue,e as rt}from"./chunk-VYDVI6FZ.js";import{b as R,d as et}from"./chunk-YO4ESCB4.js";import{createHash as Se}from"node:crypto";function Tt(n){let e=Buffer.alloc(8);return e.writeBigUInt64LE(BigInt(n)),e}function Et(n){return typeof n=="string"?Buffer.from(n,"utf8"):n instanceof Uint8Array?Buffer.from(n):Buffer.from($(n),"utf8")}function $(n){return n===null||typeof n!="object"?JSON.stringify(n)??"null":Array.isArray(n)?`[${n.map($).join(",")}]`:`{${Object.keys(n).sort().map(t=>`${JSON.stringify(t)}:${$(n[t])}`).join(",")}}`}function he(...n){let e=Se("sha256");for(let t of n)e.update(t);return e.digest()}function Ne(n,e,t){return he(ct,n,e,Tt(t))}var ct,fe,A,Re=R(()=>{"use strict";ct=Buffer.from("ruvector:chain:"),fe=Se("sha256").update("ruvector-proof-gate-v1").digest();A=class n{seq=0;prev=fe;chain=[];payloadHashes=[];admit(e){let t=he(Et(e)),r=Ne(this.prev,t,this.seq);this.prev=r,this.chain.push(r),this.payloadHashes.push(t);let i={sequence:this.seq,payloadHash:t.toString("hex"),chainCommitment:r.toString("hex")};return this.seq+=1,i}verifyReceipt(e){return e.sequence>=0&&e.sequence<this.chain.length&&this.chain[e.sequence].toString("hex")===e.chainCommitment}chainRoot(){return this.prev.toString("hex")}get length(){return this.seq}get isEmpty(){return this.seq===0}verifyIntegrity(){if(this.chain.length!==this.payloadHashes.length)return!1;let e=fe;for(let t=0;t<this.chain.length;t++){if(!Ne(e,this.payloadHashes[t],t).equals(this.chain[t]))return!1;e=this.chain[t]}return e.equals(this.prev)}toJSON(){return{seq:this.seq,head:this.prev.toString("hex"),chain:this.chain.map(e=>e.toString("hex")),payloadHashes:this.payloadHashes.map(e=>e.toString("hex"))}}static fromJSON(e){let t=new n;t.seq=e.seq,t.prev=Buffer.from(e.head,"hex");for(let r of e.chain)t.chain.push(Buffer.from(r,"hex"));for(let r of e.payloadHashes)t.payloadHashes.push(Buffer.from(r,"hex"));return t}}});function v(n){if(!K.has(n))throw new Error(`Invalid table name: "${n}" is not in the allowlist`);return n}function It(n){let e=n.split(".");if(e.length>2)throw new Error(`Invalid SQL identifier: "${n}" has too many parts (max: schema.table)`);for(let t of e)if(!Le.test(t))throw new Error(`Invalid SQL identifier: "${n}" \u2014 part "${t}" does not match pattern ${Le}`);return n}var K,Le,V=R(()=>{"use strict";K=new Set(["schema_version","kv_store","vectors","rl_q_values","goap_goals","goap_actions","goap_plans","goap_plan_signatures","concept_nodes","concept_edges","dream_cycles","dream_insights","qe_patterns","qe_pattern_embeddings","qe_pattern_usage","qe_trajectories","embeddings","execution_results","executed_steps","mincut_snapshots","mincut_history","mincut_weak_vertices","mincut_alerts","mincut_healing_actions","mincut_observations","sona_patterns","sona_fisher_matrices","test_outcomes","routing_outcomes","coverage_sessions","patterns","hypergraph_nodes","hypergraph_edges","hypergraph_vertices","hypergraph_hyperedges","hypergraph_edge_vertices","hypergraph_vertex_properties","hypergraph_edge_properties","captured_experiences","experience_applications","witness_chain","witness_chain_receipts","witness_chain_archive","trajectories","trajectory_steps","pattern_evolution_events","pattern_relationships","pattern_versions","learning_daily_snapshots","metrics_outcomes","experience_consolidation_log","qe_pattern_reuse","learning_evidence_manifests","learning_evidence_segments","learning_segment_edges","learning_evidence_admissions","pattern_manifest_lineage","pattern_segment_lineage","qe_agent_co_execution"]);Le=/^[a-z_][a-z0-9_]{0,62}$/});function Ce(n){n.exec(Ie),n.exec(`
3
3
  INSERT OR IGNORE INTO learning_evidence_manifests (
4
4
  id, trajectory_id, trajectory_hash, manifest_hash, task_family,
5
5
  outcome, oracle_refs_json, source_kind, process_signals_json
@@ -23,7 +23,7 @@ import{d as j,f as ze}from"./chunk-RKOUXVZZ.js";import{b as I,d as oe}from"./chu
23
23
  pattern_id, manifest_id, use_kind
24
24
  )
25
25
  SELECT id, 'legacy-pattern:' || id, 'legacy-context' FROM qe_patterns;
26
- `)}var ge,K=R(()=>{"use strict";ge=`
26
+ `)}var Ie,Q=R(()=>{"use strict";Ie=`
27
27
  CREATE TABLE IF NOT EXISTS learning_evidence_manifests (
28
28
  id TEXT PRIMARY KEY,
29
29
  trajectory_id TEXT,
@@ -131,13 +131,13 @@ import{d as j,f as ze}from"./chunk-RKOUXVZZ.js";import{b as I,d as oe}from"./chu
131
131
  BEGIN SELECT RAISE(ABORT, 'learning evidence admissions are append-only'); END;
132
132
  CREATE TRIGGER IF NOT EXISTS learning_admissions_no_delete BEFORE DELETE ON learning_evidence_admissions
133
133
  BEGIN SELECT RAISE(ABORT, 'learning evidence admissions are append-only'); END;
134
- `});var w,fe,Ne,Se,he,V,Re,Q,Le,Ie,Ce,Oe,Ae=R(()=>{"use strict";ze();He();K();w=13,fe=`
134
+ `});var x,Oe,Ae,ve,be,J,De,Z,b,ee,ye,Xe,Ue,Fe,xe,we,Me,te=R(()=>{"use strict";it();ot();Q();x=13,Oe=`
135
135
  CREATE TABLE IF NOT EXISTS schema_version (
136
136
  id INTEGER PRIMARY KEY CHECK (id = 1),
137
137
  version INTEGER NOT NULL,
138
138
  migrated_at TEXT DEFAULT (datetime('now'))
139
139
  );
140
- `,Ne=`
140
+ `,Ae=`
141
141
  -- Key-Value Store (v2 compatible - same schema as HybridBackend)
142
142
  CREATE TABLE IF NOT EXISTS kv_store (
143
143
  key TEXT NOT NULL,
@@ -149,7 +149,7 @@ import{d as j,f as ze}from"./chunk-RKOUXVZZ.js";import{b as I,d as oe}from"./chu
149
149
  );
150
150
  CREATE INDEX IF NOT EXISTS idx_kv_namespace ON kv_store(namespace);
151
151
  CREATE INDEX IF NOT EXISTS idx_kv_expires ON kv_store(expires_at) WHERE expires_at IS NOT NULL;
152
- `,Se=`
152
+ `,ve=`
153
153
  -- Vector Embeddings (new in v3 - replaces in-memory AgentDB)
154
154
  CREATE TABLE IF NOT EXISTS vectors (
155
155
  id TEXT PRIMARY KEY,
@@ -162,7 +162,7 @@ import{d as j,f as ze}from"./chunk-RKOUXVZZ.js";import{b as I,d as oe}from"./chu
162
162
  );
163
163
  CREATE INDEX IF NOT EXISTS idx_vectors_namespace ON vectors(namespace);
164
164
  CREATE INDEX IF NOT EXISTS idx_vectors_dimensions ON vectors(dimensions);
165
- `,he=`
165
+ `,be=`
166
166
  -- Q-Values for RL algorithms (ADR-046)
167
167
  CREATE TABLE IF NOT EXISTS rl_q_values (
168
168
  id TEXT PRIMARY KEY,
@@ -183,7 +183,7 @@ import{d as j,f as ze}from"./chunk-RKOUXVZZ.js";import{b as I,d as oe}from"./chu
183
183
  CREATE INDEX IF NOT EXISTS idx_qvalues_state ON rl_q_values(agent_id, state_key);
184
184
  CREATE INDEX IF NOT EXISTS idx_qvalues_domain ON rl_q_values(domain);
185
185
  CREATE INDEX IF NOT EXISTS idx_qvalues_updated ON rl_q_values(updated_at);
186
- `,V=`
186
+ `,J=`
187
187
  -- GOAP Goals
188
188
  CREATE TABLE IF NOT EXISTS goap_goals (
189
189
  id TEXT PRIMARY KEY,
@@ -294,7 +294,7 @@ import{d as j,f as ze}from"./chunk-RKOUXVZZ.js";import{b as I,d as oe}from"./chu
294
294
  -- would fail on "no such column" since CREATE TABLE IF NOT EXISTS above
295
295
  -- silently no-ops against them. unified-memory.ts's v11 migration creates
296
296
  -- this index only after confirming/backfilling the column.
297
- `,Re=`
297
+ `,De=`
298
298
  -- Concept Graph Nodes (Dream Engine)
299
299
  CREATE TABLE IF NOT EXISTS concept_nodes (
300
300
  id TEXT PRIMARY KEY,
@@ -363,7 +363,30 @@ import{d as j,f as ze}from"./chunk-RKOUXVZZ.js";import{b as I,d as oe}from"./chu
363
363
  CREATE INDEX IF NOT EXISTS idx_edge_weight ON concept_edges(weight DESC);
364
364
  CREATE INDEX IF NOT EXISTS idx_insight_cycle ON dream_insights(cycle_id);
365
365
  CREATE INDEX IF NOT EXISTS idx_dream_status ON dream_cycles(status);
366
- `,Q=`
366
+ `,Z=`
367
+ CREATE VIRTUAL TABLE IF NOT EXISTS qe_patterns_fts USING fts5(
368
+ name, description, pattern_type, qe_domain,
369
+ content='qe_patterns',
370
+ content_rowid='rowid'
371
+ );
372
+ `,b=Object.freeze({qe_patterns_fts_insert:`
373
+ CREATE TRIGGER IF NOT EXISTS qe_patterns_fts_insert AFTER INSERT ON qe_patterns BEGIN
374
+ INSERT INTO qe_patterns_fts(rowid, name, description, pattern_type, qe_domain)
375
+ VALUES (new.rowid, new.name, new.description, new.pattern_type, new.qe_domain);
376
+ END;
377
+ `,qe_patterns_fts_delete:`
378
+ CREATE TRIGGER IF NOT EXISTS qe_patterns_fts_delete AFTER DELETE ON qe_patterns BEGIN
379
+ INSERT INTO qe_patterns_fts(qe_patterns_fts, rowid, name, description, pattern_type, qe_domain)
380
+ VALUES ('delete', old.rowid, old.name, old.description, old.pattern_type, old.qe_domain);
381
+ END;
382
+ `,qe_patterns_fts_update:`
383
+ CREATE TRIGGER IF NOT EXISTS qe_patterns_fts_update AFTER UPDATE ON qe_patterns BEGIN
384
+ INSERT INTO qe_patterns_fts(qe_patterns_fts, rowid, name, description, pattern_type, qe_domain)
385
+ VALUES ('delete', old.rowid, old.name, old.description, old.pattern_type, old.qe_domain);
386
+ INSERT INTO qe_patterns_fts(rowid, name, description, pattern_type, qe_domain)
387
+ VALUES (new.rowid, new.name, new.description, new.pattern_type, new.qe_domain);
388
+ END;
389
+ `}),ee=Z+Object.values(b).join(""),ye=n=>`
367
390
  -- QE Patterns table (unified from sqlite-persistence.ts)
368
391
  CREATE TABLE IF NOT EXISTS qe_patterns (
369
392
  id TEXT PRIMARY KEY,
@@ -476,30 +499,8 @@ import{d as j,f as ze}from"./chunk-RKOUXVZZ.js";import{b as I,d as oe}from"./chu
476
499
  FOREIGN KEY (execution_id) REFERENCES execution_results(id)
477
500
  );
478
501
 
479
- -- FTS5 full-text search index for hybrid vector/text search
480
- CREATE VIRTUAL TABLE IF NOT EXISTS qe_patterns_fts USING fts5(
481
- name, description, pattern_type, qe_domain,
482
- content='qe_patterns',
483
- content_rowid='rowid'
484
- );
485
-
486
- -- FTS5 triggers to keep index in sync
487
- CREATE TRIGGER IF NOT EXISTS qe_patterns_fts_insert AFTER INSERT ON qe_patterns BEGIN
488
- INSERT INTO qe_patterns_fts(rowid, name, description, pattern_type, qe_domain)
489
- VALUES (new.rowid, new.name, new.description, new.pattern_type, new.qe_domain);
490
- END;
491
-
492
- CREATE TRIGGER IF NOT EXISTS qe_patterns_fts_delete AFTER DELETE ON qe_patterns BEGIN
493
- INSERT INTO qe_patterns_fts(qe_patterns_fts, rowid, name, description, pattern_type, qe_domain)
494
- VALUES ('delete', old.rowid, old.name, old.description, old.pattern_type, old.qe_domain);
495
- END;
496
-
497
- CREATE TRIGGER IF NOT EXISTS qe_patterns_fts_update AFTER UPDATE ON qe_patterns BEGIN
498
- INSERT INTO qe_patterns_fts(qe_patterns_fts, rowid, name, description, pattern_type, qe_domain)
499
- VALUES ('delete', old.rowid, old.name, old.description, old.pattern_type, old.qe_domain);
500
- INSERT INTO qe_patterns_fts(rowid, name, description, pattern_type, qe_domain)
501
- VALUES (new.rowid, new.name, new.description, new.pattern_type, new.qe_domain);
502
- END;
502
+ -- FTS5 full-text search index + sync triggers for hybrid vector/text search
503
+ ${n}
503
504
 
504
505
  -- QE Patterns indexes
505
506
  CREATE INDEX IF NOT EXISTS idx_qe_patterns_domain ON qe_patterns(qe_domain);
@@ -515,7 +516,7 @@ import{d as j,f as ze}from"./chunk-RKOUXVZZ.js";import{b as I,d as oe}from"./chu
515
516
  CREATE INDEX IF NOT EXISTS idx_execution_results_status ON execution_results(status);
516
517
  CREATE INDEX IF NOT EXISTS idx_executed_steps_execution ON executed_steps(execution_id);
517
518
  CREATE INDEX IF NOT EXISTS idx_executed_steps_action ON executed_steps(action_id);
518
- `,Le=`
519
+ `,Xe=ye(ee),Ue=ye(""),Fe=`
519
520
  -- MinCut Graph Snapshots (ADR-047)
520
521
  CREATE TABLE IF NOT EXISTS mincut_snapshots (
521
522
  id TEXT PRIMARY KEY,
@@ -621,7 +622,7 @@ import{d as j,f as ze}from"./chunk-RKOUXVZZ.js";import{b as I,d as oe}from"./chu
621
622
  CREATE INDEX IF NOT EXISTS idx_mincut_healing_type ON mincut_healing_actions(action_type);
622
623
  CREATE INDEX IF NOT EXISTS idx_mincut_healing_success ON mincut_healing_actions(success);
623
624
  CREATE INDEX IF NOT EXISTS idx_mincut_observations_iter ON mincut_observations(iteration);
624
- `,Ie=`
625
+ `,xe=`
625
626
  -- SONA Patterns table (ADR-046: Pattern Persistence for Neural Backbone)
626
627
  CREATE TABLE IF NOT EXISTS sona_patterns (
627
628
  id TEXT PRIMARY KEY,
@@ -647,7 +648,7 @@ import{d as j,f as ze}from"./chunk-RKOUXVZZ.js";import{b as I,d as oe}from"./chu
647
648
  CREATE INDEX IF NOT EXISTS idx_sona_patterns_domain ON sona_patterns(domain);
648
649
  CREATE INDEX IF NOT EXISTS idx_sona_patterns_confidence ON sona_patterns(confidence DESC);
649
650
  CREATE INDEX IF NOT EXISTS idx_sona_patterns_updated ON sona_patterns(updated_at DESC);
650
- `,Ce=`
651
+ `,we=`
651
652
  -- Test outcomes (ADR-023: Quality Feedback Loop)
652
653
  CREATE TABLE IF NOT EXISTS test_outcomes (
653
654
  id TEXT PRIMARY KEY,
@@ -730,66 +731,41 @@ import{d as j,f as ze}from"./chunk-RKOUXVZZ.js";import{b as I,d as oe}from"./chu
730
731
  CREATE INDEX IF NOT EXISTS idx_coverage_sessions_technique ON coverage_sessions(technique);
731
732
  CREATE INDEX IF NOT EXISTS idx_coverage_sessions_agent ON coverage_sessions(agent_id);
732
733
  CREATE INDEX IF NOT EXISTS idx_coverage_sessions_created ON coverage_sessions(created_at);
733
- `,Oe=["kv_store","vectors","rl_q_values","goap_actions","goap_goals","goap_plans","goap_plan_signatures","goap_execution_steps","concept_nodes","concept_edges","dream_cycles","dream_insights","qe_patterns","qe_pattern_embeddings","qe_pattern_usage","qe_trajectories","embeddings","execution_results","executed_steps","mincut_snapshots","mincut_history","mincut_weak_vertices","mincut_alerts","mincut_healing_actions","mincut_observations","hypergraph_nodes","hypergraph_edges","sona_patterns","witness_chain","learning_evidence_manifests","learning_evidence_segments","learning_segment_edges","learning_evidence_admissions","pattern_manifest_lineage","pattern_segment_lineage"]});function F(s,e,t){let n={value:e,timestamp:t??(e!==void 0?Date.now():0),nodeId:e!==void 0?s:"",version:e!==void 0?1:0,lastUpdated:Date.now()};function a(o,T,d,E){return o!==d?o-d:T.localeCompare(E)}return{get(){return n.value},set(o,T){let d=T??Date.now();(n.timestamp===0||a(d,s,n.timestamp,n.nodeId)>0)&&(n={value:o,timestamp:d,nodeId:s,version:n.version+1,lastUpdated:Date.now()})},merge(o){let T=o.getState();this.applyState(T)},getState(){return{value:n.value,timestamp:n.timestamp,nodeId:n.nodeId,version:n.version,lastUpdated:n.lastUpdated}},applyState(o){(n.timestamp===0||a(o.timestamp,o.nodeId,n.timestamp,n.nodeId)>0)&&(n={value:o.value,timestamp:o.timestamp,nodeId:o.nodeId,version:Math.max(n.version,o.version)+1,lastUpdated:Date.now()})},getNodeId(){return s},getTimestamp(){return n.timestamp}}}function x(s,e){let t=F(s);return t.applyState(e),t}var J=R(()=>{"use strict"});function C(s){let e={counts:{},version:0,lastUpdated:Date.now()};return e.counts[s]=0,{get(){return Object.values(e.counts).reduce((t,n)=>t+n,0)},increment(t=1){if(t<0)throw new Error("G-Counter can only increment by positive values");t!==0&&(e.counts[s]=(e.counts[s]||0)+t,e.version++,e.lastUpdated=Date.now())},merge(t){let n=t.getState();this.applyState(n)},getState(){return{counts:{...e.counts},version:e.version,lastUpdated:e.lastUpdated}},applyState(t){let n=!1;for(let[a,o]of Object.entries(t.counts)){let T=e.counts[a]||0;o>T&&(e.counts[a]=o,n=!0)}n&&(e.version=Math.max(e.version,t.version)+1,e.lastUpdated=Date.now())},getNodeId(){return s},getLocalCount(){return e.counts[s]||0}}}function G(s,e){let t=C(s);return t.applyState(e),t}var M=R(()=>{"use strict"});function P(s){let e=C(s),t=C(s),n=0,a=Date.now();return{get(){return e.get()-t.get()},increment(o=1){if(o<0)throw new Error("Use decrement() for negative values");o!==0&&(e.increment(o),n++,a=Date.now())},decrement(o=1){if(o<0)throw new Error("Use increment() for negative values");o!==0&&(t.increment(o),n++,a=Date.now())},merge(o){let T=o.getState();this.applyState(T)},getState(){return{positive:e.getState(),negative:t.getState(),version:n,lastUpdated:a}},applyState(o){let T=this.get();e.applyState(o.positive),t.applyState(o.negative);let d=this.get();T!==d&&(n=Math.max(n,o.version)+1,a=Date.now())},getNodeId(){return s}}}function k(s,e){let t=P(s);return t.applyState(e),t}var Z=R(()=>{"use strict";M()});function Ve(s,e){return`${s}:${Date.now()}:${e}`}function ee(s){return typeof s=="string"?`s:${s}`:typeof s=="number"?`n:${s}`:typeof s=="boolean"?`b:${s}`:`j:${JSON.stringify(s)}`}function Qe(s){let e=s.substring(0,2),t=s.substring(2);switch(e){case"s:":return t;case"n:":return Number(t);case"b:":return t==="true";case"j:":return I(t);default:throw new Error(`Unknown serialization type: ${e}`)}}function q(s){let e=new Map,t=new Map,n=0,a=Date.now(),o=0;function T(E){let u=e.get(E);if(!u||u.size===0)return!1;let _=t.get(E);if(!_||_.size===0)return!0;for(let m of u)if(!_.has(m))return!0;return!1}function d(E){let u=e.get(E);if(!u)return new Set;let _=t.get(E)||new Set,m=new Set;for(let p of u)_.has(p)||m.add(p);return m}return{has(E){let u=ee(E);return T(u)},values(){let E=[];for(let[u]of e)T(u)&&E.push(Qe(u));return E},size(){let E=0;for(let[u]of e)T(u)&&E++;return E},add(E){let u=ee(E),_=Ve(s,o++);e.has(u)||e.set(u,new Set),e.get(u).add(_),n++,a=Date.now()},remove(E){let u=ee(E),_=e.get(u);if(!_||_.size===0)return;t.has(u)||t.set(u,new Set);let m=t.get(u);for(let p of _)m.add(p);n++,a=Date.now()},merge(E){let u=E.getState();this.applyState(u)},getState(){let E={};for(let[_,m]of e)E[_]=Array.from(m);let u={};for(let[_,m]of t)m.size>0&&(u[_]=Array.from(m));return{elements:E,tombstones:u,version:n,lastUpdated:a}},applyState(E){let u=!1;for(let[_,m]of Object.entries(E.elements)){e.has(_)||e.set(_,new Set);let p=e.get(_);for(let l of m)p.has(l)||(p.add(l),u=!0)}for(let[_,m]of Object.entries(E.tombstones)){t.has(_)||t.set(_,new Set);let p=t.get(_);for(let l of m)p.has(l)||(p.add(l),u=!0)}u&&(n=Math.max(n,E.version)+1,a=Date.now())},getNodeId(){return s},clear(){for(let[E,u]of e){t.has(E)||t.set(E,new Set);let _=t.get(E);for(let m of u)_.add(m)}n++,a=Date.now()}}}function B(s,e){let t=q(s);return t.applyState(e),t}var te=R(()=>{"use strict";oe()});function ne(s){let e={...Je,...s},{nodeId:t,enableDeltaTracking:n,maxDeltaHistory:a}=e,o=new Map,T=new Map,d=new Map,E=new Map,u=0,_=[],m=new Set,p={registers:new Set,gCounters:new Set,pnCounters:new Set,sets:new Set};function l(i,r,c){let N={key:i,type:r,operation:c,timestamp:Date.now(),nodeId:t};for(let Ge of m)try{Ge(N)}catch(Me){console.error("[CRDTStore] Error in change listener:",Me)}}function g(i,r){u++,n&&p[i].add(r)}function L(){if(!n||!(p.registers.size>0||p.gCounters.size>0||p.pnCounters.size>0||p.sets.size>0))return;let r={fromVersion:_.length>0?_[_.length-1].toVersion:0,toVersion:u,timestamp:Date.now(),nodeId:t};if(p.registers.size>0){r.registers={};for(let c of p.registers){let N=o.get(c);N&&(r.registers[c]=N.getState())}p.registers.clear()}if(p.gCounters.size>0){r.gCounters={};for(let c of p.gCounters){let N=T.get(c);N&&(r.gCounters[c]=N.getState())}p.gCounters.clear()}if(p.pnCounters.size>0){r.pnCounters={};for(let c of p.pnCounters){let N=d.get(c);N&&(r.pnCounters[c]=N.getState())}p.pnCounters.clear()}if(p.sets.size>0){r.sets={};for(let c of p.sets){let N=E.get(c);N&&(r.sets[c]=N.getState())}p.sets.clear()}for(_.push(r);_.length>a;)_.shift()}let h={getRegister(i){return o.has(i)||o.set(i,F(t)),o.get(i)},setRegister(i,r){h.getRegister(i).set(r),g("registers",i),l(i,"lww-register","set")},hasRegister(i){return o.has(i)},deleteRegister(i){let r=o.delete(i);return r&&g("registers",i),r},getGCounter(i){return T.has(i)||T.set(i,C(t)),T.get(i)},incrementGCounter(i,r){h.getGCounter(i).increment(r),g("gCounters",i),l(i,"g-counter","increment")},hasGCounter(i){return T.has(i)},deleteGCounter(i){let r=T.delete(i);return r&&g("gCounters",i),r},getCounter(i){return d.has(i)||d.set(i,P(t)),d.get(i)},incrementCounter(i,r){h.getCounter(i).increment(r),g("pnCounters",i),l(i,"pn-counter","increment")},decrementCounter(i,r){h.getCounter(i).decrement(r),g("pnCounters",i),l(i,"pn-counter","decrement")},hasCounter(i){return d.has(i)},deleteCounter(i){let r=d.delete(i);return r&&g("pnCounters",i),r},getSet(i){return E.has(i)||E.set(i,q(t)),E.get(i)},addToSet(i,r){h.getSet(i).add(r),g("sets",i),l(i,"or-set","add")},removeFromSet(i,r){h.getSet(i).remove(r),g("sets",i),l(i,"or-set","remove")},hasSet(i){return E.has(i)},deleteSet(i){let r=E.delete(i);return r&&g("sets",i),r},merge(i){let r=i.getState();h.applyState(r)},getState(){L();let i={version:u,timestamp:Date.now(),nodeId:t,registers:{},gCounters:{},pnCounters:{},sets:{}};for(let[r,c]of o)i.registers[r]=c.getState();for(let[r,c]of T)i.gCounters[r]=c.getState();for(let[r,c]of d)i.pnCounters[r]=c.getState();for(let[r,c]of E)i.sets[r]=c.getState();return i},applyState(i){for(let[r,c]of Object.entries(i.registers))o.has(r)?o.get(r).applyState(c):o.set(r,x(t,c)),g("registers",r),l(r,"lww-register","merge");for(let[r,c]of Object.entries(i.gCounters))T.has(r)?T.get(r).applyState(c):T.set(r,G(t,c)),g("gCounters",r),l(r,"g-counter","merge");for(let[r,c]of Object.entries(i.pnCounters))d.has(r)?d.get(r).applyState(c):d.set(r,k(t,c)),g("pnCounters",r),l(r,"pn-counter","merge");for(let[r,c]of Object.entries(i.sets))E.has(r)?E.get(r).applyState(c):E.set(r,B(t,c)),g("sets",r),l(r,"or-set","merge");u=Math.max(u,i.version)+1},getDelta(i){if(L(),_.length===0)return i>=u,null;let r=_.filter(N=>N.toVersion>i);if(r.length===0)return null;let c={fromVersion:i,toVersion:u,timestamp:Date.now(),nodeId:t,registers:{},gCounters:{},pnCounters:{},sets:{}};for(let N of r)N.registers&&Object.assign(c.registers,N.registers),N.gCounters&&Object.assign(c.gCounters,N.gCounters),N.pnCounters&&Object.assign(c.pnCounters,N.pnCounters),N.sets&&Object.assign(c.sets,N.sets);return Object.keys(c.registers).length===0&&delete c.registers,Object.keys(c.gCounters).length===0&&delete c.gCounters,Object.keys(c.pnCounters).length===0&&delete c.pnCounters,Object.keys(c.sets).length===0&&delete c.sets,c},applyDelta(i){if(i.registers)for(let[r,c]of Object.entries(i.registers))o.has(r)?o.get(r).applyState(c):o.set(r,x(t,c)),g("registers",r),l(r,"lww-register","merge");if(i.gCounters)for(let[r,c]of Object.entries(i.gCounters))T.has(r)?T.get(r).applyState(c):T.set(r,G(t,c)),g("gCounters",r),l(r,"g-counter","merge");if(i.pnCounters)for(let[r,c]of Object.entries(i.pnCounters))d.has(r)?d.get(r).applyState(c):d.set(r,k(t,c)),g("pnCounters",r),l(r,"pn-counter","merge");if(i.sets)for(let[r,c]of Object.entries(i.sets))E.has(r)?E.get(r).applyState(c):E.set(r,B(t,c)),g("sets",r),l(r,"or-set","merge");u=Math.max(u,i.toVersion)+1},getVersion(){return u},getNodeId(){return t},on(i,r){if(i==="change")return m.add(r),()=>{m.delete(r)};throw new Error(`Unknown event type: ${i}`)},removeAllListeners(){m.clear()},keys(i){let r=[];return(!i||i==="lww-register")&&r.push(...Array.from(o.keys())),(!i||i==="g-counter")&&r.push(...Array.from(T.keys())),(!i||i==="pn-counter")&&r.push(...Array.from(d.keys())),(!i||i==="or-set")&&r.push(...Array.from(E.keys())),r},clear(){o.clear(),T.clear(),d.clear(),E.clear(),_.length=0,p.registers.clear(),p.gCounters.clear(),p.pnCounters.clear(),p.sets.clear(),u=0},getStats(){return{total:o.size+T.size+d.size+E.size,registers:o.size,gCounters:T.size,pnCounters:d.size,sets:E.size,version:u,nodeId:t,deltaHistorySize:_.length}}};return h}var Je,ve=R(()=>{"use strict";J();M();Z();te();Je={nodeId:"default-node",enableDeltaTracking:!0,maxDeltaHistory:100}});var be=R(()=>{"use strict"});var De=R(()=>{"use strict";J();M();Z();te();ve();be()});var nt={};Pe(nt,{ALLOWED_TABLE_NAMES:()=>Y,BinaryHeap:()=>ae,DEFAULT_UNIFIED_MEMORY_CONFIG:()=>we,UnifiedHnswIndex:()=>U,UnifiedMemoryManager:()=>v,clearProjectRootCache:()=>H,createHnswIndex:()=>ce,findProjectRoot:()=>D,getDefaultDbPath:()=>Ue,getResolvedDefaultConfig:()=>Fe,getUnifiedMemory:()=>xe,initializeUnifiedMemory:()=>Ze,resetUnifiedMemory:()=>et,validateTableName:()=>A});import*as f from"fs";import*as Xe from"os";import*as S from"path";function Ue(){let s=D();return S.join(s,".agentic-qe","memory.db")}function Fe(){return{...we,dbPath:Ue()}}function xe(s){return v.getInstance(s)}async function Ze(s){let e=xe(s);return await e.initialize(),e}function et(){v.resetInstance()}function tt(){if(ye)return;ye=!0;let s=()=>{try{let e=v.instance;e&&e.close()}catch(e){console.debug("[UnifiedMemory] Cleanup error:",e instanceof Error?e.message:e)}};process.on("beforeExit",s),process.on("SIGINT",()=>{s(),process.exit(0)}),process.on("SIGTERM",()=>{s(),process.exit(0)})}var y,we,v,ye,rt=R(()=>{je();oe();ke();Be();qe();le();$();$();Te();Te();Ae();K();De();We();y=re.create("unified-memory");we={dbPath:".agentic-qe/memory.db",walMode:!0,mmapSize:b.MMAP_SIZE_BYTES,cacheSize:b.CACHE_SIZE_KB,busyTimeout:b.BUSY_TIMEOUT_MS,vectorDimensions:b.DEFAULT_VECTOR_DIMENSIONS};v=class s{static instance=null;static instancePromise=null;db=null;config;initialized=!1;vectorsLoaded=!1;initPromise=null;preparedStatements=new Map;vectorIndex=new U("qe-memory");crdtStore=null;proofGate=null;proofGateEnvChecked=!1;static PROOF_NS="__proofgate__";static PROOF_KEY="chain";constructor(e){let t=Fe();if(this.config={...t,...e},process.env.AQE_MEMORY_BACKEND==="memory"){this.config.dbPath=":memory:";return}if(this.config.dbPath!==":memory:"&&!S.isAbsolute(this.config.dbPath)){let n=D();this.config.dbPath=S.join(n,this.config.dbPath)}}static getInstance(e){return s.instance||(s.instance=new s(e)),s.instance}static async getInstanceAsync(e){return s.instance?.initialized?s.instance:(s.instancePromise||(s.instancePromise=(async()=>{let t=s.getInstance(e);return await t.initialize(),t})()),s.instancePromise)}static resetInstance(){s.instance&&(s.instance.close(),s.instance=null),s.instancePromise=null,H()}async initialize(e){if(!this.initialized)return this.initPromise||(this.initPromise=this._doInitialize(e?.signal)),this.initPromise}async _doInitialize(e){if(!this.initialized){e?.throwIfAborted();try{let t=this.config.dbPath===":memory:",n="",a=!1,o=0;if(!t){let T=process.env.AQE_PROJECT_ROOT;if(T){let d=S.resolve(this.config.dbPath),E=S.resolve(T);!d.startsWith(E)&&!d.startsWith(Xe.tmpdir())&&d.includes(".agentic-qe")&&(console.error(`[UnifiedMemory] WARNING: DB path "${this.config.dbPath}" points to a production .agentic-qe/ while AQE_PROJECT_ROOT="${T}". Redirecting to test-safe path.`),this.config.dbPath=S.join(T,".agentic-qe","memory.db"))}if(n=S.dirname(this.config.dbPath),f.existsSync(n)||f.mkdirSync(n,{recursive:!0}),a=f.existsSync(this.config.dbPath),a)o=f.statSync(this.config.dbPath).size;else if(f.existsSync(n)){let d=this.findRecentBackups(n);if(d.length>0){let E=d[0];console.error(`[UnifiedMemory] CRITICAL: Database file missing but directory exists!
734
+ `,Me=["kv_store","vectors","rl_q_values","goap_actions","goap_goals","goap_plans","goap_plan_signatures","goap_execution_steps","concept_nodes","concept_edges","dream_cycles","dream_insights","qe_patterns","qe_pattern_embeddings","qe_pattern_usage","qe_trajectories","embeddings","execution_results","executed_steps","mincut_snapshots","mincut_history","mincut_weak_vertices","mincut_alerts","mincut_healing_actions","mincut_observations","hypergraph_nodes","hypergraph_edges","sona_patterns","witness_chain","learning_evidence_manifests","learning_evidence_segments","learning_segment_edges","learning_evidence_admissions","pattern_manifest_lineage","pattern_segment_lineage"]});function ne(n,e,t){return n.prepare("SELECT 1 FROM sqlite_master WHERE type = ? AND name = ?").get(e,t)!==void 0}function ke(n){return n.replace(/\s+/g," ").trim().replace(/^CREATE TRIGGER IF NOT EXISTS /i,"CREATE TRIGGER ").replace(/ ?;$/,"").toLowerCase()}function w(n,e){return n.prepare(e).get()?.n??0}function Ge(n){let e=ne(n,"table","qe_patterns_fts"),t=e&&ne(n,"table","qe_patterns_fts_docsize"),r=[],i=[],o=n.prepare("SELECT sql FROM sqlite_master WHERE type = 'trigger' AND name = ?");for(let u of dt){let l=o.get(u);l===void 0?r.push(u):ke(l.sql??"")!==ut[u]&&i.push(u)}let E=w(n,"SELECT count(*) AS n FROM qe_patterns"),c=t?w(n,"SELECT count(*) AS n FROM qe_patterns_fts_docsize"):-1,T=t&&c===E?w(n,`SELECT count(*) AS n FROM qe_patterns p
735
+ WHERE NOT EXISTS (SELECT 1 FROM qe_patterns_fts_docsize d WHERE d.id = p.rowid)`):0;return{hasTable:e,hasDocsize:t,missingTriggers:r,mismatchedTriggers:i,patterns:E,indexed:c,unindexed:T}}function Pe(n){return!n.hasTable||n.missingTriggers.length>0||n.mismatchedTriggers.length>0?!0:n.hasDocsize?n.indexed!==n.patterns||n.unindexed>0:!1}function lt(n){if(n.readonly)return!0;try{return Number(n.pragma("query_only",{simple:!0}))===1}catch{return!1}}function qe(n,e={}){let t=e.log??(o=>console.warn(o)),r=e.logPrefix??"[PatternFTS]",i={status:"healthy",createdTable:!1,recreatedTriggers:[],replacedTriggers:[],rebuilt:!1,patternsBefore:-1,indexedBefore:-1,indexedAfter:-1};try{if(!ne(n,"table","qe_patterns"))return i.status="no-patterns",i;if(lt(n))return i.status="readonly",i;let o=Ge(n);if(i.patternsBefore=o.patterns,i.indexedBefore=o.indexed,!Pe(o))return i;let E=n.transaction(()=>{let c=Ge(n);if(!Pe(c))return null;c.hasTable||n.exec(Z);for(let T of c.missingTriggers)n.exec(b[T]);for(let T of c.mismatchedTriggers)n.exec(`DROP TRIGGER IF EXISTS ${T}`),n.exec(b[T]);return n.exec("INSERT INTO qe_patterns_fts(qe_patterns_fts) VALUES('rebuild')"),{s:c,indexedAfter:w(n,"SELECT count(*) AS n FROM qe_patterns_fts_docsize")}}).immediate();if(E){let{s:c}=E;i.createdTable=!c.hasTable,i.recreatedTriggers=[...c.missingTriggers],i.replacedTriggers=[...c.mismatchedTriggers],i.patternsBefore=c.patterns,i.indexedBefore=c.indexed,i.indexedAfter=E.indexedAfter,i.rebuilt=!0}if(i.rebuilt){i.status="healed";let c=[];i.createdTable&&c.push("created qe_patterns_fts"),i.recreatedTriggers.length>0&&c.push(`recreated triggers [${i.recreatedTriggers.join(", ")}]`),i.replacedTriggers.length>0&&c.push(`replaced triggers [${i.replacedTriggers.join(", ")}]`);let T=i.indexedBefore<0?"n/a":String(i.indexedBefore);c.push(`rebuilt index (indexed ${T} -> ${i.indexedAfter}, qe_patterns ${i.patternsBefore})`),t(`${r} Healed qe_patterns FTS5 index: ${c.join("; ")}`)}return i}catch(o){i.status="failed",i.error=O(o);try{t(`${r} qe_patterns FTS5 self-heal skipped: ${i.error} (keyword search may be degraded; vector search unaffected)`)}catch{}return i}}var dt,ut,Be=R(()=>{"use strict";ce();te();dt=Object.keys(b);ut=Object.freeze(Object.fromEntries(Object.entries(b).map(([n,e])=>[n,ke(e)])))});function M(n,e,t){let r={value:e,timestamp:t??(e!==void 0?Date.now():0),nodeId:e!==void 0?n:"",version:e!==void 0?1:0,lastUpdated:Date.now()};function i(o,E,c,T){return o!==c?o-c:E.localeCompare(T)}return{get(){return r.value},set(o,E){let c=E??Date.now();(r.timestamp===0||i(c,n,r.timestamp,r.nodeId)>0)&&(r={value:o,timestamp:c,nodeId:n,version:r.version+1,lastUpdated:Date.now()})},merge(o){let E=o.getState();this.applyState(E)},getState(){return{value:r.value,timestamp:r.timestamp,nodeId:r.nodeId,version:r.version,lastUpdated:r.lastUpdated}},applyState(o){(r.timestamp===0||i(o.timestamp,o.nodeId,r.timestamp,r.nodeId)>0)&&(r={value:o.value,timestamp:o.timestamp,nodeId:o.nodeId,version:Math.max(r.version,o.version)+1,lastUpdated:Date.now()})},getNodeId(){return n},getTimestamp(){return r.timestamp}}}function G(n,e){let t=M(n);return t.applyState(e),t}var re=R(()=>{"use strict"});function C(n){let e={counts:{},version:0,lastUpdated:Date.now()};return e.counts[n]=0,{get(){return Object.values(e.counts).reduce((t,r)=>t+r,0)},increment(t=1){if(t<0)throw new Error("G-Counter can only increment by positive values");t!==0&&(e.counts[n]=(e.counts[n]||0)+t,e.version++,e.lastUpdated=Date.now())},merge(t){let r=t.getState();this.applyState(r)},getState(){return{counts:{...e.counts},version:e.version,lastUpdated:e.lastUpdated}},applyState(t){let r=!1;for(let[i,o]of Object.entries(t.counts)){let E=e.counts[i]||0;o>E&&(e.counts[i]=o,r=!0)}r&&(e.version=Math.max(e.version,t.version)+1,e.lastUpdated=Date.now())},getNodeId(){return n},getLocalCount(){return e.counts[n]||0}}}function P(n,e){let t=C(n);return t.applyState(e),t}var k=R(()=>{"use strict"});function q(n){let e=C(n),t=C(n),r=0,i=Date.now();return{get(){return e.get()-t.get()},increment(o=1){if(o<0)throw new Error("Use decrement() for negative values");o!==0&&(e.increment(o),r++,i=Date.now())},decrement(o=1){if(o<0)throw new Error("Use increment() for negative values");o!==0&&(t.increment(o),r++,i=Date.now())},merge(o){let E=o.getState();this.applyState(E)},getState(){return{positive:e.getState(),negative:t.getState(),version:r,lastUpdated:i}},applyState(o){let E=this.get();e.applyState(o.positive),t.applyState(o.negative);let c=this.get();E!==c&&(r=Math.max(r,o.version)+1,i=Date.now())},getNodeId(){return n}}}function B(n,e){let t=q(n);return t.applyState(e),t}var se=R(()=>{"use strict";k()});function gt(n,e){return`${n}:${Date.now()}:${e}`}function ie(n){return typeof n=="string"?`s:${n}`:typeof n=="number"?`n:${n}`:typeof n=="boolean"?`b:${n}`:`j:${JSON.stringify(n)}`}function pt(n){let e=n.substring(0,2),t=n.substring(2);switch(e){case"s:":return t;case"n:":return Number(t);case"b:":return t==="true";case"j:":return I(t);default:throw new Error(`Unknown serialization type: ${e}`)}}function j(n){let e=new Map,t=new Map,r=0,i=Date.now(),o=0;function E(T){let u=e.get(T);if(!u||u.size===0)return!1;let l=t.get(T);if(!l||l.size===0)return!0;for(let m of u)if(!l.has(m))return!0;return!1}function c(T){let u=e.get(T);if(!u)return new Set;let l=t.get(T)||new Set,m=new Set;for(let p of u)l.has(p)||m.add(p);return m}return{has(T){let u=ie(T);return E(u)},values(){let T=[];for(let[u]of e)E(u)&&T.push(pt(u));return T},size(){let T=0;for(let[u]of e)E(u)&&T++;return T},add(T){let u=ie(T),l=gt(n,o++);e.has(u)||e.set(u,new Set),e.get(u).add(l),r++,i=Date.now()},remove(T){let u=ie(T),l=e.get(u);if(!l||l.size===0)return;t.has(u)||t.set(u,new Set);let m=t.get(u);for(let p of l)m.add(p);r++,i=Date.now()},merge(T){let u=T.getState();this.applyState(u)},getState(){let T={};for(let[l,m]of e)T[l]=Array.from(m);let u={};for(let[l,m]of t)m.size>0&&(u[l]=Array.from(m));return{elements:T,tombstones:u,version:r,lastUpdated:i}},applyState(T){let u=!1;for(let[l,m]of Object.entries(T.elements)){e.has(l)||e.set(l,new Set);let p=e.get(l);for(let g of m)p.has(g)||(p.add(g),u=!0)}for(let[l,m]of Object.entries(T.tombstones)){t.has(l)||t.set(l,new Set);let p=t.get(l);for(let g of m)p.has(g)||(p.add(g),u=!0)}u&&(r=Math.max(r,T.version)+1,i=Date.now())},getNodeId(){return n},clear(){for(let[T,u]of e){t.has(T)||t.set(T,new Set);let l=t.get(T);for(let m of u)l.add(m)}r++,i=Date.now()}}}function z(n,e){let t=j(n);return t.applyState(e),t}var oe=R(()=>{"use strict";ge()});function ae(n){let e={..._t,...n},{nodeId:t,enableDeltaTracking:r,maxDeltaHistory:i}=e,o=new Map,E=new Map,c=new Map,T=new Map,u=0,l=[],m=new Set,p={registers:new Set,gCounters:new Set,pnCounters:new Set,sets:new Set};function g(a,s,d){let N={key:a,type:s,operation:d,timestamp:Date.now(),nodeId:t};for(let Je of m)try{Je(N)}catch(Ze){console.error("[CRDTStore] Error in change listener:",Ze)}}function _(a,s){u++,r&&p[a].add(s)}function L(){if(!r||!(p.registers.size>0||p.gCounters.size>0||p.pnCounters.size>0||p.sets.size>0))return;let s={fromVersion:l.length>0?l[l.length-1].toVersion:0,toVersion:u,timestamp:Date.now(),nodeId:t};if(p.registers.size>0){s.registers={};for(let d of p.registers){let N=o.get(d);N&&(s.registers[d]=N.getState())}p.registers.clear()}if(p.gCounters.size>0){s.gCounters={};for(let d of p.gCounters){let N=E.get(d);N&&(s.gCounters[d]=N.getState())}p.gCounters.clear()}if(p.pnCounters.size>0){s.pnCounters={};for(let d of p.pnCounters){let N=c.get(d);N&&(s.pnCounters[d]=N.getState())}p.pnCounters.clear()}if(p.sets.size>0){s.sets={};for(let d of p.sets){let N=T.get(d);N&&(s.sets[d]=N.getState())}p.sets.clear()}for(l.push(s);l.length>i;)l.shift()}let h={getRegister(a){return o.has(a)||o.set(a,M(t)),o.get(a)},setRegister(a,s){h.getRegister(a).set(s),_("registers",a),g(a,"lww-register","set")},hasRegister(a){return o.has(a)},deleteRegister(a){let s=o.delete(a);return s&&_("registers",a),s},getGCounter(a){return E.has(a)||E.set(a,C(t)),E.get(a)},incrementGCounter(a,s){h.getGCounter(a).increment(s),_("gCounters",a),g(a,"g-counter","increment")},hasGCounter(a){return E.has(a)},deleteGCounter(a){let s=E.delete(a);return s&&_("gCounters",a),s},getCounter(a){return c.has(a)||c.set(a,q(t)),c.get(a)},incrementCounter(a,s){h.getCounter(a).increment(s),_("pnCounters",a),g(a,"pn-counter","increment")},decrementCounter(a,s){h.getCounter(a).decrement(s),_("pnCounters",a),g(a,"pn-counter","decrement")},hasCounter(a){return c.has(a)},deleteCounter(a){let s=c.delete(a);return s&&_("pnCounters",a),s},getSet(a){return T.has(a)||T.set(a,j(t)),T.get(a)},addToSet(a,s){h.getSet(a).add(s),_("sets",a),g(a,"or-set","add")},removeFromSet(a,s){h.getSet(a).remove(s),_("sets",a),g(a,"or-set","remove")},hasSet(a){return T.has(a)},deleteSet(a){let s=T.delete(a);return s&&_("sets",a),s},merge(a){let s=a.getState();h.applyState(s)},getState(){L();let a={version:u,timestamp:Date.now(),nodeId:t,registers:{},gCounters:{},pnCounters:{},sets:{}};for(let[s,d]of o)a.registers[s]=d.getState();for(let[s,d]of E)a.gCounters[s]=d.getState();for(let[s,d]of c)a.pnCounters[s]=d.getState();for(let[s,d]of T)a.sets[s]=d.getState();return a},applyState(a){for(let[s,d]of Object.entries(a.registers))o.has(s)?o.get(s).applyState(d):o.set(s,G(t,d)),_("registers",s),g(s,"lww-register","merge");for(let[s,d]of Object.entries(a.gCounters))E.has(s)?E.get(s).applyState(d):E.set(s,P(t,d)),_("gCounters",s),g(s,"g-counter","merge");for(let[s,d]of Object.entries(a.pnCounters))c.has(s)?c.get(s).applyState(d):c.set(s,B(t,d)),_("pnCounters",s),g(s,"pn-counter","merge");for(let[s,d]of Object.entries(a.sets))T.has(s)?T.get(s).applyState(d):T.set(s,z(t,d)),_("sets",s),g(s,"or-set","merge");u=Math.max(u,a.version)+1},getDelta(a){if(L(),l.length===0)return a>=u,null;let s=l.filter(N=>N.toVersion>a);if(s.length===0)return null;let d={fromVersion:a,toVersion:u,timestamp:Date.now(),nodeId:t,registers:{},gCounters:{},pnCounters:{},sets:{}};for(let N of s)N.registers&&Object.assign(d.registers,N.registers),N.gCounters&&Object.assign(d.gCounters,N.gCounters),N.pnCounters&&Object.assign(d.pnCounters,N.pnCounters),N.sets&&Object.assign(d.sets,N.sets);return Object.keys(d.registers).length===0&&delete d.registers,Object.keys(d.gCounters).length===0&&delete d.gCounters,Object.keys(d.pnCounters).length===0&&delete d.pnCounters,Object.keys(d.sets).length===0&&delete d.sets,d},applyDelta(a){if(a.registers)for(let[s,d]of Object.entries(a.registers))o.has(s)?o.get(s).applyState(d):o.set(s,G(t,d)),_("registers",s),g(s,"lww-register","merge");if(a.gCounters)for(let[s,d]of Object.entries(a.gCounters))E.has(s)?E.get(s).applyState(d):E.set(s,P(t,d)),_("gCounters",s),g(s,"g-counter","merge");if(a.pnCounters)for(let[s,d]of Object.entries(a.pnCounters))c.has(s)?c.get(s).applyState(d):c.set(s,B(t,d)),_("pnCounters",s),g(s,"pn-counter","merge");if(a.sets)for(let[s,d]of Object.entries(a.sets))T.has(s)?T.get(s).applyState(d):T.set(s,z(t,d)),_("sets",s),g(s,"or-set","merge");u=Math.max(u,a.toVersion)+1},getVersion(){return u},getNodeId(){return t},on(a,s){if(a==="change")return m.add(s),()=>{m.delete(s)};throw new Error(`Unknown event type: ${a}`)},removeAllListeners(){m.clear()},keys(a){let s=[];return(!a||a==="lww-register")&&s.push(...Array.from(o.keys())),(!a||a==="g-counter")&&s.push(...Array.from(E.keys())),(!a||a==="pn-counter")&&s.push(...Array.from(c.keys())),(!a||a==="or-set")&&s.push(...Array.from(T.keys())),s},clear(){o.clear(),E.clear(),c.clear(),T.clear(),l.length=0,p.registers.clear(),p.gCounters.clear(),p.pnCounters.clear(),p.sets.clear(),u=0},getStats(){return{total:o.size+E.size+c.size+T.size,registers:o.size,gCounters:E.size,pnCounters:c.size,sets:T.size,version:u,nodeId:t,deltaHistorySize:l.length}}};return h}var _t,je=R(()=>{"use strict";re();k();se();oe();_t={nodeId:"default-node",enableDeltaTracking:!0,maxDeltaHistory:100}});var ze=R(()=>{"use strict"});var He=R(()=>{"use strict";re();k();se();oe();je();ze()});var St={};et(St,{ALLOWED_TABLE_NAMES:()=>K,BinaryHeap:()=>pe,DEFAULT_UNIFIED_MEMORY_CONFIG:()=>Ke,UnifiedHnswIndex:()=>F,UnifiedMemoryManager:()=>D,clearProjectRootCache:()=>Y,createHnswIndex:()=>_e,findProjectRoot:()=>X,getDefaultDbPath:()=>$e,getResolvedDefaultConfig:()=>Ve,getUnifiedMemory:()=>Qe,initializeUnifiedMemory:()=>mt,resetUnifiedMemory:()=>ft,validateTableName:()=>v});import*as f from"fs";import*as Ye from"os";import*as S from"path";function $e(){let n=X();return S.join(n,".agentic-qe","memory.db")}function Ve(){return{...Ke,dbPath:$e()}}function Qe(n){return D.getInstance(n)}async function mt(n){let e=Qe(n);return await e.initialize(),e}function ft(){D.resetInstance()}function Nt(){if(We)return;We=!0;let n=()=>{try{let t=D.instance;t&&t.close()}catch(t){console.debug("[UnifiedMemory] Cleanup error:",t instanceof Error?t.message:t)}};process.on("beforeExit",n),Ee(n);let e=t=>{de(t)||(n(),process.exit(0))};process.on("SIGINT",e),process.on("SIGTERM",e)}var U,Ke,D,We,ht=R(()=>{st();ge();ce();rt();tt();Re();V();V();me();me();te();Be();Q();He();at();nt();U=Te.create("unified-memory");Ke={dbPath:".agentic-qe/memory.db",walMode:!0,mmapSize:y.MMAP_SIZE_BYTES,cacheSize:y.CACHE_SIZE_KB,busyTimeout:y.BUSY_TIMEOUT_MS,vectorDimensions:y.DEFAULT_VECTOR_DIMENSIONS};D=class n{static instance=null;static instancePromise=null;db=null;config;initialized=!1;vectorsLoaded=!1;initPromise=null;preparedStatements=new Map;vectorIndex=new F("qe-memory");crdtStore=null;proofGate=null;proofGateEnvChecked=!1;static PROOF_NS="__proofgate__";static PROOF_KEY="chain";constructor(e){let t=Ve();if(this.config={...t,...e},process.env.AQE_MEMORY_BACKEND==="memory"){this.config.dbPath=":memory:";return}if(this.config.dbPath!==":memory:"&&!S.isAbsolute(this.config.dbPath)){let r=X();this.config.dbPath=S.join(r,this.config.dbPath)}}static getInstance(e){return n.instance||(n.instance=new n(e)),n.instance}static async getInstanceAsync(e){return n.instance?.initialized?n.instance:(n.instancePromise||(n.instancePromise=(async()=>{let t=n.getInstance(e);return await t.initialize(),t})()),n.instancePromise)}static resetInstance(){n.instance&&(n.instance.close(),n.instance=null),n.instancePromise=null,Y()}async initialize(e){if(!this.initialized)return this.initPromise||(this.initPromise=this._doInitialize(e?.signal)),this.initPromise}async _doInitialize(e){if(!this.initialized){e?.throwIfAborted();try{let t=this.config.dbPath===":memory:",r="",i=!1,o=0;if(!t){let E=process.env.AQE_PROJECT_ROOT;if(E){let c=S.resolve(this.config.dbPath),T=S.resolve(E);!c.startsWith(T)&&!c.startsWith(Ye.tmpdir())&&c.includes(".agentic-qe")&&(console.error(`[UnifiedMemory] WARNING: DB path "${this.config.dbPath}" points to a production .agentic-qe/ while AQE_PROJECT_ROOT="${E}". Redirecting to test-safe path.`),this.config.dbPath=S.join(E,".agentic-qe","memory.db"))}if(r=S.dirname(this.config.dbPath),f.existsSync(r)||f.mkdirSync(r,{recursive:!0}),i=f.existsSync(this.config.dbPath),i)o=f.statSync(this.config.dbPath).size;else if(f.existsSync(r)){let c=this.findRecentBackups(r);if(c.length>0){let T=c[0];console.error(`[UnifiedMemory] CRITICAL: Database file missing but directory exists!
734
736
  Expected: ${this.config.dbPath}
735
- Found ${d.length} backup(s), newest: ${E.path} (${(E.size/1024/1024).toFixed(1)}MB)
736
- Restoring from backup to prevent data loss...`),f.copyFileSync(E.path,this.config.dbPath);for(let u of["-wal","-shm"]){let _=this.config.dbPath+u;f.existsSync(_)&&f.unlinkSync(_)}o=E.size}}}if(e?.throwIfAborted(),this.db=ie(this.config.dbPath,{walMode:this.config.walMode,busyTimeout:this.config.busyTimeout,autoRestore:!0}),this.db.pragma(`mmap_size = ${this.config.mmapSize}`),this.db.pragma(`cache_size = ${this.config.cacheSize}`),this.db.pragma("foreign_keys = ON"),e?.aborted){try{this.db.close()}catch{}this.db=null,e.throwIfAborted()}if(await this.runMigrations(),e?.throwIfAborted(),a&&o>1e6)try{let T=this.db.prepare("SELECT COUNT(*) as cnt FROM qe_patterns").get();if(T&&T.cnt===0){let d=f.statSync(this.config.dbPath).size;d<o*.1&&console.error(`[UnifiedMemory] CRITICAL: Possible data loss detected!
737
- DB was ${(o/1024/1024).toFixed(1)}MB, now ${(d/1024/1024).toFixed(1)}MB with 0 patterns.
737
+ Found ${c.length} backup(s), newest: ${T.path} (${(T.size/1024/1024).toFixed(1)}MB)
738
+ Restoring from backup to prevent data loss...`),f.copyFileSync(T.path,this.config.dbPath);for(let u of["-wal","-shm"]){let l=this.config.dbPath+u;f.existsSync(l)&&f.unlinkSync(l)}o=T.size}}}if(e?.throwIfAborted(),this.db=le(this.config.dbPath,{walMode:this.config.walMode,busyTimeout:this.config.busyTimeout,autoRestore:!0}),this.db.pragma(`mmap_size = ${this.config.mmapSize}`),this.db.pragma(`cache_size = ${this.config.cacheSize}`),this.db.pragma("foreign_keys = ON"),e?.aborted){try{this.db.close()}catch{}this.db=null,e.throwIfAborted()}if(await this.runMigrations(),qe(this.db,{logPrefix:"[UnifiedMemory]"}),e?.throwIfAborted(),i&&o>1e6)try{let E=this.db.prepare("SELECT COUNT(*) as cnt FROM qe_patterns").get();if(E&&E.cnt===0){let c=f.statSync(this.config.dbPath).size;c<o*.1&&console.error(`[UnifiedMemory] CRITICAL: Possible data loss detected!
739
+ DB was ${(o/1024/1024).toFixed(1)}MB, now ${(c/1024/1024).toFixed(1)}MB with 0 patterns.
738
740
  This looks like the DB was replaced with an empty schema.
739
- Check backups in ${n} and restore manually.`)}}catch{}this.vectorsLoaded=!1,this.initialized=!0,console.log(`[UnifiedMemory] Initialized: ${this.config.dbPath}`),this.warnIfDuplicateDatabases()}catch(t){throw this.initPromise=null,t instanceof Error&&(t.name==="AbortError"||(e?.aborted??!1))?t:new Error(`Failed to initialize UnifiedMemoryManager: ${X(t)}`)}}}findRecentBackups(e){try{let n=f.readdirSync(e).filter(o=>o.startsWith("memory")&&o.endsWith(".db")&&o!=="memory.db").map(o=>{let T=S.join(e,o),d=f.statSync(T);return{path:T,size:d.size,mtime:d.mtimeMs}}).filter(o=>o.size>1e6).sort((o,T)=>T.mtime-o.mtime),a=S.join(e,"backups");if(f.existsSync(a)){let o=f.readdirSync(a);for(let T of o)if(T.endsWith(".db")){let d=S.join(a,T),E=f.statSync(d);E.size>1e6&&n.push({path:d,size:E.size,mtime:E.mtimeMs})}n.sort((T,d)=>d.mtime-T.mtime)}return n}catch{return[]}}warnIfDuplicateDatabases(){if(this.config.dbPath!==":memory:")try{let e=D(),t=S.resolve(this.config.dbPath),a=[S.join(e,".agentic-qe","memory.db"),S.join(e,"v3",".agentic-qe","memory.db")].map(o=>S.resolve(o)).filter(o=>o!==t&&f.existsSync(o));a.length>0&&console.warn(`[UnifiedMemory] WARNING: Duplicate database(s) detected!
741
+ Check backups in ${r} and restore manually.`)}}catch{}this.vectorsLoaded=!1,this.initialized=!0,console.log(`[UnifiedMemory] Initialized: ${this.config.dbPath}`),this.warnIfDuplicateDatabases()}catch(t){throw this.initPromise=null,t instanceof Error&&(t.name==="AbortError"||(e?.aborted??!1))?t:new Error(`Failed to initialize UnifiedMemoryManager: ${O(t)}`)}}}findRecentBackups(e){try{let r=f.readdirSync(e).filter(o=>o.startsWith("memory")&&o.endsWith(".db")&&o!=="memory.db").map(o=>{let E=S.join(e,o),c=f.statSync(E);return{path:E,size:c.size,mtime:c.mtimeMs}}).filter(o=>o.size>1e6).sort((o,E)=>E.mtime-o.mtime),i=S.join(e,"backups");if(f.existsSync(i)){let o=f.readdirSync(i);for(let E of o)if(E.endsWith(".db")){let c=S.join(i,E),T=f.statSync(c);T.size>1e6&&r.push({path:c,size:T.size,mtime:T.mtimeMs})}r.sort((E,c)=>c.mtime-E.mtime)}return r}catch{return[]}}warnIfDuplicateDatabases(){if(this.config.dbPath!==":memory:")try{let e=X(),t=S.resolve(this.config.dbPath),i=[S.join(e,".agentic-qe","memory.db"),S.join(e,"v3",".agentic-qe","memory.db")].map(o=>S.resolve(o)).filter(o=>o!==t&&f.existsSync(o));i.length>0&&console.warn(`[UnifiedMemory] WARNING: Duplicate database(s) detected!
740
742
  Canonical: ${t}
741
- Duplicates: ${a.join(", ")}
742
- This can cause data splits. Remove duplicates or set AQE_PROJECT_ROOT.`)}catch(e){y.debug("Duplicate database check failed",{error:e instanceof Error?e.message:String(e)})}}columnExists(e,t){if(!this.db)return!1;try{let n=A(e);return this.db.prepare(`PRAGMA table_info(${n})`).all().some(o=>o.name===t)}catch(n){return y.debug("Column existence check failed",{table:e,column:t,error:n instanceof Error?n.message:String(n)}),!1}}handleV2SchemaIncompatibilities(){if(!this.db)return;let e=[{table:"goap_plans",requiredColumn:"status",columnDef:"TEXT DEFAULT 'pending'"},{table:"goap_actions",requiredColumn:"agent_type",columnDef:"TEXT DEFAULT 'unknown'"},{table:"concept_nodes",requiredColumn:"concept_type",columnDef:"TEXT DEFAULT 'general'"},{table:"concept_edges",requiredColumn:"edge_type",columnDef:"TEXT DEFAULT 'related'"},{table:"dream_insights",requiredColumn:"cycle_id",columnDef:"TEXT DEFAULT ''"},{table:"rl_q_values",requiredColumn:"algorithm",columnDef:"TEXT DEFAULT 'q-learning'"}];for(let{table:t,requiredColumn:n,columnDef:a}of e)if(this.db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name=?").get(t)&&!this.columnExists(t,n)){let T=A(t);try{this.db.exec(`ALTER TABLE ${T} ADD COLUMN ${n} ${a}`),console.log(`[UnifiedMemory] Added column ${n} to ${t} (safe migration)`)}catch(d){console.log(`[UnifiedMemory] Column ${n} on ${t}: ${d instanceof Error?d.message:String(d)}`)}}}async runMigrations(){if(!this.db)throw new Error("Database not initialized");this.db.exec(fe),this.handleV2SchemaIncompatibilities();let t=this.db.prepare("SELECT version FROM schema_version WHERE id = 1").get()?.version??0;t<w&&(console.log(`[UnifiedMemory] Migrating from v${t} to v${w}`),this.db.transaction(()=>{t<1&&this.db.exec(Ne),t<2&&this.db.exec(Se),t<3&&(this.db.exec(he),this.db.exec(V),this.db.exec(Re)),t<4&&this.db.exec(Q),t<5&&this.db.exec(Le),t<6&&this.db.exec(j),t<7&&this.db.exec(Ie),t<8&&this.db.exec(Ce),t<9&&(this.db.exec(`
743
- CREATE VIRTUAL TABLE IF NOT EXISTS qe_patterns_fts USING fts5(
744
- name, description, pattern_type, qe_domain,
745
- content='qe_patterns',
746
- content_rowid='rowid'
747
- );
748
-
749
- CREATE TRIGGER IF NOT EXISTS qe_patterns_fts_insert AFTER INSERT ON qe_patterns BEGIN
750
- INSERT INTO qe_patterns_fts(rowid, name, description, pattern_type, qe_domain)
751
- VALUES (new.rowid, new.name, new.description, new.pattern_type, new.qe_domain);
752
- END;
753
-
754
- CREATE TRIGGER IF NOT EXISTS qe_patterns_fts_delete AFTER DELETE ON qe_patterns BEGIN
755
- INSERT INTO qe_patterns_fts(qe_patterns_fts, rowid, name, description, pattern_type, qe_domain)
756
- VALUES ('delete', old.rowid, old.name, old.description, old.pattern_type, old.qe_domain);
757
- END;
758
-
759
- CREATE TRIGGER IF NOT EXISTS qe_patterns_fts_update AFTER UPDATE ON qe_patterns BEGIN
760
- INSERT INTO qe_patterns_fts(qe_patterns_fts, rowid, name, description, pattern_type, qe_domain)
761
- VALUES ('delete', old.rowid, old.name, old.description, old.pattern_type, old.qe_domain);
762
- INSERT INTO qe_patterns_fts(rowid, name, description, pattern_type, qe_domain)
763
- VALUES (new.rowid, new.name, new.description, new.pattern_type, new.qe_domain);
764
- END;
765
- `),this.db.exec(`
766
- INSERT INTO qe_patterns_fts(rowid, name, description, pattern_type, qe_domain)
767
- SELECT rowid, name, description, pattern_type, qe_domain FROM qe_patterns;
768
- `)),t<10&&this.db.exec(z),t<11&&this.migrateToV11GoapExecutionSteps(),t<12&&me(this.db),t<13&&this.migrateToV13EmbeddingSpace(),this.db.prepare(`
743
+ Duplicates: ${i.join(", ")}
744
+ This can cause data splits. Remove duplicates or set AQE_PROJECT_ROOT.`)}catch(e){U.debug("Duplicate database check failed",{error:e instanceof Error?e.message:String(e)})}}columnExists(e,t){if(!this.db)return!1;try{let r=v(e);return this.db.prepare(`PRAGMA table_info(${r})`).all().some(o=>o.name===t)}catch(r){return U.debug("Column existence check failed",{table:e,column:t,error:r instanceof Error?r.message:String(r)}),!1}}handleV2SchemaIncompatibilities(){if(!this.db)return;let e=[{table:"goap_plans",requiredColumn:"status",columnDef:"TEXT DEFAULT 'pending'"},{table:"goap_actions",requiredColumn:"agent_type",columnDef:"TEXT DEFAULT 'unknown'"},{table:"concept_nodes",requiredColumn:"concept_type",columnDef:"TEXT DEFAULT 'general'"},{table:"concept_edges",requiredColumn:"edge_type",columnDef:"TEXT DEFAULT 'related'"},{table:"dream_insights",requiredColumn:"cycle_id",columnDef:"TEXT DEFAULT ''"},{table:"rl_q_values",requiredColumn:"algorithm",columnDef:"TEXT DEFAULT 'q-learning'"}];for(let{table:t,requiredColumn:r,columnDef:i}of e)if(this.db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name=?").get(t)&&!this.columnExists(t,r)){let E=v(t);try{this.db.exec(`ALTER TABLE ${E} ADD COLUMN ${r} ${i}`),console.log(`[UnifiedMemory] Added column ${r} to ${t} (safe migration)`)}catch(c){console.log(`[UnifiedMemory] Column ${r} on ${t}: ${c instanceof Error?c.message:String(c)}`)}}}async runMigrations(){if(!this.db)throw new Error("Database not initialized");this.db.exec(Oe),this.handleV2SchemaIncompatibilities();let t=this.db.prepare("SELECT version FROM schema_version WHERE id = 1").get()?.version??0;t<x&&(console.log(`[UnifiedMemory] Migrating from v${t} to v${x}`),this.db.transaction(()=>{t<1&&this.db.exec(Ae),t<2&&this.db.exec(ve),t<3&&(this.db.exec(be),this.db.exec(J),this.db.exec(De)),t<4&&this.db.exec(Xe),t<5&&this.db.exec(Fe),t<6&&this.db.exec(H),t<7&&this.db.exec(xe),t<8&&this.db.exec(we),t<9&&(this.db.exec(ee),this.db.exec("INSERT INTO qe_patterns_fts(qe_patterns_fts) VALUES('rebuild')")),t<10&&this.db.exec(W),t<11&&this.migrateToV11GoapExecutionSteps(),t<12&&Ce(this.db),t<13&&this.migrateToV13EmbeddingSpace(),this.db.prepare(`
769
745
  INSERT OR REPLACE INTO schema_version (id, version, migrated_at)
770
746
  VALUES (1, ?, datetime('now'))
771
- `).run(w)})(),console.log("[UnifiedMemory] Migration complete"))}migrateToV11GoapExecutionSteps(){let e=this.db;e.exec(V);let t=(n,a,o)=>{e.prepare(`SELECT name FROM pragma_table_info('${n}')`).all().some(d=>d.name===a)||e.exec(`ALTER TABLE ${n} ADD COLUMN ${a} ${o}`)};t("goap_execution_steps","execution_id","TEXT"),t("goap_execution_steps","retries","INTEGER DEFAULT 0"),t("goap_execution_steps","started_at","TEXT"),t("goap_execution_steps","agent_output","TEXT"),t("goap_actions","method","TEXT"),t("goap_actions","params","TEXT"),t("goap_actions","implemented","INTEGER DEFAULT 0"),e.exec("CREATE INDEX IF NOT EXISTS idx_goap_exec_steps_execution ON goap_execution_steps(execution_id)")}async loadVectorIndex(){if(this.vectorsLoaded)return;if(!this.db)throw new Error("Database not initialized");this.vectorIndex.clear();let e=this.db.prepare("SELECT id, embedding, dimensions FROM vectors").all();for(let t of e){let n=this.bufferToFloatArray(t.embedding,t.dimensions);this.vectorIndex.add(t.id,n)}this.vectorsLoaded=!0,console.log(`[UnifiedMemory] Loaded ${e.length} vectors into vector index (ruvector flat)`)}async kvSet(e,t,n="default",a){this.ensureInitialized();let o=a?Date.now()+a*1e3:null,T=JSON.stringify(t);this.db.prepare(`
747
+ `).run(x)})(),console.log("[UnifiedMemory] Migration complete"))}migrateToV11GoapExecutionSteps(){let e=this.db;e.exec(J);let t=(r,i,o)=>{e.prepare(`SELECT name FROM pragma_table_info('${r}')`).all().some(c=>c.name===i)||e.exec(`ALTER TABLE ${r} ADD COLUMN ${i} ${o}`)};t("goap_execution_steps","execution_id","TEXT"),t("goap_execution_steps","retries","INTEGER DEFAULT 0"),t("goap_execution_steps","started_at","TEXT"),t("goap_execution_steps","agent_output","TEXT"),t("goap_actions","method","TEXT"),t("goap_actions","params","TEXT"),t("goap_actions","implemented","INTEGER DEFAULT 0"),e.exec("CREATE INDEX IF NOT EXISTS idx_goap_exec_steps_execution ON goap_execution_steps(execution_id)")}async loadVectorIndex(){if(this.vectorsLoaded)return;if(!this.db)throw new Error("Database not initialized");this.vectorIndex.clear();let e=this.db.prepare("SELECT id, embedding, dimensions FROM vectors").all();for(let t of e){let r=this.bufferToFloatArray(t.embedding,t.dimensions);this.vectorIndex.add(t.id,r)}this.vectorsLoaded=!0,console.log(`[UnifiedMemory] Loaded ${e.length} vectors into vector index (ruvector flat)`)}async kvSet(e,t,r="default",i){this.ensureInitialized();let o=i?Date.now()+i*1e3:null,E=JSON.stringify(t);this.db.prepare(`
772
748
  INSERT OR REPLACE INTO kv_store (key, namespace, value, expires_at)
773
749
  VALUES (?, ?, ?, ?)
774
- `).run(e,n,T,o),this.auditWrite("kvSet",n,e,T)}async kvGet(e,t="default"){this.ensureInitialized();let n=this.db.prepare(`
750
+ `).run(e,r,E,o),this.auditWrite("kvSet",r,e,E)}async kvGet(e,t="default"){this.ensureInitialized();let r=this.db.prepare(`
775
751
  SELECT value, expires_at FROM kv_store
776
752
  WHERE key = ? AND namespace = ?
777
- `).get(e,t);if(n){if(n.expires_at&&Date.now()>n.expires_at){this.db.prepare("DELETE FROM kv_store WHERE key = ? AND namespace = ?").run(e,t);return}return I(n.value)}}async kvDelete(e,t="default"){this.ensureInitialized();let n=this.db.prepare("DELETE FROM kv_store WHERE key = ? AND namespace = ?").run(e,t);return n.changes>0&&this.auditWrite("kvDelete",t,e,""),n.changes>0}async kvExists(e,t="default"){return this.ensureInitialized(),this.db.prepare(`
753
+ `).get(e,t);if(r){if(r.expires_at&&Date.now()>r.expires_at){this.db.prepare("DELETE FROM kv_store WHERE key = ? AND namespace = ?").run(e,t);return}return I(r.value)}}async kvDelete(e,t="default"){this.ensureInitialized();let r=this.db.prepare("DELETE FROM kv_store WHERE key = ? AND namespace = ?").run(e,t);return r.changes>0&&this.auditWrite("kvDelete",t,e,""),r.changes>0}async kvExists(e,t="default"){return this.ensureInitialized(),this.db.prepare(`
778
754
  SELECT 1 FROM kv_store
779
755
  WHERE key = ? AND namespace = ? AND (expires_at IS NULL OR expires_at > ?)
780
- `).get(e,t,Date.now())!==void 0}async kvSearch(e,t="default",n=100){this.ensureInitialized();let a=e.replace(/\*/g,"%").replace(/\?/g,"_");return this.db.prepare(`
756
+ `).get(e,t,Date.now())!==void 0}async kvSearch(e,t="default",r=100){this.ensureInitialized();let i=e.replace(/\*/g,"%").replace(/\?/g,"_");return this.db.prepare(`
781
757
  SELECT key FROM kv_store
782
758
  WHERE namespace = ? AND key LIKE ?
783
759
  AND (expires_at IS NULL OR expires_at > ?)
784
760
  LIMIT ?
785
- `).all(t,a,Date.now(),n).map(T=>T.key)}async kvCleanupExpired(){return this.ensureInitialized(),this.db.prepare("DELETE FROM kv_store WHERE expires_at IS NOT NULL AND expires_at < ?").run(Date.now()).changes}enableProofGate(){this.ensureInitialized(),this.proofGateEnvChecked=!0,!this.proofGate&&(this.proofGate=this.loadProofChain()??new O)}isProofGateEnabled(){return this.proofGate!==null}verifyMemoryIntegrity(){if(!this.proofGate)throw new Error("Proof-gate not enabled \u2014 call enableProofGate() or set AQE_PROOF_GATE=1");return this.proofGate.verifyIntegrity()}getProofChainRoot(){return this.proofGate?this.proofGate.chainRoot():null}getProofChainLength(){return this.proofGate?this.proofGate.length:0}auditWrite(e,t,n,a){if(!this.proofGate){if(this.proofGateEnvChecked||(this.proofGateEnvChecked=!0,process.env.AQE_PROOF_GATE!=="1"))return;this.proofGate=this.loadProofChain()??new O}if(t!==s.PROOF_NS)try{this.proofGate.admit({op:e,ns:t,key:n,value:a}),this.persistProofChain()}catch(o){y.warn(`proof-gate audit skipped for ${t}/${n}: ${X(o)}`)}}persistProofChain(){!this.proofGate||!this.db||this.db.prepare(`
761
+ `).all(t,i,Date.now(),r).map(E=>E.key)}async kvCleanupExpired(){return this.ensureInitialized(),this.db.prepare("DELETE FROM kv_store WHERE expires_at IS NOT NULL AND expires_at < ?").run(Date.now()).changes}enableProofGate(){this.ensureInitialized(),this.proofGateEnvChecked=!0,!this.proofGate&&(this.proofGate=this.loadProofChain()??new A)}isProofGateEnabled(){return this.proofGate!==null}verifyMemoryIntegrity(){if(!this.proofGate)throw new Error("Proof-gate not enabled \u2014 call enableProofGate() or set AQE_PROOF_GATE=1");return this.proofGate.verifyIntegrity()}getProofChainRoot(){return this.proofGate?this.proofGate.chainRoot():null}getProofChainLength(){return this.proofGate?this.proofGate.length:0}auditWrite(e,t,r,i){if(!this.proofGate){if(this.proofGateEnvChecked||(this.proofGateEnvChecked=!0,process.env.AQE_PROOF_GATE!=="1"))return;this.proofGate=this.loadProofChain()??new A}if(t!==n.PROOF_NS)try{this.proofGate.admit({op:e,ns:t,key:r,value:i}),this.persistProofChain()}catch(o){U.warn(`proof-gate audit skipped for ${t}/${r}: ${O(o)}`)}}persistProofChain(){!this.proofGate||!this.db||this.db.prepare(`
786
762
  INSERT OR REPLACE INTO kv_store (key, namespace, value, expires_at)
787
763
  VALUES (?, ?, ?, NULL)
788
- `).run(s.PROOF_KEY,s.PROOF_NS,JSON.stringify(this.proofGate.toJSON()))}loadProofChain(){if(!this.db)return null;let e=this.db.prepare(`
764
+ `).run(n.PROOF_KEY,n.PROOF_NS,JSON.stringify(this.proofGate.toJSON()))}loadProofChain(){if(!this.db)return null;let e=this.db.prepare(`
789
765
  SELECT value FROM kv_store WHERE key = ? AND namespace = ?
790
- `).get(s.PROOF_KEY,s.PROOF_NS);if(!e)return null;try{return O.fromJSON(JSON.parse(e.value))}catch(t){return y.warn(`proof-gate chain failed to load (starting fresh): ${X(t)}`),null}}async vectorStore(e,t,n="default",a){this.ensureInitialized();let o=this.floatArrayToBuffer(t),T=a?JSON.stringify(a):null;this.db.prepare(`
766
+ `).get(n.PROOF_KEY,n.PROOF_NS);if(!e)return null;try{return A.fromJSON(JSON.parse(e.value))}catch(t){return U.warn(`proof-gate chain failed to load (starting fresh): ${O(t)}`),null}}async vectorStore(e,t,r="default",i){this.ensureInitialized();let o=this.floatArrayToBuffer(t),E=i?JSON.stringify(i):null;this.db.prepare(`
791
767
  INSERT OR REPLACE INTO vectors (id, namespace, embedding, dimensions, metadata, updated_at)
792
768
  VALUES (?, ?, ?, ?, ?, datetime('now'))
793
- `).run(e,n,o,t.length,T),this.vectorIndex.add(e,t)}async vectorGet(e){this.ensureInitialized();let t=this.db.prepare(`
769
+ `).run(e,r,o,t.length,E),this.vectorIndex.add(e,t)}async vectorGet(e){this.ensureInitialized();let t=this.db.prepare(`
794
770
  SELECT embedding, dimensions, metadata FROM vectors WHERE id = ?
795
- `).get(e);if(t)return{embedding:this.bufferToFloatArray(t.embedding,t.dimensions),metadata:t.metadata?I(t.metadata):void 0}}async vectorDelete(e){this.ensureInitialized();let t=this.db.prepare("DELETE FROM vectors WHERE id = ?").run(e);return this.vectorIndex.remove(e),t.changes>0}async vectorSearch(e,t=10,n,a){if(this.ensureInitialized(),!Number.isInteger(t)||t<=0)return[];this.vectorsLoaded||await this.loadVectorIndex();let o=this.vectorIndex.size(),T=!!(n||a),d=Math.min(o,Math.max(T?t*2:t,1)),E=n?this.db.prepare("SELECT id, namespace, metadata FROM vectors WHERE namespace = ?").all(n):void 0,u=E?new Map(E.map(l=>[l.id,l])):void 0,_=this.vectorIndex.search(e,d);for(;T&&_.filter(l=>(!a||l.id.startsWith(a))&&(!u||u.has(l.id))).length<t&&d<o;)d=Math.min(o,d*2),_=this.vectorIndex.search(e,d);if(_.length===0)return[];let m=u??(()=>{let l=_.map(h=>h.id),g=l.map(()=>"?").join(","),L=this.db.prepare(`SELECT id, namespace, metadata FROM vectors WHERE id IN (${g})`).all(...l);return new Map(L.map(h=>[h.id,h]))})();if(n){let l=[];for(let g of _){let L=m.get(g.id);if(L&&L.namespace===n&&(!a||g.id.startsWith(a))&&(l.push({id:g.id,score:g.score,metadata:L.metadata?I(L.metadata):void 0}),l.length>=t))break}return l}return(a?_.filter(l=>l.id.startsWith(a)).slice(0,t):_.slice(0,t)).map(l=>{let g=m.get(l.id);return{id:l.id,score:l.score,metadata:g?.metadata?I(g.metadata):void 0}})}migrateToV13EmbeddingSpace(){let e=this.db;if(!e.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='qe_pattern_embeddings'").get()){e.exec(Q);return}e.prepare("PRAGMA table_info('qe_pattern_embeddings')").all().some(a=>a.name==="space_id")||e.exec("ALTER TABLE qe_pattern_embeddings ADD COLUMN space_id TEXT"),e.exec("CREATE INDEX IF NOT EXISTS idx_qe_pattern_embeddings_space ON qe_pattern_embeddings(space_id)")}getVectorSearchProvenance(){return this.vectorIndex.getProvider().isNativeBackend()?{backend:"native-hnsw",indexType:"hnsw",approximate:!0,estimatedRecall:this.vectorIndex.recall(),qualifiedMaxK:se.EF_SEARCH}:{backend:"progressive-hnsw",indexType:"flat",approximate:!1,estimatedRecall:1}}async vectorCount(e){return this.ensureInitialized(),e?this.db.prepare("SELECT COUNT(*) as count FROM vectors WHERE namespace = ?").get(e).count:this.db.prepare("SELECT COUNT(*) as count FROM vectors").get().count}queryCount(e){this.ensureInitialized();let t=A(e);return this.db.prepare(`SELECT COUNT(*) as c FROM ${t}`).get().c}initializeCRDT(e){if(this.crdtStore){console.warn("[UnifiedMemory] CRDT store already initialized");return}this.crdtStore=ne({nodeId:e}),console.log(`[UnifiedMemory] CRDT store initialized for node: ${e}`)}getCRDTStore(){return this.crdtStore}isCRDTInitialized(){return this.crdtStore!==null}async crdtSet(e,t,n="crdt"){this.ensureInitialized(),this.crdtStore&&this.crdtStore.setRegister(e,t),await this.kvSet(e,t,n)}async crdtGet(e,t="crdt"){if(this.crdtStore){let n=this.crdtStore.getRegister(e);if(n)return n.get()}return this.kvGet(e,t)}crdtIncrement(e,t=1){if(!this.crdtStore)throw new Error("CRDT store not initialized. Call initializeCRDT first.");let n=this.crdtStore.getCounter(e);n||(this.crdtStore.incrementCounter(e,0),n=this.crdtStore.getCounter(e));for(let a=0;a<t;a++)this.crdtStore.incrementCounter(e)}crdtGetCounter(e){return this.crdtStore?this.crdtStore.getCounter(e)?.get()??0:0}crdtAddToSet(e,t){if(!this.crdtStore)throw new Error("CRDT store not initialized. Call initializeCRDT first.");this.crdtStore.addToSet(e,t)}crdtRemoveFromSet(e,t){if(!this.crdtStore)throw new Error("CRDT store not initialized. Call initializeCRDT first.");this.crdtStore.removeFromSet(e,t)}crdtGetSet(e){if(!this.crdtStore)return new Set;let t=this.crdtStore.getSet(e);return new Set(t.values())}crdtGetState(){return this.crdtStore?this.crdtStore.getState():null}crdtGetDelta(e){return this.crdtStore?this.crdtStore.getDelta(e??0):null}crdtMerge(e){if(!this.crdtStore)throw new Error("CRDT store not initialized. Call initializeCRDT first.");this.crdtStore.applyState(e)}crdtApplyDelta(e){if(!this.crdtStore)throw new Error("CRDT store not initialized. Call initializeCRDT first.");this.crdtStore.applyDelta(e)}async crdtPersist(){if(!this.crdtStore)return;let e=this.crdtStore.getState();await this.kvSet("__crdt_state__",e,"crdt-internal")}async crdtRestore(){if(!this.crdtStore)return!1;let e=await this.kvGet("__crdt_state__","crdt-internal");return e?(this.crdtStore.applyState(e),!0):!1}getDatabase(){if(!this.db||!this.initialized)throw new Error("UnifiedMemoryManager not initialized");return this.db}isInitialized(){return this.initialized}getDbPath(){return this.config.dbPath}prepare(e,t){if(!this.db)throw new Error("Database not initialized");let n=this.preparedStatements.get(e);return n||(n=this.db.prepare(t),this.preparedStatements.set(e,n)),n}transaction(e){if(!this.db)throw new Error("Database not initialized");return this.db.transaction(e)()}getStats(){if(!this.db)throw new Error("Database not initialized");let e=Oe.map(a=>{try{let o=this.db.prepare(`SELECT COUNT(*) as count FROM ${a}`).get();return{name:a,rowCount:o.count}}catch(o){return y.debug("Table row count query failed",{table:a,error:o instanceof Error?o.message:String(o)}),{name:a,rowCount:0}}}),t=0,n=0;try{f.existsSync(this.config.dbPath)&&(t=f.statSync(this.config.dbPath).size);let a=this.config.dbPath+"-wal";f.existsSync(a)&&(n=f.statSync(a).size)}catch(a){console.debug("[UnifiedMemory] File stat error:",a instanceof Error?a.message:a)}return{tables:e,fileSize:t,walSize:n,vectorIndexSize:this.vectorIndex.size()}}vacuum(){if(!this.db)throw new Error("Database not initialized");this.db.exec("VACUUM")}checkpoint(){if(!this.db)throw new Error("Database not initialized");this.db.pragma("wal_checkpoint(TRUNCATE)")}close(){this.db&&(this.preparedStatements.clear(),this.vectorIndex.clear(),this.db.close(),this.db=null,this.initialized=!1,console.log("[UnifiedMemory] Database closed"))}ensureInitialized(){if(!this.initialized||!this.db)throw new Error("UnifiedMemoryManager not initialized. Call initialize() first.")}floatArrayToBuffer(e){let t=Buffer.alloc(e.length*4);for(let n=0;n<e.length;n++)t.writeFloatLE(e[n],n*4);return t}bufferToFloatArray(e,t){let n=new Float32Array(e.buffer,e.byteOffset,t);return Array.from(n)}};ye=!1;tt()});export{Y as a,A as b,ot as c,$ as d,ge as e,K as f,Ue as g,we as h,Fe as i,v as j,xe as k,Ze as l,et as m,nt as n,rt as o};
771
+ `).get(e);if(t)return{embedding:this.bufferToFloatArray(t.embedding,t.dimensions),metadata:t.metadata?I(t.metadata):void 0}}async vectorDelete(e){this.ensureInitialized();let t=this.db.prepare("DELETE FROM vectors WHERE id = ?").run(e);return this.vectorIndex.remove(e),t.changes>0}async vectorSearch(e,t=10,r,i){if(this.ensureInitialized(),!Number.isInteger(t)||t<=0)return[];this.vectorsLoaded||await this.loadVectorIndex();let o=this.vectorIndex.size(),E=!!(r||i),c=Math.min(o,Math.max(E?t*2:t,1)),T=r?this.db.prepare("SELECT id, namespace, metadata FROM vectors WHERE namespace = ?").all(r):void 0,u=T?new Map(T.map(g=>[g.id,g])):void 0,l=this.vectorIndex.search(e,c);for(;E&&l.filter(g=>(!i||g.id.startsWith(i))&&(!u||u.has(g.id))).length<t&&c<o;)c=Math.min(o,c*2),l=this.vectorIndex.search(e,c);if(l.length===0)return[];let m=u??(()=>{let g=l.map(h=>h.id),_=g.map(()=>"?").join(","),L=this.db.prepare(`SELECT id, namespace, metadata FROM vectors WHERE id IN (${_})`).all(...g);return new Map(L.map(h=>[h.id,h]))})();if(r){let g=[];for(let _ of l){let L=m.get(_.id);if(L&&L.namespace===r&&(!i||_.id.startsWith(i))&&(g.push({id:_.id,score:_.score,metadata:L.metadata?I(L.metadata):void 0}),g.length>=t))break}return g}return(i?l.filter(g=>g.id.startsWith(i)).slice(0,t):l.slice(0,t)).map(g=>{let _=m.get(g.id);return{id:g.id,score:g.score,metadata:_?.metadata?I(_.metadata):void 0}})}migrateToV13EmbeddingSpace(){let e=this.db;if(!e.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='qe_pattern_embeddings'").get()){e.exec(Ue);return}e.prepare("PRAGMA table_info('qe_pattern_embeddings')").all().some(i=>i.name==="space_id")||e.exec("ALTER TABLE qe_pattern_embeddings ADD COLUMN space_id TEXT"),e.exec("CREATE INDEX IF NOT EXISTS idx_qe_pattern_embeddings_space ON qe_pattern_embeddings(space_id)")}getVectorSearchProvenance(){return this.vectorIndex.getProvider().isNativeBackend()?{backend:"native-hnsw",indexType:"hnsw",approximate:!0,estimatedRecall:this.vectorIndex.recall(),qualifiedMaxK:ue.EF_SEARCH}:{backend:"progressive-hnsw",indexType:"flat",approximate:!1,estimatedRecall:1}}async vectorCount(e){return this.ensureInitialized(),e?this.db.prepare("SELECT COUNT(*) as count FROM vectors WHERE namespace = ?").get(e).count:this.db.prepare("SELECT COUNT(*) as count FROM vectors").get().count}queryCount(e){this.ensureInitialized();let t=v(e);return this.db.prepare(`SELECT COUNT(*) as c FROM ${t}`).get().c}initializeCRDT(e){if(this.crdtStore){console.warn("[UnifiedMemory] CRDT store already initialized");return}this.crdtStore=ae({nodeId:e}),console.log(`[UnifiedMemory] CRDT store initialized for node: ${e}`)}getCRDTStore(){return this.crdtStore}isCRDTInitialized(){return this.crdtStore!==null}async crdtSet(e,t,r="crdt"){this.ensureInitialized(),this.crdtStore&&this.crdtStore.setRegister(e,t),await this.kvSet(e,t,r)}async crdtGet(e,t="crdt"){if(this.crdtStore){let r=this.crdtStore.getRegister(e);if(r)return r.get()}return this.kvGet(e,t)}crdtIncrement(e,t=1){if(!this.crdtStore)throw new Error("CRDT store not initialized. Call initializeCRDT first.");let r=this.crdtStore.getCounter(e);r||(this.crdtStore.incrementCounter(e,0),r=this.crdtStore.getCounter(e));for(let i=0;i<t;i++)this.crdtStore.incrementCounter(e)}crdtGetCounter(e){return this.crdtStore?this.crdtStore.getCounter(e)?.get()??0:0}crdtAddToSet(e,t){if(!this.crdtStore)throw new Error("CRDT store not initialized. Call initializeCRDT first.");this.crdtStore.addToSet(e,t)}crdtRemoveFromSet(e,t){if(!this.crdtStore)throw new Error("CRDT store not initialized. Call initializeCRDT first.");this.crdtStore.removeFromSet(e,t)}crdtGetSet(e){if(!this.crdtStore)return new Set;let t=this.crdtStore.getSet(e);return new Set(t.values())}crdtGetState(){return this.crdtStore?this.crdtStore.getState():null}crdtGetDelta(e){return this.crdtStore?this.crdtStore.getDelta(e??0):null}crdtMerge(e){if(!this.crdtStore)throw new Error("CRDT store not initialized. Call initializeCRDT first.");this.crdtStore.applyState(e)}crdtApplyDelta(e){if(!this.crdtStore)throw new Error("CRDT store not initialized. Call initializeCRDT first.");this.crdtStore.applyDelta(e)}async crdtPersist(){if(!this.crdtStore)return;let e=this.crdtStore.getState();await this.kvSet("__crdt_state__",e,"crdt-internal")}async crdtRestore(){if(!this.crdtStore)return!1;let e=await this.kvGet("__crdt_state__","crdt-internal");return e?(this.crdtStore.applyState(e),!0):!1}getDatabase(){if(!this.db||!this.initialized)throw new Error("UnifiedMemoryManager not initialized");return this.db}isInitialized(){return this.initialized}getDbPath(){return this.config.dbPath}prepare(e,t){if(!this.db)throw new Error("Database not initialized");let r=this.preparedStatements.get(e);return r||(r=this.db.prepare(t),this.preparedStatements.set(e,r)),r}transaction(e){if(!this.db)throw new Error("Database not initialized");return this.db.transaction(e)()}getStats(){if(!this.db)throw new Error("Database not initialized");let e=Me.map(i=>{try{let o=this.db.prepare(`SELECT COUNT(*) as count FROM ${i}`).get();return{name:i,rowCount:o.count}}catch(o){return U.debug("Table row count query failed",{table:i,error:o instanceof Error?o.message:String(o)}),{name:i,rowCount:0}}}),t=0,r=0;try{f.existsSync(this.config.dbPath)&&(t=f.statSync(this.config.dbPath).size);let i=this.config.dbPath+"-wal";f.existsSync(i)&&(r=f.statSync(i).size)}catch(i){console.debug("[UnifiedMemory] File stat error:",i instanceof Error?i.message:i)}return{tables:e,fileSize:t,walSize:r,vectorIndexSize:this.vectorIndex.size()}}vacuum(){if(!this.db)throw new Error("Database not initialized");this.db.exec("VACUUM")}checkpoint(){if(!this.db)throw new Error("Database not initialized");this.db.pragma("wal_checkpoint(TRUNCATE)")}close(){this.db&&(this.preparedStatements.clear(),this.vectorIndex.clear(),this.db.close(),this.db=null,this.initialized=!1,console.log("[UnifiedMemory] Database closed"))}ensureInitialized(){if(!this.initialized||!this.db)throw new Error("UnifiedMemoryManager not initialized. Call initialize() first.")}floatArrayToBuffer(e){let t=Buffer.alloc(e.length*4);for(let r=0;r<e.length;r++)t.writeFloatLE(e[r],r*4);return t}bufferToFloatArray(e,t){let r=new Float32Array(e.buffer,e.byteOffset,t);return Array.from(r)}};We=!1;Nt()});export{K as a,v as b,It as c,V as d,Ie as e,Q as f,ee as g,te as h,qe as i,Be as j,$e as k,Ke as l,Ve as m,D as n,Qe as o,mt as p,ft as q,St as r,ht as s};
@@ -1,4 +1,4 @@
1
- import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.14.5");process.exit(0)}
1
+ import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.14.7");process.exit(0)}
2
2
  function l(s,e){let t=s.prepare("SELECT confidence, usage_count, successful_uses FROM qe_patterns WHERE id = ?").get(e.patternId);if(!t)return{updated:!1};let u=e.success?1:0,n=t.usage_count+1,a=t.successful_uses+u,c=a/n,r=Math.min(1,n/100),o=t.confidence*.3+r*.2+c*.5,i=s.prepare(`
3
3
  INSERT INTO qe_pattern_usage (pattern_id, success, metrics_json, feedback)
4
4
  VALUES (?, ?, ?, ?)
@@ -1,2 +1,2 @@
1
- import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.14.5");process.exit(0)}
2
- import{b as d,d as c}from"./chunk-IJHCIXJC.js";import{a as l,c as g}from"./chunk-J5UNP6W3.js";g();c();import{existsSync as y,readFileSync as p}from"node:fs";import{join as o,dirname as u}from"node:path";import{fileURLToPath as m}from"node:url";var i=class extends Error{constructor(t,n,r){super(t);this.code=n;this.cause=r;this.name="PatternLoaderError"}code;cause},s=class a{static instance=null;config;patterns;isLoading=!1;constructor(e={}){this.config={basePath:e.basePath??this.getDefaultBasePath(),throwOnMissing:e.throwOnMissing??!1,validatePatterns:e.validatePatterns??!0},this.patterns={index:null,booster:null,router:null,embedding:null,reasoning:null,loadedAt:null,errors:[]}}static getInstance(e){return a.instance||(a.instance=new a(e)),a.instance}static resetInstance(){a.instance=null}getDefaultBasePath(){try{let e=import.meta.url,t=m(e),n=u(t),r=o(n,"..","..","..");return o(r,"assets","patterns")}catch{return o(process.cwd(),"assets","patterns")}}async loadPatterns(){if(!this.isLoading){this.isLoading=!0,this.patterns.errors=[];try{this.patterns.index=this.loadJsonFile("index.json");let[e,t,n,r]=await Promise.all([Promise.resolve(this.loadJsonFile("adr-051-booster-patterns.json")),Promise.resolve(this.loadJsonFile("adr-051-router-patterns.json")),Promise.resolve(this.loadJsonFile("adr-051-embedding-patterns.json")),Promise.resolve(this.loadJsonFile("adr-051-reasoning-patterns.json"))]);this.patterns.booster=e,this.patterns.router=t,this.patterns.embedding=n,this.patterns.reasoning=r,this.patterns.loadedAt=new Date,this.config.validatePatterns&&this.validateLoadedPatterns()}finally{this.isLoading=!1}}}loadJsonFile(e){let t=o(this.config.basePath,e);try{if(!y(t)){let r=`Pattern file not found: ${t}`;if(this.patterns.errors.push(r),this.config.throwOnMissing)throw new i(r,"FILE_NOT_FOUND");return null}let n=p(t,"utf-8");return d(n)}catch(n){if(n instanceof i)throw n;let r=`Failed to load pattern file ${e}: ${l(n)}`;if(this.patterns.errors.push(r),this.config.throwOnMissing)throw new i(r,"PARSE_ERROR",n instanceof Error?n:void 0);return null}}validateLoadedPatterns(){this.patterns.booster&&(Array.isArray(this.patterns.booster.patterns)||this.patterns.errors.push("Booster patterns file missing patterns array")),this.patterns.router&&(Array.isArray(this.patterns.router.patterns)||this.patterns.errors.push("Router patterns file missing patterns array")),this.patterns.embedding&&(Array.isArray(this.patterns.embedding.patterns)||this.patterns.errors.push("Embedding patterns file missing patterns array")),this.patterns.reasoning&&(Array.isArray(this.patterns.reasoning.patterns)||this.patterns.errors.push("Reasoning patterns file missing patterns array"))}async ensureLoaded(){this.patterns.loadedAt||await this.loadPatterns()}async getIndex(){return await this.ensureLoaded(),this.patterns.index}async getBoosterPatterns(){return await this.ensureLoaded(),this.patterns.booster}async getRouterPatterns(){return await this.ensureLoaded(),this.patterns.router}async getEmbeddingPatterns(){return await this.ensureLoaded(),this.patterns.embedding}async getReasoningPatterns(){return await this.ensureLoaded(),this.patterns.reasoning}async getBoosterPatternByKey(e){let t=await this.getBoosterPatterns();return t?t.patterns.find(r=>r.key===e)??null:null}async getRouterPatternByKey(e){let t=await this.getRouterPatterns();return t?t.patterns.find(r=>r.key===e)??null:null}async getEmbeddingPatternByKey(e){let t=await this.getEmbeddingPatterns();return t?t.patterns.find(r=>r.key===e)??null:null}async getReasoningPatternByKey(e){let t=await this.getReasoningPatterns();return t?t.patterns.find(r=>r.key===e)??null:null}async getEligibleBoosterTransforms(){let e=await this.getBoosterPatternByKey("booster-transform-eligibility");return e?e.eligibility_criteria.simple_transforms:[]}async getTierHierarchy(){let e=await this.getRouterPatternByKey("router-5tier-complexity");return e?e.tier_hierarchy:null}async getQualityGateThresholds(){let e=await this.getReasoningPatternByKey("reasoning-pattern-quality-gates");return e?e.gate_thresholds:null}isLoaded(){return this.patterns.loadedAt!==null}getLoadedAt(){return this.patterns.loadedAt}getErrors(){return[...this.patterns.errors]}async getStatistics(){let e=await this.getIndex();return e?e.pattern_statistics:null}async reload(){this.patterns={index:null,booster:null,router:null,embedding:null,reasoning:null,loadedAt:null,errors:[]},await this.loadPatterns()}async getAllPatterns(){return await this.ensureLoaded(),{...this.patterns}}};function x(){return s.getInstance()}export{x as a};
1
+ import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.14.7");process.exit(0)}
2
+ import{b as d,d as c}from"./chunk-OIDWDGLG.js";import{a as l,e as g}from"./chunk-ZUOVNFXK.js";g();c();import{existsSync as y,readFileSync as p}from"node:fs";import{join as o,dirname as u}from"node:path";import{fileURLToPath as m}from"node:url";var i=class extends Error{constructor(t,n,r){super(t);this.code=n;this.cause=r;this.name="PatternLoaderError"}code;cause},s=class a{static instance=null;config;patterns;isLoading=!1;constructor(e={}){this.config={basePath:e.basePath??this.getDefaultBasePath(),throwOnMissing:e.throwOnMissing??!1,validatePatterns:e.validatePatterns??!0},this.patterns={index:null,booster:null,router:null,embedding:null,reasoning:null,loadedAt:null,errors:[]}}static getInstance(e){return a.instance||(a.instance=new a(e)),a.instance}static resetInstance(){a.instance=null}getDefaultBasePath(){try{let e=import.meta.url,t=m(e),n=u(t),r=o(n,"..","..","..");return o(r,"assets","patterns")}catch{return o(process.cwd(),"assets","patterns")}}async loadPatterns(){if(!this.isLoading){this.isLoading=!0,this.patterns.errors=[];try{this.patterns.index=this.loadJsonFile("index.json");let[e,t,n,r]=await Promise.all([Promise.resolve(this.loadJsonFile("adr-051-booster-patterns.json")),Promise.resolve(this.loadJsonFile("adr-051-router-patterns.json")),Promise.resolve(this.loadJsonFile("adr-051-embedding-patterns.json")),Promise.resolve(this.loadJsonFile("adr-051-reasoning-patterns.json"))]);this.patterns.booster=e,this.patterns.router=t,this.patterns.embedding=n,this.patterns.reasoning=r,this.patterns.loadedAt=new Date,this.config.validatePatterns&&this.validateLoadedPatterns()}finally{this.isLoading=!1}}}loadJsonFile(e){let t=o(this.config.basePath,e);try{if(!y(t)){let r=`Pattern file not found: ${t}`;if(this.patterns.errors.push(r),this.config.throwOnMissing)throw new i(r,"FILE_NOT_FOUND");return null}let n=p(t,"utf-8");return d(n)}catch(n){if(n instanceof i)throw n;let r=`Failed to load pattern file ${e}: ${l(n)}`;if(this.patterns.errors.push(r),this.config.throwOnMissing)throw new i(r,"PARSE_ERROR",n instanceof Error?n:void 0);return null}}validateLoadedPatterns(){this.patterns.booster&&(Array.isArray(this.patterns.booster.patterns)||this.patterns.errors.push("Booster patterns file missing patterns array")),this.patterns.router&&(Array.isArray(this.patterns.router.patterns)||this.patterns.errors.push("Router patterns file missing patterns array")),this.patterns.embedding&&(Array.isArray(this.patterns.embedding.patterns)||this.patterns.errors.push("Embedding patterns file missing patterns array")),this.patterns.reasoning&&(Array.isArray(this.patterns.reasoning.patterns)||this.patterns.errors.push("Reasoning patterns file missing patterns array"))}async ensureLoaded(){this.patterns.loadedAt||await this.loadPatterns()}async getIndex(){return await this.ensureLoaded(),this.patterns.index}async getBoosterPatterns(){return await this.ensureLoaded(),this.patterns.booster}async getRouterPatterns(){return await this.ensureLoaded(),this.patterns.router}async getEmbeddingPatterns(){return await this.ensureLoaded(),this.patterns.embedding}async getReasoningPatterns(){return await this.ensureLoaded(),this.patterns.reasoning}async getBoosterPatternByKey(e){let t=await this.getBoosterPatterns();return t?t.patterns.find(r=>r.key===e)??null:null}async getRouterPatternByKey(e){let t=await this.getRouterPatterns();return t?t.patterns.find(r=>r.key===e)??null:null}async getEmbeddingPatternByKey(e){let t=await this.getEmbeddingPatterns();return t?t.patterns.find(r=>r.key===e)??null:null}async getReasoningPatternByKey(e){let t=await this.getReasoningPatterns();return t?t.patterns.find(r=>r.key===e)??null:null}async getEligibleBoosterTransforms(){let e=await this.getBoosterPatternByKey("booster-transform-eligibility");return e?e.eligibility_criteria.simple_transforms:[]}async getTierHierarchy(){let e=await this.getRouterPatternByKey("router-5tier-complexity");return e?e.tier_hierarchy:null}async getQualityGateThresholds(){let e=await this.getReasoningPatternByKey("reasoning-pattern-quality-gates");return e?e.gate_thresholds:null}isLoaded(){return this.patterns.loadedAt!==null}getLoadedAt(){return this.patterns.loadedAt}getErrors(){return[...this.patterns.errors]}async getStatistics(){let e=await this.getIndex();return e?e.pattern_statistics:null}async reload(){this.patterns={index:null,booster:null,router:null,embedding:null,reasoning:null,loadedAt:null,errors:[]},await this.loadPatterns()}async getAllPatterns(){return await this.ensureLoaded(),{...this.patterns}}};function x(){return s.getInstance()}export{x as a};
@@ -1,2 +1,2 @@
1
- import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.14.5");process.exit(0)}
2
- import{b as t}from"./chunk-JSZ663MU.js";import{randomInt as o}from"node:crypto";function a(){return Math.random()}function m(n,e){return o(n,e)}function c(n,e){return n+Math.random()*(e-n)}var r=t(()=>{"use strict"});export{a,m as b,c,r as d};
1
+ import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.14.7");process.exit(0)}
2
+ import{b as t}from"./chunk-YO4ESCB4.js";import{randomInt as o}from"node:crypto";function a(){return Math.random()}function m(n,e){return o(n,e)}function c(n,e){return n+Math.random()*(e-n)}var r=t(()=>{"use strict"});export{a,m as b,c,r as d};
@@ -1,4 +1,4 @@
1
- import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.14.5");process.exit(0)}
2
- import*as a from"fs";import*as m from"path";import{createRequire as z}from"node:module";var B=z(import.meta.url),b=B("semver"),L="3.14.5",y=t=>typeof t=="string"&&b.valid(t)===t.split("+")[0],E=t=>b.validRange(t)!==null,x=(t,e)=>b.satisfies(t,e),C=(t,e)=>b.compare(t,e),N=(t,e)=>C(e,t)||t.localeCompare(e);var R=class{cacheDir;keepVersions;constructor(e={}){this.cacheDir=e.cacheDir??m.join(process.cwd(),".agentic-qe","plugins"),this.keepVersions=e.keepVersions??2}has(e,n){let s=this.versionDir(e,n);return a.existsSync(s)&&a.existsSync(m.join(s,"qe-plugin.json"))}get(e,n){if(!this.has(e,n))return;let s=this.versionDir(e,n),i=a.readFileSync(m.join(s,"qe-plugin.json"),"utf-8"),r=JSON.parse(i),l=a.statSync(s);return{manifest:r,path:s,cachedAt:l.birthtime.toISOString()}}store(e,n){let s=this.versionDir(e.name,e.version);return a.existsSync(s)||(a.mkdirSync(s,{recursive:!0}),this.copyDir(n,s),a.writeFileSync(m.join(s,"qe-plugin.json"),JSON.stringify(e,null,2)),this.pruneOldVersions(e.name)),s}remove(e,n){let s=this.versionDir(e,n);return a.existsSync(s)?(a.rmSync(s,{recursive:!0,force:!0}),!0):!1}listVersions(e){let n=m.join(this.cacheDir,e);if(!a.existsSync(n))return[];let s=[],i=a.readdirSync(n);for(let r of i){let l=m.join(n,r),d=m.join(l,"qe-plugin.json");if(a.existsSync(d))try{let p=a.readFileSync(d,"utf-8"),v=JSON.parse(p);if(!y(v.version)){console.warn(`[PluginCache] Skipping cached plugin ${e}@${r}: invalid version ${JSON.stringify(v.version)}`);continue}let c=a.statSync(l);s.push({manifest:v,path:l,cachedAt:c.birthtime.toISOString()})}catch{}}return s}listAll(){if(!a.existsSync(this.cacheDir))return[];let e=[],n=a.readdirSync(this.cacheDir);for(let s of n){let i=this.listVersions(s);i.length>0&&(i.sort((r,l)=>N(r.manifest.version,l.manifest.version)),e.push(i[0]))}return e}listCandidates(){return a.existsSync(this.cacheDir)?a.readdirSync(this.cacheDir).flatMap(e=>this.listVersions(e)):[]}versionDir(e,n){return m.join(this.cacheDir,e,n)}pruneOldVersions(e){let n=this.listVersions(e);if(n.length<=this.keepVersions)return;n.sort((i,r)=>i.cachedAt.localeCompare(r.cachedAt));let s=n.slice(0,n.length-this.keepVersions);for(let i of s)a.rmSync(i.path,{recursive:!0,force:!0})}copyDir(e,n){if(!a.existsSync(e))return;let s=a.readdirSync(e,{withFileTypes:!0});for(let i of s){let r=m.join(e,i.name),l=m.join(n,i.name);if(i.isDirectory()){if(i.name===".git"||i.name==="node_modules")continue;a.mkdirSync(l,{recursive:!0}),this.copyDir(r,l)}else a.copyFileSync(r,l)}}};var K=/^[a-z][a-z0-9-]*$/,Z=["aqe-core-","agentic-qe-core-"],F=64,G=500;function k(t){let e=[],n=[];if(!t||typeof t!="object")return{valid:!1,errors:["Manifest must be a non-null object"],warnings:[]};let s=t;if(!s.name||typeof s.name!="string"?e.push("name is required and must be a string"):ee(s.name,e,n),!s.version||typeof s.version!="string"?e.push("version is required and must be a string"):y(s.version)||e.push(`version "${s.version}" is not valid semver (expected: major.minor.patch)`),!s.description||typeof s.description!="string"?e.push("description is required and must be a string"):s.description.length>G&&n.push(`description exceeds ${G} characters`),(!s.author||typeof s.author!="string")&&e.push("author is required and must be a string"),!Array.isArray(s.domains)||s.domains.length===0)e.push("domains is required and must be a non-empty array");else for(let i of s.domains)if(typeof i!="string"){e.push("Each domain must be a string");break}if(!s.entryPoint||typeof s.entryPoint!="string"?e.push("entryPoint is required and must be a string"):se(s.entryPoint,e),s.dependencies!==void 0)if(typeof s.dependencies!="object"||s.dependencies===null||Array.isArray(s.dependencies))e.push("dependencies must be an object mapping plugin names to semver ranges");else for(let[i,r]of Object.entries(s.dependencies))typeof r!="string"?e.push(`Dependency "${i}" must have a string version range`):E(r)||e.push(`Dependency "${i}" has an invalid semver range`);if(s.hooks!==void 0)if(typeof s.hooks!="object"||s.hooks===null||Array.isArray(s.hooks))e.push("hooks must be an object mapping event names to handler paths");else for(let[,i]of Object.entries(s.hooks)){if(typeof i!="string"){e.push("Hook handler paths must be strings");break}i.includes("..")&&e.push(`Hook handler path "${i}" must not contain ".." (path traversal)`)}if(s.minAqeVersion!==void 0&&(typeof s.minAqeVersion!="string"||!y(s.minAqeVersion))&&e.push("minAqeVersion must be valid semver"),s.permissions!==void 0){if(!Array.isArray(s.permissions))e.push("permissions must be an array of strings");else for(let i of s.permissions)if(typeof i!="string"){e.push("Each permission must be a string");break}}return{valid:e.length===0,errors:e,warnings:n}}function T(t){let e=typeof t=="string"?JSON.parse(t):t,n=k(e);if(!n.valid)throw new Error(`Invalid plugin manifest:
1
+ import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.14.7");process.exit(0)}
2
+ import*as a from"fs";import*as m from"path";import{createRequire as z}from"node:module";var B=z(import.meta.url),b=B("semver"),L="3.14.7",y=t=>typeof t=="string"&&b.valid(t)===t.split("+")[0],E=t=>b.validRange(t)!==null,x=(t,e)=>b.satisfies(t,e),C=(t,e)=>b.compare(t,e),N=(t,e)=>C(e,t)||t.localeCompare(e);var R=class{cacheDir;keepVersions;constructor(e={}){this.cacheDir=e.cacheDir??m.join(process.cwd(),".agentic-qe","plugins"),this.keepVersions=e.keepVersions??2}has(e,n){let s=this.versionDir(e,n);return a.existsSync(s)&&a.existsSync(m.join(s,"qe-plugin.json"))}get(e,n){if(!this.has(e,n))return;let s=this.versionDir(e,n),i=a.readFileSync(m.join(s,"qe-plugin.json"),"utf-8"),r=JSON.parse(i),l=a.statSync(s);return{manifest:r,path:s,cachedAt:l.birthtime.toISOString()}}store(e,n){let s=this.versionDir(e.name,e.version);return a.existsSync(s)||(a.mkdirSync(s,{recursive:!0}),this.copyDir(n,s),a.writeFileSync(m.join(s,"qe-plugin.json"),JSON.stringify(e,null,2)),this.pruneOldVersions(e.name)),s}remove(e,n){let s=this.versionDir(e,n);return a.existsSync(s)?(a.rmSync(s,{recursive:!0,force:!0}),!0):!1}listVersions(e){let n=m.join(this.cacheDir,e);if(!a.existsSync(n))return[];let s=[],i=a.readdirSync(n);for(let r of i){let l=m.join(n,r),d=m.join(l,"qe-plugin.json");if(a.existsSync(d))try{let p=a.readFileSync(d,"utf-8"),v=JSON.parse(p);if(!y(v.version)){console.warn(`[PluginCache] Skipping cached plugin ${e}@${r}: invalid version ${JSON.stringify(v.version)}`);continue}let c=a.statSync(l);s.push({manifest:v,path:l,cachedAt:c.birthtime.toISOString()})}catch{}}return s}listAll(){if(!a.existsSync(this.cacheDir))return[];let e=[],n=a.readdirSync(this.cacheDir);for(let s of n){let i=this.listVersions(s);i.length>0&&(i.sort((r,l)=>N(r.manifest.version,l.manifest.version)),e.push(i[0]))}return e}listCandidates(){return a.existsSync(this.cacheDir)?a.readdirSync(this.cacheDir).flatMap(e=>this.listVersions(e)):[]}versionDir(e,n){return m.join(this.cacheDir,e,n)}pruneOldVersions(e){let n=this.listVersions(e);if(n.length<=this.keepVersions)return;n.sort((i,r)=>i.cachedAt.localeCompare(r.cachedAt));let s=n.slice(0,n.length-this.keepVersions);for(let i of s)a.rmSync(i.path,{recursive:!0,force:!0})}copyDir(e,n){if(!a.existsSync(e))return;let s=a.readdirSync(e,{withFileTypes:!0});for(let i of s){let r=m.join(e,i.name),l=m.join(n,i.name);if(i.isDirectory()){if(i.name===".git"||i.name==="node_modules")continue;a.mkdirSync(l,{recursive:!0}),this.copyDir(r,l)}else a.copyFileSync(r,l)}}};var K=/^[a-z][a-z0-9-]*$/,Z=["aqe-core-","agentic-qe-core-"],F=64,G=500;function k(t){let e=[],n=[];if(!t||typeof t!="object")return{valid:!1,errors:["Manifest must be a non-null object"],warnings:[]};let s=t;if(!s.name||typeof s.name!="string"?e.push("name is required and must be a string"):ee(s.name,e,n),!s.version||typeof s.version!="string"?e.push("version is required and must be a string"):y(s.version)||e.push(`version "${s.version}" is not valid semver (expected: major.minor.patch)`),!s.description||typeof s.description!="string"?e.push("description is required and must be a string"):s.description.length>G&&n.push(`description exceeds ${G} characters`),(!s.author||typeof s.author!="string")&&e.push("author is required and must be a string"),!Array.isArray(s.domains)||s.domains.length===0)e.push("domains is required and must be a non-empty array");else for(let i of s.domains)if(typeof i!="string"){e.push("Each domain must be a string");break}if(!s.entryPoint||typeof s.entryPoint!="string"?e.push("entryPoint is required and must be a string"):se(s.entryPoint,e),s.dependencies!==void 0)if(typeof s.dependencies!="object"||s.dependencies===null||Array.isArray(s.dependencies))e.push("dependencies must be an object mapping plugin names to semver ranges");else for(let[i,r]of Object.entries(s.dependencies))typeof r!="string"?e.push(`Dependency "${i}" must have a string version range`):E(r)||e.push(`Dependency "${i}" has an invalid semver range`);if(s.hooks!==void 0)if(typeof s.hooks!="object"||s.hooks===null||Array.isArray(s.hooks))e.push("hooks must be an object mapping event names to handler paths");else for(let[,i]of Object.entries(s.hooks)){if(typeof i!="string"){e.push("Hook handler paths must be strings");break}i.includes("..")&&e.push(`Hook handler path "${i}" must not contain ".." (path traversal)`)}if(s.minAqeVersion!==void 0&&(typeof s.minAqeVersion!="string"||!y(s.minAqeVersion))&&e.push("minAqeVersion must be valid semver"),s.permissions!==void 0){if(!Array.isArray(s.permissions))e.push("permissions must be an array of strings");else for(let i of s.permissions)if(typeof i!="string"){e.push("Each permission must be a string");break}}return{valid:e.length===0,errors:e,warnings:n}}function T(t){let e=typeof t=="string"?JSON.parse(t):t,n=k(e);if(!n.valid)throw new Error(`Invalid plugin manifest:
3
3
  - ${n.errors.join(`
4
4
  - `)}`);return e}function ee(t,e,n){t.length>F&&e.push(`name must be ${F} characters or fewer`),K.test(t)||e.push("name must be lowercase alphanumeric with hyphens, starting with a letter"),/[^\x00-\x7F]/.test(t)&&e.push("name must contain only ASCII characters");for(let s of Z)t.startsWith(s)&&e.push(`name cannot start with reserved prefix "${s}"`);["plugin","test","tool"].includes(t)&&n.push(`name "${t}" is very generic \u2014 consider a more descriptive name`)}function se(t,e){t.includes("..")&&e.push('entryPoint must not contain ".." (path traversal)'),(t.startsWith("/")||t.startsWith("\\"))&&e.push("entryPoint must be a relative path"),!t.endsWith(".js")&&!t.endsWith(".ts")&&!t.endsWith(".mjs")&&e.push("entryPoint must end in .js, .ts, or .mjs")}var I=class{constructor(e=L){this.aqeVersion=e}aqeVersion;resolve(e,n){let s=new Map,i=new Map;for(let o of e){let u=s.get(o.name)??[];s.set(o.name,u);let f=this.validateVersions(o);f?i.set(o.name,[...i.get(o.name)??[],f]):u.push(o)}for(let o of s.values())o.sort((u,f)=>N(u.version,f.version));let r=new Map,l=[],d=o=>({ordered:o.map((u,f)=>({manifest:u,order:f})),missing:r,errors:l,selectedVersions:Object.fromEntries(o.map(u=>[u.name,u.version])),aqeVersion:this.aqeVersion}),p=[...n??s.keys()].sort(),v=new Set(p),c=new Map,_=0,h=!1,J=()=>{for(let o of c.values())for(let[u,f]of Object.entries(o.dependencies??{})){let g=c.get(u);if(!(g?[g]:s.get(u)??[]).some(M=>x(M.version,f)))return!1}return!0},A,X=()=>{let o=new Set,u=new Set,f=(g,P)=>{if(u.has(g))return[...P.slice(P.indexOf(g)),g];if(!o.has(g)){u.add(g);for(let M of Object.keys(c.get(g)?.dependencies??{})){let Q=f(M,[...P,g]);if(Q)return Q}u.delete(g),o.add(g)}};for(let g of c.keys()){let P=f(g,[]);if(P)return P}},j=()=>{let o=new Set(p);for(let f of c.values())for(let g of Object.keys(f.dependencies??{}))o.add(g);let u=[...o].sort().find(f=>!c.has(f));if(!u){let f=X();return f?(A=f,!1):!0}v.add(u);for(let f of s.get(u)??[]){if(++_>1e4)return h=!0,!1;if(c.set(u,f),J()&&j())return!0;if(c.delete(u),h)return!1}return!1};if(!j()){if(A&&!h)throw new Error(`Dependency cycle detected: ${A.join(" -> ")}`);for(let o of v)s.get(o)?.length||l.push(...i.get(o)??[]);for(let[o,u]of s){let f=[...new Set(u.flatMap(g=>Object.keys(g.dependencies??{})))].filter(g=>!s.has(g));f.length&&r.set(o,f)}return l.push({code:h?"RESOLUTION_LIMIT":r.size?"MISSING_DEPENDENCY":"UNSATISFIED_DEPENDENCY_RANGE",plugin:p.join(", "),message:h?"Plugin dependency search exceeded 10000 candidates":"No cached plugin selection satisfies all dependency ranges"}),d([])}let O=[],q=new Set,w=new Set,$=(o,u)=>{if(q.has(o))return;if(w.has(o))throw new Error(`Dependency cycle detected: ${[...u.slice(u.indexOf(o)),o].join(" -> ")}`);w.add(o);let f=c.get(o);for(let g of Object.keys(f.dependencies??{}))$(g,[...u,o]);w.delete(o),q.add(o),O.push(f)};for(let o of[...c.keys()].sort())$(o,[]);return d(O)}resolveAvailable(e){let n=[],s=this.resolve(e,[]),i=[],r=new Map;for(let l of[...new Set(e.map(d=>d.name))].sort())try{let d=this.resolve(e,[...n,l]);if(d.errors.length){i.push(...d.errors.map(p=>({...p,plugin:l})));for(let[p,v]of d.missing)r.set(p,v);continue}n.push(l),s=d}catch(d){i.push({code:"DEPENDENCY_CYCLE",plugin:l,message:d instanceof Error?d.message:String(d)})}return{...s,errors:i,missing:r}}canLoad(e,n){let s=Object.entries(e.dependencies??{}).filter(([i,r])=>{let l=n instanceof Set?void 0:n.get(i);return!l||!E(r)||!x(l,r)}).map(([i])=>i);return{canLoad:!this.validateVersions(e)&&s.length===0,missingDeps:s}}validateVersions(e){if(!y(e.version))return{code:"INVALID_PLUGIN_VERSION",plugin:e.name,message:"Invalid plugin version"};for(let n of Object.values(e.dependencies??{}))if(!E(n))return{code:"INVALID_DEPENDENCY_RANGE",plugin:e.name,message:"Invalid dependency range"};if(e.minAqeVersion&&(!y(e.minAqeVersion)||!y(this.aqeVersion)||C(this.aqeVersion,e.minAqeVersion)<0))return{code:"AQE_VERSION_INCOMPATIBLE",plugin:e.name,message:`Requires AQE ${e.minAqeVersion}; running ${this.aqeVersion}`}}};var ne=["aqe-core-","agentic-qe-core-","agentic-qe-internal-"],U=new Set(["aqe","agentic-qe","ruflo","claude-flow"]),te=["..","~","/etc/","/proc/","/dev/","node_modules/"];function Y(t){let e=[];return ie(t.name,e),re(t.entryPoint,e),oe(t.hooks,e),ae(t.permissions,e),{safe:e.length===0,violations:e}}function ie(t,e){/[^\x20-\x7E]/.test(t)&&e.push(`Plugin name "${t}" contains non-ASCII characters`),U.has(t.toLowerCase())&&e.push(`Plugin name "${t}" is a reserved name`);for(let s of ne)t.toLowerCase().startsWith(s)&&e.push(`Plugin name "${t}" uses reserved prefix "${s}"`);let n=t.toLowerCase().replace(/[0o]/g,"o").replace(/[1il]/g,"l").replace(/[-_]/g,"");U.has(n)&&e.push(`Plugin name "${t}" is visually similar to a reserved name`)}function re(t,e){W(t,"entryPoint",e),(t.startsWith("/")||t.startsWith("\\"))&&e.push("entryPoint must be a relative path, not absolute")}function oe(t,e){if(t)for(let[n,s]of Object.entries(t))W(s,`hook[${n}]`,e)}function W(t,e,n){for(let s of te)t.includes(s)&&n.push(`${e} contains dangerous path pattern "${s}"`);t.includes("\0")&&n.push(`${e} contains null byte (path injection attempt)`)}function ae(t,e){if(!t)return;let n=["fs:write-root","net:arbitrary","exec:shell"];for(let s of t)n.includes(s)&&e.push(`Plugin requests dangerous permission: ${s}`)}import*as S from"fs";import*as V from"path";var D=class{type="local";async resolve(e){let n=V.resolve(e),s=V.join(n,"qe-plugin.json");if(!S.existsSync(s))throw new Error(`No qe-plugin.json found at ${s}`);let i=S.readFileSync(s,"utf-8");return T(i)}async getPluginPath(e){let n=V.resolve(e);if(!S.existsSync(n))throw new Error(`Plugin directory does not exist: ${n}`);return n}};var H=class{cache;resolver;sources=new Map;constructor(e={}){this.cache=e.cache??new R,this.resolver=new I;let n=new D;if(this.sources.set("local",n),e.sources)for(let s of e.sources)this.sources.set(s.type,s)}async install(e,n="local"){if(process.env.AQE_PLUGINS_DISABLED==="true")return{success:!1,errors:["Plugin loading is disabled (AQE_PLUGINS_DISABLED=true)"],securityViolations:[]};let s=[],i=this.sources.get(n);if(!i)return{success:!1,errors:[`Unknown source type: ${n}. Available: ${[...this.sources.keys()].join(", ")}`],securityViolations:[]};let r;try{r=await i.resolve(e)}catch(c){return{success:!1,errors:[`Failed to resolve plugin: ${c instanceof Error?c.message:String(c)}`],securityViolations:[]}}let l=k(r);if(!l.valid)return{success:!1,manifest:r,errors:l.errors,securityViolations:[]};let d=Y(r);if(!d.safe)return{success:!1,manifest:r,errors:["Plugin failed security checks"],securityViolations:d.violations};try{let c=this.cache.listCandidates().map(h=>h.manifest).filter(h=>h.name!==r.name),_=this.resolver.resolve([...c,r],[r.name]);if(_.errors.length)return{success:!1,manifest:r,errors:_.errors.map(h=>`${h.code}: ${h.message}`),securityViolations:[]}}catch(c){return{success:!1,manifest:r,errors:[c instanceof Error?c.message:String(c)],securityViolations:[]}}if(this.cache.has(r.name,r.version)){let c=this.cache.get(r.name,r.version);return{success:!0,manifest:r,cachePath:c.path,errors:[],securityViolations:[]}}let p;try{p=await i.getPluginPath(e)}catch(c){return{success:!1,manifest:r,errors:[`Failed to get plugin path: ${c instanceof Error?c.message:String(c)}`],securityViolations:[]}}let v=this.cache.store(r,p);return{success:!0,manifest:r,cachePath:v,errors:s,securityViolations:[]}}remove(e,n){if(n)return this.cache.remove(e,n);let s=this.cache.listVersions(e),i=!1;for(let r of s)this.cache.remove(e,r.manifest.version)&&(i=!0);return i}list(){return this.cache.listAll().map(n=>({name:n.manifest.name,version:n.manifest.version,description:n.manifest.description,domains:n.manifest.domains,source:"cached",cachePath:n.path}))}resolveLoadOrder(){let e=this.cache.listCandidates();return this.resolver.resolveAvailable(e.map(n=>n.manifest))}registerSource(e){this.sources.set(e.type,e)}};export{T as a,R as b,H as c};
@@ -1,5 +1,5 @@
1
- import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.14.5");process.exit(0)}
2
- import{h as c,k as d,o as f}from"./chunk-EFV4ADMO.js";import{a as h}from"./chunk-J27F4NSB.js";import{c as l}from"./chunk-7CD7PBHY.js";import{a as r,e as p}from"./chunk-CVMNJSCB.js";f();p();h();import*as m from"path";var u=l.create("hybrid-backend"),s=class{unifiedMemory=null;config;cleanupInterval;cleanupCount=0;initialized=!1;constructor(e){this.config={sqlite:{path:e?.sqlite?.path??".agentic-qe/memory.db",walMode:e?.sqlite?.walMode??!0,poolSize:e?.sqlite?.poolSize??5,busyTimeout:e?.sqlite?.busyTimeout??r.BUSY_TIMEOUT_MS,...e?.sqlite},agentdb:{path:e?.agentdb?.path??".agentic-qe/memory.db",...e?.agentdb},enableFallback:e?.enableFallback??!0,defaultNamespace:e?.defaultNamespace??"default",cleanupInterval:e?.cleanupInterval??r.CLEANUP_INTERVAL_MS}}async initialize(e){if(this.initialized)return;let i=e?.signal;i?.throwIfAborted();let t={dbPath:this.config.sqlite.path??c.dbPath,walMode:this.config.sqlite.walMode??!0,busyTimeout:this.config.sqlite.busyTimeout??r.BUSY_TIMEOUT_MS};this.unifiedMemory=d(t),i?.throwIfAborted(),await this.unifiedMemory.initialize({signal:i}),i?.throwIfAborted(),this.cleanupInterval=setInterval(()=>this.cleanup(),this.config.cleanupInterval),this.cleanupInterval.unref&&this.cleanupInterval.unref(),this.initialized=!0,console.log(`[HybridBackend] Initialized with unified memory: ${this.unifiedMemory.getDbPath()}`)}async dispose(){this.cleanupInterval&&clearInterval(this.cleanupInterval),this.initialized=!1}async set(e,i,t){this.ensureInitialized();let n=t?.namespace??this.config.defaultNamespace;await this.unifiedMemory.kvSet(e,i,n,t?.ttl)}async get(e,i){this.ensureInitialized();let t=i?.namespace??this.config.defaultNamespace;return this.unifiedMemory.kvGet(e,t)}async delete(e,i){this.ensureInitialized();let t=i?.namespace??this.config.defaultNamespace,n=await this.unifiedMemory.kvDelete(e,t),a=await this.unifiedMemory.vectorDelete(e);return n||a}async has(e,i){this.ensureInitialized();let t=i?.namespace??this.config.defaultNamespace;return this.unifiedMemory.kvExists(e,t)}async search(e,i=100,t){this.ensureInitialized();let n=t?.namespace??this.config.defaultNamespace;return this.unifiedMemory.kvSearch(e,n,i)}async vectorSearch(e,i,t){return this.ensureInitialized(),(await this.unifiedMemory.vectorSearch(e,i,void 0,t)).map(a=>({key:a.id,score:a.score,metadata:a.metadata}))}getVectorSearchProvenance(){return this.ensureInitialized(),this.unifiedMemory.getVectorSearchProvenance()}async storeVector(e,i,t){this.ensureInitialized(),await this.unifiedMemory.vectorStore(e,i,this.config.defaultNamespace,t)}getHealth(){return{sqlite:this.unifiedMemory?.isInitialized()?"healthy":"unavailable",sqlitePersistent:!0,agentdb:this.unifiedMemory?.isInitialized()?"healthy":"unavailable",fallback:"inactive"}}isPersistent(){return this.unifiedMemory?.isInitialized()??!1}getConfig(){return{...this.config}}async setWithBackend(e,i,t,n){await this.set(e,i,n)}async getVectorStats(){if(!this.unifiedMemory?.isInitialized())return null;let e=await this.unifiedMemory.vectorCount(),i=this.unifiedMemory.getStats();return{vectorCount:e,indexSize:i.vectorIndexSize}}getUnifiedMemory(){return this.unifiedMemory}async count(e){return this.ensureInitialized(),this.unifiedMemory.getDatabase().prepare(`
1
+ import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.14.7");process.exit(0)}
2
+ import{l as c,o as d,s as f}from"./chunk-QUORH2MG.js";import{a as h}from"./chunk-TW3SR4TS.js";import{e as l}from"./chunk-5GFKTJ65.js";import{a as r,e as p}from"./chunk-VYDVI6FZ.js";f();p();h();import*as m from"path";var u=l.create("hybrid-backend"),s=class{unifiedMemory=null;config;cleanupInterval;cleanupCount=0;initialized=!1;constructor(e){this.config={sqlite:{path:e?.sqlite?.path??".agentic-qe/memory.db",walMode:e?.sqlite?.walMode??!0,poolSize:e?.sqlite?.poolSize??5,busyTimeout:e?.sqlite?.busyTimeout??r.BUSY_TIMEOUT_MS,...e?.sqlite},agentdb:{path:e?.agentdb?.path??".agentic-qe/memory.db",...e?.agentdb},enableFallback:e?.enableFallback??!0,defaultNamespace:e?.defaultNamespace??"default",cleanupInterval:e?.cleanupInterval??r.CLEANUP_INTERVAL_MS}}async initialize(e){if(this.initialized)return;let i=e?.signal;i?.throwIfAborted();let t={dbPath:this.config.sqlite.path??c.dbPath,walMode:this.config.sqlite.walMode??!0,busyTimeout:this.config.sqlite.busyTimeout??r.BUSY_TIMEOUT_MS};this.unifiedMemory=d(t),i?.throwIfAborted(),await this.unifiedMemory.initialize({signal:i}),i?.throwIfAborted(),this.cleanupInterval=setInterval(()=>this.cleanup(),this.config.cleanupInterval),this.cleanupInterval.unref&&this.cleanupInterval.unref(),this.initialized=!0,console.log(`[HybridBackend] Initialized with unified memory: ${this.unifiedMemory.getDbPath()}`)}async dispose(){this.cleanupInterval&&clearInterval(this.cleanupInterval),this.initialized=!1}async set(e,i,t){this.ensureInitialized();let n=t?.namespace??this.config.defaultNamespace;await this.unifiedMemory.kvSet(e,i,n,t?.ttl)}async get(e,i){this.ensureInitialized();let t=i?.namespace??this.config.defaultNamespace;return this.unifiedMemory.kvGet(e,t)}async delete(e,i){this.ensureInitialized();let t=i?.namespace??this.config.defaultNamespace,n=await this.unifiedMemory.kvDelete(e,t),a=await this.unifiedMemory.vectorDelete(e);return n||a}async has(e,i){this.ensureInitialized();let t=i?.namespace??this.config.defaultNamespace;return this.unifiedMemory.kvExists(e,t)}async search(e,i=100,t){this.ensureInitialized();let n=t?.namespace??this.config.defaultNamespace;return this.unifiedMemory.kvSearch(e,n,i)}async vectorSearch(e,i,t){return this.ensureInitialized(),(await this.unifiedMemory.vectorSearch(e,i,void 0,t)).map(a=>({key:a.id,score:a.score,metadata:a.metadata}))}getVectorSearchProvenance(){return this.ensureInitialized(),this.unifiedMemory.getVectorSearchProvenance()}async storeVector(e,i,t){this.ensureInitialized(),await this.unifiedMemory.vectorStore(e,i,this.config.defaultNamespace,t)}getHealth(){return{sqlite:this.unifiedMemory?.isInitialized()?"healthy":"unavailable",sqlitePersistent:!0,agentdb:this.unifiedMemory?.isInitialized()?"healthy":"unavailable",fallback:"inactive"}}isPersistent(){return this.unifiedMemory?.isInitialized()??!1}getConfig(){return{...this.config}}async setWithBackend(e,i,t,n){await this.set(e,i,n)}async getVectorStats(){if(!this.unifiedMemory?.isInitialized())return null;let e=await this.unifiedMemory.vectorCount(),i=this.unifiedMemory.getStats();return{vectorCount:e,indexSize:i.vectorIndexSize}}getUnifiedMemory(){return this.unifiedMemory}async count(e){return this.ensureInitialized(),this.unifiedMemory.getDatabase().prepare(`
3
3
  SELECT COUNT(*) as count FROM kv_store
4
4
  WHERE namespace LIKE ?
5
5
  AND (expires_at IS NULL OR expires_at > ?)
@@ -0,0 +1,2 @@
1
+ import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.14.7");process.exit(0)}
2
+ import{c as r,e as u}from"./chunk-ZUOVNFXK.js";u();var a='expected [{ "functionName": "add", "args": [2, 3], "expected": 5 }]',p={type:"object",description:"One caller-owned specification example",properties:{functionName:{type:"string",description:"Named export of the source file to call"},args:{type:"array",description:"Positional JSON arguments; length must equal the function arity",items:{}},expected:{description:"Expected JSON return value (use null for a null result)"}},required:["functionName","args","expected"]};function s(o,n="Behavior example value"){let i=(e,t)=>{if(!(e===null||typeof e=="string"||typeof e=="boolean")&&!(typeof e=="number"&&Number.isFinite(e)&&!Object.is(e,-0))){if(typeof e!="object"||t.has(e))throw new r(`${n} must be finite JSON data (no undefined, functions, NaN/Infinity, cycles, or negative zero)`);if(!Array.isArray(e)&&Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw new r(`${n} must contain only plain JSON objects`);t.add(e);for(let c of Array.isArray(e)?Array.from(e):Object.values(e))i(c,t);t.delete(e)}};i(o,new Set)}function l(o){if(o!==void 0){if(!Array.isArray(o))throw new r(`behaviorExamples must be an array; ${a}`);return o.forEach((n,i)=>{let e=`behaviorExamples[${i}]`;if(typeof n!="object"||n===null||Array.isArray(n))throw new r(`${e} must be an object; ${a}`);let t=n;if(typeof t.functionName!="string"||t.functionName.trim()==="")throw new r(`${e}.functionName must be a non-empty string`);if(!Array.isArray(t.args))throw new r(`${e}.args must be an array of arguments`);if(!Object.prototype.hasOwnProperty.call(t,"expected"))throw new r(`${e}.expected is required (use null for a null result)`);s(t.args,`${e}.args`),s(t.expected,`${e}.expected`)}),o}}export{p as a,s as b,l as c};