@wirecat/tg-cli 0.122.0 → 0.124.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 +62 -4
- package/dist/bin/tg.js +2 -2
- package/dist/bundle/{adapter-ZI57T2L5.js → adapter-GEIZVMWU.js} +55 -53
- package/dist/bundle/{all-profiles-7VXJF42C.js → all-profiles-EY4GJFWN.js} +10 -10
- package/dist/bundle/{anthropic-DKRXIWVV.js → anthropic-RIANJ7WM.js} +17 -10
- package/dist/bundle/{app-server-F5MKHZ7S.js → app-server-LW7WBFIF.js} +62 -52
- package/dist/bundle/{bot-api-F24NWJT3.js → bot-api-FHIQ66OM.js} +54 -52
- package/dist/bundle/{bot-history-U3WM3A7S.js → bot-history-O34YZEFH.js} +18 -18
- package/dist/bundle/{bun-OMTJAXGK.js → bun-MJWD4VGV.js} +2 -2
- package/dist/bundle/{bun-sqlite-HSYLO46A.js → bun-sqlite-LCHVO3OB.js} +9 -5
- package/dist/bundle/{chunk-DCGGZUNJ.js → chunk-2GFGZDWS.js} +2 -2
- package/dist/bundle/{chunk-7FWU4RON.js → chunk-2NG4JPP7.js} +4 -4
- package/dist/bundle/{chunk-UGEYQWEO.js → chunk-2YLIVDWJ.js} +2 -2
- package/dist/bundle/chunk-3PLMMFP6.js +1068 -0
- package/dist/bundle/{chunk-27SVHRHV.js → chunk-3VVZFBE2.js} +23 -4
- package/dist/bundle/{chunk-FYHFAOPM.js → chunk-42R4YO4L.js} +12064 -9579
- package/dist/bundle/{chunk-U6HEZPCR.js → chunk-4CIVGT4P.js} +57 -28
- package/dist/bundle/{chunk-CB6AHU6H.js → chunk-4EGB7GSW.js} +96 -19
- package/dist/bundle/chunk-54JPEGQA.js +71 -0
- package/dist/bundle/chunk-5EL6E6PW.js +13 -0
- package/dist/bundle/{chunk-QROAXWDU.js → chunk-7AWJZ6NJ.js} +8 -8
- package/dist/bundle/{chunk-2UHANFLM.js → chunk-A5RWKKBZ.js} +3 -3
- package/dist/bundle/{chunk-7I6YVQHW.js → chunk-ASEBKZFY.js} +2 -2
- package/dist/bundle/{chunk-SODUFMDW.js → chunk-BV3HZYOX.js} +7435 -6559
- package/dist/bundle/{chunk-FHWUOFWX.js → chunk-CDSSKK5J.js} +3 -3
- package/dist/bundle/{chunk-6LMEIELG.js → chunk-DFSLHF46.js} +1 -1
- package/dist/bundle/{chunk-Y74WJL3M.js → chunk-E66JBGZZ.js} +6 -6
- package/dist/bundle/{chunk-VUBZFMGP.js → chunk-E6VSARSU.js} +2 -2
- package/dist/bundle/{chunk-MFWWZ6XL.js → chunk-F3GHTPAO.js} +4 -4
- package/dist/bundle/{chunk-NU4RMUMQ.js → chunk-GUL6QLNI.js} +40 -21
- package/dist/bundle/{chunk-E3MFMMVY.js → chunk-HEV23NIB.js} +6 -6
- package/dist/bundle/{chunk-FZKHFTKH.js → chunk-HSRO77SW.js} +35 -29
- package/dist/bundle/{chunk-FATTEYZH.js → chunk-I4JUKRW7.js} +2 -2
- package/dist/bundle/{chunk-YDMKP7PO.js → chunk-IK6XKMLL.js} +1 -1
- package/dist/bundle/{chunk-DDSAJKPO.js → chunk-ISGXVFA4.js} +4 -4
- package/dist/bundle/chunk-IVFUSI7G.js +53 -0
- package/dist/bundle/{chunk-DTTONQW7.js → chunk-KVJSCJGZ.js} +2 -2
- package/dist/bundle/{chunk-NE3EGYPD.js → chunk-LKMZ53GC.js} +4 -7
- package/dist/bundle/{chunk-YFEH7OWG.js → chunk-M4W4Y5YR.js} +132 -40
- package/dist/bundle/{chunk-R2IW6JBV.js → chunk-N5UM63JW.js} +343 -112
- package/dist/bundle/{chunk-V4BPS7MH.js → chunk-NL4COYPY.js} +9 -9
- package/dist/bundle/{chunk-ZNPRTCUO.js → chunk-NQXVZ5WT.js} +15 -117
- package/dist/bundle/{chunk-4MFMUBHH.js → chunk-OH3IZ6GW.js} +2395 -2369
- package/dist/bundle/{chunk-RX5CJ55S.js → chunk-OIF4B526.js} +1 -1
- package/dist/bundle/{chunk-4W4EVVL4.js → chunk-OK4M4MWI.js} +4 -4
- package/dist/bundle/{chunk-W34QQMBK.js → chunk-OVDB5CQM.js} +1 -1
- package/dist/bundle/{chunk-7GCVON7M.js → chunk-PI4XXMPG.js} +6 -6
- package/dist/bundle/{chunk-MCPOZNWG.js → chunk-PJGOQSE5.js} +1 -1
- package/dist/bundle/{chunk-D3ODL4P7.js → chunk-PP4ZBLS4.js} +69 -6
- package/dist/bundle/{chunk-LVGX7VTD.js → chunk-PZ6H65D6.js} +4 -4
- package/dist/bundle/{chunk-ARKB3M5X.js → chunk-QFV36CAH.js} +4 -4
- package/dist/bundle/{chunk-7X6YLKTK.js → chunk-QGCVQRHV.js} +1 -1
- package/dist/bundle/{chunk-O5A4IS2D.js → chunk-QK4T3VN7.js} +1 -1
- package/dist/bundle/{chunk-VC6J7X76.js → chunk-QWAMX6CN.js} +12 -12
- package/dist/bundle/{chunk-ALW7ROTM.js → chunk-RBV4M2TC.js} +1 -1
- package/dist/bundle/{chunk-GJBGZQHN.js → chunk-RHJHOOUL.js} +354 -184
- package/dist/bundle/{chunk-4N2WJYLE.js → chunk-SGBH3D5D.js} +3 -3
- package/dist/bundle/{chunk-N7WDVH2O.js → chunk-UII3D3HR.js} +51 -51
- package/dist/bundle/{chunk-HAR76KJG.js → chunk-UP3J3YXH.js} +6 -6
- package/dist/bundle/{chunk-WGGSFGNZ.js → chunk-UR62DZ7Q.js} +48 -9
- package/dist/bundle/{chunk-RFFU6KQ5.js → chunk-VAKSXD4F.js} +13 -13
- package/dist/bundle/{chunk-TKJZENAZ.js → chunk-VGUWIHXD.js} +1 -1
- package/dist/bundle/chunk-VIIIC5LU.js +32 -0
- package/dist/bundle/{chunk-VDFEWSCS.js → chunk-VMWJGUVV.js} +14 -5
- package/dist/bundle/{chunk-C5CB6RIX.js → chunk-W4LMTNN2.js} +2 -2
- package/dist/bundle/{chunk-33ELXJRR.js → chunk-WKOVQ4OU.js} +14 -12
- package/dist/bundle/{chunk-6DLRATDC.js → chunk-WSLIXJET.js} +3817 -3378
- package/dist/bundle/{chunk-LQRZUNYF.js → chunk-XDHGM2Z7.js} +3 -3
- package/dist/bundle/{chunk-7DPWVKYS.js → chunk-XSGUG5WG.js} +4 -4
- package/dist/bundle/{chunk-CW3C7FSO.js → chunk-YQFO7WXQ.js} +2 -2
- package/dist/bundle/{chunk-2FXA32RJ.js → chunk-ZL5YG2WK.js} +14 -9
- package/dist/bundle/{chunk-VQL4RVXZ.js → chunk-ZNICTHSC.js} +1 -1
- package/dist/bundle/{chunk-PG3V225O.js → chunk-ZTMV5M3D.js} +32 -27
- package/dist/bundle/command-contract-UKOL455D.js +34 -0
- package/dist/bundle/{command-server-entry-N32NX4QW.js → command-server-entry-K52OEKIO.js} +24 -22
- package/dist/bundle/{decode-ZKJWSFXF.js → decode-OAE25LEJ.js} +5 -5
- package/dist/bundle/{dispatch-U2DW6UI7.js → dispatch-6GVTXIZ2.js} +8 -8
- package/dist/bundle/{echarts-QLVLIP73.js → echarts-EO4ZGKMN.js} +2 -2
- package/dist/bundle/{embed-LC6K7P3S.js → embed-TB2AS4AT.js} +6 -6
- package/dist/bundle/{embedder-6C3OQBOV.js → embedder-YKC42G6L.js} +9 -9
- package/dist/bundle/{entry-5H6LB3MP.js → entry-AB6FU7BN.js} +9 -8
- package/dist/bundle/{failure-HJD7S5UA.js → failure-CY7ACT6V.js} +2 -2
- package/dist/bundle/{first-run-IOYQ4XQK.js → first-run-CMQZHDI5.js} +11 -11
- package/dist/bundle/first-screen-XZ73W3VE.js +32 -0
- package/dist/bundle/{instructions-SZUMEDY3.js → instructions-RM3IB6ID.js} +1 -1
- package/dist/bundle/{mcp-7KQUJNFN.js → mcp-M5YCSWJJ.js} +2 -2
- package/dist/bundle/{node-V76RRFIA.js → node-D2PM62TA.js} +2 -2
- package/dist/bundle/{node-sqlite-2DTVOT7L.js → node-sqlite-UK5DE525.js} +10 -6
- package/dist/bundle/{oauth-CT7EBDRY.js → oauth-SKRG67A2.js} +7 -7
- package/dist/bundle/{open-G3VHOOMV.js → open-XP3SY62D.js} +5 -5
- package/dist/bundle/{openai-F4K7MVTZ.js → openai-Q3U46UPA.js} +21 -17
- package/dist/bundle/{process-XH3KEHSF.js → process-YJ4LHMJB.js} +1 -1
- package/dist/bundle/{program-FLGIHTHM.js → program-EEPEFKTR.js} +80 -63
- package/dist/bundle/{prompt-JWQ6UQ6R.js → prompt-WYTODP4U.js} +5 -5
- package/dist/bundle/{proxy-transport-ENU2SJYT.js → proxy-transport-HJMQ5QFT.js} +5 -5
- package/dist/bundle/{recognize-Z26T3SYD.js → recognize-K2S5QQU2.js} +4 -4
- package/dist/bundle/{remote-7KHT6V3O.js → remote-7RSAJ3JC.js} +9 -7
- package/dist/bundle/{rerank-6QVI74QY.js → rerank-RJX77BKD.js} +7 -7
- package/dist/bundle/{serve-WYDZTONY.js → serve-3E7NN3VW.js} +14 -14
- package/dist/bundle/server-ITHYDPWQ.js +62 -0
- package/dist/bundle/{server-Y4J2NCFA.js → server-O3KU56A4.js} +36 -35
- package/dist/bundle/sqlite-runtime-RCS5WSG5.js +19 -0
- package/dist/bundle/{state-YCXBKOD2.js → state-PLWSPSAG.js} +6 -6
- package/dist/bundle/store-3FYLH53Z.js +276 -0
- package/dist/bundle/{store-QECSDJRP.js → store-DWMKCXYL.js} +15 -13
- package/dist/bundle/store-maintenance-command-3UEKINRB.js +52 -0
- package/dist/bundle/tg.js +13 -13
- package/dist/commands/account-removal.d.ts.map +1 -1
- package/dist/commands/account-removal.js +5 -3
- package/dist/commands/account-removal.js.map +1 -1
- package/dist/commands/session.d.ts.map +1 -1
- package/dist/commands/session.js +21 -3
- package/dist/commands/session.js.map +1 -1
- package/dist/paths.d.ts +6 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +23 -2
- package/dist/paths.js.map +1 -1
- package/dist/program.d.ts +4 -1
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +5 -2
- package/dist/program.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -4
- package/dist/bundle/chunk-GJFICFQB.js +0 -27
- package/dist/bundle/chunk-Y52T5EMB.js +0 -35
- package/dist/bundle/chunk-ZKHXWSKD.js +0 -265
- package/dist/bundle/command-contract-247AKZTE.js +0 -33
- package/dist/bundle/first-screen-NVK7PFX4.js +0 -31
- package/dist/bundle/server-UXQT7LZT.js +0 -61
- package/dist/bundle/store-maintenance-command-5YW6TRJA.js +0 -49
- /package/dist/bundle/{chunk-YVNHQFLC.js → chunk-HVJJWJYQ.js} +0 -0
|
@@ -3,7 +3,7 @@ const require = __bundleRequire(import.meta.url);
|
|
|
3
3
|
import {
|
|
4
4
|
answerOf,
|
|
5
5
|
messengerContext
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-HSRO77SW.js";
|
|
7
7
|
import {
|
|
8
8
|
FETCHING,
|
|
9
9
|
RULES_VERSION,
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
patiently,
|
|
21
21
|
pollVoteAnswer,
|
|
22
22
|
queryTerms,
|
|
23
|
+
refuseLockedOutput,
|
|
23
24
|
senderIsMe,
|
|
24
25
|
serveRelay,
|
|
25
26
|
servicesFor,
|
|
@@ -27,7 +28,14 @@ import {
|
|
|
27
28
|
typedQuery,
|
|
28
29
|
withQuery,
|
|
29
30
|
withTimeLimit
|
|
30
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-WSLIXJET.js";
|
|
32
|
+
import {
|
|
33
|
+
holdLock,
|
|
34
|
+
lockPath,
|
|
35
|
+
releaseLock,
|
|
36
|
+
servingProfiles,
|
|
37
|
+
takeLock
|
|
38
|
+
} from "./chunk-CDSSKK5J.js";
|
|
31
39
|
import {
|
|
32
40
|
QUICK_HEALTH_CHECKS,
|
|
33
41
|
fts5Tables,
|
|
@@ -35,21 +43,14 @@ import {
|
|
|
35
43
|
lossUnknown,
|
|
36
44
|
storeDamageReport,
|
|
37
45
|
storeHealth
|
|
38
|
-
} from "./chunk-
|
|
39
|
-
import {
|
|
40
|
-
holdLock,
|
|
41
|
-
lockPath,
|
|
42
|
-
releaseLock,
|
|
43
|
-
servingProfiles,
|
|
44
|
-
takeLock
|
|
45
|
-
} from "./chunk-FHWUOFWX.js";
|
|
46
|
+
} from "./chunk-3PLMMFP6.js";
|
|
46
47
|
import {
|
|
47
48
|
stringWidth,
|
|
48
49
|
wrapAnsi
|
|
49
50
|
} from "./chunk-2ABQZVK4.js";
|
|
50
51
|
import {
|
|
51
52
|
readSecret
|
|
52
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-XDHGM2Z7.js";
|
|
53
54
|
import {
|
|
54
55
|
CORPORA,
|
|
55
56
|
MIGRATIONS,
|
|
@@ -84,10 +85,10 @@ import {
|
|
|
84
85
|
storeClients,
|
|
85
86
|
storeContents,
|
|
86
87
|
vectorIndexCounts
|
|
87
|
-
} from "./chunk-
|
|
88
|
+
} from "./chunk-42R4YO4L.js";
|
|
88
89
|
import {
|
|
89
90
|
openCache
|
|
90
|
-
} from "./chunk-
|
|
91
|
+
} from "./chunk-HEV23NIB.js";
|
|
91
92
|
import {
|
|
92
93
|
Command,
|
|
93
94
|
LOCAL_READ,
|
|
@@ -96,8 +97,10 @@ import {
|
|
|
96
97
|
REMOTE_WRITE,
|
|
97
98
|
annotate,
|
|
98
99
|
codeOf,
|
|
100
|
+
commandAt,
|
|
99
101
|
destroysNothing,
|
|
100
102
|
environmentOf,
|
|
103
|
+
grantsAuthority,
|
|
101
104
|
itemOf,
|
|
102
105
|
jsonlRecords,
|
|
103
106
|
levelFor,
|
|
@@ -113,10 +116,14 @@ import {
|
|
|
113
116
|
snakeKeys,
|
|
114
117
|
storeTable,
|
|
115
118
|
withoutProviderRefs
|
|
116
|
-
} from "./chunk-
|
|
119
|
+
} from "./chunk-RHJHOOUL.js";
|
|
117
120
|
import {
|
|
118
121
|
holdersOf
|
|
119
|
-
} from "./chunk-
|
|
122
|
+
} from "./chunk-QK4T3VN7.js";
|
|
123
|
+
import {
|
|
124
|
+
modelAddressAllowed,
|
|
125
|
+
onThisComputer
|
|
126
|
+
} from "./chunk-VIIIC5LU.js";
|
|
120
127
|
import {
|
|
121
128
|
currentRun,
|
|
122
129
|
formatLocator,
|
|
@@ -126,24 +133,32 @@ import {
|
|
|
126
133
|
readHealthMark,
|
|
127
134
|
readJournalMark,
|
|
128
135
|
recordDeepCheck
|
|
129
|
-
} from "./chunk-
|
|
136
|
+
} from "./chunk-OH3IZ6GW.js";
|
|
130
137
|
import {
|
|
131
138
|
failureKey,
|
|
132
139
|
isStoreDamage
|
|
133
|
-
} from "./chunk-
|
|
140
|
+
} from "./chunk-3VVZFBE2.js";
|
|
141
|
+
import {
|
|
142
|
+
readSharedSection,
|
|
143
|
+
sharedConfigPath,
|
|
144
|
+
writeSharedSection
|
|
145
|
+
} from "./chunk-UP3J3YXH.js";
|
|
134
146
|
import {
|
|
135
147
|
storePath
|
|
136
|
-
} from "./chunk-
|
|
148
|
+
} from "./chunk-IVFUSI7G.js";
|
|
137
149
|
import {
|
|
150
|
+
Credentials,
|
|
151
|
+
isMovedRun,
|
|
138
152
|
resolvePaths,
|
|
139
153
|
writeSecurely
|
|
140
|
-
} from "./chunk-
|
|
154
|
+
} from "./chunk-4CIVGT4P.js";
|
|
141
155
|
import {
|
|
142
156
|
array,
|
|
143
157
|
boolean,
|
|
144
158
|
check,
|
|
145
159
|
forward,
|
|
146
160
|
getDotPath,
|
|
161
|
+
maxLength,
|
|
147
162
|
minLength,
|
|
148
163
|
nullable,
|
|
149
164
|
object,
|
|
@@ -158,12 +173,12 @@ import {
|
|
|
158
173
|
string,
|
|
159
174
|
transform,
|
|
160
175
|
trim
|
|
161
|
-
} from "./chunk-
|
|
176
|
+
} from "./chunk-UR62DZ7Q.js";
|
|
162
177
|
import {
|
|
163
178
|
CliError,
|
|
164
179
|
singleLine,
|
|
165
180
|
visibleControls
|
|
166
|
-
} from "./chunk-
|
|
181
|
+
} from "./chunk-E6VSARSU.js";
|
|
167
182
|
import {
|
|
168
183
|
__commonJS,
|
|
169
184
|
__name,
|
|
@@ -5503,11 +5518,11 @@ var require_liquid_node = __commonJS({
|
|
|
5503
5518
|
}
|
|
5504
5519
|
});
|
|
5505
5520
|
|
|
5506
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5521
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.648.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.98.0_commander@15._22e948f6f1aa7f4572ea465a838ccfd1/node_modules/@wirecat/cli-core/dist/cli/messenger/store-maintenance-command.js
|
|
5507
5522
|
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
5523
|
import { dirname as dirname3, resolve } from "node:path";
|
|
5509
5524
|
|
|
5510
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5525
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.648.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.98.0_commander@15._22e948f6f1aa7f4572ea465a838ccfd1/node_modules/@wirecat/cli-core/dist/sealed.js
|
|
5511
5526
|
import { createCipheriv, createDecipheriv, createHash, randomBytes, scrypt, timingSafeEqual } from "node:crypto";
|
|
5512
5527
|
import { closeSync, createReadStream, createWriteStream, existsSync, openSync, readSync, renameSync, rmSync, statSync } from "node:fs";
|
|
5513
5528
|
import { Transform } from "node:stream";
|
|
@@ -5614,7 +5629,7 @@ var unsealFile = /* @__PURE__ */ __name(async (from, to, password) => {
|
|
|
5614
5629
|
renameSync(pending, to);
|
|
5615
5630
|
}, "unsealFile");
|
|
5616
5631
|
|
|
5617
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5632
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.648.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.98.0_commander@15._22e948f6f1aa7f4572ea465a838ccfd1/node_modules/@wirecat/cli-core/dist/store/compatibility.js
|
|
5618
5633
|
var SPEAKS = MIGRATIONS.at(-1)?.version ?? 0;
|
|
5619
5634
|
var fileSchemaOf = /* @__PURE__ */ __name((database) => {
|
|
5620
5635
|
const tracked = database.prepare("SELECT 1 FROM sqlite_master WHERE name = 'schema_migrations'").get();
|
|
@@ -5638,7 +5653,7 @@ var compatibilityOf = /* @__PURE__ */ __name((file2, migrations = MIGRATIONS) =>
|
|
|
5638
5653
|
};
|
|
5639
5654
|
}, "compatibilityOf");
|
|
5640
5655
|
|
|
5641
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5656
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.648.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.98.0_commander@15._22e948f6f1aa7f4572ea465a838ccfd1/node_modules/@wirecat/cli-core/dist/store/repair.js
|
|
5642
5657
|
import { createHash as createHash2 } from "node:crypto";
|
|
5643
5658
|
var COPY_MARK = "__repair_";
|
|
5644
5659
|
var COPY_NAME = /__repair_[0-9a-f]{8}(_\d+)?$/;
|
|
@@ -5892,19 +5907,19 @@ var deleteCopy = /* @__PURE__ */ __name((database, name) => {
|
|
|
5892
5907
|
return found;
|
|
5893
5908
|
}, "deleteCopy");
|
|
5894
5909
|
|
|
5895
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5910
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.648.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.98.0_commander@15._22e948f6f1aa7f4572ea465a838ccfd1/node_modules/@wirecat/cli-core/dist/cli/store-info.js
|
|
5896
5911
|
import { existsSync as existsSync4, statSync as statSync3 } from "node:fs";
|
|
5897
5912
|
|
|
5898
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5913
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.648.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.98.0_commander@15._22e948f6f1aa7f4572ea465a838ccfd1/node_modules/@wirecat/cli-core/dist/cli/store-recover.js
|
|
5899
5914
|
import { existsSync as existsSync3 } from "node:fs";
|
|
5900
5915
|
|
|
5901
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5916
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.648.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.98.0_commander@15._22e948f6f1aa7f4572ea465a838ccfd1/node_modules/@wirecat/cli-core/dist/store/recover.js
|
|
5902
5917
|
import { execFileSync, spawn } from "node:child_process";
|
|
5903
5918
|
import { existsSync as existsSync2, readFileSync, realpathSync, renameSync as renameSync2, rmSync as rmSync2, statfsSync, statSync as statSync2, writeFileSync } from "node:fs";
|
|
5904
5919
|
import { basename, dirname, join } from "node:path";
|
|
5905
5920
|
import { Transform as Transform2 } from "node:stream";
|
|
5906
5921
|
|
|
5907
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
5922
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.648.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.98.0_commander@15._22e948f6f1aa7f4572ea465a838ccfd1/node_modules/@wirecat/cli-core/dist/store/refill.js
|
|
5908
5923
|
var REFILL_MARGIN_MS = 864e5;
|
|
5909
5924
|
var TIME_KEYS = 1e12;
|
|
5910
5925
|
var integerId = `external_id GLOB '[0-9]*' AND NOT external_id GLOB '*[^0-9]*'`;
|
|
@@ -5984,7 +5999,7 @@ var forgetMail = /* @__PURE__ */ __name((database, cutoff, now) => {
|
|
|
5984
5999
|
return [...folders].map(([account, count3]) => ({ account, folders: count3 }));
|
|
5985
6000
|
}, "forgetMail");
|
|
5986
6001
|
|
|
5987
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6002
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.648.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.98.0_commander@15._22e948f6f1aa7f4572ea465a838ccfd1/node_modules/@wirecat/cli-core/dist/store/recover.js
|
|
5988
6003
|
var SQLITE3_MINIMUM = [3, 43, 0];
|
|
5989
6004
|
var STORE_PARTS = ["", "-wal", "-shm"];
|
|
5990
6005
|
var RECOVER_LOCK = ".recover-lock";
|
|
@@ -6512,7 +6527,7 @@ var recoverLocked = /* @__PURE__ */ __name(async ({ path, command, version, sqli
|
|
|
6512
6527
|
}
|
|
6513
6528
|
}, "recoverLocked");
|
|
6514
6529
|
|
|
6515
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6530
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.648.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.98.0_commander@15._22e948f6f1aa7f4572ea465a838ccfd1/node_modules/@wirecat/cli-core/dist/cli/store-recover.js
|
|
6516
6531
|
var COUNTED = [
|
|
6517
6532
|
"accounts",
|
|
6518
6533
|
"chats",
|
|
@@ -6653,7 +6668,7 @@ var storeRecoverCommand = /* @__PURE__ */ __name(({ command, version }) => {
|
|
|
6653
6668
|
for (const line of recoveryNotes(answer))
|
|
6654
6669
|
output.renderer.note(line);
|
|
6655
6670
|
});
|
|
6656
|
-
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() {
|
|
6671
|
+
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() {
|
|
6657
6672
|
const output = outputFor(this);
|
|
6658
6673
|
const answer = await storeRecoveryRun(environmentOf(this).env ?? process.env, {
|
|
6659
6674
|
command,
|
|
@@ -6668,7 +6683,7 @@ var storeRecoverCommand = /* @__PURE__ */ __name(({ command, version }) => {
|
|
|
6668
6683
|
return recover;
|
|
6669
6684
|
}, "storeRecoverCommand");
|
|
6670
6685
|
|
|
6671
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6686
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.648.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.98.0_commander@15._22e948f6f1aa7f4572ea465a838ccfd1/node_modules/@wirecat/cli-core/dist/cli/store-info.js
|
|
6672
6687
|
var pendingIfKnown = /* @__PURE__ */ __name((database) => database.prepare("SELECT 1 FROM pragma_table_info('messages') WHERE name = 'normalized_text'").get() ? pendingNormalization(database) : null, "pendingIfKnown");
|
|
6673
6688
|
var bytesOf = /* @__PURE__ */ __name((path) => existsSync4(path) ? statSync3(path).size : 0, "bytesOf");
|
|
6674
6689
|
var messageOf = /* @__PURE__ */ __name((error) => error instanceof Error ? error.message : String(error), "messageOf");
|
|
@@ -6714,7 +6729,7 @@ var storeInfoCommand = /* @__PURE__ */ __name(() => annotate(new Command("info")
|
|
|
6714
6729
|
renderAnswer(this, outputFor(this), itemOf(answer));
|
|
6715
6730
|
}), "storeInfoCommand");
|
|
6716
6731
|
|
|
6717
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6732
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.648.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.98.0_commander@15._22e948f6f1aa7f4572ea465a838ccfd1/node_modules/@wirecat/cli-core/dist/cli/messenger/password.js
|
|
6718
6733
|
var ENCRYPT_OPTION = [
|
|
6719
6734
|
"--encrypt",
|
|
6720
6735
|
"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"
|
|
@@ -6733,7 +6748,7 @@ var passwordOf = /* @__PURE__ */ __name(async (command, { twice }) => {
|
|
|
6733
6748
|
return password;
|
|
6734
6749
|
}, "passwordOf");
|
|
6735
6750
|
|
|
6736
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6751
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.648.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.98.0_commander@15._22e948f6f1aa7f4572ea465a838ccfd1/node_modules/@wirecat/cli-core/dist/replies/rules.js
|
|
6737
6752
|
import { existsSync as existsSync5, readFileSync as readFileSync2 } from "node:fs";
|
|
6738
6753
|
import { join as join2 } from "node:path";
|
|
6739
6754
|
var REPLY_ACTIONS = ["reply", "task"];
|
|
@@ -6904,7 +6919,7 @@ var problem = /* @__PURE__ */ __name((issue) => {
|
|
|
6904
6919
|
}, "problem");
|
|
6905
6920
|
var broken = /* @__PURE__ */ __name((path, why) => new CliError("configuration_error", `the reply rules ${path} cannot be read (${why}) \u2014 fix the file`), "broken");
|
|
6906
6921
|
|
|
6907
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6922
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.648.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.98.0_commander@15._22e948f6f1aa7f4572ea465a838ccfd1/node_modules/@wirecat/cli-core/dist/replies/state.js
|
|
6908
6923
|
import { existsSync as existsSync6, readFileSync as readFileSync3 } from "node:fs";
|
|
6909
6924
|
import { join as join3 } from "node:path";
|
|
6910
6925
|
var ANSWERED_KEPT = 1e3;
|
|
@@ -6957,7 +6972,7 @@ var recordReply = /* @__PURE__ */ __name((state, rule2, message, now) => {
|
|
|
6957
6972
|
}, "recordReply");
|
|
6958
6973
|
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");
|
|
6959
6974
|
|
|
6960
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
6975
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.648.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.98.0_commander@15._22e948f6f1aa7f4572ea465a838ccfd1/node_modules/@wirecat/cli-core/dist/replies/decide.js
|
|
6961
6976
|
var skip = /* @__PURE__ */ __name((why) => ({ skip: why }), "skip");
|
|
6962
6977
|
var decide = /* @__PURE__ */ __name((rule2, incoming, state, now) => {
|
|
6963
6978
|
const { message, chat, owner, sender } = incoming;
|
|
@@ -7063,10 +7078,10 @@ var filled = /* @__PURE__ */ __name((template2, senderName) => {
|
|
|
7063
7078
|
return template2.replaceAll("{firstName}", name.split(/\s+/)[0] ?? name).replaceAll("{name}", name);
|
|
7064
7079
|
}, "filled");
|
|
7065
7080
|
|
|
7066
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7081
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.648.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.98.0_commander@15._22e948f6f1aa7f4572ea465a838ccfd1/node_modules/@wirecat/cli-core/dist/replies/template.js
|
|
7067
7082
|
var import_liquidjs2 = __toESM(require_liquid_node(), 1);
|
|
7068
7083
|
|
|
7069
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7084
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.648.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.98.0_commander@15._22e948f6f1aa7f4572ea465a838ccfd1/node_modules/@wirecat/cli-core/dist/render/liquid.js
|
|
7070
7085
|
var import_liquidjs = __toESM(require_liquid_node(), 1);
|
|
7071
7086
|
var safeLiquid = /* @__PURE__ */ __name((limits) => {
|
|
7072
7087
|
const engine = new import_liquidjs.Liquid({
|
|
@@ -7093,7 +7108,7 @@ var safeLiquid = /* @__PURE__ */ __name((limits) => {
|
|
|
7093
7108
|
return engine;
|
|
7094
7109
|
}, "safeLiquid");
|
|
7095
7110
|
|
|
7096
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7111
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.648.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.98.0_commander@15._22e948f6f1aa7f4572ea465a838ccfd1/node_modules/@wirecat/cli-core/dist/replies/template.js
|
|
7097
7112
|
var TEMPLATE_LIMITS = {
|
|
7098
7113
|
parse: 32768,
|
|
7099
7114
|
renders: 2e3,
|
|
@@ -7232,7 +7247,7 @@ var renderReplyTemplate = /* @__PURE__ */ __name(async (reply, input) => {
|
|
|
7232
7247
|
}
|
|
7233
7248
|
}, "renderReplyTemplate");
|
|
7234
7249
|
|
|
7235
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7250
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.648.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.98.0_commander@15._22e948f6f1aa7f4572ea465a838ccfd1/node_modules/@wirecat/cli-core/dist/replies/dry-run.js
|
|
7236
7251
|
var DRY_RUN_DAYS = 7;
|
|
7237
7252
|
var PAGE = 500;
|
|
7238
7253
|
var dryRun = /* @__PURE__ */ __name(async (store, account, rules, { since, until = Date.now(), only, audience, render }) => {
|
|
@@ -7346,7 +7361,178 @@ var storedSince = /* @__PURE__ */ __name(async (store, account, chat, since) =>
|
|
|
7346
7361
|
}
|
|
7347
7362
|
}, "storedSince");
|
|
7348
7363
|
|
|
7349
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7364
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.648.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.98.0_commander@15._22e948f6f1aa7f4572ea465a838ccfd1/node_modules/@wirecat/cli-core/dist/models/ai.js
|
|
7365
|
+
var AI_PROVIDERS = ["anthropic", "openai", "ollama"];
|
|
7366
|
+
var DEFAULT_BASE_URL = {
|
|
7367
|
+
anthropic: "https://api.anthropic.com",
|
|
7368
|
+
openai: "https://api.openai.com/v1",
|
|
7369
|
+
ollama: "http://127.0.0.1:11434/v1"
|
|
7370
|
+
};
|
|
7371
|
+
var OFFICIAL = {
|
|
7372
|
+
"https://api.openai.com": "openai",
|
|
7373
|
+
"https://api.anthropic.com": "anthropic"
|
|
7374
|
+
};
|
|
7375
|
+
var SECTION = "ai";
|
|
7376
|
+
var aiAddressAllowed = modelAddressAllowed;
|
|
7377
|
+
var consentShape = strictObject({
|
|
7378
|
+
origin: string(),
|
|
7379
|
+
model: string(),
|
|
7380
|
+
at: string()
|
|
7381
|
+
});
|
|
7382
|
+
var settingShape = strictObject({
|
|
7383
|
+
provider: picklist(AI_PROVIDERS),
|
|
7384
|
+
model: pipe(string(), trim(), minLength(1), maxLength(200)),
|
|
7385
|
+
base_url: optional(pipe(string(), check(aiAddressAllowed, "use https, or http only on this computer"))),
|
|
7386
|
+
images: optional(consentShape)
|
|
7387
|
+
});
|
|
7388
|
+
var aiSettingPath = /* @__PURE__ */ __name((env) => sharedConfigPath(storePath(env), env), "aiSettingPath");
|
|
7389
|
+
var readAiSetting = /* @__PURE__ */ __name((path) => {
|
|
7390
|
+
const section = readSharedSection(path, SECTION);
|
|
7391
|
+
if (section === void 0)
|
|
7392
|
+
return void 0;
|
|
7393
|
+
const checked = safeParse(settingShape, section);
|
|
7394
|
+
if (!checked.success)
|
|
7395
|
+
throw new CliError("configuration_error", `${path}: ai.${getDotPath(checked.issues[0]) ?? "setting"} is invalid`, {
|
|
7396
|
+
reason: "ai.setting-invalid"
|
|
7397
|
+
});
|
|
7398
|
+
return checked.output;
|
|
7399
|
+
}, "readAiSetting");
|
|
7400
|
+
var writeAiSetting = /* @__PURE__ */ __name((path, setting) => writeSharedSection(path, SECTION, setting), "writeAiSetting");
|
|
7401
|
+
var aiSettingOf = /* @__PURE__ */ __name((given) => {
|
|
7402
|
+
const draft = {
|
|
7403
|
+
provider: given.provider,
|
|
7404
|
+
model: given.model,
|
|
7405
|
+
...given.baseUrl?.trim() ? { base_url: given.baseUrl.trim().replace(/\/+$/, "") } : {}
|
|
7406
|
+
};
|
|
7407
|
+
const checked = safeParse(settingShape, draft);
|
|
7408
|
+
if (!checked.success) {
|
|
7409
|
+
const field = getDotPath(checked.issues[0]);
|
|
7410
|
+
throw new CliError("validation_error", field === "provider" ? `the provider is one of ${AI_PROVIDERS.join(", ")}` : field === "base_url" ? "this address is not allowed: use https, or http only on this computer" : "name the model, 1 to 200 characters", { reason: field === "base_url" ? "ai.address-refused" : "ai.setting-invalid" });
|
|
7411
|
+
}
|
|
7412
|
+
if (checked.output.provider === "ollama" && !onThisComputer(aiBaseUrl(checked.output)))
|
|
7413
|
+
throw new CliError("validation_error", "Ollama is read only on this computer", { reason: "ai.address-refused" });
|
|
7414
|
+
return given.allowImages ? {
|
|
7415
|
+
...checked.output,
|
|
7416
|
+
images: { origin: aiOrigin(checked.output), model: checked.output.model, at: (/* @__PURE__ */ new Date()).toISOString() }
|
|
7417
|
+
} : checked.output;
|
|
7418
|
+
}, "aiSettingOf");
|
|
7419
|
+
var aiBaseUrl = /* @__PURE__ */ __name((setting) => setting.base_url ?? DEFAULT_BASE_URL[setting.provider], "aiBaseUrl");
|
|
7420
|
+
var aiOrigin = /* @__PURE__ */ __name((setting) => new URL(aiBaseUrl(setting)).origin, "aiOrigin");
|
|
7421
|
+
var aiTarget = /* @__PURE__ */ __name((setting) => ({
|
|
7422
|
+
provider: setting.provider === "anthropic" ? "anthropic" : "openai",
|
|
7423
|
+
model: setting.model,
|
|
7424
|
+
baseUrl: aiBaseUrl(setting)
|
|
7425
|
+
}), "aiTarget");
|
|
7426
|
+
var aiImagesAllowed = /* @__PURE__ */ __name((setting) => setting.images?.origin === aiOrigin(setting) && setting.images.model === setting.model, "aiImagesAllowed");
|
|
7427
|
+
var aiKeys = /* @__PURE__ */ __name((app, env, keyring) => {
|
|
7428
|
+
const where = { appName: "WireCat", prefix: "WIRECAT", env };
|
|
7429
|
+
const credentials = new Credentials({
|
|
7430
|
+
configDir: resolvePaths(where).config,
|
|
7431
|
+
service: "WireCat",
|
|
7432
|
+
// A tool run with its own folders moved (MEMO_CONFIG_DIR…) is a test or a sandbox, not the owner.
|
|
7433
|
+
isolated: isMovedRun(where) || isMovedRun({ appName: app.appName, prefix: app.envPrefix, env }),
|
|
7434
|
+
env,
|
|
7435
|
+
...keyring ? { keyring } : {},
|
|
7436
|
+
warn: /* @__PURE__ */ __name((message) => process.stderr.write(`${message}
|
|
7437
|
+
`), "warn")
|
|
7438
|
+
});
|
|
7439
|
+
const account = /* @__PURE__ */ __name((origin) => `ai:${origin}`, "account");
|
|
7440
|
+
return {
|
|
7441
|
+
read: /* @__PURE__ */ __name((origin) => {
|
|
7442
|
+
const stored = credentials.read(account(origin));
|
|
7443
|
+
if (stored)
|
|
7444
|
+
return { key: stored.secret, source: stored.source };
|
|
7445
|
+
const official = OFFICIAL[origin];
|
|
7446
|
+
const legacy = official ?? (origin.startsWith("https://") ? endpointKeyName(origin) : void 0);
|
|
7447
|
+
const found = legacy === void 0 ? void 0 : embeddingKeys(app, env, keyring).read(legacy);
|
|
7448
|
+
return found ? { key: found.key, source: found.source === "env" ? "environment" : found.source } : void 0;
|
|
7449
|
+
}, "read"),
|
|
7450
|
+
write: /* @__PURE__ */ __name((origin, key) => credentials.write(account(origin), key, { signIn: true }), "write"),
|
|
7451
|
+
remove: /* @__PURE__ */ __name((origin) => credentials.remove(account(origin)), "remove")
|
|
7452
|
+
};
|
|
7453
|
+
}, "aiKeys");
|
|
7454
|
+
var aiNeedsKey = /* @__PURE__ */ __name((setting) => aiLeavesComputer(setting), "aiNeedsKey");
|
|
7455
|
+
var aiTakesKey = /* @__PURE__ */ __name((setting) => setting.provider !== "ollama", "aiTakesKey");
|
|
7456
|
+
var keyFor = /* @__PURE__ */ __name((setting, deps) => aiTakesKey(setting) ? aiKeys(deps.app, deps.env, deps.keyring).read(aiOrigin(setting))?.key : void 0, "keyFor");
|
|
7457
|
+
var gatewayFor = /* @__PURE__ */ __name((setting, deps, key) => modelGateway({
|
|
7458
|
+
resolve: /* @__PURE__ */ __name(() => aiTarget(setting), "resolve"),
|
|
7459
|
+
consent: /* @__PURE__ */ __name(() => true, "consent"),
|
|
7460
|
+
key: /* @__PURE__ */ __name(() => key, "key"),
|
|
7461
|
+
env: deps.env,
|
|
7462
|
+
...deps.fetch ? { fetch: deps.fetch } : {},
|
|
7463
|
+
...deps.signal ? { signal: deps.signal } : {}
|
|
7464
|
+
}), "gatewayFor");
|
|
7465
|
+
var aiLeavesComputer = /* @__PURE__ */ __name((setting) => !onThisComputer(aiBaseUrl(setting)), "aiLeavesComputer");
|
|
7466
|
+
var sharedModel = /* @__PURE__ */ __name((deps) => {
|
|
7467
|
+
const setting = readAiSetting(aiSettingPath(deps.env));
|
|
7468
|
+
if (!setting)
|
|
7469
|
+
return void 0;
|
|
7470
|
+
return { target: { ...aiTarget(setting), baseUrl: aiBaseUrl(setting) }, key: keyFor(setting, deps), setting };
|
|
7471
|
+
}, "sharedModel");
|
|
7472
|
+
var reasonOf = /* @__PURE__ */ __name((error) => {
|
|
7473
|
+
if (!(error instanceof CliError))
|
|
7474
|
+
return "ai.failed";
|
|
7475
|
+
if (error.code === "rate_limited")
|
|
7476
|
+
return "ai.rate-limited";
|
|
7477
|
+
const { reason, status } = error.details;
|
|
7478
|
+
if (reason === "model.key-rejected")
|
|
7479
|
+
return "ai.key-rejected";
|
|
7480
|
+
if (reason === "model.unreachable")
|
|
7481
|
+
return "ai.unreachable";
|
|
7482
|
+
if (reason === "model.empty-answer")
|
|
7483
|
+
return "ai.empty-answer";
|
|
7484
|
+
if (status === 402)
|
|
7485
|
+
return "ai.no-credit";
|
|
7486
|
+
if (status === 404)
|
|
7487
|
+
return "ai.model-unknown";
|
|
7488
|
+
if (typeof status === "number" && status >= 500)
|
|
7489
|
+
return "ai.provider-error";
|
|
7490
|
+
return "ai.failed";
|
|
7491
|
+
}, "reasonOf");
|
|
7492
|
+
var checkAi = /* @__PURE__ */ __name(async (deps) => {
|
|
7493
|
+
const setting = readAiSetting(aiSettingPath(deps.env));
|
|
7494
|
+
if (!setting)
|
|
7495
|
+
return { ok: false, reason: "ai.not-set", ms: null };
|
|
7496
|
+
const key = keyFor(setting, deps);
|
|
7497
|
+
if (aiNeedsKey(setting) && !key)
|
|
7498
|
+
return { ok: false, reason: "ai.key-missing", ms: null };
|
|
7499
|
+
const started = Date.now();
|
|
7500
|
+
try {
|
|
7501
|
+
await gatewayFor(setting, deps, key).complete({
|
|
7502
|
+
purpose: "check",
|
|
7503
|
+
system: "Reply with the word OK.",
|
|
7504
|
+
prompt: "OK?",
|
|
7505
|
+
// Reasoning models spend tokens before they answer; too low a cap reads as a broken setup.
|
|
7506
|
+
maxTokens: 2048
|
|
7507
|
+
});
|
|
7508
|
+
return { ok: true, reason: "ai.ok", ms: Date.now() - started };
|
|
7509
|
+
} catch (error) {
|
|
7510
|
+
return { ok: false, reason: reasonOf(error), ms: null };
|
|
7511
|
+
}
|
|
7512
|
+
}, "checkAi");
|
|
7513
|
+
|
|
7514
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.648.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.98.0_commander@15._22e948f6f1aa7f4572ea465a838ccfd1/node_modules/@wirecat/cli-core/dist/models/purpose.js
|
|
7515
|
+
var HOSTED = {
|
|
7516
|
+
openai: "https://api.openai.com/v1",
|
|
7517
|
+
anthropic: "https://api.anthropic.com"
|
|
7518
|
+
};
|
|
7519
|
+
var purposeModel = /* @__PURE__ */ __name((settings, purpose, deps) => {
|
|
7520
|
+
const configured = modelTarget(settings, purpose);
|
|
7521
|
+
if (configured) {
|
|
7522
|
+
const baseUrl = configured.baseUrl ?? HOSTED[configured.provider] ?? "";
|
|
7523
|
+
return {
|
|
7524
|
+
target: { ...configured, baseUrl },
|
|
7525
|
+
key: /* @__PURE__ */ __name(() => embeddingKeys(deps.app, deps.env, deps.keyring).read(configured.baseUrl === void 0 ? configured.provider : endpointKeyName(configured.baseUrl))?.key, "key")
|
|
7526
|
+
};
|
|
7527
|
+
}
|
|
7528
|
+
const provider = settings.models?.[purpose]?.provider ?? settings.models?.default?.provider;
|
|
7529
|
+
if (provider === "off")
|
|
7530
|
+
return void 0;
|
|
7531
|
+
const shared = sharedModel(deps);
|
|
7532
|
+
return shared ? { target: shared.target, key: /* @__PURE__ */ __name(() => shared.key, "key"), shared: shared.setting } : void 0;
|
|
7533
|
+
}, "purposeModel");
|
|
7534
|
+
|
|
7535
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.648.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.98.0_commander@15._22e948f6f1aa7f4572ea465a838ccfd1/node_modules/@wirecat/cli-core/dist/replies/consents.js
|
|
7350
7536
|
import { existsSync as existsSync7, readFileSync as readFileSync4 } from "node:fs";
|
|
7351
7537
|
import { join as join4 } from "node:path";
|
|
7352
7538
|
var shape = strictObject({
|
|
@@ -7371,19 +7557,21 @@ var mayModelReply = /* @__PURE__ */ __name((path, provider, chat) => {
|
|
|
7371
7557
|
return consent.provider === provider && !consent.deniedChats.includes(chat);
|
|
7372
7558
|
}, "mayModelReply");
|
|
7373
7559
|
|
|
7374
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7560
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.648.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.98.0_commander@15._22e948f6f1aa7f4572ea465a838ccfd1/node_modules/@wirecat/cli-core/dist/replies/rendering.js
|
|
7375
7561
|
var replyRenderer = /* @__PURE__ */ __name((app, profile, settings, env, warn, options = {
|
|
7376
7562
|
ai: true
|
|
7377
7563
|
}) => async (rule2, message, chat, now) => {
|
|
7564
|
+
const deps = { app, env, keyring: options.keyring };
|
|
7378
7565
|
let called;
|
|
7379
7566
|
const gateway = modelGateway({
|
|
7380
7567
|
signal: options.signal,
|
|
7568
|
+
env,
|
|
7381
7569
|
resolve: /* @__PURE__ */ __name((purpose) => {
|
|
7382
|
-
called =
|
|
7383
|
-
return called;
|
|
7570
|
+
called = purposeModel(settings(), purpose, deps);
|
|
7571
|
+
return called?.target;
|
|
7384
7572
|
}, "resolve"),
|
|
7385
7573
|
consent: /* @__PURE__ */ __name((_request, target) => mayModelReply(replyConsentPathFor(app, profile, env), replyModelIdentity(target.provider, target.baseUrl ?? ""), message.chatId), "consent"),
|
|
7386
|
-
key: /* @__PURE__ */ __name((
|
|
7574
|
+
key: /* @__PURE__ */ __name(() => called?.key(), "key")
|
|
7387
7575
|
});
|
|
7388
7576
|
if (options.signal?.aborted)
|
|
7389
7577
|
throw new CliError("cancelled", "reply rendering cancelled");
|
|
@@ -7405,9 +7593,8 @@ var replyRenderer = /* @__PURE__ */ __name((app, profile, settings, env, warn, o
|
|
|
7405
7593
|
});
|
|
7406
7594
|
if (options.signal?.aborted)
|
|
7407
7595
|
throw new CliError("cancelled", "reply rendering cancelled");
|
|
7408
|
-
const current =
|
|
7409
|
-
|
|
7410
|
-
if (!called || JSON.stringify(current) !== JSON.stringify(called) || !mayModelReply(replyConsentPathFor(app, profile, env), replyModelIdentity(called.provider, baseUrl), message.chatId)) {
|
|
7596
|
+
const current = purposeModel(settings(), "replies", deps)?.target;
|
|
7597
|
+
if (!called || JSON.stringify(current) !== JSON.stringify(called.target) || !mayModelReply(replyConsentPathFor(app, profile, env), replyModelIdentity(called.target.provider, called.target.baseUrl), message.chatId)) {
|
|
7411
7598
|
throw new CliError("permission_error", "reply model consent or configuration changed during rendering");
|
|
7412
7599
|
}
|
|
7413
7600
|
return result3;
|
|
@@ -7418,7 +7605,7 @@ var replyRenderer = /* @__PURE__ */ __name((app, profile, settings, env, warn, o
|
|
|
7418
7605
|
return result2;
|
|
7419
7606
|
}, "replyRenderer");
|
|
7420
7607
|
|
|
7421
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7608
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.648.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.98.0_commander@15._22e948f6f1aa7f4572ea465a838ccfd1/node_modules/@wirecat/cli-core/dist/replies/serve.js
|
|
7422
7609
|
var NOT_ALLOWED = "replies.send is not allow";
|
|
7423
7610
|
var NO_RULES = "no rules";
|
|
7424
7611
|
var ONLY_TASK = "opened a task, sent nothing";
|
|
@@ -7511,7 +7698,7 @@ var replyTo = /* @__PURE__ */ __name(async (deps, message) => {
|
|
|
7511
7698
|
return { skip: why };
|
|
7512
7699
|
}, "replyTo");
|
|
7513
7700
|
|
|
7514
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7701
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.648.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.98.0_commander@15._22e948f6f1aa7f4572ea465a838ccfd1/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-catch-up.js
|
|
7515
7702
|
var START_SYNC_DELAY_MS = 3e4;
|
|
7516
7703
|
var START_SYNC_BUDGET_MS = 5 * 6e4;
|
|
7517
7704
|
var START_SYNC_WINDOW_MS = 7 * 864e5;
|
|
@@ -7588,7 +7775,7 @@ var startSync = /* @__PURE__ */ __name(({ chats, newestHeld, fetch, note, warn,
|
|
|
7588
7775
|
};
|
|
7589
7776
|
}, "startSync");
|
|
7590
7777
|
|
|
7591
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7778
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.648.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.98.0_commander@15._22e948f6f1aa7f4572ea465a838ccfd1/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-members.js
|
|
7592
7779
|
var FIRST_FETCH_MS = 6e4;
|
|
7593
7780
|
var DAY_MS = 864e5;
|
|
7594
7781
|
var memberFetches = /* @__PURE__ */ __name(({ withStore, fetch, warn, firstMs = FIRST_FETCH_MS, everyMs = DAY_MS }) => {
|
|
@@ -7642,7 +7829,7 @@ var memberFetches = /* @__PURE__ */ __name(({ withStore, fetch, warn, firstMs =
|
|
|
7642
7829
|
};
|
|
7643
7830
|
}, "memberFetches");
|
|
7644
7831
|
|
|
7645
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7832
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.648.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.98.0_commander@15._22e948f6f1aa7f4572ea465a838ccfd1/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-notice.js
|
|
7646
7833
|
var record2 = /* @__PURE__ */ __name((context, app, severity, attributes) => recordLogFor(context.streams.diagnostic, app, { command: currentRun().command || "serve" })[severity](attributes), "record");
|
|
7647
7834
|
var noticeFor = /* @__PURE__ */ __name((context, app, severity = "warn") => ({ text, ...attributes }) => {
|
|
7648
7835
|
if (context.format === "pretty") {
|
|
@@ -7675,7 +7862,7 @@ var recordDiagnostics = /* @__PURE__ */ __name((context, app) => {
|
|
|
7675
7862
|
return context;
|
|
7676
7863
|
}, "recordDiagnostics");
|
|
7677
7864
|
|
|
7678
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7865
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.648.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.98.0_commander@15._22e948f6f1aa7f4572ea465a838ccfd1/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-outdated.js
|
|
7679
7866
|
import { existsSync as existsSync8, readFileSync as readFileSync5, realpathSync as realpathSync2 } from "node:fs";
|
|
7680
7867
|
import { dirname as dirname2, join as join5 } from "node:path";
|
|
7681
7868
|
var OUTDATED_CHECK_MS = 6e4;
|
|
@@ -7761,7 +7948,7 @@ var watchOutdated = /* @__PURE__ */ __name(({ check: check2, onOutdated, everyMs
|
|
|
7761
7948
|
};
|
|
7762
7949
|
}, "watchOutdated");
|
|
7763
7950
|
|
|
7764
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7951
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.648.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.98.0_commander@15._22e948f6f1aa7f4572ea465a838ccfd1/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-stems.js
|
|
7765
7952
|
var STEMS_EVERY_MS = 3e4;
|
|
7766
7953
|
var STEMS_SLICE_MS = 2e3;
|
|
7767
7954
|
var stemFills = /* @__PURE__ */ __name(({ withStore, warn, everyMs = STEMS_EVERY_MS, sliceMs = STEMS_SLICE_MS }) => {
|
|
@@ -7801,7 +7988,7 @@ var stemFills = /* @__PURE__ */ __name(({ withStore, warn, everyMs = STEMS_EVERY
|
|
|
7801
7988
|
};
|
|
7802
7989
|
}, "stemFills");
|
|
7803
7990
|
|
|
7804
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7991
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.648.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.98.0_commander@15._22e948f6f1aa7f4572ea465a838ccfd1/node_modules/@wirecat/cli-core/dist/render/messages.js
|
|
7805
7992
|
import { styleText } from "node:util";
|
|
7806
7993
|
var TIME_WIDTH = 8;
|
|
7807
7994
|
var INDENT = " ".repeat(TIME_WIDTH + 2);
|
|
@@ -7977,7 +8164,7 @@ var editedAt = /* @__PURE__ */ __name((message, options) => {
|
|
|
7977
8164
|
return day(edited) === day(message.timestamp) ? time : `${day(edited)} ${time}`;
|
|
7978
8165
|
}, "editedAt");
|
|
7979
8166
|
|
|
7980
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
8167
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.648.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.98.0_commander@15._22e948f6f1aa7f4572ea465a838ccfd1/node_modules/@wirecat/cli-core/dist/cli/messenger/message-items.js
|
|
7981
8168
|
var defined = /* @__PURE__ */ __name((value) => Object.fromEntries(Object.entries(value).filter(([, one]) => one !== void 0)), "defined");
|
|
7982
8169
|
var attachmentItem = /* @__PURE__ */ __name((attachment) => defined({
|
|
7983
8170
|
kind: attachment.kind,
|
|
@@ -7989,6 +8176,7 @@ var attachmentItem = /* @__PURE__ */ __name((attachment) => defined({
|
|
|
7989
8176
|
width: attachment.width,
|
|
7990
8177
|
height: attachment.height,
|
|
7991
8178
|
duration: attachment.duration,
|
|
8179
|
+
local_path: attachment.localPath,
|
|
7992
8180
|
contact: attachment.contact && defined({
|
|
7993
8181
|
name: attachment.contact.name,
|
|
7994
8182
|
first_name: attachment.contact.firstName,
|
|
@@ -8072,7 +8260,7 @@ var viewOf = /* @__PURE__ */ __name((context, messenger) => ({
|
|
|
8072
8260
|
locale: messenger.app.locale
|
|
8073
8261
|
}), "viewOf");
|
|
8074
8262
|
|
|
8075
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
8263
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.648.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.98.0_commander@15._22e948f6f1aa7f4572ea465a838ccfd1/node_modules/@wirecat/cli-core/dist/cli/messenger/watch-answers.js
|
|
8076
8264
|
var observed = /* @__PURE__ */ __name((value) => ({
|
|
8077
8265
|
value: value.value,
|
|
8078
8266
|
observed_at: value.observedAt,
|
|
@@ -8139,7 +8327,7 @@ var watchEventItem = /* @__PURE__ */ __name((value, account) => {
|
|
|
8139
8327
|
}
|
|
8140
8328
|
}, "watchEventItem");
|
|
8141
8329
|
|
|
8142
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
8330
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.648.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.98.0_commander@15._22e948f6f1aa7f4572ea465a838ccfd1/node_modules/@wirecat/cli-core/dist/cli/messenger/watch-command.js
|
|
8143
8331
|
var watchCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("watch"), {
|
|
8144
8332
|
output: { entity: "watch_item" },
|
|
8145
8333
|
effects: REMOTE_READ,
|
|
@@ -8294,7 +8482,7 @@ var describe = /* @__PURE__ */ __name((event, render) => {
|
|
|
8294
8482
|
}
|
|
8295
8483
|
}, "describe");
|
|
8296
8484
|
|
|
8297
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
8485
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.648.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.98.0_commander@15._22e948f6f1aa7f4572ea465a838ccfd1/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-command.js
|
|
8298
8486
|
var serveCommand = /* @__PURE__ */ __name((messenger) => {
|
|
8299
8487
|
const command = annotate(new Command("serve"), {
|
|
8300
8488
|
output: { entity: "serve_summary" },
|
|
@@ -8577,7 +8765,7 @@ var tasking = /* @__PURE__ */ __name((context, warn) => {
|
|
|
8577
8765
|
};
|
|
8578
8766
|
}, "tasking");
|
|
8579
8767
|
|
|
8580
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
8768
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.648.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.98.0_commander@15._22e948f6f1aa7f4572ea465a838ccfd1/node_modules/@wirecat/cli-core/dist/cli/messenger/store-tables-command.js
|
|
8581
8769
|
import { existsSync as existsSync9 } from "node:fs";
|
|
8582
8770
|
var PATH = "store tables list";
|
|
8583
8771
|
var STORE_TABLES_QUERY = {
|
|
@@ -8594,14 +8782,14 @@ var filterOf = /* @__PURE__ */ __name((words) => {
|
|
|
8594
8782
|
const kind = terms.get("kind");
|
|
8595
8783
|
return { ...name === void 0 ? {} : { name }, ...kind === void 0 ? {} : { kind } };
|
|
8596
8784
|
}, "filterOf");
|
|
8597
|
-
var storeTablesCommand = /* @__PURE__ */ __name((
|
|
8598
|
-
const tables = new Command("tables").description("the tables of the local
|
|
8785
|
+
var storeTablesCommand = /* @__PURE__ */ __name((owner) => {
|
|
8786
|
+
const tables = new Command("tables").description("the tables of the local store");
|
|
8599
8787
|
withQuery(annotate(tables.command("list"), {
|
|
8600
8788
|
effects: LOCAL_READ,
|
|
8601
8789
|
examples: [
|
|
8602
|
-
`${
|
|
8603
|
-
`${
|
|
8604
|
-
`${
|
|
8790
|
+
`${owner.app.command} store tables list`,
|
|
8791
|
+
`${owner.app.command} store tables list kind:data`,
|
|
8792
|
+
`${owner.app.command} store tables list --full --json`
|
|
8605
8793
|
]
|
|
8606
8794
|
}), 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) {
|
|
8607
8795
|
const filter = filterOf(words);
|
|
@@ -8620,7 +8808,7 @@ var storeTablesCommand = /* @__PURE__ */ __name((messenger) => {
|
|
|
8620
8808
|
return tables;
|
|
8621
8809
|
}, "storeTablesCommand");
|
|
8622
8810
|
|
|
8623
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
8811
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.648.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.98.0_commander@15._22e948f6f1aa7f4572ea465a838ccfd1/node_modules/@wirecat/cli-core/dist/cli/messenger/store-maintenance-command.js
|
|
8624
8812
|
var SEARCH_INDEXES = ["messages_fts", "chats_fts", "identities_fts"];
|
|
8625
8813
|
var WORD_INDEX = "message_words";
|
|
8626
8814
|
var schemaOf = /* @__PURE__ */ __name((database) => {
|
|
@@ -8705,27 +8893,52 @@ var storeSummary = /* @__PURE__ */ __name(async (env, { deep = false, command, v
|
|
|
8705
8893
|
}
|
|
8706
8894
|
}, "storeSummary");
|
|
8707
8895
|
var result = /* @__PURE__ */ __name((command, value, next = []) => renderAnswer(command, outputFor(command), itemOf(snakeKeys(value), { next })), "result");
|
|
8708
|
-
var
|
|
8896
|
+
var chatty = /* @__PURE__ */ __name((owner) => owner.provider !== void 0, "chatty");
|
|
8897
|
+
var archive = /* @__PURE__ */ __name((owner) => chatty(owner) ? "local archive" : "local store", "archive");
|
|
8898
|
+
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");
|
|
8899
|
+
var storeMaintenanceCommands = /* @__PURE__ */ __name((owner) => [
|
|
8709
8900
|
storeInfoCommand(),
|
|
8710
|
-
checkCommand(
|
|
8711
|
-
migrateCommand(
|
|
8712
|
-
reindexCommand(
|
|
8901
|
+
checkCommand(owner),
|
|
8902
|
+
migrateCommand(owner),
|
|
8903
|
+
reindexCommand(owner),
|
|
8713
8904
|
backupCommand(),
|
|
8714
|
-
restoreCommand(
|
|
8905
|
+
restoreCommand(owner),
|
|
8715
8906
|
decryptCommand(),
|
|
8716
|
-
repairCommand(
|
|
8717
|
-
resetCommand(
|
|
8907
|
+
repairCommand(owner),
|
|
8908
|
+
resetCommand(owner),
|
|
8718
8909
|
copiesCommand(),
|
|
8719
|
-
storeTablesCommand(
|
|
8720
|
-
storeRecoverCommand({ command:
|
|
8910
|
+
storeTablesCommand(owner),
|
|
8911
|
+
storeRecoverCommand({ command: owner.app.command, version: owner.app.version })
|
|
8721
8912
|
], "storeMaintenanceCommands");
|
|
8722
|
-
var
|
|
8723
|
-
|
|
8913
|
+
var EXAMPLES = {
|
|
8914
|
+
backup: "./backup.db",
|
|
8915
|
+
check: "",
|
|
8916
|
+
"copies delete": "messages_copy_1",
|
|
8917
|
+
decrypt: "./backup.enc --output ./restored.db",
|
|
8918
|
+
info: "",
|
|
8919
|
+
migrate: "",
|
|
8920
|
+
rebuild: "",
|
|
8921
|
+
repair: "--dry-run",
|
|
8922
|
+
reset: "",
|
|
8923
|
+
restore: "./backup.db"
|
|
8924
|
+
};
|
|
8925
|
+
var addStoreMaintenanceCommands = /* @__PURE__ */ __name((store, owner, profile) => {
|
|
8926
|
+
for (const command of storeMaintenanceCommands(owner))
|
|
8927
|
+
store.addCommand(command);
|
|
8928
|
+
for (const [path, args] of Object.entries(EXAMPLES)) {
|
|
8929
|
+
const command = commandAt(store, path);
|
|
8930
|
+
if (command)
|
|
8931
|
+
annotate(command, { examples: [`${owner.app.command} ${profile} store ${path} ${args}`.trimEnd()] });
|
|
8932
|
+
}
|
|
8933
|
+
return store;
|
|
8934
|
+
}, "addStoreMaintenanceCommands");
|
|
8935
|
+
var refuseWhileServing = /* @__PURE__ */ __name((command, owner) => {
|
|
8936
|
+
const serving = servingProfiles(owner.app, environmentOf(command).env ?? process.env);
|
|
8724
8937
|
if (serving.length > 0) {
|
|
8725
|
-
throw new CliError("validation_error", `${
|
|
8938
|
+
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`);
|
|
8726
8939
|
}
|
|
8727
8940
|
}, "refuseWhileServing");
|
|
8728
|
-
var repairCommand = /* @__PURE__ */ __name((
|
|
8941
|
+
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() {
|
|
8729
8942
|
const { renderer, format } = outputFor(this);
|
|
8730
8943
|
const { dryRun: dryRun2 } = this.opts();
|
|
8731
8944
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
@@ -8734,13 +8947,13 @@ var repairCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("
|
|
|
8734
8947
|
return;
|
|
8735
8948
|
}
|
|
8736
8949
|
if (!dryRun2)
|
|
8737
|
-
refuseWhileServing(this,
|
|
8950
|
+
refuseWhileServing(this, owner);
|
|
8738
8951
|
const fresh = await openCache(":memory:");
|
|
8739
8952
|
try {
|
|
8740
8953
|
const report = await reading(path, (database) => repairStore(database, fresh, { dryRun: dryRun2 === true }));
|
|
8741
8954
|
result(this, { path, ...report });
|
|
8742
8955
|
if (format === "pretty")
|
|
8743
|
-
for (const note of notesOf(report,
|
|
8956
|
+
for (const note of notesOf(report, owner.app.command))
|
|
8744
8957
|
renderer.note(note);
|
|
8745
8958
|
} finally {
|
|
8746
8959
|
fresh.close();
|
|
@@ -8774,7 +8987,7 @@ var copiesCommand = /* @__PURE__ */ __name(() => new Command("copies").descripti
|
|
|
8774
8987
|
const deleted = await reading(path, (database) => deleteCopy(database, name));
|
|
8775
8988
|
result(this, { path, deleted });
|
|
8776
8989
|
})), "copiesCommand");
|
|
8777
|
-
var checkCommand = /* @__PURE__ */ __name((
|
|
8990
|
+
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() {
|
|
8778
8991
|
const { renderer } = outputFor(this);
|
|
8779
8992
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8780
8993
|
if (!existsSync10(path)) {
|
|
@@ -8788,7 +9001,7 @@ var checkCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("c
|
|
|
8788
9001
|
result(this, { path, exists: true, ok: false, opens: false, error: messageOf2(error) });
|
|
8789
9002
|
return;
|
|
8790
9003
|
}
|
|
8791
|
-
const { command } =
|
|
9004
|
+
const { command } = owner.app;
|
|
8792
9005
|
const next = /* @__PURE__ */ new Map();
|
|
8793
9006
|
const step = /* @__PURE__ */ __name((id, args = {}) => {
|
|
8794
9007
|
if (!next.has(id))
|
|
@@ -8804,10 +9017,10 @@ var checkCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("c
|
|
|
8804
9017
|
step("store.reindex");
|
|
8805
9018
|
else if (stems && !stems.ready)
|
|
8806
9019
|
step("store.migrate");
|
|
8807
|
-
const behind = answer.chatsBehind.find((chat) => chat.provider ===
|
|
8808
|
-
if (behind &&
|
|
9020
|
+
const behind = answer.chatsBehind.find((chat) => chat.provider === owner.provider);
|
|
9021
|
+
if (behind && owner.history !== "store")
|
|
8809
9022
|
step("messages.sync");
|
|
8810
|
-
else if (behind && syncsOneChat(
|
|
9023
|
+
else if (behind && syncsOneChat(owner))
|
|
8811
9024
|
step("messages.sync", { chat: behind.chat });
|
|
8812
9025
|
result(this, answer, [...next.values()]);
|
|
8813
9026
|
if (answer.schema.version < SPEAKS) {
|
|
@@ -8822,7 +9035,7 @@ var checkCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("c
|
|
|
8822
9035
|
renderer.note(`${orphans} pointers name a row that is gone or a type the store does not know \u2014 see orphan_pointers`);
|
|
8823
9036
|
if (answer.vectors && answer.vectors.unused > 0)
|
|
8824
9037
|
renderer.note(`${answer.vectors.unused} vectors belong to no text the store still holds \u2014 \`${command} store rebuild\` drops them`);
|
|
8825
|
-
const older = answer.conversations.filter((chat) => chat.provider ===
|
|
9038
|
+
const older = answer.conversations.filter((chat) => chat.provider === owner.provider && !chat.current).length;
|
|
8826
9039
|
if (older > 0) {
|
|
8827
9040
|
renderer.note(`${older} chats' conversations were built by older rules \u2014 \`${command} conversations links rebuild --chat <chat>\``);
|
|
8828
9041
|
}
|
|
@@ -8925,19 +9138,19 @@ var chatsBehind = /* @__PURE__ */ __name((database) => database.prepare(`SELECT
|
|
|
8925
9138
|
held: row.held === null ? null : isoOf(row.held),
|
|
8926
9139
|
refreshed: isoOf(row.refreshed)
|
|
8927
9140
|
})), "chatsBehind");
|
|
8928
|
-
var migrateCommand = /* @__PURE__ */ __name((
|
|
9141
|
+
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() {
|
|
8929
9142
|
const { renderer } = outputFor(this);
|
|
8930
9143
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8931
9144
|
if (!existsSync10(path)) {
|
|
8932
9145
|
result(this, { path, exists: false });
|
|
8933
|
-
renderer.note(`no store yet \u2014
|
|
9146
|
+
renderer.note(`no store yet \u2014 ${createdBy(owner)}`);
|
|
8934
9147
|
return;
|
|
8935
9148
|
}
|
|
8936
9149
|
const answer = await reading(path, (database) => {
|
|
8937
9150
|
const from = schemaOf(database).version;
|
|
8938
9151
|
migrate(database, {
|
|
8939
|
-
command:
|
|
8940
|
-
version:
|
|
9152
|
+
command: owner.app.command,
|
|
9153
|
+
version: owner.app.version,
|
|
8941
9154
|
rollback: { store: path, warn: /* @__PURE__ */ __name((line) => renderer.warn(line), "warn") }
|
|
8942
9155
|
});
|
|
8943
9156
|
const { normalized, indexed, terms } = buildWordIndex(database, (note) => renderer.note(note));
|
|
@@ -8989,7 +9202,7 @@ var buildNoteIndex = /* @__PURE__ */ __name((database, note, { reset = false } =
|
|
|
8989
9202
|
note(`indexing ${pending} notes`);
|
|
8990
9203
|
return { notesIndexed: drainNoteIndex(database, stemmerCache()) };
|
|
8991
9204
|
}, "buildNoteIndex");
|
|
8992
|
-
var reindexCommand = /* @__PURE__ */ __name((
|
|
9205
|
+
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() {
|
|
8993
9206
|
const { renderer } = outputFor(this);
|
|
8994
9207
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
8995
9208
|
if (!existsSync10(path)) {
|
|
@@ -9034,6 +9247,9 @@ var backupCommand = /* @__PURE__ */ __name(() => destroysNothing(annotate(new Co
|
|
|
9034
9247
|
const { encrypt } = this.opts();
|
|
9035
9248
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
9036
9249
|
const target = resolve(file2);
|
|
9250
|
+
const { app, env } = environmentOf(this);
|
|
9251
|
+
if (app)
|
|
9252
|
+
refuseLockedOutput(target, app, env ?? process.env, "<file>");
|
|
9037
9253
|
if (!existsSync10(path))
|
|
9038
9254
|
throw new CliError("not_found", `no store at ${path} to back up`);
|
|
9039
9255
|
if (existsSync10(target))
|
|
@@ -9078,37 +9294,37 @@ var decryptCommand = /* @__PURE__ */ __name(() => annotate(new Command("decrypt"
|
|
|
9078
9294
|
await unsealFile(from, to, await passwordOf(this, { twice: false }));
|
|
9079
9295
|
result(this, { path: to, from, bytes: bytesOf2(to) });
|
|
9080
9296
|
}), "decryptCommand");
|
|
9081
|
-
var restoreCommand = /* @__PURE__ */ __name((
|
|
9297
|
+
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) {
|
|
9082
9298
|
const path = storePath(environmentOf(this).env ?? process.env);
|
|
9083
9299
|
const given = resolve(file2);
|
|
9084
9300
|
if (!existsSync10(given))
|
|
9085
9301
|
throw new CliError("not_found", `no file at ${given}`);
|
|
9086
|
-
refuseWhileServing(this,
|
|
9302
|
+
refuseWhileServing(this, owner);
|
|
9087
9303
|
if (!isSealed(given))
|
|
9088
|
-
return restoreFrom(this,
|
|
9304
|
+
return restoreFrom(this, owner, given, given);
|
|
9089
9305
|
const opened = `${path}.unsealing-${process.pid}`;
|
|
9090
9306
|
mkdirSync(dirname3(path), { recursive: true, mode: 448 });
|
|
9091
9307
|
try {
|
|
9092
9308
|
await unsealFile(given, opened, await passwordOf(this, { twice: false }));
|
|
9093
|
-
await restoreFrom(this,
|
|
9309
|
+
await restoreFrom(this, owner, opened, given);
|
|
9094
9310
|
} finally {
|
|
9095
9311
|
rmSync3(opened, { force: true });
|
|
9096
9312
|
}
|
|
9097
9313
|
}), "restoreCommand");
|
|
9098
|
-
var restoreFrom = /* @__PURE__ */ __name(async (command,
|
|
9314
|
+
var restoreFrom = /* @__PURE__ */ __name(async (command, owner, backup, given) => {
|
|
9099
9315
|
const { renderer } = outputFor(command);
|
|
9100
9316
|
const path = storePath(environmentOf(command).env ?? process.env);
|
|
9101
9317
|
if (existsSync10(path) && realpathSync3(backup) === realpathSync3(path)) {
|
|
9102
9318
|
throw new CliError("validation_error", `${backup} is the store itself`);
|
|
9103
9319
|
}
|
|
9104
9320
|
if (await isRollbackCopy(backup))
|
|
9105
|
-
return rollBackFrom(command,
|
|
9321
|
+
return rollBackFrom(command, owner, backup);
|
|
9106
9322
|
const schema = await backupSchema(backup);
|
|
9107
9323
|
const stamp = stampNow();
|
|
9108
9324
|
const kept = existsSync10(path) ? `${path}.before-restore-${stamp}` : null;
|
|
9109
9325
|
if (kept) {
|
|
9110
9326
|
const waitMs = environmentOf(command).storeLockWaitMs;
|
|
9111
|
-
await quiesce(path,
|
|
9327
|
+
await quiesce(path, owner, "restore", (message) => renderer.warn(message), waitMs);
|
|
9112
9328
|
} else
|
|
9113
9329
|
mkdirSync(dirname3(path), { recursive: true, mode: 448 });
|
|
9114
9330
|
const incoming = `${path}.restoring-${stamp}`;
|
|
@@ -9136,13 +9352,13 @@ var isRollbackCopy = /* @__PURE__ */ __name(async (file2) => {
|
|
|
9136
9352
|
return false;
|
|
9137
9353
|
}
|
|
9138
9354
|
}, "isRollbackCopy");
|
|
9139
|
-
var rollBackFrom = /* @__PURE__ */ __name(async (command,
|
|
9355
|
+
var rollBackFrom = /* @__PURE__ */ __name(async (command, owner, copy) => {
|
|
9140
9356
|
const { renderer } = outputFor(command);
|
|
9141
9357
|
const path = storePath(environmentOf(command).env ?? process.env);
|
|
9142
9358
|
if (!existsSync10(path))
|
|
9143
9359
|
throw new CliError("not_found", `no store at ${path} to roll back`);
|
|
9144
9360
|
const waitMs = environmentOf(command).storeLockWaitMs;
|
|
9145
|
-
await quiesce(path,
|
|
9361
|
+
await quiesce(path, owner, "restore", (message) => renderer.warn(message), waitMs);
|
|
9146
9362
|
const { database } = await openSqlite(path);
|
|
9147
9363
|
let rolled;
|
|
9148
9364
|
try {
|
|
@@ -9187,8 +9403,8 @@ var backupSchema = /* @__PURE__ */ __name(async (backup) => {
|
|
|
9187
9403
|
return schema;
|
|
9188
9404
|
}, "backupSchema");
|
|
9189
9405
|
var STORE_LOCK_WAIT_MS = 1e3;
|
|
9190
|
-
var quiesce = /* @__PURE__ */ __name(async (path,
|
|
9191
|
-
const { command } =
|
|
9406
|
+
var quiesce = /* @__PURE__ */ __name(async (path, owner, then, warn, waitMs = STORE_LOCK_WAIT_MS) => {
|
|
9407
|
+
const { command } = owner.app;
|
|
9192
9408
|
const files = [path, `${path}-wal`, `${path}-shm`].filter((file2) => existsSync10(file2)).map((file2) => realpathSync3(file2));
|
|
9193
9409
|
const holders = holdersOf(files);
|
|
9194
9410
|
if (holders === void 0) {
|
|
@@ -9210,21 +9426,21 @@ var quiesce = /* @__PURE__ */ __name(async (path, messenger, then, warn, waitMs
|
|
|
9210
9426
|
database.close();
|
|
9211
9427
|
}
|
|
9212
9428
|
}, "quiesce");
|
|
9213
|
-
var resetCommand = /* @__PURE__ */ __name((
|
|
9429
|
+
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 }) {
|
|
9214
9430
|
const { renderer } = outputFor(this);
|
|
9215
|
-
const { command } =
|
|
9431
|
+
const { command } = owner.app;
|
|
9216
9432
|
const env = environmentOf(this).env ?? process.env;
|
|
9217
9433
|
const path = storePath(env);
|
|
9218
9434
|
if (!existsSync10(path)) {
|
|
9219
9435
|
result(this, { path, exists: false, reset: false });
|
|
9220
|
-
renderer.note(`no store at ${path} \u2014 nothing to reset;
|
|
9436
|
+
renderer.note(`no store at ${path} \u2014 nothing to reset; ${createdBy(owner)}`);
|
|
9221
9437
|
return;
|
|
9222
9438
|
}
|
|
9223
9439
|
if (dryRun2) {
|
|
9224
|
-
result(this, await resetPreview(path,
|
|
9440
|
+
result(this, await resetPreview(path, owner, env, keep));
|
|
9225
9441
|
return;
|
|
9226
9442
|
}
|
|
9227
|
-
refuseWhileServing(this,
|
|
9443
|
+
refuseWhileServing(this, owner);
|
|
9228
9444
|
if (this.optsWithGlobals().yes !== true) {
|
|
9229
9445
|
const what = `this deletes the store at ${path} and starts an empty one, ${keep ? "after a backup beside it" : "with no backup"}`;
|
|
9230
9446
|
const answer = await answerOf(this, `${what}. Go ahead? [y/N] `);
|
|
@@ -9233,7 +9449,7 @@ var resetCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("r
|
|
|
9233
9449
|
if (!/^\s*y(es)?\s*$/i.test(answer))
|
|
9234
9450
|
throw new CliError("cancelled", "cancelled \u2014 the store is unchanged");
|
|
9235
9451
|
}
|
|
9236
|
-
await quiesce(path,
|
|
9452
|
+
await quiesce(path, owner, "reset", (message) => renderer.warn(message), environmentOf(this).storeLockWaitMs);
|
|
9237
9453
|
const backup = keep ? `${path}.backup-${stampNow()}` : null;
|
|
9238
9454
|
let backedUp = null;
|
|
9239
9455
|
if (backup) {
|
|
@@ -9259,10 +9475,10 @@ var resetCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("r
|
|
|
9259
9475
|
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`);
|
|
9260
9476
|
}), "resetCommand");
|
|
9261
9477
|
var STORE_PARTS2 = ["", "-wal", "-shm"];
|
|
9262
|
-
var resetPreview = /* @__PURE__ */ __name(async (path,
|
|
9478
|
+
var resetPreview = /* @__PURE__ */ __name(async (path, owner, env, keep) => {
|
|
9263
9479
|
const files = STORE_PARTS2.map((suffix) => `${path}${suffix}`).filter((file2) => existsSync10(file2));
|
|
9264
9480
|
const holders = holdersOf(files.map((file2) => realpathSync3(file2)));
|
|
9265
|
-
const serving = servingProfiles(
|
|
9481
|
+
const serving = servingProfiles(owner.app, env).length > 0;
|
|
9266
9482
|
const read = await readingOnly(path, (database) => ({
|
|
9267
9483
|
schema: schemaOf(database).version,
|
|
9268
9484
|
tables: emptiedTables(database)
|
|
@@ -9310,6 +9526,20 @@ export {
|
|
|
9310
9526
|
safeLiquid,
|
|
9311
9527
|
DRY_RUN_DAYS,
|
|
9312
9528
|
dryRun,
|
|
9529
|
+
AI_PROVIDERS,
|
|
9530
|
+
aiSettingPath,
|
|
9531
|
+
readAiSetting,
|
|
9532
|
+
writeAiSetting,
|
|
9533
|
+
aiSettingOf,
|
|
9534
|
+
aiBaseUrl,
|
|
9535
|
+
aiOrigin,
|
|
9536
|
+
aiImagesAllowed,
|
|
9537
|
+
aiKeys,
|
|
9538
|
+
aiTakesKey,
|
|
9539
|
+
aiLeavesComputer,
|
|
9540
|
+
sharedModel,
|
|
9541
|
+
checkAi,
|
|
9542
|
+
purposeModel,
|
|
9313
9543
|
replyConsentPathFor,
|
|
9314
9544
|
readReplyConsent,
|
|
9315
9545
|
writeReplyConsent,
|
|
@@ -9325,5 +9555,6 @@ export {
|
|
|
9325
9555
|
serveCommand,
|
|
9326
9556
|
storeSummary,
|
|
9327
9557
|
storeMaintenanceCommands,
|
|
9558
|
+
addStoreMaintenanceCommands,
|
|
9328
9559
|
buildStems
|
|
9329
9560
|
};
|