@remnic/core 1.1.31 → 9.3.516

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 (1102) hide show
  1. package/dist/abstraction-nodes.js +2 -2
  2. package/dist/access-cli.d.ts +1 -1
  3. package/dist/access-cli.js +158 -121
  4. package/dist/access-cli.js.map +1 -1
  5. package/dist/access-http.d.ts +9 -5
  6. package/dist/access-http.js +51 -51
  7. package/dist/access-idempotency.d.ts +2 -0
  8. package/dist/access-idempotency.js +1 -1
  9. package/dist/access-mcp.d.ts +16 -9
  10. package/dist/access-mcp.js +44 -44
  11. package/dist/access-schema.d.ts +45 -13
  12. package/dist/access-schema.js +8 -8
  13. package/dist/{access-service-CkZyb35d.d.ts → access-service-CZfksQuS.d.ts} +11 -130
  14. package/dist/access-service.d.ts +7 -4
  15. package/dist/access-service.js +40 -40
  16. package/dist/action-confidence.d.ts +1 -0
  17. package/dist/active-memory-bridge.d.ts +1 -0
  18. package/dist/active-memory-bridge.js +3 -2
  19. package/dist/active-recall.d.ts +1 -0
  20. package/dist/active-recall.js +14 -9
  21. package/dist/active-recall.js.map +1 -1
  22. package/dist/adapters/claude-code.d.ts +6 -2
  23. package/dist/adapters/claude-code.js +2 -2
  24. package/dist/adapters/codex.d.ts +5 -1
  25. package/dist/adapters/codex.js +2 -2
  26. package/dist/adapters/hermes.js +2 -2
  27. package/dist/adapters/index.js +6 -6
  28. package/dist/adapters/registry.js +6 -6
  29. package/dist/adapters/replit.d.ts +4 -2
  30. package/dist/adapters/replit.js +2 -2
  31. package/dist/adapters/types.d.ts +4 -0
  32. package/dist/adapters/types.js +1 -1
  33. package/dist/behavior-learner.d.ts +1 -0
  34. package/dist/behavior-signals.d.ts +1 -0
  35. package/dist/behavior-signals.js +1 -1
  36. package/dist/bootstrap.d.ts +5 -3
  37. package/dist/bootstrap.js +2 -2
  38. package/dist/boxes.d.ts +1 -0
  39. package/dist/boxes.js +1 -1
  40. package/dist/briefing.d.ts +1 -0
  41. package/dist/briefing.js +9 -9
  42. package/dist/buffer-surprise-report.d.ts +1 -0
  43. package/dist/buffer.d.ts +1 -0
  44. package/dist/buffer.js +2 -2
  45. package/dist/bulk-import/index.d.ts +28 -0
  46. package/dist/bulk-import/index.js +31 -0
  47. package/dist/calibration.d.ts +2 -0
  48. package/dist/calibration.js +50 -17
  49. package/dist/calibration.js.map +1 -1
  50. package/dist/{capsule-crypto-5CYAGVC5.js → capsule-crypto-7FJQINUR.js} +2 -2
  51. package/dist/{capsule-merge-4MGKE7C5.js → capsule-merge-T2JRE46P.js} +3 -3
  52. package/dist/causal-behavior.d.ts +1 -0
  53. package/dist/causal-behavior.js +4 -4
  54. package/dist/causal-chain.js +4 -4
  55. package/dist/causal-consolidation.d.ts +16 -1
  56. package/dist/causal-consolidation.js +115 -32
  57. package/dist/causal-consolidation.js.map +1 -1
  58. package/dist/causal-retrieval.js +14 -6
  59. package/dist/causal-retrieval.js.map +1 -1
  60. package/dist/causal-trajectory-graph.js +2 -2
  61. package/dist/causal-trajectory.js +2 -2
  62. package/dist/{chunk-SAZS2QZB.js → chunk-23UORJ4S.js} +3 -3
  63. package/dist/{chunk-76FLAAUC.js → chunk-2AN2L4NL.js} +17 -6
  64. package/dist/chunk-2AN2L4NL.js.map +1 -0
  65. package/dist/{chunk-W4L6CZKA.js → chunk-2DL3OFLD.js} +15 -10
  66. package/dist/chunk-2DL3OFLD.js.map +1 -0
  67. package/dist/{chunk-NJ3MJQZX.js → chunk-2I5JGH3M.js} +2 -2
  68. package/dist/{chunk-NJ3MJQZX.js.map → chunk-2I5JGH3M.js.map} +1 -1
  69. package/dist/{chunk-7OZ53EXP.js → chunk-2NLLXCJG.js} +21 -10
  70. package/dist/chunk-2NLLXCJG.js.map +1 -0
  71. package/dist/{chunk-PK7H5L6Y.js → chunk-2NM43EWN.js} +2 -2
  72. package/dist/{chunk-PYXS46O7.js → chunk-3BP57I6J.js} +2 -2
  73. package/dist/{chunk-FBYESMQ2.js → chunk-3C5RPJAX.js} +2 -2
  74. package/dist/{chunk-FKFMOY3N.js → chunk-42NQ7AVG.js} +3 -4
  75. package/dist/{chunk-FKFMOY3N.js.map → chunk-42NQ7AVG.js.map} +1 -1
  76. package/dist/chunk-4426WSWL.js +73 -0
  77. package/dist/chunk-4426WSWL.js.map +1 -0
  78. package/dist/{chunk-LIRZNNUP.js → chunk-44442YCH.js} +5 -2
  79. package/dist/chunk-44442YCH.js.map +1 -0
  80. package/dist/{chunk-H3ME6L6D.js → chunk-46GJIW5M.js} +23 -20
  81. package/dist/chunk-46GJIW5M.js.map +1 -0
  82. package/dist/{chunk-QDZ2RLEC.js → chunk-472U7RDF.js} +3 -3
  83. package/dist/chunk-472U7RDF.js.map +1 -0
  84. package/dist/{chunk-NN2DKE4T.js → chunk-4H5ZJHEN.js} +16 -3
  85. package/dist/{chunk-NN2DKE4T.js.map → chunk-4H5ZJHEN.js.map} +1 -1
  86. package/dist/{chunk-56K5QLHX.js → chunk-4HP7HIE3.js} +56 -13
  87. package/dist/chunk-4HP7HIE3.js.map +1 -0
  88. package/dist/{chunk-RK2Y4XOM.js → chunk-4JRRISLU.js} +9 -6
  89. package/dist/chunk-4JRRISLU.js.map +1 -0
  90. package/dist/{chunk-XKLD5OK4.js → chunk-4RR6ROTB.js} +10 -11
  91. package/dist/chunk-4RR6ROTB.js.map +1 -0
  92. package/dist/{chunk-YROHKYBY.js → chunk-5UHVGNZD.js} +22 -6
  93. package/dist/chunk-5UHVGNZD.js.map +1 -0
  94. package/dist/{chunk-ZAVUCJ4H.js → chunk-5V456VRV.js} +154 -69
  95. package/dist/chunk-5V456VRV.js.map +1 -0
  96. package/dist/{chunk-77H5NU3M.js → chunk-6BR7L222.js} +82 -18
  97. package/dist/chunk-6BR7L222.js.map +1 -0
  98. package/dist/{chunk-4KGVTPGD.js → chunk-6F6BXB7A.js} +9 -8
  99. package/dist/chunk-6F6BXB7A.js.map +1 -0
  100. package/dist/{chunk-NMZY542O.js → chunk-6URPAY2D.js} +41 -17
  101. package/dist/chunk-6URPAY2D.js.map +1 -0
  102. package/dist/{chunk-N53K2EXC.js → chunk-6VF75M3X.js} +2 -2
  103. package/dist/{chunk-XSZEP4SF.js → chunk-6XSPNR6L.js} +6 -5
  104. package/dist/chunk-6XSPNR6L.js.map +1 -0
  105. package/dist/{chunk-6H2TESSP.js → chunk-765K3SAT.js} +3 -3
  106. package/dist/{chunk-EDTHC6UD.js → chunk-77NAFXUD.js} +2 -2
  107. package/dist/{chunk-S7KDBTWT.js → chunk-7F7Z6MOS.js} +29 -14
  108. package/dist/chunk-7F7Z6MOS.js.map +1 -0
  109. package/dist/{chunk-MZH6EHNR.js → chunk-7H6CFEBJ.js} +41 -14
  110. package/dist/chunk-7H6CFEBJ.js.map +1 -0
  111. package/dist/{chunk-MGKYQQYF.js → chunk-7Q3RCKAQ.js} +2 -2
  112. package/dist/chunk-7RXCMVFQ.js +27 -0
  113. package/dist/chunk-7RXCMVFQ.js.map +1 -0
  114. package/dist/{chunk-DGXUHMOV.js → chunk-A2IYSXDQ.js} +25 -6
  115. package/dist/chunk-A2IYSXDQ.js.map +1 -0
  116. package/dist/{chunk-EABGC2TL.js → chunk-A2Z6UCWT.js} +26 -4
  117. package/dist/chunk-A2Z6UCWT.js.map +1 -0
  118. package/dist/{chunk-5375UYTQ.js → chunk-A6D7A2FW.js} +4 -4
  119. package/dist/chunk-A6D7A2FW.js.map +1 -0
  120. package/dist/{chunk-FAAFWE4G.js → chunk-ALEPI75L.js} +24 -6
  121. package/dist/chunk-ALEPI75L.js.map +1 -0
  122. package/dist/{chunk-3SLRNYNG.js → chunk-AUDJPF4N.js} +15 -4
  123. package/dist/chunk-AUDJPF4N.js.map +1 -0
  124. package/dist/chunk-B5XMS73R.js +145 -0
  125. package/dist/chunk-B5XMS73R.js.map +1 -0
  126. package/dist/{chunk-HXXBL2KD.js → chunk-BECQDWBA.js} +44 -4
  127. package/dist/chunk-BECQDWBA.js.map +1 -0
  128. package/dist/{chunk-7SEAZFFB.js → chunk-BEUDU7Y4.js} +24 -4
  129. package/dist/chunk-BEUDU7Y4.js.map +1 -0
  130. package/dist/chunk-CHBI22MI.js +159 -0
  131. package/dist/chunk-CHBI22MI.js.map +1 -0
  132. package/dist/{chunk-GDFS42HT.js → chunk-CHCA44C3.js} +15 -8
  133. package/dist/chunk-CHCA44C3.js.map +1 -0
  134. package/dist/chunk-CINZGPSJ.js +22 -0
  135. package/dist/chunk-CINZGPSJ.js.map +1 -0
  136. package/dist/chunk-CMTINOFS.js +36 -0
  137. package/dist/chunk-CMTINOFS.js.map +1 -0
  138. package/dist/{chunk-34DQE4KF.js → chunk-CO7ZO4TU.js} +2 -2
  139. package/dist/{chunk-PFV5C235.js → chunk-CPPS65WS.js} +2 -1
  140. package/dist/{chunk-PFV5C235.js.map → chunk-CPPS65WS.js.map} +1 -1
  141. package/dist/{chunk-DINWEURR.js → chunk-CSKLPDN6.js} +20 -6
  142. package/dist/chunk-CSKLPDN6.js.map +1 -0
  143. package/dist/chunk-CWWMTTQE.js +566 -0
  144. package/dist/chunk-CWWMTTQE.js.map +1 -0
  145. package/dist/{chunk-IQT3XTKW.js → chunk-D24OXEPB.js} +13 -7
  146. package/dist/chunk-D24OXEPB.js.map +1 -0
  147. package/dist/{chunk-WIICJPET.js → chunk-DEUNUKTD.js} +6 -4
  148. package/dist/{chunk-WIICJPET.js.map → chunk-DEUNUKTD.js.map} +1 -1
  149. package/dist/{chunk-ZYVPLJ4T.js → chunk-DHGSZ3UD.js} +9 -7
  150. package/dist/chunk-DHGSZ3UD.js.map +1 -0
  151. package/dist/{chunk-JR4ZC3G4.js → chunk-DLJ4IR6M.js} +91 -41
  152. package/dist/chunk-DLJ4IR6M.js.map +1 -0
  153. package/dist/{chunk-U4SCL7B7.js → chunk-DRD2Q7HQ.js} +82 -18
  154. package/dist/chunk-DRD2Q7HQ.js.map +1 -0
  155. package/dist/{chunk-2IWUMAES.js → chunk-E62SBGQ3.js} +28 -13
  156. package/dist/chunk-E62SBGQ3.js.map +1 -0
  157. package/dist/{chunk-C5BCH4ZS.js → chunk-EAZGEEG2.js} +21 -3
  158. package/dist/chunk-EAZGEEG2.js.map +1 -0
  159. package/dist/{chunk-TPB3I2AC.js → chunk-ECZU5BJH.js} +31 -10
  160. package/dist/chunk-ECZU5BJH.js.map +1 -0
  161. package/dist/chunk-EDQVAMQI.js +308 -0
  162. package/dist/chunk-EDQVAMQI.js.map +1 -0
  163. package/dist/{chunk-RRF5UOBJ.js → chunk-EI6V5UXY.js} +22 -15
  164. package/dist/chunk-EI6V5UXY.js.map +1 -0
  165. package/dist/{chunk-ZKSK55RC.js → chunk-ETUPBUHB.js} +2 -2
  166. package/dist/{chunk-25MQ7IHJ.js → chunk-EUML3N6B.js} +17 -6
  167. package/dist/chunk-EUML3N6B.js.map +1 -0
  168. package/dist/{chunk-5RGLBDQF.js → chunk-EVZFIAPG.js} +12 -12
  169. package/dist/chunk-EVZFIAPG.js.map +1 -0
  170. package/dist/{chunk-QRNI5JBH.js → chunk-EYIEWJNI.js} +2 -2
  171. package/dist/{chunk-TPU5L5EY.js → chunk-FCOQXV3T.js} +272 -411
  172. package/dist/chunk-FCOQXV3T.js.map +1 -0
  173. package/dist/{chunk-TMQLARTH.js → chunk-FK556DDH.js} +34 -15
  174. package/dist/chunk-FK556DDH.js.map +1 -0
  175. package/dist/{chunk-43PJZYGL.js → chunk-FPGE5NVO.js} +45 -10
  176. package/dist/chunk-FPGE5NVO.js.map +1 -0
  177. package/dist/{chunk-3VAL7ZL2.js → chunk-FUC4LZMD.js} +60 -25
  178. package/dist/chunk-FUC4LZMD.js.map +1 -0
  179. package/dist/{chunk-C6QPK5GG.js → chunk-FZZ2QTJI.js} +2 -2
  180. package/dist/{chunk-D46YSIYX.js → chunk-G3Z3QEF5.js} +19 -11
  181. package/dist/{chunk-D46YSIYX.js.map → chunk-G3Z3QEF5.js.map} +1 -1
  182. package/dist/{chunk-3JXBXXM2.js → chunk-G4IAEX6D.js} +2 -2
  183. package/dist/{chunk-MSWG7JI6.js → chunk-G56P5RLD.js} +8 -2
  184. package/dist/chunk-G56P5RLD.js.map +1 -0
  185. package/dist/{chunk-AGZQD76C.js → chunk-GCGJW34D.js} +48 -2
  186. package/dist/chunk-GCGJW34D.js.map +1 -0
  187. package/dist/chunk-H2NCNXMS.js +159 -0
  188. package/dist/chunk-H2NCNXMS.js.map +1 -0
  189. package/dist/{chunk-XYIK4LF6.js → chunk-H3FZVNRN.js} +8 -2
  190. package/dist/chunk-H3FZVNRN.js.map +1 -0
  191. package/dist/{chunk-YU5KIWYQ.js → chunk-HC6EKOID.js} +94 -43
  192. package/dist/chunk-HC6EKOID.js.map +1 -0
  193. package/dist/{chunk-TK4UEOSK.js → chunk-HDDRVXX4.js} +8 -8
  194. package/dist/chunk-HDDRVXX4.js.map +1 -0
  195. package/dist/{chunk-LLQ2LLWF.js → chunk-HENLZHIT.js} +15 -5
  196. package/dist/chunk-HENLZHIT.js.map +1 -0
  197. package/dist/{chunk-N2D6GXBM.js → chunk-HINSGUA7.js} +28 -20
  198. package/dist/chunk-HINSGUA7.js.map +1 -0
  199. package/dist/{chunk-APO3DCMU.js → chunk-HLAVGJ62.js} +30 -8
  200. package/dist/chunk-HLAVGJ62.js.map +1 -0
  201. package/dist/{chunk-TPMQ3G6Z.js → chunk-HOJZMQ4J.js} +2 -2
  202. package/dist/chunk-HOJZMQ4J.js.map +1 -0
  203. package/dist/{chunk-LUDTDZLK.js → chunk-HPWVAEET.js} +33 -7
  204. package/dist/chunk-HPWVAEET.js.map +1 -0
  205. package/dist/{chunk-NZL6GGQE.js → chunk-HQ6NIBL6.js} +92 -30
  206. package/dist/chunk-HQ6NIBL6.js.map +1 -0
  207. package/dist/{chunk-UWVJF25J.js → chunk-HWVTS5NO.js} +20 -6
  208. package/dist/chunk-HWVTS5NO.js.map +1 -0
  209. package/dist/{chunk-2WWLHTZY.js → chunk-IC4GELZE.js} +2 -2
  210. package/dist/{chunk-QA2ZAPBU.js → chunk-IPLYGWQF.js} +28 -20
  211. package/dist/chunk-IPLYGWQF.js.map +1 -0
  212. package/dist/{chunk-A6KTB5R6.js → chunk-IQ3OI2RR.js} +3 -3
  213. package/dist/chunk-IQ3OI2RR.js.map +1 -0
  214. package/dist/{chunk-6LVVDPJ4.js → chunk-J64TK33U.js} +3 -4
  215. package/dist/chunk-J64TK33U.js.map +1 -0
  216. package/dist/{chunk-6FC5EGNV.js → chunk-JBPKEARU.js} +15 -5
  217. package/dist/{chunk-6FC5EGNV.js.map → chunk-JBPKEARU.js.map} +1 -1
  218. package/dist/{chunk-RHY3HH7P.js → chunk-JFEKNTX7.js} +125 -33
  219. package/dist/chunk-JFEKNTX7.js.map +1 -0
  220. package/dist/{chunk-TZOLIGIG.js → chunk-JJEJJ7RK.js} +4 -2
  221. package/dist/chunk-JJEJJ7RK.js.map +1 -0
  222. package/dist/{chunk-PCUKNJAZ.js → chunk-JKV57BTN.js} +2 -2
  223. package/dist/{chunk-EJI5XIBB.js → chunk-JLNBQWZ2.js} +55 -7
  224. package/dist/chunk-JLNBQWZ2.js.map +1 -0
  225. package/dist/{chunk-PIRJPV5T.js → chunk-JNANKJLN.js} +2 -2
  226. package/dist/chunk-JNANKJLN.js.map +1 -0
  227. package/dist/{chunk-XIG5PDM7.js → chunk-JUC24CTX.js} +8 -12
  228. package/dist/chunk-JUC24CTX.js.map +1 -0
  229. package/dist/{chunk-OIGNEXKZ.js → chunk-K5O2QY6T.js} +5 -1
  230. package/dist/{chunk-OIGNEXKZ.js.map → chunk-K5O2QY6T.js.map} +1 -1
  231. package/dist/{chunk-ZTFCYYEZ.js → chunk-KCYE2MZM.js} +3 -3
  232. package/dist/chunk-KCYE2MZM.js.map +1 -0
  233. package/dist/{chunk-JWPLJLDU.js → chunk-KD3QD3A5.js} +2 -2
  234. package/dist/{chunk-JWPLJLDU.js.map → chunk-KD3QD3A5.js.map} +1 -1
  235. package/dist/{chunk-YRMVARQP.js → chunk-KFY3SGN7.js} +49 -2
  236. package/dist/chunk-KFY3SGN7.js.map +1 -0
  237. package/dist/{chunk-CYFQJMUV.js → chunk-KIB7SDIJ.js} +15 -10
  238. package/dist/chunk-KIB7SDIJ.js.map +1 -0
  239. package/dist/{chunk-3KW65B36.js → chunk-KILOTVIF.js} +95 -48
  240. package/dist/chunk-KILOTVIF.js.map +1 -0
  241. package/dist/{chunk-MXFBBHJU.js → chunk-KJMYHC7K.js} +10 -5
  242. package/dist/chunk-KJMYHC7K.js.map +1 -0
  243. package/dist/{chunk-W3LR522O.js → chunk-KM2A35EO.js} +36 -34
  244. package/dist/chunk-KM2A35EO.js.map +1 -0
  245. package/dist/{chunk-575RMLWN.js → chunk-KXULCVOC.js} +30 -24
  246. package/dist/chunk-KXULCVOC.js.map +1 -0
  247. package/dist/{chunk-WELDCG6C.js → chunk-L227SKTB.js} +109 -36
  248. package/dist/chunk-L227SKTB.js.map +1 -0
  249. package/dist/{chunk-BVF3AGJP.js → chunk-LJBOVCQG.js} +26 -11
  250. package/dist/chunk-LJBOVCQG.js.map +1 -0
  251. package/dist/{chunk-2KI4QFHU.js → chunk-LMDRGRJ2.js} +2 -2
  252. package/dist/{chunk-MY6TPVXW.js → chunk-LMPHTYJC.js} +2 -2
  253. package/dist/{chunk-EHRTFRWW.js → chunk-LQHDIS7L.js} +10 -5
  254. package/dist/chunk-LQHDIS7L.js.map +1 -0
  255. package/dist/chunk-LUDUFZTV.js +170 -0
  256. package/dist/chunk-LUDUFZTV.js.map +1 -0
  257. package/dist/{chunk-5HRY2WRF.js → chunk-LZ3VEOU5.js} +2 -2
  258. package/dist/{chunk-Q7P4WJDP.js → chunk-M5T4Q2ZU.js} +1 -1
  259. package/dist/chunk-M5T4Q2ZU.js.map +1 -0
  260. package/dist/{chunk-ICRIXAP2.js → chunk-MC4FJXPA.js} +16 -6
  261. package/dist/chunk-MC4FJXPA.js.map +1 -0
  262. package/dist/{chunk-WPGJYVUH.js → chunk-MGVIEM2O.js} +23 -6
  263. package/dist/chunk-MGVIEM2O.js.map +1 -0
  264. package/dist/{chunk-NGAVDO7E.js → chunk-OADWQ5CR.js} +2 -2
  265. package/dist/{chunk-2NMMFZ5T.js → chunk-OD4FM2U7.js} +6 -3
  266. package/dist/chunk-OD4FM2U7.js.map +1 -0
  267. package/dist/{chunk-OZHRDTDX.js → chunk-OKTXM5H4.js} +11 -1
  268. package/dist/chunk-OKTXM5H4.js.map +1 -0
  269. package/dist/{chunk-RXDLTSWT.js → chunk-ONPLNAPX.js} +16 -7
  270. package/dist/chunk-ONPLNAPX.js.map +1 -0
  271. package/dist/{chunk-FJ43PRLT.js → chunk-ORFGK3XI.js} +20 -14
  272. package/dist/chunk-ORFGK3XI.js.map +1 -0
  273. package/dist/{chunk-DOM4GKSW.js → chunk-OZKVVUJB.js} +3 -3
  274. package/dist/{chunk-3TNBOMQT.js → chunk-PCI747N2.js} +13 -13
  275. package/dist/{chunk-3TNBOMQT.js.map → chunk-PCI747N2.js.map} +1 -1
  276. package/dist/{chunk-MT4HVDUZ.js → chunk-PM3QHTFT.js} +3 -3
  277. package/dist/{chunk-4DWOBS2A.js → chunk-PRQJ5ESM.js} +27 -2
  278. package/dist/{chunk-4DWOBS2A.js.map → chunk-PRQJ5ESM.js.map} +1 -1
  279. package/dist/chunk-PU44GBL4.js +52 -0
  280. package/dist/chunk-PU44GBL4.js.map +1 -0
  281. package/dist/{chunk-MJFNCJXV.js → chunk-Q4CAQGKQ.js} +47 -9
  282. package/dist/chunk-Q4CAQGKQ.js.map +1 -0
  283. package/dist/{chunk-U3WSW6PZ.js → chunk-QMYXNM4P.js} +90 -35
  284. package/dist/chunk-QMYXNM4P.js.map +1 -0
  285. package/dist/{chunk-XVVIG67A.js → chunk-QVJ4NWL2.js} +62 -18
  286. package/dist/chunk-QVJ4NWL2.js.map +1 -0
  287. package/dist/{chunk-NBNN5GOB.js → chunk-QY7YA7OL.js} +11 -2
  288. package/dist/chunk-QY7YA7OL.js.map +1 -0
  289. package/dist/{chunk-ZK7I7JYV.js → chunk-R3PS27B4.js} +7 -7
  290. package/dist/{chunk-2PRLKQAH.js → chunk-RLV3PQGH.js} +35 -19
  291. package/dist/chunk-RLV3PQGH.js.map +1 -0
  292. package/dist/{chunk-WW3QQF4H.js → chunk-ROZJACKP.js} +16 -1
  293. package/dist/chunk-ROZJACKP.js.map +1 -0
  294. package/dist/{chunk-7MNMYOFP.js → chunk-RSUYKGGZ.js} +3 -4
  295. package/dist/chunk-RSUYKGGZ.js.map +1 -0
  296. package/dist/{chunk-LT3NLYSI.js → chunk-RUZOJKNF.js} +10 -7
  297. package/dist/chunk-RUZOJKNF.js.map +1 -0
  298. package/dist/{chunk-326G7DJK.js → chunk-RW5DGAGO.js} +67 -13
  299. package/dist/chunk-RW5DGAGO.js.map +1 -0
  300. package/dist/{chunk-KOSORCJG.js → chunk-S53PKKWK.js} +63 -24
  301. package/dist/chunk-S53PKKWK.js.map +1 -0
  302. package/dist/{chunk-65PG43EQ.js → chunk-S7WU3Y3D.js} +21 -4
  303. package/dist/chunk-S7WU3Y3D.js.map +1 -0
  304. package/dist/{chunk-SKE7JYKA.js → chunk-SFXKHM7P.js} +2 -2
  305. package/dist/{chunk-HMDCOMYU.js → chunk-SKGV326D.js} +3 -3
  306. package/dist/{chunk-I5GLV3VE.js → chunk-SML26KED.js} +33 -26
  307. package/dist/{chunk-I5GLV3VE.js.map → chunk-SML26KED.js.map} +1 -1
  308. package/dist/chunk-T2PO5MUF.js +62 -0
  309. package/dist/chunk-T2PO5MUF.js.map +1 -0
  310. package/dist/{chunk-C7VW7C3F.js → chunk-TDKQGLJW.js} +3 -3
  311. package/dist/chunk-TDKQGLJW.js.map +1 -0
  312. package/dist/{chunk-3QKK7QOS.js → chunk-TERNBNJB.js} +3 -3
  313. package/dist/chunk-TERNBNJB.js.map +1 -0
  314. package/dist/{chunk-MXC3AP5I.js → chunk-TGQ2NTWH.js} +12 -7
  315. package/dist/chunk-TGQ2NTWH.js.map +1 -0
  316. package/dist/{chunk-3Y4P7RXM.js → chunk-TMSXWOBZ.js} +3 -4
  317. package/dist/chunk-TMSXWOBZ.js.map +1 -0
  318. package/dist/{chunk-3ZLVGM76.js → chunk-TTGZV5R3.js} +106 -44
  319. package/dist/chunk-TTGZV5R3.js.map +1 -0
  320. package/dist/{chunk-5UM2VJ6D.js → chunk-UEY3VB6W.js} +2 -2
  321. package/dist/{chunk-I6K5FBRQ.js → chunk-UI3NYK34.js} +4 -1
  322. package/dist/{chunk-I6K5FBRQ.js.map → chunk-UI3NYK34.js.map} +1 -1
  323. package/dist/{chunk-VBJ7V5SK.js → chunk-UIPDNLXA.js} +21 -8
  324. package/dist/chunk-UIPDNLXA.js.map +1 -0
  325. package/dist/{chunk-GIF42EW3.js → chunk-UP6MOYCB.js} +3 -3
  326. package/dist/{chunk-K4FLSOR5.js → chunk-USYGGIJZ.js} +44 -15
  327. package/dist/chunk-USYGGIJZ.js.map +1 -0
  328. package/dist/{chunk-FIT6DMX6.js → chunk-UWY7GIVS.js} +152 -54
  329. package/dist/chunk-UWY7GIVS.js.map +1 -0
  330. package/dist/{chunk-MRILGULB.js → chunk-V2RCP53Q.js} +2 -2
  331. package/dist/{chunk-XKECPATV.js → chunk-VFUEZZBS.js} +113 -4
  332. package/dist/chunk-VFUEZZBS.js.map +1 -0
  333. package/dist/{chunk-FSFEQI74.js → chunk-W7L6HXUC.js} +2 -2
  334. package/dist/{chunk-3IQ2TR4N.js → chunk-WLEB7WCG.js} +2 -2
  335. package/dist/{chunk-GL6I6MEQ.js → chunk-WSGF57U2.js} +3 -3
  336. package/dist/{chunk-KNKUID7G.js → chunk-X7Y7WX73.js} +72 -6
  337. package/dist/chunk-X7Y7WX73.js.map +1 -0
  338. package/dist/{chunk-5NPGSAVB.js → chunk-XEKAG3FM.js} +23 -5
  339. package/dist/chunk-XEKAG3FM.js.map +1 -0
  340. package/dist/{chunk-3APJ5EVB.js → chunk-XKIQZXUB.js} +41 -26
  341. package/dist/chunk-XKIQZXUB.js.map +1 -0
  342. package/dist/chunk-XKXKSQU7.js +92 -0
  343. package/dist/chunk-XKXKSQU7.js.map +1 -0
  344. package/dist/{chunk-JA3AK3PT.js → chunk-XNLXAWHX.js} +4 -4
  345. package/dist/{chunk-CULXMQJH.js → chunk-XPXEJRUB.js} +3 -3
  346. package/dist/chunk-XPXEJRUB.js.map +1 -0
  347. package/dist/{chunk-PZIAX57I.js → chunk-XR6DNK4U.js} +7 -4
  348. package/dist/chunk-XR6DNK4U.js.map +1 -0
  349. package/dist/{chunk-47VWKCAF.js → chunk-XSQ4SGM5.js} +33 -4
  350. package/dist/chunk-XSQ4SGM5.js.map +1 -0
  351. package/dist/{chunk-66DHUKLO.js → chunk-XSWKORGM.js} +16 -14
  352. package/dist/chunk-XSWKORGM.js.map +1 -0
  353. package/dist/{chunk-QR3C7BKQ.js → chunk-XZ4WBBB5.js} +7 -8
  354. package/dist/chunk-XZ4WBBB5.js.map +1 -0
  355. package/dist/{chunk-WNARATI3.js → chunk-Y2SXZ5KZ.js} +59 -11
  356. package/dist/chunk-Y2SXZ5KZ.js.map +1 -0
  357. package/dist/{chunk-QLLBRHAT.js → chunk-YDMVYYD2.js} +229 -264
  358. package/dist/chunk-YDMVYYD2.js.map +1 -0
  359. package/dist/{chunk-SIC6U3GZ.js → chunk-YHV3KRKS.js} +3 -3
  360. package/dist/{chunk-ZPKBYX2F.js → chunk-YNDLCWXS.js} +85 -9
  361. package/dist/chunk-YNDLCWXS.js.map +1 -0
  362. package/dist/{chunk-W6AQJ2PY.js → chunk-YNXOKMJP.js} +35 -16
  363. package/dist/chunk-YNXOKMJP.js.map +1 -0
  364. package/dist/{chunk-VLXA6PI2.js → chunk-YQMZ7IH2.js} +4 -4
  365. package/dist/{chunk-TMM4S4IJ.js → chunk-YR6GIWWY.js} +58 -8
  366. package/dist/chunk-YR6GIWWY.js.map +1 -0
  367. package/dist/{chunk-DK5LDEQM.js → chunk-YR7XMOWK.js} +39 -23
  368. package/dist/chunk-YR7XMOWK.js.map +1 -0
  369. package/dist/{chunk-U7EJOMFC.js → chunk-ZEY4KYRQ.js} +41 -14
  370. package/dist/chunk-ZEY4KYRQ.js.map +1 -0
  371. package/dist/chunk-ZFXCQPNO.js +27 -0
  372. package/dist/chunk-ZFXCQPNO.js.map +1 -0
  373. package/dist/citations.js +1 -1
  374. package/dist/{cli-kuh9PwZ5.d.ts → cli-CPe_2KB1.d.ts} +8 -31
  375. package/dist/cli.d.ts +10 -6
  376. package/dist/cli.js +124 -119
  377. package/dist/commitment-ledger.js +2 -2
  378. package/dist/compat/checks.js +1 -2
  379. package/dist/compounding/engine.d.ts +3 -2
  380. package/dist/compounding/engine.js +11 -11
  381. package/dist/compounding/preference-consolidator.d.ts +1 -0
  382. package/dist/compounding/preference-consolidator.js +8 -8
  383. package/dist/compounding/preference-consolidator.js.map +1 -1
  384. package/dist/compression-optimizer.d.ts +1 -0
  385. package/dist/compression-optimizer.js +1 -1
  386. package/dist/config.d.ts +1 -0
  387. package/dist/config.js +3 -2
  388. package/dist/connectors/codex-materialize-runner.d.ts +1 -0
  389. package/dist/connectors/codex-materialize-runner.js +12 -11
  390. package/dist/connectors/codex-materialize.d.ts +1 -0
  391. package/dist/connectors/codex-materialize.js +3 -2
  392. package/dist/connectors/index.d.ts +1 -0
  393. package/dist/connectors/index.js +14 -14
  394. package/dist/{connectors-cli-CwbyjGR7.d.ts → connectors-cli-DbTPNj2H.d.ts} +7 -1
  395. package/dist/connectors-cli.d.ts +1 -1
  396. package/dist/connectors-cli.js +3 -1
  397. package/dist/consolidation-provenance-check.d.ts +1 -0
  398. package/dist/consolidation-provenance-check.js +2 -2
  399. package/dist/consolidation-undo.d.ts +1 -0
  400. package/dist/consolidation-undo.js +1 -1
  401. package/dist/contradiction/index.d.ts +3 -1
  402. package/dist/contradiction/index.js +3 -3
  403. package/dist/{contradiction-review-ATP4S6IC.js → contradiction-review-6V2LXXK6.js} +2 -2
  404. package/dist/{contradiction-scan-5A4IDZV5.js → contradiction-scan-GIRVC4C7.js} +3 -3
  405. package/dist/conversation-index/backend.d.ts +3 -1
  406. package/dist/conversation-index/backend.js +3 -3
  407. package/dist/conversation-index/chunker.d.ts +1 -0
  408. package/dist/conversation-index/cleanup.js +1 -1
  409. package/dist/conversation-index/faiss-adapter.d.ts +2 -1
  410. package/dist/conversation-index/faiss-adapter.js +1 -1
  411. package/dist/conversation-index/indexer.d.ts +5 -2
  412. package/dist/conversation-index/indexer.js +1 -1
  413. package/dist/conversation-index/search.d.ts +2 -1
  414. package/dist/cross-namespace-budget.js +1 -1
  415. package/dist/cue-anchors.js +2 -2
  416. package/dist/dashboard-runtime.d.ts +6 -0
  417. package/dist/dashboard-runtime.js +3 -3
  418. package/dist/day-summary.d.ts +1 -0
  419. package/dist/day-summary.js +2 -2
  420. package/dist/delinearize.d.ts +1 -0
  421. package/dist/direct-answer-wiring.d.ts +1 -0
  422. package/dist/direct-answer.d.ts +1 -0
  423. package/dist/{dreams-ledger-LR2NBAZE.js → dreams-ledger-3WSCI5V4.js} +5 -4
  424. package/dist/{dreams-ledger-LR2NBAZE.js.map → dreams-ledger-3WSCI5V4.js.map} +1 -1
  425. package/dist/embedding-fallback.d.ts +3 -0
  426. package/dist/embedding-fallback.js +2 -2
  427. package/dist/enrichment/index.d.ts +1 -0
  428. package/dist/enrichment/index.js +1 -1
  429. package/dist/entity-retrieval.d.ts +2 -0
  430. package/dist/entity-retrieval.js +9 -9
  431. package/dist/entity-schema.d.ts +1 -0
  432. package/dist/evals.js +1 -1
  433. package/dist/explicit-capture.d.ts +5 -3
  434. package/dist/explicit-capture.js +2 -2
  435. package/dist/extraction-judge-telemetry.d.ts +2 -0
  436. package/dist/extraction-judge-training.d.ts +2 -0
  437. package/dist/extraction-judge.d.ts +2 -0
  438. package/dist/extraction.d.ts +2 -0
  439. package/dist/extraction.js +12 -12
  440. package/dist/{faiss-adapter-CzPghc4C.d.ts → faiss-adapter-BHecI1fF.d.ts} +4 -1
  441. package/dist/fallback-llm.d.ts +11 -1
  442. package/dist/fallback-llm.js +8 -6
  443. package/dist/{first-start-migration-4MHQEOSD.js → first-start-migration-CKTCTCQI.js} +5 -5
  444. package/dist/graph-dashboard-diff.d.ts +4 -0
  445. package/dist/graph-dashboard-diff.js +1 -1
  446. package/dist/graph-dashboard-parser.js +1 -1
  447. package/dist/{graph-edge-decay-5DI5GUNL.js → graph-edge-decay-MUP5J7CC.js} +6 -6
  448. package/dist/graph-events.js +1 -1
  449. package/dist/graph-snapshot.js +3 -3
  450. package/dist/graph.js +2 -2
  451. package/dist/harmonic-retrieval.js +4 -4
  452. package/dist/identity-continuity.d.ts +1 -0
  453. package/dist/importance.d.ts +1 -0
  454. package/dist/importers/index.d.ts +244 -0
  455. package/dist/importers/index.js +20 -0
  456. package/dist/index.d.ts +20 -350
  457. package/dist/index.js +885 -562
  458. package/dist/index.js.map +1 -1
  459. package/dist/intent.d.ts +1 -0
  460. package/dist/lcm/archive.d.ts +2 -2
  461. package/dist/lcm/archive.js +2 -2
  462. package/dist/lcm/engine.d.ts +3 -2
  463. package/dist/lcm/engine.js +6 -6
  464. package/dist/lcm/index.d.ts +1 -0
  465. package/dist/lcm/index.js +8 -8
  466. package/dist/lcm/recall.js +1 -1
  467. package/dist/lcm/summarizer.js +3 -3
  468. package/dist/lcm/tools.d.ts +1 -0
  469. package/dist/lifecycle.d.ts +1 -0
  470. package/dist/live-connectors-runner.d.ts +1 -0
  471. package/dist/live-connectors-runner.js +6 -6
  472. package/dist/local-llm.d.ts +1 -0
  473. package/dist/local-llm.js +2 -2
  474. package/dist/maintenance/archive-observations.js +1 -1
  475. package/dist/maintenance/memory-governance.d.ts +3 -1
  476. package/dist/maintenance/memory-governance.js +10 -8
  477. package/dist/maintenance/migrate-observations.js +3 -2
  478. package/dist/maintenance/observation-ledger-utils.d.ts +3 -0
  479. package/dist/maintenance/observation-ledger-utils.js +2 -1
  480. package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +2 -1
  481. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +11 -8
  482. package/dist/maintenance/rebuild-memory-projection.d.ts +2 -1
  483. package/dist/maintenance/rebuild-memory-projection.js +13 -10
  484. package/dist/maintenance/rebuild-observations.d.ts +1 -0
  485. package/dist/maintenance/rebuild-observations.js +3 -2
  486. package/dist/mcp-memory-inspector-app.d.ts +7 -4
  487. package/dist/mcp-memory-inspector-app.js +1 -1
  488. package/dist/memory-action-policy.d.ts +1 -0
  489. package/dist/memory-cache.d.ts +1 -0
  490. package/dist/memory-cache.js +1 -1
  491. package/dist/memory-lifecycle-ledger-utils.d.ts +1 -0
  492. package/dist/memory-projection-store.d.ts +1 -0
  493. package/dist/memory-projection-store.js +1 -1
  494. package/dist/memory-provenance.d.ts +1 -0
  495. package/dist/memory-worth-outcomes.d.ts +1 -0
  496. package/dist/migrate/from-engram.js +2 -2
  497. package/dist/{migrate-from-identity-anchor-G27MCD6A.js → migrate-from-identity-anchor-EB4XI4Q2.js} +2 -2
  498. package/dist/model-registry.js +1 -1
  499. package/dist/models-json.d.ts +1 -0
  500. package/dist/namespaces/migrate.d.ts +3 -0
  501. package/dist/namespaces/migrate.js +26 -24
  502. package/dist/namespaces/principal.d.ts +1 -0
  503. package/dist/namespaces/principal.js +2 -1
  504. package/dist/namespaces/search.d.ts +2 -1
  505. package/dist/namespaces/search.js +17 -15
  506. package/dist/namespaces/storage.d.ts +4 -2
  507. package/dist/namespaces/storage.js +10 -9
  508. package/dist/native-knowledge.d.ts +1 -0
  509. package/dist/native-knowledge.js +1 -1
  510. package/dist/negative.js +1 -1
  511. package/dist/network/webdav.d.ts +16 -1
  512. package/dist/network/webdav.js +5 -3
  513. package/dist/objective-state-writers.js +4 -4
  514. package/dist/objective-state.js +2 -2
  515. package/dist/offline-sync.d.ts +4 -0
  516. package/dist/offline-sync.js +4 -4
  517. package/dist/operator-toolkit.d.ts +4 -1
  518. package/dist/operator-toolkit.js +37 -34
  519. package/dist/opik-exporter.js +1 -1
  520. package/dist/{orchestrator-DuWl9Hwx.d.ts → orchestrator-Co9nxRLF.d.ts} +4 -74
  521. package/dist/orchestrator.d.ts +5 -3
  522. package/dist/orchestrator.js +101 -98
  523. package/dist/page-versioning.js +1 -1
  524. package/dist/path-X2K5XCHL.js +9 -0
  525. package/dist/patterns-cli.d.ts +1 -0
  526. package/dist/peers/index.d.ts +328 -0
  527. package/dist/{peers-HCVGHMAE.js → peers/index.js} +4 -4
  528. package/dist/pipeline-D18UAKlN.d.ts +32 -0
  529. package/dist/plugin-entry-resolver.d.ts +9 -0
  530. package/dist/plugin-entry-resolver.js +8 -0
  531. package/dist/plugin-entry-resolver.js.map +1 -0
  532. package/dist/plugin-id.d.ts +2 -21
  533. package/dist/plugin-id.js +33 -4
  534. package/dist/plugin-id.js.map +1 -1
  535. package/dist/policy-runtime.d.ts +4 -0
  536. package/dist/policy-runtime.js +1 -1
  537. package/dist/profiling.js +1 -1
  538. package/dist/qmd-recall-cache.d.ts +1 -0
  539. package/dist/qmd.d.ts +2 -1
  540. package/dist/qmd.js +3 -3
  541. package/dist/recall-disclosure-escalation.d.ts +1 -0
  542. package/dist/recall-explain-renderer.d.ts +1 -0
  543. package/dist/recall-explain-renderer.js +3 -3
  544. package/dist/recall-state.d.ts +8 -1
  545. package/dist/recall-state.js +2 -1
  546. package/dist/recall-tag-filter.d.ts +1 -0
  547. package/dist/recall-xray-cli.d.ts +1 -0
  548. package/dist/recall-xray-cli.js +4 -4
  549. package/dist/recall-xray-renderer.d.ts +1 -0
  550. package/dist/recall-xray-renderer.js +3 -3
  551. package/dist/recall-xray.d.ts +1 -0
  552. package/dist/recall-xray.js +2 -2
  553. package/dist/relevance.d.ts +7 -1
  554. package/dist/relevance.js +2 -1
  555. package/dist/replay/normalizers/chatgpt.js +2 -2
  556. package/dist/replay/normalizers/claude.js +2 -2
  557. package/dist/replay/normalizers/openclaw.js +2 -2
  558. package/dist/replay/normalizers/shared.js +1 -1
  559. package/dist/replay/runner.js +1 -1
  560. package/dist/rerank.js +1 -1
  561. package/dist/{resolution-B7FNQSSP.js → resolution-ZY7VM6WS.js} +3 -3
  562. package/dist/resolution-ZY7VM6WS.js.map +1 -0
  563. package/dist/resolve-auth-token.d.ts +1 -0
  564. package/dist/resolve-auth-token.js +1 -1
  565. package/dist/resolve-provider-secret.d.ts +19 -29
  566. package/dist/resolve-provider-secret.js +2 -6
  567. package/dist/resume-bundles.js +10 -9
  568. package/dist/retrieval-agents.d.ts +2 -1
  569. package/dist/retrieval-agents.js +2 -1
  570. package/dist/retrieval-tiers.d.ts +1 -0
  571. package/dist/routing/engine.d.ts +1 -0
  572. package/dist/routing/store.d.ts +3 -0
  573. package/dist/routing/store.js +1 -1
  574. package/dist/runtime/env.js +1 -1
  575. package/dist/schemas.d.ts +191 -17
  576. package/dist/schemas.js +1 -1
  577. package/dist/sdk-compat.js +1 -1
  578. package/dist/search/document-scanner.js +1 -1
  579. package/dist/search/embed-helper.d.ts +7 -2
  580. package/dist/search/embed-helper.js +3 -1
  581. package/dist/search/factory.d.ts +2 -1
  582. package/dist/search/factory.js +15 -14
  583. package/dist/search/index.d.ts +2 -1
  584. package/dist/search/index.js +21 -20
  585. package/dist/search/lancedb-backend.d.ts +8 -7
  586. package/dist/search/lancedb-backend.js +4 -2
  587. package/dist/search/meilisearch-backend.d.ts +8 -7
  588. package/dist/search/meilisearch-backend.js +4 -2
  589. package/dist/search/noop-backend.d.ts +2 -1
  590. package/dist/search/noop-backend.js +1 -1
  591. package/dist/search/orama-backend.d.ts +10 -8
  592. package/dist/search/orama-backend.js +8 -4
  593. package/dist/search/port.d.ts +2 -1
  594. package/dist/search/remote-backend.d.ts +2 -1
  595. package/dist/search/remote-backend.js +1 -1
  596. package/dist/secure-store/index.d.ts +16 -3
  597. package/dist/secure-store/index.js +2 -2
  598. package/dist/{semantic-VwGI14Ok.d.ts → semantic-SLAa_prH.d.ts} +5 -3
  599. package/dist/semantic-consolidation.d.ts +1 -0
  600. package/dist/semantic-consolidation.js +14 -13
  601. package/dist/semantic-rule-promotion.js +8 -8
  602. package/dist/semantic-rule-verifier.d.ts +1 -0
  603. package/dist/semantic-rule-verifier.js +8 -8
  604. package/dist/session-integrity.d.ts +1 -0
  605. package/dist/session-integrity.js +1 -1
  606. package/dist/session-observer-bands.d.ts +1 -0
  607. package/dist/session-observer-state.d.ts +6 -1
  608. package/dist/session-observer-state.js +1 -1
  609. package/dist/shared-context/manager.d.ts +5 -0
  610. package/dist/shared-context/manager.js +3 -3
  611. package/dist/signal.d.ts +1 -0
  612. package/dist/signal.js +1 -1
  613. package/dist/source-attribution.js +1 -1
  614. package/dist/state-store-4QZISH3J.js +30 -0
  615. package/dist/state-store-4QZISH3J.js.map +1 -0
  616. package/dist/storage-C4DX8CuG.d.ts +157 -0
  617. package/dist/storage.d.ts +2 -0
  618. package/dist/storage.js +7 -7
  619. package/dist/store-contract.js +1 -1
  620. package/dist/summarizer.d.ts +1 -0
  621. package/dist/summarizer.js +7 -7
  622. package/dist/summary-snapshot.d.ts +1 -0
  623. package/dist/surfaces/dreams.js +48 -17
  624. package/dist/surfaces/dreams.js.map +1 -1
  625. package/dist/temporal-supersession.d.ts +1 -0
  626. package/dist/temporal-supersession.js +1 -1
  627. package/dist/temporal-validity.d.ts +1 -0
  628. package/dist/threading.d.ts +1 -0
  629. package/dist/tier-migration.d.ts +1 -0
  630. package/dist/tier-routing.d.ts +1 -0
  631. package/dist/{tier-stats-62ZVDFKS.js → tier-stats-SKML2OSF.js} +5 -5
  632. package/dist/tmt.js +1 -1
  633. package/dist/tokens.js +2 -2
  634. package/dist/topics.d.ts +1 -0
  635. package/dist/{trace-C5ETWBEF.js → trace-WM7V4CKI.js} +31 -1
  636. package/dist/trace-WM7V4CKI.js.map +1 -0
  637. package/dist/transcript.d.ts +1 -0
  638. package/dist/transcript.js +2 -2
  639. package/dist/transfer/autodetect.js +7 -7
  640. package/dist/transfer/backup.js +5 -5
  641. package/dist/transfer/capsule-export.js +5 -5
  642. package/dist/transfer/capsule-import.d.ts +6 -0
  643. package/dist/transfer/capsule-import.js +4 -4
  644. package/dist/transfer/export-json.js +3 -3
  645. package/dist/transfer/export-md.js +3 -3
  646. package/dist/transfer/export-sqlite.js +3 -3
  647. package/dist/transfer/fs-utils.d.ts +2 -1
  648. package/dist/transfer/fs-utils.js +5 -3
  649. package/dist/transfer/import-json.js +3 -3
  650. package/dist/transfer/import-md.js +3 -3
  651. package/dist/transfer/import-sqlite.js +3 -3
  652. package/dist/trust-zones.js +2 -2
  653. package/dist/types-B1VHaf2w.d.ts +126 -0
  654. package/dist/types-BliCnURB.d.ts +83 -0
  655. package/dist/types.d.ts +35 -0
  656. package/dist/types.js +1 -1
  657. package/dist/utility-learner.js +3 -3
  658. package/dist/utility-runtime.d.ts +1 -0
  659. package/dist/utility-runtime.js +4 -4
  660. package/dist/utility-telemetry.js +2 -2
  661. package/dist/verified-recall.js +9 -9
  662. package/dist/work/board.js +2 -2
  663. package/dist/work/boundary.js +1 -1
  664. package/dist/work/storage.d.ts +5 -0
  665. package/dist/work/storage.js +1 -1
  666. package/dist/work-product-ledger.js +2 -2
  667. package/package.json +74 -3
  668. package/scripts/ensure-better-sqlite3.mjs +8 -7
  669. package/scripts/faiss_index.py +141 -29
  670. package/src/access-cli.test.ts +87 -2
  671. package/src/access-cli.ts +59 -5
  672. package/src/access-http.test.ts +150 -0
  673. package/src/access-http.ts +103 -34
  674. package/src/access-idempotency.ts +136 -3
  675. package/src/access-mcp.test.ts +155 -0
  676. package/src/access-mcp.ts +116 -30
  677. package/src/access-schema.ts +22 -4
  678. package/src/access-service-namespace.test.ts +9 -9
  679. package/src/access-service-project-tag.test.ts +37 -0
  680. package/src/access-service.ts +15 -14
  681. package/src/active-recall.test.ts +29 -1
  682. package/src/active-recall.ts +11 -7
  683. package/src/adapters/claude-code.ts +7 -8
  684. package/src/adapters/codex.ts +6 -7
  685. package/src/adapters/hermes.ts +1 -5
  686. package/src/adapters/registry.test.ts +63 -0
  687. package/src/adapters/registry.ts +10 -0
  688. package/src/adapters/replit.ts +5 -7
  689. package/src/adapters/types.ts +24 -1
  690. package/src/behavior-signals.ts +1 -1
  691. package/src/binary-lifecycle/backend.ts +16 -4
  692. package/src/binary-lifecycle/pipeline.test.ts +149 -0
  693. package/src/binary-lifecycle/pipeline.ts +49 -7
  694. package/src/binary-lifecycle/scanner.ts +19 -4
  695. package/src/boxes.ts +119 -32
  696. package/src/buffer-session.test.ts +28 -0
  697. package/src/buffer.ts +10 -14
  698. package/src/bulk-import/types.ts +10 -0
  699. package/src/calibration.test.ts +99 -0
  700. package/src/calibration.ts +57 -13
  701. package/src/causal-consolidation.test.ts +214 -0
  702. package/src/causal-consolidation.ts +131 -14
  703. package/src/causal-retrieval.ts +16 -3
  704. package/src/citations.test.ts +75 -0
  705. package/src/citations.ts +19 -6
  706. package/src/cli.ts +134 -109
  707. package/src/coding/coding-namespace.test.ts +7 -0
  708. package/src/coding/coding-namespace.ts +8 -0
  709. package/src/coding/review-context.test.ts +30 -0
  710. package/src/coding/review-context.ts +79 -9
  711. package/src/coding/wire-coding-context.test.ts +16 -0
  712. package/src/compat/checks.test.ts +33 -0
  713. package/src/compat/checks.ts +64 -4
  714. package/src/compounding/engine.ts +2 -2
  715. package/src/compounding/preference-consolidator.test.ts +47 -0
  716. package/src/compounding/preference-consolidator.ts +8 -8
  717. package/src/compression-optimizer.ts +5 -2
  718. package/src/config.test.ts +34 -2
  719. package/src/config.ts +62 -18
  720. package/src/connectors/codex-materialize-runner.ts +4 -3
  721. package/src/connectors/codex-materialize.ts +149 -34
  722. package/src/connectors/index.test.ts +144 -7
  723. package/src/connectors/index.ts +86 -15
  724. package/src/connectors/live/github.test.ts +47 -0
  725. package/src/connectors/live/github.ts +29 -1
  726. package/src/connectors/live/index.ts +2 -0
  727. package/src/connectors/live/live-connectors.test.ts +359 -73
  728. package/src/connectors/live/notion.test.ts +84 -0
  729. package/src/connectors/live/notion.ts +18 -1
  730. package/src/connectors/live/state-store.ts +419 -38
  731. package/src/connectors/weclone-installer.test.ts +16 -18
  732. package/src/connectors-cli.ts +19 -0
  733. package/src/console/trace.test.ts +28 -0
  734. package/src/console/trace.ts +42 -5
  735. package/src/contradiction/contradiction-judge.test.ts +49 -0
  736. package/src/contradiction/contradiction-judge.ts +15 -5
  737. package/src/contradiction/contradiction-review.ts +31 -7
  738. package/src/contradiction/contradiction-scan.ts +28 -18
  739. package/src/contradiction/contradiction.test.ts +237 -1
  740. package/src/contradiction/resolution.ts +43 -4
  741. package/src/conversation-index/backend.ts +13 -5
  742. package/src/conversation-index/cleanup.ts +25 -4
  743. package/src/conversation-index/faiss-adapter.ts +24 -15
  744. package/src/conversation-index/indexer.test.ts +71 -10
  745. package/src/conversation-index/indexer.ts +22 -3
  746. package/src/cross-namespace-budget.test.ts +59 -0
  747. package/src/cross-namespace-budget.ts +15 -7
  748. package/src/curation/index.ts +18 -17
  749. package/src/dashboard-runtime.test.ts +98 -0
  750. package/src/dashboard-runtime.ts +96 -6
  751. package/src/dedup/index.test.ts +133 -0
  752. package/src/dedup/index.ts +73 -10
  753. package/src/dedup/semantic.test.ts +77 -2
  754. package/src/dedup/semantic.ts +26 -6
  755. package/src/embedding-fallback.ts +47 -15
  756. package/src/enrichment/audit.ts +8 -1
  757. package/src/enrichment/pipeline.ts +21 -13
  758. package/src/enrichment/web-search-provider.ts +1 -6
  759. package/src/entity-retrieval.ts +57 -6
  760. package/src/evals.ts +22 -13
  761. package/src/explicit-capture.test.ts +40 -0
  762. package/src/explicit-capture.ts +14 -2
  763. package/src/extraction.ts +42 -30
  764. package/src/fallback-llm.ts +35 -2
  765. package/src/graph-dashboard-diff.test.ts +57 -0
  766. package/src/graph-dashboard-diff.ts +24 -2
  767. package/src/graph-dashboard-parser.test.ts +31 -0
  768. package/src/graph-dashboard-parser.ts +4 -1
  769. package/src/graph-events.ts +6 -4
  770. package/src/graph.test.ts +69 -0
  771. package/src/graph.ts +7 -4
  772. package/src/importers/base.test.ts +70 -0
  773. package/src/importers/base.ts +56 -7
  774. package/src/index.ts +5 -2
  775. package/src/lcm/archive.ts +65 -16
  776. package/src/lcm/engine.ts +27 -8
  777. package/src/lcm/recall.ts +5 -5
  778. package/src/lcm-engine.test.ts +87 -1
  779. package/src/lcm-recall.test.ts +71 -0
  780. package/src/live-connectors-runner.ts +100 -36
  781. package/src/maintenance/archive-observations.ts +24 -3
  782. package/src/maintenance/atomic-file.ts +85 -0
  783. package/src/maintenance/dreams-ledger.ts +15 -8
  784. package/src/maintenance/memory-governance.test.ts +53 -0
  785. package/src/maintenance/memory-governance.ts +15 -5
  786. package/src/maintenance/observation-ledger-utils.ts +6 -5
  787. package/src/maintenance/purge.test.ts +64 -0
  788. package/src/maintenance/rebuild-memory-lifecycle-ledger.ts +22 -9
  789. package/src/maintenance/rebuild-memory-projection.ts +22 -9
  790. package/src/maintenance/rebuild-observations.ts +7 -3
  791. package/src/mcp-memory-inspector-app.ts +26 -3
  792. package/src/memory-cache.test.ts +19 -0
  793. package/src/memory-cache.ts +1 -0
  794. package/src/memory-extension/codex-publisher.ts +25 -4
  795. package/src/memory-extension-host/host-discovery.test.ts +69 -0
  796. package/src/memory-extension-host/host-discovery.ts +63 -6
  797. package/src/memory-projection-store.ts +114 -62
  798. package/src/message-parts/index.ts +46 -31
  799. package/src/message-parts/message-parts.test.ts +77 -0
  800. package/src/migrate/from-engram.ts +68 -14
  801. package/src/model-registry.test.ts +38 -0
  802. package/src/model-registry.ts +12 -7
  803. package/src/namespaces/identity.test.ts +66 -0
  804. package/src/namespaces/identity.ts +23 -0
  805. package/src/namespaces/migrate.test.ts +62 -0
  806. package/src/namespaces/migrate.ts +82 -14
  807. package/src/namespaces/principal.test.ts +37 -1
  808. package/src/namespaces/principal.ts +18 -7
  809. package/src/namespaces/search.test.ts +96 -7
  810. package/src/namespaces/search.ts +32 -25
  811. package/src/namespaces/storage.ts +93 -11
  812. package/src/native-knowledge.ts +23 -3
  813. package/src/negative.ts +50 -5
  814. package/src/network/webdav.ts +177 -58
  815. package/src/offline-sync.test.ts +128 -18
  816. package/src/offline-sync.ts +41 -7
  817. package/src/onboarding/index.test.ts +105 -0
  818. package/src/onboarding/index.ts +17 -5
  819. package/src/operator-toolkit.ts +43 -5
  820. package/src/orchestrator.ts +120 -27
  821. package/src/page-versioning.ts +31 -5
  822. package/src/peers/peers.test.ts +70 -0
  823. package/src/peers/storage.ts +32 -3
  824. package/src/plugin-entry-resolver.test.ts +60 -0
  825. package/src/plugin-entry-resolver.ts +48 -0
  826. package/src/plugin-id.test.ts +38 -0
  827. package/src/plugin-id.ts +31 -64
  828. package/src/policy-runtime.test.ts +75 -0
  829. package/src/policy-runtime.ts +32 -3
  830. package/src/procedural/procedure-miner.test.ts +152 -0
  831. package/src/procedural/procedure-miner.ts +124 -19
  832. package/src/profiling.test.ts +23 -0
  833. package/src/profiling.ts +10 -1
  834. package/src/projection/index.test.ts +253 -0
  835. package/src/projection/index.ts +159 -18
  836. package/src/qmd-client.test.ts +45 -0
  837. package/src/qmd.ts +13 -10
  838. package/src/recall-disclosure.test.ts +15 -1
  839. package/src/recall-state.ts +24 -5
  840. package/src/relevance.ts +24 -5
  841. package/src/replay/normalizers/chatgpt.ts +14 -4
  842. package/src/replay/normalizers/claude.ts +8 -3
  843. package/src/replay/normalizers/openclaw.ts +35 -12
  844. package/src/replay/normalizers/replay-normalizers.test.ts +65 -0
  845. package/src/replay/normalizers/shared.ts +4 -1
  846. package/src/replay/runner.ts +1 -1
  847. package/src/rerank.test.ts +41 -1
  848. package/src/rerank.ts +2 -2
  849. package/src/resolve-auth-token.test.ts +29 -0
  850. package/src/resolve-auth-token.ts +12 -7
  851. package/src/resolve-provider-secret.test.ts +78 -22
  852. package/src/resolve-provider-secret.ts +55 -223
  853. package/src/retrieval-agents.ts +51 -14
  854. package/src/review/index.test.ts +75 -1
  855. package/src/review/index.ts +88 -30
  856. package/src/routing/store.ts +36 -6
  857. package/src/runtime/env.test.ts +73 -0
  858. package/src/runtime/env.ts +7 -11
  859. package/src/schemas.ts +16 -1
  860. package/src/search/abort.ts +18 -0
  861. package/src/search/document-scanner.test.ts +80 -0
  862. package/src/search/document-scanner.ts +51 -9
  863. package/src/search/embed-helper.ts +19 -6
  864. package/src/search/factory.ts +9 -5
  865. package/src/search/lancedb-backend.ts +66 -23
  866. package/src/search/meilisearch-backend.ts +39 -13
  867. package/src/search/noop-backend.ts +1 -1
  868. package/src/search/orama-backend.test.ts +27 -0
  869. package/src/search/orama-backend.ts +69 -16
  870. package/src/search/port.ts +4 -1
  871. package/src/search/remote-backend.ts +1 -1
  872. package/src/secure-store/cli-handlers.ts +70 -6
  873. package/src/secure-store/cli-renderer.ts +13 -7
  874. package/src/secure-store/secure-fs.ts +11 -5
  875. package/src/secure-store/secure-store.test.ts +70 -0
  876. package/src/semantic-consolidation.test.ts +45 -0
  877. package/src/semantic-consolidation.ts +3 -3
  878. package/src/session-integrity.test.ts +98 -0
  879. package/src/session-integrity.ts +51 -1
  880. package/src/session-observer-state.ts +108 -41
  881. package/src/shared-context/manager.ts +93 -15
  882. package/src/signal.test.ts +14 -0
  883. package/src/signal.ts +8 -1
  884. package/src/source-attribution.test.ts +8 -0
  885. package/src/source-attribution.ts +24 -2
  886. package/src/spaces/index.test.ts +93 -0
  887. package/src/spaces/index.ts +75 -9
  888. package/src/storage.ts +14 -1
  889. package/src/store-contract.test.ts +35 -0
  890. package/src/store-contract.ts +39 -5
  891. package/src/summarizer.ts +24 -18
  892. package/src/summary-snapshot.test.ts +77 -0
  893. package/src/surfaces/dreams.test.ts +73 -0
  894. package/src/surfaces/dreams.ts +53 -19
  895. package/src/sync/index.ts +42 -17
  896. package/src/taxonomy/taxonomy-loader.ts +43 -4
  897. package/src/temporal-supersession.test.ts +67 -0
  898. package/src/temporal-supersession.ts +8 -0
  899. package/src/tmt.test.ts +50 -0
  900. package/src/tmt.ts +35 -11
  901. package/src/tokens.test.ts +18 -0
  902. package/src/tokens.ts +7 -0
  903. package/src/training-export/converter.test.ts +55 -2
  904. package/src/training-export/converter.ts +36 -10
  905. package/src/training-export/registry.test.ts +17 -0
  906. package/src/training-export/registry.ts +19 -1
  907. package/src/transcript.ts +2 -2
  908. package/src/transfer/backup.ts +18 -7
  909. package/src/transfer/capsule-crypto.ts +105 -21
  910. package/src/transfer/capsule-encrypt.test.ts +106 -7
  911. package/src/transfer/capsule-export.ts +23 -14
  912. package/src/transfer/capsule-import.ts +11 -2
  913. package/src/transfer/exclusions.ts +7 -0
  914. package/src/transfer/export-sqlite.ts +14 -13
  915. package/src/transfer/fs-utils.ts +52 -1
  916. package/src/transfer/import-json.ts +12 -7
  917. package/src/transfer/import-md.ts +5 -5
  918. package/src/transfer/import-sqlite.ts +4 -5
  919. package/src/trust-zones.ts +1 -1
  920. package/src/types.ts +25 -0
  921. package/src/utility-telemetry.ts +1 -1
  922. package/src/utils/category-dir.test.ts +15 -0
  923. package/src/utils/category-dir.ts +3 -1
  924. package/src/work/boundary.ts +30 -18
  925. package/src/work/storage.ts +116 -38
  926. package/src/work-product-ledger.ts +1 -1
  927. package/dist/chunk-25MQ7IHJ.js.map +0 -1
  928. package/dist/chunk-2IWUMAES.js.map +0 -1
  929. package/dist/chunk-2NMMFZ5T.js.map +0 -1
  930. package/dist/chunk-2PRLKQAH.js.map +0 -1
  931. package/dist/chunk-326G7DJK.js.map +0 -1
  932. package/dist/chunk-3APJ5EVB.js.map +0 -1
  933. package/dist/chunk-3KW65B36.js.map +0 -1
  934. package/dist/chunk-3QKK7QOS.js.map +0 -1
  935. package/dist/chunk-3SLRNYNG.js.map +0 -1
  936. package/dist/chunk-3VAL7ZL2.js.map +0 -1
  937. package/dist/chunk-3Y4P7RXM.js.map +0 -1
  938. package/dist/chunk-3ZLVGM76.js.map +0 -1
  939. package/dist/chunk-43PJZYGL.js.map +0 -1
  940. package/dist/chunk-47VWKCAF.js.map +0 -1
  941. package/dist/chunk-4KGVTPGD.js.map +0 -1
  942. package/dist/chunk-5375UYTQ.js.map +0 -1
  943. package/dist/chunk-56K5QLHX.js.map +0 -1
  944. package/dist/chunk-575RMLWN.js.map +0 -1
  945. package/dist/chunk-5NPGSAVB.js.map +0 -1
  946. package/dist/chunk-5RGLBDQF.js.map +0 -1
  947. package/dist/chunk-65PG43EQ.js.map +0 -1
  948. package/dist/chunk-66DHUKLO.js.map +0 -1
  949. package/dist/chunk-6LVVDPJ4.js.map +0 -1
  950. package/dist/chunk-76FLAAUC.js.map +0 -1
  951. package/dist/chunk-77H5NU3M.js.map +0 -1
  952. package/dist/chunk-7MNMYOFP.js.map +0 -1
  953. package/dist/chunk-7OZ53EXP.js.map +0 -1
  954. package/dist/chunk-7SEAZFFB.js.map +0 -1
  955. package/dist/chunk-A6KTB5R6.js.map +0 -1
  956. package/dist/chunk-AGZQD76C.js.map +0 -1
  957. package/dist/chunk-APO3DCMU.js.map +0 -1
  958. package/dist/chunk-BVF3AGJP.js.map +0 -1
  959. package/dist/chunk-C5BCH4ZS.js.map +0 -1
  960. package/dist/chunk-C7VW7C3F.js.map +0 -1
  961. package/dist/chunk-CULXMQJH.js.map +0 -1
  962. package/dist/chunk-CYFQJMUV.js.map +0 -1
  963. package/dist/chunk-D654IBA6.js +0 -61
  964. package/dist/chunk-D654IBA6.js.map +0 -1
  965. package/dist/chunk-DGXUHMOV.js.map +0 -1
  966. package/dist/chunk-DINWEURR.js.map +0 -1
  967. package/dist/chunk-DK5LDEQM.js.map +0 -1
  968. package/dist/chunk-EABGC2TL.js.map +0 -1
  969. package/dist/chunk-EHRTFRWW.js.map +0 -1
  970. package/dist/chunk-EJI5XIBB.js.map +0 -1
  971. package/dist/chunk-FAAFWE4G.js.map +0 -1
  972. package/dist/chunk-FAJ7FZYM.js +0 -11
  973. package/dist/chunk-FAJ7FZYM.js.map +0 -1
  974. package/dist/chunk-FDU6HUUL.js +0 -147
  975. package/dist/chunk-FDU6HUUL.js.map +0 -1
  976. package/dist/chunk-FIT6DMX6.js.map +0 -1
  977. package/dist/chunk-FJ43PRLT.js.map +0 -1
  978. package/dist/chunk-FLTNHQK6.js +0 -262
  979. package/dist/chunk-FLTNHQK6.js.map +0 -1
  980. package/dist/chunk-GDFS42HT.js.map +0 -1
  981. package/dist/chunk-H3ME6L6D.js.map +0 -1
  982. package/dist/chunk-HXXBL2KD.js.map +0 -1
  983. package/dist/chunk-ICRIXAP2.js.map +0 -1
  984. package/dist/chunk-IQT3XTKW.js.map +0 -1
  985. package/dist/chunk-JR4ZC3G4.js.map +0 -1
  986. package/dist/chunk-K4FLSOR5.js.map +0 -1
  987. package/dist/chunk-KNKUID7G.js.map +0 -1
  988. package/dist/chunk-KOSORCJG.js.map +0 -1
  989. package/dist/chunk-LIRZNNUP.js.map +0 -1
  990. package/dist/chunk-LLQ2LLWF.js.map +0 -1
  991. package/dist/chunk-LPMVBPA3.js +0 -236
  992. package/dist/chunk-LPMVBPA3.js.map +0 -1
  993. package/dist/chunk-LT3NLYSI.js.map +0 -1
  994. package/dist/chunk-LUDTDZLK.js.map +0 -1
  995. package/dist/chunk-MJFNCJXV.js.map +0 -1
  996. package/dist/chunk-MSWG7JI6.js.map +0 -1
  997. package/dist/chunk-MXC3AP5I.js.map +0 -1
  998. package/dist/chunk-MXFBBHJU.js.map +0 -1
  999. package/dist/chunk-MZH6EHNR.js.map +0 -1
  1000. package/dist/chunk-N2D6GXBM.js.map +0 -1
  1001. package/dist/chunk-NBNN5GOB.js.map +0 -1
  1002. package/dist/chunk-NMZY542O.js.map +0 -1
  1003. package/dist/chunk-NZL6GGQE.js.map +0 -1
  1004. package/dist/chunk-OZHRDTDX.js.map +0 -1
  1005. package/dist/chunk-PIRJPV5T.js.map +0 -1
  1006. package/dist/chunk-PZIAX57I.js.map +0 -1
  1007. package/dist/chunk-Q7P4WJDP.js.map +0 -1
  1008. package/dist/chunk-QA2ZAPBU.js.map +0 -1
  1009. package/dist/chunk-QDZ2RLEC.js.map +0 -1
  1010. package/dist/chunk-QLLBRHAT.js.map +0 -1
  1011. package/dist/chunk-QR3C7BKQ.js.map +0 -1
  1012. package/dist/chunk-RHY3HH7P.js.map +0 -1
  1013. package/dist/chunk-RK2Y4XOM.js.map +0 -1
  1014. package/dist/chunk-RR2PKP3I.js +0 -63
  1015. package/dist/chunk-RR2PKP3I.js.map +0 -1
  1016. package/dist/chunk-RRF5UOBJ.js.map +0 -1
  1017. package/dist/chunk-RXDLTSWT.js.map +0 -1
  1018. package/dist/chunk-RYED3SPJ.js +0 -42
  1019. package/dist/chunk-RYED3SPJ.js.map +0 -1
  1020. package/dist/chunk-S7KDBTWT.js.map +0 -1
  1021. package/dist/chunk-TK4UEOSK.js.map +0 -1
  1022. package/dist/chunk-TMM4S4IJ.js.map +0 -1
  1023. package/dist/chunk-TMQLARTH.js.map +0 -1
  1024. package/dist/chunk-TPB3I2AC.js.map +0 -1
  1025. package/dist/chunk-TPMQ3G6Z.js.map +0 -1
  1026. package/dist/chunk-TPU5L5EY.js.map +0 -1
  1027. package/dist/chunk-TZOLIGIG.js.map +0 -1
  1028. package/dist/chunk-U3WSW6PZ.js.map +0 -1
  1029. package/dist/chunk-U4SCL7B7.js.map +0 -1
  1030. package/dist/chunk-U66YHYC7.js +0 -31
  1031. package/dist/chunk-U66YHYC7.js.map +0 -1
  1032. package/dist/chunk-U7EJOMFC.js.map +0 -1
  1033. package/dist/chunk-UWVJF25J.js.map +0 -1
  1034. package/dist/chunk-VBJ7V5SK.js.map +0 -1
  1035. package/dist/chunk-W3LR522O.js.map +0 -1
  1036. package/dist/chunk-W4L6CZKA.js.map +0 -1
  1037. package/dist/chunk-W6AQJ2PY.js.map +0 -1
  1038. package/dist/chunk-WELDCG6C.js.map +0 -1
  1039. package/dist/chunk-WNARATI3.js.map +0 -1
  1040. package/dist/chunk-WPGJYVUH.js.map +0 -1
  1041. package/dist/chunk-WW3QQF4H.js.map +0 -1
  1042. package/dist/chunk-XIG5PDM7.js.map +0 -1
  1043. package/dist/chunk-XKECPATV.js.map +0 -1
  1044. package/dist/chunk-XKLD5OK4.js.map +0 -1
  1045. package/dist/chunk-XSZEP4SF.js.map +0 -1
  1046. package/dist/chunk-XVVIG67A.js.map +0 -1
  1047. package/dist/chunk-XYIK4LF6.js.map +0 -1
  1048. package/dist/chunk-YRMVARQP.js.map +0 -1
  1049. package/dist/chunk-YROHKYBY.js.map +0 -1
  1050. package/dist/chunk-YU5KIWYQ.js.map +0 -1
  1051. package/dist/chunk-ZAVUCJ4H.js.map +0 -1
  1052. package/dist/chunk-ZPKBYX2F.js.map +0 -1
  1053. package/dist/chunk-ZTFCYYEZ.js.map +0 -1
  1054. package/dist/chunk-ZYVPLJ4T.js.map +0 -1
  1055. package/dist/path-MR5JPYOP.js +0 -9
  1056. package/dist/state-store-VZU2IA53.js +0 -16
  1057. package/dist/trace-C5ETWBEF.js.map +0 -1
  1058. /package/dist/{capsule-crypto-5CYAGVC5.js.map → bulk-import/index.js.map} +0 -0
  1059. /package/dist/{contradiction-review-ATP4S6IC.js.map → capsule-crypto-7FJQINUR.js.map} +0 -0
  1060. /package/dist/{capsule-merge-4MGKE7C5.js.map → capsule-merge-T2JRE46P.js.map} +0 -0
  1061. /package/dist/{chunk-SAZS2QZB.js.map → chunk-23UORJ4S.js.map} +0 -0
  1062. /package/dist/{chunk-PK7H5L6Y.js.map → chunk-2NM43EWN.js.map} +0 -0
  1063. /package/dist/{chunk-PYXS46O7.js.map → chunk-3BP57I6J.js.map} +0 -0
  1064. /package/dist/{chunk-FBYESMQ2.js.map → chunk-3C5RPJAX.js.map} +0 -0
  1065. /package/dist/{chunk-N53K2EXC.js.map → chunk-6VF75M3X.js.map} +0 -0
  1066. /package/dist/{chunk-6H2TESSP.js.map → chunk-765K3SAT.js.map} +0 -0
  1067. /package/dist/{chunk-EDTHC6UD.js.map → chunk-77NAFXUD.js.map} +0 -0
  1068. /package/dist/{chunk-MGKYQQYF.js.map → chunk-7Q3RCKAQ.js.map} +0 -0
  1069. /package/dist/{chunk-34DQE4KF.js.map → chunk-CO7ZO4TU.js.map} +0 -0
  1070. /package/dist/{chunk-ZKSK55RC.js.map → chunk-ETUPBUHB.js.map} +0 -0
  1071. /package/dist/{chunk-QRNI5JBH.js.map → chunk-EYIEWJNI.js.map} +0 -0
  1072. /package/dist/{chunk-C6QPK5GG.js.map → chunk-FZZ2QTJI.js.map} +0 -0
  1073. /package/dist/{chunk-3JXBXXM2.js.map → chunk-G4IAEX6D.js.map} +0 -0
  1074. /package/dist/{chunk-2WWLHTZY.js.map → chunk-IC4GELZE.js.map} +0 -0
  1075. /package/dist/{chunk-PCUKNJAZ.js.map → chunk-JKV57BTN.js.map} +0 -0
  1076. /package/dist/{chunk-2KI4QFHU.js.map → chunk-LMDRGRJ2.js.map} +0 -0
  1077. /package/dist/{chunk-MY6TPVXW.js.map → chunk-LMPHTYJC.js.map} +0 -0
  1078. /package/dist/{chunk-5HRY2WRF.js.map → chunk-LZ3VEOU5.js.map} +0 -0
  1079. /package/dist/{chunk-NGAVDO7E.js.map → chunk-OADWQ5CR.js.map} +0 -0
  1080. /package/dist/{chunk-DOM4GKSW.js.map → chunk-OZKVVUJB.js.map} +0 -0
  1081. /package/dist/{chunk-MT4HVDUZ.js.map → chunk-PM3QHTFT.js.map} +0 -0
  1082. /package/dist/{chunk-ZK7I7JYV.js.map → chunk-R3PS27B4.js.map} +0 -0
  1083. /package/dist/{chunk-SKE7JYKA.js.map → chunk-SFXKHM7P.js.map} +0 -0
  1084. /package/dist/{chunk-HMDCOMYU.js.map → chunk-SKGV326D.js.map} +0 -0
  1085. /package/dist/{chunk-5UM2VJ6D.js.map → chunk-UEY3VB6W.js.map} +0 -0
  1086. /package/dist/{chunk-GIF42EW3.js.map → chunk-UP6MOYCB.js.map} +0 -0
  1087. /package/dist/{chunk-MRILGULB.js.map → chunk-V2RCP53Q.js.map} +0 -0
  1088. /package/dist/{chunk-FSFEQI74.js.map → chunk-W7L6HXUC.js.map} +0 -0
  1089. /package/dist/{chunk-3IQ2TR4N.js.map → chunk-WLEB7WCG.js.map} +0 -0
  1090. /package/dist/{chunk-GL6I6MEQ.js.map → chunk-WSGF57U2.js.map} +0 -0
  1091. /package/dist/{chunk-JA3AK3PT.js.map → chunk-XNLXAWHX.js.map} +0 -0
  1092. /package/dist/{chunk-SIC6U3GZ.js.map → chunk-YHV3KRKS.js.map} +0 -0
  1093. /package/dist/{chunk-VLXA6PI2.js.map → chunk-YQMZ7IH2.js.map} +0 -0
  1094. /package/dist/{contradiction-scan-5A4IDZV5.js.map → contradiction-review-6V2LXXK6.js.map} +0 -0
  1095. /package/dist/{migrate-from-identity-anchor-G27MCD6A.js.map → contradiction-scan-GIRVC4C7.js.map} +0 -0
  1096. /package/dist/{first-start-migration-4MHQEOSD.js.map → first-start-migration-CKTCTCQI.js.map} +0 -0
  1097. /package/dist/{graph-edge-decay-5DI5GUNL.js.map → graph-edge-decay-MUP5J7CC.js.map} +0 -0
  1098. /package/dist/{path-MR5JPYOP.js.map → importers/index.js.map} +0 -0
  1099. /package/dist/{peers-HCVGHMAE.js.map → migrate-from-identity-anchor-EB4XI4Q2.js.map} +0 -0
  1100. /package/dist/{resolution-B7FNQSSP.js.map → path-X2K5XCHL.js.map} +0 -0
  1101. /package/dist/{state-store-VZU2IA53.js.map → peers/index.js.map} +0 -0
  1102. /package/dist/{tier-stats-62ZVDFKS.js.map → tier-stats-SKML2OSF.js.map} +0 -0
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./chunk-SKE7JYKA.js";
1
+ import "./chunk-SFXKHM7P.js";
2
2
  import {
3
3
  PEERS_DIR_NAME,
4
4
  PEER_ID_MAX_LENGTH,
@@ -11,7 +11,7 @@ import {
11
11
  readPeerProfile,
12
12
  writePeer,
13
13
  writePeerProfile
14
- } from "./chunk-4DWOBS2A.js";
14
+ } from "./chunk-PRQJ5ESM.js";
15
15
  import {
16
16
  EnrichmentProviderRegistry,
17
17
  WebSearchProvider,
@@ -19,7 +19,15 @@ import {
19
19
  defaultEnrichmentPipelineConfig,
20
20
  readAuditLog,
21
21
  runEnrichmentPipeline
22
- } from "./chunk-N2D6GXBM.js";
22
+ } from "./chunk-HINSGUA7.js";
23
+ import {
24
+ DEFAULT_IMPORT_BATCH_SIZE,
25
+ defaultWriteMemoriesToOrchestrator,
26
+ importedMemoryToTurn,
27
+ runImporter,
28
+ validateImportBatchSize,
29
+ validateImportRateLimit
30
+ } from "./chunk-LUDUFZTV.js";
23
31
  import {
24
32
  MARKETPLACE_MANIFEST_FILENAME,
25
33
  MARKETPLACE_SCHEMA_VERSION,
@@ -35,17 +43,17 @@ import {
35
43
  saveRegistry,
36
44
  validateMarketplaceManifest,
37
45
  writeMarketplaceManifest
38
- } from "./chunk-326G7DJK.js";
46
+ } from "./chunk-RW5DGAGO.js";
39
47
  import "./chunk-V5OCT34X.js";
40
48
  import {
41
49
  executeResolution,
42
50
  isValidResolutionVerb
43
- } from "./chunk-47VWKCAF.js";
51
+ } from "./chunk-XSQ4SGM5.js";
44
52
  import {
45
53
  ACTIVE_STATUSES,
46
54
  judgeContradictionPairs,
47
55
  runContradictionScan
48
- } from "./chunk-DK5LDEQM.js";
56
+ } from "./chunk-YR7XMOWK.js";
49
57
  import {
50
58
  computePairId,
51
59
  isCoolingDown,
@@ -54,7 +62,7 @@ import {
54
62
  resolvePair,
55
63
  writePair,
56
64
  writePairs
57
- } from "./chunk-APO3DCMU.js";
65
+ } from "./chunk-HLAVGJ62.js";
58
66
  import {
59
67
  generateToken,
60
68
  getAllValidTokens,
@@ -64,7 +72,7 @@ import {
64
72
  resolveConnectorFromToken,
65
73
  revokeToken,
66
74
  saveTokenStore
67
- } from "./chunk-MSWG7JI6.js";
75
+ } from "./chunk-G56P5RLD.js";
68
76
  import {
69
77
  runGraphRecall
70
78
  } from "./chunk-DGVM5SFL.js";
@@ -79,69 +87,75 @@ import {
79
87
  queryGraph
80
88
  } from "./chunk-64NJRYU2.js";
81
89
  import {
82
- clearBulkImportSources,
83
90
  clearTrainingExportAdapters,
84
91
  convertMemoriesToRecords,
85
- formatBatchTranscript,
86
- getBulkImportSource,
87
92
  getTrainingExportAdapter,
88
- isImportRole,
89
- listBulkImportSources,
90
93
  listTrainingExportAdapters,
91
- parseIsoTimestamp,
92
- registerBulkImportSource,
93
94
  registerTrainingExportAdapter,
94
- runBulkImportCliCommand,
95
- runBulkImportPipeline,
96
- validateImportTurn
97
- } from "./chunk-TPU5L5EY.js";
98
- import "./chunk-ICRIXAP2.js";
99
- import "./chunk-EHRTFRWW.js";
100
- import "./chunk-S7KDBTWT.js";
101
- import "./chunk-TZOLIGIG.js";
102
- import "./chunk-TK4UEOSK.js";
103
- import "./chunk-XKLD5OK4.js";
104
- import "./chunk-DOM4GKSW.js";
105
- import "./chunk-W4L6CZKA.js";
106
- import "./chunk-3JXBXXM2.js";
107
- import "./chunk-7OZ53EXP.js";
108
- import "./chunk-GIF42EW3.js";
109
- import "./chunk-6H2TESSP.js";
110
- import "./chunk-66DHUKLO.js";
95
+ runBulkImportCliCommand
96
+ } from "./chunk-FCOQXV3T.js";
97
+ import "./chunk-7F7Z6MOS.js";
98
+ import "./chunk-MC4FJXPA.js";
99
+ import "./chunk-LQHDIS7L.js";
100
+ import "./chunk-JJEJJ7RK.js";
101
+ import "./chunk-UP6MOYCB.js";
102
+ import "./chunk-XSWKORGM.js";
103
+ import "./chunk-HDDRVXX4.js";
104
+ import "./chunk-4RR6ROTB.js";
111
105
  import "./chunk-Z734BLO3.js";
106
+ import "./chunk-OZKVVUJB.js";
107
+ import "./chunk-2DL3OFLD.js";
108
+ import "./chunk-G4IAEX6D.js";
109
+ import "./chunk-2NLLXCJG.js";
110
+ import "./chunk-765K3SAT.js";
112
111
  import "./chunk-TKWGAOLV.js";
113
- import "./chunk-FIT6DMX6.js";
114
- import "./chunk-TPMQ3G6Z.js";
115
- import "./chunk-BVF3AGJP.js";
116
- import "./chunk-2IWUMAES.js";
117
- import "./chunk-PZIAX57I.js";
118
- import "./chunk-65PG43EQ.js";
112
+ import "./chunk-UWY7GIVS.js";
113
+ import "./chunk-HOJZMQ4J.js";
114
+ import "./chunk-2NM43EWN.js";
115
+ import "./chunk-LJBOVCQG.js";
116
+ import "./chunk-E62SBGQ3.js";
117
+ import "./chunk-XR6DNK4U.js";
118
+ import "./chunk-RUZOJKNF.js";
119
+ import "./chunk-S7WU3Y3D.js";
119
120
  import "./chunk-KJTKLXTH.js";
120
- import "./chunk-PK7H5L6Y.js";
121
- import "./chunk-LT3NLYSI.js";
122
- import "./chunk-TMM4S4IJ.js";
123
- import "./chunk-MRILGULB.js";
121
+ import {
122
+ clearBulkImportSources,
123
+ formatBatchTranscript,
124
+ getBulkImportSource,
125
+ listBulkImportSources,
126
+ registerBulkImportSource,
127
+ resolveBulkImportContext,
128
+ runBulkImportPipeline,
129
+ validateBatchSize
130
+ } from "./chunk-H2NCNXMS.js";
131
+ import {
132
+ isImportRole,
133
+ parseIsoTimestamp,
134
+ validateImportTurn
135
+ } from "./chunk-PU44GBL4.js";
136
+ import "./chunk-YR6GIWWY.js";
137
+ import "./chunk-V2RCP53Q.js";
138
+ import "./chunk-R3PS27B4.js";
124
139
  import {
125
140
  clearAuthTokenSecretCache,
126
141
  isAgentAccessSecretRef,
127
142
  resolveAgentAccessAuthToken
128
- } from "./chunk-MXC3AP5I.js";
129
- import "./chunk-ZK7I7JYV.js";
143
+ } from "./chunk-TGQ2NTWH.js";
130
144
  import {
131
145
  parseXrayBudgetFlag,
132
146
  parseXrayCliOptions
133
- } from "./chunk-MT4HVDUZ.js";
147
+ } from "./chunk-PM3QHTFT.js";
134
148
  import {
135
149
  parseStrictCliDate
136
150
  } from "./chunk-AJA46VX5.js";
137
- import "./chunk-W6AQJ2PY.js";
138
- import "./chunk-77H5NU3M.js";
151
+ import "./chunk-YNXOKMJP.js";
152
+ import "./chunk-6BR7L222.js";
139
153
  import "./chunk-HL4DB7TO.js";
140
- import "./chunk-ZPKBYX2F.js";
141
- import "./chunk-3SLRNYNG.js";
142
- import "./chunk-LIRZNNUP.js";
154
+ import "./chunk-YNDLCWXS.js";
155
+ import "./chunk-AUDJPF4N.js";
156
+ import "./chunk-44442YCH.js";
143
157
  import "./chunk-Y4Z4I6WK.js";
144
- import "./chunk-5HRY2WRF.js";
158
+ import "./chunk-LZ3VEOU5.js";
145
159
  import {
146
160
  reportBufferSurpriseDistribution
147
161
  } from "./chunk-YBPYIAA5.js";
@@ -152,88 +166,84 @@ import {
152
166
  import {
153
167
  getMemoryForActiveMemory,
154
168
  recallForActiveMemory
155
- } from "./chunk-2WWLHTZY.js";
169
+ } from "./chunk-IC4GELZE.js";
156
170
  import "./chunk-6MKAMLQL.js";
157
171
  import {
158
172
  DEFAULT_TAXONOMY,
159
173
  Orchestrator,
160
- branchNamespaceName,
161
174
  buildProcedureRecallSection,
162
175
  decideSemanticDedup,
163
176
  defaultWorkspaceDir,
164
- describeCodingScope,
165
177
  generateResolverDocument,
166
178
  getTaxonomyDir,
167
179
  getTaxonomyFilePath,
168
180
  loadTaxonomy,
169
- projectNamespaceName,
170
- resolveCodingNamespaceOverlay,
171
181
  sanitizeSessionKeyForFilename,
172
182
  saveTaxonomy,
173
183
  validateSlug,
174
184
  validateTaxonomy
175
- } from "./chunk-QLLBRHAT.js";
176
- import "./chunk-WNARATI3.js";
185
+ } from "./chunk-YDMVYYD2.js";
186
+ import "./chunk-Y2SXZ5KZ.js";
187
+ import "./chunk-BFBF3XEF.js";
177
188
  import {
178
189
  migrateFromEngram,
179
190
  rollbackFromEngramMigration
180
- } from "./chunk-KOSORCJG.js";
181
- import "./chunk-BFBF3XEF.js";
191
+ } from "./chunk-S53PKKWK.js";
182
192
  import "./chunk-HHLLAQGZ.js";
183
193
  import "./chunk-UWK5OXUJ.js";
184
- import "./chunk-2PRLKQAH.js";
194
+ import "./chunk-RLV3PQGH.js";
195
+ import "./chunk-TPDBFYEG.js";
196
+ import "./chunk-KCYE2MZM.js";
185
197
  import {
186
198
  applyLcmSchema,
187
199
  ensureLcmStateDir,
188
200
  openLcmDatabase
189
201
  } from "./chunk-7XYTQGCC.js";
190
- import "./chunk-34DQE4KF.js";
191
- import "./chunk-56K5QLHX.js";
202
+ import "./chunk-CO7ZO4TU.js";
203
+ import "./chunk-4HP7HIE3.js";
192
204
  import "./chunk-7N4KAIGN.js";
193
- import "./chunk-TPDBFYEG.js";
194
- import "./chunk-ZTFCYYEZ.js";
195
205
  import "./chunk-TECVW3JP.js";
196
- import "./chunk-RYED3SPJ.js";
197
- import "./chunk-A6KTB5R6.js";
198
- import "./chunk-U4SCL7B7.js";
206
+ import "./chunk-T2PO5MUF.js";
207
+ import "./chunk-IQ3OI2RR.js";
208
+ import "./chunk-DRD2Q7HQ.js";
199
209
  import "./chunk-UHGBNIOS.js";
200
- import "./chunk-FSFEQI74.js";
201
- import "./chunk-OIGNEXKZ.js";
210
+ import "./chunk-W7L6HXUC.js";
211
+ import "./chunk-K5O2QY6T.js";
202
212
  import "./chunk-MDYG7VI7.js";
203
213
  import "./chunk-Z5AAYHUC.js";
204
214
  import {
205
215
  computeTierValueScore,
206
216
  decideTierTransition
207
217
  } from "./chunk-S75M5ZRK.js";
208
- import "./chunk-TPB3I2AC.js";
209
- import "./chunk-H3ME6L6D.js";
218
+ import "./chunk-ECZU5BJH.js";
219
+ import "./chunk-46GJIW5M.js";
210
220
  import "./chunk-XJNBEDFE.js";
211
221
  import {
212
222
  buildTargetedFactRecallSection,
213
223
  shouldRecallTargetedFactEvidence
214
224
  } from "./chunk-VWT3F4IV.js";
215
- import "./chunk-JR4ZC3G4.js";
216
- import "./chunk-K4FLSOR5.js";
225
+ import "./chunk-DLJ4IR6M.js";
226
+ import "./chunk-USYGGIJZ.js";
217
227
  import "./chunk-V3RXWQIE.js";
218
228
  import "./chunk-5IZL4DCV.js";
219
229
  import "./chunk-X7XN6YU4.js";
220
- import "./chunk-5NPGSAVB.js";
221
- import "./chunk-C7VW7C3F.js";
230
+ import "./chunk-XEKAG3FM.js";
231
+ import "./chunk-TDKQGLJW.js";
222
232
  import {
223
233
  buildResponseGuidanceRecallSection,
224
234
  shouldRecallResponseGuidance
225
235
  } from "./chunk-OZKZ2TRP.js";
236
+ import "./chunk-YDBIWGNI.js";
226
237
  import "./chunk-7DHTMOND.js";
227
- import "./chunk-WPGJYVUH.js";
238
+ import "./chunk-MGVIEM2O.js";
239
+ import "./chunk-YCN4BVDK.js";
228
240
  import {
229
241
  DEFAULT_REASONING_TRACE_BOOST,
230
242
  applyReasoningTraceBoost,
231
243
  isReasoningTracePath,
232
244
  looksLikeProblemSolvingQuery
233
245
  } from "./chunk-ZZTOURJI.js";
234
- import "./chunk-YDBIWGNI.js";
235
- import "./chunk-YCN4BVDK.js";
236
- import "./chunk-D654IBA6.js";
246
+ import "./chunk-XKXKSQU7.js";
237
247
  import {
238
248
  applyMemoryWorthFilter,
239
249
  buildMemoryWorthCounterMap
@@ -245,7 +255,7 @@ import {
245
255
  builtInLiveConnectorDefinitions,
246
256
  hasEnabledLiveConnector,
247
257
  runLiveConnectorsOnce
248
- } from "./chunk-U3WSW6PZ.js";
258
+ } from "./chunk-QMYXNM4P.js";
249
259
  import "./chunk-H63EDPFJ.js";
250
260
  import {
251
261
  hasBroadGraphIntent,
@@ -268,21 +278,21 @@ import {
268
278
  } from "./chunk-C4SQJZAF.js";
269
279
  import {
270
280
  ExtractionEngine
271
- } from "./chunk-W3LR522O.js";
281
+ } from "./chunk-KM2A35EO.js";
272
282
  import "./chunk-4RA3C3EV.js";
273
- import "./chunk-WW3QQF4H.js";
283
+ import "./chunk-ROZJACKP.js";
274
284
  import "./chunk-54V4BZWP.js";
275
285
  import {
276
286
  ModelRegistry
277
- } from "./chunk-QR3C7BKQ.js";
278
- import "./chunk-EDTHC6UD.js";
287
+ } from "./chunk-XZ4WBBB5.js";
288
+ import "./chunk-77NAFXUD.js";
279
289
  import {
280
290
  buildFocusedListRecallSection,
281
291
  shouldRecallFocusedListEvidence
282
292
  } from "./chunk-DB5A3NHS.js";
283
293
  import {
284
294
  buildEntityRecallSection
285
- } from "./chunk-43PJZYGL.js";
295
+ } from "./chunk-FPGE5NVO.js";
286
296
  import {
287
297
  buildEventOrderRecallSection,
288
298
  shouldRecallEventOrderEvidence
@@ -305,7 +315,7 @@ import {
305
315
  import {
306
316
  buildExtensionsFooterForSummary,
307
317
  loadDaySummaryPrompt
308
- } from "./chunk-3IQ2TR4N.js";
318
+ } from "./chunk-WLEB7WCG.js";
309
319
  import "./chunk-VEWZZM3H.js";
310
320
  import {
311
321
  resolveCategory
@@ -314,72 +324,77 @@ import {
314
324
  FILTER_LABELS,
315
325
  isDirectAnswerEligible
316
326
  } from "./chunk-Y4FHOFJ2.js";
317
- import "./chunk-NMZY542O.js";
327
+ import "./chunk-6URPAY2D.js";
318
328
  import {
319
329
  CODEX_THREAD_KEY_PREFIX
320
330
  } from "./chunk-3PG3H5TD.js";
321
- import "./chunk-2NMMFZ5T.js";
331
+ import "./chunk-OD4FM2U7.js";
322
332
  import {
323
333
  buildExtensionsBlockForConsolidation
324
- } from "./chunk-XSZEP4SF.js";
334
+ } from "./chunk-6XSPNR6L.js";
325
335
  import {
326
336
  runCodexMaterialize,
327
337
  runPostConsolidationMaterialize
328
- } from "./chunk-4KGVTPGD.js";
338
+ } from "./chunk-6F6BXB7A.js";
329
339
  import {
330
340
  MATERIALIZE_VERSION,
331
341
  SENTINEL_FILE,
332
342
  describeMemoriesDir,
333
343
  ensureSentinel,
334
344
  materializeForNamespace
335
- } from "./chunk-RHY3HH7P.js";
345
+ } from "./chunk-JFEKNTX7.js";
336
346
  import {
337
347
  REMNIC_EXTENSIONS_TOTAL_TOKEN_LIMIT,
338
348
  discoverMemoryExtensions,
339
349
  renderExtensionsBlock,
340
350
  renderExtensionsFooter,
341
351
  resolveExtensionsRoot
342
- } from "./chunk-EJI5XIBB.js";
352
+ } from "./chunk-JLNBQWZ2.js";
353
+ import "./chunk-HPWVAEET.js";
343
354
  import "./chunk-2PRQG7PV.js";
344
- import "./chunk-LUDTDZLK.js";
345
- import "./chunk-JA3AK3PT.js";
346
- import "./chunk-PYXS46O7.js";
347
- import "./chunk-3QKK7QOS.js";
355
+ import "./chunk-XNLXAWHX.js";
356
+ import "./chunk-3BP57I6J.js";
357
+ import "./chunk-TERNBNJB.js";
348
358
  import "./chunk-W4RVMTHR.js";
349
- import "./chunk-SAZS2QZB.js";
350
- import "./chunk-CULXMQJH.js";
351
- import "./chunk-5375UYTQ.js";
359
+ import "./chunk-23UORJ4S.js";
360
+ import "./chunk-XPXEJRUB.js";
361
+ import "./chunk-A6D7A2FW.js";
352
362
  import "./chunk-FF4KLI5W.js";
353
- import "./chunk-EABGC2TL.js";
354
- import "./chunk-RR2PKP3I.js";
355
- import "./chunk-575RMLWN.js";
356
- import "./chunk-I5GLV3VE.js";
357
- import "./chunk-NJ3MJQZX.js";
358
- import {
359
- OramaBackend
360
- } from "./chunk-XVVIG67A.js";
361
- import "./chunk-PIRJPV5T.js";
362
- import "./chunk-RXDLTSWT.js";
363
+ import "./chunk-4426WSWL.js";
364
+ import "./chunk-A2Z6UCWT.js";
365
+ import "./chunk-KXULCVOC.js";
366
+ import "./chunk-SML26KED.js";
363
367
  import {
364
368
  LanceDbBackend
365
- } from "./chunk-3VAL7ZL2.js";
369
+ } from "./chunk-FUC4LZMD.js";
366
370
  import {
367
371
  MeilisearchBackend
368
- } from "./chunk-TMQLARTH.js";
369
- import "./chunk-MJFNCJXV.js";
370
- import "./chunk-CYFQJMUV.js";
372
+ } from "./chunk-FK556DDH.js";
373
+ import "./chunk-2I5JGH3M.js";
374
+ import {
375
+ OramaBackend
376
+ } from "./chunk-QVJ4NWL2.js";
377
+ import "./chunk-JNANKJLN.js";
378
+ import "./chunk-Q4CAQGKQ.js";
379
+ import "./chunk-ONPLNAPX.js";
380
+ import "./chunk-CINZGPSJ.js";
381
+ import {
382
+ ALL_CATEGORY_DIRS,
383
+ ALL_CATEGORY_KEYS,
384
+ getCategoryDir
385
+ } from "./chunk-CHBI22MI.js";
386
+ import "./chunk-ZFXCQPNO.js";
387
+ import "./chunk-KIB7SDIJ.js";
388
+ import "./chunk-ORFGK3XI.js";
389
+ import "./chunk-HENLZHIT.js";
371
390
  import "./chunk-7DTASS5T.js";
372
- import "./chunk-FJ43PRLT.js";
373
- import "./chunk-LLQ2LLWF.js";
374
- import "./chunk-YRMVARQP.js";
391
+ import "./chunk-KFY3SGN7.js";
375
392
  import {
376
393
  QmdClient
377
- } from "./chunk-3TNBOMQT.js";
394
+ } from "./chunk-PCI747N2.js";
378
395
  import {
379
- LEGACY_PLUGIN_ID,
380
- PLUGIN_ID,
381
- resolveRemnicPluginEntry
382
- } from "./chunk-U66YHYC7.js";
396
+ resolvePluginEntry
397
+ } from "./chunk-CMTINOFS.js";
383
398
  import {
384
399
  DEFAULT_POLL_INTERVAL_MS,
385
400
  GOOGLE_DRIVE_CONNECTOR_ID,
@@ -394,21 +409,21 @@ import {
394
409
  defaultGoogleDriveClientFactory,
395
410
  validateGoogleDriveConfig,
396
411
  validateNotionConfig
397
- } from "./chunk-HXXBL2KD.js";
412
+ } from "./chunk-BECQDWBA.js";
398
413
  import {
399
414
  CONNECTOR_ID_PATTERN,
400
415
  isValidConnectorId,
401
416
  listConnectorStates,
402
417
  readConnectorState,
403
418
  writeConnectorState
404
- } from "./chunk-LPMVBPA3.js";
419
+ } from "./chunk-CWWMTTQE.js";
405
420
  import "./chunk-JXS5PDQ7.js";
406
- import "./chunk-HMDCOMYU.js";
407
- import "./chunk-7SEAZFFB.js";
408
- import "./chunk-D46YSIYX.js";
421
+ import "./chunk-SKGV326D.js";
422
+ import "./chunk-BEUDU7Y4.js";
423
+ import "./chunk-G3Z3QEF5.js";
409
424
  import "./chunk-AJU4PJGY.js";
410
- import "./chunk-C6QPK5GG.js";
411
- import "./chunk-2KI4QFHU.js";
425
+ import "./chunk-FZZ2QTJI.js";
426
+ import "./chunk-LMDRGRJ2.js";
412
427
  import {
413
428
  CONNECTORS_OUTPUT_FORMATS,
414
429
  parseConnectorsFormat,
@@ -418,17 +433,17 @@ import {
418
433
  renderConnectorsList,
419
434
  renderConnectorsRunResult,
420
435
  runConnectorPollOnce
421
- } from "./chunk-OZHRDTDX.js";
436
+ } from "./chunk-OKTXM5H4.js";
422
437
  import "./chunk-3UXOZBHV.js";
423
438
  import "./chunk-KVE7R4CG.js";
424
439
  import "./chunk-4WMCPJWX.js";
425
440
  import {
426
441
  SmartBuffer
427
- } from "./chunk-5RGLBDQF.js";
442
+ } from "./chunk-EVZFIAPG.js";
428
443
  import {
429
444
  FallbackLlmClient
430
- } from "./chunk-DINWEURR.js";
431
- import "./chunk-FLTNHQK6.js";
445
+ } from "./chunk-CSKLPDN6.js";
446
+ import "./chunk-B5XMS73R.js";
432
447
  import "./chunk-7SI52C65.js";
433
448
  import "./chunk-L2EXJQJP.js";
434
449
  import "./chunk-UZB5KHKX.js";
@@ -439,33 +454,33 @@ import {
439
454
  isOpenaiApiKeyDisabled,
440
455
  parseConfig,
441
456
  resolveEnvVars
442
- } from "./chunk-MZH6EHNR.js";
457
+ } from "./chunk-7H6CFEBJ.js";
443
458
  import {
444
459
  coerceInstallExtension
445
460
  } from "./chunk-PHK3HARR.js";
446
461
  import "./chunk-Z5LAYHGJ.js";
447
462
  import "./chunk-6HZ6AO2P.js";
448
- import "./chunk-JWPLJLDU.js";
463
+ import "./chunk-KD3QD3A5.js";
449
464
  import {
450
465
  BootstrapEngine
451
- } from "./chunk-N53K2EXC.js";
452
- import "./chunk-XYIK4LF6.js";
453
- import "./chunk-NZL6GGQE.js";
466
+ } from "./chunk-6VF75M3X.js";
467
+ import "./chunk-H3FZVNRN.js";
468
+ import "./chunk-HQ6NIBL6.js";
454
469
  import "./chunk-PVGDJXVK.js";
455
- import "./chunk-NGAVDO7E.js";
470
+ import "./chunk-OADWQ5CR.js";
456
471
  import {
457
472
  EngramAccessHttpServer
458
- } from "./chunk-YU5KIWYQ.js";
473
+ } from "./chunk-HC6EKOID.js";
459
474
  import "./chunk-SEDEKFYQ.js";
460
- import "./chunk-6FC5EGNV.js";
461
- import "./chunk-3Y4P7RXM.js";
462
- import "./chunk-6LVVDPJ4.js";
463
- import "./chunk-7MNMYOFP.js";
464
- import "./chunk-FKFMOY3N.js";
465
- import "./chunk-FAJ7FZYM.js";
475
+ import "./chunk-JBPKEARU.js";
476
+ import "./chunk-TMSXWOBZ.js";
477
+ import "./chunk-J64TK33U.js";
478
+ import "./chunk-RSUYKGGZ.js";
479
+ import "./chunk-42NQ7AVG.js";
480
+ import "./chunk-7RXCMVFQ.js";
466
481
  import {
467
482
  EngramMcpServer
468
- } from "./chunk-3ZLVGM76.js";
483
+ } from "./chunk-TTGZV5R3.js";
469
484
  import {
470
485
  REMNIC_CHATGPT_MEMORY_INSPECTOR_CANONICAL_TOOL,
471
486
  REMNIC_CHATGPT_MEMORY_INSPECTOR_MIME_TYPE,
@@ -474,24 +489,24 @@ import {
474
489
  REMNIC_CHATGPT_MEMORY_INSPECTOR_WIDGET_URI,
475
490
  buildChatGptMemoryInspectorActionRequest,
476
491
  buildChatGptMemoryInspectorResult
477
- } from "./chunk-C5BCH4ZS.js";
492
+ } from "./chunk-EAZGEEG2.js";
478
493
  import {
479
494
  buildCitationGuidance,
480
495
  formatOaiMemCitation,
481
496
  parseOaiMemCitation,
482
497
  sanitizeNoteForCitation
483
- } from "./chunk-IQT3XTKW.js";
498
+ } from "./chunk-D24OXEPB.js";
484
499
  import {
485
500
  EngramAccessInputError,
486
501
  EngramAccessService,
487
502
  computeProcedureStats,
488
503
  formatProcedureStatsText
489
- } from "./chunk-ZAVUCJ4H.js";
490
- import "./chunk-ZKSK55RC.js";
491
- import "./chunk-WELDCG6C.js";
504
+ } from "./chunk-5V456VRV.js";
505
+ import "./chunk-ETUPBUHB.js";
506
+ import "./chunk-L227SKTB.js";
492
507
  import {
493
508
  importCapsule
494
- } from "./chunk-ZYVPLJ4T.js";
509
+ } from "./chunk-DHGSZ3UD.js";
495
510
  import "./chunk-BT7NVCML.js";
496
511
  import "./chunk-H7XKCNR6.js";
497
512
  import {
@@ -501,18 +516,22 @@ import {
501
516
  renderXrayJson,
502
517
  renderXrayMarkdown,
503
518
  renderXrayText
504
- } from "./chunk-FBYESMQ2.js";
519
+ } from "./chunk-3C5RPJAX.js";
505
520
  import "./chunk-SOBJ6NEY.js";
506
521
  import {
522
+ branchNamespaceName,
523
+ describeCodingScope,
507
524
  normalizeOriginUrl,
525
+ projectNamespaceName,
526
+ resolveCodingNamespaceOverlay,
508
527
  resolveGitContext,
509
528
  stableHash
510
- } from "./chunk-FDU6HUUL.js";
529
+ } from "./chunk-EDQVAMQI.js";
511
530
  import {
512
531
  isTrustZoneName
513
- } from "./chunk-QDZ2RLEC.js";
514
- import "./chunk-MGKYQQYF.js";
515
- import "./chunk-GL6I6MEQ.js";
532
+ } from "./chunk-472U7RDF.js";
533
+ import "./chunk-7Q3RCKAQ.js";
534
+ import "./chunk-WSGF57U2.js";
516
535
  import {
517
536
  isLcmMessagePartKind,
518
537
  normalizeExplicitParts,
@@ -522,30 +541,29 @@ import {
522
541
  parseOpenClawMessageParts,
523
542
  parsePiMessageParts,
524
543
  partsFromRenderedText
525
- } from "./chunk-3APJ5EVB.js";
526
- import "./chunk-5UM2VJ6D.js";
527
- import "./chunk-76FLAAUC.js";
544
+ } from "./chunk-XKIQZXUB.js";
545
+ import "./chunk-UEY3VB6W.js";
546
+ import "./chunk-2AN2L4NL.js";
528
547
  import {
529
548
  memoryWorthOutcomeEligibleCategories,
530
549
  recordMemoryOutcome
531
550
  } from "./chunk-EIR5VLIH.js";
532
- import "./chunk-PCUKNJAZ.js";
533
- import "./chunk-RRF5UOBJ.js";
534
- import "./chunk-NBNN5GOB.js";
551
+ import "./chunk-JKV57BTN.js";
552
+ import "./chunk-EI6V5UXY.js";
553
+ import "./chunk-QY7YA7OL.js";
535
554
  import "./chunk-NNVTUXEB.js";
536
555
  import {
537
556
  buildProcedureMarkdownBody,
538
557
  parseProcedureStepsFromBody
539
558
  } from "./chunk-QDW3E4RD.js";
540
- import "./chunk-25MQ7IHJ.js";
559
+ import "./chunk-EUML3N6B.js";
541
560
  import {
542
561
  CrossNamespaceBudget,
543
562
  DEFAULT_CROSS_NAMESPACE_BUDGET
544
- } from "./chunk-GDFS42HT.js";
545
- import "./chunk-U3PN77QT.js";
546
- import "./chunk-RK2Y4XOM.js";
563
+ } from "./chunk-CHCA44C3.js";
564
+ import "./chunk-4JRRISLU.js";
547
565
  import "./chunk-2LSZVONP.js";
548
- import "./chunk-WIICJPET.js";
566
+ import "./chunk-DEUNUKTD.js";
549
567
  import {
550
568
  BRIEFING_FORMAT_ALLOWED,
551
569
  FileCalendarSource,
@@ -558,12 +576,12 @@ import {
558
576
  renderBriefingMarkdown,
559
577
  resolveBriefingSaveDir,
560
578
  validateBriefingFormat
561
- } from "./chunk-SIC6U3GZ.js";
579
+ } from "./chunk-YHV3KRKS.js";
562
580
  import {
563
581
  StorageManager,
564
582
  parseEntityFile,
565
583
  serializeEntityFile
566
- } from "./chunk-VBJ7V5SK.js";
584
+ } from "./chunk-UIPDNLXA.js";
567
585
  import "./chunk-5UZXUTVO.js";
568
586
  import {
569
587
  CITATION_UNKNOWN,
@@ -575,19 +593,19 @@ import {
575
593
  parseAllCitations,
576
594
  parseCitation,
577
595
  stripCitation
578
- } from "./chunk-NN2DKE4T.js";
596
+ } from "./chunk-4H5ZJHEN.js";
579
597
  import {
580
598
  DEFAULT_RECALL_DISCLOSURE,
581
599
  RECALL_DISCLOSURE_LEVELS,
582
600
  isRecallDisclosure
583
- } from "./chunk-Q7P4WJDP.js";
601
+ } from "./chunk-M5T4Q2ZU.js";
584
602
  import {
585
603
  normalizeProjectionPreview,
586
604
  normalizeProjectionTags
587
605
  } from "./chunk-SCU65EZI.js";
588
- import "./chunk-3KW65B36.js";
606
+ import "./chunk-KILOTVIF.js";
589
607
  import "./chunk-3HPAPHUK.js";
590
- import "./chunk-PFV5C235.js";
608
+ import "./chunk-CPPS65WS.js";
591
609
  import "./chunk-RULE4VG5.js";
592
610
  import "./chunk-DM2T26WE.js";
593
611
  import "./chunk-QSVPYQPG.js";
@@ -599,27 +617,28 @@ import {
599
617
  getVersion,
600
618
  listVersions,
601
619
  revertToVersion
602
- } from "./chunk-FAAFWE4G.js";
603
- import {
604
- expandTildePath
605
- } from "./chunk-QRNI5JBH.js";
620
+ } from "./chunk-ALEPI75L.js";
606
621
  import "./chunk-ZY2MNJR6.js";
607
- import "./chunk-MY6TPVXW.js";
622
+ import "./chunk-LMPHTYJC.js";
608
623
  import "./chunk-DT5TVLJE.js";
609
624
  import {
610
625
  resolvePrincipal
611
- } from "./chunk-UWVJF25J.js";
626
+ } from "./chunk-HWVTS5NO.js";
627
+ import "./chunk-U3PN77QT.js";
612
628
  import "./chunk-4DJQYKMN.js";
629
+ import {
630
+ expandTildePath
631
+ } from "./chunk-EYIEWJNI.js";
613
632
  import {
614
633
  readEnvVar,
615
634
  resolveHomeDir
616
- } from "./chunk-XIG5PDM7.js";
635
+ } from "./chunk-JUC24CTX.js";
617
636
  import "./chunk-TBBDFYXW.js";
618
637
  import {
619
638
  initLogger,
620
639
  log
621
640
  } from "./chunk-2ODBA7MQ.js";
622
- import "./chunk-DGXUHMOV.js";
641
+ import "./chunk-A2IYSXDQ.js";
623
642
  import "./chunk-LPSF4OQH.js";
624
643
  import {
625
644
  AccessAuditAdapter
@@ -630,7 +649,7 @@ import {
630
649
  normalizeQueryText
631
650
  } from "./chunk-RFYAYKTD.js";
632
651
  import "./chunk-LBLXEFWK.js";
633
- import "./chunk-XKECPATV.js";
652
+ import "./chunk-VFUEZZBS.js";
634
653
  import {
635
654
  formatZodError,
636
655
  memoryStoreRequestSchema,
@@ -638,13 +657,13 @@ import {
638
657
  recallRequestSchema,
639
658
  suggestionSubmitRequestSchema,
640
659
  validateRequest
641
- } from "./chunk-YROHKYBY.js";
642
- import "./chunk-QA2ZAPBU.js";
660
+ } from "./chunk-5UHVGNZD.js";
661
+ import "./chunk-IPLYGWQF.js";
662
+ import "./chunk-J4EB7DNW.js";
643
663
  import {
644
664
  CAPSULE_ID_PATTERN
645
665
  } from "./chunk-WEHSQBFR.js";
646
- import "./chunk-KNKUID7G.js";
647
- import "./chunk-J4EB7DNW.js";
666
+ import "./chunk-X7Y7WX73.js";
648
667
  import "./chunk-BJMBJZ2Y.js";
649
668
  import "./chunk-UKJAGEXH.js";
650
669
  import "./chunk-FP2373TW.js";
@@ -677,13 +696,13 @@ import {
677
696
  summarizeOfflineSyncPendingChanges,
678
697
  summarizeOfflineSyncPendingFiles,
679
698
  writeOfflineSyncState
680
- } from "./chunk-U7EJOMFC.js";
681
- import "./chunk-I6K5FBRQ.js";
699
+ } from "./chunk-ZEY4KYRQ.js";
700
+ import "./chunk-UI3NYK34.js";
682
701
  import {
683
702
  assertIsDirectoryNotSymlink,
684
703
  assertRealpathInsideRoot
685
- } from "./chunk-AGZQD76C.js";
686
- import "./chunk-MXFBBHJU.js";
704
+ } from "./chunk-GCGJW34D.js";
705
+ import "./chunk-KJMYHC7K.js";
687
706
  import "./chunk-A6XUJE5D.js";
688
707
  import {
689
708
  parseFlexibleIsoTimestamp,
@@ -814,13 +833,80 @@ function splitDiffGitPaths(rest) {
814
833
  function stripDiffPathPrefix(raw) {
815
834
  let s = raw;
816
835
  if (s.length >= 2 && s[0] === '"' && s[s.length - 1] === '"') {
817
- s = s.slice(1, -1);
818
- s = s.replace(/\\(["\\])/g, "$1");
836
+ const decoded = decodeGitCQuotedPath(s.slice(1, -1));
837
+ if (decoded === null) {
838
+ return raw;
839
+ }
840
+ s = decoded;
819
841
  }
820
842
  s = s.replace(/\\/g, "/");
821
843
  if (s.startsWith("a/") || s.startsWith("b/")) s = s.slice(2);
822
844
  return s;
823
845
  }
846
+ function decodeGitCQuotedPath(value) {
847
+ const bytes = [];
848
+ const encoder = new TextEncoder();
849
+ const appendText = (text) => {
850
+ bytes.push(...encoder.encode(text));
851
+ };
852
+ for (let index = 0; index < value.length; index += 1) {
853
+ const char = value[index];
854
+ if (char !== "\\") {
855
+ appendText(char);
856
+ continue;
857
+ }
858
+ if (index + 1 >= value.length) {
859
+ appendText("\\");
860
+ continue;
861
+ }
862
+ const next = value[index + 1];
863
+ if (next >= "0" && next <= "7") {
864
+ let octal = next;
865
+ let cursor = index + 2;
866
+ while (cursor < value.length && octal.length < 3) {
867
+ const digit = value[cursor];
868
+ if (digit < "0" || digit > "7") break;
869
+ octal += digit;
870
+ cursor += 1;
871
+ }
872
+ bytes.push(Number.parseInt(octal, 8));
873
+ index = cursor - 1;
874
+ continue;
875
+ }
876
+ const escaped = cEscapeValue(next);
877
+ if (escaped !== null) {
878
+ appendText(escaped);
879
+ index += 1;
880
+ continue;
881
+ }
882
+ appendText(`\\${next}`);
883
+ index += 1;
884
+ }
885
+ try {
886
+ return new TextDecoder("utf-8", { fatal: true }).decode(Uint8Array.from(bytes));
887
+ } catch {
888
+ return null;
889
+ }
890
+ }
891
+ function cEscapeValue(value) {
892
+ switch (value) {
893
+ case "n":
894
+ return "\n";
895
+ case "t":
896
+ return " ";
897
+ case "r":
898
+ return "\r";
899
+ case "b":
900
+ return "\b";
901
+ case "f":
902
+ return "\f";
903
+ case "\\":
904
+ case '"':
905
+ return value;
906
+ default:
907
+ return null;
908
+ }
909
+ }
824
910
  var BOOST_PER_MATCH = 0.5;
825
911
  var MAX_BOOST = 1;
826
912
  function countPathHits(entityRefs, touchedFiles) {
@@ -891,17 +977,28 @@ var FilesystemBackend = class {
891
977
  if (!basePath || basePath.trim().length === 0) {
892
978
  throw new Error("FilesystemBackend requires a non-empty basePath");
893
979
  }
894
- this.basePath = basePath;
980
+ this.basePath = path.resolve(basePath);
981
+ }
982
+ resolveRemotePath(remotePath) {
983
+ if (path.isAbsolute(remotePath)) {
984
+ throw new Error(`FilesystemBackend remotePath must be relative: ${JSON.stringify(remotePath)}`);
985
+ }
986
+ const resolved = path.resolve(this.basePath, remotePath);
987
+ const relative = path.relative(this.basePath, resolved);
988
+ if (relative === ".." || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)) {
989
+ throw new Error(`FilesystemBackend remotePath escapes basePath: ${JSON.stringify(remotePath)}`);
990
+ }
991
+ return resolved;
895
992
  }
896
993
  async upload(localPath, remotePath) {
897
- const dest = path.join(this.basePath, remotePath);
994
+ const dest = this.resolveRemotePath(remotePath);
898
995
  const destDir = path.dirname(dest);
899
996
  await fsp.mkdir(destDir, { recursive: true });
900
997
  await fsp.copyFile(localPath, dest);
901
998
  return dest;
902
999
  }
903
1000
  async exists(remotePath) {
904
- const dest = path.join(this.basePath, remotePath);
1001
+ const dest = this.resolveRemotePath(remotePath);
905
1002
  try {
906
1003
  await fsp.access(dest, fs.constants.F_OK);
907
1004
  return true;
@@ -910,7 +1007,7 @@ var FilesystemBackend = class {
910
1007
  }
911
1008
  }
912
1009
  async delete(remotePath) {
913
- const dest = path.join(this.basePath, remotePath);
1010
+ const dest = this.resolveRemotePath(remotePath);
914
1011
  try {
915
1012
  await fsp.unlink(dest);
916
1013
  } catch (err) {
@@ -951,6 +1048,7 @@ function createBackend(cfg) {
951
1048
  // src/binary-lifecycle/scanner.ts
952
1049
  import fsp2 from "fs/promises";
953
1050
  import path2 from "path";
1051
+ import crypto from "crypto";
954
1052
  function matchesPatterns(filename, patterns) {
955
1053
  const lower = filename.toLowerCase();
956
1054
  for (const pattern of patterns) {
@@ -964,7 +1062,7 @@ function matchesPatterns(filename, patterns) {
964
1062
  return false;
965
1063
  }
966
1064
  async function scanForBinaries(memoryDir, config, manifest) {
967
- const tracked = new Set(manifest.assets.map((a) => a.originalPath));
1065
+ const tracked = new Map(manifest.assets.map((a) => [a.originalPath, a]));
968
1066
  const results = [];
969
1067
  async function walk(dir) {
970
1068
  let entries;
@@ -983,11 +1081,22 @@ async function scanForBinaries(memoryDir, config, manifest) {
983
1081
  }
984
1082
  if (!entry.isFile()) continue;
985
1083
  if (!matchesPatterns(entry.name, config.scanPatterns)) continue;
986
- if (tracked.has(relativePath)) continue;
987
1084
  try {
988
1085
  const stat = await fsp2.stat(fullPath);
989
1086
  if (stat.size > config.maxBinarySizeBytes) continue;
990
1087
  if (stat.size === 0) continue;
1088
+ const existing = tracked.get(relativePath);
1089
+ if (existing) {
1090
+ if (existing.sizeBytes !== stat.size) {
1091
+ results.push(relativePath);
1092
+ continue;
1093
+ }
1094
+ const contentHash = await hashFile(fullPath);
1095
+ if (existing.contentHash !== contentHash) {
1096
+ results.push(relativePath);
1097
+ }
1098
+ continue;
1099
+ }
991
1100
  } catch {
992
1101
  continue;
993
1102
  }
@@ -997,11 +1106,15 @@ async function scanForBinaries(memoryDir, config, manifest) {
997
1106
  await walk(memoryDir);
998
1107
  return results;
999
1108
  }
1109
+ async function hashFile(filePath) {
1110
+ const content = await fsp2.readFile(filePath);
1111
+ return crypto.createHash("sha256").update(content).digest("hex");
1112
+ }
1000
1113
 
1001
1114
  // src/binary-lifecycle/manifest.ts
1002
1115
  import fsp3 from "fs/promises";
1003
1116
  import path3 from "path";
1004
- import crypto from "crypto";
1117
+ import crypto2 from "crypto";
1005
1118
  var MANIFEST_DIR = ".binary-lifecycle";
1006
1119
  var MANIFEST_FILE = "manifest.json";
1007
1120
  function manifestDir(memoryDir) {
@@ -1031,7 +1144,7 @@ async function writeManifest(memoryDir, manifest) {
1031
1144
  const dir = manifestDir(memoryDir);
1032
1145
  await fsp3.mkdir(dir, { recursive: true });
1033
1146
  const dest = manifestPath(memoryDir);
1034
- const tmpSuffix = crypto.randomBytes(8).toString("hex");
1147
+ const tmpSuffix = crypto2.randomBytes(8).toString("hex");
1035
1148
  const tmpPath = `${dest}.${tmpSuffix}.tmp`;
1036
1149
  const content = JSON.stringify(manifest, null, 2) + "\n";
1037
1150
  await fsp3.writeFile(tmpPath, content, "utf-8");
@@ -1052,10 +1165,10 @@ function emptyManifest() {
1052
1165
  // src/binary-lifecycle/pipeline.ts
1053
1166
  import fsp4 from "fs/promises";
1054
1167
  import path4 from "path";
1055
- import crypto2 from "crypto";
1056
- async function hashFile(filePath) {
1168
+ import crypto3 from "crypto";
1169
+ async function hashFile2(filePath) {
1057
1170
  const content = await fsp4.readFile(filePath);
1058
- return crypto2.createHash("sha256").update(content).digest("hex");
1171
+ return crypto3.createHash("sha256").update(content).digest("hex");
1059
1172
  }
1060
1173
  function guessMimeType(ext) {
1061
1174
  const map = {
@@ -1073,6 +1186,11 @@ function guessMimeType(ext) {
1073
1186
  function escapeRegex(s) {
1074
1187
  return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1075
1188
  }
1189
+ function validateBinaryLifecycleConfig(config) {
1190
+ if (typeof config.gracePeriodDays !== "number" || !Number.isFinite(config.gracePeriodDays) || !Number.isInteger(config.gracePeriodDays) || config.gracePeriodDays < 0) {
1191
+ throw new Error("binary lifecycle gracePeriodDays must be a finite non-negative integer");
1192
+ }
1193
+ }
1076
1194
  async function stageMirror(memoryDir, newPaths, backend, assets, log2, dryRun) {
1077
1195
  let mirrored = 0;
1078
1196
  const errors = [];
@@ -1080,7 +1198,7 @@ async function stageMirror(memoryDir, newPaths, backend, assets, log2, dryRun) {
1080
1198
  const fullPath = path4.join(memoryDir, relPath);
1081
1199
  try {
1082
1200
  const stat = await fsp4.stat(fullPath);
1083
- const contentHash = await hashFile(fullPath);
1201
+ const contentHash = await hashFile2(fullPath);
1084
1202
  const ext = path4.extname(relPath);
1085
1203
  const mimeType = guessMimeType(ext);
1086
1204
  const remotePath = relPath;
@@ -1097,7 +1215,13 @@ async function stageMirror(memoryDir, newPaths, backend, assets, log2, dryRun) {
1097
1215
  mirroredAt: (/* @__PURE__ */ new Date()).toISOString(),
1098
1216
  status: "mirrored"
1099
1217
  };
1100
- assets.push(record);
1218
+ if (!dryRun) {
1219
+ const existingIndex = assets.findIndex((asset) => asset.originalPath === relPath);
1220
+ if (existingIndex >= 0) {
1221
+ assets.splice(existingIndex, 1);
1222
+ }
1223
+ assets.push(record);
1224
+ }
1101
1225
  mirrored++;
1102
1226
  log2.info(`[binary-lifecycle] mirrored: ${relPath} (${stat.size} bytes)${dryRun ? " [dry-run]" : ""}`);
1103
1227
  } catch (err) {
@@ -1146,14 +1270,18 @@ async function stageRedirect(memoryDir, assets, log2, dryRun) {
1146
1270
  }
1147
1271
  }
1148
1272
  if (matchCount > 0 && writeFailCount === 0) {
1149
- asset.status = "redirected";
1150
- asset.redirectedAt = (/* @__PURE__ */ new Date()).toISOString();
1273
+ if (!dryRun) {
1274
+ asset.status = "redirected";
1275
+ asset.redirectedAt = (/* @__PURE__ */ new Date()).toISOString();
1276
+ }
1151
1277
  redirected++;
1152
1278
  log2.info(`[binary-lifecycle] redirected: ${asset.originalPath}${dryRun ? " [dry-run]" : ""}`);
1153
1279
  } else if (matchCount > 0 && writeFailCount > 0) {
1154
- asset.status = "error";
1280
+ if (!dryRun) {
1281
+ asset.status = "error";
1282
+ }
1155
1283
  log2.warn(
1156
- `[binary-lifecycle] redirect partial failure for ${asset.originalPath}: ${matchCount} match(es), ${writeFailCount} write failure(s) \u2014 status set to error`
1284
+ `[binary-lifecycle] redirect partial failure for ${asset.originalPath}: ${matchCount} match(es), ${writeFailCount} write failure(s)${dryRun ? "" : " \u2014 status set to error"}`
1157
1285
  );
1158
1286
  }
1159
1287
  }
@@ -1175,11 +1303,18 @@ async function stageClean(memoryDir, assets, gracePeriodDays, log2, dryRun, forc
1175
1303
  }
1176
1304
  const fullPath = path4.join(memoryDir, asset.originalPath);
1177
1305
  try {
1306
+ const currentHash = await hashFile2(fullPath);
1307
+ if (currentHash !== asset.contentHash) {
1308
+ const msg = `clean blocked for ${asset.originalPath}: local content hash does not match manifest`;
1309
+ log2.warn(`[binary-lifecycle] ${msg}`);
1310
+ errors.push(msg);
1311
+ continue;
1312
+ }
1178
1313
  if (!dryRun) {
1179
1314
  await fsp4.unlink(fullPath);
1315
+ asset.status = "cleaned";
1316
+ asset.cleanedAt = (/* @__PURE__ */ new Date()).toISOString();
1180
1317
  }
1181
- asset.status = "cleaned";
1182
- asset.cleanedAt = (/* @__PURE__ */ new Date()).toISOString();
1183
1318
  cleaned++;
1184
1319
  log2.info(`[binary-lifecycle] cleaned: ${asset.originalPath}${dryRun ? " [dry-run]" : ""}`);
1185
1320
  } catch (err) {
@@ -1219,8 +1354,19 @@ async function findMarkdownFiles(dir) {
1219
1354
  return results;
1220
1355
  }
1221
1356
  async function runBinaryLifecyclePipeline(memoryDir, config, backend, log2, opts) {
1357
+ validateBinaryLifecycleConfig(config);
1222
1358
  const dryRun = opts?.dryRun ?? false;
1223
1359
  const forceClean = opts?.forceClean ?? false;
1360
+ if (config.enabled === false) {
1361
+ return {
1362
+ scanned: 0,
1363
+ mirrored: 0,
1364
+ redirected: 0,
1365
+ cleaned: 0,
1366
+ errors: [],
1367
+ dryRun
1368
+ };
1369
+ }
1224
1370
  const manifest = await readManifest(memoryDir);
1225
1371
  const newPaths = await scanForBinaries(memoryDir, config, manifest);
1226
1372
  const scanned = newPaths.length;
@@ -1262,38 +1408,8 @@ async function runBinaryLifecyclePipeline(memoryDir, config, backend, log2, opts
1262
1408
 
1263
1409
  // src/projection/index.ts
1264
1410
  import fs2 from "fs";
1265
- import path6 from "path";
1266
-
1267
- // src/utils/category-dir.ts
1268
1411
  import path5 from "path";
1269
- var CATEGORY_DIR_MAP = {
1270
- correction: "corrections",
1271
- question: "questions",
1272
- preference: "preferences",
1273
- decision: "decisions",
1274
- moment: "moments",
1275
- commitment: "commitments",
1276
- principle: "principles",
1277
- rule: "rules",
1278
- skill: "skills",
1279
- relationship: "relationships",
1280
- procedure: "procedures",
1281
- reasoning_trace: "reasoning-traces"
1282
- };
1283
- var ALL_CATEGORY_DIRS = [
1284
- "facts",
1285
- ...Object.values(CATEGORY_DIR_MAP)
1286
- ];
1287
- var ALL_CATEGORY_KEYS = [
1288
- "fact",
1289
- ...Object.keys(CATEGORY_DIR_MAP)
1290
- ];
1291
- function getCategoryDir(memoryDir, category) {
1292
- const dir = CATEGORY_DIR_MAP[category];
1293
- return dir ? path5.join(memoryDir, dir) : path5.join(memoryDir, "facts");
1294
- }
1295
-
1296
- // src/projection/index.ts
1412
+ var VALID_PROJECTION_CATEGORIES = new Set(ALL_CATEGORY_KEYS);
1297
1413
  async function generateContextTree(options) {
1298
1414
  const startTime = Date.now();
1299
1415
  const {
@@ -1307,13 +1423,20 @@ async function generateContextTree(options) {
1307
1423
  let nodesGenerated = 0;
1308
1424
  let nodesSkipped = 0;
1309
1425
  const categoryCounts = {};
1310
- fs2.mkdirSync(outputDir, { recursive: true });
1311
- const allCategories = filterCategories ?? ALL_CATEGORY_KEYS.filter((c) => c !== "question");
1426
+ const resolvedMemoryDir = path5.resolve(memoryDir);
1427
+ const resolvedOutputDir = path5.resolve(outputDir);
1428
+ const requestedCategories = validateProjectionCategories(filterCategories);
1429
+ const realMemoryDir = fs2.realpathSync(resolvedMemoryDir);
1430
+ assertNotSymlink(resolvedOutputDir, "context tree outputDir");
1431
+ fs2.mkdirSync(resolvedOutputDir, { recursive: true });
1432
+ const realOutputDir = fs2.realpathSync(resolvedOutputDir);
1433
+ const allCategories = (requestedCategories ?? ALL_CATEGORY_KEYS).filter((c) => c !== "question");
1312
1434
  for (const category of allCategories) {
1313
1435
  const categoryDir = getCategoryDir(memoryDir, category);
1314
1436
  if (!fs2.existsSync(categoryDir)) continue;
1437
+ assertSafeInputRoot(realMemoryDir, categoryDir, `${category} memory category`);
1315
1438
  categoryCounts[category] = 0;
1316
- const files = walkR(categoryDir);
1439
+ const files = walkR(categoryDir, realMemoryDir);
1317
1440
  let count = 0;
1318
1441
  for (const filePath of files) {
1319
1442
  if (count >= maxPerCategory) {
@@ -1331,19 +1454,19 @@ async function generateContextTree(options) {
1331
1454
  nodesSkipped++;
1332
1455
  continue;
1333
1456
  }
1334
- const outputPath = path6.join(outputDir, node.path);
1335
- fs2.mkdirSync(path6.dirname(outputPath), { recursive: true });
1336
- fs2.writeFileSync(outputPath, node.content);
1457
+ const outputPath = resolveContainedOutputPath(realOutputDir, node.path);
1458
+ writeProjectedContent(realOutputDir, outputPath, node.content);
1337
1459
  nodesGenerated++;
1338
1460
  categoryCounts[category] = (categoryCounts[category] ?? 0) + 1;
1339
1461
  count++;
1340
1462
  }
1341
1463
  }
1342
1464
  if (includeEntities) {
1343
- const entitiesDir = path6.join(memoryDir, "entities");
1465
+ const entitiesDir = path5.join(memoryDir, "entities");
1344
1466
  if (fs2.existsSync(entitiesDir)) {
1467
+ assertSafeInputRoot(realMemoryDir, entitiesDir, "entities root");
1345
1468
  categoryCounts["entity"] = 0;
1346
- const entityFiles = walkR(entitiesDir);
1469
+ const entityFiles = walkR(entitiesDir, realMemoryDir);
1347
1470
  let count = 0;
1348
1471
  for (const filePath of entityFiles) {
1349
1472
  if (count >= maxPerCategory) {
@@ -1351,22 +1474,23 @@ async function generateContextTree(options) {
1351
1474
  continue;
1352
1475
  }
1353
1476
  const content = fs2.readFileSync(filePath, "utf8");
1354
- const fileName = path6.basename(filePath, ".md");
1477
+ const fileName = path5.basename(filePath, ".md");
1355
1478
  const node = projectEntityNode(fileName, content);
1356
- const outputPath = path6.join(outputDir, "entities", `${fileName}.md`);
1357
- fs2.mkdirSync(path6.dirname(outputPath), { recursive: true });
1358
- fs2.writeFileSync(outputPath, node.content);
1479
+ const outputPath = resolveContainedOutputPath(realOutputDir, "entities", `${fileName}.md`);
1480
+ writeProjectedContent(realOutputDir, outputPath, node.content);
1359
1481
  nodesGenerated++;
1360
1482
  categoryCounts["entity"] = (categoryCounts["entity"] ?? 0) + 1;
1361
1483
  count++;
1362
1484
  }
1363
1485
  }
1364
1486
  }
1365
- if (includeQuestions) {
1366
- const questionsDir = path6.join(memoryDir, "questions");
1487
+ const shouldIncludeQuestions = includeQuestions && (requestedCategories === void 0 || requestedCategories.includes("question"));
1488
+ if (shouldIncludeQuestions) {
1489
+ const questionsDir = path5.join(memoryDir, "questions");
1367
1490
  if (fs2.existsSync(questionsDir)) {
1491
+ assertSafeInputRoot(realMemoryDir, questionsDir, "questions root");
1368
1492
  categoryCounts["question"] = 0;
1369
- const qFiles = walkR(questionsDir);
1493
+ const qFiles = walkR(questionsDir, realMemoryDir);
1370
1494
  let count = 0;
1371
1495
  for (const filePath of qFiles) {
1372
1496
  if (count >= maxPerCategory) {
@@ -1384,17 +1508,16 @@ async function generateContextTree(options) {
1384
1508
  nodesSkipped++;
1385
1509
  continue;
1386
1510
  }
1387
- const outputPath = path6.join(outputDir, node.path);
1388
- fs2.mkdirSync(path6.dirname(outputPath), { recursive: true });
1389
- fs2.writeFileSync(outputPath, node.content);
1511
+ const outputPath = resolveContainedOutputPath(realOutputDir, node.path);
1512
+ writeProjectedContent(realOutputDir, outputPath, node.content);
1390
1513
  nodesGenerated++;
1391
1514
  categoryCounts["question"] = (categoryCounts["question"] ?? 0) + 1;
1392
1515
  count++;
1393
1516
  }
1394
1517
  }
1395
1518
  }
1396
- const index = generateIndex(categoryCounts, outputDir);
1397
- fs2.writeFileSync(path6.join(outputDir, "INDEX.md"), index);
1519
+ const index = generateIndex(categoryCounts, resolvedOutputDir);
1520
+ writeProjectedContent(realOutputDir, resolveContainedOutputPath(realOutputDir, "INDEX.md"), index);
1398
1521
  return {
1399
1522
  nodesGenerated,
1400
1523
  nodesSkipped,
@@ -1403,14 +1526,134 @@ async function generateContextTree(options) {
1403
1526
  outputDir
1404
1527
  };
1405
1528
  }
1406
- function walkR(dir) {
1529
+ function isPathInside(root, candidate) {
1530
+ const relative = path5.relative(root, candidate);
1531
+ return relative === "" || !relative.startsWith("..") && !path5.isAbsolute(relative);
1532
+ }
1533
+ function assertNotSymlink(targetPath, label) {
1534
+ try {
1535
+ if (fs2.lstatSync(targetPath).isSymbolicLink()) {
1536
+ throw new Error(`${label} must not be a symlink: ${targetPath}`);
1537
+ }
1538
+ } catch (err) {
1539
+ if (err.code === "ENOENT") return;
1540
+ throw err;
1541
+ }
1542
+ }
1543
+ function assertSafeInputRoot(realMemoryDir, targetPath, label) {
1544
+ const stat = fs2.lstatSync(targetPath);
1545
+ if (stat.isSymbolicLink()) {
1546
+ throw new Error(`${label} must not be a symlink: ${targetPath}`);
1547
+ }
1548
+ if (!stat.isDirectory()) {
1549
+ throw new Error(`${label} must be a directory: ${targetPath}`);
1550
+ }
1551
+ const realTarget = fs2.realpathSync(targetPath);
1552
+ if (!isPathInside(realMemoryDir, realTarget)) {
1553
+ throw new Error(`${label} escapes memoryDir: ${targetPath}`);
1554
+ }
1555
+ }
1556
+ function assertSafeOutputTarget(realOutputDir, outputPath) {
1557
+ let current = realOutputDir;
1558
+ const relative = path5.relative(realOutputDir, outputPath);
1559
+ if (relative.startsWith("..") || path5.isAbsolute(relative)) {
1560
+ throw new Error(`context tree output path escapes outputDir: ${outputPath}`);
1561
+ }
1562
+ for (const segment of relative.split(path5.sep).filter(Boolean)) {
1563
+ current = path5.join(current, segment);
1564
+ try {
1565
+ const stat = fs2.lstatSync(current);
1566
+ if (stat.isSymbolicLink()) {
1567
+ throw new Error(`context tree output path contains symlink: ${current}`);
1568
+ }
1569
+ } catch (err) {
1570
+ if (err.code === "ENOENT") {
1571
+ break;
1572
+ }
1573
+ throw err;
1574
+ }
1575
+ }
1576
+ }
1577
+ function validateProjectionCategories(categories) {
1578
+ if (categories === void 0) {
1579
+ return void 0;
1580
+ }
1581
+ const validated = [];
1582
+ for (const category of categories) {
1583
+ if (typeof category !== "string" || !VALID_PROJECTION_CATEGORIES.has(category)) {
1584
+ throw new Error(`invalid context tree category: ${String(category)}`);
1585
+ }
1586
+ if (!validated.includes(category)) {
1587
+ validated.push(category);
1588
+ }
1589
+ }
1590
+ return validated;
1591
+ }
1592
+ function resolveContainedOutputPath(outputRoot, ...segments) {
1593
+ const resolved = path5.resolve(outputRoot, ...segments);
1594
+ const relative = path5.relative(outputRoot, resolved);
1595
+ if (relative === "" || !relative.startsWith("..") && !path5.isAbsolute(relative)) {
1596
+ return resolved;
1597
+ }
1598
+ throw new Error(`context tree output path escapes outputDir: ${segments.join("/")}`);
1599
+ }
1600
+ function writeProjectedContent(realOutputDir, outputPath, generatedContent) {
1601
+ assertSafeOutputTarget(realOutputDir, outputPath);
1602
+ fs2.mkdirSync(path5.dirname(outputPath), { recursive: true });
1603
+ const realParent = fs2.realpathSync(path5.dirname(outputPath));
1604
+ if (!isPathInside(realOutputDir, realParent)) {
1605
+ throw new Error(`context tree output path escapes outputDir: ${outputPath}`);
1606
+ }
1607
+ const existingContent = fs2.existsSync(outputPath) ? fs2.readFileSync(outputPath, "utf8") : "";
1608
+ fs2.writeFileSync(
1609
+ outputPath,
1610
+ preserveManualFencedBlocks(generatedContent, existingContent)
1611
+ );
1612
+ }
1613
+ function preserveManualFencedBlocks(generatedContent, existingContent) {
1614
+ const manualBlocks = extractManualFencedBlocks(existingContent).filter((block) => !generatedContent.includes(block));
1615
+ if (manualBlocks.length === 0) {
1616
+ return generatedContent;
1617
+ }
1618
+ return `${generatedContent.trimEnd()}
1619
+
1620
+ ## Manual Edits
1621
+
1622
+ ${manualBlocks.join("\n\n")}
1623
+ `;
1624
+ }
1625
+ function extractManualFencedBlocks(content) {
1626
+ const blocks = [];
1627
+ const seen = /* @__PURE__ */ new Set();
1628
+ const fencePattern = /(?:^|\n)([`~]{3,})[^\n]*\bmanual\b[^\n]*\n[\s\S]*?\n\1[ \t]*(?=\n|$)/gi;
1629
+ for (const match of content.matchAll(fencePattern)) {
1630
+ const block = match[0].trim();
1631
+ if (!seen.has(block)) {
1632
+ seen.add(block);
1633
+ blocks.push(block);
1634
+ }
1635
+ }
1636
+ return blocks;
1637
+ }
1638
+ function walkR(dir, realMemoryDir) {
1407
1639
  const results = [];
1408
1640
  function walk(directory) {
1409
1641
  for (const entry of fs2.readdirSync(directory, { withFileTypes: true })) {
1410
- const fullPath = path6.join(directory, entry.name);
1642
+ const fullPath = path5.join(directory, entry.name);
1643
+ if (entry.isSymbolicLink()) {
1644
+ throw new Error(`context tree input path contains symlink: ${fullPath}`);
1645
+ }
1411
1646
  if (entry.isDirectory()) {
1647
+ const realDir = fs2.realpathSync(fullPath);
1648
+ if (!isPathInside(realMemoryDir, realDir)) {
1649
+ throw new Error(`context tree input path escapes memoryDir: ${fullPath}`);
1650
+ }
1412
1651
  walk(fullPath);
1413
1652
  } else if (entry.name.endsWith(".md")) {
1653
+ const realFile = fs2.realpathSync(fullPath);
1654
+ if (!isPathInside(realMemoryDir, realFile)) {
1655
+ throw new Error(`context tree input path escapes memoryDir: ${fullPath}`);
1656
+ }
1414
1657
  results.push(fullPath);
1415
1658
  }
1416
1659
  }
@@ -1449,13 +1692,13 @@ function extractBody(content) {
1449
1692
  }
1450
1693
  function projectNode(filePath, category, fm, rawContent) {
1451
1694
  const body = extractBody(rawContent);
1452
- const fileName = path6.basename(filePath, ".md");
1453
- const dateDir = path6.basename(path6.dirname(filePath));
1695
+ const fileName = path5.basename(filePath, ".md");
1696
+ const dateDir = path5.basename(path5.dirname(filePath));
1454
1697
  let relPath;
1455
1698
  if (/^\d{4}-\d{2}-\d{2}$/.test(dateDir)) {
1456
- relPath = path6.join(category, dateDir, `${fileName}.md`);
1699
+ relPath = path5.join(category, dateDir, `${fileName}.md`);
1457
1700
  } else {
1458
- relPath = path6.join(category, `${fileName}.md`);
1701
+ relPath = path5.join(category, `${fileName}.md`);
1459
1702
  }
1460
1703
  const generatedAt = (/* @__PURE__ */ new Date()).toISOString();
1461
1704
  const md = `# ${fm.id}
@@ -1501,7 +1744,7 @@ function projectEntityNode(fileName, content) {
1501
1744
  ${content}
1502
1745
  `;
1503
1746
  return {
1504
- path: path6.join("entities", `${fileName}.md`),
1747
+ path: path5.join("entities", `${fileName}.md`),
1505
1748
  category: "entity",
1506
1749
  title: fileName,
1507
1750
  content: md,
@@ -1554,18 +1797,18 @@ function generateIndex(categoryCounts, outputDir) {
1554
1797
 
1555
1798
  // src/onboarding/index.ts
1556
1799
  import fs3 from "fs";
1557
- import path7 from "path";
1800
+ import path6 from "path";
1558
1801
  var LANGUAGE_RULES = [
1559
1802
  {
1560
1803
  language: "TypeScript",
1561
1804
  extensions: [".ts", ".tsx"],
1562
- manifests: ["package.json"],
1805
+ manifests: [],
1563
1806
  configFiles: ["tsconfig.json", "tsup.config.ts"]
1564
1807
  },
1565
1808
  {
1566
1809
  language: "JavaScript",
1567
1810
  extensions: [".js", ".jsx", ".mjs", ".cjs"],
1568
- manifests: ["package.json"],
1811
+ manifests: [],
1569
1812
  configFiles: [".eslintrc", ".prettierrc"]
1570
1813
  },
1571
1814
  {
@@ -1653,10 +1896,19 @@ var DEFAULT_EXCLUDE = /* @__PURE__ */ new Set([
1653
1896
  function onboard(options) {
1654
1897
  const startTime = Date.now();
1655
1898
  const {
1656
- directory,
1657
1899
  maxDepth = 6,
1658
1900
  excludeDirs = []
1659
1901
  } = options;
1902
+ const directory = path6.resolve(options.directory ?? process.cwd());
1903
+ let rootStat;
1904
+ try {
1905
+ rootStat = fs3.statSync(directory);
1906
+ } catch (err) {
1907
+ throw new Error(`Cannot scan onboarding directory ${directory}: ${err instanceof Error ? err.message : String(err)}`);
1908
+ }
1909
+ if (!rootStat.isDirectory()) {
1910
+ throw new Error(`Cannot scan onboarding directory ${directory}: not a directory`);
1911
+ }
1660
1912
  const exclude = /* @__PURE__ */ new Set([...DEFAULT_EXCLUDE, ...excludeDirs]);
1661
1913
  const files = walkDir(directory, exclude, maxDepth);
1662
1914
  const languages = detectLanguages(files, directory);
@@ -1681,12 +1933,15 @@ function walkDir(root, exclude, maxDepth) {
1681
1933
  let entries;
1682
1934
  try {
1683
1935
  entries = fs3.readdirSync(dir, { withFileTypes: true });
1684
- } catch {
1936
+ } catch (err) {
1937
+ if (depth === 0) {
1938
+ throw new Error(`Cannot scan onboarding directory ${root}: ${err instanceof Error ? err.message : String(err)}`);
1939
+ }
1685
1940
  return;
1686
1941
  }
1687
1942
  for (const entry of entries) {
1688
1943
  if (exclude.has(entry.name)) continue;
1689
- const fullPath = path7.join(dir, entry.name);
1944
+ const fullPath = path6.join(dir, entry.name);
1690
1945
  if (entry.isDirectory()) {
1691
1946
  walk(fullPath, depth + 1);
1692
1947
  } else if (entry.isFile()) {
@@ -1701,11 +1956,11 @@ function detectLanguages(files, root) {
1701
1956
  const results = [];
1702
1957
  const extCounts = /* @__PURE__ */ new Map();
1703
1958
  for (const f of files) {
1704
- const ext = path7.extname(f).toLowerCase();
1959
+ const ext = path6.extname(f).toLowerCase();
1705
1960
  if (ext) extCounts.set(ext, (extCounts.get(ext) ?? 0) + 1);
1706
1961
  }
1707
1962
  const rootFiles = new Set(
1708
- files.filter((f) => path7.dirname(f) === root).map((f) => path7.basename(f))
1963
+ files.filter((f) => path6.dirname(f) === root).map((f) => path6.basename(f))
1709
1964
  );
1710
1965
  for (const rule of LANGUAGE_RULES) {
1711
1966
  const evidence = [];
@@ -1749,7 +2004,7 @@ function detectLanguages(files, root) {
1749
2004
  }
1750
2005
  function detectShape(files, root) {
1751
2006
  const rootFiles = new Set(
1752
- files.filter((f) => path7.dirname(f) === root).map((f) => path7.basename(f))
2007
+ files.filter((f) => path6.dirname(f) === root).map((f) => path6.basename(f))
1753
2008
  );
1754
2009
  const rootDirs = /* @__PURE__ */ new Set();
1755
2010
  try {
@@ -1760,7 +2015,7 @@ function detectShape(files, root) {
1760
2015
  }
1761
2016
  const evidence = [];
1762
2017
  if (rootFiles.has("package.json")) {
1763
- const pkg = readJsonSafe(path7.join(root, "package.json"));
2018
+ const pkg = readJsonSafe(path6.join(root, "package.json"));
1764
2019
  if (pkg?.workspaces) {
1765
2020
  evidence.push("package.json has workspaces");
1766
2021
  return { shape: "monorepo", evidence };
@@ -1774,13 +2029,13 @@ function detectShape(files, root) {
1774
2029
  evidence.push("workspace manifest found");
1775
2030
  return { shape: "workspace", evidence };
1776
2031
  }
1777
- const cargoToml = readTomlWorkspace(path7.join(root, "Cargo.toml"));
2032
+ const cargoToml = readTomlWorkspace(path6.join(root, "Cargo.toml"));
1778
2033
  if (cargoToml) {
1779
2034
  evidence.push("Cargo.toml has workspace");
1780
2035
  return { shape: "workspace", evidence };
1781
2036
  }
1782
2037
  if (rootFiles.has("package.json")) {
1783
- const pkg = readJsonSafe(path7.join(root, "package.json"));
2038
+ const pkg = readJsonSafe(path6.join(root, "package.json"));
1784
2039
  if (pkg?.exports || pkg?.main) {
1785
2040
  if (pkg?.bin) {
1786
2041
  evidence.push("package.json has bin");
@@ -1814,8 +2069,8 @@ function discoverDocs(files, root) {
1814
2069
  { pattern: /^\.editorconfig$/i, kind: "config" }
1815
2070
  ];
1816
2071
  for (const filePath of files) {
1817
- const basename = path7.basename(filePath).toLowerCase();
1818
- const relPath = path7.relative(root, filePath);
2072
+ const basename = path6.basename(filePath).toLowerCase();
2073
+ const relPath = path6.relative(root, filePath);
1819
2074
  let kind;
1820
2075
  for (const { pattern, kind: k } of docPatterns) {
1821
2076
  if (pattern.test(basename)) {
@@ -1827,7 +2082,7 @@ function discoverDocs(files, root) {
1827
2082
  kind = "docs";
1828
2083
  }
1829
2084
  if (!kind && (basename.endsWith(".md") || basename.endsWith(".mdx"))) {
1830
- if (path7.dirname(relPath) === "." || isUnderDocsDir(relPath)) {
2085
+ if (path6.dirname(relPath) === "." || isUnderDocsDir(relPath)) {
1831
2086
  kind = "docs";
1832
2087
  }
1833
2088
  }
@@ -1848,7 +2103,7 @@ function discoverDocs(files, root) {
1848
2103
  return docs;
1849
2104
  }
1850
2105
  function isUnderDocsDir(relPath) {
1851
- const parts = relPath.split(path7.sep);
2106
+ const parts = relPath.split(path6.sep);
1852
2107
  return parts[0] === "docs" || parts[0] === "doc" || parts[0] === "documentation";
1853
2108
  }
1854
2109
  function buildPlan(languages, shape, docs, _root) {
@@ -1892,8 +2147,8 @@ function readTomlWorkspace(filePath) {
1892
2147
 
1893
2148
  // src/curation/index.ts
1894
2149
  import fs4 from "fs";
1895
- import path8 from "path";
1896
- import crypto3 from "crypto";
2150
+ import path7 from "path";
2151
+ import crypto4 from "crypto";
1897
2152
  async function curate(options) {
1898
2153
  const startTime = Date.now();
1899
2154
  const {
@@ -1915,6 +2170,7 @@ async function curate(options) {
1915
2170
  let filesProcessed = 0;
1916
2171
  let filesSkipped = 0;
1917
2172
  const targets = resolveTargets(targetPath);
2173
+ const provenanceRoot = resolveProvenanceRoot(targetPath);
1918
2174
  const existingMemories = checkDuplicates || checkContradictions ? loadExistingMemories(memoryDir) : /* @__PURE__ */ new Map();
1919
2175
  for (const filePath of targets) {
1920
2176
  const content = readFileSafe(filePath);
@@ -1931,7 +2187,7 @@ async function curate(options) {
1931
2187
  const fileStatements = extractStatements(
1932
2188
  content,
1933
2189
  filePath,
1934
- targetPath,
2190
+ provenanceRoot,
1935
2191
  source,
1936
2192
  sourceFileHash,
1937
2193
  categoryOverride,
@@ -1956,14 +2212,12 @@ async function curate(options) {
1956
2212
  statements.push(stmt);
1957
2213
  if (write) {
1958
2214
  const writtenPath = writeStatement(stmt, memoryDir);
1959
- if (writtenPath) {
1960
- written.push(writtenPath);
1961
- existingMemories.set(stmt.contentHash, {
1962
- id: stmt.id,
1963
- content: stmt.content,
1964
- category: stmt.category
1965
- });
1966
- }
2215
+ written.push(writtenPath);
2216
+ existingMemories.set(stmt.contentHash, {
2217
+ id: stmt.id,
2218
+ content: stmt.content,
2219
+ category: stmt.category
2220
+ });
1967
2221
  }
1968
2222
  }
1969
2223
  }
@@ -1984,12 +2238,12 @@ function resolveTargets(targetPath) {
1984
2238
  const extensions = /* @__PURE__ */ new Set([".md", ".txt", ".mdx", ".rst"]);
1985
2239
  function walk(dir) {
1986
2240
  for (const entry of fs4.readdirSync(dir, { withFileTypes: true })) {
1987
- const fullPath = path8.join(dir, entry.name);
2241
+ const fullPath = path7.join(dir, entry.name);
1988
2242
  if (entry.isDirectory()) {
1989
2243
  if (entry.name !== "node_modules" && entry.name !== ".git") {
1990
2244
  walk(fullPath);
1991
2245
  }
1992
- } else if (extensions.has(path8.extname(entry.name).toLowerCase())) {
2246
+ } else if (extensions.has(path7.extname(entry.name).toLowerCase())) {
1993
2247
  results.push(fullPath);
1994
2248
  }
1995
2249
  }
@@ -1997,8 +2251,13 @@ function resolveTargets(targetPath) {
1997
2251
  walk(targetPath);
1998
2252
  return results;
1999
2253
  }
2254
+ function resolveProvenanceRoot(targetPath) {
2255
+ const resolvedTarget = path7.resolve(targetPath);
2256
+ const stat = fs4.statSync(resolvedTarget);
2257
+ return stat.isFile() ? path7.dirname(resolvedTarget) : resolvedTarget;
2258
+ }
2000
2259
  function extractStatements(content, filePath, projectRoot, source, sourceFileHash, categoryOverride, confidence, entityRef, tags) {
2001
- const relativePath = path8.relative(projectRoot, filePath);
2260
+ const relativePath = path7.relative(projectRoot, path7.resolve(filePath)) || path7.basename(filePath);
2002
2261
  const statements = [];
2003
2262
  const now = (/* @__PURE__ */ new Date()).toISOString();
2004
2263
  const paragraphs = content.split(/\n{2,}/).map((p) => p.trim()).filter((p) => p.length > 20 && p.length < 2e3);
@@ -2092,7 +2351,7 @@ function loadExistingMemories(memoryDir) {
2092
2351
  if (!fs4.existsSync(memoryDir)) return result;
2093
2352
  const dirs = ALL_CATEGORY_DIRS;
2094
2353
  for (const dir of dirs) {
2095
- const fullDir = path8.join(memoryDir, dir);
2354
+ const fullDir = path7.join(memoryDir, dir);
2096
2355
  if (!fs4.existsSync(fullDir)) continue;
2097
2356
  walkFiles(fullDir, (filePath) => {
2098
2357
  const content = readFileSafe(filePath);
@@ -2114,10 +2373,10 @@ function writeStatement(stmt, memoryDir) {
2114
2373
  const now = /* @__PURE__ */ new Date();
2115
2374
  const dateDir = now.toISOString().split("T")[0];
2116
2375
  const categoryDir = getCategoryDir(memoryDir, stmt.category);
2117
- const dir = path8.join(categoryDir, dateDir);
2376
+ const dir = path7.join(categoryDir, dateDir);
2118
2377
  fs4.mkdirSync(dir, { recursive: true });
2119
2378
  const fileName = `${stmt.category}-${Date.now()}-${stmt.id.slice(0, 8)}.md`;
2120
- const filePath = path8.join(dir, fileName);
2379
+ const filePath = path7.join(dir, fileName);
2121
2380
  const frontmatter = [
2122
2381
  "---",
2123
2382
  `id: ${stmt.id}`,
@@ -2137,18 +2396,14 @@ function writeStatement(stmt, memoryDir) {
2137
2396
 
2138
2397
  ${stmt.content}
2139
2398
  `;
2140
- try {
2141
- fs4.writeFileSync(filePath, body);
2142
- return filePath;
2143
- } catch {
2144
- return null;
2145
- }
2399
+ fs4.writeFileSync(filePath, body);
2400
+ return filePath;
2146
2401
  }
2147
2402
  function generateId() {
2148
- return crypto3.randomUUID();
2403
+ return crypto4.randomUUID();
2149
2404
  }
2150
2405
  function hashContent(content) {
2151
- return crypto3.createHash("sha256").update(content).digest("hex").slice(0, 16);
2406
+ return crypto4.createHash("sha256").update(content).digest("hex").slice(0, 16);
2152
2407
  }
2153
2408
  function tierFromConfidence(confidence) {
2154
2409
  if (confidence >= 0.95) return "explicit";
@@ -2188,7 +2443,7 @@ function extractBody2(content) {
2188
2443
  }
2189
2444
  function walkFiles(dir, callback) {
2190
2445
  for (const entry of fs4.readdirSync(dir, { withFileTypes: true })) {
2191
- const fullPath = path8.join(dir, entry.name);
2446
+ const fullPath = path7.join(dir, entry.name);
2192
2447
  if (entry.isDirectory()) {
2193
2448
  walkFiles(fullPath, callback);
2194
2449
  } else if (entry.name.endsWith(".md")) {
@@ -2199,11 +2454,21 @@ function walkFiles(dir, callback) {
2199
2454
 
2200
2455
  // src/dedup/index.ts
2201
2456
  import fs5 from "fs";
2202
- import path9 from "path";
2203
- import crypto4 from "crypto";
2457
+ import path8 from "path";
2458
+ import crypto5 from "crypto";
2459
+ var DEFAULT_DEDUP_THRESHOLD = 0.85;
2460
+ var DEFAULT_MAX_LOAD = 1e4;
2461
+ function normalizeThreshold(value, defaultValue) {
2462
+ return typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= 1 ? value : defaultValue;
2463
+ }
2464
+ function normalizeMaxLoad(value, defaultValue) {
2465
+ return typeof value === "number" && Number.isInteger(value) && value >= 0 ? value : defaultValue;
2466
+ }
2204
2467
  function findDuplicates(options) {
2205
2468
  const startTime = Date.now();
2206
- const { memoryDir, threshold = 0.85, maxLoad = 1e4 } = options;
2469
+ const { memoryDir } = options;
2470
+ const threshold = normalizeThreshold(options.threshold, DEFAULT_DEDUP_THRESHOLD);
2471
+ const maxLoad = normalizeMaxLoad(options.maxLoad, DEFAULT_MAX_LOAD);
2207
2472
  const memories = loadMemories(memoryDir, options.categories, maxLoad);
2208
2473
  const duplicates = [];
2209
2474
  for (let i = 0; i < memories.length; i++) {
@@ -2227,7 +2492,8 @@ function findDuplicates(options) {
2227
2492
  }
2228
2493
  function findContradictions(options) {
2229
2494
  const startTime = Date.now();
2230
- const { memoryDir, maxLoad = 1e4 } = options;
2495
+ const { memoryDir } = options;
2496
+ const maxLoad = normalizeMaxLoad(options.maxLoad, DEFAULT_MAX_LOAD);
2231
2497
  const memories = loadMemories(memoryDir, options.categories, maxLoad);
2232
2498
  const contradictions = [];
2233
2499
  for (let i = 0; i < memories.length; i++) {
@@ -2272,6 +2538,7 @@ var NEGATION_WORDS = /* @__PURE__ */ new Set([
2272
2538
  "aren't",
2273
2539
  "won't",
2274
2540
  "can't",
2541
+ "cannot",
2275
2542
  "never",
2276
2543
  "no",
2277
2544
  "none",
@@ -2320,18 +2587,27 @@ function containsNegation(text) {
2320
2587
  return words.some((w) => NEGATION_WORDS.has(w));
2321
2588
  }
2322
2589
  function stripNegation(text) {
2323
- return text.replace(/\b(not|don't|doesn't|isn't|aren't|won't|can't|never|no|none|neither|nor|nothing|nowhere)\b/gi, "").replace(/\s+/g, " ").trim();
2590
+ return text.replace(/\b(not|don't|doesn't|isn't|aren't|won't|can't|cannot|never|no|none|neither|nor|nothing|nowhere)\b/gi, "").replace(/\s+/g, " ").trim();
2324
2591
  }
2325
2592
  function loadMemories(memoryDir, categories, maxLoad = 1e4) {
2326
2593
  const result = [];
2327
2594
  const allCategories = categories ?? ALL_CATEGORY_DIRS;
2595
+ if (!fs5.existsSync(memoryDir)) return result;
2596
+ const memoryRootReal = fs5.realpathSync(memoryDir);
2328
2597
  for (const category of allCategories) {
2329
2598
  if (result.length >= maxLoad) break;
2330
- const dir = path9.join(memoryDir, category);
2599
+ const dir = path8.join(memoryDir, category);
2331
2600
  if (!fs5.existsSync(dir)) continue;
2332
- walkMdFiles(dir, (filePath) => {
2601
+ const categoryStat = fs5.lstatSync(dir);
2602
+ if (categoryStat.isSymbolicLink()) {
2603
+ throw new Error(`Refusing to scan symlinked memory category directory: ${dir}`);
2604
+ }
2605
+ if (!categoryStat.isDirectory()) continue;
2606
+ const categoryRootReal = fs5.realpathSync(dir);
2607
+ assertPathInsideRoot(memoryRootReal, categoryRootReal, dir);
2608
+ walkMdFiles(dir, memoryRootReal, categoryRootReal, (filePath) => {
2333
2609
  if (result.length >= maxLoad) return;
2334
- const content = readFileSafe2(filePath);
2610
+ const content = readFileSafe2(filePath, memoryRootReal, categoryRootReal);
2335
2611
  if (!content) return;
2336
2612
  const fm = parseFrontmatter3(content);
2337
2613
  const body = extractBody3(content);
@@ -2347,10 +2623,17 @@ function loadMemories(memoryDir, categories, maxLoad = 1e4) {
2347
2623
  return result;
2348
2624
  }
2349
2625
  function hashContent2(content) {
2350
- return crypto4.createHash("sha256").update(content).digest("hex").slice(0, 16);
2626
+ return crypto5.createHash("sha256").update(content).digest("hex").slice(0, 16);
2351
2627
  }
2352
- function readFileSafe2(filePath) {
2628
+ function readFileSafe2(filePath, memoryRootReal, categoryRootReal) {
2353
2629
  try {
2630
+ const fileStat = fs5.lstatSync(filePath);
2631
+ if (fileStat.isSymbolicLink()) {
2632
+ throw new Error(`Refusing to read symlinked memory file: ${filePath}`);
2633
+ }
2634
+ const fileReal = fs5.realpathSync(filePath);
2635
+ assertPathInsideRoot(memoryRootReal, fileReal, filePath);
2636
+ assertPathInsideRoot(categoryRootReal, fileReal, filePath);
2354
2637
  return fs5.readFileSync(filePath, "utf8");
2355
2638
  } catch {
2356
2639
  return null;
@@ -2373,11 +2656,25 @@ function extractBody3(content) {
2373
2656
  const match = content.match(/^---\n[\s\S]*?\n---\n([\s\S]*)/);
2374
2657
  return match ? match[1].trim() : content.trim();
2375
2658
  }
2376
- function walkMdFiles(dir, callback) {
2659
+ function assertPathInsideRoot(rootReal, targetReal, sourcePath) {
2660
+ const rel = path8.relative(rootReal, targetReal);
2661
+ if (rel === "" || !rel.startsWith("..") && !path8.isAbsolute(rel)) {
2662
+ return;
2663
+ }
2664
+ throw new Error(`Refusing to scan memory path outside root: ${sourcePath}`);
2665
+ }
2666
+ function walkMdFiles(dir, memoryRootReal, categoryRootReal, callback) {
2377
2667
  for (const entry of fs5.readdirSync(dir, { withFileTypes: true })) {
2378
- const fullPath = path9.join(dir, entry.name);
2379
- if (entry.isDirectory()) {
2380
- walkMdFiles(fullPath, callback);
2668
+ const fullPath = path8.join(dir, entry.name);
2669
+ const entryStat = fs5.lstatSync(fullPath);
2670
+ if (entryStat.isSymbolicLink()) {
2671
+ throw new Error(`Refusing to scan symlinked memory path: ${fullPath}`);
2672
+ }
2673
+ const entryReal = fs5.realpathSync(fullPath);
2674
+ assertPathInsideRoot(memoryRootReal, entryReal, fullPath);
2675
+ assertPathInsideRoot(categoryRootReal, entryReal, fullPath);
2676
+ if (entryStat.isDirectory()) {
2677
+ walkMdFiles(fullPath, memoryRootReal, categoryRootReal, callback);
2381
2678
  } else if (entry.name.endsWith(".md")) {
2382
2679
  callback(fullPath);
2383
2680
  }
@@ -2386,8 +2683,42 @@ function walkMdFiles(dir, callback) {
2386
2683
 
2387
2684
  // src/review/index.ts
2388
2685
  import fs6 from "fs";
2389
- import path10 from "path";
2686
+ import path9 from "path";
2390
2687
  var DEFAULT_CONFIDENCE_THRESHOLD = 0.7;
2688
+ function realMemoryRoot(memoryDir) {
2689
+ try {
2690
+ const stat = fs6.lstatSync(memoryDir);
2691
+ if (!stat.isDirectory() || stat.isSymbolicLink()) return null;
2692
+ return fs6.realpathSync(memoryDir);
2693
+ } catch {
2694
+ return null;
2695
+ }
2696
+ }
2697
+ function isPathInside2(rootReal, candidateReal) {
2698
+ const relative = path9.relative(rootReal, candidateReal);
2699
+ return relative === "" || !!relative && !relative.startsWith("..") && !path9.isAbsolute(relative);
2700
+ }
2701
+ function isSafeDirectory(rootReal, dir) {
2702
+ try {
2703
+ const stat = fs6.lstatSync(dir);
2704
+ if (!stat.isDirectory() || stat.isSymbolicLink()) return false;
2705
+ return isPathInside2(rootReal, fs6.realpathSync(dir));
2706
+ } catch {
2707
+ return false;
2708
+ }
2709
+ }
2710
+ function ensureSafeDirectory(rootReal, dir) {
2711
+ if (fs6.existsSync(dir)) {
2712
+ if (!isSafeDirectory(rootReal, dir)) {
2713
+ throw new Error(`Refusing to write through unsafe review path: ${dir}`);
2714
+ }
2715
+ return;
2716
+ }
2717
+ fs6.mkdirSync(dir, { recursive: true });
2718
+ if (!isSafeDirectory(rootReal, dir)) {
2719
+ throw new Error(`Refusing to write through unsafe review path: ${dir}`);
2720
+ }
2721
+ }
2391
2722
  function listReviewItems(options) {
2392
2723
  const startTime = Date.now();
2393
2724
  const {
@@ -2396,19 +2727,25 @@ function listReviewItems(options) {
2396
2727
  limit = 50,
2397
2728
  confidenceThreshold = DEFAULT_CONFIDENCE_THRESHOLD
2398
2729
  } = options;
2730
+ const maxItems = Math.max(0, limit);
2731
+ const rootReal = realMemoryRoot(memoryDir);
2732
+ if (!rootReal || maxItems === 0) {
2733
+ return { items: [], total: 0, durationMs: Date.now() - startTime };
2734
+ }
2399
2735
  const items = [];
2736
+ const isLimitReached = () => items.length >= maxItems;
2400
2737
  const addItem = (item) => {
2401
- if (items.length >= limit) return;
2738
+ if (isLimitReached()) return;
2402
2739
  if (filterReason && item.reviewReason !== filterReason) return;
2403
2740
  items.push(item);
2404
2741
  };
2405
- const suggestionsDir = path10.join(memoryDir, "suggestions");
2406
- if (fs6.existsSync(suggestionsDir)) {
2407
- walkMd(suggestionsDir, (filePath, content) => {
2408
- if (items.length >= limit) return;
2742
+ const suggestionsDir = path9.join(memoryDir, "suggestions");
2743
+ if (!isLimitReached() && fs6.existsSync(suggestionsDir) && isSafeDirectory(rootReal, suggestionsDir)) {
2744
+ walkMd(rootReal, suggestionsDir, (filePath, content) => {
2745
+ if (isLimitReached()) return true;
2409
2746
  const fm = parseFrontmatter4(content);
2410
2747
  const body = extractBody4(content);
2411
- if (!fm?.id) return;
2748
+ if (!fm?.id) return false;
2412
2749
  addItem({
2413
2750
  id: fm.id,
2414
2751
  content: body,
@@ -2420,15 +2757,16 @@ function listReviewItems(options) {
2420
2757
  created: fm.created ?? (/* @__PURE__ */ new Date()).toISOString(),
2421
2758
  reviewReason: "suggestion"
2422
2759
  });
2760
+ return isLimitReached();
2423
2761
  });
2424
2762
  }
2425
- const reviewDir = path10.join(memoryDir, "review");
2426
- if (fs6.existsSync(reviewDir)) {
2427
- walkMd(reviewDir, (filePath, content) => {
2428
- if (items.length >= limit) return;
2763
+ const reviewDir = path9.join(memoryDir, "review");
2764
+ if (!isLimitReached() && fs6.existsSync(reviewDir) && isSafeDirectory(rootReal, reviewDir)) {
2765
+ walkMd(rootReal, reviewDir, (filePath, content) => {
2766
+ if (isLimitReached()) return true;
2429
2767
  const fm = parseFrontmatter4(content);
2430
2768
  const body = extractBody4(content);
2431
- if (!fm?.id) return;
2769
+ if (!fm?.id) return false;
2432
2770
  addItem({
2433
2771
  id: fm.id,
2434
2772
  content: body,
@@ -2441,22 +2779,23 @@ function listReviewItems(options) {
2441
2779
  reviewReason: fm.reviewReason ?? "low_confidence",
2442
2780
  context: fm.context
2443
2781
  });
2782
+ return isLimitReached();
2444
2783
  });
2445
2784
  }
2446
2785
  const categories = ALL_CATEGORY_DIRS;
2447
2786
  for (const category of categories) {
2448
- if (items.length >= limit) break;
2449
- const dir = path10.join(memoryDir, category);
2450
- if (!fs6.existsSync(dir)) continue;
2451
- walkMd(dir, (filePath, content) => {
2452
- if (items.length >= limit) return;
2787
+ if (isLimitReached()) break;
2788
+ const dir = path9.join(memoryDir, category);
2789
+ if (!fs6.existsSync(dir) || !isSafeDirectory(rootReal, dir)) continue;
2790
+ walkMd(rootReal, dir, (filePath, content) => {
2791
+ if (isLimitReached()) return true;
2453
2792
  const fm = parseFrontmatter4(content);
2454
2793
  const body = extractBody4(content);
2455
- if (!fm?.id) return;
2794
+ if (!fm?.id) return false;
2456
2795
  const confidence = parseConfidence(fm.confidence, 1);
2457
- if (confidence >= confidenceThreshold) return;
2458
- if (parseBoolean(fm.reviewDismissed)) return;
2459
- if (items.some((i) => i.id === fm.id)) return;
2796
+ if (confidence >= confidenceThreshold) return false;
2797
+ if (parseBoolean(fm.reviewDismissed)) return false;
2798
+ if (items.some((i) => i.id === fm.id)) return false;
2460
2799
  addItem({
2461
2800
  id: fm.id,
2462
2801
  content: body,
@@ -2468,6 +2807,7 @@ function listReviewItems(options) {
2468
2807
  created: fm.created ?? (/* @__PURE__ */ new Date()).toISOString(),
2469
2808
  reviewReason: "low_confidence"
2470
2809
  });
2810
+ return isLimitReached();
2471
2811
  });
2472
2812
  }
2473
2813
  return {
@@ -2487,6 +2827,8 @@ function performReview(memoryDir, itemId, action, options = {}) {
2487
2827
  }
2488
2828
  }
2489
2829
  function approveItem(memoryDir, itemId, options) {
2830
+ const rootReal = realMemoryRoot(memoryDir);
2831
+ if (!rootReal) return { itemId, action: "approve", message: "Item not found" };
2490
2832
  const found = findReviewFileById(memoryDir, itemId, options);
2491
2833
  if (!found) {
2492
2834
  return { itemId, action: "approve", message: "Item not found" };
@@ -2511,8 +2853,9 @@ function approveItem(memoryDir, itemId, options) {
2511
2853
  const category = fm.category ?? "fact";
2512
2854
  const targetDir = getCategoryDir(memoryDir, category);
2513
2855
  const dateDir = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
2514
- const outputPath = path10.join(targetDir, dateDir, path10.basename(found.filePath));
2515
- fs6.mkdirSync(path10.dirname(outputPath), { recursive: true });
2856
+ ensureSafeDirectory(rootReal, targetDir);
2857
+ const outputPath = path9.join(targetDir, dateDir, path9.basename(found.filePath));
2858
+ ensureSafeDirectory(rootReal, path9.dirname(outputPath));
2516
2859
  const promotedPath = writeFileWithoutClobber(outputPath, updatedContent, itemId);
2517
2860
  fs6.unlinkSync(found.filePath);
2518
2861
  return {
@@ -2566,22 +2909,24 @@ function flagItem(memoryDir, itemId, options) {
2566
2909
  };
2567
2910
  }
2568
2911
  function findReviewFileById(memoryDir, id, options = {}) {
2912
+ const rootReal = realMemoryRoot(memoryDir);
2913
+ if (!rootReal) return null;
2569
2914
  for (const loc of ["suggestions", "review"]) {
2570
- const dir = path10.join(memoryDir, loc);
2571
- if (!fs6.existsSync(dir)) continue;
2572
- const found = findFileById(dir, id);
2915
+ const dir = path9.join(memoryDir, loc);
2916
+ if (!fs6.existsSync(dir) || !isSafeDirectory(rootReal, dir)) continue;
2917
+ const found = findFileById(rootReal, dir, id);
2573
2918
  if (found) return { filePath: found, location: "queue" };
2574
2919
  }
2575
2920
  for (const category of ALL_CATEGORY_DIRS) {
2576
- const dir = path10.join(memoryDir, category);
2577
- if (!fs6.existsSync(dir)) continue;
2578
- const found = findFileById(dir, id, (fm) => isLowConfidenceReviewCandidate(fm, options));
2921
+ const dir = path9.join(memoryDir, category);
2922
+ if (!fs6.existsSync(dir) || !isSafeDirectory(rootReal, dir)) continue;
2923
+ const found = findFileById(rootReal, dir, id, (fm) => isLowConfidenceReviewCandidate(fm, options));
2579
2924
  if (found) return { filePath: found, location: "category" };
2580
2925
  }
2581
2926
  return null;
2582
2927
  }
2583
- function findFileById(dir, id, include) {
2584
- const files = walkMdPaths(dir);
2928
+ function findFileById(rootReal, dir, id, include) {
2929
+ const files = walkMdPaths(rootReal, dir);
2585
2930
  for (const filePath of files) {
2586
2931
  const content = readFileSafe3(filePath);
2587
2932
  if (!content) continue;
@@ -2646,10 +2991,10 @@ function readFileSafe3(filePath) {
2646
2991
  }
2647
2992
  }
2648
2993
  function writeFileWithoutClobber(basePath, content, discriminator) {
2649
- const parsed = path10.parse(basePath);
2994
+ const parsed = path9.parse(basePath);
2650
2995
  const safeDiscriminator = sanitizeFilePart(discriminator);
2651
2996
  for (let attempt = 0; attempt < 1e3; attempt++) {
2652
- const candidate = attempt === 0 ? basePath : path10.join(
2997
+ const candidate = attempt === 0 ? basePath : path9.join(
2653
2998
  parsed.dir,
2654
2999
  `${parsed.name}-${safeDiscriminator}${attempt === 1 ? "" : `-${attempt}`}${parsed.ext || ".md"}`
2655
3000
  );
@@ -2702,24 +3047,29 @@ function extractBody4(content) {
2702
3047
  const match = content.match(/^---\n[\s\S]*?\n---\n([\s\S]*)/);
2703
3048
  return match ? match[1].trim() : content.trim();
2704
3049
  }
2705
- function walkMd(dir, callback) {
3050
+ function walkMd(rootReal, dir, callback) {
3051
+ if (!isSafeDirectory(rootReal, dir)) return false;
2706
3052
  for (const entry of fs6.readdirSync(dir, { withFileTypes: true })) {
2707
- const fullPath = path10.join(dir, entry.name);
3053
+ const fullPath = path9.join(dir, entry.name);
3054
+ if (entry.isSymbolicLink()) continue;
2708
3055
  if (entry.isDirectory()) {
2709
- walkMd(fullPath, callback);
2710
- } else if (entry.name.endsWith(".md")) {
3056
+ if (walkMd(rootReal, fullPath, callback)) return true;
3057
+ } else if (entry.isFile() && entry.name.endsWith(".md")) {
2711
3058
  const content = readFileSafe3(fullPath);
2712
- if (content) callback(fullPath, content);
3059
+ if (content && callback(fullPath, content) === true) return true;
2713
3060
  }
2714
3061
  }
3062
+ return false;
2715
3063
  }
2716
- function walkMdPaths(dir) {
3064
+ function walkMdPaths(rootReal, dir) {
2717
3065
  const results = [];
3066
+ if (!isSafeDirectory(rootReal, dir)) return results;
2718
3067
  for (const entry of fs6.readdirSync(dir, { withFileTypes: true })) {
2719
- const fullPath = path10.join(dir, entry.name);
3068
+ const fullPath = path9.join(dir, entry.name);
3069
+ if (entry.isSymbolicLink()) continue;
2720
3070
  if (entry.isDirectory()) {
2721
- results.push(...walkMdPaths(fullPath));
2722
- } else if (entry.name.endsWith(".md")) {
3071
+ results.push(...walkMdPaths(rootReal, fullPath));
3072
+ } else if (entry.isFile() && entry.name.endsWith(".md")) {
2723
3073
  results.push(fullPath);
2724
3074
  }
2725
3075
  }
@@ -2728,8 +3078,8 @@ function walkMdPaths(dir) {
2728
3078
 
2729
3079
  // src/sync/index.ts
2730
3080
  import fs7 from "fs";
2731
- import path11 from "path";
2732
- import crypto5 from "crypto";
3081
+ import path10 from "path";
3082
+ import crypto6 from "crypto";
2733
3083
  var DEFAULT_EXTENSIONS = /* @__PURE__ */ new Set([".md", ".txt", ".mdx", ".rst"]);
2734
3084
  var DEFAULT_EXCLUDE2 = /* @__PURE__ */ new Set([
2735
3085
  "node_modules",
@@ -2750,7 +3100,7 @@ function syncChanges(options) {
2750
3100
  } = options;
2751
3101
  const extSet = new Set(extensions);
2752
3102
  const excludeSet = /* @__PURE__ */ new Set([...DEFAULT_EXCLUDE2, ...excludeDirs]);
2753
- const stateFilePath = options.stateFile ?? path11.join(memoryDir, ".sync-state.json");
3103
+ const stateFilePath = options.stateFile ?? path10.join(memoryDir, ".sync-state.json");
2754
3104
  const prevState = loadState(stateFilePath);
2755
3105
  const currentFiles = scanFiles(sourceDir, extSet, excludeSet);
2756
3106
  const changes = computeDiff(currentFiles, prevState.fileHashes, sourceDir);
@@ -2766,7 +3116,7 @@ function syncChanges(options) {
2766
3116
  for (const [relPath, hash] of Object.entries(currentFiles)) {
2767
3117
  newState.fileHashes[relPath] = hash;
2768
3118
  }
2769
- fs7.mkdirSync(path11.dirname(stateFilePath), { recursive: true });
3119
+ fs7.mkdirSync(path10.dirname(stateFilePath), { recursive: true });
2770
3120
  fs7.writeFileSync(stateFilePath, JSON.stringify(newState, null, 2));
2771
3121
  }
2772
3122
  return {
@@ -2783,45 +3133,62 @@ function watchForChanges(options, onChange) {
2783
3133
  const { sourceDir, extensions, excludeDirs } = options;
2784
3134
  const extSet = new Set(extensions ?? DEFAULT_EXTENSIONS);
2785
3135
  const excludeSet = /* @__PURE__ */ new Set([...DEFAULT_EXCLUDE2, ...excludeDirs ?? []]);
3136
+ const pollIntervalMs = typeof options.pollIntervalMs === "number" && Number.isFinite(options.pollIntervalMs) && options.pollIntervalMs > 0 ? options.pollIntervalMs : 5e3;
2786
3137
  let lastHashes = {};
3138
+ let pollInFlight = false;
2787
3139
  const currentFiles = scanFiles(sourceDir, extSet, excludeSet);
2788
3140
  lastHashes = { ...currentFiles };
2789
- const interval = setInterval(() => {
2790
- const nowFiles = scanFiles(sourceDir, extSet, excludeSet);
2791
- const changes = computeDiff(nowFiles, lastHashes, sourceDir);
2792
- if (changes.length > 0) {
2793
- for (const change of changes) {
2794
- if (change.type === "deleted") {
2795
- delete lastHashes[change.relativePath];
2796
- } else {
2797
- lastHashes[change.relativePath] = change.currentHash;
3141
+ const poll = async () => {
3142
+ if (pollInFlight) return;
3143
+ pollInFlight = true;
3144
+ try {
3145
+ const nowFiles = scanFiles(sourceDir, extSet, excludeSet);
3146
+ const changes = computeDiff(nowFiles, lastHashes, sourceDir);
3147
+ if (changes.length > 0) {
3148
+ await onChange(changes);
3149
+ for (const change of changes) {
3150
+ if (change.type === "deleted") {
3151
+ delete lastHashes[change.relativePath];
3152
+ } else {
3153
+ lastHashes[change.relativePath] = change.currentHash;
3154
+ }
2798
3155
  }
2799
3156
  }
2800
- onChange(changes);
3157
+ } catch {
3158
+ } finally {
3159
+ pollInFlight = false;
2801
3160
  }
2802
- }, 5e3);
3161
+ };
3162
+ const interval = setInterval(() => {
3163
+ void poll();
3164
+ }, pollIntervalMs);
2803
3165
  return {
2804
3166
  stop: () => clearInterval(interval)
2805
3167
  };
2806
3168
  }
2807
3169
  function scanFiles(root, extensions, exclude) {
2808
3170
  const result = {};
2809
- function walk(dir) {
3171
+ function walk(dir, isRoot = false) {
2810
3172
  let entries;
2811
3173
  try {
2812
3174
  entries = fs7.readdirSync(dir, { withFileTypes: true });
2813
- } catch {
3175
+ } catch (err) {
3176
+ if (isRoot) {
3177
+ throw new Error(
3178
+ `sync scan failed for ${dir}: ${err instanceof Error ? err.message : String(err)}`
3179
+ );
3180
+ }
2814
3181
  return;
2815
3182
  }
2816
3183
  for (const entry of entries) {
2817
3184
  if (exclude.has(entry.name)) continue;
2818
- const fullPath = path11.join(dir, entry.name);
3185
+ const fullPath = path10.join(dir, entry.name);
2819
3186
  if (entry.isDirectory()) {
2820
3187
  walk(fullPath);
2821
3188
  } else if (entry.isFile()) {
2822
- const ext = path11.extname(entry.name).toLowerCase();
3189
+ const ext = path10.extname(entry.name).toLowerCase();
2823
3190
  if (!extensions.has(ext)) continue;
2824
- const relPath = path11.relative(root, fullPath);
3191
+ const relPath = path10.relative(root, fullPath);
2825
3192
  try {
2826
3193
  const content = fs7.readFileSync(fullPath, "utf8");
2827
3194
  result[relPath] = hashContent3(content);
@@ -2830,13 +3197,13 @@ function scanFiles(root, extensions, exclude) {
2830
3197
  }
2831
3198
  }
2832
3199
  }
2833
- walk(root);
3200
+ walk(root, true);
2834
3201
  return result;
2835
3202
  }
2836
3203
  function computeDiff(current, previous, sourceDir) {
2837
3204
  const changes = [];
2838
3205
  for (const [relPath, hash] of Object.entries(current)) {
2839
- const fullPath = path11.join(sourceDir, relPath);
3206
+ const fullPath = path10.join(sourceDir, relPath);
2840
3207
  if (!(relPath in previous)) {
2841
3208
  let size = 0;
2842
3209
  try {
@@ -2869,7 +3236,7 @@ function computeDiff(current, previous, sourceDir) {
2869
3236
  for (const relPath of Object.keys(previous)) {
2870
3237
  if (!(relPath in current)) {
2871
3238
  changes.push({
2872
- filePath: path11.join(sourceDir, relPath),
3239
+ filePath: path10.join(sourceDir, relPath),
2873
3240
  relativePath: relPath,
2874
3241
  type: "deleted",
2875
3242
  currentHash: "",
@@ -2892,20 +3259,23 @@ function loadState(stateFilePath) {
2892
3259
  }
2893
3260
  }
2894
3261
  function hashContent3(content) {
2895
- return crypto5.createHash("sha256").update(content).digest("hex").slice(0, 16);
3262
+ return crypto6.createHash("sha256").update(content).digest("hex").slice(0, 16);
2896
3263
  }
2897
3264
 
2898
3265
  // src/spaces/index.ts
2899
3266
  import fs8 from "fs";
2900
- import path12 from "path";
2901
- import crypto6 from "crypto";
3267
+ import path11 from "path";
3268
+ import crypto7 from "crypto";
2902
3269
  var MANIFEST_VERSION = 1;
3270
+ function normalizeSpaceMemoryDir(memoryDir) {
3271
+ return path11.resolve(memoryDir);
3272
+ }
2903
3273
  function getSpacesDir(baseDir) {
2904
3274
  const homeDir = baseDir ?? resolveHomeDir();
2905
- return path12.join(homeDir, ".config", "engram", "spaces");
3275
+ return path11.join(homeDir, ".config", "engram", "spaces");
2906
3276
  }
2907
3277
  function getManifestPath(baseDir) {
2908
- return path12.join(getSpacesDir(baseDir), "manifest.json");
3278
+ return path11.join(getSpacesDir(baseDir), "manifest.json");
2909
3279
  }
2910
3280
  function loadManifest(baseDir, memoryDirOverride) {
2911
3281
  const manifestPath2 = getManifestPath(baseDir);
@@ -2924,21 +3294,22 @@ function loadManifest(baseDir, memoryDirOverride) {
2924
3294
  }
2925
3295
  function saveManifest(manifest, baseDir) {
2926
3296
  const manifestPath2 = getManifestPath(baseDir);
2927
- fs8.mkdirSync(path12.dirname(manifestPath2), { recursive: true });
3297
+ fs8.mkdirSync(path11.dirname(manifestPath2), { recursive: true });
2928
3298
  fs8.writeFileSync(manifestPath2, JSON.stringify(manifest, null, 2) + "\n");
2929
3299
  }
2930
3300
  function createPersonalSpace(baseDir, memoryDirOverride) {
2931
3301
  const homeDir = baseDir ?? resolveHomeDir();
2932
- const standalonePath = path12.join(homeDir, ".engram", "memory");
2933
- const openclawPath = path12.join(homeDir, ".openclaw", "workspace", "memory", "local");
2934
- const memoryDir = memoryDirOverride ?? readEnvVar("ENGRAM_MEMORY_DIR") ?? (fs8.existsSync(standalonePath) ? standalonePath : fs8.existsSync(openclawPath) ? openclawPath : standalonePath);
3302
+ const standalonePath = path11.join(homeDir, ".engram", "memory");
3303
+ const openclawPath = path11.join(homeDir, ".openclaw", "workspace", "memory", "local");
3304
+ const memoryDir = memoryDirOverride ?? readEnvVar("REMNIC_MEMORY_DIR") ?? readEnvVar("ENGRAM_MEMORY_DIR") ?? (fs8.existsSync(standalonePath) ? standalonePath : fs8.existsSync(openclawPath) ? openclawPath : standalonePath);
3305
+ const normalizedMemoryDir = normalizeSpaceMemoryDir(memoryDir);
2935
3306
  const now = (/* @__PURE__ */ new Date()).toISOString();
2936
3307
  return {
2937
3308
  id: "personal",
2938
3309
  name: "Personal",
2939
3310
  kind: "personal",
2940
3311
  description: "Default personal memory space",
2941
- memoryDir,
3312
+ memoryDir: normalizedMemoryDir,
2942
3313
  createdAt: now,
2943
3314
  updatedAt: now,
2944
3315
  owner: readEnvVar("USER")
@@ -2964,10 +3335,12 @@ function createSpace(options) {
2964
3335
  throw new Error(`Parent space "${options.parentSpaceId}" not found`);
2965
3336
  }
2966
3337
  const now = (/* @__PURE__ */ new Date()).toISOString();
2967
- const memoryDir = options.memoryDir ?? path12.join(
2968
- getSpacesDir(options.baseDir),
2969
- id,
2970
- "memory"
3338
+ const memoryDir = normalizeSpaceMemoryDir(
3339
+ options.memoryDir ?? path11.join(
3340
+ getSpacesDir(options.baseDir),
3341
+ id,
3342
+ "memory"
3343
+ )
2971
3344
  );
2972
3345
  const space = {
2973
3346
  id,
@@ -3154,16 +3527,16 @@ function mergeSpaces(sourceSpaceId, targetSpaceId, options) {
3154
3527
  };
3155
3528
  }
3156
3529
  function getAuditLog(baseDir) {
3157
- const auditPath = path12.join(getSpacesDir(baseDir), "audit.jsonl");
3530
+ const auditPath = path11.join(getSpacesDir(baseDir), "audit.jsonl");
3158
3531
  if (!fs8.existsSync(auditPath)) return [];
3159
3532
  const lines = fs8.readFileSync(auditPath, "utf8").trim().split("\n");
3160
3533
  return lines.filter((l) => l.trim()).map((l) => JSON.parse(l));
3161
3534
  }
3162
3535
  function appendAudit(entry, baseDir) {
3163
- const auditPath = path12.join(getSpacesDir(baseDir), "audit.jsonl");
3164
- fs8.mkdirSync(path12.dirname(auditPath), { recursive: true });
3536
+ const auditPath = path11.join(getSpacesDir(baseDir), "audit.jsonl");
3537
+ fs8.mkdirSync(path11.dirname(auditPath), { recursive: true });
3165
3538
  const full = {
3166
- id: crypto6.randomUUID(),
3539
+ id: crypto7.randomUUID(),
3167
3540
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
3168
3541
  ...entry
3169
3542
  };
@@ -3176,12 +3549,28 @@ function copyMemories(sourceDir, targetDir, options) {
3176
3549
  if (!fs8.existsSync(sourceDir)) {
3177
3550
  return { merged: 0, conflicts: [], skipped: 0 };
3178
3551
  }
3552
+ const sourceRoot = fs8.realpathSync(sourceDir);
3179
3553
  fs8.mkdirSync(targetDir, { recursive: true });
3180
- const sourceFiles = walkMd2(sourceDir);
3554
+ const targetRoot = fs8.realpathSync(targetDir);
3555
+ const sourceFiles = walkMd2(sourceRoot);
3181
3556
  for (const sourcePath of sourceFiles) {
3557
+ const sourceRealPath = safeRealpath(sourcePath);
3558
+ if (!sourceRealPath || !isPathInsideRoot(sourceRealPath, sourceRoot)) {
3559
+ skipped++;
3560
+ continue;
3561
+ }
3562
+ const sourceStat = safeLstat(sourcePath);
3563
+ if (!sourceStat?.isFile()) {
3564
+ skipped++;
3565
+ continue;
3566
+ }
3182
3567
  const content = fs8.readFileSync(sourcePath, "utf8");
3183
- const relativePath = path12.relative(sourceDir, sourcePath);
3184
- const targetPath = path12.join(targetDir, relativePath);
3568
+ const relativePath = path11.relative(sourceRoot, sourceRealPath);
3569
+ const targetPath = path11.resolve(targetRoot, relativePath);
3570
+ if (!isPathInsideRoot(targetPath, targetRoot)) {
3571
+ skipped++;
3572
+ continue;
3573
+ }
3185
3574
  const sourceHash = hashContent4(content);
3186
3575
  if (options?.filterIds?.length) {
3187
3576
  const fm = parseSimpleFrontmatter(content);
@@ -3190,6 +3579,18 @@ function copyMemories(sourceDir, targetDir, options) {
3190
3579
  continue;
3191
3580
  }
3192
3581
  }
3582
+ if (fs8.existsSync(targetPath)) {
3583
+ const targetStat = safeLstat(targetPath);
3584
+ if (!targetStat?.isFile() || targetStat.isSymbolicLink()) {
3585
+ skipped++;
3586
+ continue;
3587
+ }
3588
+ const targetRealPath = safeRealpath(targetPath);
3589
+ if (!targetRealPath || !isPathInsideRoot(targetRealPath, targetRoot)) {
3590
+ skipped++;
3591
+ continue;
3592
+ }
3593
+ }
3193
3594
  if (fs8.existsSync(targetPath) && !options?.force) {
3194
3595
  const targetContent = fs8.readFileSync(targetPath, "utf8");
3195
3596
  const targetHash = hashContent4(targetContent);
@@ -3207,20 +3608,28 @@ function copyMemories(sourceDir, targetDir, options) {
3207
3608
  skipped++;
3208
3609
  continue;
3209
3610
  }
3210
- fs8.mkdirSync(path12.dirname(targetPath), { recursive: true });
3611
+ fs8.mkdirSync(path11.dirname(targetPath), { recursive: true });
3612
+ const targetParentRealPath = safeRealpath(path11.dirname(targetPath));
3613
+ if (!targetParentRealPath || !isPathInsideRoot(targetParentRealPath, targetRoot)) {
3614
+ skipped++;
3615
+ continue;
3616
+ }
3211
3617
  fs8.writeFileSync(targetPath, content);
3212
3618
  merged++;
3213
3619
  }
3214
3620
  return { merged, conflicts, skipped };
3215
3621
  }
3216
3622
  function hashContent4(content) {
3217
- return crypto6.createHash("sha256").update(content).digest("hex").slice(0, 16);
3623
+ return crypto7.createHash("sha256").update(content).digest("hex").slice(0, 16);
3218
3624
  }
3219
3625
  function walkMd2(dir) {
3220
3626
  const results = [];
3221
3627
  function walk(d) {
3222
3628
  for (const entry of fs8.readdirSync(d, { withFileTypes: true })) {
3223
- const fullPath = path12.join(d, entry.name);
3629
+ const fullPath = path11.join(d, entry.name);
3630
+ if (entry.isSymbolicLink()) {
3631
+ continue;
3632
+ }
3224
3633
  if (entry.isDirectory()) {
3225
3634
  walk(fullPath);
3226
3635
  } else if (entry.name.endsWith(".md")) {
@@ -3231,6 +3640,24 @@ function walkMd2(dir) {
3231
3640
  walk(dir);
3232
3641
  return results;
3233
3642
  }
3643
+ function safeLstat(filePath) {
3644
+ try {
3645
+ return fs8.lstatSync(filePath);
3646
+ } catch {
3647
+ return null;
3648
+ }
3649
+ }
3650
+ function safeRealpath(filePath) {
3651
+ try {
3652
+ return fs8.realpathSync(filePath);
3653
+ } catch {
3654
+ return null;
3655
+ }
3656
+ }
3657
+ function isPathInsideRoot(candidatePath, rootPath) {
3658
+ const relative = path11.relative(rootPath, candidatePath);
3659
+ return relative === "" || !relative.startsWith("..") && !path11.isAbsolute(relative);
3660
+ }
3234
3661
  function parseSimpleFrontmatter(content) {
3235
3662
  const match = content.match(/^---\n([\s\S]*?)\n---/);
3236
3663
  if (!match) return null;
@@ -3350,23 +3777,39 @@ var REMNIC_RECALL_DECISION_RULES = `## When to Use Recall vs Direct Read
3350
3777
  // src/memory-extension/codex-publisher.ts
3351
3778
  import fs9 from "fs";
3352
3779
  import os from "os";
3353
- import path13 from "path";
3780
+ import path12 from "path";
3354
3781
  var REMNIC_EXTENSION_DIR_NAME = "remnic";
3782
+ function resolveEnvHome(env) {
3783
+ if (env === void 0) return resolveHomeDir();
3784
+ return env.HOME?.trim() || env.USERPROFILE?.trim() || os.homedir();
3785
+ }
3786
+ function expandTildeWithHome(input, homeDir) {
3787
+ if (input === "~") return homeDir;
3788
+ if (input.startsWith("~/") || input.startsWith("~\\")) {
3789
+ return path12.join(homeDir, input.slice(2));
3790
+ }
3791
+ return input;
3792
+ }
3793
+ function normalizeHostRoot(input, homeDir) {
3794
+ return path12.resolve(expandTildeWithHome(input.trim(), homeDir));
3795
+ }
3355
3796
  var CodexMemoryExtensionPublisher = class {
3356
3797
  hostId = "codex";
3357
3798
  static capabilities = {
3358
3799
  instructionsMd: true,
3359
- skillsFolder: true,
3800
+ skillsFolder: false,
3360
3801
  citationFormat: true,
3361
3802
  readPathTemplate: true
3362
3803
  };
3363
3804
  async resolveExtensionRoot(env) {
3364
- const codexHome = env === void 0 ? readEnvVar("CODEX_HOME")?.trim() || path13.join(resolveHomeDir(), ".codex") : env.CODEX_HOME?.trim() || path13.join(env.HOME ?? env.USERPROFILE ?? os.homedir(), ".codex");
3365
- return path13.join(codexHome, "memories_extensions", REMNIC_EXTENSION_DIR_NAME);
3805
+ const homeDir = resolveEnvHome(env);
3806
+ const codexHomeInput = env === void 0 ? readEnvVar("CODEX_HOME")?.trim() : env.CODEX_HOME?.trim();
3807
+ const codexHome = codexHomeInput ? normalizeHostRoot(codexHomeInput, homeDir) : path12.resolve(homeDir, ".codex");
3808
+ return path12.join(codexHome, "memories_extensions", REMNIC_EXTENSION_DIR_NAME);
3366
3809
  }
3367
3810
  async isHostAvailable() {
3368
3811
  try {
3369
- const home = readEnvVar("CODEX_HOME")?.trim() || path13.join(resolveHomeDir(), ".codex");
3812
+ const home = readEnvVar("CODEX_HOME")?.trim() || path12.join(resolveHomeDir(), ".codex");
3370
3813
  return fs9.existsSync(home);
3371
3814
  } catch {
3372
3815
  return false;
@@ -3417,7 +3860,7 @@ When running inside the Codex phase-2 consolidation sandbox:
3417
3860
  }
3418
3861
  async publish(ctx) {
3419
3862
  const extensionRoot = await this.resolveExtensionRoot();
3420
- const instructionsPath = path13.join(extensionRoot, "instructions.md");
3863
+ const instructionsPath = path12.join(extensionRoot, "instructions.md");
3421
3864
  const filesWritten = [];
3422
3865
  const skipped = [];
3423
3866
  ctx.log.info(`Publishing Codex memory extension to ${extensionRoot}`);
@@ -3532,141 +3975,21 @@ function publisherForConnector(connectorId) {
3532
3975
  return publisherFor(hostIdForConnector(connectorId));
3533
3976
  }
3534
3977
 
3535
- // src/importers/base.ts
3536
- var DEFAULT_IMPORT_BATCH_SIZE = 25;
3537
- var MIN_IMPORT_BATCH_SIZE = 1;
3538
- var MAX_IMPORT_BATCH_SIZE = 500;
3539
- function validateImportBatchSize(value) {
3540
- if (value === void 0) return DEFAULT_IMPORT_BATCH_SIZE;
3541
- if (typeof value !== "number" || !Number.isFinite(value)) {
3542
- throw new Error(
3543
- `batchSize must be a finite number, received ${String(value)}`
3544
- );
3545
- }
3546
- if (!Number.isInteger(value)) {
3547
- throw new Error(`batchSize must be an integer, received ${value}`);
3548
- }
3549
- if (value < MIN_IMPORT_BATCH_SIZE || value > MAX_IMPORT_BATCH_SIZE) {
3550
- throw new Error(
3551
- `batchSize must be between ${MIN_IMPORT_BATCH_SIZE} and ${MAX_IMPORT_BATCH_SIZE}, received ${value}`
3552
- );
3553
- }
3554
- return value;
3555
- }
3556
- function validateImportRateLimit(value) {
3557
- if (value === void 0) return void 0;
3558
- if (typeof value !== "number" || !Number.isFinite(value)) {
3559
- throw new Error(
3560
- `rateLimit must be a finite number (requests per second), received ${String(value)}`
3561
- );
3562
- }
3563
- if (value <= 0) {
3564
- throw new Error(
3565
- `rateLimit must be greater than 0 (requests per second), received ${value}`
3566
- );
3567
- }
3568
- return value;
3569
- }
3570
- function importedMemoryToTurn(memory) {
3571
- const timestamp = typeof memory.sourceTimestamp === "string" && memory.sourceTimestamp.length > 0 ? memory.sourceTimestamp : memory.importedAt ?? (/* @__PURE__ */ new Date()).toISOString();
3572
- return {
3573
- role: "user",
3574
- content: memory.content,
3575
- timestamp,
3576
- participantName: memory.sourceLabel,
3577
- ...memory.sourceId !== void 0 ? { participantId: memory.sourceId } : {}
3578
- };
3579
- }
3580
- async function runImporter(adapter, input, target, options = {}) {
3581
- const batchSize = validateImportBatchSize(options.batchSize);
3582
- validateImportRateLimit(options.rateLimit);
3583
- const importedAt = (/* @__PURE__ */ new Date()).toISOString();
3584
- const dryRun = options.dryRun === true;
3585
- const onProgress = options.onProgress;
3586
- onProgress?.({ processed: 0, total: 0, phase: "parse" });
3587
- const parseOptions = {
3588
- ...options.rateLimit !== void 0 ? { rateLimit: options.rateLimit } : {},
3589
- ...options.parseOptions ?? {}
3590
- };
3591
- const parsed = await adapter.parse(input, parseOptions);
3592
- onProgress?.({ processed: 0, total: 0, phase: "transform" });
3593
- const memoriesRaw = await adapter.transform(parsed, options.transformOptions);
3594
- if (!Array.isArray(memoriesRaw)) {
3595
- throw new Error(
3596
- `Importer '${adapter.name}' transform() returned a non-array. Adapters must produce ImportedMemory[].`
3597
- );
3598
- }
3599
- const memories = memoriesRaw.map((memory) => {
3600
- const sourceLabel = typeof memory.sourceLabel === "string" && memory.sourceLabel.length > 0 ? memory.sourceLabel : adapter.sourceLabel;
3601
- return {
3602
- ...memory,
3603
- sourceLabel,
3604
- importedAt: memory.importedAt ?? importedAt
3605
- };
3606
- });
3607
- if (dryRun) {
3608
- onProgress?.({
3609
- processed: memories.length,
3610
- total: memories.length,
3611
- phase: "dry-run"
3612
- });
3613
- return {
3614
- adapter: adapter.name,
3615
- sourceLabel: adapter.sourceLabel,
3616
- memoriesPlanned: memories.length,
3617
- memoriesWritten: 0,
3618
- batchesProcessed: 0,
3619
- dryRun: true,
3620
- importedAt
3621
- };
3622
- }
3623
- let batchesProcessed = 0;
3624
- let memoriesWritten = 0;
3625
- for (let i = 0; i < memories.length; i += batchSize) {
3626
- const batch = memories.slice(i, i + batchSize);
3627
- const result = await adapter.writeTo(target, batch, options);
3628
- memoriesWritten += result.memoriesIngested;
3629
- batchesProcessed += 1;
3630
- onProgress?.({
3631
- processed: Math.min(i + batch.length, memories.length),
3632
- total: memories.length,
3633
- phase: "write"
3634
- });
3635
- }
3636
- return {
3637
- adapter: adapter.name,
3638
- sourceLabel: adapter.sourceLabel,
3639
- memoriesPlanned: memories.length,
3640
- memoriesWritten,
3641
- batchesProcessed,
3642
- dryRun: false,
3643
- importedAt
3644
- };
3645
- }
3646
- async function defaultWriteMemoriesToOrchestrator(target, memories) {
3647
- if (memories.length === 0) {
3648
- return { memoriesIngested: 0 };
3649
- }
3650
- const turns = memories.map(importedMemoryToTurn);
3651
- await target.ingestBulkImportBatch(turns);
3652
- return { memoriesIngested: memories.length };
3653
- }
3654
-
3655
3978
  // src/transfer/capsule-fork.ts
3656
3979
  import { lstat, mkdir, readFile, realpath, writeFile } from "fs/promises";
3657
- import path14 from "path";
3980
+ import path13 from "path";
3658
3981
  async function forkCapsule(opts) {
3659
3982
  validateForkId(opts.forkId);
3660
- const rootAbs = path14.resolve(opts.targetRoot);
3983
+ const rootAbs = path13.resolve(opts.targetRoot);
3661
3984
  await assertIsDirectoryNotSymlink(rootAbs, "forkCapsule", "targetRoot");
3662
- const forkDirAbs = path14.join(rootAbs, "forks", opts.forkId);
3985
+ const forkDirAbs = path13.join(rootAbs, "forks", opts.forkId);
3663
3986
  const forkEntryExists = await pathEntryExists(forkDirAbs);
3664
3987
  if (forkEntryExists) {
3665
3988
  throw new Error(
3666
3989
  `forkCapsule: fork path already exists \u2014 forkId "${opts.forkId}" is already in use at: ${forkDirAbs}`
3667
3990
  );
3668
3991
  }
3669
- const archiveAbs = path14.resolve(opts.sourceArchive);
3992
+ const archiveAbs = path13.resolve(opts.sourceArchive);
3670
3993
  const importResult = await importCapsule({
3671
3994
  archivePath: archiveAbs,
3672
3995
  root: rootAbs,
@@ -3688,10 +4011,10 @@ async function forkCapsule(opts) {
3688
4011
  importedRecords: importResult.imported.length,
3689
4012
  skippedRecords: importResult.skipped.length
3690
4013
  };
3691
- const lineagePath = path14.join(forkDirAbs, "lineage.json");
4014
+ const lineagePath = path13.join(forkDirAbs, "lineage.json");
3692
4015
  const rootReal = await realpath(rootAbs);
3693
4016
  await assertRealpathInsideRoot(rootReal, lineagePath, `forks/${opts.forkId}/lineage.json`, "forkCapsule");
3694
- await mkdir(path14.dirname(lineagePath), { recursive: true });
4017
+ await mkdir(path13.dirname(lineagePath), { recursive: true });
3695
4018
  await writeFile(lineagePath, JSON.stringify(lineage, null, 2) + "\n", "utf-8");
3696
4019
  return {
3697
4020
  archivePath: archiveAbs,
@@ -3705,11 +4028,11 @@ async function readForkLineage(targetRoot, forkId) {
3705
4028
  if (typeof forkId !== "string" || forkId.length === 0 || forkId.length > 64 || !CAPSULE_ID_PATTERN.test(forkId)) {
3706
4029
  return null;
3707
4030
  }
3708
- const rootAbs = path14.resolve(targetRoot);
4031
+ const rootAbs = path13.resolve(targetRoot);
3709
4032
  const rootReal = await realpath(rootAbs).catch(() => rootAbs);
3710
- const lineagePath = path14.join(rootReal, "forks", forkId, "lineage.json");
3711
- const rel = path14.relative(rootReal, lineagePath);
3712
- if (rel.startsWith("..") || path14.isAbsolute(rel)) {
4033
+ const lineagePath = path13.join(rootReal, "forks", forkId, "lineage.json");
4034
+ const rel = path13.relative(rootReal, lineagePath);
4035
+ if (rel.startsWith("..") || path13.isAbsolute(rel)) {
3713
4036
  return null;
3714
4037
  }
3715
4038
  if (!await isLineagePathContained(rootReal, lineagePath)) {
@@ -3750,19 +4073,19 @@ async function pathEntryExists(absPath) {
3750
4073
  async function isLineagePathContained(rootReal, lineagePath) {
3751
4074
  let existing = lineagePath;
3752
4075
  const suffix = [];
3753
- while (existing !== path14.dirname(existing)) {
4076
+ while (existing !== path13.dirname(existing)) {
3754
4077
  const st = await lstat(existing).catch(() => null);
3755
4078
  if (st !== null) break;
3756
- suffix.unshift(path14.basename(existing));
3757
- existing = path14.dirname(existing);
4079
+ suffix.unshift(path13.basename(existing));
4080
+ existing = path13.dirname(existing);
3758
4081
  }
3759
4082
  const existingReal = await realpath(existing).catch(() => existing);
3760
- const targetReal = suffix.length > 0 ? path14.join(existingReal, ...suffix) : existingReal;
3761
- const rel = path14.relative(rootReal, targetReal);
4083
+ const targetReal = suffix.length > 0 ? path13.join(existingReal, ...suffix) : existingReal;
4084
+ const rel = path13.relative(rootReal, targetReal);
3762
4085
  if (rel === "") return true;
3763
4086
  if (rel === "..") return false;
3764
- if (rel.startsWith(`..${path14.sep}`)) return false;
3765
- if (path14.isAbsolute(rel)) return false;
4087
+ if (rel.startsWith(`..${path13.sep}`)) return false;
4088
+ if (path13.isAbsolute(rel)) return false;
3766
4089
  return true;
3767
4090
  }
3768
4091
  export {
@@ -3809,7 +4132,6 @@ export {
3809
4132
  GOOGLE_DRIVE_CURSOR_KIND,
3810
4133
  DEFAULT_POLL_INTERVAL_MS as GOOGLE_DRIVE_DEFAULT_POLL_INTERVAL_MS,
3811
4134
  HermesMemoryExtensionPublisher,
3812
- LEGACY_PLUGIN_ID,
3813
4135
  LanceDbBackend,
3814
4136
  LiveConnectorRegistry,
3815
4137
  LiveConnectorRegistryError,
@@ -3834,7 +4156,6 @@ export {
3834
4156
  PEERS_DIR_NAME,
3835
4157
  PEER_ID_MAX_LENGTH,
3836
4158
  PEER_ID_PATTERN,
3837
- PLUGIN_ID,
3838
4159
  PUBLISHERS,
3839
4160
  QmdClient,
3840
4161
  RECALL_DISCLOSURE_LEVELS,
@@ -4115,6 +4436,7 @@ export {
4115
4436
  reportBufferSurpriseDistribution,
4116
4437
  resolveAgentAccessAuthToken,
4117
4438
  resolveBriefingSaveDir,
4439
+ resolveBulkImportContext,
4118
4440
  resolveCategory,
4119
4441
  resolveCodingNamespaceOverlay,
4120
4442
  resolveConnectorFromToken,
@@ -4122,8 +4444,8 @@ export {
4122
4444
  resolveExtensionsRoot,
4123
4445
  resolveGitContext,
4124
4446
  resolvePair,
4447
+ resolvePluginEntry,
4125
4448
  resolvePrincipal,
4126
- resolveRemnicPluginEntry,
4127
4449
  revertToVersion,
4128
4450
  revokeToken,
4129
4451
  rollbackFromEngramMigration,
@@ -4163,6 +4485,7 @@ export {
4163
4485
  summarizeUserModelCoverage,
4164
4486
  switchSpace,
4165
4487
  syncChanges,
4488
+ validateBatchSize,
4166
4489
  validateBriefingFormat,
4167
4490
  validateGoogleDriveConfig,
4168
4491
  validateImportBatchSize,