@remnic/core 9.3.726 → 9.3.728

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 (342) hide show
  1. package/dist/access-boundary.d.ts +5 -5
  2. package/dist/access-boundary.js +22 -22
  3. package/dist/access-cli.js +45 -45
  4. package/dist/access-http.d.ts +20 -5
  5. package/dist/access-http.js +27 -27
  6. package/dist/access-mcp.d.ts +5 -5
  7. package/dist/access-mcp.js +26 -26
  8. package/dist/access-operations-batch.js +23 -23
  9. package/dist/access-operations.d.ts +6 -6
  10. package/dist/access-operations.js +25 -25
  11. package/dist/access-schema.d.ts +4 -4
  12. package/dist/access-schema.js +3 -3
  13. package/dist/{access-service-B2PlPtxh.d.ts → access-service-Bgpjxo4f.d.ts} +36 -4
  14. package/dist/access-service.d.ts +5 -5
  15. package/dist/access-service.js +21 -21
  16. package/dist/access-surface-catalog.d.ts +5 -5
  17. package/dist/action-confidence.d.ts +1 -1
  18. package/dist/active-memory-bridge.d.ts +1 -1
  19. package/dist/active-recall.d.ts +1 -1
  20. package/dist/active-recall.js +3 -3
  21. package/dist/behavior-learner.d.ts +1 -1
  22. package/dist/behavior-signals.d.ts +1 -1
  23. package/dist/bootstrap.d.ts +4 -4
  24. package/dist/briefing.d.ts +1 -1
  25. package/dist/briefing.js +7 -7
  26. package/dist/buffer-surprise-report.d.ts +1 -1
  27. package/dist/buffer.d.ts +1 -1
  28. package/dist/calibration.d.ts +1 -1
  29. package/dist/capabilities.d.ts +44 -2
  30. package/dist/capabilities.js +5 -3
  31. package/dist/{capsule-crypto-GWVG7LGC.js → capsule-crypto-7FJQINUR.js} +2 -2
  32. package/dist/{catalog-CzUb-GyD.d.ts → catalog-bMczlO2G.d.ts} +1 -1
  33. package/dist/causal-behavior.d.ts +1 -1
  34. package/dist/causal-consolidation.d.ts +1 -1
  35. package/dist/causal-consolidation.js +8 -8
  36. package/dist/causal-trajectory-graph.d.ts +1 -1
  37. package/dist/{chunk-OWHERGF2.js → chunk-2NLLXCJG.js} +2 -2
  38. package/dist/{chunk-BIA7ELIB.js → chunk-36SEDFAU.js} +3 -3
  39. package/dist/{chunk-UQSVUEN2.js → chunk-37436GML.js} +2 -2
  40. package/dist/{chunk-DVRHLN2O.js → chunk-3RCBIOOJ.js} +18 -2
  41. package/dist/{chunk-DVRHLN2O.js.map → chunk-3RCBIOOJ.js.map} +1 -1
  42. package/dist/{chunk-RRHHQYJS.js → chunk-3TSTGI6F.js} +2 -2
  43. package/dist/{chunk-5OOA7SGX.js → chunk-4ESAR77N.js} +2 -2
  44. package/dist/{chunk-FO3HO52S.js → chunk-4H4F3BFL.js} +2 -2
  45. package/dist/{chunk-BEUCACTV.js → chunk-4NOI577P.js} +2 -2
  46. package/dist/{chunk-BBIE7W52.js → chunk-4NR2PDZ5.js} +2 -2
  47. package/dist/{chunk-WGTWGDR5.js → chunk-76NHR6ZL.js} +5 -5
  48. package/dist/{chunk-PKMQK2WY.js → chunk-773DPI6T.js} +4 -4
  49. package/dist/{chunk-MQVKHFIU.js → chunk-7RLCCNHU.js} +8 -8
  50. package/dist/{chunk-XGTBNVIU.js → chunk-AAD2ZS6P.js} +11 -1
  51. package/dist/chunk-AAD2ZS6P.js.map +1 -0
  52. package/dist/{chunk-EZNDNMRH.js → chunk-AQLOP5F4.js} +2 -2
  53. package/dist/{chunk-UNNDFYUX.js → chunk-ARV3AUOM.js} +5 -5
  54. package/dist/{chunk-NPL7VDM6.js → chunk-ASKXIAHD.js} +2 -2
  55. package/dist/{chunk-TQQH2FTX.js → chunk-BQCHEV7O.js} +106 -15
  56. package/dist/{chunk-TQQH2FTX.js.map → chunk-BQCHEV7O.js.map} +1 -1
  57. package/dist/{chunk-ZA2S2VLL.js → chunk-C2PG7IEH.js} +5 -2
  58. package/dist/chunk-C2PG7IEH.js.map +1 -0
  59. package/dist/{chunk-K4ZNARDO.js → chunk-CBWI22JN.js} +2 -2
  60. package/dist/{chunk-ZOHMPFOB.js → chunk-CKFLLAIS.js} +3 -3
  61. package/dist/{chunk-JPUT5NGH.js → chunk-DMQWV6SQ.js} +2 -2
  62. package/dist/{chunk-F3XZN24Z.js → chunk-DRUDC2UX.js} +2 -2
  63. package/dist/{chunk-KJR66XOM.js → chunk-EY6MDMHK.js} +2 -2
  64. package/dist/{chunk-3TUT4PWB.js → chunk-FVZ2ISIX.js} +2 -2
  65. package/dist/{chunk-C4X4QGIO.js → chunk-G6NKALRN.js} +5 -2
  66. package/dist/chunk-G6NKALRN.js.map +1 -0
  67. package/dist/{chunk-6SQQOJ4U.js → chunk-GKRLPHPU.js} +2 -2
  68. package/dist/{chunk-PLG6JHQS.js → chunk-H5BWGCRZ.js} +43 -42
  69. package/dist/chunk-H5BWGCRZ.js.map +1 -0
  70. package/dist/{chunk-2NBP25BG.js → chunk-HGNOCPZX.js} +171 -79
  71. package/dist/chunk-HGNOCPZX.js.map +1 -0
  72. package/dist/{chunk-5NWYQUQC.js → chunk-HOHVIVDR.js} +2 -2
  73. package/dist/{chunk-DCKNMLEQ.js → chunk-I5REUWLH.js} +11 -5
  74. package/dist/chunk-I5REUWLH.js.map +1 -0
  75. package/dist/{chunk-6WAJQKBS.js → chunk-JYLFZWUX.js} +2 -2
  76. package/dist/{chunk-5W7CTZ2E.js → chunk-KQAFEZQX.js} +4 -4
  77. package/dist/{chunk-UKTDXTWX.js → chunk-M4AYVEWS.js} +7 -7
  78. package/dist/{chunk-YTZ3VGC7.js → chunk-M4V2JVSZ.js} +2 -2
  79. package/dist/{chunk-TA3Y6GEX.js → chunk-MLKWJOAJ.js} +2 -2
  80. package/dist/{chunk-DQXPJ6HD.js → chunk-O6YH5F47.js} +4 -4
  81. package/dist/{chunk-7AG54AF3.js → chunk-PUR2CKX2.js} +1 -1
  82. package/dist/chunk-PUR2CKX2.js.map +1 -0
  83. package/dist/{chunk-OAHOL3ZC.js → chunk-QNEUZIAH.js} +152 -62
  84. package/dist/chunk-QNEUZIAH.js.map +1 -0
  85. package/dist/{chunk-Q6D75LVH.js → chunk-UM5AWJNQ.js} +79 -17
  86. package/dist/chunk-UM5AWJNQ.js.map +1 -0
  87. package/dist/{chunk-53EEQYE5.js → chunk-UTHQPSRC.js} +8 -8
  88. package/dist/{chunk-BB57OZWC.js → chunk-UVPL565C.js} +2 -2
  89. package/dist/{chunk-6AFVIOVZ.js → chunk-V4GNSDFH.js} +2 -2
  90. package/dist/{chunk-EHISUJFN.js → chunk-WAS3NV46.js} +6 -3
  91. package/dist/chunk-WAS3NV46.js.map +1 -0
  92. package/dist/{chunk-UVYI6VIX.js → chunk-X7Y7WX73.js} +1 -1
  93. package/dist/{chunk-V7CMKMHM.js → chunk-Y4YD5TYW.js} +3 -3
  94. package/dist/{chunk-7NS7AWMZ.js → chunk-YGIQORJ3.js} +3 -3
  95. package/dist/{chunk-MDBZTH7N.js → chunk-YKBHOBJK.js} +44 -10
  96. package/dist/chunk-YKBHOBJK.js.map +1 -0
  97. package/dist/{chunk-3MS3QVX6.js → chunk-YOLZS7NY.js} +2 -2
  98. package/dist/{chunk-6OIDDKAA.js → chunk-YTU7WKYN.js} +35 -9
  99. package/dist/chunk-YTU7WKYN.js.map +1 -0
  100. package/dist/{cli-IOlDHSBT.d.ts → cli-BLME420h.d.ts} +3 -3
  101. package/dist/cli.d.ts +6 -6
  102. package/dist/cli.js +49 -49
  103. package/dist/compat/codex-cli-fallback.d.ts +1 -0
  104. package/dist/compat/codex-cli-fallback.js +22 -0
  105. package/dist/compat/codex-cli-fallback.js.map +1 -0
  106. package/dist/compat/codex-thread-key.d.ts +1 -0
  107. package/dist/compat/codex-thread-key.js +18 -0
  108. package/dist/compat/codex-thread-key.js.map +1 -0
  109. package/dist/compounding/engine.d.ts +1 -1
  110. package/dist/compounding/engine.js +7 -7
  111. package/dist/compounding/preference-consolidator.d.ts +1 -1
  112. package/dist/compression-optimizer.d.ts +1 -1
  113. package/dist/config.d.ts +1 -1
  114. package/dist/config.js +3 -3
  115. package/dist/connectors/codex-materialize-runner.d.ts +1 -1
  116. package/dist/connectors/codex-materialize-runner.js +7 -7
  117. package/dist/connectors/codex-materialize.d.ts +1 -1
  118. package/dist/connectors/index.d.ts +1 -1
  119. package/dist/connectors/index.js +7 -7
  120. package/dist/consolidation-provenance-check.d.ts +1 -1
  121. package/dist/consolidation-undo.d.ts +1 -1
  122. package/dist/contradiction/index.d.ts +1 -1
  123. package/dist/conversation-index/backend.d.ts +1 -1
  124. package/dist/conversation-index/chunker.d.ts +1 -1
  125. package/dist/conversation-index/faiss-adapter.d.ts +1 -1
  126. package/dist/conversation-index/indexer.d.ts +1 -1
  127. package/dist/conversation-index/search.d.ts +1 -1
  128. package/dist/day-summary.d.ts +1 -1
  129. package/dist/delinearize.d.ts +1 -1
  130. package/dist/direct-answer-wiring.d.ts +1 -1
  131. package/dist/direct-answer.d.ts +1 -1
  132. package/dist/embedding-fallback.d.ts +1 -1
  133. package/dist/embedding-fallback.js +2 -1
  134. package/dist/enrichment/index.d.ts +1 -1
  135. package/dist/entity-retrieval.d.ts +1 -1
  136. package/dist/entity-retrieval.js +7 -7
  137. package/dist/entity-schema.d.ts +1 -1
  138. package/dist/explicit-capture.d.ts +4 -4
  139. package/dist/extraction-faithfulness.d.ts +1 -1
  140. package/dist/extraction-faithfulness.js +2 -2
  141. package/dist/extraction-judge-telemetry.d.ts +1 -1
  142. package/dist/extraction-judge-training.d.ts +1 -1
  143. package/dist/extraction-judge.d.ts +1 -1
  144. package/dist/extraction.d.ts +1 -1
  145. package/dist/extraction.js +3 -2
  146. package/dist/faithfulness-config.d.ts +1 -0
  147. package/dist/faithfulness-config.js +1 -1
  148. package/dist/fallback-llm.d.ts +1 -1
  149. package/dist/{first-start-migration-PG5HBC3K.js → first-start-migration-22LPFHD5.js} +6 -2
  150. package/dist/first-start-migration-22LPFHD5.js.map +1 -0
  151. package/dist/graph-dashboard-diff.d.ts +1 -1
  152. package/dist/graph-dashboard-key.d.ts +1 -1
  153. package/dist/graph-dashboard-parser.d.ts +1 -1
  154. package/dist/graph-edge-reinforcement.d.ts +1 -1
  155. package/dist/graph-snapshot.d.ts +1 -1
  156. package/dist/graph.d.ts +1 -1
  157. package/dist/identity-continuity.d.ts +1 -1
  158. package/dist/importance.d.ts +1 -1
  159. package/dist/index.d.ts +9 -9
  160. package/dist/index.js +64 -64
  161. package/dist/intent.d.ts +1 -1
  162. package/dist/lcm/engine.d.ts +1 -1
  163. package/dist/lcm/engine.js +2 -2
  164. package/dist/lcm/index.d.ts +1 -1
  165. package/dist/lcm/index.js +7 -7
  166. package/dist/lcm/tools.d.ts +1 -1
  167. package/dist/lifecycle.d.ts +1 -1
  168. package/dist/live-connectors-runner.d.ts +1 -1
  169. package/dist/local-llm.d.ts +1 -1
  170. package/dist/local-model-endpoint.d.ts +9 -4
  171. package/dist/local-model-endpoint.js +1 -1
  172. package/dist/maintenance/memory-governance.d.ts +1 -1
  173. package/dist/maintenance/memory-governance.js +7 -7
  174. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +7 -7
  175. package/dist/maintenance/rebuild-memory-projection.js +8 -8
  176. package/dist/mcp-memory-inspector-app.d.ts +5 -5
  177. package/dist/memory-action-policy.d.ts +1 -1
  178. package/dist/memory-cache.d.ts +1 -1
  179. package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
  180. package/dist/memory-projection-store.d.ts +1 -1
  181. package/dist/memory-provenance.d.ts +1 -1
  182. package/dist/memory-worth-outcomes.d.ts +1 -1
  183. package/dist/models-json.d.ts +1 -1
  184. package/dist/namespaces/migrate.d.ts +2 -2
  185. package/dist/namespaces/migrate.js +14 -13
  186. package/dist/namespaces/principal.d.ts +1 -1
  187. package/dist/namespaces/search.d.ts +1 -1
  188. package/dist/namespaces/search.js +6 -5
  189. package/dist/namespaces/storage.d.ts +2 -2
  190. package/dist/namespaces/storage.js +7 -7
  191. package/dist/native-knowledge.d.ts +1 -1
  192. package/dist/operator-toolkit.d.ts +1 -1
  193. package/dist/operator-toolkit.js +20 -20
  194. package/dist/orchestration/maintenance.d.ts +2 -2
  195. package/dist/orchestration/maintenance.js +9 -9
  196. package/dist/{orchestrator-C_OMSIMZ.d.ts → orchestrator-DqPAz8ot.d.ts} +3 -3
  197. package/dist/orchestrator.d.ts +4 -4
  198. package/dist/orchestrator.js +33 -33
  199. package/dist/patterns-cli.d.ts +1 -1
  200. package/dist/policy-runtime.d.ts +1 -1
  201. package/dist/provenance.d.ts +1 -1
  202. package/dist/provenance.js +1 -1
  203. package/dist/qmd-recall-cache.d.ts +1 -1
  204. package/dist/qmd.d.ts +1 -1
  205. package/dist/recall-disclosure-escalation.d.ts +1 -1
  206. package/dist/recall-explain-renderer.d.ts +1 -1
  207. package/dist/recall-explain-renderer.js +3 -3
  208. package/dist/recall-planner-llm.d.ts +1 -1
  209. package/dist/recall-state.d.ts +1 -1
  210. package/dist/recall-tag-filter.d.ts +1 -1
  211. package/dist/recall-xray-cli.d.ts +1 -1
  212. package/dist/recall-xray-cli.js +4 -4
  213. package/dist/recall-xray-renderer.d.ts +1 -1
  214. package/dist/recall-xray-renderer.js +3 -3
  215. package/dist/recall-xray.d.ts +1 -1
  216. package/dist/recall-xray.js +2 -2
  217. package/dist/resolve-auth-token.d.ts +1 -1
  218. package/dist/resume-bundles.js +4 -4
  219. package/dist/retrieval-agents.d.ts +1 -1
  220. package/dist/retrieval-tiers.d.ts +1 -1
  221. package/dist/routing/engine.d.ts +1 -1
  222. package/dist/routing/store.d.ts +1 -1
  223. package/dist/search/embed-helper.d.ts +1 -1
  224. package/dist/search/embed-helper.js +2 -1
  225. package/dist/search/factory.d.ts +1 -1
  226. package/dist/search/factory.js +5 -4
  227. package/dist/search/index.d.ts +1 -1
  228. package/dist/search/index.js +9 -8
  229. package/dist/search/lancedb-backend.d.ts +1 -1
  230. package/dist/search/meilisearch-backend.d.ts +1 -1
  231. package/dist/search/noop-backend.d.ts +1 -1
  232. package/dist/search/orama-backend.d.ts +1 -1
  233. package/dist/search/port.d.ts +1 -1
  234. package/dist/search/remote-backend.d.ts +1 -1
  235. package/dist/{semantic-consolidation-B8LiYtvx.d.ts → semantic-consolidation-Cl15ksZy.d.ts} +1 -1
  236. package/dist/semantic-consolidation.d.ts +2 -2
  237. package/dist/semantic-consolidation.js +8 -8
  238. package/dist/semantic-rule-promotion.js +7 -7
  239. package/dist/semantic-rule-verifier.d.ts +1 -1
  240. package/dist/semantic-rule-verifier.js +7 -7
  241. package/dist/session-observer-bands.d.ts +1 -1
  242. package/dist/session-observer-state.d.ts +1 -1
  243. package/dist/shared-context/manager.d.ts +1 -1
  244. package/dist/signal.d.ts +1 -1
  245. package/dist/storage.d.ts +1 -1
  246. package/dist/storage.js +6 -6
  247. package/dist/summarizer.d.ts +1 -1
  248. package/dist/summary-snapshot.d.ts +1 -1
  249. package/dist/temporal-supersession.d.ts +1 -1
  250. package/dist/temporal-validity.d.ts +1 -1
  251. package/dist/threading.d.ts +1 -1
  252. package/dist/tier-migration.d.ts +1 -1
  253. package/dist/tier-routing.d.ts +1 -1
  254. package/dist/topics.d.ts +1 -1
  255. package/dist/transcript.d.ts +1 -1
  256. package/dist/transfer/backup.js +2 -2
  257. package/dist/transfer/capsule-export.js +2 -2
  258. package/dist/transfer/capsule-import.js +2 -2
  259. package/dist/trust-score-stage.d.ts +1 -1
  260. package/dist/trust-score.d.ts +1 -1
  261. package/dist/{types-DmTaqob2.d.ts → types-ChQb9D6s.d.ts} +8 -0
  262. package/dist/types.d.ts +1 -1
  263. package/dist/types.js +1 -1
  264. package/dist/utility-runtime.d.ts +1 -1
  265. package/dist/verified-recall.js +7 -7
  266. package/package.json +26 -2
  267. package/src/access-http.ts +68 -1
  268. package/src/access-service.ts +2 -1
  269. package/src/admin/admin-surfaces.test.ts +289 -0
  270. package/src/admin/admin-surfaces.ts +138 -7
  271. package/src/bitemporal-dedup-backfill.test.ts +294 -0
  272. package/src/capabilities.test.ts +155 -0
  273. package/src/capabilities.ts +91 -0
  274. package/src/chat/chat-engine.test.ts +104 -1
  275. package/src/chat/chat-http.test.ts +119 -1
  276. package/src/chat/chat-http.ts +252 -97
  277. package/src/chat/chat-session.ts +166 -7
  278. package/src/cli.ts +3 -2
  279. package/src/compat/codex-cli-fallback.ts +23 -0
  280. package/src/compat/codex-subpath-aliases.test.ts +93 -0
  281. package/src/compat/codex-thread-key.ts +23 -0
  282. package/src/embedding-fallback.ts +2 -1
  283. package/src/extraction-faithfulness.test.ts +240 -0
  284. package/src/extraction-faithfulness.ts +58 -6
  285. package/src/extraction.ts +7 -3
  286. package/src/faithfulness-config.ts +16 -1
  287. package/src/local-model-endpoint.ts +24 -3
  288. package/src/maintenance/first-start-migration.ts +3 -1
  289. package/src/orchestrator.ts +238 -34
  290. package/src/provenance-extraction.test.ts +266 -0
  291. package/src/provenance.ts +66 -16
  292. package/src/search/embed-helper.ts +3 -2
  293. package/src/types.ts +8 -0
  294. package/dist/chunk-2NBP25BG.js.map +0 -1
  295. package/dist/chunk-6OIDDKAA.js.map +0 -1
  296. package/dist/chunk-7AG54AF3.js.map +0 -1
  297. package/dist/chunk-C4X4QGIO.js.map +0 -1
  298. package/dist/chunk-DCKNMLEQ.js.map +0 -1
  299. package/dist/chunk-EHISUJFN.js.map +0 -1
  300. package/dist/chunk-MDBZTH7N.js.map +0 -1
  301. package/dist/chunk-OAHOL3ZC.js.map +0 -1
  302. package/dist/chunk-PLG6JHQS.js.map +0 -1
  303. package/dist/chunk-Q6D75LVH.js.map +0 -1
  304. package/dist/chunk-XGTBNVIU.js.map +0 -1
  305. package/dist/chunk-ZA2S2VLL.js.map +0 -1
  306. package/dist/first-start-migration-PG5HBC3K.js.map +0 -1
  307. /package/dist/{capsule-crypto-GWVG7LGC.js.map → capsule-crypto-7FJQINUR.js.map} +0 -0
  308. /package/dist/{chunk-OWHERGF2.js.map → chunk-2NLLXCJG.js.map} +0 -0
  309. /package/dist/{chunk-BIA7ELIB.js.map → chunk-36SEDFAU.js.map} +0 -0
  310. /package/dist/{chunk-UQSVUEN2.js.map → chunk-37436GML.js.map} +0 -0
  311. /package/dist/{chunk-RRHHQYJS.js.map → chunk-3TSTGI6F.js.map} +0 -0
  312. /package/dist/{chunk-5OOA7SGX.js.map → chunk-4ESAR77N.js.map} +0 -0
  313. /package/dist/{chunk-FO3HO52S.js.map → chunk-4H4F3BFL.js.map} +0 -0
  314. /package/dist/{chunk-BEUCACTV.js.map → chunk-4NOI577P.js.map} +0 -0
  315. /package/dist/{chunk-BBIE7W52.js.map → chunk-4NR2PDZ5.js.map} +0 -0
  316. /package/dist/{chunk-WGTWGDR5.js.map → chunk-76NHR6ZL.js.map} +0 -0
  317. /package/dist/{chunk-PKMQK2WY.js.map → chunk-773DPI6T.js.map} +0 -0
  318. /package/dist/{chunk-MQVKHFIU.js.map → chunk-7RLCCNHU.js.map} +0 -0
  319. /package/dist/{chunk-EZNDNMRH.js.map → chunk-AQLOP5F4.js.map} +0 -0
  320. /package/dist/{chunk-UNNDFYUX.js.map → chunk-ARV3AUOM.js.map} +0 -0
  321. /package/dist/{chunk-NPL7VDM6.js.map → chunk-ASKXIAHD.js.map} +0 -0
  322. /package/dist/{chunk-K4ZNARDO.js.map → chunk-CBWI22JN.js.map} +0 -0
  323. /package/dist/{chunk-ZOHMPFOB.js.map → chunk-CKFLLAIS.js.map} +0 -0
  324. /package/dist/{chunk-JPUT5NGH.js.map → chunk-DMQWV6SQ.js.map} +0 -0
  325. /package/dist/{chunk-F3XZN24Z.js.map → chunk-DRUDC2UX.js.map} +0 -0
  326. /package/dist/{chunk-KJR66XOM.js.map → chunk-EY6MDMHK.js.map} +0 -0
  327. /package/dist/{chunk-3TUT4PWB.js.map → chunk-FVZ2ISIX.js.map} +0 -0
  328. /package/dist/{chunk-6SQQOJ4U.js.map → chunk-GKRLPHPU.js.map} +0 -0
  329. /package/dist/{chunk-5NWYQUQC.js.map → chunk-HOHVIVDR.js.map} +0 -0
  330. /package/dist/{chunk-6WAJQKBS.js.map → chunk-JYLFZWUX.js.map} +0 -0
  331. /package/dist/{chunk-5W7CTZ2E.js.map → chunk-KQAFEZQX.js.map} +0 -0
  332. /package/dist/{chunk-UKTDXTWX.js.map → chunk-M4AYVEWS.js.map} +0 -0
  333. /package/dist/{chunk-YTZ3VGC7.js.map → chunk-M4V2JVSZ.js.map} +0 -0
  334. /package/dist/{chunk-TA3Y6GEX.js.map → chunk-MLKWJOAJ.js.map} +0 -0
  335. /package/dist/{chunk-DQXPJ6HD.js.map → chunk-O6YH5F47.js.map} +0 -0
  336. /package/dist/{chunk-53EEQYE5.js.map → chunk-UTHQPSRC.js.map} +0 -0
  337. /package/dist/{chunk-BB57OZWC.js.map → chunk-UVPL565C.js.map} +0 -0
  338. /package/dist/{chunk-6AFVIOVZ.js.map → chunk-V4GNSDFH.js.map} +0 -0
  339. /package/dist/{chunk-UVYI6VIX.js.map → chunk-X7Y7WX73.js.map} +0 -0
  340. /package/dist/{chunk-V7CMKMHM.js.map → chunk-Y4YD5TYW.js.map} +0 -0
  341. /package/dist/{chunk-7NS7AWMZ.js.map → chunk-YGIQORJ3.js.map} +0 -0
  342. /package/dist/{chunk-3MS3QVX6.js.map → chunk-YOLZS7NY.js.map} +0 -0
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-ZFXCQPNO.js";
5
5
  import {
6
6
  StorageManager
7
- } from "./chunk-MQVKHFIU.js";
7
+ } from "./chunk-7RLCCNHU.js";
8
8
  import {
9
9
  MutationSerializer
10
10
  } from "./chunk-LTJAMRGI.js";
@@ -336,4 +336,4 @@ export {
336
336
  resolveNamespaceStorageRoot,
337
337
  NamespaceStorageRouter
338
338
  };
339
- //# sourceMappingURL=chunk-RRHHQYJS.js.map
339
+ //# sourceMappingURL=chunk-3TSTGI6F.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  EngramAccessInputError
3
- } from "./chunk-Q6D75LVH.js";
3
+ } from "./chunk-UM5AWJNQ.js";
4
4
  import {
5
5
  expandTildePath
6
6
  } from "./chunk-EYIEWJNI.js";
@@ -130,4 +130,4 @@ export {
130
130
  listRegisteredOperations,
131
131
  __resetRegistryForTest
132
132
  };
133
- //# sourceMappingURL=chunk-5OOA7SGX.js.map
133
+ //# sourceMappingURL=chunk-4ESAR77N.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  StorageManager
3
- } from "./chunk-MQVKHFIU.js";
3
+ } from "./chunk-7RLCCNHU.js";
4
4
 
5
5
  // src/semantic-rule-promotion.ts
6
6
  import { createHash, randomUUID } from "crypto";
@@ -529,4 +529,4 @@ export {
529
529
  setSemanticRulePromotionTestHooks,
530
530
  promoteSemanticRuleFromMemory
531
531
  };
532
- //# sourceMappingURL=chunk-FO3HO52S.js.map
532
+ //# sourceMappingURL=chunk-4H4F3BFL.js.map
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-TBBDFYXW.js";
4
4
  import {
5
5
  StorageManager
6
- } from "./chunk-MQVKHFIU.js";
6
+ } from "./chunk-7RLCCNHU.js";
7
7
  import {
8
8
  assertPathInsideRoot
9
9
  } from "./chunk-5GPPACXK.js";
@@ -751,4 +751,4 @@ export {
751
751
  listMemoryGovernanceRuns,
752
752
  readMemoryGovernanceRunArtifact
753
753
  };
754
- //# sourceMappingURL=chunk-BEUCACTV.js.map
754
+ //# sourceMappingURL=chunk-4NOI577P.js.map
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-UFS7OXGL.js";
5
5
  import {
6
6
  StorageManager
7
- } from "./chunk-MQVKHFIU.js";
7
+ } from "./chunk-7RLCCNHU.js";
8
8
  import {
9
9
  parseContinuityImprovementLoops
10
10
  } from "./chunk-LDXUBPMO.js";
@@ -1261,4 +1261,4 @@ export {
1261
1261
  defaultTierMigrationCycleBudget,
1262
1262
  CompoundingEngine
1263
1263
  };
1264
- //# sourceMappingURL=chunk-BBIE7W52.js.map
1264
+ //# sourceMappingURL=chunk-4NR2PDZ5.js.map
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  memoryStoreRequestSchema
3
- } from "./chunk-3TUT4PWB.js";
3
+ } from "./chunk-FVZ2ISIX.js";
4
4
  import {
5
5
  defineOperation
6
- } from "./chunk-5OOA7SGX.js";
6
+ } from "./chunk-4ESAR77N.js";
7
7
  import {
8
8
  DECISION_SUBCOMMANDS,
9
9
  DELTA_SUBCOMMANDS,
10
10
  EngramAccessInputError,
11
11
  isCodegraphToolName
12
- } from "./chunk-Q6D75LVH.js";
12
+ } from "./chunk-UM5AWJNQ.js";
13
13
  import {
14
14
  CorrectionContractError
15
- } from "./chunk-EZNDNMRH.js";
15
+ } from "./chunk-AQLOP5F4.js";
16
16
 
17
17
  // src/access-operations.ts
18
18
  import { z } from "zod";
@@ -465,4 +465,4 @@ export {
465
465
  codegraphIngestTracesOperation,
466
466
  REGISTERED_OPERATIONS
467
467
  };
468
- //# sourceMappingURL=chunk-WGTWGDR5.js.map
468
+ //# sourceMappingURL=chunk-76NHR6ZL.js.map
@@ -1,3 +1,6 @@
1
+ import {
2
+ LcmDag
3
+ } from "./chunk-7N4KAIGN.js";
1
4
  import {
2
5
  LcmWorkQueue
3
6
  } from "./chunk-TPDBFYEG.js";
@@ -14,9 +17,6 @@ import {
14
17
  import {
15
18
  LcmArchive
16
19
  } from "./chunk-HW5EF6LV.js";
17
- import {
18
- LcmDag
19
- } from "./chunk-7N4KAIGN.js";
20
20
  import {
21
21
  log
22
22
  } from "./chunk-NU3CSQ4H.js";
@@ -513,4 +513,4 @@ export {
513
513
  extractLcmConfig,
514
514
  LcmEngine
515
515
  };
516
- //# sourceMappingURL=chunk-PKMQK2WY.js.map
516
+ //# sourceMappingURL=chunk-773DPI6T.js.map
@@ -1,12 +1,12 @@
1
- import {
2
- WEARABLES_DIR_NAME,
3
- isValidTranscriptDate
4
- } from "./chunk-M7XQSUBB.js";
5
1
  import {
6
2
  TombstoneStore,
7
3
  buildRetiredFactTombstoneInputs,
8
4
  collectRetiredMemoriesForRebuild
9
5
  } from "./chunk-L2B3EE7B.js";
6
+ import {
7
+ WEARABLES_DIR_NAME,
8
+ isValidTranscriptDate
9
+ } from "./chunk-M7XQSUBB.js";
10
10
  import {
11
11
  isErrnoCode
12
12
  } from "./chunk-5UZXUTVO.js";
@@ -27,7 +27,7 @@ import {
27
27
  import {
28
28
  SPECULATIVE_TTL_DAYS,
29
29
  confidenceTier
30
- } from "./chunk-7AG54AF3.js";
30
+ } from "./chunk-PUR2CKX2.js";
31
31
  import {
32
32
  getCachedEntities,
33
33
  invalidateAllForDir,
@@ -64,7 +64,7 @@ import {
64
64
  import {
65
65
  parseFaithfulnessField,
66
66
  serializeFaithfulnessFields
67
- } from "./chunk-6OIDDKAA.js";
67
+ } from "./chunk-YTU7WKYN.js";
68
68
  import {
69
69
  isConsolidationOperator,
70
70
  isValidDerivedFromEntry
@@ -98,7 +98,7 @@ import {
98
98
  parseProvenanceTag,
99
99
  reconcileProvenanceRead,
100
100
  serializeProvenanceFields
101
- } from "./chunk-MDBZTH7N.js";
101
+ } from "./chunk-YKBHOBJK.js";
102
102
  import {
103
103
  sanitizeMemoryContent
104
104
  } from "./chunk-5GKPFL3S.js";
@@ -5866,4 +5866,4 @@ export {
5866
5866
  serializeEntityFile,
5867
5867
  StorageManager
5868
5868
  };
5869
- //# sourceMappingURL=chunk-MQVKHFIU.js.map
5869
+ //# sourceMappingURL=chunk-7RLCCNHU.js.map
@@ -15,6 +15,15 @@ async function callOpenAiCompatibleChat(endpoint, messages, options, fetchImpl =
15
15
  const url = joinBaseUrl(endpoint.baseUrl, "/chat/completions");
16
16
  const controller = new AbortController();
17
17
  const timer = setTimeout(() => controller.abort(), options.timeoutMs);
18
+ const batchSignal = options.signal;
19
+ const onBatchAbort = () => controller.abort();
20
+ if (batchSignal) {
21
+ if (batchSignal.aborted) {
22
+ controller.abort();
23
+ } else {
24
+ batchSignal.addEventListener("abort", onBatchAbort, { once: true });
25
+ }
26
+ }
18
27
  try {
19
28
  const body = {
20
29
  model: endpoint.model,
@@ -45,6 +54,7 @@ async function callOpenAiCompatibleChat(endpoint, messages, options, fetchImpl =
45
54
  return { content, modelUsed: extractModel(parsed) ?? endpoint.model };
46
55
  } finally {
47
56
  clearTimeout(timer);
57
+ if (batchSignal) batchSignal.removeEventListener("abort", onBatchAbort);
48
58
  }
49
59
  }
50
60
  function joinBaseUrl(base, path) {
@@ -76,4 +86,4 @@ export {
76
86
  resolveCorrectionIntentEndpoint,
77
87
  callOpenAiCompatibleChat
78
88
  };
79
- //# sourceMappingURL=chunk-XGTBNVIU.js.map
89
+ //# sourceMappingURL=chunk-AAD2ZS6P.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/local-model-endpoint.ts"],"sourcesContent":["/**\n * Local fine-tuned model endpoint resolver + openai-compatible caller\n * (issue #1585 model-lab integration).\n *\n * Remnic's two classification workloads — the extraction faithfulness gate\n * (#1576) and passive-correction intent detection (#1581) — can run on small\n * fine-tuned models served locally (Ollama / vLLM) instead of prompted\n * frontier LLMs. The model-lab (`model-lab/`) produces those models; this\n * module is the config-side half: it resolves the optional local endpoint\n * pointer from config and, when set, makes a minimal openai-compatible\n * chat-completions call to it.\n *\n * Design:\n * - **Pointers are optional.** Empty defaults preserve the existing routing\n * chain exactly (rule 39 / byte-identical pre-feature). A resolver returns\n * `null` when the pointer is unset, so callers short-circuit before any\n * network.\n * - **Graceful degradation.** A local-endpoint failure (network, non-2xx,\n * malformed body, timeout) returns `null`; callers fall back to the\n * configured chain (checklist §4 — never block writes on a classifier).\n * - **No inline casts.** The fetch JSON is narrowed with `in` / `typeof`\n * guards (project rule: never assert a shape to read one property).\n * - **Injectable fetch.** `callOpenAiCompatibleChat` takes an optional\n * `fetchImpl` so the caller is unit-testable without a live server.\n */\n\nimport type { PluginConfig } from \"./types.js\";\n\n/** A resolved local endpoint: where to call + which model to name. */\nexport interface LocalModelEndpoint {\n /** Base URL, e.g. `http://localhost:11434/v1` (no trailing slash required). */\n baseUrl: string;\n /** Model name the server expects, e.g. `remnic-faithfulness-gate-v1`. */\n model: string;\n}\n\n/** A chat message in the openai-compatible shape this caller sends. */\nexport interface EndpointChatMessage {\n role: \"system\" | \"user\" | \"assistant\";\n content: string;\n}\n\n/** Options for a single local-endpoint chat call. */\nexport interface EndpointChatOptions {\n /** Per-call timeout in ms. Bounds each attempt so one slow server can't\n * starve the batch (matches the local-LLM precedent). */\n timeoutMs: number;\n /** Optional batch AbortSignal forwarded into the probe (issue #1700 nit #5).\n * When the batch budget elapses (or the caller aborts), the in-flight probe\n * aborts immediately instead of waiting for its own `timeoutMs` — a\n * micro-optimization, not a correctness fix (the outer race already bounds\n * the total). Undefined preserves the prior per-attempt-only behavior. */\n signal?: AbortSignal;\n /** Sampling temperature — classification wants low entropy (0.0–0.2). */\n temperature?: number;\n /** Max output tokens. */\n maxTokens?: number;\n /** Request JSON-object output (the gate emits a JSON verdict array). */\n responseFormatJson?: boolean;\n}\n\n/** Result of a local-endpoint chat call. */\nexport interface EndpointChatResult {\n content: string;\n /** The model the server reports it used (falls back to the requested name). */\n modelUsed: string;\n}\n\n/**\n * Resolve the faithfulness-gate local endpoint from config (issue #1585).\n *\n * Returns the endpoint only when BOTH a base URL and a model name are\n * configured; otherwise `null` (gate uses its existing routing chain). The\n * gate's verifier needs a model identity, so a base URL alone is intentionally\n * insufficient — silently calling whatever the server's default model is would\n * be an unreviewed behavioral change.\n */\nexport function resolveFaithfulnessGateEndpoint(\n config: Pick<PluginConfig, \"extractionFaithfulnessModel\" | \"extractionFaithfulnessBaseUrl\">,\n): LocalModelEndpoint | null {\n const baseUrl = config.extractionFaithfulnessBaseUrl.trim();\n const model = config.extractionFaithfulnessModel.trim();\n if (!baseUrl || !model) return null;\n return { baseUrl, model };\n}\n\n/**\n * Resolve the correction-intent local endpoint from config (issue #1581/#1585).\n *\n * Same contract as the gate resolver. Consumption by the model-backed\n * detector is the consuming child's job — the rule-based\n * `detectPassiveCorrections` remains the default path; this pointer lets a\n * future model-backed detector route to a fine-tuned local classifier when an\n * operator configures one.\n */\nexport function resolveCorrectionIntentEndpoint(\n config: Pick<PluginConfig, \"correctionIntentModel\" | \"correctionIntentBaseUrl\">,\n): LocalModelEndpoint | null {\n const baseUrl = config.correctionIntentBaseUrl.trim();\n const model = config.correctionIntentModel.trim();\n if (!baseUrl || !model) return null;\n return { baseUrl, model };\n}\n\ntype FetchLike = typeof fetch;\n\n/**\n * Make an openai-compatible chat-completions call to a local endpoint.\n *\n * POSTs to `${baseUrl}/chat/completions` with `{ model, messages, ... }` and\n * returns the first choice's content. Any failure (non-2xx, network error,\n * malformed body, timeout) returns `null` so callers fall back gracefully.\n *\n * The response is narrowed with runtime guards — never an unchecked cast — so\n * a surprising server response fails closed (`null`) rather than reading a\n * fabricated field.\n */\nexport async function callOpenAiCompatibleChat(\n endpoint: LocalModelEndpoint,\n messages: EndpointChatMessage[],\n options: EndpointChatOptions,\n fetchImpl: FetchLike = fetch,\n): Promise<EndpointChatResult | null> {\n const url = joinBaseUrl(endpoint.baseUrl, \"/chat/completions\");\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), options.timeoutMs);\n // Forward the batch AbortSignal into the probe (issue #1700 nit #5): if the\n // batch budget already elapsed, abort the in-flight probe immediately rather\n // than waiting for the probe's own timeoutMs. AbortSignal.any is ES2024\n // (forbidden here); wire the listener manually + guard the already-aborted\n // case. The fetch still uses the probe's controller, so clearing the timer\n // below is the only cleanup needed.\n const batchSignal = options.signal;\n const onBatchAbort = () => controller.abort();\n if (batchSignal) {\n if (batchSignal.aborted) {\n controller.abort();\n } else {\n batchSignal.addEventListener(\"abort\", onBatchAbort, { once: true });\n }\n }\n try {\n const body: Record<string, unknown> = {\n model: endpoint.model,\n messages,\n temperature: options.temperature ?? 0.1,\n };\n if (typeof options.maxTokens === \"number\") {\n body.max_tokens = options.maxTokens;\n }\n if (options.responseFormatJson) {\n body.response_format = { type: \"json_object\" };\n }\n let response: Response;\n try {\n response = await fetchImpl(url, {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify(body),\n signal: controller.signal,\n });\n } catch {\n // Network error or abort — fail closed, let the caller fall back.\n return null;\n }\n if (!response.ok) return null;\n const parsed: unknown = await response.json().catch(() => null);\n const content = extractFirstChoiceContent(parsed);\n if (content === null) return null;\n return { content, modelUsed: extractModel(parsed) ?? endpoint.model };\n } finally {\n clearTimeout(timer);\n if (batchSignal) batchSignal.removeEventListener(\"abort\", onBatchAbort);\n }\n}\n\n/** Join a base URL and a path, tolerating a trailing slash on the base. */\nfunction joinBaseUrl(base: string, path: string): string {\n return base.endsWith(\"/\") ? `${base.slice(0, -1)}${path}` : `${base}${path}`;\n}\n\n/**\n * Narrow the openai-compatible response and pull the first choice's content.\n *\n * `in` / `typeof` guards only — no `as` cast (project rule). Returns `null`\n * for any shape that isn't `{ choices: [{ message: { content: string } }, …] }`.\n */\nfunction extractFirstChoiceContent(data: unknown): string | null {\n if (!data || typeof data !== \"object\") return null;\n // After `in`, TS narrows the property to `unknown` — read it directly, no cast.\n if (!(\"choices\" in data) || !Array.isArray(data.choices)) return null;\n const choices: unknown[] = data.choices;\n for (const choice of choices) {\n if (!choice || typeof choice !== \"object\") continue;\n if (!(\"message\" in choice)) continue;\n const message = choice.message;\n if (!message || typeof message !== \"object\") continue;\n if (!(\"content\" in message)) continue;\n const content = message.content;\n if (typeof content === \"string\" && content.length > 0) return content;\n }\n return null;\n}\n\n/** Narrow the `model` field from the response (best-effort, may be absent). */\nfunction extractModel(data: unknown): string | null {\n if (!data || typeof data !== \"object\" || !(\"model\" in data)) return null;\n const model = data.model;\n return typeof model === \"string\" && model.length > 0 ? model : null;\n}\n"],"mappings":"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","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  enqueuePassiveCorrectionNotification
3
- } from "./chunk-KJR66XOM.js";
3
+ } from "./chunk-EY6MDMHK.js";
4
4
  import {
5
5
  stripAttributesSuffix
6
6
  } from "./chunk-SVOZFLIQ.js";
@@ -1794,4 +1794,4 @@ export {
1794
1794
  capturePassiveCorrections,
1795
1795
  clusterByKey
1796
1796
  };
1797
- //# sourceMappingURL=chunk-EZNDNMRH.js.map
1797
+ //# sourceMappingURL=chunk-AQLOP5F4.js.map
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  createVersion
3
3
  } from "./chunk-VF4XKTX3.js";
4
- import {
5
- decryptCapsuleFileInMemory,
6
- isEncryptedCapsuleFile
7
- } from "./chunk-UVYI6VIX.js";
8
4
  import {
9
5
  parseExportBundle
10
6
  } from "./chunk-WEHSQBFR.js";
7
+ import {
8
+ decryptCapsuleFileInMemory,
9
+ isEncryptedCapsuleFile
10
+ } from "./chunk-X7Y7WX73.js";
11
11
  import {
12
12
  assertIsDirectoryNotSymlink,
13
13
  assertRealpathInsideRoot,
@@ -227,4 +227,4 @@ function mintForkId(capsuleId, originalId, now) {
227
227
  export {
228
228
  importCapsule
229
229
  };
230
- //# sourceMappingURL=chunk-UNNDFYUX.js.map
230
+ //# sourceMappingURL=chunk-ARV3AUOM.js.map
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-ZBJMUXZH.js";
8
8
  import {
9
9
  StorageManager
10
- } from "./chunk-MQVKHFIU.js";
10
+ } from "./chunk-7RLCCNHU.js";
11
11
  import {
12
12
  getCachedEpisodeMap,
13
13
  setCachedEpisodeMap
@@ -107,4 +107,4 @@ export {
107
107
  compareVerifiedEpisodeResults,
108
108
  searchVerifiedEpisodes
109
109
  };
110
- //# sourceMappingURL=chunk-NPL7VDM6.js.map
110
+ //# sourceMappingURL=chunk-ASKXIAHD.js.map
@@ -9,13 +9,13 @@ import {
9
9
  } from "./chunk-T4WDJPEZ.js";
10
10
  import {
11
11
  validateRequest
12
- } from "./chunk-3TUT4PWB.js";
12
+ } from "./chunk-FVZ2ISIX.js";
13
13
  import {
14
14
  getOperation
15
- } from "./chunk-5OOA7SGX.js";
15
+ } from "./chunk-4ESAR77N.js";
16
16
  import {
17
17
  EngramAccessInputError
18
- } from "./chunk-Q6D75LVH.js";
18
+ } from "./chunk-UM5AWJNQ.js";
19
19
  import {
20
20
  readEnvVar
21
21
  } from "./chunk-JUC24CTX.js";
@@ -796,7 +796,8 @@ The plan/apply pipeline is pending. Inspection tools are fully functional.`
796
796
  }
797
797
 
798
798
  // src/chat/chat-session.ts
799
- import { mkdir, readFile, appendFile, readdir, stat, unlink } from "fs/promises";
799
+ import { mkdir, readFile, appendFile, readdir, stat, unlink, open } from "fs/promises";
800
+ import { constants as fsConstants } from "fs";
800
801
  import { join } from "path";
801
802
  import { randomUUID } from "crypto";
802
803
  var CHAT_DIR_NAME = "state/chat";
@@ -812,6 +813,12 @@ function chatSessionFile(memoryDir, chatSessionId) {
812
813
  }
813
814
  return join(chatSessionDir(memoryDir), `${chatSessionId}.jsonl`);
814
815
  }
816
+ var lastTranscriptSeq = 0;
817
+ function nextTranscriptSeq() {
818
+ const now = Date.now();
819
+ lastTranscriptSeq = now > lastTranscriptSeq ? now : lastTranscriptSeq + 1;
820
+ return lastTranscriptSeq;
821
+ }
815
822
  async function createChatSession(memoryDir, opts) {
816
823
  const id = randomUUID();
817
824
  const now = (/* @__PURE__ */ new Date()).toISOString();
@@ -896,6 +903,11 @@ async function loadChatSession(memoryDir, chatSessionId) {
896
903
  } catch {
897
904
  }
898
905
  }
906
+ for (const e of transcript) {
907
+ if (typeof e.seq === "number" && e.seq + 1 > lastTranscriptSeq) {
908
+ lastTranscriptSeq = e.seq + 1;
909
+ }
910
+ }
899
911
  return {
900
912
  id: chatSessionId,
901
913
  principal,
@@ -909,18 +921,68 @@ async function loadChatSession(memoryDir, chatSessionId) {
909
921
  };
910
922
  }
911
923
  async function appendTranscriptEntry(memoryDir, chatSessionId, entry) {
924
+ const filePath = chatSessionFile(memoryDir, chatSessionId);
912
925
  const full = {
913
926
  ...entry,
914
- seq: Date.now(),
927
+ seq: nextTranscriptSeq(),
915
928
  ts: (/* @__PURE__ */ new Date()).toISOString()
916
929
  };
917
- await appendFile(
918
- chatSessionFile(memoryDir, chatSessionId),
919
- JSON.stringify(full) + "\n",
920
- "utf8"
921
- );
930
+ let fh;
931
+ try {
932
+ fh = await open(filePath, fsConstants.O_APPEND | fsConstants.O_WRONLY);
933
+ } catch (err) {
934
+ if (err instanceof Error && err.code === "ENOENT") {
935
+ throw new Error("chat_session_expired");
936
+ }
937
+ throw err;
938
+ }
939
+ try {
940
+ await fh.appendFile(JSON.stringify(full) + "\n", "utf8");
941
+ } finally {
942
+ await fh.close();
943
+ }
944
+ try {
945
+ await stat(filePath);
946
+ } catch (err) {
947
+ if (err instanceof Error && err.code === "ENOENT") {
948
+ throw new Error("chat_session_expired");
949
+ }
950
+ throw err;
951
+ }
952
+ notifyTranscriptListeners(memoryDir, chatSessionId, full);
922
953
  return full;
923
954
  }
955
+ var transcriptListeners = /* @__PURE__ */ new Map();
956
+ function transcriptListenerKey(memoryDir, chatSessionId) {
957
+ return `${memoryDir}\0${chatSessionId}`;
958
+ }
959
+ function notifyTranscriptListeners(memoryDir, chatSessionId, entry) {
960
+ const set = transcriptListeners.get(transcriptListenerKey(memoryDir, chatSessionId));
961
+ if (!set) return;
962
+ for (const fn of set) {
963
+ try {
964
+ fn(entry);
965
+ } catch {
966
+ }
967
+ }
968
+ }
969
+ function subscribeChatTranscript(memoryDir, chatSessionId, listener) {
970
+ const key = transcriptListenerKey(memoryDir, chatSessionId);
971
+ let set = transcriptListeners.get(key);
972
+ if (!set) {
973
+ set = /* @__PURE__ */ new Set();
974
+ transcriptListeners.set(key, set);
975
+ }
976
+ set.add(listener);
977
+ return () => {
978
+ const current = transcriptListeners.get(key);
979
+ if (!current) return;
980
+ current.delete(listener);
981
+ if (current.size === 0) {
982
+ transcriptListeners.delete(key);
983
+ }
984
+ };
985
+ }
924
986
  async function markPendingPlan(memoryDir, chatSessionId, planId) {
925
987
  await appendTranscriptEntry(memoryDir, chatSessionId, {
926
988
  role: "system",
@@ -945,6 +1007,36 @@ async function markPromotionResolved(memoryDir, chatSessionId, memoryId) {
945
1007
  content: `promotion_applied:${memoryId}`
946
1008
  });
947
1009
  }
1010
+ async function cleanupExpiredChatSessions(memoryDir, ttlHours) {
1011
+ const dir = chatSessionDir(memoryDir);
1012
+ let files;
1013
+ try {
1014
+ files = await readdir(dir);
1015
+ } catch {
1016
+ return 0;
1017
+ }
1018
+ const now = Date.now();
1019
+ let removed = 0;
1020
+ for (const file of files) {
1021
+ if (!file.endsWith(".jsonl")) continue;
1022
+ try {
1023
+ const filePath = join(dir, file);
1024
+ const st = await stat(filePath);
1025
+ const ageHours = (now - st.mtimeMs) / (1e3 * 60 * 60);
1026
+ if (ttlHours <= 0 || ageHours >= ttlHours) {
1027
+ if (ttlHours > 0) {
1028
+ const fresh = await stat(filePath);
1029
+ const freshAge = (Date.now() - fresh.mtimeMs) / (1e3 * 60 * 60);
1030
+ if (freshAge < ttlHours) continue;
1031
+ }
1032
+ await unlink(filePath);
1033
+ removed++;
1034
+ }
1035
+ } catch {
1036
+ }
1037
+ }
1038
+ return removed;
1039
+ }
948
1040
  function sessionBelongsToPrincipal(session, principal) {
949
1041
  if (!session.principal) return true;
950
1042
  return session.principal === principal;
@@ -3521,11 +3613,10 @@ export {
3521
3613
  createChatSession,
3522
3614
  loadChatSession,
3523
3615
  appendTranscriptEntry,
3524
- markPendingPlan,
3525
- markPendingPromotion,
3526
- markPlanResolved,
3527
- markPromotionResolved,
3616
+ subscribeChatTranscript,
3617
+ cleanupExpiredChatSessions,
3528
3618
  sessionBelongsToPrincipal,
3619
+ processChatMessage,
3529
3620
  EngramMcpServer
3530
3621
  };
3531
- //# sourceMappingURL=chunk-TQQH2FTX.js.map
3622
+ //# sourceMappingURL=chunk-BQCHEV7O.js.map