@wirecat/zoom-cli 0.70.0 → 0.72.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/answer-entities.d.ts +2 -0
- package/dist/answer-entities.d.ts.map +1 -1
- package/dist/answers.d.ts +56 -0
- package/dist/answers.d.ts.map +1 -1
- package/dist/bin/zm.js +2 -2
- package/dist/bundle/{all-profiles-GE2TFJJP.js → all-profiles-XFIPF4GF.js} +12 -12
- package/dist/bundle/answer-policy-AT6CDEE5.js +110 -0
- package/dist/bundle/{anthropic-FA6NHENI.js → anthropic-SSUBR3BC.js} +29 -13
- package/dist/bundle/{app-server-IRADMSNX.js → app-server-7DJHHF2F.js} +68 -56
- package/dist/bundle/{bun-ZYZGGCX5.js → bun-6HBYWQIX.js} +2 -2
- package/dist/bundle/{bun-sqlite-Y24TUIGS.js → bun-sqlite-4L3Q55NB.js} +10 -6
- package/dist/bundle/{chunk-JULBAECW.js → chunk-23J2ANZ7.js} +16 -6
- package/dist/bundle/{chunk-4DSIWYGO.js → chunk-24OFZNRC.js} +39296 -24139
- package/dist/bundle/{chunk-LXXCLQCW.js → chunk-2MIBRVSV.js} +2 -2
- package/dist/bundle/{chunk-CHGUNZ3L.js → chunk-37NF5CBJ.js} +4 -4
- package/dist/bundle/chunk-3KRTEX5M.js +53 -0
- package/dist/bundle/{chunk-VNU5L37V.js → chunk-4SY67IUA.js} +34 -42
- package/dist/bundle/{chunk-XWQNJKTP.js → chunk-4XQWF3U2.js} +6 -6
- package/dist/bundle/{chunk-OAQLVV6W.js → chunk-4YIGXTBP.js} +3 -3
- package/dist/bundle/{chunk-RB33VTUW.js → chunk-5AELTC52.js} +810 -210
- package/dist/bundle/chunk-5MGICK47.js +1243 -0
- package/dist/bundle/{chunk-RRRJCHUC.js → chunk-5X4IY5JH.js} +4504 -1622
- package/dist/bundle/{chunk-EOSVN2ER.js → chunk-63QXCE5Z.js} +242 -242
- package/dist/bundle/{chunk-OE7EIP5L.js → chunk-6DCLZLGX.js} +1 -1
- package/dist/bundle/chunk-7GLJSJ7M.js +16 -0
- package/dist/bundle/{chunk-KM736RMJ.js → chunk-7IFO43Q5.js} +2 -2
- package/dist/bundle/{chunk-IWPXWGF7.js → chunk-7JYMGXLI.js} +44 -42
- package/dist/bundle/{chunk-LAG5O2FV.js → chunk-7OD3522V.js} +4162 -3769
- package/dist/bundle/{chunk-DCUWJITQ.js → chunk-7S4D5SM2.js} +60 -608
- package/dist/bundle/{chunk-3KC7C465.js → chunk-7SUWPMZG.js} +10 -15
- package/dist/bundle/{chunk-6IF5ZHDS.js → chunk-ADKMBXY4.js} +1 -1
- package/dist/bundle/{chunk-56OV5ASY.js → chunk-B3SILJBU.js} +18 -18
- package/dist/bundle/{chunk-CIZ25UPK.js → chunk-CANRIRNZ.js} +8241 -5553
- package/dist/bundle/{chunk-YUHM2OJM.js → chunk-CW46FWKW.js} +38 -123
- package/dist/bundle/{chunk-VSLDWT4E.js → chunk-D24OQAHM.js} +4 -4
- package/dist/bundle/{chunk-ZBKWRYRS.js → chunk-D5EUMWD5.js} +3 -3
- package/dist/bundle/{chunk-CSEBB4OP.js → chunk-DEPXZJ2V.js} +21 -150
- package/dist/bundle/{chunk-YJSPBUGB.js → chunk-DOCVEKP2.js} +51 -67
- package/dist/bundle/{chunk-V2E7QFZ3.js → chunk-EFF2XBHP.js} +2 -2
- package/dist/bundle/{chunk-XRFHQGOD.js → chunk-EG25AY4L.js} +1 -1
- package/dist/bundle/{chunk-FEM2JQN2.js → chunk-ELJUBPY4.js} +1 -1
- package/dist/bundle/{chunk-2U6SER67.js → chunk-ERJYJ36F.js} +2 -2
- package/dist/bundle/chunk-FSCPQQS5.js +244 -0
- package/dist/bundle/{chunk-BVWF4B33.js → chunk-H53WFZBN.js} +16 -139
- package/dist/bundle/{chunk-VJ5ZU4UF.js → chunk-I7CUMZD6.js} +3 -3
- package/dist/bundle/{chunk-OA37BWE5.js → chunk-IACWKZWS.js} +1 -1
- package/dist/bundle/{chunk-BSS6HX4O.js → chunk-IFBIXU6C.js} +2 -2
- package/dist/bundle/{chunk-UVPL7YAY.js → chunk-IU4DUUB3.js} +7 -7
- package/dist/bundle/{chunk-W7ZEEC4K.js → chunk-IXO4SCKE.js} +1 -1
- package/dist/bundle/{chunk-J3SKXICS.js → chunk-JAEPK457.js} +359 -765
- package/dist/bundle/{chunk-ZV3INEKM.js → chunk-JFPUYQSP.js} +5 -5
- package/dist/bundle/{chunk-ZS55EERO.js → chunk-JG4MNYG2.js} +1 -1
- package/dist/bundle/{chunk-IINZIP73.js → chunk-JRCH4YZP.js} +17 -10
- package/dist/bundle/{chunk-2JEM2YNV.js → chunk-JZ4XNNL7.js} +1 -1
- package/dist/bundle/chunk-K6HR6HCO.js +32 -0
- package/dist/bundle/{chunk-SNIY3JDN.js → chunk-KFZL67JP.js} +328 -60
- package/dist/bundle/{chunk-CEJJBZAE.js → chunk-KPIQXFNB.js} +375 -10
- package/dist/bundle/{chunk-M7VUXXGS.js → chunk-KWURWGGB.js} +137 -7
- package/dist/bundle/{chunk-M6JIXMQZ.js → chunk-LA6QUVGQ.js} +3 -2
- package/dist/bundle/{chunk-AISJCF7A.js → chunk-LLUNHAZ7.js} +4 -4
- package/dist/bundle/{chunk-KWRCP55G.js → chunk-LTWJM3ED.js} +17 -17
- package/dist/bundle/{chunk-IS3ZTT2Z.js → chunk-M3DMXDX6.js} +6 -6
- package/dist/bundle/{chunk-VW6BF6M7.js → chunk-MCPOZNWG.js} +1 -1
- package/dist/bundle/{chunk-L24UOUWG.js → chunk-MSQHSW4C.js} +2 -2
- package/dist/bundle/chunk-N4QNYWWG.js +71 -0
- package/dist/bundle/chunk-NMZQTYKJ.js +18 -0
- package/dist/bundle/{chunk-DNR4B5YV.js → chunk-OHCLQJOV.js} +3 -3
- package/dist/bundle/{chunk-MVOMLJYQ.js → chunk-OP5PGE2N.js} +4 -4
- package/dist/bundle/{chunk-QL7EMFIC.js → chunk-OY6N2ABP.js} +29 -23
- package/dist/bundle/chunk-PJWSGXOB.js +185 -0
- package/dist/bundle/{chunk-YTN2JN6N.js → chunk-QA6KIL7Q.js} +12 -8
- package/dist/bundle/{chunk-6HJFIMT7.js → chunk-QQUY4MZY.js} +1 -1
- package/dist/bundle/{chunk-ZSKE7N2U.js → chunk-QW7YTRV2.js} +3 -3
- package/dist/bundle/chunk-RJTGENHZ.js +109 -0
- package/dist/bundle/{chunk-RIPAUCKJ.js → chunk-RLCVPECY.js} +74 -67
- package/dist/bundle/{chunk-M7E44TMT.js → chunk-RN5SU2RN.js} +6 -6
- package/dist/bundle/{chunk-P3ASN72F.js → chunk-RX5CJ55S.js} +1 -1
- package/dist/bundle/{chunk-7QC4M4HS.js → chunk-RZUJMAMK.js} +4 -4
- package/dist/bundle/{chunk-OORMSM6O.js → chunk-S7SXSHRC.js} +21 -21
- package/dist/bundle/{chunk-SVF3NDAO.js → chunk-SXZGCD6E.js} +3 -3
- package/dist/bundle/{chunk-DXCTW3MV.js → chunk-T27IMG6X.js} +3 -1
- package/dist/bundle/{chunk-PV6OHXHN.js → chunk-TF2WKPNW.js} +18 -18
- package/dist/bundle/{chunk-X4ZF4XXI.js → chunk-U32VL3MA.js} +1 -1
- package/dist/bundle/{chunk-RQG5VOGH.js → chunk-U3NJBGLA.js} +3 -3
- package/dist/bundle/{chunk-WOIHSQAL.js → chunk-UVZLK3M4.js} +33 -9
- package/dist/bundle/chunk-VIV64MQM.js +779 -0
- package/dist/bundle/{chunk-2QFPVUM3.js → chunk-W3YTVEWV.js} +69 -6
- package/dist/bundle/{chunk-AUNW7N4I.js → chunk-WLVG4RBZ.js} +1 -1
- package/dist/bundle/{chunk-JRO2FWO2.js → chunk-WOAYHCM2.js} +1 -1
- package/dist/bundle/{chunk-RO3ZR4VP.js → chunk-WXTYYWZI.js} +13 -13
- package/dist/bundle/{chunk-RWIILYKW.js → chunk-WZGKHTA4.js} +2 -2
- package/dist/bundle/{chunk-GB5X3GBE.js → chunk-X2MP634F.js} +14 -5
- package/dist/bundle/{chunk-RGJ7OWHU.js → chunk-XPWZSW6Y.js} +61 -21
- package/dist/bundle/{chunk-D3PNCJD5.js → chunk-YVVJ6Y5C.js} +7 -7
- package/dist/bundle/chunk-ZHA56THL.js +2355 -0
- package/dist/bundle/{chunk-QO2KPU26.js → chunk-ZVFYGTGJ.js} +101 -44
- package/dist/bundle/{chunk-V5GRSOCZ.js → chunk-ZW5KHKMA.js} +5 -5
- package/dist/bundle/{cli-VRSQ7HAE.js → cli-IYYI7GAM.js} +215 -100
- package/dist/bundle/command-contract-TX7NSUBM.js +42 -0
- package/dist/bundle/command-server-entry-FXX4LJWF.js +171 -0
- package/dist/bundle/config-YKNM33J7.js +96 -0
- package/dist/bundle/{decode-523PUQMR.js → decode-SRGOOGBW.js} +6 -6
- package/dist/bundle/{dispatch-IZCAK47P.js → dispatch-OUHRPFUL.js} +11 -11
- package/dist/bundle/{dist-6WWKPEVW.js → dist-UZLNLAIO.js} +97 -56
- package/dist/bundle/{echarts-S5UMX2D3.js → echarts-7CM2MCMW.js} +2 -2
- package/dist/bundle/{embed-ODPDVHUK.js → embed-VEE56BOB.js} +7 -7
- package/dist/bundle/{embedder-PAXRBSZE.js → embedder-SZFYR543.js} +10 -10
- package/dist/bundle/{failure-R2OIHCE5.js → failure-MZBNM7M5.js} +3 -3
- package/dist/bundle/first-run-KWC7RKF2.js +29 -0
- package/dist/bundle/first-screen-DWKMNSEI.js +40 -0
- package/dist/bundle/{folders-ZXTOFY4T.js → folders-UQXRSDJJ.js} +5 -5
- package/dist/bundle/{instructions-DUB7E6C5.js → instructions-R7OHVAWH.js} +1 -1
- package/dist/bundle/{main-A7JSYQI6.js → main-EFUN2O3K.js} +21 -20
- package/dist/bundle/{mcp-M4QN2E7R.js → mcp-7KQUJNFN.js} +2 -2
- package/dist/bundle/{meetings-BDZQV3HR.js → meetings-5I2BDNTA.js} +9 -7
- package/dist/bundle/{node-E25KP53H.js → node-3N2JGZ7V.js} +2 -2
- package/dist/bundle/{node-sqlite-PHWDFZCP.js → node-sqlite-2UVEE2WM.js} +11 -7
- package/dist/bundle/{oauth-G2K46IYP.js → oauth-AYGD7UU3.js} +8 -8
- package/dist/bundle/{open-INWS5HIZ.js → open-3GUVDLGD.js} +6 -6
- package/dist/bundle/openai-NHCDLWWY.js +28 -0
- package/dist/bundle/{output-file-YGQYZCBJ.js → output-file-72JFXVHQ.js} +6 -6
- package/dist/bundle/{process-UJ2JHMJN.js → process-YAHHUFR5.js} +1 -1
- package/dist/bundle/{program-LYTGFV6L.js → program-OSZROCTK.js} +113 -118
- package/dist/bundle/{prompt-VTUCRCE4.js → prompt-HMCW4XQJ.js} +6 -6
- package/dist/bundle/{recognize-3CEPOW2F.js → recognize-VF5CA7EM.js} +5 -5
- package/dist/bundle/{remote-DRQEXEZL.js → remote-5C6VTPR2.js} +10 -8
- package/dist/bundle/{rerank-UL4KNNVN.js → rerank-ER7NEDOI.js} +8 -8
- package/dist/bundle/run-log-JKTLKXSK.js +124 -0
- package/dist/bundle/{serve-P5UWUOWQ.js → serve-QJWXJOM7.js} +10 -10
- package/dist/bundle/{server-M6XK2Y3X.js → server-KCIK3Y2P.js} +50 -48
- package/dist/bundle/server-LLGFDLLJ.js +75 -0
- package/dist/bundle/{services-4HRYNY62.js → services-LQMYJQG3.js} +121 -52
- package/dist/bundle/{speech-BBPBMFAO.js → speech-74GJQNQH.js} +20 -17
- package/dist/bundle/{state-GDSUNUSY.js → state-4XDGCHDF.js} +7 -7
- package/dist/bundle/{store-LBQ6FZP2.js → store-5Y5HK2L2.js} +28 -19
- package/dist/bundle/{store-VWLABMLF.js → store-Y56AHJ2Y.js} +64 -31
- package/dist/bundle/store-connection-4WI32AYU.js +89 -0
- package/dist/bundle/store-maintenance-command-PCXO5AH4.js +65 -0
- package/dist/bundle/{streaming-EJ3NM2C2.js → streaming-E5CR6HSR.js} +7 -7
- package/dist/bundle/{tokens-BE6CJMR5.js → tokens-E2QNVC4F.js} +7 -7
- package/dist/bundle/zm.js +34 -10
- package/dist/bundle/{zoom-app-YIEJLWCW.js → zoom-app-NVL7HEAX.js} +8 -8
- package/dist/contract-overrides.d.ts.map +1 -1
- package/dist/contract-overrides.js +0 -6
- package/dist/contract-overrides.js.map +1 -1
- package/dist/ingestion-search-commands.d.ts.map +1 -1
- package/dist/ingestion-search-commands.js +0 -10
- package/dist/ingestion-search-commands.js.map +1 -1
- package/dist/meeting-integration-commands.d.ts.map +1 -1
- package/dist/meeting-integration-commands.js +8 -6
- package/dist/meeting-integration-commands.js.map +1 -1
- package/dist/meeting-integration.d.ts +3 -1
- package/dist/meeting-integration.d.ts.map +1 -1
- package/dist/store-connection.d.ts.map +1 -1
- package/dist/store-connection.js +4 -3
- package/dist/store-connection.js.map +1 -1
- package/dist/unified-search.d.ts +4 -4
- package/dist/unified-search.d.ts.map +1 -1
- package/dist/unified-search.js +1 -24
- package/dist/unified-search.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -4
- package/skills/zoom-cli/SKILL.md +2 -2
- package/dist/bundle/answer-policy-GOXSDYDD.js +0 -104
- package/dist/bundle/chunk-5XWCBLUR.js +0 -27
- package/dist/bundle/chunk-AT2XKNFN.js +0 -342
- package/dist/bundle/chunk-GVT5363M.js +0 -35
- package/dist/bundle/chunk-VE2VNECR.js +0 -380
- package/dist/bundle/chunk-Y6C3N7YG.js +0 -12434
- package/dist/bundle/command-contract-RPRKHVU6.js +0 -41
- package/dist/bundle/config-QU6A6VIO.js +0 -90
- package/dist/bundle/first-run-NVTDR5VO.js +0 -28
- package/dist/bundle/first-screen-5RWZDWLK.js +0 -39
- package/dist/bundle/openai-T44ORVGQ.js +0 -25
- package/dist/bundle/run-log-UZAB5CWF.js +0 -118
- package/dist/bundle/server-F3NPVMS2.js +0 -72
- package/dist/bundle/store-connection-XEBFP56U.js +0 -83
- package/dist/bundle/store-maintenance-command-G43JN57J.js +0 -61
- /package/dist/bundle/{chunk-VOXIGICJ.js → chunk-YVNHQFLC.js} +0 -0
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { createRequire as __bundleRequire } from "node:module";
|
|
2
2
|
const require = __bundleRequire(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
renderMessages
|
|
5
|
-
} from "./chunk-KM736RMJ.js";
|
|
6
3
|
import {
|
|
7
4
|
answerOf,
|
|
8
5
|
messengerContext
|
|
9
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-7S4D5SM2.js";
|
|
10
7
|
import {
|
|
11
8
|
chatEventAnswer,
|
|
12
9
|
memberAnswer,
|
|
@@ -15,14 +12,17 @@ import {
|
|
|
15
12
|
serveRelay,
|
|
16
13
|
typedQuery,
|
|
17
14
|
withQuery
|
|
18
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-OY6N2ABP.js";
|
|
16
|
+
import {
|
|
17
|
+
renderMessages
|
|
18
|
+
} from "./chunk-7IFO43Q5.js";
|
|
19
19
|
import {
|
|
20
20
|
holdLock,
|
|
21
21
|
lockPath,
|
|
22
22
|
releaseLock,
|
|
23
23
|
servingProfiles,
|
|
24
24
|
takeLock
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-SXZGCD6E.js";
|
|
26
26
|
import {
|
|
27
27
|
FETCHING,
|
|
28
28
|
RULES_VERSION,
|
|
@@ -35,52 +35,23 @@ import {
|
|
|
35
35
|
onlineDeps,
|
|
36
36
|
openRequestTask,
|
|
37
37
|
patiently,
|
|
38
|
+
refuseLockedOutput,
|
|
38
39
|
senderIsMe,
|
|
39
40
|
servicesFor,
|
|
40
41
|
syncsOneChat,
|
|
41
42
|
withTimeLimit
|
|
42
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-5X4IY5JH.js";
|
|
43
44
|
import {
|
|
44
45
|
QUICK_HEALTH_CHECKS,
|
|
45
|
-
explainDamage,
|
|
46
46
|
fts5Tables,
|
|
47
47
|
invalidJson,
|
|
48
|
+
lossUnknown,
|
|
49
|
+
storeDamageReport,
|
|
48
50
|
storeHealth
|
|
49
|
-
} from "./chunk-
|
|
50
|
-
import {
|
|
51
|
-
Command,
|
|
52
|
-
LOCAL_READ,
|
|
53
|
-
LOCAL_WRITE,
|
|
54
|
-
REMOTE_READ,
|
|
55
|
-
REMOTE_WRITE,
|
|
56
|
-
annotate,
|
|
57
|
-
destroysNothing,
|
|
58
|
-
environmentOf,
|
|
59
|
-
itemOf,
|
|
60
|
-
jsonlRecords,
|
|
61
|
-
lineOf,
|
|
62
|
-
listOf,
|
|
63
|
-
nextStep,
|
|
64
|
-
outputFor,
|
|
65
|
-
recalledAccount,
|
|
66
|
-
recordLogFor,
|
|
67
|
-
renderAnswer,
|
|
68
|
-
snakeKeys,
|
|
69
|
-
storeTable,
|
|
70
|
-
withoutProviderRefs
|
|
71
|
-
} from "./chunk-LAG5O2FV.js";
|
|
72
|
-
import {
|
|
73
|
-
holdersOf
|
|
74
|
-
} from "./chunk-OA37BWE5.js";
|
|
75
|
-
import {
|
|
76
|
-
codeOf,
|
|
77
|
-
currentRun,
|
|
78
|
-
modelTarget,
|
|
79
|
-
parseDuration
|
|
80
|
-
} from "./chunk-J3SKXICS.js";
|
|
51
|
+
} from "./chunk-ZVFYGTGJ.js";
|
|
81
52
|
import {
|
|
82
|
-
|
|
83
|
-
} from "./chunk-
|
|
53
|
+
readSecret
|
|
54
|
+
} from "./chunk-I7CUMZD6.js";
|
|
84
55
|
import {
|
|
85
56
|
CORPORA,
|
|
86
57
|
MIGRATIONS,
|
|
@@ -94,6 +65,7 @@ import {
|
|
|
94
65
|
fillTrigrams,
|
|
95
66
|
fillVectorIndexes,
|
|
96
67
|
involvementStoreOver,
|
|
68
|
+
isDerivedTable,
|
|
97
69
|
migrate,
|
|
98
70
|
noteIndexState,
|
|
99
71
|
openSqlite,
|
|
@@ -114,42 +86,87 @@ import {
|
|
|
114
86
|
storeClients,
|
|
115
87
|
storeContents,
|
|
116
88
|
vectorIndexCounts
|
|
117
|
-
} from "./chunk-
|
|
89
|
+
} from "./chunk-24OFZNRC.js";
|
|
118
90
|
import {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
91
|
+
openCache
|
|
92
|
+
} from "./chunk-RN5SU2RN.js";
|
|
93
|
+
import {
|
|
94
|
+
Command,
|
|
95
|
+
LOCAL_READ,
|
|
96
|
+
LOCAL_WRITE,
|
|
97
|
+
REMOTE_READ,
|
|
98
|
+
REMOTE_WRITE,
|
|
99
|
+
annotate,
|
|
100
|
+
commandAt,
|
|
101
|
+
destroysNothing,
|
|
102
|
+
environmentOf,
|
|
103
|
+
itemOf,
|
|
104
|
+
jsonlRecords,
|
|
105
|
+
lineOf,
|
|
106
|
+
listOf,
|
|
107
|
+
nextStep,
|
|
108
|
+
outputFor,
|
|
109
|
+
recalledAccount,
|
|
110
|
+
recordLogFor,
|
|
111
|
+
renderAnswer,
|
|
112
|
+
snakeKeys,
|
|
113
|
+
storeTable,
|
|
114
|
+
withoutProviderRefs
|
|
115
|
+
} from "./chunk-7OD3522V.js";
|
|
116
|
+
import {
|
|
117
|
+
holdersOf
|
|
118
|
+
} from "./chunk-IACWKZWS.js";
|
|
122
119
|
import {
|
|
120
|
+
codeOf,
|
|
121
|
+
modelTarget,
|
|
122
|
+
parseDuration
|
|
123
|
+
} from "./chunk-JAEPK457.js";
|
|
124
|
+
import {
|
|
125
|
+
levelFor
|
|
126
|
+
} from "./chunk-LA6QUVGQ.js";
|
|
127
|
+
import {
|
|
128
|
+
modelAddressAllowed,
|
|
129
|
+
onThisComputer
|
|
130
|
+
} from "./chunk-K6HR6HCO.js";
|
|
131
|
+
import {
|
|
132
|
+
currentRun,
|
|
123
133
|
readDamageMark,
|
|
124
134
|
readHealthMark,
|
|
135
|
+
readJournalMark,
|
|
125
136
|
recordDeepCheck
|
|
126
|
-
} from "./chunk-
|
|
137
|
+
} from "./chunk-5MGICK47.js";
|
|
127
138
|
import {
|
|
128
139
|
failureKey,
|
|
129
140
|
isStoreDamage
|
|
130
|
-
} from "./chunk-
|
|
141
|
+
} from "./chunk-WZGKHTA4.js";
|
|
131
142
|
import {
|
|
132
|
-
|
|
133
|
-
|
|
143
|
+
formatLocator,
|
|
144
|
+
parseLocator
|
|
145
|
+
} from "./chunk-VIV64MQM.js";
|
|
134
146
|
import {
|
|
135
|
-
|
|
136
|
-
|
|
147
|
+
readSharedSection,
|
|
148
|
+
sharedConfigPath,
|
|
149
|
+
writeSharedSection
|
|
150
|
+
} from "./chunk-IU4DUUB3.js";
|
|
137
151
|
import {
|
|
138
|
-
|
|
139
|
-
} from "./chunk-
|
|
152
|
+
storePath
|
|
153
|
+
} from "./chunk-3KRTEX5M.js";
|
|
140
154
|
import {
|
|
141
155
|
queryFieldsOf
|
|
142
|
-
} from "./chunk-
|
|
156
|
+
} from "./chunk-63QXCE5Z.js";
|
|
143
157
|
import {
|
|
158
|
+
Credentials,
|
|
159
|
+
isMovedRun,
|
|
144
160
|
resolvePaths,
|
|
145
161
|
writeSecurely
|
|
146
|
-
} from "./chunk-
|
|
162
|
+
} from "./chunk-S7SXSHRC.js";
|
|
147
163
|
import {
|
|
148
164
|
array,
|
|
149
165
|
boolean,
|
|
150
166
|
check,
|
|
151
167
|
forward,
|
|
152
168
|
getDotPath,
|
|
169
|
+
maxLength,
|
|
153
170
|
minLength,
|
|
154
171
|
nullable,
|
|
155
172
|
object,
|
|
@@ -164,10 +181,10 @@ import {
|
|
|
164
181
|
string,
|
|
165
182
|
transform,
|
|
166
183
|
trim
|
|
167
|
-
} from "./chunk-
|
|
184
|
+
} from "./chunk-UVZLK3M4.js";
|
|
168
185
|
import {
|
|
169
186
|
CliError
|
|
170
|
-
} from "./chunk-
|
|
187
|
+
} from "./chunk-ELJUBPY4.js";
|
|
171
188
|
import {
|
|
172
189
|
__commonJS,
|
|
173
190
|
__name,
|
|
@@ -1821,7 +1838,7 @@ var require_liquid_node = __commonJS({
|
|
|
1821
1838
|
return readFileAsync(filepath, "utf8");
|
|
1822
1839
|
}
|
|
1823
1840
|
__name(readFile, "readFile");
|
|
1824
|
-
function
|
|
1841
|
+
function existsSync11(filepath) {
|
|
1825
1842
|
try {
|
|
1826
1843
|
fs$1.statSync(filepath);
|
|
1827
1844
|
return true;
|
|
@@ -1829,11 +1846,11 @@ var require_liquid_node = __commonJS({
|
|
|
1829
1846
|
return false;
|
|
1830
1847
|
}
|
|
1831
1848
|
}
|
|
1832
|
-
__name(
|
|
1833
|
-
function
|
|
1849
|
+
__name(existsSync11, "existsSync");
|
|
1850
|
+
function readFileSync6(filepath) {
|
|
1834
1851
|
return fs$1.readFileSync(filepath, "utf8");
|
|
1835
1852
|
}
|
|
1836
|
-
__name(
|
|
1853
|
+
__name(readFileSync6, "readFileSync");
|
|
1837
1854
|
function resolve2(root, file2, ext) {
|
|
1838
1855
|
if (!path.extname(file2))
|
|
1839
1856
|
file2 += ext;
|
|
@@ -1847,10 +1864,10 @@ var require_liquid_node = __commonJS({
|
|
|
1847
1864
|
}
|
|
1848
1865
|
}
|
|
1849
1866
|
__name(fallback, "fallback");
|
|
1850
|
-
function
|
|
1867
|
+
function dirname4(filepath) {
|
|
1851
1868
|
return path.dirname(filepath);
|
|
1852
1869
|
}
|
|
1853
|
-
__name(
|
|
1870
|
+
__name(dirname4, "dirname");
|
|
1854
1871
|
var realpathAsync = promisify(fs$1.realpath);
|
|
1855
1872
|
async function contains(root, file2) {
|
|
1856
1873
|
try {
|
|
@@ -1878,11 +1895,11 @@ var require_liquid_node = __commonJS({
|
|
|
1878
1895
|
__proto__: null,
|
|
1879
1896
|
exists,
|
|
1880
1897
|
readFile,
|
|
1881
|
-
existsSync:
|
|
1882
|
-
readFileSync:
|
|
1898
|
+
existsSync: existsSync11,
|
|
1899
|
+
readFileSync: readFileSync6,
|
|
1883
1900
|
resolve: resolve2,
|
|
1884
1901
|
fallback,
|
|
1885
|
-
dirname:
|
|
1902
|
+
dirname: dirname4,
|
|
1886
1903
|
contains,
|
|
1887
1904
|
containsSync,
|
|
1888
1905
|
sep: path.sep
|
|
@@ -3607,7 +3624,7 @@ var require_liquid_node = __commonJS({
|
|
|
3607
3624
|
uri_escape,
|
|
3608
3625
|
slugify
|
|
3609
3626
|
});
|
|
3610
|
-
var
|
|
3627
|
+
var join6 = argumentsToValue(function(v, arg) {
|
|
3611
3628
|
const array2 = toArray(v);
|
|
3612
3629
|
const sep = isNil(arg) ? " " : stringify(arg);
|
|
3613
3630
|
let outputSize = sep.length * Math.max(array2.length - 1, 0);
|
|
@@ -3883,7 +3900,7 @@ var require_liquid_node = __commonJS({
|
|
|
3883
3900
|
__name(sample, "sample");
|
|
3884
3901
|
var arrayFilters = /* @__PURE__ */ Object.freeze({
|
|
3885
3902
|
__proto__: null,
|
|
3886
|
-
join:
|
|
3903
|
+
join: join6,
|
|
3887
3904
|
last,
|
|
3888
3905
|
first,
|
|
3889
3906
|
reverse,
|
|
@@ -5507,11 +5524,11 @@ var require_liquid_node = __commonJS({
|
|
|
5507
5524
|
}
|
|
5508
5525
|
});
|
|
5509
5526
|
|
|
5510
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5511
|
-
import { chmodSync, constants, copyFileSync, existsSync as
|
|
5512
|
-
import { dirname as
|
|
5527
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/cli/messenger/store-maintenance-command.js
|
|
5528
|
+
import { chmodSync, constants, copyFileSync, existsSync as existsSync10, mkdirSync, realpathSync as realpathSync3, renameSync as renameSync3, rmSync as rmSync3, statfsSync as statfsSync2, statSync as statSync4, writeFileSync as writeFileSync2 } from "node:fs";
|
|
5529
|
+
import { dirname as dirname3, resolve } from "node:path";
|
|
5513
5530
|
|
|
5514
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5531
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/sealed.js
|
|
5515
5532
|
import { createCipheriv, createDecipheriv, createHash, randomBytes, scrypt, timingSafeEqual } from "node:crypto";
|
|
5516
5533
|
import { closeSync, createReadStream, createWriteStream, existsSync, openSync, readSync, renameSync, rmSync, statSync } from "node:fs";
|
|
5517
5534
|
import { Transform } from "node:stream";
|
|
@@ -5618,7 +5635,7 @@ var unsealFile = /* @__PURE__ */ __name(async (from, to, password) => {
|
|
|
5618
5635
|
renameSync(pending, to);
|
|
5619
5636
|
}, "unsealFile");
|
|
5620
5637
|
|
|
5621
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5638
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/store/compatibility.js
|
|
5622
5639
|
var SPEAKS = MIGRATIONS.at(-1)?.version ?? 0;
|
|
5623
5640
|
var fileSchemaOf = /* @__PURE__ */ __name((database) => {
|
|
5624
5641
|
const tracked = database.prepare("SELECT 1 FROM sqlite_master WHERE name = 'schema_migrations'").get();
|
|
@@ -5642,7 +5659,7 @@ var compatibilityOf = /* @__PURE__ */ __name((file2, migrations = MIGRATIONS) =>
|
|
|
5642
5659
|
};
|
|
5643
5660
|
}, "compatibilityOf");
|
|
5644
5661
|
|
|
5645
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5662
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/store/repair.js
|
|
5646
5663
|
import { createHash as createHash2 } from "node:crypto";
|
|
5647
5664
|
var COPY_MARK = "__repair_";
|
|
5648
5665
|
var COPY_NAME = /__repair_[0-9a-f]{8}(_\d+)?$/;
|
|
@@ -5896,17 +5913,99 @@ var deleteCopy = /* @__PURE__ */ __name((database, name) => {
|
|
|
5896
5913
|
return found;
|
|
5897
5914
|
}, "deleteCopy");
|
|
5898
5915
|
|
|
5899
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5916
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/cli/store-info.js
|
|
5900
5917
|
import { existsSync as existsSync4, statSync as statSync3 } from "node:fs";
|
|
5901
5918
|
|
|
5902
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5919
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/cli/store-recover.js
|
|
5903
5920
|
import { existsSync as existsSync3 } from "node:fs";
|
|
5904
5921
|
|
|
5905
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5922
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/store/recover.js
|
|
5906
5923
|
import { execFileSync, spawn } from "node:child_process";
|
|
5907
5924
|
import { existsSync as existsSync2, readFileSync, realpathSync, renameSync as renameSync2, rmSync as rmSync2, statfsSync, statSync as statSync2, writeFileSync } from "node:fs";
|
|
5908
5925
|
import { basename, dirname, join } from "node:path";
|
|
5909
5926
|
import { Transform as Transform2 } from "node:stream";
|
|
5927
|
+
|
|
5928
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/store/refill.js
|
|
5929
|
+
var REFILL_MARGIN_MS = 864e5;
|
|
5930
|
+
var TIME_KEYS = 1e12;
|
|
5931
|
+
var integerId = `external_id GLOB '[0-9]*' AND NOT external_id GLOB '*[^0-9]*'`;
|
|
5932
|
+
var forgetCoverageSince = /* @__PURE__ */ __name((database, cutoff, now = Date.now()) => {
|
|
5933
|
+
database.exec("BEGIN");
|
|
5934
|
+
try {
|
|
5935
|
+
const refetch = forget(database, cutoff, now);
|
|
5936
|
+
database.exec("COMMIT");
|
|
5937
|
+
return refetch;
|
|
5938
|
+
} catch (error) {
|
|
5939
|
+
database.exec("ROLLBACK");
|
|
5940
|
+
throw error;
|
|
5941
|
+
}
|
|
5942
|
+
}, "forgetCoverageSince");
|
|
5943
|
+
var forget = /* @__PURE__ */ __name((database, cutoff, now) => {
|
|
5944
|
+
const chats = /* @__PURE__ */ new Map();
|
|
5945
|
+
const held = database.prepare(`SELECT c.id, c.account_id, c.external_id AS chat, a.provider, a.external_id AS account,
|
|
5946
|
+
max(r.to_key) AS top FROM sync_ranges r JOIN chats c ON c.id = r.chat_id JOIN accounts a ON a.id = c.account_id
|
|
5947
|
+
GROUP BY c.id`).all();
|
|
5948
|
+
for (const row of held) {
|
|
5949
|
+
const chat = Number(row.id);
|
|
5950
|
+
const top = Number(row.top);
|
|
5951
|
+
const keepTo = cutoff === null ? null : top >= TIME_KEYS ? cutoff : database.prepare(`SELECT max(CAST(external_id AS INTEGER)) AS k FROM messages WHERE chat_id = ? AND sent_at < ? AND ${integerId}`).get(chat, cutoff)?.k;
|
|
5952
|
+
if (keepTo !== null && top <= keepTo)
|
|
5953
|
+
continue;
|
|
5954
|
+
if (keepTo === null)
|
|
5955
|
+
database.prepare("DELETE FROM sync_ranges WHERE chat_id = ?").run(chat);
|
|
5956
|
+
else {
|
|
5957
|
+
database.prepare("DELETE FROM sync_ranges WHERE chat_id = ? AND from_key > ?").run(chat, keepTo);
|
|
5958
|
+
database.prepare("UPDATE sync_ranges SET to_key = ?, updated_at = ? WHERE chat_id = ? AND to_key > ?").run(keepTo, now, chat, keepTo);
|
|
5959
|
+
}
|
|
5960
|
+
const account = Number(row.account_id);
|
|
5961
|
+
const external = String(row.chat);
|
|
5962
|
+
database.prepare("DELETE FROM sync_cursors WHERE account_id = ? AND key = ?").run(account, `fetched:${external}`);
|
|
5963
|
+
database.prepare(`DELETE FROM sync_cursors WHERE account_id = ? AND key = ? AND NOT EXISTS
|
|
5964
|
+
(SELECT 1 FROM sync_ranges WHERE chat_id = ? AND from_key <= CAST(sync_cursors.value AS INTEGER))`).run(account, `history_start:${external}`, chat);
|
|
5965
|
+
const key = `${row.provider}\0${row.account}`;
|
|
5966
|
+
const one = chats.get(key) ?? { provider: String(row.provider), account: String(row.account), chats: 0 };
|
|
5967
|
+
one.chats += 1;
|
|
5968
|
+
chats.set(key, one);
|
|
5969
|
+
}
|
|
5970
|
+
return {
|
|
5971
|
+
since: cutoff === null ? null : new Date(cutoff).toISOString(),
|
|
5972
|
+
chats: [...chats.values()],
|
|
5973
|
+
mail: forgetMail(database, cutoff, now)
|
|
5974
|
+
};
|
|
5975
|
+
}, "forget");
|
|
5976
|
+
var forgetMail = /* @__PURE__ */ __name((database, cutoff, now) => {
|
|
5977
|
+
const folders = /* @__PURE__ */ new Map();
|
|
5978
|
+
const points = database.prepare(`SELECT s.account_id, s.key, s.value, a.external_id AS account FROM sync_cursors s
|
|
5979
|
+
JOIN accounts a ON a.id = s.account_id WHERE a.provider = 'email' AND s.key LIKE 'mail_resume:%'`).all();
|
|
5980
|
+
for (const row of points) {
|
|
5981
|
+
let point;
|
|
5982
|
+
try {
|
|
5983
|
+
point = JSON.parse(String(row.value));
|
|
5984
|
+
} catch {
|
|
5985
|
+
continue;
|
|
5986
|
+
}
|
|
5987
|
+
const account = String(row.account);
|
|
5988
|
+
if (!Array.isArray(point.done)) {
|
|
5989
|
+
if (cutoff !== null && Date.parse(point.updatedAt ?? "") < cutoff)
|
|
5990
|
+
continue;
|
|
5991
|
+
database.prepare("DELETE FROM sync_cursors WHERE account_id = ? AND key = ?").run(Number(row.account_id), String(row.key));
|
|
5992
|
+
folders.set(account, (folders.get(account) ?? 0) + 1);
|
|
5993
|
+
continue;
|
|
5994
|
+
}
|
|
5995
|
+
const folder = String(row.key).slice("mail_resume:".length);
|
|
5996
|
+
const last = cutoff === null ? null : database.prepare(`SELECT max(l.uid) AS uid FROM email_locations l JOIN emails e ON e.id = l.email_id
|
|
5997
|
+
WHERE l.mailbox_id = (SELECT id FROM mailboxes WHERE account_id = ? AND external_id = ?)
|
|
5998
|
+
AND l.uidvalidity = ? AND coalesce(e.received_at, e.sent_at) < ?`).get(Number(row.account_id), folder, point.validity ?? "", cutoff)?.uid;
|
|
5999
|
+
const done = last === null ? [] : point.done.filter(([from]) => from <= last).map(([from, to]) => [from, Math.min(to, last)]);
|
|
6000
|
+
if (JSON.stringify(done) === JSON.stringify(point.done))
|
|
6001
|
+
continue;
|
|
6002
|
+
database.prepare("UPDATE sync_cursors SET value = ?, updated_at = ? WHERE account_id = ? AND key = ?").run(JSON.stringify({ ...point, done }), now, Number(row.account_id), String(row.key));
|
|
6003
|
+
folders.set(account, (folders.get(account) ?? 0) + 1);
|
|
6004
|
+
}
|
|
6005
|
+
return [...folders].map(([account, count3]) => ({ account, folders: count3 }));
|
|
6006
|
+
}, "forgetMail");
|
|
6007
|
+
|
|
6008
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/store/recover.js
|
|
5910
6009
|
var SQLITE3_MINIMUM = [3, 43, 0];
|
|
5911
6010
|
var STORE_PARTS = ["", "-wal", "-shm"];
|
|
5912
6011
|
var RECOVER_LOCK = ".recover-lock";
|
|
@@ -6001,9 +6100,12 @@ var storeHolders = /* @__PURE__ */ __name((path) => {
|
|
|
6001
6100
|
return { pid, name };
|
|
6002
6101
|
});
|
|
6003
6102
|
}, "storeHolders");
|
|
6004
|
-
var
|
|
6103
|
+
var dataTables = /* @__PURE__ */ __name((database) => {
|
|
6005
6104
|
const indexes = fts5Tables(database).map((index) => index.name);
|
|
6006
|
-
|
|
6105
|
+
return database.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND rootpage > 0 AND name NOT LIKE 'sqlite_%' AND name NOT LIKE 'vector_index_%' ORDER BY name").all().map((row) => String(row.name)).filter((name) => !indexes.some((index) => name.startsWith(`${index}_`)));
|
|
6106
|
+
}, "dataTables");
|
|
6107
|
+
var tableRows = /* @__PURE__ */ __name((database) => {
|
|
6108
|
+
const tables = dataTables(database);
|
|
6007
6109
|
return Object.fromEntries(tables.map((table) => {
|
|
6008
6110
|
try {
|
|
6009
6111
|
return [table, Number(database.prepare(`SELECT count(*) AS n FROM "${table}"`).get()?.n)];
|
|
@@ -6012,6 +6114,117 @@ var tableRows = /* @__PURE__ */ __name((database) => {
|
|
|
6012
6114
|
}
|
|
6013
6115
|
}));
|
|
6014
6116
|
}, "tableRows");
|
|
6117
|
+
var sourceTables = /* @__PURE__ */ __name((database) => {
|
|
6118
|
+
const withoutRowid = new Set(database.prepare("SELECT name FROM pragma_table_list WHERE wr = 1").all().map((row) => String(row.name)));
|
|
6119
|
+
return dataTables(database).filter((table) => table !== LOST_AND_FOUND && !withoutRowid.has(table) && !isDerivedTable(table));
|
|
6120
|
+
}, "sourceTables");
|
|
6121
|
+
var indexedButGone = /* @__PURE__ */ __name((database) => {
|
|
6122
|
+
const found = {};
|
|
6123
|
+
for (const table of sourceTables(database)) {
|
|
6124
|
+
const indexes = database.prepare("SELECT name FROM pragma_index_list(?) WHERE partial = 0 ORDER BY name").all(table).map((row) => String(row.name));
|
|
6125
|
+
for (const index of indexes) {
|
|
6126
|
+
const columns = database.prepare("SELECT cid, name FROM pragma_index_xinfo(?) WHERE key = 1 ORDER BY seqno").all(index);
|
|
6127
|
+
if (columns.some((column) => Number(column.cid) < 0))
|
|
6128
|
+
continue;
|
|
6129
|
+
const keys = columns.map((column) => `"${String(column.name)}"`).join(", ");
|
|
6130
|
+
const grouped = `${keys}, row_id`;
|
|
6131
|
+
let rows;
|
|
6132
|
+
try {
|
|
6133
|
+
rows = Number(database.prepare(`SELECT count(*) AS n FROM (SELECT 1 FROM (SELECT ${keys}, rowid AS row_id, 1 AS side FROM "${table}" INDEXED BY "${index}" UNION ALL SELECT ${keys}, rowid, 2 FROM "${table}" NOT INDEXED) GROUP BY ${grouped} HAVING max(side) = 1)`).get()?.n);
|
|
6134
|
+
} catch {
|
|
6135
|
+
continue;
|
|
6136
|
+
}
|
|
6137
|
+
if (rows > (found[table]?.rows ?? 0))
|
|
6138
|
+
found[table] = { rows, index };
|
|
6139
|
+
}
|
|
6140
|
+
}
|
|
6141
|
+
return found;
|
|
6142
|
+
}, "indexedButGone");
|
|
6143
|
+
var storedAs = /* @__PURE__ */ __name((declared) => {
|
|
6144
|
+
const type = declared.toUpperCase();
|
|
6145
|
+
if (type.includes("INT"))
|
|
6146
|
+
return ["integer"];
|
|
6147
|
+
if (/CHAR|CLOB|TEXT/.test(type))
|
|
6148
|
+
return ["text"];
|
|
6149
|
+
if (type === "" || type.includes("BLOB"))
|
|
6150
|
+
return null;
|
|
6151
|
+
if (/REAL|FLOA|DOUB/.test(type))
|
|
6152
|
+
return ["real", "integer"];
|
|
6153
|
+
return null;
|
|
6154
|
+
}, "storedAs");
|
|
6155
|
+
var columnsOf = /* @__PURE__ */ __name((database, table) => {
|
|
6156
|
+
const all = database.prepare('SELECT name, type, "notnull" AS required, dflt_value, pk FROM pragma_table_info(?)').all(table);
|
|
6157
|
+
const keys = all.filter((column) => Number(column.pk) > 0);
|
|
6158
|
+
return all.map((column) => ({
|
|
6159
|
+
name: String(column.name),
|
|
6160
|
+
type: String(column.type),
|
|
6161
|
+
required: Number(column.required) === 1,
|
|
6162
|
+
hasDefault: column.dflt_value !== null,
|
|
6163
|
+
rowid: keys.length === 1 && Number(column.pk) === 1 && String(column.type).toUpperCase() === "INTEGER"
|
|
6164
|
+
}));
|
|
6165
|
+
}, "columnsOf");
|
|
6166
|
+
var fits = /* @__PURE__ */ __name((columns, fields, types) => fields <= columns.length && columns.every((column, at) => {
|
|
6167
|
+
if (at >= fields)
|
|
6168
|
+
return !column.required || column.hasDefault;
|
|
6169
|
+
const type = types[at];
|
|
6170
|
+
if (column.rowid)
|
|
6171
|
+
return type === "null" || type === "integer";
|
|
6172
|
+
if (type === "null")
|
|
6173
|
+
return !column.required;
|
|
6174
|
+
const allowed = storedAs(column.type);
|
|
6175
|
+
return allowed === null || allowed.includes(type);
|
|
6176
|
+
}), "fits");
|
|
6177
|
+
var placeLostRows = /* @__PURE__ */ __name((database) => {
|
|
6178
|
+
if (!database.prepare("SELECT 1 FROM sqlite_master WHERE name = ?").get(LOST_AND_FOUND))
|
|
6179
|
+
return {};
|
|
6180
|
+
const fields = database.prepare("SELECT name FROM pragma_table_info(?) WHERE name GLOB 'c[0-9]*'").all(LOST_AND_FOUND).map((row) => String(row.name));
|
|
6181
|
+
const tables = sourceTables(database).map((table) => ({ table, columns: columnsOf(database, table) }));
|
|
6182
|
+
const rows = database.prepare(`SELECT rowid AS at, nfield, ${fields.map((field) => `typeof(${field}) AS "${field}"`).join(", ")} FROM ${LOST_AND_FOUND} WHERE id IS NOT NULL`).all();
|
|
6183
|
+
const placed = {};
|
|
6184
|
+
const triggers = [];
|
|
6185
|
+
const quiet = /* @__PURE__ */ __name((table) => {
|
|
6186
|
+
if (table in placed)
|
|
6187
|
+
return;
|
|
6188
|
+
placed[table] = 0;
|
|
6189
|
+
for (const row of database.prepare("SELECT name, sql FROM sqlite_master WHERE type = 'trigger' AND tbl_name = ?").all(table)) {
|
|
6190
|
+
triggers.push(String(row.sql));
|
|
6191
|
+
database.exec(`DROP TRIGGER "${String(row.name)}"`);
|
|
6192
|
+
}
|
|
6193
|
+
}, "quiet");
|
|
6194
|
+
database.exec("PRAGMA foreign_keys = OFF");
|
|
6195
|
+
database.exec("BEGIN");
|
|
6196
|
+
try {
|
|
6197
|
+
for (const row of rows) {
|
|
6198
|
+
const count3 = Number(row.nfield);
|
|
6199
|
+
const types = fields.slice(0, count3).map((field) => String(row[field]));
|
|
6200
|
+
const fitting = tables.filter(({ columns: columns2 }) => fits(columns2, count3, types));
|
|
6201
|
+
if (fitting.length !== 1)
|
|
6202
|
+
continue;
|
|
6203
|
+
const { table, columns } = fitting[0];
|
|
6204
|
+
quiet(table);
|
|
6205
|
+
const given = columns.slice(0, count3);
|
|
6206
|
+
const names = [...given.some((column) => column.rowid) ? [] : ["rowid"], ...given.map((column) => column.name)];
|
|
6207
|
+
const values = [
|
|
6208
|
+
...given.some((column) => column.rowid) ? [] : ["id"],
|
|
6209
|
+
...given.map((column, at) => column.rowid ? "id" : `c${at}`)
|
|
6210
|
+
];
|
|
6211
|
+
const inserted = database.prepare(`INSERT OR IGNORE INTO "${table}" (${names.map((name) => `"${name}"`).join(", ")}) SELECT ${values.join(", ")} FROM ${LOST_AND_FOUND} WHERE rowid = ?`).run(Number(row.at));
|
|
6212
|
+
if (Number(inserted.changes) === 0)
|
|
6213
|
+
continue;
|
|
6214
|
+
placed[table] = (placed[table] ?? 0) + 1;
|
|
6215
|
+
database.prepare(`DELETE FROM ${LOST_AND_FOUND} WHERE rowid = ?`).run(Number(row.at));
|
|
6216
|
+
}
|
|
6217
|
+
for (const sql of triggers)
|
|
6218
|
+
database.exec(sql);
|
|
6219
|
+
database.exec("COMMIT");
|
|
6220
|
+
} catch (error) {
|
|
6221
|
+
database.exec("ROLLBACK");
|
|
6222
|
+
throw error;
|
|
6223
|
+
} finally {
|
|
6224
|
+
database.exec("PRAGMA foreign_keys = ON");
|
|
6225
|
+
}
|
|
6226
|
+
return Object.fromEntries(Object.entries(placed).filter(([, rows2]) => rows2 > 0));
|
|
6227
|
+
}, "placeLostRows");
|
|
6015
6228
|
var copyReadableRows = /* @__PURE__ */ __name((path, target, program = "sqlite3") => new Promise((resolve2, reject) => {
|
|
6016
6229
|
const reader = spawn(program, ["-readonly", path, `.recover --ignore-freelist --lost-and-found ${LOST_AND_FOUND}`], {
|
|
6017
6230
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -6208,6 +6421,9 @@ var recoverLocked = /* @__PURE__ */ __name(async ({ path, command, version, sqli
|
|
|
6208
6421
|
throw error;
|
|
6209
6422
|
throw new CliError("configuration_error", "the store file's header or schema is damaged, so its tables cannot be listed and it cannot be recovered; the file was left as it was", { reason: "store.unreadable" });
|
|
6210
6423
|
}
|
|
6424
|
+
note("looking for rows the indexes list and the tables no longer hold");
|
|
6425
|
+
const gone = indexedButGone(watch);
|
|
6426
|
+
const lastKnownGood = readHealthMark(path)?.last_ok_at ?? null;
|
|
6211
6427
|
const before = { data: dataVersion(), inode: statSync2(path).ino };
|
|
6212
6428
|
const stamp = new Date(now()).toISOString().replace(/[:.]/g, "-");
|
|
6213
6429
|
const target = `${path}.recovering-${stamp}`;
|
|
@@ -6236,7 +6452,10 @@ var recoverLocked = /* @__PURE__ */ __name(async ({ path, command, version, sqli
|
|
|
6236
6452
|
let json;
|
|
6237
6453
|
let fetch;
|
|
6238
6454
|
let schema;
|
|
6455
|
+
let placed;
|
|
6456
|
+
let refetch;
|
|
6239
6457
|
try {
|
|
6458
|
+
placed = placeLostRows(opened.database);
|
|
6240
6459
|
kept = tableRows(opened.database);
|
|
6241
6460
|
migrate(opened.database, { command, ...version ? { version } : {} });
|
|
6242
6461
|
note("clearing values that are not valid JSON");
|
|
@@ -6245,6 +6464,8 @@ var recoverLocked = /* @__PURE__ */ __name(async ({ path, command, version, sqli
|
|
|
6245
6464
|
note("looking for rows that point at rows that were lost");
|
|
6246
6465
|
dangling = danglingRows(opened.database);
|
|
6247
6466
|
fetch = mailToFetch(opened.database);
|
|
6467
|
+
const good = lastKnownGood === null ? Number.NaN : Date.parse(lastKnownGood);
|
|
6468
|
+
refetch = forgetCoverageSince(opened.database, Number.isNaN(good) ? null : good - REFILL_MARGIN_MS, now());
|
|
6248
6469
|
schema = fileSchemaOf(opened.database).version;
|
|
6249
6470
|
opened.database.exec("PRAGMA wal_checkpoint(TRUNCATE)");
|
|
6250
6471
|
} catch (error) {
|
|
@@ -6274,16 +6495,29 @@ var recoverLocked = /* @__PURE__ */ __name(async ({ path, command, version, sqli
|
|
|
6274
6495
|
if (existsSync2(`${target}${suffix}`))
|
|
6275
6496
|
renameSync2(`${target}${suffix}`, `${path}${suffix}`);
|
|
6276
6497
|
recordDeepCheck(path, health, { cli: command, ...version ? { version } : {}, schema, now });
|
|
6277
|
-
const lost = Object.entries(rowsBefore).map(([table, before2]) =>
|
|
6498
|
+
const lost = Object.entries(rowsBefore).map(([table, before2]) => {
|
|
6499
|
+
const goneAtLeast = Math.max(0, (gone[table]?.rows ?? 0) - (placed[table] ?? 0));
|
|
6500
|
+
return {
|
|
6501
|
+
table,
|
|
6502
|
+
before: before2,
|
|
6503
|
+
read: read[table] ?? 0,
|
|
6504
|
+
kept: kept[table] ?? 0,
|
|
6505
|
+
goneAtLeast,
|
|
6506
|
+
seenIn: goneAtLeast > 0 ? gone[table]?.index ?? null : null
|
|
6507
|
+
};
|
|
6508
|
+
}).filter(({ before: before2, read: read2, kept: kept2, goneAtLeast }) => before2 === null || before2 > kept2 || read2 > kept2 || goneAtLeast > 0);
|
|
6278
6509
|
const seconds = /* @__PURE__ */ __name((from, to) => Math.round((to - from) / 100) / 10, "seconds");
|
|
6279
6510
|
return {
|
|
6280
6511
|
path,
|
|
6281
6512
|
keptAt,
|
|
6282
6513
|
sqlite3: program.version,
|
|
6283
6514
|
lost,
|
|
6515
|
+
placed,
|
|
6516
|
+
lastKnownGood,
|
|
6284
6517
|
dangling,
|
|
6285
6518
|
invalidJson: json,
|
|
6286
6519
|
mailToFetch: fetch,
|
|
6520
|
+
refetch,
|
|
6287
6521
|
rebuilt,
|
|
6288
6522
|
copyErrors,
|
|
6289
6523
|
health,
|
|
@@ -6299,7 +6533,7 @@ var recoverLocked = /* @__PURE__ */ __name(async ({ path, command, version, sqli
|
|
|
6299
6533
|
}
|
|
6300
6534
|
}, "recoverLocked");
|
|
6301
6535
|
|
|
6302
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6536
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/cli/store-recover.js
|
|
6303
6537
|
var COUNTED = [
|
|
6304
6538
|
"accounts",
|
|
6305
6539
|
"chats",
|
|
@@ -6332,18 +6566,23 @@ var storeRecoveryCheck = /* @__PURE__ */ __name(async (env, command, version) =>
|
|
|
6332
6566
|
}
|
|
6333
6567
|
} catch {
|
|
6334
6568
|
}
|
|
6569
|
+
const journal = readJournalMark(path);
|
|
6335
6570
|
recordDeepCheck(path, health, { cli: command, ...version ? { version } : {}, schema });
|
|
6336
6571
|
const mark = readDamageMark(path);
|
|
6337
|
-
const
|
|
6572
|
+
const lastKnownGood = readHealthMark(path)?.last_ok_at ?? null;
|
|
6338
6573
|
const inUse = storeHolders(path) ?? null;
|
|
6339
6574
|
const timers = activeTimers() ?? null;
|
|
6340
6575
|
const sqlite3 = sqlite3Program();
|
|
6341
|
-
const
|
|
6342
|
-
|
|
6343
|
-
|
|
6344
|
-
|
|
6345
|
-
|
|
6346
|
-
|
|
6576
|
+
const report = storeDamageReport({
|
|
6577
|
+
health,
|
|
6578
|
+
command,
|
|
6579
|
+
mark,
|
|
6580
|
+
journal,
|
|
6581
|
+
lastOkAt: lastKnownGood,
|
|
6582
|
+
holders: inUse,
|
|
6583
|
+
timers,
|
|
6584
|
+
sqlite3Usable: sqlite3.usable
|
|
6585
|
+
});
|
|
6347
6586
|
return {
|
|
6348
6587
|
path,
|
|
6349
6588
|
exists: true,
|
|
@@ -6354,13 +6593,13 @@ var storeRecoveryCheck = /* @__PURE__ */ __name(async (env, command, version) =>
|
|
|
6354
6593
|
damagedSearchIndexes: (health.searchIndexes ?? []).filter((index) => !index.ok).map(({ name, error }) => ({ name, ...error ? { error } : {} })),
|
|
6355
6594
|
invalidJson: health.invalidJson ?? [],
|
|
6356
6595
|
rows,
|
|
6357
|
-
|
|
6596
|
+
report,
|
|
6358
6597
|
damageMark: mark ? (({ inode: _, ...seen }) => seen)(mark) : null,
|
|
6359
|
-
lastKnownGood
|
|
6598
|
+
lastKnownGood,
|
|
6360
6599
|
inUse,
|
|
6361
6600
|
timers,
|
|
6362
6601
|
sqlite3: { version: sqlite3.version, usable: sqlite3.usable },
|
|
6363
|
-
next
|
|
6602
|
+
next: report?.steps.map((step) => step.command) ?? []
|
|
6364
6603
|
};
|
|
6365
6604
|
}, "storeRecoveryCheck");
|
|
6366
6605
|
var storeRecoveryRun = /* @__PURE__ */ __name(async (env, { command, version, note, timers: scheduled = activeTimers, copy }) => {
|
|
@@ -6386,12 +6625,27 @@ var storeRecoveryRun = /* @__PURE__ */ __name(async (env, { command, version, no
|
|
|
6386
6625
|
next: [...mail, ...lostMail, "systemctl --user start <the timers stopped before>"]
|
|
6387
6626
|
};
|
|
6388
6627
|
}, "storeRecoveryRun");
|
|
6628
|
+
var refetchNotes = /* @__PURE__ */ __name(({ since, chats, mail }) => {
|
|
6629
|
+
const from = since === null ? "from the start" : `from ${since} on`;
|
|
6630
|
+
const marked = [
|
|
6631
|
+
...chats.map(({ provider, account, chats: chats2 }) => `${chats2} chats of ${provider} ${account}`),
|
|
6632
|
+
...mail.map(({ account, folders }) => `${folders} mail folders of ${account}`)
|
|
6633
|
+
];
|
|
6634
|
+
return [
|
|
6635
|
+
marked.length > 0 ? `marked as not fetched ${from}, so the next sync or serve fetches it again: ${marked.join(", ")}` : `nothing held ${from} was marked as fetched, so there is nothing to fetch again`,
|
|
6636
|
+
...chats.filter(({ provider }) => provider === "whatsapp").map(({ account }) => `whatsapp ${account}: WhatsApp cannot be asked for its chats, so only what the phone pushes while serve runs comes back`),
|
|
6637
|
+
"notes, memories, tags and whatever else only this store held cannot be fetched again"
|
|
6638
|
+
];
|
|
6639
|
+
}, "refetchNotes");
|
|
6389
6640
|
var recoveryNotes = /* @__PURE__ */ __name((answer) => {
|
|
6390
6641
|
if ("keptAt" in answer) {
|
|
6391
|
-
const lost = answer.lost.map(({ table, before, read, kept }) => `${table}: ${kept} kept of ${before ?? "an uncountable number"}${read > kept ? `, ${read - kept} read but unusable` : ""}`);
|
|
6642
|
+
const lost = answer.lost.map(({ table, before, read, kept, goneAtLeast, seenIn }) => `${table}: ${kept} kept of ${before ?? "an uncountable number"}${read > kept ? `, ${read - kept} read but unusable` : ""}` + (goneAtLeast > 0 ? `; at least ${goneAtLeast} rows are gone (the index ${seenIn} lists them)` : ""));
|
|
6392
6643
|
return [
|
|
6393
6644
|
`recovered in ${answer.seconds.total} s; the damaged file is kept at ${answer.keptAt}`,
|
|
6394
|
-
...lost
|
|
6645
|
+
...lost,
|
|
6646
|
+
...Object.entries(answer.placed).map(([table, rows]) => `${table}: ${rows} rows found on pages no table claimed were put back`),
|
|
6647
|
+
...refetchNotes(answer.refetch),
|
|
6648
|
+
lossUnknown(answer.lastKnownGood, lost.some((line) => line.includes("are gone"))),
|
|
6395
6649
|
...answer.dangling.map(({ table, parent, rows }) => `${rows} rows of ${table} point at ${parent} rows the store does not hold`),
|
|
6396
6650
|
...answer.invalidJson.map(({ table, column, rows, required }) => `${table}.${column}: ${rows} values were not valid JSON \u2014 ${required ? "those rows were dropped" : "set to empty"}`),
|
|
6397
6651
|
...answer.next.map((line) => `next: ${line}`)
|
|
@@ -6399,13 +6653,16 @@ var recoveryNotes = /* @__PURE__ */ __name((answer) => {
|
|
|
6399
6653
|
}
|
|
6400
6654
|
if (!answer.exists)
|
|
6401
6655
|
return ["no store yet"];
|
|
6402
|
-
|
|
6656
|
+
const report = answer.report;
|
|
6657
|
+
if (!report)
|
|
6403
6658
|
return [`the store is healthy (checked every page and search index in ${answer.seconds} s)`];
|
|
6404
|
-
const why = answer.explanation;
|
|
6405
6659
|
return [
|
|
6406
|
-
|
|
6407
|
-
|
|
6408
|
-
|
|
6660
|
+
report.whatHappened,
|
|
6661
|
+
...report.impact,
|
|
6662
|
+
report.externalDataSafe,
|
|
6663
|
+
report.loss,
|
|
6664
|
+
...report.likelyCauses.map(({ cause, check: check2 }) => `maybe: ${cause} \u2014 check: ${check2}`),
|
|
6665
|
+
...report.steps.map(({ command, why, destructive }) => `next: ${command} # ${destructive ? "changes things: " : ""}${why}`)
|
|
6409
6666
|
];
|
|
6410
6667
|
}, "recoveryNotes");
|
|
6411
6668
|
var storeRecoverCommand = /* @__PURE__ */ __name(({ command, version }) => {
|
|
@@ -6432,7 +6689,7 @@ var storeRecoverCommand = /* @__PURE__ */ __name(({ command, version }) => {
|
|
|
6432
6689
|
return recover;
|
|
6433
6690
|
}, "storeRecoverCommand");
|
|
6434
6691
|
|
|
6435
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6692
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/cli/store-info.js
|
|
6436
6693
|
var pendingIfKnown = /* @__PURE__ */ __name((database) => database.prepare("SELECT 1 FROM pragma_table_info('messages') WHERE name = 'normalized_text'").get() ? pendingNormalization(database) : null, "pendingIfKnown");
|
|
6437
6694
|
var bytesOf = /* @__PURE__ */ __name((path) => existsSync4(path) ? statSync3(path).size : 0, "bytesOf");
|
|
6438
6695
|
var messageOf = /* @__PURE__ */ __name((error) => error instanceof Error ? error.message : String(error), "messageOf");
|
|
@@ -6482,7 +6739,7 @@ var sharedStoreCommand = /* @__PURE__ */ __name((app) => {
|
|
|
6482
6739
|
return app ? store.addCommand(storeRecoverCommand(app)) : store;
|
|
6483
6740
|
}, "sharedStoreCommand");
|
|
6484
6741
|
|
|
6485
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6742
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/cli/messenger/password.js
|
|
6486
6743
|
var ENCRYPT_OPTION = [
|
|
6487
6744
|
"--encrypt",
|
|
6488
6745
|
"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"
|
|
@@ -6501,7 +6758,7 @@ var passwordOf = /* @__PURE__ */ __name(async (command, { twice }) => {
|
|
|
6501
6758
|
return password;
|
|
6502
6759
|
}, "passwordOf");
|
|
6503
6760
|
|
|
6504
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6761
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/replies/rules.js
|
|
6505
6762
|
import { existsSync as existsSync5, readFileSync as readFileSync2 } from "node:fs";
|
|
6506
6763
|
import { join as join2 } from "node:path";
|
|
6507
6764
|
var REPLY_ACTIONS = ["reply", "task"];
|
|
@@ -6672,7 +6929,7 @@ var problem = /* @__PURE__ */ __name((issue) => {
|
|
|
6672
6929
|
}, "problem");
|
|
6673
6930
|
var broken = /* @__PURE__ */ __name((path, why) => new CliError("configuration_error", `the reply rules ${path} cannot be read (${why}) \u2014 fix the file`), "broken");
|
|
6674
6931
|
|
|
6675
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6932
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/replies/state.js
|
|
6676
6933
|
import { existsSync as existsSync6, readFileSync as readFileSync3 } from "node:fs";
|
|
6677
6934
|
import { join as join3 } from "node:path";
|
|
6678
6935
|
var ANSWERED_KEPT = 1e3;
|
|
@@ -6725,7 +6982,7 @@ var recordReply = /* @__PURE__ */ __name((state, rule2, message, now) => {
|
|
|
6725
6982
|
}, "recordReply");
|
|
6726
6983
|
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");
|
|
6727
6984
|
|
|
6728
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6985
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/replies/decide.js
|
|
6729
6986
|
var skip = /* @__PURE__ */ __name((why) => ({ skip: why }), "skip");
|
|
6730
6987
|
var decide = /* @__PURE__ */ __name((rule2, incoming, state, now) => {
|
|
6731
6988
|
const { message, chat, owner, sender } = incoming;
|
|
@@ -6831,10 +7088,10 @@ var filled = /* @__PURE__ */ __name((template2, senderName) => {
|
|
|
6831
7088
|
return template2.replaceAll("{firstName}", name.split(/\s+/)[0] ?? name).replaceAll("{name}", name);
|
|
6832
7089
|
}, "filled");
|
|
6833
7090
|
|
|
6834
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7091
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/replies/template.js
|
|
6835
7092
|
var import_liquidjs2 = __toESM(require_liquid_node(), 1);
|
|
6836
7093
|
|
|
6837
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7094
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/render/liquid.js
|
|
6838
7095
|
var import_liquidjs = __toESM(require_liquid_node(), 1);
|
|
6839
7096
|
var safeLiquid = /* @__PURE__ */ __name((limits) => {
|
|
6840
7097
|
const engine = new import_liquidjs.Liquid({
|
|
@@ -6861,7 +7118,7 @@ var safeLiquid = /* @__PURE__ */ __name((limits) => {
|
|
|
6861
7118
|
return engine;
|
|
6862
7119
|
}, "safeLiquid");
|
|
6863
7120
|
|
|
6864
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7121
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/replies/template.js
|
|
6865
7122
|
var TEMPLATE_LIMITS = {
|
|
6866
7123
|
parse: 32768,
|
|
6867
7124
|
renders: 2e3,
|
|
@@ -7000,7 +7257,7 @@ var renderReplyTemplate = /* @__PURE__ */ __name(async (reply, input) => {
|
|
|
7000
7257
|
}
|
|
7001
7258
|
}, "renderReplyTemplate");
|
|
7002
7259
|
|
|
7003
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7260
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/replies/dry-run.js
|
|
7004
7261
|
var DRY_RUN_DAYS = 7;
|
|
7005
7262
|
var PAGE = 500;
|
|
7006
7263
|
var dryRun = /* @__PURE__ */ __name(async (store, account, rules, { since, until = Date.now(), only, audience, render }) => {
|
|
@@ -7114,7 +7371,192 @@ var storedSince = /* @__PURE__ */ __name(async (store, account, chat, since) =>
|
|
|
7114
7371
|
}
|
|
7115
7372
|
}, "storedSince");
|
|
7116
7373
|
|
|
7117
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7374
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/models/ai.js
|
|
7375
|
+
var AI_PROVIDERS = ["anthropic", "openai", "ollama"];
|
|
7376
|
+
var DEFAULT_BASE_URL = {
|
|
7377
|
+
anthropic: "https://api.anthropic.com",
|
|
7378
|
+
openai: "https://api.openai.com/v1",
|
|
7379
|
+
ollama: "http://127.0.0.1:11434/v1"
|
|
7380
|
+
};
|
|
7381
|
+
var OFFICIAL = {
|
|
7382
|
+
"https://api.openai.com": "openai",
|
|
7383
|
+
"https://api.anthropic.com": "anthropic"
|
|
7384
|
+
};
|
|
7385
|
+
var SECTION = "ai";
|
|
7386
|
+
var aiAddressAllowed = modelAddressAllowed;
|
|
7387
|
+
var consentShape = strictObject({
|
|
7388
|
+
origin: string(),
|
|
7389
|
+
model: string(),
|
|
7390
|
+
at: string()
|
|
7391
|
+
});
|
|
7392
|
+
var settingShape = strictObject({
|
|
7393
|
+
provider: picklist(AI_PROVIDERS),
|
|
7394
|
+
model: pipe(string(), trim(), minLength(1), maxLength(200)),
|
|
7395
|
+
base_url: optional(pipe(string(), check(aiAddressAllowed, "use https, or http only on this computer"))),
|
|
7396
|
+
images: optional(consentShape)
|
|
7397
|
+
});
|
|
7398
|
+
var aiSettingPath = /* @__PURE__ */ __name((env) => sharedConfigPath(storePath(env), env), "aiSettingPath");
|
|
7399
|
+
var readAiSetting = /* @__PURE__ */ __name((path) => {
|
|
7400
|
+
const section = readSharedSection(path, SECTION);
|
|
7401
|
+
if (section === void 0)
|
|
7402
|
+
return void 0;
|
|
7403
|
+
const checked = safeParse(settingShape, section);
|
|
7404
|
+
if (!checked.success)
|
|
7405
|
+
throw new CliError("configuration_error", `${path}: ai.${getDotPath(checked.issues[0]) ?? "setting"} is invalid`, {
|
|
7406
|
+
reason: "ai.setting-invalid"
|
|
7407
|
+
});
|
|
7408
|
+
return checked.output;
|
|
7409
|
+
}, "readAiSetting");
|
|
7410
|
+
var writeAiSetting = /* @__PURE__ */ __name((path, setting) => writeSharedSection(path, SECTION, setting), "writeAiSetting");
|
|
7411
|
+
var aiSettingOf = /* @__PURE__ */ __name((given) => {
|
|
7412
|
+
const draft = {
|
|
7413
|
+
provider: given.provider,
|
|
7414
|
+
model: given.model,
|
|
7415
|
+
...given.baseUrl?.trim() ? { base_url: given.baseUrl.trim().replace(/\/+$/, "") } : {}
|
|
7416
|
+
};
|
|
7417
|
+
const checked = safeParse(settingShape, draft);
|
|
7418
|
+
if (!checked.success) {
|
|
7419
|
+
const field = getDotPath(checked.issues[0]);
|
|
7420
|
+
throw new CliError("validation_error", field === "provider" ? `the provider is one of ${AI_PROVIDERS.join(", ")}` : field === "base_url" ? "this address is not allowed: use https, or http only on this computer" : "name the model, 1 to 200 characters", { reason: field === "base_url" ? "ai.address-refused" : "ai.setting-invalid" });
|
|
7421
|
+
}
|
|
7422
|
+
if (checked.output.provider === "ollama" && !onThisComputer(aiBaseUrl(checked.output)))
|
|
7423
|
+
throw new CliError("validation_error", "Ollama is read only on this computer", { reason: "ai.address-refused" });
|
|
7424
|
+
return given.allowImages ? {
|
|
7425
|
+
...checked.output,
|
|
7426
|
+
images: { origin: aiOrigin(checked.output), model: checked.output.model, at: (/* @__PURE__ */ new Date()).toISOString() }
|
|
7427
|
+
} : checked.output;
|
|
7428
|
+
}, "aiSettingOf");
|
|
7429
|
+
var aiBaseUrl = /* @__PURE__ */ __name((setting) => setting.base_url ?? DEFAULT_BASE_URL[setting.provider], "aiBaseUrl");
|
|
7430
|
+
var aiOrigin = /* @__PURE__ */ __name((setting) => new URL(aiBaseUrl(setting)).origin, "aiOrigin");
|
|
7431
|
+
var aiTarget = /* @__PURE__ */ __name((setting) => ({
|
|
7432
|
+
provider: setting.provider === "anthropic" ? "anthropic" : "openai",
|
|
7433
|
+
model: setting.model,
|
|
7434
|
+
baseUrl: aiBaseUrl(setting)
|
|
7435
|
+
}), "aiTarget");
|
|
7436
|
+
var aiImagesAllowed = /* @__PURE__ */ __name((setting) => setting.images?.origin === aiOrigin(setting) && setting.images.model === setting.model, "aiImagesAllowed");
|
|
7437
|
+
var aiKeys = /* @__PURE__ */ __name((app, env, keyring) => {
|
|
7438
|
+
const where = { appName: "WireCat", prefix: "WIRECAT", env };
|
|
7439
|
+
const credentials = new Credentials({
|
|
7440
|
+
configDir: resolvePaths(where).config,
|
|
7441
|
+
service: "WireCat",
|
|
7442
|
+
// A tool run with its own folders moved (MEMO_CONFIG_DIR…) is a test or a sandbox, not the owner.
|
|
7443
|
+
isolated: isMovedRun(where) || isMovedRun({ appName: app.appName, prefix: app.envPrefix, env }),
|
|
7444
|
+
env,
|
|
7445
|
+
...keyring ? { keyring } : {},
|
|
7446
|
+
warn: /* @__PURE__ */ __name((message) => process.stderr.write(`${message}
|
|
7447
|
+
`), "warn")
|
|
7448
|
+
});
|
|
7449
|
+
const account = /* @__PURE__ */ __name((origin) => `ai:${origin}`, "account");
|
|
7450
|
+
return {
|
|
7451
|
+
read: /* @__PURE__ */ __name((origin) => {
|
|
7452
|
+
const stored = credentials.read(account(origin));
|
|
7453
|
+
if (stored)
|
|
7454
|
+
return { key: stored.secret, source: stored.source };
|
|
7455
|
+
const official = OFFICIAL[origin];
|
|
7456
|
+
const legacy = official ?? (origin.startsWith("https://") ? endpointKeyName(origin) : void 0);
|
|
7457
|
+
const found = legacy === void 0 ? void 0 : embeddingKeys(app, env, keyring).read(legacy);
|
|
7458
|
+
return found ? { key: found.key, source: found.source === "env" ? "environment" : found.source } : void 0;
|
|
7459
|
+
}, "read"),
|
|
7460
|
+
write: /* @__PURE__ */ __name((origin, key) => credentials.write(account(origin), key, { signIn: true }), "write"),
|
|
7461
|
+
remove: /* @__PURE__ */ __name((origin) => credentials.remove(account(origin)), "remove")
|
|
7462
|
+
};
|
|
7463
|
+
}, "aiKeys");
|
|
7464
|
+
var aiNeedsKey = /* @__PURE__ */ __name((setting) => aiLeavesComputer(setting), "aiNeedsKey");
|
|
7465
|
+
var aiTakesKey = /* @__PURE__ */ __name((setting) => setting.provider !== "ollama", "aiTakesKey");
|
|
7466
|
+
var keyFor = /* @__PURE__ */ __name((setting, deps) => aiTakesKey(setting) ? aiKeys(deps.app, deps.env, deps.keyring).read(aiOrigin(setting))?.key : void 0, "keyFor");
|
|
7467
|
+
var gatewayFor = /* @__PURE__ */ __name((setting, deps, key) => modelGateway({
|
|
7468
|
+
resolve: /* @__PURE__ */ __name(() => aiTarget(setting), "resolve"),
|
|
7469
|
+
consent: /* @__PURE__ */ __name(() => true, "consent"),
|
|
7470
|
+
key: /* @__PURE__ */ __name(() => key, "key"),
|
|
7471
|
+
env: deps.env,
|
|
7472
|
+
...deps.fetch ? { fetch: deps.fetch } : {},
|
|
7473
|
+
...deps.signal ? { signal: deps.signal } : {}
|
|
7474
|
+
}), "gatewayFor");
|
|
7475
|
+
var aiLeavesComputer = /* @__PURE__ */ __name((setting) => !onThisComputer(aiBaseUrl(setting)), "aiLeavesComputer");
|
|
7476
|
+
var sharedModel = /* @__PURE__ */ __name((deps) => {
|
|
7477
|
+
const setting = readAiSetting(aiSettingPath(deps.env));
|
|
7478
|
+
if (!setting)
|
|
7479
|
+
return void 0;
|
|
7480
|
+
return { target: { ...aiTarget(setting), baseUrl: aiBaseUrl(setting) }, key: keyFor(setting, deps), setting };
|
|
7481
|
+
}, "sharedModel");
|
|
7482
|
+
var aiTextReader = /* @__PURE__ */ __name((deps) => {
|
|
7483
|
+
const setting = readAiSetting(aiSettingPath(deps.env));
|
|
7484
|
+
if (!setting)
|
|
7485
|
+
return { refused: "ai.not-set" };
|
|
7486
|
+
const key = keyFor(setting, deps);
|
|
7487
|
+
if (aiNeedsKey(setting) && !key)
|
|
7488
|
+
return { refused: "ai.key-missing" };
|
|
7489
|
+
const gateway = gatewayFor(setting, deps, key);
|
|
7490
|
+
return {
|
|
7491
|
+
by: `${setting.provider}/${setting.model}`,
|
|
7492
|
+
leavesComputer: aiLeavesComputer(setting),
|
|
7493
|
+
complete: /* @__PURE__ */ __name(async (request) => (await gateway.complete(request)).text, "complete")
|
|
7494
|
+
};
|
|
7495
|
+
}, "aiTextReader");
|
|
7496
|
+
var reasonOf = /* @__PURE__ */ __name((error) => {
|
|
7497
|
+
if (!(error instanceof CliError))
|
|
7498
|
+
return "ai.failed";
|
|
7499
|
+
if (error.code === "rate_limited")
|
|
7500
|
+
return "ai.rate-limited";
|
|
7501
|
+
const { reason, status } = error.details;
|
|
7502
|
+
if (reason === "model.key-rejected")
|
|
7503
|
+
return "ai.key-rejected";
|
|
7504
|
+
if (reason === "model.unreachable")
|
|
7505
|
+
return "ai.unreachable";
|
|
7506
|
+
if (reason === "model.empty-answer")
|
|
7507
|
+
return "ai.empty-answer";
|
|
7508
|
+
if (status === 402)
|
|
7509
|
+
return "ai.no-credit";
|
|
7510
|
+
if (status === 404)
|
|
7511
|
+
return "ai.model-unknown";
|
|
7512
|
+
if (typeof status === "number" && status >= 500)
|
|
7513
|
+
return "ai.provider-error";
|
|
7514
|
+
return "ai.failed";
|
|
7515
|
+
}, "reasonOf");
|
|
7516
|
+
var checkAi = /* @__PURE__ */ __name(async (deps) => {
|
|
7517
|
+
const setting = readAiSetting(aiSettingPath(deps.env));
|
|
7518
|
+
if (!setting)
|
|
7519
|
+
return { ok: false, reason: "ai.not-set", ms: null };
|
|
7520
|
+
const key = keyFor(setting, deps);
|
|
7521
|
+
if (aiNeedsKey(setting) && !key)
|
|
7522
|
+
return { ok: false, reason: "ai.key-missing", ms: null };
|
|
7523
|
+
const started = Date.now();
|
|
7524
|
+
try {
|
|
7525
|
+
await gatewayFor(setting, deps, key).complete({
|
|
7526
|
+
purpose: "check",
|
|
7527
|
+
system: "Reply with the word OK.",
|
|
7528
|
+
prompt: "OK?",
|
|
7529
|
+
// Reasoning models spend tokens before they answer; too low a cap reads as a broken setup.
|
|
7530
|
+
maxTokens: 2048
|
|
7531
|
+
});
|
|
7532
|
+
return { ok: true, reason: "ai.ok", ms: Date.now() - started };
|
|
7533
|
+
} catch (error) {
|
|
7534
|
+
return { ok: false, reason: reasonOf(error), ms: null };
|
|
7535
|
+
}
|
|
7536
|
+
}, "checkAi");
|
|
7537
|
+
|
|
7538
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/models/purpose.js
|
|
7539
|
+
var HOSTED = {
|
|
7540
|
+
openai: "https://api.openai.com/v1",
|
|
7541
|
+
anthropic: "https://api.anthropic.com"
|
|
7542
|
+
};
|
|
7543
|
+
var purposeModel = /* @__PURE__ */ __name((settings, purpose, deps) => {
|
|
7544
|
+
const configured = modelTarget(settings, purpose);
|
|
7545
|
+
if (configured) {
|
|
7546
|
+
const baseUrl = configured.baseUrl ?? HOSTED[configured.provider] ?? "";
|
|
7547
|
+
return {
|
|
7548
|
+
target: { ...configured, baseUrl },
|
|
7549
|
+
key: /* @__PURE__ */ __name(() => embeddingKeys(deps.app, deps.env, deps.keyring).read(configured.baseUrl === void 0 ? configured.provider : endpointKeyName(configured.baseUrl))?.key, "key")
|
|
7550
|
+
};
|
|
7551
|
+
}
|
|
7552
|
+
const provider = settings.models?.[purpose]?.provider ?? settings.models?.default?.provider;
|
|
7553
|
+
if (provider === "off")
|
|
7554
|
+
return void 0;
|
|
7555
|
+
const shared = sharedModel(deps);
|
|
7556
|
+
return shared ? { target: shared.target, key: /* @__PURE__ */ __name(() => shared.key, "key"), shared: shared.setting } : void 0;
|
|
7557
|
+
}, "purposeModel");
|
|
7558
|
+
|
|
7559
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/replies/consents.js
|
|
7118
7560
|
import { existsSync as existsSync7, readFileSync as readFileSync4 } from "node:fs";
|
|
7119
7561
|
import { join as join4 } from "node:path";
|
|
7120
7562
|
var shape = strictObject({
|
|
@@ -7139,19 +7581,21 @@ var mayModelReply = /* @__PURE__ */ __name((path, provider, chat) => {
|
|
|
7139
7581
|
return consent.provider === provider && !consent.deniedChats.includes(chat);
|
|
7140
7582
|
}, "mayModelReply");
|
|
7141
7583
|
|
|
7142
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7584
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/replies/rendering.js
|
|
7143
7585
|
var replyRenderer = /* @__PURE__ */ __name((app, profile, settings, env, warn, options = {
|
|
7144
7586
|
ai: true
|
|
7145
7587
|
}) => async (rule2, message, chat, now) => {
|
|
7588
|
+
const deps = { app, env, keyring: options.keyring };
|
|
7146
7589
|
let called;
|
|
7147
7590
|
const gateway = modelGateway({
|
|
7148
7591
|
signal: options.signal,
|
|
7592
|
+
env,
|
|
7149
7593
|
resolve: /* @__PURE__ */ __name((purpose) => {
|
|
7150
|
-
called =
|
|
7151
|
-
return called;
|
|
7594
|
+
called = purposeModel(settings(), purpose, deps);
|
|
7595
|
+
return called?.target;
|
|
7152
7596
|
}, "resolve"),
|
|
7153
7597
|
consent: /* @__PURE__ */ __name((_request, target) => mayModelReply(replyConsentPathFor(app, profile, env), replyModelIdentity(target.provider, target.baseUrl ?? ""), message.chatId), "consent"),
|
|
7154
|
-
key: /* @__PURE__ */ __name((
|
|
7598
|
+
key: /* @__PURE__ */ __name(() => called?.key(), "key")
|
|
7155
7599
|
});
|
|
7156
7600
|
if (options.signal?.aborted)
|
|
7157
7601
|
throw new CliError("cancelled", "reply rendering cancelled");
|
|
@@ -7173,9 +7617,8 @@ var replyRenderer = /* @__PURE__ */ __name((app, profile, settings, env, warn, o
|
|
|
7173
7617
|
});
|
|
7174
7618
|
if (options.signal?.aborted)
|
|
7175
7619
|
throw new CliError("cancelled", "reply rendering cancelled");
|
|
7176
|
-
const current =
|
|
7177
|
-
|
|
7178
|
-
if (!called || JSON.stringify(current) !== JSON.stringify(called) || !mayModelReply(replyConsentPathFor(app, profile, env), replyModelIdentity(called.provider, baseUrl), message.chatId)) {
|
|
7620
|
+
const current = purposeModel(settings(), "replies", deps)?.target;
|
|
7621
|
+
if (!called || JSON.stringify(current) !== JSON.stringify(called.target) || !mayModelReply(replyConsentPathFor(app, profile, env), replyModelIdentity(called.target.provider, called.target.baseUrl), message.chatId)) {
|
|
7179
7622
|
throw new CliError("permission_error", "reply model consent or configuration changed during rendering");
|
|
7180
7623
|
}
|
|
7181
7624
|
return result3;
|
|
@@ -7186,7 +7629,7 @@ var replyRenderer = /* @__PURE__ */ __name((app, profile, settings, env, warn, o
|
|
|
7186
7629
|
return result2;
|
|
7187
7630
|
}, "replyRenderer");
|
|
7188
7631
|
|
|
7189
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7632
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/replies/serve.js
|
|
7190
7633
|
var NOT_ALLOWED = "replies.send is not allow";
|
|
7191
7634
|
var NO_RULES = "no rules";
|
|
7192
7635
|
var ONLY_TASK = "opened a task, sent nothing";
|
|
@@ -7279,7 +7722,7 @@ var replyTo = /* @__PURE__ */ __name(async (deps, message) => {
|
|
|
7279
7722
|
return { skip: why };
|
|
7280
7723
|
}, "replyTo");
|
|
7281
7724
|
|
|
7282
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7725
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-catch-up.js
|
|
7283
7726
|
var START_SYNC_DELAY_MS = 3e4;
|
|
7284
7727
|
var START_SYNC_BUDGET_MS = 5 * 6e4;
|
|
7285
7728
|
var START_SYNC_WINDOW_MS = 7 * 864e5;
|
|
@@ -7356,7 +7799,7 @@ var startSync = /* @__PURE__ */ __name(({ chats, newestHeld, fetch, note, warn,
|
|
|
7356
7799
|
};
|
|
7357
7800
|
}, "startSync");
|
|
7358
7801
|
|
|
7359
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7802
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-members.js
|
|
7360
7803
|
var FIRST_FETCH_MS = 6e4;
|
|
7361
7804
|
var DAY_MS = 864e5;
|
|
7362
7805
|
var memberFetches = /* @__PURE__ */ __name(({ withStore, fetch, warn, firstMs = FIRST_FETCH_MS, everyMs = DAY_MS }) => {
|
|
@@ -7410,7 +7853,7 @@ var memberFetches = /* @__PURE__ */ __name(({ withStore, fetch, warn, firstMs =
|
|
|
7410
7853
|
};
|
|
7411
7854
|
}, "memberFetches");
|
|
7412
7855
|
|
|
7413
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7856
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-notice.js
|
|
7414
7857
|
var record2 = /* @__PURE__ */ __name((context, app, severity, attributes) => recordLogFor(context.streams.diagnostic, app, { command: currentRun().command || "serve" })[severity](attributes), "record");
|
|
7415
7858
|
var noticeFor = /* @__PURE__ */ __name((context, app, severity = "warn") => ({ text, ...attributes }) => {
|
|
7416
7859
|
if (context.format === "pretty") {
|
|
@@ -7443,7 +7886,93 @@ var recordDiagnostics = /* @__PURE__ */ __name((context, app) => {
|
|
|
7443
7886
|
return context;
|
|
7444
7887
|
}, "recordDiagnostics");
|
|
7445
7888
|
|
|
7446
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7889
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-outdated.js
|
|
7890
|
+
import { existsSync as existsSync8, readFileSync as readFileSync5, realpathSync as realpathSync2 } from "node:fs";
|
|
7891
|
+
import { dirname as dirname2, join as join5 } from "node:path";
|
|
7892
|
+
var OUTDATED_CHECK_MS = 6e4;
|
|
7893
|
+
var ownPackageRoot = /* @__PURE__ */ __name((running, script = process.argv[1]) => {
|
|
7894
|
+
let dir;
|
|
7895
|
+
try {
|
|
7896
|
+
dir = dirname2(realpathSync2(script ?? ""));
|
|
7897
|
+
} catch {
|
|
7898
|
+
return void 0;
|
|
7899
|
+
}
|
|
7900
|
+
for (let up = 0; up < 8; up++) {
|
|
7901
|
+
const manifest = join5(dir, "package.json");
|
|
7902
|
+
if (existsSync8(manifest))
|
|
7903
|
+
return installedVersion(dir) === running ? dir : void 0;
|
|
7904
|
+
const parent = dirname2(dir);
|
|
7905
|
+
if (parent === dir)
|
|
7906
|
+
return void 0;
|
|
7907
|
+
dir = parent;
|
|
7908
|
+
}
|
|
7909
|
+
return void 0;
|
|
7910
|
+
}, "ownPackageRoot");
|
|
7911
|
+
var installedVersion = /* @__PURE__ */ __name((root) => {
|
|
7912
|
+
try {
|
|
7913
|
+
const { version } = JSON.parse(readFileSync5(join5(root, "package.json"), "utf8"));
|
|
7914
|
+
return typeof version === "string" ? version : void 0;
|
|
7915
|
+
} catch {
|
|
7916
|
+
return void 0;
|
|
7917
|
+
}
|
|
7918
|
+
}, "installedVersion");
|
|
7919
|
+
var newer = /* @__PURE__ */ __name((one, other) => {
|
|
7920
|
+
const parts = /* @__PURE__ */ __name((version) => version.split(/[.+-]/, 3).map(Number), "parts");
|
|
7921
|
+
const [a, b] = [parts(one), parts(other)];
|
|
7922
|
+
for (let i = 0; i < 3; i++)
|
|
7923
|
+
if ((a[i] ?? 0) !== (b[i] ?? 0))
|
|
7924
|
+
return (a[i] ?? 0) > (b[i] ?? 0);
|
|
7925
|
+
return false;
|
|
7926
|
+
}, "newer");
|
|
7927
|
+
var outdatedReason = /* @__PURE__ */ __name(async ({ command, running, storePath: storePath2, packageRoot, speaks = SPEAKS }) => {
|
|
7928
|
+
const installed = packageRoot === void 0 ? void 0 : installedVersion(packageRoot);
|
|
7929
|
+
if (installed !== void 0 && newer(installed, running))
|
|
7930
|
+
return `${command} ${installed} is installed and this serve runs ${running}: stopping so it starts again on ${installed}`;
|
|
7931
|
+
if (!existsSync8(storePath2))
|
|
7932
|
+
return void 0;
|
|
7933
|
+
let schema;
|
|
7934
|
+
try {
|
|
7935
|
+
const { database } = await openSqlite(storePath2, { readOnly: true });
|
|
7936
|
+
try {
|
|
7937
|
+
schema = fileSchemaOf(database);
|
|
7938
|
+
} finally {
|
|
7939
|
+
database.close();
|
|
7940
|
+
}
|
|
7941
|
+
} catch {
|
|
7942
|
+
return void 0;
|
|
7943
|
+
}
|
|
7944
|
+
if (writableBy(schema, speaks))
|
|
7945
|
+
return void 0;
|
|
7946
|
+
return `the store is at format ${schema.version} and needs at least ${schema.minCompatible}; this serve (${command} ${running}) speaks ${speaks} and can no longer write it: stopping \u2014 \`${command} upgrade\` if it does not start again on a newer version`;
|
|
7947
|
+
}, "outdatedReason");
|
|
7948
|
+
var watchOutdated = /* @__PURE__ */ __name(({ check: check2, onOutdated, everyMs = OUTDATED_CHECK_MS }) => {
|
|
7949
|
+
let busy = false;
|
|
7950
|
+
let done = false;
|
|
7951
|
+
const timer = setInterval(() => {
|
|
7952
|
+
if (busy || done)
|
|
7953
|
+
return;
|
|
7954
|
+
busy = true;
|
|
7955
|
+
check2().then((reason) => {
|
|
7956
|
+
if (reason === void 0 || done)
|
|
7957
|
+
return;
|
|
7958
|
+
done = true;
|
|
7959
|
+
clearInterval(timer);
|
|
7960
|
+
onOutdated(reason);
|
|
7961
|
+
}).catch(() => {
|
|
7962
|
+
}).finally(() => {
|
|
7963
|
+
busy = false;
|
|
7964
|
+
});
|
|
7965
|
+
}, everyMs);
|
|
7966
|
+
timer.unref();
|
|
7967
|
+
return {
|
|
7968
|
+
stop: /* @__PURE__ */ __name(() => {
|
|
7969
|
+
done = true;
|
|
7970
|
+
clearInterval(timer);
|
|
7971
|
+
}, "stop")
|
|
7972
|
+
};
|
|
7973
|
+
}, "watchOutdated");
|
|
7974
|
+
|
|
7975
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-stems.js
|
|
7447
7976
|
var STEMS_EVERY_MS = 3e4;
|
|
7448
7977
|
var STEMS_SLICE_MS = 2e3;
|
|
7449
7978
|
var stemFills = /* @__PURE__ */ __name(({ withStore, warn, everyMs = STEMS_EVERY_MS, sliceMs = STEMS_SLICE_MS }) => {
|
|
@@ -7483,7 +8012,7 @@ var stemFills = /* @__PURE__ */ __name(({ withStore, warn, everyMs = STEMS_EVERY
|
|
|
7483
8012
|
};
|
|
7484
8013
|
}, "stemFills");
|
|
7485
8014
|
|
|
7486
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
8015
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/cli/messenger/message-items.js
|
|
7487
8016
|
var defined = /* @__PURE__ */ __name((value) => Object.fromEntries(Object.entries(value).filter(([, one]) => one !== void 0)), "defined");
|
|
7488
8017
|
var attachmentItem = /* @__PURE__ */ __name((attachment) => defined({
|
|
7489
8018
|
kind: attachment.kind,
|
|
@@ -7495,6 +8024,7 @@ var attachmentItem = /* @__PURE__ */ __name((attachment) => defined({
|
|
|
7495
8024
|
width: attachment.width,
|
|
7496
8025
|
height: attachment.height,
|
|
7497
8026
|
duration: attachment.duration,
|
|
8027
|
+
local_path: attachment.localPath,
|
|
7498
8028
|
contact: attachment.contact && defined({
|
|
7499
8029
|
name: attachment.contact.name,
|
|
7500
8030
|
first_name: attachment.contact.firstName,
|
|
@@ -7502,7 +8032,7 @@ var attachmentItem = /* @__PURE__ */ __name((attachment) => defined({
|
|
|
7502
8032
|
phone: attachment.contact.phone,
|
|
7503
8033
|
user_id: attachment.contact.userId
|
|
7504
8034
|
}),
|
|
7505
|
-
buttons: attachment.buttons
|
|
8035
|
+
buttons: attachment.buttons?.map((row) => row.map(({ data: _data, ...button }) => button))
|
|
7506
8036
|
}), "attachmentItem");
|
|
7507
8037
|
var quotedItem = /* @__PURE__ */ __name((quoted) => quoted === null ? null : {
|
|
7508
8038
|
id: quoted.id,
|
|
@@ -7578,7 +8108,7 @@ var viewOf = /* @__PURE__ */ __name((context, messenger) => ({
|
|
|
7578
8108
|
locale: messenger.app.locale
|
|
7579
8109
|
}), "viewOf");
|
|
7580
8110
|
|
|
7581
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
8111
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/cli/messenger/watch-answers.js
|
|
7582
8112
|
var observed = /* @__PURE__ */ __name((value) => ({
|
|
7583
8113
|
value: value.value,
|
|
7584
8114
|
observed_at: value.observedAt,
|
|
@@ -7645,7 +8175,7 @@ var watchEventItem = /* @__PURE__ */ __name((value, account) => {
|
|
|
7645
8175
|
}
|
|
7646
8176
|
}, "watchEventItem");
|
|
7647
8177
|
|
|
7648
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
8178
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/cli/messenger/watch-command.js
|
|
7649
8179
|
var watchCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("watch"), {
|
|
7650
8180
|
output: { entity: "watch_item" },
|
|
7651
8181
|
effects: REMOTE_READ,
|
|
@@ -7800,7 +8330,7 @@ var describe = /* @__PURE__ */ __name((event, render) => {
|
|
|
7800
8330
|
}
|
|
7801
8331
|
}, "describe");
|
|
7802
8332
|
|
|
7803
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
8333
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-command.js
|
|
7804
8334
|
var serveCommand = /* @__PURE__ */ __name((messenger) => {
|
|
7805
8335
|
const command = annotate(new Command("serve"), {
|
|
7806
8336
|
output: { entity: "serve_summary" },
|
|
@@ -7824,8 +8354,8 @@ var serveCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
7824
8354
|
}
|
|
7825
8355
|
let relaying;
|
|
7826
8356
|
const onReady = /* @__PURE__ */ __name(() => {
|
|
7827
|
-
const
|
|
7828
|
-
holdLock(path,
|
|
8357
|
+
const listening2 = { pid: process.pid, startedAt, version, listeningAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
8358
|
+
holdLock(path, listening2);
|
|
7829
8359
|
note({
|
|
7830
8360
|
code: "listening",
|
|
7831
8361
|
text: `listening for profile ${context.profile}, catching up on what arrived while it was down`
|
|
@@ -7834,7 +8364,7 @@ var serveCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
7834
8364
|
return;
|
|
7835
8365
|
relaying = relay.open(path, context.profile).then((address) => {
|
|
7836
8366
|
if (address)
|
|
7837
|
-
holdLock(path, { ...
|
|
8367
|
+
holdLock(path, { ...listening2, relay: address });
|
|
7838
8368
|
}).catch((error) => {
|
|
7839
8369
|
const errorCode = failureKey(error);
|
|
7840
8370
|
warn({ code: "relay_failed", errorCode, text: `commands cannot run through this serve: ${errorCode}` });
|
|
@@ -7843,7 +8373,7 @@ var serveCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
7843
8373
|
const counts = {};
|
|
7844
8374
|
const rules = replying(context, messenger, Date.parse(startedAt));
|
|
7845
8375
|
const tasks = tasking(context, warn);
|
|
7846
|
-
const { handled, startSyncDelayMs } = environmentOf(this);
|
|
8376
|
+
const { handled, startSyncDelayMs, outdated: outdatedHook } = environmentOf(this);
|
|
7847
8377
|
const count3 = /* @__PURE__ */ __name((event) => {
|
|
7848
8378
|
counts[event.event] = (counts[event.event] ?? 0) + 1;
|
|
7849
8379
|
if (event.event === "message") {
|
|
@@ -7915,9 +8445,25 @@ var serveCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
7915
8445
|
withStore: /* @__PURE__ */ __name((work) => context.withStore((store) => work(store), { name: "serve stems" }), "withStore"),
|
|
7916
8446
|
warn
|
|
7917
8447
|
});
|
|
8448
|
+
const listening = new AbortController();
|
|
8449
|
+
let outdated;
|
|
8450
|
+
const packageRoot = outdatedHook?.packageRoot ?? ownPackageRoot(version);
|
|
8451
|
+
const watch = watchOutdated({
|
|
8452
|
+
check: /* @__PURE__ */ __name(() => outdatedReason({
|
|
8453
|
+
command: messenger.app.command,
|
|
8454
|
+
running: version,
|
|
8455
|
+
storePath: storePath(context.env),
|
|
8456
|
+
packageRoot
|
|
8457
|
+
}), "check"),
|
|
8458
|
+
onOutdated: /* @__PURE__ */ __name((reason) => {
|
|
8459
|
+
outdated = reason;
|
|
8460
|
+
listening.abort();
|
|
8461
|
+
}, "onOutdated"),
|
|
8462
|
+
...outdatedHook?.everyMs === void 0 ? {} : { everyMs: outdatedHook.everyMs }
|
|
8463
|
+
});
|
|
7918
8464
|
try {
|
|
7919
8465
|
await listenUntilStopped(this, context, relay?.messenger ?? messenger, count3, {
|
|
7920
|
-
stop:
|
|
8466
|
+
stop: listening,
|
|
7921
8467
|
catchUp: true,
|
|
7922
8468
|
onReady,
|
|
7923
8469
|
connected: /* @__PURE__ */ __name((open) => {
|
|
@@ -7930,6 +8476,7 @@ var serveCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
7930
8476
|
}, "connected")
|
|
7931
8477
|
});
|
|
7932
8478
|
} finally {
|
|
8479
|
+
watch.stop();
|
|
7933
8480
|
await relaying;
|
|
7934
8481
|
await relay?.close();
|
|
7935
8482
|
rules.stop();
|
|
@@ -7940,6 +8487,8 @@ var serveCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
7940
8487
|
await tasks.settled();
|
|
7941
8488
|
releaseLock(path);
|
|
7942
8489
|
}
|
|
8490
|
+
if (outdated !== void 0)
|
|
8491
|
+
throw new CliError("configuration_error", outdated, { reason: "serve.outdated" });
|
|
7943
8492
|
renderAnswer(this, context, itemOf({
|
|
7944
8493
|
profile: context.profile,
|
|
7945
8494
|
started_at: startedAt,
|
|
@@ -8064,8 +8613,8 @@ var tasking = /* @__PURE__ */ __name((context, warn) => {
|
|
|
8064
8613
|
};
|
|
8065
8614
|
}, "tasking");
|
|
8066
8615
|
|
|
8067
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
8068
|
-
import { existsSync as
|
|
8616
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/cli/messenger/store-tables-command.js
|
|
8617
|
+
import { existsSync as existsSync9 } from "node:fs";
|
|
8069
8618
|
var PATH = "store tables list";
|
|
8070
8619
|
var STORE_TABLES_QUERY = {
|
|
8071
8620
|
entity: "store_table",
|
|
@@ -8081,20 +8630,20 @@ var filterOf = /* @__PURE__ */ __name((words) => {
|
|
|
8081
8630
|
const kind = terms.get("kind");
|
|
8082
8631
|
return { ...name === void 0 ? {} : { name }, ...kind === void 0 ? {} : { kind } };
|
|
8083
8632
|
}, "filterOf");
|
|
8084
|
-
var storeTablesCommand = /* @__PURE__ */ __name((
|
|
8085
|
-
const tables = new Command("tables").description("the tables of the local
|
|
8633
|
+
var storeTablesCommand = /* @__PURE__ */ __name((owner) => {
|
|
8634
|
+
const tables = new Command("tables").description("the tables of the local store");
|
|
8086
8635
|
withQuery(annotate(tables.command("list"), {
|
|
8087
8636
|
effects: LOCAL_READ,
|
|
8088
8637
|
examples: [
|
|
8089
|
-
`${
|
|
8090
|
-
`${
|
|
8091
|
-
`${
|
|
8638
|
+
`${owner.app.command} store tables list`,
|
|
8639
|
+
`${owner.app.command} store tables list kind:data`,
|
|
8640
|
+
`${owner.app.command} store tables list --full --json`
|
|
8092
8641
|
]
|
|
8093
8642
|
}), STORE_TABLES_QUERY).summary("every table of the local archive, with its kind and row count").description("every table of the local archive: its kind (data, search index, part of a search index, internal) and its rows, a search index's rows not counted; --full adds each table's size on disk, which reads the whole file (about ten seconds for 3 GB); changes nothing").action(async function(words) {
|
|
8094
8643
|
const filter = filterOf(words);
|
|
8095
8644
|
const { full } = this.optsWithGlobals();
|
|
8096
8645
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8097
|
-
if (!
|
|
8646
|
+
if (!existsSync9(path))
|
|
8098
8647
|
throw new CliError("not_found", `no store at ${path}`);
|
|
8099
8648
|
const items = await readStoreTables(path, { filter, sizes: full === true });
|
|
8100
8649
|
renderAnswer(this, outputFor(this), listOf(PATH, {
|
|
@@ -8107,7 +8656,7 @@ var storeTablesCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
8107
8656
|
return tables;
|
|
8108
8657
|
}, "storeTablesCommand");
|
|
8109
8658
|
|
|
8110
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
8659
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.647.0_@wirecat+cli-base@0.93.0_commander@15.0.0_esbuild@0.28.2_type_a46df5420a4458268e3f15f3e8c41b99/node_modules/@wirecat/cli-core/dist/cli/messenger/store-maintenance-command.js
|
|
8111
8660
|
var SEARCH_INDEXES = ["messages_fts", "chats_fts", "identities_fts"];
|
|
8112
8661
|
var WORD_INDEX = "message_words";
|
|
8113
8662
|
var schemaOf = /* @__PURE__ */ __name((database) => {
|
|
@@ -8116,7 +8665,7 @@ var schemaOf = /* @__PURE__ */ __name((database) => {
|
|
|
8116
8665
|
}, "schemaOf");
|
|
8117
8666
|
var count2 = /* @__PURE__ */ __name((database, table) => Number(database.prepare(`SELECT count(*) AS n FROM ${table}`).get()?.n ?? 0), "count");
|
|
8118
8667
|
var pendingIfKnown2 = /* @__PURE__ */ __name((database) => database.prepare("SELECT 1 FROM pragma_table_info('messages') WHERE name = 'normalized_text'").get() ? pendingNormalization(database) : null, "pendingIfKnown");
|
|
8119
|
-
var bytesOf2 = /* @__PURE__ */ __name((path) =>
|
|
8668
|
+
var bytesOf2 = /* @__PURE__ */ __name((path) => existsSync10(path) ? statSync4(path).size : 0, "bytesOf");
|
|
8120
8669
|
var reading = /* @__PURE__ */ __name(async (path, read) => {
|
|
8121
8670
|
const database = await openCache(path);
|
|
8122
8671
|
try {
|
|
@@ -8143,9 +8692,10 @@ var fileSchema = /* @__PURE__ */ __name(async (path) => {
|
|
|
8143
8692
|
}, "fileSchema");
|
|
8144
8693
|
var storeSummary = /* @__PURE__ */ __name(async (env, { deep = false, command, version } = {}) => {
|
|
8145
8694
|
const path = storePath(env);
|
|
8146
|
-
if (!
|
|
8695
|
+
if (!existsSync10(path))
|
|
8147
8696
|
return { path, exists: false };
|
|
8148
8697
|
const checked = await storeHealth(path, { deep });
|
|
8698
|
+
const journal = readJournalMark(path);
|
|
8149
8699
|
const recorded = deep ? recordDeepCheck(path, checked, {
|
|
8150
8700
|
cli: command ?? "unknown",
|
|
8151
8701
|
...version ? { version } : {},
|
|
@@ -8163,13 +8713,15 @@ var storeSummary = /* @__PURE__ */ __name(async (env, { deep = false, command, v
|
|
|
8163
8713
|
...checked.invalidJson?.length ? { invalidJson: checked.invalidJson } : {},
|
|
8164
8714
|
...checked.searchIndexes?.some((index) => !index.ok) ? { damagedSearchIndexes: checked.searchIndexes.filter((index) => !index.ok).map((index) => index.name) } : {}
|
|
8165
8715
|
};
|
|
8166
|
-
const damage = command ?
|
|
8716
|
+
const damage = command ? storeDamageReport({ health: checked, command, mark, journal, lastOkAt: lastKnownGood }) : null;
|
|
8167
8717
|
const healthOf = {
|
|
8168
8718
|
health,
|
|
8169
8719
|
lastKnownGood,
|
|
8170
8720
|
...mark ? { damageMark: withoutInode(mark) } : {},
|
|
8721
|
+
...journal ? { journalMark: journal } : {},
|
|
8171
8722
|
...recorded?.cleared ? { damageMarkCleared: withoutInode(recorded.cleared) } : {},
|
|
8172
|
-
|
|
8723
|
+
// `what` keeps memo's doctor, which reads it, compiling until it moves to `whatHappened`.
|
|
8724
|
+
...damage ? { damage: { what: damage.whatHappened, ...damage } } : {}
|
|
8173
8725
|
};
|
|
8174
8726
|
try {
|
|
8175
8727
|
return await reading(path, (database) => {
|
|
@@ -8189,42 +8741,67 @@ var storeSummary = /* @__PURE__ */ __name(async (env, { deep = false, command, v
|
|
|
8189
8741
|
}
|
|
8190
8742
|
}, "storeSummary");
|
|
8191
8743
|
var result = /* @__PURE__ */ __name((command, value, next = []) => renderAnswer(command, outputFor(command), itemOf(snakeKeys(value), { next })), "result");
|
|
8192
|
-
var
|
|
8744
|
+
var chatty = /* @__PURE__ */ __name((owner) => owner.provider !== void 0, "chatty");
|
|
8745
|
+
var archive = /* @__PURE__ */ __name((owner) => chatty(owner) ? "local archive" : "local store", "archive");
|
|
8746
|
+
var createdBy = /* @__PURE__ */ __name((owner) => chatty(owner) ? `the first \`${owner.app.command}\` command that reads a chat creates it` : `the first \`${owner.app.command}\` command that saves anything creates it`, "createdBy");
|
|
8747
|
+
var storeMaintenanceCommands = /* @__PURE__ */ __name((owner) => [
|
|
8193
8748
|
storeInfoCommand(),
|
|
8194
|
-
checkCommand(
|
|
8195
|
-
migrateCommand(
|
|
8196
|
-
reindexCommand(
|
|
8749
|
+
checkCommand(owner),
|
|
8750
|
+
migrateCommand(owner),
|
|
8751
|
+
reindexCommand(owner),
|
|
8197
8752
|
backupCommand(),
|
|
8198
|
-
restoreCommand(
|
|
8753
|
+
restoreCommand(owner),
|
|
8199
8754
|
decryptCommand(),
|
|
8200
|
-
repairCommand(
|
|
8201
|
-
resetCommand(
|
|
8755
|
+
repairCommand(owner),
|
|
8756
|
+
resetCommand(owner),
|
|
8202
8757
|
copiesCommand(),
|
|
8203
|
-
storeTablesCommand(
|
|
8204
|
-
storeRecoverCommand({ command:
|
|
8758
|
+
storeTablesCommand(owner),
|
|
8759
|
+
storeRecoverCommand({ command: owner.app.command, version: owner.app.version })
|
|
8205
8760
|
], "storeMaintenanceCommands");
|
|
8206
|
-
var
|
|
8207
|
-
|
|
8761
|
+
var EXAMPLES = {
|
|
8762
|
+
backup: "./backup.db",
|
|
8763
|
+
check: "",
|
|
8764
|
+
"copies delete": "messages_copy_1",
|
|
8765
|
+
decrypt: "./backup.enc --output ./restored.db",
|
|
8766
|
+
info: "",
|
|
8767
|
+
migrate: "",
|
|
8768
|
+
rebuild: "",
|
|
8769
|
+
repair: "--dry-run",
|
|
8770
|
+
reset: "",
|
|
8771
|
+
restore: "./backup.db"
|
|
8772
|
+
};
|
|
8773
|
+
var addStoreMaintenanceCommands = /* @__PURE__ */ __name((store, owner, profile) => {
|
|
8774
|
+
for (const command of storeMaintenanceCommands(owner))
|
|
8775
|
+
store.addCommand(command);
|
|
8776
|
+
for (const [path, args] of Object.entries(EXAMPLES)) {
|
|
8777
|
+
const command = commandAt(store, path);
|
|
8778
|
+
if (command)
|
|
8779
|
+
annotate(command, { examples: [`${owner.app.command} ${profile} store ${path} ${args}`.trimEnd()] });
|
|
8780
|
+
}
|
|
8781
|
+
return store;
|
|
8782
|
+
}, "addStoreMaintenanceCommands");
|
|
8783
|
+
var refuseWhileServing = /* @__PURE__ */ __name((command, owner) => {
|
|
8784
|
+
const serving = servingProfiles(owner.app, environmentOf(command).env ?? process.env);
|
|
8208
8785
|
if (serving.length > 0) {
|
|
8209
|
-
throw new CliError("validation_error", `${
|
|
8786
|
+
throw new CliError("validation_error", `${owner.app.command} serve is running for ${serving.join(", ")} \u2014 ${serving.map((profile) => `\`${owner.app.command} ${profile} server stop\``).join(", ")} first`);
|
|
8210
8787
|
}
|
|
8211
8788
|
}, "refuseWhileServing");
|
|
8212
|
-
var repairCommand = /* @__PURE__ */ __name((
|
|
8789
|
+
var repairCommand = /* @__PURE__ */ __name((owner) => annotate(new Command("repair"), { output: { entity: "store_repair" }, effects: LOCAL_WRITE }).summary("repair table shapes while keeping the old tables").description("bring every table to this build's shape, deleting nothing: a table of the wrong shape is kept as a copy beside a new one").option("--dry-run", "say what it would do, and change nothing").action(async function() {
|
|
8213
8790
|
const { renderer, format } = outputFor(this);
|
|
8214
8791
|
const { dryRun: dryRun2 } = this.opts();
|
|
8215
8792
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8216
|
-
if (!
|
|
8793
|
+
if (!existsSync10(path)) {
|
|
8217
8794
|
result(this, { path, exists: false });
|
|
8218
8795
|
return;
|
|
8219
8796
|
}
|
|
8220
8797
|
if (!dryRun2)
|
|
8221
|
-
refuseWhileServing(this,
|
|
8798
|
+
refuseWhileServing(this, owner);
|
|
8222
8799
|
const fresh = await openCache(":memory:");
|
|
8223
8800
|
try {
|
|
8224
8801
|
const report = await reading(path, (database) => repairStore(database, fresh, { dryRun: dryRun2 === true }));
|
|
8225
8802
|
result(this, { path, ...report });
|
|
8226
8803
|
if (format === "pretty")
|
|
8227
|
-
for (const note of notesOf(report,
|
|
8804
|
+
for (const note of notesOf(report, owner.app.command))
|
|
8228
8805
|
renderer.note(note);
|
|
8229
8806
|
} finally {
|
|
8230
8807
|
fresh.close();
|
|
@@ -8253,15 +8830,15 @@ var notesOf = /* @__PURE__ */ __name((report, command) => {
|
|
|
8253
8830
|
}, "notesOf");
|
|
8254
8831
|
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) {
|
|
8255
8832
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8256
|
-
if (!
|
|
8833
|
+
if (!existsSync10(path))
|
|
8257
8834
|
throw new CliError("not_found", `no store at ${path}`);
|
|
8258
8835
|
const deleted = await reading(path, (database) => deleteCopy(database, name));
|
|
8259
8836
|
result(this, { path, deleted });
|
|
8260
8837
|
})), "copiesCommand");
|
|
8261
|
-
var checkCommand = /* @__PURE__ */ __name((
|
|
8838
|
+
var checkCommand = /* @__PURE__ */ __name((owner) => annotate(new Command("check"), { output: { entity: "store_check" }, effects: LOCAL_READ }).summary(`check the ${archive(owner)} for problems`).description(`whether the store is healthy \u2014 integrity, search indexes, disk${chatty(owner) ? ", and which chats are behind" : ""}`).action(async function() {
|
|
8262
8839
|
const { renderer } = outputFor(this);
|
|
8263
8840
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8264
|
-
if (!
|
|
8841
|
+
if (!existsSync10(path)) {
|
|
8265
8842
|
result(this, { path, exists: false, ok: true });
|
|
8266
8843
|
return;
|
|
8267
8844
|
}
|
|
@@ -8272,7 +8849,7 @@ var checkCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("c
|
|
|
8272
8849
|
result(this, { path, exists: true, ok: false, opens: false, error: messageOf2(error) });
|
|
8273
8850
|
return;
|
|
8274
8851
|
}
|
|
8275
|
-
const { command } =
|
|
8852
|
+
const { command } = owner.app;
|
|
8276
8853
|
const next = /* @__PURE__ */ new Map();
|
|
8277
8854
|
const step = /* @__PURE__ */ __name((id, args = {}) => {
|
|
8278
8855
|
if (!next.has(id))
|
|
@@ -8288,10 +8865,10 @@ var checkCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("c
|
|
|
8288
8865
|
step("store.reindex");
|
|
8289
8866
|
else if (stems && !stems.ready)
|
|
8290
8867
|
step("store.migrate");
|
|
8291
|
-
const behind = answer.chatsBehind.find((chat) => chat.provider ===
|
|
8292
|
-
if (behind &&
|
|
8868
|
+
const behind = answer.chatsBehind.find((chat) => chat.provider === owner.provider);
|
|
8869
|
+
if (behind && owner.history !== "store")
|
|
8293
8870
|
step("messages.sync");
|
|
8294
|
-
else if (behind && syncsOneChat(
|
|
8871
|
+
else if (behind && syncsOneChat(owner))
|
|
8295
8872
|
step("messages.sync", { chat: behind.chat });
|
|
8296
8873
|
result(this, answer, [...next.values()]);
|
|
8297
8874
|
if (answer.schema.version < SPEAKS) {
|
|
@@ -8306,7 +8883,7 @@ var checkCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("c
|
|
|
8306
8883
|
renderer.note(`${orphans} pointers name a row that is gone or a type the store does not know \u2014 see orphan_pointers`);
|
|
8307
8884
|
if (answer.vectors && answer.vectors.unused > 0)
|
|
8308
8885
|
renderer.note(`${answer.vectors.unused} vectors belong to no text the store still holds \u2014 \`${command} store rebuild\` drops them`);
|
|
8309
|
-
const older = answer.conversations.filter((chat) => chat.provider ===
|
|
8886
|
+
const older = answer.conversations.filter((chat) => chat.provider === owner.provider && !chat.current).length;
|
|
8310
8887
|
if (older > 0) {
|
|
8311
8888
|
renderer.note(`${older} chats' conversations were built by older rules \u2014 \`${command} conversations links rebuild --chat <chat>\``);
|
|
8312
8889
|
}
|
|
@@ -8324,7 +8901,7 @@ var inspect = /* @__PURE__ */ __name((path) => reading(path, (database) => {
|
|
|
8324
8901
|
...schema.version > 0 ? [["attachment_words", indexIntegrity(database, "attachment_words", 0)]] : []
|
|
8325
8902
|
]);
|
|
8326
8903
|
const size = bytesOf2(path) + bytesOf2(`${path}-wal`);
|
|
8327
|
-
const { bavail, bsize } = statfsSync2(
|
|
8904
|
+
const { bavail, bsize } = statfsSync2(dirname3(path));
|
|
8328
8905
|
const free = Number(bavail) * Number(bsize);
|
|
8329
8906
|
const behind = schema.version > 0 ? chatsBehind(database) : [];
|
|
8330
8907
|
const vectorIndexes = schema.version >= 34 ? vectorIndexCounts(database) : [];
|
|
@@ -8409,19 +8986,19 @@ var chatsBehind = /* @__PURE__ */ __name((database) => database.prepare(`SELECT
|
|
|
8409
8986
|
held: row.held === null ? null : isoOf(row.held),
|
|
8410
8987
|
refreshed: isoOf(row.refreshed)
|
|
8411
8988
|
})), "chatsBehind");
|
|
8412
|
-
var migrateCommand = /* @__PURE__ */ __name((
|
|
8989
|
+
var migrateCommand = /* @__PURE__ */ __name((owner) => annotate(new Command("migrate"), { output: { entity: "store_migration" }, effects: LOCAL_WRITE }).summary(`migrate an older ${archive(owner)}`).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() {
|
|
8413
8990
|
const { renderer } = outputFor(this);
|
|
8414
8991
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8415
|
-
if (!
|
|
8992
|
+
if (!existsSync10(path)) {
|
|
8416
8993
|
result(this, { path, exists: false });
|
|
8417
|
-
renderer.note(`no store yet \u2014
|
|
8994
|
+
renderer.note(`no store yet \u2014 ${createdBy(owner)}`);
|
|
8418
8995
|
return;
|
|
8419
8996
|
}
|
|
8420
8997
|
const answer = await reading(path, (database) => {
|
|
8421
8998
|
const from = schemaOf(database).version;
|
|
8422
8999
|
migrate(database, {
|
|
8423
|
-
command:
|
|
8424
|
-
version:
|
|
9000
|
+
command: owner.app.command,
|
|
9001
|
+
version: owner.app.version,
|
|
8425
9002
|
rollback: { store: path, warn: /* @__PURE__ */ __name((line) => renderer.warn(line), "warn") }
|
|
8426
9003
|
});
|
|
8427
9004
|
const { normalized, indexed, terms } = buildWordIndex(database, (note) => renderer.note(note));
|
|
@@ -8473,10 +9050,10 @@ var buildNoteIndex = /* @__PURE__ */ __name((database, note, { reset = false } =
|
|
|
8473
9050
|
note(`indexing ${pending} notes`);
|
|
8474
9051
|
return { notesIndexed: drainNoteIndex(database, stemmerCache()) };
|
|
8475
9052
|
}, "buildNoteIndex");
|
|
8476
|
-
var reindexCommand = /* @__PURE__ */ __name((
|
|
9053
|
+
var reindexCommand = /* @__PURE__ */ __name((owner) => destroysNothing(annotate(new Command("rebuild"), { output: { entity: "store_reindex" }, effects: LOCAL_WRITE })).summary(`rebuild the ${archive(owner)}'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() {
|
|
8477
9054
|
const { renderer } = outputFor(this);
|
|
8478
9055
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8479
|
-
if (!
|
|
9056
|
+
if (!existsSync10(path)) {
|
|
8480
9057
|
result(this, { path, exists: false });
|
|
8481
9058
|
return;
|
|
8482
9059
|
}
|
|
@@ -8518,9 +9095,12 @@ var backupCommand = /* @__PURE__ */ __name(() => destroysNothing(annotate(new Co
|
|
|
8518
9095
|
const { encrypt } = this.opts();
|
|
8519
9096
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8520
9097
|
const target = resolve(file2);
|
|
8521
|
-
|
|
9098
|
+
const { app, env } = environmentOf(this);
|
|
9099
|
+
if (app)
|
|
9100
|
+
refuseLockedOutput(target, app, env ?? process.env, "<file>");
|
|
9101
|
+
if (!existsSync10(path))
|
|
8522
9102
|
throw new CliError("not_found", `no store at ${path} to back up`);
|
|
8523
|
-
if (
|
|
9103
|
+
if (existsSync10(target))
|
|
8524
9104
|
throw new CliError("validation_error", `${target} exists \u2014 a backup never overwrites a file`);
|
|
8525
9105
|
const password = encrypt ? await passwordOf(this, { twice: true }) : void 0;
|
|
8526
9106
|
const copyAt = password === void 0 ? target : `${path}.backup-${process.pid}`;
|
|
@@ -8553,55 +9133,55 @@ var decryptCommand = /* @__PURE__ */ __name(() => annotate(new Command("decrypt"
|
|
|
8553
9133
|
const { output } = this.opts();
|
|
8554
9134
|
const from = resolve(file2);
|
|
8555
9135
|
const to = resolve(output);
|
|
8556
|
-
if (!
|
|
9136
|
+
if (!existsSync10(from))
|
|
8557
9137
|
throw new CliError("not_found", `no file at ${from}`);
|
|
8558
9138
|
if (!isSealed(from))
|
|
8559
9139
|
throw new CliError("validation_error", `${from} was not written with --encrypt`);
|
|
8560
|
-
if (
|
|
9140
|
+
if (existsSync10(to))
|
|
8561
9141
|
throw new CliError("validation_error", `${to} exists \u2014 never overwritten`);
|
|
8562
9142
|
await unsealFile(from, to, await passwordOf(this, { twice: false }));
|
|
8563
9143
|
result(this, { path: to, from, bytes: bytesOf2(to) });
|
|
8564
9144
|
}), "decryptCommand");
|
|
8565
|
-
var restoreCommand = /* @__PURE__ */ __name((
|
|
9145
|
+
var restoreCommand = /* @__PURE__ */ __name((owner) => 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) {
|
|
8566
9146
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8567
9147
|
const given = resolve(file2);
|
|
8568
|
-
if (!
|
|
9148
|
+
if (!existsSync10(given))
|
|
8569
9149
|
throw new CliError("not_found", `no file at ${given}`);
|
|
8570
|
-
refuseWhileServing(this,
|
|
9150
|
+
refuseWhileServing(this, owner);
|
|
8571
9151
|
if (!isSealed(given))
|
|
8572
|
-
return restoreFrom(this,
|
|
9152
|
+
return restoreFrom(this, owner, given, given);
|
|
8573
9153
|
const opened = `${path}.unsealing-${process.pid}`;
|
|
8574
|
-
mkdirSync(
|
|
9154
|
+
mkdirSync(dirname3(path), { recursive: true, mode: 448 });
|
|
8575
9155
|
try {
|
|
8576
9156
|
await unsealFile(given, opened, await passwordOf(this, { twice: false }));
|
|
8577
|
-
await restoreFrom(this,
|
|
9157
|
+
await restoreFrom(this, owner, opened, given);
|
|
8578
9158
|
} finally {
|
|
8579
9159
|
rmSync3(opened, { force: true });
|
|
8580
9160
|
}
|
|
8581
9161
|
}), "restoreCommand");
|
|
8582
|
-
var restoreFrom = /* @__PURE__ */ __name(async (command,
|
|
9162
|
+
var restoreFrom = /* @__PURE__ */ __name(async (command, owner, backup, given) => {
|
|
8583
9163
|
const { renderer } = outputFor(command);
|
|
8584
9164
|
const path = storePath(environmentOf(command).env ?? process.env);
|
|
8585
|
-
if (
|
|
9165
|
+
if (existsSync10(path) && realpathSync3(backup) === realpathSync3(path)) {
|
|
8586
9166
|
throw new CliError("validation_error", `${backup} is the store itself`);
|
|
8587
9167
|
}
|
|
8588
9168
|
if (await isRollbackCopy(backup))
|
|
8589
|
-
return rollBackFrom(command,
|
|
9169
|
+
return rollBackFrom(command, owner, backup);
|
|
8590
9170
|
const schema = await backupSchema(backup);
|
|
8591
9171
|
const stamp = stampNow();
|
|
8592
|
-
const kept =
|
|
9172
|
+
const kept = existsSync10(path) ? `${path}.before-restore-${stamp}` : null;
|
|
8593
9173
|
if (kept) {
|
|
8594
9174
|
const waitMs = environmentOf(command).storeLockWaitMs;
|
|
8595
|
-
await quiesce(path,
|
|
9175
|
+
await quiesce(path, owner, "restore", (message) => renderer.warn(message), waitMs);
|
|
8596
9176
|
} else
|
|
8597
|
-
mkdirSync(
|
|
9177
|
+
mkdirSync(dirname3(path), { recursive: true, mode: 448 });
|
|
8598
9178
|
const incoming = `${path}.restoring-${stamp}`;
|
|
8599
9179
|
copyFileSync(backup, incoming, constants.COPYFILE_EXCL);
|
|
8600
9180
|
chmodSync(incoming, 384);
|
|
8601
9181
|
if (kept) {
|
|
8602
9182
|
renameSync3(path, kept);
|
|
8603
9183
|
for (const suffix of ["-wal", "-shm"])
|
|
8604
|
-
if (
|
|
9184
|
+
if (existsSync10(`${path}${suffix}`))
|
|
8605
9185
|
renameSync3(`${path}${suffix}`, `${kept}${suffix}`);
|
|
8606
9186
|
}
|
|
8607
9187
|
renameSync3(incoming, path);
|
|
@@ -8620,13 +9200,13 @@ var isRollbackCopy = /* @__PURE__ */ __name(async (file2) => {
|
|
|
8620
9200
|
return false;
|
|
8621
9201
|
}
|
|
8622
9202
|
}, "isRollbackCopy");
|
|
8623
|
-
var rollBackFrom = /* @__PURE__ */ __name(async (command,
|
|
9203
|
+
var rollBackFrom = /* @__PURE__ */ __name(async (command, owner, copy) => {
|
|
8624
9204
|
const { renderer } = outputFor(command);
|
|
8625
9205
|
const path = storePath(environmentOf(command).env ?? process.env);
|
|
8626
|
-
if (!
|
|
9206
|
+
if (!existsSync10(path))
|
|
8627
9207
|
throw new CliError("not_found", `no store at ${path} to roll back`);
|
|
8628
9208
|
const waitMs = environmentOf(command).storeLockWaitMs;
|
|
8629
|
-
await quiesce(path,
|
|
9209
|
+
await quiesce(path, owner, "restore", (message) => renderer.warn(message), waitMs);
|
|
8630
9210
|
const { database } = await openSqlite(path);
|
|
8631
9211
|
let rolled;
|
|
8632
9212
|
try {
|
|
@@ -8671,9 +9251,9 @@ var backupSchema = /* @__PURE__ */ __name(async (backup) => {
|
|
|
8671
9251
|
return schema;
|
|
8672
9252
|
}, "backupSchema");
|
|
8673
9253
|
var STORE_LOCK_WAIT_MS = 1e3;
|
|
8674
|
-
var quiesce = /* @__PURE__ */ __name(async (path,
|
|
8675
|
-
const { command } =
|
|
8676
|
-
const files = [path, `${path}-wal`, `${path}-shm`].filter((file2) =>
|
|
9254
|
+
var quiesce = /* @__PURE__ */ __name(async (path, owner, then, warn, waitMs = STORE_LOCK_WAIT_MS) => {
|
|
9255
|
+
const { command } = owner.app;
|
|
9256
|
+
const files = [path, `${path}-wal`, `${path}-shm`].filter((file2) => existsSync10(file2)).map((file2) => realpathSync3(file2));
|
|
8677
9257
|
const holders = holdersOf(files);
|
|
8678
9258
|
if (holders === void 0) {
|
|
8679
9259
|
warn(`this system cannot say which processes have the store open \u2014 restart every running serve and mcp after this`);
|
|
@@ -8694,21 +9274,21 @@ var quiesce = /* @__PURE__ */ __name(async (path, messenger, then, warn, waitMs
|
|
|
8694
9274
|
database.close();
|
|
8695
9275
|
}
|
|
8696
9276
|
}, "quiesce");
|
|
8697
|
-
var resetCommand = /* @__PURE__ */ __name((
|
|
9277
|
+
var resetCommand = /* @__PURE__ */ __name((owner) => annotate(new Command("reset"), { output: { entity: "store_reset" }, effects: LOCAL_WRITE }).summary(`back up the ${archive(owner)} and replace it with an empty one`).description("back the store up beside itself, then delete it and start an empty one at this build's schema; asks first, or --yes").option("--no-backup", "delete the store without backing it up first").option("--dry-run", "list every table it would empty, with its rows, and delete nothing").action(async function({ backup: keep, dryRun: dryRun2 }) {
|
|
8698
9278
|
const { renderer } = outputFor(this);
|
|
8699
|
-
const { command } =
|
|
9279
|
+
const { command } = owner.app;
|
|
8700
9280
|
const env = environmentOf(this).env ?? process.env;
|
|
8701
9281
|
const path = storePath(env);
|
|
8702
|
-
if (!
|
|
9282
|
+
if (!existsSync10(path)) {
|
|
8703
9283
|
result(this, { path, exists: false, reset: false });
|
|
8704
|
-
renderer.note(`no store at ${path} \u2014 nothing to reset;
|
|
9284
|
+
renderer.note(`no store at ${path} \u2014 nothing to reset; ${createdBy(owner)}`);
|
|
8705
9285
|
return;
|
|
8706
9286
|
}
|
|
8707
9287
|
if (dryRun2) {
|
|
8708
|
-
result(this, await resetPreview(path,
|
|
9288
|
+
result(this, await resetPreview(path, owner, env, keep));
|
|
8709
9289
|
return;
|
|
8710
9290
|
}
|
|
8711
|
-
refuseWhileServing(this,
|
|
9291
|
+
refuseWhileServing(this, owner);
|
|
8712
9292
|
if (this.optsWithGlobals().yes !== true) {
|
|
8713
9293
|
const what = `this deletes the store at ${path} and starts an empty one, ${keep ? "after a backup beside it" : "with no backup"}`;
|
|
8714
9294
|
const answer = await answerOf(this, `${what}. Go ahead? [y/N] `);
|
|
@@ -8717,7 +9297,7 @@ var resetCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("r
|
|
|
8717
9297
|
if (!/^\s*y(es)?\s*$/i.test(answer))
|
|
8718
9298
|
throw new CliError("cancelled", "cancelled \u2014 the store is unchanged");
|
|
8719
9299
|
}
|
|
8720
|
-
await quiesce(path,
|
|
9300
|
+
await quiesce(path, owner, "reset", (message) => renderer.warn(message), environmentOf(this).storeLockWaitMs);
|
|
8721
9301
|
const backup = keep ? `${path}.backup-${stampNow()}` : null;
|
|
8722
9302
|
let backedUp = null;
|
|
8723
9303
|
if (backup) {
|
|
@@ -8743,10 +9323,10 @@ var resetCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("r
|
|
|
8743
9323
|
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`);
|
|
8744
9324
|
}), "resetCommand");
|
|
8745
9325
|
var STORE_PARTS2 = ["", "-wal", "-shm"];
|
|
8746
|
-
var resetPreview = /* @__PURE__ */ __name(async (path,
|
|
8747
|
-
const files = STORE_PARTS2.map((suffix) => `${path}${suffix}`).filter((file2) =>
|
|
8748
|
-
const holders = holdersOf(files.map((file2) =>
|
|
8749
|
-
const serving = servingProfiles(
|
|
9326
|
+
var resetPreview = /* @__PURE__ */ __name(async (path, owner, env, keep) => {
|
|
9327
|
+
const files = STORE_PARTS2.map((suffix) => `${path}${suffix}`).filter((file2) => existsSync10(file2));
|
|
9328
|
+
const holders = holdersOf(files.map((file2) => realpathSync3(file2)));
|
|
9329
|
+
const serving = servingProfiles(owner.app, env).length > 0;
|
|
8750
9330
|
const read = await readingOnly(path, (database) => ({
|
|
8751
9331
|
schema: schemaOf(database).version,
|
|
8752
9332
|
tables: emptiedTables(database)
|
|
@@ -8802,6 +9382,21 @@ export {
|
|
|
8802
9382
|
DRY_RUN_DAYS,
|
|
8803
9383
|
dryRun,
|
|
8804
9384
|
senderFacts,
|
|
9385
|
+
AI_PROVIDERS,
|
|
9386
|
+
aiSettingPath,
|
|
9387
|
+
readAiSetting,
|
|
9388
|
+
writeAiSetting,
|
|
9389
|
+
aiSettingOf,
|
|
9390
|
+
aiBaseUrl,
|
|
9391
|
+
aiOrigin,
|
|
9392
|
+
aiImagesAllowed,
|
|
9393
|
+
aiKeys,
|
|
9394
|
+
aiTakesKey,
|
|
9395
|
+
aiLeavesComputer,
|
|
9396
|
+
sharedModel,
|
|
9397
|
+
aiTextReader,
|
|
9398
|
+
checkAi,
|
|
9399
|
+
purposeModel,
|
|
8805
9400
|
replyConsentPathFor,
|
|
8806
9401
|
readReplyConsent,
|
|
8807
9402
|
writeReplyConsent,
|
|
@@ -8815,6 +9410,10 @@ export {
|
|
|
8815
9410
|
FIRST_FETCH_MS,
|
|
8816
9411
|
DAY_MS,
|
|
8817
9412
|
memberFetches,
|
|
9413
|
+
OUTDATED_CHECK_MS,
|
|
9414
|
+
ownPackageRoot,
|
|
9415
|
+
outdatedReason,
|
|
9416
|
+
watchOutdated,
|
|
8818
9417
|
STEMS_EVERY_MS,
|
|
8819
9418
|
STEMS_SLICE_MS,
|
|
8820
9419
|
stemFills,
|
|
@@ -8826,5 +9425,6 @@ export {
|
|
|
8826
9425
|
serveCommand,
|
|
8827
9426
|
storeSummary,
|
|
8828
9427
|
storeMaintenanceCommands,
|
|
9428
|
+
addStoreMaintenanceCommands,
|
|
8829
9429
|
buildStems
|
|
8830
9430
|
};
|