@remnic/core 1.1.12 → 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 (1324) hide show
  1. package/dist/access-cli.d.ts +2 -1
  2. package/dist/access-cli.js +263 -82
  3. package/dist/access-cli.js.map +1 -1
  4. package/dist/access-http.d.ts +26 -60
  5. package/dist/access-http.js +43 -29
  6. package/dist/access-mcp.d.ts +24 -6
  7. package/dist/access-mcp.js +35 -28
  8. package/dist/access-schema.d.ts +9 -6
  9. package/dist/access-schema.js +7 -5
  10. package/dist/access-service-DcCDmNYC.d.ts +1542 -0
  11. package/dist/access-service.d.ts +25 -7
  12. package/dist/access-service.js +33 -26
  13. package/dist/active-memory-bridge.js +2 -2
  14. package/dist/active-recall.js +11 -3
  15. package/dist/active-recall.js.map +1 -1
  16. package/dist/adapters/claude-code.d.ts +24 -0
  17. package/dist/adapters/claude-code.js +9 -0
  18. package/dist/adapters/codex.d.ts +25 -0
  19. package/dist/adapters/codex.js +9 -0
  20. package/dist/adapters/hermes.d.ts +35 -0
  21. package/dist/adapters/hermes.js +9 -0
  22. package/dist/adapters/index.d.ts +6 -0
  23. package/dist/adapters/index.js +26 -0
  24. package/dist/adapters/registry.d.ts +20 -0
  25. package/dist/adapters/registry.js +13 -0
  26. package/dist/adapters/replit.d.ts +28 -0
  27. package/dist/adapters/replit.js +9 -0
  28. package/dist/adapters/types.d.ts +43 -0
  29. package/dist/adapters/types.js +8 -0
  30. package/dist/bootstrap.d.ts +20 -5
  31. package/dist/boxes.d.ts +7 -0
  32. package/dist/boxes.js +1 -1
  33. package/dist/briefing.d.ts +5 -3
  34. package/dist/briefing.js +9 -6
  35. package/dist/buffer-surprise-report.js +1 -1
  36. package/dist/buffer.d.ts +18 -4
  37. package/dist/buffer.js +1 -1
  38. package/dist/calibration.js +4 -4
  39. package/dist/capsule-cli.d.ts +4 -4
  40. package/dist/capsule-cli.js +1 -1
  41. package/dist/capsule-crypto-5CYAGVC5.js +18 -0
  42. package/dist/capsule-merge-4MGKE7C5.js +189 -0
  43. package/dist/causal-behavior.d.ts +8 -28
  44. package/dist/causal-behavior.js +6 -3
  45. package/dist/causal-behavior.js.map +1 -1
  46. package/dist/causal-chain.js +3 -2
  47. package/dist/causal-consolidation.d.ts +1 -1
  48. package/dist/causal-consolidation.js +24 -13
  49. package/dist/causal-consolidation.js.map +1 -1
  50. package/dist/causal-retrieval.js +3 -3
  51. package/dist/causal-trajectory.js +1 -1
  52. package/dist/chunk-25MQ7IHJ.js +427 -0
  53. package/dist/chunk-25MQ7IHJ.js.map +1 -0
  54. package/dist/chunk-2F2W355T.js +256 -0
  55. package/dist/chunk-2F2W355T.js.map +1 -0
  56. package/dist/chunk-2KI4QFHU.js +228 -0
  57. package/dist/chunk-2KI4QFHU.js.map +1 -0
  58. package/dist/chunk-2PRQG7PV.js +86 -0
  59. package/dist/chunk-2PRQG7PV.js.map +1 -0
  60. package/dist/chunk-2QR3XXIC.js +2272 -0
  61. package/dist/chunk-2QR3XXIC.js.map +1 -0
  62. package/dist/chunk-2WWLHTZY.js +121 -0
  63. package/dist/chunk-326G7DJK.js +2185 -0
  64. package/dist/chunk-326G7DJK.js.map +1 -0
  65. package/dist/chunk-34DQE4KF.js +174 -0
  66. package/dist/chunk-34DQE4KF.js.map +1 -0
  67. package/dist/chunk-3APJ5EVB.js +601 -0
  68. package/dist/chunk-3APJ5EVB.js.map +1 -0
  69. package/dist/chunk-3HPAPHUK.js +51 -0
  70. package/dist/chunk-3HPAPHUK.js.map +1 -0
  71. package/dist/chunk-3JXBXXM2.js +69 -0
  72. package/dist/chunk-3JXBXXM2.js.map +1 -0
  73. package/dist/chunk-3KW65B36.js +681 -0
  74. package/dist/chunk-3KW65B36.js.map +1 -0
  75. package/dist/chunk-3UXOZBHV.js +20 -0
  76. package/dist/chunk-3UXOZBHV.js.map +1 -0
  77. package/dist/chunk-3VAL7ZL2.js +266 -0
  78. package/dist/chunk-3VAL7ZL2.js.map +1 -0
  79. package/dist/chunk-3Y4P7RXM.js +31 -0
  80. package/dist/chunk-3Y4P7RXM.js.map +1 -0
  81. package/dist/chunk-47VWKCAF.js +273 -0
  82. package/dist/chunk-47VWKCAF.js.map +1 -0
  83. package/dist/chunk-4CRG46BG.js +271 -0
  84. package/dist/chunk-5375UYTQ.js +914 -0
  85. package/dist/chunk-5375UYTQ.js.map +1 -0
  86. package/dist/chunk-56K5QLHX.js +506 -0
  87. package/dist/chunk-56K5QLHX.js.map +1 -0
  88. package/dist/chunk-5RGLBDQF.js +596 -0
  89. package/dist/chunk-5RGLBDQF.js.map +1 -0
  90. package/dist/chunk-5UZXUTVO.js +9 -0
  91. package/dist/chunk-5UZXUTVO.js.map +1 -0
  92. package/dist/chunk-65PG43EQ.js +105 -0
  93. package/dist/chunk-65PG43EQ.js.map +1 -0
  94. package/dist/chunk-66DHUKLO.js +57 -0
  95. package/dist/chunk-66DHUKLO.js.map +1 -0
  96. package/dist/chunk-6FC5EGNV.js +46 -0
  97. package/dist/chunk-6FC5EGNV.js.map +1 -0
  98. package/dist/chunk-6H2TESSP.js +62 -0
  99. package/dist/chunk-6H2TESSP.js.map +1 -0
  100. package/dist/chunk-6LVVDPJ4.js +32 -0
  101. package/dist/chunk-6LVVDPJ4.js.map +1 -0
  102. package/dist/chunk-6RVI47ZR.js +159 -0
  103. package/dist/chunk-6RVI47ZR.js.map +1 -0
  104. package/dist/chunk-7AAT6G4Q.js +5117 -0
  105. package/dist/chunk-7AAT6G4Q.js.map +1 -0
  106. package/dist/chunk-7DTASS5T.js +29 -0
  107. package/dist/chunk-7DTASS5T.js.map +1 -0
  108. package/dist/chunk-7IASACLB.js +596 -0
  109. package/dist/chunk-7MNMYOFP.js +32 -0
  110. package/dist/chunk-7MNMYOFP.js.map +1 -0
  111. package/dist/chunk-7N4KAIGN.js +133 -0
  112. package/dist/chunk-7N4KAIGN.js.map +1 -0
  113. package/dist/chunk-7OZ53EXP.js +101 -0
  114. package/dist/chunk-7OZ53EXP.js.map +1 -0
  115. package/dist/chunk-7XYTQGCC.js +134 -0
  116. package/dist/chunk-7XYTQGCC.js.map +1 -0
  117. package/dist/chunk-A2XUIMJ3.js +341 -0
  118. package/dist/chunk-A2XUIMJ3.js.map +1 -0
  119. package/dist/chunk-AGZQD76C.js +201 -0
  120. package/dist/chunk-AGZQD76C.js.map +1 -0
  121. package/dist/chunk-APO3DCMU.js +361 -0
  122. package/dist/chunk-APO3DCMU.js.map +1 -0
  123. package/dist/chunk-BFBF3XEF.js +283 -0
  124. package/dist/chunk-BFBF3XEF.js.map +1 -0
  125. package/dist/chunk-BJ3KMYTB.js +1974 -0
  126. package/dist/chunk-BJ3KMYTB.js.map +1 -0
  127. package/dist/chunk-CHEL3SKB.js +6758 -0
  128. package/dist/chunk-CHEL3SKB.js.map +1 -0
  129. package/dist/chunk-CQZRLNMV.js +1491 -0
  130. package/dist/chunk-CQZRLNMV.js.map +1 -0
  131. package/dist/chunk-D46YSIYX.js +892 -0
  132. package/dist/chunk-D46YSIYX.js.map +1 -0
  133. package/dist/chunk-DINWEURR.js +648 -0
  134. package/dist/chunk-DINWEURR.js.map +1 -0
  135. package/dist/chunk-DK5LDEQM.js +530 -0
  136. package/dist/chunk-DK5LDEQM.js.map +1 -0
  137. package/dist/chunk-DOM4GKSW.js +34 -0
  138. package/dist/chunk-DOM4GKSW.js.map +1 -0
  139. package/dist/chunk-EDTHC6UD.js +1075 -0
  140. package/dist/chunk-EFJ3MQ4V.js +721 -0
  141. package/dist/chunk-EHRTFRWW.js +89 -0
  142. package/dist/chunk-EHRTFRWW.js.map +1 -0
  143. package/dist/chunk-FAJ7FZYM.js +11 -0
  144. package/dist/chunk-FAJ7FZYM.js.map +1 -0
  145. package/dist/chunk-FBYESMQ2.js +570 -0
  146. package/dist/chunk-FDU6HUUL.js +147 -0
  147. package/dist/chunk-FF4KLI5W.js +99 -0
  148. package/dist/chunk-FF4KLI5W.js.map +1 -0
  149. package/dist/chunk-FIT6DMX6.js +310 -0
  150. package/dist/chunk-FIT6DMX6.js.map +1 -0
  151. package/dist/chunk-FJ43PRLT.js +272 -0
  152. package/dist/chunk-FJ43PRLT.js.map +1 -0
  153. package/dist/chunk-FKFMOY3N.js +32 -0
  154. package/dist/chunk-FKFMOY3N.js.map +1 -0
  155. package/dist/chunk-FLTNHQK6.js +262 -0
  156. package/dist/chunk-FLTNHQK6.js.map +1 -0
  157. package/dist/chunk-GA454ALV.js +12436 -0
  158. package/dist/chunk-GA454ALV.js.map +1 -0
  159. package/dist/chunk-GGKRUQOO.js +228 -0
  160. package/dist/chunk-GIF42EW3.js +63 -0
  161. package/dist/chunk-GIF42EW3.js.map +1 -0
  162. package/dist/chunk-GL6I6MEQ.js +647 -0
  163. package/dist/chunk-H3ME6L6D.js +709 -0
  164. package/dist/chunk-H3ME6L6D.js.map +1 -0
  165. package/dist/chunk-HHLLAQGZ.js +1 -0
  166. package/dist/chunk-HXXBL2KD.js +2040 -0
  167. package/dist/chunk-I5V2VDIW.js +219 -0
  168. package/dist/chunk-I5V2VDIW.js.map +1 -0
  169. package/dist/chunk-I6K5FBRQ.js +35 -0
  170. package/dist/chunk-I6K5FBRQ.js.map +1 -0
  171. package/dist/chunk-ICRIXAP2.js +121 -0
  172. package/dist/chunk-ICRIXAP2.js.map +1 -0
  173. package/dist/chunk-J4EB7DNW.js +11 -0
  174. package/dist/chunk-J4EB7DNW.js.map +1 -0
  175. package/dist/chunk-JLFA7DQG.js +62 -0
  176. package/dist/chunk-JLFA7DQG.js.map +1 -0
  177. package/dist/chunk-KJTKLXTH.js +9 -0
  178. package/dist/chunk-KJTKLXTH.js.map +1 -0
  179. package/dist/chunk-KLAO5DGL.js +917 -0
  180. package/dist/chunk-KLAO5DGL.js.map +1 -0
  181. package/dist/chunk-KNKUID7G.js +183 -0
  182. package/dist/chunk-KOSORCJG.js +624 -0
  183. package/dist/chunk-KOSORCJG.js.map +1 -0
  184. package/dist/chunk-KUJVMMZQ.js +1262 -0
  185. package/dist/chunk-KUJVMMZQ.js.map +1 -0
  186. package/dist/chunk-LCR46JY5.js +123 -0
  187. package/dist/chunk-LCR46JY5.js.map +1 -0
  188. package/dist/chunk-LLQ2LLWF.js +148 -0
  189. package/dist/chunk-LLQ2LLWF.js.map +1 -0
  190. package/dist/chunk-LPMVBPA3.js +236 -0
  191. package/dist/chunk-LT3NLYSI.js +50 -0
  192. package/dist/chunk-LT3NLYSI.js.map +1 -0
  193. package/dist/chunk-LUDTDZLK.js +287 -0
  194. package/dist/chunk-LUDTDZLK.js.map +1 -0
  195. package/dist/chunk-M23FSH32.js +3963 -0
  196. package/dist/chunk-M23FSH32.js.map +1 -0
  197. package/dist/chunk-MC26UJIM.js +118 -0
  198. package/dist/chunk-ME6ESPZU.js +119 -0
  199. package/dist/chunk-ME6ESPZU.js.map +1 -0
  200. package/dist/chunk-MGKYQQYF.js +272 -0
  201. package/dist/chunk-MJFNCJXV.js +66 -0
  202. package/dist/chunk-MJFNCJXV.js.map +1 -0
  203. package/dist/chunk-MSWG7JI6.js +237 -0
  204. package/dist/chunk-MSWG7JI6.js.map +1 -0
  205. package/dist/chunk-MT25YHYH.js +141 -0
  206. package/dist/chunk-MT25YHYH.js.map +1 -0
  207. package/dist/chunk-MT4HVDUZ.js +53 -0
  208. package/dist/chunk-MY6TPVXW.js +219 -0
  209. package/dist/chunk-N2D6GXBM.js +267 -0
  210. package/dist/chunk-N2D6GXBM.js.map +1 -0
  211. package/dist/chunk-NJ3MJQZX.js +46 -0
  212. package/dist/chunk-NJ3MJQZX.js.map +1 -0
  213. package/dist/chunk-NMZY542O.js +335 -0
  214. package/dist/chunk-NMZY542O.js.map +1 -0
  215. package/dist/chunk-NNVTUXEB.js +23 -0
  216. package/dist/chunk-NZL6GGQE.js +375 -0
  217. package/dist/chunk-NZL6GGQE.js.map +1 -0
  218. package/dist/chunk-P4NEIHUT.js +108 -0
  219. package/dist/chunk-P7FMDTKL.js +103 -0
  220. package/dist/chunk-P7FMDTKL.js.map +1 -0
  221. package/dist/chunk-PHK3HARR.js +32 -0
  222. package/dist/chunk-PHK3HARR.js.map +1 -0
  223. package/dist/chunk-PIRJPV5T.js +98 -0
  224. package/dist/chunk-PIRJPV5T.js.map +1 -0
  225. package/dist/chunk-PK7H5L6Y.js +159 -0
  226. package/dist/chunk-PK7H5L6Y.js.map +1 -0
  227. package/dist/chunk-PR5FBTFU.js +233 -0
  228. package/dist/chunk-PR5FBTFU.js.map +1 -0
  229. package/dist/chunk-PU63GXWS.js +174 -0
  230. package/dist/chunk-PU63GXWS.js.map +1 -0
  231. package/dist/chunk-PZIAX57I.js +124 -0
  232. package/dist/chunk-PZIAX57I.js.map +1 -0
  233. package/dist/chunk-Q7P4WJDP.js +26 -0
  234. package/dist/chunk-Q7P4WJDP.js.map +1 -0
  235. package/dist/chunk-QQUAB63I.js +63 -0
  236. package/dist/chunk-QQUAB63I.js.map +1 -0
  237. package/dist/chunk-QRNI5JBH.js +18 -0
  238. package/dist/chunk-RHY3HH7P.js +601 -0
  239. package/dist/chunk-RHY3HH7P.js.map +1 -0
  240. package/dist/chunk-RRF5UOBJ.js +91 -0
  241. package/dist/chunk-RXDLTSWT.js +124 -0
  242. package/dist/chunk-RXDLTSWT.js.map +1 -0
  243. package/dist/chunk-RYED3SPJ.js +42 -0
  244. package/dist/chunk-RYED3SPJ.js.map +1 -0
  245. package/dist/chunk-S7KDBTWT.js +106 -0
  246. package/dist/chunk-S7KDBTWT.js.map +1 -0
  247. package/dist/chunk-SEDEKFYQ.js +1 -0
  248. package/dist/chunk-TECVW3JP.js +36 -0
  249. package/dist/chunk-TECVW3JP.js.map +1 -0
  250. package/dist/chunk-TFO23QT4.js +88 -0
  251. package/dist/chunk-TFO23QT4.js.map +1 -0
  252. package/dist/chunk-TK4UEOSK.js +76 -0
  253. package/dist/chunk-TK4UEOSK.js.map +1 -0
  254. package/dist/chunk-TKWGAOLV.js +122 -0
  255. package/dist/chunk-TKWGAOLV.js.map +1 -0
  256. package/dist/chunk-TMM4S4IJ.js +597 -0
  257. package/dist/chunk-TMM4S4IJ.js.map +1 -0
  258. package/dist/chunk-TMQLARTH.js +188 -0
  259. package/dist/chunk-TMQLARTH.js.map +1 -0
  260. package/dist/chunk-TPDBFYEG.js +130 -0
  261. package/dist/chunk-TPDBFYEG.js.map +1 -0
  262. package/dist/chunk-TPMQ3G6Z.js +145 -0
  263. package/dist/chunk-TPMQ3G6Z.js.map +1 -0
  264. package/dist/chunk-TZOLIGIG.js +61 -0
  265. package/dist/chunk-TZOLIGIG.js.map +1 -0
  266. package/dist/chunk-U3PN77QT.js +113 -0
  267. package/dist/chunk-U3WSW6PZ.js +277 -0
  268. package/dist/chunk-U4SCL7B7.js +640 -0
  269. package/dist/chunk-U4SCL7B7.js.map +1 -0
  270. package/dist/chunk-UWK5OXUJ.js +156 -0
  271. package/dist/chunk-UWK5OXUJ.js.map +1 -0
  272. package/dist/chunk-UWVJF25J.js +74 -0
  273. package/dist/chunk-UXHQAFNA.js +1317 -0
  274. package/dist/chunk-UXHQAFNA.js.map +1 -0
  275. package/dist/chunk-V5OCT34X.js +1 -0
  276. package/dist/chunk-VLXA6PI2.js +304 -0
  277. package/dist/chunk-VLXA6PI2.js.map +1 -0
  278. package/dist/chunk-VNO6ZJ35.js +500 -0
  279. package/dist/chunk-VNO6ZJ35.js.map +1 -0
  280. package/dist/chunk-VW676BEI.js +827 -0
  281. package/dist/chunk-VW676BEI.js.map +1 -0
  282. package/dist/chunk-W3LR522O.js +2296 -0
  283. package/dist/chunk-W4L6CZKA.js +96 -0
  284. package/dist/chunk-W4L6CZKA.js.map +1 -0
  285. package/dist/chunk-W4RVMTHR.js +372 -0
  286. package/dist/chunk-W4RVMTHR.js.map +1 -0
  287. package/dist/chunk-WEHSQBFR.js +188 -0
  288. package/dist/chunk-WEHSQBFR.js.map +1 -0
  289. package/dist/chunk-WELDCG6C.js +380 -0
  290. package/dist/chunk-WELDCG6C.js.map +1 -0
  291. package/dist/chunk-WZYKANL3.js +2800 -0
  292. package/dist/chunk-WZYKANL3.js.map +1 -0
  293. package/dist/chunk-XIG5PDM7.js +48 -0
  294. package/dist/chunk-XJNBEDFE.js +193 -0
  295. package/dist/chunk-XJNBEDFE.js.map +1 -0
  296. package/dist/chunk-XVVIG67A.js +291 -0
  297. package/dist/chunk-XVVIG67A.js.map +1 -0
  298. package/dist/chunk-XVZ7B3HG.js +135 -0
  299. package/dist/chunk-YBPYIAA5.js +73 -0
  300. package/dist/chunk-YBPYIAA5.js.map +1 -0
  301. package/dist/chunk-Z734BLO3.js +21 -0
  302. package/dist/chunk-Z734BLO3.js.map +1 -0
  303. package/dist/chunk-ZKSK55RC.js +269 -0
  304. package/dist/chunk-ZKSK55RC.js.map +1 -0
  305. package/dist/chunk-ZTFCYYEZ.js +69 -0
  306. package/dist/chunk-ZTFCYYEZ.js.map +1 -0
  307. package/dist/chunk-ZY2MNJR6.js +329 -0
  308. package/dist/chunk-ZY2MNJR6.js.map +1 -0
  309. package/dist/cli-D3VpkVwB.d.ts +1136 -0
  310. package/dist/cli.d.ts +39 -10
  311. package/dist/cli.js +108 -49
  312. package/dist/commitment-ledger.js +1 -1
  313. package/dist/compat/checks.d.ts +5 -0
  314. package/dist/compat/checks.js +11 -0
  315. package/dist/compat/checks.js.map +1 -0
  316. package/dist/compat/types.d.ts +30 -0
  317. package/dist/compat/types.js +1 -0
  318. package/dist/compat/types.js.map +1 -0
  319. package/dist/compounding/engine.d.ts +221 -0
  320. package/dist/compounding/engine.js +32 -0
  321. package/dist/compounding/engine.js.map +1 -0
  322. package/dist/compounding/preference-consolidator.d.ts +92 -0
  323. package/dist/compounding/preference-consolidator.js +553 -0
  324. package/dist/compounding/preference-consolidator.js.map +1 -0
  325. package/dist/config.d.ts +4 -2
  326. package/dist/config.js +9 -4
  327. package/dist/conflict-policy-DyJ2wd-h.d.ts +4 -0
  328. package/dist/connectors/codex-materialize-runner.d.ts +64 -0
  329. package/dist/connectors/codex-materialize-runner.js +33 -0
  330. package/dist/connectors/codex-materialize-runner.js.map +1 -0
  331. package/dist/connectors/codex-materialize.d.ts +195 -0
  332. package/dist/connectors/codex-materialize.js +38 -0
  333. package/dist/connectors/codex-materialize.js.map +1 -0
  334. package/dist/connectors/index.d.ts +444 -0
  335. package/dist/connectors/index.js +115 -0
  336. package/dist/connectors/index.js.map +1 -0
  337. package/dist/connectors-cli-CwbyjGR7.d.ts +257 -0
  338. package/dist/connectors-cli.d.ts +1 -1
  339. package/dist/consolidation-provenance-check.d.ts +3 -1
  340. package/dist/consolidation-undo.d.ts +3 -1
  341. package/dist/contradiction/index.d.ts +258 -0
  342. package/dist/contradiction/index.js +43 -0
  343. package/dist/contradiction/index.js.map +1 -0
  344. package/dist/contradiction-review-ATP4S6IC.js +30 -0
  345. package/dist/contradiction-review-ATP4S6IC.js.map +1 -0
  346. package/dist/contradiction-scan-5A4IDZV5.js +13 -0
  347. package/dist/contradiction-scan-5A4IDZV5.js.map +1 -0
  348. package/dist/conversation-index/backend.d.ts +97 -0
  349. package/dist/conversation-index/backend.js +13 -0
  350. package/dist/conversation-index/backend.js.map +1 -0
  351. package/dist/conversation-index/chunker.d.ts +16 -0
  352. package/dist/conversation-index/chunker.js +8 -0
  353. package/dist/conversation-index/chunker.js.map +1 -0
  354. package/dist/conversation-index/cleanup.d.ts +11 -0
  355. package/dist/conversation-index/cleanup.js +9 -0
  356. package/dist/conversation-index/cleanup.js.map +1 -0
  357. package/dist/conversation-index/faiss-adapter.d.ts +6 -0
  358. package/dist/conversation-index/faiss-adapter.js +16 -0
  359. package/dist/conversation-index/faiss-adapter.js.map +1 -0
  360. package/dist/conversation-index/indexer.d.ts +23 -0
  361. package/dist/conversation-index/indexer.js +15 -0
  362. package/dist/conversation-index/indexer.js.map +1 -0
  363. package/dist/conversation-index/search.d.ts +6 -0
  364. package/dist/conversation-index/search.js +11 -0
  365. package/dist/conversation-index/search.js.map +1 -0
  366. package/dist/embedding-fallback.js +2 -2
  367. package/dist/enrichment/index.d.ts +163 -0
  368. package/dist/enrichment/index.js +18 -0
  369. package/dist/enrichment/index.js.map +1 -0
  370. package/dist/entity-retrieval.d.ts +4 -2
  371. package/dist/entity-retrieval.js +8 -5
  372. package/dist/evals.js +1 -1
  373. package/dist/explicit-capture.d.ts +20 -5
  374. package/dist/explicit-capture.js +2 -2
  375. package/dist/extraction-judge-training.js +1 -1
  376. package/dist/extraction.js +8 -8
  377. package/dist/faiss-adapter-CzPghc4C.d.ts +70 -0
  378. package/dist/fallback-llm.d.ts +2 -0
  379. package/dist/fallback-llm.js +4 -4
  380. package/dist/graph-edge-decay-5DI5GUNL.js +207 -0
  381. package/dist/index.d.ts +66 -711
  382. package/dist/index.js +556 -2680
  383. package/dist/index.js.map +1 -1
  384. package/dist/lcm/archive.d.ts +89 -0
  385. package/dist/lcm/archive.js +12 -0
  386. package/dist/lcm/archive.js.map +1 -0
  387. package/dist/lcm/dag.d.ts +48 -0
  388. package/dist/lcm/dag.js +8 -0
  389. package/dist/lcm/dag.js.map +1 -0
  390. package/dist/lcm/engine.d.ts +116 -0
  391. package/dist/lcm/engine.js +20 -0
  392. package/dist/lcm/engine.js.map +1 -0
  393. package/dist/lcm/index.d.ts +12 -0
  394. package/dist/lcm/index.js +44 -0
  395. package/dist/lcm/index.js.map +1 -0
  396. package/dist/lcm/queue.d.ts +62 -0
  397. package/dist/lcm/queue.js +8 -0
  398. package/dist/lcm/queue.js.map +1 -0
  399. package/dist/lcm/recall.d.ts +20 -0
  400. package/dist/lcm/recall.js +8 -0
  401. package/dist/lcm/recall.js.map +1 -0
  402. package/dist/lcm/schema.d.ts +16 -0
  403. package/dist/lcm/schema.js +14 -0
  404. package/dist/lcm/schema.js.map +1 -0
  405. package/dist/lcm/summarizer.d.ts +38 -0
  406. package/dist/lcm/summarizer.js +12 -0
  407. package/dist/lcm/summarizer.js.map +1 -0
  408. package/dist/lcm/tools.d.ts +29 -0
  409. package/dist/lcm/tools.js +8 -0
  410. package/dist/lcm/tools.js.map +1 -0
  411. package/dist/live-connectors-runner.js +5 -5
  412. package/dist/local-llm.js +3 -3
  413. package/dist/maintenance/archive-observations.d.ts +18 -0
  414. package/dist/maintenance/archive-observations.js +8 -0
  415. package/dist/maintenance/archive-observations.js.map +1 -0
  416. package/dist/maintenance/backup-stamp.d.ts +3 -0
  417. package/dist/maintenance/backup-stamp.js +8 -0
  418. package/dist/maintenance/backup-stamp.js.map +1 -0
  419. package/dist/maintenance/memory-governance-cron.d.ts +85 -0
  420. package/dist/maintenance/memory-governance-cron.js +22 -0
  421. package/dist/maintenance/memory-governance-cron.js.map +1 -0
  422. package/dist/maintenance/memory-governance.d.ts +137 -0
  423. package/dist/maintenance/memory-governance.js +40 -0
  424. package/dist/maintenance/memory-governance.js.map +1 -0
  425. package/dist/maintenance/migrate-observations.d.ts +18 -0
  426. package/dist/maintenance/migrate-observations.js +9 -0
  427. package/dist/maintenance/migrate-observations.js.map +1 -0
  428. package/dist/maintenance/observation-ledger-utils.d.ts +10 -0
  429. package/dist/maintenance/observation-ledger-utils.js +10 -0
  430. package/dist/maintenance/observation-ledger-utils.js.map +1 -0
  431. package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +15 -0
  432. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +28 -0
  433. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js.map +1 -0
  434. package/dist/maintenance/rebuild-memory-projection.d.ts +77 -0
  435. package/dist/maintenance/rebuild-memory-projection.js +35 -0
  436. package/dist/maintenance/rebuild-memory-projection.js.map +1 -0
  437. package/dist/maintenance/rebuild-observations.d.ts +17 -0
  438. package/dist/maintenance/rebuild-observations.js +9 -0
  439. package/dist/maintenance/rebuild-observations.js.map +1 -0
  440. package/dist/mcp-memory-inspector-app.d.ts +24 -6
  441. package/dist/memory-projection-store.d.ts +108 -3
  442. package/dist/memory-projection-store.js +2 -1
  443. package/dist/memory-worth-outcomes.d.ts +4 -2
  444. package/dist/migrate/from-engram.d.ts +24 -0
  445. package/dist/migrate/from-engram.js +12 -0
  446. package/dist/migrate/from-engram.js.map +1 -0
  447. package/dist/namespaces/migrate.d.ts +50 -0
  448. package/dist/namespaces/migrate.js +50 -0
  449. package/dist/namespaces/migrate.js.map +1 -0
  450. package/dist/namespaces/principal.d.ts +17 -0
  451. package/dist/namespaces/principal.js +16 -0
  452. package/dist/namespaces/principal.js.map +1 -0
  453. package/dist/namespaces/search.d.ts +46 -0
  454. package/dist/namespaces/search.js +28 -0
  455. package/dist/namespaces/search.js.map +1 -0
  456. package/dist/namespaces/storage.d.ts +32 -0
  457. package/dist/namespaces/storage.js +28 -0
  458. package/dist/namespaces/storage.js.map +1 -0
  459. package/dist/network/tailscale.d.ts +41 -0
  460. package/dist/network/tailscale.js +9 -0
  461. package/dist/network/tailscale.js.map +1 -0
  462. package/dist/network/webdav.d.ts +39 -0
  463. package/dist/network/webdav.js +10 -0
  464. package/dist/network/webdav.js.map +1 -0
  465. package/dist/objective-state-writers.js +2 -2
  466. package/dist/operator-toolkit.d.ts +4 -2
  467. package/dist/operator-toolkit.js +32 -14
  468. package/dist/opik-exporter.js +2 -2
  469. package/dist/opik-exporter.js.map +1 -1
  470. package/dist/orchestrator-DuWl9Hwx.d.ts +1244 -0
  471. package/dist/orchestrator.d.ts +22 -7
  472. package/dist/orchestrator.js +79 -44
  473. package/dist/path-MR5JPYOP.js +9 -0
  474. package/dist/path-MR5JPYOP.js.map +1 -0
  475. package/dist/qmd-recall-cache.d.ts +1 -1
  476. package/dist/qmd.d.ts +102 -3
  477. package/dist/qmd.js +23 -5
  478. package/dist/recall-explain-renderer.js +3 -3
  479. package/dist/recall-xray-cli.js +4 -4
  480. package/dist/recall-xray-renderer.js +3 -3
  481. package/dist/recall-xray.js +2 -2
  482. package/dist/replay/normalizers/chatgpt.d.ts +6 -0
  483. package/dist/replay/normalizers/chatgpt.js +11 -0
  484. package/dist/replay/normalizers/chatgpt.js.map +1 -0
  485. package/dist/replay/normalizers/claude.d.ts +6 -0
  486. package/dist/replay/normalizers/claude.js +11 -0
  487. package/dist/replay/normalizers/claude.js.map +1 -0
  488. package/dist/replay/normalizers/openclaw.d.ts +6 -0
  489. package/dist/replay/normalizers/openclaw.js +11 -0
  490. package/dist/replay/normalizers/openclaw.js.map +1 -0
  491. package/dist/replay/normalizers/shared.d.ts +16 -0
  492. package/dist/replay/normalizers/shared.js +14 -0
  493. package/dist/replay/normalizers/shared.js.map +1 -0
  494. package/dist/replay/runner.d.ts +35 -0
  495. package/dist/replay/runner.js +16 -0
  496. package/dist/replay/runner.js.map +1 -0
  497. package/dist/replay/types.d.ts +57 -0
  498. package/dist/replay/types.js +19 -0
  499. package/dist/replay/types.js.map +1 -0
  500. package/dist/resolution-B7FNQSSP.js +12 -0
  501. package/dist/resolution-B7FNQSSP.js.map +1 -0
  502. package/dist/resolve-provider-secret.js +2 -2
  503. package/dist/resume-bundles.js +8 -6
  504. package/dist/retrieval-agents.d.ts +1 -1
  505. package/dist/routing/engine.d.ts +35 -0
  506. package/dist/routing/engine.js +16 -0
  507. package/dist/routing/engine.js.map +1 -0
  508. package/dist/routing/store.d.ts +27 -0
  509. package/dist/routing/store.js +10 -0
  510. package/dist/routing/store.js.map +1 -0
  511. package/dist/runtime/better-sqlite.d.ts +8 -0
  512. package/dist/runtime/better-sqlite.js +10 -0
  513. package/dist/runtime/better-sqlite.js.map +1 -0
  514. package/dist/runtime/child-process.d.ts +32 -0
  515. package/dist/runtime/child-process.js +10 -0
  516. package/dist/runtime/child-process.js.map +1 -0
  517. package/dist/runtime/env.d.ts +5 -0
  518. package/dist/runtime/env.js +12 -0
  519. package/dist/runtime/env.js.map +1 -0
  520. package/dist/schemas.d.ts +22 -22
  521. package/dist/sdk-compat.js +1 -1
  522. package/dist/search/document-scanner.d.ts +22 -0
  523. package/dist/search/document-scanner.js +8 -0
  524. package/dist/search/document-scanner.js.map +1 -0
  525. package/dist/search/embed-helper.d.ts +35 -0
  526. package/dist/search/embed-helper.js +9 -0
  527. package/dist/search/embed-helper.js.map +1 -0
  528. package/dist/search/factory.d.ts +32 -0
  529. package/dist/search/factory.js +29 -0
  530. package/dist/search/factory.js.map +1 -0
  531. package/dist/search/index.d.ts +15 -0
  532. package/dist/search/index.js +50 -0
  533. package/dist/search/index.js.map +1 -0
  534. package/dist/search/lancedb-backend.d.ts +51 -0
  535. package/dist/search/lancedb-backend.js +10 -0
  536. package/dist/search/lancedb-backend.js.map +1 -0
  537. package/dist/search/meilisearch-backend.d.ts +48 -0
  538. package/dist/search/meilisearch-backend.js +10 -0
  539. package/dist/search/meilisearch-backend.js.map +1 -0
  540. package/dist/search/noop-backend.d.ts +26 -0
  541. package/dist/search/noop-backend.js +8 -0
  542. package/dist/search/noop-backend.js.map +1 -0
  543. package/dist/search/orama-backend.d.ts +53 -0
  544. package/dist/search/orama-backend.js +10 -0
  545. package/dist/search/orama-backend.js.map +1 -0
  546. package/dist/search/port.d.ts +61 -0
  547. package/dist/search/port.js +1 -0
  548. package/dist/search/port.js.map +1 -0
  549. package/dist/search/remote-backend.d.ts +39 -0
  550. package/dist/search/remote-backend.js +9 -0
  551. package/dist/search/remote-backend.js.map +1 -0
  552. package/dist/secure-store/index.d.ts +890 -0
  553. package/dist/secure-store/index.js +156 -0
  554. package/dist/secure-store/index.js.map +1 -0
  555. package/dist/semantic-VwGI14Ok.d.ts +69 -0
  556. package/dist/semantic-consolidation-4HkHWgeI.d.ts +180 -0
  557. package/dist/semantic-consolidation.d.ts +2 -2
  558. package/dist/semantic-consolidation.js +13 -6
  559. package/dist/semantic-rule-promotion.js +8 -5
  560. package/dist/semantic-rule-verifier.js +8 -5
  561. package/dist/shared-context/manager.d.ts +131 -0
  562. package/dist/shared-context/manager.js +15 -0
  563. package/dist/shared-context/manager.js.map +1 -0
  564. package/dist/skills-registry.js +13 -1
  565. package/dist/skills-registry.js.map +1 -1
  566. package/dist/state-store-VZU2IA53.js +16 -0
  567. package/dist/state-store-VZU2IA53.js.map +1 -0
  568. package/dist/storage-paths.d.ts +9 -0
  569. package/dist/storage-paths.js +20 -0
  570. package/dist/storage-paths.js.map +1 -0
  571. package/dist/storage.d.ts +3 -1
  572. package/dist/storage.js +7 -4
  573. package/dist/summarizer.d.ts +5 -0
  574. package/dist/summarizer.js +9 -8
  575. package/dist/summary-snapshot.js +2 -1
  576. package/dist/surfaces/dreams.d.ts +16 -0
  577. package/dist/surfaces/dreams.js +282 -0
  578. package/dist/surfaces/dreams.js.map +1 -0
  579. package/dist/surfaces/heartbeat.d.ts +17 -0
  580. package/dist/surfaces/heartbeat.js +265 -0
  581. package/dist/surfaces/heartbeat.js.map +1 -0
  582. package/dist/temporal-supersession.d.ts +3 -1
  583. package/dist/threading.d.ts +5 -0
  584. package/dist/threading.js +2 -1
  585. package/dist/tier-migration.d.ts +4 -2
  586. package/dist/tokens.js +2 -2
  587. package/dist/transcript.d.ts +15 -1
  588. package/dist/transcript.js +2 -1
  589. package/dist/transfer/autodetect.d.ts +4 -0
  590. package/dist/transfer/autodetect.js +15 -0
  591. package/dist/transfer/autodetect.js.map +1 -0
  592. package/dist/transfer/backup.d.ts +21 -0
  593. package/dist/transfer/backup.js +17 -0
  594. package/dist/transfer/backup.js.map +1 -0
  595. package/dist/transfer/capsule-export.d.ts +113 -0
  596. package/dist/transfer/capsule-export.js +19 -0
  597. package/dist/transfer/capsule-export.js.map +1 -0
  598. package/dist/transfer/capsule-import.d.ts +124 -0
  599. package/dist/transfer/capsule-import.js +16 -0
  600. package/dist/transfer/capsule-import.js.map +1 -0
  601. package/dist/transfer/constants.d.ts +13 -0
  602. package/dist/transfer/constants.js +12 -0
  603. package/dist/transfer/constants.js.map +1 -0
  604. package/dist/transfer/export-json.d.ts +11 -0
  605. package/dist/transfer/export-json.js +11 -0
  606. package/dist/transfer/export-json.js.map +1 -0
  607. package/dist/transfer/export-md.d.ts +10 -0
  608. package/dist/transfer/export-md.js +13 -0
  609. package/dist/transfer/export-md.js.map +1 -0
  610. package/dist/transfer/export-sqlite.d.ts +9 -0
  611. package/dist/transfer/export-sqlite.js +12 -0
  612. package/dist/transfer/export-sqlite.js.map +1 -0
  613. package/dist/transfer/fs-utils.d.ts +61 -0
  614. package/dist/transfer/fs-utils.js +40 -0
  615. package/dist/transfer/fs-utils.js.map +1 -0
  616. package/dist/transfer/import-json.d.ts +16 -0
  617. package/dist/transfer/import-json.js +13 -0
  618. package/dist/transfer/import-json.js.map +1 -0
  619. package/dist/transfer/import-md.d.ts +14 -0
  620. package/dist/transfer/import-md.js +11 -0
  621. package/dist/transfer/import-md.js.map +1 -0
  622. package/dist/transfer/import-sqlite.d.ts +14 -0
  623. package/dist/transfer/import-sqlite.js +12 -0
  624. package/dist/transfer/import-sqlite.js.map +1 -0
  625. package/dist/transfer/sqlite-schema.d.ts +4 -0
  626. package/dist/transfer/sqlite-schema.js +10 -0
  627. package/dist/transfer/sqlite-schema.js.map +1 -0
  628. package/dist/transfer/types.d.ts +916 -0
  629. package/dist/transfer/types.js +30 -0
  630. package/dist/transfer/types.js.map +1 -0
  631. package/dist/types.d.ts +28 -1
  632. package/dist/types.js +1 -1
  633. package/dist/verified-recall.js +9 -6
  634. package/dist/work/board.d.ts +43 -0
  635. package/dist/work/board.js +14 -0
  636. package/dist/work/board.js.map +1 -0
  637. package/dist/work/boundary.d.ts +8 -0
  638. package/dist/work/boundary.js +14 -0
  639. package/dist/work/boundary.js.map +1 -0
  640. package/dist/work/storage.d.ts +39 -0
  641. package/dist/work/storage.js +11 -0
  642. package/dist/work/storage.js.map +1 -0
  643. package/dist/work/types.d.ts +75 -0
  644. package/dist/work/types.js +1 -0
  645. package/dist/work/types.js.map +1 -0
  646. package/package.json +2767 -6
  647. package/scripts/faiss_index.py +816 -0
  648. package/scripts/faiss_requirements.txt +3 -0
  649. package/skills/remnic-entities/SKILL.md +51 -0
  650. package/skills/remnic-memory-workflow/SKILL.md +61 -0
  651. package/skills/remnic-recall/SKILL.md +51 -0
  652. package/skills/remnic-remember/SKILL.md +56 -0
  653. package/skills/remnic-search/SKILL.md +51 -0
  654. package/skills/remnic-status/SKILL.md +51 -0
  655. package/src/abort-error.test.ts +49 -0
  656. package/src/abort-error.ts +46 -0
  657. package/src/abstraction-nodes.ts +162 -0
  658. package/src/access-audit.test.ts +178 -0
  659. package/src/access-audit.ts +125 -0
  660. package/src/access-cli.test.ts +439 -0
  661. package/src/access-cli.ts +438 -0
  662. package/src/access-http.test.ts +225 -0
  663. package/src/access-http.ts +1899 -0
  664. package/src/access-idempotency.ts +232 -0
  665. package/src/access-mcp.test.ts +568 -0
  666. package/src/access-mcp.ts +3056 -0
  667. package/src/access-schema-pi.test.ts +60 -0
  668. package/src/access-schema.ts +522 -0
  669. package/src/access-service-namespace.test.ts +123 -0
  670. package/src/access-service.ts +5629 -0
  671. package/src/action-confidence.test.ts +206 -0
  672. package/src/action-confidence.ts +466 -0
  673. package/src/active-memory-bridge.test.ts +285 -0
  674. package/src/active-memory-bridge.ts +217 -0
  675. package/src/active-recall.test.ts +484 -0
  676. package/src/active-recall.ts +459 -0
  677. package/src/adapters/claude-code.ts +56 -0
  678. package/src/adapters/codex.ts +57 -0
  679. package/src/adapters/hermes.ts +64 -0
  680. package/src/adapters/index.ts +6 -0
  681. package/src/adapters/registry.ts +41 -0
  682. package/src/adapters/replit.ts +55 -0
  683. package/src/adapters/types.ts +51 -0
  684. package/src/behavior-learner.ts +144 -0
  685. package/src/behavior-signals.ts +73 -0
  686. package/src/binary-lifecycle/backend.ts +117 -0
  687. package/src/binary-lifecycle/index.ts +35 -0
  688. package/src/binary-lifecycle/manifest.ts +79 -0
  689. package/src/binary-lifecycle/pipeline.ts +352 -0
  690. package/src/binary-lifecycle/scanner.ts +89 -0
  691. package/src/binary-lifecycle/types.ts +89 -0
  692. package/src/bootstrap.ts +178 -0
  693. package/src/boxes.ts +521 -0
  694. package/src/briefing.test.ts +1535 -0
  695. package/src/briefing.ts +1382 -0
  696. package/src/buffer-session.test.ts +443 -0
  697. package/src/buffer-surprise-report.ts +176 -0
  698. package/src/buffer-surprise-telemetry.test.ts +606 -0
  699. package/src/buffer-surprise-trigger.test.ts +766 -0
  700. package/src/buffer-surprise.test.ts +339 -0
  701. package/src/buffer-surprise.ts +203 -0
  702. package/src/buffer.ts +900 -0
  703. package/src/bulk-import/cli-command.test.ts +204 -0
  704. package/src/bulk-import/index.ts +34 -0
  705. package/src/bulk-import/pipeline.test.ts +445 -0
  706. package/src/bulk-import/pipeline.ts +178 -0
  707. package/src/bulk-import/registry.test.ts +151 -0
  708. package/src/bulk-import/registry.ts +72 -0
  709. package/src/bulk-import/types.test.ts +272 -0
  710. package/src/bulk-import/types.ts +145 -0
  711. package/src/calibration.ts +394 -0
  712. package/src/capsule-cli.test.ts +398 -0
  713. package/src/capsule-cli.ts +565 -0
  714. package/src/causal-behavior.ts +308 -0
  715. package/src/causal-chain.ts +419 -0
  716. package/src/causal-consolidation.ts +370 -0
  717. package/src/causal-retrieval.ts +286 -0
  718. package/src/causal-trajectory-graph.ts +60 -0
  719. package/src/causal-trajectory.ts +303 -0
  720. package/src/chunking.ts +220 -0
  721. package/src/citations.ts +232 -0
  722. package/src/cli.ts +9403 -0
  723. package/src/codex-cli-fallback.ts +162 -0
  724. package/src/codex-thread-key.ts +1 -0
  725. package/src/coding/access-coding-context.test.ts +197 -0
  726. package/src/coding/coding-branch-scope.test.ts +281 -0
  727. package/src/coding/coding-namespace.test.ts +360 -0
  728. package/src/coding/coding-namespace.ts +412 -0
  729. package/src/coding/coding-orchestrator.test.ts +249 -0
  730. package/src/coding/git-context.test.ts +507 -0
  731. package/src/coding/git-context.ts +336 -0
  732. package/src/coding/mcp-set-coding-context.test.ts +174 -0
  733. package/src/coding/review-context.test.ts +316 -0
  734. package/src/coding/review-context.ts +349 -0
  735. package/src/coding/wire-coding-context.test.ts +468 -0
  736. package/src/commitment-ledger.test.ts +78 -0
  737. package/src/commitment-ledger.ts +337 -0
  738. package/src/compat/checks.test.ts +206 -0
  739. package/src/compat/checks.ts +716 -0
  740. package/src/compat/types.ts +33 -0
  741. package/src/compounding/engine.ts +1686 -0
  742. package/src/compounding/preference-consolidator.ts +778 -0
  743. package/src/compression-optimizer.ts +312 -0
  744. package/src/config.test.ts +930 -0
  745. package/src/config.ts +3807 -0
  746. package/src/connectors/codex/instructions.md +160 -0
  747. package/src/connectors/codex/resources/namespace-cheatsheet.md +48 -0
  748. package/src/connectors/codex-marketplace.ts +500 -0
  749. package/src/connectors/codex-materialize-runner.ts +212 -0
  750. package/src/connectors/codex-materialize.ts +983 -0
  751. package/src/connectors/coerce.ts +62 -0
  752. package/src/connectors/index.test.ts +1570 -0
  753. package/src/connectors/index.ts +3222 -0
  754. package/src/connectors/live/framework.ts +164 -0
  755. package/src/connectors/live/github.test.ts +1218 -0
  756. package/src/connectors/live/github.ts +1068 -0
  757. package/src/connectors/live/gmail.test.ts +1706 -0
  758. package/src/connectors/live/gmail.ts +1293 -0
  759. package/src/connectors/live/google-drive.test.ts +696 -0
  760. package/src/connectors/live/google-drive.ts +724 -0
  761. package/src/connectors/live/index.ts +101 -0
  762. package/src/connectors/live/live-connectors.test.ts +689 -0
  763. package/src/connectors/live/notion.test.ts +1109 -0
  764. package/src/connectors/live/notion.ts +978 -0
  765. package/src/connectors/live/registry.ts +103 -0
  766. package/src/connectors/live/state-store.ts +399 -0
  767. package/src/connectors/live/transient-errors.ts +150 -0
  768. package/src/connectors/weclone-installer.test.ts +850 -0
  769. package/src/connectors-cli.ts +513 -0
  770. package/src/console/state.test.ts +224 -0
  771. package/src/console/state.ts +514 -0
  772. package/src/console/trace.test.ts +813 -0
  773. package/src/console/trace.ts +603 -0
  774. package/src/console/tui.test.ts +582 -0
  775. package/src/console/tui.ts +508 -0
  776. package/src/consolidation-operator.ts +182 -0
  777. package/src/consolidation-provenance-check.ts +551 -0
  778. package/src/consolidation-undo.ts +718 -0
  779. package/src/contradiction/contradiction-judge.test.ts +189 -0
  780. package/src/contradiction/contradiction-judge.ts +333 -0
  781. package/src/contradiction/contradiction-review.ts +574 -0
  782. package/src/contradiction/contradiction-scan.ts +504 -0
  783. package/src/contradiction/contradiction.test.ts +2230 -0
  784. package/src/contradiction/index.ts +37 -0
  785. package/src/contradiction/resolution.ts +383 -0
  786. package/src/conversation-index/backend.ts +323 -0
  787. package/src/conversation-index/chunker.ts +47 -0
  788. package/src/conversation-index/cleanup.ts +53 -0
  789. package/src/conversation-index/faiss-adapter.ts +384 -0
  790. package/src/conversation-index/indexer.test.ts +164 -0
  791. package/src/conversation-index/indexer.ts +192 -0
  792. package/src/conversation-index/search.ts +37 -0
  793. package/src/cross-namespace-budget.test.ts +275 -0
  794. package/src/cross-namespace-budget.ts +365 -0
  795. package/src/cue-anchors.ts +163 -0
  796. package/src/curation/index.ts +544 -0
  797. package/src/dashboard-runtime.ts +337 -0
  798. package/src/day-summary.ts +122 -0
  799. package/src/dedup/index.ts +330 -0
  800. package/src/dedup/semantic.test.ts +1577 -0
  801. package/src/dedup/semantic.ts +148 -0
  802. package/src/delinearize.ts +193 -0
  803. package/src/direct-answer-wiring.test.ts +473 -0
  804. package/src/direct-answer-wiring.ts +180 -0
  805. package/src/direct-answer.test.ts +484 -0
  806. package/src/direct-answer.ts +273 -0
  807. package/src/embedding-fallback.ts +565 -0
  808. package/src/enrichment/audit.ts +89 -0
  809. package/src/enrichment/index.ts +27 -0
  810. package/src/enrichment/pipeline.ts +197 -0
  811. package/src/enrichment/provider-registry.ts +85 -0
  812. package/src/enrichment/types.ts +100 -0
  813. package/src/enrichment/web-search-provider.ts +63 -0
  814. package/src/entity-retrieval.ts +774 -0
  815. package/src/entity-schema.ts +239 -0
  816. package/src/evals.ts +1312 -0
  817. package/src/event-order-recall.test.ts +4164 -0
  818. package/src/event-order-recall.ts +2802 -0
  819. package/src/evidence-pack.test.ts +89 -0
  820. package/src/evidence-pack.ts +388 -0
  821. package/src/explicit-capture.ts +530 -0
  822. package/src/explicit-cue-recall.test.ts +3019 -0
  823. package/src/explicit-cue-recall.ts +5545 -0
  824. package/src/extraction-judge-telemetry.ts +234 -0
  825. package/src/extraction-judge-training.ts +221 -0
  826. package/src/extraction-judge.ts +846 -0
  827. package/src/extraction-timeout.test.ts +265 -0
  828. package/src/extraction.ts +2719 -0
  829. package/src/fallback-llm.test.ts +1060 -0
  830. package/src/fallback-llm.ts +918 -0
  831. package/src/focused-list-recall.test.ts +734 -0
  832. package/src/focused-list-recall.ts +1160 -0
  833. package/src/graph-dashboard-diff.ts +35 -0
  834. package/src/graph-dashboard-key.ts +5 -0
  835. package/src/graph-dashboard-parser.ts +104 -0
  836. package/src/graph-edge-reinforcement.ts +192 -0
  837. package/src/graph-events.ts +151 -0
  838. package/src/graph-recall.test.ts +164 -0
  839. package/src/graph-recall.ts +189 -0
  840. package/src/graph-retrieval.test.ts +809 -0
  841. package/src/graph-retrieval.ts +823 -0
  842. package/src/graph-snapshot.ts +329 -0
  843. package/src/graph.ts +813 -0
  844. package/src/harmonic-retrieval.ts +223 -0
  845. package/src/himem.ts +154 -0
  846. package/src/hygiene.ts +87 -0
  847. package/src/identity-continuity.ts +333 -0
  848. package/src/importance.ts +328 -0
  849. package/src/importers/base.test.ts +294 -0
  850. package/src/importers/base.ts +436 -0
  851. package/src/importers/index.ts +21 -0
  852. package/src/index.ts +1204 -0
  853. package/src/intent.ts +154 -0
  854. package/src/json-extract.ts +85 -0
  855. package/src/json-store.ts +42 -0
  856. package/src/lcm/archive.ts +617 -0
  857. package/src/lcm/dag.ts +199 -0
  858. package/src/lcm/engine.ts +645 -0
  859. package/src/lcm/index.ts +7 -0
  860. package/src/lcm/queue.test.ts +178 -0
  861. package/src/lcm/queue.ts +200 -0
  862. package/src/lcm/recall.ts +117 -0
  863. package/src/lcm/schema.ts +154 -0
  864. package/src/lcm/summarizer.ts +235 -0
  865. package/src/lcm/tools.ts +191 -0
  866. package/src/lcm-engine.test.ts +660 -0
  867. package/src/legacy-hook-compat.test.ts +20 -0
  868. package/src/legacy-hook-compat.ts +45 -0
  869. package/src/lifecycle.ts +289 -0
  870. package/src/live-connectors-runner.ts +385 -0
  871. package/src/local-llm-qos.test.ts +303 -0
  872. package/src/local-llm-thinking.test.ts +292 -0
  873. package/src/local-llm.ts +1464 -0
  874. package/src/logger.ts +49 -0
  875. package/src/maintenance/archive-observations.ts +147 -0
  876. package/src/maintenance/backup-stamp.ts +3 -0
  877. package/src/maintenance/dreams-ledger.ts +516 -0
  878. package/src/maintenance/first-start-migration.ts +362 -0
  879. package/src/maintenance/forget.test.ts +206 -0
  880. package/src/maintenance/forget.ts +126 -0
  881. package/src/maintenance/graph-edge-decay.test.ts +409 -0
  882. package/src/maintenance/graph-edge-decay.ts +394 -0
  883. package/src/maintenance/memory-governance-cron.ts +447 -0
  884. package/src/maintenance/memory-governance.ts +1039 -0
  885. package/src/maintenance/migrate-observations.ts +216 -0
  886. package/src/maintenance/observation-ledger-utils.ts +54 -0
  887. package/src/maintenance/pattern-reinforcement.test.ts +875 -0
  888. package/src/maintenance/pattern-reinforcement.ts +369 -0
  889. package/src/maintenance/purge.ts +334 -0
  890. package/src/maintenance/rebuild-memory-lifecycle-ledger.ts +78 -0
  891. package/src/maintenance/rebuild-memory-projection.ts +1234 -0
  892. package/src/maintenance/rebuild-observations.ts +178 -0
  893. package/src/maintenance/tier-stats.test.ts +378 -0
  894. package/src/maintenance/tier-stats.ts +222 -0
  895. package/src/mcp-memory-inspector-app.ts +421 -0
  896. package/src/memory-action-policy.ts +80 -0
  897. package/src/memory-cache.ts +208 -0
  898. package/src/memory-extension/claude-code-publisher.ts +51 -0
  899. package/src/memory-extension/codex-publisher.ts +149 -0
  900. package/src/memory-extension/hermes-publisher.ts +51 -0
  901. package/src/memory-extension/index.ts +100 -0
  902. package/src/memory-extension/shared-instructions.ts +133 -0
  903. package/src/memory-extension/types.ts +86 -0
  904. package/src/memory-extension-host/host-discovery.ts +276 -0
  905. package/src/memory-extension-host/index.ts +14 -0
  906. package/src/memory-extension-host/render-extensions-block.ts +73 -0
  907. package/src/memory-extension-host/types.ts +21 -0
  908. package/src/memory-lifecycle-ledger-utils.ts +116 -0
  909. package/src/memory-projection-format.ts +11 -0
  910. package/src/memory-projection-store.ts +951 -0
  911. package/src/memory-provenance.test.ts +196 -0
  912. package/src/memory-provenance.ts +484 -0
  913. package/src/memory-worth-bench.test.ts +71 -0
  914. package/src/memory-worth-bench.ts +265 -0
  915. package/src/memory-worth-filter.test.ts +209 -0
  916. package/src/memory-worth-filter.ts +204 -0
  917. package/src/memory-worth-frontmatter.test.ts +311 -0
  918. package/src/memory-worth-outcomes.test.ts +316 -0
  919. package/src/memory-worth-outcomes.ts +286 -0
  920. package/src/memory-worth.test.ts +317 -0
  921. package/src/memory-worth.ts +215 -0
  922. package/src/message-parts/index.ts +806 -0
  923. package/src/message-parts/message-parts.test.ts +421 -0
  924. package/src/migrate/from-engram.ts +789 -0
  925. package/src/model-registry.ts +313 -0
  926. package/src/models-json.ts +76 -0
  927. package/src/namespaces/migrate.ts +187 -0
  928. package/src/namespaces/path.ts +25 -0
  929. package/src/namespaces/principal.test.ts +195 -0
  930. package/src/namespaces/principal.ts +86 -0
  931. package/src/namespaces/search.test.ts +105 -0
  932. package/src/namespaces/search.ts +233 -0
  933. package/src/namespaces/storage.ts +74 -0
  934. package/src/native-knowledge.ts +1823 -0
  935. package/src/negative.ts +72 -0
  936. package/src/network/tailscale.ts +179 -0
  937. package/src/network/webdav.ts +385 -0
  938. package/src/objective-state-writers.ts +951 -0
  939. package/src/objective-state.ts +320 -0
  940. package/src/onboarding/index.ts +529 -0
  941. package/src/openai-chat-compat.ts +56 -0
  942. package/src/operator-toolkit.ts +2132 -0
  943. package/src/opik-exporter.test.ts +72 -0
  944. package/src/opik-exporter.ts +587 -0
  945. package/src/orchestrator-extraction-queue.test.ts +197 -0
  946. package/src/orchestrator-flush.test.ts +1171 -0
  947. package/src/orchestrator-pattern-reinforcement.test.ts +128 -0
  948. package/src/orchestrator-source-attribution.test.ts +701 -0
  949. package/src/orchestrator.ts +16368 -0
  950. package/src/page-versioning.ts +450 -0
  951. package/src/patterns-cli.ts +574 -0
  952. package/src/peers/index.ts +54 -0
  953. package/src/peers/migrate-from-identity-anchor.test.ts +291 -0
  954. package/src/peers/migrate-from-identity-anchor.ts +350 -0
  955. package/src/peers/peers.test.ts +419 -0
  956. package/src/peers/profile-reasoner.ts +694 -0
  957. package/src/peers/storage.ts +1350 -0
  958. package/src/peers/types.ts +138 -0
  959. package/src/plugin-id.ts +84 -0
  960. package/src/policy-runtime.ts +209 -0
  961. package/src/procedural/procedure-miner.ts +150 -0
  962. package/src/procedural/procedure-recall.ts +93 -0
  963. package/src/procedural/procedure-stats.ts +213 -0
  964. package/src/procedural/procedure-types.ts +132 -0
  965. package/src/procedural/reinforcement-core.test.ts +132 -0
  966. package/src/procedural/reinforcement-core.ts +73 -0
  967. package/src/profiling.test.ts +263 -0
  968. package/src/profiling.ts +435 -0
  969. package/src/projection/index.ts +398 -0
  970. package/src/qmd-recall-cache.test.ts +138 -0
  971. package/src/qmd-recall-cache.ts +111 -0
  972. package/src/qmd.test.ts +257 -0
  973. package/src/qmd.ts +2614 -0
  974. package/src/reasoning-trace-recall.ts +201 -0
  975. package/src/reasoning-trace-types.ts +235 -0
  976. package/src/recall-audit-anomaly.test.ts +246 -0
  977. package/src/recall-audit-anomaly.ts +297 -0
  978. package/src/recall-audit.test.ts +51 -0
  979. package/src/recall-audit.ts +72 -0
  980. package/src/recall-budget-config.test.ts +87 -0
  981. package/src/recall-disclosure-escalation.test.ts +196 -0
  982. package/src/recall-disclosure-escalation.ts +158 -0
  983. package/src/recall-disclosure-shaping.test.ts +146 -0
  984. package/src/recall-disclosure.test.ts +214 -0
  985. package/src/recall-explain-renderer.test.ts +140 -0
  986. package/src/recall-explain-renderer.ts +356 -0
  987. package/src/recall-mmr.test.ts +808 -0
  988. package/src/recall-mmr.ts +607 -0
  989. package/src/recall-qos.test.ts +85 -0
  990. package/src/recall-qos.ts +82 -0
  991. package/src/recall-query-policy.ts +221 -0
  992. package/src/recall-state.test.ts +233 -0
  993. package/src/recall-state.ts +456 -0
  994. package/src/recall-tag-filter.ts +143 -0
  995. package/src/recall-tokenization.ts +35 -0
  996. package/src/recall-xray-cli.test.ts +118 -0
  997. package/src/recall-xray-cli.ts +100 -0
  998. package/src/recall-xray-disclosure-telemetry.test.ts +183 -0
  999. package/src/recall-xray-renderer.test.ts +539 -0
  1000. package/src/recall-xray-renderer.ts +487 -0
  1001. package/src/recall-xray.test.ts +503 -0
  1002. package/src/recall-xray.ts +621 -0
  1003. package/src/reconstruct.ts +41 -0
  1004. package/src/release-changelog.ts +35 -0
  1005. package/src/relevance.ts +67 -0
  1006. package/src/replay/normalizers/chatgpt.ts +133 -0
  1007. package/src/replay/normalizers/claude.ts +102 -0
  1008. package/src/replay/normalizers/openclaw.ts +119 -0
  1009. package/src/replay/normalizers/shared.ts +69 -0
  1010. package/src/replay/runner.ts +197 -0
  1011. package/src/replay/types.ts +143 -0
  1012. package/src/rerank.test.ts +48 -0
  1013. package/src/rerank.ts +176 -0
  1014. package/src/resolve-auth-token.test.ts +226 -0
  1015. package/src/resolve-auth-token.ts +151 -0
  1016. package/src/resolve-provider-secret.test.ts +187 -0
  1017. package/src/resolve-provider-secret.ts +410 -0
  1018. package/src/response-guidance-recall.test.ts +3952 -0
  1019. package/src/response-guidance-recall.ts +4431 -0
  1020. package/src/resume-bundles.ts +415 -0
  1021. package/src/retrieval-agents.ts +623 -0
  1022. package/src/retrieval-tiers.ts +25 -0
  1023. package/src/retrieval.ts +104 -0
  1024. package/src/review/index.test.ts +201 -0
  1025. package/src/review/index.ts +536 -0
  1026. package/src/routing/engine.ts +162 -0
  1027. package/src/routing/store.ts +321 -0
  1028. package/src/runtime/better-sqlite.test.ts +32 -0
  1029. package/src/runtime/better-sqlite.ts +76 -0
  1030. package/src/runtime/child-process.ts +67 -0
  1031. package/src/runtime/env.ts +48 -0
  1032. package/src/sanitize.ts +58 -0
  1033. package/src/schemas.ts +449 -0
  1034. package/src/sdk-compat.ts +87 -0
  1035. package/src/search/document-scanner.ts +96 -0
  1036. package/src/search/embed-helper.ts +142 -0
  1037. package/src/search/factory.ts +189 -0
  1038. package/src/search/index.ts +10 -0
  1039. package/src/search/lancedb-backend.ts +342 -0
  1040. package/src/search/meilisearch-backend.ts +232 -0
  1041. package/src/search/noop-backend.ts +57 -0
  1042. package/src/search/orama-backend.ts +358 -0
  1043. package/src/search/port.ts +86 -0
  1044. package/src/search/remote-backend.ts +124 -0
  1045. package/src/secure-store/cipher.ts +271 -0
  1046. package/src/secure-store/cli-handlers.ts +355 -0
  1047. package/src/secure-store/cli-renderer.ts +131 -0
  1048. package/src/secure-store/header.ts +373 -0
  1049. package/src/secure-store/index.ts +137 -0
  1050. package/src/secure-store/kdf.ts +263 -0
  1051. package/src/secure-store/keyring.ts +106 -0
  1052. package/src/secure-store/metadata.ts +394 -0
  1053. package/src/secure-store/passphrase-reader.ts +252 -0
  1054. package/src/secure-store/secure-fs.ts +571 -0
  1055. package/src/secure-store/secure-store.test.ts +755 -0
  1056. package/src/semantic-chunking.ts +545 -0
  1057. package/src/semantic-consolidation.test.ts +182 -0
  1058. package/src/semantic-consolidation.ts +432 -0
  1059. package/src/semantic-rule-promotion.ts +183 -0
  1060. package/src/semantic-rule-verifier.ts +160 -0
  1061. package/src/session-integrity.ts +569 -0
  1062. package/src/session-observer-bands.ts +11 -0
  1063. package/src/session-observer-state.ts +346 -0
  1064. package/src/session-toggles.test.ts +96 -0
  1065. package/src/session-toggles.ts +159 -0
  1066. package/src/shared-context/manager.ts +810 -0
  1067. package/src/signal.ts +84 -0
  1068. package/src/skills-registry.test.ts +277 -0
  1069. package/src/skills-registry.ts +120 -0
  1070. package/src/source-attribution-roundtrip.test.ts +215 -0
  1071. package/src/source-attribution.test.ts +1425 -0
  1072. package/src/source-attribution.ts +639 -0
  1073. package/src/spaces/index.ts +627 -0
  1074. package/src/storage-paths.ts +117 -0
  1075. package/src/storage.ts +6657 -0
  1076. package/src/store-contract.ts +55 -0
  1077. package/src/summarizer.ts +844 -0
  1078. package/src/summary-snapshot.test.ts +681 -0
  1079. package/src/summary-snapshot.ts +238 -0
  1080. package/src/surfaces/dreams.test.ts +394 -0
  1081. package/src/surfaces/dreams.ts +346 -0
  1082. package/src/surfaces/heartbeat.test.ts +415 -0
  1083. package/src/surfaces/heartbeat.ts +325 -0
  1084. package/src/sync/index.ts +308 -0
  1085. package/src/targeted-fact-recall.test.ts +1694 -0
  1086. package/src/targeted-fact-recall.ts +2905 -0
  1087. package/src/taxonomy/default-taxonomy.ts +87 -0
  1088. package/src/taxonomy/index.ts +26 -0
  1089. package/src/taxonomy/resolver-doc-generator.ts +57 -0
  1090. package/src/taxonomy/resolver.ts +184 -0
  1091. package/src/taxonomy/taxonomy-loader.ts +186 -0
  1092. package/src/taxonomy/types.ts +48 -0
  1093. package/src/telemetry-transcript.ts +70 -0
  1094. package/src/temporal-index.ts +890 -0
  1095. package/src/temporal-supersession.test.ts +2703 -0
  1096. package/src/temporal-supersession.ts +493 -0
  1097. package/src/temporal-validity.test.ts +448 -0
  1098. package/src/temporal-validity.ts +123 -0
  1099. package/src/threading.ts +395 -0
  1100. package/src/tier-migration.ts +124 -0
  1101. package/src/tier-routing.ts +102 -0
  1102. package/src/tmt.ts +462 -0
  1103. package/src/tokens.test.ts +178 -0
  1104. package/src/tokens.ts +279 -0
  1105. package/src/topics.ts +147 -0
  1106. package/src/training-export/cli-date-validation.test.ts +258 -0
  1107. package/src/training-export/converter.test.ts +452 -0
  1108. package/src/training-export/converter.ts +319 -0
  1109. package/src/training-export/date-parse.ts +117 -0
  1110. package/src/training-export/index.ts +26 -0
  1111. package/src/training-export/registry.test.ts +85 -0
  1112. package/src/training-export/registry.ts +57 -0
  1113. package/src/training-export/types.ts +31 -0
  1114. package/src/transcript.ts +1179 -0
  1115. package/src/transfer/autodetect.ts +30 -0
  1116. package/src/transfer/backup.ts +138 -0
  1117. package/src/transfer/capsule-crypto.ts +485 -0
  1118. package/src/transfer/capsule-encrypt.test.ts +690 -0
  1119. package/src/transfer/capsule-export.ts +543 -0
  1120. package/src/transfer/capsule-fork.ts +375 -0
  1121. package/src/transfer/capsule-import.ts +564 -0
  1122. package/src/transfer/capsule-merge.ts +433 -0
  1123. package/src/transfer/conflict-policy.ts +16 -0
  1124. package/src/transfer/constants.ts +13 -0
  1125. package/src/transfer/exclusions.ts +37 -0
  1126. package/src/transfer/export-json.ts +65 -0
  1127. package/src/transfer/export-md.ts +59 -0
  1128. package/src/transfer/export-sqlite.ts +52 -0
  1129. package/src/transfer/fs-utils.ts +269 -0
  1130. package/src/transfer/import-json.ts +108 -0
  1131. package/src/transfer/import-md.ts +84 -0
  1132. package/src/transfer/import-sqlite.ts +100 -0
  1133. package/src/transfer/integrity.ts +71 -0
  1134. package/src/transfer/sqlite-schema.ts +16 -0
  1135. package/src/transfer/types.ts +297 -0
  1136. package/src/trust-zones.ts +1186 -0
  1137. package/src/types.ts +3074 -0
  1138. package/src/user-model.test.ts +124 -0
  1139. package/src/user-model.ts +162 -0
  1140. package/src/utility-learner.ts +353 -0
  1141. package/src/utility-runtime.ts +88 -0
  1142. package/src/utility-telemetry.ts +215 -0
  1143. package/src/utils/category-dir.ts +44 -0
  1144. package/src/utils/errno.ts +6 -0
  1145. package/src/utils/iso-timestamp.test.ts +37 -0
  1146. package/src/utils/iso-timestamp.ts +164 -0
  1147. package/src/utils/path.ts +26 -0
  1148. package/src/verified-recall.ts +138 -0
  1149. package/src/version-utils.test.ts +10 -0
  1150. package/src/version-utils.ts +9 -0
  1151. package/src/whitespace.ts +10 -0
  1152. package/src/work/board.ts +359 -0
  1153. package/src/work/boundary.ts +107 -0
  1154. package/src/work/storage.ts +436 -0
  1155. package/src/work/types.ts +82 -0
  1156. package/src/work-product-ledger.ts +265 -0
  1157. package/dist/access-service-DDjzFALq.d.ts +0 -2088
  1158. package/dist/capsule-crypto-SJS5VVAP.js +0 -18
  1159. package/dist/capsule-export-7QNCBZOQ.js +0 -17
  1160. package/dist/capsule-import-EPBHD2EN.js +0 -16
  1161. package/dist/capsule-merge-DI7PNQ2H.js +0 -189
  1162. package/dist/chunk-23ZZK64Y.js +0 -26
  1163. package/dist/chunk-23ZZK64Y.js.map +0 -1
  1164. package/dist/chunk-242S3I2A.js +0 -647
  1165. package/dist/chunk-2LGMW3DJ.js +0 -111
  1166. package/dist/chunk-3B6KIRBH.js +0 -5213
  1167. package/dist/chunk-3B6KIRBH.js.map +0 -1
  1168. package/dist/chunk-457A4P3L.js +0 -119
  1169. package/dist/chunk-457A4P3L.js.map +0 -1
  1170. package/dist/chunk-4IS4SXIQ.js +0 -2040
  1171. package/dist/chunk-4YM32CRU.js +0 -721
  1172. package/dist/chunk-6TBWYBJ3.js +0 -236
  1173. package/dist/chunk-74EMIVE4.js +0 -329
  1174. package/dist/chunk-74EMIVE4.js.map +0 -1
  1175. package/dist/chunk-767ODGE6.js +0 -183
  1176. package/dist/chunk-7V22HTMD.js +0 -623
  1177. package/dist/chunk-7V22HTMD.js.map +0 -1
  1178. package/dist/chunk-7ZM3BFKK.js +0 -9705
  1179. package/dist/chunk-7ZM3BFKK.js.map +0 -1
  1180. package/dist/chunk-AQJNPMOA.js +0 -643
  1181. package/dist/chunk-AQJNPMOA.js.map +0 -1
  1182. package/dist/chunk-ASAITVLA.js +0 -64
  1183. package/dist/chunk-ASAITVLA.js.map +0 -1
  1184. package/dist/chunk-BBE34QBJ.js +0 -275
  1185. package/dist/chunk-BBE34QBJ.js.map +0 -1
  1186. package/dist/chunk-BZSQEPRW.js +0 -14710
  1187. package/dist/chunk-BZSQEPRW.js.map +0 -1
  1188. package/dist/chunk-CPKTBRS2.js +0 -891
  1189. package/dist/chunk-CPKTBRS2.js.map +0 -1
  1190. package/dist/chunk-D4GAOFF6.js +0 -562
  1191. package/dist/chunk-D4GAOFF6.js.map +0 -1
  1192. package/dist/chunk-D54LZC5L.js +0 -147
  1193. package/dist/chunk-DF3RVK3X.js +0 -119
  1194. package/dist/chunk-DF3RVK3X.js.map +0 -1
  1195. package/dist/chunk-DZZPC36E.js +0 -1451
  1196. package/dist/chunk-DZZPC36E.js.map +0 -1
  1197. package/dist/chunk-E2UCDP5S.js +0 -570
  1198. package/dist/chunk-E6K4NIEU.js +0 -747
  1199. package/dist/chunk-E6K4NIEU.js.map +0 -1
  1200. package/dist/chunk-EEQLFRUM.js +0 -89
  1201. package/dist/chunk-ETOW6ACV.js +0 -158
  1202. package/dist/chunk-ETOW6ACV.js.map +0 -1
  1203. package/dist/chunk-FMEBPEAO.js +0 -347
  1204. package/dist/chunk-FMEBPEAO.js.map +0 -1
  1205. package/dist/chunk-FQDPCE3I.js +0 -1837
  1206. package/dist/chunk-FQDPCE3I.js.map +0 -1
  1207. package/dist/chunk-FYIYMQ5N.js +0 -221
  1208. package/dist/chunk-FYIYMQ5N.js.map +0 -1
  1209. package/dist/chunk-G2WADRQ3.js +0 -219
  1210. package/dist/chunk-G4SK7DSQ.js +0 -121
  1211. package/dist/chunk-GVPWB7EY.js +0 -390
  1212. package/dist/chunk-GVPWB7EY.js.map +0 -1
  1213. package/dist/chunk-HELQZFZO.js +0 -1075
  1214. package/dist/chunk-HL5LRPNA.js +0 -1914
  1215. package/dist/chunk-HL5LRPNA.js.map +0 -1
  1216. package/dist/chunk-HQZVVSVB.js +0 -147
  1217. package/dist/chunk-HQZVVSVB.js.map +0 -1
  1218. package/dist/chunk-HY3L4WKC.js +0 -2195
  1219. package/dist/chunk-HY3L4WKC.js.map +0 -1
  1220. package/dist/chunk-IB3BFHGN.js +0 -228
  1221. package/dist/chunk-IXEJRKCZ.js +0 -18
  1222. package/dist/chunk-JBMSGZEQ.js +0 -441
  1223. package/dist/chunk-JBMSGZEQ.js.map +0 -1
  1224. package/dist/chunk-JESOB2HO.js +0 -108
  1225. package/dist/chunk-JKDVIE52.js +0 -272
  1226. package/dist/chunk-JRNQ3RNA.js +0 -284
  1227. package/dist/chunk-JRNQ3RNA.js.map +0 -1
  1228. package/dist/chunk-K6WK37A6.js +0 -865
  1229. package/dist/chunk-K6WK37A6.js.map +0 -1
  1230. package/dist/chunk-MARWOCVP.js +0 -48
  1231. package/dist/chunk-MNU6ZBWT.js +0 -4454
  1232. package/dist/chunk-MNU6ZBWT.js.map +0 -1
  1233. package/dist/chunk-N5AKDXAI.js +0 -74
  1234. package/dist/chunk-OA3L7BFR.js +0 -183
  1235. package/dist/chunk-OA3L7BFR.js.map +0 -1
  1236. package/dist/chunk-OR64ZGRZ.js +0 -23
  1237. package/dist/chunk-P77UEOU2.js +0 -1521
  1238. package/dist/chunk-P77UEOU2.js.map +0 -1
  1239. package/dist/chunk-PH4C2U43.js +0 -239
  1240. package/dist/chunk-PH4C2U43.js.map +0 -1
  1241. package/dist/chunk-RVPLBATS.js +0 -1586
  1242. package/dist/chunk-RVPLBATS.js.map +0 -1
  1243. package/dist/chunk-U5JMRGKX.js +0 -340
  1244. package/dist/chunk-U5JMRGKX.js.map +0 -1
  1245. package/dist/chunk-URB2WSKZ.js +0 -350
  1246. package/dist/chunk-URB2WSKZ.js.map +0 -1
  1247. package/dist/chunk-UVMUAWVT.js +0 -596
  1248. package/dist/chunk-WEJG4TB5.js +0 -118
  1249. package/dist/chunk-X7HPGUVG.js +0 -271
  1250. package/dist/chunk-XAMBKFQS.js +0 -2777
  1251. package/dist/chunk-XAMBKFQS.js.map +0 -1
  1252. package/dist/chunk-XJKFSSDW.js +0 -726
  1253. package/dist/chunk-XJKFSSDW.js.map +0 -1
  1254. package/dist/chunk-XMHBH5H6.js +0 -283
  1255. package/dist/chunk-XMHBH5H6.js.map +0 -1
  1256. package/dist/chunk-XMVFHBHT.js +0 -277
  1257. package/dist/chunk-Y3VMVTYX.js +0 -53
  1258. package/dist/chunk-YNB73F22.js +0 -137
  1259. package/dist/chunk-YNB73F22.js.map +0 -1
  1260. package/dist/chunk-Z2E7VW55.js +0 -335
  1261. package/dist/chunk-Z2E7VW55.js.map +0 -1
  1262. package/dist/chunk-ZG7PTKBK.js +0 -2296
  1263. package/dist/chunk-ZNQN6ZTA.js +0 -135
  1264. package/dist/chunk-ZVTKDVVM.js +0 -827
  1265. package/dist/chunk-ZVTKDVVM.js.map +0 -1
  1266. package/dist/cli-BR8KpIU0.d.ts +0 -1259
  1267. package/dist/codex-materialize-CQlLTzke.d.ts +0 -139
  1268. package/dist/connectors-cli-DFGtY2DB.d.ts +0 -257
  1269. package/dist/contradiction-review-5LTTVDQV.js +0 -22
  1270. package/dist/contradiction-scan-QTXAMBUA.js +0 -414
  1271. package/dist/contradiction-scan-QTXAMBUA.js.map +0 -1
  1272. package/dist/engine-35M5BKQ7.js +0 -28
  1273. package/dist/fs-utils-IRVUFB6G.js +0 -30
  1274. package/dist/graph-edge-decay-PWB63GRE.js +0 -207
  1275. package/dist/memory-governance-IMPQZXFC.js +0 -37
  1276. package/dist/memory-projection-store-CY8TU40w.d.ts +0 -222
  1277. package/dist/orchestrator-DDMPqU6R.d.ts +0 -1792
  1278. package/dist/path-RMTY5Y5A.js +0 -9
  1279. package/dist/port-B6VEDIkC.d.ts +0 -53
  1280. package/dist/resolution-YGIBORXI.js +0 -101
  1281. package/dist/resolution-YGIBORXI.js.map +0 -1
  1282. package/dist/secure-store-4R2GSO7S.js +0 -156
  1283. package/dist/semantic-consolidation-ByBXb-sf.d.ts +0 -180
  1284. package/dist/state-store-3EH7HYIN.js +0 -16
  1285. package/dist/types-V3FJ26TF.js +0 -30
  1286. /package/dist/{capsule-crypto-SJS5VVAP.js.map → adapters/claude-code.js.map} +0 -0
  1287. /package/dist/{capsule-export-7QNCBZOQ.js.map → adapters/codex.js.map} +0 -0
  1288. /package/dist/{capsule-import-EPBHD2EN.js.map → adapters/hermes.js.map} +0 -0
  1289. /package/dist/{contradiction-review-5LTTVDQV.js.map → adapters/index.js.map} +0 -0
  1290. /package/dist/{engine-35M5BKQ7.js.map → adapters/registry.js.map} +0 -0
  1291. /package/dist/{fs-utils-IRVUFB6G.js.map → adapters/replit.js.map} +0 -0
  1292. /package/dist/{memory-governance-IMPQZXFC.js.map → adapters/types.js.map} +0 -0
  1293. /package/dist/{path-RMTY5Y5A.js.map → capsule-crypto-5CYAGVC5.js.map} +0 -0
  1294. /package/dist/{capsule-merge-DI7PNQ2H.js.map → capsule-merge-4MGKE7C5.js.map} +0 -0
  1295. /package/dist/{chunk-G4SK7DSQ.js.map → chunk-2WWLHTZY.js.map} +0 -0
  1296. /package/dist/{chunk-X7HPGUVG.js.map → chunk-4CRG46BG.js.map} +0 -0
  1297. /package/dist/{chunk-UVMUAWVT.js.map → chunk-7IASACLB.js.map} +0 -0
  1298. /package/dist/{chunk-HELQZFZO.js.map → chunk-EDTHC6UD.js.map} +0 -0
  1299. /package/dist/{chunk-4YM32CRU.js.map → chunk-EFJ3MQ4V.js.map} +0 -0
  1300. /package/dist/{chunk-E2UCDP5S.js.map → chunk-FBYESMQ2.js.map} +0 -0
  1301. /package/dist/{chunk-D54LZC5L.js.map → chunk-FDU6HUUL.js.map} +0 -0
  1302. /package/dist/{chunk-IB3BFHGN.js.map → chunk-GGKRUQOO.js.map} +0 -0
  1303. /package/dist/{chunk-242S3I2A.js.map → chunk-GL6I6MEQ.js.map} +0 -0
  1304. /package/dist/{secure-store-4R2GSO7S.js.map → chunk-HHLLAQGZ.js.map} +0 -0
  1305. /package/dist/{chunk-4IS4SXIQ.js.map → chunk-HXXBL2KD.js.map} +0 -0
  1306. /package/dist/{chunk-767ODGE6.js.map → chunk-KNKUID7G.js.map} +0 -0
  1307. /package/dist/{chunk-6TBWYBJ3.js.map → chunk-LPMVBPA3.js.map} +0 -0
  1308. /package/dist/{chunk-WEJG4TB5.js.map → chunk-MC26UJIM.js.map} +0 -0
  1309. /package/dist/{chunk-JKDVIE52.js.map → chunk-MGKYQQYF.js.map} +0 -0
  1310. /package/dist/{chunk-Y3VMVTYX.js.map → chunk-MT4HVDUZ.js.map} +0 -0
  1311. /package/dist/{chunk-G2WADRQ3.js.map → chunk-MY6TPVXW.js.map} +0 -0
  1312. /package/dist/{chunk-OR64ZGRZ.js.map → chunk-NNVTUXEB.js.map} +0 -0
  1313. /package/dist/{chunk-JESOB2HO.js.map → chunk-P4NEIHUT.js.map} +0 -0
  1314. /package/dist/{chunk-IXEJRKCZ.js.map → chunk-QRNI5JBH.js.map} +0 -0
  1315. /package/dist/{chunk-EEQLFRUM.js.map → chunk-RRF5UOBJ.js.map} +0 -0
  1316. /package/dist/{state-store-3EH7HYIN.js.map → chunk-SEDEKFYQ.js.map} +0 -0
  1317. /package/dist/{chunk-2LGMW3DJ.js.map → chunk-U3PN77QT.js.map} +0 -0
  1318. /package/dist/{chunk-XMVFHBHT.js.map → chunk-U3WSW6PZ.js.map} +0 -0
  1319. /package/dist/{chunk-N5AKDXAI.js.map → chunk-UWVJF25J.js.map} +0 -0
  1320. /package/dist/{types-V3FJ26TF.js.map → chunk-V5OCT34X.js.map} +0 -0
  1321. /package/dist/{chunk-ZG7PTKBK.js.map → chunk-W3LR522O.js.map} +0 -0
  1322. /package/dist/{chunk-MARWOCVP.js.map → chunk-XIG5PDM7.js.map} +0 -0
  1323. /package/dist/{chunk-ZNQN6ZTA.js.map → chunk-XVZ7B3HG.js.map} +0 -0
  1324. /package/dist/{graph-edge-decay-PWB63GRE.js.map → graph-edge-decay-5DI5GUNL.js.map} +0 -0
@@ -0,0 +1,2800 @@
1
+ import {
2
+ REMNIC_CHATGPT_MEMORY_INSPECTOR_MIME_TYPE,
3
+ REMNIC_CHATGPT_MEMORY_INSPECTOR_TOOL,
4
+ REMNIC_CHATGPT_MEMORY_INSPECTOR_WIDGET_HTML,
5
+ REMNIC_CHATGPT_MEMORY_INSPECTOR_WIDGET_URI,
6
+ buildChatGptMemoryInspectorActionRequest,
7
+ buildChatGptMemoryInspectorResult
8
+ } from "./chunk-C5BCH4ZS.js";
9
+ import {
10
+ buildCitationGuidance
11
+ } from "./chunk-IQT3XTKW.js";
12
+ import {
13
+ EngramAccessInputError
14
+ } from "./chunk-M23FSH32.js";
15
+ import {
16
+ validateBriefingFormat
17
+ } from "./chunk-VW676BEI.js";
18
+ import {
19
+ expandTildePath
20
+ } from "./chunk-QRNI5JBH.js";
21
+ import {
22
+ readEnvVar
23
+ } from "./chunk-XIG5PDM7.js";
24
+ import {
25
+ validateRequest
26
+ } from "./chunk-A2XUIMJ3.js";
27
+
28
+ // src/access-mcp.ts
29
+ import { readFile } from "fs/promises";
30
+ import { randomUUID } from "crypto";
31
+ var MCP_PROTOCOL_VERSION = "2024-11-05";
32
+ var LEGACY_MCP_PREFIX = "engram.";
33
+ var CANONICAL_MCP_PREFIX = "remnic.";
34
+ function toCanonicalToolName(name) {
35
+ return name.startsWith(LEGACY_MCP_PREFIX) ? `${CANONICAL_MCP_PREFIX}${name.slice(LEGACY_MCP_PREFIX.length)}` : name;
36
+ }
37
+ function toLegacyToolName(name) {
38
+ return name.startsWith(CANONICAL_MCP_PREFIX) ? `${LEGACY_MCP_PREFIX}${name.slice(CANONICAL_MCP_PREFIX.length)}` : name;
39
+ }
40
+ function withToolAliases(tool) {
41
+ const canonicalName = toCanonicalToolName(tool.name);
42
+ const canonicalTool = canonicalName === tool.name ? tool : { ...tool, name: canonicalName };
43
+ if (canonicalName === tool.name) return [canonicalTool];
44
+ return [canonicalTool, tool];
45
+ }
46
+ function resolveChatGptInspectorRecallSessionKey(explicitSessionKey, authenticatedPrincipal) {
47
+ if (explicitSessionKey) return explicitSessionKey;
48
+ if (!authenticatedPrincipal) return void 0;
49
+ return `remnic:chatgpt-memory-inspector:${randomUUID()}`;
50
+ }
51
+ var STRICT_MCP_SCHEMA_KEYS = {
52
+ capsuleExport: [
53
+ "name",
54
+ "namespace",
55
+ "since",
56
+ "includeKinds",
57
+ "peerIds",
58
+ "includeTranscripts",
59
+ "encrypt"
60
+ ],
61
+ capsuleImport: ["archivePath", "namespace", "mode"],
62
+ capsuleList: ["namespace"]
63
+ };
64
+ function parseMcpRequest(schemaName, args) {
65
+ const allowedKeys = STRICT_MCP_SCHEMA_KEYS[schemaName];
66
+ if (allowedKeys) {
67
+ const allowed = new Set(allowedKeys);
68
+ const unexpected = Object.keys(args).filter((key) => !allowed.has(key));
69
+ if (unexpected.length > 0) {
70
+ throw new EngramAccessInputError(
71
+ `request validation failed: (root): Unrecognized key(s) in object: ${unexpected.join(", ")}`
72
+ );
73
+ }
74
+ }
75
+ const validation = validateRequest(schemaName, args);
76
+ if (validation.success) return validation.data;
77
+ const details = validation.error.details.map((detail) => `${detail.field}: ${detail.message}`).join("; ");
78
+ throw new EngramAccessInputError(
79
+ details.length > 0 ? `${validation.error.error}: ${details}` : validation.error.error
80
+ );
81
+ }
82
+ async function getMcpServerVersion() {
83
+ const envVersion = readEnvVar("OPENCLAW_ENGRAM_VERSION")?.trim() || readEnvVar("npm_package_version")?.trim();
84
+ if (envVersion) return envVersion;
85
+ try {
86
+ const pkgPath = new URL("../package.json", import.meta.url);
87
+ const raw = await readFile(pkgPath, "utf-8");
88
+ const parsed = JSON.parse(raw);
89
+ return parsed.version?.trim() || "unknown";
90
+ } catch {
91
+ return "unknown";
92
+ }
93
+ }
94
+ var EngramMcpServer = class {
95
+ constructor(service, options = {}) {
96
+ this.service = service;
97
+ this.citationsEnabled = options.citationsEnabled === true;
98
+ this.citationsAutoDetect = options.citationsAutoDetect !== false;
99
+ this.authenticatedPrincipal = options.principal?.trim() || readEnvVar("OPENCLAW_ENGRAM_ACCESS_PRINCIPAL")?.trim() || void 0;
100
+ this.resources = [
101
+ {
102
+ uri: REMNIC_CHATGPT_MEMORY_INSPECTOR_WIDGET_URI,
103
+ name: "remnic-memory-inspector",
104
+ title: "Remnic Memory Inspector",
105
+ description: "Apps-compatible widget for inspecting retrieved Remnic memories, provenance, safety, and correction/scoping affordances.",
106
+ mimeType: REMNIC_CHATGPT_MEMORY_INSPECTOR_MIME_TYPE,
107
+ _meta: {
108
+ ui: {
109
+ csp: {
110
+ connectDomains: [],
111
+ resourceDomains: []
112
+ },
113
+ prefersBorder: true
114
+ },
115
+ "openai/widgetDescription": "Inspect retrieved Remnic memories, provenance, safety, and correction/scoping affordances."
116
+ }
117
+ }
118
+ ];
119
+ this.resourceTextByUri = /* @__PURE__ */ new Map([
120
+ [
121
+ REMNIC_CHATGPT_MEMORY_INSPECTOR_WIDGET_URI,
122
+ REMNIC_CHATGPT_MEMORY_INSPECTOR_WIDGET_HTML
123
+ ]
124
+ ]);
125
+ this.tools = [
126
+ {
127
+ name: "engram.recall",
128
+ description: "Recall Engram context for a query.",
129
+ inputSchema: {
130
+ type: "object",
131
+ properties: {
132
+ query: { type: "string" },
133
+ sessionKey: { type: "string" },
134
+ namespace: { type: "string" },
135
+ topK: { type: "number" },
136
+ mode: { type: "string", enum: ["auto", "no_recall", "minimal", "full", "graph_mode"] },
137
+ includeDebug: { type: "boolean" },
138
+ // Recall disclosure depth (issue #677). Default `chunk` when
139
+ // omitted. Section/raw payload shaping ships in PR 2; this PR
140
+ // wires the field end-to-end so clients can already pass it
141
+ // without it being silently dropped.
142
+ disclosure: { type: "string", enum: ["chunk", "section", "raw"] },
143
+ cwd: { type: "string", description: "Working directory for auto git-context resolution." },
144
+ projectTag: { type: "string", description: "Project tag for non-git project scoping (e.g. 'blend-supply')." },
145
+ asOf: {
146
+ type: "string",
147
+ description: "Historical recall pin (issue #680). ISO 8601 timestamp; when set, the recall returns the corpus as it existed at this instant."
148
+ },
149
+ tags: {
150
+ type: "array",
151
+ items: { type: "string" },
152
+ description: "Filter recall results to memories whose frontmatter tags match (issue #689)."
153
+ },
154
+ tagMatch: {
155
+ type: "string",
156
+ enum: ["any", "all"],
157
+ description: "Tag-filter match mode. 'any' (default) admits results with at least one filter tag; 'all' requires every filter tag."
158
+ }
159
+ },
160
+ required: ["query"],
161
+ additionalProperties: false
162
+ }
163
+ },
164
+ {
165
+ name: "engram.recall_explain",
166
+ description: "Return the last recall snapshot for a session or the most recent one.",
167
+ inputSchema: {
168
+ type: "object",
169
+ properties: {
170
+ sessionKey: { type: "string" },
171
+ namespace: { type: "string" }
172
+ },
173
+ additionalProperties: false
174
+ }
175
+ },
176
+ {
177
+ name: "engram.set_coding_context",
178
+ description: "Attach a coding-agent context (project / branch) to a session so recall routes to a project- / branch-scoped namespace (issue #569). For MCP clients that do not ship cwd automatically (Cursor, generic agents, etc.). Also aliased as remnic.set_coding_context. Pass codingContext: null to clear. Alternatively, pass just a projectTag for non-git project scoping (e.g. OpenClaw channels).",
179
+ inputSchema: {
180
+ type: "object",
181
+ properties: {
182
+ sessionKey: {
183
+ type: "string",
184
+ description: "Session identifier the context should attach to."
185
+ },
186
+ codingContext: {
187
+ anyOf: [
188
+ { type: "null" },
189
+ {
190
+ type: "object",
191
+ properties: {
192
+ projectId: { type: "string", description: "Stable project id (origin:<hex> or root:<hex>)." },
193
+ branch: { type: ["string", "null"], description: "Current branch, or null in detached HEAD." },
194
+ rootPath: { type: "string", description: "Absolute path to the repo root." },
195
+ defaultBranch: { type: ["string", "null"], description: "Default branch (usually main/master), or null when unknown." }
196
+ },
197
+ required: ["projectId", "branch", "rootPath", "defaultBranch"],
198
+ additionalProperties: false
199
+ }
200
+ ],
201
+ description: "The context to attach, or null to clear. Omit when using projectTag instead."
202
+ },
203
+ projectTag: {
204
+ type: "string",
205
+ description: "Arbitrary project tag for non-git project scoping (e.g. 'blend-supply'). Creates a coding context with projectId 'tag:<projectTag>'. Use instead of codingContext when the session isn't tied to a specific git repo."
206
+ }
207
+ },
208
+ required: ["sessionKey"],
209
+ additionalProperties: false
210
+ }
211
+ },
212
+ {
213
+ name: "engram.recall_tier_explain",
214
+ description: "Return a structured tier-explain payload for the last direct-answer-eligible recall (issue #518). Orthogonal to engram.recall_explain, which returns a graph-path explanation.",
215
+ inputSchema: {
216
+ type: "object",
217
+ properties: {
218
+ sessionKey: {
219
+ type: "string",
220
+ description: "Optional session key. Omit to read the most recent snapshot."
221
+ },
222
+ namespace: {
223
+ type: "string",
224
+ description: "Optional namespace to scope the returned snapshot."
225
+ }
226
+ },
227
+ additionalProperties: false
228
+ }
229
+ },
230
+ {
231
+ // Registered as `engram.recall_xray`; `withToolAliases` below
232
+ // emits the canonical `remnic.recall_xray` alias automatically
233
+ // (dual-naming invariant for every new MCP tool).
234
+ name: "engram.recall_xray",
235
+ description: "Run a recall with X-ray capture enabled and return the unified per-result attribution snapshot (tier + audit + MMR + filters in one view). Issue #570.",
236
+ inputSchema: {
237
+ type: "object",
238
+ properties: {
239
+ query: {
240
+ type: "string",
241
+ description: "Query to recall against. Required; non-empty."
242
+ },
243
+ sessionKey: {
244
+ type: "string",
245
+ description: "Optional session key to scope the recall."
246
+ },
247
+ namespace: {
248
+ type: "string",
249
+ description: "Optional namespace. Enforced against the caller's principal; a mismatch yields snapshotFound:false."
250
+ },
251
+ budget: {
252
+ type: "integer",
253
+ minimum: 1,
254
+ description: "Optional positive-integer override for the recall character budget."
255
+ },
256
+ disclosure: {
257
+ type: "string",
258
+ enum: ["chunk", "section", "raw"],
259
+ description: "Optional disclosure depth for X-ray telemetry (issue #677). When set, populates the per-disclosure token-spend summary on each result."
260
+ }
261
+ },
262
+ required: ["query"],
263
+ additionalProperties: false
264
+ }
265
+ },
266
+ {
267
+ name: "engram.action_confidence",
268
+ description: "Advisory ask/draft/act/refuse/escalate decision helper for interruption budgeting. Read-only; never mutates memory.",
269
+ inputSchema: {
270
+ type: "object",
271
+ properties: {
272
+ intendedAction: { type: "string" },
273
+ confidence: { type: "number", minimum: 0, maximum: 1 },
274
+ risk: {
275
+ type: "string",
276
+ enum: ["low", "medium", "high", "irreversible", "restricted"]
277
+ },
278
+ contextReadiness: {
279
+ type: "string",
280
+ enum: ["none", "partial", "sufficient"]
281
+ },
282
+ currentContextScopes: {
283
+ type: "array",
284
+ items: { type: "string" }
285
+ },
286
+ userRules: {
287
+ type: "array",
288
+ items: {
289
+ type: "object",
290
+ properties: {
291
+ kind: {
292
+ type: "string",
293
+ enum: [
294
+ "ask-before",
295
+ "do-not-use-outside-this-context",
296
+ "never",
297
+ "requires-escalation"
298
+ ]
299
+ },
300
+ description: { type: "string" },
301
+ matched: { type: "boolean" }
302
+ },
303
+ required: ["kind"],
304
+ additionalProperties: false
305
+ }
306
+ },
307
+ retrievedMemories: {
308
+ type: "array",
309
+ items: {
310
+ type: "object",
311
+ properties: {
312
+ source: { type: "string" },
313
+ created: { type: "string" },
314
+ updated: { type: "string" },
315
+ scope: { type: "string" },
316
+ userContextScopes: {
317
+ type: "array",
318
+ items: { type: "string" }
319
+ },
320
+ retrievalReason: { type: "string" },
321
+ confidence: { type: "number", minimum: 0, maximum: 1 },
322
+ stale: { type: "boolean" },
323
+ corrected: { type: "boolean" },
324
+ correctionState: {
325
+ type: "string",
326
+ enum: ["none", "correction", "superseded", "disputed", "forgotten"]
327
+ },
328
+ safeToUse: { type: "boolean" },
329
+ safety: {
330
+ type: "string",
331
+ enum: ["safe", "requires-review", "blocked"]
332
+ },
333
+ safetyReasons: {
334
+ type: "array",
335
+ items: { type: "string" }
336
+ }
337
+ },
338
+ additionalProperties: false
339
+ }
340
+ }
341
+ },
342
+ additionalProperties: false
343
+ }
344
+ },
345
+ {
346
+ name: REMNIC_CHATGPT_MEMORY_INSPECTOR_TOOL,
347
+ title: "Show Remnic Memory Inspector",
348
+ description: "Use this when the user wants a ChatGPT Apps-compatible UI for inspecting Remnic recall, provenance, safety, and correction/forget/scoping affordances. Read-only; correction and forget actions are proposed as follow-up prompts.",
349
+ inputSchema: {
350
+ type: "object",
351
+ properties: {
352
+ query: {
353
+ type: "string",
354
+ description: "Memory question to inspect."
355
+ },
356
+ sessionKey: {
357
+ type: "string",
358
+ description: "Optional Remnic session key for scoped recall."
359
+ },
360
+ namespace: {
361
+ type: "string",
362
+ description: "Optional Remnic namespace to inspect."
363
+ },
364
+ currentContextScopes: {
365
+ type: "array",
366
+ items: { type: "string" },
367
+ description: "Optional current user-context scopes, such as repo, work, personal, client, or private."
368
+ }
369
+ },
370
+ required: ["query"],
371
+ additionalProperties: false
372
+ },
373
+ outputSchema: {
374
+ type: "object",
375
+ properties: {
376
+ app: { type: "object" },
377
+ query: { type: "string" },
378
+ sessionKey: { type: "string" },
379
+ namespace: { type: "string" },
380
+ safeRecallPreview: { type: "string" },
381
+ memoryCount: { type: "number" },
382
+ memoryIds: { type: "array", items: { type: "string" } },
383
+ memories: { type: "array", items: { type: "object" } },
384
+ actionConfidence: { type: "object" },
385
+ affordances: { type: "array", items: { type: "object" } },
386
+ guidance: { type: "object" }
387
+ },
388
+ required: [
389
+ "app",
390
+ "query",
391
+ "namespace",
392
+ "safeRecallPreview",
393
+ "memoryCount",
394
+ "memoryIds",
395
+ "memories",
396
+ "actionConfidence",
397
+ "affordances",
398
+ "guidance"
399
+ ],
400
+ additionalProperties: false
401
+ },
402
+ annotations: {
403
+ readOnlyHint: true,
404
+ destructiveHint: false,
405
+ idempotentHint: true,
406
+ openWorldHint: false
407
+ },
408
+ _meta: {
409
+ ui: {
410
+ resourceUri: REMNIC_CHATGPT_MEMORY_INSPECTOR_WIDGET_URI,
411
+ visibility: ["model", "app"]
412
+ },
413
+ "openai/outputTemplate": REMNIC_CHATGPT_MEMORY_INSPECTOR_WIDGET_URI,
414
+ "openai/toolInvocation/invoking": "Inspecting Remnic memory...",
415
+ "openai/toolInvocation/invoked": "Remnic memory inspector ready."
416
+ }
417
+ },
418
+ {
419
+ name: "engram.day_summary",
420
+ description: "Generate a structured end-of-day summary. When memories is omitted or empty, auto-gathers today's facts and hourly summaries from storage.",
421
+ inputSchema: {
422
+ type: "object",
423
+ properties: {
424
+ memories: { type: "string" },
425
+ sessionKey: { type: "string" },
426
+ namespace: { type: "string" }
427
+ },
428
+ required: [],
429
+ additionalProperties: false
430
+ }
431
+ },
432
+ {
433
+ name: "engram.capsule_export",
434
+ description: "Export a portable Remnic capsule archive from the namespace-scoped memory store.",
435
+ inputSchema: {
436
+ type: "object",
437
+ properties: {
438
+ name: {
439
+ type: "string",
440
+ description: "Capsule id (alphanumeric with single dashes, max 64 characters)."
441
+ },
442
+ namespace: { type: "string" },
443
+ since: {
444
+ type: "string",
445
+ description: "Only include files modified on or after this ISO 8601 timestamp."
446
+ },
447
+ includeKinds: {
448
+ type: "array",
449
+ items: { type: "string" },
450
+ description: "Optional top-level directory allow-list."
451
+ },
452
+ peerIds: {
453
+ type: "array",
454
+ items: { type: "string" },
455
+ description: "Optional peer id allow-list for the peers/ subtree."
456
+ },
457
+ includeTranscripts: { type: "boolean" },
458
+ encrypt: { type: "boolean" }
459
+ },
460
+ required: ["name"],
461
+ additionalProperties: false
462
+ }
463
+ },
464
+ {
465
+ name: "engram.capsule_import",
466
+ description: "Import a Remnic capsule archive into the namespace-scoped memory store.",
467
+ inputSchema: {
468
+ type: "object",
469
+ properties: {
470
+ archivePath: {
471
+ type: "string",
472
+ description: "Path to a .capsule.json.gz or .capsule.json.gz.enc archive."
473
+ },
474
+ namespace: { type: "string" },
475
+ mode: {
476
+ type: "string",
477
+ enum: ["skip", "overwrite", "fork"],
478
+ description: "Conflict handling mode. Defaults to skip."
479
+ }
480
+ },
481
+ required: ["archivePath"],
482
+ additionalProperties: false
483
+ }
484
+ },
485
+ {
486
+ name: "engram.capsule_list",
487
+ description: "List capsule archives in the namespace-scoped capsule store.",
488
+ inputSchema: {
489
+ type: "object",
490
+ properties: {
491
+ namespace: { type: "string" }
492
+ },
493
+ additionalProperties: false
494
+ }
495
+ },
496
+ {
497
+ name: "engram.memory_governance_run",
498
+ description: "Run Remnic memory governance in a bounded shadow/apply pass.",
499
+ inputSchema: {
500
+ type: "object",
501
+ properties: {
502
+ namespace: { type: "string" },
503
+ mode: { type: "string", enum: ["shadow", "apply"] },
504
+ recentDays: { type: "number" },
505
+ maxMemories: { type: "number" },
506
+ batchSize: { type: "number" }
507
+ },
508
+ additionalProperties: false
509
+ }
510
+ },
511
+ {
512
+ name: "engram.procedure_mining_run",
513
+ description: "Run procedural memory mining from causal trajectories (issue #519). Respects procedural.enabled; writes under procedures/ when clusters qualify.",
514
+ inputSchema: {
515
+ type: "object",
516
+ properties: {
517
+ namespace: { type: "string" }
518
+ },
519
+ additionalProperties: false
520
+ }
521
+ },
522
+ {
523
+ name: "engram.pattern_reinforcement_run",
524
+ description: "Run the pattern-reinforcement maintenance job (issue #687 PR 2/4). Clusters duplicate non-procedural memories by normalized content, promotes the most-recent member to canonical, and supersedes the older duplicates. Gated on patternReinforcementEnabled and the patternReinforcementCadenceMs floor \u2014 pass force=true to bypass the cadence for an ad-hoc operator run.",
525
+ inputSchema: {
526
+ type: "object",
527
+ properties: {
528
+ namespace: { type: "string" },
529
+ force: { type: "boolean" }
530
+ },
531
+ additionalProperties: false
532
+ }
533
+ },
534
+ {
535
+ // The canonical `remnic.procedural_stats` alias is added automatically
536
+ // by `withToolAliases` — the dual-naming invariant keeps both names
537
+ // alive for the legacy surface.
538
+ name: "engram.procedural_stats",
539
+ description: "Procedural memory stats (issue #567): counts by status, recent write activity, and the active procedural.* config. Read-only, namespace-scoped.",
540
+ inputSchema: {
541
+ type: "object",
542
+ properties: {
543
+ namespace: { type: "string" }
544
+ },
545
+ additionalProperties: false
546
+ }
547
+ },
548
+ {
549
+ name: "engram.memory_get",
550
+ description: "Fetch one Remnic memory by id.",
551
+ inputSchema: {
552
+ type: "object",
553
+ properties: {
554
+ memoryId: { type: "string" },
555
+ namespace: { type: "string" }
556
+ },
557
+ required: ["memoryId"],
558
+ additionalProperties: false
559
+ }
560
+ },
561
+ {
562
+ name: "engram.memory_timeline",
563
+ description: "Fetch one Remnic memory timeline by id.",
564
+ inputSchema: {
565
+ type: "object",
566
+ properties: {
567
+ memoryId: { type: "string" },
568
+ namespace: { type: "string" },
569
+ limit: { type: "number" }
570
+ },
571
+ required: ["memoryId"],
572
+ additionalProperties: false
573
+ }
574
+ },
575
+ {
576
+ name: "engram.memory_store",
577
+ description: "Store an explicit Remnic memory through the access layer.",
578
+ inputSchema: {
579
+ type: "object",
580
+ properties: {
581
+ schemaVersion: { type: "number" },
582
+ idempotencyKey: { type: "string" },
583
+ dryRun: { type: "boolean" },
584
+ sessionKey: { type: "string" },
585
+ content: { type: "string" },
586
+ category: { type: "string" },
587
+ confidence: { type: "number" },
588
+ namespace: { type: "string" },
589
+ tags: { type: "array", items: { type: "string" } },
590
+ entityRef: { type: "string" },
591
+ ttl: { type: "string" },
592
+ sourceReason: { type: "string" }
593
+ },
594
+ required: ["content"],
595
+ additionalProperties: false
596
+ }
597
+ },
598
+ {
599
+ name: "engram.suggestion_submit",
600
+ description: "Queue a suggested Remnic memory for review.",
601
+ inputSchema: {
602
+ type: "object",
603
+ properties: {
604
+ schemaVersion: { type: "number" },
605
+ idempotencyKey: { type: "string" },
606
+ dryRun: { type: "boolean" },
607
+ sessionKey: { type: "string" },
608
+ content: { type: "string" },
609
+ category: { type: "string" },
610
+ confidence: { type: "number" },
611
+ namespace: { type: "string" },
612
+ tags: { type: "array", items: { type: "string" } },
613
+ entityRef: { type: "string" },
614
+ ttl: { type: "string" },
615
+ sourceReason: { type: "string" }
616
+ },
617
+ required: ["content"],
618
+ additionalProperties: false
619
+ }
620
+ },
621
+ {
622
+ name: "engram.entity_get",
623
+ description: "Fetch one Engram entity by name.",
624
+ inputSchema: {
625
+ type: "object",
626
+ properties: {
627
+ name: { type: "string" },
628
+ namespace: { type: "string" }
629
+ },
630
+ required: ["name"],
631
+ additionalProperties: false
632
+ }
633
+ },
634
+ {
635
+ name: "engram.review_queue_list",
636
+ description: "Fetch the latest Engram review queue artifact bundle.",
637
+ inputSchema: {
638
+ type: "object",
639
+ properties: {
640
+ runId: { type: "string" },
641
+ namespace: { type: "string" }
642
+ },
643
+ additionalProperties: false
644
+ }
645
+ },
646
+ {
647
+ name: "engram.observe",
648
+ description: "Feed conversation messages into Engram's memory pipeline (LCM archive + extraction).",
649
+ inputSchema: {
650
+ type: "object",
651
+ properties: {
652
+ sessionKey: { type: "string", description: "Conversation session identifier" },
653
+ messages: {
654
+ type: "array",
655
+ items: {
656
+ type: "object",
657
+ properties: {
658
+ role: { type: "string", enum: ["user", "assistant"] },
659
+ content: { type: "string" },
660
+ sourceFormat: {
661
+ type: "string",
662
+ enum: ["openai", "anthropic", "openclaw", "pi", "lossless-claw", "remnic"]
663
+ },
664
+ rawContent: {
665
+ description: "Optional native provider content blocks for structured message-part capture."
666
+ },
667
+ parts: {
668
+ type: "array",
669
+ description: "Optional normalized Remnic LCM message parts.",
670
+ items: {
671
+ type: "object",
672
+ properties: {
673
+ ordinal: { type: ["number", "null"], minimum: 0 },
674
+ kind: {
675
+ type: "string",
676
+ enum: [
677
+ "text",
678
+ "tool_call",
679
+ "tool_result",
680
+ "patch",
681
+ "file_read",
682
+ "file_write",
683
+ "step_start",
684
+ "step_finish",
685
+ "snapshot",
686
+ "retry"
687
+ ]
688
+ },
689
+ payload: { type: "object", additionalProperties: true },
690
+ toolName: { type: ["string", "null"] },
691
+ tool_name: { type: ["string", "null"] },
692
+ filePath: { type: ["string", "null"] },
693
+ file_path: { type: ["string", "null"] },
694
+ createdAt: { type: ["string", "null"] },
695
+ created_at: { type: ["string", "null"] }
696
+ },
697
+ required: ["kind", "payload"],
698
+ additionalProperties: false
699
+ }
700
+ }
701
+ },
702
+ required: ["role", "content"],
703
+ additionalProperties: false
704
+ },
705
+ description: "Conversation messages to observe"
706
+ },
707
+ namespace: { type: "string" },
708
+ skipExtraction: { type: "boolean" },
709
+ cwd: { type: "string", description: "Working directory for auto git-context resolution." },
710
+ projectTag: { type: "string", description: "Project tag for non-git project scoping (e.g. 'blend-supply')." }
711
+ },
712
+ required: ["sessionKey", "messages"],
713
+ additionalProperties: false
714
+ }
715
+ },
716
+ {
717
+ name: "engram.lcm_search",
718
+ description: "Search the LCM conversation archive for matching content.",
719
+ inputSchema: {
720
+ type: "object",
721
+ properties: {
722
+ query: { type: "string", description: "Search query" },
723
+ sessionKey: { type: "string", description: "Optional session filter" },
724
+ namespace: { type: "string" },
725
+ limit: { type: "number", description: "Max results to return" }
726
+ },
727
+ required: ["query"],
728
+ additionalProperties: false
729
+ }
730
+ },
731
+ {
732
+ name: "engram.lcm_compaction_flush",
733
+ description: "Flush pending LCM observe work and incremental summaries before a host compacts session context.",
734
+ inputSchema: {
735
+ type: "object",
736
+ properties: {
737
+ sessionKey: { type: "string", description: "Conversation session identifier" },
738
+ namespace: { type: "string" }
739
+ },
740
+ required: ["sessionKey"],
741
+ additionalProperties: false
742
+ }
743
+ },
744
+ {
745
+ name: "engram.lcm_compaction_record",
746
+ description: "Record a host compaction event with before/after token counts in the LCM archive.",
747
+ inputSchema: {
748
+ type: "object",
749
+ properties: {
750
+ sessionKey: { type: "string", description: "Conversation session identifier" },
751
+ namespace: { type: "string" },
752
+ tokensBefore: { type: "integer", minimum: 0 },
753
+ tokensAfter: { type: "integer", minimum: 0 }
754
+ },
755
+ required: ["sessionKey", "tokensBefore", "tokensAfter"],
756
+ additionalProperties: false
757
+ }
758
+ },
759
+ // ── Continuity / Identity tools ─────────────────────────────────────
760
+ {
761
+ name: "engram.continuity_audit_generate",
762
+ description: "Generate a deterministic identity continuity audit report (weekly/monthly).",
763
+ inputSchema: {
764
+ type: "object",
765
+ properties: {
766
+ period: { type: "string", enum: ["weekly", "monthly"] },
767
+ key: { type: "string", description: "Period key (weekly: YYYY-Www, monthly: YYYY-MM). Defaults to current." }
768
+ },
769
+ additionalProperties: false
770
+ }
771
+ },
772
+ {
773
+ name: "engram.continuity_incident_open",
774
+ description: "Create a new continuity incident record in append-only storage.",
775
+ inputSchema: {
776
+ type: "object",
777
+ properties: {
778
+ symptom: { type: "string", description: "Observed continuity failure symptom." },
779
+ namespace: { type: "string" },
780
+ triggerWindow: { type: "string", description: "Time window when incident occurred." },
781
+ suspectedCause: { type: "string" }
782
+ },
783
+ required: ["symptom"],
784
+ additionalProperties: false
785
+ }
786
+ },
787
+ {
788
+ name: "engram.continuity_incident_close",
789
+ description: "Close an open continuity incident with verification details.",
790
+ inputSchema: {
791
+ type: "object",
792
+ properties: {
793
+ id: { type: "string", description: "Incident ID to close." },
794
+ namespace: { type: "string" },
795
+ fixApplied: { type: "string", description: "What fix was applied." },
796
+ verificationResult: { type: "string", description: "How closure was verified." },
797
+ preventiveRule: { type: "string", description: "Optional preventive follow-up rule." }
798
+ },
799
+ required: ["id", "fixApplied", "verificationResult"],
800
+ additionalProperties: false
801
+ }
802
+ },
803
+ {
804
+ name: "engram.continuity_incident_list",
805
+ description: "List continuity incidents, optionally filtered by state.",
806
+ inputSchema: {
807
+ type: "object",
808
+ properties: {
809
+ state: { type: "string", enum: ["open", "closed", "all"] },
810
+ namespace: { type: "string" },
811
+ limit: { type: "number", description: "Max incidents (default 25, max 200)." }
812
+ },
813
+ additionalProperties: false
814
+ }
815
+ },
816
+ {
817
+ name: "engram.continuity_loop_add_or_update",
818
+ description: "Add or update a continuity improvement loop entry.",
819
+ inputSchema: {
820
+ type: "object",
821
+ properties: {
822
+ id: { type: "string", description: "Stable loop identifier." },
823
+ cadence: { type: "string", enum: ["daily", "weekly", "monthly", "quarterly"] },
824
+ purpose: { type: "string", description: "What this recurring loop improves." },
825
+ status: { type: "string", enum: ["active", "paused", "retired"] },
826
+ killCondition: { type: "string", description: "Clear condition for retiring this loop." },
827
+ namespace: { type: "string" },
828
+ lastReviewed: { type: "string", description: "ISO timestamp for last review." },
829
+ notes: { type: "string" }
830
+ },
831
+ required: ["id", "cadence", "purpose", "status", "killCondition"],
832
+ additionalProperties: false
833
+ }
834
+ },
835
+ {
836
+ name: "engram.continuity_loop_review",
837
+ description: "Update review metadata for an existing continuity improvement loop.",
838
+ inputSchema: {
839
+ type: "object",
840
+ properties: {
841
+ id: { type: "string", description: "Loop ID to review." },
842
+ namespace: { type: "string" },
843
+ status: { type: "string", enum: ["active", "paused", "retired"] },
844
+ notes: { type: "string" },
845
+ reviewedAt: { type: "string", description: "ISO timestamp for review event." }
846
+ },
847
+ required: ["id"],
848
+ additionalProperties: false
849
+ }
850
+ },
851
+ {
852
+ name: "engram.identity_anchor_get",
853
+ description: "Read the identity continuity anchor document (recovery-safe identity context).",
854
+ inputSchema: {
855
+ type: "object",
856
+ properties: {
857
+ namespace: { type: "string" }
858
+ },
859
+ additionalProperties: false
860
+ }
861
+ },
862
+ {
863
+ name: "engram.identity_anchor_update",
864
+ description: "Conservatively merge identity anchor sections without overwriting existing material.",
865
+ inputSchema: {
866
+ type: "object",
867
+ properties: {
868
+ namespace: { type: "string" },
869
+ identityTraits: { type: "string", description: "Updates for 'Identity Traits' section." },
870
+ communicationPreferences: { type: "string", description: "Updates for 'Communication Preferences' section." },
871
+ operatingPrinciples: { type: "string", description: "Updates for 'Operating Principles' section." },
872
+ continuityNotes: { type: "string", description: "Updates for 'Continuity Notes' section." }
873
+ },
874
+ additionalProperties: false
875
+ }
876
+ },
877
+ {
878
+ name: "engram.memory_identity",
879
+ description: "Read the agent's identity reflections from the workspace IDENTITY.md file.",
880
+ inputSchema: {
881
+ type: "object",
882
+ properties: {
883
+ namespace: { type: "string" }
884
+ },
885
+ additionalProperties: false
886
+ }
887
+ },
888
+ // ── Work Layer tools ─────────────────────────────────────────────────
889
+ {
890
+ name: "engram.work_task",
891
+ description: "Manage work-layer tasks (create, get, list, update, transition, delete). Excluded from memory extraction.",
892
+ inputSchema: {
893
+ type: "object",
894
+ properties: {
895
+ action: { type: "string", enum: ["create", "get", "list", "update", "transition", "delete"] },
896
+ id: { type: "string" },
897
+ title: { type: "string" },
898
+ description: { type: "string" },
899
+ status: { type: "string", enum: ["todo", "in_progress", "blocked", "done", "cancelled"] },
900
+ priority: { type: "string", enum: ["low", "medium", "high"] },
901
+ owner: { type: "string" },
902
+ assignee: { type: "string" },
903
+ projectId: { type: "string" },
904
+ tags: { type: "array", items: { type: "string" } },
905
+ dueAt: { type: "string" }
906
+ },
907
+ required: ["action"],
908
+ additionalProperties: false
909
+ }
910
+ },
911
+ {
912
+ name: "engram.work_project",
913
+ description: "Manage work-layer projects (create, get, list, update, delete, link_task). Excluded from memory extraction.",
914
+ inputSchema: {
915
+ type: "object",
916
+ properties: {
917
+ action: { type: "string", enum: ["create", "get", "list", "update", "delete", "link_task"] },
918
+ id: { type: "string" },
919
+ name: { type: "string" },
920
+ description: { type: "string" },
921
+ status: { type: "string", enum: ["active", "on_hold", "completed", "archived"] },
922
+ owner: { type: "string" },
923
+ tags: { type: "array", items: { type: "string" } },
924
+ taskId: { type: "string", description: "Task ID for link_task." },
925
+ projectId: { type: "string", description: "Project ID for link_task." }
926
+ },
927
+ required: ["action"],
928
+ additionalProperties: false
929
+ }
930
+ },
931
+ {
932
+ name: "engram.work_board",
933
+ description: "Export/import work-layer board snapshots and markdown.",
934
+ inputSchema: {
935
+ type: "object",
936
+ properties: {
937
+ action: { type: "string", enum: ["export_markdown", "export_snapshot", "import_snapshot"] },
938
+ projectId: { type: "string" },
939
+ snapshotJson: { type: "string", description: "Snapshot JSON for import_snapshot." },
940
+ linkToMemory: { type: "boolean", description: "If true, output can be retained as long-term memory." }
941
+ },
942
+ required: ["action"],
943
+ additionalProperties: false
944
+ }
945
+ },
946
+ // ── Shared Context / Compounding tools ────────────────────────────
947
+ {
948
+ name: "engram.shared_context_write_output",
949
+ description: "Write agent work product into shared-context directory for cross-agent coordination.",
950
+ inputSchema: {
951
+ type: "object",
952
+ properties: {
953
+ agentId: { type: "string", description: "Agent ID producing this output." },
954
+ title: { type: "string", description: "Short title for the output." },
955
+ content: { type: "string", description: "Markdown content to write." }
956
+ },
957
+ required: ["agentId", "title", "content"],
958
+ additionalProperties: false
959
+ }
960
+ },
961
+ {
962
+ name: "engram.shared_feedback_record",
963
+ description: "Append approval/rejection decision into shared-context feedback inbox for compounding learning.",
964
+ inputSchema: {
965
+ type: "object",
966
+ properties: {
967
+ agent: { type: "string", description: "Agent name that produced the output." },
968
+ decision: { type: "string", enum: ["approved", "approved_with_feedback", "rejected"] },
969
+ reason: { type: "string" },
970
+ date: { type: "string", description: "ISO timestamp. Defaults to now." },
971
+ learning: { type: "string" },
972
+ outcome: { type: "string" },
973
+ severity: { type: "string", enum: ["low", "medium", "high"] },
974
+ confidence: { type: "number", description: "Confidence 0-1." },
975
+ workflow: { type: "string" },
976
+ tags: { type: "array", items: { type: "string" } },
977
+ evidenceWindowStart: { type: "string" },
978
+ evidenceWindowEnd: { type: "string" },
979
+ refs: { type: "array", items: { type: "string" } }
980
+ },
981
+ required: ["agent", "decision", "reason"],
982
+ additionalProperties: false
983
+ }
984
+ },
985
+ {
986
+ name: "engram.shared_priorities_append",
987
+ description: "Append priorities text into shared-context inbox for curator merge.",
988
+ inputSchema: {
989
+ type: "object",
990
+ properties: {
991
+ agentId: { type: "string" },
992
+ text: { type: "string", description: "Priority notes (markdown)." }
993
+ },
994
+ required: ["agentId", "text"],
995
+ additionalProperties: false
996
+ }
997
+ },
998
+ {
999
+ name: "engram.shared_context_cross_signals_run",
1000
+ description: "Generate cross-signal markdown + JSON artifacts from agent outputs and feedback.",
1001
+ inputSchema: {
1002
+ type: "object",
1003
+ properties: {
1004
+ date: { type: "string", description: "YYYY-MM-DD. Defaults to today." }
1005
+ },
1006
+ additionalProperties: false
1007
+ }
1008
+ },
1009
+ {
1010
+ name: "engram.shared_context_curate_daily",
1011
+ description: "Generate daily roundtable summary (deterministic baseline aggregation).",
1012
+ inputSchema: {
1013
+ type: "object",
1014
+ properties: {
1015
+ date: { type: "string", description: "YYYY-MM-DD. Defaults to today." }
1016
+ },
1017
+ additionalProperties: false
1018
+ }
1019
+ },
1020
+ {
1021
+ name: "engram.compounding_weekly_synthesize",
1022
+ description: "Generate weekly compounding outputs: reports, mistake registry, rubrics, and promotion candidates.",
1023
+ inputSchema: {
1024
+ type: "object",
1025
+ properties: {
1026
+ weekId: { type: "string", description: "ISO week ID (YYYY-Www). Defaults to current week." }
1027
+ },
1028
+ additionalProperties: false
1029
+ }
1030
+ },
1031
+ {
1032
+ name: "engram.compounding_promote_candidate",
1033
+ description: "Promote a compounding candidate from weekly report into durable rule/principle memory.",
1034
+ inputSchema: {
1035
+ type: "object",
1036
+ properties: {
1037
+ weekId: { type: "string" },
1038
+ candidateId: { type: "string" },
1039
+ dryRun: { type: "boolean", description: "Preview without writing." }
1040
+ },
1041
+ required: ["weekId", "candidateId"],
1042
+ additionalProperties: false
1043
+ }
1044
+ },
1045
+ // ── Compression Guidelines tools ────────────────────────────────────
1046
+ {
1047
+ name: "engram.compression_guidelines_optimize",
1048
+ description: "Run compression guideline optimizer, optionally persisting new guidelines.",
1049
+ inputSchema: {
1050
+ type: "object",
1051
+ properties: {
1052
+ dryRun: { type: "boolean" },
1053
+ eventLimit: { type: "number" }
1054
+ },
1055
+ additionalProperties: false
1056
+ }
1057
+ },
1058
+ {
1059
+ name: "engram.compression_guidelines_activate",
1060
+ description: "Promote staged compression guideline draft to active (after review).",
1061
+ inputSchema: {
1062
+ type: "object",
1063
+ properties: {
1064
+ expectedContentHash: { type: "string" },
1065
+ expectedGuidelineVersion: { type: "number" }
1066
+ },
1067
+ additionalProperties: false
1068
+ }
1069
+ },
1070
+ // ── Memory search & debug tools ────────────────────────────────────
1071
+ {
1072
+ name: "engram.memory_search",
1073
+ description: "Direct semantic search over memory files using the QMD index. Returns matching memories with relevance scores.",
1074
+ inputSchema: {
1075
+ type: "object",
1076
+ properties: {
1077
+ query: { type: "string" },
1078
+ namespace: { type: "string" },
1079
+ maxResults: { type: "number" },
1080
+ collection: { type: "string", description: "QMD collection (omit for memory, 'global' for all)" }
1081
+ },
1082
+ required: ["query"],
1083
+ additionalProperties: false
1084
+ }
1085
+ },
1086
+ {
1087
+ name: "engram.memory_profile",
1088
+ description: "Read the user's behavioral profile \u2014 a living document of their preferences, habits, and personality.",
1089
+ inputSchema: {
1090
+ type: "object",
1091
+ properties: { namespace: { type: "string" } },
1092
+ additionalProperties: false
1093
+ }
1094
+ },
1095
+ {
1096
+ name: "engram.memory_entities_list",
1097
+ description: "List all tracked entities (people, projects, tools, companies).",
1098
+ inputSchema: {
1099
+ type: "object",
1100
+ properties: { namespace: { type: "string" } },
1101
+ additionalProperties: false
1102
+ }
1103
+ },
1104
+ {
1105
+ name: "engram.memory_questions",
1106
+ description: "List open questions the system is curious about from past conversations.",
1107
+ inputSchema: {
1108
+ type: "object",
1109
+ properties: { namespace: { type: "string" } },
1110
+ additionalProperties: false
1111
+ }
1112
+ },
1113
+ {
1114
+ name: "engram.memory_last_recall",
1115
+ description: "Return the last recall snapshot for a session (debug introspection).",
1116
+ inputSchema: {
1117
+ type: "object",
1118
+ properties: { sessionKey: { type: "string" } },
1119
+ additionalProperties: false
1120
+ }
1121
+ },
1122
+ {
1123
+ name: "engram.memory_intent_debug",
1124
+ description: "Return the last intent classification debug snapshot.",
1125
+ inputSchema: {
1126
+ type: "object",
1127
+ properties: { namespace: { type: "string" } },
1128
+ additionalProperties: false
1129
+ }
1130
+ },
1131
+ {
1132
+ name: "engram.memory_qmd_debug",
1133
+ description: "Return QMD search index debug information from the last recall.",
1134
+ inputSchema: {
1135
+ type: "object",
1136
+ properties: { namespace: { type: "string" } },
1137
+ additionalProperties: false
1138
+ }
1139
+ },
1140
+ {
1141
+ name: "engram.memory_graph_explain",
1142
+ description: "Explain the last entity graph recall \u2014 which entities were activated and why.",
1143
+ inputSchema: {
1144
+ type: "object",
1145
+ properties: { namespace: { type: "string" } },
1146
+ additionalProperties: false
1147
+ }
1148
+ },
1149
+ {
1150
+ // Graph snapshot for the admin pane (issue #691 PR 2/5). Returns
1151
+ // a read-only `{ nodes, edges, generatedAt }` view of the
1152
+ // multi-graph adjacency, with the same filter knobs as the HTTP
1153
+ // surface so connectors / CLI clients can hit either endpoint
1154
+ // interchangeably.
1155
+ name: "engram.graph_snapshot",
1156
+ description: "Return a read-only graph snapshot (nodes + edges) for the admin pane. Filters: limit (default 500, max 5000), since (ISO timestamp), focusNodeId (restricts to neighborhood), categories (allow-list of memory categories).",
1157
+ inputSchema: {
1158
+ type: "object",
1159
+ properties: {
1160
+ namespace: { type: "string" },
1161
+ limit: { type: "number", description: "Maximum number of edges to return (default 500, max 5000)." },
1162
+ since: { type: "string", description: "Inclusive lower bound on edge timestamp (ISO-8601)." },
1163
+ focusNodeId: { type: "string", description: "When set, restrict the snapshot to the focus node and its neighbors." },
1164
+ categories: {
1165
+ type: "array",
1166
+ items: { type: "string" },
1167
+ description: "Optional category allow-list (e.g. ['fact', 'decision'])."
1168
+ }
1169
+ },
1170
+ additionalProperties: false
1171
+ }
1172
+ },
1173
+ {
1174
+ name: "engram.memory_feedback",
1175
+ description: "Record relevance feedback (thumbs up/down) for a specific memory.",
1176
+ inputSchema: {
1177
+ type: "object",
1178
+ properties: {
1179
+ memoryId: { type: "string" },
1180
+ vote: { type: "string", enum: ["up", "down"] },
1181
+ note: { type: "string" }
1182
+ },
1183
+ required: ["memoryId", "vote"],
1184
+ additionalProperties: false
1185
+ }
1186
+ },
1187
+ {
1188
+ name: "engram.memory_promote",
1189
+ description: "Promote a memory's lifecycle state (e.g. from draft to active).",
1190
+ inputSchema: {
1191
+ type: "object",
1192
+ properties: {
1193
+ memoryId: { type: "string" },
1194
+ namespace: { type: "string" },
1195
+ sessionKey: { type: "string" }
1196
+ },
1197
+ required: ["memoryId"],
1198
+ additionalProperties: false
1199
+ }
1200
+ },
1201
+ // Memory Worth outcome signal (issue #560 PR 3). Callers record whether
1202
+ // a session that used a given memory ultimately succeeded or failed;
1203
+ // the counter is persisted in the memory's frontmatter (mw_success /
1204
+ // mw_fail) and will feed the recall-time filter added in PR 4.
1205
+ {
1206
+ name: "engram.memory_outcome",
1207
+ description: "Record a Memory Worth outcome (success/failure) for a memory. Increments mw_success or mw_fail in the memory's frontmatter for use by the recall filter.",
1208
+ inputSchema: {
1209
+ type: "object",
1210
+ properties: {
1211
+ memoryId: { type: "string" },
1212
+ outcome: { type: "string", enum: ["success", "failure"] },
1213
+ namespace: { type: "string" },
1214
+ sessionKey: { type: "string" },
1215
+ timestamp: { type: "string", description: "Optional ISO-8601 timestamp of the observation." }
1216
+ },
1217
+ required: ["memoryId", "outcome"],
1218
+ additionalProperties: false
1219
+ }
1220
+ },
1221
+ {
1222
+ name: "engram.memory_action_apply",
1223
+ description: "Record a memory-action application event for policy-learning telemetry.",
1224
+ inputSchema: {
1225
+ type: "object",
1226
+ properties: {
1227
+ action: {
1228
+ type: "string",
1229
+ enum: [
1230
+ "store_episode",
1231
+ "store_note",
1232
+ "update_note",
1233
+ "create_artifact",
1234
+ "summarize_node",
1235
+ "discard",
1236
+ "link_graph"
1237
+ ]
1238
+ },
1239
+ category: { type: "string" },
1240
+ content: { type: "string" },
1241
+ outcome: { type: "string", enum: ["applied", "skipped", "failed"] },
1242
+ reason: { type: "string" },
1243
+ memoryId: { type: "string" },
1244
+ sessionKey: { type: "string" },
1245
+ linkTargetId: { type: "string" },
1246
+ linkType: { type: "string" },
1247
+ linkStrength: { type: "number" },
1248
+ artifactType: { type: "string" },
1249
+ execute: { type: "boolean" },
1250
+ sourcePrompt: { type: "string" },
1251
+ namespace: { type: "string" },
1252
+ dryRun: { type: "boolean" }
1253
+ },
1254
+ required: ["action"],
1255
+ additionalProperties: false
1256
+ }
1257
+ },
1258
+ {
1259
+ name: "engram.context_checkpoint",
1260
+ description: "Save a structured context checkpoint for a session (preserves conversation state to disk).",
1261
+ inputSchema: {
1262
+ type: "object",
1263
+ properties: {
1264
+ sessionKey: { type: "string" },
1265
+ context: { type: "string", description: "Context content to checkpoint" },
1266
+ namespace: { type: "string" }
1267
+ },
1268
+ required: ["sessionKey", "context"],
1269
+ additionalProperties: false
1270
+ }
1271
+ },
1272
+ // ── Daily Context Briefing (#370) ───────────────────────────────────
1273
+ // Uses the legacy "engram.*" prefix like every other tool in this array;
1274
+ // withToolAliases (applied via .flatMap below) generates the canonical
1275
+ // "remnic.briefing" alias automatically.
1276
+ ...service.briefingEnabled ? [{
1277
+ name: "engram.briefing",
1278
+ description: "Generate a daily context briefing by cross-referencing active entities, recent facts, open commitments, and optional calendar events.",
1279
+ inputSchema: {
1280
+ type: "object",
1281
+ properties: {
1282
+ since: { type: "string", description: "Lookback window (e.g. 'yesterday', '3d', '1w', '24h')." },
1283
+ focus: { type: "string", description: "Optional focus filter (e.g. 'person:Jane Doe', 'project:remnic-core', 'topic:retrieval')." },
1284
+ namespace: { type: "string" },
1285
+ format: { type: "string", enum: ["markdown", "json"] },
1286
+ maxFollowups: { type: "number", description: "Maximum LLM-suggested follow-ups (0 disables that section)." }
1287
+ },
1288
+ additionalProperties: false
1289
+ }
1290
+ }] : [],
1291
+ // ── Contradiction Review (issue #520) ────────────────────────────────
1292
+ {
1293
+ name: "engram.review_list",
1294
+ description: "List contradiction review items pending user resolution.",
1295
+ inputSchema: {
1296
+ type: "object",
1297
+ properties: {
1298
+ filter: { type: "string", enum: ["all", "unresolved", "contradicts", "independent", "duplicates", "needs-user"], description: "Filter by verdict type. Default: unresolved." },
1299
+ namespace: { type: "string" },
1300
+ limit: { type: "number", description: "Max items to return (default 50)." }
1301
+ },
1302
+ additionalProperties: false
1303
+ }
1304
+ },
1305
+ {
1306
+ name: "engram.review_resolve",
1307
+ description: "Resolve a contradiction pair with a chosen verb.",
1308
+ inputSchema: {
1309
+ type: "object",
1310
+ properties: {
1311
+ pairId: { type: "string", description: "The contradiction pair ID to resolve." },
1312
+ verb: { type: "string", enum: ["keep-a", "keep-b", "merge", "both-valid", "needs-more-context"], description: "Resolution action." },
1313
+ mergedMemoryId: { type: "string", description: "Existing merged memory ID to use when verb is merge." },
1314
+ mergedContent: { type: "string", description: "Content for a new merged memory when verb is merge." }
1315
+ },
1316
+ required: ["pairId", "verb"],
1317
+ additionalProperties: false
1318
+ }
1319
+ },
1320
+ {
1321
+ name: "engram.contradiction_scan_run",
1322
+ description: "Run an on-demand contradiction scan over the memory corpus.",
1323
+ inputSchema: {
1324
+ type: "object",
1325
+ properties: {
1326
+ namespace: { type: "string" }
1327
+ },
1328
+ additionalProperties: false
1329
+ }
1330
+ },
1331
+ {
1332
+ name: "engram.memory_summarize_hourly",
1333
+ description: "Generate hourly summaries for recent conversations.",
1334
+ inputSchema: {
1335
+ type: "object",
1336
+ properties: {},
1337
+ additionalProperties: false
1338
+ }
1339
+ },
1340
+ {
1341
+ name: "engram.conversation_index_update",
1342
+ description: "Chunk transcript history into conversation-index documents.",
1343
+ inputSchema: {
1344
+ type: "object",
1345
+ properties: {
1346
+ sessionKey: { type: "string" },
1347
+ hours: { type: "number", description: "How many hours of transcript history to include." },
1348
+ embed: { type: "boolean", description: "If true, run QMD embed after update for this invocation." }
1349
+ },
1350
+ additionalProperties: false
1351
+ }
1352
+ },
1353
+ {
1354
+ name: "engram.profiling_report",
1355
+ description: "Return timing and performance data for Remnic recall and extraction pipelines. Requires profilingEnabled: true.",
1356
+ inputSchema: {
1357
+ type: "object",
1358
+ properties: {
1359
+ format: {
1360
+ type: "string",
1361
+ enum: ["ascii", "json"],
1362
+ description: "Output format. Defaults to ascii."
1363
+ },
1364
+ limit: {
1365
+ type: "integer",
1366
+ minimum: 1,
1367
+ maximum: 20,
1368
+ description: "Number of recent traces to include. Defaults to 5."
1369
+ }
1370
+ },
1371
+ additionalProperties: false
1372
+ }
1373
+ },
1374
+ {
1375
+ name: "engram.graph_edge_decay_run",
1376
+ description: "Run the graph-edge-confidence decay maintenance pass (issue #681 PR 2/3). Respects graphEdgeDecayEnabled; writes a structured telemetry record to state/graph-edge-decay-status.json.",
1377
+ inputSchema: {
1378
+ type: "object",
1379
+ properties: {
1380
+ dryRun: { type: "boolean" }
1381
+ },
1382
+ additionalProperties: false
1383
+ }
1384
+ },
1385
+ {
1386
+ name: "engram.live_connectors_run",
1387
+ description: "Run due live connectors once. Used by the live-connector cron and available for operator-triggered sync checks.",
1388
+ inputSchema: {
1389
+ type: "object",
1390
+ properties: {
1391
+ force: {
1392
+ type: "boolean",
1393
+ description: "When true, run enabled connectors even if their poll interval has not elapsed."
1394
+ }
1395
+ },
1396
+ additionalProperties: false
1397
+ }
1398
+ },
1399
+ // ── Peer Registry tools (issue #679 PR 4/5) ─────────────────────────
1400
+ {
1401
+ name: "engram.peer_list",
1402
+ description: "List all registered peers in the peer registry (issue #679). Returns an array of peer identity records sorted alphabetically by id.",
1403
+ inputSchema: {
1404
+ type: "object",
1405
+ properties: {},
1406
+ additionalProperties: false
1407
+ }
1408
+ },
1409
+ {
1410
+ name: "engram.peer_get",
1411
+ description: "Get a single peer by id. Returns the peer's identity record or { found: false } when not found (issue #679).",
1412
+ inputSchema: {
1413
+ type: "object",
1414
+ properties: {
1415
+ id: { type: "string", description: "Peer id to look up." }
1416
+ },
1417
+ required: ["id"],
1418
+ additionalProperties: false
1419
+ }
1420
+ },
1421
+ {
1422
+ name: "engram.peer_set",
1423
+ description: "Create or update a peer identity record (issue #679). On first write, creates the peer with the given kind (default 'human'). On subsequent writes, updates displayName and/or notes; kind and createdAt are immutable.",
1424
+ inputSchema: {
1425
+ type: "object",
1426
+ properties: {
1427
+ id: { type: "string", description: "Peer id \u2014 must match PEER_ID_PATTERN." },
1428
+ kind: {
1429
+ type: "string",
1430
+ enum: ["self", "human", "agent", "integration"],
1431
+ description: "Kind of peer. Required on first write; ignored on updates."
1432
+ },
1433
+ displayName: { type: "string", description: "Human-readable display name." },
1434
+ notes: { type: "string", description: "Optional free-form markdown notes." }
1435
+ },
1436
+ required: ["id"],
1437
+ additionalProperties: false
1438
+ }
1439
+ },
1440
+ {
1441
+ name: "engram.peer_delete",
1442
+ description: "Delete a peer's identity record (issue #679). Idempotent \u2014 succeeds even if the peer does not exist. The peer directory is preserved so profile and interaction-log data are not destroyed.",
1443
+ inputSchema: {
1444
+ type: "object",
1445
+ properties: {
1446
+ id: { type: "string", description: "Peer id to delete." }
1447
+ },
1448
+ required: ["id"],
1449
+ additionalProperties: false
1450
+ }
1451
+ },
1452
+ {
1453
+ name: "engram.peer_profile_get",
1454
+ description: "Get the evolving cognitive profile for a peer (issue #679). Returns the profile written by the async reasoner (PR 2/5), or { found: false } if no profile has been generated yet.",
1455
+ inputSchema: {
1456
+ type: "object",
1457
+ properties: {
1458
+ id: { type: "string", description: "Peer id whose profile to retrieve." }
1459
+ },
1460
+ required: ["id"],
1461
+ additionalProperties: false
1462
+ }
1463
+ },
1464
+ {
1465
+ name: "engram.peer_forget",
1466
+ description: "DESTRUCTIVELY purge the entire peer directory (identity.md + profile.md + interactions.log.md and any companion files). Requires confirm: 'yes'. Idempotent \u2014 safe to call twice. Use engram.peer_delete when you only want to remove the identity record and preserve profile data.",
1467
+ inputSchema: {
1468
+ type: "object",
1469
+ properties: {
1470
+ id: { type: "string", description: "Peer id to purge." },
1471
+ confirm: {
1472
+ type: "string",
1473
+ enum: ["yes"],
1474
+ description: "Must be exactly 'yes' to proceed. Guard against accidental invocation."
1475
+ }
1476
+ },
1477
+ required: ["id", "confirm"],
1478
+ additionalProperties: false
1479
+ }
1480
+ },
1481
+ // ── Operator Console state (issue #688 PR 2/3) ─────────────────────────
1482
+ {
1483
+ name: "engram.console_state",
1484
+ description: "Return a point-in-time ConsoleStateSnapshot of the engine's runtime state \u2014 buffer, extraction queue, dedup decisions, maintenance ledger tail, QMD probe, and daemon info (issue #688). Read-only; never mutates state.",
1485
+ inputSchema: {
1486
+ type: "object",
1487
+ properties: {
1488
+ namespace: {
1489
+ type: "string",
1490
+ description: "Optional namespace to scope the snapshot."
1491
+ }
1492
+ },
1493
+ additionalProperties: false
1494
+ }
1495
+ },
1496
+ // ── Dreams telemetry (issue #678 PR 3+4) ─────────────────────────────
1497
+ {
1498
+ name: "engram.dreams_status",
1499
+ description: "Return per-phase Dreams pipeline telemetry for the last N hours (default 24). Reports run count, total duration, and items processed for each phase: lightSleep, rem, deepSleep.",
1500
+ inputSchema: {
1501
+ type: "object",
1502
+ properties: {
1503
+ windowHours: {
1504
+ type: "number",
1505
+ description: "How many hours to look back (default 24, minimum 1)."
1506
+ },
1507
+ namespace: {
1508
+ type: "string",
1509
+ description: "Optional namespace to read Dreams telemetry from."
1510
+ }
1511
+ },
1512
+ additionalProperties: false
1513
+ }
1514
+ },
1515
+ {
1516
+ name: "engram.dreams_run",
1517
+ description: "Manually invoke a single Dreams pipeline phase (lightSleep, rem, or deepSleep). Returns the same telemetry shape as a scheduled run. Pass dryRun: true to preview without committing writes.",
1518
+ inputSchema: {
1519
+ type: "object",
1520
+ properties: {
1521
+ phase: {
1522
+ type: "string",
1523
+ enum: ["lightSleep", "rem", "deepSleep"],
1524
+ description: "Which phase to run."
1525
+ },
1526
+ dryRun: {
1527
+ type: "boolean",
1528
+ description: "When true, report what would change without committing writes (default false)."
1529
+ },
1530
+ namespace: {
1531
+ type: "string",
1532
+ description: "Optional namespace to run the phase in."
1533
+ }
1534
+ },
1535
+ required: ["phase"],
1536
+ additionalProperties: false
1537
+ }
1538
+ }
1539
+ ].flatMap((tool) => withToolAliases(tool));
1540
+ }
1541
+ service;
1542
+ buffer = Buffer.alloc(0);
1543
+ flushTask = null;
1544
+ tools;
1545
+ resources;
1546
+ resourceTextByUri;
1547
+ authenticatedPrincipal;
1548
+ /**
1549
+ * MCP client info keyed by server-assigned session ID. On each `initialize`
1550
+ * handshake the server generates a UUID, stores the client's clientInfo
1551
+ * against it, and returns the ID as `Mcp-Session-Id` in the response
1552
+ * metadata. Subsequent requests from the same client include this header,
1553
+ * allowing per-session clientInfo lookup without cross-session leaks.
1554
+ */
1555
+ clientInfoBySession = /* @__PURE__ */ new Map();
1556
+ /**
1557
+ * Session IDs generated during initialize, keyed by caller-supplied correlation
1558
+ * ID (unique per HTTP request) to avoid collisions when multiple clients send
1559
+ * initialize with the same JSON-RPC id concurrently.
1560
+ */
1561
+ initSessionIds = /* @__PURE__ */ new Map();
1562
+ /** Whether oai-mem-citation guidance is explicitly enabled via config. */
1563
+ citationsEnabled;
1564
+ /** Whether to auto-enable citations for Codex adapter connections. */
1565
+ citationsAutoDetect;
1566
+ /** Get clientInfo for a specific MCP session. Returns undefined for non-MCP requests. */
1567
+ getClientInfo(sessionId) {
1568
+ if (sessionId) {
1569
+ return this.clientInfoBySession.get(sessionId);
1570
+ }
1571
+ return void 0;
1572
+ }
1573
+ /** Pop the session ID generated during an initialize handshake, keyed by correlation ID. */
1574
+ popInitSessionId(correlationId) {
1575
+ const sid = this.initSessionIds.get(correlationId);
1576
+ if (sid !== void 0) this.initSessionIds.delete(correlationId);
1577
+ return sid;
1578
+ }
1579
+ async handleRequest(request, options) {
1580
+ const id = request.id ?? null;
1581
+ const method = request.method ?? "";
1582
+ if (method === "notifications/initialized") return null;
1583
+ if (method === "ping") {
1584
+ return { jsonrpc: "2.0", id, result: {} };
1585
+ }
1586
+ if (method === "initialize") {
1587
+ const params = request.params ?? {};
1588
+ const rawClientInfo = params.clientInfo;
1589
+ const newSessionId = randomUUID();
1590
+ if (rawClientInfo && typeof rawClientInfo.name === "string") {
1591
+ const info = { name: rawClientInfo.name, version: rawClientInfo.version };
1592
+ this.clientInfoBySession.set(newSessionId, info);
1593
+ if (this.clientInfoBySession.size > 1e3) {
1594
+ const firstKey = this.clientInfoBySession.keys().next().value;
1595
+ if (firstKey) this.clientInfoBySession.delete(firstKey);
1596
+ }
1597
+ }
1598
+ const version = await getMcpServerVersion();
1599
+ const corrId = options?.correlationId;
1600
+ if (corrId) this.initSessionIds.set(corrId, newSessionId);
1601
+ return {
1602
+ jsonrpc: "2.0",
1603
+ id,
1604
+ result: {
1605
+ protocolVersion: MCP_PROTOCOL_VERSION,
1606
+ capabilities: {
1607
+ tools: {},
1608
+ resources: {}
1609
+ },
1610
+ serverInfo: {
1611
+ name: "remnic",
1612
+ version
1613
+ }
1614
+ }
1615
+ };
1616
+ }
1617
+ if (method === "tools/list") {
1618
+ return {
1619
+ jsonrpc: "2.0",
1620
+ id,
1621
+ result: {
1622
+ tools: this.tools
1623
+ }
1624
+ };
1625
+ }
1626
+ if (method === "resources/list") {
1627
+ return {
1628
+ jsonrpc: "2.0",
1629
+ id,
1630
+ result: {
1631
+ resources: this.resources
1632
+ }
1633
+ };
1634
+ }
1635
+ if (method === "resources/templates/list") {
1636
+ return {
1637
+ jsonrpc: "2.0",
1638
+ id,
1639
+ result: {
1640
+ resourceTemplates: []
1641
+ }
1642
+ };
1643
+ }
1644
+ if (method === "resources/read") {
1645
+ const params = request.params ?? {};
1646
+ const uri = typeof params.uri === "string" ? params.uri : "";
1647
+ const resource = this.resources.find((entry) => entry.uri === uri);
1648
+ if (!resource) {
1649
+ return {
1650
+ jsonrpc: "2.0",
1651
+ id,
1652
+ error: {
1653
+ code: -32602,
1654
+ message: `Unknown resource URI: ${uri}`
1655
+ }
1656
+ };
1657
+ }
1658
+ const text = this.resourceTextByUri.get(resource.uri);
1659
+ if (text === void 0) {
1660
+ return {
1661
+ jsonrpc: "2.0",
1662
+ id,
1663
+ error: {
1664
+ code: -32603,
1665
+ message: `Resource content unavailable: ${resource.uri}`
1666
+ }
1667
+ };
1668
+ }
1669
+ return {
1670
+ jsonrpc: "2.0",
1671
+ id,
1672
+ result: {
1673
+ contents: [
1674
+ {
1675
+ uri: resource.uri,
1676
+ mimeType: resource.mimeType,
1677
+ text,
1678
+ _meta: resource._meta
1679
+ }
1680
+ ]
1681
+ }
1682
+ };
1683
+ }
1684
+ if (method === "tools/call") {
1685
+ const params = request.params ?? {};
1686
+ const name = typeof params.name === "string" ? params.name : "";
1687
+ try {
1688
+ let argumentsObject = {};
1689
+ if ("arguments" in params && params.arguments !== void 0) {
1690
+ if (params.arguments === null || typeof params.arguments !== "object" || Array.isArray(params.arguments)) {
1691
+ throw new EngramAccessInputError("tools/call arguments must be an object when provided");
1692
+ }
1693
+ argumentsObject = params.arguments;
1694
+ }
1695
+ const effectivePrincipal = options?.principalOverride ?? this.authenticatedPrincipal;
1696
+ const result = await this.callTool(name, argumentsObject, effectivePrincipal, options?.sessionId);
1697
+ return {
1698
+ jsonrpc: "2.0",
1699
+ id,
1700
+ result: {
1701
+ content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
1702
+ structuredContent: result,
1703
+ isError: false
1704
+ }
1705
+ };
1706
+ } catch (err) {
1707
+ const message = err instanceof Error ? err.message : String(err);
1708
+ return {
1709
+ jsonrpc: "2.0",
1710
+ id,
1711
+ result: {
1712
+ content: [{ type: "text", text: message }],
1713
+ isError: true
1714
+ }
1715
+ };
1716
+ }
1717
+ }
1718
+ return {
1719
+ jsonrpc: "2.0",
1720
+ id,
1721
+ error: {
1722
+ code: -32601,
1723
+ message: `Method not found: ${method}`
1724
+ }
1725
+ };
1726
+ }
1727
+ async runStdio(input, output) {
1728
+ input.on("data", (chunk) => {
1729
+ this.buffer = Buffer.concat([this.buffer, Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk)]);
1730
+ this.scheduleFlush(output);
1731
+ });
1732
+ await new Promise((resolve, reject) => {
1733
+ input.on("end", resolve);
1734
+ input.on("error", reject);
1735
+ });
1736
+ while (this.flushTask) {
1737
+ await this.flushTask;
1738
+ }
1739
+ }
1740
+ scheduleFlush(output) {
1741
+ if (this.flushTask) return;
1742
+ const task = this.flushBuffer(output).catch((err) => {
1743
+ this.writeMessage(output, {
1744
+ jsonrpc: "2.0",
1745
+ id: null,
1746
+ error: {
1747
+ code: -32700,
1748
+ message: err instanceof Error ? err.message : String(err)
1749
+ }
1750
+ });
1751
+ }).finally(() => {
1752
+ if (this.flushTask === task) {
1753
+ this.flushTask = null;
1754
+ }
1755
+ if (this.buffer.length > 0) {
1756
+ this.scheduleFlush(output);
1757
+ }
1758
+ });
1759
+ this.flushTask = task;
1760
+ }
1761
+ async flushBuffer(output) {
1762
+ while (true) {
1763
+ const headerEnd = this.buffer.indexOf("\r\n\r\n");
1764
+ if (headerEnd < 0) return;
1765
+ const headerText = this.buffer.slice(0, headerEnd).toString("utf-8");
1766
+ const headers = headerText.split("\r\n");
1767
+ const contentLengthHeader = headers.find((line) => line.toLowerCase().startsWith("content-length:"));
1768
+ if (!contentLengthHeader) {
1769
+ this.buffer = Buffer.alloc(0);
1770
+ return;
1771
+ }
1772
+ const contentLength = parseInt(contentLengthHeader.split(":")[1]?.trim() ?? "0", 10);
1773
+ if (!Number.isFinite(contentLength) || contentLength < 0) {
1774
+ this.buffer = Buffer.alloc(0);
1775
+ return;
1776
+ }
1777
+ const messageStart = headerEnd + 4;
1778
+ const messageEnd = messageStart + contentLength;
1779
+ if (this.buffer.length < messageEnd) return;
1780
+ const body = this.buffer.slice(messageStart, messageEnd).toString("utf-8");
1781
+ this.buffer = this.buffer.slice(messageEnd);
1782
+ let parsed;
1783
+ try {
1784
+ parsed = JSON.parse(body);
1785
+ } catch {
1786
+ this.writeMessage(output, {
1787
+ jsonrpc: "2.0",
1788
+ id: null,
1789
+ error: {
1790
+ code: -32700,
1791
+ message: "Parse error"
1792
+ }
1793
+ });
1794
+ continue;
1795
+ }
1796
+ const response = await this.handleRequest(parsed);
1797
+ if (response) {
1798
+ this.writeMessage(output, response);
1799
+ }
1800
+ }
1801
+ }
1802
+ writeMessage(output, payload) {
1803
+ const body = JSON.stringify(payload);
1804
+ const message = `Content-Length: ${Buffer.byteLength(body, "utf-8")}\r
1805
+ \r
1806
+ ${body}`;
1807
+ output.write(message);
1808
+ }
1809
+ /**
1810
+ * Determine whether oai-mem-citation guidance should be appended to recall.
1811
+ * Returns true when explicitly enabled via config OR when auto-detect is
1812
+ * active and the current MCP session belongs to a Codex adapter client.
1813
+ *
1814
+ * When no sessionId is provided (e.g., stdio transport where there are no
1815
+ * HTTP headers carrying mcp-session-id), fall back to checking if there is
1816
+ * exactly one known session whose clientInfo matches the Codex pattern.
1817
+ * This covers the common stdio case where a single client connection exists.
1818
+ */
1819
+ shouldEmitCitations(mcpSessionId) {
1820
+ if (this.citationsEnabled) return true;
1821
+ if (!this.citationsAutoDetect) return false;
1822
+ if (mcpSessionId) {
1823
+ const info = this.clientInfoBySession.get(mcpSessionId);
1824
+ if (!info) return false;
1825
+ return this.isCodexClient(info);
1826
+ }
1827
+ if (this.clientInfoBySession.size === 1) {
1828
+ const [info] = [...this.clientInfoBySession.values()];
1829
+ if (info) return this.isCodexClient(info);
1830
+ }
1831
+ return false;
1832
+ }
1833
+ /** Check whether a clientInfo record identifies a Codex adapter client. */
1834
+ isCodexClient(info) {
1835
+ const lowerName = info.name.toLowerCase();
1836
+ return lowerName === "codex-mcp-client" || lowerName.includes("codex");
1837
+ }
1838
+ /**
1839
+ * Build citation metadata for each recall result that has a path.
1840
+ * Line range defaults to 1-1 when not determinable from the summary.
1841
+ */
1842
+ buildRecallCitations(response) {
1843
+ return response.results.filter((r) => r.path && r.path.length > 0).map((r) => ({
1844
+ memoryId: r.id,
1845
+ path: r.path,
1846
+ lineStart: 1,
1847
+ lineEnd: 1,
1848
+ noteDefault: r.preview?.slice(0, 60) || r.id
1849
+ }));
1850
+ }
1851
+ async callTool(name, args, effectivePrincipal, mcpSessionId) {
1852
+ switch (toLegacyToolName(name)) {
1853
+ case "engram.recall": {
1854
+ let disclosure;
1855
+ if ("disclosure" in args && args.disclosure !== void 0 && args.disclosure !== null) {
1856
+ if (typeof args.disclosure !== "string") {
1857
+ throw new EngramAccessInputError(
1858
+ "disclosure must be a string (one of: chunk, section, raw)"
1859
+ );
1860
+ }
1861
+ disclosure = args.disclosure;
1862
+ }
1863
+ if ("cwd" in args && args.cwd !== void 0 && args.cwd !== null && typeof args.cwd !== "string") {
1864
+ throw new EngramAccessInputError("cwd must be a string");
1865
+ }
1866
+ if ("projectTag" in args && args.projectTag !== void 0 && args.projectTag !== null && typeof args.projectTag !== "string") {
1867
+ throw new EngramAccessInputError("projectTag must be a string");
1868
+ }
1869
+ if ("asOf" in args && args.asOf !== void 0 && args.asOf !== null && typeof args.asOf !== "string") {
1870
+ throw new EngramAccessInputError("asOf must be a string (ISO 8601 timestamp)");
1871
+ }
1872
+ let tags;
1873
+ if ("tags" in args && args.tags !== void 0 && args.tags !== null) {
1874
+ if (!Array.isArray(args.tags) || !args.tags.every((t) => typeof t === "string")) {
1875
+ throw new EngramAccessInputError("tags must be an array of strings");
1876
+ }
1877
+ tags = args.tags;
1878
+ }
1879
+ let tagMatch;
1880
+ if ("tagMatch" in args && args.tagMatch !== void 0 && args.tagMatch !== null) {
1881
+ if (typeof args.tagMatch !== "string" || args.tagMatch !== "any" && args.tagMatch !== "all") {
1882
+ throw new EngramAccessInputError(
1883
+ `tagMatch must be one of: any, all (got: ${String(args.tagMatch)})`
1884
+ );
1885
+ }
1886
+ tagMatch = args.tagMatch;
1887
+ }
1888
+ const response = await this.service.recall({
1889
+ query: typeof args.query === "string" ? args.query : "",
1890
+ sessionKey: typeof args.sessionKey === "string" ? args.sessionKey : void 0,
1891
+ authenticatedPrincipal: effectivePrincipal,
1892
+ namespace: typeof args.namespace === "string" ? args.namespace : void 0,
1893
+ topK: typeof args.topK === "number" && Number.isFinite(args.topK) ? args.topK : void 0,
1894
+ mode: typeof args.mode === "string" ? args.mode : void 0,
1895
+ includeDebug: args.includeDebug === true,
1896
+ disclosure,
1897
+ cwd: typeof args.cwd === "string" ? args.cwd : void 0,
1898
+ projectTag: typeof args.projectTag === "string" ? args.projectTag : void 0,
1899
+ asOf: typeof args.asOf === "string" ? args.asOf : void 0,
1900
+ ...tags !== void 0 ? { tags } : {},
1901
+ ...tagMatch !== void 0 ? { tagMatch } : {}
1902
+ });
1903
+ if (this.shouldEmitCitations(mcpSessionId)) {
1904
+ const citations = this.buildRecallCitations(response);
1905
+ const guidance = buildCitationGuidance(citations);
1906
+ if (guidance.length > 0) {
1907
+ return {
1908
+ ...response,
1909
+ context: response.context + guidance,
1910
+ citations
1911
+ };
1912
+ }
1913
+ }
1914
+ return response;
1915
+ }
1916
+ case "engram.recall_explain":
1917
+ return this.service.recallExplain({
1918
+ sessionKey: typeof args.sessionKey === "string" ? args.sessionKey : void 0,
1919
+ namespace: typeof args.namespace === "string" ? args.namespace : void 0
1920
+ });
1921
+ case "engram.set_coding_context": {
1922
+ const sessionKey = typeof args.sessionKey === "string" ? args.sessionKey : "";
1923
+ const hasProjectTag = typeof args.projectTag === "string" && args.projectTag.trim().length > 0;
1924
+ const hasCodingContext = "codingContext" in args;
1925
+ if (!hasCodingContext && hasProjectTag) {
1926
+ const tag = args.projectTag.trim();
1927
+ this.service.setCodingContext({
1928
+ sessionKey,
1929
+ codingContext: {
1930
+ projectId: `tag:${tag}`,
1931
+ branch: null,
1932
+ rootPath: `tag:${tag}`,
1933
+ defaultBranch: null
1934
+ }
1935
+ });
1936
+ return { ok: true };
1937
+ }
1938
+ if (!hasCodingContext && !hasProjectTag) {
1939
+ throw new EngramAccessInputError(
1940
+ "set_coding_context requires either codingContext or projectTag"
1941
+ );
1942
+ }
1943
+ const rawCtx = args.codingContext;
1944
+ let codingContext = null;
1945
+ if (rawCtx !== null) {
1946
+ if (typeof rawCtx !== "object" || rawCtx === void 0) {
1947
+ throw new EngramAccessInputError("codingContext must be an object or null");
1948
+ }
1949
+ const obj = rawCtx;
1950
+ const projectId = typeof obj.projectId === "string" ? obj.projectId : "";
1951
+ const rootPath = typeof obj.rootPath === "string" ? obj.rootPath : "";
1952
+ const branch = obj.branch === null ? null : typeof obj.branch === "string" ? obj.branch : void 0;
1953
+ const defaultBranch = obj.defaultBranch === null ? null : typeof obj.defaultBranch === "string" ? obj.defaultBranch : void 0;
1954
+ if (branch === void 0) {
1955
+ throw new EngramAccessInputError("codingContext.branch must be a string or null");
1956
+ }
1957
+ if (defaultBranch === void 0) {
1958
+ throw new EngramAccessInputError("codingContext.defaultBranch must be a string or null");
1959
+ }
1960
+ codingContext = { projectId, branch, rootPath, defaultBranch };
1961
+ }
1962
+ this.service.setCodingContext({ sessionKey, codingContext });
1963
+ return { ok: true };
1964
+ }
1965
+ case "engram.recall_tier_explain":
1966
+ return this.service.recallTierExplain(
1967
+ typeof args.sessionKey === "string" && args.sessionKey.length > 0 ? args.sessionKey : void 0,
1968
+ typeof args.namespace === "string" && args.namespace.length > 0 ? args.namespace : void 0,
1969
+ effectivePrincipal
1970
+ );
1971
+ case "engram.recall_xray": {
1972
+ const query = typeof args.query === "string" ? args.query : "";
1973
+ const sessionKey = typeof args.sessionKey === "string" && args.sessionKey.length > 0 ? args.sessionKey : void 0;
1974
+ const namespace = typeof args.namespace === "string" && args.namespace.length > 0 ? args.namespace : void 0;
1975
+ let budget;
1976
+ if (args.budget !== void 0 && args.budget !== null) {
1977
+ if (typeof args.budget !== "number" && typeof args.budget !== "string") {
1978
+ throw new Error(
1979
+ `engram.recall_xray: budget expects a positive integer; got ${JSON.stringify(args.budget)}`
1980
+ );
1981
+ }
1982
+ const parsed = typeof args.budget === "number" ? args.budget : Number(args.budget);
1983
+ if (!Number.isFinite(parsed) || parsed <= 0 || !Number.isInteger(parsed)) {
1984
+ throw new Error(
1985
+ `engram.recall_xray: budget expects a positive integer; got ${JSON.stringify(args.budget)}`
1986
+ );
1987
+ }
1988
+ budget = parsed;
1989
+ }
1990
+ let disclosure;
1991
+ if ("disclosure" in args && args.disclosure !== void 0 && args.disclosure !== null && args.disclosure !== "") {
1992
+ if (typeof args.disclosure !== "string") {
1993
+ throw new Error(
1994
+ "engram.recall_xray: disclosure must be a string (one of: chunk, section, raw)"
1995
+ );
1996
+ }
1997
+ disclosure = args.disclosure;
1998
+ }
1999
+ return this.service.recallXray({
2000
+ query,
2001
+ sessionKey,
2002
+ namespace,
2003
+ budget,
2004
+ authenticatedPrincipal: effectivePrincipal,
2005
+ ...disclosure !== void 0 ? { disclosure } : {}
2006
+ });
2007
+ }
2008
+ case "engram.action_confidence": {
2009
+ const body = parseMcpRequest("actionConfidence", args);
2010
+ return this.service.actionConfidence(body);
2011
+ }
2012
+ case REMNIC_CHATGPT_MEMORY_INSPECTOR_TOOL: {
2013
+ if (typeof args.query !== "string" || args.query.trim().length === 0) {
2014
+ throw new EngramAccessInputError(
2015
+ "chatgpt_memory_inspector requires a non-empty query string"
2016
+ );
2017
+ }
2018
+ if ("sessionKey" in args && args.sessionKey !== void 0 && args.sessionKey !== null && typeof args.sessionKey !== "string") {
2019
+ throw new EngramAccessInputError("sessionKey must be a string");
2020
+ }
2021
+ if ("namespace" in args && args.namespace !== void 0 && args.namespace !== null && typeof args.namespace !== "string") {
2022
+ throw new EngramAccessInputError("namespace must be a string");
2023
+ }
2024
+ let currentContextScopes;
2025
+ if (args.currentContextScopes !== void 0 && args.currentContextScopes !== null) {
2026
+ if (!Array.isArray(args.currentContextScopes) || !args.currentContextScopes.every((scope) => typeof scope === "string")) {
2027
+ throw new EngramAccessInputError(
2028
+ "currentContextScopes must be an array of strings"
2029
+ );
2030
+ }
2031
+ currentContextScopes = args.currentContextScopes;
2032
+ }
2033
+ const input = {
2034
+ query: args.query.trim()
2035
+ };
2036
+ if (typeof args.sessionKey === "string" && args.sessionKey.trim().length > 0) {
2037
+ input.sessionKey = args.sessionKey;
2038
+ }
2039
+ if (typeof args.namespace === "string" && args.namespace.trim().length > 0) {
2040
+ input.namespace = args.namespace;
2041
+ }
2042
+ if (currentContextScopes !== void 0) {
2043
+ input.currentContextScopes = currentContextScopes;
2044
+ }
2045
+ const recallSessionKey = resolveChatGptInspectorRecallSessionKey(
2046
+ input.sessionKey,
2047
+ effectivePrincipal
2048
+ );
2049
+ const xrayResponse = await this.service.recallXray({
2050
+ query: input.query,
2051
+ sessionKey: recallSessionKey,
2052
+ namespace: input.namespace,
2053
+ currentContextScopes: input.currentContextScopes,
2054
+ authenticatedPrincipal: effectivePrincipal,
2055
+ mode: "full",
2056
+ disclosure: "chunk",
2057
+ includeRecall: true
2058
+ });
2059
+ const xray = xrayResponse.snapshotFound === true ? xrayResponse.snapshot ?? null : null;
2060
+ const recall = xrayResponse.recall ?? {
2061
+ query: input.query,
2062
+ namespace: input.namespace ?? xray?.namespace ?? "global",
2063
+ context: "",
2064
+ count: 0,
2065
+ memoryIds: [],
2066
+ results: [],
2067
+ fallbackUsed: false,
2068
+ sourcesUsed: [],
2069
+ disclosure: "chunk"
2070
+ };
2071
+ const actionRequest = buildChatGptMemoryInspectorActionRequest(
2072
+ input,
2073
+ recall,
2074
+ xray
2075
+ );
2076
+ const actionConfidence = await this.service.actionConfidence(actionRequest);
2077
+ return buildChatGptMemoryInspectorResult(
2078
+ input,
2079
+ recall,
2080
+ xray,
2081
+ actionConfidence
2082
+ );
2083
+ }
2084
+ case "engram.day_summary":
2085
+ return this.service.daySummary({
2086
+ memories: typeof args.memories === "string" ? args.memories : "",
2087
+ sessionKey: typeof args.sessionKey === "string" ? args.sessionKey : void 0,
2088
+ namespace: typeof args.namespace === "string" ? args.namespace : void 0
2089
+ });
2090
+ case "engram.capsule_export": {
2091
+ const body = parseMcpRequest("capsuleExport", args);
2092
+ return this.service.capsuleExport({
2093
+ name: body.name,
2094
+ namespace: body.namespace,
2095
+ principal: effectivePrincipal,
2096
+ since: body.since,
2097
+ includeKinds: body.includeKinds,
2098
+ peerIds: body.peerIds,
2099
+ includeTranscripts: body.includeTranscripts,
2100
+ encrypt: body.encrypt
2101
+ });
2102
+ }
2103
+ case "engram.capsule_import": {
2104
+ const body = parseMcpRequest("capsuleImport", args);
2105
+ return this.service.capsuleImport({
2106
+ archivePath: expandTildePath(body.archivePath),
2107
+ namespace: body.namespace,
2108
+ principal: effectivePrincipal,
2109
+ mode: body.mode
2110
+ });
2111
+ }
2112
+ case "engram.capsule_list": {
2113
+ const body = parseMcpRequest("capsuleList", args);
2114
+ return this.service.capsuleList({
2115
+ namespace: body.namespace,
2116
+ principal: effectivePrincipal
2117
+ });
2118
+ }
2119
+ case "engram.memory_governance_run":
2120
+ return this.service.governanceRun({
2121
+ namespace: typeof args.namespace === "string" ? args.namespace : void 0,
2122
+ mode: args.mode === "apply" ? "apply" : "shadow",
2123
+ recentDays: typeof args.recentDays === "number" && Number.isFinite(args.recentDays) ? args.recentDays : void 0,
2124
+ maxMemories: typeof args.maxMemories === "number" && Number.isFinite(args.maxMemories) ? args.maxMemories : void 0,
2125
+ batchSize: typeof args.batchSize === "number" && Number.isFinite(args.batchSize) ? args.batchSize : void 0,
2126
+ authenticatedPrincipal: effectivePrincipal
2127
+ }, effectivePrincipal);
2128
+ case "engram.procedure_mining_run":
2129
+ return this.service.procedureMiningRun(
2130
+ {
2131
+ namespace: typeof args.namespace === "string" ? args.namespace : void 0,
2132
+ authenticatedPrincipal: effectivePrincipal
2133
+ },
2134
+ effectivePrincipal
2135
+ );
2136
+ case "engram.pattern_reinforcement_run":
2137
+ return this.service.patternReinforcementRun(
2138
+ {
2139
+ namespace: typeof args.namespace === "string" ? args.namespace : void 0,
2140
+ authenticatedPrincipal: effectivePrincipal,
2141
+ force: args.force === true
2142
+ },
2143
+ effectivePrincipal
2144
+ );
2145
+ case "remnic.procedural_stats":
2146
+ case "engram.procedural_stats":
2147
+ return this.service.procedureStats(
2148
+ {
2149
+ namespace: typeof args.namespace === "string" ? args.namespace : void 0
2150
+ },
2151
+ effectivePrincipal
2152
+ );
2153
+ case "engram.memory_get":
2154
+ return this.service.memoryGet(
2155
+ typeof args.memoryId === "string" ? args.memoryId : "",
2156
+ typeof args.namespace === "string" ? args.namespace : void 0,
2157
+ effectivePrincipal
2158
+ );
2159
+ case "engram.memory_timeline": {
2160
+ const limit = typeof args.limit === "number" && Number.isFinite(args.limit) ? args.limit : 200;
2161
+ return this.service.memoryTimeline(
2162
+ typeof args.memoryId === "string" ? args.memoryId : "",
2163
+ typeof args.namespace === "string" ? args.namespace : void 0,
2164
+ limit,
2165
+ effectivePrincipal
2166
+ );
2167
+ }
2168
+ case "engram.memory_store":
2169
+ return this.service.memoryStore({
2170
+ schemaVersion: typeof args.schemaVersion === "number" ? args.schemaVersion : void 0,
2171
+ idempotencyKey: typeof args.idempotencyKey === "string" ? args.idempotencyKey : void 0,
2172
+ dryRun: args.dryRun === true,
2173
+ sessionKey: typeof args.sessionKey === "string" ? args.sessionKey : void 0,
2174
+ authenticatedPrincipal: effectivePrincipal,
2175
+ content: typeof args.content === "string" ? args.content : "",
2176
+ category: typeof args.category === "string" ? args.category : void 0,
2177
+ confidence: typeof args.confidence === "number" ? args.confidence : void 0,
2178
+ namespace: typeof args.namespace === "string" ? args.namespace : void 0,
2179
+ tags: Array.isArray(args.tags) ? args.tags.filter((tag) => typeof tag === "string") : void 0,
2180
+ entityRef: typeof args.entityRef === "string" ? args.entityRef : void 0,
2181
+ ttl: typeof args.ttl === "string" ? args.ttl : void 0,
2182
+ sourceReason: typeof args.sourceReason === "string" ? args.sourceReason : void 0
2183
+ });
2184
+ case "engram.suggestion_submit":
2185
+ return this.service.suggestionSubmit({
2186
+ schemaVersion: typeof args.schemaVersion === "number" ? args.schemaVersion : void 0,
2187
+ idempotencyKey: typeof args.idempotencyKey === "string" ? args.idempotencyKey : void 0,
2188
+ dryRun: args.dryRun === true,
2189
+ sessionKey: typeof args.sessionKey === "string" ? args.sessionKey : void 0,
2190
+ authenticatedPrincipal: effectivePrincipal,
2191
+ content: typeof args.content === "string" ? args.content : "",
2192
+ category: typeof args.category === "string" ? args.category : void 0,
2193
+ confidence: typeof args.confidence === "number" ? args.confidence : void 0,
2194
+ namespace: typeof args.namespace === "string" ? args.namespace : void 0,
2195
+ tags: Array.isArray(args.tags) ? args.tags.filter((tag) => typeof tag === "string") : void 0,
2196
+ entityRef: typeof args.entityRef === "string" ? args.entityRef : void 0,
2197
+ ttl: typeof args.ttl === "string" ? args.ttl : void 0,
2198
+ sourceReason: typeof args.sourceReason === "string" ? args.sourceReason : void 0
2199
+ });
2200
+ case "engram.entity_get":
2201
+ return this.service.entityGet(
2202
+ typeof args.name === "string" ? args.name : "",
2203
+ typeof args.namespace === "string" ? args.namespace : void 0
2204
+ );
2205
+ case "engram.review_queue_list":
2206
+ return this.service.reviewQueue(
2207
+ typeof args.runId === "string" ? args.runId : void 0,
2208
+ typeof args.namespace === "string" ? args.namespace : void 0,
2209
+ effectivePrincipal
2210
+ );
2211
+ case "engram.observe": {
2212
+ const body = parseMcpRequest("observe", args);
2213
+ return this.service.observe({
2214
+ sessionKey: body.sessionKey,
2215
+ messages: body.messages.map((message) => ({
2216
+ role: message.role,
2217
+ content: message.content,
2218
+ parts: message.parts ?? void 0,
2219
+ rawContent: message.rawContent ?? void 0,
2220
+ sourceFormat: message.sourceFormat ?? void 0
2221
+ })),
2222
+ namespace: body.namespace,
2223
+ authenticatedPrincipal: effectivePrincipal,
2224
+ skipExtraction: body.skipExtraction === true,
2225
+ cwd: body.cwd,
2226
+ projectTag: body.projectTag
2227
+ });
2228
+ }
2229
+ case "engram.lcm_search":
2230
+ return this.service.lcmSearch({
2231
+ query: typeof args.query === "string" ? args.query : "",
2232
+ sessionKey: typeof args.sessionKey === "string" ? args.sessionKey : void 0,
2233
+ namespace: typeof args.namespace === "string" ? args.namespace : void 0,
2234
+ limit: typeof args.limit === "number" && Number.isFinite(args.limit) ? args.limit : void 0,
2235
+ authenticatedPrincipal: effectivePrincipal
2236
+ });
2237
+ case "engram.lcm_compaction_flush": {
2238
+ const body = parseMcpRequest("lcmCompactionFlush", args);
2239
+ return this.service.lcmCompactionFlush({
2240
+ sessionKey: body.sessionKey,
2241
+ namespace: body.namespace,
2242
+ authenticatedPrincipal: effectivePrincipal
2243
+ });
2244
+ }
2245
+ case "engram.lcm_compaction_record": {
2246
+ const body = parseMcpRequest("lcmCompactionRecord", args);
2247
+ return this.service.lcmCompactionRecord({
2248
+ sessionKey: body.sessionKey,
2249
+ namespace: body.namespace,
2250
+ tokensBefore: body.tokensBefore,
2251
+ tokensAfter: body.tokensAfter,
2252
+ authenticatedPrincipal: effectivePrincipal
2253
+ });
2254
+ }
2255
+ // ── Continuity / Identity tools ───────────────────────────────────
2256
+ case "engram.continuity_audit_generate":
2257
+ return this.service.continuityAuditGenerate({
2258
+ period: args.period === "monthly" ? "monthly" : args.period === "weekly" ? "weekly" : void 0,
2259
+ key: typeof args.key === "string" ? args.key : void 0
2260
+ });
2261
+ case "engram.continuity_incident_open":
2262
+ return this.service.continuityIncidentOpen({
2263
+ symptom: typeof args.symptom === "string" ? args.symptom : "",
2264
+ namespace: typeof args.namespace === "string" ? args.namespace : void 0,
2265
+ principal: effectivePrincipal,
2266
+ triggerWindow: typeof args.triggerWindow === "string" ? args.triggerWindow : void 0,
2267
+ suspectedCause: typeof args.suspectedCause === "string" ? args.suspectedCause : void 0
2268
+ });
2269
+ case "engram.continuity_incident_close":
2270
+ return this.service.continuityIncidentClose({
2271
+ id: typeof args.id === "string" ? args.id : "",
2272
+ namespace: typeof args.namespace === "string" ? args.namespace : void 0,
2273
+ principal: effectivePrincipal,
2274
+ fixApplied: typeof args.fixApplied === "string" ? args.fixApplied : "",
2275
+ verificationResult: typeof args.verificationResult === "string" ? args.verificationResult : "",
2276
+ preventiveRule: typeof args.preventiveRule === "string" ? args.preventiveRule : void 0
2277
+ });
2278
+ case "engram.continuity_incident_list":
2279
+ return this.service.continuityIncidentList({
2280
+ state: args.state === "closed" ? "closed" : args.state === "all" ? "all" : args.state === "open" ? "open" : void 0,
2281
+ namespace: typeof args.namespace === "string" ? args.namespace : void 0,
2282
+ principal: effectivePrincipal,
2283
+ limit: typeof args.limit === "number" ? args.limit : void 0
2284
+ });
2285
+ case "engram.continuity_loop_add_or_update":
2286
+ return this.service.continuityLoopAddOrUpdate({
2287
+ id: typeof args.id === "string" ? args.id : "",
2288
+ cadence: args.cadence ?? "weekly",
2289
+ purpose: typeof args.purpose === "string" ? args.purpose : "",
2290
+ status: args.status ?? "active",
2291
+ killCondition: typeof args.killCondition === "string" ? args.killCondition : "",
2292
+ namespace: typeof args.namespace === "string" ? args.namespace : void 0,
2293
+ principal: effectivePrincipal,
2294
+ lastReviewed: typeof args.lastReviewed === "string" ? args.lastReviewed : void 0,
2295
+ notes: typeof args.notes === "string" ? args.notes : void 0
2296
+ });
2297
+ case "engram.continuity_loop_review":
2298
+ return this.service.continuityLoopReview({
2299
+ id: typeof args.id === "string" ? args.id : "",
2300
+ namespace: typeof args.namespace === "string" ? args.namespace : void 0,
2301
+ principal: effectivePrincipal,
2302
+ status: args.status === "active" || args.status === "paused" || args.status === "retired" ? args.status : void 0,
2303
+ notes: typeof args.notes === "string" ? args.notes : void 0,
2304
+ reviewedAt: typeof args.reviewedAt === "string" ? args.reviewedAt : void 0
2305
+ });
2306
+ case "engram.identity_anchor_get":
2307
+ return this.service.identityAnchorGet({
2308
+ namespace: typeof args.namespace === "string" ? args.namespace : void 0,
2309
+ principal: effectivePrincipal
2310
+ });
2311
+ case "engram.identity_anchor_update":
2312
+ return this.service.identityAnchorUpdate({
2313
+ namespace: typeof args.namespace === "string" ? args.namespace : void 0,
2314
+ principal: effectivePrincipal,
2315
+ identityTraits: typeof args.identityTraits === "string" ? args.identityTraits : void 0,
2316
+ communicationPreferences: typeof args.communicationPreferences === "string" ? args.communicationPreferences : void 0,
2317
+ operatingPrinciples: typeof args.operatingPrinciples === "string" ? args.operatingPrinciples : void 0,
2318
+ continuityNotes: typeof args.continuityNotes === "string" ? args.continuityNotes : void 0
2319
+ });
2320
+ case "engram.memory_identity":
2321
+ return this.service.memoryIdentity({
2322
+ namespace: typeof args.namespace === "string" ? args.namespace : void 0,
2323
+ principal: effectivePrincipal
2324
+ });
2325
+ // ── Work Layer tools ──────────────────────────────────────────────
2326
+ case "engram.work_task":
2327
+ return this.service.workTask({
2328
+ action: args.action ?? "list",
2329
+ id: typeof args.id === "string" ? args.id : void 0,
2330
+ title: typeof args.title === "string" ? args.title : void 0,
2331
+ description: typeof args.description === "string" ? args.description : void 0,
2332
+ status: typeof args.status === "string" ? args.status : void 0,
2333
+ priority: typeof args.priority === "string" ? args.priority : void 0,
2334
+ owner: typeof args.owner === "string" ? args.owner : void 0,
2335
+ assignee: typeof args.assignee === "string" ? args.assignee : void 0,
2336
+ projectId: typeof args.projectId === "string" ? args.projectId : void 0,
2337
+ tags: Array.isArray(args.tags) ? args.tags.filter((x) => typeof x === "string") : void 0,
2338
+ dueAt: typeof args.dueAt === "string" ? args.dueAt : void 0
2339
+ });
2340
+ case "engram.work_project":
2341
+ return this.service.workProject({
2342
+ action: args.action ?? "list",
2343
+ id: typeof args.id === "string" ? args.id : void 0,
2344
+ name: typeof args.name === "string" ? args.name : void 0,
2345
+ description: typeof args.description === "string" ? args.description : void 0,
2346
+ status: typeof args.status === "string" ? args.status : void 0,
2347
+ owner: typeof args.owner === "string" ? args.owner : void 0,
2348
+ tags: Array.isArray(args.tags) ? args.tags.filter((x) => typeof x === "string") : void 0,
2349
+ taskId: typeof args.taskId === "string" ? args.taskId : void 0,
2350
+ projectId: typeof args.projectId === "string" ? args.projectId : void 0
2351
+ });
2352
+ case "engram.work_board":
2353
+ return this.service.workBoard({
2354
+ action: args.action ?? "export_markdown",
2355
+ projectId: typeof args.projectId === "string" ? args.projectId : void 0,
2356
+ snapshotJson: typeof args.snapshotJson === "string" ? args.snapshotJson : void 0,
2357
+ linkToMemory: args.linkToMemory === true
2358
+ });
2359
+ // ── Shared Context / Compounding tools ─────────────────────────
2360
+ case "engram.shared_context_write_output":
2361
+ return this.service.sharedContextWriteOutput({
2362
+ agentId: typeof args.agentId === "string" ? args.agentId : "",
2363
+ title: typeof args.title === "string" ? args.title : "",
2364
+ content: typeof args.content === "string" ? args.content : ""
2365
+ });
2366
+ case "engram.shared_feedback_record":
2367
+ return this.service.sharedFeedbackRecord({
2368
+ agent: typeof args.agent === "string" ? args.agent : "",
2369
+ decision: args.decision ?? "approved",
2370
+ reason: typeof args.reason === "string" ? args.reason : "",
2371
+ date: typeof args.date === "string" ? args.date : void 0,
2372
+ learning: typeof args.learning === "string" ? args.learning : void 0,
2373
+ outcome: typeof args.outcome === "string" ? args.outcome : void 0,
2374
+ severity: args.severity === "low" || args.severity === "medium" || args.severity === "high" ? args.severity : void 0,
2375
+ confidence: typeof args.confidence === "number" ? args.confidence : void 0,
2376
+ workflow: typeof args.workflow === "string" ? args.workflow : void 0,
2377
+ tags: Array.isArray(args.tags) ? args.tags.filter((x) => typeof x === "string") : void 0,
2378
+ evidenceWindowStart: typeof args.evidenceWindowStart === "string" ? args.evidenceWindowStart : void 0,
2379
+ evidenceWindowEnd: typeof args.evidenceWindowEnd === "string" ? args.evidenceWindowEnd : void 0,
2380
+ refs: Array.isArray(args.refs) ? args.refs.filter((x) => typeof x === "string") : void 0
2381
+ });
2382
+ case "engram.shared_priorities_append":
2383
+ return this.service.sharedPrioritiesAppend({
2384
+ agentId: typeof args.agentId === "string" ? args.agentId : "",
2385
+ text: typeof args.text === "string" ? args.text : ""
2386
+ });
2387
+ case "engram.shared_context_cross_signals_run":
2388
+ return this.service.sharedContextCrossSignalsRun({
2389
+ date: typeof args.date === "string" ? args.date : void 0
2390
+ });
2391
+ case "engram.shared_context_curate_daily":
2392
+ return this.service.sharedContextCurateDaily({
2393
+ date: typeof args.date === "string" ? args.date : void 0
2394
+ });
2395
+ case "engram.compounding_weekly_synthesize":
2396
+ return this.service.compoundingWeeklySynthesize({
2397
+ weekId: typeof args.weekId === "string" ? args.weekId : void 0
2398
+ });
2399
+ case "engram.compounding_promote_candidate":
2400
+ return this.service.compoundingPromoteCandidate({
2401
+ weekId: typeof args.weekId === "string" ? args.weekId : "",
2402
+ candidateId: typeof args.candidateId === "string" ? args.candidateId : "",
2403
+ dryRun: args.dryRun === true
2404
+ });
2405
+ // ── Compression Guidelines tools ───────────────────────────────────
2406
+ case "engram.compression_guidelines_optimize":
2407
+ return this.service.compressionGuidelinesOptimize({
2408
+ dryRun: args.dryRun === true,
2409
+ eventLimit: typeof args.eventLimit === "number" ? args.eventLimit : void 0
2410
+ });
2411
+ case "engram.compression_guidelines_activate":
2412
+ return this.service.compressionGuidelinesActivate({
2413
+ expectedContentHash: typeof args.expectedContentHash === "string" ? args.expectedContentHash : void 0,
2414
+ expectedGuidelineVersion: typeof args.expectedGuidelineVersion === "number" ? args.expectedGuidelineVersion : void 0
2415
+ });
2416
+ // ── Memory search & debug tools ──────────────────────────────────
2417
+ case "engram.memory_search":
2418
+ return this.service.memorySearch({
2419
+ query: typeof args.query === "string" ? args.query : "",
2420
+ namespace: typeof args.namespace === "string" ? args.namespace : void 0,
2421
+ maxResults: typeof args.maxResults === "number" && Number.isFinite(args.maxResults) ? args.maxResults : void 0,
2422
+ collection: typeof args.collection === "string" ? args.collection : void 0,
2423
+ principal: effectivePrincipal
2424
+ });
2425
+ case "engram.memory_profile":
2426
+ return this.service.memoryProfile(
2427
+ typeof args.namespace === "string" ? args.namespace : void 0,
2428
+ effectivePrincipal
2429
+ );
2430
+ case "engram.memory_entities_list":
2431
+ return this.service.memoryEntitiesList(
2432
+ typeof args.namespace === "string" ? args.namespace : void 0,
2433
+ effectivePrincipal
2434
+ );
2435
+ case "engram.memory_questions":
2436
+ return this.service.memoryQuestions(
2437
+ typeof args.namespace === "string" ? args.namespace : void 0,
2438
+ effectivePrincipal
2439
+ );
2440
+ case "engram.memory_last_recall":
2441
+ return this.service.lastRecallSnapshot(
2442
+ typeof args.sessionKey === "string" ? args.sessionKey : void 0
2443
+ );
2444
+ case "engram.memory_intent_debug":
2445
+ return this.service.intentDebug(
2446
+ typeof args.namespace === "string" ? args.namespace : void 0
2447
+ );
2448
+ case "engram.memory_qmd_debug":
2449
+ return this.service.qmdDebug(
2450
+ typeof args.namespace === "string" ? args.namespace : void 0
2451
+ );
2452
+ case "engram.memory_graph_explain":
2453
+ return this.service.graphExplainLastRecall(
2454
+ typeof args.namespace === "string" ? args.namespace : void 0
2455
+ );
2456
+ case "engram.graph_snapshot": {
2457
+ if (args.limit !== void 0 && typeof args.limit !== "number") {
2458
+ throw new Error("engram.graph_snapshot: limit must be a number");
2459
+ }
2460
+ if (args.since !== void 0 && typeof args.since !== "string") {
2461
+ throw new Error("engram.graph_snapshot: since must be a string");
2462
+ }
2463
+ if (args.focusNodeId !== void 0 && typeof args.focusNodeId !== "string") {
2464
+ throw new Error("engram.graph_snapshot: focusNodeId must be a string");
2465
+ }
2466
+ let categories;
2467
+ if (args.categories !== void 0) {
2468
+ if (!Array.isArray(args.categories)) {
2469
+ throw new Error(
2470
+ "engram.graph_snapshot: categories must be an array of strings"
2471
+ );
2472
+ }
2473
+ categories = args.categories.map((value, index) => {
2474
+ if (typeof value !== "string") {
2475
+ throw new Error(
2476
+ `engram.graph_snapshot: categories[${index}] must be a string`
2477
+ );
2478
+ }
2479
+ return value;
2480
+ });
2481
+ }
2482
+ return this.service.graphSnapshot(
2483
+ {
2484
+ namespace: typeof args.namespace === "string" ? args.namespace : void 0,
2485
+ limit: typeof args.limit === "number" ? args.limit : void 0,
2486
+ since: typeof args.since === "string" ? args.since : void 0,
2487
+ focusNodeId: typeof args.focusNodeId === "string" ? args.focusNodeId : void 0,
2488
+ ...categories !== void 0 ? { categories } : {}
2489
+ },
2490
+ effectivePrincipal
2491
+ );
2492
+ }
2493
+ case "engram.memory_feedback":
2494
+ return this.service.memoryFeedback({
2495
+ memoryId: typeof args.memoryId === "string" ? args.memoryId : "",
2496
+ vote: args.vote === "down" ? "down" : "up",
2497
+ note: typeof args.note === "string" ? args.note : void 0
2498
+ });
2499
+ case "engram.memory_promote":
2500
+ return this.service.memoryPromote({
2501
+ memoryId: typeof args.memoryId === "string" ? args.memoryId : "",
2502
+ namespace: typeof args.namespace === "string" ? args.namespace : void 0,
2503
+ principal: effectivePrincipal,
2504
+ sessionKey: typeof args.sessionKey === "string" ? args.sessionKey : void 0
2505
+ });
2506
+ case "engram.memory_outcome": {
2507
+ const outcome = args.outcome;
2508
+ if (outcome !== "success" && outcome !== "failure") {
2509
+ throw new Error(
2510
+ `engram.memory_outcome: outcome must be "success" or "failure"; got ${JSON.stringify(outcome)}`
2511
+ );
2512
+ }
2513
+ return this.service.memoryOutcome({
2514
+ memoryId: typeof args.memoryId === "string" ? args.memoryId : "",
2515
+ outcome,
2516
+ namespace: typeof args.namespace === "string" ? args.namespace : void 0,
2517
+ principal: effectivePrincipal,
2518
+ sessionKey: typeof args.sessionKey === "string" ? args.sessionKey : void 0,
2519
+ timestamp: typeof args.timestamp === "string" ? args.timestamp : void 0
2520
+ });
2521
+ }
2522
+ case "engram.memory_action_apply":
2523
+ return this.service.memoryActionApply({
2524
+ action: typeof args.action === "string" ? args.action : "",
2525
+ outcome: typeof args.outcome === "string" ? args.outcome : void 0,
2526
+ reason: typeof args.reason === "string" ? args.reason : void 0,
2527
+ memoryId: typeof args.memoryId === "string" ? args.memoryId : void 0,
2528
+ namespace: typeof args.namespace === "string" ? args.namespace : void 0,
2529
+ principal: effectivePrincipal,
2530
+ sessionKey: typeof args.sessionKey === "string" ? args.sessionKey : void 0,
2531
+ content: typeof args.content === "string" ? args.content : void 0,
2532
+ category: typeof args.category === "string" ? args.category : void 0,
2533
+ linkTargetId: typeof args.linkTargetId === "string" ? args.linkTargetId : void 0,
2534
+ linkType: typeof args.linkType === "string" ? args.linkType : void 0,
2535
+ linkStrength: typeof args.linkStrength === "number" ? args.linkStrength : void 0,
2536
+ artifactType: typeof args.artifactType === "string" ? args.artifactType : void 0,
2537
+ execute: typeof args.execute === "boolean" ? args.execute : void 0,
2538
+ sourcePrompt: typeof args.sourcePrompt === "string" ? args.sourcePrompt : void 0,
2539
+ dryRun: args.dryRun === true
2540
+ });
2541
+ case "engram.context_checkpoint":
2542
+ return this.service.contextCheckpoint({
2543
+ sessionKey: typeof args.sessionKey === "string" ? args.sessionKey : "",
2544
+ context: typeof args.context === "string" ? args.context : "",
2545
+ namespace: typeof args.namespace === "string" ? args.namespace : void 0,
2546
+ principal: effectivePrincipal
2547
+ });
2548
+ // ── Daily Context Briefing (#370) ───────────────────────────────────
2549
+ case "engram.briefing": {
2550
+ const rawFormat = typeof args.format === "string" ? args.format : void 0;
2551
+ const formatErr = validateBriefingFormat(rawFormat);
2552
+ if (formatErr) throw new Error(formatErr);
2553
+ return this.service.briefing({
2554
+ since: typeof args.since === "string" ? args.since : void 0,
2555
+ focus: typeof args.focus === "string" ? args.focus : void 0,
2556
+ namespace: typeof args.namespace === "string" ? args.namespace : void 0,
2557
+ format: rawFormat,
2558
+ maxFollowups: typeof args.maxFollowups === "number" ? args.maxFollowups : void 0,
2559
+ principal: effectivePrincipal
2560
+ });
2561
+ }
2562
+ // ── Contradiction Review (issue #520) ──────────────────────────────────
2563
+ case "engram.review_list":
2564
+ case "remnic.review_list": {
2565
+ const {
2566
+ isDefaultReviewNamespace,
2567
+ listPairs
2568
+ } = await import("./contradiction-review-ATP4S6IC.js");
2569
+ const VALID_REVIEW_FILTERS = /* @__PURE__ */ new Set(["all", "unresolved", "contradicts", "independent", "duplicates", "needs-user"]);
2570
+ const rawFilter = typeof args.filter === "string" ? args.filter : "unresolved";
2571
+ if (!VALID_REVIEW_FILTERS.has(rawFilter)) {
2572
+ throw new Error(`Invalid filter '${rawFilter}'. Valid: ${[...VALID_REVIEW_FILTERS].join(", ")}`);
2573
+ }
2574
+ const filter = rawFilter;
2575
+ const ns = typeof args.namespace === "string" ? args.namespace : void 0;
2576
+ const limit = typeof args.limit === "number" ? args.limit : 50;
2577
+ const resolved = await this.service.getReadableStorageForNamespace(ns, effectivePrincipal);
2578
+ const reviewNamespace = this.service.configRef.namespacesEnabled ? resolved.namespace : void 0;
2579
+ const includeUnscopedForNamespace = Boolean(
2580
+ reviewNamespace && isDefaultReviewNamespace(this.service.configRef.defaultNamespace, ns, reviewNamespace)
2581
+ );
2582
+ return listPairs(this.service.memoryDir, {
2583
+ filter,
2584
+ namespace: reviewNamespace,
2585
+ includeUnscopedForNamespace,
2586
+ limit
2587
+ });
2588
+ }
2589
+ case "engram.review_resolve":
2590
+ case "remnic.review_resolve": {
2591
+ const pairId = typeof args.pairId === "string" ? args.pairId : "";
2592
+ const verb = typeof args.verb === "string" ? args.verb : "";
2593
+ if (!pairId) throw new Error("pairId is required");
2594
+ if (!verb) throw new Error("verb is required");
2595
+ const { isValidResolutionVerb } = await import("./resolution-B7FNQSSP.js");
2596
+ if (!isValidResolutionVerb(verb)) throw new Error(`Invalid verb: ${verb}. Must be one of: keep-a, keep-b, merge, both-valid, needs-more-context`);
2597
+ const { executeResolution } = await import("./resolution-B7FNQSSP.js");
2598
+ return executeResolution(this.service.memoryDir, this.service.storageRef, pairId, verb, {
2599
+ mergedMemoryId: typeof args.mergedMemoryId === "string" ? args.mergedMemoryId : void 0,
2600
+ mergedContent: typeof args.mergedContent === "string" ? args.mergedContent : void 0,
2601
+ storageForNamespace: async (namespace) => {
2602
+ const resolved = await this.service.getWritableStorageForNamespace(namespace, effectivePrincipal);
2603
+ return resolved.storage;
2604
+ }
2605
+ });
2606
+ }
2607
+ case "engram.contradiction_scan_run":
2608
+ case "remnic.contradiction_scan_run": {
2609
+ const { runContradictionScan } = await import("./contradiction-scan-5A4IDZV5.js");
2610
+ return runContradictionScan({
2611
+ storage: this.service.storageRef,
2612
+ config: this.service.configRef,
2613
+ memoryDir: this.service.memoryDir,
2614
+ embeddingLookupFactory: this.service.embeddingLookupFactoryRef,
2615
+ storageForNamespace: (namespace) => this.service.getWritableStorageForNamespace(namespace, effectivePrincipal),
2616
+ localLlm: this.service.localLlmRef,
2617
+ fallbackLlm: this.service.fallbackLlmRef,
2618
+ namespace: typeof args.namespace === "string" ? args.namespace : void 0
2619
+ });
2620
+ }
2621
+ case "engram.memory_summarize_hourly":
2622
+ case "remnic.memory_summarize_hourly":
2623
+ return this.service.memorySummarizeHourly();
2624
+ case "engram.conversation_index_update":
2625
+ case "remnic.conversation_index_update": {
2626
+ if ("sessionKey" in args && args.sessionKey !== void 0 && typeof args.sessionKey !== "string") {
2627
+ throw new Error("sessionKey must be a string when provided");
2628
+ }
2629
+ const sessionKey = typeof args.sessionKey === "string" ? args.sessionKey : void 0;
2630
+ return this.service.conversationIndexUpdate({
2631
+ sessionKey,
2632
+ hours: typeof args.hours === "number" && Number.isFinite(args.hours) ? args.hours : void 0,
2633
+ embed: typeof args.embed === "boolean" ? args.embed : void 0
2634
+ });
2635
+ }
2636
+ case "engram.profiling_report":
2637
+ case "remnic.profiling_report": {
2638
+ if ("format" in args && args.format !== void 0 && typeof args.format !== "string") {
2639
+ throw new EngramAccessInputError("format must be a string when provided");
2640
+ }
2641
+ if ("limit" in args && args.limit !== void 0 && typeof args.limit !== "number") {
2642
+ throw new EngramAccessInputError("limit must be a number when provided");
2643
+ }
2644
+ return this.service.profilingReport({
2645
+ format: typeof args.format === "string" ? args.format : void 0,
2646
+ limit: typeof args.limit === "number" ? args.limit : void 0
2647
+ });
2648
+ }
2649
+ case "engram.graph_edge_decay_run":
2650
+ case "remnic.graph_edge_decay_run": {
2651
+ const cfg = this.service.configRef;
2652
+ if (!cfg.graphEdgeDecayEnabled) {
2653
+ return {
2654
+ ranAt: (/* @__PURE__ */ new Date()).toISOString(),
2655
+ disabled: true,
2656
+ reason: "graphEdgeDecayEnabled is false"
2657
+ };
2658
+ }
2659
+ const { runGraphEdgeDecayMaintenanceAcrossNamespaces } = await import("./graph-edge-decay-5DI5GUNL.js");
2660
+ const dryRun = args.dryRun === true;
2661
+ const results = await runGraphEdgeDecayMaintenanceAcrossNamespaces(
2662
+ this.service.memoryDir,
2663
+ {
2664
+ windowMs: cfg.graphEdgeDecayWindowMs,
2665
+ perWindow: cfg.graphEdgeDecayPerWindow,
2666
+ floor: cfg.graphEdgeDecayFloor,
2667
+ visibilityThreshold: cfg.graphEdgeDecayVisibilityThreshold,
2668
+ dryRun,
2669
+ namespacesEnabled: cfg.namespacesEnabled === true,
2670
+ defaultNamespace: cfg.defaultNamespace
2671
+ }
2672
+ );
2673
+ return { results };
2674
+ }
2675
+ case "engram.live_connectors_run":
2676
+ case "remnic.live_connectors_run":
2677
+ return this.service.liveConnectorsRun(
2678
+ {
2679
+ authenticatedPrincipal: effectivePrincipal,
2680
+ force: args.force === true
2681
+ },
2682
+ effectivePrincipal
2683
+ );
2684
+ // ── Peer Registry dispatchers (issue #679 PR 4/5) ─────────────────
2685
+ case "engram.peer_list":
2686
+ case "remnic.peer_list":
2687
+ return this.service.peerList();
2688
+ case "engram.peer_get":
2689
+ case "remnic.peer_get": {
2690
+ const id = typeof args.id === "string" ? args.id : "";
2691
+ if (!id) throw new Error("engram.peer_get: id is required");
2692
+ return this.service.peerGet(id);
2693
+ }
2694
+ case "engram.peer_set":
2695
+ case "remnic.peer_set": {
2696
+ const id = typeof args.id === "string" ? args.id : "";
2697
+ if (!id) throw new Error("engram.peer_set: id is required");
2698
+ if (args.kind !== void 0 && typeof args.kind !== "string") {
2699
+ throw new Error("engram.peer_set: kind must be a string when provided");
2700
+ }
2701
+ if (args.displayName !== void 0 && typeof args.displayName !== "string") {
2702
+ throw new Error("engram.peer_set: displayName must be a string when provided");
2703
+ }
2704
+ if (args.notes !== void 0 && typeof args.notes !== "string") {
2705
+ throw new Error("engram.peer_set: notes must be a string when provided");
2706
+ }
2707
+ return this.service.peerSet({
2708
+ id,
2709
+ kind: typeof args.kind === "string" ? args.kind : void 0,
2710
+ displayName: typeof args.displayName === "string" ? args.displayName : void 0,
2711
+ notes: typeof args.notes === "string" ? args.notes : void 0
2712
+ });
2713
+ }
2714
+ case "engram.peer_delete":
2715
+ case "remnic.peer_delete": {
2716
+ const id = typeof args.id === "string" ? args.id : "";
2717
+ if (!id) throw new Error("engram.peer_delete: id is required");
2718
+ return this.service.peerDelete(id);
2719
+ }
2720
+ case "engram.peer_profile_get":
2721
+ case "remnic.peer_profile_get": {
2722
+ const id = typeof args.id === "string" ? args.id : "";
2723
+ if (!id) throw new Error("engram.peer_profile_get: id is required");
2724
+ return this.service.peerProfileGet(id);
2725
+ }
2726
+ case "engram.peer_forget":
2727
+ case "remnic.peer_forget": {
2728
+ const id = typeof args.id === "string" ? args.id : "";
2729
+ if (!id) throw new Error("engram.peer_forget: id is required");
2730
+ const confirm = typeof args.confirm === "string" ? args.confirm : "";
2731
+ if (confirm !== "yes") {
2732
+ throw new Error(
2733
+ "engram.peer_forget: confirm must be 'yes' to prevent accidental data loss"
2734
+ );
2735
+ }
2736
+ return this.service.peerForget(id, { confirm: "yes" });
2737
+ }
2738
+ // ── Operator Console state (issue #688 PR 2/3) ──────────────────────────
2739
+ case "engram.console_state":
2740
+ case "remnic.console_state":
2741
+ return this.service.consoleState(
2742
+ typeof args.namespace === "string" ? args.namespace : void 0,
2743
+ effectivePrincipal
2744
+ );
2745
+ // ── Dreams telemetry (issue #678 PR 3+4) ──────────────────────────────
2746
+ case "engram.dreams_status":
2747
+ case "remnic.dreams_status": {
2748
+ const { normalizeDreamsStatusWindowHours } = await import("./dreams-ledger-LR2NBAZE.js");
2749
+ let windowHours = 24;
2750
+ try {
2751
+ windowHours = normalizeDreamsStatusWindowHours(args.windowHours);
2752
+ } catch {
2753
+ throw new Error(
2754
+ `engram.dreams_status: windowHours must be a positive integer (e.g. 24). Got: ${String(args.windowHours)}`
2755
+ );
2756
+ }
2757
+ if ("namespace" in args && args.namespace !== void 0 && typeof args.namespace !== "string") {
2758
+ throw new Error("engram.dreams_status: namespace must be a string when provided");
2759
+ }
2760
+ const namespace = typeof args.namespace === "string" ? args.namespace : void 0;
2761
+ return this.service.dreamsStatus({
2762
+ windowHours,
2763
+ namespace,
2764
+ principal: effectivePrincipal
2765
+ });
2766
+ }
2767
+ case "engram.dreams_run":
2768
+ case "remnic.dreams_run": {
2769
+ const VALID_PHASES = ["lightSleep", "rem", "deepSleep"];
2770
+ const phase = typeof args.phase === "string" ? args.phase : "";
2771
+ if (!phase || !VALID_PHASES.includes(phase)) {
2772
+ throw new Error(
2773
+ `engram.dreams_run: phase is required and must be one of: ${VALID_PHASES.join(", ")}`
2774
+ );
2775
+ }
2776
+ if ("dryRun" in args && args.dryRun !== void 0 && typeof args.dryRun !== "boolean") {
2777
+ throw new Error("engram.dreams_run: dryRun must be a boolean when provided");
2778
+ }
2779
+ if ("namespace" in args && args.namespace !== void 0 && typeof args.namespace !== "string") {
2780
+ throw new Error("engram.dreams_run: namespace must be a string when provided");
2781
+ }
2782
+ const namespace = typeof args.namespace === "string" ? args.namespace : void 0;
2783
+ const dryRun = args.dryRun === true;
2784
+ return this.service.dreamsRun({
2785
+ phase,
2786
+ dryRun,
2787
+ namespace,
2788
+ authenticatedPrincipal: effectivePrincipal
2789
+ });
2790
+ }
2791
+ default:
2792
+ throw new Error(`unknown tool: ${name}`);
2793
+ }
2794
+ }
2795
+ };
2796
+
2797
+ export {
2798
+ EngramMcpServer
2799
+ };
2800
+ //# sourceMappingURL=chunk-WZYKANL3.js.map