@remnic/core 9.45.5 → 9.46.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (402) hide show
  1. package/dist/access-admin-ops-surface.d.ts +10 -10
  2. package/dist/access-admin-ops-surface.js +24 -24
  3. package/dist/access-authorization-probe.d.ts +10 -10
  4. package/dist/access-authorization-probe.js +25 -25
  5. package/dist/access-boundary.d.ts +10 -10
  6. package/dist/access-boundary.js +24 -24
  7. package/dist/access-cli.js +73 -71
  8. package/dist/access-cli.js.map +1 -1
  9. package/dist/access-coding-context-resolution.d.ts +1 -1
  10. package/dist/access-extraction-force-flush.d.ts +10 -10
  11. package/dist/access-extraction-force-flush.js +24 -24
  12. package/dist/access-health-types.d.ts +1 -1
  13. package/dist/access-http-lcm-compaction.d.ts +10 -10
  14. package/dist/access-http-lifecycle-flush.d.ts +10 -10
  15. package/dist/access-http-offline-stream.d.ts +10 -10
  16. package/dist/access-http-query.js +24 -24
  17. package/dist/access-http.d.ts +10 -10
  18. package/dist/access-http.js +31 -31
  19. package/dist/access-identity-continuity-surface.d.ts +8 -8
  20. package/dist/access-identity-continuity-surface.js +24 -24
  21. package/dist/access-lcm-surface.d.ts +10 -10
  22. package/dist/access-lcm-surface.js +24 -24
  23. package/dist/access-mcp.d.ts +10 -10
  24. package/dist/access-mcp.js +28 -28
  25. package/dist/access-memory-search-fanout.d.ts +2 -2
  26. package/dist/{access-namespace-preflight-CWUDwB4M.d.ts → access-namespace-preflight--H6HwN85.d.ts} +1 -1
  27. package/dist/access-namespace-preflight.d.ts +3 -3
  28. package/dist/access-namespace-preflight.js +24 -24
  29. package/dist/access-observe-write-surface.d.ts +10 -10
  30. package/dist/access-observe-write-surface.js +24 -24
  31. package/dist/access-offline-manifest.d.ts +8 -8
  32. package/dist/access-operations-batch.js +25 -25
  33. package/dist/access-operations.d.ts +13 -13
  34. package/dist/access-operations.js +27 -27
  35. package/dist/access-recall-concurrency.d.ts +10 -10
  36. package/dist/access-recall-concurrency.js +24 -24
  37. package/dist/access-recall-response.d.ts +10 -10
  38. package/dist/access-recall-response.js +24 -24
  39. package/dist/access-recall-surface.d.ts +10 -10
  40. package/dist/access-recall-surface.js +24 -24
  41. package/dist/access-schema.d.ts +84 -84
  42. package/dist/access-service-helpers.d.ts +10 -10
  43. package/dist/{access-service-CNN89xyn.d.ts → access-service-loJadYd7.d.ts} +7 -7
  44. package/dist/access-service.d.ts +10 -10
  45. package/dist/access-service.js +24 -24
  46. package/dist/access-surface-catalog.d.ts +10 -10
  47. package/dist/access-wearables-meetings-surface.d.ts +3 -3
  48. package/dist/action-confidence.d.ts +1 -1
  49. package/dist/active-memory-bridge.d.ts +1 -1
  50. package/dist/active-recall.d.ts +1 -1
  51. package/dist/ambient-provenance.d.ts +109 -0
  52. package/dist/ambient-provenance.js +22 -0
  53. package/dist/ambient-provenance.js.map +1 -0
  54. package/dist/{auto-sync-UPTUVE4X.js → auto-sync-7O6RP2RT.js} +3 -2
  55. package/dist/{auto-sync-UPTUVE4X.js.map → auto-sync-7O6RP2RT.js.map} +1 -1
  56. package/dist/behavior-learner.d.ts +1 -1
  57. package/dist/behavior-signals.d.ts +1 -1
  58. package/dist/bootstrap.d.ts +8 -8
  59. package/dist/briefing.d.ts +2 -2
  60. package/dist/briefing.js +5 -5
  61. package/dist/buffer-surprise-report.d.ts +1 -1
  62. package/dist/buffer-turn-helpers.d.ts +1 -1
  63. package/dist/buffer-turn-helpers.js +1 -1
  64. package/dist/buffer.d.ts +2 -2
  65. package/dist/buffer.js +2 -2
  66. package/dist/bulk-import/index.d.ts +3 -3
  67. package/dist/calibration.d.ts +1 -1
  68. package/dist/capabilities.d.ts +1 -1
  69. package/dist/{catalog-bctMURhN.d.ts → catalog-Iwbk9h5E.d.ts} +1 -1
  70. package/dist/causal-behavior.d.ts +1 -1
  71. package/dist/causal-consolidation.d.ts +1 -1
  72. package/dist/causal-consolidation.js +6 -6
  73. package/dist/causal-trajectory-graph.d.ts +1 -1
  74. package/dist/{chunk-LEPOP46W.js → chunk-227UFSEQ.js} +4 -4
  75. package/dist/{chunk-ER7W6H4T.js → chunk-2AD5SXO4.js} +5 -2
  76. package/dist/chunk-2AD5SXO4.js.map +1 -0
  77. package/dist/{chunk-CX4ZUMC6.js → chunk-2DSUT7DZ.js} +9 -9
  78. package/dist/{chunk-DZPFMQZ7.js → chunk-3S63QIFQ.js} +1 -1
  79. package/dist/chunk-3S63QIFQ.js.map +1 -0
  80. package/dist/{chunk-DAJPRXBR.js → chunk-47J4EDGR.js} +5 -5
  81. package/dist/{chunk-QVJPH7SH.js → chunk-5LRDM4R7.js} +40 -40
  82. package/dist/{chunk-XAGYS7X6.js → chunk-5R6S4DJZ.js} +7 -7
  83. package/dist/{chunk-QR6G5KF4.js → chunk-5VQPZ4GV.js} +3 -3
  84. package/dist/{chunk-E5XQIWAL.js → chunk-64BHFFKZ.js} +2 -2
  85. package/dist/{chunk-GRUYA45P.js → chunk-6H744ZBH.js} +3 -3
  86. package/dist/{chunk-6ISC4AVB.js → chunk-BDNL34CT.js} +2 -2
  87. package/dist/{chunk-GQL52GQ5.js → chunk-CDKHKZL5.js} +15 -12
  88. package/dist/chunk-CDKHKZL5.js.map +1 -0
  89. package/dist/{chunk-AC5OWJLV.js → chunk-E4FOAENZ.js} +4 -4
  90. package/dist/{chunk-UW66OZTD.js → chunk-FULKGK7P.js} +2 -2
  91. package/dist/{chunk-V2TNYF6Q.js → chunk-HJ3SVHUW.js} +3 -3
  92. package/dist/{chunk-A4IJCD2Z.js → chunk-HXXTXLKA.js} +2 -2
  93. package/dist/{chunk-FUCYDRE5.js → chunk-IDE5AR5W.js} +11 -11
  94. package/dist/{chunk-2FSTB6BJ.js → chunk-ILBLZ5Y5.js} +2 -2
  95. package/dist/chunk-J7T4MX7P.js +131 -0
  96. package/dist/chunk-J7T4MX7P.js.map +1 -0
  97. package/dist/{chunk-WZ3TOIDW.js → chunk-JFO5QZ7N.js} +2 -2
  98. package/dist/{chunk-FR27HBBA.js → chunk-KA47C7BF.js} +2 -2
  99. package/dist/{chunk-JZH4LWHB.js → chunk-KMWYZTIE.js} +2 -2
  100. package/dist/{chunk-LPYDOLSM.js → chunk-L7G72WY4.js} +2 -2
  101. package/dist/{chunk-AMAUBUKY.js → chunk-LI7OE7G6.js} +2 -2
  102. package/dist/{chunk-MO4HSXHZ.js → chunk-M2INOSTA.js} +2 -2
  103. package/dist/{chunk-GODSPTOT.js → chunk-M32URQXV.js} +652 -601
  104. package/dist/chunk-M32URQXV.js.map +1 -0
  105. package/dist/{chunk-HFPASSFV.js → chunk-P2OTGMTR.js} +2 -2
  106. package/dist/{chunk-W2V7UESE.js → chunk-PFJXPOD4.js} +2 -2
  107. package/dist/{chunk-R3KHKU7M.js → chunk-PKCLQ7KM.js} +43 -143
  108. package/dist/chunk-PKCLQ7KM.js.map +1 -0
  109. package/dist/chunk-QW27DOHG.js +84 -0
  110. package/dist/chunk-QW27DOHG.js.map +1 -0
  111. package/dist/{chunk-QUENPGWZ.js → chunk-RCU25Z66.js} +24 -24
  112. package/dist/{chunk-QUENPGWZ.js.map → chunk-RCU25Z66.js.map} +1 -1
  113. package/dist/{chunk-NEF7LR5J.js → chunk-RVPTS4U5.js} +2 -2
  114. package/dist/{chunk-W3IC7QOY.js → chunk-RVYVMQK4.js} +3 -3
  115. package/dist/{chunk-GUAL4PQH.js → chunk-ST5IEK3H.js} +2 -2
  116. package/dist/{chunk-O4KMGRXE.js → chunk-SXWHN7GC.js} +2 -2
  117. package/dist/{chunk-RNHVVMFN.js → chunk-T6JRMVOV.js} +2 -2
  118. package/dist/{chunk-5QJQHBLE.js → chunk-U6JGQ37L.js} +2 -2
  119. package/dist/{chunk-UV72DEZD.js → chunk-UYUYZ4WY.js} +36 -10
  120. package/dist/chunk-UYUYZ4WY.js.map +1 -0
  121. package/dist/{chunk-HC3PBX23.js → chunk-V5FE3UAI.js} +2 -2
  122. package/dist/{chunk-ERZ2R42X.js → chunk-W2ZSNIBP.js} +2 -2
  123. package/dist/{chunk-3COYXTGM.js → chunk-WHWDBTCJ.js} +2 -2
  124. package/dist/{chunk-FIK3CQNA.js → chunk-WOC6DXP5.js} +3 -3
  125. package/dist/{chunk-4FBVAGV3.js → chunk-XBMJ35IP.js} +2 -2
  126. package/dist/{chunk-GFCVUY6G.js → chunk-YWCOJOUI.js} +2 -2
  127. package/dist/{chunk-2X2T2UVE.js → chunk-ZDAYWJV6.js} +1 -1
  128. package/dist/chunk-ZDAYWJV6.js.map +1 -0
  129. package/dist/{cli-BHBswmUa.d.ts → cli-D_RcqXfZ.d.ts} +5 -5
  130. package/dist/cli.d.ts +12 -12
  131. package/dist/cli.js +50 -50
  132. package/dist/compat/checks.js +1 -1
  133. package/dist/compounding/engine.d.ts +2 -2
  134. package/dist/compounding/engine.js +5 -5
  135. package/dist/compounding/preference-consolidator.d.ts +1 -1
  136. package/dist/compression-optimizer.d.ts +1 -1
  137. package/dist/config.d.ts +1 -1
  138. package/dist/connectors/codex-materialize-runner.d.ts +1 -1
  139. package/dist/connectors/codex-materialize-runner.js +5 -5
  140. package/dist/connectors/codex-materialize.d.ts +1 -1
  141. package/dist/connectors/index.d.ts +1 -1
  142. package/dist/connectors/index.js +5 -5
  143. package/dist/consolidation-provenance-check.d.ts +2 -2
  144. package/dist/consolidation-undo.d.ts +2 -2
  145. package/dist/contradiction/index.d.ts +2 -2
  146. package/dist/converge-config.d.ts +1 -1
  147. package/dist/convergence-refresh.d.ts +2 -2
  148. package/dist/convergence-refresh.js +7 -7
  149. package/dist/conversation-index/backend.d.ts +1 -1
  150. package/dist/conversation-index/backend.js +2 -2
  151. package/dist/conversation-index/chunker.d.ts +1 -1
  152. package/dist/conversation-index/faiss-adapter.d.ts +1 -1
  153. package/dist/conversation-index/indexer.d.ts +1 -1
  154. package/dist/conversation-index/search.d.ts +1 -1
  155. package/dist/corpus-watermark.d.ts +1 -1
  156. package/dist/corpus-watermark.js +13 -13
  157. package/dist/day-summary.d.ts +1 -1
  158. package/dist/delinearize.d.ts +1 -1
  159. package/dist/direct-answer-wiring.d.ts +1 -1
  160. package/dist/direct-answer.d.ts +1 -1
  161. package/dist/embedding-fallback.d.ts +1 -1
  162. package/dist/enrichment/index.d.ts +1 -1
  163. package/dist/entity-retrieval.d.ts +2 -2
  164. package/dist/entity-retrieval.js +5 -5
  165. package/dist/entity-schema.d.ts +1 -1
  166. package/dist/explicit-capture.d.ts +8 -8
  167. package/dist/external-wiki-access.d.ts +10 -10
  168. package/dist/external-wiki-access.js +25 -25
  169. package/dist/external-wiki-collection-registration.d.ts +1 -1
  170. package/dist/external-wiki-collection.d.ts +1 -1
  171. package/dist/external-wiki-mcp-tools.d.ts +10 -10
  172. package/dist/extraction-error-classification.d.ts +1 -1
  173. package/dist/extraction-faithfulness.d.ts +1 -1
  174. package/dist/extraction-judge-telemetry.d.ts +1 -1
  175. package/dist/extraction-judge-training.d.ts +1 -1
  176. package/dist/extraction-judge.d.ts +1 -1
  177. package/dist/extraction-liveness.d.ts +1 -1
  178. package/dist/extraction-prompt.d.ts +36 -0
  179. package/dist/extraction-prompt.js +16 -0
  180. package/dist/extraction-prompt.js.map +1 -0
  181. package/dist/extraction-source-grounding-rules.d.ts +1 -1
  182. package/dist/extraction-source-grounding.d.ts +1 -1
  183. package/dist/extraction.d.ts +6 -14
  184. package/dist/extraction.js +9 -7
  185. package/dist/fallback-llm.d.ts +1 -1
  186. package/dist/graph-dashboard-diff.d.ts +1 -1
  187. package/dist/graph-dashboard-key.d.ts +1 -1
  188. package/dist/graph-dashboard-parser.d.ts +1 -1
  189. package/dist/graph-edge-reinforcement.d.ts +1 -1
  190. package/dist/graph-snapshot.d.ts +1 -1
  191. package/dist/graph.d.ts +1 -1
  192. package/dist/importance.d.ts +1 -1
  193. package/dist/importers/index.d.ts +1 -1
  194. package/dist/in-flight-reads.d.ts +1 -1
  195. package/dist/index.d.ts +699 -696
  196. package/dist/index.js +124 -122
  197. package/dist/intent.d.ts +1 -1
  198. package/dist/lcm/engine.d.ts +1 -1
  199. package/dist/lcm/index.d.ts +1 -1
  200. package/dist/lcm/tools.d.ts +1 -1
  201. package/dist/lifecycle.d.ts +1 -1
  202. package/dist/live-connectors-runner.d.ts +1 -1
  203. package/dist/local-llm.d.ts +1 -1
  204. package/dist/local-model-endpoint.d.ts +1 -1
  205. package/dist/maintenance/memory-governance.d.ts +1 -1
  206. package/dist/maintenance/memory-governance.js +5 -5
  207. package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +2 -2
  208. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +5 -5
  209. package/dist/maintenance/rebuild-memory-projection.d.ts +2 -2
  210. package/dist/maintenance/rebuild-memory-projection.js +6 -6
  211. package/dist/{maintenance-CoRikzIt.d.ts → maintenance-DQrL93Uu.d.ts} +3 -3
  212. package/dist/mcp-memory-inspector-app.d.ts +10 -10
  213. package/dist/memory-action-policy.d.ts +1 -1
  214. package/dist/memory-cache.d.ts +1 -1
  215. package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
  216. package/dist/memory-projection-store.d.ts +1 -1
  217. package/dist/memory-provenance.d.ts +1 -1
  218. package/dist/memory-snapshot.d.ts +1 -1
  219. package/dist/memory-worth-outcomes.d.ts +2 -2
  220. package/dist/models-json.d.ts +1 -1
  221. package/dist/namespaces/migrate.d.ts +3 -3
  222. package/dist/namespaces/migrate.js +12 -12
  223. package/dist/namespaces/principal.d.ts +1 -1
  224. package/dist/namespaces/search.d.ts +1 -1
  225. package/dist/namespaces/search.js +6 -6
  226. package/dist/namespaces/storage.d.ts +3 -3
  227. package/dist/namespaces/storage.js +5 -5
  228. package/dist/native-knowledge.d.ts +1 -1
  229. package/dist/offline-sync-impression-drain.d.ts +1 -1
  230. package/dist/operator-doctor-corpus.d.ts +1 -1
  231. package/dist/operator-doctor-corpus.js +14 -14
  232. package/dist/operator-doctor-replica.d.ts +1 -1
  233. package/dist/operator-toolkit.d.ts +3 -3
  234. package/dist/operator-toolkit.js +18 -18
  235. package/dist/orchestration/compression-guideline-coordinator.d.ts +2 -2
  236. package/dist/orchestration/maintenance.d.ts +4 -4
  237. package/dist/orchestration/maintenance.js +10 -10
  238. package/dist/{orchestrator-BJeq7Pw1.d.ts → orchestrator-LPGegii3.d.ts} +8 -8
  239. package/dist/orchestrator.d.ts +8 -8
  240. package/dist/orchestrator.js +73 -71
  241. package/dist/patterns-cli.d.ts +1 -1
  242. package/dist/{pipeline-CNjY4wk3.d.ts → pipeline-1h2GpiHP.d.ts} +1 -1
  243. package/dist/policy-runtime.d.ts +1 -1
  244. package/dist/proactive-contention.d.ts +1 -1
  245. package/dist/provenance.d.ts +1 -1
  246. package/dist/{qmd-C0UDZidt.d.ts → qmd-UdwoF71D.d.ts} +1 -1
  247. package/dist/qmd-preflight.d.ts +2 -2
  248. package/dist/qmd-recall-cache.d.ts +1 -1
  249. package/dist/qmd.d.ts +2 -2
  250. package/dist/recall-concurrency-config.d.ts +1 -1
  251. package/dist/recall-disclosure-escalation.d.ts +1 -1
  252. package/dist/recall-explain-renderer.d.ts +1 -1
  253. package/dist/recall-explain-renderer.js +3 -3
  254. package/dist/recall-memory-map.d.ts +1 -1
  255. package/dist/recall-planner-llm.d.ts +1 -1
  256. package/dist/recall-state.d.ts +1 -1
  257. package/dist/recall-tag-filter.d.ts +1 -1
  258. package/dist/recall-timings.d.ts +1 -1
  259. package/dist/recall-xray-cli.d.ts +1 -1
  260. package/dist/recall-xray-cli.js +4 -4
  261. package/dist/recall-xray-renderer.d.ts +1 -1
  262. package/dist/recall-xray-renderer.js +3 -3
  263. package/dist/recall-xray.d.ts +1 -1
  264. package/dist/recall-xray.js +2 -2
  265. package/dist/reconcile/cursor.d.ts +1 -1
  266. package/dist/reconcile/manifest.d.ts +1 -1
  267. package/dist/reconcile/plan.d.ts +1 -1
  268. package/dist/replay/normalizers/chatgpt.d.ts +1 -1
  269. package/dist/replay/normalizers/claude.d.ts +1 -1
  270. package/dist/replay/normalizers/openclaw.d.ts +1 -1
  271. package/dist/replay/normalizers/shared.d.ts +1 -1
  272. package/dist/replay/runner.d.ts +1 -1
  273. package/dist/replay/types.d.ts +1 -1
  274. package/dist/replica-divergence.d.ts +1 -1
  275. package/dist/replica-peers-config.d.ts +1 -1
  276. package/dist/resolve-auth-token.d.ts +1 -1
  277. package/dist/retrieval-agents.d.ts +2 -2
  278. package/dist/retrieval-tiers.d.ts +1 -1
  279. package/dist/routing/engine.d.ts +1 -1
  280. package/dist/routing/store.d.ts +1 -1
  281. package/dist/salvage-envelope.d.ts +1 -1
  282. package/dist/schemas.d.ts +76 -76
  283. package/dist/{scope-profiles-BJzp2F5A.d.ts → scope-profiles-APjhSe-w.d.ts} +1 -1
  284. package/dist/sdk-compat.js.map +1 -1
  285. package/dist/search/embed-helper.d.ts +1 -1
  286. package/dist/search/factory.d.ts +1 -1
  287. package/dist/search/factory.js +5 -5
  288. package/dist/search/index.d.ts +1 -1
  289. package/dist/search/index.js +9 -9
  290. package/dist/search/lancedb-backend.d.ts +1 -1
  291. package/dist/search/meilisearch-backend.d.ts +1 -1
  292. package/dist/search/noop-backend.d.ts +1 -1
  293. package/dist/search/orama-backend.d.ts +1 -1
  294. package/dist/search/port.d.ts +1 -1
  295. package/dist/search/remote-backend.d.ts +1 -1
  296. package/dist/{semantic-consolidation-D4KAZO2G.d.ts → semantic-consolidation-CrySDbk3.d.ts} +1 -1
  297. package/dist/semantic-consolidation.d.ts +2 -2
  298. package/dist/semantic-consolidation.js +6 -6
  299. package/dist/semantic-rule-promotion.js +5 -5
  300. package/dist/semantic-rule-verifier.d.ts +1 -1
  301. package/dist/semantic-rule-verifier.js +5 -5
  302. package/dist/{service-DWC4tq7p.d.ts → service-DJ0LDyuN.d.ts} +2 -2
  303. package/dist/session-observer-bands.d.ts +1 -1
  304. package/dist/session-observer-state.d.ts +1 -1
  305. package/dist/shared-context/manager.d.ts +9 -9
  306. package/dist/signal.d.ts +1 -1
  307. package/dist/source-agent-qualifier.d.ts +4 -1
  308. package/dist/source-agent-qualifier.js +6 -6
  309. package/dist/{storage-DPGjB-8e.d.ts → storage-y340tYKb.d.ts} +1 -1
  310. package/dist/storage.d.ts +2 -2
  311. package/dist/storage.js +4 -4
  312. package/dist/summarizer.d.ts +1 -1
  313. package/dist/summary-snapshot.d.ts +1 -1
  314. package/dist/temporal-supersession.d.ts +2 -2
  315. package/dist/temporal-timeline-recall.d.ts +1 -1
  316. package/dist/temporal-validity.d.ts +1 -1
  317. package/dist/threading.d.ts +1 -1
  318. package/dist/tier-migration.d.ts +2 -2
  319. package/dist/tier-routing.d.ts +1 -1
  320. package/dist/topics.d.ts +1 -1
  321. package/dist/transcript.d.ts +1 -1
  322. package/dist/transfer/types.d.ts +66 -66
  323. package/dist/trust-score-stage.d.ts +1 -1
  324. package/dist/trust-score.d.ts +1 -1
  325. package/dist/{types-yX_FwERf.d.ts → types-D_Au9qJO.d.ts} +13 -2
  326. package/dist/types.d.ts +1 -1
  327. package/dist/types.js +1 -1
  328. package/dist/utility-runtime.d.ts +1 -1
  329. package/dist/verified-recall.js +5 -5
  330. package/dist/write-envelope.d.ts +1 -1
  331. package/package.json +2 -12
  332. package/src/ambient-provenance.test.ts +510 -0
  333. package/src/ambient-provenance.ts +229 -0
  334. package/src/buffer-turn-helpers.ts +17 -1
  335. package/src/compat/checks.test.ts +45 -1
  336. package/src/compat/checks.ts +16 -16
  337. package/src/extraction-prompt.ts +142 -0
  338. package/src/extraction.ts +37 -148
  339. package/src/meetings/memory-gen.test.ts +51 -0
  340. package/src/meetings/memory-gen.ts +36 -8
  341. package/src/meetings/summary-extractor.ts +4 -2
  342. package/src/orchestration/recall-internal.ts +5 -148
  343. package/src/orchestration/recall-profile-storage.ts +194 -0
  344. package/src/orchestration/recall-search-pipeline.ts +13 -182
  345. package/src/orchestration/recall-search-prefilter.ts +254 -0
  346. package/src/orchestration/session-context.ts +1 -1
  347. package/src/orchestrator.ts +1 -1
  348. package/src/sdk-compat.ts +2 -4
  349. package/src/source-agent-qualifier.ts +3 -0
  350. package/src/testing/subjects/recall-profile-storage.test.ts +362 -0
  351. package/src/testing/subjects/recall-search-prefilter.test.ts +365 -0
  352. package/src/types.ts +2 -2
  353. package/src/wearables/memory-gen.test.ts +82 -0
  354. package/src/wearables/memory-gen.ts +54 -5
  355. package/src/wearables/trust.ts +19 -2
  356. package/dist/chunk-2X2T2UVE.js.map +0 -1
  357. package/dist/chunk-DZPFMQZ7.js.map +0 -1
  358. package/dist/chunk-ER7W6H4T.js.map +0 -1
  359. package/dist/chunk-GODSPTOT.js.map +0 -1
  360. package/dist/chunk-GQL52GQ5.js.map +0 -1
  361. package/dist/chunk-R3KHKU7M.js.map +0 -1
  362. package/dist/chunk-UV72DEZD.js.map +0 -1
  363. package/dist/legacy-hook-compat.d.ts +0 -3
  364. package/dist/legacy-hook-compat.js +0 -36
  365. package/dist/legacy-hook-compat.js.map +0 -1
  366. package/src/legacy-hook-compat.test.ts +0 -20
  367. package/src/legacy-hook-compat.ts +0 -45
  368. /package/dist/{chunk-LEPOP46W.js.map → chunk-227UFSEQ.js.map} +0 -0
  369. /package/dist/{chunk-CX4ZUMC6.js.map → chunk-2DSUT7DZ.js.map} +0 -0
  370. /package/dist/{chunk-DAJPRXBR.js.map → chunk-47J4EDGR.js.map} +0 -0
  371. /package/dist/{chunk-QVJPH7SH.js.map → chunk-5LRDM4R7.js.map} +0 -0
  372. /package/dist/{chunk-XAGYS7X6.js.map → chunk-5R6S4DJZ.js.map} +0 -0
  373. /package/dist/{chunk-QR6G5KF4.js.map → chunk-5VQPZ4GV.js.map} +0 -0
  374. /package/dist/{chunk-E5XQIWAL.js.map → chunk-64BHFFKZ.js.map} +0 -0
  375. /package/dist/{chunk-GRUYA45P.js.map → chunk-6H744ZBH.js.map} +0 -0
  376. /package/dist/{chunk-6ISC4AVB.js.map → chunk-BDNL34CT.js.map} +0 -0
  377. /package/dist/{chunk-AC5OWJLV.js.map → chunk-E4FOAENZ.js.map} +0 -0
  378. /package/dist/{chunk-UW66OZTD.js.map → chunk-FULKGK7P.js.map} +0 -0
  379. /package/dist/{chunk-V2TNYF6Q.js.map → chunk-HJ3SVHUW.js.map} +0 -0
  380. /package/dist/{chunk-A4IJCD2Z.js.map → chunk-HXXTXLKA.js.map} +0 -0
  381. /package/dist/{chunk-FUCYDRE5.js.map → chunk-IDE5AR5W.js.map} +0 -0
  382. /package/dist/{chunk-2FSTB6BJ.js.map → chunk-ILBLZ5Y5.js.map} +0 -0
  383. /package/dist/{chunk-WZ3TOIDW.js.map → chunk-JFO5QZ7N.js.map} +0 -0
  384. /package/dist/{chunk-FR27HBBA.js.map → chunk-KA47C7BF.js.map} +0 -0
  385. /package/dist/{chunk-JZH4LWHB.js.map → chunk-KMWYZTIE.js.map} +0 -0
  386. /package/dist/{chunk-LPYDOLSM.js.map → chunk-L7G72WY4.js.map} +0 -0
  387. /package/dist/{chunk-AMAUBUKY.js.map → chunk-LI7OE7G6.js.map} +0 -0
  388. /package/dist/{chunk-MO4HSXHZ.js.map → chunk-M2INOSTA.js.map} +0 -0
  389. /package/dist/{chunk-HFPASSFV.js.map → chunk-P2OTGMTR.js.map} +0 -0
  390. /package/dist/{chunk-W2V7UESE.js.map → chunk-PFJXPOD4.js.map} +0 -0
  391. /package/dist/{chunk-NEF7LR5J.js.map → chunk-RVPTS4U5.js.map} +0 -0
  392. /package/dist/{chunk-W3IC7QOY.js.map → chunk-RVYVMQK4.js.map} +0 -0
  393. /package/dist/{chunk-GUAL4PQH.js.map → chunk-ST5IEK3H.js.map} +0 -0
  394. /package/dist/{chunk-O4KMGRXE.js.map → chunk-SXWHN7GC.js.map} +0 -0
  395. /package/dist/{chunk-RNHVVMFN.js.map → chunk-T6JRMVOV.js.map} +0 -0
  396. /package/dist/{chunk-5QJQHBLE.js.map → chunk-U6JGQ37L.js.map} +0 -0
  397. /package/dist/{chunk-HC3PBX23.js.map → chunk-V5FE3UAI.js.map} +0 -0
  398. /package/dist/{chunk-ERZ2R42X.js.map → chunk-W2ZSNIBP.js.map} +0 -0
  399. /package/dist/{chunk-3COYXTGM.js.map → chunk-WHWDBTCJ.js.map} +0 -0
  400. /package/dist/{chunk-FIK3CQNA.js.map → chunk-WOC6DXP5.js.map} +0 -0
  401. /package/dist/{chunk-4FBVAGV3.js.map → chunk-XBMJ35IP.js.map} +0 -0
  402. /package/dist/{chunk-GFCVUY6G.js.map → chunk-YWCOJOUI.js.map} +0 -0
@@ -6,20 +6,20 @@ import {
6
6
  loadSyncState,
7
7
  syncWearableSource,
8
8
  wearableSourceLabel
9
- } from "./chunk-UV72DEZD.js";
10
- import {
11
- runPeerProfileReasoner
12
- } from "./chunk-I74SUMNI.js";
13
- import {
14
- CompressionGuidelineCoordinator
15
- } from "./chunk-6LKEUCEM.js";
9
+ } from "./chunk-UYUYZ4WY.js";
16
10
  import {
17
11
  ActivityStore,
18
12
  MaintenanceScheduler
19
- } from "./chunk-AC5OWJLV.js";
13
+ } from "./chunk-E4FOAENZ.js";
14
+ import {
15
+ runPeerProfileReasoner
16
+ } from "./chunk-I74SUMNI.js";
20
17
  import {
21
18
  migrateFromEngram
22
19
  } from "./chunk-7HYPN2GC.js";
20
+ import {
21
+ CompressionGuidelineCoordinator
22
+ } from "./chunk-6LKEUCEM.js";
23
23
  import {
24
24
  LcmEngine
25
25
  } from "./chunk-Z54EM5YZ.js";
@@ -32,7 +32,7 @@ import {
32
32
  import {
33
33
  CompoundingEngine,
34
34
  defaultTierMigrationCycleBudget
35
- } from "./chunk-RNHVVMFN.js";
35
+ } from "./chunk-T6JRMVOV.js";
36
36
  import {
37
37
  SharedContextManager
38
38
  } from "./chunk-M23RF3LJ.js";
@@ -41,6 +41,9 @@ import {
41
41
  applyUtilityRankingRuntimeDelta,
42
42
  loadUtilityRuntimeValues
43
43
  } from "./chunk-LXOM6IQU.js";
44
+ import {
45
+ CODEX_THREAD_KEY_PREFIX
46
+ } from "./chunk-4EX5WZ4M.js";
44
47
  import {
45
48
  TierMigrationExecutor
46
49
  } from "./chunk-YRFAYOFQ.js";
@@ -53,19 +56,16 @@ import {
53
56
  import {
54
57
  extractTopics
55
58
  } from "./chunk-UHGBNIOS.js";
59
+ import {
60
+ buildTargetedFactRecallSection,
61
+ shouldRecallTargetedFactEvidence
62
+ } from "./chunk-T67LUYCR.js";
56
63
  import {
57
64
  buildTemporalTimelineRecallSection
58
65
  } from "./chunk-I6WYQSX4.js";
59
- import {
60
- CODEX_THREAD_KEY_PREFIX
61
- } from "./chunk-4EX5WZ4M.js";
62
66
  import {
63
67
  HourlySummarizer
64
68
  } from "./chunk-LLJMAULE.js";
65
- import {
66
- buildTargetedFactRecallSection,
67
- shouldRecallTargetedFactEvidence
68
- } from "./chunk-T67LUYCR.js";
69
69
  import {
70
70
  SessionObserverState
71
71
  } from "./chunk-QFN4U7AG.js";
@@ -108,6 +108,9 @@ import {
108
108
  reorderByRankedKeys,
109
109
  rerankLocalOrNoop
110
110
  } from "./chunk-LUDXM7MD.js";
111
+ import {
112
+ createRecallSectionMetricRecorder
113
+ } from "./chunk-C3AKM55W.js";
111
114
  import {
112
115
  LastRecallStore,
113
116
  RecallHandleHistoryStore,
@@ -125,9 +128,6 @@ import {
125
128
  import {
126
129
  reorderRecallResultsWithMmr
127
130
  } from "./chunk-YDBIWGNI.js";
128
- import {
129
- createRecallSectionMetricRecorder
130
- } from "./chunk-C3AKM55W.js";
131
131
  import {
132
132
  applyReasoningTraceBoost
133
133
  } from "./chunk-ZZTOURJI.js";
@@ -154,9 +154,16 @@ import {
154
154
  buildFocusedListRecallSection,
155
155
  shouldRecallFocusedListEvidence
156
156
  } from "./chunk-OH7QLI6W.js";
157
+ import {
158
+ createDeferCountMap,
159
+ createVerdictCache,
160
+ getVerdictKind,
161
+ judgeFactDurability,
162
+ validateProcedureExtraction
163
+ } from "./chunk-K2TDK7GG.js";
157
164
  import {
158
165
  ExtractionEngine
159
- } from "./chunk-R3KHKU7M.js";
166
+ } from "./chunk-PKCLQ7KM.js";
160
167
  import {
161
168
  parseMemoryActionEligibilityContext
162
169
  } from "./chunk-CMQZNEIF.js";
@@ -169,13 +176,6 @@ import {
169
176
  import {
170
177
  recordJudgeTrainingPair
171
178
  } from "./chunk-PWFCHOB3.js";
172
- import {
173
- createDeferCountMap,
174
- createVerdictCache,
175
- getVerdictKind,
176
- judgeFactDurability,
177
- validateProcedureExtraction
178
- } from "./chunk-K2TDK7GG.js";
179
179
  import {
180
180
  buildExplicitCueRecallSection
181
181
  } from "./chunk-TVIVY7KU.js";
@@ -183,7 +183,7 @@ import {
183
183
  buildEntityRecallSection,
184
184
  entityRecentTranscriptLookbackHours,
185
185
  readRecentEntityTranscriptEntries
186
- } from "./chunk-6ISC4AVB.js";
186
+ } from "./chunk-BDNL34CT.js";
187
187
  import {
188
188
  buildEventOrderRecallSection,
189
189
  shouldRecallEventOrderEvidence
@@ -203,30 +203,30 @@ import {
203
203
  } from "./chunk-YK6BDDHP.js";
204
204
  import {
205
205
  refreshConvergedNamespaces
206
- } from "./chunk-WZ3TOIDW.js";
206
+ } from "./chunk-JFO5QZ7N.js";
207
207
  import {
208
208
  builtInConnectorPackageSpecifier,
209
209
  ensureBuiltInWearableConnectors,
210
210
  getWearableConnector,
211
211
  listWearableConnectors
212
- } from "./chunk-QVJPH7SH.js";
213
- import {
214
- normalizeReplaySessionKey
215
- } from "./chunk-AJVLDJU6.js";
212
+ } from "./chunk-5LRDM4R7.js";
216
213
  import {
217
214
  RoutingRulesStore
218
215
  } from "./chunk-XL24QQ63.js";
216
+ import {
217
+ normalizeReplaySessionKey
218
+ } from "./chunk-AJVLDJU6.js";
219
219
  import {
220
220
  compareVerifiedEpisodeResults,
221
221
  searchVerifiedEpisodes
222
- } from "./chunk-ERZ2R42X.js";
222
+ } from "./chunk-W2ZSNIBP.js";
223
223
  import {
224
224
  ThreadingManager
225
225
  } from "./chunk-OJP3N7UK.js";
226
226
  import {
227
227
  compareVerifiedSemanticRuleResults,
228
228
  searchVerifiedSemanticRules
229
- } from "./chunk-GFCVUY6G.js";
229
+ } from "./chunk-YWCOJOUI.js";
230
230
  import {
231
231
  searchWorkProductLedgerEntries
232
232
  } from "./chunk-ZRWB5D4H.js";
@@ -239,18 +239,18 @@ import {
239
239
  import {
240
240
  runNamespaceMaintenanceFanout,
241
241
  summarizeNamespaceMaintenanceHealth
242
- } from "./chunk-XAGYS7X6.js";
242
+ } from "./chunk-5R6S4DJZ.js";
243
243
  import {
244
244
  NamespaceCatalog,
245
245
  planNamespaceMaintenance
246
- } from "./chunk-2FSTB6BJ.js";
247
- import {
248
- searchHarmonicRetrieval
249
- } from "./chunk-KVJRXN2E.js";
246
+ } from "./chunk-ILBLZ5Y5.js";
250
247
  import {
251
248
  isAboveImportanceThreshold,
252
249
  scoreImportance
253
250
  } from "./chunk-JXS5PDQ7.js";
251
+ import {
252
+ searchHarmonicRetrieval
253
+ } from "./chunk-KVJRXN2E.js";
254
254
  import {
255
255
  EXTRACTION_JUDGE_VERDICT_CATEGORY,
256
256
  recordJudgeVerdict
@@ -275,7 +275,10 @@ import {
275
275
  materializeAfterSemanticConsolidation,
276
276
  parseConsolidationResponse,
277
277
  parseOperatorAwareConsolidationResponse
278
- } from "./chunk-MO4HSXHZ.js";
278
+ } from "./chunk-M2INOSTA.js";
279
+ import {
280
+ BoxBuilder
281
+ } from "./chunk-B7RWBZXW.js";
279
282
  import {
280
283
  semanticChunkContent
281
284
  } from "./chunk-P4BC54KI.js";
@@ -284,7 +287,7 @@ import {
284
287
  } from "./chunk-UQ7RN5HK.js";
285
288
  import {
286
289
  SmartBuffer
287
- } from "./chunk-E5XQIWAL.js";
290
+ } from "./chunk-64BHFFKZ.js";
288
291
  import {
289
292
  detectMeetings
290
293
  } from "./chunk-AUMWZSE7.js";
@@ -303,6 +306,10 @@ import {
303
306
  assertExternalWikiRootOutsideMemoryDirCanonical,
304
307
  isExternalWikiCollectionName
305
308
  } from "./chunk-JV3C2MNQ.js";
309
+ import {
310
+ AMBIENT_CAPTURE_PROMPT_RULE,
311
+ isHighImpactPersonalFact
312
+ } from "./chunk-QW27DOHG.js";
306
313
  import {
307
314
  buildRecallQueryPolicy
308
315
  } from "./chunk-LBJBNWS2.js";
@@ -316,12 +323,9 @@ import {
316
323
  import {
317
324
  isDisagreementPrompt
318
325
  } from "./chunk-H3FZVNRN.js";
319
- import {
320
- BoxBuilder
321
- } from "./chunk-B7RWBZXW.js";
322
326
  import {
323
327
  MeetingsInputError
324
- } from "./chunk-CX4ZUMC6.js";
328
+ } from "./chunk-2DSUT7DZ.js";
325
329
  import {
326
330
  WearablesInputError,
327
331
  describeErrorForOperator
@@ -339,7 +343,7 @@ import {
339
343
  capturePassiveCorrections,
340
344
  clusterByKey,
341
345
  detectPassiveCorrections
342
- } from "./chunk-QUENPGWZ.js";
346
+ } from "./chunk-RCU25Z66.js";
343
347
  import {
344
348
  importCapsule
345
349
  } from "./chunk-A4JMGKCD.js";
@@ -357,9 +361,6 @@ import {
357
361
  listTrustZoneRecords,
358
362
  searchTrustZoneRecords
359
363
  } from "./chunk-JGSKJHF7.js";
360
- import {
361
- buildXraySnapshot
362
- } from "./chunk-HFPASSFV.js";
363
364
  import {
364
365
  boundRecallContextComposition,
365
366
  composeRecallContext,
@@ -367,6 +368,9 @@ import {
367
368
  formatCuriosityFooter,
368
369
  selectCuriosityQuestion
369
370
  } from "./chunk-AHVEHR6K.js";
371
+ import {
372
+ buildXraySnapshot
373
+ } from "./chunk-P2OTGMTR.js";
370
374
  import {
371
375
  objectiveStateStoreOverrideForNamespace,
372
376
  searchObjectiveStateSnapshots
@@ -387,18 +391,18 @@ import {
387
391
  import {
388
392
  NamespaceSearchRouter,
389
393
  namespaceCollectionName
390
- } from "./chunk-JZH4LWHB.js";
394
+ } from "./chunk-KMWYZTIE.js";
391
395
  import {
392
396
  createConversationIndexRuntime,
393
397
  createSearchBackend,
394
398
  isSearchBackendEnabled
395
- } from "./chunk-DAJPRXBR.js";
399
+ } from "./chunk-47J4EDGR.js";
396
400
  import {
397
401
  NoopSearchBackend
398
402
  } from "./chunk-CYEPCZN5.js";
399
403
  import {
400
404
  NamespaceStorageRouter
401
- } from "./chunk-AMAUBUKY.js";
405
+ } from "./chunk-LI7OE7G6.js";
402
406
  import {
403
407
  writeConversationChunks
404
408
  } from "./chunk-72A4L5JJ.js";
@@ -410,7 +414,7 @@ import {
410
414
  } from "./chunk-W4FBGYGK.js";
411
415
  import {
412
416
  buildChainFollowupGenerator
413
- } from "./chunk-LPYDOLSM.js";
417
+ } from "./chunk-L7G72WY4.js";
414
418
  import {
415
419
  QmdResultResolver,
416
420
  StorageManager,
@@ -429,7 +433,10 @@ import {
429
433
  reconstructFusionInputs,
430
434
  selfDeps,
431
435
  serializeFusionDay
432
- } from "./chunk-FUCYDRE5.js";
436
+ } from "./chunk-IDE5AR5W.js";
437
+ import {
438
+ buildRetiredFactTombstoneInputs
439
+ } from "./chunk-ENTCVTQR.js";
433
440
  import {
434
441
  bodyIsEscaped,
435
442
  decodeTranscriptBody,
@@ -440,9 +447,6 @@ import {
440
447
  saveSpeakerRegistry,
441
448
  speakerRegistryKey
442
449
  } from "./chunk-UHVXE24Y.js";
443
- import {
444
- buildRetiredFactTombstoneInputs
445
- } from "./chunk-ENTCVTQR.js";
446
450
  import {
447
451
  canRecallToolScopedMemory,
448
452
  shouldPromoteGlobalFactToShared,
@@ -455,7 +459,7 @@ import {
455
459
  } from "./chunk-J6A3CX5N.js";
456
460
  import {
457
461
  confidenceTier
458
- } from "./chunk-DZPFMQZ7.js";
462
+ } from "./chunk-3S63QIFQ.js";
459
463
  import {
460
464
  lintWorkspaceFiles,
461
465
  rotateMarkdownFileToArchive
@@ -669,7 +673,7 @@ import {
669
673
  } from "./chunk-3WCASNQZ.js";
670
674
 
671
675
  // src/orchestrator.ts
672
- import path16 from "path";
676
+ import path18 from "path";
673
677
  import { createHash as createHash6 } from "crypto";
674
678
 
675
679
  // src/orchestration/tier-migration-coordinator.ts
@@ -2164,7 +2168,7 @@ var RecallRerankCoordinator = class _RecallRerankCoordinator {
2164
2168
  namespaces,
2165
2169
  {
2166
2170
  readNamespaceMemories: async (ns) => (await this.getStorage(ns)).readAllMemories(),
2167
- readMemoryFrontmatter: async (path31, preferredNamespace) => {
2171
+ readMemoryFrontmatter: async (path33, preferredNamespace) => {
2168
2172
  if (!fallbackReader) {
2169
2173
  for (const ns of namespaces) {
2170
2174
  try {
@@ -2176,7 +2180,7 @@ var RecallRerankCoordinator = class _RecallRerankCoordinator {
2176
2180
  }
2177
2181
  if (!fallbackReader) return null;
2178
2182
  const memory = await this.readQmdResultMemory(
2179
- path31,
2183
+ path33,
2180
2184
  fallbackReader,
2181
2185
  namespaces,
2182
2186
  preferredNamespace
@@ -5088,7 +5092,7 @@ var ExtractionPersistCoordinator = class {
5088
5092
  // src/orchestration/recall-internal.ts
5089
5093
  import { createHash as createHash3 } from "crypto";
5090
5094
  import { readFile as readFile2, stat, unlink } from "fs/promises";
5091
- import path7 from "path";
5095
+ import path8 from "path";
5092
5096
 
5093
5097
  // src/orchestration/graph-recall-coordinator.ts
5094
5098
  import { createHash as createHash2 } from "crypto";
@@ -5498,6 +5502,158 @@ function filterRecallCandidates(candidates, options) {
5498
5502
  return scopedByNamespace.filter((r) => !isGenericRecallExcludedPath(r.path, pathPolicy, "qmd")).slice(0, Math.max(0, options.limit));
5499
5503
  }
5500
5504
 
5505
+ // src/orchestration/recall-profile-storage.ts
5506
+ import path7 from "path";
5507
+ function resolveCompositeProfileStorage(options) {
5508
+ const { profileStorages, memoryDir } = options;
5509
+ const emptyProfileStorage = new Proxy(
5510
+ { dir: path7.join(memoryDir, ".empty-scope-profile") },
5511
+ {
5512
+ get(target, prop) {
5513
+ if (prop in target) return Reflect.get(target, prop);
5514
+ if (prop === "readProfile") return async () => "";
5515
+ if (prop === "readQuestions" || prop === "listEntityNames" || prop === "readContinuityIncidents")
5516
+ return async () => [];
5517
+ if (prop === "readIdentityAnchor" || prop === "readIdentityImprovementLoops")
5518
+ return async () => "";
5519
+ if (prop === "readEntity" || prop === "readMemoryByPath")
5520
+ return async () => null;
5521
+ return async () => [];
5522
+ }
5523
+ }
5524
+ );
5525
+ const profileStorage = profileStorages.length <= 1 ? profileStorages[0] ?? emptyProfileStorage : new Proxy(profileStorages[0], {
5526
+ get(target, prop) {
5527
+ if (prop === "readProfile") {
5528
+ return async () => {
5529
+ for (const storage of profileStorages) {
5530
+ const profile = await storage.readProfile();
5531
+ if (profile.trim().length > 0) return profile;
5532
+ }
5533
+ return "";
5534
+ };
5535
+ }
5536
+ if (prop === "readQuestions") {
5537
+ return async (...args) => {
5538
+ const merged = [];
5539
+ const seen = /* @__PURE__ */ new Set();
5540
+ const priorityOf = (question) => {
5541
+ const priority = Number(question?.priority ?? 0);
5542
+ return Number.isFinite(priority) ? priority : 0;
5543
+ };
5544
+ for (const storage of profileStorages) {
5545
+ const readFn = storage.readQuestions;
5546
+ const questions = await readFn.call(storage, ...args);
5547
+ for (const question of questions) {
5548
+ const key = typeof question === "string" ? question : JSON.stringify(question);
5549
+ if (seen.has(key)) continue;
5550
+ seen.add(key);
5551
+ merged.push(question);
5552
+ }
5553
+ }
5554
+ return merged.sort(
5555
+ (left, right) => priorityOf(right) - priorityOf(left) || String(left?.id ?? "").localeCompare(String(right?.id ?? ""))
5556
+ );
5557
+ };
5558
+ }
5559
+ if (prop === "readIdentityAnchor") {
5560
+ return async () => {
5561
+ for (const storage of profileStorages) {
5562
+ const anchor = await storage.readIdentityAnchor() ?? "";
5563
+ if (anchor.trim().length > 0) return anchor;
5564
+ }
5565
+ return "";
5566
+ };
5567
+ }
5568
+ if (prop === "readIdentityImprovementLoops") {
5569
+ return async () => {
5570
+ const sections = [];
5571
+ const seen = /* @__PURE__ */ new Set();
5572
+ for (const storage of profileStorages) {
5573
+ const loops = (await storage.readIdentityImprovementLoops() ?? "").trim();
5574
+ if (!loops || seen.has(loops)) continue;
5575
+ seen.add(loops);
5576
+ sections.push(loops);
5577
+ }
5578
+ return sections.join("\n\n");
5579
+ };
5580
+ }
5581
+ if (prop === "readContinuityIncidents") {
5582
+ return async (...args) => {
5583
+ const limit = typeof args[0] === "number" && Number.isFinite(args[0]) ? Math.max(0, args[0]) : void 0;
5584
+ const incidents = [];
5585
+ const seen = /* @__PURE__ */ new Set();
5586
+ const incidentTime = (incident) => {
5587
+ const incObj = incident;
5588
+ const raw = incObj?.updatedAt ?? incObj?.openedAt ?? incObj?.createdAt;
5589
+ const parsed = typeof raw === "string" ? Date.parse(raw) : Number.NaN;
5590
+ return Number.isFinite(parsed) ? parsed : 0;
5591
+ };
5592
+ for (const storage of profileStorages) {
5593
+ const readFn = storage.readContinuityIncidents;
5594
+ for (const incident of await readFn.call(storage, ...args)) {
5595
+ const key = JSON.stringify(incident);
5596
+ if (seen.has(key)) continue;
5597
+ seen.add(key);
5598
+ incidents.push(incident);
5599
+ }
5600
+ }
5601
+ incidents.sort(
5602
+ (left, right) => incidentTime(right) - incidentTime(left) || String(left?.id ?? "").localeCompare(String(right?.id ?? ""))
5603
+ );
5604
+ return limit === void 0 ? incidents : incidents.slice(0, limit);
5605
+ };
5606
+ }
5607
+ if (prop === "listEntityNames") {
5608
+ return async (...args) => {
5609
+ const names = /* @__PURE__ */ new Set();
5610
+ for (const storage of profileStorages) {
5611
+ const listFn = storage.listEntityNames;
5612
+ for (const name of await listFn.call(storage, ...args)) names.add(name);
5613
+ }
5614
+ return [...names];
5615
+ };
5616
+ }
5617
+ if (prop === "readEntity" || prop === "readMemoryByPath") {
5618
+ return async (...args) => {
5619
+ for (const storage of profileStorages) {
5620
+ const methodFn = storage[prop];
5621
+ if (methodFn) {
5622
+ const value = await methodFn.call(storage, ...args);
5623
+ if (value) return value;
5624
+ }
5625
+ }
5626
+ return null;
5627
+ };
5628
+ }
5629
+ if (prop === "readAllMemories") {
5630
+ return async (...args) => {
5631
+ const memories = [];
5632
+ const seen = /* @__PURE__ */ new Set();
5633
+ for (const storage of profileStorages) {
5634
+ const readFn = storage.readAllMemories;
5635
+ for (const memory of await readFn.call(storage, ...args)) {
5636
+ const memObj = memory;
5637
+ const key = String(memObj?.path ?? memObj?.frontmatter?.id ?? JSON.stringify(memory));
5638
+ if (seen.has(key)) continue;
5639
+ seen.add(key);
5640
+ memories.push(memory);
5641
+ }
5642
+ }
5643
+ return memories;
5644
+ };
5645
+ }
5646
+ return Reflect.get(target, prop);
5647
+ }
5648
+ });
5649
+ const profileStorageDirs = Array.from(
5650
+ new Set(
5651
+ profileStorages.map((storage) => storage.dir).filter((dir) => typeof dir === "string" && dir.length > 0)
5652
+ )
5653
+ );
5654
+ return { profileStorage, profileStorageDirs };
5655
+ }
5656
+
5501
5657
  // src/orchestration/recall-internal.ts
5502
5658
  var RecallInternalCoordinator = class {
5503
5659
  constructor(deps) {
@@ -5720,7 +5876,7 @@ var RecallInternalCoordinator = class {
5720
5876
  const graphExpandedResultPaths = /* @__PURE__ */ new Set();
5721
5877
  const graphSourceLabelsForPath = (resultPath) => {
5722
5878
  const labels = [];
5723
- const normalizedPath = resultPath.split(path7.sep).join("/");
5879
+ const normalizedPath = resultPath.split(path8.sep).join("/");
5724
5880
  const isEntityPath = normalizedPath.startsWith("entities/") || normalizedPath.includes("/entities/");
5725
5881
  if (graphBaselinePaths.has(resultPath)) labels.push("baseline");
5726
5882
  if (graphExpandedResultPaths.has(resultPath))
@@ -5881,140 +6037,10 @@ var RecallInternalCoordinator = class {
5881
6037
  const profileStorages = await Promise.all(
5882
6038
  profileStorageNamespaces.map((namespace) => this.deps.storageRouter.storageFor(namespace))
5883
6039
  );
5884
- const emptyProfileStorage = new Proxy(
5885
- { dir: path7.join(this.deps.config.memoryDir, ".empty-scope-profile") },
5886
- {
5887
- get(target, prop) {
5888
- if (prop in target) return target[prop];
5889
- if (prop === "readProfile") return async () => "";
5890
- if (prop === "readQuestions" || prop === "listEntityNames" || prop === "readContinuityIncidents")
5891
- return async () => [];
5892
- if (prop === "readIdentityAnchor" || prop === "readIdentityImprovementLoops")
5893
- return async () => "";
5894
- if (prop === "readEntity" || prop === "readMemoryByPath")
5895
- return async () => null;
5896
- return async () => [];
5897
- }
5898
- }
5899
- );
5900
- const profileStorage = profileStorages.length <= 1 ? profileStorages[0] ?? emptyProfileStorage : new Proxy(profileStorages[0], {
5901
- get(target, prop) {
5902
- if (prop === "readProfile") {
5903
- return async () => {
5904
- for (const storage of profileStorages) {
5905
- const profile2 = await storage.readProfile();
5906
- if (profile2.trim().length > 0) return profile2;
5907
- }
5908
- return "";
5909
- };
5910
- }
5911
- if (prop === "readQuestions") {
5912
- return async (...args) => {
5913
- const merged = [];
5914
- const seen = /* @__PURE__ */ new Set();
5915
- const priorityOf = (question) => {
5916
- const priority = Number(question?.priority ?? 0);
5917
- return Number.isFinite(priority) ? priority : 0;
5918
- };
5919
- for (const storage of profileStorages) {
5920
- const questions = await storage.readQuestions(...args);
5921
- for (const question of questions) {
5922
- const key = typeof question === "string" ? question : JSON.stringify(question);
5923
- if (seen.has(key)) continue;
5924
- seen.add(key);
5925
- merged.push(question);
5926
- }
5927
- }
5928
- return merged.sort(
5929
- (left, right) => priorityOf(right) - priorityOf(left) || String(left?.id ?? "").localeCompare(String(right?.id ?? ""))
5930
- );
5931
- };
5932
- }
5933
- if (prop === "readIdentityAnchor") {
5934
- return async () => {
5935
- for (const storage of profileStorages) {
5936
- const anchor = await storage.readIdentityAnchor() ?? "";
5937
- if (anchor.trim().length > 0) return anchor;
5938
- }
5939
- return "";
5940
- };
5941
- }
5942
- if (prop === "readIdentityImprovementLoops") {
5943
- return async () => {
5944
- const sections = [];
5945
- const seen = /* @__PURE__ */ new Set();
5946
- for (const storage of profileStorages) {
5947
- const loops = (await storage.readIdentityImprovementLoops() ?? "").trim();
5948
- if (!loops || seen.has(loops)) continue;
5949
- seen.add(loops);
5950
- sections.push(loops);
5951
- }
5952
- return sections.join("\n\n");
5953
- };
5954
- }
5955
- if (prop === "readContinuityIncidents") {
5956
- return async (...args) => {
5957
- const limit = typeof args[0] === "number" && Number.isFinite(args[0]) ? Math.max(0, args[0]) : void 0;
5958
- const incidents = [];
5959
- const seen = /* @__PURE__ */ new Set();
5960
- const incidentTime = (incident) => {
5961
- const raw = incident?.updatedAt ?? incident?.openedAt ?? incident?.createdAt;
5962
- const parsed = typeof raw === "string" ? Date.parse(raw) : Number.NaN;
5963
- return Number.isFinite(parsed) ? parsed : 0;
5964
- };
5965
- for (const storage of profileStorages) {
5966
- for (const incident of await storage.readContinuityIncidents(...args)) {
5967
- const key = JSON.stringify(incident);
5968
- if (seen.has(key)) continue;
5969
- seen.add(key);
5970
- incidents.push(incident);
5971
- }
5972
- }
5973
- incidents.sort(
5974
- (left, right) => incidentTime(right) - incidentTime(left) || String(left?.id ?? "").localeCompare(String(right?.id ?? ""))
5975
- );
5976
- return limit === void 0 ? incidents : incidents.slice(0, limit);
5977
- };
5978
- }
5979
- if (prop === "listEntityNames") {
5980
- return async (...args) => {
5981
- const names = /* @__PURE__ */ new Set();
5982
- for (const storage of profileStorages) {
5983
- for (const name of await storage.listEntityNames(...args)) names.add(name);
5984
- }
5985
- return [...names];
5986
- };
5987
- }
5988
- if (prop === "readEntity" || prop === "readMemoryByPath") {
5989
- return async (...args) => {
5990
- for (const storage of profileStorages) {
5991
- const value = await storage[prop](...args);
5992
- if (value) return value;
5993
- }
5994
- return null;
5995
- };
5996
- }
5997
- if (prop === "readAllMemories") {
5998
- return async (...args) => {
5999
- const memories = [];
6000
- const seen = /* @__PURE__ */ new Set();
6001
- for (const storage of profileStorages) {
6002
- for (const memory of await storage.readAllMemories(...args)) {
6003
- const key = String(memory?.path ?? memory?.frontmatter?.id ?? JSON.stringify(memory));
6004
- if (seen.has(key)) continue;
6005
- seen.add(key);
6006
- memories.push(memory);
6007
- }
6008
- }
6009
- return memories;
6010
- };
6011
- }
6012
- return target[prop];
6013
- }
6040
+ const { profileStorage, profileStorageDirs } = resolveCompositeProfileStorage({
6041
+ profileStorages,
6042
+ memoryDir: this.deps.config.memoryDir
6014
6043
  });
6015
- const profileStorageDirs = Array.from(
6016
- new Set(profileStorages.map((storage) => storage.dir).filter((dir) => typeof dir === "string" && dir.length > 0))
6017
- );
6018
6044
  throwIfRecallAborted(options.abortSignal);
6019
6045
  if (this.deps.namespaceCatalog.enabled && recallResultLimit > 0 && !options.abortSignal?.aborted) {
6020
6046
  for (const ns of recallNamespaces) this.deps.storageRouter.recordRead(ns);
@@ -7366,11 +7392,11 @@ ${formatted}`;
7366
7392
  if (!resolveRecallAuxiliaryCapabilities(this.deps.config).compactionReset) return null;
7367
7393
  const workspaceDir = compactionWorkspaceDir || this.deps.config.workspaceDir || defaultWorkspaceDir();
7368
7394
  const safeSessionKey = sanitizeSessionKeyForFilename(effectiveSessionKey);
7369
- const signalPath = path7.join(
7395
+ const signalPath = path8.join(
7370
7396
  workspaceDir,
7371
7397
  `.compaction-reset-signal-${safeSessionKey}`
7372
7398
  );
7373
- const bootPath = path7.join(workspaceDir, "BOOT.md");
7399
+ const bootPath = path8.join(workspaceDir, "BOOT.md");
7374
7400
  try {
7375
7401
  const signalStat = await stat(signalPath).catch(() => null);
7376
7402
  if (!signalStat) return null;
@@ -9600,127 +9626,170 @@ ${tmtNode.summary}`
9600
9626
 
9601
9627
  // src/orchestration/recall-search-pipeline.ts
9602
9628
  import { createHash as createHash4 } from "crypto";
9603
- import path8 from "path";
9604
- var RecallSearchPipelineCoordinator = class {
9605
- constructor(deps) {
9606
- this.deps = deps;
9607
- }
9608
- deps;
9609
- async fetchActiveArtifactsForNamespace(namespace, prompt, targetCount) {
9610
- const storage = await this.deps.storageRouter.storageFor(namespace);
9611
- let fetchLimit = computeArtifactCandidateFetchLimit(targetCount);
9612
- const maxFetchLimit = Math.min(800, Math.max(fetchLimit, targetCount * 8));
9613
- const MAX_ATTEMPTS = 4;
9614
- let bestFiltered = [];
9615
- for (let attempt = 0; attempt < MAX_ATTEMPTS; attempt += 1) {
9616
- const rawResults = await storage.searchArtifacts(prompt, fetchLimit);
9617
- const sourceIds = Array.from(
9618
- new Set(
9619
- rawResults.map((a) => a.frontmatter.sourceMemoryId).filter(
9620
- (id) => typeof id === "string" && id.length > 0
9621
- )
9629
+ import path10 from "path";
9630
+
9631
+ // src/orchestration/recall-search-prefilter.ts
9632
+ import path9 from "path";
9633
+ async function fetchActiveArtifactsForNamespace(deps, namespace, prompt, targetCount) {
9634
+ const storage = await deps.storageRouter.storageFor(namespace);
9635
+ let fetchLimit = computeArtifactCandidateFetchLimit(targetCount);
9636
+ const maxFetchLimit = Math.min(800, Math.max(fetchLimit, targetCount * 8));
9637
+ const MAX_ATTEMPTS = 4;
9638
+ let bestFiltered = [];
9639
+ for (let attempt = 0; attempt < MAX_ATTEMPTS; attempt += 1) {
9640
+ const rawResults = await storage.searchArtifacts(prompt, fetchLimit);
9641
+ const sourceIds = Array.from(
9642
+ new Set(
9643
+ rawResults.map((a) => a.frontmatter.sourceMemoryId).filter(
9644
+ (id) => typeof id === "string" && id.length > 0
9622
9645
  )
9623
- );
9624
- const sourceStatus = sourceIds.length > 0 ? await this.deps.resolveArtifactSourceStatuses(storage, sourceIds) : /* @__PURE__ */ new Map();
9625
- const filtered = [];
9626
- for (const artifact of rawResults) {
9627
- const sourceId = artifact.frontmatter.sourceMemoryId;
9628
- if (!sourceId) {
9629
- filtered.push(artifact);
9630
- if (filtered.length >= targetCount) break;
9631
- continue;
9632
- }
9633
- const status = sourceStatus.get(sourceId) ?? "missing";
9634
- if (status !== "active") continue;
9646
+ )
9647
+ );
9648
+ const sourceStatus = sourceIds.length > 0 ? await deps.resolveArtifactSourceStatuses(storage, sourceIds) : /* @__PURE__ */ new Map();
9649
+ const filtered = [];
9650
+ for (const artifact of rawResults) {
9651
+ const sourceId = artifact.frontmatter.sourceMemoryId;
9652
+ if (!sourceId) {
9635
9653
  filtered.push(artifact);
9636
9654
  if (filtered.length >= targetCount) break;
9655
+ continue;
9637
9656
  }
9638
- if (filtered.length >= targetCount) return filtered.slice(0, targetCount);
9639
- if (filtered.length > bestFiltered.length) {
9640
- bestFiltered = filtered;
9641
- }
9642
- if (rawResults.length === 0) return filtered;
9643
- if (rawResults.length < fetchLimit && filtered.length > 0)
9644
- return filtered;
9645
- if (fetchLimit >= maxFetchLimit) return filtered;
9646
- const growth = Math.max(targetCount * 2, 12);
9647
- fetchLimit = Math.min(maxFetchLimit, fetchLimit + growth);
9648
- }
9649
- return bestFiltered;
9650
- }
9651
- async buildQueryAwarePrefilter(prompt, recallNamespaces) {
9652
- if (!resolveIndexingCapabilities(this.deps.config).queryAwareIndexing || !prompt.trim()) {
9653
- return {
9654
- candidatePaths: null,
9655
- temporalFromDate: null,
9656
- matchedTags: [],
9657
- expandedTags: [],
9658
- combination: "none",
9659
- filteredToFullSearch: false
9660
- };
9661
- }
9662
- const temporalFromDate = isTemporalQuery(prompt) ? recencyWindowFromPrompt(prompt, Date.now()) : null;
9663
- const [rawTemporal, tagSignals] = await readIndexSnapshotAsync(
9664
- this.deps.config.memoryDir,
9665
- () => Promise.all([
9666
- temporalFromDate ? queryByDateRangeAsync(this.deps.config.memoryDir, temporalFromDate) : Promise.resolve(null),
9667
- resolvePromptTagPrefilterAsync(this.deps.config.memoryDir, prompt).catch(
9668
- () => ({
9669
- matchedTags: extractTagsFromPrompt(prompt),
9670
- expandedTags: extractTagsFromPrompt(prompt),
9671
- paths: null
9672
- })
9673
- )
9674
- ])
9675
- );
9676
- const temporalCandidates = this.deps.scopeQueryAwarePaths(
9677
- rawTemporal,
9678
- recallNamespaces
9679
- );
9680
- const tagCandidates = this.deps.scopeQueryAwarePaths(
9681
- tagSignals.paths,
9682
- recallNamespaces
9683
- );
9684
- const maxCandidates = this.deps.config.queryAwareIndexingMaxCandidates;
9685
- let candidatePaths = null;
9686
- let combination = "none";
9687
- let filteredToFullSearch = false;
9688
- if (tagSignals.matchedTags.length > 0 && tagCandidates !== null && tagCandidates.size === 0) {
9689
- candidatePaths = tagCandidates;
9690
- combination = "tag";
9691
- } else if (temporalCandidates !== null && tagCandidates !== null) {
9692
- const intersection = new Set(
9693
- Array.from(temporalCandidates).filter(
9694
- (memoryPath) => tagCandidates.has(memoryPath)
9695
- )
9696
- );
9697
- if (intersection.size > 0) {
9698
- candidatePaths = intersection;
9699
- combination = "intersection";
9700
- } else {
9701
- candidatePaths = /* @__PURE__ */ new Set([...temporalCandidates, ...tagCandidates]);
9702
- combination = "union";
9703
- }
9704
- } else if (temporalCandidates !== null) {
9705
- candidatePaths = temporalCandidates;
9706
- combination = "temporal";
9707
- } else if (tagCandidates !== null) {
9708
- candidatePaths = tagCandidates;
9709
- combination = "tag";
9657
+ const status = sourceStatus.get(sourceId) ?? "missing";
9658
+ if (status !== "active") continue;
9659
+ filtered.push(artifact);
9660
+ if (filtered.length >= targetCount) break;
9710
9661
  }
9711
- if (candidatePaths && maxCandidates > 0 && candidatePaths.size > maxCandidates) {
9712
- filteredToFullSearch = true;
9713
- candidatePaths = null;
9662
+ if (filtered.length >= targetCount) return filtered.slice(0, targetCount);
9663
+ if (filtered.length > bestFiltered.length) {
9664
+ bestFiltered = filtered;
9714
9665
  }
9666
+ if (rawResults.length === 0) return filtered;
9667
+ if (rawResults.length < fetchLimit && filtered.length > 0)
9668
+ return filtered;
9669
+ if (fetchLimit >= maxFetchLimit) return filtered;
9670
+ const growth = Math.max(targetCount * 2, 12);
9671
+ fetchLimit = Math.min(maxFetchLimit, fetchLimit + growth);
9672
+ }
9673
+ return bestFiltered;
9674
+ }
9675
+ async function buildQueryAwarePrefilter(deps, prompt, recallNamespaces) {
9676
+ if (!resolveIndexingCapabilities(deps.config).queryAwareIndexing || !prompt.trim()) {
9715
9677
  return {
9716
- candidatePaths,
9717
- temporalFromDate,
9718
- matchedTags: tagSignals.matchedTags,
9719
- expandedTags: tagSignals.expandedTags,
9720
- combination,
9721
- filteredToFullSearch
9678
+ candidatePaths: null,
9679
+ temporalFromDate: null,
9680
+ matchedTags: [],
9681
+ expandedTags: [],
9682
+ combination: "none",
9683
+ filteredToFullSearch: false
9722
9684
  };
9723
9685
  }
9686
+ const temporalFromDate = isTemporalQuery(prompt) ? recencyWindowFromPrompt(prompt, Date.now()) : null;
9687
+ const [rawTemporal, tagSignals] = await readIndexSnapshotAsync(
9688
+ deps.config.memoryDir,
9689
+ () => Promise.all([
9690
+ temporalFromDate ? queryByDateRangeAsync(deps.config.memoryDir, temporalFromDate) : Promise.resolve(null),
9691
+ resolvePromptTagPrefilterAsync(deps.config.memoryDir, prompt).catch(
9692
+ () => ({
9693
+ matchedTags: extractTagsFromPrompt(prompt),
9694
+ expandedTags: extractTagsFromPrompt(prompt),
9695
+ paths: null
9696
+ })
9697
+ )
9698
+ ])
9699
+ );
9700
+ const temporalCandidates = deps.scopeQueryAwarePaths(
9701
+ rawTemporal,
9702
+ recallNamespaces
9703
+ );
9704
+ const tagCandidates = deps.scopeQueryAwarePaths(
9705
+ tagSignals.paths,
9706
+ recallNamespaces
9707
+ );
9708
+ const maxCandidates = deps.config.queryAwareIndexingMaxCandidates;
9709
+ let candidatePaths = null;
9710
+ let combination = "none";
9711
+ let filteredToFullSearch = false;
9712
+ if (tagSignals.matchedTags.length > 0 && tagCandidates !== null && tagCandidates.size === 0) {
9713
+ candidatePaths = tagCandidates;
9714
+ combination = "tag";
9715
+ } else if (temporalCandidates !== null && tagCandidates !== null) {
9716
+ const intersection = new Set(
9717
+ Array.from(temporalCandidates).filter(
9718
+ (memoryPath) => tagCandidates.has(memoryPath)
9719
+ )
9720
+ );
9721
+ if (intersection.size > 0) {
9722
+ candidatePaths = intersection;
9723
+ combination = "intersection";
9724
+ } else {
9725
+ candidatePaths = /* @__PURE__ */ new Set([...temporalCandidates, ...tagCandidates]);
9726
+ combination = "union";
9727
+ }
9728
+ } else if (temporalCandidates !== null) {
9729
+ candidatePaths = temporalCandidates;
9730
+ combination = "temporal";
9731
+ } else if (tagCandidates !== null) {
9732
+ candidatePaths = tagCandidates;
9733
+ combination = "tag";
9734
+ }
9735
+ if (candidatePaths && maxCandidates > 0 && candidatePaths.size > maxCandidates) {
9736
+ filteredToFullSearch = true;
9737
+ candidatePaths = null;
9738
+ }
9739
+ return {
9740
+ candidatePaths,
9741
+ temporalFromDate,
9742
+ matchedTags: tagSignals.matchedTags,
9743
+ expandedTags: tagSignals.expandedTags,
9744
+ combination,
9745
+ filteredToFullSearch
9746
+ };
9747
+ }
9748
+ async function searchEmbeddingFallback(deps, query, limit) {
9749
+ if (!resolveMemoryLifecycleCapabilities(deps.config).embeddingFallback) return [];
9750
+ if (!await deps.embeddingFallback.isAvailable()) return [];
9751
+ const hits = await deps.embeddingFallback.search(query, limit);
9752
+ if (hits.length === 0) return [];
9753
+ const results = [];
9754
+ for (const hit of hits) {
9755
+ const fullPath = path9.isAbsolute(hit.path) ? hit.path : path9.join(deps.config.memoryDir, hit.path);
9756
+ const memory = await deps.storage.readMemoryByPath(fullPath);
9757
+ if (!memory) continue;
9758
+ results.push({
9759
+ docid: hit.id,
9760
+ path: fullPath,
9761
+ score: hit.score,
9762
+ snippet: memory.content.slice(0, 400).replace(/\n/g, " ")
9763
+ });
9764
+ }
9765
+ return results;
9766
+ }
9767
+ async function searchQueryAwareFallback(deps, prompt, limit, queryAwarePrefilter, abortSignal) {
9768
+ throwIfRecallAborted(abortSignal);
9769
+ const cappedLimit = Math.max(0, limit);
9770
+ if (cappedLimit === 0 || queryAwarePrefilter?.candidatePaths?.size === 0) return [];
9771
+ const candidatePaths = queryAwarePrefilter?.candidatePaths;
9772
+ const scopedSeedResults = (candidatePaths?.size ? await deps.searchScopedMemoryCandidates(
9773
+ candidatePaths,
9774
+ prompt,
9775
+ candidatePaths.size,
9776
+ { allowArchived: true }
9777
+ ) : []).filter((result) => !isGenericRecallExcludedPath(result.path, deps.config, "qmd"));
9778
+ return scopedSeedResults.slice(0, cappedLimit);
9779
+ }
9780
+
9781
+ // src/orchestration/recall-search-pipeline.ts
9782
+ var RecallSearchPipelineCoordinator = class {
9783
+ constructor(deps) {
9784
+ this.deps = deps;
9785
+ }
9786
+ deps;
9787
+ async fetchActiveArtifactsForNamespace(namespace, prompt, targetCount) {
9788
+ return fetchActiveArtifactsForNamespace(this.deps, namespace, prompt, targetCount);
9789
+ }
9790
+ async buildQueryAwarePrefilter(prompt, recallNamespaces) {
9791
+ return buildQueryAwarePrefilter(this.deps, prompt, recallNamespaces);
9792
+ }
9724
9793
  async fetchQmdMemoryResultsWithArtifactTopUp(prompt, qmdFetchLimit, qmdHybridFetchLimit, options) {
9725
9794
  throwIfRecallAborted(options.abortSignal);
9726
9795
  const queryAwarePrefilter = options.queryAwarePrefilter ?? await this.deps.buildQueryAwarePrefilter(prompt, options.recallNamespaces);
@@ -9902,40 +9971,14 @@ var RecallSearchPipelineCoordinator = class {
9902
9971
  return capped;
9903
9972
  }
9904
9973
  async searchEmbeddingFallback(query, limit) {
9905
- if (!resolveMemoryLifecycleCapabilities(this.deps.config).embeddingFallback) return [];
9906
- if (!await this.deps.embeddingFallback.isAvailable()) return [];
9907
- const hits = await this.deps.embeddingFallback.search(query, limit);
9908
- if (hits.length === 0) return [];
9909
- const results = [];
9910
- for (const hit of hits) {
9911
- const fullPath = path8.isAbsolute(hit.path) ? hit.path : path8.join(this.deps.config.memoryDir, hit.path);
9912
- const memory = await this.deps.storage.readMemoryByPath(fullPath);
9913
- if (!memory) continue;
9914
- results.push({
9915
- docid: hit.id,
9916
- path: fullPath,
9917
- score: hit.score,
9918
- snippet: memory.content.slice(0, 400).replace(/\n/g, " ")
9919
- });
9920
- }
9921
- return results;
9974
+ return searchEmbeddingFallback(this.deps, query, limit);
9922
9975
  }
9923
9976
  /**
9924
9977
  * Cold fallback retains qualifying query-aware candidates. Archive records
9925
9978
  * belong to dedicated surfaces and never re-enter generic recall.
9926
9979
  */
9927
9980
  async searchQueryAwareFallback(prompt, limit, queryAwarePrefilter, abortSignal) {
9928
- throwIfRecallAborted(abortSignal);
9929
- const cappedLimit = Math.max(0, limit);
9930
- if (cappedLimit === 0 || queryAwarePrefilter?.candidatePaths?.size === 0) return [];
9931
- const candidatePaths = queryAwarePrefilter?.candidatePaths;
9932
- const scopedSeedResults = (candidatePaths?.size ? await this.deps.searchScopedMemoryCandidates(
9933
- candidatePaths,
9934
- prompt,
9935
- candidatePaths.size,
9936
- { allowArchived: true }
9937
- ) : []).filter((result) => !isGenericRecallExcludedPath(result.path, this.deps.config, "qmd"));
9938
- return scopedSeedResults.slice(0, cappedLimit);
9981
+ return searchQueryAwareFallback(this.deps, prompt, limit, queryAwarePrefilter, abortSignal);
9939
9982
  }
9940
9983
  async applyColdFallbackPipeline(options) {
9941
9984
  const caps = options.caps ?? resolveCapabilities(this.deps.config);
@@ -10071,7 +10114,7 @@ var RecallSearchPipelineCoordinator = class {
10071
10114
  const storage = await this.deps.storageRouter.storageFor(namespace);
10072
10115
  const storageDir = typeof storage.dir === "string" && storage.dir ? storage.dir : null;
10073
10116
  if (!storageDir) continue;
10074
- const recallRoot = path8.resolve(storageDir);
10117
+ const recallRoot = path10.resolve(storageDir);
10075
10118
  if (seenRecallRoots.has(recallRoot)) continue;
10076
10119
  seenRecallRoots.add(recallRoot);
10077
10120
  recallRoots.push(recallRoot);
@@ -10095,8 +10138,8 @@ var RecallSearchPipelineCoordinator = class {
10095
10138
  if (resolvedCold) scopedResults.push(resolvedCold.result);
10096
10139
  continue;
10097
10140
  }
10098
- if (path8.isAbsolute(result.path)) {
10099
- if (recallRoots.some((recallRoot) => isPathInsideStorageRoot(recallRoot, path8.resolve(result.path)))) {
10141
+ if (path10.isAbsolute(result.path)) {
10142
+ if (recallRoots.some((recallRoot) => isPathInsideStorageRoot(recallRoot, path10.resolve(result.path)))) {
10100
10143
  scopedResults.push(result);
10101
10144
  }
10102
10145
  continue;
@@ -11185,7 +11228,7 @@ var TurnIngestionCoordinator = class {
11185
11228
 
11186
11229
  // src/orchestration/recall-introspection.ts
11187
11230
  import { mkdir as mkdir5, readFile as readFile4, writeFile as writeFile5 } from "fs/promises";
11188
- import path10 from "path";
11231
+ import path12 from "path";
11189
11232
 
11190
11233
  // src/taxonomy/default-taxonomy.ts
11191
11234
  var DEFAULT_TAXONOMY = {
@@ -11308,7 +11351,7 @@ function generateResolverDocument(taxonomy) {
11308
11351
 
11309
11352
  // src/taxonomy/taxonomy-loader.ts
11310
11353
  import { readFile as readFile3, mkdir as mkdir4, writeFile as writeFile4 } from "fs/promises";
11311
- import path9 from "path";
11354
+ import path11 from "path";
11312
11355
  var TAXONOMY_DIR = ".taxonomy";
11313
11356
  var TAXONOMY_FILE = "taxonomy.json";
11314
11357
  var MAX_SLUG_LENGTH = 32;
@@ -11406,7 +11449,7 @@ function validateTaxonomy(taxonomy) {
11406
11449
  }
11407
11450
  }
11408
11451
  async function loadTaxonomy(memoryDir) {
11409
- const taxonomyPath = path9.join(memoryDir, TAXONOMY_DIR, TAXONOMY_FILE);
11452
+ const taxonomyPath = path11.join(memoryDir, TAXONOMY_DIR, TAXONOMY_FILE);
11410
11453
  let raw;
11411
11454
  try {
11412
11455
  raw = await readFile3(taxonomyPath, "utf-8");
@@ -11456,16 +11499,16 @@ async function loadTaxonomy(memoryDir) {
11456
11499
  }
11457
11500
  async function saveTaxonomy(memoryDir, taxonomy) {
11458
11501
  validateTaxonomy(taxonomy);
11459
- const dir = path9.join(memoryDir, TAXONOMY_DIR);
11502
+ const dir = path11.join(memoryDir, TAXONOMY_DIR);
11460
11503
  await mkdir4(dir, { recursive: true });
11461
- const filePath = path9.join(dir, TAXONOMY_FILE);
11504
+ const filePath = path11.join(dir, TAXONOMY_FILE);
11462
11505
  await writeFile4(filePath, JSON.stringify(taxonomy, null, 2) + "\n", "utf-8");
11463
11506
  }
11464
11507
  function getTaxonomyDir(memoryDir) {
11465
- return path9.join(memoryDir, TAXONOMY_DIR);
11508
+ return path11.join(memoryDir, TAXONOMY_DIR);
11466
11509
  }
11467
11510
  function getTaxonomyFilePath(memoryDir) {
11468
- return path9.join(memoryDir, TAXONOMY_DIR, TAXONOMY_FILE);
11511
+ return path11.join(memoryDir, TAXONOMY_DIR, TAXONOMY_FILE);
11469
11512
  }
11470
11513
 
11471
11514
  // src/orchestration/recall-introspection.ts
@@ -11489,7 +11532,7 @@ var RecallIntrospectionCoordinator = class {
11489
11532
  }
11490
11533
  async getLastGraphRecallSnapshot(namespace) {
11491
11534
  const storage = await this.deps.getStorage(namespace);
11492
- const snapshotPath = path10.join(
11535
+ const snapshotPath = path12.join(
11493
11536
  storage.dir,
11494
11537
  "state",
11495
11538
  "last_graph_recall.json"
@@ -11528,7 +11571,7 @@ var RecallIntrospectionCoordinator = class {
11528
11571
  }
11529
11572
  async getLastIntentSnapshot(namespace) {
11530
11573
  const storage = await this.deps.getStorage(namespace);
11531
- const snapshotPath = path10.join(storage.dir, "state", "last_intent.json");
11574
+ const snapshotPath = path12.join(storage.dir, "state", "last_intent.json");
11532
11575
  try {
11533
11576
  const raw = await readFile4(snapshotPath, "utf-8");
11534
11577
  const parsed = JSON.parse(raw);
@@ -11561,7 +11604,7 @@ var RecallIntrospectionCoordinator = class {
11561
11604
  }
11562
11605
  async getLastQmdRecallSnapshot(namespace) {
11563
11606
  const storage = await this.deps.getStorage(namespace);
11564
- const snapshotPath = path10.join(
11607
+ const snapshotPath = path12.join(
11565
11608
  storage.dir,
11566
11609
  "state",
11567
11610
  "last_qmd_recall.json"
@@ -11851,12 +11894,12 @@ var RecallIntrospectionCoordinator = class {
11851
11894
  }
11852
11895
  async recordLastIntentSnapshot(options) {
11853
11896
  try {
11854
- const snapshotPath = path10.join(
11897
+ const snapshotPath = path12.join(
11855
11898
  options.storage.dir,
11856
11899
  "state",
11857
11900
  "last_intent.json"
11858
11901
  );
11859
- await mkdir5(path10.dirname(snapshotPath), { recursive: true });
11902
+ await mkdir5(path12.dirname(snapshotPath), { recursive: true });
11860
11903
  await writeFile5(
11861
11904
  snapshotPath,
11862
11905
  JSON.stringify(options.snapshot, null, 2),
@@ -11868,12 +11911,12 @@ var RecallIntrospectionCoordinator = class {
11868
11911
  }
11869
11912
  async recordLastQmdRecallSnapshot(options) {
11870
11913
  try {
11871
- const snapshotPath = path10.join(
11914
+ const snapshotPath = path12.join(
11872
11915
  options.storage.dir,
11873
11916
  "state",
11874
11917
  "last_qmd_recall.json"
11875
11918
  );
11876
- await mkdir5(path10.dirname(snapshotPath), { recursive: true });
11919
+ await mkdir5(path12.dirname(snapshotPath), { recursive: true });
11877
11920
  await writeFile5(
11878
11921
  snapshotPath,
11879
11922
  JSON.stringify(options.snapshot, null, 2),
@@ -11888,8 +11931,8 @@ var RecallIntrospectionCoordinator = class {
11888
11931
  const stateDir = await this.deps.resolveStateDirForNamespace(
11889
11932
  options.namespace
11890
11933
  );
11891
- const snapshotPath = path10.join(stateDir, "last_intent.json");
11892
- await mkdir5(path10.dirname(snapshotPath), { recursive: true });
11934
+ const snapshotPath = path12.join(stateDir, "last_intent.json");
11935
+ await mkdir5(path12.dirname(snapshotPath), { recursive: true });
11893
11936
  await writeFile5(
11894
11937
  snapshotPath,
11895
11938
  JSON.stringify(options.snapshot, null, 2),
@@ -11903,7 +11946,7 @@ var RecallIntrospectionCoordinator = class {
11903
11946
 
11904
11947
  // src/orchestration/orchestrator-init.ts
11905
11948
  import { readdir as readdir2, stat as stat2, unlink as unlink2 } from "fs/promises";
11906
- import path11 from "path";
11949
+ import path13 from "path";
11907
11950
  var OrchestratorInitCoordinator = class {
11908
11951
  constructor(deps) {
11909
11952
  this.deps = deps;
@@ -12007,7 +12050,7 @@ var OrchestratorInitCoordinator = class {
12007
12050
  const files = await readdir2(wsDir).catch(() => []);
12008
12051
  for (const f of files) {
12009
12052
  if (!f.startsWith(".compaction-reset-signal-")) continue;
12010
- const fp = path11.join(wsDir, f);
12053
+ const fp = path13.join(wsDir, f);
12011
12054
  const s = await stat2(fp).catch(() => null);
12012
12055
  if (s && Date.now() - s.mtimeMs >= COMPACTION_SIGNAL_MAX_AGE_MS) {
12013
12056
  await unlink2(fp).catch(() => {
@@ -12225,7 +12268,7 @@ var OrchestratorInitCoordinator = class {
12225
12268
  if (signal.aborted) return;
12226
12269
  if (!this.deps.wearablesAutoSyncHandle && this.deps.config.wearables.enabled && this.deps.config.wearables.autoSyncEnabled && Object.values(this.deps.config.wearables.sources).some((source) => source.enabled)) {
12227
12270
  try {
12228
- const { startWearablesAutoSync } = await import("./auto-sync-UPTUVE4X.js");
12271
+ const { startWearablesAutoSync } = await import("./auto-sync-7O6RP2RT.js");
12229
12272
  if (signal.aborted) return;
12230
12273
  this.deps.wearablesAutoSyncHandle = startWearablesAutoSync(
12231
12274
  {
@@ -12359,7 +12402,7 @@ var OrchestratorInitCoordinator = class {
12359
12402
  };
12360
12403
 
12361
12404
  // src/orchestration/persistence-index.ts
12362
- import path12 from "path";
12405
+ import path14 from "path";
12363
12406
  var PersistenceIndexCoordinator = class {
12364
12407
  constructor(deps) {
12365
12408
  this.deps = deps;
@@ -12545,7 +12588,7 @@ var PersistenceIndexCoordinator = class {
12545
12588
  const allMems = allMemsForGraph ?? [];
12546
12589
  for (const m of allMems) {
12547
12590
  if (m.frontmatter.entityRef === entityRef) {
12548
- const rel = path12.relative(storage.dir, m.path);
12591
+ const rel = path14.relative(storage.dir, m.path);
12549
12592
  if (rel !== memoryRelPath) entitySiblings.push(rel);
12550
12593
  }
12551
12594
  }
@@ -12694,7 +12737,7 @@ var PersistenceIndexCoordinator = class {
12694
12737
 
12695
12738
  // src/orchestration/workspace-ops.ts
12696
12739
  import { lstat, mkdir as mkdir6, readFile as readFile5, readdir as readdir3, realpath, writeFile as writeFile6 } from "fs/promises";
12697
- import path13 from "path";
12740
+ import path15 from "path";
12698
12741
 
12699
12742
  // src/maintenance/pattern-reinforcement.ts
12700
12743
  function patternReinforcementKey(content) {
@@ -13865,10 +13908,12 @@ async function writeMeetingEpisodeMemory(record, writer) {
13865
13908
  if (envelope.salvageNotes.length > 0) {
13866
13909
  log.warn(`meeting episode write salvaged invalid fields: ${envelope.salvageNotes.join("; ")}`);
13867
13910
  }
13911
+ const titleIsPersonalClaim = record.title !== void 0 && record.title.length > 0 && isHighImpactPersonalFact({ category: "fact", content: record.title });
13912
+ const uncorroboratedDetection = record.detectionSource === "audio";
13868
13913
  await writer.writeSealedMemory(envelope, {
13869
13914
  importance: scoreImportance(content, "moment", [MEETING_SOURCE_PREFIX]),
13870
13915
  contentHashSource: content,
13871
- status: "active",
13916
+ status: titleIsPersonalClaim || uncorroboratedDetection ? "pending_review" : "active",
13872
13917
  memoryKind: "episode"
13873
13918
  });
13874
13919
  return true;
@@ -13924,14 +13969,16 @@ async function writeMeetingFact(record, candidate, status, writer) {
13924
13969
  });
13925
13970
  }
13926
13971
  var SUMMARY_FACT_CONFIDENCE = 0.8;
13927
- function resolveMeetingFactOutcome(config, trust, judgeVerdict) {
13972
+ function resolveMeetingFactOutcome(config, trust, judgeVerdict, claim) {
13928
13973
  if (config.summaryMode === "review") {
13929
13974
  return judgeVerdict === "reject" ? "drop" : "review";
13930
13975
  }
13931
- return decideSmart(trust, judgeVerdict, {
13932
- autoApproveTrust: config.autoApproveTrust,
13933
- reviewTrust: config.reviewTrust
13934
- }).outcome;
13976
+ return decideSmart(
13977
+ trust,
13978
+ judgeVerdict,
13979
+ { autoApproveTrust: config.autoApproveTrust, reviewTrust: config.reviewTrust },
13980
+ { capAtReview: isHighImpactPersonalFact(claim) }
13981
+ ).outcome;
13935
13982
  }
13936
13983
  async function generateMeetingSummaryFacts(record, config, deps) {
13937
13984
  const empty = {
@@ -13978,7 +14025,7 @@ async function generateMeetingSummaryFacts(record, config, deps) {
13978
14025
  judgeVerdict,
13979
14026
  evidence
13980
14027
  });
13981
- const outcome = resolveMeetingFactOutcome(config, trust, judgeVerdict);
14028
+ const outcome = resolveMeetingFactOutcome(config, trust, judgeVerdict, candidate);
13982
14029
  if (outcome === "drop") {
13983
14030
  result.dropped++;
13984
14031
  continue;
@@ -14003,7 +14050,10 @@ async function generateMeetingSummaryFacts(record, config, deps) {
14003
14050
  sourceTrust: config.sourceTrust,
14004
14051
  evidence
14005
14052
  });
14006
- const outcome = resolveMeetingFactOutcome(config, summaryTrust, void 0);
14053
+ const outcome = resolveMeetingFactOutcome(config, summaryTrust, void 0, {
14054
+ category: "fact",
14055
+ content: summaryText
14056
+ });
14007
14057
  if (outcome === "drop") {
14008
14058
  result.dropped++;
14009
14059
  } else {
@@ -14122,7 +14172,8 @@ Rules:
14122
14172
  - decisions: concrete choices the group made. Omit hypotheticals and discussion that led nowhere.
14123
14173
  - commitments: owner-bearing action items only. If there is no clear owner, omit it.
14124
14174
  - openQuestions: genuinely unresolved questions, not rhetorical asides.
14125
- - Prefer fewer, higher-quality items. Use [] for any empty list. Never invent content the transcript does not support.`;
14175
+ - Prefer fewer, higher-quality items. Use [] for any empty list. Never invent content the transcript does not support.
14176
+ ${AMBIENT_CAPTURE_PROMPT_RULE}`;
14126
14177
  var DECISION_CONFIDENCE = 0.8;
14127
14178
  var COMMITMENT_CONFIDENCE = 0.8;
14128
14179
  var QUESTION_CONFIDENCE = 0.6;
@@ -14593,8 +14644,8 @@ var MeetingsService = class {
14593
14644
  // src/orchestration/workspace-ops.ts
14594
14645
  var MEETINGS_BUILD_DEBOUNCE_MS = 5e3;
14595
14646
  function matchesMemoryPath(candidatePath, requestedPath, memoryDir) {
14596
- const normalizedCandidate = path13.resolve(candidatePath);
14597
- return normalizedCandidate === path13.resolve(requestedPath) || normalizedCandidate === path13.resolve(memoryDir, requestedPath);
14647
+ const normalizedCandidate = path15.resolve(candidatePath);
14648
+ return normalizedCandidate === path15.resolve(requestedPath) || normalizedCandidate === path15.resolve(memoryDir, requestedPath);
14598
14649
  }
14599
14650
  function accessTrackingPathCandidates(storageDir, memoryPath) {
14600
14651
  const candidates = qmdResultPathCandidates(storageDir, memoryPath);
@@ -14602,12 +14653,12 @@ function accessTrackingPathCandidates(storageDir, memoryPath) {
14602
14653
  if (!parts) return candidates;
14603
14654
  candidates.push(
14604
14655
  ...qmdResultPathCandidates(storageDir, parts.relativePath),
14605
- ...qmdResultPathCandidates(path13.join(storageDir, "cold"), parts.relativePath)
14656
+ ...qmdResultPathCandidates(path15.join(storageDir, "cold"), parts.relativePath)
14606
14657
  );
14607
14658
  return [...new Set(candidates)];
14608
14659
  }
14609
14660
  function canonicalMemoryPath(memoryPath, memoryDir) {
14610
- return path13.resolve(path13.isAbsolute(memoryPath) ? memoryPath : path13.resolve(memoryDir, memoryPath));
14661
+ return path15.resolve(path15.isAbsolute(memoryPath) ? memoryPath : path15.resolve(memoryDir, memoryPath));
14611
14662
  }
14612
14663
  var WorkspaceOpsCoordinator = class {
14613
14664
  constructor(deps) {
@@ -14689,15 +14740,15 @@ var WorkspaceOpsCoordinator = class {
14689
14740
  this.deps.lastFileHygieneRunAtMs = now;
14690
14741
  if (hygiene.rotateEnabled) {
14691
14742
  for (const rel of hygiene.rotatePaths) {
14692
- const abs = path13.isAbsolute(rel) ? rel : path13.join(this.deps.config.workspaceDir, rel);
14743
+ const abs = path15.isAbsolute(rel) ? rel : path15.join(this.deps.config.workspaceDir, rel);
14693
14744
  try {
14694
14745
  const raw = await readFile5(abs, "utf-8");
14695
14746
  if (raw.length > hygiene.rotateMaxBytes) {
14696
- const archiveDir = path13.join(
14747
+ const archiveDir = path15.join(
14697
14748
  this.deps.config.workspaceDir,
14698
14749
  hygiene.archiveDir
14699
14750
  );
14700
- const base = path13.basename(abs);
14751
+ const base = path15.basename(abs);
14701
14752
  const prefix = base.toUpperCase().replace(/\.MD$/i, "").replace(/[^A-Z0-9]+/g, "-") || "FILE";
14702
14753
  const { newContent } = await rotateMarkdownFileToArchive({
14703
14754
  filePath: abs,
@@ -14722,8 +14773,8 @@ var WorkspaceOpsCoordinator = class {
14722
14773
  log.warn(w.message);
14723
14774
  }
14724
14775
  if (hygiene.warningsLogEnabled && warnings.length > 0) {
14725
- const fp = path13.join(this.deps.config.memoryDir, hygiene.warningsLogPath);
14726
- await mkdir6(path13.dirname(fp), { recursive: true });
14776
+ const fp = path15.join(this.deps.config.memoryDir, hygiene.warningsLogPath);
14777
+ await mkdir6(path15.dirname(fp), { recursive: true });
14727
14778
  const stamp = (/* @__PURE__ */ new Date()).toISOString();
14728
14779
  const block = `
14729
14780
 
@@ -14763,7 +14814,7 @@ var WorkspaceOpsCoordinator = class {
14763
14814
  for (const categoryDir of RECALL_FALLBACK_DIRS) {
14764
14815
  if (memoryRootReal === null) break;
14765
14816
  for (const date of datesToScan) {
14766
- const dateDir = path13.join(storage.dir, categoryDir, date);
14817
+ const dateDir = path15.join(storage.dir, categoryDir, date);
14767
14818
  try {
14768
14819
  const dirStat = await lstat(dateDir);
14769
14820
  if (dirStat.isSymbolicLink() || !dirStat.isDirectory()) continue;
@@ -14772,7 +14823,7 @@ var WorkspaceOpsCoordinator = class {
14772
14823
  for (const entry of entries) {
14773
14824
  if (entry.isSymbolicLink()) continue;
14774
14825
  if (!entry.name.endsWith(".md")) continue;
14775
- const fullPath = path13.join(dateDir, entry.name);
14826
+ const fullPath = path15.join(dateDir, entry.name);
14776
14827
  try {
14777
14828
  assertPathInsideRoot(memoryRootReal, await realpath(fullPath), fullPath);
14778
14829
  const raw = await readFile5(fullPath, "utf-8");
@@ -14794,7 +14845,7 @@ var WorkspaceOpsCoordinator = class {
14794
14845
  facts.push({
14795
14846
  path: fullPath,
14796
14847
  frontmatter: {
14797
- id: fm.id || path13.basename(entry.name, ".md"),
14848
+ id: fm.id || path15.basename(entry.name, ".md"),
14798
14849
  category: fm.category || "fact",
14799
14850
  created,
14800
14851
  updated: fm.updated || created,
@@ -14817,13 +14868,13 @@ var WorkspaceOpsCoordinator = class {
14817
14868
  return a.frontmatter.created < b.frontmatter.created ? -1 : 1;
14818
14869
  });
14819
14870
  const hourlySummaries = [];
14820
- const hourlyBaseDir = path13.join(storage.dir, "summaries", "hourly");
14871
+ const hourlyBaseDir = path15.join(storage.dir, "summaries", "hourly");
14821
14872
  try {
14822
14873
  const sessionKeys = await readdir3(hourlyBaseDir, { withFileTypes: true });
14823
14874
  for (const sk of sessionKeys) {
14824
14875
  if (!sk.isDirectory()) continue;
14825
14876
  for (const date of datesToScan) {
14826
- const summaryFile = path13.join(hourlyBaseDir, sk.name, `${date}.md`);
14877
+ const summaryFile = path15.join(hourlyBaseDir, sk.name, `${date}.md`);
14827
14878
  try {
14828
14879
  const raw = await readFile5(summaryFile, "utf-8");
14829
14880
  const filtered = filterHourlySummaryMarkdownForLocalDay(
@@ -15287,18 +15338,18 @@ ${reflectionsContent.trim()}
15287
15338
  // src/orchestration/namespace-read-fanout.ts
15288
15339
  import { existsSync, readFileSync } from "fs";
15289
15340
  import { stat as stat3 } from "fs/promises";
15290
- import path15 from "path";
15341
+ import path17 from "path";
15291
15342
 
15292
15343
  // src/orchestration/orchestrator-namespace-scope.ts
15293
- import path14 from "path";
15344
+ import path16 from "path";
15294
15345
  function computeSemanticDedupScope(targetStorage, config) {
15295
15346
  if (!resolveNamespaceCapabilities(config).namespaces) return {};
15296
- const memoryDir = path14.resolve(config.memoryDir);
15297
- const storageDir = path14.resolve(targetStorage.dir);
15347
+ const memoryDir = path16.resolve(config.memoryDir);
15348
+ const storageDir = path16.resolve(targetStorage.dir);
15298
15349
  if (storageDir === memoryDir) {
15299
15350
  return { pathExcludePrefixes: ["namespaces/"] };
15300
15351
  }
15301
- let rel = path14.relative(memoryDir, storageDir);
15352
+ let rel = path16.relative(memoryDir, storageDir);
15302
15353
  if (!rel || rel.startsWith("..")) {
15303
15354
  log.debug(
15304
15355
  `semantic dedup: target storage dir ${storageDir} is outside memoryDir ${memoryDir}; scoping lookup to absolute path prefix`
@@ -15351,7 +15402,7 @@ var NamespaceReadFanoutCoordinator = class {
15351
15402
  loadNamespaceStorageDirHintsFromCatalog() {
15352
15403
  if (this.deps.namespaceStorageDirHintsLoaded || !this.deps.namespaceCatalog.enabled) return;
15353
15404
  this.deps.namespaceStorageDirHintsLoaded = true;
15354
- const catalogPath = path15.join(this.deps.config.memoryDir, "state", "namespaces.jsonl");
15405
+ const catalogPath = path17.join(this.deps.config.memoryDir, "state", "namespaces.jsonl");
15355
15406
  if (!existsSync(catalogPath)) return;
15356
15407
  let body;
15357
15408
  try {
@@ -15388,7 +15439,7 @@ var NamespaceReadFanoutCoordinator = class {
15388
15439
  if (!this.deps.storageDirMatchesNamespaceHint(record.namespace, record.storageDir)) {
15389
15440
  continue;
15390
15441
  }
15391
- const resolvedStorageDir = path15.resolve(record.storageDir);
15442
+ const resolvedStorageDir = path17.resolve(record.storageDir);
15392
15443
  const current = preferredByStorageDir.get(resolvedStorageDir);
15393
15444
  preferredByStorageDir.set(
15394
15445
  resolvedStorageDir,
@@ -15569,12 +15620,12 @@ var NamespaceReadFanoutCoordinator = class {
15569
15620
  }
15570
15621
  async resolveStateDirForNamespace(namespace) {
15571
15622
  if (!resolveNamespaceCapabilities(this.deps.config).namespaces) {
15572
- return path15.join(this.deps.config.memoryDir, "state");
15623
+ return path17.join(this.deps.config.memoryDir, "state");
15573
15624
  }
15574
15625
  if (namespace !== this.deps.config.defaultNamespace) {
15575
- return path15.join(this.deps.config.memoryDir, "namespaces", namespace, "state");
15626
+ return path17.join(this.deps.config.memoryDir, "namespaces", namespace, "state");
15576
15627
  }
15577
- const candidate = path15.join(
15628
+ const candidate = path17.join(
15578
15629
  this.deps.config.memoryDir,
15579
15630
  "namespaces",
15580
15631
  this.deps.config.defaultNamespace
@@ -15582,11 +15633,11 @@ var NamespaceReadFanoutCoordinator = class {
15582
15633
  try {
15583
15634
  const candidateStat = await stat3(candidate);
15584
15635
  if (candidateStat.isDirectory()) {
15585
- return path15.join(candidate, "state");
15636
+ return path17.join(candidate, "state");
15586
15637
  }
15587
15638
  } catch {
15588
15639
  }
15589
- return path15.join(this.deps.config.memoryDir, "state");
15640
+ return path17.join(this.deps.config.memoryDir, "state");
15590
15641
  }
15591
15642
  namespaceFromPath(p) {
15592
15643
  if (!resolveNamespaceCapabilities(this.deps.config).namespaces) return this.deps.config.defaultNamespace;
@@ -15977,7 +16028,7 @@ var Orchestrator = class {
15977
16028
  rerankCache = new RerankCache();
15978
16029
  /**
15979
16030
  * Per-session workspace selections keyed by sessionKey.
15980
- * Set by the before_agent_start hook so recall() uses the correct
16031
+ * Set by the before_prompt_build hook so recall() uses the correct
15981
16032
  * agent workspace for BOOT.md injection. Cleared after each recall.
15982
16033
  * Using a Map prevents concurrent sessions from overwriting each other.
15983
16034
  */
@@ -16365,7 +16416,7 @@ var Orchestrator = class {
16365
16416
  const defaultNs = normalizeNamespaceIdentity(this.config.defaultNamespace);
16366
16417
  if (ns !== defaultNs && !isSafeRouteNamespace(ns)) return;
16367
16418
  if (!this.storageDirMatchesNamespaceHint(ns, storageDir)) return;
16368
- const resolvedStorageDir = path16.resolve(storageDir);
16419
+ const resolvedStorageDir = path18.resolve(storageDir);
16369
16420
  let hints = this.namespaceStorageDirHints.get(resolvedStorageDir);
16370
16421
  if (!hints) {
16371
16422
  hints = /* @__PURE__ */ new Set();
@@ -16376,21 +16427,21 @@ var Orchestrator = class {
16376
16427
  storageDirMatchesNamespaceHint(namespace, storageDir) {
16377
16428
  const ns = normalizeNamespaceIdentity(namespace);
16378
16429
  if (!ns) return false;
16379
- const resolvedStorageDir = path16.resolve(storageDir);
16380
- const resolvedMemoryDir = path16.resolve(this.config.memoryDir);
16430
+ const resolvedStorageDir = path18.resolve(storageDir);
16431
+ const resolvedMemoryDir = path18.resolve(this.config.memoryDir);
16381
16432
  const defaultNs = normalizeNamespaceIdentity(this.config.defaultNamespace);
16382
16433
  if (resolvedStorageDir === resolvedMemoryDir) return ns === defaultNs;
16383
- const resolvedNamespacesDir = path16.join(resolvedMemoryDir, "namespaces");
16434
+ const resolvedNamespacesDir = path18.join(resolvedMemoryDir, "namespaces");
16384
16435
  if (!isPathInsideStorageRoot(resolvedNamespacesDir, resolvedStorageDir)) return false;
16385
- const rawRoot = path16.resolve(resolvedNamespacesDir, ns);
16386
- const tokenRoot = path16.resolve(resolvedNamespacesDir, namespaceIdentityToken(ns));
16436
+ const rawRoot = path18.resolve(resolvedNamespacesDir, ns);
16437
+ const tokenRoot = path18.resolve(resolvedNamespacesDir, namespaceIdentityToken(ns));
16387
16438
  return resolvedStorageDir === rawRoot || resolvedStorageDir === tokenRoot;
16388
16439
  }
16389
16440
  namespaceStorageDirHintOwnershipRank(record, resolvedStorageDir, configured) {
16390
- if (resolvedStorageDir === path16.resolve(this.config.memoryDir)) {
16441
+ if (resolvedStorageDir === path18.resolve(this.config.memoryDir)) {
16391
16442
  return record.namespace === normalizeNamespaceIdentity(this.config.defaultNamespace) ? 0 : 3;
16392
16443
  }
16393
- const leaf = path16.basename(resolvedStorageDir);
16444
+ const leaf = path18.basename(resolvedStorageDir);
16394
16445
  const tokenOwnsRoot = namespaceIdentityToken(record.namespace) === leaf;
16395
16446
  if (tokenOwnsRoot && configured.has(record.namespace)) return 0;
16396
16447
  if (record.namespace === leaf) return 1;
@@ -16530,7 +16581,7 @@ var Orchestrator = class {
16530
16581
  StorageManager.setScopedCacheInvalidationDefault(config.memoryDir, scopedCacheInvalidationEnabled);
16531
16582
  this.profiler = new ProfilingCollector({
16532
16583
  enabled: resolvePipelineProcessingCapabilities(this.config).profiling,
16533
- storageDir: config.profilingStorageDir || path16.join(config.memoryDir, "profiling"),
16584
+ storageDir: config.profilingStorageDir || path18.join(config.memoryDir, "profiling"),
16534
16585
  maxTraces: config.profilingMaxTraces
16535
16586
  });
16536
16587
  this.namespaceCatalog = new NamespaceCatalog(config);
@@ -16617,7 +16668,7 @@ var Orchestrator = class {
16617
16668
  this.compounding = resolveConsolidationCapabilities(config).compounding ? new CompoundingEngine(config, this.storage) : void 0;
16618
16669
  this.buffer = new SmartBuffer(config, this.storage);
16619
16670
  this.transcript = new TranscriptManager(config);
16620
- this.conversationIndexDir = path16.join(
16671
+ this.conversationIndexDir = path18.join(
16621
16672
  config.memoryDir,
16622
16673
  "conversation-index",
16623
16674
  "chunks"
@@ -16764,7 +16815,7 @@ var Orchestrator = class {
16764
16815
  saveContentHashIndexes: () => this.saveContentHashIndexes()
16765
16816
  });
16766
16817
  this.threading = new ThreadingManager(
16767
- path16.join(config.memoryDir, "threads"),
16818
+ path18.join(config.memoryDir, "threads"),
16768
16819
  config.threadingGapMinutes
16769
16820
  );
16770
16821
  const lifecycleCaps = resolveMemoryLifecycleCapabilities(config);
@@ -18870,9 +18921,9 @@ function readStructuralSymbol(entry) {
18870
18921
  const rec = entry;
18871
18922
  const symbol = typeof rec.symbol === "string" ? rec.symbol.trim() : "";
18872
18923
  if (!symbol) return null;
18873
- const path31 = typeof rec.path === "string" && rec.path.length > 0 ? rec.path : void 0;
18924
+ const path33 = typeof rec.path === "string" && rec.path.length > 0 ? rec.path : void 0;
18874
18925
  const kind = typeof rec.kind === "string" && rec.kind.length > 0 ? rec.kind : void 0;
18875
- const item = path31 !== void 0 && kind !== void 0 ? { symbol, path: path31, kind } : path31 !== void 0 ? { symbol, path: path31 } : kind !== void 0 ? { symbol, kind } : { symbol };
18926
+ const item = path33 !== void 0 && kind !== void 0 ? { symbol, path: path33, kind } : path33 !== void 0 ? { symbol, path: path33 } : kind !== void 0 ? { symbol, kind } : { symbol };
18876
18927
  return item;
18877
18928
  }
18878
18929
  function classifySpawnError(err) {
@@ -18946,7 +18997,7 @@ var DEFAULT_GRACE_PERIOD_DAYS = 7;
18946
18997
 
18947
18998
  // src/binary-lifecycle/backend.ts
18948
18999
  import fsp from "fs/promises";
18949
- import path17 from "path";
19000
+ import path19 from "path";
18950
19001
  var FilesystemBackend = class {
18951
19002
  type = "filesystem";
18952
19003
  basePath;
@@ -18954,19 +19005,19 @@ var FilesystemBackend = class {
18954
19005
  if (!basePath || basePath.trim().length === 0) {
18955
19006
  throw new Error("FilesystemBackend requires a non-empty basePath");
18956
19007
  }
18957
- this.basePath = path17.resolve(basePath);
19008
+ this.basePath = path19.resolve(basePath);
18958
19009
  }
18959
19010
  resolveRemotePath(remotePath) {
18960
- const resolved = path17.isAbsolute(remotePath) ? path17.resolve(remotePath) : path17.resolve(this.basePath, remotePath);
18961
- const relative = path17.relative(this.basePath, resolved);
18962
- if (relative === ".." || relative.startsWith(`..${path17.sep}`) || path17.isAbsolute(relative)) {
19011
+ const resolved = path19.isAbsolute(remotePath) ? path19.resolve(remotePath) : path19.resolve(this.basePath, remotePath);
19012
+ const relative = path19.relative(this.basePath, resolved);
19013
+ if (relative === ".." || relative.startsWith(`..${path19.sep}`) || path19.isAbsolute(relative)) {
18963
19014
  throw new Error(`FilesystemBackend remotePath escapes basePath: ${JSON.stringify(remotePath)}`);
18964
19015
  }
18965
19016
  return resolved;
18966
19017
  }
18967
19018
  isInsideBase(candidate, realBase) {
18968
- const relative = path17.relative(realBase, candidate);
18969
- return relative === "" || relative !== ".." && !relative.startsWith(`..${path17.sep}`) && !path17.isAbsolute(relative);
19019
+ const relative = path19.relative(realBase, candidate);
19020
+ return relative === "" || relative !== ".." && !relative.startsWith(`..${path19.sep}`) && !path19.isAbsolute(relative);
18970
19021
  }
18971
19022
  async realBasePathIfExists() {
18972
19023
  try {
@@ -18995,13 +19046,13 @@ var FilesystemBackend = class {
18995
19046
  }
18996
19047
  async ensureSafeParentDirectory(dest) {
18997
19048
  const realBase = await this.ensureBaseDirectory();
18998
- const destDir = path17.dirname(dest);
18999
- const relativeDir = path17.relative(this.basePath, destDir);
19000
- const segments = relativeDir === "" ? [] : relativeDir.split(path17.sep);
19049
+ const destDir = path19.dirname(dest);
19050
+ const relativeDir = path19.relative(this.basePath, destDir);
19051
+ const segments = relativeDir === "" ? [] : relativeDir.split(path19.sep);
19001
19052
  let current = this.basePath;
19002
19053
  for (const segment of segments) {
19003
19054
  if (segment === "." || segment === "") continue;
19004
- current = path17.join(current, segment);
19055
+ current = path19.join(current, segment);
19005
19056
  try {
19006
19057
  const stat5 = await fsp.lstat(current);
19007
19058
  if (stat5.isSymbolicLink()) {
@@ -19029,13 +19080,13 @@ var FilesystemBackend = class {
19029
19080
  if (realBase === null) {
19030
19081
  return null;
19031
19082
  }
19032
- const destDir = path17.dirname(dest);
19033
- const relativeDir = path17.relative(this.basePath, destDir);
19034
- const segments = relativeDir === "" ? [] : relativeDir.split(path17.sep);
19083
+ const destDir = path19.dirname(dest);
19084
+ const relativeDir = path19.relative(this.basePath, destDir);
19085
+ const segments = relativeDir === "" ? [] : relativeDir.split(path19.sep);
19035
19086
  let current = this.basePath;
19036
19087
  for (const segment of segments) {
19037
19088
  if (segment === "." || segment === "") continue;
19038
- current = path17.join(current, segment);
19089
+ current = path19.join(current, segment);
19039
19090
  let stat5;
19040
19091
  try {
19041
19092
  stat5 = await fsp.lstat(current);
@@ -19083,7 +19134,7 @@ var FilesystemBackend = class {
19083
19134
  return dest;
19084
19135
  }
19085
19136
  async upload(localPath, remotePath) {
19086
- if (path17.isAbsolute(remotePath)) {
19137
+ if (path19.isAbsolute(remotePath)) {
19087
19138
  throw new Error(`FilesystemBackend upload remotePath must be relative: ${JSON.stringify(remotePath)}`);
19088
19139
  }
19089
19140
  const dest = this.resolveRemotePath(remotePath);
@@ -19156,7 +19207,7 @@ function createBackend(cfg) {
19156
19207
 
19157
19208
  // src/binary-lifecycle/scanner.ts
19158
19209
  import fsp2 from "fs/promises";
19159
- import path18 from "path";
19210
+ import path20 from "path";
19160
19211
  import crypto from "crypto";
19161
19212
  function matchesPatterns(filename, patterns) {
19162
19213
  const lower = filename.toLowerCase();
@@ -19181,8 +19232,8 @@ async function scanForBinaries(memoryDir, config, manifest) {
19181
19232
  return;
19182
19233
  }
19183
19234
  for (const entry of entries) {
19184
- const fullPath = path18.join(dir, entry.name);
19185
- const relativePath = path18.relative(memoryDir, fullPath).split(path18.sep).join("/");
19235
+ const fullPath = path20.join(dir, entry.name);
19236
+ const relativePath = path20.relative(memoryDir, fullPath).split(path20.sep).join("/");
19186
19237
  if (entry.isDirectory()) {
19187
19238
  if (entry.name === ".binary-lifecycle") continue;
19188
19239
  await walk(fullPath);
@@ -19222,15 +19273,15 @@ async function hashFile(filePath) {
19222
19273
 
19223
19274
  // src/binary-lifecycle/manifest.ts
19224
19275
  import fsp3 from "fs/promises";
19225
- import path19 from "path";
19276
+ import path21 from "path";
19226
19277
  import crypto2 from "crypto";
19227
19278
  var MANIFEST_DIR = ".binary-lifecycle";
19228
19279
  var MANIFEST_FILE = "manifest.json";
19229
19280
  function manifestDir(memoryDir) {
19230
- return path19.join(memoryDir, MANIFEST_DIR);
19281
+ return path21.join(memoryDir, MANIFEST_DIR);
19231
19282
  }
19232
19283
  function manifestPath(memoryDir) {
19233
- return path19.join(memoryDir, MANIFEST_DIR, MANIFEST_FILE);
19284
+ return path21.join(memoryDir, MANIFEST_DIR, MANIFEST_FILE);
19234
19285
  }
19235
19286
  async function readManifest(memoryDir) {
19236
19287
  const filePath = manifestPath(memoryDir);
@@ -19282,13 +19333,13 @@ function emptyManifest() {
19282
19333
 
19283
19334
  // src/binary-lifecycle/pipeline.ts
19284
19335
  import fsp4 from "fs/promises";
19285
- import path20 from "path";
19336
+ import path22 from "path";
19286
19337
  import crypto3 from "crypto";
19287
19338
  var historicalIdCache = new HistoricalEntityCanonicalIdCache();
19288
19339
  function isRecallCorpusMarkdown(mdPath, memoryDir) {
19289
- const rel = path20.relative(memoryDir, mdPath);
19290
- if (rel.startsWith("..") || path20.isAbsolute(rel)) return false;
19291
- const top = rel.split(path20.sep)[0];
19340
+ const rel = path22.relative(memoryDir, mdPath);
19341
+ if (rel.startsWith("..") || path22.isAbsolute(rel)) return false;
19342
+ const top = rel.split(path22.sep)[0];
19292
19343
  return RECALL_FALLBACK_DIRS.includes(top);
19293
19344
  }
19294
19345
  async function hashFile2(filePath) {
@@ -19312,13 +19363,13 @@ function escapeRegex(s) {
19312
19363
  return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
19313
19364
  }
19314
19365
  function resolveManifestAssetPath(memoryDir, originalPath) {
19315
- if (originalPath.length === 0 || originalPath.includes("\0") || originalPath.includes("\\") || path20.isAbsolute(originalPath) || path20.win32.isAbsolute(originalPath)) {
19366
+ if (originalPath.length === 0 || originalPath.includes("\0") || originalPath.includes("\\") || path22.isAbsolute(originalPath) || path22.win32.isAbsolute(originalPath)) {
19316
19367
  return null;
19317
19368
  }
19318
- const memoryRoot = path20.resolve(memoryDir);
19319
- const fullPath = path20.resolve(memoryRoot, originalPath);
19320
- const relative = path20.relative(memoryRoot, fullPath);
19321
- if (relative === "" || relative === ".." || relative.startsWith(`..${path20.sep}`) || path20.isAbsolute(relative)) {
19369
+ const memoryRoot = path22.resolve(memoryDir);
19370
+ const fullPath = path22.resolve(memoryRoot, originalPath);
19371
+ const relative = path22.relative(memoryRoot, fullPath);
19372
+ if (relative === "" || relative === ".." || relative.startsWith(`..${path22.sep}`) || path22.isAbsolute(relative)) {
19322
19373
  return null;
19323
19374
  }
19324
19375
  return fullPath;
@@ -19329,7 +19380,7 @@ function validateBinaryLifecycleConfig(config) {
19329
19380
  }
19330
19381
  }
19331
19382
  function remotePathForAsset(backend, relPath) {
19332
- const normalized = relPath.split(path20.sep).join("/");
19383
+ const normalized = relPath.split(path22.sep).join("/");
19333
19384
  if (backend.type === "filesystem") {
19334
19385
  return `.binary-lifecycle/mirrors/${normalized}`;
19335
19386
  }
@@ -19342,11 +19393,11 @@ async function stageMirror(memoryDir, newPaths, backend, assets, log2, dryRun) {
19342
19393
  let mirrored = 0;
19343
19394
  const errors = [];
19344
19395
  for (const relPath of newPaths) {
19345
- const fullPath = path20.join(memoryDir, relPath);
19396
+ const fullPath = path22.join(memoryDir, relPath);
19346
19397
  try {
19347
19398
  const stat5 = await fsp4.stat(fullPath);
19348
19399
  const contentHash = await hashFile2(fullPath);
19349
- const ext = path20.extname(relPath);
19400
+ const ext = path22.extname(relPath);
19350
19401
  const mimeType = guessMimeType(ext);
19351
19402
  const remotePath = remotePathForAsset(backend, relPath);
19352
19403
  let backendLocation = remotePath;
@@ -19484,7 +19535,7 @@ async function stageRedirect(memoryDir, assets, log2, dryRun, readMarkdownFile,
19484
19535
  for (const update of updates) {
19485
19536
  try {
19486
19537
  await withRawEntityPageMutation(memoryDir, update.mdPath, async () => {
19487
- const stateDir = path20.join(memoryDir, "state");
19538
+ const stateDir = path22.join(memoryDir, "state");
19488
19539
  const kind = classifyEntityRefWritePath(memoryDir, update.mdPath);
19489
19540
  if (kind === "memory") {
19490
19541
  const idsAtWrite = historicalIdCache.get(stateDir);
@@ -19578,10 +19629,10 @@ async function countRemainingLocalReferences(memoryDir, asset, assetAbsolute, md
19578
19629
  return { remaining, errors };
19579
19630
  }
19580
19631
  function markdownReferencePattern(asset, assetAbsolute, mdPath) {
19581
- const mdDir = path20.dirname(mdPath);
19632
+ const mdDir = path22.dirname(mdPath);
19582
19633
  const candidates = /* @__PURE__ */ new Set();
19583
19634
  const addCandidate = (candidate) => {
19584
- const normalized = candidate.split(path20.sep).join("/");
19635
+ const normalized = candidate.split(path22.sep).join("/");
19585
19636
  if (normalized.length === 0) return;
19586
19637
  candidates.add(normalized);
19587
19638
  const isParentTraversal = normalized === ".." || normalized.startsWith("../");
@@ -19589,10 +19640,10 @@ function markdownReferencePattern(asset, assetAbsolute, mdPath) {
19589
19640
  candidates.add(`./${normalized}`);
19590
19641
  }
19591
19642
  };
19592
- addCandidate(path20.relative(mdDir, assetAbsolute));
19593
- const originalPath = asset.originalPath.split(path20.sep).join("/");
19594
- const originalAsFileRelative = path20.resolve(mdDir, ...originalPath.split("/"));
19595
- if (path20.resolve(originalAsFileRelative) === path20.resolve(assetAbsolute)) {
19643
+ addCandidate(path22.relative(mdDir, assetAbsolute));
19644
+ const originalPath = asset.originalPath.split(path22.sep).join("/");
19645
+ const originalAsFileRelative = path22.resolve(mdDir, ...originalPath.split("/"));
19646
+ if (path22.resolve(originalAsFileRelative) === path22.resolve(assetAbsolute)) {
19596
19647
  addCandidate(originalPath);
19597
19648
  }
19598
19649
  addCandidate(`/${originalPath}`);
@@ -19688,7 +19739,7 @@ async function findMarkdownFiles(dir) {
19688
19739
  return;
19689
19740
  }
19690
19741
  for (const entry of entries) {
19691
- const full = path20.join(current, entry.name);
19742
+ const full = path22.join(current, entry.name);
19692
19743
  if (entry.isDirectory()) {
19693
19744
  if (entry.name === ".binary-lifecycle") continue;
19694
19745
  await walk(full);
@@ -19763,7 +19814,7 @@ async function runBinaryLifecyclePipeline(memoryDir, config, backend, log2, opts
19763
19814
 
19764
19815
  // src/projection/index.ts
19765
19816
  import fs from "fs";
19766
- import path21 from "path";
19817
+ import path23 from "path";
19767
19818
  var VALID_PROJECTION_CATEGORIES = new Set(ALL_CATEGORY_KEYS);
19768
19819
  async function generateContextTree(options) {
19769
19820
  const startTime = Date.now();
@@ -19778,8 +19829,8 @@ async function generateContextTree(options) {
19778
19829
  let nodesGenerated = 0;
19779
19830
  let nodesSkipped = 0;
19780
19831
  const categoryCounts = {};
19781
- const resolvedMemoryDir = path21.resolve(memoryDir);
19782
- const resolvedOutputDir = path21.resolve(outputDir);
19832
+ const resolvedMemoryDir = path23.resolve(memoryDir);
19833
+ const resolvedOutputDir = path23.resolve(outputDir);
19783
19834
  const requestedCategories = validateProjectionCategories(filterCategories);
19784
19835
  const realMemoryDir = assertSafeMemoryRoot(resolvedMemoryDir);
19785
19836
  assertNotSymlink(resolvedOutputDir, "context tree outputDir");
@@ -19817,7 +19868,7 @@ async function generateContextTree(options) {
19817
19868
  }
19818
19869
  }
19819
19870
  if (includeEntities) {
19820
- const entitiesDir = path21.join(memoryDir, "entities");
19871
+ const entitiesDir = path23.join(memoryDir, "entities");
19821
19872
  if (fs.existsSync(entitiesDir)) {
19822
19873
  assertSafeInputRoot(realMemoryDir, entitiesDir, "entities root");
19823
19874
  categoryCounts["entity"] = 0;
@@ -19829,7 +19880,7 @@ async function generateContextTree(options) {
19829
19880
  continue;
19830
19881
  }
19831
19882
  const content = fs.readFileSync(filePath, "utf8");
19832
- const fileName = path21.basename(filePath, ".md");
19883
+ const fileName = path23.basename(filePath, ".md");
19833
19884
  const node = projectEntityNode(fileName, content);
19834
19885
  const outputPath = resolveContainedOutputPath(realOutputDir, "entities", `${fileName}.md`);
19835
19886
  writeProjectedContent(realOutputDir, outputPath, node.content);
@@ -19841,7 +19892,7 @@ async function generateContextTree(options) {
19841
19892
  }
19842
19893
  const shouldIncludeQuestions = includeQuestions && (requestedCategories === void 0 || requestedCategories.includes("question"));
19843
19894
  if (shouldIncludeQuestions) {
19844
- const questionsDir = path21.join(memoryDir, "questions");
19895
+ const questionsDir = path23.join(memoryDir, "questions");
19845
19896
  if (fs.existsSync(questionsDir)) {
19846
19897
  assertSafeInputRoot(realMemoryDir, questionsDir, "questions root");
19847
19898
  categoryCounts["question"] = 0;
@@ -19882,8 +19933,8 @@ async function generateContextTree(options) {
19882
19933
  };
19883
19934
  }
19884
19935
  function isPathInside(root, candidate) {
19885
- const relative = path21.relative(root, candidate);
19886
- return relative === "" || !relative.startsWith("..") && !path21.isAbsolute(relative);
19936
+ const relative = path23.relative(root, candidate);
19937
+ return relative === "" || !relative.startsWith("..") && !path23.isAbsolute(relative);
19887
19938
  }
19888
19939
  function assertNotSymlink(targetPath, label) {
19889
19940
  try {
@@ -19920,12 +19971,12 @@ function assertSafeInputRoot(realMemoryDir, targetPath, label) {
19920
19971
  }
19921
19972
  function assertSafeOutputTarget(realOutputDir, outputPath) {
19922
19973
  let current = realOutputDir;
19923
- const relative = path21.relative(realOutputDir, outputPath);
19924
- if (relative.startsWith("..") || path21.isAbsolute(relative)) {
19974
+ const relative = path23.relative(realOutputDir, outputPath);
19975
+ if (relative.startsWith("..") || path23.isAbsolute(relative)) {
19925
19976
  throw new Error(`context tree output path escapes outputDir: ${outputPath}`);
19926
19977
  }
19927
- for (const segment of relative.split(path21.sep).filter(Boolean)) {
19928
- current = path21.join(current, segment);
19978
+ for (const segment of relative.split(path23.sep).filter(Boolean)) {
19979
+ current = path23.join(current, segment);
19929
19980
  try {
19930
19981
  const stat5 = fs.lstatSync(current);
19931
19982
  if (stat5.isSymbolicLink()) {
@@ -19955,17 +20006,17 @@ function validateProjectionCategories(categories) {
19955
20006
  return validated;
19956
20007
  }
19957
20008
  function resolveContainedOutputPath(outputRoot, ...segments) {
19958
- const resolved = path21.resolve(outputRoot, ...segments);
19959
- const relative = path21.relative(outputRoot, resolved);
19960
- if (relative === "" || !relative.startsWith("..") && !path21.isAbsolute(relative)) {
20009
+ const resolved = path23.resolve(outputRoot, ...segments);
20010
+ const relative = path23.relative(outputRoot, resolved);
20011
+ if (relative === "" || !relative.startsWith("..") && !path23.isAbsolute(relative)) {
19961
20012
  return resolved;
19962
20013
  }
19963
20014
  throw new Error(`context tree output path escapes outputDir: ${segments.join("/")}`);
19964
20015
  }
19965
20016
  function writeProjectedContent(realOutputDir, outputPath, generatedContent) {
19966
20017
  assertSafeOutputTarget(realOutputDir, outputPath);
19967
- fs.mkdirSync(path21.dirname(outputPath), { recursive: true });
19968
- const realParent = fs.realpathSync(path21.dirname(outputPath));
20018
+ fs.mkdirSync(path23.dirname(outputPath), { recursive: true });
20019
+ const realParent = fs.realpathSync(path23.dirname(outputPath));
19969
20020
  if (!isPathInside(realOutputDir, realParent)) {
19970
20021
  throw new Error(`context tree output path escapes outputDir: ${outputPath}`);
19971
20022
  }
@@ -20004,7 +20055,7 @@ function walkR(dir, realMemoryDir) {
20004
20055
  const results = [];
20005
20056
  function walk(directory) {
20006
20057
  for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
20007
- const fullPath = path21.join(directory, entry.name);
20058
+ const fullPath = path23.join(directory, entry.name);
20008
20059
  if (entry.isSymbolicLink()) {
20009
20060
  throw new Error(`context tree input path contains symlink: ${fullPath}`);
20010
20061
  }
@@ -20057,13 +20108,13 @@ function extractBody(content) {
20057
20108
  }
20058
20109
  function projectNode(filePath, category, fm, rawContent) {
20059
20110
  const body = extractBody(rawContent);
20060
- const fileName = path21.basename(filePath, ".md");
20061
- const dateDir = path21.basename(path21.dirname(filePath));
20111
+ const fileName = path23.basename(filePath, ".md");
20112
+ const dateDir = path23.basename(path23.dirname(filePath));
20062
20113
  let relPath;
20063
20114
  if (/^\d{4}-\d{2}-\d{2}$/.test(dateDir)) {
20064
- relPath = path21.join(category, dateDir, `${fileName}.md`);
20115
+ relPath = path23.join(category, dateDir, `${fileName}.md`);
20065
20116
  } else {
20066
- relPath = path21.join(category, `${fileName}.md`);
20117
+ relPath = path23.join(category, `${fileName}.md`);
20067
20118
  }
20068
20119
  const generatedAt = (/* @__PURE__ */ new Date()).toISOString();
20069
20120
  const md = `# ${fm.id}
@@ -20109,7 +20160,7 @@ function projectEntityNode(fileName, content) {
20109
20160
  ${content}
20110
20161
  `;
20111
20162
  return {
20112
- path: path21.join("entities", `${fileName}.md`),
20163
+ path: path23.join("entities", `${fileName}.md`),
20113
20164
  category: "entity",
20114
20165
  title: fileName,
20115
20166
  content: md,
@@ -20162,7 +20213,7 @@ function generateIndex(categoryCounts, outputDir) {
20162
20213
 
20163
20214
  // src/onboarding/index.ts
20164
20215
  import fs2 from "fs";
20165
- import path22 from "path";
20216
+ import path24 from "path";
20166
20217
  var LANGUAGE_RULES = [
20167
20218
  {
20168
20219
  language: "TypeScript",
@@ -20264,7 +20315,7 @@ function onboard(options) {
20264
20315
  maxDepth = 6,
20265
20316
  excludeDirs = []
20266
20317
  } = options;
20267
- const directory = path22.resolve(options.directory ?? process.cwd());
20318
+ const directory = path24.resolve(options.directory ?? process.cwd());
20268
20319
  let rootStat;
20269
20320
  try {
20270
20321
  rootStat = fs2.statSync(directory);
@@ -20306,7 +20357,7 @@ function walkDir(root, exclude, maxDepth) {
20306
20357
  }
20307
20358
  for (const entry of entries) {
20308
20359
  if (exclude.has(entry.name)) continue;
20309
- const fullPath = path22.join(dir, entry.name);
20360
+ const fullPath = path24.join(dir, entry.name);
20310
20361
  if (entry.isDirectory()) {
20311
20362
  walk(fullPath, depth + 1);
20312
20363
  } else if (entry.isFile()) {
@@ -20321,11 +20372,11 @@ function detectLanguages(files, root) {
20321
20372
  const results = [];
20322
20373
  const extCounts = /* @__PURE__ */ new Map();
20323
20374
  for (const f of files) {
20324
- const ext = path22.extname(f).toLowerCase();
20375
+ const ext = path24.extname(f).toLowerCase();
20325
20376
  if (ext) extCounts.set(ext, (extCounts.get(ext) ?? 0) + 1);
20326
20377
  }
20327
20378
  const rootFiles = new Set(
20328
- files.filter((f) => path22.dirname(f) === root).map((f) => path22.basename(f))
20379
+ files.filter((f) => path24.dirname(f) === root).map((f) => path24.basename(f))
20329
20380
  );
20330
20381
  for (const rule of LANGUAGE_RULES) {
20331
20382
  const evidence = [];
@@ -20369,7 +20420,7 @@ function detectLanguages(files, root) {
20369
20420
  }
20370
20421
  function detectShape(files, root) {
20371
20422
  const rootFiles = new Set(
20372
- files.filter((f) => path22.dirname(f) === root).map((f) => path22.basename(f))
20423
+ files.filter((f) => path24.dirname(f) === root).map((f) => path24.basename(f))
20373
20424
  );
20374
20425
  const rootDirs = /* @__PURE__ */ new Set();
20375
20426
  try {
@@ -20380,7 +20431,7 @@ function detectShape(files, root) {
20380
20431
  }
20381
20432
  const evidence = [];
20382
20433
  if (rootFiles.has("package.json")) {
20383
- const pkg = readJsonSafe(path22.join(root, "package.json"));
20434
+ const pkg = readJsonSafe(path24.join(root, "package.json"));
20384
20435
  if (pkg?.workspaces) {
20385
20436
  evidence.push("package.json has workspaces");
20386
20437
  return { shape: "monorepo", evidence };
@@ -20394,13 +20445,13 @@ function detectShape(files, root) {
20394
20445
  evidence.push("workspace manifest found");
20395
20446
  return { shape: "workspace", evidence };
20396
20447
  }
20397
- const cargoToml = readTomlWorkspace(path22.join(root, "Cargo.toml"));
20448
+ const cargoToml = readTomlWorkspace(path24.join(root, "Cargo.toml"));
20398
20449
  if (cargoToml) {
20399
20450
  evidence.push("Cargo.toml has workspace");
20400
20451
  return { shape: "workspace", evidence };
20401
20452
  }
20402
20453
  if (rootFiles.has("package.json")) {
20403
- const pkg = readJsonSafe(path22.join(root, "package.json"));
20454
+ const pkg = readJsonSafe(path24.join(root, "package.json"));
20404
20455
  if (pkg?.exports || pkg?.main) {
20405
20456
  if (pkg?.bin) {
20406
20457
  evidence.push("package.json has bin");
@@ -20434,8 +20485,8 @@ function discoverDocs(files, root) {
20434
20485
  { pattern: /^\.editorconfig$/i, kind: "config" }
20435
20486
  ];
20436
20487
  for (const filePath of files) {
20437
- const basename = path22.basename(filePath).toLowerCase();
20438
- const relPath = path22.relative(root, filePath);
20488
+ const basename = path24.basename(filePath).toLowerCase();
20489
+ const relPath = path24.relative(root, filePath);
20439
20490
  let kind;
20440
20491
  for (const { pattern, kind: k } of docPatterns) {
20441
20492
  if (pattern.test(basename)) {
@@ -20447,7 +20498,7 @@ function discoverDocs(files, root) {
20447
20498
  kind = "docs";
20448
20499
  }
20449
20500
  if (!kind && (basename.endsWith(".md") || basename.endsWith(".mdx"))) {
20450
- if (path22.dirname(relPath) === "." || isUnderDocsDir(relPath)) {
20501
+ if (path24.dirname(relPath) === "." || isUnderDocsDir(relPath)) {
20451
20502
  kind = "docs";
20452
20503
  }
20453
20504
  }
@@ -20468,7 +20519,7 @@ function discoverDocs(files, root) {
20468
20519
  return docs;
20469
20520
  }
20470
20521
  function isUnderDocsDir(relPath) {
20471
- const parts = relPath.split(path22.sep);
20522
+ const parts = relPath.split(path24.sep);
20472
20523
  return parts[0] === "docs" || parts[0] === "doc" || parts[0] === "documentation";
20473
20524
  }
20474
20525
  function buildPlan(languages, shape, docs, _root) {
@@ -20512,7 +20563,7 @@ function readTomlWorkspace(filePath) {
20512
20563
 
20513
20564
  // src/curation/index.ts
20514
20565
  import fs3 from "fs";
20515
- import path23 from "path";
20566
+ import path25 from "path";
20516
20567
  import crypto4 from "crypto";
20517
20568
  async function curate(options) {
20518
20569
  const startTime = Date.now();
@@ -20603,12 +20654,12 @@ function resolveTargets(targetPath) {
20603
20654
  const extensions = /* @__PURE__ */ new Set([".md", ".txt", ".mdx", ".rst"]);
20604
20655
  function walk(dir) {
20605
20656
  for (const entry of fs3.readdirSync(dir, { withFileTypes: true })) {
20606
- const fullPath = path23.join(dir, entry.name);
20657
+ const fullPath = path25.join(dir, entry.name);
20607
20658
  if (entry.isDirectory()) {
20608
20659
  if (entry.name !== "node_modules" && entry.name !== ".git") {
20609
20660
  walk(fullPath);
20610
20661
  }
20611
- } else if (extensions.has(path23.extname(entry.name).toLowerCase())) {
20662
+ } else if (extensions.has(path25.extname(entry.name).toLowerCase())) {
20612
20663
  results.push(fullPath);
20613
20664
  }
20614
20665
  }
@@ -20617,12 +20668,12 @@ function resolveTargets(targetPath) {
20617
20668
  return results;
20618
20669
  }
20619
20670
  function resolveProvenanceRoot(targetPath) {
20620
- const resolvedTarget = path23.resolve(targetPath);
20671
+ const resolvedTarget = path25.resolve(targetPath);
20621
20672
  const stat5 = fs3.statSync(resolvedTarget);
20622
- return stat5.isFile() ? path23.dirname(resolvedTarget) : resolvedTarget;
20673
+ return stat5.isFile() ? path25.dirname(resolvedTarget) : resolvedTarget;
20623
20674
  }
20624
20675
  function extractStatements(content, filePath, projectRoot, source, sourceFileHash, categoryOverride, confidence, entityRef, tags) {
20625
- const relativePath = path23.relative(projectRoot, path23.resolve(filePath)) || path23.basename(filePath);
20676
+ const relativePath = path25.relative(projectRoot, path25.resolve(filePath)) || path25.basename(filePath);
20626
20677
  const statements = [];
20627
20678
  const now = (/* @__PURE__ */ new Date()).toISOString();
20628
20679
  const paragraphs = content.split(/\n{2,}/).map((p) => p.trim()).filter((p) => p.length > 20 && p.length < 2e3);
@@ -20716,7 +20767,7 @@ function loadExistingMemories(memoryDir) {
20716
20767
  if (!fs3.existsSync(memoryDir)) return result;
20717
20768
  const dirs = ALL_CATEGORY_DIRS;
20718
20769
  for (const dir of dirs) {
20719
- const fullDir = path23.join(memoryDir, dir);
20770
+ const fullDir = path25.join(memoryDir, dir);
20720
20771
  if (!fs3.existsSync(fullDir)) continue;
20721
20772
  walkFiles(fullDir, (filePath) => {
20722
20773
  const content = readFileSafe(filePath);
@@ -20739,11 +20790,11 @@ function writeStatement(stmt, memoryDir) {
20739
20790
  const now = /* @__PURE__ */ new Date();
20740
20791
  const dateDir = now.toISOString().split("T")[0];
20741
20792
  const categoryDir = getCategoryDir(memoryDir, stmt.category);
20742
- const dir = path23.join(categoryDir, dateDir);
20793
+ const dir = path25.join(categoryDir, dateDir);
20743
20794
  fs3.mkdirSync(dir, { recursive: true });
20744
20795
  const fileName = `${stmt.category}-${Date.now()}-${stmt.id.slice(0, 8)}.md`;
20745
- const filePath = path23.join(dir, fileName);
20746
- const historicalIds = historicalIdCache2.get(path23.join(memoryDir, "state"));
20796
+ const filePath = path25.join(dir, fileName);
20797
+ const historicalIds = historicalIdCache2.get(path25.join(memoryDir, "state"));
20747
20798
  const rawBody = `${[
20748
20799
  "---",
20749
20800
  `id: ${stmt.id}`,
@@ -20766,7 +20817,7 @@ ${stmt.content}
20766
20817
  fs3.writeFileSync(filePath, body);
20767
20818
  try {
20768
20819
  repairContentAfterJournalMoveSync({
20769
- stateDir: path23.join(memoryDir, "state"),
20820
+ stateDir: path25.join(memoryDir, "state"),
20770
20821
  cache: historicalIdCache2,
20771
20822
  idsAtWrite: historicalIds,
20772
20823
  rawContent: rawBody,
@@ -20827,7 +20878,7 @@ function extractBody2(content) {
20827
20878
  }
20828
20879
  function walkFiles(dir, callback) {
20829
20880
  for (const entry of fs3.readdirSync(dir, { withFileTypes: true })) {
20830
- const fullPath = path23.join(dir, entry.name);
20881
+ const fullPath = path25.join(dir, entry.name);
20831
20882
  if (entry.isDirectory()) {
20832
20883
  walkFiles(fullPath, callback);
20833
20884
  } else if (entry.name.endsWith(".md")) {
@@ -20838,7 +20889,7 @@ function walkFiles(dir, callback) {
20838
20889
 
20839
20890
  // src/dedup/index.ts
20840
20891
  import fs4 from "fs";
20841
- import path24 from "path";
20892
+ import path26 from "path";
20842
20893
  import crypto5 from "crypto";
20843
20894
  var DEFAULT_DEDUP_THRESHOLD = 0.85;
20844
20895
  var DEFAULT_MAX_LOAD = 1e4;
@@ -20980,7 +21031,7 @@ function loadMemories(memoryDir, categories, maxLoad = 1e4) {
20980
21031
  const memoryRootReal = fs4.realpathSync(memoryDir);
20981
21032
  for (const category of allCategories) {
20982
21033
  if (result.length >= maxLoad) break;
20983
- const dir = path24.join(memoryDir, category);
21034
+ const dir = path26.join(memoryDir, category);
20984
21035
  if (!fs4.existsSync(dir)) continue;
20985
21036
  const categoryStat = fs4.lstatSync(dir);
20986
21037
  if (categoryStat.isSymbolicLink()) {
@@ -21041,15 +21092,15 @@ function extractBody3(content) {
21041
21092
  return match ? match[1].trim() : content.trim();
21042
21093
  }
21043
21094
  function assertPathInsideRoot2(rootReal, targetReal, sourcePath) {
21044
- const rel = path24.relative(rootReal, targetReal);
21045
- if (rel === "" || !rel.startsWith("..") && !path24.isAbsolute(rel)) {
21095
+ const rel = path26.relative(rootReal, targetReal);
21096
+ if (rel === "" || !rel.startsWith("..") && !path26.isAbsolute(rel)) {
21046
21097
  return;
21047
21098
  }
21048
21099
  throw new Error(`Refusing to scan memory path outside root: ${sourcePath}`);
21049
21100
  }
21050
21101
  function walkMdFiles(dir, memoryRootReal, categoryRootReal, callback) {
21051
21102
  for (const entry of fs4.readdirSync(dir, { withFileTypes: true })) {
21052
- const fullPath = path24.join(dir, entry.name);
21103
+ const fullPath = path26.join(dir, entry.name);
21053
21104
  const entryStat = fs4.lstatSync(fullPath);
21054
21105
  if (entryStat.isSymbolicLink()) {
21055
21106
  throw new Error(`Refusing to scan symlinked memory path: ${fullPath}`);
@@ -21067,10 +21118,10 @@ function walkMdFiles(dir, memoryRootReal, categoryRootReal, callback) {
21067
21118
 
21068
21119
  // src/review/index.ts
21069
21120
  import fs5 from "fs";
21070
- import path25 from "path";
21121
+ import path27 from "path";
21071
21122
  var historicalIdCache3 = new HistoricalEntityCanonicalIdCache();
21072
21123
  function writeReviewFileCanonicalized(memoryDir, filePath, content) {
21073
- const stateDir = path25.join(memoryDir, "state");
21124
+ const stateDir = path27.join(memoryDir, "state");
21074
21125
  const idsAtWrite = historicalIdCache3.get(stateDir);
21075
21126
  let originalBytes = null;
21076
21127
  try {
@@ -21112,8 +21163,8 @@ function realMemoryRoot(memoryDir) {
21112
21163
  }
21113
21164
  }
21114
21165
  function isPathInside2(rootReal, candidateReal) {
21115
- const relative = path25.relative(rootReal, candidateReal);
21116
- return relative === "" || !!relative && !relative.startsWith("..") && !path25.isAbsolute(relative);
21166
+ const relative = path27.relative(rootReal, candidateReal);
21167
+ return relative === "" || !!relative && !relative.startsWith("..") && !path27.isAbsolute(relative);
21117
21168
  }
21118
21169
  function isSafeDirectory(rootReal, dir) {
21119
21170
  try {
@@ -21156,7 +21207,7 @@ function listReviewItems(options) {
21156
21207
  if (filterReason && item.reviewReason !== filterReason) return;
21157
21208
  items.push(item);
21158
21209
  };
21159
- const suggestionsDir = path25.join(memoryDir, "suggestions");
21210
+ const suggestionsDir = path27.join(memoryDir, "suggestions");
21160
21211
  if (!isLimitReached() && fs5.existsSync(suggestionsDir) && isSafeDirectory(rootReal, suggestionsDir)) {
21161
21212
  walkMd(rootReal, suggestionsDir, (filePath, content) => {
21162
21213
  if (isLimitReached()) return true;
@@ -21177,7 +21228,7 @@ function listReviewItems(options) {
21177
21228
  return isLimitReached();
21178
21229
  });
21179
21230
  }
21180
- const reviewDir = path25.join(memoryDir, "review");
21231
+ const reviewDir = path27.join(memoryDir, "review");
21181
21232
  if (!isLimitReached() && fs5.existsSync(reviewDir) && isSafeDirectory(rootReal, reviewDir)) {
21182
21233
  walkMd(rootReal, reviewDir, (filePath, content) => {
21183
21234
  if (isLimitReached()) return true;
@@ -21202,7 +21253,7 @@ function listReviewItems(options) {
21202
21253
  const categories = ALL_CATEGORY_DIRS;
21203
21254
  for (const category of categories) {
21204
21255
  if (isLimitReached()) break;
21205
- const dir = path25.join(memoryDir, category);
21256
+ const dir = path27.join(memoryDir, category);
21206
21257
  if (!fs5.existsSync(dir) || !isSafeDirectory(rootReal, dir)) continue;
21207
21258
  walkMd(rootReal, dir, (filePath, content) => {
21208
21259
  if (isLimitReached()) return true;
@@ -21284,9 +21335,9 @@ function approveItem(memoryDir, itemId, options) {
21284
21335
  const targetDir = getCategoryDir(memoryDir, category);
21285
21336
  const dateDir = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
21286
21337
  ensureSafeDirectory(rootReal, targetDir);
21287
- const outputPath = path25.join(targetDir, dateDir, path25.basename(found.filePath));
21288
- ensureSafeDirectory(rootReal, path25.dirname(outputPath));
21289
- const reviewStateDir = path25.join(memoryDir, "state");
21338
+ const outputPath = path27.join(targetDir, dateDir, path27.basename(found.filePath));
21339
+ ensureSafeDirectory(rootReal, path27.dirname(outputPath));
21340
+ const reviewStateDir = path27.join(memoryDir, "state");
21290
21341
  const idsAtWrite = historicalIdCache3.get(reviewStateDir);
21291
21342
  const promotedWritten = canonicalizeEntityRefFrontmatter(updatedContent, idsAtWrite);
21292
21343
  const promotedPath = writeFileWithoutClobber(outputPath, promotedWritten, itemId);
@@ -21363,13 +21414,13 @@ function findReviewFileById(memoryDir, id, options = {}) {
21363
21414
  const rootReal = realMemoryRoot(memoryDir);
21364
21415
  if (!rootReal) return null;
21365
21416
  for (const loc of ["suggestions", "review"]) {
21366
- const dir = path25.join(memoryDir, loc);
21417
+ const dir = path27.join(memoryDir, loc);
21367
21418
  if (!fs5.existsSync(dir) || !isSafeDirectory(rootReal, dir)) continue;
21368
21419
  const found = findFileById(rootReal, dir, id);
21369
21420
  if (found) return { filePath: found, location: "queue" };
21370
21421
  }
21371
21422
  for (const category of ALL_CATEGORY_DIRS) {
21372
- const dir = path25.join(memoryDir, category);
21423
+ const dir = path27.join(memoryDir, category);
21373
21424
  if (!fs5.existsSync(dir) || !isSafeDirectory(rootReal, dir)) continue;
21374
21425
  const found = findFileById(rootReal, dir, id, (fm) => isLowConfidenceReviewCandidate(fm, options));
21375
21426
  if (found) return { filePath: found, location: "category" };
@@ -21445,10 +21496,10 @@ function readFileSafe3(filePath) {
21445
21496
  }
21446
21497
  }
21447
21498
  function writeFileWithoutClobber(basePath, content, discriminator) {
21448
- const parsed = path25.parse(basePath);
21499
+ const parsed = path27.parse(basePath);
21449
21500
  const safeDiscriminator = sanitizeFilePart(discriminator);
21450
21501
  for (let attempt = 0; attempt < 1e3; attempt++) {
21451
- const candidate = attempt === 0 ? basePath : path25.join(
21502
+ const candidate = attempt === 0 ? basePath : path27.join(
21452
21503
  parsed.dir,
21453
21504
  `${parsed.name}-${safeDiscriminator}${attempt === 1 ? "" : `-${attempt}`}${parsed.ext || ".md"}`
21454
21505
  );
@@ -21504,7 +21555,7 @@ function extractBody4(content) {
21504
21555
  function walkMd(rootReal, dir, callback) {
21505
21556
  if (!isSafeDirectory(rootReal, dir)) return false;
21506
21557
  for (const entry of fs5.readdirSync(dir, { withFileTypes: true })) {
21507
- const fullPath = path25.join(dir, entry.name);
21558
+ const fullPath = path27.join(dir, entry.name);
21508
21559
  if (entry.isSymbolicLink()) continue;
21509
21560
  if (entry.isDirectory()) {
21510
21561
  if (walkMd(rootReal, fullPath, callback)) return true;
@@ -21519,7 +21570,7 @@ function walkMdPaths(rootReal, dir) {
21519
21570
  const results = [];
21520
21571
  if (!isSafeDirectory(rootReal, dir)) return results;
21521
21572
  for (const entry of fs5.readdirSync(dir, { withFileTypes: true })) {
21522
- const fullPath = path25.join(dir, entry.name);
21573
+ const fullPath = path27.join(dir, entry.name);
21523
21574
  if (entry.isSymbolicLink()) continue;
21524
21575
  if (entry.isDirectory()) {
21525
21576
  results.push(...walkMdPaths(rootReal, fullPath));
@@ -21532,7 +21583,7 @@ function walkMdPaths(rootReal, dir) {
21532
21583
 
21533
21584
  // src/sync/index.ts
21534
21585
  import fs6 from "fs";
21535
- import path26 from "path";
21586
+ import path28 from "path";
21536
21587
  import crypto6 from "crypto";
21537
21588
  var DEFAULT_EXTENSIONS = /* @__PURE__ */ new Set([".md", ".txt", ".mdx", ".rst"]);
21538
21589
  var DEFAULT_EXCLUDE2 = /* @__PURE__ */ new Set([
@@ -21554,7 +21605,7 @@ function syncChanges(options) {
21554
21605
  } = options;
21555
21606
  const extSet = new Set(extensions);
21556
21607
  const excludeSet = /* @__PURE__ */ new Set([...DEFAULT_EXCLUDE2, ...excludeDirs]);
21557
- const stateFilePath = options.stateFile ?? path26.join(memoryDir, ".sync-state.json");
21608
+ const stateFilePath = options.stateFile ?? path28.join(memoryDir, ".sync-state.json");
21558
21609
  const prevState = loadState(stateFilePath);
21559
21610
  const currentFiles = scanFiles(sourceDir, extSet, excludeSet);
21560
21611
  const changes = computeDiff(currentFiles, prevState.fileHashes, sourceDir);
@@ -21570,7 +21621,7 @@ function syncChanges(options) {
21570
21621
  for (const [relPath, hash] of Object.entries(currentFiles)) {
21571
21622
  newState.fileHashes[relPath] = hash;
21572
21623
  }
21573
- fs6.mkdirSync(path26.dirname(stateFilePath), { recursive: true });
21624
+ fs6.mkdirSync(path28.dirname(stateFilePath), { recursive: true });
21574
21625
  fs6.writeFileSync(stateFilePath, JSON.stringify(newState, null, 2));
21575
21626
  }
21576
21627
  return {
@@ -21636,13 +21687,13 @@ function scanFiles(root, extensions, exclude) {
21636
21687
  }
21637
21688
  for (const entry of entries) {
21638
21689
  if (exclude.has(entry.name)) continue;
21639
- const fullPath = path26.join(dir, entry.name);
21690
+ const fullPath = path28.join(dir, entry.name);
21640
21691
  if (entry.isDirectory()) {
21641
21692
  walk(fullPath);
21642
21693
  } else if (entry.isFile()) {
21643
- const ext = path26.extname(entry.name).toLowerCase();
21694
+ const ext = path28.extname(entry.name).toLowerCase();
21644
21695
  if (!extensions.has(ext)) continue;
21645
- const relPath = path26.relative(root, fullPath);
21696
+ const relPath = path28.relative(root, fullPath);
21646
21697
  try {
21647
21698
  const content = fs6.readFileSync(fullPath, "utf8");
21648
21699
  result[relPath] = hashContent3(content);
@@ -21657,7 +21708,7 @@ function scanFiles(root, extensions, exclude) {
21657
21708
  function computeDiff(current, previous, sourceDir) {
21658
21709
  const changes = [];
21659
21710
  for (const [relPath, hash] of Object.entries(current)) {
21660
- const fullPath = path26.join(sourceDir, relPath);
21711
+ const fullPath = path28.join(sourceDir, relPath);
21661
21712
  if (!(relPath in previous)) {
21662
21713
  let size = 0;
21663
21714
  try {
@@ -21690,7 +21741,7 @@ function computeDiff(current, previous, sourceDir) {
21690
21741
  for (const relPath of Object.keys(previous)) {
21691
21742
  if (!(relPath in current)) {
21692
21743
  changes.push({
21693
- filePath: path26.join(sourceDir, relPath),
21744
+ filePath: path28.join(sourceDir, relPath),
21694
21745
  relativePath: relPath,
21695
21746
  type: "deleted",
21696
21747
  currentHash: "",
@@ -21720,21 +21771,21 @@ function hashContent3(content) {
21720
21771
  import { spawnSync } from "child_process";
21721
21772
  import crypto7 from "crypto";
21722
21773
  import fs7 from "fs";
21723
- import path27 from "path";
21774
+ import path29 from "path";
21724
21775
  var historicalIdCache4 = new HistoricalEntityCanonicalIdCache();
21725
21776
  var MANIFEST_VERSION = 1;
21726
21777
  var MANIFEST_LOCK_STALE_MS = 3e4;
21727
21778
  var MANIFEST_LOCK_TIMEOUT_MS = MANIFEST_LOCK_STALE_MS + 1e4;
21728
21779
  var MANIFEST_LOCK_SLEEP_MS = 20;
21729
21780
  function normalizeSpaceMemoryDir(memoryDir) {
21730
- return path27.resolve(memoryDir);
21781
+ return path29.resolve(memoryDir);
21731
21782
  }
21732
21783
  function getSpacesDir(baseDir) {
21733
21784
  const homeDir = baseDir ?? resolveHomeDir();
21734
- return path27.join(homeDir, ".config", "engram", "spaces");
21785
+ return path29.join(homeDir, ".config", "engram", "spaces");
21735
21786
  }
21736
21787
  function getManifestPath(baseDir) {
21737
- return path27.join(getSpacesDir(baseDir), "manifest.json");
21788
+ return path29.join(getSpacesDir(baseDir), "manifest.json");
21738
21789
  }
21739
21790
  function loadManifest(baseDir, memoryDirOverride) {
21740
21791
  if (fs7.existsSync(getManifestPath(baseDir))) {
@@ -21781,9 +21832,9 @@ function readManifestUnlocked(baseDir, memoryDirOverride, options = {}) {
21781
21832
  }
21782
21833
  function saveManifestUnlocked(manifest, baseDir) {
21783
21834
  const manifestPath2 = getManifestPath(baseDir);
21784
- const manifestDir2 = path27.dirname(manifestPath2);
21835
+ const manifestDir2 = path29.dirname(manifestPath2);
21785
21836
  fs7.mkdirSync(manifestDir2, { recursive: true });
21786
- const tempPath = path27.join(manifestDir2, `.manifest.${process.pid}.${Date.now()}.${crypto7.randomUUID()}.tmp`);
21837
+ const tempPath = path29.join(manifestDir2, `.manifest.${process.pid}.${Date.now()}.${crypto7.randomUUID()}.tmp`);
21787
21838
  try {
21788
21839
  fs7.writeFileSync(tempPath, `${JSON.stringify(manifest, null, 2)}
21789
21840
  `, { flag: "wx" });
@@ -21798,7 +21849,7 @@ function saveManifestUnlocked(manifest, baseDir) {
21798
21849
  }
21799
21850
  function withManifestLock(baseDir, operation) {
21800
21851
  const lockDir = `${getManifestPath(baseDir)}.lock`;
21801
- fs7.mkdirSync(path27.dirname(lockDir), { recursive: true });
21852
+ fs7.mkdirSync(path29.dirname(lockDir), { recursive: true });
21802
21853
  const lockOwner = acquireManifestLock(lockDir);
21803
21854
  try {
21804
21855
  return operation();
@@ -21824,7 +21875,7 @@ function acquireManifestLock(lockDir) {
21824
21875
  try {
21825
21876
  fs7.mkdirSync(lockDir, { recursive: false });
21826
21877
  try {
21827
- fs7.writeFileSync(path27.join(lockDir, "owner"), `${owner}
21878
+ fs7.writeFileSync(path29.join(lockDir, "owner"), `${owner}
21828
21879
  `, { flag: "wx" });
21829
21880
  } catch (error) {
21830
21881
  fs7.rmSync(lockDir, { recursive: true, force: true });
@@ -21854,7 +21905,7 @@ function acquireManifestLock(lockDir) {
21854
21905
  }
21855
21906
  function releaseManifestLock(lockDir, owner) {
21856
21907
  try {
21857
- const ownerPath = path27.join(lockDir, "owner");
21908
+ const ownerPath = path29.join(lockDir, "owner");
21858
21909
  if (fs7.readFileSync(ownerPath, "utf8").trim() === owner) {
21859
21910
  fs7.rmSync(lockDir, { recursive: true, force: true });
21860
21911
  }
@@ -21870,7 +21921,7 @@ function removeStaleManifestLock(lockDir) {
21870
21921
  try {
21871
21922
  fs7.mkdirSync(reclaimDir, { recursive: false });
21872
21923
  try {
21873
- fs7.writeFileSync(path27.join(reclaimDir, "owner"), `${reclaimOwner}
21924
+ fs7.writeFileSync(path29.join(reclaimDir, "owner"), `${reclaimOwner}
21874
21925
  `, { flag: "wx" });
21875
21926
  } catch (error) {
21876
21927
  fs7.rmSync(reclaimDir, { recursive: true, force: true });
@@ -21945,7 +21996,7 @@ function readManifestLockSnapshot(lockDir) {
21945
21996
  throw error;
21946
21997
  }
21947
21998
  try {
21948
- const owner = fs7.readFileSync(path27.join(lockDir, "owner"), "utf8").trim();
21999
+ const owner = fs7.readFileSync(path29.join(lockDir, "owner"), "utf8").trim();
21949
22000
  return { mtimeMs: stat5.mtimeMs, owner };
21950
22001
  } catch (error) {
21951
22002
  if (error.code === "ENOENT") {
@@ -22017,8 +22068,8 @@ function sleepSync(ms) {
22017
22068
  }
22018
22069
  function createPersonalSpace(baseDir, memoryDirOverride) {
22019
22070
  const homeDir = baseDir ?? resolveHomeDir();
22020
- const standalonePath = path27.join(homeDir, ".engram", "memory");
22021
- const openclawPath = path27.join(homeDir, ".openclaw", "workspace", "memory", "local");
22071
+ const standalonePath = path29.join(homeDir, ".engram", "memory");
22072
+ const openclawPath = path29.join(homeDir, ".openclaw", "workspace", "memory", "local");
22022
22073
  const memoryDir = memoryDirOverride ?? readEnvVar("REMNIC_MEMORY_DIR") ?? readEnvVar("ENGRAM_MEMORY_DIR") ?? (fs7.existsSync(standalonePath) ? standalonePath : fs7.existsSync(openclawPath) ? openclawPath : standalonePath);
22023
22074
  const normalizedMemoryDir = normalizeSpaceMemoryDir(memoryDir);
22024
22075
  const now = (/* @__PURE__ */ new Date()).toISOString();
@@ -22047,7 +22098,7 @@ function createSpace(options) {
22047
22098
  const id = options.name.toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-");
22048
22099
  const now = (/* @__PURE__ */ new Date()).toISOString();
22049
22100
  const memoryDir = normalizeSpaceMemoryDir(
22050
- options.memoryDir ?? path27.join(getSpacesDir(options.baseDir), id, "memory")
22101
+ options.memoryDir ?? path29.join(getSpacesDir(options.baseDir), id, "memory")
22051
22102
  );
22052
22103
  const space = updateManifest(options.baseDir, (manifest) => {
22053
22104
  if (manifest.spaces.some((s) => s.id === id)) {
@@ -22268,14 +22319,14 @@ async function mergeSpaces(sourceSpaceId, targetSpaceId, options) {
22268
22319
  };
22269
22320
  }
22270
22321
  function getAuditLog(baseDir) {
22271
- const auditPath = path27.join(getSpacesDir(baseDir), "audit.jsonl");
22322
+ const auditPath = path29.join(getSpacesDir(baseDir), "audit.jsonl");
22272
22323
  if (!fs7.existsSync(auditPath)) return [];
22273
22324
  const lines = fs7.readFileSync(auditPath, "utf8").trim().split("\n");
22274
22325
  return lines.filter((l) => l.trim()).map((l) => JSON.parse(l));
22275
22326
  }
22276
22327
  function appendAudit(entry, baseDir) {
22277
- const auditPath = path27.join(getSpacesDir(baseDir), "audit.jsonl");
22278
- fs7.mkdirSync(path27.dirname(auditPath), { recursive: true });
22328
+ const auditPath = path29.join(getSpacesDir(baseDir), "audit.jsonl");
22329
+ fs7.mkdirSync(path29.dirname(auditPath), { recursive: true });
22279
22330
  const full = {
22280
22331
  id: crypto7.randomUUID(),
22281
22332
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
@@ -22296,11 +22347,11 @@ async function copyMemories(sourceDir, targetDir, options) {
22296
22347
  sourceFiles.filter((p) => {
22297
22348
  const rp = safeRealpath(p);
22298
22349
  if (!rp || !isPathInsideRoot(rp, sourceRoot)) return false;
22299
- const rel = path27.relative(sourceRoot, rp);
22300
- const mapped = path27.resolve(targetRoot, rel);
22350
+ const rel = path29.relative(sourceRoot, rp);
22351
+ const mapped = path29.resolve(targetRoot, rel);
22301
22352
  if (!isPathInsideRoot(mapped, targetRoot)) return false;
22302
22353
  return classifyEntityRefWritePath(targetRoot, mapped) === "entity";
22303
- }).map((p) => path27.basename(p, ".md"))
22354
+ }).map((p) => path29.basename(p, ".md"))
22304
22355
  );
22305
22356
  const firstEntityId = sourceEntityIds.values().next().value;
22306
22357
  if (firstEntityId === void 0) {
@@ -22308,7 +22359,7 @@ async function copyMemories(sourceDir, targetDir, options) {
22308
22359
  }
22309
22360
  return withRawEntityPageMutation(
22310
22361
  targetRoot,
22311
- path27.join(targetRoot, "entities", `${firstEntityId}.md`),
22362
+ path29.join(targetRoot, "entities", `${firstEntityId}.md`),
22312
22363
  async () => copyPreparedMemories(
22313
22364
  sourceFiles,
22314
22365
  sourceRoot,
@@ -22335,14 +22386,14 @@ function copyPreparedMemories(sourceFiles, sourceRoot, targetRoot, sourceEntityI
22335
22386
  continue;
22336
22387
  }
22337
22388
  const content = fs7.readFileSync(sourcePath, "utf8");
22338
- const relativePath = path27.relative(sourceRoot, sourceRealPath);
22339
- const targetPath = path27.resolve(targetRoot, relativePath);
22389
+ const relativePath = path29.relative(sourceRoot, sourceRealPath);
22390
+ const targetPath = path29.resolve(targetRoot, relativePath);
22340
22391
  if (!isPathInsideRoot(targetPath, targetRoot)) {
22341
22392
  skipped++;
22342
22393
  continue;
22343
22394
  }
22344
22395
  const targetKind = classifyEntityRefWritePath(targetRoot, targetPath);
22345
- const idsAtCompare = historicalIdCache4.get(path27.join(targetRoot, "state"));
22396
+ const idsAtCompare = historicalIdCache4.get(path29.join(targetRoot, "state"));
22346
22397
  const sourceRef = targetKind === "memory" ? readEntityRefFromFrontmatter(content) : null;
22347
22398
  const refHasSourceClaimant = sourceRef !== null && sourceEntityIds.has(sourceRef);
22348
22399
  const canonicalContent = targetKind === "memory" && !refHasSourceClaimant ? canonicalizeEntityRefFrontmatter(content, idsAtCompare) : content;
@@ -22369,7 +22420,7 @@ function copyPreparedMemories(sourceFiles, sourceRoot, targetRoot, sourceEntityI
22369
22420
  if (fs7.existsSync(targetPath) && !options?.force) {
22370
22421
  const targetContent = fs7.readFileSync(targetPath, "utf8");
22371
22422
  const targetHash = hashContent4(targetContent);
22372
- if (hashContent4(canonicalContent) === targetHash && historicalIdCache4.get(path27.join(targetRoot, "state")) === idsAtCompare) {
22423
+ if (hashContent4(canonicalContent) === targetHash && historicalIdCache4.get(path29.join(targetRoot, "state")) === idsAtCompare) {
22373
22424
  skipped++;
22374
22425
  continue;
22375
22426
  }
@@ -22385,13 +22436,13 @@ function copyPreparedMemories(sourceFiles, sourceRoot, targetRoot, sourceEntityI
22385
22436
  continue;
22386
22437
  }
22387
22438
  }
22388
- fs7.mkdirSync(path27.dirname(targetPath), { recursive: true });
22389
- const targetParentRealPath = safeRealpath(path27.dirname(targetPath));
22439
+ fs7.mkdirSync(path29.dirname(targetPath), { recursive: true });
22440
+ const targetParentRealPath = safeRealpath(path29.dirname(targetPath));
22390
22441
  if (!targetParentRealPath || !isPathInsideRoot(targetParentRealPath, targetRoot)) {
22391
22442
  skipped++;
22392
22443
  continue;
22393
22444
  }
22394
- const stateDir = path27.join(targetRoot, "state");
22445
+ const stateDir = path29.join(targetRoot, "state");
22395
22446
  if (targetKind === "memory" && !refHasSourceClaimant) {
22396
22447
  const idsAtWrite = historicalIdCache4.get(stateDir);
22397
22448
  const written = canonicalizeEntityRefFrontmatter(content, idsAtWrite);
@@ -22435,7 +22486,7 @@ function copyPreparedMemories(sourceFiles, sourceRoot, targetRoot, sourceEntityI
22435
22486
  bumpMemoryCorpusVersionForDir(targetRoot);
22436
22487
  }
22437
22488
  if (reconcileNeeded) {
22438
- requestEntityCanonicalIdReconcileSync(path27.join(targetRoot, "state"));
22489
+ requestEntityCanonicalIdReconcileSync(path29.join(targetRoot, "state"));
22439
22490
  }
22440
22491
  return { merged, conflicts, skipped };
22441
22492
  }
@@ -22446,7 +22497,7 @@ function walkMd2(dir) {
22446
22497
  const results = [];
22447
22498
  function walk(d) {
22448
22499
  for (const entry of fs7.readdirSync(d, { withFileTypes: true })) {
22449
- const fullPath = path27.join(d, entry.name);
22500
+ const fullPath = path29.join(d, entry.name);
22450
22501
  if (entry.isSymbolicLink()) {
22451
22502
  continue;
22452
22503
  }
@@ -22475,8 +22526,8 @@ function safeRealpath(filePath) {
22475
22526
  }
22476
22527
  }
22477
22528
  function isPathInsideRoot(candidatePath, rootPath) {
22478
- const relative = path27.relative(rootPath, candidatePath);
22479
- return relative === "" || !relative.startsWith("..") && !path27.isAbsolute(relative);
22529
+ const relative = path29.relative(rootPath, candidatePath);
22530
+ return relative === "" || !relative.startsWith("..") && !path29.isAbsolute(relative);
22480
22531
  }
22481
22532
  function parseSimpleFrontmatter(content) {
22482
22533
  const match = content.match(/^---\n([\s\S]*?)\n---/);
@@ -22597,7 +22648,7 @@ var REMNIC_RECALL_DECISION_RULES = `## When to Use Recall vs Direct Read
22597
22648
  // src/memory-extension/codex-publisher.ts
22598
22649
  import fs8 from "fs";
22599
22650
  import os from "os";
22600
- import path28 from "path";
22651
+ import path30 from "path";
22601
22652
  var REMNIC_EXTENSION_DIR_NAME = "remnic";
22602
22653
  function resolveEnvHome(env) {
22603
22654
  if (env === void 0) return resolveHomeDir();
@@ -22606,12 +22657,12 @@ function resolveEnvHome(env) {
22606
22657
  function expandTildeWithHome(input, homeDir) {
22607
22658
  if (input === "~") return homeDir;
22608
22659
  if (input.startsWith("~/") || input.startsWith("~\\")) {
22609
- return path28.join(homeDir, input.slice(2));
22660
+ return path30.join(homeDir, input.slice(2));
22610
22661
  }
22611
22662
  return input;
22612
22663
  }
22613
22664
  function normalizeHostRoot(input, homeDir) {
22614
- return path28.resolve(expandTildeWithHome(input.trim(), homeDir));
22665
+ return path30.resolve(expandTildeWithHome(input.trim(), homeDir));
22615
22666
  }
22616
22667
  var CodexMemoryExtensionPublisher = class {
22617
22668
  hostId = "codex";
@@ -22625,12 +22676,12 @@ var CodexMemoryExtensionPublisher = class {
22625
22676
  async resolveExtensionRoot(env) {
22626
22677
  const homeDir = resolveEnvHome(env);
22627
22678
  const codexHomeInput = env === void 0 ? readEnvVar("CODEX_HOME")?.trim() : env.CODEX_HOME?.trim();
22628
- const codexHome = codexHomeInput ? normalizeHostRoot(codexHomeInput, homeDir) : path28.resolve(homeDir, ".codex");
22629
- return path28.join(codexHome, "memories_extensions", REMNIC_EXTENSION_DIR_NAME);
22679
+ const codexHome = codexHomeInput ? normalizeHostRoot(codexHomeInput, homeDir) : path30.resolve(homeDir, ".codex");
22680
+ return path30.join(codexHome, "memories_extensions", REMNIC_EXTENSION_DIR_NAME);
22630
22681
  }
22631
22682
  async isHostAvailable() {
22632
22683
  try {
22633
- const home = readEnvVar("CODEX_HOME")?.trim() || path28.join(resolveHomeDir(), ".codex");
22684
+ const home = readEnvVar("CODEX_HOME")?.trim() || path30.join(resolveHomeDir(), ".codex");
22634
22685
  return fs8.existsSync(home);
22635
22686
  } catch {
22636
22687
  return false;
@@ -22681,7 +22732,7 @@ When running inside the Codex phase-2 consolidation sandbox:
22681
22732
  }
22682
22733
  async publish(ctx) {
22683
22734
  const extensionRoot = await this.resolveExtensionRoot();
22684
- const instructionsPath = path28.join(extensionRoot, "instructions.md");
22735
+ const instructionsPath = path30.join(extensionRoot, "instructions.md");
22685
22736
  const filesWritten = [];
22686
22737
  const skipped = [];
22687
22738
  ctx.log.info(`Publishing Codex memory extension to ${extensionRoot}`);
@@ -23057,7 +23108,7 @@ async function generateActivityMemories(date, digestBody, config, deps) {
23057
23108
  // src/session-summaries/index.ts
23058
23109
  import { createHash as createHash7 } from "crypto";
23059
23110
  import { lstat as lstat2, mkdir as mkdir7, readFile as readFile6, readdir as readdir4, rename, rm, stat as stat4, writeFile as writeFile7 } from "fs/promises";
23060
- import path29 from "path";
23111
+ import path31 from "path";
23061
23112
 
23062
23113
  // src/session-summaries/adapters.ts
23063
23114
  var VALID_ROLES = /* @__PURE__ */ new Set(["user", "assistant", "tool", "system", "other"]);
@@ -23562,7 +23613,7 @@ function shortHash(value, length = 16) {
23562
23613
  async function listTranscriptFiles(root, maxFiles) {
23563
23614
  const out = [];
23564
23615
  let truncated = false;
23565
- const entrySortKey = (entryName, isDirectory) => isDirectory ? `${entryName}${path29.sep}` : entryName;
23616
+ const entrySortKey = (entryName, isDirectory) => isDirectory ? `${entryName}${path31.sep}` : entryName;
23566
23617
  async function visit(dir) {
23567
23618
  if (truncated) return;
23568
23619
  const entries = (await readdir4(dir, { withFileTypes: true })).sort(
@@ -23572,13 +23623,13 @@ async function listTranscriptFiles(root, maxFiles) {
23572
23623
  if (truncated) return;
23573
23624
  if (entry.name.startsWith(".")) continue;
23574
23625
  if (entry.isSymbolicLink()) continue;
23575
- const fullPath = path29.join(dir, entry.name);
23626
+ const fullPath = path31.join(dir, entry.name);
23576
23627
  if (entry.isDirectory()) {
23577
23628
  await visit(fullPath);
23578
23629
  continue;
23579
23630
  }
23580
23631
  if (!entry.isFile()) continue;
23581
- const ext = path29.extname(entry.name).toLowerCase();
23632
+ const ext = path31.extname(entry.name).toLowerCase();
23582
23633
  if (!SUPPORTED_EXTENSIONS.has(ext)) continue;
23583
23634
  out.push(fullPath);
23584
23635
  if (out.length > maxFiles) {
@@ -23605,7 +23656,7 @@ function normalizeInputDir(inputDir) {
23605
23656
  if (typeof inputDir !== "string" || inputDir.trim().length === 0) {
23606
23657
  throw new Error("inputDir must be a non-empty string");
23607
23658
  }
23608
- return path29.resolve(expandTildePath(inputDir.trim()));
23659
+ return path31.resolve(expandTildePath(inputDir.trim()));
23609
23660
  }
23610
23661
  function initRoleCounts() {
23611
23662
  return {
@@ -23762,11 +23813,11 @@ async function collectLocalSessionSummaries(options) {
23762
23813
  continue;
23763
23814
  }
23764
23815
  seenFileHashes.add(fileHash);
23765
- const fileExtension = path29.extname(filePath).toLowerCase();
23816
+ const fileExtension = path31.extname(filePath).toLowerCase();
23766
23817
  const parsed = await adapter.parseFile(
23767
23818
  {
23768
23819
  content,
23769
- fileName: path29.basename(filePath),
23820
+ fileName: path31.basename(filePath),
23770
23821
  fileExtension,
23771
23822
  fileRef: fileHash
23772
23823
  },
@@ -23822,7 +23873,7 @@ async function collectLocalSessionSummaries(options) {
23822
23873
  }
23823
23874
  async function readRedactionConfig(pathLike) {
23824
23875
  if (!pathLike) return void 0;
23825
- const raw = await readFile6(path29.resolve(expandTildePath(pathLike)), "utf-8");
23876
+ const raw = await readFile6(path31.resolve(expandTildePath(pathLike)), "utf-8");
23826
23877
  const parsed = JSON.parse(raw);
23827
23878
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
23828
23879
  throw new Error("redaction config must be a JSON object");
@@ -23835,15 +23886,15 @@ function toJsonl(drafts) {
23835
23886
  }
23836
23887
  function defaultDraftOutputPath(memoryDir, generatedAt) {
23837
23888
  const stamp = generatedAt.replace(/[:.]/g, "-");
23838
- return path29.join(
23839
- path29.resolve(expandTildePath(memoryDir)),
23889
+ return path31.join(
23890
+ path31.resolve(expandTildePath(memoryDir)),
23840
23891
  "state",
23841
23892
  "session-summary-drafts",
23842
23893
  `session-summaries-${stamp}.jsonl`
23843
23894
  );
23844
23895
  }
23845
23896
  async function writeDrafts(filePath, drafts) {
23846
- await mkdir7(path29.dirname(filePath), { recursive: true });
23897
+ await mkdir7(path31.dirname(filePath), { recursive: true });
23847
23898
  const tempPath = `${filePath}.${process.pid}.${Date.now()}.tmp`;
23848
23899
  try {
23849
23900
  await writeFile7(tempPath, toJsonl(drafts), "utf-8");
@@ -23861,7 +23912,7 @@ async function runLocalSessionSummaryCliCommand(options) {
23861
23912
  });
23862
23913
  const wroteFiles = [];
23863
23914
  if (options.output) {
23864
- const outputPath = path29.resolve(expandTildePath(options.output));
23915
+ const outputPath = path31.resolve(expandTildePath(options.output));
23865
23916
  await writeDrafts(outputPath, report.drafts);
23866
23917
  wroteFiles.push(outputPath);
23867
23918
  }
@@ -23896,19 +23947,19 @@ async function runLocalSessionSummaryCliCommand(options) {
23896
23947
 
23897
23948
  // src/transfer/capsule-fork.ts
23898
23949
  import { lstat as lstat3, mkdir as mkdir8, readFile as readFile7, realpath as realpath2, writeFile as writeFile8 } from "fs/promises";
23899
- import path30 from "path";
23950
+ import path32 from "path";
23900
23951
  async function forkCapsule(opts) {
23901
23952
  validateForkId(opts.forkId);
23902
- const rootAbs = path30.resolve(opts.targetRoot);
23953
+ const rootAbs = path32.resolve(opts.targetRoot);
23903
23954
  await assertIsDirectoryNotSymlink(rootAbs, "forkCapsule", "targetRoot");
23904
- const forkDirAbs = path30.join(rootAbs, "forks", opts.forkId);
23955
+ const forkDirAbs = path32.join(rootAbs, "forks", opts.forkId);
23905
23956
  const forkEntryExists = await pathEntryExists(forkDirAbs);
23906
23957
  if (forkEntryExists) {
23907
23958
  throw new Error(
23908
23959
  `forkCapsule: fork path already exists \u2014 forkId "${opts.forkId}" is already in use at: ${forkDirAbs}`
23909
23960
  );
23910
23961
  }
23911
- const archiveAbs = path30.resolve(opts.sourceArchive);
23962
+ const archiveAbs = path32.resolve(opts.sourceArchive);
23912
23963
  const importResult = await importCapsule({
23913
23964
  archivePath: archiveAbs,
23914
23965
  root: rootAbs,
@@ -23930,10 +23981,10 @@ async function forkCapsule(opts) {
23930
23981
  importedRecords: importResult.imported.length,
23931
23982
  skippedRecords: importResult.skipped.length
23932
23983
  };
23933
- const lineagePath = path30.join(forkDirAbs, "lineage.json");
23984
+ const lineagePath = path32.join(forkDirAbs, "lineage.json");
23934
23985
  const rootReal = await realpath2(rootAbs);
23935
23986
  await assertRealpathInsideRoot(rootReal, lineagePath, `forks/${opts.forkId}/lineage.json`, "forkCapsule");
23936
- await mkdir8(path30.dirname(lineagePath), { recursive: true });
23987
+ await mkdir8(path32.dirname(lineagePath), { recursive: true });
23937
23988
  await writeFile8(lineagePath, JSON.stringify(lineage, null, 2) + "\n", "utf-8");
23938
23989
  return {
23939
23990
  archivePath: archiveAbs,
@@ -23947,11 +23998,11 @@ async function readForkLineage(targetRoot, forkId) {
23947
23998
  if (typeof forkId !== "string" || forkId.length === 0 || forkId.length > 64 || !CAPSULE_ID_PATTERN.test(forkId)) {
23948
23999
  return null;
23949
24000
  }
23950
- const rootAbs = path30.resolve(targetRoot);
24001
+ const rootAbs = path32.resolve(targetRoot);
23951
24002
  const rootReal = await realpath2(rootAbs).catch(() => rootAbs);
23952
- const lineagePath = path30.join(rootReal, "forks", forkId, "lineage.json");
23953
- const rel = path30.relative(rootReal, lineagePath);
23954
- if (rel.startsWith("..") || path30.isAbsolute(rel)) {
24003
+ const lineagePath = path32.join(rootReal, "forks", forkId, "lineage.json");
24004
+ const rel = path32.relative(rootReal, lineagePath);
24005
+ if (rel.startsWith("..") || path32.isAbsolute(rel)) {
23955
24006
  return null;
23956
24007
  }
23957
24008
  if (!await isLineagePathContained(rootReal, lineagePath)) {
@@ -23992,19 +24043,19 @@ async function pathEntryExists(absPath) {
23992
24043
  async function isLineagePathContained(rootReal, lineagePath) {
23993
24044
  let existing = lineagePath;
23994
24045
  const suffix = [];
23995
- while (existing !== path30.dirname(existing)) {
24046
+ while (existing !== path32.dirname(existing)) {
23996
24047
  const st = await lstat3(existing).catch(() => null);
23997
24048
  if (st !== null) break;
23998
- suffix.unshift(path30.basename(existing));
23999
- existing = path30.dirname(existing);
24049
+ suffix.unshift(path32.basename(existing));
24050
+ existing = path32.dirname(existing);
24000
24051
  }
24001
24052
  const existingReal = await realpath2(existing).catch(() => existing);
24002
- const targetReal = suffix.length > 0 ? path30.join(existingReal, ...suffix) : existingReal;
24003
- const rel = path30.relative(rootReal, targetReal);
24053
+ const targetReal = suffix.length > 0 ? path32.join(existingReal, ...suffix) : existingReal;
24054
+ const rel = path32.relative(rootReal, targetReal);
24004
24055
  if (rel === "") return true;
24005
24056
  if (rel === "..") return false;
24006
- if (rel.startsWith(`..${path30.sep}`)) return false;
24007
- if (path30.isAbsolute(rel)) return false;
24057
+ if (rel.startsWith(`..${path32.sep}`)) return false;
24058
+ if (path32.isAbsolute(rel)) return false;
24008
24059
  return true;
24009
24060
  }
24010
24061
 
@@ -24124,4 +24175,4 @@ export {
24124
24175
  filterRecallCandidates,
24125
24176
  Orchestrator
24126
24177
  };
24127
- //# sourceMappingURL=chunk-GODSPTOT.js.map
24178
+ //# sourceMappingURL=chunk-M32URQXV.js.map