@wirecat/drive-cli 0.71.0 → 0.72.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +150 -71
- package/contracts/wirecat.json +77 -8
- package/dist/bin/drive.js +2 -2
- package/dist/bundle/agent-23OB2NZP.js +46 -0
- package/dist/bundle/{all-profiles-3QJG2NAN.js → all-profiles-GXGDVNQJ.js} +67 -25
- package/dist/bundle/{anthropic-PSWTEU6G.js → anthropic-H5C4GQHC.js} +9 -9
- package/dist/bundle/{app-server-PVTA6ABR.js → app-server-EQ3UK4C7.js} +97 -79
- package/dist/bundle/{bun-LU5LP3JI.js → bun-DTJVSRY3.js} +2 -2
- package/dist/bundle/{bun-sqlite-PYMKLBRU.js → bun-sqlite-JIFY7MAE.js} +9 -9
- package/dist/bundle/chunk-2Q325BBD.js +353 -0
- package/dist/bundle/chunk-35FIJGTT.js +52 -0
- package/dist/bundle/{chunk-RWDKMU74.js → chunk-3FRQ6V4T.js} +3 -3
- package/dist/bundle/chunk-47L262VI.js +340 -0
- package/dist/bundle/chunk-4HP6KGBI.js +32 -0
- package/dist/bundle/{chunk-YVI5SQPY.js → chunk-4HPXWYTE.js} +1 -1
- package/dist/bundle/{chunk-QETR5HIZ.js → chunk-4IUNYYYL.js} +4385 -2684
- package/dist/bundle/{chunk-I4RWW3UD.js → chunk-4JS32SRX.js} +20 -5
- package/dist/bundle/chunk-4ZAQMDLD.js +1308 -0
- package/dist/bundle/chunk-4ZTB7LS3.js +87 -0
- package/dist/bundle/{chunk-3N2OFXB5.js → chunk-55FH6IEL.js} +5 -5
- package/dist/bundle/{chunk-6TNNT2MQ.js → chunk-5BNMWSU2.js} +483 -176
- package/dist/bundle/{chunk-6XFIITOG.js → chunk-5H747A76.js} +5532 -3265
- package/dist/bundle/{chunk-MNLL5YLM.js → chunk-5KWCO56H.js} +2 -2
- package/dist/bundle/{chunk-GZ2D4KXG.js → chunk-5U3NCE5R.js} +35 -12
- package/dist/bundle/{chunk-CJLVYIOP.js → chunk-6CCO3JCM.js} +30 -21
- package/dist/bundle/{chunk-26DHFMGZ.js → chunk-6ZW2ZJYC.js} +2 -2
- package/dist/bundle/{chunk-COJSWDNU.js → chunk-75DAHQOV.js} +3 -3
- package/dist/bundle/{chunk-Q7DOMFJ4.js → chunk-77OBW43F.js} +6 -6
- package/dist/bundle/{chunk-FCS26CYQ.js → chunk-7EFM6AW3.js} +4 -4
- package/dist/bundle/{chunk-XMMFBPGC.js → chunk-A3S7QM5L.js} +3 -3
- package/dist/bundle/{chunk-ASMMG72J.js → chunk-AA4LKC6W.js} +244 -565
- package/dist/bundle/chunk-ASTKHB6B.js +3233 -0
- package/dist/bundle/{chunk-LXKYKRHD.js → chunk-BM6V7456.js} +8 -227
- package/dist/bundle/chunk-BO6EDBYJ.js +50 -0
- package/dist/bundle/{chunk-YPFWNVHV.js → chunk-BPA3R4KN.js} +2 -100
- package/dist/bundle/chunk-CIFE4KPX.js +2159 -0
- package/dist/bundle/chunk-CKB4XZZJ.js +730 -0
- package/dist/bundle/{chunk-RJOQH5YY.js → chunk-COJTCEZP.js} +111 -859
- package/dist/bundle/{chunk-FJH7DJWK.js → chunk-CWPYDT73.js} +6 -6
- package/dist/bundle/{chunk-BKSQBBYG.js → chunk-D4JNCXS7.js} +9 -9
- package/dist/bundle/chunk-DCPWZIOV.js +696 -0
- package/dist/bundle/{chunk-PRW6SYA3.js → chunk-DHMNCOQI.js} +313 -257
- package/dist/bundle/chunk-DOQMH4DC.js +280 -0
- package/dist/bundle/chunk-DQSOYH6N.js +20 -0
- package/dist/bundle/{chunk-YJIGGUPI.js → chunk-DWRUOLBF.js} +4 -4
- package/dist/bundle/{chunk-6W763DZN.js → chunk-E3VWZC3K.js} +14 -13
- package/dist/bundle/chunk-ECYOTDJM.js +14 -0
- package/dist/bundle/{chunk-KGYVHPGE.js → chunk-EVG3AA5M.js} +2 -2
- package/dist/bundle/chunk-F4BX7TH2.js +15 -0
- package/dist/bundle/{chunk-Y2NWGNUB.js → chunk-FBEZSA76.js} +5 -5
- package/dist/bundle/{chunk-2BVVU7GG.js → chunk-FBQJN74J.js} +1 -1
- package/dist/bundle/{chunk-Z56QFOBR.js → chunk-FIZOPJYY.js} +1 -1
- package/dist/bundle/chunk-FNAYSZWK.js +783 -0
- package/dist/bundle/{chunk-GPQ44Y2R.js → chunk-FRCJHGZM.js} +2 -2
- package/dist/bundle/{chunk-35SCQ4VI.js → chunk-FTG5QBSD.js} +41 -33
- package/dist/bundle/{chunk-KYKW2W6X.js → chunk-FUDUXIVG.js} +1 -1
- package/dist/bundle/{chunk-NYECVHFH.js → chunk-G4NHRFS7.js} +755 -0
- package/dist/bundle/{chunk-FT3LN3HP.js → chunk-GIEZYBRC.js} +1 -1
- package/dist/bundle/chunk-GTPPUBYU.js +1876 -0
- package/dist/bundle/chunk-GU6ICH53.js +108 -0
- package/dist/bundle/{chunk-ACUAV6VX.js → chunk-GUMKKRE6.js} +107 -71
- package/dist/bundle/{chunk-KGERXYTV.js → chunk-GWCDOYSC.js} +1 -1
- package/dist/bundle/{chunk-OJSBWP3F.js → chunk-GXGSC622.js} +69 -7
- package/dist/bundle/chunk-HAGXTGJC.js +188 -0
- package/dist/bundle/{chunk-XF4EXO2C.js → chunk-IMAWQC5K.js} +6 -6
- package/dist/bundle/{chunk-HKY7X6NY.js → chunk-IVGVVSPW.js} +4 -4
- package/dist/bundle/{chunk-P7CUM5IB.js → chunk-J4NUHSM7.js} +1 -1
- package/dist/bundle/{chunk-MIA7P6FZ.js → chunk-K652FYCO.js} +6 -6
- package/dist/bundle/chunk-K6ZWNTXY.js +561 -0
- package/dist/bundle/{chunk-COOOO5B3.js → chunk-KF3ZBQJV.js} +4 -4
- package/dist/bundle/chunk-KFZCHJRT.js +80 -0
- package/dist/bundle/chunk-KLPFDFLI.js +221 -0
- package/dist/bundle/{chunk-EOEU3AZN.js → chunk-KP2XMCNT.js} +13 -13
- package/dist/bundle/{chunk-FP54WSIR.js → chunk-KWDZ3KVH.js} +4 -4
- package/dist/bundle/{chunk-QNRRK3CN.js → chunk-KX4C32WD.js} +2 -2
- package/dist/bundle/chunk-L7P3LUDQ.js +286 -0
- package/dist/bundle/{chunk-2LHAVY4U.js → chunk-M2ZWYVWO.js} +1 -1
- package/dist/bundle/chunk-MEYYH47C.js +25 -0
- package/dist/bundle/{chunk-3EBBLKIT.js → chunk-ML2QIWX2.js} +4 -4
- package/dist/bundle/{chunk-ZM63SUHG.js → chunk-MUFF2YTH.js} +2 -2
- package/dist/bundle/{chunk-2PUNKUYJ.js → chunk-N24YSLED.js} +9150 -9869
- package/dist/bundle/chunk-N4GTCPML.js +7 -0
- package/dist/bundle/{chunk-B5KSXHJ7.js → chunk-NBMGDRP4.js} +1 -1
- package/dist/bundle/chunk-NMQRSEZM.js +37 -0
- package/dist/bundle/{chunk-JDV7HNNQ.js → chunk-NNGA4QDR.js} +13 -26
- package/dist/bundle/{chunk-5DPV7X27.js → chunk-NTZWY5R3.js} +321 -0
- package/dist/bundle/chunk-O7CZZ36M.js +80 -0
- package/dist/bundle/{chunk-ICDCAQ6K.js → chunk-OAONP6KI.js} +13 -9
- package/dist/bundle/{chunk-WVDCCYS3.js → chunk-OESP4PHB.js} +17 -17
- package/dist/bundle/chunk-OHR6IZNH.js +116 -0
- package/dist/bundle/{chunk-4QNW4NK6.js → chunk-OLCU7Q2B.js} +1 -1
- package/dist/bundle/{chunk-SDKQNOL5.js → chunk-OLDQLEPA.js} +6 -6
- package/dist/bundle/{chunk-ZCR3IRZ2.js → chunk-OPIPG6AP.js} +16 -9
- package/dist/bundle/{chunk-5D4AEUVA.js → chunk-PL5P7UKW.js} +434 -1
- package/dist/bundle/chunk-PRYMT3OG.js +30 -0
- package/dist/bundle/chunk-QDUIVMEW.js +36 -0
- package/dist/bundle/{chunk-ZZ32DXTH.js → chunk-QKBPCX7Y.js} +1 -1
- package/dist/bundle/{chunk-QXC6IEH6.js → chunk-QSLOACDT.js} +201 -423
- package/dist/bundle/{chunk-7PDHGZN4.js → chunk-QUZFDU4K.js} +4 -4
- package/dist/bundle/{chunk-3UGYFXH6.js → chunk-R32DHS6J.js} +187 -379
- package/dist/bundle/{chunk-6SJOTNHF.js → chunk-R57QUYBG.js} +6 -28
- package/dist/bundle/{chunk-UTO2GO4P.js → chunk-R64OSDOD.js} +45 -66
- package/dist/bundle/{chunk-GBKNJWOZ.js → chunk-RSPBVKOC.js} +8 -8
- package/dist/bundle/{chunk-HL52XXZX.js → chunk-SPNPJ3FZ.js} +3 -4
- package/dist/bundle/chunk-SQHDSIFL.js +388 -0
- package/dist/bundle/{chunk-YPNWIB6H.js → chunk-ST35FIUG.js} +3 -3
- package/dist/bundle/{chunk-37MAA6F2.js → chunk-STUPCKAA.js} +11 -2221
- package/dist/bundle/chunk-SZ7XJZGH.js +2231 -0
- package/dist/bundle/chunk-TRYYWV7J.js +291 -0
- package/dist/bundle/{chunk-X4TIMMKJ.js → chunk-TTPWKTVR.js} +1 -1
- package/dist/bundle/{chunk-TAFHYHKA.js → chunk-U7VEJ3CW.js} +45 -27
- package/dist/bundle/{chunk-6Y2BYFXQ.js → chunk-UC7JLE6J.js} +0 -7
- package/dist/bundle/{chunk-4HWJOU7N.js → chunk-UIQ35CA5.js} +1 -1
- package/dist/bundle/{chunk-SAKO3P4H.js → chunk-UJY26HW4.js} +1 -1
- package/dist/bundle/{chunk-D5TGYUVU.js → chunk-UWG3PRY7.js} +9 -60
- package/dist/bundle/{chunk-JZHBZOJR.js → chunk-VAR3MJU6.js} +3 -3
- package/dist/bundle/{chunk-GOWXXYEF.js → chunk-VPQSI5IU.js} +4 -4
- package/dist/bundle/{chunk-QFR2PNJN.js → chunk-VQPT3Y7W.js} +12 -12
- package/dist/bundle/{chunk-Z3KUSRCF.js → chunk-WMG3H2VK.js} +2 -2
- package/dist/bundle/{chunk-4PA4DHYV.js → chunk-X5BGAZC5.js} +6 -6
- package/dist/bundle/{chunk-2UUWXPOB.js → chunk-XC6TRWLZ.js} +3 -3
- package/dist/bundle/{chunk-OF422U5D.js → chunk-XQZEMRCU.js} +402 -402
- package/dist/bundle/{chunk-72C4YOCH.js → chunk-XZ7MO6EU.js} +7 -7
- package/dist/bundle/{chunk-SERXSCN3.js → chunk-YAIOEPKU.js} +337 -390
- package/dist/bundle/chunk-YHWFF6DN.js +39 -0
- package/dist/bundle/{chunk-RESDD3Q4.js → chunk-YWOLQEDV.js} +16 -3
- package/dist/bundle/{chunk-YMJ6IDGT.js → chunk-ZFDSJ5YJ.js} +38 -8
- package/dist/bundle/{chunk-HMS6EEQL.js → chunk-ZFUZEFU6.js} +3 -3
- package/dist/bundle/{chunk-TAUBRNC5.js → chunk-ZJKXSMXK.js} +72 -59
- package/dist/bundle/{chunk-22QQUKWA.js → chunk-ZKWT6HXT.js} +1 -1
- package/dist/bundle/chunk-ZPUY3COZ.js +250 -0
- package/dist/bundle/{cli-556DERZL.js → cli-2P5FW2RL.js} +201 -98
- package/dist/bundle/command-contract-BMQT2G5X.js +45 -0
- package/dist/bundle/{command-server-entry-AYLGNZWD.js → command-server-entry-KP2UDGLA.js} +36 -34
- package/dist/bundle/{decode-QU24MWMN.js → decode-K2JZ5D6V.js} +10 -10
- package/dist/bundle/{dispatch-4KODNOXV.js → dispatch-KOQZA74A.js} +10 -10
- package/dist/bundle/dist-PAKDDIBT.js +191 -0
- package/dist/bundle/drive.js +11 -11
- package/dist/bundle/{echarts-BXX4OQWC.js → echarts-URO3QGCG.js} +2 -2
- package/dist/bundle/{embed-KG27KG3D.js → embed-JLIPWTNN.js} +10 -10
- package/dist/bundle/{embedder-IPAVUQUV.js → embedder-LUTDO3HS.js} +15 -15
- package/dist/bundle/entry-AVF6LMG7.js +25 -0
- package/dist/bundle/{failure-ESL7ETL4.js → failure-GJMQLM7O.js} +4 -4
- package/dist/bundle/first-run-VYTIEUDA.js +31 -0
- package/dist/bundle/first-screen-QVZPF7KL.js +45 -0
- package/dist/bundle/google-VX7IPACN.js +46 -0
- package/dist/bundle/{google-api-VCDBSNOW.js → google-api-RFXKRLL4.js} +88 -73
- package/dist/bundle/grants-4XWJFVD6.js +133 -0
- package/dist/bundle/hast-util-from-html-X2DCPS3T.js +10531 -0
- package/dist/bundle/hast-util-to-html-VP6XLPKJ.js +998 -0
- package/dist/bundle/hast-util-to-mdast-IZ5PRX72.js +2272 -0
- package/dist/bundle/{identity-LOWMVGZY.js → identity-FXPB5EMT.js} +7 -6
- package/dist/bundle/{instructions-2VECIDXF.js → instructions-IROIUVZI.js} +1 -1
- package/dist/bundle/{login-7GBONT7V.js → login-WIY5VQU7.js} +96 -81
- package/dist/bundle/{mcp-O6ACR2DX.js → mcp-NJIOKW3E.js} +2 -2
- package/dist/bundle/{mdast-util-from-markdown-FXEPSNER.js → mdast-util-from-markdown-HEZF7KJ4.js} +137 -195
- package/dist/bundle/mdast-util-gfm-AQW6R6MG.js +925 -0
- package/dist/bundle/mdast-util-to-hast-DF2QVIRV.js +879 -0
- package/dist/bundle/mdast-util-to-markdown-XYLXB3Z3.js +18 -0
- package/dist/bundle/meeting-combined-JUNV35GM.js +28 -0
- package/dist/bundle/meeting-model-XY4UNWWK.js +29 -0
- package/dist/bundle/{meeting-semantic-G7PFOKU7.js → meeting-semantic-62QNQMOM.js} +10 -10
- package/dist/bundle/{micromark-extension-gfm-GRL24TU6.js → micromark-extension-gfm-OE2GBORZ.js} +11 -78
- package/dist/bundle/{node-MPEQSFI3.js → node-IACCI2CW.js} +2 -2
- package/dist/bundle/{node-sqlite-OLQMAYB4.js → node-sqlite-WYIRC7C7.js} +10 -10
- package/dist/bundle/notes-search-DEDUJKSN.js +70 -0
- package/dist/bundle/oauth-HXBXF4VI.js +22 -0
- package/dist/bundle/{open-OXTE672W.js → open-H32B6BCT.js} +8 -8
- package/dist/bundle/{openai-EB3TPIZY.js → openai-VHMPJJUG.js} +22 -21
- package/dist/bundle/{process-F6TKXWWA.js → process-RNHPF5OK.js} +1 -1
- package/dist/bundle/{program-4IFDZ7FM.js → program-GYMJ3DDH.js} +275 -1148
- package/dist/bundle/{prompt-F5RRHPN2.js → prompt-TOG2CRCE.js} +8 -8
- package/dist/bundle/{reasons-UORHJDHK.js → reasons-TLFQ45YX.js} +6 -5
- package/dist/bundle/{recognize-DAVNZND3.js → recognize-GYGY45EY.js} +7 -7
- package/dist/bundle/remote-6XN2QLI5.js +35 -0
- package/dist/bundle/{rerank-CND2GVLZ.js → rerank-HJO3O4TW.js} +11 -11
- package/dist/bundle/{serve-ZHSPUIGX.js → serve-XPCNLHCR.js} +19 -19
- package/dist/bundle/server-UBJZ66XE.js +97 -0
- package/dist/bundle/{server-YMAK4LHC.js → server-WPT3NC5B.js} +89 -70
- package/dist/bundle/{services-ZILSFJ6E.js → services-253KKKVU.js} +109 -89
- package/dist/bundle/{sqlite-runtime-S5VPMZQH.js → sqlite-runtime-EZASGJXW.js} +9 -9
- package/dist/bundle/{start-CR6X25RT.js → start-UHI35JFL.js} +7 -7
- package/dist/bundle/{state-YFPHVIIJ.js → state-KJTSPFGK.js} +9 -9
- package/dist/bundle/{store-UODRT6X4.js → store-62J2H2A3.js} +36 -25
- package/dist/bundle/{store-CL4ZJZRI.js → store-G5B7T7M7.js} +38 -23
- package/dist/bundle/store-maintenance-command-C6T4YLVF.js +85 -0
- package/dist/bundle/surface-3OT64BHS.js +83 -0
- package/dist/bundle/tokens-EHYO6D2X.js +133 -0
- package/dist/commands/documents.d.ts.map +1 -1
- package/dist/commands/documents.js +11 -1
- package/dist/commands/documents.js.map +1 -1
- package/dist/commands/remote.d.ts.map +1 -1
- package/dist/commands/remote.js +8 -22
- package/dist/commands/remote.js.map +1 -1
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +14 -4
- package/dist/commands/sync.js.map +1 -1
- package/dist/config.d.ts +5 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +5 -0
- package/dist/config.js.map +1 -1
- package/dist/first-screen.d.ts.map +1 -1
- package/dist/first-screen.js +2 -1
- package/dist/first-screen.js.map +1 -1
- package/dist/generated/manifest.d.ts +2 -1
- package/dist/generated/manifest.d.ts.map +1 -1
- package/dist/generated/manifest.js +782 -0
- package/dist/generated/manifest.js.map +1 -1
- package/dist/generated/types.d.ts +262 -58
- package/dist/generated/types.d.ts.map +1 -1
- package/dist/google.d.ts.map +1 -1
- package/dist/google.js +5 -5
- package/dist/google.js.map +1 -1
- package/dist/model.d.ts +5 -2
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js.map +1 -1
- package/dist/policy-keys.js +1 -1
- package/dist/policy-keys.js.map +1 -1
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +9 -4
- package/dist/program.js.map +1 -1
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +6 -1
- package/dist/state.js.map +1 -1
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +2 -7
- package/dist/store.js.map +1 -1
- package/dist/supported.d.ts +2 -2
- package/dist/supported.d.ts.map +1 -1
- package/dist/supported.js +2 -3
- package/dist/supported.js.map +1 -1
- package/dist/sync.d.ts +2 -1
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +5 -2
- package/dist/sync.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
- package/scenarios/find-decision.md +1 -1
- package/skills/drive-cli/SKILL.md +4 -2
- package/dist/bundle/chunk-J5Q5FS2N.js +0 -593
- package/dist/bundle/chunk-L46C6HQ7.js +0 -729
- package/dist/bundle/chunk-UDMNY63V.js +0 -899
- package/dist/bundle/chunk-VKE77B3F.js +0 -2
- package/dist/bundle/command-contract-VRTOAV6W.js +0 -43
- package/dist/bundle/entry-MVXQETWS.js +0 -25
- package/dist/bundle/first-run-4UVLW2WR.js +0 -31
- package/dist/bundle/first-screen-JAKAIINI.js +0 -41
- package/dist/bundle/google-22NXXJX5.js +0 -45
- package/dist/bundle/grants-MQMTVCRQ.js +0 -118
- package/dist/bundle/mdast-util-gfm-SZM5GBDF.js +0 -2103
- package/dist/bundle/meeting-combined-LVP4AZKA.js +0 -27
- package/dist/bundle/meeting-model-RAY5XDXZ.js +0 -29
- package/dist/bundle/oauth-SGH2I2BY.js +0 -22
- package/dist/bundle/remote-D5EYYIAU.js +0 -35
- package/dist/bundle/server-DUVJWP3Q.js +0 -80
- package/dist/bundle/store-maintenance-command-DY5XIBWR.js +0 -72
- 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-
|
|
5
|
+
} from "./chunk-4JS32SRX.js";
|
|
6
6
|
import {
|
|
7
7
|
walkQuery
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-XQZEMRCU.js";
|
|
9
9
|
import {
|
|
10
10
|
writeSecurely
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-6CCO3JCM.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-
|
|
30
|
+
} from "./chunk-GXGSC622.js";
|
|
28
31
|
import {
|
|
29
32
|
CliError,
|
|
30
33
|
isCliError
|
|
31
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-OLCU7Q2B.js";
|
|
32
35
|
import {
|
|
33
36
|
__name
|
|
34
37
|
} from "./chunk-ZVVMGPBJ.js";
|
|
35
38
|
|
|
36
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
39
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.722.0_@wirecat+cli-base@0.128.0_commander@15.0.0_esbuild@0.28.2_typ_a55806ccf2eb39d6be3eaf4c54d1a60a/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.
|
|
87
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.722.0_@wirecat+cli-base@0.128.0_commander@15.0.0_esbuild@0.28.2_typ_a55806ccf2eb39d6be3eaf4c54d1a60a/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
|
|
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
|
-
}, "
|
|
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) =>
|
|
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.
|
|
234
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.722.0_@wirecat+cli-base@0.128.0_commander@15.0.0_esbuild@0.28.2_typ_a55806ccf2eb39d6be3eaf4c54d1a60a/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.
|
|
269
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.722.0_@wirecat+cli-base@0.128.0_commander@15.0.0_esbuild@0.28.2_typ_a55806ccf2eb39d6be3eaf4c54d1a60a/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.
|
|
409
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.722.0_@wirecat+cli-base@0.128.0_commander@15.0.0_esbuild@0.28.2_typ_a55806ccf2eb39d6be3eaf4c54d1a60a/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((
|
|
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
|
-
|
|
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
|
|
450
|
-
if (
|
|
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.
|
|
576
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.722.0_@wirecat+cli-base@0.128.0_commander@15.0.0_esbuild@0.28.2_typ_a55806ccf2eb39d6be3eaf4c54d1a60a/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-
|
|
528
|
-
import("./mdast-util-gfm-
|
|
529
|
-
import("./micromark-extension-gfm-
|
|
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.
|
|
701
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.722.0_@wirecat+cli-base@0.128.0_commander@15.0.0_esbuild@0.28.2_typ_a55806ccf2eb39d6be3eaf4c54d1a60a/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
|
|
728
|
+
const link2 = runs[at]?.link;
|
|
677
729
|
let body = "";
|
|
678
|
-
for (; at < runs.length && runs[at]?.link ===
|
|
730
|
+
for (; at < runs.length && runs[at]?.link === link2; at++)
|
|
679
731
|
body += styled({ ...runs[at], link: void 0 });
|
|
680
|
-
out +=
|
|
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.
|
|
887
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.722.0_@wirecat+cli-base@0.128.0_commander@15.0.0_esbuild@0.28.2_typ_a55806ccf2eb39d6be3eaf4c54d1a60a/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.
|
|
890
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.722.0_@wirecat+cli-base@0.128.0_commander@15.0.0_esbuild@0.28.2_typ_a55806ccf2eb39d6be3eaf4c54d1a60a/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.
|
|
895
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.722.0_@wirecat+cli-base@0.128.0_commander@15.0.0_esbuild@0.28.2_typ_a55806ccf2eb39d6be3eaf4c54d1a60a/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
|
|
852
|
-
|
|
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
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
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
|
-
|
|
861
|
-
|
|
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,
|
|
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)
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
1220
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.722.0_@wirecat+cli-base@0.128.0_commander@15.0.0_esbuild@0.28.2_typ_a55806ccf2eb39d6be3eaf4c54d1a60a/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
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
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
|
-
|
|
1150
|
-
|
|
1151
|
-
},
|
|
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
|
|
1181
|
-
const
|
|
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
|
|
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
|
-
}, "
|
|
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.
|
|
1337
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.722.0_@wirecat+cli-base@0.128.0_commander@15.0.0_esbuild@0.28.2_typ_a55806ccf2eb39d6be3eaf4c54d1a60a/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.
|
|
1478
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.722.0_@wirecat+cli-base@0.128.0_commander@15.0.0_esbuild@0.28.2_typ_a55806ccf2eb39d6be3eaf4c54d1a60a/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.
|
|
1528
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.722.0_@wirecat+cli-base@0.128.0_commander@15.0.0_esbuild@0.28.2_typ_a55806ccf2eb39d6be3eaf4c54d1a60a/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.
|
|
1410
|
-
var within = /* @__PURE__ */ __name((file, roots, folders, seen = /* @__PURE__ */ new Set()) => {
|
|
1531
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.722.0_@wirecat+cli-base@0.128.0_commander@15.0.0_esbuild@0.28.2_typ_a55806ccf2eb39d6be3eaf4c54d1a60a/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
|
-
|
|
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
|
-
|
|
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.
|
|
1556
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.722.0_@wirecat+cli-base@0.128.0_commander@15.0.0_esbuild@0.28.2_typ_a55806ccf2eb39d6be3eaf4c54d1a60a/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.
|
|
1575
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.722.0_@wirecat+cli-base@0.128.0_commander@15.0.0_esbuild@0.28.2_typ_a55806ccf2eb39d6be3eaf4c54d1a60a/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.722.0_@wirecat+cli-base@0.128.0_commander@15.0.0_esbuild@0.28.2_typ_a55806ccf2eb39d6be3eaf4c54d1a60a/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.722.0_@wirecat+cli-base@0.128.0_commander@15.0.0_esbuild@0.28.2_typ_a55806ccf2eb39d6be3eaf4c54d1a60a/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
|
|
1475
|
-
const
|
|
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 (
|
|
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
|
-
|
|
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
|
|
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) => !
|
|
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
|
-
|
|
1503
|
-
const
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
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
|
|
1674
|
-
if (initial || !
|
|
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,
|
|
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
|
-
|
|
1710
|
-
|
|
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
|
|
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.
|
|
1920
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.722.0_@wirecat+cli-base@0.128.0_commander@15.0.0_esbuild@0.28.2_typ_a55806ccf2eb39d6be3eaf4c54d1a60a/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
|
|
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 =
|
|
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
|
|
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 =
|
|
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 =
|
|
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.722.0_@wirecat+cli-base@0.128.0_commander@15.0.0_esbuild@0.28.2_typ_a55806ccf2eb39d6be3eaf4c54d1a60a/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.722.0_@wirecat+cli-base@0.128.0_commander@15.0.0_esbuild@0.28.2_typ_a55806ccf2eb39d6be3eaf4c54d1a60a/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.722.0_@wirecat+cli-base@0.128.0_commander@15.0.0_esbuild@0.28.2_typ_a55806ccf2eb39d6be3eaf4c54d1a60a/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.722.0_@wirecat+cli-base@0.128.0_commander@15.0.0_esbuild@0.28.2_typ_a55806ccf2eb39d6be3eaf4c54d1a60a/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.722.0_@wirecat+cli-base@0.128.0_commander@15.0.0_esbuild@0.28.2_typ_a55806ccf2eb39d6be3eaf4c54d1a60a/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,
|