@wirecat/tg-cli 0.118.0 → 0.120.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/contracts/wirecat.json +7623 -0
- package/dist/bin/tg.js +2 -2
- package/dist/bot/transport.d.ts.map +1 -1
- package/dist/bot/transport.js +15 -8
- package/dist/bot/transport.js.map +1 -1
- package/dist/bundle/{adapter-4YNP6VCO.js → adapter-OJKHXGBC.js} +49 -50
- package/dist/bundle/{all-profiles-MIQDYAGO.js → all-profiles-URIWNL23.js} +10 -10
- package/dist/bundle/{anthropic-NTASPJYE.js → anthropic-YUKNB63B.js} +10 -8
- package/dist/bundle/{app-server-UJZBJ2SK.js → app-server-H5QNHGH4.js} +43 -43
- package/dist/bundle/{bot-api-JZAD4L3N.js → bot-api-27GN4Y3D.js} +49 -49
- package/dist/bundle/{bot-history-OUDHH3NU.js → bot-history-VVSWLVZM.js} +18 -18
- package/dist/bundle/{bun-EC4HDIRD.js → bun-PAAJX3GU.js} +2 -2
- package/dist/bundle/{bun-sqlite-A4HJR6KO.js → bun-sqlite-TPEBWFZH.js} +5 -5
- package/dist/bundle/{chunk-KEDHX6XG.js → chunk-34DSPJNN.js} +2 -2
- package/dist/bundle/{chunk-JZETEZHC.js → chunk-3FPFRDG2.js} +10 -8
- package/dist/bundle/{chunk-2KQHUBTV.js → chunk-3GLLWDM6.js} +12 -12
- package/dist/bundle/{chunk-NMT2VGEI.js → chunk-3SANNNWS.js} +3 -3
- package/dist/bundle/{chunk-65XV5PPI.js → chunk-4JATS2J5.js} +3 -3
- package/dist/bundle/{chunk-OTQDJUES.js → chunk-4OWY7QBE.js} +6 -6
- package/dist/bundle/{chunk-QOGYHU3Q.js → chunk-4W4EVVL4.js} +61 -21
- package/dist/bundle/{chunk-BNEP5EOV.js → chunk-6XHZV7AQ.js} +4 -4
- package/dist/bundle/{chunk-3MQOLYAN.js → chunk-7DPWVKYS.js} +4 -4
- package/dist/bundle/{chunk-NUCDEOFC.js → chunk-7I6YVQHW.js} +2 -2
- package/dist/bundle/{chunk-HJNRIK5X.js → chunk-7N4IUEX3.js} +9 -8
- package/dist/bundle/{chunk-RG2E7ZQZ.js → chunk-7VNV426X.js} +85 -17
- package/dist/bundle/{chunk-DSZJREEO.js → chunk-7WS3ULOO.js} +2205 -911
- package/dist/bundle/{chunk-TMTEWOQS.js → chunk-B7B65ZLU.js} +5 -3
- package/dist/bundle/{chunk-EPXVRJAX.js → chunk-CGUDXNJE.js} +2 -2
- package/dist/bundle/{chunk-EQJ6NLF5.js → chunk-CLTMVPGT.js} +13 -13
- package/dist/bundle/{chunk-6ZMTEUVU.js → chunk-CLURRDNU.js} +6 -6
- package/dist/bundle/{chunk-ZXXTJF4Z.js → chunk-CYWV2RLN.js} +4 -4
- package/dist/bundle/{chunk-5IIU7X4S.js → chunk-D2WNQJUQ.js} +1 -1
- package/dist/bundle/{chunk-PB252TT3.js → chunk-DDKFAUQD.js} +2 -2
- package/dist/bundle/{chunk-5LDWBEWU.js → chunk-DE7QIEUP.js} +53 -35
- package/dist/bundle/{chunk-JPVFYMSQ.js → chunk-DH7VKHTZ.js} +4 -4
- package/dist/bundle/{chunk-GXCJ47SJ.js → chunk-DQTQO6PB.js} +3265 -1034
- package/dist/bundle/{chunk-JWIUK3SK.js → chunk-FATTEYZH.js} +2 -2
- package/dist/bundle/{chunk-I4TI5HDJ.js → chunk-FPWXG53C.js} +11 -11
- package/dist/bundle/{chunk-PO74BDER.js → chunk-H5XC2WYO.js} +35 -589
- package/dist/bundle/{chunk-ZMUC3UQO.js → chunk-HDSKBXAF.js} +3 -3
- package/dist/bundle/{chunk-PWCQC56A.js → chunk-HIBYYKGO.js} +1 -1
- package/dist/bundle/{chunk-GLRRCKP6.js → chunk-JJY3TQTM.js} +23 -5
- package/dist/bundle/{chunk-YPRUWRKE.js → chunk-JQLGS3SG.js} +1 -1
- package/dist/bundle/{chunk-MBH7IKLT.js → chunk-JSEIT2WO.js} +1 -1
- package/dist/bundle/{chunk-57LKX6N2.js → chunk-KLHOQ6XQ.js} +1 -1
- package/dist/bundle/{chunk-4BV4UMBB.js → chunk-KP26Y5OA.js} +1628 -367
- package/dist/bundle/{chunk-MZNOASAW.js → chunk-KRCMKFUV.js} +16 -3
- package/dist/bundle/{chunk-6AXUEJGL.js → chunk-KTV5Y5EX.js} +2 -2
- package/dist/bundle/{chunk-YEOSV6JC.js → chunk-KW6JZGG3.js} +1 -1
- package/dist/bundle/{chunk-H6S3C3MH.js → chunk-LLCGOZ44.js} +4 -4
- package/dist/bundle/{chunk-CEY43D3A.js → chunk-LS72R7DN.js} +34 -34
- package/dist/bundle/chunk-LVGX7VTD.js +138 -0
- package/dist/bundle/{chunk-VW6BF6M7.js → chunk-MCPOZNWG.js} +1 -1
- package/dist/bundle/{chunk-G3RT2EQI.js → chunk-MMPISXSU.js} +2 -2
- package/dist/bundle/{chunk-6RI4TEIC.js → chunk-MTD6WZKV.js} +2 -2
- package/dist/bundle/{chunk-JLJKGKU2.js → chunk-PDYTNTQI.js} +6 -6
- package/dist/bundle/{chunk-P3ASN72F.js → chunk-RX5CJ55S.js} +1 -1
- package/dist/bundle/{chunk-76EKXFX2.js → chunk-S6OC367D.js} +24 -2
- package/dist/bundle/{chunk-PW3HFIJA.js → chunk-THJHYMFR.js} +1489 -1548
- package/dist/bundle/{chunk-5QYU7B27.js → chunk-U2TPRUWK.js} +689 -482
- package/dist/bundle/{chunk-YHZFGUAP.js → chunk-U6HEZPCR.js} +19 -19
- package/dist/bundle/{chunk-BXTDAGM4.js → chunk-VUBZFMGP.js} +2 -2
- package/dist/bundle/{chunk-2NA5KVP6.js → chunk-VUUR2SRS.js} +264 -45
- package/dist/bundle/{chunk-EPCFXKTX.js → chunk-WGGSFGNZ.js} +34 -8
- package/dist/bundle/{chunk-Y64SI2RO.js → chunk-WLBPNLDF.js} +3 -3
- package/dist/bundle/{chunk-GI4MTNA2.js → chunk-WQ55F4Y3.js} +8 -8
- package/dist/bundle/{chunk-FHMK6OK4.js → chunk-YBOVL25O.js} +96 -30
- package/dist/bundle/{chunk-DKFC5ZZ3.js → chunk-YDROJG2Y.js} +86 -29
- package/dist/bundle/{chunk-NKFTZVQU.js → chunk-YQKEPT22.js} +1 -1
- package/dist/bundle/{chunk-GIM37COQ.js → chunk-ZON7K5QE.js} +3 -3
- package/dist/bundle/{chunk-JWPSVS6C.js → chunk-ZRRZTPSB.js} +19059 -17055
- package/dist/bundle/command-contract-KW6FNOJO.js +33 -0
- package/dist/bundle/{decode-NMNPLKNR.js → decode-RVWSCZW4.js} +5 -5
- package/dist/bundle/{dispatch-OP27MWX5.js → dispatch-U2DW6UI7.js} +10 -10
- package/dist/bundle/{echarts-S46LEIPS.js → echarts-6VNUD3JF.js} +2 -2
- package/dist/bundle/{embed-I5ZYHGYC.js → embed-LWLCQKIK.js} +6 -6
- package/dist/bundle/{embedder-LTJI67N2.js → embedder-CXKHLRJT.js} +9 -9
- package/dist/bundle/{entry-O6BUPXF7.js → entry-HV4NSX3Z.js} +7 -7
- package/dist/bundle/{failure-4JUQFXJT.js → failure-HJD7S5UA.js} +2 -2
- package/dist/bundle/{first-run-PMZNCDGD.js → first-run-OPI6NIWQ.js} +11 -11
- package/dist/bundle/first-screen-BVQLF4LN.js +31 -0
- package/dist/bundle/{instructions-AUEGY3VO.js → instructions-TK4HXL3A.js} +1 -1
- package/dist/bundle/{mcp-M4QN2E7R.js → mcp-7KQUJNFN.js} +2 -2
- package/dist/bundle/{node-XRA7RBCQ.js → node-WFPNBUCU.js} +2 -2
- package/dist/bundle/{node-sqlite-DEZO6LRS.js → node-sqlite-L5BRGJLK.js} +6 -6
- package/dist/bundle/{oauth-DAVC7WCD.js → oauth-CGVWL35B.js} +7 -7
- package/dist/bundle/{open-DE2YO4T7.js → open-HLL55C5S.js} +5 -5
- package/dist/bundle/{openai-5BKGAULH.js → openai-YFCNXIJ4.js} +16 -37
- package/dist/bundle/{process-4ZHPNUIQ.js → process-4A5JP5LO.js} +1 -1
- package/dist/bundle/{program-EGTKSNB4.js → program-IFGQGSUF.js} +56 -53
- package/dist/bundle/{prompt-HWCWHHPE.js → prompt-B5FYE2DQ.js} +7 -5
- package/dist/bundle/{proxy-transport-4DPZB2W2.js → proxy-transport-ENU2SJYT.js} +5 -5
- package/dist/bundle/{recognize-NG6RXNGF.js → recognize-ZHMHGIV3.js} +4 -4
- package/dist/bundle/{remote-ZKXIIGYH.js → remote-A3W5HE52.js} +7 -7
- package/dist/bundle/{rerank-TX5QFURV.js → rerank-HWJAQOZM.js} +7 -7
- package/dist/bundle/{serve-XAS6DECW.js → serve-PP326Q2F.js} +9 -9
- package/dist/bundle/{server-CNPIWBYU.js → server-MV6CL63L.js} +35 -35
- package/dist/bundle/server-TZGGOJ26.js +60 -0
- package/dist/bundle/{state-3HTUETTS.js → state-Y3RJ7ZXB.js} +6 -6
- package/dist/bundle/{store-B5VZWJHN.js → store-EVNI2MHZ.js} +36 -13
- package/dist/bundle/store-maintenance-command-XPQE47RE.js +49 -0
- package/dist/bundle/tg.js +38 -14
- package/dist/commands/account-removal.d.ts +3 -0
- package/dist/commands/account-removal.d.ts.map +1 -0
- package/dist/commands/account-removal.js +57 -0
- package/dist/commands/account-removal.js.map +1 -0
- package/dist/commands/context.d.ts.map +1 -1
- package/dist/commands/context.js +2 -0
- package/dist/commands/context.js.map +1 -1
- package/dist/http.d.ts +6 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +8 -0
- package/dist/http.js.map +1 -0
- package/dist/identity.d.ts +4 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +14 -0
- package/dist/identity.js.map +1 -1
- package/dist/telegram/map.d.ts.map +1 -1
- package/dist/telegram/map.js +3 -0
- package/dist/telegram/map.js.map +1 -1
- package/dist/telegram/registration.d.ts +1 -1
- package/dist/telegram/registration.d.ts.map +1 -1
- package/dist/telegram/registration.js +4 -1
- package/dist/telegram/registration.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/wcat.d.ts +3 -0
- package/dist/wcat.d.ts.map +1 -0
- package/dist/wcat.js +4 -0
- package/dist/wcat.js.map +1 -0
- package/package.json +7 -6
- package/dist/bundle/chunk-TSTEZNSX.js +0 -33
- package/dist/bundle/command-contract-7GZ6HAA6.js +0 -33
- package/dist/bundle/first-screen-BGML5DSO.js +0 -31
- package/dist/bundle/server-FRTKLHZF.js +0 -60
- package/dist/bundle/store-maintenance-command-VG3CLELA.js +0 -50
- /package/dist/bundle/{chunk-VOXIGICJ.js → chunk-YVNHQFLC.js} +0 -0
|
@@ -3,14 +3,17 @@ const require = __bundleRequire(import.meta.url);
|
|
|
3
3
|
import {
|
|
4
4
|
answerOf,
|
|
5
5
|
messengerContext
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-H5XC2WYO.js";
|
|
7
7
|
import {
|
|
8
8
|
FETCHING,
|
|
9
9
|
RULES_VERSION,
|
|
10
10
|
applyTaskRulesOnArrival,
|
|
11
11
|
capability,
|
|
12
12
|
chatEventAnswer,
|
|
13
|
+
embeddingKeys,
|
|
14
|
+
endpointKeyName,
|
|
13
15
|
memberAnswer,
|
|
16
|
+
modelGateway,
|
|
14
17
|
newSendId,
|
|
15
18
|
onlineDeps,
|
|
16
19
|
openRequestTask,
|
|
@@ -24,14 +27,15 @@ import {
|
|
|
24
27
|
typedQuery,
|
|
25
28
|
withQuery,
|
|
26
29
|
withTimeLimit
|
|
27
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-7WS3ULOO.js";
|
|
28
31
|
import {
|
|
29
32
|
QUICK_HEALTH_CHECKS,
|
|
30
|
-
explainDamage,
|
|
31
33
|
fts5Tables,
|
|
32
34
|
invalidJson,
|
|
35
|
+
lossUnknown,
|
|
36
|
+
storeDamageReport,
|
|
33
37
|
storeHealth
|
|
34
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-YDROJG2Y.js";
|
|
35
39
|
import {
|
|
36
40
|
stringWidth,
|
|
37
41
|
wrapAnsi
|
|
@@ -44,9 +48,7 @@ import {
|
|
|
44
48
|
REMOTE_WRITE,
|
|
45
49
|
annotate,
|
|
46
50
|
codeOf,
|
|
47
|
-
currentRun,
|
|
48
51
|
destroysNothing,
|
|
49
|
-
endpoint,
|
|
50
52
|
environmentOf,
|
|
51
53
|
itemOf,
|
|
52
54
|
jsonlRecords,
|
|
@@ -63,20 +65,17 @@ import {
|
|
|
63
65
|
snakeKeys,
|
|
64
66
|
storeTable,
|
|
65
67
|
withoutProviderRefs
|
|
66
|
-
} from "./chunk-
|
|
67
|
-
import {
|
|
68
|
-
envName
|
|
69
|
-
} from "./chunk-PB252TT3.js";
|
|
68
|
+
} from "./chunk-THJHYMFR.js";
|
|
70
69
|
import {
|
|
71
70
|
holdLock,
|
|
72
71
|
lockPath,
|
|
73
72
|
releaseLock,
|
|
74
73
|
servingProfiles,
|
|
75
74
|
takeLock
|
|
76
|
-
} from "./chunk-
|
|
75
|
+
} from "./chunk-ZON7K5QE.js";
|
|
77
76
|
import {
|
|
78
77
|
holdersOf
|
|
79
|
-
} from "./chunk-
|
|
78
|
+
} from "./chunk-JQLGS3SG.js";
|
|
80
79
|
import {
|
|
81
80
|
CORPORA,
|
|
82
81
|
MIGRATIONS,
|
|
@@ -89,14 +88,13 @@ import {
|
|
|
89
88
|
fillStems,
|
|
90
89
|
fillTrigrams,
|
|
91
90
|
fillVectorIndexes,
|
|
92
|
-
formatLocator,
|
|
93
91
|
involvementStoreOver,
|
|
92
|
+
isDerivedTable,
|
|
94
93
|
migrate,
|
|
95
94
|
noteIndexState,
|
|
96
95
|
openSqlite,
|
|
97
96
|
openStore,
|
|
98
97
|
orphanPointers,
|
|
99
|
-
parseLocator,
|
|
100
98
|
pendingNormalization,
|
|
101
99
|
readStoreTables,
|
|
102
100
|
rebuildMentions,
|
|
@@ -112,51 +110,42 @@ import {
|
|
|
112
110
|
storeClients,
|
|
113
111
|
storeContents,
|
|
114
112
|
vectorIndexCounts
|
|
115
|
-
} from "./chunk-
|
|
113
|
+
} from "./chunk-ZRRZTPSB.js";
|
|
116
114
|
import {
|
|
115
|
+
currentRun,
|
|
116
|
+
formatLocator,
|
|
117
|
+
parseLocator,
|
|
117
118
|
queryFieldsOf,
|
|
118
119
|
readDamageMark,
|
|
119
120
|
readHealthMark,
|
|
121
|
+
readJournalMark,
|
|
120
122
|
recordDeepCheck
|
|
121
|
-
} from "./chunk-
|
|
123
|
+
} from "./chunk-KP26Y5OA.js";
|
|
122
124
|
import {
|
|
123
125
|
failureKey,
|
|
124
126
|
isStoreDamage
|
|
125
|
-
} from "./chunk-
|
|
127
|
+
} from "./chunk-WLBPNLDF.js";
|
|
126
128
|
import {
|
|
127
129
|
readSecret
|
|
128
|
-
} from "./chunk-
|
|
129
|
-
import {
|
|
130
|
-
checkedOptions,
|
|
131
|
-
range
|
|
132
|
-
} from "./chunk-TSTEZNSX.js";
|
|
133
|
-
import {
|
|
134
|
-
messagesFor,
|
|
135
|
-
systemFor,
|
|
136
|
-
validateImages
|
|
137
|
-
} from "./chunk-76EKXFX2.js";
|
|
130
|
+
} from "./chunk-JJY3TQTM.js";
|
|
138
131
|
import {
|
|
139
132
|
storePath
|
|
140
|
-
} from "./chunk-
|
|
133
|
+
} from "./chunk-MMPISXSU.js";
|
|
141
134
|
import {
|
|
142
135
|
openCache
|
|
143
|
-
} from "./chunk-
|
|
136
|
+
} from "./chunk-PDYTNTQI.js";
|
|
144
137
|
import {
|
|
145
|
-
Credentials,
|
|
146
|
-
pathsAreOverridden,
|
|
147
138
|
resolvePaths,
|
|
148
139
|
writeSecurely
|
|
149
|
-
} from "./chunk-
|
|
140
|
+
} from "./chunk-U6HEZPCR.js";
|
|
150
141
|
import {
|
|
151
142
|
array,
|
|
152
143
|
boolean,
|
|
153
144
|
check,
|
|
154
145
|
forward,
|
|
155
146
|
getDotPath,
|
|
156
|
-
integer,
|
|
157
147
|
minLength,
|
|
158
148
|
nullable,
|
|
159
|
-
number,
|
|
160
149
|
object,
|
|
161
150
|
optional,
|
|
162
151
|
parse,
|
|
@@ -168,14 +157,13 @@ import {
|
|
|
168
157
|
strictObject,
|
|
169
158
|
string,
|
|
170
159
|
transform,
|
|
171
|
-
trim
|
|
172
|
-
|
|
173
|
-
} from "./chunk-EPCFXKTX.js";
|
|
160
|
+
trim
|
|
161
|
+
} from "./chunk-WGGSFGNZ.js";
|
|
174
162
|
import {
|
|
175
163
|
CliError,
|
|
176
164
|
singleLine,
|
|
177
165
|
visibleControls
|
|
178
|
-
} from "./chunk-
|
|
166
|
+
} from "./chunk-VUBZFMGP.js";
|
|
179
167
|
import {
|
|
180
168
|
__commonJS,
|
|
181
169
|
__name,
|
|
@@ -353,14 +341,14 @@ var require_liquid_node = __commonJS({
|
|
|
353
341
|
return value !== null && (type === "object" || type === "function");
|
|
354
342
|
}
|
|
355
343
|
__name(isObject, "isObject");
|
|
356
|
-
function
|
|
344
|
+
function range(start, stop, step = 1) {
|
|
357
345
|
const arr = [];
|
|
358
346
|
for (let i = start; i < stop; i += step) {
|
|
359
347
|
arr.push(i);
|
|
360
348
|
}
|
|
361
349
|
return arr;
|
|
362
350
|
}
|
|
363
|
-
__name(
|
|
351
|
+
__name(range, "range");
|
|
364
352
|
function padStart(str, length, ch = " ") {
|
|
365
353
|
return pad(str, length, ch, (str2, ch2) => ch2 + str2);
|
|
366
354
|
}
|
|
@@ -554,7 +542,7 @@ var require_liquid_node = __commonJS({
|
|
|
554
542
|
const lines = token.input.split("\n");
|
|
555
543
|
const begin = Math.max(line - 2, 1);
|
|
556
544
|
const end = Math.min(line + 3, lines.length);
|
|
557
|
-
const context =
|
|
545
|
+
const context = range(begin, end + 1).map((lineNumber) => {
|
|
558
546
|
const rowIndicator = lineNumber === line ? ">> " : " ";
|
|
559
547
|
const num = padStart(String(lineNumber), String(end).length);
|
|
560
548
|
let text = `${rowIndicator}${num}| `;
|
|
@@ -1132,8 +1120,8 @@ var require_liquid_node = __commonJS({
|
|
|
1132
1120
|
valid() {
|
|
1133
1121
|
return !isNaN(this.getTime());
|
|
1134
1122
|
}
|
|
1135
|
-
format(
|
|
1136
|
-
return this.DateTimeFormat && this.DateTimeFormat(this.locale,
|
|
1123
|
+
format(options) {
|
|
1124
|
+
return this.DateTimeFormat && this.DateTimeFormat(this.locale, options).format(this.displayDate);
|
|
1137
1125
|
}
|
|
1138
1126
|
/**
|
|
1139
1127
|
* Create a Date object fixed to it's declared Timezone. Both
|
|
@@ -1217,11 +1205,11 @@ var require_liquid_node = __commonJS({
|
|
|
1217
1205
|
static {
|
|
1218
1206
|
__name(this, "TagToken");
|
|
1219
1207
|
}
|
|
1220
|
-
constructor(input, begin, end,
|
|
1221
|
-
const { trimTagLeft, trimTagRight, tagDelimiterLeft, tagDelimiterRight } =
|
|
1208
|
+
constructor(input, begin, end, options, file2) {
|
|
1209
|
+
const { trimTagLeft, trimTagRight, tagDelimiterLeft, tagDelimiterRight } = options;
|
|
1222
1210
|
const [valueBegin, valueEnd] = [begin + tagDelimiterLeft.length, end - tagDelimiterRight.length];
|
|
1223
1211
|
super(exports.TokenKind.Tag, [valueBegin, valueEnd], input, begin, end, trimTagLeft, trimTagRight, file2);
|
|
1224
|
-
this.tokenizer = new Tokenizer(input,
|
|
1212
|
+
this.tokenizer = new Tokenizer(input, options.operators, file2, this.contentRange, options.groupedExpressions);
|
|
1225
1213
|
this.name = this.tokenizer.readTagName();
|
|
1226
1214
|
this.tokenizer.assert(this.name, `illegal tag syntax, tag name expected`);
|
|
1227
1215
|
this.tokenizer.skipBlank();
|
|
@@ -1232,8 +1220,8 @@ var require_liquid_node = __commonJS({
|
|
|
1232
1220
|
static {
|
|
1233
1221
|
__name(this, "OutputToken");
|
|
1234
1222
|
}
|
|
1235
|
-
constructor(input, begin, end,
|
|
1236
|
-
const { trimOutputLeft, trimOutputRight, outputDelimiterLeft, outputDelimiterRight } =
|
|
1223
|
+
constructor(input, begin, end, options, file2) {
|
|
1224
|
+
const { trimOutputLeft, trimOutputRight, outputDelimiterLeft, outputDelimiterRight } = options;
|
|
1237
1225
|
const valueRange = [begin + outputDelimiterLeft.length, end - outputDelimiterRight.length];
|
|
1238
1226
|
super(exports.TokenKind.Output, valueRange, input, begin, end, trimOutputLeft, trimOutputRight, file2);
|
|
1239
1227
|
}
|
|
@@ -1452,9 +1440,9 @@ var require_liquid_node = __commonJS({
|
|
|
1452
1440
|
static {
|
|
1453
1441
|
__name(this, "LiquidTagToken");
|
|
1454
1442
|
}
|
|
1455
|
-
constructor(input, begin, end,
|
|
1443
|
+
constructor(input, begin, end, options, file2) {
|
|
1456
1444
|
super(exports.TokenKind.Tag, [begin, end], input, begin, end, false, false, file2);
|
|
1457
|
-
this.tokenizer = new Tokenizer(input,
|
|
1445
|
+
this.tokenizer = new Tokenizer(input, options.operators, file2, this.contentRange, options.groupedExpressions);
|
|
1458
1446
|
this.name = this.tokenizer.readTagName();
|
|
1459
1447
|
this.tokenizer.assert(this.name, "illegal liquid tag syntax");
|
|
1460
1448
|
this.tokenizer.skipBlank();
|
|
@@ -1528,11 +1516,11 @@ var require_liquid_node = __commonJS({
|
|
|
1528
1516
|
static {
|
|
1529
1517
|
__name(this, "Filter");
|
|
1530
1518
|
}
|
|
1531
|
-
constructor(token,
|
|
1519
|
+
constructor(token, options, liquid) {
|
|
1532
1520
|
this.token = token;
|
|
1533
1521
|
this.name = token.name;
|
|
1534
|
-
this.handler = isFunction(
|
|
1535
|
-
this.raw = !isFunction(
|
|
1522
|
+
this.handler = isFunction(options) ? options : isFunction(options?.handler) ? options.handler : identify;
|
|
1523
|
+
this.raw = !isFunction(options) && !!options?.raw;
|
|
1536
1524
|
this.args = token.args;
|
|
1537
1525
|
this.liquid = liquid;
|
|
1538
1526
|
}
|
|
@@ -1635,7 +1623,7 @@ var require_liquid_node = __commonJS({
|
|
|
1635
1623
|
const low = yield evalTokenValue(token.lhs, ctx);
|
|
1636
1624
|
const high = yield evalTokenValue(token.rhs, ctx);
|
|
1637
1625
|
ctx.memoryLimit.use(high - low + 1);
|
|
1638
|
-
return
|
|
1626
|
+
return range(+low, +high + 1);
|
|
1639
1627
|
}
|
|
1640
1628
|
__name(evalRangeToken, "evalRangeToken");
|
|
1641
1629
|
function* toPostfix(tokens) {
|
|
@@ -1829,7 +1817,7 @@ var require_liquid_node = __commonJS({
|
|
|
1829
1817
|
return readFileAsync(filepath, "utf8");
|
|
1830
1818
|
}
|
|
1831
1819
|
__name(readFile, "readFile");
|
|
1832
|
-
function
|
|
1820
|
+
function existsSync11(filepath) {
|
|
1833
1821
|
try {
|
|
1834
1822
|
fs$1.statSync(filepath);
|
|
1835
1823
|
return true;
|
|
@@ -1837,11 +1825,11 @@ var require_liquid_node = __commonJS({
|
|
|
1837
1825
|
return false;
|
|
1838
1826
|
}
|
|
1839
1827
|
}
|
|
1840
|
-
__name(
|
|
1841
|
-
function
|
|
1828
|
+
__name(existsSync11, "existsSync");
|
|
1829
|
+
function readFileSync6(filepath) {
|
|
1842
1830
|
return fs$1.readFileSync(filepath, "utf8");
|
|
1843
1831
|
}
|
|
1844
|
-
__name(
|
|
1832
|
+
__name(readFileSync6, "readFileSync");
|
|
1845
1833
|
function resolve2(root, file2, ext) {
|
|
1846
1834
|
if (!path.extname(file2))
|
|
1847
1835
|
file2 += ext;
|
|
@@ -1855,10 +1843,10 @@ var require_liquid_node = __commonJS({
|
|
|
1855
1843
|
}
|
|
1856
1844
|
}
|
|
1857
1845
|
__name(fallback, "fallback");
|
|
1858
|
-
function
|
|
1846
|
+
function dirname4(filepath) {
|
|
1859
1847
|
return path.dirname(filepath);
|
|
1860
1848
|
}
|
|
1861
|
-
__name(
|
|
1849
|
+
__name(dirname4, "dirname");
|
|
1862
1850
|
var realpathAsync = promisify(fs$1.realpath);
|
|
1863
1851
|
async function contains(root, file2) {
|
|
1864
1852
|
try {
|
|
@@ -1886,11 +1874,11 @@ var require_liquid_node = __commonJS({
|
|
|
1886
1874
|
__proto__: null,
|
|
1887
1875
|
exists,
|
|
1888
1876
|
readFile,
|
|
1889
|
-
existsSync:
|
|
1890
|
-
readFileSync:
|
|
1877
|
+
existsSync: existsSync11,
|
|
1878
|
+
readFileSync: readFileSync6,
|
|
1891
1879
|
resolve: resolve2,
|
|
1892
1880
|
fallback,
|
|
1893
|
-
dirname:
|
|
1881
|
+
dirname: dirname4,
|
|
1894
1882
|
contains,
|
|
1895
1883
|
containsSync,
|
|
1896
1884
|
sep: path.sep
|
|
@@ -2116,41 +2104,41 @@ var require_liquid_node = __commonJS({
|
|
|
2116
2104
|
parseLimit: Infinity,
|
|
2117
2105
|
renderLimit: Infinity
|
|
2118
2106
|
};
|
|
2119
|
-
function normalize(
|
|
2120
|
-
if (
|
|
2121
|
-
if (!
|
|
2122
|
-
|
|
2123
|
-
if (!
|
|
2124
|
-
|
|
2125
|
-
}
|
|
2126
|
-
if (
|
|
2107
|
+
function normalize(options) {
|
|
2108
|
+
if (options.hasOwnProperty("root")) {
|
|
2109
|
+
if (!options.hasOwnProperty("partials"))
|
|
2110
|
+
options.partials = options.root;
|
|
2111
|
+
if (!options.hasOwnProperty("layouts"))
|
|
2112
|
+
options.layouts = options.root;
|
|
2113
|
+
}
|
|
2114
|
+
if (options.hasOwnProperty("cache")) {
|
|
2127
2115
|
let cache;
|
|
2128
|
-
if (typeof
|
|
2129
|
-
cache =
|
|
2130
|
-
else if (typeof
|
|
2131
|
-
cache =
|
|
2116
|
+
if (typeof options.cache === "number")
|
|
2117
|
+
cache = options.cache > 0 ? new LRU(options.cache) : void 0;
|
|
2118
|
+
else if (typeof options.cache === "object")
|
|
2119
|
+
cache = options.cache;
|
|
2132
2120
|
else
|
|
2133
|
-
cache =
|
|
2134
|
-
|
|
2121
|
+
cache = options.cache ? new LRU(1024) : void 0;
|
|
2122
|
+
options.cache = cache;
|
|
2135
2123
|
}
|
|
2136
|
-
|
|
2137
|
-
if ((!
|
|
2124
|
+
options = { ...defaultOptions, ...options.jekyllInclude ? { dynamicPartials: false } : {}, ...options };
|
|
2125
|
+
if ((!options.fs.dirname || !options.fs.sep) && options.relativeReference) {
|
|
2138
2126
|
console.warn("[LiquidJS] `fs.dirname` and `fs.sep` are required for relativeReference, set relativeReference to `false` to suppress this warning");
|
|
2139
|
-
|
|
2127
|
+
options.relativeReference = false;
|
|
2140
2128
|
}
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
if (!
|
|
2146
|
-
|
|
2129
|
+
options.root = normalizeDirectoryList(options.root);
|
|
2130
|
+
options.partials = normalizeDirectoryList(options.partials);
|
|
2131
|
+
options.layouts = normalizeDirectoryList(options.layouts);
|
|
2132
|
+
options.outputEscape = options.outputEscape && getOutputEscapeFunction(options.outputEscape);
|
|
2133
|
+
if (!options.locale) {
|
|
2134
|
+
options.locale = getDateTimeFormat()?.().resolvedOptions().locale ?? "en-US";
|
|
2147
2135
|
}
|
|
2148
|
-
if (
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2136
|
+
if (options.templates) {
|
|
2137
|
+
options.fs = new MapFS(options.templates);
|
|
2138
|
+
options.relativeReference = true;
|
|
2139
|
+
options.root = options.partials = options.layouts = ".";
|
|
2152
2140
|
}
|
|
2153
|
-
return
|
|
2141
|
+
return options;
|
|
2154
2142
|
}
|
|
2155
2143
|
__name(normalize, "normalize");
|
|
2156
2144
|
function getOutputEscapeFunction(nameOrFunction) {
|
|
@@ -2171,14 +2159,14 @@ var require_liquid_node = __commonJS({
|
|
|
2171
2159
|
return list;
|
|
2172
2160
|
}
|
|
2173
2161
|
__name(normalizeDirectoryList, "normalizeDirectoryList");
|
|
2174
|
-
function whiteSpaceCtrl(tokens,
|
|
2162
|
+
function whiteSpaceCtrl(tokens, options) {
|
|
2175
2163
|
let inRaw = false;
|
|
2176
2164
|
for (let i = 0; i < tokens.length; i++) {
|
|
2177
2165
|
const token = tokens[i];
|
|
2178
2166
|
if (!isDelimitedToken(token))
|
|
2179
2167
|
continue;
|
|
2180
2168
|
if (!inRaw && token.trimLeft) {
|
|
2181
|
-
trimLeft(tokens[i - 1],
|
|
2169
|
+
trimLeft(tokens[i - 1], options.greedy);
|
|
2182
2170
|
}
|
|
2183
2171
|
if (isTagToken(token)) {
|
|
2184
2172
|
if (token.name === "raw")
|
|
@@ -2187,7 +2175,7 @@ var require_liquid_node = __commonJS({
|
|
|
2187
2175
|
inRaw = false;
|
|
2188
2176
|
}
|
|
2189
2177
|
if (!inRaw && token.trimRight) {
|
|
2190
|
-
trimRight(tokens[i + 1],
|
|
2178
|
+
trimRight(tokens[i + 1], options.greedy);
|
|
2191
2179
|
}
|
|
2192
2180
|
}
|
|
2193
2181
|
}
|
|
@@ -2214,12 +2202,12 @@ var require_liquid_node = __commonJS({
|
|
|
2214
2202
|
static {
|
|
2215
2203
|
__name(this, "Tokenizer");
|
|
2216
2204
|
}
|
|
2217
|
-
constructor(input, operators = defaultOptions.operators, file2,
|
|
2205
|
+
constructor(input, operators = defaultOptions.operators, file2, range2, groupedExpressions = false) {
|
|
2218
2206
|
this.input = input;
|
|
2219
2207
|
this.file = file2;
|
|
2220
2208
|
this.rawBeginAt = -1;
|
|
2221
|
-
this.p =
|
|
2222
|
-
this.N =
|
|
2209
|
+
this.p = range2 ? range2[0] : 0;
|
|
2210
|
+
this.N = range2 ? range2[1] : input.length;
|
|
2223
2211
|
this.opTrie = createTrie(operators);
|
|
2224
2212
|
this.literalTrie = createTrie(literalValues);
|
|
2225
2213
|
this.groupedExpressions = groupedExpressions;
|
|
@@ -2319,23 +2307,23 @@ var require_liquid_node = __commonJS({
|
|
|
2319
2307
|
const value = this.readValue();
|
|
2320
2308
|
return [key.getText(), value];
|
|
2321
2309
|
}
|
|
2322
|
-
readTopLevelTokens(
|
|
2310
|
+
readTopLevelTokens(options = defaultOptions) {
|
|
2323
2311
|
const tokens = [];
|
|
2324
2312
|
while (this.p < this.N) {
|
|
2325
|
-
const token = this.readTopLevelToken(
|
|
2313
|
+
const token = this.readTopLevelToken(options);
|
|
2326
2314
|
tokens.push(token);
|
|
2327
2315
|
}
|
|
2328
|
-
whiteSpaceCtrl(tokens,
|
|
2316
|
+
whiteSpaceCtrl(tokens, options);
|
|
2329
2317
|
return tokens;
|
|
2330
2318
|
}
|
|
2331
|
-
readTopLevelToken(
|
|
2332
|
-
const { tagDelimiterLeft, outputDelimiterLeft } =
|
|
2319
|
+
readTopLevelToken(options) {
|
|
2320
|
+
const { tagDelimiterLeft, outputDelimiterLeft } = options;
|
|
2333
2321
|
if (this.rawBeginAt > -1)
|
|
2334
|
-
return this.readEndrawOrRawContent(
|
|
2322
|
+
return this.readEndrawOrRawContent(options);
|
|
2335
2323
|
if (this.match(tagDelimiterLeft))
|
|
2336
|
-
return this.readTagToken(
|
|
2324
|
+
return this.readTagToken(options);
|
|
2337
2325
|
if (this.match(outputDelimiterLeft))
|
|
2338
|
-
return this.readOutputToken(
|
|
2326
|
+
return this.readOutputToken(options);
|
|
2339
2327
|
return this.readHTMLToken([tagDelimiterLeft, outputDelimiterLeft]);
|
|
2340
2328
|
}
|
|
2341
2329
|
readHTMLToken(stopStrings) {
|
|
@@ -2347,13 +2335,13 @@ var require_liquid_node = __commonJS({
|
|
|
2347
2335
|
}
|
|
2348
2336
|
return new HTMLToken(this.input, begin, this.p, this.file);
|
|
2349
2337
|
}
|
|
2350
|
-
readTagToken(
|
|
2338
|
+
readTagToken(options) {
|
|
2351
2339
|
const { file: file2, input } = this;
|
|
2352
2340
|
const begin = this.p;
|
|
2353
|
-
if (this.readToDelimiter(
|
|
2341
|
+
if (this.readToDelimiter(options.tagDelimiterRight) === -1) {
|
|
2354
2342
|
throw this.error(`tag ${this.snapshot(begin)} not closed`, begin);
|
|
2355
2343
|
}
|
|
2356
|
-
const token = new TagToken(input, begin, this.p,
|
|
2344
|
+
const token = new TagToken(input, begin, this.p, options, file2);
|
|
2357
2345
|
if (token.name === "raw")
|
|
2358
2346
|
this.rawBeginAt = begin;
|
|
2359
2347
|
return token;
|
|
@@ -2371,17 +2359,17 @@ var require_liquid_node = __commonJS({
|
|
|
2371
2359
|
}
|
|
2372
2360
|
return -1;
|
|
2373
2361
|
}
|
|
2374
|
-
readOutputToken(
|
|
2362
|
+
readOutputToken(options = defaultOptions) {
|
|
2375
2363
|
const { file: file2, input } = this;
|
|
2376
|
-
const { outputDelimiterRight } =
|
|
2364
|
+
const { outputDelimiterRight } = options;
|
|
2377
2365
|
const begin = this.p;
|
|
2378
2366
|
if (this.readToDelimiter(outputDelimiterRight, true) === -1) {
|
|
2379
2367
|
throw this.error(`output ${this.snapshot(begin)} not closed`, begin);
|
|
2380
2368
|
}
|
|
2381
|
-
return new OutputToken(input, begin, this.p,
|
|
2369
|
+
return new OutputToken(input, begin, this.p, options, file2);
|
|
2382
2370
|
}
|
|
2383
|
-
readEndrawOrRawContent(
|
|
2384
|
-
const { tagDelimiterLeft, tagDelimiterRight } =
|
|
2371
|
+
readEndrawOrRawContent(options) {
|
|
2372
|
+
const { tagDelimiterLeft, tagDelimiterRight } = options;
|
|
2385
2373
|
const begin = this.p;
|
|
2386
2374
|
let leftPos = this.readTo(tagDelimiterLeft) - tagDelimiterLeft.length;
|
|
2387
2375
|
while (this.p < this.N) {
|
|
@@ -2394,7 +2382,7 @@ var require_liquid_node = __commonJS({
|
|
|
2394
2382
|
const end = this.p;
|
|
2395
2383
|
if (begin === leftPos) {
|
|
2396
2384
|
this.rawBeginAt = -1;
|
|
2397
|
-
return new TagToken(this.input, begin, end,
|
|
2385
|
+
return new TagToken(this.input, begin, end, options, this.file);
|
|
2398
2386
|
} else {
|
|
2399
2387
|
this.p = leftPos;
|
|
2400
2388
|
return new HTMLToken(this.input, begin, leftPos, this.file);
|
|
@@ -2407,22 +2395,22 @@ var require_liquid_node = __commonJS({
|
|
|
2407
2395
|
}
|
|
2408
2396
|
throw this.error(`raw ${this.snapshot(this.rawBeginAt)} not closed`, begin);
|
|
2409
2397
|
}
|
|
2410
|
-
readLiquidTagTokens(
|
|
2398
|
+
readLiquidTagTokens(options = defaultOptions) {
|
|
2411
2399
|
const tokens = [];
|
|
2412
2400
|
while (this.p < this.N) {
|
|
2413
|
-
const token = this.readLiquidTagToken(
|
|
2401
|
+
const token = this.readLiquidTagToken(options);
|
|
2414
2402
|
token && tokens.push(token);
|
|
2415
2403
|
}
|
|
2416
2404
|
return tokens;
|
|
2417
2405
|
}
|
|
2418
|
-
readLiquidTagToken(
|
|
2406
|
+
readLiquidTagToken(options) {
|
|
2419
2407
|
this.skipBlank();
|
|
2420
2408
|
if (this.end())
|
|
2421
2409
|
return;
|
|
2422
2410
|
const begin = this.p;
|
|
2423
2411
|
this.readToDelimiter("\n");
|
|
2424
2412
|
const end = this.p;
|
|
2425
|
-
return new LiquidTagToken(this.input, begin, end,
|
|
2413
|
+
return new LiquidTagToken(this.input, begin, end, options, this.file);
|
|
2426
2414
|
}
|
|
2427
2415
|
error(msg, pos = this.p) {
|
|
2428
2416
|
return new TokenizationError(msg, new IdentifierToken(this.input, pos, this.N, this.file));
|
|
@@ -2634,12 +2622,12 @@ var require_liquid_node = __commonJS({
|
|
|
2634
2622
|
}
|
|
2635
2623
|
return new QuotedToken(this.input, begin, this.p, this.file);
|
|
2636
2624
|
}
|
|
2637
|
-
*readFileNameTemplate(
|
|
2638
|
-
const { outputDelimiterLeft } =
|
|
2625
|
+
*readFileNameTemplate(options) {
|
|
2626
|
+
const { outputDelimiterLeft } = options;
|
|
2639
2627
|
const htmlStopStrings = [",", " ", "\r", "\n", " ", outputDelimiterLeft];
|
|
2640
2628
|
const htmlStopStringSet = new Set(htmlStopStrings);
|
|
2641
2629
|
while (this.p < this.N && !htmlStopStringSet.has(this.peek())) {
|
|
2642
|
-
yield this.match(outputDelimiterLeft) ? this.readOutputToken(
|
|
2630
|
+
yield this.match(outputDelimiterLeft) ? this.readOutputToken(options) : this.readHTMLToken(htmlStopStrings);
|
|
2643
2631
|
}
|
|
2644
2632
|
}
|
|
2645
2633
|
match(word) {
|
|
@@ -2714,7 +2702,7 @@ var require_liquid_node = __commonJS({
|
|
|
2714
2702
|
this.token = token;
|
|
2715
2703
|
}
|
|
2716
2704
|
};
|
|
2717
|
-
var
|
|
2705
|
+
var Tag3 = class extends TemplateImpl {
|
|
2718
2706
|
static {
|
|
2719
2707
|
__name(this, "Tag");
|
|
2720
2708
|
}
|
|
@@ -2744,17 +2732,17 @@ var require_liquid_node = __commonJS({
|
|
|
2744
2732
|
return hash2;
|
|
2745
2733
|
}
|
|
2746
2734
|
};
|
|
2747
|
-
function createTagClass(
|
|
2748
|
-
return class extends
|
|
2735
|
+
function createTagClass(options) {
|
|
2736
|
+
return class extends Tag3 {
|
|
2749
2737
|
constructor(token, tokens, liquid) {
|
|
2750
2738
|
super(token, tokens, liquid);
|
|
2751
|
-
if (isFunction(
|
|
2752
|
-
|
|
2739
|
+
if (isFunction(options.parse)) {
|
|
2740
|
+
options.parse.call(this, token, tokens);
|
|
2753
2741
|
}
|
|
2754
2742
|
}
|
|
2755
2743
|
*render(ctx, emitter) {
|
|
2756
2744
|
const hash2 = yield new Hash(this.token.args, ctx.opts.keyValueSeparator).render(ctx);
|
|
2757
|
-
return yield
|
|
2745
|
+
return yield options.render.call(this, ctx, emitter, hash2);
|
|
2758
2746
|
}
|
|
2759
2747
|
};
|
|
2760
2748
|
}
|
|
@@ -2971,13 +2959,13 @@ var require_liquid_node = __commonJS({
|
|
|
2971
2959
|
};
|
|
2972
2960
|
}
|
|
2973
2961
|
__name(_analyze, "_analyze");
|
|
2974
|
-
function analyze(template2,
|
|
2975
|
-
const opts = { ...defaultStaticAnalysisOptions, ...
|
|
2962
|
+
function analyze(template2, options = {}) {
|
|
2963
|
+
const opts = { ...defaultStaticAnalysisOptions, ...options };
|
|
2976
2964
|
return toPromise(_analyze(template2, opts.partials, false));
|
|
2977
2965
|
}
|
|
2978
2966
|
__name(analyze, "analyze");
|
|
2979
|
-
function analyzeSync(template2,
|
|
2980
|
-
const opts = { ...defaultStaticAnalysisOptions, ...
|
|
2967
|
+
function analyzeSync(template2, options = {}) {
|
|
2968
|
+
const opts = { ...defaultStaticAnalysisOptions, ...options };
|
|
2981
2969
|
return toValueSync(_analyze(template2, opts.partials, true));
|
|
2982
2970
|
}
|
|
2983
2971
|
__name(analyzeSync, "analyzeSync");
|
|
@@ -3153,17 +3141,17 @@ var require_liquid_node = __commonJS({
|
|
|
3153
3141
|
static {
|
|
3154
3142
|
__name(this, "Loader");
|
|
3155
3143
|
}
|
|
3156
|
-
constructor(
|
|
3157
|
-
this.options =
|
|
3158
|
-
if (
|
|
3159
|
-
const sep =
|
|
3144
|
+
constructor(options) {
|
|
3145
|
+
this.options = options;
|
|
3146
|
+
if (options.relativeReference) {
|
|
3147
|
+
const sep = options.fs.sep;
|
|
3160
3148
|
assert(sep, "`fs.sep` is required for relative reference");
|
|
3161
3149
|
const prefixes = ["." + sep, ".." + sep, "./", "../"];
|
|
3162
3150
|
this.shouldLoadRelative = (referencedFile) => prefixes.some((prefix) => referencedFile.startsWith(prefix));
|
|
3163
3151
|
} else {
|
|
3164
3152
|
this.shouldLoadRelative = (_referencedFile) => false;
|
|
3165
3153
|
}
|
|
3166
|
-
const fs2 =
|
|
3154
|
+
const fs2 = options.fs;
|
|
3167
3155
|
this.contains = toLiquidAsync(fs2.contains?.bind(fs2) || (async () => true), fs2.containsSync?.bind(fs2) || (() => true));
|
|
3168
3156
|
this.exists = toLiquidAsync(fs2.exists?.bind(fs2) || (async () => false), fs2.existsSync?.bind(fs2));
|
|
3169
3157
|
}
|
|
@@ -3615,7 +3603,7 @@ var require_liquid_node = __commonJS({
|
|
|
3615
3603
|
uri_escape,
|
|
3616
3604
|
slugify
|
|
3617
3605
|
});
|
|
3618
|
-
var
|
|
3606
|
+
var join6 = argumentsToValue(function(v, arg) {
|
|
3619
3607
|
const array2 = toArray(v);
|
|
3620
3608
|
const sep = isNil(arg) ? " " : stringify(arg);
|
|
3621
3609
|
let outputSize = sep.length * Math.max(array2.length - 1, 0);
|
|
@@ -3891,7 +3879,7 @@ var require_liquid_node = __commonJS({
|
|
|
3891
3879
|
__name(sample, "sample");
|
|
3892
3880
|
var arrayFilters = /* @__PURE__ */ Object.freeze({
|
|
3893
3881
|
__proto__: null,
|
|
3894
|
-
join:
|
|
3882
|
+
join: join6,
|
|
3895
3883
|
last,
|
|
3896
3884
|
first,
|
|
3897
3885
|
reverse,
|
|
@@ -4313,7 +4301,7 @@ var require_liquid_node = __commonJS({
|
|
|
4313
4301
|
...cryptoFilters,
|
|
4314
4302
|
...misc
|
|
4315
4303
|
};
|
|
4316
|
-
var AssignTag = class extends
|
|
4304
|
+
var AssignTag = class extends Tag3 {
|
|
4317
4305
|
static {
|
|
4318
4306
|
__name(this, "AssignTag");
|
|
4319
4307
|
}
|
|
@@ -4338,7 +4326,7 @@ var require_liquid_node = __commonJS({
|
|
|
4338
4326
|
}
|
|
4339
4327
|
};
|
|
4340
4328
|
var MODIFIERS = ["offset", "limit", "reversed"];
|
|
4341
|
-
var ForTag = class extends
|
|
4329
|
+
var ForTag = class extends Tag3 {
|
|
4342
4330
|
static {
|
|
4343
4331
|
__name(this, "ForTag");
|
|
4344
4332
|
}
|
|
@@ -4431,7 +4419,7 @@ var require_liquid_node = __commonJS({
|
|
|
4431
4419
|
return arr.slice(0, count3);
|
|
4432
4420
|
}
|
|
4433
4421
|
__name(limit2, "limit");
|
|
4434
|
-
var CaptureTag = class extends
|
|
4422
|
+
var CaptureTag = class extends Tag3 {
|
|
4435
4423
|
static {
|
|
4436
4424
|
__name(this, "CaptureTag");
|
|
4437
4425
|
}
|
|
@@ -4469,7 +4457,7 @@ var require_liquid_node = __commonJS({
|
|
|
4469
4457
|
yield this.identifier;
|
|
4470
4458
|
}
|
|
4471
4459
|
};
|
|
4472
|
-
var CaseTag = class extends
|
|
4460
|
+
var CaseTag = class extends Tag3 {
|
|
4473
4461
|
static {
|
|
4474
4462
|
__name(this, "CaseTag");
|
|
4475
4463
|
}
|
|
@@ -4542,7 +4530,7 @@ var require_liquid_node = __commonJS({
|
|
|
4542
4530
|
return templates;
|
|
4543
4531
|
}
|
|
4544
4532
|
};
|
|
4545
|
-
var CommentTag = class extends
|
|
4533
|
+
var CommentTag = class extends Tag3 {
|
|
4546
4534
|
static {
|
|
4547
4535
|
__name(this, "CommentTag");
|
|
4548
4536
|
}
|
|
@@ -4558,7 +4546,7 @@ var require_liquid_node = __commonJS({
|
|
|
4558
4546
|
render() {
|
|
4559
4547
|
}
|
|
4560
4548
|
};
|
|
4561
|
-
var RenderTag = class extends
|
|
4549
|
+
var RenderTag = class extends Tag3 {
|
|
4562
4550
|
static {
|
|
4563
4551
|
__name(this, "RenderTag");
|
|
4564
4552
|
}
|
|
@@ -4705,7 +4693,7 @@ var require_liquid_node = __commonJS({
|
|
|
4705
4693
|
return yield evalToken(file2, ctx);
|
|
4706
4694
|
}
|
|
4707
4695
|
__name(renderFilePath, "renderFilePath");
|
|
4708
|
-
var IncludeTag = class extends
|
|
4696
|
+
var IncludeTag = class extends Tag3 {
|
|
4709
4697
|
static {
|
|
4710
4698
|
__name(this, "IncludeTag");
|
|
4711
4699
|
}
|
|
@@ -4773,7 +4761,7 @@ var require_liquid_node = __commonJS({
|
|
|
4773
4761
|
}
|
|
4774
4762
|
}
|
|
4775
4763
|
};
|
|
4776
|
-
var DecrementTag = class extends
|
|
4764
|
+
var DecrementTag = class extends Tag3 {
|
|
4777
4765
|
static {
|
|
4778
4766
|
__name(this, "DecrementTag");
|
|
4779
4767
|
}
|
|
@@ -4793,7 +4781,7 @@ var require_liquid_node = __commonJS({
|
|
|
4793
4781
|
yield this.identifier;
|
|
4794
4782
|
}
|
|
4795
4783
|
};
|
|
4796
|
-
var CycleTag = class extends
|
|
4784
|
+
var CycleTag = class extends Tag3 {
|
|
4797
4785
|
static {
|
|
4798
4786
|
__name(this, "CycleTag");
|
|
4799
4787
|
}
|
|
@@ -4837,7 +4825,7 @@ var require_liquid_node = __commonJS({
|
|
|
4837
4825
|
}
|
|
4838
4826
|
}
|
|
4839
4827
|
};
|
|
4840
|
-
var IfTag = class extends
|
|
4828
|
+
var IfTag = class extends Tag3 {
|
|
4841
4829
|
static {
|
|
4842
4830
|
__name(this, "IfTag");
|
|
4843
4831
|
}
|
|
@@ -4887,7 +4875,7 @@ var require_liquid_node = __commonJS({
|
|
|
4887
4875
|
return this.branches.map((b) => b.value);
|
|
4888
4876
|
}
|
|
4889
4877
|
};
|
|
4890
|
-
var IncrementTag = class extends
|
|
4878
|
+
var IncrementTag = class extends Tag3 {
|
|
4891
4879
|
static {
|
|
4892
4880
|
__name(this, "IncrementTag");
|
|
4893
4881
|
}
|
|
@@ -4909,7 +4897,7 @@ var require_liquid_node = __commonJS({
|
|
|
4909
4897
|
yield this.identifier;
|
|
4910
4898
|
}
|
|
4911
4899
|
};
|
|
4912
|
-
var LayoutTag = class extends
|
|
4900
|
+
var LayoutTag = class extends Tag3 {
|
|
4913
4901
|
static {
|
|
4914
4902
|
__name(this, "LayoutTag");
|
|
4915
4903
|
}
|
|
@@ -4964,7 +4952,7 @@ var require_liquid_node = __commonJS({
|
|
|
4964
4952
|
}
|
|
4965
4953
|
}
|
|
4966
4954
|
};
|
|
4967
|
-
var BlockTag = class extends
|
|
4955
|
+
var BlockTag = class extends Tag3 {
|
|
4968
4956
|
static {
|
|
4969
4957
|
__name(this, "BlockTag");
|
|
4970
4958
|
}
|
|
@@ -5013,7 +5001,7 @@ var require_liquid_node = __commonJS({
|
|
|
5013
5001
|
return ["block"];
|
|
5014
5002
|
}
|
|
5015
5003
|
};
|
|
5016
|
-
var RawTag = class extends
|
|
5004
|
+
var RawTag = class extends Tag3 {
|
|
5017
5005
|
static {
|
|
5018
5006
|
__name(this, "RawTag");
|
|
5019
5007
|
}
|
|
@@ -5057,7 +5045,7 @@ var require_liquid_node = __commonJS({
|
|
|
5057
5045
|
return this.col() === this.cols;
|
|
5058
5046
|
}
|
|
5059
5047
|
};
|
|
5060
|
-
var TablerowTag = class extends
|
|
5048
|
+
var TablerowTag = class extends Tag3 {
|
|
5061
5049
|
static {
|
|
5062
5050
|
__name(this, "TablerowTag");
|
|
5063
5051
|
}
|
|
@@ -5121,7 +5109,7 @@ var require_liquid_node = __commonJS({
|
|
|
5121
5109
|
return [this.variable, "tablerowloop"];
|
|
5122
5110
|
}
|
|
5123
5111
|
};
|
|
5124
|
-
var UnlessTag = class extends
|
|
5112
|
+
var UnlessTag = class extends Tag3 {
|
|
5125
5113
|
static {
|
|
5126
5114
|
__name(this, "UnlessTag");
|
|
5127
5115
|
}
|
|
@@ -5180,7 +5168,7 @@ var require_liquid_node = __commonJS({
|
|
|
5180
5168
|
return this.branches.map((b) => b.value);
|
|
5181
5169
|
}
|
|
5182
5170
|
};
|
|
5183
|
-
var BreakTag = class extends
|
|
5171
|
+
var BreakTag = class extends Tag3 {
|
|
5184
5172
|
static {
|
|
5185
5173
|
__name(this, "BreakTag");
|
|
5186
5174
|
}
|
|
@@ -5188,7 +5176,7 @@ var require_liquid_node = __commonJS({
|
|
|
5188
5176
|
ctx.breakCalled = true;
|
|
5189
5177
|
}
|
|
5190
5178
|
};
|
|
5191
|
-
var ContinueTag = class extends
|
|
5179
|
+
var ContinueTag = class extends Tag3 {
|
|
5192
5180
|
static {
|
|
5193
5181
|
__name(this, "ContinueTag");
|
|
5194
5182
|
}
|
|
@@ -5196,7 +5184,7 @@ var require_liquid_node = __commonJS({
|
|
|
5196
5184
|
ctx.continueCalled = true;
|
|
5197
5185
|
}
|
|
5198
5186
|
};
|
|
5199
|
-
var EchoTag = class extends
|
|
5187
|
+
var EchoTag = class extends Tag3 {
|
|
5200
5188
|
static {
|
|
5201
5189
|
__name(this, "EchoTag");
|
|
5202
5190
|
}
|
|
@@ -5219,7 +5207,7 @@ var require_liquid_node = __commonJS({
|
|
|
5219
5207
|
}
|
|
5220
5208
|
}
|
|
5221
5209
|
};
|
|
5222
|
-
var LiquidTag = class extends
|
|
5210
|
+
var LiquidTag = class extends Tag3 {
|
|
5223
5211
|
static {
|
|
5224
5212
|
__name(this, "LiquidTag");
|
|
5225
5213
|
}
|
|
@@ -5235,7 +5223,7 @@ var require_liquid_node = __commonJS({
|
|
|
5235
5223
|
return this.templates;
|
|
5236
5224
|
}
|
|
5237
5225
|
};
|
|
5238
|
-
var InlineCommentTag = class extends
|
|
5226
|
+
var InlineCommentTag = class extends Tag3 {
|
|
5239
5227
|
static {
|
|
5240
5228
|
__name(this, "InlineCommentTag");
|
|
5241
5229
|
}
|
|
@@ -5378,76 +5366,76 @@ var require_liquid_node = __commonJS({
|
|
|
5378
5366
|
self.renderFile(filePath, ctx).then((html) => callback(null, html), callback);
|
|
5379
5367
|
};
|
|
5380
5368
|
}
|
|
5381
|
-
async analyze(template2,
|
|
5382
|
-
return analyze(template2,
|
|
5369
|
+
async analyze(template2, options = {}) {
|
|
5370
|
+
return analyze(template2, options);
|
|
5383
5371
|
}
|
|
5384
|
-
analyzeSync(template2,
|
|
5385
|
-
return analyzeSync(template2,
|
|
5372
|
+
analyzeSync(template2, options = {}) {
|
|
5373
|
+
return analyzeSync(template2, options);
|
|
5386
5374
|
}
|
|
5387
|
-
async parseAndAnalyze(html, filename,
|
|
5388
|
-
return analyze(this.parse(html, filename),
|
|
5375
|
+
async parseAndAnalyze(html, filename, options = {}) {
|
|
5376
|
+
return analyze(this.parse(html, filename), options);
|
|
5389
5377
|
}
|
|
5390
|
-
parseAndAnalyzeSync(html, filename,
|
|
5391
|
-
return analyzeSync(this.parse(html, filename),
|
|
5378
|
+
parseAndAnalyzeSync(html, filename, options = {}) {
|
|
5379
|
+
return analyzeSync(this.parse(html, filename), options);
|
|
5392
5380
|
}
|
|
5393
5381
|
/** Return an array of all variables without their properties. */
|
|
5394
|
-
async variables(template2,
|
|
5395
|
-
const analysis = await analyze(isString(template2) ? this.parse(template2) : template2,
|
|
5382
|
+
async variables(template2, options = {}) {
|
|
5383
|
+
const analysis = await analyze(isString(template2) ? this.parse(template2) : template2, options);
|
|
5396
5384
|
return Object.keys(analysis.variables);
|
|
5397
5385
|
}
|
|
5398
5386
|
/** Return an array of all variables without their properties. */
|
|
5399
|
-
variablesSync(template2,
|
|
5400
|
-
const analysis = analyzeSync(isString(template2) ? this.parse(template2) : template2,
|
|
5387
|
+
variablesSync(template2, options = {}) {
|
|
5388
|
+
const analysis = analyzeSync(isString(template2) ? this.parse(template2) : template2, options);
|
|
5401
5389
|
return Object.keys(analysis.variables);
|
|
5402
5390
|
}
|
|
5403
5391
|
/** Return an array of all variables including their properties/paths. */
|
|
5404
|
-
async fullVariables(template2,
|
|
5405
|
-
const analysis = await analyze(isString(template2) ? this.parse(template2) : template2,
|
|
5392
|
+
async fullVariables(template2, options = {}) {
|
|
5393
|
+
const analysis = await analyze(isString(template2) ? this.parse(template2) : template2, options);
|
|
5406
5394
|
return Array.from(new Set(Object.values(analysis.variables).flatMap((a) => a.map((v) => String(v)))));
|
|
5407
5395
|
}
|
|
5408
5396
|
/** Return an array of all variables including their properties/paths. */
|
|
5409
|
-
fullVariablesSync(template2,
|
|
5410
|
-
const analysis = analyzeSync(isString(template2) ? this.parse(template2) : template2,
|
|
5397
|
+
fullVariablesSync(template2, options = {}) {
|
|
5398
|
+
const analysis = analyzeSync(isString(template2) ? this.parse(template2) : template2, options);
|
|
5411
5399
|
return Array.from(new Set(Object.values(analysis.variables).flatMap((a) => a.map((v) => String(v)))));
|
|
5412
5400
|
}
|
|
5413
5401
|
/** Return an array of all variables, each as an array of properties/segments. */
|
|
5414
|
-
async variableSegments(template2,
|
|
5415
|
-
const analysis = await analyze(isString(template2) ? this.parse(template2) : template2,
|
|
5402
|
+
async variableSegments(template2, options = {}) {
|
|
5403
|
+
const analysis = await analyze(isString(template2) ? this.parse(template2) : template2, options);
|
|
5416
5404
|
return Array.from(strictUniq(Object.values(analysis.variables).flatMap((a) => a.map((v) => v.toArray()))));
|
|
5417
5405
|
}
|
|
5418
5406
|
/** Return an array of all variables, each as an array of properties/segments. */
|
|
5419
|
-
variableSegmentsSync(template2,
|
|
5420
|
-
const analysis = analyzeSync(isString(template2) ? this.parse(template2) : template2,
|
|
5407
|
+
variableSegmentsSync(template2, options = {}) {
|
|
5408
|
+
const analysis = analyzeSync(isString(template2) ? this.parse(template2) : template2, options);
|
|
5421
5409
|
return Array.from(strictUniq(Object.values(analysis.variables).flatMap((a) => a.map((v) => v.toArray()))));
|
|
5422
5410
|
}
|
|
5423
5411
|
/** Return an array of all expected context variables without their properties. */
|
|
5424
|
-
async globalVariables(template2,
|
|
5425
|
-
const analysis = await analyze(isString(template2) ? this.parse(template2) : template2,
|
|
5412
|
+
async globalVariables(template2, options = {}) {
|
|
5413
|
+
const analysis = await analyze(isString(template2) ? this.parse(template2) : template2, options);
|
|
5426
5414
|
return Object.keys(analysis.globals);
|
|
5427
5415
|
}
|
|
5428
5416
|
/** Return an array of all expected context variables without their properties. */
|
|
5429
|
-
globalVariablesSync(template2,
|
|
5430
|
-
const analysis = analyzeSync(isString(template2) ? this.parse(template2) : template2,
|
|
5417
|
+
globalVariablesSync(template2, options = {}) {
|
|
5418
|
+
const analysis = analyzeSync(isString(template2) ? this.parse(template2) : template2, options);
|
|
5431
5419
|
return Object.keys(analysis.globals);
|
|
5432
5420
|
}
|
|
5433
5421
|
/** Return an array of all expected context variables including their properties/paths. */
|
|
5434
|
-
async globalFullVariables(template2,
|
|
5435
|
-
const analysis = await analyze(isString(template2) ? this.parse(template2) : template2,
|
|
5422
|
+
async globalFullVariables(template2, options = {}) {
|
|
5423
|
+
const analysis = await analyze(isString(template2) ? this.parse(template2) : template2, options);
|
|
5436
5424
|
return Array.from(new Set(Object.values(analysis.globals).flatMap((a) => a.map((v) => String(v)))));
|
|
5437
5425
|
}
|
|
5438
5426
|
/** Return an array of all expected context variables including their properties/paths. */
|
|
5439
|
-
globalFullVariablesSync(template2,
|
|
5440
|
-
const analysis = analyzeSync(isString(template2) ? this.parse(template2) : template2,
|
|
5427
|
+
globalFullVariablesSync(template2, options = {}) {
|
|
5428
|
+
const analysis = analyzeSync(isString(template2) ? this.parse(template2) : template2, options);
|
|
5441
5429
|
return Array.from(new Set(Object.values(analysis.globals).flatMap((a) => a.map((v) => String(v)))));
|
|
5442
5430
|
}
|
|
5443
5431
|
/** Return an array of all expected context variables, each as an array of properties/segments. */
|
|
5444
|
-
async globalVariableSegments(template2,
|
|
5445
|
-
const analysis = await analyze(isString(template2) ? this.parse(template2) : template2,
|
|
5432
|
+
async globalVariableSegments(template2, options = {}) {
|
|
5433
|
+
const analysis = await analyze(isString(template2) ? this.parse(template2) : template2, options);
|
|
5446
5434
|
return Array.from(strictUniq(Object.values(analysis.globals).flatMap((a) => a.map((v) => v.toArray()))));
|
|
5447
5435
|
}
|
|
5448
5436
|
/** Return an array of all expected context variables, each as an array of properties/segments. */
|
|
5449
|
-
globalVariableSegmentsSync(template2,
|
|
5450
|
-
const analysis = analyzeSync(isString(template2) ? this.parse(template2) : template2,
|
|
5437
|
+
globalVariableSegmentsSync(template2, options = {}) {
|
|
5438
|
+
const analysis = analyzeSync(isString(template2) ? this.parse(template2) : template2, options);
|
|
5451
5439
|
return Array.from(strictUniq(Object.values(analysis.globals).flatMap((a) => a.map((v) => v.toArray()))));
|
|
5452
5440
|
}
|
|
5453
5441
|
};
|
|
@@ -5485,7 +5473,7 @@ var require_liquid_node = __commonJS({
|
|
|
5485
5473
|
exports.RenderError = RenderError;
|
|
5486
5474
|
exports.RenderTag = RenderTag;
|
|
5487
5475
|
exports.TablerowTag = TablerowTag;
|
|
5488
|
-
exports.Tag =
|
|
5476
|
+
exports.Tag = Tag3;
|
|
5489
5477
|
exports.TagToken = TagToken;
|
|
5490
5478
|
exports.Token = Token;
|
|
5491
5479
|
exports.TokenizationError = TokenizationError;
|
|
@@ -5515,11 +5503,11 @@ var require_liquid_node = __commonJS({
|
|
|
5515
5503
|
}
|
|
5516
5504
|
});
|
|
5517
5505
|
|
|
5518
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5519
|
-
import { chmodSync, constants, copyFileSync, existsSync as
|
|
5520
|
-
import { dirname as
|
|
5506
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/cli/messenger/store-maintenance-command.js
|
|
5507
|
+
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";
|
|
5508
|
+
import { dirname as dirname3, resolve } from "node:path";
|
|
5521
5509
|
|
|
5522
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5510
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/sealed.js
|
|
5523
5511
|
import { createCipheriv, createDecipheriv, createHash, randomBytes, scrypt, timingSafeEqual } from "node:crypto";
|
|
5524
5512
|
import { closeSync, createReadStream, createWriteStream, existsSync, openSync, readSync, renameSync, rmSync, statSync } from "node:fs";
|
|
5525
5513
|
import { Transform } from "node:stream";
|
|
@@ -5626,7 +5614,7 @@ var unsealFile = /* @__PURE__ */ __name(async (from, to, password) => {
|
|
|
5626
5614
|
renameSync(pending, to);
|
|
5627
5615
|
}, "unsealFile");
|
|
5628
5616
|
|
|
5629
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5617
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/store/compatibility.js
|
|
5630
5618
|
var SPEAKS = MIGRATIONS.at(-1)?.version ?? 0;
|
|
5631
5619
|
var fileSchemaOf = /* @__PURE__ */ __name((database) => {
|
|
5632
5620
|
const tracked = database.prepare("SELECT 1 FROM sqlite_master WHERE name = 'schema_migrations'").get();
|
|
@@ -5650,7 +5638,7 @@ var compatibilityOf = /* @__PURE__ */ __name((file2, migrations = MIGRATIONS) =>
|
|
|
5650
5638
|
};
|
|
5651
5639
|
}, "compatibilityOf");
|
|
5652
5640
|
|
|
5653
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5641
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/store/repair.js
|
|
5654
5642
|
import { createHash as createHash2 } from "node:crypto";
|
|
5655
5643
|
var COPY_MARK = "__repair_";
|
|
5656
5644
|
var COPY_NAME = /__repair_[0-9a-f]{8}(_\d+)?$/;
|
|
@@ -5904,17 +5892,99 @@ var deleteCopy = /* @__PURE__ */ __name((database, name) => {
|
|
|
5904
5892
|
return found;
|
|
5905
5893
|
}, "deleteCopy");
|
|
5906
5894
|
|
|
5907
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5895
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/cli/store-info.js
|
|
5908
5896
|
import { existsSync as existsSync4, statSync as statSync3 } from "node:fs";
|
|
5909
5897
|
|
|
5910
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5898
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/cli/store-recover.js
|
|
5911
5899
|
import { existsSync as existsSync3 } from "node:fs";
|
|
5912
5900
|
|
|
5913
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5901
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/store/recover.js
|
|
5914
5902
|
import { execFileSync, spawn } from "node:child_process";
|
|
5915
5903
|
import { existsSync as existsSync2, readFileSync, realpathSync, renameSync as renameSync2, rmSync as rmSync2, statfsSync, statSync as statSync2, writeFileSync } from "node:fs";
|
|
5916
5904
|
import { basename, dirname, join } from "node:path";
|
|
5917
5905
|
import { Transform as Transform2 } from "node:stream";
|
|
5906
|
+
|
|
5907
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/store/refill.js
|
|
5908
|
+
var REFILL_MARGIN_MS = 864e5;
|
|
5909
|
+
var TIME_KEYS = 1e12;
|
|
5910
|
+
var integerId = `external_id GLOB '[0-9]*' AND NOT external_id GLOB '*[^0-9]*'`;
|
|
5911
|
+
var forgetCoverageSince = /* @__PURE__ */ __name((database, cutoff, now = Date.now()) => {
|
|
5912
|
+
database.exec("BEGIN");
|
|
5913
|
+
try {
|
|
5914
|
+
const refetch = forget(database, cutoff, now);
|
|
5915
|
+
database.exec("COMMIT");
|
|
5916
|
+
return refetch;
|
|
5917
|
+
} catch (error) {
|
|
5918
|
+
database.exec("ROLLBACK");
|
|
5919
|
+
throw error;
|
|
5920
|
+
}
|
|
5921
|
+
}, "forgetCoverageSince");
|
|
5922
|
+
var forget = /* @__PURE__ */ __name((database, cutoff, now) => {
|
|
5923
|
+
const chats = /* @__PURE__ */ new Map();
|
|
5924
|
+
const held = database.prepare(`SELECT c.id, c.account_id, c.external_id AS chat, a.provider, a.external_id AS account,
|
|
5925
|
+
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
|
|
5926
|
+
GROUP BY c.id`).all();
|
|
5927
|
+
for (const row of held) {
|
|
5928
|
+
const chat = Number(row.id);
|
|
5929
|
+
const top = Number(row.top);
|
|
5930
|
+
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;
|
|
5931
|
+
if (keepTo !== null && top <= keepTo)
|
|
5932
|
+
continue;
|
|
5933
|
+
if (keepTo === null)
|
|
5934
|
+
database.prepare("DELETE FROM sync_ranges WHERE chat_id = ?").run(chat);
|
|
5935
|
+
else {
|
|
5936
|
+
database.prepare("DELETE FROM sync_ranges WHERE chat_id = ? AND from_key > ?").run(chat, keepTo);
|
|
5937
|
+
database.prepare("UPDATE sync_ranges SET to_key = ?, updated_at = ? WHERE chat_id = ? AND to_key > ?").run(keepTo, now, chat, keepTo);
|
|
5938
|
+
}
|
|
5939
|
+
const account = Number(row.account_id);
|
|
5940
|
+
const external = String(row.chat);
|
|
5941
|
+
database.prepare("DELETE FROM sync_cursors WHERE account_id = ? AND key = ?").run(account, `fetched:${external}`);
|
|
5942
|
+
database.prepare(`DELETE FROM sync_cursors WHERE account_id = ? AND key = ? AND NOT EXISTS
|
|
5943
|
+
(SELECT 1 FROM sync_ranges WHERE chat_id = ? AND from_key <= CAST(sync_cursors.value AS INTEGER))`).run(account, `history_start:${external}`, chat);
|
|
5944
|
+
const key = `${row.provider}\0${row.account}`;
|
|
5945
|
+
const one = chats.get(key) ?? { provider: String(row.provider), account: String(row.account), chats: 0 };
|
|
5946
|
+
one.chats += 1;
|
|
5947
|
+
chats.set(key, one);
|
|
5948
|
+
}
|
|
5949
|
+
return {
|
|
5950
|
+
since: cutoff === null ? null : new Date(cutoff).toISOString(),
|
|
5951
|
+
chats: [...chats.values()],
|
|
5952
|
+
mail: forgetMail(database, cutoff, now)
|
|
5953
|
+
};
|
|
5954
|
+
}, "forget");
|
|
5955
|
+
var forgetMail = /* @__PURE__ */ __name((database, cutoff, now) => {
|
|
5956
|
+
const folders = /* @__PURE__ */ new Map();
|
|
5957
|
+
const points = database.prepare(`SELECT s.account_id, s.key, s.value, a.external_id AS account FROM sync_cursors s
|
|
5958
|
+
JOIN accounts a ON a.id = s.account_id WHERE a.provider = 'email' AND s.key LIKE 'mail_resume:%'`).all();
|
|
5959
|
+
for (const row of points) {
|
|
5960
|
+
let point;
|
|
5961
|
+
try {
|
|
5962
|
+
point = JSON.parse(String(row.value));
|
|
5963
|
+
} catch {
|
|
5964
|
+
continue;
|
|
5965
|
+
}
|
|
5966
|
+
const account = String(row.account);
|
|
5967
|
+
if (!Array.isArray(point.done)) {
|
|
5968
|
+
if (cutoff !== null && Date.parse(point.updatedAt ?? "") < cutoff)
|
|
5969
|
+
continue;
|
|
5970
|
+
database.prepare("DELETE FROM sync_cursors WHERE account_id = ? AND key = ?").run(Number(row.account_id), String(row.key));
|
|
5971
|
+
folders.set(account, (folders.get(account) ?? 0) + 1);
|
|
5972
|
+
continue;
|
|
5973
|
+
}
|
|
5974
|
+
const folder = String(row.key).slice("mail_resume:".length);
|
|
5975
|
+
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
|
|
5976
|
+
WHERE l.mailbox_id = (SELECT id FROM mailboxes WHERE account_id = ? AND external_id = ?)
|
|
5977
|
+
AND l.uidvalidity = ? AND coalesce(e.received_at, e.sent_at) < ?`).get(Number(row.account_id), folder, point.validity ?? "", cutoff)?.uid;
|
|
5978
|
+
const done = last === null ? [] : point.done.filter(([from]) => from <= last).map(([from, to]) => [from, Math.min(to, last)]);
|
|
5979
|
+
if (JSON.stringify(done) === JSON.stringify(point.done))
|
|
5980
|
+
continue;
|
|
5981
|
+
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));
|
|
5982
|
+
folders.set(account, (folders.get(account) ?? 0) + 1);
|
|
5983
|
+
}
|
|
5984
|
+
return [...folders].map(([account, count3]) => ({ account, folders: count3 }));
|
|
5985
|
+
}, "forgetMail");
|
|
5986
|
+
|
|
5987
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/store/recover.js
|
|
5918
5988
|
var SQLITE3_MINIMUM = [3, 43, 0];
|
|
5919
5989
|
var STORE_PARTS = ["", "-wal", "-shm"];
|
|
5920
5990
|
var RECOVER_LOCK = ".recover-lock";
|
|
@@ -6009,9 +6079,12 @@ var storeHolders = /* @__PURE__ */ __name((path) => {
|
|
|
6009
6079
|
return { pid, name };
|
|
6010
6080
|
});
|
|
6011
6081
|
}, "storeHolders");
|
|
6012
|
-
var
|
|
6082
|
+
var dataTables = /* @__PURE__ */ __name((database) => {
|
|
6013
6083
|
const indexes = fts5Tables(database).map((index) => index.name);
|
|
6014
|
-
|
|
6084
|
+
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}_`)));
|
|
6085
|
+
}, "dataTables");
|
|
6086
|
+
var tableRows = /* @__PURE__ */ __name((database) => {
|
|
6087
|
+
const tables = dataTables(database);
|
|
6015
6088
|
return Object.fromEntries(tables.map((table) => {
|
|
6016
6089
|
try {
|
|
6017
6090
|
return [table, Number(database.prepare(`SELECT count(*) AS n FROM "${table}"`).get()?.n)];
|
|
@@ -6020,6 +6093,117 @@ var tableRows = /* @__PURE__ */ __name((database) => {
|
|
|
6020
6093
|
}
|
|
6021
6094
|
}));
|
|
6022
6095
|
}, "tableRows");
|
|
6096
|
+
var sourceTables = /* @__PURE__ */ __name((database) => {
|
|
6097
|
+
const withoutRowid = new Set(database.prepare("SELECT name FROM pragma_table_list WHERE wr = 1").all().map((row) => String(row.name)));
|
|
6098
|
+
return dataTables(database).filter((table) => table !== LOST_AND_FOUND && !withoutRowid.has(table) && !isDerivedTable(table));
|
|
6099
|
+
}, "sourceTables");
|
|
6100
|
+
var indexedButGone = /* @__PURE__ */ __name((database) => {
|
|
6101
|
+
const found = {};
|
|
6102
|
+
for (const table of sourceTables(database)) {
|
|
6103
|
+
const indexes = database.prepare("SELECT name FROM pragma_index_list(?) WHERE partial = 0 ORDER BY name").all(table).map((row) => String(row.name));
|
|
6104
|
+
for (const index of indexes) {
|
|
6105
|
+
const columns = database.prepare("SELECT cid, name FROM pragma_index_xinfo(?) WHERE key = 1 ORDER BY seqno").all(index);
|
|
6106
|
+
if (columns.some((column) => Number(column.cid) < 0))
|
|
6107
|
+
continue;
|
|
6108
|
+
const keys = columns.map((column) => `"${String(column.name)}"`).join(", ");
|
|
6109
|
+
const grouped = `${keys}, row_id`;
|
|
6110
|
+
let rows;
|
|
6111
|
+
try {
|
|
6112
|
+
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);
|
|
6113
|
+
} catch {
|
|
6114
|
+
continue;
|
|
6115
|
+
}
|
|
6116
|
+
if (rows > (found[table]?.rows ?? 0))
|
|
6117
|
+
found[table] = { rows, index };
|
|
6118
|
+
}
|
|
6119
|
+
}
|
|
6120
|
+
return found;
|
|
6121
|
+
}, "indexedButGone");
|
|
6122
|
+
var storedAs = /* @__PURE__ */ __name((declared) => {
|
|
6123
|
+
const type = declared.toUpperCase();
|
|
6124
|
+
if (type.includes("INT"))
|
|
6125
|
+
return ["integer"];
|
|
6126
|
+
if (/CHAR|CLOB|TEXT/.test(type))
|
|
6127
|
+
return ["text"];
|
|
6128
|
+
if (type === "" || type.includes("BLOB"))
|
|
6129
|
+
return null;
|
|
6130
|
+
if (/REAL|FLOA|DOUB/.test(type))
|
|
6131
|
+
return ["real", "integer"];
|
|
6132
|
+
return null;
|
|
6133
|
+
}, "storedAs");
|
|
6134
|
+
var columnsOf = /* @__PURE__ */ __name((database, table) => {
|
|
6135
|
+
const all = database.prepare('SELECT name, type, "notnull" AS required, dflt_value, pk FROM pragma_table_info(?)').all(table);
|
|
6136
|
+
const keys = all.filter((column) => Number(column.pk) > 0);
|
|
6137
|
+
return all.map((column) => ({
|
|
6138
|
+
name: String(column.name),
|
|
6139
|
+
type: String(column.type),
|
|
6140
|
+
required: Number(column.required) === 1,
|
|
6141
|
+
hasDefault: column.dflt_value !== null,
|
|
6142
|
+
rowid: keys.length === 1 && Number(column.pk) === 1 && String(column.type).toUpperCase() === "INTEGER"
|
|
6143
|
+
}));
|
|
6144
|
+
}, "columnsOf");
|
|
6145
|
+
var fits = /* @__PURE__ */ __name((columns, fields, types) => fields <= columns.length && columns.every((column, at) => {
|
|
6146
|
+
if (at >= fields)
|
|
6147
|
+
return !column.required || column.hasDefault;
|
|
6148
|
+
const type = types[at];
|
|
6149
|
+
if (column.rowid)
|
|
6150
|
+
return type === "null" || type === "integer";
|
|
6151
|
+
if (type === "null")
|
|
6152
|
+
return !column.required;
|
|
6153
|
+
const allowed = storedAs(column.type);
|
|
6154
|
+
return allowed === null || allowed.includes(type);
|
|
6155
|
+
}), "fits");
|
|
6156
|
+
var placeLostRows = /* @__PURE__ */ __name((database) => {
|
|
6157
|
+
if (!database.prepare("SELECT 1 FROM sqlite_master WHERE name = ?").get(LOST_AND_FOUND))
|
|
6158
|
+
return {};
|
|
6159
|
+
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));
|
|
6160
|
+
const tables = sourceTables(database).map((table) => ({ table, columns: columnsOf(database, table) }));
|
|
6161
|
+
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();
|
|
6162
|
+
const placed = {};
|
|
6163
|
+
const triggers = [];
|
|
6164
|
+
const quiet = /* @__PURE__ */ __name((table) => {
|
|
6165
|
+
if (table in placed)
|
|
6166
|
+
return;
|
|
6167
|
+
placed[table] = 0;
|
|
6168
|
+
for (const row of database.prepare("SELECT name, sql FROM sqlite_master WHERE type = 'trigger' AND tbl_name = ?").all(table)) {
|
|
6169
|
+
triggers.push(String(row.sql));
|
|
6170
|
+
database.exec(`DROP TRIGGER "${String(row.name)}"`);
|
|
6171
|
+
}
|
|
6172
|
+
}, "quiet");
|
|
6173
|
+
database.exec("PRAGMA foreign_keys = OFF");
|
|
6174
|
+
database.exec("BEGIN");
|
|
6175
|
+
try {
|
|
6176
|
+
for (const row of rows) {
|
|
6177
|
+
const count3 = Number(row.nfield);
|
|
6178
|
+
const types = fields.slice(0, count3).map((field) => String(row[field]));
|
|
6179
|
+
const fitting = tables.filter(({ columns: columns2 }) => fits(columns2, count3, types));
|
|
6180
|
+
if (fitting.length !== 1)
|
|
6181
|
+
continue;
|
|
6182
|
+
const { table, columns } = fitting[0];
|
|
6183
|
+
quiet(table);
|
|
6184
|
+
const given = columns.slice(0, count3);
|
|
6185
|
+
const names = [...given.some((column) => column.rowid) ? [] : ["rowid"], ...given.map((column) => column.name)];
|
|
6186
|
+
const values = [
|
|
6187
|
+
...given.some((column) => column.rowid) ? [] : ["id"],
|
|
6188
|
+
...given.map((column, at) => column.rowid ? "id" : `c${at}`)
|
|
6189
|
+
];
|
|
6190
|
+
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));
|
|
6191
|
+
if (Number(inserted.changes) === 0)
|
|
6192
|
+
continue;
|
|
6193
|
+
placed[table] = (placed[table] ?? 0) + 1;
|
|
6194
|
+
database.prepare(`DELETE FROM ${LOST_AND_FOUND} WHERE rowid = ?`).run(Number(row.at));
|
|
6195
|
+
}
|
|
6196
|
+
for (const sql of triggers)
|
|
6197
|
+
database.exec(sql);
|
|
6198
|
+
database.exec("COMMIT");
|
|
6199
|
+
} catch (error) {
|
|
6200
|
+
database.exec("ROLLBACK");
|
|
6201
|
+
throw error;
|
|
6202
|
+
} finally {
|
|
6203
|
+
database.exec("PRAGMA foreign_keys = ON");
|
|
6204
|
+
}
|
|
6205
|
+
return Object.fromEntries(Object.entries(placed).filter(([, rows2]) => rows2 > 0));
|
|
6206
|
+
}, "placeLostRows");
|
|
6023
6207
|
var copyReadableRows = /* @__PURE__ */ __name((path, target, program = "sqlite3") => new Promise((resolve2, reject) => {
|
|
6024
6208
|
const reader = spawn(program, ["-readonly", path, `.recover --ignore-freelist --lost-and-found ${LOST_AND_FOUND}`], {
|
|
6025
6209
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -6216,6 +6400,9 @@ var recoverLocked = /* @__PURE__ */ __name(async ({ path, command, version, sqli
|
|
|
6216
6400
|
throw error;
|
|
6217
6401
|
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" });
|
|
6218
6402
|
}
|
|
6403
|
+
note("looking for rows the indexes list and the tables no longer hold");
|
|
6404
|
+
const gone = indexedButGone(watch);
|
|
6405
|
+
const lastKnownGood = readHealthMark(path)?.last_ok_at ?? null;
|
|
6219
6406
|
const before = { data: dataVersion(), inode: statSync2(path).ino };
|
|
6220
6407
|
const stamp = new Date(now()).toISOString().replace(/[:.]/g, "-");
|
|
6221
6408
|
const target = `${path}.recovering-${stamp}`;
|
|
@@ -6242,9 +6429,12 @@ var recoverLocked = /* @__PURE__ */ __name(async ({ path, command, version, sqli
|
|
|
6242
6429
|
let kept;
|
|
6243
6430
|
let dangling;
|
|
6244
6431
|
let json;
|
|
6245
|
-
let
|
|
6432
|
+
let fetch;
|
|
6246
6433
|
let schema;
|
|
6434
|
+
let placed;
|
|
6435
|
+
let refetch;
|
|
6247
6436
|
try {
|
|
6437
|
+
placed = placeLostRows(opened.database);
|
|
6248
6438
|
kept = tableRows(opened.database);
|
|
6249
6439
|
migrate(opened.database, { command, ...version ? { version } : {} });
|
|
6250
6440
|
note("clearing values that are not valid JSON");
|
|
@@ -6252,7 +6442,9 @@ var recoverLocked = /* @__PURE__ */ __name(async ({ path, command, version, sqli
|
|
|
6252
6442
|
rebuilt = rebuildDerived(opened.database, { now, note });
|
|
6253
6443
|
note("looking for rows that point at rows that were lost");
|
|
6254
6444
|
dangling = danglingRows(opened.database);
|
|
6255
|
-
|
|
6445
|
+
fetch = mailToFetch(opened.database);
|
|
6446
|
+
const good = lastKnownGood === null ? Number.NaN : Date.parse(lastKnownGood);
|
|
6447
|
+
refetch = forgetCoverageSince(opened.database, Number.isNaN(good) ? null : good - REFILL_MARGIN_MS, now());
|
|
6256
6448
|
schema = fileSchemaOf(opened.database).version;
|
|
6257
6449
|
opened.database.exec("PRAGMA wal_checkpoint(TRUNCATE)");
|
|
6258
6450
|
} catch (error) {
|
|
@@ -6282,16 +6474,29 @@ var recoverLocked = /* @__PURE__ */ __name(async ({ path, command, version, sqli
|
|
|
6282
6474
|
if (existsSync2(`${target}${suffix}`))
|
|
6283
6475
|
renameSync2(`${target}${suffix}`, `${path}${suffix}`);
|
|
6284
6476
|
recordDeepCheck(path, health, { cli: command, ...version ? { version } : {}, schema, now });
|
|
6285
|
-
const lost = Object.entries(rowsBefore).map(([table, before2]) =>
|
|
6477
|
+
const lost = Object.entries(rowsBefore).map(([table, before2]) => {
|
|
6478
|
+
const goneAtLeast = Math.max(0, (gone[table]?.rows ?? 0) - (placed[table] ?? 0));
|
|
6479
|
+
return {
|
|
6480
|
+
table,
|
|
6481
|
+
before: before2,
|
|
6482
|
+
read: read[table] ?? 0,
|
|
6483
|
+
kept: kept[table] ?? 0,
|
|
6484
|
+
goneAtLeast,
|
|
6485
|
+
seenIn: goneAtLeast > 0 ? gone[table]?.index ?? null : null
|
|
6486
|
+
};
|
|
6487
|
+
}).filter(({ before: before2, read: read2, kept: kept2, goneAtLeast }) => before2 === null || before2 > kept2 || read2 > kept2 || goneAtLeast > 0);
|
|
6286
6488
|
const seconds = /* @__PURE__ */ __name((from, to) => Math.round((to - from) / 100) / 10, "seconds");
|
|
6287
6489
|
return {
|
|
6288
6490
|
path,
|
|
6289
6491
|
keptAt,
|
|
6290
6492
|
sqlite3: program.version,
|
|
6291
6493
|
lost,
|
|
6494
|
+
placed,
|
|
6495
|
+
lastKnownGood,
|
|
6292
6496
|
dangling,
|
|
6293
6497
|
invalidJson: json,
|
|
6294
|
-
mailToFetch:
|
|
6498
|
+
mailToFetch: fetch,
|
|
6499
|
+
refetch,
|
|
6295
6500
|
rebuilt,
|
|
6296
6501
|
copyErrors,
|
|
6297
6502
|
health,
|
|
@@ -6307,7 +6512,7 @@ var recoverLocked = /* @__PURE__ */ __name(async ({ path, command, version, sqli
|
|
|
6307
6512
|
}
|
|
6308
6513
|
}, "recoverLocked");
|
|
6309
6514
|
|
|
6310
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6515
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/cli/store-recover.js
|
|
6311
6516
|
var COUNTED = [
|
|
6312
6517
|
"accounts",
|
|
6313
6518
|
"chats",
|
|
@@ -6340,18 +6545,23 @@ var storeRecoveryCheck = /* @__PURE__ */ __name(async (env, command, version) =>
|
|
|
6340
6545
|
}
|
|
6341
6546
|
} catch {
|
|
6342
6547
|
}
|
|
6548
|
+
const journal = readJournalMark(path);
|
|
6343
6549
|
recordDeepCheck(path, health, { cli: command, ...version ? { version } : {}, schema });
|
|
6344
6550
|
const mark = readDamageMark(path);
|
|
6345
|
-
const
|
|
6551
|
+
const lastKnownGood = readHealthMark(path)?.last_ok_at ?? null;
|
|
6346
6552
|
const inUse = storeHolders(path) ?? null;
|
|
6347
6553
|
const timers = activeTimers() ?? null;
|
|
6348
6554
|
const sqlite3 = sqlite3Program();
|
|
6349
|
-
const
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6555
|
+
const report = storeDamageReport({
|
|
6556
|
+
health,
|
|
6557
|
+
command,
|
|
6558
|
+
mark,
|
|
6559
|
+
journal,
|
|
6560
|
+
lastOkAt: lastKnownGood,
|
|
6561
|
+
holders: inUse,
|
|
6562
|
+
timers,
|
|
6563
|
+
sqlite3Usable: sqlite3.usable
|
|
6564
|
+
});
|
|
6355
6565
|
return {
|
|
6356
6566
|
path,
|
|
6357
6567
|
exists: true,
|
|
@@ -6362,13 +6572,13 @@ var storeRecoveryCheck = /* @__PURE__ */ __name(async (env, command, version) =>
|
|
|
6362
6572
|
damagedSearchIndexes: (health.searchIndexes ?? []).filter((index) => !index.ok).map(({ name, error }) => ({ name, ...error ? { error } : {} })),
|
|
6363
6573
|
invalidJson: health.invalidJson ?? [],
|
|
6364
6574
|
rows,
|
|
6365
|
-
|
|
6575
|
+
report,
|
|
6366
6576
|
damageMark: mark ? (({ inode: _, ...seen }) => seen)(mark) : null,
|
|
6367
|
-
lastKnownGood
|
|
6577
|
+
lastKnownGood,
|
|
6368
6578
|
inUse,
|
|
6369
6579
|
timers,
|
|
6370
6580
|
sqlite3: { version: sqlite3.version, usable: sqlite3.usable },
|
|
6371
|
-
next
|
|
6581
|
+
next: report?.steps.map((step) => step.command) ?? []
|
|
6372
6582
|
};
|
|
6373
6583
|
}, "storeRecoveryCheck");
|
|
6374
6584
|
var storeRecoveryRun = /* @__PURE__ */ __name(async (env, { command, version, note, timers: scheduled = activeTimers, copy }) => {
|
|
@@ -6394,12 +6604,27 @@ var storeRecoveryRun = /* @__PURE__ */ __name(async (env, { command, version, no
|
|
|
6394
6604
|
next: [...mail, ...lostMail, "systemctl --user start <the timers stopped before>"]
|
|
6395
6605
|
};
|
|
6396
6606
|
}, "storeRecoveryRun");
|
|
6607
|
+
var refetchNotes = /* @__PURE__ */ __name(({ since, chats, mail }) => {
|
|
6608
|
+
const from = since === null ? "from the start" : `from ${since} on`;
|
|
6609
|
+
const marked = [
|
|
6610
|
+
...chats.map(({ provider, account, chats: chats2 }) => `${chats2} chats of ${provider} ${account}`),
|
|
6611
|
+
...mail.map(({ account, folders }) => `${folders} mail folders of ${account}`)
|
|
6612
|
+
];
|
|
6613
|
+
return [
|
|
6614
|
+
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`,
|
|
6615
|
+
...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`),
|
|
6616
|
+
"notes, memories, tags and whatever else only this store held cannot be fetched again"
|
|
6617
|
+
];
|
|
6618
|
+
}, "refetchNotes");
|
|
6397
6619
|
var recoveryNotes = /* @__PURE__ */ __name((answer) => {
|
|
6398
6620
|
if ("keptAt" in answer) {
|
|
6399
|
-
const lost = answer.lost.map(({ table, before, read, kept }) => `${table}: ${kept} kept of ${before ?? "an uncountable number"}${read > kept ? `, ${read - kept} read but unusable` : ""}`);
|
|
6621
|
+
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)` : ""));
|
|
6400
6622
|
return [
|
|
6401
6623
|
`recovered in ${answer.seconds.total} s; the damaged file is kept at ${answer.keptAt}`,
|
|
6402
|
-
...lost
|
|
6624
|
+
...lost,
|
|
6625
|
+
...Object.entries(answer.placed).map(([table, rows]) => `${table}: ${rows} rows found on pages no table claimed were put back`),
|
|
6626
|
+
...refetchNotes(answer.refetch),
|
|
6627
|
+
lossUnknown(answer.lastKnownGood, lost.some((line) => line.includes("are gone"))),
|
|
6403
6628
|
...answer.dangling.map(({ table, parent, rows }) => `${rows} rows of ${table} point at ${parent} rows the store does not hold`),
|
|
6404
6629
|
...answer.invalidJson.map(({ table, column, rows, required }) => `${table}.${column}: ${rows} values were not valid JSON \u2014 ${required ? "those rows were dropped" : "set to empty"}`),
|
|
6405
6630
|
...answer.next.map((line) => `next: ${line}`)
|
|
@@ -6407,13 +6632,16 @@ var recoveryNotes = /* @__PURE__ */ __name((answer) => {
|
|
|
6407
6632
|
}
|
|
6408
6633
|
if (!answer.exists)
|
|
6409
6634
|
return ["no store yet"];
|
|
6410
|
-
|
|
6635
|
+
const report = answer.report;
|
|
6636
|
+
if (!report)
|
|
6411
6637
|
return [`the store is healthy (checked every page and search index in ${answer.seconds} s)`];
|
|
6412
|
-
const why = answer.explanation;
|
|
6413
6638
|
return [
|
|
6414
|
-
|
|
6415
|
-
|
|
6416
|
-
|
|
6639
|
+
report.whatHappened,
|
|
6640
|
+
...report.impact,
|
|
6641
|
+
report.externalDataSafe,
|
|
6642
|
+
report.loss,
|
|
6643
|
+
...report.likelyCauses.map(({ cause, check: check2 }) => `maybe: ${cause} \u2014 check: ${check2}`),
|
|
6644
|
+
...report.steps.map(({ command, why, destructive }) => `next: ${command} # ${destructive ? "changes things: " : ""}${why}`)
|
|
6417
6645
|
];
|
|
6418
6646
|
}, "recoveryNotes");
|
|
6419
6647
|
var storeRecoverCommand = /* @__PURE__ */ __name(({ command, version }) => {
|
|
@@ -6440,7 +6668,7 @@ var storeRecoverCommand = /* @__PURE__ */ __name(({ command, version }) => {
|
|
|
6440
6668
|
return recover;
|
|
6441
6669
|
}, "storeRecoverCommand");
|
|
6442
6670
|
|
|
6443
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6671
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/cli/store-info.js
|
|
6444
6672
|
var pendingIfKnown = /* @__PURE__ */ __name((database) => database.prepare("SELECT 1 FROM pragma_table_info('messages') WHERE name = 'normalized_text'").get() ? pendingNormalization(database) : null, "pendingIfKnown");
|
|
6445
6673
|
var bytesOf = /* @__PURE__ */ __name((path) => existsSync4(path) ? statSync3(path).size : 0, "bytesOf");
|
|
6446
6674
|
var messageOf = /* @__PURE__ */ __name((error) => error instanceof Error ? error.message : String(error), "messageOf");
|
|
@@ -6486,7 +6714,7 @@ var storeInfoCommand = /* @__PURE__ */ __name(() => annotate(new Command("info")
|
|
|
6486
6714
|
renderAnswer(this, outputFor(this), itemOf(answer));
|
|
6487
6715
|
}), "storeInfoCommand");
|
|
6488
6716
|
|
|
6489
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6717
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/cli/messenger/password.js
|
|
6490
6718
|
var ENCRYPT_OPTION = [
|
|
6491
6719
|
"--encrypt",
|
|
6492
6720
|
"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"
|
|
@@ -6505,7 +6733,7 @@ var passwordOf = /* @__PURE__ */ __name(async (command, { twice }) => {
|
|
|
6505
6733
|
return password;
|
|
6506
6734
|
}, "passwordOf");
|
|
6507
6735
|
|
|
6508
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6736
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/replies/rules.js
|
|
6509
6737
|
import { existsSync as existsSync5, readFileSync as readFileSync2 } from "node:fs";
|
|
6510
6738
|
import { join as join2 } from "node:path";
|
|
6511
6739
|
var REPLY_ACTIONS = ["reply", "task"];
|
|
@@ -6676,7 +6904,7 @@ var problem = /* @__PURE__ */ __name((issue) => {
|
|
|
6676
6904
|
}, "problem");
|
|
6677
6905
|
var broken = /* @__PURE__ */ __name((path, why) => new CliError("configuration_error", `the reply rules ${path} cannot be read (${why}) \u2014 fix the file`), "broken");
|
|
6678
6906
|
|
|
6679
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6907
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/replies/state.js
|
|
6680
6908
|
import { existsSync as existsSync6, readFileSync as readFileSync3 } from "node:fs";
|
|
6681
6909
|
import { join as join3 } from "node:path";
|
|
6682
6910
|
var ANSWERED_KEPT = 1e3;
|
|
@@ -6729,7 +6957,7 @@ var recordReply = /* @__PURE__ */ __name((state, rule2, message, now) => {
|
|
|
6729
6957
|
}, "recordReply");
|
|
6730
6958
|
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");
|
|
6731
6959
|
|
|
6732
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6960
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/replies/decide.js
|
|
6733
6961
|
var skip = /* @__PURE__ */ __name((why) => ({ skip: why }), "skip");
|
|
6734
6962
|
var decide = /* @__PURE__ */ __name((rule2, incoming, state, now) => {
|
|
6735
6963
|
const { message, chat, owner, sender } = incoming;
|
|
@@ -6835,8 +7063,37 @@ var filled = /* @__PURE__ */ __name((template2, senderName) => {
|
|
|
6835
7063
|
return template2.replaceAll("{firstName}", name.split(/\s+/)[0] ?? name).replaceAll("{name}", name);
|
|
6836
7064
|
}, "filled");
|
|
6837
7065
|
|
|
6838
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7066
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/replies/template.js
|
|
7067
|
+
var import_liquidjs2 = __toESM(require_liquid_node(), 1);
|
|
7068
|
+
|
|
7069
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/render/liquid.js
|
|
6839
7070
|
var import_liquidjs = __toESM(require_liquid_node(), 1);
|
|
7071
|
+
var safeLiquid = /* @__PURE__ */ __name((limits) => {
|
|
7072
|
+
const engine = new import_liquidjs.Liquid({
|
|
7073
|
+
ownPropertyOnly: true,
|
|
7074
|
+
strictVariables: true,
|
|
7075
|
+
strictFilters: true,
|
|
7076
|
+
lenientIf: false,
|
|
7077
|
+
parseLimit: limits.parse,
|
|
7078
|
+
renderLimit: limits.milliseconds,
|
|
7079
|
+
memoryLimit: limits.memory,
|
|
7080
|
+
preserveTimezones: true
|
|
7081
|
+
});
|
|
7082
|
+
for (const name of ["include", "render", "layout"]) {
|
|
7083
|
+
engine.registerTag(name, class extends import_liquidjs.Tag {
|
|
7084
|
+
constructor(token, tokens, liquid) {
|
|
7085
|
+
super(token, tokens, liquid);
|
|
7086
|
+
throw new Error("templates cannot read files");
|
|
7087
|
+
}
|
|
7088
|
+
render() {
|
|
7089
|
+
return "";
|
|
7090
|
+
}
|
|
7091
|
+
});
|
|
7092
|
+
}
|
|
7093
|
+
return engine;
|
|
7094
|
+
}, "safeLiquid");
|
|
7095
|
+
|
|
7096
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/replies/template.js
|
|
6840
7097
|
var TEMPLATE_LIMITS = {
|
|
6841
7098
|
parse: 32768,
|
|
6842
7099
|
renders: 2e3,
|
|
@@ -6890,28 +7147,8 @@ var renderReplyTemplate = /* @__PURE__ */ __name(async (reply, input) => {
|
|
|
6890
7147
|
hourCycle: "h23"
|
|
6891
7148
|
}).formatToParts(input.now).map(({ type, value }) => [type, value]));
|
|
6892
7149
|
const localTime = `${parts2.year}-${parts2.month}-${parts2.day}T${parts2.hour}:${parts2.minute}:${parts2.second}${parts2.timeZoneName?.replace("GMT", "") || "+00:00"}`;
|
|
6893
|
-
const engine =
|
|
6894
|
-
|
|
6895
|
-
strictVariables: true,
|
|
6896
|
-
strictFilters: true,
|
|
6897
|
-
lenientIf: false,
|
|
6898
|
-
parseLimit: limits.parse,
|
|
6899
|
-
renderLimit: limits.milliseconds,
|
|
6900
|
-
memoryLimit: limits.memory,
|
|
6901
|
-
preserveTimezones: true
|
|
6902
|
-
});
|
|
6903
|
-
for (const name2 of ["include", "render", "layout"]) {
|
|
6904
|
-
engine.registerTag(name2, class extends import_liquidjs.Tag {
|
|
6905
|
-
constructor(token, tokens, liquid) {
|
|
6906
|
-
super(token, tokens, liquid);
|
|
6907
|
-
throw new Error("reply templates cannot read files");
|
|
6908
|
-
}
|
|
6909
|
-
render() {
|
|
6910
|
-
return "";
|
|
6911
|
-
}
|
|
6912
|
-
});
|
|
6913
|
-
}
|
|
6914
|
-
engine.registerTag("ai", class extends import_liquidjs.Tag {
|
|
7150
|
+
const engine = safeLiquid({ parse: limits.parse, memory: limits.memory, milliseconds: limits.milliseconds });
|
|
7151
|
+
engine.registerTag("ai", class extends import_liquidjs2.Tag {
|
|
6915
7152
|
body = [];
|
|
6916
7153
|
fallback = null;
|
|
6917
7154
|
constructor(token, tokens, liquid, parser) {
|
|
@@ -6972,7 +7209,7 @@ var renderReplyTemplate = /* @__PURE__ */ __name(async (reply, input) => {
|
|
|
6972
7209
|
});
|
|
6973
7210
|
const templates = engine.parse(source);
|
|
6974
7211
|
const name = input.senderName?.trim() ?? "";
|
|
6975
|
-
const context = new
|
|
7212
|
+
const context = new import_liquidjs2.Context({
|
|
6976
7213
|
sender: { firstName: name.split(/\s+/)[0] ?? "", name },
|
|
6977
7214
|
chat: { title: input.chat.title ?? "", kind: input.chat.kind },
|
|
6978
7215
|
now: localTime
|
|
@@ -6995,7 +7232,7 @@ var renderReplyTemplate = /* @__PURE__ */ __name(async (reply, input) => {
|
|
|
6995
7232
|
}
|
|
6996
7233
|
}, "renderReplyTemplate");
|
|
6997
7234
|
|
|
6998
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7235
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/replies/dry-run.js
|
|
6999
7236
|
var DRY_RUN_DAYS = 7;
|
|
7000
7237
|
var PAGE = 500;
|
|
7001
7238
|
var dryRun = /* @__PURE__ */ __name(async (store, account, rules, { since, until = Date.now(), only, audience, render }) => {
|
|
@@ -7109,143 +7346,7 @@ var storedSince = /* @__PURE__ */ __name(async (store, account, chat, since) =>
|
|
|
7109
7346
|
}
|
|
7110
7347
|
}, "storedSince");
|
|
7111
7348
|
|
|
7112
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7113
|
-
var endpointKeyName = /* @__PURE__ */ __name((baseUrl) => {
|
|
7114
|
-
const host = new URL(baseUrl).host;
|
|
7115
|
-
return ["openai", "anthropic"].includes(host) ? `endpoint:${host}` : host;
|
|
7116
|
-
}, "endpointKeyName");
|
|
7117
|
-
var embeddingKeys = /* @__PURE__ */ __name((app, env = process.env, keyring) => {
|
|
7118
|
-
const where = { appName: app.appName, prefix: app.envPrefix, env };
|
|
7119
|
-
const credentials = /* @__PURE__ */ __name((provider) => new Credentials({
|
|
7120
|
-
configDir: resolvePaths(where).config,
|
|
7121
|
-
service: app.appName,
|
|
7122
|
-
...["openai", "anthropic"].includes(provider) ? { envVar: envName(app, `${provider.toUpperCase()}_API_KEY`) } : {},
|
|
7123
|
-
isolated: pathsAreOverridden(where),
|
|
7124
|
-
env,
|
|
7125
|
-
...keyring ? { keyring } : {},
|
|
7126
|
-
warn: /* @__PURE__ */ __name((message) => process.stderr.write(`${message}
|
|
7127
|
-
`), "warn")
|
|
7128
|
-
}), "credentials");
|
|
7129
|
-
const account = /* @__PURE__ */ __name((provider) => `embeddings:${provider}`, "account");
|
|
7130
|
-
return {
|
|
7131
|
-
read: /* @__PURE__ */ __name((provider) => {
|
|
7132
|
-
const stored = credentials(provider).read(account(provider));
|
|
7133
|
-
if (stored)
|
|
7134
|
-
return { key: stored.secret, source: stored.source };
|
|
7135
|
-
const shared = ["openai", "anthropic"].includes(provider) ? env[`${provider.toUpperCase()}_API_KEY`]?.trim() : void 0;
|
|
7136
|
-
return shared ? { key: shared, source: "env" } : void 0;
|
|
7137
|
-
}, "read"),
|
|
7138
|
-
write: /* @__PURE__ */ __name((provider, key) => credentials(provider).write(account(provider), key, { signIn: true }), "write"),
|
|
7139
|
-
remove: /* @__PURE__ */ __name((provider) => credentials(provider).remove(account(provider)), "remove")
|
|
7140
|
-
};
|
|
7141
|
-
}, "embeddingKeys");
|
|
7142
|
-
|
|
7143
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._981e87e6afb3f510e9b2b59ded3c7286/node_modules/@wirecat/cli-core/dist/models/openai.js
|
|
7144
|
-
var options = strictObject({
|
|
7145
|
-
temperature: range(0, 2),
|
|
7146
|
-
top_p: range(0, 1),
|
|
7147
|
-
presence_penalty: range(-2, 2),
|
|
7148
|
-
frequency_penalty: range(-2, 2),
|
|
7149
|
-
seed: optional(pipe(number(), integer())),
|
|
7150
|
-
stop: optional(union([string(), array(string())])),
|
|
7151
|
-
response_format: optional(strictObject({ type: picklist(["text", "json_object"]) }))
|
|
7152
|
-
});
|
|
7153
|
-
var openai = {
|
|
7154
|
-
images: true,
|
|
7155
|
-
baseUrl: "https://api.openai.com/v1",
|
|
7156
|
-
validate: /* @__PURE__ */ __name((given) => checkedOptions("openai", options, given), "validate"),
|
|
7157
|
-
complete: /* @__PURE__ */ __name((target, request, checked, apiKey, fetcher) => withTimeLimit(12e4, async (deadline) => {
|
|
7158
|
-
const response = await fetcher(`${target.baseUrl.replace(/\/+$/, "")}/chat/completions`, {
|
|
7159
|
-
method: "POST",
|
|
7160
|
-
headers: { "Content-Type": "application/json", ...apiKey ? { Authorization: `Bearer ${apiKey}` } : {} },
|
|
7161
|
-
body: JSON.stringify({
|
|
7162
|
-
...checked,
|
|
7163
|
-
model: target.model,
|
|
7164
|
-
messages: [
|
|
7165
|
-
{ role: "system", content: systemFor(request) },
|
|
7166
|
-
...messagesFor(request),
|
|
7167
|
-
...request.images === void 0 ? [] : [
|
|
7168
|
-
{
|
|
7169
|
-
role: "user",
|
|
7170
|
-
content: request.images.map((image) => ({
|
|
7171
|
-
type: "image_url",
|
|
7172
|
-
image_url: { url: `data:${image.mimeType};base64,${image.data}`, detail: "high" }
|
|
7173
|
-
}))
|
|
7174
|
-
}
|
|
7175
|
-
]
|
|
7176
|
-
],
|
|
7177
|
-
...new URL(target.baseUrl).hostname === "api.openai.com" ? { max_completion_tokens: request.maxTokens } : { max_tokens: request.maxTokens }
|
|
7178
|
-
}),
|
|
7179
|
-
signal: deadline,
|
|
7180
|
-
redirect: "error"
|
|
7181
|
-
});
|
|
7182
|
-
if (!response.ok)
|
|
7183
|
-
throw new Error("provider rejected request");
|
|
7184
|
-
const body = await response.json();
|
|
7185
|
-
const choice = body.choices?.[0];
|
|
7186
|
-
if (choice?.finish_reason !== "stop" || typeof choice.message?.content !== "string" || !Number.isInteger(body.usage?.total_tokens) || (body.usage?.total_tokens ?? 0) < 1)
|
|
7187
|
-
throw new Error("incomplete response");
|
|
7188
|
-
return { text: choice.message.content, tokens: body.usage?.total_tokens };
|
|
7189
|
-
}), "complete")
|
|
7190
|
-
};
|
|
7191
|
-
|
|
7192
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._981e87e6afb3f510e9b2b59ded3c7286/node_modules/@wirecat/cli-core/dist/models/index.js
|
|
7193
|
-
var modelGateway = /* @__PURE__ */ __name((deps) => ({
|
|
7194
|
-
complete: /* @__PURE__ */ __name(async (request) => {
|
|
7195
|
-
if (deps.signal?.aborted)
|
|
7196
|
-
throw new CliError("cancelled", "model request cancelled");
|
|
7197
|
-
const target = deps.resolve(request.purpose);
|
|
7198
|
-
if (!target || target.provider === "off")
|
|
7199
|
-
throw new CliError("configuration_error", `models.${request.purpose}.provider is not configured; no model was called`);
|
|
7200
|
-
if (!request.purpose || !Number.isSafeInteger(request.maxTokens) || request.maxTokens < 1 || typeof request.prompt !== "string")
|
|
7201
|
-
throw new CliError("validation_error", "a model request needs a purpose, prompt and positive whole maxTokens");
|
|
7202
|
-
validateImages(request.images);
|
|
7203
|
-
let adapter = deps.adapters?.[target.provider];
|
|
7204
|
-
if (!adapter && target.provider === "openai")
|
|
7205
|
-
adapter = openai;
|
|
7206
|
-
if (!adapter && target.provider === "anthropic")
|
|
7207
|
-
adapter = (await import("./anthropic-NTASPJYE.js")).anthropic;
|
|
7208
|
-
if (!adapter)
|
|
7209
|
-
throw new CliError("validation_error", `no model adapter for ${target.provider}`);
|
|
7210
|
-
if (request.images !== void 0 && adapter.images !== true)
|
|
7211
|
-
throw new CliError("validation_error", "the model adapter does not support image inputs");
|
|
7212
|
-
const options2 = adapter.validate(request.options ?? {});
|
|
7213
|
-
const baseUrl = target.baseUrl ?? adapter.baseUrl;
|
|
7214
|
-
if (!target.model.trim() || !endpoint(baseUrl))
|
|
7215
|
-
throw new CliError("validation_error", "a model target needs a model and an HTTP/S endpoint without credentials, query or fragment");
|
|
7216
|
-
if (!await deps.consent(request, { ...target, baseUrl }))
|
|
7217
|
-
throw new CliError("permission_error", `model consent for ${request.purpose} is missing; no data was sent`);
|
|
7218
|
-
const apiKey = await deps.key?.(target.provider, target);
|
|
7219
|
-
if (deps.signal?.aborted)
|
|
7220
|
-
throw new CliError("cancelled", "model request cancelled");
|
|
7221
|
-
const fetcher = deps.fetch ?? fetch;
|
|
7222
|
-
let limited = false;
|
|
7223
|
-
const cancellable = /* @__PURE__ */ __name(async (input, init) => {
|
|
7224
|
-
const signal = init?.signal ?? (input instanceof Request ? input.signal : void 0);
|
|
7225
|
-
const response = await fetcher(input, {
|
|
7226
|
-
...init,
|
|
7227
|
-
signal: deps.signal ? AbortSignal.any([deps.signal, ...signal ? [signal] : []]) : signal
|
|
7228
|
-
});
|
|
7229
|
-
if (response.status === 429)
|
|
7230
|
-
limited = true;
|
|
7231
|
-
return response;
|
|
7232
|
-
}, "cancellable");
|
|
7233
|
-
try {
|
|
7234
|
-
const answer = await adapter.complete({ ...target, baseUrl }, request, options2, apiKey, cancellable);
|
|
7235
|
-
if (deps.signal?.aborted)
|
|
7236
|
-
throw new Error("cancelled");
|
|
7237
|
-
if (typeof answer.text !== "string" || !Number.isSafeInteger(answer.tokens) || answer.tokens < 1)
|
|
7238
|
-
throw new Error("incomplete");
|
|
7239
|
-
return { ...answer, provider: target.provider, model: target.model };
|
|
7240
|
-
} catch {
|
|
7241
|
-
if (limited)
|
|
7242
|
-
throw new CliError("rate_limited", `${request.purpose} provider rate limit reached; no result was stored`);
|
|
7243
|
-
throw new CliError("invalid_response", `${request.purpose} provider failed or returned an incomplete response; no result was stored`);
|
|
7244
|
-
}
|
|
7245
|
-
}, "complete")
|
|
7246
|
-
}), "modelGateway");
|
|
7247
|
-
|
|
7248
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.80.8_commander@15._981e87e6afb3f510e9b2b59ded3c7286/node_modules/@wirecat/cli-core/dist/replies/consents.js
|
|
7349
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/replies/consents.js
|
|
7249
7350
|
import { existsSync as existsSync7, readFileSync as readFileSync4 } from "node:fs";
|
|
7250
7351
|
import { join as join4 } from "node:path";
|
|
7251
7352
|
var shape = strictObject({
|
|
@@ -7270,21 +7371,21 @@ var mayModelReply = /* @__PURE__ */ __name((path, provider, chat) => {
|
|
|
7270
7371
|
return consent.provider === provider && !consent.deniedChats.includes(chat);
|
|
7271
7372
|
}, "mayModelReply");
|
|
7272
7373
|
|
|
7273
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7274
|
-
var replyRenderer = /* @__PURE__ */ __name((app, profile, settings, env, warn,
|
|
7374
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/replies/rendering.js
|
|
7375
|
+
var replyRenderer = /* @__PURE__ */ __name((app, profile, settings, env, warn, options = {
|
|
7275
7376
|
ai: true
|
|
7276
7377
|
}) => async (rule2, message, chat, now) => {
|
|
7277
7378
|
let called;
|
|
7278
7379
|
const gateway = modelGateway({
|
|
7279
|
-
signal:
|
|
7380
|
+
signal: options.signal,
|
|
7280
7381
|
resolve: /* @__PURE__ */ __name((purpose) => {
|
|
7281
7382
|
called = modelTarget(settings(), purpose);
|
|
7282
7383
|
return called;
|
|
7283
7384
|
}, "resolve"),
|
|
7284
7385
|
consent: /* @__PURE__ */ __name((_request, target) => mayModelReply(replyConsentPathFor(app, profile, env), replyModelIdentity(target.provider, target.baseUrl ?? ""), message.chatId), "consent"),
|
|
7285
|
-
key: /* @__PURE__ */ __name((provider, target) => embeddingKeys(app, env,
|
|
7386
|
+
key: /* @__PURE__ */ __name((provider, target) => embeddingKeys(app, env, options.keyring).read(target.baseUrl === void 0 ? provider : endpointKeyName(target.baseUrl))?.key, "key")
|
|
7286
7387
|
});
|
|
7287
|
-
if (
|
|
7388
|
+
if (options.signal?.aborted)
|
|
7288
7389
|
throw new CliError("cancelled", "reply rendering cancelled");
|
|
7289
7390
|
const result2 = await renderReplyTemplate(rule2.reply, {
|
|
7290
7391
|
senderName: message.senderName,
|
|
@@ -7292,8 +7393,8 @@ var replyRenderer = /* @__PURE__ */ __name((app, profile, settings, env, warn, o
|
|
|
7292
7393
|
now,
|
|
7293
7394
|
timezone: rule2.when.hours?.timezone,
|
|
7294
7395
|
data: message.text,
|
|
7295
|
-
allowAI:
|
|
7296
|
-
preview:
|
|
7396
|
+
allowAI: options.ai === true,
|
|
7397
|
+
preview: options.preview === true,
|
|
7297
7398
|
complete: /* @__PURE__ */ __name(async (prompt, data) => {
|
|
7298
7399
|
const result3 = await gateway.complete({
|
|
7299
7400
|
purpose: "replies",
|
|
@@ -7302,7 +7403,7 @@ var replyRenderer = /* @__PURE__ */ __name((app, profile, settings, env, warn, o
|
|
|
7302
7403
|
data,
|
|
7303
7404
|
maxTokens: 512
|
|
7304
7405
|
});
|
|
7305
|
-
if (
|
|
7406
|
+
if (options.signal?.aborted)
|
|
7306
7407
|
throw new CliError("cancelled", "reply rendering cancelled");
|
|
7307
7408
|
const current = modelTarget(settings(), "replies");
|
|
7308
7409
|
const baseUrl = called?.baseUrl ?? (called?.provider === "anthropic" ? "https://api.anthropic.com" : "https://api.openai.com/v1");
|
|
@@ -7317,7 +7418,7 @@ var replyRenderer = /* @__PURE__ */ __name((app, profile, settings, env, warn, o
|
|
|
7317
7418
|
return result2;
|
|
7318
7419
|
}, "replyRenderer");
|
|
7319
7420
|
|
|
7320
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7421
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/replies/serve.js
|
|
7321
7422
|
var NOT_ALLOWED = "replies.send is not allow";
|
|
7322
7423
|
var NO_RULES = "no rules";
|
|
7323
7424
|
var ONLY_TASK = "opened a task, sent nothing";
|
|
@@ -7410,12 +7511,12 @@ var replyTo = /* @__PURE__ */ __name(async (deps, message) => {
|
|
|
7410
7511
|
return { skip: why };
|
|
7411
7512
|
}, "replyTo");
|
|
7412
7513
|
|
|
7413
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7514
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-catch-up.js
|
|
7414
7515
|
var START_SYNC_DELAY_MS = 3e4;
|
|
7415
7516
|
var START_SYNC_BUDGET_MS = 5 * 6e4;
|
|
7416
7517
|
var START_SYNC_WINDOW_MS = 7 * 864e5;
|
|
7417
7518
|
var START_SYNC_PER_CHAT = 500;
|
|
7418
|
-
var startSync = /* @__PURE__ */ __name(({ chats, newestHeld, fetch
|
|
7519
|
+
var startSync = /* @__PURE__ */ __name(({ chats, newestHeld, fetch, note, warn, delayMs = START_SYNC_DELAY_MS, budgetMs = START_SYNC_BUDGET_MS, windowMs = START_SYNC_WINDOW_MS, now = Date.now }) => {
|
|
7419
7520
|
const controller = new AbortController();
|
|
7420
7521
|
let timer;
|
|
7421
7522
|
let pass = Promise.resolve();
|
|
@@ -7443,7 +7544,7 @@ var startSync = /* @__PURE__ */ __name(({ chats, newestHeld, fetch: fetch2, note
|
|
|
7443
7544
|
if (stop.aborted)
|
|
7444
7545
|
break;
|
|
7445
7546
|
try {
|
|
7446
|
-
summary.fetched += (await
|
|
7547
|
+
summary.fetched += (await fetch(chat.id, Math.max(held ?? anywhere, floor), stop)).fetched;
|
|
7447
7548
|
summary.chats += 1;
|
|
7448
7549
|
} catch (error) {
|
|
7449
7550
|
if (stop.aborted)
|
|
@@ -7487,10 +7588,10 @@ var startSync = /* @__PURE__ */ __name(({ chats, newestHeld, fetch: fetch2, note
|
|
|
7487
7588
|
};
|
|
7488
7589
|
}, "startSync");
|
|
7489
7590
|
|
|
7490
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7591
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-members.js
|
|
7491
7592
|
var FIRST_FETCH_MS = 6e4;
|
|
7492
7593
|
var DAY_MS = 864e5;
|
|
7493
|
-
var memberFetches = /* @__PURE__ */ __name(({ withStore, fetch
|
|
7594
|
+
var memberFetches = /* @__PURE__ */ __name(({ withStore, fetch, warn, firstMs = FIRST_FETCH_MS, everyMs = DAY_MS }) => {
|
|
7494
7595
|
let timer;
|
|
7495
7596
|
let round = Promise.resolve();
|
|
7496
7597
|
let stopped = false;
|
|
@@ -7503,7 +7604,7 @@ var memberFetches = /* @__PURE__ */ __name(({ withStore, fetch: fetch2, warn, fi
|
|
|
7503
7604
|
if (lastCount?.day === today)
|
|
7504
7605
|
continue;
|
|
7505
7606
|
try {
|
|
7506
|
-
await
|
|
7607
|
+
await fetch(store, account, chatId);
|
|
7507
7608
|
done.fetched += 1;
|
|
7508
7609
|
} catch (error) {
|
|
7509
7610
|
done.failed += 1;
|
|
@@ -7541,7 +7642,7 @@ var memberFetches = /* @__PURE__ */ __name(({ withStore, fetch: fetch2, warn, fi
|
|
|
7541
7642
|
};
|
|
7542
7643
|
}, "memberFetches");
|
|
7543
7644
|
|
|
7544
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7645
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-notice.js
|
|
7545
7646
|
var record2 = /* @__PURE__ */ __name((context, app, severity, attributes) => recordLogFor(context.streams.diagnostic, app, { command: currentRun().command || "serve" })[severity](attributes), "record");
|
|
7546
7647
|
var noticeFor = /* @__PURE__ */ __name((context, app, severity = "warn") => ({ text, ...attributes }) => {
|
|
7547
7648
|
if (context.format === "pretty") {
|
|
@@ -7574,7 +7675,93 @@ var recordDiagnostics = /* @__PURE__ */ __name((context, app) => {
|
|
|
7574
7675
|
return context;
|
|
7575
7676
|
}, "recordDiagnostics");
|
|
7576
7677
|
|
|
7577
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7678
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-outdated.js
|
|
7679
|
+
import { existsSync as existsSync8, readFileSync as readFileSync5, realpathSync as realpathSync2 } from "node:fs";
|
|
7680
|
+
import { dirname as dirname2, join as join5 } from "node:path";
|
|
7681
|
+
var OUTDATED_CHECK_MS = 6e4;
|
|
7682
|
+
var ownPackageRoot = /* @__PURE__ */ __name((running, script = process.argv[1]) => {
|
|
7683
|
+
let dir;
|
|
7684
|
+
try {
|
|
7685
|
+
dir = dirname2(realpathSync2(script ?? ""));
|
|
7686
|
+
} catch {
|
|
7687
|
+
return void 0;
|
|
7688
|
+
}
|
|
7689
|
+
for (let up = 0; up < 8; up++) {
|
|
7690
|
+
const manifest = join5(dir, "package.json");
|
|
7691
|
+
if (existsSync8(manifest))
|
|
7692
|
+
return installedVersion(dir) === running ? dir : void 0;
|
|
7693
|
+
const parent = dirname2(dir);
|
|
7694
|
+
if (parent === dir)
|
|
7695
|
+
return void 0;
|
|
7696
|
+
dir = parent;
|
|
7697
|
+
}
|
|
7698
|
+
return void 0;
|
|
7699
|
+
}, "ownPackageRoot");
|
|
7700
|
+
var installedVersion = /* @__PURE__ */ __name((root) => {
|
|
7701
|
+
try {
|
|
7702
|
+
const { version } = JSON.parse(readFileSync5(join5(root, "package.json"), "utf8"));
|
|
7703
|
+
return typeof version === "string" ? version : void 0;
|
|
7704
|
+
} catch {
|
|
7705
|
+
return void 0;
|
|
7706
|
+
}
|
|
7707
|
+
}, "installedVersion");
|
|
7708
|
+
var newer = /* @__PURE__ */ __name((one, other) => {
|
|
7709
|
+
const parts2 = /* @__PURE__ */ __name((version) => version.split(/[.+-]/, 3).map(Number), "parts");
|
|
7710
|
+
const [a, b] = [parts2(one), parts2(other)];
|
|
7711
|
+
for (let i = 0; i < 3; i++)
|
|
7712
|
+
if ((a[i] ?? 0) !== (b[i] ?? 0))
|
|
7713
|
+
return (a[i] ?? 0) > (b[i] ?? 0);
|
|
7714
|
+
return false;
|
|
7715
|
+
}, "newer");
|
|
7716
|
+
var outdatedReason = /* @__PURE__ */ __name(async ({ command, running, storePath: storePath2, packageRoot, speaks = SPEAKS }) => {
|
|
7717
|
+
const installed = packageRoot === void 0 ? void 0 : installedVersion(packageRoot);
|
|
7718
|
+
if (installed !== void 0 && newer(installed, running))
|
|
7719
|
+
return `${command} ${installed} is installed and this serve runs ${running}: stopping so it starts again on ${installed}`;
|
|
7720
|
+
if (!existsSync8(storePath2))
|
|
7721
|
+
return void 0;
|
|
7722
|
+
let schema;
|
|
7723
|
+
try {
|
|
7724
|
+
const { database } = await openSqlite(storePath2, { readOnly: true });
|
|
7725
|
+
try {
|
|
7726
|
+
schema = fileSchemaOf(database);
|
|
7727
|
+
} finally {
|
|
7728
|
+
database.close();
|
|
7729
|
+
}
|
|
7730
|
+
} catch {
|
|
7731
|
+
return void 0;
|
|
7732
|
+
}
|
|
7733
|
+
if (writableBy(schema, speaks))
|
|
7734
|
+
return void 0;
|
|
7735
|
+
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`;
|
|
7736
|
+
}, "outdatedReason");
|
|
7737
|
+
var watchOutdated = /* @__PURE__ */ __name(({ check: check2, onOutdated, everyMs = OUTDATED_CHECK_MS }) => {
|
|
7738
|
+
let busy = false;
|
|
7739
|
+
let done = false;
|
|
7740
|
+
const timer = setInterval(() => {
|
|
7741
|
+
if (busy || done)
|
|
7742
|
+
return;
|
|
7743
|
+
busy = true;
|
|
7744
|
+
check2().then((reason) => {
|
|
7745
|
+
if (reason === void 0 || done)
|
|
7746
|
+
return;
|
|
7747
|
+
done = true;
|
|
7748
|
+
clearInterval(timer);
|
|
7749
|
+
onOutdated(reason);
|
|
7750
|
+
}).catch(() => {
|
|
7751
|
+
}).finally(() => {
|
|
7752
|
+
busy = false;
|
|
7753
|
+
});
|
|
7754
|
+
}, everyMs);
|
|
7755
|
+
timer.unref();
|
|
7756
|
+
return {
|
|
7757
|
+
stop: /* @__PURE__ */ __name(() => {
|
|
7758
|
+
done = true;
|
|
7759
|
+
clearInterval(timer);
|
|
7760
|
+
}, "stop")
|
|
7761
|
+
};
|
|
7762
|
+
}, "watchOutdated");
|
|
7763
|
+
|
|
7764
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-stems.js
|
|
7578
7765
|
var STEMS_EVERY_MS = 3e4;
|
|
7579
7766
|
var STEMS_SLICE_MS = 2e3;
|
|
7580
7767
|
var stemFills = /* @__PURE__ */ __name(({ withStore, warn, everyMs = STEMS_EVERY_MS, sliceMs = STEMS_SLICE_MS }) => {
|
|
@@ -7614,17 +7801,17 @@ var stemFills = /* @__PURE__ */ __name(({ withStore, warn, everyMs = STEMS_EVERY
|
|
|
7614
7801
|
};
|
|
7615
7802
|
}, "stemFills");
|
|
7616
7803
|
|
|
7617
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7804
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/render/messages.js
|
|
7618
7805
|
import { styleText } from "node:util";
|
|
7619
7806
|
var TIME_WIDTH = 8;
|
|
7620
7807
|
var INDENT = " ".repeat(TIME_WIDTH + 2);
|
|
7621
7808
|
var MIN_WIDTH = 40;
|
|
7622
7809
|
var SENDER_COLOURS = ["green", "yellow", "magenta", "blue", "red"];
|
|
7623
|
-
var renderMessages = /* @__PURE__ */ __name((messages,
|
|
7810
|
+
var renderMessages = /* @__PURE__ */ __name((messages, options = {}) => {
|
|
7624
7811
|
if (messages.length === 0)
|
|
7625
7812
|
return "(nothing)";
|
|
7626
|
-
const day = dayFormatter(
|
|
7627
|
-
const paint = painter(
|
|
7813
|
+
const day = dayFormatter(options);
|
|
7814
|
+
const paint = painter(options);
|
|
7628
7815
|
let previous;
|
|
7629
7816
|
const blocks = [];
|
|
7630
7817
|
for (const message of messages) {
|
|
@@ -7632,40 +7819,40 @@ var renderMessages = /* @__PURE__ */ __name((messages, options2 = {}) => {
|
|
|
7632
7819
|
if (date !== previous)
|
|
7633
7820
|
blocks.push(paint("dim", `\u2500\u2500 ${date} \u2500\u2500`));
|
|
7634
7821
|
previous = date;
|
|
7635
|
-
blocks.push(renderMessage(message,
|
|
7822
|
+
blocks.push(renderMessage(message, options));
|
|
7636
7823
|
}
|
|
7637
7824
|
return blocks.join("\n\n");
|
|
7638
7825
|
}, "renderMessages");
|
|
7639
|
-
var renderMessage = /* @__PURE__ */ __name((message,
|
|
7640
|
-
const paint = painter(
|
|
7641
|
-
const width = Math.max(MIN_WIDTH,
|
|
7826
|
+
var renderMessage = /* @__PURE__ */ __name((message, options = {}) => {
|
|
7827
|
+
const paint = painter(options);
|
|
7828
|
+
const width = Math.max(MIN_WIDTH, options.width ?? 80);
|
|
7642
7829
|
const room = width - INDENT.length;
|
|
7643
|
-
const time = timeFormatter(
|
|
7644
|
-
const verbosity =
|
|
7830
|
+
const time = timeFormatter(options);
|
|
7831
|
+
const verbosity = options.verbosity ?? 0;
|
|
7645
7832
|
const chat = "chatTitle" in message ? paint("dim", ` \xB7 ${singleLine(message.chatTitle ?? message.chatId)}`) : "";
|
|
7646
7833
|
const mark = "anchor" in message && message.anchor ? paint("bold", " \u25C0") : "";
|
|
7647
|
-
const lines = [`${paint("dim", time(message.timestamp))} ${senderOf(message,
|
|
7834
|
+
const lines = [`${paint("dim", time(message.timestamp))} ${senderOf(message, options)}${chat}${mark}`];
|
|
7648
7835
|
const body = /* @__PURE__ */ __name((text) => wrapAnsi(visibleControls(text), room, { hard: true }).split("\n"), "body");
|
|
7649
7836
|
const email = message.email;
|
|
7650
7837
|
if (email)
|
|
7651
7838
|
lines.push(paint("dim", mailLine(email)));
|
|
7652
7839
|
if (message.replyTo)
|
|
7653
|
-
lines.push(paint("dim", preview("\u21B3", message.replyTo, room,
|
|
7840
|
+
lines.push(paint("dim", preview("\u21B3", message.replyTo, room, options)));
|
|
7654
7841
|
if (message.forwardedFrom) {
|
|
7655
|
-
lines.push(paint("dim", `\u21AA ${nameOf(message.forwardedFrom,
|
|
7842
|
+
lines.push(paint("dim", `\u21AA ${nameOf(message.forwardedFrom, options)}`));
|
|
7656
7843
|
if (message.forwardedFrom.text)
|
|
7657
7844
|
for (const line of body(message.forwardedFrom.text))
|
|
7658
7845
|
lines.push(line);
|
|
7659
|
-
lines.push(...attachmentLines(message.forwardedFrom.attachments, paint,
|
|
7846
|
+
lines.push(...attachmentLines(message.forwardedFrom.attachments, paint, options));
|
|
7660
7847
|
}
|
|
7661
7848
|
if (message.text)
|
|
7662
7849
|
for (const line of body(message.text))
|
|
7663
7850
|
lines.push(line);
|
|
7664
|
-
lines.push(...attachmentLines(message.attachments, paint,
|
|
7851
|
+
lines.push(...attachmentLines(message.attachments, paint, options));
|
|
7665
7852
|
if (message.reactions && message.reactions.total > 0)
|
|
7666
7853
|
lines.push(paint("dim", reactionLine(message.reactions)));
|
|
7667
7854
|
if (message.editedAt)
|
|
7668
|
-
lines.push(paint("dim", `edited ${editedAt(message,
|
|
7855
|
+
lines.push(paint("dim", `edited ${editedAt(message, options)}`));
|
|
7669
7856
|
if (verbosity >= 1) {
|
|
7670
7857
|
const fields = [
|
|
7671
7858
|
["message", message.id],
|
|
@@ -7677,7 +7864,7 @@ var renderMessage = /* @__PURE__ */ __name((message, options2 = {}) => {
|
|
|
7677
7864
|
...message.attachments.map((a) => ["link", a.url])
|
|
7678
7865
|
];
|
|
7679
7866
|
if (verbosity >= 2) {
|
|
7680
|
-
fields.push(["provider",
|
|
7867
|
+
fields.push(["provider", options.provider], ["profile", options.profile], ["sent", message.timestamp], ["edited", message.editedAt], ["outgoing", message.outgoing === null ? "unknown" : String(message.outgoing)], ...message.attachments.map((a) => ["attachment", JSON.stringify(a)]), ["metadata", message.providerMetadata && JSON.stringify(message.providerMetadata)]);
|
|
7681
7868
|
}
|
|
7682
7869
|
const shown = fields.filter((field) => typeof field[1] === "string");
|
|
7683
7870
|
const label = Math.max(...shown.map(([key]) => key.length));
|
|
@@ -7690,36 +7877,36 @@ var mailLine = /* @__PURE__ */ __name(({ to, cc, labels }) => {
|
|
|
7690
7877
|
return [to.length ? `to ${names(to)}` : "", cc.length ? `cc ${names(cc)}` : "", labels.join(", ")].filter(Boolean).join(" \xB7 ");
|
|
7691
7878
|
}, "mailLine");
|
|
7692
7879
|
var painter = /* @__PURE__ */ __name(({ color = false }) => (style, text) => color ? styleText(style, text, { validateStream: false }) : text, "painter");
|
|
7693
|
-
var senderOf = /* @__PURE__ */ __name((message,
|
|
7694
|
-
const paint = painter(
|
|
7880
|
+
var senderOf = /* @__PURE__ */ __name((message, options) => {
|
|
7881
|
+
const paint = painter(options);
|
|
7695
7882
|
if (message.outgoing === true)
|
|
7696
|
-
return paint(["bold", "cyan"], you(
|
|
7697
|
-
const name = nameOf(message,
|
|
7698
|
-
if (!
|
|
7883
|
+
return paint(["bold", "cyan"], you(options));
|
|
7884
|
+
const name = nameOf(message, options);
|
|
7885
|
+
if (!options.senderColors)
|
|
7699
7886
|
return paint("bold", name);
|
|
7700
7887
|
const colour = SENDER_COLOURS[hash(message.senderId ?? name) % SENDER_COLOURS.length] ?? "green";
|
|
7701
7888
|
return paint(["bold", colour], name);
|
|
7702
7889
|
}, "senderOf");
|
|
7703
|
-
var nameOf = /* @__PURE__ */ __name(({ senderName, senderId, outgoing },
|
|
7890
|
+
var nameOf = /* @__PURE__ */ __name(({ senderName, senderId, outgoing }, options) => outgoing === true ? you(options) : singleLine(senderName ?? senderId ?? "unknown"), "nameOf");
|
|
7704
7891
|
var DEFAULT_LOCALE = "ru-RU";
|
|
7705
7892
|
var you = /* @__PURE__ */ __name(({ locale = DEFAULT_LOCALE }) => locale.startsWith("ru") ? "\u0432\u044B" : "you", "you");
|
|
7706
7893
|
var hash = /* @__PURE__ */ __name((value) => [...value].reduce((sum, char) => sum * 31 + char.charCodeAt(0) >>> 0, 7), "hash");
|
|
7707
|
-
var preview = /* @__PURE__ */ __name((mark, quoted, room,
|
|
7894
|
+
var preview = /* @__PURE__ */ __name((mark, quoted, room, options) => {
|
|
7708
7895
|
const text = singleLine(quoted.text.split("\n")[0] ?? "") || (quoted.attachments[0] ? `\u{1F4CE} ${quoted.attachments[0].kind}` : "");
|
|
7709
|
-
const line = text ? `${mark} ${nameOf(quoted,
|
|
7896
|
+
const line = text ? `${mark} ${nameOf(quoted, options)}: ${text}` : `${mark} message ${quoted.id}`;
|
|
7710
7897
|
if (stringWidth(line) <= room)
|
|
7711
7898
|
return line;
|
|
7712
7899
|
return `${wrapAnsi(line, room - 1, { hard: true }).split("\n")[0]}\u2026`;
|
|
7713
7900
|
}, "preview");
|
|
7714
|
-
var attachmentLines = /* @__PURE__ */ __name((attachments, paint,
|
|
7901
|
+
var attachmentLines = /* @__PURE__ */ __name((attachments, paint, options) => {
|
|
7715
7902
|
const link = /* @__PURE__ */ __name((label, raw) => {
|
|
7716
7903
|
if (raw === void 0)
|
|
7717
7904
|
return label;
|
|
7718
7905
|
const url = singleLine(raw);
|
|
7719
|
-
return
|
|
7906
|
+
return options.color ? `\x1B]8;;${url}\x07${label}\x1B]8;;\x07` : `${label} ${url}`;
|
|
7720
7907
|
}, "link");
|
|
7721
|
-
let
|
|
7722
|
-
const keyboard = attachments.flatMap((attachment) => attachment.buttons ?? []).map((row) => paint("dim", row.map((button) => link(`[${++
|
|
7908
|
+
let number = 0;
|
|
7909
|
+
const keyboard = attachments.flatMap((attachment) => attachment.buttons ?? []).map((row) => paint("dim", row.map((button) => link(`[${++number} ${singleLine(button.text)}]`, button.url)).join(" ")));
|
|
7723
7910
|
const polls = attachments.flatMap((attachment) => attachment.poll ? pollLines(attachment.poll) : []);
|
|
7724
7911
|
const cards = attachments.flatMap(({ contact }) => contact ? [
|
|
7725
7912
|
paint("dim", `\u{1F464} ${[contact.name, contact.phone].flatMap((part) => part ? [singleLine(part)] : []).join(" \xB7 ")}`)
|
|
@@ -7783,14 +7970,14 @@ var reactionLine = /* @__PURE__ */ __name(({ counts, mine }) => {
|
|
|
7783
7970
|
const shown = counts.map(({ reaction, count: count3 }) => `${singleLine(reaction)} ${count3}`).join(" ");
|
|
7784
7971
|
return mine ? `${shown} (you: ${singleLine(mine)})` : shown;
|
|
7785
7972
|
}, "reactionLine");
|
|
7786
|
-
var editedAt = /* @__PURE__ */ __name((message,
|
|
7973
|
+
var editedAt = /* @__PURE__ */ __name((message, options) => {
|
|
7787
7974
|
const edited = message.editedAt ?? message.timestamp;
|
|
7788
|
-
const time = timeFormatter(
|
|
7789
|
-
const day = dayFormatter(
|
|
7975
|
+
const time = timeFormatter(options)(edited);
|
|
7976
|
+
const day = dayFormatter(options);
|
|
7790
7977
|
return day(edited) === day(message.timestamp) ? time : `${day(edited)} ${time}`;
|
|
7791
7978
|
}, "editedAt");
|
|
7792
7979
|
|
|
7793
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7980
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/cli/messenger/message-items.js
|
|
7794
7981
|
var defined = /* @__PURE__ */ __name((value) => Object.fromEntries(Object.entries(value).filter(([, one]) => one !== void 0)), "defined");
|
|
7795
7982
|
var attachmentItem = /* @__PURE__ */ __name((attachment) => defined({
|
|
7796
7983
|
kind: attachment.kind,
|
|
@@ -7885,7 +8072,7 @@ var viewOf = /* @__PURE__ */ __name((context, messenger) => ({
|
|
|
7885
8072
|
locale: messenger.app.locale
|
|
7886
8073
|
}), "viewOf");
|
|
7887
8074
|
|
|
7888
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
8075
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/cli/messenger/watch-answers.js
|
|
7889
8076
|
var observed = /* @__PURE__ */ __name((value) => ({
|
|
7890
8077
|
value: value.value,
|
|
7891
8078
|
observed_at: value.observedAt,
|
|
@@ -7952,7 +8139,7 @@ var watchEventItem = /* @__PURE__ */ __name((value, account) => {
|
|
|
7952
8139
|
}
|
|
7953
8140
|
}, "watchEventItem");
|
|
7954
8141
|
|
|
7955
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
8142
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/cli/messenger/watch-command.js
|
|
7956
8143
|
var watchCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("watch"), {
|
|
7957
8144
|
output: { entity: "watch_item" },
|
|
7958
8145
|
effects: REMOTE_READ,
|
|
@@ -8107,7 +8294,7 @@ var describe = /* @__PURE__ */ __name((event, render) => {
|
|
|
8107
8294
|
}
|
|
8108
8295
|
}, "describe");
|
|
8109
8296
|
|
|
8110
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
8297
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-command.js
|
|
8111
8298
|
var serveCommand = /* @__PURE__ */ __name((messenger) => {
|
|
8112
8299
|
const command = annotate(new Command("serve"), {
|
|
8113
8300
|
output: { entity: "serve_summary" },
|
|
@@ -8131,8 +8318,8 @@ var serveCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
8131
8318
|
}
|
|
8132
8319
|
let relaying;
|
|
8133
8320
|
const onReady = /* @__PURE__ */ __name(() => {
|
|
8134
|
-
const
|
|
8135
|
-
holdLock(path,
|
|
8321
|
+
const listening2 = { pid: process.pid, startedAt, version, listeningAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
8322
|
+
holdLock(path, listening2);
|
|
8136
8323
|
note({
|
|
8137
8324
|
code: "listening",
|
|
8138
8325
|
text: `listening for profile ${context.profile}, catching up on what arrived while it was down`
|
|
@@ -8141,7 +8328,7 @@ var serveCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
8141
8328
|
return;
|
|
8142
8329
|
relaying = relay.open(path, context.profile).then((address) => {
|
|
8143
8330
|
if (address)
|
|
8144
|
-
holdLock(path, { ...
|
|
8331
|
+
holdLock(path, { ...listening2, relay: address });
|
|
8145
8332
|
}).catch((error) => {
|
|
8146
8333
|
const errorCode = failureKey(error);
|
|
8147
8334
|
warn({ code: "relay_failed", errorCode, text: `commands cannot run through this serve: ${errorCode}` });
|
|
@@ -8150,7 +8337,7 @@ var serveCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
8150
8337
|
const counts = {};
|
|
8151
8338
|
const rules = replying(context, messenger, Date.parse(startedAt));
|
|
8152
8339
|
const tasks = tasking(context, warn);
|
|
8153
|
-
const { handled, startSyncDelayMs } = environmentOf(this);
|
|
8340
|
+
const { handled, startSyncDelayMs, outdated: outdatedHook } = environmentOf(this);
|
|
8154
8341
|
const count3 = /* @__PURE__ */ __name((event) => {
|
|
8155
8342
|
counts[event.event] = (counts[event.event] ?? 0) + 1;
|
|
8156
8343
|
if (event.event === "message") {
|
|
@@ -8222,9 +8409,25 @@ var serveCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
8222
8409
|
withStore: /* @__PURE__ */ __name((work) => context.withStore((store) => work(store), { name: "serve stems" }), "withStore"),
|
|
8223
8410
|
warn
|
|
8224
8411
|
});
|
|
8412
|
+
const listening = new AbortController();
|
|
8413
|
+
let outdated;
|
|
8414
|
+
const packageRoot = outdatedHook?.packageRoot ?? ownPackageRoot(version);
|
|
8415
|
+
const watch = watchOutdated({
|
|
8416
|
+
check: /* @__PURE__ */ __name(() => outdatedReason({
|
|
8417
|
+
command: messenger.app.command,
|
|
8418
|
+
running: version,
|
|
8419
|
+
storePath: storePath(context.env),
|
|
8420
|
+
packageRoot
|
|
8421
|
+
}), "check"),
|
|
8422
|
+
onOutdated: /* @__PURE__ */ __name((reason) => {
|
|
8423
|
+
outdated = reason;
|
|
8424
|
+
listening.abort();
|
|
8425
|
+
}, "onOutdated"),
|
|
8426
|
+
...outdatedHook?.everyMs === void 0 ? {} : { everyMs: outdatedHook.everyMs }
|
|
8427
|
+
});
|
|
8225
8428
|
try {
|
|
8226
8429
|
await listenUntilStopped(this, context, relay?.messenger ?? messenger, count3, {
|
|
8227
|
-
stop:
|
|
8430
|
+
stop: listening,
|
|
8228
8431
|
catchUp: true,
|
|
8229
8432
|
onReady,
|
|
8230
8433
|
connected: /* @__PURE__ */ __name((open) => {
|
|
@@ -8237,6 +8440,7 @@ var serveCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
8237
8440
|
}, "connected")
|
|
8238
8441
|
});
|
|
8239
8442
|
} finally {
|
|
8443
|
+
watch.stop();
|
|
8240
8444
|
await relaying;
|
|
8241
8445
|
await relay?.close();
|
|
8242
8446
|
rules.stop();
|
|
@@ -8247,6 +8451,8 @@ var serveCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
8247
8451
|
await tasks.settled();
|
|
8248
8452
|
releaseLock(path);
|
|
8249
8453
|
}
|
|
8454
|
+
if (outdated !== void 0)
|
|
8455
|
+
throw new CliError("configuration_error", outdated, { reason: "serve.outdated" });
|
|
8250
8456
|
renderAnswer(this, context, itemOf({
|
|
8251
8457
|
profile: context.profile,
|
|
8252
8458
|
started_at: startedAt,
|
|
@@ -8371,8 +8577,8 @@ var tasking = /* @__PURE__ */ __name((context, warn) => {
|
|
|
8371
8577
|
};
|
|
8372
8578
|
}, "tasking");
|
|
8373
8579
|
|
|
8374
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
8375
|
-
import { existsSync as
|
|
8580
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/cli/messenger/store-tables-command.js
|
|
8581
|
+
import { existsSync as existsSync9 } from "node:fs";
|
|
8376
8582
|
var PATH = "store tables list";
|
|
8377
8583
|
var STORE_TABLES_QUERY = {
|
|
8378
8584
|
entity: "store_table",
|
|
@@ -8401,7 +8607,7 @@ var storeTablesCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
8401
8607
|
const filter = filterOf(words);
|
|
8402
8608
|
const { full } = this.optsWithGlobals();
|
|
8403
8609
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8404
|
-
if (!
|
|
8610
|
+
if (!existsSync9(path))
|
|
8405
8611
|
throw new CliError("not_found", `no store at ${path}`);
|
|
8406
8612
|
const items = await readStoreTables(path, { filter, sizes: full === true });
|
|
8407
8613
|
renderAnswer(this, outputFor(this), listOf(PATH, {
|
|
@@ -8414,7 +8620,7 @@ var storeTablesCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
8414
8620
|
return tables;
|
|
8415
8621
|
}, "storeTablesCommand");
|
|
8416
8622
|
|
|
8417
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
8623
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.619.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._3343d636b3fedf7ef3285e4c7a47096e/node_modules/@wirecat/cli-core/dist/cli/messenger/store-maintenance-command.js
|
|
8418
8624
|
var SEARCH_INDEXES = ["messages_fts", "chats_fts", "identities_fts"];
|
|
8419
8625
|
var WORD_INDEX = "message_words";
|
|
8420
8626
|
var schemaOf = /* @__PURE__ */ __name((database) => {
|
|
@@ -8423,7 +8629,7 @@ var schemaOf = /* @__PURE__ */ __name((database) => {
|
|
|
8423
8629
|
}, "schemaOf");
|
|
8424
8630
|
var count2 = /* @__PURE__ */ __name((database, table) => Number(database.prepare(`SELECT count(*) AS n FROM ${table}`).get()?.n ?? 0), "count");
|
|
8425
8631
|
var pendingIfKnown2 = /* @__PURE__ */ __name((database) => database.prepare("SELECT 1 FROM pragma_table_info('messages') WHERE name = 'normalized_text'").get() ? pendingNormalization(database) : null, "pendingIfKnown");
|
|
8426
|
-
var bytesOf2 = /* @__PURE__ */ __name((path) =>
|
|
8632
|
+
var bytesOf2 = /* @__PURE__ */ __name((path) => existsSync10(path) ? statSync4(path).size : 0, "bytesOf");
|
|
8427
8633
|
var reading = /* @__PURE__ */ __name(async (path, read) => {
|
|
8428
8634
|
const database = await openCache(path);
|
|
8429
8635
|
try {
|
|
@@ -8450,9 +8656,10 @@ var fileSchema = /* @__PURE__ */ __name(async (path) => {
|
|
|
8450
8656
|
}, "fileSchema");
|
|
8451
8657
|
var storeSummary = /* @__PURE__ */ __name(async (env, { deep = false, command, version } = {}) => {
|
|
8452
8658
|
const path = storePath(env);
|
|
8453
|
-
if (!
|
|
8659
|
+
if (!existsSync10(path))
|
|
8454
8660
|
return { path, exists: false };
|
|
8455
8661
|
const checked = await storeHealth(path, { deep });
|
|
8662
|
+
const journal = readJournalMark(path);
|
|
8456
8663
|
const recorded = deep ? recordDeepCheck(path, checked, {
|
|
8457
8664
|
cli: command ?? "unknown",
|
|
8458
8665
|
...version ? { version } : {},
|
|
@@ -8470,13 +8677,15 @@ var storeSummary = /* @__PURE__ */ __name(async (env, { deep = false, command, v
|
|
|
8470
8677
|
...checked.invalidJson?.length ? { invalidJson: checked.invalidJson } : {},
|
|
8471
8678
|
...checked.searchIndexes?.some((index) => !index.ok) ? { damagedSearchIndexes: checked.searchIndexes.filter((index) => !index.ok).map((index) => index.name) } : {}
|
|
8472
8679
|
};
|
|
8473
|
-
const damage = command ?
|
|
8680
|
+
const damage = command ? storeDamageReport({ health: checked, command, mark, journal, lastOkAt: lastKnownGood }) : null;
|
|
8474
8681
|
const healthOf = {
|
|
8475
8682
|
health,
|
|
8476
8683
|
lastKnownGood,
|
|
8477
8684
|
...mark ? { damageMark: withoutInode(mark) } : {},
|
|
8685
|
+
...journal ? { journalMark: journal } : {},
|
|
8478
8686
|
...recorded?.cleared ? { damageMarkCleared: withoutInode(recorded.cleared) } : {},
|
|
8479
|
-
|
|
8687
|
+
// `what` keeps memo's doctor, which reads it, compiling until it moves to `whatHappened`.
|
|
8688
|
+
...damage ? { damage: { what: damage.whatHappened, ...damage } } : {}
|
|
8480
8689
|
};
|
|
8481
8690
|
try {
|
|
8482
8691
|
return await reading(path, (database) => {
|
|
@@ -8520,7 +8729,7 @@ var repairCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("
|
|
|
8520
8729
|
const { renderer, format } = outputFor(this);
|
|
8521
8730
|
const { dryRun: dryRun2 } = this.opts();
|
|
8522
8731
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8523
|
-
if (!
|
|
8732
|
+
if (!existsSync10(path)) {
|
|
8524
8733
|
result(this, { path, exists: false });
|
|
8525
8734
|
return;
|
|
8526
8735
|
}
|
|
@@ -8560,7 +8769,7 @@ var notesOf = /* @__PURE__ */ __name((report, command) => {
|
|
|
8560
8769
|
}, "notesOf");
|
|
8561
8770
|
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) {
|
|
8562
8771
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8563
|
-
if (!
|
|
8772
|
+
if (!existsSync10(path))
|
|
8564
8773
|
throw new CliError("not_found", `no store at ${path}`);
|
|
8565
8774
|
const deleted = await reading(path, (database) => deleteCopy(database, name));
|
|
8566
8775
|
result(this, { path, deleted });
|
|
@@ -8568,7 +8777,7 @@ var copiesCommand = /* @__PURE__ */ __name(() => new Command("copies").descripti
|
|
|
8568
8777
|
var checkCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("check"), { output: { entity: "store_check" }, effects: LOCAL_READ }).summary("check the local archive for problems").description("whether the store is healthy \u2014 integrity, search indexes, disk, and which chats are behind").action(async function() {
|
|
8569
8778
|
const { renderer } = outputFor(this);
|
|
8570
8779
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8571
|
-
if (!
|
|
8780
|
+
if (!existsSync10(path)) {
|
|
8572
8781
|
result(this, { path, exists: false, ok: true });
|
|
8573
8782
|
return;
|
|
8574
8783
|
}
|
|
@@ -8631,7 +8840,7 @@ var inspect = /* @__PURE__ */ __name((path) => reading(path, (database) => {
|
|
|
8631
8840
|
...schema.version > 0 ? [["attachment_words", indexIntegrity(database, "attachment_words", 0)]] : []
|
|
8632
8841
|
]);
|
|
8633
8842
|
const size = bytesOf2(path) + bytesOf2(`${path}-wal`);
|
|
8634
|
-
const { bavail, bsize } = statfsSync2(
|
|
8843
|
+
const { bavail, bsize } = statfsSync2(dirname3(path));
|
|
8635
8844
|
const free = Number(bavail) * Number(bsize);
|
|
8636
8845
|
const behind = schema.version > 0 ? chatsBehind(database) : [];
|
|
8637
8846
|
const vectorIndexes = schema.version >= 34 ? vectorIndexCounts(database) : [];
|
|
@@ -8719,7 +8928,7 @@ var chatsBehind = /* @__PURE__ */ __name((database) => database.prepare(`SELECT
|
|
|
8719
8928
|
var migrateCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("migrate"), { output: { entity: "store_migration" }, effects: LOCAL_WRITE }).summary("migrate an older local archive").description("bring the store up to this build's schema, then normalize, index and stem the messages and notes stored before it").action(async function() {
|
|
8720
8929
|
const { renderer } = outputFor(this);
|
|
8721
8930
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8722
|
-
if (!
|
|
8931
|
+
if (!existsSync10(path)) {
|
|
8723
8932
|
result(this, { path, exists: false });
|
|
8724
8933
|
renderer.note(`no store yet \u2014 the first \`${messenger.app.command}\` command that reads a chat creates it`);
|
|
8725
8934
|
return;
|
|
@@ -8783,7 +8992,7 @@ var buildNoteIndex = /* @__PURE__ */ __name((database, note, { reset = false } =
|
|
|
8783
8992
|
var reindexCommand = /* @__PURE__ */ __name((messenger) => destroysNothing(annotate(new Command("rebuild"), { output: { entity: "store_reindex" }, effects: LOCAL_WRITE })).summary("rebuild the local archive's search indexes").description("rebuild the word index, its typo vocabulary, the stems, the files' word index, the notes' indexes and who took part in what, from what is stored, and drop the vectors no stored text uses; loses nothing").action(async function() {
|
|
8784
8993
|
const { renderer } = outputFor(this);
|
|
8785
8994
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8786
|
-
if (!
|
|
8995
|
+
if (!existsSync10(path)) {
|
|
8787
8996
|
result(this, { path, exists: false });
|
|
8788
8997
|
return;
|
|
8789
8998
|
}
|
|
@@ -8825,9 +9034,9 @@ var backupCommand = /* @__PURE__ */ __name(() => destroysNothing(annotate(new Co
|
|
|
8825
9034
|
const { encrypt } = this.opts();
|
|
8826
9035
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8827
9036
|
const target = resolve(file2);
|
|
8828
|
-
if (!
|
|
9037
|
+
if (!existsSync10(path))
|
|
8829
9038
|
throw new CliError("not_found", `no store at ${path} to back up`);
|
|
8830
|
-
if (
|
|
9039
|
+
if (existsSync10(target))
|
|
8831
9040
|
throw new CliError("validation_error", `${target} exists \u2014 a backup never overwrites a file`);
|
|
8832
9041
|
const password = encrypt ? await passwordOf(this, { twice: true }) : void 0;
|
|
8833
9042
|
const copyAt = password === void 0 ? target : `${path}.backup-${process.pid}`;
|
|
@@ -8860,11 +9069,11 @@ var decryptCommand = /* @__PURE__ */ __name(() => annotate(new Command("decrypt"
|
|
|
8860
9069
|
const { output } = this.opts();
|
|
8861
9070
|
const from = resolve(file2);
|
|
8862
9071
|
const to = resolve(output);
|
|
8863
|
-
if (!
|
|
9072
|
+
if (!existsSync10(from))
|
|
8864
9073
|
throw new CliError("not_found", `no file at ${from}`);
|
|
8865
9074
|
if (!isSealed(from))
|
|
8866
9075
|
throw new CliError("validation_error", `${from} was not written with --encrypt`);
|
|
8867
|
-
if (
|
|
9076
|
+
if (existsSync10(to))
|
|
8868
9077
|
throw new CliError("validation_error", `${to} exists \u2014 never overwritten`);
|
|
8869
9078
|
await unsealFile(from, to, await passwordOf(this, { twice: false }));
|
|
8870
9079
|
result(this, { path: to, from, bytes: bytesOf2(to) });
|
|
@@ -8872,13 +9081,13 @@ var decryptCommand = /* @__PURE__ */ __name(() => annotate(new Command("decrypt"
|
|
|
8872
9081
|
var restoreCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("restore"), { output: { entity: "store_restore" }, effects: LOCAL_WRITE }).summary("restore a backup and keep the current store, or roll back a breaking upgrade").description("put a backup in place of the store; the store it replaces is kept beside it, never deleted. Given a rollback copy (backups/<store>-rollback-schema-<version>-<time>.db, kept for a day before an upgrade older tools cannot open), put its tables back in the store and return it to that version instead").argument("<file>", "a file `store backup` wrote, or a rollback copy; one written with --encrypt asks for its password").action(async function(file2) {
|
|
8873
9082
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8874
9083
|
const given = resolve(file2);
|
|
8875
|
-
if (!
|
|
9084
|
+
if (!existsSync10(given))
|
|
8876
9085
|
throw new CliError("not_found", `no file at ${given}`);
|
|
8877
9086
|
refuseWhileServing(this, messenger);
|
|
8878
9087
|
if (!isSealed(given))
|
|
8879
9088
|
return restoreFrom(this, messenger, given, given);
|
|
8880
9089
|
const opened = `${path}.unsealing-${process.pid}`;
|
|
8881
|
-
mkdirSync(
|
|
9090
|
+
mkdirSync(dirname3(path), { recursive: true, mode: 448 });
|
|
8882
9091
|
try {
|
|
8883
9092
|
await unsealFile(given, opened, await passwordOf(this, { twice: false }));
|
|
8884
9093
|
await restoreFrom(this, messenger, opened, given);
|
|
@@ -8889,26 +9098,26 @@ var restoreCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command(
|
|
|
8889
9098
|
var restoreFrom = /* @__PURE__ */ __name(async (command, messenger, backup, given) => {
|
|
8890
9099
|
const { renderer } = outputFor(command);
|
|
8891
9100
|
const path = storePath(environmentOf(command).env ?? process.env);
|
|
8892
|
-
if (
|
|
9101
|
+
if (existsSync10(path) && realpathSync3(backup) === realpathSync3(path)) {
|
|
8893
9102
|
throw new CliError("validation_error", `${backup} is the store itself`);
|
|
8894
9103
|
}
|
|
8895
9104
|
if (await isRollbackCopy(backup))
|
|
8896
9105
|
return rollBackFrom(command, messenger, backup);
|
|
8897
9106
|
const schema = await backupSchema(backup);
|
|
8898
9107
|
const stamp = stampNow();
|
|
8899
|
-
const kept =
|
|
9108
|
+
const kept = existsSync10(path) ? `${path}.before-restore-${stamp}` : null;
|
|
8900
9109
|
if (kept) {
|
|
8901
9110
|
const waitMs = environmentOf(command).storeLockWaitMs;
|
|
8902
9111
|
await quiesce(path, messenger, "restore", (message) => renderer.warn(message), waitMs);
|
|
8903
9112
|
} else
|
|
8904
|
-
mkdirSync(
|
|
9113
|
+
mkdirSync(dirname3(path), { recursive: true, mode: 448 });
|
|
8905
9114
|
const incoming = `${path}.restoring-${stamp}`;
|
|
8906
9115
|
copyFileSync(backup, incoming, constants.COPYFILE_EXCL);
|
|
8907
9116
|
chmodSync(incoming, 384);
|
|
8908
9117
|
if (kept) {
|
|
8909
9118
|
renameSync3(path, kept);
|
|
8910
9119
|
for (const suffix of ["-wal", "-shm"])
|
|
8911
|
-
if (
|
|
9120
|
+
if (existsSync10(`${path}${suffix}`))
|
|
8912
9121
|
renameSync3(`${path}${suffix}`, `${kept}${suffix}`);
|
|
8913
9122
|
}
|
|
8914
9123
|
renameSync3(incoming, path);
|
|
@@ -8930,7 +9139,7 @@ var isRollbackCopy = /* @__PURE__ */ __name(async (file2) => {
|
|
|
8930
9139
|
var rollBackFrom = /* @__PURE__ */ __name(async (command, messenger, copy) => {
|
|
8931
9140
|
const { renderer } = outputFor(command);
|
|
8932
9141
|
const path = storePath(environmentOf(command).env ?? process.env);
|
|
8933
|
-
if (!
|
|
9142
|
+
if (!existsSync10(path))
|
|
8934
9143
|
throw new CliError("not_found", `no store at ${path} to roll back`);
|
|
8935
9144
|
const waitMs = environmentOf(command).storeLockWaitMs;
|
|
8936
9145
|
await quiesce(path, messenger, "restore", (message) => renderer.warn(message), waitMs);
|
|
@@ -8980,7 +9189,7 @@ var backupSchema = /* @__PURE__ */ __name(async (backup) => {
|
|
|
8980
9189
|
var STORE_LOCK_WAIT_MS = 1e3;
|
|
8981
9190
|
var quiesce = /* @__PURE__ */ __name(async (path, messenger, then, warn, waitMs = STORE_LOCK_WAIT_MS) => {
|
|
8982
9191
|
const { command } = messenger.app;
|
|
8983
|
-
const files = [path, `${path}-wal`, `${path}-shm`].filter((file2) =>
|
|
9192
|
+
const files = [path, `${path}-wal`, `${path}-shm`].filter((file2) => existsSync10(file2)).map((file2) => realpathSync3(file2));
|
|
8984
9193
|
const holders = holdersOf(files);
|
|
8985
9194
|
if (holders === void 0) {
|
|
8986
9195
|
warn(`this system cannot say which processes have the store open \u2014 restart every running serve and mcp after this`);
|
|
@@ -9006,7 +9215,7 @@ var resetCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("r
|
|
|
9006
9215
|
const { command } = messenger.app;
|
|
9007
9216
|
const env = environmentOf(this).env ?? process.env;
|
|
9008
9217
|
const path = storePath(env);
|
|
9009
|
-
if (!
|
|
9218
|
+
if (!existsSync10(path)) {
|
|
9010
9219
|
result(this, { path, exists: false, reset: false });
|
|
9011
9220
|
renderer.note(`no store at ${path} \u2014 nothing to reset; the first \`${command}\` command that reads a chat creates it`);
|
|
9012
9221
|
return;
|
|
@@ -9051,8 +9260,8 @@ var resetCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("r
|
|
|
9051
9260
|
}), "resetCommand");
|
|
9052
9261
|
var STORE_PARTS2 = ["", "-wal", "-shm"];
|
|
9053
9262
|
var resetPreview = /* @__PURE__ */ __name(async (path, messenger, env, keep) => {
|
|
9054
|
-
const files = STORE_PARTS2.map((suffix) => `${path}${suffix}`).filter((file2) =>
|
|
9055
|
-
const holders = holdersOf(files.map((file2) =>
|
|
9263
|
+
const files = STORE_PARTS2.map((suffix) => `${path}${suffix}`).filter((file2) => existsSync10(file2));
|
|
9264
|
+
const holders = holdersOf(files.map((file2) => realpathSync3(file2)));
|
|
9056
9265
|
const serving = servingProfiles(messenger.app, env).length > 0;
|
|
9057
9266
|
const read = await readingOnly(path, (database) => ({
|
|
9058
9267
|
schema: schemaOf(database).version,
|
|
@@ -9098,11 +9307,9 @@ export {
|
|
|
9098
9307
|
readRepliesState,
|
|
9099
9308
|
writeRepliesState,
|
|
9100
9309
|
paused,
|
|
9310
|
+
safeLiquid,
|
|
9101
9311
|
DRY_RUN_DAYS,
|
|
9102
9312
|
dryRun,
|
|
9103
|
-
endpointKeyName,
|
|
9104
|
-
embeddingKeys,
|
|
9105
|
-
modelGateway,
|
|
9106
9313
|
replyConsentPathFor,
|
|
9107
9314
|
readReplyConsent,
|
|
9108
9315
|
writeReplyConsent,
|