@wirecat/cli-core 0.705.0 → 0.707.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +77 -0
- package/dist/cli/bot/api.d.ts +8 -0
- package/dist/cli/bot/api.js +31 -3
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/list-query.d.ts +3 -1
- package/dist/cli/list-query.js +5 -2
- package/dist/cli/messenger/lacks.js +3 -0
- package/dist/cli/messenger/messages-delete-command.js +30 -25
- package/dist/cli/messenger/messages-edit-command.js +2 -0
- package/dist/cli/messenger/messages-scheduled-command.js +110 -4
- package/dist/cli/service-api.js +65 -27
- package/dist/cli/token-session.d.ts +4 -1
- package/dist/cli/token-session.js +6 -1
- package/dist/content/cli/index.d.ts +2 -2
- package/dist/content/cli/index.js +64 -54
- package/dist/content/manifest/writer.d.ts +4 -1
- package/dist/content/manifest/writer.js +15 -12
- package/dist/content/testing/index.d.ts +1 -0
- package/dist/content/testing/index.js +1 -0
- package/dist/content/testing/manifest-fake.d.ts +54 -0
- package/dist/content/testing/manifest-fake.js +426 -0
- package/dist/content/writer.d.ts +5 -0
- package/dist/content/writer.js +1 -4
- package/dist/content/writes.js +13 -7
- package/dist/entities/index.d.ts +8 -2
- package/dist/entities/index.js +4 -2
- package/dist/entities/message-change.d.ts +240 -0
- package/dist/entities/message-change.js +6 -0
- package/dist/kit/fake.d.ts +2 -2
- package/dist/kit/fake.js +21 -0
- package/dist/mcp/surface.js +6 -3
- package/dist/ports/messenger.d.ts +20 -1
- package/dist/sends/permissions.js +11 -1
- package/dist/services/messages.d.ts +31 -0
- package/dist/services/messages.js +62 -0
- package/package.json +2 -2
|
@@ -17,3 +17,243 @@ export declare const messageDeletion: v.StrictObjectSchema<{
|
|
|
17
17
|
readonly deleted: v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
|
|
18
18
|
readonly for_everyone: v.BooleanSchema<undefined>;
|
|
19
19
|
}, undefined>;
|
|
20
|
+
/** Scheduled ids, which are never the ids of sent messages. */
|
|
21
|
+
export declare const scheduledCancellation: v.StrictObjectSchema<{
|
|
22
|
+
readonly operation_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
23
|
+
readonly chat_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
24
|
+
readonly cancelled: v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
|
|
25
|
+
}, undefined>;
|
|
26
|
+
declare const scheduledSendEntries: {
|
|
27
|
+
operation_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
28
|
+
chat_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
29
|
+
sent: v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
|
|
30
|
+
messages: v.ArraySchema<v.StrictObjectSchema<{
|
|
31
|
+
readonly ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
32
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
33
|
+
readonly provider: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
34
|
+
readonly account: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
35
|
+
readonly chat_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
36
|
+
readonly chat_title: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
37
|
+
readonly sender_id: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
|
|
38
|
+
readonly sender_name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
39
|
+
readonly sender_username: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
40
|
+
readonly sender_is_chat: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
41
|
+
readonly sender_is_me: v.BooleanSchema<undefined>;
|
|
42
|
+
readonly mentions: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>, undefined>;
|
|
43
|
+
readonly timestamp: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>;
|
|
44
|
+
readonly edited_at: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>, undefined>;
|
|
45
|
+
readonly text: v.StringSchema<undefined>;
|
|
46
|
+
readonly transcript: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
47
|
+
readonly anchor: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
48
|
+
readonly excerpt: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
49
|
+
readonly matched_in: v.OptionalSchema<v.PicklistSchema<["text", "transcript", "filename", "file", "context", "picture"], undefined>, undefined>;
|
|
50
|
+
readonly score: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
51
|
+
readonly match: v.OptionalSchema<v.PicklistSchema<["words", "beginnings", "corrected"], undefined>, undefined>;
|
|
52
|
+
readonly corrections: v.OptionalSchema<v.ArraySchema<v.StrictObjectSchema<{
|
|
53
|
+
readonly from: v.StringSchema<undefined>;
|
|
54
|
+
readonly to: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
55
|
+
}, undefined>, undefined>, undefined>;
|
|
56
|
+
readonly found_in: v.OptionalSchema<v.PicklistSchema<["archive", "server", "both"], undefined>, undefined>;
|
|
57
|
+
readonly discovery: v.OptionalSchema<v.StrictObjectSchema<{
|
|
58
|
+
readonly coverage: v.NumberSchema<undefined>;
|
|
59
|
+
readonly matched_terms: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
60
|
+
readonly missing_terms: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
61
|
+
readonly parent: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
|
|
62
|
+
readonly found_by: v.OptionalSchema<v.ArraySchema<v.PicklistSchema<["words", "meaning"], undefined>, undefined>, undefined>;
|
|
63
|
+
readonly reranker_score: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
64
|
+
}, undefined>, undefined>;
|
|
65
|
+
readonly context: v.OptionalSchema<v.ArraySchema<v.StrictObjectSchema<{
|
|
66
|
+
readonly ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
67
|
+
readonly timestamp: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>;
|
|
68
|
+
readonly sender_name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
69
|
+
readonly text: v.StringSchema<undefined>;
|
|
70
|
+
}, undefined>, undefined>, undefined>;
|
|
71
|
+
readonly follow_ups: v.OptionalSchema<v.ArraySchema<v.StrictObjectSchema<{
|
|
72
|
+
readonly ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
73
|
+
readonly chat_title: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
74
|
+
readonly timestamp: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>;
|
|
75
|
+
readonly sender_name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
76
|
+
readonly excerpt: v.StringSchema<undefined>;
|
|
77
|
+
}, undefined>, undefined>, undefined>;
|
|
78
|
+
readonly outgoing: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
79
|
+
readonly attachments: v.ArraySchema<v.StrictObjectSchema<{
|
|
80
|
+
readonly message: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
|
|
81
|
+
readonly kind: v.StringSchema<undefined>;
|
|
82
|
+
readonly position: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
83
|
+
readonly url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
84
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
85
|
+
readonly title: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
86
|
+
readonly mime: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
87
|
+
readonly size: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
88
|
+
readonly width: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
89
|
+
readonly height: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
90
|
+
readonly duration: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
91
|
+
readonly text: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
92
|
+
readonly extraction: v.OptionalSchema<v.StrictObjectSchema<{
|
|
93
|
+
readonly origin: v.StringSchema<undefined>;
|
|
94
|
+
readonly extractor: v.StringSchema<undefined>;
|
|
95
|
+
readonly chars: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
96
|
+
readonly error: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
97
|
+
}, undefined>, undefined>;
|
|
98
|
+
readonly local_path: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
99
|
+
readonly contact: v.OptionalSchema<v.StrictObjectSchema<{
|
|
100
|
+
readonly name: v.StringSchema<undefined>;
|
|
101
|
+
readonly first_name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
102
|
+
readonly last_name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
103
|
+
readonly phone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
104
|
+
readonly user_id: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
|
|
105
|
+
}, undefined>, undefined>;
|
|
106
|
+
readonly buttons: v.OptionalSchema<v.ArraySchema<v.ArraySchema<v.StrictObjectSchema<{
|
|
107
|
+
readonly kind: v.PicklistSchema<["callback", "link", "message", "chat", "contact", "location", "app", "clipboard", "other"], undefined>;
|
|
108
|
+
readonly text: v.StringSchema<undefined>;
|
|
109
|
+
readonly url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
110
|
+
}, undefined>, undefined>, undefined>, undefined>;
|
|
111
|
+
}, undefined>, undefined>;
|
|
112
|
+
readonly reply_to: v.NullableSchema<v.StrictObjectSchema<{
|
|
113
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
114
|
+
readonly sender_id: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
|
|
115
|
+
readonly sender_name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
116
|
+
readonly timestamp: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>, undefined>;
|
|
117
|
+
readonly text: v.StringSchema<undefined>;
|
|
118
|
+
readonly attachments: v.ArraySchema<v.StrictObjectSchema<{
|
|
119
|
+
readonly message: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
|
|
120
|
+
readonly kind: v.StringSchema<undefined>;
|
|
121
|
+
readonly position: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
122
|
+
readonly url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
123
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
124
|
+
readonly title: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
125
|
+
readonly mime: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
126
|
+
readonly size: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
127
|
+
readonly width: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
128
|
+
readonly height: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
129
|
+
readonly duration: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
130
|
+
readonly text: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
131
|
+
readonly extraction: v.OptionalSchema<v.StrictObjectSchema<{
|
|
132
|
+
readonly origin: v.StringSchema<undefined>;
|
|
133
|
+
readonly extractor: v.StringSchema<undefined>;
|
|
134
|
+
readonly chars: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
135
|
+
readonly error: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
136
|
+
}, undefined>, undefined>;
|
|
137
|
+
readonly local_path: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
138
|
+
readonly contact: v.OptionalSchema<v.StrictObjectSchema<{
|
|
139
|
+
readonly name: v.StringSchema<undefined>;
|
|
140
|
+
readonly first_name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
141
|
+
readonly last_name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
142
|
+
readonly phone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
143
|
+
readonly user_id: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
|
|
144
|
+
}, undefined>, undefined>;
|
|
145
|
+
readonly buttons: v.OptionalSchema<v.ArraySchema<v.ArraySchema<v.StrictObjectSchema<{
|
|
146
|
+
readonly kind: v.PicklistSchema<["callback", "link", "message", "chat", "contact", "location", "app", "clipboard", "other"], undefined>;
|
|
147
|
+
readonly text: v.StringSchema<undefined>;
|
|
148
|
+
readonly url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
149
|
+
}, undefined>, undefined>, undefined>, undefined>;
|
|
150
|
+
}, undefined>, undefined>;
|
|
151
|
+
readonly outgoing: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
152
|
+
}, undefined>, undefined>;
|
|
153
|
+
readonly reply_to_id: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
|
|
154
|
+
readonly forwarded_from: v.NullableSchema<v.StrictObjectSchema<{
|
|
155
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
156
|
+
readonly sender_id: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
|
|
157
|
+
readonly sender_name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
158
|
+
readonly timestamp: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>, undefined>;
|
|
159
|
+
readonly text: v.StringSchema<undefined>;
|
|
160
|
+
readonly attachments: v.ArraySchema<v.StrictObjectSchema<{
|
|
161
|
+
readonly message: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
|
|
162
|
+
readonly kind: v.StringSchema<undefined>;
|
|
163
|
+
readonly position: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
164
|
+
readonly url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
165
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
166
|
+
readonly title: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
167
|
+
readonly mime: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
168
|
+
readonly size: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
169
|
+
readonly width: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
170
|
+
readonly height: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
171
|
+
readonly duration: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
172
|
+
readonly text: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
173
|
+
readonly extraction: v.OptionalSchema<v.StrictObjectSchema<{
|
|
174
|
+
readonly origin: v.StringSchema<undefined>;
|
|
175
|
+
readonly extractor: v.StringSchema<undefined>;
|
|
176
|
+
readonly chars: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
177
|
+
readonly error: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
178
|
+
}, undefined>, undefined>;
|
|
179
|
+
readonly local_path: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
180
|
+
readonly contact: v.OptionalSchema<v.StrictObjectSchema<{
|
|
181
|
+
readonly name: v.StringSchema<undefined>;
|
|
182
|
+
readonly first_name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
183
|
+
readonly last_name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
184
|
+
readonly phone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
185
|
+
readonly user_id: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
|
|
186
|
+
}, undefined>, undefined>;
|
|
187
|
+
readonly buttons: v.OptionalSchema<v.ArraySchema<v.ArraySchema<v.StrictObjectSchema<{
|
|
188
|
+
readonly kind: v.PicklistSchema<["callback", "link", "message", "chat", "contact", "location", "app", "clipboard", "other"], undefined>;
|
|
189
|
+
readonly text: v.StringSchema<undefined>;
|
|
190
|
+
readonly url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
191
|
+
}, undefined>, undefined>, undefined>, undefined>;
|
|
192
|
+
}, undefined>, undefined>;
|
|
193
|
+
readonly outgoing: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
194
|
+
}, undefined>, undefined>;
|
|
195
|
+
readonly thread_id: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
|
|
196
|
+
readonly thread_root_id: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
|
|
197
|
+
readonly reactions: v.OptionalSchema<v.NullableSchema<v.StrictObjectSchema<{
|
|
198
|
+
readonly counts: v.ArraySchema<v.StrictObjectSchema<{
|
|
199
|
+
readonly reaction: v.StringSchema<undefined>;
|
|
200
|
+
readonly count: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
201
|
+
}, undefined>, undefined>;
|
|
202
|
+
readonly mine: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
203
|
+
readonly total: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
204
|
+
}, undefined>, undefined>, undefined>;
|
|
205
|
+
readonly scheduled_for: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>, undefined>;
|
|
206
|
+
readonly starred: v.OptionalSchema<v.LiteralSchema<true, undefined>, undefined>;
|
|
207
|
+
readonly delivery: v.OptionalSchema<v.PicklistSchema<["delivered", "read"], undefined>, undefined>;
|
|
208
|
+
readonly email: v.OptionalSchema<v.StrictObjectSchema<{
|
|
209
|
+
readonly subject: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
210
|
+
readonly from: v.NullableSchema<v.StrictObjectSchema<{
|
|
211
|
+
readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
212
|
+
readonly address: v.StringSchema<undefined>;
|
|
213
|
+
readonly ref: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
|
|
214
|
+
}, undefined>, undefined>;
|
|
215
|
+
readonly to: v.ArraySchema<v.StrictObjectSchema<{
|
|
216
|
+
readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
217
|
+
readonly address: v.StringSchema<undefined>;
|
|
218
|
+
readonly ref: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
|
|
219
|
+
}, undefined>, undefined>;
|
|
220
|
+
readonly cc: v.ArraySchema<v.StrictObjectSchema<{
|
|
221
|
+
readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
222
|
+
readonly address: v.StringSchema<undefined>;
|
|
223
|
+
readonly ref: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
|
|
224
|
+
}, undefined>, undefined>;
|
|
225
|
+
readonly bcc: v.ArraySchema<v.StrictObjectSchema<{
|
|
226
|
+
readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
227
|
+
readonly address: v.StringSchema<undefined>;
|
|
228
|
+
readonly ref: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
|
|
229
|
+
}, undefined>, undefined>;
|
|
230
|
+
readonly reply_addresses: v.ArraySchema<v.StrictObjectSchema<{
|
|
231
|
+
readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
232
|
+
readonly address: v.StringSchema<undefined>;
|
|
233
|
+
readonly ref: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
|
|
234
|
+
}, undefined>, undefined>;
|
|
235
|
+
readonly labels: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
236
|
+
readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
237
|
+
readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
238
|
+
readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
239
|
+
readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
|
|
240
|
+
readonly score: v.NumberSchema<undefined>;
|
|
241
|
+
readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
242
|
+
readonly demoted: v.OptionalSchema<v.LiteralSchema<true, undefined>, undefined>;
|
|
243
|
+
}, undefined>, undefined>;
|
|
244
|
+
readonly bulk: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
245
|
+
readonly list_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
246
|
+
readonly rule_id: v.OptionalSchema<v.NullableSchema<v.NumberSchema<undefined>, undefined>, undefined>;
|
|
247
|
+
readonly fingerprint: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
|
|
248
|
+
readonly new_sender: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
249
|
+
readonly sender_identities: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
250
|
+
}, undefined>, undefined>;
|
|
251
|
+
readonly provider_metadata: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
|
|
252
|
+
}, undefined>, undefined>;
|
|
253
|
+
};
|
|
254
|
+
type ScheduledSendEntriesOf = typeof scheduledSendEntries;
|
|
255
|
+
export interface ScheduledSendEntries extends ScheduledSendEntriesOf {
|
|
256
|
+
}
|
|
257
|
+
/** `sent` holds the scheduled ids; `messages` the messages as sent, with their new ids. */
|
|
258
|
+
export declare const scheduledSend: v.StrictObjectSchema<ScheduledSendEntries, undefined>;
|
|
259
|
+
export {};
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
import { id } from "./fields.js";
|
|
3
|
+
import { message } from "./message.js";
|
|
3
4
|
const operated = { operation_id: id, chat_id: id };
|
|
4
5
|
export const messagePin = v.strictObject({ ...operated, message_id: id, pinned: v.boolean() });
|
|
5
6
|
export const messageStar = v.strictObject({ ...operated, message_id: id, starred: v.boolean() });
|
|
6
7
|
export const messageDeletion = v.strictObject({ ...operated, deleted: v.array(id), for_everyone: v.boolean() });
|
|
8
|
+
/** Scheduled ids, which are never the ids of sent messages. */
|
|
9
|
+
export const scheduledCancellation = v.strictObject({ ...operated, cancelled: v.array(id) });
|
|
10
|
+
const scheduledSendEntries = { ...operated, sent: v.array(id), messages: v.array(message) };
|
|
11
|
+
/** `sent` holds the scheduled ids; `messages` the messages as sent, with their new ids. */
|
|
12
|
+
export const scheduledSend = v.strictObject(scheduledSendEntries);
|
package/dist/kit/fake.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { AccountEditing, AccountTools, ChatFolders, ChatReading, ContactBook, GroupAdmin, GroupModeration, LiveUpdates, MessageEditing, MessageMedia, MessagePins, MessagePolls, MessageReactions, MessageStars, MessengerCore, PassiveUpdates, PushedHistory, ReadState, ScheduledMessages, ServerReads, TopicReadState } from "../ports/messenger.js";
|
|
1
|
+
import type { AccountEditing, AccountTools, ChatFolders, ChatReading, ContactBook, GroupAdmin, GroupModeration, LiveUpdates, MessageEditing, MessageMedia, MessagePins, MessagePolls, MessageReactions, MessageStars, MessengerCore, PassiveUpdates, PushedHistory, ReadState, ScheduledChanges, ScheduledMessages, ServerReads, TopicReadState } from "../ports/messenger.js";
|
|
2
2
|
import { type Seed } from "./seed.js";
|
|
3
3
|
/** Every group of the port, over memory. */
|
|
4
|
-
export type FakeAdapter = MessengerCore & ServerReads & ChatReading & MessageEditing & MessagePins & MessageStars & MessageReactions & ReadState & TopicReadState & MessagePolls & LiveUpdates & MessageMedia & ScheduledMessages & GroupModeration & AccountTools & GroupAdmin & ChatFolders & ContactBook & AccountEditing & Partial<PushedHistory> & Partial<PassiveUpdates>;
|
|
4
|
+
export type FakeAdapter = MessengerCore & ServerReads & ChatReading & MessageEditing & MessagePins & MessageStars & MessageReactions & ReadState & TopicReadState & MessagePolls & LiveUpdates & MessageMedia & ScheduledMessages & ScheduledChanges & GroupModeration & AccountTools & GroupAdmin & ChatFolders & ContactBook & AccountEditing & Partial<PushedHistory> & Partial<PassiveUpdates>;
|
|
5
5
|
export declare const fakeAdapter: (seed?: Seed, options?: {
|
|
6
6
|
feed?: boolean;
|
|
7
7
|
listen?: boolean;
|
package/dist/kit/fake.js
CHANGED
|
@@ -84,6 +84,12 @@ export const fakeAdapter = (seed = contractSeed(), options = {}) => {
|
|
|
84
84
|
return pickChat(reference, state.chats);
|
|
85
85
|
};
|
|
86
86
|
const messagesOf = (chatId) => state.messages.filter((message) => message.chatId === chatId);
|
|
87
|
+
const scheduledAt = (chatId, id) => {
|
|
88
|
+
const at = scheduled.findIndex((message) => message.chatId === chatId && message.id === id);
|
|
89
|
+
if (at === -1)
|
|
90
|
+
throw missing(`scheduled message ${id} in chat ${chatId}`);
|
|
91
|
+
return at;
|
|
92
|
+
};
|
|
87
93
|
const messageOf = (chatId, messageId) => {
|
|
88
94
|
const found = state.messages.find((message) => message.chatId === chatId && message.id === messageId);
|
|
89
95
|
if (!found)
|
|
@@ -360,6 +366,21 @@ export const fakeAdapter = (seed = contractSeed(), options = {}) => {
|
|
|
360
366
|
const chat = chatOf(reference);
|
|
361
367
|
return structuredClone(scheduled.filter((message) => message.chatId === chat.id));
|
|
362
368
|
},
|
|
369
|
+
cancelScheduled: async (chatId, ids) => {
|
|
370
|
+
for (const id of ids)
|
|
371
|
+
scheduled.splice(scheduledAt(chatId, id), 1);
|
|
372
|
+
},
|
|
373
|
+
editScheduled: async (chatId, id, { text, at }) => {
|
|
374
|
+
const message = scheduled[scheduledAt(chatId, id)];
|
|
375
|
+
if (text !== undefined)
|
|
376
|
+
message.text = text;
|
|
377
|
+
message.scheduledFor = at;
|
|
378
|
+
return structuredClone(message);
|
|
379
|
+
},
|
|
380
|
+
sendScheduled: async (chatId, ids) => ids.map((id) => {
|
|
381
|
+
const [waiting] = scheduled.splice(scheduledAt(chatId, id), 1);
|
|
382
|
+
return structuredClone(post(chatOf(chatId), waiting.text, { attachments: waiting.attachments }));
|
|
383
|
+
}),
|
|
363
384
|
members: async (reference, window) => {
|
|
364
385
|
const chat = chatOf(reference);
|
|
365
386
|
const ruling = admins.get(chat.id) ?? [];
|
package/dist/mcp/surface.js
CHANGED
|
@@ -80,7 +80,7 @@ export const search = (commands, query) => {
|
|
|
80
80
|
.filter((word) => word.length > 1 && !STOP_WORDS.has(word))
|
|
81
81
|
.map(stem)),
|
|
82
82
|
];
|
|
83
|
-
return all
|
|
83
|
+
return (all
|
|
84
84
|
.map((entry) => {
|
|
85
85
|
const fields = fieldsOf(entry[0], entry[1]);
|
|
86
86
|
const weights = words.map((word) => fields.reduce((best, [weight, known]) => (known.some((one) => sameWord(word, one)) ? Math.max(best, weight) : best), 0));
|
|
@@ -89,8 +89,11 @@ export const search = (commands, query) => {
|
|
|
89
89
|
return { entry, matched, rank: (exact ? 1000 : 0) + matched * 10 + weights.reduce((a, b) => a + b, 0) };
|
|
90
90
|
})
|
|
91
91
|
.filter(({ matched, rank }) => matched > 0 || rank >= 1000)
|
|
92
|
-
|
|
93
|
-
.
|
|
92
|
+
// A tie goes to the shorter name, which holds less the task did not ask for: `messages send` first.
|
|
93
|
+
.sort((a, b) => b.rank - a.rank ||
|
|
94
|
+
wordsOf(a.entry[0]).length - wordsOf(b.entry[0]).length ||
|
|
95
|
+
a.entry[0].localeCompare(b.entry[0]))
|
|
96
|
+
.map(({ entry }) => entry));
|
|
94
97
|
};
|
|
95
98
|
const nearest = (commands, asked) => {
|
|
96
99
|
const words = normal(asked).split(" ");
|
|
@@ -485,6 +485,25 @@ export interface ScheduledMessages {
|
|
|
485
485
|
/** Messages waiting to be sent later in a chat, soonest first, each with `scheduledFor`. */
|
|
486
486
|
scheduled(chat: string): Promise<Message[]>;
|
|
487
487
|
}
|
|
488
|
+
/**
|
|
489
|
+
* Changes to what `scheduled` lists. An id here is one `scheduled` gave: a scheduled message has ids of its own, and
|
|
490
|
+
* the same number in the chat's history is another, already sent message.
|
|
491
|
+
*/
|
|
492
|
+
export interface ScheduledChanges {
|
|
493
|
+
/** Takes them off the list unsent; nobody can get them back. */
|
|
494
|
+
cancelScheduled(chatId: Id, ids: Id[]): Promise<void>;
|
|
495
|
+
/**
|
|
496
|
+
* New text, a new time, or both; the answer is the message as it now waits. `at` is always given, the current time
|
|
497
|
+
* when only the text changes, as the messenger may take the id for a sent message's without it.
|
|
498
|
+
*/
|
|
499
|
+
editScheduled(chatId: Id, id: Id, change: {
|
|
500
|
+
text?: string;
|
|
501
|
+
formatting?: TextSpan[];
|
|
502
|
+
at: string;
|
|
503
|
+
}): Promise<Message>;
|
|
504
|
+
/** Sends them now; the answer is the messages as sent, with their new ids. */
|
|
505
|
+
sendScheduled(chatId: Id, ids: Id[]): Promise<Message[]>;
|
|
506
|
+
}
|
|
488
507
|
/** Who is in a group, who runs it, and who came and went. */
|
|
489
508
|
export interface GroupModeration {
|
|
490
509
|
/**
|
|
@@ -703,7 +722,7 @@ export interface AccountHealth {
|
|
|
703
722
|
* be held to all of it. A method added from now on goes into a group, never the core, and returns a
|
|
704
723
|
* promise: the wrappers time and pass it through without being told about it (`throughWrapper`).
|
|
705
724
|
*/
|
|
706
|
-
export interface MessengerAdapter extends MessengerCore, Partial<MarkdownFormatting>, Partial<HtmlFormatting>, Partial<ServerReads>, Partial<PersonProfiles>, Partial<ChatReading>, Partial<SenderSearch>, Partial<MessageSearch>, Partial<MessageEditing>, Partial<MessagePins>, Partial<MessageStars>, Partial<MessageReactions>, Partial<ReadState>, Partial<TopicReadState>, Partial<MessagePolls>, Partial<MessageButtons>, Partial<BotChats>, Partial<ThreadAddressing>, Partial<TopicHistory>, Partial<ForumControl>, Partial<TopicEditing>, Partial<LiveUpdates>, Partial<PassiveUpdates>, Partial<PushedHistory>, Partial<MessageMedia>, Partial<ScheduledMessages>, Partial<ChannelComments>, Partial<MessagePermalinks>, Partial<SenderIdentities>, Partial<GroupModeration>, Partial<AccountTools>, Partial<ProfilePhotos>, Partial<GroupAdmin>, Partial<JoinRequests>, Partial<InviteLinks>, Partial<ChatFolders>, Partial<ContactBook>, Partial<AccountEditing>, Partial<AccountRecords>, Partial<AccountSettings>, Partial<ChatDeletion>, Partial<AccountHealth>, Partial<OfficialStats> {
|
|
725
|
+
export interface MessengerAdapter extends MessengerCore, Partial<MarkdownFormatting>, Partial<HtmlFormatting>, Partial<ServerReads>, Partial<PersonProfiles>, Partial<ChatReading>, Partial<SenderSearch>, Partial<MessageSearch>, Partial<MessageEditing>, Partial<MessagePins>, Partial<MessageStars>, Partial<MessageReactions>, Partial<ReadState>, Partial<TopicReadState>, Partial<MessagePolls>, Partial<MessageButtons>, Partial<BotChats>, Partial<ThreadAddressing>, Partial<TopicHistory>, Partial<ForumControl>, Partial<TopicEditing>, Partial<LiveUpdates>, Partial<PassiveUpdates>, Partial<PushedHistory>, Partial<MessageMedia>, Partial<ScheduledMessages>, Partial<ScheduledChanges>, Partial<ChannelComments>, Partial<MessagePermalinks>, Partial<SenderIdentities>, Partial<GroupModeration>, Partial<AccountTools>, Partial<ProfilePhotos>, Partial<GroupAdmin>, Partial<JoinRequests>, Partial<InviteLinks>, Partial<ChatFolders>, Partial<ContactBook>, Partial<AccountEditing>, Partial<AccountRecords>, Partial<AccountSettings>, Partial<ChatDeletion>, Partial<AccountHealth>, Partial<OfficialStats> {
|
|
707
726
|
}
|
|
708
727
|
type Method = (...args: never[]) => unknown;
|
|
709
728
|
/**
|
|
@@ -2,7 +2,14 @@ import { CliError } from "@wirecat/cli-base";
|
|
|
2
2
|
/** What a profile may do with one command path — the standard's "Permissions". */
|
|
3
3
|
export const LEVELS = ["deny", "readonly", "ask", "allow"];
|
|
4
4
|
/** The deletions nobody gets back: the word that skips their question is `--allow-dangerous`, never `--yes`. */
|
|
5
|
-
const DANGEROUS = new Set([
|
|
5
|
+
const DANGEROUS = new Set([
|
|
6
|
+
"messages.delete",
|
|
7
|
+
"messages.scheduled.cancel",
|
|
8
|
+
"bot.messages.delete",
|
|
9
|
+
"topics.delete",
|
|
10
|
+
"chats.delete",
|
|
11
|
+
"chats.clear",
|
|
12
|
+
]);
|
|
6
13
|
/** Deleting has its own word for "yes": the flag a person has to mean, not a habit (max-cli `NEED-238`). */
|
|
7
14
|
export const skipFlagFor = (key) => DANGEROUS.has(key) ? "--allow-dangerous" : "--yes";
|
|
8
15
|
/** Only what cannot be undone asks; the tool is meant to work without questions (owner, NEED-460). */
|
|
@@ -268,6 +275,9 @@ const NAMED_WRITE_KEYS = [
|
|
|
268
275
|
"messages.sync-first",
|
|
269
276
|
"messages.server-search",
|
|
270
277
|
"messages.press",
|
|
278
|
+
"messages.scheduled.cancel",
|
|
279
|
+
"messages.scheduled.edit",
|
|
280
|
+
"messages.scheduled.send",
|
|
271
281
|
"chats.start",
|
|
272
282
|
"chats.app",
|
|
273
283
|
"stats.messages.counters.sync",
|
|
@@ -257,6 +257,37 @@ export interface MessagesService {
|
|
|
257
257
|
messages: string[];
|
|
258
258
|
forEveryone: boolean;
|
|
259
259
|
}): Promise<Operated<Deletion>>;
|
|
260
|
+
/**
|
|
261
|
+
* The scheduled messages by the ids `scheduled` lists, each checked against that list first: the same number in the
|
|
262
|
+
* chat's history is another message. Cancelling counts as deleting, sending now as sending.
|
|
263
|
+
*/
|
|
264
|
+
cancelScheduled(request: {
|
|
265
|
+
chat: string;
|
|
266
|
+
ids: string[];
|
|
267
|
+
}): Promise<Operated<{
|
|
268
|
+
chatId: Id;
|
|
269
|
+
cancelled: Id[];
|
|
270
|
+
}>>;
|
|
271
|
+
/** New text, a new time (`at`), or both. */
|
|
272
|
+
editScheduled(request: {
|
|
273
|
+
chat: string;
|
|
274
|
+
id: string;
|
|
275
|
+
text?: string;
|
|
276
|
+
markdown?: boolean;
|
|
277
|
+
html?: boolean;
|
|
278
|
+
at?: string;
|
|
279
|
+
}): Promise<Operated<{
|
|
280
|
+
message: Message;
|
|
281
|
+
scheduledFor: string;
|
|
282
|
+
}>>;
|
|
283
|
+
sendScheduled(request: {
|
|
284
|
+
chat: string;
|
|
285
|
+
ids: string[];
|
|
286
|
+
}): Promise<Operated<{
|
|
287
|
+
chatId: Id;
|
|
288
|
+
sent: Id[];
|
|
289
|
+
messages: Message[];
|
|
290
|
+
}>>;
|
|
260
291
|
/** Guarded against the chat it goes to: that is where somebody new reads it. */
|
|
261
292
|
forward(target: MessageTarget & {
|
|
262
293
|
to: string;
|
|
@@ -22,6 +22,10 @@ import { searchServer, sourceKey, } from "./server-search.js";
|
|
|
22
22
|
import { readThreadContext, threadBounds } from "./thread-context.js";
|
|
23
23
|
/** max-cli's: many at once is what a ban for automation looks like. */
|
|
24
24
|
export const DELETE_AT_ONCE = 10;
|
|
25
|
+
const atOnce = (ids) => {
|
|
26
|
+
if (ids.length > DELETE_AT_ONCE)
|
|
27
|
+
throw new CliError("validation_error", `at most ${DELETE_AT_ONCE} messages at once, got ${ids.length}`);
|
|
28
|
+
};
|
|
25
29
|
/** Every write goes through the guard: asked before it goes, told after, on every outcome. */
|
|
26
30
|
/** Only a message with files says what can be linked of them. */
|
|
27
31
|
const filesOf = ({ attachments }) => {
|
|
@@ -69,6 +73,17 @@ export const messagesService = (deps) => {
|
|
|
69
73
|
})
|
|
70
74
|
.catch(() => undefined);
|
|
71
75
|
};
|
|
76
|
+
/** The chat and its scheduled messages by the ids asked for; an id it does not list is refused before any write. */
|
|
77
|
+
const waiting = async (connection, chat, ids) => {
|
|
78
|
+
const list = capability(connection, "scheduled", "list scheduled messages");
|
|
79
|
+
const { id: chatId } = await connection.resolve(chat);
|
|
80
|
+
const queued = await list(chatId);
|
|
81
|
+
const unknown = ids.filter((id) => !queued.some((message) => message.id === id));
|
|
82
|
+
if (unknown.length > 0)
|
|
83
|
+
throw new CliError("not_found", `nothing scheduled in this chat has the id ${unknown.join(", ")} — a scheduled message has an id of ` +
|
|
84
|
+
`its own, not the one of a sent message; \`messages scheduled ${chat}\` lists them`, { sent: false });
|
|
85
|
+
return { chatId, found: ids.map((id) => queued.find((message) => message.id === id)) };
|
|
86
|
+
};
|
|
72
87
|
const pinning = async ({ chat, message }, pinned, asked, requested) => {
|
|
73
88
|
const allowed = deps.messenger.pinDurations;
|
|
74
89
|
if (requested !== undefined && !allowed?.includes(requested))
|
|
@@ -398,6 +413,53 @@ export const messagesService = (deps) => {
|
|
|
398
413
|
await guardedWrite(guard, { operationId, chatId, kind: "delete", count: messages.length, forEveryone }, () => remove(chatId, messages, { forEveryone }));
|
|
399
414
|
return { operationId, chatId, deleted: messages, forEveryone };
|
|
400
415
|
},
|
|
416
|
+
cancelScheduled: async ({ chat, ids }) => {
|
|
417
|
+
atOnce(ids);
|
|
418
|
+
const connection = await deps.connection();
|
|
419
|
+
const cancel = capability(connection, "cancelScheduled", "cancel a scheduled message");
|
|
420
|
+
const { chatId } = await waiting(connection, chat, ids);
|
|
421
|
+
const operationId = newOperationId();
|
|
422
|
+
await guardedWrite(guard, { operationId, chatId, kind: "delete", key: "messages.scheduled.cancel", count: ids.length }, () => cancel(chatId, ids));
|
|
423
|
+
return { operationId, chatId, cancelled: ids };
|
|
424
|
+
},
|
|
425
|
+
editScheduled: async ({ chat, id, text: typed, markdown, html, at }) => {
|
|
426
|
+
if (typed === undefined && at === undefined)
|
|
427
|
+
throw new CliError("validation_error", "nothing to change — give the new text, --at-time, or both");
|
|
428
|
+
const connection = await deps.connection();
|
|
429
|
+
const edit = capability(connection, "editScheduled", "edit a scheduled message");
|
|
430
|
+
const prepared = typed === undefined ? undefined : await formatted(connection, typed, { markdown, html });
|
|
431
|
+
const change = prepared && (deps.agentText ? visibleFormattedText(prepared) : prepared);
|
|
432
|
+
if (change !== undefined && change.text.trim() === "")
|
|
433
|
+
throw new CliError("validation_error", "no new text — the marks leave nothing");
|
|
434
|
+
const { chatId, found: [current], } = await waiting(connection, chat, [id]);
|
|
435
|
+
const scheduledFor = at ?? current?.scheduledFor ?? current?.timestamp;
|
|
436
|
+
if (scheduledFor === undefined)
|
|
437
|
+
throw new CliError("invalid_response", "the scheduled message has no time");
|
|
438
|
+
const operationId = newOperationId();
|
|
439
|
+
const message = await guardedWrite(guard, {
|
|
440
|
+
operationId,
|
|
441
|
+
chatId,
|
|
442
|
+
kind: "edit",
|
|
443
|
+
key: "messages.scheduled.edit",
|
|
444
|
+
messageId: id,
|
|
445
|
+
scheduledFor,
|
|
446
|
+
...(change === undefined ? {} : { length: change.text.length }),
|
|
447
|
+
}, () => edit(chatId, id, {
|
|
448
|
+
at: scheduledFor,
|
|
449
|
+
...(change === undefined ? {} : { text: change.text }),
|
|
450
|
+
...(change === undefined || change.spans.length === 0 ? {} : { formatting: change.spans }),
|
|
451
|
+
}));
|
|
452
|
+
return { operationId, message, scheduledFor };
|
|
453
|
+
},
|
|
454
|
+
sendScheduled: async ({ chat, ids }) => {
|
|
455
|
+
atOnce(ids);
|
|
456
|
+
const connection = await deps.connection();
|
|
457
|
+
const send = capability(connection, "sendScheduled", "send a scheduled message now");
|
|
458
|
+
const { chatId } = await waiting(connection, chat, ids);
|
|
459
|
+
const operationId = newOperationId();
|
|
460
|
+
const messages = await guardedWrite(guard, { operationId, chatId, kind: "message", key: "messages.scheduled.send", count: ids.length }, () => send(chatId, ids));
|
|
461
|
+
return { operationId, chatId, sent: ids, messages };
|
|
462
|
+
},
|
|
401
463
|
forward: async ({ chat, message, to, silent, sendId, sendAs, threadId: typedThread }) => {
|
|
402
464
|
const connection = await deps.connection();
|
|
403
465
|
const forward = capability(connection, "forward", "forward a message");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wirecat/cli-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.707.0",
|
|
4
4
|
"description": "The messenger-neutral half of a messaging CLI: domain model, message locators, rendering, name resolution, the SQLite seam, the command skeleton and shared read commands, the send guard, run records and the message store",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Viacheslav Ptsarev",
|
|
@@ -326,7 +326,7 @@
|
|
|
326
326
|
"@types/pngjs": "6.0.5",
|
|
327
327
|
"@types/ssh2": "1.15.5",
|
|
328
328
|
"@vitest/coverage-v8": "^5.0.5",
|
|
329
|
-
"@wirecat/cli-base": "0.
|
|
329
|
+
"@wirecat/cli-base": "0.123.0",
|
|
330
330
|
"@wirecat/cli-core-legacy-tags": "npm:@wirecat/cli-core@0.414.0",
|
|
331
331
|
"ajv": "8.17.1",
|
|
332
332
|
"commander": "15.0.0",
|