@wirecat/drive-cli 0.52.1 → 0.53.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/dist/bin/drive.js +2 -2
- package/dist/bin/drive.js.map +1 -1
- package/dist/bundle/{chunk-ZWSG7OCA.js → all-profiles-WRN35CUF.js} +11 -6
- package/dist/bundle/{anthropic-KW6KU36Y.js → anthropic-DZASXWG3.js} +1 -1
- package/dist/bundle/{app-server-TCJZ333E.js → app-server-4VHT7QZN.js} +33 -41
- package/dist/bundle/{bun-sqlite-RI7DR6RZ.js → bun-sqlite-2GOM5PM3.js} +1 -1
- package/dist/bundle/{chunk-LONV6HIK.js → chunk-2HHOMN2G.js} +440 -25
- package/dist/bundle/{chunk-NYOPEHEU.js → chunk-2PVDFLJJ.js} +8 -3
- package/dist/bundle/{chunk-725OHXKR.js → chunk-3RYX7IB6.js} +2218 -30
- package/dist/bundle/{chunk-CB7SBYLO.js → chunk-54BYJQ77.js} +41 -21
- package/dist/bundle/{chunk-5FONRUG6.js → chunk-5D4AEUVA.js} +1 -23
- package/dist/bundle/{chunk-RNSP57TC.js → chunk-6BNALDGA.js} +1 -1
- package/dist/bundle/{chunk-H47W2J6S.js → chunk-6XYGTRMQ.js} +812 -381
- package/dist/bundle/{chunk-UR32UWTQ.js → chunk-7IUMHMTP.js} +11 -0
- package/dist/bundle/{chunk-W7IK7E4B.js → chunk-BEL4XZ3M.js} +5 -7
- package/dist/bundle/{chunk-43QVYW3K.js → chunk-CL4GVCXS.js} +230 -56
- package/dist/bundle/{chunk-PQYVPCJ2.js → chunk-CNKILAWA.js} +18 -24
- package/dist/bundle/chunk-DOZOLBXE.js +110 -0
- package/dist/bundle/{chunk-2AUXBJRX.js → chunk-DT2YCB2V.js} +84 -11
- package/dist/bundle/{chunk-HQVJK5E7.js → chunk-DZMK255Y.js} +210 -357
- package/dist/bundle/{chunk-G6QF5KWF.js → chunk-E6XDFMRZ.js} +22 -28
- package/dist/bundle/{chunk-54O62JWP.js → chunk-F3KHUJEE.js} +24 -5
- package/dist/bundle/{chunk-I7UH5CTA.js → chunk-FXWBUTR7.js} +7 -9
- package/dist/bundle/{chunk-ZNZUZGSV.js → chunk-GE4DP24O.js} +131 -4
- package/dist/bundle/{chunk-PEOCBV2Z.js → chunk-GPJEYW2J.js} +1 -1
- package/dist/bundle/{chunk-A4UNTWAX.js → chunk-HM352LJR.js} +84 -15
- package/dist/bundle/{chunk-KYVXMEBC.js → chunk-IAQ4L6SM.js} +1 -1
- package/dist/bundle/{chunk-PQJYM5ES.js → chunk-IJFZKQC4.js} +1 -1
- package/dist/bundle/{chunk-O6IOL6RX.js → chunk-KPBCGUJC.js} +1 -1
- package/dist/bundle/{chunk-XOLQSCMF.js → chunk-KXMJE3XC.js} +2 -2
- package/dist/bundle/{chunk-33NVQGUY.js → chunk-LSGAJYVN.js} +2 -2
- package/dist/bundle/{chunk-2UIMEMWU.js → chunk-MK3N7WX7.js} +1 -1
- package/dist/bundle/{chunk-IDUNJCFO.js → chunk-OQMK6WXQ.js} +1 -1
- package/dist/bundle/{chunk-CM7GAXGD.js → chunk-PC4UA6UN.js} +1 -1
- package/dist/bundle/{chunk-YNFELLNQ.js → chunk-PIMMF67N.js} +2 -2
- package/dist/bundle/{chunk-WBTVGFXI.js → chunk-PR3DA7KA.js} +9 -9
- package/dist/bundle/{chunk-VJZST5RD.js → chunk-QXYGK6G5.js} +1 -1
- package/dist/bundle/{chunk-WQJBAWQP.js → chunk-R4TE4ZSD.js} +549 -224
- package/dist/bundle/{chunk-BSSCTWWK.js → chunk-RNIHKIQP.js} +1 -1
- package/dist/bundle/{chunk-PAXKALHV.js → chunk-SIWBUGBU.js} +116 -5
- package/dist/bundle/{chunk-2623YE5I.js → chunk-SQHPJBNO.js} +6 -8
- package/dist/bundle/chunk-SVTYS36O.js +5305 -0
- package/dist/bundle/{chunk-WLFUBNFX.js → chunk-T334CFU4.js} +2 -2
- package/dist/bundle/{chunk-IEXPOEEO.js → chunk-TZLO3ZZF.js} +3 -3
- package/dist/bundle/{chunk-5PLJKSG4.js → chunk-UFWK3L5Z.js} +4 -6
- package/dist/bundle/{chunk-FCJAHD4R.js → chunk-VTWADVEQ.js} +2 -2
- package/dist/bundle/{chunk-HX7Y2ASG.js → chunk-WJRJBQIM.js} +26040 -15126
- package/dist/bundle/{chunk-VSOLLTYT.js → chunk-YLKQSVLI.js} +5 -0
- package/dist/bundle/{chunk-IWFBAWZK.js → chunk-YQOVVCIA.js} +282 -10
- package/dist/bundle/{chunk-7YMDL4JQ.js → chunk-ZG6X24ON.js} +4 -1
- package/dist/bundle/{command-contract-I2YB5IXI.js → command-contract-D4UG3D33.js} +12 -15
- package/dist/bundle/{decode-EDN2ARXZ.js → decode-WAPM2VBH.js} +1 -1
- package/dist/bundle/drive.js +9 -20
- package/dist/bundle/{embed-3GSQIQXE.js → embed-HW3N3KNP.js} +4 -4
- package/dist/bundle/{embedder-6ULWRG3R.js → embedder-7WNFXYYP.js} +4 -4
- package/dist/bundle/{entry-IPRJLFHO.js → entry-J7YIRDPD.js} +4 -4
- package/dist/bundle/{first-run-FGHGWHC2.js → first-run-53CL2IYH.js} +6 -6
- package/dist/bundle/{first-screen-M62KTPZG.js → first-screen-2KT7HM2K.js} +13 -16
- package/dist/bundle/{google-BD3ZNFVJ.js → google-5NNVARNR.js} +2 -2
- package/dist/bundle/{chunk-GR5GGZKH.js → google-api-EQQH53QD.js} +60 -4
- package/dist/bundle/grants-4NETZ4MR.js +98 -0
- package/dist/bundle/{identity-U7IHZEMR.js → identity-LBTXDMTA.js} +4 -2
- package/dist/bundle/{login-7HRYPZMM.js → login-Y6ENYKC3.js} +44 -50
- package/dist/bundle/{node-sqlite-J3OODPYK.js → node-sqlite-FSQIKGED.js} +1 -1
- package/dist/bundle/{oauth-L4VTCBLF.js → oauth-HF5USWXY.js} +5 -5
- package/dist/bundle/{open-SGUN7ZVF.js → open-NHGJENCX.js} +2 -2
- package/dist/bundle/{openai-RLVISEDH.js → openai-3JCJYKNX.js} +6 -6
- package/dist/bundle/{program-YVLXSKZV.js → program-QAJ66K3Z.js} +713 -902
- package/dist/bundle/{prompt-AUWTBLO7.js → prompt-LQJBCCUF.js} +3 -3
- package/dist/bundle/{recognize-ORX2UBQW.js → recognize-QM3LN4ZF.js} +1 -1
- package/dist/bundle/{remote-AGIJY73X.js → remote-WREGEZJQ.js} +5 -5
- package/dist/bundle/{rerank-R6PE44M5.js → rerank-YFUB6J6M.js} +4 -4
- package/dist/bundle/{chunk-G7DCVJ4F.js → serve-7NFEZ564.js} +7 -4
- package/dist/bundle/{chunk-F7UUZATI.js → server-KBCFZ2AU.js} +38 -11
- package/dist/bundle/server-UYVL2CFI.js +63 -0
- package/dist/bundle/{services-HZFTTZSF.js → services-C3XWRA2W.js} +16 -21
- package/dist/bundle/{sqlite-runtime-DTGPR2T2.js → sqlite-runtime-H3TSAMIN.js} +3 -3
- package/dist/bundle/{state-WG3JKJM3.js → state-S2Q53L6L.js} +3 -3
- package/dist/bundle/{store-33VHIMEO.js → store-H345VQHP.js} +6 -8
- package/dist/bundle/{store-EV72MT5U.js → store-I27LAJPU.js} +7 -9
- package/dist/bundle/store-maintenance-command-3XA73XMC.js +52 -0
- package/dist/bundle/{chunk-GNI7INK6.js → terminal-DHJ4D3BC.js} +2 -3
- package/dist/bundle/tokens-7MUGKFEM.js +96 -0
- package/dist/commands/context.d.ts +14 -13
- package/dist/commands/context.d.ts.map +1 -1
- package/dist/commands/context.js.map +1 -1
- package/dist/commands/documents.d.ts.map +1 -1
- package/dist/commands/documents.js +1 -4
- package/dist/commands/documents.js.map +1 -1
- package/dist/commands/mirrors.d.ts.map +1 -1
- package/dist/commands/mirrors.js +1 -2
- package/dist/commands/mirrors.js.map +1 -1
- package/dist/commands/upgrade.d.ts +1 -1
- package/dist/commands/upgrade.d.ts.map +1 -1
- package/dist/commands/upgrade.js +4 -9
- package/dist/commands/upgrade.js.map +1 -1
- package/dist/config.d.ts +182 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +38 -3
- package/dist/config.js.map +1 -1
- package/dist/contract-overrides.d.ts +0 -3
- package/dist/contract-overrides.d.ts.map +1 -1
- package/dist/contract-overrides.js +0 -234
- package/dist/contract-overrides.js.map +1 -1
- package/dist/first-screen.d.ts +3 -2
- package/dist/first-screen.d.ts.map +1 -1
- package/dist/first-screen.js +17 -22
- package/dist/first-screen.js.map +1 -1
- package/dist/grants.d.ts +9 -0
- package/dist/grants.d.ts.map +1 -0
- package/dist/grants.js +30 -0
- package/dist/grants.js.map +1 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +2 -0
- package/dist/identity.js.map +1 -1
- package/dist/policy-keys.d.ts +12 -0
- package/dist/policy-keys.d.ts.map +1 -0
- package/dist/policy-keys.js +107 -0
- package/dist/policy-keys.js.map +1 -0
- package/dist/policy.d.ts +1 -8
- package/dist/policy.d.ts.map +1 -1
- package/dist/policy.js +2 -105
- package/dist/policy.js.map +1 -1
- package/dist/program.d.ts +8 -4
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +251 -222
- package/dist/program.js.map +1 -1
- package/dist/testing/mcp.d.ts +28 -0
- package/dist/testing/mcp.d.ts.map +1 -0
- package/dist/testing/mcp.js +56 -0
- package/dist/testing/mcp.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -3
- package/scenarios/agent-access.md +4 -2
- package/dist/bundle/all-profiles-CYW6XBBS.js +0 -26
- package/dist/bundle/chunk-234MHU76.js +0 -384
- package/dist/bundle/chunk-BBYD2FA3.js +0 -9
- package/dist/bundle/chunk-DO4PDQY5.js +0 -48
- package/dist/bundle/chunk-FDWYPONW.js +0 -1988
- package/dist/bundle/chunk-FQRJWVEB.js +0 -2
- package/dist/bundle/chunk-GJN5B5JK.js +0 -522
- package/dist/bundle/chunk-NPSZPUK6.js +0 -193
- package/dist/bundle/chunk-PDGECM5D.js +0 -138
- package/dist/bundle/chunk-Q765VPZY.js +0 -421
- package/dist/bundle/chunk-QYUHS6DE.js +0 -1714
- package/dist/bundle/chunk-WQRGA75U.js +0 -256
- package/dist/bundle/chunk-YVPHJHIL.js +0 -15572
- package/dist/bundle/chunk-Z47LOJUS.js +0 -484
- package/dist/bundle/failure-IXS2ZHA5.js +0 -37
- package/dist/bundle/google-api-BDUWZMRV.js +0 -83
- package/dist/bundle/mcp-F67RATLF.js +0 -502
- package/dist/bundle/mcp-JZSYPQA4.js +0 -96
- package/dist/bundle/serve-VOBAQHAQ.js +0 -20
- package/dist/bundle/server-24PS4M7U.js +0 -70
- package/dist/bundle/server-G6HFZ2CK.js +0 -57
- package/dist/bundle/store-maintenance-command-ZTUEI4EC.js +0 -58
- package/dist/bundle/terminal-TFCTWLOS.js +0 -11
- package/dist/bundle/tokens-XMOGQFI6.js +0 -102
- package/dist/commands/doctor.d.ts +0 -56
- package/dist/commands/doctor.d.ts.map +0 -1
- package/dist/commands/doctor.js +0 -75
- package/dist/commands/doctor.js.map +0 -1
- package/dist/commands/mcp.d.ts +0 -6
- package/dist/commands/mcp.d.ts.map +0 -1
- package/dist/commands/mcp.js +0 -156
- package/dist/commands/mcp.js.map +0 -1
- package/dist/commands/skill.d.ts +0 -6
- package/dist/commands/skill.d.ts.map +0 -1
- package/dist/commands/skill.js +0 -34
- package/dist/commands/skill.js.map +0 -1
- package/dist/failure.d.ts +0 -88
- package/dist/failure.d.ts.map +0 -1
- package/dist/failure.js +0 -60
- package/dist/failure.js.map +0 -1
- package/dist/mcp.d.ts +0 -175
- package/dist/mcp.d.ts.map +0 -1
- package/dist/mcp.js +0 -412
- package/dist/mcp.js.map +0 -1
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import { createRequire as __bundleRequire } from "node:module";
|
|
2
2
|
const require = __bundleRequire(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
classify,
|
|
5
|
-
documentExtractor,
|
|
6
|
-
documentKind,
|
|
7
|
-
engineMissing,
|
|
8
|
-
extractText,
|
|
9
|
-
importEngine
|
|
10
|
-
} from "./chunk-WUX7AUOQ.js";
|
|
11
3
|
import {
|
|
12
4
|
acquireLock,
|
|
13
5
|
openOrdinaryFile,
|
|
@@ -17,25 +9,18 @@ import {
|
|
|
17
9
|
writeFileAtomic
|
|
18
10
|
} from "./chunk-7SH4JHYW.js";
|
|
19
11
|
import {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
moderationPathFor,
|
|
28
|
-
nextPoint,
|
|
29
|
-
pickChat,
|
|
30
|
-
pickPerson,
|
|
31
|
-
someUndone,
|
|
32
|
-
validateFormattedText,
|
|
33
|
-
visibleFormattedText
|
|
34
|
-
} from "./chunk-Z47LOJUS.js";
|
|
12
|
+
classify,
|
|
13
|
+
documentExtractor,
|
|
14
|
+
documentKind,
|
|
15
|
+
engineMissing,
|
|
16
|
+
extractText,
|
|
17
|
+
importEngine
|
|
18
|
+
} from "./chunk-WUX7AUOQ.js";
|
|
35
19
|
import {
|
|
36
20
|
DEFAULT_IMAGE_MODEL,
|
|
37
21
|
DEFAULT_RERANK_MODEL,
|
|
38
22
|
DEFAULT_TEXT_MODEL,
|
|
23
|
+
LEVELS,
|
|
39
24
|
LINK,
|
|
40
25
|
WEIGHTS,
|
|
41
26
|
agenda,
|
|
@@ -58,14 +43,14 @@ import {
|
|
|
58
43
|
typedCommand,
|
|
59
44
|
vectorModelKey,
|
|
60
45
|
withAttempt
|
|
61
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-2HHOMN2G.js";
|
|
62
47
|
import {
|
|
63
48
|
isCliFailure
|
|
64
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-YLKQSVLI.js";
|
|
65
50
|
import {
|
|
66
51
|
isNewer,
|
|
67
52
|
updateCommand
|
|
68
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-ZG6X24ON.js";
|
|
69
54
|
import {
|
|
70
55
|
MAX_MODEL_IMAGE_BYTES
|
|
71
56
|
} from "./chunk-VZ2I62HN.js";
|
|
@@ -74,7 +59,7 @@ import {
|
|
|
74
59
|
openRemote,
|
|
75
60
|
remoteKey,
|
|
76
61
|
remoteModel
|
|
77
|
-
} from "./chunk-
|
|
62
|
+
} from "./chunk-MK3N7WX7.js";
|
|
78
63
|
import {
|
|
79
64
|
defaultThreads,
|
|
80
65
|
installNativeRuntime,
|
|
@@ -83,11 +68,11 @@ import {
|
|
|
83
68
|
placedText,
|
|
84
69
|
runEmbedders,
|
|
85
70
|
textModelsDirectory
|
|
86
|
-
} from "./chunk-
|
|
71
|
+
} from "./chunk-PC4UA6UN.js";
|
|
87
72
|
import {
|
|
88
73
|
installFiles,
|
|
89
74
|
megabytes
|
|
90
|
-
} from "./chunk-
|
|
75
|
+
} from "./chunk-RNIHKIQP.js";
|
|
91
76
|
import {
|
|
92
77
|
AGENDA_COLUMNS,
|
|
93
78
|
CHAT_COLUMNS,
|
|
@@ -95,17 +80,21 @@ import {
|
|
|
95
80
|
CHUNK_CHARS,
|
|
96
81
|
CONTEXT_MAX_READ_BYTES,
|
|
97
82
|
CONVERSATION_COLUMNS,
|
|
83
|
+
COUNTER_FIELDS,
|
|
98
84
|
EVIDENCE_FINDINGS_KIND,
|
|
99
85
|
FIELD_VERSION,
|
|
86
|
+
INTERNAL_NOTES,
|
|
100
87
|
MENTION_QUERY,
|
|
101
88
|
MESSAGE_PARSING,
|
|
102
89
|
NOT_FILES,
|
|
103
90
|
PRESET_VERSION,
|
|
104
91
|
QUERY_LIMITS,
|
|
105
92
|
QUERY_VERSION,
|
|
93
|
+
RANKING_TOKENIZER_VERSION,
|
|
106
94
|
SEARCH_QUERY,
|
|
107
95
|
TASK_RELATION_KINDS,
|
|
108
96
|
TRACKED_CHAT_COLUMNS,
|
|
97
|
+
UNKNOWN_PROVIDER,
|
|
109
98
|
attachmentColumns,
|
|
110
99
|
calendarKey,
|
|
111
100
|
calendarMoment,
|
|
@@ -116,12 +105,16 @@ import {
|
|
|
116
105
|
contextEvidenceRequest,
|
|
117
106
|
contextSource,
|
|
118
107
|
correctWords,
|
|
108
|
+
counterFreshness,
|
|
109
|
+
counterObservationTime,
|
|
119
110
|
cutChunks,
|
|
120
111
|
entriesOfList,
|
|
121
112
|
exhausted,
|
|
122
113
|
fetchedKey,
|
|
123
114
|
findMentions,
|
|
124
115
|
fitting,
|
|
116
|
+
formatLocator,
|
|
117
|
+
formatReference,
|
|
125
118
|
googleDocumentId,
|
|
126
119
|
googleDocumentLinks,
|
|
127
120
|
hasStems,
|
|
@@ -130,52 +123,40 @@ import {
|
|
|
130
123
|
inSource,
|
|
131
124
|
inboxKey,
|
|
132
125
|
isAccountList,
|
|
126
|
+
isFolderProvider,
|
|
127
|
+
isKind,
|
|
128
|
+
isLocator,
|
|
133
129
|
isStemmed,
|
|
130
|
+
kindIn,
|
|
131
|
+
kindOf,
|
|
134
132
|
matchDownloads,
|
|
135
133
|
messageOfEmail,
|
|
136
134
|
normalizeVocabularyName,
|
|
135
|
+
parseLocator,
|
|
136
|
+
parseReference,
|
|
137
|
+
providerNamed,
|
|
137
138
|
queryFilter,
|
|
138
139
|
rankingContextRange,
|
|
140
|
+
rankingOptions,
|
|
139
141
|
searchError,
|
|
140
142
|
sourceOf,
|
|
141
143
|
threadConversation,
|
|
142
144
|
validateAst,
|
|
143
145
|
validateFields
|
|
144
|
-
} from "./chunk-
|
|
146
|
+
} from "./chunk-R4TE4ZSD.js";
|
|
145
147
|
import {
|
|
146
148
|
MAX_TEXT_CHARS,
|
|
147
149
|
attachmentMaxBytes,
|
|
148
150
|
pdfPreviewLimits
|
|
149
151
|
} from "./chunk-JEOYFKUK.js";
|
|
150
152
|
import {
|
|
151
|
-
|
|
152
|
-
INTERNAL_NOTES,
|
|
153
|
-
RANKING_TOKENIZER_VERSION,
|
|
154
|
-
UNKNOWN_PROVIDER,
|
|
155
|
-
counterFreshness,
|
|
156
|
-
counterObservationTime,
|
|
157
|
-
formatLocator,
|
|
158
|
-
formatReference,
|
|
159
|
-
isFolderProvider,
|
|
160
|
-
isKind,
|
|
161
|
-
isLocator,
|
|
162
|
-
kindIn,
|
|
163
|
-
kindOf,
|
|
164
|
-
parseLocator,
|
|
165
|
-
parseReference,
|
|
166
|
-
providerNamed,
|
|
167
|
-
rankingOptions
|
|
168
|
-
} from "./chunk-234MHU76.js";
|
|
169
|
-
import {
|
|
153
|
+
MEETING_FINDINGS_KIND,
|
|
170
154
|
TASK_KINDS,
|
|
171
155
|
TASK_ORIGINS,
|
|
172
156
|
TASK_STATES,
|
|
173
|
-
createTaskService
|
|
174
|
-
} from "./chunk-PDGECM5D.js";
|
|
175
|
-
import {
|
|
176
|
-
MEETING_FINDINGS_KIND,
|
|
177
157
|
canonicalMeetingReference,
|
|
178
158
|
createMeetingContext,
|
|
159
|
+
createTaskService,
|
|
179
160
|
formatMeetingReference,
|
|
180
161
|
liftMeetingFields,
|
|
181
162
|
meetingCueFingerprint,
|
|
@@ -190,7 +171,7 @@ import {
|
|
|
190
171
|
validateMeetingHitSearch,
|
|
191
172
|
validateMeetingPassage,
|
|
192
173
|
validateMeetingSeriesHistory
|
|
193
|
-
} from "./chunk-
|
|
174
|
+
} from "./chunk-GE4DP24O.js";
|
|
194
175
|
import {
|
|
195
176
|
dateRange,
|
|
196
177
|
implicitTextTerms,
|
|
@@ -210,35 +191,82 @@ import {
|
|
|
210
191
|
import {
|
|
211
192
|
DEFAULT_TASK_CATEGORIES,
|
|
212
193
|
FALLBACK_CATEGORY
|
|
213
|
-
} from "./chunk-
|
|
194
|
+
} from "./chunk-KXMJE3XC.js";
|
|
214
195
|
import {
|
|
215
196
|
storePath,
|
|
216
197
|
wirecatDirectory
|
|
217
|
-
} from "./chunk-
|
|
198
|
+
} from "./chunk-QXYGK6G5.js";
|
|
218
199
|
import {
|
|
219
200
|
resolvePaths,
|
|
220
|
-
singleLine
|
|
221
|
-
|
|
201
|
+
singleLine,
|
|
202
|
+
visibleControls,
|
|
203
|
+
writeSecurely
|
|
204
|
+
} from "./chunk-DZMK255Y.js";
|
|
222
205
|
import {
|
|
223
206
|
CliError,
|
|
224
207
|
array,
|
|
208
|
+
getDotPath,
|
|
209
|
+
integer,
|
|
225
210
|
isCliError,
|
|
226
211
|
maxLength,
|
|
227
212
|
minLength,
|
|
228
213
|
minValue,
|
|
214
|
+
nullable,
|
|
229
215
|
number,
|
|
230
216
|
optional,
|
|
217
|
+
picklist,
|
|
231
218
|
pipe,
|
|
219
|
+
record,
|
|
232
220
|
regex,
|
|
233
221
|
safeInteger,
|
|
234
222
|
safeParse,
|
|
235
223
|
strictObject,
|
|
236
|
-
string
|
|
224
|
+
string,
|
|
225
|
+
transform,
|
|
226
|
+
unknown
|
|
237
227
|
} from "./chunk-YKZ4IPLB.js";
|
|
238
228
|
import {
|
|
239
229
|
__name
|
|
240
230
|
} from "./chunk-ZVVMGPBJ.js";
|
|
241
231
|
|
|
232
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/resolve.js
|
|
233
|
+
var isId = /* @__PURE__ */ __name((reference) => /^-?\d+$/.test(reference.trim()), "isId");
|
|
234
|
+
var foldName = /* @__PURE__ */ __name((name) => name.normalize("NFC").replace(/[\uFE0E\uFE0F\u200D]/g, "").toLowerCase(), "foldName");
|
|
235
|
+
var pickChat = /* @__PURE__ */ __name((reference, chats) => {
|
|
236
|
+
const wanted = foldName(reference.trim());
|
|
237
|
+
const matches = chats.filter((chat) => chat.title !== null && foldName(chat.title).includes(wanted));
|
|
238
|
+
if (matches.length === 1 && matches[0])
|
|
239
|
+
return matches[0];
|
|
240
|
+
if (matches.length === 0)
|
|
241
|
+
throw new CliError("not_found", `no chat matches "${reference}"`);
|
|
242
|
+
throw ambiguous(reference, "chats", matches.map((chat) => ({ id: chat.id, title: chat.title })), ({ title }) => singleLine(String(title)));
|
|
243
|
+
}, "pickChat");
|
|
244
|
+
var pickPerson = /* @__PURE__ */ __name((reference, people) => {
|
|
245
|
+
const trimmed = reference.trim();
|
|
246
|
+
const known2 = people.get(trimmed);
|
|
247
|
+
if (known2)
|
|
248
|
+
return known2;
|
|
249
|
+
if (isId(trimmed))
|
|
250
|
+
throw new CliError("not_found", `no person ${trimmed} in what this account has seen`);
|
|
251
|
+
const wanted = foldName(trimmed.replace(/^@/, ""));
|
|
252
|
+
const everyone = people.all().toSorted((a, b) => (a.name ?? "").localeCompare(b.name ?? ""));
|
|
253
|
+
const fields = /* @__PURE__ */ __name((person) => [person.alias, person.name, person.username].filter(isPresent).map(foldName), "fields");
|
|
254
|
+
const exact = everyone.filter((person) => fields(person).includes(wanted));
|
|
255
|
+
const matches = exact.length > 0 ? exact : everyone.filter((person) => fields(person).some((one) => one.includes(wanted)));
|
|
256
|
+
if (matches.length === 1 && matches[0])
|
|
257
|
+
return matches[0];
|
|
258
|
+
if (matches.length === 0)
|
|
259
|
+
throw new CliError("not_found", `nobody matches "${reference}"`);
|
|
260
|
+
throw ambiguous(reference, "people", matches.map(({ id: id2, name, username }) => ({ id: id2, name, username })), ({ name, username }) => singleLine([name, username && `@${username}`].filter(isPresent).join(" ")));
|
|
261
|
+
}, "pickPerson");
|
|
262
|
+
var ambiguous = /* @__PURE__ */ __name((reference, what, candidates, label) => {
|
|
263
|
+
const width = Math.max(...candidates.map(({ id: id2 }) => id2.length));
|
|
264
|
+
const lines = candidates.map((candidate) => ` ${candidate.id.padEnd(width)} ${label(candidate)}`).join("\n");
|
|
265
|
+
return new CliError("validation_error", `"${singleLine(reference)}" matches ${candidates.length} ${what} \u2014 name one by its id:
|
|
266
|
+
${lines}`, { candidates });
|
|
267
|
+
}, "ambiguous");
|
|
268
|
+
var isPresent = /* @__PURE__ */ __name((value) => value !== null && value !== void 0, "isPresent");
|
|
269
|
+
|
|
242
270
|
// node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/deps.js
|
|
243
271
|
var accountStore = /* @__PURE__ */ __name(async (deps) => (await deps.store()).forAccount(await deps.account()), "accountStore");
|
|
244
272
|
var crossAccount = /* @__PURE__ */ __name((deps, _reason) => deps.store(), "crossAccount");
|
|
@@ -334,19 +362,19 @@ var repeated = /* @__PURE__ */ __name((messages) => {
|
|
|
334
362
|
}, "repeated");
|
|
335
363
|
var scorePerson = /* @__PURE__ */ __name(({ subject, provider, activity, photos, registries, now = /* @__PURE__ */ new Date() }) => {
|
|
336
364
|
const reasons = [];
|
|
337
|
-
const
|
|
365
|
+
const unknown2 = [];
|
|
338
366
|
const add = /* @__PURE__ */ __name((reason, source, detail) => reasons.push({ reason, weight: WEIGHTS[reason], source, ...detail ? { detail } : {} }), "add");
|
|
339
367
|
const young = /* @__PURE__ */ __name((at) => now.getTime() - Date.parse(at) < NEW_DAYS * DAY_MS, "young");
|
|
340
368
|
const { flags } = subject;
|
|
341
369
|
for (const flag of ["bot", "scam", "fake", "deleted"]) {
|
|
342
370
|
if (flags?.[flag] === void 0)
|
|
343
|
-
|
|
371
|
+
unknown2.push(flag);
|
|
344
372
|
else if (flags[flag])
|
|
345
373
|
add(flag, "messenger");
|
|
346
374
|
}
|
|
347
375
|
const withPhoto = subject.hasPhoto ?? (photos ? photos.count > 0 : void 0);
|
|
348
376
|
if (withPhoto === void 0)
|
|
349
|
-
|
|
377
|
+
unknown2.push("no_photo");
|
|
350
378
|
else if (!withPhoto)
|
|
351
379
|
add("no_photo", "messenger");
|
|
352
380
|
if (subject.usernames.length === 0)
|
|
@@ -354,26 +382,26 @@ var scorePerson = /* @__PURE__ */ __name(({ subject, provider, activity, photos,
|
|
|
354
382
|
if (oddName(subject.name))
|
|
355
383
|
add("odd_name", "messenger");
|
|
356
384
|
if (subject.bio === void 0)
|
|
357
|
-
|
|
385
|
+
unknown2.push("no_bio");
|
|
358
386
|
else if (!subject.bio?.trim())
|
|
359
387
|
add("no_bio", "messenger");
|
|
360
388
|
if (subject.registered === void 0 || subject.registered === null)
|
|
361
|
-
|
|
389
|
+
unknown2.push("new_account");
|
|
362
390
|
else if (young(subject.registered.at))
|
|
363
391
|
add("new_account", subject.registered.source, subject.registered.at);
|
|
364
392
|
if (photos === void 0)
|
|
365
|
-
|
|
393
|
+
unknown2.push("photo_recent");
|
|
366
394
|
else if (photos.oldestAt && young(photos.oldestAt))
|
|
367
395
|
add("photo_recent", "messenger", photos.oldestAt);
|
|
368
396
|
if (activity === void 0 || activity.chatsStored === 0)
|
|
369
|
-
|
|
397
|
+
unknown2.push("never_wrote", "link_first", "same_text");
|
|
370
398
|
else {
|
|
371
399
|
const { messages, complete } = activity;
|
|
372
400
|
if (messages.length === 0)
|
|
373
401
|
add("never_wrote", "store");
|
|
374
402
|
const first = complete ? messages.at(-1) : void 0;
|
|
375
403
|
if (!complete)
|
|
376
|
-
|
|
404
|
+
unknown2.push("link_first");
|
|
377
405
|
else if (first && (first.forwardedFrom !== null || LINK.test(first.text)))
|
|
378
406
|
add("link_first", "store");
|
|
379
407
|
const chats = repeated(messages);
|
|
@@ -389,7 +417,7 @@ var scorePerson = /* @__PURE__ */ __name(({ subject, provider, activity, photos,
|
|
|
389
417
|
score: reasons.reduce((total, { weight }) => total + weight, 0),
|
|
390
418
|
reasons: reasons.sort((a, b) => b.weight - a.weight),
|
|
391
419
|
registries,
|
|
392
|
-
unknown,
|
|
420
|
+
unknown: unknown2,
|
|
393
421
|
checkedAt: now.toISOString()
|
|
394
422
|
};
|
|
395
423
|
}, "scorePerson");
|
|
@@ -424,16 +452,16 @@ var isObject = /* @__PURE__ */ __name((value) => typeof value === "object" && va
|
|
|
424
452
|
var askCas = /* @__PURE__ */ __name(async (id2, options = {}) => {
|
|
425
453
|
const checkedAt = (options.now?.() ?? /* @__PURE__ */ new Date()).toISOString();
|
|
426
454
|
const got = await getJson(`https://api.cas.chat/check?user_id=${encodeURIComponent(id2)}`, options.casKey ? { authorization: `Bearer ${options.casKey}` } : {}, options);
|
|
427
|
-
const
|
|
455
|
+
const unknown2 = /* @__PURE__ */ __name((detail) => ({ name: "cas", answer: "unknown", checkedAt, detail }), "unknown");
|
|
428
456
|
if ("failed" in got)
|
|
429
|
-
return
|
|
457
|
+
return unknown2(got.failed);
|
|
430
458
|
if (got.status === 401)
|
|
431
|
-
return
|
|
459
|
+
return unknown2(options.casKey ? "refused the key" : "now asks for a key from combot.org");
|
|
432
460
|
const { body } = got;
|
|
433
461
|
if (!isObject(body) || typeof body.ok !== "boolean")
|
|
434
|
-
return
|
|
462
|
+
return unknown2("answered in an unexpected shape");
|
|
435
463
|
if (!body.ok) {
|
|
436
|
-
return body.description === "Record not found." ? { name: "cas", answer: "clean", checkedAt } :
|
|
464
|
+
return body.description === "Record not found." ? { name: "cas", answer: "clean", checkedAt } : unknown2(typeof body.description === "string" ? body.description : "refused");
|
|
437
465
|
}
|
|
438
466
|
const result = isObject(body.result) ? body.result : {};
|
|
439
467
|
const offenses = typeof result.offenses === "number" ? result.offenses : void 0;
|
|
@@ -449,12 +477,12 @@ var askCas = /* @__PURE__ */ __name(async (id2, options = {}) => {
|
|
|
449
477
|
var askLols = /* @__PURE__ */ __name(async (id2, options = {}) => {
|
|
450
478
|
const checkedAt = (options.now?.() ?? /* @__PURE__ */ new Date()).toISOString();
|
|
451
479
|
const got = await getJson(`https://api.lols.bot/account?id=${encodeURIComponent(id2)}`, {}, options);
|
|
452
|
-
const
|
|
480
|
+
const unknown2 = /* @__PURE__ */ __name((detail) => ({ name: "lols", answer: "unknown", checkedAt, detail }), "unknown");
|
|
453
481
|
if ("failed" in got)
|
|
454
|
-
return
|
|
482
|
+
return unknown2(got.failed);
|
|
455
483
|
const { body } = got;
|
|
456
484
|
if (got.status !== 200 || !isObject(body) || body.ok !== true || typeof body.banned !== "boolean") {
|
|
457
|
-
return
|
|
485
|
+
return unknown2(`answered ${got.status} in an unexpected shape`);
|
|
458
486
|
}
|
|
459
487
|
const reasons = [
|
|
460
488
|
...body.banned ? ["lols_banned"] : [],
|
|
@@ -786,7 +814,7 @@ import { createHash } from "node:crypto";
|
|
|
786
814
|
var metadataLimit = 16384;
|
|
787
815
|
var partialIdentity = /* @__PURE__ */ __name((locator) => JSON.stringify([locator.provider, locator.account, locator.occurrenceId, locator.assetId]), "partialIdentity");
|
|
788
816
|
var missing = /* @__PURE__ */ __name((error) => typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT", "missing");
|
|
789
|
-
var fingerprintPartial = /* @__PURE__ */ __name(async (
|
|
817
|
+
var fingerprintPartial = /* @__PURE__ */ __name(async (file2, signal, length) => {
|
|
790
818
|
const hash3 = createHash("sha256");
|
|
791
819
|
let size4 = 0;
|
|
792
820
|
const buffer = Buffer.alloc(65536);
|
|
@@ -795,7 +823,7 @@ var fingerprintPartial = /* @__PURE__ */ __name(async (file, signal, length) =>
|
|
|
795
823
|
const wanted = length === void 0 ? buffer.length : Math.min(buffer.length, length - size4);
|
|
796
824
|
if (wanted === 0)
|
|
797
825
|
break;
|
|
798
|
-
const count2 = (await
|
|
826
|
+
const count2 = (await file2.read(buffer, 0, wanted, size4)).bytesRead;
|
|
799
827
|
signal?.throwIfAborted();
|
|
800
828
|
if (count2 === 0)
|
|
801
829
|
break;
|
|
@@ -805,9 +833,9 @@ var fingerprintPartial = /* @__PURE__ */ __name(async (file, signal, length) =>
|
|
|
805
833
|
return { offset: size4, sha256: hash3.copy().digest("hex"), hash: hash3 };
|
|
806
834
|
}, "fingerprintPartial");
|
|
807
835
|
var readPartialMetadata = /* @__PURE__ */ __name(async (path, locator, maxBytes, signal) => {
|
|
808
|
-
let
|
|
836
|
+
let file2;
|
|
809
837
|
try {
|
|
810
|
-
|
|
838
|
+
file2 = await openOrdinaryFile(path);
|
|
811
839
|
} catch (error) {
|
|
812
840
|
if (missing(error))
|
|
813
841
|
return null;
|
|
@@ -815,13 +843,13 @@ var readPartialMetadata = /* @__PURE__ */ __name(async (path, locator, maxBytes,
|
|
|
815
843
|
}
|
|
816
844
|
try {
|
|
817
845
|
signal?.throwIfAborted();
|
|
818
|
-
if ((await
|
|
846
|
+
if ((await file2.stat()).size > metadataLimit)
|
|
819
847
|
throw new Error("metadata limit");
|
|
820
848
|
const bytes2 = Buffer.alloc(metadataLimit + 1);
|
|
821
849
|
let size4 = 0;
|
|
822
850
|
while (size4 < bytes2.length) {
|
|
823
851
|
signal?.throwIfAborted();
|
|
824
|
-
const count2 = (await
|
|
852
|
+
const count2 = (await file2.read(bytes2, size4, bytes2.length - size4, size4)).bytesRead;
|
|
825
853
|
if (!count2)
|
|
826
854
|
break;
|
|
827
855
|
size4 += count2;
|
|
@@ -837,7 +865,7 @@ var readPartialMetadata = /* @__PURE__ */ __name(async (path, locator, maxBytes,
|
|
|
837
865
|
signal?.throwIfAborted();
|
|
838
866
|
throw new CliError("validation_error", "recording partial metadata is invalid");
|
|
839
867
|
} finally {
|
|
840
|
-
await
|
|
868
|
+
await file2.close();
|
|
841
869
|
}
|
|
842
870
|
}, "readPartialMetadata");
|
|
843
871
|
|
|
@@ -846,8 +874,8 @@ import { randomUUID } from "node:crypto";
|
|
|
846
874
|
import { open, rename, unlink } from "node:fs/promises";
|
|
847
875
|
import { join } from "node:path";
|
|
848
876
|
var partialWriter = /* @__PURE__ */ __name(async (input) => {
|
|
849
|
-
const { file, signal, partial } = input;
|
|
850
|
-
const owned = await
|
|
877
|
+
const { file: file2, signal, partial } = input;
|
|
878
|
+
const owned = await file2.stat({ bigint: true });
|
|
851
879
|
let size4 = input.fingerprint.offset;
|
|
852
880
|
const hash3 = input.fingerprint.hash;
|
|
853
881
|
let closed = false;
|
|
@@ -861,7 +889,7 @@ var partialWriter = /* @__PURE__ */ __name(async (input) => {
|
|
|
861
889
|
}, "usable");
|
|
862
890
|
const checkpoint = /* @__PURE__ */ __name(async () => {
|
|
863
891
|
await usable();
|
|
864
|
-
await
|
|
892
|
+
await file2.sync();
|
|
865
893
|
if (!partial.validator || !input.persistent) {
|
|
866
894
|
await syncDirectory(input.root);
|
|
867
895
|
signal?.throwIfAborted();
|
|
@@ -899,7 +927,7 @@ var partialWriter = /* @__PURE__ */ __name(async (input) => {
|
|
|
899
927
|
try {
|
|
900
928
|
while (offset < bytes2.length) {
|
|
901
929
|
signal?.throwIfAborted();
|
|
902
|
-
const written = (await
|
|
930
|
+
const written = (await file2.write(bytes2, offset, bytes2.length - offset, size4 + offset)).bytesWritten;
|
|
903
931
|
if (written === 0)
|
|
904
932
|
throw new CliError("configuration_error", "recording partial write did not progress");
|
|
905
933
|
offset += written;
|
|
@@ -924,7 +952,7 @@ var partialWriter = /* @__PURE__ */ __name(async (input) => {
|
|
|
924
952
|
return;
|
|
925
953
|
closed = true;
|
|
926
954
|
try {
|
|
927
|
-
await
|
|
955
|
+
await file2.close();
|
|
928
956
|
} catch (error) {
|
|
929
957
|
input.complete(null);
|
|
930
958
|
throw error;
|
|
@@ -971,14 +999,14 @@ var NativeRecordingPartialStore = class {
|
|
|
971
999
|
const value = await readPartialMetadata(this.metadataPath, this.locator, this.options.maxBytes, this.options.signal);
|
|
972
1000
|
if (!value)
|
|
973
1001
|
return null;
|
|
974
|
-
const
|
|
1002
|
+
const file2 = await openOrdinaryFile(this.path);
|
|
975
1003
|
try {
|
|
976
|
-
const actual = await fingerprintPartial(
|
|
1004
|
+
const actual = await fingerprintPartial(file2, this.options.signal, value.offset);
|
|
977
1005
|
if (actual.offset !== value.offset || actual.sha256 !== value.sha256)
|
|
978
1006
|
throw new CliError("validation_error", "recording partial checksum does not match");
|
|
979
1007
|
return value;
|
|
980
1008
|
} finally {
|
|
981
|
-
await
|
|
1009
|
+
await file2.close();
|
|
982
1010
|
}
|
|
983
1011
|
}
|
|
984
1012
|
async open(locator, options) {
|
|
@@ -994,12 +1022,12 @@ var NativeRecordingPartialStore = class {
|
|
|
994
1022
|
if (resume && (partialIdentity(resume.locator) !== partialIdentity(this.locator) || !Number.isSafeInteger(resume.offset) || resume.offset < 0 || resume.offset > this.options.maxBytes))
|
|
995
1023
|
throw new CliError("validation_error", "recording partial scope changed");
|
|
996
1024
|
this.completed = null;
|
|
997
|
-
let
|
|
1025
|
+
let file2;
|
|
998
1026
|
if (resume) {
|
|
999
|
-
|
|
1027
|
+
file2 = await openOrdinaryFile(this.path, { writable: true });
|
|
1000
1028
|
} else {
|
|
1001
1029
|
const temp = join2(this.root, `${this.options.prefix}${randomUUID2()}.tmp`);
|
|
1002
|
-
|
|
1030
|
+
file2 = await open2(temp, "wx+", 384);
|
|
1003
1031
|
try {
|
|
1004
1032
|
await rename2(temp, this.path);
|
|
1005
1033
|
await unlink2(this.metadataPath).catch((error) => {
|
|
@@ -1007,19 +1035,19 @@ var NativeRecordingPartialStore = class {
|
|
|
1007
1035
|
throw error;
|
|
1008
1036
|
});
|
|
1009
1037
|
} catch (error) {
|
|
1010
|
-
await
|
|
1038
|
+
await file2.close();
|
|
1011
1039
|
await unlink2(temp).catch(() => void 0);
|
|
1012
1040
|
throw error;
|
|
1013
1041
|
}
|
|
1014
1042
|
}
|
|
1015
1043
|
try {
|
|
1016
|
-
const fingerprint = await fingerprintPartial(
|
|
1044
|
+
const fingerprint = await fingerprintPartial(file2, this.options.signal, resume?.offset);
|
|
1017
1045
|
if (resume && (fingerprint.offset !== resume.offset || fingerprint.sha256 !== resume.sha256))
|
|
1018
1046
|
throw new CliError("validation_error", "recording partial changed before append");
|
|
1019
|
-
if (resume && (await
|
|
1020
|
-
await
|
|
1047
|
+
if (resume && (await file2.stat()).size > fingerprint.offset)
|
|
1048
|
+
await file2.truncate(fingerprint.offset);
|
|
1021
1049
|
return await partialWriter({
|
|
1022
|
-
file,
|
|
1050
|
+
file: file2,
|
|
1023
1051
|
path: this.path,
|
|
1024
1052
|
root: this.root,
|
|
1025
1053
|
metadataPath: this.metadataPath,
|
|
@@ -1034,7 +1062,7 @@ var NativeRecordingPartialStore = class {
|
|
|
1034
1062
|
}, "complete")
|
|
1035
1063
|
});
|
|
1036
1064
|
} catch (error) {
|
|
1037
|
-
await
|
|
1065
|
+
await file2.close();
|
|
1038
1066
|
throw error;
|
|
1039
1067
|
}
|
|
1040
1068
|
}
|
|
@@ -1049,21 +1077,21 @@ import { basename, dirname, join as join4, resolve } from "node:path";
|
|
|
1049
1077
|
import { unlink as unlink3 } from "node:fs/promises";
|
|
1050
1078
|
var verifiedPublicationFile = /* @__PURE__ */ __name(async (path, expected, signal, writable = false) => {
|
|
1051
1079
|
signal?.throwIfAborted();
|
|
1052
|
-
const
|
|
1080
|
+
const file2 = await openOrdinaryFile(path, { writable });
|
|
1053
1081
|
try {
|
|
1054
|
-
if ((await
|
|
1082
|
+
if ((await file2.stat()).size !== expected.size)
|
|
1055
1083
|
throw new CliError("validation_error", "recording recovery final checksum does not match");
|
|
1056
|
-
const actual = await fingerprintPartial(
|
|
1084
|
+
const actual = await fingerprintPartial(file2, signal, expected.size);
|
|
1057
1085
|
if (actual.offset !== expected.size || actual.sha256 !== expected.sha256)
|
|
1058
1086
|
throw new CliError("validation_error", "recording recovery final checksum does not match");
|
|
1059
|
-
return
|
|
1087
|
+
return file2;
|
|
1060
1088
|
} catch (error) {
|
|
1061
|
-
await
|
|
1089
|
+
await file2.close();
|
|
1062
1090
|
throw error;
|
|
1063
1091
|
}
|
|
1064
1092
|
}, "verifiedPublicationFile");
|
|
1065
|
-
var assertPublicationIdentity = /* @__PURE__ */ __name(async (path,
|
|
1066
|
-
if (!await sameOrdinaryFile(path, await
|
|
1093
|
+
var assertPublicationIdentity = /* @__PURE__ */ __name(async (path, file2) => {
|
|
1094
|
+
if (!await sameOrdinaryFile(path, await file2.stat({ bigint: true })))
|
|
1067
1095
|
throw new CliError("validation_error", "recording publication path changed");
|
|
1068
1096
|
}, "assertPublicationIdentity");
|
|
1069
1097
|
var commitPublication = /* @__PURE__ */ __name(async (root, partialPath, finalPath, partial, final, commit, signal) => {
|
|
@@ -1086,23 +1114,23 @@ import { open as open3, rename as rename3, unlink as unlink4 } from "node:fs/pro
|
|
|
1086
1114
|
import { join as join3 } from "node:path";
|
|
1087
1115
|
var readPublicationJournal = /* @__PURE__ */ __name(async (path, codec, limit, signal) => {
|
|
1088
1116
|
signal?.throwIfAborted();
|
|
1089
|
-
let
|
|
1117
|
+
let file2;
|
|
1090
1118
|
try {
|
|
1091
|
-
|
|
1119
|
+
file2 = await openOrdinaryFile(path);
|
|
1092
1120
|
} catch (error) {
|
|
1093
1121
|
if (missing(error))
|
|
1094
1122
|
return null;
|
|
1095
1123
|
throw error;
|
|
1096
1124
|
}
|
|
1097
1125
|
try {
|
|
1098
|
-
if ((await
|
|
1126
|
+
if ((await file2.stat()).size > limit)
|
|
1099
1127
|
throw new Error("metadata limit");
|
|
1100
|
-
const identity = await
|
|
1128
|
+
const identity = await file2.stat({ bigint: true });
|
|
1101
1129
|
const bytes2 = Buffer.alloc(limit + 1);
|
|
1102
1130
|
let size4 = 0;
|
|
1103
1131
|
while (size4 < bytes2.length) {
|
|
1104
1132
|
signal?.throwIfAborted();
|
|
1105
|
-
const count2 = (await
|
|
1133
|
+
const count2 = (await file2.read(bytes2, size4, bytes2.length - size4, size4)).bytesRead;
|
|
1106
1134
|
if (!count2)
|
|
1107
1135
|
break;
|
|
1108
1136
|
size4 += count2;
|
|
@@ -1118,7 +1146,7 @@ var readPublicationJournal = /* @__PURE__ */ __name(async (path, codec, limit, s
|
|
|
1118
1146
|
signal?.throwIfAborted();
|
|
1119
1147
|
throw new CliError("validation_error", "recording recovery record does not match this scoped asset");
|
|
1120
1148
|
} finally {
|
|
1121
|
-
await
|
|
1149
|
+
await file2.close();
|
|
1122
1150
|
}
|
|
1123
1151
|
}, "readPublicationJournal");
|
|
1124
1152
|
var writePublicationJournal = /* @__PURE__ */ __name(async (root, path, prefix, value, codec, limit, signal) => {
|
|
@@ -1255,18 +1283,18 @@ var parseMediaEntry = /* @__PURE__ */ __name((value) => {
|
|
|
1255
1283
|
}, "parseMediaEntry");
|
|
1256
1284
|
var mediaFingerprint = /* @__PURE__ */ __name(async (path, signal) => {
|
|
1257
1285
|
signal?.throwIfAborted();
|
|
1258
|
-
const
|
|
1286
|
+
const file2 = await openOrdinaryFile(path);
|
|
1259
1287
|
try {
|
|
1260
1288
|
const hash3 = createHash4("sha256");
|
|
1261
1289
|
let size4 = 0;
|
|
1262
|
-
for await (const chunk of
|
|
1290
|
+
for await (const chunk of file2.createReadStream({ autoClose: false, ...signal ? { signal } : {} })) {
|
|
1263
1291
|
signal?.throwIfAborted();
|
|
1264
1292
|
hash3.update(chunk);
|
|
1265
1293
|
size4 += chunk.length;
|
|
1266
1294
|
}
|
|
1267
1295
|
return { size: size4, sha256: hash3.digest("hex") };
|
|
1268
1296
|
} finally {
|
|
1269
|
-
await
|
|
1297
|
+
await file2.close();
|
|
1270
1298
|
}
|
|
1271
1299
|
}, "mediaFingerprint");
|
|
1272
1300
|
var readMediaManifests = /* @__PURE__ */ __name(async (root, signal) => {
|
|
@@ -1316,7 +1344,7 @@ var commitMediaEntry = /* @__PURE__ */ __name((root, one, beforePublish) => writ
|
|
|
1316
1344
|
// node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/media-archive-files.js
|
|
1317
1345
|
var validator = '"media-completed-v1"';
|
|
1318
1346
|
var maximumFileBytes = 64 * 1024 * 1024 * 1024;
|
|
1319
|
-
var archiveMediaFile = /* @__PURE__ */ __name(async (root, identity, kind,
|
|
1347
|
+
var archiveMediaFile = /* @__PURE__ */ __name(async (root, identity, kind, file2, beforeWrite, signal, metadata = {}) => {
|
|
1320
1348
|
const key = mediaKey(identity);
|
|
1321
1349
|
const locator = {
|
|
1322
1350
|
provider: identity.provider,
|
|
@@ -1376,7 +1404,7 @@ var archiveMediaFile = /* @__PURE__ */ __name(async (root, identity, kind, file,
|
|
|
1376
1404
|
await publication.publish(storage.path, intent, () => commit(intent));
|
|
1377
1405
|
return intent;
|
|
1378
1406
|
}
|
|
1379
|
-
const remote = await
|
|
1407
|
+
const remote = await file2();
|
|
1380
1408
|
if (remote.size !== void 0 && (!Number.isSafeInteger(remote.size) || remote.size < 0 || remote.size > maximumFileBytes))
|
|
1381
1409
|
throw new CliError("validation_error", "invalid media download size");
|
|
1382
1410
|
await beforeWrite();
|
|
@@ -1530,10 +1558,10 @@ var saveMessage = /* @__PURE__ */ __name(async (root, account2, message, ports,
|
|
|
1530
1558
|
name: one.name ?? null
|
|
1531
1559
|
})), download.files);
|
|
1532
1560
|
const index = positions.indexOf(position);
|
|
1533
|
-
const
|
|
1534
|
-
if (!
|
|
1561
|
+
const file2 = download.files[index];
|
|
1562
|
+
if (!file2)
|
|
1535
1563
|
throw new CliError("invalid_response", "the messenger did not return an identifiable attachment");
|
|
1536
|
-
return
|
|
1564
|
+
return file2;
|
|
1537
1565
|
}, beforeWrite, options.signal, { messageTime: new Date(message.timestamp).toISOString(), ...attachment2.mime ? { mime: attachment2.mime } : {} });
|
|
1538
1566
|
known2.set(key, entry);
|
|
1539
1567
|
saved++;
|
|
@@ -1650,16 +1678,16 @@ var canonicalDestination = /* @__PURE__ */ __name(async (directory) => {
|
|
|
1650
1678
|
var image = /* @__PURE__ */ __name((entry) => ["photo", "image"].includes(entry.kind) || entry.mime?.startsWith("image/"), "image");
|
|
1651
1679
|
var removeLocalCopy = /* @__PURE__ */ __name(async (root, entry, beforeWrite, signal) => {
|
|
1652
1680
|
const path = join7(root, entry.path);
|
|
1653
|
-
let
|
|
1681
|
+
let file2;
|
|
1654
1682
|
try {
|
|
1655
|
-
|
|
1683
|
+
file2 = await openOrdinaryFile(path);
|
|
1656
1684
|
} catch (error) {
|
|
1657
1685
|
if (missingMediaFile(error))
|
|
1658
1686
|
return;
|
|
1659
1687
|
throw error;
|
|
1660
1688
|
}
|
|
1661
1689
|
try {
|
|
1662
|
-
const identity = await
|
|
1690
|
+
const identity = await file2.stat({ bigint: true });
|
|
1663
1691
|
const proof = await mediaFingerprint(path, signal);
|
|
1664
1692
|
if (proof.size !== entry.size || proof.sha256 !== entry.sha256 || !await sameOrdinaryFile(path, identity))
|
|
1665
1693
|
throw new CliError("validation_error", "local image changed during rotation; it was preserved");
|
|
@@ -1671,7 +1699,7 @@ var removeLocalCopy = /* @__PURE__ */ __name(async (root, entry, beforeWrite, si
|
|
|
1671
1699
|
await unlink5(path);
|
|
1672
1700
|
await syncDirectory(root);
|
|
1673
1701
|
} finally {
|
|
1674
|
-
await
|
|
1702
|
+
await file2.close();
|
|
1675
1703
|
}
|
|
1676
1704
|
}, "removeLocalCopy");
|
|
1677
1705
|
var moveMediaArchive = /* @__PURE__ */ __name(async (options) => {
|
|
@@ -1736,7 +1764,7 @@ var moveMediaArchive = /* @__PURE__ */ __name(async (options) => {
|
|
|
1736
1764
|
for (const entry of candidates) {
|
|
1737
1765
|
await beforeWrite();
|
|
1738
1766
|
if (!known2.has(mediaKey(entry))) {
|
|
1739
|
-
const
|
|
1767
|
+
const file2 = await openOrdinaryFile(join7(root, entry.path));
|
|
1740
1768
|
try {
|
|
1741
1769
|
const identity = {
|
|
1742
1770
|
provider: entry.provider,
|
|
@@ -1748,7 +1776,7 @@ var moveMediaArchive = /* @__PURE__ */ __name(async (options) => {
|
|
|
1748
1776
|
const copied = await archiveMediaFile(target, identity, entry.kind, async () => ({
|
|
1749
1777
|
kind: entry.kind,
|
|
1750
1778
|
size: entry.size,
|
|
1751
|
-
bytes: /* @__PURE__ */ __name(() =>
|
|
1779
|
+
bytes: /* @__PURE__ */ __name(() => file2.createReadStream({ autoClose: false, ...options.signal ? { signal: options.signal } : {} }), "bytes")
|
|
1752
1780
|
}), beforeWrite, options.signal, {
|
|
1753
1781
|
messageTime: entry.messageTime,
|
|
1754
1782
|
mime: entry.mime,
|
|
@@ -1756,7 +1784,7 @@ var moveMediaArchive = /* @__PURE__ */ __name(async (options) => {
|
|
|
1756
1784
|
});
|
|
1757
1785
|
known2.set(mediaKey(entry), copied);
|
|
1758
1786
|
} finally {
|
|
1759
|
-
await
|
|
1787
|
+
await file2.close();
|
|
1760
1788
|
}
|
|
1761
1789
|
}
|
|
1762
1790
|
const receipt = parseMediaEntry({ ...entry, relocatedTo: target });
|
|
@@ -1788,7 +1816,7 @@ var moveMediaArchive = /* @__PURE__ */ __name(async (options) => {
|
|
|
1788
1816
|
}, "moveMediaArchive");
|
|
1789
1817
|
|
|
1790
1818
|
// node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/model-downloads.js
|
|
1791
|
-
var bytesOf = /* @__PURE__ */ __name((model) => model.files.reduce((sum2,
|
|
1819
|
+
var bytesOf = /* @__PURE__ */ __name((model) => model.files.reduce((sum2, file2) => sum2 + file2.bytes, 0), "bytesOf");
|
|
1792
1820
|
var nativeRuntime = /* @__PURE__ */ __name(async ({ env, progress = /* @__PURE__ */ __name(() => {
|
|
1793
1821
|
}, "progress") }) => {
|
|
1794
1822
|
try {
|
|
@@ -1810,7 +1838,7 @@ var downloadTextModel = /* @__PURE__ */ __name(async (id2, { env, progress = /*
|
|
|
1810
1838
|
}
|
|
1811
1839
|
await nativeRuntime({ env, progress });
|
|
1812
1840
|
progress(`${model.id}: loading it once to check it works`);
|
|
1813
|
-
const { openEmbedder: openEmbedder2 } = await import("./embed-
|
|
1841
|
+
const { openEmbedder: openEmbedder2 } = await import("./embed-HW3N3KNP.js");
|
|
1814
1842
|
const embedder = await openEmbedder2(model, directory);
|
|
1815
1843
|
try {
|
|
1816
1844
|
const [vector] = await embedder.embed(["check"], "query");
|
|
@@ -1831,7 +1859,7 @@ var downloadRerankModel = /* @__PURE__ */ __name(async (id2, { env, progress = /
|
|
|
1831
1859
|
}
|
|
1832
1860
|
await nativeRuntime({ env, progress });
|
|
1833
1861
|
progress(`${model.id}: loading it once to check it works`);
|
|
1834
|
-
const { openReranker } = await import("./rerank-
|
|
1862
|
+
const { openReranker } = await import("./rerank-YFUB6J6M.js");
|
|
1835
1863
|
const reranker = await openReranker(model, directory);
|
|
1836
1864
|
try {
|
|
1837
1865
|
await reranker.score("check", ["check"]);
|
|
@@ -1849,7 +1877,7 @@ var downloadImageModel = /* @__PURE__ */ __name(async (id2, { env, progress = /*
|
|
|
1849
1877
|
await installFiles(placedImage(model, directory), { progress });
|
|
1850
1878
|
}
|
|
1851
1879
|
progress(`${model.id}: loading it once to check it works`);
|
|
1852
|
-
const { openPictureEmbedder } = await import("./embedder-
|
|
1880
|
+
const { openPictureEmbedder } = await import("./embedder-7WNFXYYP.js");
|
|
1853
1881
|
const embedder = await openPictureEmbedder(model, directory);
|
|
1854
1882
|
try {
|
|
1855
1883
|
const vector = await embedder.embedQuery("check");
|
|
@@ -1982,9 +2010,9 @@ var fail = /* @__PURE__ */ __name((message, param) => {
|
|
|
1982
2010
|
throw new CliError("validation_error", message, param ? { param } : void 0);
|
|
1983
2011
|
}, "fail");
|
|
1984
2012
|
var known = /* @__PURE__ */ __name((value, allowed, prefix) => {
|
|
1985
|
-
const
|
|
1986
|
-
if (
|
|
1987
|
-
fail(`${prefix}${
|
|
2013
|
+
const unknown2 = Object.keys(value).find((key) => !allowed.includes(key));
|
|
2014
|
+
if (unknown2)
|
|
2015
|
+
fail(`${prefix}${unknown2} is not supported`, `${prefix}${unknown2}`);
|
|
1988
2016
|
}, "known");
|
|
1989
2017
|
var text = /* @__PURE__ */ __name((value, name, max) => typeof value === "string" && value.trim() && Buffer.byteLength(value) <= max ? value.trim() : fail(`${name} needs 1\u2013${max} UTF-8 bytes`, name), "text");
|
|
1990
2018
|
var whole = /* @__PURE__ */ __name((value, name, low, high) => Number.isSafeInteger(value) && value >= low && value <= high ? value : fail(`${name} must be a whole number from ${low} to ${high}`, name), "whole");
|
|
@@ -2683,7 +2711,7 @@ var matchProjectCandidates = /* @__PURE__ */ __name((catalog, input) => matchVoc
|
|
|
2683
2711
|
}))
|
|
2684
2712
|
]).map(({ entry, matches, omitted }) => ({
|
|
2685
2713
|
project: { reference: `project:${entry.id}`, id: entry.id, name: entry.name, key: entry.key },
|
|
2686
|
-
matches: matches.map(({ term, source, ambiguous }) => ({ term, source, ambiguous })),
|
|
2714
|
+
matches: matches.map(({ term, source, ambiguous: ambiguous2 }) => ({ term, source, ambiguous: ambiguous2 })),
|
|
2687
2715
|
omittedMatches: omitted
|
|
2688
2716
|
})), "matchProjectCandidates");
|
|
2689
2717
|
|
|
@@ -2722,7 +2750,7 @@ var findEvidenceMentions = /* @__PURE__ */ __name(async (vocabulary, gathering,
|
|
|
2722
2750
|
continue;
|
|
2723
2751
|
items.push({
|
|
2724
2752
|
target: { kind, id: entry.id, reference, name: entry.name, key: entry.key },
|
|
2725
|
-
matches: matches.map(({ term, source, ambiguous }) => ({ term, ambiguous, ...source })),
|
|
2753
|
+
matches: matches.map(({ term, source, ambiguous: ambiguous2 }) => ({ term, ambiguous: ambiguous2, ...source })),
|
|
2726
2754
|
omittedMatches: omitted
|
|
2727
2755
|
});
|
|
2728
2756
|
}
|
|
@@ -2771,12 +2799,12 @@ var accountService = /* @__PURE__ */ __name((deps) => {
|
|
|
2771
2799
|
throw new CliError("validation_error", `\`${command}\` changes the account; not with --offline`);
|
|
2772
2800
|
return deps.connection();
|
|
2773
2801
|
}, "online");
|
|
2774
|
-
const onOneChat = /* @__PURE__ */ __name(async (command, chat,
|
|
2802
|
+
const onOneChat = /* @__PURE__ */ __name(async (command, chat, action2, write) => {
|
|
2775
2803
|
const connection = await online(command);
|
|
2776
2804
|
const act2 = write(connection);
|
|
2777
2805
|
const { id: chatId } = await connection.resolve(chat);
|
|
2778
2806
|
const operationId = newOperationId();
|
|
2779
|
-
await guardedWrite(deps.guard, { operationId, chatId, kind: "account", action }, () => act2(chatId));
|
|
2807
|
+
await guardedWrite(deps.guard, { operationId, chatId, kind: "account", action: action2 }, () => act2(chatId));
|
|
2780
2808
|
return { operationId, chatId };
|
|
2781
2809
|
}, "onOneChat");
|
|
2782
2810
|
return {
|
|
@@ -2866,7 +2894,7 @@ var recordMembership = /* @__PURE__ */ __name(async (deps, operationId, done2, c
|
|
|
2866
2894
|
throw new CliError(isCliError(error) ? error.code : "invalid_response", `${done2}, but the local store could not ${change} (${reason}) \u2014 do not run it again; ${fix}`, { operation_id: operationId, retryable: false });
|
|
2867
2895
|
}
|
|
2868
2896
|
}, "recordMembership");
|
|
2869
|
-
var reportedFix = /* @__PURE__ */ __name((deps, chatId, shows,
|
|
2897
|
+
var reportedFix = /* @__PURE__ */ __name((deps, chatId, shows, action2) => `it may show as ${shows} until the messenger reports the ${action2}; \`${typedCommand(deps.messenger.app.command, `chats show ${chatId}`)}\` says when it has`, "reportedFix");
|
|
2870
2898
|
var adminService = /* @__PURE__ */ __name((deps) => {
|
|
2871
2899
|
const online = /* @__PURE__ */ __name(async (command) => {
|
|
2872
2900
|
if (deps.offline)
|
|
@@ -2879,16 +2907,16 @@ var adminService = /* @__PURE__ */ __name((deps) => {
|
|
|
2879
2907
|
throw new CliError("validation_error", "a group needs a title");
|
|
2880
2908
|
const connection = await online("chats create");
|
|
2881
2909
|
const create = capability(connection, "createGroup", "create a group");
|
|
2882
|
-
const
|
|
2910
|
+
const personIds2 = people.length === 0 ? [] : await capability(connection, "people", "find people")(people);
|
|
2883
2911
|
const operationId = newOperationId();
|
|
2884
|
-
const chat = await guardedWrite(deps.guard, { operationId, chatId: null, kind: "chat", action: "create", personIds, people:
|
|
2912
|
+
const chat = await guardedWrite(deps.guard, { operationId, chatId: null, kind: "chat", action: "create", personIds: personIds2, people: personIds2.length }, () => create(title.trim(), personIds2, { channel }), (made) => ({ chatId: made.id }));
|
|
2885
2913
|
return { operationId, chat };
|
|
2886
2914
|
}, "create"),
|
|
2887
2915
|
join: /* @__PURE__ */ __name(async (link4) => {
|
|
2888
2916
|
const connection = await online("chats join");
|
|
2889
|
-
const
|
|
2917
|
+
const join11 = capability(connection, "join", "join a chat by its link");
|
|
2890
2918
|
const operationId = newOperationId();
|
|
2891
|
-
const joined = await guardedWrite(deps.guard, { operationId, chatId: null, kind: "chat", action: "join" }, () =>
|
|
2919
|
+
const joined = await guardedWrite(deps.guard, { operationId, chatId: null, kind: "chat", action: "join" }, () => join11(link4.trim()), (answer) => "requested" in answer ? {} : { chatId: answer.id });
|
|
2892
2920
|
if ("requested" in joined)
|
|
2893
2921
|
return { operationId, requested: true };
|
|
2894
2922
|
const fix = deps.reads === "store" ? reportedFix(deps, joined.id, "left", "join") : `an online \`${typedCommand(deps.messenger.app.command, "chats list")}\` that shows the chat corrects it`;
|
|
@@ -2942,8 +2970,8 @@ var adminService = /* @__PURE__ */ __name((deps) => {
|
|
|
2942
2970
|
const update = capability(connection, "updateGroup", "change a group");
|
|
2943
2971
|
const { id: chatId } = await connection.resolve(chat);
|
|
2944
2972
|
const operationId = newOperationId();
|
|
2945
|
-
const
|
|
2946
|
-
const card = await guardedWrite(deps.guard, { operationId, chatId, kind: "chat", action }, () => update(chatId, change));
|
|
2973
|
+
const action2 = profile ? "update" : "settings";
|
|
2974
|
+
const card = await guardedWrite(deps.guard, { operationId, chatId, kind: "chat", action: action2 }, () => update(chatId, change));
|
|
2947
2975
|
return { operationId, chat: card };
|
|
2948
2976
|
}, "update"),
|
|
2949
2977
|
link: /* @__PURE__ */ __name(async (chat) => {
|
|
@@ -2982,9 +3010,9 @@ var adminService = /* @__PURE__ */ __name((deps) => {
|
|
|
2982
3010
|
if (window2.search?.trim() === "" || window2.link?.trim() === "")
|
|
2983
3011
|
throw new CliError("validation_error", "a name or a link needs a value");
|
|
2984
3012
|
const connection = await deps.connection();
|
|
2985
|
-
const
|
|
3013
|
+
const list3 = capability(connection, "joinRequests", "read join requests");
|
|
2986
3014
|
const { id: chatId } = await connection.resolve(chat);
|
|
2987
|
-
return { chatId, ...await
|
|
3015
|
+
return { chatId, ...await list3(chatId, window2) };
|
|
2988
3016
|
}, "requests"),
|
|
2989
3017
|
answerRequest: /* @__PURE__ */ __name(async (chat, person, accept) => {
|
|
2990
3018
|
const connection = await online(`chats requests ${accept ? "accept" : "decline"}`);
|
|
@@ -2997,10 +3025,10 @@ var adminService = /* @__PURE__ */ __name((deps) => {
|
|
|
2997
3025
|
}, "answerRequest"),
|
|
2998
3026
|
answerAllRequests: /* @__PURE__ */ __name(async (chat, accept, { link: link4 }) => {
|
|
2999
3027
|
const connection = await online(`chats requests ${accept ? "accept" : "decline"} --all`);
|
|
3000
|
-
const
|
|
3028
|
+
const list3 = capability(connection, "joinRequests", "read join requests");
|
|
3001
3029
|
const answerAll = capability(connection, "answerAllJoinRequests", "answer every join request at once");
|
|
3002
3030
|
const { id: chatId } = await connection.resolve(chat);
|
|
3003
|
-
const page = await
|
|
3031
|
+
const page = await list3(chatId, { limit: 100, ...link4 === void 0 ? {} : { link: link4 } });
|
|
3004
3032
|
const counted2 = page.total ?? page.items.length;
|
|
3005
3033
|
if (page.total === void 0 && page.hasMore)
|
|
3006
3034
|
throw new CliError("validation_error", "too many requests to count; answer them by person, or by --link");
|
|
@@ -3021,9 +3049,9 @@ var adminService = /* @__PURE__ */ __name((deps) => {
|
|
|
3021
3049
|
if (deps.offline)
|
|
3022
3050
|
throw new CliError("validation_error", "invite links are read from the messenger; not with --offline");
|
|
3023
3051
|
const connection = await deps.connection();
|
|
3024
|
-
const
|
|
3052
|
+
const list3 = capability(connection, "inviteLinks", "list invite links");
|
|
3025
3053
|
const { id: chatId } = await connection.resolve(chat);
|
|
3026
|
-
return { chatId, ...await
|
|
3054
|
+
return { chatId, ...await list3(chatId, window2) };
|
|
3027
3055
|
}, "links"),
|
|
3028
3056
|
revokeLink: /* @__PURE__ */ __name(async (chat, link4) => {
|
|
3029
3057
|
if (link4.trim() === "")
|
|
@@ -3057,20 +3085,20 @@ var adminService = /* @__PURE__ */ __name((deps) => {
|
|
|
3057
3085
|
addMembers: /* @__PURE__ */ __name(async (chat, people, options) => {
|
|
3058
3086
|
const connection = await online("chats members add");
|
|
3059
3087
|
const add = capability(connection, "addMembers", "add people to a group");
|
|
3060
|
-
const
|
|
3088
|
+
const personIds2 = await capability(connection, "people", "find people")(people);
|
|
3061
3089
|
const { id: chatId } = await connection.resolve(chat);
|
|
3062
3090
|
const operationId = newOperationId();
|
|
3063
|
-
const { notAdded } = await guardedWrite(deps.guard, { operationId, chatId, kind: "chat", action: "members.add", personIds, people:
|
|
3064
|
-
return { operationId, chatId, added:
|
|
3091
|
+
const { notAdded } = await guardedWrite(deps.guard, { operationId, chatId, kind: "chat", action: "members.add", personIds: personIds2, people: personIds2.length }, () => add(chatId, personIds2, options));
|
|
3092
|
+
return { operationId, chatId, added: personIds2.filter((id2) => !notAdded.includes(id2)), notAdded };
|
|
3065
3093
|
}, "addMembers"),
|
|
3066
3094
|
removeMembers: /* @__PURE__ */ __name(async (chat, people) => {
|
|
3067
3095
|
const connection = await online("chats members remove");
|
|
3068
3096
|
const remove = capability(connection, "removeMembers", "remove people from a group");
|
|
3069
|
-
const
|
|
3097
|
+
const personIds2 = await capability(connection, "people", "find people")(people);
|
|
3070
3098
|
const { id: chatId } = await connection.resolve(chat);
|
|
3071
3099
|
const operationId = newOperationId();
|
|
3072
|
-
await guardedWrite(deps.guard, { operationId, chatId, kind: "chat", action: "members.remove", people:
|
|
3073
|
-
return { operationId, chatId, removed:
|
|
3100
|
+
await guardedWrite(deps.guard, { operationId, chatId, kind: "chat", action: "members.remove", people: personIds2.length }, () => remove(chatId, personIds2));
|
|
3101
|
+
return { operationId, chatId, removed: personIds2 };
|
|
3074
3102
|
}, "removeMembers"),
|
|
3075
3103
|
addAdmin: /* @__PURE__ */ __name(async (chat, person, rights) => {
|
|
3076
3104
|
if (rights.length === 0)
|
|
@@ -3423,16 +3451,16 @@ var prepareLucene = /* @__PURE__ */ __name(async (store, account2, request, mess
|
|
|
3423
3451
|
if (request.senders !== void 0 && leaves.some(({ field }) => field === "from"))
|
|
3424
3452
|
throw new CliError("validation_error", "--from and from: together \u2014 name the people once");
|
|
3425
3453
|
const chosen = request.accounts ?? listed?.accounts ?? (source !== void 0 ? held.filter(({ provider }) => inSource(source, provider)) : sources.length ? held.filter(({ provider }) => sources.some((source2) => inSource(source2, provider))) : [account2]);
|
|
3426
|
-
const
|
|
3427
|
-
const unknownSkipped =
|
|
3454
|
+
const unknown2 = chosen.filter(({ provider }) => provider !== account2.provider && kindIn(provider) === void 0);
|
|
3455
|
+
const unknownSkipped = unknown2.map(({ provider, account: account3 }) => ({
|
|
3428
3456
|
source: `${provider}:${account3}`,
|
|
3429
3457
|
code: "not_found",
|
|
3430
3458
|
reason: UNKNOWN_PROVIDER
|
|
3431
3459
|
}));
|
|
3432
|
-
if (
|
|
3460
|
+
if (unknown2.length > 0 && unknown2.length === chosen.length)
|
|
3433
3461
|
throw new CliError("not_found", `this search reads nothing: ${unknownSkipped.map(({ source: source2 }) => source2).join(", ")} (${UNKNOWN_PROVIDER})`);
|
|
3434
3462
|
const skipped = [...listed?.skipped ?? [], ...unknownSkipped];
|
|
3435
|
-
const accounts = accountsOfKind(request.kind, chosen.filter((one) => !
|
|
3463
|
+
const accounts = accountsOfKind(request.kind, chosen.filter((one) => !unknown2.includes(one)), held, source ?? (sources.includes("email") ? "email" : sources[0]), messenger.app?.command, request.mailAccount, listed !== void 0 || request.accounts !== void 0);
|
|
3436
3464
|
const scopeAccounts = accounts.map(({ provider, account: account3 }) => ({ provider, account: account3 }));
|
|
3437
3465
|
const chatLookup = scopeAccounts.some(({ provider }) => provider === MAIL) ? withMailThreads(store) : store;
|
|
3438
3466
|
const mailField = leaves.find(({ field, value }) => MAIL_FIELDS.has(field) && !(field === "is" && value.toLowerCase() === "starred" && messenger.messageStars === true));
|
|
@@ -4473,7 +4501,7 @@ var auditMembers = /* @__PURE__ */ __name((members, { firstMessages, self, minSc
|
|
|
4473
4501
|
};
|
|
4474
4502
|
}).filter(({ score }) => score >= minScore).sort((a, b) => b.score - a.score || a.id.localeCompare(b.id));
|
|
4475
4503
|
const carried = /* @__PURE__ */ __name((field) => members.some((member) => member[field] !== void 0), "carried");
|
|
4476
|
-
const
|
|
4504
|
+
const unknown2 = [
|
|
4477
4505
|
...carried("isBot") ? [] : ["bot"],
|
|
4478
4506
|
...carried("flagged") ? [] : ["scam", "fake"],
|
|
4479
4507
|
...carried("deleted") ? [] : ["deleted"],
|
|
@@ -4482,7 +4510,7 @@ var auditMembers = /* @__PURE__ */ __name((members, { firstMessages, self, minSc
|
|
|
4482
4510
|
...carried("joinedAt") ? [] : ["burst_join"],
|
|
4483
4511
|
...carried("invitedBy") ? [] : ["mass_invited"]
|
|
4484
4512
|
];
|
|
4485
|
-
return { items, unknown };
|
|
4513
|
+
return { items, unknown: unknown2 };
|
|
4486
4514
|
}, "auditMembers");
|
|
4487
4515
|
var burstJoins = /* @__PURE__ */ __name((members) => {
|
|
4488
4516
|
const joined = members.flatMap(({ id: id2, joinedAt }) => joinedAt ? [{ id: id2, at: Date.parse(joinedAt) }] : []).sort((a, b) => a.at - b.at);
|
|
@@ -4530,11 +4558,11 @@ var deepChecks = /* @__PURE__ */ __name(async (deps, items, deep, pauseMs, regis
|
|
|
4530
4558
|
}
|
|
4531
4559
|
if (index > 0)
|
|
4532
4560
|
await new Promise((resolve7) => setTimeout(resolve7, pauseMs));
|
|
4533
|
-
const { score, reasons, registries, unknown } = await checks.person(item.id, {
|
|
4561
|
+
const { score, reasons, registries, unknown: unknown2 } = await checks.person(item.id, {
|
|
4534
4562
|
registries: true,
|
|
4535
4563
|
...registry ? { registry } : {}
|
|
4536
4564
|
});
|
|
4537
|
-
checked2.push({ ...item, check: { score, reasons, registries, unknown } });
|
|
4565
|
+
checked2.push({ ...item, check: { score, reasons, registries, unknown: unknown2 } });
|
|
4538
4566
|
}
|
|
4539
4567
|
return checked2;
|
|
4540
4568
|
}, "deepChecks");
|
|
@@ -4643,7 +4671,7 @@ var chatsService = /* @__PURE__ */ __name((deps) => ({
|
|
|
4643
4671
|
const { chatId: id2, members: read, more, participants } = await readMembers(connection, chat, budget, pauseMs);
|
|
4644
4672
|
const held = await accountStoreIfOpen(deps);
|
|
4645
4673
|
const stored = held ? await storedFacts(held, id2) : void 0;
|
|
4646
|
-
const { items: judged, unknown } = auditMembers(read, {
|
|
4674
|
+
const { items: judged, unknown: unknown2 } = auditMembers(read, {
|
|
4647
4675
|
firstMessages: stored?.firstMessages,
|
|
4648
4676
|
self: connection.self(),
|
|
4649
4677
|
minScore
|
|
@@ -4654,7 +4682,7 @@ var chatsService = /* @__PURE__ */ __name((deps) => ({
|
|
|
4654
4682
|
read: read.length,
|
|
4655
4683
|
participantsCount: participants ?? stored?.participantsCount ?? null,
|
|
4656
4684
|
more,
|
|
4657
|
-
unknown,
|
|
4685
|
+
unknown: unknown2,
|
|
4658
4686
|
...stored?.completeness ? { completeness: stored.completeness } : {},
|
|
4659
4687
|
...stored?.completeness && stored.completeness.state !== "complete" && syncsOneChat(deps.messenger) ? { fetch: typedCommand(deps.messenger.app.command, `messages sync ${id2}`) } : {},
|
|
4660
4688
|
items
|
|
@@ -5153,8 +5181,8 @@ var agendaService = /* @__PURE__ */ __name((deps, now = Date.now) => ({
|
|
|
5153
5181
|
waiting: chats.filter((chat) => chat.lastFromOwner === true && silentFor(chat) >= waiting),
|
|
5154
5182
|
unsynced: chats.filter((chat) => chat.lastMessage === null)
|
|
5155
5183
|
};
|
|
5156
|
-
const covered = new Map((await chatCoverage(store, account2, Object.values(shown).flatMap((
|
|
5157
|
-
const withCoverage = /* @__PURE__ */ __name((
|
|
5184
|
+
const covered = new Map((await chatCoverage(store, account2, Object.values(shown).flatMap((list3) => list3.map(({ chatId }) => chatId)))).map((one) => [one.chatId, one]));
|
|
5185
|
+
const withCoverage = /* @__PURE__ */ __name((list3) => list3.map((chat) => ({ ...chat, coverage: covered.get(chat.chatId) })), "withCoverage");
|
|
5158
5186
|
const inList = new Set((await store.tasks.categories()).map(({ name }) => name));
|
|
5159
5187
|
const unlisted = /* @__PURE__ */ new Map();
|
|
5160
5188
|
for (const { category } of open7)
|
|
@@ -5735,7 +5763,7 @@ var embeddingTarget = /* @__PURE__ */ __name((deps, choice = DEFAULT_TEXT_MODEL)
|
|
|
5735
5763
|
price: remote.price,
|
|
5736
5764
|
installed: true,
|
|
5737
5765
|
perBatch: PER_REQUEST * concurrency,
|
|
5738
|
-
open: /* @__PURE__ */ __name(async () => (await import("./remote-
|
|
5766
|
+
open: /* @__PURE__ */ __name(async () => (await import("./remote-WREGEZJQ.js")).openRemote(remote, apiKey, { concurrency }), "open")
|
|
5739
5767
|
};
|
|
5740
5768
|
}
|
|
5741
5769
|
const model = textModel(choice);
|
|
@@ -6205,10 +6233,10 @@ var archiveService = /* @__PURE__ */ __name((deps) => {
|
|
|
6205
6233
|
return deps.withConnection((adapter) => archiveService({ ...deps, withConnection: void 0, connection: /* @__PURE__ */ __name(async () => adapter, "connection") }).fetchAll(options));
|
|
6206
6234
|
pushed(deps, "`messages sync --all`");
|
|
6207
6235
|
const connection = await deps.connection();
|
|
6208
|
-
const
|
|
6236
|
+
const list3 = capability(connection, "chats", "list its chats");
|
|
6209
6237
|
const chats = [];
|
|
6210
6238
|
for (let offset = 0; ; ) {
|
|
6211
|
-
const page = await patiently(() =>
|
|
6239
|
+
const page = await patiently(() => list3({ offset, limit: 100 }), options.note, options.stop);
|
|
6212
6240
|
chats.push(...page.items);
|
|
6213
6241
|
offset += page.items.length;
|
|
6214
6242
|
if (!page.hasMore || page.items.length === 0)
|
|
@@ -6444,7 +6472,7 @@ var gapsService = /* @__PURE__ */ __name((deps) => {
|
|
|
6444
6472
|
});
|
|
6445
6473
|
const knownStart = await store.sync.syncState(account2, historyStartKey(chatId));
|
|
6446
6474
|
const start = knownStart === null ? NaN : Number(knownStart?.value);
|
|
6447
|
-
const
|
|
6475
|
+
const unknown2 = { older: !Number.isSafeInteger(start) || !held[0] || held[0].from > start, newer: true };
|
|
6448
6476
|
const identity = { account: account2, chat: chatId, ordering, held };
|
|
6449
6477
|
return {
|
|
6450
6478
|
version: 1,
|
|
@@ -6452,7 +6480,7 @@ var gapsService = /* @__PURE__ */ __name((deps) => {
|
|
|
6452
6480
|
...identity,
|
|
6453
6481
|
limits: { ...GAP_BOUNDS, pageSize: (deps.messenger.fetching ?? FETCHING).page },
|
|
6454
6482
|
gaps,
|
|
6455
|
-
unknown,
|
|
6483
|
+
unknown: unknown2,
|
|
6456
6484
|
fingerprint: createHash6("sha256").update(JSON.stringify(identity)).digest("hex")
|
|
6457
6485
|
};
|
|
6458
6486
|
}, "plan");
|
|
@@ -6576,13 +6604,13 @@ var SIGNATURES = {
|
|
|
6576
6604
|
}, ".webp")
|
|
6577
6605
|
};
|
|
6578
6606
|
var fileHead = /* @__PURE__ */ __name(async (path) => {
|
|
6579
|
-
const
|
|
6607
|
+
const file2 = await open4(path, "r");
|
|
6580
6608
|
try {
|
|
6581
6609
|
const head = new Uint8Array(12);
|
|
6582
|
-
const { bytesRead } = await
|
|
6610
|
+
const { bytesRead } = await file2.read(head, 0, head.length, 0);
|
|
6583
6611
|
return head.subarray(0, bytesRead);
|
|
6584
6612
|
} finally {
|
|
6585
|
-
await
|
|
6613
|
+
await file2.close();
|
|
6586
6614
|
}
|
|
6587
6615
|
}, "fileHead");
|
|
6588
6616
|
var typesText = /* @__PURE__ */ __name((types2) => types2.length < 2 ? types2[0] ?? "" : `${types2.slice(0, -1).join(", ")} or ${types2.at(-1)}`, "typesText");
|
|
@@ -6676,7 +6704,7 @@ var refusedPlace = /* @__PURE__ */ __name((path, app, env, platform = process.pl
|
|
|
6676
6704
|
return names2.some((name, index) => parts.has(name) || /^\.env\./.test(name) || runs.some((run) => run.every((part, offset) => names2[index + offset] === part)));
|
|
6677
6705
|
}, "named");
|
|
6678
6706
|
const same2 = /* @__PURE__ */ __name((a, b) => fold2(a) === fold2(b), "same");
|
|
6679
|
-
return [resolve5(path), real].some((candidate) => named2(candidate) || own.some((dir) => inside(fold2(candidate), fold2(dir))) || [store, `${store}-wal`, `${store}-shm`].some((
|
|
6707
|
+
return [resolve5(path), real].some((candidate) => named2(candidate) || own.some((dir) => inside(fold2(candidate), fold2(dir))) || [store, `${store}-wal`, `${store}-shm`].some((file2) => same2(candidate, file2)));
|
|
6680
6708
|
}, "refusedPlace");
|
|
6681
6709
|
var inside = /* @__PURE__ */ __name((path, dir) => {
|
|
6682
6710
|
const way = relative(resolve5(dir), path);
|
|
@@ -6724,9 +6752,9 @@ var checkFilename = /* @__PURE__ */ __name((filename, files) => {
|
|
|
6724
6752
|
throw new CliError("validation_error", "--filename is a name, not a path: no / or \\, at most 255 characters");
|
|
6725
6753
|
}, "checkFilename");
|
|
6726
6754
|
var listOf = /* @__PURE__ */ __name((value) => value === void 0 ? [] : typeof value === "string" ? [value] : value, "listOf");
|
|
6727
|
-
var readAttachments = /* @__PURE__ */ __name(async ({ photo, file, voice, asFile, filename, text: text2 }, read) => {
|
|
6755
|
+
var readAttachments = /* @__PURE__ */ __name(async ({ photo, file: file2, voice, asFile, filename, text: text2 }, read) => {
|
|
6728
6756
|
const photos = listOf(photo);
|
|
6729
|
-
const files = listOf(
|
|
6757
|
+
const files = listOf(file2);
|
|
6730
6758
|
if (voice !== void 0 && (photos.length > 0 || files.length > 0 || (text2 ?? "").trim() !== "")) {
|
|
6731
6759
|
throw new CliError("validation_error", "a voice message goes alone \u2014 no text, no file, no photo beside it");
|
|
6732
6760
|
}
|
|
@@ -6793,30 +6821,30 @@ var directoryPaths = /* @__PURE__ */ __name(async (store, chat, directory, app,
|
|
|
6793
6821
|
throw new CliError("validation_error", "this chat holds too many attachments for directory matching; use recorded download paths");
|
|
6794
6822
|
const groups = /* @__PURE__ */ new Map();
|
|
6795
6823
|
const counts = /* @__PURE__ */ new Map();
|
|
6796
|
-
for (const
|
|
6797
|
-
const group = groups.get(
|
|
6798
|
-
group.push(
|
|
6799
|
-
groups.set(
|
|
6800
|
-
if (
|
|
6801
|
-
counts.set(basename4(
|
|
6824
|
+
for (const file2 of held.filter(({ kind }) => !NOT_FILES.has(kind))) {
|
|
6825
|
+
const group = groups.get(file2.messageId) ?? [];
|
|
6826
|
+
group.push(file2);
|
|
6827
|
+
groups.set(file2.messageId, group);
|
|
6828
|
+
if (file2.name)
|
|
6829
|
+
counts.set(basename4(file2.name), (counts.get(basename4(file2.name)) ?? 0) + 1);
|
|
6802
6830
|
}
|
|
6803
6831
|
const choices = /* @__PURE__ */ new Map();
|
|
6804
6832
|
for (const group of groups.values()) {
|
|
6805
6833
|
group.sort((a, b) => a.position - b.position);
|
|
6806
|
-
const candidates = group.map((
|
|
6807
|
-
const prefix = `${
|
|
6808
|
-
return [...files].filter(([name]) => name === prefix || name.startsWith(`${prefix}.`) ||
|
|
6834
|
+
const candidates = group.map((file2, index) => {
|
|
6835
|
+
const prefix = `${file2.messageId}-${index + 1}`;
|
|
6836
|
+
return [...files].filter(([name]) => name === prefix || name.startsWith(`${prefix}.`) || file2.name !== null && name === `${prefix}-${basename4(file2.name)}`).map(([, path]) => path);
|
|
6809
6837
|
});
|
|
6810
6838
|
if (candidates.some((paths) => paths.length > 1))
|
|
6811
6839
|
throw new CliError("validation_error", "more than one directory file matches a download ordinal");
|
|
6812
6840
|
const complete = candidates.every((paths) => paths.length === 1);
|
|
6813
|
-
group.forEach((
|
|
6814
|
-
const own =
|
|
6841
|
+
group.forEach((file2, index) => {
|
|
6842
|
+
const own = file2.name === null ? void 0 : basename4(file2.name);
|
|
6815
6843
|
const named2 = own && counts.get(own) === 1 ? files.get(own) : void 0;
|
|
6816
6844
|
const canonical2 = complete ? candidates[index]?.[0] : void 0;
|
|
6817
6845
|
if (named2 && canonical2 && named2 !== canonical2 || !complete && own && files.has(own) && (counts.get(own) ?? 0) > 1)
|
|
6818
6846
|
throw new CliError("validation_error", "directory file names are ambiguous; use complete message-prefixed downloads");
|
|
6819
|
-
choices.set(
|
|
6847
|
+
choices.set(file2.pk, canonical2 ?? named2 ?? null);
|
|
6820
6848
|
});
|
|
6821
6849
|
}
|
|
6822
6850
|
const uses = /* @__PURE__ */ new Map();
|
|
@@ -8224,7 +8252,7 @@ var ATTACHMENT_QUERY = {
|
|
|
8224
8252
|
})
|
|
8225
8253
|
};
|
|
8226
8254
|
var PAGE3 = 200;
|
|
8227
|
-
var outcome = /* @__PURE__ */ __name(async (
|
|
8255
|
+
var outcome = /* @__PURE__ */ __name(async (file2, path, load, signal, noFollow = false, ocr, env = process.env) => {
|
|
8228
8256
|
const maxBytes = attachmentMaxBytes(env);
|
|
8229
8257
|
const tooLarge2 = /* @__PURE__ */ __name(() => ({
|
|
8230
8258
|
status: "too-large",
|
|
@@ -8237,7 +8265,7 @@ var outcome = /* @__PURE__ */ __name(async (file, path, load, signal, noFollow =
|
|
|
8237
8265
|
const size4 = await stat2(path).then((found) => found.isFile() ? found.size : void 0, () => void 0);
|
|
8238
8266
|
if (size4 === void 0)
|
|
8239
8267
|
return { status: "missing" };
|
|
8240
|
-
const hint = { kind:
|
|
8268
|
+
const hint = { kind: file2.kind, name: file2.name, mime: file2.mime, path };
|
|
8241
8269
|
const known2 = classify(hint);
|
|
8242
8270
|
if (known2 === "unsupported")
|
|
8243
8271
|
return { status: "unsupported" };
|
|
@@ -8259,7 +8287,7 @@ var outcome = /* @__PURE__ */ __name(async (file, path, load, signal, noFollow =
|
|
|
8259
8287
|
const isPdf = Buffer.from(bytes2.subarray(0, 5)).toString() === "%PDF-";
|
|
8260
8288
|
const ocrCandidate = ocr !== void 0 && (known2 === "image" || isPdf);
|
|
8261
8289
|
const localKind = documentKind(hint);
|
|
8262
|
-
if (
|
|
8290
|
+
if (file2.read?.origin === "extracted" && file2.read.contentSha256 === sha && (!localKind || file2.read.extractor === documentExtractor(localKind)) && (file2.read.error === null || !ocrCandidate && file2.read.error === "no_text") && (!ocrCandidate || file2.read.extractor === ocr?.extractor && file2.read.error === null))
|
|
8263
8291
|
return { status: "unchanged" };
|
|
8264
8292
|
if (ocr && ocrCandidate) {
|
|
8265
8293
|
const extraction2 = known2 === "image" ? await ocrImage(bytes2, ocr, signal) : await ocrPdf(bytes2, ocr, load, signal);
|
|
@@ -8270,23 +8298,23 @@ var outcome = /* @__PURE__ */ __name(async (file, path, load, signal, noFollow =
|
|
|
8270
8298
|
const extraction = await extractText(bytes2, hint, load, signal, env);
|
|
8271
8299
|
return { status: extraction.status, extraction, bytes: size4, sha };
|
|
8272
8300
|
}, "outcome");
|
|
8273
|
-
var keep = /* @__PURE__ */ __name(async (store,
|
|
8301
|
+
var keep = /* @__PURE__ */ __name(async (store, file2, extraction, bytes2, sha) => {
|
|
8274
8302
|
const base = { origin: "extracted", contentSha256: sha, bytes: bytes2 };
|
|
8275
8303
|
if (extraction.status === "extracted") {
|
|
8276
|
-
return store.attachments.keepAttachmentText(
|
|
8304
|
+
return store.attachments.keepAttachmentText(file2.pk, {
|
|
8277
8305
|
...base,
|
|
8278
8306
|
text: extraction.text,
|
|
8279
8307
|
extractor: extraction.extractor
|
|
8280
8308
|
});
|
|
8281
8309
|
} else if (extraction.status === "unreadable") {
|
|
8282
|
-
return store.attachments.keepAttachmentText(
|
|
8310
|
+
return store.attachments.keepAttachmentText(file2.pk, {
|
|
8283
8311
|
...base,
|
|
8284
8312
|
text: "",
|
|
8285
8313
|
extractor: extraction.extractor,
|
|
8286
8314
|
error: extraction.error
|
|
8287
8315
|
});
|
|
8288
8316
|
} else if (extraction.status === "needs-agent" && extraction.extractor) {
|
|
8289
|
-
return store.attachments.keepAttachmentText(
|
|
8317
|
+
return store.attachments.keepAttachmentText(file2.pk, {
|
|
8290
8318
|
...base,
|
|
8291
8319
|
text: "",
|
|
8292
8320
|
extractor: extraction.extractor,
|
|
@@ -8364,9 +8392,9 @@ var attachmentsService = /* @__PURE__ */ __name((deps) => ({
|
|
|
8364
8392
|
let scanned = 0;
|
|
8365
8393
|
const pending = [];
|
|
8366
8394
|
const finished = /* @__PURE__ */ new Map();
|
|
8367
|
-
const processFile = /* @__PURE__ */ __name(async (
|
|
8368
|
-
deps.guard.check({ chatId:
|
|
8369
|
-
const { status, extraction, bytes: bytes2, sha, issue: limitIssue } = await outcome(
|
|
8395
|
+
const processFile = /* @__PURE__ */ __name(async (file2, path) => {
|
|
8396
|
+
deps.guard.check({ chatId: file2.chatId, key: "attachments.extract" }, { reserve: false });
|
|
8397
|
+
const { status, extraction, bytes: bytes2, sha, issue: limitIssue } = await outcome(file2, path, load, signal, fromDir !== void 0, ocr, deps.env);
|
|
8370
8398
|
if (status === "unchanged") {
|
|
8371
8399
|
run.unchanged += 1;
|
|
8372
8400
|
return;
|
|
@@ -8379,8 +8407,8 @@ var attachmentsService = /* @__PURE__ */ __name((deps) => ({
|
|
|
8379
8407
|
run.complete = false;
|
|
8380
8408
|
return;
|
|
8381
8409
|
}
|
|
8382
|
-
if (extraction && bytes2 !== void 0 && (!ocr || status === "extracted") && (status === "extracted" ||
|
|
8383
|
-
if (await keep(store,
|
|
8410
|
+
if (extraction && bytes2 !== void 0 && (!ocr || status === "extracted") && (status === "extracted" || file2.read?.error !== null)) {
|
|
8411
|
+
if (await keep(store, file2, extraction, bytes2, sha) === false) {
|
|
8384
8412
|
run.unchanged += 1;
|
|
8385
8413
|
read += 1;
|
|
8386
8414
|
return;
|
|
@@ -8398,14 +8426,14 @@ var attachmentsService = /* @__PURE__ */ __name((deps) => ({
|
|
|
8398
8426
|
run.failed += 1;
|
|
8399
8427
|
let issue;
|
|
8400
8428
|
if (["missing", "too-large", "engine-missing", "unreadable"].includes(status)) {
|
|
8401
|
-
issue = batch.fail(formatLocator({ ...account2, chat:
|
|
8429
|
+
issue = batch.fail(formatLocator({ ...account2, chat: file2.chatId, message: file2.messageId }), "extract", limitIssue ?? (extraction?.status === "unreadable" && extraction.issue ? extraction.issue : new CliError(status === "missing" ? "not_found" : "validation_error", status === "too-large" ? "attachment exceeds an extraction, decompression or OCR size limit" : extraction?.status === "engine-missing" ? `attachment engine-missing; ${engineMissing(extraction.engine)}; \`doctor\` lists the readers` : `attachment ${status}; retry or skip this item`, { limit_source: ocr ? "provider" : "local" })), file2.position + 1);
|
|
8402
8430
|
} else
|
|
8403
8431
|
batch.ok();
|
|
8404
8432
|
const item = {
|
|
8405
|
-
ref: formatLocator({ ...account2, chat:
|
|
8406
|
-
attachment:
|
|
8407
|
-
kind:
|
|
8408
|
-
name:
|
|
8433
|
+
ref: formatLocator({ ...account2, chat: file2.chatId, message: file2.messageId }),
|
|
8434
|
+
attachment: file2.position + 1,
|
|
8435
|
+
kind: file2.kind,
|
|
8436
|
+
name: file2.name,
|
|
8409
8437
|
status,
|
|
8410
8438
|
...issue ? { issue } : {},
|
|
8411
8439
|
...status === "needs-agent" ? { localPath: path } : {},
|
|
@@ -8416,22 +8444,22 @@ var attachmentsService = /* @__PURE__ */ __name((deps) => ({
|
|
|
8416
8444
|
...extraction.pages === void 0 ? {} : { pages: extraction.pages, ocrPages: extraction.ocrPages }
|
|
8417
8445
|
} : {}
|
|
8418
8446
|
};
|
|
8419
|
-
finished.set(
|
|
8447
|
+
finished.set(file2.pk, item);
|
|
8420
8448
|
onItem?.(item);
|
|
8421
8449
|
}, "processFile");
|
|
8422
|
-
const failedItem = /* @__PURE__ */ __name((
|
|
8423
|
-
const issue = batch.fail(formatLocator({ ...account2, chat:
|
|
8450
|
+
const failedItem = /* @__PURE__ */ __name((file2, stage, error) => {
|
|
8451
|
+
const issue = batch.fail(formatLocator({ ...account2, chat: file2.chatId, message: file2.messageId }), stage, error, file2.position + 1);
|
|
8424
8452
|
run.failed += 1;
|
|
8425
8453
|
const item = {
|
|
8426
|
-
ref: formatLocator({ ...account2, chat:
|
|
8427
|
-
attachment:
|
|
8428
|
-
kind:
|
|
8429
|
-
name:
|
|
8454
|
+
ref: formatLocator({ ...account2, chat: file2.chatId, message: file2.messageId }),
|
|
8455
|
+
attachment: file2.position + 1,
|
|
8456
|
+
kind: file2.kind,
|
|
8457
|
+
name: file2.name,
|
|
8430
8458
|
status: "unreadable",
|
|
8431
8459
|
error: issue.code,
|
|
8432
8460
|
issue
|
|
8433
8461
|
};
|
|
8434
|
-
finished.set(
|
|
8462
|
+
finished.set(file2.pk, item);
|
|
8435
8463
|
onItem?.(item);
|
|
8436
8464
|
}, "failedItem");
|
|
8437
8465
|
try {
|
|
@@ -8442,7 +8470,7 @@ var attachmentsService = /* @__PURE__ */ __name((deps) => ({
|
|
|
8442
8470
|
...beforePk === void 0 ? {} : { beforePk },
|
|
8443
8471
|
limit: PAGE3
|
|
8444
8472
|
});
|
|
8445
|
-
for (const
|
|
8473
|
+
for (const file2 of page) {
|
|
8446
8474
|
while (pending.length && (pending.length >= concurrency || limit !== void 0 && read + pending.length >= limit))
|
|
8447
8475
|
await pending.shift();
|
|
8448
8476
|
if (batch.stopped || signal?.aborted || limit !== void 0 && read >= limit || scanLimit !== void 0 && scanned >= scanLimit) {
|
|
@@ -8451,31 +8479,31 @@ var attachmentsService = /* @__PURE__ */ __name((deps) => ({
|
|
|
8451
8479
|
run.cursor = String(beforePk);
|
|
8452
8480
|
break walk;
|
|
8453
8481
|
}
|
|
8454
|
-
beforePk =
|
|
8482
|
+
beforePk = file2.pk;
|
|
8455
8483
|
scanned += 1;
|
|
8456
|
-
let path = directory === void 0 ?
|
|
8484
|
+
let path = directory === void 0 ? file2.localPath : directory.get(file2.pk) ?? null;
|
|
8457
8485
|
if (directory && path)
|
|
8458
|
-
await store.attachments.keepDownloads(
|
|
8459
|
-
{ kind:
|
|
8486
|
+
await store.attachments.keepDownloads(file2.chatId, file2.messageId, [
|
|
8487
|
+
{ kind: file2.kind, position: file2.position, path }
|
|
8460
8488
|
]);
|
|
8461
8489
|
if (selected && (path === null || !selected.has(path)))
|
|
8462
8490
|
continue;
|
|
8463
|
-
const message = `${
|
|
8491
|
+
const message = `${file2.chatId}/${file2.messageId}`;
|
|
8464
8492
|
if (path === null && download && !fetched.has(message)) {
|
|
8465
8493
|
fetched.add(message);
|
|
8466
8494
|
try {
|
|
8467
|
-
await download(
|
|
8495
|
+
await download(file2.chatId, file2.messageId);
|
|
8468
8496
|
} catch (error) {
|
|
8469
|
-
failedItem(
|
|
8497
|
+
failedItem(file2, "download", error);
|
|
8470
8498
|
}
|
|
8471
|
-
path = await store.attachments.localPathOf(
|
|
8499
|
+
path = await store.attachments.localPathOf(file2.pk);
|
|
8472
8500
|
}
|
|
8473
8501
|
if (path === null) {
|
|
8474
8502
|
run.notDownloaded += 1;
|
|
8475
8503
|
continue;
|
|
8476
8504
|
}
|
|
8477
|
-
const task2 = processFile(
|
|
8478
|
-
failedItem(
|
|
8505
|
+
const task2 = processFile(file2, path).catch((error) => {
|
|
8506
|
+
failedItem(file2, "extract", error);
|
|
8479
8507
|
});
|
|
8480
8508
|
void task2.catch(() => {
|
|
8481
8509
|
});
|
|
@@ -9456,9 +9484,9 @@ var foldersService = /* @__PURE__ */ __name((deps) => {
|
|
|
9456
9484
|
if (link4.trim() === "")
|
|
9457
9485
|
throw new CliError("validation_error", "give the folder's link");
|
|
9458
9486
|
const connection = await online("chats folders join");
|
|
9459
|
-
const
|
|
9487
|
+
const join11 = capability(connection, "joinFolder", "join a shared folder");
|
|
9460
9488
|
const operationId = newOperationId();
|
|
9461
|
-
const folder = await guardedWrite(deps.guard, { operationId, chatId: null, kind: "account", action: "folder-join" }, () =>
|
|
9489
|
+
const folder = await guardedWrite(deps.guard, { operationId, chatId: null, kind: "account", action: "folder-join" }, () => join11(link4.trim()));
|
|
9462
9490
|
return { operationId, folder };
|
|
9463
9491
|
}, "join")
|
|
9464
9492
|
};
|
|
@@ -9751,6 +9779,66 @@ var mentionsService = /* @__PURE__ */ __name((deps) => {
|
|
|
9751
9779
|
};
|
|
9752
9780
|
}, "mentionsService");
|
|
9753
9781
|
|
|
9782
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/domain/formatting.js
|
|
9783
|
+
var invalid3 = /* @__PURE__ */ __name(() => new CliError("validation_error", "the messenger formatter returned invalid text spans"), "invalid");
|
|
9784
|
+
var validateFormattedText = /* @__PURE__ */ __name((formatted2) => {
|
|
9785
|
+
const { text: text2, spans } = formatted2;
|
|
9786
|
+
if (typeof text2 !== "string" || !Array.isArray(spans) || spans.length > 100)
|
|
9787
|
+
throw invalid3();
|
|
9788
|
+
const boundary = /* @__PURE__ */ __name((at) => !(at > 0 && at < text2.length && /[\uD800-\uDBFF]/u.test(text2[at - 1] ?? "") && /[\uDC00-\uDFFF]/u.test(text2[at] ?? "")), "boundary");
|
|
9789
|
+
for (const span of spans) {
|
|
9790
|
+
if (![
|
|
9791
|
+
"bold",
|
|
9792
|
+
"italic",
|
|
9793
|
+
"strike",
|
|
9794
|
+
"underline",
|
|
9795
|
+
"code",
|
|
9796
|
+
"pre",
|
|
9797
|
+
"link",
|
|
9798
|
+
"blockquote",
|
|
9799
|
+
"spoiler",
|
|
9800
|
+
"highlight",
|
|
9801
|
+
"heading"
|
|
9802
|
+
].includes(span.type) || !Number.isInteger(span.from) || !Number.isInteger(span.length) || span.from < 0 || span.length <= 0 || span.from + span.length > text2.length || !boundary(span.from) || !boundary(span.from + span.length))
|
|
9803
|
+
throw invalid3();
|
|
9804
|
+
if (span.type === "link") {
|
|
9805
|
+
if (!span.url || Array.from(span.url).some((char) => char.charCodeAt(0) <= 32 || char.charCodeAt(0) === 127))
|
|
9806
|
+
throw new CliError("validation_error", "a Markdown link needs an absolute http, https or mailto URL");
|
|
9807
|
+
let url;
|
|
9808
|
+
try {
|
|
9809
|
+
url = new URL(span.url);
|
|
9810
|
+
} catch {
|
|
9811
|
+
throw new CliError("validation_error", "a Markdown link needs an absolute http, https or mailto URL");
|
|
9812
|
+
}
|
|
9813
|
+
if (!["http:", "https:", "mailto:"].includes(url.protocol))
|
|
9814
|
+
throw new CliError("validation_error", "Markdown links support http, https and mailto URLs");
|
|
9815
|
+
}
|
|
9816
|
+
}
|
|
9817
|
+
return formatted2;
|
|
9818
|
+
}, "validateFormattedText");
|
|
9819
|
+
var visibleFormattedText = /* @__PURE__ */ __name((formatted2) => {
|
|
9820
|
+
validateFormattedText(formatted2);
|
|
9821
|
+
const text2 = visibleControls(formatted2.text);
|
|
9822
|
+
const positions = /* @__PURE__ */ new Map([[0, 0]]);
|
|
9823
|
+
let original = 0;
|
|
9824
|
+
let visible2 = 0;
|
|
9825
|
+
for (const character of formatted2.text) {
|
|
9826
|
+
const rendered = text2.startsWith(character, visible2) ? character : visibleControls(character);
|
|
9827
|
+
original += character.length;
|
|
9828
|
+
visible2 += rendered.length;
|
|
9829
|
+
positions.set(original, visible2);
|
|
9830
|
+
}
|
|
9831
|
+
return {
|
|
9832
|
+
text: text2,
|
|
9833
|
+
spans: formatted2.spans.map((span) => ({
|
|
9834
|
+
...span,
|
|
9835
|
+
from: positions.get(span.from),
|
|
9836
|
+
length: positions.get(span.from + span.length) - positions.get(span.from),
|
|
9837
|
+
...span.url === void 0 ? {} : { url: visibleControls(span.url) }
|
|
9838
|
+
}))
|
|
9839
|
+
};
|
|
9840
|
+
}, "visibleFormattedText");
|
|
9841
|
+
|
|
9754
9842
|
// node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/domain/message-link.js
|
|
9755
9843
|
var messageLinkTarget = /* @__PURE__ */ __name((reference, message, provider) => {
|
|
9756
9844
|
if (isLocator(reference)) {
|
|
@@ -10009,11 +10097,11 @@ var searchCombined = /* @__PURE__ */ __name(async (store, account2, request, mes
|
|
|
10009
10097
|
const corrections = expanding ? await correctWords(store.searchIndex, [...new Set(eligible.map((leaf) => normalize(leaf.value)))]) : /* @__PURE__ */ new Map();
|
|
10010
10098
|
check();
|
|
10011
10099
|
const bySpan = new Map(eligible.map((leaf) => [leaf.span.start, leaf]));
|
|
10012
|
-
const
|
|
10100
|
+
const transform2 = /* @__PURE__ */ __name((node, source, exact2 = false) => {
|
|
10013
10101
|
if (node.kind === "boolean")
|
|
10014
10102
|
return {
|
|
10015
10103
|
...node,
|
|
10016
|
-
clauses: node.clauses.map((clause) => ({ ...clause, node:
|
|
10104
|
+
clauses: node.clauses.map((clause) => ({ ...clause, node: transform2(clause.node, source, exact2) }))
|
|
10017
10105
|
};
|
|
10018
10106
|
if (exact2 && node.field === "text" && (node.operator === "term" || node.operator === "phrase"))
|
|
10019
10107
|
return { ...node, field: "exact" };
|
|
@@ -10042,18 +10130,18 @@ var searchCombined = /* @__PURE__ */ __name(async (store, account2, request, mes
|
|
|
10042
10130
|
const found = await read(execution.root, request.limit);
|
|
10043
10131
|
return finish(found.items, found.hasMore, [], false, false);
|
|
10044
10132
|
}
|
|
10045
|
-
const exact = await read(
|
|
10133
|
+
const exact = await read(transform2(execution.root, "words", true), depth);
|
|
10046
10134
|
const stemmed = await read(execution.root, depth);
|
|
10047
|
-
const prefix = await read(
|
|
10048
|
-
const fixed = corrections.size ? await read(
|
|
10049
|
-
const fixedPrefixRoot =
|
|
10135
|
+
const prefix = await read(transform2(execution.root, "beginnings"), depth);
|
|
10136
|
+
const fixed = corrections.size ? await read(transform2(execution.root, "corrected"), depth) : { items: [], hasMore: false };
|
|
10137
|
+
const fixedPrefixRoot = transform2(execution.root, "corrected");
|
|
10050
10138
|
const correctedBeginnings = /* @__PURE__ */ __name((node) => node.kind === "boolean" ? { ...node, clauses: node.clauses.map((clause) => ({ ...clause, node: correctedBeginnings(clause.node) })) } : bySpan.has(node.span.start) && [...normalize(node.value)].length >= 3 ? { ...node, field: "exact", operator: "wildcard", value: `${normalize(node.value)}*` } : node, "correctedBeginnings");
|
|
10051
10139
|
const fixedPrefix = corrections.size ? await read(correctedBeginnings(fixedPrefixRoot), depth) : { items: [], hasMore: false };
|
|
10052
10140
|
const ranked = /* @__PURE__ */ new Map();
|
|
10053
10141
|
const add = /* @__PURE__ */ __name((lists, source) => {
|
|
10054
10142
|
const shares = /* @__PURE__ */ new Map();
|
|
10055
|
-
for (const
|
|
10056
|
-
|
|
10143
|
+
for (const list3 of lists)
|
|
10144
|
+
list3.items.forEach((hit, rank) => {
|
|
10057
10145
|
const share = 1 / (options.rrfK + rank + 1);
|
|
10058
10146
|
const old = shares.get(hit.locator);
|
|
10059
10147
|
if (!old || share > old.share)
|
|
@@ -10812,18 +10900,18 @@ var downloadMessage = /* @__PURE__ */ __name(async (messages, chat, message, out
|
|
|
10812
10900
|
var saveFiles = /* @__PURE__ */ __name(async (messages, chat, message, files, output, { unique = false, warn, onSaved, batch = batchProgress() }) => {
|
|
10813
10901
|
const saved = [];
|
|
10814
10902
|
const successful = [];
|
|
10815
|
-
for (const [index,
|
|
10903
|
+
for (const [index, file2] of files.entries()) {
|
|
10816
10904
|
if (batch.stopped)
|
|
10817
10905
|
break;
|
|
10818
10906
|
try {
|
|
10819
|
-
const one = await save(
|
|
10907
|
+
const one = await save(file2, output, `${message}-${index + 1}`, { unique });
|
|
10820
10908
|
saved.push(one);
|
|
10821
|
-
successful.push(
|
|
10909
|
+
successful.push(file2);
|
|
10822
10910
|
batch.ok();
|
|
10823
10911
|
onSaved?.(one);
|
|
10824
10912
|
} catch (error) {
|
|
10825
|
-
const issue = batch.fail(message, "download", error, (
|
|
10826
|
-
warn(`message ${message}, attachment ${(
|
|
10913
|
+
const issue = batch.fail(message, "download", error, (file2.position ?? index) + 1);
|
|
10914
|
+
warn(`message ${message}, attachment ${(file2.position ?? index) + 1}: ${issue.code} \u2014 ${issue.message}`);
|
|
10827
10915
|
}
|
|
10828
10916
|
}
|
|
10829
10917
|
await recordPaths(messages, chat, message, successful, saved, warn, (error) => batch.fail(message, "record_downloads", error));
|
|
@@ -10851,10 +10939,10 @@ var safeName = /* @__PURE__ */ __name((name, platform = process.platform) => {
|
|
|
10851
10939
|
}
|
|
10852
10940
|
return plain === "" ? void 0 : plain;
|
|
10853
10941
|
}, "safeName");
|
|
10854
|
-
var save = /* @__PURE__ */ __name(async (
|
|
10855
|
-
const own = safeName(
|
|
10942
|
+
var save = /* @__PURE__ */ __name(async (file2, directory, fallbackName, { unique = false } = {}) => {
|
|
10943
|
+
const own = safeName(file2.name);
|
|
10856
10944
|
const fileName = /* @__PURE__ */ __name(() => {
|
|
10857
|
-
const extension = EXTENSIONS[
|
|
10945
|
+
const extension = EXTENSIONS[file2.mime ?? ""] ?? BY_KIND[file2.kind];
|
|
10858
10946
|
return own ?? (extension ? `${fallbackName}.${extension}` : fallbackName);
|
|
10859
10947
|
}, "fileName");
|
|
10860
10948
|
const partial = join9(directory, `.${fileName()}.${process.pid}.part`);
|
|
@@ -10866,7 +10954,7 @@ var save = /* @__PURE__ */ __name(async (file, directory, fallbackName, { unique
|
|
|
10866
10954
|
}
|
|
10867
10955
|
});
|
|
10868
10956
|
try {
|
|
10869
|
-
await pipeline(Readable.from(
|
|
10957
|
+
await pipeline(Readable.from(file2.bytes()), counting, createWriteStream(partial, { flags: "wx", mode: 384 }));
|
|
10870
10958
|
const name = fileName();
|
|
10871
10959
|
const names2 = unique && own ? [name, `${fallbackName}-${own}`] : [name];
|
|
10872
10960
|
for (const candidate of names2) {
|
|
@@ -10877,11 +10965,11 @@ var save = /* @__PURE__ */ __name(async (file, directory, fallbackName, { unique
|
|
|
10877
10965
|
throw error;
|
|
10878
10966
|
});
|
|
10879
10967
|
if (!taken)
|
|
10880
|
-
return { kind:
|
|
10968
|
+
return { kind: file2.kind, path: path2, bytes: bytes2 };
|
|
10881
10969
|
}
|
|
10882
10970
|
const path = resolve6(join9(directory, names2.at(-1) ?? name));
|
|
10883
10971
|
if (unique)
|
|
10884
|
-
return { kind:
|
|
10972
|
+
return { kind: file2.kind, path, bytes: bytes2, existing: true };
|
|
10885
10973
|
throw new CliError("validation_error", `${path} already exists \u2014 nothing was overwritten; choose --output-dir`);
|
|
10886
10974
|
} finally {
|
|
10887
10975
|
await rm(partial, { force: true });
|
|
@@ -10905,7 +10993,7 @@ var picturesService = /* @__PURE__ */ __name((deps) => {
|
|
|
10905
10993
|
const directory = imageModelsDirectory(deps.env);
|
|
10906
10994
|
if (!isImageModelInstalled(model2, directory))
|
|
10907
10995
|
throw new CliError("not_found", missingModel(model2.id), { reason: "model.not-downloaded", model: model2.id });
|
|
10908
|
-
const { openPictureEmbedder } = await import("./embedder-
|
|
10996
|
+
const { openPictureEmbedder } = await import("./embedder-7WNFXYYP.js");
|
|
10909
10997
|
return openPictureEmbedder(model2, directory);
|
|
10910
10998
|
}, "open");
|
|
10911
10999
|
const embedder = /* @__PURE__ */ __name(() => {
|
|
@@ -10925,18 +11013,18 @@ var picturesService = /* @__PURE__ */ __name((deps) => {
|
|
|
10925
11013
|
}
|
|
10926
11014
|
}
|
|
10927
11015
|
const images = (await files()).filter(({ kind, mime }) => kind === "photo" || mime?.startsWith("image/"));
|
|
10928
|
-
const
|
|
10929
|
-
if (!
|
|
11016
|
+
const file2 = images.find(({ position }) => position === picture.position) ?? (images.every(({ position }) => position === void 0) ? images[0] : void 0);
|
|
11017
|
+
if (!file2 || file2.size !== void 0 && file2.size > PICTURE_MAX_BYTES)
|
|
10930
11018
|
return void 0;
|
|
10931
11019
|
const parts = [];
|
|
10932
11020
|
let total = 0;
|
|
10933
|
-
for await (const part of
|
|
11021
|
+
for await (const part of file2.bytes()) {
|
|
10934
11022
|
total += part.length;
|
|
10935
11023
|
if (total > PICTURE_MAX_BYTES)
|
|
10936
11024
|
return void 0;
|
|
10937
11025
|
parts.push(part);
|
|
10938
11026
|
}
|
|
10939
|
-
await read(
|
|
11027
|
+
await read(file2);
|
|
10940
11028
|
return Buffer.concat(parts);
|
|
10941
11029
|
}, "bytesOf");
|
|
10942
11030
|
return {
|
|
@@ -10989,8 +11077,8 @@ var picturesService = /* @__PURE__ */ __name((deps) => {
|
|
|
10989
11077
|
return downloaded.files;
|
|
10990
11078
|
}, "files");
|
|
10991
11079
|
try {
|
|
10992
|
-
const bytes2 = await bytesOf2(picture, files, async (
|
|
10993
|
-
const refreshed = refreshedFiles([
|
|
11080
|
+
const bytes2 = await bytesOf2(picture, files, async (file2) => {
|
|
11081
|
+
const refreshed = refreshedFiles([file2]);
|
|
10994
11082
|
if (refreshed.length === 0)
|
|
10995
11083
|
return;
|
|
10996
11084
|
await store.attachments.keepProviderRefs(account2, picture.chatId, picture.messageId, refreshed).catch(() => void 0);
|
|
@@ -11164,7 +11252,7 @@ var rerankLane = /* @__PURE__ */ __name((deps) => {
|
|
|
11164
11252
|
const warm = deps.embedders;
|
|
11165
11253
|
const reranker = warm ? await warm.reranker(`rerank:${model.id}`, async () => (await import("./process-ZXO2MWRJ.js")).openRerankerProcess(model, directory, {
|
|
11166
11254
|
threads: defaultThreads()
|
|
11167
|
-
})) : await (await import("./rerank-
|
|
11255
|
+
})) : await (await import("./rerank-YFUB6J6M.js")).openReranker(model, directory);
|
|
11168
11256
|
return {
|
|
11169
11257
|
model: model.id,
|
|
11170
11258
|
score: /* @__PURE__ */ __name((question, passages) => reranker.score(plainWords(question), passages), "score"),
|
|
@@ -11192,7 +11280,7 @@ var openPictureEmbedderFor = /* @__PURE__ */ __name(async ({ env, command } = {}
|
|
|
11192
11280
|
const directory = imageModelsDirectory(env);
|
|
11193
11281
|
if (!isImageModelInstalled(model, directory))
|
|
11194
11282
|
throw new CliError("not_found", `the picture model is not downloaded \u2014 ${command === void 0 ? "install it with a WireCat CLI that has `images models download` (tg, max or wa); they share the model folder" : `\`${command} images models download ${model.id}\` fetches it`}`, { reason: "model.not-downloaded", model: model.id });
|
|
11195
|
-
const { openPictureEmbedder } = await import("./embedder-
|
|
11283
|
+
const { openPictureEmbedder } = await import("./embedder-7WNFXYYP.js");
|
|
11196
11284
|
return openPictureEmbedder(model, directory);
|
|
11197
11285
|
}, "openPictureEmbedderFor");
|
|
11198
11286
|
var savePicture = /* @__PURE__ */ __name(async (store, target, bytes2, options = {}) => {
|
|
@@ -11214,12 +11302,12 @@ var savePicture = /* @__PURE__ */ __name(async (store, target, bytes2, options =
|
|
|
11214
11302
|
var removePicture = /* @__PURE__ */ __name((store, target) => store.notes.removePicture(refOf(target)), "removePicture");
|
|
11215
11303
|
|
|
11216
11304
|
// node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/document-source.js
|
|
11217
|
-
var documentSource = /* @__PURE__ */ __name((note, accounts, profiles,
|
|
11305
|
+
var documentSource = /* @__PURE__ */ __name((note, accounts, profiles, file2) => {
|
|
11218
11306
|
const metadata = note.frontMatter;
|
|
11219
11307
|
const account2 = accounts.find(({ id: id2 }) => String(id2) === note.folderId);
|
|
11220
11308
|
const remote = note.source === "file" && (account2 !== void 0 && kindIn(account2.provider) === "documents" || metadata?.source === "google-drive");
|
|
11221
11309
|
const profile = remote && account2 ? Object.entries(profiles).flatMap(([command, named2]) => Object.entries(named2).map(([name, key]) => ({ command, name, key }))).find(({ key }) => key.provider === account2.provider && key.account === account2.account || isFolderProvider(key.provider) && key.account === account2.name) : void 0;
|
|
11222
|
-
const url =
|
|
11310
|
+
const url = file2?.url ?? (remote && typeof metadata?.sourceUrl === "string" ? metadata.sourceUrl : void 0);
|
|
11223
11311
|
return {
|
|
11224
11312
|
kind: remote ? "document" : "note",
|
|
11225
11313
|
provider: profile ? profile.command : "notes",
|
|
@@ -11599,7 +11687,7 @@ var searchNotes = /* @__PURE__ */ __name(async (store, query, { limit = 20, offs
|
|
|
11599
11687
|
...scope
|
|
11600
11688
|
});
|
|
11601
11689
|
const ranked = /* @__PURE__ */ new Map();
|
|
11602
|
-
const add = /* @__PURE__ */ __name((
|
|
11690
|
+
const add = /* @__PURE__ */ __name((list3, by) => list3.forEach(({ ref, note, at }, rank) => {
|
|
11603
11691
|
if (tierRefs.has(ref))
|
|
11604
11692
|
return;
|
|
11605
11693
|
const held = ranked.get(ref) ?? { note, at, score: 0, foundBy: [] };
|
|
@@ -11651,13 +11739,13 @@ var searchNotes = /* @__PURE__ */ __name(async (store, query, { limit = 20, offs
|
|
|
11651
11739
|
ref,
|
|
11652
11740
|
name
|
|
11653
11741
|
]));
|
|
11654
|
-
for (const
|
|
11655
|
-
if (
|
|
11656
|
-
|
|
11657
|
-
if (
|
|
11658
|
-
|
|
11659
|
-
if (
|
|
11660
|
-
|
|
11742
|
+
for (const record2 of counts.values()) {
|
|
11743
|
+
if (record2.ref && names2.has(record2.ref))
|
|
11744
|
+
record2.name = names2.get(record2.ref) ?? record2.name;
|
|
11745
|
+
if (record2.ref?.startsWith("person:"))
|
|
11746
|
+
record2.name = (await store.people.personByUid(record2.ref.slice("person:".length)))?.name ?? record2.name;
|
|
11747
|
+
if (record2.ref?.startsWith("note:") || record2.ref?.startsWith("document:"))
|
|
11748
|
+
record2.name = (await store.notes.note(record2.ref).catch(() => void 0))?.title ?? record2.name;
|
|
11661
11749
|
}
|
|
11662
11750
|
const lane = withPictures2 ? await pictureLane(store, words2, {
|
|
11663
11751
|
folderIds,
|
|
@@ -11691,7 +11779,7 @@ var notesScopeOf = /* @__PURE__ */ __name((accounts) => {
|
|
|
11691
11779
|
return { source: "internal" };
|
|
11692
11780
|
return { folderIds, ...accounts.length > folderIds.length ? { withInternal: true } : {} };
|
|
11693
11781
|
}, "notesScopeOf");
|
|
11694
|
-
var searchNotesOf = /* @__PURE__ */ __name(async (store, account2, text2, { accounts:
|
|
11782
|
+
var searchNotesOf = /* @__PURE__ */ __name(async (store, account2, text2, { accounts: list3, app, ...query }) => {
|
|
11695
11783
|
const own = app?.command ?? query.command;
|
|
11696
11784
|
const what = `${own === void 0 ? "" : `${own} `}search notes`;
|
|
11697
11785
|
const held = [
|
|
@@ -11699,12 +11787,12 @@ var searchNotesOf = /* @__PURE__ */ __name(async (store, account2, text2, { acco
|
|
|
11699
11787
|
...(await store.notes.folders()).map(({ id: id2 }) => ({ provider: "notes", account: id2 })),
|
|
11700
11788
|
...(await store.notes.documentsAccounts()).map(({ id: id2 }) => ({ provider: "notes", account: id2 }))
|
|
11701
11789
|
];
|
|
11702
|
-
const named2 =
|
|
11790
|
+
const named2 = list3 === void 0 ? { accounts: held, skipped: [] } : fitting(entriesOfList(list3, await listContextOf(store, account2, app)), ["notes", "documents"], what);
|
|
11703
11791
|
const source = query.source ?? noteSourceOfQuery(text2).source;
|
|
11704
11792
|
const typed = named2.accounts.filter(({ account: account3 }) => source === void 0 || account3 === INTERNAL_NOTES === (source === "internal"));
|
|
11705
|
-
if (!typed.length &&
|
|
11793
|
+
if (!typed.length && list3 !== void 0)
|
|
11706
11794
|
throw new CliError("validation_error", source === "internal" ? "the query's source:internal keeps the notes written in memo, and the --source list names none of them: add notes:internal to --source, or drop source:internal from the query" : "the query's source:file keeps the files from notes folders, and the --source list names none of them: add notes:<folder id> to --source, or drop source:file from the query");
|
|
11707
|
-
const scope =
|
|
11795
|
+
const scope = list3 === void 0 ? {} : notesScopeOf(typed);
|
|
11708
11796
|
const found = await searchNotes(store, text2, {
|
|
11709
11797
|
...query,
|
|
11710
11798
|
...scope,
|
|
@@ -11809,7 +11897,7 @@ var searchEvents = /* @__PURE__ */ __name(async (store, query, { limit = 20, off
|
|
|
11809
11897
|
...truncated
|
|
11810
11898
|
};
|
|
11811
11899
|
const ranked = /* @__PURE__ */ new Map();
|
|
11812
|
-
const add = /* @__PURE__ */ __name((
|
|
11900
|
+
const add = /* @__PURE__ */ __name((list3, half) => list3.forEach((hit, rank) => {
|
|
11813
11901
|
const held = ranked.get(keyOf4(hit)) ?? { hit, score: 0, by: [] };
|
|
11814
11902
|
held.score += 1 / (RRF_K3 + rank + 1);
|
|
11815
11903
|
held.by.push(half);
|
|
@@ -12013,8 +12101,8 @@ var searchAll = /* @__PURE__ */ __name(async (store, account2, request, messenge
|
|
|
12013
12101
|
await embedders.close();
|
|
12014
12102
|
}
|
|
12015
12103
|
const ranked = /* @__PURE__ */ new Map();
|
|
12016
|
-
for (const
|
|
12017
|
-
|
|
12104
|
+
for (const list3 of lists)
|
|
12105
|
+
list3.forEach((item, rank) => {
|
|
12018
12106
|
const held = ranked.get(item.ref) ?? { item, score: 0 };
|
|
12019
12107
|
held.score += 1 / (RRF_K3 + rank + 1);
|
|
12020
12108
|
ranked.set(item.ref, held);
|
|
@@ -12199,8 +12287,8 @@ var searchAllIncludingMeetings = /* @__PURE__ */ __name(async (store, account2,
|
|
|
12199
12287
|
};
|
|
12200
12288
|
}
|
|
12201
12289
|
const ranked = /* @__PURE__ */ new Map();
|
|
12202
|
-
for (const
|
|
12203
|
-
|
|
12290
|
+
for (const list3 of [legacy.items, meetings.items.map(({ item }) => item)])
|
|
12291
|
+
list3.forEach((item, rank) => {
|
|
12204
12292
|
const key = item.kind === "meeting" ? JSON.stringify([item.kind, item.accountId, item.meetingId, item.scope, item.id]) : item.ref;
|
|
12205
12293
|
const held = ranked.get(key) ?? { item, score: 0 };
|
|
12206
12294
|
held.score += 1 / (RRF_K3 + rank + 1);
|
|
@@ -12462,12 +12550,12 @@ var searchServer = /* @__PURE__ */ __name(async (deps, request) => {
|
|
|
12462
12550
|
report.new += 1;
|
|
12463
12551
|
byChat.set(hit.chatId, [...byChat.get(hit.chatId) ?? [], hit]);
|
|
12464
12552
|
}
|
|
12465
|
-
const
|
|
12553
|
+
const unknown2 = [];
|
|
12466
12554
|
for (const [chatId, chat] of chats)
|
|
12467
12555
|
if (!(await store.messages.messages(account2, chatId, { limit: 1 })).items.length)
|
|
12468
|
-
|
|
12469
|
-
if (
|
|
12470
|
-
await store.chats.saveChats(account2,
|
|
12556
|
+
unknown2.push(chat);
|
|
12557
|
+
if (unknown2.length)
|
|
12558
|
+
await store.chats.saveChats(account2, unknown2);
|
|
12471
12559
|
for (const [chatId, hits] of byChat)
|
|
12472
12560
|
await store.messages.saveMessages(account2, chatId, hits.map(({ chatTitle, ...message }) => message), { via: "search" });
|
|
12473
12561
|
return { report, sources };
|
|
@@ -13000,24 +13088,355 @@ var metadataService = /* @__PURE__ */ __name((deps) => {
|
|
|
13000
13088
|
};
|
|
13001
13089
|
}, "metadataService");
|
|
13002
13090
|
|
|
13091
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/moderation/check.js
|
|
13092
|
+
var INVITE = /max\.ru\/join\/|(t|telegram)\.me\/(\+|joinchat\/)|tg:\/\/join/i;
|
|
13093
|
+
var LINK2 = /https?:\/\/\S+/i;
|
|
13094
|
+
var STRENGTH = { report: 0, delete: 1, remove: 2 };
|
|
13095
|
+
var judge = /* @__PURE__ */ __name(({ rules, messages, joined, answerers: answerers2, service, now, invites }) => {
|
|
13096
|
+
const invite = invites ? new RegExp(`${INVITE.source}|${invites.source}`, "i") : INVITE;
|
|
13097
|
+
const trusted = new Set(rules.trusted);
|
|
13098
|
+
const blocked = /* @__PURE__ */ __name((id2, name) => id2 !== null && rules.blocked.includes(id2) || name !== null && rules.blockedNames.some((part) => name.toLocaleLowerCase().includes(part.toLocaleLowerCase())), "blocked");
|
|
13099
|
+
const young = /* @__PURE__ */ __name((member) => rules.newAccount.days > 0 && typeof member.registeredAt === "string" && now - Date.parse(member.registeredAt) < rules.newAccount.days * 864e5, "young");
|
|
13100
|
+
const found = [];
|
|
13101
|
+
const add = /* @__PURE__ */ __name((finding) => {
|
|
13102
|
+
if (finding.action === "remove" && found.some((f) => f.action === "remove" && f.personId === finding.personId)) {
|
|
13103
|
+
return;
|
|
13104
|
+
}
|
|
13105
|
+
found.push(finding);
|
|
13106
|
+
}, "add");
|
|
13107
|
+
for (const member of joined) {
|
|
13108
|
+
if (trusted.has(member.id) || answerers2.has(member.id))
|
|
13109
|
+
continue;
|
|
13110
|
+
const person = { kind: "member", personId: member.id, personName: member.name };
|
|
13111
|
+
if (blocked(member.id, member.name)) {
|
|
13112
|
+
add({ ...person, rule: "blocked", action: rules.blockedPeople === "remove" ? "remove" : "report" });
|
|
13113
|
+
} else if (young(member)) {
|
|
13114
|
+
add({ ...person, rule: "newAccount", action: rules.newAccount.action });
|
|
13115
|
+
}
|
|
13116
|
+
}
|
|
13117
|
+
const flooding = floodOf(messages, rules.flood);
|
|
13118
|
+
for (const message of messages) {
|
|
13119
|
+
const id2 = message.senderId;
|
|
13120
|
+
if (id2 === null || message.outgoing === true || answerers2.has(id2) || trusted.has(id2))
|
|
13121
|
+
continue;
|
|
13122
|
+
if (service.has(message.id) || message.attachments.some((attachment2) => attachment2.kind === "control"))
|
|
13123
|
+
continue;
|
|
13124
|
+
const base = { kind: "message", personId: id2, personName: message.senderName, messageId: message.id };
|
|
13125
|
+
const text2 = message.text;
|
|
13126
|
+
const broken2 = [];
|
|
13127
|
+
if (blocked(id2, message.senderName))
|
|
13128
|
+
broken2.push(["blocked", rules.blockedPeople]);
|
|
13129
|
+
if (invite.test(text2))
|
|
13130
|
+
broken2.push(["invites", rules.invites]);
|
|
13131
|
+
if (LINK2.test(text2) || message.attachments.some((attachment2) => attachment2.kind === "share")) {
|
|
13132
|
+
broken2.push(["links", rules.links]);
|
|
13133
|
+
}
|
|
13134
|
+
if (message.forwardedFrom !== null)
|
|
13135
|
+
broken2.push(["forwards", rules.forwards]);
|
|
13136
|
+
if (flooding.has(message.id))
|
|
13137
|
+
broken2.push(["flood", rules.flood.action]);
|
|
13138
|
+
const strongest = broken2.reduce((best, rule) => best === void 0 || STRENGTH[rule[1]] > STRENGTH[best[1]] ? rule : best, void 0);
|
|
13139
|
+
if (strongest)
|
|
13140
|
+
add({ ...base, rule: strongest[0], action: strongest[1] });
|
|
13141
|
+
}
|
|
13142
|
+
return found;
|
|
13143
|
+
}, "judge");
|
|
13144
|
+
var floodOf = /* @__PURE__ */ __name((messages, flood) => {
|
|
13145
|
+
const window2 = flood.minutes * 6e4;
|
|
13146
|
+
const over = /* @__PURE__ */ new Set();
|
|
13147
|
+
const bySender = /* @__PURE__ */ new Map();
|
|
13148
|
+
for (const message of messages) {
|
|
13149
|
+
if (message.senderId === null)
|
|
13150
|
+
continue;
|
|
13151
|
+
const times = bySender.get(message.senderId) ?? [];
|
|
13152
|
+
const at = Date.parse(message.timestamp);
|
|
13153
|
+
times.push(at);
|
|
13154
|
+
bySender.set(message.senderId, times);
|
|
13155
|
+
if (times.filter((time) => at - time < window2).length > flood.messages)
|
|
13156
|
+
over.add(message.id);
|
|
13157
|
+
}
|
|
13158
|
+
return over;
|
|
13159
|
+
}, "floodOf");
|
|
13160
|
+
var act = /* @__PURE__ */ __name(async (moderator, findings, options) => {
|
|
13161
|
+
const { chatId, rules, allowDangerous, dryRun, maxActions, confirm, command } = options;
|
|
13162
|
+
const typed = options.commandFor ?? ((chat, finding) => commandFor(command, chat, finding));
|
|
13163
|
+
const rows = [];
|
|
13164
|
+
let acted = 0;
|
|
13165
|
+
let stopped;
|
|
13166
|
+
for (const finding of findings) {
|
|
13167
|
+
if (finding.action === "report") {
|
|
13168
|
+
rows.push({ ...finding, outcome: "reported" });
|
|
13169
|
+
continue;
|
|
13170
|
+
}
|
|
13171
|
+
const consent = finding.action;
|
|
13172
|
+
const level2 = rules.consent[consent];
|
|
13173
|
+
const row = /* @__PURE__ */ __name((outcome2, reason) => ({
|
|
13174
|
+
...finding,
|
|
13175
|
+
outcome: outcome2,
|
|
13176
|
+
...reason ? { reason } : {},
|
|
13177
|
+
...outcome2 === "done" || outcome2 === "reported" ? {} : { command: typed(chatId, finding) }
|
|
13178
|
+
}), "row");
|
|
13179
|
+
if (level2 === "deny") {
|
|
13180
|
+
rows.push(row("forbidden", `consent.${consent} is deny`));
|
|
13181
|
+
continue;
|
|
13182
|
+
}
|
|
13183
|
+
if (level2 === "readonly") {
|
|
13184
|
+
rows.push(row("reported", `consent.${consent} is readonly`));
|
|
13185
|
+
continue;
|
|
13186
|
+
}
|
|
13187
|
+
if (dryRun) {
|
|
13188
|
+
rows.push(row("planned", "--dry-run"));
|
|
13189
|
+
continue;
|
|
13190
|
+
}
|
|
13191
|
+
if (stopped || acted >= maxActions) {
|
|
13192
|
+
rows.push(row("skipped", stopped ?? `over the limit of ${maxActions} actions per check`));
|
|
13193
|
+
continue;
|
|
13194
|
+
}
|
|
13195
|
+
if (level2 === "ask" && !allowDangerous) {
|
|
13196
|
+
const yes = confirm ? await confirm(finding) : void 0;
|
|
13197
|
+
if (yes === void 0) {
|
|
13198
|
+
rows.push(row("planned", `consent.${consent} is ask, and nobody is there to answer \u2014 run with --allow-dangerous`));
|
|
13199
|
+
continue;
|
|
13200
|
+
}
|
|
13201
|
+
if (!yes) {
|
|
13202
|
+
rows.push(row("declined", "the answer was no"));
|
|
13203
|
+
continue;
|
|
13204
|
+
}
|
|
13205
|
+
}
|
|
13206
|
+
acted += 1;
|
|
13207
|
+
try {
|
|
13208
|
+
if (finding.action === "delete" && finding.messageId) {
|
|
13209
|
+
await moderator.deleteMessage(chatId, finding.messageId);
|
|
13210
|
+
} else {
|
|
13211
|
+
await moderator.removePerson(chatId, finding.personId);
|
|
13212
|
+
}
|
|
13213
|
+
rows.push(row("done"));
|
|
13214
|
+
} catch (error) {
|
|
13215
|
+
const failure = asCliError(error);
|
|
13216
|
+
if (failure.code === "rate_limited")
|
|
13217
|
+
stopped = failure.message;
|
|
13218
|
+
const refused = ["rate_limited", "permission_error", "confirmation_required"].includes(failure.code);
|
|
13219
|
+
rows.push(row(refused ? "refused" : "failed", failure.message));
|
|
13220
|
+
}
|
|
13221
|
+
}
|
|
13222
|
+
return rows;
|
|
13223
|
+
}, "act");
|
|
13224
|
+
var asCliError = /* @__PURE__ */ __name((error) => error instanceof CliError ? error : new CliError("provider_error", error instanceof Error ? error.message : String(error)), "asCliError");
|
|
13225
|
+
var who = /* @__PURE__ */ __name((finding) => finding.personName ?? finding.personId, "who");
|
|
13226
|
+
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");
|
|
13227
|
+
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");
|
|
13228
|
+
var CHECK_READS = 1e3;
|
|
13229
|
+
var PAGE5 = 100;
|
|
13230
|
+
var gather = /* @__PURE__ */ __name(async (adapter, chatId, since) => {
|
|
13231
|
+
const notes = [];
|
|
13232
|
+
const historyAfter = adapter.historyAfter;
|
|
13233
|
+
if (!historyAfter)
|
|
13234
|
+
throw new CliError("validation_error", "this messenger cannot read a chat forward from a time");
|
|
13235
|
+
const messages = [];
|
|
13236
|
+
let more = true;
|
|
13237
|
+
while (more && messages.length < CHECK_READS) {
|
|
13238
|
+
const last = messages.at(-1);
|
|
13239
|
+
const page = await historyAfter.call(adapter, chatId, {
|
|
13240
|
+
limit: PAGE5,
|
|
13241
|
+
after: last ? { id: last.id } : { time: since }
|
|
13242
|
+
});
|
|
13243
|
+
messages.push(...page.items);
|
|
13244
|
+
more = page.hasMore && page.items.length > 0;
|
|
13245
|
+
}
|
|
13246
|
+
const scanned = adapter.chatEvents ? (await adapter.chatEvents(chatId, { since })).events : [];
|
|
13247
|
+
const until = messages.at(-1)?.timestamp ?? null;
|
|
13248
|
+
const events = more && until !== null ? scanned.filter((event) => Date.parse(event.timestamp) <= Date.parse(until)) : scanned;
|
|
13249
|
+
if (!adapter.chatEvents)
|
|
13250
|
+
notes.push("this messenger does not say who joined, so only messages are judged");
|
|
13251
|
+
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] : []));
|
|
13252
|
+
const joined = joinedIds.size === 0 || !adapter.members ? [] : (await adapter.members(chatId, { offset: 0 })).items.filter((member) => joinedIds.has(member.id));
|
|
13253
|
+
const admins = adapter.admins ? await adapter.admins(chatId) : null;
|
|
13254
|
+
if (admins === null)
|
|
13255
|
+
notes.push("the group's admins are not known, so only your own messages are exempt");
|
|
13256
|
+
return {
|
|
13257
|
+
messages,
|
|
13258
|
+
joined,
|
|
13259
|
+
answerers: new Set(admins ?? []),
|
|
13260
|
+
service: new Set(events.map((one) => one.messageId)),
|
|
13261
|
+
until,
|
|
13262
|
+
more,
|
|
13263
|
+
notes
|
|
13264
|
+
};
|
|
13265
|
+
}, "gather");
|
|
13266
|
+
var MAX_ACTIONS = 10;
|
|
13267
|
+
var undone = /* @__PURE__ */ __name((row) => ["planned", "skipped", "failed"].includes(row.outcome), "undone");
|
|
13268
|
+
var nextPoint = /* @__PURE__ */ __name((rows, found) => {
|
|
13269
|
+
const waiting = rows.filter(undone);
|
|
13270
|
+
if (waiting.some((row) => row.messageId === void 0))
|
|
13271
|
+
return null;
|
|
13272
|
+
const times = waiting.map((row) => found.messages.find((message) => message.id === row.messageId)?.timestamp).filter((time) => time !== void 0).map(Date.parse);
|
|
13273
|
+
if (times.length === 0)
|
|
13274
|
+
return found.until;
|
|
13275
|
+
return new Date(Math.min(...times) - 1).toISOString();
|
|
13276
|
+
}, "nextPoint");
|
|
13277
|
+
var someUndone = /* @__PURE__ */ __name((rows) => rows.some(undone), "someUndone");
|
|
13278
|
+
|
|
13279
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/moderation/rules.js
|
|
13280
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
13281
|
+
import { join as join10 } from "node:path";
|
|
13282
|
+
var RULE_ACTIONS = ["report", "delete", "remove"];
|
|
13283
|
+
var OLD_LEVELS = { forbid: "deny", flag: "ask", confirm: "ask", allow: "allow" };
|
|
13284
|
+
var level = pipe(picklist([...LEVELS, ...Object.keys(OLD_LEVELS)]), transform((typed) => OLD_LEVELS[typed] ?? typed));
|
|
13285
|
+
var action = picklist(RULE_ACTIONS);
|
|
13286
|
+
var personIds = array(pipe(string(), regex(/^-?\d+$/, "a person id is digits")));
|
|
13287
|
+
var atLeast = /* @__PURE__ */ __name((min) => pipe(number(), integer(), minValue(min)), "atLeast");
|
|
13288
|
+
var groupRules = pipe(strictObject({
|
|
13289
|
+
title: nullable(string()),
|
|
13290
|
+
trusted: personIds,
|
|
13291
|
+
blocked: personIds,
|
|
13292
|
+
blockedNames: array(pipe(string(), minLength(1))),
|
|
13293
|
+
links: action,
|
|
13294
|
+
invites: action,
|
|
13295
|
+
forwards: action,
|
|
13296
|
+
blockedPeople: action,
|
|
13297
|
+
flood: strictObject({ messages: atLeast(1), minutes: atLeast(1), action }),
|
|
13298
|
+
/** 0 days turns the rule off. */
|
|
13299
|
+
newAccount: strictObject({ days: atLeast(0), action: picklist(["report", "remove"]) }),
|
|
13300
|
+
requests: optional(unknown()),
|
|
13301
|
+
consent: strictObject({
|
|
13302
|
+
delete: level,
|
|
13303
|
+
remove: level,
|
|
13304
|
+
accept: optional(unknown()),
|
|
13305
|
+
decline: optional(unknown())
|
|
13306
|
+
})
|
|
13307
|
+
}), transform(({ requests: _, consent: { accept: _accept, decline: _decline, ...consent }, ...rules }) => ({
|
|
13308
|
+
...rules,
|
|
13309
|
+
consent
|
|
13310
|
+
})));
|
|
13311
|
+
var file = strictObject({
|
|
13312
|
+
groups: record(string(), groupRules),
|
|
13313
|
+
/** Where each group's next `chats moderate` starts, ISO 8601. */
|
|
13314
|
+
checkedUntil: optional(record(string(), string()))
|
|
13315
|
+
});
|
|
13316
|
+
var defaultRules = /* @__PURE__ */ __name((title) => ({
|
|
13317
|
+
title,
|
|
13318
|
+
trusted: [],
|
|
13319
|
+
blocked: [],
|
|
13320
|
+
blockedNames: [],
|
|
13321
|
+
links: "report",
|
|
13322
|
+
invites: "report",
|
|
13323
|
+
forwards: "report",
|
|
13324
|
+
blockedPeople: "report",
|
|
13325
|
+
flood: { messages: 5, minutes: 1, action: "report" },
|
|
13326
|
+
newAccount: { days: 7, action: "report" },
|
|
13327
|
+
consent: { delete: "ask", remove: "ask" }
|
|
13328
|
+
}), "defaultRules");
|
|
13329
|
+
var list2 = /* @__PURE__ */ __name((value) => value.split(",").map((item) => item.trim()).filter(Boolean), "list");
|
|
13330
|
+
var whole3 = /* @__PURE__ */ __name((value) => /^\d+$/.test(value.trim()) ? Number(value) : Number.NaN, "whole");
|
|
13331
|
+
var KEYS = {
|
|
13332
|
+
trusted: { help: "person ids, comma-separated; never acted on", parse: list2 },
|
|
13333
|
+
blocked: { help: "person ids, comma-separated", parse: list2 },
|
|
13334
|
+
blockedNames: { help: "parts of a name, comma-separated, any case", parse: list2 },
|
|
13335
|
+
links: { help: RULE_ACTIONS.join("|"), parse: String },
|
|
13336
|
+
invites: { help: RULE_ACTIONS.join("|"), parse: String },
|
|
13337
|
+
forwards: { help: RULE_ACTIONS.join("|"), parse: String },
|
|
13338
|
+
blockedPeople: { help: RULE_ACTIONS.join("|"), parse: String },
|
|
13339
|
+
"flood.messages": { help: "a whole number, 1 or more", parse: whole3 },
|
|
13340
|
+
"flood.minutes": { help: "a whole number, 1 or more", parse: whole3 },
|
|
13341
|
+
"flood.action": { help: RULE_ACTIONS.join("|"), parse: String },
|
|
13342
|
+
"newAccount.days": { help: "a whole number; 0 turns it off", parse: whole3 },
|
|
13343
|
+
"newAccount.action": { help: "report|remove", parse: String },
|
|
13344
|
+
"consent.delete": { help: LEVELS.join("|"), parse: String },
|
|
13345
|
+
"consent.remove": { help: LEVELS.join("|"), parse: String }
|
|
13346
|
+
};
|
|
13347
|
+
var RULE_KEYS = Object.keys(KEYS);
|
|
13348
|
+
var moderationPathFor = /* @__PURE__ */ __name((app, profile, env = process.env) => join10(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "profiles", `${profile}.moderation.json`), "moderationPathFor");
|
|
13349
|
+
var ModerationRules = class {
|
|
13350
|
+
static {
|
|
13351
|
+
__name(this, "ModerationRules");
|
|
13352
|
+
}
|
|
13353
|
+
path;
|
|
13354
|
+
constructor(path) {
|
|
13355
|
+
this.path = path;
|
|
13356
|
+
}
|
|
13357
|
+
/** `undefined` when this group has no section yet. */
|
|
13358
|
+
read(chatId) {
|
|
13359
|
+
return this.#file().groups[chatId];
|
|
13360
|
+
}
|
|
13361
|
+
/** Writes the group's whole section — the defaults first, if it had none — with one key changed. */
|
|
13362
|
+
set(chatId, title, key, value) {
|
|
13363
|
+
const known2 = KEYS[key];
|
|
13364
|
+
if (!known2)
|
|
13365
|
+
throw invalid4(`no rule ${key} \u2014 one of: ${RULE_KEYS.join(", ")}`);
|
|
13366
|
+
const current = this.read(chatId) ?? defaultRules(title);
|
|
13367
|
+
const checked2 = safeParse(groupRules, assign(current, key, known2.parse(value)));
|
|
13368
|
+
if (!checked2.success)
|
|
13369
|
+
throw invalid4(`${key} ${JSON.stringify(value)} is not valid \u2014 ${known2.help}`);
|
|
13370
|
+
const saved = this.#file();
|
|
13371
|
+
this.#write({ ...saved, groups: { ...saved.groups, [chatId]: checked2.output } });
|
|
13372
|
+
return checked2.output;
|
|
13373
|
+
}
|
|
13374
|
+
/** Puts one key back to its default. */
|
|
13375
|
+
unset(chatId, title, key) {
|
|
13376
|
+
if (!KEYS[key])
|
|
13377
|
+
throw invalid4(`no rule ${key} \u2014 one of: ${RULE_KEYS.join(", ")}`);
|
|
13378
|
+
const current = this.read(chatId) ?? defaultRules(title);
|
|
13379
|
+
const changed = assign(current, key, lookup(defaultRules(title), key));
|
|
13380
|
+
const saved = this.#file();
|
|
13381
|
+
this.#write({ ...saved, groups: { ...saved.groups, [chatId]: changed } });
|
|
13382
|
+
return changed;
|
|
13383
|
+
}
|
|
13384
|
+
checkedUntil(chatId) {
|
|
13385
|
+
return this.#file().checkedUntil?.[chatId];
|
|
13386
|
+
}
|
|
13387
|
+
markChecked(chatId, at) {
|
|
13388
|
+
const saved = this.#file();
|
|
13389
|
+
this.#write({ ...saved, checkedUntil: { ...saved.checkedUntil, [chatId]: at } });
|
|
13390
|
+
}
|
|
13391
|
+
#file() {
|
|
13392
|
+
if (!existsSync(this.path))
|
|
13393
|
+
return { groups: {} };
|
|
13394
|
+
let parsed;
|
|
13395
|
+
try {
|
|
13396
|
+
parsed = JSON.parse(readFileSync(this.path, "utf8"));
|
|
13397
|
+
} catch (error) {
|
|
13398
|
+
throw broken(this.path, error instanceof Error ? error.message : String(error));
|
|
13399
|
+
}
|
|
13400
|
+
const checked2 = safeParse(file, parsed);
|
|
13401
|
+
if (!checked2.success) {
|
|
13402
|
+
const problems = checked2.issues.map((issue) => `${getDotPath(issue) ?? "file"}: ${issue.message}`);
|
|
13403
|
+
throw broken(this.path, problems.join("; "));
|
|
13404
|
+
}
|
|
13405
|
+
return checked2.output;
|
|
13406
|
+
}
|
|
13407
|
+
#write(content) {
|
|
13408
|
+
writeSecurely(this.path, `${JSON.stringify(content, null, 2)}
|
|
13409
|
+
`, 384);
|
|
13410
|
+
}
|
|
13411
|
+
};
|
|
13412
|
+
var invalid4 = /* @__PURE__ */ __name((message) => new CliError("validation_error", message), "invalid");
|
|
13413
|
+
var broken = /* @__PURE__ */ __name((path, why) => new CliError("configuration_error", `the moderation rules ${path} cannot be read (${why}) \u2014 fix the file`), "broken");
|
|
13414
|
+
var lookup = /* @__PURE__ */ __name((rules, key) => key.split(".").reduce((value, part) => value[part], rules), "lookup");
|
|
13415
|
+
var assign = /* @__PURE__ */ __name((rules, key, value) => {
|
|
13416
|
+
const [head, tail] = key.split(".");
|
|
13417
|
+
if (tail === void 0)
|
|
13418
|
+
return { ...rules, [head]: value };
|
|
13419
|
+
return { ...rules, [head]: { ...rules[head], [tail]: value } };
|
|
13420
|
+
}, "assign");
|
|
13421
|
+
|
|
13003
13422
|
// node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/moderation/run.js
|
|
13004
13423
|
var FIRST_LOOK_MS = 24 * 36e5;
|
|
13005
13424
|
var moderateWith = /* @__PURE__ */ __name(async (run) => {
|
|
13006
13425
|
const { chatId, title, rules, point, since, dryRun } = run;
|
|
13007
13426
|
const saved = rules.read(chatId);
|
|
13008
|
-
const
|
|
13427
|
+
const groupRules2 = saved ?? defaultRules(title);
|
|
13009
13428
|
const last = point.read(chatId);
|
|
13010
13429
|
const from = since ?? (last === void 0 ? Date.now() - FIRST_LOOK_MS : Date.parse(last));
|
|
13011
13430
|
const found = await run.gather(from);
|
|
13012
13431
|
const findings = judge({
|
|
13013
13432
|
...found,
|
|
13014
|
-
rules:
|
|
13433
|
+
rules: groupRules2,
|
|
13015
13434
|
now: Date.now(),
|
|
13016
13435
|
...run.invites ? { invites: run.invites } : {}
|
|
13017
13436
|
});
|
|
13018
13437
|
const rows = await act(run.moderator, findings, {
|
|
13019
13438
|
chatId,
|
|
13020
|
-
rules:
|
|
13439
|
+
rules: groupRules2,
|
|
13021
13440
|
allowDangerous: run.allowDangerous,
|
|
13022
13441
|
dryRun,
|
|
13023
13442
|
maxActions: run.maxActions,
|
|
@@ -13039,7 +13458,7 @@ var moderateWith = /* @__PURE__ */ __name(async (run) => {
|
|
|
13039
13458
|
|
|
13040
13459
|
// node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/moderation.js
|
|
13041
13460
|
var moderationService = /* @__PURE__ */ __name((deps) => {
|
|
13042
|
-
const
|
|
13461
|
+
const file2 = /* @__PURE__ */ __name(() => new ModerationRules(moderationPathFor(deps.messenger.app, deps.profile ?? "default", deps.env ?? process.env)), "file");
|
|
13043
13462
|
const group = /* @__PURE__ */ __name(async (chat) => {
|
|
13044
13463
|
if (deps.offline)
|
|
13045
13464
|
throw new CliError("validation_error", "a group's rules are kept by its id, which the messenger gives");
|
|
@@ -13057,18 +13476,18 @@ var moderationService = /* @__PURE__ */ __name((deps) => {
|
|
|
13057
13476
|
return {
|
|
13058
13477
|
rules: /* @__PURE__ */ __name(async (chat) => {
|
|
13059
13478
|
const { id: id2, title } = await group(chat);
|
|
13060
|
-
return shown(id2, title,
|
|
13479
|
+
return shown(id2, title, file2());
|
|
13061
13480
|
}, "rules"),
|
|
13062
13481
|
set: /* @__PURE__ */ __name(async (chat, key, value) => {
|
|
13063
13482
|
refuseAge(key);
|
|
13064
13483
|
const { id: id2, title } = await group(chat);
|
|
13065
|
-
const rules =
|
|
13484
|
+
const rules = file2();
|
|
13066
13485
|
rules.set(id2, title, key, value);
|
|
13067
13486
|
return shown(id2, title, rules);
|
|
13068
13487
|
}, "set"),
|
|
13069
13488
|
unset: /* @__PURE__ */ __name(async (chat, key) => {
|
|
13070
13489
|
const { id: id2, title } = await group(chat);
|
|
13071
|
-
const rules =
|
|
13490
|
+
const rules = file2();
|
|
13072
13491
|
rules.unset(id2, title, key);
|
|
13073
13492
|
return shown(id2, title, rules);
|
|
13074
13493
|
}, "unset"),
|
|
@@ -13077,7 +13496,7 @@ var moderationService = /* @__PURE__ */ __name((deps) => {
|
|
|
13077
13496
|
throw new CliError("validation_error", "`chats moderate` asks the messenger what is new");
|
|
13078
13497
|
const connection = await deps.connection();
|
|
13079
13498
|
const { id: chatId, title } = await connection.resolve(chat);
|
|
13080
|
-
const rules =
|
|
13499
|
+
const rules = file2();
|
|
13081
13500
|
const { inviteLinks } = deps.messenger;
|
|
13082
13501
|
return moderateWith({
|
|
13083
13502
|
chatId,
|
|
@@ -13191,11 +13610,11 @@ var eventsOnce = /* @__PURE__ */ __name(async (store, filter, limit) => {
|
|
|
13191
13610
|
}
|
|
13192
13611
|
return { items, cut: true };
|
|
13193
13612
|
}, "eventsOnce");
|
|
13194
|
-
var readsOf = /* @__PURE__ */ __name((
|
|
13613
|
+
var readsOf = /* @__PURE__ */ __name((record2, asked) => record2.identities.flatMap((identity) => (identity.provider === asked.provider ? [asked.account] : identity.accounts).filter((account2) => identity.accounts.includes(account2)).map((account2) => ({ key: { provider: identity.provider, account: account2 }, identity }))), "readsOf");
|
|
13195
13614
|
var personContext = /* @__PURE__ */ __name(async (store, asked, reference, { messages = CONTEXT_MESSAGES2, bytes: bytes2 = CONTEXT_BYTES, since, now = Date.now() } = {}) => {
|
|
13196
13615
|
const found = pickPerson(reference, await store.people.people(asked.provider, { account: asked.account }));
|
|
13197
|
-
const
|
|
13198
|
-
if (!
|
|
13616
|
+
const record2 = await store.people.personOf({ provider: asked.provider, id: found.id });
|
|
13617
|
+
if (!record2)
|
|
13199
13618
|
throw new CliError("not_found", `no person ${found.id} in the store`);
|
|
13200
13619
|
const recent = /* @__PURE__ */ __name((message) => since === void 0 || Date.parse(message.timestamp) >= since, "recent");
|
|
13201
13620
|
const shared = [];
|
|
@@ -13205,7 +13624,7 @@ var personContext = /* @__PURE__ */ __name(async (store, asked, reference, { mes
|
|
|
13205
13624
|
const theirs = [];
|
|
13206
13625
|
const mentions = [];
|
|
13207
13626
|
let cut = false;
|
|
13208
|
-
for (const { key, identity } of readsOf(
|
|
13627
|
+
for (const { key, identity } of readsOf(record2, asked)) {
|
|
13209
13628
|
const chats = await store.chats.chatsWith(key, identity.id);
|
|
13210
13629
|
for (const chat of chats) {
|
|
13211
13630
|
shared.push({ ...key, chatId: chat.id, title: chat.title, kind: chat.kind, lastMessageAt: chat.lastMessageAt });
|
|
@@ -13253,7 +13672,7 @@ var personContext = /* @__PURE__ */ __name(async (store, asked, reference, { mes
|
|
|
13253
13672
|
mentions.push(...named2.items.filter((hit) => hit.senderId !== identity.id).map((hit) => toContext(key, hit, hit.chatTitle ?? null)).filter(recent));
|
|
13254
13673
|
cut ||= named2.hasMore;
|
|
13255
13674
|
}
|
|
13256
|
-
const personId = Number(
|
|
13675
|
+
const personId = Number(record2.uid);
|
|
13257
13676
|
const upcoming = await eventsOnce(store, { personId, from: now }, messages);
|
|
13258
13677
|
const upcomingIds = new Set(upcoming.items.map(({ id: id2 }) => id2));
|
|
13259
13678
|
const past = await eventsOnce(store, { personId, to: now, newest: true, ...since === void 0 ? {} : { from: since } }, messages);
|
|
@@ -13273,7 +13692,7 @@ var personContext = /* @__PURE__ */ __name(async (store, asked, reference, { mes
|
|
|
13273
13692
|
cut ||= direct.length > messages || groups.length > messages || mentions.length > messages;
|
|
13274
13693
|
const kept = withinBytes(lists, bytes2);
|
|
13275
13694
|
return {
|
|
13276
|
-
person: { ...
|
|
13695
|
+
person: { ...record2, provider: asked.provider, id: found.id },
|
|
13277
13696
|
shared: shared.sort((a, b) => Date.parse(b.lastMessageAt ?? "") - Date.parse(a.lastMessageAt ?? "")),
|
|
13278
13697
|
last: {
|
|
13279
13698
|
fromThem: each.find((message) => !message.outgoing) ?? null,
|
|
@@ -13348,8 +13767,8 @@ var lean = /* @__PURE__ */ __name((key, message, detail) => {
|
|
|
13348
13767
|
var kindOf3 = /* @__PURE__ */ __name((chat, chatId, person) => chat && chat.kind !== "unknown" ? chat.kind : chatId === person ? "dialog" : chat?.kind ?? "unknown", "kindOf");
|
|
13349
13768
|
var personMessages = /* @__PURE__ */ __name(async (store, asked, reference, { chats, limit = CHAT_MESSAGES, detail = 0 }) => {
|
|
13350
13769
|
const found = pickPerson(reference, await store.people.people(asked.provider, { account: asked.account }));
|
|
13351
|
-
const
|
|
13352
|
-
if (!
|
|
13770
|
+
const record2 = await store.people.personOf({ provider: asked.provider, id: found.id });
|
|
13771
|
+
if (!record2)
|
|
13353
13772
|
throw new CliError("not_found", `no person ${found.id} in the store`);
|
|
13354
13773
|
const stored = (await store.chats.chats(asked, {})).items;
|
|
13355
13774
|
const held = new Map((await store.chats.chatCompleteness(asked, chats)).map((one) => [one.chatId, one.state]));
|
|
@@ -13365,7 +13784,7 @@ var personMessages = /* @__PURE__ */ __name(async (store, asked, reference, { ch
|
|
|
13365
13784
|
});
|
|
13366
13785
|
}
|
|
13367
13786
|
return {
|
|
13368
|
-
person: { uid:
|
|
13787
|
+
person: { uid: record2.uid, provider: asked.provider, id: found.id, name: found.name ?? record2.name },
|
|
13369
13788
|
chats: answer,
|
|
13370
13789
|
limits: { messages: limit }
|
|
13371
13790
|
};
|
|
@@ -13883,7 +14302,7 @@ var activityIn = /* @__PURE__ */ __name(async (store, account2, facts) => {
|
|
|
13883
14302
|
...facts.chats,
|
|
13884
14303
|
...[...stats.values()].filter(({ chatId }) => !listed.has(chatId)).map(({ chatId, title, kind, lastAt }) => ({ id: chatId, title, kind, lastMessageAt: lastAt }))
|
|
13885
14304
|
];
|
|
13886
|
-
const
|
|
14305
|
+
const whole4 = new Set((await store.chats.chatCompleteness(account2, chats.map(({ id: id2 }) => id2))).filter(({ state }) => state === "complete").map(({ chatId }) => chatId));
|
|
13887
14306
|
return chats.map(({ id: id2, title, kind }) => {
|
|
13888
14307
|
const one = stats.get(id2);
|
|
13889
14308
|
return {
|
|
@@ -13893,7 +14312,7 @@ var activityIn = /* @__PURE__ */ __name(async (store, account2, facts) => {
|
|
|
13893
14312
|
theirMessages: one?.messages ?? 0,
|
|
13894
14313
|
firstAt: one?.firstAt ?? null,
|
|
13895
14314
|
lastAt: one?.lastAt ?? null,
|
|
13896
|
-
complete:
|
|
14315
|
+
complete: whole4.has(id2)
|
|
13897
14316
|
};
|
|
13898
14317
|
});
|
|
13899
14318
|
}, "activityIn");
|
|
@@ -13925,10 +14344,10 @@ var personTimeline = /* @__PURE__ */ __name(async (store, asked, reference, { sc
|
|
|
13925
14344
|
if (since !== void 0 && until !== void 0 && since > until)
|
|
13926
14345
|
throw new CliError("validation_error", "the start of the range is after its end");
|
|
13927
14346
|
const found = pickPerson(reference, await store.people.people(asked.provider, { account: asked.account }));
|
|
13928
|
-
const
|
|
13929
|
-
if (!
|
|
14347
|
+
const record2 = await store.people.personOf({ provider: asked.provider, id: found.id });
|
|
14348
|
+
if (!record2)
|
|
13930
14349
|
throw new CliError("not_found", `no person ${found.id} in the store`);
|
|
13931
|
-
const personId = Number(
|
|
14350
|
+
const personId = Number(record2.uid);
|
|
13932
14351
|
const pending = store.involvements.pending();
|
|
13933
14352
|
const rows = store.involvements.forPerson(personId, {
|
|
13934
14353
|
...scope === void 0 ? {} : { scope },
|
|
@@ -13942,7 +14361,7 @@ var personTimeline = /* @__PURE__ */ __name(async (store, asked, reference, { sc
|
|
|
13942
14361
|
const last = shown.at(-1);
|
|
13943
14362
|
const hasMore = rows.length > limit;
|
|
13944
14363
|
return {
|
|
13945
|
-
person: { uid:
|
|
14364
|
+
person: { uid: record2.uid, name: record2.name },
|
|
13946
14365
|
items: shown.map((row) => ({
|
|
13947
14366
|
at: new Date(row.occurredAt).toISOString(),
|
|
13948
14367
|
subject: row.subjectType,
|
|
@@ -13979,20 +14398,20 @@ var peopleService = /* @__PURE__ */ __name((deps) => {
|
|
|
13979
14398
|
const held = await storeIfOpen(deps);
|
|
13980
14399
|
if (!held)
|
|
13981
14400
|
return reference;
|
|
13982
|
-
const
|
|
14401
|
+
const lookup2 = await held.store.people.people(held.account.provider, { account: held.account.account });
|
|
13983
14402
|
const wanted = reference.trim().toLowerCase();
|
|
13984
|
-
return
|
|
14403
|
+
return lookup2.all().some((person) => person.alias?.toLowerCase().includes(wanted)) ? pickPerson(reference, lookup2).id : reference;
|
|
13985
14404
|
}, "referenceOf");
|
|
13986
14405
|
const online = /* @__PURE__ */ __name(async (command) => {
|
|
13987
14406
|
if (deps.offline)
|
|
13988
14407
|
throw new CliError("validation_error", `\`${command}\` changes the address book; not with --offline`);
|
|
13989
14408
|
return deps.connection();
|
|
13990
14409
|
}, "online");
|
|
13991
|
-
const change = /* @__PURE__ */ __name(async (
|
|
13992
|
-
const connection = await online(`contacts ${
|
|
14410
|
+
const change = /* @__PURE__ */ __name(async (action2, person, act2) => {
|
|
14411
|
+
const connection = await online(`contacts ${action2.slice("contact-".length)}`);
|
|
13993
14412
|
const [personId] = await capability(connection, "people", "find people")([await referenceOf(person)]);
|
|
13994
14413
|
const operationId = newOperationId();
|
|
13995
|
-
const done2 = await guardedWrite(deps.guard, { operationId, chatId: null, kind: "account", action }, () => act2(connection, personId));
|
|
14414
|
+
const done2 = await guardedWrite(deps.guard, { operationId, chatId: null, kind: "account", action: action2 }, () => act2(connection, personId));
|
|
13996
14415
|
return { operationId, personId, done: done2 };
|
|
13997
14416
|
}, "change");
|
|
13998
14417
|
return {
|
|
@@ -14679,14 +15098,14 @@ var viewOf = /* @__PURE__ */ __name((account2, target) => target.type === "messa
|
|
|
14679
15098
|
var tagsService = /* @__PURE__ */ __name((deps) => {
|
|
14680
15099
|
const inStore = /* @__PURE__ */ __name(async (work) => work(await deps.store(), await deps.account()), "inStore");
|
|
14681
15100
|
return {
|
|
14682
|
-
add: /* @__PURE__ */ __name((given,
|
|
14683
|
-
const tags = tagsOf(
|
|
15101
|
+
add: /* @__PURE__ */ __name((given, list3) => inStore(async (store, account2) => {
|
|
15102
|
+
const tags = tagsOf(list3);
|
|
14684
15103
|
const target = await targetOf(deps, store, account2, given);
|
|
14685
15104
|
const added = await store.tags.addTags(account2, target, tags);
|
|
14686
15105
|
return { target: viewOf(account2, target), added, unchanged: tags.filter((tag) => !added.includes(tag)) };
|
|
14687
15106
|
}), "add"),
|
|
14688
|
-
remove: /* @__PURE__ */ __name((given,
|
|
14689
|
-
const tags = tagsOf(
|
|
15107
|
+
remove: /* @__PURE__ */ __name((given, list3, source) => inStore(async (store, account2) => {
|
|
15108
|
+
const tags = tagsOf(list3);
|
|
14690
15109
|
const target = await targetOf(deps, store, account2, given);
|
|
14691
15110
|
const removed = await store.tags.removeTags(account2, target, tags, source);
|
|
14692
15111
|
return { target: viewOf(account2, target), removed, unchanged: tags.filter((tag) => !removed.includes(tag)) };
|
|
@@ -14846,21 +15265,21 @@ var tasksService = /* @__PURE__ */ __name((deps, categories) => {
|
|
|
14846
15265
|
const author = by === "owner" ? "owner" : { bot: by };
|
|
14847
15266
|
await store.tasks.edit(id2, fields, author);
|
|
14848
15267
|
if (assignees !== void 0)
|
|
14849
|
-
await
|
|
15268
|
+
await assign2(store, id2, assignees, author);
|
|
14850
15269
|
return cardOf(store, id2);
|
|
14851
15270
|
}, "planOf");
|
|
14852
|
-
const
|
|
15271
|
+
const assign2 = /* @__PURE__ */ __name(async (store, id2, given, by) => {
|
|
14853
15272
|
const wanted = /* @__PURE__ */ new Set();
|
|
14854
15273
|
for (const one of given ?? []) {
|
|
14855
|
-
const
|
|
14856
|
-
if (
|
|
15274
|
+
const who2 = one.trim();
|
|
15275
|
+
if (who2 === "sender") {
|
|
14857
15276
|
const sender = await store.tasks.sourceSender(id2);
|
|
14858
15277
|
if (sender)
|
|
14859
15278
|
wanted.add(sender);
|
|
14860
|
-
} else if (/^person:\d+$/.test(
|
|
14861
|
-
wanted.add(
|
|
15279
|
+
} else if (/^person:\d+$/.test(who2))
|
|
15280
|
+
wanted.add(who2);
|
|
14862
15281
|
else
|
|
14863
|
-
throw new CliError("validation_error", `an assignee is sender or person:<id>, not "${singleLine(
|
|
15282
|
+
throw new CliError("validation_error", `an assignee is sender or person:<id>, not "${singleLine(who2)}"`);
|
|
14864
15283
|
}
|
|
14865
15284
|
const current = (await store.tasks.details(id2)).assignments.filter((one) => one.role === "assignee");
|
|
14866
15285
|
for (const one of current)
|
|
@@ -15329,8 +15748,8 @@ var topicsService = /* @__PURE__ */ __name((deps) => {
|
|
|
15329
15748
|
const editTopic = capability(connection, "editTopic", "edit forum topics");
|
|
15330
15749
|
const chatId = (await connection.resolve(chat)).id;
|
|
15331
15750
|
const operationId = newOperationId();
|
|
15332
|
-
const
|
|
15333
|
-
const topic = await guardedWrite(deps.guard, { operationId, chatId, kind: "chat", action, key: "topics.edit", threadId: topicId }, () => editTopic(chatId, topicId, {
|
|
15751
|
+
const action2 = actionOf(change);
|
|
15752
|
+
const topic = await guardedWrite(deps.guard, { operationId, chatId, kind: "chat", action: action2, key: "topics.edit", threadId: topicId }, () => editTopic(chatId, topicId, {
|
|
15334
15753
|
...title === void 0 ? {} : { title },
|
|
15335
15754
|
...closed === void 0 ? {} : { closed },
|
|
15336
15755
|
...pinned === void 0 ? {} : { pinned },
|
|
@@ -15566,20 +15985,20 @@ var readMeetingLinks = /* @__PURE__ */ __name(async (store, request) => {
|
|
|
15566
15985
|
import { createHash as createHash13 } from "node:crypto";
|
|
15567
15986
|
|
|
15568
15987
|
// node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/meeting-project-candidate-validation.js
|
|
15569
|
-
function
|
|
15988
|
+
function invalid5(field, response = false) {
|
|
15570
15989
|
throw new CliError(response ? "invalid_response" : "validation_error", `invalid project candidate ${field}`);
|
|
15571
15990
|
}
|
|
15572
|
-
__name(
|
|
15991
|
+
__name(invalid5, "invalid");
|
|
15573
15992
|
var object2 = /* @__PURE__ */ __name((value, fields, field) => {
|
|
15574
15993
|
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
15575
|
-
|
|
15994
|
+
invalid5(field);
|
|
15576
15995
|
for (const key of Object.keys(value))
|
|
15577
15996
|
if (!fields.includes(key))
|
|
15578
|
-
|
|
15997
|
+
invalid5(`${field}.${key}`);
|
|
15579
15998
|
}, "object");
|
|
15580
15999
|
var bounded = /* @__PURE__ */ __name((value, max, field) => {
|
|
15581
16000
|
if (typeof value !== "string" || value.length > max)
|
|
15582
|
-
|
|
16001
|
+
invalid5(field);
|
|
15583
16002
|
return value;
|
|
15584
16003
|
}, "bounded");
|
|
15585
16004
|
var utf8 = /* @__PURE__ */ __name((value) => new TextEncoder().encode(value).byteLength, "utf8");
|
|
@@ -15594,10 +16013,10 @@ var candidateLimits = /* @__PURE__ */ __name((options = {}) => {
|
|
|
15594
16013
|
for (const [key, value] of Object.entries(limits)) {
|
|
15595
16014
|
const max = key === "limit" ? 10 : key === "maxProjects" ? 128 : 65536;
|
|
15596
16015
|
if (!Number.isSafeInteger(value) || value < (key === "bytes" ? 1024 : 1) || value > max)
|
|
15597
|
-
|
|
16016
|
+
invalid5(key);
|
|
15598
16017
|
}
|
|
15599
16018
|
if (options.signal !== void 0 && !(options.signal instanceof AbortSignal))
|
|
15600
|
-
|
|
16019
|
+
invalid5("signal");
|
|
15601
16020
|
return limits;
|
|
15602
16021
|
}, "candidateLimits");
|
|
15603
16022
|
var candidateInput = /* @__PURE__ */ __name((input, accountId) => {
|
|
@@ -15605,11 +16024,11 @@ var candidateInput = /* @__PURE__ */ __name((input, accountId) => {
|
|
|
15605
16024
|
const reference = bounded(input.reference, 200, "reference");
|
|
15606
16025
|
const parent = parseMeetingReference(reference);
|
|
15607
16026
|
if (parent.accountId !== accountId || parent.transcriptId !== void 0 || formatMeetingReference(parent) !== reference)
|
|
15608
|
-
|
|
16027
|
+
invalid5("reference");
|
|
15609
16028
|
if (input.title !== void 0)
|
|
15610
16029
|
bounded(input.title, 8192, "title");
|
|
15611
16030
|
if (input.cues !== void 0 && (!Array.isArray(input.cues) || input.cues.length > 100))
|
|
15612
|
-
|
|
16031
|
+
invalid5("cues");
|
|
15613
16032
|
let bytes2 = utf8(input.title ?? "");
|
|
15614
16033
|
const cues = /* @__PURE__ */ new Map();
|
|
15615
16034
|
for (const cue of input.cues ?? []) {
|
|
@@ -15617,70 +16036,70 @@ var candidateInput = /* @__PURE__ */ __name((input, accountId) => {
|
|
|
15617
16036
|
const ref = bounded(cue.reference, 200, "cue.reference");
|
|
15618
16037
|
bounded(cue.text, 65536, "cue.text");
|
|
15619
16038
|
if (!/^[a-f0-9]{64}$/.test(bounded(cue.fingerprint, 64, "cue.fingerprint")))
|
|
15620
|
-
|
|
16039
|
+
invalid5("cue.fingerprint");
|
|
15621
16040
|
if (cue.revision !== "current" && cue.revision !== "superseded")
|
|
15622
|
-
|
|
16041
|
+
invalid5("cue.revision");
|
|
15623
16042
|
const parsed = parseMeetingReference(ref);
|
|
15624
16043
|
if (parsed.accountId !== accountId || parsed.meetingId !== parent.meetingId || parsed.cuePosition === void 0 || formatMeetingReference(parsed) !== ref)
|
|
15625
|
-
|
|
16044
|
+
invalid5("cue.reference");
|
|
15626
16045
|
bytes2 += utf8(cue.text);
|
|
15627
16046
|
if (bytes2 > 65536)
|
|
15628
|
-
|
|
16047
|
+
invalid5("input bytes");
|
|
15629
16048
|
const previous = cues.get(ref);
|
|
15630
16049
|
if (previous && (previous.text !== cue.text || previous.fingerprint !== cue.fingerprint || previous.revision !== cue.revision))
|
|
15631
|
-
|
|
16050
|
+
invalid5("conflicting cue.reference");
|
|
15632
16051
|
cues.set(ref, { reference: ref, fingerprint: cue.fingerprint, text: cue.text, revision: cue.revision });
|
|
15633
16052
|
}
|
|
15634
16053
|
if (bytes2 > 65536)
|
|
15635
|
-
|
|
16054
|
+
invalid5("input bytes");
|
|
15636
16055
|
return { reference, ...input.title === void 0 ? {} : { title: input.title }, cues: [...cues.values()] };
|
|
15637
16056
|
}, "candidateInput");
|
|
15638
16057
|
var candidateCatalog = /* @__PURE__ */ __name((catalog, limits) => {
|
|
15639
16058
|
if (!catalog || !Array.isArray(catalog.entries) || catalog.entries.length > limits.maxProjects)
|
|
15640
|
-
|
|
16059
|
+
invalid5("catalog.entries", true);
|
|
15641
16060
|
if (typeof catalog.fingerprint !== "string" || !catalog.fingerprint || catalog.fingerprint.length > 200 || /[\p{Cc}\p{Cf}]/u.test(catalog.fingerprint) || catalog.coverage?.complete !== true || catalog.coverage.maxEntries !== limits.maxProjects || catalog.coverage.maxReadBytes !== limits.maxVocabularyReadBytes)
|
|
15642
|
-
|
|
16061
|
+
invalid5("catalog.coverage", true);
|
|
15643
16062
|
let aliases = 0, bytes2 = 0;
|
|
15644
16063
|
const ids = /* @__PURE__ */ new Set();
|
|
15645
16064
|
const aliasIds = /* @__PURE__ */ new Set();
|
|
15646
16065
|
const id2 = /* @__PURE__ */ __name((value) => {
|
|
15647
16066
|
if (typeof value !== "string" || !/^[1-9]\d{0,15}$/.test(value) || !Number.isSafeInteger(Number(value)))
|
|
15648
|
-
|
|
16067
|
+
invalid5("catalog.id", true);
|
|
15649
16068
|
}, "id");
|
|
15650
16069
|
const name = /* @__PURE__ */ __name((value) => {
|
|
15651
16070
|
try {
|
|
15652
16071
|
normalizeVocabularyName(value);
|
|
15653
16072
|
} catch {
|
|
15654
|
-
|
|
16073
|
+
invalid5("catalog.name", true);
|
|
15655
16074
|
}
|
|
15656
16075
|
bytes2 += utf8(value);
|
|
15657
16076
|
}, "name");
|
|
15658
16077
|
for (const entry of catalog.entries) {
|
|
15659
16078
|
if (entry?.kind !== "project")
|
|
15660
|
-
|
|
16079
|
+
invalid5("catalog.kind", true);
|
|
15661
16080
|
id2(entry.id);
|
|
15662
16081
|
if (ids.has(entry.id))
|
|
15663
|
-
|
|
16082
|
+
invalid5("catalog.id", true);
|
|
15664
16083
|
ids.add(entry.id);
|
|
15665
16084
|
name(entry.name);
|
|
15666
16085
|
if (entry.key !== null)
|
|
15667
16086
|
name(entry.key);
|
|
15668
16087
|
if (!Array.isArray(entry.aliases))
|
|
15669
|
-
|
|
16088
|
+
invalid5("catalog.aliases", true);
|
|
15670
16089
|
aliases += entry.aliases.length;
|
|
15671
16090
|
if (aliases > limits.maxProjects * 20)
|
|
15672
|
-
|
|
16091
|
+
invalid5("catalog.aliases", true);
|
|
15673
16092
|
for (const alias of entry.aliases) {
|
|
15674
16093
|
if (!alias)
|
|
15675
|
-
|
|
16094
|
+
invalid5("catalog.alias", true);
|
|
15676
16095
|
id2(alias.id);
|
|
15677
16096
|
if (aliasIds.has(alias.id))
|
|
15678
|
-
|
|
16097
|
+
invalid5("catalog.alias.id", true);
|
|
15679
16098
|
aliasIds.add(alias.id);
|
|
15680
16099
|
name(alias.name);
|
|
15681
16100
|
}
|
|
15682
16101
|
if (bytes2 > limits.maxVocabularyReadBytes)
|
|
15683
|
-
|
|
16102
|
+
invalid5("catalog.bytes", true);
|
|
15684
16103
|
}
|
|
15685
16104
|
}, "candidateCatalog");
|
|
15686
16105
|
|
|
@@ -15894,9 +16313,9 @@ var meetingSearchesService = /* @__PURE__ */ __name((searches) => {
|
|
|
15894
16313
|
});
|
|
15895
16314
|
return search;
|
|
15896
16315
|
}, "found");
|
|
15897
|
-
const
|
|
16316
|
+
const record2 = /* @__PURE__ */ __name(({ query, options }) => searchRecordOf("meetings-search", { ...options, text: query }), "record");
|
|
15898
16317
|
return {
|
|
15899
|
-
create: /* @__PURE__ */ __name(async (name, params, { replace = false } = {}) => (await searches()).saveSearch(nameOf(name),
|
|
16318
|
+
create: /* @__PURE__ */ __name(async (name, params, { replace = false } = {}) => (await searches()).saveSearch(nameOf(name), record2(params), { replace }), "create"),
|
|
15900
16319
|
list: /* @__PURE__ */ __name(async () => (await searches()).savedSearches(KIND), "list"),
|
|
15901
16320
|
show: found,
|
|
15902
16321
|
delete: /* @__PURE__ */ __name(async (reference) => (await searches()).deleteSearch((await found(reference)).id), "delete"),
|
|
@@ -15904,7 +16323,7 @@ var meetingSearchesService = /* @__PURE__ */ __name((searches) => {
|
|
|
15904
16323
|
const search = await found(reference);
|
|
15905
16324
|
const { text: text2, ...options } = search.params;
|
|
15906
16325
|
const query = { query: String(text2 ?? ""), options };
|
|
15907
|
-
await (await searches()).recordSearch(
|
|
16326
|
+
await (await searches()).recordSearch(record2(query), { saved: search.id });
|
|
15908
16327
|
return { id: search.id, name: search.name, ...query };
|
|
15909
16328
|
}, "run")
|
|
15910
16329
|
};
|
|
@@ -16528,7 +16947,7 @@ var createMeetingContextService = /* @__PURE__ */ __name(async (store, input, op
|
|
|
16528
16947
|
}, "createMeetingContextService");
|
|
16529
16948
|
|
|
16530
16949
|
// node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/meeting-model.js
|
|
16531
|
-
var
|
|
16950
|
+
var integer2 = /* @__PURE__ */ __name((value, name, max) => {
|
|
16532
16951
|
if (!Number.isSafeInteger(value) || value < 1 || value > max)
|
|
16533
16952
|
throw new CliError("validation_error", `Invalid ${name}`);
|
|
16534
16953
|
return value;
|
|
@@ -16548,7 +16967,7 @@ var validatedRemote = /* @__PURE__ */ __name((remote) => {
|
|
|
16548
16967
|
throw new CliError("validation_error", "Embedding endpoint requires HTTP/S without credentials, query or fragment");
|
|
16549
16968
|
if (typeof remote.model !== "string" || !/^[\w./:-]{1,200}$/.test(remote.model))
|
|
16550
16969
|
throw new CliError("validation_error", "Invalid embedding model name");
|
|
16551
|
-
const dims =
|
|
16970
|
+
const dims = integer2(remote.dims, "embedding dimensions", 8192);
|
|
16552
16971
|
const baseUrl = remote.baseUrl.replace(/\/+$/, "");
|
|
16553
16972
|
const result = remoteModel({ model: remote.model, dims, ...baseUrl === OPENAI_URL ? {} : { baseUrl } });
|
|
16554
16973
|
return result;
|
|
@@ -16630,10 +17049,10 @@ var openMeetingEmbedder = /* @__PURE__ */ __name(async (choice, options = {}) =>
|
|
|
16630
17049
|
const descriptor2 = meetingEmbeddingModel(choice);
|
|
16631
17050
|
const { signal } = options;
|
|
16632
17051
|
cancelled3(signal);
|
|
16633
|
-
const maxInputBytes =
|
|
16634
|
-
const maxResponseBytes =
|
|
17052
|
+
const maxInputBytes = integer2(options.maxInputBytes ?? 1024 * 1024, "input byte budget", 16 * 1024 * 1024);
|
|
17053
|
+
const maxResponseBytes = integer2(options.maxResponseBytes ?? 8 * 1024 * 1024, "response byte budget", 64 * 1024 * 1024);
|
|
16635
17054
|
if (options.threads !== void 0)
|
|
16636
|
-
|
|
17055
|
+
integer2(options.threads, "embedding threads", 128);
|
|
16637
17056
|
let engine;
|
|
16638
17057
|
let remoteFailure;
|
|
16639
17058
|
if (typeof choice === "string") {
|
|
@@ -16923,9 +17342,9 @@ var readPreparationCommunications = /* @__PURE__ */ __name(async (plan, signal)
|
|
|
16923
17342
|
continue;
|
|
16924
17343
|
refs.add(item.ref);
|
|
16925
17344
|
const text2 = excerpt(item.text, plan.input.query, 300, { literal: true });
|
|
16926
|
-
const
|
|
17345
|
+
const whole4 = item.text.replace(/\s+/g, " ").trim();
|
|
16927
17346
|
const { sender: _, ...rest } = item;
|
|
16928
|
-
items.push({ ...rest, text: text2, selectionId: read.id, textTruncated: text2 !==
|
|
17347
|
+
items.push({ ...rest, text: text2, selectionId: read.id, textTruncated: text2 !== whole4 });
|
|
16929
17348
|
}
|
|
16930
17349
|
} catch (error) {
|
|
16931
17350
|
preparationCancelled(signal);
|
|
@@ -17083,12 +17502,12 @@ var validatePreparationCommunications = /* @__PURE__ */ __name((section, request
|
|
|
17083
17502
|
}, "validatePreparationCommunications");
|
|
17084
17503
|
|
|
17085
17504
|
// node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/meeting-knowledge-preparation.js
|
|
17086
|
-
var
|
|
17505
|
+
var invalid6 = /* @__PURE__ */ __name(() => {
|
|
17087
17506
|
throw new CliError("invalid_response", "Preparation knowledge returned an invalid selection");
|
|
17088
17507
|
}, "invalid");
|
|
17089
17508
|
var factOf = /* @__PURE__ */ __name((fact, before2) => {
|
|
17090
17509
|
if (!fact || typeof fact.ref !== "string" || !/^fact:[1-9]\d*$/.test(fact.ref) || !["fact", "statement", "question", "decision", "promise"].includes(fact.type) || typeof fact.statement !== "string" || !fact.statement.trim() || fact.subject !== null && (typeof fact.subject !== "string" || !/^(person|project):[1-9]\d*$/.test(fact.subject)) || fact.project !== null && (typeof fact.project !== "string" || !/^project:[1-9]\d*$/.test(fact.project)) || !Number.isSafeInteger(fact.updatedAt) || Math.abs(fact.updatedAt) > 864e13 || fact.updatedAt > before2 || typeof fact.sharedPerson !== "boolean" || typeof fact.sharedProject !== "boolean" || !(fact.sharedPerson || fact.sharedProject) || fact.sharedPerson && !fact.subject?.startsWith("person:") || fact.sharedProject && !fact.project && !fact.subject?.startsWith("project:"))
|
|
17091
|
-
return
|
|
17510
|
+
return invalid6();
|
|
17092
17511
|
return {
|
|
17093
17512
|
ref: fact.ref,
|
|
17094
17513
|
type: fact.type,
|
|
@@ -17116,13 +17535,13 @@ var appendKnowledgePreparation = /* @__PURE__ */ __name(async (store, result, in
|
|
|
17116
17535
|
});
|
|
17117
17536
|
preparationCancelled(input.signal);
|
|
17118
17537
|
if (!page || !Array.isArray(page.items) || page.items.length > limit || typeof page.hasMore !== "boolean")
|
|
17119
|
-
return
|
|
17538
|
+
return invalid6();
|
|
17120
17539
|
const items = page.items.map((fact) => factOf(fact, input.after));
|
|
17121
17540
|
if (new Set(items.map((fact) => fact.ref)).size !== items.length)
|
|
17122
|
-
return
|
|
17541
|
+
return invalid6();
|
|
17123
17542
|
const readBytes = items.reduce((total, fact) => total + Buffer.byteLength(fact.statement + fact.type, "utf8"), 0);
|
|
17124
17543
|
if (readBytes > input.maxReadBytes)
|
|
17125
|
-
return
|
|
17544
|
+
return invalid6();
|
|
17126
17545
|
const knowledge = {
|
|
17127
17546
|
anchors: result.items.map((item) => item.reference),
|
|
17128
17547
|
items: [],
|
|
@@ -17152,12 +17571,12 @@ var appendKnowledgePreparation = /* @__PURE__ */ __name(async (store, result, in
|
|
|
17152
17571
|
}, "appendKnowledgePreparation");
|
|
17153
17572
|
|
|
17154
17573
|
// node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/meeting-notes-preparation.js
|
|
17155
|
-
var
|
|
17574
|
+
var invalid7 = /* @__PURE__ */ __name(() => {
|
|
17156
17575
|
throw new CliError("invalid_response", "Preparation notes returned an invalid selection");
|
|
17157
17576
|
}, "invalid");
|
|
17158
17577
|
var noteOf = /* @__PURE__ */ __name((note, before2, anchors) => {
|
|
17159
17578
|
if (!note || typeof note.ref !== "string" || !/^note:[1-9]\d*$/.test(note.ref) || note.title !== null && typeof note.title !== "string" || typeof note.text !== "string" || !note.text.trim() || !Number.isSafeInteger(note.revision) || note.revision < 1 || !Number.isSafeInteger(note.updatedAt) || Math.abs(note.updatedAt) > 864e13 || note.updatedAt > before2 || note.person !== null && (typeof note.person !== "string" || !/^person:[1-9]\d*$/.test(note.person)) || note.project !== null && (typeof note.project !== "string" || !/^project:[1-9]\d*$/.test(note.project)) || note.meeting !== void 0 && note.meeting !== null && !anchors.has(note.meeting) || !(note.person || note.project || note.meeting))
|
|
17160
|
-
return
|
|
17579
|
+
return invalid7();
|
|
17161
17580
|
return {
|
|
17162
17581
|
ref: note.ref,
|
|
17163
17582
|
title: note.title,
|
|
@@ -17185,18 +17604,18 @@ var appendNotesPreparation = /* @__PURE__ */ __name(async (store, result, input)
|
|
|
17185
17604
|
});
|
|
17186
17605
|
preparationCancelled(input.signal);
|
|
17187
17606
|
if (!page || !Array.isArray(page.items) || page.items.length > limit || typeof page.hasMore !== "boolean")
|
|
17188
|
-
return
|
|
17607
|
+
return invalid7();
|
|
17189
17608
|
const selection = page.selection === void 0 ? "owner-written-global-person/project-notes" : page.selection;
|
|
17190
17609
|
if (!["owner-written-global-person/project-notes", "owner-written-meeting/person/project-notes"].includes(selection))
|
|
17191
|
-
return
|
|
17610
|
+
return invalid7();
|
|
17192
17611
|
const anchors = new Set(result.items.map((item) => item.reference));
|
|
17193
17612
|
const items = page.items.map((note) => noteOf(note, input.after, anchors));
|
|
17194
17613
|
if (items.some((note) => note.meeting) && selection !== "owner-written-meeting/person/project-notes")
|
|
17195
|
-
return
|
|
17614
|
+
return invalid7();
|
|
17196
17615
|
if (new Set(items.map((note) => note.ref)).size !== items.length)
|
|
17197
|
-
return
|
|
17616
|
+
return invalid7();
|
|
17198
17617
|
if (items.reduce((total, note) => total + Buffer.byteLength((note.title ?? "") + note.text, "utf8"), 0) > input.maxReadBytes)
|
|
17199
|
-
return
|
|
17618
|
+
return invalid7();
|
|
17200
17619
|
const notes = {
|
|
17201
17620
|
anchors: result.items.map((item) => item.reference),
|
|
17202
17621
|
items: [],
|
|
@@ -17664,20 +18083,20 @@ var approveAsTask = /* @__PURE__ */ __name(async (store, id2) => {
|
|
|
17664
18083
|
|
|
17665
18084
|
// node_modules/.pnpm/@wirecat+cli-core@0.501.0_@wirecat+cli-base@0.67.0_commander@15.0.0_esbuild@0.28.2_type_e6af10c98f87b1454255e560646d3ddf/node_modules/@wirecat/cli-core/dist/services/stored-meeting-project-candidate-validation.js
|
|
17666
18085
|
var storedCandidateRequest = /* @__PURE__ */ __name((reference, accountId, options) => {
|
|
17667
|
-
const
|
|
18086
|
+
const invalid8 = /* @__PURE__ */ __name((field) => {
|
|
17668
18087
|
throw new CliError("validation_error", `invalid stored project candidate ${field}`);
|
|
17669
18088
|
}, "invalid");
|
|
17670
18089
|
if (!options || typeof options !== "object" || Array.isArray(options))
|
|
17671
|
-
|
|
18090
|
+
invalid8("options");
|
|
17672
18091
|
const allowed = ["limit", "cues", "bytes", "maxReadBytes", "after", "afterTranscriptId", "signal"];
|
|
17673
18092
|
for (const key of Object.keys(options))
|
|
17674
18093
|
if (!allowed.includes(key))
|
|
17675
|
-
|
|
18094
|
+
invalid8(key);
|
|
17676
18095
|
if (typeof reference !== "string" || reference.length > 200)
|
|
17677
|
-
|
|
18096
|
+
invalid8("reference");
|
|
17678
18097
|
const parsed = parseMeetingReference(reference);
|
|
17679
18098
|
if (parsed.accountId !== accountId || parsed.transcriptId !== void 0 || formatMeetingReference(parsed) !== reference)
|
|
17680
|
-
|
|
18099
|
+
invalid8("reference");
|
|
17681
18100
|
const limits = {
|
|
17682
18101
|
limit: options.limit ?? 10,
|
|
17683
18102
|
cues: options.cues ?? 20,
|
|
@@ -17687,20 +18106,20 @@ var storedCandidateRequest = /* @__PURE__ */ __name((reference, accountId, optio
|
|
|
17687
18106
|
for (const [key, value] of Object.entries(limits)) {
|
|
17688
18107
|
const max = key === "limit" ? 10 : key === "cues" ? 100 : 65536;
|
|
17689
18108
|
if (!Number.isSafeInteger(value) || value < (key === "bytes" ? 2048 : 1) || value > max)
|
|
17690
|
-
|
|
18109
|
+
invalid8(key);
|
|
17691
18110
|
}
|
|
17692
18111
|
const { after, afterTranscriptId, signal } = options;
|
|
17693
18112
|
if (signal !== void 0 && !(signal instanceof AbortSignal))
|
|
17694
|
-
|
|
18113
|
+
invalid8("signal");
|
|
17695
18114
|
if (after !== void 0) {
|
|
17696
18115
|
if (typeof after !== "string" || after.length > 200)
|
|
17697
|
-
|
|
18116
|
+
invalid8("after");
|
|
17698
18117
|
const cursor = parseMeetingReference(after);
|
|
17699
18118
|
if (cursor.accountId !== accountId || cursor.meetingId !== parsed.meetingId || cursor.cuePosition === void 0 || formatMeetingReference(cursor) !== after)
|
|
17700
|
-
|
|
18119
|
+
invalid8("after");
|
|
17701
18120
|
}
|
|
17702
18121
|
if (afterTranscriptId !== void 0 && (!Number.isSafeInteger(afterTranscriptId) || afterTranscriptId < 1 || after !== void 0))
|
|
17703
|
-
|
|
18122
|
+
invalid8("afterTranscriptId");
|
|
17704
18123
|
return { reference, limits, after, afterTranscriptId, signal };
|
|
17705
18124
|
}, "storedCandidateRequest");
|
|
17706
18125
|
|
|
@@ -17844,6 +18263,10 @@ export {
|
|
|
17844
18263
|
storedDeps,
|
|
17845
18264
|
storeModeDeps,
|
|
17846
18265
|
storeOnlyDeps,
|
|
18266
|
+
isId,
|
|
18267
|
+
foldName,
|
|
18268
|
+
pickChat,
|
|
18269
|
+
pickPerson,
|
|
17847
18270
|
REGISTRIES,
|
|
17848
18271
|
registriesCover,
|
|
17849
18272
|
chatCoverage,
|
|
@@ -17933,6 +18356,7 @@ export {
|
|
|
17933
18356
|
reviewStart,
|
|
17934
18357
|
kindsOf,
|
|
17935
18358
|
inboxService,
|
|
18359
|
+
validateFormattedText,
|
|
17936
18360
|
pinLengthHelp,
|
|
17937
18361
|
pinDurationOf,
|
|
17938
18362
|
sendAsCheck,
|
|
@@ -17977,6 +18401,13 @@ export {
|
|
|
17977
18401
|
DELETE_AT_ONCE,
|
|
17978
18402
|
messagesService,
|
|
17979
18403
|
metadataService,
|
|
18404
|
+
describe,
|
|
18405
|
+
CHECK_READS,
|
|
18406
|
+
MAX_ACTIONS,
|
|
18407
|
+
defaultRules,
|
|
18408
|
+
RULE_KEYS,
|
|
18409
|
+
moderationPathFor,
|
|
18410
|
+
ModerationRules,
|
|
17980
18411
|
moderateWith,
|
|
17981
18412
|
moderationService,
|
|
17982
18413
|
CONTEXT_MESSAGES2 as CONTEXT_MESSAGES,
|