@wirecat/amo-cli 0.6.0 → 0.7.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 +17 -0
- package/README.md +2 -2
- package/contracts/wirecat.json +14 -0
- package/dist/amo/button.js +1 -1
- package/dist/amo/json.js +1 -1
- package/dist/amo/oauth.js +1 -2
- package/dist/amo/transport.js +1 -2
- package/dist/api-keys.js +1 -1
- package/dist/bin/amo.js +11 -11
- package/dist/bundle/amo.js +5 -183
- package/dist/bundle/{chunk-FYOPPKAN.js → chunk-3HWD4BKU.js} +4 -6
- package/dist/bundle/{chunk-GOCMJBEE.js → chunk-4EXURQQQ.js} +21 -19
- package/dist/bundle/chunk-AEWYRB6F.js +8 -0
- package/dist/bundle/{chunk-SWCJM3YD.js → chunk-GL7CRTHR.js} +3 -3
- package/dist/bundle/chunk-N2UB32VN.js +76 -0
- package/dist/bundle/{chunk-RNWUCAJJ.js → chunk-PVVSHDMQ.js} +7 -15
- package/dist/bundle/program-SQH3SPOW.js +2352 -0
- package/dist/bundle/{instructions-4H7UREH2.js → source-C65ZJUTW.js} +5 -6
- package/dist/bundle/store-SJ2TOUGU.js +12 -0
- package/dist/bundle/writer-I7GBI3VE.js +12 -0
- package/dist/commands/account.js +1 -1
- package/dist/commands/api.js +1 -3
- package/dist/commands/crm-shared.js +2 -3
- package/dist/commands/schedule.js +1 -1
- package/dist/commands/session.js +1 -3
- package/dist/commands/write.js +1 -2
- package/dist/config.js +1 -2
- package/dist/context.js +1 -2
- package/dist/crm/activities.js +1 -1
- package/dist/crm/records.js +1 -1
- package/dist/crm/source.js +1 -1
- package/dist/crm/writer.js +1 -1
- package/dist/identity.js +4 -0
- package/dist/program.js +1 -2
- package/dist/setup/flow.js +1 -1
- package/dist/store.js +1 -1
- package/dist/version.js +1 -1
- package/dist/whoami.js +1 -1
- package/package.json +3 -3
- package/scenarios/first-sync.md +13 -11
- package/scenarios/keep-in-sync.md +7 -6
- package/scenarios/safe-agent-writes.md +10 -9
- package/dist/amo/account.d.ts +0 -18
- package/dist/amo/account.d.ts.map +0 -1
- package/dist/amo/account.js.map +0 -1
- package/dist/amo/allow-list.d.ts +0 -31
- package/dist/amo/allow-list.d.ts.map +0 -1
- package/dist/amo/allow-list.js.map +0 -1
- package/dist/amo/button.d.ts +0 -53
- package/dist/amo/button.d.ts.map +0 -1
- package/dist/amo/button.js.map +0 -1
- package/dist/amo/errors.d.ts +0 -12
- package/dist/amo/errors.d.ts.map +0 -1
- package/dist/amo/errors.js.map +0 -1
- package/dist/amo/json.d.ts +0 -3
- package/dist/amo/json.d.ts.map +0 -1
- package/dist/amo/json.js.map +0 -1
- package/dist/amo/oauth.d.ts +0 -64
- package/dist/amo/oauth.d.ts.map +0 -1
- package/dist/amo/oauth.js.map +0 -1
- package/dist/amo/operation.d.ts +0 -45
- package/dist/amo/operation.d.ts.map +0 -1
- package/dist/amo/operation.js.map +0 -1
- package/dist/amo/operations.d.ts +0 -3
- package/dist/amo/operations.d.ts.map +0 -1
- package/dist/amo/operations.js.map +0 -1
- package/dist/amo/routes.d.ts +0 -67
- package/dist/amo/routes.d.ts.map +0 -1
- package/dist/amo/routes.js.map +0 -1
- package/dist/amo/transport.d.ts +0 -62
- package/dist/amo/transport.d.ts.map +0 -1
- package/dist/amo/transport.js.map +0 -1
- package/dist/api-keys.d.ts +0 -47
- package/dist/api-keys.d.ts.map +0 -1
- package/dist/api-keys.js.map +0 -1
- package/dist/bin/amo.d.ts +0 -3
- package/dist/bin/amo.d.ts.map +0 -1
- package/dist/bin/amo.js.map +0 -1
- package/dist/bundle/agent-VVACEKSX.js +0 -42
- package/dist/bundle/all-profiles-QNUKL4NA.js +0 -320
- package/dist/bundle/anthropic-PQN6MNP7.js +0 -90
- package/dist/bundle/app-server-Q2QEA7GP.js +0 -258
- package/dist/bundle/areas-27FRPBF3.js +0 -71
- package/dist/bundle/bun-F4M4KCNA.js +0 -169
- package/dist/bundle/bun-sqlite-P5IDBDVR.js +0 -75
- package/dist/bundle/chunk-22KAQPX7.js +0 -58
- package/dist/bundle/chunk-2JGNMZ55.js +0 -338
- package/dist/bundle/chunk-2VDHC7QO.js +0 -288
- package/dist/bundle/chunk-34ZOMVUK.js +0 -185
- package/dist/bundle/chunk-3J3EDSXF.js +0 -1939
- package/dist/bundle/chunk-3TYER5IK.js +0 -80
- package/dist/bundle/chunk-5NGLCDYQ.js +0 -106
- package/dist/bundle/chunk-5SQTHOBI.js +0 -12313
- package/dist/bundle/chunk-6GE36KUE.js +0 -360
- package/dist/bundle/chunk-6GZKY3HV.js +0 -3752
- package/dist/bundle/chunk-6OV2TRGF.js +0 -362
- package/dist/bundle/chunk-7CPIZFOE.js +0 -460
- package/dist/bundle/chunk-A5K2NU3K.js +0 -37780
- package/dist/bundle/chunk-ADLS6FVG.js +0 -24600
- package/dist/bundle/chunk-AEC4H5WZ.js +0 -259
- package/dist/bundle/chunk-APBEDWOE.js +0 -1718
- package/dist/bundle/chunk-AQ5RIOUE.js +0 -633
- package/dist/bundle/chunk-B7L5MSRP.js +0 -136
- package/dist/bundle/chunk-C7JPYWYQ.js +0 -77
- package/dist/bundle/chunk-D72URWJE.js +0 -532
- package/dist/bundle/chunk-DFDN6AUB.js +0 -21
- package/dist/bundle/chunk-DIZEHPS6.js +0 -1347
- package/dist/bundle/chunk-DNCLQPOM.js +0 -7
- package/dist/bundle/chunk-DPV53EZC.js +0 -206
- package/dist/bundle/chunk-DUPCDJ3W.js +0 -357
- package/dist/bundle/chunk-DWT24UVR.js +0 -388
- package/dist/bundle/chunk-DXWJORSY.js +0 -1703
- package/dist/bundle/chunk-DY3PLWIH.js +0 -332
- package/dist/bundle/chunk-DYWHAJRK.js +0 -1259
- package/dist/bundle/chunk-EH6ZEJGT.js +0 -932
- package/dist/bundle/chunk-EXRM3ML4.js +0 -76
- package/dist/bundle/chunk-FFER7KJI.js +0 -407
- package/dist/bundle/chunk-FIP2DG7W.js +0 -64
- package/dist/bundle/chunk-FTH6WGYO.js +0 -24
- package/dist/bundle/chunk-FWRLGIF6.js +0 -5304
- package/dist/bundle/chunk-G3N2RHGF.js +0 -738
- package/dist/bundle/chunk-G46PNDWL.js +0 -58
- package/dist/bundle/chunk-G6NY7LFB.js +0 -230
- package/dist/bundle/chunk-GRGCZSES.js +0 -1007
- package/dist/bundle/chunk-GVSKLZRD.js +0 -30
- package/dist/bundle/chunk-GZ7WBU5Y.js +0 -18
- package/dist/bundle/chunk-HN2LCLGT.js +0 -1068
- package/dist/bundle/chunk-HO4JGD4Q.js +0 -16
- package/dist/bundle/chunk-HOF7GQWW.js +0 -142
- package/dist/bundle/chunk-HUAHLO6N.js +0 -29
- package/dist/bundle/chunk-IDCZ4LWS.js +0 -150
- package/dist/bundle/chunk-IN3VL7UU.js +0 -560
- package/dist/bundle/chunk-ISQ23VKV.js +0 -123
- package/dist/bundle/chunk-JVBCQHCS.js +0 -80
- package/dist/bundle/chunk-K5W7YEHB.js +0 -9541
- package/dist/bundle/chunk-KAFSS35C.js +0 -193
- package/dist/bundle/chunk-KLRCTMES.js +0 -100
- package/dist/bundle/chunk-KYRYD4CR.js +0 -38
- package/dist/bundle/chunk-LBZSURLL.js +0 -798
- package/dist/bundle/chunk-LC7ZD2RW.js +0 -92
- package/dist/bundle/chunk-LH6FJYMO.js +0 -334
- package/dist/bundle/chunk-LJKINNWC.js +0 -209
- package/dist/bundle/chunk-M36XP74N.js +0 -86
- package/dist/bundle/chunk-MNPGZCKE.js +0 -361
- package/dist/bundle/chunk-MRPMORLH.js +0 -353
- package/dist/bundle/chunk-NNREILWP.js +0 -189
- package/dist/bundle/chunk-NSOY4FMN.js +0 -159
- package/dist/bundle/chunk-OEEWVKJX.js +0 -53
- package/dist/bundle/chunk-OGJFDKDL.js +0 -161
- package/dist/bundle/chunk-PATZAYFZ.js +0 -453
- package/dist/bundle/chunk-PCR6GFNP.js +0 -1171
- package/dist/bundle/chunk-PL5P7UKW.js +0 -25216
- package/dist/bundle/chunk-Q4MH2O5E.js +0 -108
- package/dist/bundle/chunk-QFOP3KUP.js +0 -2603
- package/dist/bundle/chunk-QQRJEWKB.js +0 -1197
- package/dist/bundle/chunk-S6JG4YUH.js +0 -72
- package/dist/bundle/chunk-SDVUGWD7.js +0 -614
- package/dist/bundle/chunk-SEFE6PGL.js +0 -218
- package/dist/bundle/chunk-SYRDEMQE.js +0 -68141
- package/dist/bundle/chunk-SYYQZDHJ.js +0 -95
- package/dist/bundle/chunk-T3W4V4A6.js +0 -63
- package/dist/bundle/chunk-TCT5D2X2.js +0 -6848
- package/dist/bundle/chunk-TES7MB6I.js +0 -82
- package/dist/bundle/chunk-TXDR6YSF.js +0 -23
- package/dist/bundle/chunk-TY7NDMFY.js +0 -46
- package/dist/bundle/chunk-U6XPWCWM.js +0 -133
- package/dist/bundle/chunk-UFKC7TIX.js +0 -28404
- package/dist/bundle/chunk-UNWF3TH5.js +0 -274
- package/dist/bundle/chunk-W3BOR6AT.js +0 -2333
- package/dist/bundle/chunk-WIHN3ELW.js +0 -2793
- package/dist/bundle/chunk-X76RS6JO.js +0 -1043
- package/dist/bundle/chunk-Y5E2WNWB.js +0 -35
- package/dist/bundle/chunk-YF3S26TS.js +0 -4172
- package/dist/bundle/chunk-ZCQ4H7CA.js +0 -54
- package/dist/bundle/chunk-ZOZV32IR.js +0 -170
- package/dist/bundle/chunk-ZTKHXDEU.js +0 -52
- package/dist/bundle/chunk-ZVVMGPBJ.js +0 -50
- package/dist/bundle/cli-EAD3WZLR.js +0 -1254
- package/dist/bundle/command-contract-SMEJ2ICG.js +0 -40
- package/dist/bundle/command-server-entry-YTZP6I4T.js +0 -169
- package/dist/bundle/decode-57BE5OBT.js +0 -296
- package/dist/bundle/dispatch-56FECRCU.js +0 -411
- package/dist/bundle/dist-PAKDDIBT.js +0 -191
- package/dist/bundle/dist-T54K3FJV.js +0 -7577
- package/dist/bundle/echarts-QMAA7HH5.js +0 -42501
- package/dist/bundle/embed-NFGFYUO4.js +0 -37
- package/dist/bundle/embedder-SRBOJMXX.js +0 -110
- package/dist/bundle/failure-WDSX6H3B.js +0 -24
- package/dist/bundle/first-run-HWRUL2GR.js +0 -28
- package/dist/bundle/first-screen-ATN4D3FQ.js +0 -41
- package/dist/bundle/mcp-5HFPWC3W.js +0 -167
- package/dist/bundle/meeting-combined-BGDEHCWY.js +0 -26
- package/dist/bundle/meeting-model-WWGVRXPL.js +0 -24
- package/dist/bundle/meeting-semantic-ZQ47BL2Z.js +0 -21
- package/dist/bundle/node-P3PUHKYH.js +0 -176
- package/dist/bundle/node-P4E63KXA.js +0 -2340
- package/dist/bundle/node-TLZSIHIJ.js +0 -21
- package/dist/bundle/node-sqlite-JOTSNH3P.js +0 -73
- package/dist/bundle/oauth-XPSAL6VO.js +0 -19
- package/dist/bundle/open-PO52FVA5.js +0 -22
- package/dist/bundle/openai-WITYLMY5.js +0 -237
- package/dist/bundle/process-AFIXYXWL.js +0 -91
- package/dist/bundle/program-JODTZNBZ.js +0 -4920
- package/dist/bundle/prompt-XORLAXHY.js +0 -16
- package/dist/bundle/recognize-JKMZHDYS.js +0 -25
- package/dist/bundle/remote-3IMEJTEH.js +0 -30
- package/dist/bundle/rerank-3F2E6NNN.js +0 -51
- package/dist/bundle/serve-6BWU3NMB.js +0 -198
- package/dist/bundle/server-GPSB5WFG.js +0 -220
- package/dist/bundle/server-HMCC64ZU.js +0 -88
- package/dist/bundle/source-E72OS27D.js +0 -47
- package/dist/bundle/sqlite-runtime-YHYQDUXE.js +0 -19
- package/dist/bundle/state-R7W4U6T4.js +0 -35
- package/dist/bundle/store-HTVRL7FB.js +0 -312
- package/dist/bundle/store-IWW6U6QN.js +0 -34
- package/dist/bundle/store-TBZ3ZS6H.js +0 -186
- package/dist/bundle/store-maintenance-command-CJM2VLMW.js +0 -75
- package/dist/bundle/surface-5GBWNYBE.js +0 -74
- package/dist/bundle/writer-TW2Q55VJ.js +0 -49
- package/dist/commands/account.d.ts +0 -4
- package/dist/commands/account.d.ts.map +0 -1
- package/dist/commands/account.js.map +0 -1
- package/dist/commands/api.d.ts +0 -3
- package/dist/commands/api.d.ts.map +0 -1
- package/dist/commands/api.js.map +0 -1
- package/dist/commands/crm-shared.d.ts +0 -8
- package/dist/commands/crm-shared.d.ts.map +0 -1
- package/dist/commands/crm-shared.js.map +0 -1
- package/dist/commands/schedule.d.ts +0 -3
- package/dist/commands/schedule.d.ts.map +0 -1
- package/dist/commands/schedule.js.map +0 -1
- package/dist/commands/session.d.ts +0 -35
- package/dist/commands/session.d.ts.map +0 -1
- package/dist/commands/session.js.map +0 -1
- package/dist/commands/write.d.ts +0 -14
- package/dist/commands/write.d.ts.map +0 -1
- package/dist/commands/write.js.map +0 -1
- package/dist/config.d.ts +0 -4
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js.map +0 -1
- package/dist/context.d.ts +0 -62
- package/dist/context.d.ts.map +0 -1
- package/dist/context.js.map +0 -1
- package/dist/crm/activities.d.ts +0 -32
- package/dist/crm/activities.d.ts.map +0 -1
- package/dist/crm/activities.js.map +0 -1
- package/dist/crm/records.d.ts +0 -20
- package/dist/crm/records.d.ts.map +0 -1
- package/dist/crm/records.js.map +0 -1
- package/dist/crm/source.d.ts +0 -41
- package/dist/crm/source.d.ts.map +0 -1
- package/dist/crm/source.js.map +0 -1
- package/dist/crm/writer.d.ts +0 -14
- package/dist/crm/writer.d.ts.map +0 -1
- package/dist/crm/writer.js.map +0 -1
- package/dist/identity.d.ts +0 -7
- package/dist/identity.d.ts.map +0 -1
- package/dist/identity.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/program.d.ts +0 -6
- package/dist/program.d.ts.map +0 -1
- package/dist/program.js.map +0 -1
- package/dist/reasons.d.ts +0 -10
- package/dist/reasons.d.ts.map +0 -1
- package/dist/reasons.js.map +0 -1
- package/dist/setup/flow.d.ts +0 -2
- package/dist/setup/flow.d.ts.map +0 -1
- package/dist/setup/flow.js.map +0 -1
- package/dist/store.d.ts +0 -15
- package/dist/store.d.ts.map +0 -1
- package/dist/store.js.map +0 -1
- package/dist/version.d.ts +0 -2
- package/dist/version.d.ts.map +0 -1
- package/dist/version.js.map +0 -1
- package/dist/wcat.d.ts +0 -3
- package/dist/wcat.d.ts.map +0 -1
- package/dist/wcat.js.map +0 -1
- package/dist/whoami.d.ts +0 -24
- package/dist/whoami.d.ts.map +0 -1
- package/dist/whoami.js.map +0 -1
|
@@ -1,460 +0,0 @@
|
|
|
1
|
-
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
-
const require = __bundleRequire(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
LEVELS
|
|
5
|
-
} from "./chunk-SDVUGWD7.js";
|
|
6
|
-
import {
|
|
7
|
-
WORD_BODY
|
|
8
|
-
} from "./chunk-3J3EDSXF.js";
|
|
9
|
-
import {
|
|
10
|
-
resolvePaths,
|
|
11
|
-
writeSecurely
|
|
12
|
-
} from "./chunk-WIHN3ELW.js";
|
|
13
|
-
import {
|
|
14
|
-
array,
|
|
15
|
-
getDotPath,
|
|
16
|
-
integer,
|
|
17
|
-
minLength,
|
|
18
|
-
minValue,
|
|
19
|
-
nullable,
|
|
20
|
-
number,
|
|
21
|
-
optional,
|
|
22
|
-
picklist,
|
|
23
|
-
pipe,
|
|
24
|
-
record,
|
|
25
|
-
regex,
|
|
26
|
-
safeParse,
|
|
27
|
-
strictObject,
|
|
28
|
-
string,
|
|
29
|
-
transform,
|
|
30
|
-
unknown
|
|
31
|
-
} from "./chunk-QFOP3KUP.js";
|
|
32
|
-
import {
|
|
33
|
-
CliError,
|
|
34
|
-
visibleControls
|
|
35
|
-
} from "./chunk-S6JG4YUH.js";
|
|
36
|
-
import {
|
|
37
|
-
__name
|
|
38
|
-
} from "./chunk-ZVVMGPBJ.js";
|
|
39
|
-
|
|
40
|
-
// node_modules/.pnpm/@wirecat+cli-core@2.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_a82f624c57005d53c3f072e45c3a3a86/node_modules/@wirecat/cli-core/dist/domain/formatting.js
|
|
41
|
-
var invalid = /* @__PURE__ */ __name(() => new CliError("validation_error", "the messenger formatter returned invalid text spans"), "invalid");
|
|
42
|
-
var validateFormattedText = /* @__PURE__ */ __name((formatted) => {
|
|
43
|
-
const { text, spans } = formatted;
|
|
44
|
-
if (typeof text !== "string" || !Array.isArray(spans) || spans.length > 100)
|
|
45
|
-
throw invalid();
|
|
46
|
-
const boundary = /* @__PURE__ */ __name((at) => !(at > 0 && at < text.length && /[\uD800-\uDBFF]/u.test(text[at - 1] ?? "") && /[\uDC00-\uDFFF]/u.test(text[at] ?? "")), "boundary");
|
|
47
|
-
for (const span of spans) {
|
|
48
|
-
if (![
|
|
49
|
-
"bold",
|
|
50
|
-
"italic",
|
|
51
|
-
"strike",
|
|
52
|
-
"underline",
|
|
53
|
-
"code",
|
|
54
|
-
"pre",
|
|
55
|
-
"link",
|
|
56
|
-
"blockquote",
|
|
57
|
-
"spoiler",
|
|
58
|
-
"highlight",
|
|
59
|
-
"heading"
|
|
60
|
-
].includes(span.type) || !Number.isInteger(span.from) || !Number.isInteger(span.length) || span.from < 0 || span.length <= 0 || span.from + span.length > text.length || !boundary(span.from) || !boundary(span.from + span.length))
|
|
61
|
-
throw invalid();
|
|
62
|
-
if (span.type === "link") {
|
|
63
|
-
if (!span.url || Array.from(span.url).some((char) => char.charCodeAt(0) <= 32 || char.charCodeAt(0) === 127))
|
|
64
|
-
throw new CliError("validation_error", "a Markdown link needs an absolute http, https or mailto URL");
|
|
65
|
-
let url;
|
|
66
|
-
try {
|
|
67
|
-
url = new URL(span.url);
|
|
68
|
-
} catch {
|
|
69
|
-
throw new CliError("validation_error", "a Markdown link needs an absolute http, https or mailto URL");
|
|
70
|
-
}
|
|
71
|
-
if (!["http:", "https:", "mailto:"].includes(url.protocol))
|
|
72
|
-
throw new CliError("validation_error", "Markdown links support http, https and mailto URLs");
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return formatted;
|
|
76
|
-
}, "validateFormattedText");
|
|
77
|
-
var visibleFormattedText = /* @__PURE__ */ __name((formatted) => {
|
|
78
|
-
validateFormattedText(formatted);
|
|
79
|
-
const text = visibleControls(formatted.text);
|
|
80
|
-
const positions = /* @__PURE__ */ new Map([[0, 0]]);
|
|
81
|
-
let original = 0;
|
|
82
|
-
let visible = 0;
|
|
83
|
-
for (const character of formatted.text) {
|
|
84
|
-
const rendered = text.startsWith(character, visible) ? character : visibleControls(character);
|
|
85
|
-
original += character.length;
|
|
86
|
-
visible += rendered.length;
|
|
87
|
-
positions.set(original, visible);
|
|
88
|
-
}
|
|
89
|
-
return {
|
|
90
|
-
text,
|
|
91
|
-
spans: formatted.spans.map((span) => ({
|
|
92
|
-
...span,
|
|
93
|
-
from: positions.get(span.from),
|
|
94
|
-
length: positions.get(span.from + span.length) - positions.get(span.from),
|
|
95
|
-
...span.url === void 0 ? {} : { url: visibleControls(span.url) }
|
|
96
|
-
}))
|
|
97
|
-
};
|
|
98
|
-
}, "visibleFormattedText");
|
|
99
|
-
|
|
100
|
-
// node_modules/.pnpm/@wirecat+cli-core@2.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_a82f624c57005d53c3f072e45c3a3a86/node_modules/@wirecat/cli-core/dist/domain/vcard.js
|
|
101
|
-
var AS_WORD = new RegExp(`^${WORD_BODY}$`);
|
|
102
|
-
var encoder = new TextEncoder();
|
|
103
|
-
|
|
104
|
-
// node_modules/.pnpm/@wirecat+cli-core@2.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_a82f624c57005d53c3f072e45c3a3a86/node_modules/@wirecat/cli-core/dist/moderation/check.js
|
|
105
|
-
var INVITE = /max\.ru\/join\/|(t|telegram)\.me\/(\+|joinchat\/)|tg:\/\/join/i;
|
|
106
|
-
var LINK = /https?:\/\/\S+/i;
|
|
107
|
-
var STRENGTH = { report: 0, delete: 1, remove: 2 };
|
|
108
|
-
var judge = /* @__PURE__ */ __name(({ rules, messages, joined, answerers, service, now, invites }) => {
|
|
109
|
-
const invite = invites ? new RegExp(`${INVITE.source}|${invites.source}`, "i") : INVITE;
|
|
110
|
-
const trusted = new Set(rules.trusted);
|
|
111
|
-
const blocked = /* @__PURE__ */ __name((id, name) => id !== null && rules.blocked.includes(id) || name !== null && rules.blockedNames.some((part) => name.toLocaleLowerCase().includes(part.toLocaleLowerCase())), "blocked");
|
|
112
|
-
const young = /* @__PURE__ */ __name((member) => rules.newAccount.days > 0 && typeof member.registeredAt === "string" && now - Date.parse(member.registeredAt) < rules.newAccount.days * 864e5, "young");
|
|
113
|
-
const found = [];
|
|
114
|
-
const add = /* @__PURE__ */ __name((finding) => {
|
|
115
|
-
if (finding.action === "remove" && found.some((f) => f.action === "remove" && f.personId === finding.personId)) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
found.push(finding);
|
|
119
|
-
}, "add");
|
|
120
|
-
for (const member of joined) {
|
|
121
|
-
if (trusted.has(member.id) || answerers.has(member.id))
|
|
122
|
-
continue;
|
|
123
|
-
const person = { kind: "member", personId: member.id, personName: member.name };
|
|
124
|
-
if (blocked(member.id, member.name)) {
|
|
125
|
-
add({ ...person, rule: "blocked", action: rules.blockedPeople === "remove" ? "remove" : "report" });
|
|
126
|
-
} else if (young(member)) {
|
|
127
|
-
add({ ...person, rule: "newAccount", action: rules.newAccount.action });
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
const flooding = floodOf(messages, rules.flood);
|
|
131
|
-
for (const message of messages) {
|
|
132
|
-
const id = message.senderId;
|
|
133
|
-
if (id === null || message.outgoing === true || answerers.has(id) || trusted.has(id))
|
|
134
|
-
continue;
|
|
135
|
-
if (service.has(message.id) || message.attachments.some((attachment) => attachment.kind === "control"))
|
|
136
|
-
continue;
|
|
137
|
-
const base = { kind: "message", personId: id, personName: message.senderName, messageId: message.id };
|
|
138
|
-
const text = message.text;
|
|
139
|
-
const broken2 = [];
|
|
140
|
-
if (blocked(id, message.senderName))
|
|
141
|
-
broken2.push(["blocked", rules.blockedPeople]);
|
|
142
|
-
if (invite.test(text))
|
|
143
|
-
broken2.push(["invites", rules.invites]);
|
|
144
|
-
if (LINK.test(text) || message.attachments.some((attachment) => attachment.kind === "share")) {
|
|
145
|
-
broken2.push(["links", rules.links]);
|
|
146
|
-
}
|
|
147
|
-
if (message.forwardedFrom !== null)
|
|
148
|
-
broken2.push(["forwards", rules.forwards]);
|
|
149
|
-
if (flooding.has(message.id))
|
|
150
|
-
broken2.push(["flood", rules.flood.action]);
|
|
151
|
-
const strongest = broken2.reduce((best, rule) => best === void 0 || STRENGTH[rule[1]] > STRENGTH[best[1]] ? rule : best, void 0);
|
|
152
|
-
if (strongest)
|
|
153
|
-
add({ ...base, rule: strongest[0], action: strongest[1] });
|
|
154
|
-
}
|
|
155
|
-
return found;
|
|
156
|
-
}, "judge");
|
|
157
|
-
var floodOf = /* @__PURE__ */ __name((messages, flood) => {
|
|
158
|
-
const window = flood.minutes * 6e4;
|
|
159
|
-
const over = /* @__PURE__ */ new Set();
|
|
160
|
-
const bySender = /* @__PURE__ */ new Map();
|
|
161
|
-
for (const message of messages) {
|
|
162
|
-
if (message.senderId === null)
|
|
163
|
-
continue;
|
|
164
|
-
const times = bySender.get(message.senderId) ?? [];
|
|
165
|
-
const at = Date.parse(message.timestamp);
|
|
166
|
-
times.push(at);
|
|
167
|
-
bySender.set(message.senderId, times);
|
|
168
|
-
if (times.filter((time) => at - time < window).length > flood.messages)
|
|
169
|
-
over.add(message.id);
|
|
170
|
-
}
|
|
171
|
-
return over;
|
|
172
|
-
}, "floodOf");
|
|
173
|
-
var act = /* @__PURE__ */ __name(async (moderator, findings, options) => {
|
|
174
|
-
const { chatId, rules, allowDangerous, dryRun, maxActions, confirm, command } = options;
|
|
175
|
-
const typed = options.commandFor ?? ((chat, finding) => commandFor(command, chat, finding));
|
|
176
|
-
const rows = [];
|
|
177
|
-
let acted = 0;
|
|
178
|
-
let stopped;
|
|
179
|
-
for (const finding of findings) {
|
|
180
|
-
if (finding.action === "report") {
|
|
181
|
-
rows.push({ ...finding, outcome: "reported" });
|
|
182
|
-
continue;
|
|
183
|
-
}
|
|
184
|
-
const consent = finding.action;
|
|
185
|
-
const level2 = rules.consent[consent];
|
|
186
|
-
const row = /* @__PURE__ */ __name((outcome, reason) => ({
|
|
187
|
-
...finding,
|
|
188
|
-
outcome,
|
|
189
|
-
...reason ? { reason } : {},
|
|
190
|
-
...outcome === "done" || outcome === "reported" ? {} : { command: typed(chatId, finding) }
|
|
191
|
-
}), "row");
|
|
192
|
-
if (level2 === "deny") {
|
|
193
|
-
rows.push(row("forbidden", `consent.${consent} is deny`));
|
|
194
|
-
continue;
|
|
195
|
-
}
|
|
196
|
-
if (level2 === "readonly") {
|
|
197
|
-
rows.push(row("reported", `consent.${consent} is readonly`));
|
|
198
|
-
continue;
|
|
199
|
-
}
|
|
200
|
-
if (dryRun) {
|
|
201
|
-
rows.push(row("planned", "--dry-run"));
|
|
202
|
-
continue;
|
|
203
|
-
}
|
|
204
|
-
if (stopped || acted >= maxActions) {
|
|
205
|
-
rows.push(row("skipped", stopped ?? `over the limit of ${maxActions} actions per check`));
|
|
206
|
-
continue;
|
|
207
|
-
}
|
|
208
|
-
if (level2 === "ask" && !allowDangerous) {
|
|
209
|
-
const yes = confirm ? await confirm(finding) : void 0;
|
|
210
|
-
if (yes === void 0) {
|
|
211
|
-
rows.push(row("planned", `consent.${consent} is ask, and nobody is there to answer \u2014 run with --allow-dangerous`));
|
|
212
|
-
continue;
|
|
213
|
-
}
|
|
214
|
-
if (!yes) {
|
|
215
|
-
rows.push(row("declined", "the answer was no"));
|
|
216
|
-
continue;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
acted += 1;
|
|
220
|
-
try {
|
|
221
|
-
if (finding.action === "delete" && finding.messageId) {
|
|
222
|
-
await moderator.deleteMessage(chatId, finding.messageId);
|
|
223
|
-
} else {
|
|
224
|
-
await moderator.removePerson(chatId, finding.personId);
|
|
225
|
-
}
|
|
226
|
-
rows.push(row("done"));
|
|
227
|
-
} catch (error) {
|
|
228
|
-
const failure = asCliError(error);
|
|
229
|
-
if (failure.code === "rate_limited")
|
|
230
|
-
stopped = failure.message;
|
|
231
|
-
const refused = ["rate_limited", "permission_error", "confirmation_required"].includes(failure.code);
|
|
232
|
-
rows.push(row(refused ? "refused" : "failed", failure.message));
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
return rows;
|
|
236
|
-
}, "act");
|
|
237
|
-
var asCliError = /* @__PURE__ */ __name((error) => error instanceof CliError ? error : new CliError("provider_error", error instanceof Error ? error.message : String(error)), "asCliError");
|
|
238
|
-
var who = /* @__PURE__ */ __name((finding) => finding.personName ?? finding.personId, "who");
|
|
239
|
-
var describe = /* @__PURE__ */ __name((finding) => finding.action === "delete" ? `delete message ${finding.messageId} from ${who(finding)} for everyone (${finding.rule})` : `remove ${who(finding)} from the group (${finding.rule})`, "describe");
|
|
240
|
-
var commandFor = /* @__PURE__ */ __name((command, chatId, finding) => finding.action === "delete" ? `${command} messages delete ${chatId} ${finding.messageId} --for-everyone --allow-dangerous` : finding.action === "remove" ? `${command} chats members remove ${chatId} ${finding.personId}` : "", "commandFor");
|
|
241
|
-
var CHECK_READS = 1e3;
|
|
242
|
-
var PAGE = 100;
|
|
243
|
-
var gather = /* @__PURE__ */ __name(async (adapter, chatId, since) => {
|
|
244
|
-
const notes = [];
|
|
245
|
-
const historyAfter = adapter.historyAfter;
|
|
246
|
-
if (!historyAfter)
|
|
247
|
-
throw new CliError("validation_error", "this messenger cannot read a chat forward from a time");
|
|
248
|
-
const messages = [];
|
|
249
|
-
let more = true;
|
|
250
|
-
while (more && messages.length < CHECK_READS) {
|
|
251
|
-
const last = messages.at(-1);
|
|
252
|
-
const page = await historyAfter.call(adapter, chatId, {
|
|
253
|
-
limit: PAGE,
|
|
254
|
-
after: last ? { id: last.id } : { time: since }
|
|
255
|
-
});
|
|
256
|
-
messages.push(...page.items);
|
|
257
|
-
more = page.hasMore && page.items.length > 0;
|
|
258
|
-
}
|
|
259
|
-
const scanned = adapter.chatEvents ? (await adapter.chatEvents(chatId, { since })).events : [];
|
|
260
|
-
const until = messages.at(-1)?.timestamp ?? null;
|
|
261
|
-
const events = more && until !== null ? scanned.filter((event) => Date.parse(event.timestamp) <= Date.parse(until)) : scanned;
|
|
262
|
-
if (!adapter.chatEvents)
|
|
263
|
-
notes.push("this messenger does not say who joined, so only messages are judged");
|
|
264
|
-
const joinedIds = new Set(events.filter((one) => one.event === "join" || one.event === "add").flatMap((one) => one.people.length > 0 ? one.people.map((person) => person.id) : one.by.id ? [one.by.id] : []));
|
|
265
|
-
const joined = joinedIds.size === 0 || !adapter.members ? [] : (await adapter.members(chatId, { offset: 0 })).items.filter((member) => joinedIds.has(member.id));
|
|
266
|
-
const admins = adapter.admins ? await adapter.admins(chatId) : null;
|
|
267
|
-
if (admins === null)
|
|
268
|
-
notes.push("the group's admins are not known, so only your own messages are exempt");
|
|
269
|
-
return {
|
|
270
|
-
messages,
|
|
271
|
-
joined,
|
|
272
|
-
answerers: new Set(admins ?? []),
|
|
273
|
-
service: new Set(events.map((one) => one.messageId)),
|
|
274
|
-
until,
|
|
275
|
-
more,
|
|
276
|
-
notes
|
|
277
|
-
};
|
|
278
|
-
}, "gather");
|
|
279
|
-
var MAX_ACTIONS = 10;
|
|
280
|
-
var undone = /* @__PURE__ */ __name((row) => ["planned", "skipped", "failed"].includes(row.outcome), "undone");
|
|
281
|
-
var nextPoint = /* @__PURE__ */ __name((rows, found) => {
|
|
282
|
-
const waiting = rows.filter(undone);
|
|
283
|
-
if (waiting.some((row) => row.messageId === void 0))
|
|
284
|
-
return null;
|
|
285
|
-
const times = waiting.map((row) => found.messages.find((message) => message.id === row.messageId)?.timestamp).filter((time) => time !== void 0).map(Date.parse);
|
|
286
|
-
if (times.length === 0)
|
|
287
|
-
return found.until;
|
|
288
|
-
return new Date(Math.min(...times) - 1).toISOString();
|
|
289
|
-
}, "nextPoint");
|
|
290
|
-
var someUndone = /* @__PURE__ */ __name((rows) => rows.some(undone), "someUndone");
|
|
291
|
-
|
|
292
|
-
// node_modules/.pnpm/@wirecat+cli-core@2.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_a82f624c57005d53c3f072e45c3a3a86/node_modules/@wirecat/cli-core/dist/moderation/rules.js
|
|
293
|
-
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
294
|
-
import { join } from "node:path";
|
|
295
|
-
var RULE_ACTIONS = ["report", "delete", "remove"];
|
|
296
|
-
var OLD_LEVELS = { forbid: "deny", flag: "ask", confirm: "ask", allow: "allow" };
|
|
297
|
-
var level = pipe(picklist([...LEVELS, ...Object.keys(OLD_LEVELS)]), transform((typed) => OLD_LEVELS[typed] ?? typed));
|
|
298
|
-
var action = picklist(RULE_ACTIONS);
|
|
299
|
-
var personIds = array(pipe(string(), regex(/^-?\d+$/, "a person id is digits")));
|
|
300
|
-
var atLeast = /* @__PURE__ */ __name((min) => pipe(number(), integer(), minValue(min)), "atLeast");
|
|
301
|
-
var groupRules = pipe(strictObject({
|
|
302
|
-
title: nullable(string()),
|
|
303
|
-
trusted: personIds,
|
|
304
|
-
blocked: personIds,
|
|
305
|
-
blockedNames: array(pipe(string(), minLength(1))),
|
|
306
|
-
links: action,
|
|
307
|
-
invites: action,
|
|
308
|
-
forwards: action,
|
|
309
|
-
blockedPeople: action,
|
|
310
|
-
flood: strictObject({ messages: atLeast(1), minutes: atLeast(1), action }),
|
|
311
|
-
/** 0 days turns the rule off. */
|
|
312
|
-
newAccount: strictObject({ days: atLeast(0), action: picklist(["report", "remove"]) }),
|
|
313
|
-
requests: optional(unknown()),
|
|
314
|
-
consent: strictObject({
|
|
315
|
-
delete: level,
|
|
316
|
-
remove: level,
|
|
317
|
-
accept: optional(unknown()),
|
|
318
|
-
decline: optional(unknown())
|
|
319
|
-
})
|
|
320
|
-
}), transform(({ requests: _, consent: { accept: _accept, decline: _decline, ...consent }, ...rules }) => ({
|
|
321
|
-
...rules,
|
|
322
|
-
consent
|
|
323
|
-
})));
|
|
324
|
-
var file = strictObject({
|
|
325
|
-
groups: record(string(), groupRules),
|
|
326
|
-
/** Where each group's next `chats moderate` starts, ISO 8601. */
|
|
327
|
-
checkedUntil: optional(record(string(), string()))
|
|
328
|
-
});
|
|
329
|
-
var defaultRules = /* @__PURE__ */ __name((title) => ({
|
|
330
|
-
title,
|
|
331
|
-
trusted: [],
|
|
332
|
-
blocked: [],
|
|
333
|
-
blockedNames: [],
|
|
334
|
-
links: "report",
|
|
335
|
-
invites: "report",
|
|
336
|
-
forwards: "report",
|
|
337
|
-
blockedPeople: "report",
|
|
338
|
-
flood: { messages: 5, minutes: 1, action: "report" },
|
|
339
|
-
newAccount: { days: 7, action: "report" },
|
|
340
|
-
consent: { delete: "ask", remove: "ask" }
|
|
341
|
-
}), "defaultRules");
|
|
342
|
-
var list = /* @__PURE__ */ __name((value) => value.split(",").map((item) => item.trim()).filter(Boolean), "list");
|
|
343
|
-
var whole = /* @__PURE__ */ __name((value) => /^\d+$/.test(value.trim()) ? Number(value) : Number.NaN, "whole");
|
|
344
|
-
var KEYS = {
|
|
345
|
-
trusted: { help: "person ids, comma-separated; never acted on", parse: list },
|
|
346
|
-
blocked: { help: "person ids, comma-separated", parse: list },
|
|
347
|
-
blockedNames: { help: "parts of a name, comma-separated, any case", parse: list },
|
|
348
|
-
links: { help: RULE_ACTIONS.join("|"), parse: String },
|
|
349
|
-
invites: { help: RULE_ACTIONS.join("|"), parse: String },
|
|
350
|
-
forwards: { help: RULE_ACTIONS.join("|"), parse: String },
|
|
351
|
-
blockedPeople: { help: RULE_ACTIONS.join("|"), parse: String },
|
|
352
|
-
"flood.messages": { help: "a whole number, 1 or more", parse: whole },
|
|
353
|
-
"flood.minutes": { help: "a whole number, 1 or more", parse: whole },
|
|
354
|
-
"flood.action": { help: RULE_ACTIONS.join("|"), parse: String },
|
|
355
|
-
"newAccount.days": { help: "a whole number; 0 turns it off", parse: whole },
|
|
356
|
-
"newAccount.action": { help: "report|remove", parse: String },
|
|
357
|
-
"consent.delete": { help: LEVELS.join("|"), parse: String },
|
|
358
|
-
"consent.remove": { help: LEVELS.join("|"), parse: String }
|
|
359
|
-
};
|
|
360
|
-
var RULE_KEYS = Object.keys(KEYS);
|
|
361
|
-
var stateFolder = /* @__PURE__ */ __name((app, env, folder) => join(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, folder), "stateFolder");
|
|
362
|
-
var profilesFolder = /* @__PURE__ */ __name((app, env) => stateFolder(app, env, "profiles"), "profilesFolder");
|
|
363
|
-
var moderationPathFor = /* @__PURE__ */ __name((app, profile, env = process.env) => join(profilesFolder(app, env), `${profile}.moderation.json`), "moderationPathFor");
|
|
364
|
-
var namesIn = /* @__PURE__ */ __name((folder, suffix) => existsSync(folder) ? readdirSync(folder).filter((name) => name.endsWith(suffix)).map((name) => name.slice(0, -suffix.length)) : [], "namesIn");
|
|
365
|
-
var moderationProfiles = /* @__PURE__ */ __name((app, env = process.env) => [
|
|
366
|
-
.../* @__PURE__ */ new Set([
|
|
367
|
-
...namesIn(stateFolder(app, env, "accounts"), ".json"),
|
|
368
|
-
...namesIn(profilesFolder(app, env), ".moderation.json")
|
|
369
|
-
])
|
|
370
|
-
].sort(), "moderationProfiles");
|
|
371
|
-
var ModerationRules = class {
|
|
372
|
-
static {
|
|
373
|
-
__name(this, "ModerationRules");
|
|
374
|
-
}
|
|
375
|
-
path;
|
|
376
|
-
constructor(path) {
|
|
377
|
-
this.path = path;
|
|
378
|
-
}
|
|
379
|
-
/** `undefined` when this group has no section yet. */
|
|
380
|
-
read(chatId) {
|
|
381
|
-
return this.#file().groups[chatId];
|
|
382
|
-
}
|
|
383
|
-
/** Writes the group's whole section — the defaults first, if it had none — with one key changed. */
|
|
384
|
-
set(chatId, title, key, value) {
|
|
385
|
-
const known = KEYS[key];
|
|
386
|
-
if (!known)
|
|
387
|
-
throw invalid2(`no rule ${key} \u2014 one of: ${RULE_KEYS.join(", ")}`);
|
|
388
|
-
const current = this.read(chatId) ?? defaultRules(title);
|
|
389
|
-
const checked = safeParse(groupRules, assign(current, key, known.parse(value)));
|
|
390
|
-
if (!checked.success)
|
|
391
|
-
throw invalid2(`${key} ${JSON.stringify(value)} is not valid \u2014 ${known.help}`);
|
|
392
|
-
const saved = this.#file();
|
|
393
|
-
this.#write({ ...saved, groups: { ...saved.groups, [chatId]: checked.output } });
|
|
394
|
-
return checked.output;
|
|
395
|
-
}
|
|
396
|
-
/** Puts one key back to its default. */
|
|
397
|
-
unset(chatId, title, key) {
|
|
398
|
-
if (!KEYS[key])
|
|
399
|
-
throw invalid2(`no rule ${key} \u2014 one of: ${RULE_KEYS.join(", ")}`);
|
|
400
|
-
const current = this.read(chatId) ?? defaultRules(title);
|
|
401
|
-
const changed = assign(current, key, lookup(defaultRules(title), key));
|
|
402
|
-
const saved = this.#file();
|
|
403
|
-
this.#write({ ...saved, groups: { ...saved.groups, [chatId]: changed } });
|
|
404
|
-
return changed;
|
|
405
|
-
}
|
|
406
|
-
checkedUntil(chatId) {
|
|
407
|
-
return this.#file().checkedUntil?.[chatId];
|
|
408
|
-
}
|
|
409
|
-
markChecked(chatId, at) {
|
|
410
|
-
const saved = this.#file();
|
|
411
|
-
this.#write({ ...saved, checkedUntil: { ...saved.checkedUntil, [chatId]: at } });
|
|
412
|
-
}
|
|
413
|
-
#file() {
|
|
414
|
-
if (!existsSync(this.path))
|
|
415
|
-
return { groups: {} };
|
|
416
|
-
let parsed;
|
|
417
|
-
try {
|
|
418
|
-
parsed = JSON.parse(readFileSync(this.path, "utf8"));
|
|
419
|
-
} catch (error) {
|
|
420
|
-
throw broken(this.path, error instanceof Error ? error.message : String(error));
|
|
421
|
-
}
|
|
422
|
-
const checked = safeParse(file, parsed);
|
|
423
|
-
if (!checked.success) {
|
|
424
|
-
const problems = checked.issues.map((issue) => `${getDotPath(issue) ?? "file"}: ${issue.message}`);
|
|
425
|
-
throw broken(this.path, problems.join("; "));
|
|
426
|
-
}
|
|
427
|
-
return checked.output;
|
|
428
|
-
}
|
|
429
|
-
#write(content) {
|
|
430
|
-
writeSecurely(this.path, `${JSON.stringify(content, null, 2)}
|
|
431
|
-
`, 384);
|
|
432
|
-
}
|
|
433
|
-
};
|
|
434
|
-
var invalid2 = /* @__PURE__ */ __name((message) => new CliError("validation_error", message), "invalid");
|
|
435
|
-
var broken = /* @__PURE__ */ __name((path, why) => new CliError("configuration_error", `the moderation rules ${path} cannot be read (${why}) \u2014 fix the file`), "broken");
|
|
436
|
-
var lookup = /* @__PURE__ */ __name((rules, key) => key.split(".").reduce((value, part) => value[part], rules), "lookup");
|
|
437
|
-
var assign = /* @__PURE__ */ __name((rules, key, value) => {
|
|
438
|
-
const [head, tail] = key.split(".");
|
|
439
|
-
if (tail === void 0)
|
|
440
|
-
return { ...rules, [head]: value };
|
|
441
|
-
return { ...rules, [head]: { ...rules[head], [tail]: value } };
|
|
442
|
-
}, "assign");
|
|
443
|
-
|
|
444
|
-
export {
|
|
445
|
-
validateFormattedText,
|
|
446
|
-
visibleFormattedText,
|
|
447
|
-
judge,
|
|
448
|
-
act,
|
|
449
|
-
describe,
|
|
450
|
-
CHECK_READS,
|
|
451
|
-
gather,
|
|
452
|
-
MAX_ACTIONS,
|
|
453
|
-
nextPoint,
|
|
454
|
-
someUndone,
|
|
455
|
-
defaultRules,
|
|
456
|
-
RULE_KEYS,
|
|
457
|
-
moderationPathFor,
|
|
458
|
-
moderationProfiles,
|
|
459
|
-
ModerationRules
|
|
460
|
-
};
|