agentic-qe 3.11.3 → 3.11.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (426) hide show
  1. package/.claude/hooks/aqe-hook.cjs +44 -10
  2. package/.claude/skills/skills-manifest.json +1 -1
  3. package/CHANGELOG.md +106 -0
  4. package/assets/skills/skills-manifest.json +1 -1
  5. package/dist/audit/witness-chain.d.ts +25 -0
  6. package/dist/audit/witness-chain.js +69 -22
  7. package/dist/audit/witness-key-manager.d.ts +11 -0
  8. package/dist/audit/witness-key-manager.js +24 -0
  9. package/dist/cli/brain-commands.js +2 -1
  10. package/dist/cli/bundle.js +5 -5
  11. package/dist/cli/chunks/adapter-KNM5R47J.js +2 -0
  12. package/dist/cli/chunks/{agent-booster-wasm-BFRW7HEU.js → agent-booster-wasm-CSTBLNYZ.js} +2 -2
  13. package/dist/cli/chunks/{agent-handler-ZVC3VFPC.js → agent-handler-M4W4GTXN.js} +2 -2
  14. package/dist/cli/chunks/{agent-memory-branch-3WU3CVSX.js → agent-memory-branch-VGXFYLSQ.js} +2 -2
  15. package/dist/cli/chunks/aqe-learning-engine-MXPJLVR3.js +2 -0
  16. package/dist/cli/chunks/{arena-QMRLNQUC.js → arena-FKSD3LLM.js} +4 -4
  17. package/dist/cli/chunks/{arena-JMVTWWG5.js → arena-IQBRGWAG.js} +2 -2
  18. package/dist/cli/chunks/audit-7NSGRR4Z.js +3 -0
  19. package/dist/cli/chunks/base-X4EXQ2AS.js +2 -0
  20. package/dist/cli/chunks/{hnswlib-node-EBRXKEX5.js → better-sqlite3-2KR4LQRU.js} +2 -2
  21. package/dist/cli/chunks/brain-handler-M6A3UB66.js +89 -0
  22. package/dist/cli/chunks/{branch-enumerator-CJJG6X3I.js → branch-enumerator-2JGKY4BB.js} +2 -2
  23. package/dist/cli/chunks/{browser-LI2CDWVR.js → browser-J43WQPJL.js} +2 -2
  24. package/dist/cli/chunks/browser-workflow-4HX6RP5F.js +2 -0
  25. package/dist/cli/chunks/{chunk-DS7AZD26.js → chunk-26WEI3P4.js} +2 -2
  26. package/dist/cli/chunks/{chunk-OVEG5MEL.js → chunk-2XPMATEK.js} +2 -2
  27. package/dist/cli/chunks/{chunk-36HTS4EP.js → chunk-2XQHG56O.js} +2 -2
  28. package/dist/cli/chunks/{chunk-CGKHG46K.js → chunk-354367AP.js} +2 -2
  29. package/dist/cli/chunks/{chunk-FPKKKUWF.js → chunk-37ZUF5NX.js} +1 -1
  30. package/dist/cli/chunks/{chunk-H7Y43HBQ.js → chunk-3I4TCMOJ.js} +1 -1
  31. package/dist/cli/chunks/{chunk-WV66MXJI.js → chunk-3JF5A72M.js} +2 -2
  32. package/dist/cli/chunks/{chunk-MX5FMAY5.js → chunk-3LY7OCSO.js} +1 -1
  33. package/dist/cli/chunks/{chunk-KHUN65Q3.js → chunk-3V36WMIO.js} +1 -1
  34. package/dist/cli/chunks/{chunk-VFEU4JM4.js → chunk-3WR35GFF.js} +2 -2
  35. package/dist/cli/chunks/{chunk-A43MKBSX.js → chunk-4LODYRNV.js} +2 -2
  36. package/dist/cli/chunks/{chunk-3E3PSEC5.js → chunk-4MHN7JWC.js} +3 -3
  37. package/dist/cli/chunks/chunk-4QOI5JS7.js +14 -0
  38. package/dist/cli/chunks/{chunk-LKLWIP4Z.js → chunk-4RTWPR3X.js} +1 -1
  39. package/dist/cli/chunks/chunk-4XJ2A3HY.js +65 -0
  40. package/dist/cli/chunks/{chunk-PMHSTMHV.js → chunk-4Y3LGBKJ.js} +3 -3
  41. package/dist/cli/chunks/{chunk-SFDBIO64.js → chunk-52U5BFZP.js} +2 -2
  42. package/dist/cli/chunks/{chunk-YPRM6ZFL.js → chunk-53YOYZW5.js} +2 -2
  43. package/dist/cli/chunks/{chunk-REZ2GZQ3.js → chunk-5WMU7XCF.js} +1 -1
  44. package/dist/cli/chunks/{chunk-VUEYLW5P.js → chunk-62OTU2AP.js} +2 -2
  45. package/dist/cli/chunks/{chunk-3XLGXCSX.js → chunk-62UM7Q5N.js} +1 -1
  46. package/dist/cli/chunks/{chunk-DZZ4AJQI.js → chunk-6Q57K4YD.js} +2 -2
  47. package/dist/cli/chunks/chunk-6R3YOAKO.js +2 -0
  48. package/dist/cli/chunks/chunk-6T65OKUM.js +2 -0
  49. package/dist/cli/chunks/{chunk-VTDWQ7WI.js → chunk-7BCRULCP.js} +2 -2
  50. package/dist/cli/chunks/{chunk-XCSEJQXR.js → chunk-7DTMENY6.js} +2 -2
  51. package/dist/cli/chunks/{chunk-N2K2EQFH.js → chunk-7KXPNNMR.js} +2 -2
  52. package/dist/cli/chunks/{chunk-XKUN5PDH.js → chunk-7P6X4BFO.js} +3 -3
  53. package/dist/cli/chunks/{chunk-3CBYKKRW.js → chunk-7YSBATSN.js} +2 -2
  54. package/dist/cli/chunks/{chunk-ZDPQB67L.js → chunk-ABU64UWB.js} +1 -1
  55. package/dist/cli/chunks/{chunk-IJHPZMEQ.js → chunk-AF6P5RWY.js} +2 -2
  56. package/dist/cli/chunks/{chunk-7S7QF4HJ.js → chunk-AGJOGUP5.js} +1 -1
  57. package/dist/cli/chunks/{chunk-EHEFI6LR.js → chunk-AL5VJJN4.js} +1 -1
  58. package/dist/cli/chunks/{chunk-Q2A2XQGF.js → chunk-AOQYORVA.js} +2 -2
  59. package/dist/cli/chunks/{chunk-6WWNK67C.js → chunk-AOXJFDH5.js} +180 -176
  60. package/dist/cli/chunks/{chunk-SWRGPCZ2.js → chunk-AXKWV5NF.js} +4 -4
  61. package/dist/cli/chunks/{chunk-3BREKEL5.js → chunk-B2VBDMDI.js} +2 -2
  62. package/dist/cli/chunks/{chunk-RXN5DWVM.js → chunk-BJLA2IX7.js} +2 -2
  63. package/dist/cli/chunks/{chunk-DPYNXEBC.js → chunk-BLPWJQTY.js} +2 -2
  64. package/dist/cli/chunks/{chunk-SMHYPPO6.js → chunk-BTLUWH4R.js} +2 -2
  65. package/dist/cli/chunks/{chunk-PUK5NE47.js → chunk-C4EZNOWK.js} +1 -1
  66. package/dist/cli/chunks/{chunk-ATFADWGD.js → chunk-C5C4W572.js} +2 -2
  67. package/dist/cli/chunks/{chunk-WTKT2AD3.js → chunk-CDJP6COA.js} +2 -2
  68. package/dist/cli/chunks/{chunk-G6MPXBCD.js → chunk-CKOF27L7.js} +2 -2
  69. package/dist/cli/chunks/{chunk-BQ5EJPK3.js → chunk-D45QLJEL.js} +1 -1
  70. package/dist/cli/chunks/{chunk-WCVZHXWL.js → chunk-DFRRWOEX.js} +2 -2
  71. package/dist/cli/chunks/{chunk-PSL53AQ4.js → chunk-DLBVADWQ.js} +92 -92
  72. package/dist/cli/chunks/{chunk-HRD5I7ES.js → chunk-DPL762HU.js} +1 -1
  73. package/dist/cli/chunks/{chunk-7QIYYYUE.js → chunk-DVW66FPU.js} +1 -1
  74. package/dist/cli/chunks/{chunk-ABD6JBNO.js → chunk-EDOGRFAG.js} +1 -1
  75. package/dist/cli/chunks/{chunk-7SBMTSGY.js → chunk-EEKG35K5.js} +5 -5
  76. package/dist/cli/chunks/{chunk-PW4GGJMP.js → chunk-EK3HPH6A.js} +1 -1
  77. package/dist/cli/chunks/{chunk-QPMISAWB.js → chunk-FGD6HINU.js} +1 -1
  78. package/dist/cli/chunks/{chunk-SLU35IDJ.js → chunk-FGSIID5C.js} +2 -2
  79. package/dist/cli/chunks/{chunk-DNOBN3IR.js → chunk-FHTYEAQ3.js} +2 -2
  80. package/dist/cli/chunks/{chunk-S2T2BXUL.js → chunk-FII3WCCY.js} +2 -2
  81. package/dist/cli/chunks/{chunk-77QJQRL2.js → chunk-FIPKIIMS.js} +2 -2
  82. package/dist/cli/chunks/{chunk-WYJFVSEB.js → chunk-FMNXHVIN.js} +2 -2
  83. package/dist/cli/chunks/{chunk-FZLCKIPP.js → chunk-G2ZIJZJ7.js} +2 -2
  84. package/dist/cli/chunks/{chunk-L6PH7JIE.js → chunk-GODAWJMZ.js} +2 -2
  85. package/dist/cli/chunks/{chunk-KTYESESI.js → chunk-GW6XWMX2.js} +2 -2
  86. package/dist/cli/chunks/{chunk-AC6OZTY4.js → chunk-HC6KTVFR.js} +2 -2
  87. package/dist/cli/chunks/{chunk-EXCU4J7T.js → chunk-HJWT4KME.js} +1 -1
  88. package/dist/cli/chunks/{chunk-GBCDJJWH.js → chunk-I3ANRYQ6.js} +2 -2
  89. package/dist/cli/chunks/{chunk-KXRI4MR3.js → chunk-I3NWKPXJ.js} +2 -2
  90. package/dist/cli/chunks/chunk-IBDQWKI3.js +2 -0
  91. package/dist/cli/chunks/{chunk-7FVWETN4.js → chunk-IU5RSN6M.js} +2 -2
  92. package/dist/cli/chunks/{chunk-L44XXD3X.js → chunk-J5XDKVI7.js} +2 -2
  93. package/dist/cli/chunks/{chunk-NJ2RY4OL.js → chunk-J6PFPY7V.js} +2 -2
  94. package/dist/cli/chunks/{chunk-27MMZQ7X.js → chunk-JATLFS6A.js} +1 -1
  95. package/dist/cli/chunks/{chunk-SIAJP3YA.js → chunk-JBKZ5TUM.js} +2 -2
  96. package/dist/cli/chunks/{chunk-PLQADRA6.js → chunk-JDSHUECG.js} +2 -2
  97. package/dist/cli/chunks/chunk-K4C25BWV.js +24 -0
  98. package/dist/cli/chunks/{chunk-UFZCHVLH.js → chunk-K4I7UIU5.js} +1 -1
  99. package/dist/cli/chunks/{chunk-6F43POT6.js → chunk-KP3R2M2G.js} +1 -1
  100. package/dist/cli/chunks/chunk-KQVIWE3W.js +2 -0
  101. package/dist/cli/chunks/{chunk-JWTMVC6E.js → chunk-KVVJVMDM.js} +2 -2
  102. package/dist/cli/chunks/{chunk-EZ4GKHSI.js → chunk-LOE2JETO.js} +2 -2
  103. package/dist/cli/chunks/{chunk-O7ZDQ5FF.js → chunk-LPR2R3AN.js} +3 -3
  104. package/dist/cli/chunks/{chunk-AKOGQT3A.js → chunk-M6FW56MV.js} +2 -2
  105. package/dist/cli/chunks/{chunk-NBOEXSV2.js → chunk-MCHEUSY4.js} +1 -1
  106. package/dist/cli/chunks/{chunk-B7XPSXK6.js → chunk-MEIU7457.js} +2 -2
  107. package/dist/cli/chunks/{chunk-3FOFPGHH.js → chunk-MHMQ6MCT.js} +2 -2
  108. package/dist/cli/chunks/{chunk-6JR2RSY2.js → chunk-MIU5RUBJ.js} +2 -2
  109. package/dist/cli/chunks/{chunk-QCCXH5DK.js → chunk-MMEXHZUC.js} +37 -12
  110. package/dist/cli/chunks/{chunk-LW5TUN5F.js → chunk-MTBGOWJA.js} +2 -2
  111. package/dist/cli/chunks/{chunk-JVXPKHND.js → chunk-NCSXLMDL.js} +77 -27
  112. package/dist/cli/chunks/{chunk-WLLGPGQY.js → chunk-O7J54OHN.js} +1 -1
  113. package/dist/cli/chunks/{chunk-ZM7WOA3K.js → chunk-OGNTCZKK.js} +1 -1
  114. package/dist/cli/chunks/{chunk-CYJ6O5VZ.js → chunk-OS2HHJTM.js} +2 -2
  115. package/dist/cli/chunks/{chunk-242B625Q.js → chunk-OS62Y77J.js} +2 -2
  116. package/dist/cli/chunks/{chunk-CLZ5RQVA.js → chunk-PVDXNQPL.js} +2 -2
  117. package/dist/cli/chunks/{chunk-PUUGIBFF.js → chunk-PW72M2FE.js} +2 -2
  118. package/dist/cli/chunks/{chunk-RWUGXU2K.js → chunk-Q5TR6ETB.js} +22 -22
  119. package/dist/cli/chunks/{chunk-CCDGNJZX.js → chunk-QKK7VBVB.js} +2 -2
  120. package/dist/cli/chunks/{chunk-BHZI6PDR.js → chunk-RFLHPLET.js} +1 -1
  121. package/dist/cli/chunks/{chunk-KULBMV6K.js → chunk-RJN2RM76.js} +2 -2
  122. package/dist/cli/chunks/{chunk-LGEZ3ZJX.js → chunk-RKXZLTWR.js} +2 -2
  123. package/dist/cli/chunks/{chunk-OFMVC6P3.js → chunk-SE3JFUKP.js} +1 -1
  124. package/dist/cli/chunks/{chunk-S7KDHA6P.js → chunk-SK754ZSH.js} +4 -4
  125. package/dist/cli/chunks/{chunk-OQGELUM2.js → chunk-SO6G4IX3.js} +2 -2
  126. package/dist/cli/chunks/{chunk-5746QYRF.js → chunk-SUL3I6QZ.js} +2 -2
  127. package/dist/cli/chunks/{chunk-22CUJA33.js → chunk-TBT3OFRW.js} +2 -2
  128. package/dist/cli/chunks/{chunk-26KHL4VO.js → chunk-TEIWJ3GJ.js} +1 -1
  129. package/dist/cli/chunks/{chunk-SFGBC5RP.js → chunk-TRNBQFFG.js} +8 -20
  130. package/dist/cli/chunks/{chunk-UTGW75AZ.js → chunk-TTJJ4DQE.js} +2 -2
  131. package/dist/cli/chunks/{chunk-H6YFMUFG.js → chunk-UBI2EOS3.js} +1 -1
  132. package/dist/cli/chunks/{chunk-GCIL7PK7.js → chunk-UBY322ED.js} +2 -2
  133. package/dist/cli/chunks/{chunk-P4UGVVVX.js → chunk-UORTQXJ2.js} +1 -1
  134. package/dist/cli/chunks/{chunk-BFBZFUBP.js → chunk-URP75DL4.js} +1 -1
  135. package/dist/cli/chunks/chunk-V6NAB5UZ.js +2 -0
  136. package/dist/cli/chunks/{chunk-DZ7PWB6E.js → chunk-VMFAANWX.js} +2 -2
  137. package/dist/cli/chunks/{chunk-6KKKPVOF.js → chunk-VMWRMINE.js} +1 -1
  138. package/dist/cli/chunks/{chunk-ECGASTG7.js → chunk-VN2HHBZN.js} +2 -2
  139. package/dist/cli/chunks/{chunk-6GVRP64A.js → chunk-W72FJA2H.js} +2 -2
  140. package/dist/cli/chunks/chunk-W7TYKPLY.js +27 -0
  141. package/dist/cli/chunks/{chunk-2OUXYSQV.js → chunk-WHHQIL4F.js} +2 -2
  142. package/dist/cli/chunks/{chunk-RRSUW2TK.js → chunk-WMZ2QGGS.js} +2 -2
  143. package/dist/cli/chunks/{chunk-54TDOQAH.js → chunk-WPSK237F.js} +3 -3
  144. package/dist/cli/chunks/{chunk-LMA6KEZH.js → chunk-XKQY2Z3Q.js} +1 -1
  145. package/dist/cli/chunks/{chunk-UMWYL37S.js → chunk-XLT3FYS7.js} +2 -2
  146. package/dist/cli/chunks/{chunk-5EW36WTI.js → chunk-XT4TDLOB.js} +2 -2
  147. package/dist/cli/chunks/{chunk-7UOH55UT.js → chunk-Y25PO65W.js} +2 -2
  148. package/dist/cli/chunks/{chunk-ED7MD6OI.js → chunk-Y6DWJKHU.js} +3 -3
  149. package/dist/cli/chunks/{chunk-A4NYOH7P.js → chunk-YBPLJRVT.js} +2 -2
  150. package/dist/cli/chunks/{chunk-BA7PJS3Y.js → chunk-YFCULQBP.js} +2 -2
  151. package/dist/cli/chunks/{chunk-B65CRJN6.js → chunk-YGVDP6X7.js} +1 -1
  152. package/dist/cli/chunks/chunk-YR2JKBZO.js +2 -0
  153. package/dist/cli/chunks/{chunk-FJRRXCIS.js → chunk-YZSTZUGJ.js} +1 -1
  154. package/dist/cli/chunks/{chunk-H2YOWAEB.js → chunk-ZG5UAEEO.js} +2 -2
  155. package/dist/cli/chunks/{chunk-MU36VPXV.js → chunk-ZLBY25MB.js} +1 -1
  156. package/dist/cli/chunks/chunk-ZMPAM4DY.js +2 -0
  157. package/dist/cli/chunks/{chunk-4ITHKHR5.js → chunk-ZPP57WQU.js} +2 -2
  158. package/dist/cli/chunks/{chunk-B6USJW5E.js → chunk-ZXEWTZFR.js} +1 -1
  159. package/dist/cli/chunks/{ci-JW4O2J3W.js → ci-CBNVLOOQ.js} +2 -2
  160. package/dist/cli/chunks/{ci-output-JNXJV4B2.js → ci-output-I4HY2FYJ.js} +2 -2
  161. package/dist/cli/chunks/{circuit-breaker-XDD4KUGR.js → circuit-breaker-5VRBKGWL.js} +2 -2
  162. package/dist/cli/chunks/{claude-flow-setup-L6IZOGYZ.js → claude-flow-setup-XPJPKHIO.js} +2 -2
  163. package/dist/cli/chunks/client-AHXNCOHK.js +2 -0
  164. package/dist/cli/chunks/{cline-installer-PK5SMN2B.js → cline-installer-OFRDUUWZ.js} +2 -2
  165. package/dist/cli/chunks/{code-ZDVX3SQH.js → code-QIZQVB3E.js} +2 -2
  166. package/dist/cli/chunks/{code-index-extractor-VXZNKEU5.js → code-index-extractor-LMUUWEX4.js} +2 -2
  167. package/dist/cli/chunks/{codex-installer-OXKSIX7H.js → codex-installer-N2MKIZ2S.js} +2 -2
  168. package/dist/cli/chunks/{completions-VRFFK223.js → completions-Y36S3C5J.js} +2 -2
  169. package/dist/cli/chunks/{complexity-analyzer-FTIMV74J.js → complexity-analyzer-73YS3WUD.js} +2 -2
  170. package/dist/cli/chunks/{continuedev-installer-KTYBBPN4.js → continuedev-installer-SAOTP6J3.js} +2 -2
  171. package/dist/cli/chunks/{copilot-installer-WDC3YNUR.js → copilot-installer-A4HXF6HE.js} +2 -2
  172. package/dist/cli/chunks/core-handlers-EEFLLMAZ.js +2 -0
  173. package/dist/cli/chunks/{cost-tracker-6MH4H33B.js → cost-tracker-P26XUVZS.js} +2 -2
  174. package/dist/cli/chunks/{coverage-NHATLNS4.js → coverage-HVNHSMVJ.js} +3 -3
  175. package/dist/cli/chunks/cross-domain-router-LT3H4SNJ.js +2 -0
  176. package/dist/cli/chunks/{cursor-installer-VQSUJDFB.js → cursor-installer-46BQFTYZ.js} +2 -2
  177. package/dist/cli/chunks/{daemon-3VAOEKQW.js → daemon-Y54O3FLT.js} +3 -3
  178. package/dist/cli/chunks/daemon-YE7K2AZF.js +10 -0
  179. package/dist/cli/chunks/{dag-attention-scheduler-HZ6OGYIH.js → dag-attention-scheduler-ETA7YY52.js} +2 -2
  180. package/dist/cli/chunks/{detect-CGU3SC63.js → detect-5WLQ2J3E.js} +2 -2
  181. package/dist/cli/chunks/{dist-node-DIBQ7PTA.js → dist-node-45WW6I7J.js} +2 -2
  182. package/dist/cli/chunks/{domain-handler-DCMGAYXS.js → domain-handler-J7DQV74M.js} +2 -2
  183. package/dist/cli/chunks/domain-transfer-GD2EGQVR.js +2 -0
  184. package/dist/cli/chunks/dream-4K3BK4IG.js +2 -0
  185. package/dist/cli/chunks/{embed-and-insert-pattern-7247LAU3.js → embed-and-insert-pattern-JELNEA2D.js} +2 -2
  186. package/dist/cli/chunks/{eval-6KR7TFOK.js → eval-A4PA5G2U.js} +2 -2
  187. package/dist/cli/chunks/{experience-capture-middleware-IIOR6RVV.js → experience-capture-middleware-MLHTYWTA.js} +3 -3
  188. package/dist/cli/chunks/{fast-paths-M7OGD4ZI.js → fast-paths-QYDTITRV.js} +2 -2
  189. package/dist/cli/chunks/{feature-flags-U75KFIGH.js → feature-flags-H4MSY26Z.js} +2 -2
  190. package/dist/cli/chunks/{feature-flags-GGUXHRJI.js → feature-flags-MQYYRHIK.js} +2 -2
  191. package/dist/cli/chunks/{file-discovery-V52AYEB7.js → file-discovery-RMFVJNGL.js} +2 -2
  192. package/dist/cli/chunks/{fleet-2UH72CK4.js → fleet-7KZQOTAC.js} +4 -4
  193. package/dist/cli/chunks/{gnn-wrapper-J2GDLT3P.js → gnn-wrapper-NMZFTGVH.js} +2 -2
  194. package/dist/cli/chunks/{heartbeat-handler-QIDQHRXT.js → heartbeat-handler-7BQDK7MG.js} +4 -4
  195. package/dist/cli/chunks/heartbeat-scheduler-IMPPGQUK.js +2 -0
  196. package/dist/cli/chunks/hnsw-adapter-EIAA6R2L.js +2 -0
  197. package/dist/cli/chunks/hnsw-index-ZXXP6AXZ.js +2 -0
  198. package/dist/cli/chunks/{hnsw-legacy-bridge-IU62PIY5.js → hnsw-legacy-bridge-TPPGBPKF.js} +2 -2
  199. package/dist/cli/chunks/{better-sqlite3-QNZJOJAB.js → hnswlib-node-E6NSZPP2.js} +2 -2
  200. package/dist/cli/chunks/{hooks-ZI4D3ATS.js → hooks-CYZIUYSH.js} +48 -52
  201. package/dist/cli/chunks/hybrid-router-LXWG4MLH.js +2 -0
  202. package/dist/cli/chunks/{hypergraph-engine-6JEERAGA.js → hypergraph-engine-WC6DMTYQ.js} +2 -2
  203. package/dist/cli/chunks/{hypergraph-handler-YMDGYCB6.js → hypergraph-handler-GTGA3TXJ.js} +3 -3
  204. package/dist/cli/chunks/impact-analyzer-TP5LRFYH.js +2 -0
  205. package/dist/cli/chunks/{init-handler-N57NW3QI.js → init-handler-N3Z72JNI.js} +6 -6
  206. package/dist/cli/chunks/init-wizard-AIOA5KOY.js +2 -0
  207. package/dist/cli/chunks/kernel-SQALRU6Q.js +2 -0
  208. package/dist/cli/chunks/{kilocode-installer-7ABTGXJ5.js → kilocode-installer-FUX4V6II.js} +2 -2
  209. package/dist/cli/chunks/{kiro-installer-2JFOHLVI.js → kiro-installer-ZSNZT7ZR.js} +2 -2
  210. package/dist/cli/chunks/knowledge-graph-JFVT6SNN.js +2 -0
  211. package/dist/cli/chunks/{learning-3P3ZXRGD.js → learning-UQY64COU.js} +3 -3
  212. package/dist/cli/chunks/{llm-router-AWB2KHDW.js → llm-router-CMHGGX6N.js} +4 -4
  213. package/dist/cli/chunks/llm-router-service-XHFKTH3I.js +2 -0
  214. package/dist/cli/chunks/{load-GGVBCBGX.js → load-E6WH4QN2.js} +2 -2
  215. package/dist/cli/chunks/load-test-JEIFJKNN.js +2 -0
  216. package/dist/cli/chunks/{mcp-33NHIBN3.js → mcp-UM5VTW6N.js} +2 -2
  217. package/dist/cli/chunks/{memory-IVAQS4OW.js → memory-7Q3XDUE5.js} +5 -5
  218. package/dist/cli/chunks/memory-backend-NT7I37CP.js +2 -0
  219. package/dist/cli/chunks/memory-handlers-746D7NE7.js +2 -0
  220. package/dist/cli/chunks/{multi-model-executor-NWQY6IN2.js → multi-model-executor-LZENWVRR.js} +2 -2
  221. package/dist/cli/chunks/{opencode-installer-FBB4JOEV.js → opencode-installer-O2JAIPLF.js} +2 -2
  222. package/dist/cli/chunks/{orchestrator-GDAXR7DH.js → orchestrator-DKZWXDRI.js} +5 -5
  223. package/dist/cli/chunks/pattern-null-store-6QU6WHDW.js +2 -0
  224. package/dist/cli/chunks/pattern-usage-recorder-CLUL4M55.js +2 -0
  225. package/dist/cli/chunks/{pipeline-VIKAOIBE.js → pipeline-2VDLTR5J.js} +2 -2
  226. package/dist/cli/chunks/{platform-FFVP36LH.js → platform-4N4Q5XYX.js} +2 -2
  227. package/dist/cli/chunks/{plugin-TI6QOLXH.js → plugin-GY5AU5CS.js} +2 -2
  228. package/dist/cli/chunks/{prime-radiant-advanced-wasm-AZRNI2OL.js → prime-radiant-advanced-wasm-TQ4DKDZS.js} +2 -2
  229. package/dist/cli/chunks/protocol-executor-GT2MZYUU.js +2 -0
  230. package/dist/cli/chunks/{protocol-handler-J4EA34B3.js → protocol-handler-T3LZ3WRG.js} +2 -2
  231. package/dist/cli/chunks/{prove-ADVRMAWS.js → prove-OV7S5J4W.js} +2 -2
  232. package/dist/cli/chunks/provider-manager-OATJ7R3D.js +2 -0
  233. package/dist/cli/chunks/qe-reasoning-bank-IJXNQ67O.js +2 -0
  234. package/dist/cli/chunks/{quality-GB5SJFSD.js → quality-AXD4NLQA.js} +2 -2
  235. package/dist/cli/chunks/queen-coordinator-6RBHWCUG.js +2 -0
  236. package/dist/cli/chunks/{real-embeddings-GDRJ4XSH.js → real-embeddings-2PUCC7FG.js} +2 -2
  237. package/dist/cli/chunks/{roocode-installer-Q6EISUDV.js → roocode-installer-WJ5ARGLW.js} +2 -2
  238. package/dist/cli/chunks/router-XKQRT5JK.js +2 -0
  239. package/dist/cli/chunks/routing-feedback-ACPSD4LW.js +2 -0
  240. package/dist/cli/chunks/{routing-handler-RO4RTRAG.js → routing-handler-CU6657SZ.js} +2 -2
  241. package/dist/cli/chunks/{ruvector-commands-FFIHCGVQ.js → ruvector-commands-IIF6VSFW.js} +2 -2
  242. package/dist/cli/chunks/{rvf-dual-writer-JGEK3A5Y.js → rvf-dual-writer-YMQI7XO2.js} +2 -2
  243. package/dist/cli/chunks/{rvf-migration-adapter-OVYC4QM6.js → rvf-migration-adapter-HDE3PR2W.js} +2 -2
  244. package/dist/cli/chunks/{rvf-migration-coordinator-U6L77QTS.js → rvf-migration-coordinator-MQV5OA7K.js} +2 -2
  245. package/dist/cli/chunks/rvf-native-adapter-SIWRKE33.js +2 -0
  246. package/dist/cli/chunks/safe-db-LCPUYMX4.js +2 -0
  247. package/dist/cli/chunks/schedule-HIQJCWXG.js +2 -0
  248. package/dist/cli/chunks/scheduler-QE5EJ5LE.js +2 -0
  249. package/dist/cli/chunks/{security-QPQIDAIL.js → security-UM3IGDSM.js} +3 -3
  250. package/dist/cli/chunks/{shared-rvf-adapter-JRJTI4UD.js → shared-rvf-adapter-I3SOJ6M4.js} +2 -2
  251. package/dist/cli/chunks/{shared-rvf-dual-writer-DSHGURDA.js → shared-rvf-dual-writer-KQGC2UO7.js} +2 -2
  252. package/dist/cli/chunks/sqlite-persistence-EU54UTMH.js +2 -0
  253. package/dist/cli/chunks/status-handler-OX4CJZME.js +46 -0
  254. package/dist/cli/chunks/{structural-health-UVECCN7U.js → structural-health-PYUMVBXJ.js} +2 -2
  255. package/dist/cli/chunks/{sync-XXIGTGCG.js → sync-2TED3YTY.js} +2 -2
  256. package/dist/cli/chunks/{sync-ZLZ4CZFJ.js → sync-VALFNTA6.js} +2 -2
  257. package/dist/cli/chunks/{task-handler-73YAVOKJ.js → task-handler-VPGAJVPC.js} +2 -2
  258. package/dist/cli/chunks/{task-handlers-PKECV27D.js → task-handlers-IB4UAMU6.js} +3 -3
  259. package/dist/cli/chunks/{test-U3SXW4SV.js → test-OMRJOZB6.js} +4 -4
  260. package/dist/cli/chunks/{test-scheduling-POJND3GV.js → test-scheduling-ZL3YFPBU.js} +3 -3
  261. package/dist/cli/chunks/{token-bootstrap-ICX6SIXJ.js → token-bootstrap-DNWZI7SH.js} +2 -2
  262. package/dist/cli/chunks/{token-usage-WCHJUVGT.js → token-usage-IYO7RGFF.js} +2 -2
  263. package/dist/cli/chunks/{transformers-L77UIHIY.js → transformers-53ALC34T.js} +2 -2
  264. package/dist/cli/chunks/{tree-sitter-wasm-parser-CVAXURQP.js → tree-sitter-wasm-parser-WUKJ2I2Q.js} +2 -2
  265. package/dist/cli/chunks/{types-LNVJBDM2.js → types-47FTEPMV.js} +2 -2
  266. package/dist/cli/chunks/unified-memory-CJLMC2I4.js +2 -0
  267. package/dist/cli/chunks/unified-memory-hnsw-FDGR4D2J.js +2 -0
  268. package/dist/cli/chunks/unified-persistence-UFH5GLDN.js +2 -0
  269. package/dist/cli/chunks/{upgrade-4ND5RQFY.js → upgrade-QPLMJA5Z.js} +2 -2
  270. package/dist/cli/chunks/{validate-ZA4XT6K2.js → validate-3GVKZOVF.js} +2 -2
  271. package/dist/cli/chunks/{validate-swarm-FNK3GCJ4.js → validate-swarm-XCRTLVM6.js} +2 -2
  272. package/dist/cli/chunks/{vibium-E2CK2GBQ.js → vibium-CH4VPKVZ.js} +2 -2
  273. package/dist/cli/chunks/visual-security-4ARJ7J2Y.js +2 -0
  274. package/dist/cli/chunks/{web-tree-sitter-63VRNKZV.js → web-tree-sitter-JDBNAZTV.js} +2 -2
  275. package/dist/cli/chunks/{windsurf-installer-5BTCVOLH.js → windsurf-installer-3MNPVJBP.js} +2 -2
  276. package/dist/cli/chunks/witness-chain-73QC33ED.js +2 -0
  277. package/dist/cli/chunks/{witness-chain-6CUUGISD.js → witness-chain-HR5UBV5J.js} +2 -2
  278. package/dist/cli/chunks/witness-key-manager-G5SQTIBZ.js +2 -0
  279. package/dist/cli/chunks/{workflow-V7ED22XT.js → workflow-43EMD5FY.js} +4 -4
  280. package/dist/cli/chunks/workflow-orchestrator-RKMMPXNA.js +2 -0
  281. package/dist/cli/chunks/{wrappers-7S3NTTLW.js → wrappers-3N7AYNM3.js} +2 -2
  282. package/dist/cli/commands/audit.d.ts +12 -0
  283. package/dist/cli/commands/audit.js +64 -4
  284. package/dist/cli/commands/hooks-handlers/hooks-dream-learning.js +45 -19
  285. package/dist/cli/commands/hooks-handlers/hooks-shared.d.ts +13 -0
  286. package/dist/cli/commands/hooks-handlers/hooks-shared.js +38 -0
  287. package/dist/cli/commands/hooks-handlers/task-hooks.js +19 -1
  288. package/dist/cli/handlers/status-handler.d.ts +18 -0
  289. package/dist/cli/handlers/status-handler.js +47 -0
  290. package/dist/coordination/consensus/providers/ollama-provider.js +3 -2
  291. package/dist/coordination/mincut/queen-integration.js +24 -7
  292. package/dist/coordination/protocol-executor.js +2 -1
  293. package/dist/coordination/queen-lifecycle.js +4 -1
  294. package/dist/domains/code-intelligence/coordinator.js +10 -6
  295. package/dist/domains/code-intelligence/services/product-factors-bridge.js +3 -1
  296. package/dist/domains/defect-intelligence/services/defect-predictor.d.ts +6 -0
  297. package/dist/domains/defect-intelligence/services/defect-predictor.js +21 -0
  298. package/dist/domains/learning-optimization/interfaces.d.ts +7 -0
  299. package/dist/domains/learning-optimization/plugin.js +5 -0
  300. package/dist/domains/learning-optimization/services/learning-coordinator.d.ts +10 -0
  301. package/dist/domains/learning-optimization/services/learning-coordinator.js +57 -0
  302. package/dist/domains/test-execution/plugin.js +2 -2
  303. package/dist/domains/test-execution/services/flaky-detector.js +1 -1
  304. package/dist/domains/test-generation/coordinator.js +22 -8
  305. package/dist/domains/test-generation/interfaces.d.ts +3 -0
  306. package/dist/domains/test-generation/services/test-generator.js +9 -1
  307. package/dist/integrations/ruvector/delta-tracker.js +10 -1
  308. package/dist/integrations/ruvector/proof-gate.d.ts +68 -0
  309. package/dist/integrations/ruvector/proof-gate.js +135 -0
  310. package/dist/integrations/ruvector/sona-persistence.d.ts +24 -0
  311. package/dist/integrations/ruvector/sona-persistence.js +76 -0
  312. package/dist/integrations/ruvector/sona-three-loop.d.ts +15 -0
  313. package/dist/integrations/ruvector/sona-three-loop.js +17 -0
  314. package/dist/kernel/unified-memory-schemas.d.ts +2 -2
  315. package/dist/kernel/unified-memory-schemas.js +48 -2
  316. package/dist/kernel/unified-memory.d.ts +57 -0
  317. package/dist/kernel/unified-memory.js +148 -0
  318. package/dist/learning/aqe-learning-engine.js +3 -1
  319. package/dist/learning/dream/concept-graph.d.ts +31 -1
  320. package/dist/learning/dream/concept-graph.js +109 -3
  321. package/dist/learning/dream/dream-engine.d.ts +13 -1
  322. package/dist/learning/dream/dream-engine.js +146 -10
  323. package/dist/learning/dream/index.d.ts +1 -1
  324. package/dist/learning/dream/types.d.ts +23 -0
  325. package/dist/learning/local-judge-client.js +2 -1
  326. package/dist/learning/pattern-store.d.ts +2 -2
  327. package/dist/learning/pattern-store.js +14 -3
  328. package/dist/learning/qe-reasoning-bank.js +34 -31
  329. package/dist/learning/routing-topology-gate.d.ts +12 -2
  330. package/dist/learning/routing-topology-gate.js +15 -3
  331. package/dist/learning/rvf-pattern-store.d.ts +1 -1
  332. package/dist/learning/rvf-pattern-store.js +21 -8
  333. package/dist/learning/sqlite-persistence.js +12 -9
  334. package/dist/mcp/bundle.js +524 -445
  335. package/dist/mcp/qe-tool-bridge.js +7 -2
  336. package/dist/mcp/tools/base.d.ts +29 -0
  337. package/dist/mcp/tools/base.js +25 -0
  338. package/dist/mcp/tools/coverage-analysis/index.js +6 -4
  339. package/dist/mcp/tools/learning-optimization/dream.d.ts +4 -13
  340. package/dist/mcp/tools/learning-optimization/dream.js +10 -96
  341. package/dist/mcp/tools/planning/goap-execute.d.ts +13 -1
  342. package/dist/mcp/tools/planning/goap-execute.js +33 -18
  343. package/dist/mcp/tools/registry.js +7 -2
  344. package/dist/persistence/rvf-migration-coordinator.js +2 -1
  345. package/dist/planning/actions/qe-action-library.js +124 -1
  346. package/dist/planning/goap-planner.d.ts +14 -2
  347. package/dist/planning/goap-planner.js +51 -9
  348. package/dist/planning/index.d.ts +1 -1
  349. package/dist/planning/plan-executor.d.ts +84 -4
  350. package/dist/planning/plan-executor.js +221 -56
  351. package/dist/planning/types.d.ts +27 -0
  352. package/dist/routing/free-tier/coordinator-support.d.ts +6 -3
  353. package/dist/routing/free-tier/coordinator-support.js +6 -3
  354. package/dist/routing/free-tier/executor.d.ts +14 -0
  355. package/dist/routing/free-tier/executor.js +21 -0
  356. package/dist/routing/free-tier/index.d.ts +1 -0
  357. package/dist/routing/free-tier/index.js +1 -0
  358. package/dist/routing/free-tier/pattern-cache.d.ts +57 -0
  359. package/dist/routing/free-tier/pattern-cache.js +148 -0
  360. package/dist/routing/free-tier/provider.js +9 -1
  361. package/dist/routing/value-score.js +3 -0
  362. package/dist/shared/embeddings/ollama-client.js +2 -1
  363. package/dist/shared/events/domain-events.d.ts +2 -0
  364. package/dist/shared/llm/model-mapping.js +26 -0
  365. package/dist/shared/llm/model-registry.d.ts +10 -0
  366. package/dist/shared/llm/model-registry.js +92 -0
  367. package/dist/shared/llm/ollama-url.d.ts +17 -0
  368. package/dist/shared/llm/ollama-url.js +25 -0
  369. package/dist/shared/llm/providers/ollama-timeout.d.ts +26 -0
  370. package/dist/shared/llm/providers/ollama-timeout.js +31 -0
  371. package/dist/shared/llm/providers/ollama.d.ts +10 -0
  372. package/dist/shared/llm/providers/ollama.js +31 -4
  373. package/dist/shared/llm/router/hybrid-router.js +18 -1
  374. package/dist/workers/workers/learning-consolidation.js +21 -1
  375. package/package.json +5 -1
  376. package/dist/cli/chunks/adapter-IU3H3MD7.js +0 -2
  377. package/dist/cli/chunks/aqe-learning-engine-BGOC63IN.js +0 -2
  378. package/dist/cli/chunks/audit-TTWAAV7P.js +0 -3
  379. package/dist/cli/chunks/base-DVPRE3WO.js +0 -2
  380. package/dist/cli/chunks/brain-handler-FXPLJCPV.js +0 -89
  381. package/dist/cli/chunks/browser-workflow-MP5P7KZF.js +0 -2
  382. package/dist/cli/chunks/chunk-2SZQDTI5.js +0 -2
  383. package/dist/cli/chunks/chunk-6IHB3T6M.js +0 -2
  384. package/dist/cli/chunks/chunk-7PDUD7FF.js +0 -2
  385. package/dist/cli/chunks/chunk-EBCUWMLX.js +0 -27
  386. package/dist/cli/chunks/chunk-NWUVXLBB.js +0 -65
  387. package/dist/cli/chunks/chunk-OCACCUFO.js +0 -2
  388. package/dist/cli/chunks/chunk-PY2Q6MN3.js +0 -24
  389. package/dist/cli/chunks/chunk-UNH2DE2G.js +0 -2
  390. package/dist/cli/chunks/client-ADCDBTEE.js +0 -2
  391. package/dist/cli/chunks/core-handlers-HCACMLUW.js +0 -2
  392. package/dist/cli/chunks/cross-domain-router-HXFQAU4M.js +0 -2
  393. package/dist/cli/chunks/daemon-ZSK6CLQR.js +0 -10
  394. package/dist/cli/chunks/domain-transfer-UWFKBZTJ.js +0 -2
  395. package/dist/cli/chunks/dream-SVWQH62A.js +0 -2
  396. package/dist/cli/chunks/heartbeat-scheduler-QW5TW5QS.js +0 -2
  397. package/dist/cli/chunks/hnsw-adapter-D6EJWYAL.js +0 -2
  398. package/dist/cli/chunks/hnsw-index-4MWR4U5W.js +0 -2
  399. package/dist/cli/chunks/hybrid-router-BYVUBHER.js +0 -2
  400. package/dist/cli/chunks/impact-analyzer-OK2UIMSG.js +0 -2
  401. package/dist/cli/chunks/init-wizard-6NNPNS6J.js +0 -2
  402. package/dist/cli/chunks/kernel-F4A4GRNO.js +0 -2
  403. package/dist/cli/chunks/knowledge-graph-MSJDEZCF.js +0 -2
  404. package/dist/cli/chunks/llm-router-service-27IQAO7G.js +0 -2
  405. package/dist/cli/chunks/load-test-TT5VLAN7.js +0 -2
  406. package/dist/cli/chunks/memory-backend-FVSK53IM.js +0 -2
  407. package/dist/cli/chunks/memory-handlers-OPUDOZNT.js +0 -2
  408. package/dist/cli/chunks/pattern-null-store-7MVEDWCY.js +0 -2
  409. package/dist/cli/chunks/protocol-executor-BLDDYEJ4.js +0 -2
  410. package/dist/cli/chunks/provider-manager-ZYCFRYZQ.js +0 -2
  411. package/dist/cli/chunks/qe-reasoning-bank-P66CCPHM.js +0 -2
  412. package/dist/cli/chunks/queen-coordinator-LPHT3SX5.js +0 -2
  413. package/dist/cli/chunks/router-XQ2TERUT.js +0 -2
  414. package/dist/cli/chunks/routing-feedback-K52O752B.js +0 -2
  415. package/dist/cli/chunks/rvf-native-adapter-G4DV7FK3.js +0 -2
  416. package/dist/cli/chunks/safe-db-TMSEITES.js +0 -2
  417. package/dist/cli/chunks/schedule-RWFLA43O.js +0 -2
  418. package/dist/cli/chunks/scheduler-2V55MJJR.js +0 -2
  419. package/dist/cli/chunks/sqlite-persistence-L7QM6IWF.js +0 -2
  420. package/dist/cli/chunks/status-handler-SBT3MZTX.js +0 -45
  421. package/dist/cli/chunks/unified-memory-ZSULA46X.js +0 -2
  422. package/dist/cli/chunks/unified-memory-hnsw-SQEWFUBN.js +0 -2
  423. package/dist/cli/chunks/unified-persistence-EDCTT6SE.js +0 -2
  424. package/dist/cli/chunks/visual-security-SOGAETFP.js +0 -2
  425. package/dist/cli/chunks/witness-chain-AJCECBH5.js +0 -2
  426. package/dist/cli/chunks/workflow-orchestrator-UXRUCOZR.js +0 -2
@@ -1,11 +1,11 @@
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.11.3");process.exit(0)}
2
- import{d as G,f as we}from"./chunk-7FVWETN4.js";import{a as ye}from"./chunk-UNH2DE2G.js";import{c as J}from"./chunk-7UOH55UT.js";import{a as q,b,c as Fe}from"./chunk-BA7PJS3Y.js";import{b as L,d as ee}from"./chunk-G6MPXBCD.js";import{a as k,c as Ue}from"./chunk-UTGW75AZ.js";import{a as Q,c as ve}from"./chunk-LGEZ3ZJX.js";import{a as Z,b as Xe}from"./chunk-DNOBN3IR.js";import{a as te,d as v,e as ne,f as re}from"./chunk-WV66MXJI.js";import{a as O,e as De}from"./chunk-77QJQRL2.js";import{c as R,e as be}from"./chunk-PUK5NE47.js";function I(i){if(!z.has(i))throw new Error(`Invalid table name: "${i}" is not in the allowlist`);return i}function Be(i){let e=i.split(".");if(e.length>2)throw new Error(`Invalid SQL identifier: "${i}" has too many parts (max: schema.table)`);for(let t of e)if(!se.test(t))throw new Error(`Invalid SQL identifier: "${i}" \u2014 part "${t}" does not match pattern ${se}`);return i}var z,se,j=R(()=>{"use strict";z=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","qe_agent_co_execution"]);se=/^[a-z_][a-z0-9_]{0,62}$/});var D,oe,ie,ae,ce,Te,Ee,de,ue,le,pe,ge,me=R(()=>{"use strict";we();Ue();D=10,oe=`
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.11.5");process.exit(0)}
2
+ import{d as z,f as ke}from"./chunk-IU5RSN6M.js";import{a as Ge}from"./chunk-ZMPAM4DY.js";import{c as te}from"./chunk-Y25PO65W.js";import{a as B,b,c as ze}from"./chunk-YFCULQBP.js";import{b as L,d as re}from"./chunk-CKOF27L7.js";import{a as j,c as qe}from"./chunk-TTJJ4DQE.js";import{a as D,c as Fe}from"./chunk-RKXZLTWR.js";import{a as ne,b as Pe}from"./chunk-FHTYEAQ3.js";import{a as se,d as X,e as oe,f as ie}from"./chunk-3JF5A72M.js";import{a as v,e as Me}from"./chunk-FIPKIIMS.js";import{c as h,e as xe}from"./chunk-C4EZNOWK.js";import{createHash as Te}from"node:crypto";function Be(o){let e=Buffer.alloc(8);return e.writeBigUInt64LE(BigInt(o)),e}function We(o){return typeof o=="string"?Buffer.from(o,"utf8"):o instanceof Uint8Array?Buffer.from(o):Buffer.from(W(o),"utf8")}function W(o){return o===null||typeof o!="object"?JSON.stringify(o)??"null":Array.isArray(o)?`[${o.map(W).join(",")}]`:`{${Object.keys(o).sort().map(t=>`${JSON.stringify(t)}:${W(o[t])}`).join(",")}}`}function de(...o){let e=Te("sha256");for(let t of o)e.update(t);return e.digest()}function ce(o,e,t){return de(je,o,e,Be(t))}var je,ae,I,Ee=h(()=>{"use strict";je=Buffer.from("ruvector:chain:"),ae=Te("sha256").update("ruvector-proof-gate-v1").digest();I=class o{seq=0;prev=ae;chain=[];payloadHashes=[];admit(e){let t=de(We(e)),n=ce(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=ae;for(let t=0;t<this.chain.length;t++){if(!ce(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 o;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 O(o){if(!H.has(o))throw new Error(`Invalid table name: "${o}" is not in the allowlist`);return o}function nt(o){let e=o.split(".");if(e.length>2)throw new Error(`Invalid SQL identifier: "${o}" has too many parts (max: schema.table)`);for(let t of e)if(!ue.test(t))throw new Error(`Invalid SQL identifier: "${o}" \u2014 part "${t}" does not match pattern ${ue}`);return o}var H,ue,Y=h(()=>{"use strict";H=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","qe_agent_co_execution"]);ue=/^[a-z_][a-z0-9_]{0,62}$/});var w,pe,le,ge,me,$,_e,fe,Ne,Se,he,Re,Le=h(()=>{"use strict";ke();qe();w=11,pe=`
3
3
  CREATE TABLE IF NOT EXISTS schema_version (
4
4
  id INTEGER PRIMARY KEY CHECK (id = 1),
5
5
  version INTEGER NOT NULL,
6
6
  migrated_at TEXT DEFAULT (datetime('now'))
7
7
  );
8
- `,ie=`
8
+ `,le=`
9
9
  -- Key-Value Store (v2 compatible - same schema as HybridBackend)
10
10
  CREATE TABLE IF NOT EXISTS kv_store (
11
11
  key TEXT NOT NULL,
@@ -17,7 +17,7 @@ import{d as G,f as we}from"./chunk-7FVWETN4.js";import{a as ye}from"./chunk-UNH2
17
17
  );
18
18
  CREATE INDEX IF NOT EXISTS idx_kv_namespace ON kv_store(namespace);
19
19
  CREATE INDEX IF NOT EXISTS idx_kv_expires ON kv_store(expires_at) WHERE expires_at IS NOT NULL;
20
- `,ae=`
20
+ `,ge=`
21
21
  -- Vector Embeddings (new in v3 - replaces in-memory AgentDB)
22
22
  CREATE TABLE IF NOT EXISTS vectors (
23
23
  id TEXT PRIMARY KEY,
@@ -30,7 +30,7 @@ import{d as G,f as we}from"./chunk-7FVWETN4.js";import{a as ye}from"./chunk-UNH2
30
30
  );
31
31
  CREATE INDEX IF NOT EXISTS idx_vectors_namespace ON vectors(namespace);
32
32
  CREATE INDEX IF NOT EXISTS idx_vectors_dimensions ON vectors(dimensions);
33
- `,ce=`
33
+ `,me=`
34
34
  -- Q-Values for RL algorithms (ADR-046)
35
35
  CREATE TABLE IF NOT EXISTS rl_q_values (
36
36
  id TEXT PRIMARY KEY,
@@ -51,7 +51,7 @@ import{d as G,f as we}from"./chunk-7FVWETN4.js";import{a as ye}from"./chunk-UNH2
51
51
  CREATE INDEX IF NOT EXISTS idx_qvalues_state ON rl_q_values(agent_id, state_key);
52
52
  CREATE INDEX IF NOT EXISTS idx_qvalues_domain ON rl_q_values(domain);
53
53
  CREATE INDEX IF NOT EXISTS idx_qvalues_updated ON rl_q_values(updated_at);
54
- `,Te=`
54
+ `,$=`
55
55
  -- GOAP Goals
56
56
  CREATE TABLE IF NOT EXISTS goap_goals (
57
57
  id TEXT PRIMARY KEY,
@@ -78,7 +78,13 @@ import{d as G,f as we}from"./chunk-7FVWETN4.js";import{a as ye}from"./chunk-UNH2
78
78
  category TEXT NOT NULL,
79
79
  qe_domain TEXT,
80
80
  created_at TEXT DEFAULT (datetime('now')),
81
- updated_at TEXT DEFAULT (datetime('now'))
81
+ updated_at TEXT DEFAULT (datetime('now')),
82
+ -- A14: real domain API method binding (kernel.getDomainAPI(qe_domain)[method](params)).
83
+ -- method/implemented are NULL/0 for actions with no real backing yet \u2014
84
+ -- GOAPExecutor must report those as "not implemented", never simulate them.
85
+ method TEXT,
86
+ params TEXT,
87
+ implemented INTEGER DEFAULT 0
82
88
  );
83
89
 
84
90
  -- GOAP Plans
@@ -112,12 +118,51 @@ import{d as G,f as we}from"./chunk-7FVWETN4.js";import{a as ye}from"./chunk-UNH2
112
118
  created_at TEXT DEFAULT (datetime('now'))
113
119
  );
114
120
 
121
+ -- A14: canonical per-step execution history (was previously undefined in
122
+ -- this schema \u2014 plan-executor.ts invented its own parallel
123
+ -- execution_results/executed_steps tables instead). One row per action
124
+ -- step per execution attempt (execution_id groups steps from the same
125
+ -- plan.execute() call, since a plan can be executed/retried more than
126
+ -- once). Aggregate per-execution stats (steps completed/failed, total
127
+ -- duration, final world state) are derived by querying this table rather
128
+ -- than maintained in a separate denormalized summary table.
129
+ CREATE TABLE IF NOT EXISTS goap_execution_steps (
130
+ id TEXT PRIMARY KEY,
131
+ plan_id TEXT NOT NULL,
132
+ execution_id TEXT NOT NULL,
133
+ action_id TEXT NOT NULL,
134
+ step_order INTEGER NOT NULL,
135
+ world_state_before TEXT,
136
+ world_state_after TEXT,
137
+ status TEXT NOT NULL DEFAULT 'pending',
138
+ retries INTEGER DEFAULT 0,
139
+ started_at TEXT,
140
+ duration_ms INTEGER,
141
+ agent_id TEXT,
142
+ agent_output TEXT,
143
+ error_message TEXT,
144
+ created_at TEXT DEFAULT (datetime('now'))
145
+ -- Deliberately no FK to goap_plans/goap_actions: PlanExecutor.execute()
146
+ -- can legitimately run an ad-hoc GOAPPlan/GOAPAction that was never
147
+ -- saved via savePlan()/addAction() (e.g. programmatic orchestration
148
+ -- bypassing the A* planner). unified-memory.ts enables the
149
+ -- foreign_keys pragma, so an enforced FK here would reject that
150
+ -- entirely legitimate usage, not just catch real corruption.
151
+ );
152
+
115
153
  -- GOAP Indexes
116
154
  CREATE INDEX IF NOT EXISTS idx_goap_actions_category ON goap_actions(category);
117
155
  CREATE INDEX IF NOT EXISTS idx_goap_actions_agent ON goap_actions(agent_type);
118
156
  CREATE INDEX IF NOT EXISTS idx_goap_plans_status ON goap_plans(status);
119
157
  CREATE INDEX IF NOT EXISTS idx_goap_sig_goal ON goap_plan_signatures(goal_hash);
120
- `,Ee=`
158
+ CREATE INDEX IF NOT EXISTS idx_goap_exec_steps_plan ON goap_execution_steps(plan_id);
159
+ CREATE INDEX IF NOT EXISTS idx_goap_exec_steps_action ON goap_execution_steps(action_id);
160
+ -- idx_goap_exec_steps_execution is NOT created here: databases with a
161
+ -- pre-existing narrower goap_execution_steps table (missing execution_id)
162
+ -- would fail on "no such column" since CREATE TABLE IF NOT EXISTS above
163
+ -- silently no-ops against them. unified-memory.ts's v11 migration creates
164
+ -- this index only after confirming/backfilling the column.
165
+ `,_e=`
121
166
  -- Concept Graph Nodes (Dream Engine)
122
167
  CREATE TABLE IF NOT EXISTS concept_nodes (
123
168
  id TEXT PRIMARY KEY,
@@ -186,7 +231,7 @@ import{d as G,f as we}from"./chunk-7FVWETN4.js";import{a as ye}from"./chunk-UNH2
186
231
  CREATE INDEX IF NOT EXISTS idx_edge_weight ON concept_edges(weight DESC);
187
232
  CREATE INDEX IF NOT EXISTS idx_insight_cycle ON dream_insights(cycle_id);
188
233
  CREATE INDEX IF NOT EXISTS idx_dream_status ON dream_cycles(status);
189
- `,de=`
234
+ `,fe=`
190
235
  -- QE Patterns table (unified from sqlite-persistence.ts)
191
236
  CREATE TABLE IF NOT EXISTS qe_patterns (
192
237
  id TEXT PRIMARY KEY,
@@ -336,7 +381,7 @@ import{d as G,f as we}from"./chunk-7FVWETN4.js";import{a as ye}from"./chunk-UNH2
336
381
  CREATE INDEX IF NOT EXISTS idx_execution_results_status ON execution_results(status);
337
382
  CREATE INDEX IF NOT EXISTS idx_executed_steps_execution ON executed_steps(execution_id);
338
383
  CREATE INDEX IF NOT EXISTS idx_executed_steps_action ON executed_steps(action_id);
339
- `,ue=`
384
+ `,Ne=`
340
385
  -- MinCut Graph Snapshots (ADR-047)
341
386
  CREATE TABLE IF NOT EXISTS mincut_snapshots (
342
387
  id TEXT PRIMARY KEY,
@@ -442,7 +487,7 @@ import{d as G,f as we}from"./chunk-7FVWETN4.js";import{a as ye}from"./chunk-UNH2
442
487
  CREATE INDEX IF NOT EXISTS idx_mincut_healing_type ON mincut_healing_actions(action_type);
443
488
  CREATE INDEX IF NOT EXISTS idx_mincut_healing_success ON mincut_healing_actions(success);
444
489
  CREATE INDEX IF NOT EXISTS idx_mincut_observations_iter ON mincut_observations(iteration);
445
- `,le=`
490
+ `,Se=`
446
491
  -- SONA Patterns table (ADR-046: Pattern Persistence for Neural Backbone)
447
492
  CREATE TABLE IF NOT EXISTS sona_patterns (
448
493
  id TEXT PRIMARY KEY,
@@ -468,7 +513,7 @@ import{d as G,f as we}from"./chunk-7FVWETN4.js";import{a as ye}from"./chunk-UNH2
468
513
  CREATE INDEX IF NOT EXISTS idx_sona_patterns_domain ON sona_patterns(domain);
469
514
  CREATE INDEX IF NOT EXISTS idx_sona_patterns_confidence ON sona_patterns(confidence DESC);
470
515
  CREATE INDEX IF NOT EXISTS idx_sona_patterns_updated ON sona_patterns(updated_at DESC);
471
- `,pe=`
516
+ `,he=`
472
517
  -- Test outcomes (ADR-023: Quality Feedback Loop)
473
518
  CREATE TABLE IF NOT EXISTS test_outcomes (
474
519
  id TEXT PRIMARY KEY,
@@ -551,16 +596,16 @@ import{d as G,f as we}from"./chunk-7FVWETN4.js";import{a as ye}from"./chunk-UNH2
551
596
  CREATE INDEX IF NOT EXISTS idx_coverage_sessions_technique ON coverage_sessions(technique);
552
597
  CREATE INDEX IF NOT EXISTS idx_coverage_sessions_agent ON coverage_sessions(agent_id);
553
598
  CREATE INDEX IF NOT EXISTS idx_coverage_sessions_created ON coverage_sessions(created_at);
554
- `,ge=["kv_store","vectors","rl_q_values","goap_actions","goap_goals","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","hypergraph_nodes","hypergraph_edges","sona_patterns","witness_chain"]});function y(i,e,t){let n={value:e,timestamp:t??(e!==void 0?Date.now():0),nodeId:e!==void 0?i:"",version:e!==void 0?1:0,lastUpdated:Date.now()};function d(o,T,u,c){return o!==u?o-u:T.localeCompare(c)}return{get(){return n.value},set(o,T){let u=T??Date.now();(n.timestamp===0||d(u,i,n.timestamp,n.nodeId)>0)&&(n={value:o,timestamp:u,nodeId:i,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||d(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 i},getTimestamp(){return n.timestamp}}}function X(i,e){let t=y(i);return t.applyState(e),t}var B=R(()=>{"use strict"});function C(i){let e={counts:{},version:0,lastUpdated:Date.now()};return e.counts[i]=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[i]=(e.counts[i]||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[d,o]of Object.entries(t.counts)){let T=e.counts[d]||0;o>T&&(e.counts[d]=o,n=!0)}n&&(e.version=Math.max(e.version,t.version)+1,e.lastUpdated=Date.now())},getNodeId(){return i},getLocalCount(){return e.counts[i]||0}}}function w(i,e){let t=C(i);return t.applyState(e),t}var U=R(()=>{"use strict"});function F(i){let e=C(i),t=C(i),n=0,d=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++,d=Date.now())},decrement(o=1){if(o<0)throw new Error("Use increment() for negative values");o!==0&&(t.increment(o),n++,d=Date.now())},merge(o){let T=o.getState();this.applyState(T)},getState(){return{positive:e.getState(),negative:t.getState(),version:n,lastUpdated:d}},applyState(o){let T=this.get();e.applyState(o.positive),t.applyState(o.negative);let u=this.get();T!==u&&(n=Math.max(n,o.version)+1,d=Date.now())},getNodeId(){return i}}}function x(i,e){let t=F(i);return t.applyState(e),t}var W=R(()=>{"use strict";U()});function xe(i,e){return`${i}:${Date.now()}:${e}`}function Y(i){return typeof i=="string"?`s:${i}`:typeof i=="number"?`n:${i}`:typeof i=="boolean"?`b:${i}`:`j:${JSON.stringify(i)}`}function Me(i){let e=i.substring(0,2),t=i.substring(2);switch(e){case"s:":return t;case"n:":return Number(t);case"b:":return t==="true";case"j:":return L(t);default:throw new Error(`Unknown serialization type: ${e}`)}}function M(i){let e=new Map,t=new Map,n=0,d=Date.now(),o=0;function T(c){let E=e.get(c);if(!E||E.size===0)return!1;let l=t.get(c);if(!l||l.size===0)return!0;for(let g of E)if(!l.has(g))return!0;return!1}function u(c){let E=e.get(c);if(!E)return new Set;let l=t.get(c)||new Set,g=new Set;for(let p of E)l.has(p)||g.add(p);return g}return{has(c){let E=Y(c);return T(E)},values(){let c=[];for(let[E]of e)T(E)&&c.push(Me(E));return c},size(){let c=0;for(let[E]of e)T(E)&&c++;return c},add(c){let E=Y(c),l=xe(i,o++);e.has(E)||e.set(E,new Set),e.get(E).add(l),n++,d=Date.now()},remove(c){let E=Y(c),l=e.get(E);if(!l||l.size===0)return;t.has(E)||t.set(E,new Set);let g=t.get(E);for(let p of l)g.add(p);n++,d=Date.now()},merge(c){let E=c.getState();this.applyState(E)},getState(){let c={};for(let[l,g]of e)c[l]=Array.from(g);let E={};for(let[l,g]of t)g.size>0&&(E[l]=Array.from(g));return{elements:c,tombstones:E,version:n,lastUpdated:d}},applyState(c){let E=!1;for(let[l,g]of Object.entries(c.elements)){e.has(l)||e.set(l,new Set);let p=e.get(l);for(let f of g)p.has(f)||(p.add(f),E=!0)}for(let[l,g]of Object.entries(c.tombstones)){t.has(l)||t.set(l,new Set);let p=t.get(l);for(let f of g)p.has(f)||(p.add(f),E=!0)}E&&(n=Math.max(n,c.version)+1,d=Date.now())},getNodeId(){return i},clear(){for(let[c,E]of e){t.has(c)||t.set(c,new Set);let l=t.get(c);for(let g of E)l.add(g)}n++,d=Date.now()}}}function P(i,e){let t=M(i);return t.applyState(e),t}var H=R(()=>{"use strict";ee()});function $(i){let e={...Pe,...i},{nodeId:t,enableDeltaTracking:n,maxDeltaHistory:d}=e,o=new Map,T=new Map,u=new Map,c=new Map,E=0,l=[],g=new Set,p={registers:new Set,gCounters:new Set,pnCounters:new Set,sets:new Set};function f(s,r,a){let _={key:s,type:r,operation:a,timestamp:Date.now(),nodeId:t};for(let Ae of g)try{Ae(_)}catch(Oe){console.error("[CRDTStore] Error in change listener:",Oe)}}function N(s,r){E++,n&&p[s].add(r)}function V(){if(!n||!(p.registers.size>0||p.gCounters.size>0||p.pnCounters.size>0||p.sets.size>0))return;let r={fromVersion:l.length>0?l[l.length-1].toVersion:0,toVersion:E,timestamp:Date.now(),nodeId:t};if(p.registers.size>0){r.registers={};for(let a of p.registers){let _=o.get(a);_&&(r.registers[a]=_.getState())}p.registers.clear()}if(p.gCounters.size>0){r.gCounters={};for(let a of p.gCounters){let _=T.get(a);_&&(r.gCounters[a]=_.getState())}p.gCounters.clear()}if(p.pnCounters.size>0){r.pnCounters={};for(let a of p.pnCounters){let _=u.get(a);_&&(r.pnCounters[a]=_.getState())}p.pnCounters.clear()}if(p.sets.size>0){r.sets={};for(let a of p.sets){let _=c.get(a);_&&(r.sets[a]=_.getState())}p.sets.clear()}for(l.push(r);l.length>d;)l.shift()}let h={getRegister(s){return o.has(s)||o.set(s,y(t)),o.get(s)},setRegister(s,r){h.getRegister(s).set(r),N("registers",s),f(s,"lww-register","set")},hasRegister(s){return o.has(s)},deleteRegister(s){let r=o.delete(s);return r&&N("registers",s),r},getGCounter(s){return T.has(s)||T.set(s,C(t)),T.get(s)},incrementGCounter(s,r){h.getGCounter(s).increment(r),N("gCounters",s),f(s,"g-counter","increment")},hasGCounter(s){return T.has(s)},deleteGCounter(s){let r=T.delete(s);return r&&N("gCounters",s),r},getCounter(s){return u.has(s)||u.set(s,F(t)),u.get(s)},incrementCounter(s,r){h.getCounter(s).increment(r),N("pnCounters",s),f(s,"pn-counter","increment")},decrementCounter(s,r){h.getCounter(s).decrement(r),N("pnCounters",s),f(s,"pn-counter","decrement")},hasCounter(s){return u.has(s)},deleteCounter(s){let r=u.delete(s);return r&&N("pnCounters",s),r},getSet(s){return c.has(s)||c.set(s,M(t)),c.get(s)},addToSet(s,r){h.getSet(s).add(r),N("sets",s),f(s,"or-set","add")},removeFromSet(s,r){h.getSet(s).remove(r),N("sets",s),f(s,"or-set","remove")},hasSet(s){return c.has(s)},deleteSet(s){let r=c.delete(s);return r&&N("sets",s),r},merge(s){let r=s.getState();h.applyState(r)},getState(){V();let s={version:E,timestamp:Date.now(),nodeId:t,registers:{},gCounters:{},pnCounters:{},sets:{}};for(let[r,a]of o)s.registers[r]=a.getState();for(let[r,a]of T)s.gCounters[r]=a.getState();for(let[r,a]of u)s.pnCounters[r]=a.getState();for(let[r,a]of c)s.sets[r]=a.getState();return s},applyState(s){for(let[r,a]of Object.entries(s.registers))o.has(r)?o.get(r).applyState(a):o.set(r,X(t,a)),N("registers",r),f(r,"lww-register","merge");for(let[r,a]of Object.entries(s.gCounters))T.has(r)?T.get(r).applyState(a):T.set(r,w(t,a)),N("gCounters",r),f(r,"g-counter","merge");for(let[r,a]of Object.entries(s.pnCounters))u.has(r)?u.get(r).applyState(a):u.set(r,x(t,a)),N("pnCounters",r),f(r,"pn-counter","merge");for(let[r,a]of Object.entries(s.sets))c.has(r)?c.get(r).applyState(a):c.set(r,P(t,a)),N("sets",r),f(r,"or-set","merge");E=Math.max(E,s.version)+1},getDelta(s){if(V(),l.length===0)return s>=E,null;let r=l.filter(_=>_.toVersion>s);if(r.length===0)return null;let a={fromVersion:s,toVersion:E,timestamp:Date.now(),nodeId:t,registers:{},gCounters:{},pnCounters:{},sets:{}};for(let _ of r)_.registers&&Object.assign(a.registers,_.registers),_.gCounters&&Object.assign(a.gCounters,_.gCounters),_.pnCounters&&Object.assign(a.pnCounters,_.pnCounters),_.sets&&Object.assign(a.sets,_.sets);return Object.keys(a.registers).length===0&&delete a.registers,Object.keys(a.gCounters).length===0&&delete a.gCounters,Object.keys(a.pnCounters).length===0&&delete a.pnCounters,Object.keys(a.sets).length===0&&delete a.sets,a},applyDelta(s){if(s.registers)for(let[r,a]of Object.entries(s.registers))o.has(r)?o.get(r).applyState(a):o.set(r,X(t,a)),N("registers",r),f(r,"lww-register","merge");if(s.gCounters)for(let[r,a]of Object.entries(s.gCounters))T.has(r)?T.get(r).applyState(a):T.set(r,w(t,a)),N("gCounters",r),f(r,"g-counter","merge");if(s.pnCounters)for(let[r,a]of Object.entries(s.pnCounters))u.has(r)?u.get(r).applyState(a):u.set(r,x(t,a)),N("pnCounters",r),f(r,"pn-counter","merge");if(s.sets)for(let[r,a]of Object.entries(s.sets))c.has(r)?c.get(r).applyState(a):c.set(r,P(t,a)),N("sets",r),f(r,"or-set","merge");E=Math.max(E,s.toVersion)+1},getVersion(){return E},getNodeId(){return t},on(s,r){if(s==="change")return g.add(r),()=>{g.delete(r)};throw new Error(`Unknown event type: ${s}`)},removeAllListeners(){g.clear()},keys(s){let r=[];return(!s||s==="lww-register")&&r.push(...Array.from(o.keys())),(!s||s==="g-counter")&&r.push(...Array.from(T.keys())),(!s||s==="pn-counter")&&r.push(...Array.from(u.keys())),(!s||s==="or-set")&&r.push(...Array.from(c.keys())),r},clear(){o.clear(),T.clear(),u.clear(),c.clear(),l.length=0,p.registers.clear(),p.gCounters.clear(),p.pnCounters.clear(),p.sets.clear(),E=0},getStats(){return{total:o.size+T.size+u.size+c.size,registers:o.size,gCounters:T.size,pnCounters:u.size,sets:c.size,version:E,nodeId:t,deltaHistorySize:l.length}}};return h}var Pe,_e=R(()=>{"use strict";B();U();W();H();Pe={nodeId:"default-node",enableDeltaTracking:!0,maxDeltaHistory:100}});var fe=R(()=>{"use strict"});var Ne=R(()=>{"use strict";B();U();W();H();_e();fe()});var ze={};be(ze,{ALLOWED_TABLE_NAMES:()=>z,BinaryHeap:()=>te,DEFAULT_UNIFIED_MEMORY_CONFIG:()=>Le,UnifiedHnswIndex:()=>v,UnifiedMemoryManager:()=>A,clearProjectRootCache:()=>q,createHnswIndex:()=>ne,findProjectRoot:()=>b,getDefaultDbPath:()=>he,getResolvedDefaultConfig:()=>Ce,getUnifiedMemory:()=>Ie,initializeUnifiedMemory:()=>Ge,resetUnifiedMemory:()=>ke,validateTableName:()=>I});import*as m from"fs";import*as Re from"os";import*as S from"path";function he(){let i=b();return S.join(i,".agentic-qe","memory.db")}function Ce(){return{...Le,dbPath:he()}}function Ie(i){return A.getInstance(i)}async function Ge(i){let e=Ie(i);return await e.initialize(),e}function ke(){A.resetInstance()}function qe(){if(Se)return;Se=!0;let i=()=>{try{let e=A.instance;e&&e.close()}catch(e){console.debug("[UnifiedMemory] Cleanup error:",e instanceof Error?e.message:e)}};process.on("beforeExit",i),process.on("SIGINT",()=>{i(),process.exit(0)}),process.on("SIGTERM",()=>{i(),process.exit(0)})}var K,Le,A,Se,je=R(()=>{Xe();ee();ve();De();ye();j();j();re();re();me();Ne();Fe();K=J.create("unified-memory");Le={dbPath:".agentic-qe/memory.db",walMode:!0,mmapSize:O.MMAP_SIZE_BYTES,cacheSize:O.CACHE_SIZE_KB,busyTimeout:O.BUSY_TIMEOUT_MS,vectorDimensions:O.DEFAULT_VECTOR_DIMENSIONS};A=class i{static instance=null;static instancePromise=null;db=null;config;initialized=!1;vectorsLoaded=!1;initPromise=null;preparedStatements=new Map;vectorIndex=new v("qe-memory");crdtStore=null;constructor(e){let t=Ce();if(this.config={...t,...e},process.env.AQE_MEMORY_BACKEND==="memory"){this.config.dbPath=":memory:";return}if(!S.isAbsolute(this.config.dbPath)){let n=b();this.config.dbPath=S.join(n,this.config.dbPath)}}static getInstance(e){return i.instance||(i.instance=new i(e)),i.instance}static async getInstanceAsync(e){return i.instance?.initialized?i.instance:(i.instancePromise||(i.instancePromise=(async()=>{let t=i.getInstance(e);return await t.initialize(),t})()),i.instancePromise)}static resetInstance(){i.instance&&(i.instance.close(),i.instance=null),i.instancePromise=null,q()}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="",d=!1,o=0;if(!t){let T=process.env.AQE_PROJECT_ROOT;if(T){let u=S.resolve(this.config.dbPath),c=S.resolve(T);!u.startsWith(c)&&!u.startsWith(Re.tmpdir())&&u.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),m.existsSync(n)||m.mkdirSync(n,{recursive:!0}),d=m.existsSync(this.config.dbPath),d)o=m.statSync(this.config.dbPath).size;else if(m.existsSync(n)){let u=this.findRecentBackups(n);if(u.length>0){let c=u[0];console.error(`[UnifiedMemory] CRITICAL: Database file missing but directory exists!
599
+ `,Re=["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"]});function U(o,e,t){let n={value:e,timestamp:t??(e!==void 0?Date.now():0),nodeId:e!==void 0?o:"",version:e!==void 0?1:0,lastUpdated:Date.now()};function a(i,d,u,T){return i!==u?i-u:d.localeCompare(T)}return{get(){return n.value},set(i,d){let u=d??Date.now();(n.timestamp===0||a(u,o,n.timestamp,n.nodeId)>0)&&(n={value:i,timestamp:u,nodeId:o,version:n.version+1,lastUpdated:Date.now()})},merge(i){let d=i.getState();this.applyState(d)},getState(){return{value:n.value,timestamp:n.timestamp,nodeId:n.nodeId,version:n.version,lastUpdated:n.lastUpdated}},applyState(i){(n.timestamp===0||a(i.timestamp,i.nodeId,n.timestamp,n.nodeId)>0)&&(n={value:i.value,timestamp:i.timestamp,nodeId:i.nodeId,version:Math.max(n.version,i.version)+1,lastUpdated:Date.now()})},getNodeId(){return o},getTimestamp(){return n.timestamp}}}function x(o,e){let t=U(o);return t.applyState(e),t}var K=h(()=>{"use strict"});function C(o){let e={counts:{},version:0,lastUpdated:Date.now()};return e.counts[o]=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[o]=(e.counts[o]||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,i]of Object.entries(t.counts)){let d=e.counts[a]||0;i>d&&(e.counts[a]=i,n=!0)}n&&(e.version=Math.max(e.version,t.version)+1,e.lastUpdated=Date.now())},getNodeId(){return o},getLocalCount(){return e.counts[o]||0}}}function F(o,e){let t=C(o);return t.applyState(e),t}var M=h(()=>{"use strict"});function G(o){let e=C(o),t=C(o),n=0,a=Date.now();return{get(){return e.get()-t.get()},increment(i=1){if(i<0)throw new Error("Use decrement() for negative values");i!==0&&(e.increment(i),n++,a=Date.now())},decrement(i=1){if(i<0)throw new Error("Use increment() for negative values");i!==0&&(t.increment(i),n++,a=Date.now())},merge(i){let d=i.getState();this.applyState(d)},getState(){return{positive:e.getState(),negative:t.getState(),version:n,lastUpdated:a}},applyState(i){let d=this.get();e.applyState(i.positive),t.applyState(i.negative);let u=this.get();d!==u&&(n=Math.max(n,i.version)+1,a=Date.now())},getNodeId(){return o}}}function P(o,e){let t=G(o);return t.applyState(e),t}var V=h(()=>{"use strict";M()});function He(o,e){return`${o}:${Date.now()}:${e}`}function Q(o){return typeof o=="string"?`s:${o}`:typeof o=="number"?`n:${o}`:typeof o=="boolean"?`b:${o}`:`j:${JSON.stringify(o)}`}function Ye(o){let e=o.substring(0,2),t=o.substring(2);switch(e){case"s:":return t;case"n:":return Number(t);case"b:":return t==="true";case"j:":return L(t);default:throw new Error(`Unknown serialization type: ${e}`)}}function k(o){let e=new Map,t=new Map,n=0,a=Date.now(),i=0;function d(T){let E=e.get(T);if(!E||E.size===0)return!1;let p=t.get(T);if(!p||p.size===0)return!0;for(let g of E)if(!p.has(g))return!0;return!1}function u(T){let E=e.get(T);if(!E)return new Set;let p=t.get(T)||new Set,g=new Set;for(let l of E)p.has(l)||g.add(l);return g}return{has(T){let E=Q(T);return d(E)},values(){let T=[];for(let[E]of e)d(E)&&T.push(Ye(E));return T},size(){let T=0;for(let[E]of e)d(E)&&T++;return T},add(T){let E=Q(T),p=He(o,i++);e.has(E)||e.set(E,new Set),e.get(E).add(p),n++,a=Date.now()},remove(T){let E=Q(T),p=e.get(E);if(!p||p.size===0)return;t.has(E)||t.set(E,new Set);let g=t.get(E);for(let l of p)g.add(l);n++,a=Date.now()},merge(T){let E=T.getState();this.applyState(E)},getState(){let T={};for(let[p,g]of e)T[p]=Array.from(g);let E={};for(let[p,g]of t)g.size>0&&(E[p]=Array.from(g));return{elements:T,tombstones:E,version:n,lastUpdated:a}},applyState(T){let E=!1;for(let[p,g]of Object.entries(T.elements)){e.has(p)||e.set(p,new Set);let l=e.get(p);for(let f of g)l.has(f)||(l.add(f),E=!0)}for(let[p,g]of Object.entries(T.tombstones)){t.has(p)||t.set(p,new Set);let l=t.get(p);for(let f of g)l.has(f)||(l.add(f),E=!0)}E&&(n=Math.max(n,T.version)+1,a=Date.now())},getNodeId(){return o},clear(){for(let[T,E]of e){t.has(T)||t.set(T,new Set);let p=t.get(T);for(let g of E)p.add(g)}n++,a=Date.now()}}}function q(o,e){let t=k(o);return t.applyState(e),t}var J=h(()=>{"use strict";re()});function Z(o){let e={...$e,...o},{nodeId:t,enableDeltaTracking:n,maxDeltaHistory:a}=e,i=new Map,d=new Map,u=new Map,T=new Map,E=0,p=[],g=new Set,l={registers:new Set,gCounters:new Set,pnCounters:new Set,sets:new Set};function f(s,r,c){let _={key:s,type:r,operation:c,timestamp:Date.now(),nodeId:t};for(let we of g)try{we(_)}catch(Ue){console.error("[CRDTStore] Error in change listener:",Ue)}}function N(s,r){E++,n&&l[s].add(r)}function ee(){if(!n||!(l.registers.size>0||l.gCounters.size>0||l.pnCounters.size>0||l.sets.size>0))return;let r={fromVersion:p.length>0?p[p.length-1].toVersion:0,toVersion:E,timestamp:Date.now(),nodeId:t};if(l.registers.size>0){r.registers={};for(let c of l.registers){let _=i.get(c);_&&(r.registers[c]=_.getState())}l.registers.clear()}if(l.gCounters.size>0){r.gCounters={};for(let c of l.gCounters){let _=d.get(c);_&&(r.gCounters[c]=_.getState())}l.gCounters.clear()}if(l.pnCounters.size>0){r.pnCounters={};for(let c of l.pnCounters){let _=u.get(c);_&&(r.pnCounters[c]=_.getState())}l.pnCounters.clear()}if(l.sets.size>0){r.sets={};for(let c of l.sets){let _=T.get(c);_&&(r.sets[c]=_.getState())}l.sets.clear()}for(p.push(r);p.length>a;)p.shift()}let R={getRegister(s){return i.has(s)||i.set(s,U(t)),i.get(s)},setRegister(s,r){R.getRegister(s).set(r),N("registers",s),f(s,"lww-register","set")},hasRegister(s){return i.has(s)},deleteRegister(s){let r=i.delete(s);return r&&N("registers",s),r},getGCounter(s){return d.has(s)||d.set(s,C(t)),d.get(s)},incrementGCounter(s,r){R.getGCounter(s).increment(r),N("gCounters",s),f(s,"g-counter","increment")},hasGCounter(s){return d.has(s)},deleteGCounter(s){let r=d.delete(s);return r&&N("gCounters",s),r},getCounter(s){return u.has(s)||u.set(s,G(t)),u.get(s)},incrementCounter(s,r){R.getCounter(s).increment(r),N("pnCounters",s),f(s,"pn-counter","increment")},decrementCounter(s,r){R.getCounter(s).decrement(r),N("pnCounters",s),f(s,"pn-counter","decrement")},hasCounter(s){return u.has(s)},deleteCounter(s){let r=u.delete(s);return r&&N("pnCounters",s),r},getSet(s){return T.has(s)||T.set(s,k(t)),T.get(s)},addToSet(s,r){R.getSet(s).add(r),N("sets",s),f(s,"or-set","add")},removeFromSet(s,r){R.getSet(s).remove(r),N("sets",s),f(s,"or-set","remove")},hasSet(s){return T.has(s)},deleteSet(s){let r=T.delete(s);return r&&N("sets",s),r},merge(s){let r=s.getState();R.applyState(r)},getState(){ee();let s={version:E,timestamp:Date.now(),nodeId:t,registers:{},gCounters:{},pnCounters:{},sets:{}};for(let[r,c]of i)s.registers[r]=c.getState();for(let[r,c]of d)s.gCounters[r]=c.getState();for(let[r,c]of u)s.pnCounters[r]=c.getState();for(let[r,c]of T)s.sets[r]=c.getState();return s},applyState(s){for(let[r,c]of Object.entries(s.registers))i.has(r)?i.get(r).applyState(c):i.set(r,x(t,c)),N("registers",r),f(r,"lww-register","merge");for(let[r,c]of Object.entries(s.gCounters))d.has(r)?d.get(r).applyState(c):d.set(r,F(t,c)),N("gCounters",r),f(r,"g-counter","merge");for(let[r,c]of Object.entries(s.pnCounters))u.has(r)?u.get(r).applyState(c):u.set(r,P(t,c)),N("pnCounters",r),f(r,"pn-counter","merge");for(let[r,c]of Object.entries(s.sets))T.has(r)?T.get(r).applyState(c):T.set(r,q(t,c)),N("sets",r),f(r,"or-set","merge");E=Math.max(E,s.version)+1},getDelta(s){if(ee(),p.length===0)return s>=E,null;let r=p.filter(_=>_.toVersion>s);if(r.length===0)return null;let c={fromVersion:s,toVersion:E,timestamp:Date.now(),nodeId:t,registers:{},gCounters:{},pnCounters:{},sets:{}};for(let _ of r)_.registers&&Object.assign(c.registers,_.registers),_.gCounters&&Object.assign(c.gCounters,_.gCounters),_.pnCounters&&Object.assign(c.pnCounters,_.pnCounters),_.sets&&Object.assign(c.sets,_.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(s){if(s.registers)for(let[r,c]of Object.entries(s.registers))i.has(r)?i.get(r).applyState(c):i.set(r,x(t,c)),N("registers",r),f(r,"lww-register","merge");if(s.gCounters)for(let[r,c]of Object.entries(s.gCounters))d.has(r)?d.get(r).applyState(c):d.set(r,F(t,c)),N("gCounters",r),f(r,"g-counter","merge");if(s.pnCounters)for(let[r,c]of Object.entries(s.pnCounters))u.has(r)?u.get(r).applyState(c):u.set(r,P(t,c)),N("pnCounters",r),f(r,"pn-counter","merge");if(s.sets)for(let[r,c]of Object.entries(s.sets))T.has(r)?T.get(r).applyState(c):T.set(r,q(t,c)),N("sets",r),f(r,"or-set","merge");E=Math.max(E,s.toVersion)+1},getVersion(){return E},getNodeId(){return t},on(s,r){if(s==="change")return g.add(r),()=>{g.delete(r)};throw new Error(`Unknown event type: ${s}`)},removeAllListeners(){g.clear()},keys(s){let r=[];return(!s||s==="lww-register")&&r.push(...Array.from(i.keys())),(!s||s==="g-counter")&&r.push(...Array.from(d.keys())),(!s||s==="pn-counter")&&r.push(...Array.from(u.keys())),(!s||s==="or-set")&&r.push(...Array.from(T.keys())),r},clear(){i.clear(),d.clear(),u.clear(),T.clear(),p.length=0,l.registers.clear(),l.gCounters.clear(),l.pnCounters.clear(),l.sets.clear(),E=0},getStats(){return{total:i.size+d.size+u.size+T.size,registers:i.size,gCounters:d.size,pnCounters:u.size,sets:T.size,version:E,nodeId:t,deltaHistorySize:p.length}}};return R}var $e,Ce=h(()=>{"use strict";K();M();V();J();$e={nodeId:"default-node",enableDeltaTracking:!0,maxDeltaHistory:100}});var Ie=h(()=>{"use strict"});var Oe=h(()=>{"use strict";K();M();V();J();Ce();Ie()});var Je={};xe(Je,{ALLOWED_TABLE_NAMES:()=>H,BinaryHeap:()=>se,DEFAULT_UNIFIED_MEMORY_CONFIG:()=>ye,UnifiedHnswIndex:()=>X,UnifiedMemoryManager:()=>A,clearProjectRootCache:()=>B,createHnswIndex:()=>oe,findProjectRoot:()=>b,getDefaultDbPath:()=>be,getResolvedDefaultConfig:()=>De,getUnifiedMemory:()=>Xe,initializeUnifiedMemory:()=>Ke,resetUnifiedMemory:()=>Ve,validateTableName:()=>O});import*as m from"fs";import*as ve from"os";import*as S from"path";function be(){let o=b();return S.join(o,".agentic-qe","memory.db")}function De(){return{...ye,dbPath:be()}}function Xe(o){return A.getInstance(o)}async function Ke(o){let e=Xe(o);return await e.initialize(),e}function Ve(){A.resetInstance()}function Qe(){if(Ae)return;Ae=!0;let o=()=>{try{let e=A.instance;e&&e.close()}catch(e){console.debug("[UnifiedMemory] Cleanup error:",e instanceof Error?e.message:e)}};process.on("beforeExit",o),process.on("SIGINT",()=>{o(),process.exit(0)}),process.on("SIGTERM",()=>{o(),process.exit(0)})}var y,ye,A,Ae,Ze=h(()=>{Pe();re();Fe();Me();Ge();Ee();Y();Y();ie();ie();Le();Oe();ze();y=te.create("unified-memory");ye={dbPath:".agentic-qe/memory.db",walMode:!0,mmapSize:v.MMAP_SIZE_BYTES,cacheSize:v.CACHE_SIZE_KB,busyTimeout:v.BUSY_TIMEOUT_MS,vectorDimensions:v.DEFAULT_VECTOR_DIMENSIONS};A=class o{static instance=null;static instancePromise=null;db=null;config;initialized=!1;vectorsLoaded=!1;initPromise=null;preparedStatements=new Map;vectorIndex=new X("qe-memory");crdtStore=null;proofGate=null;proofGateEnvChecked=!1;static PROOF_NS="__proofgate__";static PROOF_KEY="chain";constructor(e){let t=De();if(this.config={...t,...e},process.env.AQE_MEMORY_BACKEND==="memory"){this.config.dbPath=":memory:";return}if(!S.isAbsolute(this.config.dbPath)){let n=b();this.config.dbPath=S.join(n,this.config.dbPath)}}static getInstance(e){return o.instance||(o.instance=new o(e)),o.instance}static async getInstanceAsync(e){return o.instance?.initialized?o.instance:(o.instancePromise||(o.instancePromise=(async()=>{let t=o.getInstance(e);return await t.initialize(),t})()),o.instancePromise)}static resetInstance(){o.instance&&(o.instance.close(),o.instance=null),o.instancePromise=null,B()}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,i=0;if(!t){let d=process.env.AQE_PROJECT_ROOT;if(d){let u=S.resolve(this.config.dbPath),T=S.resolve(d);!u.startsWith(T)&&!u.startsWith(ve.tmpdir())&&u.includes(".agentic-qe")&&(console.error(`[UnifiedMemory] WARNING: DB path "${this.config.dbPath}" points to a production .agentic-qe/ while AQE_PROJECT_ROOT="${d}". Redirecting to test-safe path.`),this.config.dbPath=S.join(d,".agentic-qe","memory.db"))}if(n=S.dirname(this.config.dbPath),m.existsSync(n)||m.mkdirSync(n,{recursive:!0}),a=m.existsSync(this.config.dbPath),a)i=m.statSync(this.config.dbPath).size;else if(m.existsSync(n)){let u=this.findRecentBackups(n);if(u.length>0){let T=u[0];console.error(`[UnifiedMemory] CRITICAL: Database file missing but directory exists!
555
600
  Expected: ${this.config.dbPath}
556
- Found ${u.length} backup(s), newest: ${c.path} (${(c.size/1024/1024).toFixed(1)}MB)
557
- Restoring from backup to prevent data loss...`),m.copyFileSync(c.path,this.config.dbPath);for(let E of["-wal","-shm"]){let l=this.config.dbPath+E;m.existsSync(l)&&m.unlinkSync(l)}o=c.size}}}if(e?.throwIfAborted(),this.db=Z(this.config.dbPath,{walMode:this.config.walMode,busyTimeout:this.config.busyTimeout}),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(),d&&o>1e6)try{let T=this.db.prepare("SELECT COUNT(*) as cnt FROM qe_patterns").get();if(T&&T.cnt===0){let u=m.statSync(this.config.dbPath).size;u<o*.1&&console.error(`[UnifiedMemory] CRITICAL: Possible data loss detected!
558
- DB was ${(o/1024/1024).toFixed(1)}MB, now ${(u/1024/1024).toFixed(1)}MB with 0 patterns.
601
+ Found ${u.length} backup(s), newest: ${T.path} (${(T.size/1024/1024).toFixed(1)}MB)
602
+ Restoring from backup to prevent data loss...`),m.copyFileSync(T.path,this.config.dbPath);for(let E of["-wal","-shm"]){let p=this.config.dbPath+E;m.existsSync(p)&&m.unlinkSync(p)}i=T.size}}}if(e?.throwIfAborted(),this.db=ne(this.config.dbPath,{walMode:this.config.walMode,busyTimeout:this.config.busyTimeout}),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&&i>1e6)try{let d=this.db.prepare("SELECT COUNT(*) as cnt FROM qe_patterns").get();if(d&&d.cnt===0){let u=m.statSync(this.config.dbPath).size;u<i*.1&&console.error(`[UnifiedMemory] CRITICAL: Possible data loss detected!
603
+ DB was ${(i/1024/1024).toFixed(1)}MB, now ${(u/1024/1024).toFixed(1)}MB with 0 patterns.
559
604
  This looks like the DB was replaced with an empty schema.
560
- 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: ${Q(t)}`)}}}findRecentBackups(e){try{let n=m.readdirSync(e).filter(o=>o.startsWith("memory")&&o.endsWith(".db")&&o!=="memory.db").map(o=>{let T=S.join(e,o),u=m.statSync(T);return{path:T,size:u.size,mtime:u.mtimeMs}}).filter(o=>o.size>1e6).sort((o,T)=>T.mtime-o.mtime),d=S.join(e,"backups");if(m.existsSync(d)){let o=m.readdirSync(d);for(let T of o)if(T.endsWith(".db")){let u=S.join(d,T),c=m.statSync(u);c.size>1e6&&n.push({path:u,size:c.size,mtime:c.mtimeMs})}n.sort((T,u)=>u.mtime-T.mtime)}return n}catch{return[]}}warnIfDuplicateDatabases(){if(this.config.dbPath!==":memory:")try{let e=b(),t=S.resolve(this.config.dbPath),d=[S.join(e,".agentic-qe","memory.db"),S.join(e,"v3",".agentic-qe","memory.db")].map(o=>S.resolve(o)).filter(o=>o!==t&&m.existsSync(o));d.length>0&&console.warn(`[UnifiedMemory] WARNING: Duplicate database(s) detected!
605
+ 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: ${D(t)}`)}}}findRecentBackups(e){try{let n=m.readdirSync(e).filter(i=>i.startsWith("memory")&&i.endsWith(".db")&&i!=="memory.db").map(i=>{let d=S.join(e,i),u=m.statSync(d);return{path:d,size:u.size,mtime:u.mtimeMs}}).filter(i=>i.size>1e6).sort((i,d)=>d.mtime-i.mtime),a=S.join(e,"backups");if(m.existsSync(a)){let i=m.readdirSync(a);for(let d of i)if(d.endsWith(".db")){let u=S.join(a,d),T=m.statSync(u);T.size>1e6&&n.push({path:u,size:T.size,mtime:T.mtimeMs})}n.sort((d,u)=>u.mtime-d.mtime)}return n}catch{return[]}}warnIfDuplicateDatabases(){if(this.config.dbPath!==":memory:")try{let e=b(),t=S.resolve(this.config.dbPath),a=[S.join(e,".agentic-qe","memory.db"),S.join(e,"v3",".agentic-qe","memory.db")].map(i=>S.resolve(i)).filter(i=>i!==t&&m.existsSync(i));a.length>0&&console.warn(`[UnifiedMemory] WARNING: Duplicate database(s) detected!
561
606
  Canonical: ${t}
562
- Duplicates: ${d.join(", ")}
563
- This can cause data splits. Remove duplicates or set AQE_PROJECT_ROOT.`)}catch(e){K.debug("Duplicate database check failed",{error:e instanceof Error?e.message:String(e)})}}columnExists(e,t){if(!this.db)return!1;try{let n=I(e);return this.db.prepare(`PRAGMA table_info(${n})`).all().some(o=>o.name===t)}catch(n){return K.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:d}of e)if(this.db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name=?").get(t)&&!this.columnExists(t,n)){let T=I(t);try{this.db.exec(`ALTER TABLE ${T} ADD COLUMN ${n} ${d}`),console.log(`[UnifiedMemory] Added column ${n} to ${t} (safe migration)`)}catch(u){console.log(`[UnifiedMemory] Column ${n} on ${t}: ${u instanceof Error?u.message:String(u)}`)}}}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<D&&(console.log(`[UnifiedMemory] Migrating from v${t} to v${D}`),this.db.transaction(()=>{t<1&&this.db.exec(ie),t<2&&this.db.exec(ae),t<3&&(this.db.exec(ce),this.db.exec(Te),this.db.exec(Ee)),t<4&&this.db.exec(de),t<5&&this.db.exec(ue),t<6&&this.db.exec(G),t<7&&this.db.exec(le),t<8&&this.db.exec(pe),t<9&&(this.db.exec(`
607
+ Duplicates: ${a.join(", ")}
608
+ 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=O(e);return this.db.prepare(`PRAGMA table_info(${n})`).all().some(i=>i.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 d=O(t);try{this.db.exec(`ALTER TABLE ${d} ADD COLUMN ${n} ${a}`),console.log(`[UnifiedMemory] Added column ${n} to ${t} (safe migration)`)}catch(u){console.log(`[UnifiedMemory] Column ${n} on ${t}: ${u instanceof Error?u.message:String(u)}`)}}}async runMigrations(){if(!this.db)throw new Error("Database not initialized");this.db.exec(pe),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(le),t<2&&this.db.exec(ge),t<3&&(this.db.exec(me),this.db.exec($),this.db.exec(_e)),t<4&&this.db.exec(fe),t<5&&this.db.exec(Ne),t<6&&this.db.exec(z),t<7&&this.db.exec(Se),t<8&&this.db.exec(he),t<9&&(this.db.exec(`
564
609
  CREATE VIRTUAL TABLE IF NOT EXISTS qe_patterns_fts USING fts5(
565
610
  name, description, pattern_type, qe_domain,
566
611
  content='qe_patterns',
@@ -586,26 +631,31 @@ import{d as G,f as we}from"./chunk-7FVWETN4.js";import{a as ye}from"./chunk-UNH2
586
631
  `),this.db.exec(`
587
632
  INSERT INTO qe_patterns_fts(rowid, name, description, pattern_type, qe_domain)
588
633
  SELECT rowid, name, description, pattern_type, qe_domain FROM qe_patterns;
589
- `)),t<10&&this.db.exec(k),this.db.prepare(`
634
+ `)),t<10&&this.db.exec(j),t<11&&this.migrateToV11GoapExecutionSteps(),this.db.prepare(`
590
635
  INSERT OR REPLACE INTO schema_version (id, version, migrated_at)
591
636
  VALUES (1, ?, datetime('now'))
592
- `).run(D)})(),console.log("[UnifiedMemory] Migration complete"))}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",d){this.ensureInitialized();let o=d?Date.now()+d*1e3:null,T=JSON.stringify(t);this.db.prepare(`
637
+ `).run(w)})(),console.log("[UnifiedMemory] Migration complete"))}migrateToV11GoapExecutionSteps(){let e=this.db;e.exec($);let t=(n,a,i)=>{e.prepare(`SELECT name FROM pragma_table_info('${n}')`).all().some(u=>u.name===a)||e.exec(`ALTER TABLE ${n} ADD COLUMN ${a} ${i}`)};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 i=a?Date.now()+a*1e3:null,d=JSON.stringify(t);this.db.prepare(`
593
638
  INSERT OR REPLACE INTO kv_store (key, namespace, value, expires_at)
594
639
  VALUES (?, ?, ?, ?)
595
- `).run(e,n,T,o)}async kvGet(e,t="default"){this.ensureInitialized();let n=this.db.prepare(`
640
+ `).run(e,n,d,i),this.auditWrite("kvSet",n,e,d)}async kvGet(e,t="default"){this.ensureInitialized();let n=this.db.prepare(`
596
641
  SELECT value, expires_at FROM kv_store
597
642
  WHERE key = ? AND namespace = ?
598
- `).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 L(n.value)}}async kvDelete(e,t="default"){return this.ensureInitialized(),this.db.prepare("DELETE FROM kv_store WHERE key = ? AND namespace = ?").run(e,t).changes>0}async kvExists(e,t="default"){return this.ensureInitialized(),this.db.prepare(`
643
+ `).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 L(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(`
599
644
  SELECT 1 FROM kv_store
600
645
  WHERE key = ? AND namespace = ? AND (expires_at IS NULL OR expires_at > ?)
601
- `).get(e,t,Date.now())!==void 0}async kvSearch(e,t="default",n=100){this.ensureInitialized();let d=e.replace(/\*/g,"%").replace(/\?/g,"_");return this.db.prepare(`
646
+ `).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(`
602
647
  SELECT key FROM kv_store
603
648
  WHERE namespace = ? AND key LIKE ?
604
649
  AND (expires_at IS NULL OR expires_at > ?)
605
650
  LIMIT ?
606
- `).all(t,d,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}async vectorStore(e,t,n="default",d){this.ensureInitialized();let o=this.floatArrayToBuffer(t),T=d?JSON.stringify(d):null;this.db.prepare(`
651
+ `).all(t,a,Date.now(),n).map(d=>d.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 I)}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 I}if(t!==o.PROOF_NS)try{this.proofGate.admit({op:e,ns:t,key:n,value:a}),this.persistProofChain()}catch(i){y.warn(`proof-gate audit skipped for ${t}/${n}: ${D(i)}`)}}persistProofChain(){!this.proofGate||!this.db||this.db.prepare(`
652
+ INSERT OR REPLACE INTO kv_store (key, namespace, value, expires_at)
653
+ VALUES (?, ?, ?, NULL)
654
+ `).run(o.PROOF_KEY,o.PROOF_NS,JSON.stringify(this.proofGate.toJSON()))}loadProofChain(){if(!this.db)return null;let e=this.db.prepare(`
655
+ SELECT value FROM kv_store WHERE key = ? AND namespace = ?
656
+ `).get(o.PROOF_KEY,o.PROOF_NS);if(!e)return null;try{return I.fromJSON(JSON.parse(e.value))}catch(t){return y.warn(`proof-gate chain failed to load (starting fresh): ${D(t)}`),null}}async vectorStore(e,t,n="default",a){this.ensureInitialized();let i=this.floatArrayToBuffer(t),d=a?JSON.stringify(a):null;this.db.prepare(`
607
657
  INSERT OR REPLACE INTO vectors (id, namespace, embedding, dimensions, metadata, updated_at)
608
658
  VALUES (?, ?, ?, ?, ?, datetime('now'))
609
- `).run(e,n,o,t.length,T),this.vectorIndex.add(e,t)}async vectorGet(e){this.ensureInitialized();let t=this.db.prepare(`
659
+ `).run(e,n,i,t.length,d),this.vectorIndex.add(e,t)}async vectorGet(e){this.ensureInitialized();let t=this.db.prepare(`
610
660
  SELECT embedding, dimensions, metadata FROM vectors WHERE id = ?
611
- `).get(e);if(t)return{embedding:this.bufferToFloatArray(t.embedding,t.dimensions),metadata:t.metadata?L(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){this.ensureInitialized(),this.vectorsLoaded||await this.loadVectorIndex();let d=this.vectorIndex.search(e,t*2);if(d.length===0)return[];let o=d.map(E=>E.id),T=o.map(()=>"?").join(","),u=this.db.prepare(`SELECT id, namespace, metadata FROM vectors WHERE id IN (${T})`).all(...o),c=new Map(u.map(E=>[E.id,E]));if(n){let E=[];for(let l of d){let g=c.get(l.id);if(g&&g.namespace===n&&(E.push({id:l.id,score:l.score,metadata:g.metadata?L(g.metadata):void 0}),E.length>=t))break}return E}return d.slice(0,t).map(E=>{let l=c.get(E.id);return{id:E.id,score:E.score,metadata:l?.metadata?L(l.metadata):void 0}})}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=I(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=$({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 d=0;d<t;d++)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=ge.map(d=>{try{let o=this.db.prepare(`SELECT COUNT(*) as count FROM ${d}`).get();return{name:d,rowCount:o.count}}catch(o){return K.debug("Table row count query failed",{table:d,error:o instanceof Error?o.message:String(o)}),{name:d,rowCount:0}}}),t=0,n=0;try{m.existsSync(this.config.dbPath)&&(t=m.statSync(this.config.dbPath).size);let d=this.config.dbPath+"-wal";m.existsSync(d)&&(n=m.statSync(d).size)}catch(d){console.debug("[UnifiedMemory] File stat error:",d instanceof Error?d.message:d)}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)}};Se=!1;qe()});export{z as a,I as b,Be as c,j as d,he as e,Le as f,Ce as g,A as h,Ie as i,Ge as j,ke as k,ze as l,je as m};
661
+ `).get(e);if(t)return{embedding:this.bufferToFloatArray(t.embedding,t.dimensions),metadata:t.metadata?L(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){this.ensureInitialized(),this.vectorsLoaded||await this.loadVectorIndex();let a=this.vectorIndex.search(e,t*2);if(a.length===0)return[];let i=a.map(E=>E.id),d=i.map(()=>"?").join(","),u=this.db.prepare(`SELECT id, namespace, metadata FROM vectors WHERE id IN (${d})`).all(...i),T=new Map(u.map(E=>[E.id,E]));if(n){let E=[];for(let p of a){let g=T.get(p.id);if(g&&g.namespace===n&&(E.push({id:p.id,score:p.score,metadata:g.metadata?L(g.metadata):void 0}),E.length>=t))break}return E}return a.slice(0,t).map(E=>{let p=T.get(E.id);return{id:E.id,score:E.score,metadata:p?.metadata?L(p.metadata):void 0}})}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=O(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=Z({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=Re.map(a=>{try{let i=this.db.prepare(`SELECT COUNT(*) as count FROM ${a}`).get();return{name:a,rowCount:i.count}}catch(i){return y.debug("Table row count query failed",{table:a,error:i instanceof Error?i.message:String(i)}),{name:a,rowCount:0}}}),t=0,n=0;try{m.existsSync(this.config.dbPath)&&(t=m.statSync(this.config.dbPath).size);let a=this.config.dbPath+"-wal";m.existsSync(a)&&(n=m.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)}};Ae=!1;Qe()});export{H as a,O as b,nt as c,Y as d,be as e,ye as f,De as g,A as h,Xe as i,Ke as j,Ve as k,Je as l,Ze as m};
@@ -1,3 +1,3 @@
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.11.3");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.11.5");process.exit(0)}
2
2
  import{readFileSync as R,existsSync as v,readdirSync as y}from"fs";import{join as S}from"path";var M=100*1024,b=/mcp__([a-z][a-z0-9-]*)__([a-z][a-z0-9_]*)/g,x=/^```/;function w(e,r){let n=e.length>M?e.slice(0,M):e,o=[],i=n.split(`
3
3
  `),a=!1;for(let s=0;s<i.length;s++){let p=i[s];if(x.test(p.trim())){a=!a;continue}let l,c=new RegExp(b.source,"g");for(;(l=c.exec(p))!==null;){let t=l[1],g=l[2],f=l[0],d=a?"code-block":"prose",u=d==="prose"?.9:.5;o.push({toolName:f,serverName:t,actionName:g,confidence:u,context:d,lineNumber:s+1})}}return o}function E(e){let r=new Map;for(let n of e)r.has(n.serverName)||r.set(n.serverName,[]),r.get(n.serverName).push(n);return r}function N(e){let r=[],n=[S(e,".claude","mcp.json"),S(e,".mcp.json")],o=process.env.HOME||process.env.USERPROFILE||"";o&&n.push(S(o,".claude","mcp.json"));for(let i of n)if(v(i))try{let a=R(i,"utf-8"),s=JSON.parse(a);s.mcpServers&&typeof s.mcpServers=="object"&&r.push(...Object.keys(s.mcpServers))}catch{}return[...new Set(r)]}function h(e,r,n){if(!v(e))return{agentName:r,references:[],requiredServers:[],availableServers:n,missingServers:[],warnings:[`Agent file not found: ${e}`],allSatisfied:!0};let o;try{o=R(e,"utf-8")}catch{return{agentName:r,references:[],requiredServers:[],availableServers:n,missingServers:[],warnings:[`Failed to read agent file: ${e}`],allSatisfied:!0}}let i=w(o,r),a=E(i),s=[...a.keys()],p=new Set(n),l=s.filter(t=>!p.has(t)),c=[];for(let t of l){let g=a.get(t)||[],f=Math.max(...g.map(m=>m.confidence)),d=g.length,u=[...new Set(g.map(m=>m.context))].join(", ");c.push(`[advisory] Agent "${r}" references MCP server "${t}" (${d} tool ref${d>1?"s":""}, confidence: ${f}, context: ${u}) but server is not configured. Agent may have reduced capabilities.`)}return{agentName:r,references:i,requiredServers:s,availableServers:n,missingServers:l,warnings:c,allSatisfied:l.length===0}}function C(e,r){let n=Date.now(),o=[],i=[],a=N(r);if(!v(e))return{agents:[],totalServersReferenced:0,globalMissingServers:[],agentsWithMissingDeps:[],warnings:[`Agents directory not found: ${e}`],durationMs:Date.now()-n};try{let c=y(e);for(let g of c){if(!g.endsWith(".md"))continue;let f=g.replace(".md",""),d=S(e,g),u=h(d,f,a);o.push(u),i.push(...u.warnings)}let t=S(e,"subagents");if(v(t)){let g=y(t);for(let f of g){if(!f.endsWith(".md"))continue;let d=f.replace(".md",""),u=S(t,f),m=h(u,d,a);o.push(m),i.push(...m.warnings)}}}catch(c){i.push(`Error scanning agents directory: ${c.message}`)}let s=new Set,p=new Set,l=[];for(let c of o){for(let t of c.requiredServers)s.add(t);for(let t of c.missingServers)p.add(t);c.missingServers.length>0&&l.push(c.agentName)}return{agents:o,totalServersReferenced:s.size,globalMissingServers:[...p],agentsWithMissingDeps:l,warnings:i,durationMs:Date.now()-n}}export{N as a,C as b};
@@ -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.11.3");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.11.5");process.exit(0)}
2
2
  function M(u){let e=u|0;return()=>{e=e+1831565813|0;let n=Math.imul(e^e>>>15,1|e);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}var A=2,y=10,x=200,p=1e-8,b=class{epsilon;seed;constructor(e){if(this.epsilon=e?.epsilon??.3,this.seed=e?.seed,this.epsilon<=0||this.epsilon>=1)throw new Error("SparsifierConfig.epsilon must be in (0, 1)")}sparsify(e){if(e.nodeCount<=0||e.edges.length===0)return{nodeCount:e.nodeCount,edges:[]};let n=this.seed!==void 0?M(this.seed):Math.random,t=this.approximateEffectiveResistances(e),i=e.nodeCount,r=e.edges.length,o=Math.max(1,Math.log(i)),m=this.epsilon*this.epsilon,l=Math.min(r,Math.max(i-1,A*(i-1)*(1-this.epsilon))),s=new Float64Array(r),c=0;for(let a=0;a<r;a++){let d=e.edges[a][2];s[a]=d*t[a],c+=s[a]}if(c<=0)return{nodeCount:e.nodeCount,edges:[]};let f=[];for(let a=0;a<r;a++){let[d,C,E]=e.edges[a],g=Math.min(1,s[a]/c*l);if(n()<g){let w=E/g;f.push([d,C,w])}}return{nodeCount:e.nodeCount,edges:f}}validateSpectral(e,n){let t=Math.min(y,Math.max(1,e.nodeCount-1)),i=this.computeLaplacian(e),r=this.computeLaplacian(n),o=this.computeTopEigenvalues(i,t),m=this.computeTopEigenvalues(r,t),l=[],s=!0,c=this.epsilon;for(let f=0;f<o.length;f++){if(o[f]<1e-10)continue;let a=m[f]/o[f];l.push(a),(a<1-c||a>1+c)&&(s=!1)}return{isValid:s,eigenvalueRatios:l,originalEdgeCount:e.edges.length,sparsifiedEdgeCount:n.edges.length,compressionRatio:e.edges.length>0?n.edges.length/e.edges.length:0}}computeLaplacian(e){let n=e.nodeCount,t=Array.from({length:n},()=>new Array(n).fill(0));for(let[i,r,o]of e.edges)i<0||i>=n||r<0||r>=n||(t[i][i]+=o,t[r][r]+=o,t[i][r]-=o,t[r][i]-=o);return t}computeTopEigenvalues(e,n){let t=e.length;if(t===0)return[];let i=[],r=[],o=e.map(m=>[...m]);for(let m=0;m<Math.min(n,t);m++){let l=this.powerIteration(o,t,r);if(l===null)break;i.push(l.eigenvalue),r.push(l.eigenvector),V(o,l.eigenvalue,l.eigenvector)}return i}approximateEffectiveResistances(e){let n=e.nodeCount,t=new Float64Array(n);for(let[r,o,m]of e.edges)r>=0&&r<n&&(t[r]+=m),o>=0&&o<n&&(t[o]+=m);let i=new Array(e.edges.length);for(let r=0;r<e.edges.length;r++){let[o,m]=e.edges[r],l=t[o]||1,s=t[m]||1;i[r]=1/l+1/s}return i}powerIteration(e,n,t){let i=0;for(let s=0;s<n;s++)for(let c=0;c<n;c++)i+=e[s][c]*e[s][c];if(i<p*p)return null;let r=t.length,o=new Array(n);for(let s=0;s<n;s++)o[s]=Math.sin((s+1)*(r+1)*1.618033988749895)+.1*(s-n/2);for(let s of t)h(o,s);if(R(o)<p)return null;let l=0;for(let s=0;s<x;s++){let c=L(e,o);for(let d of t)h(c,d);let f=S(c,o),a=v(c);if(a<p)return{eigenvalue:0,eigenvector:o};for(let d=0;d<n;d++)o[d]=c[d]/a;if(Math.abs(f-l)<p){l=f;break}l=f}return{eigenvalue:Math.abs(l),eigenvector:o}}};function L(u,e){let n=u.length,t=new Array(n).fill(0);for(let i=0;i<n;i++){let r=0;for(let o=0;o<n;o++)r+=u[i][o]*e[o];t[i]=r}return t}function v(u){let e=0;for(let n=0;n<u.length;n++)e+=u[n]*u[n];return Math.sqrt(e)}function R(u){let e=v(u);if(e>0)for(let n=0;n<u.length;n++)u[n]/=e;return e}function S(u,e){let n=0;for(let t=0;t<u.length;t++)n+=u[t]*e[t];return n}function h(u,e){let n=S(u,e);for(let t=0;t<u.length;t++)u[t]-=n*e[t]}function V(u,e,n){let t=n.length;for(let i=0;i<t;i++)for(let r=0;r<t;r++)u[i][r]-=e*n[i]*n[r]}export{b as a};
@@ -1,3 +1,3 @@
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.11.3");process.exit(0)}
2
- import{a as C,f as x}from"./chunk-MX5FMAY5.js";import{a as h}from"./chunk-26KHL4VO.js";var d={mechanical:["convert var to const","add types","remove console","convert to async","convert to esm","arrow function","rename variable","format code"],simple:["fix typo","update comment","fix simple bug","add documentation","format","rename","simple refactor","basic test"],moderate:["implement feature","implement","refactor","complex refactor","performance optimization","optimize","test generation","generate test","error handling","validation logic","api integration","code index","coverage analysis","quality assessment","defect prediction","predict defect","analyze coverage","analyze","assess","scan","detect"],complex:["multi-file refactor","orchestrate","coordinate","large codebase","migration","cross-domain","workflow","system design","analyze security","security scan","security analysis","vulnerability scan","chaos test","resilience test","contract validation"],critical:["architecture","security audit","critical bug","algorithm design","system-wide","vulnerability","cryptography","performance critical","hardcoded secret","cve","owasp","penetration test","exploit"]},f={architecture:/\b(architect|design|system design|overall structure|component design)\b/i,security:/\b(security|vulnerability|audit|xss|sql injection|csrf|encryption|auth|authentication|authorization)\b/i,multiStep:/\b(orchestrate|coordinate|workflow|pipeline|multi[- ]step)\b/i,crossDomain:/\b(cross[- ]domain|across (domains|modules)|integrate|coordination)\b/i},m=class{config;agentBoosterAdapter;constructor(e,t){this.config=e,this.agentBoosterAdapter=t}async collectSignals(e){let t=e.task.toLowerCase(),r=await this.checkAgentBoosterEligibility(e),o={simple:this.findKeywordMatches(t,d.simple),moderate:this.findKeywordMatches(t,d.moderate),complex:this.findKeywordMatches(t,d.complex),critical:this.findKeywordMatches(t,d.critical)},c=e.codeContext?e.codeContext.split(`
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.11.5");process.exit(0)}
2
+ import{a as h}from"./chunk-TEIWJ3GJ.js";import{a as C,f as x}from"./chunk-3LY7OCSO.js";var d={mechanical:["convert var to const","add types","remove console","convert to async","convert to esm","arrow function","rename variable","format code"],simple:["fix typo","update comment","fix simple bug","add documentation","format","rename","simple refactor","basic test"],moderate:["implement feature","implement","refactor","complex refactor","performance optimization","optimize","test generation","generate test","error handling","validation logic","api integration","code index","coverage analysis","quality assessment","defect prediction","predict defect","analyze coverage","analyze","assess","scan","detect"],complex:["multi-file refactor","orchestrate","coordinate","large codebase","migration","cross-domain","workflow","system design","analyze security","security scan","security analysis","vulnerability scan","chaos test","resilience test","contract validation"],critical:["architecture","security audit","critical bug","algorithm design","system-wide","vulnerability","cryptography","performance critical","hardcoded secret","cve","owasp","penetration test","exploit"]},f={architecture:/\b(architect|design|system design|overall structure|component design)\b/i,security:/\b(security|vulnerability|audit|xss|sql injection|csrf|encryption|auth|authentication|authorization)\b/i,multiStep:/\b(orchestrate|coordinate|workflow|pipeline|multi[- ]step)\b/i,crossDomain:/\b(cross[- ]domain|across (domains|modules)|integrate|coordination)\b/i},m=class{config;agentBoosterAdapter;constructor(e,t){this.config=e,this.agentBoosterAdapter=t}async collectSignals(e){let t=e.task.toLowerCase(),r=await this.checkAgentBoosterEligibility(e),o={simple:this.findKeywordMatches(t,d.simple),moderate:this.findKeywordMatches(t,d.moderate),complex:this.findKeywordMatches(t,d.complex),critical:this.findKeywordMatches(t,d.critical)},c=e.codeContext?e.codeContext.split(`
3
3
  `).length:void 0,n=e.filePaths?e.filePaths.length:void 0,i=f.architecture.test(t),a=f.security.test(t),l=f.multiStep.test(t),g=f.crossDomain.test(t),b=this.detectCreativityRequirement(t),S=this.estimateLanguageComplexity(e.codeContext,e.filePaths),T=e.codeContext?this.estimateCyclomaticComplexity(e.codeContext):void 0;return{linesOfCode:c,fileCount:n,hasArchitectureScope:i,hasSecurityScope:a,requiresMultiStepReasoning:l,requiresCrossDomainCoordination:g,isMechanicalTransform:r.eligible,languageComplexity:S,cyclomaticComplexity:T,dependencyCount:this.countDependencies(e.codeContext),requiresCreativity:b,detectedTransformType:r.transformType,keywordMatches:o}}async checkAgentBoosterEligibility(e){if(!this.config.enableAgentBooster)return{eligible:!1,confidence:0,reason:"Agent Booster is disabled"};let t=e.task.toLowerCase(),r,o=0;for(let n of h){let i=this.getTransformKeywords(n),a=0;for(let l of i)t.includes(l.toLowerCase())&&(a=a===0?.5:a+.25);for(let l of d.mechanical)t.includes(l.toLowerCase())&&(a=Math.max(a,.6));a>o&&(o=a,r=n)}if(e.codeContext&&r&&this.agentBoosterAdapter)try{let i=(await this.agentBoosterAdapter.detectTransformOpportunities(e.codeContext)).opportunities.find(a=>a.type===r);if(i)return{eligible:i.confidence>=this.config.agentBoosterThreshold,transformType:r,confidence:i.confidence,reason:i.reason}}catch(n){console.debug("[SignalCollector] WASM analysis error:",n instanceof Error?n.message:n)}let c=o>=this.config.agentBoosterThreshold&&r!==void 0;return{eligible:c,transformType:r,confidence:Math.min(o,1),reason:c?`Detected ${r} transform pattern`:"No mechanical transform pattern detected"}}findKeywordMatches(e,t){let r=[];for(let o of t)e.includes(o.toLowerCase())&&r.push(o);return r}detectCreativityRequirement(e){return e.includes("design")||e.includes("creative")||e.includes("innovative")||e.includes("novel")}estimateLanguageComplexity(e,t){if(!e&&(!t||t.length===0))return;let r=[".ts",".tsx",".rs",".cpp",".c",".go"],o=[".js",".jsx",".py",".java"],c=[".json",".yaml",".md",".txt",".css",".html"];if(t){for(let n of t)if(r.some(i=>n.endsWith(i)))return"high";for(let n of t)if(o.some(i=>n.endsWith(i)))return"medium";for(let n of t)if(c.some(i=>n.endsWith(i)))return"low"}if(e){let n=/<[A-Z][^>]*>/.test(e),i=/\b(async|await)\b/.test(e),a=/\b(interface|type|class)\b/.test(e);return n&&a?"high":i||a?"medium":"low"}return"medium"}estimateCyclomaticComplexity(e){let t=[/\bif\b/g,/\bfor\b/g,/\bwhile\b/g,/\bcase\b/g,/\bcatch\b/g,/&&/g,/\|\|/g,/\?/g],r=1;for(let o of t){let c=e.match(o);c&&(r+=c.length)}return r}countDependencies(e){if(!e)return;let t=e.match(/\b(import|require|from)\b.*['"].*['"]/g);return t?t.length:0}getTransformKeywords(e){return{"var-to-const":["var to const","convert var","var declaration","var to let","convert var to const","change var to const"],"add-types":["add types","add type","typescript types","type annotations","type annotation","add type annotations"],"remove-console":["remove console","delete console","console.log","remove console.log","strip console"],"promise-to-async":["promise to async","async await",".then to async","convert to async","convert function to async"],"cjs-to-esm":["commonjs to esm","require to import","convert to esm","cjs to esm","module conversion"],"func-to-arrow":["arrow function","function to arrow","convert to arrow","convert function to arrow"]}[e]||[]}};function v(s,e){return new m(s,e)}var u=class{calculateCodeComplexity(e){let t=0;return t+=this.calculateLinesOfCodeContribution(e.linesOfCode),t+=this.calculateFileCountContribution(e.fileCount),t+=this.calculateCyclomaticContribution(e.cyclomaticComplexity),t+=this.calculateLanguageContribution(e.languageComplexity),Math.min(t,100)}calculateReasoningComplexity(e){let t=0;return t+=this.calculateKeywordScore(e.keywordMatches),e.requiresMultiStepReasoning&&(t+=20),e.requiresCreativity&&(t+=20),Math.min(t,100)}calculateScopeComplexity(e){let t=0;return e.hasArchitectureScope&&(t+=40),e.hasSecurityScope&&(t+=30),e.requiresCrossDomainCoordination&&(t+=20),t+=this.calculateDependencyContribution(e.dependencyCount),Math.min(t,100)}calculateOverallComplexity(e,t,r,o){if(o.isMechanicalTransform&&!o.hasSecurityScope&&!o.hasArchitectureScope&&!o.requiresMultiStepReasoning&&!o.requiresCrossDomainCoordination&&e===0&&t===0&&r===0)return 5;let c=e*.3+t*.4+r*.3,n=0;return o.hasSecurityScope&&(n=Math.max(n,50)),o.hasArchitectureScope&&(n=Math.max(n,55)),o.requiresCrossDomainCoordination&&(n=Math.max(n,35)),o.requiresMultiStepReasoning&&(n=Math.max(n,30)),o.keywordMatches.simple.length+o.keywordMatches.moderate.length+o.keywordMatches.complex.length+o.keywordMatches.critical.length===0&&!o.isMechanicalTransform&&c<15&&(n=Math.max(n,15)),Math.min(Math.max(Math.round(c),n),100)}calculateConfidence(e,t){let r=.5;return t.codeContext&&(r+=.2),t.filePaths&&t.filePaths.length>0&&(r+=.1),r+=this.calculateKeywordConfidenceBoost(e.keywordMatches),e.isMechanicalTransform&&(r+=.15),Math.min(r,1)}calculateLinesOfCodeContribution(e){return e===void 0||e<10?0:e<50?10:e<200?20:30}calculateFileCountContribution(e){return e===void 0||e===1?0:e<5?10:20}calculateCyclomaticContribution(e){return e===void 0||e<5?0:e<10?10:e<20?20:30}calculateLanguageContribution(e){return e==="low"?0:e==="medium"?10:e==="high"?20:0}calculateKeywordScore(e){let t=e.simple.length*5+e.moderate.length*15+e.complex.length*25+e.critical.length*35;return Math.min(t,60)}calculateDependencyContribution(e){return e===void 0||e<3?0:e<10?5:10}calculateKeywordConfidenceBoost(e){let t=e.simple.length+e.moderate.length+e.complex.length+e.critical.length;return t>=3?.1:t>=1?.05:0}};function M(){return new u}var p=class{getRecommendedTier(e){for(let t of[0,1,2,3,4]){let[r,o]=C[t].complexityRange;if(e>=r&&e<=o)return t}return 2}findAlternateTiers(e,t){let r=[];return t>0&&r.push(t-1),t<4&&r.push(t+1),t<3&&!r.includes(4)&&r.push(4),r}generateExplanation(e,t,r){let o=[];return o.push(`Complexity score: ${e}/100 (Tier ${t})`),r.isMechanicalTransform&&o.push(this.formatMechanicalTransformInfo(r.detectedTransformType)),o.push(...this.formatScopeExplanations(r)),o.push(...this.formatCodeMetricsExplanations(r)),o.join(". ")}formatMechanicalTransformInfo(e){return`Detected mechanical transform: ${e}`}formatScopeExplanations(e){let t=[];return e.hasArchitectureScope&&t.push("Architecture scope detected"),e.hasSecurityScope&&t.push("Security scope detected"),e.requiresMultiStepReasoning&&t.push("Multi-step reasoning required"),e.requiresCrossDomainCoordination&&t.push("Cross-domain coordination required"),t}formatCodeMetricsExplanations(e){let t=[];return e.linesOfCode!==void 0&&e.linesOfCode>100&&t.push(`Large code change: ${e.linesOfCode} lines`),e.fileCount!==void 0&&e.fileCount>3&&t.push(`Multi-file change: ${e.fileCount} files`),t}};function w(){return new p}var y=class{config;signalCollector;scoreCalculator;tierRecommender;constructor(e,t,r,o){this.config=e,this.signalCollector=t,this.scoreCalculator=r,this.tierRecommender=o}async analyze(e){try{let t=await this.signalCollector.collectSignals(e),r=this.scoreCalculator.calculateCodeComplexity(t),o=this.scoreCalculator.calculateReasoningComplexity(t),c=this.scoreCalculator.calculateScopeComplexity(t),n=this.scoreCalculator.calculateOverallComplexity(r,o,c,t),i=this.tierRecommender.getRecommendedTier(n),a=this.tierRecommender.findAlternateTiers(n,i),l=this.scoreCalculator.calculateConfidence(t,e),g=this.tierRecommender.generateExplanation(n,i,t);return{overall:n,codeComplexity:r,reasoningComplexity:o,scopeComplexity:c,confidence:l,signals:t,recommendedTier:i,alternateTiers:a,explanation:g}}catch(t){throw new x(`Failed to analyze task complexity: ${t instanceof Error?t.message:"Unknown error"}`,t instanceof Error?t:void 0)}}async checkAgentBoosterEligibility(e){return this.signalCollector.checkAgentBoosterEligibility(e)}getRecommendedTier(e){return this.tierRecommender.getRecommendedTier(e)}};function L(s,e){let t=new m(s,e),r=new u,o=new p;return new y(s,t,r,o)}function z(s,e,t,r){return new y(s,e,t,r)}export{m as a,v as b,u as c,M as d,p as e,w as f,y as g,L as h,z as i};
@@ -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.11.3");process.exit(0)}
2
- import{b as l,c}from"./chunk-UTGW75AZ.js";import{i}from"./chunk-UFZCHVLH.js";c();var u=.15,d=.03,p=.25,s=class{constructor(t){this.db=t;l(t)}db;recordNull(t){this.db.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.11.5");process.exit(0)}
2
+ import{b as l,c}from"./chunk-TTJJ4DQE.js";import{i}from"./chunk-K4I7UIU5.js";c();var u=.15,d=.03,p=.25,s=class{constructor(t){this.db=t;l(t)}db;recordNull(t){this.db.prepare(`
3
3
  INSERT INTO qe_pattern_nulls (id, pattern_id, context_fingerprint, failure_mode, trajectory_ref, evidence_class)
4
4
  VALUES (?, ?, ?, ?, ?, ?)
5
5
  ON CONFLICT(pattern_id, context_fingerprint) DO UPDATE SET
@@ -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.11.3");process.exit(0)}
2
- import{c as t,e as o}from"./chunk-PUK5NE47.js";var g={};o(g,{DotProductAttention:()=>u,FlashAttention:()=>m,HyperbolicAttention:()=>h,LinearAttention:()=>f,MoEAttention:()=>_,MultiHeadAttention:()=>A,RuvectorLayer:()=>a,SonaEngine:()=>b,TensorCompress:()=>c,default:()=>r,differentiableSearch:()=>l,getCompressionLevel:()=>p,hierarchicalForward:()=>s,init:()=>d,pipeline:()=>L});import{createRequire as n}from"module";var i,e,r,a,c,l,s,p,d,m,u,A,h,f,_,b,L,q=t(()=>{i=n(import.meta.url),e=i("hnswlib-node"),r=e,{RuvectorLayer:a,TensorCompress:c,differentiableSearch:l,hierarchicalForward:s,getCompressionLevel:p,init:d,FlashAttention:m,DotProductAttention:u,MultiHeadAttention:A,HyperbolicAttention:h,LinearAttention:f,MoEAttention:_,SonaEngine:b,pipeline:L}=e||{}});export{r as a,a as b,c,l as d,s as e,p as f,d as g,m as h,u as i,A as j,h as k,f as l,_ as m,b as n,L as o,g as p,q};
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.11.5");process.exit(0)}
2
+ import{c as t,e as o}from"./chunk-C4EZNOWK.js";var g={};o(g,{DotProductAttention:()=>u,FlashAttention:()=>m,HyperbolicAttention:()=>h,LinearAttention:()=>f,MoEAttention:()=>_,MultiHeadAttention:()=>A,RuvectorLayer:()=>a,SonaEngine:()=>b,TensorCompress:()=>c,default:()=>r,differentiableSearch:()=>l,getCompressionLevel:()=>p,hierarchicalForward:()=>s,init:()=>d,pipeline:()=>L});import{createRequire as n}from"module";var i,e,r,a,c,l,s,p,d,m,u,A,h,f,_,b,L,q=t(()=>{i=n(import.meta.url),e=i("hnswlib-node"),r=e,{RuvectorLayer:a,TensorCompress:c,differentiableSearch:l,hierarchicalForward:s,getCompressionLevel:p,init:d,FlashAttention:m,DotProductAttention:u,MultiHeadAttention:A,HyperbolicAttention:h,LinearAttention:f,MoEAttention:_,SonaEngine:b,pipeline:L}=e||{}});export{r as a,a as b,c,l as d,s as e,p as f,d as g,m as h,u as i,A as j,h as k,f as l,_ as m,b as n,L as o,g as p,q};
@@ -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.11.3");process.exit(0)}
2
- import{b as y,d as p}from"./chunk-H6YFMUFG.js";import{i as h}from"./chunk-UFZCHVLH.js";var f={healthyThreshold:3,warningThreshold:2,checkIntervalMs:5e3,maxHistoryEntries:100,alertsEnabled:!0,alertCooldownMs:6e4,selfHealingEnabled:!1,maxHealingActionsPerMinute:5};var g=class{calculator;config;eventBus;persistence;graph;history=[];alerts=new Map;lastAlertTime=new Map;monitoringInterval=null;isMonitoring=!1;constructor(e,t={},r,i){this.graph=e,this.config={...f,...t},this.calculator=p(),this.eventBus=r,this.persistence=i}start(){this.isMonitoring||(this.isMonitoring=!0,this.monitoringInterval=setInterval(()=>this.checkHealth(),this.config.checkIntervalMs),this.checkHealth())}stop(){this.monitoringInterval&&(clearInterval(this.monitoringInterval),this.monitoringInterval=null),this.isMonitoring=!1}updateGraph(e){this.graph=e,this.isMonitoring&&this.checkHealth()}isEmptyTopology(){return this.graph.getVerticesByType("agent").length===0}checkHealth(){let e=this.calculator.getMinCutValue(this.graph),t=this.calculator.findWeakVertices(this.graph),r=this.isEmptyTopology()?"idle":this.determineStatus(e),i=this.calculateTrend();return this.recordHistory(e),this.isEmptyTopology()||this.checkAlertConditions(e,t,r),this.persistence&&t.length>0&&this.persistence.saveWeakVertices(t).catch(n=>console.warn("[MinCutHealthMonitor] Failed to persist weak vertices:",n)),this.emitEvent("mincut.updated",e,{status:r,weakVertexCount:t.length}),{status:r,minCutValue:e,healthyThreshold:this.config.healthyThreshold,warningThreshold:this.config.warningThreshold,weakVertexCount:t.length,topWeakVertices:t.slice(0,5),trend:i,history:this.history.slice(-20),lastUpdated:new Date}}getHealth(){let e=this.calculator.getMinCutValue(this.graph),t=this.calculator.findWeakVertices(this.graph);return{status:this.isEmptyTopology()?"idle":this.determineStatus(e),minCutValue:e,healthyThreshold:this.config.healthyThreshold,warningThreshold:this.config.warningThreshold,weakVertexCount:t.length,topWeakVertices:t.slice(0,5),trend:this.calculateTrend(),history:this.history.slice(-20),lastUpdated:new Date}}getMinCutValue(){return this.calculator.getMinCutValue(this.graph)}getWeakVertices(){return this.calculator.findWeakVertices(this.graph)}isCritical(){return this.calculator.getMinCutValue(this.graph)<this.config.warningThreshold}isHealthy(){return this.calculator.getMinCutValue(this.graph)>=this.config.healthyThreshold}getActiveAlerts(){return Array.from(this.alerts.values()).filter(e=>!e.acknowledged).sort((e,t)=>{let r={critical:0,high:1,medium:2,low:3,info:4};return r[e.severity]-r[t.severity]})}getAllAlerts(){return Array.from(this.alerts.values())}acknowledgeAlert(e){let t=this.alerts.get(e);return t?(t.acknowledged=!0,!0):!1}clearAcknowledgedAlerts(){let e=[];for(let[t,r]of this.alerts)r.acknowledged&&e.push(t);for(let t of e)this.alerts.delete(t);return e.length}getHistory(){return[...this.history]}getTrend(){return this.calculateTrend()}getStats(e=6e4){let t=Date.now()-e,r=this.history.filter(n=>n.timestamp.getTime()>t);if(r.length===0){let n=this.calculator.getMinCutValue(this.graph);return{min:n,max:n,average:n,count:0}}let i=r.map(n=>n.value);return{min:Math.min(...i),max:Math.max(...i),average:i.reduce((n,a)=>n+a,0)/i.length,count:r.length}}updateConfig(e){Object.assign(this.config,e),e.checkIntervalMs&&this.isMonitoring&&(this.stop(),this.start())}getConfig(){return{...this.config}}determineStatus(e){return e>=this.config.healthyThreshold?"healthy":e>=this.config.warningThreshold?"warning":"critical"}calculateTrend(){if(this.history.length<3)return"stable";let e=this.history.slice(-5),t=e[0].value,i=e[e.length-1].value-t,a=e.reduce((o,c)=>o+c.value,0)/e.length*.1;return i>a?"improving":i<-a?"degrading":"stable"}recordHistory(e){let t={timestamp:new Date,value:e,vertexCount:this.graph.vertexCount,edgeCount:this.graph.edgeCount};for(this.history.push(t);this.history.length>this.config.maxHistoryEntries;)this.history.shift()}checkAlertConditions(e,t,r){if(!this.config.alertsEnabled)return;let i=Date.now();r==="critical"?this.maybeGenerateAlert("critical-threshold","critical",`MinCut value (${e.toFixed(2)}) is below critical threshold (${this.config.warningThreshold})`,e,this.config.warningThreshold,t):r==="warning"&&this.maybeGenerateAlert("warning-threshold","high",`MinCut value (${e.toFixed(2)}) is below healthy threshold (${this.config.healthyThreshold})`,e,this.config.healthyThreshold,t);let n=t.filter(o=>o.weightedDegree===0);n.length>0&&this.maybeGenerateAlert("isolated-vertices","high",`${n.length} isolated vertex(es) detected`,e,0,n);let a=t.filter(o=>o.riskScore>.8);a.length>0&&this.maybeGenerateAlert("critical-vertices","medium",`${a.length} critical vertex(es) with high risk score`,e,0,a)}maybeGenerateAlert(e,t,r,i,n,a){let o=Date.now(),c=this.lastAlertTime.get(e)||0;if(o-c<this.config.alertCooldownMs)return;let s={id:h(),severity:t,message:r,minCutValue:i,threshold:n,affectedVertices:a.map(l=>l.vertexId),timestamp:new Date,acknowledged:!1,remediations:a.flatMap(l=>l.suggestions).slice(0,5)};this.alerts.set(s.id,s),this.persistence&&this.persistence.saveAlert(s).catch(l=>console.warn("[MinCutHealthMonitor] Failed to persist alert:",l)),this.lastAlertTime.set(e,o),this.emitEvent("mincut.alert.generated",i,{alert:s})}emitEvent(e,t,r){if(!this.eventBus)return;let i={id:h(),type:e,source:"coordination",timestamp:new Date,correlationId:h(),payload:{minCutValue:t,...r}};this.eventBus.publish(i).catch(n=>{console.error("Failed to publish MinCut event:",n)})}};function v(m,e,t,r){return new g(m,e,t,r)}var d=null,u=null;function C(){return d||(d=y()),d}function P(){return u||(u=v(C())),u}function B(){return d!==null}function F(){return u!==null}export{f as a,v as b,C as c,P as d,B as e,F as f};
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.11.5");process.exit(0)}
2
+ import{b as y,d as p}from"./chunk-UBI2EOS3.js";import{i as h}from"./chunk-K4I7UIU5.js";var f={healthyThreshold:3,warningThreshold:2,checkIntervalMs:5e3,maxHistoryEntries:100,alertsEnabled:!0,alertCooldownMs:6e4,selfHealingEnabled:!1,maxHealingActionsPerMinute:5};var g=class{calculator;config;eventBus;persistence;graph;history=[];alerts=new Map;lastAlertTime=new Map;monitoringInterval=null;isMonitoring=!1;constructor(e,t={},r,i){this.graph=e,this.config={...f,...t},this.calculator=p(),this.eventBus=r,this.persistence=i}start(){this.isMonitoring||(this.isMonitoring=!0,this.monitoringInterval=setInterval(()=>this.checkHealth(),this.config.checkIntervalMs),this.checkHealth())}stop(){this.monitoringInterval&&(clearInterval(this.monitoringInterval),this.monitoringInterval=null),this.isMonitoring=!1}updateGraph(e){this.graph=e,this.isMonitoring&&this.checkHealth()}isEmptyTopology(){return this.graph.getVerticesByType("agent").length===0}checkHealth(){let e=this.calculator.getMinCutValue(this.graph),t=this.calculator.findWeakVertices(this.graph),r=this.isEmptyTopology()?"idle":this.determineStatus(e),i=this.calculateTrend();return this.recordHistory(e),this.isEmptyTopology()||this.checkAlertConditions(e,t,r),this.persistence&&t.length>0&&this.persistence.saveWeakVertices(t).catch(n=>console.warn("[MinCutHealthMonitor] Failed to persist weak vertices:",n)),this.emitEvent("mincut.updated",e,{status:r,weakVertexCount:t.length}),{status:r,minCutValue:e,healthyThreshold:this.config.healthyThreshold,warningThreshold:this.config.warningThreshold,weakVertexCount:t.length,topWeakVertices:t.slice(0,5),trend:i,history:this.history.slice(-20),lastUpdated:new Date}}getHealth(){let e=this.calculator.getMinCutValue(this.graph),t=this.calculator.findWeakVertices(this.graph);return{status:this.isEmptyTopology()?"idle":this.determineStatus(e),minCutValue:e,healthyThreshold:this.config.healthyThreshold,warningThreshold:this.config.warningThreshold,weakVertexCount:t.length,topWeakVertices:t.slice(0,5),trend:this.calculateTrend(),history:this.history.slice(-20),lastUpdated:new Date}}getMinCutValue(){return this.calculator.getMinCutValue(this.graph)}getWeakVertices(){return this.calculator.findWeakVertices(this.graph)}isCritical(){return this.calculator.getMinCutValue(this.graph)<this.config.warningThreshold}isHealthy(){return this.calculator.getMinCutValue(this.graph)>=this.config.healthyThreshold}getActiveAlerts(){return Array.from(this.alerts.values()).filter(e=>!e.acknowledged).sort((e,t)=>{let r={critical:0,high:1,medium:2,low:3,info:4};return r[e.severity]-r[t.severity]})}getAllAlerts(){return Array.from(this.alerts.values())}acknowledgeAlert(e){let t=this.alerts.get(e);return t?(t.acknowledged=!0,!0):!1}clearAcknowledgedAlerts(){let e=[];for(let[t,r]of this.alerts)r.acknowledged&&e.push(t);for(let t of e)this.alerts.delete(t);return e.length}getHistory(){return[...this.history]}getTrend(){return this.calculateTrend()}getStats(e=6e4){let t=Date.now()-e,r=this.history.filter(n=>n.timestamp.getTime()>t);if(r.length===0){let n=this.calculator.getMinCutValue(this.graph);return{min:n,max:n,average:n,count:0}}let i=r.map(n=>n.value);return{min:Math.min(...i),max:Math.max(...i),average:i.reduce((n,a)=>n+a,0)/i.length,count:r.length}}updateConfig(e){Object.assign(this.config,e),e.checkIntervalMs&&this.isMonitoring&&(this.stop(),this.start())}getConfig(){return{...this.config}}determineStatus(e){return e>=this.config.healthyThreshold?"healthy":e>=this.config.warningThreshold?"warning":"critical"}calculateTrend(){if(this.history.length<3)return"stable";let e=this.history.slice(-5),t=e[0].value,i=e[e.length-1].value-t,a=e.reduce((o,c)=>o+c.value,0)/e.length*.1;return i>a?"improving":i<-a?"degrading":"stable"}recordHistory(e){let t={timestamp:new Date,value:e,vertexCount:this.graph.vertexCount,edgeCount:this.graph.edgeCount};for(this.history.push(t);this.history.length>this.config.maxHistoryEntries;)this.history.shift()}checkAlertConditions(e,t,r){if(!this.config.alertsEnabled)return;let i=Date.now();r==="critical"?this.maybeGenerateAlert("critical-threshold","critical",`MinCut value (${e.toFixed(2)}) is below critical threshold (${this.config.warningThreshold})`,e,this.config.warningThreshold,t):r==="warning"&&this.maybeGenerateAlert("warning-threshold","high",`MinCut value (${e.toFixed(2)}) is below healthy threshold (${this.config.healthyThreshold})`,e,this.config.healthyThreshold,t);let n=t.filter(o=>o.weightedDegree===0);n.length>0&&this.maybeGenerateAlert("isolated-vertices","high",`${n.length} isolated vertex(es) detected`,e,0,n);let a=t.filter(o=>o.riskScore>.8);a.length>0&&this.maybeGenerateAlert("critical-vertices","medium",`${a.length} critical vertex(es) with high risk score`,e,0,a)}maybeGenerateAlert(e,t,r,i,n,a){let o=Date.now(),c=this.lastAlertTime.get(e)||0;if(o-c<this.config.alertCooldownMs)return;let s={id:h(),severity:t,message:r,minCutValue:i,threshold:n,affectedVertices:a.map(l=>l.vertexId),timestamp:new Date,acknowledged:!1,remediations:a.flatMap(l=>l.suggestions).slice(0,5)};this.alerts.set(s.id,s),this.persistence&&this.persistence.saveAlert(s).catch(l=>console.warn("[MinCutHealthMonitor] Failed to persist alert:",l)),this.lastAlertTime.set(e,o),this.emitEvent("mincut.alert.generated",i,{alert:s})}emitEvent(e,t,r){if(!this.eventBus)return;let i={id:h(),type:e,source:"coordination",timestamp:new Date,correlationId:h(),payload:{minCutValue:t,...r}};this.eventBus.publish(i).catch(n=>{console.error("Failed to publish MinCut event:",n)})}};function v(m,e,t,r){return new g(m,e,t,r)}var d=null,u=null;function C(){return d||(d=y()),d}function P(){return u||(u=v(C())),u}function B(){return d!==null}function F(){return u!==null}export{f as a,v as b,C as c,P as d,B as e,F as f};