@remnic/core 9.69.87 → 9.69.89

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 (416) hide show
  1. package/dist/access-admin-ops-surface.js +56 -49
  2. package/dist/access-authorization-probe.js +57 -50
  3. package/dist/access-boundary.js +56 -49
  4. package/dist/access-citation-namespace.js +2 -2
  5. package/dist/access-cli.js +129 -122
  6. package/dist/access-cli.js.map +1 -1
  7. package/dist/access-extraction-force-flush.js +56 -49
  8. package/dist/access-http-briefing.js +57 -50
  9. package/dist/access-http-offline-stream.d.ts.map +1 -1
  10. package/dist/access-http-offline-stream.js +1 -1
  11. package/dist/access-http-query.js +58 -51
  12. package/dist/access-http.js +78 -71
  13. package/dist/access-identity-continuity-surface.js +56 -49
  14. package/dist/access-lcm-surface.js +56 -49
  15. package/dist/access-mcp-output-schemas.d.ts.map +1 -1
  16. package/dist/access-mcp-output-schemas.js +1 -1
  17. package/dist/access-mcp.js +69 -62
  18. package/dist/access-namespace-preflight.js +56 -49
  19. package/dist/access-observe-write-category.js +20 -13
  20. package/dist/access-observe-write-surface.js +56 -49
  21. package/dist/access-offline-manifest.js +16 -10
  22. package/dist/access-operations-batch.js +60 -53
  23. package/dist/access-operations.js +67 -60
  24. package/dist/access-recall-concurrency.js +56 -49
  25. package/dist/access-recall-response.js +56 -49
  26. package/dist/access-recall-surface.js +56 -49
  27. package/dist/access-schema.js +16 -7
  28. package/dist/access-service.d.ts.map +1 -1
  29. package/dist/access-service.js +56 -49
  30. package/dist/access-surface-catalog.js +58 -51
  31. package/dist/access-surface-catalog.js.map +1 -1
  32. package/dist/active-recall.js +24 -18
  33. package/dist/active-recall.js.map +1 -1
  34. package/dist/{auto-sync-6IPX2BAC.js → auto-sync-U5N3CB5Y.js} +7 -7
  35. package/dist/briefing.js +11 -11
  36. package/dist/buffer.js +7 -7
  37. package/dist/{capsule-crypto-7FJQINUR.js → capsule-crypto-GWVG7LGC.js} +2 -2
  38. package/dist/{capsule-merge-3MNURAQ3.js → capsule-merge-ZCXUPLNJ.js} +2 -2
  39. package/dist/causal-behavior.js +2 -2
  40. package/dist/causal-chain.js +2 -2
  41. package/dist/causal-consolidation.js +14 -14
  42. package/dist/causal-retrieval.js +2 -2
  43. package/dist/causal-trajectory-graph.js +2 -2
  44. package/dist/causal-trajectory.js +1 -1
  45. package/dist/{chunk-JE334SIA.js → chunk-22DYJLFN.js} +2 -2
  46. package/dist/{chunk-YTQGGO3K.js → chunk-22LMCQ5B.js} +85 -82
  47. package/dist/{chunk-YTQGGO3K.js.map → chunk-22LMCQ5B.js.map} +1 -1
  48. package/dist/{chunk-JGSQ6P4D.js → chunk-2FX374UI.js} +2 -2
  49. package/dist/{chunk-SY5KDWGU.js → chunk-2WLMWP2T.js} +2 -2
  50. package/dist/{chunk-6TT6HRE4.js → chunk-3AGHSQPM.js} +2 -2
  51. package/dist/{chunk-P6WFK4ZJ.js → chunk-3O5BB45T.js} +4 -4
  52. package/dist/{chunk-3C3J243X.js → chunk-3QKO4QN7.js} +3 -3
  53. package/dist/{chunk-KFCMMDHH.js → chunk-3YD44CH2.js} +2 -2
  54. package/dist/{chunk-FRCESVV6.js → chunk-4HUCP4R4.js} +18 -18
  55. package/dist/chunk-4HUCP4R4.js.map +1 -0
  56. package/dist/chunk-4NSLQ7EU.js +137 -0
  57. package/dist/chunk-4NSLQ7EU.js.map +1 -0
  58. package/dist/{chunk-7DE2NOON.js → chunk-4O4XCBOS.js} +3 -3
  59. package/dist/{chunk-GDYU6VF4.js → chunk-5AYUHSAU.js} +2 -2
  60. package/dist/{chunk-ICZQG4XE.js → chunk-5FAGCOZD.js} +4 -4
  61. package/dist/{chunk-VKQI47DJ.js → chunk-5FNZ3G6X.js} +4 -4
  62. package/dist/{chunk-CK5KOVHW.js → chunk-5R627MYY.js} +3 -2
  63. package/dist/{chunk-CK5KOVHW.js.map → chunk-5R627MYY.js.map} +1 -1
  64. package/dist/{chunk-VQNONC4E.js → chunk-5STPRPE7.js} +2 -2
  65. package/dist/{chunk-52II7PB6.js → chunk-645WOU5I.js} +4 -4
  66. package/dist/{chunk-SRZW7FNU.js → chunk-64ZUALXK.js} +2 -2
  67. package/dist/{chunk-4BZP2B4U.js → chunk-6MNKDTDI.js} +2 -2
  68. package/dist/{chunk-DUJYRVUD.js → chunk-6O2VUWV6.js} +3 -3
  69. package/dist/chunk-75PT4N7Q.js +75 -0
  70. package/dist/chunk-75PT4N7Q.js.map +1 -0
  71. package/dist/{chunk-HESDNYRB.js → chunk-76M5OK7V.js} +2 -2
  72. package/dist/{chunk-FAN73COB.js → chunk-7D7OUO5W.js} +2 -2
  73. package/dist/{chunk-DZ525SNQ.js → chunk-7QE46QXI.js} +1 -1
  74. package/dist/{chunk-VX6GCKBS.js → chunk-7WBSMXGC.js} +4 -4
  75. package/dist/{chunk-VVDWZRZG.js → chunk-A6RVIHHK.js} +3 -3
  76. package/dist/{chunk-M536WNTQ.js → chunk-AEJ3TE5H.js} +2 -2
  77. package/dist/{chunk-72JNNJJJ.js → chunk-AXC4WSF3.js} +3 -3
  78. package/dist/chunk-AXGJMDBS.js +684 -0
  79. package/dist/chunk-AXGJMDBS.js.map +1 -0
  80. package/dist/{chunk-UA5DX5C3.js → chunk-AZIOEOK4.js} +2 -2
  81. package/dist/{chunk-N4S4NUX5.js → chunk-B3O3IRZN.js} +1 -1
  82. package/dist/{chunk-XTYX6V52.js → chunk-BJVO4H5C.js} +2 -2
  83. package/dist/{chunk-7LCGFUMB.js → chunk-BUKK5SWA.js} +4 -4
  84. package/dist/{chunk-TM3RXL4G.js → chunk-BUQKSQXL.js} +2 -2
  85. package/dist/chunk-C6HPNPNK.js +64 -0
  86. package/dist/chunk-C6HPNPNK.js.map +1 -0
  87. package/dist/{chunk-RB776UH3.js → chunk-C7V3KPKJ.js} +235 -93
  88. package/dist/chunk-C7V3KPKJ.js.map +1 -0
  89. package/dist/{chunk-FOH7AMMI.js → chunk-CALBQ2NG.js} +71 -72
  90. package/dist/chunk-CALBQ2NG.js.map +1 -0
  91. package/dist/{chunk-37S3IMYB.js → chunk-DGS34QSY.js} +2 -2
  92. package/dist/{chunk-4IEOGIPB.js → chunk-DO4C4AXD.js} +2 -2
  93. package/dist/{chunk-SPSRGEDQ.js → chunk-EAQQ2FD3.js} +9 -9
  94. package/dist/{chunk-3BTFBQLO.js → chunk-EFHNFTWB.js} +49 -3
  95. package/dist/chunk-EFHNFTWB.js.map +1 -0
  96. package/dist/{chunk-C3QXITIP.js → chunk-EQUD7FP4.js} +2 -2
  97. package/dist/chunk-ETUZFFPU.js +218 -0
  98. package/dist/chunk-ETUZFFPU.js.map +1 -0
  99. package/dist/{chunk-YNDLCWXS.js → chunk-EZ25VE3G.js} +4 -4
  100. package/dist/{chunk-YITN5WXI.js → chunk-FC52YWAO.js} +2 -2
  101. package/dist/{chunk-ZI7QA4MK.js → chunk-FEIXG5FA.js} +2 -2
  102. package/dist/{chunk-CLXTDOKV.js → chunk-FUNBJQYR.js} +2 -2
  103. package/dist/{chunk-CLSYE5OZ.js → chunk-G2STTRYB.js} +2 -2
  104. package/dist/{chunk-TDYAIXHK.js → chunk-H36X4NRH.js} +5 -5
  105. package/dist/{chunk-3GQC3NMB.js → chunk-H56VY4BY.js} +5 -5
  106. package/dist/{chunk-PUKTBULQ.js → chunk-HWLIMQE2.js} +2 -2
  107. package/dist/{chunk-V2ES4WCZ.js → chunk-IIARQTZ2.js} +2 -2
  108. package/dist/{chunk-QEV26L2F.js → chunk-IKDRGVVJ.js} +2 -2
  109. package/dist/{chunk-WQZZDN5M.js → chunk-IVEHY2VT.js} +254 -377
  110. package/dist/chunk-IVEHY2VT.js.map +1 -0
  111. package/dist/{chunk-LS3XH3UE.js → chunk-IYIBGSHJ.js} +2 -2
  112. package/dist/{chunk-YSJTCOHR.js → chunk-J27JML5O.js} +2 -2
  113. package/dist/{chunk-AQK54Q7O.js → chunk-JB56XYHP.js} +2 -2
  114. package/dist/{chunk-NE6PHPLG.js → chunk-JBH26P62.js} +10 -10
  115. package/dist/{chunk-CWHV574S.js → chunk-JUT3OR2L.js} +6 -6
  116. package/dist/{chunk-6ET2VII7.js → chunk-JYG2334B.js} +2 -2
  117. package/dist/{chunk-LF5IGOOD.js → chunk-JYM4Y6SO.js} +16 -16
  118. package/dist/{chunk-FB64XE3R.js → chunk-JZ4TJHR2.js} +2 -2
  119. package/dist/{chunk-EHS5MJEF.js → chunk-KTKHO3UI.js} +3 -3
  120. package/dist/{chunk-WIKO4SCR.js → chunk-LHRQBMJN.js} +2 -2
  121. package/dist/{chunk-K4J4E7WV.js → chunk-LO4UKPKX.js} +2 -2
  122. package/dist/{chunk-JN72EPOE.js → chunk-MAAL6OZV.js} +7 -7
  123. package/dist/chunk-MAAL6OZV.js.map +1 -0
  124. package/dist/{chunk-MY2PLXSM.js → chunk-MCTM4YPL.js} +2 -1
  125. package/dist/{chunk-MY2PLXSM.js.map → chunk-MCTM4YPL.js.map} +1 -1
  126. package/dist/{chunk-6NQ4LSMS.js → chunk-MGZMC6WN.js} +47 -47
  127. package/dist/chunk-MSAI3Q7D.js +372 -0
  128. package/dist/chunk-MSAI3Q7D.js.map +1 -0
  129. package/dist/{chunk-BMYZTZ5D.js → chunk-MY7B3HYC.js} +2 -2
  130. package/dist/{chunk-NB3LRY4T.js → chunk-N4PYB235.js} +2 -2
  131. package/dist/{chunk-S3YM4SZQ.js → chunk-N7QV3CMX.js} +2 -2
  132. package/dist/{chunk-L6UZEAID.js → chunk-NJVR724O.js} +4 -4
  133. package/dist/{chunk-VLLD4TOB.js → chunk-NMZVDRVP.js} +2 -2
  134. package/dist/{chunk-P2WZHLUF.js → chunk-NOL7SEWN.js} +2 -2
  135. package/dist/{chunk-2NLLXCJG.js → chunk-OWHERGF2.js} +2 -2
  136. package/dist/{chunk-6L3PBSAR.js → chunk-PMNLL2TL.js} +2 -2
  137. package/dist/{chunk-VYCOJKSX.js → chunk-PO7NXNGC.js} +2 -2
  138. package/dist/{chunk-4IIMMZZK.js → chunk-PULDSMCJ.js} +10 -10
  139. package/dist/{chunk-G6SVZWPB.js → chunk-PZX3AQLF.js} +44 -1
  140. package/dist/chunk-PZX3AQLF.js.map +1 -0
  141. package/dist/{chunk-HBBHL4YF.js → chunk-QOXNTKXB.js} +2 -2
  142. package/dist/{chunk-CUCWX3MO.js → chunk-QZLCVO2V.js} +2 -2
  143. package/dist/{chunk-NE7I2RCT.js → chunk-R3X2T2LP.js} +2 -2
  144. package/dist/{chunk-S7GCT7NU.js → chunk-RBITPCMK.js} +8 -8
  145. package/dist/{chunk-EVBI7S4J.js → chunk-RMDGAAZF.js} +4 -4
  146. package/dist/{chunk-BJRAELDH.js → chunk-SCXURCVT.js} +3 -3
  147. package/dist/{chunk-EQ6YOIKO.js → chunk-ST2RQUXC.js} +3 -3
  148. package/dist/{chunk-CS52MFDV.js → chunk-SZG4WFAG.js} +2 -2
  149. package/dist/{chunk-BFO3IR56.js → chunk-TPEZ2SHV.js} +2 -2
  150. package/dist/chunk-TYT4TEQV.js +45 -0
  151. package/dist/chunk-TYT4TEQV.js.map +1 -0
  152. package/dist/{chunk-YRLHEEQT.js → chunk-U6VC6RP3.js} +2 -2
  153. package/dist/chunk-UCPGOUDZ.js +726 -0
  154. package/dist/chunk-UCPGOUDZ.js.map +1 -0
  155. package/dist/{chunk-MOQPEFLN.js → chunk-UP75KL3L.js} +2 -2
  156. package/dist/{chunk-W4AOR52H.js → chunk-UQDC3W77.js} +2 -2
  157. package/dist/{chunk-X7Y7WX73.js → chunk-UVYI6VIX.js} +1 -1
  158. package/dist/{chunk-D5F7TKMH.js → chunk-V4JZCTMK.js} +2 -2
  159. package/dist/{chunk-MQJL6CDZ.js → chunk-VA4O3U7U.js} +4 -4
  160. package/dist/{chunk-4CDYONWO.js → chunk-VDO32NLK.js} +3 -3
  161. package/dist/{chunk-SOZUJCME.js → chunk-VHDKPGMG.js} +6 -6
  162. package/dist/{chunk-QWW2JDDX.js → chunk-WNRTXEWW.js} +6 -6
  163. package/dist/{chunk-NR2ASHBL.js → chunk-XOV7NRY5.js} +2 -2
  164. package/dist/{chunk-KP7SANCF.js → chunk-YPI4RQWV.js} +2 -2
  165. package/dist/{chunk-JKMHZF3Q.js → chunk-YSWJXOOL.js} +2 -2
  166. package/dist/{chunk-LQG5O5EP.js → chunk-Z3O53WZR.js} +2 -2
  167. package/dist/{chunk-QVS22WTO.js → chunk-ZG5DWWKK.js} +2 -2
  168. package/dist/cli.js +99 -92
  169. package/dist/coding/export-okf-codegraph.js +12 -12
  170. package/dist/coding/pre-action-gate.js +2 -2
  171. package/dist/compounding/engine.js +12 -12
  172. package/dist/config.js +24 -18
  173. package/dist/connectors/codex-materialize-runner.js +11 -11
  174. package/dist/connectors/index.js +11 -11
  175. package/dist/console/state.d.ts +30 -0
  176. package/dist/console/state.d.ts.map +1 -1
  177. package/dist/contradiction/index.js +5 -5
  178. package/dist/convergence-refresh.js +13 -13
  179. package/dist/corpus-watermark.js +13 -13
  180. package/dist/dashboard-runtime.js +2 -2
  181. package/dist/deep-recall-http-glue.js +16 -8
  182. package/dist/embedding-fallback.d.ts +41 -31
  183. package/dist/embedding-fallback.d.ts.map +1 -1
  184. package/dist/embedding-fallback.js +9 -1
  185. package/dist/embedding-generation-lock.d.ts +49 -0
  186. package/dist/embedding-generation-lock.d.ts.map +1 -0
  187. package/dist/embedding-generation-lock.js +19 -0
  188. package/dist/embedding-index-storage.d.ts +276 -0
  189. package/dist/embedding-index-storage.d.ts.map +1 -0
  190. package/dist/embedding-index-storage.js +28 -0
  191. package/dist/entity-retrieval.js +12 -12
  192. package/dist/event-order-recall.js +3 -3
  193. package/dist/explicit-capture.js +6 -6
  194. package/dist/external-wiki-access.js +57 -50
  195. package/dist/extraction.js +17 -17
  196. package/dist/{first-start-migration-7OATHJKB.js → first-start-migration-GAT7G733.js} +4 -4
  197. package/dist/{graph-edge-decay-KQGS3L3B.js → graph-edge-decay-MKIRZ762.js} +5 -5
  198. package/dist/graph-jsonl.js +3 -3
  199. package/dist/graph-snapshot.js +3 -3
  200. package/dist/graph.js +2 -2
  201. package/dist/harmonic-retrieval.js +1 -1
  202. package/dist/index.d.ts +2 -0
  203. package/dist/index.d.ts.map +1 -1
  204. package/dist/index.js +195 -164
  205. package/dist/lcm/engine.js +2 -2
  206. package/dist/lcm/index.js +5 -5
  207. package/dist/local-llm.js +2 -2
  208. package/dist/location/index.js +14 -14
  209. package/dist/maintenance/memory-governance.js +11 -11
  210. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +11 -11
  211. package/dist/maintenance/rebuild-memory-projection.js +12 -12
  212. package/dist/memory-browse-operations.js +57 -50
  213. package/dist/memory-subject.js +3 -3
  214. package/dist/namespaces/migrate.js +12 -12
  215. package/dist/namespaces/storage.js +11 -11
  216. package/dist/offline-sync-changeset-generations.d.ts +82 -0
  217. package/dist/offline-sync-changeset-generations.d.ts.map +1 -0
  218. package/dist/offline-sync-changeset-generations.js +21 -0
  219. package/dist/offline-sync-embedding-generation.d.ts +257 -0
  220. package/dist/offline-sync-embedding-generation.d.ts.map +1 -0
  221. package/dist/offline-sync-embedding-generation.js +44 -0
  222. package/dist/offline-sync-embedding-generation.js.map +1 -0
  223. package/dist/offline-sync-exclude-globs.d.ts +15 -0
  224. package/dist/offline-sync-exclude-globs.d.ts.map +1 -1
  225. package/dist/offline-sync-exclude-globs.js +11 -3
  226. package/dist/offline-sync-file-io.d.ts +7 -0
  227. package/dist/offline-sync-file-io.d.ts.map +1 -1
  228. package/dist/offline-sync-file-io.js +14 -2
  229. package/dist/offline-sync-impression-drain.js +3 -3
  230. package/dist/offline-sync-runtime-state.d.ts +5 -0
  231. package/dist/offline-sync-runtime-state.d.ts.map +1 -0
  232. package/dist/offline-sync-runtime-state.js +14 -0
  233. package/dist/offline-sync-runtime-state.js.map +1 -0
  234. package/dist/offline-sync-snapshot-stream.d.ts +26 -0
  235. package/dist/offline-sync-snapshot-stream.d.ts.map +1 -0
  236. package/dist/offline-sync-snapshot-stream.js +29 -0
  237. package/dist/offline-sync-snapshot-stream.js.map +1 -0
  238. package/dist/offline-sync-upload-staging.d.ts +34 -0
  239. package/dist/offline-sync-upload-staging.d.ts.map +1 -0
  240. package/dist/offline-sync-upload-staging.js +26 -0
  241. package/dist/offline-sync-upload-staging.js.map +1 -0
  242. package/dist/offline-sync.d.ts +58 -28
  243. package/dist/offline-sync.d.ts.map +1 -1
  244. package/dist/offline-sync.js +22 -8
  245. package/dist/operator-doctor-corpus.js +14 -14
  246. package/dist/operator-toolkit.js +35 -29
  247. package/dist/orchestration/maintenance.js +22 -22
  248. package/dist/orchestrator.d.ts.map +1 -1
  249. package/dist/orchestrator.js +129 -122
  250. package/dist/recall-navigation-operations.js +57 -50
  251. package/dist/recall-navigation.js +56 -49
  252. package/dist/reconcile/manifest.js +4 -4
  253. package/dist/{resolution-DNX7FO7A.js → resolution-K4A3VPKZ.js} +6 -6
  254. package/dist/resolution-K4A3VPKZ.js.map +1 -0
  255. package/dist/resume-bundles.js +25 -19
  256. package/dist/salvage-envelope.js +5 -5
  257. package/dist/secure-store/index.js +2 -2
  258. package/dist/secure-store/secure-fs.d.ts +14 -1
  259. package/dist/secure-store/secure-fs.d.ts.map +1 -1
  260. package/dist/semantic-consolidation.js +12 -12
  261. package/dist/semantic-rule-promotion.js +11 -11
  262. package/dist/semantic-rule-verifier.js +11 -11
  263. package/dist/source-agent-qualifier.js +14 -14
  264. package/dist/standup/build.js +11 -11
  265. package/dist/{state-ITXJKXRE.js → state-JB47KHYV.js} +2 -2
  266. package/dist/state-JB47KHYV.js.map +1 -0
  267. package/dist/storage.d.ts +9 -3
  268. package/dist/storage.d.ts.map +1 -1
  269. package/dist/storage.js +10 -10
  270. package/dist/subject-config.js +4 -4
  271. package/dist/summarizer.js +3 -3
  272. package/dist/support-passport/index.js +59 -52
  273. package/dist/support-passport/offline-sync-guard.d.ts +6 -2
  274. package/dist/support-passport/offline-sync-guard.d.ts.map +1 -1
  275. package/dist/{trace-ZFVRH4GO.js → trace-LXXCMZJA.js} +3 -3
  276. package/dist/transfer/backup.js +2 -2
  277. package/dist/transfer/capsule-export.js +2 -2
  278. package/dist/transfer/capsule-import.js +3 -3
  279. package/dist/transfer/export-okf.js +12 -12
  280. package/dist/{tui-55UJMJX7.js → tui-2Z5WOV7L.js} +3 -3
  281. package/dist/tui-2Z5WOV7L.js.map +1 -0
  282. package/dist/verified-recall.js +11 -11
  283. package/dist/who-knows-cli.js +12 -12
  284. package/dist/who-knows.js +11 -11
  285. package/dist/write-envelope.js +4 -4
  286. package/package.json +2 -2
  287. package/src/access-http-offline-stream.ts +3 -0
  288. package/src/access-mcp-output-schemas.ts +1 -0
  289. package/src/access-service.ts +7 -18
  290. package/src/console/state.test.ts +56 -0
  291. package/src/console/state.ts +83 -0
  292. package/src/embedding-fallback.ts +325 -141
  293. package/src/embedding-generation-lock.ts +141 -0
  294. package/src/embedding-index-storage.test.ts +245 -0
  295. package/src/embedding-index-storage.ts +1068 -0
  296. package/src/index.ts +3 -3
  297. package/src/offline-sync-changeset-generations.test.ts +962 -0
  298. package/src/offline-sync-changeset-generations.ts +549 -0
  299. package/src/offline-sync-embedding-generation.test.ts +2173 -0
  300. package/src/offline-sync-embedding-generation.ts +1153 -0
  301. package/src/offline-sync-exclude-globs.ts +112 -0
  302. package/src/offline-sync-file-io.ts +48 -0
  303. package/src/offline-sync-runtime-state.ts +48 -0
  304. package/src/offline-sync-snapshot-stream.ts +99 -0
  305. package/src/offline-sync-upload-staging.ts +291 -0
  306. package/src/offline-sync.test.ts +164 -1
  307. package/src/offline-sync.ts +372 -454
  308. package/src/orchestrator.ts +2 -1
  309. package/src/secure-store/secure-fs.ts +26 -6
  310. package/src/storage.ts +11 -6
  311. package/src/support-passport/offline-sync-guard.ts +16 -2
  312. package/dist/chunk-3BTFBQLO.js.map +0 -1
  313. package/dist/chunk-AREGMX2J.js +0 -50
  314. package/dist/chunk-AREGMX2J.js.map +0 -1
  315. package/dist/chunk-FOH7AMMI.js.map +0 -1
  316. package/dist/chunk-FRCESVV6.js.map +0 -1
  317. package/dist/chunk-G6SVZWPB.js.map +0 -1
  318. package/dist/chunk-JN72EPOE.js.map +0 -1
  319. package/dist/chunk-RB776UH3.js.map +0 -1
  320. package/dist/chunk-WQZZDN5M.js.map +0 -1
  321. /package/dist/{auto-sync-6IPX2BAC.js.map → auto-sync-U5N3CB5Y.js.map} +0 -0
  322. /package/dist/{capsule-crypto-7FJQINUR.js.map → capsule-crypto-GWVG7LGC.js.map} +0 -0
  323. /package/dist/{capsule-merge-3MNURAQ3.js.map → capsule-merge-ZCXUPLNJ.js.map} +0 -0
  324. /package/dist/{chunk-JE334SIA.js.map → chunk-22DYJLFN.js.map} +0 -0
  325. /package/dist/{chunk-JGSQ6P4D.js.map → chunk-2FX374UI.js.map} +0 -0
  326. /package/dist/{chunk-SY5KDWGU.js.map → chunk-2WLMWP2T.js.map} +0 -0
  327. /package/dist/{chunk-6TT6HRE4.js.map → chunk-3AGHSQPM.js.map} +0 -0
  328. /package/dist/{chunk-P6WFK4ZJ.js.map → chunk-3O5BB45T.js.map} +0 -0
  329. /package/dist/{chunk-3C3J243X.js.map → chunk-3QKO4QN7.js.map} +0 -0
  330. /package/dist/{chunk-KFCMMDHH.js.map → chunk-3YD44CH2.js.map} +0 -0
  331. /package/dist/{chunk-7DE2NOON.js.map → chunk-4O4XCBOS.js.map} +0 -0
  332. /package/dist/{chunk-GDYU6VF4.js.map → chunk-5AYUHSAU.js.map} +0 -0
  333. /package/dist/{chunk-ICZQG4XE.js.map → chunk-5FAGCOZD.js.map} +0 -0
  334. /package/dist/{chunk-VKQI47DJ.js.map → chunk-5FNZ3G6X.js.map} +0 -0
  335. /package/dist/{chunk-VQNONC4E.js.map → chunk-5STPRPE7.js.map} +0 -0
  336. /package/dist/{chunk-52II7PB6.js.map → chunk-645WOU5I.js.map} +0 -0
  337. /package/dist/{chunk-SRZW7FNU.js.map → chunk-64ZUALXK.js.map} +0 -0
  338. /package/dist/{chunk-4BZP2B4U.js.map → chunk-6MNKDTDI.js.map} +0 -0
  339. /package/dist/{chunk-DUJYRVUD.js.map → chunk-6O2VUWV6.js.map} +0 -0
  340. /package/dist/{chunk-HESDNYRB.js.map → chunk-76M5OK7V.js.map} +0 -0
  341. /package/dist/{chunk-FAN73COB.js.map → chunk-7D7OUO5W.js.map} +0 -0
  342. /package/dist/{chunk-DZ525SNQ.js.map → chunk-7QE46QXI.js.map} +0 -0
  343. /package/dist/{chunk-VX6GCKBS.js.map → chunk-7WBSMXGC.js.map} +0 -0
  344. /package/dist/{chunk-VVDWZRZG.js.map → chunk-A6RVIHHK.js.map} +0 -0
  345. /package/dist/{chunk-M536WNTQ.js.map → chunk-AEJ3TE5H.js.map} +0 -0
  346. /package/dist/{chunk-72JNNJJJ.js.map → chunk-AXC4WSF3.js.map} +0 -0
  347. /package/dist/{chunk-UA5DX5C3.js.map → chunk-AZIOEOK4.js.map} +0 -0
  348. /package/dist/{chunk-N4S4NUX5.js.map → chunk-B3O3IRZN.js.map} +0 -0
  349. /package/dist/{chunk-XTYX6V52.js.map → chunk-BJVO4H5C.js.map} +0 -0
  350. /package/dist/{chunk-7LCGFUMB.js.map → chunk-BUKK5SWA.js.map} +0 -0
  351. /package/dist/{chunk-TM3RXL4G.js.map → chunk-BUQKSQXL.js.map} +0 -0
  352. /package/dist/{chunk-37S3IMYB.js.map → chunk-DGS34QSY.js.map} +0 -0
  353. /package/dist/{chunk-4IEOGIPB.js.map → chunk-DO4C4AXD.js.map} +0 -0
  354. /package/dist/{chunk-SPSRGEDQ.js.map → chunk-EAQQ2FD3.js.map} +0 -0
  355. /package/dist/{chunk-C3QXITIP.js.map → chunk-EQUD7FP4.js.map} +0 -0
  356. /package/dist/{chunk-YNDLCWXS.js.map → chunk-EZ25VE3G.js.map} +0 -0
  357. /package/dist/{chunk-YITN5WXI.js.map → chunk-FC52YWAO.js.map} +0 -0
  358. /package/dist/{chunk-ZI7QA4MK.js.map → chunk-FEIXG5FA.js.map} +0 -0
  359. /package/dist/{chunk-CLXTDOKV.js.map → chunk-FUNBJQYR.js.map} +0 -0
  360. /package/dist/{chunk-CLSYE5OZ.js.map → chunk-G2STTRYB.js.map} +0 -0
  361. /package/dist/{chunk-TDYAIXHK.js.map → chunk-H36X4NRH.js.map} +0 -0
  362. /package/dist/{chunk-3GQC3NMB.js.map → chunk-H56VY4BY.js.map} +0 -0
  363. /package/dist/{chunk-PUKTBULQ.js.map → chunk-HWLIMQE2.js.map} +0 -0
  364. /package/dist/{chunk-V2ES4WCZ.js.map → chunk-IIARQTZ2.js.map} +0 -0
  365. /package/dist/{chunk-QEV26L2F.js.map → chunk-IKDRGVVJ.js.map} +0 -0
  366. /package/dist/{chunk-LS3XH3UE.js.map → chunk-IYIBGSHJ.js.map} +0 -0
  367. /package/dist/{chunk-YSJTCOHR.js.map → chunk-J27JML5O.js.map} +0 -0
  368. /package/dist/{chunk-AQK54Q7O.js.map → chunk-JB56XYHP.js.map} +0 -0
  369. /package/dist/{chunk-NE6PHPLG.js.map → chunk-JBH26P62.js.map} +0 -0
  370. /package/dist/{chunk-CWHV574S.js.map → chunk-JUT3OR2L.js.map} +0 -0
  371. /package/dist/{chunk-6ET2VII7.js.map → chunk-JYG2334B.js.map} +0 -0
  372. /package/dist/{chunk-LF5IGOOD.js.map → chunk-JYM4Y6SO.js.map} +0 -0
  373. /package/dist/{chunk-FB64XE3R.js.map → chunk-JZ4TJHR2.js.map} +0 -0
  374. /package/dist/{chunk-EHS5MJEF.js.map → chunk-KTKHO3UI.js.map} +0 -0
  375. /package/dist/{chunk-WIKO4SCR.js.map → chunk-LHRQBMJN.js.map} +0 -0
  376. /package/dist/{chunk-K4J4E7WV.js.map → chunk-LO4UKPKX.js.map} +0 -0
  377. /package/dist/{chunk-6NQ4LSMS.js.map → chunk-MGZMC6WN.js.map} +0 -0
  378. /package/dist/{chunk-BMYZTZ5D.js.map → chunk-MY7B3HYC.js.map} +0 -0
  379. /package/dist/{chunk-NB3LRY4T.js.map → chunk-N4PYB235.js.map} +0 -0
  380. /package/dist/{chunk-S3YM4SZQ.js.map → chunk-N7QV3CMX.js.map} +0 -0
  381. /package/dist/{chunk-L6UZEAID.js.map → chunk-NJVR724O.js.map} +0 -0
  382. /package/dist/{chunk-VLLD4TOB.js.map → chunk-NMZVDRVP.js.map} +0 -0
  383. /package/dist/{chunk-P2WZHLUF.js.map → chunk-NOL7SEWN.js.map} +0 -0
  384. /package/dist/{chunk-2NLLXCJG.js.map → chunk-OWHERGF2.js.map} +0 -0
  385. /package/dist/{chunk-6L3PBSAR.js.map → chunk-PMNLL2TL.js.map} +0 -0
  386. /package/dist/{chunk-VYCOJKSX.js.map → chunk-PO7NXNGC.js.map} +0 -0
  387. /package/dist/{chunk-4IIMMZZK.js.map → chunk-PULDSMCJ.js.map} +0 -0
  388. /package/dist/{chunk-HBBHL4YF.js.map → chunk-QOXNTKXB.js.map} +0 -0
  389. /package/dist/{chunk-CUCWX3MO.js.map → chunk-QZLCVO2V.js.map} +0 -0
  390. /package/dist/{chunk-NE7I2RCT.js.map → chunk-R3X2T2LP.js.map} +0 -0
  391. /package/dist/{chunk-S7GCT7NU.js.map → chunk-RBITPCMK.js.map} +0 -0
  392. /package/dist/{chunk-EVBI7S4J.js.map → chunk-RMDGAAZF.js.map} +0 -0
  393. /package/dist/{chunk-BJRAELDH.js.map → chunk-SCXURCVT.js.map} +0 -0
  394. /package/dist/{chunk-EQ6YOIKO.js.map → chunk-ST2RQUXC.js.map} +0 -0
  395. /package/dist/{chunk-CS52MFDV.js.map → chunk-SZG4WFAG.js.map} +0 -0
  396. /package/dist/{chunk-BFO3IR56.js.map → chunk-TPEZ2SHV.js.map} +0 -0
  397. /package/dist/{chunk-YRLHEEQT.js.map → chunk-U6VC6RP3.js.map} +0 -0
  398. /package/dist/{chunk-MOQPEFLN.js.map → chunk-UP75KL3L.js.map} +0 -0
  399. /package/dist/{chunk-W4AOR52H.js.map → chunk-UQDC3W77.js.map} +0 -0
  400. /package/dist/{chunk-X7Y7WX73.js.map → chunk-UVYI6VIX.js.map} +0 -0
  401. /package/dist/{chunk-D5F7TKMH.js.map → chunk-V4JZCTMK.js.map} +0 -0
  402. /package/dist/{chunk-MQJL6CDZ.js.map → chunk-VA4O3U7U.js.map} +0 -0
  403. /package/dist/{chunk-4CDYONWO.js.map → chunk-VDO32NLK.js.map} +0 -0
  404. /package/dist/{chunk-SOZUJCME.js.map → chunk-VHDKPGMG.js.map} +0 -0
  405. /package/dist/{chunk-QWW2JDDX.js.map → chunk-WNRTXEWW.js.map} +0 -0
  406. /package/dist/{chunk-NR2ASHBL.js.map → chunk-XOV7NRY5.js.map} +0 -0
  407. /package/dist/{chunk-KP7SANCF.js.map → chunk-YPI4RQWV.js.map} +0 -0
  408. /package/dist/{chunk-JKMHZF3Q.js.map → chunk-YSWJXOOL.js.map} +0 -0
  409. /package/dist/{chunk-LQG5O5EP.js.map → chunk-Z3O53WZR.js.map} +0 -0
  410. /package/dist/{chunk-QVS22WTO.js.map → chunk-ZG5DWWKK.js.map} +0 -0
  411. /package/dist/{graph-edge-decay-KQGS3L3B.js.map → embedding-generation-lock.js.map} +0 -0
  412. /package/dist/{resolution-DNX7FO7A.js.map → embedding-index-storage.js.map} +0 -0
  413. /package/dist/{first-start-migration-7OATHJKB.js.map → first-start-migration-GAT7G733.js.map} +0 -0
  414. /package/dist/{state-ITXJKXRE.js.map → graph-edge-decay-MKIRZ762.js.map} +0 -0
  415. /package/dist/{tui-55UJMJX7.js.map → offline-sync-changeset-generations.js.map} +0 -0
  416. /package/dist/{trace-ZFVRH4GO.js.map → trace-LXXCMZJA.js.map} +0 -0
@@ -2,24 +2,57 @@ import {
2
2
  DEFAULT_TRANSFER_EXCLUDE_DIRS
3
3
  } from "./chunk-UI3NYK34.js";
4
4
  import {
5
- prepareSafeArchiveRoot,
6
- resolveSafeArchiveTarget,
7
- sha256Bytes,
8
- validateArchiveRelativePath
9
- } from "./chunk-GCGJW34D.js";
5
+ cleanupOfflineUpload,
6
+ digestOfflineUploadStagingContent,
7
+ hashText,
8
+ pruneOfflineUploadStaging,
9
+ writeOfflineUploadChunk,
10
+ writeSafeFileFromUpload
11
+ } from "./chunk-ETUZFFPU.js";
12
+ import {
13
+ applyChangesetEmbeddingGenerations,
14
+ normalizeChangesetGenerations
15
+ } from "./chunk-MSAI3Q7D.js";
16
+ import {
17
+ applyIncomingEmbeddingGenerations,
18
+ assertEmbeddingGenerationStillIncluded,
19
+ computeOmittedEmbeddingGenerationPaths,
20
+ divergedEmbeddingGenerationDeferrals,
21
+ embeddingGenerationMembership,
22
+ isEmbeddingGenerationDirPath,
23
+ isPathInOmittedEmbeddingGeneration
24
+ } from "./chunk-AXGJMDBS.js";
10
25
  import {
11
- DEFAULT_OFFLINE_SYNC_EXCLUDE_GLOBS
12
- } from "./chunk-AREGMX2J.js";
26
+ isCanonicalRuntimeStatePath,
27
+ shouldDeleteAbsentIncomingOfflineRuntimeFile,
28
+ shouldPreferIncomingOfflineRuntimeFile
29
+ } from "./chunk-TYT4TEQV.js";
13
30
  import {
31
+ matchesOfflineSyncDefaultExclude
32
+ } from "./chunk-4NSLQ7EU.js";
33
+ import {
34
+ OFFLINE_SYNC_FAST_BASE_MTIME_TOLERANCE_MS,
35
+ SYNC_INTERNAL_DIR,
36
+ assertOfflineSyncMtimeMs,
14
37
  isEncryptedOfflineSyncFile,
15
38
  plainFileDigest,
16
39
  readPlainOfflineSyncFileChunk,
40
+ setSafeFileMtime,
17
41
  sha256OfflineSyncFile,
18
42
  shouldExcludeOfflineSyncFile
19
- } from "./chunk-3BTFBQLO.js";
43
+ } from "./chunk-EFHNFTWB.js";
44
+ import {
45
+ prepareSafeArchiveRoot,
46
+ resolveSafeArchiveTarget,
47
+ sha256Bytes,
48
+ validateArchiveRelativePath
49
+ } from "./chunk-GCGJW34D.js";
50
+ import {
51
+ withEmbeddingGenerationLock,
52
+ withEmbeddingGenerationLockIter
53
+ } from "./chunk-75PT4N7Q.js";
20
54
  import {
21
55
  CENSUS_MAX_MTIME_MS,
22
- isCensusMtimeMs,
23
56
  isSha256Hex
24
57
  } from "./chunk-LQWOFU6L.js";
25
58
  import {
@@ -27,18 +60,15 @@ import {
27
60
  } from "./chunk-P7FMDTKL.js";
28
61
 
29
62
  // src/offline-sync.ts
30
- import { createHash, randomUUID } from "crypto";
63
+ import { randomUUID } from "crypto";
31
64
  import {
32
65
  lstat,
33
66
  mkdir,
34
- open,
35
67
  readdir,
36
68
  readFile,
37
69
  rename,
38
- rm,
39
70
  stat,
40
71
  unlink,
41
- utimes,
42
72
  writeFile
43
73
  } from "fs/promises";
44
74
  import path from "path";
@@ -50,9 +80,6 @@ var OFFLINE_SYNC_FILE_CONTENT_TRANSFER_CHUNK_BYTES = 8 * 1024 * 1024;
50
80
  var OFFLINE_SYNC_APPLY_MAX_BODY_BYTES = 16 * 1024 * 1024;
51
81
  var OFFLINE_SYNC_SNAPSHOT_BASE_MAX_BODY_BYTES = 64 * 1024 * 1024;
52
82
  var OFFLINE_SYNC_MAX_MTIME_MS = CENSUS_MAX_MTIME_MS;
53
- var SYNC_INTERNAL_DIR = ".offline-sync";
54
- var OFFLINE_SYNC_UPLOAD_STAGING_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
55
- var OFFLINE_SYNC_FAST_BASE_MTIME_TOLERANCE_MS = 1e3;
56
83
  var OFFLINE_SYNC_FAST_BASE_CTIME_TOLERANCE_MS = 1;
57
84
  var EXCLUDED_FILE_NAMES = /* @__PURE__ */ new Set([
58
85
  ".sync-state.json"
@@ -61,45 +88,6 @@ var EXCLUDED_FILE_PREFIXES = [
61
88
  ".remnic-sync.",
62
89
  ".remnic-sync-state."
63
90
  ];
64
- function globToRegExp(glob) {
65
- if (typeof glob !== "string" || glob.length === 0) {
66
- throw new Error("offlineSyncExcludes entry must be a non-empty string");
67
- }
68
- if (glob.includes("\0")) {
69
- throw new Error("offlineSyncExcludes entry must not contain NUL bytes");
70
- }
71
- let source = "";
72
- for (let i = 0; i < glob.length; i += 1) {
73
- const ch = glob[i];
74
- if (ch === "*") {
75
- if (glob[i + 1] === "*") {
76
- if (glob[i + 2] === "/") {
77
- source += "(?:.*/)?";
78
- i += 2;
79
- continue;
80
- }
81
- source += ".*";
82
- i += 1;
83
- continue;
84
- }
85
- source += "[^/]*";
86
- continue;
87
- }
88
- if (ch === "?") {
89
- source += "[^/]";
90
- continue;
91
- }
92
- if (ch === "/") {
93
- source += "/";
94
- continue;
95
- }
96
- source += ch.replace(/[\\^$.+()|{}\[\]]/g, "\\$&");
97
- }
98
- return new RegExp(`^${source}$`);
99
- }
100
- function hashText(value) {
101
- return createHash("sha256").update(value).digest("hex");
102
- }
103
91
  function sha256Buffer(buffer) {
104
92
  return sha256Bytes(buffer);
105
93
  }
@@ -122,19 +110,6 @@ function assertNonNegativeInteger(value, field) {
122
110
  }
123
111
  return value;
124
112
  }
125
- function assertNonNegativeFinite(value, field) {
126
- if (typeof value !== "number" || !Number.isFinite(value) || value < 0) {
127
- throw new Error(`${field} must be a non-negative finite number`);
128
- }
129
- return value;
130
- }
131
- function assertOfflineSyncMtimeMs(value, field) {
132
- const mtimeMs = assertNonNegativeFinite(value, field);
133
- if (!isCensusMtimeMs(mtimeMs)) {
134
- throw new Error(`${field} must be within JavaScript Date range`);
135
- }
136
- return mtimeMs;
137
- }
138
113
  function assertBoolean(value, field) {
139
114
  if (typeof value !== "boolean") {
140
115
  throw new Error(`${field} must be a boolean`);
@@ -206,12 +181,17 @@ function snapshotBuilderDeletions(options) {
206
181
  if (deletions.length === 0) return deletions;
207
182
  const presentPaths = new Set(options.files.map((file) => file.path.toLowerCase()));
208
183
  const scopedPaths = options.paths ? new Set(options.paths.map((relPath) => relPath.toLowerCase())) : void 0;
209
- return deletions.filter((deletion) => (scopedPaths === void 0 || scopedPaths.has(deletion.path.toLowerCase())) && !presentPaths.has(deletion.path.toLowerCase()) && !(options.excludeNodeLocalState === false ? shouldExcludeRelPath(deletion.path, options.includeTranscripts) : shouldExcludePushRelPath(
184
+ return deletions.filter((deletion) => (scopedPaths === void 0 || scopedPaths.has(deletion.path.toLowerCase())) && !presentPaths.has(deletion.path.toLowerCase()) && !isDeletionInOmittedGeneration(deletion.path, options.omittedGenerationDirs) && !(options.excludeNodeLocalState === false ? shouldExcludeRelPath(deletion.path, options.includeTranscripts) : shouldExcludePushRelPath(
210
185
  deletion.path,
211
186
  options.includeTranscripts,
212
187
  options.userExcludeRegexps
213
188
  )));
214
189
  }
190
+ function isDeletionInOmittedGeneration(relPath, omittedGenerationDirs) {
191
+ if (!omittedGenerationDirs || omittedGenerationDirs.size === 0) return false;
192
+ const membership = embeddingGenerationMembership(relPath);
193
+ return membership !== null && omittedGenerationDirs.has(membership.shardDir);
194
+ }
215
195
  async function filterOfflineSyncDeletionRevisions(options) {
216
196
  const deletions = normalizeDeletionRevisions(options.deletions, "deletions");
217
197
  if (deletions === void 0) throw new Error("deletions must be an array");
@@ -222,9 +202,16 @@ async function filterOfflineSyncDeletionRevisions(options) {
222
202
  "root"
223
203
  );
224
204
  const includeTranscripts = options.includeTranscripts !== false;
205
+ const omission = await computeOmittedEmbeddingGenerationPaths({
206
+ rootAbs: root.abs,
207
+ userExcludeRegexps: options.userExcludeRegexps,
208
+ excludeFile: options.excludeFile,
209
+ isExcludedRelPath: (relPath) => shouldExcludePushRelPath(relPath, includeTranscripts, options.userExcludeRegexps)
210
+ });
211
+ const omittedDirs = new Set(omission.omittedDirs);
225
212
  const filtered = [];
226
213
  for (const deletion of deletions) {
227
- if (shouldExcludePushRelPath(deletion.path, includeTranscripts, options.userExcludeRegexps)) {
214
+ if (shouldExcludePushRelPath(deletion.path, includeTranscripts, options.userExcludeRegexps) || isDeletionInOmittedGeneration(deletion.path, omittedDirs)) {
228
215
  continue;
229
216
  }
230
217
  const filePath = path.join(root.abs, ...deletion.path.split("/"));
@@ -272,6 +259,22 @@ function normalizeOfflineSyncSnapshot(input, options = {}) {
272
259
  if (excludedPath) {
273
260
  throw new Error(`offline sync snapshot contains excluded path: ${excludedPath}`);
274
261
  }
262
+ let omittedEmbeddingGenerationDirs;
263
+ if (obj.omittedEmbeddingGenerationDirs !== void 0) {
264
+ if (!Array.isArray(obj.omittedEmbeddingGenerationDirs)) {
265
+ throw new Error("offline sync snapshot omittedEmbeddingGenerationDirs must be an array");
266
+ }
267
+ const seenDirs = /* @__PURE__ */ new Set();
268
+ for (const [index, entry] of obj.omittedEmbeddingGenerationDirs.entries()) {
269
+ if (typeof entry !== "string" || !isEmbeddingGenerationDirPath(entry) || seenDirs.has(entry)) {
270
+ throw new Error(
271
+ `omittedEmbeddingGenerationDirs[${index}] must be a unique canonical embeddings generation dir`
272
+ );
273
+ }
274
+ seenDirs.add(entry);
275
+ }
276
+ omittedEmbeddingGenerationDirs = [...seenDirs].sort((left, right) => left.localeCompare(right));
277
+ }
275
278
  return {
276
279
  format: OFFLINE_SYNC_SNAPSHOT_FORMAT,
277
280
  schemaVersion: 1,
@@ -279,7 +282,8 @@ function normalizeOfflineSyncSnapshot(input, options = {}) {
279
282
  sourceId,
280
283
  includeTranscripts,
281
284
  files,
282
- ...deletions === void 0 ? {} : { deletions }
285
+ ...deletions === void 0 ? {} : { deletions },
286
+ ...omittedEmbeddingGenerationDirs === void 0 ? {} : { omittedEmbeddingGenerationDirs }
283
287
  };
284
288
  }
285
289
  function normalizeOfflineSyncChangeset(input) {
@@ -347,13 +351,15 @@ function normalizeOfflineSyncChangeset(input) {
347
351
  if (excludedPath) {
348
352
  throw new Error(`offline sync changeset contains excluded path: ${excludedPath}`);
349
353
  }
354
+ const embeddingGenerations = normalizeChangesetGenerations(obj.embeddingGenerations, changes);
350
355
  return {
351
356
  format: OFFLINE_SYNC_CHANGESET_FORMAT,
352
357
  schemaVersion: 1,
353
358
  createdAt,
354
359
  sourceId,
355
360
  includeTranscripts,
356
- changes: changes.sort(compareByPath)
361
+ changes: changes.sort(compareByPath),
362
+ ...embeddingGenerations === void 0 ? {} : { embeddingGenerations }
357
363
  };
358
364
  }
359
365
  function normalizeIsoString(input, field) {
@@ -404,79 +410,12 @@ function shouldExcludePushRelPath(relPosix, includeTranscripts, userExcludeRegex
404
410
  if (userExcludeRegexps && userExcludeRegexps.some((re) => re.test(relPosix))) return true;
405
411
  return false;
406
412
  }
407
- var DEFAULT_OFFLINE_SYNC_EXCLUDE_REGEXPS = DEFAULT_OFFLINE_SYNC_EXCLUDE_GLOBS.map((glob) => globToRegExp(glob));
408
- function matchesOfflineSyncDefaultExclude(relPosix) {
409
- for (const regexp of DEFAULT_OFFLINE_SYNC_EXCLUDE_REGEXPS) {
410
- if (regexp.test(relPosix)) return true;
411
- }
412
- return false;
413
- }
414
- function compileOfflineSyncExcludeGlobs(globs) {
415
- const out = [];
416
- for (const entry of globs) {
417
- if (typeof entry !== "string" || entry.length === 0) {
418
- throw new Error("offlineSyncExcludes must contain only non-empty strings");
419
- }
420
- out.push(globToRegExp(entry));
421
- }
422
- return out;
423
- }
424
- function parseOfflineSyncExcludes(raw) {
425
- if (raw === void 0 || raw === null) return [];
426
- if (!Array.isArray(raw)) {
427
- throw new Error(
428
- `offlineSyncExcludes must be an array of non-empty glob strings; got ${typeof raw}`
429
- );
430
- }
431
- for (const entry of raw) {
432
- if (typeof entry !== "string" || entry.trim().length === 0) {
433
- throw new Error(
434
- "offlineSyncExcludes must contain only non-empty glob strings"
435
- );
436
- }
437
- }
438
- const globs = raw.map((entry) => entry.trim());
439
- compileOfflineSyncExcludeGlobs(globs);
440
- return globs;
441
- }
442
413
  function shouldIgnoreIncomingRuntimePath(relPosix) {
443
414
  if (isInternalRemnicStatePath(relPosix)) return true;
444
415
  const parts = relPosix.split("/");
445
416
  const basename = parts[parts.length - 1] ?? "";
446
417
  return isCanonicalRuntimeStatePath(parts) && basename.includes(".tmp-");
447
418
  }
448
- function isCanonicalRuntimeStatePath(parts) {
449
- if (parts[0] === "state") return true;
450
- return parts[0] === "namespaces" && parts.length >= 4 && parts[2] === "state";
451
- }
452
- var REMOTE_AUTHORITATIVE_RUNTIME_STATE_FILES = /* @__PURE__ */ new Set([
453
- ".artifact-write-version.log",
454
- ".memory-status-version.log",
455
- "buffer.json",
456
- "embeddings.json",
457
- "index_time.json",
458
- "last_intent.json",
459
- "last_qmd_recall.json",
460
- "last_recall.json",
461
- "lcm.sqlite-shm",
462
- "lcm.sqlite-wal",
463
- "memory-lifecycle-ledger.jsonl",
464
- "recall_impressions.jsonl"
465
- ]);
466
- var ABSENT_INCOMING_RUNTIME_DELETE_FILES = /* @__PURE__ */ new Set([
467
- "lcm.sqlite-shm",
468
- "lcm.sqlite-wal"
469
- ]);
470
- function shouldPreferIncomingOfflineRuntimeFile(relPosix) {
471
- const parts = relPosix.split("/");
472
- const basename = parts[parts.length - 1] ?? "";
473
- return isCanonicalRuntimeStatePath(parts) && REMOTE_AUTHORITATIVE_RUNTIME_STATE_FILES.has(basename);
474
- }
475
- function shouldDeleteAbsentIncomingOfflineRuntimeFile(relPosix) {
476
- const parts = relPosix.split("/");
477
- const basename = parts[parts.length - 1] ?? "";
478
- return isCanonicalRuntimeStatePath(parts) && ABSENT_INCOMING_RUNTIME_DELETE_FILES.has(basename);
479
- }
480
419
  function filterBaseFilesForMode(files, includeTranscripts) {
481
420
  return files.filter((file) => !shouldExcludeRelPath(file.path, includeTranscripts));
482
421
  }
@@ -526,7 +465,14 @@ async function* iterateOfflineSyncSnapshotFileRecords(options) {
526
465
  const rootAbs = path.resolve(options.root);
527
466
  const root = await prepareSafeArchiveRoot(rootAbs, "iterateOfflineSyncSnapshotFileRecords", "root");
528
467
  const includeTranscripts = options.includeTranscripts !== false;
529
- async function* walk(dirAbs) {
468
+ const pushExcludes = options.excludeNodeLocalState !== false;
469
+ const skipGenerationPaths = options.skipEmbeddingGenerationPaths ?? (pushExcludes ? (await computeOmittedEmbeddingGenerationPaths({
470
+ rootAbs: root.abs,
471
+ userExcludeRegexps: options.userExcludeRegexps,
472
+ excludeFile: options.excludeFile,
473
+ isExcludedRelPath: (relPath) => shouldExcludePushRelPath(relPath, includeTranscripts, options.userExcludeRegexps)
474
+ })).omittedPaths : void 0);
475
+ async function* walk(dirAbs, includeContent = options.includeContent === true) {
530
476
  throwIfOfflineSyncAborted(options.signal);
531
477
  let entries = await readdir(dirAbs, { withFileTypes: true });
532
478
  entries = entries.sort((left, right) => left.name.localeCompare(right.name));
@@ -534,9 +480,25 @@ async function* iterateOfflineSyncSnapshotFileRecords(options) {
534
480
  const abs = path.join(dirAbs, entry.name);
535
481
  const relPosix = path.relative(root.abs, abs).split(path.sep).join("/");
536
482
  if (options.excludeNodeLocalState === false ? shouldExcludeRelPath(relPosix, includeTranscripts) : shouldExcludePushRelPath(relPosix, includeTranscripts, options.userExcludeRegexps)) continue;
483
+ if (skipGenerationPaths?.has(relPosix)) continue;
537
484
  if (entry.isSymbolicLink()) continue;
538
485
  if (entry.isDirectory()) {
539
- yield* walk(abs);
486
+ if (isEmbeddingGenerationDirPath(relPosix)) {
487
+ yield* withEmbeddingGenerationLockIter(
488
+ path.dirname(abs),
489
+ (content) => walk(abs, content),
490
+ includeContent,
491
+ () => assertEmbeddingGenerationStillIncluded(
492
+ root.abs,
493
+ relPosix,
494
+ options.excludeFile,
495
+ (rel) => shouldExcludePushRelPath(rel, includeTranscripts, options.userExcludeRegexps),
496
+ []
497
+ )
498
+ );
499
+ continue;
500
+ }
501
+ yield* walk(abs, includeContent);
540
502
  continue;
541
503
  }
542
504
  if (!entry.isFile()) continue;
@@ -549,7 +511,7 @@ async function* iterateOfflineSyncSnapshotFileRecords(options) {
549
511
  root,
550
512
  relPath: relPosix,
551
513
  filePath: abs,
552
- includeContent: options.includeContent === true,
514
+ includeContent,
553
515
  readFile: options.readFile,
554
516
  readFileDigest: options.readFileDigest,
555
517
  signal: options.signal
@@ -561,8 +523,20 @@ async function* iterateOfflineSyncSnapshotFileRecords(options) {
561
523
  async function buildOfflineSyncSnapshot(options) {
562
524
  throwIfOfflineSyncAborted(options.signal);
563
525
  const includeTranscripts = options.includeTranscripts !== false;
526
+ const pushExcludes = options.excludeNodeLocalState !== false;
527
+ const normalizedDeletions = normalizeDeletionRevisions(options.deletions, "deletions");
528
+ const omission = pushExcludes ? await computeOmittedEmbeddingGenerationPaths({
529
+ rootAbs: path.resolve(options.root),
530
+ userExcludeRegexps: options.userExcludeRegexps,
531
+ excludeFile: options.excludeFile,
532
+ tombstonedPaths: (normalizedDeletions ?? []).map((deletion) => deletion.path),
533
+ isExcludedRelPath: (relPath) => shouldExcludePushRelPath(relPath, includeTranscripts, options.userExcludeRegexps)
534
+ }) : void 0;
564
535
  const files = [];
565
- for await (const file of iterateOfflineSyncSnapshotFileRecords(options)) files.push(file);
536
+ for await (const file of iterateOfflineSyncSnapshotFileRecords({
537
+ ...options,
538
+ skipEmbeddingGenerationPaths: omission?.omittedPaths
539
+ })) files.push(file);
566
540
  throwIfOfflineSyncAborted(options.signal);
567
541
  const sortedFiles = files.sort(compareByPath);
568
542
  const deletions = snapshotBuilderDeletions({
@@ -570,7 +544,8 @@ async function buildOfflineSyncSnapshot(options) {
570
544
  files: sortedFiles,
571
545
  includeTranscripts,
572
546
  excludeNodeLocalState: options.excludeNodeLocalState,
573
- userExcludeRegexps: options.userExcludeRegexps
547
+ userExcludeRegexps: options.userExcludeRegexps,
548
+ omittedGenerationDirs: omission && omission.omittedDirs.length > 0 ? new Set(omission.omittedDirs) : void 0
574
549
  });
575
550
  return {
576
551
  format: OFFLINE_SYNC_SNAPSHOT_FORMAT,
@@ -579,7 +554,8 @@ async function buildOfflineSyncSnapshot(options) {
579
554
  sourceId: normalizeSourceId(options.sourceId, "sourceId"),
580
555
  includeTranscripts,
581
556
  files: sortedFiles,
582
- ...deletions === void 0 ? {} : { deletions }
557
+ ...deletions === void 0 ? {} : { deletions },
558
+ ...omission && omission.omittedDirs.length > 0 ? { omittedEmbeddingGenerationDirs: omission.omittedDirs } : {}
583
559
  };
584
560
  }
585
561
  async function buildOfflineSyncSnapshotFromBase(options) {
@@ -593,6 +569,15 @@ async function buildOfflineSyncSnapshotFromBase(options) {
593
569
  ));
594
570
  const rawBaseCapturedAtMs = options.baseCapturedAt?.getTime();
595
571
  const baseCapturedAtMs = rawBaseCapturedAtMs !== void 0 && Number.isFinite(rawBaseCapturedAtMs) ? rawBaseCapturedAtMs : null;
572
+ const pushExcludes = options.excludeNodeLocalState !== false;
573
+ const normalizedDeletions = normalizeDeletionRevisions(options.deletions, "deletions");
574
+ const omission = pushExcludes ? await computeOmittedEmbeddingGenerationPaths({
575
+ rootAbs: root.abs,
576
+ userExcludeRegexps: options.userExcludeRegexps,
577
+ excludeFile: options.excludeFile,
578
+ tombstonedPaths: (normalizedDeletions ?? []).map((deletion) => deletion.path),
579
+ isExcludedRelPath: (relPath) => shouldExcludePushRelPath(relPath, includeTranscripts, options.userExcludeRegexps)
580
+ }) : void 0;
596
581
  const files = [];
597
582
  async function walk(dirAbs) {
598
583
  throwIfOfflineSyncAborted(options.signal);
@@ -603,8 +588,22 @@ async function buildOfflineSyncSnapshotFromBase(options) {
603
588
  const abs = path.join(dirAbs, entry.name);
604
589
  const relPosix = path.relative(root.abs, abs).split(path.sep).join("/");
605
590
  if (options.excludeNodeLocalState === false ? shouldExcludeRelPath(relPosix, includeTranscripts) : shouldExcludePushRelPath(relPosix, includeTranscripts, options.userExcludeRegexps)) continue;
591
+ if (omission?.omittedPaths.has(relPosix)) continue;
606
592
  if (entry.isSymbolicLink()) continue;
607
593
  if (entry.isDirectory()) {
594
+ if (isEmbeddingGenerationDirPath(relPosix)) {
595
+ await withEmbeddingGenerationLock(path.dirname(abs), async () => {
596
+ await assertEmbeddingGenerationStillIncluded(
597
+ root.abs,
598
+ relPosix,
599
+ options.excludeFile,
600
+ (rel) => shouldExcludePushRelPath(rel, includeTranscripts, options.userExcludeRegexps),
601
+ (normalizedDeletions ?? []).map((deletion) => deletion.path)
602
+ );
603
+ await walk(abs);
604
+ });
605
+ continue;
606
+ }
608
607
  await walk(abs);
609
608
  continue;
610
609
  }
@@ -639,7 +638,8 @@ async function buildOfflineSyncSnapshotFromBase(options) {
639
638
  files: sortedFiles,
640
639
  includeTranscripts,
641
640
  excludeNodeLocalState: options.excludeNodeLocalState,
642
- userExcludeRegexps: options.userExcludeRegexps
641
+ userExcludeRegexps: options.userExcludeRegexps,
642
+ omittedGenerationDirs: omission && omission.omittedDirs.length > 0 ? new Set(omission.omittedDirs) : void 0
643
643
  });
644
644
  return {
645
645
  format: OFFLINE_SYNC_SNAPSHOT_FORMAT,
@@ -648,7 +648,8 @@ async function buildOfflineSyncSnapshotFromBase(options) {
648
648
  sourceId: normalizeSourceId(options.sourceId, "sourceId"),
649
649
  includeTranscripts,
650
650
  files: sortedFiles,
651
- ...deletions === void 0 ? {} : { deletions }
651
+ ...deletions === void 0 ? {} : { deletions },
652
+ ...omission && omission.omittedDirs.length > 0 ? { omittedEmbeddingGenerationDirs: omission.omittedDirs } : {}
652
653
  };
653
654
  }
654
655
  async function buildOfflineSyncSnapshotForPaths(options) {
@@ -942,8 +943,9 @@ async function applyOfflineSyncSnapshot(options) {
942
943
  ));
943
944
  const incomingMap = byPath(snapshot.files);
944
945
  const deletionMtimeByPath = snapshot.deletions === void 0 ? void 0 : new Map(snapshot.deletions.map((deletion) => [deletion.path, deletion.mtimeMs]));
945
- const incomingBuffers = verifyRecordContents(snapshot.files, "offline sync snapshot", {
946
- requireContent: false
946
+ const incomingBuffers = await verifyRecordContents(snapshot.files, "offline sync snapshot", {
947
+ requireContent: false,
948
+ readIncomingFile: options.readIncomingFile
947
949
  });
948
950
  const root = await ensureSyncRoot(options.root, "applyOfflineSyncSnapshot");
949
951
  const currentFiles = options.currentFiles ? filterBaseFilesForMode(normalizeFileStates(options.currentFiles), snapshot.includeTranscripts).sort(compareByPath) : (await buildOfflineSyncSnapshot({
@@ -956,10 +958,18 @@ async function applyOfflineSyncSnapshot(options) {
956
958
  excludeNodeLocalState: false
957
959
  })).files;
958
960
  const currentMap = byPath(currentFiles);
959
- const deferredPaths = new Set(options.deferredPaths ?? []);
961
+ const deferredPaths = /* @__PURE__ */ new Set([
962
+ ...options.deferredPaths ?? [],
963
+ ...divergedEmbeddingGenerationDeferrals({
964
+ incomingFiles: snapshot.files,
965
+ baseFiles: [...baseMap.values()],
966
+ currentFiles
967
+ })
968
+ ]);
969
+ const omittedGenerationDirs = new Set(snapshot.omittedEmbeddingGenerationDirs ?? []);
960
970
  if (deletionMtimeByPath && options.recordDeletionRevision) {
961
971
  for (const [relPath, mtimeMs] of deletionMtimeByPath) {
962
- if (currentMap.has(relPath) || deferredPaths.has(relPath) || matchesOfflineSyncDefaultExclude(relPath)) {
972
+ if (currentMap.has(relPath) || deferredPaths.has(relPath) || omittedGenerationDirs.size > 0 && isPathInOmittedEmbeddingGeneration(relPath, omittedGenerationDirs) || matchesOfflineSyncDefaultExclude(relPath)) {
963
973
  continue;
964
974
  }
965
975
  await options.recordDeletionRevision({
@@ -982,6 +992,45 @@ async function applyOfflineSyncSnapshot(options) {
982
992
  if (buffer || options.allowMissingConflictContent === true) return buffer;
983
993
  return requiredBuffer(incomingBuffers, relPath);
984
994
  };
995
+ const { transactionResults, deferredGenerationDirs } = await applyIncomingEmbeddingGenerations({
996
+ root,
997
+ incomingMap,
998
+ incomingBuffers,
999
+ baseMap,
1000
+ currentMap,
1001
+ deferredPaths,
1002
+ omittedGenerationDirs,
1003
+ deletionMtimeByPath,
1004
+ io: {
1005
+ readFile: options.readFile,
1006
+ writeStagingFile: options.writeStagingFile,
1007
+ readStagingFile: options.readStagingFile,
1008
+ deleteFile: options.deleteFile
1009
+ },
1010
+ customIoPresent: Boolean(options.writeFile || options.readFile || options.readFileDigest || options.deleteFile),
1011
+ now: Date.now()
1012
+ });
1013
+ const transactionHandled = /* @__PURE__ */ new Set();
1014
+ let generationUpserted = 0;
1015
+ let generationDeleted = 0;
1016
+ for (const result of transactionResults) {
1017
+ if (result.deferredLocalDivergence) {
1018
+ for (const relPath of result.handledPaths) deferredPaths.add(relPath);
1019
+ deferredGenerationDirs.add(result.shardDirRel);
1020
+ continue;
1021
+ }
1022
+ generationUpserted += result.upserted;
1023
+ generationDeleted += result.deleted;
1024
+ for (const relPath of result.handledPaths) transactionHandled.add(relPath);
1025
+ for (const [relPath, state] of result.writtenStates) {
1026
+ nextBase.set(relPath, state);
1027
+ transactionHandled.add(relPath);
1028
+ }
1029
+ for (const relPath of result.removedPaths) {
1030
+ nextBase.delete(relPath);
1031
+ transactionHandled.add(relPath);
1032
+ }
1033
+ }
985
1034
  for (const relPath of unionPaths(baseMap, incomingMap, currentMap)) {
986
1035
  const base = baseMap.get(relPath);
987
1036
  const incoming = incomingMap.get(relPath);
@@ -992,6 +1041,14 @@ async function applyOfflineSyncSnapshot(options) {
992
1041
  skipped += 1;
993
1042
  continue;
994
1043
  }
1044
+ if (transactionHandled.has(relPath)) continue;
1045
+ const membership = embeddingGenerationMembership(relPath);
1046
+ if (membership && deferredGenerationDirs.has(membership.shardDir)) {
1047
+ if (base) nextBase.set(relPath, base);
1048
+ else nextBase.delete(relPath);
1049
+ skipped += 1;
1050
+ continue;
1051
+ }
995
1052
  if (incoming) {
996
1053
  if (currentEntry?.sha256 === incoming.sha256) {
997
1054
  if (await setSafeFileMtime(root, relPath, incoming.mtimeMs)) {
@@ -1079,6 +1136,11 @@ async function applyOfflineSyncSnapshot(options) {
1079
1136
  skipped += 1;
1080
1137
  continue;
1081
1138
  }
1139
+ if (shouldPreferIncomingOfflineRuntimeFile(relPath) && membership !== null && omittedGenerationDirs.has(membership.shardDir)) {
1140
+ pendingLocal += 1;
1141
+ skipped += 1;
1142
+ continue;
1143
+ }
1082
1144
  if (shouldPreferIncomingOfflineRuntimeFile(relPath) && (base || shouldDeleteAbsentIncomingOfflineRuntimeFile(relPath))) {
1083
1145
  await deleteSafeFile(
1084
1146
  root,
@@ -1120,8 +1182,8 @@ async function applyOfflineSyncSnapshot(options) {
1120
1182
  skipped += 1;
1121
1183
  }
1122
1184
  return {
1123
- upserted,
1124
- deleted,
1185
+ upserted: upserted + generationUpserted,
1186
+ deleted: deleted + generationDeleted,
1125
1187
  skipped,
1126
1188
  pendingLocal,
1127
1189
  conflicts,
@@ -1140,7 +1202,7 @@ async function applyOfflineSyncChangeset(options) {
1140
1202
  }
1141
1203
  const root = await ensureSyncRoot(options.root, "applyOfflineSyncChangeset");
1142
1204
  const records = changeset.changes.filter((change) => change.type === "upsert").map((change) => change.file);
1143
- const incomingBuffers = verifyRecordContents(records, "offline sync changeset");
1205
+ const incomingBuffers = await verifyRecordContents(records, "offline sync changeset");
1144
1206
  const currentFiles = options.currentFiles ? filterBaseFilesForMode(normalizeFileStates(options.currentFiles), changeset.includeTranscripts).sort(compareByPath) : (await buildOfflineSyncSnapshotForPaths({
1145
1207
  root: root.abs,
1146
1208
  sourceId: "local",
@@ -1156,7 +1218,26 @@ async function applyOfflineSyncChangeset(options) {
1156
1218
  let appliedUpserts = 0;
1157
1219
  let appliedDeletes = 0;
1158
1220
  let skipped = 0;
1221
+ const generationRouting = await applyChangesetEmbeddingGenerations({
1222
+ root,
1223
+ changeset,
1224
+ incomingBuffers,
1225
+ currentMap,
1226
+ io: {
1227
+ readFile: options.readFile,
1228
+ writeStagingFile: options.writeStagingFile,
1229
+ readStagingFile: options.readStagingFile,
1230
+ deleteFile: options.deleteFile
1231
+ },
1232
+ customIoPresent: Boolean(options.writeFile || options.readFile || options.readFileDigest || options.deleteFile),
1233
+ now: Date.now()
1234
+ });
1235
+ appliedUpserts += generationRouting.appliedUpserts;
1236
+ appliedDeletes += generationRouting.appliedDeletes;
1237
+ conflicts.push(...generationRouting.conflicts);
1159
1238
  for (const change of changeset.changes) {
1239
+ if (generationRouting.conflictedPaths.has(change.path)) continue;
1240
+ if (generationRouting.transactionHandled.has(change.path)) continue;
1160
1241
  const currentEntry = currentMap.get(change.path);
1161
1242
  if (change.type === "upsert") {
1162
1243
  if (currentEntry?.sha256 === change.file.sha256) {
@@ -1234,6 +1315,8 @@ async function applyOfflineSyncChangeset(options) {
1234
1315
  localSha256: currentEntry.sha256
1235
1316
  });
1236
1317
  }
1318
+ for (const [relPath, state] of generationRouting.writtenStates) currentMap.set(relPath, state);
1319
+ for (const relPath of generationRouting.removedPaths) currentMap.delete(relPath);
1237
1320
  return {
1238
1321
  appliedUpserts,
1239
1322
  appliedDeletes,
@@ -1251,10 +1334,25 @@ async function applyOfflineSyncChangeset(options) {
1251
1334
  ...options.returnCurrentFiles === false ? { currentFilesComplete: false } : {}
1252
1335
  };
1253
1336
  }
1254
- function verifyRecordContents(records, context, options = {}) {
1337
+ async function verifyRecordContents(records, context, options = {}) {
1255
1338
  const buffers = /* @__PURE__ */ new Map();
1256
1339
  for (const record of records) {
1257
1340
  if (typeof record.contentBase64 !== "string") {
1341
+ if (options.readIncomingFile) {
1342
+ const incoming = await options.readIncomingFile({
1343
+ path: record.path,
1344
+ sha256: record.sha256,
1345
+ bytes: record.bytes
1346
+ });
1347
+ if (incoming) {
1348
+ const digest2 = sha256Buffer(incoming);
1349
+ if (digest2.sha256 !== record.sha256 || digest2.bytes !== record.bytes) {
1350
+ throw new Error(`${context}: incoming content checksum mismatch for ${record.path}`);
1351
+ }
1352
+ buffers.set(record.path, incoming);
1353
+ continue;
1354
+ }
1355
+ }
1258
1356
  if (options.requireContent === false) continue;
1259
1357
  throw new Error(`${context}: contentBase64 is required for ${record.path}`);
1260
1358
  }
@@ -1332,25 +1430,6 @@ async function writeSafeFile(root, relPath, content, writeFileHook, mtimeMs) {
1332
1430
  throw error;
1333
1431
  }
1334
1432
  }
1335
- async function setSafeFileMtime(root, relPath, mtimeMs) {
1336
- if (mtimeMs === void 0) return true;
1337
- const target = await resolveSafeArchiveTarget(root, relPath);
1338
- const targetStat = await lstat(target).catch((error) => {
1339
- if (error.code === "ENOENT") return null;
1340
- throw error;
1341
- });
1342
- if (!targetStat) return false;
1343
- if (targetStat.isSymbolicLink()) {
1344
- throw new Error(`offline sync target is a symlink: ${relPath}`);
1345
- }
1346
- const targetMtimeMs = assertOfflineSyncMtimeMs(mtimeMs, "mtimeMs");
1347
- if (Math.abs(targetStat.mtimeMs - targetMtimeMs) <= OFFLINE_SYNC_FAST_BASE_MTIME_TOLERANCE_MS) {
1348
- return true;
1349
- }
1350
- const mtime = new Date(targetMtimeMs);
1351
- await utimes(target, mtime, mtime);
1352
- return true;
1353
- }
1354
1433
  async function readLocalFileState(options) {
1355
1434
  const filePath = await resolveSafeArchiveTarget(
1356
1435
  await prepareSafeArchiveRoot(options.rootAbs, "readLocalFileState", "rootAbs"),
@@ -1562,204 +1641,6 @@ async function applyOfflineSyncFileContentChunk(options) {
1562
1641
  });
1563
1642
  }
1564
1643
  }
1565
- function offlineUploadRelPath(options) {
1566
- const key = hashText([
1567
- options.sourceId,
1568
- options.relPath,
1569
- options.sha256,
1570
- String(options.bytes)
1571
- ].join("\0"));
1572
- return `${SYNC_INTERNAL_DIR}/uploads/${key}.part`;
1573
- }
1574
- async function offlineUploadPath(root, options) {
1575
- const relPath = offlineUploadRelPath(options);
1576
- return {
1577
- kind: "single",
1578
- relPath,
1579
- filePath: await resolveSafeArchiveTarget(root, relPath)
1580
- };
1581
- }
1582
- async function offlineUploadChunkPath(root, options) {
1583
- const uploadRelPath = offlineUploadRelPath(options);
1584
- const relPath = `${uploadRelPath}/${String(options.offset).padStart(20, "0")}.part`;
1585
- return {
1586
- kind: "chunks",
1587
- relPath,
1588
- filePath: await resolveSafeArchiveTarget(root, relPath)
1589
- };
1590
- }
1591
- async function writeOfflineUploadChunk(options) {
1592
- if ((options.writeFile || options.writeStagingFile) && !options.readFile) {
1593
- throw new Error("offline sync upload chunk storage hooks require readFile");
1594
- }
1595
- const uploadRoot = {
1596
- ...await offlineUploadPath(options.root, options),
1597
- kind: "chunks"
1598
- };
1599
- if (options.offset === 0) {
1600
- await rm(uploadRoot.filePath, { recursive: true, force: true }).catch(() => {
1601
- });
1602
- } else {
1603
- const existing = await stat(uploadRoot.filePath).catch((error) => {
1604
- if (error.code === "ENOENT") return null;
1605
- throw error;
1606
- });
1607
- if (!existing || !existing.isDirectory()) {
1608
- throw new Error(`offline sync upload is missing initial chunk for ${options.relPath}`);
1609
- }
1610
- }
1611
- const chunk = await offlineUploadChunkPath(options.root, { ...options, offset: options.offset });
1612
- const writeStagingFile = options.writeStagingFile ?? options.writeFile;
1613
- if (writeStagingFile) {
1614
- await writeOfflineUploadContent({
1615
- root: options.root,
1616
- relPath: chunk.relPath,
1617
- filePath: chunk.filePath,
1618
- content: options.content,
1619
- writeFile: writeStagingFile
1620
- });
1621
- return uploadRoot;
1622
- }
1623
- await mkdir(path.dirname(chunk.filePath), { recursive: true });
1624
- const existingChunk = await lstat(chunk.filePath).catch((error) => {
1625
- if (error.code === "ENOENT") return null;
1626
- throw error;
1627
- });
1628
- if (existingChunk?.isSymbolicLink()) {
1629
- throw new Error(`offline sync upload chunk is a symlink: ${chunk.relPath}`);
1630
- }
1631
- await writeFile(chunk.filePath, options.content, { mode: 384 });
1632
- return uploadRoot;
1633
- }
1634
- async function pruneOfflineUploadStaging(root) {
1635
- const uploadsRelPath = `${SYNC_INTERNAL_DIR}/uploads`;
1636
- const uploadsPath = await resolveSafeArchiveTarget(root, uploadsRelPath);
1637
- const entries = await readdir(uploadsPath, { withFileTypes: true }).catch((error) => {
1638
- if (error.code === "ENOENT") return [];
1639
- throw error;
1640
- });
1641
- const now = Date.now();
1642
- await Promise.all(entries.map(async (entry) => {
1643
- if (!/^[a-f0-9]{64}\.part$/i.test(entry.name)) return;
1644
- const relPath = `${uploadsRelPath}/${entry.name}`;
1645
- const filePath = await resolveSafeArchiveTarget(root, relPath);
1646
- const info = await lstat(filePath).catch((error) => {
1647
- if (error.code === "ENOENT") return null;
1648
- throw error;
1649
- });
1650
- if (!info) return;
1651
- if (now - info.mtimeMs <= OFFLINE_SYNC_UPLOAD_STAGING_MAX_AGE_MS) return;
1652
- await rm(filePath, { recursive: true, force: true });
1653
- }));
1654
- }
1655
- async function* readOfflineUploadStagingChunks(options) {
1656
- if (options.upload.kind === "single") {
1657
- yield await readOfflineUploadContent({
1658
- root: options.root,
1659
- relPath: options.upload.relPath,
1660
- filePath: options.upload.filePath,
1661
- readFile: options.readFile
1662
- });
1663
- return;
1664
- }
1665
- const entries = await readdir(options.upload.filePath);
1666
- const chunkNames = entries.filter((entry) => /^\d{20}\.part$/.test(entry)).sort();
1667
- if (chunkNames.length === 0) {
1668
- throw new Error(`offline sync upload is missing chunks for ${options.upload.relPath}`);
1669
- }
1670
- let expectedOffset = 0;
1671
- for (const chunkName of chunkNames) {
1672
- const offset = Number(chunkName.slice(0, 20));
1673
- if (!Number.isSafeInteger(offset) || offset !== expectedOffset) {
1674
- throw new Error(
1675
- `offline sync upload offset mismatch for ${options.upload.relPath}: expected ${expectedOffset}, got ${offset}`
1676
- );
1677
- }
1678
- const relPath = `${options.upload.relPath}/${chunkName}`;
1679
- const filePath = await resolveSafeArchiveTarget(options.root, relPath);
1680
- const content = await readOfflineUploadContent({
1681
- root: options.root,
1682
- relPath,
1683
- filePath,
1684
- readFile: options.readFile
1685
- });
1686
- expectedOffset += content.length;
1687
- yield content;
1688
- }
1689
- }
1690
- async function digestOfflineUploadStagingContent(options) {
1691
- const hash = createHash("sha256");
1692
- let bytes = 0;
1693
- for await (const chunk of readOfflineUploadStagingChunks(options)) {
1694
- hash.update(chunk);
1695
- bytes += chunk.length;
1696
- }
1697
- return { sha256: hash.digest("hex"), bytes };
1698
- }
1699
- async function writeSafeFileFromUpload(root, relPath, upload, readFile2, writeFileChunks, mtimeMs) {
1700
- const target = await resolveSafeArchiveTarget(root, relPath);
1701
- const chunks = readOfflineUploadStagingChunks({ root, upload, readFile: readFile2 });
1702
- if (writeFileChunks) {
1703
- await writeFileChunks({ root: root.abs, path: relPath, filePath: target, chunks });
1704
- await setSafeFileMtime(root, relPath, mtimeMs);
1705
- return;
1706
- }
1707
- await mkdir(path.dirname(target), { recursive: true });
1708
- const tmp = path.join(
1709
- path.dirname(target),
1710
- `.remnic-sync.${process.pid}.${randomUUID()}.tmp`
1711
- );
1712
- const handle = await open(tmp, "w", 384);
1713
- try {
1714
- for await (const chunk of chunks) {
1715
- if (chunk.length > 0) await handle.write(chunk);
1716
- }
1717
- await handle.close();
1718
- const targetStat = await lstat(target).catch((error) => {
1719
- if (error.code === "ENOENT") return null;
1720
- throw error;
1721
- });
1722
- if (targetStat?.isSymbolicLink()) {
1723
- throw new Error(`offline sync target is a symlink: ${relPath}`);
1724
- }
1725
- await rename(tmp, target);
1726
- await setSafeFileMtime(root, relPath, mtimeMs);
1727
- } catch (error) {
1728
- await handle.close().catch(() => {
1729
- });
1730
- await unlink(tmp).catch(() => {
1731
- });
1732
- throw error;
1733
- }
1734
- }
1735
- async function cleanupOfflineUpload(upload) {
1736
- if (upload.kind === "chunks") {
1737
- await rm(upload.filePath, { recursive: true, force: true });
1738
- return;
1739
- }
1740
- await unlink(upload.filePath).catch((error) => {
1741
- if (error.code === "ENOENT") return;
1742
- throw error;
1743
- });
1744
- }
1745
- async function readOfflineUploadContent(options) {
1746
- if (options.readFile) {
1747
- return options.readFile({
1748
- root: options.root.abs,
1749
- path: options.relPath,
1750
- filePath: options.filePath
1751
- });
1752
- }
1753
- return readFile(options.filePath);
1754
- }
1755
- async function writeOfflineUploadContent(options) {
1756
- await options.writeFile({
1757
- root: options.root.abs,
1758
- path: options.relPath,
1759
- filePath: options.filePath,
1760
- content: options.content
1761
- });
1762
- }
1763
1644
  async function deleteSafeFile(root, relPath, deleteFile, mtimeMs) {
1764
1645
  const target = await resolveSafeArchiveTarget(root, relPath);
1765
1646
  if (deleteFile) {
@@ -1869,14 +1750,10 @@ export {
1869
1750
  OFFLINE_SYNC_APPLY_MAX_BODY_BYTES,
1870
1751
  OFFLINE_SYNC_SNAPSHOT_BASE_MAX_BODY_BYTES,
1871
1752
  OFFLINE_SYNC_MAX_MTIME_MS,
1872
- globToRegExp,
1873
1753
  filterOfflineSyncDeletionRevisions,
1874
1754
  normalizeOfflineSyncSnapshot,
1875
1755
  normalizeOfflineSyncChangeset,
1876
1756
  isInternalRemnicStatePath,
1877
- compileOfflineSyncExcludeGlobs,
1878
- parseOfflineSyncExcludes,
1879
- shouldPreferIncomingOfflineRuntimeFile,
1880
1757
  iterateOfflineSyncSnapshotFileRecords,
1881
1758
  buildOfflineSyncSnapshot,
1882
1759
  buildOfflineSyncSnapshotFromBase,
@@ -1897,4 +1774,4 @@ export {
1897
1774
  normalizeOfflineSyncState,
1898
1775
  fileStatesFromSnapshot
1899
1776
  };
1900
- //# sourceMappingURL=chunk-WQZZDN5M.js.map
1777
+ //# sourceMappingURL=chunk-IVEHY2VT.js.map