@wirecat/drive-cli 0.63.0 → 0.65.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 +2 -1
- package/dist/bin/drive.js +2 -2
- package/dist/bundle/{all-profiles-GZJS3UKC.js → all-profiles-PD7GJHFA.js} +14 -13
- package/dist/bundle/{anthropic-RGV3WXX5.js → anthropic-PJKFON5H.js} +25 -14
- package/dist/bundle/{app-server-AA2PJ7PV.js → app-server-6ELQA6FJ.js} +59 -56
- package/dist/bundle/{bun-OXZYIA3R.js → bun-P54TGES2.js} +2 -2
- package/dist/bundle/{bun-sqlite-D45NSDM3.js → bun-sqlite-TND5ZRJH.js} +12 -8
- package/dist/bundle/chunk-2AFI4KGI.js +185 -0
- package/dist/bundle/{chunk-Q5DJTRKV.js → chunk-3HXNDF6Q.js} +2 -2
- package/dist/bundle/{chunk-DJHLVUL6.js → chunk-3ONWN3IA.js} +278 -49
- package/dist/bundle/{chunk-WYGWWHZP.js → chunk-42G2XNPN.js} +2 -2
- package/dist/bundle/chunk-4AOINPN2.js +66 -0
- package/dist/bundle/{chunk-J4DIHPZ6.js → chunk-4EDWLR22.js} +1 -1
- package/dist/bundle/{chunk-ABYGSJZ4.js → chunk-4Y5YBFMS.js} +7 -7
- package/dist/bundle/{chunk-YGU6ULU5.js → chunk-54V4H6PM.js} +16 -16
- package/dist/bundle/{chunk-2TFXK3R4.js → chunk-5XSBCMAF.js} +4 -4
- package/dist/bundle/{chunk-2HF2MRXI.js → chunk-6DCLZLGX.js} +1 -1
- package/dist/bundle/{chunk-OD4U7GUY.js → chunk-7AQGVX5O.js} +20 -20
- package/dist/bundle/{chunk-YIP7ELON.js → chunk-7TAP7Y2E.js} +727 -518
- package/dist/bundle/{chunk-TF23BZW5.js → chunk-A27UVLPK.js} +3 -3
- package/dist/bundle/{chunk-LZEOQW7S.js → chunk-A4QNADEX.js} +58 -52
- package/dist/bundle/{chunk-FXBHOCJK.js → chunk-ADLS6FVG.js} +1 -1
- package/dist/bundle/{chunk-LMAVCYLQ.js → chunk-B2LPCHQN.js} +4 -4
- package/dist/bundle/{chunk-5PPL7JDM.js → chunk-CGQRZRTH.js} +2 -2
- package/dist/bundle/{chunk-VAUMOZU5.js → chunk-CWLL63JD.js} +107 -48
- package/dist/bundle/{chunk-V3NVXIQR.js → chunk-D6Z43SOG.js} +1563 -266
- package/dist/bundle/{chunk-OXY6SSZG.js → chunk-D7WB54P7.js} +127 -28
- package/dist/bundle/{chunk-VJEOGKAN.js → chunk-DA63E2UM.js} +13 -9
- package/dist/bundle/{chunk-EOOGWUTP.js → chunk-ECEP4SO3.js} +20 -20
- package/dist/bundle/{chunk-NEFSGCVA.js → chunk-EHU6EYGO.js} +38 -28
- package/dist/bundle/{chunk-4OSSOWDM.js → chunk-ELJUBPY4.js} +1 -1
- package/dist/bundle/{chunk-FRIJUILO.js → chunk-EM7NL5ES.js} +3 -3
- package/dist/bundle/{chunk-3BZRKLJ6.js → chunk-EU5MD24W.js} +13 -13
- package/dist/bundle/{chunk-MOTRI3SY.js → chunk-EZ2OLYEK.js} +24 -2
- package/dist/bundle/{chunk-6MQSQ4LX.js → chunk-F56DRBGY.js} +370 -717
- package/dist/bundle/{chunk-ZOJU7ZFI.js → chunk-FA6JNXCC.js} +8 -8
- package/dist/bundle/{chunk-ND6LLYGF.js → chunk-FBHSWQU7.js} +1531 -136
- package/dist/bundle/{chunk-Z42YYLTS.js → chunk-GW3LBY3T.js} +74 -72
- package/dist/bundle/{chunk-Y6GNA7HE.js → chunk-HP3NT6JJ.js} +23 -5
- package/dist/bundle/{chunk-DJ3SDJZY.js → chunk-I272E6UR.js} +9 -8
- package/dist/bundle/{chunk-L37LMMRJ.js → chunk-IBO23OID.js} +2 -2
- package/dist/bundle/{chunk-CE2TJBLP.js → chunk-II4S2DBJ.js} +3 -3
- package/dist/bundle/{chunk-ZM5J6ZMB.js → chunk-IKHOIXJR.js} +2 -2
- package/dist/bundle/{chunk-PO5RQQIG.js → chunk-IMHW7VIV.js} +5 -5
- package/dist/bundle/{chunk-3HK5WMI5.js → chunk-JMJIH6JH.js} +6 -6
- package/dist/bundle/{chunk-FUITWY7O.js → chunk-JPPPLKAO.js} +26 -1
- package/dist/bundle/{chunk-4S4JMW6I.js → chunk-LMKPP2JP.js} +1 -1
- package/dist/bundle/{chunk-HZZCEQTH.js → chunk-M7ELUGU6.js} +4 -4
- package/dist/bundle/{chunk-ZMOUUOT2.js → chunk-MCPOZNWG.js} +1 -1
- package/dist/bundle/{chunk-XNVFKMVR.js → chunk-NI5PD5KM.js} +39485 -35729
- package/dist/bundle/{chunk-2TDUGC5D.js → chunk-NQ5XMSLA.js} +4927 -1978
- package/dist/bundle/chunk-NQRTKYJB.js +257 -0
- package/dist/bundle/{chunk-44SBK6KB.js → chunk-O6K2E7OA.js} +4201 -2565
- package/dist/bundle/{chunk-534OBX5Y.js → chunk-O7ZDCOZE.js} +1 -1
- package/dist/bundle/{chunk-7EMQ26BA.js → chunk-OFJXHEFT.js} +13 -13
- package/dist/bundle/chunk-OWMZUWCM.js +109 -0
- package/dist/bundle/chunk-PHOL2DZM.js +138 -0
- package/dist/bundle/{chunk-UQLWMGSD.js → chunk-PLP5527C.js} +5 -5
- package/dist/bundle/{chunk-3QINVLZI.js → chunk-RNHGQ35R.js} +1 -1
- package/dist/bundle/{chunk-27YUUGXQ.js → chunk-RX5CJ55S.js} +1 -1
- package/dist/bundle/{chunk-XIUDS3OK.js → chunk-SE352DBY.js} +1 -1
- package/dist/bundle/chunk-SEQWBZYH.js +18 -0
- package/dist/bundle/{chunk-33MGFUED.js → chunk-SIWXYB4E.js} +3789 -3538
- package/dist/bundle/{chunk-4CIZWCXV.js → chunk-SNLSEYJO.js} +1 -1
- package/dist/bundle/{chunk-XDC3TWTL.js → chunk-SS4LKLD7.js} +52 -605
- package/dist/bundle/{chunk-BKYMKVHT.js → chunk-TMHF4BCL.js} +2 -2
- package/dist/bundle/{chunk-FEZF3TII.js → chunk-TOVWMURV.js} +74 -6
- package/dist/bundle/{chunk-QCKZ3GAA.js → chunk-TTP4NOP3.js} +4 -4
- package/dist/bundle/chunk-UTNRBOEN.js +53 -0
- package/dist/bundle/{chunk-2NIC72HH.js → chunk-VDZY3L7U.js} +3 -1
- package/dist/bundle/chunk-VHQYWFWV.js +13 -0
- package/dist/bundle/{chunk-VKPCONDQ.js → chunk-VLXWAH5E.js} +4 -4
- package/dist/bundle/{chunk-6KQJSFYF.js → chunk-VMAMRFFC.js} +23 -23
- package/dist/bundle/{chunk-6EY46GAN.js → chunk-W2XY6C5S.js} +2 -2
- package/dist/bundle/{chunk-J24ZFCWM.js → chunk-WRAUO5EJ.js} +22 -24
- package/dist/bundle/{chunk-S4RXABDR.js → chunk-WRMJN6UQ.js} +3 -3
- package/dist/bundle/{chunk-UPOSDTPT.js → chunk-WVJHZIDH.js} +3 -3
- package/dist/bundle/{chunk-E4SDKMBJ.js → chunk-X7YGGWXI.js} +1 -59
- package/dist/bundle/{chunk-O2XOX4HB.js → chunk-XPWZSW6Y.js} +50 -34
- package/dist/bundle/{chunk-PDCCYHCH.js → chunk-XYE7XZPB.js} +5 -5
- package/dist/bundle/{chunk-RKELRWH7.js → chunk-Y5PKRITX.js} +5 -5
- package/dist/bundle/{chunk-XR6ESRU6.js → chunk-Z2ADO6UA.js} +2 -2
- package/dist/bundle/{chunk-YUWPNG7B.js → chunk-ZD4MB7NH.js} +1 -1
- package/dist/bundle/{chunk-TWUH22Z5.js → chunk-ZILALBYQ.js} +4 -4
- package/dist/bundle/{chunk-SXM6MHRR.js → chunk-ZR2EJPMQ.js} +44 -15
- package/dist/bundle/command-contract-25E4PYMD.js +40 -0
- package/dist/bundle/command-server-entry-36JXYIJB.js +170 -0
- package/dist/bundle/{decode-G5YEIPNC.js → decode-T5ZW57WZ.js} +8 -8
- package/dist/bundle/{dispatch-GEFIXA6X.js → dispatch-RMA2XFYA.js} +11 -11
- package/dist/bundle/drive.js +11 -11
- package/dist/bundle/{echarts-W2CWHNXR.js → echarts-KQ44LPSF.js} +2 -2
- package/dist/bundle/{embed-OBFFPVF4.js → embed-Q7XST53J.js} +9 -9
- package/dist/bundle/{embedder-NGCBQHIG.js → embedder-RWZSBVW2.js} +12 -12
- package/dist/bundle/entry-HPLW4QL2.js +25 -0
- package/dist/bundle/{failure-GV77W3CD.js → failure-7NP4QPIN.js} +4 -4
- package/dist/bundle/first-run-RL3RKYZW.js +30 -0
- package/dist/bundle/first-screen-NX3TM2VJ.js +38 -0
- package/dist/bundle/google-DPD5N6AQ.js +42 -0
- package/dist/bundle/{google-api-Z3NSTBBR.js → google-api-P5DRHD7L.js} +61 -56
- package/dist/bundle/grants-TX4MHLI4.js +109 -0
- package/dist/bundle/{identity-OM6GFZ7T.js → identity-VDV6CHRW.js} +6 -6
- package/dist/bundle/{instructions-YQBQSYSS.js → instructions-Q45FVY6H.js} +1 -1
- package/dist/bundle/{login-7RYSDVN3.js → login-XKN3NI6X.js} +67 -62
- package/dist/bundle/{mcp-GWDA3HOA.js → mcp-7KQUJNFN.js} +2 -2
- package/dist/bundle/{node-IVU33RL7.js → node-MSW565D3.js} +2 -2
- package/dist/bundle/{node-KM3CUABH.js → node-P4E63KXA.js} +9 -9
- package/dist/bundle/{node-sqlite-SIH5BEW2.js → node-sqlite-S74XVVHL.js} +13 -9
- package/dist/bundle/oauth-6R7AWAES.js +22 -0
- package/dist/bundle/{open-IAO2SNII.js → open-P7UQG7XJ.js} +8 -8
- package/dist/bundle/{openai-SGOUBHXP.js → openai-DDHJ57KZ.js} +19 -40
- package/dist/bundle/{process-BPBMV3AT.js → process-NMUB5SHK.js} +1 -1
- package/dist/bundle/{program-MYKKJ4F6.js → program-PJNWP6JW.js} +517 -330
- package/dist/bundle/prompt-VOSMK4C2.js +19 -0
- package/dist/bundle/{reasons-57J2D77K.js → reasons-KDAXOC5S.js} +5 -5
- package/dist/bundle/{recognize-A5C5RPB3.js → recognize-GZIY63HS.js} +7 -7
- package/dist/bundle/{remote-VWYFLRGO.js → remote-V3YGN7LN.js} +10 -10
- package/dist/bundle/{rerank-4NGQWREA.js → rerank-XRU6AVN7.js} +10 -10
- package/dist/bundle/{serve-Y6LQTFH5.js → serve-NDOAFA57.js} +12 -12
- package/dist/bundle/{server-6AUHIIUA.js → server-BKGWJYMC.js} +46 -44
- package/dist/bundle/server-QD2MUJJZ.js +72 -0
- package/dist/bundle/{services-2W4J7EMW.js → services-TYDMFQCA.js} +129 -39
- package/dist/bundle/{sqlite-runtime-P6BBDX2H.js → sqlite-runtime-UAFJKSJR.js} +9 -9
- package/dist/bundle/{start-AFFA3LKM.js → start-2ZLDP2OE.js} +30 -8
- package/dist/bundle/{state-PXKKXR3R.js → state-6SP27J2K.js} +9 -9
- package/dist/bundle/{store-CN6JEUC4.js → store-4UUY545Q.js} +42 -18
- package/dist/bundle/{store-IVV2BAGZ.js → store-EJN27MXI.js} +69 -28
- package/dist/bundle/store-maintenance-command-LETURZDC.js +60 -0
- package/dist/bundle/tokens-MTFJPTYT.js +107 -0
- package/dist/commands/account.d.ts +4 -0
- package/dist/commands/account.d.ts.map +1 -0
- package/dist/commands/account.js +33 -0
- package/dist/commands/account.js.map +1 -0
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +6 -5
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/context.d.ts +4 -2
- package/dist/commands/context.d.ts.map +1 -1
- package/dist/commands/context.js.map +1 -1
- package/dist/commands/documents.d.ts +2 -0
- package/dist/commands/documents.d.ts.map +1 -1
- package/dist/commands/documents.js +39 -3
- package/dist/commands/documents.js.map +1 -1
- package/dist/config.d.ts +13 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +32 -2
- package/dist/config.js.map +1 -1
- package/dist/documents-add.d.ts +49 -0
- package/dist/documents-add.d.ts.map +1 -0
- package/dist/documents-add.js +122 -0
- package/dist/documents-add.js.map +1 -0
- package/dist/errors.d.ts +1 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +9 -1
- package/dist/errors.js.map +1 -1
- package/dist/knowledge.d.ts +1 -1
- package/dist/knowledge.d.ts.map +1 -1
- package/dist/knowledge.js +15 -17
- package/dist/knowledge.js.map +1 -1
- package/dist/model.d.ts +3 -0
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js.map +1 -1
- package/dist/profile-lock.d.ts +1 -0
- package/dist/profile-lock.d.ts.map +1 -1
- package/dist/profile-lock.js +1 -0
- package/dist/profile-lock.js.map +1 -1
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +24 -15
- package/dist/program.js.map +1 -1
- package/dist/reasons.d.ts.map +1 -1
- package/dist/reasons.js +25 -0
- package/dist/reasons.js.map +1 -1
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +20 -0
- package/dist/store.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -4
- package/dist/bundle/chunk-AEX37ETW.js +0 -35
- package/dist/bundle/chunk-OTROVC4E.js +0 -62
- package/dist/bundle/chunk-Z5KC7XBR.js +0 -33
- package/dist/bundle/command-contract-BRW3AP44.js +0 -38
- package/dist/bundle/entry-ET6HGM7A.js +0 -22
- package/dist/bundle/first-run-JG52UZVO.js +0 -30
- package/dist/bundle/first-screen-CIL3GFAA.js +0 -36
- package/dist/bundle/google-CIWUVJ5C.js +0 -36
- package/dist/bundle/grants-3S4RL3WB.js +0 -104
- package/dist/bundle/oauth-PT4JEHLL.js +0 -22
- package/dist/bundle/prompt-3ZM64DCB.js +0 -17
- package/dist/bundle/server-PFHI35HA.js +0 -69
- package/dist/bundle/store-maintenance-command-MSY2QNEH.js +0 -59
- package/dist/bundle/tokens-P4LPNUFW.js +0 -102
- package/dist/bundle/{chunk-ZQ3GWKDQ.js → chunk-YVNHQFLC.js} +0 -0
- package/dist/bundle/{mdast-util-from-markdown-FXEPSNER.js → mdast-util-from-markdown-CE73EWJ2.js} +3 -3
|
@@ -3,7 +3,7 @@ const require = __bundleRequire(import.meta.url);
|
|
|
3
3
|
import {
|
|
4
4
|
answerOf,
|
|
5
5
|
messengerContext
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-SS4LKLD7.js";
|
|
7
7
|
import {
|
|
8
8
|
chatEventAnswer,
|
|
9
9
|
memberAnswer,
|
|
@@ -12,11 +12,45 @@ import {
|
|
|
12
12
|
serveRelay,
|
|
13
13
|
typedQuery,
|
|
14
14
|
withQuery
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-WRAUO5EJ.js";
|
|
16
|
+
import {
|
|
17
|
+
FETCHING,
|
|
18
|
+
RULES_VERSION,
|
|
19
|
+
applyTaskRulesOnArrival,
|
|
20
|
+
capability,
|
|
21
|
+
newSendId,
|
|
22
|
+
onlineDeps,
|
|
23
|
+
openRequestTask,
|
|
24
|
+
patiently,
|
|
25
|
+
senderIsMe,
|
|
26
|
+
servicesFor,
|
|
27
|
+
syncsOneChat
|
|
28
|
+
} from "./chunk-O6K2E7OA.js";
|
|
29
|
+
import {
|
|
30
|
+
embeddingKeys,
|
|
31
|
+
endpointKeyName,
|
|
32
|
+
modelGateway,
|
|
33
|
+
withTimeLimit
|
|
34
|
+
} from "./chunk-FBHSWQU7.js";
|
|
16
35
|
import {
|
|
17
36
|
stringWidth,
|
|
18
37
|
wrapAnsi
|
|
19
38
|
} from "./chunk-HTQTIKWP.js";
|
|
39
|
+
import {
|
|
40
|
+
holdLock,
|
|
41
|
+
lockPath,
|
|
42
|
+
releaseLock,
|
|
43
|
+
servingProfiles,
|
|
44
|
+
takeLock
|
|
45
|
+
} from "./chunk-EM7NL5ES.js";
|
|
46
|
+
import {
|
|
47
|
+
QUICK_HEALTH_CHECKS,
|
|
48
|
+
fts5Tables,
|
|
49
|
+
invalidJson,
|
|
50
|
+
lossUnknown,
|
|
51
|
+
storeDamageReport,
|
|
52
|
+
storeHealth
|
|
53
|
+
} from "./chunk-CWLL63JD.js";
|
|
20
54
|
import {
|
|
21
55
|
Command,
|
|
22
56
|
LOCAL_READ,
|
|
@@ -25,13 +59,11 @@ import {
|
|
|
25
59
|
REMOTE_WRITE,
|
|
26
60
|
annotate,
|
|
27
61
|
destroysNothing,
|
|
28
|
-
endpoint,
|
|
29
62
|
environmentOf,
|
|
30
63
|
itemOf,
|
|
31
64
|
jsonlRecords,
|
|
32
65
|
lineOf,
|
|
33
66
|
listOf,
|
|
34
|
-
modelTarget,
|
|
35
67
|
nextStep,
|
|
36
68
|
outputFor,
|
|
37
69
|
recalledAccount,
|
|
@@ -40,58 +72,21 @@ import {
|
|
|
40
72
|
snakeKeys,
|
|
41
73
|
storeTable,
|
|
42
74
|
withoutProviderRefs
|
|
43
|
-
} from "./chunk-
|
|
44
|
-
import {
|
|
45
|
-
envName
|
|
46
|
-
} from "./chunk-ZM5J6ZMB.js";
|
|
47
|
-
import {
|
|
48
|
-
holdLock,
|
|
49
|
-
lockPath,
|
|
50
|
-
releaseLock,
|
|
51
|
-
servingProfiles,
|
|
52
|
-
takeLock
|
|
53
|
-
} from "./chunk-FRIJUILO.js";
|
|
54
|
-
import {
|
|
55
|
-
holdersOf
|
|
56
|
-
} from "./chunk-534OBX5Y.js";
|
|
57
|
-
import {
|
|
58
|
-
checkedOptions,
|
|
59
|
-
range
|
|
60
|
-
} from "./chunk-Z5KC7XBR.js";
|
|
61
|
-
import {
|
|
62
|
-
FETCHING,
|
|
63
|
-
RULES_VERSION,
|
|
64
|
-
applyTaskRulesOnArrival,
|
|
65
|
-
capability,
|
|
66
|
-
newSendId,
|
|
67
|
-
onlineDeps,
|
|
68
|
-
openRequestTask,
|
|
69
|
-
patiently,
|
|
70
|
-
senderIsMe,
|
|
71
|
-
servicesFor,
|
|
72
|
-
syncsOneChat
|
|
73
|
-
} from "./chunk-44SBK6KB.js";
|
|
74
|
-
import {
|
|
75
|
-
withTimeLimit
|
|
76
|
-
} from "./chunk-ND6LLYGF.js";
|
|
75
|
+
} from "./chunk-SIWXYB4E.js";
|
|
77
76
|
import {
|
|
78
77
|
codeOf,
|
|
79
|
-
currentRun,
|
|
80
78
|
levelFor,
|
|
81
79
|
parseDuration
|
|
82
|
-
} from "./chunk-
|
|
80
|
+
} from "./chunk-F56DRBGY.js";
|
|
83
81
|
import {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
validateImages
|
|
87
|
-
} from "./chunk-MOTRI3SY.js";
|
|
82
|
+
modelTarget
|
|
83
|
+
} from "./chunk-OWMZUWCM.js";
|
|
88
84
|
import {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
} from "./chunk-VAUMOZU5.js";
|
|
85
|
+
holdersOf
|
|
86
|
+
} from "./chunk-O7ZDCOZE.js";
|
|
87
|
+
import {
|
|
88
|
+
readSecret
|
|
89
|
+
} from "./chunk-HP3NT6JJ.js";
|
|
95
90
|
import {
|
|
96
91
|
CORPORA,
|
|
97
92
|
MIGRATIONS,
|
|
@@ -104,14 +99,13 @@ import {
|
|
|
104
99
|
fillStems,
|
|
105
100
|
fillTrigrams,
|
|
106
101
|
fillVectorIndexes,
|
|
107
|
-
formatLocator,
|
|
108
102
|
involvementStoreOver,
|
|
103
|
+
isDerivedTable,
|
|
109
104
|
migrate,
|
|
110
105
|
noteIndexState,
|
|
111
106
|
openSqlite,
|
|
112
107
|
openStore,
|
|
113
108
|
orphanPointers,
|
|
114
|
-
parseLocator,
|
|
115
109
|
pendingNormalization,
|
|
116
110
|
readStoreTables,
|
|
117
111
|
rebuildMentions,
|
|
@@ -127,48 +121,45 @@ import {
|
|
|
127
121
|
storeClients,
|
|
128
122
|
storeContents,
|
|
129
123
|
vectorIndexCounts
|
|
130
|
-
} from "./chunk-
|
|
124
|
+
} from "./chunk-NI5PD5KM.js";
|
|
125
|
+
import {
|
|
126
|
+
openCache
|
|
127
|
+
} from "./chunk-JMJIH6JH.js";
|
|
131
128
|
import {
|
|
129
|
+
currentRun,
|
|
130
|
+
formatLocator,
|
|
131
|
+
parseLocator,
|
|
132
132
|
readDamageMark,
|
|
133
133
|
readHealthMark,
|
|
134
|
+
readJournalMark,
|
|
134
135
|
recordDeepCheck
|
|
135
|
-
} from "./chunk-
|
|
136
|
+
} from "./chunk-D6Z43SOG.js";
|
|
136
137
|
import {
|
|
137
138
|
queryFieldsOf
|
|
138
|
-
} from "./chunk-
|
|
139
|
+
} from "./chunk-ECEP4SO3.js";
|
|
139
140
|
import {
|
|
140
141
|
failureKey,
|
|
141
142
|
isStoreDamage
|
|
142
|
-
} from "./chunk-
|
|
143
|
+
} from "./chunk-4AOINPN2.js";
|
|
143
144
|
import {
|
|
144
145
|
storePath
|
|
145
|
-
} from "./chunk-
|
|
146
|
+
} from "./chunk-UTNRBOEN.js";
|
|
146
147
|
import {
|
|
147
|
-
openCache
|
|
148
|
-
} from "./chunk-3HK5WMI5.js";
|
|
149
|
-
import {
|
|
150
|
-
readSecret
|
|
151
|
-
} from "./chunk-Y6GNA7HE.js";
|
|
152
|
-
import {
|
|
153
|
-
Credentials,
|
|
154
|
-
pathsAreOverridden,
|
|
155
148
|
resolvePaths,
|
|
156
149
|
writeSecurely
|
|
157
|
-
} from "./chunk-
|
|
150
|
+
} from "./chunk-7AQGVX5O.js";
|
|
158
151
|
import {
|
|
159
152
|
singleLine,
|
|
160
153
|
visibleControls
|
|
161
|
-
} from "./chunk-
|
|
154
|
+
} from "./chunk-6DCLZLGX.js";
|
|
162
155
|
import {
|
|
163
156
|
array,
|
|
164
157
|
boolean,
|
|
165
158
|
check,
|
|
166
159
|
forward,
|
|
167
160
|
getDotPath,
|
|
168
|
-
integer,
|
|
169
161
|
minLength,
|
|
170
162
|
nullable,
|
|
171
|
-
number,
|
|
172
163
|
object,
|
|
173
164
|
optional,
|
|
174
165
|
parse,
|
|
@@ -180,12 +171,11 @@ import {
|
|
|
180
171
|
strictObject,
|
|
181
172
|
string,
|
|
182
173
|
transform,
|
|
183
|
-
trim
|
|
184
|
-
|
|
185
|
-
} from "./chunk-FEZF3TII.js";
|
|
174
|
+
trim
|
|
175
|
+
} from "./chunk-TOVWMURV.js";
|
|
186
176
|
import {
|
|
187
177
|
CliError
|
|
188
|
-
} from "./chunk-
|
|
178
|
+
} from "./chunk-ELJUBPY4.js";
|
|
189
179
|
import {
|
|
190
180
|
__commonJS,
|
|
191
181
|
__name,
|
|
@@ -363,14 +353,14 @@ var require_liquid_node = __commonJS({
|
|
|
363
353
|
return value !== null && (type === "object" || type === "function");
|
|
364
354
|
}
|
|
365
355
|
__name(isObject, "isObject");
|
|
366
|
-
function
|
|
356
|
+
function range(start, stop, step = 1) {
|
|
367
357
|
const arr = [];
|
|
368
358
|
for (let i = start; i < stop; i += step) {
|
|
369
359
|
arr.push(i);
|
|
370
360
|
}
|
|
371
361
|
return arr;
|
|
372
362
|
}
|
|
373
|
-
__name(
|
|
363
|
+
__name(range, "range");
|
|
374
364
|
function padStart(str, length, ch = " ") {
|
|
375
365
|
return pad(str, length, ch, (str2, ch2) => ch2 + str2);
|
|
376
366
|
}
|
|
@@ -564,7 +554,7 @@ var require_liquid_node = __commonJS({
|
|
|
564
554
|
const lines = token.input.split("\n");
|
|
565
555
|
const begin = Math.max(line - 2, 1);
|
|
566
556
|
const end = Math.min(line + 3, lines.length);
|
|
567
|
-
const context =
|
|
557
|
+
const context = range(begin, end + 1).map((lineNumber) => {
|
|
568
558
|
const rowIndicator = lineNumber === line ? ">> " : " ";
|
|
569
559
|
const num = padStart(String(lineNumber), String(end).length);
|
|
570
560
|
let text = `${rowIndicator}${num}| `;
|
|
@@ -1142,8 +1132,8 @@ var require_liquid_node = __commonJS({
|
|
|
1142
1132
|
valid() {
|
|
1143
1133
|
return !isNaN(this.getTime());
|
|
1144
1134
|
}
|
|
1145
|
-
format(
|
|
1146
|
-
return this.DateTimeFormat && this.DateTimeFormat(this.locale,
|
|
1135
|
+
format(options) {
|
|
1136
|
+
return this.DateTimeFormat && this.DateTimeFormat(this.locale, options).format(this.displayDate);
|
|
1147
1137
|
}
|
|
1148
1138
|
/**
|
|
1149
1139
|
* Create a Date object fixed to it's declared Timezone. Both
|
|
@@ -1227,11 +1217,11 @@ var require_liquid_node = __commonJS({
|
|
|
1227
1217
|
static {
|
|
1228
1218
|
__name(this, "TagToken");
|
|
1229
1219
|
}
|
|
1230
|
-
constructor(input, begin, end,
|
|
1231
|
-
const { trimTagLeft, trimTagRight, tagDelimiterLeft, tagDelimiterRight } =
|
|
1220
|
+
constructor(input, begin, end, options, file2) {
|
|
1221
|
+
const { trimTagLeft, trimTagRight, tagDelimiterLeft, tagDelimiterRight } = options;
|
|
1232
1222
|
const [valueBegin, valueEnd] = [begin + tagDelimiterLeft.length, end - tagDelimiterRight.length];
|
|
1233
1223
|
super(exports.TokenKind.Tag, [valueBegin, valueEnd], input, begin, end, trimTagLeft, trimTagRight, file2);
|
|
1234
|
-
this.tokenizer = new Tokenizer(input,
|
|
1224
|
+
this.tokenizer = new Tokenizer(input, options.operators, file2, this.contentRange, options.groupedExpressions);
|
|
1235
1225
|
this.name = this.tokenizer.readTagName();
|
|
1236
1226
|
this.tokenizer.assert(this.name, `illegal tag syntax, tag name expected`);
|
|
1237
1227
|
this.tokenizer.skipBlank();
|
|
@@ -1242,8 +1232,8 @@ var require_liquid_node = __commonJS({
|
|
|
1242
1232
|
static {
|
|
1243
1233
|
__name(this, "OutputToken");
|
|
1244
1234
|
}
|
|
1245
|
-
constructor(input, begin, end,
|
|
1246
|
-
const { trimOutputLeft, trimOutputRight, outputDelimiterLeft, outputDelimiterRight } =
|
|
1235
|
+
constructor(input, begin, end, options, file2) {
|
|
1236
|
+
const { trimOutputLeft, trimOutputRight, outputDelimiterLeft, outputDelimiterRight } = options;
|
|
1247
1237
|
const valueRange = [begin + outputDelimiterLeft.length, end - outputDelimiterRight.length];
|
|
1248
1238
|
super(exports.TokenKind.Output, valueRange, input, begin, end, trimOutputLeft, trimOutputRight, file2);
|
|
1249
1239
|
}
|
|
@@ -1462,9 +1452,9 @@ var require_liquid_node = __commonJS({
|
|
|
1462
1452
|
static {
|
|
1463
1453
|
__name(this, "LiquidTagToken");
|
|
1464
1454
|
}
|
|
1465
|
-
constructor(input, begin, end,
|
|
1455
|
+
constructor(input, begin, end, options, file2) {
|
|
1466
1456
|
super(exports.TokenKind.Tag, [begin, end], input, begin, end, false, false, file2);
|
|
1467
|
-
this.tokenizer = new Tokenizer(input,
|
|
1457
|
+
this.tokenizer = new Tokenizer(input, options.operators, file2, this.contentRange, options.groupedExpressions);
|
|
1468
1458
|
this.name = this.tokenizer.readTagName();
|
|
1469
1459
|
this.tokenizer.assert(this.name, "illegal liquid tag syntax");
|
|
1470
1460
|
this.tokenizer.skipBlank();
|
|
@@ -1538,11 +1528,11 @@ var require_liquid_node = __commonJS({
|
|
|
1538
1528
|
static {
|
|
1539
1529
|
__name(this, "Filter");
|
|
1540
1530
|
}
|
|
1541
|
-
constructor(token,
|
|
1531
|
+
constructor(token, options, liquid) {
|
|
1542
1532
|
this.token = token;
|
|
1543
1533
|
this.name = token.name;
|
|
1544
|
-
this.handler = isFunction(
|
|
1545
|
-
this.raw = !isFunction(
|
|
1534
|
+
this.handler = isFunction(options) ? options : isFunction(options?.handler) ? options.handler : identify;
|
|
1535
|
+
this.raw = !isFunction(options) && !!options?.raw;
|
|
1546
1536
|
this.args = token.args;
|
|
1547
1537
|
this.liquid = liquid;
|
|
1548
1538
|
}
|
|
@@ -1645,7 +1635,7 @@ var require_liquid_node = __commonJS({
|
|
|
1645
1635
|
const low = yield evalTokenValue(token.lhs, ctx);
|
|
1646
1636
|
const high = yield evalTokenValue(token.rhs, ctx);
|
|
1647
1637
|
ctx.memoryLimit.use(high - low + 1);
|
|
1648
|
-
return
|
|
1638
|
+
return range(+low, +high + 1);
|
|
1649
1639
|
}
|
|
1650
1640
|
__name(evalRangeToken, "evalRangeToken");
|
|
1651
1641
|
function* toPostfix(tokens) {
|
|
@@ -1839,7 +1829,7 @@ var require_liquid_node = __commonJS({
|
|
|
1839
1829
|
return readFileAsync(filepath, "utf8");
|
|
1840
1830
|
}
|
|
1841
1831
|
__name(readFile, "readFile");
|
|
1842
|
-
function
|
|
1832
|
+
function existsSync11(filepath) {
|
|
1843
1833
|
try {
|
|
1844
1834
|
fs$1.statSync(filepath);
|
|
1845
1835
|
return true;
|
|
@@ -1847,11 +1837,11 @@ var require_liquid_node = __commonJS({
|
|
|
1847
1837
|
return false;
|
|
1848
1838
|
}
|
|
1849
1839
|
}
|
|
1850
|
-
__name(
|
|
1851
|
-
function
|
|
1840
|
+
__name(existsSync11, "existsSync");
|
|
1841
|
+
function readFileSync6(filepath) {
|
|
1852
1842
|
return fs$1.readFileSync(filepath, "utf8");
|
|
1853
1843
|
}
|
|
1854
|
-
__name(
|
|
1844
|
+
__name(readFileSync6, "readFileSync");
|
|
1855
1845
|
function resolve2(root, file2, ext) {
|
|
1856
1846
|
if (!path.extname(file2))
|
|
1857
1847
|
file2 += ext;
|
|
@@ -1865,10 +1855,10 @@ var require_liquid_node = __commonJS({
|
|
|
1865
1855
|
}
|
|
1866
1856
|
}
|
|
1867
1857
|
__name(fallback, "fallback");
|
|
1868
|
-
function
|
|
1858
|
+
function dirname4(filepath) {
|
|
1869
1859
|
return path.dirname(filepath);
|
|
1870
1860
|
}
|
|
1871
|
-
__name(
|
|
1861
|
+
__name(dirname4, "dirname");
|
|
1872
1862
|
var realpathAsync = promisify(fs$1.realpath);
|
|
1873
1863
|
async function contains(root, file2) {
|
|
1874
1864
|
try {
|
|
@@ -1896,11 +1886,11 @@ var require_liquid_node = __commonJS({
|
|
|
1896
1886
|
__proto__: null,
|
|
1897
1887
|
exists,
|
|
1898
1888
|
readFile,
|
|
1899
|
-
existsSync:
|
|
1900
|
-
readFileSync:
|
|
1889
|
+
existsSync: existsSync11,
|
|
1890
|
+
readFileSync: readFileSync6,
|
|
1901
1891
|
resolve: resolve2,
|
|
1902
1892
|
fallback,
|
|
1903
|
-
dirname:
|
|
1893
|
+
dirname: dirname4,
|
|
1904
1894
|
contains,
|
|
1905
1895
|
containsSync,
|
|
1906
1896
|
sep: path.sep
|
|
@@ -2126,41 +2116,41 @@ var require_liquid_node = __commonJS({
|
|
|
2126
2116
|
parseLimit: Infinity,
|
|
2127
2117
|
renderLimit: Infinity
|
|
2128
2118
|
};
|
|
2129
|
-
function normalize(
|
|
2130
|
-
if (
|
|
2131
|
-
if (!
|
|
2132
|
-
|
|
2133
|
-
if (!
|
|
2134
|
-
|
|
2135
|
-
}
|
|
2136
|
-
if (
|
|
2119
|
+
function normalize(options) {
|
|
2120
|
+
if (options.hasOwnProperty("root")) {
|
|
2121
|
+
if (!options.hasOwnProperty("partials"))
|
|
2122
|
+
options.partials = options.root;
|
|
2123
|
+
if (!options.hasOwnProperty("layouts"))
|
|
2124
|
+
options.layouts = options.root;
|
|
2125
|
+
}
|
|
2126
|
+
if (options.hasOwnProperty("cache")) {
|
|
2137
2127
|
let cache;
|
|
2138
|
-
if (typeof
|
|
2139
|
-
cache =
|
|
2140
|
-
else if (typeof
|
|
2141
|
-
cache =
|
|
2128
|
+
if (typeof options.cache === "number")
|
|
2129
|
+
cache = options.cache > 0 ? new LRU(options.cache) : void 0;
|
|
2130
|
+
else if (typeof options.cache === "object")
|
|
2131
|
+
cache = options.cache;
|
|
2142
2132
|
else
|
|
2143
|
-
cache =
|
|
2144
|
-
|
|
2133
|
+
cache = options.cache ? new LRU(1024) : void 0;
|
|
2134
|
+
options.cache = cache;
|
|
2145
2135
|
}
|
|
2146
|
-
|
|
2147
|
-
if ((!
|
|
2136
|
+
options = { ...defaultOptions, ...options.jekyllInclude ? { dynamicPartials: false } : {}, ...options };
|
|
2137
|
+
if ((!options.fs.dirname || !options.fs.sep) && options.relativeReference) {
|
|
2148
2138
|
console.warn("[LiquidJS] `fs.dirname` and `fs.sep` are required for relativeReference, set relativeReference to `false` to suppress this warning");
|
|
2149
|
-
|
|
2139
|
+
options.relativeReference = false;
|
|
2150
2140
|
}
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
if (!
|
|
2156
|
-
|
|
2141
|
+
options.root = normalizeDirectoryList(options.root);
|
|
2142
|
+
options.partials = normalizeDirectoryList(options.partials);
|
|
2143
|
+
options.layouts = normalizeDirectoryList(options.layouts);
|
|
2144
|
+
options.outputEscape = options.outputEscape && getOutputEscapeFunction(options.outputEscape);
|
|
2145
|
+
if (!options.locale) {
|
|
2146
|
+
options.locale = getDateTimeFormat()?.().resolvedOptions().locale ?? "en-US";
|
|
2157
2147
|
}
|
|
2158
|
-
if (
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2148
|
+
if (options.templates) {
|
|
2149
|
+
options.fs = new MapFS(options.templates);
|
|
2150
|
+
options.relativeReference = true;
|
|
2151
|
+
options.root = options.partials = options.layouts = ".";
|
|
2162
2152
|
}
|
|
2163
|
-
return
|
|
2153
|
+
return options;
|
|
2164
2154
|
}
|
|
2165
2155
|
__name(normalize, "normalize");
|
|
2166
2156
|
function getOutputEscapeFunction(nameOrFunction) {
|
|
@@ -2181,14 +2171,14 @@ var require_liquid_node = __commonJS({
|
|
|
2181
2171
|
return list;
|
|
2182
2172
|
}
|
|
2183
2173
|
__name(normalizeDirectoryList, "normalizeDirectoryList");
|
|
2184
|
-
function whiteSpaceCtrl(tokens,
|
|
2174
|
+
function whiteSpaceCtrl(tokens, options) {
|
|
2185
2175
|
let inRaw = false;
|
|
2186
2176
|
for (let i = 0; i < tokens.length; i++) {
|
|
2187
2177
|
const token = tokens[i];
|
|
2188
2178
|
if (!isDelimitedToken(token))
|
|
2189
2179
|
continue;
|
|
2190
2180
|
if (!inRaw && token.trimLeft) {
|
|
2191
|
-
trimLeft(tokens[i - 1],
|
|
2181
|
+
trimLeft(tokens[i - 1], options.greedy);
|
|
2192
2182
|
}
|
|
2193
2183
|
if (isTagToken(token)) {
|
|
2194
2184
|
if (token.name === "raw")
|
|
@@ -2197,7 +2187,7 @@ var require_liquid_node = __commonJS({
|
|
|
2197
2187
|
inRaw = false;
|
|
2198
2188
|
}
|
|
2199
2189
|
if (!inRaw && token.trimRight) {
|
|
2200
|
-
trimRight(tokens[i + 1],
|
|
2190
|
+
trimRight(tokens[i + 1], options.greedy);
|
|
2201
2191
|
}
|
|
2202
2192
|
}
|
|
2203
2193
|
}
|
|
@@ -2224,12 +2214,12 @@ var require_liquid_node = __commonJS({
|
|
|
2224
2214
|
static {
|
|
2225
2215
|
__name(this, "Tokenizer");
|
|
2226
2216
|
}
|
|
2227
|
-
constructor(input, operators = defaultOptions.operators, file2,
|
|
2217
|
+
constructor(input, operators = defaultOptions.operators, file2, range2, groupedExpressions = false) {
|
|
2228
2218
|
this.input = input;
|
|
2229
2219
|
this.file = file2;
|
|
2230
2220
|
this.rawBeginAt = -1;
|
|
2231
|
-
this.p =
|
|
2232
|
-
this.N =
|
|
2221
|
+
this.p = range2 ? range2[0] : 0;
|
|
2222
|
+
this.N = range2 ? range2[1] : input.length;
|
|
2233
2223
|
this.opTrie = createTrie(operators);
|
|
2234
2224
|
this.literalTrie = createTrie(literalValues);
|
|
2235
2225
|
this.groupedExpressions = groupedExpressions;
|
|
@@ -2329,23 +2319,23 @@ var require_liquid_node = __commonJS({
|
|
|
2329
2319
|
const value = this.readValue();
|
|
2330
2320
|
return [key.getText(), value];
|
|
2331
2321
|
}
|
|
2332
|
-
readTopLevelTokens(
|
|
2322
|
+
readTopLevelTokens(options = defaultOptions) {
|
|
2333
2323
|
const tokens = [];
|
|
2334
2324
|
while (this.p < this.N) {
|
|
2335
|
-
const token = this.readTopLevelToken(
|
|
2325
|
+
const token = this.readTopLevelToken(options);
|
|
2336
2326
|
tokens.push(token);
|
|
2337
2327
|
}
|
|
2338
|
-
whiteSpaceCtrl(tokens,
|
|
2328
|
+
whiteSpaceCtrl(tokens, options);
|
|
2339
2329
|
return tokens;
|
|
2340
2330
|
}
|
|
2341
|
-
readTopLevelToken(
|
|
2342
|
-
const { tagDelimiterLeft, outputDelimiterLeft } =
|
|
2331
|
+
readTopLevelToken(options) {
|
|
2332
|
+
const { tagDelimiterLeft, outputDelimiterLeft } = options;
|
|
2343
2333
|
if (this.rawBeginAt > -1)
|
|
2344
|
-
return this.readEndrawOrRawContent(
|
|
2334
|
+
return this.readEndrawOrRawContent(options);
|
|
2345
2335
|
if (this.match(tagDelimiterLeft))
|
|
2346
|
-
return this.readTagToken(
|
|
2336
|
+
return this.readTagToken(options);
|
|
2347
2337
|
if (this.match(outputDelimiterLeft))
|
|
2348
|
-
return this.readOutputToken(
|
|
2338
|
+
return this.readOutputToken(options);
|
|
2349
2339
|
return this.readHTMLToken([tagDelimiterLeft, outputDelimiterLeft]);
|
|
2350
2340
|
}
|
|
2351
2341
|
readHTMLToken(stopStrings) {
|
|
@@ -2357,13 +2347,13 @@ var require_liquid_node = __commonJS({
|
|
|
2357
2347
|
}
|
|
2358
2348
|
return new HTMLToken(this.input, begin, this.p, this.file);
|
|
2359
2349
|
}
|
|
2360
|
-
readTagToken(
|
|
2350
|
+
readTagToken(options) {
|
|
2361
2351
|
const { file: file2, input } = this;
|
|
2362
2352
|
const begin = this.p;
|
|
2363
|
-
if (this.readToDelimiter(
|
|
2353
|
+
if (this.readToDelimiter(options.tagDelimiterRight) === -1) {
|
|
2364
2354
|
throw this.error(`tag ${this.snapshot(begin)} not closed`, begin);
|
|
2365
2355
|
}
|
|
2366
|
-
const token = new TagToken(input, begin, this.p,
|
|
2356
|
+
const token = new TagToken(input, begin, this.p, options, file2);
|
|
2367
2357
|
if (token.name === "raw")
|
|
2368
2358
|
this.rawBeginAt = begin;
|
|
2369
2359
|
return token;
|
|
@@ -2381,17 +2371,17 @@ var require_liquid_node = __commonJS({
|
|
|
2381
2371
|
}
|
|
2382
2372
|
return -1;
|
|
2383
2373
|
}
|
|
2384
|
-
readOutputToken(
|
|
2374
|
+
readOutputToken(options = defaultOptions) {
|
|
2385
2375
|
const { file: file2, input } = this;
|
|
2386
|
-
const { outputDelimiterRight } =
|
|
2376
|
+
const { outputDelimiterRight } = options;
|
|
2387
2377
|
const begin = this.p;
|
|
2388
2378
|
if (this.readToDelimiter(outputDelimiterRight, true) === -1) {
|
|
2389
2379
|
throw this.error(`output ${this.snapshot(begin)} not closed`, begin);
|
|
2390
2380
|
}
|
|
2391
|
-
return new OutputToken(input, begin, this.p,
|
|
2381
|
+
return new OutputToken(input, begin, this.p, options, file2);
|
|
2392
2382
|
}
|
|
2393
|
-
readEndrawOrRawContent(
|
|
2394
|
-
const { tagDelimiterLeft, tagDelimiterRight } =
|
|
2383
|
+
readEndrawOrRawContent(options) {
|
|
2384
|
+
const { tagDelimiterLeft, tagDelimiterRight } = options;
|
|
2395
2385
|
const begin = this.p;
|
|
2396
2386
|
let leftPos = this.readTo(tagDelimiterLeft) - tagDelimiterLeft.length;
|
|
2397
2387
|
while (this.p < this.N) {
|
|
@@ -2404,7 +2394,7 @@ var require_liquid_node = __commonJS({
|
|
|
2404
2394
|
const end = this.p;
|
|
2405
2395
|
if (begin === leftPos) {
|
|
2406
2396
|
this.rawBeginAt = -1;
|
|
2407
|
-
return new TagToken(this.input, begin, end,
|
|
2397
|
+
return new TagToken(this.input, begin, end, options, this.file);
|
|
2408
2398
|
} else {
|
|
2409
2399
|
this.p = leftPos;
|
|
2410
2400
|
return new HTMLToken(this.input, begin, leftPos, this.file);
|
|
@@ -2417,22 +2407,22 @@ var require_liquid_node = __commonJS({
|
|
|
2417
2407
|
}
|
|
2418
2408
|
throw this.error(`raw ${this.snapshot(this.rawBeginAt)} not closed`, begin);
|
|
2419
2409
|
}
|
|
2420
|
-
readLiquidTagTokens(
|
|
2410
|
+
readLiquidTagTokens(options = defaultOptions) {
|
|
2421
2411
|
const tokens = [];
|
|
2422
2412
|
while (this.p < this.N) {
|
|
2423
|
-
const token = this.readLiquidTagToken(
|
|
2413
|
+
const token = this.readLiquidTagToken(options);
|
|
2424
2414
|
token && tokens.push(token);
|
|
2425
2415
|
}
|
|
2426
2416
|
return tokens;
|
|
2427
2417
|
}
|
|
2428
|
-
readLiquidTagToken(
|
|
2418
|
+
readLiquidTagToken(options) {
|
|
2429
2419
|
this.skipBlank();
|
|
2430
2420
|
if (this.end())
|
|
2431
2421
|
return;
|
|
2432
2422
|
const begin = this.p;
|
|
2433
2423
|
this.readToDelimiter("\n");
|
|
2434
2424
|
const end = this.p;
|
|
2435
|
-
return new LiquidTagToken(this.input, begin, end,
|
|
2425
|
+
return new LiquidTagToken(this.input, begin, end, options, this.file);
|
|
2436
2426
|
}
|
|
2437
2427
|
error(msg, pos = this.p) {
|
|
2438
2428
|
return new TokenizationError(msg, new IdentifierToken(this.input, pos, this.N, this.file));
|
|
@@ -2644,12 +2634,12 @@ var require_liquid_node = __commonJS({
|
|
|
2644
2634
|
}
|
|
2645
2635
|
return new QuotedToken(this.input, begin, this.p, this.file);
|
|
2646
2636
|
}
|
|
2647
|
-
*readFileNameTemplate(
|
|
2648
|
-
const { outputDelimiterLeft } =
|
|
2637
|
+
*readFileNameTemplate(options) {
|
|
2638
|
+
const { outputDelimiterLeft } = options;
|
|
2649
2639
|
const htmlStopStrings = [",", " ", "\r", "\n", " ", outputDelimiterLeft];
|
|
2650
2640
|
const htmlStopStringSet = new Set(htmlStopStrings);
|
|
2651
2641
|
while (this.p < this.N && !htmlStopStringSet.has(this.peek())) {
|
|
2652
|
-
yield this.match(outputDelimiterLeft) ? this.readOutputToken(
|
|
2642
|
+
yield this.match(outputDelimiterLeft) ? this.readOutputToken(options) : this.readHTMLToken(htmlStopStrings);
|
|
2653
2643
|
}
|
|
2654
2644
|
}
|
|
2655
2645
|
match(word) {
|
|
@@ -2724,7 +2714,7 @@ var require_liquid_node = __commonJS({
|
|
|
2724
2714
|
this.token = token;
|
|
2725
2715
|
}
|
|
2726
2716
|
};
|
|
2727
|
-
var
|
|
2717
|
+
var Tag3 = class extends TemplateImpl {
|
|
2728
2718
|
static {
|
|
2729
2719
|
__name(this, "Tag");
|
|
2730
2720
|
}
|
|
@@ -2754,17 +2744,17 @@ var require_liquid_node = __commonJS({
|
|
|
2754
2744
|
return hash2;
|
|
2755
2745
|
}
|
|
2756
2746
|
};
|
|
2757
|
-
function createTagClass(
|
|
2758
|
-
return class extends
|
|
2747
|
+
function createTagClass(options) {
|
|
2748
|
+
return class extends Tag3 {
|
|
2759
2749
|
constructor(token, tokens, liquid) {
|
|
2760
2750
|
super(token, tokens, liquid);
|
|
2761
|
-
if (isFunction(
|
|
2762
|
-
|
|
2751
|
+
if (isFunction(options.parse)) {
|
|
2752
|
+
options.parse.call(this, token, tokens);
|
|
2763
2753
|
}
|
|
2764
2754
|
}
|
|
2765
2755
|
*render(ctx, emitter) {
|
|
2766
2756
|
const hash2 = yield new Hash(this.token.args, ctx.opts.keyValueSeparator).render(ctx);
|
|
2767
|
-
return yield
|
|
2757
|
+
return yield options.render.call(this, ctx, emitter, hash2);
|
|
2768
2758
|
}
|
|
2769
2759
|
};
|
|
2770
2760
|
}
|
|
@@ -2981,13 +2971,13 @@ var require_liquid_node = __commonJS({
|
|
|
2981
2971
|
};
|
|
2982
2972
|
}
|
|
2983
2973
|
__name(_analyze, "_analyze");
|
|
2984
|
-
function analyze(template2,
|
|
2985
|
-
const opts = { ...defaultStaticAnalysisOptions, ...
|
|
2974
|
+
function analyze(template2, options = {}) {
|
|
2975
|
+
const opts = { ...defaultStaticAnalysisOptions, ...options };
|
|
2986
2976
|
return toPromise(_analyze(template2, opts.partials, false));
|
|
2987
2977
|
}
|
|
2988
2978
|
__name(analyze, "analyze");
|
|
2989
|
-
function analyzeSync(template2,
|
|
2990
|
-
const opts = { ...defaultStaticAnalysisOptions, ...
|
|
2979
|
+
function analyzeSync(template2, options = {}) {
|
|
2980
|
+
const opts = { ...defaultStaticAnalysisOptions, ...options };
|
|
2991
2981
|
return toValueSync(_analyze(template2, opts.partials, true));
|
|
2992
2982
|
}
|
|
2993
2983
|
__name(analyzeSync, "analyzeSync");
|
|
@@ -3163,17 +3153,17 @@ var require_liquid_node = __commonJS({
|
|
|
3163
3153
|
static {
|
|
3164
3154
|
__name(this, "Loader");
|
|
3165
3155
|
}
|
|
3166
|
-
constructor(
|
|
3167
|
-
this.options =
|
|
3168
|
-
if (
|
|
3169
|
-
const sep =
|
|
3156
|
+
constructor(options) {
|
|
3157
|
+
this.options = options;
|
|
3158
|
+
if (options.relativeReference) {
|
|
3159
|
+
const sep = options.fs.sep;
|
|
3170
3160
|
assert(sep, "`fs.sep` is required for relative reference");
|
|
3171
3161
|
const prefixes = ["." + sep, ".." + sep, "./", "../"];
|
|
3172
3162
|
this.shouldLoadRelative = (referencedFile) => prefixes.some((prefix) => referencedFile.startsWith(prefix));
|
|
3173
3163
|
} else {
|
|
3174
3164
|
this.shouldLoadRelative = (_referencedFile) => false;
|
|
3175
3165
|
}
|
|
3176
|
-
const fs2 =
|
|
3166
|
+
const fs2 = options.fs;
|
|
3177
3167
|
this.contains = toLiquidAsync(fs2.contains?.bind(fs2) || (async () => true), fs2.containsSync?.bind(fs2) || (() => true));
|
|
3178
3168
|
this.exists = toLiquidAsync(fs2.exists?.bind(fs2) || (async () => false), fs2.existsSync?.bind(fs2));
|
|
3179
3169
|
}
|
|
@@ -3625,7 +3615,7 @@ var require_liquid_node = __commonJS({
|
|
|
3625
3615
|
uri_escape,
|
|
3626
3616
|
slugify
|
|
3627
3617
|
});
|
|
3628
|
-
var
|
|
3618
|
+
var join6 = argumentsToValue(function(v, arg) {
|
|
3629
3619
|
const array2 = toArray(v);
|
|
3630
3620
|
const sep = isNil(arg) ? " " : stringify(arg);
|
|
3631
3621
|
let outputSize = sep.length * Math.max(array2.length - 1, 0);
|
|
@@ -3901,7 +3891,7 @@ var require_liquid_node = __commonJS({
|
|
|
3901
3891
|
__name(sample, "sample");
|
|
3902
3892
|
var arrayFilters = /* @__PURE__ */ Object.freeze({
|
|
3903
3893
|
__proto__: null,
|
|
3904
|
-
join:
|
|
3894
|
+
join: join6,
|
|
3905
3895
|
last,
|
|
3906
3896
|
first,
|
|
3907
3897
|
reverse,
|
|
@@ -4323,7 +4313,7 @@ var require_liquid_node = __commonJS({
|
|
|
4323
4313
|
...cryptoFilters,
|
|
4324
4314
|
...misc
|
|
4325
4315
|
};
|
|
4326
|
-
var AssignTag = class extends
|
|
4316
|
+
var AssignTag = class extends Tag3 {
|
|
4327
4317
|
static {
|
|
4328
4318
|
__name(this, "AssignTag");
|
|
4329
4319
|
}
|
|
@@ -4348,7 +4338,7 @@ var require_liquid_node = __commonJS({
|
|
|
4348
4338
|
}
|
|
4349
4339
|
};
|
|
4350
4340
|
var MODIFIERS = ["offset", "limit", "reversed"];
|
|
4351
|
-
var ForTag = class extends
|
|
4341
|
+
var ForTag = class extends Tag3 {
|
|
4352
4342
|
static {
|
|
4353
4343
|
__name(this, "ForTag");
|
|
4354
4344
|
}
|
|
@@ -4441,7 +4431,7 @@ var require_liquid_node = __commonJS({
|
|
|
4441
4431
|
return arr.slice(0, count3);
|
|
4442
4432
|
}
|
|
4443
4433
|
__name(limit2, "limit");
|
|
4444
|
-
var CaptureTag = class extends
|
|
4434
|
+
var CaptureTag = class extends Tag3 {
|
|
4445
4435
|
static {
|
|
4446
4436
|
__name(this, "CaptureTag");
|
|
4447
4437
|
}
|
|
@@ -4479,7 +4469,7 @@ var require_liquid_node = __commonJS({
|
|
|
4479
4469
|
yield this.identifier;
|
|
4480
4470
|
}
|
|
4481
4471
|
};
|
|
4482
|
-
var CaseTag = class extends
|
|
4472
|
+
var CaseTag = class extends Tag3 {
|
|
4483
4473
|
static {
|
|
4484
4474
|
__name(this, "CaseTag");
|
|
4485
4475
|
}
|
|
@@ -4552,7 +4542,7 @@ var require_liquid_node = __commonJS({
|
|
|
4552
4542
|
return templates;
|
|
4553
4543
|
}
|
|
4554
4544
|
};
|
|
4555
|
-
var CommentTag = class extends
|
|
4545
|
+
var CommentTag = class extends Tag3 {
|
|
4556
4546
|
static {
|
|
4557
4547
|
__name(this, "CommentTag");
|
|
4558
4548
|
}
|
|
@@ -4568,7 +4558,7 @@ var require_liquid_node = __commonJS({
|
|
|
4568
4558
|
render() {
|
|
4569
4559
|
}
|
|
4570
4560
|
};
|
|
4571
|
-
var RenderTag = class extends
|
|
4561
|
+
var RenderTag = class extends Tag3 {
|
|
4572
4562
|
static {
|
|
4573
4563
|
__name(this, "RenderTag");
|
|
4574
4564
|
}
|
|
@@ -4715,7 +4705,7 @@ var require_liquid_node = __commonJS({
|
|
|
4715
4705
|
return yield evalToken(file2, ctx);
|
|
4716
4706
|
}
|
|
4717
4707
|
__name(renderFilePath, "renderFilePath");
|
|
4718
|
-
var IncludeTag = class extends
|
|
4708
|
+
var IncludeTag = class extends Tag3 {
|
|
4719
4709
|
static {
|
|
4720
4710
|
__name(this, "IncludeTag");
|
|
4721
4711
|
}
|
|
@@ -4783,7 +4773,7 @@ var require_liquid_node = __commonJS({
|
|
|
4783
4773
|
}
|
|
4784
4774
|
}
|
|
4785
4775
|
};
|
|
4786
|
-
var DecrementTag = class extends
|
|
4776
|
+
var DecrementTag = class extends Tag3 {
|
|
4787
4777
|
static {
|
|
4788
4778
|
__name(this, "DecrementTag");
|
|
4789
4779
|
}
|
|
@@ -4803,7 +4793,7 @@ var require_liquid_node = __commonJS({
|
|
|
4803
4793
|
yield this.identifier;
|
|
4804
4794
|
}
|
|
4805
4795
|
};
|
|
4806
|
-
var CycleTag = class extends
|
|
4796
|
+
var CycleTag = class extends Tag3 {
|
|
4807
4797
|
static {
|
|
4808
4798
|
__name(this, "CycleTag");
|
|
4809
4799
|
}
|
|
@@ -4847,7 +4837,7 @@ var require_liquid_node = __commonJS({
|
|
|
4847
4837
|
}
|
|
4848
4838
|
}
|
|
4849
4839
|
};
|
|
4850
|
-
var IfTag = class extends
|
|
4840
|
+
var IfTag = class extends Tag3 {
|
|
4851
4841
|
static {
|
|
4852
4842
|
__name(this, "IfTag");
|
|
4853
4843
|
}
|
|
@@ -4897,7 +4887,7 @@ var require_liquid_node = __commonJS({
|
|
|
4897
4887
|
return this.branches.map((b) => b.value);
|
|
4898
4888
|
}
|
|
4899
4889
|
};
|
|
4900
|
-
var IncrementTag = class extends
|
|
4890
|
+
var IncrementTag = class extends Tag3 {
|
|
4901
4891
|
static {
|
|
4902
4892
|
__name(this, "IncrementTag");
|
|
4903
4893
|
}
|
|
@@ -4919,7 +4909,7 @@ var require_liquid_node = __commonJS({
|
|
|
4919
4909
|
yield this.identifier;
|
|
4920
4910
|
}
|
|
4921
4911
|
};
|
|
4922
|
-
var LayoutTag = class extends
|
|
4912
|
+
var LayoutTag = class extends Tag3 {
|
|
4923
4913
|
static {
|
|
4924
4914
|
__name(this, "LayoutTag");
|
|
4925
4915
|
}
|
|
@@ -4974,7 +4964,7 @@ var require_liquid_node = __commonJS({
|
|
|
4974
4964
|
}
|
|
4975
4965
|
}
|
|
4976
4966
|
};
|
|
4977
|
-
var BlockTag = class extends
|
|
4967
|
+
var BlockTag = class extends Tag3 {
|
|
4978
4968
|
static {
|
|
4979
4969
|
__name(this, "BlockTag");
|
|
4980
4970
|
}
|
|
@@ -5023,7 +5013,7 @@ var require_liquid_node = __commonJS({
|
|
|
5023
5013
|
return ["block"];
|
|
5024
5014
|
}
|
|
5025
5015
|
};
|
|
5026
|
-
var RawTag = class extends
|
|
5016
|
+
var RawTag = class extends Tag3 {
|
|
5027
5017
|
static {
|
|
5028
5018
|
__name(this, "RawTag");
|
|
5029
5019
|
}
|
|
@@ -5067,7 +5057,7 @@ var require_liquid_node = __commonJS({
|
|
|
5067
5057
|
return this.col() === this.cols;
|
|
5068
5058
|
}
|
|
5069
5059
|
};
|
|
5070
|
-
var TablerowTag = class extends
|
|
5060
|
+
var TablerowTag = class extends Tag3 {
|
|
5071
5061
|
static {
|
|
5072
5062
|
__name(this, "TablerowTag");
|
|
5073
5063
|
}
|
|
@@ -5131,7 +5121,7 @@ var require_liquid_node = __commonJS({
|
|
|
5131
5121
|
return [this.variable, "tablerowloop"];
|
|
5132
5122
|
}
|
|
5133
5123
|
};
|
|
5134
|
-
var UnlessTag = class extends
|
|
5124
|
+
var UnlessTag = class extends Tag3 {
|
|
5135
5125
|
static {
|
|
5136
5126
|
__name(this, "UnlessTag");
|
|
5137
5127
|
}
|
|
@@ -5190,7 +5180,7 @@ var require_liquid_node = __commonJS({
|
|
|
5190
5180
|
return this.branches.map((b) => b.value);
|
|
5191
5181
|
}
|
|
5192
5182
|
};
|
|
5193
|
-
var BreakTag = class extends
|
|
5183
|
+
var BreakTag = class extends Tag3 {
|
|
5194
5184
|
static {
|
|
5195
5185
|
__name(this, "BreakTag");
|
|
5196
5186
|
}
|
|
@@ -5198,7 +5188,7 @@ var require_liquid_node = __commonJS({
|
|
|
5198
5188
|
ctx.breakCalled = true;
|
|
5199
5189
|
}
|
|
5200
5190
|
};
|
|
5201
|
-
var ContinueTag = class extends
|
|
5191
|
+
var ContinueTag = class extends Tag3 {
|
|
5202
5192
|
static {
|
|
5203
5193
|
__name(this, "ContinueTag");
|
|
5204
5194
|
}
|
|
@@ -5206,7 +5196,7 @@ var require_liquid_node = __commonJS({
|
|
|
5206
5196
|
ctx.continueCalled = true;
|
|
5207
5197
|
}
|
|
5208
5198
|
};
|
|
5209
|
-
var EchoTag = class extends
|
|
5199
|
+
var EchoTag = class extends Tag3 {
|
|
5210
5200
|
static {
|
|
5211
5201
|
__name(this, "EchoTag");
|
|
5212
5202
|
}
|
|
@@ -5229,7 +5219,7 @@ var require_liquid_node = __commonJS({
|
|
|
5229
5219
|
}
|
|
5230
5220
|
}
|
|
5231
5221
|
};
|
|
5232
|
-
var LiquidTag = class extends
|
|
5222
|
+
var LiquidTag = class extends Tag3 {
|
|
5233
5223
|
static {
|
|
5234
5224
|
__name(this, "LiquidTag");
|
|
5235
5225
|
}
|
|
@@ -5245,7 +5235,7 @@ var require_liquid_node = __commonJS({
|
|
|
5245
5235
|
return this.templates;
|
|
5246
5236
|
}
|
|
5247
5237
|
};
|
|
5248
|
-
var InlineCommentTag = class extends
|
|
5238
|
+
var InlineCommentTag = class extends Tag3 {
|
|
5249
5239
|
static {
|
|
5250
5240
|
__name(this, "InlineCommentTag");
|
|
5251
5241
|
}
|
|
@@ -5388,76 +5378,76 @@ var require_liquid_node = __commonJS({
|
|
|
5388
5378
|
self.renderFile(filePath, ctx).then((html) => callback(null, html), callback);
|
|
5389
5379
|
};
|
|
5390
5380
|
}
|
|
5391
|
-
async analyze(template2,
|
|
5392
|
-
return analyze(template2,
|
|
5381
|
+
async analyze(template2, options = {}) {
|
|
5382
|
+
return analyze(template2, options);
|
|
5393
5383
|
}
|
|
5394
|
-
analyzeSync(template2,
|
|
5395
|
-
return analyzeSync(template2,
|
|
5384
|
+
analyzeSync(template2, options = {}) {
|
|
5385
|
+
return analyzeSync(template2, options);
|
|
5396
5386
|
}
|
|
5397
|
-
async parseAndAnalyze(html, filename,
|
|
5398
|
-
return analyze(this.parse(html, filename),
|
|
5387
|
+
async parseAndAnalyze(html, filename, options = {}) {
|
|
5388
|
+
return analyze(this.parse(html, filename), options);
|
|
5399
5389
|
}
|
|
5400
|
-
parseAndAnalyzeSync(html, filename,
|
|
5401
|
-
return analyzeSync(this.parse(html, filename),
|
|
5390
|
+
parseAndAnalyzeSync(html, filename, options = {}) {
|
|
5391
|
+
return analyzeSync(this.parse(html, filename), options);
|
|
5402
5392
|
}
|
|
5403
5393
|
/** Return an array of all variables without their properties. */
|
|
5404
|
-
async variables(template2,
|
|
5405
|
-
const analysis = await analyze(isString(template2) ? this.parse(template2) : template2,
|
|
5394
|
+
async variables(template2, options = {}) {
|
|
5395
|
+
const analysis = await analyze(isString(template2) ? this.parse(template2) : template2, options);
|
|
5406
5396
|
return Object.keys(analysis.variables);
|
|
5407
5397
|
}
|
|
5408
5398
|
/** Return an array of all variables without their properties. */
|
|
5409
|
-
variablesSync(template2,
|
|
5410
|
-
const analysis = analyzeSync(isString(template2) ? this.parse(template2) : template2,
|
|
5399
|
+
variablesSync(template2, options = {}) {
|
|
5400
|
+
const analysis = analyzeSync(isString(template2) ? this.parse(template2) : template2, options);
|
|
5411
5401
|
return Object.keys(analysis.variables);
|
|
5412
5402
|
}
|
|
5413
5403
|
/** Return an array of all variables including their properties/paths. */
|
|
5414
|
-
async fullVariables(template2,
|
|
5415
|
-
const analysis = await analyze(isString(template2) ? this.parse(template2) : template2,
|
|
5404
|
+
async fullVariables(template2, options = {}) {
|
|
5405
|
+
const analysis = await analyze(isString(template2) ? this.parse(template2) : template2, options);
|
|
5416
5406
|
return Array.from(new Set(Object.values(analysis.variables).flatMap((a) => a.map((v) => String(v)))));
|
|
5417
5407
|
}
|
|
5418
5408
|
/** Return an array of all variables including their properties/paths. */
|
|
5419
|
-
fullVariablesSync(template2,
|
|
5420
|
-
const analysis = analyzeSync(isString(template2) ? this.parse(template2) : template2,
|
|
5409
|
+
fullVariablesSync(template2, options = {}) {
|
|
5410
|
+
const analysis = analyzeSync(isString(template2) ? this.parse(template2) : template2, options);
|
|
5421
5411
|
return Array.from(new Set(Object.values(analysis.variables).flatMap((a) => a.map((v) => String(v)))));
|
|
5422
5412
|
}
|
|
5423
5413
|
/** Return an array of all variables, each as an array of properties/segments. */
|
|
5424
|
-
async variableSegments(template2,
|
|
5425
|
-
const analysis = await analyze(isString(template2) ? this.parse(template2) : template2,
|
|
5414
|
+
async variableSegments(template2, options = {}) {
|
|
5415
|
+
const analysis = await analyze(isString(template2) ? this.parse(template2) : template2, options);
|
|
5426
5416
|
return Array.from(strictUniq(Object.values(analysis.variables).flatMap((a) => a.map((v) => v.toArray()))));
|
|
5427
5417
|
}
|
|
5428
5418
|
/** Return an array of all variables, each as an array of properties/segments. */
|
|
5429
|
-
variableSegmentsSync(template2,
|
|
5430
|
-
const analysis = analyzeSync(isString(template2) ? this.parse(template2) : template2,
|
|
5419
|
+
variableSegmentsSync(template2, options = {}) {
|
|
5420
|
+
const analysis = analyzeSync(isString(template2) ? this.parse(template2) : template2, options);
|
|
5431
5421
|
return Array.from(strictUniq(Object.values(analysis.variables).flatMap((a) => a.map((v) => v.toArray()))));
|
|
5432
5422
|
}
|
|
5433
5423
|
/** Return an array of all expected context variables without their properties. */
|
|
5434
|
-
async globalVariables(template2,
|
|
5435
|
-
const analysis = await analyze(isString(template2) ? this.parse(template2) : template2,
|
|
5424
|
+
async globalVariables(template2, options = {}) {
|
|
5425
|
+
const analysis = await analyze(isString(template2) ? this.parse(template2) : template2, options);
|
|
5436
5426
|
return Object.keys(analysis.globals);
|
|
5437
5427
|
}
|
|
5438
5428
|
/** Return an array of all expected context variables without their properties. */
|
|
5439
|
-
globalVariablesSync(template2,
|
|
5440
|
-
const analysis = analyzeSync(isString(template2) ? this.parse(template2) : template2,
|
|
5429
|
+
globalVariablesSync(template2, options = {}) {
|
|
5430
|
+
const analysis = analyzeSync(isString(template2) ? this.parse(template2) : template2, options);
|
|
5441
5431
|
return Object.keys(analysis.globals);
|
|
5442
5432
|
}
|
|
5443
5433
|
/** Return an array of all expected context variables including their properties/paths. */
|
|
5444
|
-
async globalFullVariables(template2,
|
|
5445
|
-
const analysis = await analyze(isString(template2) ? this.parse(template2) : template2,
|
|
5434
|
+
async globalFullVariables(template2, options = {}) {
|
|
5435
|
+
const analysis = await analyze(isString(template2) ? this.parse(template2) : template2, options);
|
|
5446
5436
|
return Array.from(new Set(Object.values(analysis.globals).flatMap((a) => a.map((v) => String(v)))));
|
|
5447
5437
|
}
|
|
5448
5438
|
/** Return an array of all expected context variables including their properties/paths. */
|
|
5449
|
-
globalFullVariablesSync(template2,
|
|
5450
|
-
const analysis = analyzeSync(isString(template2) ? this.parse(template2) : template2,
|
|
5439
|
+
globalFullVariablesSync(template2, options = {}) {
|
|
5440
|
+
const analysis = analyzeSync(isString(template2) ? this.parse(template2) : template2, options);
|
|
5451
5441
|
return Array.from(new Set(Object.values(analysis.globals).flatMap((a) => a.map((v) => String(v)))));
|
|
5452
5442
|
}
|
|
5453
5443
|
/** Return an array of all expected context variables, each as an array of properties/segments. */
|
|
5454
|
-
async globalVariableSegments(template2,
|
|
5455
|
-
const analysis = await analyze(isString(template2) ? this.parse(template2) : template2,
|
|
5444
|
+
async globalVariableSegments(template2, options = {}) {
|
|
5445
|
+
const analysis = await analyze(isString(template2) ? this.parse(template2) : template2, options);
|
|
5456
5446
|
return Array.from(strictUniq(Object.values(analysis.globals).flatMap((a) => a.map((v) => v.toArray()))));
|
|
5457
5447
|
}
|
|
5458
5448
|
/** Return an array of all expected context variables, each as an array of properties/segments. */
|
|
5459
|
-
globalVariableSegmentsSync(template2,
|
|
5460
|
-
const analysis = analyzeSync(isString(template2) ? this.parse(template2) : template2,
|
|
5449
|
+
globalVariableSegmentsSync(template2, options = {}) {
|
|
5450
|
+
const analysis = analyzeSync(isString(template2) ? this.parse(template2) : template2, options);
|
|
5461
5451
|
return Array.from(strictUniq(Object.values(analysis.globals).flatMap((a) => a.map((v) => v.toArray()))));
|
|
5462
5452
|
}
|
|
5463
5453
|
};
|
|
@@ -5495,7 +5485,7 @@ var require_liquid_node = __commonJS({
|
|
|
5495
5485
|
exports.RenderError = RenderError;
|
|
5496
5486
|
exports.RenderTag = RenderTag;
|
|
5497
5487
|
exports.TablerowTag = TablerowTag;
|
|
5498
|
-
exports.Tag =
|
|
5488
|
+
exports.Tag = Tag3;
|
|
5499
5489
|
exports.TagToken = TagToken;
|
|
5500
5490
|
exports.Token = Token;
|
|
5501
5491
|
exports.TokenizationError = TokenizationError;
|
|
@@ -5525,11 +5515,11 @@ var require_liquid_node = __commonJS({
|
|
|
5525
5515
|
}
|
|
5526
5516
|
});
|
|
5527
5517
|
|
|
5528
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5529
|
-
import { chmodSync, constants, copyFileSync, existsSync as
|
|
5530
|
-
import { dirname as
|
|
5518
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/cli/messenger/store-maintenance-command.js
|
|
5519
|
+
import { chmodSync, constants, copyFileSync, existsSync as existsSync10, mkdirSync, realpathSync as realpathSync3, renameSync as renameSync3, rmSync as rmSync3, statfsSync as statfsSync2, statSync as statSync4, writeFileSync as writeFileSync2 } from "node:fs";
|
|
5520
|
+
import { dirname as dirname3, resolve } from "node:path";
|
|
5531
5521
|
|
|
5532
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5522
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/sealed.js
|
|
5533
5523
|
import { createCipheriv, createDecipheriv, createHash, randomBytes, scrypt, timingSafeEqual } from "node:crypto";
|
|
5534
5524
|
import { closeSync, createReadStream, createWriteStream, existsSync, openSync, readSync, renameSync, rmSync, statSync } from "node:fs";
|
|
5535
5525
|
import { Transform } from "node:stream";
|
|
@@ -5636,7 +5626,7 @@ var unsealFile = /* @__PURE__ */ __name(async (from, to, password) => {
|
|
|
5636
5626
|
renameSync(pending, to);
|
|
5637
5627
|
}, "unsealFile");
|
|
5638
5628
|
|
|
5639
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5629
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/store/compatibility.js
|
|
5640
5630
|
var SPEAKS = MIGRATIONS.at(-1)?.version ?? 0;
|
|
5641
5631
|
var fileSchemaOf = /* @__PURE__ */ __name((database) => {
|
|
5642
5632
|
const tracked = database.prepare("SELECT 1 FROM sqlite_master WHERE name = 'schema_migrations'").get();
|
|
@@ -5660,7 +5650,7 @@ var compatibilityOf = /* @__PURE__ */ __name((file2, migrations = MIGRATIONS) =>
|
|
|
5660
5650
|
};
|
|
5661
5651
|
}, "compatibilityOf");
|
|
5662
5652
|
|
|
5663
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5653
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/store/repair.js
|
|
5664
5654
|
import { createHash as createHash2 } from "node:crypto";
|
|
5665
5655
|
var COPY_MARK = "__repair_";
|
|
5666
5656
|
var COPY_NAME = /__repair_[0-9a-f]{8}(_\d+)?$/;
|
|
@@ -5914,17 +5904,99 @@ var deleteCopy = /* @__PURE__ */ __name((database, name) => {
|
|
|
5914
5904
|
return found;
|
|
5915
5905
|
}, "deleteCopy");
|
|
5916
5906
|
|
|
5917
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5907
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/cli/store-info.js
|
|
5918
5908
|
import { existsSync as existsSync4, statSync as statSync3 } from "node:fs";
|
|
5919
5909
|
|
|
5920
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5910
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/cli/store-recover.js
|
|
5921
5911
|
import { existsSync as existsSync3 } from "node:fs";
|
|
5922
5912
|
|
|
5923
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5913
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/store/recover.js
|
|
5924
5914
|
import { execFileSync, spawn } from "node:child_process";
|
|
5925
5915
|
import { existsSync as existsSync2, readFileSync, realpathSync, renameSync as renameSync2, rmSync as rmSync2, statfsSync, statSync as statSync2, writeFileSync } from "node:fs";
|
|
5926
5916
|
import { basename, dirname, join } from "node:path";
|
|
5927
5917
|
import { Transform as Transform2 } from "node:stream";
|
|
5918
|
+
|
|
5919
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/store/refill.js
|
|
5920
|
+
var REFILL_MARGIN_MS = 864e5;
|
|
5921
|
+
var TIME_KEYS = 1e12;
|
|
5922
|
+
var integerId = `external_id GLOB '[0-9]*' AND NOT external_id GLOB '*[^0-9]*'`;
|
|
5923
|
+
var forgetCoverageSince = /* @__PURE__ */ __name((database, cutoff, now = Date.now()) => {
|
|
5924
|
+
database.exec("BEGIN");
|
|
5925
|
+
try {
|
|
5926
|
+
const refetch = forget(database, cutoff, now);
|
|
5927
|
+
database.exec("COMMIT");
|
|
5928
|
+
return refetch;
|
|
5929
|
+
} catch (error) {
|
|
5930
|
+
database.exec("ROLLBACK");
|
|
5931
|
+
throw error;
|
|
5932
|
+
}
|
|
5933
|
+
}, "forgetCoverageSince");
|
|
5934
|
+
var forget = /* @__PURE__ */ __name((database, cutoff, now) => {
|
|
5935
|
+
const chats = /* @__PURE__ */ new Map();
|
|
5936
|
+
const held = database.prepare(`SELECT c.id, c.account_id, c.external_id AS chat, a.provider, a.external_id AS account,
|
|
5937
|
+
max(r.to_key) AS top FROM sync_ranges r JOIN chats c ON c.id = r.chat_id JOIN accounts a ON a.id = c.account_id
|
|
5938
|
+
GROUP BY c.id`).all();
|
|
5939
|
+
for (const row of held) {
|
|
5940
|
+
const chat = Number(row.id);
|
|
5941
|
+
const top = Number(row.top);
|
|
5942
|
+
const keepTo = cutoff === null ? null : top >= TIME_KEYS ? cutoff : database.prepare(`SELECT max(CAST(external_id AS INTEGER)) AS k FROM messages WHERE chat_id = ? AND sent_at < ? AND ${integerId}`).get(chat, cutoff)?.k;
|
|
5943
|
+
if (keepTo !== null && top <= keepTo)
|
|
5944
|
+
continue;
|
|
5945
|
+
if (keepTo === null)
|
|
5946
|
+
database.prepare("DELETE FROM sync_ranges WHERE chat_id = ?").run(chat);
|
|
5947
|
+
else {
|
|
5948
|
+
database.prepare("DELETE FROM sync_ranges WHERE chat_id = ? AND from_key > ?").run(chat, keepTo);
|
|
5949
|
+
database.prepare("UPDATE sync_ranges SET to_key = ?, updated_at = ? WHERE chat_id = ? AND to_key > ?").run(keepTo, now, chat, keepTo);
|
|
5950
|
+
}
|
|
5951
|
+
const account = Number(row.account_id);
|
|
5952
|
+
const external = String(row.chat);
|
|
5953
|
+
database.prepare("DELETE FROM sync_cursors WHERE account_id = ? AND key = ?").run(account, `fetched:${external}`);
|
|
5954
|
+
database.prepare(`DELETE FROM sync_cursors WHERE account_id = ? AND key = ? AND NOT EXISTS
|
|
5955
|
+
(SELECT 1 FROM sync_ranges WHERE chat_id = ? AND from_key <= CAST(sync_cursors.value AS INTEGER))`).run(account, `history_start:${external}`, chat);
|
|
5956
|
+
const key = `${row.provider}\0${row.account}`;
|
|
5957
|
+
const one = chats.get(key) ?? { provider: String(row.provider), account: String(row.account), chats: 0 };
|
|
5958
|
+
one.chats += 1;
|
|
5959
|
+
chats.set(key, one);
|
|
5960
|
+
}
|
|
5961
|
+
return {
|
|
5962
|
+
since: cutoff === null ? null : new Date(cutoff).toISOString(),
|
|
5963
|
+
chats: [...chats.values()],
|
|
5964
|
+
mail: forgetMail(database, cutoff, now)
|
|
5965
|
+
};
|
|
5966
|
+
}, "forget");
|
|
5967
|
+
var forgetMail = /* @__PURE__ */ __name((database, cutoff, now) => {
|
|
5968
|
+
const folders = /* @__PURE__ */ new Map();
|
|
5969
|
+
const points = database.prepare(`SELECT s.account_id, s.key, s.value, a.external_id AS account FROM sync_cursors s
|
|
5970
|
+
JOIN accounts a ON a.id = s.account_id WHERE a.provider = 'email' AND s.key LIKE 'mail_resume:%'`).all();
|
|
5971
|
+
for (const row of points) {
|
|
5972
|
+
let point;
|
|
5973
|
+
try {
|
|
5974
|
+
point = JSON.parse(String(row.value));
|
|
5975
|
+
} catch {
|
|
5976
|
+
continue;
|
|
5977
|
+
}
|
|
5978
|
+
const account = String(row.account);
|
|
5979
|
+
if (!Array.isArray(point.done)) {
|
|
5980
|
+
if (cutoff !== null && Date.parse(point.updatedAt ?? "") < cutoff)
|
|
5981
|
+
continue;
|
|
5982
|
+
database.prepare("DELETE FROM sync_cursors WHERE account_id = ? AND key = ?").run(Number(row.account_id), String(row.key));
|
|
5983
|
+
folders.set(account, (folders.get(account) ?? 0) + 1);
|
|
5984
|
+
continue;
|
|
5985
|
+
}
|
|
5986
|
+
const folder = String(row.key).slice("mail_resume:".length);
|
|
5987
|
+
const last = cutoff === null ? null : database.prepare(`SELECT max(l.uid) AS uid FROM email_locations l JOIN emails e ON e.id = l.email_id
|
|
5988
|
+
WHERE l.mailbox_id = (SELECT id FROM mailboxes WHERE account_id = ? AND external_id = ?)
|
|
5989
|
+
AND l.uidvalidity = ? AND coalesce(e.received_at, e.sent_at) < ?`).get(Number(row.account_id), folder, point.validity ?? "", cutoff)?.uid;
|
|
5990
|
+
const done = last === null ? [] : point.done.filter(([from]) => from <= last).map(([from, to]) => [from, Math.min(to, last)]);
|
|
5991
|
+
if (JSON.stringify(done) === JSON.stringify(point.done))
|
|
5992
|
+
continue;
|
|
5993
|
+
database.prepare("UPDATE sync_cursors SET value = ?, updated_at = ? WHERE account_id = ? AND key = ?").run(JSON.stringify({ ...point, done }), now, Number(row.account_id), String(row.key));
|
|
5994
|
+
folders.set(account, (folders.get(account) ?? 0) + 1);
|
|
5995
|
+
}
|
|
5996
|
+
return [...folders].map(([account, count3]) => ({ account, folders: count3 }));
|
|
5997
|
+
}, "forgetMail");
|
|
5998
|
+
|
|
5999
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/store/recover.js
|
|
5928
6000
|
var SQLITE3_MINIMUM = [3, 43, 0];
|
|
5929
6001
|
var STORE_PARTS = ["", "-wal", "-shm"];
|
|
5930
6002
|
var RECOVER_LOCK = ".recover-lock";
|
|
@@ -6019,9 +6091,12 @@ var storeHolders = /* @__PURE__ */ __name((path) => {
|
|
|
6019
6091
|
return { pid, name };
|
|
6020
6092
|
});
|
|
6021
6093
|
}, "storeHolders");
|
|
6022
|
-
var
|
|
6094
|
+
var dataTables = /* @__PURE__ */ __name((database) => {
|
|
6023
6095
|
const indexes = fts5Tables(database).map((index) => index.name);
|
|
6024
|
-
|
|
6096
|
+
return database.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND rootpage > 0 AND name NOT LIKE 'sqlite_%' AND name NOT LIKE 'vector_index_%' ORDER BY name").all().map((row) => String(row.name)).filter((name) => !indexes.some((index) => name.startsWith(`${index}_`)));
|
|
6097
|
+
}, "dataTables");
|
|
6098
|
+
var tableRows = /* @__PURE__ */ __name((database) => {
|
|
6099
|
+
const tables = dataTables(database);
|
|
6025
6100
|
return Object.fromEntries(tables.map((table) => {
|
|
6026
6101
|
try {
|
|
6027
6102
|
return [table, Number(database.prepare(`SELECT count(*) AS n FROM "${table}"`).get()?.n)];
|
|
@@ -6030,6 +6105,117 @@ var tableRows = /* @__PURE__ */ __name((database) => {
|
|
|
6030
6105
|
}
|
|
6031
6106
|
}));
|
|
6032
6107
|
}, "tableRows");
|
|
6108
|
+
var sourceTables = /* @__PURE__ */ __name((database) => {
|
|
6109
|
+
const withoutRowid = new Set(database.prepare("SELECT name FROM pragma_table_list WHERE wr = 1").all().map((row) => String(row.name)));
|
|
6110
|
+
return dataTables(database).filter((table) => table !== LOST_AND_FOUND && !withoutRowid.has(table) && !isDerivedTable(table));
|
|
6111
|
+
}, "sourceTables");
|
|
6112
|
+
var indexedButGone = /* @__PURE__ */ __name((database) => {
|
|
6113
|
+
const found = {};
|
|
6114
|
+
for (const table of sourceTables(database)) {
|
|
6115
|
+
const indexes = database.prepare("SELECT name FROM pragma_index_list(?) WHERE partial = 0 ORDER BY name").all(table).map((row) => String(row.name));
|
|
6116
|
+
for (const index of indexes) {
|
|
6117
|
+
const columns = database.prepare("SELECT cid, name FROM pragma_index_xinfo(?) WHERE key = 1 ORDER BY seqno").all(index);
|
|
6118
|
+
if (columns.some((column) => Number(column.cid) < 0))
|
|
6119
|
+
continue;
|
|
6120
|
+
const keys = columns.map((column) => `"${String(column.name)}"`).join(", ");
|
|
6121
|
+
const grouped = `${keys}, row_id`;
|
|
6122
|
+
let rows;
|
|
6123
|
+
try {
|
|
6124
|
+
rows = Number(database.prepare(`SELECT count(*) AS n FROM (SELECT 1 FROM (SELECT ${keys}, rowid AS row_id, 1 AS side FROM "${table}" INDEXED BY "${index}" UNION ALL SELECT ${keys}, rowid, 2 FROM "${table}" NOT INDEXED) GROUP BY ${grouped} HAVING max(side) = 1)`).get()?.n);
|
|
6125
|
+
} catch {
|
|
6126
|
+
continue;
|
|
6127
|
+
}
|
|
6128
|
+
if (rows > (found[table]?.rows ?? 0))
|
|
6129
|
+
found[table] = { rows, index };
|
|
6130
|
+
}
|
|
6131
|
+
}
|
|
6132
|
+
return found;
|
|
6133
|
+
}, "indexedButGone");
|
|
6134
|
+
var storedAs = /* @__PURE__ */ __name((declared) => {
|
|
6135
|
+
const type = declared.toUpperCase();
|
|
6136
|
+
if (type.includes("INT"))
|
|
6137
|
+
return ["integer"];
|
|
6138
|
+
if (/CHAR|CLOB|TEXT/.test(type))
|
|
6139
|
+
return ["text"];
|
|
6140
|
+
if (type === "" || type.includes("BLOB"))
|
|
6141
|
+
return null;
|
|
6142
|
+
if (/REAL|FLOA|DOUB/.test(type))
|
|
6143
|
+
return ["real", "integer"];
|
|
6144
|
+
return null;
|
|
6145
|
+
}, "storedAs");
|
|
6146
|
+
var columnsOf = /* @__PURE__ */ __name((database, table) => {
|
|
6147
|
+
const all = database.prepare('SELECT name, type, "notnull" AS required, dflt_value, pk FROM pragma_table_info(?)').all(table);
|
|
6148
|
+
const keys = all.filter((column) => Number(column.pk) > 0);
|
|
6149
|
+
return all.map((column) => ({
|
|
6150
|
+
name: String(column.name),
|
|
6151
|
+
type: String(column.type),
|
|
6152
|
+
required: Number(column.required) === 1,
|
|
6153
|
+
hasDefault: column.dflt_value !== null,
|
|
6154
|
+
rowid: keys.length === 1 && Number(column.pk) === 1 && String(column.type).toUpperCase() === "INTEGER"
|
|
6155
|
+
}));
|
|
6156
|
+
}, "columnsOf");
|
|
6157
|
+
var fits = /* @__PURE__ */ __name((columns, fields, types) => fields <= columns.length && columns.every((column, at) => {
|
|
6158
|
+
if (at >= fields)
|
|
6159
|
+
return !column.required || column.hasDefault;
|
|
6160
|
+
const type = types[at];
|
|
6161
|
+
if (column.rowid)
|
|
6162
|
+
return type === "null" || type === "integer";
|
|
6163
|
+
if (type === "null")
|
|
6164
|
+
return !column.required;
|
|
6165
|
+
const allowed = storedAs(column.type);
|
|
6166
|
+
return allowed === null || allowed.includes(type);
|
|
6167
|
+
}), "fits");
|
|
6168
|
+
var placeLostRows = /* @__PURE__ */ __name((database) => {
|
|
6169
|
+
if (!database.prepare("SELECT 1 FROM sqlite_master WHERE name = ?").get(LOST_AND_FOUND))
|
|
6170
|
+
return {};
|
|
6171
|
+
const fields = database.prepare("SELECT name FROM pragma_table_info(?) WHERE name GLOB 'c[0-9]*'").all(LOST_AND_FOUND).map((row) => String(row.name));
|
|
6172
|
+
const tables = sourceTables(database).map((table) => ({ table, columns: columnsOf(database, table) }));
|
|
6173
|
+
const rows = database.prepare(`SELECT rowid AS at, nfield, ${fields.map((field) => `typeof(${field}) AS "${field}"`).join(", ")} FROM ${LOST_AND_FOUND} WHERE id IS NOT NULL`).all();
|
|
6174
|
+
const placed = {};
|
|
6175
|
+
const triggers = [];
|
|
6176
|
+
const quiet = /* @__PURE__ */ __name((table) => {
|
|
6177
|
+
if (table in placed)
|
|
6178
|
+
return;
|
|
6179
|
+
placed[table] = 0;
|
|
6180
|
+
for (const row of database.prepare("SELECT name, sql FROM sqlite_master WHERE type = 'trigger' AND tbl_name = ?").all(table)) {
|
|
6181
|
+
triggers.push(String(row.sql));
|
|
6182
|
+
database.exec(`DROP TRIGGER "${String(row.name)}"`);
|
|
6183
|
+
}
|
|
6184
|
+
}, "quiet");
|
|
6185
|
+
database.exec("PRAGMA foreign_keys = OFF");
|
|
6186
|
+
database.exec("BEGIN");
|
|
6187
|
+
try {
|
|
6188
|
+
for (const row of rows) {
|
|
6189
|
+
const count3 = Number(row.nfield);
|
|
6190
|
+
const types = fields.slice(0, count3).map((field) => String(row[field]));
|
|
6191
|
+
const fitting = tables.filter(({ columns: columns2 }) => fits(columns2, count3, types));
|
|
6192
|
+
if (fitting.length !== 1)
|
|
6193
|
+
continue;
|
|
6194
|
+
const { table, columns } = fitting[0];
|
|
6195
|
+
quiet(table);
|
|
6196
|
+
const given = columns.slice(0, count3);
|
|
6197
|
+
const names = [...given.some((column) => column.rowid) ? [] : ["rowid"], ...given.map((column) => column.name)];
|
|
6198
|
+
const values = [
|
|
6199
|
+
...given.some((column) => column.rowid) ? [] : ["id"],
|
|
6200
|
+
...given.map((column, at) => column.rowid ? "id" : `c${at}`)
|
|
6201
|
+
];
|
|
6202
|
+
const inserted = database.prepare(`INSERT OR IGNORE INTO "${table}" (${names.map((name) => `"${name}"`).join(", ")}) SELECT ${values.join(", ")} FROM ${LOST_AND_FOUND} WHERE rowid = ?`).run(Number(row.at));
|
|
6203
|
+
if (Number(inserted.changes) === 0)
|
|
6204
|
+
continue;
|
|
6205
|
+
placed[table] = (placed[table] ?? 0) + 1;
|
|
6206
|
+
database.prepare(`DELETE FROM ${LOST_AND_FOUND} WHERE rowid = ?`).run(Number(row.at));
|
|
6207
|
+
}
|
|
6208
|
+
for (const sql of triggers)
|
|
6209
|
+
database.exec(sql);
|
|
6210
|
+
database.exec("COMMIT");
|
|
6211
|
+
} catch (error) {
|
|
6212
|
+
database.exec("ROLLBACK");
|
|
6213
|
+
throw error;
|
|
6214
|
+
} finally {
|
|
6215
|
+
database.exec("PRAGMA foreign_keys = ON");
|
|
6216
|
+
}
|
|
6217
|
+
return Object.fromEntries(Object.entries(placed).filter(([, rows2]) => rows2 > 0));
|
|
6218
|
+
}, "placeLostRows");
|
|
6033
6219
|
var copyReadableRows = /* @__PURE__ */ __name((path, target, program = "sqlite3") => new Promise((resolve2, reject) => {
|
|
6034
6220
|
const reader = spawn(program, ["-readonly", path, `.recover --ignore-freelist --lost-and-found ${LOST_AND_FOUND}`], {
|
|
6035
6221
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -6226,6 +6412,9 @@ var recoverLocked = /* @__PURE__ */ __name(async ({ path, command, version, sqli
|
|
|
6226
6412
|
throw error;
|
|
6227
6413
|
throw new CliError("configuration_error", "the store file's header or schema is damaged, so its tables cannot be listed and it cannot be recovered; the file was left as it was", { reason: "store.unreadable" });
|
|
6228
6414
|
}
|
|
6415
|
+
note("looking for rows the indexes list and the tables no longer hold");
|
|
6416
|
+
const gone = indexedButGone(watch);
|
|
6417
|
+
const lastKnownGood = readHealthMark(path)?.last_ok_at ?? null;
|
|
6229
6418
|
const before = { data: dataVersion(), inode: statSync2(path).ino };
|
|
6230
6419
|
const stamp = new Date(now()).toISOString().replace(/[:.]/g, "-");
|
|
6231
6420
|
const target = `${path}.recovering-${stamp}`;
|
|
@@ -6252,9 +6441,12 @@ var recoverLocked = /* @__PURE__ */ __name(async ({ path, command, version, sqli
|
|
|
6252
6441
|
let kept;
|
|
6253
6442
|
let dangling;
|
|
6254
6443
|
let json;
|
|
6255
|
-
let
|
|
6444
|
+
let fetch;
|
|
6256
6445
|
let schema;
|
|
6446
|
+
let placed;
|
|
6447
|
+
let refetch;
|
|
6257
6448
|
try {
|
|
6449
|
+
placed = placeLostRows(opened.database);
|
|
6258
6450
|
kept = tableRows(opened.database);
|
|
6259
6451
|
migrate(opened.database, { command, ...version ? { version } : {} });
|
|
6260
6452
|
note("clearing values that are not valid JSON");
|
|
@@ -6262,7 +6454,9 @@ var recoverLocked = /* @__PURE__ */ __name(async ({ path, command, version, sqli
|
|
|
6262
6454
|
rebuilt = rebuildDerived(opened.database, { now, note });
|
|
6263
6455
|
note("looking for rows that point at rows that were lost");
|
|
6264
6456
|
dangling = danglingRows(opened.database);
|
|
6265
|
-
|
|
6457
|
+
fetch = mailToFetch(opened.database);
|
|
6458
|
+
const good = lastKnownGood === null ? Number.NaN : Date.parse(lastKnownGood);
|
|
6459
|
+
refetch = forgetCoverageSince(opened.database, Number.isNaN(good) ? null : good - REFILL_MARGIN_MS, now());
|
|
6266
6460
|
schema = fileSchemaOf(opened.database).version;
|
|
6267
6461
|
opened.database.exec("PRAGMA wal_checkpoint(TRUNCATE)");
|
|
6268
6462
|
} catch (error) {
|
|
@@ -6292,16 +6486,29 @@ var recoverLocked = /* @__PURE__ */ __name(async ({ path, command, version, sqli
|
|
|
6292
6486
|
if (existsSync2(`${target}${suffix}`))
|
|
6293
6487
|
renameSync2(`${target}${suffix}`, `${path}${suffix}`);
|
|
6294
6488
|
recordDeepCheck(path, health, { cli: command, ...version ? { version } : {}, schema, now });
|
|
6295
|
-
const lost = Object.entries(rowsBefore).map(([table, before2]) =>
|
|
6489
|
+
const lost = Object.entries(rowsBefore).map(([table, before2]) => {
|
|
6490
|
+
const goneAtLeast = Math.max(0, (gone[table]?.rows ?? 0) - (placed[table] ?? 0));
|
|
6491
|
+
return {
|
|
6492
|
+
table,
|
|
6493
|
+
before: before2,
|
|
6494
|
+
read: read[table] ?? 0,
|
|
6495
|
+
kept: kept[table] ?? 0,
|
|
6496
|
+
goneAtLeast,
|
|
6497
|
+
seenIn: goneAtLeast > 0 ? gone[table]?.index ?? null : null
|
|
6498
|
+
};
|
|
6499
|
+
}).filter(({ before: before2, read: read2, kept: kept2, goneAtLeast }) => before2 === null || before2 > kept2 || read2 > kept2 || goneAtLeast > 0);
|
|
6296
6500
|
const seconds = /* @__PURE__ */ __name((from, to) => Math.round((to - from) / 100) / 10, "seconds");
|
|
6297
6501
|
return {
|
|
6298
6502
|
path,
|
|
6299
6503
|
keptAt,
|
|
6300
6504
|
sqlite3: program.version,
|
|
6301
6505
|
lost,
|
|
6506
|
+
placed,
|
|
6507
|
+
lastKnownGood,
|
|
6302
6508
|
dangling,
|
|
6303
6509
|
invalidJson: json,
|
|
6304
|
-
mailToFetch:
|
|
6510
|
+
mailToFetch: fetch,
|
|
6511
|
+
refetch,
|
|
6305
6512
|
rebuilt,
|
|
6306
6513
|
copyErrors,
|
|
6307
6514
|
health,
|
|
@@ -6317,7 +6524,7 @@ var recoverLocked = /* @__PURE__ */ __name(async ({ path, command, version, sqli
|
|
|
6317
6524
|
}
|
|
6318
6525
|
}, "recoverLocked");
|
|
6319
6526
|
|
|
6320
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6527
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/cli/store-recover.js
|
|
6321
6528
|
var COUNTED = [
|
|
6322
6529
|
"accounts",
|
|
6323
6530
|
"chats",
|
|
@@ -6350,18 +6557,23 @@ var storeRecoveryCheck = /* @__PURE__ */ __name(async (env, command, version) =>
|
|
|
6350
6557
|
}
|
|
6351
6558
|
} catch {
|
|
6352
6559
|
}
|
|
6560
|
+
const journal = readJournalMark(path);
|
|
6353
6561
|
recordDeepCheck(path, health, { cli: command, ...version ? { version } : {}, schema });
|
|
6354
6562
|
const mark = readDamageMark(path);
|
|
6355
|
-
const
|
|
6563
|
+
const lastKnownGood = readHealthMark(path)?.last_ok_at ?? null;
|
|
6356
6564
|
const inUse = storeHolders(path) ?? null;
|
|
6357
6565
|
const timers = activeTimers() ?? null;
|
|
6358
6566
|
const sqlite3 = sqlite3Program();
|
|
6359
|
-
const
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
|
|
6567
|
+
const report = storeDamageReport({
|
|
6568
|
+
health,
|
|
6569
|
+
command,
|
|
6570
|
+
mark,
|
|
6571
|
+
journal,
|
|
6572
|
+
lastOkAt: lastKnownGood,
|
|
6573
|
+
holders: inUse,
|
|
6574
|
+
timers,
|
|
6575
|
+
sqlite3Usable: sqlite3.usable
|
|
6576
|
+
});
|
|
6365
6577
|
return {
|
|
6366
6578
|
path,
|
|
6367
6579
|
exists: true,
|
|
@@ -6372,13 +6584,13 @@ var storeRecoveryCheck = /* @__PURE__ */ __name(async (env, command, version) =>
|
|
|
6372
6584
|
damagedSearchIndexes: (health.searchIndexes ?? []).filter((index) => !index.ok).map(({ name, error }) => ({ name, ...error ? { error } : {} })),
|
|
6373
6585
|
invalidJson: health.invalidJson ?? [],
|
|
6374
6586
|
rows,
|
|
6375
|
-
|
|
6587
|
+
report,
|
|
6376
6588
|
damageMark: mark ? (({ inode: _, ...seen }) => seen)(mark) : null,
|
|
6377
|
-
lastKnownGood
|
|
6589
|
+
lastKnownGood,
|
|
6378
6590
|
inUse,
|
|
6379
6591
|
timers,
|
|
6380
6592
|
sqlite3: { version: sqlite3.version, usable: sqlite3.usable },
|
|
6381
|
-
next
|
|
6593
|
+
next: report?.steps.map((step) => step.command) ?? []
|
|
6382
6594
|
};
|
|
6383
6595
|
}, "storeRecoveryCheck");
|
|
6384
6596
|
var storeRecoveryRun = /* @__PURE__ */ __name(async (env, { command, version, note, timers: scheduled = activeTimers, copy }) => {
|
|
@@ -6404,12 +6616,27 @@ var storeRecoveryRun = /* @__PURE__ */ __name(async (env, { command, version, no
|
|
|
6404
6616
|
next: [...mail, ...lostMail, "systemctl --user start <the timers stopped before>"]
|
|
6405
6617
|
};
|
|
6406
6618
|
}, "storeRecoveryRun");
|
|
6619
|
+
var refetchNotes = /* @__PURE__ */ __name(({ since, chats, mail }) => {
|
|
6620
|
+
const from = since === null ? "from the start" : `from ${since} on`;
|
|
6621
|
+
const marked = [
|
|
6622
|
+
...chats.map(({ provider, account, chats: chats2 }) => `${chats2} chats of ${provider} ${account}`),
|
|
6623
|
+
...mail.map(({ account, folders }) => `${folders} mail folders of ${account}`)
|
|
6624
|
+
];
|
|
6625
|
+
return [
|
|
6626
|
+
marked.length > 0 ? `marked as not fetched ${from}, so the next sync or serve fetches it again: ${marked.join(", ")}` : `nothing held ${from} was marked as fetched, so there is nothing to fetch again`,
|
|
6627
|
+
...chats.filter(({ provider }) => provider === "whatsapp").map(({ account }) => `whatsapp ${account}: WhatsApp cannot be asked for its chats, so only what the phone pushes while serve runs comes back`),
|
|
6628
|
+
"notes, memories, tags and whatever else only this store held cannot be fetched again"
|
|
6629
|
+
];
|
|
6630
|
+
}, "refetchNotes");
|
|
6407
6631
|
var recoveryNotes = /* @__PURE__ */ __name((answer) => {
|
|
6408
6632
|
if ("keptAt" in answer) {
|
|
6409
|
-
const lost = answer.lost.map(({ table, before, read, kept }) => `${table}: ${kept} kept of ${before ?? "an uncountable number"}${read > kept ? `, ${read - kept} read but unusable` : ""}`);
|
|
6633
|
+
const lost = answer.lost.map(({ table, before, read, kept, goneAtLeast, seenIn }) => `${table}: ${kept} kept of ${before ?? "an uncountable number"}${read > kept ? `, ${read - kept} read but unusable` : ""}` + (goneAtLeast > 0 ? `; at least ${goneAtLeast} rows are gone (the index ${seenIn} lists them)` : ""));
|
|
6410
6634
|
return [
|
|
6411
6635
|
`recovered in ${answer.seconds.total} s; the damaged file is kept at ${answer.keptAt}`,
|
|
6412
|
-
...lost
|
|
6636
|
+
...lost,
|
|
6637
|
+
...Object.entries(answer.placed).map(([table, rows]) => `${table}: ${rows} rows found on pages no table claimed were put back`),
|
|
6638
|
+
...refetchNotes(answer.refetch),
|
|
6639
|
+
lossUnknown(answer.lastKnownGood, lost.some((line) => line.includes("are gone"))),
|
|
6413
6640
|
...answer.dangling.map(({ table, parent, rows }) => `${rows} rows of ${table} point at ${parent} rows the store does not hold`),
|
|
6414
6641
|
...answer.invalidJson.map(({ table, column, rows, required }) => `${table}.${column}: ${rows} values were not valid JSON \u2014 ${required ? "those rows were dropped" : "set to empty"}`),
|
|
6415
6642
|
...answer.next.map((line) => `next: ${line}`)
|
|
@@ -6417,13 +6644,16 @@ var recoveryNotes = /* @__PURE__ */ __name((answer) => {
|
|
|
6417
6644
|
}
|
|
6418
6645
|
if (!answer.exists)
|
|
6419
6646
|
return ["no store yet"];
|
|
6420
|
-
|
|
6647
|
+
const report = answer.report;
|
|
6648
|
+
if (!report)
|
|
6421
6649
|
return [`the store is healthy (checked every page and search index in ${answer.seconds} s)`];
|
|
6422
|
-
const why = answer.explanation;
|
|
6423
6650
|
return [
|
|
6424
|
-
|
|
6425
|
-
|
|
6426
|
-
|
|
6651
|
+
report.whatHappened,
|
|
6652
|
+
...report.impact,
|
|
6653
|
+
report.externalDataSafe,
|
|
6654
|
+
report.loss,
|
|
6655
|
+
...report.likelyCauses.map(({ cause, check: check2 }) => `maybe: ${cause} \u2014 check: ${check2}`),
|
|
6656
|
+
...report.steps.map(({ command, why, destructive }) => `next: ${command} # ${destructive ? "changes things: " : ""}${why}`)
|
|
6427
6657
|
];
|
|
6428
6658
|
}, "recoveryNotes");
|
|
6429
6659
|
var storeRecoverCommand = /* @__PURE__ */ __name(({ command, version }) => {
|
|
@@ -6450,7 +6680,7 @@ var storeRecoverCommand = /* @__PURE__ */ __name(({ command, version }) => {
|
|
|
6450
6680
|
return recover;
|
|
6451
6681
|
}, "storeRecoverCommand");
|
|
6452
6682
|
|
|
6453
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6683
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/cli/store-info.js
|
|
6454
6684
|
var pendingIfKnown = /* @__PURE__ */ __name((database) => database.prepare("SELECT 1 FROM pragma_table_info('messages') WHERE name = 'normalized_text'").get() ? pendingNormalization(database) : null, "pendingIfKnown");
|
|
6455
6685
|
var bytesOf = /* @__PURE__ */ __name((path) => existsSync4(path) ? statSync3(path).size : 0, "bytesOf");
|
|
6456
6686
|
var messageOf = /* @__PURE__ */ __name((error) => error instanceof Error ? error.message : String(error), "messageOf");
|
|
@@ -6496,7 +6726,7 @@ var storeInfoCommand = /* @__PURE__ */ __name(() => annotate(new Command("info")
|
|
|
6496
6726
|
renderAnswer(this, outputFor(this), itemOf(answer));
|
|
6497
6727
|
}), "storeInfoCommand");
|
|
6498
6728
|
|
|
6499
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6729
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/cli/messenger/password.js
|
|
6500
6730
|
var ENCRYPT_OPTION = [
|
|
6501
6731
|
"--encrypt",
|
|
6502
6732
|
"compress and encrypt with a password, typed at a hidden prompt or piped on stdin; it is never kept \u2014 lose it and the file cannot be opened"
|
|
@@ -6515,7 +6745,7 @@ var passwordOf = /* @__PURE__ */ __name(async (command, { twice }) => {
|
|
|
6515
6745
|
return password;
|
|
6516
6746
|
}, "passwordOf");
|
|
6517
6747
|
|
|
6518
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6748
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/replies/rules.js
|
|
6519
6749
|
import { existsSync as existsSync5, readFileSync as readFileSync2 } from "node:fs";
|
|
6520
6750
|
import { join as join2 } from "node:path";
|
|
6521
6751
|
var REPLY_ACTIONS = ["reply", "task"];
|
|
@@ -6686,7 +6916,7 @@ var problem = /* @__PURE__ */ __name((issue) => {
|
|
|
6686
6916
|
}, "problem");
|
|
6687
6917
|
var broken = /* @__PURE__ */ __name((path, why) => new CliError("configuration_error", `the reply rules ${path} cannot be read (${why}) \u2014 fix the file`), "broken");
|
|
6688
6918
|
|
|
6689
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6919
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/replies/state.js
|
|
6690
6920
|
import { existsSync as existsSync6, readFileSync as readFileSync3 } from "node:fs";
|
|
6691
6921
|
import { join as join3 } from "node:path";
|
|
6692
6922
|
var ANSWERED_KEPT = 1e3;
|
|
@@ -6739,7 +6969,7 @@ var recordReply = /* @__PURE__ */ __name((state, rule2, message, now) => {
|
|
|
6739
6969
|
}, "recordReply");
|
|
6740
6970
|
var broken2 = /* @__PURE__ */ __name((path, why) => new CliError("configuration_error", `the reply state ${path} cannot be read (${why}) \u2014 fix or move the file`), "broken");
|
|
6741
6971
|
|
|
6742
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6972
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/replies/decide.js
|
|
6743
6973
|
var skip = /* @__PURE__ */ __name((why) => ({ skip: why }), "skip");
|
|
6744
6974
|
var decide = /* @__PURE__ */ __name((rule2, incoming, state, now) => {
|
|
6745
6975
|
const { message, chat, owner, sender } = incoming;
|
|
@@ -6845,8 +7075,37 @@ var filled = /* @__PURE__ */ __name((template2, senderName) => {
|
|
|
6845
7075
|
return template2.replaceAll("{firstName}", name.split(/\s+/)[0] ?? name).replaceAll("{name}", name);
|
|
6846
7076
|
}, "filled");
|
|
6847
7077
|
|
|
6848
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7078
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/replies/template.js
|
|
7079
|
+
var import_liquidjs2 = __toESM(require_liquid_node(), 1);
|
|
7080
|
+
|
|
7081
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/render/liquid.js
|
|
6849
7082
|
var import_liquidjs = __toESM(require_liquid_node(), 1);
|
|
7083
|
+
var safeLiquid = /* @__PURE__ */ __name((limits) => {
|
|
7084
|
+
const engine = new import_liquidjs.Liquid({
|
|
7085
|
+
ownPropertyOnly: true,
|
|
7086
|
+
strictVariables: true,
|
|
7087
|
+
strictFilters: true,
|
|
7088
|
+
lenientIf: false,
|
|
7089
|
+
parseLimit: limits.parse,
|
|
7090
|
+
renderLimit: limits.milliseconds,
|
|
7091
|
+
memoryLimit: limits.memory,
|
|
7092
|
+
preserveTimezones: true
|
|
7093
|
+
});
|
|
7094
|
+
for (const name of ["include", "render", "layout"]) {
|
|
7095
|
+
engine.registerTag(name, class extends import_liquidjs.Tag {
|
|
7096
|
+
constructor(token, tokens, liquid) {
|
|
7097
|
+
super(token, tokens, liquid);
|
|
7098
|
+
throw new Error("templates cannot read files");
|
|
7099
|
+
}
|
|
7100
|
+
render() {
|
|
7101
|
+
return "";
|
|
7102
|
+
}
|
|
7103
|
+
});
|
|
7104
|
+
}
|
|
7105
|
+
return engine;
|
|
7106
|
+
}, "safeLiquid");
|
|
7107
|
+
|
|
7108
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/replies/template.js
|
|
6850
7109
|
var TEMPLATE_LIMITS = {
|
|
6851
7110
|
parse: 32768,
|
|
6852
7111
|
renders: 2e3,
|
|
@@ -6900,28 +7159,8 @@ var renderReplyTemplate = /* @__PURE__ */ __name(async (reply, input) => {
|
|
|
6900
7159
|
hourCycle: "h23"
|
|
6901
7160
|
}).formatToParts(input.now).map(({ type, value }) => [type, value]));
|
|
6902
7161
|
const localTime = `${parts2.year}-${parts2.month}-${parts2.day}T${parts2.hour}:${parts2.minute}:${parts2.second}${parts2.timeZoneName?.replace("GMT", "") || "+00:00"}`;
|
|
6903
|
-
const engine =
|
|
6904
|
-
|
|
6905
|
-
strictVariables: true,
|
|
6906
|
-
strictFilters: true,
|
|
6907
|
-
lenientIf: false,
|
|
6908
|
-
parseLimit: limits.parse,
|
|
6909
|
-
renderLimit: limits.milliseconds,
|
|
6910
|
-
memoryLimit: limits.memory,
|
|
6911
|
-
preserveTimezones: true
|
|
6912
|
-
});
|
|
6913
|
-
for (const name2 of ["include", "render", "layout"]) {
|
|
6914
|
-
engine.registerTag(name2, class extends import_liquidjs.Tag {
|
|
6915
|
-
constructor(token, tokens, liquid) {
|
|
6916
|
-
super(token, tokens, liquid);
|
|
6917
|
-
throw new Error("reply templates cannot read files");
|
|
6918
|
-
}
|
|
6919
|
-
render() {
|
|
6920
|
-
return "";
|
|
6921
|
-
}
|
|
6922
|
-
});
|
|
6923
|
-
}
|
|
6924
|
-
engine.registerTag("ai", class extends import_liquidjs.Tag {
|
|
7162
|
+
const engine = safeLiquid({ parse: limits.parse, memory: limits.memory, milliseconds: limits.milliseconds });
|
|
7163
|
+
engine.registerTag("ai", class extends import_liquidjs2.Tag {
|
|
6925
7164
|
body = [];
|
|
6926
7165
|
fallback = null;
|
|
6927
7166
|
constructor(token, tokens, liquid, parser) {
|
|
@@ -6982,7 +7221,7 @@ var renderReplyTemplate = /* @__PURE__ */ __name(async (reply, input) => {
|
|
|
6982
7221
|
});
|
|
6983
7222
|
const templates = engine.parse(source);
|
|
6984
7223
|
const name = input.senderName?.trim() ?? "";
|
|
6985
|
-
const context = new
|
|
7224
|
+
const context = new import_liquidjs2.Context({
|
|
6986
7225
|
sender: { firstName: name.split(/\s+/)[0] ?? "", name },
|
|
6987
7226
|
chat: { title: input.chat.title ?? "", kind: input.chat.kind },
|
|
6988
7227
|
now: localTime
|
|
@@ -7005,7 +7244,7 @@ var renderReplyTemplate = /* @__PURE__ */ __name(async (reply, input) => {
|
|
|
7005
7244
|
}
|
|
7006
7245
|
}, "renderReplyTemplate");
|
|
7007
7246
|
|
|
7008
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7247
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/replies/dry-run.js
|
|
7009
7248
|
var DRY_RUN_DAYS = 7;
|
|
7010
7249
|
var PAGE = 500;
|
|
7011
7250
|
var dryRun = /* @__PURE__ */ __name(async (store, account, rules, { since, until = Date.now(), only, audience, render }) => {
|
|
@@ -7119,143 +7358,7 @@ var storedSince = /* @__PURE__ */ __name(async (store, account, chat, since) =>
|
|
|
7119
7358
|
}
|
|
7120
7359
|
}, "storedSince");
|
|
7121
7360
|
|
|
7122
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7123
|
-
var endpointKeyName = /* @__PURE__ */ __name((baseUrl) => {
|
|
7124
|
-
const host = new URL(baseUrl).host;
|
|
7125
|
-
return ["openai", "anthropic"].includes(host) ? `endpoint:${host}` : host;
|
|
7126
|
-
}, "endpointKeyName");
|
|
7127
|
-
var embeddingKeys = /* @__PURE__ */ __name((app, env = process.env, keyring) => {
|
|
7128
|
-
const where = { appName: app.appName, prefix: app.envPrefix, env };
|
|
7129
|
-
const credentials = /* @__PURE__ */ __name((provider) => new Credentials({
|
|
7130
|
-
configDir: resolvePaths(where).config,
|
|
7131
|
-
service: app.appName,
|
|
7132
|
-
...["openai", "anthropic"].includes(provider) ? { envVar: envName(app, `${provider.toUpperCase()}_API_KEY`) } : {},
|
|
7133
|
-
isolated: pathsAreOverridden(where),
|
|
7134
|
-
env,
|
|
7135
|
-
...keyring ? { keyring } : {},
|
|
7136
|
-
warn: /* @__PURE__ */ __name((message) => process.stderr.write(`${message}
|
|
7137
|
-
`), "warn")
|
|
7138
|
-
}), "credentials");
|
|
7139
|
-
const account = /* @__PURE__ */ __name((provider) => `embeddings:${provider}`, "account");
|
|
7140
|
-
return {
|
|
7141
|
-
read: /* @__PURE__ */ __name((provider) => {
|
|
7142
|
-
const stored = credentials(provider).read(account(provider));
|
|
7143
|
-
if (stored)
|
|
7144
|
-
return { key: stored.secret, source: stored.source };
|
|
7145
|
-
const shared = ["openai", "anthropic"].includes(provider) ? env[`${provider.toUpperCase()}_API_KEY`]?.trim() : void 0;
|
|
7146
|
-
return shared ? { key: shared, source: "env" } : void 0;
|
|
7147
|
-
}, "read"),
|
|
7148
|
-
write: /* @__PURE__ */ __name((provider, key) => credentials(provider).write(account(provider), key, { signIn: true }), "write"),
|
|
7149
|
-
remove: /* @__PURE__ */ __name((provider) => credentials(provider).remove(account(provider)), "remove")
|
|
7150
|
-
};
|
|
7151
|
-
}, "embeddingKeys");
|
|
7152
|
-
|
|
7153
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_835308f42ae01aacd71fad942c0d0dc0/node_modules/@wirecat/cli-core/dist/models/openai.js
|
|
7154
|
-
var options = strictObject({
|
|
7155
|
-
temperature: range(0, 2),
|
|
7156
|
-
top_p: range(0, 1),
|
|
7157
|
-
presence_penalty: range(-2, 2),
|
|
7158
|
-
frequency_penalty: range(-2, 2),
|
|
7159
|
-
seed: optional(pipe(number(), integer())),
|
|
7160
|
-
stop: optional(union([string(), array(string())])),
|
|
7161
|
-
response_format: optional(strictObject({ type: picklist(["text", "json_object"]) }))
|
|
7162
|
-
});
|
|
7163
|
-
var openai = {
|
|
7164
|
-
images: true,
|
|
7165
|
-
baseUrl: "https://api.openai.com/v1",
|
|
7166
|
-
validate: /* @__PURE__ */ __name((given) => checkedOptions("openai", options, given), "validate"),
|
|
7167
|
-
complete: /* @__PURE__ */ __name((target, request, checked, apiKey, fetcher) => withTimeLimit(12e4, async (deadline) => {
|
|
7168
|
-
const response = await fetcher(`${target.baseUrl.replace(/\/+$/, "")}/chat/completions`, {
|
|
7169
|
-
method: "POST",
|
|
7170
|
-
headers: { "Content-Type": "application/json", ...apiKey ? { Authorization: `Bearer ${apiKey}` } : {} },
|
|
7171
|
-
body: JSON.stringify({
|
|
7172
|
-
...checked,
|
|
7173
|
-
model: target.model,
|
|
7174
|
-
messages: [
|
|
7175
|
-
{ role: "system", content: systemFor(request) },
|
|
7176
|
-
...messagesFor(request),
|
|
7177
|
-
...request.images === void 0 ? [] : [
|
|
7178
|
-
{
|
|
7179
|
-
role: "user",
|
|
7180
|
-
content: request.images.map((image) => ({
|
|
7181
|
-
type: "image_url",
|
|
7182
|
-
image_url: { url: `data:${image.mimeType};base64,${image.data}`, detail: "high" }
|
|
7183
|
-
}))
|
|
7184
|
-
}
|
|
7185
|
-
]
|
|
7186
|
-
],
|
|
7187
|
-
...new URL(target.baseUrl).hostname === "api.openai.com" ? { max_completion_tokens: request.maxTokens } : { max_tokens: request.maxTokens }
|
|
7188
|
-
}),
|
|
7189
|
-
signal: deadline,
|
|
7190
|
-
redirect: "error"
|
|
7191
|
-
});
|
|
7192
|
-
if (!response.ok)
|
|
7193
|
-
throw new Error("provider rejected request");
|
|
7194
|
-
const body = await response.json();
|
|
7195
|
-
const choice = body.choices?.[0];
|
|
7196
|
-
if (choice?.finish_reason !== "stop" || typeof choice.message?.content !== "string" || !Number.isInteger(body.usage?.total_tokens) || (body.usage?.total_tokens ?? 0) < 1)
|
|
7197
|
-
throw new Error("incomplete response");
|
|
7198
|
-
return { text: choice.message.content, tokens: body.usage?.total_tokens };
|
|
7199
|
-
}), "complete")
|
|
7200
|
-
};
|
|
7201
|
-
|
|
7202
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_835308f42ae01aacd71fad942c0d0dc0/node_modules/@wirecat/cli-core/dist/models/index.js
|
|
7203
|
-
var modelGateway = /* @__PURE__ */ __name((deps) => ({
|
|
7204
|
-
complete: /* @__PURE__ */ __name(async (request) => {
|
|
7205
|
-
if (deps.signal?.aborted)
|
|
7206
|
-
throw new CliError("cancelled", "model request cancelled");
|
|
7207
|
-
const target = deps.resolve(request.purpose);
|
|
7208
|
-
if (!target || target.provider === "off")
|
|
7209
|
-
throw new CliError("configuration_error", `models.${request.purpose}.provider is not configured; no model was called`);
|
|
7210
|
-
if (!request.purpose || !Number.isSafeInteger(request.maxTokens) || request.maxTokens < 1 || typeof request.prompt !== "string")
|
|
7211
|
-
throw new CliError("validation_error", "a model request needs a purpose, prompt and positive whole maxTokens");
|
|
7212
|
-
validateImages(request.images);
|
|
7213
|
-
let adapter = deps.adapters?.[target.provider];
|
|
7214
|
-
if (!adapter && target.provider === "openai")
|
|
7215
|
-
adapter = openai;
|
|
7216
|
-
if (!adapter && target.provider === "anthropic")
|
|
7217
|
-
adapter = (await import("./anthropic-RGV3WXX5.js")).anthropic;
|
|
7218
|
-
if (!adapter)
|
|
7219
|
-
throw new CliError("validation_error", `no model adapter for ${target.provider}`);
|
|
7220
|
-
if (request.images !== void 0 && adapter.images !== true)
|
|
7221
|
-
throw new CliError("validation_error", "the model adapter does not support image inputs");
|
|
7222
|
-
const options2 = adapter.validate(request.options ?? {});
|
|
7223
|
-
const baseUrl = target.baseUrl ?? adapter.baseUrl;
|
|
7224
|
-
if (!target.model.trim() || !endpoint(baseUrl))
|
|
7225
|
-
throw new CliError("validation_error", "a model target needs a model and an HTTP/S endpoint without credentials, query or fragment");
|
|
7226
|
-
if (!await deps.consent(request, { ...target, baseUrl }))
|
|
7227
|
-
throw new CliError("permission_error", `model consent for ${request.purpose} is missing; no data was sent`);
|
|
7228
|
-
const apiKey = await deps.key?.(target.provider, target);
|
|
7229
|
-
if (deps.signal?.aborted)
|
|
7230
|
-
throw new CliError("cancelled", "model request cancelled");
|
|
7231
|
-
const fetcher = deps.fetch ?? fetch;
|
|
7232
|
-
let limited = false;
|
|
7233
|
-
const cancellable = /* @__PURE__ */ __name(async (input, init) => {
|
|
7234
|
-
const signal = init?.signal ?? (input instanceof Request ? input.signal : void 0);
|
|
7235
|
-
const response = await fetcher(input, {
|
|
7236
|
-
...init,
|
|
7237
|
-
signal: deps.signal ? AbortSignal.any([deps.signal, ...signal ? [signal] : []]) : signal
|
|
7238
|
-
});
|
|
7239
|
-
if (response.status === 429)
|
|
7240
|
-
limited = true;
|
|
7241
|
-
return response;
|
|
7242
|
-
}, "cancellable");
|
|
7243
|
-
try {
|
|
7244
|
-
const answer = await adapter.complete({ ...target, baseUrl }, request, options2, apiKey, cancellable);
|
|
7245
|
-
if (deps.signal?.aborted)
|
|
7246
|
-
throw new Error("cancelled");
|
|
7247
|
-
if (typeof answer.text !== "string" || !Number.isSafeInteger(answer.tokens) || answer.tokens < 1)
|
|
7248
|
-
throw new Error("incomplete");
|
|
7249
|
-
return { ...answer, provider: target.provider, model: target.model };
|
|
7250
|
-
} catch {
|
|
7251
|
-
if (limited)
|
|
7252
|
-
throw new CliError("rate_limited", `${request.purpose} provider rate limit reached; no result was stored`);
|
|
7253
|
-
throw new CliError("invalid_response", `${request.purpose} provider failed or returned an incomplete response; no result was stored`);
|
|
7254
|
-
}
|
|
7255
|
-
}, "complete")
|
|
7256
|
-
}), "modelGateway");
|
|
7257
|
-
|
|
7258
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.9_commander@15.0.0_esbuild@0.28.2_type_835308f42ae01aacd71fad942c0d0dc0/node_modules/@wirecat/cli-core/dist/replies/consents.js
|
|
7361
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/replies/consents.js
|
|
7259
7362
|
import { existsSync as existsSync7, readFileSync as readFileSync4 } from "node:fs";
|
|
7260
7363
|
import { join as join4 } from "node:path";
|
|
7261
7364
|
var shape = strictObject({
|
|
@@ -7280,21 +7383,21 @@ var mayModelReply = /* @__PURE__ */ __name((path, provider, chat) => {
|
|
|
7280
7383
|
return consent.provider === provider && !consent.deniedChats.includes(chat);
|
|
7281
7384
|
}, "mayModelReply");
|
|
7282
7385
|
|
|
7283
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7284
|
-
var replyRenderer = /* @__PURE__ */ __name((app, profile, settings, env, warn,
|
|
7386
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/replies/rendering.js
|
|
7387
|
+
var replyRenderer = /* @__PURE__ */ __name((app, profile, settings, env, warn, options = {
|
|
7285
7388
|
ai: true
|
|
7286
7389
|
}) => async (rule2, message, chat, now) => {
|
|
7287
7390
|
let called;
|
|
7288
7391
|
const gateway = modelGateway({
|
|
7289
|
-
signal:
|
|
7392
|
+
signal: options.signal,
|
|
7290
7393
|
resolve: /* @__PURE__ */ __name((purpose) => {
|
|
7291
7394
|
called = modelTarget(settings(), purpose);
|
|
7292
7395
|
return called;
|
|
7293
7396
|
}, "resolve"),
|
|
7294
7397
|
consent: /* @__PURE__ */ __name((_request, target) => mayModelReply(replyConsentPathFor(app, profile, env), replyModelIdentity(target.provider, target.baseUrl ?? ""), message.chatId), "consent"),
|
|
7295
|
-
key: /* @__PURE__ */ __name((provider, target) => embeddingKeys(app, env,
|
|
7398
|
+
key: /* @__PURE__ */ __name((provider, target) => embeddingKeys(app, env, options.keyring).read(target.baseUrl === void 0 ? provider : endpointKeyName(target.baseUrl))?.key, "key")
|
|
7296
7399
|
});
|
|
7297
|
-
if (
|
|
7400
|
+
if (options.signal?.aborted)
|
|
7298
7401
|
throw new CliError("cancelled", "reply rendering cancelled");
|
|
7299
7402
|
const result2 = await renderReplyTemplate(rule2.reply, {
|
|
7300
7403
|
senderName: message.senderName,
|
|
@@ -7302,8 +7405,8 @@ var replyRenderer = /* @__PURE__ */ __name((app, profile, settings, env, warn, o
|
|
|
7302
7405
|
now,
|
|
7303
7406
|
timezone: rule2.when.hours?.timezone,
|
|
7304
7407
|
data: message.text,
|
|
7305
|
-
allowAI:
|
|
7306
|
-
preview:
|
|
7408
|
+
allowAI: options.ai === true,
|
|
7409
|
+
preview: options.preview === true,
|
|
7307
7410
|
complete: /* @__PURE__ */ __name(async (prompt, data) => {
|
|
7308
7411
|
const result3 = await gateway.complete({
|
|
7309
7412
|
purpose: "replies",
|
|
@@ -7312,7 +7415,7 @@ var replyRenderer = /* @__PURE__ */ __name((app, profile, settings, env, warn, o
|
|
|
7312
7415
|
data,
|
|
7313
7416
|
maxTokens: 512
|
|
7314
7417
|
});
|
|
7315
|
-
if (
|
|
7418
|
+
if (options.signal?.aborted)
|
|
7316
7419
|
throw new CliError("cancelled", "reply rendering cancelled");
|
|
7317
7420
|
const current = modelTarget(settings(), "replies");
|
|
7318
7421
|
const baseUrl = called?.baseUrl ?? (called?.provider === "anthropic" ? "https://api.anthropic.com" : "https://api.openai.com/v1");
|
|
@@ -7327,7 +7430,7 @@ var replyRenderer = /* @__PURE__ */ __name((app, profile, settings, env, warn, o
|
|
|
7327
7430
|
return result2;
|
|
7328
7431
|
}, "replyRenderer");
|
|
7329
7432
|
|
|
7330
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7433
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/replies/serve.js
|
|
7331
7434
|
var NOT_ALLOWED = "replies.send is not allow";
|
|
7332
7435
|
var NO_RULES = "no rules";
|
|
7333
7436
|
var ONLY_TASK = "opened a task, sent nothing";
|
|
@@ -7420,12 +7523,12 @@ var replyTo = /* @__PURE__ */ __name(async (deps, message) => {
|
|
|
7420
7523
|
return { skip: why };
|
|
7421
7524
|
}, "replyTo");
|
|
7422
7525
|
|
|
7423
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7526
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-catch-up.js
|
|
7424
7527
|
var START_SYNC_DELAY_MS = 3e4;
|
|
7425
7528
|
var START_SYNC_BUDGET_MS = 5 * 6e4;
|
|
7426
7529
|
var START_SYNC_WINDOW_MS = 7 * 864e5;
|
|
7427
7530
|
var START_SYNC_PER_CHAT = 500;
|
|
7428
|
-
var startSync = /* @__PURE__ */ __name(({ chats, newestHeld, fetch
|
|
7531
|
+
var startSync = /* @__PURE__ */ __name(({ chats, newestHeld, fetch, note, warn, delayMs = START_SYNC_DELAY_MS, budgetMs = START_SYNC_BUDGET_MS, windowMs = START_SYNC_WINDOW_MS, now = Date.now }) => {
|
|
7429
7532
|
const controller = new AbortController();
|
|
7430
7533
|
let timer;
|
|
7431
7534
|
let pass = Promise.resolve();
|
|
@@ -7453,7 +7556,7 @@ var startSync = /* @__PURE__ */ __name(({ chats, newestHeld, fetch: fetch2, note
|
|
|
7453
7556
|
if (stop.aborted)
|
|
7454
7557
|
break;
|
|
7455
7558
|
try {
|
|
7456
|
-
summary.fetched += (await
|
|
7559
|
+
summary.fetched += (await fetch(chat.id, Math.max(held ?? anywhere, floor), stop)).fetched;
|
|
7457
7560
|
summary.chats += 1;
|
|
7458
7561
|
} catch (error) {
|
|
7459
7562
|
if (stop.aborted)
|
|
@@ -7497,10 +7600,10 @@ var startSync = /* @__PURE__ */ __name(({ chats, newestHeld, fetch: fetch2, note
|
|
|
7497
7600
|
};
|
|
7498
7601
|
}, "startSync");
|
|
7499
7602
|
|
|
7500
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7603
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-members.js
|
|
7501
7604
|
var FIRST_FETCH_MS = 6e4;
|
|
7502
7605
|
var DAY_MS = 864e5;
|
|
7503
|
-
var memberFetches = /* @__PURE__ */ __name(({ withStore, fetch
|
|
7606
|
+
var memberFetches = /* @__PURE__ */ __name(({ withStore, fetch, warn, firstMs = FIRST_FETCH_MS, everyMs = DAY_MS }) => {
|
|
7504
7607
|
let timer;
|
|
7505
7608
|
let round = Promise.resolve();
|
|
7506
7609
|
let stopped = false;
|
|
@@ -7513,7 +7616,7 @@ var memberFetches = /* @__PURE__ */ __name(({ withStore, fetch: fetch2, warn, fi
|
|
|
7513
7616
|
if (lastCount?.day === today)
|
|
7514
7617
|
continue;
|
|
7515
7618
|
try {
|
|
7516
|
-
await
|
|
7619
|
+
await fetch(store, account, chatId);
|
|
7517
7620
|
done.fetched += 1;
|
|
7518
7621
|
} catch (error) {
|
|
7519
7622
|
done.failed += 1;
|
|
@@ -7551,7 +7654,7 @@ var memberFetches = /* @__PURE__ */ __name(({ withStore, fetch: fetch2, warn, fi
|
|
|
7551
7654
|
};
|
|
7552
7655
|
}, "memberFetches");
|
|
7553
7656
|
|
|
7554
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7657
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-notice.js
|
|
7555
7658
|
var record2 = /* @__PURE__ */ __name((context, app, severity, attributes) => recordLogFor(context.streams.diagnostic, app, { command: currentRun().command || "serve" })[severity](attributes), "record");
|
|
7556
7659
|
var noticeFor = /* @__PURE__ */ __name((context, app, severity = "warn") => ({ text, ...attributes }) => {
|
|
7557
7660
|
if (context.format === "pretty") {
|
|
@@ -7584,7 +7687,93 @@ var recordDiagnostics = /* @__PURE__ */ __name((context, app) => {
|
|
|
7584
7687
|
return context;
|
|
7585
7688
|
}, "recordDiagnostics");
|
|
7586
7689
|
|
|
7587
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7690
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-outdated.js
|
|
7691
|
+
import { existsSync as existsSync8, readFileSync as readFileSync5, realpathSync as realpathSync2 } from "node:fs";
|
|
7692
|
+
import { dirname as dirname2, join as join5 } from "node:path";
|
|
7693
|
+
var OUTDATED_CHECK_MS = 6e4;
|
|
7694
|
+
var ownPackageRoot = /* @__PURE__ */ __name((running, script = process.argv[1]) => {
|
|
7695
|
+
let dir;
|
|
7696
|
+
try {
|
|
7697
|
+
dir = dirname2(realpathSync2(script ?? ""));
|
|
7698
|
+
} catch {
|
|
7699
|
+
return void 0;
|
|
7700
|
+
}
|
|
7701
|
+
for (let up = 0; up < 8; up++) {
|
|
7702
|
+
const manifest = join5(dir, "package.json");
|
|
7703
|
+
if (existsSync8(manifest))
|
|
7704
|
+
return installedVersion(dir) === running ? dir : void 0;
|
|
7705
|
+
const parent = dirname2(dir);
|
|
7706
|
+
if (parent === dir)
|
|
7707
|
+
return void 0;
|
|
7708
|
+
dir = parent;
|
|
7709
|
+
}
|
|
7710
|
+
return void 0;
|
|
7711
|
+
}, "ownPackageRoot");
|
|
7712
|
+
var installedVersion = /* @__PURE__ */ __name((root) => {
|
|
7713
|
+
try {
|
|
7714
|
+
const { version } = JSON.parse(readFileSync5(join5(root, "package.json"), "utf8"));
|
|
7715
|
+
return typeof version === "string" ? version : void 0;
|
|
7716
|
+
} catch {
|
|
7717
|
+
return void 0;
|
|
7718
|
+
}
|
|
7719
|
+
}, "installedVersion");
|
|
7720
|
+
var newer = /* @__PURE__ */ __name((one, other) => {
|
|
7721
|
+
const parts2 = /* @__PURE__ */ __name((version) => version.split(/[.+-]/, 3).map(Number), "parts");
|
|
7722
|
+
const [a, b] = [parts2(one), parts2(other)];
|
|
7723
|
+
for (let i = 0; i < 3; i++)
|
|
7724
|
+
if ((a[i] ?? 0) !== (b[i] ?? 0))
|
|
7725
|
+
return (a[i] ?? 0) > (b[i] ?? 0);
|
|
7726
|
+
return false;
|
|
7727
|
+
}, "newer");
|
|
7728
|
+
var outdatedReason = /* @__PURE__ */ __name(async ({ command, running, storePath: storePath2, packageRoot, speaks = SPEAKS }) => {
|
|
7729
|
+
const installed = packageRoot === void 0 ? void 0 : installedVersion(packageRoot);
|
|
7730
|
+
if (installed !== void 0 && newer(installed, running))
|
|
7731
|
+
return `${command} ${installed} is installed and this serve runs ${running}: stopping so it starts again on ${installed}`;
|
|
7732
|
+
if (!existsSync8(storePath2))
|
|
7733
|
+
return void 0;
|
|
7734
|
+
let schema;
|
|
7735
|
+
try {
|
|
7736
|
+
const { database } = await openSqlite(storePath2, { readOnly: true });
|
|
7737
|
+
try {
|
|
7738
|
+
schema = fileSchemaOf(database);
|
|
7739
|
+
} finally {
|
|
7740
|
+
database.close();
|
|
7741
|
+
}
|
|
7742
|
+
} catch {
|
|
7743
|
+
return void 0;
|
|
7744
|
+
}
|
|
7745
|
+
if (writableBy(schema, speaks))
|
|
7746
|
+
return void 0;
|
|
7747
|
+
return `the store is at format ${schema.version} and needs at least ${schema.minCompatible}; this serve (${command} ${running}) speaks ${speaks} and can no longer write it: stopping \u2014 \`${command} upgrade\` if it does not start again on a newer version`;
|
|
7748
|
+
}, "outdatedReason");
|
|
7749
|
+
var watchOutdated = /* @__PURE__ */ __name(({ check: check2, onOutdated, everyMs = OUTDATED_CHECK_MS }) => {
|
|
7750
|
+
let busy = false;
|
|
7751
|
+
let done = false;
|
|
7752
|
+
const timer = setInterval(() => {
|
|
7753
|
+
if (busy || done)
|
|
7754
|
+
return;
|
|
7755
|
+
busy = true;
|
|
7756
|
+
check2().then((reason) => {
|
|
7757
|
+
if (reason === void 0 || done)
|
|
7758
|
+
return;
|
|
7759
|
+
done = true;
|
|
7760
|
+
clearInterval(timer);
|
|
7761
|
+
onOutdated(reason);
|
|
7762
|
+
}).catch(() => {
|
|
7763
|
+
}).finally(() => {
|
|
7764
|
+
busy = false;
|
|
7765
|
+
});
|
|
7766
|
+
}, everyMs);
|
|
7767
|
+
timer.unref();
|
|
7768
|
+
return {
|
|
7769
|
+
stop: /* @__PURE__ */ __name(() => {
|
|
7770
|
+
done = true;
|
|
7771
|
+
clearInterval(timer);
|
|
7772
|
+
}, "stop")
|
|
7773
|
+
};
|
|
7774
|
+
}, "watchOutdated");
|
|
7775
|
+
|
|
7776
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-stems.js
|
|
7588
7777
|
var STEMS_EVERY_MS = 3e4;
|
|
7589
7778
|
var STEMS_SLICE_MS = 2e3;
|
|
7590
7779
|
var stemFills = /* @__PURE__ */ __name(({ withStore, warn, everyMs = STEMS_EVERY_MS, sliceMs = STEMS_SLICE_MS }) => {
|
|
@@ -7624,17 +7813,17 @@ var stemFills = /* @__PURE__ */ __name(({ withStore, warn, everyMs = STEMS_EVERY
|
|
|
7624
7813
|
};
|
|
7625
7814
|
}, "stemFills");
|
|
7626
7815
|
|
|
7627
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7816
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/render/messages.js
|
|
7628
7817
|
import { styleText } from "node:util";
|
|
7629
7818
|
var TIME_WIDTH = 8;
|
|
7630
7819
|
var INDENT = " ".repeat(TIME_WIDTH + 2);
|
|
7631
7820
|
var MIN_WIDTH = 40;
|
|
7632
7821
|
var SENDER_COLOURS = ["green", "yellow", "magenta", "blue", "red"];
|
|
7633
|
-
var renderMessages = /* @__PURE__ */ __name((messages,
|
|
7822
|
+
var renderMessages = /* @__PURE__ */ __name((messages, options = {}) => {
|
|
7634
7823
|
if (messages.length === 0)
|
|
7635
7824
|
return "(nothing)";
|
|
7636
|
-
const day = dayFormatter(
|
|
7637
|
-
const paint = painter(
|
|
7825
|
+
const day = dayFormatter(options);
|
|
7826
|
+
const paint = painter(options);
|
|
7638
7827
|
let previous;
|
|
7639
7828
|
const blocks = [];
|
|
7640
7829
|
for (const message of messages) {
|
|
@@ -7642,40 +7831,40 @@ var renderMessages = /* @__PURE__ */ __name((messages, options2 = {}) => {
|
|
|
7642
7831
|
if (date !== previous)
|
|
7643
7832
|
blocks.push(paint("dim", `\u2500\u2500 ${date} \u2500\u2500`));
|
|
7644
7833
|
previous = date;
|
|
7645
|
-
blocks.push(renderMessage(message,
|
|
7834
|
+
blocks.push(renderMessage(message, options));
|
|
7646
7835
|
}
|
|
7647
7836
|
return blocks.join("\n\n");
|
|
7648
7837
|
}, "renderMessages");
|
|
7649
|
-
var renderMessage = /* @__PURE__ */ __name((message,
|
|
7650
|
-
const paint = painter(
|
|
7651
|
-
const width = Math.max(MIN_WIDTH,
|
|
7838
|
+
var renderMessage = /* @__PURE__ */ __name((message, options = {}) => {
|
|
7839
|
+
const paint = painter(options);
|
|
7840
|
+
const width = Math.max(MIN_WIDTH, options.width ?? 80);
|
|
7652
7841
|
const room = width - INDENT.length;
|
|
7653
|
-
const time = timeFormatter(
|
|
7654
|
-
const verbosity =
|
|
7842
|
+
const time = timeFormatter(options);
|
|
7843
|
+
const verbosity = options.verbosity ?? 0;
|
|
7655
7844
|
const chat = "chatTitle" in message ? paint("dim", ` \xB7 ${singleLine(message.chatTitle ?? message.chatId)}`) : "";
|
|
7656
7845
|
const mark = "anchor" in message && message.anchor ? paint("bold", " \u25C0") : "";
|
|
7657
|
-
const lines = [`${paint("dim", time(message.timestamp))} ${senderOf(message,
|
|
7846
|
+
const lines = [`${paint("dim", time(message.timestamp))} ${senderOf(message, options)}${chat}${mark}`];
|
|
7658
7847
|
const body = /* @__PURE__ */ __name((text) => wrapAnsi(visibleControls(text), room, { hard: true }).split("\n"), "body");
|
|
7659
7848
|
const email = message.email;
|
|
7660
7849
|
if (email)
|
|
7661
7850
|
lines.push(paint("dim", mailLine(email)));
|
|
7662
7851
|
if (message.replyTo)
|
|
7663
|
-
lines.push(paint("dim", preview("\u21B3", message.replyTo, room,
|
|
7852
|
+
lines.push(paint("dim", preview("\u21B3", message.replyTo, room, options)));
|
|
7664
7853
|
if (message.forwardedFrom) {
|
|
7665
|
-
lines.push(paint("dim", `\u21AA ${nameOf(message.forwardedFrom,
|
|
7854
|
+
lines.push(paint("dim", `\u21AA ${nameOf(message.forwardedFrom, options)}`));
|
|
7666
7855
|
if (message.forwardedFrom.text)
|
|
7667
7856
|
for (const line of body(message.forwardedFrom.text))
|
|
7668
7857
|
lines.push(line);
|
|
7669
|
-
lines.push(...attachmentLines(message.forwardedFrom.attachments, paint,
|
|
7858
|
+
lines.push(...attachmentLines(message.forwardedFrom.attachments, paint, options));
|
|
7670
7859
|
}
|
|
7671
7860
|
if (message.text)
|
|
7672
7861
|
for (const line of body(message.text))
|
|
7673
7862
|
lines.push(line);
|
|
7674
|
-
lines.push(...attachmentLines(message.attachments, paint,
|
|
7863
|
+
lines.push(...attachmentLines(message.attachments, paint, options));
|
|
7675
7864
|
if (message.reactions && message.reactions.total > 0)
|
|
7676
7865
|
lines.push(paint("dim", reactionLine(message.reactions)));
|
|
7677
7866
|
if (message.editedAt)
|
|
7678
|
-
lines.push(paint("dim", `edited ${editedAt(message,
|
|
7867
|
+
lines.push(paint("dim", `edited ${editedAt(message, options)}`));
|
|
7679
7868
|
if (verbosity >= 1) {
|
|
7680
7869
|
const fields = [
|
|
7681
7870
|
["message", message.id],
|
|
@@ -7687,7 +7876,7 @@ var renderMessage = /* @__PURE__ */ __name((message, options2 = {}) => {
|
|
|
7687
7876
|
...message.attachments.map((a) => ["link", a.url])
|
|
7688
7877
|
];
|
|
7689
7878
|
if (verbosity >= 2) {
|
|
7690
|
-
fields.push(["provider",
|
|
7879
|
+
fields.push(["provider", options.provider], ["profile", options.profile], ["sent", message.timestamp], ["edited", message.editedAt], ["outgoing", message.outgoing === null ? "unknown" : String(message.outgoing)], ...message.attachments.map((a) => ["attachment", JSON.stringify(a)]), ["metadata", message.providerMetadata && JSON.stringify(message.providerMetadata)]);
|
|
7691
7880
|
}
|
|
7692
7881
|
const shown = fields.filter((field) => typeof field[1] === "string");
|
|
7693
7882
|
const label = Math.max(...shown.map(([key]) => key.length));
|
|
@@ -7700,36 +7889,36 @@ var mailLine = /* @__PURE__ */ __name(({ to, cc, labels }) => {
|
|
|
7700
7889
|
return [to.length ? `to ${names(to)}` : "", cc.length ? `cc ${names(cc)}` : "", labels.join(", ")].filter(Boolean).join(" \xB7 ");
|
|
7701
7890
|
}, "mailLine");
|
|
7702
7891
|
var painter = /* @__PURE__ */ __name(({ color = false }) => (style, text) => color ? styleText(style, text, { validateStream: false }) : text, "painter");
|
|
7703
|
-
var senderOf = /* @__PURE__ */ __name((message,
|
|
7704
|
-
const paint = painter(
|
|
7892
|
+
var senderOf = /* @__PURE__ */ __name((message, options) => {
|
|
7893
|
+
const paint = painter(options);
|
|
7705
7894
|
if (message.outgoing === true)
|
|
7706
|
-
return paint(["bold", "cyan"], you(
|
|
7707
|
-
const name = nameOf(message,
|
|
7708
|
-
if (!
|
|
7895
|
+
return paint(["bold", "cyan"], you(options));
|
|
7896
|
+
const name = nameOf(message, options);
|
|
7897
|
+
if (!options.senderColors)
|
|
7709
7898
|
return paint("bold", name);
|
|
7710
7899
|
const colour = SENDER_COLOURS[hash(message.senderId ?? name) % SENDER_COLOURS.length] ?? "green";
|
|
7711
7900
|
return paint(["bold", colour], name);
|
|
7712
7901
|
}, "senderOf");
|
|
7713
|
-
var nameOf = /* @__PURE__ */ __name(({ senderName, senderId, outgoing },
|
|
7902
|
+
var nameOf = /* @__PURE__ */ __name(({ senderName, senderId, outgoing }, options) => outgoing === true ? you(options) : singleLine(senderName ?? senderId ?? "unknown"), "nameOf");
|
|
7714
7903
|
var DEFAULT_LOCALE = "ru-RU";
|
|
7715
7904
|
var you = /* @__PURE__ */ __name(({ locale = DEFAULT_LOCALE }) => locale.startsWith("ru") ? "\u0432\u044B" : "you", "you");
|
|
7716
7905
|
var hash = /* @__PURE__ */ __name((value) => [...value].reduce((sum, char) => sum * 31 + char.charCodeAt(0) >>> 0, 7), "hash");
|
|
7717
|
-
var preview = /* @__PURE__ */ __name((mark, quoted, room,
|
|
7906
|
+
var preview = /* @__PURE__ */ __name((mark, quoted, room, options) => {
|
|
7718
7907
|
const text = singleLine(quoted.text.split("\n")[0] ?? "") || (quoted.attachments[0] ? `\u{1F4CE} ${quoted.attachments[0].kind}` : "");
|
|
7719
|
-
const line = text ? `${mark} ${nameOf(quoted,
|
|
7908
|
+
const line = text ? `${mark} ${nameOf(quoted, options)}: ${text}` : `${mark} message ${quoted.id}`;
|
|
7720
7909
|
if (stringWidth(line) <= room)
|
|
7721
7910
|
return line;
|
|
7722
7911
|
return `${wrapAnsi(line, room - 1, { hard: true }).split("\n")[0]}\u2026`;
|
|
7723
7912
|
}, "preview");
|
|
7724
|
-
var attachmentLines = /* @__PURE__ */ __name((attachments, paint,
|
|
7913
|
+
var attachmentLines = /* @__PURE__ */ __name((attachments, paint, options) => {
|
|
7725
7914
|
const link = /* @__PURE__ */ __name((label, raw) => {
|
|
7726
7915
|
if (raw === void 0)
|
|
7727
7916
|
return label;
|
|
7728
7917
|
const url = singleLine(raw);
|
|
7729
|
-
return
|
|
7918
|
+
return options.color ? `\x1B]8;;${url}\x07${label}\x1B]8;;\x07` : `${label} ${url}`;
|
|
7730
7919
|
}, "link");
|
|
7731
|
-
let
|
|
7732
|
-
const keyboard = attachments.flatMap((attachment) => attachment.buttons ?? []).map((row) => paint("dim", row.map((button) => link(`[${++
|
|
7920
|
+
let number = 0;
|
|
7921
|
+
const keyboard = attachments.flatMap((attachment) => attachment.buttons ?? []).map((row) => paint("dim", row.map((button) => link(`[${++number} ${singleLine(button.text)}]`, button.url)).join(" ")));
|
|
7733
7922
|
const polls = attachments.flatMap((attachment) => attachment.poll ? pollLines(attachment.poll) : []);
|
|
7734
7923
|
const cards = attachments.flatMap(({ contact }) => contact ? [
|
|
7735
7924
|
paint("dim", `\u{1F464} ${[contact.name, contact.phone].flatMap((part) => part ? [singleLine(part)] : []).join(" \xB7 ")}`)
|
|
@@ -7793,14 +7982,14 @@ var reactionLine = /* @__PURE__ */ __name(({ counts, mine }) => {
|
|
|
7793
7982
|
const shown = counts.map(({ reaction, count: count3 }) => `${singleLine(reaction)} ${count3}`).join(" ");
|
|
7794
7983
|
return mine ? `${shown} (you: ${singleLine(mine)})` : shown;
|
|
7795
7984
|
}, "reactionLine");
|
|
7796
|
-
var editedAt = /* @__PURE__ */ __name((message,
|
|
7985
|
+
var editedAt = /* @__PURE__ */ __name((message, options) => {
|
|
7797
7986
|
const edited = message.editedAt ?? message.timestamp;
|
|
7798
|
-
const time = timeFormatter(
|
|
7799
|
-
const day = dayFormatter(
|
|
7987
|
+
const time = timeFormatter(options)(edited);
|
|
7988
|
+
const day = dayFormatter(options);
|
|
7800
7989
|
return day(edited) === day(message.timestamp) ? time : `${day(edited)} ${time}`;
|
|
7801
7990
|
}, "editedAt");
|
|
7802
7991
|
|
|
7803
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7992
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/cli/messenger/message-items.js
|
|
7804
7993
|
var defined = /* @__PURE__ */ __name((value) => Object.fromEntries(Object.entries(value).filter(([, one]) => one !== void 0)), "defined");
|
|
7805
7994
|
var attachmentItem = /* @__PURE__ */ __name((attachment) => defined({
|
|
7806
7995
|
kind: attachment.kind,
|
|
@@ -7819,7 +8008,7 @@ var attachmentItem = /* @__PURE__ */ __name((attachment) => defined({
|
|
|
7819
8008
|
phone: attachment.contact.phone,
|
|
7820
8009
|
user_id: attachment.contact.userId
|
|
7821
8010
|
}),
|
|
7822
|
-
buttons: attachment.buttons
|
|
8011
|
+
buttons: attachment.buttons?.map((row) => row.map(({ data: _data, ...button }) => button))
|
|
7823
8012
|
}), "attachmentItem");
|
|
7824
8013
|
var quotedItem = /* @__PURE__ */ __name((quoted) => quoted === null ? null : {
|
|
7825
8014
|
id: quoted.id,
|
|
@@ -7895,7 +8084,7 @@ var viewOf = /* @__PURE__ */ __name((context, messenger) => ({
|
|
|
7895
8084
|
locale: messenger.app.locale
|
|
7896
8085
|
}), "viewOf");
|
|
7897
8086
|
|
|
7898
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
8087
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/cli/messenger/watch-answers.js
|
|
7899
8088
|
var observed = /* @__PURE__ */ __name((value) => ({
|
|
7900
8089
|
value: value.value,
|
|
7901
8090
|
observed_at: value.observedAt,
|
|
@@ -7962,7 +8151,7 @@ var watchEventItem = /* @__PURE__ */ __name((value, account) => {
|
|
|
7962
8151
|
}
|
|
7963
8152
|
}, "watchEventItem");
|
|
7964
8153
|
|
|
7965
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
8154
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/cli/messenger/watch-command.js
|
|
7966
8155
|
var watchCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("watch"), {
|
|
7967
8156
|
output: { entity: "watch_item" },
|
|
7968
8157
|
effects: REMOTE_READ,
|
|
@@ -8117,7 +8306,7 @@ var describe = /* @__PURE__ */ __name((event, render) => {
|
|
|
8117
8306
|
}
|
|
8118
8307
|
}, "describe");
|
|
8119
8308
|
|
|
8120
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
8309
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-command.js
|
|
8121
8310
|
var serveCommand = /* @__PURE__ */ __name((messenger) => {
|
|
8122
8311
|
const command = annotate(new Command("serve"), {
|
|
8123
8312
|
output: { entity: "serve_summary" },
|
|
@@ -8141,8 +8330,8 @@ var serveCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
8141
8330
|
}
|
|
8142
8331
|
let relaying;
|
|
8143
8332
|
const onReady = /* @__PURE__ */ __name(() => {
|
|
8144
|
-
const
|
|
8145
|
-
holdLock(path,
|
|
8333
|
+
const listening2 = { pid: process.pid, startedAt, version, listeningAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
8334
|
+
holdLock(path, listening2);
|
|
8146
8335
|
note({
|
|
8147
8336
|
code: "listening",
|
|
8148
8337
|
text: `listening for profile ${context.profile}, catching up on what arrived while it was down`
|
|
@@ -8151,7 +8340,7 @@ var serveCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
8151
8340
|
return;
|
|
8152
8341
|
relaying = relay.open(path, context.profile).then((address) => {
|
|
8153
8342
|
if (address)
|
|
8154
|
-
holdLock(path, { ...
|
|
8343
|
+
holdLock(path, { ...listening2, relay: address });
|
|
8155
8344
|
}).catch((error) => {
|
|
8156
8345
|
const errorCode = failureKey(error);
|
|
8157
8346
|
warn({ code: "relay_failed", errorCode, text: `commands cannot run through this serve: ${errorCode}` });
|
|
@@ -8160,7 +8349,7 @@ var serveCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
8160
8349
|
const counts = {};
|
|
8161
8350
|
const rules = replying(context, messenger, Date.parse(startedAt));
|
|
8162
8351
|
const tasks = tasking(context, warn);
|
|
8163
|
-
const { handled, startSyncDelayMs } = environmentOf(this);
|
|
8352
|
+
const { handled, startSyncDelayMs, outdated: outdatedHook } = environmentOf(this);
|
|
8164
8353
|
const count3 = /* @__PURE__ */ __name((event) => {
|
|
8165
8354
|
counts[event.event] = (counts[event.event] ?? 0) + 1;
|
|
8166
8355
|
if (event.event === "message") {
|
|
@@ -8232,9 +8421,25 @@ var serveCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
8232
8421
|
withStore: /* @__PURE__ */ __name((work) => context.withStore((store) => work(store), { name: "serve stems" }), "withStore"),
|
|
8233
8422
|
warn
|
|
8234
8423
|
});
|
|
8424
|
+
const listening = new AbortController();
|
|
8425
|
+
let outdated;
|
|
8426
|
+
const packageRoot = outdatedHook?.packageRoot ?? ownPackageRoot(version);
|
|
8427
|
+
const watch = watchOutdated({
|
|
8428
|
+
check: /* @__PURE__ */ __name(() => outdatedReason({
|
|
8429
|
+
command: messenger.app.command,
|
|
8430
|
+
running: version,
|
|
8431
|
+
storePath: storePath(context.env),
|
|
8432
|
+
packageRoot
|
|
8433
|
+
}), "check"),
|
|
8434
|
+
onOutdated: /* @__PURE__ */ __name((reason) => {
|
|
8435
|
+
outdated = reason;
|
|
8436
|
+
listening.abort();
|
|
8437
|
+
}, "onOutdated"),
|
|
8438
|
+
...outdatedHook?.everyMs === void 0 ? {} : { everyMs: outdatedHook.everyMs }
|
|
8439
|
+
});
|
|
8235
8440
|
try {
|
|
8236
8441
|
await listenUntilStopped(this, context, relay?.messenger ?? messenger, count3, {
|
|
8237
|
-
stop:
|
|
8442
|
+
stop: listening,
|
|
8238
8443
|
catchUp: true,
|
|
8239
8444
|
onReady,
|
|
8240
8445
|
connected: /* @__PURE__ */ __name((open) => {
|
|
@@ -8247,6 +8452,7 @@ var serveCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
8247
8452
|
}, "connected")
|
|
8248
8453
|
});
|
|
8249
8454
|
} finally {
|
|
8455
|
+
watch.stop();
|
|
8250
8456
|
await relaying;
|
|
8251
8457
|
await relay?.close();
|
|
8252
8458
|
rules.stop();
|
|
@@ -8257,6 +8463,8 @@ var serveCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
8257
8463
|
await tasks.settled();
|
|
8258
8464
|
releaseLock(path);
|
|
8259
8465
|
}
|
|
8466
|
+
if (outdated !== void 0)
|
|
8467
|
+
throw new CliError("configuration_error", outdated, { reason: "serve.outdated" });
|
|
8260
8468
|
renderAnswer(this, context, itemOf({
|
|
8261
8469
|
profile: context.profile,
|
|
8262
8470
|
started_at: startedAt,
|
|
@@ -8381,8 +8589,8 @@ var tasking = /* @__PURE__ */ __name((context, warn) => {
|
|
|
8381
8589
|
};
|
|
8382
8590
|
}, "tasking");
|
|
8383
8591
|
|
|
8384
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
8385
|
-
import { existsSync as
|
|
8592
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/cli/messenger/store-tables-command.js
|
|
8593
|
+
import { existsSync as existsSync9 } from "node:fs";
|
|
8386
8594
|
var PATH = "store tables list";
|
|
8387
8595
|
var STORE_TABLES_QUERY = {
|
|
8388
8596
|
entity: "store_table",
|
|
@@ -8411,7 +8619,7 @@ var storeTablesCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
8411
8619
|
const filter = filterOf(words);
|
|
8412
8620
|
const { full } = this.optsWithGlobals();
|
|
8413
8621
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8414
|
-
if (!
|
|
8622
|
+
if (!existsSync9(path))
|
|
8415
8623
|
throw new CliError("not_found", `no store at ${path}`);
|
|
8416
8624
|
const items = await readStoreTables(path, { filter, sizes: full === true });
|
|
8417
8625
|
renderAnswer(this, outputFor(this), listOf(PATH, {
|
|
@@ -8424,7 +8632,7 @@ var storeTablesCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
8424
8632
|
return tables;
|
|
8425
8633
|
}, "storeTablesCommand");
|
|
8426
8634
|
|
|
8427
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
8635
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.634.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_795ed7a67bda78d624888739490b3720/node_modules/@wirecat/cli-core/dist/cli/messenger/store-maintenance-command.js
|
|
8428
8636
|
var SEARCH_INDEXES = ["messages_fts", "chats_fts", "identities_fts"];
|
|
8429
8637
|
var WORD_INDEX = "message_words";
|
|
8430
8638
|
var schemaOf = /* @__PURE__ */ __name((database) => {
|
|
@@ -8433,7 +8641,7 @@ var schemaOf = /* @__PURE__ */ __name((database) => {
|
|
|
8433
8641
|
}, "schemaOf");
|
|
8434
8642
|
var count2 = /* @__PURE__ */ __name((database, table) => Number(database.prepare(`SELECT count(*) AS n FROM ${table}`).get()?.n ?? 0), "count");
|
|
8435
8643
|
var pendingIfKnown2 = /* @__PURE__ */ __name((database) => database.prepare("SELECT 1 FROM pragma_table_info('messages') WHERE name = 'normalized_text'").get() ? pendingNormalization(database) : null, "pendingIfKnown");
|
|
8436
|
-
var bytesOf2 = /* @__PURE__ */ __name((path) =>
|
|
8644
|
+
var bytesOf2 = /* @__PURE__ */ __name((path) => existsSync10(path) ? statSync4(path).size : 0, "bytesOf");
|
|
8437
8645
|
var reading = /* @__PURE__ */ __name(async (path, read) => {
|
|
8438
8646
|
const database = await openCache(path);
|
|
8439
8647
|
try {
|
|
@@ -8460,9 +8668,10 @@ var fileSchema = /* @__PURE__ */ __name(async (path) => {
|
|
|
8460
8668
|
}, "fileSchema");
|
|
8461
8669
|
var storeSummary = /* @__PURE__ */ __name(async (env, { deep = false, command, version } = {}) => {
|
|
8462
8670
|
const path = storePath(env);
|
|
8463
|
-
if (!
|
|
8671
|
+
if (!existsSync10(path))
|
|
8464
8672
|
return { path, exists: false };
|
|
8465
8673
|
const checked = await storeHealth(path, { deep });
|
|
8674
|
+
const journal = readJournalMark(path);
|
|
8466
8675
|
const recorded = deep ? recordDeepCheck(path, checked, {
|
|
8467
8676
|
cli: command ?? "unknown",
|
|
8468
8677
|
...version ? { version } : {},
|
|
@@ -8480,13 +8689,15 @@ var storeSummary = /* @__PURE__ */ __name(async (env, { deep = false, command, v
|
|
|
8480
8689
|
...checked.invalidJson?.length ? { invalidJson: checked.invalidJson } : {},
|
|
8481
8690
|
...checked.searchIndexes?.some((index) => !index.ok) ? { damagedSearchIndexes: checked.searchIndexes.filter((index) => !index.ok).map((index) => index.name) } : {}
|
|
8482
8691
|
};
|
|
8483
|
-
const damage = command ?
|
|
8692
|
+
const damage = command ? storeDamageReport({ health: checked, command, mark, journal, lastOkAt: lastKnownGood }) : null;
|
|
8484
8693
|
const healthOf = {
|
|
8485
8694
|
health,
|
|
8486
8695
|
lastKnownGood,
|
|
8487
8696
|
...mark ? { damageMark: withoutInode(mark) } : {},
|
|
8697
|
+
...journal ? { journalMark: journal } : {},
|
|
8488
8698
|
...recorded?.cleared ? { damageMarkCleared: withoutInode(recorded.cleared) } : {},
|
|
8489
|
-
|
|
8699
|
+
// `what` keeps memo's doctor, which reads it, compiling until it moves to `whatHappened`.
|
|
8700
|
+
...damage ? { damage: { what: damage.whatHappened, ...damage } } : {}
|
|
8490
8701
|
};
|
|
8491
8702
|
try {
|
|
8492
8703
|
return await reading(path, (database) => {
|
|
@@ -8530,7 +8741,7 @@ var repairCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("
|
|
|
8530
8741
|
const { renderer, format } = outputFor(this);
|
|
8531
8742
|
const { dryRun: dryRun2 } = this.opts();
|
|
8532
8743
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8533
|
-
if (!
|
|
8744
|
+
if (!existsSync10(path)) {
|
|
8534
8745
|
result(this, { path, exists: false });
|
|
8535
8746
|
return;
|
|
8536
8747
|
}
|
|
@@ -8570,7 +8781,7 @@ var notesOf = /* @__PURE__ */ __name((report, command) => {
|
|
|
8570
8781
|
}, "notesOf");
|
|
8571
8782
|
var copiesCommand = /* @__PURE__ */ __name(() => new Command("copies").description("the tables `store repair` kept as copies").addCommand(annotate(new Command("delete"), { output: { entity: "store_copy_removal" }, effects: LOCAL_WRITE }).description("delete one copy `store repair` kept, named exactly; refuses any other table").argument("<name>", "the copy's name, as `store repair` printed it").action(async function(name) {
|
|
8572
8783
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8573
|
-
if (!
|
|
8784
|
+
if (!existsSync10(path))
|
|
8574
8785
|
throw new CliError("not_found", `no store at ${path}`);
|
|
8575
8786
|
const deleted = await reading(path, (database) => deleteCopy(database, name));
|
|
8576
8787
|
result(this, { path, deleted });
|
|
@@ -8578,7 +8789,7 @@ var copiesCommand = /* @__PURE__ */ __name(() => new Command("copies").descripti
|
|
|
8578
8789
|
var checkCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("check"), { output: { entity: "store_check" }, effects: LOCAL_READ }).summary("check the local archive for problems").description("whether the store is healthy \u2014 integrity, search indexes, disk, and which chats are behind").action(async function() {
|
|
8579
8790
|
const { renderer } = outputFor(this);
|
|
8580
8791
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8581
|
-
if (!
|
|
8792
|
+
if (!existsSync10(path)) {
|
|
8582
8793
|
result(this, { path, exists: false, ok: true });
|
|
8583
8794
|
return;
|
|
8584
8795
|
}
|
|
@@ -8641,7 +8852,7 @@ var inspect = /* @__PURE__ */ __name((path) => reading(path, (database) => {
|
|
|
8641
8852
|
...schema.version > 0 ? [["attachment_words", indexIntegrity(database, "attachment_words", 0)]] : []
|
|
8642
8853
|
]);
|
|
8643
8854
|
const size = bytesOf2(path) + bytesOf2(`${path}-wal`);
|
|
8644
|
-
const { bavail, bsize } = statfsSync2(
|
|
8855
|
+
const { bavail, bsize } = statfsSync2(dirname3(path));
|
|
8645
8856
|
const free = Number(bavail) * Number(bsize);
|
|
8646
8857
|
const behind = schema.version > 0 ? chatsBehind(database) : [];
|
|
8647
8858
|
const vectorIndexes = schema.version >= 34 ? vectorIndexCounts(database) : [];
|
|
@@ -8729,7 +8940,7 @@ var chatsBehind = /* @__PURE__ */ __name((database) => database.prepare(`SELECT
|
|
|
8729
8940
|
var migrateCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("migrate"), { output: { entity: "store_migration" }, effects: LOCAL_WRITE }).summary("migrate an older local archive").description("bring the store up to this build's schema, then normalize, index and stem the messages and notes stored before it").action(async function() {
|
|
8730
8941
|
const { renderer } = outputFor(this);
|
|
8731
8942
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8732
|
-
if (!
|
|
8943
|
+
if (!existsSync10(path)) {
|
|
8733
8944
|
result(this, { path, exists: false });
|
|
8734
8945
|
renderer.note(`no store yet \u2014 the first \`${messenger.app.command}\` command that reads a chat creates it`);
|
|
8735
8946
|
return;
|
|
@@ -8793,7 +9004,7 @@ var buildNoteIndex = /* @__PURE__ */ __name((database, note, { reset = false } =
|
|
|
8793
9004
|
var reindexCommand = /* @__PURE__ */ __name((messenger) => destroysNothing(annotate(new Command("rebuild"), { output: { entity: "store_reindex" }, effects: LOCAL_WRITE })).summary("rebuild the local archive's search indexes").description("rebuild the word index, its typo vocabulary, the stems, the files' word index, the notes' indexes and who took part in what, from what is stored, and drop the vectors no stored text uses; loses nothing").action(async function() {
|
|
8794
9005
|
const { renderer } = outputFor(this);
|
|
8795
9006
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8796
|
-
if (!
|
|
9007
|
+
if (!existsSync10(path)) {
|
|
8797
9008
|
result(this, { path, exists: false });
|
|
8798
9009
|
return;
|
|
8799
9010
|
}
|
|
@@ -8835,9 +9046,9 @@ var backupCommand = /* @__PURE__ */ __name(() => destroysNothing(annotate(new Co
|
|
|
8835
9046
|
const { encrypt } = this.opts();
|
|
8836
9047
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8837
9048
|
const target = resolve(file2);
|
|
8838
|
-
if (!
|
|
9049
|
+
if (!existsSync10(path))
|
|
8839
9050
|
throw new CliError("not_found", `no store at ${path} to back up`);
|
|
8840
|
-
if (
|
|
9051
|
+
if (existsSync10(target))
|
|
8841
9052
|
throw new CliError("validation_error", `${target} exists \u2014 a backup never overwrites a file`);
|
|
8842
9053
|
const password = encrypt ? await passwordOf(this, { twice: true }) : void 0;
|
|
8843
9054
|
const copyAt = password === void 0 ? target : `${path}.backup-${process.pid}`;
|
|
@@ -8870,11 +9081,11 @@ var decryptCommand = /* @__PURE__ */ __name(() => annotate(new Command("decrypt"
|
|
|
8870
9081
|
const { output } = this.opts();
|
|
8871
9082
|
const from = resolve(file2);
|
|
8872
9083
|
const to = resolve(output);
|
|
8873
|
-
if (!
|
|
9084
|
+
if (!existsSync10(from))
|
|
8874
9085
|
throw new CliError("not_found", `no file at ${from}`);
|
|
8875
9086
|
if (!isSealed(from))
|
|
8876
9087
|
throw new CliError("validation_error", `${from} was not written with --encrypt`);
|
|
8877
|
-
if (
|
|
9088
|
+
if (existsSync10(to))
|
|
8878
9089
|
throw new CliError("validation_error", `${to} exists \u2014 never overwritten`);
|
|
8879
9090
|
await unsealFile(from, to, await passwordOf(this, { twice: false }));
|
|
8880
9091
|
result(this, { path: to, from, bytes: bytesOf2(to) });
|
|
@@ -8882,13 +9093,13 @@ var decryptCommand = /* @__PURE__ */ __name(() => annotate(new Command("decrypt"
|
|
|
8882
9093
|
var restoreCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("restore"), { output: { entity: "store_restore" }, effects: LOCAL_WRITE }).summary("restore a backup and keep the current store, or roll back a breaking upgrade").description("put a backup in place of the store; the store it replaces is kept beside it, never deleted. Given a rollback copy (backups/<store>-rollback-schema-<version>-<time>.db, kept for a day before an upgrade older tools cannot open), put its tables back in the store and return it to that version instead").argument("<file>", "a file `store backup` wrote, or a rollback copy; one written with --encrypt asks for its password").action(async function(file2) {
|
|
8883
9094
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8884
9095
|
const given = resolve(file2);
|
|
8885
|
-
if (!
|
|
9096
|
+
if (!existsSync10(given))
|
|
8886
9097
|
throw new CliError("not_found", `no file at ${given}`);
|
|
8887
9098
|
refuseWhileServing(this, messenger);
|
|
8888
9099
|
if (!isSealed(given))
|
|
8889
9100
|
return restoreFrom(this, messenger, given, given);
|
|
8890
9101
|
const opened = `${path}.unsealing-${process.pid}`;
|
|
8891
|
-
mkdirSync(
|
|
9102
|
+
mkdirSync(dirname3(path), { recursive: true, mode: 448 });
|
|
8892
9103
|
try {
|
|
8893
9104
|
await unsealFile(given, opened, await passwordOf(this, { twice: false }));
|
|
8894
9105
|
await restoreFrom(this, messenger, opened, given);
|
|
@@ -8899,26 +9110,26 @@ var restoreCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command(
|
|
|
8899
9110
|
var restoreFrom = /* @__PURE__ */ __name(async (command, messenger, backup, given) => {
|
|
8900
9111
|
const { renderer } = outputFor(command);
|
|
8901
9112
|
const path = storePath(environmentOf(command).env ?? process.env);
|
|
8902
|
-
if (
|
|
9113
|
+
if (existsSync10(path) && realpathSync3(backup) === realpathSync3(path)) {
|
|
8903
9114
|
throw new CliError("validation_error", `${backup} is the store itself`);
|
|
8904
9115
|
}
|
|
8905
9116
|
if (await isRollbackCopy(backup))
|
|
8906
9117
|
return rollBackFrom(command, messenger, backup);
|
|
8907
9118
|
const schema = await backupSchema(backup);
|
|
8908
9119
|
const stamp = stampNow();
|
|
8909
|
-
const kept =
|
|
9120
|
+
const kept = existsSync10(path) ? `${path}.before-restore-${stamp}` : null;
|
|
8910
9121
|
if (kept) {
|
|
8911
9122
|
const waitMs = environmentOf(command).storeLockWaitMs;
|
|
8912
9123
|
await quiesce(path, messenger, "restore", (message) => renderer.warn(message), waitMs);
|
|
8913
9124
|
} else
|
|
8914
|
-
mkdirSync(
|
|
9125
|
+
mkdirSync(dirname3(path), { recursive: true, mode: 448 });
|
|
8915
9126
|
const incoming = `${path}.restoring-${stamp}`;
|
|
8916
9127
|
copyFileSync(backup, incoming, constants.COPYFILE_EXCL);
|
|
8917
9128
|
chmodSync(incoming, 384);
|
|
8918
9129
|
if (kept) {
|
|
8919
9130
|
renameSync3(path, kept);
|
|
8920
9131
|
for (const suffix of ["-wal", "-shm"])
|
|
8921
|
-
if (
|
|
9132
|
+
if (existsSync10(`${path}${suffix}`))
|
|
8922
9133
|
renameSync3(`${path}${suffix}`, `${kept}${suffix}`);
|
|
8923
9134
|
}
|
|
8924
9135
|
renameSync3(incoming, path);
|
|
@@ -8940,7 +9151,7 @@ var isRollbackCopy = /* @__PURE__ */ __name(async (file2) => {
|
|
|
8940
9151
|
var rollBackFrom = /* @__PURE__ */ __name(async (command, messenger, copy) => {
|
|
8941
9152
|
const { renderer } = outputFor(command);
|
|
8942
9153
|
const path = storePath(environmentOf(command).env ?? process.env);
|
|
8943
|
-
if (!
|
|
9154
|
+
if (!existsSync10(path))
|
|
8944
9155
|
throw new CliError("not_found", `no store at ${path} to roll back`);
|
|
8945
9156
|
const waitMs = environmentOf(command).storeLockWaitMs;
|
|
8946
9157
|
await quiesce(path, messenger, "restore", (message) => renderer.warn(message), waitMs);
|
|
@@ -8990,7 +9201,7 @@ var backupSchema = /* @__PURE__ */ __name(async (backup) => {
|
|
|
8990
9201
|
var STORE_LOCK_WAIT_MS = 1e3;
|
|
8991
9202
|
var quiesce = /* @__PURE__ */ __name(async (path, messenger, then, warn, waitMs = STORE_LOCK_WAIT_MS) => {
|
|
8992
9203
|
const { command } = messenger.app;
|
|
8993
|
-
const files = [path, `${path}-wal`, `${path}-shm`].filter((file2) =>
|
|
9204
|
+
const files = [path, `${path}-wal`, `${path}-shm`].filter((file2) => existsSync10(file2)).map((file2) => realpathSync3(file2));
|
|
8994
9205
|
const holders = holdersOf(files);
|
|
8995
9206
|
if (holders === void 0) {
|
|
8996
9207
|
warn(`this system cannot say which processes have the store open \u2014 restart every running serve and mcp after this`);
|
|
@@ -9016,7 +9227,7 @@ var resetCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("r
|
|
|
9016
9227
|
const { command } = messenger.app;
|
|
9017
9228
|
const env = environmentOf(this).env ?? process.env;
|
|
9018
9229
|
const path = storePath(env);
|
|
9019
|
-
if (!
|
|
9230
|
+
if (!existsSync10(path)) {
|
|
9020
9231
|
result(this, { path, exists: false, reset: false });
|
|
9021
9232
|
renderer.note(`no store at ${path} \u2014 nothing to reset; the first \`${command}\` command that reads a chat creates it`);
|
|
9022
9233
|
return;
|
|
@@ -9061,8 +9272,8 @@ var resetCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("r
|
|
|
9061
9272
|
}), "resetCommand");
|
|
9062
9273
|
var STORE_PARTS2 = ["", "-wal", "-shm"];
|
|
9063
9274
|
var resetPreview = /* @__PURE__ */ __name(async (path, messenger, env, keep) => {
|
|
9064
|
-
const files = STORE_PARTS2.map((suffix) => `${path}${suffix}`).filter((file2) =>
|
|
9065
|
-
const holders = holdersOf(files.map((file2) =>
|
|
9275
|
+
const files = STORE_PARTS2.map((suffix) => `${path}${suffix}`).filter((file2) => existsSync10(file2));
|
|
9276
|
+
const holders = holdersOf(files.map((file2) => realpathSync3(file2)));
|
|
9066
9277
|
const serving = servingProfiles(messenger.app, env).length > 0;
|
|
9067
9278
|
const read = await readingOnly(path, (database) => ({
|
|
9068
9279
|
schema: schemaOf(database).version,
|
|
@@ -9109,11 +9320,9 @@ export {
|
|
|
9109
9320
|
readRepliesState,
|
|
9110
9321
|
writeRepliesState,
|
|
9111
9322
|
paused,
|
|
9323
|
+
safeLiquid,
|
|
9112
9324
|
DRY_RUN_DAYS,
|
|
9113
9325
|
dryRun,
|
|
9114
|
-
endpointKeyName,
|
|
9115
|
-
embeddingKeys,
|
|
9116
|
-
modelGateway,
|
|
9117
9326
|
replyConsentPathFor,
|
|
9118
9327
|
readReplyConsent,
|
|
9119
9328
|
writeReplyConsent,
|