@remnic/core 9.65.8 → 9.66.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 (702) hide show
  1. package/dist/access-admin-ops-surface.d.ts +11 -12
  2. package/dist/access-admin-ops-surface.js +54 -51
  3. package/dist/access-authorization-probe.d.ts +11 -12
  4. package/dist/access-authorization-probe.js +55 -52
  5. package/dist/access-boundary.d.ts +11 -12
  6. package/dist/access-boundary.js +54 -51
  7. package/dist/access-citation-namespace.js +3 -3
  8. package/dist/access-cli.js +132 -125
  9. package/dist/access-cli.js.map +1 -1
  10. package/dist/access-coding-context-resolution.d.ts +1 -2
  11. package/dist/access-coding-context-resolution.js +2 -2
  12. package/dist/access-extraction-force-flush.d.ts +11 -12
  13. package/dist/access-extraction-force-flush.js +54 -51
  14. package/dist/access-health-types.d.ts +1 -2
  15. package/dist/access-http-lcm-compaction.d.ts +11 -12
  16. package/dist/access-http-lifecycle-flush.d.ts +11 -12
  17. package/dist/access-http-offline-stream.d.ts +11 -12
  18. package/dist/access-http-query.d.ts +2 -3
  19. package/dist/access-http-query.js +56 -53
  20. package/dist/access-http.d.ts +12 -13
  21. package/dist/access-http.js +77 -74
  22. package/dist/access-identity-continuity-surface.d.ts +9 -10
  23. package/dist/access-identity-continuity-surface.js +54 -51
  24. package/dist/access-lcm-surface.d.ts +11 -12
  25. package/dist/access-lcm-surface.js +54 -51
  26. package/dist/access-mcp-output-schemas.js +1 -1
  27. package/dist/access-mcp.d.ts +11 -12
  28. package/dist/access-mcp.js +67 -64
  29. package/dist/access-memory-search-fanout.d.ts +2 -3
  30. package/dist/{access-namespace-preflight-CpAOrS-9.d.ts → access-namespace-preflight-50VIkPhB.d.ts} +1 -1
  31. package/dist/access-namespace-preflight.d.ts +3 -4
  32. package/dist/access-namespace-preflight.js +54 -51
  33. package/dist/access-observe-write-surface.d.ts +11 -12
  34. package/dist/access-observe-write-surface.js +54 -51
  35. package/dist/access-offline-manifest.d.ts +9 -10
  36. package/dist/access-offline-manifest.js +15 -15
  37. package/dist/access-operations-batch.js +59 -56
  38. package/dist/access-operations.d.ts +12 -13
  39. package/dist/access-operations.js +64 -61
  40. package/dist/access-recall-concurrency.d.ts +11 -12
  41. package/dist/access-recall-concurrency.js +54 -51
  42. package/dist/access-recall-response.d.ts +11 -12
  43. package/dist/access-recall-response.js +54 -51
  44. package/dist/access-recall-surface.d.ts +11 -12
  45. package/dist/access-recall-surface.js +54 -51
  46. package/dist/access-schema.d.ts +12 -12
  47. package/dist/access-schema.js +5 -5
  48. package/dist/{access-service-Diu61Cfv.d.ts → access-service-C2tV2-uL.d.ts} +8 -8
  49. package/dist/access-service-helpers.d.ts +11 -12
  50. package/dist/access-service.d.ts +11 -12
  51. package/dist/access-service.js +54 -51
  52. package/dist/access-surface-catalog.d.ts +11 -12
  53. package/dist/access-surface-catalog.js +58 -53
  54. package/dist/access-surface-catalog.js.map +1 -1
  55. package/dist/access-wearables-meetings-surface.d.ts +3 -4
  56. package/dist/action-confidence.d.ts +1 -2
  57. package/dist/active-memory-bridge.d.ts +1 -2
  58. package/dist/active-memory-bridge.js +2 -2
  59. package/dist/active-recall.d.ts +1 -2
  60. package/dist/active-recall.js +11 -11
  61. package/dist/adapters/index.js +7 -7
  62. package/dist/adapters/registry.js +3 -3
  63. package/dist/ambient-provenance.d.ts +1 -2
  64. package/dist/artifact-search.d.ts +1 -2
  65. package/dist/{auto-sync-2YPITIWN.js → auto-sync-Q6Q2FVSC.js} +9 -9
  66. package/dist/behavior-learner.d.ts +1 -2
  67. package/dist/behavior-signals.d.ts +1 -2
  68. package/dist/bootstrap.d.ts +9 -10
  69. package/dist/briefing-window.d.ts +2 -3
  70. package/dist/briefing.d.ts +2 -3
  71. package/dist/briefing.js +28 -28
  72. package/dist/buffer-surprise-report.d.ts +1 -2
  73. package/dist/buffer-turn-helpers.d.ts +1 -2
  74. package/dist/buffer.d.ts +2 -3
  75. package/dist/buffer.js +20 -4
  76. package/dist/bulk-import/index.d.ts +3 -4
  77. package/dist/calibration.d.ts +1 -2
  78. package/dist/calibration.js +1 -1
  79. package/dist/capabilities.d.ts +1 -2
  80. package/dist/{capsule-merge-SGIVB3WA.js → capsule-merge-SEHERWWP.js} +4 -4
  81. package/dist/{catalog-9f-vEQLS.d.ts → catalog-C2jA-gLm.d.ts} +1 -1
  82. package/dist/causal-behavior.d.ts +1 -2
  83. package/dist/causal-consolidation.d.ts +1 -2
  84. package/dist/causal-consolidation.js +29 -29
  85. package/dist/causal-trajectory-graph.d.ts +1 -2
  86. package/dist/{chunk-LEPOP46W.js → chunk-227UFSEQ.js} +4 -4
  87. package/dist/{chunk-TFR3HG4K.js → chunk-2FA7U5XY.js} +4 -4
  88. package/dist/{chunk-PO7NXBG2.js → chunk-2GF27PGH.js} +5 -5
  89. package/dist/{chunk-W2BAGGEW.js → chunk-2ITZ74A6.js} +40 -31
  90. package/dist/{chunk-W2BAGGEW.js.map → chunk-2ITZ74A6.js.map} +1 -1
  91. package/dist/{chunk-MY2BC6UE.js → chunk-2X6BGKQL.js} +11 -11
  92. package/dist/{chunk-UEBDCMOO.js → chunk-3TSU662L.js} +3 -3
  93. package/dist/{chunk-XAB6STPO.js → chunk-46XR5FNZ.js} +53 -3
  94. package/dist/chunk-46XR5FNZ.js.map +1 -0
  95. package/dist/{chunk-FP7YTTVO.js → chunk-4OFKZAJG.js} +2 -1
  96. package/dist/chunk-4OFKZAJG.js.map +1 -0
  97. package/dist/{chunk-S5XOSTYM.js → chunk-4XLTUR6R.js} +3 -3
  98. package/dist/{chunk-BWGCOLEL.js → chunk-65JOGLIS.js} +2 -2
  99. package/dist/{chunk-HMZKGHMD.js → chunk-7UOXCCCI.js} +3 -3
  100. package/dist/{chunk-7WOWGRAU.js → chunk-AF5H7TKI.js} +108 -23
  101. package/dist/chunk-AF5H7TKI.js.map +1 -0
  102. package/dist/{chunk-7BDZTALN.js → chunk-AJTG3CP7.js} +12 -2
  103. package/dist/chunk-AJTG3CP7.js.map +1 -0
  104. package/dist/{chunk-2LWQSV6A.js → chunk-AL3UYZ5N.js} +3 -2
  105. package/dist/chunk-AL3UYZ5N.js.map +1 -0
  106. package/dist/{chunk-4F4AQFWL.js → chunk-B4AOWRYF.js} +10 -10
  107. package/dist/{chunk-ODU2CNNX.js → chunk-C5IUOBCN.js} +2 -2
  108. package/dist/{chunk-3A2NJP2U.js → chunk-CHGG74CY.js} +3 -3
  109. package/dist/{chunk-76DIF5KT.js → chunk-CX4OLNIH.js} +2 -2
  110. package/dist/{chunk-Z3YEGSR4.js → chunk-D3UXGE5D.js} +10 -10
  111. package/dist/{chunk-5HK3CJAR.js → chunk-D6Q5EPOV.js} +2 -2
  112. package/dist/{chunk-EGBDFJ36.js → chunk-DD5JFCWM.js} +2 -2
  113. package/dist/{chunk-XBGHAAKR.js → chunk-DDX6KIXF.js} +2 -2
  114. package/dist/{chunk-JIYDRBVZ.js → chunk-DJORULH3.js} +2 -2
  115. package/dist/{chunk-7KQB4EBS.js → chunk-DUAJKRR2.js} +2 -2
  116. package/dist/{chunk-XDL5CYZN.js → chunk-EEOUMG3J.js} +2 -1
  117. package/dist/{chunk-XDL5CYZN.js.map → chunk-EEOUMG3J.js.map} +1 -1
  118. package/dist/{chunk-Q57GOHLF.js → chunk-EGALNSZ4.js} +3 -3
  119. package/dist/{chunk-DPCXDG7G.js → chunk-EH65UV2Z.js} +2 -2
  120. package/dist/{chunk-KCT36JAW.js → chunk-ESNFSSO4.js} +2 -2
  121. package/dist/{chunk-XQ3HXAQH.js → chunk-ET2CNMLD.js} +4 -4
  122. package/dist/{chunk-TUHBYJXL.js → chunk-EWKVYCFP.js} +1 -1
  123. package/dist/{chunk-NPFUNWNX.js → chunk-FFUMTH27.js} +2 -2
  124. package/dist/{chunk-3PKAS6VL.js → chunk-GAJK3DQ5.js} +2 -2
  125. package/dist/{chunk-DA7ITC5Z.js → chunk-GBEOUCBB.js} +2 -2
  126. package/dist/{chunk-UENKPWCS.js → chunk-H2IRSXZN.js} +6 -6
  127. package/dist/{chunk-CFVTRUR3.js → chunk-H6RSANGQ.js} +2 -2
  128. package/dist/chunk-HVAEXYPL.js +98 -0
  129. package/dist/chunk-HVAEXYPL.js.map +1 -0
  130. package/dist/{chunk-EUYWQ7TS.js → chunk-IEZ6CGTW.js} +2 -2
  131. package/dist/{chunk-3SZD4CYO.js → chunk-IGZCAHFL.js} +3 -3
  132. package/dist/{chunk-UPFNQJC7.js → chunk-INUBU6I5.js} +2 -2
  133. package/dist/{chunk-PMVPCZJZ.js → chunk-J2R275FN.js} +3 -3
  134. package/dist/{chunk-UW5NPZJ2.js → chunk-JALOAKSZ.js} +59 -7
  135. package/dist/chunk-JALOAKSZ.js.map +1 -0
  136. package/dist/{chunk-2QSZNTDO.js → chunk-JBPKEARU.js} +7 -7
  137. package/dist/{chunk-3BCULS4U.js → chunk-JKTV3JNX.js} +145 -507
  138. package/dist/chunk-JKTV3JNX.js.map +1 -0
  139. package/dist/{chunk-5ACCD4L7.js → chunk-JRRQ747T.js} +7 -7
  140. package/dist/{chunk-V4IDF3EZ.js → chunk-JTWZKNUH.js} +5 -5
  141. package/dist/{chunk-AZMLH5UT.js → chunk-KI64TTBL.js} +2 -2
  142. package/dist/{chunk-DEACDKE3.js → chunk-KJXCD7VR.js} +112 -87
  143. package/dist/chunk-KJXCD7VR.js.map +1 -0
  144. package/dist/chunk-LJABGXC4.js +267 -0
  145. package/dist/chunk-LJABGXC4.js.map +1 -0
  146. package/dist/{chunk-NPIBN2VL.js → chunk-LK4TOYPU.js} +2 -2
  147. package/dist/{chunk-UTQUEHC7.js → chunk-LUDBXTBJ.js} +8 -8
  148. package/dist/{chunk-PU56CXZA.js → chunk-LYUUA6QB.js} +2 -2
  149. package/dist/{chunk-P36Z4JRA.js → chunk-M5ERTI4I.js} +2 -2
  150. package/dist/{chunk-LDKPDODJ.js → chunk-ME35HVDJ.js} +2 -2
  151. package/dist/{chunk-773TRRGT.js → chunk-MJUCDM3C.js} +2 -2
  152. package/dist/{chunk-OXRRJXPR.js → chunk-MUEGIKKY.js} +476 -1796
  153. package/dist/chunk-MUEGIKKY.js.map +1 -0
  154. package/dist/{chunk-AHPIFKNG.js → chunk-N4F7ZSSG.js} +2 -2
  155. package/dist/{chunk-JOZUBF4A.js → chunk-NACLNNFQ.js} +2 -2
  156. package/dist/{chunk-LC2BDILZ.js → chunk-NBP4EX5N.js} +2 -2
  157. package/dist/{chunk-T7XP6IZE.js → chunk-NFP4KPTA.js} +2 -2
  158. package/dist/{chunk-ZVPVTPGI.js → chunk-NNZFPYYX.js} +4 -4
  159. package/dist/{chunk-LPNCR4QK.js → chunk-NSTNGMSS.js} +14 -14
  160. package/dist/{chunk-5RWZH6PH.js → chunk-NUF7VSEX.js} +2 -2
  161. package/dist/{chunk-7VZFRUQU.js → chunk-O7ERGZDA.js} +5 -5
  162. package/dist/{chunk-HSZMX3ZJ.js → chunk-ODW5GDFE.js} +2 -2
  163. package/dist/{chunk-5DHKCO52.js → chunk-OJUEUQDJ.js} +2 -2
  164. package/dist/{chunk-LOXHYCVS.js → chunk-OMX6TKXH.js} +2 -2
  165. package/dist/{chunk-J2WC5LF4.js → chunk-QBC33MPY.js} +2 -1
  166. package/dist/{chunk-SEEJOGQX.js → chunk-QBNE55VA.js} +4 -4
  167. package/dist/chunk-QJCWK2A7.js +1466 -0
  168. package/dist/chunk-QJCWK2A7.js.map +1 -0
  169. package/dist/{chunk-YEUXERJ6.js → chunk-RDGKVH6T.js} +7 -3
  170. package/dist/{chunk-YEUXERJ6.js.map → chunk-RDGKVH6T.js.map} +1 -1
  171. package/dist/{chunk-JYSN42VN.js → chunk-RPIS5FQ7.js} +237 -183
  172. package/dist/chunk-RPIS5FQ7.js.map +1 -0
  173. package/dist/{chunk-F7XUD3PL.js → chunk-S4CDUXQY.js} +2 -2
  174. package/dist/{chunk-WNXYT4MK.js → chunk-S4Z2OBTX.js} +4 -4
  175. package/dist/{chunk-UL4MKZHI.js → chunk-SN4JXNLL.js} +2 -2
  176. package/dist/{chunk-CAMNRAJF.js → chunk-SZMYGDSM.js} +2 -2
  177. package/dist/chunk-TB2MJRI6.js +866 -0
  178. package/dist/chunk-TB2MJRI6.js.map +1 -0
  179. package/dist/{chunk-XNWXSGHS.js → chunk-TBCDF556.js} +28 -10
  180. package/dist/chunk-TBCDF556.js.map +1 -0
  181. package/dist/{chunk-LKYIOCWL.js → chunk-TCF4MU7L.js} +967 -132
  182. package/dist/chunk-TCF4MU7L.js.map +1 -0
  183. package/dist/chunk-TCQRIIIN.js +202 -0
  184. package/dist/chunk-TCQRIIIN.js.map +1 -0
  185. package/dist/{chunk-7PHI6GUI.js → chunk-TEZ2HTC7.js} +42 -2
  186. package/dist/chunk-TEZ2HTC7.js.map +1 -0
  187. package/dist/{chunk-CPA5NBHN.js → chunk-TNGH4ZYI.js} +2 -2
  188. package/dist/{chunk-F3NVYTTA.js → chunk-TNXNECAN.js} +6 -6
  189. package/dist/{chunk-BEC4YBNA.js → chunk-TVW4C7PV.js} +2 -2
  190. package/dist/{chunk-UFKPQBXH.js → chunk-U62OK7BB.js} +2 -2
  191. package/dist/{chunk-KZIF6XHX.js → chunk-U65VJSCJ.js} +32 -19
  192. package/dist/chunk-U65VJSCJ.js.map +1 -0
  193. package/dist/{chunk-4QEYREAV.js → chunk-U6NGKS32.js} +8 -8
  194. package/dist/{chunk-HRHO3ZNG.js → chunk-UW4RYPWC.js} +2 -2
  195. package/dist/{chunk-AX7UXCHJ.js → chunk-UYA36DQ7.js} +2 -1
  196. package/dist/chunk-UYA36DQ7.js.map +1 -0
  197. package/dist/{chunk-T6ILXUAH.js → chunk-VG4SSPAW.js} +2 -2
  198. package/dist/chunk-VOSWUO3K.js +100 -0
  199. package/dist/chunk-VOSWUO3K.js.map +1 -0
  200. package/dist/chunk-WFCWP4XU.js +17 -0
  201. package/dist/chunk-WFCWP4XU.js.map +1 -0
  202. package/dist/{chunk-H2YSH3DG.js → chunk-WKAXBXVA.js} +2 -2
  203. package/dist/{chunk-SXIMQLGV.js → chunk-WVGXCBOC.js} +2 -2
  204. package/dist/{chunk-UNUMFURP.js → chunk-X5PIDJ3L.js} +3 -3
  205. package/dist/{chunk-CRML27CO.js → chunk-X5YYSAZX.js} +4 -4
  206. package/dist/{chunk-FZEEWOI2.js → chunk-XJJYSX6F.js} +2 -2
  207. package/dist/{chunk-U7EW2W4W.js → chunk-XKNHFDTT.js} +26 -6
  208. package/dist/chunk-XKNHFDTT.js.map +1 -0
  209. package/dist/{chunk-OA2O2GJ4.js → chunk-XOHYGIWF.js} +3 -3
  210. package/dist/{chunk-UG6VXIOK.js → chunk-XSTNGNJP.js} +2 -2
  211. package/dist/{chunk-MINHJ55X.js → chunk-XXW32OL7.js} +1 -1
  212. package/dist/{chunk-MINHJ55X.js.map → chunk-XXW32OL7.js.map} +1 -1
  213. package/dist/{chunk-YDPAE2RD.js → chunk-YFLLGRXO.js} +2 -2
  214. package/dist/{chunk-MDD2RINF.js → chunk-YWPLOJ7T.js} +3 -3
  215. package/dist/{chunk-Q4WONDMJ.js → chunk-YYGZJPOK.js} +2 -2
  216. package/dist/{chunk-GTO56JY5.js → chunk-ZPS724LT.js} +2 -2
  217. package/dist/{chunk-SNOIKAHM.js → chunk-ZZZWEDF4.js} +3 -3
  218. package/dist/{cli-O3F-ht3i.d.ts → cli-CsfFMe6n.d.ts} +5 -5
  219. package/dist/cli.d.ts +13 -14
  220. package/dist/cli.js +101 -96
  221. package/dist/coding/export-okf-codegraph.d.ts +56 -0
  222. package/dist/coding/export-okf-codegraph.js +526 -0
  223. package/dist/coding/export-okf-codegraph.js.map +1 -0
  224. package/dist/coding/pre-action-gate.d.ts +1 -2
  225. package/dist/compounding/engine.d.ts +2 -3
  226. package/dist/compounding/engine.js +29 -29
  227. package/dist/compounding/preference-consolidator.d.ts +1 -2
  228. package/dist/compression-optimizer.d.ts +1 -2
  229. package/dist/config.d.ts +1 -2
  230. package/dist/config.js +11 -11
  231. package/dist/connectors/codex-materialize-runner.d.ts +1 -2
  232. package/dist/connectors/codex-materialize-runner.js +28 -28
  233. package/dist/connectors/codex-materialize.d.ts +1 -2
  234. package/dist/connectors/index.d.ts +1 -2
  235. package/dist/connectors/index.js +28 -28
  236. package/dist/consolidation-provenance-check.d.ts +2 -3
  237. package/dist/consolidation-provenance-check.js +4 -4
  238. package/dist/consolidation-undo.d.ts +2 -3
  239. package/dist/consolidation-undo.js +3 -3
  240. package/dist/contradiction/index.d.ts +3 -4
  241. package/dist/contradiction/index.js +9 -9
  242. package/dist/{contradiction-scan-AKUWPX5N.js → contradiction-scan-NOYMFG66.js} +3 -3
  243. package/dist/converge-config.d.ts +1 -2
  244. package/dist/convergence-refresh.d.ts +2 -3
  245. package/dist/convergence-refresh.js +30 -30
  246. package/dist/conversation-index/backend.d.ts +1 -2
  247. package/dist/conversation-index/backend.js +2 -2
  248. package/dist/conversation-index/chunker.d.ts +1 -2
  249. package/dist/conversation-index/faiss-adapter.d.ts +1 -2
  250. package/dist/conversation-index/indexer.d.ts +1 -2
  251. package/dist/conversation-index/search.d.ts +1 -2
  252. package/dist/corpus-watermark.d.ts +1 -2
  253. package/dist/corpus-watermark.js +30 -30
  254. package/dist/cross-lingual-recall.d.ts +1 -2
  255. package/dist/day-summary.d.ts +1 -2
  256. package/dist/delinearize.d.ts +1 -2
  257. package/dist/dependency-propagation-config.d.ts +1 -2
  258. package/dist/{dependency-propagation-delivery-CL6RWXTA.d.ts → dependency-propagation-delivery-D4WMbOwA.d.ts} +1 -1
  259. package/dist/direct-answer-wiring.d.ts +1 -2
  260. package/dist/direct-answer.d.ts +1 -2
  261. package/dist/embedding-fallback.d.ts +1 -2
  262. package/dist/enrichment/index.d.ts +1 -2
  263. package/dist/entity-origin-fields.d.ts +1 -2
  264. package/dist/entity-retrieval.d.ts +2 -3
  265. package/dist/entity-retrieval.js +28 -28
  266. package/dist/entity-schema.d.ts +1 -2
  267. package/dist/episodic-context.d.ts +1 -2
  268. package/dist/eval-trajectory-contracts.d.ts +1 -2
  269. package/dist/eval-trajectory-store.d.ts +1 -2
  270. package/dist/eval-trajectory.d.ts +1 -2
  271. package/dist/explicit-capture.d.ts +9 -10
  272. package/dist/explicit-capture.js +11 -11
  273. package/dist/external-wiki-access.d.ts +11 -12
  274. package/dist/external-wiki-access.js +55 -52
  275. package/dist/external-wiki-collection-registration.d.ts +1 -2
  276. package/dist/external-wiki-collection.d.ts +1 -2
  277. package/dist/external-wiki-mcp-tools.d.ts +11 -12
  278. package/dist/extraction-error-classification.d.ts +1 -2
  279. package/dist/extraction-faithfulness.d.ts +1 -2
  280. package/dist/extraction-faithfulness.js +2 -2
  281. package/dist/extraction-judge-telemetry.d.ts +1 -2
  282. package/dist/extraction-judge-training.d.ts +1 -2
  283. package/dist/extraction-judge.d.ts +1 -2
  284. package/dist/extraction-judge.js +2 -2
  285. package/dist/extraction-liveness.d.ts +1 -2
  286. package/dist/extraction-normalization.d.ts +1 -2
  287. package/dist/extraction-prompt.d.ts +1 -2
  288. package/dist/extraction-source-grounding-rules.d.ts +1 -2
  289. package/dist/extraction-source-grounding.d.ts +1 -2
  290. package/dist/extraction.d.ts +1 -2
  291. package/dist/extraction.js +37 -34
  292. package/dist/fallback-llm.d.ts +7 -2
  293. package/dist/fallback-llm.js +1 -1
  294. package/dist/{first-start-migration-4NETATFF.js → first-start-migration-KHIMCBIC.js} +3 -3
  295. package/dist/graph-dashboard-diff.d.ts +1 -2
  296. package/dist/graph-dashboard-key.d.ts +1 -2
  297. package/dist/graph-dashboard-parser.d.ts +1 -2
  298. package/dist/graph-edge-reinforcement.d.ts +1 -2
  299. package/dist/graph-path-reconstruction.d.ts +1 -2
  300. package/dist/graph-path-scoring.d.ts +1 -2
  301. package/dist/graph-snapshot.d.ts +1 -2
  302. package/dist/graph.d.ts +1 -2
  303. package/dist/harmonic-retrieval.js +1 -1
  304. package/dist/importance.d.ts +1 -2
  305. package/dist/importers/index.d.ts +1 -2
  306. package/dist/in-flight-reads.d.ts +1 -2
  307. package/dist/{index-C7Xep6S9.d.ts → index-DuJnzwHv.d.ts} +2 -2
  308. package/dist/index.d.ts +364 -26
  309. package/dist/index.js +232 -169
  310. package/dist/intent.d.ts +1 -2
  311. package/dist/lcm/engine.d.ts +1 -2
  312. package/dist/lcm/engine.js +4 -4
  313. package/dist/lcm/index.d.ts +1 -2
  314. package/dist/lcm/index.js +10 -10
  315. package/dist/lcm/tools.d.ts +1 -2
  316. package/dist/lifecycle.d.ts +1 -2
  317. package/dist/live-connectors-runner.d.ts +1 -2
  318. package/dist/local-llm.d.ts +1 -2
  319. package/dist/local-model-endpoint.d.ts +1 -2
  320. package/dist/location/index.d.ts +315 -6
  321. package/dist/location/index.js +151 -19
  322. package/dist/maintenance/memory-governance.d.ts +1 -2
  323. package/dist/maintenance/memory-governance.js +28 -28
  324. package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +2 -3
  325. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +28 -28
  326. package/dist/maintenance/rebuild-memory-projection.d.ts +2 -3
  327. package/dist/maintenance/rebuild-memory-projection.js +29 -29
  328. package/dist/{maintenance-CJ-xqFp0.d.ts → maintenance-BBeaeYRR.d.ts} +3 -3
  329. package/dist/mcp-memory-inspector-app.d.ts +11 -12
  330. package/dist/mcp-read-only-tools.js +1 -1
  331. package/dist/memory-action-policy.d.ts +1 -2
  332. package/dist/memory-cache.d.ts +1 -2
  333. package/dist/memory-controller.d.ts +1 -2
  334. package/dist/memory-lifecycle-ledger-utils.d.ts +1 -2
  335. package/dist/memory-projection-mutations.js +3 -3
  336. package/dist/memory-projection-store.d.ts +1 -2
  337. package/dist/memory-projection-store.js +1 -1
  338. package/dist/memory-provenance.d.ts +1 -2
  339. package/dist/memory-snapshot.d.ts +1 -2
  340. package/dist/memory-subject-cli.d.ts +11 -12
  341. package/dist/memory-subject.d.ts +11 -12
  342. package/dist/memory-subject.js +4 -4
  343. package/dist/memory-worth-outcomes.d.ts +2 -3
  344. package/dist/models-json.d.ts +1 -2
  345. package/dist/namespaces/migrate.d.ts +3 -4
  346. package/dist/namespaces/migrate.js +29 -29
  347. package/dist/namespaces/principal.d.ts +1 -2
  348. package/dist/namespaces/search.d.ts +1 -2
  349. package/dist/namespaces/search.js +8 -8
  350. package/dist/namespaces/storage.d.ts +3 -4
  351. package/dist/namespaces/storage.js +28 -28
  352. package/dist/native-knowledge.d.ts +1 -2
  353. package/dist/offline-sync-file-io.js +3 -3
  354. package/dist/offline-sync-impression-drain.d.ts +1 -2
  355. package/dist/offline-sync-impression-drain.js +9 -9
  356. package/dist/offline-sync.js +4 -4
  357. package/dist/operator-doctor-corpus.d.ts +1 -2
  358. package/dist/operator-doctor-corpus.js +31 -31
  359. package/dist/operator-doctor-replica.d.ts +1 -2
  360. package/dist/operator-toolkit.d.ts +3 -4
  361. package/dist/operator-toolkit.js +47 -47
  362. package/dist/orchestration/compression-guideline-coordinator.d.ts +2 -3
  363. package/dist/orchestration/maintenance.d.ts +4 -5
  364. package/dist/orchestration/maintenance.js +42 -41
  365. package/dist/{orchestrator-BsntWxLy.d.ts → orchestrator-CaqnwNwM.d.ts} +8 -8
  366. package/dist/orchestrator.d.ts +9 -10
  367. package/dist/orchestrator.js +132 -125
  368. package/dist/page-versioning.js +3 -3
  369. package/dist/patterns-cli.d.ts +1 -2
  370. package/dist/{pipeline-CVoysPm2.d.ts → pipeline-CrxVjlJr.d.ts} +1 -1
  371. package/dist/policy-runtime.d.ts +1 -2
  372. package/dist/proactive-contention.d.ts +1 -2
  373. package/dist/provenance.d.ts +1 -2
  374. package/dist/{public-http-CuOxlTC2.d.ts → public-http-Cwvl4QZr.d.ts} +1 -1
  375. package/dist/{purge-GB7PZHT2.js → purge-OP6BEDFY.js} +2 -2
  376. package/dist/{qmd-DWMAGA5l.d.ts → qmd-BZgbJm0g.d.ts} +1 -1
  377. package/dist/qmd-preflight.d.ts +2 -3
  378. package/dist/qmd-recall-cache.d.ts +1 -2
  379. package/dist/qmd.d.ts +2 -3
  380. package/dist/recall-concurrency-config.d.ts +1 -2
  381. package/dist/recall-deep.d.ts +37 -0
  382. package/dist/recall-deep.js +81 -0
  383. package/dist/recall-deep.js.map +1 -0
  384. package/dist/recall-disclosure-escalation.d.ts +1 -2
  385. package/dist/recall-explain-renderer.d.ts +1 -2
  386. package/dist/recall-explain-renderer.js +3 -3
  387. package/dist/recall-memory-map.d.ts +1 -2
  388. package/dist/recall-navigate.d.ts +70 -0
  389. package/dist/recall-navigate.js +51 -0
  390. package/dist/recall-navigate.js.map +1 -0
  391. package/dist/recall-planner-llm.d.ts +1 -2
  392. package/dist/recall-planner-llm.js +1 -1
  393. package/dist/recall-state-view-wire.d.ts +14 -0
  394. package/dist/recall-state-view-wire.js +11 -0
  395. package/dist/recall-state-view.d.ts +25 -0
  396. package/dist/recall-state-view.js +22 -0
  397. package/dist/recall-state-view.js.map +1 -0
  398. package/dist/recall-state.d.ts +1 -2
  399. package/dist/recall-tag-filter.d.ts +1 -2
  400. package/dist/recall-timings.d.ts +1 -2
  401. package/dist/recall-xray-cli.d.ts +1 -2
  402. package/dist/recall-xray-cli.js +4 -4
  403. package/dist/recall-xray-renderer.d.ts +1 -2
  404. package/dist/recall-xray-renderer.js +3 -3
  405. package/dist/recall-xray.d.ts +1 -2
  406. package/dist/recall-xray.js +2 -2
  407. package/dist/reconcile/cursor.d.ts +1 -2
  408. package/dist/reconcile/manifest.d.ts +1 -2
  409. package/dist/reconcile/manifest.js +4 -4
  410. package/dist/reconcile/plan.d.ts +1 -2
  411. package/dist/replay/normalizers/chatgpt.d.ts +1 -2
  412. package/dist/replay/normalizers/claude.d.ts +1 -2
  413. package/dist/replay/normalizers/openclaw.d.ts +1 -2
  414. package/dist/replay/normalizers/shared.d.ts +1 -2
  415. package/dist/replay/runner.d.ts +1 -2
  416. package/dist/replay/types.d.ts +1 -2
  417. package/dist/replica-divergence.d.ts +1 -2
  418. package/dist/replica-peers-config.d.ts +1 -2
  419. package/dist/{resolution-XWBPKYFB.js → resolution-4DLI3IOR.js} +10 -10
  420. package/dist/resolution-4DLI3IOR.js.map +1 -0
  421. package/dist/resolve-auth-token.d.ts +1 -2
  422. package/dist/resume-bundles.js +12 -12
  423. package/dist/retrieval-agents.d.ts +2 -3
  424. package/dist/retrieval-tiers.d.ts +1 -2
  425. package/dist/routing/engine.d.ts +1 -2
  426. package/dist/routing/store.d.ts +1 -2
  427. package/dist/salvage-envelope.d.ts +1 -2
  428. package/dist/salvage-envelope.js +6 -6
  429. package/dist/schemas.d.ts +570 -105
  430. package/dist/schemas.js +3 -1
  431. package/dist/{scope-profiles-CPWkW_dI.d.ts → scope-profiles-DFaojvoP.d.ts} +1 -1
  432. package/dist/search/document-scanner.js +1 -1
  433. package/dist/search/embed-helper.d.ts +1 -2
  434. package/dist/search/factory.d.ts +1 -2
  435. package/dist/search/factory.js +7 -7
  436. package/dist/search/index.d.ts +1 -2
  437. package/dist/search/index.js +13 -13
  438. package/dist/search/lancedb-backend.d.ts +1 -2
  439. package/dist/search/lancedb-backend.js +1 -1
  440. package/dist/search/meilisearch-backend.d.ts +1 -2
  441. package/dist/search/meilisearch-backend.js +1 -1
  442. package/dist/search/noop-backend.d.ts +1 -2
  443. package/dist/search/orama-backend.d.ts +1 -2
  444. package/dist/search/orama-backend.js +1 -1
  445. package/dist/search/port.d.ts +1 -2
  446. package/dist/search/remote-backend.d.ts +1 -2
  447. package/dist/secure-store/index.js +3 -3
  448. package/dist/{semantic-consolidation-CNFVBXFc.d.ts → semantic-consolidation-BiX68wZA.d.ts} +1 -1
  449. package/dist/semantic-consolidation.d.ts +2 -3
  450. package/dist/semantic-consolidation.js +29 -29
  451. package/dist/semantic-rule-promotion.js +28 -28
  452. package/dist/semantic-rule-verifier.d.ts +1 -2
  453. package/dist/semantic-rule-verifier.js +28 -28
  454. package/dist/{service-Bb-JIdQ0.d.ts → service-D5h2zZ0M.d.ts} +2 -2
  455. package/dist/session-observer-bands.d.ts +1 -2
  456. package/dist/session-observer-state.d.ts +1 -2
  457. package/dist/shared-context/manager.d.ts +1 -2
  458. package/dist/signal.d.ts +1 -2
  459. package/dist/source-agent-qualifier.d.ts +1 -2
  460. package/dist/source-agent-qualifier.js +35 -32
  461. package/dist/standup/build.d.ts +16 -0
  462. package/dist/standup/build.js +17 -0
  463. package/dist/standup/build.js.map +1 -0
  464. package/dist/{storage-CukrlNKk.d.ts → storage-CtsaojWD.d.ts} +1 -1
  465. package/dist/storage.d.ts +2 -3
  466. package/dist/storage.js +27 -27
  467. package/dist/subject-config.d.ts +1 -2
  468. package/dist/subject-config.js +5 -5
  469. package/dist/summarizer.d.ts +1 -2
  470. package/dist/summarizer.js +2 -2
  471. package/dist/summary-snapshot.d.ts +1 -2
  472. package/dist/support-passport/index.d.ts +16 -17
  473. package/dist/support-passport/index.js +57 -54
  474. package/dist/temporal-supersession.d.ts +2 -3
  475. package/dist/temporal-timeline-recall.d.ts +1 -2
  476. package/dist/temporal-validity.d.ts +1 -2
  477. package/dist/threading.d.ts +1 -2
  478. package/dist/tier-migration.d.ts +2 -3
  479. package/dist/tier-routing.d.ts +1 -2
  480. package/dist/tier-routing.js +2 -2
  481. package/dist/{tier-stats-4B5IJ3NE.js → tier-stats-2TOW3QNL.js} +3 -3
  482. package/dist/topics.d.ts +1 -2
  483. package/dist/transcript.d.ts +1 -2
  484. package/dist/transfer/capsule-import.js +4 -4
  485. package/dist/transfer/export-okf.d.ts +39 -0
  486. package/dist/transfer/export-okf.js +112 -0
  487. package/dist/transfer/export-okf.js.map +1 -0
  488. package/dist/trust-score-stage.d.ts +1 -2
  489. package/dist/trust-score.d.ts +1 -2
  490. package/dist/{types-djxQlxJ7.d.ts → types-CIpfYz1I.d.ts} +132 -12
  491. package/dist/types.d.ts +1 -2
  492. package/dist/types.js +1 -1
  493. package/dist/utility-runtime.d.ts +1 -2
  494. package/dist/verified-recall.js +28 -28
  495. package/dist/who-knows-cli.d.ts +11 -12
  496. package/dist/who-knows-cli.js +29 -29
  497. package/dist/who-knows.d.ts +11 -12
  498. package/dist/who-knows.js +28 -28
  499. package/dist/write-envelope.d.ts +1 -2
  500. package/dist/write-envelope.js +5 -5
  501. package/package.json +34 -3
  502. package/src/access-admin-ops-surface.ts +6 -1
  503. package/src/access-boundary.ts +1 -0
  504. package/src/access-http.ts +3 -1
  505. package/src/access-mcp-output-schemas.ts +1 -0
  506. package/src/access-mcp.ts +3 -3
  507. package/src/access-operations.ts +1 -0
  508. package/src/access-service-offline-file-content.test.ts +63 -0
  509. package/src/access-surface-catalog.ts +2 -0
  510. package/src/activity/config.test.ts +1 -0
  511. package/src/activity/config.ts +66 -1
  512. package/src/activity/index.ts +3 -0
  513. package/src/activity/journal.test.ts +97 -0
  514. package/src/activity/journal.ts +113 -0
  515. package/src/activity/privacy.test.ts +53 -0
  516. package/src/activity/privacy.ts +80 -0
  517. package/src/activity/timeline/build.ts +279 -0
  518. package/src/activity/timeline/categories.ts +111 -0
  519. package/src/activity/timeline/classify.ts +110 -0
  520. package/src/activity/timeline/corrections.ts +145 -0
  521. package/src/activity/timeline/index.ts +8 -0
  522. package/src/activity/timeline/journal-recap.test.ts +113 -0
  523. package/src/activity/timeline/journal-recap.ts +130 -0
  524. package/src/activity/timeline/query.test.ts +198 -0
  525. package/src/activity/timeline/query.ts +313 -0
  526. package/src/activity/timeline/timeline.test.ts +277 -0
  527. package/src/activity/timeline/types.ts +106 -0
  528. package/src/activity/timeline/weekly.test.ts +215 -0
  529. package/src/activity/timeline/weekly.ts +234 -0
  530. package/src/activity/types.ts +20 -0
  531. package/src/activity/vault-publish.test.ts +166 -0
  532. package/src/activity/vault-publish.ts +101 -0
  533. package/src/cli/okf-commands.ts +45 -0
  534. package/src/cli.ts +2 -2
  535. package/src/coding/export-okf-codegraph.test.ts +381 -0
  536. package/src/coding/export-okf-codegraph.ts +565 -0
  537. package/src/config.test.ts +1 -0
  538. package/src/config.ts +2 -22
  539. package/src/dedup/merge-on-write.test.ts +91 -0
  540. package/src/dedup/merge-on-write.ts +75 -0
  541. package/src/dedup/novelty-gate.test.ts +143 -0
  542. package/src/dedup/novelty-gate.ts +163 -0
  543. package/src/extraction-prompt-safety.test.ts +14 -2
  544. package/src/extraction.ts +21 -1
  545. package/src/fallback-llm.test.ts +134 -0
  546. package/src/fallback-llm.ts +77 -5
  547. package/src/location/access-operations.ts +17 -8
  548. package/src/location/backfill.ts +137 -0
  549. package/src/location/config.test.ts +3 -0
  550. package/src/location/config.ts +46 -2
  551. package/src/location/http-glue.ts +1 -1
  552. package/src/location/index.ts +3 -0
  553. package/src/location/intervals.ts +1 -0
  554. package/src/location/matching.test.ts +65 -0
  555. package/src/location/matching.ts +354 -0
  556. package/src/location/mcp-tools.ts +2 -1
  557. package/src/location/recall-exclusion.test.ts +1 -0
  558. package/src/location/surfaces.test.ts +15 -2
  559. package/src/location/surfaces.ts +95 -18
  560. package/src/location/tagging.test.ts +119 -0
  561. package/src/location/tagging.ts +277 -0
  562. package/src/location/types.ts +23 -1
  563. package/src/mcp-read-only-tools.ts +1 -0
  564. package/src/memory-projection-store.ts +3 -1
  565. package/src/okf/cli.ts +18 -5
  566. package/src/okf/config.ts +5 -0
  567. package/src/okf/index-files.test.ts +60 -0
  568. package/src/okf/index-files.ts +114 -0
  569. package/src/okf/render.ts +133 -0
  570. package/src/okf/type-mapping.test.ts +3 -0
  571. package/src/okf/type-mapping.ts +2 -0
  572. package/src/orchestration/extraction-persist.ts +22 -23
  573. package/src/orchestration/extraction-run.ts +2 -1
  574. package/src/orchestration/generic-recall-paths.ts +15 -3
  575. package/src/orchestration/recall-entry.ts +8 -3
  576. package/src/recall-deep.test.ts +72 -0
  577. package/src/recall-deep.ts +113 -0
  578. package/src/recall-navigate.test.ts +84 -0
  579. package/src/recall-navigate.ts +100 -0
  580. package/src/recall-state-view-wire.test.ts +35 -0
  581. package/src/recall-state-view-wire.ts +28 -0
  582. package/src/recall-state-view.test.ts +131 -0
  583. package/src/recall-state-view.ts +138 -0
  584. package/src/schemas.ts +17 -1
  585. package/src/shared-context/governance.test.ts +53 -0
  586. package/src/shared-context/governance.ts +86 -0
  587. package/src/standup/access-operations.ts +14 -0
  588. package/src/standup/build.test.ts +34 -0
  589. package/src/standup/build.ts +115 -0
  590. package/src/standup/http-glue.ts +15 -0
  591. package/src/standup/mcp-tools.ts +16 -0
  592. package/src/support-passport/card-projection.ts +1 -0
  593. package/src/support-passport/card-service-commit-forwarding.test.ts +1 -0
  594. package/src/support-passport/card-service.test.ts +75 -1
  595. package/src/support-passport/card-service.ts +6 -3
  596. package/src/support-passport/card-state.ts +5 -1
  597. package/src/support-passport/offline-sync-guard.ts +14 -1
  598. package/src/transfer/export-okf.test.ts +164 -0
  599. package/src/transfer/export-okf.ts +286 -0
  600. package/src/types.ts +3 -10
  601. package/dist/chunk-2LWQSV6A.js.map +0 -1
  602. package/dist/chunk-3BCULS4U.js.map +0 -1
  603. package/dist/chunk-7BDZTALN.js.map +0 -1
  604. package/dist/chunk-7PHI6GUI.js.map +0 -1
  605. package/dist/chunk-7WOWGRAU.js.map +0 -1
  606. package/dist/chunk-AX7UXCHJ.js.map +0 -1
  607. package/dist/chunk-DEACDKE3.js.map +0 -1
  608. package/dist/chunk-FP7YTTVO.js.map +0 -1
  609. package/dist/chunk-JYSN42VN.js.map +0 -1
  610. package/dist/chunk-KZIF6XHX.js.map +0 -1
  611. package/dist/chunk-LKYIOCWL.js.map +0 -1
  612. package/dist/chunk-OXRRJXPR.js.map +0 -1
  613. package/dist/chunk-U7EW2W4W.js.map +0 -1
  614. package/dist/chunk-UW5NPZJ2.js.map +0 -1
  615. package/dist/chunk-XAB6STPO.js.map +0 -1
  616. package/dist/chunk-XNWXSGHS.js.map +0 -1
  617. package/dist/types-CM86alG1.d.ts +0 -89
  618. /package/dist/{auto-sync-2YPITIWN.js.map → auto-sync-Q6Q2FVSC.js.map} +0 -0
  619. /package/dist/{capsule-merge-SGIVB3WA.js.map → capsule-merge-SEHERWWP.js.map} +0 -0
  620. /package/dist/{chunk-LEPOP46W.js.map → chunk-227UFSEQ.js.map} +0 -0
  621. /package/dist/{chunk-TFR3HG4K.js.map → chunk-2FA7U5XY.js.map} +0 -0
  622. /package/dist/{chunk-PO7NXBG2.js.map → chunk-2GF27PGH.js.map} +0 -0
  623. /package/dist/{chunk-MY2BC6UE.js.map → chunk-2X6BGKQL.js.map} +0 -0
  624. /package/dist/{chunk-UEBDCMOO.js.map → chunk-3TSU662L.js.map} +0 -0
  625. /package/dist/{chunk-S5XOSTYM.js.map → chunk-4XLTUR6R.js.map} +0 -0
  626. /package/dist/{chunk-BWGCOLEL.js.map → chunk-65JOGLIS.js.map} +0 -0
  627. /package/dist/{chunk-HMZKGHMD.js.map → chunk-7UOXCCCI.js.map} +0 -0
  628. /package/dist/{chunk-4F4AQFWL.js.map → chunk-B4AOWRYF.js.map} +0 -0
  629. /package/dist/{chunk-ODU2CNNX.js.map → chunk-C5IUOBCN.js.map} +0 -0
  630. /package/dist/{chunk-3A2NJP2U.js.map → chunk-CHGG74CY.js.map} +0 -0
  631. /package/dist/{chunk-76DIF5KT.js.map → chunk-CX4OLNIH.js.map} +0 -0
  632. /package/dist/{chunk-Z3YEGSR4.js.map → chunk-D3UXGE5D.js.map} +0 -0
  633. /package/dist/{chunk-5HK3CJAR.js.map → chunk-D6Q5EPOV.js.map} +0 -0
  634. /package/dist/{chunk-EGBDFJ36.js.map → chunk-DD5JFCWM.js.map} +0 -0
  635. /package/dist/{chunk-XBGHAAKR.js.map → chunk-DDX6KIXF.js.map} +0 -0
  636. /package/dist/{chunk-JIYDRBVZ.js.map → chunk-DJORULH3.js.map} +0 -0
  637. /package/dist/{chunk-7KQB4EBS.js.map → chunk-DUAJKRR2.js.map} +0 -0
  638. /package/dist/{chunk-Q57GOHLF.js.map → chunk-EGALNSZ4.js.map} +0 -0
  639. /package/dist/{chunk-DPCXDG7G.js.map → chunk-EH65UV2Z.js.map} +0 -0
  640. /package/dist/{chunk-KCT36JAW.js.map → chunk-ESNFSSO4.js.map} +0 -0
  641. /package/dist/{chunk-XQ3HXAQH.js.map → chunk-ET2CNMLD.js.map} +0 -0
  642. /package/dist/{chunk-TUHBYJXL.js.map → chunk-EWKVYCFP.js.map} +0 -0
  643. /package/dist/{chunk-NPFUNWNX.js.map → chunk-FFUMTH27.js.map} +0 -0
  644. /package/dist/{chunk-3PKAS6VL.js.map → chunk-GAJK3DQ5.js.map} +0 -0
  645. /package/dist/{chunk-DA7ITC5Z.js.map → chunk-GBEOUCBB.js.map} +0 -0
  646. /package/dist/{chunk-UENKPWCS.js.map → chunk-H2IRSXZN.js.map} +0 -0
  647. /package/dist/{chunk-CFVTRUR3.js.map → chunk-H6RSANGQ.js.map} +0 -0
  648. /package/dist/{chunk-EUYWQ7TS.js.map → chunk-IEZ6CGTW.js.map} +0 -0
  649. /package/dist/{chunk-3SZD4CYO.js.map → chunk-IGZCAHFL.js.map} +0 -0
  650. /package/dist/{chunk-UPFNQJC7.js.map → chunk-INUBU6I5.js.map} +0 -0
  651. /package/dist/{chunk-PMVPCZJZ.js.map → chunk-J2R275FN.js.map} +0 -0
  652. /package/dist/{chunk-2QSZNTDO.js.map → chunk-JBPKEARU.js.map} +0 -0
  653. /package/dist/{chunk-5ACCD4L7.js.map → chunk-JRRQ747T.js.map} +0 -0
  654. /package/dist/{chunk-V4IDF3EZ.js.map → chunk-JTWZKNUH.js.map} +0 -0
  655. /package/dist/{chunk-AZMLH5UT.js.map → chunk-KI64TTBL.js.map} +0 -0
  656. /package/dist/{chunk-NPIBN2VL.js.map → chunk-LK4TOYPU.js.map} +0 -0
  657. /package/dist/{chunk-UTQUEHC7.js.map → chunk-LUDBXTBJ.js.map} +0 -0
  658. /package/dist/{chunk-PU56CXZA.js.map → chunk-LYUUA6QB.js.map} +0 -0
  659. /package/dist/{chunk-P36Z4JRA.js.map → chunk-M5ERTI4I.js.map} +0 -0
  660. /package/dist/{chunk-LDKPDODJ.js.map → chunk-ME35HVDJ.js.map} +0 -0
  661. /package/dist/{chunk-773TRRGT.js.map → chunk-MJUCDM3C.js.map} +0 -0
  662. /package/dist/{chunk-AHPIFKNG.js.map → chunk-N4F7ZSSG.js.map} +0 -0
  663. /package/dist/{chunk-JOZUBF4A.js.map → chunk-NACLNNFQ.js.map} +0 -0
  664. /package/dist/{chunk-LC2BDILZ.js.map → chunk-NBP4EX5N.js.map} +0 -0
  665. /package/dist/{chunk-T7XP6IZE.js.map → chunk-NFP4KPTA.js.map} +0 -0
  666. /package/dist/{chunk-ZVPVTPGI.js.map → chunk-NNZFPYYX.js.map} +0 -0
  667. /package/dist/{chunk-LPNCR4QK.js.map → chunk-NSTNGMSS.js.map} +0 -0
  668. /package/dist/{chunk-5RWZH6PH.js.map → chunk-NUF7VSEX.js.map} +0 -0
  669. /package/dist/{chunk-7VZFRUQU.js.map → chunk-O7ERGZDA.js.map} +0 -0
  670. /package/dist/{chunk-HSZMX3ZJ.js.map → chunk-ODW5GDFE.js.map} +0 -0
  671. /package/dist/{chunk-5DHKCO52.js.map → chunk-OJUEUQDJ.js.map} +0 -0
  672. /package/dist/{chunk-LOXHYCVS.js.map → chunk-OMX6TKXH.js.map} +0 -0
  673. /package/dist/{chunk-J2WC5LF4.js.map → chunk-QBC33MPY.js.map} +0 -0
  674. /package/dist/{chunk-SEEJOGQX.js.map → chunk-QBNE55VA.js.map} +0 -0
  675. /package/dist/{chunk-F7XUD3PL.js.map → chunk-S4CDUXQY.js.map} +0 -0
  676. /package/dist/{chunk-WNXYT4MK.js.map → chunk-S4Z2OBTX.js.map} +0 -0
  677. /package/dist/{chunk-UL4MKZHI.js.map → chunk-SN4JXNLL.js.map} +0 -0
  678. /package/dist/{chunk-CAMNRAJF.js.map → chunk-SZMYGDSM.js.map} +0 -0
  679. /package/dist/{chunk-CPA5NBHN.js.map → chunk-TNGH4ZYI.js.map} +0 -0
  680. /package/dist/{chunk-F3NVYTTA.js.map → chunk-TNXNECAN.js.map} +0 -0
  681. /package/dist/{chunk-BEC4YBNA.js.map → chunk-TVW4C7PV.js.map} +0 -0
  682. /package/dist/{chunk-UFKPQBXH.js.map → chunk-U62OK7BB.js.map} +0 -0
  683. /package/dist/{chunk-4QEYREAV.js.map → chunk-U6NGKS32.js.map} +0 -0
  684. /package/dist/{chunk-HRHO3ZNG.js.map → chunk-UW4RYPWC.js.map} +0 -0
  685. /package/dist/{chunk-T6ILXUAH.js.map → chunk-VG4SSPAW.js.map} +0 -0
  686. /package/dist/{chunk-H2YSH3DG.js.map → chunk-WKAXBXVA.js.map} +0 -0
  687. /package/dist/{chunk-SXIMQLGV.js.map → chunk-WVGXCBOC.js.map} +0 -0
  688. /package/dist/{chunk-UNUMFURP.js.map → chunk-X5PIDJ3L.js.map} +0 -0
  689. /package/dist/{chunk-CRML27CO.js.map → chunk-X5YYSAZX.js.map} +0 -0
  690. /package/dist/{chunk-FZEEWOI2.js.map → chunk-XJJYSX6F.js.map} +0 -0
  691. /package/dist/{chunk-OA2O2GJ4.js.map → chunk-XOHYGIWF.js.map} +0 -0
  692. /package/dist/{chunk-UG6VXIOK.js.map → chunk-XSTNGNJP.js.map} +0 -0
  693. /package/dist/{chunk-YDPAE2RD.js.map → chunk-YFLLGRXO.js.map} +0 -0
  694. /package/dist/{chunk-MDD2RINF.js.map → chunk-YWPLOJ7T.js.map} +0 -0
  695. /package/dist/{chunk-Q4WONDMJ.js.map → chunk-YYGZJPOK.js.map} +0 -0
  696. /package/dist/{chunk-GTO56JY5.js.map → chunk-ZPS724LT.js.map} +0 -0
  697. /package/dist/{chunk-SNOIKAHM.js.map → chunk-ZZZWEDF4.js.map} +0 -0
  698. /package/dist/{contradiction-scan-AKUWPX5N.js.map → contradiction-scan-NOYMFG66.js.map} +0 -0
  699. /package/dist/{first-start-migration-4NETATFF.js.map → first-start-migration-KHIMCBIC.js.map} +0 -0
  700. /package/dist/{purge-GB7PZHT2.js.map → purge-OP6BEDFY.js.map} +0 -0
  701. /package/dist/{resolution-XWBPKYFB.js.map → recall-state-view-wire.js.map} +0 -0
  702. /package/dist/{tier-stats-4B5IJ3NE.js.map → tier-stats-2TOW3QNL.js.map} +0 -0
@@ -8,20 +8,34 @@ import {
8
8
  } from "./chunk-GDB4J2H3.js";
9
9
  import {
10
10
  importCapsule
11
- } from "./chunk-PMVPCZJZ.js";
11
+ } from "./chunk-J2R275FN.js";
12
12
  import {
13
- buildCodingGraphInstallHint,
14
- tryLoadCodingGraphModule
15
- } from "./chunk-VQ7B2Q6M.js";
13
+ ACTIVE_DECISION_STATUSES,
14
+ CodegraphRuntimeError,
15
+ DEFAULT_DECISION_STATUS,
16
+ buildArchitectureCard,
17
+ codegraphSurfaceVisible,
18
+ createArchitectureCardSummariser,
19
+ createArchitectureVersioningHook,
20
+ deleteCodegraphProject,
21
+ getCodegraphStore,
22
+ handleCodingArchitecture,
23
+ isDecisionStatus,
24
+ listCodegraphProjects,
25
+ makeCodegraphRuntimeDelegates,
26
+ parseDecisionRecord,
27
+ resolveCodegraphProjectId,
28
+ serializeDecisionRecord
29
+ } from "./chunk-QJCWK2A7.js";
30
+ import {
31
+ WriteQuarantineStore
32
+ } from "./chunk-PJSK6OJM.js";
16
33
  import {
17
34
  WHO_KNOWS_DEFAULT_LIMIT,
18
35
  computeWhoKnows,
19
36
  loadWhoKnowsEntities,
20
37
  validateWhoKnowsInput
21
- } from "./chunk-HRHO3ZNG.js";
22
- import {
23
- WriteQuarantineStore
24
- } from "./chunk-PJSK6OJM.js";
38
+ } from "./chunk-UW4RYPWC.js";
25
39
  import {
26
40
  trustResultFor
27
41
  } from "./chunk-GNVZQ5JN.js";
@@ -45,13 +59,13 @@ import {
45
59
  } from "./chunk-H7XKCNR6.js";
46
60
  import {
47
61
  toRecallExplainJson
48
- } from "./chunk-CFVTRUR3.js";
62
+ } from "./chunk-H6RSANGQ.js";
49
63
  import {
50
64
  estimateRecallTokens
51
- } from "./chunk-NPIBN2VL.js";
65
+ } from "./chunk-LK4TOYPU.js";
52
66
  import {
53
67
  readAggregateExtractionWatermark
54
- } from "./chunk-LOXHYCVS.js";
68
+ } from "./chunk-OMX6TKXH.js";
55
69
  import {
56
70
  ReplicaDivergenceMonitor
57
71
  } from "./chunk-CVILPI77.js";
@@ -92,7 +106,7 @@ import {
92
106
  persistExplicitCapture,
93
107
  queueExplicitCaptureForReview,
94
108
  validateExplicitCaptureInput
95
- } from "./chunk-CRML27CO.js";
109
+ } from "./chunk-X5YYSAZX.js";
96
110
  import {
97
111
  lcmEvidenceIdentity
98
112
  } from "./chunk-C37ZRXX7.js";
@@ -104,7 +118,7 @@ import {
104
118
  import {
105
119
  CorpusWatermarkCache,
106
120
  computeServiceCorpusCensus
107
- } from "./chunk-CAMNRAJF.js";
121
+ } from "./chunk-SZMYGDSM.js";
108
122
  import {
109
123
  CrossNamespaceBudget,
110
124
  toBudgetWarning
@@ -116,14 +130,14 @@ import {
116
130
  listMemoryGovernanceRuns,
117
131
  readMemoryGovernanceRunArtifact,
118
132
  runMemoryGovernance
119
- } from "./chunk-SEEJOGQX.js";
133
+ } from "./chunk-QBNE55VA.js";
120
134
  import {
121
135
  ExtractionDeadlineError,
122
136
  isActivityDigestPath,
123
137
  isArtifactMemoryPath,
124
138
  isLocationDayPath,
125
139
  isMeetingRecordPath
126
- } from "./chunk-YEUXERJ6.js";
140
+ } from "./chunk-RDGKVH6T.js";
127
141
  import {
128
142
  defaultCapsulesDir
129
143
  } from "./chunk-ZY2MNJR6.js";
@@ -133,42 +147,31 @@ import {
133
147
  enqueuePassiveCorrectionNotification,
134
148
  parseBriefingFocus,
135
149
  parseBriefingWindow
136
- } from "./chunk-HMZKGHMD.js";
150
+ } from "./chunk-7UOXCCCI.js";
137
151
  import {
152
+ OKF_RESERVED_BASENAMES,
138
153
  parseEntityFile,
139
154
  parseFrontmatter,
140
155
  qmdCollectionPathParts,
141
156
  qmdResultPathCandidates,
142
157
  selfDeps
143
- } from "./chunk-W2BAGGEW.js";
158
+ } from "./chunk-2ITZ74A6.js";
144
159
  import {
145
160
  namespaceCollectionName
146
- } from "./chunk-ODU2CNNX.js";
161
+ } from "./chunk-C5IUOBCN.js";
147
162
  import {
148
163
  DEFAULT_RECALL_DISCLOSURE,
149
164
  isRecallDisclosure
150
- } from "./chunk-MINHJ55X.js";
165
+ } from "./chunk-XXW32OL7.js";
151
166
  import {
152
167
  normalizeProjectionPreview,
153
168
  normalizeProjectionTags
154
169
  } from "./chunk-SCU65EZI.js";
155
- import {
156
- STRUCTURED_ATTRIBUTE_LIMITS,
157
- buildAccessWriteRequestFingerprint,
158
- buildObserveRequestFingerprint,
159
- composeMemoryEnvelope,
160
- isMemoryCategory
161
- } from "./chunk-H2YSH3DG.js";
162
- import {
163
- applyTagFilter,
164
- normalizeTags,
165
- parseTagMatch
166
- } from "./chunk-BT7NVCML.js";
167
170
  import {
168
171
  createVersion,
169
172
  getVersion,
170
173
  revertToVersion
171
- } from "./chunk-UFKPQBXH.js";
174
+ } from "./chunk-U62OK7BB.js";
172
175
  import {
173
176
  MEMORY_CORPUS_VERSION_SENTINEL,
174
177
  bumpMemoryCorpusVersionForDir
@@ -177,13 +180,25 @@ import {
177
180
  HistoricalEntityCanonicalIdCache,
178
181
  canonicalizeEntityRefFrontmatter,
179
182
  repairContentAfterJournalMoveSync
180
- } from "./chunk-ZVPVTPGI.js";
183
+ } from "./chunk-NNZFPYYX.js";
181
184
  import {
182
185
  supersessionKeysForFact
183
186
  } from "./chunk-5WITETWU.js";
187
+ import {
188
+ STRUCTURED_ATTRIBUTE_LIMITS,
189
+ buildAccessWriteRequestFingerprint,
190
+ buildObserveRequestFingerprint,
191
+ composeMemoryEnvelope,
192
+ isMemoryCategory
193
+ } from "./chunk-WKAXBXVA.js";
194
+ import {
195
+ applyTagFilter,
196
+ normalizeTags,
197
+ parseTagMatch
198
+ } from "./chunk-BT7NVCML.js";
184
199
  import {
185
200
  FallbackLlmClient
186
- } from "./chunk-UW5NPZJ2.js";
201
+ } from "./chunk-JALOAKSZ.js";
187
202
  import {
188
203
  extractJsonCandidates
189
204
  } from "./chunk-RGMVMVMF.js";
@@ -202,13 +217,16 @@ import {
202
217
  normalizeProcedureSteps,
203
218
  parseProcedureStepsFromBody
204
219
  } from "./chunk-QDW3E4RD.js";
220
+ import {
221
+ isValidActivityDate
222
+ } from "./chunk-M6L7HI7R.js";
205
223
  import {
206
224
  filterTrajectoriesByLookbackDays,
207
225
  readCausalTrajectoryRecords
208
226
  } from "./chunk-GPFZFCRN.js";
209
227
  import {
210
228
  computePromotionCandidates
211
- } from "./chunk-LDKPDODJ.js";
229
+ } from "./chunk-ME35HVDJ.js";
212
230
  import {
213
231
  exportCapsule
214
232
  } from "./chunk-KQAFEZQX.js";
@@ -240,22 +258,22 @@ import {
240
258
  } from "./chunk-LNEWDF2A.js";
241
259
  import {
242
260
  createOfflineSyncManifestStream
243
- } from "./chunk-7VZFRUQU.js";
261
+ } from "./chunk-O7ERGZDA.js";
244
262
  import {
245
263
  offlineSyncStorageForSnapshot
246
- } from "./chunk-F3NVYTTA.js";
264
+ } from "./chunk-TNXNECAN.js";
247
265
  import {
248
266
  resolveScopePlan,
249
267
  resolveScopedWritableNamespaceValue,
250
268
  resolveWritableNamespaceValue
251
- } from "./chunk-Q57GOHLF.js";
252
- import {
253
- writeFileAtomically
254
- } from "./chunk-AW4QUFQF.js";
269
+ } from "./chunk-EGALNSZ4.js";
255
270
  import {
256
271
  expandScopeProfileReadNamespaces,
257
272
  resolveScopeProfilePlan
258
- } from "./chunk-KCT36JAW.js";
273
+ } from "./chunk-ESNFSSO4.js";
274
+ import {
275
+ writeFileAtomically
276
+ } from "./chunk-AW4QUFQF.js";
259
277
  import {
260
278
  inferMemoryStatus,
261
279
  isActiveMemoryStatus,
@@ -263,7 +281,7 @@ import {
263
281
  } from "./chunk-7RJUVTVF.js";
264
282
  import {
265
283
  getMemoryProjectionPath
266
- } from "./chunk-2LWQSV6A.js";
284
+ } from "./chunk-AL3UYZ5N.js";
267
285
  import {
268
286
  displayErrorDetail
269
287
  } from "./chunk-RL6NEVXT.js";
@@ -289,7 +307,7 @@ import {
289
307
  encodeSupportPassportNamespaceAttributes,
290
308
  isSupportPassportPrivateMemory,
291
309
  projectSupportPassportCard
292
- } from "./chunk-XDL5CYZN.js";
310
+ } from "./chunk-EEOUMG3J.js";
293
311
  import {
294
312
  serializeMutations,
295
313
  withHeldFileLock
@@ -305,1546 +323,125 @@ import {
305
323
  } from "./chunk-5GKPFL3S.js";
306
324
  import {
307
325
  buildHandleIndexForResults,
308
- isHandleToken
309
- } from "./chunk-JAKIDQB2.js";
310
- import {
311
- OFFLINE_SYNC_SNAPSHOT_FORMAT,
312
- applyOfflineSyncChangeset,
313
- applyOfflineSyncFileContentChunk,
314
- buildOfflineSyncSnapshot,
315
- buildOfflineSyncSnapshotForPaths,
316
- buildOfflineSyncSnapshotFromBase,
317
- compileOfflineSyncExcludeGlobs,
318
- filterOfflineSyncDeletionRevisions,
319
- iterateOfflineSyncSnapshotFileRecords,
320
- normalizeOfflineSyncChangeset,
321
- readOfflineSyncFileContentChunk
322
- } from "./chunk-FZEEWOI2.js";
323
- import {
324
- validateArchiveRelativePath
325
- } from "./chunk-GCGJW34D.js";
326
- import {
327
- parseIsoOffsetTimestamp
328
- } from "./chunk-P7FMDTKL.js";
329
- import {
330
- assertOperationAuthorizationAllowed,
331
- capabilityAllowsOp,
332
- enforceNamespaceAllowList,
333
- isNamespaceAllowed,
334
- tokenCapabilityStore
335
- } from "./chunk-MZWSOLMT.js";
336
- import {
337
- canReadNamespace,
338
- canWriteNamespace,
339
- citationAuthorizedNamespaces,
340
- defaultNamespaceForPrincipal,
341
- recallNamespacesForPrincipal,
342
- resolvePrincipal
343
- } from "./chunk-MRV7VSQK.js";
344
- import {
345
- namespaceIdentityFromToken
346
- } from "./chunk-VUFL7X3H.js";
347
- import {
348
- resolveAccessSetupCapabilities,
349
- resolveCompressionCapabilities,
350
- resolveConsolidationCapabilities,
351
- resolveGraphConstructionCapabilities,
352
- resolveIdentityContinuityCapabilities,
353
- resolveIndexingCapabilities,
354
- resolveLocalLlmCapabilities,
355
- resolveMemoryLifecycleCapabilities,
356
- resolveNamespaceCapabilities,
357
- resolveObjectiveStateCapabilities,
358
- resolveQmdCapabilities,
359
- resolveRecallAuxiliaryCapabilities,
360
- resolveRecallEnhancementCapabilities,
361
- resolveSecurityCapabilities
362
- } from "./chunk-JUOZ62Y7.js";
363
- import {
364
- AccessIdempotencyStore,
365
- hashAccessIdempotencyPayload
366
- } from "./chunk-VFUEZZBS.js";
367
- import {
368
- resolveCodingContextFromOptions
369
- } from "./chunk-773TRRGT.js";
370
- import {
371
- combineNamespaces,
372
- defaultGitInvokerSync,
373
- lcmSessionKeyForNamespace,
374
- projectTagProjectId,
375
- resolveCodingNamespaceOverlay,
376
- resolveGitContext,
377
- sanitizeFragment
378
- } from "./chunk-J2WC5LF4.js";
379
- import {
380
- expandTildePath
381
- } from "./chunk-EYIEWJNI.js";
382
- import {
383
- EngramAccessForbiddenError,
384
- EngramAccessInputError,
385
- NamespaceNotWritableError
386
- } from "./chunk-2Z24E5W2.js";
387
- import {
388
- abortError,
389
- isAbortError,
390
- raceAbort,
391
- throwIfAborted
392
- } from "./chunk-BTTPKDIL.js";
393
- import {
394
- readJsonFile,
395
- writeJsonFileAtomic
396
- } from "./chunk-P77QX3ID.js";
397
- import {
398
- AccessAuditAdapter
399
- } from "./chunk-TVVEYCNW.js";
400
- import {
401
- decodeCitationNamespace
402
- } from "./chunk-JIYDRBVZ.js";
403
- import {
404
- isPathInsideStorageRoot
405
- } from "./chunk-FF4KLI5W.js";
406
- import {
407
- SecureStoreLockedError
408
- } from "./chunk-XQ3HXAQH.js";
409
- import {
410
- ALL_CATEGORY_DIRS,
411
- getCategoryDir
412
- } from "./chunk-VS2IYZRU.js";
413
- import {
414
- recordCitationUsage
415
- } from "./chunk-NINSR6LX.js";
416
- import {
417
- log
418
- } from "./chunk-3WCASNQZ.js";
419
-
420
- // src/access-service.ts
421
- import { createHash as createHash13 } from "crypto";
422
- import { constants as fsConstants2 } from "fs";
423
- import { readdirSync, unlinkSync } from "fs";
424
- import { stat as stat3 } from "fs/promises";
425
- import * as nodeFs2 from "fs/promises";
426
- import { ZodError } from "zod";
427
-
428
- // src/coding/architecture-card.ts
429
- import { readFile, readdir, lstat } from "fs/promises";
430
- import path from "path";
431
- var ARCHITECTURE_CARD_MAX_BYTES = 4096;
432
- var ARCHITECTURE_CARD_TRUNCATION_MARKER = "\u2026 card truncated to fit size cap \u2026";
433
- var ARCHITECTURE_CARD_MAX_SUMMARY_BYTES = 1024;
434
- var KNOWN_MANIFEST_FILES = [
435
- "package.json",
436
- "Cargo.toml",
437
- "go.mod",
438
- "pyproject.toml",
439
- "setup.py",
440
- "pom.xml",
441
- "build.gradle",
442
- "build.gradle.kts",
443
- "Gemfile",
444
- "composer.json",
445
- "mix.exs",
446
- "deno.json"
447
- ];
448
- var SCAN_IGNORE_DIRS = /* @__PURE__ */ new Set([
449
- "node_modules",
450
- ".git",
451
- ".svn",
452
- ".hg",
453
- "vendor",
454
- "__pycache__",
455
- ".venv",
456
- "venv",
457
- "env",
458
- "dist",
459
- "build",
460
- "target",
461
- "out",
462
- ".next",
463
- ".nuxt",
464
- "coverage",
465
- ".cache",
466
- ".turbo",
467
- ".idea",
468
- ".vscode"
469
- ]);
470
- var ARCHITECTURE_CARD_SUMMARY_SYSTEM_PROMPT = `You write a concise overview for a repository architecture card.
471
- Given the deterministic card (languages, manifests, entry points), produce a 3-5 sentence plain-text overview naming the dominant language, the primary entry point, and the project's shape.
472
- Rules:
473
- - Never invent facts absent from the input.
474
- - No headings, no markdown \u2014 just sentences.
475
- - Keep it under 600 characters.`;
476
- function createArchitectureCardSummariser(client) {
477
- if (!client) return void 0;
478
- return async (deterministicCard, repoRoot) => {
479
- const response = await client.chatCompletion(
480
- [
481
- { role: "system", content: ARCHITECTURE_CARD_SUMMARY_SYSTEM_PROMPT },
482
- { role: "user", content: `Repository: ${path.basename(repoRoot) || repoRoot}
483
-
484
- ${deterministicCard}` }
485
- ],
486
- {
487
- temperature: 0.2,
488
- maxTokens: 512,
489
- operation: "architecture-card-summary",
490
- priority: "background"
491
- }
492
- );
493
- return response?.content ?? null;
494
- };
495
- }
496
- async function buildArchitectureCard(repoRoot, options = {}) {
497
- if (typeof repoRoot !== "string" || repoRoot.length === 0) {
498
- return { ok: false, code: "invalid_root", detail: "repoRoot must be a non-empty string" };
499
- }
500
- const absoluteRoot = path.resolve(expandTildePath(repoRoot));
501
- try {
502
- const rootStat = await lstat(absoluteRoot);
503
- if (!rootStat.isDirectory()) {
504
- return { ok: false, code: "invalid_root", detail: `not a directory: ${absoluteRoot}` };
505
- }
506
- } catch (err) {
507
- return {
508
- ok: false,
509
- code: "invalid_root",
510
- detail: `repoRoot not accessible: ${err instanceof Error ? err.message : String(err)}`
511
- };
512
- }
513
- try {
514
- await readdir(absoluteRoot);
515
- } catch (err) {
516
- return {
517
- ok: false,
518
- code: "scan_failed",
519
- detail: `repoRoot not readable: ${err instanceof Error ? err.message : String(err)}`
520
- };
521
- }
522
- try {
523
- const scan = await scanRepository(absoluteRoot);
524
- const deterministic = renderCard(scan, options.now ?? /* @__PURE__ */ new Date());
525
- const maxBytes = options.maxBytes ?? ARCHITECTURE_CARD_MAX_BYTES;
526
- let content = deterministic;
527
- if (options.llmSummary === true && options.summariser) {
528
- try {
529
- const summary = await options.summariser(deterministic, absoluteRoot);
530
- if (typeof summary === "string" && summary.trim().length > 0) {
531
- const separator = "\n\n---\n\n";
532
- const detBytes = Buffer.byteLength(deterministic, "utf-8");
533
- const sepBytes = Buffer.byteLength(separator, "utf-8");
534
- const summaryBudget = Math.min(
535
- ARCHITECTURE_CARD_MAX_SUMMARY_BYTES,
536
- maxBytes - detBytes - sepBytes
537
- );
538
- if (summaryBudget > 0) {
539
- const clampedSummary = clampSummaryToBytes(summary.trim(), summaryBudget);
540
- if (clampedSummary.length > 0) {
541
- content = `${clampedSummary}${separator}${deterministic}`;
542
- }
543
- }
544
- }
545
- } catch (err) {
546
- void err;
547
- }
548
- }
549
- const { text: truncatedContent, truncated } = capToBytes(content, maxBytes);
550
- return {
551
- ok: true,
552
- card: {
553
- content: truncatedContent,
554
- generatedAt: (options.now ?? /* @__PURE__ */ new Date()).toISOString(),
555
- byteSize: Buffer.byteLength(truncatedContent, "utf-8"),
556
- truncated
557
- }
558
- };
559
- } catch (err) {
560
- return {
561
- ok: false,
562
- code: "scan_failed",
563
- detail: err instanceof Error ? err.message : String(err)
564
- };
565
- }
566
- }
567
- async function scanRepository(root) {
568
- const topEntries = await readSortedDirEntries(root);
569
- const topDirs = topEntries.filter((e) => e.isDirectory && !SCAN_IGNORE_DIRS.has(e.name)).map((e) => e.name);
570
- const manifestFiles = topEntries.filter((e) => e.isFile && KNOWN_MANIFEST_FILES.includes(e.name)).map((e) => e.name);
571
- const manifests = [];
572
- for (const mf of sortStrings(manifestFiles)) {
573
- const parsed = await parseManifest(path.join(root, mf));
574
- manifests.push({ filename: mf, name: parsed.name, entryPoints: sortStrings(parsed.entryPoints) });
575
- }
576
- const languageHistogram = await computeLanguageHistogram(root, topEntries);
577
- return {
578
- root: path.basename(root) || root,
579
- topDirs: sortStrings(topDirs),
580
- manifests,
581
- languageHistogram: sortLanguageHistogram(languageHistogram)
582
- };
583
- }
584
- async function readSortedDirEntries(dir) {
585
- let names;
586
- try {
587
- names = await readdir(dir);
588
- } catch {
589
- return [];
590
- }
591
- const entries = [];
592
- for (const name of sortStrings(names)) {
593
- try {
594
- const s = await lstat(path.join(dir, name));
595
- if (s.isSymbolicLink()) continue;
596
- entries.push({ name, isDirectory: s.isDirectory(), isFile: s.isFile() });
597
- } catch {
598
- }
599
- }
600
- return entries;
601
- }
602
- async function computeLanguageHistogram(root, topEntries) {
603
- const counts = /* @__PURE__ */ new Map();
604
- const dirsToScan = topEntries.filter((e) => e.isDirectory && !SCAN_IGNORE_DIRS.has(e.name)).map((e) => path.join(root, e.name));
605
- const rootFiles = topEntries.filter((e) => e.isFile);
606
- const visitDir = async (dir, depth) => {
607
- if (depth > 2) return;
608
- let entries;
609
- try {
610
- entries = await readSortedDirEntries(dir);
611
- } catch {
612
- return;
613
- }
614
- for (const entry of entries) {
615
- if (entry.isDirectory) {
616
- if (!SCAN_IGNORE_DIRS.has(entry.name)) {
617
- await visitDir(path.join(dir, entry.name), depth + 1);
618
- }
619
- } else if (entry.isFile) {
620
- const ext = path.extname(entry.name).toLowerCase();
621
- if (ext.length > 0) {
622
- counts.set(ext, (counts.get(ext) ?? 0) + 1);
623
- }
624
- }
625
- }
626
- };
627
- for (const f of rootFiles) {
628
- const ext = path.extname(f.name).toLowerCase();
629
- if (ext.length > 0) counts.set(ext, (counts.get(ext) ?? 0) + 1);
630
- }
631
- for (const dir of dirsToScan) {
632
- await visitDir(dir, 0);
633
- }
634
- return Array.from(counts.entries()).map(([ext, count]) => ({ ext, count }));
635
- }
636
- async function parseManifest(filePath) {
637
- const filename = path.basename(filePath);
638
- try {
639
- const raw = await readFile(filePath, "utf-8");
640
- switch (filename) {
641
- case "package.json":
642
- return parsePackageJson(raw);
643
- case "pyproject.toml":
644
- case "setup.py":
645
- return parsePythonProject(raw, filename);
646
- case "go.mod":
647
- return parseGoMod(raw);
648
- case "Cargo.toml":
649
- return parseCargoToml(raw);
650
- default:
651
- return { name: null, entryPoints: [] };
652
- }
653
- } catch {
654
- return { name: null, entryPoints: [] };
655
- }
656
- }
657
- function parsePackageJson(raw) {
658
- let parsed;
659
- try {
660
- parsed = JSON.parse(raw);
661
- } catch {
662
- return { name: null, entryPoints: [] };
663
- }
664
- if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
665
- return { name: null, entryPoints: [] };
666
- }
667
- const obj = parsed;
668
- const name = typeof obj["name"] === "string" ? obj["name"] : null;
669
- const entryPoints = [];
670
- const bin = obj["bin"];
671
- if (typeof bin === "string") {
672
- entryPoints.push(bin);
673
- } else if (typeof bin === "object" && bin !== null && !Array.isArray(bin)) {
674
- for (const [key, value] of Object.entries(bin)) {
675
- entryPoints.push(typeof value === "string" ? value : `bin/${key}`);
676
- }
677
- }
678
- const main = typeof obj["main"] === "string" ? obj["main"] : null;
679
- if (main) entryPoints.push(main);
680
- const module = typeof obj["module"] === "string" ? obj["module"] : null;
681
- if (module) entryPoints.push(module);
682
- const scripts = obj["scripts"];
683
- if (typeof scripts === "object" && scripts !== null && !Array.isArray(scripts)) {
684
- const scriptKeys = Object.keys(scripts);
685
- for (const key of ["start", "dev", "serve"]) {
686
- if (scriptKeys.includes(key)) entryPoints.push(`scripts.${key}`);
687
- }
688
- }
689
- return { name, entryPoints };
690
- }
691
- function parsePythonProject(raw, _filename) {
692
- const entryPoints = [];
693
- let name = null;
694
- const nameMatch = raw.match(/^name\s*=\s*["']([^"']+)["']/m);
695
- if (nameMatch) name = nameMatch[1] ?? null;
696
- const scriptsMatch = raw.match(/\[project\.scripts\]([\s\S]*?)(?:\n\[|$)/);
697
- if (scriptsMatch && scriptsMatch[1]) {
698
- for (const line of scriptsMatch[1].split("\n")) {
699
- const m = line.match(/^([a-zA-Z0-9_-]+)\s*=/);
700
- if (m && m[1]) entryPoints.push(`scripts.${m[1]}`);
701
- }
702
- }
703
- return { name, entryPoints };
704
- }
705
- function parseGoMod(raw) {
706
- const moduleMatch = raw.match(/^module\s+(\S+)/m);
707
- const name = moduleMatch && moduleMatch[1] ? moduleMatch[1] : null;
708
- return { name, entryPoints: name ? ["main.go"] : [] };
709
- }
710
- function parseCargoToml(raw) {
711
- const nameMatch = raw.match(/^name\s*=\s*"([^"]+)"/m);
712
- const name = nameMatch && nameMatch[1] ? nameMatch[1] : null;
713
- const entryPoints = [];
714
- if (/\[\[bin\]\]/.test(raw)) entryPoints.push("src/bin/");
715
- if (name) entryPoints.push("src/main.rs");
716
- return { name, entryPoints };
717
- }
718
- function renderCard(scan, now) {
719
- const lines = [];
720
- lines.push(`# Architecture Card \u2014 ${scan.root}`);
721
- lines.push("");
722
- lines.push(`_Generated ${now.toISOString()}_`);
723
- lines.push("");
724
- const namedManifest = scan.manifests.find((m) => m.name !== null);
725
- if (namedManifest && namedManifest.name) {
726
- lines.push(`**Project:** ${namedManifest.name}`);
727
- lines.push("");
728
- }
729
- if (scan.manifests.length > 0) {
730
- lines.push("## Manifests");
731
- for (const m of scan.manifests) {
732
- const label = m.name ? `${m.filename} (${m.name})` : m.filename;
733
- lines.push(`- ${label}`);
734
- }
735
- lines.push("");
736
- }
737
- if (scan.topDirs.length > 0) {
738
- lines.push("## Top-level directories");
739
- const cols = 4;
740
- for (let i = 0; i < scan.topDirs.length; i += cols) {
741
- const row = scan.topDirs.slice(i, i + cols).join(" \xB7 ");
742
- lines.push(`- ${row}`);
743
- }
744
- lines.push("");
745
- }
746
- if (scan.languageHistogram.length > 0) {
747
- lines.push("## Languages (by file count)");
748
- const top = scan.languageHistogram.slice(0, 10);
749
- for (const entry of top) {
750
- lines.push(`- ${entry.ext}: ${entry.count}`);
751
- }
752
- lines.push("");
753
- }
754
- const allEntryPoints = sortStrings(scan.manifests.flatMap((m) => m.entryPoints));
755
- if (allEntryPoints.length > 0) {
756
- lines.push("## Entry points");
757
- for (const ep of allEntryPoints) {
758
- lines.push(`- ${ep}`);
759
- }
760
- lines.push("");
761
- }
762
- return lines.join("\n").trimEnd() + "\n";
763
- }
764
- function sortStrings(values) {
765
- return [...values].sort((a, b) => a.localeCompare(b));
766
- }
767
- function sortLanguageHistogram(entries) {
768
- return [...entries].sort((a, b) => {
769
- if (b.count !== a.count) return b.count - a.count;
770
- return a.ext.localeCompare(b.ext);
771
- });
772
- }
773
- function capToBytes(text, maxBytes) {
774
- const byteLen = Buffer.byteLength(text, "utf-8");
775
- if (byteLen <= maxBytes) {
776
- return { text, truncated: false };
777
- }
778
- const marker = `
779
-
780
- _${ARCHITECTURE_CARD_TRUNCATION_MARKER}_`;
781
- const markerBytes = Buffer.byteLength(marker, "utf-8");
782
- const budget = maxBytes - markerBytes;
783
- if (budget <= 0) {
784
- return { text: marker.trimStart(), truncated: true };
785
- }
786
- let cut = 0;
787
- let running = 0;
788
- const chars = [...text];
789
- for (let i = 0; i < chars.length; i++) {
790
- const charBytes = Buffer.byteLength(chars[i], "utf-8");
791
- if (running + charBytes > budget) break;
792
- running += charBytes;
793
- cut = i + 1;
794
- }
795
- return { text: chars.slice(0, cut).join("") + marker, truncated: true };
796
- }
797
- function clampSummaryToBytes(text, maxBytes) {
798
- if (maxBytes <= 0) return "";
799
- if (Buffer.byteLength(text, "utf-8") <= maxBytes) return text;
800
- const ellipsis = " \u2026";
801
- const budget = maxBytes - Buffer.byteLength(ellipsis, "utf-8");
802
- if (budget <= 0) return "";
803
- let cut = 0;
804
- let running = 0;
805
- const chars = [...text];
806
- for (let i = 0; i < chars.length; i++) {
807
- const charBytes = Buffer.byteLength(chars[i], "utf-8");
808
- if (running + charBytes > budget) break;
809
- running += charBytes;
810
- cut = i + 1;
811
- }
812
- return chars.slice(0, cut).join("") + ellipsis;
813
- }
814
-
815
- // src/coding/architecture-surfaces.ts
816
- var ARCHITECTURE_CARD_TAG = "architecture-card";
817
- var ARCHITECTURE_CARD_KIND = "architecture";
818
- async function handleCodingArchitecture(request, ctx) {
819
- const codingContext = request.sessionKey ? ctx.getCodingContext(request.sessionKey) : null;
820
- if (codingContext === null || !isCodingKnowledgeFeatureEnabled(ctx.codingKnowledge, "architectureCard", codingContext)) {
821
- ctx.throwInputError(
822
- "coding_architecture requires codingKnowledge.enabled, codingKnowledge.architectureCard, and an attached coding context"
823
- );
824
- }
825
- switch (request.subcommand) {
826
- case "get":
827
- return architectureGet(request, ctx);
828
- case "refresh":
829
- return architectureRefresh(request, ctx, codingContext);
830
- }
831
- }
832
- async function architectureGet(request, ctx) {
833
- const storage = await ctx.resolveStorage(request);
834
- const existing = await findArchitectureCardMemory(storage);
835
- if (!existing) {
836
- return { subcommand: "get", found: false };
837
- }
838
- const content = stripAttributesSuffix(existing.content);
839
- return {
840
- subcommand: "get",
841
- found: true,
842
- card: {
843
- content,
844
- generatedAt: existing.frontmatter.updated ?? existing.frontmatter.created,
845
- byteSize: Buffer.byteLength(content, "utf-8"),
846
- // Derive truncation from the CONTENT marker, not a frontmatter tag —
847
- // the refresh update path changes content without rewriting tags, so
848
- // a tag-based check goes stale (cursor review: stale truncated tag).
849
- truncated: content.includes(ARCHITECTURE_CARD_TRUNCATION_MARKER)
850
- }
851
- };
852
- }
853
- async function architectureRefresh(request, ctx, codingContext) {
854
- const repoRoot = codingContext.rootPath ?? codingContext.projectId;
855
- const storage = await ctx.resolveStorage(request);
856
- const buildResult = await ctx.buildCard(repoRoot);
857
- if (!buildResult.ok) {
858
- log.warn(
859
- `coding_architecture/refresh: card build failed (code=${buildResult.code}): ${buildResult.detail}`
860
- );
861
- ctx.throwInputError(
862
- `coding_architecture refresh failed: card build returned ${buildResult.code}`
863
- );
864
- }
865
- const cardContent = buildResult.card.content;
866
- const tags = [ARCHITECTURE_CARD_TAG];
867
- if (buildResult.card.truncated) tags.push("truncated");
868
- const existing = await findArchitectureCardMemory(storage);
869
- if (existing) {
870
- await ctx.versioning.snapshotIfExists(existing);
871
- const updated = await storage.updateMemory(existing.frontmatter.id, cardContent, {
872
- actor: "coding-architecture-refresh",
873
- ...ctx.sourceConnector ? { sourceConnector: ctx.sourceConnector } : {}
874
- });
875
- if (!updated) {
876
- log.warn(
877
- `coding_architecture/refresh: updateMemory returned false for id=${existing.frontmatter.id} \u2014 falling back to writeMemory`
878
- );
879
- const fallbackWrite = await storage.writeSealedMemory(
880
- composeMemoryEnvelope(
881
- {
882
- content: cardContent,
883
- category: "fact",
884
- confidence: 1,
885
- tags,
886
- structuredAttributes: { cardKind: ARCHITECTURE_CARD_KIND },
887
- ...ctx.sourceConnector ? { sourceConnector: ctx.sourceConnector } : {}
888
- },
889
- { source: "coding-architecture" }
890
- ),
891
- {}
892
- );
893
- log.info(
894
- `access-write op=coding_architecture/refresh memoryId=${fallbackWrite.id} (fallback write) byteSize=${buildResult.card.byteSize}`
895
- );
896
- return refreshResponse(fallbackWrite, buildResult.card);
897
- }
898
- log.info(
899
- `access-write op=coding_architecture/refresh memoryId=${existing.frontmatter.id} (updated) byteSize=${buildResult.card.byteSize}`
900
- );
901
- return {
902
- subcommand: "refresh",
903
- refreshed: true,
904
- memoryId: existing.frontmatter.id,
905
- byteSize: buildResult.card.byteSize,
906
- truncated: buildResult.card.truncated
907
- };
908
- }
909
- const newWrite = await storage.writeSealedMemory(
910
- composeMemoryEnvelope(
911
- {
912
- content: cardContent,
913
- category: "fact",
914
- confidence: 1,
915
- tags,
916
- structuredAttributes: { cardKind: ARCHITECTURE_CARD_KIND },
917
- ...ctx.sourceConnector ? { sourceConnector: ctx.sourceConnector } : {}
918
- },
919
- { source: "coding-architecture" }
920
- ),
921
- {}
922
- );
923
- log.info(
924
- `access-write op=coding_architecture/refresh memoryId=${newWrite.id} (new) byteSize=${buildResult.card.byteSize}`
925
- );
926
- return refreshResponse(newWrite, buildResult.card);
927
- }
928
- function refreshResponse(writeResult, card) {
929
- if (writeResult.tombstoneBlocked) {
930
- return {
931
- subcommand: "refresh",
932
- refreshed: false,
933
- memoryId: writeResult.id,
934
- byteSize: card.byteSize,
935
- truncated: card.truncated,
936
- blockedReason: "tombstone-blocked",
937
- ...writeResult.blockedBy !== void 0 ? { blockedBy: writeResult.blockedBy } : {}
938
- };
939
- }
940
- return {
941
- subcommand: "refresh",
942
- refreshed: true,
943
- memoryId: writeResult.id,
944
- byteSize: card.byteSize,
945
- truncated: card.truncated
946
- };
947
- }
948
- async function findArchitectureCardMemory(storage) {
949
- const memories = await storage.readAllMemories();
950
- const cards = memories.filter((m) => {
951
- if (m.frontmatter.category !== "fact") return false;
952
- const tags = m.frontmatter.tags ?? [];
953
- if (!tags.includes(ARCHITECTURE_CARD_TAG)) return false;
954
- if (m.frontmatter.structuredAttributes?.cardKind !== ARCHITECTURE_CARD_KIND) return false;
955
- const outer = m.frontmatter.status;
956
- if (outer !== void 0 && outer !== "active") return false;
957
- if (m.frontmatter.archivedAt !== void 0 && m.frontmatter.archivedAt !== null) return false;
958
- return true;
959
- });
960
- if (cards.length === 0) return null;
961
- cards.sort((a, b) => {
962
- const aUpdated = a.frontmatter.updated ?? a.frontmatter.created;
963
- const bUpdated = b.frontmatter.updated ?? b.frontmatter.created;
964
- if (aUpdated !== bUpdated) return bUpdated.localeCompare(aUpdated);
965
- return b.frontmatter.id.localeCompare(a.frontmatter.id);
966
- });
967
- return cards[0] ?? null;
968
- }
969
- function createArchitectureVersioningHook(enabled, maxVersionsPerPage, sidecarDir, memoryDir, readFile7, writeVersion) {
970
- return {
971
- async snapshotIfExists(memory) {
972
- if (!enabled) return;
973
- try {
974
- const fullContent = await readFile7(memory.path);
975
- await writeVersion(
976
- memory.path,
977
- fullContent,
978
- "manual",
979
- { enabled: true, maxVersionsPerPage, sidecarDir },
980
- void 0,
981
- "architecture-card-refresh",
982
- memoryDir
983
- );
984
- } catch {
985
- }
986
- }
987
- };
988
- }
989
-
990
- // src/coding/codegraph-runtime.ts
991
- import path2 from "path";
992
- import { readFile as readFile2, realpath } from "fs/promises";
993
- import { readFileSync, realpathSync } from "fs";
994
- import { pathToFileURL } from "url";
995
- import { createHash } from "crypto";
996
- function codegraphSurfaceVisible(config) {
997
- const ck = config.codingKnowledge;
998
- if (ck === void 0 || ck === null) return false;
999
- return ck.enabled === true && ck.codegraphTools === true;
1000
- }
1001
- function resolveCodegraphRoot(config, memoryDir) {
1002
- const rawDir = config.codingKnowledge.codegraphDbDir.trim();
1003
- const root = rawDir.length > 0 ? expandTildePath(rawDir) : path2.join(memoryDir, "codegraph");
1004
- if (!path2.isAbsolute(root)) {
1005
- throw new CodegraphRuntimeError(
1006
- "store_error",
1007
- "codegraph DB root must be an absolute path; set codingKnowledge.codegraphDbDir (or memoryDir) to an absolute path"
1008
- );
1009
- }
1010
- return root;
1011
- }
1012
- function resolveCodegraphDbPath(params) {
1013
- const { config, memoryDir, principal, projectId } = params;
1014
- const root = resolveCodegraphRoot(config, memoryDir);
1015
- const principalSafe = sanitizePathSegment(principal);
1016
- const projectSafe = sanitizePathSegment(projectId);
1017
- return path2.join(root, principalSafe, `${projectSafe}.sqlite`);
1018
- }
1019
- function sanitizePathSegment(input) {
1020
- const trimmed = (input ?? "").trim();
1021
- if (trimmed.length === 0) return "_";
1022
- const sanitized = trimmed.replace(/[^A-Za-z0-9._:-]+/g, "_");
1023
- return sanitized.replace(/^\.+/, "").replace(/[/\\]+/g, "_") || "_";
1024
- }
1025
- var storeCache = /* @__PURE__ */ new Map();
1026
- function storeCacheKey(principalSafe, projectSafe, dbPath) {
1027
- return `${principalSafe}::${projectSafe}::${dbPath}`;
1028
- }
1029
- function isCodegraphModule(value) {
1030
- if (!value || typeof value !== "object") return false;
1031
- const candidate = value;
1032
- const graphStore = candidate.GraphStore;
1033
- return graphStore !== void 0 && typeof graphStore.open === "function";
1034
- }
1035
- async function resolveCodegraphModule() {
1036
- const mod = await tryLoadCodingGraphModule();
1037
- if (mod === null || !isCodegraphModule(mod)) return null;
1038
- return mod;
1039
- }
1040
- async function getCodegraphStore(params) {
1041
- const { config, memoryDir, principal, projectId, repoRoot } = params;
1042
- if (!codegraphSurfaceVisible(config)) {
1043
- throw new CodegraphRuntimeError(
1044
- "disabled",
1045
- "codegraph tools are disabled (codingKnowledge.enabled or codingKnowledge.codegraphTools is false)"
1046
- );
1047
- }
1048
- const mod = await resolveCodegraphModule();
1049
- if (mod === null) {
1050
- throw new CodegraphRuntimeError("package_missing", buildCodingGraphInstallHint());
1051
- }
1052
- const principalSafe = sanitizePathSegment(principal);
1053
- const projectSafe = sanitizePathSegment(projectId);
1054
- const dbPath = resolveCodegraphDbPath({ config, memoryDir, principal, projectId });
1055
- const key = storeCacheKey(principalSafe, projectSafe, dbPath);
1056
- const cached = storeCache.get(key);
1057
- if (cached !== void 0) {
1058
- if (repoRoot !== void 0 && cached.repoRoot === void 0) {
1059
- storeCache.delete(key);
1060
- try {
1061
- await cached.store.close();
1062
- } catch {
1063
- }
1064
- const store2 = await mod.GraphStore.open({ dbPath, repoRoot });
1065
- storeCache.set(key, { store: store2, repoRoot, openedAt: Date.now() });
1066
- return store2;
1067
- }
1068
- if (repoRoot !== void 0 && cached.repoRoot !== void 0 && cached.repoRoot !== repoRoot) {
1069
- throw new CodegraphRuntimeError(
1070
- "repo_root_conflict",
1071
- `codegraph store for project ${projectId} is already bound to repo root ${cached.repoRoot}; refusing to rebind to ${repoRoot}`
1072
- );
1073
- }
1074
- return cached.store;
1075
- }
1076
- const store = await mod.GraphStore.open({ dbPath, repoRoot });
1077
- storeCache.set(key, { store, repoRoot, openedAt: Date.now() });
1078
- return store;
1079
- }
1080
- function listCodegraphProjects(params) {
1081
- const { config, memoryDir, principal, listDir } = params;
1082
- if (!codegraphSurfaceVisible(config)) return [];
1083
- let root;
1084
- try {
1085
- root = resolveCodegraphRoot(config, memoryDir);
1086
- } catch {
1087
- return [];
1088
- }
1089
- const principalSafe = sanitizePathSegment(principal);
1090
- const principalDir = path2.join(root, principalSafe);
1091
- let entries;
1092
- try {
1093
- entries = listDir(principalDir);
1094
- } catch {
1095
- return [];
1096
- }
1097
- const projects = [];
1098
- for (const entry of entries) {
1099
- if (entry.endsWith(".sqlite")) {
1100
- projects.push(entry.slice(0, -".sqlite".length));
1101
- }
1102
- }
1103
- return projects;
1104
- }
1105
- async function deleteCodegraphProject(params) {
1106
- const { config, memoryDir, principal, projectId, confirm, removeFile } = params;
1107
- if (!confirm) {
1108
- throw new CodegraphRuntimeError(
1109
- "confirm_required",
1110
- "codegraph_delete_project requires confirm: true; destructive operations are never defaulted to proceed (rule 48)"
1111
- );
1112
- }
1113
- if (!codegraphSurfaceVisible(config)) {
1114
- throw new CodegraphRuntimeError("disabled", "codegraph tools are disabled");
1115
- }
1116
- const principalSafe = sanitizePathSegment(principal);
1117
- const projectSafe = sanitizePathSegment(projectId);
1118
- const dbPath = resolveCodegraphDbPath({ config, memoryDir, principal, projectId });
1119
- const key = storeCacheKey(principalSafe, projectSafe, dbPath);
1120
- const cached = storeCache.get(key);
1121
- if (cached !== void 0) {
1122
- storeCache.delete(key);
1123
- try {
1124
- await cached.store.close();
1125
- } catch {
1126
- }
1127
- }
1128
- let deleted = false;
1129
- try {
1130
- removeFile(dbPath);
1131
- deleted = true;
1132
- } catch (err) {
1133
- const code = err?.code;
1134
- if (code === "ENOENT") {
1135
- deleted = true;
1136
- } else {
1137
- deleted = false;
1138
- }
1139
- }
1140
- return { deleted, projectId };
1141
- }
1142
- function makeCodegraphRuntimeDelegates() {
1143
- return {
1144
- runReindex: (store, repoRoot, mode) => runCodegraphReindex({ store, repoRoot, mode }),
1145
- reportIndexStatus: (store, repoRoot) => reportCodegraphIndexStatus({ store, repoRoot }),
1146
- detectChanges: (store, repoRoot, head) => detectCodegraphChanges({ store, repoRoot, head }),
1147
- ingestTraces: (store, traces) => ingestCodegraphTraces({ store, traces }),
1148
- runLspResolution: (store, repoRoot, lspConfig) => runCodegraphLspResolution({ store, repoRoot, lspConfig })
1149
- };
1150
- }
1151
- async function runCodegraphReindex(params) {
1152
- const mod = await resolveCodegraphModule();
1153
- if (mod === null) {
1154
- return { ok: false, code: "package_missing", message: "The @remnic/coding-graph package is not installed." };
1155
- }
1156
- if (typeof mod.executeReindex !== "function" || typeof mod.defaultCodingGitInvoker !== "function") {
1157
- return { ok: false, code: "runtime_unavailable", message: "executeReindex is not available in the installed @remnic/coding-graph." };
1158
- }
1159
- const git = mod.defaultCodingGitInvoker();
1160
- let engine;
1161
- try {
1162
- if (typeof mod.createCodingGraphEngine !== "function") {
1163
- return { ok: false, code: "engine_unavailable", message: "createCodingGraphEngine is not exported by @remnic/coding-graph." };
1164
- }
1165
- engine = mod.createCodingGraphEngine();
1166
- } catch (err) {
1167
- const msg = err instanceof Error ? err.message : String(err);
1168
- return { ok: false, code: "engine_unavailable", message: `The coding-graph engine is not ready: ${msg}` };
1169
- }
1170
- let candidatePaths = [];
1171
- try {
1172
- const tracked = git.listTrackedFiles(params.repoRoot);
1173
- if (tracked.ok) {
1174
- candidatePaths = tracked.paths;
1175
- }
1176
- } catch {
1177
- }
1178
- try {
1179
- const result = await mod.executeReindex({
1180
- store: params.store,
1181
- git,
1182
- repoRoot: params.repoRoot,
1183
- parseFile: (input) => engine.parseFile(input),
1184
- candidatePaths
1185
- });
1186
- if (result && result.ok === true) {
1187
- return { ok: true, mode: result.mode ?? "auto", filesIngested: result.filesIngested ?? 0, head: result.head ?? null };
1188
- }
1189
- return {
1190
- ok: false,
1191
- code: result?.code ?? "store_error",
1192
- message: result?.message ?? "executeReindex reported a failure."
1193
- };
1194
- } catch (err) {
1195
- const msg = err instanceof Error ? err.message : String(err);
1196
- return { ok: false, code: "store_error", message: msg };
1197
- }
1198
- }
1199
- async function lspPathEscapesRoot(repoRoot, absPath) {
1200
- try {
1201
- const [realRoot, realAbs] = await Promise.all([realpath(repoRoot), realpath(absPath)]);
1202
- const rel = path2.relative(realRoot, realAbs);
1203
- return rel === ".." || rel.startsWith(".." + path2.sep) || path2.isAbsolute(rel);
1204
- } catch {
1205
- return false;
1206
- }
1207
- }
1208
- function lspPathEscapesRootSync(repoRoot, absPath) {
1209
- try {
1210
- const realRoot = realpathSync(repoRoot);
1211
- const realAbs = realpathSync(absPath);
1212
- const rel = path2.relative(realRoot, realAbs);
1213
- return rel === ".." || rel.startsWith(".." + path2.sep) || path2.isAbsolute(rel);
1214
- } catch {
1215
- return false;
1216
- }
1217
- }
1218
- var DEFAULT_LSP_SERVERS = {
1219
- typescript: { command: "typescript-language-server", args: ["--stdio"] },
1220
- tsx: { command: "typescript-language-server", args: ["--stdio"] },
1221
- javascript: { command: "typescript-language-server", args: ["--stdio"] },
1222
- python: { command: "pyright-langserver", args: ["--stdio"] },
1223
- go: { command: "gopls", args: [] },
1224
- rust: { command: "rust-analyzer", args: [] }
1225
- };
1226
- async function runCodegraphLspResolution(params) {
1227
- const mod = await resolveCodegraphModule();
1228
- if (mod === null) {
1229
- return { ok: false, code: "package_missing", message: "@remnic/coding-graph is not installed." };
1230
- }
1231
- if (typeof mod.executeLspResolution !== "function" || typeof mod.planLspUpgrades !== "function" || typeof mod.LspClient?.connect !== "function") {
1232
- return { ok: false, code: "runtime_unavailable", message: "LSP resolution is not available in the installed @remnic/coding-graph." };
1233
- }
1234
- const engine = mod.createCodingGraphEngine?.() ?? null;
1235
- if (engine === null) {
1236
- return { ok: false, code: "engine_unavailable", message: "createCodingGraphEngine is not available." };
1237
- }
1238
- const repoRoot = path2.resolve(params.repoRoot);
1239
- const gitFactory = mod.defaultCodingGitInvoker;
1240
- if (typeof gitFactory !== "function") {
1241
- return { ok: true, upgraded: 0, unresolved: 0, budgetExhausted: 0 };
1242
- }
1243
- const tracked = gitFactory().listTrackedFiles(repoRoot);
1244
- if (!("paths" in tracked)) {
1245
- return { ok: true, upgraded: 0, unresolved: 0, budgetExhausted: 0 };
1246
- }
1247
- const resolvedCalleesBySrc = /* @__PURE__ */ new Map();
1248
- const alreadyResolved = (filePath, srcQualifiedName, calleeName) => {
1249
- const key = `${filePath}\0${srcQualifiedName}`;
1250
- let names = resolvedCalleesBySrc.get(key);
1251
- if (names === void 0) {
1252
- names = /* @__PURE__ */ new Set();
1253
- if (typeof params.store.resolvedCalleeNames === "function") {
1254
- for (const name of params.store.resolvedCalleeNames(srcQualifiedName, "heuristic", filePath)) {
1255
- names.add(name);
1256
- }
1257
- }
1258
- resolvedCalleesBySrc.set(key, names);
1259
- }
1260
- return names.has(calleeName);
1261
- };
1262
- const sites = [];
1263
- const gatheredCountByFile = /* @__PURE__ */ new Map();
1264
- const filteredCountByFile = /* @__PURE__ */ new Map();
1265
- const filteredSrcByFile = /* @__PURE__ */ new Map();
1266
- const parsedFiles = /* @__PURE__ */ new Set();
1267
- for (const rel of tracked.paths) {
1268
- const absPath = path2.join(repoRoot, rel);
1269
- if (await lspPathEscapesRoot(repoRoot, absPath)) continue;
1270
- let content;
1271
- try {
1272
- content = await readFile2(absPath, "utf-8");
1273
- } catch {
1274
- continue;
1275
- }
1276
- let parsed;
1277
- try {
1278
- parsed = await engine.parseFile({ path: rel, content });
1279
- } catch {
1280
- continue;
1281
- }
1282
- if (!parsed || typeof parsed !== "object" || !("ok" in parsed) || parsed.ok !== true || !("ir" in parsed)) continue;
1283
- const ir = parsed.ir;
1284
- if (!ir || typeof ir !== "object" || !("callSites" in ir) || !Array.isArray(ir.callSites)) continue;
1285
- parsedFiles.add(rel);
1286
- const language = "language" in ir && typeof ir.language === "string" ? ir.language : "";
1287
- const symbols = "symbols" in ir && Array.isArray(ir.symbols) ? ir.symbols : [];
1288
- const contentBytes = Buffer.from(content, "utf-8");
1289
- for (const site of ir.callSites) {
1290
- if (!site || typeof site !== "object" || !("span" in site)) continue;
1291
- const span = site.span;
1292
- if (!span || typeof span !== "object" || !("startByte" in span) || typeof span.startByte !== "number") continue;
1293
- const calleeName = "calleeNameCandidates" in site && Array.isArray(site.calleeNameCandidates) && typeof site.calleeNameCandidates[0] === "string" ? site.calleeNameCandidates[0] : "";
1294
- if (calleeName.length === 0) continue;
1295
- let srcQualifiedName = "";
1296
- let bestSpanSize = Number.POSITIVE_INFINITY;
1297
- for (const sym of symbols) {
1298
- if (!sym || typeof sym !== "object" || !("span" in sym) || !("qualifiedName" in sym)) continue;
1299
- const ss = sym.span;
1300
- if (!ss || typeof ss !== "object" || !("startByte" in ss) || !("endByte" in ss)) continue;
1301
- if (typeof ss.startByte !== "number" || typeof ss.endByte !== "number") continue;
1302
- if (ss.startByte <= span.startByte && span.startByte < ss.endByte) {
1303
- const size = ss.endByte - ss.startByte;
1304
- if (size < bestSpanSize) {
1305
- bestSpanSize = size;
1306
- srcQualifiedName = typeof sym.qualifiedName === "string" ? sym.qualifiedName : "";
1307
- }
1308
- }
1309
- }
1310
- if (srcQualifiedName.length === 0) continue;
1311
- const memberAccess = "memberAccess" in site && site.memberAccess === true;
1312
- if (!memberAccess && alreadyResolved(rel, srcQualifiedName, calleeName)) {
1313
- filteredCountByFile.set(rel, (filteredCountByFile.get(rel) ?? 0) + 1);
1314
- let srcs = filteredSrcByFile.get(rel);
1315
- if (srcs === void 0) {
1316
- srcs = /* @__PURE__ */ new Map();
1317
- filteredSrcByFile.set(rel, srcs);
1318
- }
1319
- const callees = srcs.get(srcQualifiedName);
1320
- if (callees === void 0) srcs.set(srcQualifiedName, /* @__PURE__ */ new Set([calleeName]));
1321
- else callees.add(calleeName);
1322
- continue;
1323
- }
1324
- const nameIdx = contentBytes.indexOf(Buffer.from(calleeName, "utf-8"), span.startByte);
1325
- const endByte = "endByte" in span && typeof span.endByte === "number" ? span.endByte : span.startByte + calleeName.length;
1326
- const calleeByteOffset = nameIdx >= 0 && nameIdx < endByte ? nameIdx : span.startByte;
1327
- sites.push({ filePath: rel, language, content, calleeByteOffset, calleeName, srcQualifiedName });
1328
- gatheredCountByFile.set(rel, (gatheredCountByFile.get(rel) ?? 0) + 1);
1329
- }
1330
- }
1331
- const canPreserve = typeof params.store.callEdgesForCaller === "function";
1332
- const preservedEdgesForFile = (rel) => {
1333
- const srcs = filteredSrcByFile.get(rel);
1334
- if (srcs === void 0 || !canPreserve) return [];
1335
- const preserved = [];
1336
- for (const [src] of srcs) {
1337
- const heuristicDsts = new Set(
1338
- params.store.callEdgesForCaller(src, rel, "heuristic").map((e) => e.dstQualifiedName)
1339
- );
1340
- for (const edge of params.store.callEdgesForCaller(src, rel, "lsp")) {
1341
- if (!heuristicDsts.has(edge.dstQualifiedName)) continue;
1342
- preserved.push({
1343
- srcQualifiedName: edge.srcQualifiedName,
1344
- dstQualifiedName: edge.dstQualifiedName,
1345
- type: edge.type
1346
- });
1347
- }
1348
- }
1349
- return preserved;
1350
- };
1351
- if (typeof params.store.reconcileLspEdges === "function") {
1352
- for (const rel of parsedFiles) {
1353
- if ((gatheredCountByFile.get(rel) ?? 0) !== 0) continue;
1354
- const filteredCount = filteredCountByFile.get(rel) ?? 0;
1355
- if (filteredCount > 0 && !canPreserve) continue;
1356
- params.store.reconcileLspEdges(rel, preservedEdgesForFile(rel));
1357
- }
1358
- }
1359
- if (sites.length === 0) {
1360
- return { ok: true, upgraded: 0, unresolved: 0, budgetExhausted: 0 };
1361
- }
1362
- const byLanguage = /* @__PURE__ */ new Map();
1363
- const srcToFiles = /* @__PURE__ */ new Map();
1364
- for (const site of sites) {
1365
- const group = byLanguage.get(site.language);
1366
- if (group === void 0) byLanguage.set(site.language, [site]);
1367
- else group.push(site);
1368
- const files = srcToFiles.get(site.srcQualifiedName);
1369
- if (files === void 0) srcToFiles.set(site.srcQualifiedName, /* @__PURE__ */ new Set([site.filePath]));
1370
- else files.add(site.filePath);
1371
- }
1372
- const configServers = params.lspConfig.servers ?? {};
1373
- const timeoutMs = params.lspConfig.timeoutMs ?? 3e3;
1374
- let remainingBudget = Math.max(1, Math.floor(params.lspConfig.maxRequestsPerRun ?? 500));
1375
- const rootUri = pathToFileURL(repoRoot).href;
1376
- const resolveContent = (filePath) => {
1377
- const absPath = path2.join(repoRoot, filePath);
1378
- if (lspPathEscapesRootSync(repoRoot, absPath)) return null;
1379
- try {
1380
- return readFileSync(absPath, "utf-8");
1381
- } catch {
1382
- return null;
1383
- }
1384
- };
1385
- let upgraded = 0;
1386
- let unresolved = 0;
1387
- let budgetExhausted = 0;
1388
- const degradations = [];
1389
- for (const [language, group] of byLanguage) {
1390
- if (remainingBudget <= 0) {
1391
- budgetExhausted += group.length;
1392
- continue;
1393
- }
1394
- const rawSpec = configServers[language] ?? DEFAULT_LSP_SERVERS[language];
1395
- if (rawSpec === void 0) {
1396
- degradations.push({
1397
- language,
1398
- code: "no_launch_spec",
1399
- message: `No LSP server configured for ${language} (${group.length} candidate call site(s)); set codingKnowledge.lsp.servers.${language}.`
1400
- });
1401
- unresolved += group.length;
1402
- continue;
1403
- }
1404
- const launchSpec = { command: rawSpec.command, args: rawSpec.args ?? [] };
1405
- const plan = mod.planLspUpgrades(group, { maxRequests: remainingBudget });
1406
- budgetExhausted += plan.budgetExhausted;
1407
- remainingBudget -= plan.requests.length;
1408
- if (plan.requests.length === 0) continue;
1409
- const plannedCountByFile = /* @__PURE__ */ new Map();
1410
- for (const req of plan.requests) {
1411
- if (req && typeof req === "object" && "filePath" in req && typeof req.filePath === "string") {
1412
- plannedCountByFile.set(req.filePath, (plannedCountByFile.get(req.filePath) ?? 0) + 1);
1413
- }
1414
- }
1415
- const connected = await mod.LspClient.connect({ launchSpec, rootUri, timeoutMs });
1416
- if (!connected.ok) {
1417
- const deg = connected.degradation;
1418
- const code = deg && typeof deg === "object" && "code" in deg && typeof deg.code === "string" ? deg.code : "connect_failed";
1419
- const message = deg && typeof deg === "object" && "detail" in deg && typeof deg.detail === "string" ? deg.detail : `LSP server for ${language} failed to connect.`;
1420
- degradations.push({ language, code, message });
1421
- unresolved += plan.requests.length;
1422
- remainingBudget += plan.requests.length;
1423
- continue;
1424
- }
1425
- const client = connected.client;
1426
- let skippedEdgesTotal = 0;
1427
- const skippedFiles = /* @__PURE__ */ new Set();
1428
- try {
1429
- const result = await mod.executeLspResolution(plan.requests, {
1430
- client,
1431
- workspaceRoot: repoRoot,
1432
- resolveContent,
1433
- nodeLocator: (filePath, byteOffset) => typeof params.store.findNodeBySpan === "function" ? params.store.findNodeBySpan(filePath, byteOffset) : null,
1434
- applyUpgrades: async (upgrades) => {
1435
- if (typeof params.store.upsertEdges !== "function") {
1436
- throw new Error("store.upsertEdges is not available");
1437
- }
1438
- const result2 = await params.store.upsertEdges(upgrades);
1439
- if (!result2.ok) {
1440
- degradations.push({
1441
- language,
1442
- code: "edge_write_failed",
1443
- message: `upsertEdges failed for ${language}: ${result2.code}.`
1444
- });
1445
- throw new Error(`upsertEdges failed: ${result2.code}`);
1446
- }
1447
- if (result2.skipped > 0) {
1448
- skippedEdgesTotal += result2.skipped;
1449
- for (const upgrade of upgrades) {
1450
- for (const file of srcToFiles.get(upgrade.srcQualifiedName) ?? []) {
1451
- skippedFiles.add(file);
1452
- }
1453
- }
1454
- degradations.push({
1455
- language,
1456
- code: "edges_skipped",
1457
- message: `upsertEdges persisted ${result2.persisted} and skipped ${result2.skipped} edge(s) for ${language} (unresolvable endpoints).`
1458
- });
1459
- }
1460
- },
1461
- reconcileLspEdges: (filePath, assertedEdges) => {
1462
- if (typeof params.store.reconcileLspEdges !== "function") return;
1463
- if (plannedCountByFile.get(filePath) !== gatheredCountByFile.get(filePath)) return;
1464
- if (skippedFiles.has(filePath)) return;
1465
- if ((filteredCountByFile.get(filePath) ?? 0) > 0 && !canPreserve) return;
1466
- params.store.reconcileLspEdges(filePath, [...assertedEdges, ...preservedEdgesForFile(filePath)]);
1467
- }
1468
- });
1469
- if (result && typeof result === "object" && "upgraded" in result && typeof result.upgraded === "number") {
1470
- upgraded += Math.max(0, result.upgraded - skippedEdgesTotal);
1471
- unresolved += "unresolved" in result && typeof result.unresolved === "number" ? result.unresolved : 0;
1472
- budgetExhausted += "budgetExhausted" in result && typeof result.budgetExhausted === "number" ? result.budgetExhausted : 0;
1473
- if ("degradation" in result && result.degradation && typeof result.degradation === "object") {
1474
- const rd = result.degradation;
1475
- degradations.push({
1476
- language,
1477
- code: "code" in rd && typeof rd.code === "string" ? rd.code : "lsp_degraded",
1478
- message: "detail" in rd && typeof rd.detail === "string" ? rd.detail : `LSP pass for ${language} degraded mid-run.`
1479
- });
1480
- }
1481
- } else {
1482
- unresolved += plan.requests.length;
1483
- }
1484
- } catch (err) {
1485
- const detail = displayErrorDetail(err);
1486
- return {
1487
- ok: false,
1488
- code: "lsp_resolution_error",
1489
- message: detail.length > 0 ? `LSP resolution failed: ${detail}.` : "LSP resolution failed."
1490
- };
1491
- } finally {
1492
- const disposable = client;
1493
- if (typeof disposable.dispose === "function") {
1494
- try {
1495
- await disposable.dispose();
1496
- } catch {
1497
- }
1498
- }
1499
- }
1500
- }
1501
- return {
1502
- ok: true,
1503
- upgraded,
1504
- unresolved,
1505
- budgetExhausted,
1506
- ...degradations.length > 0 ? { degradations } : {}
1507
- };
1508
- }
1509
- async function reportCodegraphIndexStatus(params) {
1510
- const mod = await resolveCodegraphModule();
1511
- if (mod === null) {
1512
- return { ok: false, code: "package_missing", message: "The @remnic/coding-graph package is not installed." };
1513
- }
1514
- if (typeof mod.getIndexStatus !== "function" || typeof mod.defaultCodingGitInvoker !== "function") {
1515
- return { ok: false, code: "runtime_unavailable", message: "getIndexStatus is not available in the installed @remnic/coding-graph." };
1516
- }
1517
- const git = mod.defaultCodingGitInvoker();
1518
- try {
1519
- const status = mod.getIndexStatus(params.store, git, params.repoRoot);
1520
- return { ok: true, status };
1521
- } catch (err) {
1522
- const msg = err instanceof Error ? err.message : String(err);
1523
- return { ok: false, code: "store_error", message: msg };
1524
- }
1525
- }
1526
- async function detectCodegraphChanges(params) {
1527
- const mod = await resolveCodegraphModule();
1528
- if (mod === null) {
1529
- return { ok: false, code: "package_missing", message: "The @remnic/coding-graph package is not installed." };
1530
- }
1531
- if (typeof mod.computeBlastRadius !== "function") {
1532
- return { ok: false, code: "runtime_unavailable", message: "computeBlastRadius is not available in the installed @remnic/coding-graph." };
1533
- }
1534
- let engine;
1535
- try {
1536
- if (typeof mod.createCodingGraphEngine !== "function") {
1537
- return { ok: false, code: "engine_unavailable", message: "createCodingGraphEngine is not exported by @remnic/coding-graph." };
1538
- }
1539
- engine = mod.createCodingGraphEngine();
1540
- } catch (err) {
1541
- const msg = err instanceof Error ? err.message : String(err);
1542
- return { ok: false, code: "engine_unavailable", message: `The coding-graph engine is not ready: ${msg}` };
1543
- }
1544
- void engine;
1545
- void params;
1546
- try {
1547
- const result = mod.computeBlastRadius(params.store, /* @__PURE__ */ new Set());
1548
- if (result && result.ok === true) {
1549
- return { ok: true, affected: result.affected ?? [] };
1550
- }
1551
- return { ok: false, code: result?.code ?? "store_error", message: "computeBlastRadius reported a failure." };
1552
- } catch (err) {
1553
- const msg = err instanceof Error ? err.message : String(err);
1554
- return { ok: false, code: "store_error", message: msg };
1555
- }
1556
- }
1557
- async function ingestCodegraphTraces(params) {
1558
- if (typeof params.store.upsertEdges !== "function") {
1559
- return {
1560
- ok: false,
1561
- code: "runtime_unavailable",
1562
- message: "The installed @remnic/coding-graph does not expose upsertEdges; traces cannot be persisted."
1563
- };
1564
- }
1565
- const edges = [];
1566
- let accepted = 0;
1567
- for (const trace of params.traces) {
1568
- const t = trace;
1569
- if (typeof t?.caller !== "string" || typeof t?.callee !== "string") {
1570
- continue;
1571
- }
1572
- accepted += 1;
1573
- edges.push({
1574
- srcQualifiedName: t.caller,
1575
- dstQualifiedName: t.callee,
1576
- type: "HTTP_CALLS",
1577
- confidence: typeof t.confidence === "number" && t.confidence >= 0 && t.confidence <= 1 ? t.confidence : 0.5,
1578
- provenance: "trace"
1579
- });
1580
- }
1581
- try {
1582
- const result = await params.store.upsertEdges(edges);
1583
- if (result.ok === true) {
1584
- return { ok: true, accepted, persisted: result.persisted, skipped: result.skipped };
1585
- }
1586
- return { ok: false, code: result.code, message: "store.upsertEdges reported a failure." };
1587
- } catch (err) {
1588
- const msg = err instanceof Error ? err.message : String(err);
1589
- return { ok: false, code: "store_error", message: msg };
1590
- }
1591
- }
1592
- function deriveCodegraphProjectId(repoRoot) {
1593
- return `root:${createHash("sha256").update(repoRoot).digest("hex").slice(0, 16)}`;
1594
- }
1595
- function resolveCodegraphProjectId(params) {
1596
- const { request, getCodingContext } = params;
1597
- const explicit = typeof request.project === "string" ? request.project.trim() : "";
1598
- if (explicit.length > 0) return explicit;
1599
- const sessionKey = typeof request.sessionKey === "string" ? request.sessionKey.trim() : "";
1600
- if (sessionKey.length > 0) {
1601
- const cc = getCodingContext(sessionKey);
1602
- if (cc !== null) return cc.projectId;
1603
- }
1604
- const repoRoot = typeof request.repoRoot === "string" ? request.repoRoot.trim() : "";
1605
- if (repoRoot.length > 0) return deriveCodegraphProjectId(repoRoot);
1606
- throw new CodegraphRuntimeError(
1607
- "project_required",
1608
- "codegraph: project must be supplied explicitly, via a session coding context, or alongside a repoRoot"
1609
- );
1610
- }
1611
- var CodegraphRuntimeError = class extends Error {
1612
- code;
1613
- constructor(code, message) {
1614
- super(message);
1615
- this.name = "CodegraphRuntimeError";
1616
- this.code = code;
1617
- }
1618
- };
326
+ isHandleToken
327
+ } from "./chunk-JAKIDQB2.js";
328
+ import {
329
+ OFFLINE_SYNC_SNAPSHOT_FORMAT,
330
+ applyOfflineSyncChangeset,
331
+ applyOfflineSyncFileContentChunk,
332
+ buildOfflineSyncSnapshot,
333
+ buildOfflineSyncSnapshotForPaths,
334
+ buildOfflineSyncSnapshotFromBase,
335
+ compileOfflineSyncExcludeGlobs,
336
+ filterOfflineSyncDeletionRevisions,
337
+ iterateOfflineSyncSnapshotFileRecords,
338
+ normalizeOfflineSyncChangeset,
339
+ readOfflineSyncFileContentChunk
340
+ } from "./chunk-XJJYSX6F.js";
341
+ import {
342
+ validateArchiveRelativePath
343
+ } from "./chunk-GCGJW34D.js";
344
+ import {
345
+ parseIsoOffsetTimestamp
346
+ } from "./chunk-P7FMDTKL.js";
347
+ import {
348
+ assertOperationAuthorizationAllowed,
349
+ capabilityAllowsOp,
350
+ enforceNamespaceAllowList,
351
+ isNamespaceAllowed,
352
+ tokenCapabilityStore
353
+ } from "./chunk-MZWSOLMT.js";
354
+ import {
355
+ canReadNamespace,
356
+ canWriteNamespace,
357
+ citationAuthorizedNamespaces,
358
+ defaultNamespaceForPrincipal,
359
+ recallNamespacesForPrincipal,
360
+ resolvePrincipal
361
+ } from "./chunk-MRV7VSQK.js";
362
+ import {
363
+ namespaceIdentityFromToken
364
+ } from "./chunk-VUFL7X3H.js";
365
+ import {
366
+ resolveAccessSetupCapabilities,
367
+ resolveCompressionCapabilities,
368
+ resolveConsolidationCapabilities,
369
+ resolveGraphConstructionCapabilities,
370
+ resolveIdentityContinuityCapabilities,
371
+ resolveIndexingCapabilities,
372
+ resolveLocalLlmCapabilities,
373
+ resolveMemoryLifecycleCapabilities,
374
+ resolveNamespaceCapabilities,
375
+ resolveObjectiveStateCapabilities,
376
+ resolveQmdCapabilities,
377
+ resolveRecallAuxiliaryCapabilities,
378
+ resolveRecallEnhancementCapabilities,
379
+ resolveSecurityCapabilities
380
+ } from "./chunk-JUOZ62Y7.js";
381
+ import {
382
+ AccessIdempotencyStore,
383
+ hashAccessIdempotencyPayload
384
+ } from "./chunk-VFUEZZBS.js";
385
+ import {
386
+ resolveCodingContextFromOptions
387
+ } from "./chunk-MJUCDM3C.js";
388
+ import {
389
+ combineNamespaces,
390
+ defaultGitInvokerSync,
391
+ lcmSessionKeyForNamespace,
392
+ projectTagProjectId,
393
+ resolveCodingNamespaceOverlay,
394
+ resolveGitContext,
395
+ sanitizeFragment
396
+ } from "./chunk-QBC33MPY.js";
397
+ import {
398
+ expandTildePath
399
+ } from "./chunk-EYIEWJNI.js";
400
+ import {
401
+ EngramAccessForbiddenError,
402
+ EngramAccessInputError,
403
+ NamespaceNotWritableError
404
+ } from "./chunk-2Z24E5W2.js";
405
+ import {
406
+ abortError,
407
+ isAbortError,
408
+ raceAbort,
409
+ throwIfAborted
410
+ } from "./chunk-BTTPKDIL.js";
411
+ import {
412
+ readJsonFile,
413
+ writeJsonFileAtomic
414
+ } from "./chunk-P77QX3ID.js";
415
+ import {
416
+ AccessAuditAdapter
417
+ } from "./chunk-TVVEYCNW.js";
418
+ import {
419
+ decodeCitationNamespace
420
+ } from "./chunk-DJORULH3.js";
421
+ import {
422
+ isPathInsideStorageRoot
423
+ } from "./chunk-FF4KLI5W.js";
424
+ import {
425
+ SecureStoreLockedError
426
+ } from "./chunk-ET2CNMLD.js";
427
+ import {
428
+ ALL_CATEGORY_DIRS,
429
+ getCategoryDir
430
+ } from "./chunk-VS2IYZRU.js";
431
+ import {
432
+ recordCitationUsage
433
+ } from "./chunk-NINSR6LX.js";
434
+ import {
435
+ log
436
+ } from "./chunk-3WCASNQZ.js";
1619
437
 
1620
- // src/coding/decision-records.ts
1621
- var DECISION_STATUSES = [
1622
- "proposed",
1623
- "accepted",
1624
- "superseded",
1625
- "rejected"
1626
- ];
1627
- var ACTIVE_DECISION_STATUSES = /* @__PURE__ */ new Set([
1628
- "proposed",
1629
- "accepted"
1630
- ]);
1631
- var DEFAULT_DECISION_STATUS = "proposed";
1632
- var DECISION_STATUS_BY_VALUE = Object.freeze({
1633
- proposed: "proposed",
1634
- accepted: "accepted",
1635
- superseded: "superseded",
1636
- rejected: "rejected"
1637
- });
1638
- function isDecisionStatus(value) {
1639
- return typeof value === "string" && Object.prototype.hasOwnProperty.call(DECISION_STATUS_BY_VALUE, value);
1640
- }
1641
- var FRONTMATTER_KEYS = Object.freeze([
1642
- "id",
1643
- "title",
1644
- "status",
1645
- "context",
1646
- "decision",
1647
- "consequences",
1648
- "entityRefs",
1649
- "supersedes"
1650
- ]);
1651
- function serializeDecisionRecord(record) {
1652
- const lines = ["---"];
1653
- for (const key of FRONTMATTER_KEYS) {
1654
- const present = key === "supersedes" ? record.supersedes !== void 0 : key === "consequences" ? record.consequences !== void 0 : true;
1655
- if (!present) continue;
1656
- lines.push(`${key}: ${encodeFrontmatterValue(key, record)}`);
1657
- }
1658
- lines.push("---", "");
1659
- if (record.context) lines.push(record.context);
1660
- lines.push("");
1661
- lines.push("# Decision");
1662
- lines.push("");
1663
- if (record.decision) lines.push(record.decision);
1664
- if (record.consequences !== void 0 && record.consequences.length > 0) {
1665
- lines.push("");
1666
- lines.push("# Consequences");
1667
- lines.push("");
1668
- lines.push(record.consequences);
1669
- }
1670
- if (record.entityRefs.length > 0) {
1671
- lines.push("");
1672
- lines.push("# Entity references");
1673
- for (const ref of record.entityRefs) lines.push(`- ${ref}`);
1674
- }
1675
- lines.push("");
1676
- return lines.join("\n");
1677
- }
1678
- function encodeFrontmatterValue(key, record) {
1679
- if (key === "entityRefs") {
1680
- const refs = record.entityRefs;
1681
- if (refs.length === 0) return "[]";
1682
- const inner = refs.map((ref) => `"${escapeYamlString(ref)}"`).join(", ");
1683
- return `[${inner}]`;
1684
- }
1685
- if (key === "status") return `"${record.status}"`;
1686
- if (key === "supersedes") return `"${record.supersedes ?? ""}"`;
1687
- if (key === "consequences") return `"${escapeYamlString(record.consequences ?? "")}"`;
1688
- const value = record[key];
1689
- return `"${escapeYamlString(typeof value === "string" ? value : String(value))}"`;
1690
- }
1691
- function escapeYamlString(value) {
1692
- return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\n/g, "\\n");
1693
- }
1694
- function parseDecisionRecord(raw) {
1695
- const { fields, body } = extractFrontmatter(raw);
1696
- for (const fieldKey of Object.keys(fields)) {
1697
- if (!FRONTMATTER_KEYS.includes(fieldKey)) {
1698
- throw new Error(
1699
- `decision record frontmatter contains unknown key '${fieldKey}'; valid keys are ${FRONTMATTER_KEYS.join(", ")}.`
1700
- );
1701
- }
1702
- }
1703
- const id = requireString(fields.id, "id");
1704
- const title = requireString(fields.title, "title");
1705
- const context = requireString(fields.context, "context");
1706
- const decision = requireString(fields.decision, "decision");
1707
- const consequences = fields.consequences === void 0 ? void 0 : requireString(fields.consequences, "consequences");
1708
- let status = DEFAULT_DECISION_STATUS;
1709
- if (fields.status !== void 0 && fields.status !== null) {
1710
- if (!isDecisionStatus(fields.status)) {
1711
- throw new Error(
1712
- `decision '${id}' has invalid status '${JSON.stringify(fields.status)}'; valid statuses are ${DECISION_STATUSES.join(", ")}.`
1713
- );
1714
- }
1715
- status = fields.status;
1716
- }
1717
- const entityRefs = parseEntityRefs(fields.entityRefs);
1718
- const supersedes = fields.supersedes === void 0 ? void 0 : requireString(fields.supersedes, "supersedes");
1719
- const record = {
1720
- id,
1721
- title,
1722
- status,
1723
- context,
1724
- decision,
1725
- consequences,
1726
- entityRefs,
1727
- ...supersedes !== void 0 ? { supersedes } : {}
1728
- };
1729
- void body;
1730
- return record;
1731
- }
1732
- function requireString(field, key) {
1733
- if (field === void 0 || field === null) {
1734
- throw new Error(`decision record frontmatter is missing required field '${key}'.`);
1735
- }
1736
- if (typeof field !== "string") {
1737
- throw new Error(
1738
- `decision record frontmatter field '${key}' must be a string; got ${JSON.stringify(field)}.`
1739
- );
1740
- }
1741
- return field;
1742
- }
1743
- function parseEntityRefs(field) {
1744
- if (field === void 0) return [];
1745
- if (!Array.isArray(field)) {
1746
- throw new Error(
1747
- `decision record frontmatter field 'entityRefs' must be an array of strings; got ${JSON.stringify(field)}.`
1748
- );
1749
- }
1750
- for (const entry of field) {
1751
- if (typeof entry !== "string") {
1752
- throw new Error(
1753
- `decision record frontmatter 'entityRefs' entries must be strings; got ${JSON.stringify(entry)}.`
1754
- );
1755
- }
1756
- }
1757
- return [...field];
1758
- }
1759
- function extractFrontmatter(raw) {
1760
- const text = raw.charCodeAt(0) === 65279 ? raw.slice(1) : raw;
1761
- if (!text.startsWith("---\n")) {
1762
- throw new Error(
1763
- "decision record must start with a YAML frontmatter fence (`---\\n`); got a document with no leading fence."
1764
- );
1765
- }
1766
- const closeAt = text.indexOf("\n---", 4);
1767
- if (closeAt === -1) {
1768
- throw new Error(
1769
- "decision record frontmatter is missing its closing fence (`\\n---`); the document is truncated."
1770
- );
1771
- }
1772
- const yamlBody = text.slice(4, closeAt);
1773
- const after = text.slice(closeAt + 4);
1774
- const body = after.startsWith("\n") ? after.slice(1) : after;
1775
- return { fields: parseYamlMapping(yamlBody), body };
1776
- }
1777
- function parseYamlMapping(input) {
1778
- const fields = {};
1779
- for (const rawLine of input.split("\n")) {
1780
- const line = rawLine.trimEnd();
1781
- if (line.length === 0 || line.startsWith("#")) continue;
1782
- const colonAt = line.indexOf(":");
1783
- if (colonAt === -1) {
1784
- throw new Error(`decision record frontmatter line is not a key:value pair: "${line}".`);
1785
- }
1786
- const key = line.slice(0, colonAt).trim();
1787
- const valueText = line.slice(colonAt + 1).trim();
1788
- if (key.length === 0) {
1789
- throw new Error(`decision record frontmatter has an empty key in line: "${line}".`);
1790
- }
1791
- fields[key] = decodeScalar(valueText);
1792
- }
1793
- return fields;
1794
- }
1795
- function decodeScalar(valueText) {
1796
- if (valueText.length === 0) return "";
1797
- const lower = valueText.toLowerCase();
1798
- if (lower === "true") return true;
1799
- if (lower === "false") return false;
1800
- if (lower === "null" || lower === "~") return null;
1801
- if (/^-?\d+$/.test(valueText)) return Number(valueText);
1802
- if (/^".*"$/.test(valueText)) {
1803
- return valueText.slice(1, -1).replace(/\\\\/g, "\0").replace(/\\n/g, "\n").replace(/\\"/g, '"').replace(/\u0000/g, "\\");
1804
- }
1805
- if (/^\[.*\]$/.test(valueText)) return parseFlowList(valueText);
1806
- return valueText;
1807
- }
1808
- function parseFlowList(valueText) {
1809
- const inner = valueText.slice(1, -1).trim();
1810
- if (inner.length === 0) return [];
1811
- const out = [];
1812
- let buf = "";
1813
- let inQuotes = false;
1814
- let escaped = false;
1815
- for (let i = 0; i < inner.length; i += 1) {
1816
- const c = inner[i];
1817
- if (escaped) {
1818
- buf += c;
1819
- escaped = false;
1820
- continue;
1821
- }
1822
- if (c === "\\") {
1823
- buf += c;
1824
- escaped = true;
1825
- continue;
1826
- }
1827
- if (c === '"') {
1828
- inQuotes = !inQuotes;
1829
- buf += c;
1830
- continue;
1831
- }
1832
- if (c === "," && !inQuotes) {
1833
- out.push(stripFlowStringQuotes(buf.trim()));
1834
- buf = "";
1835
- continue;
1836
- }
1837
- buf += c;
1838
- }
1839
- if (buf.length > 0) out.push(stripFlowStringQuotes(buf.trim()));
1840
- return out;
1841
- }
1842
- function stripFlowStringQuotes(value) {
1843
- if (value.length >= 2 && value.startsWith('"') && value.endsWith('"')) {
1844
- return value.slice(1, -1).replace(/\\\\/g, "\0").replace(/\\n/g, "\n").replace(/\\"/g, '"').replace(/\u0000/g, "\\");
1845
- }
1846
- return value;
1847
- }
438
+ // src/access-service.ts
439
+ import { createHash as createHash12 } from "crypto";
440
+ import { constants as fsConstants2 } from "fs";
441
+ import { readdirSync, unlinkSync } from "fs";
442
+ import { stat as stat3 } from "fs/promises";
443
+ import * as nodeFs2 from "fs/promises";
444
+ import { ZodError } from "zod";
1848
445
 
1849
446
  // src/coding/decision-surfaces.ts
1850
447
  var DECISION_SUBCOMMANDS = [
@@ -2167,7 +764,7 @@ async function handleGetSchema(store, tool) {
2167
764
  return { tool, ok: true, result: stats };
2168
765
  }
2169
766
  async function handleSearchGraph(store, request, ctx) {
2170
- const query = requireString2(request.query, "query", ctx);
767
+ const query = requireString(request.query, "query", ctx);
2171
768
  const limit = clampPositiveInteger(request.limit, 50, "limit", ctx);
2172
769
  const result = store.searchGraph({ namePattern: query, limit });
2173
770
  if (!result.ok) {
@@ -2177,7 +774,7 @@ async function handleSearchGraph(store, request, ctx) {
2177
774
  }
2178
775
  var SEARCH_CODE_KINDS = ["function", "class", "method"];
2179
776
  async function handleSearchCode(store, request, ctx) {
2180
- const query = requireString2(request.query, "query", ctx);
777
+ const query = requireString(request.query, "query", ctx);
2181
778
  const limit = clampPositiveInteger(request.limit, 50, "limit", ctx);
2182
779
  const seen = /* @__PURE__ */ new Set();
2183
780
  const merged = [];
@@ -2198,7 +795,7 @@ async function handleSearchCode(store, request, ctx) {
2198
795
  return { tool: request.tool, ok: true, result: { hits: merged } };
2199
796
  }
2200
797
  async function handleTracePath(store, request, ctx) {
2201
- const start = requireString2(request.start, "start", ctx);
798
+ const start = requireString(request.start, "start", ctx);
2202
799
  const direction = request.direction ?? "outbound";
2203
800
  if (!TRACE_DIRECTION_SET.has(direction)) {
2204
801
  ctx.throwInputError(
@@ -2214,7 +811,7 @@ async function handleTracePath(store, request, ctx) {
2214
811
  return { tool: request.tool, ok: true, result };
2215
812
  }
2216
813
  async function handleGetSnippet(store, request, ctx) {
2217
- const qualifiedName = requireString2(request.qualifiedName, "qualifiedName", ctx);
814
+ const qualifiedName = requireString(request.qualifiedName, "qualifiedName", ctx);
2218
815
  const result = await store.snippetFor({ qualifiedName });
2219
816
  if (!result.ok) {
2220
817
  return { tool: request.tool, ok: false, code: result.code, message: "snippetFor failed" };
@@ -2254,7 +851,7 @@ async function handleIndexStatus(store, request, ctx) {
2254
851
  return { tool: request.tool, ok: true, result: outcome.status };
2255
852
  }
2256
853
  async function handleDetectChanges(store, request, ctx) {
2257
- const head = requireString2(request.head, "head", ctx);
854
+ const head = requireString(request.head, "head", ctx);
2258
855
  if (!ctx.detectChanges) {
2259
856
  return {
2260
857
  tool: request.tool,
@@ -2272,7 +869,7 @@ async function handleDetectChanges(store, request, ctx) {
2272
869
  return { tool: request.tool, ok: true, result: { head, affected: outcome.affected } };
2273
870
  }
2274
871
  async function handleIndex(request, ctx) {
2275
- const repoRoot = requireString2(request.repoRoot, "repoRoot", ctx);
872
+ const repoRoot = requireString(request.repoRoot, "repoRoot", ctx);
2276
873
  const modeRaw = request.mode ?? "auto";
2277
874
  if (!INDEX_MODE_SET.has(modeRaw)) {
2278
875
  ctx.throwInputError(`mode must be one of ${INDEX_MODES.join(", ")}; got ${JSON.stringify(modeRaw)}`);
@@ -2426,7 +1023,7 @@ async function handleIngestTraces(store, request, ctx) {
2426
1023
  }
2427
1024
  };
2428
1025
  }
2429
- function requireString2(value, field, ctx) {
1026
+ function requireString(value, field, ctx) {
2430
1027
  if (typeof value !== "string" || value.trim().length === 0) {
2431
1028
  ctx.throwInputError(`codegraph: ${field} is required and must be a non-empty string`);
2432
1029
  }
@@ -2468,8 +1065,8 @@ function isLikelyCypher(input) {
2468
1065
  }
2469
1066
 
2470
1067
  // src/coding/session-delta.ts
2471
- import { readFile as readFile3, writeFile, mkdir, rename } from "fs/promises";
2472
- import path3 from "path";
1068
+ import { readFile, writeFile, mkdir, rename } from "fs/promises";
1069
+ import path from "path";
2473
1070
  var MAX_DELTA_COMMITS = 20;
2474
1071
  var MAX_DELTA_FILES = 50;
2475
1072
  function computeSessionDelta(lastSeen, current) {
@@ -2527,14 +1124,14 @@ function formatSinceDate(iso) {
2527
1124
  const match = /^(\d{4}-\d{2}-\d{2})/.exec(iso);
2528
1125
  return match ? match[1] : iso;
2529
1126
  }
2530
- var CODING_KNOWLEDGE_STATE_DIR = path3.join("state", "coding-knowledge");
1127
+ var CODING_KNOWLEDGE_STATE_DIR = path.join("state", "coding-knowledge");
2531
1128
  function sessionDeltaStatePath(memoryDir, namespace) {
2532
1129
  const safe = sanitizeFragment(namespace) || "default";
2533
- return path3.join(memoryDir, CODING_KNOWLEDGE_STATE_DIR, `${safe}.json`);
1130
+ return path.join(memoryDir, CODING_KNOWLEDGE_STATE_DIR, `${safe}.json`);
2534
1131
  }
2535
1132
  async function readLastSeenState(statePath) {
2536
1133
  try {
2537
- const raw = await readFile3(statePath, "utf8");
1134
+ const raw = await readFile(statePath, "utf8");
2538
1135
  const parsed = JSON.parse(raw);
2539
1136
  if (typeof parsed !== "object" || parsed === null) return null;
2540
1137
  const obj = parsed;
@@ -2552,7 +1149,7 @@ async function writeLastSeenState(statePath, state) {
2552
1149
  `writeLastSeenState: invalid state (head=${JSON.stringify(state.head)}, at=${JSON.stringify(state.at)})`
2553
1150
  );
2554
1151
  }
2555
- const dir = path3.dirname(statePath);
1152
+ const dir = path.dirname(statePath);
2556
1153
  await mkdir(dir, { recursive: true });
2557
1154
  const tmp = `${statePath}.tmp-${process.pid}-${Date.now()}`;
2558
1155
  await writeFile(tmp, JSON.stringify(state, null, 2), "utf8");
@@ -2945,8 +1542,8 @@ var CorrectionContractError = class extends Error {
2945
1542
  };
2946
1543
 
2947
1544
  // src/correction/correction-planner.ts
2948
- import { readFile as readFile4, readdir as readdir2, unlink } from "fs/promises";
2949
- import path4 from "path";
1545
+ import { readFile as readFile2, readdir, unlink } from "fs/promises";
1546
+ import path2 from "path";
2950
1547
  var REDACTED_REQUEST_TEXT = "[redacted \u2014 never-store/redaction correction text withheld from the pending-plan file]";
2951
1548
  var CorrectionPlanner = class _CorrectionPlanner {
2952
1549
  constructor(deps) {
@@ -3137,13 +1734,13 @@ var CorrectionPlanner = class _CorrectionPlanner {
3137
1734
  // -------------------------------------------------------------------------
3138
1735
  /** Directory holding pending plans for one namespace. */
3139
1736
  async pendingDir(namespace) {
3140
- return path4.join(await this.deps.storageDir(namespace), "state", "corrections", "pending");
1737
+ return path2.join(await this.deps.storageDir(namespace), "state", "corrections", "pending");
3141
1738
  }
3142
1739
  async persist(plan, abortSignal) {
3143
1740
  throwIfAborted(abortSignal, "correction planning aborted");
3144
1741
  const dir = await this.pendingDir(plan.namespace);
3145
1742
  throwIfAborted(abortSignal, "correction planning aborted");
3146
- const target = path4.join(dir, `${plan.planId}.json`);
1743
+ const target = path2.join(dir, `${plan.planId}.json`);
3147
1744
  const sensitive = plan.classification === "never_store" || plan.actions.some((a) => a.kind === "redaction_rule");
3148
1745
  const persistedPlan = sensitive ? { ...plan, request: { ...plan.request, text: REDACTED_REQUEST_TEXT } } : plan;
3149
1746
  await serializeMutations(`correction-plan:${target}`, async () => {
@@ -3157,11 +1754,11 @@ var CorrectionPlanner = class _CorrectionPlanner {
3157
1754
  /** Load a pending plan by id (used by the service / executor). */
3158
1755
  async loadPlan(namespace, planId) {
3159
1756
  assertSafePlanId(planId);
3160
- const file = path4.join(await this.pendingDir(namespace), `${planId}.json`);
1757
+ const file = path2.join(await this.pendingDir(namespace), `${planId}.json`);
3161
1758
  return serializeMutations(`correction-plan:${file}`, async () => {
3162
1759
  let raw;
3163
1760
  try {
3164
- raw = await readFile4(file, "utf-8");
1761
+ raw = await readFile2(file, "utf-8");
3165
1762
  } catch (err) {
3166
1763
  const code = err?.code;
3167
1764
  if (code === "ENOENT") return null;
@@ -3175,7 +1772,7 @@ var CorrectionPlanner = class _CorrectionPlanner {
3175
1772
  const dir = await this.pendingDir(namespace);
3176
1773
  let files;
3177
1774
  try {
3178
- files = await readdir2(dir);
1775
+ files = await readdir(dir);
3179
1776
  } catch (err) {
3180
1777
  const code = err?.code;
3181
1778
  if (code === "ENOENT") return [];
@@ -3197,11 +1794,11 @@ var CorrectionPlanner = class _CorrectionPlanner {
3197
1794
  }
3198
1795
  async markConsumed(namespace, planId, status) {
3199
1796
  assertSafePlanId(planId);
3200
- const file = path4.join(await this.pendingDir(namespace), `${planId}.json`);
1797
+ const file = path2.join(await this.pendingDir(namespace), `${planId}.json`);
3201
1798
  await serializeMutations(`correction-plan:${file}`, async () => {
3202
1799
  let raw;
3203
1800
  try {
3204
- raw = await readFile4(file, "utf-8");
1801
+ raw = await readFile2(file, "utf-8");
3205
1802
  } catch (err) {
3206
1803
  const code = err?.code;
3207
1804
  if (code === "ENOENT") return;
@@ -3230,11 +1827,11 @@ var CorrectionPlanner = class _CorrectionPlanner {
3230
1827
  */
3231
1828
  async resetApplying(namespace, planId) {
3232
1829
  assertSafePlanId(planId);
3233
- const file = path4.join(await this.pendingDir(namespace), `${planId}.json`);
1830
+ const file = path2.join(await this.pendingDir(namespace), `${planId}.json`);
3234
1831
  await serializeMutations(`correction-plan:${file}`, async () => {
3235
1832
  let raw;
3236
1833
  try {
3237
- raw = await readFile4(file, "utf-8");
1834
+ raw = await readFile2(file, "utf-8");
3238
1835
  } catch (err) {
3239
1836
  const code = err?.code;
3240
1837
  if (code === "ENOENT") return;
@@ -3250,7 +1847,7 @@ var CorrectionPlanner = class _CorrectionPlanner {
3250
1847
  }
3251
1848
  async deletePlan(namespace, planId) {
3252
1849
  assertSafePlanId(planId);
3253
- const file = path4.join(await this.pendingDir(namespace), `${planId}.json`);
1850
+ const file = path2.join(await this.pendingDir(namespace), `${planId}.json`);
3254
1851
  await serializeMutations(`correction-plan:${file}`, async () => {
3255
1852
  try {
3256
1853
  await unlink(file);
@@ -3286,7 +1883,7 @@ var CorrectionPlanner = class _CorrectionPlanner {
3286
1883
  const dir = await this.pendingDir(namespace);
3287
1884
  let files;
3288
1885
  try {
3289
- files = await readdir2(dir);
1886
+ files = await readdir(dir);
3290
1887
  } catch (err) {
3291
1888
  const code = err?.code;
3292
1889
  if (code === "ENOENT") return [];
@@ -3912,8 +2509,8 @@ var CorrectionService = class {
3912
2509
  };
3913
2510
 
3914
2511
  // src/correction/correction-access-wiring.ts
3915
- import path5 from "path";
3916
- import { createHash as createHash2 } from "crypto";
2512
+ import path3 from "path";
2513
+ import { createHash } from "crypto";
3917
2514
  function createCorrectionService(wiring) {
3918
2515
  const cfg = wiring.orchestrator.config;
3919
2516
  const correctionEnabled = isCorrectionFeatureEnabled(cfg);
@@ -4357,14 +2954,14 @@ async function registerRedactionRuleFn(wiring, namespace, pattern, abortSignal,
4357
2954
  throwIfAborted(abortSignal, "correction apply aborted");
4358
2955
  const storage = await wiring.orchestrator.getStorage(namespace);
4359
2956
  throwIfAborted(abortSignal, "correction apply aborted");
4360
- const dir = path5.join(storage.dir, REDACTION_RULES_SUBDIR);
2957
+ const dir = path3.join(storage.dir, REDACTION_RULES_SUBDIR);
4361
2958
  throwIfAborted(abortSignal, "correction apply aborted");
4362
2959
  const slugBase = pattern.replace(/[^a-zA-Z0-9]+/g, "-").slice(0, 48) || "rule";
4363
- const patternHash = createHash2("sha256").update(pattern).digest("hex").slice(0, 16);
2960
+ const patternHash = createHash("sha256").update(pattern).digest("hex").slice(0, 16);
4364
2961
  const slug = `${slugBase}-${patternHash}`;
4365
2962
  throwIfAborted(abortSignal, "correction apply aborted");
4366
2963
  await writeRule(
4367
- path5.join(dir, `${slug}.json`),
2964
+ path3.join(dir, `${slug}.json`),
4368
2965
  `${JSON.stringify({ pattern, namespace, createdAt: (/* @__PURE__ */ new Date()).toISOString() })}
4369
2966
  `
4370
2967
  );
@@ -4860,7 +3457,74 @@ function buildNotificationSummary(plan) {
4860
3457
  }
4861
3458
 
4862
3459
  // src/orchestration/generic-recall-paths.ts
4863
- import path6 from "path";
3460
+ import path5 from "path";
3461
+
3462
+ // src/activity/journal.ts
3463
+ import { mkdirSync, statSync, writeFileSync } from "fs";
3464
+ import path4 from "path";
3465
+ var JOURNAL_DIR_NAME = "journal";
3466
+ var JOURNAL_DAY_TOPLEVEL = /^journal[\\/]\d{4}-\d{2}-\d{2}\.md$/i;
3467
+ var JOURNAL_DAY_ANYWHERE = /(?:^|[\\/])journal[\\/]\d{4}-\d{2}-\d{2}\.md$/i;
3468
+ function journalPath(memoryDir, date) {
3469
+ if (!isValidActivityDate(date)) {
3470
+ throw new RangeError(`Invalid journal date "${date}"; expected YYYY-MM-DD.`);
3471
+ }
3472
+ return path4.join(memoryDir, JOURNAL_DIR_NAME, `${date}.md`);
3473
+ }
3474
+ function isJournalDayPath(filePath, memoryRoot) {
3475
+ if (memoryRoot !== void 0 && memoryRoot.length > 0) {
3476
+ const relative2 = path4.relative(memoryRoot, path4.resolve(memoryRoot, filePath));
3477
+ return JOURNAL_DAY_TOPLEVEL.test(relative2);
3478
+ }
3479
+ return JOURNAL_DAY_ANYWHERE.test(filePath);
3480
+ }
3481
+ function todayJournalDate(now = /* @__PURE__ */ new Date()) {
3482
+ const year = now.getFullYear();
3483
+ const month = String(now.getMonth() + 1).padStart(2, "0");
3484
+ const day = String(now.getDate()).padStart(2, "0");
3485
+ return `${year}-${month}-${day}`;
3486
+ }
3487
+ function formatCardDuration(card) {
3488
+ const start = Date.parse(card.startUtc);
3489
+ const end = Date.parse(card.endUtc);
3490
+ const minutes = Number.isFinite(start) && Number.isFinite(end) && end > start ? Math.round((end - start) / 6e4) : 0;
3491
+ return `${minutes}m`;
3492
+ }
3493
+ function renderJournalSeed(date, cards) {
3494
+ const ordered = [...cards].sort((left, right) => {
3495
+ const byStart = left.startUtc.localeCompare(right.startUtc);
3496
+ return byStart !== 0 ? byStart : left.title.localeCompare(right.title);
3497
+ });
3498
+ const glance = ordered.length === 0 ? ["_No cards._"] : ordered.map((card) => `- ${formatCardDuration(card)} ${card.title}`);
3499
+ return [`# Journal \u2014 ${date}`, "", "## Day at a glance", "", ...glance, "", "## Notes", "", ""].join(
3500
+ "\n"
3501
+ );
3502
+ }
3503
+ function writeJournalFile(filePath, content, force) {
3504
+ let exists = false;
3505
+ try {
3506
+ statSync(filePath);
3507
+ exists = true;
3508
+ } catch (err) {
3509
+ const code = err.code;
3510
+ if (code !== "ENOENT") throw err;
3511
+ }
3512
+ if (exists && !force) return false;
3513
+ mkdirSync(path4.dirname(filePath), { recursive: true });
3514
+ writeFileSync(filePath, content);
3515
+ return true;
3516
+ }
3517
+ function seedJournal(input) {
3518
+ const filePath = journalPath(input.memoryDir, input.date);
3519
+ const wrote = writeJournalFile(
3520
+ filePath,
3521
+ renderJournalSeed(input.date, input.cards ?? []),
3522
+ input.force === true
3523
+ );
3524
+ return { path: filePath, wrote };
3525
+ }
3526
+
3527
+ // src/orchestration/generic-recall-paths.ts
4864
3528
  var CATEGORY_MEMORY_ROOTS = Object.fromEntries(
4865
3529
  ALL_CATEGORY_DIRS.map((directory) => [directory, true])
4866
3530
  );
@@ -4885,7 +3549,7 @@ function normalizeQmdUriPath(relativePath, source) {
4885
3549
  }
4886
3550
  }
4887
3551
  function stripQmdCollectionPrefix(relativePath, policy, source) {
4888
- const normalized = path6.posix.normalize(normalizeQmdUriPath(relativePath, source).replace(/\\/g, "/"));
3552
+ const normalized = path5.posix.normalize(normalizeQmdUriPath(relativePath, source).replace(/\\/g, "/"));
4889
3553
  const slashIndex = normalized.indexOf("/");
4890
3554
  if (slashIndex <= 0 || slashIndex >= normalized.length - 1) return normalized;
4891
3555
  const prefix = normalized.slice(0, slashIndex);
@@ -4894,8 +3558,8 @@ function stripQmdCollectionPrefix(relativePath, policy, source) {
4894
3558
  return matchesHotCollection || matchesColdCollection ? normalized.slice(slashIndex + 1) : normalized;
4895
3559
  }
4896
3560
  function isTopLevelArchivePath(filePath, policy = {}, source = "filesystem") {
4897
- const isAbsolutePath = path6.isAbsolute(filePath);
4898
- const relative2 = policy.memoryDir && isAbsolutePath ? path6.relative(policy.memoryDir, path6.resolve(filePath)) : filePath;
3561
+ const isAbsolutePath = path5.isAbsolute(filePath);
3562
+ const relative2 = policy.memoryDir && isAbsolutePath ? path5.relative(policy.memoryDir, path5.resolve(filePath)) : filePath;
4899
3563
  const normalized = !isAbsolutePath ? stripQmdCollectionPrefix(relative2, policy, source) : relative2;
4900
3564
  return /^(?:archive|namespaces[\\/][^\\/]+[\\/]archive)(?:[\\/]|$)/i.test(normalized);
4901
3565
  }
@@ -4909,7 +3573,7 @@ function isExternalWikiQmdPath(filePath, source) {
4909
3573
  function isSearchExcludedPath(filePath, policy = {}, source = "filesystem") {
4910
3574
  if (isExternalWikiQmdPath(filePath, source)) return true;
4911
3575
  for (const candidate of collectionSpellings(filePath, policy, source)) {
4912
- if (isArtifactMemoryPath(candidate) || isNamespacedActivityDigestPath(candidate, policy.memoryDir) || isNamespacedLocationDayPath(candidate, policy.memoryDir) || isMeetingRecordPath(candidate)) {
3576
+ if (isArtifactMemoryPath(candidate) || isNamespacedActivityDigestPath(candidate, policy.memoryDir) || isNamespacedLocationDayPath(candidate, policy.memoryDir) || isNamespacedJournalDayPath(candidate, policy.memoryDir) || isMeetingRecordPath(candidate)) {
4913
3577
  return true;
4914
3578
  }
4915
3579
  }
@@ -4918,7 +3582,7 @@ function isSearchExcludedPath(filePath, policy = {}, source = "filesystem") {
4918
3582
  function isNamespacedActivityDigestPath(candidate, memoryDir) {
4919
3583
  if (isActivityDigestPath(candidate, memoryDir)) return true;
4920
3584
  if (memoryDir === void 0 || memoryDir.length === 0) return false;
4921
- const relative2 = path6.relative(memoryDir, path6.resolve(memoryDir, candidate));
3585
+ const relative2 = path5.relative(memoryDir, path5.resolve(memoryDir, candidate));
4922
3586
  const namespaced = /^namespaces[\\/]([^\\/]+)[\\/](.*)$/.exec(relative2);
4923
3587
  if (namespaced === null) return false;
4924
3588
  return isActivityDigestPath(namespaced[2] ?? "", memoryDir);
@@ -4926,19 +3590,27 @@ function isNamespacedActivityDigestPath(candidate, memoryDir) {
4926
3590
  function isNamespacedLocationDayPath(candidate, memoryDir) {
4927
3591
  if (isLocationDayPath(candidate, memoryDir)) return true;
4928
3592
  if (memoryDir === void 0 || memoryDir.length === 0) return false;
4929
- const relative2 = path6.relative(memoryDir, path6.resolve(memoryDir, candidate));
3593
+ const relative2 = path5.relative(memoryDir, path5.resolve(memoryDir, candidate));
4930
3594
  const namespaced = /^namespaces[\\/]([^\\/]+)[\\/](.*)$/.exec(relative2);
4931
3595
  if (namespaced === null) return false;
4932
3596
  return isLocationDayPath(namespaced[2] ?? "", memoryDir);
4933
3597
  }
3598
+ function isNamespacedJournalDayPath(candidate, memoryDir) {
3599
+ if (isJournalDayPath(candidate, memoryDir)) return true;
3600
+ if (memoryDir === void 0 || memoryDir.length === 0) return false;
3601
+ const relative2 = path5.relative(memoryDir, path5.resolve(memoryDir, candidate));
3602
+ const namespaced = /^namespaces[\\/]([^\\/]+)[\\/](.*)$/.exec(relative2);
3603
+ if (namespaced === null) return false;
3604
+ return isJournalDayPath(namespaced[2] ?? "", memoryDir);
3605
+ }
4934
3606
  function collectionSpellings(filePath, policy, source) {
4935
- if (path6.isAbsolute(filePath)) return [filePath];
3607
+ if (path5.isAbsolute(filePath)) return [filePath];
4936
3608
  if (source === "qmd" && filePath.startsWith("qmd://")) {
4937
- const normalized2 = path6.posix.normalize(normalizeQmdUriPath(filePath, source).replace(/\\/g, "/"));
3609
+ const normalized2 = path5.posix.normalize(normalizeQmdUriPath(filePath, source).replace(/\\/g, "/"));
4938
3610
  const slashIndex2 = normalized2.indexOf("/");
4939
3611
  return slashIndex2 <= 0 || slashIndex2 >= normalized2.length - 1 ? [normalized2] : [normalized2, normalized2.slice(slashIndex2 + 1)];
4940
3612
  }
4941
- const normalized = path6.posix.normalize(
3613
+ const normalized = path5.posix.normalize(
4942
3614
  normalizeQmdUriPath(filePath, source).replace(/\\/g, "/")
4943
3615
  );
4944
3616
  const stripped = stripQmdCollectionPrefix(filePath, policy, source);
@@ -4955,9 +3627,7 @@ function collectionSpellings(filePath, policy, source) {
4955
3627
  return spellings;
4956
3628
  }
4957
3629
  function isGenericRecallExcludedPath(filePath, policy = {}, source = "filesystem") {
4958
- return isSearchExcludedPath(filePath, policy, source) || // Recall-only: archived memories are cold, but an explicit search is one
4959
- // of the surfaces they remain reachable through.
4960
- isTopLevelArchivePath(filePath, policy, source);
3630
+ return isSearchExcludedPath(filePath, policy, source) || isTopLevelArchivePath(filePath, policy, source) || OKF_RESERVED_BASENAMES[path5.basename(filePath)] === true;
4961
3631
  }
4962
3632
  function filterRecallCandidates(candidates, options) {
4963
3633
  const pathPolicy = options.pathPolicy ?? (options.memoryRoot === void 0 ? void 0 : { memoryDir: options.memoryRoot });
@@ -4968,9 +3638,9 @@ function filterRecallCandidates(candidates, options) {
4968
3638
  }
4969
3639
 
4970
3640
  // src/procedural/procedure-miner.ts
4971
- import { createHash as createHash3 } from "crypto";
3641
+ import { createHash as createHash2 } from "crypto";
4972
3642
  import { mkdir as mkdir2, rm, stat } from "fs/promises";
4973
- import path7 from "path";
3643
+ import path6 from "path";
4974
3644
 
4975
3645
  // src/procedural/reinforcement-core.ts
4976
3646
  function clusterByKey(items, keyFn) {
@@ -5014,7 +3684,7 @@ function clusterKey(record) {
5014
3684
  return `${goal}|${refs.join(",")}`;
5015
3685
  }
5016
3686
  function clusterKeyHash(cluster) {
5017
- return createHash3("sha256").update(cluster).digest("hex");
3687
+ return createHash2("sha256").update(cluster).digest("hex");
5018
3688
  }
5019
3689
  function isErrnoCode(error, code) {
5020
3690
  return typeof error === "object" && error !== null && "code" in error && error.code === code;
@@ -5023,8 +3693,8 @@ function sleep(ms) {
5023
3693
  return new Promise((resolve4) => setTimeout(resolve4, ms));
5024
3694
  }
5025
3695
  async function acquireClusterWriteLock(memoryDir, clusterHash) {
5026
- const lockRoot = path7.join(path7.resolve(memoryDir), "state", "procedure-miner-locks");
5027
- const lockDir = path7.join(lockRoot, `${clusterHash}.lock`);
3696
+ const lockRoot = path6.join(path6.resolve(memoryDir), "state", "procedure-miner-locks");
3697
+ const lockDir = path6.join(lockRoot, `${clusterHash}.lock`);
5028
3698
  await mkdir2(lockRoot, { recursive: true });
5029
3699
  const startedAt = Date.now();
5030
3700
  let attempts = 0;
@@ -5055,7 +3725,7 @@ async function acquireClusterWriteLock(memoryDir, clusterHash) {
5055
3725
  }
5056
3726
  }
5057
3727
  async function withClusterWriteLock(memoryDir, clusterHash, fn) {
5058
- const inProcessKey = `${path7.resolve(memoryDir)}:${clusterHash}`;
3728
+ const inProcessKey = `${path6.resolve(memoryDir)}:${clusterHash}`;
5059
3729
  const previous = inProcessClusterWriteLocks.get(inProcessKey) ?? Promise.resolve();
5060
3730
  let releaseInProcess;
5061
3731
  const current = previous.catch(() => void 0).then(
@@ -5193,7 +3863,7 @@ async function runProcedureMining(options) {
5193
3863
  }
5194
3864
 
5195
3865
  // src/support-passport/offline-sync-guard.ts
5196
- import path8 from "path";
3866
+ import path7 from "path";
5197
3867
  var MAX_SUPPORT_PASSPORT_FRONTMATTER_BYTES = 1048576;
5198
3868
  var SUPPORT_PASSPORT_MARKER = "support-passport-";
5199
3869
  var FRONTMATTER_PREFIXES = ["---\n", "---\r\n"];
@@ -5211,6 +3881,10 @@ function assertFrontmatterAllowed(frontmatter, relativePath) {
5211
3881
  if (frontmatter.includes(SUPPORT_PASSPORT_MARKER)) {
5212
3882
  throw new Error(`offline sync cannot modify private support-passport record: ${relativePath}`);
5213
3883
  }
3884
+ const parsed = parseFrontmatter(frontmatter);
3885
+ if (parsed && isSupportPassportPrivateMemory({ frontmatter: parsed.frontmatter })) {
3886
+ throw new Error(`offline sync cannot modify private support-passport record: ${relativePath}`);
3887
+ }
5214
3888
  }
5215
3889
  function inspectBufferedFrontmatter(raw, relativePath, endOfFile) {
5216
3890
  const prefixState = frontmatterPrefixState(raw);
@@ -5259,7 +3933,7 @@ function createSupportPassportOfflineSyncGuard(storage) {
5259
3933
  return {
5260
3934
  root: storage.dir,
5261
3935
  path: normalizedPath,
5262
- filePath: path8.resolve(storage.dir, ...normalizedPath.split("/"))
3936
+ filePath: path7.resolve(storage.dir, ...normalizedPath.split("/"))
5263
3937
  };
5264
3938
  };
5265
3939
  const assertTargetAllowed = async (target) => {
@@ -5403,6 +4077,7 @@ var OPERATION_NAMES = [
5403
4077
  "meetings_list",
5404
4078
  "meetings_get",
5405
4079
  "meetings_build",
4080
+ "standup",
5406
4081
  "action_confidence",
5407
4082
  "chatgpt_memory_inspector",
5408
4083
  "day_summary",
@@ -5590,10 +4265,10 @@ function formatZodIssues(error) {
5590
4265
  const parts = [];
5591
4266
  for (const issue of error.issues) {
5592
4267
  const hasNumeric = issue.path.some((p) => typeof p === "number");
5593
- const path20 = hasNumeric ? issue.path.filter((p) => typeof p === "string").join(".") || "(root)" : issue.path.length > 0 ? issue.path.join(".") : "(root)";
4268
+ const path19 = hasNumeric ? issue.path.filter((p) => typeof p === "string").join(".") || "(root)" : issue.path.length > 0 ? issue.path.join(".") : "(root)";
5594
4269
  const options = enumOptionsFromIssue(issue);
5595
4270
  const suffix = options ? `. Valid: ${options.join(", ")}` : "";
5596
- parts.push(`${path20}: ${issue.message}${suffix}`);
4271
+ parts.push(`${path19}: ${issue.message}${suffix}`);
5597
4272
  }
5598
4273
  return parts.length > 0 ? `request validation failed: ${parts.join("; ")}` : "request validation failed";
5599
4274
  }
@@ -5735,7 +4410,7 @@ function resolveQueryNamespaceWritablePreflight(caps, params, authenticatedPrinc
5735
4410
  }
5736
4411
 
5737
4412
  // src/admin/admin-surfaces.ts
5738
- import path9 from "path";
4413
+ import path8 from "path";
5739
4414
  var REDACTED = "<redacted>";
5740
4415
  var SENSITIVE_KEY_RE = /(token|secret|password|api[_-]?key|bearer|authorization|credential|private[_-]?key)/i;
5741
4416
  var BEARER_VALUE_RE = /^(bearer|sk-|pk-|xox[bp]-|AKIA)/i;
@@ -6008,7 +4683,7 @@ async function auditTranscripts(memoryDir) {
6008
4683
  movedEntries: file.groups.reduce((sum, group) => sum + group.entryCount, 0),
6009
4684
  unmovableLines: file.unmovableLines
6010
4685
  }));
6011
- const mixedOtherDefault = files.some((file) => file.sourceRelPath.split(path9.sep).includes("other"));
4686
+ const mixedOtherDefault = files.some((file) => file.sourceRelPath.split(path8.sep).includes("other"));
6012
4687
  const summary = plan.movedEntries === 0 ? "No mixed-session transcript data detected; nothing to migrate." : `Found ${plan.movedEntries} entries across ${plan.distinctSessions} distinct sessions stranded in shared/legacy directories. Run the CLI migration command to re-home them.`;
6013
4688
  return {
6014
4689
  generatedAt: plan.generatedAt,
@@ -6147,11 +4822,11 @@ async function promoteMemory(options) {
6147
4822
  }
6148
4823
 
6149
4824
  // src/procedural/library-maintenance.ts
6150
- import path10 from "path";
4825
+ import path9 from "path";
6151
4826
  var MAINTENANCE_ACTOR = "procedure-library-maintenance";
6152
4827
  var MAINTENANCE_RULE_VERSION = "procedure-library-maintenance:1";
6153
4828
  function maintenanceMarkerPath(memoryDir) {
6154
- return path10.join(memoryDir, "state", "procedure-maintenance.json");
4829
+ return path9.join(memoryDir, "state", "procedure-maintenance.json");
6155
4830
  }
6156
4831
  async function readProcedureMaintenanceMarker(memoryDir) {
6157
4832
  try {
@@ -7176,7 +5851,7 @@ var AccessAdminOpsSurface = class {
7176
5851
  readMemory: async (namespace, memoryId) => {
7177
5852
  const resolved = await this.deps.orchestrator.getStorage(namespace);
7178
5853
  const memory = await resolved.getMemoryById(memoryId);
7179
- if (!memory) return null;
5854
+ if (!memory || isSupportPassportPrivateMemory(memory)) return null;
7180
5855
  return {
7181
5856
  category: memory.frontmatter.category,
7182
5857
  content: memory.content,
@@ -7777,7 +6452,7 @@ var AccessLcmSurface = class {
7777
6452
  };
7778
6453
 
7779
6454
  // src/access-observe-write-surface.ts
7780
- import { createHash as createHash4 } from "crypto";
6455
+ import { createHash as createHash3 } from "crypto";
7781
6456
 
7782
6457
  // src/orchestration/session-context.ts
7783
6458
  var SessionOwnershipError = class extends Error {
@@ -9055,7 +7730,7 @@ var AccessObserveWriteSurface = class {
9055
7730
  sourceSessionKey: request.sessionKey,
9056
7731
  inputSummary: inputSummaryParts.length > 0 ? inputSummaryParts.join(" | ").slice(0, 500) : void 0,
9057
7732
  dryRun: request.dryRun === true,
9058
- promptHash: typeof request.sourcePrompt === "string" && request.sourcePrompt.length > 0 ? createHash4("sha256").update(request.sourcePrompt).digest("hex") : void 0
7733
+ promptHash: typeof request.sourcePrompt === "string" && request.sourcePrompt.length > 0 ? createHash3("sha256").update(request.sourcePrompt).digest("hex") : void 0
9059
7734
  };
9060
7735
  const preview = this.deps.orchestrator.previewMemoryActionEvent(event);
9061
7736
  if (request.dryRun === true) {
@@ -9067,11 +7742,11 @@ var AccessObserveWriteSurface = class {
9067
7742
  };
9068
7743
 
9069
7744
  // src/access-recall-surface.ts
9070
- import { createHash as createHash5 } from "crypto";
7745
+ import { createHash as createHash4 } from "crypto";
9071
7746
  import * as nodePath2 from "path";
9072
7747
 
9073
7748
  // src/orchestration/recall-result-formatter.ts
9074
- import path11 from "path";
7749
+ import path10 from "path";
9075
7750
  function renderConnectorLabel(connector) {
9076
7751
  if (!isValidConnectorId(connector)) return null;
9077
7752
  return connector.length <= CONNECTOR_LABEL_MAX_LENGTH ? connector : `${connector.slice(0, CONNECTOR_LABEL_MAX_LENGTH - 1)}\u2026`;
@@ -9093,15 +7768,15 @@ function resolveEffectiveIdentityInjectionMode(options) {
9093
7768
  return { mode: options.configuredMode, shouldInject: true };
9094
7769
  }
9095
7770
  function displayResultPath(resultPath, memoryDir, namespace) {
9096
- if (!path11.isAbsolute(resultPath)) return resultPath;
9097
- const root = path11.resolve(memoryDir);
9098
- const nsRoot = path11.join(root, "namespaces");
9099
- if (namespace && (resultPath === nsRoot || resultPath.startsWith(nsRoot + path11.sep))) {
9100
- const afterNs = path11.relative(nsRoot, resultPath).split(path11.sep).slice(1).join("/");
7771
+ if (!path10.isAbsolute(resultPath)) return resultPath;
7772
+ const root = path10.resolve(memoryDir);
7773
+ const nsRoot = path10.join(root, "namespaces");
7774
+ if (namespace && (resultPath === nsRoot || resultPath.startsWith(nsRoot + path10.sep))) {
7775
+ const afterNs = path10.relative(nsRoot, resultPath).split(path10.sep).slice(1).join("/");
9101
7776
  if (afterNs) return `${namespace}/${afterNs}`;
9102
7777
  }
9103
- const rel = path11.relative(root, resultPath);
9104
- return rel && !rel.startsWith("..") && !path11.isAbsolute(rel) ? rel.split(path11.sep).join("/") : resultPath;
7778
+ const rel = path10.relative(root, resultPath);
7779
+ return rel && !rel.startsWith("..") && !path10.isAbsolute(rel) ? rel.split(path10.sep).join("/") : resultPath;
9105
7780
  }
9106
7781
  function displaySafeRecallSnapshot(snapshot, memoryDir) {
9107
7782
  const includedMemories = coerceIncludedMemories(snapshot).map((memory) => ({
@@ -9656,7 +8331,7 @@ var AccessRecallSurface = class {
9656
8331
  const snapshotForSerialization = {
9657
8332
  sessionKey: options.sessionKey ?? "",
9658
8333
  recordedAt: new Date(options.snapshot.capturedAt).toISOString(),
9659
- queryHash: createHash5("sha256").update(options.query).digest("hex"),
8334
+ queryHash: createHash4("sha256").update(options.query).digest("hex"),
9660
8335
  queryLen: options.query.length,
9661
8336
  memoryIds,
9662
8337
  namespace,
@@ -10371,10 +9046,10 @@ var AccessRecallSurface = class {
10371
9046
  };
10372
9047
 
10373
9048
  // src/review/review-deck-surface.ts
10374
- import { createHash as createHash8 } from "crypto";
9049
+ import { createHash as createHash7 } from "crypto";
10375
9050
 
10376
9051
  // src/review/review-deck.ts
10377
- import { createHash as createHash6 } from "crypto";
9052
+ import { createHash as createHash5 } from "crypto";
10378
9053
 
10379
9054
  // src/review/frontmatter.ts
10380
9055
  function splitMarkdownFrontmatter(content) {
@@ -10419,7 +9094,7 @@ var REVIEW_REASON_LABELS = {
10419
9094
  };
10420
9095
  var EXCERPT_LIMIT = 240;
10421
9096
  function computeReviewItemRevision(fileContent) {
10422
- return `rv1:${createHash6("sha256").update(fileContent).digest("hex")}`;
9097
+ return `rv1:${createHash5("sha256").update(fileContent).digest("hex")}`;
10423
9098
  }
10424
9099
  function projectReviewDeckItem(row, namespace) {
10425
9100
  const provenance = provenanceFromRow(row);
@@ -10564,16 +9239,16 @@ function parseCursorPayload(cursor) {
10564
9239
  }
10565
9240
 
10566
9241
  // src/review/review-deck-mutation.ts
10567
- import { createHash as createHash7, randomUUID } from "crypto";
9242
+ import { createHash as createHash6, randomUUID } from "crypto";
10568
9243
  import fs3 from "fs";
10569
- import path14 from "path";
9244
+ import path13 from "path";
10570
9245
 
10571
9246
  // src/review/index.ts
10572
9247
  import fs from "fs";
10573
- import path12 from "path";
9248
+ import path11 from "path";
10574
9249
  var historicalIdCache = new HistoricalEntityCanonicalIdCache();
10575
9250
  function writeReviewFileCanonicalized(memoryDir, filePath, content) {
10576
- const stateDir = path12.join(memoryDir, "state");
9251
+ const stateDir = path11.join(memoryDir, "state");
10577
9252
  const idsAtWrite = historicalIdCache.get(stateDir);
10578
9253
  let originalBytes = null;
10579
9254
  try {
@@ -10615,8 +9290,8 @@ function realMemoryRoot(memoryDir) {
10615
9290
  }
10616
9291
  }
10617
9292
  function isPathInside(rootReal, candidateReal) {
10618
- const relative2 = path12.relative(rootReal, candidateReal);
10619
- return relative2 === "" || !!relative2 && !relative2.startsWith("..") && !path12.isAbsolute(relative2);
9293
+ const relative2 = path11.relative(rootReal, candidateReal);
9294
+ return relative2 === "" || !!relative2 && !relative2.startsWith("..") && !path11.isAbsolute(relative2);
10620
9295
  }
10621
9296
  function isSafeDirectory(rootReal, dir) {
10622
9297
  try {
@@ -10659,7 +9334,7 @@ function listReviewItems(options) {
10659
9334
  if (filterReason && item.reviewReason !== filterReason) return;
10660
9335
  items.push(item);
10661
9336
  };
10662
- const suggestionsDir = path12.join(memoryDir, "suggestions");
9337
+ const suggestionsDir = path11.join(memoryDir, "suggestions");
10663
9338
  if (!isLimitReached() && fs.existsSync(suggestionsDir) && isSafeDirectory(rootReal, suggestionsDir)) {
10664
9339
  walkMd(rootReal, suggestionsDir, (filePath, content) => {
10665
9340
  if (isLimitReached()) return true;
@@ -10680,7 +9355,7 @@ function listReviewItems(options) {
10680
9355
  return isLimitReached();
10681
9356
  });
10682
9357
  }
10683
- const reviewDir = path12.join(memoryDir, "review");
9358
+ const reviewDir = path11.join(memoryDir, "review");
10684
9359
  if (!isLimitReached() && fs.existsSync(reviewDir) && isSafeDirectory(rootReal, reviewDir)) {
10685
9360
  walkMd(rootReal, reviewDir, (filePath, content) => {
10686
9361
  if (isLimitReached()) return true;
@@ -10705,7 +9380,7 @@ function listReviewItems(options) {
10705
9380
  const categories = ALL_CATEGORY_DIRS;
10706
9381
  for (const category of categories) {
10707
9382
  if (isLimitReached()) break;
10708
- const dir = path12.join(memoryDir, category);
9383
+ const dir = path11.join(memoryDir, category);
10709
9384
  if (!fs.existsSync(dir) || !isSafeDirectory(rootReal, dir)) continue;
10710
9385
  walkMd(rootReal, dir, (filePath, content) => {
10711
9386
  if (isLimitReached()) return true;
@@ -10787,9 +9462,9 @@ function approveItem(memoryDir, itemId, options) {
10787
9462
  const targetDir = getCategoryDir(memoryDir, category);
10788
9463
  const dateDir = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
10789
9464
  ensureSafeDirectory(rootReal, targetDir);
10790
- const outputPath = path12.join(targetDir, dateDir, path12.basename(found.filePath));
10791
- ensureSafeDirectory(rootReal, path12.dirname(outputPath));
10792
- const reviewStateDir = path12.join(memoryDir, "state");
9465
+ const outputPath = path11.join(targetDir, dateDir, path11.basename(found.filePath));
9466
+ ensureSafeDirectory(rootReal, path11.dirname(outputPath));
9467
+ const reviewStateDir = path11.join(memoryDir, "state");
10793
9468
  const idsAtWrite = historicalIdCache.get(reviewStateDir);
10794
9469
  const promotedWritten = canonicalizeEntityRefFrontmatter(updatedContent, idsAtWrite);
10795
9470
  const promotedPath = writeFileWithoutClobber(outputPath, promotedWritten, itemId);
@@ -10866,13 +9541,13 @@ function findReviewFileById(memoryDir, id, options = {}) {
10866
9541
  const rootReal = realMemoryRoot(memoryDir);
10867
9542
  if (!rootReal) return null;
10868
9543
  for (const loc of ["suggestions", "review"]) {
10869
- const dir = path12.join(memoryDir, loc);
9544
+ const dir = path11.join(memoryDir, loc);
10870
9545
  if (!fs.existsSync(dir) || !isSafeDirectory(rootReal, dir)) continue;
10871
9546
  const found = findFileById(rootReal, dir, id);
10872
9547
  if (found) return { filePath: found, location: "queue" };
10873
9548
  }
10874
9549
  for (const category of ALL_CATEGORY_DIRS) {
10875
- const dir = path12.join(memoryDir, category);
9550
+ const dir = path11.join(memoryDir, category);
10876
9551
  if (!fs.existsSync(dir) || !isSafeDirectory(rootReal, dir)) continue;
10877
9552
  const found = findFileById(rootReal, dir, id, (fm) => isLowConfidenceReviewCandidate(fm, options));
10878
9553
  if (found) return { filePath: found, location: "category" };
@@ -10948,10 +9623,10 @@ function readFileSafe(filePath) {
10948
9623
  }
10949
9624
  }
10950
9625
  function writeFileWithoutClobber(basePath, content, discriminator) {
10951
- const parsed = path12.parse(basePath);
9626
+ const parsed = path11.parse(basePath);
10952
9627
  const safeDiscriminator = sanitizeFilePart(discriminator);
10953
9628
  for (let attempt = 0; attempt < 1e3; attempt++) {
10954
- const candidate = attempt === 0 ? basePath : path12.join(
9629
+ const candidate = attempt === 0 ? basePath : path11.join(
10955
9630
  parsed.dir,
10956
9631
  `${parsed.name}-${safeDiscriminator}${attempt === 1 ? "" : `-${attempt}`}${parsed.ext || ".md"}`
10957
9632
  );
@@ -11007,7 +9682,7 @@ function extractBody(content) {
11007
9682
  function walkMd(rootReal, dir, callback) {
11008
9683
  if (!isSafeDirectory(rootReal, dir)) return false;
11009
9684
  for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
11010
- const fullPath = path12.join(dir, entry.name);
9685
+ const fullPath = path11.join(dir, entry.name);
11011
9686
  if (entry.isSymbolicLink()) continue;
11012
9687
  if (entry.isDirectory()) {
11013
9688
  if (walkMd(rootReal, fullPath, callback)) return true;
@@ -11022,7 +9697,7 @@ function walkMdPaths(rootReal, dir) {
11022
9697
  const results = [];
11023
9698
  if (!isSafeDirectory(rootReal, dir)) return results;
11024
9699
  for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
11025
- const fullPath = path12.join(dir, entry.name);
9700
+ const fullPath = path11.join(dir, entry.name);
11026
9701
  if (entry.isSymbolicLink()) continue;
11027
9702
  if (entry.isDirectory()) {
11028
9703
  results.push(...walkMdPaths(rootReal, fullPath));
@@ -11035,7 +9710,7 @@ function walkMdPaths(rootReal, dir) {
11035
9710
 
11036
9711
  // src/review/review-deck-snapshot.ts
11037
9712
  import fs2 from "fs";
11038
- import path13 from "path";
9713
+ import path12 from "path";
11039
9714
  var QUEUE_DIRS = ["suggestions", "review"];
11040
9715
  function readReviewDeckSnapshot(opts) {
11041
9716
  const corpusVersion = readCorpusVersion(opts.memoryDir);
@@ -11043,7 +9718,7 @@ function readReviewDeckSnapshot(opts) {
11043
9718
  if (!rootReal) return { corpusVersion, total: 0, rows: [] };
11044
9719
  const rows = [];
11045
9720
  for (const location of QUEUE_DIRS) {
11046
- const dir = path13.join(opts.memoryDir, location);
9721
+ const dir = path12.join(opts.memoryDir, location);
11047
9722
  if (!fs2.existsSync(dir) || !isSafeDirectory2(rootReal, dir)) continue;
11048
9723
  walkMd2(rootReal, dir, (filePath, content) => {
11049
9724
  const row = rowFromQueueFile(filePath, content, location);
@@ -11056,7 +9731,7 @@ function readReviewDeckRow(opts) {
11056
9731
  const rootReal = realMemoryRoot2(opts.memoryDir);
11057
9732
  if (!rootReal) return null;
11058
9733
  for (const location of QUEUE_DIRS) {
11059
- const dir = path13.join(opts.memoryDir, location);
9734
+ const dir = path12.join(opts.memoryDir, location);
11060
9735
  if (!fs2.existsSync(dir) || !isSafeDirectory2(rootReal, dir)) continue;
11061
9736
  let found = null;
11062
9737
  walkMd2(rootReal, dir, (filePath, content) => {
@@ -11072,7 +9747,7 @@ function readReviewDeckRow(opts) {
11072
9747
  }
11073
9748
  function readCorpusVersion(memoryDir) {
11074
9749
  try {
11075
- return String(fs2.statSync(path13.join(memoryDir, "state", MEMORY_CORPUS_VERSION_SENTINEL)).size);
9750
+ return String(fs2.statSync(path12.join(memoryDir, "state", MEMORY_CORPUS_VERSION_SENTINEL)).size);
11076
9751
  } catch {
11077
9752
  return "0";
11078
9753
  }
@@ -11122,8 +9797,8 @@ function realMemoryRoot2(memoryDir) {
11122
9797
  }
11123
9798
  }
11124
9799
  function isPathInside2(rootReal, candidateReal) {
11125
- const relative2 = path13.relative(rootReal, candidateReal);
11126
- return relative2 === "" || !!relative2 && !relative2.startsWith("..") && !path13.isAbsolute(relative2);
9800
+ const relative2 = path12.relative(rootReal, candidateReal);
9801
+ return relative2 === "" || !!relative2 && !relative2.startsWith("..") && !path12.isAbsolute(relative2);
11127
9802
  }
11128
9803
  function isSafeDirectory2(rootReal, dir) {
11129
9804
  try {
@@ -11137,7 +9812,7 @@ function isSafeDirectory2(rootReal, dir) {
11137
9812
  function walkMd2(rootReal, dir, callback) {
11138
9813
  if (!isSafeDirectory2(rootReal, dir)) return false;
11139
9814
  for (const entry of fs2.readdirSync(dir, { withFileTypes: true })) {
11140
- const fullPath = path13.join(dir, entry.name);
9815
+ const fullPath = path12.join(dir, entry.name);
11141
9816
  if (entry.isSymbolicLink()) continue;
11142
9817
  if (entry.isDirectory()) {
11143
9818
  if (walkMd2(rootReal, fullPath, callback)) return true;
@@ -11222,7 +9897,7 @@ var EVENT_TYPE = {
11222
9897
  undo: "restored"
11223
9898
  };
11224
9899
  function sha256Hex(value) {
11225
- return createHash7("sha256").update(value, "utf8").digest("hex");
9900
+ return createHash6("sha256").update(value, "utf8").digest("hex");
11226
9901
  }
11227
9902
  function computeReceiptId(namespace, principalDigest, idempotencyKey) {
11228
9903
  return `rcp1:${sha256Hex(`${namespace}\0${principalDigest}\0${idempotencyKey}`)}`;
@@ -11252,7 +9927,7 @@ function parseReviewLifecycleReceipt(value) {
11252
9927
  if (!isReceiptAction(rec.action)) return null;
11253
9928
  if (typeof rec.beforeRevision !== "string") return null;
11254
9929
  if (typeof rec.afterRevision !== "string") return null;
11255
- if (!isNonEmptyString(rec.sourcePath) || path14.isAbsolute(rec.sourcePath)) return null;
9930
+ if (!isNonEmptyString(rec.sourcePath) || path13.isAbsolute(rec.sourcePath)) return null;
11256
9931
  if (rec.revisionArtifact !== void 0 && typeof rec.revisionArtifact !== "string") return null;
11257
9932
  if (rec.undoOfReceiptId !== void 0 && typeof rec.undoOfReceiptId !== "string") return null;
11258
9933
  const parsed = {
@@ -11284,11 +9959,11 @@ function findStoredReceipt(events, receiptId) {
11284
9959
  return null;
11285
9960
  }
11286
9961
  function resolveInside(memoryDir, rel) {
11287
- if (!rel || path14.isAbsolute(rel)) return null;
11288
- const root = path14.resolve(memoryDir);
11289
- const abs = path14.resolve(root, rel.split("/").join(path14.sep));
11290
- const next = path14.relative(root, abs);
11291
- if (next.startsWith("..") || path14.isAbsolute(next)) return null;
9962
+ if (!rel || path13.isAbsolute(rel)) return null;
9963
+ const root = path13.resolve(memoryDir);
9964
+ const abs = path13.resolve(root, rel.split("/").join(path13.sep));
9965
+ const next = path13.relative(root, abs);
9966
+ if (next.startsWith("..") || path13.isAbsolute(next)) return null;
11292
9967
  return abs;
11293
9968
  }
11294
9969
  function currentRevision(absPath) {
@@ -11693,7 +10368,7 @@ async function executeReviewDeckUndo(ctx, req) {
11693
10368
 
11694
10369
  // src/review/review-deck-surface.ts
11695
10370
  function digest(value) {
11696
- return createHash8("sha256").update(value).digest("hex");
10371
+ return createHash7("sha256").update(value).digest("hex");
11697
10372
  }
11698
10373
  var ReviewDeckSurface = class {
11699
10374
  constructor(deps) {
@@ -11864,7 +10539,7 @@ function ownerListCards(storedCards) {
11864
10539
  if (replacedDraftIds.has(item.card.cardId)) return false;
11865
10540
  if (!item.replacesDraftId) return true;
11866
10541
  const replacedStatus = byId.get(item.replacesDraftId)?.card.status;
11867
- return replacedStatus === "pending_review" || replacedStatus === "rejected";
10542
+ return replacedStatus === void 0 || replacedStatus === "pending_review" || replacedStatus === "rejected";
11868
10543
  });
11869
10544
  }
11870
10545
 
@@ -11951,14 +10626,14 @@ async function completeSupportPassportReplacementPrior(input) {
11951
10626
  }
11952
10627
 
11953
10628
  // src/support-passport/generated-batch.ts
11954
- import path16 from "path";
10629
+ import path15 from "path";
11955
10630
  import { z as z2 } from "zod";
11956
10631
 
11957
10632
  // src/support-passport/private-file.ts
11958
10633
  import { randomUUID as randomUUID2 } from "crypto";
11959
10634
  import { constants as fsConstants } from "fs";
11960
- import { lstat as lstat3, mkdir as mkdir3, open, rename as rename2, rm as rm2, stat as stat2 } from "fs/promises";
11961
- import path15 from "path";
10635
+ import { lstat as lstat2, mkdir as mkdir3, open, rename as rename2, rm as rm2, stat as stat2 } from "fs/promises";
10636
+ import path14 from "path";
11962
10637
  var UNSUPPORTED_DIRECTORY_SYNC_ERRORS = /* @__PURE__ */ new Set(["EINVAL", "ENOSYS", "ENOTSUP", "EOPNOTSUPP"]);
11963
10638
  var NON_WRITABLE_ANCESTOR_SYNC_ERRORS = /* @__PURE__ */ new Set(["EROFS", "EPERM", "EACCES"]);
11964
10639
  function assertStableDirectory(before, opened, after, errorMessage) {
@@ -11973,7 +10648,7 @@ function assertStableRegularFile(before, opened, after, errorMessage) {
11973
10648
  }
11974
10649
  async function lstatPrivateTarget(filePath, errorMessage) {
11975
10650
  try {
11976
- return await lstat3(filePath);
10651
+ return await lstat2(filePath);
11977
10652
  } catch {
11978
10653
  throw new Error(errorMessage);
11979
10654
  }
@@ -11984,13 +10659,13 @@ function openFlags(...flags) {
11984
10659
  return combined;
11985
10660
  }
11986
10661
  function assertContainedPath(trustedRoot, directory, errorMessage) {
11987
- const relative2 = path15.relative(path15.resolve(trustedRoot), path15.resolve(directory));
11988
- if (relative2 === ".." || relative2.startsWith(`..${path15.sep}`) || path15.isAbsolute(relative2)) {
10662
+ const relative2 = path14.relative(path14.resolve(trustedRoot), path14.resolve(directory));
10663
+ if (relative2 === ".." || relative2.startsWith(`..${path14.sep}`) || path14.isAbsolute(relative2)) {
11989
10664
  throw new Error(errorMessage);
11990
10665
  }
11991
10666
  }
11992
10667
  async function openDirectoryNoFollow(directory, errorMessage) {
11993
- const before = await lstat3(directory);
10668
+ const before = await lstat2(directory);
11994
10669
  if (before.isSymbolicLink() || !before.isDirectory()) throw new Error(errorMessage);
11995
10670
  const handle = await open(
11996
10671
  directory,
@@ -11998,7 +10673,7 @@ async function openDirectoryNoFollow(directory, errorMessage) {
11998
10673
  );
11999
10674
  try {
12000
10675
  const opened = await handle.stat();
12001
- assertStableDirectory(before, opened, await lstat3(directory), errorMessage);
10676
+ assertStableDirectory(before, opened, await lstat2(directory), errorMessage);
12002
10677
  return { before, opened, handle };
12003
10678
  } catch (error) {
12004
10679
  await handle.close().catch(() => void 0);
@@ -12018,7 +10693,7 @@ async function syncDirectoryHandle(handle) {
12018
10693
  }
12019
10694
  async function resolvePrivateDirectoryPath(directory, handle, opened, errorMessage, platform = process.platform) {
12020
10695
  const descriptorRoot = requirePrivateFileDescriptorRoot(platform, errorMessage);
12021
- const pinnedPath = path15.join(descriptorRoot, String(handle.fd));
10696
+ const pinnedPath = path14.join(descriptorRoot, String(handle.fd));
12022
10697
  const metadata = await stat2(pinnedPath);
12023
10698
  if (!metadata.isDirectory() || metadata.dev !== opened.dev || metadata.ino !== opened.ino) {
12024
10699
  throw new Error(errorMessage);
@@ -12034,12 +10709,12 @@ function requirePrivateFileDescriptorRoot(platform, errorMessage) {
12034
10709
  throw new Error(errorMessage);
12035
10710
  }
12036
10711
  async function openStableDirectoryFromRoot(trustedRoot, directory, errorMessage, platform = process.platform) {
12037
- const root = path15.resolve(trustedRoot);
12038
- const target = path15.resolve(directory);
10712
+ const root = path14.resolve(trustedRoot);
10713
+ const target = path14.resolve(directory);
12039
10714
  assertContainedPath(root, target, errorMessage);
12040
10715
  requirePrivateFileDescriptorRoot(platform, errorMessage);
12041
- const relative2 = path15.relative(root, target);
12042
- const components = relative2 === "" ? [] : relative2.split(path15.sep);
10716
+ const relative2 = path14.relative(root, target);
10717
+ const components = relative2 === "" ? [] : relative2.split(path14.sep);
12043
10718
  const handles = [];
12044
10719
  let currentPath = root;
12045
10720
  try {
@@ -12047,13 +10722,13 @@ async function openStableDirectoryFromRoot(trustedRoot, directory, errorMessage,
12047
10722
  handles.push(current.handle);
12048
10723
  for (const component of components) {
12049
10724
  const pinnedParent = await resolvePrivateDirectoryPath(currentPath, current.handle, current.opened, errorMessage);
12050
- const child = await openDirectoryNoFollow(path15.join(pinnedParent, component), errorMessage);
10725
+ const child = await openDirectoryNoFollow(path14.join(pinnedParent, component), errorMessage);
12051
10726
  handles.push(child.handle);
12052
- assertStableDirectory(current.before, current.opened, await lstat3(currentPath), errorMessage);
12053
- currentPath = path15.join(currentPath, component);
10727
+ assertStableDirectory(current.before, current.opened, await lstat2(currentPath), errorMessage);
10728
+ currentPath = path14.join(currentPath, component);
12054
10729
  current = child;
12055
10730
  }
12056
- assertStableDirectory(current.before, current.opened, await lstat3(target), errorMessage);
10731
+ assertStableDirectory(current.before, current.opened, await lstat2(target), errorMessage);
12057
10732
  return {
12058
10733
  ...current,
12059
10734
  handles,
@@ -12071,12 +10746,12 @@ async function openStableDirectoryFromRoot(trustedRoot, directory, errorMessage,
12071
10746
  }
12072
10747
  }
12073
10748
  async function ensurePrivateDirectoryNoFollow(trustedRoot, directory, errorMessage, syncVerifiedParent = syncDirectoryHandle, hardenExistingChildren = true, platform = process.platform) {
12074
- const root = path15.resolve(trustedRoot);
12075
- const target = path15.resolve(directory);
10749
+ const root = path14.resolve(trustedRoot);
10750
+ const target = path14.resolve(directory);
12076
10751
  assertContainedPath(root, target, errorMessage);
12077
- const relative2 = path15.relative(root, target);
10752
+ const relative2 = path14.relative(root, target);
12078
10753
  requirePrivateFileDescriptorRoot(platform, errorMessage);
12079
- const components = relative2 === "" ? [] : relative2.split(path15.sep);
10754
+ const components = relative2 === "" ? [] : relative2.split(path14.sep);
12080
10755
  const handles = [];
12081
10756
  let currentPath = root;
12082
10757
  try {
@@ -12084,7 +10759,7 @@ async function ensurePrivateDirectoryNoFollow(trustedRoot, directory, errorMessa
12084
10759
  handles.push(current.handle);
12085
10760
  for (const component of components) {
12086
10761
  const pinnedParent = await resolvePrivateDirectoryPath(currentPath, current.handle, current.opened, errorMessage);
12087
- const childPath = path15.join(pinnedParent, component);
10762
+ const childPath = path14.join(pinnedParent, component);
12088
10763
  let created = false;
12089
10764
  try {
12090
10765
  await mkdir3(childPath, { mode: 448 });
@@ -12098,18 +10773,18 @@ async function ensurePrivateDirectoryNoFollow(trustedRoot, directory, errorMessa
12098
10773
  if (created || hardenExistingChildren && (child.opened.mode & 511) !== 448) {
12099
10774
  await child.handle.chmod(448);
12100
10775
  }
12101
- assertStableDirectory(current.before, current.opened, await lstat3(currentPath), errorMessage);
12102
- currentPath = path15.join(currentPath, component);
10776
+ assertStableDirectory(current.before, current.opened, await lstat2(currentPath), errorMessage);
10777
+ currentPath = path14.join(currentPath, component);
12103
10778
  current = child;
12104
10779
  }
12105
- assertStableDirectory(current.before, current.opened, await lstat3(target), errorMessage);
10780
+ assertStableDirectory(current.before, current.opened, await lstat2(target), errorMessage);
12106
10781
  } finally {
12107
10782
  await closeDirectoryHandles(handles);
12108
10783
  }
12109
10784
  }
12110
10785
  async function ensurePrivateDirectoryTreeNoFollow(directory, errorMessage, syncVerifiedParent = syncDirectoryHandle, platform = process.platform) {
12111
- const target = path15.resolve(directory);
12112
- const filesystemRoot = path15.parse(target).root;
10786
+ const target = path14.resolve(directory);
10787
+ const filesystemRoot = path14.parse(target).root;
12113
10788
  const rootMetadata = await stat2(filesystemRoot);
12114
10789
  await ensurePrivateDirectoryNoFollow(
12115
10790
  filesystemRoot,
@@ -12137,23 +10812,23 @@ async function withPrivateDirectoryNoFollow(trustedRoot, directory, errorMessage
12137
10812
  const stableDirectory = await openStableDirectoryFromRoot(trustedRoot, directory, errorMessage, platform);
12138
10813
  directoryHandles = stableDirectory.handles;
12139
10814
  const result = await task(stableDirectory.pinnedDirectory);
12140
- assertStableDirectory(stableDirectory.before, stableDirectory.opened, await lstat3(directory), errorMessage);
10815
+ assertStableDirectory(stableDirectory.before, stableDirectory.opened, await lstat2(directory), errorMessage);
12141
10816
  return result;
12142
10817
  } finally {
12143
10818
  await closeDirectoryHandles(directoryHandles);
12144
10819
  }
12145
10820
  }
12146
10821
  async function readPrivateFileNoFollow(directory, filePath, errorMessage, trustedRoot = directory, platform = process.platform) {
12147
- if (path15.dirname(filePath) !== path15.resolve(directory)) throw new Error(errorMessage);
12148
- const targetName = path15.basename(filePath);
10822
+ if (path14.dirname(filePath) !== path14.resolve(directory)) throw new Error(errorMessage);
10823
+ const targetName = path14.basename(filePath);
12149
10824
  let directoryHandles = [];
12150
10825
  let fileHandle;
12151
10826
  try {
12152
10827
  const stableDirectory = await openStableDirectoryFromRoot(trustedRoot, directory, errorMessage, platform);
12153
10828
  directoryHandles = stableDirectory.handles;
12154
10829
  const pinnedDirectory = stableDirectory.pinnedDirectory;
12155
- const targetPath = path15.join(pinnedDirectory, targetName);
12156
- const before = await lstat3(targetPath);
10830
+ const targetPath = path14.join(pinnedDirectory, targetName);
10831
+ const before = await lstat2(targetPath);
12157
10832
  if (before.isSymbolicLink() || !before.isFile()) throw new Error(errorMessage);
12158
10833
  try {
12159
10834
  fileHandle = await open(targetPath, openFlags(fsConstants.O_RDONLY, fsConstants.O_NOFOLLOW));
@@ -12162,8 +10837,8 @@ async function readPrivateFileNoFollow(directory, filePath, errorMessage, truste
12162
10837
  throw error;
12163
10838
  }
12164
10839
  const fileMetadata = await fileHandle.stat();
12165
- assertStableRegularFile(before, fileMetadata, await lstat3(targetPath), errorMessage);
12166
- assertStableDirectory(stableDirectory.before, stableDirectory.opened, await lstat3(directory), errorMessage);
10840
+ assertStableRegularFile(before, fileMetadata, await lstat2(targetPath), errorMessage);
10841
+ assertStableDirectory(stableDirectory.before, stableDirectory.opened, await lstat2(directory), errorMessage);
12167
10842
  return await fileHandle.readFile("utf8");
12168
10843
  } finally {
12169
10844
  await fileHandle?.close().catch(() => void 0);
@@ -12171,10 +10846,10 @@ async function readPrivateFileNoFollow(directory, filePath, errorMessage, truste
12171
10846
  }
12172
10847
  }
12173
10848
  async function appendPrivateFileAtPinnedDirectory(pinnedDirectory, targetName, content, errorMessage, directoryHandle, openFile) {
12174
- if (targetName.length === 0 || targetName === "." || targetName === ".." || path15.basename(targetName) !== targetName) {
10849
+ if (targetName.length === 0 || targetName === "." || targetName === ".." || path14.basename(targetName) !== targetName) {
12175
10850
  throw new Error(errorMessage);
12176
10851
  }
12177
- const targetPath = path15.join(pinnedDirectory, targetName);
10852
+ const targetPath = path14.join(pinnedDirectory, targetName);
12178
10853
  let fileHandle;
12179
10854
  try {
12180
10855
  try {
@@ -12210,8 +10885,8 @@ async function appendPrivateFileAtPinnedDirectory(pinnedDirectory, targetName, c
12210
10885
  }
12211
10886
  async function appendPrivateFileInPinnedDirectory(pinnedDirectory, fileName, content, errorMessage, platform = process.platform) {
12212
10887
  const descriptorRoot = requirePrivateFileDescriptorRoot(platform, errorMessage);
12213
- const resolvedDirectory = path15.resolve(pinnedDirectory);
12214
- const descriptor = path15.relative(descriptorRoot, resolvedDirectory);
10888
+ const resolvedDirectory = path14.resolve(pinnedDirectory);
10889
+ const descriptor = path14.relative(descriptorRoot, resolvedDirectory);
12215
10890
  if (!/^\d+$/.test(descriptor)) throw new Error(errorMessage);
12216
10891
  const before = await stat2(resolvedDirectory);
12217
10892
  if (!before.isDirectory()) throw new Error(errorMessage);
@@ -12227,8 +10902,8 @@ async function appendPrivateFileInPinnedDirectory(pinnedDirectory, fileName, con
12227
10902
  }
12228
10903
  }
12229
10904
  async function writePrivateFileAtomicallyNoFollow(directory, filePath, content, errorMessage, trustedRoot = directory, platform = process.platform, syncVerifiedDirectory = syncDirectoryHandle) {
12230
- if (path15.dirname(filePath) !== path15.resolve(directory)) throw new Error(errorMessage);
12231
- const targetName = path15.basename(filePath);
10905
+ if (path14.dirname(filePath) !== path14.resolve(directory)) throw new Error(errorMessage);
10906
+ const targetName = path14.basename(filePath);
12232
10907
  const tempName = `.${targetName}.${randomUUID2()}.tmp`;
12233
10908
  let tempPath;
12234
10909
  let directoryHandles = [];
@@ -12237,8 +10912,8 @@ async function writePrivateFileAtomicallyNoFollow(directory, filePath, content,
12237
10912
  const stableDirectory = await openStableDirectoryFromRoot(trustedRoot, directory, errorMessage, platform);
12238
10913
  directoryHandles = stableDirectory.handles;
12239
10914
  const pinnedDirectory = stableDirectory.pinnedDirectory;
12240
- tempPath = path15.join(pinnedDirectory, tempName);
12241
- const targetPath = path15.join(pinnedDirectory, targetName);
10915
+ tempPath = path14.join(pinnedDirectory, tempName);
10916
+ const targetPath = path14.join(pinnedDirectory, targetName);
12242
10917
  try {
12243
10918
  fileHandle = await open(
12244
10919
  tempPath,
@@ -12250,15 +10925,15 @@ async function writePrivateFileAtomicallyNoFollow(directory, filePath, content,
12250
10925
  throw error;
12251
10926
  }
12252
10927
  const fileMetadata = await fileHandle.stat();
12253
- const tempMetadata = await lstat3(tempPath);
12254
- assertStableRegularFile(tempMetadata, fileMetadata, await lstat3(tempPath), errorMessage);
12255
- assertStableDirectory(stableDirectory.before, stableDirectory.opened, await lstat3(directory), errorMessage);
10928
+ const tempMetadata = await lstat2(tempPath);
10929
+ assertStableRegularFile(tempMetadata, fileMetadata, await lstat2(tempPath), errorMessage);
10930
+ assertStableDirectory(stableDirectory.before, stableDirectory.opened, await lstat2(directory), errorMessage);
12256
10931
  await fileHandle.chmod(384);
12257
10932
  await fileHandle.writeFile(content, "utf8");
12258
10933
  await fileHandle.sync();
12259
- assertStableDirectory(stableDirectory.before, stableDirectory.opened, await lstat3(directory), errorMessage);
10934
+ assertStableDirectory(stableDirectory.before, stableDirectory.opened, await lstat2(directory), errorMessage);
12260
10935
  await rename2(tempPath, targetPath);
12261
- assertStableDirectory(stableDirectory.before, stableDirectory.opened, await lstat3(directory), errorMessage);
10936
+ assertStableDirectory(stableDirectory.before, stableDirectory.opened, await lstat2(directory), errorMessage);
12262
10937
  if (stableDirectory.handle) await syncVerifiedDirectory(stableDirectory.handle);
12263
10938
  const committedMetadata = await lstatPrivateTarget(targetPath, errorMessage);
12264
10939
  assertStableRegularFile(
@@ -12275,7 +10950,7 @@ async function writePrivateFileAtomicallyNoFollow(directory, filePath, content,
12275
10950
  }
12276
10951
  async function removePrivateFilesNoFollow(directory, fileNames, errorMessage, trustedRoot = directory, platform = process.platform) {
12277
10952
  if (fileNames.some(
12278
- (fileName) => fileName.length === 0 || fileName === "." || fileName === ".." || path15.basename(fileName) !== fileName
10953
+ (fileName) => fileName.length === 0 || fileName === "." || fileName === ".." || path14.basename(fileName) !== fileName
12279
10954
  )) {
12280
10955
  throw new Error(errorMessage);
12281
10956
  }
@@ -12285,9 +10960,9 @@ async function removePrivateFilesNoFollow(directory, fileNames, errorMessage, tr
12285
10960
  directoryHandles = stableDirectory.handles;
12286
10961
  const pinnedDirectory = stableDirectory.pinnedDirectory;
12287
10962
  for (const fileName of fileNames) {
12288
- await rm2(path15.join(pinnedDirectory, fileName), { force: true });
10963
+ await rm2(path14.join(pinnedDirectory, fileName), { force: true });
12289
10964
  }
12290
- assertStableDirectory(stableDirectory.before, stableDirectory.opened, await lstat3(directory), errorMessage);
10965
+ assertStableDirectory(stableDirectory.before, stableDirectory.opened, await lstat2(directory), errorMessage);
12291
10966
  if (stableDirectory.handle) await syncDirectoryHandle(stableDirectory.handle);
12292
10967
  } finally {
12293
10968
  await closeDirectoryHandles(directoryHandles);
@@ -12306,13 +10981,13 @@ var GeneratedBatchMarkerSchema = z2.object({
12306
10981
  }).strict();
12307
10982
  var BATCH_ERROR = "The generated draft batch state is not safe.";
12308
10983
  function batchDirectory(storage) {
12309
- return path16.join(storage.dir, "state", "support-passport", "generated-batches");
10984
+ return path15.join(storage.dir, "state", "support-passport", "generated-batches");
12310
10985
  }
12311
10986
  function batchFileName(batchId) {
12312
10987
  return `${BatchIdSchema.parse(batchId)}.json`;
12313
10988
  }
12314
10989
  function batchPath(storage, batchId) {
12315
- return path16.join(batchDirectory(storage), batchFileName(batchId));
10990
+ return path15.join(batchDirectory(storage), batchFileName(batchId));
12316
10991
  }
12317
10992
  function markerFor(context, batchId, size, complete) {
12318
10993
  return GeneratedBatchMarkerSchema.parse({
@@ -12736,19 +11411,19 @@ var SupportPassportAnswerModelInputSchema = z4.object({
12736
11411
  }).strict();
12737
11412
 
12738
11413
  // src/support-passport/owner-lock.ts
12739
- import { createHash as createHash9 } from "crypto";
12740
- import path17 from "path";
11414
+ import { createHash as createHash8 } from "crypto";
11415
+ import path16 from "path";
12741
11416
  var CARD_MUTATION_LOCK_STALE_MS = 6e4;
12742
11417
  var CARD_MUTATION_LOCK_MAX_WAIT_MS = 3e4;
12743
11418
  function computeSupportPassportOwnerLockKey(namespace, principal) {
12744
- return createHash9("sha256").update(JSON.stringify([namespace, principal])).digest("hex");
11419
+ return createHash8("sha256").update(JSON.stringify([namespace, principal])).digest("hex");
12745
11420
  }
12746
11421
  function supportPassportOwnerLockPath(storage, scope) {
12747
11422
  const ownerLockKey = scope.ownerKey ?? computeSupportPassportOwnerLockKey(scope.namespace, scope.principal);
12748
11423
  if (!/^[a-f0-9]{64}$/.test(ownerLockKey)) {
12749
11424
  throw new SupportPassportError("card_data_invalid", "The support passport owner scope is invalid.", 500);
12750
11425
  }
12751
- return path17.join(storage.dir, "state", `support-passport-cards-${ownerLockKey}.lock`);
11426
+ return path16.join(storage.dir, "state", `support-passport-cards-${ownerLockKey}.lock`);
12752
11427
  }
12753
11428
  async function withSupportPassportOwnerLock(storage, scope, task) {
12754
11429
  const lockPath = supportPassportOwnerLockPath(storage, scope);
@@ -13387,7 +12062,7 @@ var SupportPassportCardService = class {
13387
12062
  if (currentCard.card.status === "pending_review") {
13388
12063
  const priorId = currentMemory.frontmatter.supersedes;
13389
12064
  if (!priorId) return currentMemory;
13390
- const prior = await storage.getMemoryById(priorId);
12065
+ const prior = await storage.getMemoryByIdIncludingArchived(priorId);
13391
12066
  if (prior && ownsMemory(prior, namespace, principal) && prior.frontmatter.status === "superseded" && prior.frontmatter.supersededBy === replacement.card.cardId) {
13392
12067
  await this.restorePriorAfterApprovalFailure(
13393
12068
  storage,
@@ -13488,7 +12163,7 @@ var SupportPassportCardService = class {
13488
12163
  }
13489
12164
  async recoverReplacedDraft(storage, replacement, lock, principal, namespace, onCommitted) {
13490
12165
  if (!replacement.replacesDraftId) return;
13491
- const replacedDraft = await storage.getMemoryById(replacement.replacesDraftId);
12166
+ const replacedDraft = await storage.getMemoryByIdIncludingArchived(replacement.replacesDraftId);
13492
12167
  const projectedDraft = replacedDraft ? projectOwnedCard(replacedDraft, namespace, principal) : null;
13493
12168
  if (replacedDraft && projectedDraft?.card.status === "pending_review" && projectedDraft.card.revision === replacement.replacedRevision) {
13494
12169
  await this.requireOwnerLock(lock);
@@ -13510,7 +12185,7 @@ var SupportPassportCardService = class {
13510
12185
  return;
13511
12186
  }
13512
12187
  }
13513
- const currentDraft = await storage.getMemoryById(replacement.replacesDraftId);
12188
+ const currentDraft = await storage.getMemoryByIdIncludingArchived(replacement.replacesDraftId);
13514
12189
  if (currentDraft && ownsMemory(currentDraft, namespace, principal) && currentDraft.frontmatter.status === "rejected") {
13515
12190
  await this.finishPreparedDraftReplacement(
13516
12191
  storage,
@@ -13644,9 +12319,9 @@ var SupportPassportCardService = class {
13644
12319
  };
13645
12320
 
13646
12321
  // src/support-passport/grant-store.ts
13647
- import { createHash as createHash10, randomBytes, randomUUID as randomUUID4, timingSafeEqual } from "crypto";
13648
- import { lstat as lstat4, open as open2, readdir as readdir4 } from "fs/promises";
13649
- import path18 from "path";
12322
+ import { createHash as createHash9, randomBytes, randomUUID as randomUUID4, timingSafeEqual } from "crypto";
12323
+ import { lstat as lstat3, open as open2, readdir as readdir3 } from "fs/promises";
12324
+ import path17 from "path";
13650
12325
  var GRANT_LOCK_STALE_MS = 3e4;
13651
12326
  var GRANT_LOCK_WAIT_MS = 5e3;
13652
12327
  var GRANT_LOCK_HEARTBEAT_MS = 1e4;
@@ -13669,7 +12344,7 @@ var MalformedGrantStateError = class extends Error {
13669
12344
  }
13670
12345
  };
13671
12346
  function sha256(domain, value) {
13672
- return createHash10("sha256").update(domain).update("\0").update(value).digest("hex");
12347
+ return createHash9("sha256").update(domain).update("\0").update(value).digest("hex");
13673
12348
  }
13674
12349
  function hashesMatch(left, right) {
13675
12350
  const leftBytes = Buffer.from(left, "hex");
@@ -13738,9 +12413,9 @@ var SupportPassportGrantStore = class {
13738
12413
  runWithHeldFileLock;
13739
12414
  syncDirectory;
13740
12415
  constructor(options) {
13741
- this.memoryDir = path18.resolve(expandTildePath(options.memoryDir));
13742
- this.grantsDir = path18.join(this.memoryDir, "state", "support-passport", "grants");
13743
- this.ownerIndexesDir = path18.join(this.grantsDir, "owners");
12416
+ this.memoryDir = path17.resolve(expandTildePath(options.memoryDir));
12417
+ this.grantsDir = path17.join(this.memoryDir, "state", "support-passport", "grants");
12418
+ this.ownerIndexesDir = path17.join(this.grantsDir, "owners");
13744
12419
  this.now = options.now ?? (() => /* @__PURE__ */ new Date());
13745
12420
  this.makeSecret = options.makeSecret ?? (() => randomBytes(32));
13746
12421
  this.makeGrantId = options.makeGrantId ?? randomUUID4;
@@ -13953,11 +12628,11 @@ var SupportPassportGrantStore = class {
13953
12628
  }
13954
12629
  filePath(grantId) {
13955
12630
  const normalizedGrantId = normalizeGrantId(grantId);
13956
- return path18.join(this.grantsDir, `${normalizedGrantId}.json`);
12631
+ return path17.join(this.grantsDir, `${normalizedGrantId}.json`);
13957
12632
  }
13958
12633
  ownerIndexPath(ownerHash) {
13959
12634
  if (!SAFE_OWNER_INDEX_HASH.test(ownerHash)) throw new Error("support passport owner index hash is invalid");
13960
- return path18.join(this.ownerIndexesDir, `${ownerHash}.json`);
12635
+ return path17.join(this.ownerIndexesDir, `${ownerHash}.json`);
13961
12636
  }
13962
12637
  ownerHash(namespace, principalHash) {
13963
12638
  return sha256("support-passport-owner-index:v1", `${namespace}\0${principalHash}`);
@@ -14013,12 +12688,12 @@ var SupportPassportGrantStore = class {
14013
12688
  this.grantsDir,
14014
12689
  grantIds.map((grantId) => `${grantId}.json`),
14015
12690
  "support passport grant files must be regular files in a stable directory",
14016
- path18.parse(this.memoryDir).root
12691
+ path17.parse(this.memoryDir).root
14017
12692
  );
14018
12693
  }
14019
12694
  ownerMembershipDirectory(ownerHash) {
14020
12695
  if (!SAFE_OWNER_INDEX_HASH.test(ownerHash)) throw new Error("support passport owner index hash is invalid");
14021
- return path18.join(this.ownerIndexesDir, ownerHash);
12696
+ return path17.join(this.ownerIndexesDir, ownerHash);
14022
12697
  }
14023
12698
  async ensureOwnerMembershipDirectory(ownerHash) {
14024
12699
  const directory = this.ownerMembershipDirectory(ownerHash);
@@ -14033,11 +12708,11 @@ var SupportPassportGrantStore = class {
14033
12708
  const directory = await this.ensureOwnerMembershipDirectory(ownerHash);
14034
12709
  await writePrivateFileAtomicallyNoFollow(
14035
12710
  directory,
14036
- path18.join(directory, `${state.grantId}.json`),
12711
+ path17.join(directory, `${state.grantId}.json`),
14037
12712
  `${JSON.stringify({ schemaVersion: 1, grantId: state.grantId })}
14038
12713
  `,
14039
12714
  "support passport owner membership must be regular files in a stable directory",
14040
- path18.parse(this.memoryDir).root
12715
+ path17.parse(this.memoryDir).root
14041
12716
  );
14042
12717
  }
14043
12718
  async removeOwnerMembership(state) {
@@ -14047,7 +12722,7 @@ var SupportPassportGrantStore = class {
14047
12722
  directory,
14048
12723
  [`${state.grantId}.json`],
14049
12724
  "support passport owner membership must be regular files in a stable directory",
14050
- path18.parse(this.memoryDir).root
12725
+ path17.parse(this.memoryDir).root
14051
12726
  );
14052
12727
  }
14053
12728
  async removeStoredGrant(state) {
@@ -14148,11 +12823,11 @@ var SupportPassportGrantStore = class {
14148
12823
  const ownerHash = this.ownerHash(namespace, principalHash);
14149
12824
  const directory = await this.ensureOwnerMembershipDirectory(ownerHash);
14150
12825
  const grantIds = await withPrivateDirectoryNoFollow(
14151
- path18.parse(this.memoryDir).root,
12826
+ path17.parse(this.memoryDir).root,
14152
12827
  directory,
14153
12828
  "support passport owner membership must be regular files in a stable directory",
14154
12829
  async (pinnedDirectory) => {
14155
- const entries = await readdir4(pinnedDirectory, { withFileTypes: true });
12830
+ const entries = await readdir3(pinnedDirectory, { withFileTypes: true });
14156
12831
  return entries.filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -5)).filter((grantId) => SAFE_GRANT_ID.test(grantId));
14157
12832
  }
14158
12833
  );
@@ -14179,7 +12854,7 @@ var SupportPassportGrantStore = class {
14179
12854
  this.ownerIndexesDir,
14180
12855
  filePath,
14181
12856
  "support passport owner indexes must be regular files in a stable directory",
14182
- path18.parse(this.memoryDir).root
12857
+ path17.parse(this.memoryDir).root
14183
12858
  );
14184
12859
  } catch (error) {
14185
12860
  if (error.code === "ENOENT") return [];
@@ -14206,7 +12881,7 @@ var SupportPassportGrantStore = class {
14206
12881
  async writeOwnerIndex(ownerHash, grantIds) {
14207
12882
  const filePath = this.ownerIndexPath(ownerHash);
14208
12883
  try {
14209
- const metadata = await lstat4(filePath);
12884
+ const metadata = await lstat3(filePath);
14210
12885
  if (metadata.isSymbolicLink() || !metadata.isFile()) {
14211
12886
  throw new Error("support passport owner indexes must be regular files");
14212
12887
  }
@@ -14219,7 +12894,7 @@ var SupportPassportGrantStore = class {
14219
12894
  `${JSON.stringify({ schemaVersion: 1, ownerHash, grantIds }, null, 2)}
14220
12895
  `,
14221
12896
  "support passport owner indexes must be regular files in a stable directory",
14222
- path18.parse(this.memoryDir).root
12897
+ path17.parse(this.memoryDir).root
14223
12898
  );
14224
12899
  }
14225
12900
  async readState(grantId) {
@@ -14229,7 +12904,7 @@ var SupportPassportGrantStore = class {
14229
12904
  this.grantsDir,
14230
12905
  filePath,
14231
12906
  "support passport grant files must be regular files in a stable directory",
14232
- path18.parse(this.memoryDir).root
12907
+ path17.parse(this.memoryDir).root
14233
12908
  );
14234
12909
  try {
14235
12910
  const state = SupportPassportGrantStateSchema.parse(JSON.parse(content));
@@ -14248,7 +12923,7 @@ var SupportPassportGrantStore = class {
14248
12923
  async writeState(state, requireAbsent = false) {
14249
12924
  const filePath = this.filePath(state.grantId);
14250
12925
  try {
14251
- const metadata = await lstat4(filePath);
12926
+ const metadata = await lstat3(filePath);
14252
12927
  if (metadata.isSymbolicLink() || !metadata.isFile())
14253
12928
  throw new Error("support passport grant files must be regular files");
14254
12929
  if (requireAbsent) {
@@ -14263,7 +12938,7 @@ var SupportPassportGrantStore = class {
14263
12938
  `${JSON.stringify(state, null, 2)}
14264
12939
  `,
14265
12940
  "support passport grant files must be regular files in a stable directory",
14266
- path18.parse(this.memoryDir).root
12941
+ path17.parse(this.memoryDir).root
14267
12942
  );
14268
12943
  }
14269
12944
  async ensureSafeDirectories() {
@@ -14297,8 +12972,8 @@ var SupportPassportGrantStore = class {
14297
12972
  void 0
14298
12973
  );
14299
12974
  this.memoryDir = configuredMemoryDir;
14300
- this.grantsDir = path18.join(configuredMemoryDir, "state", "support-passport", "grants");
14301
- this.ownerIndexesDir = path18.join(this.grantsDir, "owners");
12975
+ this.grantsDir = path17.join(configuredMemoryDir, "state", "support-passport", "grants");
12976
+ this.ownerIndexesDir = path17.join(this.grantsDir, "owners");
14302
12977
  })();
14303
12978
  }
14304
12979
  const currentAttempt = this.memoryRootReady;
@@ -14312,12 +12987,12 @@ var SupportPassportGrantStore = class {
14312
12987
  async withMutationLock(task) {
14313
12988
  await this.ensureSafeDirectories();
14314
12989
  return await withPrivateDirectoryNoFollow(
14315
- path18.parse(this.memoryDir).root,
12990
+ path17.parse(this.memoryDir).root,
14316
12991
  this.grantsDir,
14317
12992
  "support passport grant lock directory must remain inside the memory directory",
14318
12993
  async (pinnedDirectory) => await this.withExclusiveLock(
14319
12994
  `support-passport-grants:${this.grantsDir}`,
14320
- path18.join(pinnedDirectory, ".grants.lock"),
12995
+ path17.join(pinnedDirectory, ".grants.lock"),
14321
12996
  task
14322
12997
  )
14323
12998
  );
@@ -14326,12 +13001,12 @@ var SupportPassportGrantStore = class {
14326
13001
  const normalizedGrantId = normalizeGrantId(grantId);
14327
13002
  await this.ensureSafeDirectories();
14328
13003
  return await withPrivateDirectoryNoFollow(
14329
- path18.parse(this.memoryDir).root,
13004
+ path17.parse(this.memoryDir).root,
14330
13005
  this.grantsDir,
14331
13006
  "support passport grant lock directory must remain inside the memory directory",
14332
13007
  async (pinnedDirectory) => await this.withExclusiveLock(
14333
13008
  `support-passport-grant:${this.grantsDir}:${normalizedGrantId}`,
14334
- path18.join(pinnedDirectory, `.${normalizedGrantId}.lock`),
13009
+ path17.join(pinnedDirectory, `.${normalizedGrantId}.lock`),
14335
13010
  task
14336
13011
  )
14337
13012
  );
@@ -14339,12 +13014,12 @@ var SupportPassportGrantStore = class {
14339
13014
  async withOwnerIndexLock(ownerHash, task) {
14340
13015
  await this.ensureSafeDirectories();
14341
13016
  return await withPrivateDirectoryNoFollow(
14342
- path18.parse(this.memoryDir).root,
13017
+ path17.parse(this.memoryDir).root,
14343
13018
  this.ownerIndexesDir,
14344
13019
  "support passport owner lock directory must remain inside the memory directory",
14345
13020
  async (pinnedDirectory) => await this.withExclusiveLock(
14346
13021
  `support-passport-owner:${this.ownerIndexesDir}:${ownerHash}`,
14347
- path18.join(pinnedDirectory, `.${ownerHash}.lock`),
13022
+ path17.join(pinnedDirectory, `.${ownerHash}.lock`),
14348
13023
  task
14349
13024
  )
14350
13025
  );
@@ -15181,8 +13856,8 @@ var SupportPassportModelAdapter = class {
15181
13856
  };
15182
13857
 
15183
13858
  // src/support-passport/model-audit.ts
15184
- import { createHash as createHash11 } from "crypto";
15185
- import path19 from "path";
13859
+ import { createHash as createHash10 } from "crypto";
13860
+ import path18 from "path";
15186
13861
  import { z as z5 } from "zod";
15187
13862
  var HashSchema = z5.string().regex(/^[a-f0-9]{64}$/);
15188
13863
  var SupportPassportModelAuditRecordSchema = z5.object({
@@ -15219,7 +13894,7 @@ var SupportPassportModelAuditRecordSchema = z5.object({
15219
13894
  }
15220
13895
  });
15221
13896
  function hashSupportPassportAuditValues(domain, values) {
15222
- return createHash11("sha256").update(`support-passport-audit:${domain}:v1`).update("\0").update([...values].sort().join("\0")).digest("hex");
13897
+ return createHash10("sha256").update(`support-passport-audit:${domain}:v1`).update("\0").update([...values].sort().join("\0")).digest("hex");
15223
13898
  }
15224
13899
  var SupportPassportModelAuditStore = class {
15225
13900
  memoryDir;
@@ -15227,15 +13902,15 @@ var SupportPassportModelAuditStore = class {
15227
13902
  memoryRootReady;
15228
13903
  runWithHeldFileLock;
15229
13904
  constructor(options) {
15230
- this.memoryDir = path19.resolve(expandTildePath(options.memoryDir));
15231
- this.auditDir = path19.join(this.memoryDir, "state", "support-passport", "audit");
13905
+ this.memoryDir = path18.resolve(expandTildePath(options.memoryDir));
13906
+ this.auditDir = path18.join(this.memoryDir, "state", "support-passport", "audit");
15232
13907
  this.runWithHeldFileLock = options.withHeldFileLock ?? withHeldFileLock;
15233
13908
  }
15234
13909
  async record(input) {
15235
13910
  const record = SupportPassportModelAuditRecordSchema.parse(input);
15236
13911
  await this.ensureSafeDirectories();
15237
13912
  const day = record.occurredAt.slice(0, 10);
15238
- const filePath = path19.join(this.auditDir, `${day}.jsonl`);
13913
+ const filePath = path18.join(this.auditDir, `${day}.jsonl`);
15239
13914
  await serializeMutations(
15240
13915
  `support-passport-audit:${filePath}`,
15241
13916
  () => withPrivateDirectoryNoFollow(
@@ -15243,7 +13918,7 @@ var SupportPassportModelAuditStore = class {
15243
13918
  this.auditDir,
15244
13919
  "support passport audit directory must remain inside the memory directory",
15245
13920
  async (pinnedDirectory) => await this.runWithHeldFileLock(
15246
- path19.join(pinnedDirectory, `.${day}.lock`),
13921
+ path18.join(pinnedDirectory, `.${day}.lock`),
15247
13922
  {
15248
13923
  staleMs: 3e4,
15249
13924
  maxWaitMs: 5e3,
@@ -15280,7 +13955,7 @@ var SupportPassportModelAuditStore = class {
15280
13955
  "support passport memory directory must be a stable directory"
15281
13956
  );
15282
13957
  this.memoryDir = configuredMemoryDir;
15283
- this.auditDir = path19.join(configuredMemoryDir, "state", "support-passport", "audit");
13958
+ this.auditDir = path18.join(configuredMemoryDir, "state", "support-passport", "audit");
15284
13959
  })();
15285
13960
  }
15286
13961
  const currentAttempt = this.memoryRootReady;
@@ -15294,7 +13969,7 @@ var SupportPassportModelAuditStore = class {
15294
13969
  };
15295
13970
 
15296
13971
  // src/support-passport/model-service.ts
15297
- import { createHash as createHash12 } from "crypto";
13972
+ import { createHash as createHash11 } from "crypto";
15298
13973
  import { z as z6 } from "zod";
15299
13974
  var DraftServiceInputSchema = z6.object({
15300
13975
  principal: z6.string().trim().min(1).max(512),
@@ -15330,7 +14005,7 @@ function supportPassportSourceContent(memory) {
15330
14005
  return hasStructuredAttributes(memory.frontmatter.structuredAttributes) ? stripAttributesSuffix(memory.content) : memory.content;
15331
14006
  }
15332
14007
  function computeSupportPassportSourceRevision(content, structuredAttributes) {
15333
- return createHash12("sha256").update("support-passport-source:v1\0").update(hasStructuredAttributes(structuredAttributes) ? stripAttributesSuffix(content) : content).digest("hex");
14008
+ return createHash11("sha256").update("support-passport-source:v1\0").update(hasStructuredAttributes(structuredAttributes) ? stripAttributesSuffix(content) : content).digest("hex");
15334
14009
  }
15335
14010
  function isSupportPassportSourceEligible(memory) {
15336
14011
  const status = memory.frontmatter.status ?? "active";
@@ -18827,8 +17502,8 @@ var EngramAccessService = class extends SupportPassportAccessServiceBase {
18827
17502
  async offlineSyncSnapshot(options = {}) {
18828
17503
  const resolvedNamespace = this.resolveReadableNamespace(options.namespace, options.principal);
18829
17504
  const storage = await offlineSyncStorageForSnapshot(this.orchestrator, resolvedNamespace);
18830
- const storageHash = createHash13("sha256").update(storage.dir).digest("hex").slice(0, 16);
18831
- const deletions = [...await storage.readDeletionRevisions()].map(([path20, mtimeMs]) => ({ path: path20, mtimeMs }));
17505
+ const storageHash = createHash12("sha256").update(storage.dir).digest("hex").slice(0, 16);
17506
+ const deletions = [...await storage.readDeletionRevisions()].map(([path19, mtimeMs]) => ({ path: path19, mtimeMs }));
18832
17507
  const snapshotBuilder = options.includeContent === false && options.baseFiles && options.baseFiles.length > 0 ? buildOfflineSyncSnapshotFromBase : buildOfflineSyncSnapshot;
18833
17508
  const snapshot = await snapshotBuilder({
18834
17509
  root: storage.dir,
@@ -18851,10 +17526,10 @@ var EngramAccessService = class extends SupportPassportAccessServiceBase {
18851
17526
  async offlineSyncSnapshotStream(options = {}) {
18852
17527
  const resolvedNamespace = this.resolveReadableNamespace(options.namespace, options.principal);
18853
17528
  const storage = await offlineSyncStorageForSnapshot(this.orchestrator, resolvedNamespace);
18854
- const storageHash = createHash13("sha256").update(storage.dir).digest("hex").slice(0, 16);
17529
+ const storageHash = createHash12("sha256").update(storage.dir).digest("hex").slice(0, 16);
18855
17530
  const deletions = await filterOfflineSyncDeletionRevisions({
18856
17531
  root: storage.dir,
18857
- deletions: [...await storage.readDeletionRevisions()].map(([path20, mtimeMs]) => ({ path: path20, mtimeMs })),
17532
+ deletions: [...await storage.readDeletionRevisions()].map(([path19, mtimeMs]) => ({ path: path19, mtimeMs })),
18858
17533
  includeTranscripts: options.includeTranscripts !== false,
18859
17534
  userExcludeRegexps: this.offlineSyncUserExcludes
18860
17535
  });
@@ -18891,7 +17566,7 @@ var EngramAccessService = class extends SupportPassportAccessServiceBase {
18891
17566
  async offlineSyncFiles(options) {
18892
17567
  const resolvedNamespace = this.resolveReadableNamespace(options.namespace, options.principal);
18893
17568
  const storage = await offlineSyncStorageForSnapshot(this.orchestrator, resolvedNamespace);
18894
- const storageHash = createHash13("sha256").update(storage.dir).digest("hex").slice(0, 16);
17569
+ const storageHash = createHash12("sha256").update(storage.dir).digest("hex").slice(0, 16);
18895
17570
  try {
18896
17571
  const snapshot = await buildOfflineSyncSnapshotForPaths({
18897
17572
  root: storage.dir,
@@ -19476,6 +18151,11 @@ export {
19476
18151
  CorrectionContractError,
19477
18152
  detectPassiveCorrections,
19478
18153
  capturePassiveCorrections,
18154
+ JOURNAL_DIR_NAME,
18155
+ journalPath,
18156
+ isJournalDayPath,
18157
+ todayJournalDate,
18158
+ seedJournal,
19479
18159
  isTopLevelArchivePath,
19480
18160
  isGenericRecallExcludedPath,
19481
18161
  filterRecallCandidates,
@@ -19567,4 +18247,4 @@ export {
19567
18247
  EngramAccessService,
19568
18248
  AccessAdminOpsSurface
19569
18249
  };
19570
- //# sourceMappingURL=chunk-OXRRJXPR.js.map
18250
+ //# sourceMappingURL=chunk-MUEGIKKY.js.map