@wirecat/mail-cli 0.24.0 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -0
- package/README.md +3 -0
- package/contracts/wirecat.json +1325 -0
- package/dist/bin/mail.js +2 -2
- package/dist/bin/mail.js.map +1 -1
- package/dist/bundle/{all-profiles-VS7P6DJY.js → all-profiles-6NXVQLUQ.js} +11 -11
- package/dist/bundle/{anthropic-C5JXKGBS.js → anthropic-OLNFE2CL.js} +17 -10
- package/dist/bundle/{app-server-HU3LVU42.js → app-server-J76N6XIK.js} +60 -49
- package/dist/bundle/{bun-QLFX47WZ.js → bun-6PYDHXNR.js} +2 -2
- package/dist/bundle/{bun-sqlite-W4PGAKVY.js → bun-sqlite-QD5PFHPS.js} +9 -5
- package/dist/bundle/{chunk-WOX7FZJP.js → chunk-2E2EV4HD.js} +130 -77
- package/dist/bundle/{chunk-A6J4MPTI.js → chunk-2TCS4PLJ.js} +1 -1
- package/dist/bundle/{chunk-QI3PXUOJ.js → chunk-3J2UJFBJ.js} +39 -32
- package/dist/bundle/{chunk-LVGX7VTD.js → chunk-3RY4HC4V.js} +63 -5
- package/dist/bundle/chunk-3XTKQ5EM.js +54 -0
- package/dist/bundle/{chunk-ZO4MQWIK.js → chunk-4Q6KAV4O.js} +8 -8
- package/dist/bundle/{chunk-JOQGJUFT.js → chunk-52M5BAEG.js} +1 -1
- package/dist/bundle/{chunk-Q4OKEN3B.js → chunk-5WROIMUV.js} +12 -7
- package/dist/bundle/{chunk-VVL4MKYH.js → chunk-66C66FNK.js} +1 -1
- package/dist/bundle/{chunk-O373QEAJ.js → chunk-76EKZSDK.js} +27 -27
- package/dist/bundle/{chunk-AUTX2MLF.js → chunk-76VSHS5Y.js} +15 -10
- package/dist/bundle/{chunk-HBZAJINU.js → chunk-7C6FGWDH.js} +4 -4
- package/dist/bundle/{chunk-VUBZFMGP.js → chunk-7KCBPAQS.js} +2 -2
- package/dist/bundle/{chunk-FNLUKODV.js → chunk-7MEVD5PI.js} +57 -28
- package/dist/bundle/chunk-A3EBRXOQ.js +16 -0
- package/dist/bundle/{chunk-C3NYJW6B.js → chunk-A6XETABW.js} +852 -278
- package/dist/bundle/{chunk-VNKWSCN7.js → chunk-AJ5K74X6.js} +17 -17
- package/dist/bundle/{chunk-BFQQV22T.js → chunk-BDYQQ6G2.js} +1 -1
- package/dist/bundle/{chunk-ZR2BDNGG.js → chunk-BMGRDZM3.js} +1 -1
- package/dist/bundle/{chunk-TLEBSMC7.js → chunk-CFBIPM7T.js} +4109 -3575
- package/dist/bundle/{chunk-IRUN4XOV.js → chunk-CZI45AQM.js} +2 -2
- package/dist/bundle/{chunk-QVMOEB3I.js → chunk-DKIVYAXW.js} +18 -17
- package/dist/bundle/{chunk-X7J3TTDO.js → chunk-ECZSYLSL.js} +48 -9
- package/dist/bundle/{chunk-EKGRNFYQ.js → chunk-EDWJ7IYH.js} +1 -1
- package/dist/bundle/{chunk-MCPOZNWG.js → chunk-FIVFP53N.js} +1 -1
- package/dist/bundle/{chunk-5X3GU5LI.js → chunk-GIG7F6UW.js} +6 -6
- package/dist/bundle/{chunk-RN7OI5KL.js → chunk-H2IJQH5X.js} +20 -112
- package/dist/bundle/{chunk-NWKKPDZV.js → chunk-HI5XUETY.js} +2 -2
- package/dist/bundle/{chunk-YBQ5AYLZ.js → chunk-HNSBXC6U.js} +3 -3
- package/dist/bundle/{chunk-4W4EVVL4.js → chunk-IX3GUNGV.js} +4 -4
- package/dist/bundle/{chunk-PT6MF2VU.js → chunk-JNKXU7AE.js} +340 -108
- package/dist/bundle/{chunk-64ZG5ERD.js → chunk-JVJG54QK.js} +40 -2
- package/dist/bundle/{chunk-KGOVFEWZ.js → chunk-KXASCNOV.js} +3 -3
- package/dist/bundle/{chunk-5NLHDK7P.js → chunk-LMTQMYUF.js} +31 -31
- package/dist/bundle/{chunk-Q6K2XUGU.js → chunk-LTZGLOKE.js} +3 -2
- package/dist/bundle/{chunk-RLQZFZLK.js → chunk-M2LATBP2.js} +84 -10
- package/dist/bundle/{chunk-RX5CJ55S.js → chunk-M4OP5ASJ.js} +1 -1
- package/dist/bundle/{chunk-H5FJTHVA.js → chunk-M4Y33SJJ.js} +2 -2
- package/dist/bundle/{chunk-SWKQ6IAR.js → chunk-M7ECSGSN.js} +3 -3
- package/dist/bundle/{chunk-MTO6YVMN.js → chunk-M7RHPCXM.js} +3 -3
- package/dist/bundle/{chunk-PRQ2U7HF.js → chunk-MIWSCTLG.js} +2 -2
- package/dist/bundle/{chunk-NSIN5IM4.js → chunk-NBJU6MBU.js} +10 -15
- package/dist/bundle/{chunk-JWMLMAHP.js → chunk-NMFPK3MU.js} +14 -5
- package/dist/bundle/{chunk-4QNHAM3J.js → chunk-OGE7YG4J.js} +2 -2
- package/dist/bundle/{chunk-XBEO472U.js → chunk-PJ6YMNJG.js} +26515 -24466
- package/dist/bundle/{chunk-RUASZW3M.js → chunk-PY2IOVUN.js} +5 -5
- package/dist/bundle/{chunk-OQW6GHUA.js → chunk-QI6EXKSH.js} +1 -1
- package/dist/bundle/{chunk-KV4VTKF3.js → chunk-QJGG6QYV.js} +69 -6
- package/dist/bundle/{chunk-JMLIKXFO.js → chunk-RXKIP2ML.js} +2 -2
- package/dist/bundle/{chunk-6VV7J2TN.js → chunk-T7SHPALQ.js} +35 -28
- package/dist/bundle/{chunk-YI544LHI.js → chunk-UE2NKPA4.js} +9 -9
- package/dist/bundle/{chunk-X47BL4M5.js → chunk-UNJUCK5R.js} +13 -13
- package/dist/bundle/{chunk-C5BMCLCQ.js → chunk-V32L23NN.js} +4 -4
- package/dist/bundle/{chunk-DW3F6DUW.js → chunk-V4PFD25P.js} +1 -1
- package/dist/bundle/{chunk-U6MMQNNK.js → chunk-VA4V73SL.js} +6 -6
- package/dist/bundle/{chunk-3KSK5BBB.js → chunk-VJPLIXV4.js} +8 -2
- package/dist/bundle/{chunk-YA45XV6G.js → chunk-VWRT57QU.js} +4 -4
- package/dist/bundle/{chunk-FKWUUCX2.js → chunk-XELZCDWE.js} +427 -189
- package/dist/bundle/{chunk-3FD3IATT.js → chunk-XUJEZ5YF.js} +6 -6
- package/dist/bundle/{chunk-TI7ZIPA2.js → chunk-XZ7CQ6NA.js} +4 -4
- package/dist/bundle/{chunk-NCRSE647.js → chunk-YM345236.js} +159 -46
- package/dist/bundle/{chunk-6PWCQKMD.js → chunk-YXGHC3NP.js} +14 -14
- package/dist/bundle/{chunk-RNZKQMFY.js → chunk-ZZSZN4CJ.js} +22 -15
- package/dist/bundle/command-contract-NNEXHZW5.js +36 -0
- package/dist/bundle/{command-server-entry-5E3PPDE5.js → command-server-entry-AIBWNC5D.js} +25 -24
- package/dist/bundle/{decode-AVWV7SVZ.js → decode-H7KLRD33.js} +5 -5
- package/dist/bundle/{dispatch-BXPHSNK5.js → dispatch-DSVN7MNG.js} +8 -8
- package/dist/bundle/{dist-PIOOKBWT.js → dist-YYSP43J3.js} +29 -18
- package/dist/bundle/{echarts-7K6YQV52.js → echarts-VSD3LS6D.js} +2 -2
- package/dist/bundle/{embed-4NT76GJK.js → embed-UENZ5HN3.js} +6 -6
- package/dist/bundle/{embedder-ITQFF7EN.js → embedder-MJMGOJT7.js} +9 -9
- package/dist/bundle/{failure-3Q65JOPD.js → failure-COTPFUP4.js} +2 -2
- package/dist/bundle/{first-run-PM74YU4X.js → first-run-HYALREFN.js} +12 -11
- package/dist/bundle/first-screen-GPF5RHBX.js +34 -0
- package/dist/bundle/{instructions-JDSITYHV.js → instructions-WOHRYOLN.js} +1 -1
- package/dist/bundle/mail.js +15 -20
- package/dist/bundle/{mcp-7KQUJNFN.js → mcp-TDKGDB4V.js} +2 -2
- package/dist/bundle/{node-D6YIJOJI.js → node-4BRWJJCE.js} +2 -2
- package/dist/bundle/{node-sqlite-PJOHHB4X.js → node-sqlite-D3QESEYQ.js} +10 -6
- package/dist/bundle/{oauth-BOWJ3IBT.js → oauth-T7TTOBIZ.js} +7 -7
- package/dist/bundle/{open-FIAKKZMW.js → open-6P6627QB.js} +5 -5
- package/dist/bundle/{openai-QL54VVLC.js → openai-FIMCJGAP.js} +24 -19
- package/dist/bundle/{process-AYHK7WRC.js → process-35IH3WHC.js} +1 -1
- package/dist/bundle/{program-6FKWOTBK.js → program-IEXB72IK.js} +6685 -5463
- package/dist/bundle/{prompt-XJZCBELC.js → prompt-HFBCPMVL.js} +5 -5
- package/dist/bundle/{recognize-OQKWAHBY.js → recognize-CNL4HJ7Z.js} +4 -4
- package/dist/bundle/{remote-NLVUZ5WK.js → remote-AYGZI7HT.js} +9 -7
- package/dist/bundle/{rerank-NRPZDTJ7.js → rerank-5C2OZZXD.js} +7 -7
- package/dist/bundle/{serve-O4YUI7F6.js → serve-S6OYBDIB.js} +9 -9
- package/dist/bundle/{server-WAL3M4OO.js → server-VKO6E6PI.js} +42 -40
- package/dist/bundle/server-WXSHVDME.js +68 -0
- package/dist/bundle/{sqlite-runtime-5YHGI4D4.js → sqlite-runtime-DBTGNTVE.js} +6 -6
- package/dist/bundle/{state-WYYOJ7KK.js → state-ZQG6AL2Y.js} +6 -6
- package/dist/bundle/{store-X72GOJHD.js → store-B7BXWILZ.js} +25 -18
- package/dist/bundle/{store-6BJO3F2J.js → store-LY4QKTOO.js} +19 -16
- package/dist/bundle/store-maintenance-command-UR6NQDVV.js +58 -0
- package/dist/commands/rules.d.ts.map +1 -1
- package/dist/commands/rules.js +57 -19
- package/dist/commands/rules.js.map +1 -1
- package/dist/commands/session-start.d.ts.map +1 -1
- package/dist/commands/session-start.js +1 -1
- package/dist/commands/session-start.js.map +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +13 -12
- package/dist/config.js.map +1 -1
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +7 -2
- package/dist/discovery.js.map +1 -1
- package/dist/identity.d.ts +2 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +34 -0
- package/dist/identity.js.map +1 -1
- package/dist/mail/domain-age.d.ts +1 -1
- package/dist/mail/domain-age.d.ts.map +1 -1
- package/dist/mail/domain-age.js +9 -3
- package/dist/mail/domain-age.js.map +1 -1
- package/dist/mail/rules/file.d.ts.map +1 -1
- package/dist/mail/rules/file.js +4 -1
- package/dist/mail/rules/file.js.map +1 -1
- package/dist/mail/rules/query.d.ts +2 -1
- package/dist/mail/rules/query.d.ts.map +1 -1
- package/dist/mail/rules/query.js +16 -3
- package/dist/mail/rules/query.js.map +1 -1
- package/dist/oauth.d.ts +3 -1
- package/dist/oauth.d.ts.map +1 -1
- package/dist/oauth.js +48 -34
- package/dist/oauth.js.map +1 -1
- package/dist/reasons.d.ts.map +1 -1
- package/dist/reasons.js +5 -0
- package/dist/reasons.js.map +1 -1
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +2 -21
- package/dist/store.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 +10 -9
- package/dist/bundle/chunk-B72343TK.js +0 -35
- package/dist/bundle/command-contract-ERYYPAD2.js +0 -35
- package/dist/bundle/first-screen-WBVGVSMY.js +0 -33
- package/dist/bundle/server-6OT5ZEWL.js +0 -66
- package/dist/bundle/store-maintenance-command-ASS7RBYC.js +0 -54
- /package/dist/bundle/{chunk-YVNHQFLC.js → chunk-XWBPP2HX.js} +0 -0
|
@@ -2,11 +2,11 @@ import { createRequire as __bundleRequire } from "node:module";
|
|
|
2
2
|
const require = __bundleRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
renderMessages
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-OGE7YG4J.js";
|
|
6
6
|
import {
|
|
7
7
|
answerOf,
|
|
8
8
|
messengerContext
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-3J2UJFBJ.js";
|
|
10
10
|
import {
|
|
11
11
|
FETCHING,
|
|
12
12
|
RULES_VERSION,
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
patiently,
|
|
24
24
|
pollVoteAnswer,
|
|
25
25
|
queryTerms,
|
|
26
|
+
refuseLockedOutput,
|
|
26
27
|
senderIsMe,
|
|
27
28
|
serveRelay,
|
|
28
29
|
servicesFor,
|
|
@@ -30,17 +31,17 @@ import {
|
|
|
30
31
|
typedQuery,
|
|
31
32
|
withQuery,
|
|
32
33
|
withTimeLimit
|
|
33
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-CFBIPM7T.js";
|
|
34
35
|
import {
|
|
35
36
|
holdLock,
|
|
36
37
|
lockPath,
|
|
37
38
|
releaseLock,
|
|
38
39
|
servingProfiles,
|
|
39
40
|
takeLock
|
|
40
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-HNSBXC6U.js";
|
|
41
42
|
import {
|
|
42
43
|
readSecret
|
|
43
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-KXASCNOV.js";
|
|
44
45
|
import {
|
|
45
46
|
Command,
|
|
46
47
|
LOCAL_READ,
|
|
@@ -49,8 +50,10 @@ import {
|
|
|
49
50
|
REMOTE_WRITE,
|
|
50
51
|
annotate,
|
|
51
52
|
codeOf,
|
|
53
|
+
commandAt,
|
|
52
54
|
destroysNothing,
|
|
53
55
|
environmentOf,
|
|
56
|
+
grantsAuthority,
|
|
54
57
|
itemOf,
|
|
55
58
|
jsonlRecords,
|
|
56
59
|
lineOf,
|
|
@@ -65,13 +68,13 @@ import {
|
|
|
65
68
|
snakeKeys,
|
|
66
69
|
storeTable,
|
|
67
70
|
withoutProviderRefs
|
|
68
|
-
} from "./chunk-
|
|
71
|
+
} from "./chunk-XELZCDWE.js";
|
|
69
72
|
import {
|
|
70
73
|
levelFor
|
|
71
|
-
} from "./chunk-
|
|
74
|
+
} from "./chunk-5WROIMUV.js";
|
|
72
75
|
import {
|
|
73
76
|
holdersOf
|
|
74
|
-
} from "./chunk-
|
|
77
|
+
} from "./chunk-V4PFD25P.js";
|
|
75
78
|
import {
|
|
76
79
|
QUICK_HEALTH_CHECKS,
|
|
77
80
|
fts5Tables,
|
|
@@ -79,7 +82,7 @@ import {
|
|
|
79
82
|
lossUnknown,
|
|
80
83
|
storeDamageReport,
|
|
81
84
|
storeHealth
|
|
82
|
-
} from "./chunk-
|
|
85
|
+
} from "./chunk-AJ5K74X6.js";
|
|
83
86
|
import {
|
|
84
87
|
CORPORA,
|
|
85
88
|
MIGRATIONS,
|
|
@@ -114,39 +117,51 @@ import {
|
|
|
114
117
|
storeClients,
|
|
115
118
|
storeContents,
|
|
116
119
|
vectorIndexCounts
|
|
117
|
-
} from "./chunk-
|
|
120
|
+
} from "./chunk-PJ6YMNJG.js";
|
|
118
121
|
import {
|
|
119
122
|
currentRun,
|
|
120
123
|
readDamageMark,
|
|
121
124
|
readHealthMark,
|
|
122
125
|
readJournalMark,
|
|
123
126
|
recordDeepCheck
|
|
124
|
-
} from "./chunk-
|
|
127
|
+
} from "./chunk-76EKZSDK.js";
|
|
125
128
|
import {
|
|
126
129
|
formatLocator,
|
|
127
130
|
parseLocator,
|
|
128
131
|
queryFieldsOf
|
|
129
|
-
} from "./chunk-
|
|
132
|
+
} from "./chunk-2E2EV4HD.js";
|
|
130
133
|
import {
|
|
131
134
|
failureKey,
|
|
132
135
|
isStoreDamage
|
|
133
|
-
} from "./chunk-
|
|
136
|
+
} from "./chunk-VJPLIXV4.js";
|
|
137
|
+
import {
|
|
138
|
+
modelAddressAllowed,
|
|
139
|
+
onThisComputer
|
|
140
|
+
} from "./chunk-3RY4HC4V.js";
|
|
141
|
+
import {
|
|
142
|
+
readSharedSection,
|
|
143
|
+
sharedConfigPath,
|
|
144
|
+
writeSharedSection
|
|
145
|
+
} from "./chunk-XUJEZ5YF.js";
|
|
134
146
|
import {
|
|
135
147
|
storePath
|
|
136
|
-
} from "./chunk-
|
|
148
|
+
} from "./chunk-3XTKQ5EM.js";
|
|
137
149
|
import {
|
|
138
150
|
openCache
|
|
139
|
-
} from "./chunk-
|
|
151
|
+
} from "./chunk-VA4V73SL.js";
|
|
140
152
|
import {
|
|
153
|
+
Credentials,
|
|
154
|
+
isMovedRun,
|
|
141
155
|
resolvePaths,
|
|
142
156
|
writeSecurely
|
|
143
|
-
} from "./chunk-
|
|
157
|
+
} from "./chunk-7MEVD5PI.js";
|
|
144
158
|
import {
|
|
145
159
|
array,
|
|
146
160
|
boolean,
|
|
147
161
|
check,
|
|
148
162
|
forward,
|
|
149
163
|
getDotPath,
|
|
164
|
+
maxLength,
|
|
150
165
|
minLength,
|
|
151
166
|
nullable,
|
|
152
167
|
object,
|
|
@@ -161,10 +176,10 @@ import {
|
|
|
161
176
|
string,
|
|
162
177
|
transform,
|
|
163
178
|
trim
|
|
164
|
-
} from "./chunk-
|
|
179
|
+
} from "./chunk-ECZSYLSL.js";
|
|
165
180
|
import {
|
|
166
181
|
CliError
|
|
167
|
-
} from "./chunk-
|
|
182
|
+
} from "./chunk-7KCBPAQS.js";
|
|
168
183
|
import {
|
|
169
184
|
__commonJS,
|
|
170
185
|
__name,
|
|
@@ -5504,11 +5519,11 @@ var require_liquid_node = __commonJS({
|
|
|
5504
5519
|
}
|
|
5505
5520
|
});
|
|
5506
5521
|
|
|
5507
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5522
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.653.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_65220cf269874adf69135700bd89254b/node_modules/@wirecat/cli-core/dist/cli/messenger/store-maintenance-command.js
|
|
5508
5523
|
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";
|
|
5509
5524
|
import { dirname as dirname3, resolve } from "node:path";
|
|
5510
5525
|
|
|
5511
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5526
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.653.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_65220cf269874adf69135700bd89254b/node_modules/@wirecat/cli-core/dist/sealed.js
|
|
5512
5527
|
import { createCipheriv, createDecipheriv, createHash, randomBytes, scrypt, timingSafeEqual } from "node:crypto";
|
|
5513
5528
|
import { closeSync, createReadStream, createWriteStream, existsSync, openSync, readSync, renameSync, rmSync, statSync } from "node:fs";
|
|
5514
5529
|
import { Transform } from "node:stream";
|
|
@@ -5615,7 +5630,7 @@ var unsealFile = /* @__PURE__ */ __name(async (from, to, password) => {
|
|
|
5615
5630
|
renameSync(pending, to);
|
|
5616
5631
|
}, "unsealFile");
|
|
5617
5632
|
|
|
5618
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5633
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.653.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_65220cf269874adf69135700bd89254b/node_modules/@wirecat/cli-core/dist/store/compatibility.js
|
|
5619
5634
|
var SPEAKS = MIGRATIONS.at(-1)?.version ?? 0;
|
|
5620
5635
|
var fileSchemaOf = /* @__PURE__ */ __name((database) => {
|
|
5621
5636
|
const tracked = database.prepare("SELECT 1 FROM sqlite_master WHERE name = 'schema_migrations'").get();
|
|
@@ -5639,7 +5654,7 @@ var compatibilityOf = /* @__PURE__ */ __name((file2, migrations = MIGRATIONS) =>
|
|
|
5639
5654
|
};
|
|
5640
5655
|
}, "compatibilityOf");
|
|
5641
5656
|
|
|
5642
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5657
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.653.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_65220cf269874adf69135700bd89254b/node_modules/@wirecat/cli-core/dist/store/repair.js
|
|
5643
5658
|
import { createHash as createHash2 } from "node:crypto";
|
|
5644
5659
|
var COPY_MARK = "__repair_";
|
|
5645
5660
|
var COPY_NAME = /__repair_[0-9a-f]{8}(_\d+)?$/;
|
|
@@ -5893,19 +5908,19 @@ var deleteCopy = /* @__PURE__ */ __name((database, name) => {
|
|
|
5893
5908
|
return found;
|
|
5894
5909
|
}, "deleteCopy");
|
|
5895
5910
|
|
|
5896
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5911
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.653.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_65220cf269874adf69135700bd89254b/node_modules/@wirecat/cli-core/dist/cli/store-info.js
|
|
5897
5912
|
import { existsSync as existsSync4, statSync as statSync3 } from "node:fs";
|
|
5898
5913
|
|
|
5899
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5914
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.653.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_65220cf269874adf69135700bd89254b/node_modules/@wirecat/cli-core/dist/cli/store-recover.js
|
|
5900
5915
|
import { existsSync as existsSync3 } from "node:fs";
|
|
5901
5916
|
|
|
5902
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5917
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.653.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_65220cf269874adf69135700bd89254b/node_modules/@wirecat/cli-core/dist/store/recover.js
|
|
5903
5918
|
import { execFileSync, spawn } from "node:child_process";
|
|
5904
5919
|
import { existsSync as existsSync2, readFileSync, realpathSync, renameSync as renameSync2, rmSync as rmSync2, statfsSync, statSync as statSync2, writeFileSync } from "node:fs";
|
|
5905
5920
|
import { basename, dirname, join } from "node:path";
|
|
5906
5921
|
import { Transform as Transform2 } from "node:stream";
|
|
5907
5922
|
|
|
5908
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5923
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.653.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_65220cf269874adf69135700bd89254b/node_modules/@wirecat/cli-core/dist/store/refill.js
|
|
5909
5924
|
var REFILL_MARGIN_MS = 864e5;
|
|
5910
5925
|
var TIME_KEYS = 1e12;
|
|
5911
5926
|
var integerId = `external_id GLOB '[0-9]*' AND NOT external_id GLOB '*[^0-9]*'`;
|
|
@@ -5985,7 +6000,7 @@ var forgetMail = /* @__PURE__ */ __name((database, cutoff, now) => {
|
|
|
5985
6000
|
return [...folders].map(([account, count3]) => ({ account, folders: count3 }));
|
|
5986
6001
|
}, "forgetMail");
|
|
5987
6002
|
|
|
5988
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6003
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.653.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_65220cf269874adf69135700bd89254b/node_modules/@wirecat/cli-core/dist/store/recover.js
|
|
5989
6004
|
var SQLITE3_MINIMUM = [3, 43, 0];
|
|
5990
6005
|
var STORE_PARTS = ["", "-wal", "-shm"];
|
|
5991
6006
|
var RECOVER_LOCK = ".recover-lock";
|
|
@@ -6513,7 +6528,7 @@ var recoverLocked = /* @__PURE__ */ __name(async ({ path, command, version, sqli
|
|
|
6513
6528
|
}
|
|
6514
6529
|
}, "recoverLocked");
|
|
6515
6530
|
|
|
6516
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6531
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.653.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_65220cf269874adf69135700bd89254b/node_modules/@wirecat/cli-core/dist/cli/store-recover.js
|
|
6517
6532
|
var COUNTED = [
|
|
6518
6533
|
"accounts",
|
|
6519
6534
|
"chats",
|
|
@@ -6654,7 +6669,7 @@ var storeRecoverCommand = /* @__PURE__ */ __name(({ command, version }) => {
|
|
|
6654
6669
|
for (const line of recoveryNotes(answer))
|
|
6655
6670
|
output.renderer.note(line);
|
|
6656
6671
|
});
|
|
6657
|
-
recover.addCommand(annotate(new Command("run"), { effects: LOCAL_WRITE, examples: [`${command} store recover run`] }).summary("rebuild a damaged store from every row it can read").description("copy every readable row into a new file with the sqlite3 program, rebuild the search indexes, mentions and vector index, check it, and put it in place of the store; the damaged file is kept beside it. Refuses while a WireCat timer or process has the store").action(async function() {
|
|
6672
|
+
recover.addCommand(grantsAuthority(annotate(new Command("run"), { effects: LOCAL_WRITE, examples: [`${command} store recover run`] })).summary("rebuild a damaged store from every row it can read").description("copy every readable row into a new file with the sqlite3 program, rebuild the search indexes, mentions and vector index, check it, and put it in place of the store; the damaged file is kept beside it. Refuses while a WireCat timer or process has the store").action(async function() {
|
|
6658
6673
|
const output = outputFor(this);
|
|
6659
6674
|
const answer = await storeRecoveryRun(environmentOf(this).env ?? process.env, {
|
|
6660
6675
|
command,
|
|
@@ -6669,7 +6684,7 @@ var storeRecoverCommand = /* @__PURE__ */ __name(({ command, version }) => {
|
|
|
6669
6684
|
return recover;
|
|
6670
6685
|
}, "storeRecoverCommand");
|
|
6671
6686
|
|
|
6672
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6687
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.653.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_65220cf269874adf69135700bd89254b/node_modules/@wirecat/cli-core/dist/cli/store-info.js
|
|
6673
6688
|
var pendingIfKnown = /* @__PURE__ */ __name((database) => database.prepare("SELECT 1 FROM pragma_table_info('messages') WHERE name = 'normalized_text'").get() ? pendingNormalization(database) : null, "pendingIfKnown");
|
|
6674
6689
|
var bytesOf = /* @__PURE__ */ __name((path) => existsSync4(path) ? statSync3(path).size : 0, "bytesOf");
|
|
6675
6690
|
var messageOf = /* @__PURE__ */ __name((error) => error instanceof Error ? error.message : String(error), "messageOf");
|
|
@@ -6715,7 +6730,7 @@ var storeInfoCommand = /* @__PURE__ */ __name(() => annotate(new Command("info")
|
|
|
6715
6730
|
renderAnswer(this, outputFor(this), itemOf(answer));
|
|
6716
6731
|
}), "storeInfoCommand");
|
|
6717
6732
|
|
|
6718
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6733
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.653.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_65220cf269874adf69135700bd89254b/node_modules/@wirecat/cli-core/dist/cli/messenger/password.js
|
|
6719
6734
|
var ENCRYPT_OPTION = [
|
|
6720
6735
|
"--encrypt",
|
|
6721
6736
|
"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"
|
|
@@ -6734,7 +6749,7 @@ var passwordOf = /* @__PURE__ */ __name(async (command, { twice }) => {
|
|
|
6734
6749
|
return password;
|
|
6735
6750
|
}, "passwordOf");
|
|
6736
6751
|
|
|
6737
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6752
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.653.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_65220cf269874adf69135700bd89254b/node_modules/@wirecat/cli-core/dist/replies/rules.js
|
|
6738
6753
|
import { existsSync as existsSync5, readFileSync as readFileSync2 } from "node:fs";
|
|
6739
6754
|
import { join as join2 } from "node:path";
|
|
6740
6755
|
var REPLY_ACTIONS = ["reply", "task"];
|
|
@@ -6905,7 +6920,7 @@ var problem = /* @__PURE__ */ __name((issue) => {
|
|
|
6905
6920
|
}, "problem");
|
|
6906
6921
|
var broken = /* @__PURE__ */ __name((path, why) => new CliError("configuration_error", `the reply rules ${path} cannot be read (${why}) \u2014 fix the file`), "broken");
|
|
6907
6922
|
|
|
6908
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6923
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.653.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_65220cf269874adf69135700bd89254b/node_modules/@wirecat/cli-core/dist/replies/state.js
|
|
6909
6924
|
import { existsSync as existsSync6, readFileSync as readFileSync3 } from "node:fs";
|
|
6910
6925
|
import { join as join3 } from "node:path";
|
|
6911
6926
|
var ANSWERED_KEPT = 1e3;
|
|
@@ -6958,7 +6973,7 @@ var recordReply = /* @__PURE__ */ __name((state, rule2, message, now) => {
|
|
|
6958
6973
|
}, "recordReply");
|
|
6959
6974
|
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");
|
|
6960
6975
|
|
|
6961
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6976
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.653.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_65220cf269874adf69135700bd89254b/node_modules/@wirecat/cli-core/dist/replies/decide.js
|
|
6962
6977
|
var skip = /* @__PURE__ */ __name((why) => ({ skip: why }), "skip");
|
|
6963
6978
|
var decide = /* @__PURE__ */ __name((rule2, incoming, state, now) => {
|
|
6964
6979
|
const { message, chat, owner, sender } = incoming;
|
|
@@ -7064,10 +7079,10 @@ var filled = /* @__PURE__ */ __name((template2, senderName) => {
|
|
|
7064
7079
|
return template2.replaceAll("{firstName}", name.split(/\s+/)[0] ?? name).replaceAll("{name}", name);
|
|
7065
7080
|
}, "filled");
|
|
7066
7081
|
|
|
7067
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7082
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.653.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_65220cf269874adf69135700bd89254b/node_modules/@wirecat/cli-core/dist/replies/template.js
|
|
7068
7083
|
var import_liquidjs2 = __toESM(require_liquid_node(), 1);
|
|
7069
7084
|
|
|
7070
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7085
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.653.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_65220cf269874adf69135700bd89254b/node_modules/@wirecat/cli-core/dist/render/liquid.js
|
|
7071
7086
|
var import_liquidjs = __toESM(require_liquid_node(), 1);
|
|
7072
7087
|
var safeLiquid = /* @__PURE__ */ __name((limits) => {
|
|
7073
7088
|
const engine = new import_liquidjs.Liquid({
|
|
@@ -7094,7 +7109,7 @@ var safeLiquid = /* @__PURE__ */ __name((limits) => {
|
|
|
7094
7109
|
return engine;
|
|
7095
7110
|
}, "safeLiquid");
|
|
7096
7111
|
|
|
7097
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7112
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.653.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_65220cf269874adf69135700bd89254b/node_modules/@wirecat/cli-core/dist/replies/template.js
|
|
7098
7113
|
var TEMPLATE_LIMITS = {
|
|
7099
7114
|
parse: 32768,
|
|
7100
7115
|
renders: 2e3,
|
|
@@ -7233,7 +7248,7 @@ var renderReplyTemplate = /* @__PURE__ */ __name(async (reply, input) => {
|
|
|
7233
7248
|
}
|
|
7234
7249
|
}, "renderReplyTemplate");
|
|
7235
7250
|
|
|
7236
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7251
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.653.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_65220cf269874adf69135700bd89254b/node_modules/@wirecat/cli-core/dist/replies/dry-run.js
|
|
7237
7252
|
var DRY_RUN_DAYS = 7;
|
|
7238
7253
|
var PAGE = 500;
|
|
7239
7254
|
var dryRun = /* @__PURE__ */ __name(async (store, account, rules, { since, until = Date.now(), only, audience, render }) => {
|
|
@@ -7347,7 +7362,178 @@ var storedSince = /* @__PURE__ */ __name(async (store, account, chat, since) =>
|
|
|
7347
7362
|
}
|
|
7348
7363
|
}, "storedSince");
|
|
7349
7364
|
|
|
7350
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7365
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.653.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_65220cf269874adf69135700bd89254b/node_modules/@wirecat/cli-core/dist/models/ai.js
|
|
7366
|
+
var AI_PROVIDERS = ["anthropic", "openai", "ollama"];
|
|
7367
|
+
var DEFAULT_BASE_URL = {
|
|
7368
|
+
anthropic: "https://api.anthropic.com",
|
|
7369
|
+
openai: "https://api.openai.com/v1",
|
|
7370
|
+
ollama: "http://127.0.0.1:11434/v1"
|
|
7371
|
+
};
|
|
7372
|
+
var OFFICIAL = {
|
|
7373
|
+
"https://api.openai.com": "openai",
|
|
7374
|
+
"https://api.anthropic.com": "anthropic"
|
|
7375
|
+
};
|
|
7376
|
+
var SECTION = "ai";
|
|
7377
|
+
var aiAddressAllowed = modelAddressAllowed;
|
|
7378
|
+
var consentShape = strictObject({
|
|
7379
|
+
origin: string(),
|
|
7380
|
+
model: string(),
|
|
7381
|
+
at: string()
|
|
7382
|
+
});
|
|
7383
|
+
var settingShape = strictObject({
|
|
7384
|
+
provider: picklist(AI_PROVIDERS),
|
|
7385
|
+
model: pipe(string(), trim(), minLength(1), maxLength(200)),
|
|
7386
|
+
base_url: optional(pipe(string(), check(aiAddressAllowed, "use https, or http only on this computer"))),
|
|
7387
|
+
images: optional(consentShape)
|
|
7388
|
+
});
|
|
7389
|
+
var aiSettingPath = /* @__PURE__ */ __name((env) => sharedConfigPath(storePath(env), env), "aiSettingPath");
|
|
7390
|
+
var readAiSetting = /* @__PURE__ */ __name((path) => {
|
|
7391
|
+
const section = readSharedSection(path, SECTION);
|
|
7392
|
+
if (section === void 0)
|
|
7393
|
+
return void 0;
|
|
7394
|
+
const checked = safeParse(settingShape, section);
|
|
7395
|
+
if (!checked.success)
|
|
7396
|
+
throw new CliError("configuration_error", `${path}: ai.${getDotPath(checked.issues[0]) ?? "setting"} is invalid`, {
|
|
7397
|
+
reason: "ai.setting-invalid"
|
|
7398
|
+
});
|
|
7399
|
+
return checked.output;
|
|
7400
|
+
}, "readAiSetting");
|
|
7401
|
+
var writeAiSetting = /* @__PURE__ */ __name((path, setting) => writeSharedSection(path, SECTION, setting), "writeAiSetting");
|
|
7402
|
+
var aiSettingOf = /* @__PURE__ */ __name((given) => {
|
|
7403
|
+
const draft = {
|
|
7404
|
+
provider: given.provider,
|
|
7405
|
+
model: given.model,
|
|
7406
|
+
...given.baseUrl?.trim() ? { base_url: given.baseUrl.trim().replace(/\/+$/, "") } : {}
|
|
7407
|
+
};
|
|
7408
|
+
const checked = safeParse(settingShape, draft);
|
|
7409
|
+
if (!checked.success) {
|
|
7410
|
+
const field = getDotPath(checked.issues[0]);
|
|
7411
|
+
throw new CliError("validation_error", field === "provider" ? `the provider is one of ${AI_PROVIDERS.join(", ")}` : field === "base_url" ? "this address is not allowed: use https, or http only on this computer" : "name the model, 1 to 200 characters", { reason: field === "base_url" ? "model.address-refused" : "ai.setting-invalid" });
|
|
7412
|
+
}
|
|
7413
|
+
if (checked.output.provider === "ollama" && !onThisComputer(aiBaseUrl(checked.output)))
|
|
7414
|
+
throw new CliError("validation_error", "Ollama is read only on this computer", { reason: "model.address-refused" });
|
|
7415
|
+
return given.allowImages ? {
|
|
7416
|
+
...checked.output,
|
|
7417
|
+
images: { origin: aiOrigin(checked.output), model: checked.output.model, at: (/* @__PURE__ */ new Date()).toISOString() }
|
|
7418
|
+
} : checked.output;
|
|
7419
|
+
}, "aiSettingOf");
|
|
7420
|
+
var aiBaseUrl = /* @__PURE__ */ __name((setting) => setting.base_url ?? DEFAULT_BASE_URL[setting.provider], "aiBaseUrl");
|
|
7421
|
+
var aiOrigin = /* @__PURE__ */ __name((setting) => new URL(aiBaseUrl(setting)).origin, "aiOrigin");
|
|
7422
|
+
var aiTarget = /* @__PURE__ */ __name((setting) => ({
|
|
7423
|
+
provider: setting.provider === "anthropic" ? "anthropic" : "openai",
|
|
7424
|
+
model: setting.model,
|
|
7425
|
+
baseUrl: aiBaseUrl(setting)
|
|
7426
|
+
}), "aiTarget");
|
|
7427
|
+
var aiImagesAllowed = /* @__PURE__ */ __name((setting) => setting.images?.origin === aiOrigin(setting) && setting.images.model === setting.model, "aiImagesAllowed");
|
|
7428
|
+
var aiKeys = /* @__PURE__ */ __name((app, env, keyring) => {
|
|
7429
|
+
const where = { appName: "WireCat", prefix: "WIRECAT", env };
|
|
7430
|
+
const credentials = new Credentials({
|
|
7431
|
+
configDir: resolvePaths(where).config,
|
|
7432
|
+
service: "WireCat",
|
|
7433
|
+
// A tool run with its own folders moved (MEMO_CONFIG_DIR…) is a test or a sandbox, not the owner.
|
|
7434
|
+
isolated: isMovedRun(where) || isMovedRun({ appName: app.appName, prefix: app.envPrefix, env }),
|
|
7435
|
+
env,
|
|
7436
|
+
...keyring ? { keyring } : {},
|
|
7437
|
+
warn: /* @__PURE__ */ __name((message) => process.stderr.write(`${message}
|
|
7438
|
+
`), "warn")
|
|
7439
|
+
});
|
|
7440
|
+
const account = /* @__PURE__ */ __name((origin) => `ai:${origin}`, "account");
|
|
7441
|
+
return {
|
|
7442
|
+
read: /* @__PURE__ */ __name((origin) => {
|
|
7443
|
+
const stored = credentials.read(account(origin));
|
|
7444
|
+
if (stored)
|
|
7445
|
+
return { key: stored.secret, source: stored.source };
|
|
7446
|
+
const official = OFFICIAL[origin];
|
|
7447
|
+
const legacy = official ?? (origin.startsWith("https://") ? endpointKeyName(origin) : void 0);
|
|
7448
|
+
const found = legacy === void 0 ? void 0 : embeddingKeys(app, env, keyring).read(legacy);
|
|
7449
|
+
return found ? { key: found.key, source: found.source === "env" ? "environment" : found.source } : void 0;
|
|
7450
|
+
}, "read"),
|
|
7451
|
+
write: /* @__PURE__ */ __name((origin, key) => credentials.write(account(origin), key, { signIn: true }), "write"),
|
|
7452
|
+
remove: /* @__PURE__ */ __name((origin) => credentials.remove(account(origin)), "remove")
|
|
7453
|
+
};
|
|
7454
|
+
}, "aiKeys");
|
|
7455
|
+
var aiNeedsKey = /* @__PURE__ */ __name((setting) => aiLeavesComputer(setting), "aiNeedsKey");
|
|
7456
|
+
var aiTakesKey = /* @__PURE__ */ __name((setting) => setting.provider !== "ollama", "aiTakesKey");
|
|
7457
|
+
var keyFor = /* @__PURE__ */ __name((setting, deps) => aiTakesKey(setting) ? aiKeys(deps.app, deps.env, deps.keyring).read(aiOrigin(setting))?.key : void 0, "keyFor");
|
|
7458
|
+
var gatewayFor = /* @__PURE__ */ __name((setting, deps, key) => modelGateway({
|
|
7459
|
+
resolve: /* @__PURE__ */ __name(() => aiTarget(setting), "resolve"),
|
|
7460
|
+
consent: /* @__PURE__ */ __name(() => true, "consent"),
|
|
7461
|
+
key: /* @__PURE__ */ __name(() => key, "key"),
|
|
7462
|
+
env: deps.env,
|
|
7463
|
+
...deps.fetch ? { fetch: deps.fetch } : {},
|
|
7464
|
+
...deps.signal ? { signal: deps.signal } : {}
|
|
7465
|
+
}), "gatewayFor");
|
|
7466
|
+
var aiLeavesComputer = /* @__PURE__ */ __name((setting) => !onThisComputer(aiBaseUrl(setting)), "aiLeavesComputer");
|
|
7467
|
+
var sharedModel = /* @__PURE__ */ __name((deps) => {
|
|
7468
|
+
const setting = readAiSetting(aiSettingPath(deps.env));
|
|
7469
|
+
if (!setting)
|
|
7470
|
+
return void 0;
|
|
7471
|
+
return { target: { ...aiTarget(setting), baseUrl: aiBaseUrl(setting) }, key: keyFor(setting, deps), setting };
|
|
7472
|
+
}, "sharedModel");
|
|
7473
|
+
var reasonOf = /* @__PURE__ */ __name((error) => {
|
|
7474
|
+
if (!(error instanceof CliError))
|
|
7475
|
+
return "ai.failed";
|
|
7476
|
+
if (error.code === "rate_limited")
|
|
7477
|
+
return "ai.rate-limited";
|
|
7478
|
+
const { reason, status } = error.details;
|
|
7479
|
+
if (reason === "model.key-rejected")
|
|
7480
|
+
return "ai.key-rejected";
|
|
7481
|
+
if (reason === "model.unreachable")
|
|
7482
|
+
return "ai.unreachable";
|
|
7483
|
+
if (reason === "model.empty-answer")
|
|
7484
|
+
return "ai.empty-answer";
|
|
7485
|
+
if (status === 402)
|
|
7486
|
+
return "ai.no-credit";
|
|
7487
|
+
if (status === 404)
|
|
7488
|
+
return "ai.model-unknown";
|
|
7489
|
+
if (typeof status === "number" && status >= 500)
|
|
7490
|
+
return "ai.provider-error";
|
|
7491
|
+
return "ai.failed";
|
|
7492
|
+
}, "reasonOf");
|
|
7493
|
+
var checkAi = /* @__PURE__ */ __name(async (deps) => {
|
|
7494
|
+
const setting = readAiSetting(aiSettingPath(deps.env));
|
|
7495
|
+
if (!setting)
|
|
7496
|
+
return { ok: false, reason: "ai.not-set", ms: null };
|
|
7497
|
+
const key = keyFor(setting, deps);
|
|
7498
|
+
if (aiNeedsKey(setting) && !key)
|
|
7499
|
+
return { ok: false, reason: "ai.key-missing", ms: null };
|
|
7500
|
+
const started = Date.now();
|
|
7501
|
+
try {
|
|
7502
|
+
await gatewayFor(setting, deps, key).complete({
|
|
7503
|
+
purpose: "check",
|
|
7504
|
+
system: "Reply with the word OK.",
|
|
7505
|
+
prompt: "OK?",
|
|
7506
|
+
// Reasoning models spend tokens before they answer; too low a cap reads as a broken setup.
|
|
7507
|
+
maxTokens: 2048
|
|
7508
|
+
});
|
|
7509
|
+
return { ok: true, reason: "ai.ok", ms: Date.now() - started };
|
|
7510
|
+
} catch (error) {
|
|
7511
|
+
return { ok: false, reason: reasonOf(error), ms: null };
|
|
7512
|
+
}
|
|
7513
|
+
}, "checkAi");
|
|
7514
|
+
|
|
7515
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.653.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_65220cf269874adf69135700bd89254b/node_modules/@wirecat/cli-core/dist/models/purpose.js
|
|
7516
|
+
var HOSTED = {
|
|
7517
|
+
openai: "https://api.openai.com/v1",
|
|
7518
|
+
anthropic: "https://api.anthropic.com"
|
|
7519
|
+
};
|
|
7520
|
+
var purposeModel = /* @__PURE__ */ __name((settings, purpose, deps) => {
|
|
7521
|
+
const configured = modelTarget(settings, purpose);
|
|
7522
|
+
if (configured) {
|
|
7523
|
+
const baseUrl = configured.baseUrl ?? HOSTED[configured.provider] ?? "";
|
|
7524
|
+
return {
|
|
7525
|
+
target: { ...configured, baseUrl },
|
|
7526
|
+
key: /* @__PURE__ */ __name(() => embeddingKeys(deps.app, deps.env, deps.keyring).read(configured.baseUrl === void 0 ? configured.provider : endpointKeyName(configured.baseUrl))?.key, "key")
|
|
7527
|
+
};
|
|
7528
|
+
}
|
|
7529
|
+
const provider = settings.models?.[purpose]?.provider ?? settings.models?.default?.provider;
|
|
7530
|
+
if (provider === "off")
|
|
7531
|
+
return void 0;
|
|
7532
|
+
const shared = sharedModel(deps);
|
|
7533
|
+
return shared ? { target: shared.target, key: /* @__PURE__ */ __name(() => shared.key, "key"), shared: shared.setting } : void 0;
|
|
7534
|
+
}, "purposeModel");
|
|
7535
|
+
|
|
7536
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.653.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_65220cf269874adf69135700bd89254b/node_modules/@wirecat/cli-core/dist/replies/consents.js
|
|
7351
7537
|
import { existsSync as existsSync7, readFileSync as readFileSync4 } from "node:fs";
|
|
7352
7538
|
import { join as join4 } from "node:path";
|
|
7353
7539
|
var shape = strictObject({
|
|
@@ -7372,19 +7558,21 @@ var mayModelReply = /* @__PURE__ */ __name((path, provider, chat) => {
|
|
|
7372
7558
|
return consent.provider === provider && !consent.deniedChats.includes(chat);
|
|
7373
7559
|
}, "mayModelReply");
|
|
7374
7560
|
|
|
7375
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7561
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.653.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_65220cf269874adf69135700bd89254b/node_modules/@wirecat/cli-core/dist/replies/rendering.js
|
|
7376
7562
|
var replyRenderer = /* @__PURE__ */ __name((app, profile, settings, env, warn, options = {
|
|
7377
7563
|
ai: true
|
|
7378
7564
|
}) => async (rule2, message, chat, now) => {
|
|
7565
|
+
const deps = { app, env, keyring: options.keyring };
|
|
7379
7566
|
let called;
|
|
7380
7567
|
const gateway = modelGateway({
|
|
7381
7568
|
signal: options.signal,
|
|
7569
|
+
env,
|
|
7382
7570
|
resolve: /* @__PURE__ */ __name((purpose) => {
|
|
7383
|
-
called =
|
|
7384
|
-
return called;
|
|
7571
|
+
called = purposeModel(settings(), purpose, deps);
|
|
7572
|
+
return called?.target;
|
|
7385
7573
|
}, "resolve"),
|
|
7386
7574
|
consent: /* @__PURE__ */ __name((_request, target) => mayModelReply(replyConsentPathFor(app, profile, env), replyModelIdentity(target.provider, target.baseUrl ?? ""), message.chatId), "consent"),
|
|
7387
|
-
key: /* @__PURE__ */ __name((
|
|
7575
|
+
key: /* @__PURE__ */ __name(() => called?.key(), "key")
|
|
7388
7576
|
});
|
|
7389
7577
|
if (options.signal?.aborted)
|
|
7390
7578
|
throw new CliError("cancelled", "reply rendering cancelled");
|
|
@@ -7406,9 +7594,8 @@ var replyRenderer = /* @__PURE__ */ __name((app, profile, settings, env, warn, o
|
|
|
7406
7594
|
});
|
|
7407
7595
|
if (options.signal?.aborted)
|
|
7408
7596
|
throw new CliError("cancelled", "reply rendering cancelled");
|
|
7409
|
-
const current =
|
|
7410
|
-
|
|
7411
|
-
if (!called || JSON.stringify(current) !== JSON.stringify(called) || !mayModelReply(replyConsentPathFor(app, profile, env), replyModelIdentity(called.provider, baseUrl), message.chatId)) {
|
|
7597
|
+
const current = purposeModel(settings(), "replies", deps)?.target;
|
|
7598
|
+
if (!called || JSON.stringify(current) !== JSON.stringify(called.target) || !mayModelReply(replyConsentPathFor(app, profile, env), replyModelIdentity(called.target.provider, called.target.baseUrl), message.chatId)) {
|
|
7412
7599
|
throw new CliError("permission_error", "reply model consent or configuration changed during rendering");
|
|
7413
7600
|
}
|
|
7414
7601
|
return result3;
|
|
@@ -7419,7 +7606,7 @@ var replyRenderer = /* @__PURE__ */ __name((app, profile, settings, env, warn, o
|
|
|
7419
7606
|
return result2;
|
|
7420
7607
|
}, "replyRenderer");
|
|
7421
7608
|
|
|
7422
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7609
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.653.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_65220cf269874adf69135700bd89254b/node_modules/@wirecat/cli-core/dist/replies/serve.js
|
|
7423
7610
|
var NOT_ALLOWED = "replies.send is not allow";
|
|
7424
7611
|
var NO_RULES = "no rules";
|
|
7425
7612
|
var ONLY_TASK = "opened a task, sent nothing";
|
|
@@ -7512,7 +7699,7 @@ var replyTo = /* @__PURE__ */ __name(async (deps, message) => {
|
|
|
7512
7699
|
return { skip: why };
|
|
7513
7700
|
}, "replyTo");
|
|
7514
7701
|
|
|
7515
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7702
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.653.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_65220cf269874adf69135700bd89254b/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-catch-up.js
|
|
7516
7703
|
var START_SYNC_DELAY_MS = 3e4;
|
|
7517
7704
|
var START_SYNC_BUDGET_MS = 5 * 6e4;
|
|
7518
7705
|
var START_SYNC_WINDOW_MS = 7 * 864e5;
|
|
@@ -7589,7 +7776,7 @@ var startSync = /* @__PURE__ */ __name(({ chats, newestHeld, fetch, note, warn,
|
|
|
7589
7776
|
};
|
|
7590
7777
|
}, "startSync");
|
|
7591
7778
|
|
|
7592
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7779
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.653.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_65220cf269874adf69135700bd89254b/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-members.js
|
|
7593
7780
|
var FIRST_FETCH_MS = 6e4;
|
|
7594
7781
|
var DAY_MS = 864e5;
|
|
7595
7782
|
var memberFetches = /* @__PURE__ */ __name(({ withStore, fetch, warn, firstMs = FIRST_FETCH_MS, everyMs = DAY_MS }) => {
|
|
@@ -7643,7 +7830,7 @@ var memberFetches = /* @__PURE__ */ __name(({ withStore, fetch, warn, firstMs =
|
|
|
7643
7830
|
};
|
|
7644
7831
|
}, "memberFetches");
|
|
7645
7832
|
|
|
7646
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7833
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.653.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_65220cf269874adf69135700bd89254b/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-notice.js
|
|
7647
7834
|
var record2 = /* @__PURE__ */ __name((context, app, severity, attributes) => recordLogFor(context.streams.diagnostic, app, { command: currentRun().command || "serve" })[severity](attributes), "record");
|
|
7648
7835
|
var noticeFor = /* @__PURE__ */ __name((context, app, severity = "warn") => ({ text, ...attributes }) => {
|
|
7649
7836
|
if (context.format === "pretty") {
|
|
@@ -7676,7 +7863,7 @@ var recordDiagnostics = /* @__PURE__ */ __name((context, app) => {
|
|
|
7676
7863
|
return context;
|
|
7677
7864
|
}, "recordDiagnostics");
|
|
7678
7865
|
|
|
7679
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7866
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.653.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_65220cf269874adf69135700bd89254b/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-outdated.js
|
|
7680
7867
|
import { existsSync as existsSync8, readFileSync as readFileSync5, realpathSync as realpathSync2 } from "node:fs";
|
|
7681
7868
|
import { dirname as dirname2, join as join5 } from "node:path";
|
|
7682
7869
|
var OUTDATED_CHECK_MS = 6e4;
|
|
@@ -7762,7 +7949,7 @@ var watchOutdated = /* @__PURE__ */ __name(({ check: check2, onOutdated, everyMs
|
|
|
7762
7949
|
};
|
|
7763
7950
|
}, "watchOutdated");
|
|
7764
7951
|
|
|
7765
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7952
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.653.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_65220cf269874adf69135700bd89254b/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-stems.js
|
|
7766
7953
|
var STEMS_EVERY_MS = 3e4;
|
|
7767
7954
|
var STEMS_SLICE_MS = 2e3;
|
|
7768
7955
|
var stemFills = /* @__PURE__ */ __name(({ withStore, warn, everyMs = STEMS_EVERY_MS, sliceMs = STEMS_SLICE_MS }) => {
|
|
@@ -7802,7 +7989,7 @@ var stemFills = /* @__PURE__ */ __name(({ withStore, warn, everyMs = STEMS_EVERY
|
|
|
7802
7989
|
};
|
|
7803
7990
|
}, "stemFills");
|
|
7804
7991
|
|
|
7805
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7992
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.653.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_65220cf269874adf69135700bd89254b/node_modules/@wirecat/cli-core/dist/cli/messenger/message-items.js
|
|
7806
7993
|
var defined = /* @__PURE__ */ __name((value) => Object.fromEntries(Object.entries(value).filter(([, one]) => one !== void 0)), "defined");
|
|
7807
7994
|
var attachmentItem = /* @__PURE__ */ __name((attachment) => defined({
|
|
7808
7995
|
kind: attachment.kind,
|
|
@@ -7814,6 +8001,7 @@ var attachmentItem = /* @__PURE__ */ __name((attachment) => defined({
|
|
|
7814
8001
|
width: attachment.width,
|
|
7815
8002
|
height: attachment.height,
|
|
7816
8003
|
duration: attachment.duration,
|
|
8004
|
+
local_path: attachment.localPath,
|
|
7817
8005
|
contact: attachment.contact && defined({
|
|
7818
8006
|
name: attachment.contact.name,
|
|
7819
8007
|
first_name: attachment.contact.firstName,
|
|
@@ -7897,7 +8085,7 @@ var viewOf = /* @__PURE__ */ __name((context, messenger) => ({
|
|
|
7897
8085
|
locale: messenger.app.locale
|
|
7898
8086
|
}), "viewOf");
|
|
7899
8087
|
|
|
7900
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
8088
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.653.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_65220cf269874adf69135700bd89254b/node_modules/@wirecat/cli-core/dist/cli/messenger/watch-answers.js
|
|
7901
8089
|
var observed = /* @__PURE__ */ __name((value) => ({
|
|
7902
8090
|
value: value.value,
|
|
7903
8091
|
observed_at: value.observedAt,
|
|
@@ -7964,7 +8152,7 @@ var watchEventItem = /* @__PURE__ */ __name((value, account) => {
|
|
|
7964
8152
|
}
|
|
7965
8153
|
}, "watchEventItem");
|
|
7966
8154
|
|
|
7967
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
8155
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.653.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_65220cf269874adf69135700bd89254b/node_modules/@wirecat/cli-core/dist/cli/messenger/watch-command.js
|
|
7968
8156
|
var watchCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("watch"), {
|
|
7969
8157
|
output: { entity: "watch_item" },
|
|
7970
8158
|
effects: REMOTE_READ,
|
|
@@ -8119,7 +8307,7 @@ var describe = /* @__PURE__ */ __name((event, render) => {
|
|
|
8119
8307
|
}
|
|
8120
8308
|
}, "describe");
|
|
8121
8309
|
|
|
8122
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
8310
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.653.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_65220cf269874adf69135700bd89254b/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-command.js
|
|
8123
8311
|
var serveCommand = /* @__PURE__ */ __name((messenger) => {
|
|
8124
8312
|
const command = annotate(new Command("serve"), {
|
|
8125
8313
|
output: { entity: "serve_summary" },
|
|
@@ -8402,7 +8590,7 @@ var tasking = /* @__PURE__ */ __name((context, warn) => {
|
|
|
8402
8590
|
};
|
|
8403
8591
|
}, "tasking");
|
|
8404
8592
|
|
|
8405
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
8593
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.653.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_65220cf269874adf69135700bd89254b/node_modules/@wirecat/cli-core/dist/cli/messenger/store-tables-command.js
|
|
8406
8594
|
import { existsSync as existsSync9 } from "node:fs";
|
|
8407
8595
|
var PATH = "store tables list";
|
|
8408
8596
|
var STORE_TABLES_QUERY = {
|
|
@@ -8419,14 +8607,14 @@ var filterOf = /* @__PURE__ */ __name((words) => {
|
|
|
8419
8607
|
const kind = terms.get("kind");
|
|
8420
8608
|
return { ...name === void 0 ? {} : { name }, ...kind === void 0 ? {} : { kind } };
|
|
8421
8609
|
}, "filterOf");
|
|
8422
|
-
var storeTablesCommand = /* @__PURE__ */ __name((
|
|
8423
|
-
const tables = new Command("tables").description("the tables of the local
|
|
8610
|
+
var storeTablesCommand = /* @__PURE__ */ __name((owner) => {
|
|
8611
|
+
const tables = new Command("tables").description("the tables of the local store");
|
|
8424
8612
|
withQuery(annotate(tables.command("list"), {
|
|
8425
8613
|
effects: LOCAL_READ,
|
|
8426
8614
|
examples: [
|
|
8427
|
-
`${
|
|
8428
|
-
`${
|
|
8429
|
-
`${
|
|
8615
|
+
`${owner.app.command} store tables list`,
|
|
8616
|
+
`${owner.app.command} store tables list kind:data`,
|
|
8617
|
+
`${owner.app.command} store tables list --full --json`
|
|
8430
8618
|
]
|
|
8431
8619
|
}), STORE_TABLES_QUERY).summary("every table of the local archive, with its kind and row count").description("every table of the local archive: its kind (data, search index, part of a search index, internal) and its rows, a search index's rows not counted; --full adds each table's size on disk, which reads the whole file (about ten seconds for 3 GB); changes nothing").action(async function(words) {
|
|
8432
8620
|
const filter = filterOf(words);
|
|
@@ -8445,7 +8633,7 @@ var storeTablesCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
8445
8633
|
return tables;
|
|
8446
8634
|
}, "storeTablesCommand");
|
|
8447
8635
|
|
|
8448
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
8636
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.653.0_@wirecat+cli-base@0.99.0_commander@15.0.0_esbuild@0.28.2_type_65220cf269874adf69135700bd89254b/node_modules/@wirecat/cli-core/dist/cli/messenger/store-maintenance-command.js
|
|
8449
8637
|
var SEARCH_INDEXES = ["messages_fts", "chats_fts", "identities_fts"];
|
|
8450
8638
|
var WORD_INDEX = "message_words";
|
|
8451
8639
|
var schemaOf = /* @__PURE__ */ __name((database) => {
|
|
@@ -8530,27 +8718,52 @@ var storeSummary = /* @__PURE__ */ __name(async (env, { deep = false, command, v
|
|
|
8530
8718
|
}
|
|
8531
8719
|
}, "storeSummary");
|
|
8532
8720
|
var result = /* @__PURE__ */ __name((command, value, next = []) => renderAnswer(command, outputFor(command), itemOf(snakeKeys(value), { next })), "result");
|
|
8533
|
-
var
|
|
8721
|
+
var chatty = /* @__PURE__ */ __name((owner) => owner.provider !== void 0, "chatty");
|
|
8722
|
+
var archive = /* @__PURE__ */ __name((owner) => chatty(owner) ? "local archive" : "local store", "archive");
|
|
8723
|
+
var createdBy = /* @__PURE__ */ __name((owner) => chatty(owner) ? `the first \`${owner.app.command}\` command that reads a chat creates it` : `the first \`${owner.app.command}\` command that saves anything creates it`, "createdBy");
|
|
8724
|
+
var storeMaintenanceCommands = /* @__PURE__ */ __name((owner) => [
|
|
8534
8725
|
storeInfoCommand(),
|
|
8535
|
-
checkCommand(
|
|
8536
|
-
migrateCommand(
|
|
8537
|
-
reindexCommand(
|
|
8726
|
+
checkCommand(owner),
|
|
8727
|
+
migrateCommand(owner),
|
|
8728
|
+
reindexCommand(owner),
|
|
8538
8729
|
backupCommand(),
|
|
8539
|
-
restoreCommand(
|
|
8730
|
+
restoreCommand(owner),
|
|
8540
8731
|
decryptCommand(),
|
|
8541
|
-
repairCommand(
|
|
8542
|
-
resetCommand(
|
|
8732
|
+
repairCommand(owner),
|
|
8733
|
+
resetCommand(owner),
|
|
8543
8734
|
copiesCommand(),
|
|
8544
|
-
storeTablesCommand(
|
|
8545
|
-
storeRecoverCommand({ command:
|
|
8735
|
+
storeTablesCommand(owner),
|
|
8736
|
+
storeRecoverCommand({ command: owner.app.command, version: owner.app.version })
|
|
8546
8737
|
], "storeMaintenanceCommands");
|
|
8547
|
-
var
|
|
8548
|
-
|
|
8738
|
+
var EXAMPLES = {
|
|
8739
|
+
backup: "./backup.db",
|
|
8740
|
+
check: "",
|
|
8741
|
+
"copies delete": "messages_copy_1",
|
|
8742
|
+
decrypt: "./backup.enc --output ./restored.db",
|
|
8743
|
+
info: "",
|
|
8744
|
+
migrate: "",
|
|
8745
|
+
rebuild: "",
|
|
8746
|
+
repair: "--dry-run",
|
|
8747
|
+
reset: "",
|
|
8748
|
+
restore: "./backup.db"
|
|
8749
|
+
};
|
|
8750
|
+
var addStoreMaintenanceCommands = /* @__PURE__ */ __name((store, owner, profile) => {
|
|
8751
|
+
for (const command of storeMaintenanceCommands(owner))
|
|
8752
|
+
store.addCommand(command);
|
|
8753
|
+
for (const [path, args] of Object.entries(EXAMPLES)) {
|
|
8754
|
+
const command = commandAt(store, path);
|
|
8755
|
+
if (command)
|
|
8756
|
+
annotate(command, { examples: [`${owner.app.command} ${profile} store ${path} ${args}`.trimEnd()] });
|
|
8757
|
+
}
|
|
8758
|
+
return store;
|
|
8759
|
+
}, "addStoreMaintenanceCommands");
|
|
8760
|
+
var refuseWhileServing = /* @__PURE__ */ __name((command, owner) => {
|
|
8761
|
+
const serving = servingProfiles(owner.app, environmentOf(command).env ?? process.env);
|
|
8549
8762
|
if (serving.length > 0) {
|
|
8550
|
-
throw new CliError("validation_error", `${
|
|
8763
|
+
throw new CliError("validation_error", `${owner.app.command} serve is running for ${serving.join(", ")} \u2014 ${serving.map((profile) => `\`${owner.app.command} ${profile} server stop\``).join(", ")} first`);
|
|
8551
8764
|
}
|
|
8552
8765
|
}, "refuseWhileServing");
|
|
8553
|
-
var repairCommand = /* @__PURE__ */ __name((
|
|
8766
|
+
var repairCommand = /* @__PURE__ */ __name((owner) => annotate(new Command("repair"), { output: { entity: "store_repair" }, effects: LOCAL_WRITE }).summary("repair table shapes while keeping the old tables").description("bring every table to this build's shape, deleting nothing: a table of the wrong shape is kept as a copy beside a new one").option("--dry-run", "say what it would do, and change nothing").action(async function() {
|
|
8554
8767
|
const { renderer, format } = outputFor(this);
|
|
8555
8768
|
const { dryRun: dryRun2 } = this.opts();
|
|
8556
8769
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
@@ -8559,13 +8772,13 @@ var repairCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("
|
|
|
8559
8772
|
return;
|
|
8560
8773
|
}
|
|
8561
8774
|
if (!dryRun2)
|
|
8562
|
-
refuseWhileServing(this,
|
|
8775
|
+
refuseWhileServing(this, owner);
|
|
8563
8776
|
const fresh = await openCache(":memory:");
|
|
8564
8777
|
try {
|
|
8565
8778
|
const report = await reading(path, (database) => repairStore(database, fresh, { dryRun: dryRun2 === true }));
|
|
8566
8779
|
result(this, { path, ...report });
|
|
8567
8780
|
if (format === "pretty")
|
|
8568
|
-
for (const note of notesOf(report,
|
|
8781
|
+
for (const note of notesOf(report, owner.app.command))
|
|
8569
8782
|
renderer.note(note);
|
|
8570
8783
|
} finally {
|
|
8571
8784
|
fresh.close();
|
|
@@ -8599,7 +8812,7 @@ var copiesCommand = /* @__PURE__ */ __name(() => new Command("copies").descripti
|
|
|
8599
8812
|
const deleted = await reading(path, (database) => deleteCopy(database, name));
|
|
8600
8813
|
result(this, { path, deleted });
|
|
8601
8814
|
})), "copiesCommand");
|
|
8602
|
-
var checkCommand = /* @__PURE__ */ __name((
|
|
8815
|
+
var checkCommand = /* @__PURE__ */ __name((owner) => annotate(new Command("check"), { output: { entity: "store_check" }, effects: LOCAL_READ }).summary(`check the ${archive(owner)} for problems`).description(`whether the store is healthy \u2014 integrity, search indexes, disk${chatty(owner) ? ", and which chats are behind" : ""}`).action(async function() {
|
|
8603
8816
|
const { renderer } = outputFor(this);
|
|
8604
8817
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8605
8818
|
if (!existsSync10(path)) {
|
|
@@ -8613,7 +8826,7 @@ var checkCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("c
|
|
|
8613
8826
|
result(this, { path, exists: true, ok: false, opens: false, error: messageOf2(error) });
|
|
8614
8827
|
return;
|
|
8615
8828
|
}
|
|
8616
|
-
const { command } =
|
|
8829
|
+
const { command } = owner.app;
|
|
8617
8830
|
const next = /* @__PURE__ */ new Map();
|
|
8618
8831
|
const step = /* @__PURE__ */ __name((id, args = {}) => {
|
|
8619
8832
|
if (!next.has(id))
|
|
@@ -8629,10 +8842,10 @@ var checkCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("c
|
|
|
8629
8842
|
step("store.reindex");
|
|
8630
8843
|
else if (stems && !stems.ready)
|
|
8631
8844
|
step("store.migrate");
|
|
8632
|
-
const behind = answer.chatsBehind.find((chat) => chat.provider ===
|
|
8633
|
-
if (behind &&
|
|
8845
|
+
const behind = answer.chatsBehind.find((chat) => chat.provider === owner.provider);
|
|
8846
|
+
if (behind && owner.history !== "store")
|
|
8634
8847
|
step("messages.sync");
|
|
8635
|
-
else if (behind && syncsOneChat(
|
|
8848
|
+
else if (behind && syncsOneChat(owner))
|
|
8636
8849
|
step("messages.sync", { chat: behind.chat });
|
|
8637
8850
|
result(this, answer, [...next.values()]);
|
|
8638
8851
|
if (answer.schema.version < SPEAKS) {
|
|
@@ -8647,7 +8860,7 @@ var checkCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("c
|
|
|
8647
8860
|
renderer.note(`${orphans} pointers name a row that is gone or a type the store does not know \u2014 see orphan_pointers`);
|
|
8648
8861
|
if (answer.vectors && answer.vectors.unused > 0)
|
|
8649
8862
|
renderer.note(`${answer.vectors.unused} vectors belong to no text the store still holds \u2014 \`${command} store rebuild\` drops them`);
|
|
8650
|
-
const older = answer.conversations.filter((chat) => chat.provider ===
|
|
8863
|
+
const older = answer.conversations.filter((chat) => chat.provider === owner.provider && !chat.current).length;
|
|
8651
8864
|
if (older > 0) {
|
|
8652
8865
|
renderer.note(`${older} chats' conversations were built by older rules \u2014 \`${command} conversations links rebuild --chat <chat>\``);
|
|
8653
8866
|
}
|
|
@@ -8750,19 +8963,19 @@ var chatsBehind = /* @__PURE__ */ __name((database) => database.prepare(`SELECT
|
|
|
8750
8963
|
held: row.held === null ? null : isoOf(row.held),
|
|
8751
8964
|
refreshed: isoOf(row.refreshed)
|
|
8752
8965
|
})), "chatsBehind");
|
|
8753
|
-
var migrateCommand = /* @__PURE__ */ __name((
|
|
8966
|
+
var migrateCommand = /* @__PURE__ */ __name((owner) => annotate(new Command("migrate"), { output: { entity: "store_migration" }, effects: LOCAL_WRITE }).summary(`migrate an older ${archive(owner)}`).description("bring the store up to this build's schema, then normalize, index and stem the messages and notes stored before it").action(async function() {
|
|
8754
8967
|
const { renderer } = outputFor(this);
|
|
8755
8968
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8756
8969
|
if (!existsSync10(path)) {
|
|
8757
8970
|
result(this, { path, exists: false });
|
|
8758
|
-
renderer.note(`no store yet \u2014
|
|
8971
|
+
renderer.note(`no store yet \u2014 ${createdBy(owner)}`);
|
|
8759
8972
|
return;
|
|
8760
8973
|
}
|
|
8761
8974
|
const answer = await reading(path, (database) => {
|
|
8762
8975
|
const from = schemaOf(database).version;
|
|
8763
8976
|
migrate(database, {
|
|
8764
|
-
command:
|
|
8765
|
-
version:
|
|
8977
|
+
command: owner.app.command,
|
|
8978
|
+
version: owner.app.version,
|
|
8766
8979
|
rollback: { store: path, warn: /* @__PURE__ */ __name((line) => renderer.warn(line), "warn") }
|
|
8767
8980
|
});
|
|
8768
8981
|
const { normalized, indexed, terms } = buildWordIndex(database, (note) => renderer.note(note));
|
|
@@ -8814,7 +9027,7 @@ var buildNoteIndex = /* @__PURE__ */ __name((database, note, { reset = false } =
|
|
|
8814
9027
|
note(`indexing ${pending} notes`);
|
|
8815
9028
|
return { notesIndexed: drainNoteIndex(database, stemmerCache()) };
|
|
8816
9029
|
}, "buildNoteIndex");
|
|
8817
|
-
var reindexCommand = /* @__PURE__ */ __name((
|
|
9030
|
+
var reindexCommand = /* @__PURE__ */ __name((owner) => destroysNothing(annotate(new Command("rebuild"), { output: { entity: "store_reindex" }, effects: LOCAL_WRITE })).summary(`rebuild the ${archive(owner)}'s search indexes`).description("rebuild the word index, its typo vocabulary, the stems, the files' word index, the notes' indexes and who took part in what, from what is stored, and drop the vectors no stored text uses; loses nothing").action(async function() {
|
|
8818
9031
|
const { renderer } = outputFor(this);
|
|
8819
9032
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8820
9033
|
if (!existsSync10(path)) {
|
|
@@ -8859,6 +9072,9 @@ var backupCommand = /* @__PURE__ */ __name(() => destroysNothing(annotate(new Co
|
|
|
8859
9072
|
const { encrypt } = this.opts();
|
|
8860
9073
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8861
9074
|
const target = resolve(file2);
|
|
9075
|
+
const { app, env } = environmentOf(this);
|
|
9076
|
+
if (app)
|
|
9077
|
+
refuseLockedOutput(target, app, env ?? process.env, "<file>");
|
|
8862
9078
|
if (!existsSync10(path))
|
|
8863
9079
|
throw new CliError("not_found", `no store at ${path} to back up`);
|
|
8864
9080
|
if (existsSync10(target))
|
|
@@ -8903,37 +9119,37 @@ var decryptCommand = /* @__PURE__ */ __name(() => annotate(new Command("decrypt"
|
|
|
8903
9119
|
await unsealFile(from, to, await passwordOf(this, { twice: false }));
|
|
8904
9120
|
result(this, { path: to, from, bytes: bytesOf2(to) });
|
|
8905
9121
|
}), "decryptCommand");
|
|
8906
|
-
var restoreCommand = /* @__PURE__ */ __name((
|
|
9122
|
+
var restoreCommand = /* @__PURE__ */ __name((owner) => grantsAuthority(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) {
|
|
8907
9123
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8908
9124
|
const given = resolve(file2);
|
|
8909
9125
|
if (!existsSync10(given))
|
|
8910
9126
|
throw new CliError("not_found", `no file at ${given}`);
|
|
8911
|
-
refuseWhileServing(this,
|
|
9127
|
+
refuseWhileServing(this, owner);
|
|
8912
9128
|
if (!isSealed(given))
|
|
8913
|
-
return restoreFrom(this,
|
|
9129
|
+
return restoreFrom(this, owner, given, given);
|
|
8914
9130
|
const opened = `${path}.unsealing-${process.pid}`;
|
|
8915
9131
|
mkdirSync(dirname3(path), { recursive: true, mode: 448 });
|
|
8916
9132
|
try {
|
|
8917
9133
|
await unsealFile(given, opened, await passwordOf(this, { twice: false }));
|
|
8918
|
-
await restoreFrom(this,
|
|
9134
|
+
await restoreFrom(this, owner, opened, given);
|
|
8919
9135
|
} finally {
|
|
8920
9136
|
rmSync3(opened, { force: true });
|
|
8921
9137
|
}
|
|
8922
9138
|
}), "restoreCommand");
|
|
8923
|
-
var restoreFrom = /* @__PURE__ */ __name(async (command,
|
|
9139
|
+
var restoreFrom = /* @__PURE__ */ __name(async (command, owner, backup, given) => {
|
|
8924
9140
|
const { renderer } = outputFor(command);
|
|
8925
9141
|
const path = storePath(environmentOf(command).env ?? process.env);
|
|
8926
9142
|
if (existsSync10(path) && realpathSync3(backup) === realpathSync3(path)) {
|
|
8927
9143
|
throw new CliError("validation_error", `${backup} is the store itself`);
|
|
8928
9144
|
}
|
|
8929
9145
|
if (await isRollbackCopy(backup))
|
|
8930
|
-
return rollBackFrom(command,
|
|
9146
|
+
return rollBackFrom(command, owner, backup);
|
|
8931
9147
|
const schema = await backupSchema(backup);
|
|
8932
9148
|
const stamp = stampNow();
|
|
8933
9149
|
const kept = existsSync10(path) ? `${path}.before-restore-${stamp}` : null;
|
|
8934
9150
|
if (kept) {
|
|
8935
9151
|
const waitMs = environmentOf(command).storeLockWaitMs;
|
|
8936
|
-
await quiesce(path,
|
|
9152
|
+
await quiesce(path, owner, "restore", (message) => renderer.warn(message), waitMs);
|
|
8937
9153
|
} else
|
|
8938
9154
|
mkdirSync(dirname3(path), { recursive: true, mode: 448 });
|
|
8939
9155
|
const incoming = `${path}.restoring-${stamp}`;
|
|
@@ -8961,13 +9177,13 @@ var isRollbackCopy = /* @__PURE__ */ __name(async (file2) => {
|
|
|
8961
9177
|
return false;
|
|
8962
9178
|
}
|
|
8963
9179
|
}, "isRollbackCopy");
|
|
8964
|
-
var rollBackFrom = /* @__PURE__ */ __name(async (command,
|
|
9180
|
+
var rollBackFrom = /* @__PURE__ */ __name(async (command, owner, copy) => {
|
|
8965
9181
|
const { renderer } = outputFor(command);
|
|
8966
9182
|
const path = storePath(environmentOf(command).env ?? process.env);
|
|
8967
9183
|
if (!existsSync10(path))
|
|
8968
9184
|
throw new CliError("not_found", `no store at ${path} to roll back`);
|
|
8969
9185
|
const waitMs = environmentOf(command).storeLockWaitMs;
|
|
8970
|
-
await quiesce(path,
|
|
9186
|
+
await quiesce(path, owner, "restore", (message) => renderer.warn(message), waitMs);
|
|
8971
9187
|
const { database } = await openSqlite(path);
|
|
8972
9188
|
let rolled;
|
|
8973
9189
|
try {
|
|
@@ -9012,8 +9228,8 @@ var backupSchema = /* @__PURE__ */ __name(async (backup) => {
|
|
|
9012
9228
|
return schema;
|
|
9013
9229
|
}, "backupSchema");
|
|
9014
9230
|
var STORE_LOCK_WAIT_MS = 1e3;
|
|
9015
|
-
var quiesce = /* @__PURE__ */ __name(async (path,
|
|
9016
|
-
const { command } =
|
|
9231
|
+
var quiesce = /* @__PURE__ */ __name(async (path, owner, then, warn, waitMs = STORE_LOCK_WAIT_MS) => {
|
|
9232
|
+
const { command } = owner.app;
|
|
9017
9233
|
const files = [path, `${path}-wal`, `${path}-shm`].filter((file2) => existsSync10(file2)).map((file2) => realpathSync3(file2));
|
|
9018
9234
|
const holders = holdersOf(files);
|
|
9019
9235
|
if (holders === void 0) {
|
|
@@ -9035,21 +9251,21 @@ var quiesce = /* @__PURE__ */ __name(async (path, messenger, then, warn, waitMs
|
|
|
9035
9251
|
database.close();
|
|
9036
9252
|
}
|
|
9037
9253
|
}, "quiesce");
|
|
9038
|
-
var resetCommand = /* @__PURE__ */ __name((
|
|
9254
|
+
var resetCommand = /* @__PURE__ */ __name((owner) => annotate(new Command("reset"), { output: { entity: "store_reset" }, effects: LOCAL_WRITE, mcp: false }).summary(`back up the ${archive(owner)} and replace it with an empty one`).description("back the store up beside itself, then delete it and start an empty one at this build's schema; asks first, or --yes").option("--no-backup", "delete the store without backing it up first").option("--dry-run", "list every table it would empty, with its rows, and delete nothing").action(async function({ backup: keep, dryRun: dryRun2 }) {
|
|
9039
9255
|
const { renderer } = outputFor(this);
|
|
9040
|
-
const { command } =
|
|
9256
|
+
const { command } = owner.app;
|
|
9041
9257
|
const env = environmentOf(this).env ?? process.env;
|
|
9042
9258
|
const path = storePath(env);
|
|
9043
9259
|
if (!existsSync10(path)) {
|
|
9044
9260
|
result(this, { path, exists: false, reset: false });
|
|
9045
|
-
renderer.note(`no store at ${path} \u2014 nothing to reset;
|
|
9261
|
+
renderer.note(`no store at ${path} \u2014 nothing to reset; ${createdBy(owner)}`);
|
|
9046
9262
|
return;
|
|
9047
9263
|
}
|
|
9048
9264
|
if (dryRun2) {
|
|
9049
|
-
result(this, await resetPreview(path,
|
|
9265
|
+
result(this, await resetPreview(path, owner, env, keep));
|
|
9050
9266
|
return;
|
|
9051
9267
|
}
|
|
9052
|
-
refuseWhileServing(this,
|
|
9268
|
+
refuseWhileServing(this, owner);
|
|
9053
9269
|
if (this.optsWithGlobals().yes !== true) {
|
|
9054
9270
|
const what = `this deletes the store at ${path} and starts an empty one, ${keep ? "after a backup beside it" : "with no backup"}`;
|
|
9055
9271
|
const answer = await answerOf(this, `${what}. Go ahead? [y/N] `);
|
|
@@ -9058,7 +9274,7 @@ var resetCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("r
|
|
|
9058
9274
|
if (!/^\s*y(es)?\s*$/i.test(answer))
|
|
9059
9275
|
throw new CliError("cancelled", "cancelled \u2014 the store is unchanged");
|
|
9060
9276
|
}
|
|
9061
|
-
await quiesce(path,
|
|
9277
|
+
await quiesce(path, owner, "reset", (message) => renderer.warn(message), environmentOf(this).storeLockWaitMs);
|
|
9062
9278
|
const backup = keep ? `${path}.backup-${stampNow()}` : null;
|
|
9063
9279
|
let backedUp = null;
|
|
9064
9280
|
if (backup) {
|
|
@@ -9084,10 +9300,10 @@ var resetCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("r
|
|
|
9084
9300
|
renderer.note(backup ? `the store is empty at schema ${schema}; \`${command} store restore ${backup}\` puts the old one back once a build can read it` : `the store is empty at schema ${schema}; there is no backup`);
|
|
9085
9301
|
}), "resetCommand");
|
|
9086
9302
|
var STORE_PARTS2 = ["", "-wal", "-shm"];
|
|
9087
|
-
var resetPreview = /* @__PURE__ */ __name(async (path,
|
|
9303
|
+
var resetPreview = /* @__PURE__ */ __name(async (path, owner, env, keep) => {
|
|
9088
9304
|
const files = STORE_PARTS2.map((suffix) => `${path}${suffix}`).filter((file2) => existsSync10(file2));
|
|
9089
9305
|
const holders = holdersOf(files.map((file2) => realpathSync3(file2)));
|
|
9090
|
-
const serving = servingProfiles(
|
|
9306
|
+
const serving = servingProfiles(owner.app, env).length > 0;
|
|
9091
9307
|
const read = await readingOnly(path, (database) => ({
|
|
9092
9308
|
schema: schemaOf(database).version,
|
|
9093
9309
|
tables: emptiedTables(database)
|
|
@@ -9130,6 +9346,20 @@ export {
|
|
|
9130
9346
|
paused,
|
|
9131
9347
|
DRY_RUN_DAYS,
|
|
9132
9348
|
dryRun,
|
|
9349
|
+
AI_PROVIDERS,
|
|
9350
|
+
aiSettingPath,
|
|
9351
|
+
readAiSetting,
|
|
9352
|
+
writeAiSetting,
|
|
9353
|
+
aiSettingOf,
|
|
9354
|
+
aiBaseUrl,
|
|
9355
|
+
aiOrigin,
|
|
9356
|
+
aiImagesAllowed,
|
|
9357
|
+
aiKeys,
|
|
9358
|
+
aiTakesKey,
|
|
9359
|
+
aiLeavesComputer,
|
|
9360
|
+
sharedModel,
|
|
9361
|
+
checkAi,
|
|
9362
|
+
purposeModel,
|
|
9133
9363
|
replyConsentPathFor,
|
|
9134
9364
|
readReplyConsent,
|
|
9135
9365
|
writeReplyConsent,
|
|
@@ -9141,6 +9371,7 @@ export {
|
|
|
9141
9371
|
ENCRYPT_OPTION,
|
|
9142
9372
|
passwordOf,
|
|
9143
9373
|
DAY_MS,
|
|
9374
|
+
ownPackageRoot,
|
|
9144
9375
|
messageItem,
|
|
9145
9376
|
messageItems,
|
|
9146
9377
|
selfOf,
|
|
@@ -9149,5 +9380,6 @@ export {
|
|
|
9149
9380
|
serveCommand,
|
|
9150
9381
|
storeSummary,
|
|
9151
9382
|
storeMaintenanceCommands,
|
|
9383
|
+
addStoreMaintenanceCommands,
|
|
9152
9384
|
buildStems
|
|
9153
9385
|
};
|