@remnic/core 1.1.12 → 1.1.14

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