@remnic/core 9.65.7 → 9.66.0

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 (713) hide show
  1. package/dist/access-admin-ops-surface.d.ts +15 -14
  2. package/dist/access-admin-ops-surface.js +65 -62
  3. package/dist/access-authorization-probe.d.ts +15 -14
  4. package/dist/access-authorization-probe.js +66 -63
  5. package/dist/access-boundary.d.ts +15 -14
  6. package/dist/access-boundary.js +65 -62
  7. package/dist/access-citation-namespace.js +3 -3
  8. package/dist/access-cli.js +182 -174
  9. package/dist/access-cli.js.map +1 -1
  10. package/dist/access-coding-context-resolution.d.ts +2 -2
  11. package/dist/access-coding-context-resolution.js +2 -2
  12. package/dist/access-extraction-force-flush.d.ts +15 -14
  13. package/dist/access-extraction-force-flush.js +65 -62
  14. package/dist/access-health-types.d.ts +2 -2
  15. package/dist/access-http-lcm-compaction.d.ts +15 -14
  16. package/dist/access-http-lifecycle-flush.d.ts +15 -14
  17. package/dist/access-http-offline-stream.d.ts +15 -14
  18. package/dist/access-http-query.d.ts +3 -3
  19. package/dist/access-http-query.js +67 -64
  20. package/dist/access-http.d.ts +16 -15
  21. package/dist/access-http.js +87 -84
  22. package/dist/access-identity-continuity-surface.d.ts +13 -12
  23. package/dist/access-identity-continuity-surface.js +65 -62
  24. package/dist/access-lcm-surface.d.ts +15 -14
  25. package/dist/access-lcm-surface.js +65 -62
  26. package/dist/access-mcp-output-schemas.js +1 -1
  27. package/dist/access-mcp.d.ts +15 -14
  28. package/dist/access-mcp.js +77 -74
  29. package/dist/access-memory-search-fanout.d.ts +3 -3
  30. package/dist/{access-namespace-preflight-8VYKmRX0.d.ts → access-namespace-preflight-CLWUoMyW.d.ts} +1 -1
  31. package/dist/access-namespace-preflight.d.ts +4 -4
  32. package/dist/access-namespace-preflight.js +65 -62
  33. package/dist/access-observe-write-surface.d.ts +15 -14
  34. package/dist/access-observe-write-surface.js +65 -62
  35. package/dist/access-offline-manifest.d.ts +13 -12
  36. package/dist/access-offline-manifest.js +16 -16
  37. package/dist/access-operations-batch.js +69 -66
  38. package/dist/access-operations.d.ts +16 -15
  39. package/dist/access-operations.js +74 -71
  40. package/dist/access-recall-concurrency.d.ts +15 -14
  41. package/dist/access-recall-concurrency.js +65 -62
  42. package/dist/access-recall-response.d.ts +15 -14
  43. package/dist/access-recall-response.js +65 -62
  44. package/dist/access-recall-surface.d.ts +15 -14
  45. package/dist/access-recall-surface.js +65 -62
  46. package/dist/access-schema.js +7 -7
  47. package/dist/{access-service-Crk__Git.d.ts → access-service-CEUE1Isj.d.ts} +14 -14
  48. package/dist/access-service-helpers.d.ts +15 -14
  49. package/dist/access-service.d.ts +15 -14
  50. package/dist/access-service.js +65 -62
  51. package/dist/access-surface-catalog.d.ts +15 -14
  52. package/dist/access-surface-catalog.js +69 -64
  53. package/dist/access-surface-catalog.js.map +1 -1
  54. package/dist/access-wearables-meetings-surface.d.ts +6 -4
  55. package/dist/action-confidence.d.ts +2 -2
  56. package/dist/active-context-config.d.ts +27 -0
  57. package/dist/active-context-config.js +14 -0
  58. package/dist/active-context-transform.d.ts +267 -0
  59. package/dist/active-context-transform.js +31 -0
  60. package/dist/active-memory-bridge.d.ts +2 -2
  61. package/dist/active-memory-bridge.js +2 -2
  62. package/dist/active-recall.d.ts +2 -2
  63. package/dist/active-recall.js +17 -16
  64. package/dist/active-recall.js.map +1 -1
  65. package/dist/adapters/index.js +7 -7
  66. package/dist/adapters/registry.js +3 -3
  67. package/dist/ambient-provenance.d.ts +2 -2
  68. package/dist/artifact-search.d.ts +2 -2
  69. package/dist/{auto-sync-XVMLL2RH.js → auto-sync-Q6Q2FVSC.js} +10 -10
  70. package/dist/behavior-learner.d.ts +2 -2
  71. package/dist/behavior-signals.d.ts +2 -2
  72. package/dist/bootstrap.d.ts +13 -12
  73. package/dist/briefing-window.d.ts +5 -3
  74. package/dist/briefing.d.ts +5 -3
  75. package/dist/briefing.js +33 -33
  76. package/dist/buffer-surprise-report.d.ts +2 -2
  77. package/dist/buffer-turn-helpers.d.ts +2 -2
  78. package/dist/buffer.d.ts +5 -3
  79. package/dist/buffer.js +24 -8
  80. package/dist/bulk-import/index.d.ts +4 -4
  81. package/dist/calibration.d.ts +2 -2
  82. package/dist/calibration.js +1 -1
  83. package/dist/capabilities.d.ts +2 -2
  84. package/dist/{capsule-merge-SGIVB3WA.js → capsule-merge-SEHERWWP.js} +4 -4
  85. package/dist/{catalog-DybwVNW3.d.ts → catalog-D1HgugTA.d.ts} +1 -1
  86. package/dist/causal-behavior.d.ts +4 -4
  87. package/dist/causal-consolidation.d.ts +2 -2
  88. package/dist/causal-consolidation.js +34 -34
  89. package/dist/causal-trajectory-graph.d.ts +2 -2
  90. package/dist/{chunk-CFGU52XJ.js → chunk-23CVL7HS.js} +2 -2
  91. package/dist/{chunk-PO7NXBG2.js → chunk-2GF27PGH.js} +5 -5
  92. package/dist/{chunk-6CPUQ5D6.js → chunk-2LBAFHOQ.js} +15 -15
  93. package/dist/{chunk-JBPKEARU.js → chunk-2QSZNTDO.js} +7 -7
  94. package/dist/{chunk-IP4ZNT4U.js → chunk-33MFRY25.js} +2 -2
  95. package/dist/{chunk-VFYRYFLL.js → chunk-3TSU662L.js} +3 -3
  96. package/dist/chunk-43HUVDTD.js +114 -0
  97. package/dist/chunk-43HUVDTD.js.map +1 -0
  98. package/dist/{chunk-VXVZ2GM3.js → chunk-4FHRZD5T.js} +2 -2
  99. package/dist/{chunk-FP7YTTVO.js → chunk-4OFKZAJG.js} +2 -1
  100. package/dist/chunk-4OFKZAJG.js.map +1 -0
  101. package/dist/{chunk-5VPQSRQO.js → chunk-4STAANV7.js} +3 -3
  102. package/dist/{chunk-46WM6JX2.js → chunk-4ZWCQJNM.js} +5 -5
  103. package/dist/{chunk-LLQCM2U2.js → chunk-56IV4J5W.js} +617 -167
  104. package/dist/chunk-56IV4J5W.js.map +1 -0
  105. package/dist/{chunk-52II7PB6.js → chunk-645WOU5I.js} +4 -4
  106. package/dist/{chunk-YKWFK7XA.js → chunk-6CEGSTBD.js} +7 -7
  107. package/dist/{chunk-I7EX6KSH.js → chunk-6QDXA26G.js} +264 -210
  108. package/dist/chunk-6QDXA26G.js.map +1 -0
  109. package/dist/{chunk-GEPACVWN.js → chunk-6RUHELWR.js} +3 -3
  110. package/dist/{chunk-ZAOHJDKH.js → chunk-72OIT7KS.js} +4 -4
  111. package/dist/{chunk-KQAFEZQX.js → chunk-7LCGFUMB.js} +4 -4
  112. package/dist/{chunk-7TCGNUVP.js → chunk-7UTDHQZ5.js} +3 -3
  113. package/dist/{chunk-5HK3CJAR.js → chunk-7XOG75AU.js} +3 -3
  114. package/dist/{chunk-7BDZTALN.js → chunk-AJTG3CP7.js} +12 -2
  115. package/dist/chunk-AJTG3CP7.js.map +1 -0
  116. package/dist/{chunk-2LWQSV6A.js → chunk-AL3UYZ5N.js} +3 -2
  117. package/dist/chunk-AL3UYZ5N.js.map +1 -0
  118. package/dist/chunk-B32WYRXX.js +77 -0
  119. package/dist/chunk-B32WYRXX.js.map +1 -0
  120. package/dist/{chunk-C24UZSFW.js → chunk-CEH2AFXG.js} +6 -6
  121. package/dist/{chunk-YOXVZJFM.js → chunk-CFVTRUR3.js} +2 -2
  122. package/dist/{chunk-ACOC27BB.js → chunk-CN4VKV3S.js} +2 -2
  123. package/dist/{chunk-PMVPCZJZ.js → chunk-CTCGHNWN.js} +6 -6
  124. package/dist/{chunk-EGBDFJ36.js → chunk-DD5JFCWM.js} +2 -2
  125. package/dist/{chunk-T42L3S6A.js → chunk-DDX6KIXF.js} +2 -2
  126. package/dist/{chunk-JIYDRBVZ.js → chunk-DJORULH3.js} +2 -2
  127. package/dist/{chunk-WTOZBZNN.js → chunk-DMEHOEC7.js} +6 -6
  128. package/dist/{chunk-OPPBTPUU.js → chunk-DUAJKRR2.js} +4 -4
  129. package/dist/{chunk-XDL5CYZN.js → chunk-EEOUMG3J.js} +2 -1
  130. package/dist/{chunk-XDL5CYZN.js.map → chunk-EEOUMG3J.js.map} +1 -1
  131. package/dist/{chunk-SVVIASVX.js → chunk-EFQCDJZ2.js} +7 -7
  132. package/dist/{chunk-Q57GOHLF.js → chunk-EGALNSZ4.js} +3 -3
  133. package/dist/{chunk-KCT36JAW.js → chunk-ESNFSSO4.js} +2 -2
  134. package/dist/{chunk-XQ3HXAQH.js → chunk-ET2CNMLD.js} +4 -4
  135. package/dist/{chunk-Z4U3UN56.js → chunk-EZSCW4EM.js} +6 -6
  136. package/dist/{chunk-F6QHHRWP.js → chunk-FESUGFIL.js} +3 -3
  137. package/dist/{chunk-S3K2CIK5.js → chunk-FKKGCGYL.js} +3 -3
  138. package/dist/{chunk-BWGCOLEL.js → chunk-FTTJRVB7.js} +2 -2
  139. package/dist/{chunk-JAQXUGLN.js → chunk-FYWLSFFS.js} +2 -2
  140. package/dist/{chunk-BJTHRFFC.js → chunk-GEJKYA7D.js} +77 -36
  141. package/dist/chunk-GEJKYA7D.js.map +1 -0
  142. package/dist/chunk-GSKINLAK.js +267 -0
  143. package/dist/chunk-GSKINLAK.js.map +1 -0
  144. package/dist/{chunk-OPGL46PX.js → chunk-GX6FTSYH.js} +2 -2
  145. package/dist/{chunk-A32YEQAM.js → chunk-H7VDIF2V.js} +2 -2
  146. package/dist/{chunk-PDDSFELN.js → chunk-HJXA6ZM7.js} +2 -2
  147. package/dist/{chunk-RGCF4XNH.js → chunk-HNPE66LB.js} +8 -8
  148. package/dist/{chunk-SEA6M7SS.js → chunk-I5VB44ZK.js} +2 -2
  149. package/dist/{chunk-SDEPLF7V.js → chunk-IBJ6U753.js} +2 -2
  150. package/dist/{chunk-EUYWQ7TS.js → chunk-IEZ6CGTW.js} +2 -2
  151. package/dist/{chunk-RQE4TITU.js → chunk-IHGMRDEE.js} +431 -1834
  152. package/dist/chunk-IHGMRDEE.js.map +1 -0
  153. package/dist/{chunk-3RI5Y7KU.js → chunk-IVIAHQBR.js} +2 -2
  154. package/dist/{chunk-7WR462EM.js → chunk-J3OND5QT.js} +4 -4
  155. package/dist/{chunk-UW5NPZJ2.js → chunk-JALOAKSZ.js} +59 -7
  156. package/dist/chunk-JALOAKSZ.js.map +1 -0
  157. package/dist/{chunk-T3JQTCCO.js → chunk-JI7U6AS3.js} +4 -4
  158. package/dist/{chunk-DVYRD4HY.js → chunk-JRRQ747T.js} +36 -7
  159. package/dist/chunk-JRRQ747T.js.map +1 -0
  160. package/dist/{chunk-I32NKXE2.js → chunk-JTWZKNUH.js} +5 -5
  161. package/dist/chunk-K66OY4EI.js +202 -0
  162. package/dist/chunk-K66OY4EI.js.map +1 -0
  163. package/dist/{chunk-XAB6STPO.js → chunk-KODXCHXJ.js} +17 -3
  164. package/dist/chunk-KODXCHXJ.js.map +1 -0
  165. package/dist/{chunk-ZPUIRTIZ.js → chunk-KOLJJN5G.js} +12 -75
  166. package/dist/chunk-KOLJJN5G.js.map +1 -0
  167. package/dist/{chunk-FMQ4MOQO.js → chunk-KXIXO76C.js} +32 -19
  168. package/dist/chunk-KXIXO76C.js.map +1 -0
  169. package/dist/{chunk-VKCAHCBI.js → chunk-L4X4PJYK.js} +2 -2
  170. package/dist/chunk-LB7WCZHY.js +553 -0
  171. package/dist/chunk-LB7WCZHY.js.map +1 -0
  172. package/dist/{chunk-W4BMEGQA.js → chunk-LUDBXTBJ.js} +8 -8
  173. package/dist/{chunk-I4343FIA.js → chunk-MAH64N55.js} +28 -10
  174. package/dist/chunk-MAH64N55.js.map +1 -0
  175. package/dist/{chunk-RIAM7DND.js → chunk-ME35HVDJ.js} +2 -2
  176. package/dist/{chunk-H63EDPFJ.js → chunk-MI2OTWV5.js} +15 -2
  177. package/dist/{chunk-H63EDPFJ.js.map → chunk-MI2OTWV5.js.map} +1 -1
  178. package/dist/{chunk-LBFFNDFM.js → chunk-MINHJ55X.js} +1 -1
  179. package/dist/chunk-MINHJ55X.js.map +1 -0
  180. package/dist/{chunk-NG3MBQV4.js → chunk-MJRGVXPQ.js} +2 -2
  181. package/dist/{chunk-773TRRGT.js → chunk-MJUCDM3C.js} +2 -2
  182. package/dist/{chunk-7F27PCSN.js → chunk-MN5NOOI7.js} +2 -2
  183. package/dist/{chunk-JCWY73FK.js → chunk-N4F7ZSSG.js} +2 -2
  184. package/dist/{chunk-TR7DGXGI.js → chunk-NACLNNFQ.js} +5 -5
  185. package/dist/{chunk-LC2BDILZ.js → chunk-NBP4EX5N.js} +2 -2
  186. package/dist/{chunk-ZVPVTPGI.js → chunk-NNZFPYYX.js} +4 -4
  187. package/dist/{chunk-MFOSZUIT.js → chunk-NPIBN2VL.js} +2 -2
  188. package/dist/{chunk-IY7UXD3J.js → chunk-O57GM3FR.js} +2 -2
  189. package/dist/{chunk-I2HTKOOP.js → chunk-O7ERGZDA.js} +5 -5
  190. package/dist/{chunk-GTSVEEP3.js → chunk-OAJMQKQR.js} +3 -3
  191. package/dist/{chunk-HSZMX3ZJ.js → chunk-ODW5GDFE.js} +2 -2
  192. package/dist/{chunk-D4QVPP3G.js → chunk-PEBH5DCK.js} +18 -11
  193. package/dist/chunk-PEBH5DCK.js.map +1 -0
  194. package/dist/{chunk-J2WC5LF4.js → chunk-QBC33MPY.js} +2 -1
  195. package/dist/{chunk-EOHKUWXW.js → chunk-QCRJMU5V.js} +2 -2
  196. package/dist/chunk-QJCWK2A7.js +1466 -0
  197. package/dist/chunk-QJCWK2A7.js.map +1 -0
  198. package/dist/{chunk-THG4GYIE.js → chunk-RDGKVH6T.js} +11 -7
  199. package/dist/{chunk-THG4GYIE.js.map → chunk-RDGKVH6T.js.map} +1 -1
  200. package/dist/{chunk-5DH6PG4B.js → chunk-RZ3IZIJG.js} +3 -3
  201. package/dist/{chunk-AAXJNINV.js → chunk-SN4JXNLL.js} +2 -2
  202. package/dist/chunk-TB2MJRI6.js +866 -0
  203. package/dist/chunk-TB2MJRI6.js.map +1 -0
  204. package/dist/{chunk-7PHI6GUI.js → chunk-TEZ2HTC7.js} +42 -2
  205. package/dist/chunk-TEZ2HTC7.js.map +1 -0
  206. package/dist/{chunk-SVSRPG6M.js → chunk-TNGH4ZYI.js} +2 -2
  207. package/dist/{chunk-HZNYJN77.js → chunk-TNXNECAN.js} +6 -6
  208. package/dist/{chunk-JOEJG4SD.js → chunk-TVW4C7PV.js} +5 -5
  209. package/dist/{chunk-UFKPQBXH.js → chunk-U62OK7BB.js} +2 -2
  210. package/dist/{chunk-R2MZCYA6.js → chunk-UNUMFURP.js} +3 -3
  211. package/dist/{chunk-AX7UXCHJ.js → chunk-UYA36DQ7.js} +2 -1
  212. package/dist/chunk-UYA36DQ7.js.map +1 -0
  213. package/dist/{chunk-AFR6AIM4.js → chunk-VCKWULAK.js} +112 -87
  214. package/dist/chunk-VCKWULAK.js.map +1 -0
  215. package/dist/chunk-VOSWUO3K.js +100 -0
  216. package/dist/chunk-VOSWUO3K.js.map +1 -0
  217. package/dist/{chunk-YRVAKONL.js → chunk-VQ4AMTGZ.js} +1 -1
  218. package/dist/{chunk-3BCULS4U.js → chunk-VQNRICAQ.js} +145 -507
  219. package/dist/chunk-VQNRICAQ.js.map +1 -0
  220. package/dist/{chunk-RAIUTAZZ.js → chunk-WKAXBXVA.js} +2 -2
  221. package/dist/{chunk-ZIJDI4CP.js → chunk-WKJFIMVN.js} +2 -2
  222. package/dist/{chunk-SXIMQLGV.js → chunk-WVGXCBOC.js} +2 -2
  223. package/dist/{chunk-7BEPVIH3.js → chunk-X5YYSAZX.js} +4 -4
  224. package/dist/{chunk-FZEEWOI2.js → chunk-XJJYSX6F.js} +2 -2
  225. package/dist/{chunk-F635GAL7.js → chunk-XKNHFDTT.js} +33 -13
  226. package/dist/chunk-XKNHFDTT.js.map +1 -0
  227. package/dist/{chunk-UG6VXIOK.js → chunk-XSTNGNJP.js} +2 -2
  228. package/dist/{chunk-YDPAE2RD.js → chunk-YFLLGRXO.js} +2 -2
  229. package/dist/{chunk-EZ25VE3G.js → chunk-YNDLCWXS.js} +4 -4
  230. package/dist/{chunk-ANJXPFRS.js → chunk-YXFCALVT.js} +14 -14
  231. package/dist/{chunk-Q4WONDMJ.js → chunk-YYGZJPOK.js} +2 -2
  232. package/dist/{chunk-5HERQ5FX.js → chunk-Z3YEGSR4.js} +10 -10
  233. package/dist/{chunk-YWSQD2IB.js → chunk-ZJPM7GZ3.js} +2 -2
  234. package/dist/{chunk-5S4LQOPE.js → chunk-ZW4VXELZ.js} +2 -2
  235. package/dist/{cli-B322UMvB.d.ts → cli-BEkm2MEf.d.ts} +5 -5
  236. package/dist/cli.d.ts +17 -16
  237. package/dist/cli.js +126 -120
  238. package/dist/coding/export-okf-codegraph.d.ts +56 -0
  239. package/dist/coding/export-okf-codegraph.js +526 -0
  240. package/dist/coding/export-okf-codegraph.js.map +1 -0
  241. package/dist/coding/pre-action-gate.d.ts +2 -2
  242. package/dist/compounding/engine.d.ts +5 -3
  243. package/dist/compounding/engine.js +34 -34
  244. package/dist/compounding/preference-consolidator.d.ts +4 -4
  245. package/dist/compression-optimizer.d.ts +2 -2
  246. package/dist/config-security.js +2 -2
  247. package/dist/config.d.ts +2 -2
  248. package/dist/config.js +17 -16
  249. package/dist/connectors/codex-materialize-runner.d.ts +2 -2
  250. package/dist/connectors/codex-materialize-runner.js +33 -33
  251. package/dist/connectors/codex-materialize.d.ts +2 -2
  252. package/dist/connectors/index.d.ts +2 -2
  253. package/dist/connectors/index.js +33 -33
  254. package/dist/consolidation-provenance-check.d.ts +5 -3
  255. package/dist/consolidation-provenance-check.js +5 -5
  256. package/dist/consolidation-undo.d.ts +5 -3
  257. package/dist/consolidation-undo.js +3 -3
  258. package/dist/context-summary.d.ts +43 -0
  259. package/dist/context-summary.js +14 -0
  260. package/dist/context-summary.js.map +1 -0
  261. package/dist/contradiction/index.d.ts +6 -4
  262. package/dist/contradiction/index.js +10 -10
  263. package/dist/{contradiction-scan-AKUWPX5N.js → contradiction-scan-NOYMFG66.js} +3 -3
  264. package/dist/contradiction-scan-NOYMFG66.js.map +1 -0
  265. package/dist/converge-config.d.ts +2 -2
  266. package/dist/convergence-refresh.d.ts +5 -3
  267. package/dist/convergence-refresh.js +36 -36
  268. package/dist/conversation-index/backend.d.ts +2 -2
  269. package/dist/conversation-index/chunker.d.ts +2 -2
  270. package/dist/conversation-index/faiss-adapter.d.ts +2 -2
  271. package/dist/conversation-index/indexer.d.ts +2 -2
  272. package/dist/conversation-index/search.d.ts +2 -2
  273. package/dist/corpus-watermark.d.ts +2 -2
  274. package/dist/corpus-watermark.js +35 -35
  275. package/dist/cross-lingual-recall.d.ts +2 -2
  276. package/dist/dashboard-runtime.js +2 -2
  277. package/dist/day-summary.d.ts +2 -2
  278. package/dist/delinearize.d.ts +2 -2
  279. package/dist/dependency-propagation-config.d.ts +2 -2
  280. package/dist/{dependency-propagation-delivery-BGcNairQ.d.ts → dependency-propagation-delivery-BCpeo14F.d.ts} +1 -1
  281. package/dist/direct-answer-wiring.d.ts +2 -2
  282. package/dist/direct-answer.d.ts +2 -2
  283. package/dist/embedding-fallback.d.ts +2 -2
  284. package/dist/enrichment/index.d.ts +2 -2
  285. package/dist/entity-origin-fields.d.ts +2 -2
  286. package/dist/entity-retrieval.d.ts +5 -3
  287. package/dist/entity-retrieval.js +34 -34
  288. package/dist/entity-schema.d.ts +2 -2
  289. package/dist/episodic-context.d.ts +2 -2
  290. package/dist/eval-trajectory-contracts.d.ts +2 -2
  291. package/dist/eval-trajectory-store.d.ts +2 -2
  292. package/dist/eval-trajectory.d.ts +2 -2
  293. package/dist/event-order-recall.js +3 -3
  294. package/dist/explicit-capture.d.ts +13 -12
  295. package/dist/explicit-capture.js +12 -12
  296. package/dist/external-wiki-access.d.ts +15 -14
  297. package/dist/external-wiki-access.js +66 -63
  298. package/dist/external-wiki-collection-registration.d.ts +2 -2
  299. package/dist/external-wiki-collection.d.ts +2 -2
  300. package/dist/external-wiki-mcp-tools.d.ts +15 -14
  301. package/dist/extraction-error-classification.d.ts +2 -2
  302. package/dist/extraction-faithfulness.d.ts +2 -2
  303. package/dist/extraction-faithfulness.js +2 -2
  304. package/dist/extraction-judge-telemetry.d.ts +2 -2
  305. package/dist/extraction-judge-training.d.ts +2 -2
  306. package/dist/extraction-judge.d.ts +2 -2
  307. package/dist/extraction-judge.js +2 -2
  308. package/dist/extraction-liveness.d.ts +2 -2
  309. package/dist/extraction-normalization.d.ts +2 -2
  310. package/dist/extraction-prompt.d.ts +2 -2
  311. package/dist/extraction-source-grounding-rules.d.ts +2 -2
  312. package/dist/extraction-source-grounding.d.ts +2 -2
  313. package/dist/extraction.d.ts +2 -2
  314. package/dist/extraction.js +47 -44
  315. package/dist/fallback-llm.d.ts +8 -2
  316. package/dist/fallback-llm.js +1 -1
  317. package/dist/{first-start-migration-4NETATFF.js → first-start-migration-KHIMCBIC.js} +3 -3
  318. package/dist/{forget-SZ2BXDGF.js → forget-2AE4MDK3.js} +3 -3
  319. package/dist/graph-dashboard-diff.d.ts +2 -2
  320. package/dist/graph-dashboard-key.d.ts +2 -2
  321. package/dist/graph-dashboard-parser.d.ts +2 -2
  322. package/dist/graph-edge-reinforcement.d.ts +2 -2
  323. package/dist/graph-path-reconstruction.d.ts +2 -2
  324. package/dist/graph-path-scoring.d.ts +2 -2
  325. package/dist/graph-snapshot.d.ts +2 -2
  326. package/dist/graph.d.ts +2 -2
  327. package/dist/harmonic-retrieval.js +1 -1
  328. package/dist/importance.d.ts +2 -2
  329. package/dist/importers/index.d.ts +2 -2
  330. package/dist/in-flight-reads.d.ts +2 -2
  331. package/dist/{index-By2QUAMh.d.ts → index-D_pyMUaP.d.ts} +2 -2
  332. package/dist/index.d.ts +261 -30
  333. package/dist/index.js +321 -257
  334. package/dist/intent.d.ts +2 -2
  335. package/dist/lcm/engine.d.ts +3 -3
  336. package/dist/lcm/engine.js +5 -4
  337. package/dist/lcm/index.d.ts +4 -3
  338. package/dist/lcm/index.js +12 -11
  339. package/dist/lcm/summarizer.d.ts +4 -6
  340. package/dist/lcm/summarizer.js +2 -1
  341. package/dist/lcm/tools.d.ts +4 -4
  342. package/dist/lifecycle.d.ts +2 -2
  343. package/dist/live-connectors-runner.d.ts +2 -2
  344. package/dist/local-llm.d.ts +2 -2
  345. package/dist/local-model-endpoint.d.ts +2 -2
  346. package/dist/location/index.d.ts +315 -6
  347. package/dist/location/index.js +151 -19
  348. package/dist/maintenance/memory-governance.d.ts +2 -2
  349. package/dist/maintenance/memory-governance.js +34 -34
  350. package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +5 -3
  351. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +33 -33
  352. package/dist/maintenance/rebuild-memory-projection.d.ts +5 -3
  353. package/dist/maintenance/rebuild-memory-projection.js +35 -35
  354. package/dist/{maintenance-Dm2McrIx.d.ts → maintenance-DDUX9d6D.d.ts} +3 -3
  355. package/dist/mcp-memory-inspector-app.d.ts +15 -14
  356. package/dist/mcp-read-only-tools.js +1 -1
  357. package/dist/memory-action-policy.d.ts +18 -3
  358. package/dist/memory-action-policy.js +3 -1
  359. package/dist/memory-cache.d.ts +2 -2
  360. package/dist/memory-controller.d.ts +2 -2
  361. package/dist/memory-controller.js +2 -2
  362. package/dist/memory-lifecycle-ledger-utils.d.ts +2 -2
  363. package/dist/memory-projection-mutations.js +3 -3
  364. package/dist/memory-projection-store.d.ts +2 -2
  365. package/dist/memory-projection-store.js +1 -1
  366. package/dist/memory-provenance.d.ts +2 -2
  367. package/dist/memory-snapshot.d.ts +2 -2
  368. package/dist/memory-subject-cli.d.ts +15 -14
  369. package/dist/memory-subject.d.ts +15 -14
  370. package/dist/memory-subject.js +5 -5
  371. package/dist/memory-worth-outcomes.d.ts +5 -3
  372. package/dist/models-json.d.ts +2 -2
  373. package/dist/namespaces/migrate.d.ts +6 -4
  374. package/dist/namespaces/migrate.js +34 -34
  375. package/dist/namespaces/principal.d.ts +2 -2
  376. package/dist/namespaces/search.d.ts +2 -2
  377. package/dist/namespaces/search.js +8 -8
  378. package/dist/namespaces/storage.d.ts +6 -4
  379. package/dist/namespaces/storage.js +33 -33
  380. package/dist/native-knowledge.d.ts +2 -2
  381. package/dist/offline-sync-file-io.js +3 -3
  382. package/dist/offline-sync-impression-drain.d.ts +2 -2
  383. package/dist/offline-sync-impression-drain.js +9 -9
  384. package/dist/offline-sync.js +4 -4
  385. package/dist/operator-doctor-corpus.d.ts +2 -2
  386. package/dist/operator-doctor-corpus.js +36 -36
  387. package/dist/operator-doctor-replica.d.ts +2 -2
  388. package/dist/operator-toolkit.d.ts +6 -4
  389. package/dist/operator-toolkit.js +56 -55
  390. package/dist/orchestration/compression-guideline-coordinator.d.ts +5 -3
  391. package/dist/orchestration/maintenance.d.ts +7 -5
  392. package/dist/orchestration/maintenance.js +48 -47
  393. package/dist/{orchestrator-Co1DyfuP.d.ts → orchestrator-3F4jihCo.d.ts} +8 -8
  394. package/dist/orchestrator.d.ts +13 -12
  395. package/dist/orchestrator.js +182 -174
  396. package/dist/page-versioning.js +3 -3
  397. package/dist/patterns-cli.d.ts +2 -2
  398. package/dist/{pipeline-DotMnb6y.d.ts → pipeline-CB1dj6Uh.d.ts} +1 -1
  399. package/dist/policy-runtime.d.ts +2 -2
  400. package/dist/proactive-contention.d.ts +2 -2
  401. package/dist/provenance.d.ts +2 -2
  402. package/dist/{public-http-PJRtnSi-.d.ts → public-http-34-JIAGQ.d.ts} +1 -1
  403. package/dist/{purge-GB7PZHT2.js → purge-OP6BEDFY.js} +2 -2
  404. package/dist/{qmd-BP0n11fR.d.ts → qmd-edLLZXc5.d.ts} +1 -1
  405. package/dist/qmd-preflight.d.ts +3 -3
  406. package/dist/qmd-recall-cache.d.ts +2 -2
  407. package/dist/qmd.d.ts +3 -3
  408. package/dist/qmd.js +4 -4
  409. package/dist/recall-concurrency-config.d.ts +2 -2
  410. package/dist/recall-disclosure-escalation.d.ts +2 -2
  411. package/dist/recall-explain-renderer.d.ts +2 -2
  412. package/dist/recall-explain-renderer.js +3 -3
  413. package/dist/recall-memory-map.d.ts +2 -2
  414. package/dist/recall-planner-llm.d.ts +2 -2
  415. package/dist/recall-planner-llm.js +1 -1
  416. package/dist/recall-state.d.ts +2 -2
  417. package/dist/recall-tag-filter.d.ts +2 -2
  418. package/dist/recall-timings.d.ts +2 -2
  419. package/dist/recall-xray-cli.d.ts +2 -2
  420. package/dist/recall-xray-cli.js +4 -4
  421. package/dist/recall-xray-renderer.d.ts +2 -2
  422. package/dist/recall-xray-renderer.js +3 -3
  423. package/dist/recall-xray.d.ts +2 -2
  424. package/dist/recall-xray.js +2 -2
  425. package/dist/reconcile/cursor.d.ts +2 -2
  426. package/dist/reconcile/manifest.d.ts +2 -2
  427. package/dist/reconcile/manifest.js +5 -5
  428. package/dist/reconcile/plan.d.ts +2 -2
  429. package/dist/replay/normalizers/chatgpt.d.ts +2 -2
  430. package/dist/replay/normalizers/claude.d.ts +2 -2
  431. package/dist/replay/normalizers/openclaw.d.ts +2 -2
  432. package/dist/replay/normalizers/shared.d.ts +2 -2
  433. package/dist/replay/runner.d.ts +2 -2
  434. package/dist/replay/types.d.ts +2 -2
  435. package/dist/replica-divergence.d.ts +2 -2
  436. package/dist/replica-peers-config.d.ts +2 -2
  437. package/dist/{resolution-4552BNRV.js → resolution-4DLI3IOR.js} +11 -11
  438. package/dist/resolution-4DLI3IOR.js.map +1 -0
  439. package/dist/resolve-auth-token.d.ts +2 -2
  440. package/dist/resume-bundles.js +18 -17
  441. package/dist/retrieval-agents.d.ts +3 -3
  442. package/dist/retrieval-tiers.d.ts +2 -2
  443. package/dist/routing/engine.d.ts +2 -2
  444. package/dist/routing/store.d.ts +2 -2
  445. package/dist/salvage-envelope.d.ts +2 -2
  446. package/dist/salvage-envelope.js +7 -7
  447. package/dist/schemas.d.ts +572 -107
  448. package/dist/schemas.js +3 -1
  449. package/dist/{scope-profiles-6ChZKTy-.d.ts → scope-profiles-BF2lu81V.d.ts} +1 -1
  450. package/dist/search/document-scanner.js +1 -1
  451. package/dist/search/embed-helper.d.ts +2 -2
  452. package/dist/search/factory.d.ts +2 -2
  453. package/dist/search/factory.js +7 -7
  454. package/dist/search/index.d.ts +2 -2
  455. package/dist/search/index.js +13 -13
  456. package/dist/search/lancedb-backend.d.ts +2 -2
  457. package/dist/search/lancedb-backend.js +1 -1
  458. package/dist/search/meilisearch-backend.d.ts +2 -2
  459. package/dist/search/meilisearch-backend.js +1 -1
  460. package/dist/search/noop-backend.d.ts +2 -2
  461. package/dist/search/orama-backend.d.ts +2 -2
  462. package/dist/search/orama-backend.js +1 -1
  463. package/dist/search/port.d.ts +2 -2
  464. package/dist/search/remote-backend.d.ts +2 -2
  465. package/dist/secure-store/index.js +3 -3
  466. package/dist/{semantic-consolidation-DziYcW5J.d.ts → semantic-consolidation-5OuWXBRt.d.ts} +1 -1
  467. package/dist/semantic-consolidation.d.ts +3 -3
  468. package/dist/semantic-consolidation.js +37 -37
  469. package/dist/semantic-rule-promotion.js +33 -33
  470. package/dist/semantic-rule-verifier.d.ts +2 -2
  471. package/dist/semantic-rule-verifier.js +33 -33
  472. package/dist/{service-C7rIBuK_.d.ts → service-CrqEhLXD.d.ts} +2 -2
  473. package/dist/session-observer-bands.d.ts +2 -2
  474. package/dist/session-observer-state.d.ts +2 -2
  475. package/dist/shared-context/manager.d.ts +2 -2
  476. package/dist/signal.d.ts +2 -2
  477. package/dist/source-agent-qualifier.d.ts +2 -2
  478. package/dist/source-agent-qualifier.js +42 -39
  479. package/dist/standup/build.d.ts +16 -0
  480. package/dist/standup/build.js +17 -0
  481. package/dist/standup/build.js.map +1 -0
  482. package/dist/{storage-B1hEx8Xg.d.ts → storage-BQn-xnxm.d.ts} +4 -1
  483. package/dist/storage.d.ts +5 -3
  484. package/dist/storage.js +32 -32
  485. package/dist/subject-config.d.ts +2 -2
  486. package/dist/subject-config.js +6 -6
  487. package/dist/summarizer.d.ts +2 -2
  488. package/dist/summarizer.js +2 -2
  489. package/dist/summary-snapshot.d.ts +2 -2
  490. package/dist/support-passport/index.d.ts +20 -19
  491. package/dist/support-passport/index.js +68 -65
  492. package/dist/temporal-supersession.d.ts +3 -3
  493. package/dist/temporal-timeline-recall.d.ts +2 -2
  494. package/dist/temporal-validity.d.ts +2 -2
  495. package/dist/threading.d.ts +2 -2
  496. package/dist/tier-migration.d.ts +5 -3
  497. package/dist/tier-routing.d.ts +2 -2
  498. package/dist/tier-routing.js +2 -2
  499. package/dist/{tier-stats-4B5IJ3NE.js → tier-stats-2TOW3QNL.js} +3 -3
  500. package/dist/topics.d.ts +2 -2
  501. package/dist/transcript.d.ts +2 -2
  502. package/dist/transfer/capsule-export.js +2 -2
  503. package/dist/transfer/capsule-import.js +5 -5
  504. package/dist/transfer/export-okf.d.ts +39 -0
  505. package/dist/transfer/export-okf.js +112 -0
  506. package/dist/transfer/export-okf.js.map +1 -0
  507. package/dist/transfer/types.d.ts +12 -12
  508. package/dist/trust-score-stage.d.ts +2 -2
  509. package/dist/trust-score.d.ts +2 -2
  510. package/dist/{types-BHDNxGTT.d.ts → types-BRpcNjHZ.d.ts} +119 -3
  511. package/dist/types.d.ts +2 -2
  512. package/dist/types.js +1 -1
  513. package/dist/utility-runtime.d.ts +2 -2
  514. package/dist/verified-recall.js +33 -33
  515. package/dist/who-knows-cli.d.ts +15 -14
  516. package/dist/who-knows-cli.js +34 -34
  517. package/dist/who-knows.d.ts +15 -14
  518. package/dist/who-knows.js +33 -33
  519. package/dist/write-envelope.d.ts +2 -2
  520. package/dist/write-envelope.js +6 -6
  521. package/package.json +54 -3
  522. package/src/access-admin-ops-surface.ts +6 -1
  523. package/src/access-boundary.ts +1 -0
  524. package/src/access-http.ts +3 -1
  525. package/src/access-mcp-output-schemas.ts +1 -0
  526. package/src/access-mcp.ts +3 -3
  527. package/src/access-operations.ts +1 -0
  528. package/src/access-service-offline-file-content.test.ts +63 -0
  529. package/src/access-surface-catalog.ts +2 -0
  530. package/src/active-context-config.ts +98 -0
  531. package/src/active-context-transform.test.ts +533 -0
  532. package/src/active-context-transform.ts +981 -0
  533. package/src/activity/config.test.ts +1 -0
  534. package/src/activity/config.ts +21 -1
  535. package/src/activity/index.ts +1 -0
  536. package/src/activity/timeline/build.ts +279 -0
  537. package/src/activity/timeline/categories.ts +111 -0
  538. package/src/activity/timeline/classify.ts +110 -0
  539. package/src/activity/timeline/corrections.ts +145 -0
  540. package/src/activity/timeline/index.ts +6 -0
  541. package/src/activity/timeline/timeline.test.ts +277 -0
  542. package/src/activity/timeline/types.ts +106 -0
  543. package/src/activity/types.ts +6 -0
  544. package/src/cli/okf-commands.ts +45 -0
  545. package/src/cli.ts +2 -2
  546. package/src/coding/export-okf-codegraph.test.ts +381 -0
  547. package/src/coding/export-okf-codegraph.ts +565 -0
  548. package/src/config.test.ts +1 -0
  549. package/src/config.ts +3 -5
  550. package/src/context-summary.ts +182 -0
  551. package/src/extraction-prompt-safety.test.ts +14 -2
  552. package/src/extraction.ts +21 -1
  553. package/src/fallback-llm.test.ts +134 -0
  554. package/src/fallback-llm.ts +77 -5
  555. package/src/index.ts +4 -11
  556. package/src/lcm/summarizer.ts +14 -93
  557. package/src/location/access-operations.ts +17 -8
  558. package/src/location/backfill.ts +137 -0
  559. package/src/location/config.test.ts +3 -0
  560. package/src/location/config.ts +46 -2
  561. package/src/location/http-glue.ts +1 -1
  562. package/src/location/index.ts +3 -0
  563. package/src/location/intervals.ts +1 -0
  564. package/src/location/matching.test.ts +65 -0
  565. package/src/location/matching.ts +354 -0
  566. package/src/location/mcp-tools.ts +2 -1
  567. package/src/location/surfaces.test.ts +15 -2
  568. package/src/location/surfaces.ts +95 -18
  569. package/src/location/tagging.test.ts +119 -0
  570. package/src/location/tagging.ts +277 -0
  571. package/src/location/types.ts +23 -1
  572. package/src/mcp-read-only-tools.ts +1 -0
  573. package/src/memory-action-policy.ts +28 -0
  574. package/src/memory-projection-store.ts +3 -1
  575. package/src/okf/cli.ts +18 -5
  576. package/src/okf/config.ts +5 -0
  577. package/src/okf/index-files.test.ts +60 -0
  578. package/src/okf/index-files.ts +114 -0
  579. package/src/okf/render.ts +133 -0
  580. package/src/okf/type-mapping.test.ts +3 -0
  581. package/src/okf/type-mapping.ts +2 -0
  582. package/src/orchestration/extraction-run.ts +2 -1
  583. package/src/orchestration/generic-recall-paths.ts +4 -3
  584. package/src/schemas.ts +17 -1
  585. package/src/standup/access-operations.ts +14 -0
  586. package/src/standup/build.test.ts +34 -0
  587. package/src/standup/build.ts +115 -0
  588. package/src/standup/http-glue.ts +15 -0
  589. package/src/standup/mcp-tools.ts +16 -0
  590. package/src/storage/context-transform-ledger.ts +39 -0
  591. package/src/storage/secure-line-reader.ts +50 -1
  592. package/src/storage.ts +4 -1
  593. package/src/support-passport/card-projection.ts +1 -0
  594. package/src/support-passport/card-service-commit-forwarding.test.ts +1 -0
  595. package/src/support-passport/card-service.test.ts +75 -1
  596. package/src/support-passport/card-service.ts +6 -3
  597. package/src/support-passport/card-state.ts +5 -1
  598. package/src/support-passport/offline-sync-guard.ts +14 -1
  599. package/src/transfer/export-okf.test.ts +164 -0
  600. package/src/transfer/export-okf.ts +286 -0
  601. package/src/types.ts +2 -3
  602. package/dist/chunk-2LWQSV6A.js.map +0 -1
  603. package/dist/chunk-3BCULS4U.js.map +0 -1
  604. package/dist/chunk-7BDZTALN.js.map +0 -1
  605. package/dist/chunk-7PHI6GUI.js.map +0 -1
  606. package/dist/chunk-AFR6AIM4.js.map +0 -1
  607. package/dist/chunk-AX7UXCHJ.js.map +0 -1
  608. package/dist/chunk-BJTHRFFC.js.map +0 -1
  609. package/dist/chunk-D4QVPP3G.js.map +0 -1
  610. package/dist/chunk-DVYRD4HY.js.map +0 -1
  611. package/dist/chunk-F635GAL7.js.map +0 -1
  612. package/dist/chunk-FMQ4MOQO.js.map +0 -1
  613. package/dist/chunk-FP7YTTVO.js.map +0 -1
  614. package/dist/chunk-I4343FIA.js.map +0 -1
  615. package/dist/chunk-I7EX6KSH.js.map +0 -1
  616. package/dist/chunk-LBFFNDFM.js.map +0 -1
  617. package/dist/chunk-LLQCM2U2.js.map +0 -1
  618. package/dist/chunk-RQE4TITU.js.map +0 -1
  619. package/dist/chunk-UW5NPZJ2.js.map +0 -1
  620. package/dist/chunk-XAB6STPO.js.map +0 -1
  621. package/dist/chunk-ZPUIRTIZ.js.map +0 -1
  622. package/dist/types-CM86alG1.d.ts +0 -89
  623. /package/dist/{contradiction-scan-AKUWPX5N.js.map → active-context-config.js.map} +0 -0
  624. /package/dist/{resolution-4552BNRV.js.map → active-context-transform.js.map} +0 -0
  625. /package/dist/{auto-sync-XVMLL2RH.js.map → auto-sync-Q6Q2FVSC.js.map} +0 -0
  626. /package/dist/{capsule-merge-SGIVB3WA.js.map → capsule-merge-SEHERWWP.js.map} +0 -0
  627. /package/dist/{chunk-CFGU52XJ.js.map → chunk-23CVL7HS.js.map} +0 -0
  628. /package/dist/{chunk-PO7NXBG2.js.map → chunk-2GF27PGH.js.map} +0 -0
  629. /package/dist/{chunk-6CPUQ5D6.js.map → chunk-2LBAFHOQ.js.map} +0 -0
  630. /package/dist/{chunk-JBPKEARU.js.map → chunk-2QSZNTDO.js.map} +0 -0
  631. /package/dist/{chunk-IP4ZNT4U.js.map → chunk-33MFRY25.js.map} +0 -0
  632. /package/dist/{chunk-VFYRYFLL.js.map → chunk-3TSU662L.js.map} +0 -0
  633. /package/dist/{chunk-VXVZ2GM3.js.map → chunk-4FHRZD5T.js.map} +0 -0
  634. /package/dist/{chunk-5VPQSRQO.js.map → chunk-4STAANV7.js.map} +0 -0
  635. /package/dist/{chunk-46WM6JX2.js.map → chunk-4ZWCQJNM.js.map} +0 -0
  636. /package/dist/{chunk-52II7PB6.js.map → chunk-645WOU5I.js.map} +0 -0
  637. /package/dist/{chunk-YKWFK7XA.js.map → chunk-6CEGSTBD.js.map} +0 -0
  638. /package/dist/{chunk-GEPACVWN.js.map → chunk-6RUHELWR.js.map} +0 -0
  639. /package/dist/{chunk-ZAOHJDKH.js.map → chunk-72OIT7KS.js.map} +0 -0
  640. /package/dist/{chunk-KQAFEZQX.js.map → chunk-7LCGFUMB.js.map} +0 -0
  641. /package/dist/{chunk-7TCGNUVP.js.map → chunk-7UTDHQZ5.js.map} +0 -0
  642. /package/dist/{chunk-5HK3CJAR.js.map → chunk-7XOG75AU.js.map} +0 -0
  643. /package/dist/{chunk-C24UZSFW.js.map → chunk-CEH2AFXG.js.map} +0 -0
  644. /package/dist/{chunk-YOXVZJFM.js.map → chunk-CFVTRUR3.js.map} +0 -0
  645. /package/dist/{chunk-ACOC27BB.js.map → chunk-CN4VKV3S.js.map} +0 -0
  646. /package/dist/{chunk-PMVPCZJZ.js.map → chunk-CTCGHNWN.js.map} +0 -0
  647. /package/dist/{chunk-EGBDFJ36.js.map → chunk-DD5JFCWM.js.map} +0 -0
  648. /package/dist/{chunk-T42L3S6A.js.map → chunk-DDX6KIXF.js.map} +0 -0
  649. /package/dist/{chunk-JIYDRBVZ.js.map → chunk-DJORULH3.js.map} +0 -0
  650. /package/dist/{chunk-WTOZBZNN.js.map → chunk-DMEHOEC7.js.map} +0 -0
  651. /package/dist/{chunk-OPPBTPUU.js.map → chunk-DUAJKRR2.js.map} +0 -0
  652. /package/dist/{chunk-SVVIASVX.js.map → chunk-EFQCDJZ2.js.map} +0 -0
  653. /package/dist/{chunk-Q57GOHLF.js.map → chunk-EGALNSZ4.js.map} +0 -0
  654. /package/dist/{chunk-KCT36JAW.js.map → chunk-ESNFSSO4.js.map} +0 -0
  655. /package/dist/{chunk-XQ3HXAQH.js.map → chunk-ET2CNMLD.js.map} +0 -0
  656. /package/dist/{chunk-Z4U3UN56.js.map → chunk-EZSCW4EM.js.map} +0 -0
  657. /package/dist/{chunk-F6QHHRWP.js.map → chunk-FESUGFIL.js.map} +0 -0
  658. /package/dist/{chunk-S3K2CIK5.js.map → chunk-FKKGCGYL.js.map} +0 -0
  659. /package/dist/{chunk-BWGCOLEL.js.map → chunk-FTTJRVB7.js.map} +0 -0
  660. /package/dist/{chunk-JAQXUGLN.js.map → chunk-FYWLSFFS.js.map} +0 -0
  661. /package/dist/{chunk-OPGL46PX.js.map → chunk-GX6FTSYH.js.map} +0 -0
  662. /package/dist/{chunk-A32YEQAM.js.map → chunk-H7VDIF2V.js.map} +0 -0
  663. /package/dist/{chunk-PDDSFELN.js.map → chunk-HJXA6ZM7.js.map} +0 -0
  664. /package/dist/{chunk-RGCF4XNH.js.map → chunk-HNPE66LB.js.map} +0 -0
  665. /package/dist/{chunk-SEA6M7SS.js.map → chunk-I5VB44ZK.js.map} +0 -0
  666. /package/dist/{chunk-SDEPLF7V.js.map → chunk-IBJ6U753.js.map} +0 -0
  667. /package/dist/{chunk-EUYWQ7TS.js.map → chunk-IEZ6CGTW.js.map} +0 -0
  668. /package/dist/{chunk-3RI5Y7KU.js.map → chunk-IVIAHQBR.js.map} +0 -0
  669. /package/dist/{chunk-7WR462EM.js.map → chunk-J3OND5QT.js.map} +0 -0
  670. /package/dist/{chunk-T3JQTCCO.js.map → chunk-JI7U6AS3.js.map} +0 -0
  671. /package/dist/{chunk-I32NKXE2.js.map → chunk-JTWZKNUH.js.map} +0 -0
  672. /package/dist/{chunk-VKCAHCBI.js.map → chunk-L4X4PJYK.js.map} +0 -0
  673. /package/dist/{chunk-W4BMEGQA.js.map → chunk-LUDBXTBJ.js.map} +0 -0
  674. /package/dist/{chunk-RIAM7DND.js.map → chunk-ME35HVDJ.js.map} +0 -0
  675. /package/dist/{chunk-NG3MBQV4.js.map → chunk-MJRGVXPQ.js.map} +0 -0
  676. /package/dist/{chunk-773TRRGT.js.map → chunk-MJUCDM3C.js.map} +0 -0
  677. /package/dist/{chunk-7F27PCSN.js.map → chunk-MN5NOOI7.js.map} +0 -0
  678. /package/dist/{chunk-JCWY73FK.js.map → chunk-N4F7ZSSG.js.map} +0 -0
  679. /package/dist/{chunk-TR7DGXGI.js.map → chunk-NACLNNFQ.js.map} +0 -0
  680. /package/dist/{chunk-LC2BDILZ.js.map → chunk-NBP4EX5N.js.map} +0 -0
  681. /package/dist/{chunk-ZVPVTPGI.js.map → chunk-NNZFPYYX.js.map} +0 -0
  682. /package/dist/{chunk-MFOSZUIT.js.map → chunk-NPIBN2VL.js.map} +0 -0
  683. /package/dist/{chunk-IY7UXD3J.js.map → chunk-O57GM3FR.js.map} +0 -0
  684. /package/dist/{chunk-I2HTKOOP.js.map → chunk-O7ERGZDA.js.map} +0 -0
  685. /package/dist/{chunk-GTSVEEP3.js.map → chunk-OAJMQKQR.js.map} +0 -0
  686. /package/dist/{chunk-HSZMX3ZJ.js.map → chunk-ODW5GDFE.js.map} +0 -0
  687. /package/dist/{chunk-J2WC5LF4.js.map → chunk-QBC33MPY.js.map} +0 -0
  688. /package/dist/{chunk-EOHKUWXW.js.map → chunk-QCRJMU5V.js.map} +0 -0
  689. /package/dist/{chunk-5DH6PG4B.js.map → chunk-RZ3IZIJG.js.map} +0 -0
  690. /package/dist/{chunk-AAXJNINV.js.map → chunk-SN4JXNLL.js.map} +0 -0
  691. /package/dist/{chunk-SVSRPG6M.js.map → chunk-TNGH4ZYI.js.map} +0 -0
  692. /package/dist/{chunk-HZNYJN77.js.map → chunk-TNXNECAN.js.map} +0 -0
  693. /package/dist/{chunk-JOEJG4SD.js.map → chunk-TVW4C7PV.js.map} +0 -0
  694. /package/dist/{chunk-UFKPQBXH.js.map → chunk-U62OK7BB.js.map} +0 -0
  695. /package/dist/{chunk-R2MZCYA6.js.map → chunk-UNUMFURP.js.map} +0 -0
  696. /package/dist/{chunk-YRVAKONL.js.map → chunk-VQ4AMTGZ.js.map} +0 -0
  697. /package/dist/{chunk-RAIUTAZZ.js.map → chunk-WKAXBXVA.js.map} +0 -0
  698. /package/dist/{chunk-ZIJDI4CP.js.map → chunk-WKJFIMVN.js.map} +0 -0
  699. /package/dist/{chunk-SXIMQLGV.js.map → chunk-WVGXCBOC.js.map} +0 -0
  700. /package/dist/{chunk-7BEPVIH3.js.map → chunk-X5YYSAZX.js.map} +0 -0
  701. /package/dist/{chunk-FZEEWOI2.js.map → chunk-XJJYSX6F.js.map} +0 -0
  702. /package/dist/{chunk-UG6VXIOK.js.map → chunk-XSTNGNJP.js.map} +0 -0
  703. /package/dist/{chunk-YDPAE2RD.js.map → chunk-YFLLGRXO.js.map} +0 -0
  704. /package/dist/{chunk-EZ25VE3G.js.map → chunk-YNDLCWXS.js.map} +0 -0
  705. /package/dist/{chunk-ANJXPFRS.js.map → chunk-YXFCALVT.js.map} +0 -0
  706. /package/dist/{chunk-Q4WONDMJ.js.map → chunk-YYGZJPOK.js.map} +0 -0
  707. /package/dist/{chunk-5HERQ5FX.js.map → chunk-Z3YEGSR4.js.map} +0 -0
  708. /package/dist/{chunk-YWSQD2IB.js.map → chunk-ZJPM7GZ3.js.map} +0 -0
  709. /package/dist/{chunk-5S4LQOPE.js.map → chunk-ZW4VXELZ.js.map} +0 -0
  710. /package/dist/{first-start-migration-4NETATFF.js.map → first-start-migration-KHIMCBIC.js.map} +0 -0
  711. /package/dist/{forget-SZ2BXDGF.js.map → forget-2AE4MDK3.js.map} +0 -0
  712. /package/dist/{purge-GB7PZHT2.js.map → purge-OP6BEDFY.js.map} +0 -0
  713. /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-CTCGHNWN.js";
12
12
  import {
13
- buildCodingGraphInstallHint,
14
- tryLoadCodingGraphModule
15
- } from "./chunk-VQ7B2Q6M.js";
16
- import {
17
- WriteQuarantineStore
18
- } from "./chunk-PJSK6OJM.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";
19
30
  import {
20
31
  WHO_KNOWS_DEFAULT_LIMIT,
21
32
  computeWhoKnows,
22
33
  loadWhoKnowsEntities,
23
34
  validateWhoKnowsInput
24
- } from "./chunk-ZIJDI4CP.js";
35
+ } from "./chunk-WKJFIMVN.js";
36
+ import {
37
+ WriteQuarantineStore
38
+ } from "./chunk-PJSK6OJM.js";
25
39
  import {
26
40
  trustResultFor
27
41
  } from "./chunk-GNVZQ5JN.js";
@@ -45,31 +59,34 @@ import {
45
59
  } from "./chunk-H7XKCNR6.js";
46
60
  import {
47
61
  toRecallExplainJson
48
- } from "./chunk-YOXVZJFM.js";
62
+ } from "./chunk-CFVTRUR3.js";
49
63
  import {
50
64
  estimateRecallTokens
51
- } from "./chunk-MFOSZUIT.js";
65
+ } from "./chunk-NPIBN2VL.js";
52
66
  import {
53
67
  readAggregateExtractionWatermark
54
- } from "./chunk-5S4LQOPE.js";
68
+ } from "./chunk-ZW4VXELZ.js";
55
69
  import {
56
70
  ReplicaDivergenceMonitor
57
71
  } from "./chunk-CVILPI77.js";
58
- import {
59
- recordMemoryOutcome
60
- } from "./chunk-UD7UNYRD.js";
61
72
  import {
62
73
  recordObjectiveStateSnapshotsFromObservedMessages
63
74
  } from "./chunk-2HIJHXB3.js";
64
75
  import {
65
76
  objectiveStateStoreOverrideForNamespace
66
77
  } from "./chunk-HTP6XRUI.js";
78
+ import {
79
+ recordMemoryOutcome
80
+ } from "./chunk-UD7UNYRD.js";
67
81
  import {
68
82
  coerceIncludedMemories
69
83
  } from "./chunk-2YA5N2BY.js";
70
84
  import {
71
85
  buildGraphSnapshot
72
86
  } from "./chunk-PD66CVSD.js";
87
+ import {
88
+ REDACTION_RULES_SUBDIR
89
+ } from "./chunk-LTHVM4XN.js";
73
90
  import {
74
91
  wrapWorkLayerContext
75
92
  } from "./chunk-EI6V5UXY.js";
@@ -85,14 +102,11 @@ import {
85
102
  import {
86
103
  LocalLlmClient
87
104
  } from "./chunk-IVKIODHO.js";
88
- import {
89
- REDACTION_RULES_SUBDIR
90
- } from "./chunk-LTHVM4XN.js";
91
105
  import {
92
106
  persistExplicitCapture,
93
107
  queueExplicitCaptureForReview,
94
108
  validateExplicitCaptureInput
95
- } from "./chunk-7BEPVIH3.js";
109
+ } from "./chunk-X5YYSAZX.js";
96
110
  import {
97
111
  lcmEvidenceIdentity
98
112
  } from "./chunk-C37ZRXX7.js";
@@ -101,6 +115,10 @@ import {
101
115
  composeRecallContext,
102
116
  renderAuthorityBoundContent
103
117
  } from "./chunk-7ZNJN5WZ.js";
118
+ import {
119
+ CorpusWatermarkCache,
120
+ computeServiceCorpusCensus
121
+ } from "./chunk-4FHRZD5T.js";
104
122
  import {
105
123
  CrossNamespaceBudget,
106
124
  toBudgetWarning
@@ -112,18 +130,14 @@ import {
112
130
  listMemoryGovernanceRuns,
113
131
  readMemoryGovernanceRunArtifact,
114
132
  runMemoryGovernance
115
- } from "./chunk-SVVIASVX.js";
116
- import {
117
- CorpusWatermarkCache,
118
- computeServiceCorpusCensus
119
- } from "./chunk-VXVZ2GM3.js";
133
+ } from "./chunk-EFQCDJZ2.js";
120
134
  import {
121
135
  ExtractionDeadlineError,
122
136
  isActivityDigestPath,
123
137
  isArtifactMemoryPath,
124
138
  isLocationDayPath,
125
139
  isMeetingRecordPath
126
- } from "./chunk-THG4GYIE.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-F6QHHRWP.js";
150
+ } from "./chunk-FESUGFIL.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-BJTHRFFC.js";
158
+ } from "./chunk-GEJKYA7D.js";
144
159
  import {
145
160
  namespaceCollectionName
146
- } from "./chunk-JAQXUGLN.js";
161
+ } from "./chunk-FYWLSFFS.js";
147
162
  import {
148
163
  DEFAULT_RECALL_DISCLOSURE,
149
164
  isRecallDisclosure
150
- } from "./chunk-LBFFNDFM.js";
165
+ } from "./chunk-MINHJ55X.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-RAIUTAZZ.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";
@@ -208,10 +223,10 @@ import {
208
223
  } from "./chunk-GPFZFCRN.js";
209
224
  import {
210
225
  computePromotionCandidates
211
- } from "./chunk-RIAM7DND.js";
226
+ } from "./chunk-ME35HVDJ.js";
212
227
  import {
213
228
  exportCapsule
214
- } from "./chunk-KQAFEZQX.js";
229
+ } from "./chunk-7LCGFUMB.js";
215
230
  import {
216
231
  evaluateActionConfidence
217
232
  } from "./chunk-Z2YFLXHU.js";
@@ -240,22 +255,22 @@ import {
240
255
  } from "./chunk-LNEWDF2A.js";
241
256
  import {
242
257
  createOfflineSyncManifestStream
243
- } from "./chunk-I2HTKOOP.js";
258
+ } from "./chunk-O7ERGZDA.js";
244
259
  import {
245
260
  offlineSyncStorageForSnapshot
246
- } from "./chunk-HZNYJN77.js";
261
+ } from "./chunk-TNXNECAN.js";
247
262
  import {
248
263
  resolveScopePlan,
249
264
  resolveScopedWritableNamespaceValue,
250
265
  resolveWritableNamespaceValue
251
- } from "./chunk-Q57GOHLF.js";
252
- import {
253
- writeFileAtomically
254
- } from "./chunk-AW4QUFQF.js";
266
+ } from "./chunk-EGALNSZ4.js";
255
267
  import {
256
268
  expandScopeProfileReadNamespaces,
257
269
  resolveScopeProfilePlan
258
- } from "./chunk-KCT36JAW.js";
270
+ } from "./chunk-ESNFSSO4.js";
271
+ import {
272
+ writeFileAtomically
273
+ } from "./chunk-AW4QUFQF.js";
259
274
  import {
260
275
  inferMemoryStatus,
261
276
  isActiveMemoryStatus,
@@ -263,7 +278,7 @@ import {
263
278
  } from "./chunk-7RJUVTVF.js";
264
279
  import {
265
280
  getMemoryProjectionPath
266
- } from "./chunk-2LWQSV6A.js";
281
+ } from "./chunk-AL3UYZ5N.js";
267
282
  import {
268
283
  displayErrorDetail
269
284
  } from "./chunk-RL6NEVXT.js";
@@ -275,1576 +290,155 @@ import {
275
290
  SupportPassportCardListSchema,
276
291
  SupportPassportCardMutationInputSchema,
277
292
  SupportPassportCardTitleSchema,
278
- SupportPassportListCardsInputSchema,
279
- SupportPassportManualDraftInputSchema,
280
- SupportPassportMemoryIdSchema,
281
- SupportPassportNamespaceSchema,
282
- SupportPassportReplaceCardInputSchema,
283
- SupportPassportSourceMemoryIdSchema,
284
- activeSupportPassportReplacementPredecessorIds,
285
- computeSupportPassportCardRevision,
286
- computeSupportPassportOwnerKey,
287
- createSupportPassportPrivateFileExclusion,
288
- decodeSupportPassportNamespaceAttributes,
289
- encodeSupportPassportNamespaceAttributes,
290
- isSupportPassportPrivateMemory,
291
- projectSupportPassportCard
292
- } from "./chunk-XDL5CYZN.js";
293
- import {
294
- computeContentHash
295
- } from "./chunk-5FVVY2EB.js";
296
- import {
297
- serializeMutations,
298
- withHeldFileLock
299
- } from "./chunk-FFAZ2XFU.js";
300
- import {
301
- stripAttributesSuffix
302
- } from "./chunk-JDSVLVCG.js";
303
- import {
304
- sanitizeMemoryContent
305
- } from "./chunk-5GKPFL3S.js";
306
- import {
307
- 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
- };
293
+ SupportPassportListCardsInputSchema,
294
+ SupportPassportManualDraftInputSchema,
295
+ SupportPassportMemoryIdSchema,
296
+ SupportPassportNamespaceSchema,
297
+ SupportPassportReplaceCardInputSchema,
298
+ SupportPassportSourceMemoryIdSchema,
299
+ activeSupportPassportReplacementPredecessorIds,
300
+ computeSupportPassportCardRevision,
301
+ computeSupportPassportOwnerKey,
302
+ createSupportPassportPrivateFileExclusion,
303
+ decodeSupportPassportNamespaceAttributes,
304
+ encodeSupportPassportNamespaceAttributes,
305
+ isSupportPassportPrivateMemory,
306
+ projectSupportPassportCard
307
+ } from "./chunk-EEOUMG3J.js";
308
+ import {
309
+ serializeMutations,
310
+ withHeldFileLock
311
+ } from "./chunk-FFAZ2XFU.js";
312
+ import {
313
+ computeContentHash
314
+ } from "./chunk-5FVVY2EB.js";
315
+ import {
316
+ stripAttributesSuffix
317
+ } from "./chunk-JDSVLVCG.js";
318
+ import {
319
+ sanitizeMemoryContent
320
+ } from "./chunk-5GKPFL3S.js";
321
+ import {
322
+ buildHandleIndexForResults,
323
+ isHandleToken
324
+ } from "./chunk-JAKIDQB2.js";
325
+ import {
326
+ OFFLINE_SYNC_SNAPSHOT_FORMAT,
327
+ applyOfflineSyncChangeset,
328
+ applyOfflineSyncFileContentChunk,
329
+ buildOfflineSyncSnapshot,
330
+ buildOfflineSyncSnapshotForPaths,
331
+ buildOfflineSyncSnapshotFromBase,
332
+ compileOfflineSyncExcludeGlobs,
333
+ filterOfflineSyncDeletionRevisions,
334
+ iterateOfflineSyncSnapshotFileRecords,
335
+ normalizeOfflineSyncChangeset,
336
+ readOfflineSyncFileContentChunk
337
+ } from "./chunk-XJJYSX6F.js";
338
+ import {
339
+ validateArchiveRelativePath
340
+ } from "./chunk-GCGJW34D.js";
341
+ import {
342
+ parseIsoOffsetTimestamp
343
+ } from "./chunk-P7FMDTKL.js";
344
+ import {
345
+ assertOperationAuthorizationAllowed,
346
+ capabilityAllowsOp,
347
+ enforceNamespaceAllowList,
348
+ isNamespaceAllowed,
349
+ tokenCapabilityStore
350
+ } from "./chunk-MZWSOLMT.js";
351
+ import {
352
+ canReadNamespace,
353
+ canWriteNamespace,
354
+ citationAuthorizedNamespaces,
355
+ defaultNamespaceForPrincipal,
356
+ recallNamespacesForPrincipal,
357
+ resolvePrincipal
358
+ } from "./chunk-MRV7VSQK.js";
359
+ import {
360
+ namespaceIdentityFromToken
361
+ } from "./chunk-VUFL7X3H.js";
362
+ import {
363
+ resolveAccessSetupCapabilities,
364
+ resolveCompressionCapabilities,
365
+ resolveConsolidationCapabilities,
366
+ resolveGraphConstructionCapabilities,
367
+ resolveIdentityContinuityCapabilities,
368
+ resolveIndexingCapabilities,
369
+ resolveLocalLlmCapabilities,
370
+ resolveMemoryLifecycleCapabilities,
371
+ resolveNamespaceCapabilities,
372
+ resolveObjectiveStateCapabilities,
373
+ resolveQmdCapabilities,
374
+ resolveRecallAuxiliaryCapabilities,
375
+ resolveRecallEnhancementCapabilities,
376
+ resolveSecurityCapabilities
377
+ } from "./chunk-JUOZ62Y7.js";
378
+ import {
379
+ AccessIdempotencyStore,
380
+ hashAccessIdempotencyPayload
381
+ } from "./chunk-VFUEZZBS.js";
382
+ import {
383
+ resolveCodingContextFromOptions
384
+ } from "./chunk-MJUCDM3C.js";
385
+ import {
386
+ combineNamespaces,
387
+ defaultGitInvokerSync,
388
+ lcmSessionKeyForNamespace,
389
+ projectTagProjectId,
390
+ resolveCodingNamespaceOverlay,
391
+ resolveGitContext,
392
+ sanitizeFragment
393
+ } from "./chunk-QBC33MPY.js";
394
+ import {
395
+ expandTildePath
396
+ } from "./chunk-EYIEWJNI.js";
397
+ import {
398
+ EngramAccessForbiddenError,
399
+ EngramAccessInputError,
400
+ NamespaceNotWritableError
401
+ } from "./chunk-2Z24E5W2.js";
402
+ import {
403
+ abortError,
404
+ isAbortError,
405
+ raceAbort,
406
+ throwIfAborted
407
+ } from "./chunk-BTTPKDIL.js";
408
+ import {
409
+ readJsonFile,
410
+ writeJsonFileAtomic
411
+ } from "./chunk-P77QX3ID.js";
412
+ import {
413
+ AccessAuditAdapter
414
+ } from "./chunk-TVVEYCNW.js";
415
+ import {
416
+ decodeCitationNamespace
417
+ } from "./chunk-DJORULH3.js";
418
+ import {
419
+ isPathInsideStorageRoot
420
+ } from "./chunk-FF4KLI5W.js";
421
+ import {
422
+ SecureStoreLockedError
423
+ } from "./chunk-ET2CNMLD.js";
424
+ import {
425
+ ALL_CATEGORY_DIRS,
426
+ getCategoryDir
427
+ } from "./chunk-VS2IYZRU.js";
428
+ import {
429
+ recordCitationUsage
430
+ } from "./chunk-NINSR6LX.js";
431
+ import {
432
+ log
433
+ } from "./chunk-3WCASNQZ.js";
1619
434
 
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
- }
435
+ // src/access-service.ts
436
+ import { createHash as createHash12 } from "crypto";
437
+ import { constants as fsConstants2 } from "fs";
438
+ import { readdirSync, unlinkSync } from "fs";
439
+ import { stat as stat3 } from "fs/promises";
440
+ import * as nodeFs2 from "fs/promises";
441
+ import { ZodError } from "zod";
1848
442
 
1849
443
  // src/coding/decision-surfaces.ts
1850
444
  var DECISION_SUBCOMMANDS = [
@@ -2167,7 +761,7 @@ async function handleGetSchema(store, tool) {
2167
761
  return { tool, ok: true, result: stats };
2168
762
  }
2169
763
  async function handleSearchGraph(store, request, ctx) {
2170
- const query = requireString2(request.query, "query", ctx);
764
+ const query = requireString(request.query, "query", ctx);
2171
765
  const limit = clampPositiveInteger(request.limit, 50, "limit", ctx);
2172
766
  const result = store.searchGraph({ namePattern: query, limit });
2173
767
  if (!result.ok) {
@@ -2177,7 +771,7 @@ async function handleSearchGraph(store, request, ctx) {
2177
771
  }
2178
772
  var SEARCH_CODE_KINDS = ["function", "class", "method"];
2179
773
  async function handleSearchCode(store, request, ctx) {
2180
- const query = requireString2(request.query, "query", ctx);
774
+ const query = requireString(request.query, "query", ctx);
2181
775
  const limit = clampPositiveInteger(request.limit, 50, "limit", ctx);
2182
776
  const seen = /* @__PURE__ */ new Set();
2183
777
  const merged = [];
@@ -2198,7 +792,7 @@ async function handleSearchCode(store, request, ctx) {
2198
792
  return { tool: request.tool, ok: true, result: { hits: merged } };
2199
793
  }
2200
794
  async function handleTracePath(store, request, ctx) {
2201
- const start = requireString2(request.start, "start", ctx);
795
+ const start = requireString(request.start, "start", ctx);
2202
796
  const direction = request.direction ?? "outbound";
2203
797
  if (!TRACE_DIRECTION_SET.has(direction)) {
2204
798
  ctx.throwInputError(
@@ -2214,7 +808,7 @@ async function handleTracePath(store, request, ctx) {
2214
808
  return { tool: request.tool, ok: true, result };
2215
809
  }
2216
810
  async function handleGetSnippet(store, request, ctx) {
2217
- const qualifiedName = requireString2(request.qualifiedName, "qualifiedName", ctx);
811
+ const qualifiedName = requireString(request.qualifiedName, "qualifiedName", ctx);
2218
812
  const result = await store.snippetFor({ qualifiedName });
2219
813
  if (!result.ok) {
2220
814
  return { tool: request.tool, ok: false, code: result.code, message: "snippetFor failed" };
@@ -2254,7 +848,7 @@ async function handleIndexStatus(store, request, ctx) {
2254
848
  return { tool: request.tool, ok: true, result: outcome.status };
2255
849
  }
2256
850
  async function handleDetectChanges(store, request, ctx) {
2257
- const head = requireString2(request.head, "head", ctx);
851
+ const head = requireString(request.head, "head", ctx);
2258
852
  if (!ctx.detectChanges) {
2259
853
  return {
2260
854
  tool: request.tool,
@@ -2272,7 +866,7 @@ async function handleDetectChanges(store, request, ctx) {
2272
866
  return { tool: request.tool, ok: true, result: { head, affected: outcome.affected } };
2273
867
  }
2274
868
  async function handleIndex(request, ctx) {
2275
- const repoRoot = requireString2(request.repoRoot, "repoRoot", ctx);
869
+ const repoRoot = requireString(request.repoRoot, "repoRoot", ctx);
2276
870
  const modeRaw = request.mode ?? "auto";
2277
871
  if (!INDEX_MODE_SET.has(modeRaw)) {
2278
872
  ctx.throwInputError(`mode must be one of ${INDEX_MODES.join(", ")}; got ${JSON.stringify(modeRaw)}`);
@@ -2426,7 +1020,7 @@ async function handleIngestTraces(store, request, ctx) {
2426
1020
  }
2427
1021
  };
2428
1022
  }
2429
- function requireString2(value, field, ctx) {
1023
+ function requireString(value, field, ctx) {
2430
1024
  if (typeof value !== "string" || value.trim().length === 0) {
2431
1025
  ctx.throwInputError(`codegraph: ${field} is required and must be a non-empty string`);
2432
1026
  }
@@ -2468,8 +1062,8 @@ function isLikelyCypher(input) {
2468
1062
  }
2469
1063
 
2470
1064
  // src/coding/session-delta.ts
2471
- import { readFile as readFile3, writeFile, mkdir, rename } from "fs/promises";
2472
- import path3 from "path";
1065
+ import { readFile, writeFile, mkdir, rename } from "fs/promises";
1066
+ import path from "path";
2473
1067
  var MAX_DELTA_COMMITS = 20;
2474
1068
  var MAX_DELTA_FILES = 50;
2475
1069
  function computeSessionDelta(lastSeen, current) {
@@ -2527,14 +1121,14 @@ function formatSinceDate(iso) {
2527
1121
  const match = /^(\d{4}-\d{2}-\d{2})/.exec(iso);
2528
1122
  return match ? match[1] : iso;
2529
1123
  }
2530
- var CODING_KNOWLEDGE_STATE_DIR = path3.join("state", "coding-knowledge");
1124
+ var CODING_KNOWLEDGE_STATE_DIR = path.join("state", "coding-knowledge");
2531
1125
  function sessionDeltaStatePath(memoryDir, namespace) {
2532
1126
  const safe = sanitizeFragment(namespace) || "default";
2533
- return path3.join(memoryDir, CODING_KNOWLEDGE_STATE_DIR, `${safe}.json`);
1127
+ return path.join(memoryDir, CODING_KNOWLEDGE_STATE_DIR, `${safe}.json`);
2534
1128
  }
2535
1129
  async function readLastSeenState(statePath) {
2536
1130
  try {
2537
- const raw = await readFile3(statePath, "utf8");
1131
+ const raw = await readFile(statePath, "utf8");
2538
1132
  const parsed = JSON.parse(raw);
2539
1133
  if (typeof parsed !== "object" || parsed === null) return null;
2540
1134
  const obj = parsed;
@@ -2552,7 +1146,7 @@ async function writeLastSeenState(statePath, state) {
2552
1146
  `writeLastSeenState: invalid state (head=${JSON.stringify(state.head)}, at=${JSON.stringify(state.at)})`
2553
1147
  );
2554
1148
  }
2555
- const dir = path3.dirname(statePath);
1149
+ const dir = path.dirname(statePath);
2556
1150
  await mkdir(dir, { recursive: true });
2557
1151
  const tmp = `${statePath}.tmp-${process.pid}-${Date.now()}`;
2558
1152
  await writeFile(tmp, JSON.stringify(state, null, 2), "utf8");
@@ -2945,8 +1539,8 @@ var CorrectionContractError = class extends Error {
2945
1539
  };
2946
1540
 
2947
1541
  // src/correction/correction-planner.ts
2948
- import { readFile as readFile4, readdir as readdir2, unlink } from "fs/promises";
2949
- import path4 from "path";
1542
+ import { readFile as readFile2, readdir, unlink } from "fs/promises";
1543
+ import path2 from "path";
2950
1544
  var REDACTED_REQUEST_TEXT = "[redacted \u2014 never-store/redaction correction text withheld from the pending-plan file]";
2951
1545
  var CorrectionPlanner = class _CorrectionPlanner {
2952
1546
  constructor(deps) {
@@ -3137,13 +1731,13 @@ var CorrectionPlanner = class _CorrectionPlanner {
3137
1731
  // -------------------------------------------------------------------------
3138
1732
  /** Directory holding pending plans for one namespace. */
3139
1733
  async pendingDir(namespace) {
3140
- return path4.join(await this.deps.storageDir(namespace), "state", "corrections", "pending");
1734
+ return path2.join(await this.deps.storageDir(namespace), "state", "corrections", "pending");
3141
1735
  }
3142
1736
  async persist(plan, abortSignal) {
3143
1737
  throwIfAborted(abortSignal, "correction planning aborted");
3144
1738
  const dir = await this.pendingDir(plan.namespace);
3145
1739
  throwIfAborted(abortSignal, "correction planning aborted");
3146
- const target = path4.join(dir, `${plan.planId}.json`);
1740
+ const target = path2.join(dir, `${plan.planId}.json`);
3147
1741
  const sensitive = plan.classification === "never_store" || plan.actions.some((a) => a.kind === "redaction_rule");
3148
1742
  const persistedPlan = sensitive ? { ...plan, request: { ...plan.request, text: REDACTED_REQUEST_TEXT } } : plan;
3149
1743
  await serializeMutations(`correction-plan:${target}`, async () => {
@@ -3157,11 +1751,11 @@ var CorrectionPlanner = class _CorrectionPlanner {
3157
1751
  /** Load a pending plan by id (used by the service / executor). */
3158
1752
  async loadPlan(namespace, planId) {
3159
1753
  assertSafePlanId(planId);
3160
- const file = path4.join(await this.pendingDir(namespace), `${planId}.json`);
1754
+ const file = path2.join(await this.pendingDir(namespace), `${planId}.json`);
3161
1755
  return serializeMutations(`correction-plan:${file}`, async () => {
3162
1756
  let raw;
3163
1757
  try {
3164
- raw = await readFile4(file, "utf-8");
1758
+ raw = await readFile2(file, "utf-8");
3165
1759
  } catch (err) {
3166
1760
  const code = err?.code;
3167
1761
  if (code === "ENOENT") return null;
@@ -3175,7 +1769,7 @@ var CorrectionPlanner = class _CorrectionPlanner {
3175
1769
  const dir = await this.pendingDir(namespace);
3176
1770
  let files;
3177
1771
  try {
3178
- files = await readdir2(dir);
1772
+ files = await readdir(dir);
3179
1773
  } catch (err) {
3180
1774
  const code = err?.code;
3181
1775
  if (code === "ENOENT") return [];
@@ -3197,11 +1791,11 @@ var CorrectionPlanner = class _CorrectionPlanner {
3197
1791
  }
3198
1792
  async markConsumed(namespace, planId, status) {
3199
1793
  assertSafePlanId(planId);
3200
- const file = path4.join(await this.pendingDir(namespace), `${planId}.json`);
1794
+ const file = path2.join(await this.pendingDir(namespace), `${planId}.json`);
3201
1795
  await serializeMutations(`correction-plan:${file}`, async () => {
3202
1796
  let raw;
3203
1797
  try {
3204
- raw = await readFile4(file, "utf-8");
1798
+ raw = await readFile2(file, "utf-8");
3205
1799
  } catch (err) {
3206
1800
  const code = err?.code;
3207
1801
  if (code === "ENOENT") return;
@@ -3230,11 +1824,11 @@ var CorrectionPlanner = class _CorrectionPlanner {
3230
1824
  */
3231
1825
  async resetApplying(namespace, planId) {
3232
1826
  assertSafePlanId(planId);
3233
- const file = path4.join(await this.pendingDir(namespace), `${planId}.json`);
1827
+ const file = path2.join(await this.pendingDir(namespace), `${planId}.json`);
3234
1828
  await serializeMutations(`correction-plan:${file}`, async () => {
3235
1829
  let raw;
3236
1830
  try {
3237
- raw = await readFile4(file, "utf-8");
1831
+ raw = await readFile2(file, "utf-8");
3238
1832
  } catch (err) {
3239
1833
  const code = err?.code;
3240
1834
  if (code === "ENOENT") return;
@@ -3250,7 +1844,7 @@ var CorrectionPlanner = class _CorrectionPlanner {
3250
1844
  }
3251
1845
  async deletePlan(namespace, planId) {
3252
1846
  assertSafePlanId(planId);
3253
- const file = path4.join(await this.pendingDir(namespace), `${planId}.json`);
1847
+ const file = path2.join(await this.pendingDir(namespace), `${planId}.json`);
3254
1848
  await serializeMutations(`correction-plan:${file}`, async () => {
3255
1849
  try {
3256
1850
  await unlink(file);
@@ -3286,7 +1880,7 @@ var CorrectionPlanner = class _CorrectionPlanner {
3286
1880
  const dir = await this.pendingDir(namespace);
3287
1881
  let files;
3288
1882
  try {
3289
- files = await readdir2(dir);
1883
+ files = await readdir(dir);
3290
1884
  } catch (err) {
3291
1885
  const code = err?.code;
3292
1886
  if (code === "ENOENT") return [];
@@ -3912,8 +2506,8 @@ var CorrectionService = class {
3912
2506
  };
3913
2507
 
3914
2508
  // src/correction/correction-access-wiring.ts
3915
- import path5 from "path";
3916
- import { createHash as createHash2 } from "crypto";
2509
+ import path3 from "path";
2510
+ import { createHash } from "crypto";
3917
2511
  function createCorrectionService(wiring) {
3918
2512
  const cfg = wiring.orchestrator.config;
3919
2513
  const correctionEnabled = isCorrectionFeatureEnabled(cfg);
@@ -4357,14 +2951,14 @@ async function registerRedactionRuleFn(wiring, namespace, pattern, abortSignal,
4357
2951
  throwIfAborted(abortSignal, "correction apply aborted");
4358
2952
  const storage = await wiring.orchestrator.getStorage(namespace);
4359
2953
  throwIfAborted(abortSignal, "correction apply aborted");
4360
- const dir = path5.join(storage.dir, REDACTION_RULES_SUBDIR);
2954
+ const dir = path3.join(storage.dir, REDACTION_RULES_SUBDIR);
4361
2955
  throwIfAborted(abortSignal, "correction apply aborted");
4362
2956
  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);
2957
+ const patternHash = createHash("sha256").update(pattern).digest("hex").slice(0, 16);
4364
2958
  const slug = `${slugBase}-${patternHash}`;
4365
2959
  throwIfAborted(abortSignal, "correction apply aborted");
4366
2960
  await writeRule(
4367
- path5.join(dir, `${slug}.json`),
2961
+ path3.join(dir, `${slug}.json`),
4368
2962
  `${JSON.stringify({ pattern, namespace, createdAt: (/* @__PURE__ */ new Date()).toISOString() })}
4369
2963
  `
4370
2964
  );
@@ -4860,7 +3454,7 @@ function buildNotificationSummary(plan) {
4860
3454
  }
4861
3455
 
4862
3456
  // src/orchestration/generic-recall-paths.ts
4863
- import path6 from "path";
3457
+ import path4 from "path";
4864
3458
  var CATEGORY_MEMORY_ROOTS = Object.fromEntries(
4865
3459
  ALL_CATEGORY_DIRS.map((directory) => [directory, true])
4866
3460
  );
@@ -4885,7 +3479,7 @@ function normalizeQmdUriPath(relativePath, source) {
4885
3479
  }
4886
3480
  }
4887
3481
  function stripQmdCollectionPrefix(relativePath, policy, source) {
4888
- const normalized = path6.posix.normalize(normalizeQmdUriPath(relativePath, source).replace(/\\/g, "/"));
3482
+ const normalized = path4.posix.normalize(normalizeQmdUriPath(relativePath, source).replace(/\\/g, "/"));
4889
3483
  const slashIndex = normalized.indexOf("/");
4890
3484
  if (slashIndex <= 0 || slashIndex >= normalized.length - 1) return normalized;
4891
3485
  const prefix = normalized.slice(0, slashIndex);
@@ -4894,8 +3488,8 @@ function stripQmdCollectionPrefix(relativePath, policy, source) {
4894
3488
  return matchesHotCollection || matchesColdCollection ? normalized.slice(slashIndex + 1) : normalized;
4895
3489
  }
4896
3490
  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;
3491
+ const isAbsolutePath = path4.isAbsolute(filePath);
3492
+ const relative2 = policy.memoryDir && isAbsolutePath ? path4.relative(policy.memoryDir, path4.resolve(filePath)) : filePath;
4899
3493
  const normalized = !isAbsolutePath ? stripQmdCollectionPrefix(relative2, policy, source) : relative2;
4900
3494
  return /^(?:archive|namespaces[\\/][^\\/]+[\\/]archive)(?:[\\/]|$)/i.test(normalized);
4901
3495
  }
@@ -4918,7 +3512,7 @@ function isSearchExcludedPath(filePath, policy = {}, source = "filesystem") {
4918
3512
  function isNamespacedActivityDigestPath(candidate, memoryDir) {
4919
3513
  if (isActivityDigestPath(candidate, memoryDir)) return true;
4920
3514
  if (memoryDir === void 0 || memoryDir.length === 0) return false;
4921
- const relative2 = path6.relative(memoryDir, path6.resolve(memoryDir, candidate));
3515
+ const relative2 = path4.relative(memoryDir, path4.resolve(memoryDir, candidate));
4922
3516
  const namespaced = /^namespaces[\\/]([^\\/]+)[\\/](.*)$/.exec(relative2);
4923
3517
  if (namespaced === null) return false;
4924
3518
  return isActivityDigestPath(namespaced[2] ?? "", memoryDir);
@@ -4926,19 +3520,19 @@ function isNamespacedActivityDigestPath(candidate, memoryDir) {
4926
3520
  function isNamespacedLocationDayPath(candidate, memoryDir) {
4927
3521
  if (isLocationDayPath(candidate, memoryDir)) return true;
4928
3522
  if (memoryDir === void 0 || memoryDir.length === 0) return false;
4929
- const relative2 = path6.relative(memoryDir, path6.resolve(memoryDir, candidate));
3523
+ const relative2 = path4.relative(memoryDir, path4.resolve(memoryDir, candidate));
4930
3524
  const namespaced = /^namespaces[\\/]([^\\/]+)[\\/](.*)$/.exec(relative2);
4931
3525
  if (namespaced === null) return false;
4932
3526
  return isLocationDayPath(namespaced[2] ?? "", memoryDir);
4933
3527
  }
4934
3528
  function collectionSpellings(filePath, policy, source) {
4935
- if (path6.isAbsolute(filePath)) return [filePath];
3529
+ if (path4.isAbsolute(filePath)) return [filePath];
4936
3530
  if (source === "qmd" && filePath.startsWith("qmd://")) {
4937
- const normalized2 = path6.posix.normalize(normalizeQmdUriPath(filePath, source).replace(/\\/g, "/"));
3531
+ const normalized2 = path4.posix.normalize(normalizeQmdUriPath(filePath, source).replace(/\\/g, "/"));
4938
3532
  const slashIndex2 = normalized2.indexOf("/");
4939
3533
  return slashIndex2 <= 0 || slashIndex2 >= normalized2.length - 1 ? [normalized2] : [normalized2, normalized2.slice(slashIndex2 + 1)];
4940
3534
  }
4941
- const normalized = path6.posix.normalize(
3535
+ const normalized = path4.posix.normalize(
4942
3536
  normalizeQmdUriPath(filePath, source).replace(/\\/g, "/")
4943
3537
  );
4944
3538
  const stripped = stripQmdCollectionPrefix(filePath, policy, source);
@@ -4955,9 +3549,7 @@ function collectionSpellings(filePath, policy, source) {
4955
3549
  return spellings;
4956
3550
  }
4957
3551
  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);
3552
+ return isSearchExcludedPath(filePath, policy, source) || isTopLevelArchivePath(filePath, policy, source) || OKF_RESERVED_BASENAMES[path4.basename(filePath)] === true;
4961
3553
  }
4962
3554
  function filterRecallCandidates(candidates, options) {
4963
3555
  const pathPolicy = options.pathPolicy ?? (options.memoryRoot === void 0 ? void 0 : { memoryDir: options.memoryRoot });
@@ -4968,9 +3560,9 @@ function filterRecallCandidates(candidates, options) {
4968
3560
  }
4969
3561
 
4970
3562
  // src/procedural/procedure-miner.ts
4971
- import { createHash as createHash3 } from "crypto";
3563
+ import { createHash as createHash2 } from "crypto";
4972
3564
  import { mkdir as mkdir2, rm, stat } from "fs/promises";
4973
- import path7 from "path";
3565
+ import path5 from "path";
4974
3566
 
4975
3567
  // src/procedural/reinforcement-core.ts
4976
3568
  function clusterByKey(items, keyFn) {
@@ -5014,7 +3606,7 @@ function clusterKey(record) {
5014
3606
  return `${goal}|${refs.join(",")}`;
5015
3607
  }
5016
3608
  function clusterKeyHash(cluster) {
5017
- return createHash3("sha256").update(cluster).digest("hex");
3609
+ return createHash2("sha256").update(cluster).digest("hex");
5018
3610
  }
5019
3611
  function isErrnoCode(error, code) {
5020
3612
  return typeof error === "object" && error !== null && "code" in error && error.code === code;
@@ -5023,8 +3615,8 @@ function sleep(ms) {
5023
3615
  return new Promise((resolve4) => setTimeout(resolve4, ms));
5024
3616
  }
5025
3617
  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`);
3618
+ const lockRoot = path5.join(path5.resolve(memoryDir), "state", "procedure-miner-locks");
3619
+ const lockDir = path5.join(lockRoot, `${clusterHash}.lock`);
5028
3620
  await mkdir2(lockRoot, { recursive: true });
5029
3621
  const startedAt = Date.now();
5030
3622
  let attempts = 0;
@@ -5055,7 +3647,7 @@ async function acquireClusterWriteLock(memoryDir, clusterHash) {
5055
3647
  }
5056
3648
  }
5057
3649
  async function withClusterWriteLock(memoryDir, clusterHash, fn) {
5058
- const inProcessKey = `${path7.resolve(memoryDir)}:${clusterHash}`;
3650
+ const inProcessKey = `${path5.resolve(memoryDir)}:${clusterHash}`;
5059
3651
  const previous = inProcessClusterWriteLocks.get(inProcessKey) ?? Promise.resolve();
5060
3652
  let releaseInProcess;
5061
3653
  const current = previous.catch(() => void 0).then(
@@ -5193,7 +3785,7 @@ async function runProcedureMining(options) {
5193
3785
  }
5194
3786
 
5195
3787
  // src/support-passport/offline-sync-guard.ts
5196
- import path8 from "path";
3788
+ import path6 from "path";
5197
3789
  var MAX_SUPPORT_PASSPORT_FRONTMATTER_BYTES = 1048576;
5198
3790
  var SUPPORT_PASSPORT_MARKER = "support-passport-";
5199
3791
  var FRONTMATTER_PREFIXES = ["---\n", "---\r\n"];
@@ -5211,6 +3803,10 @@ function assertFrontmatterAllowed(frontmatter, relativePath) {
5211
3803
  if (frontmatter.includes(SUPPORT_PASSPORT_MARKER)) {
5212
3804
  throw new Error(`offline sync cannot modify private support-passport record: ${relativePath}`);
5213
3805
  }
3806
+ const parsed = parseFrontmatter(frontmatter);
3807
+ if (parsed && isSupportPassportPrivateMemory({ frontmatter: parsed.frontmatter })) {
3808
+ throw new Error(`offline sync cannot modify private support-passport record: ${relativePath}`);
3809
+ }
5214
3810
  }
5215
3811
  function inspectBufferedFrontmatter(raw, relativePath, endOfFile) {
5216
3812
  const prefixState = frontmatterPrefixState(raw);
@@ -5259,7 +3855,7 @@ function createSupportPassportOfflineSyncGuard(storage) {
5259
3855
  return {
5260
3856
  root: storage.dir,
5261
3857
  path: normalizedPath,
5262
- filePath: path8.resolve(storage.dir, ...normalizedPath.split("/"))
3858
+ filePath: path6.resolve(storage.dir, ...normalizedPath.split("/"))
5263
3859
  };
5264
3860
  };
5265
3861
  const assertTargetAllowed = async (target) => {
@@ -5403,6 +3999,7 @@ var OPERATION_NAMES = [
5403
3999
  "meetings_list",
5404
4000
  "meetings_get",
5405
4001
  "meetings_build",
4002
+ "standup",
5406
4003
  "action_confidence",
5407
4004
  "chatgpt_memory_inspector",
5408
4005
  "day_summary",
@@ -5590,10 +4187,10 @@ function formatZodIssues(error) {
5590
4187
  const parts = [];
5591
4188
  for (const issue of error.issues) {
5592
4189
  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)";
4190
+ const path18 = hasNumeric ? issue.path.filter((p) => typeof p === "string").join(".") || "(root)" : issue.path.length > 0 ? issue.path.join(".") : "(root)";
5594
4191
  const options = enumOptionsFromIssue(issue);
5595
4192
  const suffix = options ? `. Valid: ${options.join(", ")}` : "";
5596
- parts.push(`${path20}: ${issue.message}${suffix}`);
4193
+ parts.push(`${path18}: ${issue.message}${suffix}`);
5597
4194
  }
5598
4195
  return parts.length > 0 ? `request validation failed: ${parts.join("; ")}` : "request validation failed";
5599
4196
  }
@@ -5735,7 +4332,7 @@ function resolveQueryNamespaceWritablePreflight(caps, params, authenticatedPrinc
5735
4332
  }
5736
4333
 
5737
4334
  // src/admin/admin-surfaces.ts
5738
- import path9 from "path";
4335
+ import path7 from "path";
5739
4336
  var REDACTED = "<redacted>";
5740
4337
  var SENSITIVE_KEY_RE = /(token|secret|password|api[_-]?key|bearer|authorization|credential|private[_-]?key)/i;
5741
4338
  var BEARER_VALUE_RE = /^(bearer|sk-|pk-|xox[bp]-|AKIA)/i;
@@ -6008,7 +4605,7 @@ async function auditTranscripts(memoryDir) {
6008
4605
  movedEntries: file.groups.reduce((sum, group) => sum + group.entryCount, 0),
6009
4606
  unmovableLines: file.unmovableLines
6010
4607
  }));
6011
- const mixedOtherDefault = files.some((file) => file.sourceRelPath.split(path9.sep).includes("other"));
4608
+ const mixedOtherDefault = files.some((file) => file.sourceRelPath.split(path7.sep).includes("other"));
6012
4609
  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
4610
  return {
6014
4611
  generatedAt: plan.generatedAt,
@@ -6147,11 +4744,11 @@ async function promoteMemory(options) {
6147
4744
  }
6148
4745
 
6149
4746
  // src/procedural/library-maintenance.ts
6150
- import path10 from "path";
4747
+ import path8 from "path";
6151
4748
  var MAINTENANCE_ACTOR = "procedure-library-maintenance";
6152
4749
  var MAINTENANCE_RULE_VERSION = "procedure-library-maintenance:1";
6153
4750
  function maintenanceMarkerPath(memoryDir) {
6154
- return path10.join(memoryDir, "state", "procedure-maintenance.json");
4751
+ return path8.join(memoryDir, "state", "procedure-maintenance.json");
6155
4752
  }
6156
4753
  async function readProcedureMaintenanceMarker(memoryDir) {
6157
4754
  try {
@@ -7176,7 +5773,7 @@ var AccessAdminOpsSurface = class {
7176
5773
  readMemory: async (namespace, memoryId) => {
7177
5774
  const resolved = await this.deps.orchestrator.getStorage(namespace);
7178
5775
  const memory = await resolved.getMemoryById(memoryId);
7179
- if (!memory) return null;
5776
+ if (!memory || isSupportPassportPrivateMemory(memory)) return null;
7180
5777
  return {
7181
5778
  category: memory.frontmatter.category,
7182
5779
  content: memory.content,
@@ -7777,7 +6374,7 @@ var AccessLcmSurface = class {
7777
6374
  };
7778
6375
 
7779
6376
  // src/access-observe-write-surface.ts
7780
- import { createHash as createHash4 } from "crypto";
6377
+ import { createHash as createHash3 } from "crypto";
7781
6378
 
7782
6379
  // src/orchestration/session-context.ts
7783
6380
  var SessionOwnershipError = class extends Error {
@@ -9055,7 +7652,7 @@ var AccessObserveWriteSurface = class {
9055
7652
  sourceSessionKey: request.sessionKey,
9056
7653
  inputSummary: inputSummaryParts.length > 0 ? inputSummaryParts.join(" | ").slice(0, 500) : void 0,
9057
7654
  dryRun: request.dryRun === true,
9058
- promptHash: typeof request.sourcePrompt === "string" && request.sourcePrompt.length > 0 ? createHash4("sha256").update(request.sourcePrompt).digest("hex") : void 0
7655
+ promptHash: typeof request.sourcePrompt === "string" && request.sourcePrompt.length > 0 ? createHash3("sha256").update(request.sourcePrompt).digest("hex") : void 0
9059
7656
  };
9060
7657
  const preview = this.deps.orchestrator.previewMemoryActionEvent(event);
9061
7658
  if (request.dryRun === true) {
@@ -9067,11 +7664,11 @@ var AccessObserveWriteSurface = class {
9067
7664
  };
9068
7665
 
9069
7666
  // src/access-recall-surface.ts
9070
- import { createHash as createHash5 } from "crypto";
7667
+ import { createHash as createHash4 } from "crypto";
9071
7668
  import * as nodePath2 from "path";
9072
7669
 
9073
7670
  // src/orchestration/recall-result-formatter.ts
9074
- import path11 from "path";
7671
+ import path9 from "path";
9075
7672
  function renderConnectorLabel(connector) {
9076
7673
  if (!isValidConnectorId(connector)) return null;
9077
7674
  return connector.length <= CONNECTOR_LABEL_MAX_LENGTH ? connector : `${connector.slice(0, CONNECTOR_LABEL_MAX_LENGTH - 1)}\u2026`;
@@ -9093,15 +7690,15 @@ function resolveEffectiveIdentityInjectionMode(options) {
9093
7690
  return { mode: options.configuredMode, shouldInject: true };
9094
7691
  }
9095
7692
  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("/");
7693
+ if (!path9.isAbsolute(resultPath)) return resultPath;
7694
+ const root = path9.resolve(memoryDir);
7695
+ const nsRoot = path9.join(root, "namespaces");
7696
+ if (namespace && (resultPath === nsRoot || resultPath.startsWith(nsRoot + path9.sep))) {
7697
+ const afterNs = path9.relative(nsRoot, resultPath).split(path9.sep).slice(1).join("/");
9101
7698
  if (afterNs) return `${namespace}/${afterNs}`;
9102
7699
  }
9103
- const rel = path11.relative(root, resultPath);
9104
- return rel && !rel.startsWith("..") && !path11.isAbsolute(rel) ? rel.split(path11.sep).join("/") : resultPath;
7700
+ const rel = path9.relative(root, resultPath);
7701
+ return rel && !rel.startsWith("..") && !path9.isAbsolute(rel) ? rel.split(path9.sep).join("/") : resultPath;
9105
7702
  }
9106
7703
  function displaySafeRecallSnapshot(snapshot, memoryDir) {
9107
7704
  const includedMemories = coerceIncludedMemories(snapshot).map((memory) => ({
@@ -9656,7 +8253,7 @@ var AccessRecallSurface = class {
9656
8253
  const snapshotForSerialization = {
9657
8254
  sessionKey: options.sessionKey ?? "",
9658
8255
  recordedAt: new Date(options.snapshot.capturedAt).toISOString(),
9659
- queryHash: createHash5("sha256").update(options.query).digest("hex"),
8256
+ queryHash: createHash4("sha256").update(options.query).digest("hex"),
9660
8257
  queryLen: options.query.length,
9661
8258
  memoryIds,
9662
8259
  namespace,
@@ -10371,10 +8968,10 @@ var AccessRecallSurface = class {
10371
8968
  };
10372
8969
 
10373
8970
  // src/review/review-deck-surface.ts
10374
- import { createHash as createHash8 } from "crypto";
8971
+ import { createHash as createHash7 } from "crypto";
10375
8972
 
10376
8973
  // src/review/review-deck.ts
10377
- import { createHash as createHash6 } from "crypto";
8974
+ import { createHash as createHash5 } from "crypto";
10378
8975
 
10379
8976
  // src/review/frontmatter.ts
10380
8977
  function splitMarkdownFrontmatter(content) {
@@ -10419,7 +9016,7 @@ var REVIEW_REASON_LABELS = {
10419
9016
  };
10420
9017
  var EXCERPT_LIMIT = 240;
10421
9018
  function computeReviewItemRevision(fileContent) {
10422
- return `rv1:${createHash6("sha256").update(fileContent).digest("hex")}`;
9019
+ return `rv1:${createHash5("sha256").update(fileContent).digest("hex")}`;
10423
9020
  }
10424
9021
  function projectReviewDeckItem(row, namespace) {
10425
9022
  const provenance = provenanceFromRow(row);
@@ -10564,16 +9161,16 @@ function parseCursorPayload(cursor) {
10564
9161
  }
10565
9162
 
10566
9163
  // src/review/review-deck-mutation.ts
10567
- import { createHash as createHash7, randomUUID } from "crypto";
9164
+ import { createHash as createHash6, randomUUID } from "crypto";
10568
9165
  import fs3 from "fs";
10569
- import path14 from "path";
9166
+ import path12 from "path";
10570
9167
 
10571
9168
  // src/review/index.ts
10572
9169
  import fs from "fs";
10573
- import path12 from "path";
9170
+ import path10 from "path";
10574
9171
  var historicalIdCache = new HistoricalEntityCanonicalIdCache();
10575
9172
  function writeReviewFileCanonicalized(memoryDir, filePath, content) {
10576
- const stateDir = path12.join(memoryDir, "state");
9173
+ const stateDir = path10.join(memoryDir, "state");
10577
9174
  const idsAtWrite = historicalIdCache.get(stateDir);
10578
9175
  let originalBytes = null;
10579
9176
  try {
@@ -10615,8 +9212,8 @@ function realMemoryRoot(memoryDir) {
10615
9212
  }
10616
9213
  }
10617
9214
  function isPathInside(rootReal, candidateReal) {
10618
- const relative2 = path12.relative(rootReal, candidateReal);
10619
- return relative2 === "" || !!relative2 && !relative2.startsWith("..") && !path12.isAbsolute(relative2);
9215
+ const relative2 = path10.relative(rootReal, candidateReal);
9216
+ return relative2 === "" || !!relative2 && !relative2.startsWith("..") && !path10.isAbsolute(relative2);
10620
9217
  }
10621
9218
  function isSafeDirectory(rootReal, dir) {
10622
9219
  try {
@@ -10659,7 +9256,7 @@ function listReviewItems(options) {
10659
9256
  if (filterReason && item.reviewReason !== filterReason) return;
10660
9257
  items.push(item);
10661
9258
  };
10662
- const suggestionsDir = path12.join(memoryDir, "suggestions");
9259
+ const suggestionsDir = path10.join(memoryDir, "suggestions");
10663
9260
  if (!isLimitReached() && fs.existsSync(suggestionsDir) && isSafeDirectory(rootReal, suggestionsDir)) {
10664
9261
  walkMd(rootReal, suggestionsDir, (filePath, content) => {
10665
9262
  if (isLimitReached()) return true;
@@ -10680,7 +9277,7 @@ function listReviewItems(options) {
10680
9277
  return isLimitReached();
10681
9278
  });
10682
9279
  }
10683
- const reviewDir = path12.join(memoryDir, "review");
9280
+ const reviewDir = path10.join(memoryDir, "review");
10684
9281
  if (!isLimitReached() && fs.existsSync(reviewDir) && isSafeDirectory(rootReal, reviewDir)) {
10685
9282
  walkMd(rootReal, reviewDir, (filePath, content) => {
10686
9283
  if (isLimitReached()) return true;
@@ -10705,7 +9302,7 @@ function listReviewItems(options) {
10705
9302
  const categories = ALL_CATEGORY_DIRS;
10706
9303
  for (const category of categories) {
10707
9304
  if (isLimitReached()) break;
10708
- const dir = path12.join(memoryDir, category);
9305
+ const dir = path10.join(memoryDir, category);
10709
9306
  if (!fs.existsSync(dir) || !isSafeDirectory(rootReal, dir)) continue;
10710
9307
  walkMd(rootReal, dir, (filePath, content) => {
10711
9308
  if (isLimitReached()) return true;
@@ -10787,9 +9384,9 @@ function approveItem(memoryDir, itemId, options) {
10787
9384
  const targetDir = getCategoryDir(memoryDir, category);
10788
9385
  const dateDir = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
10789
9386
  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");
9387
+ const outputPath = path10.join(targetDir, dateDir, path10.basename(found.filePath));
9388
+ ensureSafeDirectory(rootReal, path10.dirname(outputPath));
9389
+ const reviewStateDir = path10.join(memoryDir, "state");
10793
9390
  const idsAtWrite = historicalIdCache.get(reviewStateDir);
10794
9391
  const promotedWritten = canonicalizeEntityRefFrontmatter(updatedContent, idsAtWrite);
10795
9392
  const promotedPath = writeFileWithoutClobber(outputPath, promotedWritten, itemId);
@@ -10866,13 +9463,13 @@ function findReviewFileById(memoryDir, id, options = {}) {
10866
9463
  const rootReal = realMemoryRoot(memoryDir);
10867
9464
  if (!rootReal) return null;
10868
9465
  for (const loc of ["suggestions", "review"]) {
10869
- const dir = path12.join(memoryDir, loc);
9466
+ const dir = path10.join(memoryDir, loc);
10870
9467
  if (!fs.existsSync(dir) || !isSafeDirectory(rootReal, dir)) continue;
10871
9468
  const found = findFileById(rootReal, dir, id);
10872
9469
  if (found) return { filePath: found, location: "queue" };
10873
9470
  }
10874
9471
  for (const category of ALL_CATEGORY_DIRS) {
10875
- const dir = path12.join(memoryDir, category);
9472
+ const dir = path10.join(memoryDir, category);
10876
9473
  if (!fs.existsSync(dir) || !isSafeDirectory(rootReal, dir)) continue;
10877
9474
  const found = findFileById(rootReal, dir, id, (fm) => isLowConfidenceReviewCandidate(fm, options));
10878
9475
  if (found) return { filePath: found, location: "category" };
@@ -10948,10 +9545,10 @@ function readFileSafe(filePath) {
10948
9545
  }
10949
9546
  }
10950
9547
  function writeFileWithoutClobber(basePath, content, discriminator) {
10951
- const parsed = path12.parse(basePath);
9548
+ const parsed = path10.parse(basePath);
10952
9549
  const safeDiscriminator = sanitizeFilePart(discriminator);
10953
9550
  for (let attempt = 0; attempt < 1e3; attempt++) {
10954
- const candidate = attempt === 0 ? basePath : path12.join(
9551
+ const candidate = attempt === 0 ? basePath : path10.join(
10955
9552
  parsed.dir,
10956
9553
  `${parsed.name}-${safeDiscriminator}${attempt === 1 ? "" : `-${attempt}`}${parsed.ext || ".md"}`
10957
9554
  );
@@ -11007,7 +9604,7 @@ function extractBody(content) {
11007
9604
  function walkMd(rootReal, dir, callback) {
11008
9605
  if (!isSafeDirectory(rootReal, dir)) return false;
11009
9606
  for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
11010
- const fullPath = path12.join(dir, entry.name);
9607
+ const fullPath = path10.join(dir, entry.name);
11011
9608
  if (entry.isSymbolicLink()) continue;
11012
9609
  if (entry.isDirectory()) {
11013
9610
  if (walkMd(rootReal, fullPath, callback)) return true;
@@ -11022,7 +9619,7 @@ function walkMdPaths(rootReal, dir) {
11022
9619
  const results = [];
11023
9620
  if (!isSafeDirectory(rootReal, dir)) return results;
11024
9621
  for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
11025
- const fullPath = path12.join(dir, entry.name);
9622
+ const fullPath = path10.join(dir, entry.name);
11026
9623
  if (entry.isSymbolicLink()) continue;
11027
9624
  if (entry.isDirectory()) {
11028
9625
  results.push(...walkMdPaths(rootReal, fullPath));
@@ -11035,7 +9632,7 @@ function walkMdPaths(rootReal, dir) {
11035
9632
 
11036
9633
  // src/review/review-deck-snapshot.ts
11037
9634
  import fs2 from "fs";
11038
- import path13 from "path";
9635
+ import path11 from "path";
11039
9636
  var QUEUE_DIRS = ["suggestions", "review"];
11040
9637
  function readReviewDeckSnapshot(opts) {
11041
9638
  const corpusVersion = readCorpusVersion(opts.memoryDir);
@@ -11043,7 +9640,7 @@ function readReviewDeckSnapshot(opts) {
11043
9640
  if (!rootReal) return { corpusVersion, total: 0, rows: [] };
11044
9641
  const rows = [];
11045
9642
  for (const location of QUEUE_DIRS) {
11046
- const dir = path13.join(opts.memoryDir, location);
9643
+ const dir = path11.join(opts.memoryDir, location);
11047
9644
  if (!fs2.existsSync(dir) || !isSafeDirectory2(rootReal, dir)) continue;
11048
9645
  walkMd2(rootReal, dir, (filePath, content) => {
11049
9646
  const row = rowFromQueueFile(filePath, content, location);
@@ -11056,7 +9653,7 @@ function readReviewDeckRow(opts) {
11056
9653
  const rootReal = realMemoryRoot2(opts.memoryDir);
11057
9654
  if (!rootReal) return null;
11058
9655
  for (const location of QUEUE_DIRS) {
11059
- const dir = path13.join(opts.memoryDir, location);
9656
+ const dir = path11.join(opts.memoryDir, location);
11060
9657
  if (!fs2.existsSync(dir) || !isSafeDirectory2(rootReal, dir)) continue;
11061
9658
  let found = null;
11062
9659
  walkMd2(rootReal, dir, (filePath, content) => {
@@ -11072,7 +9669,7 @@ function readReviewDeckRow(opts) {
11072
9669
  }
11073
9670
  function readCorpusVersion(memoryDir) {
11074
9671
  try {
11075
- return String(fs2.statSync(path13.join(memoryDir, "state", MEMORY_CORPUS_VERSION_SENTINEL)).size);
9672
+ return String(fs2.statSync(path11.join(memoryDir, "state", MEMORY_CORPUS_VERSION_SENTINEL)).size);
11076
9673
  } catch {
11077
9674
  return "0";
11078
9675
  }
@@ -11122,8 +9719,8 @@ function realMemoryRoot2(memoryDir) {
11122
9719
  }
11123
9720
  }
11124
9721
  function isPathInside2(rootReal, candidateReal) {
11125
- const relative2 = path13.relative(rootReal, candidateReal);
11126
- return relative2 === "" || !!relative2 && !relative2.startsWith("..") && !path13.isAbsolute(relative2);
9722
+ const relative2 = path11.relative(rootReal, candidateReal);
9723
+ return relative2 === "" || !!relative2 && !relative2.startsWith("..") && !path11.isAbsolute(relative2);
11127
9724
  }
11128
9725
  function isSafeDirectory2(rootReal, dir) {
11129
9726
  try {
@@ -11137,7 +9734,7 @@ function isSafeDirectory2(rootReal, dir) {
11137
9734
  function walkMd2(rootReal, dir, callback) {
11138
9735
  if (!isSafeDirectory2(rootReal, dir)) return false;
11139
9736
  for (const entry of fs2.readdirSync(dir, { withFileTypes: true })) {
11140
- const fullPath = path13.join(dir, entry.name);
9737
+ const fullPath = path11.join(dir, entry.name);
11141
9738
  if (entry.isSymbolicLink()) continue;
11142
9739
  if (entry.isDirectory()) {
11143
9740
  if (walkMd2(rootReal, fullPath, callback)) return true;
@@ -11222,7 +9819,7 @@ var EVENT_TYPE = {
11222
9819
  undo: "restored"
11223
9820
  };
11224
9821
  function sha256Hex(value) {
11225
- return createHash7("sha256").update(value, "utf8").digest("hex");
9822
+ return createHash6("sha256").update(value, "utf8").digest("hex");
11226
9823
  }
11227
9824
  function computeReceiptId(namespace, principalDigest, idempotencyKey) {
11228
9825
  return `rcp1:${sha256Hex(`${namespace}\0${principalDigest}\0${idempotencyKey}`)}`;
@@ -11252,7 +9849,7 @@ function parseReviewLifecycleReceipt(value) {
11252
9849
  if (!isReceiptAction(rec.action)) return null;
11253
9850
  if (typeof rec.beforeRevision !== "string") return null;
11254
9851
  if (typeof rec.afterRevision !== "string") return null;
11255
- if (!isNonEmptyString(rec.sourcePath) || path14.isAbsolute(rec.sourcePath)) return null;
9852
+ if (!isNonEmptyString(rec.sourcePath) || path12.isAbsolute(rec.sourcePath)) return null;
11256
9853
  if (rec.revisionArtifact !== void 0 && typeof rec.revisionArtifact !== "string") return null;
11257
9854
  if (rec.undoOfReceiptId !== void 0 && typeof rec.undoOfReceiptId !== "string") return null;
11258
9855
  const parsed = {
@@ -11284,11 +9881,11 @@ function findStoredReceipt(events, receiptId) {
11284
9881
  return null;
11285
9882
  }
11286
9883
  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;
9884
+ if (!rel || path12.isAbsolute(rel)) return null;
9885
+ const root = path12.resolve(memoryDir);
9886
+ const abs = path12.resolve(root, rel.split("/").join(path12.sep));
9887
+ const next = path12.relative(root, abs);
9888
+ if (next.startsWith("..") || path12.isAbsolute(next)) return null;
11292
9889
  return abs;
11293
9890
  }
11294
9891
  function currentRevision(absPath) {
@@ -11693,7 +10290,7 @@ async function executeReviewDeckUndo(ctx, req) {
11693
10290
 
11694
10291
  // src/review/review-deck-surface.ts
11695
10292
  function digest(value) {
11696
- return createHash8("sha256").update(value).digest("hex");
10293
+ return createHash7("sha256").update(value).digest("hex");
11697
10294
  }
11698
10295
  var ReviewDeckSurface = class {
11699
10296
  constructor(deps) {
@@ -11864,7 +10461,7 @@ function ownerListCards(storedCards) {
11864
10461
  if (replacedDraftIds.has(item.card.cardId)) return false;
11865
10462
  if (!item.replacesDraftId) return true;
11866
10463
  const replacedStatus = byId.get(item.replacesDraftId)?.card.status;
11867
- return replacedStatus === "pending_review" || replacedStatus === "rejected";
10464
+ return replacedStatus === void 0 || replacedStatus === "pending_review" || replacedStatus === "rejected";
11868
10465
  });
11869
10466
  }
11870
10467
 
@@ -11951,14 +10548,14 @@ async function completeSupportPassportReplacementPrior(input) {
11951
10548
  }
11952
10549
 
11953
10550
  // src/support-passport/generated-batch.ts
11954
- import path16 from "path";
10551
+ import path14 from "path";
11955
10552
  import { z as z2 } from "zod";
11956
10553
 
11957
10554
  // src/support-passport/private-file.ts
11958
10555
  import { randomUUID as randomUUID2 } from "crypto";
11959
10556
  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";
10557
+ import { lstat as lstat2, mkdir as mkdir3, open, rename as rename2, rm as rm2, stat as stat2 } from "fs/promises";
10558
+ import path13 from "path";
11962
10559
  var UNSUPPORTED_DIRECTORY_SYNC_ERRORS = /* @__PURE__ */ new Set(["EINVAL", "ENOSYS", "ENOTSUP", "EOPNOTSUPP"]);
11963
10560
  var NON_WRITABLE_ANCESTOR_SYNC_ERRORS = /* @__PURE__ */ new Set(["EROFS", "EPERM", "EACCES"]);
11964
10561
  function assertStableDirectory(before, opened, after, errorMessage) {
@@ -11973,7 +10570,7 @@ function assertStableRegularFile(before, opened, after, errorMessage) {
11973
10570
  }
11974
10571
  async function lstatPrivateTarget(filePath, errorMessage) {
11975
10572
  try {
11976
- return await lstat3(filePath);
10573
+ return await lstat2(filePath);
11977
10574
  } catch {
11978
10575
  throw new Error(errorMessage);
11979
10576
  }
@@ -11984,13 +10581,13 @@ function openFlags(...flags) {
11984
10581
  return combined;
11985
10582
  }
11986
10583
  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)) {
10584
+ const relative2 = path13.relative(path13.resolve(trustedRoot), path13.resolve(directory));
10585
+ if (relative2 === ".." || relative2.startsWith(`..${path13.sep}`) || path13.isAbsolute(relative2)) {
11989
10586
  throw new Error(errorMessage);
11990
10587
  }
11991
10588
  }
11992
10589
  async function openDirectoryNoFollow(directory, errorMessage) {
11993
- const before = await lstat3(directory);
10590
+ const before = await lstat2(directory);
11994
10591
  if (before.isSymbolicLink() || !before.isDirectory()) throw new Error(errorMessage);
11995
10592
  const handle = await open(
11996
10593
  directory,
@@ -11998,7 +10595,7 @@ async function openDirectoryNoFollow(directory, errorMessage) {
11998
10595
  );
11999
10596
  try {
12000
10597
  const opened = await handle.stat();
12001
- assertStableDirectory(before, opened, await lstat3(directory), errorMessage);
10598
+ assertStableDirectory(before, opened, await lstat2(directory), errorMessage);
12002
10599
  return { before, opened, handle };
12003
10600
  } catch (error) {
12004
10601
  await handle.close().catch(() => void 0);
@@ -12018,7 +10615,7 @@ async function syncDirectoryHandle(handle) {
12018
10615
  }
12019
10616
  async function resolvePrivateDirectoryPath(directory, handle, opened, errorMessage, platform = process.platform) {
12020
10617
  const descriptorRoot = requirePrivateFileDescriptorRoot(platform, errorMessage);
12021
- const pinnedPath = path15.join(descriptorRoot, String(handle.fd));
10618
+ const pinnedPath = path13.join(descriptorRoot, String(handle.fd));
12022
10619
  const metadata = await stat2(pinnedPath);
12023
10620
  if (!metadata.isDirectory() || metadata.dev !== opened.dev || metadata.ino !== opened.ino) {
12024
10621
  throw new Error(errorMessage);
@@ -12034,12 +10631,12 @@ function requirePrivateFileDescriptorRoot(platform, errorMessage) {
12034
10631
  throw new Error(errorMessage);
12035
10632
  }
12036
10633
  async function openStableDirectoryFromRoot(trustedRoot, directory, errorMessage, platform = process.platform) {
12037
- const root = path15.resolve(trustedRoot);
12038
- const target = path15.resolve(directory);
10634
+ const root = path13.resolve(trustedRoot);
10635
+ const target = path13.resolve(directory);
12039
10636
  assertContainedPath(root, target, errorMessage);
12040
10637
  requirePrivateFileDescriptorRoot(platform, errorMessage);
12041
- const relative2 = path15.relative(root, target);
12042
- const components = relative2 === "" ? [] : relative2.split(path15.sep);
10638
+ const relative2 = path13.relative(root, target);
10639
+ const components = relative2 === "" ? [] : relative2.split(path13.sep);
12043
10640
  const handles = [];
12044
10641
  let currentPath = root;
12045
10642
  try {
@@ -12047,13 +10644,13 @@ async function openStableDirectoryFromRoot(trustedRoot, directory, errorMessage,
12047
10644
  handles.push(current.handle);
12048
10645
  for (const component of components) {
12049
10646
  const pinnedParent = await resolvePrivateDirectoryPath(currentPath, current.handle, current.opened, errorMessage);
12050
- const child = await openDirectoryNoFollow(path15.join(pinnedParent, component), errorMessage);
10647
+ const child = await openDirectoryNoFollow(path13.join(pinnedParent, component), errorMessage);
12051
10648
  handles.push(child.handle);
12052
- assertStableDirectory(current.before, current.opened, await lstat3(currentPath), errorMessage);
12053
- currentPath = path15.join(currentPath, component);
10649
+ assertStableDirectory(current.before, current.opened, await lstat2(currentPath), errorMessage);
10650
+ currentPath = path13.join(currentPath, component);
12054
10651
  current = child;
12055
10652
  }
12056
- assertStableDirectory(current.before, current.opened, await lstat3(target), errorMessage);
10653
+ assertStableDirectory(current.before, current.opened, await lstat2(target), errorMessage);
12057
10654
  return {
12058
10655
  ...current,
12059
10656
  handles,
@@ -12071,12 +10668,12 @@ async function openStableDirectoryFromRoot(trustedRoot, directory, errorMessage,
12071
10668
  }
12072
10669
  }
12073
10670
  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);
10671
+ const root = path13.resolve(trustedRoot);
10672
+ const target = path13.resolve(directory);
12076
10673
  assertContainedPath(root, target, errorMessage);
12077
- const relative2 = path15.relative(root, target);
10674
+ const relative2 = path13.relative(root, target);
12078
10675
  requirePrivateFileDescriptorRoot(platform, errorMessage);
12079
- const components = relative2 === "" ? [] : relative2.split(path15.sep);
10676
+ const components = relative2 === "" ? [] : relative2.split(path13.sep);
12080
10677
  const handles = [];
12081
10678
  let currentPath = root;
12082
10679
  try {
@@ -12084,7 +10681,7 @@ async function ensurePrivateDirectoryNoFollow(trustedRoot, directory, errorMessa
12084
10681
  handles.push(current.handle);
12085
10682
  for (const component of components) {
12086
10683
  const pinnedParent = await resolvePrivateDirectoryPath(currentPath, current.handle, current.opened, errorMessage);
12087
- const childPath = path15.join(pinnedParent, component);
10684
+ const childPath = path13.join(pinnedParent, component);
12088
10685
  let created = false;
12089
10686
  try {
12090
10687
  await mkdir3(childPath, { mode: 448 });
@@ -12098,18 +10695,18 @@ async function ensurePrivateDirectoryNoFollow(trustedRoot, directory, errorMessa
12098
10695
  if (created || hardenExistingChildren && (child.opened.mode & 511) !== 448) {
12099
10696
  await child.handle.chmod(448);
12100
10697
  }
12101
- assertStableDirectory(current.before, current.opened, await lstat3(currentPath), errorMessage);
12102
- currentPath = path15.join(currentPath, component);
10698
+ assertStableDirectory(current.before, current.opened, await lstat2(currentPath), errorMessage);
10699
+ currentPath = path13.join(currentPath, component);
12103
10700
  current = child;
12104
10701
  }
12105
- assertStableDirectory(current.before, current.opened, await lstat3(target), errorMessage);
10702
+ assertStableDirectory(current.before, current.opened, await lstat2(target), errorMessage);
12106
10703
  } finally {
12107
10704
  await closeDirectoryHandles(handles);
12108
10705
  }
12109
10706
  }
12110
10707
  async function ensurePrivateDirectoryTreeNoFollow(directory, errorMessage, syncVerifiedParent = syncDirectoryHandle, platform = process.platform) {
12111
- const target = path15.resolve(directory);
12112
- const filesystemRoot = path15.parse(target).root;
10708
+ const target = path13.resolve(directory);
10709
+ const filesystemRoot = path13.parse(target).root;
12113
10710
  const rootMetadata = await stat2(filesystemRoot);
12114
10711
  await ensurePrivateDirectoryNoFollow(
12115
10712
  filesystemRoot,
@@ -12137,23 +10734,23 @@ async function withPrivateDirectoryNoFollow(trustedRoot, directory, errorMessage
12137
10734
  const stableDirectory = await openStableDirectoryFromRoot(trustedRoot, directory, errorMessage, platform);
12138
10735
  directoryHandles = stableDirectory.handles;
12139
10736
  const result = await task(stableDirectory.pinnedDirectory);
12140
- assertStableDirectory(stableDirectory.before, stableDirectory.opened, await lstat3(directory), errorMessage);
10737
+ assertStableDirectory(stableDirectory.before, stableDirectory.opened, await lstat2(directory), errorMessage);
12141
10738
  return result;
12142
10739
  } finally {
12143
10740
  await closeDirectoryHandles(directoryHandles);
12144
10741
  }
12145
10742
  }
12146
10743
  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);
10744
+ if (path13.dirname(filePath) !== path13.resolve(directory)) throw new Error(errorMessage);
10745
+ const targetName = path13.basename(filePath);
12149
10746
  let directoryHandles = [];
12150
10747
  let fileHandle;
12151
10748
  try {
12152
10749
  const stableDirectory = await openStableDirectoryFromRoot(trustedRoot, directory, errorMessage, platform);
12153
10750
  directoryHandles = stableDirectory.handles;
12154
10751
  const pinnedDirectory = stableDirectory.pinnedDirectory;
12155
- const targetPath = path15.join(pinnedDirectory, targetName);
12156
- const before = await lstat3(targetPath);
10752
+ const targetPath = path13.join(pinnedDirectory, targetName);
10753
+ const before = await lstat2(targetPath);
12157
10754
  if (before.isSymbolicLink() || !before.isFile()) throw new Error(errorMessage);
12158
10755
  try {
12159
10756
  fileHandle = await open(targetPath, openFlags(fsConstants.O_RDONLY, fsConstants.O_NOFOLLOW));
@@ -12162,8 +10759,8 @@ async function readPrivateFileNoFollow(directory, filePath, errorMessage, truste
12162
10759
  throw error;
12163
10760
  }
12164
10761
  const fileMetadata = await fileHandle.stat();
12165
- assertStableRegularFile(before, fileMetadata, await lstat3(targetPath), errorMessage);
12166
- assertStableDirectory(stableDirectory.before, stableDirectory.opened, await lstat3(directory), errorMessage);
10762
+ assertStableRegularFile(before, fileMetadata, await lstat2(targetPath), errorMessage);
10763
+ assertStableDirectory(stableDirectory.before, stableDirectory.opened, await lstat2(directory), errorMessage);
12167
10764
  return await fileHandle.readFile("utf8");
12168
10765
  } finally {
12169
10766
  await fileHandle?.close().catch(() => void 0);
@@ -12171,10 +10768,10 @@ async function readPrivateFileNoFollow(directory, filePath, errorMessage, truste
12171
10768
  }
12172
10769
  }
12173
10770
  async function appendPrivateFileAtPinnedDirectory(pinnedDirectory, targetName, content, errorMessage, directoryHandle, openFile) {
12174
- if (targetName.length === 0 || targetName === "." || targetName === ".." || path15.basename(targetName) !== targetName) {
10771
+ if (targetName.length === 0 || targetName === "." || targetName === ".." || path13.basename(targetName) !== targetName) {
12175
10772
  throw new Error(errorMessage);
12176
10773
  }
12177
- const targetPath = path15.join(pinnedDirectory, targetName);
10774
+ const targetPath = path13.join(pinnedDirectory, targetName);
12178
10775
  let fileHandle;
12179
10776
  try {
12180
10777
  try {
@@ -12210,8 +10807,8 @@ async function appendPrivateFileAtPinnedDirectory(pinnedDirectory, targetName, c
12210
10807
  }
12211
10808
  async function appendPrivateFileInPinnedDirectory(pinnedDirectory, fileName, content, errorMessage, platform = process.platform) {
12212
10809
  const descriptorRoot = requirePrivateFileDescriptorRoot(platform, errorMessage);
12213
- const resolvedDirectory = path15.resolve(pinnedDirectory);
12214
- const descriptor = path15.relative(descriptorRoot, resolvedDirectory);
10810
+ const resolvedDirectory = path13.resolve(pinnedDirectory);
10811
+ const descriptor = path13.relative(descriptorRoot, resolvedDirectory);
12215
10812
  if (!/^\d+$/.test(descriptor)) throw new Error(errorMessage);
12216
10813
  const before = await stat2(resolvedDirectory);
12217
10814
  if (!before.isDirectory()) throw new Error(errorMessage);
@@ -12227,8 +10824,8 @@ async function appendPrivateFileInPinnedDirectory(pinnedDirectory, fileName, con
12227
10824
  }
12228
10825
  }
12229
10826
  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);
10827
+ if (path13.dirname(filePath) !== path13.resolve(directory)) throw new Error(errorMessage);
10828
+ const targetName = path13.basename(filePath);
12232
10829
  const tempName = `.${targetName}.${randomUUID2()}.tmp`;
12233
10830
  let tempPath;
12234
10831
  let directoryHandles = [];
@@ -12237,8 +10834,8 @@ async function writePrivateFileAtomicallyNoFollow(directory, filePath, content,
12237
10834
  const stableDirectory = await openStableDirectoryFromRoot(trustedRoot, directory, errorMessage, platform);
12238
10835
  directoryHandles = stableDirectory.handles;
12239
10836
  const pinnedDirectory = stableDirectory.pinnedDirectory;
12240
- tempPath = path15.join(pinnedDirectory, tempName);
12241
- const targetPath = path15.join(pinnedDirectory, targetName);
10837
+ tempPath = path13.join(pinnedDirectory, tempName);
10838
+ const targetPath = path13.join(pinnedDirectory, targetName);
12242
10839
  try {
12243
10840
  fileHandle = await open(
12244
10841
  tempPath,
@@ -12250,15 +10847,15 @@ async function writePrivateFileAtomicallyNoFollow(directory, filePath, content,
12250
10847
  throw error;
12251
10848
  }
12252
10849
  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);
10850
+ const tempMetadata = await lstat2(tempPath);
10851
+ assertStableRegularFile(tempMetadata, fileMetadata, await lstat2(tempPath), errorMessage);
10852
+ assertStableDirectory(stableDirectory.before, stableDirectory.opened, await lstat2(directory), errorMessage);
12256
10853
  await fileHandle.chmod(384);
12257
10854
  await fileHandle.writeFile(content, "utf8");
12258
10855
  await fileHandle.sync();
12259
- assertStableDirectory(stableDirectory.before, stableDirectory.opened, await lstat3(directory), errorMessage);
10856
+ assertStableDirectory(stableDirectory.before, stableDirectory.opened, await lstat2(directory), errorMessage);
12260
10857
  await rename2(tempPath, targetPath);
12261
- assertStableDirectory(stableDirectory.before, stableDirectory.opened, await lstat3(directory), errorMessage);
10858
+ assertStableDirectory(stableDirectory.before, stableDirectory.opened, await lstat2(directory), errorMessage);
12262
10859
  if (stableDirectory.handle) await syncVerifiedDirectory(stableDirectory.handle);
12263
10860
  const committedMetadata = await lstatPrivateTarget(targetPath, errorMessage);
12264
10861
  assertStableRegularFile(
@@ -12275,7 +10872,7 @@ async function writePrivateFileAtomicallyNoFollow(directory, filePath, content,
12275
10872
  }
12276
10873
  async function removePrivateFilesNoFollow(directory, fileNames, errorMessage, trustedRoot = directory, platform = process.platform) {
12277
10874
  if (fileNames.some(
12278
- (fileName) => fileName.length === 0 || fileName === "." || fileName === ".." || path15.basename(fileName) !== fileName
10875
+ (fileName) => fileName.length === 0 || fileName === "." || fileName === ".." || path13.basename(fileName) !== fileName
12279
10876
  )) {
12280
10877
  throw new Error(errorMessage);
12281
10878
  }
@@ -12285,9 +10882,9 @@ async function removePrivateFilesNoFollow(directory, fileNames, errorMessage, tr
12285
10882
  directoryHandles = stableDirectory.handles;
12286
10883
  const pinnedDirectory = stableDirectory.pinnedDirectory;
12287
10884
  for (const fileName of fileNames) {
12288
- await rm2(path15.join(pinnedDirectory, fileName), { force: true });
10885
+ await rm2(path13.join(pinnedDirectory, fileName), { force: true });
12289
10886
  }
12290
- assertStableDirectory(stableDirectory.before, stableDirectory.opened, await lstat3(directory), errorMessage);
10887
+ assertStableDirectory(stableDirectory.before, stableDirectory.opened, await lstat2(directory), errorMessage);
12291
10888
  if (stableDirectory.handle) await syncDirectoryHandle(stableDirectory.handle);
12292
10889
  } finally {
12293
10890
  await closeDirectoryHandles(directoryHandles);
@@ -12306,13 +10903,13 @@ var GeneratedBatchMarkerSchema = z2.object({
12306
10903
  }).strict();
12307
10904
  var BATCH_ERROR = "The generated draft batch state is not safe.";
12308
10905
  function batchDirectory(storage) {
12309
- return path16.join(storage.dir, "state", "support-passport", "generated-batches");
10906
+ return path14.join(storage.dir, "state", "support-passport", "generated-batches");
12310
10907
  }
12311
10908
  function batchFileName(batchId) {
12312
10909
  return `${BatchIdSchema.parse(batchId)}.json`;
12313
10910
  }
12314
10911
  function batchPath(storage, batchId) {
12315
- return path16.join(batchDirectory(storage), batchFileName(batchId));
10912
+ return path14.join(batchDirectory(storage), batchFileName(batchId));
12316
10913
  }
12317
10914
  function markerFor(context, batchId, size, complete) {
12318
10915
  return GeneratedBatchMarkerSchema.parse({
@@ -12736,19 +11333,19 @@ var SupportPassportAnswerModelInputSchema = z4.object({
12736
11333
  }).strict();
12737
11334
 
12738
11335
  // src/support-passport/owner-lock.ts
12739
- import { createHash as createHash9 } from "crypto";
12740
- import path17 from "path";
11336
+ import { createHash as createHash8 } from "crypto";
11337
+ import path15 from "path";
12741
11338
  var CARD_MUTATION_LOCK_STALE_MS = 6e4;
12742
11339
  var CARD_MUTATION_LOCK_MAX_WAIT_MS = 3e4;
12743
11340
  function computeSupportPassportOwnerLockKey(namespace, principal) {
12744
- return createHash9("sha256").update(JSON.stringify([namespace, principal])).digest("hex");
11341
+ return createHash8("sha256").update(JSON.stringify([namespace, principal])).digest("hex");
12745
11342
  }
12746
11343
  function supportPassportOwnerLockPath(storage, scope) {
12747
11344
  const ownerLockKey = scope.ownerKey ?? computeSupportPassportOwnerLockKey(scope.namespace, scope.principal);
12748
11345
  if (!/^[a-f0-9]{64}$/.test(ownerLockKey)) {
12749
11346
  throw new SupportPassportError("card_data_invalid", "The support passport owner scope is invalid.", 500);
12750
11347
  }
12751
- return path17.join(storage.dir, "state", `support-passport-cards-${ownerLockKey}.lock`);
11348
+ return path15.join(storage.dir, "state", `support-passport-cards-${ownerLockKey}.lock`);
12752
11349
  }
12753
11350
  async function withSupportPassportOwnerLock(storage, scope, task) {
12754
11351
  const lockPath = supportPassportOwnerLockPath(storage, scope);
@@ -13387,7 +11984,7 @@ var SupportPassportCardService = class {
13387
11984
  if (currentCard.card.status === "pending_review") {
13388
11985
  const priorId = currentMemory.frontmatter.supersedes;
13389
11986
  if (!priorId) return currentMemory;
13390
- const prior = await storage.getMemoryById(priorId);
11987
+ const prior = await storage.getMemoryByIdIncludingArchived(priorId);
13391
11988
  if (prior && ownsMemory(prior, namespace, principal) && prior.frontmatter.status === "superseded" && prior.frontmatter.supersededBy === replacement.card.cardId) {
13392
11989
  await this.restorePriorAfterApprovalFailure(
13393
11990
  storage,
@@ -13488,7 +12085,7 @@ var SupportPassportCardService = class {
13488
12085
  }
13489
12086
  async recoverReplacedDraft(storage, replacement, lock, principal, namespace, onCommitted) {
13490
12087
  if (!replacement.replacesDraftId) return;
13491
- const replacedDraft = await storage.getMemoryById(replacement.replacesDraftId);
12088
+ const replacedDraft = await storage.getMemoryByIdIncludingArchived(replacement.replacesDraftId);
13492
12089
  const projectedDraft = replacedDraft ? projectOwnedCard(replacedDraft, namespace, principal) : null;
13493
12090
  if (replacedDraft && projectedDraft?.card.status === "pending_review" && projectedDraft.card.revision === replacement.replacedRevision) {
13494
12091
  await this.requireOwnerLock(lock);
@@ -13510,7 +12107,7 @@ var SupportPassportCardService = class {
13510
12107
  return;
13511
12108
  }
13512
12109
  }
13513
- const currentDraft = await storage.getMemoryById(replacement.replacesDraftId);
12110
+ const currentDraft = await storage.getMemoryByIdIncludingArchived(replacement.replacesDraftId);
13514
12111
  if (currentDraft && ownsMemory(currentDraft, namespace, principal) && currentDraft.frontmatter.status === "rejected") {
13515
12112
  await this.finishPreparedDraftReplacement(
13516
12113
  storage,
@@ -13644,9 +12241,9 @@ var SupportPassportCardService = class {
13644
12241
  };
13645
12242
 
13646
12243
  // 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";
12244
+ import { createHash as createHash9, randomBytes, randomUUID as randomUUID4, timingSafeEqual } from "crypto";
12245
+ import { lstat as lstat3, open as open2, readdir as readdir3 } from "fs/promises";
12246
+ import path16 from "path";
13650
12247
  var GRANT_LOCK_STALE_MS = 3e4;
13651
12248
  var GRANT_LOCK_WAIT_MS = 5e3;
13652
12249
  var GRANT_LOCK_HEARTBEAT_MS = 1e4;
@@ -13669,7 +12266,7 @@ var MalformedGrantStateError = class extends Error {
13669
12266
  }
13670
12267
  };
13671
12268
  function sha256(domain, value) {
13672
- return createHash10("sha256").update(domain).update("\0").update(value).digest("hex");
12269
+ return createHash9("sha256").update(domain).update("\0").update(value).digest("hex");
13673
12270
  }
13674
12271
  function hashesMatch(left, right) {
13675
12272
  const leftBytes = Buffer.from(left, "hex");
@@ -13738,9 +12335,9 @@ var SupportPassportGrantStore = class {
13738
12335
  runWithHeldFileLock;
13739
12336
  syncDirectory;
13740
12337
  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");
12338
+ this.memoryDir = path16.resolve(expandTildePath(options.memoryDir));
12339
+ this.grantsDir = path16.join(this.memoryDir, "state", "support-passport", "grants");
12340
+ this.ownerIndexesDir = path16.join(this.grantsDir, "owners");
13744
12341
  this.now = options.now ?? (() => /* @__PURE__ */ new Date());
13745
12342
  this.makeSecret = options.makeSecret ?? (() => randomBytes(32));
13746
12343
  this.makeGrantId = options.makeGrantId ?? randomUUID4;
@@ -13953,11 +12550,11 @@ var SupportPassportGrantStore = class {
13953
12550
  }
13954
12551
  filePath(grantId) {
13955
12552
  const normalizedGrantId = normalizeGrantId(grantId);
13956
- return path18.join(this.grantsDir, `${normalizedGrantId}.json`);
12553
+ return path16.join(this.grantsDir, `${normalizedGrantId}.json`);
13957
12554
  }
13958
12555
  ownerIndexPath(ownerHash) {
13959
12556
  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`);
12557
+ return path16.join(this.ownerIndexesDir, `${ownerHash}.json`);
13961
12558
  }
13962
12559
  ownerHash(namespace, principalHash) {
13963
12560
  return sha256("support-passport-owner-index:v1", `${namespace}\0${principalHash}`);
@@ -14013,12 +12610,12 @@ var SupportPassportGrantStore = class {
14013
12610
  this.grantsDir,
14014
12611
  grantIds.map((grantId) => `${grantId}.json`),
14015
12612
  "support passport grant files must be regular files in a stable directory",
14016
- path18.parse(this.memoryDir).root
12613
+ path16.parse(this.memoryDir).root
14017
12614
  );
14018
12615
  }
14019
12616
  ownerMembershipDirectory(ownerHash) {
14020
12617
  if (!SAFE_OWNER_INDEX_HASH.test(ownerHash)) throw new Error("support passport owner index hash is invalid");
14021
- return path18.join(this.ownerIndexesDir, ownerHash);
12618
+ return path16.join(this.ownerIndexesDir, ownerHash);
14022
12619
  }
14023
12620
  async ensureOwnerMembershipDirectory(ownerHash) {
14024
12621
  const directory = this.ownerMembershipDirectory(ownerHash);
@@ -14033,11 +12630,11 @@ var SupportPassportGrantStore = class {
14033
12630
  const directory = await this.ensureOwnerMembershipDirectory(ownerHash);
14034
12631
  await writePrivateFileAtomicallyNoFollow(
14035
12632
  directory,
14036
- path18.join(directory, `${state.grantId}.json`),
12633
+ path16.join(directory, `${state.grantId}.json`),
14037
12634
  `${JSON.stringify({ schemaVersion: 1, grantId: state.grantId })}
14038
12635
  `,
14039
12636
  "support passport owner membership must be regular files in a stable directory",
14040
- path18.parse(this.memoryDir).root
12637
+ path16.parse(this.memoryDir).root
14041
12638
  );
14042
12639
  }
14043
12640
  async removeOwnerMembership(state) {
@@ -14047,7 +12644,7 @@ var SupportPassportGrantStore = class {
14047
12644
  directory,
14048
12645
  [`${state.grantId}.json`],
14049
12646
  "support passport owner membership must be regular files in a stable directory",
14050
- path18.parse(this.memoryDir).root
12647
+ path16.parse(this.memoryDir).root
14051
12648
  );
14052
12649
  }
14053
12650
  async removeStoredGrant(state) {
@@ -14148,11 +12745,11 @@ var SupportPassportGrantStore = class {
14148
12745
  const ownerHash = this.ownerHash(namespace, principalHash);
14149
12746
  const directory = await this.ensureOwnerMembershipDirectory(ownerHash);
14150
12747
  const grantIds = await withPrivateDirectoryNoFollow(
14151
- path18.parse(this.memoryDir).root,
12748
+ path16.parse(this.memoryDir).root,
14152
12749
  directory,
14153
12750
  "support passport owner membership must be regular files in a stable directory",
14154
12751
  async (pinnedDirectory) => {
14155
- const entries = await readdir4(pinnedDirectory, { withFileTypes: true });
12752
+ const entries = await readdir3(pinnedDirectory, { withFileTypes: true });
14156
12753
  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
12754
  }
14158
12755
  );
@@ -14179,7 +12776,7 @@ var SupportPassportGrantStore = class {
14179
12776
  this.ownerIndexesDir,
14180
12777
  filePath,
14181
12778
  "support passport owner indexes must be regular files in a stable directory",
14182
- path18.parse(this.memoryDir).root
12779
+ path16.parse(this.memoryDir).root
14183
12780
  );
14184
12781
  } catch (error) {
14185
12782
  if (error.code === "ENOENT") return [];
@@ -14206,7 +12803,7 @@ var SupportPassportGrantStore = class {
14206
12803
  async writeOwnerIndex(ownerHash, grantIds) {
14207
12804
  const filePath = this.ownerIndexPath(ownerHash);
14208
12805
  try {
14209
- const metadata = await lstat4(filePath);
12806
+ const metadata = await lstat3(filePath);
14210
12807
  if (metadata.isSymbolicLink() || !metadata.isFile()) {
14211
12808
  throw new Error("support passport owner indexes must be regular files");
14212
12809
  }
@@ -14219,7 +12816,7 @@ var SupportPassportGrantStore = class {
14219
12816
  `${JSON.stringify({ schemaVersion: 1, ownerHash, grantIds }, null, 2)}
14220
12817
  `,
14221
12818
  "support passport owner indexes must be regular files in a stable directory",
14222
- path18.parse(this.memoryDir).root
12819
+ path16.parse(this.memoryDir).root
14223
12820
  );
14224
12821
  }
14225
12822
  async readState(grantId) {
@@ -14229,7 +12826,7 @@ var SupportPassportGrantStore = class {
14229
12826
  this.grantsDir,
14230
12827
  filePath,
14231
12828
  "support passport grant files must be regular files in a stable directory",
14232
- path18.parse(this.memoryDir).root
12829
+ path16.parse(this.memoryDir).root
14233
12830
  );
14234
12831
  try {
14235
12832
  const state = SupportPassportGrantStateSchema.parse(JSON.parse(content));
@@ -14248,7 +12845,7 @@ var SupportPassportGrantStore = class {
14248
12845
  async writeState(state, requireAbsent = false) {
14249
12846
  const filePath = this.filePath(state.grantId);
14250
12847
  try {
14251
- const metadata = await lstat4(filePath);
12848
+ const metadata = await lstat3(filePath);
14252
12849
  if (metadata.isSymbolicLink() || !metadata.isFile())
14253
12850
  throw new Error("support passport grant files must be regular files");
14254
12851
  if (requireAbsent) {
@@ -14263,7 +12860,7 @@ var SupportPassportGrantStore = class {
14263
12860
  `${JSON.stringify(state, null, 2)}
14264
12861
  `,
14265
12862
  "support passport grant files must be regular files in a stable directory",
14266
- path18.parse(this.memoryDir).root
12863
+ path16.parse(this.memoryDir).root
14267
12864
  );
14268
12865
  }
14269
12866
  async ensureSafeDirectories() {
@@ -14297,8 +12894,8 @@ var SupportPassportGrantStore = class {
14297
12894
  void 0
14298
12895
  );
14299
12896
  this.memoryDir = configuredMemoryDir;
14300
- this.grantsDir = path18.join(configuredMemoryDir, "state", "support-passport", "grants");
14301
- this.ownerIndexesDir = path18.join(this.grantsDir, "owners");
12897
+ this.grantsDir = path16.join(configuredMemoryDir, "state", "support-passport", "grants");
12898
+ this.ownerIndexesDir = path16.join(this.grantsDir, "owners");
14302
12899
  })();
14303
12900
  }
14304
12901
  const currentAttempt = this.memoryRootReady;
@@ -14312,12 +12909,12 @@ var SupportPassportGrantStore = class {
14312
12909
  async withMutationLock(task) {
14313
12910
  await this.ensureSafeDirectories();
14314
12911
  return await withPrivateDirectoryNoFollow(
14315
- path18.parse(this.memoryDir).root,
12912
+ path16.parse(this.memoryDir).root,
14316
12913
  this.grantsDir,
14317
12914
  "support passport grant lock directory must remain inside the memory directory",
14318
12915
  async (pinnedDirectory) => await this.withExclusiveLock(
14319
12916
  `support-passport-grants:${this.grantsDir}`,
14320
- path18.join(pinnedDirectory, ".grants.lock"),
12917
+ path16.join(pinnedDirectory, ".grants.lock"),
14321
12918
  task
14322
12919
  )
14323
12920
  );
@@ -14326,12 +12923,12 @@ var SupportPassportGrantStore = class {
14326
12923
  const normalizedGrantId = normalizeGrantId(grantId);
14327
12924
  await this.ensureSafeDirectories();
14328
12925
  return await withPrivateDirectoryNoFollow(
14329
- path18.parse(this.memoryDir).root,
12926
+ path16.parse(this.memoryDir).root,
14330
12927
  this.grantsDir,
14331
12928
  "support passport grant lock directory must remain inside the memory directory",
14332
12929
  async (pinnedDirectory) => await this.withExclusiveLock(
14333
12930
  `support-passport-grant:${this.grantsDir}:${normalizedGrantId}`,
14334
- path18.join(pinnedDirectory, `.${normalizedGrantId}.lock`),
12931
+ path16.join(pinnedDirectory, `.${normalizedGrantId}.lock`),
14335
12932
  task
14336
12933
  )
14337
12934
  );
@@ -14339,12 +12936,12 @@ var SupportPassportGrantStore = class {
14339
12936
  async withOwnerIndexLock(ownerHash, task) {
14340
12937
  await this.ensureSafeDirectories();
14341
12938
  return await withPrivateDirectoryNoFollow(
14342
- path18.parse(this.memoryDir).root,
12939
+ path16.parse(this.memoryDir).root,
14343
12940
  this.ownerIndexesDir,
14344
12941
  "support passport owner lock directory must remain inside the memory directory",
14345
12942
  async (pinnedDirectory) => await this.withExclusiveLock(
14346
12943
  `support-passport-owner:${this.ownerIndexesDir}:${ownerHash}`,
14347
- path18.join(pinnedDirectory, `.${ownerHash}.lock`),
12944
+ path16.join(pinnedDirectory, `.${ownerHash}.lock`),
14348
12945
  task
14349
12946
  )
14350
12947
  );
@@ -15181,8 +13778,8 @@ var SupportPassportModelAdapter = class {
15181
13778
  };
15182
13779
 
15183
13780
  // src/support-passport/model-audit.ts
15184
- import { createHash as createHash11 } from "crypto";
15185
- import path19 from "path";
13781
+ import { createHash as createHash10 } from "crypto";
13782
+ import path17 from "path";
15186
13783
  import { z as z5 } from "zod";
15187
13784
  var HashSchema = z5.string().regex(/^[a-f0-9]{64}$/);
15188
13785
  var SupportPassportModelAuditRecordSchema = z5.object({
@@ -15219,7 +13816,7 @@ var SupportPassportModelAuditRecordSchema = z5.object({
15219
13816
  }
15220
13817
  });
15221
13818
  function hashSupportPassportAuditValues(domain, values) {
15222
- return createHash11("sha256").update(`support-passport-audit:${domain}:v1`).update("\0").update([...values].sort().join("\0")).digest("hex");
13819
+ return createHash10("sha256").update(`support-passport-audit:${domain}:v1`).update("\0").update([...values].sort().join("\0")).digest("hex");
15223
13820
  }
15224
13821
  var SupportPassportModelAuditStore = class {
15225
13822
  memoryDir;
@@ -15227,15 +13824,15 @@ var SupportPassportModelAuditStore = class {
15227
13824
  memoryRootReady;
15228
13825
  runWithHeldFileLock;
15229
13826
  constructor(options) {
15230
- this.memoryDir = path19.resolve(expandTildePath(options.memoryDir));
15231
- this.auditDir = path19.join(this.memoryDir, "state", "support-passport", "audit");
13827
+ this.memoryDir = path17.resolve(expandTildePath(options.memoryDir));
13828
+ this.auditDir = path17.join(this.memoryDir, "state", "support-passport", "audit");
15232
13829
  this.runWithHeldFileLock = options.withHeldFileLock ?? withHeldFileLock;
15233
13830
  }
15234
13831
  async record(input) {
15235
13832
  const record = SupportPassportModelAuditRecordSchema.parse(input);
15236
13833
  await this.ensureSafeDirectories();
15237
13834
  const day = record.occurredAt.slice(0, 10);
15238
- const filePath = path19.join(this.auditDir, `${day}.jsonl`);
13835
+ const filePath = path17.join(this.auditDir, `${day}.jsonl`);
15239
13836
  await serializeMutations(
15240
13837
  `support-passport-audit:${filePath}`,
15241
13838
  () => withPrivateDirectoryNoFollow(
@@ -15243,7 +13840,7 @@ var SupportPassportModelAuditStore = class {
15243
13840
  this.auditDir,
15244
13841
  "support passport audit directory must remain inside the memory directory",
15245
13842
  async (pinnedDirectory) => await this.runWithHeldFileLock(
15246
- path19.join(pinnedDirectory, `.${day}.lock`),
13843
+ path17.join(pinnedDirectory, `.${day}.lock`),
15247
13844
  {
15248
13845
  staleMs: 3e4,
15249
13846
  maxWaitMs: 5e3,
@@ -15280,7 +13877,7 @@ var SupportPassportModelAuditStore = class {
15280
13877
  "support passport memory directory must be a stable directory"
15281
13878
  );
15282
13879
  this.memoryDir = configuredMemoryDir;
15283
- this.auditDir = path19.join(configuredMemoryDir, "state", "support-passport", "audit");
13880
+ this.auditDir = path17.join(configuredMemoryDir, "state", "support-passport", "audit");
15284
13881
  })();
15285
13882
  }
15286
13883
  const currentAttempt = this.memoryRootReady;
@@ -15294,7 +13891,7 @@ var SupportPassportModelAuditStore = class {
15294
13891
  };
15295
13892
 
15296
13893
  // src/support-passport/model-service.ts
15297
- import { createHash as createHash12 } from "crypto";
13894
+ import { createHash as createHash11 } from "crypto";
15298
13895
  import { z as z6 } from "zod";
15299
13896
  var DraftServiceInputSchema = z6.object({
15300
13897
  principal: z6.string().trim().min(1).max(512),
@@ -15330,7 +13927,7 @@ function supportPassportSourceContent(memory) {
15330
13927
  return hasStructuredAttributes(memory.frontmatter.structuredAttributes) ? stripAttributesSuffix(memory.content) : memory.content;
15331
13928
  }
15332
13929
  function computeSupportPassportSourceRevision(content, structuredAttributes) {
15333
- return createHash12("sha256").update("support-passport-source:v1\0").update(hasStructuredAttributes(structuredAttributes) ? stripAttributesSuffix(content) : content).digest("hex");
13930
+ return createHash11("sha256").update("support-passport-source:v1\0").update(hasStructuredAttributes(structuredAttributes) ? stripAttributesSuffix(content) : content).digest("hex");
15334
13931
  }
15335
13932
  function isSupportPassportSourceEligible(memory) {
15336
13933
  const status = memory.frontmatter.status ?? "active";
@@ -18827,8 +17424,8 @@ var EngramAccessService = class extends SupportPassportAccessServiceBase {
18827
17424
  async offlineSyncSnapshot(options = {}) {
18828
17425
  const resolvedNamespace = this.resolveReadableNamespace(options.namespace, options.principal);
18829
17426
  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 }));
17427
+ const storageHash = createHash12("sha256").update(storage.dir).digest("hex").slice(0, 16);
17428
+ const deletions = [...await storage.readDeletionRevisions()].map(([path18, mtimeMs]) => ({ path: path18, mtimeMs }));
18832
17429
  const snapshotBuilder = options.includeContent === false && options.baseFiles && options.baseFiles.length > 0 ? buildOfflineSyncSnapshotFromBase : buildOfflineSyncSnapshot;
18833
17430
  const snapshot = await snapshotBuilder({
18834
17431
  root: storage.dir,
@@ -18851,10 +17448,10 @@ var EngramAccessService = class extends SupportPassportAccessServiceBase {
18851
17448
  async offlineSyncSnapshotStream(options = {}) {
18852
17449
  const resolvedNamespace = this.resolveReadableNamespace(options.namespace, options.principal);
18853
17450
  const storage = await offlineSyncStorageForSnapshot(this.orchestrator, resolvedNamespace);
18854
- const storageHash = createHash13("sha256").update(storage.dir).digest("hex").slice(0, 16);
17451
+ const storageHash = createHash12("sha256").update(storage.dir).digest("hex").slice(0, 16);
18855
17452
  const deletions = await filterOfflineSyncDeletionRevisions({
18856
17453
  root: storage.dir,
18857
- deletions: [...await storage.readDeletionRevisions()].map(([path20, mtimeMs]) => ({ path: path20, mtimeMs })),
17454
+ deletions: [...await storage.readDeletionRevisions()].map(([path18, mtimeMs]) => ({ path: path18, mtimeMs })),
18858
17455
  includeTranscripts: options.includeTranscripts !== false,
18859
17456
  userExcludeRegexps: this.offlineSyncUserExcludes
18860
17457
  });
@@ -18891,7 +17488,7 @@ var EngramAccessService = class extends SupportPassportAccessServiceBase {
18891
17488
  async offlineSyncFiles(options) {
18892
17489
  const resolvedNamespace = this.resolveReadableNamespace(options.namespace, options.principal);
18893
17490
  const storage = await offlineSyncStorageForSnapshot(this.orchestrator, resolvedNamespace);
18894
- const storageHash = createHash13("sha256").update(storage.dir).digest("hex").slice(0, 16);
17491
+ const storageHash = createHash12("sha256").update(storage.dir).digest("hex").slice(0, 16);
18895
17492
  try {
18896
17493
  const snapshot = await buildOfflineSyncSnapshotForPaths({
18897
17494
  root: storage.dir,
@@ -19567,4 +18164,4 @@ export {
19567
18164
  EngramAccessService,
19568
18165
  AccessAdminOpsSurface
19569
18166
  };
19570
- //# sourceMappingURL=chunk-RQE4TITU.js.map
18167
+ //# sourceMappingURL=chunk-IHGMRDEE.js.map