@remnic/core 1.0.3 → 1.1.1

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 (323) hide show
  1. package/dist/abort-error.d.ts +32 -0
  2. package/dist/abort-error.js +11 -0
  3. package/dist/access-audit.d.ts +56 -0
  4. package/dist/access-audit.js +9 -0
  5. package/dist/access-audit.js.map +1 -0
  6. package/dist/access-cli.js +72 -54
  7. package/dist/access-cli.js.map +1 -1
  8. package/dist/access-http.d.ts +16 -8
  9. package/dist/access-http.js +25 -17
  10. package/dist/access-mcp.d.ts +16 -8
  11. package/dist/access-mcp.js +28 -6
  12. package/dist/access-schema.d.ts +130 -39
  13. package/dist/access-schema.js +5 -1
  14. package/dist/access-service-Br8ZydTK.d.ts +827 -0
  15. package/dist/access-service.d.ts +20 -660
  16. package/dist/access-service.js +22 -14
  17. package/dist/bootstrap.d.ts +6 -3
  18. package/dist/briefing.d.ts +1 -0
  19. package/dist/briefing.js +6 -5
  20. package/dist/buffer-surprise-report.d.ts +70 -0
  21. package/dist/buffer-surprise-report.js +7 -0
  22. package/dist/buffer-surprise-report.js.map +1 -0
  23. package/dist/buffer-surprise.d.ts +98 -0
  24. package/dist/buffer-surprise.js +11 -0
  25. package/dist/buffer-surprise.js.map +1 -0
  26. package/dist/buffer.d.ts +100 -2
  27. package/dist/buffer.js +1 -1
  28. package/dist/calibration.js +5 -5
  29. package/dist/causal-behavior.js +4 -4
  30. package/dist/causal-chain.js +2 -2
  31. package/dist/causal-consolidation.js +17 -16
  32. package/dist/causal-consolidation.js.map +1 -1
  33. package/dist/causal-retrieval.js +4 -4
  34. package/dist/causal-trajectory.js +1 -1
  35. package/dist/{chunk-QNJMBKFK.js → chunk-2LGMW3DJ.js} +3 -2
  36. package/dist/chunk-2LGMW3DJ.js.map +1 -0
  37. package/dist/{chunk-QDYXG4CS.js → chunk-3FPTCC3Z.js} +4 -3
  38. package/dist/chunk-3FPTCC3Z.js.map +1 -0
  39. package/dist/chunk-3GPTTA4J.js +57 -0
  40. package/dist/chunk-3GPTTA4J.js.map +1 -0
  41. package/dist/{chunk-QKAH5B6E.js → chunk-3GXCSUXR.js} +94 -6
  42. package/dist/chunk-3GXCSUXR.js.map +1 -0
  43. package/dist/{chunk-POBPGDWI.js → chunk-3OGMS3PE.js} +2 -2
  44. package/dist/chunk-54V4BZWP.js +139 -0
  45. package/dist/chunk-54V4BZWP.js.map +1 -0
  46. package/dist/chunk-5JRF2PZA.js +67 -0
  47. package/dist/chunk-5JRF2PZA.js.map +1 -0
  48. package/dist/chunk-64NJRYU2.js +332 -0
  49. package/dist/chunk-64NJRYU2.js.map +1 -0
  50. package/dist/chunk-6AUUAZEX.js +150 -0
  51. package/dist/chunk-6AUUAZEX.js.map +1 -0
  52. package/dist/{chunk-HITJFT7E.js → chunk-7I7FKFZH.js} +28 -21
  53. package/dist/chunk-7I7FKFZH.js.map +1 -0
  54. package/dist/chunk-AJU4PJGY.js +126 -0
  55. package/dist/chunk-AJU4PJGY.js.map +1 -0
  56. package/dist/chunk-ASAITVLA.js +64 -0
  57. package/dist/chunk-ASAITVLA.js.map +1 -0
  58. package/dist/{chunk-X4WESCKA.js → chunk-B5WXLVDY.js} +187 -6
  59. package/dist/chunk-B5WXLVDY.js.map +1 -0
  60. package/dist/{chunk-RCICHSHL.js → chunk-BGJGXLZ7.js} +111 -2
  61. package/dist/{chunk-RCICHSHL.js.map → chunk-BGJGXLZ7.js.map} +1 -1
  62. package/dist/{chunk-OJFGVJS6.js → chunk-BK2EFTE2.js} +319 -18
  63. package/dist/chunk-BK2EFTE2.js.map +1 -0
  64. package/dist/chunk-C4SQJZAF.js +486 -0
  65. package/dist/chunk-C4SQJZAF.js.map +1 -0
  66. package/dist/{chunk-GJQPH5G3.js → chunk-CUPFXL3J.js} +2 -2
  67. package/dist/chunk-DF3RVK3X.js +119 -0
  68. package/dist/chunk-DF3RVK3X.js.map +1 -0
  69. package/dist/{chunk-PMB3WGDL.js → chunk-DFTTJYSO.js} +167 -7
  70. package/dist/chunk-DFTTJYSO.js.map +1 -0
  71. package/dist/chunk-DGVM5SFL.js +69 -0
  72. package/dist/chunk-DGVM5SFL.js.map +1 -0
  73. package/dist/chunk-EIR5VLIH.js +90 -0
  74. package/dist/chunk-EIR5VLIH.js.map +1 -0
  75. package/dist/{chunk-PAORGQRI.js → chunk-EPQJM2GC.js} +37 -23
  76. package/dist/chunk-EPQJM2GC.js.map +1 -0
  77. package/dist/{chunk-POMSFKTB.js → chunk-F5VP6YCB.js} +368 -10
  78. package/dist/chunk-F5VP6YCB.js.map +1 -0
  79. package/dist/{chunk-6ZH4TU6I.js → chunk-FAAFWE4G.js} +2 -1
  80. package/dist/chunk-FAAFWE4G.js.map +1 -0
  81. package/dist/{chunk-74JR4N5J.js → chunk-FVA6TGI3.js} +2 -2
  82. package/dist/chunk-GDFS42HT.js +206 -0
  83. package/dist/chunk-GDFS42HT.js.map +1 -0
  84. package/dist/{chunk-BKQJBXXX.js → chunk-GGD5W7TB.js} +2 -2
  85. package/dist/chunk-GGD5W7TB.js.map +1 -0
  86. package/dist/{chunk-V7XCAHIB.js → chunk-GKFXUTJ2.js} +508 -26
  87. package/dist/chunk-GKFXUTJ2.js.map +1 -0
  88. package/dist/{chunk-NSB3WSYS.js → chunk-HK3FGIEW.js} +278 -3
  89. package/dist/chunk-HK3FGIEW.js.map +1 -0
  90. package/dist/{chunk-AAI7JARD.js → chunk-HMDCOMYU.js} +8 -11
  91. package/dist/chunk-HMDCOMYU.js.map +1 -0
  92. package/dist/chunk-IISBCCWR.js +52 -0
  93. package/dist/chunk-IISBCCWR.js.map +1 -0
  94. package/dist/{chunk-YFYL2SIJ.js → chunk-INXV5JBT.js} +290 -46
  95. package/dist/chunk-INXV5JBT.js.map +1 -0
  96. package/dist/chunk-JBMSGZEQ.js +441 -0
  97. package/dist/chunk-JBMSGZEQ.js.map +1 -0
  98. package/dist/{chunk-UPMD5XND.js → chunk-JL2PU6AI.js} +16 -5
  99. package/dist/chunk-JL2PU6AI.js.map +1 -0
  100. package/dist/{chunk-J4IYOZZ5.js → chunk-JXS5PDQ7.js} +3 -1
  101. package/dist/chunk-JXS5PDQ7.js.map +1 -0
  102. package/dist/{chunk-AYPYCLR7.js → chunk-KUB6JU6H.js} +4 -4
  103. package/dist/chunk-KVBLZUKV.js +173 -0
  104. package/dist/chunk-KVBLZUKV.js.map +1 -0
  105. package/dist/chunk-LBLXEFWK.js +51 -0
  106. package/dist/chunk-LBLXEFWK.js.map +1 -0
  107. package/dist/{chunk-U2IQTSBY.js → chunk-LTCGGW2D.js} +1 -1
  108. package/dist/chunk-LTCGGW2D.js.map +1 -0
  109. package/dist/{chunk-UEYA6UC7.js → chunk-NZLQTHS5.js} +25 -2
  110. package/dist/chunk-NZLQTHS5.js.map +1 -0
  111. package/dist/chunk-PVGDJXVK.js +21 -0
  112. package/dist/chunk-PVGDJXVK.js.map +1 -0
  113. package/dist/chunk-PVPWZSSI.js +37 -0
  114. package/dist/chunk-PVPWZSSI.js.map +1 -0
  115. package/dist/{chunk-4NRAJUDS.js → chunk-RBBWYEFJ.js} +1 -1
  116. package/dist/chunk-RFYAYKTD.js +146 -0
  117. package/dist/chunk-RFYAYKTD.js.map +1 -0
  118. package/dist/{chunk-JROGC36Y.js → chunk-RGLL5SPU.js} +2 -2
  119. package/dist/{chunk-2VFW5K5U.js → chunk-S3EEFKNY.js} +103 -65
  120. package/dist/chunk-S3EEFKNY.js.map +1 -0
  121. package/dist/chunk-SOBJ6NEY.js +18 -0
  122. package/dist/chunk-SOBJ6NEY.js.map +1 -0
  123. package/dist/{chunk-MYQWXITD.js → chunk-SPI27QT6.js} +2 -2
  124. package/dist/chunk-TVVEYCNW.js +65 -0
  125. package/dist/chunk-TVVEYCNW.js.map +1 -0
  126. package/dist/chunk-ULYOGL6R.js +322 -0
  127. package/dist/chunk-ULYOGL6R.js.map +1 -0
  128. package/dist/{chunk-S4LX5EBI.js → chunk-VBVG2M5G.js} +64 -10
  129. package/dist/chunk-VBVG2M5G.js.map +1 -0
  130. package/dist/{chunk-KWP7T3DP.js → chunk-VDX363PS.js} +2 -2
  131. package/dist/{chunk-XMGSSBFX.js → chunk-VYM3VWOF.js} +1560 -244
  132. package/dist/chunk-VYM3VWOF.js.map +1 -0
  133. package/dist/{chunk-MTLYEMJB.js → chunk-WCLICCGB.js} +18 -3
  134. package/dist/chunk-WCLICCGB.js.map +1 -0
  135. package/dist/{chunk-ECKDIK5F.js → chunk-WVVA7F5A.js} +2 -2
  136. package/dist/chunk-X6GF3FX2.js +26 -0
  137. package/dist/chunk-X6GF3FX2.js.map +1 -0
  138. package/dist/{chunk-3QFQGRHO.js → chunk-XMHBH5H6.js} +4 -4
  139. package/dist/{chunk-KEG4GNGI.js → chunk-XZ2TIKGC.js} +38 -8
  140. package/dist/chunk-XZ2TIKGC.js.map +1 -0
  141. package/dist/chunk-Y4FHOFJ2.js +140 -0
  142. package/dist/chunk-Y4FHOFJ2.js.map +1 -0
  143. package/dist/chunk-YNB73F22.js +137 -0
  144. package/dist/chunk-YNB73F22.js.map +1 -0
  145. package/dist/{chunk-7PA4OZEU.js → chunk-YNQKWQT4.js} +55 -30
  146. package/dist/chunk-YNQKWQT4.js.map +1 -0
  147. package/dist/chunk-ZAIM4TUE.js +488 -0
  148. package/dist/chunk-ZAIM4TUE.js.map +1 -0
  149. package/dist/{chunk-BTY5RRRF.js → chunk-ZEM3OK2K.js} +5 -5
  150. package/dist/chunk-ZZTOURJI.js +91 -0
  151. package/dist/chunk-ZZTOURJI.js.map +1 -0
  152. package/dist/{cli-DwIBnp2g.d.ts → cli-BkeRaYfk.d.ts} +2 -2
  153. package/dist/cli.d.ts +13 -5
  154. package/dist/cli.js +45 -33
  155. package/dist/config.js +1 -1
  156. package/dist/consolidation-operator.d.ts +41 -0
  157. package/dist/consolidation-operator.js +11 -0
  158. package/dist/consolidation-operator.js.map +1 -0
  159. package/dist/consolidation-provenance-check.d.ts +68 -0
  160. package/dist/consolidation-provenance-check.js +9 -0
  161. package/dist/consolidation-provenance-check.js.map +1 -0
  162. package/dist/consolidation-undo.d.ts +123 -0
  163. package/dist/consolidation-undo.js +426 -0
  164. package/dist/consolidation-undo.js.map +1 -0
  165. package/dist/contradiction-review-WIUBAR52.js +21 -0
  166. package/dist/contradiction-review-WIUBAR52.js.map +1 -0
  167. package/dist/contradiction-scan-E3GJTI4F.js +412 -0
  168. package/dist/contradiction-scan-E3GJTI4F.js.map +1 -0
  169. package/dist/cross-namespace-budget.d.ts +133 -0
  170. package/dist/cross-namespace-budget.js +9 -0
  171. package/dist/cross-namespace-budget.js.map +1 -0
  172. package/dist/direct-answer-wiring.d.ts +77 -0
  173. package/dist/direct-answer-wiring.js +10 -0
  174. package/dist/direct-answer-wiring.js.map +1 -0
  175. package/dist/direct-answer.d.ts +106 -0
  176. package/dist/direct-answer.js +10 -0
  177. package/dist/direct-answer.js.map +1 -0
  178. package/dist/{engine-X7X3AAG3.js → engine-F3GOXGE5.js} +7 -6
  179. package/dist/engine-F3GOXGE5.js.map +1 -0
  180. package/dist/entity-retrieval.d.ts +1 -0
  181. package/dist/entity-retrieval.js +6 -5
  182. package/dist/explicit-capture.d.ts +6 -3
  183. package/dist/explicit-capture.js +2 -2
  184. package/dist/extraction-judge-telemetry.d.ts +113 -0
  185. package/dist/extraction-judge-telemetry.js +14 -0
  186. package/dist/extraction-judge-telemetry.js.map +1 -0
  187. package/dist/extraction-judge-training.d.ts +85 -0
  188. package/dist/extraction-judge-training.js +16 -0
  189. package/dist/extraction-judge-training.js.map +1 -0
  190. package/dist/extraction-judge.d.ts +124 -2
  191. package/dist/extraction-judge.js +11 -1
  192. package/dist/extraction.js +7 -6
  193. package/dist/fallback-llm.d.ts +11 -2
  194. package/dist/fallback-llm.js +2 -2
  195. package/dist/graph-recall.d.ts +100 -0
  196. package/dist/graph-recall.js +8 -0
  197. package/dist/graph-recall.js.map +1 -0
  198. package/dist/graph-retrieval.d.ts +271 -0
  199. package/dist/graph-retrieval.js +21 -0
  200. package/dist/graph-retrieval.js.map +1 -0
  201. package/dist/harmonic-retrieval.js +2 -1
  202. package/dist/importance.js +1 -1
  203. package/dist/index.d.ts +589 -138
  204. package/dist/index.js +531 -403
  205. package/dist/index.js.map +1 -1
  206. package/dist/intent.js +1 -1
  207. package/dist/local-llm.d.ts +10 -3
  208. package/dist/local-llm.js +1 -1
  209. package/dist/memory-worth-bench.d.ts +51 -0
  210. package/dist/memory-worth-bench.js +131 -0
  211. package/dist/memory-worth-bench.js.map +1 -0
  212. package/dist/memory-worth-filter.d.ts +128 -0
  213. package/dist/memory-worth-filter.js +10 -0
  214. package/dist/memory-worth-filter.js.map +1 -0
  215. package/dist/memory-worth-outcomes.d.ts +118 -0
  216. package/dist/memory-worth-outcomes.js +9 -0
  217. package/dist/memory-worth-outcomes.js.map +1 -0
  218. package/dist/memory-worth.d.ts +102 -0
  219. package/dist/memory-worth.js +7 -0
  220. package/dist/memory-worth.js.map +1 -0
  221. package/dist/operator-toolkit.d.ts +40 -1
  222. package/dist/operator-toolkit.js +24 -14
  223. package/dist/{orchestrator-B9kwlCep.d.ts → orchestrator-CmJ-NTdJ.d.ts} +254 -10
  224. package/dist/orchestrator.d.ts +6 -3
  225. package/dist/orchestrator.js +59 -48
  226. package/dist/page-versioning.d.ts +12 -1
  227. package/dist/page-versioning.js +5 -3
  228. package/dist/{port-C1GZFv8h.d.ts → port-BADbLZU5.d.ts} +2 -2
  229. package/dist/qmd-recall-cache.d.ts +1 -1
  230. package/dist/qmd.d.ts +5 -3
  231. package/dist/qmd.js +2 -1
  232. package/dist/reasoning-trace-recall.d.ts +90 -0
  233. package/dist/reasoning-trace-recall.js +13 -0
  234. package/dist/reasoning-trace-recall.js.map +1 -0
  235. package/dist/reasoning-trace-types.d.ts +54 -0
  236. package/dist/reasoning-trace-types.js +17 -0
  237. package/dist/reasoning-trace-types.js.map +1 -0
  238. package/dist/recall-audit-anomaly.d.ts +112 -0
  239. package/dist/recall-audit-anomaly.js +11 -0
  240. package/dist/recall-audit-anomaly.js.map +1 -0
  241. package/dist/recall-audit.js +5 -44
  242. package/dist/recall-audit.js.map +1 -1
  243. package/dist/recall-explain-renderer.d.ts +49 -0
  244. package/dist/recall-explain-renderer.js +18 -0
  245. package/dist/recall-explain-renderer.js.map +1 -0
  246. package/dist/recall-state.d.ts +39 -1
  247. package/dist/recall-state.js +1 -1
  248. package/dist/recall-xray-cli.d.ts +40 -0
  249. package/dist/recall-xray-cli.js +11 -0
  250. package/dist/recall-xray-cli.js.map +1 -0
  251. package/dist/recall-xray-renderer.d.ts +44 -0
  252. package/dist/recall-xray-renderer.js +18 -0
  253. package/dist/recall-xray-renderer.js.map +1 -0
  254. package/dist/recall-xray.d.ts +179 -0
  255. package/dist/recall-xray.js +13 -0
  256. package/dist/recall-xray.js.map +1 -0
  257. package/dist/resolution-QBTDHTG7.js +100 -0
  258. package/dist/resolution-QBTDHTG7.js.map +1 -0
  259. package/dist/resolve-provider-secret.d.ts +24 -1
  260. package/dist/resolve-provider-secret.js +3 -1
  261. package/dist/resume-bundles.js +6 -6
  262. package/dist/retrieval-agents.d.ts +1 -1
  263. package/dist/retrieval-tiers.d.ts +17 -0
  264. package/dist/retrieval-tiers.js +9 -0
  265. package/dist/retrieval-tiers.js.map +1 -0
  266. package/dist/schemas.d.ts +301 -45
  267. package/dist/schemas.js +1 -1
  268. package/dist/{semantic-consolidation-DrvSYRdB.d.ts → semantic-consolidation-CxJU6MJk.d.ts} +62 -1
  269. package/dist/semantic-consolidation.d.ts +2 -1
  270. package/dist/semantic-consolidation.js +20 -6
  271. package/dist/semantic-rule-promotion.js +6 -5
  272. package/dist/semantic-rule-verifier.js +6 -5
  273. package/dist/storage.d.ts +82 -1
  274. package/dist/storage.js +5 -4
  275. package/dist/summarizer.js +4 -4
  276. package/dist/temporal-supersession.d.ts +1 -0
  277. package/dist/tier-migration.d.ts +2 -1
  278. package/dist/types-DJhqDJUV.d.ts +50 -0
  279. package/dist/types.d.ts +309 -3
  280. package/dist/types.js +1 -1
  281. package/dist/verified-recall.js +6 -5
  282. package/package.json +1 -1
  283. package/dist/chunk-2VFW5K5U.js.map +0 -1
  284. package/dist/chunk-6ZH4TU6I.js.map +0 -1
  285. package/dist/chunk-7PA4OZEU.js.map +0 -1
  286. package/dist/chunk-AAI7JARD.js.map +0 -1
  287. package/dist/chunk-BKQJBXXX.js.map +0 -1
  288. package/dist/chunk-HITJFT7E.js.map +0 -1
  289. package/dist/chunk-J4IYOZZ5.js.map +0 -1
  290. package/dist/chunk-KEG4GNGI.js.map +0 -1
  291. package/dist/chunk-LAYN4LDC.js +0 -267
  292. package/dist/chunk-LAYN4LDC.js.map +0 -1
  293. package/dist/chunk-MTLYEMJB.js.map +0 -1
  294. package/dist/chunk-NSB3WSYS.js.map +0 -1
  295. package/dist/chunk-OJFGVJS6.js.map +0 -1
  296. package/dist/chunk-PAORGQRI.js.map +0 -1
  297. package/dist/chunk-PMB3WGDL.js.map +0 -1
  298. package/dist/chunk-POMSFKTB.js.map +0 -1
  299. package/dist/chunk-QDYXG4CS.js.map +0 -1
  300. package/dist/chunk-QKAH5B6E.js.map +0 -1
  301. package/dist/chunk-QNJMBKFK.js.map +0 -1
  302. package/dist/chunk-S4LX5EBI.js.map +0 -1
  303. package/dist/chunk-U2IQTSBY.js.map +0 -1
  304. package/dist/chunk-UEYA6UC7.js.map +0 -1
  305. package/dist/chunk-UPMD5XND.js.map +0 -1
  306. package/dist/chunk-UVJFDP7P.js +0 -202
  307. package/dist/chunk-UVJFDP7P.js.map +0 -1
  308. package/dist/chunk-V7XCAHIB.js.map +0 -1
  309. package/dist/chunk-X4WESCKA.js.map +0 -1
  310. package/dist/chunk-XMGSSBFX.js.map +0 -1
  311. package/dist/chunk-YFYL2SIJ.js.map +0 -1
  312. /package/dist/{engine-X7X3AAG3.js.map → abort-error.js.map} +0 -0
  313. /package/dist/{chunk-POBPGDWI.js.map → chunk-3OGMS3PE.js.map} +0 -0
  314. /package/dist/{chunk-GJQPH5G3.js.map → chunk-CUPFXL3J.js.map} +0 -0
  315. /package/dist/{chunk-74JR4N5J.js.map → chunk-FVA6TGI3.js.map} +0 -0
  316. /package/dist/{chunk-AYPYCLR7.js.map → chunk-KUB6JU6H.js.map} +0 -0
  317. /package/dist/{chunk-4NRAJUDS.js.map → chunk-RBBWYEFJ.js.map} +0 -0
  318. /package/dist/{chunk-JROGC36Y.js.map → chunk-RGLL5SPU.js.map} +0 -0
  319. /package/dist/{chunk-MYQWXITD.js.map → chunk-SPI27QT6.js.map} +0 -0
  320. /package/dist/{chunk-KWP7T3DP.js.map → chunk-VDX363PS.js.map} +0 -0
  321. /package/dist/{chunk-ECKDIK5F.js.map → chunk-WVVA7F5A.js.map} +0 -0
  322. /package/dist/{chunk-3QFQGRHO.js.map → chunk-XMHBH5H6.js.map} +0 -0
  323. /package/dist/{chunk-BTY5RRRF.js.map → chunk-ZEM3OK2K.js.map} +0 -0
@@ -0,0 +1,488 @@
1
+ import {
2
+ isRetrievalTier
3
+ } from "./chunk-SOBJ6NEY.js";
4
+
5
+ // src/recall-explain-renderer.ts
6
+ function sanitizeString(v) {
7
+ return typeof v === "string" && v.length > 0 ? v : null;
8
+ }
9
+ function sanitizeFiniteNumber(v) {
10
+ return typeof v === "number" && Number.isFinite(v) ? v : null;
11
+ }
12
+ function normalizeTierExplain(value) {
13
+ if (!value || typeof value !== "object" || Array.isArray(value)) return null;
14
+ const raw = value;
15
+ const filteredBy = Array.isArray(raw.filteredBy) ? raw.filteredBy.filter((x) => typeof x === "string") : [];
16
+ const sourceAnchors = Array.isArray(raw.sourceAnchors) ? raw.sourceAnchors.filter(
17
+ (a) => !!a && typeof a === "object" && typeof a.path === "string"
18
+ ).map((a) => {
19
+ const lr = a.lineRange;
20
+ const lineRange = Array.isArray(lr) && lr.length === 2 && Number.isFinite(lr[0]) && Number.isFinite(lr[1]) ? [lr[0], lr[1]] : void 0;
21
+ return lineRange ? { path: a.path, lineRange } : { path: a.path };
22
+ }) : void 0;
23
+ return {
24
+ tier: isRetrievalTier(raw.tier) ? raw.tier : "hybrid",
25
+ tierReason: typeof raw.tierReason === "string" ? raw.tierReason : "",
26
+ filteredBy,
27
+ candidatesConsidered: sanitizeFiniteNumber(raw.candidatesConsidered) ?? 0,
28
+ latencyMs: sanitizeFiniteNumber(raw.latencyMs) ?? 0,
29
+ ...sourceAnchors !== void 0 ? { sourceAnchors } : {}
30
+ };
31
+ }
32
+ function toRecallExplainJson(snapshot) {
33
+ if (!snapshot) {
34
+ return {
35
+ hasExplain: false,
36
+ snapshotFound: false,
37
+ sessionKey: null,
38
+ recordedAt: null,
39
+ namespace: null,
40
+ memoryIds: [],
41
+ source: null,
42
+ sourcesUsed: null,
43
+ latencyMs: null,
44
+ tierExplain: null
45
+ };
46
+ }
47
+ const normalizedExplain = normalizeTierExplain(snapshot.tierExplain);
48
+ return {
49
+ hasExplain: normalizedExplain !== null,
50
+ snapshotFound: true,
51
+ sessionKey: sanitizeString(snapshot.sessionKey),
52
+ recordedAt: sanitizeString(snapshot.recordedAt),
53
+ namespace: sanitizeString(snapshot.namespace),
54
+ memoryIds: Array.isArray(snapshot.memoryIds) ? snapshot.memoryIds.filter((x) => typeof x === "string") : [],
55
+ source: sanitizeString(snapshot.source),
56
+ sourcesUsed: Array.isArray(snapshot.sourcesUsed) ? snapshot.sourcesUsed.filter((x) => typeof x === "string") : null,
57
+ latencyMs: sanitizeFiniteNumber(snapshot.latencyMs),
58
+ tierExplain: normalizedExplain
59
+ };
60
+ }
61
+ function renderTierExplainTextLines(tierExplain) {
62
+ const lines = [];
63
+ if (!tierExplain) {
64
+ lines.push(
65
+ "(not populated \u2014 direct-answer tier disabled or did not fire)"
66
+ );
67
+ return lines;
68
+ }
69
+ lines.push(`tier: ${tierExplain.tier}`);
70
+ lines.push(`reason: ${tierExplain.tierReason}`);
71
+ lines.push(`candidates-considered: ${tierExplain.candidatesConsidered}`);
72
+ lines.push(`latency-ms: ${tierExplain.latencyMs}`);
73
+ if (tierExplain.filteredBy.length > 0) {
74
+ lines.push(`filtered-by: ${tierExplain.filteredBy.join(", ")}`);
75
+ } else {
76
+ lines.push("filtered-by: (none)");
77
+ }
78
+ if (tierExplain.sourceAnchors && tierExplain.sourceAnchors.length > 0) {
79
+ lines.push("source-anchors:");
80
+ for (const anchor of tierExplain.sourceAnchors) {
81
+ const range = anchor.lineRange ? `:${anchor.lineRange[0]}-${anchor.lineRange[1]}` : "";
82
+ lines.push(` - ${anchor.path}${range}`);
83
+ }
84
+ }
85
+ return lines;
86
+ }
87
+ function toRecallExplainText(snapshot) {
88
+ const lines = ["=== Recall Explain ==="];
89
+ if (!snapshot) {
90
+ lines.push("No recall snapshot recorded yet.");
91
+ return lines.join("\n");
92
+ }
93
+ const sessionKey = sanitizeString(snapshot.sessionKey);
94
+ const recordedAt = sanitizeString(snapshot.recordedAt);
95
+ const namespace = sanitizeString(snapshot.namespace);
96
+ const source = sanitizeString(snapshot.source);
97
+ lines.push(`session: ${sessionKey ?? "(unknown)"}`);
98
+ lines.push(`recorded: ${recordedAt ?? "(unknown)"}`);
99
+ if (namespace) lines.push(`namespace: ${namespace}`);
100
+ if (source) lines.push(`source: ${source}`);
101
+ const sourcesUsed = Array.isArray(snapshot.sourcesUsed) ? snapshot.sourcesUsed.filter((x) => typeof x === "string") : [];
102
+ if (sourcesUsed.length > 0) {
103
+ lines.push(`sources-used: ${sourcesUsed.join(", ")}`);
104
+ }
105
+ const latencyMs = sanitizeFiniteNumber(snapshot.latencyMs);
106
+ if (latencyMs !== null) {
107
+ lines.push(`latency-ms: ${latencyMs}`);
108
+ }
109
+ const memoryIds = Array.isArray(snapshot.memoryIds) ? snapshot.memoryIds.filter((x) => typeof x === "string") : [];
110
+ if (memoryIds.length > 0) {
111
+ lines.push(`memories: ${memoryIds.join(", ")}`);
112
+ }
113
+ const ex = normalizeTierExplain(snapshot.tierExplain);
114
+ if (!ex) {
115
+ lines.push("");
116
+ lines.push(
117
+ "tier-explain: (not populated \u2014 direct-answer tier disabled or did not fire)"
118
+ );
119
+ return lines.join("\n");
120
+ }
121
+ lines.push("");
122
+ lines.push("--- tier explain ---");
123
+ for (const line of renderTierExplainTextLines(ex)) {
124
+ lines.push(line);
125
+ }
126
+ return lines.join("\n");
127
+ }
128
+ function sanitizeForMarkdownInline(value) {
129
+ if (typeof value !== "string") return "";
130
+ return value.replace(/[`|\r\n]/g, " ").trim();
131
+ }
132
+ function mapLegacySourceToServedBy(source) {
133
+ if (source === "recent_scan") return "recent-scan";
134
+ return "hybrid";
135
+ }
136
+ function toRecallXraySnapshotFromLegacy(snapshot) {
137
+ if (!snapshot) return null;
138
+ const capturedAt = (() => {
139
+ if (typeof snapshot.recordedAt !== "string") return 0;
140
+ const ms = Date.parse(snapshot.recordedAt);
141
+ return Number.isFinite(ms) && ms >= 0 ? ms : 0;
142
+ })();
143
+ const memoryIds = Array.isArray(snapshot.memoryIds) ? snapshot.memoryIds.filter((x) => typeof x === "string") : [];
144
+ const servedBy = mapLegacySourceToServedBy(snapshot.source);
145
+ const results = memoryIds.map((memoryId) => ({
146
+ memoryId,
147
+ path: "",
148
+ servedBy,
149
+ scoreDecomposition: { final: 0 },
150
+ admittedBy: []
151
+ }));
152
+ const filters = [];
153
+ return {
154
+ schemaVersion: "1",
155
+ // `LastRecallSnapshot` does not preserve the original query text;
156
+ // synthesize a placeholder so the renderer has a non-empty
157
+ // string to print. `queryHash` + `queryLen` stay in the JSON
158
+ // payload via `toRecallExplainJson` for callers that need them.
159
+ query: snapshot.queryHash ? `(legacy explain; queryHash=${snapshot.queryHash})` : "(legacy explain)",
160
+ // `snapshotId` is synthesized here; `sessionKey` is already
161
+ // sanitized before it reaches the ID because we re-use the
162
+ // sanitized string below.
163
+ snapshotId: `legacy-${sanitizeForMarkdownInline(snapshot.sessionKey ?? "unknown") || "unknown"}-${capturedAt}`,
164
+ capturedAt,
165
+ // Run the raw on-disk value through the same normalizer the text
166
+ // and JSON paths use so the markdown adapter cannot render
167
+ // unvalidated tier-explain payloads (cursor / codex review on
168
+ // #605). A malformed tierExplain is dropped to null, matching the
169
+ // behavior of the non-markdown surfaces.
170
+ tierExplain: normalizeTierExplain(snapshot.tierExplain) ?? null,
171
+ results,
172
+ filters,
173
+ budget: { chars: 0, used: 0 },
174
+ // Sanitize legacy session metadata at the adapter boundary so a
175
+ // malformed on-disk value (containing backticks, pipes, or
176
+ // newlines) cannot break the enclosing markdown table when
177
+ // `renderXrayMarkdown` prints it in a raw code-span cell (codex P2
178
+ // review on #605).
179
+ ...snapshot.sessionKey ? (() => {
180
+ const clean = sanitizeForMarkdownInline(snapshot.sessionKey);
181
+ return clean ? { sessionKey: clean } : {};
182
+ })() : {},
183
+ ...snapshot.namespace ? (() => {
184
+ const clean = sanitizeForMarkdownInline(snapshot.namespace);
185
+ return clean ? { namespace: clean } : {};
186
+ })() : {}
187
+ };
188
+ }
189
+ function renderRecallExplain(snapshot, format) {
190
+ if (format === "json") {
191
+ return JSON.stringify(toRecallExplainJson(snapshot), null, 2);
192
+ }
193
+ if (format === "markdown") {
194
+ return renderXrayMarkdown(toRecallXraySnapshotFromLegacy(snapshot));
195
+ }
196
+ return toRecallExplainText(snapshot);
197
+ }
198
+ function parseRecallExplainFormat(value) {
199
+ if (value === void 0 || value === null) return "text";
200
+ if (typeof value !== "string") {
201
+ throw new Error(
202
+ `--format expects "text", "json", or "markdown", got ${typeof value}`
203
+ );
204
+ }
205
+ const v = value.trim().toLowerCase();
206
+ if (v === "text" || v === "json" || v === "markdown") return v;
207
+ throw new Error(
208
+ `--format expects "text", "json", or "markdown", got ${JSON.stringify(value)}`
209
+ );
210
+ }
211
+
212
+ // src/recall-xray-renderer.ts
213
+ var RECALL_XRAY_FORMATS = [
214
+ "json",
215
+ "text",
216
+ "markdown"
217
+ ];
218
+ function parseXrayFormat(value) {
219
+ if (value === void 0 || value === null) return "text";
220
+ if (typeof value !== "string") {
221
+ throw new Error(
222
+ `--format expects one of ${RECALL_XRAY_FORMATS.join(", ")}; got ${typeof value}`
223
+ );
224
+ }
225
+ const v = value.trim().toLowerCase();
226
+ if (v === "json" || v === "text" || v === "markdown") return v;
227
+ throw new Error(
228
+ `--format expects one of ${RECALL_XRAY_FORMATS.join(", ")}; got ${JSON.stringify(value)}`
229
+ );
230
+ }
231
+ function renderXray(snapshot, format) {
232
+ if (format === "json") return renderXrayJson(snapshot);
233
+ if (format === "markdown") return renderXrayMarkdown(snapshot);
234
+ return renderXrayText(snapshot);
235
+ }
236
+ function renderXrayJson(snapshot) {
237
+ if (!snapshot) {
238
+ return JSON.stringify(
239
+ { schemaVersion: "1", snapshotFound: false },
240
+ null,
241
+ 2
242
+ );
243
+ }
244
+ return JSON.stringify(
245
+ { snapshotFound: true, ...snapshot },
246
+ null,
247
+ 2
248
+ );
249
+ }
250
+ function renderXrayText(snapshot) {
251
+ const lines = ["=== Recall X-ray ==="];
252
+ if (!snapshot) {
253
+ lines.push("No X-ray snapshot captured.");
254
+ return lines.join("\n");
255
+ }
256
+ lines.push(`query: ${snapshot.query}`);
257
+ lines.push(`snapshot-id: ${snapshot.snapshotId}`);
258
+ lines.push(`captured-at: ${formatCapturedAt(snapshot.capturedAt)}`);
259
+ if (snapshot.sessionKey) lines.push(`session: ${snapshot.sessionKey}`);
260
+ if (snapshot.namespace) lines.push(`namespace: ${snapshot.namespace}`);
261
+ if (snapshot.traceId) lines.push(`trace-id: ${snapshot.traceId}`);
262
+ lines.push(
263
+ `budget: ${snapshot.budget.used} / ${snapshot.budget.chars} chars`
264
+ );
265
+ lines.push("");
266
+ lines.push("--- filters ---");
267
+ if (snapshot.filters.length === 0) {
268
+ lines.push("(no filter traces recorded)");
269
+ } else {
270
+ for (const f of snapshot.filters) {
271
+ lines.push(renderFilterTextLine(f));
272
+ }
273
+ }
274
+ lines.push("");
275
+ lines.push("--- results ---");
276
+ if (snapshot.results.length === 0) {
277
+ lines.push("(no results admitted)");
278
+ } else {
279
+ snapshot.results.forEach((result, idx) => {
280
+ for (const line of renderResultTextLines(result, idx + 1)) {
281
+ lines.push(line);
282
+ }
283
+ });
284
+ }
285
+ lines.push("");
286
+ lines.push("--- tier explain ---");
287
+ for (const line of renderTierExplainTextLines(snapshot.tierExplain ?? null)) {
288
+ lines.push(line);
289
+ }
290
+ return lines.join("\n");
291
+ }
292
+ function renderFilterTextLine(f) {
293
+ const base = `- ${f.name}: ${f.admitted}/${f.considered} admitted`;
294
+ return f.reason ? `${base} (${f.reason})` : base;
295
+ }
296
+ function renderResultTextLines(result, rank) {
297
+ const lines = [];
298
+ lines.push(`[${rank}] ${result.memoryId} \u2014 ${servedByLabel(result.servedBy)}`);
299
+ if (result.path) lines.push(` path: ${result.path}`);
300
+ lines.push(` score: ${renderScoreDecomposition(result)}`);
301
+ if (result.admittedBy.length > 0) {
302
+ lines.push(` admitted-by: ${result.admittedBy.join(", ")}`);
303
+ }
304
+ if (result.rejectedBy) {
305
+ lines.push(` rejected-by: ${result.rejectedBy}`);
306
+ }
307
+ if (result.graphPath && result.graphPath.length > 0) {
308
+ lines.push(` graph-path: ${result.graphPath.join(" -> ")}`);
309
+ }
310
+ if (result.auditEntryId) {
311
+ lines.push(` audit-entry: ${result.auditEntryId}`);
312
+ }
313
+ return lines;
314
+ }
315
+ function renderXrayMarkdown(snapshot) {
316
+ const lines = ["# Recall X-ray"];
317
+ if (!snapshot) {
318
+ lines.push("");
319
+ lines.push("_No X-ray snapshot captured._");
320
+ return lines.join("\n");
321
+ }
322
+ lines.push("");
323
+ lines.push(`**Query:** ${mdInlineCode(snapshot.query)}`);
324
+ lines.push("");
325
+ lines.push("| Field | Value |");
326
+ lines.push("| --- | --- |");
327
+ lines.push(`| Snapshot ID | \`${snapshot.snapshotId}\` |`);
328
+ lines.push(`| Captured at | ${formatCapturedAt(snapshot.capturedAt)} |`);
329
+ if (snapshot.sessionKey) {
330
+ lines.push(`| Session | \`${snapshot.sessionKey}\` |`);
331
+ }
332
+ if (snapshot.namespace) {
333
+ lines.push(`| Namespace | \`${snapshot.namespace}\` |`);
334
+ }
335
+ if (snapshot.traceId) {
336
+ lines.push(`| Trace ID | \`${snapshot.traceId}\` |`);
337
+ }
338
+ lines.push(
339
+ `| Budget | ${snapshot.budget.used} / ${snapshot.budget.chars} chars |`
340
+ );
341
+ lines.push("");
342
+ lines.push("## Filters");
343
+ if (snapshot.filters.length === 0) {
344
+ lines.push("");
345
+ lines.push("_No filter traces recorded._");
346
+ } else {
347
+ lines.push("");
348
+ lines.push("| Filter | Considered | Admitted | Reason |");
349
+ lines.push("| --- | ---: | ---: | --- |");
350
+ for (const f of snapshot.filters) {
351
+ const reason = f.reason ? mdEscape(f.reason) : "";
352
+ lines.push(`| ${mdEscape(f.name)} | ${f.considered} | ${f.admitted} | ${reason} |`);
353
+ }
354
+ }
355
+ lines.push("");
356
+ lines.push("## Results");
357
+ if (snapshot.results.length === 0) {
358
+ lines.push("");
359
+ lines.push("_No results admitted._");
360
+ } else {
361
+ snapshot.results.forEach((result, idx) => {
362
+ for (const line of renderResultMarkdownLines(result, idx + 1)) {
363
+ lines.push(line);
364
+ }
365
+ });
366
+ }
367
+ lines.push("");
368
+ lines.push("## Tier Explain");
369
+ if (!snapshot.tierExplain) {
370
+ lines.push("");
371
+ lines.push(
372
+ "_Not populated \u2014 direct-answer tier disabled or did not fire._"
373
+ );
374
+ } else {
375
+ const te = snapshot.tierExplain;
376
+ lines.push("");
377
+ lines.push("| Field | Value |");
378
+ lines.push("| --- | --- |");
379
+ lines.push(`| Tier | \`${te.tier}\` |`);
380
+ lines.push(`| Reason | ${mdEscape(te.tierReason)} |`);
381
+ lines.push(`| Candidates considered | ${te.candidatesConsidered} |`);
382
+ lines.push(`| Latency (ms) | ${te.latencyMs} |`);
383
+ lines.push(
384
+ `| Filtered by | ${te.filteredBy.length > 0 ? te.filteredBy.map(mdInlineCode).join(", ") : "_(none)_"} |`
385
+ );
386
+ if (te.sourceAnchors && te.sourceAnchors.length > 0) {
387
+ lines.push("");
388
+ lines.push("**Source anchors:**");
389
+ for (const anchor of te.sourceAnchors) {
390
+ const range = anchor.lineRange ? `:${anchor.lineRange[0]}-${anchor.lineRange[1]}` : "";
391
+ lines.push(`- \`${anchor.path}${range}\``);
392
+ }
393
+ }
394
+ }
395
+ return lines.join("\n");
396
+ }
397
+ function renderResultMarkdownLines(result, rank) {
398
+ const lines = [];
399
+ lines.push("");
400
+ lines.push(
401
+ `### ${rank}. \`${result.memoryId}\` \u2014 ${servedByLabel(result.servedBy)}`
402
+ );
403
+ if (result.path) {
404
+ lines.push("");
405
+ lines.push(`- **Path:** \`${result.path}\``);
406
+ } else {
407
+ lines.push("");
408
+ }
409
+ lines.push(`- **Score:** ${renderScoreDecomposition(result)}`);
410
+ if (result.admittedBy.length > 0) {
411
+ lines.push(
412
+ `- **Admitted by:** ${result.admittedBy.map(mdInlineCode).join(", ")}`
413
+ );
414
+ }
415
+ if (result.rejectedBy) {
416
+ lines.push(`- **Rejected by:** ${mdInlineCode(result.rejectedBy)}`);
417
+ }
418
+ if (result.graphPath && result.graphPath.length > 0) {
419
+ lines.push(
420
+ `- **Graph path:** ${result.graphPath.map(mdInlineCode).join(" \u2192 ")}`
421
+ );
422
+ }
423
+ if (result.auditEntryId) {
424
+ lines.push(`- **Audit entry:** \`${result.auditEntryId}\``);
425
+ }
426
+ return lines;
427
+ }
428
+ function servedByLabel(servedBy) {
429
+ return `served-by=${servedBy}`;
430
+ }
431
+ function renderScoreDecomposition(result) {
432
+ const parts = [`final=${formatScore(result.scoreDecomposition.final)}`];
433
+ const s = result.scoreDecomposition;
434
+ if (s.vector !== void 0) parts.push(`vector=${formatScore(s.vector)}`);
435
+ if (s.bm25 !== void 0) parts.push(`bm25=${formatScore(s.bm25)}`);
436
+ if (s.importance !== void 0) {
437
+ parts.push(`importance=${formatScore(s.importance)}`);
438
+ }
439
+ if (s.mmrPenalty !== void 0) {
440
+ parts.push(`mmr_penalty=${formatScore(s.mmrPenalty)}`);
441
+ }
442
+ if (s.tierPrior !== void 0) {
443
+ parts.push(`tier_prior=${formatScore(s.tierPrior)}`);
444
+ }
445
+ return parts.join(" ");
446
+ }
447
+ function formatScore(value) {
448
+ if (!Number.isFinite(value)) return "0.0000";
449
+ return value.toFixed(4);
450
+ }
451
+ function formatCapturedAt(ts) {
452
+ if (!Number.isFinite(ts) || ts < 0) return "(unknown)";
453
+ try {
454
+ return new Date(ts).toISOString();
455
+ } catch {
456
+ return "(unknown)";
457
+ }
458
+ }
459
+ function mdEscape(value) {
460
+ return value.replace(/\\/g, "\\\\").replace(/\|/g, "\\|");
461
+ }
462
+ function mdInlineCode(value) {
463
+ if (value.length === 0) return "``";
464
+ const longestRun = /`+/g;
465
+ let maxLen = 0;
466
+ for (const match of value.matchAll(longestRun)) {
467
+ if (match[0].length > maxLen) maxLen = match[0].length;
468
+ }
469
+ const fence = "`".repeat(maxLen + 1);
470
+ const pad = value.startsWith("`") || value.endsWith("`") ? " " : "";
471
+ return `${fence}${pad}${value}${pad}${fence}`;
472
+ }
473
+
474
+ export {
475
+ RECALL_XRAY_FORMATS,
476
+ parseXrayFormat,
477
+ renderXray,
478
+ renderXrayJson,
479
+ renderXrayText,
480
+ renderXrayMarkdown,
481
+ toRecallExplainJson,
482
+ renderTierExplainTextLines,
483
+ toRecallExplainText,
484
+ toRecallXraySnapshotFromLegacy,
485
+ renderRecallExplain,
486
+ parseRecallExplainFormat
487
+ };
488
+ //# sourceMappingURL=chunk-ZAIM4TUE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/recall-explain-renderer.ts","../src/recall-xray-renderer.ts"],"sourcesContent":["/**\n * Renderers for RecallTierExplain (issue #518).\n *\n * Pure functions that format a `LastRecallSnapshot` and its\n * optional `tierExplain` field for human text and machine JSON\n * consumption. CLI / HTTP / MCP surfaces consume these — they do\n * not format explain output themselves, so rendering is tested in\n * one place.\n */\n\nimport type { LastRecallSnapshot } from \"./recall-state.js\";\nimport type { RecallTierExplain } from \"./types.js\";\nimport { isRetrievalTier } from \"./retrieval-tiers.js\";\nimport type {\n RecallXraySnapshot,\n RecallFilterTrace,\n RecallXrayResult,\n} from \"./recall-xray.js\";\nimport { renderXrayMarkdown } from \"./recall-xray-renderer.js\";\n\nfunction sanitizeString(v: unknown): string | null {\n return typeof v === \"string\" && v.length > 0 ? v : null;\n}\n\nfunction sanitizeFiniteNumber(v: unknown): number | null {\n return typeof v === \"number\" && Number.isFinite(v) ? v : null;\n}\n\n/**\n * `text` and `json` are the original formats (backwards-compatible\n * since issue #518). `markdown` was added in issue #570 PR 7 and\n * delegates to the shared X-ray renderer so the three observability\n * surfaces stay in lock-step (CLAUDE.md rule 22).\n */\nexport type RecallExplainFormat = \"text\" | \"json\" | \"markdown\";\n\nexport interface RecallExplainJsonPayload {\n hasExplain: boolean;\n snapshotFound: boolean;\n sessionKey: string | null;\n recordedAt: string | null;\n namespace: string | null;\n memoryIds: string[];\n source: string | null;\n sourcesUsed: string[] | null;\n latencyMs: number | null;\n tierExplain: RecallTierExplain | null;\n}\n\nfunction normalizeTierExplain(value: unknown): RecallTierExplain | null {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return null;\n const raw = value as Record<string, unknown>;\n const filteredBy = Array.isArray(raw.filteredBy)\n ? raw.filteredBy.filter((x): x is string => typeof x === \"string\")\n : [];\n const sourceAnchors = Array.isArray(raw.sourceAnchors)\n ? raw.sourceAnchors\n .filter(\n (a): a is { path: string; lineRange?: unknown } =>\n !!a && typeof a === \"object\" && typeof (a as { path?: unknown }).path === \"string\",\n )\n .map((a) => {\n const lr = (a as { lineRange?: unknown }).lineRange;\n const lineRange =\n Array.isArray(lr) &&\n lr.length === 2 &&\n Number.isFinite(lr[0]) &&\n Number.isFinite(lr[1])\n ? ([lr[0] as number, lr[1] as number] as [number, number])\n : undefined;\n return lineRange\n ? { path: (a as { path: string }).path, lineRange }\n : { path: (a as { path: string }).path };\n })\n : undefined;\n return {\n tier: isRetrievalTier(raw.tier) ? raw.tier : \"hybrid\",\n tierReason: typeof raw.tierReason === \"string\" ? raw.tierReason : \"\",\n filteredBy,\n candidatesConsidered: sanitizeFiniteNumber(raw.candidatesConsidered) ?? 0,\n latencyMs: sanitizeFiniteNumber(raw.latencyMs) ?? 0,\n ...(sourceAnchors !== undefined ? { sourceAnchors } : {}),\n };\n}\n\nexport function toRecallExplainJson(\n snapshot: LastRecallSnapshot | null,\n): RecallExplainJsonPayload {\n if (!snapshot) {\n return {\n hasExplain: false,\n snapshotFound: false,\n sessionKey: null,\n recordedAt: null,\n namespace: null,\n memoryIds: [],\n source: null,\n sourcesUsed: null,\n latencyMs: null,\n tierExplain: null,\n };\n }\n const normalizedExplain = normalizeTierExplain(snapshot.tierExplain);\n return {\n hasExplain: normalizedExplain !== null,\n snapshotFound: true,\n sessionKey: sanitizeString(snapshot.sessionKey),\n recordedAt: sanitizeString(snapshot.recordedAt),\n namespace: sanitizeString(snapshot.namespace),\n memoryIds: Array.isArray(snapshot.memoryIds)\n ? snapshot.memoryIds.filter((x): x is string => typeof x === \"string\")\n : [],\n source: sanitizeString(snapshot.source),\n sourcesUsed: Array.isArray(snapshot.sourcesUsed)\n ? snapshot.sourcesUsed.filter((x): x is string => typeof x === \"string\")\n : null,\n latencyMs: sanitizeFiniteNumber(snapshot.latencyMs),\n tierExplain: normalizedExplain,\n };\n}\n\n/**\n * Render the shared \"--- tier explain ---\" text block used by both the\n * recall-explain surface and the Recall X-ray surface. Callers provide\n * the normalized `RecallTierExplain` (or `null` for the\n * not-populated/disabled case) so the block stays character-for-character\n * identical across surfaces (CLAUDE.md rule 22). The returned strings do\n * NOT include leading blank lines or headers — callers own that framing.\n */\nexport function renderTierExplainTextLines(\n tierExplain: RecallTierExplain | null,\n): string[] {\n const lines: string[] = [];\n if (!tierExplain) {\n lines.push(\n \"(not populated — direct-answer tier disabled or did not fire)\",\n );\n return lines;\n }\n lines.push(`tier: ${tierExplain.tier}`);\n lines.push(`reason: ${tierExplain.tierReason}`);\n lines.push(`candidates-considered: ${tierExplain.candidatesConsidered}`);\n lines.push(`latency-ms: ${tierExplain.latencyMs}`);\n if (tierExplain.filteredBy.length > 0) {\n lines.push(`filtered-by: ${tierExplain.filteredBy.join(\", \")}`);\n } else {\n lines.push(\"filtered-by: (none)\");\n }\n if (tierExplain.sourceAnchors && tierExplain.sourceAnchors.length > 0) {\n lines.push(\"source-anchors:\");\n for (const anchor of tierExplain.sourceAnchors) {\n const range = anchor.lineRange\n ? `:${anchor.lineRange[0]}-${anchor.lineRange[1]}`\n : \"\";\n lines.push(` - ${anchor.path}${range}`);\n }\n }\n return lines;\n}\n\nexport function toRecallExplainText(\n snapshot: LastRecallSnapshot | null,\n): string {\n const lines: string[] = [\"=== Recall Explain ===\"];\n\n if (!snapshot) {\n lines.push(\"No recall snapshot recorded yet.\");\n return lines.join(\"\\n\");\n }\n\n const sessionKey = sanitizeString(snapshot.sessionKey);\n const recordedAt = sanitizeString(snapshot.recordedAt);\n const namespace = sanitizeString(snapshot.namespace);\n const source = sanitizeString(snapshot.source);\n lines.push(`session: ${sessionKey ?? \"(unknown)\"}`);\n lines.push(`recorded: ${recordedAt ?? \"(unknown)\"}`);\n if (namespace) lines.push(`namespace: ${namespace}`);\n if (source) lines.push(`source: ${source}`);\n const sourcesUsed = Array.isArray(snapshot.sourcesUsed)\n ? snapshot.sourcesUsed.filter((x): x is string => typeof x === \"string\")\n : [];\n if (sourcesUsed.length > 0) {\n lines.push(`sources-used: ${sourcesUsed.join(\", \")}`);\n }\n const latencyMs = sanitizeFiniteNumber(snapshot.latencyMs);\n if (latencyMs !== null) {\n lines.push(`latency-ms: ${latencyMs}`);\n }\n const memoryIds = Array.isArray(snapshot.memoryIds)\n ? snapshot.memoryIds.filter((x): x is string => typeof x === \"string\")\n : [];\n if (memoryIds.length > 0) {\n lines.push(`memories: ${memoryIds.join(\", \")}`);\n }\n\n const ex = normalizeTierExplain(snapshot.tierExplain);\n if (!ex) {\n lines.push(\"\");\n lines.push(\n \"tier-explain: (not populated — direct-answer tier disabled or did not fire)\",\n );\n return lines.join(\"\\n\");\n }\n\n lines.push(\"\");\n lines.push(\"--- tier explain ---\");\n for (const line of renderTierExplainTextLines(ex)) {\n lines.push(line);\n }\n return lines.join(\"\\n\");\n}\n\n/**\n * Adapter: convert a `LastRecallSnapshot` into a best-effort\n * `RecallXraySnapshot` so the markdown renderer can produce a\n * consistent, richly-formatted document for callers that have asked\n * for `markdown` format. The LastRecallSnapshot and the X-ray\n * snapshot share session/namespace/memoryIds; additional X-ray-only\n * fields (filters, score decomposition, graph path, audit id) are\n * left empty because the legacy snapshot doesn't carry them. The\n * renderer handles missing fields gracefully.\n */\n/**\n * Strip backticks, pipes, and newlines from a host-provided value so it\n * cannot escape its enclosing markdown code span, break the surrounding\n * table row, or inject extra rows when it lands in\n * `renderXrayMarkdown`. Applied at the adapter boundary because\n * `LastRecallSnapshot` is hydrated from on-disk JSON without schema\n * validation (codex P2 review on #605).\n *\n * Accepts `unknown` so non-string truthy values (numbers, objects,\n * booleans, arrays) coming from a corrupted snapshot are coerced to\n * the empty string rather than crashing on `.replace(...)`. Callers\n * should treat an empty return as \"drop this field.\"\n */\nfunction sanitizeForMarkdownInline(value: unknown): string {\n if (typeof value !== \"string\") return \"\";\n return value.replace(/[`|\\r\\n]/g, \" \").trim();\n}\n\n/**\n * Map the legacy `LastRecallSnapshot.source` field to the\n * `RecallXrayServedBy` union used by the unified x-ray renderer.\n * Mirrors the `mapRecallSourceToXrayServedBy` helper inside\n * `orchestrator.ts` (which is private). Keep the two in sync when a\n * new source lands — unknown values collapse to `\"hybrid\"` to preserve\n * backwards compatibility with older on-disk snapshots.\n */\nfunction mapLegacySourceToServedBy(\n source: unknown,\n): \"hybrid\" | \"recent-scan\" {\n if (source === \"recent_scan\") return \"recent-scan\";\n return \"hybrid\";\n}\n\nexport function toRecallXraySnapshotFromLegacy(\n snapshot: LastRecallSnapshot | null,\n): RecallXraySnapshot | null {\n if (!snapshot) return null;\n const capturedAt = (() => {\n if (typeof snapshot.recordedAt !== \"string\") return 0;\n const ms = Date.parse(snapshot.recordedAt);\n return Number.isFinite(ms) && ms >= 0 ? ms : 0;\n })();\n const memoryIds = Array.isArray(snapshot.memoryIds)\n ? snapshot.memoryIds.filter((x): x is string => typeof x === \"string\")\n : [];\n // Codex P2 + Cursor Medium on #605: every converted result used to\n // be stamped with `servedBy: \"hybrid\"`, misattributing legacy\n // snapshots that came from `recent_scan` (or any future source).\n // Propagate the recorded `source` so markdown `recall-explain`\n // output matches the `served-by=` string the native x-ray capture\n // would emit for the same recall.\n const servedBy = mapLegacySourceToServedBy(snapshot.source);\n const results: RecallXrayResult[] = memoryIds.map((memoryId) => ({\n memoryId,\n path: \"\",\n servedBy,\n scoreDecomposition: { final: 0 },\n admittedBy: [],\n }));\n const filters: RecallFilterTrace[] = [];\n return {\n schemaVersion: \"1\",\n // `LastRecallSnapshot` does not preserve the original query text;\n // synthesize a placeholder so the renderer has a non-empty\n // string to print. `queryHash` + `queryLen` stay in the JSON\n // payload via `toRecallExplainJson` for callers that need them.\n query:\n snapshot.queryHash\n ? `(legacy explain; queryHash=${snapshot.queryHash})`\n : \"(legacy explain)\",\n // `snapshotId` is synthesized here; `sessionKey` is already\n // sanitized before it reaches the ID because we re-use the\n // sanitized string below.\n snapshotId: `legacy-${sanitizeForMarkdownInline(snapshot.sessionKey ?? \"unknown\") || \"unknown\"}-${capturedAt}`,\n capturedAt,\n // Run the raw on-disk value through the same normalizer the text\n // and JSON paths use so the markdown adapter cannot render\n // unvalidated tier-explain payloads (cursor / codex review on\n // #605). A malformed tierExplain is dropped to null, matching the\n // behavior of the non-markdown surfaces.\n tierExplain: normalizeTierExplain(snapshot.tierExplain) ?? null,\n results,\n filters,\n budget: { chars: 0, used: 0 },\n // Sanitize legacy session metadata at the adapter boundary so a\n // malformed on-disk value (containing backticks, pipes, or\n // newlines) cannot break the enclosing markdown table when\n // `renderXrayMarkdown` prints it in a raw code-span cell (codex P2\n // review on #605).\n ...(snapshot.sessionKey\n ? (() => {\n const clean = sanitizeForMarkdownInline(snapshot.sessionKey);\n return clean ? { sessionKey: clean } : {};\n })()\n : {}),\n ...(snapshot.namespace\n ? (() => {\n const clean = sanitizeForMarkdownInline(snapshot.namespace);\n return clean ? { namespace: clean } : {};\n })()\n : {}),\n };\n}\n\nexport function renderRecallExplain(\n snapshot: LastRecallSnapshot | null,\n format: RecallExplainFormat,\n): string {\n if (format === \"json\") {\n return JSON.stringify(toRecallExplainJson(snapshot), null, 2);\n }\n if (format === \"markdown\") {\n // Delegate to the shared X-ray renderer so CLI / HTTP / MCP\n // markdown output all share one implementation (CLAUDE.md rule\n // 22). The JSON and text paths remain byte-for-byte\n // backwards-compatible with pre-#570 behavior.\n return renderXrayMarkdown(toRecallXraySnapshotFromLegacy(snapshot));\n }\n return toRecallExplainText(snapshot);\n}\n\nexport function parseRecallExplainFormat(value: unknown): RecallExplainFormat {\n if (value === undefined || value === null) return \"text\";\n if (typeof value !== \"string\") {\n throw new Error(\n `--format expects \"text\", \"json\", or \"markdown\", got ${typeof value}`,\n );\n }\n const v = value.trim().toLowerCase();\n if (v === \"text\" || v === \"json\" || v === \"markdown\") return v;\n throw new Error(\n `--format expects \"text\", \"json\", or \"markdown\", got ${JSON.stringify(value)}`,\n );\n}\n","/**\n * Unified Recall X-ray renderer (issue #570, PR 2).\n *\n * Pure functions that format a `RecallXraySnapshot` for human text,\n * GitHub-flavored markdown, and machine JSON consumption. CLI / HTTP\n * / MCP surfaces all call into this module — they do NOT format X-ray\n * output themselves, so rendering is tested in one place (CLAUDE.md\n * rule 22).\n *\n * Scope for PR 2 (this slice):\n * - Pure rendering. No IO, no transport, no capture.\n * - `renderXray(snapshot, format)` with format ∈\n * `{\"json\", \"text\", \"markdown\"}`.\n * - `parseXrayFormat(value)` — input validator that rejects unknown\n * formats with a listed-options error (CLAUDE.md rule 51).\n * - Golden-file-style tests in `recall-xray-renderer.test.ts`.\n */\n\nimport type {\n RecallFilterTrace,\n RecallXrayResult,\n RecallXraySnapshot,\n RecallXrayServedBy,\n} from \"./recall-xray.js\";\nimport { renderTierExplainTextLines } from \"./recall-explain-renderer.js\";\n\nexport type RecallXrayFormat = \"json\" | \"text\" | \"markdown\";\n\nexport const RECALL_XRAY_FORMATS: readonly RecallXrayFormat[] = [\n \"json\",\n \"text\",\n \"markdown\",\n] as const;\n\n/**\n * Validate and coerce a user-provided `--format` / `format` argument to\n * `RecallXrayFormat`. Unknown values throw an error listing valid\n * options (CLAUDE.md rule 51). `undefined`/`null` defaults to `\"text\"`.\n */\nexport function parseXrayFormat(value: unknown): RecallXrayFormat {\n if (value === undefined || value === null) return \"text\";\n if (typeof value !== \"string\") {\n throw new Error(\n `--format expects one of ${RECALL_XRAY_FORMATS.join(\", \")}; got ${typeof value}`,\n );\n }\n const v = value.trim().toLowerCase();\n if (v === \"json\" || v === \"text\" || v === \"markdown\") return v;\n throw new Error(\n `--format expects one of ${RECALL_XRAY_FORMATS.join(\", \")}; got ${JSON.stringify(value)}`,\n );\n}\n\n/**\n * Top-level dispatcher. CLI / HTTP / MCP callers should always route\n * through this function so the three formats stay in lock-step.\n */\nexport function renderXray(\n snapshot: RecallXraySnapshot | null,\n format: RecallXrayFormat,\n): string {\n if (format === \"json\") return renderXrayJson(snapshot);\n if (format === \"markdown\") return renderXrayMarkdown(snapshot);\n return renderXrayText(snapshot);\n}\n\n// ─── JSON ─────────────────────────────────────────────────────────────────\n\n/**\n * Deterministic JSON encoding of an X-ray snapshot. Returns a stable\n * v1 envelope when the snapshot is absent so consumers can pattern-match\n * on `snapshotFound` rather than distinguishing `null` vs `{}`.\n */\nexport function renderXrayJson(snapshot: RecallXraySnapshot | null): string {\n if (!snapshot) {\n return JSON.stringify(\n { schemaVersion: \"1\", snapshotFound: false },\n null,\n 2,\n );\n }\n // `snapshotFound` is injected *before* the rest so downstream JSON\n // consumers see it near the top of the document.\n return JSON.stringify(\n { snapshotFound: true, ...snapshot },\n null,\n 2,\n );\n}\n\n// ─── Text ─────────────────────────────────────────────────────────────────\n\nexport function renderXrayText(snapshot: RecallXraySnapshot | null): string {\n const lines: string[] = [\"=== Recall X-ray ===\"];\n if (!snapshot) {\n lines.push(\"No X-ray snapshot captured.\");\n return lines.join(\"\\n\");\n }\n\n lines.push(`query: ${snapshot.query}`);\n lines.push(`snapshot-id: ${snapshot.snapshotId}`);\n lines.push(`captured-at: ${formatCapturedAt(snapshot.capturedAt)}`);\n if (snapshot.sessionKey) lines.push(`session: ${snapshot.sessionKey}`);\n if (snapshot.namespace) lines.push(`namespace: ${snapshot.namespace}`);\n if (snapshot.traceId) lines.push(`trace-id: ${snapshot.traceId}`);\n lines.push(\n `budget: ${snapshot.budget.used} / ${snapshot.budget.chars} chars`,\n );\n\n lines.push(\"\");\n lines.push(\"--- filters ---\");\n if (snapshot.filters.length === 0) {\n lines.push(\"(no filter traces recorded)\");\n } else {\n for (const f of snapshot.filters) {\n lines.push(renderFilterTextLine(f));\n }\n }\n\n lines.push(\"\");\n lines.push(\"--- results ---\");\n if (snapshot.results.length === 0) {\n lines.push(\"(no results admitted)\");\n } else {\n snapshot.results.forEach((result, idx) => {\n for (const line of renderResultTextLines(result, idx + 1)) {\n lines.push(line);\n }\n });\n }\n\n lines.push(\"\");\n lines.push(\"--- tier explain ---\");\n for (const line of renderTierExplainTextLines(snapshot.tierExplain ?? null)) {\n lines.push(line);\n }\n\n return lines.join(\"\\n\");\n}\n\nfunction renderFilterTextLine(f: RecallFilterTrace): string {\n const base = `- ${f.name}: ${f.admitted}/${f.considered} admitted`;\n return f.reason ? `${base} (${f.reason})` : base;\n}\n\nfunction renderResultTextLines(\n result: RecallXrayResult,\n rank: number,\n): string[] {\n const lines: string[] = [];\n lines.push(`[${rank}] ${result.memoryId} — ${servedByLabel(result.servedBy)}`);\n if (result.path) lines.push(` path: ${result.path}`);\n lines.push(` score: ${renderScoreDecomposition(result)}`);\n if (result.admittedBy.length > 0) {\n lines.push(` admitted-by: ${result.admittedBy.join(\", \")}`);\n }\n if (result.rejectedBy) {\n lines.push(` rejected-by: ${result.rejectedBy}`);\n }\n if (result.graphPath && result.graphPath.length > 0) {\n lines.push(` graph-path: ${result.graphPath.join(\" -> \")}`);\n }\n if (result.auditEntryId) {\n lines.push(` audit-entry: ${result.auditEntryId}`);\n }\n return lines;\n}\n\n// ─── Markdown ─────────────────────────────────────────────────────────────\n\nexport function renderXrayMarkdown(\n snapshot: RecallXraySnapshot | null,\n): string {\n const lines: string[] = [\"# Recall X-ray\"];\n if (!snapshot) {\n lines.push(\"\");\n lines.push(\"_No X-ray snapshot captured._\");\n return lines.join(\"\\n\");\n }\n\n lines.push(\"\");\n lines.push(`**Query:** ${mdInlineCode(snapshot.query)}`);\n lines.push(\"\");\n lines.push(\"| Field | Value |\");\n lines.push(\"| --- | --- |\");\n lines.push(`| Snapshot ID | \\`${snapshot.snapshotId}\\` |`);\n lines.push(`| Captured at | ${formatCapturedAt(snapshot.capturedAt)} |`);\n if (snapshot.sessionKey) {\n lines.push(`| Session | \\`${snapshot.sessionKey}\\` |`);\n }\n if (snapshot.namespace) {\n lines.push(`| Namespace | \\`${snapshot.namespace}\\` |`);\n }\n if (snapshot.traceId) {\n lines.push(`| Trace ID | \\`${snapshot.traceId}\\` |`);\n }\n lines.push(\n `| Budget | ${snapshot.budget.used} / ${snapshot.budget.chars} chars |`,\n );\n\n lines.push(\"\");\n lines.push(\"## Filters\");\n if (snapshot.filters.length === 0) {\n lines.push(\"\");\n lines.push(\"_No filter traces recorded._\");\n } else {\n lines.push(\"\");\n lines.push(\"| Filter | Considered | Admitted | Reason |\");\n lines.push(\"| --- | ---: | ---: | --- |\");\n for (const f of snapshot.filters) {\n const reason = f.reason ? mdEscape(f.reason) : \"\";\n lines.push(`| ${mdEscape(f.name)} | ${f.considered} | ${f.admitted} | ${reason} |`);\n }\n }\n\n lines.push(\"\");\n lines.push(\"## Results\");\n if (snapshot.results.length === 0) {\n lines.push(\"\");\n lines.push(\"_No results admitted._\");\n } else {\n snapshot.results.forEach((result, idx) => {\n for (const line of renderResultMarkdownLines(result, idx + 1)) {\n lines.push(line);\n }\n });\n }\n\n lines.push(\"\");\n lines.push(\"## Tier Explain\");\n if (!snapshot.tierExplain) {\n lines.push(\"\");\n lines.push(\n \"_Not populated — direct-answer tier disabled or did not fire._\",\n );\n } else {\n const te = snapshot.tierExplain;\n lines.push(\"\");\n lines.push(\"| Field | Value |\");\n lines.push(\"| --- | --- |\");\n lines.push(`| Tier | \\`${te.tier}\\` |`);\n lines.push(`| Reason | ${mdEscape(te.tierReason)} |`);\n lines.push(`| Candidates considered | ${te.candidatesConsidered} |`);\n lines.push(`| Latency (ms) | ${te.latencyMs} |`);\n lines.push(\n `| Filtered by | ${\n te.filteredBy.length > 0\n ? te.filteredBy.map(mdInlineCode).join(\", \")\n : \"_(none)_\"\n } |`,\n );\n if (te.sourceAnchors && te.sourceAnchors.length > 0) {\n lines.push(\"\");\n lines.push(\"**Source anchors:**\");\n for (const anchor of te.sourceAnchors) {\n const range = anchor.lineRange\n ? `:${anchor.lineRange[0]}-${anchor.lineRange[1]}`\n : \"\";\n lines.push(`- \\`${anchor.path}${range}\\``);\n }\n }\n }\n\n return lines.join(\"\\n\");\n}\n\nfunction renderResultMarkdownLines(\n result: RecallXrayResult,\n rank: number,\n): string[] {\n const lines: string[] = [];\n lines.push(\"\");\n lines.push(\n `### ${rank}. \\`${result.memoryId}\\` — ${servedByLabel(result.servedBy)}`,\n );\n if (result.path) {\n lines.push(\"\");\n lines.push(`- **Path:** \\`${result.path}\\``);\n } else {\n lines.push(\"\");\n }\n lines.push(`- **Score:** ${renderScoreDecomposition(result)}`);\n if (result.admittedBy.length > 0) {\n lines.push(\n `- **Admitted by:** ${result.admittedBy.map(mdInlineCode).join(\", \")}`,\n );\n }\n if (result.rejectedBy) {\n lines.push(`- **Rejected by:** ${mdInlineCode(result.rejectedBy)}`);\n }\n if (result.graphPath && result.graphPath.length > 0) {\n lines.push(\n `- **Graph path:** ${result.graphPath\n .map(mdInlineCode)\n .join(\" → \")}`,\n );\n }\n if (result.auditEntryId) {\n lines.push(`- **Audit entry:** \\`${result.auditEntryId}\\``);\n }\n return lines;\n}\n\n// ─── Shared helpers ───────────────────────────────────────────────────────\n\nfunction servedByLabel(servedBy: RecallXrayServedBy): string {\n return `served-by=${servedBy}`;\n}\n\nfunction renderScoreDecomposition(result: RecallXrayResult): string {\n const parts: string[] = [`final=${formatScore(result.scoreDecomposition.final)}`];\n const s = result.scoreDecomposition;\n if (s.vector !== undefined) parts.push(`vector=${formatScore(s.vector)}`);\n if (s.bm25 !== undefined) parts.push(`bm25=${formatScore(s.bm25)}`);\n if (s.importance !== undefined) {\n parts.push(`importance=${formatScore(s.importance)}`);\n }\n if (s.mmrPenalty !== undefined) {\n parts.push(`mmr_penalty=${formatScore(s.mmrPenalty)}`);\n }\n if (s.tierPrior !== undefined) {\n parts.push(`tier_prior=${formatScore(s.tierPrior)}`);\n }\n return parts.join(\" \");\n}\n\nfunction formatScore(value: number): string {\n // Deterministic 4-decimal formatting keeps golden files stable\n // without printing spurious trailing zeros via toString().\n if (!Number.isFinite(value)) return \"0.0000\";\n return value.toFixed(4);\n}\n\nfunction formatCapturedAt(ts: number): string {\n if (!Number.isFinite(ts) || ts < 0) return \"(unknown)\";\n // `new Date(n).toISOString()` throws a RangeError for finite numbers\n // outside the valid Date range (roughly |n| > 8.64e15). That case\n // can surface when snapshots are corrupted or captured with a\n // custom clock, so coerce it to the same \"(unknown)\" fallback\n // rather than crashing the renderer.\n try {\n return new Date(ts).toISOString();\n } catch {\n return \"(unknown)\";\n }\n}\n\nfunction mdEscape(value: string): string {\n // Pipe is the only character that breaks GFM table rendering; escape\n // backslash first so we do not re-escape the escape character.\n return value.replace(/\\\\/g, \"\\\\\\\\\").replace(/\\|/g, \"\\\\|\");\n}\n\nfunction mdInlineCode(value: string): string {\n if (value.length === 0) return \"``\";\n // Use exactly enough backticks to unambiguously wrap content that\n // itself contains backticks (GFM rule).\n const longestRun = /`+/g;\n let maxLen = 0;\n for (const match of value.matchAll(longestRun)) {\n if (match[0].length > maxLen) maxLen = match[0].length;\n }\n const fence = \"`\".repeat(maxLen + 1);\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aAAa,OAAuB;AAC3C,MAAI,MAAM,WAAW,EAAG,QAAO;AAG/B,QAAM,aAAa;AACnB,MAAI,SAAS;AACb,aAAW,SAAS,MAAM,SAAS,UAAU,GAAG;AAC9C,QAAI,MAAM,CAAC,EAAE,SAAS,OAAQ,UAAS,MAAM,CAAC,EAAE;AAAA,EAClD;AACA,QAAM,QAAQ,IAAI,OAAO,SAAS,CAAC;AACnC,QAAM,MAAM,MAAM,WAAW,GAAG,KAAK,MAAM,SAAS,GAAG,IAAI,MAAM;AACjE,SAAO,GAAG,KAAK,GAAG,GAAG,GAAG,KAAK,GAAG,GAAG,GAAG,KAAK;AAC7C;","names":[]}
@@ -3,15 +3,15 @@ import {
3
3
  upsertSummarySnapshot,
4
4
  writeSummarySnapshot
5
5
  } from "./chunk-ETOW6ACV.js";
6
- import {
7
- LocalLlmClient
8
- } from "./chunk-UPMD5XND.js";
9
6
  import {
10
7
  ModelRegistry
11
8
  } from "./chunk-FEMOX5AD.js";
9
+ import {
10
+ LocalLlmClient
11
+ } from "./chunk-JL2PU6AI.js";
12
12
  import {
13
13
  FallbackLlmClient
14
- } from "./chunk-QKAH5B6E.js";
14
+ } from "./chunk-3GXCSUXR.js";
15
15
  import {
16
16
  extractJsonCandidates
17
17
  } from "./chunk-UZB5KHKX.js";
@@ -618,4 +618,4 @@ ${truncatedConversation}`;
618
618
  export {
619
619
  HourlySummarizer
620
620
  };
621
- //# sourceMappingURL=chunk-BTY5RRRF.js.map
621
+ //# sourceMappingURL=chunk-ZEM3OK2K.js.map