@nubemclaw/channel-telegram 1.2.2

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.
@@ -0,0 +1,593 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Telegram Bot API response envelope (Phase 13, ADR-0020 §4 — boundary
4
+ * validation on untrusted input). Every Bot API response wraps either
5
+ * a successful `result` or a structured failure with `error_code` +
6
+ * `description`. We validate the envelope at this boundary so the rest
7
+ * of the channel package consumes typed payloads, never raw JSON.
8
+ *
9
+ * Scope: F13 covers only `message` updates with `text`. Photos, voice,
10
+ * documents, stickers, edited messages, callback queries — all reach
11
+ * Telegram but are silently ignored by the polling adapter via
12
+ * `allowed_updates: ["message"]`. The schemas below model exactly what
13
+ * we need to forward through the agent and no more — narrower payloads
14
+ * = smaller attack surface for parser bugs and easier to evolve.
15
+ *
16
+ * `passthrough()` is deliberate on `Message` and `User`: Telegram adds
17
+ * fields between minor versions; we tolerate unknown keys (do not
18
+ * reject) so a Bot API minor bump does not break the channel, but we
19
+ * never propagate them outside this boundary.
20
+ */
21
+ export declare const TelegramUserSchema: z.ZodObject<{
22
+ id: z.ZodNumber;
23
+ is_bot: z.ZodBoolean;
24
+ first_name: z.ZodOptional<z.ZodString>;
25
+ username: z.ZodOptional<z.ZodString>;
26
+ language_code: z.ZodOptional<z.ZodString>;
27
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
28
+ id: z.ZodNumber;
29
+ is_bot: z.ZodBoolean;
30
+ first_name: z.ZodOptional<z.ZodString>;
31
+ username: z.ZodOptional<z.ZodString>;
32
+ language_code: z.ZodOptional<z.ZodString>;
33
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
34
+ id: z.ZodNumber;
35
+ is_bot: z.ZodBoolean;
36
+ first_name: z.ZodOptional<z.ZodString>;
37
+ username: z.ZodOptional<z.ZodString>;
38
+ language_code: z.ZodOptional<z.ZodString>;
39
+ }, z.ZodTypeAny, "passthrough">>;
40
+ export type TelegramUser = z.infer<typeof TelegramUserSchema>;
41
+ export declare const TelegramChatSchema: z.ZodObject<{
42
+ id: z.ZodNumber;
43
+ type: z.ZodEnum<["private", "group", "supergroup", "channel"]>;
44
+ title: z.ZodOptional<z.ZodString>;
45
+ username: z.ZodOptional<z.ZodString>;
46
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
47
+ id: z.ZodNumber;
48
+ type: z.ZodEnum<["private", "group", "supergroup", "channel"]>;
49
+ title: z.ZodOptional<z.ZodString>;
50
+ username: z.ZodOptional<z.ZodString>;
51
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
52
+ id: z.ZodNumber;
53
+ type: z.ZodEnum<["private", "group", "supergroup", "channel"]>;
54
+ title: z.ZodOptional<z.ZodString>;
55
+ username: z.ZodOptional<z.ZodString>;
56
+ }, z.ZodTypeAny, "passthrough">>;
57
+ export type TelegramChat = z.infer<typeof TelegramChatSchema>;
58
+ export declare const TelegramMessageSchema: z.ZodObject<{
59
+ message_id: z.ZodNumber;
60
+ date: z.ZodNumber;
61
+ chat: z.ZodObject<{
62
+ id: z.ZodNumber;
63
+ type: z.ZodEnum<["private", "group", "supergroup", "channel"]>;
64
+ title: z.ZodOptional<z.ZodString>;
65
+ username: z.ZodOptional<z.ZodString>;
66
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
67
+ id: z.ZodNumber;
68
+ type: z.ZodEnum<["private", "group", "supergroup", "channel"]>;
69
+ title: z.ZodOptional<z.ZodString>;
70
+ username: z.ZodOptional<z.ZodString>;
71
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
72
+ id: z.ZodNumber;
73
+ type: z.ZodEnum<["private", "group", "supergroup", "channel"]>;
74
+ title: z.ZodOptional<z.ZodString>;
75
+ username: z.ZodOptional<z.ZodString>;
76
+ }, z.ZodTypeAny, "passthrough">>;
77
+ from: z.ZodOptional<z.ZodObject<{
78
+ id: z.ZodNumber;
79
+ is_bot: z.ZodBoolean;
80
+ first_name: z.ZodOptional<z.ZodString>;
81
+ username: z.ZodOptional<z.ZodString>;
82
+ language_code: z.ZodOptional<z.ZodString>;
83
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
84
+ id: z.ZodNumber;
85
+ is_bot: z.ZodBoolean;
86
+ first_name: z.ZodOptional<z.ZodString>;
87
+ username: z.ZodOptional<z.ZodString>;
88
+ language_code: z.ZodOptional<z.ZodString>;
89
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
90
+ id: z.ZodNumber;
91
+ is_bot: z.ZodBoolean;
92
+ first_name: z.ZodOptional<z.ZodString>;
93
+ username: z.ZodOptional<z.ZodString>;
94
+ language_code: z.ZodOptional<z.ZodString>;
95
+ }, z.ZodTypeAny, "passthrough">>>;
96
+ text: z.ZodOptional<z.ZodString>;
97
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
98
+ message_id: z.ZodNumber;
99
+ date: z.ZodNumber;
100
+ chat: z.ZodObject<{
101
+ id: z.ZodNumber;
102
+ type: z.ZodEnum<["private", "group", "supergroup", "channel"]>;
103
+ title: z.ZodOptional<z.ZodString>;
104
+ username: z.ZodOptional<z.ZodString>;
105
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
106
+ id: z.ZodNumber;
107
+ type: z.ZodEnum<["private", "group", "supergroup", "channel"]>;
108
+ title: z.ZodOptional<z.ZodString>;
109
+ username: z.ZodOptional<z.ZodString>;
110
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
111
+ id: z.ZodNumber;
112
+ type: z.ZodEnum<["private", "group", "supergroup", "channel"]>;
113
+ title: z.ZodOptional<z.ZodString>;
114
+ username: z.ZodOptional<z.ZodString>;
115
+ }, z.ZodTypeAny, "passthrough">>;
116
+ from: z.ZodOptional<z.ZodObject<{
117
+ id: z.ZodNumber;
118
+ is_bot: z.ZodBoolean;
119
+ first_name: z.ZodOptional<z.ZodString>;
120
+ username: z.ZodOptional<z.ZodString>;
121
+ language_code: z.ZodOptional<z.ZodString>;
122
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
123
+ id: z.ZodNumber;
124
+ is_bot: z.ZodBoolean;
125
+ first_name: z.ZodOptional<z.ZodString>;
126
+ username: z.ZodOptional<z.ZodString>;
127
+ language_code: z.ZodOptional<z.ZodString>;
128
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
129
+ id: z.ZodNumber;
130
+ is_bot: z.ZodBoolean;
131
+ first_name: z.ZodOptional<z.ZodString>;
132
+ username: z.ZodOptional<z.ZodString>;
133
+ language_code: z.ZodOptional<z.ZodString>;
134
+ }, z.ZodTypeAny, "passthrough">>>;
135
+ text: z.ZodOptional<z.ZodString>;
136
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
137
+ message_id: z.ZodNumber;
138
+ date: z.ZodNumber;
139
+ chat: z.ZodObject<{
140
+ id: z.ZodNumber;
141
+ type: z.ZodEnum<["private", "group", "supergroup", "channel"]>;
142
+ title: z.ZodOptional<z.ZodString>;
143
+ username: z.ZodOptional<z.ZodString>;
144
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
145
+ id: z.ZodNumber;
146
+ type: z.ZodEnum<["private", "group", "supergroup", "channel"]>;
147
+ title: z.ZodOptional<z.ZodString>;
148
+ username: z.ZodOptional<z.ZodString>;
149
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
150
+ id: z.ZodNumber;
151
+ type: z.ZodEnum<["private", "group", "supergroup", "channel"]>;
152
+ title: z.ZodOptional<z.ZodString>;
153
+ username: z.ZodOptional<z.ZodString>;
154
+ }, z.ZodTypeAny, "passthrough">>;
155
+ from: z.ZodOptional<z.ZodObject<{
156
+ id: z.ZodNumber;
157
+ is_bot: z.ZodBoolean;
158
+ first_name: z.ZodOptional<z.ZodString>;
159
+ username: z.ZodOptional<z.ZodString>;
160
+ language_code: z.ZodOptional<z.ZodString>;
161
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
162
+ id: z.ZodNumber;
163
+ is_bot: z.ZodBoolean;
164
+ first_name: z.ZodOptional<z.ZodString>;
165
+ username: z.ZodOptional<z.ZodString>;
166
+ language_code: z.ZodOptional<z.ZodString>;
167
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
168
+ id: z.ZodNumber;
169
+ is_bot: z.ZodBoolean;
170
+ first_name: z.ZodOptional<z.ZodString>;
171
+ username: z.ZodOptional<z.ZodString>;
172
+ language_code: z.ZodOptional<z.ZodString>;
173
+ }, z.ZodTypeAny, "passthrough">>>;
174
+ text: z.ZodOptional<z.ZodString>;
175
+ }, z.ZodTypeAny, "passthrough">>;
176
+ export type TelegramMessage = z.infer<typeof TelegramMessageSchema>;
177
+ /**
178
+ * Update wraps either a new `message` or fields F13 deliberately
179
+ * ignores (edited_message, callback_query, etc.). `allowed_updates`
180
+ * on `getUpdates`/`setWebhook` filters those at Telegram's side, so
181
+ * in practice only `update_id + message` reach us; the schema models
182
+ * the F13 happy path and tolerates extra keys via passthrough.
183
+ */
184
+ export declare const TelegramUpdateSchema: z.ZodObject<{
185
+ update_id: z.ZodNumber;
186
+ message: z.ZodOptional<z.ZodObject<{
187
+ message_id: z.ZodNumber;
188
+ date: z.ZodNumber;
189
+ chat: z.ZodObject<{
190
+ id: z.ZodNumber;
191
+ type: z.ZodEnum<["private", "group", "supergroup", "channel"]>;
192
+ title: z.ZodOptional<z.ZodString>;
193
+ username: z.ZodOptional<z.ZodString>;
194
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
195
+ id: z.ZodNumber;
196
+ type: z.ZodEnum<["private", "group", "supergroup", "channel"]>;
197
+ title: z.ZodOptional<z.ZodString>;
198
+ username: z.ZodOptional<z.ZodString>;
199
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
200
+ id: z.ZodNumber;
201
+ type: z.ZodEnum<["private", "group", "supergroup", "channel"]>;
202
+ title: z.ZodOptional<z.ZodString>;
203
+ username: z.ZodOptional<z.ZodString>;
204
+ }, z.ZodTypeAny, "passthrough">>;
205
+ from: z.ZodOptional<z.ZodObject<{
206
+ id: z.ZodNumber;
207
+ is_bot: z.ZodBoolean;
208
+ first_name: z.ZodOptional<z.ZodString>;
209
+ username: z.ZodOptional<z.ZodString>;
210
+ language_code: z.ZodOptional<z.ZodString>;
211
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
212
+ id: z.ZodNumber;
213
+ is_bot: z.ZodBoolean;
214
+ first_name: z.ZodOptional<z.ZodString>;
215
+ username: z.ZodOptional<z.ZodString>;
216
+ language_code: z.ZodOptional<z.ZodString>;
217
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
218
+ id: z.ZodNumber;
219
+ is_bot: z.ZodBoolean;
220
+ first_name: z.ZodOptional<z.ZodString>;
221
+ username: z.ZodOptional<z.ZodString>;
222
+ language_code: z.ZodOptional<z.ZodString>;
223
+ }, z.ZodTypeAny, "passthrough">>>;
224
+ text: z.ZodOptional<z.ZodString>;
225
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
226
+ message_id: z.ZodNumber;
227
+ date: z.ZodNumber;
228
+ chat: z.ZodObject<{
229
+ id: z.ZodNumber;
230
+ type: z.ZodEnum<["private", "group", "supergroup", "channel"]>;
231
+ title: z.ZodOptional<z.ZodString>;
232
+ username: z.ZodOptional<z.ZodString>;
233
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
234
+ id: z.ZodNumber;
235
+ type: z.ZodEnum<["private", "group", "supergroup", "channel"]>;
236
+ title: z.ZodOptional<z.ZodString>;
237
+ username: z.ZodOptional<z.ZodString>;
238
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
239
+ id: z.ZodNumber;
240
+ type: z.ZodEnum<["private", "group", "supergroup", "channel"]>;
241
+ title: z.ZodOptional<z.ZodString>;
242
+ username: z.ZodOptional<z.ZodString>;
243
+ }, z.ZodTypeAny, "passthrough">>;
244
+ from: z.ZodOptional<z.ZodObject<{
245
+ id: z.ZodNumber;
246
+ is_bot: z.ZodBoolean;
247
+ first_name: z.ZodOptional<z.ZodString>;
248
+ username: z.ZodOptional<z.ZodString>;
249
+ language_code: z.ZodOptional<z.ZodString>;
250
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
251
+ id: z.ZodNumber;
252
+ is_bot: z.ZodBoolean;
253
+ first_name: z.ZodOptional<z.ZodString>;
254
+ username: z.ZodOptional<z.ZodString>;
255
+ language_code: z.ZodOptional<z.ZodString>;
256
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
257
+ id: z.ZodNumber;
258
+ is_bot: z.ZodBoolean;
259
+ first_name: z.ZodOptional<z.ZodString>;
260
+ username: z.ZodOptional<z.ZodString>;
261
+ language_code: z.ZodOptional<z.ZodString>;
262
+ }, z.ZodTypeAny, "passthrough">>>;
263
+ text: z.ZodOptional<z.ZodString>;
264
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
265
+ message_id: z.ZodNumber;
266
+ date: z.ZodNumber;
267
+ chat: z.ZodObject<{
268
+ id: z.ZodNumber;
269
+ type: z.ZodEnum<["private", "group", "supergroup", "channel"]>;
270
+ title: z.ZodOptional<z.ZodString>;
271
+ username: z.ZodOptional<z.ZodString>;
272
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
273
+ id: z.ZodNumber;
274
+ type: z.ZodEnum<["private", "group", "supergroup", "channel"]>;
275
+ title: z.ZodOptional<z.ZodString>;
276
+ username: z.ZodOptional<z.ZodString>;
277
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
278
+ id: z.ZodNumber;
279
+ type: z.ZodEnum<["private", "group", "supergroup", "channel"]>;
280
+ title: z.ZodOptional<z.ZodString>;
281
+ username: z.ZodOptional<z.ZodString>;
282
+ }, z.ZodTypeAny, "passthrough">>;
283
+ from: z.ZodOptional<z.ZodObject<{
284
+ id: z.ZodNumber;
285
+ is_bot: z.ZodBoolean;
286
+ first_name: z.ZodOptional<z.ZodString>;
287
+ username: z.ZodOptional<z.ZodString>;
288
+ language_code: z.ZodOptional<z.ZodString>;
289
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
290
+ id: z.ZodNumber;
291
+ is_bot: z.ZodBoolean;
292
+ first_name: z.ZodOptional<z.ZodString>;
293
+ username: z.ZodOptional<z.ZodString>;
294
+ language_code: z.ZodOptional<z.ZodString>;
295
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
296
+ id: z.ZodNumber;
297
+ is_bot: z.ZodBoolean;
298
+ first_name: z.ZodOptional<z.ZodString>;
299
+ username: z.ZodOptional<z.ZodString>;
300
+ language_code: z.ZodOptional<z.ZodString>;
301
+ }, z.ZodTypeAny, "passthrough">>>;
302
+ text: z.ZodOptional<z.ZodString>;
303
+ }, z.ZodTypeAny, "passthrough">>>;
304
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
305
+ update_id: z.ZodNumber;
306
+ message: z.ZodOptional<z.ZodObject<{
307
+ message_id: z.ZodNumber;
308
+ date: z.ZodNumber;
309
+ chat: z.ZodObject<{
310
+ id: z.ZodNumber;
311
+ type: z.ZodEnum<["private", "group", "supergroup", "channel"]>;
312
+ title: z.ZodOptional<z.ZodString>;
313
+ username: z.ZodOptional<z.ZodString>;
314
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
315
+ id: z.ZodNumber;
316
+ type: z.ZodEnum<["private", "group", "supergroup", "channel"]>;
317
+ title: z.ZodOptional<z.ZodString>;
318
+ username: z.ZodOptional<z.ZodString>;
319
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
320
+ id: z.ZodNumber;
321
+ type: z.ZodEnum<["private", "group", "supergroup", "channel"]>;
322
+ title: z.ZodOptional<z.ZodString>;
323
+ username: z.ZodOptional<z.ZodString>;
324
+ }, z.ZodTypeAny, "passthrough">>;
325
+ from: z.ZodOptional<z.ZodObject<{
326
+ id: z.ZodNumber;
327
+ is_bot: z.ZodBoolean;
328
+ first_name: z.ZodOptional<z.ZodString>;
329
+ username: z.ZodOptional<z.ZodString>;
330
+ language_code: z.ZodOptional<z.ZodString>;
331
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
332
+ id: z.ZodNumber;
333
+ is_bot: z.ZodBoolean;
334
+ first_name: z.ZodOptional<z.ZodString>;
335
+ username: z.ZodOptional<z.ZodString>;
336
+ language_code: z.ZodOptional<z.ZodString>;
337
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
338
+ id: z.ZodNumber;
339
+ is_bot: z.ZodBoolean;
340
+ first_name: z.ZodOptional<z.ZodString>;
341
+ username: z.ZodOptional<z.ZodString>;
342
+ language_code: z.ZodOptional<z.ZodString>;
343
+ }, z.ZodTypeAny, "passthrough">>>;
344
+ text: z.ZodOptional<z.ZodString>;
345
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
346
+ message_id: z.ZodNumber;
347
+ date: z.ZodNumber;
348
+ chat: z.ZodObject<{
349
+ id: z.ZodNumber;
350
+ type: z.ZodEnum<["private", "group", "supergroup", "channel"]>;
351
+ title: z.ZodOptional<z.ZodString>;
352
+ username: z.ZodOptional<z.ZodString>;
353
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
354
+ id: z.ZodNumber;
355
+ type: z.ZodEnum<["private", "group", "supergroup", "channel"]>;
356
+ title: z.ZodOptional<z.ZodString>;
357
+ username: z.ZodOptional<z.ZodString>;
358
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
359
+ id: z.ZodNumber;
360
+ type: z.ZodEnum<["private", "group", "supergroup", "channel"]>;
361
+ title: z.ZodOptional<z.ZodString>;
362
+ username: z.ZodOptional<z.ZodString>;
363
+ }, z.ZodTypeAny, "passthrough">>;
364
+ from: z.ZodOptional<z.ZodObject<{
365
+ id: z.ZodNumber;
366
+ is_bot: z.ZodBoolean;
367
+ first_name: z.ZodOptional<z.ZodString>;
368
+ username: z.ZodOptional<z.ZodString>;
369
+ language_code: z.ZodOptional<z.ZodString>;
370
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
371
+ id: z.ZodNumber;
372
+ is_bot: z.ZodBoolean;
373
+ first_name: z.ZodOptional<z.ZodString>;
374
+ username: z.ZodOptional<z.ZodString>;
375
+ language_code: z.ZodOptional<z.ZodString>;
376
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
377
+ id: z.ZodNumber;
378
+ is_bot: z.ZodBoolean;
379
+ first_name: z.ZodOptional<z.ZodString>;
380
+ username: z.ZodOptional<z.ZodString>;
381
+ language_code: z.ZodOptional<z.ZodString>;
382
+ }, z.ZodTypeAny, "passthrough">>>;
383
+ text: z.ZodOptional<z.ZodString>;
384
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
385
+ message_id: z.ZodNumber;
386
+ date: z.ZodNumber;
387
+ chat: z.ZodObject<{
388
+ id: z.ZodNumber;
389
+ type: z.ZodEnum<["private", "group", "supergroup", "channel"]>;
390
+ title: z.ZodOptional<z.ZodString>;
391
+ username: z.ZodOptional<z.ZodString>;
392
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
393
+ id: z.ZodNumber;
394
+ type: z.ZodEnum<["private", "group", "supergroup", "channel"]>;
395
+ title: z.ZodOptional<z.ZodString>;
396
+ username: z.ZodOptional<z.ZodString>;
397
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
398
+ id: z.ZodNumber;
399
+ type: z.ZodEnum<["private", "group", "supergroup", "channel"]>;
400
+ title: z.ZodOptional<z.ZodString>;
401
+ username: z.ZodOptional<z.ZodString>;
402
+ }, z.ZodTypeAny, "passthrough">>;
403
+ from: z.ZodOptional<z.ZodObject<{
404
+ id: z.ZodNumber;
405
+ is_bot: z.ZodBoolean;
406
+ first_name: z.ZodOptional<z.ZodString>;
407
+ username: z.ZodOptional<z.ZodString>;
408
+ language_code: z.ZodOptional<z.ZodString>;
409
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
410
+ id: z.ZodNumber;
411
+ is_bot: z.ZodBoolean;
412
+ first_name: z.ZodOptional<z.ZodString>;
413
+ username: z.ZodOptional<z.ZodString>;
414
+ language_code: z.ZodOptional<z.ZodString>;
415
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
416
+ id: z.ZodNumber;
417
+ is_bot: z.ZodBoolean;
418
+ first_name: z.ZodOptional<z.ZodString>;
419
+ username: z.ZodOptional<z.ZodString>;
420
+ language_code: z.ZodOptional<z.ZodString>;
421
+ }, z.ZodTypeAny, "passthrough">>>;
422
+ text: z.ZodOptional<z.ZodString>;
423
+ }, z.ZodTypeAny, "passthrough">>>;
424
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
425
+ update_id: z.ZodNumber;
426
+ message: z.ZodOptional<z.ZodObject<{
427
+ message_id: z.ZodNumber;
428
+ date: z.ZodNumber;
429
+ chat: z.ZodObject<{
430
+ id: z.ZodNumber;
431
+ type: z.ZodEnum<["private", "group", "supergroup", "channel"]>;
432
+ title: z.ZodOptional<z.ZodString>;
433
+ username: z.ZodOptional<z.ZodString>;
434
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
435
+ id: z.ZodNumber;
436
+ type: z.ZodEnum<["private", "group", "supergroup", "channel"]>;
437
+ title: z.ZodOptional<z.ZodString>;
438
+ username: z.ZodOptional<z.ZodString>;
439
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
440
+ id: z.ZodNumber;
441
+ type: z.ZodEnum<["private", "group", "supergroup", "channel"]>;
442
+ title: z.ZodOptional<z.ZodString>;
443
+ username: z.ZodOptional<z.ZodString>;
444
+ }, z.ZodTypeAny, "passthrough">>;
445
+ from: z.ZodOptional<z.ZodObject<{
446
+ id: z.ZodNumber;
447
+ is_bot: z.ZodBoolean;
448
+ first_name: z.ZodOptional<z.ZodString>;
449
+ username: z.ZodOptional<z.ZodString>;
450
+ language_code: z.ZodOptional<z.ZodString>;
451
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
452
+ id: z.ZodNumber;
453
+ is_bot: z.ZodBoolean;
454
+ first_name: z.ZodOptional<z.ZodString>;
455
+ username: z.ZodOptional<z.ZodString>;
456
+ language_code: z.ZodOptional<z.ZodString>;
457
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
458
+ id: z.ZodNumber;
459
+ is_bot: z.ZodBoolean;
460
+ first_name: z.ZodOptional<z.ZodString>;
461
+ username: z.ZodOptional<z.ZodString>;
462
+ language_code: z.ZodOptional<z.ZodString>;
463
+ }, z.ZodTypeAny, "passthrough">>>;
464
+ text: z.ZodOptional<z.ZodString>;
465
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
466
+ message_id: z.ZodNumber;
467
+ date: z.ZodNumber;
468
+ chat: z.ZodObject<{
469
+ id: z.ZodNumber;
470
+ type: z.ZodEnum<["private", "group", "supergroup", "channel"]>;
471
+ title: z.ZodOptional<z.ZodString>;
472
+ username: z.ZodOptional<z.ZodString>;
473
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
474
+ id: z.ZodNumber;
475
+ type: z.ZodEnum<["private", "group", "supergroup", "channel"]>;
476
+ title: z.ZodOptional<z.ZodString>;
477
+ username: z.ZodOptional<z.ZodString>;
478
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
479
+ id: z.ZodNumber;
480
+ type: z.ZodEnum<["private", "group", "supergroup", "channel"]>;
481
+ title: z.ZodOptional<z.ZodString>;
482
+ username: z.ZodOptional<z.ZodString>;
483
+ }, z.ZodTypeAny, "passthrough">>;
484
+ from: z.ZodOptional<z.ZodObject<{
485
+ id: z.ZodNumber;
486
+ is_bot: z.ZodBoolean;
487
+ first_name: z.ZodOptional<z.ZodString>;
488
+ username: z.ZodOptional<z.ZodString>;
489
+ language_code: z.ZodOptional<z.ZodString>;
490
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
491
+ id: z.ZodNumber;
492
+ is_bot: z.ZodBoolean;
493
+ first_name: z.ZodOptional<z.ZodString>;
494
+ username: z.ZodOptional<z.ZodString>;
495
+ language_code: z.ZodOptional<z.ZodString>;
496
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
497
+ id: z.ZodNumber;
498
+ is_bot: z.ZodBoolean;
499
+ first_name: z.ZodOptional<z.ZodString>;
500
+ username: z.ZodOptional<z.ZodString>;
501
+ language_code: z.ZodOptional<z.ZodString>;
502
+ }, z.ZodTypeAny, "passthrough">>>;
503
+ text: z.ZodOptional<z.ZodString>;
504
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
505
+ message_id: z.ZodNumber;
506
+ date: z.ZodNumber;
507
+ chat: z.ZodObject<{
508
+ id: z.ZodNumber;
509
+ type: z.ZodEnum<["private", "group", "supergroup", "channel"]>;
510
+ title: z.ZodOptional<z.ZodString>;
511
+ username: z.ZodOptional<z.ZodString>;
512
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
513
+ id: z.ZodNumber;
514
+ type: z.ZodEnum<["private", "group", "supergroup", "channel"]>;
515
+ title: z.ZodOptional<z.ZodString>;
516
+ username: z.ZodOptional<z.ZodString>;
517
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
518
+ id: z.ZodNumber;
519
+ type: z.ZodEnum<["private", "group", "supergroup", "channel"]>;
520
+ title: z.ZodOptional<z.ZodString>;
521
+ username: z.ZodOptional<z.ZodString>;
522
+ }, z.ZodTypeAny, "passthrough">>;
523
+ from: z.ZodOptional<z.ZodObject<{
524
+ id: z.ZodNumber;
525
+ is_bot: z.ZodBoolean;
526
+ first_name: z.ZodOptional<z.ZodString>;
527
+ username: z.ZodOptional<z.ZodString>;
528
+ language_code: z.ZodOptional<z.ZodString>;
529
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
530
+ id: z.ZodNumber;
531
+ is_bot: z.ZodBoolean;
532
+ first_name: z.ZodOptional<z.ZodString>;
533
+ username: z.ZodOptional<z.ZodString>;
534
+ language_code: z.ZodOptional<z.ZodString>;
535
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
536
+ id: z.ZodNumber;
537
+ is_bot: z.ZodBoolean;
538
+ first_name: z.ZodOptional<z.ZodString>;
539
+ username: z.ZodOptional<z.ZodString>;
540
+ language_code: z.ZodOptional<z.ZodString>;
541
+ }, z.ZodTypeAny, "passthrough">>>;
542
+ text: z.ZodOptional<z.ZodString>;
543
+ }, z.ZodTypeAny, "passthrough">>>;
544
+ }, z.ZodTypeAny, "passthrough">>;
545
+ export type TelegramUpdate = z.infer<typeof TelegramUpdateSchema>;
546
+ export declare const TelegramOkEnvelope: <T extends z.ZodTypeAny>(result: T) => z.ZodObject<{
547
+ ok: z.ZodLiteral<true>;
548
+ result: T;
549
+ }, "strip", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{
550
+ ok: z.ZodLiteral<true>;
551
+ result: T;
552
+ }>, any> extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.baseObjectInputType<{
553
+ ok: z.ZodLiteral<true>;
554
+ result: T;
555
+ }> extends infer T_2 ? { [k_1 in keyof T_2]: T_2[k_1]; } : never>;
556
+ export declare const TelegramErrEnvelope: z.ZodObject<{
557
+ ok: z.ZodLiteral<false>;
558
+ error_code: z.ZodNumber;
559
+ description: z.ZodString;
560
+ parameters: z.ZodOptional<z.ZodObject<{
561
+ retry_after: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
562
+ migrate_to_chat_id: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
563
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
564
+ retry_after: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
565
+ migrate_to_chat_id: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
566
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
567
+ retry_after: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
568
+ migrate_to_chat_id: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
569
+ }, z.ZodTypeAny, "passthrough">>>;
570
+ }, "strip", z.ZodTypeAny, {
571
+ ok: false;
572
+ error_code: number;
573
+ description: string;
574
+ parameters?: z.objectOutputType<{
575
+ retry_after: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
576
+ migrate_to_chat_id: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
577
+ }, z.ZodTypeAny, "passthrough"> | undefined;
578
+ }, {
579
+ ok: false;
580
+ error_code: number;
581
+ description: string;
582
+ parameters?: z.objectInputType<{
583
+ retry_after: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
584
+ migrate_to_chat_id: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
585
+ }, z.ZodTypeAny, "passthrough"> | undefined;
586
+ }>;
587
+ export type TelegramErrResponse = z.infer<typeof TelegramErrEnvelope>;
588
+ /** Convenience type alias for "the API succeeded and gave us this T". */
589
+ export type TelegramOk<T> = {
590
+ readonly ok: true;
591
+ readonly result: T;
592
+ };
593
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/api/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;;;;;;;;GAkBG;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;gCAQf,CAAC;AACjB,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;gCAOf,CAAC;AACjB,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAQlB,CAAC;AACjB,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAKjB,CAAC;AACjB,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE,QAAQ,CAAC;;;;;;;;;iEACzB,CAAC;AAE5C,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAY9B,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEtE,yEAAyE;AACzE,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAA;CAAE,CAAC"}
@@ -0,0 +1,74 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Telegram Bot API response envelope (Phase 13, ADR-0020 §4 — boundary
4
+ * validation on untrusted input). Every Bot API response wraps either
5
+ * a successful `result` or a structured failure with `error_code` +
6
+ * `description`. We validate the envelope at this boundary so the rest
7
+ * of the channel package consumes typed payloads, never raw JSON.
8
+ *
9
+ * Scope: F13 covers only `message` updates with `text`. Photos, voice,
10
+ * documents, stickers, edited messages, callback queries — all reach
11
+ * Telegram but are silently ignored by the polling adapter via
12
+ * `allowed_updates: ["message"]`. The schemas below model exactly what
13
+ * we need to forward through the agent and no more — narrower payloads
14
+ * = smaller attack surface for parser bugs and easier to evolve.
15
+ *
16
+ * `passthrough()` is deliberate on `Message` and `User`: Telegram adds
17
+ * fields between minor versions; we tolerate unknown keys (do not
18
+ * reject) so a Bot API minor bump does not break the channel, but we
19
+ * never propagate them outside this boundary.
20
+ */
21
+ export const TelegramUserSchema = z
22
+ .object({
23
+ id: z.number().int(),
24
+ is_bot: z.boolean(),
25
+ first_name: z.string().optional(),
26
+ username: z.string().optional(),
27
+ language_code: z.string().optional(),
28
+ })
29
+ .passthrough();
30
+ export const TelegramChatSchema = z
31
+ .object({
32
+ id: z.number().int(),
33
+ type: z.enum(["private", "group", "supergroup", "channel"]),
34
+ title: z.string().optional(),
35
+ username: z.string().optional(),
36
+ })
37
+ .passthrough();
38
+ export const TelegramMessageSchema = z
39
+ .object({
40
+ message_id: z.number().int(),
41
+ date: z.number().int(),
42
+ chat: TelegramChatSchema,
43
+ from: TelegramUserSchema.optional(),
44
+ text: z.string().optional(),
45
+ })
46
+ .passthrough();
47
+ /**
48
+ * Update wraps either a new `message` or fields F13 deliberately
49
+ * ignores (edited_message, callback_query, etc.). `allowed_updates`
50
+ * on `getUpdates`/`setWebhook` filters those at Telegram's side, so
51
+ * in practice only `update_id + message` reach us; the schema models
52
+ * the F13 happy path and tolerates extra keys via passthrough.
53
+ */
54
+ export const TelegramUpdateSchema = z
55
+ .object({
56
+ update_id: z.number().int(),
57
+ message: TelegramMessageSchema.optional(),
58
+ })
59
+ .passthrough();
60
+ export const TelegramOkEnvelope = (result) => z.object({ ok: z.literal(true), result });
61
+ export const TelegramErrEnvelope = z.object({
62
+ ok: z.literal(false),
63
+ error_code: z.number().int(),
64
+ description: z.string(),
65
+ parameters: z
66
+ .object({
67
+ retry_after: z.number().int().optional(),
68
+ migrate_to_chat_id: z.number().int().optional(),
69
+ })
70
+ .partial()
71
+ .passthrough()
72
+ .optional(),
73
+ });
74
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/api/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC;KAChC,MAAM,CAAC;IACN,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IACpB,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE;IACnB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACjC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACrC,CAAC;KACD,WAAW,EAAE,CAAC;AAGjB,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC;KAChC,MAAM,CAAC;IACN,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IACpB,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;IAC3D,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAChC,CAAC;KACD,WAAW,EAAE,CAAC;AAGjB,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC;KACnC,MAAM,CAAC;IACN,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IAC5B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IACtB,IAAI,EAAE,kBAAkB;IACxB,IAAI,EAAE,kBAAkB,CAAC,QAAQ,EAAE;IACnC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC5B,CAAC;KACD,WAAW,EAAE,CAAC;AAGjB;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC;KAClC,MAAM,CAAC;IACN,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IAC3B,OAAO,EAAE,qBAAqB,CAAC,QAAQ,EAAE;CAC1C,CAAC;KACD,WAAW,EAAE,CAAC;AAGjB,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAyB,MAAS,EAAE,EAAE,CACtE,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;AAE5C,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;IACpB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IAC5B,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,UAAU,EAAE,CAAC;SACV,MAAM,CAAC;QACN,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;QACxC,kBAAkB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;KAChD,CAAC;SACD,OAAO,EAAE;SACT,WAAW,EAAE;SACb,QAAQ,EAAE;CACd,CAAC,CAAC"}