@wirecat/tg-cli 0.123.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 +47 -4
- package/dist/bin/tg.js +2 -2
- package/dist/bundle/{adapter-GAOG65O2.js → adapter-GEIZVMWU.js} +55 -53
- package/dist/bundle/{all-profiles-HLE6PHNI.js → all-profiles-EY4GJFWN.js} +10 -10
- package/dist/bundle/{anthropic-FZC4BS7T.js → anthropic-RIANJ7WM.js} +17 -10
- package/dist/bundle/{app-server-SHZNMV27.js → app-server-LW7WBFIF.js} +62 -52
- package/dist/bundle/{bot-api-LRS2KMDE.js → bot-api-FHIQ66OM.js} +54 -52
- package/dist/bundle/{bot-history-IJ7ZZKW5.js → bot-history-O34YZEFH.js} +18 -18
- package/dist/bundle/{bun-FACL53HM.js → bun-MJWD4VGV.js} +2 -2
- package/dist/bundle/{bun-sqlite-B2MD7RTL.js → bun-sqlite-LCHVO3OB.js} +6 -6
- package/dist/bundle/{chunk-3JISIGLP.js → chunk-2GFGZDWS.js} +2 -2
- package/dist/bundle/{chunk-EOUUI5FI.js → chunk-2NG4JPP7.js} +4 -4
- package/dist/bundle/{chunk-V4722KYX.js → chunk-2YLIVDWJ.js} +2 -2
- package/dist/bundle/chunk-3PLMMFP6.js +1068 -0
- package/dist/bundle/{chunk-Z5HHBTS5.js → chunk-3VVZFBE2.js} +23 -4
- package/dist/bundle/{chunk-XDL4L3OI.js → chunk-42R4YO4L.js} +3609 -1620
- package/dist/bundle/{chunk-3S6KZCZ7.js → chunk-4CIVGT4P.js} +57 -28
- package/dist/bundle/{chunk-QLXKWAET.js → chunk-4EGB7GSW.js} +87 -19
- package/dist/bundle/chunk-54JPEGQA.js +71 -0
- package/dist/bundle/chunk-5EL6E6PW.js +13 -0
- package/dist/bundle/{chunk-V23X3W2W.js → chunk-7AWJZ6NJ.js} +8 -8
- package/dist/bundle/{chunk-UB6J5HRW.js → chunk-A5RWKKBZ.js} +3 -3
- package/dist/bundle/{chunk-HJLTWT52.js → chunk-ASEBKZFY.js} +2 -2
- package/dist/bundle/{chunk-EISV5YWD.js → chunk-BV3HZYOX.js} +6959 -6230
- package/dist/bundle/{chunk-MFN5MSIL.js → chunk-CDSSKK5J.js} +3 -3
- package/dist/bundle/{chunk-7EFJHLKW.js → chunk-DFSLHF46.js} +1 -1
- package/dist/bundle/{chunk-E2Z4C6CQ.js → chunk-E66JBGZZ.js} +6 -6
- package/dist/bundle/{chunk-VUBZFMGP.js → chunk-E6VSARSU.js} +2 -2
- package/dist/bundle/{chunk-ZJPXRW65.js → chunk-F3GHTPAO.js} +4 -4
- package/dist/bundle/{chunk-SWGGYBCW.js → chunk-GUL6QLNI.js} +40 -21
- package/dist/bundle/{chunk-UBFDPLFQ.js → chunk-HEV23NIB.js} +6 -6
- package/dist/bundle/{chunk-EABZ2CUG.js → chunk-HSRO77SW.js} +34 -29
- package/dist/bundle/{chunk-ZOBRYIUG.js → chunk-I4JUKRW7.js} +2 -2
- package/dist/bundle/{chunk-QVMAZVSN.js → chunk-IK6XKMLL.js} +1 -1
- package/dist/bundle/{chunk-SNEJK4SN.js → chunk-ISGXVFA4.js} +4 -4
- package/dist/bundle/{chunk-KKMNMQMW.js → chunk-IVFUSI7G.js} +2 -2
- package/dist/bundle/{chunk-6FK2Z75N.js → chunk-KVJSCJGZ.js} +2 -2
- package/dist/bundle/{chunk-NYRAW4M5.js → chunk-LKMZ53GC.js} +4 -7
- package/dist/bundle/{chunk-B6G3TNN4.js → chunk-M4W4Y5YR.js} +132 -40
- package/dist/bundle/{chunk-BGUYYKS3.js → chunk-N5UM63JW.js} +343 -112
- package/dist/bundle/{chunk-OE5JMZSM.js → chunk-NL4COYPY.js} +9 -9
- package/dist/bundle/{chunk-3BUQXB7B.js → chunk-NQXVZ5WT.js} +15 -117
- package/dist/bundle/{chunk-DEMGDKCX.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-OOWE2O5U.js → chunk-OVDB5CQM.js} +1 -1
- package/dist/bundle/{chunk-PZQ2MQFX.js → chunk-PI4XXMPG.js} +6 -6
- package/dist/bundle/{chunk-MCPOZNWG.js → chunk-PJGOQSE5.js} +1 -1
- package/dist/bundle/{chunk-U5FILNK6.js → chunk-PP4ZBLS4.js} +69 -6
- package/dist/bundle/{chunk-LVGX7VTD.js → chunk-PZ6H65D6.js} +4 -4
- package/dist/bundle/{chunk-4DCFLHLN.js → chunk-QFV36CAH.js} +4 -4
- package/dist/bundle/{chunk-Q74XVJFT.js → chunk-QGCVQRHV.js} +1 -1
- package/dist/bundle/{chunk-QLB3BFSN.js → chunk-QK4T3VN7.js} +1 -1
- package/dist/bundle/{chunk-5IHYZ6ED.js → chunk-QWAMX6CN.js} +12 -12
- package/dist/bundle/{chunk-SCGCDLI7.js → chunk-RBV4M2TC.js} +1 -1
- package/dist/bundle/{chunk-6KT5BTWL.js → chunk-RHJHOOUL.js} +341 -184
- package/dist/bundle/{chunk-STPYSD6W.js → chunk-SGBH3D5D.js} +3 -3
- package/dist/bundle/{chunk-ADI5R2MM.js → chunk-UII3D3HR.js} +51 -51
- package/dist/bundle/{chunk-PAHSIORC.js → chunk-UP3J3YXH.js} +6 -6
- package/dist/bundle/{chunk-SMFUKHG2.js → chunk-UR62DZ7Q.js} +24 -9
- package/dist/bundle/{chunk-ZQ3WGGKK.js → chunk-VAKSXD4F.js} +13 -13
- package/dist/bundle/{chunk-WA7YED3Y.js → chunk-VGUWIHXD.js} +1 -1
- package/dist/bundle/chunk-VIIIC5LU.js +32 -0
- package/dist/bundle/{chunk-3P7HWXDJ.js → chunk-VMWJGUVV.js} +14 -5
- package/dist/bundle/{chunk-V4JEZFW5.js → chunk-W4LMTNN2.js} +2 -2
- package/dist/bundle/{chunk-ENEMZAIJ.js → chunk-WKOVQ4OU.js} +14 -12
- package/dist/bundle/{chunk-T5OO7VDT.js → chunk-WSLIXJET.js} +3798 -3401
- package/dist/bundle/{chunk-WSLTW6MI.js → chunk-XDHGM2Z7.js} +3 -3
- package/dist/bundle/{chunk-5R5HGV2J.js → chunk-XSGUG5WG.js} +4 -4
- package/dist/bundle/{chunk-RDKPKS2P.js → chunk-YQFO7WXQ.js} +2 -2
- package/dist/bundle/{chunk-VVRWH5VH.js → chunk-ZL5YG2WK.js} +14 -9
- package/dist/bundle/{chunk-FFHX7VKP.js → chunk-ZNICTHSC.js} +1 -1
- package/dist/bundle/{chunk-BAB3ALHZ.js → chunk-ZTMV5M3D.js} +27 -25
- package/dist/bundle/command-contract-UKOL455D.js +34 -0
- package/dist/bundle/{command-server-entry-5LKDRLEX.js → command-server-entry-K52OEKIO.js} +24 -22
- package/dist/bundle/{decode-L4DQDHXA.js → decode-OAE25LEJ.js} +5 -5
- package/dist/bundle/{dispatch-PQSCFHEX.js → dispatch-6GVTXIZ2.js} +8 -8
- package/dist/bundle/{echarts-6LES2JIV.js → echarts-EO4ZGKMN.js} +2 -2
- package/dist/bundle/{embed-T5MLKX75.js → embed-TB2AS4AT.js} +6 -6
- package/dist/bundle/{embedder-56NMRLC5.js → embedder-YKC42G6L.js} +9 -9
- package/dist/bundle/{entry-U5GV6Y46.js → entry-AB6FU7BN.js} +9 -8
- package/dist/bundle/{failure-BX5HJAQE.js → failure-CY7ACT6V.js} +2 -2
- package/dist/bundle/{first-run-ISQ52V3I.js → first-run-CMQZHDI5.js} +11 -11
- package/dist/bundle/first-screen-XZ73W3VE.js +32 -0
- package/dist/bundle/{instructions-CJEXDI7E.js → instructions-RM3IB6ID.js} +1 -1
- package/dist/bundle/{mcp-7KQUJNFN.js → mcp-M5YCSWJJ.js} +2 -2
- package/dist/bundle/{node-QLWTGZW7.js → node-D2PM62TA.js} +2 -2
- package/dist/bundle/{node-sqlite-X2C3RR2Q.js → node-sqlite-UK5DE525.js} +7 -7
- package/dist/bundle/{oauth-VP3KMHLX.js → oauth-SKRG67A2.js} +7 -7
- package/dist/bundle/{open-GLR5EUZS.js → open-XP3SY62D.js} +5 -5
- package/dist/bundle/{openai-6CDCJ5LQ.js → openai-Q3U46UPA.js} +21 -17
- package/dist/bundle/{process-7FABZ3T2.js → process-YJ4LHMJB.js} +1 -1
- package/dist/bundle/{program-KUIAHJDX.js → program-EEPEFKTR.js} +80 -63
- package/dist/bundle/{prompt-XPHIZMD2.js → prompt-WYTODP4U.js} +5 -5
- package/dist/bundle/{proxy-transport-IIB7ZXIS.js → proxy-transport-HJMQ5QFT.js} +5 -5
- package/dist/bundle/{recognize-FVFYI3XX.js → recognize-K2S5QQU2.js} +4 -4
- package/dist/bundle/{remote-3AMCG2P4.js → remote-7RSAJ3JC.js} +9 -7
- package/dist/bundle/{rerank-XV4E25ML.js → rerank-RJX77BKD.js} +7 -7
- package/dist/bundle/{serve-NVSZA4UN.js → serve-3E7NN3VW.js} +14 -14
- package/dist/bundle/server-ITHYDPWQ.js +62 -0
- package/dist/bundle/{server-MBMPHRJE.js → server-O3KU56A4.js} +36 -35
- package/dist/bundle/sqlite-runtime-RCS5WSG5.js +19 -0
- package/dist/bundle/{state-JBMB2QUR.js → state-PLWSPSAG.js} +6 -6
- package/dist/bundle/store-3FYLH53Z.js +276 -0
- package/dist/bundle/{store-T4SCYTY2.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-I7K4OR5Q.js +0 -265
- package/dist/bundle/chunk-PZJXQMSZ.js +0 -27
- package/dist/bundle/command-contract-HWSWHMO4.js +0 -33
- package/dist/bundle/first-screen-7L4AMZDO.js +0 -31
- package/dist/bundle/server-MHVGYRQZ.js +0 -61
- package/dist/bundle/store-maintenance-command-F7WQMTMP.js +0 -49
- /package/dist/bundle/{chunk-YVNHQFLC.js → chunk-HVJJWJYQ.js} +0 -0
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
-
const require = __bundleRequire(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
openSqlite
|
|
5
|
-
} from "./chunk-XDL4L3OI.js";
|
|
6
|
-
import {
|
|
7
|
-
__name
|
|
8
|
-
} from "./chunk-ZVVMGPBJ.js";
|
|
9
|
-
|
|
10
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.633.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._d745f308dd36458ab3f46a9ad7a22686/node_modules/@wirecat/cli-core/dist/store/damage.js
|
|
11
|
-
var DERIVED = /* @__PURE__ */ new Set(["mentions", "involvements", "embeddings"]);
|
|
12
|
-
var named = /* @__PURE__ */ __name((tables) => tables.length <= 5 ? tables.join(", ") : `${tables.slice(0, 5).join(", ")} and ${tables.length - 5} more`, "named");
|
|
13
|
-
var isDerivedTable = /* @__PURE__ */ __name((table, searchIndexes) => DERIVED.has(table) || table.startsWith("vector_index_") || searchIndexes.some((index) => table === index || table.startsWith(`${index}_`)), "isDerivedTable");
|
|
14
|
-
var WIRECAT_UNITS = ["memo-*", "mail-*", "tg-*", "max-*", "wirecat-*"];
|
|
15
|
-
var seen = /* @__PURE__ */ __name((mark) => `\`${mark.command}\` found the store damaged at ${mark.at} (${mark.error})`, "seen");
|
|
16
|
-
var journalSeen = /* @__PURE__ */ __name((store, { seen: seen2, command, at }) => {
|
|
17
|
-
const wal = `${store.replace(/^.*\//, "")}-wal`;
|
|
18
|
-
return seen2 === "shm-without-wal" ? `the store's journal file (${wal}) was missing when \`${command}\` opened the store at ${at}: another program deleted it, or a tool crashed while closing` : `the store's journal file (${wal}) was deleted or replaced by another program while \`${command}\` had the store open (${at})`;
|
|
19
|
-
}, "journalSeen");
|
|
20
|
-
var lossUnknown = /* @__PURE__ */ __name((lastOkAt, gone = false) => {
|
|
21
|
-
const since = lastOkAt ? `since the last deep check that passed (${lastOkAt})` : "since the store was made (no deep check that passed is on record)";
|
|
22
|
-
return `${gone ? "more rows may be gone" : "how many rows were lost is unknown"}: damage can take rows written ${since} without leaving a trace; a sync fetches again what the servers still hold`;
|
|
23
|
-
}, "lossUnknown");
|
|
24
|
-
var stopWriters = /* @__PURE__ */ __name((timers) => ({
|
|
25
|
-
command: timers?.length ? `systemctl --user stop ${timers.join(" ")}` : `systemctl --user stop ${WIRECAT_UNITS.map((unit) => `'${unit}'`).join(" ")}`,
|
|
26
|
-
why: "a tool that writes while the store is recovered damages the new file too",
|
|
27
|
-
destructive: false
|
|
28
|
-
}), "stopWriters");
|
|
29
|
-
var storeDamageReport = /* @__PURE__ */ __name(({ health, command, mark = null, journal = null, lastOkAt = null, holders = null, timers = null, sqlite3Usable = true }) => {
|
|
30
|
-
if (health.ok && !mark && !journal)
|
|
31
|
-
return null;
|
|
32
|
-
const indexNames = (health.searchIndexes ?? []).map((index) => index.name);
|
|
33
|
-
const badIndexes = (health.searchIndexes ?? []).filter((index) => !index.ok).map((index) => index.name);
|
|
34
|
-
const tables = (health.damagedTables ?? []).map((one) => one.table).filter((table) => table !== null);
|
|
35
|
-
const sources = tables.filter((table) => !isDerivedTable(table, indexNames));
|
|
36
|
-
const derived = [.../* @__PURE__ */ new Set([...tables.filter((table) => isDerivedTable(table, indexNames)), ...badIndexes])];
|
|
37
|
-
const unopened = health.error !== void 0;
|
|
38
|
-
const json = (health.invalidJson ?? []).map(({ table, column }) => `${table}.${column}`);
|
|
39
|
-
const damaged = !health.ok || mark !== null;
|
|
40
|
-
const folder = health.path.replace(/\/[^/]*$/, "");
|
|
41
|
-
const checked = !damaged ? `every page of the store reads, but ${journalSeen(health.path, journal)}; what was written into it may be lost` : health.ok ? `${seen(mark)}; the quick check reads too little to see it, and a deep check that passes clears it` : unopened ? `the store file cannot be opened: ${health.error}` : health.checked === "quick" ? "the store file's header or schema is damaged" : `the store file is damaged: ${health.problems ?? 0} problems` + (sources.length ? ` in the data of ${named(sources)}` : "") + (derived.length ? `${sources.length ? ", and" : " in"} the search data of ${named(derived)}` : "") + (json.length ? `; values that are not valid JSON in ${named(json)}` : "");
|
|
42
|
-
const whatHappened = mark && !health.ok ? `${checked}; ${seen(mark)}` : checked;
|
|
43
|
-
const impact = [
|
|
44
|
-
...sources.length ? [`some rows of ${named(sources)} cannot be read; a recovery keeps every row it can read and names the rest`] : [],
|
|
45
|
-
...derived.length ? [`searches may miss results or fail; ${named(derived)} hold nothing that is not elsewhere, and are rebuilt`] : [],
|
|
46
|
-
...json.length ? [`a read of a row with a broken JSON value fails ("malformed JSON"); a recovery clears those values`] : [],
|
|
47
|
-
...!damaged ? ["everything works; rows written while the journal was gone may be missing, and a sync fetches them again"] : mark ? [
|
|
48
|
-
"reads that do not touch a damaged page work; every command that writes the store refuses until it is recovered"
|
|
49
|
-
] : ["reads that do not touch a damaged page work; a write that touches one fails until the store is recovered"]
|
|
50
|
-
];
|
|
51
|
-
const likelyCauses = [
|
|
52
|
-
...journal ? [{ cause: journalSeen(health.path, journal), check: `ls -li --time-style=full-iso ${folder}/` }] : [],
|
|
53
|
-
...holders?.length ? [
|
|
54
|
-
{
|
|
55
|
-
cause: `two programs wrote the file without seeing each other: ${holders.map(({ name, pid }) => `${name} (process ${pid})`).join(", ")} still ${holders.length === 1 ? "has" : "have"} it open`,
|
|
56
|
-
check: `fuser -v ${health.path}`
|
|
57
|
-
}
|
|
58
|
-
] : [],
|
|
59
|
-
...damaged ? [
|
|
60
|
-
{
|
|
61
|
-
cause: "the computer lost power or crashed while a tool was writing",
|
|
62
|
-
check: `journalctl --user ${WIRECAT_UNITS.map((unit) => `-u '${unit}'`).join(" ")} --since -14d | grep -i -e malformed -e corrupt -e 'disk full'`
|
|
63
|
-
},
|
|
64
|
-
{ cause: "the disk filled up while a tool was writing", check: `df -h ${folder}` },
|
|
65
|
-
{
|
|
66
|
-
cause: "the file was copied, restored or synced while a tool had it open, or it sits in a synced or network folder",
|
|
67
|
-
check: `findmnt -T ${folder}`
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
cause: "a fault of the disk itself",
|
|
71
|
-
check: "journalctl -k --since -14d | grep -i -e 'I/O error' -e nvme -e ata"
|
|
72
|
-
}
|
|
73
|
-
] : []
|
|
74
|
-
];
|
|
75
|
-
const steps = [
|
|
76
|
-
stopWriters(timers),
|
|
77
|
-
...(holders ?? []).map(({ pid, name }) => ({
|
|
78
|
-
command: `kill ${pid}`,
|
|
79
|
-
why: `${name} (process ${pid}) has the store open`,
|
|
80
|
-
destructive: true
|
|
81
|
-
})),
|
|
82
|
-
...damaged && !sqlite3Usable ? [
|
|
83
|
-
{
|
|
84
|
-
command: "sudo apt install sqlite3",
|
|
85
|
-
why: "the recovery copies rows with the sqlite3 program, 3.43 or newer (on macOS: brew install sqlite)",
|
|
86
|
-
destructive: false
|
|
87
|
-
}
|
|
88
|
-
] : [],
|
|
89
|
-
...damaged ? [
|
|
90
|
-
{
|
|
91
|
-
command: `${command} store recover run`,
|
|
92
|
-
why: "copies every readable row into a new file and puts it in place of the store; the damaged file is kept beside it, and it prints the syncs that fetch again what was lost",
|
|
93
|
-
destructive: true
|
|
94
|
-
}
|
|
95
|
-
] : [],
|
|
96
|
-
{
|
|
97
|
-
command: `${command} store recover`,
|
|
98
|
-
why: "checks every page again; a check that passes lifts the damage mark",
|
|
99
|
-
destructive: false
|
|
100
|
-
}
|
|
101
|
-
];
|
|
102
|
-
return {
|
|
103
|
-
whatHappened,
|
|
104
|
-
likelyCauses,
|
|
105
|
-
impact,
|
|
106
|
-
externalDataSafe: "only this computer's copy is damaged: Telegram, MAX, WhatsApp, the mail servers and Google Drive keep their own data, so whatever is lost here can be fetched again by a sync",
|
|
107
|
-
lastOkAt,
|
|
108
|
-
loss: lossUnknown(lastOkAt),
|
|
109
|
-
steps
|
|
110
|
-
};
|
|
111
|
-
}, "storeDamageReport");
|
|
112
|
-
|
|
113
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.633.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._d745f308dd36458ab3f46a9ad7a22686/node_modules/@wirecat/cli-core/dist/store/health.js
|
|
114
|
-
import { existsSync, statSync } from "node:fs";
|
|
115
|
-
var JSON_COLUMNS = {
|
|
116
|
-
accounts: ["settings"],
|
|
117
|
-
account_identities: ["mail_signals"],
|
|
118
|
-
bot_updates: ["payload"],
|
|
119
|
-
documents: ["front_matter"],
|
|
120
|
-
emails: ["headers"],
|
|
121
|
-
meeting_participants: ["sessions"],
|
|
122
|
-
messages: ["mentions", "reply_to"],
|
|
123
|
-
proposed_actions: ["payload", "result"],
|
|
124
|
-
searches: ["params"],
|
|
125
|
-
tag_consolidations: ["source_member_ids", "survivor_member_ids"],
|
|
126
|
-
task_events: ["changes"]
|
|
127
|
-
};
|
|
128
|
-
var jsonColumns = /* @__PURE__ */ __name((database) => database.prepare(`SELECT m.name AS "table", c.name AS "column", c."notnull" AS required FROM sqlite_master m, pragma_table_info(m.name) c
|
|
129
|
-
WHERE m.type = 'table' AND m.sql NOT LIKE 'CREATE VIRTUAL%' ORDER BY 1, 2`).all().map((row) => ({ table: String(row.table), column: String(row.column), required: Number(row.required) === 1 })).filter(({ table, column }) => column === "metadata" || JSON_COLUMNS[table]?.includes(column)), "jsonColumns");
|
|
130
|
-
var invalidJson = /* @__PURE__ */ __name((database) => jsonColumns(database).map((one) => ({
|
|
131
|
-
...one,
|
|
132
|
-
rows: Number(database.prepare(`SELECT count(*) AS n FROM "${one.table}" WHERE "${one.column}" IS NOT NULL AND NOT json_valid("${one.column}")`).get()?.n)
|
|
133
|
-
})).filter(({ rows }) => rows > 0), "invalidJson");
|
|
134
|
-
var QUICK_CHECK_LIMIT = 1e4;
|
|
135
|
-
var QUICK_HEALTH_CHECKS = "the file header, its size against its page count, and the schema's own pages";
|
|
136
|
-
var FTS5 = /^\s*CREATE\s+VIRTUAL\s+TABLE\s+\S+\s+USING\s+fts5\s*\(/i;
|
|
137
|
-
var fts5Tables = /* @__PURE__ */ __name((database) => database.prepare("SELECT name, sql FROM sqlite_master WHERE type = 'table' AND sql LIKE 'CREATE VIRTUAL TABLE%' ORDER BY name").all().filter((row) => FTS5.test(String(row.sql))).map((row) => {
|
|
138
|
-
const sql = String(row.sql);
|
|
139
|
-
return { name: String(row.name), sql, external: /content\s*=\s*'[^']+'/i.test(sql) };
|
|
140
|
-
}), "fts5Tables");
|
|
141
|
-
var messageOf = /* @__PURE__ */ __name((error) => error instanceof Error ? error.message : String(error), "messageOf");
|
|
142
|
-
var bytesOf = /* @__PURE__ */ __name((path) => statSync(path, { throwIfNoEntry: false })?.size ?? 0, "bytesOf");
|
|
143
|
-
var damagedTables = /* @__PURE__ */ __name((database, lines) => {
|
|
144
|
-
const roots = new Map(database.prepare("SELECT rootpage, tbl_name FROM sqlite_master WHERE rootpage > 0").all().map((row) => [Number(row.rootpage), String(row.tbl_name)]));
|
|
145
|
-
const owners = new Map(database.prepare("SELECT name, tbl_name FROM sqlite_master WHERE type = 'index'").all().map((row) => [String(row.name), String(row.tbl_name)]));
|
|
146
|
-
const virtual = database.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND sql LIKE 'CREATE VIRTUAL TABLE%'").all().map((row) => String(row.name));
|
|
147
|
-
const ownerOf = /* @__PURE__ */ __name((table) => table === null ? null : virtual.find((name) => table.startsWith(`${name}_`)) ?? table, "ownerOf");
|
|
148
|
-
const tables = /* @__PURE__ */ new Map();
|
|
149
|
-
for (const raw of lines) {
|
|
150
|
-
const line = raw.replace(/^\*\*\* in database \w+ \*\*\*\s*/, "");
|
|
151
|
-
const tree = /^Tree (\d+) /.exec(line);
|
|
152
|
-
const column = /value in (\w+)\.\w+/.exec(line) ?? /^table (\w+): /.exec(line);
|
|
153
|
-
const index = /index (\w+)/.exec(line)?.[1];
|
|
154
|
-
const table = ownerOf(tree ? roots.get(Number(tree[1])) ?? null : column ? column[1] ?? null : index ? owners.get(index) ?? null : null);
|
|
155
|
-
const known = tables.get(table);
|
|
156
|
-
if (known)
|
|
157
|
-
known.problems += 1;
|
|
158
|
-
else
|
|
159
|
-
tables.set(table, { table, problems: 1, sample: line.slice(0, 200) });
|
|
160
|
-
}
|
|
161
|
-
return [...tables.values()].sort((a, b) => b.problems - a.problems);
|
|
162
|
-
}, "damagedTables");
|
|
163
|
-
var searchIndexHealth = /* @__PURE__ */ __name((database) => fts5Tables(database).map(({ name }) => {
|
|
164
|
-
try {
|
|
165
|
-
database.exec("BEGIN");
|
|
166
|
-
try {
|
|
167
|
-
database.exec(`INSERT INTO "${name}" ("${name}", rank) VALUES ('integrity-check', 0)`);
|
|
168
|
-
} finally {
|
|
169
|
-
database.exec("ROLLBACK");
|
|
170
|
-
}
|
|
171
|
-
return { name, ok: true };
|
|
172
|
-
} catch (error) {
|
|
173
|
-
return { name, ok: false, error: messageOf(error) };
|
|
174
|
-
}
|
|
175
|
-
}), "searchIndexHealth");
|
|
176
|
-
var pragmaLines = /* @__PURE__ */ __name((database, sql) => database.prepare(sql).all().flatMap((row) => String(Object.values(row)[0]).split("\n")), "pragmaLines");
|
|
177
|
-
var checkLines = /* @__PURE__ */ __name((database) => {
|
|
178
|
-
try {
|
|
179
|
-
return pragmaLines(database, `PRAGMA quick_check(${QUICK_CHECK_LIMIT})`);
|
|
180
|
-
} catch {
|
|
181
|
-
const tables = database.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND rootpage > 0 ORDER BY name").all().map((row) => String(row.name));
|
|
182
|
-
return tables.flatMap((table) => {
|
|
183
|
-
try {
|
|
184
|
-
return pragmaLines(database, `PRAGMA quick_check("${table}")`).filter((line) => line !== "ok");
|
|
185
|
-
} catch (error) {
|
|
186
|
-
return [`table ${table}: ${messageOf(error)}`];
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
}, "checkLines");
|
|
191
|
-
var quickHealth = /* @__PURE__ */ __name((database, path) => {
|
|
192
|
-
const pragma = /* @__PURE__ */ __name((name) => Number(Object.values(database.prepare(`PRAGMA ${name}`).get() ?? {})[0] ?? 0), "pragma");
|
|
193
|
-
const file = {
|
|
194
|
-
bytes: bytesOf(path),
|
|
195
|
-
pages: pragma("page_count"),
|
|
196
|
-
pageSize: pragma("page_size"),
|
|
197
|
-
freePages: pragma("freelist_count")
|
|
198
|
-
};
|
|
199
|
-
const schema = database.prepare("PRAGMA quick_check('sqlite_schema')").all().map((row) => String(Object.values(row)[0]));
|
|
200
|
-
const walFrames = existsSync(`${path}-wal`) && bytesOf(`${path}-wal`) > 0;
|
|
201
|
-
const sized = walFrames || file.bytes === file.pages * file.pageSize;
|
|
202
|
-
const problems = [
|
|
203
|
-
...schema.length === 1 && schema[0] === "ok" ? [] : schema,
|
|
204
|
-
...sized ? [] : [`the file holds ${file.bytes} bytes, its header says ${file.pages * file.pageSize}`]
|
|
205
|
-
];
|
|
206
|
-
return { file, problems };
|
|
207
|
-
}, "quickHealth");
|
|
208
|
-
var storeHealth = /* @__PURE__ */ __name(async (path, { deep = false } = {}) => {
|
|
209
|
-
const started = Date.now();
|
|
210
|
-
const checked = deep ? "deep" : "quick";
|
|
211
|
-
const done = /* @__PURE__ */ __name((health) => ({
|
|
212
|
-
path,
|
|
213
|
-
checked,
|
|
214
|
-
...health,
|
|
215
|
-
ms: Date.now() - started
|
|
216
|
-
}), "done");
|
|
217
|
-
let database;
|
|
218
|
-
try {
|
|
219
|
-
database = (await openSqlite(path, { readOnly: !deep })).database;
|
|
220
|
-
} catch (error) {
|
|
221
|
-
return done({ ok: false, error: messageOf(error) });
|
|
222
|
-
}
|
|
223
|
-
try {
|
|
224
|
-
const { file, problems } = quickHealth(database, path);
|
|
225
|
-
if (!deep) {
|
|
226
|
-
return done({
|
|
227
|
-
ok: problems.length === 0,
|
|
228
|
-
file,
|
|
229
|
-
...problems.length ? {
|
|
230
|
-
problems: problems.length,
|
|
231
|
-
damagedTables: [{ table: null, problems: problems.length, sample: problems[0] }]
|
|
232
|
-
} : {}
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
database.exec("PRAGMA busy_timeout = 30000");
|
|
236
|
-
const lines = checkLines(database);
|
|
237
|
-
const pagesOk = lines.length === 1 && lines[0] === "ok";
|
|
238
|
-
const indexes = searchIndexHealth(database);
|
|
239
|
-
const json = pagesOk ? invalidJson(database) : [];
|
|
240
|
-
return done({
|
|
241
|
-
ok: pagesOk && problems.length === 0 && indexes.every((index) => index.ok) && json.length === 0,
|
|
242
|
-
file,
|
|
243
|
-
problems: pagesOk ? 0 : lines.length,
|
|
244
|
-
damagedTables: pagesOk ? [] : damagedTables(database, lines),
|
|
245
|
-
searchIndexes: indexes,
|
|
246
|
-
invalidJson: json
|
|
247
|
-
});
|
|
248
|
-
} catch (error) {
|
|
249
|
-
return done({ ok: false, error: messageOf(error) });
|
|
250
|
-
} finally {
|
|
251
|
-
database.close();
|
|
252
|
-
}
|
|
253
|
-
}, "storeHealth");
|
|
254
|
-
|
|
255
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.633.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._d745f308dd36458ab3f46a9ad7a22686/node_modules/@wirecat/cli-core/dist/store/sqlite/document-transfer/snapshot.js
|
|
256
|
-
var MAX_BYTES = 16 * 1024 * 1024;
|
|
257
|
-
|
|
258
|
-
export {
|
|
259
|
-
lossUnknown,
|
|
260
|
-
storeDamageReport,
|
|
261
|
-
invalidJson,
|
|
262
|
-
QUICK_HEALTH_CHECKS,
|
|
263
|
-
fts5Tables,
|
|
264
|
-
storeHealth
|
|
265
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
-
const require = __bundleRequire(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
CliError
|
|
5
|
-
} from "./chunk-VUBZFMGP.js";
|
|
6
|
-
import {
|
|
7
|
-
__name
|
|
8
|
-
} from "./chunk-ZVVMGPBJ.js";
|
|
9
|
-
|
|
10
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.633.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.93.0_commander@15._d745f308dd36458ab3f46a9ad7a22686/node_modules/@wirecat/cli-core/dist/ports/app.js
|
|
11
|
-
var envName = /* @__PURE__ */ __name((app, name) => `${app.envPrefix}_${name}`, "envName");
|
|
12
|
-
var readOnlyLockOf = /* @__PURE__ */ __name((app, env) => {
|
|
13
|
-
const name = envName(app, "READ_ONLY");
|
|
14
|
-
const value = env[name];
|
|
15
|
-
return value === void 0 || value.trim() === "" || value === "0" ? void 0 : name;
|
|
16
|
-
}, "readOnlyLockOf");
|
|
17
|
-
var mailHolderVariable = /* @__PURE__ */ __name((app) => envName(app, "MAIL_HOLDER"), "mailHolderVariable");
|
|
18
|
-
var MESSENGER_CHANGE_REFUSAL = "send, react, change chats or change the account";
|
|
19
|
-
var readOnlyRefusal = /* @__PURE__ */ __name((lock, what) => new CliError("permission_error", `this process is read-only (${lock}) \u2014 it cannot ${what}`), "readOnlyRefusal");
|
|
20
|
-
|
|
21
|
-
export {
|
|
22
|
-
envName,
|
|
23
|
-
readOnlyLockOf,
|
|
24
|
-
mailHolderVariable,
|
|
25
|
-
MESSENGER_CHANGE_REFUSAL,
|
|
26
|
-
readOnlyRefusal
|
|
27
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
-
const require = __bundleRequire(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
SCHEMA_DIALECT,
|
|
5
|
-
commandContract,
|
|
6
|
-
commandPathOf,
|
|
7
|
-
findCommand,
|
|
8
|
-
outputOf
|
|
9
|
-
} from "./chunk-ZJPXRW65.js";
|
|
10
|
-
import "./chunk-6KT5BTWL.js";
|
|
11
|
-
import "./chunk-UB6J5HRW.js";
|
|
12
|
-
import "./chunk-QLB3BFSN.js";
|
|
13
|
-
import "./chunk-VVRWH5VH.js";
|
|
14
|
-
import "./chunk-STPYSD6W.js";
|
|
15
|
-
import "./chunk-PZJXQMSZ.js";
|
|
16
|
-
import "./chunk-DEMGDKCX.js";
|
|
17
|
-
import "./chunk-Z5HHBTS5.js";
|
|
18
|
-
import "./chunk-PAHSIORC.js";
|
|
19
|
-
import "./chunk-EOUUI5FI.js";
|
|
20
|
-
import "./chunk-YVNHQFLC.js";
|
|
21
|
-
import "./chunk-KKMNMQMW.js";
|
|
22
|
-
import "./chunk-3S6KZCZ7.js";
|
|
23
|
-
import "./chunk-SMFUKHG2.js";
|
|
24
|
-
import "./chunk-Y5E2WNWB.js";
|
|
25
|
-
import "./chunk-VUBZFMGP.js";
|
|
26
|
-
import "./chunk-ZVVMGPBJ.js";
|
|
27
|
-
export {
|
|
28
|
-
SCHEMA_DIALECT,
|
|
29
|
-
commandContract,
|
|
30
|
-
commandPathOf,
|
|
31
|
-
findCommand,
|
|
32
|
-
outputOf
|
|
33
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
-
const require = __bundleRequire(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
WIRECAT_TOOLS,
|
|
5
|
-
firstScreen,
|
|
6
|
-
installHelp
|
|
7
|
-
} from "./chunk-3BUQXB7B.js";
|
|
8
|
-
import "./chunk-2ABQZVK4.js";
|
|
9
|
-
import "./chunk-ZJPXRW65.js";
|
|
10
|
-
import "./chunk-6KT5BTWL.js";
|
|
11
|
-
import "./chunk-UB6J5HRW.js";
|
|
12
|
-
import "./chunk-QLB3BFSN.js";
|
|
13
|
-
import "./chunk-VVRWH5VH.js";
|
|
14
|
-
import "./chunk-STPYSD6W.js";
|
|
15
|
-
import "./chunk-PZJXQMSZ.js";
|
|
16
|
-
import "./chunk-DEMGDKCX.js";
|
|
17
|
-
import "./chunk-Z5HHBTS5.js";
|
|
18
|
-
import "./chunk-PAHSIORC.js";
|
|
19
|
-
import "./chunk-EOUUI5FI.js";
|
|
20
|
-
import "./chunk-YVNHQFLC.js";
|
|
21
|
-
import "./chunk-KKMNMQMW.js";
|
|
22
|
-
import "./chunk-3S6KZCZ7.js";
|
|
23
|
-
import "./chunk-SMFUKHG2.js";
|
|
24
|
-
import "./chunk-Y5E2WNWB.js";
|
|
25
|
-
import "./chunk-VUBZFMGP.js";
|
|
26
|
-
import "./chunk-ZVVMGPBJ.js";
|
|
27
|
-
export {
|
|
28
|
-
WIRECAT_TOOLS,
|
|
29
|
-
firstScreen,
|
|
30
|
-
installHelp
|
|
31
|
-
};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
-
const require = __bundleRequire(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
PER_RUN,
|
|
5
|
-
createServer,
|
|
6
|
-
envelope,
|
|
7
|
-
serveOverHttpUntilStopped,
|
|
8
|
-
serveOverStdio
|
|
9
|
-
} from "./chunk-ADI5R2MM.js";
|
|
10
|
-
import "./chunk-B6G3TNN4.js";
|
|
11
|
-
import "./chunk-BAB3ALHZ.js";
|
|
12
|
-
import "./chunk-QLXKWAET.js";
|
|
13
|
-
import "./chunk-7EFJHLKW.js";
|
|
14
|
-
import "./chunk-SNEJK4SN.js";
|
|
15
|
-
import "./chunk-OOWE2O5U.js";
|
|
16
|
-
import "./chunk-3JISIGLP.js";
|
|
17
|
-
import "./chunk-5D4AEUVA.js";
|
|
18
|
-
import "./chunk-EABZ2CUG.js";
|
|
19
|
-
import "./chunk-T5OO7VDT.js";
|
|
20
|
-
import "./chunk-I7K4OR5Q.js";
|
|
21
|
-
import "./chunk-ZQ3WGGKK.js";
|
|
22
|
-
import "./chunk-MFN5MSIL.js";
|
|
23
|
-
import "./chunk-U5FILNK6.js";
|
|
24
|
-
import "./chunk-5R5HGV2J.js";
|
|
25
|
-
import "./chunk-MCPOZNWG.js";
|
|
26
|
-
import "./chunk-V4JEZFW5.js";
|
|
27
|
-
import "./chunk-XDL4L3OI.js";
|
|
28
|
-
import "./chunk-V23X3W2W.js";
|
|
29
|
-
import "./chunk-Q74XVJFT.js";
|
|
30
|
-
import "./chunk-3P7HWXDJ.js";
|
|
31
|
-
import "./chunk-PZQ2MQFX.js";
|
|
32
|
-
import "./chunk-RX5CJ55S.js";
|
|
33
|
-
import "./chunk-D72URWJE.js";
|
|
34
|
-
import "./chunk-QVMAZVSN.js";
|
|
35
|
-
import "./chunk-UBFDPLFQ.js";
|
|
36
|
-
import "./chunk-FFHX7VKP.js";
|
|
37
|
-
import "./chunk-ZJPXRW65.js";
|
|
38
|
-
import "./chunk-6KT5BTWL.js";
|
|
39
|
-
import "./chunk-UB6J5HRW.js";
|
|
40
|
-
import "./chunk-QLB3BFSN.js";
|
|
41
|
-
import "./chunk-VVRWH5VH.js";
|
|
42
|
-
import "./chunk-STPYSD6W.js";
|
|
43
|
-
import "./chunk-PZJXQMSZ.js";
|
|
44
|
-
import "./chunk-DEMGDKCX.js";
|
|
45
|
-
import "./chunk-Z5HHBTS5.js";
|
|
46
|
-
import "./chunk-PAHSIORC.js";
|
|
47
|
-
import "./chunk-EOUUI5FI.js";
|
|
48
|
-
import "./chunk-YVNHQFLC.js";
|
|
49
|
-
import "./chunk-KKMNMQMW.js";
|
|
50
|
-
import "./chunk-3S6KZCZ7.js";
|
|
51
|
-
import "./chunk-SMFUKHG2.js";
|
|
52
|
-
import "./chunk-Y5E2WNWB.js";
|
|
53
|
-
import "./chunk-VUBZFMGP.js";
|
|
54
|
-
import "./chunk-ZVVMGPBJ.js";
|
|
55
|
-
export {
|
|
56
|
-
PER_RUN,
|
|
57
|
-
createServer,
|
|
58
|
-
envelope,
|
|
59
|
-
serveOverHttpUntilStopped,
|
|
60
|
-
serveOverStdio
|
|
61
|
-
};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
-
const require = __bundleRequire(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
buildStems,
|
|
5
|
-
storeMaintenanceCommands,
|
|
6
|
-
storeSummary
|
|
7
|
-
} from "./chunk-BGUYYKS3.js";
|
|
8
|
-
import "./chunk-EABZ2CUG.js";
|
|
9
|
-
import "./chunk-T5OO7VDT.js";
|
|
10
|
-
import "./chunk-I7K4OR5Q.js";
|
|
11
|
-
import "./chunk-ZQ3WGGKK.js";
|
|
12
|
-
import "./chunk-MFN5MSIL.js";
|
|
13
|
-
import "./chunk-U5FILNK6.js";
|
|
14
|
-
import "./chunk-2ABQZVK4.js";
|
|
15
|
-
import "./chunk-5R5HGV2J.js";
|
|
16
|
-
import "./chunk-MCPOZNWG.js";
|
|
17
|
-
import "./chunk-WSLTW6MI.js";
|
|
18
|
-
import "./chunk-V4JEZFW5.js";
|
|
19
|
-
import "./chunk-XDL4L3OI.js";
|
|
20
|
-
import "./chunk-V23X3W2W.js";
|
|
21
|
-
import "./chunk-Q74XVJFT.js";
|
|
22
|
-
import "./chunk-3P7HWXDJ.js";
|
|
23
|
-
import "./chunk-PZQ2MQFX.js";
|
|
24
|
-
import "./chunk-RX5CJ55S.js";
|
|
25
|
-
import "./chunk-D72URWJE.js";
|
|
26
|
-
import "./chunk-UBFDPLFQ.js";
|
|
27
|
-
import "./chunk-FFHX7VKP.js";
|
|
28
|
-
import "./chunk-6KT5BTWL.js";
|
|
29
|
-
import "./chunk-UB6J5HRW.js";
|
|
30
|
-
import "./chunk-QLB3BFSN.js";
|
|
31
|
-
import "./chunk-VVRWH5VH.js";
|
|
32
|
-
import "./chunk-STPYSD6W.js";
|
|
33
|
-
import "./chunk-PZJXQMSZ.js";
|
|
34
|
-
import "./chunk-DEMGDKCX.js";
|
|
35
|
-
import "./chunk-Z5HHBTS5.js";
|
|
36
|
-
import "./chunk-PAHSIORC.js";
|
|
37
|
-
import "./chunk-EOUUI5FI.js";
|
|
38
|
-
import "./chunk-YVNHQFLC.js";
|
|
39
|
-
import "./chunk-KKMNMQMW.js";
|
|
40
|
-
import "./chunk-3S6KZCZ7.js";
|
|
41
|
-
import "./chunk-SMFUKHG2.js";
|
|
42
|
-
import "./chunk-Y5E2WNWB.js";
|
|
43
|
-
import "./chunk-VUBZFMGP.js";
|
|
44
|
-
import "./chunk-ZVVMGPBJ.js";
|
|
45
|
-
export {
|
|
46
|
-
buildStems,
|
|
47
|
-
storeMaintenanceCommands,
|
|
48
|
-
storeSummary
|
|
49
|
-
};
|
|
File without changes
|