@wirecat/mail-cli 0.18.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/dist/bin/mail.js +2 -2
- package/dist/bundle/{all-profiles-4CVOXA5Y.js → all-profiles-DTUWUCQQ.js} +7 -6
- package/dist/bundle/{anthropic-5VIKYINO.js → anthropic-YJAEQSNT.js} +3 -3
- package/dist/bundle/{app-server-LTSQBDPF.js → app-server-3ZXSTBA3.js} +41 -40
- package/dist/bundle/{bun-C7DBRUW2.js → bun-34VBM7C5.js} +2 -2
- package/dist/bundle/{bun-sqlite-Y5JKT62B.js → bun-sqlite-GCT7ROCK.js} +2 -2
- package/dist/bundle/{chunk-A5OMARL4.js → chunk-2PPEDB67.js} +31 -29
- package/dist/bundle/{chunk-IANOK5SE.js → chunk-3DSYLE5N.js} +2 -2
- package/dist/bundle/{chunk-QPF4LTK5.js → chunk-3HDQVTND.js} +4 -4
- package/dist/bundle/{chunk-ZLH465EU.js → chunk-4FWJNIPH.js} +1 -1
- package/dist/bundle/{chunk-C4RUKMDT.js → chunk-4WIEVQ2Q.js} +8 -14
- package/dist/bundle/{chunk-SMS5YNPB.js → chunk-566MEXK5.js} +2 -2
- package/dist/bundle/{chunk-GRP67IQ4.js → chunk-72N26BQM.js} +24 -22
- package/dist/bundle/{chunk-6RO5RDNR.js → chunk-7XLOWYGD.js} +109 -6
- package/dist/bundle/{chunk-AOMSP4EI.js → chunk-AF62BPIW.js} +5 -5
- package/dist/bundle/{chunk-U43HUE35.js → chunk-B74SOC4R.js} +9 -20
- package/dist/bundle/{chunk-TVZ77ZOV.js → chunk-FTI73RLC.js} +2 -2
- package/dist/bundle/{chunk-EFP5NN7I.js → chunk-GAPQENMY.js} +2 -2
- package/dist/bundle/{chunk-N5VEJ3E7.js → chunk-HJ2CXDKJ.js} +130 -11
- package/dist/bundle/{chunk-P6WCG6X2.js → chunk-HN43G27G.js} +43 -27
- package/dist/bundle/{chunk-L3YX7A5M.js → chunk-HRRSTIGP.js} +4 -4
- package/dist/bundle/{chunk-NDJZQCF3.js → chunk-HSBGNVEL.js} +210 -171
- package/dist/bundle/{chunk-2NWOYXPJ.js → chunk-I2SDXWLR.js} +206 -56
- package/dist/bundle/{chunk-BMFPCW6Q.js → chunk-J2U6LUT5.js} +17 -3
- package/dist/bundle/{chunk-UXD5JMS5.js → chunk-J4UZXBEV.js} +1 -1
- package/dist/bundle/{chunk-OUGGAAXI.js → chunk-KMQAHDBM.js} +7539 -13576
- package/dist/bundle/{chunk-CPEN6BZZ.js → chunk-LF5XM4HE.js} +1 -1
- package/dist/bundle/chunk-LTXYJAJK.js +12211 -0
- package/dist/bundle/{chunk-7P4ICYJT.js → chunk-MD64ITYO.js} +1 -1
- package/dist/bundle/{chunk-WA3DQSAZ.js → chunk-MDDB7M7Z.js} +1 -1
- package/dist/bundle/{chunk-OLJDZTHB.js → chunk-NOVBK4SY.js} +12 -12
- package/dist/bundle/{chunk-MCR43SWG.js → chunk-O3M2S62X.js} +21 -13
- package/dist/bundle/{chunk-5S6Q3SWU.js → chunk-ODFHIXMA.js} +1 -1
- package/dist/bundle/{chunk-ZT2Y267T.js → chunk-OKO2Q6H6.js} +2 -2
- package/dist/bundle/{chunk-RQSF7X22.js → chunk-P2QJA7S5.js} +1 -1
- package/dist/bundle/{chunk-C5T5K7HW.js → chunk-P6FT6YYT.js} +17 -14
- package/dist/bundle/{chunk-RIO3TD3I.js → chunk-QE72KTS7.js} +1 -1
- package/dist/bundle/{chunk-JO3BIMYK.js → chunk-QPRXTLMD.js} +1 -1
- package/dist/bundle/{chunk-23HWKHPZ.js → chunk-QTMVGOSF.js} +352 -290
- package/dist/bundle/{chunk-SW2KERUB.js → chunk-R3WPMQYZ.js} +270 -153
- package/dist/bundle/{chunk-XGTW3GRX.js → chunk-RFB27ACZ.js} +2 -2
- package/dist/bundle/{chunk-HTFBXGJF.js → chunk-RPCKBXKN.js} +1 -1
- package/dist/bundle/{chunk-43I5XD7S.js → chunk-RT6SLZBI.js} +1 -1
- package/dist/bundle/{chunk-3W5H4TM7.js → chunk-RY7PBP4F.js} +71 -31
- package/dist/bundle/{chunk-BMGVKULS.js → chunk-SCIC2CJS.js} +4 -4
- package/dist/bundle/{chunk-SIYT2BBI.js → chunk-SFC46MP2.js} +250 -9
- package/dist/bundle/chunk-SYEICLTR.js +66 -0
- package/dist/bundle/{chunk-HFUS33UT.js → chunk-T2GQA2E4.js} +4 -1
- package/dist/bundle/{chunk-ITUC5WAV.js → chunk-T3DTYJTG.js} +1 -1
- package/dist/bundle/{chunk-OMKPALMX.js → chunk-TCCN5TON.js} +1 -1
- package/dist/bundle/{chunk-FLOOPXOT.js → chunk-V6OIIVH3.js} +10 -10
- package/dist/bundle/{chunk-ACLILULA.js → chunk-VDUGE6TH.js} +2 -2
- package/dist/bundle/{chunk-3YRE6DNM.js → chunk-VINSQR4X.js} +7 -7
- package/dist/bundle/{chunk-UEGABYXI.js → chunk-VQZCIDSO.js} +2 -2
- package/dist/bundle/{chunk-ERBEBORA.js → chunk-WBAA2X3E.js} +10 -10
- package/dist/bundle/{chunk-M7C4IGJ6.js → chunk-Z75WYAX6.js} +6 -6
- package/dist/bundle/{chunk-GLLLYACZ.js → chunk-Z7N4MGOQ.js} +5 -5
- package/dist/bundle/{chunk-YA2JPMYX.js → chunk-ZKLXSVIO.js} +1 -1
- package/dist/bundle/{chunk-DPSH46NO.js → chunk-ZZSHGCRC.js} +3 -3
- package/dist/bundle/{command-contract-Y3GIKCPB.js → command-contract-Y4ZQAJEC.js} +14 -13
- package/dist/bundle/{decode-WVIDLK4E.js → decode-BIOOL5E4.js} +2 -2
- package/dist/bundle/{dist-KGQWS3XL.js → dist-TJVIRLE5.js} +79 -17
- package/dist/bundle/{echarts-VMKACZBF.js → echarts-ECPGMKXO.js} +2 -2
- package/dist/bundle/{embed-EQINOOST.js → embed-F7JFSLHN.js} +3 -3
- package/dist/bundle/{embedder-LM52TDRN.js → embedder-U4G74HV3.js} +6 -6
- package/dist/bundle/{first-run-H4VXZAAF.js → first-run-JTYPUYQP.js} +5 -5
- package/dist/bundle/first-screen-W6RWTAU7.js +33 -0
- package/dist/bundle/{instructions-NLSME663.js → instructions-WNCGZ7OJ.js} +1 -1
- package/dist/bundle/mail.js +2 -2
- package/dist/bundle/{node-FGMSXLTA.js → node-UIRGGMGT.js} +2 -2
- package/dist/bundle/{node-sqlite-K3T3ZRBY.js → node-sqlite-4ZM7OPRF.js} +3 -3
- package/dist/bundle/{oauth-OJKJ6JLH.js → oauth-5RAJZPBW.js} +4 -4
- package/dist/bundle/{open-DCYIXHXS.js → open-7ORCHOAI.js} +2 -2
- package/dist/bundle/{openai-C4H4W57J.js → openai-XSJNXJA7.js} +10 -10
- package/dist/bundle/{process-MN4NSYGA.js → process-ZLO72UVZ.js} +1 -1
- package/dist/bundle/{program-ZZZOKWCX.js → program-PFVJDKM4.js} +1911 -1655
- package/dist/bundle/{prompt-ELEJUDAU.js → prompt-IDUPCUGM.js} +2 -2
- package/dist/bundle/{recognize-G2FVMI5M.js → recognize-OS3EZKIM.js} +1 -1
- package/dist/bundle/{remote-F4YVSEYM.js → remote-PF4LZR65.js} +4 -4
- package/dist/bundle/{rerank-7VM5R5N6.js → rerank-CQNZF3JI.js} +4 -4
- package/dist/bundle/{serve-A7NRFPRN.js → serve-Y2DDLGBT.js} +6 -6
- package/dist/bundle/server-I3IALQMC.js +65 -0
- package/dist/bundle/{server-7R2BEIRY.js → server-TVRT7YEY.js} +33 -32
- package/dist/bundle/{sqlite-runtime-4SKUB4EN.js → sqlite-runtime-5343C3OE.js} +3 -3
- package/dist/bundle/{state-S2FKK2XB.js → state-4GBTMPIV.js} +3 -3
- package/dist/bundle/{store-4HAARQVR.js → store-OLBLTQPT.js} +56 -13
- package/dist/bundle/{store-FLHO3UMA.js → store-QA6QJ5BB.js} +20 -11
- package/dist/bundle/store-maintenance-command-LB6CMGP4.js +55 -0
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +19 -4
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/session-start.d.ts.map +1 -1
- package/dist/commands/session-start.js +86 -11
- package/dist/commands/session-start.js.map +1 -1
- package/dist/mail/imap/errors.d.ts.map +1 -1
- package/dist/mail/imap/errors.js +14 -1
- package/dist/mail/imap/errors.js.map +1 -1
- package/dist/providers.d.ts +7 -0
- package/dist/providers.d.ts.map +1 -1
- package/dist/providers.js +5 -0
- package/dist/providers.js.map +1 -1
- package/dist/reasons.d.ts.map +1 -1
- package/dist/reasons.js +3 -0
- package/dist/reasons.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
- package/dist/bundle/chunk-KVSC657S.js +0 -656
- package/dist/bundle/first-screen-ZP74TJLK.js +0 -32
- package/dist/bundle/server-DFJA2HBO.js +0 -64
- package/dist/bundle/store-maintenance-command-BINJIQ6F.js +0 -54
|
@@ -8,12 +8,12 @@ import {
|
|
|
8
8
|
ACCESS_SECONDS,
|
|
9
9
|
REFRESH_SECONDS,
|
|
10
10
|
readStored
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-SCIC2CJS.js";
|
|
12
12
|
import {
|
|
13
13
|
__name
|
|
14
14
|
} from "./chunk-ZVVMGPBJ.js";
|
|
15
15
|
|
|
16
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
16
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/mcp/http/oauth.js
|
|
17
17
|
import { createHash, randomBytes, randomInt, timingSafeEqual } from "node:crypto";
|
|
18
18
|
import { chmodSync, mkdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
19
19
|
import { dirname } from "node:path";
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
__name
|
|
8
8
|
} from "./chunk-ZVVMGPBJ.js";
|
|
9
9
|
|
|
10
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
10
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/store/path.js
|
|
11
11
|
import { userInfo } from "node:os";
|
|
12
12
|
import { isAbsolute, join, relative, resolve } from "node:path";
|
|
13
13
|
var wirecatDirectory = /* @__PURE__ */ __name((env = process.env, platform) => resolvePaths({ appName: "WireCat", prefix: "WIRECAT", env, ...platform ? { platform } : {} }).state, "wirecatDirectory");
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
__name
|
|
5
5
|
} from "./chunk-ZVVMGPBJ.js";
|
|
6
6
|
|
|
7
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
7
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/store/sqlite/drizzle/shared-55XJMTPA.js
|
|
8
8
|
var entityKind = /* @__PURE__ */ Symbol.for("drizzle:entityKind");
|
|
9
9
|
var kindsByConstructor = /* @__PURE__ */ new WeakMap();
|
|
10
10
|
function collectKinds(ctor) {
|
|
@@ -23,16 +23,20 @@ import {
|
|
|
23
23
|
tagMemberIds,
|
|
24
24
|
thingOf,
|
|
25
25
|
write
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-KMQAHDBM.js";
|
|
27
27
|
import {
|
|
28
|
+
ADDED_PROVIDER,
|
|
28
29
|
filesAccountSql,
|
|
29
30
|
folderProviderOf,
|
|
30
31
|
folderProviderSql,
|
|
31
32
|
isDocumentAccountProvider
|
|
32
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-LTXYJAJK.js";
|
|
34
|
+
import {
|
|
35
|
+
damagedFile
|
|
36
|
+
} from "./chunk-SYEICLTR.js";
|
|
33
37
|
import {
|
|
34
38
|
fold
|
|
35
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-VINSQR4X.js";
|
|
36
40
|
import {
|
|
37
41
|
CliError
|
|
38
42
|
} from "./chunk-DALBYUPC.js";
|
|
@@ -40,13 +44,14 @@ import {
|
|
|
40
44
|
__name
|
|
41
45
|
} from "./chunk-ZVVMGPBJ.js";
|
|
42
46
|
|
|
43
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
47
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/store/damage.js
|
|
44
48
|
var DERIVED = /* @__PURE__ */ new Set(["mentions", "involvements", "embeddings"]);
|
|
45
49
|
var named = /* @__PURE__ */ __name((tables) => tables.length <= 5 ? tables.join(", ") : `${tables.slice(0, 5).join(", ")} and ${tables.length - 5} more`, "named");
|
|
46
50
|
var isDerivedTable = /* @__PURE__ */ __name((table, searchIndexes) => DERIVED.has(table) || table.startsWith("vector_index_") || searchIndexes.some((index) => table === index || table.startsWith(`${index}_`)), "isDerivedTable");
|
|
47
51
|
var WIRECAT_UNITS = ["memo-*", "mail-*", "tg-*", "max-*", "wirecat-*"];
|
|
48
|
-
var
|
|
49
|
-
|
|
52
|
+
var seen = /* @__PURE__ */ __name((mark) => `\`${mark.command}\` found the store damaged at ${mark.at} (${mark.error})`, "seen");
|
|
53
|
+
var explainDamage = /* @__PURE__ */ __name((health, command, mark = null) => {
|
|
54
|
+
if (health.ok && !mark)
|
|
50
55
|
return null;
|
|
51
56
|
const indexNames = (health.searchIndexes ?? []).map((index) => index.name);
|
|
52
57
|
const badIndexes = (health.searchIndexes ?? []).filter((index) => !index.ok).map((index) => index.name);
|
|
@@ -54,11 +59,14 @@ var explainDamage = /* @__PURE__ */ __name((health, command) => {
|
|
|
54
59
|
const sources = tables.filter((table) => !isDerivedTable(table, indexNames));
|
|
55
60
|
const derived = [.../* @__PURE__ */ new Set([...tables.filter((table) => isDerivedTable(table, indexNames)), ...badIndexes])];
|
|
56
61
|
const unopened = health.error !== void 0;
|
|
57
|
-
const
|
|
62
|
+
const json = (health.invalidJson ?? []).map(({ table, column }) => `${table}.${column}`);
|
|
63
|
+
const checked = 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)}` : "");
|
|
64
|
+
const what = mark && !health.ok ? `${checked}; ${seen(mark)}` : checked;
|
|
58
65
|
const impact = [
|
|
59
66
|
...sources.length ? [`some rows of ${named(sources)} cannot be read; a recovery keeps every row it can read and names the rest`] : [],
|
|
60
67
|
...derived.length ? [`searches may miss results or fail; ${named(derived)} hold nothing that is not elsewhere, and are rebuilt`] : [],
|
|
61
|
-
|
|
68
|
+
...json.length ? [`a read of a row with a broken JSON value fails ("malformed JSON"); a recovery clears those values`] : [],
|
|
69
|
+
mark ? "reads that do not touch a damaged page work; every command that writes the store refuses until it is recovered" : "reads that do not touch a damaged page work; a write that touches one fails until the store is recovered"
|
|
62
70
|
];
|
|
63
71
|
return {
|
|
64
72
|
what,
|
|
@@ -71,7 +79,7 @@ var explainDamage = /* @__PURE__ */ __name((health, command) => {
|
|
|
71
79
|
`journalctl --user ${WIRECAT_UNITS.map((unit) => `-u '${unit}'`).join(" ")} --since -14d | grep -i -e malformed -e corrupt -e 'disk full'`,
|
|
72
80
|
"journalctl -k --since -14d | grep -i -e 'I/O error' -e nvme -e ata",
|
|
73
81
|
`df -h ${health.path.replace(/\/[^/]*$/, "")}`,
|
|
74
|
-
...health.checked === "quick" ? [`${command} store recover`] : []
|
|
82
|
+
...health.checked === "quick" || health.ok ? [`${command} store recover`] : []
|
|
75
83
|
],
|
|
76
84
|
impact,
|
|
77
85
|
externalUnaffected: "only this computer's copy is damaged: Telegram, MAX, the mail servers and Google Drive keep their own data, so whatever is lost here can be fetched again by a sync",
|
|
@@ -83,11 +91,11 @@ var explainDamage = /* @__PURE__ */ __name((health, command) => {
|
|
|
83
91
|
};
|
|
84
92
|
}, "explainDamage");
|
|
85
93
|
|
|
86
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
94
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/store/document-transfer/index.js
|
|
87
95
|
import { realpathSync, statSync } from "node:fs";
|
|
88
96
|
import { resolve } from "node:path";
|
|
89
97
|
|
|
90
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
98
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/store/sqlite/document-transfer/people.js
|
|
91
99
|
var planPeople = /* @__PURE__ */ __name((database, snapshot, mappings, bindings, conflicts) => {
|
|
92
100
|
const creatable = /* @__PURE__ */ new Set();
|
|
93
101
|
let people = 0, identities = 0;
|
|
@@ -150,11 +158,11 @@ var copyPeople = /* @__PURE__ */ __name((database, snapshot, mappings, now) => {
|
|
|
150
158
|
}
|
|
151
159
|
}, "copyPeople");
|
|
152
160
|
|
|
153
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
161
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/store/document-transfer/digest.js
|
|
154
162
|
import { createHash } from "node:crypto";
|
|
155
163
|
var digest = /* @__PURE__ */ __name((value) => createHash("sha256").update(JSON.stringify(value)).digest("hex"), "digest");
|
|
156
164
|
|
|
157
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
165
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/store/sqlite/document-transfer/collection.js
|
|
158
166
|
var documentsKeyOf = /* @__PURE__ */ __name((collection) => {
|
|
159
167
|
const colon = collection.indexOf(":");
|
|
160
168
|
const provider = collection.slice(0, colon);
|
|
@@ -198,7 +206,7 @@ var currentCollection = /* @__PURE__ */ __name((row) => {
|
|
|
198
206
|
};
|
|
199
207
|
}, "currentCollection");
|
|
200
208
|
|
|
201
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
209
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/store/sqlite/document-transfer/plan.js
|
|
202
210
|
var planTransfer = /* @__PURE__ */ __name((database, snapshot, sourceKey, bindings) => {
|
|
203
211
|
const mappings = /* @__PURE__ */ new Map();
|
|
204
212
|
const missing = /* @__PURE__ */ new Set(), conflicts = /* @__PURE__ */ new Set();
|
|
@@ -365,7 +373,7 @@ var planTransfer = /* @__PURE__ */ __name((database, snapshot, sourceKey, bindin
|
|
|
365
373
|
};
|
|
366
374
|
}, "planTransfer");
|
|
367
375
|
|
|
368
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
376
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/store/sqlite/document-transfer/snapshot.js
|
|
369
377
|
var TRANSFER_TABLES = { document: "documents", note: "notes", memory: "memories", fact: "facts" };
|
|
370
378
|
var MAX_ENTITIES = 1e3;
|
|
371
379
|
var MAX_AUXILIARY = 1e4;
|
|
@@ -507,7 +515,7 @@ var transferSnapshot = /* @__PURE__ */ __name((database, collection) => read(dat
|
|
|
507
515
|
item.bot = { name: String(bot.name), kind: String(bot.kind) };
|
|
508
516
|
}
|
|
509
517
|
if (thing.type === "document") {
|
|
510
|
-
const doc = database.prepare(`SELECT a.provider,a.external_id AS account,a.name,d.external_id,d.body,d.content_hash,d.deleted_at FROM documents d JOIN accounts a ON a.id=d.account_id WHERE d.id=? AND ${filesAccountSql("a.provider")}`).get(thing.id);
|
|
518
|
+
const doc = database.prepare(`SELECT a.provider,a.external_id AS account,a.name,d.external_id,d.body,d.content_hash,d.deleted_at FROM documents d JOIN accounts a ON a.id=d.account_id WHERE d.id=? AND ${filesAccountSql("a.provider")} AND a.provider<>'${ADDED_PROVIDER}'`).get(thing.id);
|
|
511
519
|
if (doc) {
|
|
512
520
|
item.collection = collectionNameOf({ provider: doc.provider, external_id: doc.account, name: doc.name });
|
|
513
521
|
item.external_id = String(doc.external_id);
|
|
@@ -527,7 +535,7 @@ var transferSnapshot = /* @__PURE__ */ __name((database, collection) => read(dat
|
|
|
527
535
|
};
|
|
528
536
|
}), "transferSnapshot");
|
|
529
537
|
|
|
530
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
538
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/store/sqlite/document-transfer/apply.js
|
|
531
539
|
var providerHere = /* @__PURE__ */ __name(({ provider, name, settings }) => {
|
|
532
540
|
if (provider !== "folder" || String(name ?? "").startsWith("google-drive:"))
|
|
533
541
|
return provider ?? null;
|
|
@@ -699,7 +707,7 @@ var remapEntity = /* @__PURE__ */ __name((database, entity, id, mappings) => {
|
|
|
699
707
|
database.prepare(`UPDATE ${TRANSFER_TABLES[entity.kind]} SET ${columns.join(",")} WHERE id=?`).run(...values, id);
|
|
700
708
|
}, "remapEntity");
|
|
701
709
|
|
|
702
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
710
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/store/document-transfer/index.js
|
|
703
711
|
var locations = /* @__PURE__ */ __name((options) => {
|
|
704
712
|
for (const value of [options.source, options.destination, options.collection])
|
|
705
713
|
if (typeof value !== "string" || !value.trim())
|
|
@@ -752,6 +760,9 @@ var openPreviewTarget = /* @__PURE__ */ __name(async (path) => {
|
|
|
752
760
|
}, "openPreviewTarget");
|
|
753
761
|
var previewDocumentTransfer = /* @__PURE__ */ __name(async (options) => {
|
|
754
762
|
const location = locations(options);
|
|
763
|
+
return damagedFile([location.source, location.destination], () => previewWith(location, options));
|
|
764
|
+
}, "previewDocumentTransfer");
|
|
765
|
+
var previewWith = /* @__PURE__ */ __name(async (location, options) => {
|
|
755
766
|
const source = await openSource(location.source);
|
|
756
767
|
try {
|
|
757
768
|
const target = await openPreviewTarget(location.destination);
|
|
@@ -763,11 +774,14 @@ var previewDocumentTransfer = /* @__PURE__ */ __name(async (options) => {
|
|
|
763
774
|
} finally {
|
|
764
775
|
source.database.close();
|
|
765
776
|
}
|
|
766
|
-
}, "
|
|
777
|
+
}, "previewWith");
|
|
767
778
|
var applyDocumentTransfer = /* @__PURE__ */ __name(async (options) => {
|
|
768
779
|
if (!/^[a-f0-9]{64}$/.test(options.expected_fingerprint))
|
|
769
780
|
throw new CliError("validation_error", "apply requires the fingerprint returned by a transfer preview");
|
|
770
781
|
const location = locations(options);
|
|
782
|
+
return damagedFile([location.source, location.destination], () => applyWith(location, options));
|
|
783
|
+
}, "applyDocumentTransfer");
|
|
784
|
+
var applyWith = /* @__PURE__ */ __name(async (location, options) => {
|
|
771
785
|
const source = await openSource(location.source);
|
|
772
786
|
try {
|
|
773
787
|
const snapshot = transferSnapshot(source.database, options.collection);
|
|
@@ -793,10 +807,29 @@ var applyDocumentTransfer = /* @__PURE__ */ __name(async (options) => {
|
|
|
793
807
|
} finally {
|
|
794
808
|
source.database.close();
|
|
795
809
|
}
|
|
796
|
-
}, "
|
|
810
|
+
}, "applyWith");
|
|
797
811
|
|
|
798
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
812
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/store/health.js
|
|
799
813
|
import { existsSync, statSync as statSync2 } from "node:fs";
|
|
814
|
+
var JSON_COLUMNS = {
|
|
815
|
+
accounts: ["settings"],
|
|
816
|
+
account_identities: ["mail_signals"],
|
|
817
|
+
bot_updates: ["payload"],
|
|
818
|
+
documents: ["front_matter"],
|
|
819
|
+
emails: ["headers"],
|
|
820
|
+
meeting_participants: ["sessions"],
|
|
821
|
+
messages: ["mentions", "reply_to"],
|
|
822
|
+
proposed_actions: ["payload", "result"],
|
|
823
|
+
searches: ["params"],
|
|
824
|
+
tag_consolidations: ["source_member_ids", "survivor_member_ids"],
|
|
825
|
+
task_events: ["changes"]
|
|
826
|
+
};
|
|
827
|
+
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
|
|
828
|
+
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");
|
|
829
|
+
var invalidJson = /* @__PURE__ */ __name((database) => jsonColumns(database).map((one) => ({
|
|
830
|
+
...one,
|
|
831
|
+
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)
|
|
832
|
+
})).filter(({ rows }) => rows > 0), "invalidJson");
|
|
800
833
|
var QUICK_CHECK_LIMIT = 1e4;
|
|
801
834
|
var QUICK_HEALTH_CHECKS = "the file header, its size against its page count, and the schema's own pages";
|
|
802
835
|
var FTS5 = /^\s*CREATE\s+VIRTUAL\s+TABLE\s+\S+\s+USING\s+fts5\s*\(/i;
|
|
@@ -902,12 +935,14 @@ var storeHealth = /* @__PURE__ */ __name(async (path, { deep = false } = {}) =>
|
|
|
902
935
|
const lines = checkLines(database);
|
|
903
936
|
const pagesOk = lines.length === 1 && lines[0] === "ok";
|
|
904
937
|
const indexes = searchIndexHealth(database);
|
|
938
|
+
const json = pagesOk ? invalidJson(database) : [];
|
|
905
939
|
return done({
|
|
906
|
-
ok: pagesOk && problems.length === 0 && indexes.every((index) => index.ok),
|
|
940
|
+
ok: pagesOk && problems.length === 0 && indexes.every((index) => index.ok) && json.length === 0,
|
|
907
941
|
file,
|
|
908
942
|
problems: pagesOk ? 0 : lines.length,
|
|
909
943
|
damagedTables: pagesOk ? [] : damagedTables(database, lines),
|
|
910
|
-
searchIndexes: indexes
|
|
944
|
+
searchIndexes: indexes,
|
|
945
|
+
invalidJson: json
|
|
911
946
|
});
|
|
912
947
|
} catch (error) {
|
|
913
948
|
return done({ ok: false, error: messageOf(error) });
|
|
@@ -916,7 +951,7 @@ var storeHealth = /* @__PURE__ */ __name(async (path, { deep = false } = {}) =>
|
|
|
916
951
|
}
|
|
917
952
|
}, "storeHealth");
|
|
918
953
|
|
|
919
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
954
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/store/project-transfer/preview.js
|
|
920
955
|
var previewProjectAnnotationSnapshot = /* @__PURE__ */ __name(async (options) => {
|
|
921
956
|
if (!options || typeof options !== "object" || Array.isArray(options))
|
|
922
957
|
throw new CliError("validation_error", "project preview options are required");
|
|
@@ -930,15 +965,19 @@ var previewProjectAnnotationSnapshot = /* @__PURE__ */ __name(async (options) =>
|
|
|
930
965
|
if (typeof options.project !== "string" || !/^project:[1-9]\d*$/.test(options.project) || !Number.isSafeInteger(Number(options.project.slice(8))))
|
|
931
966
|
throw new CliError("validation_error", "project preview project is a project:<safe integer id> reference");
|
|
932
967
|
const budget = new SnapshotBudget(options.maxReadBytes ?? 4 * 1024 * 1024);
|
|
933
|
-
const
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
968
|
+
const target = options.target;
|
|
969
|
+
const project2 = options.project;
|
|
970
|
+
return damagedFile([target], async () => {
|
|
971
|
+
const context = await openStoreContext({ path: target, env: options.env, readOnly: true });
|
|
972
|
+
try {
|
|
973
|
+
return previewAnnotationSnapshot(context.database, Number(project2.slice(8)), snapshot, options.bindings, budget);
|
|
974
|
+
} finally {
|
|
975
|
+
context.database.close();
|
|
976
|
+
}
|
|
977
|
+
});
|
|
939
978
|
}, "previewProjectAnnotationSnapshot");
|
|
940
979
|
|
|
941
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
980
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/store/project-transfer/snapshot.js
|
|
942
981
|
var snapshotProjectAnnotations = /* @__PURE__ */ __name(async (options) => {
|
|
943
982
|
if (!options || typeof options !== "object" || Array.isArray(options))
|
|
944
983
|
throw new CliError("validation_error", "snapshot options are required");
|
|
@@ -963,6 +1002,7 @@ export {
|
|
|
963
1002
|
explainDamage,
|
|
964
1003
|
previewDocumentTransfer,
|
|
965
1004
|
applyDocumentTransfer,
|
|
1005
|
+
invalidJson,
|
|
966
1006
|
QUICK_HEALTH_CHECKS,
|
|
967
1007
|
fts5Tables,
|
|
968
1008
|
storeHealth,
|
|
@@ -5,15 +5,15 @@ import {
|
|
|
5
5
|
readLock,
|
|
6
6
|
releaseLock,
|
|
7
7
|
takeLock
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-VQZCIDSO.js";
|
|
9
9
|
import {
|
|
10
10
|
__name
|
|
11
11
|
} from "./chunk-ZVVMGPBJ.js";
|
|
12
12
|
|
|
13
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
13
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/mcp/http/state.js
|
|
14
14
|
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "node:fs";
|
|
15
15
|
|
|
16
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
16
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/mcp/http/activity.js
|
|
17
17
|
import { randomBytes } from "node:crypto";
|
|
18
18
|
import { chmodSync, existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
19
19
|
import { dirname } from "node:path";
|
|
@@ -86,7 +86,7 @@ var activityRecorder = /* @__PURE__ */ __name((path, now = Date.now) => {
|
|
|
86
86
|
};
|
|
87
87
|
}, "activityRecorder");
|
|
88
88
|
|
|
89
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
89
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/mcp/http/state.js
|
|
90
90
|
var ACCESS_SECONDS = 60 * 60;
|
|
91
91
|
var REFRESH_SECONDS = 30 * 24 * 60 * 60;
|
|
92
92
|
var readStored = /* @__PURE__ */ __name((path) => existsSync2(path) ? JSON.parse(readFileSync2(path, "utf8")) : { clients: [], tokens: [] }, "readStored");
|
|
@@ -2,13 +2,15 @@ import { createRequire as __bundleRequire } from "node:module";
|
|
|
2
2
|
const require = __bundleRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
LEVELS
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-HRRSTIGP.js";
|
|
6
6
|
import {
|
|
7
|
+
WORD_BODY,
|
|
7
8
|
looksLikeReference,
|
|
8
9
|
parseReference,
|
|
9
10
|
providerLabel,
|
|
10
|
-
providerNamed
|
|
11
|
-
|
|
11
|
+
providerNamed,
|
|
12
|
+
typedPhone
|
|
13
|
+
} from "./chunk-LTXYJAJK.js";
|
|
12
14
|
import {
|
|
13
15
|
resolvePaths,
|
|
14
16
|
writeSecurely
|
|
@@ -41,7 +43,7 @@ import {
|
|
|
41
43
|
__name
|
|
42
44
|
} from "./chunk-ZVVMGPBJ.js";
|
|
43
45
|
|
|
44
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
46
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/domain/ref-arguments.js
|
|
45
47
|
var TAKES = {
|
|
46
48
|
chat: "a chat: chat:<provider>/<account>/<chat>, its id or its title",
|
|
47
49
|
message: "a message: msg:<provider>/<account>/<chat>/<message>, or a chat and the message's id"
|
|
@@ -101,9 +103,9 @@ var ensureAccount = /* @__PURE__ */ __name(async (reference, scope, profilesOn)
|
|
|
101
103
|
throw wrongAccount(reference, scope, profiles);
|
|
102
104
|
}, "ensureAccount");
|
|
103
105
|
|
|
104
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
106
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/resolve.js
|
|
105
107
|
var isId = /* @__PURE__ */ __name((reference) => /^-?\d+$/.test(reference.trim()), "isId");
|
|
106
|
-
var foldName = /* @__PURE__ */ __name((name) => name.normalize("NFC").replace(/[\uFE0E\uFE0F\u200D]/g, "").toLowerCase(), "foldName");
|
|
108
|
+
var foldName = /* @__PURE__ */ __name((name) => name.normalize("NFC").replace(/[\uFE0E\uFE0F\u200D]/g, "").toLowerCase().replaceAll("\u0451", "\u0435"), "foldName");
|
|
107
109
|
var pickChat = /* @__PURE__ */ __name((reference, chats) => {
|
|
108
110
|
const wanted = foldName(reference.trim());
|
|
109
111
|
const matches = chats.filter((chat) => chat.title !== null && foldName(chat.title).includes(wanted));
|
|
@@ -146,7 +148,244 @@ ${lines}`, { candidates });
|
|
|
146
148
|
}, "ambiguous");
|
|
147
149
|
var isPresent = /* @__PURE__ */ __name((value) => value !== null && value !== void 0, "isPresent");
|
|
148
150
|
|
|
149
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
151
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/domain/vcard.js
|
|
152
|
+
import { createHash } from "node:crypto";
|
|
153
|
+
var MAX_ID = 512;
|
|
154
|
+
var AS_WORD = new RegExp(`^${WORD_BODY}$`);
|
|
155
|
+
var isVcard = /* @__PURE__ */ __name((text) => /^?\s*BEGIN:VCARD\b/i.test(text), "isVcard");
|
|
156
|
+
var isQuotedPrintable = /* @__PURE__ */ __name((line) => {
|
|
157
|
+
const colon = line.indexOf(":");
|
|
158
|
+
return /;(ENCODING=)?QUOTED-PRINTABLE\b/i.test(colon < 0 ? line : line.slice(0, colon));
|
|
159
|
+
}, "isQuotedPrintable");
|
|
160
|
+
var PROPERTY_START = /^([A-Za-z0-9-]+\.)?[A-Za-z][A-Za-z0-9-]*(;[^:]*)?:/;
|
|
161
|
+
var isSoft = /* @__PURE__ */ __name((line) => line !== void 0 && isQuotedPrintable(line) && line.endsWith("="), "isSoft");
|
|
162
|
+
var unfolded = /* @__PURE__ */ __name((text) => {
|
|
163
|
+
const lines = [];
|
|
164
|
+
for (const raw of text.replace(/^\uFEFF/, "").split(/\r\n|\r|\n/)) {
|
|
165
|
+
const last2 = lines.length - 1;
|
|
166
|
+
const previous = lines[last2];
|
|
167
|
+
const bounds = /^(BEGIN|END):/i.test(raw);
|
|
168
|
+
if (isSoft(previous) && !bounds && !PROPERTY_START.test(raw))
|
|
169
|
+
lines[last2] = previous.slice(0, -1) + raw.replace(/^[ \t]/, "");
|
|
170
|
+
else if (previous !== void 0 && /^[ \t]/.test(raw) && !bounds)
|
|
171
|
+
lines[last2] = previous + raw.slice(1);
|
|
172
|
+
else {
|
|
173
|
+
if (isSoft(previous))
|
|
174
|
+
lines[last2] = previous.slice(0, -1);
|
|
175
|
+
lines.push(raw);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
const last = lines.length - 1;
|
|
179
|
+
if (isSoft(lines[last]))
|
|
180
|
+
lines[last] = lines[last].slice(0, -1);
|
|
181
|
+
return lines.filter((line) => line.trim() !== "");
|
|
182
|
+
}, "unfolded");
|
|
183
|
+
var propertyOf = /* @__PURE__ */ __name((line) => {
|
|
184
|
+
let quoted = false;
|
|
185
|
+
let colon = -1;
|
|
186
|
+
for (let index = 0; index < line.length; index += 1) {
|
|
187
|
+
if (line[index] === '"')
|
|
188
|
+
quoted = !quoted;
|
|
189
|
+
else if (line[index] === ":" && !quoted) {
|
|
190
|
+
colon = index;
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (colon < 0)
|
|
195
|
+
return void 0;
|
|
196
|
+
const [head = "", ...rest] = line.slice(0, colon).split(";");
|
|
197
|
+
const params = /* @__PURE__ */ new Map();
|
|
198
|
+
for (const part of rest) {
|
|
199
|
+
const equals = part.indexOf("=");
|
|
200
|
+
const key = equals < 0 ? /^(QUOTED-PRINTABLE|BASE64|8BIT|7BIT|B)$/i.test(part) ? "ENCODING" : "TYPE" : part.slice(0, equals);
|
|
201
|
+
const values = (equals < 0 ? part : part.slice(equals + 1)).replaceAll('"', "").split(",");
|
|
202
|
+
params.set(key.toUpperCase(), [...params.get(key.toUpperCase()) ?? [], ...values.map((one) => one.toUpperCase())]);
|
|
203
|
+
}
|
|
204
|
+
const name = head.replace(/^[^.]*\./, "").toUpperCase();
|
|
205
|
+
return { name, params, value: line.slice(colon + 1) };
|
|
206
|
+
}, "propertyOf");
|
|
207
|
+
var encoder = new TextEncoder();
|
|
208
|
+
var decoded = /* @__PURE__ */ __name((property, report) => {
|
|
209
|
+
const encoding = property.params.get("ENCODING")?.[0];
|
|
210
|
+
if (encoding !== "QUOTED-PRINTABLE")
|
|
211
|
+
return property.value;
|
|
212
|
+
const bytes = [];
|
|
213
|
+
const { value } = property;
|
|
214
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
215
|
+
const hex = value.slice(index + 1, index + 3);
|
|
216
|
+
if (value[index] === "=" && /^[0-9A-F]{2}$/i.test(hex)) {
|
|
217
|
+
bytes.push(Number.parseInt(hex, 16));
|
|
218
|
+
index += 2;
|
|
219
|
+
} else
|
|
220
|
+
for (const byte of encoder.encode(value[index]))
|
|
221
|
+
bytes.push(byte);
|
|
222
|
+
}
|
|
223
|
+
const charset = property.params.get("CHARSET")?.[0]?.toLowerCase() ?? "utf-8";
|
|
224
|
+
try {
|
|
225
|
+
return new TextDecoder(charset).decode(new Uint8Array(bytes));
|
|
226
|
+
} catch {
|
|
227
|
+
report(`${property.name} names the unknown charset ${charset}: read as UTF-8`);
|
|
228
|
+
return new TextDecoder("utf-8").decode(new Uint8Array(bytes));
|
|
229
|
+
}
|
|
230
|
+
}, "decoded");
|
|
231
|
+
var components = /* @__PURE__ */ __name((value) => {
|
|
232
|
+
const parts = [""];
|
|
233
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
234
|
+
const char = value[index];
|
|
235
|
+
if (char === "\\" && index + 1 < value.length) {
|
|
236
|
+
const next = value[index + 1];
|
|
237
|
+
parts[parts.length - 1] += next === "n" || next === "N" ? "\n" : next;
|
|
238
|
+
index += 1;
|
|
239
|
+
} else if (char === ";")
|
|
240
|
+
parts.push("");
|
|
241
|
+
else
|
|
242
|
+
parts[parts.length - 1] += char;
|
|
243
|
+
}
|
|
244
|
+
return parts.map((part) => part.trim());
|
|
245
|
+
}, "components");
|
|
246
|
+
var textOf = /* @__PURE__ */ __name((property, report) => components(decoded(property, report)).join(";").trim(), "textOf");
|
|
247
|
+
var e164 = /* @__PURE__ */ __name((typed, region) => {
|
|
248
|
+
const text = typed.replace(/^tel:/i, "").replace(/;.*$/, "").trim();
|
|
249
|
+
const international = /^(\+|00)/.test(text);
|
|
250
|
+
if (!international && region === void 0)
|
|
251
|
+
return void 0;
|
|
252
|
+
const value = typedPhone(text, region === void 0 ? {} : { phoneCountries: [region] })?.value;
|
|
253
|
+
return value?.startsWith("+") ? value : void 0;
|
|
254
|
+
}, "e164");
|
|
255
|
+
var foldedName = /* @__PURE__ */ __name((name) => name.normalize("NFKC").toLowerCase().replace(/\s+/g, " ").trim(), "foldedName");
|
|
256
|
+
var hashed = /* @__PURE__ */ __name((prefix, parts) => `${prefix}${createHash("sha256").update(parts.join("\n")).digest("hex").slice(0, 32)}`, "hashed");
|
|
257
|
+
var organizationId = /* @__PURE__ */ __name((name) => {
|
|
258
|
+
const id = `org:${foldedName(name)}`;
|
|
259
|
+
return id.length <= MAX_ID ? id : hashed("org:", [foldedName(name)]);
|
|
260
|
+
}, "organizationId");
|
|
261
|
+
var titleWord = /* @__PURE__ */ __name((title) => {
|
|
262
|
+
const word = title.toLowerCase().trim().replace(/\s+/g, "-");
|
|
263
|
+
return AS_WORD.test(word) ? word : void 0;
|
|
264
|
+
}, "titleWord");
|
|
265
|
+
var nameOf = /* @__PURE__ */ __name((properties, report) => {
|
|
266
|
+
const full = properties.find(({ name }) => name === "FN");
|
|
267
|
+
const text = full ? textOf(full, report) : "";
|
|
268
|
+
if (text)
|
|
269
|
+
return text;
|
|
270
|
+
const structured = properties.find(({ name }) => name === "N");
|
|
271
|
+
if (!structured)
|
|
272
|
+
return void 0;
|
|
273
|
+
const [family = "", given = "", additional = ""] = components(decoded(structured, report));
|
|
274
|
+
return [given, additional, family].filter(Boolean).join(" ") || void 0;
|
|
275
|
+
}, "nameOf");
|
|
276
|
+
var SKIPPED = /* @__PURE__ */ new Set(["PHOTO", "LOGO", "SOUND", "KEY"]);
|
|
277
|
+
var cardsOf = /* @__PURE__ */ __name((text) => {
|
|
278
|
+
const cards = [];
|
|
279
|
+
const issues = [];
|
|
280
|
+
let card;
|
|
281
|
+
const isBound = /* @__PURE__ */ __name((property, name) => property.name === name && property.value.trim().toUpperCase() === "VCARD", "isBound");
|
|
282
|
+
for (const line of unfolded(text)) {
|
|
283
|
+
const property = propertyOf(line);
|
|
284
|
+
if (!property)
|
|
285
|
+
continue;
|
|
286
|
+
if (isBound(property, "BEGIN")) {
|
|
287
|
+
if (card) {
|
|
288
|
+
issues.push({ card: cards.length, message: "BEGIN:VCARD inside a card: the card ends there, unfinished" });
|
|
289
|
+
cards.push(card);
|
|
290
|
+
}
|
|
291
|
+
card = [];
|
|
292
|
+
} else if (isBound(property, "END")) {
|
|
293
|
+
if (card)
|
|
294
|
+
cards.push(card);
|
|
295
|
+
card = void 0;
|
|
296
|
+
} else if (card && !SKIPPED.has(property.name))
|
|
297
|
+
card.push(property);
|
|
298
|
+
}
|
|
299
|
+
if (card) {
|
|
300
|
+
issues.push({ card: cards.length, message: "the file ends inside a card, with no END:VCARD" });
|
|
301
|
+
cards.push(card);
|
|
302
|
+
}
|
|
303
|
+
return { cards, issues };
|
|
304
|
+
}, "cardsOf");
|
|
305
|
+
var envelopeOfVcard = /* @__PURE__ */ __name((text, { provider, account, batchId, region }) => {
|
|
306
|
+
const { cards, issues } = cardsOf(text);
|
|
307
|
+
const people = [];
|
|
308
|
+
const organizations = /* @__PURE__ */ new Map();
|
|
309
|
+
const seen = /* @__PURE__ */ new Set();
|
|
310
|
+
for (const [index, properties] of cards.entries()) {
|
|
311
|
+
const report = /* @__PURE__ */ __name((message) => {
|
|
312
|
+
if (!issues.some((one) => one.card === index && one.message === message))
|
|
313
|
+
issues.push({ card: index, message });
|
|
314
|
+
}, "report");
|
|
315
|
+
const values = /* @__PURE__ */ __name((wanted) => properties.filter(({ name: name2 }) => name2 === wanted).map((one) => textOf(one, report)).filter(Boolean), "values");
|
|
316
|
+
const name = nameOf(properties, report);
|
|
317
|
+
const phones = [];
|
|
318
|
+
const unread = [];
|
|
319
|
+
for (const typed of values("TEL")) {
|
|
320
|
+
const value = e164(typed, region);
|
|
321
|
+
if (value !== void 0) {
|
|
322
|
+
if (!phones.includes(value))
|
|
323
|
+
phones.push(value);
|
|
324
|
+
} else {
|
|
325
|
+
unread.push(typed);
|
|
326
|
+
issues.push({
|
|
327
|
+
card: index,
|
|
328
|
+
message: `${typed} has no country code${region === void 0 ? " and no region was given" : ` in ${region}`}: kept, not matched`
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
const emails = [...new Set(values("EMAIL").map((one) => one.replace(/^mailto:/i, "").toLowerCase()))];
|
|
333
|
+
if (name === void 0 && phones.length === 0 && unread.length === 0 && emails.length === 0) {
|
|
334
|
+
report("the card holds no name, number or address: left out");
|
|
335
|
+
continue;
|
|
336
|
+
}
|
|
337
|
+
const uid = values("UID")[0];
|
|
338
|
+
const externalId = uid === void 0 ? hashed("vcard:", [name ?? "", ...[...phones].sort(), ...emails.sort()]) : uid.length <= MAX_ID ? uid : hashed("vcard:", [uid]);
|
|
339
|
+
if (seen.has(externalId)) {
|
|
340
|
+
issues.push({ card: index, message: `another card of the file is ${externalId}: left out` });
|
|
341
|
+
continue;
|
|
342
|
+
}
|
|
343
|
+
seen.add(externalId);
|
|
344
|
+
const organization = properties.find(({ name: name2 }) => name2 === "ORG");
|
|
345
|
+
const organizationName = organization ? components(decoded(organization, report))[0] : void 0;
|
|
346
|
+
const title = values("TITLE")[0];
|
|
347
|
+
const relations = [];
|
|
348
|
+
if (organizationName) {
|
|
349
|
+
const id = organizationId(organizationName);
|
|
350
|
+
if (!organizations.has(id))
|
|
351
|
+
organizations.set(id, {
|
|
352
|
+
key: id,
|
|
353
|
+
type: "organization",
|
|
354
|
+
external_id: id,
|
|
355
|
+
operation: "upsert",
|
|
356
|
+
fields: { name: organizationName }
|
|
357
|
+
});
|
|
358
|
+
const as = title === void 0 ? void 0 : titleWord(title);
|
|
359
|
+
relations.push({ role: "member-of", type: "organization", external_id: id, ...as ? { as } : {} });
|
|
360
|
+
}
|
|
361
|
+
people.push({
|
|
362
|
+
key: `person:${externalId}`,
|
|
363
|
+
type: "person",
|
|
364
|
+
external_id: externalId,
|
|
365
|
+
operation: "upsert",
|
|
366
|
+
fields: {
|
|
367
|
+
...name === void 0 ? {} : { name },
|
|
368
|
+
...phones.length ? { phone: phones } : {},
|
|
369
|
+
...emails.length ? { email: emails } : {},
|
|
370
|
+
...unread.length ? { phone_unread: unread } : {},
|
|
371
|
+
...organizationName ? { organization: organizationName } : {},
|
|
372
|
+
...title === void 0 ? {} : { title }
|
|
373
|
+
},
|
|
374
|
+
...relations.length ? { relations } : {}
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
return {
|
|
378
|
+
envelope: {
|
|
379
|
+
schema_version: 1,
|
|
380
|
+
source: { provider, account, batch_id: batchId },
|
|
381
|
+
...region === void 0 ? {} : { options: { phone_region: region } },
|
|
382
|
+
records: [...organizations.values(), ...people]
|
|
383
|
+
},
|
|
384
|
+
issues
|
|
385
|
+
};
|
|
386
|
+
}, "envelopeOfVcard");
|
|
387
|
+
|
|
388
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/domain/formatting.js
|
|
150
389
|
var invalid = /* @__PURE__ */ __name(() => new CliError("validation_error", "the messenger formatter returned invalid text spans"), "invalid");
|
|
151
390
|
var validateFormattedText = /* @__PURE__ */ __name((formatted) => {
|
|
152
391
|
const { text, spans } = formatted;
|
|
@@ -206,7 +445,7 @@ var visibleFormattedText = /* @__PURE__ */ __name((formatted) => {
|
|
|
206
445
|
};
|
|
207
446
|
}, "visibleFormattedText");
|
|
208
447
|
|
|
209
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
448
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/moderation/check.js
|
|
210
449
|
var INVITE = /max\.ru\/join\/|(t|telegram)\.me\/(\+|joinchat\/)|tg:\/\/join/i;
|
|
211
450
|
var LINK = /https?:\/\/\S+/i;
|
|
212
451
|
var STRENGTH = { report: 0, delete: 1, remove: 2 };
|
|
@@ -394,7 +633,7 @@ var nextPoint = /* @__PURE__ */ __name((rows, found) => {
|
|
|
394
633
|
}, "nextPoint");
|
|
395
634
|
var someUndone = /* @__PURE__ */ __name((rows) => rows.some(undone), "someUndone");
|
|
396
635
|
|
|
397
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
636
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.608.0_@wirecat+cli-base@0.80.7_commander@15.0.0_esbuild@0.28.2_type_2045f8d992dff370989171c93240f8d7/node_modules/@wirecat/cli-core/dist/moderation/rules.js
|
|
398
637
|
import { existsSync, readFileSync } from "node:fs";
|
|
399
638
|
import { join } from "node:path";
|
|
400
639
|
var RULE_ACTIONS = ["report", "delete", "remove"];
|
|
@@ -545,6 +784,8 @@ export {
|
|
|
545
784
|
foldName,
|
|
546
785
|
pickChat,
|
|
547
786
|
pickPerson,
|
|
787
|
+
isVcard,
|
|
788
|
+
envelopeOfVcard,
|
|
548
789
|
validateFormattedText,
|
|
549
790
|
visibleFormattedText,
|
|
550
791
|
judge,
|