@wirecat/hubspot-cli 0.0.0-stage → 0.1.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 +29 -0
- package/LICENSE +204 -0
- package/README.md +256 -2
- package/contracts/wirecat.json +1965 -0
- package/dist/bin/hubspot.d.ts +3 -0
- package/dist/bin/hubspot.d.ts.map +1 -0
- package/dist/bin/hubspot.js +40 -0
- package/dist/bin/hubspot.js.map +1 -0
- package/dist/bundle/all-profiles-64JAUYW4.js +279 -0
- package/dist/bundle/anthropic-VJOS4OUM.js +91 -0
- package/dist/bundle/app-server-422MCA7S.js +245 -0
- package/dist/bundle/bun-M3J2QTR3.js +169 -0
- package/dist/bundle/bun-sqlite-IX3XYA5F.js +76 -0
- package/dist/bundle/chunk-24ERVFJP.js +73 -0
- package/dist/bundle/chunk-2QZK5BEP.js +392 -0
- package/dist/bundle/chunk-2TWQIWWG.js +1328 -0
- package/dist/bundle/chunk-2VGD63G6.js +604 -0
- package/dist/bundle/chunk-2VGZRYEH.js +334 -0
- package/dist/bundle/chunk-36ITRDYY.js +63116 -0
- package/dist/bundle/chunk-43EKCUBJ.js +72 -0
- package/dist/bundle/chunk-4W6BMH45.js +731 -0
- package/dist/bundle/chunk-5A6ZYNAQ.js +2003 -0
- package/dist/bundle/chunk-5D4AEUVA.js +24783 -0
- package/dist/bundle/chunk-5GBUCHRU.js +274 -0
- package/dist/bundle/chunk-5K7QLJMM.js +4072 -0
- package/dist/bundle/chunk-65TWQ7BV.js +54 -0
- package/dist/bundle/chunk-7ELMWE3P.js +12066 -0
- package/dist/bundle/chunk-ADLS6FVG.js +24600 -0
- package/dist/bundle/chunk-B3MANLNK.js +602 -0
- package/dist/bundle/chunk-BKXDHU3G.js +1395 -0
- package/dist/bundle/chunk-C32AKHTY.js +2310 -0
- package/dist/bundle/chunk-CLAN3FES.js +1246 -0
- package/dist/bundle/chunk-CWXOXIWS.js +46 -0
- package/dist/bundle/chunk-D72URWJE.js +532 -0
- package/dist/bundle/chunk-DB2XKHI4.js +72 -0
- package/dist/bundle/chunk-DBEQI5YM.js +100 -0
- package/dist/bundle/chunk-DFCHHR5M.js +38 -0
- package/dist/bundle/chunk-DFDN6AUB.js +21 -0
- package/dist/bundle/chunk-DRWWJLI6.js +188 -0
- package/dist/bundle/chunk-DSP36YHQ.js +29 -0
- package/dist/bundle/chunk-E52JAS35.js +1028 -0
- package/dist/bundle/chunk-E5WLE7BM.js +78 -0
- package/dist/bundle/chunk-ECEZOLOD.js +230 -0
- package/dist/bundle/chunk-EH6ZEJGT.js +932 -0
- package/dist/bundle/chunk-FBCCBCFH.js +288 -0
- package/dist/bundle/chunk-FKA7DOCK.js +53 -0
- package/dist/bundle/chunk-FOZYMDRL.js +259 -0
- package/dist/bundle/chunk-FPUGMDJV.js +7 -0
- package/dist/bundle/chunk-FTFV3HFW.js +721 -0
- package/dist/bundle/chunk-H3TNVEQX.js +782 -0
- package/dist/bundle/chunk-HC5ZWE5X.js +193 -0
- package/dist/bundle/chunk-HCAZV5NP.js +95 -0
- package/dist/bundle/chunk-HTAN663T.js +4045 -0
- package/dist/bundle/chunk-HZRQLAHO.js +16 -0
- package/dist/bundle/chunk-IMJQRPLN.js +92 -0
- package/dist/bundle/chunk-JLDBMEKZ.js +106 -0
- package/dist/bundle/chunk-JRCPCVPI.js +9393 -0
- package/dist/bundle/chunk-LNV33FDC.js +786 -0
- package/dist/bundle/chunk-LOBVOGOE.js +66 -0
- package/dist/bundle/chunk-MVA5HVKL.js +1392 -0
- package/dist/bundle/chunk-N2XADGL4.js +76 -0
- package/dist/bundle/chunk-NHHJHXMQ.js +58 -0
- package/dist/bundle/chunk-NUU4WZVL.js +52 -0
- package/dist/bundle/chunk-NWHEHV3K.js +133 -0
- package/dist/bundle/chunk-NXERIDPJ.js +319 -0
- package/dist/bundle/chunk-O3DYRCIT.js +23 -0
- package/dist/bundle/chunk-O55RWNSH.js +161 -0
- package/dist/bundle/chunk-P5BHKKBI.js +206 -0
- package/dist/bundle/chunk-PPHBRESD.js +82 -0
- package/dist/bundle/chunk-PVKF24ZW.js +364 -0
- package/dist/bundle/chunk-QGFX5MXL.js +460 -0
- package/dist/bundle/chunk-QJW35N5V.js +761 -0
- package/dist/bundle/chunk-QU25DA5N.js +360 -0
- package/dist/bundle/chunk-RMIYKDUL.js +1068 -0
- package/dist/bundle/chunk-RR5MX5TM.js +142 -0
- package/dist/bundle/chunk-SAKK2YRU.js +218 -0
- package/dist/bundle/chunk-SDQGB4KB.js +185 -0
- package/dist/bundle/chunk-TBJYLC5K.js +2788 -0
- package/dist/bundle/chunk-TI46WQXQ.js +1197 -0
- package/dist/bundle/chunk-TKVL2C3B.js +170 -0
- package/dist/bundle/chunk-TOSCB4SO.js +1227 -0
- package/dist/bundle/chunk-TP7GDWVF.js +6848 -0
- package/dist/bundle/chunk-UUMUL4L3.js +72 -0
- package/dist/bundle/chunk-VIEYMDBR.js +41 -0
- package/dist/bundle/chunk-W53EJOFQ.js +63 -0
- package/dist/bundle/chunk-W7HM2VGO.js +24 -0
- package/dist/bundle/chunk-WE4UFASG.js +88 -0
- package/dist/bundle/chunk-WQBX7XYP.js +26174 -0
- package/dist/bundle/chunk-X2M6NIQG.js +18 -0
- package/dist/bundle/chunk-X7XUX7A4.js +1846 -0
- package/dist/bundle/chunk-XRREFEIW.js +372 -0
- package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
- package/dist/bundle/chunk-ZBDSHFG4.js +40933 -0
- package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
- package/dist/bundle/command-contract-C6CBFXZF.js +40 -0
- package/dist/bundle/command-server-entry-DJKVVZCQ.js +169 -0
- package/dist/bundle/decode-FC65Y4IV.js +297 -0
- package/dist/bundle/definitions-MVPICAWV.js +2991 -0
- package/dist/bundle/dispatch-KOISQ5QJ.js +411 -0
- package/dist/bundle/dist-MYZZKZJ7.js +7577 -0
- package/dist/bundle/echarts-FVTUDXDU.js +42501 -0
- package/dist/bundle/embed-VNBZFPYH.js +38 -0
- package/dist/bundle/embedder-6U4NOFRO.js +111 -0
- package/dist/bundle/failure-FZ6VYKEQ.js +25 -0
- package/dist/bundle/first-run-RPIJZEDT.js +29 -0
- package/dist/bundle/first-screen-RTVMGHAE.js +40 -0
- package/dist/bundle/hubspot.js +198 -0
- package/dist/bundle/instructions-HET7BCYK.js +11 -0
- package/dist/bundle/mcp-RGNRW77S.js +167 -0
- package/dist/bundle/meeting-combined-L5AGBPYX.js +25 -0
- package/dist/bundle/meeting-model-NTB4RK3F.js +25 -0
- package/dist/bundle/meeting-semantic-JY3OGCBS.js +22 -0
- package/dist/bundle/node-CXZIFHZC.js +176 -0
- package/dist/bundle/node-P4E63KXA.js +2340 -0
- package/dist/bundle/node-TLZSIHIJ.js +21 -0
- package/dist/bundle/node-sqlite-P3O7XN7Q.js +74 -0
- package/dist/bundle/oauth-HNCY4B2S.js +20 -0
- package/dist/bundle/open-F4P6YV54.js +23 -0
- package/dist/bundle/openai-4AICLIK3.js +238 -0
- package/dist/bundle/process-5RUXWGYS.js +91 -0
- package/dist/bundle/program-POG5GHUQ.js +9241 -0
- package/dist/bundle/prompt-NFMDVBZ4.js +17 -0
- package/dist/bundle/recognize-DKN3RY4V.js +26 -0
- package/dist/bundle/remote-6QHAGQWY.js +31 -0
- package/dist/bundle/rerank-M4KHEHUZ.js +52 -0
- package/dist/bundle/schemas-JRL3DLMP.js +952 -0
- package/dist/bundle/serve-DNU43ND6.js +199 -0
- package/dist/bundle/server-C3ZHA7AZ.js +77 -0
- package/dist/bundle/server-XJSNF3K5.js +207 -0
- package/dist/bundle/source-A3SBLHC4.js +934 -0
- package/dist/bundle/sqlite-runtime-EMQAC63N.js +20 -0
- package/dist/bundle/state-T45CX7VY.js +36 -0
- package/dist/bundle/store-6LCEVBAZ.js +176 -0
- package/dist/bundle/store-6TZ2FCVA.js +295 -0
- package/dist/bundle/store-CCDNUB6A.js +32 -0
- package/dist/bundle/store-maintenance-command-BRCG6MNA.js +68 -0
- package/dist/commands/account.d.ts +3 -0
- package/dist/commands/account.d.ts.map +1 -0
- package/dist/commands/account.js +87 -0
- package/dist/commands/account.js.map +1 -0
- package/dist/commands/api.d.ts +9 -0
- package/dist/commands/api.d.ts.map +1 -0
- package/dist/commands/api.js +65 -0
- package/dist/commands/api.js.map +1 -0
- package/dist/commands/comments.d.ts +3 -0
- package/dist/commands/comments.d.ts.map +1 -0
- package/dist/commands/comments.js +114 -0
- package/dist/commands/comments.js.map +1 -0
- package/dist/commands/crm-shared.d.ts +8 -0
- package/dist/commands/crm-shared.d.ts.map +1 -0
- package/dist/commands/crm-shared.js +93 -0
- package/dist/commands/crm-shared.js.map +1 -0
- package/dist/commands/schedule.d.ts +3 -0
- package/dist/commands/schedule.d.ts.map +1 -0
- package/dist/commands/schedule.js +9 -0
- package/dist/commands/schedule.js.map +1 -0
- package/dist/commands/session.d.ts +14 -0
- package/dist/commands/session.d.ts.map +1 -0
- package/dist/commands/session.js +164 -0
- package/dist/commands/session.js.map +1 -0
- package/dist/config.d.ts +22 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +28 -0
- package/dist/config.js.map +1 -0
- package/dist/context.d.ts +88 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +137 -0
- package/dist/context.js.map +1 -0
- package/dist/crm/activities.d.ts +24 -0
- package/dist/crm/activities.d.ts.map +1 -0
- package/dist/crm/activities.js +214 -0
- package/dist/crm/activities.js.map +1 -0
- package/dist/crm/associations.d.ts +20 -0
- package/dist/crm/associations.d.ts.map +1 -0
- package/dist/crm/associations.js +47 -0
- package/dist/crm/associations.js.map +1 -0
- package/dist/crm/records.d.ts +63 -0
- package/dist/crm/records.d.ts.map +1 -0
- package/dist/crm/records.js +333 -0
- package/dist/crm/records.js.map +1 -0
- package/dist/crm/search.d.ts +57 -0
- package/dist/crm/search.d.ts.map +1 -0
- package/dist/crm/search.js +47 -0
- package/dist/crm/search.js.map +1 -0
- package/dist/crm/source.d.ts +32 -0
- package/dist/crm/source.d.ts.map +1 -0
- package/dist/crm/source.js +369 -0
- package/dist/crm/source.js.map +1 -0
- package/dist/generated/definitions.d.ts +3 -0
- package/dist/generated/definitions.d.ts.map +1 -0
- package/dist/generated/definitions.js +2987 -0
- package/dist/generated/definitions.js.map +1 -0
- package/dist/generated/manifest.d.ts +6 -0
- package/dist/generated/manifest.d.ts.map +1 -0
- package/dist/generated/manifest.js +6499 -0
- package/dist/generated/manifest.js.map +1 -0
- package/dist/generated/schemas.d.ts +205 -0
- package/dist/generated/schemas.d.ts.map +1 -0
- package/dist/generated/schemas.js +810 -0
- package/dist/generated/schemas.js.map +1 -0
- package/dist/generated/types.d.ts +1114 -0
- package/dist/generated/types.d.ts.map +1 -0
- package/dist/generated/types.js +5 -0
- package/dist/generated/types.js.map +1 -0
- package/dist/hubspot/account.d.ts +12 -0
- package/dist/hubspot/account.d.ts.map +1 -0
- package/dist/hubspot/account.js +23 -0
- package/dist/hubspot/account.js.map +1 -0
- package/dist/hubspot/transport.d.ts +76 -0
- package/dist/hubspot/transport.d.ts.map +1 -0
- package/dist/hubspot/transport.js +346 -0
- package/dist/hubspot/transport.js.map +1 -0
- package/dist/identity.d.ts +7 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +32 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/program.d.ts +6 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +77 -0
- package/dist/program.js.map +1 -0
- package/dist/reasons.d.ts +10 -0
- package/dist/reasons.d.ts.map +1 -0
- package/dist/reasons.js +33 -0
- package/dist/reasons.js.map +1 -0
- package/dist/sample/comments.d.ts +61 -0
- package/dist/sample/comments.d.ts.map +1 -0
- package/dist/sample/comments.js +39 -0
- package/dist/sample/comments.js.map +1 -0
- package/dist/sample/records.d.ts +16 -0
- package/dist/sample/records.d.ts.map +1 -0
- package/dist/sample/records.js +22 -0
- package/dist/sample/records.js.map +1 -0
- package/dist/sample/transport.d.ts +42 -0
- package/dist/sample/transport.d.ts.map +1 -0
- package/dist/sample/transport.js +153 -0
- package/dist/sample/transport.js.map +1 -0
- package/dist/setup/flow.d.ts +2 -0
- package/dist/setup/flow.d.ts.map +1 -0
- package/dist/setup/flow.js +97 -0
- package/dist/setup/flow.js.map +1 -0
- package/dist/setup/texts.en.json +19 -0
- package/dist/setup/texts.es.json +19 -0
- package/dist/setup/texts.ru.json +19 -0
- package/dist/store.d.ts +16 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +34 -0
- package/dist/store.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -0
- package/dist/wcat.d.ts +3 -0
- package/dist/wcat.d.ts.map +1 -0
- package/dist/wcat.js +4 -0
- package/dist/wcat.js.map +1 -0
- package/dist/whoami.d.ts +19 -0
- package/dist/whoami.d.ts.map +1 -0
- package/dist/whoami.js +15 -0
- package/dist/whoami.js.map +1 -0
- package/package.json +98 -4
- package/skills/hubspot-cli/SKILL.md +97 -0
- package/skills/hubspot-cli/references/api/api-basic.md +462 -0
- package/skills/hubspot-cli/references/api/api-batch.md +149 -0
- package/skills/hubspot-cli/references/api/api-search.md +147 -0
- package/skills/hubspot-cli/references/api.md +15 -0
|
@@ -0,0 +1,460 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
LEVELS
|
|
5
|
+
} from "./chunk-2VGD63G6.js";
|
|
6
|
+
import {
|
|
7
|
+
WORD_BODY
|
|
8
|
+
} from "./chunk-5A6ZYNAQ.js";
|
|
9
|
+
import {
|
|
10
|
+
resolvePaths,
|
|
11
|
+
writeSecurely
|
|
12
|
+
} from "./chunk-TBJYLC5K.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-MVA5HVKL.js";
|
|
32
|
+
import {
|
|
33
|
+
CliError,
|
|
34
|
+
visibleControls
|
|
35
|
+
} from "./chunk-DB2XKHI4.js";
|
|
36
|
+
import {
|
|
37
|
+
__name
|
|
38
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
39
|
+
|
|
40
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.687.0_@wirecat+cli-base@0.109.0_commander@15.0.0_esbuild@0.28.2_typ_3e6248e31e5b79d53006284373ddef70/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@0.687.0_@wirecat+cli-base@0.109.0_commander@15.0.0_esbuild@0.28.2_typ_3e6248e31e5b79d53006284373ddef70/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@0.687.0_@wirecat+cli-base@0.109.0_commander@15.0.0_esbuild@0.28.2_typ_3e6248e31e5b79d53006284373ddef70/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@0.687.0_@wirecat+cli-base@0.109.0_commander@15.0.0_esbuild@0.28.2_typ_3e6248e31e5b79d53006284373ddef70/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
|
+
};
|