@wirecat/zoom-cli 0.67.0 → 0.69.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-ZQWPCJEK.js} +12 -12
- package/dist/bundle/answer-policy-VBDYLUXI.js +104 -0
- package/dist/bundle/{anthropic-FSNASJML.js → anthropic-7FUQ2HYJ.js} +7 -7
- package/dist/bundle/{app-server-EVSRYJ3H.js → app-server-DNPE2EQB.js} +61 -58
- package/dist/bundle/{bun-DACL5SVO.js → bun-ZVQFCFCC.js} +2 -2
- package/dist/bundle/{bun-sqlite-HQ2KOXSI.js → bun-sqlite-EB2UMUPJ.js} +6 -6
- package/dist/bundle/{chunk-4ZR5DJ26.js → chunk-2SYWVIQJ.js} +3 -3
- package/dist/bundle/chunk-37B7A4RP.js +66 -0
- package/dist/bundle/{chunk-WHQ4ZCJI.js → chunk-3TPRYZUW.js} +214 -86
- package/dist/bundle/{chunk-L6CAUVMU.js → chunk-4APZQYCH.js} +5 -5
- package/dist/bundle/{chunk-ASCHAVNW.js → chunk-52DCABMU.js} +27 -27
- package/dist/bundle/{chunk-LM26DJOK.js → chunk-5GOE6PQK.js} +6 -6
- package/dist/bundle/{chunk-QX2MAT6I.js → chunk-5H6VTEEC.js} +3 -3
- package/dist/bundle/{chunk-V33VGWT3.js → chunk-5ZF6QVMC.js} +16 -6
- package/dist/bundle/{chunk-GP4NSYDU.js → chunk-5ZJXKASF.js} +254 -13
- package/dist/bundle/chunk-6AMMTXEA.js +12473 -0
- package/dist/bundle/{chunk-Q65SDEFN.js → chunk-6KMTQX3D.js} +2 -2
- package/dist/bundle/{chunk-TBRG2DPE.js → chunk-6N2D6JGX.js} +2 -2
- package/dist/bundle/{chunk-X67YD3QI.js → chunk-6TICX3MN.js} +2 -2
- package/dist/bundle/{chunk-4GCKDO2H.js → chunk-7AUP2WT3.js} +3 -3
- package/dist/bundle/{chunk-JVCHGI7W.js → chunk-B5D7NZI7.js} +1 -1
- 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-VQTAU4DV.js → chunk-C6TEYKXV.js} +8 -8
- package/dist/bundle/{chunk-6AJDVJVZ.js → chunk-CKK6JOC4.js} +2 -2
- package/dist/bundle/{chunk-4U2555EQ.js → chunk-CUZHKYC2.js} +30 -28
- package/dist/bundle/{chunk-7LLUUXJB.js → chunk-DHD25JII.js} +1 -1
- package/dist/bundle/{chunk-RYKG6AEH.js → chunk-EPPSMCEV.js} +4 -2
- package/dist/bundle/chunk-F5DYBWH7.js +299 -0
- 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-SSXCOUP3.js → chunk-G6IX2MD2.js} +500 -227
- package/dist/bundle/{chunk-OTMGAKUM.js → chunk-GR3QDHBU.js} +7 -7
- package/dist/bundle/{chunk-QEI55M2F.js → chunk-GXDOTUUO.js} +10 -10
- package/dist/bundle/chunk-H3MFBYTQ.js +261 -0
- package/dist/bundle/{chunk-DFUPETW7.js → chunk-HC56J5LB.js} +135 -76
- package/dist/bundle/{chunk-D6OXI2NV.js → chunk-HSI7YOYK.js} +229 -67
- package/dist/bundle/{chunk-FGTPREAZ.js → chunk-HW5QTRFF.js} +35 -35
- package/dist/bundle/{chunk-VNIBTNV4.js → chunk-IEC4E65G.js} +2 -2
- package/dist/bundle/{chunk-EUPZSR2G.js → chunk-IPBZKUC3.js} +4 -4
- package/dist/bundle/{chunk-EQ7XRRKV.js → chunk-JHFP3Z5S.js} +11 -11
- package/dist/bundle/{chunk-3GO3KME7.js → chunk-JX5JJZC3.js} +3 -3
- package/dist/bundle/{chunk-7HAIM7GV.js → chunk-JZ4YOAHA.js} +963 -622
- 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-I7SOXH64.js → chunk-KX5MZVPX.js} +66 -39
- package/dist/bundle/chunk-L62EJDNZ.js +64 -0
- package/dist/bundle/{chunk-EPDRF66S.js → chunk-LDRQ5NAP.js} +22 -14
- package/dist/bundle/{chunk-7VU5UGRR.js → chunk-LEA4BGK7.js} +16 -16
- package/dist/bundle/{chunk-ZMPTO2WB.js → chunk-LQX74VKG.js} +1 -1
- package/dist/bundle/{chunk-LKJXTACE.js → chunk-MJMVIFSC.js} +7 -7
- package/dist/bundle/{chunk-KWRSC6O6.js → chunk-MNOVYS43.js} +18 -4
- package/dist/bundle/{chunk-M43MBWJX.js → chunk-MOTKS7XG.js} +20741 -14882
- package/dist/bundle/{chunk-MWEOVTIF.js → chunk-MSDCZ6GT.js} +4 -4
- package/dist/bundle/{chunk-SOZVC3SV.js → chunk-MVDPZRFE.js} +1 -1
- package/dist/bundle/{chunk-NTZDM5SJ.js → chunk-NRRI37NJ.js} +9 -9
- package/dist/bundle/{chunk-BKY4XVB4.js → chunk-O7L44JK2.js} +2632 -1870
- package/dist/bundle/{chunk-6IBM4Z3V.js → chunk-OE7EIP5L.js} +1 -1
- package/dist/bundle/{chunk-RAMPYIO2.js → chunk-OSBHEM2A.js} +11 -11
- package/dist/bundle/{chunk-KV4267S4.js → chunk-P3ASN72F.js} +1 -1
- package/dist/bundle/{chunk-DG4DWAU7.js → chunk-QLGG7S6F.js} +3 -3
- package/dist/bundle/{chunk-6UFWFKFH.js → chunk-QW5VPZEH.js} +2 -2
- package/dist/bundle/{chunk-C6UKW7JO.js → chunk-QXM7S3Y3.js} +6 -6
- package/dist/bundle/{chunk-ESFMHBHH.js → chunk-R2ULMWB4.js} +62 -53
- package/dist/bundle/{chunk-L6WUAGPN.js → chunk-R3JYPY3J.js} +3 -3
- package/dist/bundle/{chunk-2UW533HQ.js → chunk-RGJ7OWHU.js} +4 -4
- package/dist/bundle/{chunk-7K5TDTZY.js → chunk-RPQ3JOD3.js} +7 -7
- package/dist/bundle/{chunk-L643D4RJ.js → chunk-S2EAGDS7.js} +12 -12
- package/dist/bundle/{chunk-4KDZ22RA.js → chunk-SQT47CFW.js} +1 -1
- package/dist/bundle/{chunk-CLEZE65P.js → chunk-SZ3Z4ZNO.js} +1 -1
- package/dist/bundle/chunk-T5X4LGXE.js +380 -0
- package/dist/bundle/{chunk-SMVO5R3T.js → chunk-TFFEFEG2.js} +39 -26
- package/dist/bundle/{chunk-LFQ73UFK.js → chunk-TKXLWFM2.js} +3 -3
- package/dist/bundle/{chunk-SCFFCIIP.js → chunk-TN77LX6W.js} +2 -2
- package/dist/bundle/{chunk-VFIEYRYD.js → chunk-TWIC6JJG.js} +8 -8
- package/dist/bundle/{chunk-FXQPK742.js → chunk-UEZ6URJR.js} +29 -15
- package/dist/bundle/{chunk-OZEYFJX2.js → chunk-V4MM6GST.js} +1 -1
- package/dist/bundle/chunk-V74QFMSL.js +31 -0
- package/dist/bundle/{chunk-YPF6OS37.js → chunk-VW6BF6M7.js} +1 -1
- package/dist/bundle/{chunk-6TZF2JP7.js → chunk-WY4NYPPS.js} +13 -13
- package/dist/bundle/{chunk-B5Z4XPVS.js → chunk-XITUFTON.js} +2 -2
- package/dist/bundle/{chunk-FWU3ZYHE.js → chunk-XJBYGMZ4.js} +776 -134
- package/dist/bundle/{chunk-KANH7GBB.js → chunk-XRZDYWF6.js} +2 -2
- package/dist/bundle/{chunk-ZRMZBMOF.js → chunk-Z6TTGTMU.js} +156 -9
- package/dist/bundle/{chunk-IFDO3YPJ.js → chunk-ZRHMB3LQ.js} +1 -1
- package/dist/bundle/{cli-YUATSOLA.js → cli-P3BZUE6S.js} +106 -64
- package/dist/bundle/command-contract-TOLB32NJ.js +41 -0
- package/dist/bundle/config-4KLLIADY.js +90 -0
- package/dist/bundle/{decode-IL44LNC3.js → decode-QWOQXM7M.js} +6 -6
- package/dist/bundle/{dispatch-3BGIXSJR.js → dispatch-5MGDLOK4.js} +9 -9
- package/dist/bundle/{dist-3W27UQ2S.js → dist-OUE4MF37.js} +108 -28
- package/dist/bundle/{echarts-CO4D26JF.js → echarts-65IMPY43.js} +2 -2
- package/dist/bundle/{embed-XH2X4DFM.js → embed-4IULBCKL.js} +7 -7
- package/dist/bundle/{embedder-WTFWDXBJ.js → embedder-JW4W6IZI.js} +10 -10
- package/dist/bundle/{failure-HTIS3NLS.js → failure-CR64C4XA.js} +3 -3
- package/dist/bundle/{first-run-5RBH7FDO.js → first-run-CH6C674R.js} +12 -12
- package/dist/bundle/first-screen-OCAW5ZN6.js +39 -0
- package/dist/bundle/{folders-F4DNQPIY.js → folders-VU4IN35Y.js} +5 -5
- package/dist/bundle/{instructions-EPPBL6TT.js → instructions-G5QIH2TM.js} +1 -1
- package/dist/bundle/{main-LVQTCDZS.js → main-O4ZJIEWP.js} +21 -23
- package/dist/bundle/{mcp-PPVOM4SE.js → mcp-M4QN2E7R.js} +2 -2
- package/dist/bundle/{meetings-BMELXRTR.js → meetings-77CCAVYD.js} +13 -7
- package/dist/bundle/{node-CQVMWVIG.js → node-E6VQHU4Y.js} +2 -2
- package/dist/bundle/{node-sqlite-QQEX7LZT.js → node-sqlite-RJZ4PGLD.js} +7 -7
- package/dist/bundle/{oauth-AYGX7CQS.js → oauth-F4JKNRW4.js} +8 -8
- package/dist/bundle/{open-MIL2TOT6.js → open-NYOGMIAA.js} +6 -6
- package/dist/bundle/openai-5U6EQTFQ.js +25 -0
- package/dist/bundle/{output-file-4XADZPYH.js → output-file-6COFGPUL.js} +6 -6
- package/dist/bundle/{process-NJVQK6GB.js → process-OBWUKBMX.js} +1 -1
- package/dist/bundle/{program-WUYRS6H7.js → program-MU7DEJTO.js} +115 -187
- package/dist/bundle/{prompt-J4QPFLEA.js → prompt-2QWQTHWT.js} +6 -6
- package/dist/bundle/{recognize-OLJZVNWW.js → recognize-SNUNTUC3.js} +5 -5
- package/dist/bundle/{remote-JPUXNYLV.js → remote-2CTCIQGF.js} +8 -8
- package/dist/bundle/{rerank-XVV3X5TT.js → rerank-XDA7NJNH.js} +8 -8
- package/dist/bundle/{run-log-DJXBEVS5.js → run-log-NSG3DJVX.js} +59 -59
- package/dist/bundle/{serve-NYYUO3MR.js → serve-TWQFHOV2.js} +10 -10
- package/dist/bundle/{server-4Z5E4YTT.js → server-RIQ6HMH2.js} +47 -47
- package/dist/bundle/server-XO6XQQTJ.js +72 -0
- package/dist/bundle/{services-EKWM76HP.js → services-NKZQJQIV.js} +49 -33
- package/dist/bundle/{speech-WFJ44ACJ.js → speech-ZOB76SXA.js} +14 -14
- package/dist/bundle/{state-VIRCT4VW.js → state-7YYEIXQ5.js} +7 -7
- package/dist/bundle/{store-ZTDZ6UY5.js → store-E6RTSSNR.js} +29 -18
- package/dist/bundle/{store-2Q4GEZJS.js → store-OX4HRBLO.js} +80 -29
- package/dist/bundle/store-connection-55QPNUDS.js +83 -0
- package/dist/bundle/store-maintenance-command-Q5MSU6OK.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-TSI2MGVK.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-3ZIHUSMM.js +0 -22
- 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-J3ZBEWQY.js +0 -880
- package/dist/bundle/chunk-SXFODCYK.js +0 -9
- package/dist/bundle/chunk-YRNZT4GQ.js +0 -176
- 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-XITUFTON.js";
|
|
6
6
|
import {
|
|
7
7
|
answerOf,
|
|
8
8
|
messengerContext
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-R2ULMWB4.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-TFFEFEG2.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-TKXLWFM2.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-JZ4YOAHA.js";
|
|
40
|
+
import {
|
|
41
|
+
QUICK_HEALTH_CHECKS,
|
|
42
|
+
explainDamage,
|
|
43
|
+
fts5Tables,
|
|
44
|
+
invalidJson,
|
|
45
|
+
storeHealth
|
|
46
|
+
} from "./chunk-HSI7YOYK.js";
|
|
39
47
|
import {
|
|
40
48
|
Command,
|
|
41
49
|
LOCAL_READ,
|
|
@@ -59,31 +67,33 @@ import {
|
|
|
59
67
|
snakeKeys,
|
|
60
68
|
storeTable,
|
|
61
69
|
withoutProviderRefs
|
|
62
|
-
} from "./chunk-
|
|
70
|
+
} from "./chunk-G6IX2MD2.js";
|
|
63
71
|
import {
|
|
64
72
|
envName
|
|
65
|
-
} from "./chunk-
|
|
73
|
+
} from "./chunk-TN77LX6W.js";
|
|
66
74
|
import {
|
|
67
75
|
holdersOf
|
|
68
|
-
} from "./chunk-
|
|
76
|
+
} from "./chunk-MVDPZRFE.js";
|
|
69
77
|
import {
|
|
70
78
|
codeOf,
|
|
71
79
|
currentRun,
|
|
72
80
|
parseDuration
|
|
73
|
-
} from "./chunk-
|
|
74
|
-
import {
|
|
75
|
-
failureKey
|
|
76
|
-
} from "./chunk-3ZIHUSMM.js";
|
|
81
|
+
} from "./chunk-CUZHKYC2.js";
|
|
77
82
|
import {
|
|
78
83
|
levelFor
|
|
79
|
-
} from "./chunk-
|
|
84
|
+
} from "./chunk-IEC4E65G.js";
|
|
80
85
|
import {
|
|
86
|
+
CORPORA,
|
|
81
87
|
MIGRATIONS,
|
|
88
|
+
drainCorpus,
|
|
89
|
+
drainMeetingIndex,
|
|
82
90
|
drainNoteIndex,
|
|
83
91
|
dropAllUnusedVectors,
|
|
84
92
|
fileFacts,
|
|
85
93
|
fillSearchIndex,
|
|
86
94
|
fillStems,
|
|
95
|
+
fillTrigrams,
|
|
96
|
+
fillVectorIndexes,
|
|
87
97
|
involvementStoreOver,
|
|
88
98
|
migrate,
|
|
89
99
|
noteIndexState,
|
|
@@ -92,10 +102,12 @@ import {
|
|
|
92
102
|
orphanPointers,
|
|
93
103
|
pendingNormalization,
|
|
94
104
|
readStoreTables,
|
|
105
|
+
rebuildMentions,
|
|
95
106
|
resetAttachmentWords,
|
|
96
107
|
resetNoteIndex,
|
|
97
108
|
resetSearchIndex,
|
|
98
109
|
resetStems,
|
|
110
|
+
rollBack,
|
|
99
111
|
rowCounts,
|
|
100
112
|
searchIndexState,
|
|
101
113
|
stemmerCache,
|
|
@@ -103,38 +115,47 @@ import {
|
|
|
103
115
|
storeClients,
|
|
104
116
|
storeContents,
|
|
105
117
|
vectorIndexCounts
|
|
106
|
-
} from "./chunk-
|
|
118
|
+
} from "./chunk-MOTKS7XG.js";
|
|
107
119
|
import {
|
|
108
120
|
formatLocator,
|
|
109
121
|
parseLocator
|
|
110
|
-
} from "./chunk-
|
|
122
|
+
} from "./chunk-6AMMTXEA.js";
|
|
123
|
+
import {
|
|
124
|
+
readDamageMark,
|
|
125
|
+
readHealthMark,
|
|
126
|
+
recordDeepCheck
|
|
127
|
+
} from "./chunk-T5X4LGXE.js";
|
|
128
|
+
import {
|
|
129
|
+
failureKey,
|
|
130
|
+
isStoreDamage
|
|
131
|
+
} from "./chunk-37B7A4RP.js";
|
|
111
132
|
import {
|
|
112
133
|
readSecret
|
|
113
|
-
} from "./chunk-
|
|
134
|
+
} from "./chunk-QLGG7S6F.js";
|
|
114
135
|
import {
|
|
115
136
|
checkedOptions,
|
|
116
137
|
range
|
|
117
|
-
} from "./chunk-
|
|
138
|
+
} from "./chunk-2SYWVIQJ.js";
|
|
118
139
|
import {
|
|
119
140
|
messagesFor,
|
|
120
141
|
systemFor,
|
|
121
142
|
validateImages
|
|
122
|
-
} from "./chunk-
|
|
143
|
+
} from "./chunk-QW5VPZEH.js";
|
|
123
144
|
import {
|
|
124
145
|
storePath
|
|
125
|
-
} from "./chunk-
|
|
146
|
+
} from "./chunk-CKK6JOC4.js";
|
|
126
147
|
import {
|
|
127
148
|
openCache
|
|
128
|
-
} from "./chunk-
|
|
149
|
+
} from "./chunk-QXM7S3Y3.js";
|
|
129
150
|
import {
|
|
130
151
|
queryFieldsOf
|
|
131
|
-
} from "./chunk-
|
|
152
|
+
} from "./chunk-B6JMVB6R.js";
|
|
132
153
|
import {
|
|
133
154
|
Credentials,
|
|
134
155
|
pathsAreOverridden,
|
|
135
156
|
resolvePaths,
|
|
136
157
|
writeSecurely
|
|
137
|
-
} from "./chunk-
|
|
158
|
+
} from "./chunk-KNE6VFHZ.js";
|
|
138
159
|
import {
|
|
139
160
|
array,
|
|
140
161
|
boolean,
|
|
@@ -158,10 +179,10 @@ import {
|
|
|
158
179
|
transform,
|
|
159
180
|
trim,
|
|
160
181
|
union
|
|
161
|
-
} from "./chunk-
|
|
182
|
+
} from "./chunk-NRRI37NJ.js";
|
|
162
183
|
import {
|
|
163
184
|
CliError
|
|
164
|
-
} from "./chunk-
|
|
185
|
+
} from "./chunk-FEM2JQN2.js";
|
|
165
186
|
import {
|
|
166
187
|
__commonJS,
|
|
167
188
|
__name,
|
|
@@ -1815,7 +1836,7 @@ var require_liquid_node = __commonJS({
|
|
|
1815
1836
|
return readFileAsync(filepath, "utf8");
|
|
1816
1837
|
}
|
|
1817
1838
|
__name(readFile, "readFile");
|
|
1818
|
-
function
|
|
1839
|
+
function existsSync10(filepath) {
|
|
1819
1840
|
try {
|
|
1820
1841
|
fs$1.statSync(filepath);
|
|
1821
1842
|
return true;
|
|
@@ -1823,11 +1844,11 @@ var require_liquid_node = __commonJS({
|
|
|
1823
1844
|
return false;
|
|
1824
1845
|
}
|
|
1825
1846
|
}
|
|
1826
|
-
__name(
|
|
1827
|
-
function
|
|
1847
|
+
__name(existsSync10, "existsSync");
|
|
1848
|
+
function readFileSync5(filepath) {
|
|
1828
1849
|
return fs$1.readFileSync(filepath, "utf8");
|
|
1829
1850
|
}
|
|
1830
|
-
__name(
|
|
1851
|
+
__name(readFileSync5, "readFileSync");
|
|
1831
1852
|
function resolve2(root, file2, ext) {
|
|
1832
1853
|
if (!path.extname(file2))
|
|
1833
1854
|
file2 += ext;
|
|
@@ -1841,10 +1862,10 @@ var require_liquid_node = __commonJS({
|
|
|
1841
1862
|
}
|
|
1842
1863
|
}
|
|
1843
1864
|
__name(fallback, "fallback");
|
|
1844
|
-
function
|
|
1865
|
+
function dirname3(filepath) {
|
|
1845
1866
|
return path.dirname(filepath);
|
|
1846
1867
|
}
|
|
1847
|
-
__name(
|
|
1868
|
+
__name(dirname3, "dirname");
|
|
1848
1869
|
var realpathAsync = promisify(fs$1.realpath);
|
|
1849
1870
|
async function contains(root, file2) {
|
|
1850
1871
|
try {
|
|
@@ -1872,11 +1893,11 @@ var require_liquid_node = __commonJS({
|
|
|
1872
1893
|
__proto__: null,
|
|
1873
1894
|
exists,
|
|
1874
1895
|
readFile,
|
|
1875
|
-
existsSync:
|
|
1876
|
-
readFileSync:
|
|
1896
|
+
existsSync: existsSync10,
|
|
1897
|
+
readFileSync: readFileSync5,
|
|
1877
1898
|
resolve: resolve2,
|
|
1878
1899
|
fallback,
|
|
1879
|
-
dirname:
|
|
1900
|
+
dirname: dirname3,
|
|
1880
1901
|
contains,
|
|
1881
1902
|
containsSync,
|
|
1882
1903
|
sep: path.sep
|
|
@@ -3601,7 +3622,7 @@ var require_liquid_node = __commonJS({
|
|
|
3601
3622
|
uri_escape,
|
|
3602
3623
|
slugify
|
|
3603
3624
|
});
|
|
3604
|
-
var
|
|
3625
|
+
var join5 = argumentsToValue(function(v, arg) {
|
|
3605
3626
|
const array2 = toArray(v);
|
|
3606
3627
|
const sep = isNil(arg) ? " " : stringify(arg);
|
|
3607
3628
|
let outputSize = sep.length * Math.max(array2.length - 1, 0);
|
|
@@ -3877,7 +3898,7 @@ var require_liquid_node = __commonJS({
|
|
|
3877
3898
|
__name(sample, "sample");
|
|
3878
3899
|
var arrayFilters = /* @__PURE__ */ Object.freeze({
|
|
3879
3900
|
__proto__: null,
|
|
3880
|
-
join:
|
|
3901
|
+
join: join5,
|
|
3881
3902
|
last,
|
|
3882
3903
|
first,
|
|
3883
3904
|
reverse,
|
|
@@ -5501,11 +5522,11 @@ var require_liquid_node = __commonJS({
|
|
|
5501
5522
|
}
|
|
5502
5523
|
});
|
|
5503
5524
|
|
|
5504
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5505
|
-
import { chmodSync, constants, copyFileSync, existsSync as
|
|
5506
|
-
import { dirname, resolve } from "node:path";
|
|
5525
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3e7ac84c094d466aed903c683c124ab5/node_modules/@wirecat/cli-core/dist/cli/messenger/store-maintenance-command.js
|
|
5526
|
+
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";
|
|
5527
|
+
import { dirname as dirname2, resolve } from "node:path";
|
|
5507
5528
|
|
|
5508
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5529
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3e7ac84c094d466aed903c683c124ab5/node_modules/@wirecat/cli-core/dist/sealed.js
|
|
5509
5530
|
import { createCipheriv, createDecipheriv, createHash, randomBytes, scrypt, timingSafeEqual } from "node:crypto";
|
|
5510
5531
|
import { closeSync, createReadStream, createWriteStream, existsSync, openSync, readSync, renameSync, rmSync, statSync } from "node:fs";
|
|
5511
5532
|
import { Transform } from "node:stream";
|
|
@@ -5612,7 +5633,7 @@ var unsealFile = /* @__PURE__ */ __name(async (from, to, password) => {
|
|
|
5612
5633
|
renameSync(pending, to);
|
|
5613
5634
|
}, "unsealFile");
|
|
5614
5635
|
|
|
5615
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5636
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3e7ac84c094d466aed903c683c124ab5/node_modules/@wirecat/cli-core/dist/store/compatibility.js
|
|
5616
5637
|
var SPEAKS = MIGRATIONS.at(-1)?.version ?? 0;
|
|
5617
5638
|
var fileSchemaOf = /* @__PURE__ */ __name((database) => {
|
|
5618
5639
|
const tracked = database.prepare("SELECT 1 FROM sqlite_master WHERE name = 'schema_migrations'").get();
|
|
@@ -5636,7 +5657,7 @@ var compatibilityOf = /* @__PURE__ */ __name((file2, migrations = MIGRATIONS) =>
|
|
|
5636
5657
|
};
|
|
5637
5658
|
}, "compatibilityOf");
|
|
5638
5659
|
|
|
5639
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5660
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3e7ac84c094d466aed903c683c124ab5/node_modules/@wirecat/cli-core/dist/store/repair.js
|
|
5640
5661
|
import { createHash as createHash2 } from "node:crypto";
|
|
5641
5662
|
var COPY_MARK = "__repair_";
|
|
5642
5663
|
var COPY_NAME = /__repair_[0-9a-f]{8}(_\d+)?$/;
|
|
@@ -5890,10 +5911,545 @@ var deleteCopy = /* @__PURE__ */ __name((database, name) => {
|
|
|
5890
5911
|
return found;
|
|
5891
5912
|
}, "deleteCopy");
|
|
5892
5913
|
|
|
5893
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5894
|
-
import { existsSync as
|
|
5914
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3e7ac84c094d466aed903c683c124ab5/node_modules/@wirecat/cli-core/dist/cli/store-info.js
|
|
5915
|
+
import { existsSync as existsSync4, statSync as statSync3 } from "node:fs";
|
|
5916
|
+
|
|
5917
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3e7ac84c094d466aed903c683c124ab5/node_modules/@wirecat/cli-core/dist/cli/store-recover.js
|
|
5918
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
5919
|
+
|
|
5920
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3e7ac84c094d466aed903c683c124ab5/node_modules/@wirecat/cli-core/dist/store/recover.js
|
|
5921
|
+
import { execFileSync, spawn } from "node:child_process";
|
|
5922
|
+
import { existsSync as existsSync2, readFileSync, realpathSync, renameSync as renameSync2, rmSync as rmSync2, statfsSync, statSync as statSync2, writeFileSync } from "node:fs";
|
|
5923
|
+
import { basename, dirname, join } from "node:path";
|
|
5924
|
+
import { Transform as Transform2 } from "node:stream";
|
|
5925
|
+
var SQLITE3_MINIMUM = [3, 43, 0];
|
|
5926
|
+
var STORE_PARTS = ["", "-wal", "-shm"];
|
|
5927
|
+
var RECOVER_LOCK = ".recover-lock";
|
|
5928
|
+
var INSERTED = /^INSERT OR IGNORE INTO '([^']+)'/;
|
|
5929
|
+
var LOST_AND_FOUND = "recover_lost_and_found";
|
|
5930
|
+
var recovers = /* @__PURE__ */ __name((program) => {
|
|
5931
|
+
try {
|
|
5932
|
+
execFileSync(program, [":memory:", ".recover"], { stdio: ["ignore", "ignore", "pipe"] });
|
|
5933
|
+
return true;
|
|
5934
|
+
} catch {
|
|
5935
|
+
return false;
|
|
5936
|
+
}
|
|
5937
|
+
}, "recovers");
|
|
5938
|
+
var sqlite3Program = /* @__PURE__ */ __name((program = "sqlite3") => {
|
|
5939
|
+
let version = null;
|
|
5940
|
+
try {
|
|
5941
|
+
version = execFileSync(program, ["--version"], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).split(" ")[0] ?? null;
|
|
5942
|
+
} catch {
|
|
5943
|
+
return { program, version: null, usable: false };
|
|
5944
|
+
}
|
|
5945
|
+
const parts = (version ?? "").split(".").map(Number);
|
|
5946
|
+
const at = SQLITE3_MINIMUM.findIndex((wanted, i) => (parts[i] ?? 0) !== wanted);
|
|
5947
|
+
const recent = at === -1 || (parts[at] ?? 0) > (SQLITE3_MINIMUM[at] ?? 0);
|
|
5948
|
+
return { program, version, usable: recent && recovers(program) };
|
|
5949
|
+
}, "sqlite3Program");
|
|
5950
|
+
var activeTimers = /* @__PURE__ */ __name(() => {
|
|
5951
|
+
if (process.platform !== "linux")
|
|
5952
|
+
return void 0;
|
|
5953
|
+
try {
|
|
5954
|
+
return execFileSync("systemctl", ["--user", "list-timers", "--plain", "--no-legend"], {
|
|
5955
|
+
encoding: "utf8",
|
|
5956
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
5957
|
+
}).split("\n").map((line) => line.trim().split(/\s+/).at(-2) ?? "").filter((unit) => /^(memo|mail|tg|max|whatsapp|zoom|drive|gcal|wirecat)-.*\.timer$/.test(unit));
|
|
5958
|
+
} catch {
|
|
5959
|
+
return void 0;
|
|
5960
|
+
}
|
|
5961
|
+
}, "activeTimers");
|
|
5962
|
+
var alive = /* @__PURE__ */ __name((pid) => {
|
|
5963
|
+
try {
|
|
5964
|
+
process.kill(pid, 0);
|
|
5965
|
+
return true;
|
|
5966
|
+
} catch (error) {
|
|
5967
|
+
return error.code === "EPERM";
|
|
5968
|
+
}
|
|
5969
|
+
}, "alive");
|
|
5970
|
+
var runningRecovery = /* @__PURE__ */ __name((path) => {
|
|
5971
|
+
let pid;
|
|
5972
|
+
try {
|
|
5973
|
+
pid = Number(readFileSync(`${path}${RECOVER_LOCK}`, "utf8").trim());
|
|
5974
|
+
} catch {
|
|
5975
|
+
return null;
|
|
5976
|
+
}
|
|
5977
|
+
return Number.isInteger(pid) && pid > 0 && alive(pid) ? pid : null;
|
|
5978
|
+
}, "runningRecovery");
|
|
5979
|
+
var takeRecoverLock = /* @__PURE__ */ __name((path) => {
|
|
5980
|
+
const lock = `${path}${RECOVER_LOCK}`;
|
|
5981
|
+
const take = /* @__PURE__ */ __name(() => writeFileSync(lock, String(process.pid), { flag: "wx", mode: 384 }), "take");
|
|
5982
|
+
try {
|
|
5983
|
+
take();
|
|
5984
|
+
} catch (error) {
|
|
5985
|
+
if (error.code !== "EEXIST")
|
|
5986
|
+
throw error;
|
|
5987
|
+
const pid = runningRecovery(path);
|
|
5988
|
+
if (pid === null) {
|
|
5989
|
+
rmSync2(lock, { force: true });
|
|
5990
|
+
take();
|
|
5991
|
+
} else {
|
|
5992
|
+
throw new CliError("validation_error", `the store is being recovered by process ${pid} \u2014 wait for it to finish`, {
|
|
5993
|
+
reason: "store.recovering"
|
|
5994
|
+
});
|
|
5995
|
+
}
|
|
5996
|
+
}
|
|
5997
|
+
return () => rmSync2(lock, { force: true });
|
|
5998
|
+
}, "takeRecoverLock");
|
|
5999
|
+
var storeHolders = /* @__PURE__ */ __name((path) => {
|
|
6000
|
+
const folder = realpathSync(dirname(path));
|
|
6001
|
+
const files = STORE_PARTS.map((suffix) => join(folder, `${basename(path)}${suffix}`));
|
|
6002
|
+
const wanted = process.platform === "linux" ? files.flatMap((file2) => [file2, `${file2} (deleted)`]) : files.filter(existsSync2);
|
|
6003
|
+
const recovering = runningRecovery(path);
|
|
6004
|
+
const pids = holdersOf(wanted);
|
|
6005
|
+
if (pids === void 0 && recovering === null)
|
|
6006
|
+
return void 0;
|
|
6007
|
+
const all = [
|
|
6008
|
+
.../* @__PURE__ */ new Set([...pids ?? [], ...recovering !== null && recovering !== process.pid ? [recovering] : []])
|
|
6009
|
+
];
|
|
6010
|
+
return all.map((pid) => {
|
|
6011
|
+
let name = "?";
|
|
6012
|
+
try {
|
|
6013
|
+
name = readFileSync(`/proc/${pid}/comm`, "utf8").trim();
|
|
6014
|
+
} catch {
|
|
6015
|
+
}
|
|
6016
|
+
return { pid, name };
|
|
6017
|
+
});
|
|
6018
|
+
}, "storeHolders");
|
|
6019
|
+
var tableRows = /* @__PURE__ */ __name((database) => {
|
|
6020
|
+
const indexes = fts5Tables(database).map((index) => index.name);
|
|
6021
|
+
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}_`)));
|
|
6022
|
+
return Object.fromEntries(tables.map((table) => {
|
|
6023
|
+
try {
|
|
6024
|
+
return [table, Number(database.prepare(`SELECT count(*) AS n FROM "${table}"`).get()?.n)];
|
|
6025
|
+
} catch {
|
|
6026
|
+
return [table, null];
|
|
6027
|
+
}
|
|
6028
|
+
}));
|
|
6029
|
+
}, "tableRows");
|
|
6030
|
+
var copyReadableRows = /* @__PURE__ */ __name((path, target, program = "sqlite3") => new Promise((resolve2, reject) => {
|
|
6031
|
+
const reader = spawn(program, ["-readonly", path, `.recover --ignore-freelist --lost-and-found ${LOST_AND_FOUND}`], {
|
|
6032
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
6033
|
+
});
|
|
6034
|
+
const writer = spawn(program, ["-cmd", ".dbconfig defensive off", target], { stdio: ["pipe", "ignore", "pipe"] });
|
|
6035
|
+
const errors = [];
|
|
6036
|
+
const collect = /* @__PURE__ */ __name((chunk) => {
|
|
6037
|
+
for (const line of chunk.toString("utf8").split("\n"))
|
|
6038
|
+
if (line && errors.length < 50)
|
|
6039
|
+
errors.push(line.slice(0, 300));
|
|
6040
|
+
}, "collect");
|
|
6041
|
+
reader.stderr.on("data", collect);
|
|
6042
|
+
writer.stderr.on("data", collect);
|
|
6043
|
+
const read = {};
|
|
6044
|
+
let rest = "";
|
|
6045
|
+
const counter = new Transform2({
|
|
6046
|
+
transform(chunk, _encoding, done) {
|
|
6047
|
+
const lines = (rest + chunk.toString("latin1")).split("\n");
|
|
6048
|
+
rest = lines.pop() ?? "";
|
|
6049
|
+
for (const line of lines) {
|
|
6050
|
+
const table = INSERTED.exec(line)?.[1];
|
|
6051
|
+
if (table)
|
|
6052
|
+
read[table] = (read[table] ?? 0) + 1;
|
|
6053
|
+
}
|
|
6054
|
+
done(null, chunk);
|
|
6055
|
+
}
|
|
6056
|
+
});
|
|
6057
|
+
reader.stdout.pipe(counter).pipe(writer.stdin);
|
|
6058
|
+
let exits = 0;
|
|
6059
|
+
let readerCode = null;
|
|
6060
|
+
const exited = /* @__PURE__ */ __name(() => {
|
|
6061
|
+
exits += 1;
|
|
6062
|
+
if (exits < 2)
|
|
6063
|
+
return;
|
|
6064
|
+
if (readerCode !== 0)
|
|
6065
|
+
reject(new CliError("validation_error", `sqlite3 could not read the store: ${errors.join("; ")}`));
|
|
6066
|
+
else
|
|
6067
|
+
resolve2({ errors, read });
|
|
6068
|
+
}, "exited");
|
|
6069
|
+
reader.on("error", reject);
|
|
6070
|
+
writer.on("error", reject);
|
|
6071
|
+
reader.on("close", (code) => {
|
|
6072
|
+
readerCode = code;
|
|
6073
|
+
exited();
|
|
6074
|
+
});
|
|
6075
|
+
writer.on("close", exited);
|
|
6076
|
+
}), "copyReadableRows");
|
|
6077
|
+
var FILLERS = {
|
|
6078
|
+
message_words: /* @__PURE__ */ __name((database, now) => {
|
|
6079
|
+
resetSearchIndex(database);
|
|
6080
|
+
fillSearchIndex(database, { now });
|
|
6081
|
+
}, "message_words"),
|
|
6082
|
+
message_stems: /* @__PURE__ */ __name((database, now) => {
|
|
6083
|
+
resetStems(database, { force: true, now });
|
|
6084
|
+
fillStems(database, { now });
|
|
6085
|
+
}, "message_stems"),
|
|
6086
|
+
attachment_words: /* @__PURE__ */ __name((database) => void resetAttachmentWords(database), "attachment_words"),
|
|
6087
|
+
attachment_name_words: /* @__PURE__ */ __name((database) => (
|
|
6088
|
+
// As migration 20 filled it: й and ё fold as the triggers fold them.
|
|
6089
|
+
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")
|
|
6090
|
+
), "attachment_name_words"),
|
|
6091
|
+
meeting_words: /* @__PURE__ */ __name((database) => {
|
|
6092
|
+
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");
|
|
6093
|
+
drainMeetingIndex(database);
|
|
6094
|
+
}, "meeting_words"),
|
|
6095
|
+
// Built per account by the first search that needs them.
|
|
6096
|
+
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")
|
|
6097
|
+
};
|
|
6098
|
+
var CORPUS_TABLES = new Set(Object.values(CORPORA).flatMap((corpus) => [`${corpus.type}_words`, `${corpus.type}_stems`]));
|
|
6099
|
+
var TRIGRAMS = ["note_trigrams", "document_trigrams"];
|
|
6100
|
+
var rebuildDerived = /* @__PURE__ */ __name((database, { now = Date.now, note = /* @__PURE__ */ __name(() => {
|
|
6101
|
+
}, "note") } = {}) => {
|
|
6102
|
+
const lost = database.prepare("SELECT 1 FROM sqlite_master WHERE name = ?").get(LOST_AND_FOUND);
|
|
6103
|
+
const lostAndFound = lost ? Number(database.prepare(`SELECT count(*) AS n FROM ${LOST_AND_FOUND}`).get()?.n) : 0;
|
|
6104
|
+
if (lost)
|
|
6105
|
+
database.exec(`DROP TABLE ${LOST_AND_FOUND}`);
|
|
6106
|
+
const indexes = fts5Tables(database);
|
|
6107
|
+
for (const { name, sql } of indexes) {
|
|
6108
|
+
database.exec(`DROP TABLE "${name}"`);
|
|
6109
|
+
database.exec(sql);
|
|
6110
|
+
}
|
|
6111
|
+
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));
|
|
6112
|
+
for (const table of vectors) {
|
|
6113
|
+
database.exec(`DROP TRIGGER IF EXISTS "${table}_redo"`);
|
|
6114
|
+
database.exec(`DROP TABLE "${table}"`);
|
|
6115
|
+
database.prepare("DELETE FROM vector_indexes WHERE id = ?").run(Number(table.replace("vector_index_", "")));
|
|
6116
|
+
}
|
|
6117
|
+
const unfilled = [];
|
|
6118
|
+
const stemmerFor = stemmerCache();
|
|
6119
|
+
for (const { name, external } of indexes) {
|
|
6120
|
+
note(`rebuilding ${name}`);
|
|
6121
|
+
if (external)
|
|
6122
|
+
database.exec(`INSERT INTO "${name}" ("${name}") VALUES ('rebuild')`);
|
|
6123
|
+
else if (FILLERS[name])
|
|
6124
|
+
FILLERS[name](database, now);
|
|
6125
|
+
else if (!CORPUS_TABLES.has(name) && !TRIGRAMS.includes(name))
|
|
6126
|
+
unfilled.push(name);
|
|
6127
|
+
}
|
|
6128
|
+
note("rebuilding the words of notes, documents, memories, mail, tasks, transcripts and events");
|
|
6129
|
+
resetNoteIndex(database);
|
|
6130
|
+
for (const corpus of Object.values(CORPORA))
|
|
6131
|
+
drainCorpus(database, corpus, stemmerFor);
|
|
6132
|
+
for (const name of TRIGRAMS) {
|
|
6133
|
+
const type = name.replace("_trigrams", "");
|
|
6134
|
+
database.prepare(`UPDATE search_index_state SET filled_through = 0, watermark = (SELECT coalesce(max(id), 0) FROM ${type}s) WHERE name = ?`).run(name);
|
|
6135
|
+
}
|
|
6136
|
+
fillTrigrams(database);
|
|
6137
|
+
note("finding mentions again");
|
|
6138
|
+
const mentions = rebuildMentions(database, { now: now() }).mentions;
|
|
6139
|
+
involvementStoreOver({ database, now }).rebuild();
|
|
6140
|
+
note("indexing the stored vectors");
|
|
6141
|
+
const vectorModels = fillVectorIndexes(database);
|
|
6142
|
+
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)");
|
|
6143
|
+
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)]));
|
|
6144
|
+
return {
|
|
6145
|
+
lostAndFound,
|
|
6146
|
+
searchIndexes: indexes.map((index) => index.name),
|
|
6147
|
+
unfilled,
|
|
6148
|
+
mentions,
|
|
6149
|
+
vectorModels,
|
|
6150
|
+
chunksWithoutVector
|
|
6151
|
+
};
|
|
6152
|
+
}, "rebuildDerived");
|
|
6153
|
+
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) => {
|
|
6154
|
+
const child = String(group.child);
|
|
6155
|
+
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;
|
|
6156
|
+
let missing = [];
|
|
6157
|
+
try {
|
|
6158
|
+
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));
|
|
6159
|
+
} catch {
|
|
6160
|
+
}
|
|
6161
|
+
return { table: child, parent: String(group.parent), rows: Number(group.n), missing };
|
|
6162
|
+
}), "danglingRows");
|
|
6163
|
+
var mailToFetch = /* @__PURE__ */ __name((database) => {
|
|
6164
|
+
try {
|
|
6165
|
+
return database.prepare(`SELECT a.external_id AS account, count(DISTINCT l.email_id) AS n FROM email_locations l
|
|
6166
|
+
JOIN mailboxes b ON b.id = l.mailbox_id JOIN accounts a ON a.id = b.account_id
|
|
6167
|
+
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) }));
|
|
6168
|
+
} catch {
|
|
6169
|
+
return [];
|
|
6170
|
+
}
|
|
6171
|
+
}, "mailToFetch");
|
|
6172
|
+
var clearInvalidJson = /* @__PURE__ */ __name((database) => {
|
|
6173
|
+
const found = invalidJson(database);
|
|
6174
|
+
for (const { table, column, required } of found) {
|
|
6175
|
+
const invalid = `"${column}" IS NOT NULL AND NOT json_valid("${column}")`;
|
|
6176
|
+
database.exec(required ? `DELETE FROM "${table}" WHERE ${invalid}` : `UPDATE "${table}" SET "${column}" = NULL WHERE ${invalid}`);
|
|
6177
|
+
}
|
|
6178
|
+
return found;
|
|
6179
|
+
}, "clearInvalidJson");
|
|
6180
|
+
var refuseInUse = /* @__PURE__ */ __name((path) => {
|
|
6181
|
+
const holders = storeHolders(path);
|
|
6182
|
+
if (holders && holders.length > 0) {
|
|
6183
|
+
const timers = activeTimers() ?? [];
|
|
6184
|
+
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" });
|
|
6185
|
+
}
|
|
6186
|
+
}, "refuseInUse");
|
|
6187
|
+
var recoverStore = /* @__PURE__ */ __name(async ({ path, command, version, sqlite3 = "sqlite3", now = Date.now, note = /* @__PURE__ */ __name(() => {
|
|
6188
|
+
}, "note"), copy }) => {
|
|
6189
|
+
const started = Date.now();
|
|
6190
|
+
if (!existsSync2(path))
|
|
6191
|
+
throw new CliError("not_found", `no store at ${path}`);
|
|
6192
|
+
const program = copy ? { program: sqlite3, version: "given", usable: true } : sqlite3Program(sqlite3);
|
|
6193
|
+
if (!program.usable) {
|
|
6194
|
+
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" });
|
|
6195
|
+
}
|
|
6196
|
+
const releaseLock2 = takeRecoverLock(path);
|
|
6197
|
+
try {
|
|
6198
|
+
refuseInUse(path);
|
|
6199
|
+
const bytes = STORE_PARTS.reduce((sum, suffix) => sum + (statSync2(`${path}${suffix}`, { throwIfNoEntry: false })?.size ?? 0), 0);
|
|
6200
|
+
const { bavail, bsize } = statfsSync(dirname(path));
|
|
6201
|
+
if (Number(bavail) * Number(bsize) < bytes * 1.2)
|
|
6202
|
+
throw new CliError("validation_error", `the recovery needs about ${Math.ceil(bytes * 1.2 / 1e9)} GB free beside the store`);
|
|
6203
|
+
return await recoverLocked({ path, command, version, sqlite3, now, note, copy, started, program });
|
|
6204
|
+
} finally {
|
|
6205
|
+
releaseLock2();
|
|
6206
|
+
}
|
|
6207
|
+
}, "recoverStore");
|
|
6208
|
+
var recoverLocked = /* @__PURE__ */ __name(async ({ path, command, version, sqlite3, now, note, copy, started, program }) => {
|
|
6209
|
+
const watch = (await openSqlite(path, { readOnly: true })).database;
|
|
6210
|
+
let watching = true;
|
|
6211
|
+
const stopWatching = /* @__PURE__ */ __name(() => {
|
|
6212
|
+
if (watching)
|
|
6213
|
+
watch.close();
|
|
6214
|
+
watching = false;
|
|
6215
|
+
}, "stopWatching");
|
|
6216
|
+
try {
|
|
6217
|
+
const dataVersion = /* @__PURE__ */ __name(() => Number(watch.prepare("PRAGMA data_version").get()?.data_version), "dataVersion");
|
|
6218
|
+
let rowsBefore;
|
|
6219
|
+
try {
|
|
6220
|
+
rowsBefore = tableRows(watch);
|
|
6221
|
+
} catch (error) {
|
|
6222
|
+
if (!isStoreDamage(error))
|
|
6223
|
+
throw error;
|
|
6224
|
+
throw new CliError("configuration_error", "the store file's header or schema is damaged, so its tables cannot be listed and it cannot be recovered; the file was left as it was", { reason: "store.unreadable" });
|
|
6225
|
+
}
|
|
6226
|
+
const before = { data: dataVersion(), inode: statSync2(path).ino };
|
|
6227
|
+
const stamp = new Date(now()).toISOString().replace(/[:.]/g, "-");
|
|
6228
|
+
const target = `${path}.recovering-${stamp}`;
|
|
6229
|
+
writeFileSync(target, "", { flag: "wx", mode: 384 });
|
|
6230
|
+
const dropTarget = /* @__PURE__ */ __name(() => {
|
|
6231
|
+
for (const suffix of [...STORE_PARTS, "-journal"])
|
|
6232
|
+
rmSync2(`${target}${suffix}`, { force: true });
|
|
6233
|
+
}, "dropTarget");
|
|
6234
|
+
note(`copying the readable rows into ${target}`);
|
|
6235
|
+
let copied;
|
|
6236
|
+
let copyErrors;
|
|
6237
|
+
let read;
|
|
6238
|
+
let opened;
|
|
6239
|
+
try {
|
|
6240
|
+
;
|
|
6241
|
+
({ errors: copyErrors, read } = await (copy ?? ((from, to) => copyReadableRows(from, to, sqlite3)))(path, target));
|
|
6242
|
+
copied = Date.now();
|
|
6243
|
+
opened = await openSqlite(target);
|
|
6244
|
+
} catch (error) {
|
|
6245
|
+
dropTarget();
|
|
6246
|
+
throw error;
|
|
6247
|
+
}
|
|
6248
|
+
let rebuilt;
|
|
6249
|
+
let kept;
|
|
6250
|
+
let dangling;
|
|
6251
|
+
let json;
|
|
6252
|
+
let fetch2;
|
|
6253
|
+
let schema;
|
|
6254
|
+
try {
|
|
6255
|
+
kept = tableRows(opened.database);
|
|
6256
|
+
migrate(opened.database, { command, ...version ? { version } : {} });
|
|
6257
|
+
note("clearing values that are not valid JSON");
|
|
6258
|
+
json = clearInvalidJson(opened.database);
|
|
6259
|
+
rebuilt = rebuildDerived(opened.database, { now, note });
|
|
6260
|
+
note("looking for rows that point at rows that were lost");
|
|
6261
|
+
dangling = danglingRows(opened.database);
|
|
6262
|
+
fetch2 = mailToFetch(opened.database);
|
|
6263
|
+
schema = fileSchemaOf(opened.database).version;
|
|
6264
|
+
opened.database.exec("PRAGMA wal_checkpoint(TRUNCATE)");
|
|
6265
|
+
} catch (error) {
|
|
6266
|
+
opened.database.close();
|
|
6267
|
+
dropTarget();
|
|
6268
|
+
throw error;
|
|
6269
|
+
}
|
|
6270
|
+
opened.database.close();
|
|
6271
|
+
const rebuiltAt = Date.now();
|
|
6272
|
+
note("checking the recovered file");
|
|
6273
|
+
const health = await storeHealth(target, { deep: true });
|
|
6274
|
+
const checkedAt = Date.now();
|
|
6275
|
+
if (!health.ok) {
|
|
6276
|
+
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" });
|
|
6277
|
+
}
|
|
6278
|
+
refuseInUse(path);
|
|
6279
|
+
const changed = dataVersion() !== before.data || statSync2(path, { throwIfNoEntry: false })?.ino !== before.inode;
|
|
6280
|
+
stopWatching();
|
|
6281
|
+
if (changed) {
|
|
6282
|
+
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" });
|
|
6283
|
+
}
|
|
6284
|
+
const keptAt = `${path}.before-recover-${stamp}`;
|
|
6285
|
+
for (const suffix of STORE_PARTS)
|
|
6286
|
+
if (existsSync2(`${path}${suffix}`))
|
|
6287
|
+
renameSync2(`${path}${suffix}`, `${keptAt}${suffix}`);
|
|
6288
|
+
for (const suffix of STORE_PARTS)
|
|
6289
|
+
if (existsSync2(`${target}${suffix}`))
|
|
6290
|
+
renameSync2(`${target}${suffix}`, `${path}${suffix}`);
|
|
6291
|
+
recordDeepCheck(path, health, { cli: command, ...version ? { version } : {}, schema, now });
|
|
6292
|
+
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);
|
|
6293
|
+
const seconds = /* @__PURE__ */ __name((from, to) => Math.round((to - from) / 100) / 10, "seconds");
|
|
6294
|
+
return {
|
|
6295
|
+
path,
|
|
6296
|
+
keptAt,
|
|
6297
|
+
sqlite3: program.version,
|
|
6298
|
+
lost,
|
|
6299
|
+
dangling,
|
|
6300
|
+
invalidJson: json,
|
|
6301
|
+
mailToFetch: fetch2,
|
|
6302
|
+
rebuilt,
|
|
6303
|
+
copyErrors,
|
|
6304
|
+
health,
|
|
6305
|
+
seconds: {
|
|
6306
|
+
copy: seconds(started, copied),
|
|
6307
|
+
rebuild: seconds(copied, rebuiltAt),
|
|
6308
|
+
check: seconds(rebuiltAt, checkedAt),
|
|
6309
|
+
total: seconds(started, Date.now())
|
|
6310
|
+
}
|
|
6311
|
+
};
|
|
6312
|
+
} finally {
|
|
6313
|
+
stopWatching();
|
|
6314
|
+
}
|
|
6315
|
+
}, "recoverLocked");
|
|
6316
|
+
|
|
6317
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3e7ac84c094d466aed903c683c124ab5/node_modules/@wirecat/cli-core/dist/cli/store-recover.js
|
|
6318
|
+
var COUNTED = [
|
|
6319
|
+
"accounts",
|
|
6320
|
+
"chats",
|
|
6321
|
+
"messages",
|
|
6322
|
+
"attachments",
|
|
6323
|
+
"emails",
|
|
6324
|
+
"documents",
|
|
6325
|
+
"notes",
|
|
6326
|
+
"meetings",
|
|
6327
|
+
"chunks",
|
|
6328
|
+
"embeddings",
|
|
6329
|
+
"mentions"
|
|
6330
|
+
];
|
|
6331
|
+
var stopTimers = /* @__PURE__ */ __name((timers) => `systemctl --user stop ${timers.join(" ")}`, "stopTimers");
|
|
6332
|
+
var storeRecoveryCheck = /* @__PURE__ */ __name(async (env, command, version) => {
|
|
6333
|
+
const path = storePath(env);
|
|
6334
|
+
if (!existsSync3(path))
|
|
6335
|
+
return { path, exists: false, ok: true, next: [] };
|
|
6336
|
+
const health = await storeHealth(path, { deep: true });
|
|
6337
|
+
let rows = {};
|
|
6338
|
+
let schema = null;
|
|
6339
|
+
try {
|
|
6340
|
+
const { database } = await openSqlite(path, { readOnly: true });
|
|
6341
|
+
try {
|
|
6342
|
+
schema = fileSchemaOf(database).version;
|
|
6343
|
+
const all = tableRows(database);
|
|
6344
|
+
rows = Object.fromEntries(COUNTED.filter((table) => table in all).map((table) => [table, all[table] ?? null]));
|
|
6345
|
+
} finally {
|
|
6346
|
+
database.close();
|
|
6347
|
+
}
|
|
6348
|
+
} catch {
|
|
6349
|
+
}
|
|
6350
|
+
recordDeepCheck(path, health, { cli: command, ...version ? { version } : {}, schema });
|
|
6351
|
+
const mark = readDamageMark(path);
|
|
6352
|
+
const explanation = explainDamage(health, command, mark);
|
|
6353
|
+
const inUse = storeHolders(path) ?? null;
|
|
6354
|
+
const timers = activeTimers() ?? null;
|
|
6355
|
+
const sqlite3 = sqlite3Program();
|
|
6356
|
+
const next = health.ok ? [] : [
|
|
6357
|
+
...timers?.length ? [stopTimers(timers)] : [],
|
|
6358
|
+
...(inUse ?? []).map(({ pid, name }) => `stop ${name} (process ${pid}): it has the store open`),
|
|
6359
|
+
...sqlite3.usable ? [] : ["install sqlite3 3.43 or newer (apt install sqlite3, brew install sqlite)"],
|
|
6360
|
+
`${command} store recover run`
|
|
6361
|
+
];
|
|
6362
|
+
return {
|
|
6363
|
+
path,
|
|
6364
|
+
exists: true,
|
|
6365
|
+
ok: health.ok,
|
|
6366
|
+
seconds: Math.round(health.ms / 100) / 10,
|
|
6367
|
+
problems: health.problems ?? 0,
|
|
6368
|
+
damagedTables: health.damagedTables ?? [],
|
|
6369
|
+
damagedSearchIndexes: (health.searchIndexes ?? []).filter((index) => !index.ok).map(({ name, error }) => ({ name, ...error ? { error } : {} })),
|
|
6370
|
+
invalidJson: health.invalidJson ?? [],
|
|
6371
|
+
rows,
|
|
6372
|
+
explanation,
|
|
6373
|
+
damageMark: mark ? (({ inode: _, ...seen }) => seen)(mark) : null,
|
|
6374
|
+
lastKnownGood: readHealthMark(path)?.last_ok_at ?? null,
|
|
6375
|
+
inUse,
|
|
6376
|
+
timers,
|
|
6377
|
+
sqlite3: { version: sqlite3.version, usable: sqlite3.usable },
|
|
6378
|
+
next
|
|
6379
|
+
};
|
|
6380
|
+
}, "storeRecoveryCheck");
|
|
6381
|
+
var storeRecoveryRun = /* @__PURE__ */ __name(async (env, { command, version, note, timers: scheduled = activeTimers, copy }) => {
|
|
6382
|
+
const timers = scheduled() ?? [];
|
|
6383
|
+
if (timers.length > 0)
|
|
6384
|
+
throw new CliError("validation_error", `stop the timers first, they open the store: ${stopTimers(timers)}`, {
|
|
6385
|
+
reason: "store.in-use"
|
|
6386
|
+
});
|
|
6387
|
+
const recovery = await recoverStore({
|
|
6388
|
+
path: storePath(env),
|
|
6389
|
+
command,
|
|
6390
|
+
...version ? { version } : {},
|
|
6391
|
+
...note ? { note } : {},
|
|
6392
|
+
...copy ? { copy } : {}
|
|
6393
|
+
});
|
|
6394
|
+
const mail = recovery.mailToFetch.map(({ account, emails }) => `mail <profile of ${account}> sync --rescan # ${emails} emails`);
|
|
6395
|
+
const lostMail = recovery.lost.some(({ table }) => table === "emails") && mail.length === 0 ? ["mail <profile> sync --rescan # each mail profile"] : [];
|
|
6396
|
+
const { health, copyErrors, ...kept } = recovery;
|
|
6397
|
+
return {
|
|
6398
|
+
...kept,
|
|
6399
|
+
copyErrors: copyErrors.length,
|
|
6400
|
+
checkedOk: health.ok,
|
|
6401
|
+
next: [...mail, ...lostMail, "systemctl --user start <the timers stopped before>"]
|
|
6402
|
+
};
|
|
6403
|
+
}, "storeRecoveryRun");
|
|
6404
|
+
var recoveryNotes = /* @__PURE__ */ __name((answer) => {
|
|
6405
|
+
if ("keptAt" in answer) {
|
|
6406
|
+
const lost = answer.lost.map(({ table, before, read, kept }) => `${table}: ${kept} kept of ${before ?? "an uncountable number"}${read > kept ? `, ${read - kept} read but unusable` : ""}`);
|
|
6407
|
+
return [
|
|
6408
|
+
`recovered in ${answer.seconds.total} s; the damaged file is kept at ${answer.keptAt}`,
|
|
6409
|
+
...lost.length ? lost : ["no table lost a row"],
|
|
6410
|
+
...answer.dangling.map(({ table, parent, rows }) => `${rows} rows of ${table} point at ${parent} rows the store does not hold`),
|
|
6411
|
+
...answer.invalidJson.map(({ table, column, rows, required }) => `${table}.${column}: ${rows} values were not valid JSON \u2014 ${required ? "those rows were dropped" : "set to empty"}`),
|
|
6412
|
+
...answer.next.map((line) => `next: ${line}`)
|
|
6413
|
+
];
|
|
6414
|
+
}
|
|
6415
|
+
if (!answer.exists)
|
|
6416
|
+
return ["no store yet"];
|
|
6417
|
+
if (answer.ok)
|
|
6418
|
+
return [`the store is healthy (checked every page and search index in ${answer.seconds} s)`];
|
|
6419
|
+
const why = answer.explanation;
|
|
6420
|
+
return [
|
|
6421
|
+
...why ? [why.what, ...why.impact, why.externalUnaffected] : [],
|
|
6422
|
+
answer.lastKnownGood ? `the store last passed a deep check at ${answer.lastKnownGood}` : "no deep check that passed is on record for this store",
|
|
6423
|
+
...answer.next.map((line) => `next: ${line}`)
|
|
6424
|
+
];
|
|
6425
|
+
}, "recoveryNotes");
|
|
6426
|
+
var storeRecoverCommand = /* @__PURE__ */ __name(({ command, version }) => {
|
|
6427
|
+
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() {
|
|
6428
|
+
const output = outputFor(this);
|
|
6429
|
+
const answer = await storeRecoveryCheck(environmentOf(this).env ?? process.env, command, version);
|
|
6430
|
+
renderAnswer(this, output, itemOf(snakeKeys(answer)));
|
|
6431
|
+
if (output.format === "pretty")
|
|
6432
|
+
for (const line of recoveryNotes(answer))
|
|
6433
|
+
output.renderer.note(line);
|
|
6434
|
+
});
|
|
6435
|
+
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() {
|
|
6436
|
+
const output = outputFor(this);
|
|
6437
|
+
const answer = await storeRecoveryRun(environmentOf(this).env ?? process.env, {
|
|
6438
|
+
command,
|
|
6439
|
+
...version ? { version } : {},
|
|
6440
|
+
note: /* @__PURE__ */ __name((text) => output.renderer.note(text), "note")
|
|
6441
|
+
});
|
|
6442
|
+
renderAnswer(this, output, itemOf(snakeKeys(answer)));
|
|
6443
|
+
if (output.format === "pretty")
|
|
6444
|
+
for (const line of recoveryNotes(answer))
|
|
6445
|
+
output.renderer.note(line);
|
|
6446
|
+
}));
|
|
6447
|
+
return recover;
|
|
6448
|
+
}, "storeRecoverCommand");
|
|
6449
|
+
|
|
6450
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3e7ac84c094d466aed903c683c124ab5/node_modules/@wirecat/cli-core/dist/cli/store-info.js
|
|
5895
6451
|
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) =>
|
|
6452
|
+
var bytesOf = /* @__PURE__ */ __name((path) => existsSync4(path) ? statSync3(path).size : 0, "bytesOf");
|
|
5897
6453
|
var messageOf = /* @__PURE__ */ __name((error) => error instanceof Error ? error.message : String(error), "messageOf");
|
|
5898
6454
|
var contentsOf = /* @__PURE__ */ __name((database, version, writable) => version > 0 && writable ? {
|
|
5899
6455
|
rows: rowCounts(database),
|
|
@@ -5904,7 +6460,7 @@ var contentsOf = /* @__PURE__ */ __name((database, version, writable) => version
|
|
|
5904
6460
|
} : { rows: {}, pendingNormalization: null, wordIndex: null, stemIndex: null }, "contentsOf");
|
|
5905
6461
|
var storeInfo = /* @__PURE__ */ __name(async (env) => {
|
|
5906
6462
|
const path = storePath(env);
|
|
5907
|
-
if (!
|
|
6463
|
+
if (!existsSync4(path))
|
|
5908
6464
|
return snakeKeys({ path, exists: false, schema: compatibilityOf(void 0) });
|
|
5909
6465
|
let schema = compatibilityOf(void 0);
|
|
5910
6466
|
try {
|
|
@@ -5936,9 +6492,12 @@ var storeInfoCommand = /* @__PURE__ */ __name(() => annotate(new Command("info")
|
|
|
5936
6492
|
const answer = await storeInfo(environmentOf(this).env ?? process.env);
|
|
5937
6493
|
renderAnswer(this, outputFor(this), itemOf(answer));
|
|
5938
6494
|
}), "storeInfoCommand");
|
|
5939
|
-
var sharedStoreCommand = /* @__PURE__ */ __name(() =>
|
|
6495
|
+
var sharedStoreCommand = /* @__PURE__ */ __name((app) => {
|
|
6496
|
+
const store = annotate(new Command("store"), { effects: LOCAL_READ }).description("the shared local store every WireCat tool reads").addCommand(storeInfoCommand());
|
|
6497
|
+
return app ? store.addCommand(storeRecoverCommand(app)) : store;
|
|
6498
|
+
}, "sharedStoreCommand");
|
|
5940
6499
|
|
|
5941
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6500
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3e7ac84c094d466aed903c683c124ab5/node_modules/@wirecat/cli-core/dist/cli/messenger/password.js
|
|
5942
6501
|
var ENCRYPT_OPTION = [
|
|
5943
6502
|
"--encrypt",
|
|
5944
6503
|
"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 +6516,9 @@ var passwordOf = /* @__PURE__ */ __name(async (command, { twice }) => {
|
|
|
5957
6516
|
return password;
|
|
5958
6517
|
}, "passwordOf");
|
|
5959
6518
|
|
|
5960
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5961
|
-
import { existsSync as
|
|
5962
|
-
import { join } from "node:path";
|
|
6519
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3e7ac84c094d466aed903c683c124ab5/node_modules/@wirecat/cli-core/dist/replies/rules.js
|
|
6520
|
+
import { existsSync as existsSync5, readFileSync as readFileSync2 } from "node:fs";
|
|
6521
|
+
import { join as join2 } from "node:path";
|
|
5963
6522
|
var REPLY_ACTIONS = ["reply", "task"];
|
|
5964
6523
|
var REPLY_MODELS = ["fill-only", "may-reword"];
|
|
5965
6524
|
var REPLY_KINDS = ["dialog", "group"];
|
|
@@ -6045,7 +6604,7 @@ var defaultRule = /* @__PURE__ */ __name((id) => ({
|
|
|
6045
6604
|
reply: { template: "", asReply: true },
|
|
6046
6605
|
limits: { perChat: "1/1d", perPerson: "1/1d" }
|
|
6047
6606
|
}), "defaultRule");
|
|
6048
|
-
var repliesPathFor = /* @__PURE__ */ __name((app, profile, env = process.env) =>
|
|
6607
|
+
var repliesPathFor = /* @__PURE__ */ __name((app, profile, env = process.env) => join2(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).config, `${profile}.replies.json`), "repliesPathFor");
|
|
6049
6608
|
var EVERYONE = { reply: "all", allow: { people: [], chats: [] }, deny: { people: [], chats: [] } };
|
|
6050
6609
|
var outsideAudience = /* @__PURE__ */ __name((audience, person, chat) => {
|
|
6051
6610
|
if (person !== null && audience.deny.people.includes(person))
|
|
@@ -6075,11 +6634,11 @@ var readReplies = /* @__PURE__ */ __name((path, provider) => {
|
|
|
6075
6634
|
return parseReplies(readRepliesFile(path, provider), path, provider);
|
|
6076
6635
|
}, "readReplies");
|
|
6077
6636
|
var readRepliesFile = /* @__PURE__ */ __name((path, provider) => {
|
|
6078
|
-
if (!
|
|
6637
|
+
if (!existsSync5(path))
|
|
6079
6638
|
return { audience: structuredClone(EVERYONE), rules: [] };
|
|
6080
6639
|
let parsed;
|
|
6081
6640
|
try {
|
|
6082
|
-
parsed = JSON.parse(
|
|
6641
|
+
parsed = JSON.parse(readFileSync2(path, "utf8"));
|
|
6083
6642
|
} catch (error) {
|
|
6084
6643
|
throw broken(path, error instanceof Error ? error.message : String(error));
|
|
6085
6644
|
}
|
|
@@ -6128,9 +6687,9 @@ var problem = /* @__PURE__ */ __name((issue) => {
|
|
|
6128
6687
|
}, "problem");
|
|
6129
6688
|
var broken = /* @__PURE__ */ __name((path, why) => new CliError("configuration_error", `the reply rules ${path} cannot be read (${why}) \u2014 fix the file`), "broken");
|
|
6130
6689
|
|
|
6131
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6132
|
-
import { existsSync as
|
|
6133
|
-
import { join as
|
|
6690
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3e7ac84c094d466aed903c683c124ab5/node_modules/@wirecat/cli-core/dist/replies/state.js
|
|
6691
|
+
import { existsSync as existsSync6, readFileSync as readFileSync3 } from "node:fs";
|
|
6692
|
+
import { join as join3 } from "node:path";
|
|
6134
6693
|
var ANSWERED_KEPT = 1e3;
|
|
6135
6694
|
var times = record(string(), array(string()));
|
|
6136
6695
|
var stateFile = object({
|
|
@@ -6142,13 +6701,13 @@ var stateFile = object({
|
|
|
6142
6701
|
});
|
|
6143
6702
|
var emptyState = /* @__PURE__ */ __name(() => ({ paused: false, answered: [], sent: {} }), "emptyState");
|
|
6144
6703
|
var answeredKey = /* @__PURE__ */ __name((message) => `${message.chatId}:${message.id}`, "answeredKey");
|
|
6145
|
-
var repliesStatePathFor = /* @__PURE__ */ __name((app, profile, env = process.env) =>
|
|
6704
|
+
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
6705
|
var readRepliesState = /* @__PURE__ */ __name((path) => {
|
|
6147
|
-
if (!
|
|
6706
|
+
if (!existsSync6(path))
|
|
6148
6707
|
return emptyState();
|
|
6149
6708
|
let parsed;
|
|
6150
6709
|
try {
|
|
6151
|
-
parsed = JSON.parse(
|
|
6710
|
+
parsed = JSON.parse(readFileSync3(path, "utf8"));
|
|
6152
6711
|
} catch (error) {
|
|
6153
6712
|
throw broken2(path, error instanceof Error ? error.message : String(error));
|
|
6154
6713
|
}
|
|
@@ -6181,7 +6740,7 @@ var recordReply = /* @__PURE__ */ __name((state, rule2, message, now) => {
|
|
|
6181
6740
|
}, "recordReply");
|
|
6182
6741
|
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
6742
|
|
|
6184
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6743
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3e7ac84c094d466aed903c683c124ab5/node_modules/@wirecat/cli-core/dist/replies/decide.js
|
|
6185
6744
|
var skip = /* @__PURE__ */ __name((why) => ({ skip: why }), "skip");
|
|
6186
6745
|
var decide = /* @__PURE__ */ __name((rule2, incoming, state, now) => {
|
|
6187
6746
|
const { message, chat, owner, sender } = incoming;
|
|
@@ -6287,7 +6846,7 @@ var filled = /* @__PURE__ */ __name((template2, senderName) => {
|
|
|
6287
6846
|
return template2.replaceAll("{firstName}", name.split(/\s+/)[0] ?? name).replaceAll("{name}", name);
|
|
6288
6847
|
}, "filled");
|
|
6289
6848
|
|
|
6290
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6849
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3e7ac84c094d466aed903c683c124ab5/node_modules/@wirecat/cli-core/dist/replies/template.js
|
|
6291
6850
|
var import_liquidjs = __toESM(require_liquid_node(), 1);
|
|
6292
6851
|
var TEMPLATE_LIMITS = {
|
|
6293
6852
|
parse: 32768,
|
|
@@ -6447,7 +7006,7 @@ var renderReplyTemplate = /* @__PURE__ */ __name(async (reply, input) => {
|
|
|
6447
7006
|
}
|
|
6448
7007
|
}, "renderReplyTemplate");
|
|
6449
7008
|
|
|
6450
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7009
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3e7ac84c094d466aed903c683c124ab5/node_modules/@wirecat/cli-core/dist/replies/dry-run.js
|
|
6451
7010
|
var DRY_RUN_DAYS = 7;
|
|
6452
7011
|
var PAGE = 500;
|
|
6453
7012
|
var dryRun = /* @__PURE__ */ __name(async (store, account, rules, { since, until = Date.now(), only, audience, render }) => {
|
|
@@ -6561,7 +7120,7 @@ var storedSince = /* @__PURE__ */ __name(async (store, account, chat, since) =>
|
|
|
6561
7120
|
}
|
|
6562
7121
|
}, "storedSince");
|
|
6563
7122
|
|
|
6564
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7123
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3e7ac84c094d466aed903c683c124ab5/node_modules/@wirecat/cli-core/dist/embeddings/keys.js
|
|
6565
7124
|
var endpointKeyName = /* @__PURE__ */ __name((baseUrl) => {
|
|
6566
7125
|
const host = new URL(baseUrl).host;
|
|
6567
7126
|
return ["openai", "anthropic"].includes(host) ? `endpoint:${host}` : host;
|
|
@@ -6592,7 +7151,7 @@ var embeddingKeys = /* @__PURE__ */ __name((app, env = process.env, keyring) =>
|
|
|
6592
7151
|
};
|
|
6593
7152
|
}, "embeddingKeys");
|
|
6594
7153
|
|
|
6595
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7154
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3e7ac84c094d466aed903c683c124ab5/node_modules/@wirecat/cli-core/dist/models/openai.js
|
|
6596
7155
|
var options = strictObject({
|
|
6597
7156
|
temperature: range(0, 2),
|
|
6598
7157
|
top_p: range(0, 1),
|
|
@@ -6606,7 +7165,7 @@ var openai = {
|
|
|
6606
7165
|
images: true,
|
|
6607
7166
|
baseUrl: "https://api.openai.com/v1",
|
|
6608
7167
|
validate: /* @__PURE__ */ __name((given) => checkedOptions("openai", options, given), "validate"),
|
|
6609
|
-
complete: /* @__PURE__ */ __name(
|
|
7168
|
+
complete: /* @__PURE__ */ __name((target, request, checked, apiKey, fetcher) => withTimeLimit(12e4, async (deadline) => {
|
|
6610
7169
|
const response = await fetcher(`${target.baseUrl.replace(/\/+$/, "")}/chat/completions`, {
|
|
6611
7170
|
method: "POST",
|
|
6612
7171
|
headers: { "Content-Type": "application/json", ...apiKey ? { Authorization: `Bearer ${apiKey}` } : {} },
|
|
@@ -6628,7 +7187,7 @@ var openai = {
|
|
|
6628
7187
|
],
|
|
6629
7188
|
...new URL(target.baseUrl).hostname === "api.openai.com" ? { max_completion_tokens: request.maxTokens } : { max_tokens: request.maxTokens }
|
|
6630
7189
|
}),
|
|
6631
|
-
signal:
|
|
7190
|
+
signal: deadline,
|
|
6632
7191
|
redirect: "error"
|
|
6633
7192
|
});
|
|
6634
7193
|
if (!response.ok)
|
|
@@ -6638,10 +7197,10 @@ var openai = {
|
|
|
6638
7197
|
if (choice?.finish_reason !== "stop" || typeof choice.message?.content !== "string" || !Number.isInteger(body.usage?.total_tokens) || (body.usage?.total_tokens ?? 0) < 1)
|
|
6639
7198
|
throw new Error("incomplete response");
|
|
6640
7199
|
return { text: choice.message.content, tokens: body.usage?.total_tokens };
|
|
6641
|
-
}, "complete")
|
|
7200
|
+
}), "complete")
|
|
6642
7201
|
};
|
|
6643
7202
|
|
|
6644
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7203
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3e7ac84c094d466aed903c683c124ab5/node_modules/@wirecat/cli-core/dist/models/index.js
|
|
6645
7204
|
var modelGateway = /* @__PURE__ */ __name((deps) => ({
|
|
6646
7205
|
complete: /* @__PURE__ */ __name(async (request) => {
|
|
6647
7206
|
if (deps.signal?.aborted)
|
|
@@ -6656,7 +7215,7 @@ var modelGateway = /* @__PURE__ */ __name((deps) => ({
|
|
|
6656
7215
|
if (!adapter && target.provider === "openai")
|
|
6657
7216
|
adapter = openai;
|
|
6658
7217
|
if (!adapter && target.provider === "anthropic")
|
|
6659
|
-
adapter = (await import("./anthropic-
|
|
7218
|
+
adapter = (await import("./anthropic-7FUQ2HYJ.js")).anthropic;
|
|
6660
7219
|
if (!adapter)
|
|
6661
7220
|
throw new CliError("validation_error", `no model adapter for ${target.provider}`);
|
|
6662
7221
|
if (request.images !== void 0 && adapter.images !== true)
|
|
@@ -6697,19 +7256,19 @@ var modelGateway = /* @__PURE__ */ __name((deps) => ({
|
|
|
6697
7256
|
}, "complete")
|
|
6698
7257
|
}), "modelGateway");
|
|
6699
7258
|
|
|
6700
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6701
|
-
import { existsSync as
|
|
6702
|
-
import { join as
|
|
7259
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3e7ac84c094d466aed903c683c124ab5/node_modules/@wirecat/cli-core/dist/replies/consents.js
|
|
7260
|
+
import { existsSync as existsSync7, readFileSync as readFileSync4 } from "node:fs";
|
|
7261
|
+
import { join as join4 } from "node:path";
|
|
6703
7262
|
var shape = strictObject({
|
|
6704
7263
|
provider: nullable(pipe(string(), minLength(1))),
|
|
6705
7264
|
deniedChats: array(pipe(string(), minLength(1)))
|
|
6706
7265
|
});
|
|
6707
|
-
var replyConsentPathFor = /* @__PURE__ */ __name((app, profile, env = process.env) =>
|
|
7266
|
+
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
7267
|
var readReplyConsent = /* @__PURE__ */ __name((path) => {
|
|
6709
|
-
if (!
|
|
7268
|
+
if (!existsSync7(path))
|
|
6710
7269
|
return { provider: null, deniedChats: [] };
|
|
6711
7270
|
try {
|
|
6712
|
-
return parse(shape, JSON.parse(
|
|
7271
|
+
return parse(shape, JSON.parse(readFileSync4(path, "utf8")));
|
|
6713
7272
|
} catch {
|
|
6714
7273
|
throw new CliError("configuration_error", "reply model consent is invalid; fix its file before granting consent");
|
|
6715
7274
|
}
|
|
@@ -6722,7 +7281,7 @@ var mayModelReply = /* @__PURE__ */ __name((path, provider, chat) => {
|
|
|
6722
7281
|
return consent.provider === provider && !consent.deniedChats.includes(chat);
|
|
6723
7282
|
}, "mayModelReply");
|
|
6724
7283
|
|
|
6725
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7284
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3e7ac84c094d466aed903c683c124ab5/node_modules/@wirecat/cli-core/dist/replies/rendering.js
|
|
6726
7285
|
var replyRenderer = /* @__PURE__ */ __name((app, profile, settings, env, warn, options2 = {
|
|
6727
7286
|
ai: true
|
|
6728
7287
|
}) => async (rule2, message, chat, now) => {
|
|
@@ -6769,7 +7328,7 @@ var replyRenderer = /* @__PURE__ */ __name((app, profile, settings, env, warn, o
|
|
|
6769
7328
|
return result2;
|
|
6770
7329
|
}, "replyRenderer");
|
|
6771
7330
|
|
|
6772
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7331
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3e7ac84c094d466aed903c683c124ab5/node_modules/@wirecat/cli-core/dist/replies/serve.js
|
|
6773
7332
|
var NOT_ALLOWED = "replies.send is not allow";
|
|
6774
7333
|
var NO_RULES = "no rules";
|
|
6775
7334
|
var ONLY_TASK = "opened a task, sent nothing";
|
|
@@ -6862,7 +7421,7 @@ var replyTo = /* @__PURE__ */ __name(async (deps, message) => {
|
|
|
6862
7421
|
return { skip: why };
|
|
6863
7422
|
}, "replyTo");
|
|
6864
7423
|
|
|
6865
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7424
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3e7ac84c094d466aed903c683c124ab5/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-catch-up.js
|
|
6866
7425
|
var START_SYNC_DELAY_MS = 3e4;
|
|
6867
7426
|
var START_SYNC_BUDGET_MS = 5 * 6e4;
|
|
6868
7427
|
var START_SYNC_WINDOW_MS = 7 * 864e5;
|
|
@@ -6873,8 +7432,8 @@ var startSync = /* @__PURE__ */ __name(({ chats, newestHeld, fetch: fetch2, note
|
|
|
6873
7432
|
let pass = Promise.resolve();
|
|
6874
7433
|
let started = false;
|
|
6875
7434
|
let done;
|
|
6876
|
-
const run = /* @__PURE__ */ __name(
|
|
6877
|
-
|
|
7435
|
+
const run = /* @__PURE__ */ __name(() => withTimeLimit(budgetMs, (deadline) => catchUp(AbortSignal.any([controller.signal, deadline]))), "run");
|
|
7436
|
+
const catchUp = /* @__PURE__ */ __name(async (stop) => {
|
|
6878
7437
|
const floor = now() - windowMs;
|
|
6879
7438
|
const moved = [];
|
|
6880
7439
|
for (const chat of await chats(stop)) {
|
|
@@ -6915,7 +7474,7 @@ var startSync = /* @__PURE__ */ __name(({ chats, newestHeld, fetch: fetch2, note
|
|
|
6915
7474
|
code: "start_sync",
|
|
6916
7475
|
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
7476
|
});
|
|
6918
|
-
}, "
|
|
7477
|
+
}, "catchUp");
|
|
6919
7478
|
return {
|
|
6920
7479
|
start: /* @__PURE__ */ __name(() => {
|
|
6921
7480
|
if (started || controller.signal.aborted)
|
|
@@ -6939,7 +7498,7 @@ var startSync = /* @__PURE__ */ __name(({ chats, newestHeld, fetch: fetch2, note
|
|
|
6939
7498
|
};
|
|
6940
7499
|
}, "startSync");
|
|
6941
7500
|
|
|
6942
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7501
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3e7ac84c094d466aed903c683c124ab5/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-members.js
|
|
6943
7502
|
var FIRST_FETCH_MS = 6e4;
|
|
6944
7503
|
var DAY_MS = 864e5;
|
|
6945
7504
|
var memberFetches = /* @__PURE__ */ __name(({ withStore, fetch: fetch2, warn, firstMs = FIRST_FETCH_MS, everyMs = DAY_MS }) => {
|
|
@@ -6993,7 +7552,7 @@ var memberFetches = /* @__PURE__ */ __name(({ withStore, fetch: fetch2, warn, fi
|
|
|
6993
7552
|
};
|
|
6994
7553
|
}, "memberFetches");
|
|
6995
7554
|
|
|
6996
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7555
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3e7ac84c094d466aed903c683c124ab5/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-notice.js
|
|
6997
7556
|
var record2 = /* @__PURE__ */ __name((context, app, severity, attributes) => recordLogFor(context.streams.diagnostic, app, { command: currentRun().command || "serve" })[severity](attributes), "record");
|
|
6998
7557
|
var noticeFor = /* @__PURE__ */ __name((context, app, severity = "warn") => ({ text, ...attributes }) => {
|
|
6999
7558
|
if (context.format === "pretty") {
|
|
@@ -7026,7 +7585,7 @@ var recordDiagnostics = /* @__PURE__ */ __name((context, app) => {
|
|
|
7026
7585
|
return context;
|
|
7027
7586
|
}, "recordDiagnostics");
|
|
7028
7587
|
|
|
7029
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7588
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3e7ac84c094d466aed903c683c124ab5/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-stems.js
|
|
7030
7589
|
var STEMS_EVERY_MS = 3e4;
|
|
7031
7590
|
var STEMS_SLICE_MS = 2e3;
|
|
7032
7591
|
var stemFills = /* @__PURE__ */ __name(({ withStore, warn, everyMs = STEMS_EVERY_MS, sliceMs = STEMS_SLICE_MS }) => {
|
|
@@ -7066,7 +7625,7 @@ var stemFills = /* @__PURE__ */ __name(({ withStore, warn, everyMs = STEMS_EVERY
|
|
|
7066
7625
|
};
|
|
7067
7626
|
}, "stemFills");
|
|
7068
7627
|
|
|
7069
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7628
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3e7ac84c094d466aed903c683c124ab5/node_modules/@wirecat/cli-core/dist/cli/messenger/message-items.js
|
|
7070
7629
|
var defined = /* @__PURE__ */ __name((value) => Object.fromEntries(Object.entries(value).filter(([, one]) => one !== void 0)), "defined");
|
|
7071
7630
|
var attachmentItem = /* @__PURE__ */ __name((attachment) => defined({
|
|
7072
7631
|
kind: attachment.kind,
|
|
@@ -7161,7 +7720,7 @@ var viewOf = /* @__PURE__ */ __name((context, messenger) => ({
|
|
|
7161
7720
|
locale: messenger.app.locale
|
|
7162
7721
|
}), "viewOf");
|
|
7163
7722
|
|
|
7164
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7723
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3e7ac84c094d466aed903c683c124ab5/node_modules/@wirecat/cli-core/dist/cli/messenger/watch-answers.js
|
|
7165
7724
|
var observed = /* @__PURE__ */ __name((value) => ({
|
|
7166
7725
|
value: value.value,
|
|
7167
7726
|
observed_at: value.observedAt,
|
|
@@ -7228,7 +7787,7 @@ var watchEventItem = /* @__PURE__ */ __name((value, account) => {
|
|
|
7228
7787
|
}
|
|
7229
7788
|
}, "watchEventItem");
|
|
7230
7789
|
|
|
7231
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7790
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3e7ac84c094d466aed903c683c124ab5/node_modules/@wirecat/cli-core/dist/cli/messenger/watch-command.js
|
|
7232
7791
|
var watchCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("watch"), {
|
|
7233
7792
|
output: { entity: "watch_item" },
|
|
7234
7793
|
effects: REMOTE_READ,
|
|
@@ -7383,7 +7942,7 @@ var describe = /* @__PURE__ */ __name((event, render) => {
|
|
|
7383
7942
|
}
|
|
7384
7943
|
}, "describe");
|
|
7385
7944
|
|
|
7386
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7945
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3e7ac84c094d466aed903c683c124ab5/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-command.js
|
|
7387
7946
|
var serveCommand = /* @__PURE__ */ __name((messenger) => {
|
|
7388
7947
|
const command = annotate(new Command("serve"), {
|
|
7389
7948
|
output: { entity: "serve_summary" },
|
|
@@ -7647,8 +8206,8 @@ var tasking = /* @__PURE__ */ __name((context, warn) => {
|
|
|
7647
8206
|
};
|
|
7648
8207
|
}, "tasking");
|
|
7649
8208
|
|
|
7650
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7651
|
-
import { existsSync as
|
|
8209
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3e7ac84c094d466aed903c683c124ab5/node_modules/@wirecat/cli-core/dist/cli/messenger/store-tables-command.js
|
|
8210
|
+
import { existsSync as existsSync8 } from "node:fs";
|
|
7652
8211
|
var PATH = "store tables list";
|
|
7653
8212
|
var STORE_TABLES_QUERY = {
|
|
7654
8213
|
entity: "store_table",
|
|
@@ -7677,7 +8236,7 @@ var storeTablesCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
7677
8236
|
const filter = filterOf(words);
|
|
7678
8237
|
const { full } = this.optsWithGlobals();
|
|
7679
8238
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
7680
|
-
if (!
|
|
8239
|
+
if (!existsSync8(path))
|
|
7681
8240
|
throw new CliError("not_found", `no store at ${path}`);
|
|
7682
8241
|
const items = await readStoreTables(path, { filter, sizes: full === true });
|
|
7683
8242
|
renderAnswer(this, outputFor(this), listOf(PATH, {
|
|
@@ -7690,7 +8249,7 @@ var storeTablesCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
7690
8249
|
return tables;
|
|
7691
8250
|
}, "storeTablesCommand");
|
|
7692
8251
|
|
|
7693
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
8252
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.8_commander@15.0.0_esbuild@0.28.2_type_3e7ac84c094d466aed903c683c124ab5/node_modules/@wirecat/cli-core/dist/cli/messenger/store-maintenance-command.js
|
|
7694
8253
|
var SEARCH_INDEXES = ["messages_fts", "chats_fts", "identities_fts"];
|
|
7695
8254
|
var WORD_INDEX = "message_words";
|
|
7696
8255
|
var schemaOf = /* @__PURE__ */ __name((database) => {
|
|
@@ -7699,7 +8258,7 @@ var schemaOf = /* @__PURE__ */ __name((database) => {
|
|
|
7699
8258
|
}, "schemaOf");
|
|
7700
8259
|
var count2 = /* @__PURE__ */ __name((database, table) => Number(database.prepare(`SELECT count(*) AS n FROM ${table}`).get()?.n ?? 0), "count");
|
|
7701
8260
|
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) =>
|
|
8261
|
+
var bytesOf2 = /* @__PURE__ */ __name((path) => existsSync9(path) ? statSync4(path).size : 0, "bytesOf");
|
|
7703
8262
|
var reading = /* @__PURE__ */ __name(async (path, read) => {
|
|
7704
8263
|
const database = await openCache(path);
|
|
7705
8264
|
try {
|
|
@@ -7716,24 +8275,59 @@ var readingOnly = /* @__PURE__ */ __name(async (path, read) => {
|
|
|
7716
8275
|
database.close();
|
|
7717
8276
|
}
|
|
7718
8277
|
}, "readingOnly");
|
|
7719
|
-
var
|
|
8278
|
+
var withoutInode = /* @__PURE__ */ __name(({ inode: _, ...mark }) => mark, "withoutInode");
|
|
8279
|
+
var fileSchema = /* @__PURE__ */ __name(async (path) => {
|
|
8280
|
+
try {
|
|
8281
|
+
return await readingOnly(path, (database) => fileSchemaOf(database).version);
|
|
8282
|
+
} catch {
|
|
8283
|
+
return null;
|
|
8284
|
+
}
|
|
8285
|
+
}, "fileSchema");
|
|
8286
|
+
var storeSummary = /* @__PURE__ */ __name(async (env, { deep = false, command, version } = {}) => {
|
|
7720
8287
|
const path = storePath(env);
|
|
7721
|
-
if (!
|
|
8288
|
+
if (!existsSync9(path))
|
|
7722
8289
|
return { path, exists: false };
|
|
8290
|
+
const checked = await storeHealth(path, { deep });
|
|
8291
|
+
const recorded = deep ? recordDeepCheck(path, checked, {
|
|
8292
|
+
cli: command ?? "unknown",
|
|
8293
|
+
...version ? { version } : {},
|
|
8294
|
+
schema: await fileSchema(path)
|
|
8295
|
+
}) : null;
|
|
8296
|
+
const mark = readDamageMark(path);
|
|
8297
|
+
const lastKnownGood = readHealthMark(path)?.last_ok_at ?? null;
|
|
8298
|
+
const health = {
|
|
8299
|
+
checked: checked.checked,
|
|
8300
|
+
covers: deep ? "every page and every search index" : QUICK_HEALTH_CHECKS,
|
|
8301
|
+
ok: checked.ok,
|
|
8302
|
+
ms: checked.ms,
|
|
8303
|
+
...checked.problems ? { problems: checked.problems } : {},
|
|
8304
|
+
...checked.damagedTables?.length ? { damagedTables: checked.damagedTables } : {},
|
|
8305
|
+
...checked.invalidJson?.length ? { invalidJson: checked.invalidJson } : {},
|
|
8306
|
+
...checked.searchIndexes?.some((index) => !index.ok) ? { damagedSearchIndexes: checked.searchIndexes.filter((index) => !index.ok).map((index) => index.name) } : {}
|
|
8307
|
+
};
|
|
8308
|
+
const damage = command ? explainDamage(checked, command, mark) : null;
|
|
8309
|
+
const healthOf = {
|
|
8310
|
+
health,
|
|
8311
|
+
lastKnownGood,
|
|
8312
|
+
...mark ? { damageMark: withoutInode(mark) } : {},
|
|
8313
|
+
...recorded?.cleared ? { damageMarkCleared: withoutInode(recorded.cleared) } : {},
|
|
8314
|
+
...damage ? { damage } : {}
|
|
8315
|
+
};
|
|
7723
8316
|
try {
|
|
7724
8317
|
return await reading(path, (database) => {
|
|
7725
|
-
const { version, writable } = schemaOf(database);
|
|
8318
|
+
const { version: version2, writable } = schemaOf(database);
|
|
7726
8319
|
return {
|
|
7727
8320
|
path,
|
|
7728
8321
|
exists: true,
|
|
7729
|
-
schema:
|
|
8322
|
+
schema: version2,
|
|
7730
8323
|
speaks: SPEAKS,
|
|
7731
8324
|
writable,
|
|
7732
|
-
...
|
|
8325
|
+
...version2 > 0 ? { chats: count2(database, "chats"), messages: count2(database, "messages") } : {},
|
|
8326
|
+
...healthOf
|
|
7733
8327
|
};
|
|
7734
8328
|
});
|
|
7735
8329
|
} catch (error) {
|
|
7736
|
-
return { path, exists: true, error: messageOf2(error) };
|
|
8330
|
+
return { path, exists: true, error: messageOf2(error), ...healthOf };
|
|
7737
8331
|
}
|
|
7738
8332
|
}, "storeSummary");
|
|
7739
8333
|
var result = /* @__PURE__ */ __name((command, value, next = []) => renderAnswer(command, outputFor(command), itemOf(snakeKeys(value), { next })), "result");
|
|
@@ -7748,7 +8342,8 @@ var storeMaintenanceCommands = /* @__PURE__ */ __name((messenger) => [
|
|
|
7748
8342
|
repairCommand(messenger),
|
|
7749
8343
|
resetCommand(messenger),
|
|
7750
8344
|
copiesCommand(),
|
|
7751
|
-
storeTablesCommand(messenger)
|
|
8345
|
+
storeTablesCommand(messenger),
|
|
8346
|
+
storeRecoverCommand({ command: messenger.app.command, version: messenger.app.version })
|
|
7752
8347
|
], "storeMaintenanceCommands");
|
|
7753
8348
|
var refuseWhileServing = /* @__PURE__ */ __name((command, messenger) => {
|
|
7754
8349
|
const serving = servingProfiles(messenger.app, environmentOf(command).env ?? process.env);
|
|
@@ -7760,7 +8355,7 @@ var repairCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("
|
|
|
7760
8355
|
const { renderer, format } = outputFor(this);
|
|
7761
8356
|
const { dryRun: dryRun2 } = this.opts();
|
|
7762
8357
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
7763
|
-
if (!
|
|
8358
|
+
if (!existsSync9(path)) {
|
|
7764
8359
|
result(this, { path, exists: false });
|
|
7765
8360
|
return;
|
|
7766
8361
|
}
|
|
@@ -7800,7 +8395,7 @@ var notesOf = /* @__PURE__ */ __name((report, command) => {
|
|
|
7800
8395
|
}, "notesOf");
|
|
7801
8396
|
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
8397
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
7803
|
-
if (!
|
|
8398
|
+
if (!existsSync9(path))
|
|
7804
8399
|
throw new CliError("not_found", `no store at ${path}`);
|
|
7805
8400
|
const deleted = await reading(path, (database) => deleteCopy(database, name));
|
|
7806
8401
|
result(this, { path, deleted });
|
|
@@ -7808,7 +8403,7 @@ var copiesCommand = /* @__PURE__ */ __name(() => new Command("copies").descripti
|
|
|
7808
8403
|
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
8404
|
const { renderer } = outputFor(this);
|
|
7810
8405
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
7811
|
-
if (!
|
|
8406
|
+
if (!existsSync9(path)) {
|
|
7812
8407
|
result(this, { path, exists: false, ok: true });
|
|
7813
8408
|
return;
|
|
7814
8409
|
}
|
|
@@ -7871,7 +8466,7 @@ var inspect = /* @__PURE__ */ __name((path) => reading(path, (database) => {
|
|
|
7871
8466
|
...schema.version > 0 ? [["attachment_words", indexIntegrity(database, "attachment_words", 0)]] : []
|
|
7872
8467
|
]);
|
|
7873
8468
|
const size = bytesOf2(path) + bytesOf2(`${path}-wal`);
|
|
7874
|
-
const { bavail, bsize } =
|
|
8469
|
+
const { bavail, bsize } = statfsSync2(dirname2(path));
|
|
7875
8470
|
const free = Number(bavail) * Number(bsize);
|
|
7876
8471
|
const behind = schema.version > 0 ? chatsBehind(database) : [];
|
|
7877
8472
|
const vectorIndexes = schema.version >= 34 ? vectorIndexCounts(database) : [];
|
|
@@ -7959,14 +8554,18 @@ var chatsBehind = /* @__PURE__ */ __name((database) => database.prepare(`SELECT
|
|
|
7959
8554
|
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
8555
|
const { renderer } = outputFor(this);
|
|
7961
8556
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
7962
|
-
if (!
|
|
8557
|
+
if (!existsSync9(path)) {
|
|
7963
8558
|
result(this, { path, exists: false });
|
|
7964
8559
|
renderer.note(`no store yet \u2014 the first \`${messenger.app.command}\` command that reads a chat creates it`);
|
|
7965
8560
|
return;
|
|
7966
8561
|
}
|
|
7967
8562
|
const answer = await reading(path, (database) => {
|
|
7968
8563
|
const from = schemaOf(database).version;
|
|
7969
|
-
migrate(database, {
|
|
8564
|
+
migrate(database, {
|
|
8565
|
+
command: messenger.app.command,
|
|
8566
|
+
version: messenger.app.version,
|
|
8567
|
+
rollback: { store: path, warn: /* @__PURE__ */ __name((line) => renderer.warn(line), "warn") }
|
|
8568
|
+
});
|
|
7970
8569
|
const { normalized, indexed, terms } = buildWordIndex(database, (note) => renderer.note(note));
|
|
7971
8570
|
const stemmed = buildStems(database, (note) => renderer.note(note));
|
|
7972
8571
|
const notes = buildNoteIndex(database, (note) => renderer.note(note));
|
|
@@ -8019,7 +8618,7 @@ var buildNoteIndex = /* @__PURE__ */ __name((database, note, { reset = false } =
|
|
|
8019
8618
|
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
8619
|
const { renderer } = outputFor(this);
|
|
8021
8620
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8022
|
-
if (!
|
|
8621
|
+
if (!existsSync9(path)) {
|
|
8023
8622
|
result(this, { path, exists: false });
|
|
8024
8623
|
return;
|
|
8025
8624
|
}
|
|
@@ -8048,11 +8647,11 @@ var reindexCommand = /* @__PURE__ */ __name((messenger) => destroysNothing(annot
|
|
|
8048
8647
|
result(this, answer);
|
|
8049
8648
|
}), "reindexCommand");
|
|
8050
8649
|
var vacuumInto = /* @__PURE__ */ __name(async (path, target) => {
|
|
8051
|
-
|
|
8650
|
+
writeFileSync2(target, "", { flag: "wx", mode: 384 });
|
|
8052
8651
|
try {
|
|
8053
8652
|
await reading(path, (database) => database.prepare("VACUUM INTO ?").run(target));
|
|
8054
8653
|
} catch (error) {
|
|
8055
|
-
|
|
8654
|
+
rmSync3(target, { force: true });
|
|
8056
8655
|
throw error;
|
|
8057
8656
|
}
|
|
8058
8657
|
}, "vacuumInto");
|
|
@@ -8061,9 +8660,9 @@ var backupCommand = /* @__PURE__ */ __name(() => destroysNothing(annotate(new Co
|
|
|
8061
8660
|
const { encrypt } = this.opts();
|
|
8062
8661
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8063
8662
|
const target = resolve(file2);
|
|
8064
|
-
if (!
|
|
8663
|
+
if (!existsSync9(path))
|
|
8065
8664
|
throw new CliError("not_found", `no store at ${path} to back up`);
|
|
8066
|
-
if (
|
|
8665
|
+
if (existsSync9(target))
|
|
8067
8666
|
throw new CliError("validation_error", `${target} exists \u2014 a backup never overwrites a file`);
|
|
8068
8667
|
const password = encrypt ? await passwordOf(this, { twice: true }) : void 0;
|
|
8069
8668
|
const copyAt = password === void 0 ? target : `${path}.backup-${process.pid}`;
|
|
@@ -8085,67 +8684,69 @@ var backupCommand = /* @__PURE__ */ __name(() => destroysNothing(annotate(new Co
|
|
|
8085
8684
|
});
|
|
8086
8685
|
} catch (error) {
|
|
8087
8686
|
if (password === void 0)
|
|
8088
|
-
|
|
8687
|
+
rmSync3(target, { force: true });
|
|
8089
8688
|
throw error;
|
|
8090
8689
|
} finally {
|
|
8091
8690
|
if (password !== void 0)
|
|
8092
|
-
|
|
8691
|
+
rmSync3(copyAt, { force: true });
|
|
8093
8692
|
}
|
|
8094
8693
|
}), "backupCommand");
|
|
8095
8694
|
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
8695
|
const { output } = this.opts();
|
|
8097
8696
|
const from = resolve(file2);
|
|
8098
8697
|
const to = resolve(output);
|
|
8099
|
-
if (!
|
|
8698
|
+
if (!existsSync9(from))
|
|
8100
8699
|
throw new CliError("not_found", `no file at ${from}`);
|
|
8101
8700
|
if (!isSealed(from))
|
|
8102
8701
|
throw new CliError("validation_error", `${from} was not written with --encrypt`);
|
|
8103
|
-
if (
|
|
8702
|
+
if (existsSync9(to))
|
|
8104
8703
|
throw new CliError("validation_error", `${to} exists \u2014 never overwritten`);
|
|
8105
8704
|
await unsealFile(from, to, await passwordOf(this, { twice: false }));
|
|
8106
8705
|
result(this, { path: to, from, bytes: bytesOf2(to) });
|
|
8107
8706
|
}), "decryptCommand");
|
|
8108
|
-
var restoreCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("restore"), { output: { entity: "store_restore" }, effects: LOCAL_WRITE }).summary("restore a backup
|
|
8707
|
+
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
8708
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8110
8709
|
const given = resolve(file2);
|
|
8111
|
-
if (!
|
|
8710
|
+
if (!existsSync9(given))
|
|
8112
8711
|
throw new CliError("not_found", `no file at ${given}`);
|
|
8113
8712
|
refuseWhileServing(this, messenger);
|
|
8114
8713
|
if (!isSealed(given))
|
|
8115
8714
|
return restoreFrom(this, messenger, given, given);
|
|
8116
8715
|
const opened = `${path}.unsealing-${process.pid}`;
|
|
8117
|
-
mkdirSync(
|
|
8716
|
+
mkdirSync(dirname2(path), { recursive: true, mode: 448 });
|
|
8118
8717
|
try {
|
|
8119
8718
|
await unsealFile(given, opened, await passwordOf(this, { twice: false }));
|
|
8120
8719
|
await restoreFrom(this, messenger, opened, given);
|
|
8121
8720
|
} finally {
|
|
8122
|
-
|
|
8721
|
+
rmSync3(opened, { force: true });
|
|
8123
8722
|
}
|
|
8124
8723
|
}), "restoreCommand");
|
|
8125
8724
|
var restoreFrom = /* @__PURE__ */ __name(async (command, messenger, backup, given) => {
|
|
8126
8725
|
const { renderer } = outputFor(command);
|
|
8127
8726
|
const path = storePath(environmentOf(command).env ?? process.env);
|
|
8128
|
-
if (
|
|
8727
|
+
if (existsSync9(path) && realpathSync2(backup) === realpathSync2(path)) {
|
|
8129
8728
|
throw new CliError("validation_error", `${backup} is the store itself`);
|
|
8130
8729
|
}
|
|
8730
|
+
if (await isRollbackCopy(backup))
|
|
8731
|
+
return rollBackFrom(command, messenger, backup);
|
|
8131
8732
|
const schema = await backupSchema(backup);
|
|
8132
8733
|
const stamp = stampNow();
|
|
8133
|
-
const kept =
|
|
8734
|
+
const kept = existsSync9(path) ? `${path}.before-restore-${stamp}` : null;
|
|
8134
8735
|
if (kept) {
|
|
8135
8736
|
const waitMs = environmentOf(command).storeLockWaitMs;
|
|
8136
8737
|
await quiesce(path, messenger, "restore", (message) => renderer.warn(message), waitMs);
|
|
8137
8738
|
} else
|
|
8138
|
-
mkdirSync(
|
|
8739
|
+
mkdirSync(dirname2(path), { recursive: true, mode: 448 });
|
|
8139
8740
|
const incoming = `${path}.restoring-${stamp}`;
|
|
8140
8741
|
copyFileSync(backup, incoming, constants.COPYFILE_EXCL);
|
|
8141
8742
|
chmodSync(incoming, 384);
|
|
8142
8743
|
if (kept) {
|
|
8143
|
-
|
|
8744
|
+
renameSync3(path, kept);
|
|
8144
8745
|
for (const suffix of ["-wal", "-shm"])
|
|
8145
|
-
if (
|
|
8146
|
-
|
|
8746
|
+
if (existsSync9(`${path}${suffix}`))
|
|
8747
|
+
renameSync3(`${path}${suffix}`, `${kept}${suffix}`);
|
|
8147
8748
|
}
|
|
8148
|
-
|
|
8749
|
+
renameSync3(incoming, path);
|
|
8149
8750
|
result(command, { path, restoredFrom: given, keptAt: kept, schema: schema.version });
|
|
8150
8751
|
if (kept)
|
|
8151
8752
|
renderer.note(`the store it replaced is kept at ${kept}`);
|
|
@@ -8154,6 +8755,43 @@ var restoreFrom = /* @__PURE__ */ __name(async (command, messenger, backup, give
|
|
|
8154
8755
|
renderer.note(`the backup is behind this build; the next command migrates it \u2014 \`${lineOf(command, "store migrate")}\` now`);
|
|
8155
8756
|
}
|
|
8156
8757
|
}, "restoreFrom");
|
|
8758
|
+
var isRollbackCopy = /* @__PURE__ */ __name(async (file2) => {
|
|
8759
|
+
try {
|
|
8760
|
+
return await readingOnly(file2, (database) => database.prepare("SELECT 1 FROM sqlite_master WHERE name = 'rollback_meta'").get() !== void 0);
|
|
8761
|
+
} catch {
|
|
8762
|
+
return false;
|
|
8763
|
+
}
|
|
8764
|
+
}, "isRollbackCopy");
|
|
8765
|
+
var rollBackFrom = /* @__PURE__ */ __name(async (command, messenger, copy) => {
|
|
8766
|
+
const { renderer } = outputFor(command);
|
|
8767
|
+
const path = storePath(environmentOf(command).env ?? process.env);
|
|
8768
|
+
if (!existsSync9(path))
|
|
8769
|
+
throw new CliError("not_found", `no store at ${path} to roll back`);
|
|
8770
|
+
const waitMs = environmentOf(command).storeLockWaitMs;
|
|
8771
|
+
await quiesce(path, messenger, "restore", (message) => renderer.warn(message), waitMs);
|
|
8772
|
+
const { database } = await openSqlite(path);
|
|
8773
|
+
let rolled;
|
|
8774
|
+
try {
|
|
8775
|
+
rolled = rollBack(database, copy);
|
|
8776
|
+
} finally {
|
|
8777
|
+
database.close();
|
|
8778
|
+
}
|
|
8779
|
+
result(command, {
|
|
8780
|
+
path,
|
|
8781
|
+
restoredFrom: copy,
|
|
8782
|
+
rolledBack: true,
|
|
8783
|
+
schema: rolled.from,
|
|
8784
|
+
was: rolled.was,
|
|
8785
|
+
tables: rolled.restored,
|
|
8786
|
+
rebuilt: rolled.rebuilt,
|
|
8787
|
+
foreignKeyViolations: rolled.foreignKeyViolations
|
|
8788
|
+
});
|
|
8789
|
+
const taken = new Date(rolled.createdAt).toISOString();
|
|
8790
|
+
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`);
|
|
8791
|
+
renderer.note("open it with the older tool and run its `store rebuild`: the search indexes are behind the tables");
|
|
8792
|
+
renderer.note(`a tool that speaks schema ${rolled.to} or later migrates it again on its next run`);
|
|
8793
|
+
renderer.note("restart every serve and mcp of either CLI that was running, so they read the restored store");
|
|
8794
|
+
}, "rollBackFrom");
|
|
8157
8795
|
var backupSchema = /* @__PURE__ */ __name(async (backup) => {
|
|
8158
8796
|
let read;
|
|
8159
8797
|
try {
|
|
@@ -8177,7 +8815,7 @@ var backupSchema = /* @__PURE__ */ __name(async (backup) => {
|
|
|
8177
8815
|
var STORE_LOCK_WAIT_MS = 1e3;
|
|
8178
8816
|
var quiesce = /* @__PURE__ */ __name(async (path, messenger, then, warn, waitMs = STORE_LOCK_WAIT_MS) => {
|
|
8179
8817
|
const { command } = messenger.app;
|
|
8180
|
-
const files = [path, `${path}-wal`, `${path}-shm`].filter((file2) =>
|
|
8818
|
+
const files = [path, `${path}-wal`, `${path}-shm`].filter((file2) => existsSync9(file2)).map((file2) => realpathSync2(file2));
|
|
8181
8819
|
const holders = holdersOf(files);
|
|
8182
8820
|
if (holders === void 0) {
|
|
8183
8821
|
warn(`this system cannot say which processes have the store open \u2014 restart every running serve and mcp after this`);
|
|
@@ -8203,7 +8841,7 @@ var resetCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("r
|
|
|
8203
8841
|
const { command } = messenger.app;
|
|
8204
8842
|
const env = environmentOf(this).env ?? process.env;
|
|
8205
8843
|
const path = storePath(env);
|
|
8206
|
-
if (!
|
|
8844
|
+
if (!existsSync9(path)) {
|
|
8207
8845
|
result(this, { path, exists: false, reset: false });
|
|
8208
8846
|
renderer.note(`no store at ${path} \u2014 nothing to reset; the first \`${command}\` command that reads a chat creates it`);
|
|
8209
8847
|
return;
|
|
@@ -8239,17 +8877,17 @@ var resetCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("r
|
|
|
8239
8877
|
});
|
|
8240
8878
|
renderer.note(`backed the store up to ${backup}`);
|
|
8241
8879
|
}
|
|
8242
|
-
for (const suffix of
|
|
8243
|
-
|
|
8880
|
+
for (const suffix of STORE_PARTS2)
|
|
8881
|
+
rmSync3(`${path}${suffix}`, { force: true });
|
|
8244
8882
|
await (await openStore({ path, command })).close();
|
|
8245
8883
|
const schema = await reading(path, (database) => schemaOf(database).version);
|
|
8246
8884
|
result(this, { path, exists: true, reset: true, backup, backedUp, schema });
|
|
8247
8885
|
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
8886
|
}), "resetCommand");
|
|
8249
|
-
var
|
|
8887
|
+
var STORE_PARTS2 = ["", "-wal", "-shm"];
|
|
8250
8888
|
var resetPreview = /* @__PURE__ */ __name(async (path, messenger, env, keep) => {
|
|
8251
|
-
const files =
|
|
8252
|
-
const holders = holdersOf(files.map((file2) =>
|
|
8889
|
+
const files = STORE_PARTS2.map((suffix) => `${path}${suffix}`).filter((file2) => existsSync9(file2));
|
|
8890
|
+
const holders = holdersOf(files.map((file2) => realpathSync2(file2)));
|
|
8253
8891
|
const serving = servingProfiles(messenger.app, env).length > 0;
|
|
8254
8892
|
const read = await readingOnly(path, (database) => ({
|
|
8255
8893
|
schema: schemaOf(database).version,
|
|
@@ -8280,6 +8918,10 @@ export {
|
|
|
8280
8918
|
checkFor,
|
|
8281
8919
|
passes,
|
|
8282
8920
|
seal,
|
|
8921
|
+
storeRecoveryCheck,
|
|
8922
|
+
storeRecoveryRun,
|
|
8923
|
+
recoveryNotes,
|
|
8924
|
+
storeRecoverCommand,
|
|
8283
8925
|
storeInfo,
|
|
8284
8926
|
storeInfoCommand,
|
|
8285
8927
|
sharedStoreCommand,
|