@remnic/core 9.3.613 → 9.3.615

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 (386) hide show
  1. package/dist/access-cli.js +59 -58
  2. package/dist/access-cli.js.map +1 -1
  3. package/dist/access-http.d.ts +4 -2
  4. package/dist/access-http.js +23 -23
  5. package/dist/access-mcp.d.ts +9 -2
  6. package/dist/access-mcp.js +20 -20
  7. package/dist/access-schema.d.ts +26 -14
  8. package/dist/access-schema.js +3 -3
  9. package/dist/{access-service-D2J9dh_9.d.ts → access-service-CBNEKjzN.d.ts} +71 -6
  10. package/dist/access-service.d.ts +2 -2
  11. package/dist/access-service.js +17 -17
  12. package/dist/active-recall.js +20 -3
  13. package/dist/active-recall.js.map +1 -1
  14. package/dist/adapters/index.js +4 -4
  15. package/dist/adapters/registry.js +2 -2
  16. package/dist/behavior-learner.js +2 -3
  17. package/dist/behavior-learner.js.map +1 -1
  18. package/dist/bootstrap.d.ts +1 -1
  19. package/dist/briefing.js +3 -3
  20. package/dist/buffer.d.ts +1 -1
  21. package/dist/buffer.js +1 -1
  22. package/dist/calibration.d.ts +5 -2
  23. package/dist/calibration.js +7 -5
  24. package/dist/calibration.js.map +1 -1
  25. package/dist/{capsule-crypto-7FJQINUR.js → capsule-crypto-YO5QJ6L3.js} +2 -2
  26. package/dist/causal-consolidation.d.ts +8 -2
  27. package/dist/causal-consolidation.js +13 -11
  28. package/dist/causal-consolidation.js.map +1 -1
  29. package/dist/{chunk-3BP57I6J.js → chunk-2F6NP3NT.js} +2 -1
  30. package/dist/{chunk-3BP57I6J.js.map → chunk-2F6NP3NT.js.map} +1 -1
  31. package/dist/{chunk-AU7Q3LSC.js → chunk-2QSZNTDO.js} +4 -4
  32. package/dist/{chunk-HSVJGWYS.js → chunk-2ROPI5OE.js} +2 -2
  33. package/dist/{chunk-C4SQJZAF.js → chunk-2SGJY2UY.js} +6 -3
  34. package/dist/chunk-2SGJY2UY.js.map +1 -0
  35. package/dist/{chunk-ZDTVJXIP.js → chunk-3MAONBX3.js} +13 -5
  36. package/dist/chunk-3MAONBX3.js.map +1 -0
  37. package/dist/{chunk-G3Z3QEF5.js → chunk-3PY7VHV7.js} +2 -2
  38. package/dist/chunk-3PY7VHV7.js.map +1 -0
  39. package/dist/{chunk-CF3ZF2YU.js → chunk-3QSU4NFF.js} +3 -3
  40. package/dist/{chunk-AJA46VX5.js → chunk-3T74IZB3.js} +11 -2
  41. package/dist/chunk-3T74IZB3.js.map +1 -0
  42. package/dist/{chunk-KVEVLBKC.js → chunk-4HFJQCJZ.js} +13 -8
  43. package/dist/chunk-4HFJQCJZ.js.map +1 -0
  44. package/dist/{chunk-KGK2QKWL.js → chunk-4R4KTDIE.js} +1 -1
  45. package/dist/chunk-4R4KTDIE.js.map +1 -0
  46. package/dist/{chunk-OI27U2HT.js → chunk-5BTCT236.js} +2 -2
  47. package/dist/{chunk-TH67Q46T.js → chunk-5OHHEORR.js} +64 -21
  48. package/dist/chunk-5OHHEORR.js.map +1 -0
  49. package/dist/{chunk-CO7ZO4TU.js → chunk-5VDJMYTF.js} +2 -2
  50. package/dist/{chunk-BFBF3XEF.js → chunk-6BDVBBBY.js} +33 -25
  51. package/dist/{chunk-BFBF3XEF.js.map → chunk-6BDVBBBY.js.map} +1 -1
  52. package/dist/{chunk-EAZGEEG2.js → chunk-6L46YAEZ.js} +45 -9
  53. package/dist/chunk-6L46YAEZ.js.map +1 -0
  54. package/dist/{chunk-YFS5OEKO.js → chunk-7MLB4NCL.js} +2 -2
  55. package/dist/{chunk-LZ3VEOU5.js → chunk-AL4RAJL5.js} +22 -5
  56. package/dist/chunk-AL4RAJL5.js.map +1 -0
  57. package/dist/{chunk-557IAFPD.js → chunk-APRRL26Q.js} +2 -2
  58. package/dist/{chunk-QDDHYAKV.js → chunk-AZDOWD2L.js} +2 -2
  59. package/dist/{chunk-MLT75J5S.js → chunk-B6SU7YSE.js} +3 -3
  60. package/dist/{chunk-FXKPZ3H6.js → chunk-BPSGLMQ4.js} +2 -2
  61. package/dist/{chunk-2NLLXCJG.js → chunk-BXLOS5AJ.js} +2 -2
  62. package/dist/{chunk-NOMEVTUD.js → chunk-C6C7XVKG.js} +5 -4
  63. package/dist/chunk-C6C7XVKG.js.map +1 -0
  64. package/dist/{chunk-XKIQZXUB.js → chunk-CI7RKSRE.js} +7 -1
  65. package/dist/chunk-CI7RKSRE.js.map +1 -0
  66. package/dist/{chunk-IK34DVAC.js → chunk-CIOMS6DI.js} +2 -2
  67. package/dist/{chunk-2I5JGH3M.js → chunk-CYEPCZN5.js} +2 -2
  68. package/dist/{chunk-2I5JGH3M.js.map → chunk-CYEPCZN5.js.map} +1 -1
  69. package/dist/{chunk-JHMFYY7L.js → chunk-DCGT4FPP.js} +13 -5
  70. package/dist/chunk-DCGT4FPP.js.map +1 -0
  71. package/dist/{chunk-7DZRO2DC.js → chunk-DEPRLVLK.js} +2 -2
  72. package/dist/{chunk-CSKLPDN6.js → chunk-DEVUWMME.js} +52 -19
  73. package/dist/chunk-DEVUWMME.js.map +1 -0
  74. package/dist/{chunk-DHGSZ3UD.js → chunk-DGNQRNLL.js} +2 -2
  75. package/dist/{chunk-X7Y7WX73.js → chunk-DQEMWVMT.js} +1 -1
  76. package/dist/{chunk-HJNQQICM.js → chunk-EXUAP5LH.js} +108 -51
  77. package/dist/chunk-EXUAP5LH.js.map +1 -0
  78. package/dist/chunk-FAV25DUZ.js +12 -0
  79. package/dist/chunk-FAV25DUZ.js.map +1 -0
  80. package/dist/{chunk-ETUPBUHB.js → chunk-GDASG7NC.js} +2 -2
  81. package/dist/{chunk-L227SKTB.js → chunk-GDB4J2H3.js} +17 -1
  82. package/dist/chunk-GDB4J2H3.js.map +1 -0
  83. package/dist/{chunk-IP73YCZP.js → chunk-GLPBYIXN.js} +4 -2
  84. package/dist/chunk-GLPBYIXN.js.map +1 -0
  85. package/dist/{chunk-4HP7HIE3.js → chunk-HP5FMB6L.js} +2 -2
  86. package/dist/{chunk-EVZFIAPG.js → chunk-IBTZEBUD.js} +23 -10
  87. package/dist/chunk-IBTZEBUD.js.map +1 -0
  88. package/dist/{chunk-DOX2CG6Y.js → chunk-IEUU7O4F.js} +2 -2
  89. package/dist/{chunk-EUML3N6B.js → chunk-IMA6GU4Y.js} +3 -3
  90. package/dist/chunk-IMA6GU4Y.js.map +1 -0
  91. package/dist/{chunk-JNANKJLN.js → chunk-JOASJWQR.js} +2 -2
  92. package/dist/chunk-JOASJWQR.js.map +1 -0
  93. package/dist/{chunk-WSGF57U2.js → chunk-JQDZQ4TB.js} +2 -2
  94. package/dist/{chunk-HINSGUA7.js → chunk-KBL3JJR6.js} +9 -13
  95. package/dist/chunk-KBL3JJR6.js.map +1 -0
  96. package/dist/{chunk-IOTENEVL.js → chunk-KGLPJROV.js} +57 -50
  97. package/dist/chunk-KGLPJROV.js.map +1 -0
  98. package/dist/{chunk-W7L6HXUC.js → chunk-LXOM6IQU.js} +2 -2
  99. package/dist/{chunk-G6R5UD3Q.js → chunk-MGN7VHWQ.js} +42 -1
  100. package/dist/{chunk-G6R5UD3Q.js.map → chunk-MGN7VHWQ.js.map} +1 -1
  101. package/dist/{chunk-DLJ4IR6M.js → chunk-MHQC2WU2.js} +2 -2
  102. package/dist/chunk-MHQC2WU2.js.map +1 -0
  103. package/dist/{chunk-5RPTH6AU.js → chunk-NM5NQYJE.js} +20 -19
  104. package/dist/chunk-NM5NQYJE.js.map +1 -0
  105. package/dist/{chunk-6JGNHWCI.js → chunk-OBIRVF36.js} +3 -3
  106. package/dist/{chunk-CHCA44C3.js → chunk-ODPLEWB6.js} +3 -3
  107. package/dist/chunk-ODPLEWB6.js.map +1 -0
  108. package/dist/{chunk-HENLZHIT.js → chunk-OIF36KGD.js} +7 -4
  109. package/dist/chunk-OIF36KGD.js.map +1 -0
  110. package/dist/{chunk-GUPISBV2.js → chunk-PP2JH3GP.js} +2 -2
  111. package/dist/{chunk-OXJBNGBK.js → chunk-PSUB67YB.js} +2 -2
  112. package/dist/{chunk-UWY7GIVS.js → chunk-PYIFUBRK.js} +45 -13
  113. package/dist/chunk-PYIFUBRK.js.map +1 -0
  114. package/dist/{chunk-KIB7SDIJ.js → chunk-Q6YIJGXJ.js} +2 -2
  115. package/dist/{chunk-ZT3EGNLR.js → chunk-QPD426WT.js} +2 -2
  116. package/dist/{chunk-RLV3PQGH.js → chunk-QVO4YOB7.js} +6 -6
  117. package/dist/{chunk-GMAG2HS4.js → chunk-RG3LBSGH.js} +46 -9
  118. package/dist/chunk-RG3LBSGH.js.map +1 -0
  119. package/dist/{chunk-XSWKORGM.js → chunk-S53OYO3F.js} +3 -1
  120. package/dist/chunk-S53OYO3F.js.map +1 -0
  121. package/dist/{chunk-YCN4BVDK.js → chunk-SCPFRKIT.js} +4 -2
  122. package/dist/chunk-SCPFRKIT.js.map +1 -0
  123. package/dist/{chunk-NZPF2SYV.js → chunk-T7N6KQGS.js} +138 -5
  124. package/dist/chunk-T7N6KQGS.js.map +1 -0
  125. package/dist/{chunk-VJXSUAO7.js → chunk-TNOWU6RP.js} +13 -10
  126. package/dist/chunk-TNOWU6RP.js.map +1 -0
  127. package/dist/{chunk-PCI747N2.js → chunk-TZVQQTG4.js} +48 -19
  128. package/dist/chunk-TZVQQTG4.js.map +1 -0
  129. package/dist/{chunk-KQAFEZQX.js → chunk-VDX2J7OX.js} +2 -2
  130. package/dist/{chunk-IK7DCC5H.js → chunk-VMGLYN42.js} +2 -2
  131. package/dist/{chunk-KM2A35EO.js → chunk-WB3LYXC5.js} +11 -7
  132. package/dist/chunk-WB3LYXC5.js.map +1 -0
  133. package/dist/{chunk-PPPZY2EU.js → chunk-WD2W4234.js} +9 -3
  134. package/dist/chunk-WD2W4234.js.map +1 -0
  135. package/dist/{chunk-NSKYFGDL.js → chunk-X4QQB7O6.js} +2 -2
  136. package/dist/{chunk-HPWVAEET.js → chunk-X6IRLNOO.js} +3 -7
  137. package/dist/chunk-X6IRLNOO.js.map +1 -0
  138. package/dist/{chunk-46GJIW5M.js → chunk-XAZOWLW4.js} +5 -5
  139. package/dist/{chunk-46GJIW5M.js.map → chunk-XAZOWLW4.js.map} +1 -1
  140. package/dist/{chunk-XPSVGJYA.js → chunk-YRMKDTKF.js} +12 -9
  141. package/dist/chunk-YRMKDTKF.js.map +1 -0
  142. package/dist/{chunk-6ZZP4EJF.js → chunk-ZJR7VG5L.js} +3 -3
  143. package/dist/{chunk-6ZZP4EJF.js.map → chunk-ZJR7VG5L.js.map} +1 -1
  144. package/dist/{chunk-2QANQKSQ.js → chunk-ZK32E74R.js} +156 -45
  145. package/dist/chunk-ZK32E74R.js.map +1 -0
  146. package/dist/{cli-OrfKXNU4.d.ts → cli-Cw729yLf.d.ts} +6 -2
  147. package/dist/cli.d.ts +3 -3
  148. package/dist/cli.js +61 -60
  149. package/dist/compounding/engine.js +3 -3
  150. package/dist/compounding/preference-consolidator.js +39 -11
  151. package/dist/compounding/preference-consolidator.js.map +1 -1
  152. package/dist/config.js +1 -1
  153. package/dist/connectors/codex-materialize-runner.js +3 -3
  154. package/dist/connectors/index.js +3 -3
  155. package/dist/consolidation-provenance-check.js +1 -1
  156. package/dist/contradiction/index.js +4 -4
  157. package/dist/conversation-index/backend.js +2 -2
  158. package/dist/conversation-index/indexer.js +1 -1
  159. package/dist/cross-namespace-budget.js +1 -1
  160. package/dist/enrichment/index.js +1 -1
  161. package/dist/entity-retrieval.js +3 -3
  162. package/dist/evals.js +1 -1
  163. package/dist/explicit-capture.d.ts +11 -1
  164. package/dist/explicit-capture.js +1 -1
  165. package/dist/extraction-judge.js +8 -1
  166. package/dist/extraction.js +2 -2
  167. package/dist/fallback-llm.d.ts +23 -6
  168. package/dist/fallback-llm.js +5 -3
  169. package/dist/{first-start-migration-GYJWIH36.js → first-start-migration-FF7YFGRP.js} +6 -6
  170. package/dist/index.d.ts +3 -3
  171. package/dist/index.js +95 -94
  172. package/dist/index.js.map +1 -1
  173. package/dist/lcm/archive.js +2 -2
  174. package/dist/lcm/engine.js +5 -5
  175. package/dist/lcm/index.js +7 -7
  176. package/dist/lcm/summarizer.js +3 -3
  177. package/dist/maintenance/memory-governance-cron.d.ts +6 -4
  178. package/dist/maintenance/memory-governance-cron.js +1 -1
  179. package/dist/maintenance/memory-governance.js +3 -3
  180. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +3 -3
  181. package/dist/maintenance/rebuild-memory-projection.js +4 -4
  182. package/dist/mcp-memory-inspector-app.d.ts +2 -2
  183. package/dist/mcp-memory-inspector-app.js +1 -1
  184. package/dist/migrate/from-engram.js +1 -1
  185. package/dist/namespaces/migrate.js +16 -15
  186. package/dist/namespaces/search.js +12 -11
  187. package/dist/namespaces/storage.js +3 -3
  188. package/dist/network/webdav.d.ts +2 -0
  189. package/dist/network/webdav.js +1 -1
  190. package/dist/objective-state-writers.js +2 -2
  191. package/dist/operator-toolkit.d.ts +3 -1
  192. package/dist/operator-toolkit.js +21 -20
  193. package/dist/{orchestrator-DTRQG75J.d.ts → orchestrator-CqWOjfgl.d.ts} +46 -3
  194. package/dist/orchestrator.d.ts +1 -1
  195. package/dist/orchestrator.js +48 -45
  196. package/dist/patterns-cli.js +1 -1
  197. package/dist/qmd-recall-cache.d.ts +2 -0
  198. package/dist/qmd-recall-cache.js +1 -1
  199. package/dist/qmd.d.ts +37 -2
  200. package/dist/qmd.js +4 -1
  201. package/dist/recall-explain-renderer.js +3 -3
  202. package/dist/recall-planner-llm.d.ts +57 -0
  203. package/dist/recall-planner-llm.js +167 -0
  204. package/dist/recall-planner-llm.js.map +1 -0
  205. package/dist/recall-xray-cli.js +4 -4
  206. package/dist/recall-xray-renderer.js +3 -3
  207. package/dist/recall-xray.js +2 -2
  208. package/dist/resume-bundles.js +2 -2
  209. package/dist/retrieval-agents.js +2 -2
  210. package/dist/routing/store.js +1 -1
  211. package/dist/schemas.d.ts +22 -22
  212. package/dist/search/factory.js +11 -10
  213. package/dist/search/index.js +11 -10
  214. package/dist/search/lancedb-backend.d.ts +1 -1
  215. package/dist/search/lancedb-backend.js +3 -2
  216. package/dist/search/meilisearch-backend.d.ts +1 -1
  217. package/dist/search/meilisearch-backend.js +3 -2
  218. package/dist/search/noop-backend.d.ts +1 -1
  219. package/dist/search/noop-backend.js +1 -1
  220. package/dist/search/orama-backend.d.ts +1 -1
  221. package/dist/search/orama-backend.js +3 -2
  222. package/dist/search/port.d.ts +6 -1
  223. package/dist/search/port.js +7 -0
  224. package/dist/search/remote-backend.d.ts +1 -1
  225. package/dist/search/remote-backend.js +1 -1
  226. package/dist/semantic-consolidation.js +4 -4
  227. package/dist/semantic-rule-promotion.js +3 -3
  228. package/dist/semantic-rule-verifier.js +3 -3
  229. package/dist/session-observer-state.js +1 -1
  230. package/dist/storage.js +2 -2
  231. package/dist/summarizer.js +2 -2
  232. package/dist/temporal-index.js +1 -1
  233. package/dist/{tier-stats-SKML2OSF.js → tier-stats-3LYQ3VV5.js} +3 -3
  234. package/dist/transfer/backup.js +2 -2
  235. package/dist/transfer/capsule-export.js +2 -2
  236. package/dist/transfer/capsule-import.js +2 -2
  237. package/dist/transfer/export-sqlite.js +1 -1
  238. package/dist/transfer/types.d.ts +12 -12
  239. package/dist/types.d.ts +32 -0
  240. package/dist/types.js +1 -1
  241. package/dist/utility-learner.js +1 -1
  242. package/dist/utility-runtime.js +2 -2
  243. package/dist/verified-recall.js +3 -3
  244. package/dist/work/board.js +2 -2
  245. package/dist/work/storage.d.ts +2 -0
  246. package/dist/work/storage.js +1 -1
  247. package/package.json +1 -1
  248. package/src/access-http.ts +24 -10
  249. package/src/access-mcp.test.ts +160 -0
  250. package/src/access-mcp.ts +72 -7
  251. package/src/access-schema.ts +11 -0
  252. package/src/access-service-coding-write.test.ts +478 -0
  253. package/src/access-service.ts +237 -32
  254. package/src/active-recall.test.ts +40 -0
  255. package/src/active-recall.ts +19 -2
  256. package/src/behavior-learner.ts +5 -3
  257. package/src/buffer-session.test.ts +58 -0
  258. package/src/buffer-surprise-trigger.test.ts +4 -18
  259. package/src/buffer.ts +39 -11
  260. package/src/calibration.ts +10 -4
  261. package/src/causal-consolidation.test.ts +47 -2
  262. package/src/causal-consolidation.ts +13 -9
  263. package/src/cli.ts +19 -4
  264. package/src/compounding/engine.ts +2 -0
  265. package/src/compounding/preference-consolidator.test.ts +292 -0
  266. package/src/compounding/preference-consolidator.ts +55 -19
  267. package/src/config.test.ts +213 -0
  268. package/src/config.ts +175 -4
  269. package/src/connectors/codex-materialize-runner.ts +7 -4
  270. package/src/consolidation-provenance-check.ts +24 -5
  271. package/src/conversation-index/indexer.test.ts +22 -0
  272. package/src/conversation-index/indexer.ts +7 -3
  273. package/src/cross-namespace-budget.test.ts +44 -21
  274. package/src/cross-namespace-budget.ts +2 -2
  275. package/src/enrichment/pipeline.ts +11 -16
  276. package/src/evals.ts +1 -1
  277. package/src/explicit-capture.ts +19 -2
  278. package/src/extraction-judge-chain.test.ts +55 -0
  279. package/src/extraction-judge.ts +7 -9
  280. package/src/extraction.ts +16 -5
  281. package/src/fallback-llm.test.ts +600 -1
  282. package/src/fallback-llm.ts +91 -22
  283. package/src/maintenance/memory-governance-cron.ts +39 -29
  284. package/src/mcp-memory-inspector-app.ts +54 -12
  285. package/src/message-parts/index.ts +6 -0
  286. package/src/message-parts/message-parts.test.ts +30 -0
  287. package/src/migrate/from-engram.ts +19 -5
  288. package/src/namespaces/search.test.ts +15 -2
  289. package/src/namespaces/search.ts +1 -1
  290. package/src/network/webdav.ts +61 -21
  291. package/src/operator-toolkit.ts +6 -2
  292. package/src/orchestrator.ts +173 -20
  293. package/src/qmd-client.test.ts +85 -0
  294. package/src/qmd-recall-cache.test.ts +16 -0
  295. package/src/qmd-recall-cache.ts +7 -0
  296. package/src/qmd.test.ts +54 -0
  297. package/src/qmd.ts +119 -19
  298. package/src/recall-planner-llm.test.ts +224 -0
  299. package/src/recall-planner-llm.ts +289 -0
  300. package/src/routing/store.ts +4 -8
  301. package/src/search/factory.ts +3 -0
  302. package/src/search/lancedb-backend.ts +15 -3
  303. package/src/search/meilisearch-backend.ts +70 -7
  304. package/src/search/noop-backend.ts +5 -1
  305. package/src/search/orama-backend.ts +15 -3
  306. package/src/search/port.ts +15 -0
  307. package/src/search/remote-backend.ts +5 -1
  308. package/src/session-observer-state.ts +1 -1
  309. package/src/summarizer.ts +3 -3
  310. package/src/temporal-index.test.ts +18 -0
  311. package/src/temporal-index.ts +45 -0
  312. package/src/training-export/cli-date-validation.test.ts +36 -0
  313. package/src/training-export/date-parse.ts +21 -2
  314. package/src/transfer/export-sqlite.ts +3 -0
  315. package/src/types.ts +35 -0
  316. package/src/utility-learner.ts +1 -0
  317. package/src/work/storage.ts +23 -0
  318. package/dist/chunk-2QANQKSQ.js.map +0 -1
  319. package/dist/chunk-5RPTH6AU.js.map +0 -1
  320. package/dist/chunk-AJA46VX5.js.map +0 -1
  321. package/dist/chunk-C4SQJZAF.js.map +0 -1
  322. package/dist/chunk-CHCA44C3.js.map +0 -1
  323. package/dist/chunk-CSKLPDN6.js.map +0 -1
  324. package/dist/chunk-DLJ4IR6M.js.map +0 -1
  325. package/dist/chunk-EAZGEEG2.js.map +0 -1
  326. package/dist/chunk-EUML3N6B.js.map +0 -1
  327. package/dist/chunk-EVZFIAPG.js.map +0 -1
  328. package/dist/chunk-G3Z3QEF5.js.map +0 -1
  329. package/dist/chunk-GMAG2HS4.js.map +0 -1
  330. package/dist/chunk-HENLZHIT.js.map +0 -1
  331. package/dist/chunk-HINSGUA7.js.map +0 -1
  332. package/dist/chunk-HJNQQICM.js.map +0 -1
  333. package/dist/chunk-HPWVAEET.js.map +0 -1
  334. package/dist/chunk-IOTENEVL.js.map +0 -1
  335. package/dist/chunk-IP73YCZP.js.map +0 -1
  336. package/dist/chunk-JHMFYY7L.js.map +0 -1
  337. package/dist/chunk-JNANKJLN.js.map +0 -1
  338. package/dist/chunk-KGK2QKWL.js.map +0 -1
  339. package/dist/chunk-KM2A35EO.js.map +0 -1
  340. package/dist/chunk-KVEVLBKC.js.map +0 -1
  341. package/dist/chunk-L227SKTB.js.map +0 -1
  342. package/dist/chunk-LZ3VEOU5.js.map +0 -1
  343. package/dist/chunk-NOMEVTUD.js.map +0 -1
  344. package/dist/chunk-NZPF2SYV.js.map +0 -1
  345. package/dist/chunk-PCI747N2.js.map +0 -1
  346. package/dist/chunk-PPPZY2EU.js.map +0 -1
  347. package/dist/chunk-TH67Q46T.js.map +0 -1
  348. package/dist/chunk-UWY7GIVS.js.map +0 -1
  349. package/dist/chunk-VJXSUAO7.js.map +0 -1
  350. package/dist/chunk-XKIQZXUB.js.map +0 -1
  351. package/dist/chunk-XPSVGJYA.js.map +0 -1
  352. package/dist/chunk-XSWKORGM.js.map +0 -1
  353. package/dist/chunk-YCN4BVDK.js.map +0 -1
  354. package/dist/chunk-ZDTVJXIP.js.map +0 -1
  355. /package/dist/{capsule-crypto-7FJQINUR.js.map → capsule-crypto-YO5QJ6L3.js.map} +0 -0
  356. /package/dist/{chunk-AU7Q3LSC.js.map → chunk-2QSZNTDO.js.map} +0 -0
  357. /package/dist/{chunk-HSVJGWYS.js.map → chunk-2ROPI5OE.js.map} +0 -0
  358. /package/dist/{chunk-CF3ZF2YU.js.map → chunk-3QSU4NFF.js.map} +0 -0
  359. /package/dist/{chunk-OI27U2HT.js.map → chunk-5BTCT236.js.map} +0 -0
  360. /package/dist/{chunk-CO7ZO4TU.js.map → chunk-5VDJMYTF.js.map} +0 -0
  361. /package/dist/{chunk-YFS5OEKO.js.map → chunk-7MLB4NCL.js.map} +0 -0
  362. /package/dist/{chunk-557IAFPD.js.map → chunk-APRRL26Q.js.map} +0 -0
  363. /package/dist/{chunk-QDDHYAKV.js.map → chunk-AZDOWD2L.js.map} +0 -0
  364. /package/dist/{chunk-MLT75J5S.js.map → chunk-B6SU7YSE.js.map} +0 -0
  365. /package/dist/{chunk-FXKPZ3H6.js.map → chunk-BPSGLMQ4.js.map} +0 -0
  366. /package/dist/{chunk-2NLLXCJG.js.map → chunk-BXLOS5AJ.js.map} +0 -0
  367. /package/dist/{chunk-IK34DVAC.js.map → chunk-CIOMS6DI.js.map} +0 -0
  368. /package/dist/{chunk-7DZRO2DC.js.map → chunk-DEPRLVLK.js.map} +0 -0
  369. /package/dist/{chunk-DHGSZ3UD.js.map → chunk-DGNQRNLL.js.map} +0 -0
  370. /package/dist/{chunk-X7Y7WX73.js.map → chunk-DQEMWVMT.js.map} +0 -0
  371. /package/dist/{chunk-ETUPBUHB.js.map → chunk-GDASG7NC.js.map} +0 -0
  372. /package/dist/{chunk-4HP7HIE3.js.map → chunk-HP5FMB6L.js.map} +0 -0
  373. /package/dist/{chunk-DOX2CG6Y.js.map → chunk-IEUU7O4F.js.map} +0 -0
  374. /package/dist/{chunk-WSGF57U2.js.map → chunk-JQDZQ4TB.js.map} +0 -0
  375. /package/dist/{chunk-W7L6HXUC.js.map → chunk-LXOM6IQU.js.map} +0 -0
  376. /package/dist/{chunk-6JGNHWCI.js.map → chunk-OBIRVF36.js.map} +0 -0
  377. /package/dist/{chunk-GUPISBV2.js.map → chunk-PP2JH3GP.js.map} +0 -0
  378. /package/dist/{chunk-OXJBNGBK.js.map → chunk-PSUB67YB.js.map} +0 -0
  379. /package/dist/{chunk-KIB7SDIJ.js.map → chunk-Q6YIJGXJ.js.map} +0 -0
  380. /package/dist/{chunk-ZT3EGNLR.js.map → chunk-QPD426WT.js.map} +0 -0
  381. /package/dist/{chunk-RLV3PQGH.js.map → chunk-QVO4YOB7.js.map} +0 -0
  382. /package/dist/{chunk-KQAFEZQX.js.map → chunk-VDX2J7OX.js.map} +0 -0
  383. /package/dist/{chunk-IK7DCC5H.js.map → chunk-VMGLYN42.js.map} +0 -0
  384. /package/dist/{chunk-NSKYFGDL.js.map → chunk-X4QQB7O6.js.map} +0 -0
  385. /package/dist/{first-start-migration-GYJWIH36.js.map → first-start-migration-FF7YFGRP.js.map} +0 -0
  386. /package/dist/{tier-stats-SKML2OSF.js.map → tier-stats-3LYQ3VV5.js.map} +0 -0
@@ -111,8 +111,8 @@ declare const recallRequestSchema: z.ZodObject<{
111
111
  mode?: "no_recall" | "minimal" | "full" | "graph_mode" | "auto" | undefined;
112
112
  cwd?: string | undefined;
113
113
  includeLowConfidence?: boolean | undefined;
114
- disclosure?: "chunk" | "section" | "raw" | undefined;
115
114
  idempotencyKey?: string | undefined;
115
+ disclosure?: "chunk" | "section" | "raw" | undefined;
116
116
  asOf?: string | undefined;
117
117
  includeDebug?: boolean | undefined;
118
118
  codingContext?: {
@@ -132,8 +132,8 @@ declare const recallRequestSchema: z.ZodObject<{
132
132
  mode?: "no_recall" | "minimal" | "full" | "graph_mode" | "auto" | undefined;
133
133
  cwd?: string | undefined;
134
134
  includeLowConfidence?: boolean | undefined;
135
- disclosure?: "chunk" | "section" | "raw" | undefined;
136
135
  idempotencyKey?: string | undefined;
136
+ disclosure?: "chunk" | "section" | "raw" | undefined;
137
137
  asOf?: string | undefined;
138
138
  includeDebug?: boolean | undefined;
139
139
  codingContext?: {
@@ -241,20 +241,20 @@ declare const observeRequestSchema: z.ZodObject<{
241
241
  }, "strip", z.ZodTypeAny, {
242
242
  kind: "text" | "tool_call" | "tool_result" | "patch" | "file_read" | "file_write" | "step_start" | "step_finish" | "snapshot" | "retry";
243
243
  payload: Record<string, unknown>;
244
- tool_name?: string | null | undefined;
244
+ ordinal?: number | null | undefined;
245
245
  toolName?: string | null | undefined;
246
+ tool_name?: string | null | undefined;
246
247
  filePath?: string | null | undefined;
247
- ordinal?: number | null | undefined;
248
248
  file_path?: string | null | undefined;
249
249
  createdAt?: string | null | undefined;
250
250
  created_at?: string | null | undefined;
251
251
  }, {
252
252
  kind: "text" | "tool_call" | "tool_result" | "patch" | "file_read" | "file_write" | "step_start" | "step_finish" | "snapshot" | "retry";
253
253
  payload: Record<string, unknown>;
254
- tool_name?: string | null | undefined;
254
+ ordinal?: number | null | undefined;
255
255
  toolName?: string | null | undefined;
256
+ tool_name?: string | null | undefined;
256
257
  filePath?: string | null | undefined;
257
- ordinal?: number | null | undefined;
258
258
  file_path?: string | null | undefined;
259
259
  createdAt?: string | null | undefined;
260
260
  created_at?: string | null | undefined;
@@ -265,10 +265,10 @@ declare const observeRequestSchema: z.ZodObject<{
265
265
  parts?: {
266
266
  kind: "text" | "tool_call" | "tool_result" | "patch" | "file_read" | "file_write" | "step_start" | "step_finish" | "snapshot" | "retry";
267
267
  payload: Record<string, unknown>;
268
- tool_name?: string | null | undefined;
268
+ ordinal?: number | null | undefined;
269
269
  toolName?: string | null | undefined;
270
+ tool_name?: string | null | undefined;
270
271
  filePath?: string | null | undefined;
271
- ordinal?: number | null | undefined;
272
272
  file_path?: string | null | undefined;
273
273
  createdAt?: string | null | undefined;
274
274
  created_at?: string | null | undefined;
@@ -281,10 +281,10 @@ declare const observeRequestSchema: z.ZodObject<{
281
281
  parts?: {
282
282
  kind: "text" | "tool_call" | "tool_result" | "patch" | "file_read" | "file_write" | "step_start" | "step_finish" | "snapshot" | "retry";
283
283
  payload: Record<string, unknown>;
284
- tool_name?: string | null | undefined;
284
+ ordinal?: number | null | undefined;
285
285
  toolName?: string | null | undefined;
286
+ tool_name?: string | null | undefined;
286
287
  filePath?: string | null | undefined;
287
- ordinal?: number | null | undefined;
288
288
  file_path?: string | null | undefined;
289
289
  createdAt?: string | null | undefined;
290
290
  created_at?: string | null | undefined;
@@ -309,10 +309,10 @@ declare const observeRequestSchema: z.ZodObject<{
309
309
  parts?: {
310
310
  kind: "text" | "tool_call" | "tool_result" | "patch" | "file_read" | "file_write" | "step_start" | "step_finish" | "snapshot" | "retry";
311
311
  payload: Record<string, unknown>;
312
- tool_name?: string | null | undefined;
312
+ ordinal?: number | null | undefined;
313
313
  toolName?: string | null | undefined;
314
+ tool_name?: string | null | undefined;
314
315
  filePath?: string | null | undefined;
315
- ordinal?: number | null | undefined;
316
316
  file_path?: string | null | undefined;
317
317
  createdAt?: string | null | undefined;
318
318
  created_at?: string | null | undefined;
@@ -332,10 +332,10 @@ declare const observeRequestSchema: z.ZodObject<{
332
332
  parts?: {
333
333
  kind: "text" | "tool_call" | "tool_result" | "patch" | "file_read" | "file_write" | "step_start" | "step_finish" | "snapshot" | "retry";
334
334
  payload: Record<string, unknown>;
335
- tool_name?: string | null | undefined;
335
+ ordinal?: number | null | undefined;
336
336
  toolName?: string | null | undefined;
337
+ tool_name?: string | null | undefined;
337
338
  filePath?: string | null | undefined;
338
- ordinal?: number | null | undefined;
339
339
  file_path?: string | null | undefined;
340
340
  createdAt?: string | null | undefined;
341
341
  created_at?: string | null | undefined;
@@ -361,6 +361,8 @@ declare const memoryStoreRequestSchema: z.ZodObject<{
361
361
  entityRef: z.ZodOptional<z.ZodString>;
362
362
  ttl: z.ZodOptional<z.ZodString>;
363
363
  sourceReason: z.ZodOptional<z.ZodString>;
364
+ cwd: z.ZodOptional<z.ZodString>;
365
+ projectTag: z.ZodOptional<z.ZodString>;
364
366
  }, "strip", z.ZodTypeAny, {
365
367
  content: string;
366
368
  schemaVersion?: number | undefined;
@@ -373,7 +375,9 @@ declare const memoryStoreRequestSchema: z.ZodObject<{
373
375
  entityRef?: string | undefined;
374
376
  ttl?: string | undefined;
375
377
  sourceReason?: string | undefined;
378
+ cwd?: string | undefined;
376
379
  idempotencyKey?: string | undefined;
380
+ projectTag?: string | undefined;
377
381
  }, {
378
382
  content: string;
379
383
  schemaVersion?: number | undefined;
@@ -386,7 +390,9 @@ declare const memoryStoreRequestSchema: z.ZodObject<{
386
390
  entityRef?: string | undefined;
387
391
  ttl?: string | undefined;
388
392
  sourceReason?: string | undefined;
393
+ cwd?: string | undefined;
389
394
  idempotencyKey?: string | undefined;
395
+ projectTag?: string | undefined;
390
396
  }>;
391
397
  declare const suggestionSubmitRequestSchema: z.ZodObject<{
392
398
  schemaVersion: z.ZodOptional<z.ZodNumber>;
@@ -401,6 +407,8 @@ declare const suggestionSubmitRequestSchema: z.ZodObject<{
401
407
  entityRef: z.ZodOptional<z.ZodString>;
402
408
  ttl: z.ZodOptional<z.ZodString>;
403
409
  sourceReason: z.ZodOptional<z.ZodString>;
410
+ cwd: z.ZodOptional<z.ZodString>;
411
+ projectTag: z.ZodOptional<z.ZodString>;
404
412
  }, "strip", z.ZodTypeAny, {
405
413
  content: string;
406
414
  schemaVersion?: number | undefined;
@@ -413,7 +421,9 @@ declare const suggestionSubmitRequestSchema: z.ZodObject<{
413
421
  entityRef?: string | undefined;
414
422
  ttl?: string | undefined;
415
423
  sourceReason?: string | undefined;
424
+ cwd?: string | undefined;
416
425
  idempotencyKey?: string | undefined;
426
+ projectTag?: string | undefined;
417
427
  }, {
418
428
  content: string;
419
429
  schemaVersion?: number | undefined;
@@ -426,7 +436,9 @@ declare const suggestionSubmitRequestSchema: z.ZodObject<{
426
436
  entityRef?: string | undefined;
427
437
  ttl?: string | undefined;
428
438
  sourceReason?: string | undefined;
439
+ cwd?: string | undefined;
429
440
  idempotencyKey?: string | undefined;
441
+ projectTag?: string | undefined;
430
442
  }>;
431
443
  declare const reviewDispositionRequestSchema: z.ZodObject<{
432
444
  memoryId: z.ZodString;
@@ -25,10 +25,10 @@ import {
25
25
  trustZoneDemoSeedRequestSchema,
26
26
  trustZonePromoteRequestSchema,
27
27
  validateRequest
28
- } from "./chunk-PPPZY2EU.js";
29
- import "./chunk-KQAFEZQX.js";
28
+ } from "./chunk-WD2W4234.js";
29
+ import "./chunk-VDX2J7OX.js";
30
30
  import "./chunk-WEHSQBFR.js";
31
- import "./chunk-X7Y7WX73.js";
31
+ import "./chunk-DQEMWVMT.js";
32
32
  import "./chunk-J4EB7DNW.js";
33
33
  import "./chunk-BJMBJZ2Y.js";
34
34
  import "./chunk-UKJAGEXH.js";
@@ -6,7 +6,7 @@ import { AnomalyDetectorResult } from './recall-audit-anomaly.js';
6
6
  import { ExplicitCaptureInput } from './explicit-capture.js';
7
7
  import { BudgetDecision } from './cross-namespace-budget.js';
8
8
  import { readMemoryGovernanceRunArtifact } from './maintenance/memory-governance.js';
9
- import { O as Orchestrator, I as IntentDebugSnapshot, G as GraphRecallSnapshot, P as PatternReinforcementResult } from './orchestrator-DTRQG75J.js';
9
+ import { O as Orchestrator, I as IntentDebugSnapshot, G as GraphRecallSnapshot, P as PatternReinforcementResult } from './orchestrator-CqWOjfgl.js';
10
10
  import { LiveConnectorsRunSummary } from './live-connectors-runner.js';
11
11
  import { LastRecallSnapshot } from './recall-state.js';
12
12
  import { GraphSnapshotRequest, GraphSnapshotResponse } from './graph-snapshot.js';
@@ -644,9 +644,18 @@ interface EngramAccessWriteEnvelope {
644
644
  */
645
645
  authenticatedPrincipal?: string;
646
646
  }
647
- interface EngramAccessMemoryStoreRequest extends EngramAccessWriteEnvelope, ExplicitCaptureInput {
647
+ /**
648
+ * Optional git/project context for project-scoped writes (#1434). When no
649
+ * explicit `namespace` is supplied, these route the write to the same project
650
+ * namespace recall/observe resolve from `cwd`/`projectTag` (rule 42 symmetry).
651
+ */
652
+ interface CodingScopedWriteInput {
653
+ cwd?: string;
654
+ projectTag?: string;
648
655
  }
649
- interface EngramAccessSuggestionSubmitRequest extends EngramAccessWriteEnvelope, ExplicitCaptureInput {
656
+ interface EngramAccessMemoryStoreRequest extends EngramAccessWriteEnvelope, ExplicitCaptureInput, CodingScopedWriteInput {
657
+ }
658
+ interface EngramAccessSuggestionSubmitRequest extends EngramAccessWriteEnvelope, ExplicitCaptureInput, CodingScopedWriteInput {
650
659
  }
651
660
  interface EngramAccessWriteResponse {
652
661
  schemaVersion: 1;
@@ -774,6 +783,47 @@ declare class EngramAccessService {
774
783
  private resolveRecallNamespace;
775
784
  private resolveRequestPrincipal;
776
785
  private resolveWritableNamespace;
786
+ /**
787
+ * Resolve a coding context from `cwd`/`projectTag` WITHOUT persisting it to
788
+ * any session — the read-only half of `maybeAttachCodingContext`. Returns
789
+ * null when project scoping is off or nothing resolves. `projectTag` takes
790
+ * priority over `cwd` (matching `maybeAttachCodingContext`).
791
+ */
792
+ private resolveCodingContextFromOptions;
793
+ /**
794
+ * Resolve the write namespace for explicit-write tools (memory_store /
795
+ * suggestion_submit), project-scoping the write the same way recall does so a
796
+ * memory stored with a client-injected `cwd`/`projectTag` is discoverable by
797
+ * project-scoped recall (#1434, rule 42).
798
+ *
799
+ * Precedence:
800
+ * - An explicit `namespace` always wins and is authorized strictly via
801
+ * `resolveWritableNamespace` → `canWriteNamespace`. A coding-overlay
802
+ * namespace string (`<base>-project-*`) is NOT a writable target via the
803
+ * explicit field — project scoping is requested with `cwd`/`projectTag`,
804
+ * never by naming the derived namespace — so there is no way to bypass the
805
+ * policy allow-list by guessing/forging an overlay name (Codex review).
806
+ * - With NO coding overlay, the write stays on `config.defaultNamespace` —
807
+ * exactly the pre-#1434 behavior, so an unqualified write is NOT silently
808
+ * moved to a principal self namespace (Codex review).
809
+ * - WITH a coding overlay, the base is the principal self namespace
810
+ * (`defaultNamespaceForPrincipal`, write-checked) — the SAME base recall,
811
+ * observe, and the orchestrator buffer-flush write path overlay onto
812
+ * (rule 42 / Cursor) — so a project-scoped store lands exactly where
813
+ * project-scoped recall searches. The overlay namespace is always REBUILT
814
+ * from the authenticated principal's base, never accepted as a caller
815
+ * string, so a caller can never reach another principal's subtree.
816
+ *
817
+ * Read-only: this NEVER mutates session coding context, so the idempotency
818
+ * peeks and dryRun preflights that call it stay side-effect free (Codex
819
+ * review). It prefers the per-call `cwd`/`projectTag` (the project explicitly
820
+ * identified for this write), else the session's existing context. The HTTP
821
+ * surface lets the peek and the write each resolve independently; the peek's
822
+ * namespace only gates rate-limiting (memory_store/suggestion_submit run their
823
+ * own idempotency check), so a benign session-context change between the two
824
+ * never fails a write — there is no namespace to "pin".
825
+ */
826
+ private resolveCodingScopedWriteNamespace;
777
827
  private objectiveStateStoreLocationForNamespace;
778
828
  private resolveReadableNamespace;
779
829
  private buildRecallDebug;
@@ -831,6 +881,17 @@ declare class EngramAccessService {
831
881
  * being in a repo is a normal runtime state.
832
882
  */
833
883
  private maybeAttachCodingContext;
884
+ /**
885
+ * Seed the session's coding binding AFTER a committed, project-scoped explicit
886
+ * write (memory_store / suggestion_submit), mirroring the recall path's
887
+ * `maybeAttachCodingContext` so a later bare recall/write on the same session
888
+ * is scoped to the same project. Called only from the post-persist path, so it
889
+ * never fires on dryRun, replay/conflict, or quota-rejected requests. Skips
890
+ * when an explicit `namespace` was supplied — that write bypassed the coding
891
+ * overlay, so binding the session to a project it never wrote to would make
892
+ * later bare recalls miss (Codex review).
893
+ */
894
+ private attachCodingContextAfterScopedWrite;
834
895
  recall(request: EngramAccessRecallRequest): Promise<EngramAccessRecallResponse>;
835
896
  private executeRecall;
836
897
  recallExplain(request?: EngramAccessRecallExplainRequest): Promise<EngramAccessRecallExplainResponse>;
@@ -889,9 +950,13 @@ declare class EngramAccessService {
889
950
  recall?: EngramAccessRecallResponse;
890
951
  }>;
891
952
  private xrayQueue;
892
- memoryStore(request: EngramAccessMemoryStoreRequest): Promise<EngramAccessWriteResponse>;
953
+ memoryStore(request: EngramAccessMemoryStoreRequest, hooks?: {
954
+ enforceWriteQuota?: () => void | Promise<void>;
955
+ }): Promise<EngramAccessWriteResponse>;
893
956
  peekMemoryStoreIdempotency(request: EngramAccessMemoryStoreRequest): Promise<EngramAccessIdempotencyStatus>;
894
- suggestionSubmit(request: EngramAccessSuggestionSubmitRequest): Promise<EngramAccessWriteResponse>;
957
+ suggestionSubmit(request: EngramAccessSuggestionSubmitRequest, hooks?: {
958
+ enforceWriteQuota?: () => void | Promise<void>;
959
+ }): Promise<EngramAccessWriteResponse>;
895
960
  peekSuggestionSubmitIdempotency(request: EngramAccessSuggestionSubmitRequest): Promise<EngramAccessIdempotencyStatus>;
896
961
  private validateWriteCandidate;
897
962
  memoryGet(memoryId: string, namespace?: string, principal?: string): Promise<EngramAccessMemoryResponse>;
@@ -1489,4 +1554,4 @@ declare class EngramAccessService {
1489
1554
  }): Promise<DreamsRunResult>;
1490
1555
  }
1491
1556
 
1492
- export { type EngramAccessReviewDispositionResponse as $, type EngramAccessMemoryBrowseRequest as A, type EngramAccessMemoryBrowseResponse as B, type EngramAccessMemoryRecord as C, type EngramAccessMemoryResponse as D, EngramAccessService as E, type EngramAccessMemoryStoreRequest as F, type EngramAccessMemorySummary as G, type EngramAccessObserveMessage as H, type EngramAccessObserveRequest as I, type EngramAccessObserveResponse as J, type EngramAccessOfflineSyncApplyFileContentRequest as K, type EngramAccessOfflineSyncApplyFileContentResponse as L, type EngramAccessOfflineSyncApplyRequest as M, type EngramAccessOfflineSyncApplyResponse as N, type EngramAccessOfflineSyncFileContentRequest as O, type ProcedureStatsConfigSnapshot as P, type EngramAccessOfflineSyncFileContentResponse as Q, type EngramAccessOfflineSyncFilesRequest as R, type EngramAccessOfflineSyncFilesResponse as S, type EngramAccessOfflineSyncSnapshotRequest as T, type EngramAccessOfflineSyncSnapshotResponse as U, type EngramAccessOfflineSyncSnapshotStreamResponse as V, type EngramAccessQualityResponse as W, type EngramAccessRecallExplainRequest as X, type EngramAccessRecallExplainResponse as Y, type EngramAccessRecallRequest as Z, type EngramAccessReviewDispositionRequest as _, type EngramAccessRecallResponse as a, type EngramAccessReviewQueueResponse as a0, type EngramAccessSetCodingContextRequest as a1, type EngramAccessSuggestionSubmitRequest as a2, type EngramAccessTimelineResponse as a3, type EngramAccessTrustZoneBrowseRequest as a4, type EngramAccessTrustZoneBrowseResponse as a5, type EngramAccessTrustZoneDemoSeedRequest as a6, type EngramAccessTrustZoneDemoSeedResponse as a7, type EngramAccessTrustZonePromoteRequest as a8, type EngramAccessTrustZonePromoteResponse as a9, type EngramAccessTrustZoneRecordSummary as aa, type EngramAccessTrustZoneStatusResponse as ab, type EngramAccessWriteEnvelope as ac, type EngramAccessWriteResponse as ad, shapeMemorySummary as ae, EngramAccessInputError as b, type ProcedureStatsRecent as c, type ProcedureStatsReport as d, type ProcedureStatusCounts as e, computeProcedureStats as f, formatProcedureStatsText as g, ENGRAM_ACCESS_WRITE_SCHEMA_VERSION as h, type EngramAccessActionConfidenceRequest as i, type EngramAccessActionConfidenceResponse as j, type EngramAccessBriefingRequest as k, type EngramAccessBriefingResponse as l, type EngramAccessCapsuleListResponse as m, type EngramAccessDaySummaryRequest as n, type EngramAccessEntityListResponse as o, type EngramAccessEntityResponse as p, type EngramAccessEntitySummary as q, type EngramAccessHealthResponse as r, type EngramAccessLcmCompactionFlushRequest as s, type EngramAccessLcmCompactionFlushResponse as t, type EngramAccessLcmCompactionRecordRequest as u, type EngramAccessLcmCompactionRecordResponse as v, type EngramAccessLcmSearchRequest as w, type EngramAccessLcmSearchResponse as x, type EngramAccessLcmStatusResponse as y, type EngramAccessMaintenanceResponse as z };
1557
+ export { type EngramAccessReviewDispositionRequest as $, type EngramAccessMemoryBrowseRequest as A, type EngramAccessMemoryBrowseResponse as B, type CodingScopedWriteInput as C, type EngramAccessMemoryRecord as D, EngramAccessService as E, type EngramAccessMemoryResponse as F, type EngramAccessMemoryStoreRequest as G, type EngramAccessMemorySummary as H, type EngramAccessObserveMessage as I, type EngramAccessObserveRequest as J, type EngramAccessObserveResponse as K, type EngramAccessOfflineSyncApplyFileContentRequest as L, type EngramAccessOfflineSyncApplyFileContentResponse as M, type EngramAccessOfflineSyncApplyRequest as N, type EngramAccessOfflineSyncApplyResponse as O, type ProcedureStatsConfigSnapshot as P, type EngramAccessOfflineSyncFileContentRequest as Q, type EngramAccessOfflineSyncFileContentResponse as R, type EngramAccessOfflineSyncFilesRequest as S, type EngramAccessOfflineSyncFilesResponse as T, type EngramAccessOfflineSyncSnapshotRequest as U, type EngramAccessOfflineSyncSnapshotResponse as V, type EngramAccessOfflineSyncSnapshotStreamResponse as W, type EngramAccessQualityResponse as X, type EngramAccessRecallExplainRequest as Y, type EngramAccessRecallExplainResponse as Z, type EngramAccessRecallRequest as _, type EngramAccessRecallResponse as a, type EngramAccessReviewDispositionResponse as a0, type EngramAccessReviewQueueResponse as a1, type EngramAccessSetCodingContextRequest as a2, type EngramAccessSuggestionSubmitRequest as a3, type EngramAccessTimelineResponse as a4, type EngramAccessTrustZoneBrowseRequest as a5, type EngramAccessTrustZoneBrowseResponse as a6, type EngramAccessTrustZoneDemoSeedRequest as a7, type EngramAccessTrustZoneDemoSeedResponse as a8, type EngramAccessTrustZonePromoteRequest as a9, type EngramAccessTrustZonePromoteResponse as aa, type EngramAccessTrustZoneRecordSummary as ab, type EngramAccessTrustZoneStatusResponse as ac, type EngramAccessWriteEnvelope as ad, type EngramAccessWriteResponse as ae, shapeMemorySummary as af, EngramAccessInputError as b, type ProcedureStatsRecent as c, type ProcedureStatsReport as d, type ProcedureStatusCounts as e, computeProcedureStats as f, formatProcedureStatsText as g, ENGRAM_ACCESS_WRITE_SCHEMA_VERSION as h, type EngramAccessActionConfidenceRequest as i, type EngramAccessActionConfidenceResponse as j, type EngramAccessBriefingRequest as k, type EngramAccessBriefingResponse as l, type EngramAccessCapsuleListResponse as m, type EngramAccessDaySummaryRequest as n, type EngramAccessEntityListResponse as o, type EngramAccessEntityResponse as p, type EngramAccessEntitySummary as q, type EngramAccessHealthResponse as r, type EngramAccessLcmCompactionFlushRequest as s, type EngramAccessLcmCompactionFlushResponse as t, type EngramAccessLcmCompactionRecordRequest as u, type EngramAccessLcmCompactionRecordResponse as v, type EngramAccessLcmSearchRequest as w, type EngramAccessLcmSearchResponse as x, type EngramAccessLcmStatusResponse as y, type EngramAccessMaintenanceResponse as z };
@@ -1,13 +1,13 @@
1
1
  import './storage.js';
2
2
  import './types-B1VHaf2w.js';
3
- export { h as ENGRAM_ACCESS_WRITE_SCHEMA_VERSION, i as EngramAccessActionConfidenceRequest, j as EngramAccessActionConfidenceResponse, k as EngramAccessBriefingRequest, l as EngramAccessBriefingResponse, m as EngramAccessCapsuleListResponse, n as EngramAccessDaySummaryRequest, o as EngramAccessEntityListResponse, p as EngramAccessEntityResponse, q as EngramAccessEntitySummary, r as EngramAccessHealthResponse, b as EngramAccessInputError, s as EngramAccessLcmCompactionFlushRequest, t as EngramAccessLcmCompactionFlushResponse, u as EngramAccessLcmCompactionRecordRequest, v as EngramAccessLcmCompactionRecordResponse, w as EngramAccessLcmSearchRequest, x as EngramAccessLcmSearchResponse, y as EngramAccessLcmStatusResponse, z as EngramAccessMaintenanceResponse, A as EngramAccessMemoryBrowseRequest, B as EngramAccessMemoryBrowseResponse, C as EngramAccessMemoryRecord, D as EngramAccessMemoryResponse, F as EngramAccessMemoryStoreRequest, G as EngramAccessMemorySummary, H as EngramAccessObserveMessage, I as EngramAccessObserveRequest, J as EngramAccessObserveResponse, K as EngramAccessOfflineSyncApplyFileContentRequest, L as EngramAccessOfflineSyncApplyFileContentResponse, M as EngramAccessOfflineSyncApplyRequest, N as EngramAccessOfflineSyncApplyResponse, O as EngramAccessOfflineSyncFileContentRequest, Q as EngramAccessOfflineSyncFileContentResponse, R as EngramAccessOfflineSyncFilesRequest, S as EngramAccessOfflineSyncFilesResponse, T as EngramAccessOfflineSyncSnapshotRequest, U as EngramAccessOfflineSyncSnapshotResponse, V as EngramAccessOfflineSyncSnapshotStreamResponse, W as EngramAccessQualityResponse, X as EngramAccessRecallExplainRequest, Y as EngramAccessRecallExplainResponse, Z as EngramAccessRecallRequest, a as EngramAccessRecallResponse, _ as EngramAccessReviewDispositionRequest, $ as EngramAccessReviewDispositionResponse, a0 as EngramAccessReviewQueueResponse, E as EngramAccessService, a1 as EngramAccessSetCodingContextRequest, a2 as EngramAccessSuggestionSubmitRequest, a3 as EngramAccessTimelineResponse, a4 as EngramAccessTrustZoneBrowseRequest, a5 as EngramAccessTrustZoneBrowseResponse, a6 as EngramAccessTrustZoneDemoSeedRequest, a7 as EngramAccessTrustZoneDemoSeedResponse, a8 as EngramAccessTrustZonePromoteRequest, a9 as EngramAccessTrustZonePromoteResponse, aa as EngramAccessTrustZoneRecordSummary, ab as EngramAccessTrustZoneStatusResponse, ac as EngramAccessWriteEnvelope, ad as EngramAccessWriteResponse, ae as shapeMemorySummary } from './access-service-D2J9dh_9.js';
3
+ export { C as CodingScopedWriteInput, h as ENGRAM_ACCESS_WRITE_SCHEMA_VERSION, i as EngramAccessActionConfidenceRequest, j as EngramAccessActionConfidenceResponse, k as EngramAccessBriefingRequest, l as EngramAccessBriefingResponse, m as EngramAccessCapsuleListResponse, n as EngramAccessDaySummaryRequest, o as EngramAccessEntityListResponse, p as EngramAccessEntityResponse, q as EngramAccessEntitySummary, r as EngramAccessHealthResponse, b as EngramAccessInputError, s as EngramAccessLcmCompactionFlushRequest, t as EngramAccessLcmCompactionFlushResponse, u as EngramAccessLcmCompactionRecordRequest, v as EngramAccessLcmCompactionRecordResponse, w as EngramAccessLcmSearchRequest, x as EngramAccessLcmSearchResponse, y as EngramAccessLcmStatusResponse, z as EngramAccessMaintenanceResponse, A as EngramAccessMemoryBrowseRequest, B as EngramAccessMemoryBrowseResponse, D as EngramAccessMemoryRecord, F as EngramAccessMemoryResponse, G as EngramAccessMemoryStoreRequest, H as EngramAccessMemorySummary, I as EngramAccessObserveMessage, J as EngramAccessObserveRequest, K as EngramAccessObserveResponse, L as EngramAccessOfflineSyncApplyFileContentRequest, M as EngramAccessOfflineSyncApplyFileContentResponse, N as EngramAccessOfflineSyncApplyRequest, O as EngramAccessOfflineSyncApplyResponse, Q as EngramAccessOfflineSyncFileContentRequest, R as EngramAccessOfflineSyncFileContentResponse, S as EngramAccessOfflineSyncFilesRequest, T as EngramAccessOfflineSyncFilesResponse, U as EngramAccessOfflineSyncSnapshotRequest, V as EngramAccessOfflineSyncSnapshotResponse, W as EngramAccessOfflineSyncSnapshotStreamResponse, X as EngramAccessQualityResponse, Y as EngramAccessRecallExplainRequest, Z as EngramAccessRecallExplainResponse, _ as EngramAccessRecallRequest, a as EngramAccessRecallResponse, $ as EngramAccessReviewDispositionRequest, a0 as EngramAccessReviewDispositionResponse, a1 as EngramAccessReviewQueueResponse, E as EngramAccessService, a2 as EngramAccessSetCodingContextRequest, a3 as EngramAccessSuggestionSubmitRequest, a4 as EngramAccessTimelineResponse, a5 as EngramAccessTrustZoneBrowseRequest, a6 as EngramAccessTrustZoneBrowseResponse, a7 as EngramAccessTrustZoneDemoSeedRequest, a8 as EngramAccessTrustZoneDemoSeedResponse, a9 as EngramAccessTrustZonePromoteRequest, aa as EngramAccessTrustZonePromoteResponse, ab as EngramAccessTrustZoneRecordSummary, ac as EngramAccessTrustZoneStatusResponse, ad as EngramAccessWriteEnvelope, ae as EngramAccessWriteResponse, af as shapeMemorySummary } from './access-service-CBNEKjzN.js';
4
4
  import './recall-explain-renderer.js';
5
5
  import './types.js';
6
6
  import './recall-audit-anomaly.js';
7
7
  import './explicit-capture.js';
8
8
  import './cross-namespace-budget.js';
9
9
  import './maintenance/memory-governance.js';
10
- import './orchestrator-DTRQG75J.js';
10
+ import './orchestrator-CqWOjfgl.js';
11
11
  import './live-connectors-runner.js';
12
12
  import './recall-state.js';
13
13
  import './graph-snapshot.js';
@@ -3,20 +3,20 @@ import {
3
3
  EngramAccessInputError,
4
4
  EngramAccessService,
5
5
  shapeMemorySummary
6
- } from "./chunk-2QANQKSQ.js";
7
- import "./chunk-ETUPBUHB.js";
8
- import "./chunk-L227SKTB.js";
9
- import "./chunk-DHGSZ3UD.js";
10
- import "./chunk-BT7NVCML.js";
11
- import "./chunk-OXJBNGBK.js";
6
+ } from "./chunk-ZK32E74R.js";
7
+ import "./chunk-GDASG7NC.js";
8
+ import "./chunk-GDB4J2H3.js";
9
+ import "./chunk-DGNQRNLL.js";
10
+ import "./chunk-PSUB67YB.js";
12
11
  import "./chunk-SOBJ6NEY.js";
12
+ import "./chunk-BT7NVCML.js";
13
13
  import "./chunk-H7XKCNR6.js";
14
- import "./chunk-OI27U2HT.js";
14
+ import "./chunk-5BTCT236.js";
15
15
  import "./chunk-EDQVAMQI.js";
16
16
  import "./chunk-JGSKJHF7.js";
17
- import "./chunk-FXKPZ3H6.js";
18
- import "./chunk-WSGF57U2.js";
19
- import "./chunk-XKIQZXUB.js";
17
+ import "./chunk-BPSGLMQ4.js";
18
+ import "./chunk-JQDZQ4TB.js";
19
+ import "./chunk-CI7RKSRE.js";
20
20
  import "./chunk-UEY3VB6W.js";
21
21
  import "./chunk-EIR5VLIH.js";
22
22
  import "./chunk-7V2SGZ3H.js";
@@ -24,16 +24,16 @@ import "./chunk-EI6V5UXY.js";
24
24
  import "./chunk-QY7YA7OL.js";
25
25
  import "./chunk-NNVTUXEB.js";
26
26
  import "./chunk-QDW3E4RD.js";
27
- import "./chunk-EUML3N6B.js";
28
- import "./chunk-CHCA44C3.js";
27
+ import "./chunk-IMA6GU4Y.js";
28
+ import "./chunk-ODPLEWB6.js";
29
29
  import "./chunk-XL7FK7PJ.js";
30
30
  import "./chunk-2LSZVONP.js";
31
31
  import "./chunk-DEUNUKTD.js";
32
- import "./chunk-QDDHYAKV.js";
33
- import "./chunk-YFS5OEKO.js";
32
+ import "./chunk-AZDOWD2L.js";
33
+ import "./chunk-7MLB4NCL.js";
34
34
  import "./chunk-5UZXUTVO.js";
35
35
  import "./chunk-4H5ZJHEN.js";
36
- import "./chunk-KGK2QKWL.js";
36
+ import "./chunk-4R4KTDIE.js";
37
37
  import "./chunk-RULE4VG5.js";
38
38
  import "./chunk-SCU65EZI.js";
39
39
  import "./chunk-KILOTVIF.js";
@@ -60,9 +60,9 @@ import "./chunk-TVVEYCNW.js";
60
60
  import "./chunk-RFYAYKTD.js";
61
61
  import "./chunk-LBLXEFWK.js";
62
62
  import "./chunk-VFUEZZBS.js";
63
- import "./chunk-KQAFEZQX.js";
63
+ import "./chunk-VDX2J7OX.js";
64
64
  import "./chunk-WEHSQBFR.js";
65
- import "./chunk-X7Y7WX73.js";
65
+ import "./chunk-DQEMWVMT.js";
66
66
  import "./chunk-J4EB7DNW.js";
67
67
  import "./chunk-BJMBJZ2Y.js";
68
68
  import "./chunk-UKJAGEXH.js";
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-6MKAMLQL.js";
5
5
  import {
6
6
  DEFAULT_REASONING_MODEL
7
- } from "./chunk-NZPF2SYV.js";
7
+ } from "./chunk-T7N6KQGS.js";
8
8
  import "./chunk-PHK3HARR.js";
9
9
  import "./chunk-Z5LAYHGJ.js";
10
10
  import "./chunk-4DJQYKMN.js";
@@ -230,11 +230,26 @@ function createActiveRecallEngine(deps, config) {
230
230
  }
231
231
  const cached = cache.get(cacheKey);
232
232
  if (cacheEnabled && cached) {
233
- return {
233
+ const result2 = {
234
234
  ...cloneRecallResult(cached.value),
235
235
  latencyMs: Math.max(0, now() - currentTime),
236
236
  cacheHit: true
237
237
  };
238
+ result2.transcriptPath = null;
239
+ if (config.persistTranscripts) {
240
+ try {
241
+ result2.transcriptPath = await appendActiveRecallTranscript(
242
+ config.transcriptDir,
243
+ input,
244
+ config,
245
+ result2,
246
+ queryBundle
247
+ );
248
+ } catch {
249
+ result2.transcriptPath = null;
250
+ }
251
+ }
252
+ return result2;
238
253
  }
239
254
  const start = currentTime;
240
255
  const recallContext = await deps.recall(queryBundle, input.sessionKey);
@@ -303,9 +318,11 @@ function createActiveRecallEngine(deps, config) {
303
318
  }
304
319
  if (cacheEnabled) {
305
320
  const completedAt = now();
321
+ const cachedValue = cloneRecallResult(result);
322
+ cachedValue.transcriptPath = null;
306
323
  cache.set(cacheKey, {
307
324
  expiresAt: completedAt + config.cacheTtlMs,
308
- value: cloneRecallResult(result)
325
+ value: cachedValue
309
326
  });
310
327
  enforceCacheLimit(cache);
311
328
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/active-recall.ts"],"sourcesContent":["import { appendFile, mkdir } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { DEFAULT_REASONING_MODEL } from \"./config.js\";\nimport { collapseWhitespace, truncateCodePointSafe } from \"./whitespace.js\";\nimport type {\n ActiveRecallChatType,\n ActiveRecallModelFallbackPolicy,\n ActiveRecallPromptStyle,\n ActiveRecallQueryMode,\n ActiveRecallThinking,\n} from \"./types.js\";\n\nexport interface ActiveRecallTurn {\n role: \"user\" | \"assistant\";\n content: string;\n}\n\nexport interface ActiveRecallInput {\n sessionKey: string;\n agentId: string;\n chatType: ActiveRecallChatType;\n recentTurns: ActiveRecallTurn[];\n currentMessage: string;\n}\n\nexport interface ActiveRecallConfig {\n enabled: boolean;\n agents: string[] | null;\n allowedChatTypes: ActiveRecallChatType[];\n queryMode: ActiveRecallQueryMode;\n promptStyle: ActiveRecallPromptStyle;\n customInstruction: string | null;\n promptAppend: string | null;\n maxSummaryChars: number;\n recentUserTurns: number;\n recentAssistantTurns: number;\n recentUserChars: number;\n recentAssistantChars: number;\n thinking: ActiveRecallThinking;\n timeoutMs: number;\n cacheTtlMs: number;\n persistTranscripts: boolean;\n transcriptDir: string;\n entityGraphDepth: number;\n includeCausalTrajectories: boolean;\n includeDaySummary: boolean;\n attachRecallExplain: boolean;\n modelOverride: string | null;\n modelFallbackPolicy: ActiveRecallModelFallbackPolicy;\n}\n\nexport interface ActiveRecallResult {\n summary: string | null;\n citations: Array<{ memoryId: string; relevance: number }>;\n latencyMs: number;\n cacheHit: boolean;\n modelUsed: string;\n transcriptPath: string | null;\n}\n\nexport interface ActiveRecallDependencies {\n recall(query: string, sessionKey: string): Promise<string | null>;\n getLastRecallSnapshot?(sessionKey: string): { memoryIds?: string[] } | null;\n walkEntityGraph?(params: {\n sessionKey: string;\n query: string;\n depth: number;\n }): Promise<string[]>;\n loadCausalTrajectories?(params: {\n sessionKey: string;\n query: string;\n }): Promise<string[]>;\n loadDaySummary?(sessionKey: string): Promise<string | null>;\n explainLastRecall?(sessionKey: string): Promise<string | null>;\n generateSummary?(params: {\n prompt: string;\n sessionKey: string;\n agentId: string;\n model: string;\n timeoutMs: number;\n thinking: ActiveRecallThinking;\n fallbackPolicy: ActiveRecallModelFallbackPolicy;\n }): Promise<{ text: string | null; modelUsed?: string; cacheHit?: boolean }>;\n now?: () => number;\n}\n\ninterface CachedRecallResult {\n expiresAt: number;\n value: ActiveRecallResult;\n}\n\ninterface ActiveRecallTurnWithIndex {\n index: number;\n role: ActiveRecallTurn[\"role\"];\n content: string;\n}\n\nconst ACTIVE_RECALL_CACHE_MAX_ENTRIES = 256;\n\nconst NONE_SET = new Set([\n \"\",\n \"none\",\n \"no_reply\",\n \"nothing useful\",\n \"no relevant memory\",\n \"timeout\",\n \"[]\",\n \"{}\",\n \"null\",\n \"n/a\",\n]);\n\nconst STYLE_INSTRUCTIONS: Record<ActiveRecallPromptStyle, string> = {\n balanced: \"Summarize the most relevant memory context in a compact, neutral way.\",\n strict: \"Only include memory that is directly supported by the retrieved context.\",\n contextual: \"Prefer concise context that helps the next reply stay grounded in recent work.\",\n \"recall-heavy\": \"Bias toward richer recall coverage when multiple retrieved items reinforce each other.\",\n \"precision-heavy\": \"Bias toward precision. Omit anything uncertain or weakly supported.\",\n \"preference-only\": \"Only surface user preference or operating-style memory when present.\",\n};\n\nfunction cloneRecallResult(value: ActiveRecallResult): ActiveRecallResult {\n return {\n ...value,\n citations: [...value.citations],\n };\n}\n\nfunction buildCacheKey(input: ActiveRecallInput, config: ActiveRecallConfig, queryBundle: string): string {\n return JSON.stringify({\n sessionKey: input.sessionKey,\n agentId: input.agentId,\n queryMode: config.queryMode,\n promptStyle: config.promptStyle,\n customInstruction: config.customInstruction,\n promptAppend: config.promptAppend,\n maxSummaryChars: config.maxSummaryChars,\n entityGraphDepth: config.entityGraphDepth,\n includeCausalTrajectories: config.includeCausalTrajectories,\n includeDaySummary: config.includeDaySummary,\n attachRecallExplain: config.attachRecallExplain,\n modelOverride: config.modelOverride,\n modelFallbackPolicy: config.modelFallbackPolicy,\n thinking: config.thinking,\n queryBundle,\n });\n}\n\nfunction pruneExpiredCache(\n cache: Map<string, CachedRecallResult>,\n currentTime: number,\n): void {\n for (const [key, entry] of cache.entries()) {\n if (entry.expiresAt <= currentTime) {\n cache.delete(key);\n }\n }\n}\n\nfunction enforceCacheLimit(cache: Map<string, CachedRecallResult>): void {\n while (cache.size > ACTIVE_RECALL_CACHE_MAX_ENTRIES) {\n const oldestKey = cache.keys().next().value;\n if (typeof oldestKey !== \"string\") {\n break;\n }\n cache.delete(oldestKey);\n }\n}\n\nfunction cropTurns(\n turns: ActiveRecallTurn[],\n role: \"user\" | \"assistant\",\n maxTurns: number,\n maxChars: number,\n): ActiveRecallTurnWithIndex[] {\n if (maxTurns <= 0) {\n return [];\n }\n\n const selected: ActiveRecallTurnWithIndex[] = [];\n for (let index = turns.length - 1; index >= 0 && selected.length < maxTurns; index -= 1) {\n const turn = turns[index];\n if (turn?.role === role) {\n selected.push({\n index,\n role: turn.role,\n content: collapseWhitespace(truncateCodePointSafe(turn.content, maxChars)),\n });\n }\n }\n\n return selected.reverse();\n}\n\nfunction mergeChronologicalTurns(\n userTurns: ActiveRecallTurnWithIndex[],\n assistantTurns: ActiveRecallTurnWithIndex[],\n): ActiveRecallTurnWithIndex[] {\n return [...userTurns, ...assistantTurns]\n .sort((left, right) => left.index - right.index)\n .filter((value) => value.content.length > 0);\n}\n\nexport function buildActiveRecallQueryBundle(\n input: ActiveRecallInput,\n config: ActiveRecallConfig,\n): string {\n if (config.queryMode === \"message\") {\n return collapseWhitespace(input.currentMessage);\n }\n\n const userTurns = cropTurns(\n input.recentTurns,\n \"user\",\n config.recentUserTurns,\n config.recentUserChars,\n );\n const assistantTurns = cropTurns(\n input.recentTurns,\n \"assistant\",\n config.recentAssistantTurns,\n config.recentAssistantChars,\n );\n const mergedTurns = mergeChronologicalTurns(userTurns, assistantTurns);\n\n const parts = [\n ...mergedTurns.map((turn) => `${turn.role}: ${turn.content}`),\n ];\n\n if (config.queryMode === \"full\") {\n return [...parts, `current: ${collapseWhitespace(input.currentMessage)}`]\n .filter((value) => value.trim().length > 0)\n .join(\"\\n\");\n }\n\n return [`current: ${collapseWhitespace(input.currentMessage)}`, ...parts]\n .filter((value) => value.trim().length > 0)\n .join(\"\\n\");\n}\n\nexport function normalizeActiveRecallSummary(value: string | null, maxChars: number): string | null {\n if (value == null) return null;\n const compact = collapseWhitespace(value);\n if (NONE_SET.has(compact.toLowerCase())) return null;\n return truncateCodePointSafe(compact, maxChars);\n}\n\nfunction sanitizeTranscriptPathSegment(value: string): string {\n const normalized = collapseWhitespace(value);\n return encodeURIComponent(normalized.length > 0 ? normalized : \"unknown\").replaceAll(\n \".\",\n \"%2E\",\n );\n}\n\nexport function buildActiveRecallPrompt(params: {\n config: ActiveRecallConfig;\n queryBundle: string;\n recallContext: string | null;\n graphContext: string[];\n causalContext: string[];\n daySummary: string | null;\n recallExplain: string | null;\n}): string {\n const sections = [\n params.config.customInstruction?.trim() || STYLE_INSTRUCTIONS[params.config.promptStyle],\n `Query bundle:\\n${params.queryBundle}`,\n params.recallContext ? `Retrieved memory:\\n${params.recallContext}` : null,\n params.graphContext.length > 0 ? `Entity graph:\\n${params.graphContext.join(\"\\n\")}` : null,\n params.causalContext.length > 0 ? `Causal trajectories:\\n${params.causalContext.join(\"\\n\")}` : null,\n params.daySummary ? `Day summary:\\n${params.daySummary}` : null,\n params.recallExplain ? `Recall explain:\\n${params.recallExplain}` : null,\n params.config.promptAppend?.trim() || null,\n \"Return either NONE or a compact summary grounded only in the supplied context.\",\n ];\n return sections.filter((value): value is string => !!value && value.trim().length > 0).join(\"\\n\\n\");\n}\n\nasync function appendActiveRecallTranscript(\n transcriptRoot: string,\n input: ActiveRecallInput,\n config: ActiveRecallConfig,\n result: ActiveRecallResult,\n queryBundle: string,\n): Promise<string> {\n const date = new Date().toISOString().slice(0, 10);\n const filePath = path.join(\n transcriptRoot,\n \"agents\",\n sanitizeTranscriptPathSegment(input.agentId),\n date,\n `${sanitizeTranscriptPathSegment(input.sessionKey)}.jsonl`,\n );\n await mkdir(path.dirname(filePath), { recursive: true });\n await appendFile(\n filePath,\n `${JSON.stringify({\n ts: new Date().toISOString(),\n sessionKey: input.sessionKey,\n agentId: input.agentId,\n queryMode: config.queryMode,\n promptStyle: config.promptStyle,\n queryBundle,\n summary: result.summary,\n citations: result.citations,\n latencyMs: result.latencyMs,\n cacheHit: result.cacheHit,\n modelUsed: result.modelUsed,\n })}\\n`,\n \"utf8\",\n );\n return filePath;\n}\n\nexport function createActiveRecallEngine(\n deps: ActiveRecallDependencies,\n config: ActiveRecallConfig,\n) {\n const cache = new Map<string, CachedRecallResult>();\n const now = deps.now ?? (() => Date.now());\n\n return {\n async run(input: ActiveRecallInput): Promise<ActiveRecallResult> {\n if (!config.enabled) {\n return {\n summary: null,\n citations: [],\n latencyMs: 0,\n cacheHit: false,\n modelUsed: config.modelOverride ?? \"disabled\",\n transcriptPath: null,\n };\n }\n if (config.agents && !config.agents.includes(input.agentId)) {\n return {\n summary: null,\n citations: [],\n latencyMs: 0,\n cacheHit: false,\n modelUsed: config.modelOverride ?? \"filtered\",\n transcriptPath: null,\n };\n }\n if (!config.allowedChatTypes.includes(input.chatType)) {\n return {\n summary: null,\n citations: [],\n latencyMs: 0,\n cacheHit: false,\n modelUsed: config.modelOverride ?? \"filtered\",\n transcriptPath: null,\n };\n }\n\n const queryBundle = buildActiveRecallQueryBundle(input, config);\n const cacheKey = buildCacheKey(input, config, queryBundle);\n const currentTime = now();\n const cacheEnabled = config.cacheTtlMs > 0;\n if (cacheEnabled) {\n pruneExpiredCache(cache, currentTime);\n }\n const cached = cache.get(cacheKey);\n if (cacheEnabled && cached) {\n return {\n ...cloneRecallResult(cached.value),\n latencyMs: Math.max(0, now() - currentTime),\n cacheHit: true,\n };\n }\n\n const start = currentTime;\n const recallContext = await deps.recall(queryBundle, input.sessionKey);\n const graphContext =\n config.entityGraphDepth > 0 && deps.walkEntityGraph\n ? await deps.walkEntityGraph({\n sessionKey: input.sessionKey,\n query: queryBundle,\n depth: config.entityGraphDepth,\n })\n : [];\n const causalContext =\n config.includeCausalTrajectories && deps.loadCausalTrajectories\n ? await deps.loadCausalTrajectories({\n sessionKey: input.sessionKey,\n query: queryBundle,\n })\n : [];\n const daySummary =\n config.includeDaySummary && deps.loadDaySummary\n ? await deps.loadDaySummary(input.sessionKey)\n : null;\n const recallExplain =\n config.attachRecallExplain && deps.explainLastRecall\n ? await deps.explainLastRecall(input.sessionKey)\n : null;\n const prompt = buildActiveRecallPrompt({\n config,\n queryBundle,\n recallContext,\n graphContext,\n causalContext,\n daySummary,\n recallExplain,\n });\n\n const generated = deps.generateSummary\n ? await deps.generateSummary({\n prompt,\n sessionKey: input.sessionKey,\n agentId: input.agentId,\n model: config.modelOverride ?? DEFAULT_REASONING_MODEL,\n timeoutMs: config.timeoutMs,\n thinking: config.thinking,\n fallbackPolicy: config.modelFallbackPolicy,\n })\n : {\n text: recallContext,\n modelUsed: config.modelOverride ?? DEFAULT_REASONING_MODEL,\n cacheHit: false,\n };\n const summary = normalizeActiveRecallSummary(\n generated.text,\n config.maxSummaryChars,\n );\n const snapshot = deps.getLastRecallSnapshot?.(input.sessionKey);\n const citations = (snapshot?.memoryIds ?? []).map((memoryId, index) => ({\n memoryId,\n relevance: Number((1 / (index + 1)).toFixed(3)),\n }));\n const result: ActiveRecallResult = {\n summary,\n citations,\n latencyMs: Math.max(0, now() - start),\n cacheHit: generated.cacheHit === true,\n modelUsed: generated.modelUsed ?? config.modelOverride ?? DEFAULT_REASONING_MODEL,\n transcriptPath: null,\n };\n if (config.persistTranscripts) {\n try {\n result.transcriptPath = await appendActiveRecallTranscript(\n config.transcriptDir,\n input,\n config,\n result,\n queryBundle,\n );\n } catch {\n result.transcriptPath = null;\n }\n }\n\n if (cacheEnabled) {\n const completedAt = now();\n cache.set(cacheKey, {\n expiresAt: completedAt + config.cacheTtlMs,\n value: cloneRecallResult(result),\n });\n enforceCacheLimit(cache);\n }\n return result;\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,SAAS,YAAY,aAAa;AAClC,OAAO,UAAU;AAgGjB,IAAM,kCAAkC;AAExC,IAAM,WAAW,oBAAI,IAAI;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,IAAM,qBAA8D;AAAA,EAClE,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,mBAAmB;AAAA,EACnB,mBAAmB;AACrB;AAEA,SAAS,kBAAkB,OAA+C;AACxE,SAAO;AAAA,IACL,GAAG;AAAA,IACH,WAAW,CAAC,GAAG,MA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J,YAAM,UAAU;AAAA,QACd,UAAU;AAAA,QACV,OAAO;AAAA,MACT;AACA,YAAM,WAAW,KAAK,wBAAwB,MAAM,UAAU;AAC9D,YAAM,aAAa,UAAU,aAAa,CAAC,GAAG,IAAI,CAAC,UAAU,WAAW;AAAA,QACtE;AAAA,QACA,WAAW,QAAQ,KAAK,QAAQ,IAAI,QAAQ,CAAC,CAAC;AAAA,MAChD,EAAE;AACF,YAAM,SAA6B;AAAA,QACjC;AAAA,QACA;AAAA,QACA,WAAW,KAAK,IAAI,GAAG,IAAI,IAAI,KAAK;AAAA,QACpC,UAAU,UAAU,aAAa;AAAA,QACjC,WAAW,UAAU,aAAa,OAAO,iBAAiB;AAAA,QAC1D,gBAAgB;AAAA,MAClB;AACA,UAAI,OAAO,oBAAoB;AAC7B,YAAI;AACF,iBAAO,iBAAiB,MAAM;AAAA,YAC5B,OAAO;AAAA,YACP;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,QACF,QAAQ;AACN,iBAAO,iBAAiB;AAAA,QAC1B;AAAA,MACF;AAEA,UAAI,cAAc;AAChB,cAAM,cAAc,IAAI;AACxB,cAAM,IAAI,UAAU;AAAA,UAClB,WAAW,cAAc,OAAO;AAAA,UAChC,OAAO,kBAAkB,MAAM;AAAA,QACjC,CAAC;AACD,0BAAkB,KAAK;AAAA,MACzB;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/active-recall.ts"],"sourcesContent":["import { appendFile, mkdir } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { DEFAULT_REASONING_MODEL } from \"./config.js\";\nimport { collapseWhitespace, truncateCodePointSafe } from \"./whitespace.js\";\nimport type {\n ActiveRecallChatType,\n ActiveRecallModelFallbackPolicy,\n ActiveRecallPromptStyle,\n ActiveRecallQueryMode,\n ActiveRecallThinking,\n} from \"./types.js\";\n\nexport interface ActiveRecallTurn {\n role: \"user\" | \"assistant\";\n content: string;\n}\n\nexport interface ActiveRecallInput {\n sessionKey: string;\n agentId: string;\n chatType: ActiveRecallChatType;\n recentTurns: ActiveRecallTurn[];\n currentMessage: string;\n}\n\nexport interface ActiveRecallConfig {\n enabled: boolean;\n agents: string[] | null;\n allowedChatTypes: ActiveRecallChatType[];\n queryMode: ActiveRecallQueryMode;\n promptStyle: ActiveRecallPromptStyle;\n customInstruction: string | null;\n promptAppend: string | null;\n maxSummaryChars: number;\n recentUserTurns: number;\n recentAssistantTurns: number;\n recentUserChars: number;\n recentAssistantChars: number;\n thinking: ActiveRecallThinking;\n timeoutMs: number;\n cacheTtlMs: number;\n persistTranscripts: boolean;\n transcriptDir: string;\n entityGraphDepth: number;\n includeCausalTrajectories: boolean;\n includeDaySummary: boolean;\n attachRecallExplain: boolean;\n modelOverride: string | null;\n modelFallbackPolicy: ActiveRecallModelFallbackPolicy;\n}\n\nexport interface ActiveRecallResult {\n summary: string | null;\n citations: Array<{ memoryId: string; relevance: number }>;\n latencyMs: number;\n cacheHit: boolean;\n modelUsed: string;\n transcriptPath: string | null;\n}\n\nexport interface ActiveRecallDependencies {\n recall(query: string, sessionKey: string): Promise<string | null>;\n getLastRecallSnapshot?(sessionKey: string): { memoryIds?: string[] } | null;\n walkEntityGraph?(params: {\n sessionKey: string;\n query: string;\n depth: number;\n }): Promise<string[]>;\n loadCausalTrajectories?(params: {\n sessionKey: string;\n query: string;\n }): Promise<string[]>;\n loadDaySummary?(sessionKey: string): Promise<string | null>;\n explainLastRecall?(sessionKey: string): Promise<string | null>;\n generateSummary?(params: {\n prompt: string;\n sessionKey: string;\n agentId: string;\n model: string;\n timeoutMs: number;\n thinking: ActiveRecallThinking;\n fallbackPolicy: ActiveRecallModelFallbackPolicy;\n }): Promise<{ text: string | null; modelUsed?: string; cacheHit?: boolean }>;\n now?: () => number;\n}\n\ninterface CachedRecallResult {\n expiresAt: number;\n value: ActiveRecallResult;\n}\n\ninterface ActiveRecallTurnWithIndex {\n index: number;\n role: ActiveRecallTurn[\"role\"];\n content: string;\n}\n\nconst ACTIVE_RECALL_CACHE_MAX_ENTRIES = 256;\n\nconst NONE_SET = new Set([\n \"\",\n \"none\",\n \"no_reply\",\n \"nothing useful\",\n \"no relevant memory\",\n \"timeout\",\n \"[]\",\n \"{}\",\n \"null\",\n \"n/a\",\n]);\n\nconst STYLE_INSTRUCTIONS: Record<ActiveRecallPromptStyle, string> = {\n balanced: \"Summarize the most relevant memory context in a compact, neutral way.\",\n strict: \"Only include memory that is directly supported by the retrieved context.\",\n contextual: \"Prefer concise context that helps the next reply stay grounded in recent work.\",\n \"recall-heavy\": \"Bias toward richer recall coverage when multiple retrieved items reinforce each other.\",\n \"precision-heavy\": \"Bias toward precision. Omit anything uncertain or weakly supported.\",\n \"preference-only\": \"Only surface user preference or operating-style memory when present.\",\n};\n\nfunction cloneRecallResult(value: ActiveRecallResult): ActiveRecallResult {\n return {\n ...value,\n citations: [...value.citations],\n };\n}\n\nfunction buildCacheKey(input: ActiveRecallInput, config: ActiveRecallConfig, queryBundle: string): string {\n return JSON.stringify({\n sessionKey: input.sessionKey,\n agentId: input.agentId,\n queryMode: config.queryMode,\n promptStyle: config.promptStyle,\n customInstruction: config.customInstruction,\n promptAppend: config.promptAppend,\n maxSummaryChars: config.maxSummaryChars,\n entityGraphDepth: config.entityGraphDepth,\n includeCausalTrajectories: config.includeCausalTrajectories,\n includeDaySummary: config.includeDaySummary,\n attachRecallExplain: config.attachRecallExplain,\n modelOverride: config.modelOverride,\n modelFallbackPolicy: config.modelFallbackPolicy,\n thinking: config.thinking,\n queryBundle,\n });\n}\n\nfunction pruneExpiredCache(\n cache: Map<string, CachedRecallResult>,\n currentTime: number,\n): void {\n for (const [key, entry] of cache.entries()) {\n if (entry.expiresAt <= currentTime) {\n cache.delete(key);\n }\n }\n}\n\nfunction enforceCacheLimit(cache: Map<string, CachedRecallResult>): void {\n while (cache.size > ACTIVE_RECALL_CACHE_MAX_ENTRIES) {\n const oldestKey = cache.keys().next().value;\n if (typeof oldestKey !== \"string\") {\n break;\n }\n cache.delete(oldestKey);\n }\n}\n\nfunction cropTurns(\n turns: ActiveRecallTurn[],\n role: \"user\" | \"assistant\",\n maxTurns: number,\n maxChars: number,\n): ActiveRecallTurnWithIndex[] {\n if (maxTurns <= 0) {\n return [];\n }\n\n const selected: ActiveRecallTurnWithIndex[] = [];\n for (let index = turns.length - 1; index >= 0 && selected.length < maxTurns; index -= 1) {\n const turn = turns[index];\n if (turn?.role === role) {\n selected.push({\n index,\n role: turn.role,\n content: collapseWhitespace(truncateCodePointSafe(turn.content, maxChars)),\n });\n }\n }\n\n return selected.reverse();\n}\n\nfunction mergeChronologicalTurns(\n userTurns: ActiveRecallTurnWithIndex[],\n assistantTurns: ActiveRecallTurnWithIndex[],\n): ActiveRecallTurnWithIndex[] {\n return [...userTurns, ...assistantTurns]\n .sort((left, right) => left.index - right.index)\n .filter((value) => value.content.length > 0);\n}\n\nexport function buildActiveRecallQueryBundle(\n input: ActiveRecallInput,\n config: ActiveRecallConfig,\n): string {\n if (config.queryMode === \"message\") {\n return collapseWhitespace(input.currentMessage);\n }\n\n const userTurns = cropTurns(\n input.recentTurns,\n \"user\",\n config.recentUserTurns,\n config.recentUserChars,\n );\n const assistantTurns = cropTurns(\n input.recentTurns,\n \"assistant\",\n config.recentAssistantTurns,\n config.recentAssistantChars,\n );\n const mergedTurns = mergeChronologicalTurns(userTurns, assistantTurns);\n\n const parts = [\n ...mergedTurns.map((turn) => `${turn.role}: ${turn.content}`),\n ];\n\n if (config.queryMode === \"full\") {\n return [...parts, `current: ${collapseWhitespace(input.currentMessage)}`]\n .filter((value) => value.trim().length > 0)\n .join(\"\\n\");\n }\n\n return [`current: ${collapseWhitespace(input.currentMessage)}`, ...parts]\n .filter((value) => value.trim().length > 0)\n .join(\"\\n\");\n}\n\nexport function normalizeActiveRecallSummary(value: string | null, maxChars: number): string | null {\n if (value == null) return null;\n const compact = collapseWhitespace(value);\n if (NONE_SET.has(compact.toLowerCase())) return null;\n return truncateCodePointSafe(compact, maxChars);\n}\n\nfunction sanitizeTranscriptPathSegment(value: string): string {\n const normalized = collapseWhitespace(value);\n return encodeURIComponent(normalized.length > 0 ? normalized : \"unknown\").replaceAll(\n \".\",\n \"%2E\",\n );\n}\n\nexport function buildActiveRecallPrompt(params: {\n config: ActiveRecallConfig;\n queryBundle: string;\n recallContext: string | null;\n graphContext: string[];\n causalContext: string[];\n daySummary: string | null;\n recallExplain: string | null;\n}): string {\n const sections = [\n params.config.customInstruction?.trim() || STYLE_INSTRUCTIONS[params.config.promptStyle],\n `Query bundle:\\n${params.queryBundle}`,\n params.recallContext ? `Retrieved memory:\\n${params.recallContext}` : null,\n params.graphContext.length > 0 ? `Entity graph:\\n${params.graphContext.join(\"\\n\")}` : null,\n params.causalContext.length > 0 ? `Causal trajectories:\\n${params.causalContext.join(\"\\n\")}` : null,\n params.daySummary ? `Day summary:\\n${params.daySummary}` : null,\n params.recallExplain ? `Recall explain:\\n${params.recallExplain}` : null,\n params.config.promptAppend?.trim() || null,\n \"Return either NONE or a compact summary grounded only in the supplied context.\",\n ];\n return sections.filter((value): value is string => !!value && value.trim().length > 0).join(\"\\n\\n\");\n}\n\nasync function appendActiveRecallTranscript(\n transcriptRoot: string,\n input: ActiveRecallInput,\n config: ActiveRecallConfig,\n result: ActiveRecallResult,\n queryBundle: string,\n): Promise<string> {\n const date = new Date().toISOString().slice(0, 10);\n const filePath = path.join(\n transcriptRoot,\n \"agents\",\n sanitizeTranscriptPathSegment(input.agentId),\n date,\n `${sanitizeTranscriptPathSegment(input.sessionKey)}.jsonl`,\n );\n await mkdir(path.dirname(filePath), { recursive: true });\n await appendFile(\n filePath,\n `${JSON.stringify({\n ts: new Date().toISOString(),\n sessionKey: input.sessionKey,\n agentId: input.agentId,\n queryMode: config.queryMode,\n promptStyle: config.promptStyle,\n queryBundle,\n summary: result.summary,\n citations: result.citations,\n latencyMs: result.latencyMs,\n cacheHit: result.cacheHit,\n modelUsed: result.modelUsed,\n })}\\n`,\n \"utf8\",\n );\n return filePath;\n}\n\nexport function createActiveRecallEngine(\n deps: ActiveRecallDependencies,\n config: ActiveRecallConfig,\n) {\n const cache = new Map<string, CachedRecallResult>();\n const now = deps.now ?? (() => Date.now());\n\n return {\n async run(input: ActiveRecallInput): Promise<ActiveRecallResult> {\n if (!config.enabled) {\n return {\n summary: null,\n citations: [],\n latencyMs: 0,\n cacheHit: false,\n modelUsed: config.modelOverride ?? \"disabled\",\n transcriptPath: null,\n };\n }\n if (config.agents && !config.agents.includes(input.agentId)) {\n return {\n summary: null,\n citations: [],\n latencyMs: 0,\n cacheHit: false,\n modelUsed: config.modelOverride ?? \"filtered\",\n transcriptPath: null,\n };\n }\n if (!config.allowedChatTypes.includes(input.chatType)) {\n return {\n summary: null,\n citations: [],\n latencyMs: 0,\n cacheHit: false,\n modelUsed: config.modelOverride ?? \"filtered\",\n transcriptPath: null,\n };\n }\n\n const queryBundle = buildActiveRecallQueryBundle(input, config);\n const cacheKey = buildCacheKey(input, config, queryBundle);\n const currentTime = now();\n const cacheEnabled = config.cacheTtlMs > 0;\n if (cacheEnabled) {\n pruneExpiredCache(cache, currentTime);\n }\n const cached = cache.get(cacheKey);\n if (cacheEnabled && cached) {\n const result: ActiveRecallResult = {\n ...cloneRecallResult(cached.value),\n latencyMs: Math.max(0, now() - currentTime),\n cacheHit: true,\n };\n result.transcriptPath = null;\n if (config.persistTranscripts) {\n try {\n result.transcriptPath = await appendActiveRecallTranscript(\n config.transcriptDir,\n input,\n config,\n result,\n queryBundle,\n );\n } catch {\n result.transcriptPath = null;\n }\n }\n return result;\n }\n\n const start = currentTime;\n const recallContext = await deps.recall(queryBundle, input.sessionKey);\n const graphContext =\n config.entityGraphDepth > 0 && deps.walkEntityGraph\n ? await deps.walkEntityGraph({\n sessionKey: input.sessionKey,\n query: queryBundle,\n depth: config.entityGraphDepth,\n })\n : [];\n const causalContext =\n config.includeCausalTrajectories && deps.loadCausalTrajectories\n ? await deps.loadCausalTrajectories({\n sessionKey: input.sessionKey,\n query: queryBundle,\n })\n : [];\n const daySummary =\n config.includeDaySummary && deps.loadDaySummary\n ? await deps.loadDaySummary(input.sessionKey)\n : null;\n const recallExplain =\n config.attachRecallExplain && deps.explainLastRecall\n ? await deps.explainLastRecall(input.sessionKey)\n : null;\n const prompt = buildActiveRecallPrompt({\n config,\n queryBundle,\n recallContext,\n graphContext,\n causalContext,\n daySummary,\n recallExplain,\n });\n\n const generated = deps.generateSummary\n ? await deps.generateSummary({\n prompt,\n sessionKey: input.sessionKey,\n agentId: input.agentId,\n model: config.modelOverride ?? DEFAULT_REASONING_MODEL,\n timeoutMs: config.timeoutMs,\n thinking: config.thinking,\n fallbackPolicy: config.modelFallbackPolicy,\n })\n : {\n text: recallContext,\n modelUsed: config.modelOverride ?? DEFAULT_REASONING_MODEL,\n cacheHit: false,\n };\n const summary = normalizeActiveRecallSummary(\n generated.text,\n config.maxSummaryChars,\n );\n const snapshot = deps.getLastRecallSnapshot?.(input.sessionKey);\n const citations = (snapshot?.memoryIds ?? []).map((memoryId, index) => ({\n memoryId,\n relevance: Number((1 / (index + 1)).toFixed(3)),\n }));\n const result: ActiveRecallResult = {\n summary,\n citations,\n latencyMs: Math.max(0, now() - start),\n cacheHit: generated.cacheHit === true,\n modelUsed: generated.modelUsed ?? config.modelOverride ?? DEFAULT_REASONING_MODEL,\n transcriptPath: null,\n };\n if (config.persistTranscripts) {\n try {\n result.transcriptPath = await appendActiveRecallTranscript(\n config.transcriptDir,\n input,\n config,\n result,\n queryBundle,\n );\n } catch {\n result.transcriptPath = null;\n }\n }\n\n if (cacheEnabled) {\n const completedAt = now();\n const cachedValue = cloneRecallResult(result);\n cachedValue.transcriptPath = null;\n cache.set(cacheKey, {\n expiresAt: completedAt + config.cacheTtlMs,\n value: cachedValue,\n });\n enforceCacheLimit(cache);\n }\n return result;\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,SAAS,YAAY,aAAa;AAClC,OAAO,UAAU;AAgGjB,IAAM,k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AAAA,YACA;AAAA,UACF;AAAA,QACF,QAAQ;AACN,iBAAO,iBAAiB;AAAA,QAC1B;AAAA,MACF;AAEA,UAAI,cAAc;AAChB,cAAM,cAAc,IAAI;AACxB,cAAM,cAAc,kBAAkB,MAAM;AAC5C,oBAAY,iBAAiB;AAC7B,cAAM,IAAI,UAAU;AAAA,UAClB,WAAW,cAAc,OAAO;AAAA,UAChC,OAAO;AAAA,QACT,CAAC;AACD,0BAAkB,KAAK;AAAA,MACzB;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":["result"]}
@@ -1,7 +1,10 @@
1
1
  import "../chunk-SEDEKFYQ.js";
2
2
  import {
3
3
  AdapterRegistry
4
- } from "../chunk-AU7Q3LSC.js";
4
+ } from "../chunk-2QSZNTDO.js";
5
+ import {
6
+ CodexAdapter
7
+ } from "../chunk-RSUYKGGZ.js";
5
8
  import {
6
9
  HermesAdapter
7
10
  } from "../chunk-42NQ7AVG.js";
@@ -11,9 +14,6 @@ import {
11
14
  import {
12
15
  ClaudeCodeAdapter
13
16
  } from "../chunk-J64TK33U.js";
14
- import {
15
- CodexAdapter
16
- } from "../chunk-RSUYKGGZ.js";
17
17
  import "../chunk-7RXCMVFQ.js";
18
18
  import "../chunk-PZ5AY32C.js";
19
19
  export {
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  AdapterRegistry
3
- } from "../chunk-AU7Q3LSC.js";
3
+ } from "../chunk-2QSZNTDO.js";
4
+ import "../chunk-RSUYKGGZ.js";
4
5
  import "../chunk-42NQ7AVG.js";
5
6
  import "../chunk-TMSXWOBZ.js";
6
7
  import "../chunk-J64TK33U.js";
7
- import "../chunk-RSUYKGGZ.js";
8
8
  import "../chunk-7RXCMVFQ.js";
9
9
  import "../chunk-PZ5AY32C.js";
10
10
  export {
@@ -51,13 +51,12 @@ function aggregateSignalPressure(signals) {
51
51
  return Math.max(-1, Math.min(1, net / signals.length));
52
52
  }
53
53
  function selectRecentSignals(input) {
54
- if (input.learningWindowDays <= 0) return [...input.signals];
55
54
  const nowMs = (input.now ?? /* @__PURE__ */ new Date()).getTime();
56
- const minTs = nowMs - input.learningWindowDays * 864e5;
55
+ const minTs = input.learningWindowDays <= 0 ? Number.NEGATIVE_INFINITY : nowMs - input.learningWindowDays * 864e5;
57
56
  return input.signals.filter((signal) => {
58
57
  const ts = Date.parse(signal.timestamp);
59
58
  if (!Number.isFinite(ts)) return false;
60
- return ts >= minTs;
59
+ return ts >= minTs && ts <= nowMs;
61
60
  });
62
61
  }
63
62
  function parameterDirection(parameter, pressure) {