@wirecat/mail-cli 0.16.3 → 0.18.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/CHANGELOG.md +100 -0
- package/README.md +7 -4
- package/dist/bin/mail.js +2 -2
- package/dist/bundle/{all-profiles-TUDREUUW.js → all-profiles-4CVOXA5Y.js} +10 -10
- package/dist/bundle/{anthropic-KQOVSP6C.js → anthropic-5VIKYINO.js} +6 -6
- package/dist/bundle/{app-server-QK7PKVT7.js → app-server-LTSQBDPF.js} +53 -50
- package/dist/bundle/{bun-2NMWL5YB.js → bun-C7DBRUW2.js} +2 -2
- package/dist/bundle/{bun-sqlite-Y4FP6SDX.js → bun-sqlite-Y5JKT62B.js} +5 -5
- package/dist/bundle/{chunk-MLWN27HF.js → chunk-23HWKHPZ.js} +326 -288
- package/dist/bundle/{chunk-4IEDXIUN.js → chunk-2NWOYXPJ.js} +240 -64
- package/dist/bundle/{chunk-YPF6OS37.js → chunk-3DQYO7FB.js} +1 -1
- package/dist/bundle/{chunk-I3K6JG4I.js → chunk-3W5H4TM7.js} +182 -60
- package/dist/bundle/{chunk-CGH6UH3T.js → chunk-3YRE6DNM.js} +8 -8
- package/dist/bundle/{chunk-LMN7SYX4.js → chunk-43I5XD7S.js} +1 -1
- package/dist/bundle/{chunk-KMZRXGTF.js → chunk-5S6Q3SWU.js} +4 -2
- package/dist/bundle/{chunk-XEIGKPYU.js → chunk-6RO5RDNR.js} +50 -3
- package/dist/bundle/{chunk-OYB3FUYQ.js → chunk-7P4ICYJT.js} +1 -1
- package/dist/bundle/{chunk-XBIPSSKI.js → chunk-7SWWVDEZ.js} +4 -4
- package/dist/bundle/{chunk-4IIH5PXR.js → chunk-A5OMARL4.js} +28 -28
- package/dist/bundle/{chunk-ZNW4E3SG.js → chunk-ACLILULA.js} +3 -3
- package/dist/bundle/{chunk-EZIJPXDZ.js → chunk-AOMSP4EI.js} +6 -6
- package/dist/bundle/{chunk-G6RG2AZV.js → chunk-BHNBWFT5.js} +55 -8
- package/dist/bundle/{chunk-FHY664YS.js → chunk-BMFPCW6Q.js} +4 -4
- package/dist/bundle/{chunk-PWTEWT4M.js → chunk-BMGVKULS.js} +4 -4
- package/dist/bundle/{chunk-QCNK3YUZ.js → chunk-BMV56JCL.js} +19 -19
- package/dist/bundle/{chunk-B2NDDA2W.js → chunk-C4RUKMDT.js} +16 -10
- package/dist/bundle/{chunk-XAANQN4R.js → chunk-C5T5K7HW.js} +208 -83
- package/dist/bundle/{chunk-7LMTWOTP.js → chunk-CPEN6BZZ.js} +2 -2
- package/dist/bundle/{chunk-EB2IULWB.js → chunk-DALBYUPC.js} +2 -2
- package/dist/bundle/{chunk-6DVPPLAN.js → chunk-DPSH46NO.js} +5 -5
- package/dist/bundle/{chunk-VTJ5TMGN.js → chunk-EFP5NN7I.js} +3 -3
- package/dist/bundle/{chunk-KJV3BI7S.js → chunk-ERBEBORA.js} +23 -21
- package/dist/bundle/{chunk-RPEW7E3S.js → chunk-FLOOPXOT.js} +12 -12
- package/dist/bundle/{chunk-R6SBRHVG.js → chunk-GLLLYACZ.js} +6 -6
- package/dist/bundle/{chunk-WKHHCCJE.js → chunk-GRP67IQ4.js} +56 -47
- package/dist/bundle/{chunk-5KPPP3QN.js → chunk-HFUS33UT.js} +14 -2
- package/dist/bundle/{chunk-TTOKDZQX.js → chunk-HTFBXGJF.js} +2 -2
- package/dist/bundle/{chunk-N7DLDEFU.js → chunk-IANOK5SE.js} +2 -2
- package/dist/bundle/{chunk-3CVDHJER.js → chunk-ITUC5WAV.js} +1 -1
- package/dist/bundle/{chunk-POS35G6D.js → chunk-JO3BIMYK.js} +3 -3
- package/dist/bundle/{chunk-EBEYU7RW.js → chunk-KVSC657S.js} +44 -143
- package/dist/bundle/{chunk-DDQXDX4U.js → chunk-L3YX7A5M.js} +7 -7
- package/dist/bundle/{chunk-VP5FL5JQ.js → chunk-M7C4IGJ6.js} +8 -8
- package/dist/bundle/{chunk-ZS6YKNYS.js → chunk-MCR43SWG.js} +4 -4
- package/dist/bundle/{chunk-UBLFUQ7O.js → chunk-N5VEJ3E7.js} +97 -12
- package/dist/bundle/{chunk-IJYYD2JU.js → chunk-NDJZQCF3.js} +467 -231
- package/dist/bundle/{chunk-HN3EDDVX.js → chunk-OLJDZTHB.js} +13 -13
- package/dist/bundle/{chunk-3ZJE5TIG.js → chunk-OMKPALMX.js} +2 -2
- package/dist/bundle/{chunk-X7EBOXBY.js → chunk-OUGGAAXI.js} +13235 -1228
- package/dist/bundle/{chunk-YGJO5VNR.js → chunk-P6WCG6X2.js} +36 -30
- package/dist/bundle/{chunk-K2OQCQ2N.js → chunk-QPF4LTK5.js} +6 -6
- package/dist/bundle/{chunk-ARDUJR5Z.js → chunk-RIO3TD3I.js} +1 -1
- package/dist/bundle/{chunk-5FPQGUJA.js → chunk-RQSF7X22.js} +1 -1
- package/dist/bundle/{chunk-GAYW2JRW.js → chunk-SIYT2BBI.js} +10 -10
- package/dist/bundle/chunk-SMS5YNPB.js +64 -0
- package/dist/bundle/{chunk-PYX6K527.js → chunk-SW2KERUB.js} +648 -130
- package/dist/bundle/{chunk-Q4T2HBZP.js → chunk-TVZ77ZOV.js} +2 -2
- package/dist/bundle/{chunk-DKIAHQRN.js → chunk-U43HUE35.js} +9 -9
- package/dist/bundle/{chunk-CT2MIWXY.js → chunk-UEGABYXI.js} +3 -3
- package/dist/bundle/{chunk-KV4267S4.js → chunk-UHC5I3JV.js} +1 -1
- package/dist/bundle/{chunk-EDJQDR5X.js → chunk-UWL2IOII.js} +4 -4
- package/dist/bundle/{chunk-M6O4DH5F.js → chunk-UXD5JMS5.js} +1 -1
- package/dist/bundle/{chunk-ANFIIXBL.js → chunk-WA3DQSAZ.js} +2 -2
- package/dist/bundle/{chunk-FROWEHK7.js → chunk-XGTW3GRX.js} +2 -2
- package/dist/bundle/{chunk-VD6GZ3W2.js → chunk-YA2JPMYX.js} +2 -2
- package/dist/bundle/{chunk-CRYWPLJP.js → chunk-ZLH465EU.js} +1 -1
- package/dist/bundle/{chunk-HVAXTTOT.js → chunk-ZT2Y267T.js} +3 -3
- package/dist/bundle/command-contract-Y3GIKCPB.js +34 -0
- package/dist/bundle/{decode-WCS4KOHV.js → decode-WVIDLK4E.js} +5 -5
- package/dist/bundle/{dispatch-3ILCYZ4Q.js → dispatch-R5OF2FVZ.js} +8 -8
- package/dist/bundle/{dist-FL422DTA.js → dist-KGQWS3XL.js} +41 -23
- package/dist/bundle/{echarts-45D6USAX.js → echarts-VMKACZBF.js} +2 -2
- package/dist/bundle/{embed-4B4ATLCN.js → embed-EQINOOST.js} +6 -6
- package/dist/bundle/{embedder-ASWGJXNV.js → embedder-LM52TDRN.js} +9 -9
- package/dist/bundle/{failure-UDL5QZRZ.js → failure-WYKVF6RH.js} +2 -2
- package/dist/bundle/{first-run-5K3UD4BU.js → first-run-H4VXZAAF.js} +11 -11
- package/dist/bundle/first-screen-ZP74TJLK.js +32 -0
- package/dist/bundle/{instructions-6EFSPC7C.js → instructions-NLSME663.js} +1 -1
- package/dist/bundle/mail.js +12 -12
- package/dist/bundle/{mcp-PPVOM4SE.js → mcp-CFVG2OUS.js} +2 -2
- package/dist/bundle/{node-OXC26QXO.js → node-FGMSXLTA.js} +2 -2
- package/dist/bundle/{node-sqlite-PXHZAG7Y.js → node-sqlite-K3T3ZRBY.js} +6 -6
- package/dist/bundle/{oauth-YK2QLC7U.js → oauth-OJKJ6JLH.js} +7 -7
- package/dist/bundle/{open-SABDXZ4B.js → open-DCYIXHXS.js} +5 -5
- package/dist/bundle/{openai-DPURPXEU.js → openai-C4H4W57J.js} +14 -14
- package/dist/bundle/{process-YWPAOI6G.js → process-MN4NSYGA.js} +1 -1
- package/dist/bundle/{program-4ILOQHLO.js → program-ZZZOKWCX.js} +4026 -12667
- package/dist/bundle/{prompt-GKVNFGFE.js → prompt-ELEJUDAU.js} +5 -5
- package/dist/bundle/{recognize-344YDSLX.js → recognize-G2FVMI5M.js} +4 -4
- package/dist/bundle/{remote-53UZUJJU.js → remote-F4YVSEYM.js} +7 -7
- package/dist/bundle/{rerank-PAIRND6R.js → rerank-7VM5R5N6.js} +7 -7
- package/dist/bundle/{serve-DZSO7LJK.js → serve-A7NRFPRN.js} +9 -9
- package/dist/bundle/{server-EGG3V67I.js → server-7R2BEIRY.js} +39 -39
- package/dist/bundle/server-DFJA2HBO.js +64 -0
- package/dist/bundle/{sqlite-runtime-ZQ6F3VYZ.js → sqlite-runtime-4SKUB4EN.js} +6 -6
- package/dist/bundle/{state-LXPOWLZ5.js → state-S2FKK2XB.js} +6 -6
- package/dist/bundle/{store-PHT75I6S.js → store-4HAARQVR.js} +34 -26
- package/dist/bundle/{store-4ZMSK5R5.js → store-FLHO3UMA.js} +17 -15
- package/dist/bundle/store-maintenance-command-BINJIQ6F.js +54 -0
- package/dist/commands/account.d.ts.map +1 -1
- package/dist/commands/account.js +56 -64
- package/dist/commands/account.js.map +1 -1
- package/dist/commands/attachments.d.ts.map +1 -1
- package/dist/commands/attachments.js +15 -12
- package/dist/commands/attachments.js.map +1 -1
- package/dist/commands/context.d.ts +4 -0
- package/dist/commands/context.d.ts.map +1 -1
- package/dist/commands/context.js +12 -1
- package/dist/commands/context.js.map +1 -1
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/{mail → commands}/doctor.js +1 -1
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/drafts-send.d.ts.map +1 -1
- package/dist/commands/drafts-send.js +12 -10
- package/dist/commands/drafts-send.js.map +1 -1
- package/dist/commands/drafts.d.ts.map +1 -1
- package/dist/commands/drafts.js +28 -14
- package/dist/commands/drafts.js.map +1 -1
- package/dist/commands/export.d.ts.map +1 -1
- package/dist/commands/export.js +194 -195
- package/dist/commands/export.js.map +1 -1
- package/dist/commands/folders.d.ts.map +1 -1
- package/dist/commands/folders.js +19 -32
- package/dist/commands/folders.js.map +1 -1
- package/dist/commands/import.d.ts.map +1 -1
- package/dist/commands/import.js +10 -5
- package/dist/commands/import.js.map +1 -1
- package/dist/commands/messages.d.ts +0 -21
- package/dist/commands/messages.d.ts.map +1 -1
- package/dist/commands/messages.js +10 -278
- package/dist/commands/messages.js.map +1 -1
- package/dist/commands/organising.d.ts +98 -0
- package/dist/commands/organising.d.ts.map +1 -0
- package/dist/commands/organising.js +231 -0
- package/dist/commands/organising.js.map +1 -0
- package/dist/commands/restore.d.ts +3 -0
- package/dist/commands/restore.d.ts.map +1 -0
- package/dist/commands/restore.js +93 -0
- package/dist/commands/restore.js.map +1 -0
- package/dist/commands/rules.d.ts.map +1 -1
- package/dist/commands/rules.js +3 -2
- package/dist/commands/rules.js.map +1 -1
- package/dist/commands/send.d.ts +14 -3
- package/dist/commands/send.d.ts.map +1 -1
- package/dist/commands/send.js +18 -11
- package/dist/commands/send.js.map +1 -1
- package/dist/commands/session-start.d.ts.map +1 -1
- package/dist/commands/session-start.js +14 -4
- package/dist/commands/session-start.js.map +1 -1
- package/dist/commands/status.js +2 -2
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +136 -141
- package/dist/commands/sync.js.map +1 -1
- package/dist/commands/tags.d.ts.map +1 -1
- package/dist/commands/tags.js +11 -7
- package/dist/commands/tags.js.map +1 -1
- package/dist/commands/words.d.ts +8 -0
- package/dist/commands/words.d.ts.map +1 -0
- package/dist/commands/words.js +52 -0
- package/dist/commands/words.js.map +1 -0
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +2 -1
- package/dist/discovery.js.map +1 -1
- package/dist/export/journal.d.ts +8 -6
- package/dist/export/journal.d.ts.map +1 -1
- package/dist/export/journal.js +39 -14
- package/dist/export/journal.js.map +1 -1
- package/dist/mail/changes.d.ts +9 -2
- package/dist/mail/changes.d.ts.map +1 -1
- package/dist/mail/changes.js +45 -17
- package/dist/mail/changes.js.map +1 -1
- package/dist/mail/cleanup.d.ts.map +1 -1
- package/dist/mail/cleanup.js +5 -1
- package/dist/mail/cleanup.js.map +1 -1
- package/dist/mail/domain-age.d.ts.map +1 -1
- package/dist/mail/domain-age.js +24 -6
- package/dist/mail/domain-age.js.map +1 -1
- package/dist/mail/drafts.d.ts.map +1 -1
- package/dist/mail/drafts.js +9 -7
- package/dist/mail/drafts.js.map +1 -1
- package/dist/mail/imap/connection.d.ts.map +1 -1
- package/dist/mail/imap/connection.js +8 -9
- package/dist/mail/imap/connection.js.map +1 -1
- package/dist/mail/imap/errors.d.ts.map +1 -1
- package/dist/mail/imap/errors.js +2 -2
- package/dist/mail/imap/errors.js.map +1 -1
- package/dist/mail/imap/read.d.ts.map +1 -1
- package/dist/mail/imap/read.js +8 -5
- package/dist/mail/imap/read.js.map +1 -1
- package/dist/mail/imap/write.d.ts.map +1 -1
- package/dist/mail/imap/write.js +2 -1
- package/dist/mail/imap/write.js.map +1 -1
- package/dist/mail/locate.d.ts +32 -0
- package/dist/mail/locate.d.ts.map +1 -0
- package/dist/mail/locate.js +99 -0
- package/dist/mail/locate.js.map +1 -0
- package/dist/mail/mbox.d.ts.map +1 -1
- package/dist/mail/mbox.js +7 -5
- package/dist/mail/mbox.js.map +1 -1
- package/dist/mail/organise.d.ts +35 -50
- package/dist/mail/organise.d.ts.map +1 -1
- package/dist/mail/organise.js +44 -279
- package/dist/mail/organise.js.map +1 -1
- package/dist/mail/restore.d.ts +22 -0
- package/dist/mail/restore.d.ts.map +1 -0
- package/dist/mail/restore.js +193 -0
- package/dist/mail/restore.js.map +1 -0
- package/dist/mail/rules/apply.d.ts.map +1 -1
- package/dist/mail/rules/apply.js +5 -4
- package/dist/mail/rules/apply.js.map +1 -1
- package/dist/mail/rules/file.d.ts.map +1 -1
- package/dist/mail/rules/file.js +37 -8
- package/dist/mail/rules/file.js.map +1 -1
- package/dist/mail/rules/filters.d.ts.map +1 -1
- package/dist/mail/rules/filters.js +13 -7
- package/dist/mail/rules/filters.js.map +1 -1
- package/dist/mail/rules/query.d.ts.map +1 -1
- package/dist/mail/rules/query.js +7 -7
- package/dist/mail/rules/query.js.map +1 -1
- package/dist/mail/save.js +1 -1
- package/dist/mail/save.js.map +1 -1
- package/dist/mail/send.d.ts +4 -3
- package/dist/mail/send.d.ts.map +1 -1
- package/dist/mail/send.js +8 -8
- package/dist/mail/send.js.map +1 -1
- package/dist/mail/smtp.js +1 -1
- package/dist/mail/smtp.js.map +1 -1
- package/dist/oauth.d.ts +3 -2
- package/dist/oauth.d.ts.map +1 -1
- package/dist/oauth.js +16 -7
- package/dist/oauth.js.map +1 -1
- package/dist/profile.d.ts.map +1 -1
- package/dist/profile.js +3 -2
- package/dist/profile.js.map +1 -1
- package/dist/program.js +1 -1
- package/dist/program.js.map +1 -1
- package/dist/providers.js +3 -3
- package/dist/providers.js.map +1 -1
- package/dist/reasons.d.ts.map +1 -1
- package/dist/reasons.js +12 -0
- package/dist/reasons.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +5 -4
- package/skills/mail-cli/SKILL.md +3 -3
- package/dist/bundle/chunk-GIKNAOER.js +0 -132
- package/dist/bundle/command-contract-GVNLRXWS.js +0 -34
- package/dist/bundle/first-screen-NNX54MYC.js +0 -32
- package/dist/bundle/server-SGGMRV2K.js +0 -64
- package/dist/bundle/store-maintenance-command-C6ONZNRX.js +0 -54
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -3
- package/dist/index.js.map +0 -1
- package/dist/mail/doctor.d.ts.map +0 -1
- package/dist/mail/doctor.js.map +0 -1
- /package/dist/bundle/{chunk-LU3WKZBA.js → chunk-QZLK2ISN.js} +0 -0
- /package/dist/{mail → commands}/doctor.d.ts +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-YA2JPMYX.js";
|
|
6
6
|
import {
|
|
7
7
|
answerOf,
|
|
8
8
|
messengerContext
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-GRP67IQ4.js";
|
|
10
10
|
import {
|
|
11
11
|
FETCHING,
|
|
12
12
|
RULES_VERSION,
|
|
@@ -25,20 +25,21 @@ import {
|
|
|
25
25
|
servicesFor,
|
|
26
26
|
syncsOneChat,
|
|
27
27
|
typedQuery,
|
|
28
|
-
withQuery
|
|
29
|
-
|
|
28
|
+
withQuery,
|
|
29
|
+
withTimeLimit
|
|
30
|
+
} from "./chunk-23HWKHPZ.js";
|
|
30
31
|
import {
|
|
31
32
|
checkedOptions,
|
|
32
33
|
range
|
|
33
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-JO3BIMYK.js";
|
|
34
35
|
import {
|
|
35
36
|
messagesFor,
|
|
36
37
|
systemFor,
|
|
37
38
|
validateImages
|
|
38
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-OMKPALMX.js";
|
|
39
40
|
import {
|
|
40
41
|
readSecret
|
|
41
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-EFP5NN7I.js";
|
|
42
43
|
import {
|
|
43
44
|
Command,
|
|
44
45
|
LOCAL_READ,
|
|
@@ -66,30 +67,41 @@ import {
|
|
|
66
67
|
snakeKeys,
|
|
67
68
|
storeTable,
|
|
68
69
|
withoutProviderRefs
|
|
69
|
-
} from "./chunk-
|
|
70
|
+
} from "./chunk-NDJZQCF3.js";
|
|
70
71
|
import {
|
|
71
72
|
levelFor
|
|
72
|
-
} from "./chunk-
|
|
73
|
+
} from "./chunk-L3YX7A5M.js";
|
|
73
74
|
import {
|
|
74
75
|
failureKey
|
|
75
|
-
} from "./chunk-
|
|
76
|
+
} from "./chunk-U43HUE35.js";
|
|
76
77
|
import {
|
|
77
78
|
holdLock,
|
|
78
79
|
lockPath,
|
|
79
80
|
releaseLock,
|
|
80
81
|
servingProfiles,
|
|
81
82
|
takeLock
|
|
82
|
-
} from "./chunk-
|
|
83
|
+
} from "./chunk-UEGABYXI.js";
|
|
83
84
|
import {
|
|
84
85
|
holdersOf
|
|
85
|
-
} from "./chunk-
|
|
86
|
+
} from "./chunk-ITUC5WAV.js";
|
|
86
87
|
import {
|
|
88
|
+
QUICK_HEALTH_CHECKS,
|
|
89
|
+
explainDamage,
|
|
90
|
+
fts5Tables,
|
|
91
|
+
storeHealth
|
|
92
|
+
} from "./chunk-3W5H4TM7.js";
|
|
93
|
+
import {
|
|
94
|
+
CORPORA,
|
|
87
95
|
MIGRATIONS,
|
|
96
|
+
drainCorpus,
|
|
97
|
+
drainMeetingIndex,
|
|
88
98
|
drainNoteIndex,
|
|
89
99
|
dropAllUnusedVectors,
|
|
90
100
|
fileFacts,
|
|
91
101
|
fillSearchIndex,
|
|
92
102
|
fillStems,
|
|
103
|
+
fillTrigrams,
|
|
104
|
+
fillVectorIndexes,
|
|
93
105
|
involvementStoreOver,
|
|
94
106
|
migrate,
|
|
95
107
|
noteIndexState,
|
|
@@ -98,10 +110,12 @@ import {
|
|
|
98
110
|
orphanPointers,
|
|
99
111
|
pendingNormalization,
|
|
100
112
|
readStoreTables,
|
|
113
|
+
rebuildMentions,
|
|
101
114
|
resetAttachmentWords,
|
|
102
115
|
resetNoteIndex,
|
|
103
116
|
resetSearchIndex,
|
|
104
117
|
resetStems,
|
|
118
|
+
rollBack,
|
|
105
119
|
rowCounts,
|
|
106
120
|
searchIndexState,
|
|
107
121
|
stemmerCache,
|
|
@@ -109,26 +123,26 @@ import {
|
|
|
109
123
|
storeClients,
|
|
110
124
|
storeContents,
|
|
111
125
|
vectorIndexCounts
|
|
112
|
-
} from "./chunk-
|
|
126
|
+
} from "./chunk-OUGGAAXI.js";
|
|
113
127
|
import {
|
|
114
128
|
formatLocator,
|
|
115
129
|
parseLocator
|
|
116
|
-
} from "./chunk-
|
|
130
|
+
} from "./chunk-KVSC657S.js";
|
|
117
131
|
import {
|
|
118
132
|
queryFieldsOf
|
|
119
|
-
} from "./chunk-
|
|
133
|
+
} from "./chunk-2NWOYXPJ.js";
|
|
120
134
|
import {
|
|
121
135
|
storePath
|
|
122
|
-
} from "./chunk-
|
|
136
|
+
} from "./chunk-HTFBXGJF.js";
|
|
123
137
|
import {
|
|
124
138
|
openCache
|
|
125
|
-
} from "./chunk-
|
|
139
|
+
} from "./chunk-AOMSP4EI.js";
|
|
126
140
|
import {
|
|
127
141
|
Credentials,
|
|
128
142
|
pathsAreOverridden,
|
|
129
143
|
resolvePaths,
|
|
130
144
|
writeSecurely
|
|
131
|
-
} from "./chunk-
|
|
145
|
+
} from "./chunk-BMV56JCL.js";
|
|
132
146
|
import {
|
|
133
147
|
array,
|
|
134
148
|
boolean,
|
|
@@ -152,10 +166,10 @@ import {
|
|
|
152
166
|
transform,
|
|
153
167
|
trim,
|
|
154
168
|
union
|
|
155
|
-
} from "./chunk-
|
|
169
|
+
} from "./chunk-BHNBWFT5.js";
|
|
156
170
|
import {
|
|
157
171
|
CliError
|
|
158
|
-
} from "./chunk-
|
|
172
|
+
} from "./chunk-DALBYUPC.js";
|
|
159
173
|
import {
|
|
160
174
|
__commonJS,
|
|
161
175
|
__name,
|
|
@@ -1809,7 +1823,7 @@ var require_liquid_node = __commonJS({
|
|
|
1809
1823
|
return readFileAsync(filepath, "utf8");
|
|
1810
1824
|
}
|
|
1811
1825
|
__name(readFile, "readFile");
|
|
1812
|
-
function
|
|
1826
|
+
function existsSync10(filepath) {
|
|
1813
1827
|
try {
|
|
1814
1828
|
fs$1.statSync(filepath);
|
|
1815
1829
|
return true;
|
|
@@ -1817,11 +1831,11 @@ var require_liquid_node = __commonJS({
|
|
|
1817
1831
|
return false;
|
|
1818
1832
|
}
|
|
1819
1833
|
}
|
|
1820
|
-
__name(
|
|
1821
|
-
function
|
|
1834
|
+
__name(existsSync10, "existsSync");
|
|
1835
|
+
function readFileSync5(filepath) {
|
|
1822
1836
|
return fs$1.readFileSync(filepath, "utf8");
|
|
1823
1837
|
}
|
|
1824
|
-
__name(
|
|
1838
|
+
__name(readFileSync5, "readFileSync");
|
|
1825
1839
|
function resolve2(root, file2, ext) {
|
|
1826
1840
|
if (!path.extname(file2))
|
|
1827
1841
|
file2 += ext;
|
|
@@ -1835,10 +1849,10 @@ var require_liquid_node = __commonJS({
|
|
|
1835
1849
|
}
|
|
1836
1850
|
}
|
|
1837
1851
|
__name(fallback, "fallback");
|
|
1838
|
-
function
|
|
1852
|
+
function dirname3(filepath) {
|
|
1839
1853
|
return path.dirname(filepath);
|
|
1840
1854
|
}
|
|
1841
|
-
__name(
|
|
1855
|
+
__name(dirname3, "dirname");
|
|
1842
1856
|
var realpathAsync = promisify(fs$1.realpath);
|
|
1843
1857
|
async function contains(root, file2) {
|
|
1844
1858
|
try {
|
|
@@ -1866,11 +1880,11 @@ var require_liquid_node = __commonJS({
|
|
|
1866
1880
|
__proto__: null,
|
|
1867
1881
|
exists,
|
|
1868
1882
|
readFile,
|
|
1869
|
-
existsSync:
|
|
1870
|
-
readFileSync:
|
|
1883
|
+
existsSync: existsSync10,
|
|
1884
|
+
readFileSync: readFileSync5,
|
|
1871
1885
|
resolve: resolve2,
|
|
1872
1886
|
fallback,
|
|
1873
|
-
dirname:
|
|
1887
|
+
dirname: dirname3,
|
|
1874
1888
|
contains,
|
|
1875
1889
|
containsSync,
|
|
1876
1890
|
sep: path.sep
|
|
@@ -3595,7 +3609,7 @@ var require_liquid_node = __commonJS({
|
|
|
3595
3609
|
uri_escape,
|
|
3596
3610
|
slugify
|
|
3597
3611
|
});
|
|
3598
|
-
var
|
|
3612
|
+
var join5 = argumentsToValue(function(v, arg) {
|
|
3599
3613
|
const array2 = toArray(v);
|
|
3600
3614
|
const sep = isNil(arg) ? " " : stringify(arg);
|
|
3601
3615
|
let outputSize = sep.length * Math.max(array2.length - 1, 0);
|
|
@@ -3871,7 +3885,7 @@ var require_liquid_node = __commonJS({
|
|
|
3871
3885
|
__name(sample, "sample");
|
|
3872
3886
|
var arrayFilters = /* @__PURE__ */ Object.freeze({
|
|
3873
3887
|
__proto__: null,
|
|
3874
|
-
join:
|
|
3888
|
+
join: join5,
|
|
3875
3889
|
last,
|
|
3876
3890
|
first,
|
|
3877
3891
|
reverse,
|
|
@@ -4799,15 +4813,15 @@ var require_liquid_node = __commonJS({
|
|
|
4799
4813
|
}
|
|
4800
4814
|
*render(ctx, emitter) {
|
|
4801
4815
|
const group = yield evalToken(this.group, ctx);
|
|
4802
|
-
const
|
|
4816
|
+
const fingerprint2 = `cycle:${group}:` + this.candidates.join(",");
|
|
4803
4817
|
const groups = ctx.getRegister("cycle", {});
|
|
4804
|
-
let idx = groups[
|
|
4818
|
+
let idx = groups[fingerprint2];
|
|
4805
4819
|
if (idx === void 0) {
|
|
4806
|
-
idx = groups[
|
|
4820
|
+
idx = groups[fingerprint2] = 0;
|
|
4807
4821
|
}
|
|
4808
4822
|
const candidate = this.candidates[idx];
|
|
4809
4823
|
idx = (idx + 1) % this.candidates.length;
|
|
4810
|
-
groups[
|
|
4824
|
+
groups[fingerprint2] = idx;
|
|
4811
4825
|
return yield evalToken(candidate, ctx);
|
|
4812
4826
|
}
|
|
4813
4827
|
*arguments() {
|
|
@@ -5495,11 +5509,11 @@ var require_liquid_node = __commonJS({
|
|
|
5495
5509
|
}
|
|
5496
5510
|
});
|
|
5497
5511
|
|
|
5498
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5499
|
-
import { chmodSync, constants, copyFileSync, existsSync as
|
|
5500
|
-
import { dirname, resolve } from "node:path";
|
|
5512
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.600.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_b9e89c8ee4e42a523b0faff8db1d3e1d/node_modules/@wirecat/cli-core/dist/cli/messenger/store-maintenance-command.js
|
|
5513
|
+
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";
|
|
5514
|
+
import { dirname as dirname2, resolve } from "node:path";
|
|
5501
5515
|
|
|
5502
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5516
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.600.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_b9e89c8ee4e42a523b0faff8db1d3e1d/node_modules/@wirecat/cli-core/dist/sealed.js
|
|
5503
5517
|
import { createCipheriv, createDecipheriv, createHash, randomBytes, scrypt, timingSafeEqual } from "node:crypto";
|
|
5504
5518
|
import { closeSync, createReadStream, createWriteStream, existsSync, openSync, readSync, renameSync, rmSync, statSync } from "node:fs";
|
|
5505
5519
|
import { Transform } from "node:stream";
|
|
@@ -5606,7 +5620,7 @@ var unsealFile = /* @__PURE__ */ __name(async (from, to, password) => {
|
|
|
5606
5620
|
renameSync(pending, to);
|
|
5607
5621
|
}, "unsealFile");
|
|
5608
5622
|
|
|
5609
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5623
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.600.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_b9e89c8ee4e42a523b0faff8db1d3e1d/node_modules/@wirecat/cli-core/dist/store/compatibility.js
|
|
5610
5624
|
var SPEAKS = MIGRATIONS.at(-1)?.version ?? 0;
|
|
5611
5625
|
var fileSchemaOf = /* @__PURE__ */ __name((database) => {
|
|
5612
5626
|
const tracked = database.prepare("SELECT 1 FROM sqlite_master WHERE name = 'schema_migrations'").get();
|
|
@@ -5630,7 +5644,7 @@ var compatibilityOf = /* @__PURE__ */ __name((file2, migrations = MIGRATIONS) =>
|
|
|
5630
5644
|
};
|
|
5631
5645
|
}, "compatibilityOf");
|
|
5632
5646
|
|
|
5633
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5647
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.600.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_b9e89c8ee4e42a523b0faff8db1d3e1d/node_modules/@wirecat/cli-core/dist/store/repair.js
|
|
5634
5648
|
import { createHash as createHash2 } from "node:crypto";
|
|
5635
5649
|
var COPY_MARK = "__repair_";
|
|
5636
5650
|
var COPY_NAME = /__repair_[0-9a-f]{8}(_\d+)?$/;
|
|
@@ -5884,10 +5898,457 @@ var deleteCopy = /* @__PURE__ */ __name((database, name) => {
|
|
|
5884
5898
|
return found;
|
|
5885
5899
|
}, "deleteCopy");
|
|
5886
5900
|
|
|
5887
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5888
|
-
import { existsSync as
|
|
5901
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.600.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_b9e89c8ee4e42a523b0faff8db1d3e1d/node_modules/@wirecat/cli-core/dist/cli/store-info.js
|
|
5902
|
+
import { existsSync as existsSync4, statSync as statSync3 } from "node:fs";
|
|
5903
|
+
|
|
5904
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.600.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_b9e89c8ee4e42a523b0faff8db1d3e1d/node_modules/@wirecat/cli-core/dist/cli/store-recover.js
|
|
5905
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
5906
|
+
|
|
5907
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.600.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_b9e89c8ee4e42a523b0faff8db1d3e1d/node_modules/@wirecat/cli-core/dist/store/recover.js
|
|
5908
|
+
import { execFileSync, spawn } from "node:child_process";
|
|
5909
|
+
import { existsSync as existsSync2, readFileSync, realpathSync, renameSync as renameSync2, rmSync as rmSync2, statfsSync, statSync as statSync2, writeFileSync } from "node:fs";
|
|
5910
|
+
import { basename, dirname, join } from "node:path";
|
|
5911
|
+
import { Transform as Transform2 } from "node:stream";
|
|
5912
|
+
var SQLITE3_MINIMUM = [3, 43, 0];
|
|
5913
|
+
var STORE_PARTS = ["", "-wal", "-shm"];
|
|
5914
|
+
var INSERTED = /^INSERT OR IGNORE INTO '([^']+)'/;
|
|
5915
|
+
var LOST_AND_FOUND = "recover_lost_and_found";
|
|
5916
|
+
var recovers = /* @__PURE__ */ __name((program) => {
|
|
5917
|
+
try {
|
|
5918
|
+
execFileSync(program, [":memory:", ".recover"], { stdio: ["ignore", "ignore", "pipe"] });
|
|
5919
|
+
return true;
|
|
5920
|
+
} catch {
|
|
5921
|
+
return false;
|
|
5922
|
+
}
|
|
5923
|
+
}, "recovers");
|
|
5924
|
+
var sqlite3Program = /* @__PURE__ */ __name((program = "sqlite3") => {
|
|
5925
|
+
let version = null;
|
|
5926
|
+
try {
|
|
5927
|
+
version = execFileSync(program, ["--version"], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).split(" ")[0] ?? null;
|
|
5928
|
+
} catch {
|
|
5929
|
+
return { program, version: null, usable: false };
|
|
5930
|
+
}
|
|
5931
|
+
const parts = (version ?? "").split(".").map(Number);
|
|
5932
|
+
const at = SQLITE3_MINIMUM.findIndex((wanted, i) => (parts[i] ?? 0) !== wanted);
|
|
5933
|
+
const recent = at === -1 || (parts[at] ?? 0) > (SQLITE3_MINIMUM[at] ?? 0);
|
|
5934
|
+
return { program, version, usable: recent && recovers(program) };
|
|
5935
|
+
}, "sqlite3Program");
|
|
5936
|
+
var activeTimers = /* @__PURE__ */ __name(() => {
|
|
5937
|
+
if (process.platform !== "linux")
|
|
5938
|
+
return void 0;
|
|
5939
|
+
try {
|
|
5940
|
+
return execFileSync("systemctl", ["--user", "list-timers", "--plain", "--no-legend"], {
|
|
5941
|
+
encoding: "utf8",
|
|
5942
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
5943
|
+
}).split("\n").map((line) => line.trim().split(/\s+/).at(-2) ?? "").filter((unit) => /^(memo|mail|tg|max|whatsapp|zoom|drive|gcal|wirecat)-.*\.timer$/.test(unit));
|
|
5944
|
+
} catch {
|
|
5945
|
+
return void 0;
|
|
5946
|
+
}
|
|
5947
|
+
}, "activeTimers");
|
|
5948
|
+
var storeHolders = /* @__PURE__ */ __name((path) => {
|
|
5949
|
+
const folder = realpathSync(dirname(path));
|
|
5950
|
+
const files = STORE_PARTS.map((suffix) => join(folder, `${basename(path)}${suffix}`));
|
|
5951
|
+
const wanted = process.platform === "linux" ? files.flatMap((file2) => [file2, `${file2} (deleted)`]) : files.filter(existsSync2);
|
|
5952
|
+
return holdersOf(wanted)?.map((pid) => {
|
|
5953
|
+
let name = "?";
|
|
5954
|
+
try {
|
|
5955
|
+
name = readFileSync(`/proc/${pid}/comm`, "utf8").trim();
|
|
5956
|
+
} catch {
|
|
5957
|
+
}
|
|
5958
|
+
return { pid, name };
|
|
5959
|
+
});
|
|
5960
|
+
}, "storeHolders");
|
|
5961
|
+
var tableRows = /* @__PURE__ */ __name((database) => {
|
|
5962
|
+
const indexes = fts5Tables(database).map((index) => index.name);
|
|
5963
|
+
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}_`)));
|
|
5964
|
+
return Object.fromEntries(tables.map((table) => {
|
|
5965
|
+
try {
|
|
5966
|
+
return [table, Number(database.prepare(`SELECT count(*) AS n FROM "${table}"`).get()?.n)];
|
|
5967
|
+
} catch {
|
|
5968
|
+
return [table, null];
|
|
5969
|
+
}
|
|
5970
|
+
}));
|
|
5971
|
+
}, "tableRows");
|
|
5972
|
+
var copyReadableRows = /* @__PURE__ */ __name((path, target, program = "sqlite3") => new Promise((resolve2, reject) => {
|
|
5973
|
+
const reader = spawn(program, ["-readonly", path, `.recover --ignore-freelist --lost-and-found ${LOST_AND_FOUND}`], {
|
|
5974
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
5975
|
+
});
|
|
5976
|
+
const writer = spawn(program, ["-cmd", ".dbconfig defensive off", target], { stdio: ["pipe", "ignore", "pipe"] });
|
|
5977
|
+
const errors = [];
|
|
5978
|
+
const collect = /* @__PURE__ */ __name((chunk) => {
|
|
5979
|
+
for (const line of chunk.toString("utf8").split("\n"))
|
|
5980
|
+
if (line && errors.length < 50)
|
|
5981
|
+
errors.push(line.slice(0, 300));
|
|
5982
|
+
}, "collect");
|
|
5983
|
+
reader.stderr.on("data", collect);
|
|
5984
|
+
writer.stderr.on("data", collect);
|
|
5985
|
+
const read = {};
|
|
5986
|
+
let rest = "";
|
|
5987
|
+
const counter = new Transform2({
|
|
5988
|
+
transform(chunk, _encoding, done) {
|
|
5989
|
+
const lines = (rest + chunk.toString("latin1")).split("\n");
|
|
5990
|
+
rest = lines.pop() ?? "";
|
|
5991
|
+
for (const line of lines) {
|
|
5992
|
+
const table = INSERTED.exec(line)?.[1];
|
|
5993
|
+
if (table)
|
|
5994
|
+
read[table] = (read[table] ?? 0) + 1;
|
|
5995
|
+
}
|
|
5996
|
+
done(null, chunk);
|
|
5997
|
+
}
|
|
5998
|
+
});
|
|
5999
|
+
reader.stdout.pipe(counter).pipe(writer.stdin);
|
|
6000
|
+
let exits = 0;
|
|
6001
|
+
let readerCode = null;
|
|
6002
|
+
const exited = /* @__PURE__ */ __name(() => {
|
|
6003
|
+
exits += 1;
|
|
6004
|
+
if (exits < 2)
|
|
6005
|
+
return;
|
|
6006
|
+
if (readerCode !== 0)
|
|
6007
|
+
reject(new CliError("validation_error", `sqlite3 could not read the store: ${errors.join("; ")}`));
|
|
6008
|
+
else
|
|
6009
|
+
resolve2({ errors, read });
|
|
6010
|
+
}, "exited");
|
|
6011
|
+
reader.on("error", reject);
|
|
6012
|
+
writer.on("error", reject);
|
|
6013
|
+
reader.on("close", (code) => {
|
|
6014
|
+
readerCode = code;
|
|
6015
|
+
exited();
|
|
6016
|
+
});
|
|
6017
|
+
writer.on("close", exited);
|
|
6018
|
+
}), "copyReadableRows");
|
|
6019
|
+
var FILLERS = {
|
|
6020
|
+
message_words: /* @__PURE__ */ __name((database, now) => {
|
|
6021
|
+
resetSearchIndex(database);
|
|
6022
|
+
fillSearchIndex(database, { now });
|
|
6023
|
+
}, "message_words"),
|
|
6024
|
+
message_stems: /* @__PURE__ */ __name((database, now) => {
|
|
6025
|
+
resetStems(database, { force: true, now });
|
|
6026
|
+
fillStems(database, { now });
|
|
6027
|
+
}, "message_stems"),
|
|
6028
|
+
attachment_words: /* @__PURE__ */ __name((database) => void resetAttachmentWords(database), "attachment_words"),
|
|
6029
|
+
attachment_name_words: /* @__PURE__ */ __name((database) => (
|
|
6030
|
+
// As migration 20 filled it: й and ё fold as the triggers fold them.
|
|
6031
|
+
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")
|
|
6032
|
+
), "attachment_name_words"),
|
|
6033
|
+
meeting_words: /* @__PURE__ */ __name((database) => {
|
|
6034
|
+
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");
|
|
6035
|
+
drainMeetingIndex(database);
|
|
6036
|
+
}, "meeting_words"),
|
|
6037
|
+
// Built per account by the first search that needs them.
|
|
6038
|
+
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")
|
|
6039
|
+
};
|
|
6040
|
+
var CORPUS_TABLES = new Set(Object.values(CORPORA).flatMap((corpus) => [`${corpus.type}_words`, `${corpus.type}_stems`]));
|
|
6041
|
+
var TRIGRAMS = ["note_trigrams", "document_trigrams"];
|
|
6042
|
+
var rebuildDerived = /* @__PURE__ */ __name((database, { now = Date.now, note = /* @__PURE__ */ __name(() => {
|
|
6043
|
+
}, "note") } = {}) => {
|
|
6044
|
+
const lost = database.prepare("SELECT 1 FROM sqlite_master WHERE name = ?").get(LOST_AND_FOUND);
|
|
6045
|
+
const lostAndFound = lost ? Number(database.prepare(`SELECT count(*) AS n FROM ${LOST_AND_FOUND}`).get()?.n) : 0;
|
|
6046
|
+
if (lost)
|
|
6047
|
+
database.exec(`DROP TABLE ${LOST_AND_FOUND}`);
|
|
6048
|
+
const indexes = fts5Tables(database);
|
|
6049
|
+
for (const { name, sql } of indexes) {
|
|
6050
|
+
database.exec(`DROP TABLE "${name}"`);
|
|
6051
|
+
database.exec(sql);
|
|
6052
|
+
}
|
|
6053
|
+
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));
|
|
6054
|
+
for (const table of vectors) {
|
|
6055
|
+
database.exec(`DROP TRIGGER IF EXISTS "${table}_redo"`);
|
|
6056
|
+
database.exec(`DROP TABLE "${table}"`);
|
|
6057
|
+
database.prepare("DELETE FROM vector_indexes WHERE id = ?").run(Number(table.replace("vector_index_", "")));
|
|
6058
|
+
}
|
|
6059
|
+
const unfilled = [];
|
|
6060
|
+
const stemmerFor = stemmerCache();
|
|
6061
|
+
for (const { name, external } of indexes) {
|
|
6062
|
+
note(`rebuilding ${name}`);
|
|
6063
|
+
if (external)
|
|
6064
|
+
database.exec(`INSERT INTO "${name}" ("${name}") VALUES ('rebuild')`);
|
|
6065
|
+
else if (FILLERS[name])
|
|
6066
|
+
FILLERS[name](database, now);
|
|
6067
|
+
else if (!CORPUS_TABLES.has(name) && !TRIGRAMS.includes(name))
|
|
6068
|
+
unfilled.push(name);
|
|
6069
|
+
}
|
|
6070
|
+
note("rebuilding the words of notes, documents, memories, mail, tasks, transcripts and events");
|
|
6071
|
+
resetNoteIndex(database);
|
|
6072
|
+
for (const corpus of Object.values(CORPORA))
|
|
6073
|
+
drainCorpus(database, corpus, stemmerFor);
|
|
6074
|
+
for (const name of TRIGRAMS) {
|
|
6075
|
+
const type = name.replace("_trigrams", "");
|
|
6076
|
+
database.prepare(`UPDATE search_index_state SET filled_through = 0, watermark = (SELECT coalesce(max(id), 0) FROM ${type}s) WHERE name = ?`).run(name);
|
|
6077
|
+
}
|
|
6078
|
+
fillTrigrams(database);
|
|
6079
|
+
note("finding mentions again");
|
|
6080
|
+
const mentions = rebuildMentions(database, { now: now() }).mentions;
|
|
6081
|
+
involvementStoreOver({ database, now }).rebuild();
|
|
6082
|
+
note("indexing the stored vectors");
|
|
6083
|
+
const vectorModels = fillVectorIndexes(database);
|
|
6084
|
+
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)");
|
|
6085
|
+
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)]));
|
|
6086
|
+
return {
|
|
6087
|
+
lostAndFound,
|
|
6088
|
+
searchIndexes: indexes.map((index) => index.name),
|
|
6089
|
+
unfilled,
|
|
6090
|
+
mentions,
|
|
6091
|
+
vectorModels,
|
|
6092
|
+
chunksWithoutVector
|
|
6093
|
+
};
|
|
6094
|
+
}, "rebuildDerived");
|
|
6095
|
+
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) => {
|
|
6096
|
+
const child = String(group.child);
|
|
6097
|
+
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;
|
|
6098
|
+
let missing = [];
|
|
6099
|
+
try {
|
|
6100
|
+
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));
|
|
6101
|
+
} catch {
|
|
6102
|
+
}
|
|
6103
|
+
return { table: child, parent: String(group.parent), rows: Number(group.n), missing };
|
|
6104
|
+
}), "danglingRows");
|
|
6105
|
+
var mailToFetch = /* @__PURE__ */ __name((database) => {
|
|
6106
|
+
try {
|
|
6107
|
+
return database.prepare(`SELECT a.external_id AS account, count(DISTINCT l.email_id) AS n FROM email_locations l
|
|
6108
|
+
JOIN mailboxes b ON b.id = l.mailbox_id JOIN accounts a ON a.id = b.account_id
|
|
6109
|
+
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) }));
|
|
6110
|
+
} catch {
|
|
6111
|
+
return [];
|
|
6112
|
+
}
|
|
6113
|
+
}, "mailToFetch");
|
|
6114
|
+
var fingerprint = /* @__PURE__ */ __name((path) => ["", "-wal"].map((suffix) => {
|
|
6115
|
+
const stat = statSync2(`${path}${suffix}`, { throwIfNoEntry: false });
|
|
6116
|
+
return stat ? `${stat.size}:${stat.mtimeMs}` : "-";
|
|
6117
|
+
}).join("|"), "fingerprint");
|
|
6118
|
+
var refuseInUse = /* @__PURE__ */ __name((path) => {
|
|
6119
|
+
const holders = storeHolders(path);
|
|
6120
|
+
if (holders && holders.length > 0) {
|
|
6121
|
+
const timers = activeTimers() ?? [];
|
|
6122
|
+
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" });
|
|
6123
|
+
}
|
|
6124
|
+
}, "refuseInUse");
|
|
6125
|
+
var recoverStore = /* @__PURE__ */ __name(async ({ path, command, version, sqlite3 = "sqlite3", now = Date.now, note = /* @__PURE__ */ __name(() => {
|
|
6126
|
+
}, "note"), copy }) => {
|
|
6127
|
+
const started = Date.now();
|
|
6128
|
+
if (!existsSync2(path))
|
|
6129
|
+
throw new CliError("not_found", `no store at ${path}`);
|
|
6130
|
+
const program = copy ? { program: sqlite3, version: "given", usable: true } : sqlite3Program(sqlite3);
|
|
6131
|
+
if (!program.usable) {
|
|
6132
|
+
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" });
|
|
6133
|
+
}
|
|
6134
|
+
refuseInUse(path);
|
|
6135
|
+
const bytes = STORE_PARTS.reduce((sum, suffix) => sum + (statSync2(`${path}${suffix}`, { throwIfNoEntry: false })?.size ?? 0), 0);
|
|
6136
|
+
const { bavail, bsize } = statfsSync(dirname(path));
|
|
6137
|
+
if (Number(bavail) * Number(bsize) < bytes * 1.2)
|
|
6138
|
+
throw new CliError("validation_error", `the recovery needs about ${Math.ceil(bytes * 1.2 / 1e9)} GB free beside the store`);
|
|
6139
|
+
const old = await openSqlite(path, { readOnly: true });
|
|
6140
|
+
let rowsBefore;
|
|
6141
|
+
try {
|
|
6142
|
+
rowsBefore = tableRows(old.database);
|
|
6143
|
+
} finally {
|
|
6144
|
+
old.database.close();
|
|
6145
|
+
}
|
|
6146
|
+
const before = fingerprint(path);
|
|
6147
|
+
const stamp = new Date(now()).toISOString().replace(/[:.]/g, "-");
|
|
6148
|
+
const target = `${path}.recovering-${stamp}`;
|
|
6149
|
+
writeFileSync(target, "", { flag: "wx", mode: 384 });
|
|
6150
|
+
const dropTarget = /* @__PURE__ */ __name(() => {
|
|
6151
|
+
for (const suffix of [...STORE_PARTS, "-journal"])
|
|
6152
|
+
rmSync2(`${target}${suffix}`, { force: true });
|
|
6153
|
+
}, "dropTarget");
|
|
6154
|
+
note(`copying the readable rows into ${target}`);
|
|
6155
|
+
let copied;
|
|
6156
|
+
let copyErrors;
|
|
6157
|
+
let read;
|
|
6158
|
+
let opened;
|
|
6159
|
+
try {
|
|
6160
|
+
;
|
|
6161
|
+
({ errors: copyErrors, read } = await (copy ?? ((from, to) => copyReadableRows(from, to, sqlite3)))(path, target));
|
|
6162
|
+
copied = Date.now();
|
|
6163
|
+
opened = await openSqlite(target);
|
|
6164
|
+
} catch (error) {
|
|
6165
|
+
dropTarget();
|
|
6166
|
+
throw error;
|
|
6167
|
+
}
|
|
6168
|
+
let rebuilt;
|
|
6169
|
+
let kept;
|
|
6170
|
+
let dangling;
|
|
6171
|
+
let fetch2;
|
|
6172
|
+
try {
|
|
6173
|
+
kept = tableRows(opened.database);
|
|
6174
|
+
migrate(opened.database, { command, ...version ? { version } : {} });
|
|
6175
|
+
rebuilt = rebuildDerived(opened.database, { now, note });
|
|
6176
|
+
note("looking for rows that point at rows that were lost");
|
|
6177
|
+
dangling = danglingRows(opened.database);
|
|
6178
|
+
fetch2 = mailToFetch(opened.database);
|
|
6179
|
+
opened.database.exec("PRAGMA wal_checkpoint(TRUNCATE)");
|
|
6180
|
+
} catch (error) {
|
|
6181
|
+
opened.database.close();
|
|
6182
|
+
dropTarget();
|
|
6183
|
+
throw error;
|
|
6184
|
+
}
|
|
6185
|
+
opened.database.close();
|
|
6186
|
+
const rebuiltAt = Date.now();
|
|
6187
|
+
note("checking the recovered file");
|
|
6188
|
+
const health = await storeHealth(target, { deep: true });
|
|
6189
|
+
const checkedAt = Date.now();
|
|
6190
|
+
if (!health.ok) {
|
|
6191
|
+
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" });
|
|
6192
|
+
}
|
|
6193
|
+
refuseInUse(path);
|
|
6194
|
+
if (fingerprint(path) !== before) {
|
|
6195
|
+
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" });
|
|
6196
|
+
}
|
|
6197
|
+
const keptAt = `${path}.before-recover-${stamp}`;
|
|
6198
|
+
for (const suffix of STORE_PARTS)
|
|
6199
|
+
if (existsSync2(`${path}${suffix}`))
|
|
6200
|
+
renameSync2(`${path}${suffix}`, `${keptAt}${suffix}`);
|
|
6201
|
+
for (const suffix of STORE_PARTS)
|
|
6202
|
+
if (existsSync2(`${target}${suffix}`))
|
|
6203
|
+
renameSync2(`${target}${suffix}`, `${path}${suffix}`);
|
|
6204
|
+
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);
|
|
6205
|
+
const seconds = /* @__PURE__ */ __name((from, to) => Math.round((to - from) / 100) / 10, "seconds");
|
|
6206
|
+
return {
|
|
6207
|
+
path,
|
|
6208
|
+
keptAt,
|
|
6209
|
+
sqlite3: program.version,
|
|
6210
|
+
lost,
|
|
6211
|
+
dangling,
|
|
6212
|
+
mailToFetch: fetch2,
|
|
6213
|
+
rebuilt,
|
|
6214
|
+
copyErrors,
|
|
6215
|
+
health,
|
|
6216
|
+
seconds: {
|
|
6217
|
+
copy: seconds(started, copied),
|
|
6218
|
+
rebuild: seconds(copied, rebuiltAt),
|
|
6219
|
+
check: seconds(rebuiltAt, checkedAt),
|
|
6220
|
+
total: seconds(started, Date.now())
|
|
6221
|
+
}
|
|
6222
|
+
};
|
|
6223
|
+
}, "recoverStore");
|
|
6224
|
+
|
|
6225
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.600.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_b9e89c8ee4e42a523b0faff8db1d3e1d/node_modules/@wirecat/cli-core/dist/cli/store-recover.js
|
|
6226
|
+
var COUNTED = [
|
|
6227
|
+
"accounts",
|
|
6228
|
+
"chats",
|
|
6229
|
+
"messages",
|
|
6230
|
+
"attachments",
|
|
6231
|
+
"emails",
|
|
6232
|
+
"documents",
|
|
6233
|
+
"notes",
|
|
6234
|
+
"meetings",
|
|
6235
|
+
"chunks",
|
|
6236
|
+
"embeddings",
|
|
6237
|
+
"mentions"
|
|
6238
|
+
];
|
|
6239
|
+
var stopTimers = /* @__PURE__ */ __name((timers) => `systemctl --user stop ${timers.join(" ")}`, "stopTimers");
|
|
6240
|
+
var storeRecoveryCheck = /* @__PURE__ */ __name(async (env, command) => {
|
|
6241
|
+
const path = storePath(env);
|
|
6242
|
+
if (!existsSync3(path))
|
|
6243
|
+
return { path, exists: false, ok: true, next: [] };
|
|
6244
|
+
const health = await storeHealth(path, { deep: true });
|
|
6245
|
+
let rows = {};
|
|
6246
|
+
try {
|
|
6247
|
+
const { database } = await openSqlite(path, { readOnly: true });
|
|
6248
|
+
try {
|
|
6249
|
+
const all = tableRows(database);
|
|
6250
|
+
rows = Object.fromEntries(COUNTED.filter((table) => table in all).map((table) => [table, all[table] ?? null]));
|
|
6251
|
+
} finally {
|
|
6252
|
+
database.close();
|
|
6253
|
+
}
|
|
6254
|
+
} catch {
|
|
6255
|
+
}
|
|
6256
|
+
const explanation = explainDamage(health, command);
|
|
6257
|
+
const inUse = storeHolders(path) ?? null;
|
|
6258
|
+
const timers = activeTimers() ?? null;
|
|
6259
|
+
const sqlite3 = sqlite3Program();
|
|
6260
|
+
const next = health.ok ? [] : [
|
|
6261
|
+
...timers?.length ? [stopTimers(timers)] : [],
|
|
6262
|
+
...(inUse ?? []).map(({ pid, name }) => `stop ${name} (process ${pid}): it has the store open`),
|
|
6263
|
+
...sqlite3.usable ? [] : ["install sqlite3 3.43 or newer (apt install sqlite3, brew install sqlite)"],
|
|
6264
|
+
`${command} store recover run`
|
|
6265
|
+
];
|
|
6266
|
+
return {
|
|
6267
|
+
path,
|
|
6268
|
+
exists: true,
|
|
6269
|
+
ok: health.ok,
|
|
6270
|
+
seconds: Math.round(health.ms / 100) / 10,
|
|
6271
|
+
problems: health.problems ?? 0,
|
|
6272
|
+
damagedTables: health.damagedTables ?? [],
|
|
6273
|
+
damagedSearchIndexes: (health.searchIndexes ?? []).filter((index) => !index.ok).map(({ name, error }) => ({ name, ...error ? { error } : {} })),
|
|
6274
|
+
rows,
|
|
6275
|
+
explanation,
|
|
6276
|
+
inUse,
|
|
6277
|
+
timers,
|
|
6278
|
+
sqlite3: { version: sqlite3.version, usable: sqlite3.usable },
|
|
6279
|
+
next
|
|
6280
|
+
};
|
|
6281
|
+
}, "storeRecoveryCheck");
|
|
6282
|
+
var storeRecoveryRun = /* @__PURE__ */ __name(async (env, { command, version, note, timers: scheduled = activeTimers, copy }) => {
|
|
6283
|
+
const timers = scheduled() ?? [];
|
|
6284
|
+
if (timers.length > 0)
|
|
6285
|
+
throw new CliError("validation_error", `stop the timers first, they open the store: ${stopTimers(timers)}`, {
|
|
6286
|
+
reason: "store.in-use"
|
|
6287
|
+
});
|
|
6288
|
+
const recovery = await recoverStore({
|
|
6289
|
+
path: storePath(env),
|
|
6290
|
+
command,
|
|
6291
|
+
...version ? { version } : {},
|
|
6292
|
+
...note ? { note } : {},
|
|
6293
|
+
...copy ? { copy } : {}
|
|
6294
|
+
});
|
|
6295
|
+
const mail = recovery.mailToFetch.map(({ account, emails }) => `mail <profile of ${account}> sync --rescan # ${emails} emails`);
|
|
6296
|
+
const lostMail = recovery.lost.some(({ table }) => table === "emails") && mail.length === 0 ? ["mail <profile> sync --rescan # each mail profile"] : [];
|
|
6297
|
+
const { health, copyErrors, ...kept } = recovery;
|
|
6298
|
+
return {
|
|
6299
|
+
...kept,
|
|
6300
|
+
copyErrors: copyErrors.length,
|
|
6301
|
+
checkedOk: health.ok,
|
|
6302
|
+
next: [...mail, ...lostMail, "systemctl --user start <the timers stopped before>"]
|
|
6303
|
+
};
|
|
6304
|
+
}, "storeRecoveryRun");
|
|
6305
|
+
var recoveryNotes = /* @__PURE__ */ __name((answer) => {
|
|
6306
|
+
if ("keptAt" in answer) {
|
|
6307
|
+
const lost = answer.lost.map(({ table, before, read, kept }) => `${table}: ${kept} kept of ${before ?? "an uncountable number"}${read > kept ? `, ${read - kept} read but unusable` : ""}`);
|
|
6308
|
+
return [
|
|
6309
|
+
`recovered in ${answer.seconds.total} s; the damaged file is kept at ${answer.keptAt}`,
|
|
6310
|
+
...lost.length ? lost : ["no table lost a row"],
|
|
6311
|
+
...answer.dangling.map(({ table, parent, rows }) => `${rows} rows of ${table} point at ${parent} rows the store does not hold`),
|
|
6312
|
+
...answer.next.map((line) => `next: ${line}`)
|
|
6313
|
+
];
|
|
6314
|
+
}
|
|
6315
|
+
if (!answer.exists)
|
|
6316
|
+
return ["no store yet"];
|
|
6317
|
+
if (answer.ok)
|
|
6318
|
+
return [`the store is healthy (checked every page and search index in ${answer.seconds} s)`];
|
|
6319
|
+
const why = answer.explanation;
|
|
6320
|
+
return [
|
|
6321
|
+
...why ? [why.what, ...why.impact, why.externalUnaffected] : [],
|
|
6322
|
+
...answer.next.map((line) => `next: ${line}`)
|
|
6323
|
+
];
|
|
6324
|
+
}, "recoveryNotes");
|
|
6325
|
+
var storeRecoverCommand = /* @__PURE__ */ __name(({ command, version }) => {
|
|
6326
|
+
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() {
|
|
6327
|
+
const output = outputFor(this);
|
|
6328
|
+
const answer = await storeRecoveryCheck(environmentOf(this).env ?? process.env, command);
|
|
6329
|
+
renderAnswer(this, output, itemOf(snakeKeys(answer)));
|
|
6330
|
+
if (output.format === "pretty")
|
|
6331
|
+
for (const line of recoveryNotes(answer))
|
|
6332
|
+
output.renderer.note(line);
|
|
6333
|
+
});
|
|
6334
|
+
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() {
|
|
6335
|
+
const output = outputFor(this);
|
|
6336
|
+
const answer = await storeRecoveryRun(environmentOf(this).env ?? process.env, {
|
|
6337
|
+
command,
|
|
6338
|
+
...version ? { version } : {},
|
|
6339
|
+
note: /* @__PURE__ */ __name((text) => output.renderer.note(text), "note")
|
|
6340
|
+
});
|
|
6341
|
+
renderAnswer(this, output, itemOf(snakeKeys(answer)));
|
|
6342
|
+
if (output.format === "pretty")
|
|
6343
|
+
for (const line of recoveryNotes(answer))
|
|
6344
|
+
output.renderer.note(line);
|
|
6345
|
+
}));
|
|
6346
|
+
return recover;
|
|
6347
|
+
}, "storeRecoverCommand");
|
|
6348
|
+
|
|
6349
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.600.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_b9e89c8ee4e42a523b0faff8db1d3e1d/node_modules/@wirecat/cli-core/dist/cli/store-info.js
|
|
5889
6350
|
var pendingIfKnown = /* @__PURE__ */ __name((database) => database.prepare("SELECT 1 FROM pragma_table_info('messages') WHERE name = 'normalized_text'").get() ? pendingNormalization(database) : null, "pendingIfKnown");
|
|
5890
|
-
var bytesOf = /* @__PURE__ */ __name((path) =>
|
|
6351
|
+
var bytesOf = /* @__PURE__ */ __name((path) => existsSync4(path) ? statSync3(path).size : 0, "bytesOf");
|
|
5891
6352
|
var messageOf = /* @__PURE__ */ __name((error) => error instanceof Error ? error.message : String(error), "messageOf");
|
|
5892
6353
|
var contentsOf = /* @__PURE__ */ __name((database, version, writable) => version > 0 && writable ? {
|
|
5893
6354
|
rows: rowCounts(database),
|
|
@@ -5898,7 +6359,7 @@ var contentsOf = /* @__PURE__ */ __name((database, version, writable) => version
|
|
|
5898
6359
|
} : { rows: {}, pendingNormalization: null, wordIndex: null, stemIndex: null }, "contentsOf");
|
|
5899
6360
|
var storeInfo = /* @__PURE__ */ __name(async (env) => {
|
|
5900
6361
|
const path = storePath(env);
|
|
5901
|
-
if (!
|
|
6362
|
+
if (!existsSync4(path))
|
|
5902
6363
|
return snakeKeys({ path, exists: false, schema: compatibilityOf(void 0) });
|
|
5903
6364
|
let schema = compatibilityOf(void 0);
|
|
5904
6365
|
try {
|
|
@@ -5931,7 +6392,7 @@ var storeInfoCommand = /* @__PURE__ */ __name(() => annotate(new Command("info")
|
|
|
5931
6392
|
renderAnswer(this, outputFor(this), itemOf(answer));
|
|
5932
6393
|
}), "storeInfoCommand");
|
|
5933
6394
|
|
|
5934
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6395
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.600.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_b9e89c8ee4e42a523b0faff8db1d3e1d/node_modules/@wirecat/cli-core/dist/cli/messenger/password.js
|
|
5935
6396
|
var ENCRYPT_OPTION = [
|
|
5936
6397
|
"--encrypt",
|
|
5937
6398
|
"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"
|
|
@@ -5950,9 +6411,9 @@ var passwordOf = /* @__PURE__ */ __name(async (command, { twice }) => {
|
|
|
5950
6411
|
return password;
|
|
5951
6412
|
}, "passwordOf");
|
|
5952
6413
|
|
|
5953
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5954
|
-
import { existsSync as
|
|
5955
|
-
import { join } from "node:path";
|
|
6414
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.600.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_b9e89c8ee4e42a523b0faff8db1d3e1d/node_modules/@wirecat/cli-core/dist/replies/rules.js
|
|
6415
|
+
import { existsSync as existsSync5, readFileSync as readFileSync2 } from "node:fs";
|
|
6416
|
+
import { join as join2 } from "node:path";
|
|
5956
6417
|
var REPLY_ACTIONS = ["reply", "task"];
|
|
5957
6418
|
var REPLY_MODELS = ["fill-only", "may-reword"];
|
|
5958
6419
|
var REPLY_KINDS = ["dialog", "group"];
|
|
@@ -6038,7 +6499,7 @@ var defaultRule = /* @__PURE__ */ __name((id) => ({
|
|
|
6038
6499
|
reply: { template: "", asReply: true },
|
|
6039
6500
|
limits: { perChat: "1/1d", perPerson: "1/1d" }
|
|
6040
6501
|
}), "defaultRule");
|
|
6041
|
-
var repliesPathFor = /* @__PURE__ */ __name((app, profile, env = process.env) =>
|
|
6502
|
+
var repliesPathFor = /* @__PURE__ */ __name((app, profile, env = process.env) => join2(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).config, `${profile}.replies.json`), "repliesPathFor");
|
|
6042
6503
|
var EVERYONE = { reply: "all", allow: { people: [], chats: [] }, deny: { people: [], chats: [] } };
|
|
6043
6504
|
var outsideAudience = /* @__PURE__ */ __name((audience, person, chat) => {
|
|
6044
6505
|
if (person !== null && audience.deny.people.includes(person))
|
|
@@ -6068,11 +6529,11 @@ var readReplies = /* @__PURE__ */ __name((path, provider) => {
|
|
|
6068
6529
|
return parseReplies(readRepliesFile(path, provider), path, provider);
|
|
6069
6530
|
}, "readReplies");
|
|
6070
6531
|
var readRepliesFile = /* @__PURE__ */ __name((path, provider) => {
|
|
6071
|
-
if (!
|
|
6532
|
+
if (!existsSync5(path))
|
|
6072
6533
|
return { audience: structuredClone(EVERYONE), rules: [] };
|
|
6073
6534
|
let parsed;
|
|
6074
6535
|
try {
|
|
6075
|
-
parsed = JSON.parse(
|
|
6536
|
+
parsed = JSON.parse(readFileSync2(path, "utf8"));
|
|
6076
6537
|
} catch (error) {
|
|
6077
6538
|
throw broken(path, error instanceof Error ? error.message : String(error));
|
|
6078
6539
|
}
|
|
@@ -6121,9 +6582,9 @@ var problem = /* @__PURE__ */ __name((issue) => {
|
|
|
6121
6582
|
}, "problem");
|
|
6122
6583
|
var broken = /* @__PURE__ */ __name((path, why) => new CliError("configuration_error", `the reply rules ${path} cannot be read (${why}) \u2014 fix the file`), "broken");
|
|
6123
6584
|
|
|
6124
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6125
|
-
import { existsSync as
|
|
6126
|
-
import { join as
|
|
6585
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.600.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_b9e89c8ee4e42a523b0faff8db1d3e1d/node_modules/@wirecat/cli-core/dist/replies/state.js
|
|
6586
|
+
import { existsSync as existsSync6, readFileSync as readFileSync3 } from "node:fs";
|
|
6587
|
+
import { join as join3 } from "node:path";
|
|
6127
6588
|
var ANSWERED_KEPT = 1e3;
|
|
6128
6589
|
var times = record(string(), array(string()));
|
|
6129
6590
|
var stateFile = object({
|
|
@@ -6135,13 +6596,13 @@ var stateFile = object({
|
|
|
6135
6596
|
});
|
|
6136
6597
|
var emptyState = /* @__PURE__ */ __name(() => ({ paused: false, answered: [], sent: {} }), "emptyState");
|
|
6137
6598
|
var answeredKey = /* @__PURE__ */ __name((message) => `${message.chatId}:${message.id}`, "answeredKey");
|
|
6138
|
-
var repliesStatePathFor = /* @__PURE__ */ __name((app, profile, env = process.env) =>
|
|
6599
|
+
var repliesStatePathFor = /* @__PURE__ */ __name((app, profile, env = process.env) => join3(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, `${profile}.replies-state.json`), "repliesStatePathFor");
|
|
6139
6600
|
var readRepliesState = /* @__PURE__ */ __name((path) => {
|
|
6140
|
-
if (!
|
|
6601
|
+
if (!existsSync6(path))
|
|
6141
6602
|
return emptyState();
|
|
6142
6603
|
let parsed;
|
|
6143
6604
|
try {
|
|
6144
|
-
parsed = JSON.parse(
|
|
6605
|
+
parsed = JSON.parse(readFileSync3(path, "utf8"));
|
|
6145
6606
|
} catch (error) {
|
|
6146
6607
|
throw broken2(path, error instanceof Error ? error.message : String(error));
|
|
6147
6608
|
}
|
|
@@ -6174,7 +6635,7 @@ var recordReply = /* @__PURE__ */ __name((state, rule2, message, now) => {
|
|
|
6174
6635
|
}, "recordReply");
|
|
6175
6636
|
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");
|
|
6176
6637
|
|
|
6177
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6638
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.600.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_b9e89c8ee4e42a523b0faff8db1d3e1d/node_modules/@wirecat/cli-core/dist/replies/decide.js
|
|
6178
6639
|
var skip = /* @__PURE__ */ __name((why) => ({ skip: why }), "skip");
|
|
6179
6640
|
var decide = /* @__PURE__ */ __name((rule2, incoming, state, now) => {
|
|
6180
6641
|
const { message, chat, owner, sender } = incoming;
|
|
@@ -6280,7 +6741,7 @@ var filled = /* @__PURE__ */ __name((template2, senderName) => {
|
|
|
6280
6741
|
return template2.replaceAll("{firstName}", name.split(/\s+/)[0] ?? name).replaceAll("{name}", name);
|
|
6281
6742
|
}, "filled");
|
|
6282
6743
|
|
|
6283
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6744
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.600.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_b9e89c8ee4e42a523b0faff8db1d3e1d/node_modules/@wirecat/cli-core/dist/replies/template.js
|
|
6284
6745
|
var import_liquidjs = __toESM(require_liquid_node(), 1);
|
|
6285
6746
|
var TEMPLATE_LIMITS = {
|
|
6286
6747
|
parse: 32768,
|
|
@@ -6440,7 +6901,7 @@ var renderReplyTemplate = /* @__PURE__ */ __name(async (reply, input) => {
|
|
|
6440
6901
|
}
|
|
6441
6902
|
}, "renderReplyTemplate");
|
|
6442
6903
|
|
|
6443
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6904
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.600.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_b9e89c8ee4e42a523b0faff8db1d3e1d/node_modules/@wirecat/cli-core/dist/replies/dry-run.js
|
|
6444
6905
|
var DRY_RUN_DAYS = 7;
|
|
6445
6906
|
var PAGE = 500;
|
|
6446
6907
|
var dryRun = /* @__PURE__ */ __name(async (store, account, rules, { since, until = Date.now(), only, audience, render }) => {
|
|
@@ -6554,7 +7015,7 @@ var storedSince = /* @__PURE__ */ __name(async (store, account, chat, since) =>
|
|
|
6554
7015
|
}
|
|
6555
7016
|
}, "storedSince");
|
|
6556
7017
|
|
|
6557
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7018
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.600.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_b9e89c8ee4e42a523b0faff8db1d3e1d/node_modules/@wirecat/cli-core/dist/embeddings/keys.js
|
|
6558
7019
|
var endpointKeyName = /* @__PURE__ */ __name((baseUrl) => {
|
|
6559
7020
|
const host = new URL(baseUrl).host;
|
|
6560
7021
|
return ["openai", "anthropic"].includes(host) ? `endpoint:${host}` : host;
|
|
@@ -6585,7 +7046,7 @@ var embeddingKeys = /* @__PURE__ */ __name((app, env = process.env, keyring) =>
|
|
|
6585
7046
|
};
|
|
6586
7047
|
}, "embeddingKeys");
|
|
6587
7048
|
|
|
6588
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7049
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.600.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_b9e89c8ee4e42a523b0faff8db1d3e1d/node_modules/@wirecat/cli-core/dist/models/openai.js
|
|
6589
7050
|
var options = strictObject({
|
|
6590
7051
|
temperature: range(0, 2),
|
|
6591
7052
|
top_p: range(0, 1),
|
|
@@ -6599,7 +7060,7 @@ var openai = {
|
|
|
6599
7060
|
images: true,
|
|
6600
7061
|
baseUrl: "https://api.openai.com/v1",
|
|
6601
7062
|
validate: /* @__PURE__ */ __name((given) => checkedOptions("openai", options, given), "validate"),
|
|
6602
|
-
complete: /* @__PURE__ */ __name(
|
|
7063
|
+
complete: /* @__PURE__ */ __name((target, request, checked, apiKey, fetcher) => withTimeLimit(12e4, async (deadline) => {
|
|
6603
7064
|
const response = await fetcher(`${target.baseUrl.replace(/\/+$/, "")}/chat/completions`, {
|
|
6604
7065
|
method: "POST",
|
|
6605
7066
|
headers: { "Content-Type": "application/json", ...apiKey ? { Authorization: `Bearer ${apiKey}` } : {} },
|
|
@@ -6621,7 +7082,7 @@ var openai = {
|
|
|
6621
7082
|
],
|
|
6622
7083
|
...new URL(target.baseUrl).hostname === "api.openai.com" ? { max_completion_tokens: request.maxTokens } : { max_tokens: request.maxTokens }
|
|
6623
7084
|
}),
|
|
6624
|
-
signal:
|
|
7085
|
+
signal: deadline,
|
|
6625
7086
|
redirect: "error"
|
|
6626
7087
|
});
|
|
6627
7088
|
if (!response.ok)
|
|
@@ -6631,10 +7092,10 @@ var openai = {
|
|
|
6631
7092
|
if (choice?.finish_reason !== "stop" || typeof choice.message?.content !== "string" || !Number.isInteger(body.usage?.total_tokens) || (body.usage?.total_tokens ?? 0) < 1)
|
|
6632
7093
|
throw new Error("incomplete response");
|
|
6633
7094
|
return { text: choice.message.content, tokens: body.usage?.total_tokens };
|
|
6634
|
-
}, "complete")
|
|
7095
|
+
}), "complete")
|
|
6635
7096
|
};
|
|
6636
7097
|
|
|
6637
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7098
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.600.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_b9e89c8ee4e42a523b0faff8db1d3e1d/node_modules/@wirecat/cli-core/dist/models/index.js
|
|
6638
7099
|
var modelGateway = /* @__PURE__ */ __name((deps) => ({
|
|
6639
7100
|
complete: /* @__PURE__ */ __name(async (request) => {
|
|
6640
7101
|
if (deps.signal?.aborted)
|
|
@@ -6649,7 +7110,7 @@ var modelGateway = /* @__PURE__ */ __name((deps) => ({
|
|
|
6649
7110
|
if (!adapter && target.provider === "openai")
|
|
6650
7111
|
adapter = openai;
|
|
6651
7112
|
if (!adapter && target.provider === "anthropic")
|
|
6652
|
-
adapter = (await import("./anthropic-
|
|
7113
|
+
adapter = (await import("./anthropic-5VIKYINO.js")).anthropic;
|
|
6653
7114
|
if (!adapter)
|
|
6654
7115
|
throw new CliError("validation_error", `no model adapter for ${target.provider}`);
|
|
6655
7116
|
if (request.images !== void 0 && adapter.images !== true)
|
|
@@ -6690,19 +7151,19 @@ var modelGateway = /* @__PURE__ */ __name((deps) => ({
|
|
|
6690
7151
|
}, "complete")
|
|
6691
7152
|
}), "modelGateway");
|
|
6692
7153
|
|
|
6693
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6694
|
-
import { existsSync as
|
|
6695
|
-
import { join as
|
|
7154
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.600.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_b9e89c8ee4e42a523b0faff8db1d3e1d/node_modules/@wirecat/cli-core/dist/replies/consents.js
|
|
7155
|
+
import { existsSync as existsSync7, readFileSync as readFileSync4 } from "node:fs";
|
|
7156
|
+
import { join as join4 } from "node:path";
|
|
6696
7157
|
var shape = strictObject({
|
|
6697
7158
|
provider: nullable(pipe(string(), minLength(1))),
|
|
6698
7159
|
deniedChats: array(pipe(string(), minLength(1)))
|
|
6699
7160
|
});
|
|
6700
|
-
var replyConsentPathFor = /* @__PURE__ */ __name((app, profile, env = process.env) =>
|
|
7161
|
+
var replyConsentPathFor = /* @__PURE__ */ __name((app, profile, env = process.env) => join4(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).config, `${profile}.replies-consents.json`), "replyConsentPathFor");
|
|
6701
7162
|
var readReplyConsent = /* @__PURE__ */ __name((path) => {
|
|
6702
|
-
if (!
|
|
7163
|
+
if (!existsSync7(path))
|
|
6703
7164
|
return { provider: null, deniedChats: [] };
|
|
6704
7165
|
try {
|
|
6705
|
-
return parse(shape, JSON.parse(
|
|
7166
|
+
return parse(shape, JSON.parse(readFileSync4(path, "utf8")));
|
|
6706
7167
|
} catch {
|
|
6707
7168
|
throw new CliError("configuration_error", "reply model consent is invalid; fix its file before granting consent");
|
|
6708
7169
|
}
|
|
@@ -6715,7 +7176,7 @@ var mayModelReply = /* @__PURE__ */ __name((path, provider, chat) => {
|
|
|
6715
7176
|
return consent.provider === provider && !consent.deniedChats.includes(chat);
|
|
6716
7177
|
}, "mayModelReply");
|
|
6717
7178
|
|
|
6718
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7179
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.600.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_b9e89c8ee4e42a523b0faff8db1d3e1d/node_modules/@wirecat/cli-core/dist/replies/rendering.js
|
|
6719
7180
|
var replyRenderer = /* @__PURE__ */ __name((app, profile, settings, env, warn, options2 = {
|
|
6720
7181
|
ai: true
|
|
6721
7182
|
}) => async (rule2, message, chat, now) => {
|
|
@@ -6762,7 +7223,7 @@ var replyRenderer = /* @__PURE__ */ __name((app, profile, settings, env, warn, o
|
|
|
6762
7223
|
return result2;
|
|
6763
7224
|
}, "replyRenderer");
|
|
6764
7225
|
|
|
6765
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7226
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.600.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_b9e89c8ee4e42a523b0faff8db1d3e1d/node_modules/@wirecat/cli-core/dist/replies/serve.js
|
|
6766
7227
|
var NOT_ALLOWED = "replies.send is not allow";
|
|
6767
7228
|
var NO_RULES = "no rules";
|
|
6768
7229
|
var ONLY_TASK = "opened a task, sent nothing";
|
|
@@ -6855,7 +7316,7 @@ var replyTo = /* @__PURE__ */ __name(async (deps, message) => {
|
|
|
6855
7316
|
return { skip: why };
|
|
6856
7317
|
}, "replyTo");
|
|
6857
7318
|
|
|
6858
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7319
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.600.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_b9e89c8ee4e42a523b0faff8db1d3e1d/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-catch-up.js
|
|
6859
7320
|
var START_SYNC_DELAY_MS = 3e4;
|
|
6860
7321
|
var START_SYNC_BUDGET_MS = 5 * 6e4;
|
|
6861
7322
|
var START_SYNC_WINDOW_MS = 7 * 864e5;
|
|
@@ -6866,8 +7327,8 @@ var startSync = /* @__PURE__ */ __name(({ chats, newestHeld, fetch: fetch2, note
|
|
|
6866
7327
|
let pass = Promise.resolve();
|
|
6867
7328
|
let started = false;
|
|
6868
7329
|
let done;
|
|
6869
|
-
const run = /* @__PURE__ */ __name(
|
|
6870
|
-
|
|
7330
|
+
const run = /* @__PURE__ */ __name(() => withTimeLimit(budgetMs, (deadline) => catchUp(AbortSignal.any([controller.signal, deadline]))), "run");
|
|
7331
|
+
const catchUp = /* @__PURE__ */ __name(async (stop) => {
|
|
6871
7332
|
const floor = now() - windowMs;
|
|
6872
7333
|
const moved = [];
|
|
6873
7334
|
for (const chat of await chats(stop)) {
|
|
@@ -6908,7 +7369,7 @@ var startSync = /* @__PURE__ */ __name(({ chats, newestHeld, fetch: fetch2, note
|
|
|
6908
7369
|
code: "start_sync",
|
|
6909
7370
|
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` : "")
|
|
6910
7371
|
});
|
|
6911
|
-
}, "
|
|
7372
|
+
}, "catchUp");
|
|
6912
7373
|
return {
|
|
6913
7374
|
start: /* @__PURE__ */ __name(() => {
|
|
6914
7375
|
if (started || controller.signal.aborted)
|
|
@@ -6932,7 +7393,7 @@ var startSync = /* @__PURE__ */ __name(({ chats, newestHeld, fetch: fetch2, note
|
|
|
6932
7393
|
};
|
|
6933
7394
|
}, "startSync");
|
|
6934
7395
|
|
|
6935
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7396
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.600.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_b9e89c8ee4e42a523b0faff8db1d3e1d/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-members.js
|
|
6936
7397
|
var FIRST_FETCH_MS = 6e4;
|
|
6937
7398
|
var DAY_MS = 864e5;
|
|
6938
7399
|
var memberFetches = /* @__PURE__ */ __name(({ withStore, fetch: fetch2, warn, firstMs = FIRST_FETCH_MS, everyMs = DAY_MS }) => {
|
|
@@ -6986,7 +7447,7 @@ var memberFetches = /* @__PURE__ */ __name(({ withStore, fetch: fetch2, warn, fi
|
|
|
6986
7447
|
};
|
|
6987
7448
|
}, "memberFetches");
|
|
6988
7449
|
|
|
6989
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7450
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.600.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_b9e89c8ee4e42a523b0faff8db1d3e1d/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-notice.js
|
|
6990
7451
|
var record2 = /* @__PURE__ */ __name((context, app, severity, attributes) => recordLogFor(context.streams.diagnostic, app, { command: currentRun().command || "serve" })[severity](attributes), "record");
|
|
6991
7452
|
var noticeFor = /* @__PURE__ */ __name((context, app, severity = "warn") => ({ text, ...attributes }) => {
|
|
6992
7453
|
if (context.format === "pretty") {
|
|
@@ -7019,7 +7480,7 @@ var recordDiagnostics = /* @__PURE__ */ __name((context, app) => {
|
|
|
7019
7480
|
return context;
|
|
7020
7481
|
}, "recordDiagnostics");
|
|
7021
7482
|
|
|
7022
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7483
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.600.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_b9e89c8ee4e42a523b0faff8db1d3e1d/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-stems.js
|
|
7023
7484
|
var STEMS_EVERY_MS = 3e4;
|
|
7024
7485
|
var STEMS_SLICE_MS = 2e3;
|
|
7025
7486
|
var stemFills = /* @__PURE__ */ __name(({ withStore, warn, everyMs = STEMS_EVERY_MS, sliceMs = STEMS_SLICE_MS }) => {
|
|
@@ -7059,7 +7520,7 @@ var stemFills = /* @__PURE__ */ __name(({ withStore, warn, everyMs = STEMS_EVERY
|
|
|
7059
7520
|
};
|
|
7060
7521
|
}, "stemFills");
|
|
7061
7522
|
|
|
7062
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7523
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.600.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_b9e89c8ee4e42a523b0faff8db1d3e1d/node_modules/@wirecat/cli-core/dist/cli/messenger/message-items.js
|
|
7063
7524
|
var defined = /* @__PURE__ */ __name((value) => Object.fromEntries(Object.entries(value).filter(([, one]) => one !== void 0)), "defined");
|
|
7064
7525
|
var attachmentItem = /* @__PURE__ */ __name((attachment) => defined({
|
|
7065
7526
|
kind: attachment.kind,
|
|
@@ -7154,7 +7615,7 @@ var viewOf = /* @__PURE__ */ __name((context, messenger) => ({
|
|
|
7154
7615
|
locale: messenger.app.locale
|
|
7155
7616
|
}), "viewOf");
|
|
7156
7617
|
|
|
7157
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7618
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.600.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_b9e89c8ee4e42a523b0faff8db1d3e1d/node_modules/@wirecat/cli-core/dist/cli/messenger/watch-answers.js
|
|
7158
7619
|
var observed = /* @__PURE__ */ __name((value) => ({
|
|
7159
7620
|
value: value.value,
|
|
7160
7621
|
observed_at: value.observedAt,
|
|
@@ -7221,7 +7682,7 @@ var watchEventItem = /* @__PURE__ */ __name((value, account) => {
|
|
|
7221
7682
|
}
|
|
7222
7683
|
}, "watchEventItem");
|
|
7223
7684
|
|
|
7224
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7685
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.600.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_b9e89c8ee4e42a523b0faff8db1d3e1d/node_modules/@wirecat/cli-core/dist/cli/messenger/watch-command.js
|
|
7225
7686
|
var watchCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("watch"), {
|
|
7226
7687
|
output: { entity: "watch_item" },
|
|
7227
7688
|
effects: REMOTE_READ,
|
|
@@ -7376,7 +7837,7 @@ var describe = /* @__PURE__ */ __name((event, render) => {
|
|
|
7376
7837
|
}
|
|
7377
7838
|
}, "describe");
|
|
7378
7839
|
|
|
7379
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7840
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.600.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_b9e89c8ee4e42a523b0faff8db1d3e1d/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-command.js
|
|
7380
7841
|
var serveCommand = /* @__PURE__ */ __name((messenger) => {
|
|
7381
7842
|
const command = annotate(new Command("serve"), {
|
|
7382
7843
|
output: { entity: "serve_summary" },
|
|
@@ -7640,8 +8101,8 @@ var tasking = /* @__PURE__ */ __name((context, warn) => {
|
|
|
7640
8101
|
};
|
|
7641
8102
|
}, "tasking");
|
|
7642
8103
|
|
|
7643
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7644
|
-
import { existsSync as
|
|
8104
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.600.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_b9e89c8ee4e42a523b0faff8db1d3e1d/node_modules/@wirecat/cli-core/dist/cli/messenger/store-tables-command.js
|
|
8105
|
+
import { existsSync as existsSync8 } from "node:fs";
|
|
7645
8106
|
var PATH = "store tables list";
|
|
7646
8107
|
var STORE_TABLES_QUERY = {
|
|
7647
8108
|
entity: "store_table",
|
|
@@ -7670,7 +8131,7 @@ var storeTablesCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
7670
8131
|
const filter = filterOf(words);
|
|
7671
8132
|
const { full } = this.optsWithGlobals();
|
|
7672
8133
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
7673
|
-
if (!
|
|
8134
|
+
if (!existsSync8(path))
|
|
7674
8135
|
throw new CliError("not_found", `no store at ${path}`);
|
|
7675
8136
|
const items = await readStoreTables(path, { filter, sizes: full === true });
|
|
7676
8137
|
renderAnswer(this, outputFor(this), listOf(PATH, {
|
|
@@ -7683,7 +8144,7 @@ var storeTablesCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
7683
8144
|
return tables;
|
|
7684
8145
|
}, "storeTablesCommand");
|
|
7685
8146
|
|
|
7686
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
8147
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.600.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_b9e89c8ee4e42a523b0faff8db1d3e1d/node_modules/@wirecat/cli-core/dist/cli/messenger/store-maintenance-command.js
|
|
7687
8148
|
var SEARCH_INDEXES = ["messages_fts", "chats_fts", "identities_fts"];
|
|
7688
8149
|
var WORD_INDEX = "message_words";
|
|
7689
8150
|
var schemaOf = /* @__PURE__ */ __name((database) => {
|
|
@@ -7692,7 +8153,7 @@ var schemaOf = /* @__PURE__ */ __name((database) => {
|
|
|
7692
8153
|
}, "schemaOf");
|
|
7693
8154
|
var count2 = /* @__PURE__ */ __name((database, table) => Number(database.prepare(`SELECT count(*) AS n FROM ${table}`).get()?.n ?? 0), "count");
|
|
7694
8155
|
var pendingIfKnown2 = /* @__PURE__ */ __name((database) => database.prepare("SELECT 1 FROM pragma_table_info('messages') WHERE name = 'normalized_text'").get() ? pendingNormalization(database) : null, "pendingIfKnown");
|
|
7695
|
-
var bytesOf2 = /* @__PURE__ */ __name((path) =>
|
|
8156
|
+
var bytesOf2 = /* @__PURE__ */ __name((path) => existsSync9(path) ? statSync4(path).size : 0, "bytesOf");
|
|
7696
8157
|
var reading = /* @__PURE__ */ __name(async (path, read) => {
|
|
7697
8158
|
const database = await openCache(path);
|
|
7698
8159
|
try {
|
|
@@ -7709,10 +8170,22 @@ var readingOnly = /* @__PURE__ */ __name(async (path, read) => {
|
|
|
7709
8170
|
database.close();
|
|
7710
8171
|
}
|
|
7711
8172
|
}, "readingOnly");
|
|
7712
|
-
var storeSummary = /* @__PURE__ */ __name(async (env) => {
|
|
8173
|
+
var storeSummary = /* @__PURE__ */ __name(async (env, { deep = false, command } = {}) => {
|
|
7713
8174
|
const path = storePath(env);
|
|
7714
|
-
if (!
|
|
8175
|
+
if (!existsSync9(path))
|
|
7715
8176
|
return { path, exists: false };
|
|
8177
|
+
const checked = await storeHealth(path, { deep });
|
|
8178
|
+
const health = {
|
|
8179
|
+
checked: checked.checked,
|
|
8180
|
+
covers: deep ? "every page and every search index" : QUICK_HEALTH_CHECKS,
|
|
8181
|
+
ok: checked.ok,
|
|
8182
|
+
ms: checked.ms,
|
|
8183
|
+
...checked.problems ? { problems: checked.problems } : {},
|
|
8184
|
+
...checked.damagedTables?.length ? { damagedTables: checked.damagedTables } : {},
|
|
8185
|
+
...checked.searchIndexes?.some((index) => !index.ok) ? { damagedSearchIndexes: checked.searchIndexes.filter((index) => !index.ok).map((index) => index.name) } : {}
|
|
8186
|
+
};
|
|
8187
|
+
const damage = command ? explainDamage(checked, command) : null;
|
|
8188
|
+
const healthOf = { health, ...damage ? { damage } : {} };
|
|
7716
8189
|
try {
|
|
7717
8190
|
return await reading(path, (database) => {
|
|
7718
8191
|
const { version, writable } = schemaOf(database);
|
|
@@ -7722,11 +8195,12 @@ var storeSummary = /* @__PURE__ */ __name(async (env) => {
|
|
|
7722
8195
|
schema: version,
|
|
7723
8196
|
speaks: SPEAKS,
|
|
7724
8197
|
writable,
|
|
7725
|
-
...version > 0 ? { chats: count2(database, "chats"), messages: count2(database, "messages") } : {}
|
|
8198
|
+
...version > 0 ? { chats: count2(database, "chats"), messages: count2(database, "messages") } : {},
|
|
8199
|
+
...healthOf
|
|
7726
8200
|
};
|
|
7727
8201
|
});
|
|
7728
8202
|
} catch (error) {
|
|
7729
|
-
return { path, exists: true, error: messageOf2(error) };
|
|
8203
|
+
return { path, exists: true, error: messageOf2(error), ...healthOf };
|
|
7730
8204
|
}
|
|
7731
8205
|
}, "storeSummary");
|
|
7732
8206
|
var result = /* @__PURE__ */ __name((command, value, next = []) => renderAnswer(command, outputFor(command), itemOf(snakeKeys(value), { next })), "result");
|
|
@@ -7741,7 +8215,8 @@ var storeMaintenanceCommands = /* @__PURE__ */ __name((messenger) => [
|
|
|
7741
8215
|
repairCommand(messenger),
|
|
7742
8216
|
resetCommand(messenger),
|
|
7743
8217
|
copiesCommand(),
|
|
7744
|
-
storeTablesCommand(messenger)
|
|
8218
|
+
storeTablesCommand(messenger),
|
|
8219
|
+
storeRecoverCommand({ command: messenger.app.command, version: messenger.app.version })
|
|
7745
8220
|
], "storeMaintenanceCommands");
|
|
7746
8221
|
var refuseWhileServing = /* @__PURE__ */ __name((command, messenger) => {
|
|
7747
8222
|
const serving = servingProfiles(messenger.app, environmentOf(command).env ?? process.env);
|
|
@@ -7753,7 +8228,7 @@ var repairCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("
|
|
|
7753
8228
|
const { renderer, format } = outputFor(this);
|
|
7754
8229
|
const { dryRun: dryRun2 } = this.opts();
|
|
7755
8230
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
7756
|
-
if (!
|
|
8231
|
+
if (!existsSync9(path)) {
|
|
7757
8232
|
result(this, { path, exists: false });
|
|
7758
8233
|
return;
|
|
7759
8234
|
}
|
|
@@ -7793,7 +8268,7 @@ var notesOf = /* @__PURE__ */ __name((report, command) => {
|
|
|
7793
8268
|
}, "notesOf");
|
|
7794
8269
|
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) {
|
|
7795
8270
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
7796
|
-
if (!
|
|
8271
|
+
if (!existsSync9(path))
|
|
7797
8272
|
throw new CliError("not_found", `no store at ${path}`);
|
|
7798
8273
|
const deleted = await reading(path, (database) => deleteCopy(database, name));
|
|
7799
8274
|
result(this, { path, deleted });
|
|
@@ -7801,7 +8276,7 @@ var copiesCommand = /* @__PURE__ */ __name(() => new Command("copies").descripti
|
|
|
7801
8276
|
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() {
|
|
7802
8277
|
const { renderer } = outputFor(this);
|
|
7803
8278
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
7804
|
-
if (!
|
|
8279
|
+
if (!existsSync9(path)) {
|
|
7805
8280
|
result(this, { path, exists: false, ok: true });
|
|
7806
8281
|
return;
|
|
7807
8282
|
}
|
|
@@ -7864,7 +8339,7 @@ var inspect = /* @__PURE__ */ __name((path) => reading(path, (database) => {
|
|
|
7864
8339
|
...schema.version > 0 ? [["attachment_words", indexIntegrity(database, "attachment_words", 0)]] : []
|
|
7865
8340
|
]);
|
|
7866
8341
|
const size = bytesOf2(path) + bytesOf2(`${path}-wal`);
|
|
7867
|
-
const { bavail, bsize } =
|
|
8342
|
+
const { bavail, bsize } = statfsSync2(dirname2(path));
|
|
7868
8343
|
const free = Number(bavail) * Number(bsize);
|
|
7869
8344
|
const behind = schema.version > 0 ? chatsBehind(database) : [];
|
|
7870
8345
|
const vectorIndexes = schema.version >= 34 ? vectorIndexCounts(database) : [];
|
|
@@ -7952,14 +8427,18 @@ var chatsBehind = /* @__PURE__ */ __name((database) => database.prepare(`SELECT
|
|
|
7952
8427
|
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() {
|
|
7953
8428
|
const { renderer } = outputFor(this);
|
|
7954
8429
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
7955
|
-
if (!
|
|
8430
|
+
if (!existsSync9(path)) {
|
|
7956
8431
|
result(this, { path, exists: false });
|
|
7957
8432
|
renderer.note(`no store yet \u2014 the first \`${messenger.app.command}\` command that reads a chat creates it`);
|
|
7958
8433
|
return;
|
|
7959
8434
|
}
|
|
7960
8435
|
const answer = await reading(path, (database) => {
|
|
7961
8436
|
const from = schemaOf(database).version;
|
|
7962
|
-
migrate(database, {
|
|
8437
|
+
migrate(database, {
|
|
8438
|
+
command: messenger.app.command,
|
|
8439
|
+
version: messenger.app.version,
|
|
8440
|
+
rollback: { store: path, warn: /* @__PURE__ */ __name((line) => renderer.warn(line), "warn") }
|
|
8441
|
+
});
|
|
7963
8442
|
const { normalized, indexed, terms } = buildWordIndex(database, (note) => renderer.note(note));
|
|
7964
8443
|
const stemmed = buildStems(database, (note) => renderer.note(note));
|
|
7965
8444
|
const notes = buildNoteIndex(database, (note) => renderer.note(note));
|
|
@@ -8012,7 +8491,7 @@ var buildNoteIndex = /* @__PURE__ */ __name((database, note, { reset = false } =
|
|
|
8012
8491
|
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() {
|
|
8013
8492
|
const { renderer } = outputFor(this);
|
|
8014
8493
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8015
|
-
if (!
|
|
8494
|
+
if (!existsSync9(path)) {
|
|
8016
8495
|
result(this, { path, exists: false });
|
|
8017
8496
|
return;
|
|
8018
8497
|
}
|
|
@@ -8041,11 +8520,11 @@ var reindexCommand = /* @__PURE__ */ __name((messenger) => destroysNothing(annot
|
|
|
8041
8520
|
result(this, answer);
|
|
8042
8521
|
}), "reindexCommand");
|
|
8043
8522
|
var vacuumInto = /* @__PURE__ */ __name(async (path, target) => {
|
|
8044
|
-
|
|
8523
|
+
writeFileSync2(target, "", { flag: "wx", mode: 384 });
|
|
8045
8524
|
try {
|
|
8046
8525
|
await reading(path, (database) => database.prepare("VACUUM INTO ?").run(target));
|
|
8047
8526
|
} catch (error) {
|
|
8048
|
-
|
|
8527
|
+
rmSync3(target, { force: true });
|
|
8049
8528
|
throw error;
|
|
8050
8529
|
}
|
|
8051
8530
|
}, "vacuumInto");
|
|
@@ -8054,9 +8533,9 @@ var backupCommand = /* @__PURE__ */ __name(() => destroysNothing(annotate(new Co
|
|
|
8054
8533
|
const { encrypt } = this.opts();
|
|
8055
8534
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8056
8535
|
const target = resolve(file2);
|
|
8057
|
-
if (!
|
|
8536
|
+
if (!existsSync9(path))
|
|
8058
8537
|
throw new CliError("not_found", `no store at ${path} to back up`);
|
|
8059
|
-
if (
|
|
8538
|
+
if (existsSync9(target))
|
|
8060
8539
|
throw new CliError("validation_error", `${target} exists \u2014 a backup never overwrites a file`);
|
|
8061
8540
|
const password = encrypt ? await passwordOf(this, { twice: true }) : void 0;
|
|
8062
8541
|
const copyAt = password === void 0 ? target : `${path}.backup-${process.pid}`;
|
|
@@ -8078,67 +8557,69 @@ var backupCommand = /* @__PURE__ */ __name(() => destroysNothing(annotate(new Co
|
|
|
8078
8557
|
});
|
|
8079
8558
|
} catch (error) {
|
|
8080
8559
|
if (password === void 0)
|
|
8081
|
-
|
|
8560
|
+
rmSync3(target, { force: true });
|
|
8082
8561
|
throw error;
|
|
8083
8562
|
} finally {
|
|
8084
8563
|
if (password !== void 0)
|
|
8085
|
-
|
|
8564
|
+
rmSync3(copyAt, { force: true });
|
|
8086
8565
|
}
|
|
8087
8566
|
}), "backupCommand");
|
|
8088
8567
|
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) {
|
|
8089
8568
|
const { output } = this.opts();
|
|
8090
8569
|
const from = resolve(file2);
|
|
8091
8570
|
const to = resolve(output);
|
|
8092
|
-
if (!
|
|
8571
|
+
if (!existsSync9(from))
|
|
8093
8572
|
throw new CliError("not_found", `no file at ${from}`);
|
|
8094
8573
|
if (!isSealed(from))
|
|
8095
8574
|
throw new CliError("validation_error", `${from} was not written with --encrypt`);
|
|
8096
|
-
if (
|
|
8575
|
+
if (existsSync9(to))
|
|
8097
8576
|
throw new CliError("validation_error", `${to} exists \u2014 never overwritten`);
|
|
8098
8577
|
await unsealFile(from, to, await passwordOf(this, { twice: false }));
|
|
8099
8578
|
result(this, { path: to, from, bytes: bytesOf2(to) });
|
|
8100
8579
|
}), "decryptCommand");
|
|
8101
|
-
var restoreCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("restore"), { output: { entity: "store_restore" }, effects: LOCAL_WRITE }).summary("restore a backup
|
|
8580
|
+
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) {
|
|
8102
8581
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8103
8582
|
const given = resolve(file2);
|
|
8104
|
-
if (!
|
|
8583
|
+
if (!existsSync9(given))
|
|
8105
8584
|
throw new CliError("not_found", `no file at ${given}`);
|
|
8106
8585
|
refuseWhileServing(this, messenger);
|
|
8107
8586
|
if (!isSealed(given))
|
|
8108
8587
|
return restoreFrom(this, messenger, given, given);
|
|
8109
8588
|
const opened = `${path}.unsealing-${process.pid}`;
|
|
8110
|
-
mkdirSync(
|
|
8589
|
+
mkdirSync(dirname2(path), { recursive: true, mode: 448 });
|
|
8111
8590
|
try {
|
|
8112
8591
|
await unsealFile(given, opened, await passwordOf(this, { twice: false }));
|
|
8113
8592
|
await restoreFrom(this, messenger, opened, given);
|
|
8114
8593
|
} finally {
|
|
8115
|
-
|
|
8594
|
+
rmSync3(opened, { force: true });
|
|
8116
8595
|
}
|
|
8117
8596
|
}), "restoreCommand");
|
|
8118
8597
|
var restoreFrom = /* @__PURE__ */ __name(async (command, messenger, backup, given) => {
|
|
8119
8598
|
const { renderer } = outputFor(command);
|
|
8120
8599
|
const path = storePath(environmentOf(command).env ?? process.env);
|
|
8121
|
-
if (
|
|
8600
|
+
if (existsSync9(path) && realpathSync2(backup) === realpathSync2(path)) {
|
|
8122
8601
|
throw new CliError("validation_error", `${backup} is the store itself`);
|
|
8123
8602
|
}
|
|
8603
|
+
if (await isRollbackCopy(backup))
|
|
8604
|
+
return rollBackFrom(command, messenger, backup);
|
|
8124
8605
|
const schema = await backupSchema(backup);
|
|
8125
8606
|
const stamp = stampNow();
|
|
8126
|
-
const kept =
|
|
8607
|
+
const kept = existsSync9(path) ? `${path}.before-restore-${stamp}` : null;
|
|
8127
8608
|
if (kept) {
|
|
8128
8609
|
const waitMs = environmentOf(command).storeLockWaitMs;
|
|
8129
8610
|
await quiesce(path, messenger, "restore", (message) => renderer.warn(message), waitMs);
|
|
8130
8611
|
} else
|
|
8131
|
-
mkdirSync(
|
|
8612
|
+
mkdirSync(dirname2(path), { recursive: true, mode: 448 });
|
|
8132
8613
|
const incoming = `${path}.restoring-${stamp}`;
|
|
8133
8614
|
copyFileSync(backup, incoming, constants.COPYFILE_EXCL);
|
|
8134
8615
|
chmodSync(incoming, 384);
|
|
8135
8616
|
if (kept) {
|
|
8136
|
-
|
|
8617
|
+
renameSync3(path, kept);
|
|
8137
8618
|
for (const suffix of ["-wal", "-shm"])
|
|
8138
|
-
if (
|
|
8139
|
-
|
|
8619
|
+
if (existsSync9(`${path}${suffix}`))
|
|
8620
|
+
renameSync3(`${path}${suffix}`, `${kept}${suffix}`);
|
|
8140
8621
|
}
|
|
8141
|
-
|
|
8622
|
+
renameSync3(incoming, path);
|
|
8142
8623
|
result(command, { path, restoredFrom: given, keptAt: kept, schema: schema.version });
|
|
8143
8624
|
if (kept)
|
|
8144
8625
|
renderer.note(`the store it replaced is kept at ${kept}`);
|
|
@@ -8147,6 +8628,43 @@ var restoreFrom = /* @__PURE__ */ __name(async (command, messenger, backup, give
|
|
|
8147
8628
|
renderer.note(`the backup is behind this build; the next command migrates it \u2014 \`${lineOf(command, "store migrate")}\` now`);
|
|
8148
8629
|
}
|
|
8149
8630
|
}, "restoreFrom");
|
|
8631
|
+
var isRollbackCopy = /* @__PURE__ */ __name(async (file2) => {
|
|
8632
|
+
try {
|
|
8633
|
+
return await readingOnly(file2, (database) => database.prepare("SELECT 1 FROM sqlite_master WHERE name = 'rollback_meta'").get() !== void 0);
|
|
8634
|
+
} catch {
|
|
8635
|
+
return false;
|
|
8636
|
+
}
|
|
8637
|
+
}, "isRollbackCopy");
|
|
8638
|
+
var rollBackFrom = /* @__PURE__ */ __name(async (command, messenger, copy) => {
|
|
8639
|
+
const { renderer } = outputFor(command);
|
|
8640
|
+
const path = storePath(environmentOf(command).env ?? process.env);
|
|
8641
|
+
if (!existsSync9(path))
|
|
8642
|
+
throw new CliError("not_found", `no store at ${path} to roll back`);
|
|
8643
|
+
const waitMs = environmentOf(command).storeLockWaitMs;
|
|
8644
|
+
await quiesce(path, messenger, "restore", (message) => renderer.warn(message), waitMs);
|
|
8645
|
+
const { database } = await openSqlite(path);
|
|
8646
|
+
let rolled;
|
|
8647
|
+
try {
|
|
8648
|
+
rolled = rollBack(database, copy);
|
|
8649
|
+
} finally {
|
|
8650
|
+
database.close();
|
|
8651
|
+
}
|
|
8652
|
+
result(command, {
|
|
8653
|
+
path,
|
|
8654
|
+
restoredFrom: copy,
|
|
8655
|
+
rolledBack: true,
|
|
8656
|
+
schema: rolled.from,
|
|
8657
|
+
was: rolled.was,
|
|
8658
|
+
tables: rolled.restored,
|
|
8659
|
+
rebuilt: rolled.rebuilt,
|
|
8660
|
+
foreignKeyViolations: rolled.foreignKeyViolations
|
|
8661
|
+
});
|
|
8662
|
+
const taken = new Date(rolled.createdAt).toISOString();
|
|
8663
|
+
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`);
|
|
8664
|
+
renderer.note("open it with the older tool and run its `store rebuild`: the search indexes are behind the tables");
|
|
8665
|
+
renderer.note(`a tool that speaks schema ${rolled.to} or later migrates it again on its next run`);
|
|
8666
|
+
renderer.note("restart every serve and mcp of either CLI that was running, so they read the restored store");
|
|
8667
|
+
}, "rollBackFrom");
|
|
8150
8668
|
var backupSchema = /* @__PURE__ */ __name(async (backup) => {
|
|
8151
8669
|
let read;
|
|
8152
8670
|
try {
|
|
@@ -8170,7 +8688,7 @@ var backupSchema = /* @__PURE__ */ __name(async (backup) => {
|
|
|
8170
8688
|
var STORE_LOCK_WAIT_MS = 1e3;
|
|
8171
8689
|
var quiesce = /* @__PURE__ */ __name(async (path, messenger, then, warn, waitMs = STORE_LOCK_WAIT_MS) => {
|
|
8172
8690
|
const { command } = messenger.app;
|
|
8173
|
-
const files = [path, `${path}-wal`, `${path}-shm`].filter((file2) =>
|
|
8691
|
+
const files = [path, `${path}-wal`, `${path}-shm`].filter((file2) => existsSync9(file2)).map((file2) => realpathSync2(file2));
|
|
8174
8692
|
const holders = holdersOf(files);
|
|
8175
8693
|
if (holders === void 0) {
|
|
8176
8694
|
warn(`this system cannot say which processes have the store open \u2014 restart every running serve and mcp after this`);
|
|
@@ -8196,7 +8714,7 @@ var resetCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("r
|
|
|
8196
8714
|
const { command } = messenger.app;
|
|
8197
8715
|
const env = environmentOf(this).env ?? process.env;
|
|
8198
8716
|
const path = storePath(env);
|
|
8199
|
-
if (!
|
|
8717
|
+
if (!existsSync9(path)) {
|
|
8200
8718
|
result(this, { path, exists: false, reset: false });
|
|
8201
8719
|
renderer.note(`no store at ${path} \u2014 nothing to reset; the first \`${command}\` command that reads a chat creates it`);
|
|
8202
8720
|
return;
|
|
@@ -8232,17 +8750,17 @@ var resetCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("r
|
|
|
8232
8750
|
});
|
|
8233
8751
|
renderer.note(`backed the store up to ${backup}`);
|
|
8234
8752
|
}
|
|
8235
|
-
for (const suffix of
|
|
8236
|
-
|
|
8753
|
+
for (const suffix of STORE_PARTS2)
|
|
8754
|
+
rmSync3(`${path}${suffix}`, { force: true });
|
|
8237
8755
|
await (await openStore({ path, command })).close();
|
|
8238
8756
|
const schema = await reading(path, (database) => schemaOf(database).version);
|
|
8239
8757
|
result(this, { path, exists: true, reset: true, backup, backedUp, schema });
|
|
8240
8758
|
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`);
|
|
8241
8759
|
}), "resetCommand");
|
|
8242
|
-
var
|
|
8760
|
+
var STORE_PARTS2 = ["", "-wal", "-shm"];
|
|
8243
8761
|
var resetPreview = /* @__PURE__ */ __name(async (path, messenger, env, keep) => {
|
|
8244
|
-
const files =
|
|
8245
|
-
const holders = holdersOf(files.map((file2) =>
|
|
8762
|
+
const files = STORE_PARTS2.map((suffix) => `${path}${suffix}`).filter((file2) => existsSync9(file2));
|
|
8763
|
+
const holders = holdersOf(files.map((file2) => realpathSync2(file2)));
|
|
8246
8764
|
const serving = servingProfiles(messenger.app, env).length > 0;
|
|
8247
8765
|
const read = await readingOnly(path, (database) => ({
|
|
8248
8766
|
schema: schemaOf(database).version,
|