@remnic/core 1.1.11 → 1.1.13

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 (1462) hide show
  1. package/README.md +3 -3
  2. package/dist/access-cli.d.ts +2 -1
  3. package/dist/access-cli.js +293 -104
  4. package/dist/access-cli.js.map +1 -1
  5. package/dist/access-http.d.ts +31 -62
  6. package/dist/access-http.js +53 -35
  7. package/dist/access-mcp.d.ts +31 -8
  8. package/dist/access-mcp.js +45 -34
  9. package/dist/access-schema.d.ts +197 -14
  10. package/dist/access-schema.js +16 -5
  11. package/dist/access-service-DcCDmNYC.d.ts +1542 -0
  12. package/dist/access-service.d.ts +30 -9
  13. package/dist/access-service.js +42 -32
  14. package/dist/action-confidence.d.ts +83 -0
  15. package/dist/action-confidence.js +22 -0
  16. package/dist/active-memory-bridge.d.ts +1 -1
  17. package/dist/active-memory-bridge.js +2 -2
  18. package/dist/active-recall.d.ts +1 -1
  19. package/dist/active-recall.js +11 -3
  20. package/dist/active-recall.js.map +1 -1
  21. package/dist/adapters/claude-code.d.ts +24 -0
  22. package/dist/adapters/claude-code.js +9 -0
  23. package/dist/adapters/codex.d.ts +25 -0
  24. package/dist/adapters/codex.js +9 -0
  25. package/dist/adapters/hermes.d.ts +35 -0
  26. package/dist/adapters/hermes.js +9 -0
  27. package/dist/adapters/index.d.ts +6 -0
  28. package/dist/adapters/index.js +26 -0
  29. package/dist/adapters/registry.d.ts +20 -0
  30. package/dist/adapters/registry.js +13 -0
  31. package/dist/adapters/replit.d.ts +28 -0
  32. package/dist/adapters/replit.js +9 -0
  33. package/dist/adapters/types.d.ts +43 -0
  34. package/dist/adapters/types.js +8 -0
  35. package/dist/behavior-learner.d.ts +1 -1
  36. package/dist/behavior-signals.d.ts +1 -1
  37. package/dist/bootstrap.d.ts +23 -6
  38. package/dist/boxes.d.ts +7 -0
  39. package/dist/boxes.js +1 -1
  40. package/dist/briefing.d.ts +5 -3
  41. package/dist/briefing.js +10 -7
  42. package/dist/buffer-surprise-report.d.ts +1 -1
  43. package/dist/buffer-surprise-report.js +1 -1
  44. package/dist/buffer.d.ts +18 -4
  45. package/dist/buffer.js +1 -1
  46. package/dist/calibration.d.ts +1 -1
  47. package/dist/calibration.js +6 -6
  48. package/dist/capsule-cli.d.ts +4 -4
  49. package/dist/capsule-cli.js +1 -1
  50. package/dist/capsule-crypto-5CYAGVC5.js +18 -0
  51. package/dist/capsule-merge-4MGKE7C5.js +189 -0
  52. package/dist/causal-behavior.d.ts +9 -29
  53. package/dist/causal-behavior.js +6 -3
  54. package/dist/causal-behavior.js.map +1 -1
  55. package/dist/causal-chain.js +3 -2
  56. package/dist/causal-consolidation.d.ts +2 -2
  57. package/dist/causal-consolidation.js +28 -17
  58. package/dist/causal-consolidation.js.map +1 -1
  59. package/dist/causal-retrieval.js +3 -3
  60. package/dist/causal-trajectory.js +1 -1
  61. package/dist/chunk-25MQ7IHJ.js +427 -0
  62. package/dist/chunk-25MQ7IHJ.js.map +1 -0
  63. package/dist/chunk-2F2W355T.js +256 -0
  64. package/dist/chunk-2F2W355T.js.map +1 -0
  65. package/dist/chunk-2KI4QFHU.js +228 -0
  66. package/dist/chunk-2KI4QFHU.js.map +1 -0
  67. package/dist/chunk-2PRQG7PV.js +86 -0
  68. package/dist/chunk-2PRQG7PV.js.map +1 -0
  69. package/dist/chunk-2QR3XXIC.js +2272 -0
  70. package/dist/chunk-2QR3XXIC.js.map +1 -0
  71. package/dist/chunk-2WWLHTZY.js +121 -0
  72. package/dist/chunk-326G7DJK.js +2185 -0
  73. package/dist/chunk-326G7DJK.js.map +1 -0
  74. package/dist/chunk-34DQE4KF.js +174 -0
  75. package/dist/chunk-34DQE4KF.js.map +1 -0
  76. package/dist/chunk-3APJ5EVB.js +601 -0
  77. package/dist/chunk-3APJ5EVB.js.map +1 -0
  78. package/dist/chunk-3HPAPHUK.js +51 -0
  79. package/dist/chunk-3HPAPHUK.js.map +1 -0
  80. package/dist/chunk-3JXBXXM2.js +69 -0
  81. package/dist/chunk-3JXBXXM2.js.map +1 -0
  82. package/dist/chunk-3KW65B36.js +681 -0
  83. package/dist/chunk-3KW65B36.js.map +1 -0
  84. package/dist/chunk-3UXOZBHV.js +20 -0
  85. package/dist/chunk-3UXOZBHV.js.map +1 -0
  86. package/dist/chunk-3VAL7ZL2.js +266 -0
  87. package/dist/chunk-3VAL7ZL2.js.map +1 -0
  88. package/dist/chunk-3Y4P7RXM.js +31 -0
  89. package/dist/chunk-3Y4P7RXM.js.map +1 -0
  90. package/dist/chunk-47VWKCAF.js +273 -0
  91. package/dist/chunk-47VWKCAF.js.map +1 -0
  92. package/dist/chunk-4CRG46BG.js +271 -0
  93. package/dist/chunk-4RA3C3EV.js +60 -0
  94. package/dist/chunk-4RA3C3EV.js.map +1 -0
  95. package/dist/chunk-5375UYTQ.js +914 -0
  96. package/dist/chunk-5375UYTQ.js.map +1 -0
  97. package/dist/chunk-56K5QLHX.js +506 -0
  98. package/dist/chunk-56K5QLHX.js.map +1 -0
  99. package/dist/chunk-5NXIJZFX.js +180 -0
  100. package/dist/chunk-5NXIJZFX.js.map +1 -0
  101. package/dist/chunk-5RGLBDQF.js +596 -0
  102. package/dist/chunk-5RGLBDQF.js.map +1 -0
  103. package/dist/chunk-5UZXUTVO.js +9 -0
  104. package/dist/chunk-5UZXUTVO.js.map +1 -0
  105. package/dist/chunk-65PG43EQ.js +105 -0
  106. package/dist/chunk-65PG43EQ.js.map +1 -0
  107. package/dist/chunk-66DHUKLO.js +57 -0
  108. package/dist/chunk-66DHUKLO.js.map +1 -0
  109. package/dist/chunk-6FC5EGNV.js +46 -0
  110. package/dist/chunk-6FC5EGNV.js.map +1 -0
  111. package/dist/chunk-6H2TESSP.js +62 -0
  112. package/dist/chunk-6H2TESSP.js.map +1 -0
  113. package/dist/chunk-6LVVDPJ4.js +32 -0
  114. package/dist/chunk-6LVVDPJ4.js.map +1 -0
  115. package/dist/chunk-6NKAQ74D.js +2237 -0
  116. package/dist/chunk-6NKAQ74D.js.map +1 -0
  117. package/dist/chunk-6RVI47ZR.js +159 -0
  118. package/dist/chunk-6RVI47ZR.js.map +1 -0
  119. package/dist/chunk-7AAT6G4Q.js +5117 -0
  120. package/dist/chunk-7AAT6G4Q.js.map +1 -0
  121. package/dist/chunk-7DTASS5T.js +29 -0
  122. package/dist/chunk-7DTASS5T.js.map +1 -0
  123. package/dist/chunk-7IASACLB.js +596 -0
  124. package/dist/chunk-7MNMYOFP.js +32 -0
  125. package/dist/chunk-7MNMYOFP.js.map +1 -0
  126. package/dist/chunk-7N4KAIGN.js +133 -0
  127. package/dist/chunk-7N4KAIGN.js.map +1 -0
  128. package/dist/chunk-7OZ53EXP.js +101 -0
  129. package/dist/chunk-7OZ53EXP.js.map +1 -0
  130. package/dist/chunk-7XYTQGCC.js +134 -0
  131. package/dist/chunk-7XYTQGCC.js.map +1 -0
  132. package/dist/chunk-A2XUIMJ3.js +341 -0
  133. package/dist/chunk-A2XUIMJ3.js.map +1 -0
  134. package/dist/chunk-AC5LO7IU.js +308 -0
  135. package/dist/chunk-AC5LO7IU.js.map +1 -0
  136. package/dist/chunk-AGZQD76C.js +201 -0
  137. package/dist/chunk-AGZQD76C.js.map +1 -0
  138. package/dist/chunk-AH2JUU6X.js +336 -0
  139. package/dist/chunk-AH2JUU6X.js.map +1 -0
  140. package/dist/chunk-APO3DCMU.js +361 -0
  141. package/dist/chunk-APO3DCMU.js.map +1 -0
  142. package/dist/chunk-BFBF3XEF.js +283 -0
  143. package/dist/chunk-BFBF3XEF.js.map +1 -0
  144. package/dist/chunk-BJ3KMYTB.js +1974 -0
  145. package/dist/chunk-BJ3KMYTB.js.map +1 -0
  146. package/dist/chunk-C5BCH4ZS.js +317 -0
  147. package/dist/chunk-C5BCH4ZS.js.map +1 -0
  148. package/dist/chunk-CHEL3SKB.js +6758 -0
  149. package/dist/chunk-CHEL3SKB.js.map +1 -0
  150. package/dist/chunk-CQZRLNMV.js +1491 -0
  151. package/dist/chunk-CQZRLNMV.js.map +1 -0
  152. package/dist/chunk-D46YSIYX.js +892 -0
  153. package/dist/chunk-D46YSIYX.js.map +1 -0
  154. package/dist/chunk-DB5A3NHS.js +906 -0
  155. package/dist/chunk-DB5A3NHS.js.map +1 -0
  156. package/dist/chunk-DINWEURR.js +648 -0
  157. package/dist/chunk-DINWEURR.js.map +1 -0
  158. package/dist/chunk-DK5LDEQM.js +530 -0
  159. package/dist/chunk-DK5LDEQM.js.map +1 -0
  160. package/dist/chunk-DOM4GKSW.js +34 -0
  161. package/dist/chunk-DOM4GKSW.js.map +1 -0
  162. package/dist/chunk-EDTHC6UD.js +1075 -0
  163. package/dist/chunk-EDTHC6UD.js.map +1 -0
  164. package/dist/chunk-EFJ3MQ4V.js +721 -0
  165. package/dist/chunk-EHRTFRWW.js +89 -0
  166. package/dist/chunk-EHRTFRWW.js.map +1 -0
  167. package/dist/chunk-FAJ7FZYM.js +11 -0
  168. package/dist/chunk-FAJ7FZYM.js.map +1 -0
  169. package/dist/chunk-FBYESMQ2.js +570 -0
  170. package/dist/chunk-FBYESMQ2.js.map +1 -0
  171. package/dist/chunk-FDU6HUUL.js +147 -0
  172. package/dist/chunk-FF4KLI5W.js +99 -0
  173. package/dist/chunk-FF4KLI5W.js.map +1 -0
  174. package/dist/chunk-FIT6DMX6.js +310 -0
  175. package/dist/chunk-FIT6DMX6.js.map +1 -0
  176. package/dist/chunk-FJ43PRLT.js +272 -0
  177. package/dist/chunk-FJ43PRLT.js.map +1 -0
  178. package/dist/chunk-FKFMOY3N.js +32 -0
  179. package/dist/chunk-FKFMOY3N.js.map +1 -0
  180. package/dist/chunk-FLTNHQK6.js +262 -0
  181. package/dist/chunk-FLTNHQK6.js.map +1 -0
  182. package/dist/chunk-GA454ALV.js +12436 -0
  183. package/dist/chunk-GA454ALV.js.map +1 -0
  184. package/dist/chunk-GGKRUQOO.js +228 -0
  185. package/dist/chunk-GIF42EW3.js +63 -0
  186. package/dist/chunk-GIF42EW3.js.map +1 -0
  187. package/dist/chunk-GL6I6MEQ.js +647 -0
  188. package/dist/chunk-H3ME6L6D.js +709 -0
  189. package/dist/chunk-H3ME6L6D.js.map +1 -0
  190. package/dist/chunk-HHLLAQGZ.js +1 -0
  191. package/dist/chunk-HXXBL2KD.js +2040 -0
  192. package/dist/chunk-I5V2VDIW.js +219 -0
  193. package/dist/chunk-I5V2VDIW.js.map +1 -0
  194. package/dist/chunk-I6K5FBRQ.js +35 -0
  195. package/dist/chunk-I6K5FBRQ.js.map +1 -0
  196. package/dist/chunk-ICRIXAP2.js +121 -0
  197. package/dist/chunk-ICRIXAP2.js.map +1 -0
  198. package/dist/chunk-J4EB7DNW.js +11 -0
  199. package/dist/chunk-J4EB7DNW.js.map +1 -0
  200. package/dist/chunk-JLFA7DQG.js +62 -0
  201. package/dist/chunk-JLFA7DQG.js.map +1 -0
  202. package/dist/chunk-KJTKLXTH.js +9 -0
  203. package/dist/chunk-KJTKLXTH.js.map +1 -0
  204. package/dist/chunk-KLAO5DGL.js +917 -0
  205. package/dist/chunk-KLAO5DGL.js.map +1 -0
  206. package/dist/chunk-KNKUID7G.js +183 -0
  207. package/dist/chunk-KOSORCJG.js +624 -0
  208. package/dist/chunk-KOSORCJG.js.map +1 -0
  209. package/dist/chunk-KUJVMMZQ.js +1262 -0
  210. package/dist/chunk-KUJVMMZQ.js.map +1 -0
  211. package/dist/chunk-LCR46JY5.js +123 -0
  212. package/dist/chunk-LCR46JY5.js.map +1 -0
  213. package/dist/chunk-LLQ2LLWF.js +148 -0
  214. package/dist/chunk-LLQ2LLWF.js.map +1 -0
  215. package/dist/chunk-LPMVBPA3.js +236 -0
  216. package/dist/chunk-LT3NLYSI.js +50 -0
  217. package/dist/chunk-LT3NLYSI.js.map +1 -0
  218. package/dist/chunk-LUDTDZLK.js +287 -0
  219. package/dist/chunk-LUDTDZLK.js.map +1 -0
  220. package/dist/chunk-M23FSH32.js +3963 -0
  221. package/dist/chunk-M23FSH32.js.map +1 -0
  222. package/dist/chunk-MC26UJIM.js +118 -0
  223. package/dist/chunk-ME6ESPZU.js +119 -0
  224. package/dist/chunk-ME6ESPZU.js.map +1 -0
  225. package/dist/chunk-MGKYQQYF.js +272 -0
  226. package/dist/chunk-MGKYQQYF.js.map +1 -0
  227. package/dist/chunk-MJFNCJXV.js +66 -0
  228. package/dist/chunk-MJFNCJXV.js.map +1 -0
  229. package/dist/chunk-MSWG7JI6.js +237 -0
  230. package/dist/chunk-MSWG7JI6.js.map +1 -0
  231. package/dist/chunk-MT25YHYH.js +141 -0
  232. package/dist/chunk-MT25YHYH.js.map +1 -0
  233. package/dist/chunk-MT4HVDUZ.js +53 -0
  234. package/dist/chunk-MY6TPVXW.js +219 -0
  235. package/dist/chunk-N2D6GXBM.js +267 -0
  236. package/dist/chunk-N2D6GXBM.js.map +1 -0
  237. package/dist/chunk-NJ3MJQZX.js +46 -0
  238. package/dist/chunk-NJ3MJQZX.js.map +1 -0
  239. package/dist/chunk-NMZY542O.js +335 -0
  240. package/dist/chunk-NMZY542O.js.map +1 -0
  241. package/dist/chunk-NNVTUXEB.js +23 -0
  242. package/dist/chunk-NZL6GGQE.js +375 -0
  243. package/dist/chunk-NZL6GGQE.js.map +1 -0
  244. package/dist/chunk-OAZ5MFUB.js +4124 -0
  245. package/dist/chunk-OAZ5MFUB.js.map +1 -0
  246. package/dist/chunk-OIGNEXKZ.js +237 -0
  247. package/dist/chunk-OIGNEXKZ.js.map +1 -0
  248. package/dist/chunk-OZKZ2TRP.js +3729 -0
  249. package/dist/chunk-OZKZ2TRP.js.map +1 -0
  250. package/dist/chunk-P4NEIHUT.js +108 -0
  251. package/dist/chunk-P7FMDTKL.js +103 -0
  252. package/dist/chunk-P7FMDTKL.js.map +1 -0
  253. package/dist/chunk-PD6O7AXF.js +110 -0
  254. package/dist/chunk-PD6O7AXF.js.map +1 -0
  255. package/dist/chunk-PHK3HARR.js +32 -0
  256. package/dist/chunk-PHK3HARR.js.map +1 -0
  257. package/dist/chunk-PIRJPV5T.js +98 -0
  258. package/dist/chunk-PIRJPV5T.js.map +1 -0
  259. package/dist/chunk-PK7H5L6Y.js +159 -0
  260. package/dist/chunk-PK7H5L6Y.js.map +1 -0
  261. package/dist/chunk-PR5FBTFU.js +233 -0
  262. package/dist/chunk-PR5FBTFU.js.map +1 -0
  263. package/dist/chunk-PU63GXWS.js +174 -0
  264. package/dist/chunk-PU63GXWS.js.map +1 -0
  265. package/dist/chunk-PYPOFEMK.js +294 -0
  266. package/dist/chunk-PYPOFEMK.js.map +1 -0
  267. package/dist/chunk-PZIAX57I.js +124 -0
  268. package/dist/chunk-PZIAX57I.js.map +1 -0
  269. package/dist/chunk-Q7P4WJDP.js +26 -0
  270. package/dist/chunk-Q7P4WJDP.js.map +1 -0
  271. package/dist/chunk-QDZ2RLEC.js +908 -0
  272. package/dist/chunk-QDZ2RLEC.js.map +1 -0
  273. package/dist/chunk-QQUAB63I.js +63 -0
  274. package/dist/chunk-QQUAB63I.js.map +1 -0
  275. package/dist/chunk-QRNI5JBH.js +18 -0
  276. package/dist/chunk-RHY3HH7P.js +601 -0
  277. package/dist/chunk-RHY3HH7P.js.map +1 -0
  278. package/dist/chunk-RK6F44Y6.js +84 -0
  279. package/dist/chunk-RK6F44Y6.js.map +1 -0
  280. package/dist/chunk-RRF5UOBJ.js +91 -0
  281. package/dist/chunk-RXDLTSWT.js +124 -0
  282. package/dist/chunk-RXDLTSWT.js.map +1 -0
  283. package/dist/chunk-RYED3SPJ.js +42 -0
  284. package/dist/chunk-RYED3SPJ.js.map +1 -0
  285. package/dist/chunk-S7KDBTWT.js +106 -0
  286. package/dist/chunk-S7KDBTWT.js.map +1 -0
  287. package/dist/chunk-SEDEKFYQ.js +1 -0
  288. package/dist/chunk-SOAU2OE2.js +125 -0
  289. package/dist/chunk-SOAU2OE2.js.map +1 -0
  290. package/dist/chunk-TECVW3JP.js +36 -0
  291. package/dist/chunk-TECVW3JP.js.map +1 -0
  292. package/dist/chunk-TFO23QT4.js +88 -0
  293. package/dist/chunk-TFO23QT4.js.map +1 -0
  294. package/dist/chunk-TK4UEOSK.js +76 -0
  295. package/dist/chunk-TK4UEOSK.js.map +1 -0
  296. package/dist/chunk-TKWGAOLV.js +122 -0
  297. package/dist/chunk-TKWGAOLV.js.map +1 -0
  298. package/dist/chunk-TMM4S4IJ.js +597 -0
  299. package/dist/chunk-TMM4S4IJ.js.map +1 -0
  300. package/dist/chunk-TMQLARTH.js +188 -0
  301. package/dist/chunk-TMQLARTH.js.map +1 -0
  302. package/dist/chunk-TPDBFYEG.js +130 -0
  303. package/dist/chunk-TPDBFYEG.js.map +1 -0
  304. package/dist/chunk-TPMQ3G6Z.js +145 -0
  305. package/dist/chunk-TPMQ3G6Z.js.map +1 -0
  306. package/dist/chunk-TZOLIGIG.js +61 -0
  307. package/dist/chunk-TZOLIGIG.js.map +1 -0
  308. package/dist/chunk-U3PN77QT.js +113 -0
  309. package/dist/chunk-U3WSW6PZ.js +277 -0
  310. package/dist/chunk-U4SCL7B7.js +640 -0
  311. package/dist/chunk-U4SCL7B7.js.map +1 -0
  312. package/dist/chunk-UWK5OXUJ.js +156 -0
  313. package/dist/chunk-UWK5OXUJ.js.map +1 -0
  314. package/dist/chunk-UWVJF25J.js +74 -0
  315. package/dist/chunk-UXHQAFNA.js +1317 -0
  316. package/dist/chunk-UXHQAFNA.js.map +1 -0
  317. package/dist/chunk-V5OCT34X.js +1 -0
  318. package/dist/chunk-V5OCT34X.js.map +1 -0
  319. package/dist/chunk-VLXA6PI2.js +304 -0
  320. package/dist/chunk-VLXA6PI2.js.map +1 -0
  321. package/dist/chunk-VNO6ZJ35.js +500 -0
  322. package/dist/chunk-VNO6ZJ35.js.map +1 -0
  323. package/dist/chunk-VW676BEI.js +827 -0
  324. package/dist/chunk-VW676BEI.js.map +1 -0
  325. package/dist/chunk-VWT3F4IV.js +2161 -0
  326. package/dist/chunk-VWT3F4IV.js.map +1 -0
  327. package/dist/chunk-W3LR522O.js +2296 -0
  328. package/dist/chunk-W3LR522O.js.map +1 -0
  329. package/dist/chunk-W4L6CZKA.js +96 -0
  330. package/dist/chunk-W4L6CZKA.js.map +1 -0
  331. package/dist/chunk-W4RVMTHR.js +372 -0
  332. package/dist/chunk-W4RVMTHR.js.map +1 -0
  333. package/dist/chunk-WEHSQBFR.js +188 -0
  334. package/dist/chunk-WEHSQBFR.js.map +1 -0
  335. package/dist/chunk-WELDCG6C.js +380 -0
  336. package/dist/chunk-WELDCG6C.js.map +1 -0
  337. package/dist/chunk-WZYKANL3.js +2800 -0
  338. package/dist/chunk-WZYKANL3.js.map +1 -0
  339. package/dist/chunk-XIG5PDM7.js +48 -0
  340. package/dist/chunk-XJNBEDFE.js +193 -0
  341. package/dist/chunk-XJNBEDFE.js.map +1 -0
  342. package/dist/chunk-XVVIG67A.js +291 -0
  343. package/dist/chunk-XVVIG67A.js.map +1 -0
  344. package/dist/chunk-XVZ7B3HG.js +135 -0
  345. package/dist/chunk-YBPYIAA5.js +73 -0
  346. package/dist/chunk-YBPYIAA5.js.map +1 -0
  347. package/dist/chunk-Z734BLO3.js +21 -0
  348. package/dist/chunk-Z734BLO3.js.map +1 -0
  349. package/dist/chunk-ZKSK55RC.js +269 -0
  350. package/dist/chunk-ZKSK55RC.js.map +1 -0
  351. package/dist/chunk-ZTFCYYEZ.js +69 -0
  352. package/dist/chunk-ZTFCYYEZ.js.map +1 -0
  353. package/dist/chunk-ZY2MNJR6.js +329 -0
  354. package/dist/chunk-ZY2MNJR6.js.map +1 -0
  355. package/dist/cli-D3VpkVwB.d.ts +1136 -0
  356. package/dist/cli.d.ts +42 -10
  357. package/dist/cli.js +121 -58
  358. package/dist/codex-cli-fallback.d.ts +1 -0
  359. package/dist/codex-cli-fallback.js +1 -1
  360. package/dist/commitment-ledger.js +1 -1
  361. package/dist/compat/checks.d.ts +5 -0
  362. package/dist/compat/checks.js +11 -0
  363. package/dist/compat/checks.js.map +1 -0
  364. package/dist/compat/types.d.ts +30 -0
  365. package/dist/compat/types.js +1 -0
  366. package/dist/compat/types.js.map +1 -0
  367. package/dist/compounding/engine.d.ts +221 -0
  368. package/dist/compounding/engine.js +32 -0
  369. package/dist/compounding/engine.js.map +1 -0
  370. package/dist/compounding/preference-consolidator.d.ts +92 -0
  371. package/dist/compounding/preference-consolidator.js +553 -0
  372. package/dist/compounding/preference-consolidator.js.map +1 -0
  373. package/dist/compression-optimizer.d.ts +1 -1
  374. package/dist/config.d.ts +5 -3
  375. package/dist/config.js +9 -4
  376. package/dist/conflict-policy-DyJ2wd-h.d.ts +4 -0
  377. package/dist/connectors/codex-materialize-runner.d.ts +64 -0
  378. package/dist/connectors/codex-materialize-runner.js +33 -0
  379. package/dist/connectors/codex-materialize-runner.js.map +1 -0
  380. package/dist/connectors/codex-materialize.d.ts +195 -0
  381. package/dist/connectors/codex-materialize.js +38 -0
  382. package/dist/connectors/codex-materialize.js.map +1 -0
  383. package/dist/connectors/index.d.ts +444 -0
  384. package/dist/connectors/index.js +115 -0
  385. package/dist/connectors/index.js.map +1 -0
  386. package/dist/connectors-cli-CwbyjGR7.d.ts +257 -0
  387. package/dist/connectors-cli.d.ts +1 -1
  388. package/dist/consolidation-provenance-check.d.ts +4 -2
  389. package/dist/consolidation-undo.d.ts +4 -2
  390. package/dist/contradiction/index.d.ts +258 -0
  391. package/dist/contradiction/index.js +43 -0
  392. package/dist/contradiction/index.js.map +1 -0
  393. package/dist/contradiction-review-ATP4S6IC.js +30 -0
  394. package/dist/contradiction-review-ATP4S6IC.js.map +1 -0
  395. package/dist/contradiction-scan-5A4IDZV5.js +13 -0
  396. package/dist/contradiction-scan-5A4IDZV5.js.map +1 -0
  397. package/dist/conversation-index/backend.d.ts +97 -0
  398. package/dist/conversation-index/backend.js +13 -0
  399. package/dist/conversation-index/backend.js.map +1 -0
  400. package/dist/conversation-index/chunker.d.ts +16 -0
  401. package/dist/conversation-index/chunker.js +8 -0
  402. package/dist/conversation-index/chunker.js.map +1 -0
  403. package/dist/conversation-index/cleanup.d.ts +11 -0
  404. package/dist/conversation-index/cleanup.js +9 -0
  405. package/dist/conversation-index/cleanup.js.map +1 -0
  406. package/dist/conversation-index/faiss-adapter.d.ts +6 -0
  407. package/dist/conversation-index/faiss-adapter.js +16 -0
  408. package/dist/conversation-index/faiss-adapter.js.map +1 -0
  409. package/dist/conversation-index/indexer.d.ts +23 -0
  410. package/dist/conversation-index/indexer.js +15 -0
  411. package/dist/conversation-index/indexer.js.map +1 -0
  412. package/dist/conversation-index/search.d.ts +6 -0
  413. package/dist/conversation-index/search.js +11 -0
  414. package/dist/conversation-index/search.js.map +1 -0
  415. package/dist/day-summary.d.ts +1 -1
  416. package/dist/delinearize.d.ts +1 -1
  417. package/dist/direct-answer-wiring.d.ts +1 -1
  418. package/dist/direct-answer-wiring.js +1 -1
  419. package/dist/direct-answer.d.ts +1 -1
  420. package/dist/embedding-fallback.d.ts +1 -1
  421. package/dist/embedding-fallback.js +2 -2
  422. package/dist/enrichment/index.d.ts +163 -0
  423. package/dist/enrichment/index.js +18 -0
  424. package/dist/enrichment/index.js.map +1 -0
  425. package/dist/entity-retrieval.d.ts +4 -2
  426. package/dist/entity-retrieval.js +9 -6
  427. package/dist/entity-schema.d.ts +1 -1
  428. package/dist/evals.js +1 -1
  429. package/dist/event-order-recall.d.ts +17 -0
  430. package/dist/event-order-recall.js +11 -0
  431. package/dist/event-order-recall.js.map +1 -0
  432. package/dist/evidence-pack.d.ts +3 -1
  433. package/dist/evidence-pack.js +5 -3
  434. package/dist/explicit-capture.d.ts +23 -6
  435. package/dist/explicit-capture.js +2 -2
  436. package/dist/explicit-cue-recall.d.ts +4 -1
  437. package/dist/explicit-cue-recall.js +4 -2
  438. package/dist/extraction-judge-telemetry.d.ts +1 -1
  439. package/dist/extraction-judge-training.d.ts +1 -1
  440. package/dist/extraction-judge-training.js +1 -1
  441. package/dist/extraction-judge.d.ts +1 -1
  442. package/dist/extraction.d.ts +1 -1
  443. package/dist/extraction.js +11 -10
  444. package/dist/faiss-adapter-CzPghc4C.d.ts +70 -0
  445. package/dist/fallback-llm.d.ts +4 -1
  446. package/dist/fallback-llm.js +6 -6
  447. package/dist/focused-list-recall.d.ts +17 -0
  448. package/dist/focused-list-recall.js +11 -0
  449. package/dist/focused-list-recall.js.map +1 -0
  450. package/dist/graph-edge-decay-5DI5GUNL.js +207 -0
  451. package/dist/identity-continuity.d.ts +1 -1
  452. package/dist/importance.d.ts +1 -1
  453. package/dist/index-DJ9QWMw-.d.ts +35 -0
  454. package/dist/index.d.ts +107 -715
  455. package/dist/index.js +657 -2611
  456. package/dist/index.js.map +1 -1
  457. package/dist/intent.d.ts +1 -1
  458. package/dist/intent.js +1 -1
  459. package/dist/lcm/archive.d.ts +89 -0
  460. package/dist/lcm/archive.js +12 -0
  461. package/dist/lcm/archive.js.map +1 -0
  462. package/dist/lcm/dag.d.ts +48 -0
  463. package/dist/lcm/dag.js +8 -0
  464. package/dist/lcm/dag.js.map +1 -0
  465. package/dist/lcm/engine.d.ts +116 -0
  466. package/dist/lcm/engine.js +20 -0
  467. package/dist/lcm/engine.js.map +1 -0
  468. package/dist/lcm/index.d.ts +12 -0
  469. package/dist/lcm/index.js +44 -0
  470. package/dist/lcm/index.js.map +1 -0
  471. package/dist/lcm/queue.d.ts +62 -0
  472. package/dist/lcm/queue.js +8 -0
  473. package/dist/lcm/queue.js.map +1 -0
  474. package/dist/lcm/recall.d.ts +20 -0
  475. package/dist/lcm/recall.js +8 -0
  476. package/dist/lcm/recall.js.map +1 -0
  477. package/dist/lcm/schema.d.ts +16 -0
  478. package/dist/lcm/schema.js +14 -0
  479. package/dist/lcm/schema.js.map +1 -0
  480. package/dist/lcm/summarizer.d.ts +38 -0
  481. package/dist/lcm/summarizer.js +12 -0
  482. package/dist/lcm/summarizer.js.map +1 -0
  483. package/dist/lcm/tools.d.ts +29 -0
  484. package/dist/lcm/tools.js +8 -0
  485. package/dist/lcm/tools.js.map +1 -0
  486. package/dist/lifecycle.d.ts +1 -1
  487. package/dist/live-connectors-runner.d.ts +1 -1
  488. package/dist/live-connectors-runner.js +5 -5
  489. package/dist/local-llm.d.ts +8 -4
  490. package/dist/local-llm.js +3 -3
  491. package/dist/maintenance/archive-observations.d.ts +18 -0
  492. package/dist/maintenance/archive-observations.js +8 -0
  493. package/dist/maintenance/archive-observations.js.map +1 -0
  494. package/dist/maintenance/backup-stamp.d.ts +3 -0
  495. package/dist/maintenance/backup-stamp.js +8 -0
  496. package/dist/maintenance/backup-stamp.js.map +1 -0
  497. package/dist/maintenance/memory-governance-cron.d.ts +85 -0
  498. package/dist/maintenance/memory-governance-cron.js +22 -0
  499. package/dist/maintenance/memory-governance-cron.js.map +1 -0
  500. package/dist/maintenance/memory-governance.d.ts +137 -0
  501. package/dist/maintenance/memory-governance.js +40 -0
  502. package/dist/maintenance/memory-governance.js.map +1 -0
  503. package/dist/maintenance/migrate-observations.d.ts +18 -0
  504. package/dist/maintenance/migrate-observations.js +9 -0
  505. package/dist/maintenance/migrate-observations.js.map +1 -0
  506. package/dist/maintenance/observation-ledger-utils.d.ts +10 -0
  507. package/dist/maintenance/observation-ledger-utils.js +10 -0
  508. package/dist/maintenance/observation-ledger-utils.js.map +1 -0
  509. package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +15 -0
  510. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +28 -0
  511. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js.map +1 -0
  512. package/dist/maintenance/rebuild-memory-projection.d.ts +77 -0
  513. package/dist/maintenance/rebuild-memory-projection.js +35 -0
  514. package/dist/maintenance/rebuild-memory-projection.js.map +1 -0
  515. package/dist/maintenance/rebuild-observations.d.ts +17 -0
  516. package/dist/maintenance/rebuild-observations.js +9 -0
  517. package/dist/maintenance/rebuild-observations.js.map +1 -0
  518. package/dist/mcp-memory-inspector-app.d.ts +124 -0
  519. package/dist/mcp-memory-inspector-app.js +20 -0
  520. package/dist/mcp-memory-inspector-app.js.map +1 -0
  521. package/dist/memory-action-policy.d.ts +1 -1
  522. package/dist/memory-cache.d.ts +1 -1
  523. package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
  524. package/dist/memory-projection-store.d.ts +108 -3
  525. package/dist/memory-projection-store.js +2 -1
  526. package/dist/memory-provenance.d.ts +57 -0
  527. package/dist/memory-provenance.js +13 -0
  528. package/dist/memory-provenance.js.map +1 -0
  529. package/dist/memory-worth-outcomes.d.ts +4 -2
  530. package/dist/migrate/from-engram.d.ts +24 -0
  531. package/dist/migrate/from-engram.js +12 -0
  532. package/dist/migrate/from-engram.js.map +1 -0
  533. package/dist/models-json.d.ts +1 -1
  534. package/dist/namespaces/migrate.d.ts +50 -0
  535. package/dist/namespaces/migrate.js +50 -0
  536. package/dist/namespaces/migrate.js.map +1 -0
  537. package/dist/namespaces/principal.d.ts +17 -0
  538. package/dist/namespaces/principal.js +16 -0
  539. package/dist/namespaces/principal.js.map +1 -0
  540. package/dist/namespaces/search.d.ts +46 -0
  541. package/dist/namespaces/search.js +28 -0
  542. package/dist/namespaces/search.js.map +1 -0
  543. package/dist/namespaces/storage.d.ts +32 -0
  544. package/dist/namespaces/storage.js +28 -0
  545. package/dist/namespaces/storage.js.map +1 -0
  546. package/dist/native-knowledge.d.ts +1 -1
  547. package/dist/network/tailscale.d.ts +41 -0
  548. package/dist/network/tailscale.js +9 -0
  549. package/dist/network/tailscale.js.map +1 -0
  550. package/dist/network/webdav.d.ts +39 -0
  551. package/dist/network/webdav.js +10 -0
  552. package/dist/network/webdav.js.map +1 -0
  553. package/dist/objective-state-writers.d.ts +1 -1
  554. package/dist/objective-state-writers.js +2 -2
  555. package/dist/operator-toolkit.d.ts +4 -2
  556. package/dist/operator-toolkit.js +35 -17
  557. package/dist/opik-exporter.js +2 -2
  558. package/dist/opik-exporter.js.map +1 -1
  559. package/dist/orchestrator-DuWl9Hwx.d.ts +1244 -0
  560. package/dist/orchestrator.d.ts +24 -7
  561. package/dist/orchestrator.js +107 -65
  562. package/dist/path-MR5JPYOP.js +9 -0
  563. package/dist/path-MR5JPYOP.js.map +1 -0
  564. package/dist/patterns-cli.d.ts +1 -1
  565. package/dist/policy-runtime.d.ts +1 -1
  566. package/dist/qmd-recall-cache.d.ts +2 -2
  567. package/dist/qmd.d.ts +103 -4
  568. package/dist/qmd.js +23 -5
  569. package/dist/recall-disclosure-escalation.d.ts +1 -1
  570. package/dist/recall-explain-renderer.d.ts +3 -1
  571. package/dist/recall-explain-renderer.js +5 -3
  572. package/dist/recall-state.d.ts +1 -1
  573. package/dist/recall-tag-filter.d.ts +3 -1
  574. package/dist/recall-xray-cli.d.ts +3 -1
  575. package/dist/recall-xray-cli.js +6 -4
  576. package/dist/recall-xray-renderer.d.ts +3 -1
  577. package/dist/recall-xray-renderer.js +5 -3
  578. package/dist/recall-xray.d.ts +8 -1
  579. package/dist/recall-xray.js +4 -2
  580. package/dist/replay/normalizers/chatgpt.d.ts +6 -0
  581. package/dist/replay/normalizers/chatgpt.js +11 -0
  582. package/dist/replay/normalizers/chatgpt.js.map +1 -0
  583. package/dist/replay/normalizers/claude.d.ts +6 -0
  584. package/dist/replay/normalizers/claude.js +11 -0
  585. package/dist/replay/normalizers/claude.js.map +1 -0
  586. package/dist/replay/normalizers/openclaw.d.ts +6 -0
  587. package/dist/replay/normalizers/openclaw.js +11 -0
  588. package/dist/replay/normalizers/openclaw.js.map +1 -0
  589. package/dist/replay/normalizers/shared.d.ts +16 -0
  590. package/dist/replay/normalizers/shared.js +14 -0
  591. package/dist/replay/normalizers/shared.js.map +1 -0
  592. package/dist/replay/runner.d.ts +35 -0
  593. package/dist/replay/runner.js +16 -0
  594. package/dist/replay/runner.js.map +1 -0
  595. package/dist/replay/types.d.ts +57 -0
  596. package/dist/replay/types.js +19 -0
  597. package/dist/replay/types.js.map +1 -0
  598. package/dist/resolution-B7FNQSSP.js +12 -0
  599. package/dist/resolution-B7FNQSSP.js.map +1 -0
  600. package/dist/resolve-auth-token.d.ts +1 -1
  601. package/dist/resolve-provider-secret.js +2 -2
  602. package/dist/response-guidance-recall.d.ts +18 -0
  603. package/dist/response-guidance-recall.js +11 -0
  604. package/dist/response-guidance-recall.js.map +1 -0
  605. package/dist/resume-bundles.js +7 -5
  606. package/dist/retrieval-agents.d.ts +2 -2
  607. package/dist/retrieval-tiers.d.ts +1 -1
  608. package/dist/routing/engine.d.ts +35 -0
  609. package/dist/routing/engine.js +16 -0
  610. package/dist/routing/engine.js.map +1 -0
  611. package/dist/routing/store.d.ts +27 -0
  612. package/dist/routing/store.js +10 -0
  613. package/dist/routing/store.js.map +1 -0
  614. package/dist/runtime/better-sqlite.d.ts +8 -0
  615. package/dist/runtime/better-sqlite.js +10 -0
  616. package/dist/runtime/better-sqlite.js.map +1 -0
  617. package/dist/runtime/child-process.d.ts +32 -0
  618. package/dist/runtime/child-process.js +10 -0
  619. package/dist/runtime/child-process.js.map +1 -0
  620. package/dist/runtime/env.d.ts +5 -0
  621. package/dist/runtime/env.js +12 -0
  622. package/dist/runtime/env.js.map +1 -0
  623. package/dist/sdk-compat.js +1 -1
  624. package/dist/search/document-scanner.d.ts +22 -0
  625. package/dist/search/document-scanner.js +8 -0
  626. package/dist/search/document-scanner.js.map +1 -0
  627. package/dist/search/embed-helper.d.ts +35 -0
  628. package/dist/search/embed-helper.js +9 -0
  629. package/dist/search/embed-helper.js.map +1 -0
  630. package/dist/search/factory.d.ts +32 -0
  631. package/dist/search/factory.js +29 -0
  632. package/dist/search/factory.js.map +1 -0
  633. package/dist/search/index.d.ts +15 -0
  634. package/dist/search/index.js +50 -0
  635. package/dist/search/index.js.map +1 -0
  636. package/dist/search/lancedb-backend.d.ts +51 -0
  637. package/dist/search/lancedb-backend.js +10 -0
  638. package/dist/search/lancedb-backend.js.map +1 -0
  639. package/dist/search/meilisearch-backend.d.ts +48 -0
  640. package/dist/search/meilisearch-backend.js +10 -0
  641. package/dist/search/meilisearch-backend.js.map +1 -0
  642. package/dist/search/noop-backend.d.ts +26 -0
  643. package/dist/search/noop-backend.js +8 -0
  644. package/dist/search/noop-backend.js.map +1 -0
  645. package/dist/search/orama-backend.d.ts +53 -0
  646. package/dist/search/orama-backend.js +10 -0
  647. package/dist/search/orama-backend.js.map +1 -0
  648. package/dist/search/port.d.ts +61 -0
  649. package/dist/search/port.js +1 -0
  650. package/dist/search/port.js.map +1 -0
  651. package/dist/search/remote-backend.d.ts +39 -0
  652. package/dist/search/remote-backend.js +9 -0
  653. package/dist/search/remote-backend.js.map +1 -0
  654. package/dist/secure-store/index.d.ts +890 -0
  655. package/dist/secure-store/index.js +156 -0
  656. package/dist/secure-store/index.js.map +1 -0
  657. package/dist/semantic-VwGI14Ok.d.ts +69 -0
  658. package/dist/semantic-consolidation-4HkHWgeI.d.ts +180 -0
  659. package/dist/semantic-consolidation.d.ts +3 -3
  660. package/dist/semantic-consolidation.js +15 -8
  661. package/dist/semantic-rule-promotion.js +9 -6
  662. package/dist/semantic-rule-verifier.d.ts +1 -1
  663. package/dist/semantic-rule-verifier.js +10 -7
  664. package/dist/session-observer-bands.d.ts +1 -1
  665. package/dist/session-observer-state.d.ts +1 -1
  666. package/dist/shared-context/manager.d.ts +131 -0
  667. package/dist/shared-context/manager.js +15 -0
  668. package/dist/shared-context/manager.js.map +1 -0
  669. package/dist/signal.d.ts +1 -1
  670. package/dist/skills-registry.js +13 -1
  671. package/dist/skills-registry.js.map +1 -1
  672. package/dist/state-store-VZU2IA53.js +16 -0
  673. package/dist/state-store-VZU2IA53.js.map +1 -0
  674. package/dist/storage-paths.d.ts +9 -0
  675. package/dist/storage-paths.js +20 -0
  676. package/dist/storage-paths.js.map +1 -0
  677. package/dist/storage.d.ts +6 -2
  678. package/dist/storage.js +8 -5
  679. package/dist/summarizer.d.ts +6 -1
  680. package/dist/summarizer.js +11 -10
  681. package/dist/summary-snapshot.d.ts +1 -1
  682. package/dist/summary-snapshot.js +2 -1
  683. package/dist/surfaces/dreams.d.ts +16 -0
  684. package/dist/surfaces/dreams.js +282 -0
  685. package/dist/surfaces/dreams.js.map +1 -0
  686. package/dist/surfaces/heartbeat.d.ts +17 -0
  687. package/dist/surfaces/heartbeat.js +265 -0
  688. package/dist/surfaces/heartbeat.js.map +1 -0
  689. package/dist/targeted-fact-recall.d.ts +17 -0
  690. package/dist/targeted-fact-recall.js +11 -0
  691. package/dist/targeted-fact-recall.js.map +1 -0
  692. package/dist/telemetry-transcript.d.ts +7 -0
  693. package/dist/telemetry-transcript.js +16 -0
  694. package/dist/telemetry-transcript.js.map +1 -0
  695. package/dist/temporal-supersession.d.ts +4 -2
  696. package/dist/temporal-supersession.js +2 -1
  697. package/dist/temporal-validity.d.ts +1 -1
  698. package/dist/threading.d.ts +6 -1
  699. package/dist/threading.js +2 -1
  700. package/dist/tier-migration.d.ts +5 -3
  701. package/dist/tier-routing.d.ts +1 -1
  702. package/dist/tokens.js +2 -2
  703. package/dist/topics.d.ts +1 -1
  704. package/dist/transcript.d.ts +16 -2
  705. package/dist/transcript.js +2 -1
  706. package/dist/transfer/autodetect.d.ts +4 -0
  707. package/dist/transfer/autodetect.js +15 -0
  708. package/dist/transfer/autodetect.js.map +1 -0
  709. package/dist/transfer/backup.d.ts +21 -0
  710. package/dist/transfer/backup.js +17 -0
  711. package/dist/transfer/backup.js.map +1 -0
  712. package/dist/transfer/capsule-export.d.ts +113 -0
  713. package/dist/transfer/capsule-export.js +19 -0
  714. package/dist/transfer/capsule-export.js.map +1 -0
  715. package/dist/transfer/capsule-import.d.ts +124 -0
  716. package/dist/transfer/capsule-import.js +16 -0
  717. package/dist/transfer/capsule-import.js.map +1 -0
  718. package/dist/transfer/constants.d.ts +13 -0
  719. package/dist/transfer/constants.js +12 -0
  720. package/dist/transfer/constants.js.map +1 -0
  721. package/dist/transfer/export-json.d.ts +11 -0
  722. package/dist/transfer/export-json.js +11 -0
  723. package/dist/transfer/export-json.js.map +1 -0
  724. package/dist/transfer/export-md.d.ts +10 -0
  725. package/dist/transfer/export-md.js +13 -0
  726. package/dist/transfer/export-md.js.map +1 -0
  727. package/dist/transfer/export-sqlite.d.ts +9 -0
  728. package/dist/transfer/export-sqlite.js +12 -0
  729. package/dist/transfer/export-sqlite.js.map +1 -0
  730. package/dist/transfer/fs-utils.d.ts +61 -0
  731. package/dist/transfer/fs-utils.js +40 -0
  732. package/dist/transfer/fs-utils.js.map +1 -0
  733. package/dist/transfer/import-json.d.ts +16 -0
  734. package/dist/transfer/import-json.js +13 -0
  735. package/dist/transfer/import-json.js.map +1 -0
  736. package/dist/transfer/import-md.d.ts +14 -0
  737. package/dist/transfer/import-md.js +11 -0
  738. package/dist/transfer/import-md.js.map +1 -0
  739. package/dist/transfer/import-sqlite.d.ts +14 -0
  740. package/dist/transfer/import-sqlite.js +12 -0
  741. package/dist/transfer/import-sqlite.js.map +1 -0
  742. package/dist/transfer/sqlite-schema.d.ts +4 -0
  743. package/dist/transfer/sqlite-schema.js +10 -0
  744. package/dist/transfer/sqlite-schema.js.map +1 -0
  745. package/dist/transfer/types.d.ts +916 -0
  746. package/dist/transfer/types.js +30 -0
  747. package/dist/transfer/types.js.map +1 -0
  748. package/dist/trust-zones.d.ts +3 -2
  749. package/dist/trust-zones.js +1 -1
  750. package/dist/types.d.ts +88 -3
  751. package/dist/types.js +1 -1
  752. package/dist/user-model.d.ts +37 -0
  753. package/dist/user-model.js +28 -0
  754. package/dist/user-model.js.map +1 -0
  755. package/dist/utility-runtime.d.ts +1 -1
  756. package/dist/verified-recall.js +11 -8
  757. package/dist/work/board.d.ts +43 -0
  758. package/dist/work/board.js +14 -0
  759. package/dist/work/board.js.map +1 -0
  760. package/dist/work/boundary.d.ts +8 -0
  761. package/dist/work/boundary.js +14 -0
  762. package/dist/work/boundary.js.map +1 -0
  763. package/dist/work/storage.d.ts +39 -0
  764. package/dist/work/storage.js +11 -0
  765. package/dist/work/storage.js.map +1 -0
  766. package/dist/work/types.d.ts +75 -0
  767. package/dist/work/types.js +1 -0
  768. package/dist/work/types.js.map +1 -0
  769. package/package.json +2767 -6
  770. package/scripts/faiss_index.py +816 -0
  771. package/scripts/faiss_requirements.txt +3 -0
  772. package/skills/remnic-entities/SKILL.md +51 -0
  773. package/skills/remnic-memory-workflow/SKILL.md +61 -0
  774. package/skills/remnic-recall/SKILL.md +51 -0
  775. package/skills/remnic-remember/SKILL.md +56 -0
  776. package/skills/remnic-search/SKILL.md +51 -0
  777. package/skills/remnic-status/SKILL.md +51 -0
  778. package/src/abort-error.test.ts +49 -0
  779. package/src/abort-error.ts +46 -0
  780. package/src/abstraction-nodes.ts +162 -0
  781. package/src/access-audit.test.ts +178 -0
  782. package/src/access-audit.ts +125 -0
  783. package/src/access-cli.test.ts +439 -0
  784. package/src/access-cli.ts +438 -0
  785. package/src/access-http.test.ts +225 -0
  786. package/src/access-http.ts +1899 -0
  787. package/src/access-idempotency.ts +232 -0
  788. package/src/access-mcp.test.ts +568 -0
  789. package/src/access-mcp.ts +3056 -0
  790. package/src/access-schema-pi.test.ts +60 -0
  791. package/src/access-schema.ts +522 -0
  792. package/src/access-service-namespace.test.ts +123 -0
  793. package/src/access-service.ts +5629 -0
  794. package/src/action-confidence.test.ts +206 -0
  795. package/src/action-confidence.ts +466 -0
  796. package/src/active-memory-bridge.test.ts +285 -0
  797. package/src/active-memory-bridge.ts +217 -0
  798. package/src/active-recall.test.ts +484 -0
  799. package/src/active-recall.ts +459 -0
  800. package/src/adapters/claude-code.ts +56 -0
  801. package/src/adapters/codex.ts +57 -0
  802. package/src/adapters/hermes.ts +64 -0
  803. package/src/adapters/index.ts +6 -0
  804. package/src/adapters/registry.ts +41 -0
  805. package/src/adapters/replit.ts +55 -0
  806. package/src/adapters/types.ts +51 -0
  807. package/src/behavior-learner.ts +144 -0
  808. package/src/behavior-signals.ts +73 -0
  809. package/src/binary-lifecycle/backend.ts +117 -0
  810. package/src/binary-lifecycle/index.ts +35 -0
  811. package/src/binary-lifecycle/manifest.ts +79 -0
  812. package/src/binary-lifecycle/pipeline.ts +352 -0
  813. package/src/binary-lifecycle/scanner.ts +89 -0
  814. package/src/binary-lifecycle/types.ts +89 -0
  815. package/src/bootstrap.ts +178 -0
  816. package/src/boxes.ts +521 -0
  817. package/src/briefing.test.ts +1535 -0
  818. package/src/briefing.ts +1382 -0
  819. package/src/buffer-session.test.ts +443 -0
  820. package/src/buffer-surprise-report.ts +176 -0
  821. package/src/buffer-surprise-telemetry.test.ts +606 -0
  822. package/src/buffer-surprise-trigger.test.ts +766 -0
  823. package/src/buffer-surprise.test.ts +339 -0
  824. package/src/buffer-surprise.ts +203 -0
  825. package/src/buffer.ts +900 -0
  826. package/src/bulk-import/cli-command.test.ts +204 -0
  827. package/src/bulk-import/index.ts +34 -0
  828. package/src/bulk-import/pipeline.test.ts +445 -0
  829. package/src/bulk-import/pipeline.ts +178 -0
  830. package/src/bulk-import/registry.test.ts +151 -0
  831. package/src/bulk-import/registry.ts +72 -0
  832. package/src/bulk-import/types.test.ts +272 -0
  833. package/src/bulk-import/types.ts +145 -0
  834. package/src/calibration.ts +394 -0
  835. package/src/capsule-cli.test.ts +398 -0
  836. package/src/capsule-cli.ts +565 -0
  837. package/src/causal-behavior.ts +308 -0
  838. package/src/causal-chain.ts +419 -0
  839. package/src/causal-consolidation.ts +370 -0
  840. package/src/causal-retrieval.ts +286 -0
  841. package/src/causal-trajectory-graph.ts +60 -0
  842. package/src/causal-trajectory.ts +303 -0
  843. package/src/chunking.ts +220 -0
  844. package/src/citations.ts +232 -0
  845. package/src/cli.ts +9403 -0
  846. package/src/codex-cli-fallback.ts +162 -0
  847. package/src/codex-thread-key.ts +1 -0
  848. package/src/coding/access-coding-context.test.ts +197 -0
  849. package/src/coding/coding-branch-scope.test.ts +281 -0
  850. package/src/coding/coding-namespace.test.ts +360 -0
  851. package/src/coding/coding-namespace.ts +412 -0
  852. package/src/coding/coding-orchestrator.test.ts +249 -0
  853. package/src/coding/git-context.test.ts +507 -0
  854. package/src/coding/git-context.ts +336 -0
  855. package/src/coding/mcp-set-coding-context.test.ts +174 -0
  856. package/src/coding/review-context.test.ts +316 -0
  857. package/src/coding/review-context.ts +349 -0
  858. package/src/coding/wire-coding-context.test.ts +468 -0
  859. package/src/commitment-ledger.test.ts +78 -0
  860. package/src/commitment-ledger.ts +337 -0
  861. package/src/compat/checks.test.ts +206 -0
  862. package/src/compat/checks.ts +716 -0
  863. package/src/compat/types.ts +33 -0
  864. package/src/compounding/engine.ts +1686 -0
  865. package/src/compounding/preference-consolidator.ts +778 -0
  866. package/src/compression-optimizer.ts +312 -0
  867. package/src/config.test.ts +930 -0
  868. package/src/config.ts +3807 -0
  869. package/src/connectors/codex/instructions.md +160 -0
  870. package/src/connectors/codex/resources/namespace-cheatsheet.md +48 -0
  871. package/src/connectors/codex-marketplace.ts +500 -0
  872. package/src/connectors/codex-materialize-runner.ts +212 -0
  873. package/src/connectors/codex-materialize.ts +983 -0
  874. package/src/connectors/coerce.ts +62 -0
  875. package/src/connectors/index.test.ts +1570 -0
  876. package/src/connectors/index.ts +3222 -0
  877. package/src/connectors/live/framework.ts +164 -0
  878. package/src/connectors/live/github.test.ts +1218 -0
  879. package/src/connectors/live/github.ts +1068 -0
  880. package/src/connectors/live/gmail.test.ts +1706 -0
  881. package/src/connectors/live/gmail.ts +1293 -0
  882. package/src/connectors/live/google-drive.test.ts +696 -0
  883. package/src/connectors/live/google-drive.ts +724 -0
  884. package/src/connectors/live/index.ts +101 -0
  885. package/src/connectors/live/live-connectors.test.ts +689 -0
  886. package/src/connectors/live/notion.test.ts +1109 -0
  887. package/src/connectors/live/notion.ts +978 -0
  888. package/src/connectors/live/registry.ts +103 -0
  889. package/src/connectors/live/state-store.ts +399 -0
  890. package/src/connectors/live/transient-errors.ts +150 -0
  891. package/src/connectors/weclone-installer.test.ts +850 -0
  892. package/src/connectors-cli.ts +513 -0
  893. package/src/console/state.test.ts +224 -0
  894. package/src/console/state.ts +514 -0
  895. package/src/console/trace.test.ts +813 -0
  896. package/src/console/trace.ts +603 -0
  897. package/src/console/tui.test.ts +582 -0
  898. package/src/console/tui.ts +508 -0
  899. package/src/consolidation-operator.ts +182 -0
  900. package/src/consolidation-provenance-check.ts +551 -0
  901. package/src/consolidation-undo.ts +718 -0
  902. package/src/contradiction/contradiction-judge.test.ts +189 -0
  903. package/src/contradiction/contradiction-judge.ts +333 -0
  904. package/src/contradiction/contradiction-review.ts +574 -0
  905. package/src/contradiction/contradiction-scan.ts +504 -0
  906. package/src/contradiction/contradiction.test.ts +2230 -0
  907. package/src/contradiction/index.ts +37 -0
  908. package/src/contradiction/resolution.ts +383 -0
  909. package/src/conversation-index/backend.ts +323 -0
  910. package/src/conversation-index/chunker.ts +47 -0
  911. package/src/conversation-index/cleanup.ts +53 -0
  912. package/src/conversation-index/faiss-adapter.ts +384 -0
  913. package/src/conversation-index/indexer.test.ts +164 -0
  914. package/src/conversation-index/indexer.ts +192 -0
  915. package/src/conversation-index/search.ts +37 -0
  916. package/src/cross-namespace-budget.test.ts +275 -0
  917. package/src/cross-namespace-budget.ts +365 -0
  918. package/src/cue-anchors.ts +163 -0
  919. package/src/curation/index.ts +544 -0
  920. package/src/dashboard-runtime.ts +337 -0
  921. package/src/day-summary.ts +122 -0
  922. package/src/dedup/index.ts +330 -0
  923. package/src/dedup/semantic.test.ts +1577 -0
  924. package/src/dedup/semantic.ts +148 -0
  925. package/src/delinearize.ts +193 -0
  926. package/src/direct-answer-wiring.test.ts +473 -0
  927. package/src/direct-answer-wiring.ts +180 -0
  928. package/src/direct-answer.test.ts +484 -0
  929. package/src/direct-answer.ts +273 -0
  930. package/src/embedding-fallback.ts +565 -0
  931. package/src/enrichment/audit.ts +89 -0
  932. package/src/enrichment/index.ts +27 -0
  933. package/src/enrichment/pipeline.ts +197 -0
  934. package/src/enrichment/provider-registry.ts +85 -0
  935. package/src/enrichment/types.ts +100 -0
  936. package/src/enrichment/web-search-provider.ts +63 -0
  937. package/src/entity-retrieval.ts +774 -0
  938. package/src/entity-schema.ts +239 -0
  939. package/src/evals.ts +1312 -0
  940. package/src/event-order-recall.test.ts +4164 -0
  941. package/src/event-order-recall.ts +2802 -0
  942. package/src/evidence-pack.test.ts +89 -0
  943. package/src/evidence-pack.ts +388 -0
  944. package/src/explicit-capture.ts +530 -0
  945. package/src/explicit-cue-recall.test.ts +3019 -0
  946. package/src/explicit-cue-recall.ts +5545 -0
  947. package/src/extraction-judge-telemetry.ts +234 -0
  948. package/src/extraction-judge-training.ts +221 -0
  949. package/src/extraction-judge.ts +846 -0
  950. package/src/extraction-timeout.test.ts +265 -0
  951. package/src/extraction.ts +2719 -0
  952. package/src/fallback-llm.test.ts +1060 -0
  953. package/src/fallback-llm.ts +918 -0
  954. package/src/focused-list-recall.test.ts +734 -0
  955. package/src/focused-list-recall.ts +1160 -0
  956. package/src/graph-dashboard-diff.ts +35 -0
  957. package/src/graph-dashboard-key.ts +5 -0
  958. package/src/graph-dashboard-parser.ts +104 -0
  959. package/src/graph-edge-reinforcement.ts +192 -0
  960. package/src/graph-events.ts +151 -0
  961. package/src/graph-recall.test.ts +164 -0
  962. package/src/graph-recall.ts +189 -0
  963. package/src/graph-retrieval.test.ts +809 -0
  964. package/src/graph-retrieval.ts +823 -0
  965. package/src/graph-snapshot.ts +329 -0
  966. package/src/graph.ts +813 -0
  967. package/src/harmonic-retrieval.ts +223 -0
  968. package/src/himem.ts +154 -0
  969. package/src/hygiene.ts +87 -0
  970. package/src/identity-continuity.ts +333 -0
  971. package/src/importance.ts +328 -0
  972. package/src/importers/base.test.ts +294 -0
  973. package/src/importers/base.ts +436 -0
  974. package/src/importers/index.ts +21 -0
  975. package/src/index.ts +1204 -0
  976. package/src/intent.ts +154 -0
  977. package/src/json-extract.ts +85 -0
  978. package/src/json-store.ts +42 -0
  979. package/src/lcm/archive.ts +617 -0
  980. package/src/lcm/dag.ts +199 -0
  981. package/src/lcm/engine.ts +645 -0
  982. package/src/lcm/index.ts +7 -0
  983. package/src/lcm/queue.test.ts +178 -0
  984. package/src/lcm/queue.ts +200 -0
  985. package/src/lcm/recall.ts +117 -0
  986. package/src/lcm/schema.ts +154 -0
  987. package/src/lcm/summarizer.ts +235 -0
  988. package/src/lcm/tools.ts +191 -0
  989. package/src/lcm-engine.test.ts +660 -0
  990. package/src/legacy-hook-compat.test.ts +20 -0
  991. package/src/legacy-hook-compat.ts +45 -0
  992. package/src/lifecycle.ts +289 -0
  993. package/src/live-connectors-runner.ts +385 -0
  994. package/src/local-llm-qos.test.ts +303 -0
  995. package/src/local-llm-thinking.test.ts +292 -0
  996. package/src/local-llm.ts +1464 -0
  997. package/src/logger.ts +49 -0
  998. package/src/maintenance/archive-observations.ts +147 -0
  999. package/src/maintenance/backup-stamp.ts +3 -0
  1000. package/src/maintenance/dreams-ledger.ts +516 -0
  1001. package/src/maintenance/first-start-migration.ts +362 -0
  1002. package/src/maintenance/forget.test.ts +206 -0
  1003. package/src/maintenance/forget.ts +126 -0
  1004. package/src/maintenance/graph-edge-decay.test.ts +409 -0
  1005. package/src/maintenance/graph-edge-decay.ts +394 -0
  1006. package/src/maintenance/memory-governance-cron.ts +447 -0
  1007. package/src/maintenance/memory-governance.ts +1039 -0
  1008. package/src/maintenance/migrate-observations.ts +216 -0
  1009. package/src/maintenance/observation-ledger-utils.ts +54 -0
  1010. package/src/maintenance/pattern-reinforcement.test.ts +875 -0
  1011. package/src/maintenance/pattern-reinforcement.ts +369 -0
  1012. package/src/maintenance/purge.ts +334 -0
  1013. package/src/maintenance/rebuild-memory-lifecycle-ledger.ts +78 -0
  1014. package/src/maintenance/rebuild-memory-projection.ts +1234 -0
  1015. package/src/maintenance/rebuild-observations.ts +178 -0
  1016. package/src/maintenance/tier-stats.test.ts +378 -0
  1017. package/src/maintenance/tier-stats.ts +222 -0
  1018. package/src/mcp-memory-inspector-app.ts +421 -0
  1019. package/src/memory-action-policy.ts +80 -0
  1020. package/src/memory-cache.ts +208 -0
  1021. package/src/memory-extension/claude-code-publisher.ts +51 -0
  1022. package/src/memory-extension/codex-publisher.ts +149 -0
  1023. package/src/memory-extension/hermes-publisher.ts +51 -0
  1024. package/src/memory-extension/index.ts +100 -0
  1025. package/src/memory-extension/shared-instructions.ts +133 -0
  1026. package/src/memory-extension/types.ts +86 -0
  1027. package/src/memory-extension-host/host-discovery.ts +276 -0
  1028. package/src/memory-extension-host/index.ts +14 -0
  1029. package/src/memory-extension-host/render-extensions-block.ts +73 -0
  1030. package/src/memory-extension-host/types.ts +21 -0
  1031. package/src/memory-lifecycle-ledger-utils.ts +116 -0
  1032. package/src/memory-projection-format.ts +11 -0
  1033. package/src/memory-projection-store.ts +951 -0
  1034. package/src/memory-provenance.test.ts +196 -0
  1035. package/src/memory-provenance.ts +484 -0
  1036. package/src/memory-worth-bench.test.ts +71 -0
  1037. package/src/memory-worth-bench.ts +265 -0
  1038. package/src/memory-worth-filter.test.ts +209 -0
  1039. package/src/memory-worth-filter.ts +204 -0
  1040. package/src/memory-worth-frontmatter.test.ts +311 -0
  1041. package/src/memory-worth-outcomes.test.ts +316 -0
  1042. package/src/memory-worth-outcomes.ts +286 -0
  1043. package/src/memory-worth.test.ts +317 -0
  1044. package/src/memory-worth.ts +215 -0
  1045. package/src/message-parts/index.ts +806 -0
  1046. package/src/message-parts/message-parts.test.ts +421 -0
  1047. package/src/migrate/from-engram.ts +789 -0
  1048. package/src/model-registry.ts +313 -0
  1049. package/src/models-json.ts +76 -0
  1050. package/src/namespaces/migrate.ts +187 -0
  1051. package/src/namespaces/path.ts +25 -0
  1052. package/src/namespaces/principal.test.ts +195 -0
  1053. package/src/namespaces/principal.ts +86 -0
  1054. package/src/namespaces/search.test.ts +105 -0
  1055. package/src/namespaces/search.ts +233 -0
  1056. package/src/namespaces/storage.ts +74 -0
  1057. package/src/native-knowledge.ts +1823 -0
  1058. package/src/negative.ts +72 -0
  1059. package/src/network/tailscale.ts +179 -0
  1060. package/src/network/webdav.ts +385 -0
  1061. package/src/objective-state-writers.ts +951 -0
  1062. package/src/objective-state.ts +320 -0
  1063. package/src/onboarding/index.ts +529 -0
  1064. package/src/openai-chat-compat.ts +56 -0
  1065. package/src/operator-toolkit.ts +2132 -0
  1066. package/src/opik-exporter.test.ts +72 -0
  1067. package/src/opik-exporter.ts +587 -0
  1068. package/src/orchestrator-extraction-queue.test.ts +197 -0
  1069. package/src/orchestrator-flush.test.ts +1171 -0
  1070. package/src/orchestrator-pattern-reinforcement.test.ts +128 -0
  1071. package/src/orchestrator-source-attribution.test.ts +701 -0
  1072. package/src/orchestrator.ts +16368 -0
  1073. package/src/page-versioning.ts +450 -0
  1074. package/src/patterns-cli.ts +574 -0
  1075. package/src/peers/index.ts +54 -0
  1076. package/src/peers/migrate-from-identity-anchor.test.ts +291 -0
  1077. package/src/peers/migrate-from-identity-anchor.ts +350 -0
  1078. package/src/peers/peers.test.ts +419 -0
  1079. package/src/peers/profile-reasoner.ts +694 -0
  1080. package/src/peers/storage.ts +1350 -0
  1081. package/src/peers/types.ts +138 -0
  1082. package/src/plugin-id.ts +84 -0
  1083. package/src/policy-runtime.ts +209 -0
  1084. package/src/procedural/procedure-miner.ts +150 -0
  1085. package/src/procedural/procedure-recall.ts +93 -0
  1086. package/src/procedural/procedure-stats.ts +213 -0
  1087. package/src/procedural/procedure-types.ts +132 -0
  1088. package/src/procedural/reinforcement-core.test.ts +132 -0
  1089. package/src/procedural/reinforcement-core.ts +73 -0
  1090. package/src/profiling.test.ts +263 -0
  1091. package/src/profiling.ts +435 -0
  1092. package/src/projection/index.ts +398 -0
  1093. package/src/qmd-recall-cache.test.ts +138 -0
  1094. package/src/qmd-recall-cache.ts +111 -0
  1095. package/src/qmd.test.ts +257 -0
  1096. package/src/qmd.ts +2614 -0
  1097. package/src/reasoning-trace-recall.ts +201 -0
  1098. package/src/reasoning-trace-types.ts +235 -0
  1099. package/src/recall-audit-anomaly.test.ts +246 -0
  1100. package/src/recall-audit-anomaly.ts +297 -0
  1101. package/src/recall-audit.test.ts +51 -0
  1102. package/src/recall-audit.ts +72 -0
  1103. package/src/recall-budget-config.test.ts +87 -0
  1104. package/src/recall-disclosure-escalation.test.ts +196 -0
  1105. package/src/recall-disclosure-escalation.ts +158 -0
  1106. package/src/recall-disclosure-shaping.test.ts +146 -0
  1107. package/src/recall-disclosure.test.ts +214 -0
  1108. package/src/recall-explain-renderer.test.ts +140 -0
  1109. package/src/recall-explain-renderer.ts +356 -0
  1110. package/src/recall-mmr.test.ts +808 -0
  1111. package/src/recall-mmr.ts +607 -0
  1112. package/src/recall-qos.test.ts +85 -0
  1113. package/src/recall-qos.ts +82 -0
  1114. package/src/recall-query-policy.ts +221 -0
  1115. package/src/recall-state.test.ts +233 -0
  1116. package/src/recall-state.ts +456 -0
  1117. package/src/recall-tag-filter.ts +143 -0
  1118. package/src/recall-tokenization.ts +35 -0
  1119. package/src/recall-xray-cli.test.ts +118 -0
  1120. package/src/recall-xray-cli.ts +100 -0
  1121. package/src/recall-xray-disclosure-telemetry.test.ts +183 -0
  1122. package/src/recall-xray-renderer.test.ts +539 -0
  1123. package/src/recall-xray-renderer.ts +487 -0
  1124. package/src/recall-xray.test.ts +503 -0
  1125. package/src/recall-xray.ts +621 -0
  1126. package/src/reconstruct.ts +41 -0
  1127. package/src/release-changelog.ts +35 -0
  1128. package/src/relevance.ts +67 -0
  1129. package/src/replay/normalizers/chatgpt.ts +133 -0
  1130. package/src/replay/normalizers/claude.ts +102 -0
  1131. package/src/replay/normalizers/openclaw.ts +119 -0
  1132. package/src/replay/normalizers/shared.ts +69 -0
  1133. package/src/replay/runner.ts +197 -0
  1134. package/src/replay/types.ts +143 -0
  1135. package/src/rerank.test.ts +48 -0
  1136. package/src/rerank.ts +176 -0
  1137. package/src/resolve-auth-token.test.ts +226 -0
  1138. package/src/resolve-auth-token.ts +151 -0
  1139. package/src/resolve-provider-secret.test.ts +187 -0
  1140. package/src/resolve-provider-secret.ts +410 -0
  1141. package/src/response-guidance-recall.test.ts +3952 -0
  1142. package/src/response-guidance-recall.ts +4431 -0
  1143. package/src/resume-bundles.ts +415 -0
  1144. package/src/retrieval-agents.ts +623 -0
  1145. package/src/retrieval-tiers.ts +25 -0
  1146. package/src/retrieval.ts +104 -0
  1147. package/src/review/index.test.ts +201 -0
  1148. package/src/review/index.ts +536 -0
  1149. package/src/routing/engine.ts +162 -0
  1150. package/src/routing/store.ts +321 -0
  1151. package/src/runtime/better-sqlite.test.ts +32 -0
  1152. package/src/runtime/better-sqlite.ts +76 -0
  1153. package/src/runtime/child-process.ts +67 -0
  1154. package/src/runtime/env.ts +48 -0
  1155. package/src/sanitize.ts +58 -0
  1156. package/src/schemas.ts +449 -0
  1157. package/src/sdk-compat.ts +87 -0
  1158. package/src/search/document-scanner.ts +96 -0
  1159. package/src/search/embed-helper.ts +142 -0
  1160. package/src/search/factory.ts +189 -0
  1161. package/src/search/index.ts +10 -0
  1162. package/src/search/lancedb-backend.ts +342 -0
  1163. package/src/search/meilisearch-backend.ts +232 -0
  1164. package/src/search/noop-backend.ts +57 -0
  1165. package/src/search/orama-backend.ts +358 -0
  1166. package/src/search/port.ts +86 -0
  1167. package/src/search/remote-backend.ts +124 -0
  1168. package/src/secure-store/cipher.ts +271 -0
  1169. package/src/secure-store/cli-handlers.ts +355 -0
  1170. package/src/secure-store/cli-renderer.ts +131 -0
  1171. package/src/secure-store/header.ts +373 -0
  1172. package/src/secure-store/index.ts +137 -0
  1173. package/src/secure-store/kdf.ts +263 -0
  1174. package/src/secure-store/keyring.ts +106 -0
  1175. package/src/secure-store/metadata.ts +394 -0
  1176. package/src/secure-store/passphrase-reader.ts +252 -0
  1177. package/src/secure-store/secure-fs.ts +571 -0
  1178. package/src/secure-store/secure-store.test.ts +755 -0
  1179. package/src/semantic-chunking.ts +545 -0
  1180. package/src/semantic-consolidation.test.ts +182 -0
  1181. package/src/semantic-consolidation.ts +432 -0
  1182. package/src/semantic-rule-promotion.ts +183 -0
  1183. package/src/semantic-rule-verifier.ts +160 -0
  1184. package/src/session-integrity.ts +569 -0
  1185. package/src/session-observer-bands.ts +11 -0
  1186. package/src/session-observer-state.ts +346 -0
  1187. package/src/session-toggles.test.ts +96 -0
  1188. package/src/session-toggles.ts +159 -0
  1189. package/src/shared-context/manager.ts +810 -0
  1190. package/src/signal.ts +84 -0
  1191. package/src/skills-registry.test.ts +277 -0
  1192. package/src/skills-registry.ts +120 -0
  1193. package/src/source-attribution-roundtrip.test.ts +215 -0
  1194. package/src/source-attribution.test.ts +1425 -0
  1195. package/src/source-attribution.ts +639 -0
  1196. package/src/spaces/index.ts +627 -0
  1197. package/src/storage-paths.ts +117 -0
  1198. package/src/storage.ts +6657 -0
  1199. package/src/store-contract.ts +55 -0
  1200. package/src/summarizer.ts +844 -0
  1201. package/src/summary-snapshot.test.ts +681 -0
  1202. package/src/summary-snapshot.ts +238 -0
  1203. package/src/surfaces/dreams.test.ts +394 -0
  1204. package/src/surfaces/dreams.ts +346 -0
  1205. package/src/surfaces/heartbeat.test.ts +415 -0
  1206. package/src/surfaces/heartbeat.ts +325 -0
  1207. package/src/sync/index.ts +308 -0
  1208. package/src/targeted-fact-recall.test.ts +1694 -0
  1209. package/src/targeted-fact-recall.ts +2905 -0
  1210. package/src/taxonomy/default-taxonomy.ts +87 -0
  1211. package/src/taxonomy/index.ts +26 -0
  1212. package/src/taxonomy/resolver-doc-generator.ts +57 -0
  1213. package/src/taxonomy/resolver.ts +184 -0
  1214. package/src/taxonomy/taxonomy-loader.ts +186 -0
  1215. package/src/taxonomy/types.ts +48 -0
  1216. package/src/telemetry-transcript.ts +70 -0
  1217. package/src/temporal-index.ts +890 -0
  1218. package/src/temporal-supersession.test.ts +2703 -0
  1219. package/src/temporal-supersession.ts +493 -0
  1220. package/src/temporal-validity.test.ts +448 -0
  1221. package/src/temporal-validity.ts +123 -0
  1222. package/src/threading.ts +395 -0
  1223. package/src/tier-migration.ts +124 -0
  1224. package/src/tier-routing.ts +102 -0
  1225. package/src/tmt.ts +462 -0
  1226. package/src/tokens.test.ts +178 -0
  1227. package/src/tokens.ts +279 -0
  1228. package/src/topics.ts +147 -0
  1229. package/src/training-export/cli-date-validation.test.ts +258 -0
  1230. package/src/training-export/converter.test.ts +452 -0
  1231. package/src/training-export/converter.ts +319 -0
  1232. package/src/training-export/date-parse.ts +117 -0
  1233. package/src/training-export/index.ts +26 -0
  1234. package/src/training-export/registry.test.ts +85 -0
  1235. package/src/training-export/registry.ts +57 -0
  1236. package/src/training-export/types.ts +31 -0
  1237. package/src/transcript.ts +1179 -0
  1238. package/src/transfer/autodetect.ts +30 -0
  1239. package/src/transfer/backup.ts +138 -0
  1240. package/src/transfer/capsule-crypto.ts +485 -0
  1241. package/src/transfer/capsule-encrypt.test.ts +690 -0
  1242. package/src/transfer/capsule-export.ts +543 -0
  1243. package/src/transfer/capsule-fork.ts +375 -0
  1244. package/src/transfer/capsule-import.ts +564 -0
  1245. package/src/transfer/capsule-merge.ts +433 -0
  1246. package/src/transfer/conflict-policy.ts +16 -0
  1247. package/src/transfer/constants.ts +13 -0
  1248. package/src/transfer/exclusions.ts +37 -0
  1249. package/src/transfer/export-json.ts +65 -0
  1250. package/src/transfer/export-md.ts +59 -0
  1251. package/src/transfer/export-sqlite.ts +52 -0
  1252. package/src/transfer/fs-utils.ts +269 -0
  1253. package/src/transfer/import-json.ts +108 -0
  1254. package/src/transfer/import-md.ts +84 -0
  1255. package/src/transfer/import-sqlite.ts +100 -0
  1256. package/src/transfer/integrity.ts +71 -0
  1257. package/src/transfer/sqlite-schema.ts +16 -0
  1258. package/src/transfer/types.ts +297 -0
  1259. package/src/trust-zones.ts +1186 -0
  1260. package/src/types.ts +3074 -0
  1261. package/src/user-model.test.ts +124 -0
  1262. package/src/user-model.ts +162 -0
  1263. package/src/utility-learner.ts +353 -0
  1264. package/src/utility-runtime.ts +88 -0
  1265. package/src/utility-telemetry.ts +215 -0
  1266. package/src/utils/category-dir.ts +44 -0
  1267. package/src/utils/errno.ts +6 -0
  1268. package/src/utils/iso-timestamp.test.ts +37 -0
  1269. package/src/utils/iso-timestamp.ts +164 -0
  1270. package/src/utils/path.ts +26 -0
  1271. package/src/verified-recall.ts +138 -0
  1272. package/src/version-utils.test.ts +10 -0
  1273. package/src/version-utils.ts +9 -0
  1274. package/src/whitespace.ts +10 -0
  1275. package/src/work/board.ts +359 -0
  1276. package/src/work/boundary.ts +107 -0
  1277. package/src/work/storage.ts +436 -0
  1278. package/src/work/types.ts +82 -0
  1279. package/src/work-product-ledger.ts +265 -0
  1280. package/dist/access-service-BkXt3di1.d.ts +0 -2039
  1281. package/dist/capsule-crypto-SJS5VVAP.js +0 -18
  1282. package/dist/capsule-export-LLEVB2RG.js +0 -17
  1283. package/dist/capsule-import-UW45R2MZ.js +0 -16
  1284. package/dist/capsule-merge-DI7PNQ2H.js +0 -189
  1285. package/dist/chunk-2LGMW3DJ.js +0 -111
  1286. package/dist/chunk-2YMTO4ZJ.js +0 -265
  1287. package/dist/chunk-2YMTO4ZJ.js.map +0 -1
  1288. package/dist/chunk-363MWCD3.js +0 -9683
  1289. package/dist/chunk-363MWCD3.js.map +0 -1
  1290. package/dist/chunk-36CTNQY7.js +0 -1554
  1291. package/dist/chunk-36CTNQY7.js.map +0 -1
  1292. package/dist/chunk-457A4P3L.js +0 -119
  1293. package/dist/chunk-457A4P3L.js.map +0 -1
  1294. package/dist/chunk-4DXC6HQQ.js +0 -1837
  1295. package/dist/chunk-4DXC6HQQ.js.map +0 -1
  1296. package/dist/chunk-4IS4SXIQ.js +0 -2040
  1297. package/dist/chunk-57QNCUEZ.js +0 -1914
  1298. package/dist/chunk-57QNCUEZ.js.map +0 -1
  1299. package/dist/chunk-6AUUAZEX.js +0 -150
  1300. package/dist/chunk-6AUUAZEX.js.map +0 -1
  1301. package/dist/chunk-6TBWYBJ3.js +0 -236
  1302. package/dist/chunk-6XA7UN4Z.js +0 -135
  1303. package/dist/chunk-6Z6UH6TK.js +0 -2129
  1304. package/dist/chunk-6Z6UH6TK.js.map +0 -1
  1305. package/dist/chunk-74EMIVE4.js +0 -329
  1306. package/dist/chunk-74EMIVE4.js.map +0 -1
  1307. package/dist/chunk-74WWN7ZW.js +0 -82
  1308. package/dist/chunk-74WWN7ZW.js.map +0 -1
  1309. package/dist/chunk-767ODGE6.js +0 -183
  1310. package/dist/chunk-A4ACKWIW.js +0 -289
  1311. package/dist/chunk-A4ACKWIW.js.map +0 -1
  1312. package/dist/chunk-ASAITVLA.js +0 -64
  1313. package/dist/chunk-ASAITVLA.js.map +0 -1
  1314. package/dist/chunk-C5HUWVH2.js +0 -891
  1315. package/dist/chunk-C5HUWVH2.js.map +0 -1
  1316. package/dist/chunk-D54LZC5L.js +0 -147
  1317. package/dist/chunk-DF3RVK3X.js +0 -119
  1318. package/dist/chunk-DF3RVK3X.js.map +0 -1
  1319. package/dist/chunk-E6K4NIEU.js +0 -747
  1320. package/dist/chunk-E6K4NIEU.js.map +0 -1
  1321. package/dist/chunk-EEQLFRUM.js +0 -89
  1322. package/dist/chunk-EQINRHYR.js +0 -672
  1323. package/dist/chunk-EQINRHYR.js.map +0 -1
  1324. package/dist/chunk-ETOW6ACV.js +0 -158
  1325. package/dist/chunk-ETOW6ACV.js.map +0 -1
  1326. package/dist/chunk-EYNQTST2.js +0 -721
  1327. package/dist/chunk-FYIYMQ5N.js +0 -221
  1328. package/dist/chunk-FYIYMQ5N.js.map +0 -1
  1329. package/dist/chunk-G2WADRQ3.js +0 -219
  1330. package/dist/chunk-G4SK7DSQ.js +0 -121
  1331. package/dist/chunk-GGD5W7TB.js +0 -105
  1332. package/dist/chunk-GGD5W7TB.js.map +0 -1
  1333. package/dist/chunk-GVPWB7EY.js +0 -390
  1334. package/dist/chunk-GVPWB7EY.js.map +0 -1
  1335. package/dist/chunk-HJYHRE4S.js +0 -647
  1336. package/dist/chunk-I6BQZSML.js +0 -1451
  1337. package/dist/chunk-I6BQZSML.js.map +0 -1
  1338. package/dist/chunk-IBX3VFOM.js +0 -446
  1339. package/dist/chunk-IBX3VFOM.js.map +0 -1
  1340. package/dist/chunk-IXEJRKCZ.js +0 -18
  1341. package/dist/chunk-JBMSGZEQ.js +0 -441
  1342. package/dist/chunk-JBMSGZEQ.js.map +0 -1
  1343. package/dist/chunk-JRNQ3RNA.js +0 -284
  1344. package/dist/chunk-JRNQ3RNA.js.map +0 -1
  1345. package/dist/chunk-K6WK37A6.js +0 -865
  1346. package/dist/chunk-K6WK37A6.js.map +0 -1
  1347. package/dist/chunk-KBYWQWSB.js +0 -271
  1348. package/dist/chunk-KUHRUM6B.js +0 -14397
  1349. package/dist/chunk-KUHRUM6B.js.map +0 -1
  1350. package/dist/chunk-KWBPHZUU.js +0 -83
  1351. package/dist/chunk-KWBPHZUU.js.map +0 -1
  1352. package/dist/chunk-LIO5X3CM.js +0 -596
  1353. package/dist/chunk-MARWOCVP.js +0 -48
  1354. package/dist/chunk-MCC6KDQF.js +0 -5095
  1355. package/dist/chunk-MCC6KDQF.js.map +0 -1
  1356. package/dist/chunk-N5AKDXAI.js +0 -74
  1357. package/dist/chunk-NN3LPQ5D.js +0 -936
  1358. package/dist/chunk-NN3LPQ5D.js.map +0 -1
  1359. package/dist/chunk-O4XJUPSF.js +0 -533
  1360. package/dist/chunk-O4XJUPSF.js.map +0 -1
  1361. package/dist/chunk-OA3L7BFR.js +0 -183
  1362. package/dist/chunk-OA3L7BFR.js.map +0 -1
  1363. package/dist/chunk-OR64ZGRZ.js +0 -23
  1364. package/dist/chunk-P73JTV34.js +0 -275
  1365. package/dist/chunk-P73JTV34.js.map +0 -1
  1366. package/dist/chunk-P77UEOU2.js +0 -1521
  1367. package/dist/chunk-P77UEOU2.js.map +0 -1
  1368. package/dist/chunk-PB5KW5PL.js +0 -118
  1369. package/dist/chunk-PHNGXFQ6.js +0 -623
  1370. package/dist/chunk-PHNGXFQ6.js.map +0 -1
  1371. package/dist/chunk-QIGOEM65.js +0 -228
  1372. package/dist/chunk-RXTFCYQF.js +0 -108
  1373. package/dist/chunk-S2JJBLJG.js +0 -2101
  1374. package/dist/chunk-S2JJBLJG.js.map +0 -1
  1375. package/dist/chunk-S3IP6R6K.js +0 -219
  1376. package/dist/chunk-S3IP6R6K.js.map +0 -1
  1377. package/dist/chunk-SRBJUAMP.js +0 -403
  1378. package/dist/chunk-SRBJUAMP.js.map +0 -1
  1379. package/dist/chunk-URB2WSKZ.js +0 -350
  1380. package/dist/chunk-URB2WSKZ.js.map +0 -1
  1381. package/dist/chunk-VQXK37XA.js +0 -26
  1382. package/dist/chunk-VQXK37XA.js.map +0 -1
  1383. package/dist/chunk-VTU2B4VF.js +0 -146
  1384. package/dist/chunk-VTU2B4VF.js.map +0 -1
  1385. package/dist/chunk-VX2IUQFE.js +0 -613
  1386. package/dist/chunk-VX2IUQFE.js.map +0 -1
  1387. package/dist/chunk-WGK4VHGP.js +0 -4292
  1388. package/dist/chunk-WGK4VHGP.js.map +0 -1
  1389. package/dist/chunk-WTFWLUSX.js +0 -827
  1390. package/dist/chunk-WTFWLUSX.js.map +0 -1
  1391. package/dist/chunk-XJKFSSDW.js +0 -726
  1392. package/dist/chunk-XJKFSSDW.js.map +0 -1
  1393. package/dist/chunk-XMHBH5H6.js +0 -283
  1394. package/dist/chunk-XMHBH5H6.js.map +0 -1
  1395. package/dist/chunk-XMVFHBHT.js +0 -277
  1396. package/dist/chunk-Y5KDIOKF.js +0 -2403
  1397. package/dist/chunk-Y5KDIOKF.js.map +0 -1
  1398. package/dist/chunk-YNB73F22.js +0 -137
  1399. package/dist/chunk-YNB73F22.js.map +0 -1
  1400. package/dist/chunk-Z2E7VW55.js +0 -335
  1401. package/dist/chunk-Z2E7VW55.js.map +0 -1
  1402. package/dist/chunk-Z5S5HNGY.js +0 -2280
  1403. package/dist/chunk-Z5S5HNGY.js.map +0 -1
  1404. package/dist/chunk-ZL4S7ARC.js +0 -53
  1405. package/dist/chunk-ZTSE2ZJ6.js +0 -190
  1406. package/dist/chunk-ZTSE2ZJ6.js.map +0 -1
  1407. package/dist/cli-Cvy2SNhF.d.ts +0 -1259
  1408. package/dist/codex-materialize-CQlLTzke.d.ts +0 -139
  1409. package/dist/connectors-cli-DFGtY2DB.d.ts +0 -257
  1410. package/dist/contradiction-review-5LTTVDQV.js +0 -22
  1411. package/dist/contradiction-scan-3Z6YW7YA.js +0 -413
  1412. package/dist/contradiction-scan-3Z6YW7YA.js.map +0 -1
  1413. package/dist/engine-FOC3IJLA.js +0 -28
  1414. package/dist/fs-utils-IRVUFB6G.js +0 -30
  1415. package/dist/graph-edge-decay-PWB63GRE.js +0 -207
  1416. package/dist/index-1qIcnbG1.d.ts +0 -34
  1417. package/dist/memory-governance-F3QOJGEY.js +0 -37
  1418. package/dist/memory-projection-store-CY8TU40w.d.ts +0 -222
  1419. package/dist/orchestrator-AOQMo7QI.d.ts +0 -1784
  1420. package/dist/path-RMTY5Y5A.js +0 -9
  1421. package/dist/port-B6VEDIkC.d.ts +0 -53
  1422. package/dist/resolution-YGIBORXI.js +0 -101
  1423. package/dist/resolution-YGIBORXI.js.map +0 -1
  1424. package/dist/secure-store-4R2GSO7S.js +0 -156
  1425. package/dist/semantic-consolidation-ByBXb-sf.d.ts +0 -180
  1426. package/dist/state-store-3EH7HYIN.js +0 -16
  1427. package/dist/types-V3FJ26TF.js +0 -30
  1428. /package/dist/{capsule-crypto-SJS5VVAP.js.map → action-confidence.js.map} +0 -0
  1429. /package/dist/{capsule-export-LLEVB2RG.js.map → adapters/claude-code.js.map} +0 -0
  1430. /package/dist/{capsule-import-UW45R2MZ.js.map → adapters/codex.js.map} +0 -0
  1431. /package/dist/{contradiction-review-5LTTVDQV.js.map → adapters/hermes.js.map} +0 -0
  1432. /package/dist/{engine-FOC3IJLA.js.map → adapters/index.js.map} +0 -0
  1433. /package/dist/{fs-utils-IRVUFB6G.js.map → adapters/registry.js.map} +0 -0
  1434. /package/dist/{memory-governance-F3QOJGEY.js.map → adapters/replit.js.map} +0 -0
  1435. /package/dist/{path-RMTY5Y5A.js.map → adapters/types.js.map} +0 -0
  1436. /package/dist/{secure-store-4R2GSO7S.js.map → capsule-crypto-5CYAGVC5.js.map} +0 -0
  1437. /package/dist/{capsule-merge-DI7PNQ2H.js.map → capsule-merge-4MGKE7C5.js.map} +0 -0
  1438. /package/dist/{chunk-G4SK7DSQ.js.map → chunk-2WWLHTZY.js.map} +0 -0
  1439. /package/dist/{chunk-KBYWQWSB.js.map → chunk-4CRG46BG.js.map} +0 -0
  1440. /package/dist/{chunk-LIO5X3CM.js.map → chunk-7IASACLB.js.map} +0 -0
  1441. /package/dist/{chunk-EYNQTST2.js.map → chunk-EFJ3MQ4V.js.map} +0 -0
  1442. /package/dist/{chunk-D54LZC5L.js.map → chunk-FDU6HUUL.js.map} +0 -0
  1443. /package/dist/{chunk-QIGOEM65.js.map → chunk-GGKRUQOO.js.map} +0 -0
  1444. /package/dist/{chunk-HJYHRE4S.js.map → chunk-GL6I6MEQ.js.map} +0 -0
  1445. /package/dist/{state-store-3EH7HYIN.js.map → chunk-HHLLAQGZ.js.map} +0 -0
  1446. /package/dist/{chunk-4IS4SXIQ.js.map → chunk-HXXBL2KD.js.map} +0 -0
  1447. /package/dist/{chunk-767ODGE6.js.map → chunk-KNKUID7G.js.map} +0 -0
  1448. /package/dist/{chunk-6TBWYBJ3.js.map → chunk-LPMVBPA3.js.map} +0 -0
  1449. /package/dist/{chunk-PB5KW5PL.js.map → chunk-MC26UJIM.js.map} +0 -0
  1450. /package/dist/{chunk-ZL4S7ARC.js.map → chunk-MT4HVDUZ.js.map} +0 -0
  1451. /package/dist/{chunk-G2WADRQ3.js.map → chunk-MY6TPVXW.js.map} +0 -0
  1452. /package/dist/{chunk-OR64ZGRZ.js.map → chunk-NNVTUXEB.js.map} +0 -0
  1453. /package/dist/{chunk-RXTFCYQF.js.map → chunk-P4NEIHUT.js.map} +0 -0
  1454. /package/dist/{chunk-IXEJRKCZ.js.map → chunk-QRNI5JBH.js.map} +0 -0
  1455. /package/dist/{chunk-EEQLFRUM.js.map → chunk-RRF5UOBJ.js.map} +0 -0
  1456. /package/dist/{types-V3FJ26TF.js.map → chunk-SEDEKFYQ.js.map} +0 -0
  1457. /package/dist/{chunk-2LGMW3DJ.js.map → chunk-U3PN77QT.js.map} +0 -0
  1458. /package/dist/{chunk-XMVFHBHT.js.map → chunk-U3WSW6PZ.js.map} +0 -0
  1459. /package/dist/{chunk-N5AKDXAI.js.map → chunk-UWVJF25J.js.map} +0 -0
  1460. /package/dist/{chunk-MARWOCVP.js.map → chunk-XIG5PDM7.js.map} +0 -0
  1461. /package/dist/{chunk-6XA7UN4Z.js.map → chunk-XVZ7B3HG.js.map} +0 -0
  1462. /package/dist/{graph-edge-decay-PWB63GRE.js.map → graph-edge-decay-5DI5GUNL.js.map} +0 -0
@@ -1,2129 +0,0 @@
1
- import {
2
- cloneDefaultSessionObserverBands
3
- } from "./chunk-Z5LAYHGJ.js";
4
- import {
5
- normalizeEntitySchemas
6
- } from "./chunk-4DJQYKMN.js";
7
- import {
8
- readEnvVar,
9
- resolveHomeDir
10
- } from "./chunk-MARWOCVP.js";
11
- import {
12
- log
13
- } from "./chunk-2ODBA7MQ.js";
14
-
15
- // src/config.ts
16
- import path from "path";
17
-
18
- // src/connectors/coerce.ts
19
- function coerceBool(value) {
20
- if (typeof value === "boolean") return value;
21
- if (typeof value === "string") {
22
- const v = value.trim().toLowerCase();
23
- if (["false", "0", "no", "off"].includes(v)) return false;
24
- if (["true", "1", "yes", "on"].includes(v)) return true;
25
- }
26
- return void 0;
27
- }
28
- function coerceInstallExtension(value) {
29
- return coerceBool(value);
30
- }
31
- function coerceNumber(value) {
32
- if (typeof value === "number") {
33
- return Number.isFinite(value) ? value : void 0;
34
- }
35
- if (typeof value === "string") {
36
- const trimmed = value.trim();
37
- if (trimmed.length === 0) return void 0;
38
- const n = Number(trimmed);
39
- return Number.isFinite(n) ? n : void 0;
40
- }
41
- return void 0;
42
- }
43
-
44
- // src/config.ts
45
- var DEFAULT_MEMORY_DIR = path.join(
46
- resolveHomeDir(),
47
- ".openclaw",
48
- "workspace",
49
- "memory",
50
- "local"
51
- );
52
- var DEFAULT_WORKSPACE_DIR = path.join(
53
- resolveHomeDir(),
54
- ".openclaw",
55
- "workspace"
56
- );
57
- var DEFAULT_INIT_GATE_TIMEOUT_MS = 3e4;
58
- var CLIENT_SECRET_FIELD = ["client", "Secret"].join("");
59
- var REFRESH_TOKEN_FIELD = ["refresh", "Token"].join("");
60
- var LEGACY_ACTIVE_RECALL_CUSTOM_FIELD = [
61
- "activeRecall",
62
- "Prompt",
63
- "Override"
64
- ].join("");
65
- function parseBoundedIntegerMs(value, fallback, min, max) {
66
- const coerced = coerceNumber(value);
67
- if (coerced === void 0) return fallback;
68
- return Math.min(max, Math.max(min, Math.floor(coerced)));
69
- }
70
- function coerceBooleanLike(value) {
71
- if (typeof value === "boolean") return value;
72
- if (typeof value === "number") {
73
- if (value === 1) return true;
74
- if (value === 0) return false;
75
- return void 0;
76
- }
77
- if (typeof value === "string") {
78
- const normalized = value.trim().toLowerCase();
79
- if (normalized === "true" || normalized === "1" || normalized === "yes" || normalized === "on") {
80
- return true;
81
- }
82
- if (normalized === "false" || normalized === "0" || normalized === "no" || normalized === "off") {
83
- return false;
84
- }
85
- }
86
- return void 0;
87
- }
88
- function isSecretRefShape(value) {
89
- if (!value || typeof value !== "object" || Array.isArray(value)) return false;
90
- const obj = value;
91
- return typeof obj.source === "string" && obj.source.trim().length > 0;
92
- }
93
- function parseAgentAccessAuthToken(raw) {
94
- if (raw === void 0 || raw === null) {
95
- return readEnvVar("OPENCLAW_REMNIC_ACCESS_TOKEN") ?? readEnvVar("OPENCLAW_ENGRAM_ACCESS_TOKEN");
96
- }
97
- if (typeof raw === "string") {
98
- if (raw.trim().length === 0) {
99
- return readEnvVar("OPENCLAW_REMNIC_ACCESS_TOKEN") ?? readEnvVar("OPENCLAW_ENGRAM_ACCESS_TOKEN");
100
- }
101
- return resolveEnvVars(raw);
102
- }
103
- if (isSecretRefShape(raw)) {
104
- return raw;
105
- }
106
- throw new Error(
107
- "unsupported SecretRef shape for agentAccessHttp.authToken \u2014 expected a string or an object with a non-empty `source` field (see https://github.com/joshuaswarren/remnic/issues/757)"
108
- );
109
- }
110
- function resolveEnvVars(value) {
111
- const resolved = value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_, envVar) => {
112
- const envValue = readEnvVar(envVar);
113
- if (!envValue) {
114
- throw new Error(`Environment variable ${envVar} is not set`);
115
- }
116
- return envValue;
117
- });
118
- const remaining = resolved.match(/\$\{[^}]*\}/);
119
- if (remaining) {
120
- throw new Error(`Malformed environment variable placeholder: ${remaining[0]}`);
121
- }
122
- return resolved;
123
- }
124
- function normalizeOpenaiBaseUrl(value, source) {
125
- if (!value) return void 0;
126
- const trimmed = value.trim();
127
- if (trimmed.length === 0) return void 0;
128
- let parsed;
129
- try {
130
- parsed = new URL(trimmed);
131
- } catch {
132
- log.warn(`ignoring invalid openaiBaseUrl from ${source}: not a valid URL`);
133
- return void 0;
134
- }
135
- if (parsed.protocol !== "https:" && parsed.protocol !== "http:") {
136
- log.warn(
137
- `ignoring openaiBaseUrl from ${source}: unsupported URL scheme (${parsed.protocol.replace(":", "")})`
138
- );
139
- return void 0;
140
- }
141
- if (parsed.protocol === "http:") {
142
- log.warn(`openaiBaseUrl from ${source} is using insecure http; prefer https`);
143
- }
144
- let url = parsed.toString();
145
- while (url.endsWith("/")) url = url.slice(0, -1);
146
- return url;
147
- }
148
- function normalizeMemoryRelativeDir(raw, fallback) {
149
- if (typeof raw !== "string") return fallback;
150
- const trimmed = raw.trim();
151
- if (trimmed.length === 0) return fallback;
152
- const normalized = trimmed.replace(/\\/g, "/").split("/").filter((segment) => segment.length > 0 && segment !== "." && segment !== "..").join("/");
153
- return normalized.length > 0 ? normalized : fallback;
154
- }
155
- function parseContradictionScanConfig(raw) {
156
- if (!raw || typeof raw !== "object") {
157
- return {
158
- enabled: false,
159
- similarityFloor: 0.82,
160
- topicOverlapFloor: 0.4,
161
- maxPairsPerRun: 500,
162
- cooldownDays: 14,
163
- autoMergeDuplicates: false
164
- };
165
- }
166
- const src = raw;
167
- const simFloor = coerceNumber(src.similarityFloor) ?? 0.82;
168
- const topicFloor = coerceNumber(src.topicOverlapFloor) ?? 0.4;
169
- const maxPairs = coerceNumber(src.maxPairsPerRun) ?? 500;
170
- const cooldown = coerceNumber(src.cooldownDays) ?? 14;
171
- return {
172
- enabled: coerceBool(src.enabled) === true,
173
- similarityFloor: Math.min(1, Math.max(0, simFloor)),
174
- topicOverlapFloor: Math.min(1, Math.max(0, topicFloor)),
175
- maxPairsPerRun: Math.max(1, maxPairs),
176
- cooldownDays: Math.max(0, cooldown),
177
- autoMergeDuplicates: coerceBool(src.autoMergeDuplicates) === true
178
- };
179
- }
180
- function parseSemanticChunkingConfig(raw) {
181
- if (!raw || typeof raw !== "object") return {};
182
- const src = raw;
183
- const out = {};
184
- if (typeof src.targetTokens === "number") out.targetTokens = src.targetTokens;
185
- if (typeof src.minTokens === "number") out.minTokens = src.minTokens;
186
- if (typeof src.maxTokens === "number") out.maxTokens = src.maxTokens;
187
- if (typeof src.smoothingWindowSize === "number") out.smoothingWindowSize = src.smoothingWindowSize;
188
- if (typeof src.boundaryThresholdStdDevs === "number") out.boundaryThresholdStdDevs = src.boundaryThresholdStdDevs;
189
- if (typeof src.embeddingBatchSize === "number") out.embeddingBatchSize = src.embeddingBatchSize;
190
- if (typeof src.fallbackToRecursive === "boolean") out.fallbackToRecursive = src.fallbackToRecursive;
191
- return out;
192
- }
193
- var DEFAULT_REASONING_MODEL = "gpt-5.2";
194
- var VALID_EFFORTS = ["none", "low", "medium", "high"];
195
- var VALID_TRIGGERS = ["smart", "every_n", "time_based"];
196
- var VALID_IDENTITY_INJECTION_MODES = ["recovery_only", "minimal", "full"];
197
- var VALID_MEMORY_OS_PRESETS = [
198
- "conservative",
199
- "balanced",
200
- "research-max",
201
- "local-llm-heavy"
202
- ];
203
- var VALID_SLOT_MISMATCH_MODES = ["error", "warn", "silent"];
204
- var VALID_CODEX_COMPACTION_FLUSH_MODES = ["signal", "heuristic", "auto"];
205
- var VALID_MEMORY_CATEGORIES = /* @__PURE__ */ new Set([
206
- "fact",
207
- "preference",
208
- "correction",
209
- "entity",
210
- "decision",
211
- "relationship",
212
- "principle",
213
- "commitment",
214
- "moment",
215
- "skill",
216
- "rule",
217
- "procedure",
218
- "reasoning_trace"
219
- ]);
220
- var DEFAULT_BEHAVIOR_LOOP_PROTECTED_PARAMS = [
221
- "maxMemoryTokens",
222
- "qmdMaxResults",
223
- "qmdColdMaxResults",
224
- "recallPlannerMaxQmdResultsMinimal",
225
- "verbatimArtifactsMaxRecall"
226
- ];
227
- var MEMORY_OS_PRESET_ALIASES = {
228
- research: "research-max"
229
- };
230
- var MEMORY_OS_PRESETS = {
231
- conservative: {
232
- maxMemoryTokens: 1500,
233
- recallPlannerMaxQmdResultsMinimal: 2,
234
- recallPlannerMaxQmdResultsFull: 5,
235
- queryAwareIndexingEnabled: false,
236
- verbatimArtifactsEnabled: false,
237
- verbatimArtifactsMaxRecall: 2,
238
- rerankEnabled: false,
239
- localLlmEnabled: false,
240
- localLlmFastEnabled: false,
241
- multiGraphMemoryEnabled: false,
242
- graphRecallEnabled: false,
243
- graphAssistInFullModeEnabled: false,
244
- proactiveExtractionEnabled: false,
245
- contextCompressionActionsEnabled: false,
246
- compressionGuidelineLearningEnabled: false,
247
- compressionGuidelineSemanticRefinementEnabled: false,
248
- maxProactiveQuestionsPerExtraction: 0,
249
- maxCompressionTokensPerHour: 0,
250
- behaviorLoopAutoTuneEnabled: false,
251
- // Issue #567 PR 4/5 flipped `procedural.enabled` default to `true`.
252
- // The conservative preset intentionally keeps the feature OFF to
253
- // match its restrictive intent (no proactive extraction, no
254
- // compression guideline learning, etc.). Users who want procedural
255
- // memory on a conservative preset must set `procedural.enabled: true`
256
- // explicitly.
257
- procedural: { enabled: false }
258
- },
259
- balanced: {
260
- maxMemoryTokens: 2e3,
261
- recallPlannerMaxQmdResultsMinimal: 4,
262
- recallPlannerMaxQmdResultsFull: 8,
263
- queryAwareIndexingEnabled: true,
264
- verbatimArtifactsEnabled: true,
265
- verbatimArtifactsMaxRecall: 4,
266
- rerankEnabled: true,
267
- rerankProvider: "local",
268
- localLlmEnabled: false,
269
- localLlmFastEnabled: false,
270
- multiGraphMemoryEnabled: false,
271
- graphRecallEnabled: false,
272
- graphAssistInFullModeEnabled: false,
273
- proactiveExtractionEnabled: false,
274
- contextCompressionActionsEnabled: false,
275
- compressionGuidelineLearningEnabled: false,
276
- compressionGuidelineSemanticRefinementEnabled: false,
277
- maxProactiveQuestionsPerExtraction: 2,
278
- maxCompressionTokensPerHour: 1500,
279
- behaviorLoopAutoTuneEnabled: false
280
- },
281
- "research-max": {
282
- maxMemoryTokens: 3200,
283
- recallPlannerMaxQmdResultsMinimal: 6,
284
- recallPlannerMaxQmdResultsFull: 12,
285
- queryAwareIndexingEnabled: true,
286
- verbatimArtifactsEnabled: true,
287
- verbatimArtifactsMaxRecall: 6,
288
- rerankEnabled: true,
289
- rerankProvider: "local",
290
- localLlmEnabled: false,
291
- localLlmFastEnabled: false,
292
- multiGraphMemoryEnabled: true,
293
- graphRecallEnabled: true,
294
- graphAssistInFullModeEnabled: true,
295
- proactiveExtractionEnabled: true,
296
- contextCompressionActionsEnabled: true,
297
- compressionGuidelineLearningEnabled: true,
298
- compressionGuidelineSemanticRefinementEnabled: true,
299
- explicitCueRecallEnabled: true,
300
- explicitCueRecallMaxChars: 3200,
301
- lcmEnabled: true,
302
- maxProactiveQuestionsPerExtraction: 4,
303
- maxCompressionTokensPerHour: 3e3,
304
- behaviorLoopAutoTuneEnabled: true
305
- },
306
- "local-llm-heavy": {
307
- maxMemoryTokens: 2400,
308
- recallPlannerMaxQmdResultsMinimal: 4,
309
- recallPlannerMaxQmdResultsFull: 8,
310
- queryAwareIndexingEnabled: true,
311
- verbatimArtifactsEnabled: true,
312
- verbatimArtifactsMaxRecall: 4,
313
- rerankEnabled: true,
314
- rerankProvider: "local",
315
- localLlmEnabled: true,
316
- localLlmFastEnabled: true,
317
- embeddingFallbackProvider: "local",
318
- localLlmFallback: true,
319
- multiGraphMemoryEnabled: false,
320
- graphRecallEnabled: false,
321
- graphAssistInFullModeEnabled: false,
322
- proactiveExtractionEnabled: true,
323
- contextCompressionActionsEnabled: true,
324
- compressionGuidelineLearningEnabled: true,
325
- compressionGuidelineSemanticRefinementEnabled: false,
326
- maxProactiveQuestionsPerExtraction: 2,
327
- maxCompressionTokensPerHour: 1500,
328
- behaviorLoopAutoTuneEnabled: false
329
- }
330
- };
331
- function resolveMemoryOsPreset(value) {
332
- if (typeof value !== "string") return void 0;
333
- const normalized = value.trim();
334
- if (VALID_MEMORY_OS_PRESETS.includes(normalized)) {
335
- return normalized;
336
- }
337
- return MEMORY_OS_PRESET_ALIASES[normalized];
338
- }
339
- function parseConfig(raw) {
340
- const baseCfg = raw && typeof raw === "object" && !Array.isArray(raw) ? raw : {};
341
- const memoryOsPreset = resolveMemoryOsPreset(baseCfg.memoryOsPreset);
342
- let cfg;
343
- if (memoryOsPreset) {
344
- const preset = MEMORY_OS_PRESETS[memoryOsPreset];
345
- const presetProcedural = preset.procedural && typeof preset.procedural === "object" && !Array.isArray(preset.procedural) ? preset.procedural : void 0;
346
- const baseProcedural = baseCfg.procedural && typeof baseCfg.procedural === "object" && !Array.isArray(baseCfg.procedural) ? baseCfg.procedural : void 0;
347
- const mergedProcedural = presetProcedural && baseProcedural ? { ...presetProcedural, ...baseProcedural } : baseProcedural ?? presetProcedural;
348
- cfg = {
349
- ...preset,
350
- ...baseCfg,
351
- memoryOsPreset
352
- };
353
- if (mergedProcedural !== void 0) {
354
- cfg.procedural = mergedProcedural;
355
- }
356
- } else {
357
- cfg = baseCfg;
358
- }
359
- const modelSource = cfg.modelSource === "gateway" ? "gateway" : "plugin";
360
- let apiKey;
361
- if (typeof cfg.openaiApiKey === "string" && cfg.openaiApiKey.length > 0) {
362
- apiKey = resolveEnvVars(cfg.openaiApiKey);
363
- } else if (modelSource === "gateway") {
364
- apiKey = void 0;
365
- } else {
366
- apiKey = readEnvVar("OPENAI_API_KEY");
367
- }
368
- const model = typeof cfg.model === "string" && cfg.model.length > 0 ? cfg.model : DEFAULT_REASONING_MODEL;
369
- const captureMode = cfg.captureMode === "explicit" || cfg.captureMode === "hybrid" ? cfg.captureMode : "implicit";
370
- const rawEffort = cfg.reasoningEffort;
371
- const reasoningEffort = rawEffort && VALID_EFFORTS.includes(rawEffort) ? rawEffort : "low";
372
- const rawTrigger = cfg.triggerMode;
373
- const triggerMode = rawTrigger && VALID_TRIGGERS.includes(rawTrigger) ? rawTrigger : "smart";
374
- const rawSlotBehavior = cfg.slotBehavior && typeof cfg.slotBehavior === "object" && !Array.isArray(cfg.slotBehavior) ? cfg.slotBehavior : {};
375
- const slotBehavior = {
376
- requireExclusiveMemorySlot: rawSlotBehavior.requireExclusiveMemorySlot !== false,
377
- onSlotMismatch: typeof rawSlotBehavior.onSlotMismatch === "string" && VALID_SLOT_MISMATCH_MODES.includes(
378
- rawSlotBehavior.onSlotMismatch
379
- ) ? rawSlotBehavior.onSlotMismatch : "error"
380
- };
381
- const rawDreaming = cfg.dreaming && typeof cfg.dreaming === "object" && !Array.isArray(cfg.dreaming) ? cfg.dreaming : {};
382
- const dreaming = {
383
- enabled: rawDreaming.enabled === true,
384
- journalPath: typeof rawDreaming.journalPath === "string" && rawDreaming.journalPath.trim().length > 0 ? rawDreaming.journalPath.trim() : "DREAMS.md",
385
- maxEntries: typeof rawDreaming.maxEntries === "number" ? rawDreaming.maxEntries === 0 ? 0 : rawDreaming.maxEntries < 0 ? 500 : rawDreaming.maxEntries < 10 ? 500 : Math.min(1e4, Math.floor(rawDreaming.maxEntries)) : 500,
386
- injectRecentCount: typeof rawDreaming.injectRecentCount === "number" ? Math.min(20, Math.max(0, Math.floor(rawDreaming.injectRecentCount))) : 3,
387
- minIntervalMinutes: typeof rawDreaming.minIntervalMinutes === "number" ? Math.max(1, Math.floor(rawDreaming.minIntervalMinutes)) : 120,
388
- narrativeModel: typeof rawDreaming.narrativeModel === "string" && rawDreaming.narrativeModel.trim().length > 0 ? rawDreaming.narrativeModel.trim() : null,
389
- narrativePromptStyle: rawDreaming.narrativePromptStyle === "diary" || rawDreaming.narrativePromptStyle === "analytical" ? rawDreaming.narrativePromptStyle : "reflective",
390
- watchFile: rawDreaming.watchFile !== false
391
- };
392
- const rawDreamsBlock = cfg.dreams && typeof cfg.dreams === "object" && !Array.isArray(cfg.dreams) ? cfg.dreams : {};
393
- const rawDreamsPhases = rawDreamsBlock.phases && typeof rawDreamsBlock.phases === "object" && !Array.isArray(rawDreamsBlock.phases) ? rawDreamsBlock.phases : {};
394
- const rawDreamsLightSleep = rawDreamsPhases.lightSleep && typeof rawDreamsPhases.lightSleep === "object" && !Array.isArray(rawDreamsPhases.lightSleep) ? rawDreamsPhases.lightSleep : {};
395
- const rawDreamsRem = rawDreamsPhases.rem && typeof rawDreamsPhases.rem === "object" && !Array.isArray(rawDreamsPhases.rem) ? rawDreamsPhases.rem : {};
396
- const rawDreamsDeepSleep = rawDreamsPhases.deepSleep && typeof rawDreamsPhases.deepSleep === "object" && !Array.isArray(rawDreamsPhases.deepSleep) ? rawDreamsPhases.deepSleep : {};
397
- const legacyLifecyclePolicyEnabled = coerceBooleanLike(cfg.lifecyclePolicyEnabled) ?? true;
398
- const legacyLifecyclePromoteHeatThreshold = typeof cfg.lifecyclePromoteHeatThreshold === "number" ? Math.min(1, Math.max(0, cfg.lifecyclePromoteHeatThreshold)) : 0.55;
399
- const legacyLifecycleStaleDecayThreshold = typeof cfg.lifecycleStaleDecayThreshold === "number" ? Math.min(1, Math.max(0, cfg.lifecycleStaleDecayThreshold)) : 0.65;
400
- const legacyLifecycleArchiveDecayThreshold = typeof cfg.lifecycleArchiveDecayThreshold === "number" ? Math.min(1, Math.max(0, cfg.lifecycleArchiveDecayThreshold)) : 0.85;
401
- const legacySemanticConsolidationEnabled = cfg.semanticConsolidationEnabled === true;
402
- const legacySemanticConsolidationIntervalHours = typeof cfg.semanticConsolidationIntervalHours === "number" ? Math.max(1, Math.floor(cfg.semanticConsolidationIntervalHours)) : 168;
403
- const legacySemanticConsolidationThreshold = typeof cfg.semanticConsolidationThreshold === "number" ? cfg.semanticConsolidationThreshold : 0.8;
404
- const legacySemanticConsolidationMinClusterSize = typeof cfg.semanticConsolidationMinClusterSize === "number" ? Math.max(2, Math.floor(cfg.semanticConsolidationMinClusterSize)) : 3;
405
- const legacySemanticConsolidationMaxPerRun = typeof cfg.semanticConsolidationMaxPerRun === "number" ? Math.max(0, Math.floor(cfg.semanticConsolidationMaxPerRun)) : 100;
406
- const legacyConsolidationMinIntervalMs = typeof cfg.consolidationMinIntervalMs === "number" ? cfg.consolidationMinIntervalMs : 10 * 6e4;
407
- const legacyVersioningEnabled = cfg.versioningEnabled === true;
408
- const legacyVersioningMaxPerPage = typeof cfg.versioningMaxPerPage === "number" ? Math.max(0, Math.floor(cfg.versioningMaxPerPage)) : 50;
409
- const legacyDeepSleepEnabled = cfg.nightlyGovernanceCronAutoRegister === true || cfg.qmdTierMigrationEnabled === true || legacyVersioningEnabled;
410
- const dreamsLightSleepEnabledRaw = coerceBooleanLike(rawDreamsLightSleep.enabled);
411
- const dreamsLightSleep = {
412
- // new key wins; fall back to resolved legacy default
413
- enabled: dreamsLightSleepEnabledRaw !== void 0 ? dreamsLightSleepEnabledRaw : legacyLifecyclePolicyEnabled,
414
- cadenceMs: typeof rawDreamsLightSleep.cadenceMs === "number" ? Math.max(0, Math.floor(rawDreamsLightSleep.cadenceMs)) : 0,
415
- // 0 = no override; orchestrator uses its own internal cadence
416
- promoteHeatThreshold: typeof rawDreamsLightSleep.promoteHeatThreshold === "number" ? Math.min(1, Math.max(0, rawDreamsLightSleep.promoteHeatThreshold)) : legacyLifecyclePromoteHeatThreshold,
417
- staleDecayThreshold: typeof rawDreamsLightSleep.staleDecayThreshold === "number" ? Math.min(1, Math.max(0, rawDreamsLightSleep.staleDecayThreshold)) : legacyLifecycleStaleDecayThreshold,
418
- archiveDecayThreshold: typeof rawDreamsLightSleep.archiveDecayThreshold === "number" ? Math.min(1, Math.max(0, rawDreamsLightSleep.archiveDecayThreshold)) : legacyLifecycleArchiveDecayThreshold,
419
- filterStaleEnabled: rawDreamsLightSleep.filterStaleEnabled !== void 0 ? coerceBooleanLike(rawDreamsLightSleep.filterStaleEnabled) === true : cfg.lifecycleFilterStaleEnabled === true
420
- };
421
- const dreamsRemEnabledRaw = coerceBooleanLike(rawDreamsRem.enabled);
422
- const dreamsRem = {
423
- enabled: dreamsRemEnabledRaw !== void 0 ? dreamsRemEnabledRaw : legacySemanticConsolidationEnabled,
424
- cadenceMs: typeof rawDreamsRem.cadenceMs === "number" ? Math.max(0, Math.floor(rawDreamsRem.cadenceMs)) : legacySemanticConsolidationIntervalHours * 36e5,
425
- similarityThreshold: typeof rawDreamsRem.similarityThreshold === "number" ? Math.min(1, Math.max(0, rawDreamsRem.similarityThreshold)) : legacySemanticConsolidationThreshold,
426
- minClusterSize: typeof rawDreamsRem.minClusterSize === "number" ? Math.max(2, Math.floor(rawDreamsRem.minClusterSize)) : legacySemanticConsolidationMinClusterSize,
427
- maxPerRun: typeof rawDreamsRem.maxPerRun === "number" ? Math.max(0, Math.floor(rawDreamsRem.maxPerRun)) : legacySemanticConsolidationMaxPerRun,
428
- minIntervalMs: typeof rawDreamsRem.minIntervalMs === "number" ? Math.max(0, Math.floor(rawDreamsRem.minIntervalMs)) : legacyConsolidationMinIntervalMs
429
- };
430
- const dreamsDeepSleepEnabledRaw = coerceBooleanLike(rawDreamsDeepSleep.enabled);
431
- const dreamsDeepSleep = {
432
- enabled: dreamsDeepSleepEnabledRaw !== void 0 ? dreamsDeepSleepEnabledRaw : legacyDeepSleepEnabled,
433
- enabledExplicitlySet: dreamsDeepSleepEnabledRaw !== void 0,
434
- cadenceMs: typeof rawDreamsDeepSleep.cadenceMs === "number" ? Math.max(0, Math.floor(rawDreamsDeepSleep.cadenceMs)) : 24 * 36e5,
435
- // default: 24 h (mirrors nightly governance cron)
436
- versioningEnabled: rawDreamsDeepSleep.versioningEnabled !== void 0 ? coerceBooleanLike(rawDreamsDeepSleep.versioningEnabled) === true : legacyVersioningEnabled,
437
- versioningMaxPerPage: typeof rawDreamsDeepSleep.versioningMaxPerPage === "number" ? Math.max(0, Math.floor(rawDreamsDeepSleep.versioningMaxPerPage)) : legacyVersioningMaxPerPage
438
- };
439
- const dreamsPhases = {
440
- lightSleep: dreamsLightSleep,
441
- rem: dreamsRem,
442
- deepSleep: dreamsDeepSleep
443
- };
444
- const rawHeartbeat = cfg.heartbeat && typeof cfg.heartbeat === "object" && !Array.isArray(cfg.heartbeat) ? cfg.heartbeat : {};
445
- const heartbeat = {
446
- enabled: rawHeartbeat.enabled === true,
447
- journalPath: typeof rawHeartbeat.journalPath === "string" && rawHeartbeat.journalPath.trim().length > 0 ? rawHeartbeat.journalPath.trim() : "HEARTBEAT.md",
448
- maxPreviousRuns: typeof rawHeartbeat.maxPreviousRuns === "number" ? Math.min(20, Math.max(0, Math.floor(rawHeartbeat.maxPreviousRuns))) : 5,
449
- watchFile: rawHeartbeat.watchFile !== false,
450
- detectionMode: rawHeartbeat.detectionMode === "runtime-signal" || rawHeartbeat.detectionMode === "heuristic" ? rawHeartbeat.detectionMode : "auto",
451
- gateExtractionDuringHeartbeat: rawHeartbeat.gateExtractionDuringHeartbeat !== false
452
- };
453
- const rawCodexCompat = cfg.codexCompat && typeof cfg.codexCompat === "object" && !Array.isArray(cfg.codexCompat) ? cfg.codexCompat : {};
454
- const codexCompat = {
455
- enabled: rawCodexCompat.enabled === true,
456
- threadIdBufferKeying: rawCodexCompat.threadIdBufferKeying !== false,
457
- compactionFlushMode: typeof rawCodexCompat.compactionFlushMode === "string" && VALID_CODEX_COMPACTION_FLUSH_MODES.includes(
458
- rawCodexCompat.compactionFlushMode
459
- ) ? rawCodexCompat.compactionFlushMode : "auto",
460
- fingerprintDedup: rawCodexCompat.fingerprintDedup !== false
461
- };
462
- if (cfg.procedural !== void 0 && (cfg.procedural === null || typeof cfg.procedural !== "object" || Array.isArray(cfg.procedural))) {
463
- throw new Error(
464
- `procedural must be an object (got ${JSON.stringify(cfg.procedural)}). Use procedural: { enabled: false } to opt out; omit the key to use the default-on behavior (issue #567 PR 4).`
465
- );
466
- }
467
- const rawProcedural = cfg.procedural && typeof cfg.procedural === "object" && !Array.isArray(cfg.procedural) ? cfg.procedural : {};
468
- const proceduralMinCoerced = coerceNumber(rawProcedural.minOccurrences);
469
- const proceduralMinRaw = proceduralMinCoerced !== void 0 ? Math.floor(proceduralMinCoerced) : 3;
470
- const successFloorRaw = coerceNumber(rawProcedural.successFloor);
471
- const successFloor = successFloorRaw !== void 0 && successFloorRaw >= 0 && successFloorRaw <= 1 ? successFloorRaw : 0.75;
472
- const autoPromoteOccRaw = coerceNumber(rawProcedural.autoPromoteOccurrences);
473
- const autoPromoteOccurrences = autoPromoteOccRaw !== void 0 && Number.isFinite(autoPromoteOccRaw) ? autoPromoteOccRaw <= 0 ? 0 : Math.min(1e4, Math.max(1, Math.floor(autoPromoteOccRaw))) : 8;
474
- const lookbackCoerced = coerceNumber(rawProcedural.lookbackDays);
475
- const lookbackDays = lookbackCoerced !== void 0 && Number.isFinite(lookbackCoerced) ? Math.min(3650, Math.max(1, Math.floor(lookbackCoerced))) : 14;
476
- const recallMaxCoerced = coerceNumber(rawProcedural.recallMaxProcedures);
477
- const recallMaxProcedures = recallMaxCoerced !== void 0 && Number.isFinite(recallMaxCoerced) ? Math.min(10, Math.max(1, Math.floor(recallMaxCoerced))) : 2;
478
- const rawEnabledValue = rawProcedural.enabled;
479
- let proceduralEnabled;
480
- if (rawEnabledValue === void 0) {
481
- proceduralEnabled = true;
482
- } else {
483
- const enabledCoerced = coerceBool(rawEnabledValue);
484
- if (enabledCoerced === void 0) {
485
- throw new Error(
486
- `procedural.enabled must be a boolean or one of "true"/"false"/"1"/"0"/"yes"/"no"/"on"/"off" (got ${JSON.stringify(rawEnabledValue)}). Omit the key to use the default-on behavior (issue #567 PR 4).`
487
- );
488
- }
489
- proceduralEnabled = enabledCoerced;
490
- }
491
- const procedural = {
492
- enabled: proceduralEnabled,
493
- /** `0` skips all mining (`minOccurrences_zero`); otherwise clusters need at least this many members. */
494
- minOccurrences: Math.min(1e3, Math.max(0, proceduralMinRaw)),
495
- successFloor,
496
- autoPromoteOccurrences,
497
- autoPromoteEnabled: coerceBool(rawProcedural.autoPromoteEnabled) === true,
498
- lookbackDays,
499
- proceduralMiningCronAutoRegister: coerceBool(rawProcedural.proceduralMiningCronAutoRegister) === true,
500
- recallMaxProcedures
501
- };
502
- const rawCodingMode = cfg.codingMode && typeof cfg.codingMode === "object" && !Array.isArray(cfg.codingMode) ? cfg.codingMode : {};
503
- const codingProjectScopeRaw = coerceBool(rawCodingMode.projectScope);
504
- const codingBranchScopeRaw = coerceBool(rawCodingMode.branchScope);
505
- const codingGlobalFallbackRaw = coerceBool(rawCodingMode.globalFallback);
506
- const codingMode = {
507
- projectScope: codingProjectScopeRaw === void 0 ? true : codingProjectScopeRaw,
508
- branchScope: codingBranchScopeRaw === true,
509
- // Default true — project-scoped sessions include the root namespace in
510
- // read fallbacks so globally useful memories remain visible. CLAUDE.md #30.
511
- globalFallback: codingGlobalFallbackRaw === void 0 ? true : codingGlobalFallbackRaw
512
- };
513
- const memoryDir = typeof cfg.memoryDir === "string" && cfg.memoryDir.length > 0 ? cfg.memoryDir : DEFAULT_MEMORY_DIR;
514
- const rawIdentityInjectionMode = cfg.identityInjectionMode;
515
- const identityInjectionMode = rawIdentityInjectionMode && VALID_IDENTITY_INJECTION_MODES.includes(rawIdentityInjectionMode) ? rawIdentityInjectionMode : "recovery_only";
516
- const identityContinuityEnabled = cfg.identityContinuityEnabled === true;
517
- const sessionObserverBands = Array.isArray(cfg.sessionObserverBands) ? cfg.sessionObserverBands.map((band) => ({
518
- maxBytes: typeof band?.maxBytes === "number" ? Math.max(0, Math.floor(band.maxBytes)) : 0,
519
- triggerDeltaBytes: typeof band?.triggerDeltaBytes === "number" ? Math.max(0, Math.floor(band.triggerDeltaBytes)) : 0,
520
- triggerDeltaTokens: typeof band?.triggerDeltaTokens === "number" ? Math.max(0, Math.floor(band.triggerDeltaTokens)) : 0
521
- })).filter((band) => band.maxBytes > 0) : cloneDefaultSessionObserverBands();
522
- const principalRules = Array.isArray(cfg.principalFromSessionKeyRules) ? cfg.principalFromSessionKeyRules.map((r) => ({
523
- match: typeof r?.match === "string" ? r.match : "",
524
- principal: typeof r?.principal === "string" ? r.principal : ""
525
- })).filter((r) => r.match.length > 0 && r.principal.length > 0) : [];
526
- const entitySchemas = normalizeEntitySchemas(cfg.entitySchemas);
527
- const rawHygiene = cfg.fileHygiene && typeof cfg.fileHygiene === "object" && !Array.isArray(cfg.fileHygiene) ? cfg.fileHygiene : void 0;
528
- const hygieneEnabled = rawHygiene?.enabled === true;
529
- const fileHygiene = hygieneEnabled ? {
530
- enabled: true,
531
- lintEnabled: rawHygiene?.lintEnabled !== false,
532
- lintBudgetBytes: typeof rawHygiene?.lintBudgetBytes === "number" ? rawHygiene.lintBudgetBytes : 2e4,
533
- lintWarnRatio: typeof rawHygiene?.lintWarnRatio === "number" ? rawHygiene.lintWarnRatio : 0.8,
534
- lintPaths: Array.isArray(rawHygiene?.lintPaths) ? rawHygiene.lintPaths : ["IDENTITY.md", "MEMORY.md"],
535
- rotateEnabled: rawHygiene?.rotateEnabled === true,
536
- rotateMaxBytes: typeof rawHygiene?.rotateMaxBytes === "number" ? rawHygiene.rotateMaxBytes : 18e3,
537
- rotateKeepTailChars: typeof rawHygiene?.rotateKeepTailChars === "number" ? rawHygiene.rotateKeepTailChars : 2e3,
538
- rotatePaths: Array.isArray(rawHygiene?.rotatePaths) ? rawHygiene.rotatePaths : ["IDENTITY.md"],
539
- archiveDir: typeof rawHygiene?.archiveDir === "string" && rawHygiene.archiveDir.length > 0 ? rawHygiene.archiveDir : ".engram-archive",
540
- runMinIntervalMs: typeof rawHygiene?.runMinIntervalMs === "number" ? rawHygiene.runMinIntervalMs : 5 * 60 * 1e3,
541
- warningsLogEnabled: rawHygiene?.warningsLogEnabled === true,
542
- warningsLogPath: typeof rawHygiene?.warningsLogPath === "string" && rawHygiene.warningsLogPath.length > 0 ? rawHygiene.warningsLogPath : "hygiene/warnings.md",
543
- indexEnabled: rawHygiene?.indexEnabled === true,
544
- indexPath: typeof rawHygiene?.indexPath === "string" && rawHygiene.indexPath.length > 0 ? rawHygiene.indexPath : "ENGRAM_INDEX.md"
545
- } : void 0;
546
- const rawNativeKnowledge = cfg.nativeKnowledge && typeof cfg.nativeKnowledge === "object" && !Array.isArray(cfg.nativeKnowledge) ? cfg.nativeKnowledge : void 0;
547
- const nativeKnowledge = rawNativeKnowledge?.enabled === true ? {
548
- enabled: true,
549
- includeFiles: Array.isArray(rawNativeKnowledge.includeFiles) ? rawNativeKnowledge.includeFiles.filter((value) => typeof value === "string").map((value) => value.trim()).filter(Boolean) : ["IDENTITY.md", "MEMORY.md"],
550
- maxChunkChars: typeof rawNativeKnowledge.maxChunkChars === "number" ? Math.max(200, Math.floor(rawNativeKnowledge.maxChunkChars)) : 900,
551
- maxResults: typeof rawNativeKnowledge.maxResults === "number" ? Math.max(0, Math.floor(rawNativeKnowledge.maxResults)) : 4,
552
- maxChars: typeof rawNativeKnowledge.maxChars === "number" ? Math.max(0, Math.floor(rawNativeKnowledge.maxChars)) : 2400,
553
- stateDir: normalizeMemoryRelativeDir(rawNativeKnowledge.stateDir, "state/native-knowledge"),
554
- openclawWorkspace: rawNativeKnowledge.openclawWorkspace && typeof rawNativeKnowledge.openclawWorkspace === "object" && !Array.isArray(rawNativeKnowledge.openclawWorkspace) && rawNativeKnowledge.openclawWorkspace.enabled === true ? {
555
- enabled: true,
556
- bootstrapFiles: Array.isArray(rawNativeKnowledge.openclawWorkspace.bootstrapFiles) ? rawNativeKnowledge.openclawWorkspace.bootstrapFiles.filter((value) => typeof value === "string").map((value) => value.trim()).filter(Boolean) : ["IDENTITY.md", "MEMORY.md", "USER.md"],
557
- handoffGlobs: Array.isArray(rawNativeKnowledge.openclawWorkspace.handoffGlobs) ? rawNativeKnowledge.openclawWorkspace.handoffGlobs.filter((value) => typeof value === "string").map((value) => value.trim()).filter(Boolean) : ["**/*handoff*.md", "handoffs/**/*.md"],
558
- dailySummaryGlobs: Array.isArray(rawNativeKnowledge.openclawWorkspace.dailySummaryGlobs) ? rawNativeKnowledge.openclawWorkspace.dailySummaryGlobs.filter((value) => typeof value === "string").map((value) => value.trim()).filter(Boolean) : ["**/*daily*summary*.md", "summaries/**/*.md"],
559
- automationNoteGlobs: Array.isArray(rawNativeKnowledge.openclawWorkspace.automationNoteGlobs) ? rawNativeKnowledge.openclawWorkspace.automationNoteGlobs.filter((value) => typeof value === "string").map((value) => value.trim()).filter(Boolean) : [],
560
- workspaceDocGlobs: Array.isArray(rawNativeKnowledge.openclawWorkspace.workspaceDocGlobs) ? rawNativeKnowledge.openclawWorkspace.workspaceDocGlobs.filter((value) => typeof value === "string").map((value) => value.trim()).filter(Boolean) : [],
561
- excludeGlobs: [
562
- ".git/**",
563
- "node_modules/**",
564
- "dist/**",
565
- "build/**",
566
- "coverage/**",
567
- "**/*.log",
568
- "**/.env*",
569
- "**/*.pem",
570
- "**/*.key",
571
- ...Array.isArray(rawNativeKnowledge.openclawWorkspace.excludeGlobs) ? rawNativeKnowledge.openclawWorkspace.excludeGlobs.filter((value) => typeof value === "string").map((value) => value.trim()).filter(Boolean) : []
572
- ].filter((value, index, array) => array.indexOf(value) === index),
573
- sharedSafeGlobs: Array.isArray(rawNativeKnowledge.openclawWorkspace.sharedSafeGlobs) ? rawNativeKnowledge.openclawWorkspace.sharedSafeGlobs.filter((value) => typeof value === "string").map((value) => value.trim()).filter(Boolean) : []
574
- } : void 0,
575
- obsidianVaults: Array.isArray(rawNativeKnowledge.obsidianVaults) ? rawNativeKnowledge.obsidianVaults.filter((value) => !!value && typeof value === "object" && !Array.isArray(value)).map((vault, index) => {
576
- const defaultId = `vault-${index + 1}`;
577
- return {
578
- id: typeof vault.id === "string" && vault.id.trim().length > 0 ? vault.id.trim() : defaultId,
579
- rootDir: typeof vault.rootDir === "string" && vault.rootDir.trim().length > 0 ? vault.rootDir.trim() : "",
580
- includeGlobs: Array.isArray(vault.includeGlobs) ? vault.includeGlobs.filter((value) => typeof value === "string").map((value) => value.trim()).filter(Boolean) : ["**/*.md"],
581
- excludeGlobs: Array.isArray(vault.excludeGlobs) ? vault.excludeGlobs.filter((value) => typeof value === "string").map((value) => value.trim()).filter(Boolean) : [".obsidian/**", "**/*.canvas", "**/*.png", "**/*.jpg", "**/*.jpeg", "**/*.gif", "**/*.pdf"],
582
- namespace: typeof vault.namespace === "string" && vault.namespace.trim().length > 0 ? vault.namespace.trim() : void 0,
583
- privacyClass: typeof vault.privacyClass === "string" && vault.privacyClass.trim().length > 0 ? vault.privacyClass.trim() : void 0,
584
- folderRules: Array.isArray(vault.folderRules) ? vault.folderRules.filter((value) => !!value && typeof value === "object" && !Array.isArray(value)).map((rule) => ({
585
- pathPrefix: typeof rule.pathPrefix === "string" && rule.pathPrefix.trim().length > 0 ? rule.pathPrefix.trim() : "",
586
- namespace: typeof rule.namespace === "string" && rule.namespace.trim().length > 0 ? rule.namespace.trim() : void 0,
587
- privacyClass: typeof rule.privacyClass === "string" && rule.privacyClass.trim().length > 0 ? rule.privacyClass.trim() : void 0
588
- })).filter((rule) => rule.pathPrefix.length > 0) : [],
589
- dailyNotePatterns: Array.isArray(vault.dailyNotePatterns) ? vault.dailyNotePatterns.filter((value) => typeof value === "string").map((value) => value.trim()).filter(Boolean) : ["YYYY-MM-DD"],
590
- materializeBacklinks: vault.materializeBacklinks === true
591
- };
592
- }).filter((vault) => vault.rootDir.length > 0) : []
593
- } : void 0;
594
- const rawAgentAccessHttp = cfg.agentAccessHttp && typeof cfg.agentAccessHttp === "object" && !Array.isArray(cfg.agentAccessHttp) ? cfg.agentAccessHttp : void 0;
595
- const agentAccessAuthToken = parseAgentAccessAuthToken(rawAgentAccessHttp?.authToken);
596
- const agentAccessHttp = {
597
- enabled: rawAgentAccessHttp?.enabled === true,
598
- host: typeof rawAgentAccessHttp?.host === "string" && rawAgentAccessHttp.host.trim().length > 0 ? rawAgentAccessHttp.host.trim() : "127.0.0.1",
599
- port: typeof rawAgentAccessHttp?.port === "number" ? Math.max(0, Math.floor(rawAgentAccessHttp.port)) : 4318,
600
- [["auth", "Token"].join("")]: agentAccessAuthToken,
601
- principal: typeof rawAgentAccessHttp?.principal === "string" && rawAgentAccessHttp.principal.trim().length > 0 ? resolveEnvVars(rawAgentAccessHttp.principal) : readEnvVar("OPENCLAW_ENGRAM_ACCESS_PRINCIPAL")?.trim() || void 0,
602
- maxBodyBytes: typeof rawAgentAccessHttp?.maxBodyBytes === "number" ? Math.max(1, Math.floor(rawAgentAccessHttp.maxBodyBytes)) : 131072
603
- };
604
- let baseUrl;
605
- if (typeof cfg.openaiBaseUrl === "string" && cfg.openaiBaseUrl.length > 0) {
606
- baseUrl = normalizeOpenaiBaseUrl(resolveEnvVars(cfg.openaiBaseUrl), "config");
607
- } else {
608
- baseUrl = normalizeOpenaiBaseUrl(readEnvVar("OPENAI_BASE_URL"), "env");
609
- }
610
- const sharedCrossSignalSemanticEnabled = cfg.sharedCrossSignalSemanticEnabled === true || cfg.crossSignalsSemanticEnabled === true;
611
- const sharedCrossSignalSemanticTimeoutMs = typeof cfg.sharedCrossSignalSemanticTimeoutMs === "number" ? Math.max(1, Math.floor(cfg.sharedCrossSignalSemanticTimeoutMs)) : typeof cfg.crossSignalsSemanticTimeoutMs === "number" ? Math.max(1, Math.floor(cfg.crossSignalsSemanticTimeoutMs)) : 4e3;
612
- const recallPipelineConfig = buildRecallPipelineConfig(cfg);
613
- return {
614
- openaiApiKey: apiKey,
615
- openaiBaseUrl: baseUrl,
616
- model,
617
- reasoningEffort,
618
- triggerMode,
619
- bufferMaxTurns: typeof cfg.bufferMaxTurns === "number" ? cfg.bufferMaxTurns : 5,
620
- bufferMaxMinutes: typeof cfg.bufferMaxMinutes === "number" ? cfg.bufferMaxMinutes : 15,
621
- // Surprise-gated buffer flush (issue #563, D-MEM). See types.ts for
622
- // semantics. Default off so PR 2 ships as a pure no-op until an operator
623
- // opts in. PR 4 benchmarks the flag and may flip the default.
624
- //
625
- // Use `coerceBool` rather than a strict `=== true` check: CLI operators
626
- // set booleans via `--config bufferSurpriseTriggerEnabled=true` which
627
- // arrives as the string `"true"` — the strict form would silently
628
- // leave the flag off. Matches the coercion contract established for
629
- // other boolean config keys (CLAUDE.md rule #36).
630
- bufferSurpriseTriggerEnabled: coerceBool(cfg.bufferSurpriseTriggerEnabled) === true,
631
- // Numeric surprise knobs go through `coerceNumber` so CLI operators
632
- // can pass `--config bufferSurpriseThreshold=0.5` without the string
633
- // silently dropping to the default. Matches the coercion contract
634
- // applied to other numeric config keys (CLAUDE.md rule #28).
635
- bufferSurpriseThreshold: clampSurpriseThreshold(
636
- coerceNumber(cfg.bufferSurpriseThreshold),
637
- 0.35
638
- ),
639
- bufferSurpriseK: clampSurpriseK(
640
- coerceNumber(cfg.bufferSurpriseK),
641
- 5
642
- ),
643
- bufferSurpriseRecentMemoryCount: clampSurpriseRecentMemoryCount(
644
- coerceNumber(cfg.bufferSurpriseRecentMemoryCount),
645
- 20
646
- ),
647
- bufferSurpriseProbeTimeoutMs: clampSurpriseProbeTimeoutMs(
648
- coerceNumber(cfg.bufferSurpriseProbeTimeoutMs),
649
- 2e3
650
- ),
651
- consolidateEveryN: typeof cfg.consolidateEveryN === "number" ? cfg.consolidateEveryN : 3,
652
- highSignalPatterns: Array.isArray(cfg.highSignalPatterns) ? cfg.highSignalPatterns : [],
653
- maxMemoryTokens: typeof cfg.maxMemoryTokens === "number" ? cfg.maxMemoryTokens : 2e3,
654
- memoryOsPreset,
655
- qmdEnabled: cfg.qmdEnabled !== false,
656
- qmdCollection: typeof cfg.qmdCollection === "string" ? cfg.qmdCollection : "openclaw-engram",
657
- qmdMaxResults: typeof cfg.qmdMaxResults === "number" ? cfg.qmdMaxResults : 8,
658
- qmdColdTierEnabled: cfg.qmdColdTierEnabled === true,
659
- qmdColdCollection: typeof cfg.qmdColdCollection === "string" && cfg.qmdColdCollection.length > 0 ? cfg.qmdColdCollection : "openclaw-engram-cold",
660
- qmdColdMaxResults: typeof cfg.qmdColdMaxResults === "number" ? cfg.qmdColdMaxResults : 8,
661
- // Issue #678 PR 2/4: gate hot/cold tier migration (a deep-sleep activity)
662
- // on dreams.phases.deepSleep.enabled. When deep sleep is disabled,
663
- // tier migration is forced off regardless of legacy flag.
664
- qmdTierMigrationEnabled: dreamsDeepSleep.enabled && cfg.qmdTierMigrationEnabled === true,
665
- qmdTierDemotionMinAgeDays: typeof cfg.qmdTierDemotionMinAgeDays === "number" ? Math.max(0, Math.floor(cfg.qmdTierDemotionMinAgeDays)) : 14,
666
- qmdTierDemotionValueThreshold: typeof cfg.qmdTierDemotionValueThreshold === "number" ? Math.max(0, Math.min(1, cfg.qmdTierDemotionValueThreshold)) : 0.35,
667
- qmdTierPromotionValueThreshold: typeof cfg.qmdTierPromotionValueThreshold === "number" ? Math.max(0, Math.min(1, cfg.qmdTierPromotionValueThreshold)) : 0.7,
668
- qmdTierParityGraphEnabled: cfg.qmdTierParityGraphEnabled !== false,
669
- qmdTierParityHiMemEnabled: cfg.qmdTierParityHiMemEnabled !== false,
670
- qmdTierAutoBackfillEnabled: cfg.qmdTierAutoBackfillEnabled === true,
671
- embeddingFallbackEnabled: cfg.embeddingFallbackEnabled !== false,
672
- embeddingFallbackProvider: cfg.embeddingFallbackProvider === "openai" ? "openai" : cfg.embeddingFallbackProvider === "local" ? "local" : "auto",
673
- qmdPath: typeof cfg.qmdPath === "string" && cfg.qmdPath.length > 0 ? cfg.qmdPath : void 0,
674
- memoryDir,
675
- debug: cfg.debug === true,
676
- identityEnabled: cfg.identityEnabled !== false,
677
- identityContinuityEnabled,
678
- identityInjectionMode,
679
- identityMaxInjectChars: typeof cfg.identityMaxInjectChars === "number" ? Math.max(0, Math.floor(cfg.identityMaxInjectChars)) : 1200,
680
- continuityIncidentLoggingEnabled: typeof cfg.continuityIncidentLoggingEnabled === "boolean" ? cfg.continuityIncidentLoggingEnabled : identityContinuityEnabled,
681
- continuityAuditEnabled: cfg.continuityAuditEnabled === true,
682
- sessionObserverEnabled: cfg.sessionObserverEnabled === true,
683
- sessionObserverDebounceMs: typeof cfg.sessionObserverDebounceMs === "number" ? Math.max(0, Math.floor(cfg.sessionObserverDebounceMs)) : 12e4,
684
- sessionObserverBands,
685
- injectQuestions: cfg.injectQuestions === true,
686
- commitmentDecayDays: typeof cfg.commitmentDecayDays === "number" ? cfg.commitmentDecayDays : 90,
687
- workspaceDir: typeof cfg.workspaceDir === "string" && cfg.workspaceDir.length > 0 ? cfg.workspaceDir : DEFAULT_WORKSPACE_DIR,
688
- captureMode,
689
- fileHygiene,
690
- nativeKnowledge,
691
- agentAccessHttp,
692
- // Access tracking (Phase 1A)
693
- accessTrackingEnabled: cfg.accessTrackingEnabled !== false,
694
- accessTrackingBufferMaxSize: typeof cfg.accessTrackingBufferMaxSize === "number" ? cfg.accessTrackingBufferMaxSize : 100,
695
- // Retrieval options
696
- recencyWeight: typeof cfg.recencyWeight === "number" ? cfg.recencyWeight : 0.2,
697
- boostAccessCount: cfg.boostAccessCount !== false,
698
- recordEmptyRecallImpressions: cfg.recordEmptyRecallImpressions === true,
699
- // v2.2 Advanced Retrieval (safe defaults: off unless enabled)
700
- queryExpansionEnabled: cfg.queryExpansionEnabled === true,
701
- queryExpansionMaxQueries: typeof cfg.queryExpansionMaxQueries === "number" ? cfg.queryExpansionMaxQueries : 4,
702
- queryExpansionMinTokenLen: typeof cfg.queryExpansionMinTokenLen === "number" ? cfg.queryExpansionMinTokenLen : 3,
703
- rerankEnabled: cfg.rerankEnabled === true,
704
- rerankProvider: cfg.rerankProvider === "cloud" ? "cloud" : "local",
705
- rerankMaxCandidates: typeof cfg.rerankMaxCandidates === "number" ? cfg.rerankMaxCandidates : 20,
706
- rerankTimeoutMs: typeof cfg.rerankTimeoutMs === "number" ? cfg.rerankTimeoutMs : 8e3,
707
- rerankCacheEnabled: cfg.rerankCacheEnabled !== false,
708
- rerankCacheTtlMs: typeof cfg.rerankCacheTtlMs === "number" ? cfg.rerankCacheTtlMs : 60 * 60 * 1e3,
709
- feedbackEnabled: cfg.feedbackEnabled === true,
710
- // v2.2 Negative Examples (safe defaults: off unless enabled)
711
- negativeExamplesEnabled: cfg.negativeExamplesEnabled === true,
712
- negativeExamplesPenaltyPerHit: typeof cfg.negativeExamplesPenaltyPerHit === "number" ? cfg.negativeExamplesPenaltyPerHit : 0.05,
713
- negativeExamplesPenaltyCap: typeof cfg.negativeExamplesPenaltyCap === "number" ? cfg.negativeExamplesPenaltyCap : 0.25,
714
- // Chunking (Phase 2A)
715
- chunkingEnabled: cfg.chunkingEnabled === true,
716
- // Off by default initially
717
- chunkingTargetTokens: typeof cfg.chunkingTargetTokens === "number" ? cfg.chunkingTargetTokens : 200,
718
- chunkingMinTokens: typeof cfg.chunkingMinTokens === "number" ? cfg.chunkingMinTokens : 150,
719
- chunkingOverlapSentences: typeof cfg.chunkingOverlapSentences === "number" ? cfg.chunkingOverlapSentences : 2,
720
- // Semantic Chunking (Issue #368)
721
- semanticChunkingEnabled: cfg.semanticChunkingEnabled === true,
722
- semanticChunkingConfig: parseSemanticChunkingConfig(cfg.semanticChunkingConfig),
723
- // Contradiction Detection (Phase 2B)
724
- contradictionDetectionEnabled: cfg.contradictionDetectionEnabled === true,
725
- // Off by default initially
726
- contradictionSimilarityThreshold: typeof cfg.contradictionSimilarityThreshold === "number" ? cfg.contradictionSimilarityThreshold : 0.7,
727
- contradictionMinConfidence: typeof cfg.contradictionMinConfidence === "number" ? cfg.contradictionMinConfidence : 0.9,
728
- contradictionAutoResolve: cfg.contradictionAutoResolve !== false,
729
- // Contradiction Scan cron (issue #520)
730
- contradictionScan: parseContradictionScanConfig(cfg.contradictionScan),
731
- // Temporal Supersession (issue #375)
732
- temporalSupersessionEnabled: cfg.temporalSupersessionEnabled !== false,
733
- // On by default
734
- temporalSupersessionIncludeInRecall: cfg.temporalSupersessionIncludeInRecall === true,
735
- // Off by default
736
- // Direct-answer retrieval tier (issue #518). Default on — the
737
- // tier runs in observation mode: it annotates
738
- // LastRecallSnapshot.tierExplain but never short-circuits the
739
- // QMD path. Operators can opt out with
740
- // recallDirectAnswerEnabled=false.
741
- recallDirectAnswerEnabled: coerceBool(cfg.recallDirectAnswerEnabled) ?? true,
742
- // Disclosure auto-escalation (issue #677 PR 4/4). Default `manual`
743
- // so pre-#677 callers see unchanged behavior. Reject anything
744
- // outside the allow-list rather than silently defaulting (CLAUDE.md
745
- // rule 51).
746
- recallDisclosureEscalation: (() => {
747
- const raw2 = cfg.recallDisclosureEscalation;
748
- if (raw2 === void 0 || raw2 === null) return "manual";
749
- if (raw2 === "manual" || raw2 === "auto") return raw2;
750
- throw new Error(
751
- `recallDisclosureEscalation must be "manual" or "auto" (got ${JSON.stringify(raw2)}).`
752
- );
753
- })(),
754
- recallDisclosureEscalationThreshold: (() => {
755
- const n = coerceNumber(cfg.recallDisclosureEscalationThreshold);
756
- return n !== void 0 && n >= 0 && n <= 1 ? n : 0.5;
757
- })(),
758
- // Graph-based retrieval tier (issue #559 PR 4). Default `false` —
759
- // the tier ships off pending the `retrieval-graph` bench in PR 5.
760
- recallGraphEnabled: coerceBool(cfg.recallGraphEnabled) ?? false,
761
- recallGraphDamping: (() => {
762
- const n = coerceNumber(cfg.recallGraphDamping);
763
- return n !== void 0 && n >= 0 && n < 1 ? n : 0.85;
764
- })(),
765
- // Fractional integer values (e.g. `0.5`) are REJECTED rather than
766
- // silently floored to zero — CLAUDE.md rule 51 ("Reject invalid
767
- // user input instead of silently defaulting"). Users who set a
768
- // fractional iteration cap almost certainly meant an integer and
769
- // quietly flooring their value to 0 turns off the tier without
770
- // warning.
771
- recallGraphIterations: (() => {
772
- if (cfg.recallGraphIterations === void 0) return 20;
773
- const n = coerceNumber(cfg.recallGraphIterations);
774
- if (n === void 0 || !Number.isFinite(n) || n < 0 || n > 500) {
775
- throw new Error(
776
- `recallGraphIterations must be an integer in [0, 500] (got ${JSON.stringify(cfg.recallGraphIterations)}).`
777
- );
778
- }
779
- if (!Number.isInteger(n)) {
780
- throw new Error(
781
- `recallGraphIterations must be an integer (got fractional value ${n}).`
782
- );
783
- }
784
- return n;
785
- })(),
786
- recallGraphTopK: (() => {
787
- if (cfg.recallGraphTopK === void 0) return 50;
788
- const n = coerceNumber(cfg.recallGraphTopK);
789
- if (n === void 0 || !Number.isFinite(n) || n < 0 || n > 1e4) {
790
- throw new Error(
791
- `recallGraphTopK must be an integer in [0, 10000] (got ${JSON.stringify(cfg.recallGraphTopK)}).`
792
- );
793
- }
794
- if (!Number.isInteger(n)) {
795
- throw new Error(
796
- `recallGraphTopK must be an integer (got fractional value ${n}).`
797
- );
798
- }
799
- return n;
800
- })(),
801
- recallDirectAnswerTokenOverlapFloor: (() => {
802
- const n = coerceNumber(cfg.recallDirectAnswerTokenOverlapFloor);
803
- return n !== void 0 && n >= 0 && n <= 1 ? n : 0.55;
804
- })(),
805
- recallDirectAnswerImportanceFloor: (() => {
806
- const n = coerceNumber(cfg.recallDirectAnswerImportanceFloor);
807
- return n !== void 0 && n >= 0 && n <= 1 ? n : 0.7;
808
- })(),
809
- recallDirectAnswerAmbiguityMargin: (() => {
810
- const n = coerceNumber(cfg.recallDirectAnswerAmbiguityMargin);
811
- return n !== void 0 && n >= 0 && n <= 1 ? n : 0.15;
812
- })(),
813
- recallDirectAnswerEligibleTaxonomyBuckets: Array.isArray(
814
- cfg.recallDirectAnswerEligibleTaxonomyBuckets
815
- ) ? cfg.recallDirectAnswerEligibleTaxonomyBuckets.filter(
816
- (v) => typeof v === "string" && v.length > 0
817
- ) : ["decisions", "principles", "conventions", "runbooks", "entities"],
818
- // Cross-namespace query-budget limiter (issue #565 PR 4/5).
819
- // Defaults to false — ships disabled so existing deployments are
820
- // unaffected. When enabled, the read path throttles a principal that
821
- // issues a burst of recalls against namespaces other than their own.
822
- recallCrossNamespaceBudgetEnabled: coerceBool(cfg.recallCrossNamespaceBudgetEnabled) ?? false,
823
- recallCrossNamespaceBudgetWindowMs: (() => {
824
- const n = coerceNumber(cfg.recallCrossNamespaceBudgetWindowMs);
825
- return n !== void 0 && n > 0 ? Math.floor(n) : 6e4;
826
- })(),
827
- recallCrossNamespaceBudgetSoftLimit: (() => {
828
- const n = coerceNumber(cfg.recallCrossNamespaceBudgetSoftLimit);
829
- return n !== void 0 && n >= 0 ? Math.floor(n) : 10;
830
- })(),
831
- recallCrossNamespaceBudgetHardLimit: (() => {
832
- const n = coerceNumber(cfg.recallCrossNamespaceBudgetHardLimit);
833
- return n !== void 0 && n > 0 ? Math.floor(n) : 30;
834
- })(),
835
- // Recall-audit anomaly detector (issue #565 PR 5/5). Defaults off so
836
- // existing deployments are unaffected; enable explicitly to let the
837
- // access surfaces flag suspicious query patterns derived from the
838
- // audit trail. Thresholds floor AFTER validating the floored value
839
- // is still >= 1 — a `0.5` input that floors to 0 would turn every
840
- // detector into a flood-on-anything, flipping the default to
841
- // max-noise instead of max-silence.
842
- recallAuditAnomalyDetectionEnabled: coerceBool(cfg.recallAuditAnomalyDetectionEnabled) ?? false,
843
- recallAuditAnomalyWindowMs: (() => {
844
- const n = coerceNumber(cfg.recallAuditAnomalyWindowMs);
845
- if (n === void 0) return 5 * 6e4;
846
- const floored = Math.floor(n);
847
- return floored >= 1 ? floored : 5 * 6e4;
848
- })(),
849
- recallAuditAnomalyRepeatQueryLimit: (() => {
850
- const n = coerceNumber(cfg.recallAuditAnomalyRepeatQueryLimit);
851
- if (n === void 0) return 5;
852
- const floored = Math.floor(n);
853
- return floored >= 1 ? floored : 5;
854
- })(),
855
- recallAuditAnomalyNamespaceWalkLimit: (() => {
856
- const n = coerceNumber(cfg.recallAuditAnomalyNamespaceWalkLimit);
857
- if (n === void 0) return 3;
858
- const floored = Math.floor(n);
859
- return floored >= 1 ? floored : 3;
860
- })(),
861
- recallAuditAnomalyHighCardinalityLimit: (() => {
862
- const n = coerceNumber(cfg.recallAuditAnomalyHighCardinalityLimit);
863
- if (n === void 0) return 50;
864
- const floored = Math.floor(n);
865
- return floored >= 1 ? floored : 50;
866
- })(),
867
- recallAuditAnomalyRapidFireLimit: (() => {
868
- const n = coerceNumber(cfg.recallAuditAnomalyRapidFireLimit);
869
- if (n === void 0) return 30;
870
- const floored = Math.floor(n);
871
- return floored >= 1 ? floored : 30;
872
- })(),
873
- // Memory Worth recall filter (issue #560 PR 4, default flipped in PR 5).
874
- // Bench result on the seeded fixture: precision@5 lifts from 0.00 to
875
- // 0.60 across all 50 cases with zero regressions. See
876
- // `runMemoryWorthBench` in memory-worth-bench.ts. Operators can still
877
- // opt out with recallMemoryWorthFilterEnabled=false.
878
- recallMemoryWorthFilterEnabled: coerceBool(cfg.recallMemoryWorthFilterEnabled) ?? true,
879
- recallMemoryWorthHalfLifeMs: (() => {
880
- const n = coerceNumber(cfg.recallMemoryWorthHalfLifeMs);
881
- return n !== void 0 && n >= 0 ? n : 0;
882
- })(),
883
- // Memory Linking (Phase 3A)
884
- memoryLinkingEnabled: cfg.memoryLinkingEnabled === true,
885
- // Off by default initially
886
- // Conversation Threading (Phase 3B)
887
- threadingEnabled: cfg.threadingEnabled === true,
888
- // Off by default initially
889
- threadingGapMinutes: typeof cfg.threadingGapMinutes === "number" ? cfg.threadingGapMinutes : 30,
890
- // Memory Summarization (Phase 4A)
891
- summarizationEnabled: cfg.summarizationEnabled === true,
892
- // Off by default
893
- summarizationTriggerCount: typeof cfg.summarizationTriggerCount === "number" ? cfg.summarizationTriggerCount : 1e3,
894
- summarizationRecentToKeep: typeof cfg.summarizationRecentToKeep === "number" ? cfg.summarizationRecentToKeep : 300,
895
- summarizationImportanceThreshold: typeof cfg.summarizationImportanceThreshold === "number" ? cfg.summarizationImportanceThreshold : 0.3,
896
- summarizationProtectedTags: Array.isArray(cfg.summarizationProtectedTags) ? cfg.summarizationProtectedTags : ["commitment", "preference", "decision", "principle"],
897
- // Topic Extraction (Phase 4B)
898
- topicExtractionEnabled: cfg.topicExtractionEnabled !== false,
899
- // On by default
900
- topicExtractionTopN: typeof cfg.topicExtractionTopN === "number" ? cfg.topicExtractionTopN : 50,
901
- // Transcript & Context Preservation (v2.0)
902
- // Transcript archive
903
- transcriptEnabled: cfg.transcriptEnabled !== false,
904
- // default: true
905
- transcriptRetentionDays: typeof cfg.transcriptRetentionDays === "number" ? cfg.transcriptRetentionDays : 7,
906
- transcriptSkipChannelTypes: Array.isArray(cfg.transcriptSkipChannelTypes) ? cfg.transcriptSkipChannelTypes : ["cron"],
907
- // default: skip cron transcripts
908
- // Transcript injection
909
- transcriptRecallHours: typeof cfg.transcriptRecallHours === "number" ? cfg.transcriptRecallHours : 12,
910
- maxTranscriptTurns: typeof cfg.maxTranscriptTurns === "number" ? cfg.maxTranscriptTurns : 50,
911
- maxTranscriptTokens: typeof cfg.maxTranscriptTokens === "number" ? cfg.maxTranscriptTokens : 1e3,
912
- // Checkpoint
913
- checkpointEnabled: cfg.checkpointEnabled !== false,
914
- // default: true
915
- checkpointTurns: typeof cfg.checkpointTurns === "number" ? cfg.checkpointTurns : 15,
916
- // Compaction reset (opt-in, default: false)
917
- compactionResetEnabled: cfg.compactionResetEnabled === true,
918
- beforeResetTimeoutMs: typeof cfg.beforeResetTimeoutMs === "number" ? Math.min(3e4, Math.max(100, Math.floor(cfg.beforeResetTimeoutMs))) : 2e3,
919
- initGateTimeoutMs: parseBoundedIntegerMs(
920
- cfg.initGateTimeoutMs,
921
- DEFAULT_INIT_GATE_TIMEOUT_MS,
922
- 1e3,
923
- 12e4
924
- ),
925
- flushOnResetEnabled: cfg.flushOnResetEnabled !== false,
926
- commandsListEnabled: cfg.commandsListEnabled !== false,
927
- openclawToolsEnabled: cfg.openclawToolsEnabled !== false,
928
- openclawToolSnippetMaxChars: typeof cfg.openclawToolSnippetMaxChars === "number" ? Math.min(4e3, Math.max(80, Math.floor(cfg.openclawToolSnippetMaxChars))) : 600,
929
- sessionTogglesEnabled: cfg.sessionTogglesEnabled !== false,
930
- verboseRecallVisibility: cfg.verboseRecallVisibility !== false,
931
- recallTranscriptsEnabled: cfg.recallTranscriptsEnabled === true,
932
- recallTranscriptRetentionDays: typeof cfg.recallTranscriptRetentionDays === "number" ? Math.min(365, Math.max(1, Math.floor(cfg.recallTranscriptRetentionDays))) : 30,
933
- respectBundledActiveMemoryToggle: cfg.respectBundledActiveMemoryToggle !== false,
934
- activeRecallEnabled: cfg.activeRecallEnabled === true,
935
- activeRecallAgents: Array.isArray(cfg.activeRecallAgents) && cfg.activeRecallAgents.length > 0 ? cfg.activeRecallAgents.filter((value) => typeof value === "string" && value.trim().length > 0).map((value) => value.trim()) : null,
936
- activeRecallAllowedChatTypes: Array.isArray(cfg.activeRecallAllowedChatTypes) && cfg.activeRecallAllowedChatTypes.length > 0 ? cfg.activeRecallAllowedChatTypes.filter(
937
- (value) => value === "direct" || value === "group" || value === "channel"
938
- ) : ["direct", "group", "channel"],
939
- activeRecallQueryMode: cfg.activeRecallQueryMode === "message" || cfg.activeRecallQueryMode === "full" ? cfg.activeRecallQueryMode : "recent",
940
- activeRecallPromptStyle: cfg.activeRecallPromptStyle === "strict" || cfg.activeRecallPromptStyle === "contextual" || cfg.activeRecallPromptStyle === "recall-heavy" || cfg.activeRecallPromptStyle === "precision-heavy" || cfg.activeRecallPromptStyle === "preference-only" ? cfg.activeRecallPromptStyle : "balanced",
941
- activeRecallCustomInstruction: (() => {
942
- const customInstruction = typeof cfg.activeRecallCustomInstruction === "string" ? cfg.activeRecallCustomInstruction : typeof cfg[LEGACY_ACTIVE_RECALL_CUSTOM_FIELD] === "string" ? cfg[LEGACY_ACTIVE_RECALL_CUSTOM_FIELD] : "";
943
- return customInstruction.trim().length > 0 ? customInstruction.trim() : null;
944
- })(),
945
- activeRecallPromptAppend: typeof cfg.activeRecallPromptAppend === "string" && cfg.activeRecallPromptAppend.trim().length > 0 ? cfg.activeRecallPromptAppend.trim() : null,
946
- activeRecallMaxSummaryChars: typeof cfg.activeRecallMaxSummaryChars === "number" ? Math.min(1e3, Math.max(40, Math.floor(cfg.activeRecallMaxSummaryChars))) : 220,
947
- activeRecallRecentUserTurns: typeof cfg.activeRecallRecentUserTurns === "number" ? Math.min(4, Math.max(0, Math.floor(cfg.activeRecallRecentUserTurns))) : 2,
948
- activeRecallRecentAssistantTurns: typeof cfg.activeRecallRecentAssistantTurns === "number" ? Math.min(3, Math.max(0, Math.floor(cfg.activeRecallRecentAssistantTurns))) : 1,
949
- activeRecallRecentUserChars: typeof cfg.activeRecallRecentUserChars === "number" ? Math.min(1e3, Math.max(40, Math.floor(cfg.activeRecallRecentUserChars))) : 600,
950
- activeRecallRecentAssistantChars: typeof cfg.activeRecallRecentAssistantChars === "number" ? Math.min(1e3, Math.max(40, Math.floor(cfg.activeRecallRecentAssistantChars))) : 400,
951
- activeRecallThinking: cfg.activeRecallThinking === "low" || cfg.activeRecallThinking === "off" || cfg.activeRecallThinking === "minimal" || cfg.activeRecallThinking === "medium" || cfg.activeRecallThinking === "high" || cfg.activeRecallThinking === "xhigh" || cfg.activeRecallThinking === "adaptive" ? cfg.activeRecallThinking : "low",
952
- activeRecallTimeoutMs: typeof cfg.activeRecallTimeoutMs === "number" ? Math.max(250, Math.floor(cfg.activeRecallTimeoutMs)) : 15e3,
953
- activeRecallCacheTtlMs: typeof cfg.activeRecallCacheTtlMs === "number" ? cfg.activeRecallCacheTtlMs === 0 ? 0 : cfg.activeRecallCacheTtlMs < 0 ? 15e3 : Math.min(
954
- 12e4,
955
- Math.max(1, Math.floor(cfg.activeRecallCacheTtlMs))
956
- ) : 15e3,
957
- activeRecallModel: typeof cfg.activeRecallModel === "string" && cfg.activeRecallModel.trim().length > 0 ? cfg.activeRecallModel.trim() : null,
958
- activeRecallModelFallbackPolicy: cfg.activeRecallModelFallbackPolicy === "resolved-only" ? "resolved-only" : "default-remote",
959
- activeRecallPersistTranscripts: cfg.activeRecallPersistTranscripts === true,
960
- activeRecallTranscriptDir: typeof cfg.activeRecallTranscriptDir === "string" && cfg.activeRecallTranscriptDir.trim().length > 0 ? cfg.activeRecallTranscriptDir.trim() : "active-recall",
961
- activeRecallEntityGraphDepth: typeof cfg.activeRecallEntityGraphDepth === "number" ? Math.min(3, Math.max(0, Math.floor(cfg.activeRecallEntityGraphDepth))) : 1,
962
- activeRecallIncludeCausalTrajectories: cfg.activeRecallIncludeCausalTrajectories === true,
963
- activeRecallIncludeDaySummary: cfg.activeRecallIncludeDaySummary === true,
964
- activeRecallAttachRecallExplain: cfg.activeRecallAttachRecallExplain === true,
965
- activeRecallAllowChainedActiveMemory: cfg.activeRecallAllowChainedActiveMemory === true,
966
- dreaming,
967
- dreamsPhases,
968
- procedural,
969
- // At-rest encryption (issue #690 PR 3/4)
970
- // coerceBool handles CLI string inputs: `--config secureStoreEnabled=true`
971
- // arrives as the string "true" which `=== true` would reject (CLAUDE.md #36).
972
- secureStoreEnabled: coerceBool(cfg.secureStoreEnabled) === true,
973
- secureStoreEncryptOnWrite: coerceBool(cfg.secureStoreEncryptOnWrite) !== false,
974
- // default: true
975
- codingMode,
976
- heartbeat,
977
- slotBehavior,
978
- codexCompat,
979
- // Hourly summaries
980
- hourlySummariesEnabled: cfg.hourlySummariesEnabled !== false,
981
- // default: true
982
- daySummaryEnabled: cfg.daySummaryEnabled !== false,
983
- // default: true
984
- hourlySummaryCronAutoRegister: cfg.hourlySummaryCronAutoRegister === true,
985
- // Codex P1 on PR 763 round 2: gate the nightly-governance cron
986
- // (deep-sleep's primary scheduled execution path) on
987
- // dreams.phases.deepSleep.enabled. When the phase is disabled the
988
- // cron must NOT auto-register, otherwise `deepSleep.enabled=false`
989
- // is a contract lie — deep-sleep keeps running.
990
- nightlyGovernanceCronAutoRegister: dreamsDeepSleep.enabled && cfg.nightlyGovernanceCronAutoRegister === true,
991
- summaryRecallHours: typeof cfg.summaryRecallHours === "number" ? cfg.summaryRecallHours : 24,
992
- maxSummaryCount: typeof cfg.maxSummaryCount === "number" ? cfg.maxSummaryCount : 6,
993
- summaryModel: typeof cfg.summaryModel === "string" && cfg.summaryModel.length > 0 ? cfg.summaryModel : model,
994
- // default: same as extraction model
995
- // v2.4 Extended hourly summaries (default off)
996
- hourlySummariesExtendedEnabled: cfg.hourlySummariesExtendedEnabled === true,
997
- hourlySummariesIncludeToolStats: cfg.hourlySummariesIncludeToolStats === true,
998
- hourlySummariesIncludeSystemMessages: cfg.hourlySummariesIncludeSystemMessages === true,
999
- hourlySummariesMaxTurnsPerRun: typeof cfg.hourlySummariesMaxTurnsPerRun === "number" ? cfg.hourlySummariesMaxTurnsPerRun : 200,
1000
- // v2.4 Conversation index (default off)
1001
- conversationIndexEnabled: cfg.conversationIndexEnabled === true,
1002
- conversationIndexBackend: cfg.conversationIndexBackend === "faiss" ? "faiss" : "qmd",
1003
- conversationIndexQmdCollection: typeof cfg.conversationIndexQmdCollection === "string" && cfg.conversationIndexQmdCollection.length > 0 ? cfg.conversationIndexQmdCollection : "openclaw-engram-conversations",
1004
- conversationIndexRetentionDays: typeof cfg.conversationIndexRetentionDays === "number" ? cfg.conversationIndexRetentionDays : 30,
1005
- conversationIndexMinUpdateIntervalMs: typeof cfg.conversationIndexMinUpdateIntervalMs === "number" ? cfg.conversationIndexMinUpdateIntervalMs : 15 * 6e4,
1006
- conversationIndexEmbedOnUpdate: cfg.conversationIndexEmbedOnUpdate === true,
1007
- conversationIndexFaissScriptPath: typeof cfg.conversationIndexFaissScriptPath === "string" && cfg.conversationIndexFaissScriptPath.trim().length > 0 ? cfg.conversationIndexFaissScriptPath.trim() : void 0,
1008
- conversationIndexFaissPythonBin: typeof cfg.conversationIndexFaissPythonBin === "string" && cfg.conversationIndexFaissPythonBin.trim().length > 0 ? cfg.conversationIndexFaissPythonBin.trim() : void 0,
1009
- conversationIndexFaissModelId: typeof cfg.conversationIndexFaissModelId === "string" && cfg.conversationIndexFaissModelId.trim().length > 0 ? cfg.conversationIndexFaissModelId.trim() : "text-embedding-3-small",
1010
- conversationIndexFaissIndexDir: typeof cfg.conversationIndexFaissIndexDir === "string" && cfg.conversationIndexFaissIndexDir.trim().length > 0 ? cfg.conversationIndexFaissIndexDir.trim() : "state/conversation-index/faiss",
1011
- conversationIndexFaissUpsertTimeoutMs: typeof cfg.conversationIndexFaissUpsertTimeoutMs === "number" ? Math.max(0, Math.floor(cfg.conversationIndexFaissUpsertTimeoutMs)) : 3e4,
1012
- conversationIndexFaissSearchTimeoutMs: typeof cfg.conversationIndexFaissSearchTimeoutMs === "number" ? Math.max(0, Math.floor(cfg.conversationIndexFaissSearchTimeoutMs)) : 5e3,
1013
- conversationIndexFaissHealthTimeoutMs: typeof cfg.conversationIndexFaissHealthTimeoutMs === "number" ? Math.max(0, Math.floor(cfg.conversationIndexFaissHealthTimeoutMs)) : 2e3,
1014
- conversationIndexFaissMaxBatchSize: typeof cfg.conversationIndexFaissMaxBatchSize === "number" ? Math.max(0, Math.floor(cfg.conversationIndexFaissMaxBatchSize)) : 512,
1015
- conversationIndexFaissMaxSearchK: typeof cfg.conversationIndexFaissMaxSearchK === "number" ? Math.max(0, Math.floor(cfg.conversationIndexFaissMaxSearchK)) : 50,
1016
- conversationRecallTopK: typeof cfg.conversationRecallTopK === "number" ? cfg.conversationRecallTopK : 3,
1017
- conversationRecallMaxChars: typeof cfg.conversationRecallMaxChars === "number" ? cfg.conversationRecallMaxChars : 2500,
1018
- conversationRecallTimeoutMs: typeof cfg.conversationRecallTimeoutMs === "number" ? cfg.conversationRecallTimeoutMs : 800,
1019
- evalHarnessEnabled: cfg.evalHarnessEnabled === true,
1020
- evalShadowModeEnabled: cfg.evalShadowModeEnabled === true,
1021
- benchmarkBaselineSnapshotsEnabled: cfg.benchmarkBaselineSnapshotsEnabled === true,
1022
- benchmarkDeltaReporterEnabled: cfg.benchmarkDeltaReporterEnabled === true,
1023
- benchmarkStoredBaselineEnabled: cfg.benchmarkStoredBaselineEnabled === true,
1024
- evalStoreDir: typeof cfg.evalStoreDir === "string" && cfg.evalStoreDir.trim().length > 0 ? cfg.evalStoreDir.trim() : path.join(memoryDir, "state", "evals"),
1025
- objectiveStateMemoryEnabled: cfg.objectiveStateMemoryEnabled === true,
1026
- objectiveStateSnapshotWritesEnabled: cfg.objectiveStateSnapshotWritesEnabled === true,
1027
- objectiveStateRecallEnabled: cfg.objectiveStateRecallEnabled === true,
1028
- objectiveStateStoreDir: typeof cfg.objectiveStateStoreDir === "string" && cfg.objectiveStateStoreDir.trim().length > 0 ? cfg.objectiveStateStoreDir.trim() : path.join(memoryDir, "state", "objective-state"),
1029
- causalTrajectoryMemoryEnabled: cfg.causalTrajectoryMemoryEnabled === true,
1030
- causalTrajectoryStoreDir: typeof cfg.causalTrajectoryStoreDir === "string" && cfg.causalTrajectoryStoreDir.trim().length > 0 ? cfg.causalTrajectoryStoreDir.trim() : path.join(memoryDir, "state", "causal-trajectories"),
1031
- causalTrajectoryRecallEnabled: cfg.causalTrajectoryRecallEnabled === true,
1032
- actionGraphRecallEnabled: cfg.actionGraphRecallEnabled === true,
1033
- trustZonesEnabled: cfg.trustZonesEnabled === true,
1034
- quarantinePromotionEnabled: cfg.quarantinePromotionEnabled === true,
1035
- trustZoneStoreDir: typeof cfg.trustZoneStoreDir === "string" && cfg.trustZoneStoreDir.trim().length > 0 ? cfg.trustZoneStoreDir.trim() : path.join(memoryDir, "state", "trust-zones"),
1036
- trustZoneRecallEnabled: cfg.trustZoneRecallEnabled === true,
1037
- memoryPoisoningDefenseEnabled: cfg.memoryPoisoningDefenseEnabled === true,
1038
- memoryRedTeamBenchEnabled: cfg.memoryRedTeamBenchEnabled === true,
1039
- harmonicRetrievalEnabled: cfg.harmonicRetrievalEnabled === true,
1040
- abstractionAnchorsEnabled: cfg.abstractionAnchorsEnabled === true,
1041
- verifiedRecallEnabled: cfg.verifiedRecallEnabled === true,
1042
- semanticRulePromotionEnabled: cfg.semanticRulePromotionEnabled === true,
1043
- semanticRuleVerificationEnabled: cfg.semanticRuleVerificationEnabled === true,
1044
- // Issue #678 PR 2/4: when `dreams.phases.rem.*` is set, the resolved
1045
- // dreamsPhases value WINS over the legacy top-level key. The runtime
1046
- // gates (orchestrator's `runSemanticConsolidation`) read these legacy
1047
- // fields, so we must propagate the precedence here, not just in the
1048
- // `dreamsPhases` object.
1049
- semanticConsolidationEnabled: dreamsRem.enabled && dreamsRem.cadenceMs > 0,
1050
- semanticConsolidationModel: typeof cfg.semanticConsolidationModel === "string" && cfg.semanticConsolidationModel.length > 0 ? cfg.semanticConsolidationModel : "auto",
1051
- semanticConsolidationThreshold: dreamsRem.similarityThreshold,
1052
- semanticConsolidationMinClusterSize: dreamsRem.minClusterSize,
1053
- semanticConsolidationExcludeCategories: Array.isArray(cfg.semanticConsolidationExcludeCategories) ? cfg.semanticConsolidationExcludeCategories.filter(
1054
- (c) => typeof c === "string" && c.length > 0
1055
- ) : ["correction", "commitment", "procedure"],
1056
- // semanticConsolidationIntervalHours is derived from dreamsRem.cadenceMs
1057
- // when an override is set (rounded up to the nearest hour). Preserve
1058
- // explicit zero so legacy schedulers see the same disable-by-zero signal
1059
- // as the dreams.phases.rem config; the runtime enabled flag is also
1060
- // disabled above so zero does not mean "run every maintenance cycle".
1061
- semanticConsolidationIntervalHours: rawDreamsRem.cadenceMs !== void 0 ? Math.max(0, Math.ceil(dreamsRem.cadenceMs / 36e5)) : legacySemanticConsolidationIntervalHours,
1062
- semanticConsolidationMaxPerRun: dreamsRem.maxPerRun,
1063
- // Operator-aware consolidation prompt (issue #561 PR 3). Defaults
1064
- // to `false` to match sibling `*Enabled` flags' least-privileged
1065
- // convention. Operators opt in by setting `true` (or truthy
1066
- // coercions like "true", "1", "yes", "on") when they want the
1067
- // consolidation LLM to emit SPLIT/MERGE/UPDATE operator selection
1068
- // on the `derived_via` frontmatter field. Uses `coerceBool` per
1069
- // Gotcha #36 so CLI / env-string inputs coerce correctly. When
1070
- // disabled, `derived_via` is still populated via the cluster-shape
1071
- // heuristic (chooseConsolidationOperator) so PR 2's provenance
1072
- // wiring keeps working without operator-aware prompts.
1073
- operatorAwareConsolidationEnabled: coerceBool(cfg.operatorAwareConsolidationEnabled) ?? false,
1074
- // Pattern reinforcement (issue #687 PR 2/4). Defaults: off, weekly
1075
- // cadence, min cluster size 3, target categories preference / fact
1076
- // / decision. All bounds clamped at parse time so invalid inputs
1077
- // (negative numbers, non-arrays, non-strings) fail safe to defaults
1078
- // rather than crash the job.
1079
- patternReinforcementEnabled: coerceBool(cfg.patternReinforcementEnabled) ?? false,
1080
- patternReinforcementCadenceMs: (() => {
1081
- const raw2 = coerceNumber(cfg.patternReinforcementCadenceMs);
1082
- if (raw2 === void 0 || !Number.isFinite(raw2)) {
1083
- return 7 * 24 * 60 * 60 * 1e3;
1084
- }
1085
- return Math.max(0, Math.floor(raw2));
1086
- })(),
1087
- patternReinforcementMinCount: (() => {
1088
- const raw2 = coerceNumber(cfg.patternReinforcementMinCount);
1089
- if (raw2 === void 0 || !Number.isFinite(raw2)) return 3;
1090
- return Math.min(1e3, Math.max(2, Math.floor(raw2)));
1091
- })(),
1092
- patternReinforcementCategories: Array.isArray(cfg.patternReinforcementCategories) ? cfg.patternReinforcementCategories.filter((v) => typeof v === "string").map((v) => v.trim()).filter((v) => v.length > 0) : ["preference", "fact", "decision"],
1093
- // issue #687 PR 3/4: reinforcement recall boost config.
1094
- reinforcementRecallBoostEnabled: coerceBool(cfg.reinforcementRecallBoostEnabled) ?? false,
1095
- reinforcementRecallBoostWeight: (() => {
1096
- if (cfg.reinforcementRecallBoostWeight === void 0) return 0.05;
1097
- const n = coerceNumber(cfg.reinforcementRecallBoostWeight);
1098
- if (n === void 0 || !Number.isFinite(n) || n < 0 || n > 1) {
1099
- throw new Error(
1100
- `reinforcementRecallBoostWeight must be a number in [0, 1] (got ${JSON.stringify(cfg.reinforcementRecallBoostWeight)}).`
1101
- );
1102
- }
1103
- return n;
1104
- })(),
1105
- reinforcementRecallBoostMax: (() => {
1106
- if (cfg.reinforcementRecallBoostMax === void 0) return 0.3;
1107
- const n = coerceNumber(cfg.reinforcementRecallBoostMax);
1108
- if (n === void 0 || !Number.isFinite(n) || n < 0 || n > 1) {
1109
- throw new Error(
1110
- `reinforcementRecallBoostMax must be a number in [0, 1] (got ${JSON.stringify(cfg.reinforcementRecallBoostMax)}).`
1111
- );
1112
- }
1113
- return n;
1114
- })(),
1115
- // Async peer profile reasoner (issue #679 PR 2/5). Defaults to
1116
- // `false` (opt-in) per Gotchas #30/#48 — least-privileged default.
1117
- // `coerceBool` handles "true"/"1"/"yes"/"on" CLI strings (Gotcha
1118
- // #36). Numeric thresholds clamp at zero (Gotcha #28 + #45 — 0
1119
- // is a documented disable value for both, so the schema minimum
1120
- // matches and we do NOT silently bump to 1).
1121
- peerProfileReasonerEnabled: coerceBool(cfg.peerProfileReasonerEnabled) ?? false,
1122
- // Cursor M on PR #736: use the routing alias `"auto"` rather than
1123
- // a hardcoded model identifier. Matches the convention established
1124
- // by sibling `semanticConsolidationModel`. Operators can still
1125
- // override via config; the value is logged for telemetry only.
1126
- peerProfileReasonerModel: typeof cfg.peerProfileReasonerModel === "string" && cfg.peerProfileReasonerModel.trim().length > 0 ? cfg.peerProfileReasonerModel.trim() : "auto",
1127
- // Cursor L on PR #736: numeric config keys must coerce string CLI
1128
- // values (Gotcha #28 — `--config peerProfileReasonerMaxFieldsPerRun=2`
1129
- // arrives as the string "2"). Pre-fix `typeof === "number"`
1130
- // rejected string inputs and silently fell back to defaults. The
1131
- // shared `coerceNonNegativeInt` helper accepts both forms, throws
1132
- // on invalid input (Gotcha #51 — reject rather than silently
1133
- // default), and falls back to the documented default when the
1134
- // key is absent. 0 is a valid documented disable value here, so
1135
- // the helper does NOT bump to 1.
1136
- peerProfileReasonerMinInteractions: coerceNonNegativeInt(
1137
- cfg.peerProfileReasonerMinInteractions,
1138
- 5,
1139
- "peerProfileReasonerMinInteractions"
1140
- ),
1141
- peerProfileReasonerMaxFieldsPerRun: coerceNonNegativeInt(
1142
- cfg.peerProfileReasonerMaxFieldsPerRun,
1143
- 8,
1144
- "peerProfileReasonerMaxFieldsPerRun"
1145
- ),
1146
- // Peer profile recall injection (issue #679 PR 3/5). Default-off
1147
- // per Gotcha #30/#48 (least-privileged default, new feature gate).
1148
- // `coerceBool` handles CLI string forms "true"/"1"/"yes"/"on"
1149
- // (Gotcha #36). `coerceNonNegativeInt` handles string CLI values
1150
- // (Gotcha #28) and documents 0 as the disable value (Gotcha #45 —
1151
- // schema minimum must also be 0 so they stay consistent).
1152
- peerProfileRecallEnabled: coerceBool(cfg.peerProfileRecallEnabled) ?? false,
1153
- peerProfileRecallMaxFields: coerceNonNegativeInt(
1154
- cfg.peerProfileRecallMaxFields,
1155
- 5,
1156
- "peerProfileRecallMaxFields"
1157
- ),
1158
- creationMemoryEnabled: cfg.creationMemoryEnabled === true,
1159
- memoryUtilityLearningEnabled: cfg.memoryUtilityLearningEnabled === true,
1160
- promotionByOutcomeEnabled: cfg.promotionByOutcomeEnabled === true,
1161
- commitmentLedgerEnabled: cfg.commitmentLedgerEnabled === true,
1162
- commitmentLifecycleEnabled: cfg.commitmentLifecycleEnabled === true,
1163
- commitmentStaleDays: typeof cfg.commitmentStaleDays === "number" ? cfg.commitmentStaleDays : 14,
1164
- commitmentLedgerDir: typeof cfg.commitmentLedgerDir === "string" && cfg.commitmentLedgerDir.trim().length > 0 ? cfg.commitmentLedgerDir.trim() : path.join(memoryDir, "state", "commitment-ledger"),
1165
- resumeBundlesEnabled: cfg.resumeBundlesEnabled === true,
1166
- resumeBundleDir: typeof cfg.resumeBundleDir === "string" && cfg.resumeBundleDir.trim().length > 0 ? cfg.resumeBundleDir.trim() : path.join(memoryDir, "state", "resume-bundles"),
1167
- workProductRecallEnabled: cfg.workProductRecallEnabled === true,
1168
- workTasksEnabled: cfg.workTasksEnabled === true,
1169
- workProjectsEnabled: cfg.workProjectsEnabled === true,
1170
- workTasksDir: typeof cfg.workTasksDir === "string" && cfg.workTasksDir.trim().length > 0 ? cfg.workTasksDir.trim() : path.join(memoryDir, "work", "tasks"),
1171
- workProjectsDir: typeof cfg.workProjectsDir === "string" && cfg.workProjectsDir.trim().length > 0 ? cfg.workProjectsDir.trim() : path.join(memoryDir, "work", "projects"),
1172
- workIndexEnabled: cfg.workIndexEnabled === true,
1173
- workIndexDir: typeof cfg.workIndexDir === "string" && cfg.workIndexDir.trim().length > 0 ? cfg.workIndexDir.trim() : path.join(memoryDir, "work", "index"),
1174
- workTaskIndexEnabled: cfg.workTaskIndexEnabled === true,
1175
- workProjectIndexEnabled: cfg.workProjectIndexEnabled === true,
1176
- workIndexAutoRebuildEnabled: cfg.workIndexAutoRebuildEnabled === true,
1177
- workIndexAutoRebuildDebounceMs: typeof cfg.workIndexAutoRebuildDebounceMs === "number" ? cfg.workIndexAutoRebuildDebounceMs : 1e3,
1178
- workProductLedgerDir: typeof cfg.workProductLedgerDir === "string" && cfg.workProductLedgerDir.trim().length > 0 ? cfg.workProductLedgerDir.trim() : path.join(memoryDir, "state", "work-product-ledger"),
1179
- abstractionNodeStoreDir: typeof cfg.abstractionNodeStoreDir === "string" && cfg.abstractionNodeStoreDir.trim().length > 0 ? cfg.abstractionNodeStoreDir.trim() : path.join(memoryDir, "state", "abstraction-nodes"),
1180
- // Local LLM Provider (v2.1)
1181
- localLlmEnabled: cfg.localLlmEnabled === true || cfg.localLlmEnabled === "true",
1182
- // default: false
1183
- localLlmUrl: typeof cfg.localLlmUrl === "string" && cfg.localLlmUrl.length > 0 ? cfg.localLlmUrl : "http://localhost:1234/v1",
1184
- localLlmModel: typeof cfg.localLlmModel === "string" && cfg.localLlmModel.length > 0 ? cfg.localLlmModel : "local-model",
1185
- localLlmApiKey: typeof cfg.localLlmApiKey === "string" && cfg.localLlmApiKey.length > 0 ? resolveEnvVars(cfg.localLlmApiKey) : void 0,
1186
- localLlmHeaders: cfg.localLlmHeaders && typeof cfg.localLlmHeaders === "object" && !Array.isArray(cfg.localLlmHeaders) ? Object.fromEntries(
1187
- Object.entries(cfg.localLlmHeaders).filter(([, value]) => typeof value === "string").map(([key, value]) => [key, String(value)])
1188
- ) : void 0,
1189
- localLlmAuthHeader: cfg.localLlmAuthHeader !== false,
1190
- localLlmFallback: cfg.localLlmFallback !== false,
1191
- // default: true
1192
- localLlmHomeDir: typeof cfg.localLlmHomeDir === "string" && cfg.localLlmHomeDir.length > 0 ? cfg.localLlmHomeDir : void 0,
1193
- localLmsCliPath: typeof cfg.localLmsCliPath === "string" && cfg.localLmsCliPath.length > 0 ? cfg.localLmsCliPath : void 0,
1194
- localLmsBinDir: typeof cfg.localLmsBinDir === "string" && cfg.localLmsBinDir.length > 0 ? cfg.localLmsBinDir : void 0,
1195
- localLlmTimeoutMs: typeof cfg.localLlmTimeoutMs === "number" ? cfg.localLlmTimeoutMs : 18e4,
1196
- localLlmMaxContext: typeof cfg.localLlmMaxContext === "number" ? cfg.localLlmMaxContext : void 0,
1197
- // Observability (disabled by default to avoid log spam)
1198
- slowLogEnabled: cfg.slowLogEnabled === true,
1199
- slowLogThresholdMs: typeof cfg.slowLogThresholdMs === "number" ? cfg.slowLogThresholdMs : 3e4,
1200
- // Trace recall content — disabled by default; enable to send recalled memory text to trace subscribers
1201
- traceRecallContent: cfg.traceRecallContent === true,
1202
- // Performance profiling (opt-in, disabled by default)
1203
- profilingEnabled: cfg.profilingEnabled === true,
1204
- profilingStorageDir: typeof cfg.profilingStorageDir === "string" && cfg.profilingStorageDir.length > 0 ? cfg.profilingStorageDir : path.join(memoryDir, "profiling"),
1205
- profilingMaxTraces: typeof cfg.profilingMaxTraces === "number" && Number.isFinite(cfg.profilingMaxTraces) ? Math.max(0, cfg.profilingMaxTraces) : 100,
1206
- // Extraction stability guards (P0/P1)
1207
- extractionDedupeEnabled: cfg.extractionDedupeEnabled !== false,
1208
- extractionDedupeWindowMs: typeof cfg.extractionDedupeWindowMs === "number" ? cfg.extractionDedupeWindowMs : 5 * 6e4,
1209
- extractionMinChars: typeof cfg.extractionMinChars === "number" ? cfg.extractionMinChars : 40,
1210
- extractionMinUserTurns: typeof cfg.extractionMinUserTurns === "number" ? cfg.extractionMinUserTurns : 1,
1211
- extractionMaxTurnChars: typeof cfg.extractionMaxTurnChars === "number" ? cfg.extractionMaxTurnChars : 4e3,
1212
- extractionMaxFactsPerRun: typeof cfg.extractionMaxFactsPerRun === "number" ? cfg.extractionMaxFactsPerRun : 12,
1213
- extractionMaxEntitiesPerRun: typeof cfg.extractionMaxEntitiesPerRun === "number" ? cfg.extractionMaxEntitiesPerRun : 6,
1214
- extractionMaxQuestionsPerRun: typeof cfg.extractionMaxQuestionsPerRun === "number" ? cfg.extractionMaxQuestionsPerRun : 3,
1215
- extractionMaxProfileUpdatesPerRun: typeof cfg.extractionMaxProfileUpdatesPerRun === "number" ? cfg.extractionMaxProfileUpdatesPerRun : 4,
1216
- // Importance write-gate for trivial extracted content (issue #372).
1217
- // Default "low" drops only "trivial" facts (greetings, single-word replies,
1218
- // heartbeat pings); set to "normal" or higher to make the gate stricter.
1219
- extractionMinImportanceLevel: (() => {
1220
- const raw2 = cfg.extractionMinImportanceLevel;
1221
- if (raw2 === "trivial" || raw2 === "low" || raw2 === "normal" || raw2 === "high" || raw2 === "critical") {
1222
- return raw2;
1223
- }
1224
- return "low";
1225
- })(),
1226
- // Extraction scope classification. When enabled, the extraction prompt
1227
- // asks the LLM to classify each fact as "project" or "global". Global
1228
- // facts are promoted to the shared namespace. Default true (rule 30 gate).
1229
- extractionScopeClassificationEnabled: coerceBool(cfg.extractionScopeClassificationEnabled) !== false,
1230
- // Extraction judge (issue #376). Opt-in LLM-as-judge fact-worthiness gate.
1231
- extractionJudgeEnabled: cfg.extractionJudgeEnabled === true,
1232
- extractionJudgeModel: typeof cfg.extractionJudgeModel === "string" ? cfg.extractionJudgeModel : "",
1233
- extractionJudgeBatchSize: typeof cfg.extractionJudgeBatchSize === "number" && Number.isFinite(cfg.extractionJudgeBatchSize) ? Math.max(1, Math.round(cfg.extractionJudgeBatchSize)) : 20,
1234
- extractionJudgeShadow: cfg.extractionJudgeShadow === true,
1235
- // Defer cap (issue #562 PR 2): max re-deferrals for the same candidate
1236
- // text before the verdict is forcibly converted to reject.
1237
- extractionJudgeMaxDeferrals: typeof cfg.extractionJudgeMaxDeferrals === "number" && Number.isFinite(cfg.extractionJudgeMaxDeferrals) && cfg.extractionJudgeMaxDeferrals >= 1 ? Math.floor(cfg.extractionJudgeMaxDeferrals) : 2,
1238
- // Judge telemetry (issue #562 PR 3): opt-in structured emit to the
1239
- // observation ledger for defer-rate / latency metrics.
1240
- // Uses `coerceBool` so CLI-style string inputs (`"true"`, `"false"`,
1241
- // `"1"`, `"0"`) are accepted consistently with the rest of the
1242
- // codebase (CLAUDE.md gotcha 36).
1243
- extractionJudgeTelemetryEnabled: coerceBool(cfg.extractionJudgeTelemetryEnabled) === true,
1244
- // Judge training-pair collection (issue #562 PR 4): opt-in shim for a
1245
- // future GRPO training pipeline. Rows land under ~/.remnic/judge-
1246
- // training/<date>.jsonl — NOT in the shared memory directory.
1247
- // Uses `coerceBool` per CLAUDE.md gotcha 36 for CLI-string parity.
1248
- collectJudgeTrainingPairs: coerceBool(cfg.collectJudgeTrainingPairs) === true,
1249
- judgeTrainingDir: typeof cfg.judgeTrainingDir === "string" ? cfg.judgeTrainingDir : "",
1250
- // Inline source attribution (issue #369). Opt-in to preserve
1251
- // backwards compatibility with existing downstream consumers.
1252
- inlineSourceAttributionEnabled: cfg.inlineSourceAttributionEnabled === true,
1253
- inlineSourceAttributionFormat: typeof cfg.inlineSourceAttributionFormat === "string" && cfg.inlineSourceAttributionFormat.trim().length > 0 ? cfg.inlineSourceAttributionFormat : "[Source: agent={agent}, session={sessionId}, ts={ts}]",
1254
- consolidationRequireNonZeroExtraction: cfg.consolidationRequireNonZeroExtraction !== false,
1255
- // Issue #678 PR 2/4: dreams.phases.rem.minIntervalMs WINS when set.
1256
- consolidationMinIntervalMs: dreamsRem.minIntervalMs,
1257
- // QMD maintenance (debounced singleflight)
1258
- qmdMaintenanceEnabled: cfg.qmdMaintenanceEnabled !== false,
1259
- qmdMaintenanceDebounceMs: typeof cfg.qmdMaintenanceDebounceMs === "number" ? cfg.qmdMaintenanceDebounceMs : 3e4,
1260
- qmdAutoEmbedEnabled: cfg.qmdAutoEmbedEnabled === true,
1261
- qmdEmbedMinIntervalMs: typeof cfg.qmdEmbedMinIntervalMs === "number" ? cfg.qmdEmbedMinIntervalMs : 60 * 6e4,
1262
- qmdUpdateTimeoutMs: typeof cfg.qmdUpdateTimeoutMs === "number" ? cfg.qmdUpdateTimeoutMs : 9e4,
1263
- qmdUpdateMinIntervalMs: typeof cfg.qmdUpdateMinIntervalMs === "number" ? cfg.qmdUpdateMinIntervalMs : 15 * 6e4,
1264
- // Local LLM resilience
1265
- localLlmRetry5xxCount: typeof cfg.localLlmRetry5xxCount === "number" ? cfg.localLlmRetry5xxCount : 1,
1266
- localLlmRetryBackoffMs: typeof cfg.localLlmRetryBackoffMs === "number" ? cfg.localLlmRetryBackoffMs : 400,
1267
- localLlm400TripThreshold: typeof cfg.localLlm400TripThreshold === "number" ? cfg.localLlm400TripThreshold : 5,
1268
- localLlm400CooldownMs: typeof cfg.localLlm400CooldownMs === "number" ? cfg.localLlm400CooldownMs : 12e4,
1269
- // Local LLM fast tier (v9.1)
1270
- localLlmFastEnabled: cfg.localLlmFastEnabled === true,
1271
- localLlmFastModel: typeof cfg.localLlmFastModel === "string" && cfg.localLlmFastModel.length > 0 ? cfg.localLlmFastModel : "",
1272
- localLlmFastUrl: typeof cfg.localLlmFastUrl === "string" && cfg.localLlmFastUrl.length > 0 ? cfg.localLlmFastUrl : typeof cfg.localLlmUrl === "string" && cfg.localLlmUrl.length > 0 ? cfg.localLlmUrl : "http://localhost:1234/v1",
1273
- localLlmFastTimeoutMs: typeof cfg.localLlmFastTimeoutMs === "number" ? cfg.localLlmFastTimeoutMs : 15e3,
1274
- // Thinking-mode suppression on the main local LLM (issue #548).
1275
- // Default true — extraction / consolidation produce structured
1276
- // JSON and gain nothing from chain-of-thought; thinking-capable
1277
- // models burn their token budget on reasoning and blow the
1278
- // default 60s timeout. Operators who need thinking on the main
1279
- // client (e.g. for narrative tasks) can set this to false via
1280
- // config or --config CLI flag. The fast-tier `fastLlm` always
1281
- // disables thinking and is unaffected by this flag.
1282
- //
1283
- // Injection is backend-gated inside LocalLlmClient: the
1284
- // `chat_template_kwargs` field is only sent when the detected
1285
- // backend is in `THINKING_COMPATIBLE_BACKENDS` (LM Studio, vLLM).
1286
- // Strict OpenAI-compatible backends reject unknown request
1287
- // fields with 400, so the client fails open on unknown backends
1288
- // rather than tripping the 400 cooldown (Codex P1 on PR #550).
1289
- localLlmDisableThinking: coerceBool(cfg.localLlmDisableThinking) ?? true,
1290
- // Gateway config (passed from index.ts for fallback AI)
1291
- gatewayConfig: cfg.gatewayConfig,
1292
- // Gateway model source (v9.2) — route LLM calls through gateway agent model chain
1293
- modelSource,
1294
- gatewayAgentId: typeof cfg.gatewayAgentId === "string" && cfg.gatewayAgentId.length > 0 ? cfg.gatewayAgentId : "",
1295
- fastGatewayAgentId: typeof cfg.fastGatewayAgentId === "string" && cfg.fastGatewayAgentId.length > 0 ? cfg.fastGatewayAgentId : "",
1296
- // v3.0 namespaces (default off)
1297
- namespacesEnabled: cfg.namespacesEnabled === true,
1298
- defaultNamespace: typeof cfg.defaultNamespace === "string" && cfg.defaultNamespace.length > 0 ? cfg.defaultNamespace : "default",
1299
- sharedNamespace: typeof cfg.sharedNamespace === "string" && cfg.sharedNamespace.length > 0 ? cfg.sharedNamespace : "shared",
1300
- principalFromSessionKeyMode: cfg.principalFromSessionKeyMode === "prefix" ? "prefix" : cfg.principalFromSessionKeyMode === "regex" ? "regex" : "map",
1301
- principalFromSessionKeyRules: principalRules,
1302
- namespacePolicies: Array.isArray(cfg.namespacePolicies) ? cfg.namespacePolicies.map((p) => ({
1303
- name: typeof p?.name === "string" ? p.name : "",
1304
- readPrincipals: Array.isArray(p?.readPrincipals) ? p.readPrincipals.filter((x) => typeof x === "string") : [],
1305
- writePrincipals: Array.isArray(p?.writePrincipals) ? p.writePrincipals.filter((x) => typeof x === "string") : [],
1306
- includeInRecallByDefault: p?.includeInRecallByDefault === true
1307
- })).filter((p) => p.name.length > 0) : [],
1308
- defaultRecallNamespaces: Array.isArray(cfg.defaultRecallNamespaces) ? ["self", "shared"].filter((x) => cfg.defaultRecallNamespaces.includes(x)) : ["self", "shared"],
1309
- cronRecallMode: cfg.cronRecallMode === "none" ? "none" : cfg.cronRecallMode === "allowlist" ? "allowlist" : "all",
1310
- cronRecallAllowlist: Array.isArray(cfg.cronRecallAllowlist) ? cfg.cronRecallAllowlist.filter((v) => typeof v === "string" && v.length > 0) : [],
1311
- cronRecallPolicyEnabled: cfg.cronRecallPolicyEnabled !== false,
1312
- cronRecallNormalizedQueryMaxChars: typeof cfg.cronRecallNormalizedQueryMaxChars === "number" ? cfg.cronRecallNormalizedQueryMaxChars : 480,
1313
- cronRecallInstructionHeavyTokenCap: typeof cfg.cronRecallInstructionHeavyTokenCap === "number" ? cfg.cronRecallInstructionHeavyTokenCap : 36,
1314
- cronConversationRecallMode: cfg.cronConversationRecallMode === "always" ? "always" : cfg.cronConversationRecallMode === "never" ? "never" : "auto",
1315
- autoPromoteToSharedEnabled: cfg.autoPromoteToSharedEnabled === true,
1316
- autoPromoteToSharedCategories: Array.isArray(cfg.autoPromoteToSharedCategories) ? cfg.autoPromoteToSharedCategories.filter((c) => c === "fact" || c === "correction" || c === "decision" || c === "preference") : ["fact", "correction", "decision", "preference"],
1317
- autoPromoteMinConfidenceTier: cfg.autoPromoteMinConfidenceTier === "explicit" ? "explicit" : cfg.autoPromoteMinConfidenceTier === "implied" ? "implied" : "explicit",
1318
- routingRulesEnabled: cfg.routingRulesEnabled === true,
1319
- routingRulesStateFile: typeof cfg.routingRulesStateFile === "string" && cfg.routingRulesStateFile.trim().length > 0 ? cfg.routingRulesStateFile.trim() : "state/routing-rules.json",
1320
- // v4.0 shared-context (default off)
1321
- sharedContextEnabled: cfg.sharedContextEnabled === true,
1322
- sharedContextDir: typeof cfg.sharedContextDir === "string" && cfg.sharedContextDir.length > 0 ? cfg.sharedContextDir : void 0,
1323
- sharedContextMaxInjectChars: typeof cfg.sharedContextMaxInjectChars === "number" ? cfg.sharedContextMaxInjectChars : 4e3,
1324
- sharedCrossSignalSemanticEnabled,
1325
- sharedCrossSignalSemanticTimeoutMs,
1326
- sharedCrossSignalSemanticMaxCandidates: typeof cfg.sharedCrossSignalSemanticMaxCandidates === "number" ? Math.max(0, Math.floor(cfg.sharedCrossSignalSemanticMaxCandidates)) : 120,
1327
- // Backward-compatible aliases.
1328
- crossSignalsSemanticEnabled: sharedCrossSignalSemanticEnabled,
1329
- crossSignalsSemanticTimeoutMs: sharedCrossSignalSemanticTimeoutMs,
1330
- // v5.0 compounding (default off)
1331
- compoundingEnabled: cfg.compoundingEnabled === true,
1332
- compoundingWeeklyCronEnabled: cfg.compoundingWeeklyCronEnabled === true,
1333
- compoundingSemanticEnabled: cfg.compoundingSemanticEnabled === true,
1334
- compoundingSynthesisTimeoutMs: typeof cfg.compoundingSynthesisTimeoutMs === "number" ? cfg.compoundingSynthesisTimeoutMs : 15e3,
1335
- compoundingInjectEnabled: cfg.compoundingInjectEnabled !== false,
1336
- // IRC (Inductive Rule Consolidation) — preference synthesis
1337
- ircEnabled: cfg.ircEnabled !== false,
1338
- ircMaxPreferences: typeof cfg.ircMaxPreferences === "number" ? cfg.ircMaxPreferences : 20,
1339
- ircIncludeCorrections: cfg.ircIncludeCorrections !== false,
1340
- ircMinConfidence: typeof cfg.ircMinConfidence === "number" ? cfg.ircMinConfidence : 0.3,
1341
- // CMC (Causal Memory Consolidation) — cross-session causal reasoning
1342
- cmcEnabled: cfg.cmcEnabled === true,
1343
- cmcStitchLookbackDays: typeof cfg.cmcStitchLookbackDays === "number" ? cfg.cmcStitchLookbackDays : 7,
1344
- cmcStitchMinScore: typeof cfg.cmcStitchMinScore === "number" ? cfg.cmcStitchMinScore : 2.5,
1345
- cmcStitchMaxEdgesPerTrajectory: typeof cfg.cmcStitchMaxEdgesPerTrajectory === "number" ? cfg.cmcStitchMaxEdgesPerTrajectory : 3,
1346
- cmcConsolidationEnabled: cfg.cmcConsolidationEnabled === true,
1347
- cmcConsolidationMinRecurrence: typeof cfg.cmcConsolidationMinRecurrence === "number" ? cfg.cmcConsolidationMinRecurrence : 3,
1348
- cmcConsolidationMinSessions: typeof cfg.cmcConsolidationMinSessions === "number" ? cfg.cmcConsolidationMinSessions : 2,
1349
- cmcConsolidationSuccessThreshold: typeof cfg.cmcConsolidationSuccessThreshold === "number" ? cfg.cmcConsolidationSuccessThreshold : 0.7,
1350
- cmcRetrievalEnabled: cfg.cmcRetrievalEnabled === true,
1351
- cmcRetrievalMaxDepth: typeof cfg.cmcRetrievalMaxDepth === "number" ? cfg.cmcRetrievalMaxDepth : 3,
1352
- cmcRetrievalMaxChars: typeof cfg.cmcRetrievalMaxChars === "number" ? cfg.cmcRetrievalMaxChars : 800,
1353
- cmcRetrievalCounterfactualBoost: typeof cfg.cmcRetrievalCounterfactualBoost === "number" ? cfg.cmcRetrievalCounterfactualBoost : 0.4,
1354
- cmcBehaviorLearningEnabled: cfg.cmcBehaviorLearningEnabled === true,
1355
- cmcBehaviorMinFrequency: typeof cfg.cmcBehaviorMinFrequency === "number" ? cfg.cmcBehaviorMinFrequency : 3,
1356
- cmcBehaviorMinSessions: typeof cfg.cmcBehaviorMinSessions === "number" ? cfg.cmcBehaviorMinSessions : 2,
1357
- cmcBehaviorConfidenceThreshold: typeof cfg.cmcBehaviorConfidenceThreshold === "number" ? cfg.cmcBehaviorConfidenceThreshold : 0.6,
1358
- cmcLifecycleCausalImpactWeight: typeof cfg.cmcLifecycleCausalImpactWeight === "number" ? cfg.cmcLifecycleCausalImpactWeight : 0.05,
1359
- // PEDC (Prediction-Error-Driven Calibration) — model-user alignment
1360
- calibrationEnabled: cfg.calibrationEnabled === true,
1361
- calibrationMaxRulesPerRecall: typeof cfg.calibrationMaxRulesPerRecall === "number" ? cfg.calibrationMaxRulesPerRecall : 10,
1362
- calibrationMaxChars: typeof cfg.calibrationMaxChars === "number" ? cfg.calibrationMaxChars : 1200,
1363
- // v7.0 Knowledge Graph Enhancement
1364
- knowledgeIndexEnabled: cfg.knowledgeIndexEnabled !== false,
1365
- knowledgeIndexMaxEntities: typeof cfg.knowledgeIndexMaxEntities === "number" ? cfg.knowledgeIndexMaxEntities : 40,
1366
- knowledgeIndexMaxChars: typeof cfg.knowledgeIndexMaxChars === "number" ? cfg.knowledgeIndexMaxChars : 4e3,
1367
- entityRetrievalEnabled: cfg.entityRetrievalEnabled !== false,
1368
- entityRetrievalMaxChars: typeof cfg.entityRetrievalMaxChars === "number" ? cfg.entityRetrievalMaxChars : 2400,
1369
- entityRetrievalMaxHints: typeof cfg.entityRetrievalMaxHints === "number" ? cfg.entityRetrievalMaxHints : 2,
1370
- entityRetrievalMaxSupportingFacts: typeof cfg.entityRetrievalMaxSupportingFacts === "number" ? cfg.entityRetrievalMaxSupportingFacts : 6,
1371
- entityRetrievalMaxRelatedEntities: typeof cfg.entityRetrievalMaxRelatedEntities === "number" ? cfg.entityRetrievalMaxRelatedEntities : 3,
1372
- entityRetrievalRecentTurns: typeof cfg.entityRetrievalRecentTurns === "number" ? cfg.entityRetrievalRecentTurns : 6,
1373
- entitySchemas,
1374
- recallBudgetChars: recallPipelineConfig.recallBudgetChars,
1375
- recallOuterTimeoutMs: typeof cfg.recallOuterTimeoutMs === "number" ? Math.max(0, Math.floor(cfg.recallOuterTimeoutMs)) : 75e3,
1376
- recallCoreDeadlineMs: typeof cfg.recallCoreDeadlineMs === "number" ? Math.max(0, Math.floor(cfg.recallCoreDeadlineMs)) : 75e3,
1377
- recallEnrichmentDeadlineMs: typeof cfg.recallEnrichmentDeadlineMs === "number" ? Math.max(0, Math.floor(cfg.recallEnrichmentDeadlineMs)) : 25e3,
1378
- recallPipeline: recallPipelineConfig.pipeline,
1379
- recallMmrEnabled: cfg.recallMmrEnabled !== false,
1380
- recallMmrLambda: typeof cfg.recallMmrLambda === "number" && Number.isFinite(cfg.recallMmrLambda) ? Math.min(1, Math.max(0, cfg.recallMmrLambda)) : 0.7,
1381
- recallMmrTopN: typeof cfg.recallMmrTopN === "number" && Number.isFinite(cfg.recallMmrTopN) ? Math.max(0, Math.floor(cfg.recallMmrTopN)) : 40,
1382
- // Issue #564 PR 3: off by default; enable explicitly after bench validation.
1383
- recallReasoningTraceBoostEnabled: coerceBool(cfg.recallReasoningTraceBoostEnabled) ?? false,
1384
- qmdRecallCacheTtlMs: typeof cfg.qmdRecallCacheTtlMs === "number" ? Math.max(0, Math.floor(cfg.qmdRecallCacheTtlMs)) : 6e4,
1385
- qmdRecallCacheStaleTtlMs: typeof cfg.qmdRecallCacheStaleTtlMs === "number" ? Math.max(0, Math.floor(cfg.qmdRecallCacheStaleTtlMs)) : 10 * 6e4,
1386
- qmdRecallCacheMaxEntries: typeof cfg.qmdRecallCacheMaxEntries === "number" ? Math.max(0, Math.floor(cfg.qmdRecallCacheMaxEntries)) : 128,
1387
- entityRelationshipsEnabled: cfg.entityRelationshipsEnabled !== false,
1388
- entityActivityLogEnabled: cfg.entityActivityLogEnabled !== false,
1389
- entityActivityLogMaxEntries: typeof cfg.entityActivityLogMaxEntries === "number" ? cfg.entityActivityLogMaxEntries : 20,
1390
- entityAliasesEnabled: cfg.entityAliasesEnabled !== false,
1391
- entitySummaryEnabled: cfg.entitySummaryEnabled !== false,
1392
- entitySynthesisMaxTokens: typeof cfg.entitySynthesisMaxTokens === "number" && Number.isFinite(cfg.entitySynthesisMaxTokens) ? (() => {
1393
- const tokens = Math.max(0, Math.floor(cfg.entitySynthesisMaxTokens));
1394
- return tokens === 0 ? 0 : Math.max(10, tokens);
1395
- })() : 500,
1396
- // Search backend abstraction
1397
- searchBackend: ["qmd", "remote", "noop", "lancedb", "meilisearch", "orama"].includes(cfg.searchBackend) ? cfg.searchBackend : "qmd",
1398
- remoteSearchBaseUrl: typeof cfg.remoteSearchBaseUrl === "string" ? cfg.remoteSearchBaseUrl : void 0,
1399
- remoteSearchApiKey: typeof cfg.remoteSearchApiKey === "string" ? cfg.remoteSearchApiKey : void 0,
1400
- remoteSearchTimeoutMs: typeof cfg.remoteSearchTimeoutMs === "number" ? cfg.remoteSearchTimeoutMs : 3e4,
1401
- // LanceDB backend
1402
- lancedbEnabled: cfg.lancedbEnabled === true,
1403
- lanceDbPath: typeof cfg.lanceDbPath === "string" ? cfg.lanceDbPath : path.join(memoryDir, "lancedb"),
1404
- lanceEmbeddingDimension: typeof cfg.lanceEmbeddingDimension === "number" ? cfg.lanceEmbeddingDimension : 1536,
1405
- // Meilisearch backend
1406
- meilisearchEnabled: cfg.meilisearchEnabled === true,
1407
- meilisearchHost: typeof cfg.meilisearchHost === "string" ? cfg.meilisearchHost : "http://localhost:7700",
1408
- meilisearchApiKey: typeof cfg.meilisearchApiKey === "string" ? cfg.meilisearchApiKey : void 0,
1409
- meilisearchTimeoutMs: typeof cfg.meilisearchTimeoutMs === "number" ? cfg.meilisearchTimeoutMs : 3e4,
1410
- meilisearchAutoIndex: cfg.meilisearchAutoIndex === true,
1411
- // Orama backend
1412
- oramaEnabled: cfg.oramaEnabled === true,
1413
- oramaDbPath: typeof cfg.oramaDbPath === "string" ? cfg.oramaDbPath : path.join(memoryDir, "orama"),
1414
- oramaEmbeddingDimension: typeof cfg.oramaEmbeddingDimension === "number" ? cfg.oramaEmbeddingDimension : 1536,
1415
- // QMD daemon mode
1416
- qmdDaemonEnabled: cfg.qmdDaemonEnabled !== false,
1417
- qmdDaemonUrl: typeof cfg.qmdDaemonUrl === "string" && cfg.qmdDaemonUrl.length > 0 ? cfg.qmdDaemonUrl : "http://localhost:8181/mcp",
1418
- qmdDaemonRecheckIntervalMs: typeof cfg.qmdDaemonRecheckIntervalMs === "number" ? cfg.qmdDaemonRecheckIntervalMs : 15e3,
1419
- qmdIntentHintsEnabled: cfg.qmdIntentHintsEnabled === true,
1420
- qmdExplainEnabled: cfg.qmdExplainEnabled === true,
1421
- // v6.0 Fact deduplication & archival
1422
- factDeduplicationEnabled: cfg.factDeduplicationEnabled !== false,
1423
- // Issue #373 — write-time semantic similarity guard
1424
- semanticDedupEnabled: cfg.semanticDedupEnabled !== false,
1425
- // Guard against NaN / Infinity — Number.isFinite rejects both and falls
1426
- // back to the documented default so the semantic dedup guard cannot be
1427
- // silently disabled by a malformed config value.
1428
- semanticDedupThreshold: typeof cfg.semanticDedupThreshold === "number" && Number.isFinite(cfg.semanticDedupThreshold) ? Math.min(1, Math.max(0, cfg.semanticDedupThreshold)) : 0.92,
1429
- // Zero is a valid "disable candidate lookup" signal and must be preserved.
1430
- // Only negative or non-finite values fall back to the default of 5.
1431
- // Fractional values in (0, 1) floor to 0, which would silently disable
1432
- // semantic dedup despite a clearly non-zero operator intent — clamp to 1.
1433
- semanticDedupCandidates: (() => {
1434
- const raw2 = cfg.semanticDedupCandidates;
1435
- if (typeof raw2 !== "number" || !Number.isFinite(raw2) || raw2 < 0) return 5;
1436
- const n = Math.floor(raw2);
1437
- return raw2 > 0 && n === 0 ? 1 : n;
1438
- })(),
1439
- factArchivalEnabled: cfg.factArchivalEnabled === true,
1440
- factArchivalAgeDays: typeof cfg.factArchivalAgeDays === "number" ? cfg.factArchivalAgeDays : 90,
1441
- factArchivalMaxImportance: typeof cfg.factArchivalMaxImportance === "number" ? cfg.factArchivalMaxImportance : 0.3,
1442
- factArchivalMaxAccessCount: typeof cfg.factArchivalMaxAccessCount === "number" ? cfg.factArchivalMaxAccessCount : 2,
1443
- factArchivalProtectedCategories: Array.isArray(cfg.factArchivalProtectedCategories) ? cfg.factArchivalProtectedCategories.filter((c) => typeof c === "string") : ["commitment", "preference", "decision", "principle", "procedure"],
1444
- // Lifecycle policy engine (issue #686 PR 3/6 — flipped default to
1445
- // `true`). Tier infrastructure (`tier-routing.ts`,
1446
- // `tier-migration.ts`, separate cold QMD collection) has shipped
1447
- // for several releases. Default-on lets the year-2 retention
1448
- // story land for every install instead of staying gated behind
1449
- // an opt-in flag the typical operator never reaches. Operators
1450
- // who need pre-#686 behavior (no automatic hot↔cold migration,
1451
- // no recall-time stale filtering) can set
1452
- // `lifecyclePolicyEnabled: false` explicitly. Coerce string/number
1453
- // boolean-likes (e.g. CLI `--config lifecyclePolicyEnabled=false`)
1454
- // before applying the default — otherwise an explicit false-ish
1455
- // input falls through and silently re-enables the policy.
1456
- // Issue #678 PR 2/4: dreams.phases.lightSleep.* WINS over legacy keys.
1457
- // The runtime gate (orchestrator's `runLifecyclePolicyPass`) reads
1458
- // these legacy fields, so propagate the precedence here.
1459
- lifecyclePolicyEnabled: dreamsLightSleep.enabled,
1460
- lifecycleFilterStaleEnabled: dreamsLightSleep.filterStaleEnabled,
1461
- lifecyclePromoteHeatThreshold: dreamsLightSleep.promoteHeatThreshold,
1462
- lifecycleStaleDecayThreshold: dreamsLightSleep.staleDecayThreshold,
1463
- lifecycleArchiveDecayThreshold: dreamsLightSleep.archiveDecayThreshold,
1464
- lifecycleProtectedCategories: Array.isArray(cfg.lifecycleProtectedCategories) ? cfg.lifecycleProtectedCategories.filter(
1465
- (c) => typeof c === "string" && VALID_MEMORY_CATEGORIES.has(c)
1466
- ) : ["decision", "principle", "commitment", "preference", "procedure"],
1467
- // Mirror the *resolved* lifecyclePolicyEnabled default (not the
1468
- // raw input) — otherwise omitting both flags returns `false` for
1469
- // metrics even though the policy is enabled by default since
1470
- // #686 PR 3/6.
1471
- // Issue #678 PR 2/4: mirror the resolved dreams light-sleep enabled flag
1472
- // (which already incorporates dreams.phases precedence + legacy fallback).
1473
- lifecycleMetricsEnabled: coerceBooleanLike(cfg.lifecycleMetricsEnabled) ?? dreamsLightSleep.enabled,
1474
- // v8.3 proactive + policy learning (default off)
1475
- proactiveExtractionEnabled: cfg.proactiveExtractionEnabled === true,
1476
- contextCompressionActionsEnabled: cfg.contextCompressionActionsEnabled === true,
1477
- compressionGuidelineLearningEnabled: cfg.compressionGuidelineLearningEnabled === true,
1478
- compressionGuidelineSemanticRefinementEnabled: cfg.compressionGuidelineSemanticRefinementEnabled === true,
1479
- compressionGuidelineSemanticTimeoutMs: typeof cfg.compressionGuidelineSemanticTimeoutMs === "number" ? Math.max(1, Math.floor(cfg.compressionGuidelineSemanticTimeoutMs)) : 2500,
1480
- maxProactiveQuestionsPerExtraction: typeof cfg.maxProactiveQuestionsPerExtraction === "number" ? Math.max(0, Math.floor(cfg.maxProactiveQuestionsPerExtraction)) : 2,
1481
- proactiveExtractionTimeoutMs: typeof cfg.proactiveExtractionTimeoutMs === "number" ? Math.max(0, Math.floor(cfg.proactiveExtractionTimeoutMs)) : 2500,
1482
- proactiveExtractionMaxTokens: typeof cfg.proactiveExtractionMaxTokens === "number" ? Math.max(0, Math.floor(cfg.proactiveExtractionMaxTokens)) : 900,
1483
- extractionMaxOutputTokens: typeof cfg.extractionMaxOutputTokens === "number" ? Math.max(1, Math.floor(cfg.extractionMaxOutputTokens)) : 16384,
1484
- proactiveExtractionCategoryAllowlist: Array.isArray(cfg.proactiveExtractionCategoryAllowlist) ? cfg.proactiveExtractionCategoryAllowlist.filter(
1485
- (category) => typeof category === "string" && VALID_MEMORY_CATEGORIES.has(category)
1486
- ) : void 0,
1487
- maxCompressionTokensPerHour: typeof cfg.maxCompressionTokensPerHour === "number" ? Math.max(0, Math.floor(cfg.maxCompressionTokensPerHour)) : 1500,
1488
- behaviorLoopAutoTuneEnabled: cfg.behaviorLoopAutoTuneEnabled === true,
1489
- behaviorLoopLearningWindowDays: typeof cfg.behaviorLoopLearningWindowDays === "number" ? Math.max(0, Math.floor(cfg.behaviorLoopLearningWindowDays)) : 14,
1490
- behaviorLoopMinSignalCount: typeof cfg.behaviorLoopMinSignalCount === "number" ? Math.max(0, Math.floor(cfg.behaviorLoopMinSignalCount)) : 10,
1491
- behaviorLoopMaxDeltaPerCycle: typeof cfg.behaviorLoopMaxDeltaPerCycle === "number" ? Math.min(1, Math.max(0, cfg.behaviorLoopMaxDeltaPerCycle)) : 0.1,
1492
- behaviorLoopProtectedParams: Array.isArray(cfg.behaviorLoopProtectedParams) ? cfg.behaviorLoopProtectedParams.filter((param) => typeof param === "string" && param.trim().length > 0) : [...DEFAULT_BEHAVIOR_LOOP_PROTECTED_PARAMS],
1493
- // v8.0 phase 1
1494
- recallPlannerEnabled: cfg.recallPlannerEnabled !== false,
1495
- recallPlannerModel: typeof cfg.recallPlannerModel === "string" && cfg.recallPlannerModel.trim().length > 0 ? cfg.recallPlannerModel.trim() : "gpt-5.2-mini",
1496
- recallPlannerTimeoutMs: typeof cfg.recallPlannerTimeoutMs === "number" ? cfg.recallPlannerTimeoutMs : 1500,
1497
- recallPlannerUseResponsesApi: cfg.recallPlannerUseResponsesApi !== false,
1498
- recallPlannerMaxPromptChars: typeof cfg.recallPlannerMaxPromptChars === "number" ? cfg.recallPlannerMaxPromptChars : 4e3,
1499
- recallPlannerMaxMemoryHints: typeof cfg.recallPlannerMaxMemoryHints === "number" ? cfg.recallPlannerMaxMemoryHints : 24,
1500
- recallPlannerShadowMode: cfg.recallPlannerShadowMode === true,
1501
- recallPlannerTelemetryEnabled: cfg.recallPlannerTelemetryEnabled !== false,
1502
- recallPlannerMaxQmdResultsMinimal: typeof cfg.recallPlannerMaxQmdResultsMinimal === "number" ? cfg.recallPlannerMaxQmdResultsMinimal : 4,
1503
- recallPlannerMaxQmdResultsFull: typeof cfg.recallPlannerMaxQmdResultsFull === "number" ? cfg.recallPlannerMaxQmdResultsFull : 8,
1504
- intentRoutingEnabled: cfg.intentRoutingEnabled === true,
1505
- intentRoutingBoost: typeof cfg.intentRoutingBoost === "number" ? cfg.intentRoutingBoost : 0.12,
1506
- verbatimArtifactsEnabled: cfg.verbatimArtifactsEnabled === true,
1507
- verbatimArtifactsMinConfidence: typeof cfg.verbatimArtifactsMinConfidence === "number" ? cfg.verbatimArtifactsMinConfidence : 0.8,
1508
- verbatimArtifactsMaxRecall: typeof cfg.verbatimArtifactsMaxRecall === "number" ? cfg.verbatimArtifactsMaxRecall : 5,
1509
- verbatimArtifactCategories: Array.isArray(cfg.verbatimArtifactCategories) ? cfg.verbatimArtifactCategories.filter(
1510
- (c) => typeof c === "string" && VALID_MEMORY_CATEGORIES.has(c)
1511
- ) : ["decision", "correction", "principle", "commitment"],
1512
- // v8.0 Phase 2A: Memory Boxes + Trace Weaving
1513
- memoryBoxesEnabled: cfg.memoryBoxesEnabled === true,
1514
- boxTopicShiftThreshold: typeof cfg.boxTopicShiftThreshold === "number" ? cfg.boxTopicShiftThreshold : 0.35,
1515
- boxTimeGapMs: typeof cfg.boxTimeGapMs === "number" ? cfg.boxTimeGapMs : 30 * 60 * 1e3,
1516
- boxMaxMemories: typeof cfg.boxMaxMemories === "number" ? cfg.boxMaxMemories : 50,
1517
- traceWeaverEnabled: cfg.traceWeaverEnabled === true,
1518
- traceWeaverLookbackDays: typeof cfg.traceWeaverLookbackDays === "number" ? cfg.traceWeaverLookbackDays : 7,
1519
- traceWeaverOverlapThreshold: typeof cfg.traceWeaverOverlapThreshold === "number" ? cfg.traceWeaverOverlapThreshold : 0.4,
1520
- boxRecallDays: typeof cfg.boxRecallDays === "number" ? cfg.boxRecallDays : 3,
1521
- // v8.0 Phase 2B: Episode/Note dual store (HiMem)
1522
- episodeNoteModeEnabled: cfg.episodeNoteModeEnabled === true,
1523
- // v8.1: Temporal + Tag Indexes (SwiftMem-inspired)
1524
- queryAwareIndexingEnabled: cfg.queryAwareIndexingEnabled === true,
1525
- queryAwareIndexingMaxCandidates: typeof cfg.queryAwareIndexingMaxCandidates === "number" ? Math.max(0, cfg.queryAwareIndexingMaxCandidates) : 200,
1526
- temporalIndexWindowDays: typeof cfg.temporalIndexWindowDays === "number" ? cfg.temporalIndexWindowDays : 30,
1527
- temporalIndexMaxEntries: typeof cfg.temporalIndexMaxEntries === "number" ? cfg.temporalIndexMaxEntries : 5e3,
1528
- temporalBoostRecentDays: typeof cfg.temporalBoostRecentDays === "number" ? cfg.temporalBoostRecentDays : 7,
1529
- temporalBoostScore: typeof cfg.temporalBoostScore === "number" ? cfg.temporalBoostScore : 0.15,
1530
- temporalDecayEnabled: cfg.temporalDecayEnabled !== false,
1531
- tagMemoryEnabled: cfg.tagMemoryEnabled === true,
1532
- tagMaxPerMemory: typeof cfg.tagMaxPerMemory === "number" ? cfg.tagMaxPerMemory : 5,
1533
- tagIndexMaxEntries: typeof cfg.tagIndexMaxEntries === "number" ? cfg.tagIndexMaxEntries : 1e4,
1534
- tagRecallBoost: typeof cfg.tagRecallBoost === "number" ? cfg.tagRecallBoost : 0.15,
1535
- tagRecallMaxMatches: typeof cfg.tagRecallMaxMatches === "number" ? cfg.tagRecallMaxMatches : 10,
1536
- // v8.2: Multi-graph memory (PR 18)
1537
- multiGraphMemoryEnabled: cfg.multiGraphMemoryEnabled === true,
1538
- graphRecallEnabled: cfg.graphRecallEnabled === true,
1539
- graphRecallMaxExpansions: typeof cfg.graphRecallMaxExpansions === "number" ? cfg.graphRecallMaxExpansions : 3,
1540
- graphRecallMaxPerSeed: typeof cfg.graphRecallMaxPerSeed === "number" ? cfg.graphRecallMaxPerSeed : 5,
1541
- graphRecallMinEdgeWeight: typeof cfg.graphRecallMinEdgeWeight === "number" ? cfg.graphRecallMinEdgeWeight : 0.1,
1542
- graphRecallShadowEnabled: cfg.graphRecallShadowEnabled === true,
1543
- graphRecallSnapshotEnabled: cfg.graphRecallSnapshotEnabled === true,
1544
- graphRecallShadowSampleRate: typeof cfg.graphRecallShadowSampleRate === "number" ? cfg.graphRecallShadowSampleRate : 0.1,
1545
- graphRecallExplainToolEnabled: cfg.graphRecallExplainToolEnabled === true,
1546
- graphRecallStoreColdMirror: cfg.graphRecallStoreColdMirror === true,
1547
- graphRecallColdMirrorCollection: typeof cfg.graphRecallColdMirrorCollection === "string" && cfg.graphRecallColdMirrorCollection.trim().length > 0 ? cfg.graphRecallColdMirrorCollection.trim() : void 0,
1548
- graphRecallColdMirrorMinAgeDays: typeof cfg.graphRecallColdMirrorMinAgeDays === "number" ? cfg.graphRecallColdMirrorMinAgeDays : 7,
1549
- graphRecallUseEntityPriors: cfg.graphRecallUseEntityPriors === true,
1550
- graphRecallEntityPriorBoost: typeof cfg.graphRecallEntityPriorBoost === "number" ? cfg.graphRecallEntityPriorBoost : 0.2,
1551
- graphRecallPreferHubSeeds: cfg.graphRecallPreferHubSeeds === true,
1552
- graphRecallHubBias: typeof cfg.graphRecallHubBias === "number" ? cfg.graphRecallHubBias : 0.3,
1553
- graphRecallRecencyHalfLifeDays: typeof cfg.graphRecallRecencyHalfLifeDays === "number" ? cfg.graphRecallRecencyHalfLifeDays : 30,
1554
- graphRecallDampingFactor: typeof cfg.graphRecallDampingFactor === "number" ? cfg.graphRecallDampingFactor : 0.85,
1555
- graphRecallMaxSeedNodes: typeof cfg.graphRecallMaxSeedNodes === "number" ? cfg.graphRecallMaxSeedNodes : 10,
1556
- graphRecallMaxExpandedNodes: typeof cfg.graphRecallMaxExpandedNodes === "number" ? cfg.graphRecallMaxExpandedNodes : 30,
1557
- graphRecallMaxTrailPerNode: typeof cfg.graphRecallMaxTrailPerNode === "number" ? cfg.graphRecallMaxTrailPerNode : 5,
1558
- graphRecallMinSeedScore: typeof cfg.graphRecallMinSeedScore === "number" ? cfg.graphRecallMinSeedScore : 0.3,
1559
- graphRecallExpansionScoreThreshold: typeof cfg.graphRecallExpansionScoreThreshold === "number" ? cfg.graphRecallExpansionScoreThreshold : 0.2,
1560
- graphRecallExplainMaxPaths: typeof cfg.graphRecallExplainMaxPaths === "number" ? cfg.graphRecallExplainMaxPaths : 3,
1561
- graphRecallExplainMaxChars: typeof cfg.graphRecallExplainMaxChars === "number" ? cfg.graphRecallExplainMaxChars : 500,
1562
- graphRecallExplainEdgeLimit: typeof cfg.graphRecallExplainEdgeLimit === "number" ? cfg.graphRecallExplainEdgeLimit : 5,
1563
- graphRecallExplainEnabled: cfg.graphRecallExplainEnabled === true,
1564
- graphRecallEntityHintsEnabled: cfg.graphRecallEntityHintsEnabled === true,
1565
- graphRecallEntityHintMax: typeof cfg.graphRecallEntityHintMax === "number" ? cfg.graphRecallEntityHintMax : 3,
1566
- graphRecallEntityHintMaxChars: typeof cfg.graphRecallEntityHintMaxChars === "number" ? cfg.graphRecallEntityHintMaxChars : 200,
1567
- graphRecallSnapshotDir: typeof cfg.graphRecallSnapshotDir === "string" && cfg.graphRecallSnapshotDir.trim().length > 0 ? cfg.graphRecallSnapshotDir.trim() : path.join(memoryDir, "state", "graph"),
1568
- graphRecallEnableTrace: cfg.graphRecallEnableTrace === true,
1569
- graphRecallEnableDebug: cfg.graphRecallEnableDebug === true,
1570
- graphExpandedIntentEnabled: cfg.graphExpandedIntentEnabled !== false,
1571
- graphAssistInFullModeEnabled: cfg.graphAssistInFullModeEnabled !== false,
1572
- graphAssistShadowEvalEnabled: cfg.graphAssistShadowEvalEnabled === true,
1573
- graphAssistMinSeedResults: typeof cfg.graphAssistMinSeedResults === "number" ? Math.max(1, Math.floor(cfg.graphAssistMinSeedResults)) : 3,
1574
- entityGraphEnabled: cfg.entityGraphEnabled !== false,
1575
- timeGraphEnabled: cfg.timeGraphEnabled !== false,
1576
- graphWriteSessionAdjacencyEnabled: cfg.graphWriteSessionAdjacencyEnabled !== false,
1577
- causalGraphEnabled: cfg.causalGraphEnabled !== false,
1578
- maxGraphTraversalSteps: typeof cfg.maxGraphTraversalSteps === "number" ? Math.max(0, cfg.maxGraphTraversalSteps) : 3,
1579
- graphActivationDecay: typeof cfg.graphActivationDecay === "number" ? Math.min(1, Math.max(0, cfg.graphActivationDecay)) : 0.7,
1580
- graphExpansionActivationWeight: typeof cfg.graphExpansionActivationWeight === "number" ? Math.min(1, Math.max(0, cfg.graphExpansionActivationWeight)) : 0.65,
1581
- graphExpansionBlendMin: typeof cfg.graphExpansionBlendMin === "number" ? Math.min(1, Math.max(0, cfg.graphExpansionBlendMin)) : 0.05,
1582
- graphExpansionBlendMax: typeof cfg.graphExpansionBlendMax === "number" ? Math.min(1, Math.max(0, cfg.graphExpansionBlendMax)) : 0.95,
1583
- maxEntityGraphEdgesPerMemory: typeof cfg.maxEntityGraphEdgesPerMemory === "number" ? Math.max(0, cfg.maxEntityGraphEdgesPerMemory) : 10,
1584
- delinearizeEnabled: cfg.delinearizeEnabled !== false,
1585
- recallConfidenceGateEnabled: cfg.recallConfidenceGateEnabled === true,
1586
- recallConfidenceGateThreshold: typeof cfg.recallConfidenceGateThreshold === "number" ? Math.max(0, Math.min(1, cfg.recallConfidenceGateThreshold)) : 0.12,
1587
- causalRuleExtractionEnabled: cfg.causalRuleExtractionEnabled === true,
1588
- memoryReconstructionEnabled: cfg.memoryReconstructionEnabled === true,
1589
- memoryReconstructionMaxExpansions: typeof cfg.memoryReconstructionMaxExpansions === "number" ? Math.max(0, Math.round(cfg.memoryReconstructionMaxExpansions)) : 3,
1590
- graphLateralInhibitionEnabled: cfg.graphLateralInhibitionEnabled !== false,
1591
- graphLateralInhibitionBeta: typeof cfg.graphLateralInhibitionBeta === "number" ? Math.max(0, Math.min(1, cfg.graphLateralInhibitionBeta)) : 0.15,
1592
- graphLateralInhibitionTopM: typeof cfg.graphLateralInhibitionTopM === "number" ? Math.max(0, Math.round(cfg.graphLateralInhibitionTopM)) : 7,
1593
- // Issue #681 PR 2/3 — graph-edge confidence decay maintenance.
1594
- // Boolean coerced via shared helper (gotcha #36: string "false" is truthy).
1595
- graphEdgeDecayEnabled: coerceBooleanLike(cfg.graphEdgeDecayEnabled) ?? false,
1596
- graphEdgeDecayCadenceMs: typeof cfg.graphEdgeDecayCadenceMs === "number" && Number.isFinite(cfg.graphEdgeDecayCadenceMs) ? Math.max(6e4, Math.floor(cfg.graphEdgeDecayCadenceMs)) : 7 * 24 * 60 * 60 * 1e3,
1597
- graphEdgeDecayWindowMs: typeof cfg.graphEdgeDecayWindowMs === "number" && Number.isFinite(cfg.graphEdgeDecayWindowMs) ? Math.max(6e4, Math.floor(cfg.graphEdgeDecayWindowMs)) : 90 * 24 * 60 * 60 * 1e3,
1598
- graphEdgeDecayPerWindow: typeof cfg.graphEdgeDecayPerWindow === "number" && Number.isFinite(cfg.graphEdgeDecayPerWindow) ? Math.max(0, Math.min(1, cfg.graphEdgeDecayPerWindow)) : 0.1,
1599
- graphEdgeDecayFloor: typeof cfg.graphEdgeDecayFloor === "number" && Number.isFinite(cfg.graphEdgeDecayFloor) ? Math.max(0, Math.min(1, cfg.graphEdgeDecayFloor)) : 0.1,
1600
- graphEdgeDecayVisibilityThreshold: typeof cfg.graphEdgeDecayVisibilityThreshold === "number" && Number.isFinite(cfg.graphEdgeDecayVisibilityThreshold) ? Math.max(0, Math.min(1, cfg.graphEdgeDecayVisibilityThreshold)) : 0.2,
1601
- // Issue #681 PR 3/3 — confidence-aware traversal & PageRank refinement.
1602
- // Floor clamps to [0, 1] so misconfigured input cannot accept negative
1603
- // confidences or reject every edge. Iterations floors at 0 so a
1604
- // documented 0 disables PageRank refinement and BFS scores pass through.
1605
- graphTraversalConfidenceFloor: typeof cfg.graphTraversalConfidenceFloor === "number" && Number.isFinite(cfg.graphTraversalConfidenceFloor) ? Math.min(1, Math.max(0, cfg.graphTraversalConfidenceFloor)) : 0.2,
1606
- graphTraversalPageRankIterations: typeof cfg.graphTraversalPageRankIterations === "number" && Number.isFinite(cfg.graphTraversalPageRankIterations) && cfg.graphTraversalPageRankIterations >= 0 ? Math.floor(cfg.graphTraversalPageRankIterations) : 8,
1607
- // v8.2: Temporal Memory Tree
1608
- temporalMemoryTreeEnabled: cfg.temporalMemoryTreeEnabled === true,
1609
- tmtHourlyMinMemories: typeof cfg.tmtHourlyMinMemories === "number" ? cfg.tmtHourlyMinMemories : 3,
1610
- tmtSummaryMaxTokens: typeof cfg.tmtSummaryMaxTokens === "number" ? cfg.tmtSummaryMaxTokens : 300,
1611
- explicitCueRecallEnabled: coerceBool(cfg.explicitCueRecallEnabled) === true,
1612
- explicitCueRecallMaxChars: coerceNumber(cfg.explicitCueRecallMaxChars) !== void 0 ? Math.max(0, Math.floor(coerceNumber(cfg.explicitCueRecallMaxChars))) : 2400,
1613
- explicitCueRecallMaxReferences: coerceNumber(cfg.explicitCueRecallMaxReferences) !== void 0 ? Math.max(0, Math.floor(coerceNumber(cfg.explicitCueRecallMaxReferences))) : 24,
1614
- // Lossless Context Management (LCM)
1615
- lcmEnabled: cfg.lcmEnabled === true,
1616
- lcmLeafBatchSize: typeof cfg.lcmLeafBatchSize === "number" ? Math.max(2, Math.floor(cfg.lcmLeafBatchSize)) : 8,
1617
- lcmRollupFanIn: typeof cfg.lcmRollupFanIn === "number" ? Math.max(2, Math.floor(cfg.lcmRollupFanIn)) : 4,
1618
- lcmFreshTailTurns: typeof cfg.lcmFreshTailTurns === "number" ? Math.max(1, Math.floor(cfg.lcmFreshTailTurns)) : 16,
1619
- lcmMaxDepth: typeof cfg.lcmMaxDepth === "number" ? Math.max(1, Math.floor(cfg.lcmMaxDepth)) : 5,
1620
- lcmRecallBudgetShare: typeof cfg.lcmRecallBudgetShare === "number" ? Math.max(0, Math.min(1, cfg.lcmRecallBudgetShare)) : 0.15,
1621
- lcmDeterministicMaxTokens: typeof cfg.lcmDeterministicMaxTokens === "number" ? Math.max(64, Math.floor(cfg.lcmDeterministicMaxTokens)) : 512,
1622
- lcmArchiveRetentionDays: typeof cfg.lcmArchiveRetentionDays === "number" ? Math.max(1, Math.floor(cfg.lcmArchiveRetentionDays)) : 90,
1623
- messagePartsEnabled: coerceBooleanLike(cfg.messagePartsEnabled) === true,
1624
- messagePartsRecallMaxResults: typeof cfg.messagePartsRecallMaxResults === "number" ? Math.max(0, Math.floor(cfg.messagePartsRecallMaxResults)) : 6,
1625
- // v9.1 Parallel Specialized Retrieval
1626
- parallelRetrievalEnabled: cfg.parallelRetrievalEnabled === true,
1627
- parallelAgentWeights: (() => {
1628
- const w = cfg.parallelAgentWeights;
1629
- return {
1630
- direct: typeof w?.direct === "number" ? Math.max(0, w.direct) : 1,
1631
- contextual: typeof w?.contextual === "number" ? Math.max(0, w.contextual) : 0.7,
1632
- temporal: typeof w?.temporal === "number" ? Math.max(0, w.temporal) : 0.85
1633
- };
1634
- })(),
1635
- parallelMaxResultsPerAgent: typeof cfg.parallelMaxResultsPerAgent === "number" ? Math.max(0, Math.floor(cfg.parallelMaxResultsPerAgent)) : 20,
1636
- briefing: parseBriefingConfig(cfg.briefing),
1637
- // Codex CLI connector settings (install-time)
1638
- codex: (() => {
1639
- const raw2 = cfg.codex && typeof cfg.codex === "object" && !Array.isArray(cfg.codex) ? cfg.codex : {};
1640
- const installExtension = coerceInstallExtension(raw2.installExtension) ?? true;
1641
- const codexHome = typeof raw2.codexHome === "string" && raw2.codexHome.trim().length > 0 ? raw2.codexHome.trim() : null;
1642
- return { installExtension, codexHome };
1643
- })(),
1644
- // Live connectors (issue #683 PR 2/N).
1645
- //
1646
- // Per CLAUDE.md gotcha #30 and #48, every concrete connector ships
1647
- // disabled-by-default and the parser MUST reject malformed top-level
1648
- // shapes loudly (gotcha #51) rather than silently producing an empty
1649
- // object.
1650
- //
1651
- // We do NOT validate credential strings here — the connector module
1652
- // re-validates on every sync pass via `validateGoogleDriveConfig`.
1653
- // That keeps secret-store-driven values (which may legitimately be
1654
- // empty until the operator runs setup) round-trippable through the
1655
- // config layer without crashing the orchestrator at boot.
1656
- connectors: (() => {
1657
- if (cfg.connectors !== void 0 && (cfg.connectors === null || typeof cfg.connectors !== "object" || Array.isArray(cfg.connectors))) {
1658
- throw new Error(
1659
- `connectors must be an object (got ${JSON.stringify(cfg.connectors)}). Use connectors: {} to opt out of every live connector.`
1660
- );
1661
- }
1662
- const rawConnectors = cfg.connectors && typeof cfg.connectors === "object" && !Array.isArray(cfg.connectors) ? cfg.connectors : {};
1663
- if (rawConnectors.googleDrive !== void 0 && (rawConnectors.googleDrive === null || typeof rawConnectors.googleDrive !== "object" || Array.isArray(rawConnectors.googleDrive))) {
1664
- throw new Error(
1665
- `connectors.googleDrive must be an object (got ${JSON.stringify(rawConnectors.googleDrive)}).`
1666
- );
1667
- }
1668
- const rawDrive = rawConnectors.googleDrive && typeof rawConnectors.googleDrive === "object" && !Array.isArray(rawConnectors.googleDrive) ? rawConnectors.googleDrive : {};
1669
- const driveEnabled = coerceBool(rawDrive.enabled) === true;
1670
- const driveClientId = typeof rawDrive.clientId === "string" ? rawDrive.clientId : "";
1671
- const driveClientSecret = typeof rawDrive[CLIENT_SECRET_FIELD] === "string" ? rawDrive[CLIENT_SECRET_FIELD] : "";
1672
- const driveRefreshToken = typeof rawDrive[REFRESH_TOKEN_FIELD] === "string" ? rawDrive[REFRESH_TOKEN_FIELD] : "";
1673
- const drivePollCoerced = coerceNumber(rawDrive.pollIntervalMs);
1674
- let drivePollIntervalMs = 3e5;
1675
- if (drivePollCoerced !== void 0) {
1676
- if (!Number.isFinite(drivePollCoerced) || !Number.isInteger(drivePollCoerced) || drivePollCoerced < 1e3 || drivePollCoerced > 864e5) {
1677
- throw new Error(
1678
- `connectors.googleDrive.pollIntervalMs must be an integer in [1000, 86400000] ms (got ${JSON.stringify(rawDrive.pollIntervalMs)})`
1679
- );
1680
- }
1681
- drivePollIntervalMs = drivePollCoerced;
1682
- }
1683
- let driveFolderIds = [];
1684
- if (rawDrive.folderIds !== void 0) {
1685
- if (!Array.isArray(rawDrive.folderIds)) {
1686
- throw new Error(
1687
- `connectors.googleDrive.folderIds must be an array of strings (got ${typeof rawDrive.folderIds})`
1688
- );
1689
- }
1690
- const seen = /* @__PURE__ */ new Set();
1691
- for (const value of rawDrive.folderIds) {
1692
- if (typeof value !== "string") {
1693
- throw new Error(
1694
- `connectors.googleDrive.folderIds entries must be strings; found ${typeof value}`
1695
- );
1696
- }
1697
- const trimmed = value.trim();
1698
- if (trimmed.length === 0) continue;
1699
- if (seen.has(trimmed)) continue;
1700
- seen.add(trimmed);
1701
- driveFolderIds.push(trimmed);
1702
- }
1703
- }
1704
- if (rawConnectors.notion !== void 0 && (rawConnectors.notion === null || typeof rawConnectors.notion !== "object" || Array.isArray(rawConnectors.notion))) {
1705
- throw new Error(
1706
- `connectors.notion must be an object (got ${JSON.stringify(rawConnectors.notion)}).`
1707
- );
1708
- }
1709
- const rawNotion = rawConnectors.notion && typeof rawConnectors.notion === "object" && !Array.isArray(rawConnectors.notion) ? rawConnectors.notion : {};
1710
- const notionEnabled = coerceBool(rawNotion.enabled) === true;
1711
- const notionToken = typeof rawNotion.token === "string" ? rawNotion.token : "";
1712
- const notionPollCoerced = coerceNumber(rawNotion.pollIntervalMs);
1713
- let notionPollIntervalMs = 3e5;
1714
- if (notionPollCoerced !== void 0) {
1715
- if (!Number.isFinite(notionPollCoerced) || !Number.isInteger(notionPollCoerced) || notionPollCoerced < 1e3 || notionPollCoerced > 864e5) {
1716
- throw new Error(
1717
- `connectors.notion.pollIntervalMs must be an integer in [1000, 86400000] ms (got ${JSON.stringify(rawNotion.pollIntervalMs)})`
1718
- );
1719
- }
1720
- notionPollIntervalMs = notionPollCoerced;
1721
- }
1722
- let notionDatabaseIds = [];
1723
- if (rawNotion.databaseIds !== void 0) {
1724
- if (!Array.isArray(rawNotion.databaseIds)) {
1725
- throw new Error(
1726
- `connectors.notion.databaseIds must be an array of strings (got ${typeof rawNotion.databaseIds})`
1727
- );
1728
- }
1729
- const seen = /* @__PURE__ */ new Set();
1730
- for (const value of rawNotion.databaseIds) {
1731
- if (typeof value !== "string") {
1732
- throw new Error(
1733
- `connectors.notion.databaseIds entries must be strings; found ${typeof value}`
1734
- );
1735
- }
1736
- const trimmed = value.trim();
1737
- if (trimmed.length === 0) continue;
1738
- if (seen.has(trimmed)) continue;
1739
- seen.add(trimmed);
1740
- notionDatabaseIds.push(trimmed);
1741
- }
1742
- }
1743
- if (rawConnectors.gmail !== void 0 && (rawConnectors.gmail === null || typeof rawConnectors.gmail !== "object" || Array.isArray(rawConnectors.gmail))) {
1744
- throw new Error(
1745
- `connectors.gmail must be an object (got ${JSON.stringify(rawConnectors.gmail)}).`
1746
- );
1747
- }
1748
- const rawGmail = rawConnectors.gmail && typeof rawConnectors.gmail === "object" && !Array.isArray(rawConnectors.gmail) ? rawConnectors.gmail : {};
1749
- const gmailEnabled = coerceBool(rawGmail.enabled) === true;
1750
- const gmailClientId = typeof rawGmail.clientId === "string" ? rawGmail.clientId : "";
1751
- const gmailClientSecret = typeof rawGmail[CLIENT_SECRET_FIELD] === "string" ? rawGmail[CLIENT_SECRET_FIELD] : "";
1752
- const gmailRefreshToken = typeof rawGmail[REFRESH_TOKEN_FIELD] === "string" ? rawGmail[REFRESH_TOKEN_FIELD] : "";
1753
- const gmailUserId = typeof rawGmail.userId === "string" && rawGmail.userId.trim().length > 0 ? rawGmail.userId.trim() : "me";
1754
- const gmailQuery = typeof rawGmail.query === "string" ? rawGmail.query : "in:inbox";
1755
- const gmailPollCoerced = coerceNumber(rawGmail.pollIntervalMs);
1756
- let gmailPollIntervalMs = 3e5;
1757
- if (rawGmail.pollIntervalMs !== void 0) {
1758
- if (gmailPollCoerced === void 0) {
1759
- throw new Error(
1760
- `connectors.gmail.pollIntervalMs must be a finite number; got ${JSON.stringify(rawGmail.pollIntervalMs)}`
1761
- );
1762
- }
1763
- if (gmailPollCoerced <= 0) {
1764
- throw new Error(
1765
- `connectors.gmail.pollIntervalMs must be positive; got ${JSON.stringify(rawGmail.pollIntervalMs)}`
1766
- );
1767
- }
1768
- if (!Number.isInteger(gmailPollCoerced) || gmailPollCoerced < 1e3 || gmailPollCoerced > 864e5) {
1769
- throw new Error(
1770
- `connectors.gmail.pollIntervalMs must be an integer in [1000, 86400000] ms (got ${JSON.stringify(rawGmail.pollIntervalMs)})`
1771
- );
1772
- }
1773
- gmailPollIntervalMs = gmailPollCoerced;
1774
- }
1775
- if (rawConnectors.github !== void 0 && (rawConnectors.github === null || typeof rawConnectors.github !== "object" || Array.isArray(rawConnectors.github))) {
1776
- throw new Error(
1777
- `connectors.github must be an object (got ${JSON.stringify(rawConnectors.github)}).`
1778
- );
1779
- }
1780
- const rawGitHub = rawConnectors.github && typeof rawConnectors.github === "object" && !Array.isArray(rawConnectors.github) ? rawConnectors.github : {};
1781
- const githubEnabled = coerceBool(rawGitHub.enabled) === true;
1782
- const githubToken = typeof rawGitHub.token === "string" ? rawGitHub.token : "";
1783
- const githubUserLogin = typeof rawGitHub.userLogin === "string" ? rawGitHub.userLogin : "";
1784
- const githubPollCoerced = coerceNumber(rawGitHub.pollIntervalMs);
1785
- let githubPollIntervalMs = 3e5;
1786
- if (githubPollCoerced !== void 0) {
1787
- if (!Number.isFinite(githubPollCoerced) || !Number.isInteger(githubPollCoerced) || githubPollCoerced < 1e3 || githubPollCoerced > 864e5) {
1788
- throw new Error(
1789
- `connectors.github.pollIntervalMs must be an integer in [1000, 86400000] ms (got ${JSON.stringify(rawGitHub.pollIntervalMs)})`
1790
- );
1791
- }
1792
- githubPollIntervalMs = githubPollCoerced;
1793
- }
1794
- let githubRepos = [];
1795
- if (rawGitHub.repos !== void 0) {
1796
- if (!Array.isArray(rawGitHub.repos)) {
1797
- throw new Error(
1798
- `connectors.github.repos must be an array of strings (got ${typeof rawGitHub.repos})`
1799
- );
1800
- }
1801
- const seen = /* @__PURE__ */ new Set();
1802
- for (const value of rawGitHub.repos) {
1803
- if (typeof value !== "string") {
1804
- throw new Error(
1805
- `connectors.github.repos entries must be strings; found ${typeof value}`
1806
- );
1807
- }
1808
- const trimmed = value.trim();
1809
- if (trimmed.length === 0) continue;
1810
- if (seen.has(trimmed)) continue;
1811
- seen.add(trimmed);
1812
- githubRepos.push(trimmed);
1813
- }
1814
- }
1815
- const githubIncludeDiscussions = coerceBool(rawGitHub.includeDiscussions) === true;
1816
- return {
1817
- googleDrive: {
1818
- enabled: driveEnabled,
1819
- clientId: driveClientId,
1820
- [CLIENT_SECRET_FIELD]: driveClientSecret,
1821
- [REFRESH_TOKEN_FIELD]: driveRefreshToken,
1822
- pollIntervalMs: drivePollIntervalMs,
1823
- folderIds: driveFolderIds
1824
- },
1825
- notion: {
1826
- enabled: notionEnabled,
1827
- token: notionToken,
1828
- databaseIds: notionDatabaseIds,
1829
- pollIntervalMs: notionPollIntervalMs
1830
- },
1831
- gmail: {
1832
- enabled: gmailEnabled,
1833
- clientId: gmailClientId,
1834
- [CLIENT_SECRET_FIELD]: gmailClientSecret,
1835
- [REFRESH_TOKEN_FIELD]: gmailRefreshToken,
1836
- userId: gmailUserId,
1837
- query: gmailQuery,
1838
- pollIntervalMs: gmailPollIntervalMs
1839
- },
1840
- github: {
1841
- enabled: githubEnabled,
1842
- token: githubToken,
1843
- userLogin: githubUserLogin,
1844
- repos: githubRepos,
1845
- pollIntervalMs: githubPollIntervalMs,
1846
- includeDiscussions: githubIncludeDiscussions
1847
- }
1848
- };
1849
- })(),
1850
- // MECE Taxonomy (#366)
1851
- // Coerce string booleans from CLI (e.g. --config taxonomyEnabled=true) — gotcha #36
1852
- taxonomyEnabled: coerceBool(cfg.taxonomyEnabled) ?? false,
1853
- taxonomyAutoGenResolver: coerceBool(cfg.taxonomyAutoGenResolver) ?? true,
1854
- // Codex CLI — native memory materialization (#378)
1855
- codexMaterializeMemories: cfg.codexMaterializeMemories !== false,
1856
- codexMaterializeNamespace: typeof cfg.codexMaterializeNamespace === "string" && cfg.codexMaterializeNamespace.trim().length > 0 ? cfg.codexMaterializeNamespace.trim() : "auto",
1857
- codexMaterializeMaxSummaryTokens: typeof cfg.codexMaterializeMaxSummaryTokens === "number" ? Math.max(0, Math.floor(cfg.codexMaterializeMaxSummaryTokens)) : 4500,
1858
- codexMaterializeRolloutRetentionDays: typeof cfg.codexMaterializeRolloutRetentionDays === "number" ? Math.max(0, Math.floor(cfg.codexMaterializeRolloutRetentionDays)) : 30,
1859
- codexMaterializeOnConsolidation: cfg.codexMaterializeOnConsolidation !== false,
1860
- codexMaterializeOnSessionEnd: cfg.codexMaterializeOnSessionEnd !== false,
1861
- // Codex CLI — marketplace integration (#418)
1862
- codexMarketplaceEnabled: cfg.codexMarketplaceEnabled !== false,
1863
- // default: true
1864
- // Page-level versioning (issue #371). Issue #678 PR 2/4:
1865
- // dreams.phases.deepSleep.* WINS over legacy keys.
1866
- versioningEnabled: dreamsDeepSleep.enabled && dreamsDeepSleep.versioningEnabled,
1867
- versioningMaxPerPage: dreamsDeepSleep.versioningMaxPerPage,
1868
- versioningSidecarDir: typeof cfg.versioningSidecarDir === "string" && cfg.versioningSidecarDir.trim().length > 0 ? cfg.versioningSidecarDir.trim() : ".versions",
1869
- // Binary file lifecycle management (#367)
1870
- binaryLifecycleEnabled: cfg.binaryLifecycleEnabled === true,
1871
- binaryLifecycleGracePeriodDays: typeof cfg.binaryLifecycleGracePeriodDays === "number" ? Math.max(0, Math.floor(cfg.binaryLifecycleGracePeriodDays)) : 7,
1872
- binaryLifecycleBackendType: (() => {
1873
- const valid = ["filesystem", "s3", "none"];
1874
- const raw2 = cfg.binaryLifecycleBackendType;
1875
- if (typeof raw2 === "string" && valid.includes(raw2)) {
1876
- return raw2;
1877
- }
1878
- return "none";
1879
- })(),
1880
- binaryLifecycleBackendPath: typeof cfg.binaryLifecycleBackendPath === "string" ? cfg.binaryLifecycleBackendPath.trim() : "",
1881
- // Codex citation parity (issue #379)
1882
- citationsEnabled: cfg.citationsEnabled === true,
1883
- citationsAutoDetect: cfg.citationsAutoDetect !== false,
1884
- // External enrichment pipeline (issue #365)
1885
- enrichmentEnabled: cfg.enrichmentEnabled === true,
1886
- enrichmentAutoOnCreate: cfg.enrichmentAutoOnCreate === true,
1887
- enrichmentMaxCandidatesPerEntity: typeof cfg.enrichmentMaxCandidatesPerEntity === "number" ? Math.max(0, Math.floor(cfg.enrichmentMaxCandidatesPerEntity)) : 20,
1888
- // Memory extensions discovery (#382)
1889
- memoryExtensionsEnabled: cfg.memoryExtensionsEnabled !== false,
1890
- memoryExtensionsRoot: typeof cfg.memoryExtensionsRoot === "string" && cfg.memoryExtensionsRoot.trim().length > 0 ? cfg.memoryExtensionsRoot.trim() : ""
1891
- };
1892
- }
1893
- function parseBriefingConfig(raw) {
1894
- const entry = raw && typeof raw === "object" && !Array.isArray(raw) ? raw : {};
1895
- const defaultFormat = entry.defaultFormat === "json" || entry.defaultFormat === "markdown" ? entry.defaultFormat : "markdown";
1896
- const maxFollowupsRaw = typeof entry.maxFollowups === "number" && Number.isFinite(entry.maxFollowups) ? Math.floor(entry.maxFollowups) : 5;
1897
- const maxFollowups = Math.max(0, Math.min(10, maxFollowupsRaw));
1898
- return {
1899
- enabled: entry.enabled !== false,
1900
- defaultWindow: typeof entry.defaultWindow === "string" && entry.defaultWindow.trim().length > 0 ? entry.defaultWindow.trim() : "yesterday",
1901
- defaultFormat,
1902
- maxFollowups,
1903
- calendarSource: typeof entry.calendarSource === "string" && entry.calendarSource.trim().length > 0 ? entry.calendarSource.trim() : null,
1904
- saveByDefault: entry.saveByDefault === true,
1905
- saveDir: typeof entry.saveDir === "string" && entry.saveDir.trim().length > 0 ? entry.saveDir.trim() : null,
1906
- llmFollowups: entry.llmFollowups !== false
1907
- };
1908
- }
1909
- function clampNonNegativeNumber(value) {
1910
- if (typeof value !== "number" || !Number.isFinite(value)) return void 0;
1911
- return Math.max(0, Math.floor(value));
1912
- }
1913
- function coerceNonNegativeInt(value, fallback, keyName) {
1914
- if (value === void 0 || value === null) return fallback;
1915
- const coerced = coerceNumber(value);
1916
- if (coerced === void 0 || coerced < 0) {
1917
- const label = keyName ? ` (${keyName})` : "";
1918
- throw new Error(
1919
- `config value${label} must be a non-negative finite number; got ${JSON.stringify(value)}`
1920
- );
1921
- }
1922
- return Math.floor(coerced);
1923
- }
1924
- function clampSurpriseThreshold(value, fallback) {
1925
- if (value === void 0) return fallback;
1926
- return Math.min(1, Math.max(0, value));
1927
- }
1928
- function clampSurpriseK(value, fallback) {
1929
- if (value === void 0) return fallback;
1930
- return Math.max(1, Math.floor(value));
1931
- }
1932
- function clampSurpriseRecentMemoryCount(value, fallback) {
1933
- if (value === void 0) return fallback;
1934
- return Math.max(0, Math.floor(value));
1935
- }
1936
- function clampSurpriseProbeTimeoutMs(value, fallback) {
1937
- if (value === void 0) return fallback;
1938
- return Math.max(1, Math.floor(value));
1939
- }
1940
- function parseRecallSectionEntry(raw) {
1941
- const entry = raw && typeof raw === "object" && !Array.isArray(raw) ? raw : {};
1942
- return {
1943
- id: typeof entry.id === "string" ? entry.id.trim() : "",
1944
- enabled: entry.enabled !== false,
1945
- maxChars: entry.maxChars === null ? null : clampNonNegativeNumber(entry.maxChars),
1946
- maxHints: clampNonNegativeNumber(entry.maxHints),
1947
- maxSupportingFacts: clampNonNegativeNumber(entry.maxSupportingFacts),
1948
- maxRelatedEntities: clampNonNegativeNumber(entry.maxRelatedEntities),
1949
- consolidateTriggerLines: clampNonNegativeNumber(entry.consolidateTriggerLines),
1950
- consolidateTargetLines: clampNonNegativeNumber(entry.consolidateTargetLines),
1951
- maxEntities: clampNonNegativeNumber(entry.maxEntities),
1952
- maxResults: clampNonNegativeNumber(entry.maxResults),
1953
- recentTurns: clampNonNegativeNumber(entry.recentTurns),
1954
- maxTurns: clampNonNegativeNumber(entry.maxTurns),
1955
- maxTokens: clampNonNegativeNumber(entry.maxTokens),
1956
- lookbackHours: clampNonNegativeNumber(entry.lookbackHours),
1957
- maxCount: clampNonNegativeNumber(entry.maxCount),
1958
- topK: clampNonNegativeNumber(entry.topK),
1959
- timeoutMs: clampNonNegativeNumber(entry.timeoutMs),
1960
- maxPatterns: clampNonNegativeNumber(entry.maxPatterns),
1961
- maxRubrics: clampNonNegativeNumber(entry.maxRubrics)
1962
- };
1963
- }
1964
- function buildDefaultRecallPipeline(cfg) {
1965
- return [
1966
- {
1967
- id: "shared-context",
1968
- enabled: cfg.sharedContextEnabled === true,
1969
- maxChars: typeof cfg.sharedContextMaxInjectChars === "number" ? Math.max(0, Math.floor(cfg.sharedContextMaxInjectChars)) : 4e3
1970
- },
1971
- {
1972
- id: "explicit-cue",
1973
- enabled: coerceBool(cfg.explicitCueRecallEnabled) === true,
1974
- maxChars: coerceNumber(cfg.explicitCueRecallMaxChars) !== void 0 ? Math.max(0, Math.floor(coerceNumber(cfg.explicitCueRecallMaxChars))) : 2400,
1975
- maxResults: coerceNumber(cfg.explicitCueRecallMaxReferences) !== void 0 ? Math.max(0, Math.floor(coerceNumber(cfg.explicitCueRecallMaxReferences))) : 24
1976
- },
1977
- {
1978
- id: "profile",
1979
- enabled: true,
1980
- consolidateTriggerLines: 100,
1981
- consolidateTargetLines: 50
1982
- },
1983
- {
1984
- id: "identity-continuity",
1985
- enabled: cfg.identityContinuityEnabled === true
1986
- },
1987
- {
1988
- id: "entity-retrieval",
1989
- enabled: cfg.entityRetrievalEnabled !== false,
1990
- maxChars: typeof cfg.entityRetrievalMaxChars === "number" ? Math.max(0, Math.floor(cfg.entityRetrievalMaxChars)) : 2400,
1991
- maxHints: typeof cfg.entityRetrievalMaxHints === "number" ? Math.max(0, Math.floor(cfg.entityRetrievalMaxHints)) : 2,
1992
- maxSupportingFacts: typeof cfg.entityRetrievalMaxSupportingFacts === "number" ? Math.max(0, Math.floor(cfg.entityRetrievalMaxSupportingFacts)) : 6,
1993
- maxRelatedEntities: typeof cfg.entityRetrievalMaxRelatedEntities === "number" ? Math.max(0, Math.floor(cfg.entityRetrievalMaxRelatedEntities)) : 3,
1994
- recentTurns: typeof cfg.entityRetrievalRecentTurns === "number" ? Math.max(0, Math.floor(cfg.entityRetrievalRecentTurns)) : 6
1995
- },
1996
- {
1997
- id: "knowledge-index",
1998
- enabled: cfg.knowledgeIndexEnabled !== false,
1999
- maxChars: typeof cfg.knowledgeIndexMaxChars === "number" ? Math.max(0, Math.floor(cfg.knowledgeIndexMaxChars)) : 4e3,
2000
- maxEntities: typeof cfg.knowledgeIndexMaxEntities === "number" ? Math.max(0, Math.floor(cfg.knowledgeIndexMaxEntities)) : 40
2001
- },
2002
- { id: "verbatim-artifacts", enabled: cfg.verbatimArtifactsEnabled === true },
2003
- {
2004
- id: "procedure-recall",
2005
- // Default-on since issue #567 PR 4/5: the master `procedural.enabled`
2006
- // gate now defaults to `true` when the key is omitted, so the recall
2007
- // pipeline must stay in sync. Explicit `false` (or any coerceBool
2008
- // falsy variant) still disables recall injection.
2009
- //
2010
- // CLAUDE.md rule 48 (least-privileged defaults) + Cursor review on #609:
2011
- // never fail open on unrecognized values. Only `coerced === true` or
2012
- // the "key omitted" path enables the section. `parseConfig` throws
2013
- // on invalid values upstream, so this branch only ever sees boolean
2014
- // results — `coerced === undefined` should never happen in practice,
2015
- // but defense-in-depth keeps the section disabled if it ever does.
2016
- enabled: (() => {
2017
- const proceduralRaw = typeof cfg.procedural === "object" && cfg.procedural !== null && !Array.isArray(cfg.procedural) ? cfg.procedural : void 0;
2018
- if (proceduralRaw === void 0) return true;
2019
- const rawEnabled = proceduralRaw.enabled;
2020
- if (rawEnabled === void 0) return true;
2021
- return coerceBool(rawEnabled) === true;
2022
- })(),
2023
- maxChars: 2400
2024
- },
2025
- { id: "memory-boxes", enabled: cfg.memoryBoxesEnabled === true },
2026
- { id: "temporal-memory-tree", enabled: cfg.temporalMemoryTreeEnabled === true },
2027
- { id: "lcm-compressed-history", enabled: cfg.lcmEnabled === true },
2028
- {
2029
- id: "objective-state",
2030
- enabled: cfg.objectiveStateRecallEnabled === true,
2031
- maxResults: 4,
2032
- maxChars: 1800
2033
- },
2034
- {
2035
- id: "causal-trajectories",
2036
- enabled: cfg.causalTrajectoryRecallEnabled === true,
2037
- maxResults: 3,
2038
- maxChars: 2200
2039
- },
2040
- {
2041
- id: "trust-zones",
2042
- enabled: cfg.trustZoneRecallEnabled === true,
2043
- maxResults: 3,
2044
- maxChars: 1800
2045
- },
2046
- {
2047
- id: "harmonic-retrieval",
2048
- enabled: cfg.harmonicRetrievalEnabled === true,
2049
- maxResults: 3,
2050
- maxChars: 2200
2051
- },
2052
- {
2053
- id: "verified-episodes",
2054
- enabled: cfg.verifiedRecallEnabled === true,
2055
- maxResults: 3,
2056
- maxChars: 1800
2057
- },
2058
- {
2059
- id: "verified-rules",
2060
- enabled: cfg.semanticRuleVerificationEnabled === true,
2061
- maxResults: 3,
2062
- maxChars: 1800
2063
- },
2064
- {
2065
- id: "work-products",
2066
- enabled: cfg.workProductRecallEnabled === true,
2067
- maxResults: 3,
2068
- maxChars: 1800
2069
- },
2070
- {
2071
- id: "memories",
2072
- enabled: true,
2073
- maxResults: typeof cfg.qmdMaxResults === "number" ? Math.max(0, Math.floor(cfg.qmdMaxResults)) : 8
2074
- },
2075
- {
2076
- id: "compression-guidelines",
2077
- enabled: cfg.compressionGuidelineLearningEnabled === true
2078
- },
2079
- {
2080
- id: "native-knowledge",
2081
- enabled: cfg.nativeKnowledge && typeof cfg.nativeKnowledge === "object" ? cfg.nativeKnowledge.enabled === true : false,
2082
- maxResults: cfg.nativeKnowledge && typeof cfg.nativeKnowledge === "object" && typeof cfg.nativeKnowledge.maxResults === "number" ? Math.max(0, Math.floor(cfg.nativeKnowledge.maxResults)) : 4,
2083
- maxChars: cfg.nativeKnowledge && typeof cfg.nativeKnowledge === "object" && typeof cfg.nativeKnowledge.maxChars === "number" ? Math.max(0, Math.floor(cfg.nativeKnowledge.maxChars)) : 2400
2084
- },
2085
- {
2086
- id: "transcript",
2087
- enabled: cfg.transcriptEnabled !== false,
2088
- maxTurns: typeof cfg.maxTranscriptTurns === "number" ? Math.max(0, Math.floor(cfg.maxTranscriptTurns)) : 50,
2089
- maxTokens: typeof cfg.maxTranscriptTokens === "number" ? Math.max(0, Math.floor(cfg.maxTranscriptTokens)) : 1e3,
2090
- lookbackHours: typeof cfg.transcriptRecallHours === "number" ? Math.max(0, Math.floor(cfg.transcriptRecallHours)) : 12
2091
- },
2092
- {
2093
- id: "summaries",
2094
- enabled: cfg.hourlySummariesEnabled !== false,
2095
- maxCount: typeof cfg.maxSummaryCount === "number" ? Math.max(0, Math.floor(cfg.maxSummaryCount)) : 6,
2096
- lookbackHours: typeof cfg.summaryRecallHours === "number" ? Math.max(0, Math.floor(cfg.summaryRecallHours)) : 24
2097
- },
2098
- {
2099
- id: "conversation-recall",
2100
- enabled: cfg.conversationIndexEnabled === true,
2101
- topK: typeof cfg.conversationRecallTopK === "number" ? Math.max(0, Math.floor(cfg.conversationRecallTopK)) : 3,
2102
- maxChars: typeof cfg.conversationRecallMaxChars === "number" ? Math.max(0, Math.floor(cfg.conversationRecallMaxChars)) : 2500,
2103
- timeoutMs: typeof cfg.conversationRecallTimeoutMs === "number" ? Math.max(0, Math.floor(cfg.conversationRecallTimeoutMs)) : 800
2104
- },
2105
- {
2106
- id: "compounding",
2107
- enabled: cfg.compoundingEnabled === true && cfg.compoundingInjectEnabled !== false,
2108
- maxPatterns: 40,
2109
- maxRubrics: 4
2110
- },
2111
- { id: "questions", enabled: cfg.injectQuestions === true }
2112
- ];
2113
- }
2114
- function buildRecallPipelineConfig(cfg) {
2115
- const maxMemoryTokens = typeof cfg.maxMemoryTokens === "number" ? Math.max(0, Math.floor(cfg.maxMemoryTokens)) : 2e3;
2116
- const recallBudgetCharsRaw = clampNonNegativeNumber(cfg.recallBudgetChars);
2117
- const recallBudgetChars = recallBudgetCharsRaw ?? maxMemoryTokens * 4;
2118
- const rawPipeline = cfg.recallPipeline;
2119
- const pipeline = Array.isArray(rawPipeline) ? rawPipeline.map(parseRecallSectionEntry).filter((entry) => entry.id.length > 0) : buildDefaultRecallPipeline(cfg);
2120
- return { recallBudgetChars, pipeline };
2121
- }
2122
-
2123
- export {
2124
- coerceInstallExtension,
2125
- DEFAULT_REASONING_MODEL,
2126
- VALID_MEMORY_CATEGORIES,
2127
- parseConfig
2128
- };
2129
- //# sourceMappingURL=chunk-6Z6UH6TK.js.map