@remnic/core 1.1.30 → 9.3.515

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