@wirecat/zoom-cli 0.67.0 → 0.68.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/dist/answer-entities.d.ts +18 -0
- package/dist/answer-entities.d.ts.map +1 -1
- package/dist/answer-entities.js +12 -0
- package/dist/answer-entities.js.map +1 -1
- package/dist/answer-policy.d.ts.map +1 -1
- package/dist/answer-policy.js +2 -1
- package/dist/answer-policy.js.map +1 -1
- package/dist/bin/zm.js +2 -2
- package/dist/bundle/{all-profiles-SEW2VL76.js → all-profiles-R66UM3HM.js} +12 -12
- package/dist/bundle/answer-policy-UCGUO53A.js +104 -0
- package/dist/bundle/{anthropic-FSNASJML.js → anthropic-4ZI2BPLG.js} +7 -7
- package/dist/bundle/{app-server-EVSRYJ3H.js → app-server-64O5IQI5.js} +61 -58
- package/dist/bundle/{bun-DACL5SVO.js → bun-HUHQD76Z.js} +2 -2
- package/dist/bundle/{bun-sqlite-HQ2KOXSI.js → bun-sqlite-VOVHPTIF.js} +6 -6
- package/dist/bundle/{chunk-SMVO5R3T.js → chunk-2OSBCYJT.js} +39 -26
- package/dist/bundle/{chunk-TBRG2DPE.js → chunk-2T6XHWDX.js} +2 -2
- package/dist/bundle/{chunk-6AJDVJVZ.js → chunk-32FPA7P2.js} +2 -2
- package/dist/bundle/{chunk-7LLUUXJB.js → chunk-355PHJYX.js} +1 -1
- package/dist/bundle/{chunk-3GO3KME7.js → chunk-3BRV2YU2.js} +3 -3
- package/dist/bundle/{chunk-I7SOXH64.js → chunk-474WF55M.js} +53 -39
- package/dist/bundle/{chunk-L643D4RJ.js → chunk-4TLPOY22.js} +12 -12
- package/dist/bundle/{chunk-D6OXI2NV.js → chunk-4YFJYSSK.js} +205 -59
- package/dist/bundle/chunk-5JAYUG3X.js +261 -0
- package/dist/bundle/{chunk-VNIBTNV4.js → chunk-65T3PU75.js} +2 -2
- package/dist/bundle/{chunk-6TZF2JP7.js → chunk-6CJ7NHIP.js} +13 -13
- package/dist/bundle/{chunk-MWEOVTIF.js → chunk-6T3P226D.js} +4 -4
- package/dist/bundle/{chunk-EPDRF66S.js → chunk-6TJ62LZQ.js} +22 -14
- package/dist/bundle/{chunk-ZRMZBMOF.js → chunk-6XO7RTJY.js} +66 -6
- package/dist/bundle/{chunk-VFIEYRYD.js → chunk-77I67HWF.js} +8 -8
- package/dist/bundle/{chunk-QX2MAT6I.js → chunk-77KFLU5F.js} +3 -3
- package/dist/bundle/{chunk-4GCKDO2H.js → chunk-7AUP2WT3.js} +3 -3
- package/dist/bundle/{chunk-7VU5UGRR.js → chunk-7DUYFITC.js} +16 -16
- package/dist/bundle/{chunk-ASCHAVNW.js → chunk-7QNJICKZ.js} +27 -27
- package/dist/bundle/{chunk-KWRSC6O6.js → chunk-A63ZFOQJ.js} +18 -4
- package/dist/bundle/{chunk-SSXCOUP3.js → chunk-AJ7CMUGD.js} +464 -220
- package/dist/bundle/{chunk-SCFFCIIP.js → chunk-AVEIQMHZ.js} +2 -2
- package/dist/bundle/chunk-AYEVBAGO.js +178 -0
- package/dist/bundle/{chunk-AAZFLJSH.js → chunk-B6JMVB6R.js} +10 -10
- package/dist/bundle/{chunk-CRLBTNC4.js → chunk-BL36NSV5.js} +3 -3
- package/dist/bundle/{chunk-4UVT2QCO.js → chunk-BOAMDYLY.js} +4 -4
- package/dist/bundle/chunk-BSM43OMN.js +31 -0
- package/dist/bundle/{chunk-QEI55M2F.js → chunk-DGNPJGD3.js} +16 -10
- package/dist/bundle/{chunk-SOZVC3SV.js → chunk-DVA6MQWK.js} +1 -1
- package/dist/bundle/{chunk-YRNZT4GQ.js → chunk-DWSUSWAX.js} +98 -13
- package/dist/bundle/{chunk-LFQ73UFK.js → chunk-EH5QGQFR.js} +3 -3
- package/dist/bundle/{chunk-OZEYFJX2.js → chunk-EJDV5IIF.js} +1 -1
- package/dist/bundle/{chunk-VQTAU4DV.js → chunk-EWIBLDQQ.js} +8 -8
- package/dist/bundle/{chunk-4ZR5DJ26.js → chunk-EZRPSZJS.js} +3 -3
- package/dist/bundle/{chunk-KIJLM5UL.js → chunk-FBLUKCIR.js} +1 -1
- package/dist/bundle/{chunk-WZ5XK74U.js → chunk-FEM2JQN2.js} +1 -1
- package/dist/bundle/{chunk-GP4NSYDU.js → chunk-FMQS7HCC.js} +12 -12
- package/dist/bundle/{chunk-B5Z4XPVS.js → chunk-FNQASORM.js} +2 -2
- package/dist/bundle/{chunk-FWU3ZYHE.js → chunk-GOXDBCDM.js} +728 -130
- package/dist/bundle/{chunk-CLEZE65P.js → chunk-HXOAPH47.js} +1 -1
- package/dist/bundle/{chunk-7K5TDTZY.js → chunk-JO4YADNV.js} +7 -7
- package/dist/bundle/{chunk-4U2555EQ.js → chunk-JRCYFCPL.js} +30 -28
- package/dist/bundle/{chunk-L6CAUVMU.js → chunk-K67V24AT.js} +5 -5
- package/dist/bundle/{chunk-B3KWAULD.js → chunk-KAPJQGHE.js} +2 -2
- package/dist/bundle/{chunk-T6CZWSHF.js → chunk-KNE6VFHZ.js} +21 -21
- package/dist/bundle/{chunk-LM26DJOK.js → chunk-KUB2U5NT.js} +6 -6
- package/dist/bundle/{chunk-EUPZSR2G.js → chunk-L4WVLRXM.js} +4 -4
- package/dist/bundle/{chunk-BKY4XVB4.js → chunk-LBOSTBAY.js} +1248 -617
- package/dist/bundle/{chunk-C6UKW7JO.js → chunk-LV7QRR5S.js} +6 -6
- package/dist/bundle/{chunk-FGTPREAZ.js → chunk-LYWUG43B.js} +33 -33
- package/dist/bundle/{chunk-NTZDM5SJ.js → chunk-NRRI37NJ.js} +9 -9
- package/dist/bundle/{chunk-J3ZBEWQY.js → chunk-NUJMJQXV.js} +54 -147
- package/dist/bundle/{chunk-6IBM4Z3V.js → chunk-OE7EIP5L.js} +1 -1
- package/dist/bundle/{chunk-ZMPTO2WB.js → chunk-P2TISY3R.js} +1 -1
- package/dist/bundle/{chunk-KV4267S4.js → chunk-P3ASN72F.js} +1 -1
- package/dist/bundle/{chunk-V33VGWT3.js → chunk-PIHBD3YS.js} +16 -6
- package/dist/bundle/{chunk-RYKG6AEH.js → chunk-PUTGTW6W.js} +4 -2
- package/dist/bundle/{chunk-L6WUAGPN.js → chunk-QXTREL2M.js} +3 -3
- package/dist/bundle/{chunk-X67YD3QI.js → chunk-R7LFGEDE.js} +2 -2
- package/dist/bundle/{chunk-2UW533HQ.js → chunk-RGJ7OWHU.js} +4 -4
- package/dist/bundle/{chunk-LKJXTACE.js → chunk-RP3U3J53.js} +7 -7
- package/dist/bundle/{chunk-DG4DWAU7.js → chunk-RRYUD2EF.js} +3 -3
- package/dist/bundle/{chunk-Q65SDEFN.js → chunk-SRP6SFFD.js} +2 -2
- package/dist/bundle/{chunk-4KDZ22RA.js → chunk-SSPSNSC5.js} +1 -1
- package/dist/bundle/{chunk-DFUPETW7.js → chunk-TDGZMC6K.js} +130 -75
- package/dist/bundle/{chunk-EQ7XRRKV.js → chunk-TN3FH2GQ.js} +11 -11
- package/dist/bundle/chunk-TUNQ6NE2.js +64 -0
- package/dist/bundle/{chunk-FXQPK742.js → chunk-TZUKDM72.js} +29 -15
- package/dist/bundle/{chunk-IFDO3YPJ.js → chunk-UDJTRFRV.js} +1 -1
- package/dist/bundle/{chunk-ESFMHBHH.js → chunk-US5C3WAY.js} +60 -51
- package/dist/bundle/{chunk-KANH7GBB.js → chunk-UU5PLDRA.js} +2 -2
- package/dist/bundle/{chunk-OTMGAKUM.js → chunk-VLD7Y4SY.js} +7 -7
- package/dist/bundle/{chunk-YPF6OS37.js → chunk-VW6BF6M7.js} +1 -1
- package/dist/bundle/{chunk-JVCHGI7W.js → chunk-W42BJ65M.js} +1 -1
- package/dist/bundle/{chunk-RAMPYIO2.js → chunk-Y5LP5SHV.js} +11 -11
- package/dist/bundle/{chunk-WHQ4ZCJI.js → chunk-YJY3W2ZT.js} +210 -85
- package/dist/bundle/{chunk-3ZIHUSMM.js → chunk-YOAEZSDG.js} +2 -2
- package/dist/bundle/{chunk-M43MBWJX.js → chunk-YQRNFG2E.js} +13471 -1289
- package/dist/bundle/{chunk-7HAIM7GV.js → chunk-YTF2WPV4.js} +601 -443
- package/dist/bundle/{chunk-6UFWFKFH.js → chunk-ZRD3NDOX.js} +2 -2
- package/dist/bundle/{cli-YUATSOLA.js → cli-VQJ7ZRYR.js} +89 -61
- package/dist/bundle/command-contract-JPUWWYIV.js +41 -0
- package/dist/bundle/config-YGLLR77A.js +90 -0
- package/dist/bundle/{decode-IL44LNC3.js → decode-L3ENO2XH.js} +6 -6
- package/dist/bundle/{dispatch-3BGIXSJR.js → dispatch-5MGDLOK4.js} +9 -9
- package/dist/bundle/{dist-3W27UQ2S.js → dist-WQLS7U23.js} +47 -27
- package/dist/bundle/{echarts-CO4D26JF.js → echarts-5LLJ6JXC.js} +2 -2
- package/dist/bundle/{embed-XH2X4DFM.js → embed-37MYTCU7.js} +7 -7
- package/dist/bundle/{embedder-WTFWDXBJ.js → embedder-GNGHVJAO.js} +10 -10
- package/dist/bundle/{failure-HTIS3NLS.js → failure-CR64C4XA.js} +3 -3
- package/dist/bundle/{first-run-5RBH7FDO.js → first-run-NR5JKYP3.js} +12 -12
- package/dist/bundle/first-screen-RCR7ATO2.js +39 -0
- package/dist/bundle/{folders-F4DNQPIY.js → folders-VU4IN35Y.js} +5 -5
- package/dist/bundle/{instructions-EPPBL6TT.js → instructions-P72XX4AK.js} +1 -1
- package/dist/bundle/{main-LVQTCDZS.js → main-QYFCYSTW.js} +21 -23
- package/dist/bundle/{mcp-PPVOM4SE.js → mcp-M4QN2E7R.js} +2 -2
- package/dist/bundle/{meetings-BMELXRTR.js → meetings-66UQINKI.js} +13 -7
- package/dist/bundle/{node-CQVMWVIG.js → node-ZB4RNICS.js} +2 -2
- package/dist/bundle/{node-sqlite-QQEX7LZT.js → node-sqlite-XPRKBDF3.js} +7 -7
- package/dist/bundle/{oauth-AYGX7CQS.js → oauth-WJRDUU5J.js} +8 -8
- package/dist/bundle/{open-MIL2TOT6.js → open-S2YSIEOW.js} +6 -6
- package/dist/bundle/openai-CRNZFNZD.js +25 -0
- package/dist/bundle/{output-file-4XADZPYH.js → output-file-6COFGPUL.js} +6 -6
- package/dist/bundle/{process-NJVQK6GB.js → process-XNN4WG6N.js} +1 -1
- package/dist/bundle/{program-WUYRS6H7.js → program-BRPJKRCX.js} +115 -187
- package/dist/bundle/{prompt-J4QPFLEA.js → prompt-7RQOL25I.js} +6 -6
- package/dist/bundle/{recognize-OLJZVNWW.js → recognize-N5WADGQB.js} +5 -5
- package/dist/bundle/{remote-JPUXNYLV.js → remote-WHYV35IF.js} +8 -8
- package/dist/bundle/{rerank-XVV3X5TT.js → rerank-FBMZVWSH.js} +8 -8
- package/dist/bundle/{run-log-DJXBEVS5.js → run-log-TOCHREH2.js} +59 -59
- package/dist/bundle/{serve-NYYUO3MR.js → serve-4BABX4WS.js} +10 -10
- package/dist/bundle/{server-4Z5E4YTT.js → server-CDVI6LOB.js} +47 -47
- package/dist/bundle/server-XOFQKFVO.js +72 -0
- package/dist/bundle/{services-EKWM76HP.js → services-PIY33I7R.js} +43 -33
- package/dist/bundle/{speech-WFJ44ACJ.js → speech-LS5Q4FL2.js} +14 -14
- package/dist/bundle/{state-VIRCT4VW.js → state-YUX5R2R7.js} +7 -7
- package/dist/bundle/{store-ZTDZ6UY5.js → store-BD7HAXAA.js} +20 -18
- package/dist/bundle/{store-2Q4GEZJS.js → store-ERMGBF2B.js} +49 -29
- package/dist/bundle/store-connection-JBR6CMTJ.js +83 -0
- package/dist/bundle/store-maintenance-command-I5DUSO2C.js +62 -0
- package/dist/bundle/{streaming-7BPKIGAS.js → streaming-O53PIORL.js} +7 -7
- package/dist/bundle/{tokens-CQHMMKNX.js → tokens-QKNEP2GJ.js} +7 -7
- package/dist/bundle/zm.js +9 -10
- package/dist/bundle/zoom-app-XJXZ4ZBX.js +41 -0
- package/dist/commands.d.ts.map +1 -1
- package/dist/commands.js +1 -0
- package/dist/commands.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +2 -3
- package/dist/config.js.map +1 -1
- package/dist/identity.d.ts +1 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +11 -0
- package/dist/identity.js.map +1 -1
- package/dist/program-bindings.d.ts.map +1 -1
- package/dist/program-bindings.js +7 -2
- package/dist/program-bindings.js.map +1 -1
- package/dist/setup-commands.d.ts +6 -0
- package/dist/setup-commands.d.ts.map +1 -1
- package/dist/setup-commands.js +24 -9
- package/dist/setup-commands.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/zoom-app.d.ts +32 -0
- package/dist/zoom-app.d.ts.map +1 -1
- package/dist/zoom-app.js +61 -0
- package/dist/zoom-app.js.map +1 -1
- package/package.json +3 -3
- package/dist/bundle/answer-policy-5OYUL6UF.js +0 -103
- package/dist/bundle/chunk-54RTMQL6.js +0 -132
- package/dist/bundle/chunk-6VFORXL3.js +0 -101
- package/dist/bundle/chunk-D4KBD63W.js +0 -19
- package/dist/bundle/chunk-SXFODCYK.js +0 -9
- package/dist/bundle/chunk-Z3WXI4DK.js +0 -31
- package/dist/bundle/command-contract-UWHY55UE.js +0 -41
- package/dist/bundle/config-TGF6E6ZD.js +0 -89
- package/dist/bundle/first-screen-PGFIXJAX.js +0 -39
- package/dist/bundle/openai-7QZZXQW5.js +0 -25
- package/dist/bundle/server-VW5UVCH7.js +0 -72
- package/dist/bundle/store-connection-FKVVQLEF.js +0 -83
- package/dist/bundle/store-maintenance-command-AU73UVUQ.js +0 -62
- package/dist/bundle/zoom-app-OEKFMJS6.js +0 -25
- /package/dist/bundle/{chunk-LU3WKZBA.js → chunk-VOXIGICJ.js} +0 -0
|
@@ -2,11 +2,11 @@ import { createRequire as __bundleRequire } from "node:module";
|
|
|
2
2
|
const require = __bundleRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
renderMessages
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-FNQASORM.js";
|
|
6
6
|
import {
|
|
7
7
|
answerOf,
|
|
8
8
|
messengerContext
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-US5C3WAY.js";
|
|
10
10
|
import {
|
|
11
11
|
chatEventAnswer,
|
|
12
12
|
memberAnswer,
|
|
@@ -15,14 +15,14 @@ import {
|
|
|
15
15
|
serveRelay,
|
|
16
16
|
typedQuery,
|
|
17
17
|
withQuery
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-2OSBCYJT.js";
|
|
19
19
|
import {
|
|
20
20
|
holdLock,
|
|
21
21
|
lockPath,
|
|
22
22
|
releaseLock,
|
|
23
23
|
servingProfiles,
|
|
24
24
|
takeLock
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-EH5QGQFR.js";
|
|
26
26
|
import {
|
|
27
27
|
FETCHING,
|
|
28
28
|
RULES_VERSION,
|
|
@@ -34,8 +34,16 @@ import {
|
|
|
34
34
|
patiently,
|
|
35
35
|
senderIsMe,
|
|
36
36
|
servicesFor,
|
|
37
|
-
syncsOneChat
|
|
38
|
-
|
|
37
|
+
syncsOneChat,
|
|
38
|
+
withTimeLimit
|
|
39
|
+
} from "./chunk-YTF2WPV4.js";
|
|
40
|
+
import {
|
|
41
|
+
QUICK_HEALTH_CHECKS,
|
|
42
|
+
explainDamage,
|
|
43
|
+
fts5Tables,
|
|
44
|
+
invalidJson,
|
|
45
|
+
storeHealth
|
|
46
|
+
} from "./chunk-4YFJYSSK.js";
|
|
39
47
|
import {
|
|
40
48
|
Command,
|
|
41
49
|
LOCAL_READ,
|
|
@@ -59,31 +67,36 @@ import {
|
|
|
59
67
|
snakeKeys,
|
|
60
68
|
storeTable,
|
|
61
69
|
withoutProviderRefs
|
|
62
|
-
} from "./chunk-
|
|
70
|
+
} from "./chunk-AJ7CMUGD.js";
|
|
63
71
|
import {
|
|
64
72
|
envName
|
|
65
|
-
} from "./chunk-
|
|
73
|
+
} from "./chunk-AVEIQMHZ.js";
|
|
66
74
|
import {
|
|
67
75
|
holdersOf
|
|
68
|
-
} from "./chunk-
|
|
76
|
+
} from "./chunk-DVA6MQWK.js";
|
|
69
77
|
import {
|
|
70
78
|
codeOf,
|
|
71
79
|
currentRun,
|
|
72
80
|
parseDuration
|
|
73
|
-
} from "./chunk-
|
|
81
|
+
} from "./chunk-JRCYFCPL.js";
|
|
74
82
|
import {
|
|
75
83
|
failureKey
|
|
76
|
-
} from "./chunk-
|
|
84
|
+
} from "./chunk-YOAEZSDG.js";
|
|
77
85
|
import {
|
|
78
86
|
levelFor
|
|
79
|
-
} from "./chunk-
|
|
87
|
+
} from "./chunk-65T3PU75.js";
|
|
80
88
|
import {
|
|
89
|
+
CORPORA,
|
|
81
90
|
MIGRATIONS,
|
|
91
|
+
drainCorpus,
|
|
92
|
+
drainMeetingIndex,
|
|
82
93
|
drainNoteIndex,
|
|
83
94
|
dropAllUnusedVectors,
|
|
84
95
|
fileFacts,
|
|
85
96
|
fillSearchIndex,
|
|
86
97
|
fillStems,
|
|
98
|
+
fillTrigrams,
|
|
99
|
+
fillVectorIndexes,
|
|
87
100
|
involvementStoreOver,
|
|
88
101
|
migrate,
|
|
89
102
|
noteIndexState,
|
|
@@ -92,10 +105,12 @@ import {
|
|
|
92
105
|
orphanPointers,
|
|
93
106
|
pendingNormalization,
|
|
94
107
|
readStoreTables,
|
|
108
|
+
rebuildMentions,
|
|
95
109
|
resetAttachmentWords,
|
|
96
110
|
resetNoteIndex,
|
|
97
111
|
resetSearchIndex,
|
|
98
112
|
resetStems,
|
|
113
|
+
rollBack,
|
|
99
114
|
rowCounts,
|
|
100
115
|
searchIndexState,
|
|
101
116
|
stemmerCache,
|
|
@@ -103,38 +118,38 @@ import {
|
|
|
103
118
|
storeClients,
|
|
104
119
|
storeContents,
|
|
105
120
|
vectorIndexCounts
|
|
106
|
-
} from "./chunk-
|
|
121
|
+
} from "./chunk-YQRNFG2E.js";
|
|
107
122
|
import {
|
|
108
123
|
formatLocator,
|
|
109
124
|
parseLocator
|
|
110
|
-
} from "./chunk-
|
|
125
|
+
} from "./chunk-NUJMJQXV.js";
|
|
111
126
|
import {
|
|
112
127
|
readSecret
|
|
113
|
-
} from "./chunk-
|
|
128
|
+
} from "./chunk-RRYUD2EF.js";
|
|
114
129
|
import {
|
|
115
130
|
checkedOptions,
|
|
116
131
|
range
|
|
117
|
-
} from "./chunk-
|
|
132
|
+
} from "./chunk-EZRPSZJS.js";
|
|
118
133
|
import {
|
|
119
134
|
messagesFor,
|
|
120
135
|
systemFor,
|
|
121
136
|
validateImages
|
|
122
|
-
} from "./chunk-
|
|
137
|
+
} from "./chunk-ZRD3NDOX.js";
|
|
123
138
|
import {
|
|
124
139
|
storePath
|
|
125
|
-
} from "./chunk-
|
|
140
|
+
} from "./chunk-32FPA7P2.js";
|
|
126
141
|
import {
|
|
127
142
|
openCache
|
|
128
|
-
} from "./chunk-
|
|
143
|
+
} from "./chunk-LV7QRR5S.js";
|
|
129
144
|
import {
|
|
130
145
|
queryFieldsOf
|
|
131
|
-
} from "./chunk-
|
|
146
|
+
} from "./chunk-B6JMVB6R.js";
|
|
132
147
|
import {
|
|
133
148
|
Credentials,
|
|
134
149
|
pathsAreOverridden,
|
|
135
150
|
resolvePaths,
|
|
136
151
|
writeSecurely
|
|
137
|
-
} from "./chunk-
|
|
152
|
+
} from "./chunk-KNE6VFHZ.js";
|
|
138
153
|
import {
|
|
139
154
|
array,
|
|
140
155
|
boolean,
|
|
@@ -158,10 +173,10 @@ import {
|
|
|
158
173
|
transform,
|
|
159
174
|
trim,
|
|
160
175
|
union
|
|
161
|
-
} from "./chunk-
|
|
176
|
+
} from "./chunk-NRRI37NJ.js";
|
|
162
177
|
import {
|
|
163
178
|
CliError
|
|
164
|
-
} from "./chunk-
|
|
179
|
+
} from "./chunk-FEM2JQN2.js";
|
|
165
180
|
import {
|
|
166
181
|
__commonJS,
|
|
167
182
|
__name,
|
|
@@ -1815,7 +1830,7 @@ var require_liquid_node = __commonJS({
|
|
|
1815
1830
|
return readFileAsync(filepath, "utf8");
|
|
1816
1831
|
}
|
|
1817
1832
|
__name(readFile, "readFile");
|
|
1818
|
-
function
|
|
1833
|
+
function existsSync10(filepath) {
|
|
1819
1834
|
try {
|
|
1820
1835
|
fs$1.statSync(filepath);
|
|
1821
1836
|
return true;
|
|
@@ -1823,11 +1838,11 @@ var require_liquid_node = __commonJS({
|
|
|
1823
1838
|
return false;
|
|
1824
1839
|
}
|
|
1825
1840
|
}
|
|
1826
|
-
__name(
|
|
1827
|
-
function
|
|
1841
|
+
__name(existsSync10, "existsSync");
|
|
1842
|
+
function readFileSync5(filepath) {
|
|
1828
1843
|
return fs$1.readFileSync(filepath, "utf8");
|
|
1829
1844
|
}
|
|
1830
|
-
__name(
|
|
1845
|
+
__name(readFileSync5, "readFileSync");
|
|
1831
1846
|
function resolve2(root, file2, ext) {
|
|
1832
1847
|
if (!path.extname(file2))
|
|
1833
1848
|
file2 += ext;
|
|
@@ -1841,10 +1856,10 @@ var require_liquid_node = __commonJS({
|
|
|
1841
1856
|
}
|
|
1842
1857
|
}
|
|
1843
1858
|
__name(fallback, "fallback");
|
|
1844
|
-
function
|
|
1859
|
+
function dirname3(filepath) {
|
|
1845
1860
|
return path.dirname(filepath);
|
|
1846
1861
|
}
|
|
1847
|
-
__name(
|
|
1862
|
+
__name(dirname3, "dirname");
|
|
1848
1863
|
var realpathAsync = promisify(fs$1.realpath);
|
|
1849
1864
|
async function contains(root, file2) {
|
|
1850
1865
|
try {
|
|
@@ -1872,11 +1887,11 @@ var require_liquid_node = __commonJS({
|
|
|
1872
1887
|
__proto__: null,
|
|
1873
1888
|
exists,
|
|
1874
1889
|
readFile,
|
|
1875
|
-
existsSync:
|
|
1876
|
-
readFileSync:
|
|
1890
|
+
existsSync: existsSync10,
|
|
1891
|
+
readFileSync: readFileSync5,
|
|
1877
1892
|
resolve: resolve2,
|
|
1878
1893
|
fallback,
|
|
1879
|
-
dirname:
|
|
1894
|
+
dirname: dirname3,
|
|
1880
1895
|
contains,
|
|
1881
1896
|
containsSync,
|
|
1882
1897
|
sep: path.sep
|
|
@@ -3601,7 +3616,7 @@ var require_liquid_node = __commonJS({
|
|
|
3601
3616
|
uri_escape,
|
|
3602
3617
|
slugify
|
|
3603
3618
|
});
|
|
3604
|
-
var
|
|
3619
|
+
var join5 = argumentsToValue(function(v, arg) {
|
|
3605
3620
|
const array2 = toArray(v);
|
|
3606
3621
|
const sep = isNil(arg) ? " " : stringify(arg);
|
|
3607
3622
|
let outputSize = sep.length * Math.max(array2.length - 1, 0);
|
|
@@ -3877,7 +3892,7 @@ var require_liquid_node = __commonJS({
|
|
|
3877
3892
|
__name(sample, "sample");
|
|
3878
3893
|
var arrayFilters = /* @__PURE__ */ Object.freeze({
|
|
3879
3894
|
__proto__: null,
|
|
3880
|
-
join:
|
|
3895
|
+
join: join5,
|
|
3881
3896
|
last,
|
|
3882
3897
|
first,
|
|
3883
3898
|
reverse,
|
|
@@ -5501,11 +5516,11 @@ var require_liquid_node = __commonJS({
|
|
|
5501
5516
|
}
|
|
5502
5517
|
});
|
|
5503
5518
|
|
|
5504
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5505
|
-
import { chmodSync, constants, copyFileSync, existsSync as
|
|
5506
|
-
import { dirname, resolve } from "node:path";
|
|
5519
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.604.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_90db47d7f41d7a563eea7bc9cc13c345/node_modules/@wirecat/cli-core/dist/cli/messenger/store-maintenance-command.js
|
|
5520
|
+
import { chmodSync, constants, copyFileSync, existsSync as existsSync9, mkdirSync, realpathSync as realpathSync2, renameSync as renameSync3, rmSync as rmSync3, statfsSync as statfsSync2, statSync as statSync4, writeFileSync as writeFileSync2 } from "node:fs";
|
|
5521
|
+
import { dirname as dirname2, resolve } from "node:path";
|
|
5507
5522
|
|
|
5508
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5523
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.604.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_90db47d7f41d7a563eea7bc9cc13c345/node_modules/@wirecat/cli-core/dist/sealed.js
|
|
5509
5524
|
import { createCipheriv, createDecipheriv, createHash, randomBytes, scrypt, timingSafeEqual } from "node:crypto";
|
|
5510
5525
|
import { closeSync, createReadStream, createWriteStream, existsSync, openSync, readSync, renameSync, rmSync, statSync } from "node:fs";
|
|
5511
5526
|
import { Transform } from "node:stream";
|
|
@@ -5612,7 +5627,7 @@ var unsealFile = /* @__PURE__ */ __name(async (from, to, password) => {
|
|
|
5612
5627
|
renameSync(pending, to);
|
|
5613
5628
|
}, "unsealFile");
|
|
5614
5629
|
|
|
5615
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5630
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.604.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_90db47d7f41d7a563eea7bc9cc13c345/node_modules/@wirecat/cli-core/dist/store/compatibility.js
|
|
5616
5631
|
var SPEAKS = MIGRATIONS.at(-1)?.version ?? 0;
|
|
5617
5632
|
var fileSchemaOf = /* @__PURE__ */ __name((database) => {
|
|
5618
5633
|
const tracked = database.prepare("SELECT 1 FROM sqlite_master WHERE name = 'schema_migrations'").get();
|
|
@@ -5636,7 +5651,7 @@ var compatibilityOf = /* @__PURE__ */ __name((file2, migrations = MIGRATIONS) =>
|
|
|
5636
5651
|
};
|
|
5637
5652
|
}, "compatibilityOf");
|
|
5638
5653
|
|
|
5639
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5654
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.604.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_90db47d7f41d7a563eea7bc9cc13c345/node_modules/@wirecat/cli-core/dist/store/repair.js
|
|
5640
5655
|
import { createHash as createHash2 } from "node:crypto";
|
|
5641
5656
|
var COPY_MARK = "__repair_";
|
|
5642
5657
|
var COPY_NAME = /__repair_[0-9a-f]{8}(_\d+)?$/;
|
|
@@ -5890,10 +5905,528 @@ var deleteCopy = /* @__PURE__ */ __name((database, name) => {
|
|
|
5890
5905
|
return found;
|
|
5891
5906
|
}, "deleteCopy");
|
|
5892
5907
|
|
|
5893
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5894
|
-
import { existsSync as
|
|
5908
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.604.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_90db47d7f41d7a563eea7bc9cc13c345/node_modules/@wirecat/cli-core/dist/cli/store-info.js
|
|
5909
|
+
import { existsSync as existsSync4, statSync as statSync3 } from "node:fs";
|
|
5910
|
+
|
|
5911
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.604.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_90db47d7f41d7a563eea7bc9cc13c345/node_modules/@wirecat/cli-core/dist/cli/store-recover.js
|
|
5912
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
5913
|
+
|
|
5914
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.604.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_90db47d7f41d7a563eea7bc9cc13c345/node_modules/@wirecat/cli-core/dist/store/recover.js
|
|
5915
|
+
import { execFileSync, spawn } from "node:child_process";
|
|
5916
|
+
import { existsSync as existsSync2, readFileSync, realpathSync, renameSync as renameSync2, rmSync as rmSync2, statfsSync, statSync as statSync2, writeFileSync } from "node:fs";
|
|
5917
|
+
import { basename, dirname, join } from "node:path";
|
|
5918
|
+
import { Transform as Transform2 } from "node:stream";
|
|
5919
|
+
var SQLITE3_MINIMUM = [3, 43, 0];
|
|
5920
|
+
var STORE_PARTS = ["", "-wal", "-shm"];
|
|
5921
|
+
var RECOVER_LOCK = ".recover-lock";
|
|
5922
|
+
var INSERTED = /^INSERT OR IGNORE INTO '([^']+)'/;
|
|
5923
|
+
var LOST_AND_FOUND = "recover_lost_and_found";
|
|
5924
|
+
var recovers = /* @__PURE__ */ __name((program) => {
|
|
5925
|
+
try {
|
|
5926
|
+
execFileSync(program, [":memory:", ".recover"], { stdio: ["ignore", "ignore", "pipe"] });
|
|
5927
|
+
return true;
|
|
5928
|
+
} catch {
|
|
5929
|
+
return false;
|
|
5930
|
+
}
|
|
5931
|
+
}, "recovers");
|
|
5932
|
+
var sqlite3Program = /* @__PURE__ */ __name((program = "sqlite3") => {
|
|
5933
|
+
let version = null;
|
|
5934
|
+
try {
|
|
5935
|
+
version = execFileSync(program, ["--version"], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).split(" ")[0] ?? null;
|
|
5936
|
+
} catch {
|
|
5937
|
+
return { program, version: null, usable: false };
|
|
5938
|
+
}
|
|
5939
|
+
const parts = (version ?? "").split(".").map(Number);
|
|
5940
|
+
const at = SQLITE3_MINIMUM.findIndex((wanted, i) => (parts[i] ?? 0) !== wanted);
|
|
5941
|
+
const recent = at === -1 || (parts[at] ?? 0) > (SQLITE3_MINIMUM[at] ?? 0);
|
|
5942
|
+
return { program, version, usable: recent && recovers(program) };
|
|
5943
|
+
}, "sqlite3Program");
|
|
5944
|
+
var activeTimers = /* @__PURE__ */ __name(() => {
|
|
5945
|
+
if (process.platform !== "linux")
|
|
5946
|
+
return void 0;
|
|
5947
|
+
try {
|
|
5948
|
+
return execFileSync("systemctl", ["--user", "list-timers", "--plain", "--no-legend"], {
|
|
5949
|
+
encoding: "utf8",
|
|
5950
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
5951
|
+
}).split("\n").map((line) => line.trim().split(/\s+/).at(-2) ?? "").filter((unit) => /^(memo|mail|tg|max|whatsapp|zoom|drive|gcal|wirecat)-.*\.timer$/.test(unit));
|
|
5952
|
+
} catch {
|
|
5953
|
+
return void 0;
|
|
5954
|
+
}
|
|
5955
|
+
}, "activeTimers");
|
|
5956
|
+
var alive = /* @__PURE__ */ __name((pid) => {
|
|
5957
|
+
try {
|
|
5958
|
+
process.kill(pid, 0);
|
|
5959
|
+
return true;
|
|
5960
|
+
} catch (error) {
|
|
5961
|
+
return error.code === "EPERM";
|
|
5962
|
+
}
|
|
5963
|
+
}, "alive");
|
|
5964
|
+
var runningRecovery = /* @__PURE__ */ __name((path) => {
|
|
5965
|
+
let pid;
|
|
5966
|
+
try {
|
|
5967
|
+
pid = Number(readFileSync(`${path}${RECOVER_LOCK}`, "utf8").trim());
|
|
5968
|
+
} catch {
|
|
5969
|
+
return null;
|
|
5970
|
+
}
|
|
5971
|
+
return Number.isInteger(pid) && pid > 0 && alive(pid) ? pid : null;
|
|
5972
|
+
}, "runningRecovery");
|
|
5973
|
+
var takeRecoverLock = /* @__PURE__ */ __name((path) => {
|
|
5974
|
+
const lock = `${path}${RECOVER_LOCK}`;
|
|
5975
|
+
const take = /* @__PURE__ */ __name(() => writeFileSync(lock, String(process.pid), { flag: "wx", mode: 384 }), "take");
|
|
5976
|
+
try {
|
|
5977
|
+
take();
|
|
5978
|
+
} catch (error) {
|
|
5979
|
+
if (error.code !== "EEXIST")
|
|
5980
|
+
throw error;
|
|
5981
|
+
const pid = runningRecovery(path);
|
|
5982
|
+
if (pid === null) {
|
|
5983
|
+
rmSync2(lock, { force: true });
|
|
5984
|
+
take();
|
|
5985
|
+
} else {
|
|
5986
|
+
throw new CliError("validation_error", `the store is being recovered by process ${pid} \u2014 wait for it to finish`, {
|
|
5987
|
+
reason: "store.recovering"
|
|
5988
|
+
});
|
|
5989
|
+
}
|
|
5990
|
+
}
|
|
5991
|
+
return () => rmSync2(lock, { force: true });
|
|
5992
|
+
}, "takeRecoverLock");
|
|
5993
|
+
var storeHolders = /* @__PURE__ */ __name((path) => {
|
|
5994
|
+
const folder = realpathSync(dirname(path));
|
|
5995
|
+
const files = STORE_PARTS.map((suffix) => join(folder, `${basename(path)}${suffix}`));
|
|
5996
|
+
const wanted = process.platform === "linux" ? files.flatMap((file2) => [file2, `${file2} (deleted)`]) : files.filter(existsSync2);
|
|
5997
|
+
const recovering = runningRecovery(path);
|
|
5998
|
+
const pids = holdersOf(wanted);
|
|
5999
|
+
if (pids === void 0 && recovering === null)
|
|
6000
|
+
return void 0;
|
|
6001
|
+
const all = [
|
|
6002
|
+
.../* @__PURE__ */ new Set([...pids ?? [], ...recovering !== null && recovering !== process.pid ? [recovering] : []])
|
|
6003
|
+
];
|
|
6004
|
+
return all.map((pid) => {
|
|
6005
|
+
let name = "?";
|
|
6006
|
+
try {
|
|
6007
|
+
name = readFileSync(`/proc/${pid}/comm`, "utf8").trim();
|
|
6008
|
+
} catch {
|
|
6009
|
+
}
|
|
6010
|
+
return { pid, name };
|
|
6011
|
+
});
|
|
6012
|
+
}, "storeHolders");
|
|
6013
|
+
var tableRows = /* @__PURE__ */ __name((database) => {
|
|
6014
|
+
const indexes = fts5Tables(database).map((index) => index.name);
|
|
6015
|
+
const tables = 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}_`)));
|
|
6016
|
+
return Object.fromEntries(tables.map((table) => {
|
|
6017
|
+
try {
|
|
6018
|
+
return [table, Number(database.prepare(`SELECT count(*) AS n FROM "${table}"`).get()?.n)];
|
|
6019
|
+
} catch {
|
|
6020
|
+
return [table, null];
|
|
6021
|
+
}
|
|
6022
|
+
}));
|
|
6023
|
+
}, "tableRows");
|
|
6024
|
+
var copyReadableRows = /* @__PURE__ */ __name((path, target, program = "sqlite3") => new Promise((resolve2, reject) => {
|
|
6025
|
+
const reader = spawn(program, ["-readonly", path, `.recover --ignore-freelist --lost-and-found ${LOST_AND_FOUND}`], {
|
|
6026
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
6027
|
+
});
|
|
6028
|
+
const writer = spawn(program, ["-cmd", ".dbconfig defensive off", target], { stdio: ["pipe", "ignore", "pipe"] });
|
|
6029
|
+
const errors = [];
|
|
6030
|
+
const collect = /* @__PURE__ */ __name((chunk) => {
|
|
6031
|
+
for (const line of chunk.toString("utf8").split("\n"))
|
|
6032
|
+
if (line && errors.length < 50)
|
|
6033
|
+
errors.push(line.slice(0, 300));
|
|
6034
|
+
}, "collect");
|
|
6035
|
+
reader.stderr.on("data", collect);
|
|
6036
|
+
writer.stderr.on("data", collect);
|
|
6037
|
+
const read = {};
|
|
6038
|
+
let rest = "";
|
|
6039
|
+
const counter = new Transform2({
|
|
6040
|
+
transform(chunk, _encoding, done) {
|
|
6041
|
+
const lines = (rest + chunk.toString("latin1")).split("\n");
|
|
6042
|
+
rest = lines.pop() ?? "";
|
|
6043
|
+
for (const line of lines) {
|
|
6044
|
+
const table = INSERTED.exec(line)?.[1];
|
|
6045
|
+
if (table)
|
|
6046
|
+
read[table] = (read[table] ?? 0) + 1;
|
|
6047
|
+
}
|
|
6048
|
+
done(null, chunk);
|
|
6049
|
+
}
|
|
6050
|
+
});
|
|
6051
|
+
reader.stdout.pipe(counter).pipe(writer.stdin);
|
|
6052
|
+
let exits = 0;
|
|
6053
|
+
let readerCode = null;
|
|
6054
|
+
const exited = /* @__PURE__ */ __name(() => {
|
|
6055
|
+
exits += 1;
|
|
6056
|
+
if (exits < 2)
|
|
6057
|
+
return;
|
|
6058
|
+
if (readerCode !== 0)
|
|
6059
|
+
reject(new CliError("validation_error", `sqlite3 could not read the store: ${errors.join("; ")}`));
|
|
6060
|
+
else
|
|
6061
|
+
resolve2({ errors, read });
|
|
6062
|
+
}, "exited");
|
|
6063
|
+
reader.on("error", reject);
|
|
6064
|
+
writer.on("error", reject);
|
|
6065
|
+
reader.on("close", (code) => {
|
|
6066
|
+
readerCode = code;
|
|
6067
|
+
exited();
|
|
6068
|
+
});
|
|
6069
|
+
writer.on("close", exited);
|
|
6070
|
+
}), "copyReadableRows");
|
|
6071
|
+
var FILLERS = {
|
|
6072
|
+
message_words: /* @__PURE__ */ __name((database, now) => {
|
|
6073
|
+
resetSearchIndex(database);
|
|
6074
|
+
fillSearchIndex(database, { now });
|
|
6075
|
+
}, "message_words"),
|
|
6076
|
+
message_stems: /* @__PURE__ */ __name((database, now) => {
|
|
6077
|
+
resetStems(database, { force: true, now });
|
|
6078
|
+
fillStems(database, { now });
|
|
6079
|
+
}, "message_stems"),
|
|
6080
|
+
attachment_words: /* @__PURE__ */ __name((database) => void resetAttachmentWords(database), "attachment_words"),
|
|
6081
|
+
attachment_name_words: /* @__PURE__ */ __name((database) => (
|
|
6082
|
+
// As migration 20 filled it: й and ё fold as the triggers fold them.
|
|
6083
|
+
database.exec("INSERT INTO attachment_name_words (rowid, name) SELECT id, replace(replace(replace(replace(name, '\u0439', '\u0438'), '\u0419', '\u0418'), '\u0451', '\u0435'), '\u0401', '\u0415') FROM attachments WHERE name IS NOT NULL")
|
|
6084
|
+
), "attachment_name_words"),
|
|
6085
|
+
meeting_words: /* @__PURE__ */ __name((database) => {
|
|
6086
|
+
database.exec("INSERT OR IGNORE INTO meeting_index_pending (indexable_type, id) SELECT 'meeting_transcript_row', id FROM meeting_transcript_rows UNION ALL SELECT 'meeting_chat_message', id FROM meeting_chat_messages UNION ALL SELECT 'meeting_summary', id FROM meeting_summaries");
|
|
6087
|
+
drainMeetingIndex(database);
|
|
6088
|
+
}, "meeting_words"),
|
|
6089
|
+
// Built per account by the first search that needs them.
|
|
6090
|
+
meeting_stems: /* @__PURE__ */ __name((database) => database.exec("UPDATE search_index_state SET filled_through = 0, built_at = NULL WHERE name LIKE 'meeting_stems:%'"), "meeting_stems")
|
|
6091
|
+
};
|
|
6092
|
+
var CORPUS_TABLES = new Set(Object.values(CORPORA).flatMap((corpus) => [`${corpus.type}_words`, `${corpus.type}_stems`]));
|
|
6093
|
+
var TRIGRAMS = ["note_trigrams", "document_trigrams"];
|
|
6094
|
+
var rebuildDerived = /* @__PURE__ */ __name((database, { now = Date.now, note = /* @__PURE__ */ __name(() => {
|
|
6095
|
+
}, "note") } = {}) => {
|
|
6096
|
+
const lost = database.prepare("SELECT 1 FROM sqlite_master WHERE name = ?").get(LOST_AND_FOUND);
|
|
6097
|
+
const lostAndFound = lost ? Number(database.prepare(`SELECT count(*) AS n FROM ${LOST_AND_FOUND}`).get()?.n) : 0;
|
|
6098
|
+
if (lost)
|
|
6099
|
+
database.exec(`DROP TABLE ${LOST_AND_FOUND}`);
|
|
6100
|
+
const indexes = fts5Tables(database);
|
|
6101
|
+
for (const { name, sql } of indexes) {
|
|
6102
|
+
database.exec(`DROP TABLE "${name}"`);
|
|
6103
|
+
database.exec(sql);
|
|
6104
|
+
}
|
|
6105
|
+
const vectors = database.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name GLOB 'vector_index_[0-9]*' AND sql LIKE 'CREATE VIRTUAL%'").all().map((row) => String(row.name));
|
|
6106
|
+
for (const table of vectors) {
|
|
6107
|
+
database.exec(`DROP TRIGGER IF EXISTS "${table}_redo"`);
|
|
6108
|
+
database.exec(`DROP TABLE "${table}"`);
|
|
6109
|
+
database.prepare("DELETE FROM vector_indexes WHERE id = ?").run(Number(table.replace("vector_index_", "")));
|
|
6110
|
+
}
|
|
6111
|
+
const unfilled = [];
|
|
6112
|
+
const stemmerFor = stemmerCache();
|
|
6113
|
+
for (const { name, external } of indexes) {
|
|
6114
|
+
note(`rebuilding ${name}`);
|
|
6115
|
+
if (external)
|
|
6116
|
+
database.exec(`INSERT INTO "${name}" ("${name}") VALUES ('rebuild')`);
|
|
6117
|
+
else if (FILLERS[name])
|
|
6118
|
+
FILLERS[name](database, now);
|
|
6119
|
+
else if (!CORPUS_TABLES.has(name) && !TRIGRAMS.includes(name))
|
|
6120
|
+
unfilled.push(name);
|
|
6121
|
+
}
|
|
6122
|
+
note("rebuilding the words of notes, documents, memories, mail, tasks, transcripts and events");
|
|
6123
|
+
resetNoteIndex(database);
|
|
6124
|
+
for (const corpus of Object.values(CORPORA))
|
|
6125
|
+
drainCorpus(database, corpus, stemmerFor);
|
|
6126
|
+
for (const name of TRIGRAMS) {
|
|
6127
|
+
const type = name.replace("_trigrams", "");
|
|
6128
|
+
database.prepare(`UPDATE search_index_state SET filled_through = 0, watermark = (SELECT coalesce(max(id), 0) FROM ${type}s) WHERE name = ?`).run(name);
|
|
6129
|
+
}
|
|
6130
|
+
fillTrigrams(database);
|
|
6131
|
+
note("finding mentions again");
|
|
6132
|
+
const mentions = rebuildMentions(database, { now: now() }).mentions;
|
|
6133
|
+
involvementStoreOver({ database, now }).rebuild();
|
|
6134
|
+
note("indexing the stored vectors");
|
|
6135
|
+
const vectorModels = fillVectorIndexes(database);
|
|
6136
|
+
const without = database.prepare("SELECT count(*) AS n FROM chunks k WHERE NOT EXISTS (SELECT 1 FROM embeddings v WHERE v.model = ? AND v.content_hash = k.content_hash)");
|
|
6137
|
+
const chunksWithoutVector = Object.fromEntries(database.prepare("SELECT model FROM vector_indexes ORDER BY model").all().map((row) => [String(row.model), Number(without.get(String(row.model))?.n)]));
|
|
6138
|
+
return {
|
|
6139
|
+
lostAndFound,
|
|
6140
|
+
searchIndexes: indexes.map((index) => index.name),
|
|
6141
|
+
unfilled,
|
|
6142
|
+
mentions,
|
|
6143
|
+
vectorModels,
|
|
6144
|
+
chunksWithoutVector
|
|
6145
|
+
};
|
|
6146
|
+
}, "rebuildDerived");
|
|
6147
|
+
var danglingRows = /* @__PURE__ */ __name((database) => database.prepare(`SELECT "table" AS child, parent, fkid, count(*) AS n FROM pragma_foreign_key_check GROUP BY 1, 2, 3 ORDER BY 4 DESC`).all().map((group) => {
|
|
6148
|
+
const child = String(group.child);
|
|
6149
|
+
const column = database.prepare(`SELECT "from" AS name FROM pragma_foreign_key_list(?) WHERE id = ? ORDER BY seq LIMIT 1`).get(child, Number(group.fkid))?.name;
|
|
6150
|
+
let missing = [];
|
|
6151
|
+
try {
|
|
6152
|
+
missing = database.prepare(`SELECT DISTINCT "${String(column)}" AS id FROM "${child}" WHERE rowid IN (SELECT rowid FROM pragma_foreign_key_check(?) WHERE fkid = ?) ORDER BY 1 LIMIT 20`).all(child, Number(group.fkid)).map((row) => typeof row.id === "number" ? row.id : String(row.id));
|
|
6153
|
+
} catch {
|
|
6154
|
+
}
|
|
6155
|
+
return { table: child, parent: String(group.parent), rows: Number(group.n), missing };
|
|
6156
|
+
}), "danglingRows");
|
|
6157
|
+
var mailToFetch = /* @__PURE__ */ __name((database) => {
|
|
6158
|
+
try {
|
|
6159
|
+
return database.prepare(`SELECT a.external_id AS account, count(DISTINCT l.email_id) AS n FROM email_locations l
|
|
6160
|
+
JOIN mailboxes b ON b.id = l.mailbox_id JOIN accounts a ON a.id = b.account_id
|
|
6161
|
+
WHERE NOT EXISTS (SELECT 1 FROM emails e WHERE e.id = l.email_id) GROUP BY a.id ORDER BY a.external_id`).all().map((row) => ({ account: String(row.account), emails: Number(row.n) }));
|
|
6162
|
+
} catch {
|
|
6163
|
+
return [];
|
|
6164
|
+
}
|
|
6165
|
+
}, "mailToFetch");
|
|
6166
|
+
var clearInvalidJson = /* @__PURE__ */ __name((database) => {
|
|
6167
|
+
const found = invalidJson(database);
|
|
6168
|
+
for (const { table, column, required } of found) {
|
|
6169
|
+
const invalid = `"${column}" IS NOT NULL AND NOT json_valid("${column}")`;
|
|
6170
|
+
database.exec(required ? `DELETE FROM "${table}" WHERE ${invalid}` : `UPDATE "${table}" SET "${column}" = NULL WHERE ${invalid}`);
|
|
6171
|
+
}
|
|
6172
|
+
return found;
|
|
6173
|
+
}, "clearInvalidJson");
|
|
6174
|
+
var refuseInUse = /* @__PURE__ */ __name((path) => {
|
|
6175
|
+
const holders = storeHolders(path);
|
|
6176
|
+
if (holders && holders.length > 0) {
|
|
6177
|
+
const timers = activeTimers() ?? [];
|
|
6178
|
+
throw new CliError("validation_error", `the store is open in ${holders.map(({ pid, name }) => `${name} (process ${pid})`).join(", ")} \u2014 stop it first` + (timers.length ? `, and the timers: systemctl --user stop ${timers.join(" ")}` : ""), { reason: "store.in-use" });
|
|
6179
|
+
}
|
|
6180
|
+
}, "refuseInUse");
|
|
6181
|
+
var recoverStore = /* @__PURE__ */ __name(async ({ path, command, version, sqlite3 = "sqlite3", now = Date.now, note = /* @__PURE__ */ __name(() => {
|
|
6182
|
+
}, "note"), copy }) => {
|
|
6183
|
+
const started = Date.now();
|
|
6184
|
+
if (!existsSync2(path))
|
|
6185
|
+
throw new CliError("not_found", `no store at ${path}`);
|
|
6186
|
+
const program = copy ? { program: sqlite3, version: "given", usable: true } : sqlite3Program(sqlite3);
|
|
6187
|
+
if (!program.usable) {
|
|
6188
|
+
throw new CliError("configuration_error", program.version ? `sqlite3 ${program.version} cannot recover: the recovery needs ${SQLITE3_MINIMUM.join(".")} or newer, built with .recover` : "the recovery needs the sqlite3 program with its .recover command: install it (apt install sqlite3, brew install sqlite)", { reason: "store.sqlite3-missing" });
|
|
6189
|
+
}
|
|
6190
|
+
const releaseLock2 = takeRecoverLock(path);
|
|
6191
|
+
try {
|
|
6192
|
+
refuseInUse(path);
|
|
6193
|
+
const bytes = STORE_PARTS.reduce((sum, suffix) => sum + (statSync2(`${path}${suffix}`, { throwIfNoEntry: false })?.size ?? 0), 0);
|
|
6194
|
+
const { bavail, bsize } = statfsSync(dirname(path));
|
|
6195
|
+
if (Number(bavail) * Number(bsize) < bytes * 1.2)
|
|
6196
|
+
throw new CliError("validation_error", `the recovery needs about ${Math.ceil(bytes * 1.2 / 1e9)} GB free beside the store`);
|
|
6197
|
+
return await recoverLocked({ path, command, version, sqlite3, now, note, copy, started, program });
|
|
6198
|
+
} finally {
|
|
6199
|
+
releaseLock2();
|
|
6200
|
+
}
|
|
6201
|
+
}, "recoverStore");
|
|
6202
|
+
var recoverLocked = /* @__PURE__ */ __name(async ({ path, command, version, sqlite3, now, note, copy, started, program }) => {
|
|
6203
|
+
const watch = (await openSqlite(path, { readOnly: true })).database;
|
|
6204
|
+
let watching = true;
|
|
6205
|
+
const stopWatching = /* @__PURE__ */ __name(() => {
|
|
6206
|
+
if (watching)
|
|
6207
|
+
watch.close();
|
|
6208
|
+
watching = false;
|
|
6209
|
+
}, "stopWatching");
|
|
6210
|
+
try {
|
|
6211
|
+
const dataVersion = /* @__PURE__ */ __name(() => Number(watch.prepare("PRAGMA data_version").get()?.data_version), "dataVersion");
|
|
6212
|
+
const rowsBefore = tableRows(watch);
|
|
6213
|
+
const before = { data: dataVersion(), inode: statSync2(path).ino };
|
|
6214
|
+
const stamp = new Date(now()).toISOString().replace(/[:.]/g, "-");
|
|
6215
|
+
const target = `${path}.recovering-${stamp}`;
|
|
6216
|
+
writeFileSync(target, "", { flag: "wx", mode: 384 });
|
|
6217
|
+
const dropTarget = /* @__PURE__ */ __name(() => {
|
|
6218
|
+
for (const suffix of [...STORE_PARTS, "-journal"])
|
|
6219
|
+
rmSync2(`${target}${suffix}`, { force: true });
|
|
6220
|
+
}, "dropTarget");
|
|
6221
|
+
note(`copying the readable rows into ${target}`);
|
|
6222
|
+
let copied;
|
|
6223
|
+
let copyErrors;
|
|
6224
|
+
let read;
|
|
6225
|
+
let opened;
|
|
6226
|
+
try {
|
|
6227
|
+
;
|
|
6228
|
+
({ errors: copyErrors, read } = await (copy ?? ((from, to) => copyReadableRows(from, to, sqlite3)))(path, target));
|
|
6229
|
+
copied = Date.now();
|
|
6230
|
+
opened = await openSqlite(target);
|
|
6231
|
+
} catch (error) {
|
|
6232
|
+
dropTarget();
|
|
6233
|
+
throw error;
|
|
6234
|
+
}
|
|
6235
|
+
let rebuilt;
|
|
6236
|
+
let kept;
|
|
6237
|
+
let dangling;
|
|
6238
|
+
let json;
|
|
6239
|
+
let fetch2;
|
|
6240
|
+
try {
|
|
6241
|
+
kept = tableRows(opened.database);
|
|
6242
|
+
migrate(opened.database, { command, ...version ? { version } : {} });
|
|
6243
|
+
note("clearing values that are not valid JSON");
|
|
6244
|
+
json = clearInvalidJson(opened.database);
|
|
6245
|
+
rebuilt = rebuildDerived(opened.database, { now, note });
|
|
6246
|
+
note("looking for rows that point at rows that were lost");
|
|
6247
|
+
dangling = danglingRows(opened.database);
|
|
6248
|
+
fetch2 = mailToFetch(opened.database);
|
|
6249
|
+
opened.database.exec("PRAGMA wal_checkpoint(TRUNCATE)");
|
|
6250
|
+
} catch (error) {
|
|
6251
|
+
opened.database.close();
|
|
6252
|
+
dropTarget();
|
|
6253
|
+
throw error;
|
|
6254
|
+
}
|
|
6255
|
+
opened.database.close();
|
|
6256
|
+
const rebuiltAt = Date.now();
|
|
6257
|
+
note("checking the recovered file");
|
|
6258
|
+
const health = await storeHealth(target, { deep: true });
|
|
6259
|
+
const checkedAt = Date.now();
|
|
6260
|
+
if (!health.ok) {
|
|
6261
|
+
throw new CliError("validation_error", `the recovered file did not pass its check, so the store was left as it was; the file is kept at ${target}`, { reason: "store.recovery-failed" });
|
|
6262
|
+
}
|
|
6263
|
+
refuseInUse(path);
|
|
6264
|
+
const changed = dataVersion() !== before.data || statSync2(path, { throwIfNoEntry: false })?.ino !== before.inode;
|
|
6265
|
+
stopWatching();
|
|
6266
|
+
if (changed) {
|
|
6267
|
+
throw new CliError("validation_error", `the store was written to during the recovery, so it was left as it was \u2014 stop every timer and run it again; ${target} can be deleted`, { reason: "store.changed-during-recovery" });
|
|
6268
|
+
}
|
|
6269
|
+
const keptAt = `${path}.before-recover-${stamp}`;
|
|
6270
|
+
for (const suffix of STORE_PARTS)
|
|
6271
|
+
if (existsSync2(`${path}${suffix}`))
|
|
6272
|
+
renameSync2(`${path}${suffix}`, `${keptAt}${suffix}`);
|
|
6273
|
+
for (const suffix of STORE_PARTS)
|
|
6274
|
+
if (existsSync2(`${target}${suffix}`))
|
|
6275
|
+
renameSync2(`${target}${suffix}`, `${path}${suffix}`);
|
|
6276
|
+
const lost = Object.entries(rowsBefore).map(([table, before2]) => ({ table, before: before2, read: read[table] ?? 0, kept: kept[table] ?? 0 })).filter(({ before: before2, read: read2, kept: kept2 }) => before2 === null || before2 > kept2 || read2 > kept2);
|
|
6277
|
+
const seconds = /* @__PURE__ */ __name((from, to) => Math.round((to - from) / 100) / 10, "seconds");
|
|
6278
|
+
return {
|
|
6279
|
+
path,
|
|
6280
|
+
keptAt,
|
|
6281
|
+
sqlite3: program.version,
|
|
6282
|
+
lost,
|
|
6283
|
+
dangling,
|
|
6284
|
+
invalidJson: json,
|
|
6285
|
+
mailToFetch: fetch2,
|
|
6286
|
+
rebuilt,
|
|
6287
|
+
copyErrors,
|
|
6288
|
+
health,
|
|
6289
|
+
seconds: {
|
|
6290
|
+
copy: seconds(started, copied),
|
|
6291
|
+
rebuild: seconds(copied, rebuiltAt),
|
|
6292
|
+
check: seconds(rebuiltAt, checkedAt),
|
|
6293
|
+
total: seconds(started, Date.now())
|
|
6294
|
+
}
|
|
6295
|
+
};
|
|
6296
|
+
} finally {
|
|
6297
|
+
stopWatching();
|
|
6298
|
+
}
|
|
6299
|
+
}, "recoverLocked");
|
|
6300
|
+
|
|
6301
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.604.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_90db47d7f41d7a563eea7bc9cc13c345/node_modules/@wirecat/cli-core/dist/cli/store-recover.js
|
|
6302
|
+
var COUNTED = [
|
|
6303
|
+
"accounts",
|
|
6304
|
+
"chats",
|
|
6305
|
+
"messages",
|
|
6306
|
+
"attachments",
|
|
6307
|
+
"emails",
|
|
6308
|
+
"documents",
|
|
6309
|
+
"notes",
|
|
6310
|
+
"meetings",
|
|
6311
|
+
"chunks",
|
|
6312
|
+
"embeddings",
|
|
6313
|
+
"mentions"
|
|
6314
|
+
];
|
|
6315
|
+
var stopTimers = /* @__PURE__ */ __name((timers) => `systemctl --user stop ${timers.join(" ")}`, "stopTimers");
|
|
6316
|
+
var storeRecoveryCheck = /* @__PURE__ */ __name(async (env, command) => {
|
|
6317
|
+
const path = storePath(env);
|
|
6318
|
+
if (!existsSync3(path))
|
|
6319
|
+
return { path, exists: false, ok: true, next: [] };
|
|
6320
|
+
const health = await storeHealth(path, { deep: true });
|
|
6321
|
+
let rows = {};
|
|
6322
|
+
try {
|
|
6323
|
+
const { database } = await openSqlite(path, { readOnly: true });
|
|
6324
|
+
try {
|
|
6325
|
+
const all = tableRows(database);
|
|
6326
|
+
rows = Object.fromEntries(COUNTED.filter((table) => table in all).map((table) => [table, all[table] ?? null]));
|
|
6327
|
+
} finally {
|
|
6328
|
+
database.close();
|
|
6329
|
+
}
|
|
6330
|
+
} catch {
|
|
6331
|
+
}
|
|
6332
|
+
const explanation = explainDamage(health, command);
|
|
6333
|
+
const inUse = storeHolders(path) ?? null;
|
|
6334
|
+
const timers = activeTimers() ?? null;
|
|
6335
|
+
const sqlite3 = sqlite3Program();
|
|
6336
|
+
const next = health.ok ? [] : [
|
|
6337
|
+
...timers?.length ? [stopTimers(timers)] : [],
|
|
6338
|
+
...(inUse ?? []).map(({ pid, name }) => `stop ${name} (process ${pid}): it has the store open`),
|
|
6339
|
+
...sqlite3.usable ? [] : ["install sqlite3 3.43 or newer (apt install sqlite3, brew install sqlite)"],
|
|
6340
|
+
`${command} store recover run`
|
|
6341
|
+
];
|
|
6342
|
+
return {
|
|
6343
|
+
path,
|
|
6344
|
+
exists: true,
|
|
6345
|
+
ok: health.ok,
|
|
6346
|
+
seconds: Math.round(health.ms / 100) / 10,
|
|
6347
|
+
problems: health.problems ?? 0,
|
|
6348
|
+
damagedTables: health.damagedTables ?? [],
|
|
6349
|
+
damagedSearchIndexes: (health.searchIndexes ?? []).filter((index) => !index.ok).map(({ name, error }) => ({ name, ...error ? { error } : {} })),
|
|
6350
|
+
invalidJson: health.invalidJson ?? [],
|
|
6351
|
+
rows,
|
|
6352
|
+
explanation,
|
|
6353
|
+
inUse,
|
|
6354
|
+
timers,
|
|
6355
|
+
sqlite3: { version: sqlite3.version, usable: sqlite3.usable },
|
|
6356
|
+
next
|
|
6357
|
+
};
|
|
6358
|
+
}, "storeRecoveryCheck");
|
|
6359
|
+
var storeRecoveryRun = /* @__PURE__ */ __name(async (env, { command, version, note, timers: scheduled = activeTimers, copy }) => {
|
|
6360
|
+
const timers = scheduled() ?? [];
|
|
6361
|
+
if (timers.length > 0)
|
|
6362
|
+
throw new CliError("validation_error", `stop the timers first, they open the store: ${stopTimers(timers)}`, {
|
|
6363
|
+
reason: "store.in-use"
|
|
6364
|
+
});
|
|
6365
|
+
const recovery = await recoverStore({
|
|
6366
|
+
path: storePath(env),
|
|
6367
|
+
command,
|
|
6368
|
+
...version ? { version } : {},
|
|
6369
|
+
...note ? { note } : {},
|
|
6370
|
+
...copy ? { copy } : {}
|
|
6371
|
+
});
|
|
6372
|
+
const mail = recovery.mailToFetch.map(({ account, emails }) => `mail <profile of ${account}> sync --rescan # ${emails} emails`);
|
|
6373
|
+
const lostMail = recovery.lost.some(({ table }) => table === "emails") && mail.length === 0 ? ["mail <profile> sync --rescan # each mail profile"] : [];
|
|
6374
|
+
const { health, copyErrors, ...kept } = recovery;
|
|
6375
|
+
return {
|
|
6376
|
+
...kept,
|
|
6377
|
+
copyErrors: copyErrors.length,
|
|
6378
|
+
checkedOk: health.ok,
|
|
6379
|
+
next: [...mail, ...lostMail, "systemctl --user start <the timers stopped before>"]
|
|
6380
|
+
};
|
|
6381
|
+
}, "storeRecoveryRun");
|
|
6382
|
+
var recoveryNotes = /* @__PURE__ */ __name((answer) => {
|
|
6383
|
+
if ("keptAt" in answer) {
|
|
6384
|
+
const lost = answer.lost.map(({ table, before, read, kept }) => `${table}: ${kept} kept of ${before ?? "an uncountable number"}${read > kept ? `, ${read - kept} read but unusable` : ""}`);
|
|
6385
|
+
return [
|
|
6386
|
+
`recovered in ${answer.seconds.total} s; the damaged file is kept at ${answer.keptAt}`,
|
|
6387
|
+
...lost.length ? lost : ["no table lost a row"],
|
|
6388
|
+
...answer.dangling.map(({ table, parent, rows }) => `${rows} rows of ${table} point at ${parent} rows the store does not hold`),
|
|
6389
|
+
...answer.invalidJson.map(({ table, column, rows, required }) => `${table}.${column}: ${rows} values were not valid JSON \u2014 ${required ? "those rows were dropped" : "set to empty"}`),
|
|
6390
|
+
...answer.next.map((line) => `next: ${line}`)
|
|
6391
|
+
];
|
|
6392
|
+
}
|
|
6393
|
+
if (!answer.exists)
|
|
6394
|
+
return ["no store yet"];
|
|
6395
|
+
if (answer.ok)
|
|
6396
|
+
return [`the store is healthy (checked every page and search index in ${answer.seconds} s)`];
|
|
6397
|
+
const why = answer.explanation;
|
|
6398
|
+
return [
|
|
6399
|
+
...why ? [why.what, ...why.impact, why.externalUnaffected] : [],
|
|
6400
|
+
...answer.next.map((line) => `next: ${line}`)
|
|
6401
|
+
];
|
|
6402
|
+
}, "recoveryNotes");
|
|
6403
|
+
var storeRecoverCommand = /* @__PURE__ */ __name(({ command, version }) => {
|
|
6404
|
+
const recover = annotate(new Command("recover"), { effects: LOCAL_READ, examples: [`${command} store recover`] }).summary("what is damaged in the store and how to recover it").description("check every page and search index of the store, say what is damaged, what it means and the commands that recover it; changes nothing").action(async function() {
|
|
6405
|
+
const output = outputFor(this);
|
|
6406
|
+
const answer = await storeRecoveryCheck(environmentOf(this).env ?? process.env, command);
|
|
6407
|
+
renderAnswer(this, output, itemOf(snakeKeys(answer)));
|
|
6408
|
+
if (output.format === "pretty")
|
|
6409
|
+
for (const line of recoveryNotes(answer))
|
|
6410
|
+
output.renderer.note(line);
|
|
6411
|
+
});
|
|
6412
|
+
recover.addCommand(annotate(new Command("run"), { effects: LOCAL_WRITE, examples: [`${command} store recover run`] }).summary("rebuild a damaged store from every row it can read").description("copy every readable row into a new file with the sqlite3 program, rebuild the search indexes, mentions and vector index, check it, and put it in place of the store; the damaged file is kept beside it. Refuses while a WireCat timer or process has the store").action(async function() {
|
|
6413
|
+
const output = outputFor(this);
|
|
6414
|
+
const answer = await storeRecoveryRun(environmentOf(this).env ?? process.env, {
|
|
6415
|
+
command,
|
|
6416
|
+
...version ? { version } : {},
|
|
6417
|
+
note: /* @__PURE__ */ __name((text) => output.renderer.note(text), "note")
|
|
6418
|
+
});
|
|
6419
|
+
renderAnswer(this, output, itemOf(snakeKeys(answer)));
|
|
6420
|
+
if (output.format === "pretty")
|
|
6421
|
+
for (const line of recoveryNotes(answer))
|
|
6422
|
+
output.renderer.note(line);
|
|
6423
|
+
}));
|
|
6424
|
+
return recover;
|
|
6425
|
+
}, "storeRecoverCommand");
|
|
6426
|
+
|
|
6427
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.604.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_90db47d7f41d7a563eea7bc9cc13c345/node_modules/@wirecat/cli-core/dist/cli/store-info.js
|
|
5895
6428
|
var pendingIfKnown = /* @__PURE__ */ __name((database) => database.prepare("SELECT 1 FROM pragma_table_info('messages') WHERE name = 'normalized_text'").get() ? pendingNormalization(database) : null, "pendingIfKnown");
|
|
5896
|
-
var bytesOf = /* @__PURE__ */ __name((path) =>
|
|
6429
|
+
var bytesOf = /* @__PURE__ */ __name((path) => existsSync4(path) ? statSync3(path).size : 0, "bytesOf");
|
|
5897
6430
|
var messageOf = /* @__PURE__ */ __name((error) => error instanceof Error ? error.message : String(error), "messageOf");
|
|
5898
6431
|
var contentsOf = /* @__PURE__ */ __name((database, version, writable) => version > 0 && writable ? {
|
|
5899
6432
|
rows: rowCounts(database),
|
|
@@ -5904,7 +6437,7 @@ var contentsOf = /* @__PURE__ */ __name((database, version, writable) => version
|
|
|
5904
6437
|
} : { rows: {}, pendingNormalization: null, wordIndex: null, stemIndex: null }, "contentsOf");
|
|
5905
6438
|
var storeInfo = /* @__PURE__ */ __name(async (env) => {
|
|
5906
6439
|
const path = storePath(env);
|
|
5907
|
-
if (!
|
|
6440
|
+
if (!existsSync4(path))
|
|
5908
6441
|
return snakeKeys({ path, exists: false, schema: compatibilityOf(void 0) });
|
|
5909
6442
|
let schema = compatibilityOf(void 0);
|
|
5910
6443
|
try {
|
|
@@ -5936,9 +6469,12 @@ var storeInfoCommand = /* @__PURE__ */ __name(() => annotate(new Command("info")
|
|
|
5936
6469
|
const answer = await storeInfo(environmentOf(this).env ?? process.env);
|
|
5937
6470
|
renderAnswer(this, outputFor(this), itemOf(answer));
|
|
5938
6471
|
}), "storeInfoCommand");
|
|
5939
|
-
var sharedStoreCommand = /* @__PURE__ */ __name(() =>
|
|
6472
|
+
var sharedStoreCommand = /* @__PURE__ */ __name((app) => {
|
|
6473
|
+
const store = annotate(new Command("store"), { effects: LOCAL_READ }).description("the shared local store every WireCat tool reads").addCommand(storeInfoCommand());
|
|
6474
|
+
return app ? store.addCommand(storeRecoverCommand(app)) : store;
|
|
6475
|
+
}, "sharedStoreCommand");
|
|
5940
6476
|
|
|
5941
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6477
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.604.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_90db47d7f41d7a563eea7bc9cc13c345/node_modules/@wirecat/cli-core/dist/cli/messenger/password.js
|
|
5942
6478
|
var ENCRYPT_OPTION = [
|
|
5943
6479
|
"--encrypt",
|
|
5944
6480
|
"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"
|
|
@@ -5957,9 +6493,9 @@ var passwordOf = /* @__PURE__ */ __name(async (command, { twice }) => {
|
|
|
5957
6493
|
return password;
|
|
5958
6494
|
}, "passwordOf");
|
|
5959
6495
|
|
|
5960
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5961
|
-
import { existsSync as
|
|
5962
|
-
import { join } from "node:path";
|
|
6496
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.604.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_90db47d7f41d7a563eea7bc9cc13c345/node_modules/@wirecat/cli-core/dist/replies/rules.js
|
|
6497
|
+
import { existsSync as existsSync5, readFileSync as readFileSync2 } from "node:fs";
|
|
6498
|
+
import { join as join2 } from "node:path";
|
|
5963
6499
|
var REPLY_ACTIONS = ["reply", "task"];
|
|
5964
6500
|
var REPLY_MODELS = ["fill-only", "may-reword"];
|
|
5965
6501
|
var REPLY_KINDS = ["dialog", "group"];
|
|
@@ -6045,7 +6581,7 @@ var defaultRule = /* @__PURE__ */ __name((id) => ({
|
|
|
6045
6581
|
reply: { template: "", asReply: true },
|
|
6046
6582
|
limits: { perChat: "1/1d", perPerson: "1/1d" }
|
|
6047
6583
|
}), "defaultRule");
|
|
6048
|
-
var repliesPathFor = /* @__PURE__ */ __name((app, profile, env = process.env) =>
|
|
6584
|
+
var repliesPathFor = /* @__PURE__ */ __name((app, profile, env = process.env) => join2(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).config, `${profile}.replies.json`), "repliesPathFor");
|
|
6049
6585
|
var EVERYONE = { reply: "all", allow: { people: [], chats: [] }, deny: { people: [], chats: [] } };
|
|
6050
6586
|
var outsideAudience = /* @__PURE__ */ __name((audience, person, chat) => {
|
|
6051
6587
|
if (person !== null && audience.deny.people.includes(person))
|
|
@@ -6075,11 +6611,11 @@ var readReplies = /* @__PURE__ */ __name((path, provider) => {
|
|
|
6075
6611
|
return parseReplies(readRepliesFile(path, provider), path, provider);
|
|
6076
6612
|
}, "readReplies");
|
|
6077
6613
|
var readRepliesFile = /* @__PURE__ */ __name((path, provider) => {
|
|
6078
|
-
if (!
|
|
6614
|
+
if (!existsSync5(path))
|
|
6079
6615
|
return { audience: structuredClone(EVERYONE), rules: [] };
|
|
6080
6616
|
let parsed;
|
|
6081
6617
|
try {
|
|
6082
|
-
parsed = JSON.parse(
|
|
6618
|
+
parsed = JSON.parse(readFileSync2(path, "utf8"));
|
|
6083
6619
|
} catch (error) {
|
|
6084
6620
|
throw broken(path, error instanceof Error ? error.message : String(error));
|
|
6085
6621
|
}
|
|
@@ -6128,9 +6664,9 @@ var problem = /* @__PURE__ */ __name((issue) => {
|
|
|
6128
6664
|
}, "problem");
|
|
6129
6665
|
var broken = /* @__PURE__ */ __name((path, why) => new CliError("configuration_error", `the reply rules ${path} cannot be read (${why}) \u2014 fix the file`), "broken");
|
|
6130
6666
|
|
|
6131
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6132
|
-
import { existsSync as
|
|
6133
|
-
import { join as
|
|
6667
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.604.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_90db47d7f41d7a563eea7bc9cc13c345/node_modules/@wirecat/cli-core/dist/replies/state.js
|
|
6668
|
+
import { existsSync as existsSync6, readFileSync as readFileSync3 } from "node:fs";
|
|
6669
|
+
import { join as join3 } from "node:path";
|
|
6134
6670
|
var ANSWERED_KEPT = 1e3;
|
|
6135
6671
|
var times = record(string(), array(string()));
|
|
6136
6672
|
var stateFile = object({
|
|
@@ -6142,13 +6678,13 @@ var stateFile = object({
|
|
|
6142
6678
|
});
|
|
6143
6679
|
var emptyState = /* @__PURE__ */ __name(() => ({ paused: false, answered: [], sent: {} }), "emptyState");
|
|
6144
6680
|
var answeredKey = /* @__PURE__ */ __name((message) => `${message.chatId}:${message.id}`, "answeredKey");
|
|
6145
|
-
var repliesStatePathFor = /* @__PURE__ */ __name((app, profile, env = process.env) =>
|
|
6681
|
+
var repliesStatePathFor = /* @__PURE__ */ __name((app, profile, env = process.env) => join3(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, `${profile}.replies-state.json`), "repliesStatePathFor");
|
|
6146
6682
|
var readRepliesState = /* @__PURE__ */ __name((path) => {
|
|
6147
|
-
if (!
|
|
6683
|
+
if (!existsSync6(path))
|
|
6148
6684
|
return emptyState();
|
|
6149
6685
|
let parsed;
|
|
6150
6686
|
try {
|
|
6151
|
-
parsed = JSON.parse(
|
|
6687
|
+
parsed = JSON.parse(readFileSync3(path, "utf8"));
|
|
6152
6688
|
} catch (error) {
|
|
6153
6689
|
throw broken2(path, error instanceof Error ? error.message : String(error));
|
|
6154
6690
|
}
|
|
@@ -6181,7 +6717,7 @@ var recordReply = /* @__PURE__ */ __name((state, rule2, message, now) => {
|
|
|
6181
6717
|
}, "recordReply");
|
|
6182
6718
|
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");
|
|
6183
6719
|
|
|
6184
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6720
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.604.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_90db47d7f41d7a563eea7bc9cc13c345/node_modules/@wirecat/cli-core/dist/replies/decide.js
|
|
6185
6721
|
var skip = /* @__PURE__ */ __name((why) => ({ skip: why }), "skip");
|
|
6186
6722
|
var decide = /* @__PURE__ */ __name((rule2, incoming, state, now) => {
|
|
6187
6723
|
const { message, chat, owner, sender } = incoming;
|
|
@@ -6287,7 +6823,7 @@ var filled = /* @__PURE__ */ __name((template2, senderName) => {
|
|
|
6287
6823
|
return template2.replaceAll("{firstName}", name.split(/\s+/)[0] ?? name).replaceAll("{name}", name);
|
|
6288
6824
|
}, "filled");
|
|
6289
6825
|
|
|
6290
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6826
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.604.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_90db47d7f41d7a563eea7bc9cc13c345/node_modules/@wirecat/cli-core/dist/replies/template.js
|
|
6291
6827
|
var import_liquidjs = __toESM(require_liquid_node(), 1);
|
|
6292
6828
|
var TEMPLATE_LIMITS = {
|
|
6293
6829
|
parse: 32768,
|
|
@@ -6447,7 +6983,7 @@ var renderReplyTemplate = /* @__PURE__ */ __name(async (reply, input) => {
|
|
|
6447
6983
|
}
|
|
6448
6984
|
}, "renderReplyTemplate");
|
|
6449
6985
|
|
|
6450
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6986
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.604.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_90db47d7f41d7a563eea7bc9cc13c345/node_modules/@wirecat/cli-core/dist/replies/dry-run.js
|
|
6451
6987
|
var DRY_RUN_DAYS = 7;
|
|
6452
6988
|
var PAGE = 500;
|
|
6453
6989
|
var dryRun = /* @__PURE__ */ __name(async (store, account, rules, { since, until = Date.now(), only, audience, render }) => {
|
|
@@ -6561,7 +7097,7 @@ var storedSince = /* @__PURE__ */ __name(async (store, account, chat, since) =>
|
|
|
6561
7097
|
}
|
|
6562
7098
|
}, "storedSince");
|
|
6563
7099
|
|
|
6564
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7100
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.604.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_90db47d7f41d7a563eea7bc9cc13c345/node_modules/@wirecat/cli-core/dist/embeddings/keys.js
|
|
6565
7101
|
var endpointKeyName = /* @__PURE__ */ __name((baseUrl) => {
|
|
6566
7102
|
const host = new URL(baseUrl).host;
|
|
6567
7103
|
return ["openai", "anthropic"].includes(host) ? `endpoint:${host}` : host;
|
|
@@ -6592,7 +7128,7 @@ var embeddingKeys = /* @__PURE__ */ __name((app, env = process.env, keyring) =>
|
|
|
6592
7128
|
};
|
|
6593
7129
|
}, "embeddingKeys");
|
|
6594
7130
|
|
|
6595
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7131
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.604.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_90db47d7f41d7a563eea7bc9cc13c345/node_modules/@wirecat/cli-core/dist/models/openai.js
|
|
6596
7132
|
var options = strictObject({
|
|
6597
7133
|
temperature: range(0, 2),
|
|
6598
7134
|
top_p: range(0, 1),
|
|
@@ -6606,7 +7142,7 @@ var openai = {
|
|
|
6606
7142
|
images: true,
|
|
6607
7143
|
baseUrl: "https://api.openai.com/v1",
|
|
6608
7144
|
validate: /* @__PURE__ */ __name((given) => checkedOptions("openai", options, given), "validate"),
|
|
6609
|
-
complete: /* @__PURE__ */ __name(
|
|
7145
|
+
complete: /* @__PURE__ */ __name((target, request, checked, apiKey, fetcher) => withTimeLimit(12e4, async (deadline) => {
|
|
6610
7146
|
const response = await fetcher(`${target.baseUrl.replace(/\/+$/, "")}/chat/completions`, {
|
|
6611
7147
|
method: "POST",
|
|
6612
7148
|
headers: { "Content-Type": "application/json", ...apiKey ? { Authorization: `Bearer ${apiKey}` } : {} },
|
|
@@ -6628,7 +7164,7 @@ var openai = {
|
|
|
6628
7164
|
],
|
|
6629
7165
|
...new URL(target.baseUrl).hostname === "api.openai.com" ? { max_completion_tokens: request.maxTokens } : { max_tokens: request.maxTokens }
|
|
6630
7166
|
}),
|
|
6631
|
-
signal:
|
|
7167
|
+
signal: deadline,
|
|
6632
7168
|
redirect: "error"
|
|
6633
7169
|
});
|
|
6634
7170
|
if (!response.ok)
|
|
@@ -6638,10 +7174,10 @@ var openai = {
|
|
|
6638
7174
|
if (choice?.finish_reason !== "stop" || typeof choice.message?.content !== "string" || !Number.isInteger(body.usage?.total_tokens) || (body.usage?.total_tokens ?? 0) < 1)
|
|
6639
7175
|
throw new Error("incomplete response");
|
|
6640
7176
|
return { text: choice.message.content, tokens: body.usage?.total_tokens };
|
|
6641
|
-
}, "complete")
|
|
7177
|
+
}), "complete")
|
|
6642
7178
|
};
|
|
6643
7179
|
|
|
6644
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7180
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.604.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_90db47d7f41d7a563eea7bc9cc13c345/node_modules/@wirecat/cli-core/dist/models/index.js
|
|
6645
7181
|
var modelGateway = /* @__PURE__ */ __name((deps) => ({
|
|
6646
7182
|
complete: /* @__PURE__ */ __name(async (request) => {
|
|
6647
7183
|
if (deps.signal?.aborted)
|
|
@@ -6656,7 +7192,7 @@ var modelGateway = /* @__PURE__ */ __name((deps) => ({
|
|
|
6656
7192
|
if (!adapter && target.provider === "openai")
|
|
6657
7193
|
adapter = openai;
|
|
6658
7194
|
if (!adapter && target.provider === "anthropic")
|
|
6659
|
-
adapter = (await import("./anthropic-
|
|
7195
|
+
adapter = (await import("./anthropic-4ZI2BPLG.js")).anthropic;
|
|
6660
7196
|
if (!adapter)
|
|
6661
7197
|
throw new CliError("validation_error", `no model adapter for ${target.provider}`);
|
|
6662
7198
|
if (request.images !== void 0 && adapter.images !== true)
|
|
@@ -6697,19 +7233,19 @@ var modelGateway = /* @__PURE__ */ __name((deps) => ({
|
|
|
6697
7233
|
}, "complete")
|
|
6698
7234
|
}), "modelGateway");
|
|
6699
7235
|
|
|
6700
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6701
|
-
import { existsSync as
|
|
6702
|
-
import { join as
|
|
7236
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.604.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_90db47d7f41d7a563eea7bc9cc13c345/node_modules/@wirecat/cli-core/dist/replies/consents.js
|
|
7237
|
+
import { existsSync as existsSync7, readFileSync as readFileSync4 } from "node:fs";
|
|
7238
|
+
import { join as join4 } from "node:path";
|
|
6703
7239
|
var shape = strictObject({
|
|
6704
7240
|
provider: nullable(pipe(string(), minLength(1))),
|
|
6705
7241
|
deniedChats: array(pipe(string(), minLength(1)))
|
|
6706
7242
|
});
|
|
6707
|
-
var replyConsentPathFor = /* @__PURE__ */ __name((app, profile, env = process.env) =>
|
|
7243
|
+
var replyConsentPathFor = /* @__PURE__ */ __name((app, profile, env = process.env) => join4(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).config, `${profile}.replies-consents.json`), "replyConsentPathFor");
|
|
6708
7244
|
var readReplyConsent = /* @__PURE__ */ __name((path) => {
|
|
6709
|
-
if (!
|
|
7245
|
+
if (!existsSync7(path))
|
|
6710
7246
|
return { provider: null, deniedChats: [] };
|
|
6711
7247
|
try {
|
|
6712
|
-
return parse(shape, JSON.parse(
|
|
7248
|
+
return parse(shape, JSON.parse(readFileSync4(path, "utf8")));
|
|
6713
7249
|
} catch {
|
|
6714
7250
|
throw new CliError("configuration_error", "reply model consent is invalid; fix its file before granting consent");
|
|
6715
7251
|
}
|
|
@@ -6722,7 +7258,7 @@ var mayModelReply = /* @__PURE__ */ __name((path, provider, chat) => {
|
|
|
6722
7258
|
return consent.provider === provider && !consent.deniedChats.includes(chat);
|
|
6723
7259
|
}, "mayModelReply");
|
|
6724
7260
|
|
|
6725
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7261
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.604.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_90db47d7f41d7a563eea7bc9cc13c345/node_modules/@wirecat/cli-core/dist/replies/rendering.js
|
|
6726
7262
|
var replyRenderer = /* @__PURE__ */ __name((app, profile, settings, env, warn, options2 = {
|
|
6727
7263
|
ai: true
|
|
6728
7264
|
}) => async (rule2, message, chat, now) => {
|
|
@@ -6769,7 +7305,7 @@ var replyRenderer = /* @__PURE__ */ __name((app, profile, settings, env, warn, o
|
|
|
6769
7305
|
return result2;
|
|
6770
7306
|
}, "replyRenderer");
|
|
6771
7307
|
|
|
6772
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7308
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.604.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_90db47d7f41d7a563eea7bc9cc13c345/node_modules/@wirecat/cli-core/dist/replies/serve.js
|
|
6773
7309
|
var NOT_ALLOWED = "replies.send is not allow";
|
|
6774
7310
|
var NO_RULES = "no rules";
|
|
6775
7311
|
var ONLY_TASK = "opened a task, sent nothing";
|
|
@@ -6862,7 +7398,7 @@ var replyTo = /* @__PURE__ */ __name(async (deps, message) => {
|
|
|
6862
7398
|
return { skip: why };
|
|
6863
7399
|
}, "replyTo");
|
|
6864
7400
|
|
|
6865
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7401
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.604.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_90db47d7f41d7a563eea7bc9cc13c345/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-catch-up.js
|
|
6866
7402
|
var START_SYNC_DELAY_MS = 3e4;
|
|
6867
7403
|
var START_SYNC_BUDGET_MS = 5 * 6e4;
|
|
6868
7404
|
var START_SYNC_WINDOW_MS = 7 * 864e5;
|
|
@@ -6873,8 +7409,8 @@ var startSync = /* @__PURE__ */ __name(({ chats, newestHeld, fetch: fetch2, note
|
|
|
6873
7409
|
let pass = Promise.resolve();
|
|
6874
7410
|
let started = false;
|
|
6875
7411
|
let done;
|
|
6876
|
-
const run = /* @__PURE__ */ __name(
|
|
6877
|
-
|
|
7412
|
+
const run = /* @__PURE__ */ __name(() => withTimeLimit(budgetMs, (deadline) => catchUp(AbortSignal.any([controller.signal, deadline]))), "run");
|
|
7413
|
+
const catchUp = /* @__PURE__ */ __name(async (stop) => {
|
|
6878
7414
|
const floor = now() - windowMs;
|
|
6879
7415
|
const moved = [];
|
|
6880
7416
|
for (const chat of await chats(stop)) {
|
|
@@ -6915,7 +7451,7 @@ var startSync = /* @__PURE__ */ __name(({ chats, newestHeld, fetch: fetch2, note
|
|
|
6915
7451
|
code: "start_sync",
|
|
6916
7452
|
text: `caught up ${summary.fetched} message(s) in ${summary.chats} chat(s) that moved while serve was down` + (summary.stopped ? ` \u2014 stopped at the time limit, ${behind.length - summary.chats - summary.failed} left` : "")
|
|
6917
7453
|
});
|
|
6918
|
-
}, "
|
|
7454
|
+
}, "catchUp");
|
|
6919
7455
|
return {
|
|
6920
7456
|
start: /* @__PURE__ */ __name(() => {
|
|
6921
7457
|
if (started || controller.signal.aborted)
|
|
@@ -6939,7 +7475,7 @@ var startSync = /* @__PURE__ */ __name(({ chats, newestHeld, fetch: fetch2, note
|
|
|
6939
7475
|
};
|
|
6940
7476
|
}, "startSync");
|
|
6941
7477
|
|
|
6942
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7478
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.604.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_90db47d7f41d7a563eea7bc9cc13c345/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-members.js
|
|
6943
7479
|
var FIRST_FETCH_MS = 6e4;
|
|
6944
7480
|
var DAY_MS = 864e5;
|
|
6945
7481
|
var memberFetches = /* @__PURE__ */ __name(({ withStore, fetch: fetch2, warn, firstMs = FIRST_FETCH_MS, everyMs = DAY_MS }) => {
|
|
@@ -6993,7 +7529,7 @@ var memberFetches = /* @__PURE__ */ __name(({ withStore, fetch: fetch2, warn, fi
|
|
|
6993
7529
|
};
|
|
6994
7530
|
}, "memberFetches");
|
|
6995
7531
|
|
|
6996
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7532
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.604.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_90db47d7f41d7a563eea7bc9cc13c345/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-notice.js
|
|
6997
7533
|
var record2 = /* @__PURE__ */ __name((context, app, severity, attributes) => recordLogFor(context.streams.diagnostic, app, { command: currentRun().command || "serve" })[severity](attributes), "record");
|
|
6998
7534
|
var noticeFor = /* @__PURE__ */ __name((context, app, severity = "warn") => ({ text, ...attributes }) => {
|
|
6999
7535
|
if (context.format === "pretty") {
|
|
@@ -7026,7 +7562,7 @@ var recordDiagnostics = /* @__PURE__ */ __name((context, app) => {
|
|
|
7026
7562
|
return context;
|
|
7027
7563
|
}, "recordDiagnostics");
|
|
7028
7564
|
|
|
7029
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7565
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.604.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_90db47d7f41d7a563eea7bc9cc13c345/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-stems.js
|
|
7030
7566
|
var STEMS_EVERY_MS = 3e4;
|
|
7031
7567
|
var STEMS_SLICE_MS = 2e3;
|
|
7032
7568
|
var stemFills = /* @__PURE__ */ __name(({ withStore, warn, everyMs = STEMS_EVERY_MS, sliceMs = STEMS_SLICE_MS }) => {
|
|
@@ -7066,7 +7602,7 @@ var stemFills = /* @__PURE__ */ __name(({ withStore, warn, everyMs = STEMS_EVERY
|
|
|
7066
7602
|
};
|
|
7067
7603
|
}, "stemFills");
|
|
7068
7604
|
|
|
7069
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7605
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.604.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_90db47d7f41d7a563eea7bc9cc13c345/node_modules/@wirecat/cli-core/dist/cli/messenger/message-items.js
|
|
7070
7606
|
var defined = /* @__PURE__ */ __name((value) => Object.fromEntries(Object.entries(value).filter(([, one]) => one !== void 0)), "defined");
|
|
7071
7607
|
var attachmentItem = /* @__PURE__ */ __name((attachment) => defined({
|
|
7072
7608
|
kind: attachment.kind,
|
|
@@ -7161,7 +7697,7 @@ var viewOf = /* @__PURE__ */ __name((context, messenger) => ({
|
|
|
7161
7697
|
locale: messenger.app.locale
|
|
7162
7698
|
}), "viewOf");
|
|
7163
7699
|
|
|
7164
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7700
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.604.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_90db47d7f41d7a563eea7bc9cc13c345/node_modules/@wirecat/cli-core/dist/cli/messenger/watch-answers.js
|
|
7165
7701
|
var observed = /* @__PURE__ */ __name((value) => ({
|
|
7166
7702
|
value: value.value,
|
|
7167
7703
|
observed_at: value.observedAt,
|
|
@@ -7228,7 +7764,7 @@ var watchEventItem = /* @__PURE__ */ __name((value, account) => {
|
|
|
7228
7764
|
}
|
|
7229
7765
|
}, "watchEventItem");
|
|
7230
7766
|
|
|
7231
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7767
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.604.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_90db47d7f41d7a563eea7bc9cc13c345/node_modules/@wirecat/cli-core/dist/cli/messenger/watch-command.js
|
|
7232
7768
|
var watchCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("watch"), {
|
|
7233
7769
|
output: { entity: "watch_item" },
|
|
7234
7770
|
effects: REMOTE_READ,
|
|
@@ -7383,7 +7919,7 @@ var describe = /* @__PURE__ */ __name((event, render) => {
|
|
|
7383
7919
|
}
|
|
7384
7920
|
}, "describe");
|
|
7385
7921
|
|
|
7386
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7922
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.604.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_90db47d7f41d7a563eea7bc9cc13c345/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-command.js
|
|
7387
7923
|
var serveCommand = /* @__PURE__ */ __name((messenger) => {
|
|
7388
7924
|
const command = annotate(new Command("serve"), {
|
|
7389
7925
|
output: { entity: "serve_summary" },
|
|
@@ -7647,8 +8183,8 @@ var tasking = /* @__PURE__ */ __name((context, warn) => {
|
|
|
7647
8183
|
};
|
|
7648
8184
|
}, "tasking");
|
|
7649
8185
|
|
|
7650
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7651
|
-
import { existsSync as
|
|
8186
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.604.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_90db47d7f41d7a563eea7bc9cc13c345/node_modules/@wirecat/cli-core/dist/cli/messenger/store-tables-command.js
|
|
8187
|
+
import { existsSync as existsSync8 } from "node:fs";
|
|
7652
8188
|
var PATH = "store tables list";
|
|
7653
8189
|
var STORE_TABLES_QUERY = {
|
|
7654
8190
|
entity: "store_table",
|
|
@@ -7677,7 +8213,7 @@ var storeTablesCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
7677
8213
|
const filter = filterOf(words);
|
|
7678
8214
|
const { full } = this.optsWithGlobals();
|
|
7679
8215
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
7680
|
-
if (!
|
|
8216
|
+
if (!existsSync8(path))
|
|
7681
8217
|
throw new CliError("not_found", `no store at ${path}`);
|
|
7682
8218
|
const items = await readStoreTables(path, { filter, sizes: full === true });
|
|
7683
8219
|
renderAnswer(this, outputFor(this), listOf(PATH, {
|
|
@@ -7690,7 +8226,7 @@ var storeTablesCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
7690
8226
|
return tables;
|
|
7691
8227
|
}, "storeTablesCommand");
|
|
7692
8228
|
|
|
7693
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
8229
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.604.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_90db47d7f41d7a563eea7bc9cc13c345/node_modules/@wirecat/cli-core/dist/cli/messenger/store-maintenance-command.js
|
|
7694
8230
|
var SEARCH_INDEXES = ["messages_fts", "chats_fts", "identities_fts"];
|
|
7695
8231
|
var WORD_INDEX = "message_words";
|
|
7696
8232
|
var schemaOf = /* @__PURE__ */ __name((database) => {
|
|
@@ -7699,7 +8235,7 @@ var schemaOf = /* @__PURE__ */ __name((database) => {
|
|
|
7699
8235
|
}, "schemaOf");
|
|
7700
8236
|
var count2 = /* @__PURE__ */ __name((database, table) => Number(database.prepare(`SELECT count(*) AS n FROM ${table}`).get()?.n ?? 0), "count");
|
|
7701
8237
|
var pendingIfKnown2 = /* @__PURE__ */ __name((database) => database.prepare("SELECT 1 FROM pragma_table_info('messages') WHERE name = 'normalized_text'").get() ? pendingNormalization(database) : null, "pendingIfKnown");
|
|
7702
|
-
var bytesOf2 = /* @__PURE__ */ __name((path) =>
|
|
8238
|
+
var bytesOf2 = /* @__PURE__ */ __name((path) => existsSync9(path) ? statSync4(path).size : 0, "bytesOf");
|
|
7703
8239
|
var reading = /* @__PURE__ */ __name(async (path, read) => {
|
|
7704
8240
|
const database = await openCache(path);
|
|
7705
8241
|
try {
|
|
@@ -7716,10 +8252,23 @@ var readingOnly = /* @__PURE__ */ __name(async (path, read) => {
|
|
|
7716
8252
|
database.close();
|
|
7717
8253
|
}
|
|
7718
8254
|
}, "readingOnly");
|
|
7719
|
-
var storeSummary = /* @__PURE__ */ __name(async (env) => {
|
|
8255
|
+
var storeSummary = /* @__PURE__ */ __name(async (env, { deep = false, command } = {}) => {
|
|
7720
8256
|
const path = storePath(env);
|
|
7721
|
-
if (!
|
|
8257
|
+
if (!existsSync9(path))
|
|
7722
8258
|
return { path, exists: false };
|
|
8259
|
+
const checked = await storeHealth(path, { deep });
|
|
8260
|
+
const health = {
|
|
8261
|
+
checked: checked.checked,
|
|
8262
|
+
covers: deep ? "every page and every search index" : QUICK_HEALTH_CHECKS,
|
|
8263
|
+
ok: checked.ok,
|
|
8264
|
+
ms: checked.ms,
|
|
8265
|
+
...checked.problems ? { problems: checked.problems } : {},
|
|
8266
|
+
...checked.damagedTables?.length ? { damagedTables: checked.damagedTables } : {},
|
|
8267
|
+
...checked.invalidJson?.length ? { invalidJson: checked.invalidJson } : {},
|
|
8268
|
+
...checked.searchIndexes?.some((index) => !index.ok) ? { damagedSearchIndexes: checked.searchIndexes.filter((index) => !index.ok).map((index) => index.name) } : {}
|
|
8269
|
+
};
|
|
8270
|
+
const damage = command ? explainDamage(checked, command) : null;
|
|
8271
|
+
const healthOf = { health, ...damage ? { damage } : {} };
|
|
7723
8272
|
try {
|
|
7724
8273
|
return await reading(path, (database) => {
|
|
7725
8274
|
const { version, writable } = schemaOf(database);
|
|
@@ -7729,11 +8278,12 @@ var storeSummary = /* @__PURE__ */ __name(async (env) => {
|
|
|
7729
8278
|
schema: version,
|
|
7730
8279
|
speaks: SPEAKS,
|
|
7731
8280
|
writable,
|
|
7732
|
-
...version > 0 ? { chats: count2(database, "chats"), messages: count2(database, "messages") } : {}
|
|
8281
|
+
...version > 0 ? { chats: count2(database, "chats"), messages: count2(database, "messages") } : {},
|
|
8282
|
+
...healthOf
|
|
7733
8283
|
};
|
|
7734
8284
|
});
|
|
7735
8285
|
} catch (error) {
|
|
7736
|
-
return { path, exists: true, error: messageOf2(error) };
|
|
8286
|
+
return { path, exists: true, error: messageOf2(error), ...healthOf };
|
|
7737
8287
|
}
|
|
7738
8288
|
}, "storeSummary");
|
|
7739
8289
|
var result = /* @__PURE__ */ __name((command, value, next = []) => renderAnswer(command, outputFor(command), itemOf(snakeKeys(value), { next })), "result");
|
|
@@ -7748,7 +8298,8 @@ var storeMaintenanceCommands = /* @__PURE__ */ __name((messenger) => [
|
|
|
7748
8298
|
repairCommand(messenger),
|
|
7749
8299
|
resetCommand(messenger),
|
|
7750
8300
|
copiesCommand(),
|
|
7751
|
-
storeTablesCommand(messenger)
|
|
8301
|
+
storeTablesCommand(messenger),
|
|
8302
|
+
storeRecoverCommand({ command: messenger.app.command, version: messenger.app.version })
|
|
7752
8303
|
], "storeMaintenanceCommands");
|
|
7753
8304
|
var refuseWhileServing = /* @__PURE__ */ __name((command, messenger) => {
|
|
7754
8305
|
const serving = servingProfiles(messenger.app, environmentOf(command).env ?? process.env);
|
|
@@ -7760,7 +8311,7 @@ var repairCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("
|
|
|
7760
8311
|
const { renderer, format } = outputFor(this);
|
|
7761
8312
|
const { dryRun: dryRun2 } = this.opts();
|
|
7762
8313
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
7763
|
-
if (!
|
|
8314
|
+
if (!existsSync9(path)) {
|
|
7764
8315
|
result(this, { path, exists: false });
|
|
7765
8316
|
return;
|
|
7766
8317
|
}
|
|
@@ -7800,7 +8351,7 @@ var notesOf = /* @__PURE__ */ __name((report, command) => {
|
|
|
7800
8351
|
}, "notesOf");
|
|
7801
8352
|
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) {
|
|
7802
8353
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
7803
|
-
if (!
|
|
8354
|
+
if (!existsSync9(path))
|
|
7804
8355
|
throw new CliError("not_found", `no store at ${path}`);
|
|
7805
8356
|
const deleted = await reading(path, (database) => deleteCopy(database, name));
|
|
7806
8357
|
result(this, { path, deleted });
|
|
@@ -7808,7 +8359,7 @@ var copiesCommand = /* @__PURE__ */ __name(() => new Command("copies").descripti
|
|
|
7808
8359
|
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() {
|
|
7809
8360
|
const { renderer } = outputFor(this);
|
|
7810
8361
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
7811
|
-
if (!
|
|
8362
|
+
if (!existsSync9(path)) {
|
|
7812
8363
|
result(this, { path, exists: false, ok: true });
|
|
7813
8364
|
return;
|
|
7814
8365
|
}
|
|
@@ -7871,7 +8422,7 @@ var inspect = /* @__PURE__ */ __name((path) => reading(path, (database) => {
|
|
|
7871
8422
|
...schema.version > 0 ? [["attachment_words", indexIntegrity(database, "attachment_words", 0)]] : []
|
|
7872
8423
|
]);
|
|
7873
8424
|
const size = bytesOf2(path) + bytesOf2(`${path}-wal`);
|
|
7874
|
-
const { bavail, bsize } =
|
|
8425
|
+
const { bavail, bsize } = statfsSync2(dirname2(path));
|
|
7875
8426
|
const free = Number(bavail) * Number(bsize);
|
|
7876
8427
|
const behind = schema.version > 0 ? chatsBehind(database) : [];
|
|
7877
8428
|
const vectorIndexes = schema.version >= 34 ? vectorIndexCounts(database) : [];
|
|
@@ -7959,14 +8510,18 @@ var chatsBehind = /* @__PURE__ */ __name((database) => database.prepare(`SELECT
|
|
|
7959
8510
|
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() {
|
|
7960
8511
|
const { renderer } = outputFor(this);
|
|
7961
8512
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
7962
|
-
if (!
|
|
8513
|
+
if (!existsSync9(path)) {
|
|
7963
8514
|
result(this, { path, exists: false });
|
|
7964
8515
|
renderer.note(`no store yet \u2014 the first \`${messenger.app.command}\` command that reads a chat creates it`);
|
|
7965
8516
|
return;
|
|
7966
8517
|
}
|
|
7967
8518
|
const answer = await reading(path, (database) => {
|
|
7968
8519
|
const from = schemaOf(database).version;
|
|
7969
|
-
migrate(database, {
|
|
8520
|
+
migrate(database, {
|
|
8521
|
+
command: messenger.app.command,
|
|
8522
|
+
version: messenger.app.version,
|
|
8523
|
+
rollback: { store: path, warn: /* @__PURE__ */ __name((line) => renderer.warn(line), "warn") }
|
|
8524
|
+
});
|
|
7970
8525
|
const { normalized, indexed, terms } = buildWordIndex(database, (note) => renderer.note(note));
|
|
7971
8526
|
const stemmed = buildStems(database, (note) => renderer.note(note));
|
|
7972
8527
|
const notes = buildNoteIndex(database, (note) => renderer.note(note));
|
|
@@ -8019,7 +8574,7 @@ var buildNoteIndex = /* @__PURE__ */ __name((database, note, { reset = false } =
|
|
|
8019
8574
|
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() {
|
|
8020
8575
|
const { renderer } = outputFor(this);
|
|
8021
8576
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8022
|
-
if (!
|
|
8577
|
+
if (!existsSync9(path)) {
|
|
8023
8578
|
result(this, { path, exists: false });
|
|
8024
8579
|
return;
|
|
8025
8580
|
}
|
|
@@ -8048,11 +8603,11 @@ var reindexCommand = /* @__PURE__ */ __name((messenger) => destroysNothing(annot
|
|
|
8048
8603
|
result(this, answer);
|
|
8049
8604
|
}), "reindexCommand");
|
|
8050
8605
|
var vacuumInto = /* @__PURE__ */ __name(async (path, target) => {
|
|
8051
|
-
|
|
8606
|
+
writeFileSync2(target, "", { flag: "wx", mode: 384 });
|
|
8052
8607
|
try {
|
|
8053
8608
|
await reading(path, (database) => database.prepare("VACUUM INTO ?").run(target));
|
|
8054
8609
|
} catch (error) {
|
|
8055
|
-
|
|
8610
|
+
rmSync3(target, { force: true });
|
|
8056
8611
|
throw error;
|
|
8057
8612
|
}
|
|
8058
8613
|
}, "vacuumInto");
|
|
@@ -8061,9 +8616,9 @@ var backupCommand = /* @__PURE__ */ __name(() => destroysNothing(annotate(new Co
|
|
|
8061
8616
|
const { encrypt } = this.opts();
|
|
8062
8617
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8063
8618
|
const target = resolve(file2);
|
|
8064
|
-
if (!
|
|
8619
|
+
if (!existsSync9(path))
|
|
8065
8620
|
throw new CliError("not_found", `no store at ${path} to back up`);
|
|
8066
|
-
if (
|
|
8621
|
+
if (existsSync9(target))
|
|
8067
8622
|
throw new CliError("validation_error", `${target} exists \u2014 a backup never overwrites a file`);
|
|
8068
8623
|
const password = encrypt ? await passwordOf(this, { twice: true }) : void 0;
|
|
8069
8624
|
const copyAt = password === void 0 ? target : `${path}.backup-${process.pid}`;
|
|
@@ -8085,67 +8640,69 @@ var backupCommand = /* @__PURE__ */ __name(() => destroysNothing(annotate(new Co
|
|
|
8085
8640
|
});
|
|
8086
8641
|
} catch (error) {
|
|
8087
8642
|
if (password === void 0)
|
|
8088
|
-
|
|
8643
|
+
rmSync3(target, { force: true });
|
|
8089
8644
|
throw error;
|
|
8090
8645
|
} finally {
|
|
8091
8646
|
if (password !== void 0)
|
|
8092
|
-
|
|
8647
|
+
rmSync3(copyAt, { force: true });
|
|
8093
8648
|
}
|
|
8094
8649
|
}), "backupCommand");
|
|
8095
8650
|
var decryptCommand = /* @__PURE__ */ __name(() => annotate(new Command("decrypt"), { output: { entity: "store_decrypt" }, effects: LOCAL_WRITE }).description("open a file written with --encrypt into a new file; asks for its password").argument("<file>", "a file `store backup --encrypt` or `store export --encrypt` wrote").requiredOption("--output <file>", "the new file, readable only by you").action(async function(file2) {
|
|
8096
8651
|
const { output } = this.opts();
|
|
8097
8652
|
const from = resolve(file2);
|
|
8098
8653
|
const to = resolve(output);
|
|
8099
|
-
if (!
|
|
8654
|
+
if (!existsSync9(from))
|
|
8100
8655
|
throw new CliError("not_found", `no file at ${from}`);
|
|
8101
8656
|
if (!isSealed(from))
|
|
8102
8657
|
throw new CliError("validation_error", `${from} was not written with --encrypt`);
|
|
8103
|
-
if (
|
|
8658
|
+
if (existsSync9(to))
|
|
8104
8659
|
throw new CliError("validation_error", `${to} exists \u2014 never overwritten`);
|
|
8105
8660
|
await unsealFile(from, to, await passwordOf(this, { twice: false }));
|
|
8106
8661
|
result(this, { path: to, from, bytes: bytesOf2(to) });
|
|
8107
8662
|
}), "decryptCommand");
|
|
8108
|
-
var restoreCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("restore"), { output: { entity: "store_restore" }, effects: LOCAL_WRITE }).summary("restore a backup
|
|
8663
|
+
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) {
|
|
8109
8664
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8110
8665
|
const given = resolve(file2);
|
|
8111
|
-
if (!
|
|
8666
|
+
if (!existsSync9(given))
|
|
8112
8667
|
throw new CliError("not_found", `no file at ${given}`);
|
|
8113
8668
|
refuseWhileServing(this, messenger);
|
|
8114
8669
|
if (!isSealed(given))
|
|
8115
8670
|
return restoreFrom(this, messenger, given, given);
|
|
8116
8671
|
const opened = `${path}.unsealing-${process.pid}`;
|
|
8117
|
-
mkdirSync(
|
|
8672
|
+
mkdirSync(dirname2(path), { recursive: true, mode: 448 });
|
|
8118
8673
|
try {
|
|
8119
8674
|
await unsealFile(given, opened, await passwordOf(this, { twice: false }));
|
|
8120
8675
|
await restoreFrom(this, messenger, opened, given);
|
|
8121
8676
|
} finally {
|
|
8122
|
-
|
|
8677
|
+
rmSync3(opened, { force: true });
|
|
8123
8678
|
}
|
|
8124
8679
|
}), "restoreCommand");
|
|
8125
8680
|
var restoreFrom = /* @__PURE__ */ __name(async (command, messenger, backup, given) => {
|
|
8126
8681
|
const { renderer } = outputFor(command);
|
|
8127
8682
|
const path = storePath(environmentOf(command).env ?? process.env);
|
|
8128
|
-
if (
|
|
8683
|
+
if (existsSync9(path) && realpathSync2(backup) === realpathSync2(path)) {
|
|
8129
8684
|
throw new CliError("validation_error", `${backup} is the store itself`);
|
|
8130
8685
|
}
|
|
8686
|
+
if (await isRollbackCopy(backup))
|
|
8687
|
+
return rollBackFrom(command, messenger, backup);
|
|
8131
8688
|
const schema = await backupSchema(backup);
|
|
8132
8689
|
const stamp = stampNow();
|
|
8133
|
-
const kept =
|
|
8690
|
+
const kept = existsSync9(path) ? `${path}.before-restore-${stamp}` : null;
|
|
8134
8691
|
if (kept) {
|
|
8135
8692
|
const waitMs = environmentOf(command).storeLockWaitMs;
|
|
8136
8693
|
await quiesce(path, messenger, "restore", (message) => renderer.warn(message), waitMs);
|
|
8137
8694
|
} else
|
|
8138
|
-
mkdirSync(
|
|
8695
|
+
mkdirSync(dirname2(path), { recursive: true, mode: 448 });
|
|
8139
8696
|
const incoming = `${path}.restoring-${stamp}`;
|
|
8140
8697
|
copyFileSync(backup, incoming, constants.COPYFILE_EXCL);
|
|
8141
8698
|
chmodSync(incoming, 384);
|
|
8142
8699
|
if (kept) {
|
|
8143
|
-
|
|
8700
|
+
renameSync3(path, kept);
|
|
8144
8701
|
for (const suffix of ["-wal", "-shm"])
|
|
8145
|
-
if (
|
|
8146
|
-
|
|
8702
|
+
if (existsSync9(`${path}${suffix}`))
|
|
8703
|
+
renameSync3(`${path}${suffix}`, `${kept}${suffix}`);
|
|
8147
8704
|
}
|
|
8148
|
-
|
|
8705
|
+
renameSync3(incoming, path);
|
|
8149
8706
|
result(command, { path, restoredFrom: given, keptAt: kept, schema: schema.version });
|
|
8150
8707
|
if (kept)
|
|
8151
8708
|
renderer.note(`the store it replaced is kept at ${kept}`);
|
|
@@ -8154,6 +8711,43 @@ var restoreFrom = /* @__PURE__ */ __name(async (command, messenger, backup, give
|
|
|
8154
8711
|
renderer.note(`the backup is behind this build; the next command migrates it \u2014 \`${lineOf(command, "store migrate")}\` now`);
|
|
8155
8712
|
}
|
|
8156
8713
|
}, "restoreFrom");
|
|
8714
|
+
var isRollbackCopy = /* @__PURE__ */ __name(async (file2) => {
|
|
8715
|
+
try {
|
|
8716
|
+
return await readingOnly(file2, (database) => database.prepare("SELECT 1 FROM sqlite_master WHERE name = 'rollback_meta'").get() !== void 0);
|
|
8717
|
+
} catch {
|
|
8718
|
+
return false;
|
|
8719
|
+
}
|
|
8720
|
+
}, "isRollbackCopy");
|
|
8721
|
+
var rollBackFrom = /* @__PURE__ */ __name(async (command, messenger, copy) => {
|
|
8722
|
+
const { renderer } = outputFor(command);
|
|
8723
|
+
const path = storePath(environmentOf(command).env ?? process.env);
|
|
8724
|
+
if (!existsSync9(path))
|
|
8725
|
+
throw new CliError("not_found", `no store at ${path} to roll back`);
|
|
8726
|
+
const waitMs = environmentOf(command).storeLockWaitMs;
|
|
8727
|
+
await quiesce(path, messenger, "restore", (message) => renderer.warn(message), waitMs);
|
|
8728
|
+
const { database } = await openSqlite(path);
|
|
8729
|
+
let rolled;
|
|
8730
|
+
try {
|
|
8731
|
+
rolled = rollBack(database, copy);
|
|
8732
|
+
} finally {
|
|
8733
|
+
database.close();
|
|
8734
|
+
}
|
|
8735
|
+
result(command, {
|
|
8736
|
+
path,
|
|
8737
|
+
restoredFrom: copy,
|
|
8738
|
+
rolledBack: true,
|
|
8739
|
+
schema: rolled.from,
|
|
8740
|
+
was: rolled.was,
|
|
8741
|
+
tables: rolled.restored,
|
|
8742
|
+
rebuilt: rolled.rebuilt,
|
|
8743
|
+
foreignKeyViolations: rolled.foreignKeyViolations
|
|
8744
|
+
});
|
|
8745
|
+
const taken = new Date(rolled.createdAt).toISOString();
|
|
8746
|
+
renderer.note(`the store is back at schema ${rolled.from}; ${rolled.tables.length > 0 ? rolled.tables.join(", ") : "no table"} hold what they held at ${taken}, and what was written to them since is not kept`);
|
|
8747
|
+
renderer.note("open it with the older tool and run its `store rebuild`: the search indexes are behind the tables");
|
|
8748
|
+
renderer.note(`a tool that speaks schema ${rolled.to} or later migrates it again on its next run`);
|
|
8749
|
+
renderer.note("restart every serve and mcp of either CLI that was running, so they read the restored store");
|
|
8750
|
+
}, "rollBackFrom");
|
|
8157
8751
|
var backupSchema = /* @__PURE__ */ __name(async (backup) => {
|
|
8158
8752
|
let read;
|
|
8159
8753
|
try {
|
|
@@ -8177,7 +8771,7 @@ var backupSchema = /* @__PURE__ */ __name(async (backup) => {
|
|
|
8177
8771
|
var STORE_LOCK_WAIT_MS = 1e3;
|
|
8178
8772
|
var quiesce = /* @__PURE__ */ __name(async (path, messenger, then, warn, waitMs = STORE_LOCK_WAIT_MS) => {
|
|
8179
8773
|
const { command } = messenger.app;
|
|
8180
|
-
const files = [path, `${path}-wal`, `${path}-shm`].filter((file2) =>
|
|
8774
|
+
const files = [path, `${path}-wal`, `${path}-shm`].filter((file2) => existsSync9(file2)).map((file2) => realpathSync2(file2));
|
|
8181
8775
|
const holders = holdersOf(files);
|
|
8182
8776
|
if (holders === void 0) {
|
|
8183
8777
|
warn(`this system cannot say which processes have the store open \u2014 restart every running serve and mcp after this`);
|
|
@@ -8203,7 +8797,7 @@ var resetCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("r
|
|
|
8203
8797
|
const { command } = messenger.app;
|
|
8204
8798
|
const env = environmentOf(this).env ?? process.env;
|
|
8205
8799
|
const path = storePath(env);
|
|
8206
|
-
if (!
|
|
8800
|
+
if (!existsSync9(path)) {
|
|
8207
8801
|
result(this, { path, exists: false, reset: false });
|
|
8208
8802
|
renderer.note(`no store at ${path} \u2014 nothing to reset; the first \`${command}\` command that reads a chat creates it`);
|
|
8209
8803
|
return;
|
|
@@ -8239,17 +8833,17 @@ var resetCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("r
|
|
|
8239
8833
|
});
|
|
8240
8834
|
renderer.note(`backed the store up to ${backup}`);
|
|
8241
8835
|
}
|
|
8242
|
-
for (const suffix of
|
|
8243
|
-
|
|
8836
|
+
for (const suffix of STORE_PARTS2)
|
|
8837
|
+
rmSync3(`${path}${suffix}`, { force: true });
|
|
8244
8838
|
await (await openStore({ path, command })).close();
|
|
8245
8839
|
const schema = await reading(path, (database) => schemaOf(database).version);
|
|
8246
8840
|
result(this, { path, exists: true, reset: true, backup, backedUp, schema });
|
|
8247
8841
|
renderer.note(backup ? `the store is empty at schema ${schema}; \`${command} store restore ${backup}\` puts the old one back once a build can read it` : `the store is empty at schema ${schema}; there is no backup`);
|
|
8248
8842
|
}), "resetCommand");
|
|
8249
|
-
var
|
|
8843
|
+
var STORE_PARTS2 = ["", "-wal", "-shm"];
|
|
8250
8844
|
var resetPreview = /* @__PURE__ */ __name(async (path, messenger, env, keep) => {
|
|
8251
|
-
const files =
|
|
8252
|
-
const holders = holdersOf(files.map((file2) =>
|
|
8845
|
+
const files = STORE_PARTS2.map((suffix) => `${path}${suffix}`).filter((file2) => existsSync9(file2));
|
|
8846
|
+
const holders = holdersOf(files.map((file2) => realpathSync2(file2)));
|
|
8253
8847
|
const serving = servingProfiles(messenger.app, env).length > 0;
|
|
8254
8848
|
const read = await readingOnly(path, (database) => ({
|
|
8255
8849
|
schema: schemaOf(database).version,
|
|
@@ -8280,6 +8874,10 @@ export {
|
|
|
8280
8874
|
checkFor,
|
|
8281
8875
|
passes,
|
|
8282
8876
|
seal,
|
|
8877
|
+
storeRecoveryCheck,
|
|
8878
|
+
storeRecoveryRun,
|
|
8879
|
+
recoveryNotes,
|
|
8880
|
+
storeRecoverCommand,
|
|
8283
8881
|
storeInfo,
|
|
8284
8882
|
storeInfoCommand,
|
|
8285
8883
|
sharedStoreCommand,
|