@wirecat/drive-cli 0.71.0 → 0.72.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (258) hide show
  1. package/README.md +150 -71
  2. package/contracts/wirecat.json +77 -8
  3. package/dist/bin/drive.js +2 -2
  4. package/dist/bundle/agent-GOCD4ZW2.js +46 -0
  5. package/dist/bundle/{all-profiles-3QJG2NAN.js → all-profiles-PZVP3G73.js} +67 -25
  6. package/dist/bundle/{anthropic-PSWTEU6G.js → anthropic-PUOTKSYV.js} +9 -9
  7. package/dist/bundle/{app-server-PVTA6ABR.js → app-server-MKDCXRZM.js} +97 -79
  8. package/dist/bundle/{bun-LU5LP3JI.js → bun-NS5YLOQT.js} +2 -2
  9. package/dist/bundle/{bun-sqlite-PYMKLBRU.js → bun-sqlite-KSKWRLLO.js} +9 -9
  10. package/dist/bundle/{chunk-COOOO5B3.js → chunk-2CG3LUQS.js} +4 -4
  11. package/dist/bundle/{chunk-YVI5SQPY.js → chunk-2TVHFJKV.js} +1 -1
  12. package/dist/bundle/chunk-35FIJGTT.js +52 -0
  13. package/dist/bundle/chunk-35GROSBS.js +3233 -0
  14. package/dist/bundle/{chunk-D5TGYUVU.js → chunk-3CH7I452.js} +9 -60
  15. package/dist/bundle/{chunk-ICDCAQ6K.js → chunk-3QBRS3JT.js} +13 -9
  16. package/dist/bundle/chunk-3T7JIHSO.js +353 -0
  17. package/dist/bundle/{chunk-Q7DOMFJ4.js → chunk-3VIEGRBA.js} +6 -6
  18. package/dist/bundle/chunk-3YCUYFTD.js +2159 -0
  19. package/dist/bundle/{chunk-CJLVYIOP.js → chunk-3ZGWJYSG.js} +30 -21
  20. package/dist/bundle/{chunk-YPFWNVHV.js → chunk-43PCMVTZ.js} +2 -100
  21. package/dist/bundle/{chunk-OF422U5D.js → chunk-4DK55MLP.js} +402 -402
  22. package/dist/bundle/chunk-4HP6KGBI.js +32 -0
  23. package/dist/bundle/chunk-4P6D6CUS.js +282 -0
  24. package/dist/bundle/chunk-4ZAQMDLD.js +1308 -0
  25. package/dist/bundle/chunk-4ZTB7LS3.js +87 -0
  26. package/dist/bundle/{chunk-6W763DZN.js → chunk-54O5NJRC.js} +14 -13
  27. package/dist/bundle/{chunk-MNLL5YLM.js → chunk-5BHP4FVM.js} +2 -2
  28. package/dist/bundle/{chunk-ACUAV6VX.js → chunk-6JU4KLAZ.js} +108 -72
  29. package/dist/bundle/{chunk-YMJ6IDGT.js → chunk-6KND2DYT.js} +38 -8
  30. package/dist/bundle/{chunk-4HWJOU7N.js → chunk-7YPZPJTB.js} +1 -1
  31. package/dist/bundle/chunk-A5XNUMW7.js +108 -0
  32. package/dist/bundle/{chunk-X4TIMMKJ.js → chunk-AG34MPVN.js} +1 -1
  33. package/dist/bundle/chunk-B5V2U7IS.js +221 -0
  34. package/dist/bundle/chunk-B6JC5RS3.js +696 -0
  35. package/dist/bundle/chunk-BDZXGDGI.js +80 -0
  36. package/dist/bundle/{chunk-B5KSXHJ7.js → chunk-BMTMGMGE.js} +1 -1
  37. package/dist/bundle/{chunk-ZCR3IRZ2.js → chunk-CP2TZXAG.js} +16 -9
  38. package/dist/bundle/{chunk-TAUBRNC5.js → chunk-DOEP4EPW.js} +72 -59
  39. package/dist/bundle/chunk-DQSOYH6N.js +20 -0
  40. package/dist/bundle/{chunk-QETR5HIZ.js → chunk-E2TMWONO.js} +4385 -2684
  41. package/dist/bundle/chunk-E5EYJU5R.js +7 -0
  42. package/dist/bundle/chunk-ECYOTDJM.js +14 -0
  43. package/dist/bundle/{chunk-HL52XXZX.js → chunk-EXHTGQR2.js} +3 -4
  44. package/dist/bundle/chunk-F4BX7TH2.js +15 -0
  45. package/dist/bundle/{chunk-ASMMG72J.js → chunk-FJQO5OHR.js} +261 -565
  46. package/dist/bundle/{chunk-RJOQH5YY.js → chunk-FKP4T7A4.js} +111 -859
  47. package/dist/bundle/{chunk-JDV7HNNQ.js → chunk-FTL3WXZB.js} +13 -26
  48. package/dist/bundle/{chunk-FP54WSIR.js → chunk-G2CH4FRW.js} +4 -4
  49. package/dist/bundle/chunk-G2KKMQRN.js +30 -0
  50. package/dist/bundle/{chunk-NYECVHFH.js → chunk-G4NHRFS7.js} +755 -0
  51. package/dist/bundle/{chunk-Y2NWGNUB.js → chunk-G7SKXAVZ.js} +5 -5
  52. package/dist/bundle/{chunk-FT3LN3HP.js → chunk-GFI3UUIU.js} +1 -1
  53. package/dist/bundle/chunk-GTPPUBYU.js +1876 -0
  54. package/dist/bundle/{chunk-QFR2PNJN.js → chunk-GTROGY74.js} +12 -12
  55. package/dist/bundle/{chunk-UTO2GO4P.js → chunk-GYAPDUF5.js} +45 -66
  56. package/dist/bundle/{chunk-GBKNJWOZ.js → chunk-HCMEU7AF.js} +8 -8
  57. package/dist/bundle/{chunk-FJH7DJWK.js → chunk-HDGJ7IDE.js} +6 -6
  58. package/dist/bundle/{chunk-Z3KUSRCF.js → chunk-HMN26CVU.js} +2 -2
  59. package/dist/bundle/{chunk-I4RWW3UD.js → chunk-HOICQNJX.js} +20 -5
  60. package/dist/bundle/{chunk-P7CUM5IB.js → chunk-HPS2YGSZ.js} +1 -1
  61. package/dist/bundle/{chunk-HMS6EEQL.js → chunk-HSASPXRW.js} +3 -3
  62. package/dist/bundle/{chunk-KGYVHPGE.js → chunk-IABPGOMT.js} +2 -2
  63. package/dist/bundle/{chunk-4QNW4NK6.js → chunk-IBQZT2YD.js} +1 -1
  64. package/dist/bundle/{chunk-PRW6SYA3.js → chunk-IE3R46YN.js} +313 -257
  65. package/dist/bundle/{chunk-7PDHGZN4.js → chunk-IE6O7463.js} +4 -4
  66. package/dist/bundle/{chunk-3UGYFXH6.js → chunk-IPBYU43F.js} +192 -379
  67. package/dist/bundle/{chunk-RWDKMU74.js → chunk-IS7STZEB.js} +3 -3
  68. package/dist/bundle/{chunk-GOWXXYEF.js → chunk-IV77ZFF4.js} +4 -4
  69. package/dist/bundle/{chunk-6XFIITOG.js → chunk-JDGF3YYS.js} +4811 -3486
  70. package/dist/bundle/{chunk-GPQ44Y2R.js → chunk-JHAACT4I.js} +2 -2
  71. package/dist/bundle/{chunk-SERXSCN3.js → chunk-JRED7BNX.js} +337 -390
  72. package/dist/bundle/{chunk-MIA7P6FZ.js → chunk-JSYUB4SM.js} +6 -6
  73. package/dist/bundle/{chunk-RESDD3Q4.js → chunk-JVM75M4H.js} +16 -3
  74. package/dist/bundle/{chunk-XF4EXO2C.js → chunk-JZ65CQWK.js} +6 -6
  75. package/dist/bundle/{chunk-QNRRK3CN.js → chunk-KBR7OC5S.js} +2 -2
  76. package/dist/bundle/chunk-KI6OOW6D.js +123 -0
  77. package/dist/bundle/chunk-KOI5G7NM.js +388 -0
  78. package/dist/bundle/{chunk-ZZ32DXTH.js → chunk-KPBUJQKT.js} +1 -1
  79. package/dist/bundle/{chunk-2LHAVY4U.js → chunk-KVBGIZ2C.js} +1 -1
  80. package/dist/bundle/chunk-L7P3LUDQ.js +286 -0
  81. package/dist/bundle/{chunk-SAKO3P4H.js → chunk-LKUWH6KU.js} +1 -1
  82. package/dist/bundle/chunk-MA6U4XH2.js +36 -0
  83. package/dist/bundle/{chunk-TAFHYHKA.js → chunk-MA7ETVTZ.js} +43 -186
  84. package/dist/bundle/{chunk-KYKW2W6X.js → chunk-MDJUYCHT.js} +1 -1
  85. package/dist/bundle/chunk-MEYYH47C.js +25 -0
  86. package/dist/bundle/{chunk-Z56QFOBR.js → chunk-MGC2BAD2.js} +1 -1
  87. package/dist/bundle/chunk-NMQRSEZM.js +37 -0
  88. package/dist/bundle/{chunk-5DPV7X27.js → chunk-NTZWY5R3.js} +321 -0
  89. package/dist/bundle/{chunk-OJSBWP3F.js → chunk-OBDPKDGB.js} +69 -7
  90. package/dist/bundle/{chunk-WVDCCYS3.js → chunk-ODTBJGWQ.js} +17 -17
  91. package/dist/bundle/chunk-PB6ACIME.js +80 -0
  92. package/dist/bundle/{chunk-5D4AEUVA.js → chunk-PL5P7UKW.js} +434 -1
  93. package/dist/bundle/{chunk-72C4YOCH.js → chunk-PMAV3RNP.js} +7 -7
  94. package/dist/bundle/chunk-PSY67L73.js +783 -0
  95. package/dist/bundle/{chunk-6TNNT2MQ.js → chunk-PUVQOZ2N.js} +483 -176
  96. package/dist/bundle/{chunk-SDKQNOL5.js → chunk-QB7K6PIP.js} +6 -6
  97. package/dist/bundle/chunk-QK7GKFKB.js +188 -0
  98. package/dist/bundle/{chunk-4PA4DHYV.js → chunk-QMUWHKP5.js} +6 -6
  99. package/dist/bundle/chunk-QURQ2OU2.js +250 -0
  100. package/dist/bundle/{chunk-LXKYKRHD.js → chunk-R3EDZWXF.js} +8 -227
  101. package/dist/bundle/{chunk-KGERXYTV.js → chunk-RM4DO2WZ.js} +1 -1
  102. package/dist/bundle/chunk-S27UKJVL.js +730 -0
  103. package/dist/bundle/{chunk-22QQUKWA.js → chunk-S3SLDYTU.js} +1 -1
  104. package/dist/bundle/{chunk-FCS26CYQ.js → chunk-SAEBHENE.js} +4 -4
  105. package/dist/bundle/chunk-SM7Z2BQF.js +561 -0
  106. package/dist/bundle/{chunk-QXC6IEH6.js → chunk-SODB63MR.js} +201 -423
  107. package/dist/bundle/{chunk-2PUNKUYJ.js → chunk-SSFGSY77.js} +10320 -9907
  108. package/dist/bundle/{chunk-37MAA6F2.js → chunk-STUPCKAA.js} +11 -2221
  109. package/dist/bundle/{chunk-BKSQBBYG.js → chunk-SUQT4KI2.js} +9 -9
  110. package/dist/bundle/{chunk-YPNWIB6H.js → chunk-SWQDKO6D.js} +3 -3
  111. package/dist/bundle/chunk-SZ7XJZGH.js +2231 -0
  112. package/dist/bundle/{chunk-3N2OFXB5.js → chunk-T3OK6AYZ.js} +5 -5
  113. package/dist/bundle/{chunk-HKY7X6NY.js → chunk-TFIAD57H.js} +4 -4
  114. package/dist/bundle/chunk-TRYYWV7J.js +291 -0
  115. package/dist/bundle/{chunk-XMMFBPGC.js → chunk-TUL6MCTY.js} +3 -3
  116. package/dist/bundle/{chunk-6Y2BYFXQ.js → chunk-UC7JLE6J.js} +0 -7
  117. package/dist/bundle/{chunk-YJIGGUPI.js → chunk-UL5HSHFU.js} +4 -4
  118. package/dist/bundle/{chunk-3EBBLKIT.js → chunk-UT64BBEP.js} +4 -4
  119. package/dist/bundle/{chunk-26DHFMGZ.js → chunk-VBIZD5V5.js} +2 -2
  120. package/dist/bundle/chunk-VHTELRUA.js +50 -0
  121. package/dist/bundle/chunk-VOQICE3G.js +340 -0
  122. package/dist/bundle/{chunk-GZ2D4KXG.js → chunk-WDJRUNQN.js} +35 -12
  123. package/dist/bundle/{chunk-2UUWXPOB.js → chunk-X5CXANSA.js} +3 -3
  124. package/dist/bundle/{chunk-35SCQ4VI.js → chunk-X6HPQKAI.js} +43 -35
  125. package/dist/bundle/{chunk-COJSWDNU.js → chunk-XKWQDQ4B.js} +3 -3
  126. package/dist/bundle/{chunk-6SJOTNHF.js → chunk-XZEVHUKI.js} +6 -28
  127. package/dist/bundle/{chunk-JZHBZOJR.js → chunk-YE7DJB3F.js} +3 -3
  128. package/dist/bundle/chunk-YHWFF6DN.js +39 -0
  129. package/dist/bundle/{chunk-2BVVU7GG.js → chunk-YJVQ5GST.js} +1 -1
  130. package/dist/bundle/{chunk-ZM63SUHG.js → chunk-YRCGFSRR.js} +2 -2
  131. package/dist/bundle/{chunk-EOEU3AZN.js → chunk-ZNFXKFGF.js} +13 -13
  132. package/dist/bundle/{cli-556DERZL.js → cli-KXRWXGTS.js} +217 -114
  133. package/dist/bundle/command-contract-BGNT7MTQ.js +45 -0
  134. package/dist/bundle/{command-server-entry-AYLGNZWD.js → command-server-entry-7FZX74T6.js} +36 -34
  135. package/dist/bundle/{decode-QU24MWMN.js → decode-SZ6W34U3.js} +10 -10
  136. package/dist/bundle/{dispatch-4KODNOXV.js → dispatch-4KNSZ3PI.js} +10 -10
  137. package/dist/bundle/dist-PAKDDIBT.js +191 -0
  138. package/dist/bundle/drive.js +11 -11
  139. package/dist/bundle/{echarts-BXX4OQWC.js → echarts-ISH62J4E.js} +2 -2
  140. package/dist/bundle/{embed-KG27KG3D.js → embed-6ODGTZPK.js} +10 -10
  141. package/dist/bundle/{embedder-IPAVUQUV.js → embedder-6FY67FTQ.js} +15 -15
  142. package/dist/bundle/entry-2SA6ZX7E.js +25 -0
  143. package/dist/bundle/{failure-ESL7ETL4.js → failure-V3ILKUTX.js} +4 -4
  144. package/dist/bundle/first-run-ZNKPPD6M.js +31 -0
  145. package/dist/bundle/first-screen-WF6GYLPN.js +45 -0
  146. package/dist/bundle/google-QCADNPCQ.js +46 -0
  147. package/dist/bundle/{google-api-VCDBSNOW.js → google-api-ZTI3NKZX.js} +88 -73
  148. package/dist/bundle/grants-BPN5AGDK.js +133 -0
  149. package/dist/bundle/hast-util-from-html-X2DCPS3T.js +10531 -0
  150. package/dist/bundle/hast-util-to-html-VP6XLPKJ.js +998 -0
  151. package/dist/bundle/hast-util-to-mdast-IZ5PRX72.js +2272 -0
  152. package/dist/bundle/{identity-LOWMVGZY.js → identity-YX4IPGOO.js} +7 -6
  153. package/dist/bundle/{instructions-2VECIDXF.js → instructions-G5ZGHVFB.js} +1 -1
  154. package/dist/bundle/{login-7GBONT7V.js → login-CVX5VJX6.js} +96 -81
  155. package/dist/bundle/{mcp-O6ACR2DX.js → mcp-MQ2L5IIM.js} +2 -2
  156. package/dist/bundle/{mdast-util-from-markdown-FXEPSNER.js → mdast-util-from-markdown-HEZF7KJ4.js} +137 -195
  157. package/dist/bundle/mdast-util-gfm-AQW6R6MG.js +925 -0
  158. package/dist/bundle/mdast-util-to-hast-DF2QVIRV.js +879 -0
  159. package/dist/bundle/mdast-util-to-markdown-XYLXB3Z3.js +18 -0
  160. package/dist/bundle/meeting-combined-HKZJMJ6Q.js +28 -0
  161. package/dist/bundle/meeting-model-DSE4GRVE.js +29 -0
  162. package/dist/bundle/{meeting-semantic-G7PFOKU7.js → meeting-semantic-OHG2QN2G.js} +10 -10
  163. package/dist/bundle/{micromark-extension-gfm-GRL24TU6.js → micromark-extension-gfm-OE2GBORZ.js} +11 -78
  164. package/dist/bundle/{node-MPEQSFI3.js → node-NLJINXVQ.js} +2 -2
  165. package/dist/bundle/{node-sqlite-OLQMAYB4.js → node-sqlite-KDFQDYVZ.js} +10 -10
  166. package/dist/bundle/notes-search-3VBVSQ3R.js +70 -0
  167. package/dist/bundle/oauth-M3E62ZHC.js +22 -0
  168. package/dist/bundle/{open-OXTE672W.js → open-WVRUVBIZ.js} +8 -8
  169. package/dist/bundle/{openai-EB3TPIZY.js → openai-JJWOSJMV.js} +22 -21
  170. package/dist/bundle/{process-F6TKXWWA.js → process-LPVAYRO7.js} +1 -1
  171. package/dist/bundle/{program-4IFDZ7FM.js → program-ZJRIP25J.js} +276 -1149
  172. package/dist/bundle/{prompt-F5RRHPN2.js → prompt-XCDHTEAO.js} +8 -8
  173. package/dist/bundle/{reasons-UORHJDHK.js → reasons-REEEQDAZ.js} +6 -5
  174. package/dist/bundle/{recognize-DAVNZND3.js → recognize-OZLFDJAT.js} +7 -7
  175. package/dist/bundle/remote-MDPYVCZB.js +35 -0
  176. package/dist/bundle/{rerank-CND2GVLZ.js → rerank-FLZWJNHA.js} +11 -11
  177. package/dist/bundle/{serve-ZHSPUIGX.js → serve-5UV5VLRV.js} +19 -19
  178. package/dist/bundle/{server-YMAK4LHC.js → server-53A2X2MK.js} +89 -70
  179. package/dist/bundle/server-5GMURMDE.js +97 -0
  180. package/dist/bundle/{services-ZILSFJ6E.js → services-XSMH7BXB.js} +109 -89
  181. package/dist/bundle/{sqlite-runtime-S5VPMZQH.js → sqlite-runtime-E3L7ENFU.js} +9 -9
  182. package/dist/bundle/{start-CR6X25RT.js → start-4S2VNR4J.js} +7 -7
  183. package/dist/bundle/{state-YFPHVIIJ.js → state-TQI4JSH7.js} +9 -9
  184. package/dist/bundle/{store-CL4ZJZRI.js → store-GS7PU6PJ.js} +38 -23
  185. package/dist/bundle/{store-UODRT6X4.js → store-VYJPL7MW.js} +36 -25
  186. package/dist/bundle/store-maintenance-command-JJVYUZMG.js +85 -0
  187. package/dist/bundle/surface-JC4XVMZR.js +83 -0
  188. package/dist/bundle/tokens-KJQ5EAPW.js +133 -0
  189. package/dist/commands/documents.d.ts.map +1 -1
  190. package/dist/commands/documents.js +11 -1
  191. package/dist/commands/documents.js.map +1 -1
  192. package/dist/commands/remote.d.ts.map +1 -1
  193. package/dist/commands/remote.js +8 -22
  194. package/dist/commands/remote.js.map +1 -1
  195. package/dist/commands/sync.d.ts.map +1 -1
  196. package/dist/commands/sync.js +14 -4
  197. package/dist/commands/sync.js.map +1 -1
  198. package/dist/config.d.ts +5 -0
  199. package/dist/config.d.ts.map +1 -1
  200. package/dist/config.js +5 -0
  201. package/dist/config.js.map +1 -1
  202. package/dist/first-screen.d.ts.map +1 -1
  203. package/dist/first-screen.js +2 -1
  204. package/dist/first-screen.js.map +1 -1
  205. package/dist/generated/manifest.d.ts +2 -1
  206. package/dist/generated/manifest.d.ts.map +1 -1
  207. package/dist/generated/manifest.js +782 -0
  208. package/dist/generated/manifest.js.map +1 -1
  209. package/dist/generated/types.d.ts +262 -58
  210. package/dist/generated/types.d.ts.map +1 -1
  211. package/dist/google.d.ts.map +1 -1
  212. package/dist/google.js +5 -5
  213. package/dist/google.js.map +1 -1
  214. package/dist/model.d.ts +5 -2
  215. package/dist/model.d.ts.map +1 -1
  216. package/dist/model.js.map +1 -1
  217. package/dist/policy-keys.js +1 -1
  218. package/dist/policy-keys.js.map +1 -1
  219. package/dist/program.d.ts.map +1 -1
  220. package/dist/program.js +9 -4
  221. package/dist/program.js.map +1 -1
  222. package/dist/state.d.ts.map +1 -1
  223. package/dist/state.js +6 -1
  224. package/dist/state.js.map +1 -1
  225. package/dist/store.d.ts.map +1 -1
  226. package/dist/store.js +2 -7
  227. package/dist/store.js.map +1 -1
  228. package/dist/supported.d.ts +2 -2
  229. package/dist/supported.d.ts.map +1 -1
  230. package/dist/supported.js +2 -3
  231. package/dist/supported.js.map +1 -1
  232. package/dist/sync.d.ts +2 -1
  233. package/dist/sync.d.ts.map +1 -1
  234. package/dist/sync.js +5 -2
  235. package/dist/sync.js.map +1 -1
  236. package/dist/version.d.ts +1 -1
  237. package/dist/version.js +1 -1
  238. package/package.json +3 -3
  239. package/scenarios/find-decision.md +1 -1
  240. package/skills/drive-cli/SKILL.md +4 -2
  241. package/dist/bundle/chunk-J5Q5FS2N.js +0 -593
  242. package/dist/bundle/chunk-L46C6HQ7.js +0 -729
  243. package/dist/bundle/chunk-UDMNY63V.js +0 -899
  244. package/dist/bundle/chunk-VKE77B3F.js +0 -2
  245. package/dist/bundle/command-contract-VRTOAV6W.js +0 -43
  246. package/dist/bundle/entry-MVXQETWS.js +0 -25
  247. package/dist/bundle/first-run-4UVLW2WR.js +0 -31
  248. package/dist/bundle/first-screen-JAKAIINI.js +0 -41
  249. package/dist/bundle/google-22NXXJX5.js +0 -45
  250. package/dist/bundle/grants-MQMTVCRQ.js +0 -118
  251. package/dist/bundle/mdast-util-gfm-SZM5GBDF.js +0 -2103
  252. package/dist/bundle/meeting-combined-LVP4AZKA.js +0 -27
  253. package/dist/bundle/meeting-model-RAY5XDXZ.js +0 -29
  254. package/dist/bundle/oauth-SGH2I2BY.js +0 -22
  255. package/dist/bundle/remote-D5EYYIAU.js +0 -35
  256. package/dist/bundle/server-DUVJWP3Q.js +0 -80
  257. package/dist/bundle/store-maintenance-command-DY5XIBWR.js +0 -72
  258. package/dist/bundle/tokens-AF7QOFOF.js +0 -118
@@ -2,20 +2,23 @@ import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  deadlineMargin
5
- } from "./chunk-I4RWW3UD.js";
5
+ } from "./chunk-HOICQNJX.js";
6
6
  import {
7
7
  walkQuery
8
- } from "./chunk-OF422U5D.js";
8
+ } from "./chunk-4DK55MLP.js";
9
9
  import {
10
10
  writeSecurely
11
- } from "./chunk-CJLVYIOP.js";
11
+ } from "./chunk-3ZGWJYSG.js";
12
12
  import {
13
13
  array,
14
+ boolean,
14
15
  literal,
15
16
  looseObject,
16
17
  maxLength,
17
18
  minLength,
19
+ number,
18
20
  object,
21
+ optional,
19
22
  parse,
20
23
  picklist,
21
24
  pipe,
@@ -24,16 +27,16 @@ import {
24
27
  safeParse,
25
28
  string,
26
29
  trim
27
- } from "./chunk-OJSBWP3F.js";
30
+ } from "./chunk-OBDPKDGB.js";
28
31
  import {
29
32
  CliError,
30
33
  isCliError
31
- } from "./chunk-4QNW4NK6.js";
34
+ } from "./chunk-IBQZT2YD.js";
32
35
  import {
33
36
  __name
34
37
  } from "./chunk-ZVVMGPBJ.js";
35
38
 
36
- // node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/documents/blocks.js
39
+ // node_modules/.pnpm/@wirecat+cli-core@0.724.0_@wirecat+cli-base@0.130.0_commander@15.0.0_esbuild@0.28.2_typ_7eee7c5df32146a12ad3bd2be9b828b8/node_modules/@wirecat/cli-core/dist/documents/blocks.js
37
40
  var MARKS = ["bold", "italic", "strike", "code", "link"];
38
41
  var sameMarks = /* @__PURE__ */ __name((a, b) => MARKS.every((mark) => a[mark] === b[mark]), "sameMarks");
39
42
  var normalizeInlines = /* @__PURE__ */ __name((inlines) => {
@@ -81,7 +84,7 @@ var key = /* @__PURE__ */ __name((block, withChecked) => {
81
84
  var blockKey = /* @__PURE__ */ __name((block) => JSON.stringify(key(block, true)), "blockKey");
82
85
  var blockShape = /* @__PURE__ */ __name((block) => JSON.stringify(key(block, false)), "blockShape");
83
86
 
84
- // node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/services/documents/block-diff.js
87
+ // node_modules/.pnpm/@wirecat+cli-core@0.724.0_@wirecat+cli-base@0.130.0_commander@15.0.0_esbuild@0.28.2_typ_7eee7c5df32146a12ad3bd2be9b828b8/node_modules/@wirecat/cli-core/dist/services/documents/block-diff.js
85
88
  var MAX_CELLS = 4e6;
86
89
  var matches = /* @__PURE__ */ __name((a, b, keyOf) => {
87
90
  const ka = a.map(keyOf);
@@ -123,7 +126,7 @@ var matches = /* @__PURE__ */ __name((a, b, keyOf) => {
123
126
  pairs.push([endA + offset, endB + offset]);
124
127
  return pairs;
125
128
  }, "matches");
126
- var diffBlocks = /* @__PURE__ */ __name((base, next, keyOf = blockKey) => {
129
+ var diffSequence = /* @__PURE__ */ __name((base, next, keyOf) => {
127
130
  const hunks = [];
128
131
  let a = 0;
129
132
  let b = 0;
@@ -134,7 +137,8 @@ var diffBlocks = /* @__PURE__ */ __name((base, next, keyOf = blockKey) => {
134
137
  b = j + 1;
135
138
  }
136
139
  return hunks;
137
- }, "diffBlocks");
140
+ }, "diffSequence");
141
+ var diffBlocks = /* @__PURE__ */ __name((base, next, keyOf = blockKey) => diffSequence(base, next, keyOf), "diffBlocks");
138
142
  var isCheck = /* @__PURE__ */ __name((block) => block?.kind === "item" && block.list === "check", "isCheck");
139
143
  var sameKeys = /* @__PURE__ */ __name((a, b) => a.length === b.length && a.every((block, index) => blockKey(block) === blockKey(b[index])), "sameKeys");
140
144
  var touches = /* @__PURE__ */ __name((a, b) => Math.max(a.from, b.from) < Math.min(a.to, b.to) || a.from === b.from || a.from === a.to && b.from < a.from && a.from < b.to || b.from === b.to && a.from < b.from && b.from < a.to, "touches");
@@ -147,7 +151,7 @@ var applied = /* @__PURE__ */ __name((base, from, to, hunks) => {
147
151
  }
148
152
  return out.concat(base.slice(at, to));
149
153
  }, "applied");
150
- var mergeBlocks = /* @__PURE__ */ __name((baseLocal, baseRemote, local, remote, keep) => {
154
+ var mergeBlocks = /* @__PURE__ */ __name((baseLocal, baseRemote, local, remote, keep, overlap = touches) => {
151
155
  if (baseLocal.length !== baseRemote.length || baseLocal.some((block, index) => blockShape(block) !== blockShape(baseRemote[index])))
152
156
  return { status: "unaligned" };
153
157
  const tagged = [
@@ -157,7 +161,7 @@ var mergeBlocks = /* @__PURE__ */ __name((baseLocal, baseRemote, local, remote,
157
161
  const clusters = [];
158
162
  for (const hunk of tagged) {
159
163
  const last = clusters.at(-1);
160
- if (last?.some((other) => touches(other, hunk)))
164
+ if (last?.some((other) => overlap(other, hunk)))
161
165
  last.push(hunk);
162
166
  else
163
167
  clusters.push([hunk]);
@@ -227,7 +231,7 @@ var mergeBlocks = /* @__PURE__ */ __name((baseLocal, baseRemote, local, remote,
227
231
  return { status: "clean", blocks, conflicts };
228
232
  }, "mergeBlocks");
229
233
 
230
- // node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/services/documents/extraction.js
234
+ // node_modules/.pnpm/@wirecat+cli-core@0.724.0_@wirecat+cli-base@0.130.0_commander@15.0.0_esbuild@0.28.2_typ_7eee7c5df32146a12ad3bd2be9b828b8/node_modules/@wirecat/cli-core/dist/services/documents/extraction.js
231
235
  var Proposal = object({
232
236
  kind: picklist(["summary", "digest", "fact", "preference"]),
233
237
  body: pipe(string(), trim(), minLength(1), maxLength(15e3)),
@@ -262,7 +266,7 @@ var extractMemories = /* @__PURE__ */ __name(async (text, complete) => {
262
266
  return { ...proposals, provider: answer.provider, model: answer.model, tokens: answer.tokens };
263
267
  }, "extractMemories");
264
268
 
265
- // node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/services/documents/ingestion.js
269
+ // node_modules/.pnpm/@wirecat+cli-core@0.724.0_@wirecat+cli-base@0.130.0_commander@15.0.0_esbuild@0.28.2_typ_7eee7c5df32146a12ad3bd2be9b828b8/node_modules/@wirecat/cli-core/dist/services/documents/ingestion.js
266
270
  var documentIngestion = /* @__PURE__ */ __name((store, options) => {
267
271
  const folder = /* @__PURE__ */ __name(async (principal, create) => {
268
272
  if (options.provider)
@@ -287,7 +291,16 @@ var documentIngestion = /* @__PURE__ */ __name((store, options) => {
287
291
  }
288
292
  }
289
293
  }, "stale");
294
+ const { provider, command } = options;
290
295
  return {
296
+ // Only where both are known: a sync calls it whenever it is there and a profile is given.
297
+ ...provider && command ? {
298
+ /** Names the profile's account in the store, so a search hit says `notion`/`work`, not `notes`/`1`. */
299
+ registerProfile: /* @__PURE__ */ __name(async (name, principal) => {
300
+ await folder(principal, true);
301
+ await store.accounts.saveProfile(command, name, { provider, account: principal });
302
+ }, "registerProfile")
303
+ } : {},
291
304
  catalog: {
292
305
  import: /* @__PURE__ */ __name(async (principal, files) => {
293
306
  const selected = await folder(principal, true);
@@ -351,7 +364,7 @@ var documentIngestion = /* @__PURE__ */ __name((store, options) => {
351
364
  await options.observed?.(principal, content.metadata, note.id);
352
365
  return note.ref;
353
366
  }, "save"),
354
- remove: /* @__PURE__ */ __name(async (principal, id) => {
367
+ remove: /* @__PURE__ */ __name(async (principal, id, reason) => {
355
368
  const selected = await folder(principal, false);
356
369
  if (selected) {
357
370
  const path = options.externalId(id);
@@ -360,13 +373,40 @@ var documentIngestion = /* @__PURE__ */ __name((store, options) => {
360
373
  const ref = note?.ref ?? retired?.ref;
361
374
  if (ref)
362
375
  await stale(ref);
363
- await store.notes.deleteFileNotes(selected.id, [path]);
376
+ await store.notes.deleteFileNotes(selected.id, [path], reason);
364
377
  }
365
- }, "remove")
378
+ }, "remove"),
379
+ prune: /* @__PURE__ */ __name(async (principal, before) => {
380
+ const selected = await folder(principal, false);
381
+ return selected ? store.notes.pruneDocumentHistory?.(selected.id, before) : void 0;
382
+ }, "prune"),
383
+ /** The profile's local history: earlier versions of a document and what changed when. */
384
+ history: {
385
+ /** `id` is the source's id, or a `document:<n>` ref; a removed document is found too. */
386
+ reference: /* @__PURE__ */ __name(async (principal, id) => {
387
+ if (/^document:\d+$/.test(id))
388
+ return id;
389
+ const selected = await folder(principal, false);
390
+ if (!selected)
391
+ return void 0;
392
+ for (const path of both(id)) {
393
+ const found = await store.notes.documentAt(selected.id, path);
394
+ if (found)
395
+ return found;
396
+ }
397
+ return void 0;
398
+ }, "reference"),
399
+ versions: /* @__PURE__ */ __name((reference) => store.notes.documentHistory(reference), "versions"),
400
+ version: /* @__PURE__ */ __name((reference, revision) => store.notes.documentVersion(reference, revision), "version"),
401
+ changes: /* @__PURE__ */ __name(async (principal, query) => {
402
+ const selected = await folder(principal, false);
403
+ return selected ? store.notes.documentChanges(selected.id, query) : { items: [], hasMore: false };
404
+ }, "changes")
405
+ }
366
406
  };
367
407
  }, "documentIngestion");
368
408
 
369
- // node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/services/documents/knowledge.js
409
+ // node_modules/.pnpm/@wirecat+cli-core@0.724.0_@wirecat+cli-base@0.130.0_commander@15.0.0_esbuild@0.28.2_typ_7eee7c5df32146a12ad3bd2be9b828b8/node_modules/@wirecat/cli-core/dist/services/documents/knowledge.js
370
410
  var writer = /* @__PURE__ */ __name((by) => {
371
411
  if (by === void 0)
372
412
  throw new CliError("validation_error", "name who writes it: the owner or an agent; there is no default", {
@@ -394,7 +434,7 @@ var documentKnowledge = /* @__PURE__ */ __name((store, folder) => {
394
434
  const noteFor = /* @__PURE__ */ __name(async (principal, ref, noteRef) => {
395
435
  await document(principal, ref);
396
436
  const note = await store.notes.resolveNote(noteRef);
397
- const linked = (await store.notes.links({ from: noteRef })).some((link) => link.to === ref && link.kind === "about");
437
+ const linked = (await store.notes.links({ from: noteRef })).some((link2) => link2.to === ref && link2.kind === "about");
398
438
  if (note?.source !== "internal" || note.deletedAt)
399
439
  throw new CliError("not_found", "note is not attached to this document");
400
440
  if (linked)
@@ -443,11 +483,23 @@ var documentKnowledge = /* @__PURE__ */ __name((store, folder) => {
443
483
  }, "links"),
444
484
  addLink: /* @__PURE__ */ __name(async (principal, ref, input) => {
445
485
  await document(principal, ref);
446
- return store.notes.addLink({ ...input, from: ref, origin: input.by === "owner" ? "owner" : "suggested" });
486
+ const by = writer(input.by);
487
+ const link2 = await store.notes.addLink({
488
+ ...input,
489
+ from: ref,
490
+ ...by === "owner" ? { origin: "owner" } : { origin: "suggested", confirmed: false, provenance: `agent:${by.bot}: ${by.reason.trim()}` }
491
+ });
492
+ if (by !== "owner" || link2.confirmed)
493
+ return link2;
494
+ return await store.knowledge.decideSuggestedLink(link2.id, { confirm: true, by }) ?? link2;
447
495
  }, "addLink"),
448
496
  removeLink: /* @__PURE__ */ __name(async (principal, ref, id, by) => {
449
- const links = await port.links(principal, ref);
450
- if (!links.some((link) => link.id === id && link.origin === "owner"))
497
+ const link2 = (await port.links(principal, ref)).find((item) => item.id === id);
498
+ if (link2 && !link2.confirmed) {
499
+ await store.knowledge.decideSuggestedLink(id, { confirm: false, by });
500
+ return { id, removed: true };
501
+ }
502
+ if (link2?.origin !== "owner")
451
503
  throw new CliError("not_found", "owner link is not attached to this document");
452
504
  return store.notes.removeLink(id, by);
453
505
  }, "removeLink"),
@@ -521,12 +573,12 @@ var documentKnowledge = /* @__PURE__ */ __name((store, folder) => {
521
573
  return port;
522
574
  }, "documentKnowledge");
523
575
 
524
- // node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/documents/markdown-blocks.js
576
+ // node_modules/.pnpm/@wirecat+cli-core@0.724.0_@wirecat+cli-base@0.130.0_commander@15.0.0_esbuild@0.28.2_typ_7eee7c5df32146a12ad3bd2be9b828b8/node_modules/@wirecat/cli-core/dist/documents/markdown-blocks.js
525
577
  var parser;
526
578
  var loadParser = /* @__PURE__ */ __name(() => parser ??= Promise.all([
527
- import("./mdast-util-from-markdown-FXEPSNER.js"),
528
- import("./mdast-util-gfm-SZM5GBDF.js"),
529
- import("./micromark-extension-gfm-GRL24TU6.js")
579
+ import("./mdast-util-from-markdown-HEZF7KJ4.js"),
580
+ import("./mdast-util-gfm-AQW6R6MG.js"),
581
+ import("./micromark-extension-gfm-OE2GBORZ.js")
530
582
  ]).then(([{ fromMarkdown }, { gfmFromMarkdown }, { gfm }]) => (markdown) => fromMarkdown(markdown, { extensions: [gfm()], mdastExtensions: [gfmFromMarkdown()] })), "loadParser");
531
583
  var markdownBlocks = /* @__PURE__ */ __name(async (markdown) => (await placedMarkdownBlocks(markdown)).map((placed) => placed.block), "markdownBlocks");
532
584
  var FRONT_MATTER = /^---[ \t]*\r?\n(?:[^\n]*\n)*?---[ \t]*(?=\r?\n|$)/;
@@ -646,7 +698,7 @@ var placedMarkdownBlocks = /* @__PURE__ */ __name(async (markdown) => {
646
698
  return blocks(tree.children);
647
699
  }, "placedMarkdownBlocks");
648
700
 
649
- // node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/services/documents/markdown-splice.js
701
+ // node_modules/.pnpm/@wirecat+cli-core@0.724.0_@wirecat+cli-base@0.130.0_commander@15.0.0_esbuild@0.28.2_typ_7eee7c5df32146a12ad3bd2be9b828b8/node_modules/@wirecat/cli-core/dist/services/documents/markdown-splice.js
650
702
  var escapeText = /* @__PURE__ */ __name((text) => text.replace(/[\\`*_[\]<>~|]/g, "\\$&"), "escapeText");
651
703
  var codeSpan = /* @__PURE__ */ __name((text) => {
652
704
  const longest = (text.match(/`+/g) ?? []).reduce((most, run) => Math.max(most, run.length), 0);
@@ -673,11 +725,11 @@ var inlineMarkdown = /* @__PURE__ */ __name((inlines, indent = "") => {
673
725
  const runs = normalizeInlines(inlines);
674
726
  let out = "";
675
727
  for (let at = 0; at < runs.length; ) {
676
- const link = runs[at]?.link;
728
+ const link2 = runs[at]?.link;
677
729
  let body = "";
678
- for (; at < runs.length && runs[at]?.link === link; at++)
730
+ for (; at < runs.length && runs[at]?.link === link2; at++)
679
731
  body += styled({ ...runs[at], link: void 0 });
680
- out += link ? `[${body}](${linkTarget(link)})` : body;
732
+ out += link2 ? `[${body}](${linkTarget(link2)})` : body;
681
733
  }
682
734
  return out.replace(/^(#{1,6}\s|[-+*>]\s|[=-]+\s*$)/, "\\$1").replace(/^(\d{1,9})([.)]\s)/, "$1\\$2").replaceAll("\n", `\\
683
735
  ${indent}`);
@@ -832,49 +884,118 @@ var columnsBefore = /* @__PURE__ */ __name((placed, index) => {
832
884
  return columns;
833
885
  }, "columnsBefore");
834
886
 
835
- // node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/services/documents/mirror-watch.js
887
+ // node_modules/.pnpm/@wirecat+cli-core@0.724.0_@wirecat+cli-base@0.130.0_commander@15.0.0_esbuild@0.28.2_typ_7eee7c5df32146a12ad3bd2be9b828b8/node_modules/@wirecat/cli-core/dist/services/documents/mirror-watch.js
836
888
  import { watch } from "node:fs";
837
889
 
838
- // node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/services/documents/mirrors.js
890
+ // node_modules/.pnpm/@wirecat+cli-core@0.724.0_@wirecat+cli-base@0.130.0_commander@15.0.0_esbuild@0.28.2_typ_7eee7c5df32146a12ad3bd2be9b828b8/node_modules/@wirecat/cli-core/dist/services/documents/mirrors.js
839
891
  import { createHash as createHash2 } from "node:crypto";
840
892
  import { mkdirSync, readFileSync } from "node:fs";
841
- import { join as join2 } from "node:path";
893
+ import { dirname as dirname2, join as join2 } from "node:path";
842
894
 
843
- // node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/services/documents/push.js
895
+ // node_modules/.pnpm/@wirecat+cli-core@0.724.0_@wirecat+cli-base@0.130.0_commander@15.0.0_esbuild@0.28.2_typ_7eee7c5df32146a12ad3bd2be9b828b8/node_modules/@wirecat/cli-core/dist/services/documents/push.js
844
896
  import { createHash, randomUUID } from "node:crypto";
845
- import { createReadStream } from "node:fs";
846
- import { chmod, readdir, rename, rm, stat, writeFile } from "node:fs/promises";
897
+ import { createReadStream, createWriteStream } from "node:fs";
898
+ import { chmod, link, lstat, readdir, rename, rm, stat, writeFile } from "node:fs/promises";
847
899
  import { basename, dirname, join, posix } from "node:path";
900
+ import { pipeline } from "node:stream/promises";
848
901
  var SKIPPED = /^(\.|node_modules$|~\$)|(~|\.swp|\.tmp)$/;
849
902
  var skippedName = /* @__PURE__ */ __name((name) => SKIPPED.test(name), "skippedName");
850
903
  var hashFile = /* @__PURE__ */ __name((path) => new Promise((done, fail) => {
851
- const hash = createHash("sha256");
852
- createReadStream(path).on("data", (chunk) => hash.update(chunk)).on("error", fail).on("end", () => done(hash.digest("hex")));
904
+ const sha256 = createHash("sha256");
905
+ const md5 = createHash("md5");
906
+ createReadStream(path).on("data", (chunk) => {
907
+ sha256.update(chunk);
908
+ md5.update(chunk);
909
+ }).on("error", fail).on("end", () => done({ sha256: sha256.digest("hex"), md5: md5.digest("hex") }));
853
910
  }), "hashFile");
854
- var hashText = /* @__PURE__ */ __name((text) => createHash("sha256").update(text).digest("hex"), "hashText");
855
- var replaceLocal = /* @__PURE__ */ __name(async (file, content) => {
856
- const temp = join(dirname(file.absolute), `.${basename(file.absolute)}.${randomUUID().slice(0, 8)}.tmp`);
857
- const { mode } = await stat(file.absolute);
858
- await writeFile(temp, content, { flag: "wx" });
911
+ var placeNew = /* @__PURE__ */ __name(async (from, to) => {
912
+ try {
913
+ await link(from, to);
914
+ return;
915
+ } catch (error) {
916
+ if (!["EPERM", "ENOTSUP", "EOPNOTSUPP", "EXDEV", "ENOSYS"].includes(error.code ?? ""))
917
+ throw error;
918
+ }
919
+ const { mode } = await stat(from);
920
+ let created = false;
921
+ const into = createWriteStream(to, { flags: "wx" }).once("open", () => {
922
+ created = true;
923
+ });
924
+ try {
925
+ await pipeline(createReadStream(from), into);
926
+ await chmod(to, mode & 511);
927
+ } catch (error) {
928
+ if (created)
929
+ await rm(to, { force: true });
930
+ throw error;
931
+ }
932
+ }, "placeNew");
933
+ var assertNoLink = /* @__PURE__ */ __name(async (root, path) => {
934
+ let at = root;
935
+ for (const part of path.split("/")) {
936
+ at = join(at, part);
937
+ try {
938
+ if ((await lstat(at)).isSymbolicLink())
939
+ throw new CliError("validation_error", `${path} is under a symbolic link; the sync does not follow links`, {
940
+ reason: "mirror.symlink"
941
+ });
942
+ } catch (error) {
943
+ if (error.code === "ENOENT")
944
+ return;
945
+ throw error;
946
+ }
947
+ }
948
+ }, "assertNoLink");
949
+ var localTemp = /* @__PURE__ */ __name((absolute, tag) => join(dirname(absolute), `.${basename(absolute)}.${tag}.tmp`), "localTemp");
950
+ var replaceLocal = /* @__PURE__ */ __name(async (absolute, hash, content, { tag = randomUUID().slice(0, 8), sha256 } = {}) => {
951
+ const temp = localTemp(absolute, tag);
952
+ const mode = hash === void 0 ? void 0 : (await stat(absolute)).mode;
859
953
  try {
860
- await chmod(temp, mode & 511);
861
- if (await hashFile(file.absolute) !== file.hash)
954
+ if (typeof content === "function")
955
+ await content(temp);
956
+ else
957
+ await writeFile(temp, content, { flag: "wx" });
958
+ if (mode !== void 0)
959
+ await chmod(temp, mode & 511);
960
+ const written = await hashFile(temp);
961
+ if (sha256 !== void 0 && written.sha256 !== sha256)
962
+ throw new CliError("invalid_response", "the downloaded file has other content than the listing said", {
963
+ reason: "download.mismatch"
964
+ });
965
+ if (hash === void 0) {
966
+ try {
967
+ await placeNew(temp, absolute);
968
+ } catch (error) {
969
+ if (error.code === "EEXIST")
970
+ return void 0;
971
+ throw error;
972
+ }
973
+ return written;
974
+ }
975
+ if ((await hashFile(absolute)).sha256 !== hash)
862
976
  return void 0;
863
- await rename(temp, file.absolute);
977
+ await rename(temp, absolute);
978
+ return written;
864
979
  } finally {
865
980
  await rm(temp, { force: true });
866
981
  }
867
- return hashText(content);
868
982
  }, "replaceLocal");
869
- var scanLocal = /* @__PURE__ */ __name(async (root, kindOf, maxFiles = 1e4) => {
983
+ var scanLocal = /* @__PURE__ */ __name(async (root, kindOf, maxFiles = 1e4, known, skip) => {
870
984
  const files = [];
985
+ const links = [];
871
986
  let unsupported = 0;
872
987
  const walk = /* @__PURE__ */ __name(async (relative) => {
873
988
  const entries = await readdir(join(root, relative), { withFileTypes: true });
874
989
  for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {
875
- if (SKIPPED.test(entry.name) || entry.isSymbolicLink())
990
+ if (SKIPPED.test(entry.name))
876
991
  continue;
877
992
  const path = relative ? posix.join(relative, entry.name) : entry.name;
993
+ if (skip?.(path))
994
+ continue;
995
+ if (entry.isSymbolicLink()) {
996
+ links.push(path);
997
+ continue;
998
+ }
878
999
  if (entry.isDirectory())
879
1000
  await walk(path);
880
1001
  else if (entry.isFile()) {
@@ -888,7 +1009,10 @@ var scanLocal = /* @__PURE__ */ __name(async (root, kindOf, maxFiles = 1e4) => {
888
1009
  reason: "push.too-many-files"
889
1010
  });
890
1011
  const absolute = join(root, path);
891
- files.push({ path, absolute, kind, hash: await hashFile(absolute) });
1012
+ const { size, mtimeMs } = await stat(absolute);
1013
+ const before = known?.(path);
1014
+ const hash = before && before.size === size && before.mtimeMs === mtimeMs ? before.hash : (await hashFile(absolute)).sha256;
1015
+ files.push({ path, absolute, kind, hash, size, mtimeMs });
892
1016
  }
893
1017
  }
894
1018
  }, "walk");
@@ -899,7 +1023,7 @@ var scanLocal = /* @__PURE__ */ __name(async (root, kindOf, maxFiles = 1e4) => {
899
1023
  throw error;
900
1024
  throw new CliError("validation_error", "the folder to push could not be read", { reason: "push.unreadable" });
901
1025
  }
902
- return { files, unsupported };
1026
+ return { files, unsupported, links };
903
1027
  }, "scanLocal");
904
1028
  var planPush = /* @__PURE__ */ __name((files, state) => {
905
1029
  const plan = { create: [], update: [], unchanged: [], orphans: [] };
@@ -1053,12 +1177,13 @@ var pushDocuments = /* @__PURE__ */ __name(async (options) => {
1053
1177
  } else {
1054
1178
  if (prepared.local !== void 0) {
1055
1179
  options.assertHeld();
1056
- const written = await replaceLocal(file, prepared.local);
1180
+ await assertNoLink(root, file.path);
1181
+ const written = await replaceLocal(file.absolute, file.hash, prepared.local);
1057
1182
  if (!written) {
1058
1183
  result.conflicts.push({ path: file.path, url: entry.url, reason: "the local file changed during the sync" });
1059
1184
  continue;
1060
1185
  }
1061
- hash = written;
1186
+ hash = written.sha256;
1062
1187
  result.pulled.push(file.path);
1063
1188
  if (prepared.remote && prepared.afterLocal !== void 0) {
1064
1189
  state.entries[file.path] = { ...entry, snapshot: prepared.afterLocal, hash };
@@ -1092,7 +1217,7 @@ var pushDocuments = /* @__PURE__ */ __name(async (options) => {
1092
1217
  return result;
1093
1218
  }, "pushDocuments");
1094
1219
 
1095
- // node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/services/documents/mirrors.js
1220
+ // node_modules/.pnpm/@wirecat+cli-core@0.724.0_@wirecat+cli-base@0.130.0_commander@15.0.0_esbuild@0.28.2_typ_7eee7c5df32146a12ad3bd2be9b828b8/node_modules/@wirecat/cli-core/dist/services/documents/mirrors.js
1096
1221
  var mirrorId = /* @__PURE__ */ __name((root, folder) => createHash2("sha256").update(JSON.stringify([root, folder])).digest("hex").slice(0, 8), "mirrorId");
1097
1222
  var ID = pipe(string(), regex(/^[A-Za-z0-9_-]{1,200}$/));
1098
1223
  var stateSchema = /* @__PURE__ */ __name((kinds) => object({
@@ -1112,43 +1237,40 @@ var stateSchema = /* @__PURE__ */ __name((kinds) => object({
1112
1237
  })),
1113
1238
  pending: record(string(), object({ origin: string(), operationId: string() }))
1114
1239
  }), "stateSchema");
1115
- var fileMirrorState = /* @__PURE__ */ __name((dir, mirror, principal, kinds) => {
1116
- const path = join2(dir, `${mirror.id}.json`);
1117
- const schema = stateSchema(kinds);
1118
- return {
1119
- read: /* @__PURE__ */ __name(() => {
1120
- let value;
1121
- try {
1122
- value = JSON.parse(readFileSync(path, "utf8"));
1123
- } catch (error) {
1124
- if (error.code === "ENOENT")
1125
- return {
1126
- version: 1,
1127
- principal,
1128
- root: mirror.path,
1129
- target: mirror.folder,
1130
- folders: {},
1131
- entries: {},
1132
- pending: {}
1133
- };
1134
- throw new CliError("configuration_error", "mirror state is unreadable; refusing to reset it", {
1135
- reason: "state.invalid"
1136
- });
1137
- }
1138
- const parsed = safeParse(schema, value);
1139
- if (!parsed.success)
1140
- throw new CliError("configuration_error", "mirror state is invalid; refusing to reset it", {
1141
- reason: "state.invalid"
1142
- });
1143
- return parsed.output;
1144
- }, "read"),
1145
- save: /* @__PURE__ */ __name((state) => {
1146
- mkdirSync(dir, { recursive: true, mode: 448 });
1147
- writeSecurely(path, `${JSON.stringify(state)}
1240
+ var jsonState = /* @__PURE__ */ __name((path, schema, initial) => ({
1241
+ read: /* @__PURE__ */ __name(() => {
1242
+ let value;
1243
+ try {
1244
+ value = JSON.parse(readFileSync(path, "utf8"));
1245
+ } catch (error) {
1246
+ if (error.code === "ENOENT")
1247
+ return initial();
1248
+ throw new CliError("configuration_error", "mirror state is unreadable; refusing to reset it", {
1249
+ reason: "state.invalid"
1250
+ });
1251
+ }
1252
+ const parsed = safeParse(schema, value);
1253
+ if (!parsed.success)
1254
+ throw new CliError("configuration_error", "mirror state is invalid; refusing to reset it", {
1255
+ reason: "state.invalid"
1256
+ });
1257
+ return parsed.output;
1258
+ }, "read"),
1259
+ save: /* @__PURE__ */ __name((state) => {
1260
+ mkdirSync(dirname2(path), { recursive: true, mode: 448 });
1261
+ writeSecurely(path, `${JSON.stringify(state)}
1148
1262
  `, 384);
1149
- }, "save")
1150
- };
1151
- }, "fileMirrorState");
1263
+ }, "save")
1264
+ }), "jsonState");
1265
+ var fileMirrorState = /* @__PURE__ */ __name((dir, mirror, principal, kinds) => jsonState(join2(dir, `${mirror.id}.json`), stateSchema(kinds), () => ({
1266
+ version: 1,
1267
+ principal,
1268
+ root: mirror.path,
1269
+ target: mirror.folder,
1270
+ folders: {},
1271
+ entries: {},
1272
+ pending: {}
1273
+ })), "fileMirrorState");
1152
1274
  var mirrorStatus = /* @__PURE__ */ __name(async (mirrors, kindOf, stateOf) => {
1153
1275
  const items = [];
1154
1276
  for (const mirror of mirrors) {
@@ -1170,41 +1292,25 @@ var mirrorStatus = /* @__PURE__ */ __name(async (mirrors, kindOf, stateOf) => {
1170
1292
  }, "mirrorStatus");
1171
1293
  var conflictReport = /* @__PURE__ */ __name((conflict, remote) => ({
1172
1294
  path: conflict.path,
1173
- url: conflict.url,
1295
+ ...conflict.url ? { url: conflict.url } : {},
1174
1296
  reason: conflict.reason,
1175
1297
  ...conflict.parts ? { parts: conflict.parts.map((part) => ({ last_sync: part.base, local: part.local, [remote]: part.remote })) } : {},
1176
1298
  ...conflict.localChangedAt ? { local_changed_at: conflict.localChangedAt } : {},
1177
1299
  ...conflict.remoteChangedAt ? { [`${remote}_changed_at`]: conflict.remoteChangedAt } : {},
1178
- ...conflict.remoteChangedBy ? { [`${remote}_changed_by`]: conflict.remoteChangedBy } : {}
1300
+ ...conflict.remoteChangedBy ? { [`${remote}_changed_by`]: conflict.remoteChangedBy } : {},
1301
+ ...conflict.localSize !== void 0 ? { local_size: conflict.localSize } : {},
1302
+ ...conflict.remoteSize !== void 0 ? { [`${remote}_size`]: conflict.remoteSize } : {}
1179
1303
  }), "conflictReport");
1180
- var syncMirrors = /* @__PURE__ */ __name(async (options) => {
1181
- const { mirrors, keep, remote } = options;
1182
- const lock = await options.lock();
1304
+ var eachMirror = /* @__PURE__ */ __name(async (mirrors, lock, remote, sync) => {
1305
+ const held = await lock();
1183
1306
  const results = [];
1184
1307
  try {
1185
1308
  for (const mirror of mirrors)
1186
- results.push({
1187
- id: mirror.id,
1188
- path: mirror.path,
1189
- ...await pushDocuments({
1190
- root: mirror.path,
1191
- folder: mirror.folder,
1192
- target: options.target,
1193
- state: options.stateOf(mirror),
1194
- principal: options.principal,
1195
- ...keep ? { keep } : {},
1196
- recreate: options.recreate === true,
1197
- guard: options.guard,
1198
- operationId: options.operationId,
1199
- errorOf: options.errorOf,
1200
- assertHeld: /* @__PURE__ */ __name(() => lock.assertHeld(), "assertHeld"),
1201
- ...options.signal ? { signal: options.signal } : {}
1202
- })
1203
- });
1309
+ results.push({ id: mirror.id, path: mirror.path, ...await sync(mirror, held) });
1204
1310
  } finally {
1205
- await lock.release();
1311
+ await held.release();
1206
1312
  }
1207
- const issues = results.filter((result) => result.errors.length || result.conflicts.length || result.missing.length).map((result) => ({ code: "provider_error", reason: "mirror.partial", source: `mirror ${result.id}` }));
1313
+ const issues = results.filter((result) => result.errors.length || result.conflicts.length || result.missing?.length || result.unknown?.length).map((result) => ({ code: "provider_error", reason: "mirror.partial", source: `mirror ${result.id}` }));
1208
1314
  return {
1209
1315
  items: results.map(({ conflicts, ...result }) => ({
1210
1316
  ...result,
@@ -1212,9 +1318,23 @@ var syncMirrors = /* @__PURE__ */ __name(async (options) => {
1212
1318
  })),
1213
1319
  issues
1214
1320
  };
1215
- }, "syncMirrors");
1321
+ }, "eachMirror");
1322
+ var syncMirrors = /* @__PURE__ */ __name((options) => eachMirror(options.mirrors, options.lock, options.remote, (mirror, held) => pushDocuments({
1323
+ root: mirror.path,
1324
+ folder: mirror.folder,
1325
+ target: options.target,
1326
+ state: options.stateOf(mirror),
1327
+ principal: options.principal,
1328
+ ...options.keep ? { keep: options.keep } : {},
1329
+ recreate: options.recreate === true,
1330
+ guard: options.guard,
1331
+ operationId: options.operationId,
1332
+ errorOf: options.errorOf,
1333
+ assertHeld: /* @__PURE__ */ __name(() => held.assertHeld(), "assertHeld"),
1334
+ ...options.signal ? { signal: options.signal } : {}
1335
+ })), "syncMirrors");
1216
1336
 
1217
- // node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/services/documents/mirror-watch.js
1337
+ // node_modules/.pnpm/@wirecat+cli-core@0.724.0_@wirecat+cli-base@0.130.0_commander@15.0.0_esbuild@0.28.2_typ_7eee7c5df32146a12ad3bd2be9b828b8/node_modules/@wirecat/cli-core/dist/services/documents/mirror-watch.js
1218
1338
  var sleep = /* @__PURE__ */ __name((milliseconds, signal) => new Promise((resolve) => {
1219
1339
  const finish = /* @__PURE__ */ __name(() => {
1220
1340
  clearTimeout(timer);
@@ -1257,6 +1377,8 @@ async function* watchMirrors(sync, options) {
1257
1377
  const differs = /* @__PURE__ */ __name(async (ids) => {
1258
1378
  const chosen = [...ids].flatMap((id) => byId.get(id) ?? []);
1259
1379
  try {
1380
+ if ("localChanges" in options)
1381
+ return await options.localChanges(chosen);
1260
1382
  const items = await mirrorStatus(chosen, options.kindOf, options.stateOf);
1261
1383
  return items.filter((item) => item.create.length || item.update.length).map((item) => item.id);
1262
1384
  } catch {
@@ -1353,7 +1475,7 @@ async function* watchMirrors(sync, options) {
1353
1475
  }
1354
1476
  __name(watchMirrors, "watchMirrors");
1355
1477
 
1356
- // node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/services/documents/proposals.js
1478
+ // node_modules/.pnpm/@wirecat+cli-core@0.724.0_@wirecat+cli-base@0.130.0_commander@15.0.0_esbuild@0.28.2_typ_7eee7c5df32146a12ad3bd2be9b828b8/node_modules/@wirecat/cli-core/dist/services/documents/proposals.js
1357
1479
  var extractDocumentMemories = /* @__PURE__ */ __name(async (options) => {
1358
1480
  const source = options.read();
1359
1481
  const text = options.tab ? source.snapshot.tabs.find((tab) => tab.id === options.tab)?.text : source.snapshot.text;
@@ -1403,11 +1525,11 @@ Snapshot: ${source.hash}`;
1403
1525
  };
1404
1526
  }, "extractDocumentMemories");
1405
1527
 
1406
- // node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/services/documents/sync.js
1528
+ // node_modules/.pnpm/@wirecat+cli-core@0.724.0_@wirecat+cli-base@0.130.0_commander@15.0.0_esbuild@0.28.2_typ_7eee7c5df32146a12ad3bd2be9b828b8/node_modules/@wirecat/cli-core/dist/services/documents/sync.js
1407
1529
  import { createHash as createHash4 } from "node:crypto";
1408
1530
 
1409
- // node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/documents/scope.js
1410
- var within = /* @__PURE__ */ __name((file, roots, folders, seen = /* @__PURE__ */ new Set()) => {
1531
+ // node_modules/.pnpm/@wirecat+cli-core@0.724.0_@wirecat+cli-base@0.130.0_commander@15.0.0_esbuild@0.28.2_typ_7eee7c5df32146a12ad3bd2be9b828b8/node_modules/@wirecat/cli-core/dist/documents/scope.js
1532
+ var within = /* @__PURE__ */ __name((file, roots, folders, seen = /* @__PURE__ */ new Set(), cut) => {
1411
1533
  if (file.trashed)
1412
1534
  return false;
1413
1535
  if (roots.includes(file.id))
@@ -1417,18 +1539,21 @@ var within = /* @__PURE__ */ __name((file, roots, folders, seen = /* @__PURE__ *
1417
1539
  const next = /* @__PURE__ */ new Set([...seen, file.id]);
1418
1540
  return file.parents.some((id) => {
1419
1541
  const folder = folders[id];
1420
- return folder ? within(folder, roots, folders, next) : roots.includes(id);
1542
+ if (!folder)
1543
+ return roots.includes(id);
1544
+ return (roots.includes(id) || !cut?.(folder)) && within(folder, roots, folders, next, cut);
1421
1545
  });
1422
1546
  }, "within");
1423
1547
  var inScope = /* @__PURE__ */ __name((file, roots, folders, matched = /* @__PURE__ */ new Set(), query) => {
1424
1548
  if (file.trashed)
1425
1549
  return false;
1426
- if (query?.mode === "exclude" && query.matches(file))
1550
+ const excluded = query?.mode === "exclude" ? query.matches : void 0;
1551
+ if (excluded?.(file))
1427
1552
  return false;
1428
- return matched.has(file.id) || within(file, roots, folders);
1553
+ return matched.has(file.id) || within(file, roots, folders, /* @__PURE__ */ new Set(), excluded);
1429
1554
  }, "inScope");
1430
1555
 
1431
- // node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/documents/catalog.js
1556
+ // node_modules/.pnpm/@wirecat+cli-core@0.724.0_@wirecat+cli-base@0.130.0_commander@15.0.0_esbuild@0.28.2_typ_7eee7c5df32146a12ad3bd2be9b828b8/node_modules/@wirecat/cli-core/dist/documents/catalog.js
1432
1557
  var catalogFiles = /* @__PURE__ */ __name((state, roots, query) => {
1433
1558
  const folders = state.pending?.folders ?? state.folders;
1434
1559
  const matched = new Set(state.pending?.matched ?? state.matched ?? []);
@@ -1447,14 +1572,32 @@ var catalogFiles = /* @__PURE__ */ __name((state, roots, query) => {
1447
1572
  return [...files.values()].filter((file) => inScope(file, roots, folders, matched, query));
1448
1573
  }, "catalogFiles");
1449
1574
 
1450
- // node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/services/documents/plan.js
1575
+ // node_modules/.pnpm/@wirecat+cli-core@0.724.0_@wirecat+cli-base@0.130.0_commander@15.0.0_esbuild@0.28.2_typ_7eee7c5df32146a12ad3bd2be9b828b8/node_modules/@wirecat/cli-core/dist/services/documents/plan.js
1451
1576
  import { createHash as createHash3 } from "node:crypto";
1577
+
1578
+ // node_modules/.pnpm/@wirecat+cli-core@0.724.0_@wirecat+cli-base@0.130.0_commander@15.0.0_esbuild@0.28.2_typ_7eee7c5df32146a12ad3bd2be9b828b8/node_modules/@wirecat/cli-core/dist/documents/model.js
1579
+ var feedOf = /* @__PURE__ */ __name((source) => "changes" in source && typeof source.changes === "function" ? source : void 0, "feedOf");
1580
+
1581
+ // node_modules/.pnpm/@wirecat+cli-core@0.724.0_@wirecat+cli-base@0.130.0_commander@15.0.0_esbuild@0.28.2_typ_7eee7c5df32146a12ad3bd2be9b828b8/node_modules/@wirecat/cli-core/dist/services/documents/plan.js
1452
1582
  var scopeHash = /* @__PURE__ */ __name((roots, query, pages = false) => createHash3("sha256").update(JSON.stringify(query || pages ? [[...roots].sort(), query?.mode, query?.key, ...pages ? ["pages"] : []] : [...roots].sort())).digest("hex"), "scopeHash");
1453
1583
  var changedSince = /* @__PURE__ */ __name((previous, file) => previous.version !== file.version || previous.modifiedAt !== file.modifiedAt || previous.name !== file.name || previous.canDownload !== file.canDownload || JSON.stringify(previous.parents) !== JSON.stringify(file.parents), "changedSince");
1454
1584
  var SAVE_EVERY_MS = 2e3;
1585
+ var REREAD_BATCH = 50;
1586
+ var WALKED = "walked";
1455
1587
  var changesScope = /* @__PURE__ */ __name((scope, cursor) => `${scope}:changes:${cursor}`, "changesScope");
1456
1588
  var planDocuments = /* @__PURE__ */ __name(async (options, source, state, roots, limit, pictures, walks) => {
1457
1589
  const { isFolder, skipReason, retryable, maxEntries, errorOf, query, budget } = options;
1590
+ const answers = /* @__PURE__ */ new Map();
1591
+ const cut = query?.mode === "exclude" ? (file) => {
1592
+ const known = answers.get(file.id);
1593
+ if (known !== void 0)
1594
+ return known;
1595
+ const found2 = query.matches(file);
1596
+ answers.set(file.id, found2);
1597
+ return found2;
1598
+ } : void 0;
1599
+ const scoped = cut && query ? { ...query, matches: cut } : query;
1600
+ const excluded = /* @__PURE__ */ __name((folder) => !roots.includes(folder.id) && cut?.(folder) === true, "excluded");
1458
1601
  const scope = scopeHash(roots, query, options.isDocument !== void 0);
1459
1602
  if (!roots.length && query?.mode !== "include")
1460
1603
  return {
@@ -1463,7 +1606,7 @@ var planDocuments = /* @__PURE__ */ __name(async (options, source, state, roots,
1463
1606
  cursor: state.cursor ?? "",
1464
1607
  folders: {},
1465
1608
  skipped: [],
1466
- jobs: Object.keys(state.documents).map((id) => ({ id, kind: "remove" }))
1609
+ jobs: Object.keys(state.documents).map((id) => ({ id, kind: "remove", reason: "unsynced" }))
1467
1610
  }
1468
1611
  };
1469
1612
  if (!source)
@@ -1471,36 +1614,51 @@ var planDocuments = /* @__PURE__ */ __name(async (options, source, state, roots,
1471
1614
  if (query?.mode === "include" && !query.list)
1472
1615
  throw new CliError("configuration_error", "a query that includes files must list them");
1473
1616
  const initial = !state.cursor || scope !== state.scope;
1474
- const resumed = walks?.read(initial ? scope : changesScope(scope, state.cursor));
1475
- const folders = initial ? {} : structuredClone(state.folders);
1617
+ const feed = feedOf(source);
1618
+ const full = initial || !feed;
1619
+ const resumed = walks?.read(full ? scope : changesScope(scope, state.cursor));
1620
+ const folders = full ? {} : structuredClone(state.folders);
1476
1621
  const files = new Map(Object.values(state.documents).map((doc) => [doc.metadata.id, doc.metadata]));
1477
1622
  const changed = /* @__PURE__ */ new Set();
1478
1623
  const delta = /* @__PURE__ */ new Map();
1479
1624
  for (const skipped2 of state.skipped)
1480
1625
  if (skipped2.file)
1481
1626
  files.set(skipped2.id, skipped2.file);
1482
- if (initial)
1627
+ if (full)
1483
1628
  files.clear();
1629
+ const prior = /* @__PURE__ */ __name((id) => state.documents[id]?.metadata ?? state.skipped.find((item) => item.id === id)?.file, "prior");
1630
+ const moved = /* @__PURE__ */ __name((before, file) => JSON.stringify(before.providerMetadata ?? null) !== JSON.stringify(file.providerMetadata ?? null), "moved");
1484
1631
  const keep = /* @__PURE__ */ __name((file) => {
1485
1632
  files.set(file.id, file);
1486
- changed.add(file.id);
1633
+ const before = feed || initial ? void 0 : prior(file.id);
1634
+ if (!before || changedSince(before, file) || moved(before, file))
1635
+ changed.add(file.id);
1487
1636
  delta.set(file.id, file);
1488
1637
  }, "keep");
1489
- const drop = /* @__PURE__ */ __name((id) => {
1638
+ const removals = /* @__PURE__ */ new Map();
1639
+ const drop = /* @__PURE__ */ __name((id, reason) => {
1490
1640
  const known = files.get(id);
1491
1641
  if (known)
1492
1642
  delta.set(id, { ...known, trashed: true });
1493
1643
  files.delete(id);
1644
+ removals.set(id, reason);
1494
1645
  }, "drop");
1495
1646
  const container = /* @__PURE__ */ __name((file) => {
1496
1647
  if (options.isDocument?.(file))
1497
1648
  keep(file);
1498
1649
  }, "container");
1499
- const walked = /* @__PURE__ */ __name((id) => !initial && state.folders[id] !== void 0 && !state.folders[id]?.trashed, "walked");
1650
+ const walked = /* @__PURE__ */ __name((id) => !full && state.folders[id] !== void 0 && !state.folders[id]?.trashed, "walked");
1500
1651
  let walk = resumed;
1501
1652
  let cursor = state.cursor ?? "";
1502
- if (!walk && initial) {
1503
- const start = await source.startToken();
1653
+ const charge = /* @__PURE__ */ __name(() => {
1654
+ const taken = options.signal?.aborted ? "cancelled" : budget?.take();
1655
+ return taken === "deadline" && budget?.first?.() ? null : taken ?? null;
1656
+ }, "charge");
1657
+ if (!walk && full) {
1658
+ const before = charge();
1659
+ if (before)
1660
+ return { walk: { folders_left: roots.length, entries: 0, listed: 0, stopped: before } };
1661
+ const start = feed ? await feed.startToken() : WALKED;
1504
1662
  walk = {
1505
1663
  scope,
1506
1664
  cursor: start,
@@ -1511,12 +1669,15 @@ var planDocuments = /* @__PURE__ */ __name(async (options, source, state, roots,
1511
1669
  discovered: 0
1512
1670
  };
1513
1671
  } else if (!walk) {
1514
- const page = await source.changes(cursor);
1672
+ const before = charge();
1673
+ if (before)
1674
+ return { walk: { folders_left: 0, entries: 0, listed: 0, stopped: before } };
1675
+ const page = await feed.changes(cursor);
1515
1676
  const latest = new Map(page.items.map((change) => [change.id, change]));
1516
1677
  const entering = [];
1517
1678
  for (const change of latest.values()) {
1518
1679
  if (change.removed || change.file?.trashed) {
1519
- drop(change.id);
1680
+ drop(change.id, change.file?.trashed ? "deleted" : change.gone ?? "unavailable");
1520
1681
  if (folders[change.id])
1521
1682
  folders[change.id] = { ...folders[change.id], trashed: true };
1522
1683
  } else if (change.file && isFolder(change.file)) {
@@ -1531,7 +1692,7 @@ var planDocuments = /* @__PURE__ */ __name(async (options, source, state, roots,
1531
1692
  for (const root of roots) {
1532
1693
  const previous = folders[root];
1533
1694
  try {
1534
- const current = await source.metadata(root);
1695
+ const current = await source.metadata(root, folders[root]);
1535
1696
  if (current.id !== root || !isFolder(current))
1536
1697
  throw new CliError("invalid_response", "selected folder metadata is inconsistent");
1537
1698
  folders[root] = current;
@@ -1544,7 +1705,7 @@ var planDocuments = /* @__PURE__ */ __name(async (options, source, state, roots,
1544
1705
  folders[root] = { ...previous, trashed: true };
1545
1706
  }
1546
1707
  }
1547
- const stack = entering.filter((folder) => within(folder, roots, folders)).reverse().map((folder) => ({ id: folder.id, ancestry: [], folder }));
1708
+ const stack = entering.filter((folder) => !excluded(folder) && within(folder, roots, folders, /* @__PURE__ */ new Set(), cut)).reverse().map((folder) => ({ id: folder.id, ancestry: [], folder }));
1548
1709
  if (stack.length)
1549
1710
  walk = {
1550
1711
  scope: changesScope(scope, cursor),
@@ -1558,9 +1719,9 @@ var planDocuments = /* @__PURE__ */ __name(async (options, source, state, roots,
1558
1719
  else
1559
1720
  cursor = page.cursor;
1560
1721
  }
1561
- const vanished = /* @__PURE__ */ __name(async (id) => {
1722
+ const vanished = /* @__PURE__ */ __name(async (id, known) => {
1562
1723
  try {
1563
- return (await source.metadata(id)).trashed;
1724
+ return (await source.metadata(id, known)).trashed;
1564
1725
  } catch (error) {
1565
1726
  return errorOf(error).code === "not_found";
1566
1727
  }
@@ -1571,7 +1732,7 @@ var planDocuments = /* @__PURE__ */ __name(async (options, source, state, roots,
1571
1732
  Object.assign(folders, walk.folders);
1572
1733
  for (const file of walk.files) {
1573
1734
  if (file.trashed)
1574
- drop(file.id);
1735
+ drop(file.id, "unavailable");
1575
1736
  else
1576
1737
  keep(file);
1577
1738
  }
@@ -1594,21 +1755,41 @@ var planDocuments = /* @__PURE__ */ __name(async (options, source, state, roots,
1594
1755
  walk.stack.pop();
1595
1756
  continue;
1596
1757
  }
1597
- stopped = options.signal?.aborted ? "cancelled" : listed > 0 && spent >= maxEntries ? "entries" : budget?.take() ?? null;
1758
+ const taken = options.signal?.aborted ? "cancelled" : listed > 0 && spent >= maxEntries ? "entries" : budget?.take();
1759
+ stopped = taken === "deadline" && budget?.first?.() ? null : taken ?? null;
1598
1760
  if (stopped)
1599
1761
  break;
1600
- const folder = step.folder ?? await source.metadata(step.id);
1601
- if (!step.folder && (!isFolder(folder) || folder.trashed))
1602
- throw new CliError("validation_error", "configured root is not an accessible folder");
1603
- if (!step.folder)
1604
- container(folder);
1762
+ if (!step.folder) {
1763
+ const known = state.folders[step.id];
1764
+ let root;
1765
+ try {
1766
+ root = await source.metadata(step.id, known);
1767
+ } catch (error) {
1768
+ if (feed || !known || errorOf(error).code !== "not_found")
1769
+ throw error;
1770
+ walk.stack.pop();
1771
+ visited.add(step.id);
1772
+ folders[step.id] = { ...known, trashed: true };
1773
+ spent++;
1774
+ listed++;
1775
+ continue;
1776
+ }
1777
+ if (!isFolder(root) || root.trashed)
1778
+ throw new CliError("validation_error", "configured root is not an accessible folder");
1779
+ container(root);
1780
+ step.folder = root;
1781
+ stopped = charge();
1782
+ if (stopped)
1783
+ break;
1784
+ }
1785
+ const folder = step.folder;
1605
1786
  let children;
1606
1787
  let more;
1607
1788
  try {
1608
1789
  if (source.childrenPage)
1609
- ({ files: children, cursor: more } = await source.childrenPage(folder.id, step.listing));
1790
+ ({ files: children, cursor: more } = await source.childrenPage(folder.id, step.listing, folder));
1610
1791
  else
1611
- children = await source.children(folder.id);
1792
+ children = await source.children(folder.id, folder);
1612
1793
  } catch (error) {
1613
1794
  if (errorOf(error).code !== "not_found")
1614
1795
  throw error;
@@ -1618,12 +1799,12 @@ var planDocuments = /* @__PURE__ */ __name(async (options, source, state, roots,
1618
1799
  listed++;
1619
1800
  continue;
1620
1801
  }
1621
- if (!await vanished(folder.id))
1802
+ if (!await vanished(folder.id, folder))
1622
1803
  throw error;
1623
1804
  walk.stack.pop();
1624
1805
  visited.add(folder.id);
1625
1806
  folders[folder.id] = { ...folder, trashed: true };
1626
- drop(folder.id);
1807
+ drop(folder.id, "unavailable");
1627
1808
  spent++;
1628
1809
  listed++;
1629
1810
  continue;
@@ -1636,6 +1817,8 @@ var planDocuments = /* @__PURE__ */ __name(async (options, source, state, roots,
1636
1817
  for (const file of children)
1637
1818
  if (isFolder(file)) {
1638
1819
  container(file);
1820
+ if (excluded(file))
1821
+ continue;
1639
1822
  if (walked(file.id))
1640
1823
  folders[file.id] = file;
1641
1824
  else
@@ -1670,19 +1853,22 @@ var planDocuments = /* @__PURE__ */ __name(async (options, source, state, roots,
1670
1853
  for (const file of found) {
1671
1854
  if (isFolder(file) && !options.isDocument?.(file) || file.trashed || !query?.matches(file) || matched.has(file.id))
1672
1855
  continue;
1673
- const prior = state.documents[file.id]?.metadata ?? state.skipped.find((item) => item.id === file.id)?.file;
1674
- if (initial || !prior || changedSince(prior, file))
1856
+ const prior2 = state.documents[file.id]?.metadata ?? state.skipped.find((item) => item.id === file.id)?.file;
1857
+ if (initial || !prior2 || changedSince(prior2, file))
1675
1858
  changed.add(file.id);
1676
1859
  files.set(file.id, file);
1677
1860
  matched.add(file.id);
1678
1861
  }
1679
1862
  const jobs = [];
1680
1863
  const skipped = [];
1864
+ const again = [];
1865
+ let rereads = 0;
1866
+ const reread = /* @__PURE__ */ __name((known) => known !== void 0 && !known.notRead && rereads < REREAD_BATCH && source.reread?.(known) === true && ++rereads > 0, "reread");
1681
1867
  for (const root of roots)
1682
1868
  if (folders[root]?.trashed)
1683
1869
  skipped.push({ id: root, reason: "selected folder is unavailable" });
1684
1870
  for (const [id, file] of files) {
1685
- if (!inScope(file, roots, folders, matched, query))
1871
+ if (!inScope(file, roots, folders, matched, scoped))
1686
1872
  continue;
1687
1873
  const previousSkip = state.skipped.find((item) => item.id === id);
1688
1874
  const reason = skipReason(file);
@@ -1700,16 +1886,25 @@ var planDocuments = /* @__PURE__ */ __name(async (options, source, state, roots,
1700
1886
  continue;
1701
1887
  }
1702
1888
  if (changed.has(id) || retry || known?.notRead) {
1703
- if (!known || known.notRead || changedSince(known.metadata, file) || initial)
1889
+ if (!known || known.notRead || changedSince(known.metadata, file) || initial || !feed && moved(known.metadata, file))
1704
1890
  jobs.push({ id, kind: "save", file });
1705
- }
1891
+ else if (reread(known))
1892
+ again.push({ id, kind: "save", file });
1893
+ } else if (reread(known))
1894
+ again.push({ id, kind: "save", file });
1706
1895
  }
1896
+ for (const job of again)
1897
+ jobs.push(job);
1898
+ const narrowed = state.scope !== scope;
1707
1899
  for (const id of Object.keys(state.documents)) {
1708
1900
  const file = files.get(id);
1709
- if (!file || !inScope(file, roots, folders, matched, query))
1710
- jobs.push({ id, kind: "remove" });
1901
+ const known = file ?? state.documents[id]?.metadata;
1902
+ if (file && inScope(file, roots, folders, matched, scoped))
1903
+ continue;
1904
+ const outside = narrowed && known !== void 0 && !inScope(known, roots, folders, matched, scoped);
1905
+ jobs.push({ id, kind: "remove", reason: removals.get(id) ?? (outside ? "unsynced" : "unavailable") });
1711
1906
  }
1712
- const scopedFolders = Object.fromEntries(Object.entries(folders).filter(([, file]) => within(file, roots, folders) || roots.includes(file.id)));
1907
+ const scopedFolders = Object.fromEntries(Object.entries(folders).filter(([, file]) => roots.includes(file.id) || !excluded(file) && within(file, roots, folders, /* @__PURE__ */ new Set(), cut)));
1713
1908
  return {
1714
1909
  pending: {
1715
1910
  scope,
@@ -1722,13 +1917,15 @@ var planDocuments = /* @__PURE__ */ __name(async (options, source, state, roots,
1722
1917
  };
1723
1918
  }, "planDocuments");
1724
1919
 
1725
- // node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/services/documents/sync.js
1920
+ // node_modules/.pnpm/@wirecat+cli-core@0.724.0_@wirecat+cli-base@0.130.0_commander@15.0.0_esbuild@0.28.2_typ_7eee7c5df32146a12ad3bd2be9b828b8/node_modules/@wirecat/cli-core/dist/services/documents/sync.js
1726
1921
  var MAX_PICTURE_BYTES = 25 * 1024 * 1024;
1727
1922
  var SAVE_EVERY_MS2 = 2e3;
1728
1923
  var SAVE_EVERY_ITEMS = 25;
1729
1924
  var SETTLE_MS = 1e4;
1925
+ var DAY_MS = 24 * 60 * 60 * 1e3;
1926
+ var KEEP_VERSIONS_FOR_DAYS = 365;
1730
1927
  var isPicture = /* @__PURE__ */ __name((file) => file.mime.startsWith("image/") && file.canDownload, "isPicture");
1731
- var hashText2 = /* @__PURE__ */ __name((text) => createHash4("sha256").update(text).digest("hex"), "hashText");
1928
+ var hashText = /* @__PURE__ */ __name((text) => createHash4("sha256").update(text).digest("hex"), "hashText");
1732
1929
  var syncDocuments = /* @__PURE__ */ __name(async (options) => {
1733
1930
  const { source, index, state: statePort, principal, roots, textLimit: limit, max, signal, rescan = false, pictures = false, assertHeld, errorOf, skipReason, storeVersion: VERSION, query } = options;
1734
1931
  if (![max, limit, options.maxEntries].every((value) => Number.isSafeInteger(value) && value > 0))
@@ -1760,11 +1957,13 @@ var syncDocuments = /* @__PURE__ */ __name(async (options) => {
1760
1957
  const state = statePort.read();
1761
1958
  if (state.principal !== principal)
1762
1959
  throw new CliError("configuration_error", "sync state belongs to another source account");
1960
+ if (options.profile !== void 0)
1961
+ await index.registerProfile?.(options.profile, principal);
1763
1962
  const currentScope = scopeHash(profile.roots, query, options.isDocument !== void 0);
1764
1963
  if (state.pending && (state.pending.scope !== currentScope || rescan)) {
1765
1964
  for (const job of state.pending.jobs)
1766
1965
  if (!state.documents[job.id]) {
1767
- await index.remove(profile.principal, job.id);
1966
+ await index.remove(profile.principal, job.id, "unsynced");
1768
1967
  statePort.removeSnapshot(job.id);
1769
1968
  }
1770
1969
  delete state.pending;
@@ -1800,7 +1999,7 @@ var syncDocuments = /* @__PURE__ */ __name(async (options) => {
1800
1999
  result.skipped = state.skipped.map(({ id, reason }) => ({ id, reason }));
1801
2000
  const saveNamesOnly = /* @__PURE__ */ __name(async (file, reason) => {
1802
2001
  const doc = { metadata: file, markdown: "", text: "", tabs: [], notRead: reason };
1803
- const hash = hashText2("");
2002
+ const hash = hashText("");
1804
2003
  const previous = state.documents[file.id];
1805
2004
  const reference = await index.save(profile.principal, doc, hash);
1806
2005
  statePort.saveSnapshot(doc);
@@ -1810,15 +2009,19 @@ var syncDocuments = /* @__PURE__ */ __name(async (options) => {
1810
2009
  else
1811
2010
  result.names_only++;
1812
2011
  }, "saveNamesOnly");
2012
+ const ask = /* @__PURE__ */ __name(() => {
2013
+ const taken = options.budget?.take() ?? null;
2014
+ return taken === "deadline" && options.budget?.first?.() ? null : taken;
2015
+ }, "ask");
1813
2016
  let modelMissing = false;
1814
2017
  const savePictureOf = /* @__PURE__ */ __name(async (file) => {
1815
2018
  const entry = state.documents[file.id];
1816
2019
  if (!profile.picture_search || !isPicture(file) || modelMissing)
1817
- return;
2020
+ return null;
1818
2021
  if ((file.size ?? 0) > MAX_PICTURE_BYTES) {
1819
2022
  entry.picture = "too-large";
1820
2023
  result.pictures_too_large = (result.pictures_too_large ?? 0) + 1;
1821
- return;
2024
+ return null;
1822
2025
  }
1823
2026
  if (!source)
1824
2027
  throw new CliError("configuration_error", "a pending picture requires source sign-in");
@@ -1830,18 +2033,22 @@ var syncDocuments = /* @__PURE__ */ __name(async (options) => {
1830
2033
  throw error;
1831
2034
  modelMissing = true;
1832
2035
  result.pictures_skipped = error.message;
1833
- return;
2036
+ return null;
1834
2037
  }
1835
2038
  }
1836
- const bytes = await source.bytes(file.id);
2039
+ const stop = ask();
2040
+ if (stop)
2041
+ return stop;
2042
+ const bytes = await source.bytes(file.id, file);
1837
2043
  if (bytes.length > MAX_PICTURE_BYTES) {
1838
2044
  entry.picture = "too-large";
1839
2045
  result.pictures_too_large = (result.pictures_too_large ?? 0) + 1;
1840
- return;
2046
+ return null;
1841
2047
  }
1842
2048
  if (await writer2.save(entry.reference, bytes) === "saved")
1843
2049
  result.pictures = (result.pictures ?? 0) + 1;
1844
2050
  entry.picture = "saved";
2051
+ return null;
1845
2052
  }, "savePictureOf");
1846
2053
  let unsaved = 0;
1847
2054
  let savedAt = now();
@@ -1862,30 +2069,34 @@ var syncDocuments = /* @__PURE__ */ __name(async (options) => {
1862
2069
  lock.assertHeld();
1863
2070
  try {
1864
2071
  if (job.kind === "remove") {
1865
- await index.remove(profile.principal, job.id);
2072
+ await index.remove(profile.principal, job.id, job.reason ?? "unavailable");
1866
2073
  statePort.removeSnapshot(job.id);
1867
2074
  delete state.documents[job.id];
1868
2075
  result.removed++;
1869
2076
  } else if (job.file && skipReason(job.file)) {
1870
2077
  await saveNamesOnly(job.file, skipReason(job.file));
1871
- await savePictureOf(job.file);
2078
+ const stop = await savePictureOf(job.file);
2079
+ if (stop) {
2080
+ result.stopped = stop;
2081
+ break;
2082
+ }
1872
2083
  } else {
1873
2084
  if (!source)
1874
2085
  throw new CliError("configuration_error", "a pending save requires source sign-in");
1875
- const stop = options.budget?.take();
2086
+ const stop = ask();
1876
2087
  if (stop) {
1877
2088
  result.stopped = stop;
1878
2089
  break;
1879
2090
  }
1880
- const content = await source.content(job.id, limit);
2091
+ const content = await source.content(job.id, limit, job.file);
1881
2092
  const listed = query?.mode === "include" && (pending.matched?.includes(job.id) ?? query.matches(content.metadata));
1882
2093
  if (!listed && !inScope(content.metadata, profile.roots, pending.folders, /* @__PURE__ */ new Set(), query)) {
1883
- await index.remove(profile.principal, job.id);
2094
+ await index.remove(profile.principal, job.id, "unsynced");
1884
2095
  statePort.removeSnapshot(job.id);
1885
2096
  delete state.documents[job.id];
1886
2097
  result.removed++;
1887
2098
  } else {
1888
- const hash = hashText2(content.text);
2099
+ const hash = hashText(content.text);
1889
2100
  const previous = state.documents[job.id];
1890
2101
  const reference = await index.save(profile.principal, content, hash).catch((error) => {
1891
2102
  if (!isCliError(error) || error.code !== "validation_error")
@@ -1909,7 +2120,7 @@ var syncDocuments = /* @__PURE__ */ __name(async (options) => {
1909
2120
  const safe = errorOf(error);
1910
2121
  if (safe.code === "cancelled")
1911
2122
  throw safe;
1912
- if (job.kind === "save" && (safe.code === "not_found" || safe.code === "validation_error")) {
2123
+ if (job.kind === "save" && (safe.code === "not_found" || safe.code === "permission_error" || safe.code === "validation_error")) {
1913
2124
  const skipped = {
1914
2125
  id: job.id,
1915
2126
  reason: safe.message,
@@ -1920,7 +2131,7 @@ var syncDocuments = /* @__PURE__ */ __name(async (options) => {
1920
2131
  if (job.file && safe.code === "validation_error")
1921
2132
  await saveNamesOnly(job.file, skipped.reason);
1922
2133
  else {
1923
- await index.remove(profile.principal, job.id);
2134
+ await index.remove(profile.principal, job.id, "unavailable");
1924
2135
  statePort.removeSnapshot(job.id);
1925
2136
  delete state.documents[job.id];
1926
2137
  }
@@ -1948,6 +2159,8 @@ var syncDocuments = /* @__PURE__ */ __name(async (options) => {
1948
2159
  delete state.pending;
1949
2160
  state.lastSync = new Date(now()).toISOString();
1950
2161
  statePort.save(state);
2162
+ const days = options.keepVersionsForDays ?? KEEP_VERSIONS_FOR_DAYS;
2163
+ await index.prune?.(profile.principal, new Date(now() - days * DAY_MS).toISOString());
1951
2164
  }
1952
2165
  const settleFrom = Date.now();
1953
2166
  const settleUntil = Math.min(settleFrom + SETTLE_MS, options.deadline ? options.deadline.endsAt - deadlineMargin(options.deadline) : Number.POSITIVE_INFINITY);
@@ -1960,6 +2173,97 @@ var syncDocuments = /* @__PURE__ */ __name(async (options) => {
1960
2173
  }
1961
2174
  }, "syncDocuments");
1962
2175
 
2176
+ // node_modules/.pnpm/@wirecat+cli-core@0.724.0_@wirecat+cli-base@0.130.0_commander@15.0.0_esbuild@0.28.2_typ_7eee7c5df32146a12ad3bd2be9b828b8/node_modules/@wirecat/cli-core/dist/services/files/text-merge.js
2177
+ var MAX_MERGE_BYTES = 1024 * 1024;
2178
+
2179
+ // node_modules/.pnpm/@wirecat+cli-core@0.724.0_@wirecat+cli-base@0.130.0_commander@15.0.0_esbuild@0.28.2_typ_7eee7c5df32146a12ad3bd2be9b828b8/node_modules/@wirecat/cli-core/dist/services/files/guarded-write.js
2180
+ var remoteChanged = /* @__PURE__ */ __name((path, why, reread) => new CliError("conflict", `${path} ${why}; nothing was written. Read it again: ${reread}`, {
2181
+ reason: "mirror.remote-changed"
2182
+ }), "remoteChanged");
2183
+ var guardedFileWrite = /* @__PURE__ */ __name(async (write) => {
2184
+ const { target, versions, path, from, expected, reread, direction = "local-to-remote", signal } = write;
2185
+ const there = await target.exists(path, signal);
2186
+ if (there && expected === void 0)
2187
+ throw new CliError("validation_error", `${path} exists; read it first (${reread}) and pass its sha256 as --expected-fingerprint`, { param: "--expected-fingerprint" });
2188
+ if (!there && expected !== void 0)
2189
+ throw remoteChanged(path, "is no longer there", reread);
2190
+ const kept = expected === void 0 ? void 0 : await versions.keep((temp) => target.download(path, temp, signal));
2191
+ if (kept !== expected)
2192
+ throw remoteChanged(path, "changed since it was read", reread);
2193
+ let file;
2194
+ try {
2195
+ file = await target.upload(path, from, kept === void 0 ? { absent: true } : { sha256: kept }, signal);
2196
+ } catch (error) {
2197
+ if (isCliError(error) && error.code === "conflict")
2198
+ throw remoteChanged(path, kept === void 0 ? "appeared since it was read" : "changed since it was read", reread);
2199
+ throw error;
2200
+ }
2201
+ if (kept === void 0)
2202
+ return { file };
2203
+ versions.log({
2204
+ path,
2205
+ event: "changed",
2206
+ direction,
2207
+ old: kept,
2208
+ from: "remote",
2209
+ ...file.sha256 ? { new: file.sha256 } : {},
2210
+ size: file.size
2211
+ });
2212
+ return { file, replaced: { sha256: kept } };
2213
+ }, "guardedFileWrite");
2214
+
2215
+ // node_modules/.pnpm/@wirecat+cli-core@0.724.0_@wirecat+cli-base@0.130.0_commander@15.0.0_esbuild@0.28.2_typ_7eee7c5df32146a12ad3bd2be9b828b8/node_modules/@wirecat/cli-core/dist/services/files/listing.js
2216
+ var MAX_LISTING_AGE_MS = 7 * 24 * 36e5;
2217
+ var remoteFileSchema = object({
2218
+ path: string(),
2219
+ id: string(),
2220
+ size: number(),
2221
+ sha256: optional(string()),
2222
+ md5: optional(string()),
2223
+ modifiedAt: string()
2224
+ });
2225
+ var listingSchema = object({
2226
+ rootId: string(),
2227
+ startedAt: string(),
2228
+ next: string(),
2229
+ files: array(remoteFileSchema)
2230
+ });
2231
+
2232
+ // node_modules/.pnpm/@wirecat+cli-core@0.724.0_@wirecat+cli-base@0.130.0_commander@15.0.0_esbuild@0.28.2_typ_7eee7c5df32146a12ad3bd2be9b828b8/node_modules/@wirecat/cli-core/dist/services/files/mirror-state.js
2233
+ var entrySchema = object({
2234
+ id: string(),
2235
+ size: number(),
2236
+ sha256: string(),
2237
+ md5: optional(string()),
2238
+ remoteModified: string(),
2239
+ localMtimeMs: number(),
2240
+ localSize: number(),
2241
+ syncedAt: string()
2242
+ });
2243
+ var stateSchema2 = object({
2244
+ version: literal(1),
2245
+ principal: string(),
2246
+ root: string(),
2247
+ target: string(),
2248
+ rootId: optional(string()),
2249
+ localRoot: optional(object({ dev: number(), ino: number() })),
2250
+ entries: record(string(), entrySchema),
2251
+ pending: record(string(), object({ op: string(), operationId: string(), created: optional(boolean()) })),
2252
+ listing: optional(listingSchema),
2253
+ conflicts: optional(record(string(), object({
2254
+ reason: string(),
2255
+ at: string(),
2256
+ base: optional(string()),
2257
+ local: optional(string()),
2258
+ remote: optional(string()),
2259
+ remoteFile: optional(remoteFileSchema),
2260
+ kept: optional(boolean())
2261
+ })))
2262
+ });
2263
+
2264
+ // node_modules/.pnpm/@wirecat+cli-core@0.724.0_@wirecat+cli-base@0.130.0_commander@15.0.0_esbuild@0.28.2_typ_7eee7c5df32146a12ad3bd2be9b828b8/node_modules/@wirecat/cli-core/dist/services/files/versions.js
2265
+ var RETAIN_MS = 30 * 24 * 60 * 60 * 1e3;
2266
+
1963
2267
  // dist/model.js
1964
2268
  var FOLDER = "application/vnd.google-apps.folder";
1965
2269
  var DOC = "application/vnd.google-apps.document";
@@ -2011,7 +2315,10 @@ export {
2011
2315
  watchMirrors,
2012
2316
  extractDocumentMemories,
2013
2317
  catalogFiles,
2318
+ KEEP_VERSIONS_FOR_DAYS,
2014
2319
  syncDocuments,
2320
+ remoteChanged,
2321
+ guardedFileWrite,
2015
2322
  FOLDER,
2016
2323
  DOC,
2017
2324
  SHEET,