@dual-os/telegram 0.0.0-stage → 8.0.4

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.
Files changed (53) hide show
  1. package/LICENSE +4 -0
  2. package/README.md +65 -2
  3. package/Runner.js +5773 -0
  4. package/Runner.js.map +63 -0
  5. package/bundle-inventory.json +1 -0
  6. package/dist/Telegram.d.ts +5291 -0
  7. package/dist/Telegram.d.ts.map +1 -0
  8. package/dist/TelegramClient.d.ts +203 -0
  9. package/dist/TelegramClient.d.ts.map +1 -0
  10. package/dist/TelegramClient.js +28 -0
  11. package/dist/TelegramClient.js.map +9 -0
  12. package/dist/TelegramDefinition.d.ts +1556 -0
  13. package/dist/TelegramDefinition.d.ts.map +1 -0
  14. package/dist/channel/telegram-bot-client.d.ts +45 -0
  15. package/dist/channel/telegram-bot-client.d.ts.map +1 -0
  16. package/dist/channel/telegram-bot-definition.d.ts +155 -0
  17. package/dist/channel/telegram-bot-definition.d.ts.map +1 -0
  18. package/dist/channel/telegram-bot-webhook.d.ts +62 -0
  19. package/dist/channel/telegram-bot-webhook.d.ts.map +1 -0
  20. package/dist/channel/telegram-bot.d.ts +111 -0
  21. package/dist/channel/telegram-bot.d.ts.map +1 -0
  22. package/dist/definition.d.ts +1114 -0
  23. package/dist/definition.d.ts.map +1 -0
  24. package/dist/definition.js +20 -0
  25. package/dist/definition.js.map +9 -0
  26. package/dist/index.d.ts +3 -0
  27. package/dist/index.js +17 -0
  28. package/dist/index.js.map +9 -0
  29. package/dist/internal/TelegramSchemas.d.ts +375 -0
  30. package/dist/internal/TelegramSchemas.d.ts.map +1 -0
  31. package/dist/plugin.d.ts +3282 -0
  32. package/dist/plugin.d.ts.map +1 -0
  33. package/dist/plugin.js +26 -0
  34. package/dist/plugin.js.map +9 -0
  35. package/dual-plugin.json +1 -0
  36. package/index-3ysdpnc6.js +1301 -0
  37. package/index-3ysdpnc6.js.map +18 -0
  38. package/index-p2x5wnz4.js +251 -0
  39. package/index-p2x5wnz4.js.map +10 -0
  40. package/index-pm6k72es.js +847 -0
  41. package/index-pm6k72es.js.map +14 -0
  42. package/index-rakjqjpr.js +5524 -0
  43. package/index-rakjqjpr.js.map +56 -0
  44. package/index-s1hzpz14.js +224 -0
  45. package/index-s1hzpz14.js.map +11 -0
  46. package/index-wxqy9zdg.js +13978 -0
  47. package/index-wxqy9zdg.js.map +112 -0
  48. package/licenses/@dual-os_sdk@0.8.1/LICENSE +4 -0
  49. package/licenses/@effect_platform-node-shared@4.1.2/LICENSE +21 -0
  50. package/licenses/@effect_platform-node@4.1.2/LICENSE +21 -0
  51. package/licenses/effect@4.1.2/LICENSE +21 -0
  52. package/package.json +1 -6
  53. package/plugin.json +8 -0
@@ -0,0 +1,1301 @@
1
+ // @bun
2
+ import {
3
+ __exportAll,
4
+ TelegramChat2,
5
+ TelegramChatMember2,
6
+ TelegramMessage2,
7
+ TelegramFile2,
8
+ TelegramChatMemberUpdated,
9
+ TelegramMessageReactionUpdated,
10
+ TelegramMessageReactionCountUpdated
11
+ } from "./index-s1hzpz14.js";
12
+ import {
13
+ increment,
14
+ replace,
15
+ trim,
16
+ isEmpty,
17
+ isNonEmpty,
18
+ startsWith,
19
+ match,
20
+ replaceAll,
21
+ encode,
22
+ decode,
23
+ Action_exports,
24
+ ActionHandlerError,
25
+ AuthMethod_exports,
26
+ Schema,
27
+ AgentChannel_exports,
28
+ Key,
29
+ Event,
30
+ commandSchema,
31
+ Trigger_exports,
32
+ Service,
33
+ File,
34
+ read,
35
+ write,
36
+ Group_exports,
37
+ Plugin_exports
38
+ } from "./index-rakjqjpr.js";
39
+ import {
40
+ dual,
41
+ identity,
42
+ pipe,
43
+ isObject,
44
+ hasProperty,
45
+ PipeInspectableProto,
46
+ none,
47
+ match2,
48
+ getOrElse,
49
+ orElse2,
50
+ fromNullishOr,
51
+ fromUndefinedOr,
52
+ getOrNull,
53
+ getOrUndefined,
54
+ liftThrowable,
55
+ map,
56
+ flatMap,
57
+ filter,
58
+ liftPredicate,
59
+ succeed,
60
+ fail,
61
+ fromOption,
62
+ try_,
63
+ isSuccess,
64
+ match3,
65
+ fromEntries,
66
+ toEntries,
67
+ ensure,
68
+ append,
69
+ getUnsafe2,
70
+ findFirst,
71
+ empty2,
72
+ filter2,
73
+ every,
74
+ millis,
75
+ TaggedClass,
76
+ TaggedError,
77
+ forEach,
78
+ succeed4,
79
+ suspend,
80
+ sync,
81
+ void_2,
82
+ gen2,
83
+ fail5,
84
+ fromOption2,
85
+ flatMap3,
86
+ result,
87
+ map3,
88
+ mapError,
89
+ orDie,
90
+ ignore,
91
+ scoped,
92
+ acquireRelease,
93
+ fnUntraced,
94
+ fn,
95
+ encode3,
96
+ makeZoned,
97
+ make4,
98
+ toUtc,
99
+ toDateUtc,
100
+ toEpochMillis,
101
+ formatIso,
102
+ formatIsoOffset,
103
+ InvalidValue,
104
+ compose2,
105
+ transform,
106
+ transformEffect,
107
+ is,
108
+ decodeUnknownEffect,
109
+ decodeOption,
110
+ optionalKey,
111
+ optional,
112
+ Literal,
113
+ Never,
114
+ Unknown,
115
+ String3,
116
+ Number3,
117
+ Boolean2,
118
+ Struct,
119
+ Record,
120
+ StructWithRest,
121
+ ArraySchema,
122
+ Union,
123
+ Literals,
124
+ NullOr,
125
+ decodeTo,
126
+ isPattern,
127
+ Int,
128
+ Natural,
129
+ isMaxLength,
130
+ NonEmptyString,
131
+ Defect,
132
+ fromJsonString,
133
+ Uint8ArrayFromBase64,
134
+ TaggedError2,
135
+ toEquivalence,
136
+ Json,
137
+ make6,
138
+ get5,
139
+ set,
140
+ update,
141
+ fromEffect,
142
+ fromIterable2,
143
+ paginate,
144
+ unwrap2,
145
+ mapEffect,
146
+ flatMap4,
147
+ filterMap2,
148
+ decodeText,
149
+ runCollect,
150
+ runHead,
151
+ post,
152
+ del,
153
+ setHeaders,
154
+ bodyUint8Array,
155
+ bodyJsonUnsafe,
156
+ bodyFormDataRecord,
157
+ filterStatusOk
158
+ } from "./index-wxqy9zdg.js";
159
+
160
+ // ../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/Boolean.js
161
+ var Boolean = globalThis.Boolean;
162
+ var match4 = /* @__PURE__ */ dual(2, (value, options) => value ? options.onTrue() : options.onFalse());
163
+
164
+ // ../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/Ref.js
165
+ var TypeId = "~effect/Ref";
166
+ var RefProto = {
167
+ [TypeId]: {
168
+ _A: identity
169
+ },
170
+ ...PipeInspectableProto,
171
+ toJSON() {
172
+ return {
173
+ _id: "Ref",
174
+ ref: this.ref
175
+ };
176
+ }
177
+ };
178
+ var makeUnsafe = (value) => {
179
+ const self = Object.create(RefProto);
180
+ self.ref = make6(value);
181
+ return self;
182
+ };
183
+ var make = (value) => sync(() => makeUnsafe(value));
184
+ var get = (self) => sync(() => self.ref.current);
185
+ var set2 = /* @__PURE__ */ dual(2, (self, value) => sync(() => set(self.ref, value)));
186
+ var getAndUpdate = /* @__PURE__ */ dual(2, (self, f) => sync(() => {
187
+ const current = self.ref.current;
188
+ self.ref.current = f(current);
189
+ return current;
190
+ }));
191
+
192
+ // ../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/encoding/Sse.js
193
+ var SseErrorTypeId = "~effect/encoding/Sse/SseError";
194
+
195
+ class EventTooLarge extends (/* @__PURE__ */ TaggedError("EventTooLarge")) {
196
+ get message() {
197
+ return `Pending SSE event exceeded the maximum size of ${this.maxEventSize}`;
198
+ }
199
+ }
200
+
201
+ class SseError extends (/* @__PURE__ */ TaggedError("SseError")) {
202
+ [SseErrorTypeId] = SseErrorTypeId;
203
+ get message() {
204
+ return this.reason.message;
205
+ }
206
+ }
207
+ var defaultMaxEventSize = 10 * 1024 * 1024;
208
+ function makeParser(onParse, options) {
209
+ const maxEventSize = options?.maxEventSize ?? defaultMaxEventSize;
210
+ const dispatchEmptyNamedEvents = options?.dispatchEmptyNamedEvents === true;
211
+ let isFirstChunk;
212
+ let pending;
213
+ let pendingLength;
214
+ let discardTrailingNewline;
215
+ let generation = 0;
216
+ let lastEventId;
217
+ let eventName;
218
+ let data;
219
+ reset();
220
+ return {
221
+ feed,
222
+ reset
223
+ };
224
+ function reset() {
225
+ generation++;
226
+ isFirstChunk = true;
227
+ pending = [];
228
+ pendingLength = 0;
229
+ discardTrailingNewline = false;
230
+ lastEventId = undefined;
231
+ eventName = undefined;
232
+ data = "";
233
+ }
234
+ function feed(chunk) {
235
+ if (chunk.length === 0)
236
+ return;
237
+ if (isFirstChunk && chunk.startsWith(BOM)) {
238
+ chunk = chunk.slice(BOM.length);
239
+ }
240
+ isFirstChunk = false;
241
+ const length = chunk.length;
242
+ const currentGeneration = generation;
243
+ let position = 0;
244
+ while (position < length) {
245
+ if (discardTrailingNewline) {
246
+ discardTrailingNewline = false;
247
+ if (chunk.charCodeAt(position) === LF) {
248
+ ++position;
249
+ continue;
250
+ }
251
+ }
252
+ let lineEnd = position;
253
+ while (lineEnd < length) {
254
+ const code = chunk.charCodeAt(lineEnd);
255
+ if (code === CR || code === LF)
256
+ break;
257
+ ++lineEnd;
258
+ }
259
+ if (lineEnd === length) {
260
+ pending.push(chunk.slice(position));
261
+ pendingLength += length - position;
262
+ break;
263
+ }
264
+ discardTrailingNewline = chunk.charCodeAt(lineEnd) === CR;
265
+ let line = chunk.slice(position, lineEnd);
266
+ if (pending.length > 0) {
267
+ pending.push(line);
268
+ line = pending.join("");
269
+ pending = [];
270
+ pendingLength = 0;
271
+ }
272
+ parseLine(line);
273
+ if (generation !== currentGeneration) {
274
+ return;
275
+ }
276
+ position = lineEnd + 1;
277
+ }
278
+ if (pendingLength + data.length > maxEventSize) {
279
+ const error = new SseError({
280
+ reason: new EventTooLarge({
281
+ maxEventSize
282
+ })
283
+ });
284
+ reset();
285
+ return error;
286
+ }
287
+ }
288
+ function parseLine(line) {
289
+ if (line.length === 0) {
290
+ const named = eventName !== undefined && eventName !== "";
291
+ const event = eventName || "message";
292
+ const eventData = data;
293
+ eventName = undefined;
294
+ data = "";
295
+ if (eventData.length > 0 || dispatchEmptyNamedEvents && named) {
296
+ onParse({
297
+ _tag: "Event",
298
+ id: lastEventId,
299
+ event,
300
+ data: eventData.slice(0, -1)
301
+ });
302
+ }
303
+ return;
304
+ }
305
+ const colon = line.indexOf(":");
306
+ let field = line;
307
+ let value = "";
308
+ if (colon >= 0) {
309
+ field = line.slice(0, colon);
310
+ value = line.slice(line.charCodeAt(colon + 1) === SPACE ? colon + 2 : colon + 1);
311
+ }
312
+ if (field === "data") {
313
+ data += value + `
314
+ `;
315
+ } else if (field === "event") {
316
+ eventName = value;
317
+ } else if (field === "id" && !value.includes("\x00")) {
318
+ lastEventId = value;
319
+ } else if (field === "retry" && /^\d+$/.test(value)) {
320
+ const retry = parseInt(value, 10);
321
+ onParse(new Retry({
322
+ duration: millis(retry),
323
+ lastEventId
324
+ }));
325
+ }
326
+ }
327
+ }
328
+ var BOM = "\uFEFF";
329
+ var LF = 10;
330
+ var CR = 13;
331
+ var SPACE = 32;
332
+ var RetryTypeId = "~effect/encoding/Sse/Retry";
333
+
334
+ class Retry extends (/* @__PURE__ */ TaggedClass("Retry")) {
335
+ [RetryTypeId] = RetryTypeId;
336
+ static is(u) {
337
+ return hasProperty(u, RetryTypeId);
338
+ }
339
+ static filter(u) {
340
+ return Retry.is(u) ? succeed(u) : fail(u);
341
+ }
342
+ }
343
+
344
+ // ../../../../node_modules/.bun/@dual-os+sdk@0.8.1+a827849ded09603e/node_modules/@dual-os/sdk/dist/AgentChannelConformance.js
345
+ var Command = commandSchema(Json);
346
+ var Fixture = Struct({
347
+ activate: Command,
348
+ channelId: Key,
349
+ connectionId: optionalKey(Key),
350
+ deactivate: Command,
351
+ definitionSettings: Json,
352
+ deliver: Command,
353
+ deploymentSettings: Json,
354
+ receive: Command
355
+ });
356
+ var ConformanceError = class extends TaggedError2()("AgentChannelConformanceError", {
357
+ command: Literals([
358
+ "activate",
359
+ "deactivate",
360
+ "receive",
361
+ "deliver"
362
+ ]),
363
+ rule: Literals([
364
+ "command_kind",
365
+ "stable_result",
366
+ "stable_events",
367
+ "boundary_rejection"
368
+ ])
369
+ }) {
370
+ };
371
+ var run = fn("AgentChannelConformance.run")(function* (input) {
372
+ const fixture = yield* decodeUnknownEffect(Fixture)(input, { onExcessProperty: "error" });
373
+ const runtime = yield* Service;
374
+ const definition = yield* runtime.getAgentChannel({ channelId: fixture.channelId });
375
+ const { activate, receive, deliver, deactivate, ...config } = fixture;
376
+ const { connectionId: _connectionId, ...withoutConnection } = config;
377
+ const probes = [
378
+ {
379
+ code: "invalid_input",
380
+ input: {
381
+ ...config,
382
+ channelId: "",
383
+ command: activate
384
+ }
385
+ },
386
+ {
387
+ input: {
388
+ ...config,
389
+ channelId: "conformance/missing/channel",
390
+ command: activate
391
+ },
392
+ code: "not_found"
393
+ },
394
+ {
395
+ code: "invalid_input",
396
+ input: {
397
+ ...config,
398
+ command: {
399
+ ...activate,
400
+ operationKey: ""
401
+ }
402
+ }
403
+ },
404
+ {
405
+ code: "invalid_input",
406
+ input: {
407
+ ...config,
408
+ agent: { id: "synthetic-authority" },
409
+ command: activate
410
+ }
411
+ },
412
+ {
413
+ code: "invalid_auth",
414
+ input: definition.authMethods.length === 0 ? {
415
+ ...config,
416
+ command: activate,
417
+ connectionId: "unexpected"
418
+ } : {
419
+ ...withoutConnection,
420
+ command: activate
421
+ }
422
+ }
423
+ ];
424
+ for (const probe of probes) {
425
+ const outcome = yield* suspend(() => runtime.executeAgentChannel(probe.input)).pipe(result);
426
+ if (outcome._tag !== "Failure" || outcome.failure.code !== probe.code)
427
+ return yield* new ConformanceError({
428
+ command: "activate",
429
+ rule: "boundary_rejection"
430
+ });
431
+ }
432
+ const commands = [
433
+ ["activate", activate],
434
+ ["receive", receive],
435
+ ["deliver", deliver],
436
+ ["deactivate", deactivate]
437
+ ];
438
+ for (const [kind, command] of commands)
439
+ if (command.kind !== kind)
440
+ return yield* new ConformanceError({
441
+ command: kind,
442
+ rule: "command_kind"
443
+ });
444
+ const activated = yield* acquireRelease(runtime.executeAgentChannel({
445
+ ...config,
446
+ command: activate
447
+ }), (result2) => runtime.executeAgentChannel({
448
+ ...config,
449
+ command: {
450
+ ...deactivate,
451
+ ...result2.kind === "activate" ? {
452
+ installationKey: result2.installationKey,
453
+ state: result2.state
454
+ } : {}
455
+ }
456
+ }).pipe(orDie));
457
+ for (const [kind, command] of commands) {
458
+ const first = kind === "activate" ? activated : yield* runtime.executeAgentChannel({
459
+ ...config,
460
+ command
461
+ });
462
+ if (kind === "deliver" && definition.features.deliveryMode === "at-most-once")
463
+ continue;
464
+ const second = yield* runtime.executeAgentChannel({
465
+ ...config,
466
+ command
467
+ });
468
+ const firstJson = yield* decodeUnknownEffect(Json)(first);
469
+ const secondJson = yield* decodeUnknownEffect(Json)(second);
470
+ if (!toEquivalence(Json)(firstJson, secondJson))
471
+ return yield* new ConformanceError({
472
+ command: kind,
473
+ rule: "stable_result"
474
+ });
475
+ if (kind === "receive") {
476
+ const nextReceipt = yield* runtime.executeAgentChannel({
477
+ ...config,
478
+ command: {
479
+ ...command,
480
+ operationKey: `${command.operationKey.slice(0, 500)}:replay`
481
+ }
482
+ });
483
+ if (first.kind !== "receive" || nextReceipt.kind !== "receive" || !toEquivalence(ArraySchema(Event))(first.events, nextReceipt.events))
484
+ return yield* new ConformanceError({
485
+ command: kind,
486
+ rule: "stable_events"
487
+ });
488
+ }
489
+ }
490
+ }, scoped);
491
+
492
+ // ../../../../node_modules/.bun/@dual-os+sdk@0.8.1+a827849ded09603e/node_modules/@dual-os/sdk/dist/Mcp.js
493
+ var McpError = class extends TaggedError2()("McpError", {
494
+ cause: optional(Defect()),
495
+ message: String3
496
+ }) {
497
+ };
498
+ var protocolVersion = "2025-06-18";
499
+ var Implementation = Struct({
500
+ name: String3,
501
+ title: optionalKey(String3),
502
+ version: String3
503
+ });
504
+ var Tool = Struct({
505
+ annotations: optionalKey(Struct({ title: optionalKey(String3) })),
506
+ description: optionalKey(String3),
507
+ inputSchema: Record(String3, Unknown),
508
+ name: String3,
509
+ outputSchema: optionalKey(Record(String3, Unknown)),
510
+ title: optionalKey(String3)
511
+ });
512
+ var ListToolsResult = Struct({
513
+ nextCursor: optionalKey(String3),
514
+ tools: ArraySchema(Tool)
515
+ });
516
+ var ContentBlock = StructWithRest(Struct({
517
+ text: optionalKey(String3),
518
+ type: String3
519
+ }), [Record(String3, Unknown)]);
520
+ var CallToolResult = Struct({
521
+ content: ArraySchema(ContentBlock),
522
+ isError: optionalKey(Boolean2),
523
+ structuredContent: optionalKey(Unknown)
524
+ });
525
+ var InitializeResult = Struct({
526
+ protocolVersion: String3,
527
+ serverInfo: Implementation
528
+ });
529
+ var Message = Struct({
530
+ error: optionalKey(Struct({ message: String3 })),
531
+ id: optionalKey(Unknown),
532
+ result: optionalKey(Unknown)
533
+ });
534
+ var responseTo = fnUntraced(function* (id, method, response) {
535
+ const payloads = match4(pipe(response.headers["content-type"] ?? "", startsWith("text/event-stream")), {
536
+ onFalse: () => fromEffect(response.text),
537
+ onTrue: () => unwrap2(sync(() => {
538
+ const events = make6(empty2());
539
+ const parser = makeParser((event) => {
540
+ if (event._tag === "Event")
541
+ update(events, append(event.data));
542
+ });
543
+ return pipe(response.stream, decodeText(), mapEffect((chunk) => {
544
+ const error = parser.feed(chunk);
545
+ if (error !== undefined)
546
+ return fail5(McpError.make({
547
+ cause: error,
548
+ message: error.message
549
+ }));
550
+ const ready = get5(events);
551
+ set(events, empty2());
552
+ return succeed4(ready);
553
+ }), flatMap4(fromIterable2));
554
+ }))
555
+ });
556
+ const found = yield* pipe(payloads, filterMap2((payload) => fromOption(filter(decodeOption(fromJsonString(Message))(payload), (message) => message.id === id && (message.result !== undefined || message.error !== undefined)), () => payload)), runHead);
557
+ return yield* fromOption2(found, () => McpError.make({ message: `${method} got no response` }));
558
+ });
559
+ var connect = fn("Mcp.connect")(function* (client, endpoint, headers) {
560
+ const checked = filterStatusOk(client);
561
+ const post2 = fnUntraced(function* (version, session, body) {
562
+ return yield* checked.execute(pipe(post(endpoint), setHeaders({
563
+ ...headers,
564
+ accept: "application/json, text/event-stream",
565
+ "mcp-protocol-version": version,
566
+ ...match2(session, {
567
+ onNone: () => ({}),
568
+ onSome: (id) => ({ "mcp-session-id": id })
569
+ })
570
+ }), bodyJsonUnsafe({
571
+ jsonrpc: "2.0",
572
+ ...body
573
+ })));
574
+ });
575
+ const call = fnUntraced(function* (version, session, id, method, params) {
576
+ const response = yield* post2(version, session, {
577
+ id,
578
+ method,
579
+ params
580
+ });
581
+ const message = yield* responseTo(id, method, response);
582
+ if (message.error !== undefined)
583
+ return yield* McpError.make({ message: `${method}: ${message.error.message}` });
584
+ return {
585
+ result: message.result,
586
+ session: orElse2(fromNullishOr(response.headers["mcp-session-id"]), () => session)
587
+ };
588
+ });
589
+ const negotiatedVersion = yield* make(protocolVersion);
590
+ const initialized = yield* acquireRelease(call(protocolVersion, none(), 0, "initialize", {
591
+ capabilities: {},
592
+ clientInfo: {
593
+ name: "dual",
594
+ version: "1"
595
+ },
596
+ protocolVersion
597
+ }), (opened) => match2(opened.session, {
598
+ onNone: () => void_2,
599
+ onSome: (id) => flatMap3(get(negotiatedVersion), (version) => ignore(client.execute(pipe(del(endpoint), setHeaders({
600
+ ...headers,
601
+ "mcp-protocol-version": version,
602
+ "mcp-session-id": id
603
+ })))))
604
+ }));
605
+ const server = yield* decodeUnknownEffect(InitializeResult)(initialized.result);
606
+ if (server.protocolVersion !== protocolVersion && server.protocolVersion !== "2025-03-26")
607
+ return yield* McpError.make({ message: `Unsupported MCP protocol version ${server.protocolVersion}` });
608
+ yield* set2(negotiatedVersion, server.protocolVersion);
609
+ yield* post2(server.protocolVersion, initialized.session, { method: "notifications/initialized" });
610
+ const ids = yield* make(1);
611
+ return {
612
+ request: fn("Mcp.request")(function* (method, params) {
613
+ return (yield* call(server.protocolVersion, initialized.session, yield* getAndUpdate(ids, increment), method, params)).result;
614
+ }),
615
+ server: server.serverInfo
616
+ };
617
+ });
618
+ var listTools = fn("Mcp.listTools")(function* (client, endpoint, headers) {
619
+ const session = yield* connect(client, endpoint, headers);
620
+ const tools = yield* runCollect(paginate({}, fnUntraced(function* (params) {
621
+ const page = yield* decodeUnknownEffect(ListToolsResult)(yield* session.request("tools/list", params));
622
+ return [page.tools, map(fromUndefinedOr(page.nextCursor), (cursor) => ({ cursor }))];
623
+ })));
624
+ return {
625
+ server: session.server,
626
+ tools
627
+ };
628
+ }, scoped);
629
+
630
+ // ../../../../node_modules/.bun/@dual-os+sdk@0.8.1+a827849ded09603e/node_modules/@dual-os/sdk/dist/Http.js
631
+ var File2 = Struct({
632
+ _tag: optionalKey(Literal("ToolFile")),
633
+ contentBase64: Uint8ArrayFromBase64,
634
+ contentType: optionalKey(NullOr(String3)),
635
+ filename: optionalKey(NullOr(String3)),
636
+ sizeBytes: optionalKey(Natural)
637
+ }).annotate({ description: "A ToolFile, such as the result of a download, passed unchanged; or its contentBase64 with an optional contentType and filename." });
638
+ var signatures = [
639
+ ["image/jpeg", [[0, [
640
+ 255,
641
+ 216,
642
+ 255
643
+ ]]]],
644
+ ["image/png", [[0, [
645
+ 137,
646
+ 80,
647
+ 78,
648
+ 71
649
+ ]]]],
650
+ ["image/gif", [[0, [
651
+ 71,
652
+ 73,
653
+ 70,
654
+ 56
655
+ ]]]],
656
+ ["image/webp", [[0, [
657
+ 82,
658
+ 73,
659
+ 70,
660
+ 70
661
+ ]], [8, [
662
+ 87,
663
+ 69,
664
+ 66,
665
+ 80
666
+ ]]]],
667
+ ["application/pdf", [[0, [
668
+ 37,
669
+ 80,
670
+ 68,
671
+ 70
672
+ ]]]],
673
+ ["application/zip", [[0, [
674
+ 80,
675
+ 75,
676
+ 3,
677
+ 4
678
+ ]]]]
679
+ ];
680
+ var utf8 = new TextDecoder("utf-8", { fatal: true });
681
+ function sniff(bytes) {
682
+ return pipe(findFirst(signatures, (signature) => every(signature[1], (part) => every(part[1], (byte, index) => bytes[part[0] + index] === byte))), map((signature) => signature[0]), orElse2(() => liftPredicate("text/plain", () => isSuccess(try_(() => utf8.decode(bytes))))), getOrNull);
683
+ }
684
+ function toolFile(bytes, declared, filename) {
685
+ return {
686
+ _tag: "ToolFile",
687
+ contentBase64: encode3(bytes),
688
+ contentType: declared === null || pipe(declared, startsWith("application/octet-stream")) ? sniff(bytes) ?? declared : declared,
689
+ filename,
690
+ sizeBytes: bytes.byteLength
691
+ };
692
+ }
693
+ function invalid(expected, value, options) {
694
+ return fail5(new InvalidValue({ expected }, value, options));
695
+ }
696
+ function decodeBytes(text, options) {
697
+ return match3(decode(pipe(text, replaceAll("+", "-"), replaceAll("/", "_"))), {
698
+ onFailure: () => invalid("a Base64 or Base64Url string", text, options),
699
+ onSuccess: (bytes) => succeed4(bytes)
700
+ });
701
+ }
702
+ function contentOf(carrier) {
703
+ return transformEffect((text, options) => {
704
+ if (carrier !== "data-uri")
705
+ return map3(decodeBytes(text, options), (bytes) => ({
706
+ bytes,
707
+ contentType: null
708
+ }));
709
+ return match2(pipe(text, match(/^data:([^;,]*)(?:;[^;,]*)*;base64,(.*)$/su)), {
710
+ onNone: () => invalid("a Base64 data URI", text, options),
711
+ onSome: (parts) => map3(decodeBytes(getUnsafe2(parts, 2), options), (bytes) => ({
712
+ bytes,
713
+ contentType: pipe(getUnsafe2(parts, 1), liftPredicate(isNonEmpty), getOrNull)
714
+ }))
715
+ });
716
+ });
717
+ }
718
+ function textOf(carrier, content) {
719
+ if (carrier === "base64")
720
+ return encode3(content.bytes);
721
+ if (carrier === "base64url")
722
+ return encode(content.bytes);
723
+ return `data:${content.contentType ?? sniff(content.bytes) ?? "application/octet-stream"};base64,${encode3(content.bytes)}`;
724
+ }
725
+ function fileFrom(carrier) {
726
+ return String3.pipe(decodeTo(Schema, {
727
+ decode: compose2(contentOf(carrier), transform((content) => toolFile(content.bytes, content.contentType, null))),
728
+ encode: transformEffect((file, options) => map3(decodeBytes(file.contentBase64, options), (bytes) => textOf(carrier, {
729
+ bytes,
730
+ contentType: file.contentType
731
+ })))
732
+ }));
733
+ }
734
+ function encodedFrom(carrier) {
735
+ return File2.pipe(decodeTo(String3, {
736
+ decode: transform((file) => textOf(carrier, {
737
+ bytes: file.contentBase64,
738
+ contentType: file.contentType ?? null
739
+ })),
740
+ encode: compose2(contentOf(carrier), transform((content) => ({
741
+ contentBase64: content.bytes,
742
+ contentType: content.contentType
743
+ })))
744
+ }));
745
+ }
746
+ var FileFromBase64 = fileFrom("base64");
747
+ var FileFromBase64Url = fileFrom("base64url");
748
+ var Base64FromFile = encodedFrom("base64");
749
+ var Base64UrlFromFile = encodedFrom("base64url");
750
+ var FileFromDataUri = fileFrom("data-uri");
751
+ var DataUriFromFile = encodedFrom("data-uri");
752
+ var DateTimeText = String3.annotate({ format: "date-time" });
753
+ var rfc3339 = /^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})(?:\.\d+)?(?:Z|([+-]\d{2}:\d{2}))$/u;
754
+ function rfc3339Instant(text) {
755
+ return pipe(fromNullishOr(rfc3339.exec(text)), flatMap((match4) => filter(makeZoned(text, { timeZone: match4[2] ?? "+00:00" }), (zoned) => startsWith(match4[1] ?? "")(formatIsoOffset(zoned)))), map(toUtc));
756
+ }
757
+ function instants(wire, expected, read, write) {
758
+ const fromWire = transformEffect((value, options) => match2(read(value), {
759
+ onNone: () => invalid(expected, value, options),
760
+ onSome: (instant) => succeed4(formatIso(instant))
761
+ }));
762
+ const toWire = transformEffect((text, options) => match2(rfc3339Instant(text), {
763
+ onNone: () => invalid("an ISO 8601 date-time", text, options),
764
+ onSome: (instant) => succeed4(write(instant))
765
+ }));
766
+ return {
767
+ input: pipe(DateTimeText, decodeTo(wire, {
768
+ decode: toWire,
769
+ encode: fromWire
770
+ })),
771
+ output: pipe(wire, decodeTo(DateTimeText, {
772
+ decode: fromWire,
773
+ encode: toWire
774
+ }))
775
+ };
776
+ }
777
+ var unixSeconds = instants(Int, "Unix seconds", (seconds) => map(make4(seconds * 1000), toUtc), (instant) => Math.floor(toEpochMillis(instant) / 1000));
778
+ var rfc2822 = instants(String3, "an RFC 2822 date-time", (text) => map(make4(text), toUtc), (instant) => toDateUtc(instant).toUTCString());
779
+ var DateTimeFromUnixSeconds = unixSeconds.output;
780
+ var UnixSecondsFromDateTime = unixSeconds.input;
781
+ var DateTimeFromRfc2822 = rfc2822.output;
782
+ var Rfc2822FromDateTime = rfc2822.input;
783
+ var GraphqlResponse = Struct({
784
+ data: optionalKey(NullOr(Record(String3, Unknown))),
785
+ errors: optionalKey(ArraySchema(StructWithRest(Struct({ message: String3 }), [Record(String3, Unknown)])))
786
+ });
787
+ function coerce(value) {
788
+ return isObject(value) ? JSON.stringify(value) : `${value}`;
789
+ }
790
+ function filePart(bytes, name, contentType) {
791
+ return new globalThis.File([new Uint8Array(bytes)], name, { type: contentType });
792
+ }
793
+ function fileFailed(error) {
794
+ return ActionHandlerError.make({
795
+ cause: error,
796
+ message: error.message
797
+ });
798
+ }
799
+ function readFile(file) {
800
+ return pipe(read(file), mapError(fileFailed));
801
+ }
802
+ var withFile = fnUntraced(function* (request, file) {
803
+ return bodyUint8Array(request, yield* readFile(file), file.contentType);
804
+ });
805
+ var withForm = fnUntraced(function* (request, payload) {
806
+ return bodyFormDataRecord(request, fromEntries(yield* forEach(toEntries(payload), (field) => map3(forEach(filter2(ensure(field[1]), (item) => item !== undefined), (item) => gen2(function* () {
807
+ if (!is(File)(item))
808
+ return coerce(item);
809
+ return filePart(yield* readFile(item), item.name, item.contentType);
810
+ })), (parts) => [field[0], parts]))));
811
+ });
812
+ function dispositionName(header) {
813
+ if (header === undefined)
814
+ return;
815
+ const encoded = pipe(match(/(?:^|;)\s*filename\*\s*=\s*UTF-8'[^']*'([^;]+)/iu)(header), flatMap((match4) => fromUndefinedOr(match4[1])));
816
+ const decoded = pipe(encoded, flatMap((value) => liftThrowable(() => decodeURIComponent(trim(value)))()));
817
+ return getOrElse(decoded, () => pipe(match(/(?:^|;)\s*filename\s*=\s*(?:"((?:\\.|[^"\\])*)"|([^;]*))/iu)(header), flatMap((match4) => orElse2(map(fromUndefinedOr(match4[1]), (name) => replace(/\\(.)/gu, "$1")(name)), () => map(fromUndefinedOr(match4[2]), trim))), getOrUndefined));
818
+ }
819
+ var read2 = fnUntraced(function* (response, body) {
820
+ if (body === "json")
821
+ return yield* response.json;
822
+ if (body === "text")
823
+ return yield* response.text;
824
+ if (body === "void")
825
+ return {};
826
+ if (body === "unknown") {
827
+ const text = yield* response.text;
828
+ if (isEmpty(trim(text)))
829
+ return null;
830
+ return getOrElse(decodeOption(fromJsonString(Json))(text), () => text);
831
+ }
832
+ const bytes = new Uint8Array(yield* response.arrayBuffer);
833
+ const name = dispositionName(response.headers["content-disposition"]);
834
+ if (body === "file")
835
+ return yield* pipe(write({
836
+ bytes,
837
+ contentType: getOrNull(fromUndefinedOr(response.headers["content-type"])),
838
+ name: name ?? "file"
839
+ }), mapError(fileFailed));
840
+ return toolFile(bytes, response.headers["content-type"] ?? null, name ?? null);
841
+ });
842
+
843
+ // dist/TelegramDefinition.js
844
+ var TelegramDefinition_exports = /* @__PURE__ */ __exportAll({
845
+ TelegramDefinition: () => TelegramDefinition_exports,
846
+ TelegramUpdateConfigV2: () => TelegramUpdateConfigV22,
847
+ TelegramUpdateV2: () => TelegramUpdateV22,
848
+ telegramAccessToken: () => telegramAccessToken2,
849
+ telegramPluginBase: () => telegramPluginBase2
850
+ });
851
+ var telegramAccessToken2 = AuthMethod_exports.make("access-token", {
852
+ description: "Authenticate with a Telegram bot access token obtained from @BotFather",
853
+ name: "Telegram access token",
854
+ schema: Struct({
855
+ accessToken: String3,
856
+ baseUrl: optional(String3)
857
+ })
858
+ });
859
+ var authMethods = [telegramAccessToken2];
860
+ var ParseMode = Literals([
861
+ "Markdown",
862
+ "MarkdownV2",
863
+ "HTML"
864
+ ]);
865
+ var ReplyMarkup = Unknown;
866
+ var BoolResult = Boolean2;
867
+ var chatGet = Action_exports.make("get", {
868
+ description: "Get up to date information about a chat",
869
+ name: "Get chat",
870
+ examples: [{
871
+ input: { chatId: "@mychannel" },
872
+ title: "Get a chat"
873
+ }],
874
+ input: Struct({ chatId: String3 }),
875
+ output: TelegramChat2
876
+ });
877
+ var chatAdministrators = Action_exports.make("administrators", {
878
+ description: "Get the administrators of a chat",
879
+ name: "Get chat administrators",
880
+ input: Struct({ chatId: String3 }),
881
+ output: ArraySchema(TelegramChatMember2)
882
+ });
883
+ var chatMember = Action_exports.make("member", {
884
+ description: "Get a member of a chat",
885
+ name: "Get chat member",
886
+ input: Struct({
887
+ chatId: String3,
888
+ userId: String3
889
+ }),
890
+ output: TelegramChatMember2
891
+ });
892
+ var chatLeave = Action_exports.make("leave", {
893
+ description: "Leave a group, supergroup or channel",
894
+ name: "Leave chat",
895
+ input: Struct({ chatId: String3 }),
896
+ output: BoolResult
897
+ });
898
+ var chatSetDescription = Action_exports.make("set-description", {
899
+ description: "Set the description of a chat",
900
+ name: "Set chat description",
901
+ input: Struct({
902
+ chatId: String3,
903
+ description: String3
904
+ }),
905
+ output: BoolResult
906
+ });
907
+ var chatSetTitle = Action_exports.make("set-title", {
908
+ description: "Set the title of a chat",
909
+ name: "Set chat title",
910
+ input: Struct({
911
+ chatId: String3,
912
+ title: String3
913
+ }),
914
+ output: BoolResult
915
+ });
916
+ var callbackAnswerQuery = Action_exports.make("answer-query", {
917
+ description: "Send an answer to a callback query sent from an inline keyboard",
918
+ name: "Answer query",
919
+ input: Struct({
920
+ cacheTime: optional(Number3),
921
+ queryId: String3,
922
+ showAlert: optional(Boolean2),
923
+ text: optional(String3),
924
+ url: optional(String3)
925
+ }),
926
+ output: BoolResult
927
+ });
928
+ var callbackAnswerInlineQuery = Action_exports.make("answer-inline-query", {
929
+ description: "Send an answer to a callback query sent from an inline bot",
930
+ name: "Answer inline query",
931
+ input: Struct({
932
+ cacheTime: optional(Number3),
933
+ queryId: String3,
934
+ results: Unknown
935
+ }),
936
+ output: BoolResult
937
+ });
938
+ var fileGet = Action_exports.make("get", {
939
+ description: "Get a file's metadata, including the download path under <baseUrl>/file/bot<token>/<file_path>",
940
+ name: "Get file",
941
+ input: Struct({ fileId: String3 }),
942
+ output: TelegramFile2
943
+ });
944
+ var messageDelete = Action_exports.make("delete-message", {
945
+ description: "Delete a chat message",
946
+ name: "Delete chat message",
947
+ input: Struct({
948
+ chatId: String3,
949
+ messageId: String3
950
+ }),
951
+ output: BoolResult
952
+ });
953
+ var messageEditText = Action_exports.make("edit-message-text", {
954
+ description: "Edit a text message, by chat+message id or by inline message id",
955
+ name: "Edit message text",
956
+ input: Struct({
957
+ chatId: optional(String3),
958
+ disableWebPagePreview: optional(Boolean2),
959
+ inlineMessageId: optional(String3),
960
+ messageId: optional(String3),
961
+ parseMode: optional(ParseMode),
962
+ replyMarkup: optional(ReplyMarkup),
963
+ text: String3
964
+ }),
965
+ output: Union([TelegramMessage2, Boolean2])
966
+ });
967
+ var messagePin = Action_exports.make("pin-chat-message", {
968
+ description: "Pin a chat message",
969
+ name: "Pin chat message",
970
+ input: Struct({
971
+ chatId: String3,
972
+ disableNotification: optional(Boolean2),
973
+ messageId: String3
974
+ }),
975
+ output: BoolResult
976
+ });
977
+ var messageUnpin = Action_exports.make("unpin-chat-message", {
978
+ description: "Unpin a chat message",
979
+ name: "Unpin chat message",
980
+ input: Struct({
981
+ chatId: String3,
982
+ messageId: String3
983
+ }),
984
+ output: BoolResult
985
+ });
986
+ var messageSend = Action_exports.make("send-message", {
987
+ description: "Send a text message",
988
+ name: "Send message",
989
+ examples: [{
990
+ input: {
991
+ chatId: "123456789",
992
+ text: "Hello!"
993
+ },
994
+ title: "Say hello"
995
+ }],
996
+ input: Struct({
997
+ chatId: String3,
998
+ disableNotification: optional(Boolean2),
999
+ disableWebPagePreview: optional(Boolean2),
1000
+ messageThreadId: optional(Number3),
1001
+ parseMode: optional(ParseMode),
1002
+ replyMarkup: optional(ReplyMarkup),
1003
+ replyToMessageId: optional(Number3),
1004
+ text: String3
1005
+ }),
1006
+ output: TelegramMessage2
1007
+ });
1008
+ var messageSendAnimation = Action_exports.make("send-animation", {
1009
+ description: "Send an animated file by file_id or HTTP URL",
1010
+ name: "Send animation",
1011
+ input: Struct({
1012
+ animation: String3,
1013
+ caption: optional(String3),
1014
+ chatId: String3,
1015
+ disableNotification: optional(Boolean2),
1016
+ duration: optional(Number3),
1017
+ height: optional(Number3),
1018
+ messageThreadId: optional(Number3),
1019
+ parseMode: optional(ParseMode),
1020
+ replyMarkup: optional(ReplyMarkup),
1021
+ replyToMessageId: optional(Number3),
1022
+ thumb: optional(String3),
1023
+ width: optional(Number3)
1024
+ }),
1025
+ output: TelegramMessage2
1026
+ });
1027
+ var messageSendAudio = Action_exports.make("send-audio", {
1028
+ description: "Send an audio file by file_id or HTTP URL",
1029
+ name: "Send audio",
1030
+ input: Struct({
1031
+ audio: String3,
1032
+ caption: optional(String3),
1033
+ chatId: String3,
1034
+ disableNotification: optional(Boolean2),
1035
+ duration: optional(Number3),
1036
+ messageThreadId: optional(Number3),
1037
+ parseMode: optional(ParseMode),
1038
+ performer: optional(String3),
1039
+ replyMarkup: optional(ReplyMarkup),
1040
+ replyToMessageId: optional(Number3),
1041
+ thumb: optional(String3),
1042
+ title: optional(String3)
1043
+ }),
1044
+ output: TelegramMessage2
1045
+ });
1046
+ var messageSendChatAction = Action_exports.make("send-chat-action", {
1047
+ description: "Broadcast a chat action (typing, upload_photo, etc.)",
1048
+ name: "Send chat action",
1049
+ input: Struct({
1050
+ action: Literals([
1051
+ "typing",
1052
+ "upload_photo",
1053
+ "record_video",
1054
+ "upload_video",
1055
+ "record_audio",
1056
+ "upload_audio",
1057
+ "upload_document",
1058
+ "find_location",
1059
+ "record_video_note",
1060
+ "upload_video_note"
1061
+ ]),
1062
+ chatId: String3,
1063
+ messageThreadId: optional(Number3)
1064
+ }),
1065
+ output: BoolResult
1066
+ });
1067
+ var messageSendDocument = Action_exports.make("send-document", {
1068
+ description: "Send a document by file_id or HTTP URL",
1069
+ name: "Send document",
1070
+ input: Struct({
1071
+ caption: optional(String3),
1072
+ chatId: String3,
1073
+ disableNotification: optional(Boolean2),
1074
+ document: String3,
1075
+ messageThreadId: optional(Number3),
1076
+ parseMode: optional(ParseMode),
1077
+ replyMarkup: optional(ReplyMarkup),
1078
+ replyToMessageId: optional(Number3),
1079
+ thumb: optional(String3)
1080
+ }),
1081
+ output: TelegramMessage2
1082
+ });
1083
+ var messageSendLocation = Action_exports.make("send-location", {
1084
+ description: "Send a point on the map",
1085
+ name: "Send location",
1086
+ input: Struct({
1087
+ chatId: String3,
1088
+ disableNotification: optional(Boolean2),
1089
+ latitude: Number3,
1090
+ longitude: Number3,
1091
+ messageThreadId: optional(Number3),
1092
+ replyMarkup: optional(ReplyMarkup),
1093
+ replyToMessageId: optional(Number3)
1094
+ }),
1095
+ output: TelegramMessage2
1096
+ });
1097
+ var messageSendMediaGroup = Action_exports.make("send-media-group", {
1098
+ description: "Send a group of photos or videos as an album",
1099
+ name: "Send media group",
1100
+ input: Struct({
1101
+ chatId: String3,
1102
+ disableNotification: optional(Boolean2),
1103
+ media: Unknown,
1104
+ messageThreadId: optional(Number3),
1105
+ replyToMessageId: optional(Number3)
1106
+ }),
1107
+ output: ArraySchema(TelegramMessage2)
1108
+ });
1109
+ var messageSendPhoto = Action_exports.make("send-photo", {
1110
+ description: "Send a photo by file_id or HTTP URL",
1111
+ name: "Send photo",
1112
+ examples: [{
1113
+ input: {
1114
+ chatId: "123456789",
1115
+ photo: "https://example.com/cat.jpg"
1116
+ },
1117
+ title: "Send a photo by URL"
1118
+ }],
1119
+ input: Struct({
1120
+ caption: optional(String3),
1121
+ chatId: String3,
1122
+ disableNotification: optional(Boolean2),
1123
+ messageThreadId: optional(Number3),
1124
+ parseMode: optional(ParseMode),
1125
+ photo: String3,
1126
+ replyMarkup: optional(ReplyMarkup),
1127
+ replyToMessageId: optional(Number3)
1128
+ }),
1129
+ output: TelegramMessage2
1130
+ });
1131
+ var messageSendSticker = Action_exports.make("send-sticker", {
1132
+ description: "Send a sticker by file_id or HTTP URL",
1133
+ name: "Send sticker",
1134
+ input: Struct({
1135
+ chatId: String3,
1136
+ disableNotification: optional(Boolean2),
1137
+ messageThreadId: optional(Number3),
1138
+ replyMarkup: optional(ReplyMarkup),
1139
+ replyToMessageId: optional(Number3),
1140
+ sticker: String3
1141
+ }),
1142
+ output: TelegramMessage2
1143
+ });
1144
+ var messageSendVideo = Action_exports.make("send-video", {
1145
+ description: "Send a video by file_id or HTTP URL",
1146
+ name: "Send video",
1147
+ input: Struct({
1148
+ caption: optional(String3),
1149
+ chatId: String3,
1150
+ disableNotification: optional(Boolean2),
1151
+ duration: optional(Number3),
1152
+ height: optional(Number3),
1153
+ messageThreadId: optional(Number3),
1154
+ parseMode: optional(ParseMode),
1155
+ replyMarkup: optional(ReplyMarkup),
1156
+ replyToMessageId: optional(Number3),
1157
+ thumb: optional(String3),
1158
+ video: String3,
1159
+ width: optional(Number3)
1160
+ }),
1161
+ output: TelegramMessage2
1162
+ });
1163
+ var UPDATE_TYPES = [
1164
+ "message",
1165
+ "edited_message",
1166
+ "channel_post",
1167
+ "edited_channel_post",
1168
+ "callback_query",
1169
+ "inline_query",
1170
+ "poll",
1171
+ "pre_checkout_query",
1172
+ "shipping_query"
1173
+ ];
1174
+ var updateOutput = Struct({
1175
+ callback_query: optional(Unknown),
1176
+ channel_post: optional(Unknown),
1177
+ edited_channel_post: optional(Unknown),
1178
+ edited_message: optional(Unknown),
1179
+ inline_query: optional(Unknown),
1180
+ message: optional(Unknown),
1181
+ poll: optional(Unknown),
1182
+ pre_checkout_query: optional(Unknown),
1183
+ shipping_query: optional(Unknown),
1184
+ update_id: optional(Number3)
1185
+ });
1186
+ var updateState = Struct({ lastUpdateId: NullOr(Number3) });
1187
+ var updateStateV2 = Struct({
1188
+ ...updateState.fields,
1189
+ registrationUrl: optional(String3)
1190
+ });
1191
+ var hostedUpdateConfig = Struct({
1192
+ chatIds: optional(ArraySchema(String3)),
1193
+ secretToken: optional(String3.check(isPattern(/^[A-Za-z0-9_-]{1,256}$/u))),
1194
+ updates: optional(ArraySchema(Literals([...UPDATE_TYPES]))),
1195
+ userIds: optional(ArraySchema(String3))
1196
+ });
1197
+ var TelegramUpdateV22 = Struct({
1198
+ ...updateOutput.fields,
1199
+ chat_member: optionalKey(TelegramChatMemberUpdated),
1200
+ message_reaction: optionalKey(TelegramMessageReactionUpdated),
1201
+ message_reaction_count: optionalKey(TelegramMessageReactionCountUpdated),
1202
+ my_chat_member: optionalKey(TelegramChatMemberUpdated),
1203
+ update_id: Int
1204
+ });
1205
+ var TelegramUpdateConfigV22 = Struct({
1206
+ ...hostedUpdateConfig.fields,
1207
+ updates: optional(ArraySchema(Literals([
1208
+ ...UPDATE_TYPES,
1209
+ "my_chat_member",
1210
+ "chat_member",
1211
+ "message_reaction",
1212
+ "message_reaction_count"
1213
+ ])))
1214
+ });
1215
+ var updateTrigger = Trigger_exports.webhook("update", {
1216
+ description: "Triggers on Telegram updates (messages, callback queries, inline queries, and more)",
1217
+ name: "On update",
1218
+ config: TelegramUpdateConfigV22,
1219
+ output: TelegramUpdateV22,
1220
+ state: updateStateV2
1221
+ });
1222
+ var telegramPluginBase2 = Plugin_exports.make("telegram").pipe(Plugin_exports.withName("Telegram"), Plugin_exports.withDescription("Telegram bot messaging, chats, files, callback queries and update triggers"), Plugin_exports.withCategories(["communication"]), Plugin_exports.withHomepageUrl("https://telegram.org"), Plugin_exports.withDocsUrl("https://core.telegram.org/bots/api"), Plugin_exports.withIconUrl("https://telegram.org/img/t_logo.png"), Plugin_exports.withAuthMethods(authMethods), Plugin_exports.add(Group_exports.make("chat").pipe(Group_exports.withName("Chat"), Group_exports.add(chatGet, chatAdministrators, chatMember, chatLeave, chatSetDescription, chatSetTitle)), Group_exports.make("callback").pipe(Group_exports.withName("Callback"), Group_exports.add(callbackAnswerQuery, callbackAnswerInlineQuery)), Group_exports.make("file").pipe(Group_exports.withName("File"), Group_exports.add(fileGet)), Group_exports.make("message").pipe(Group_exports.withName("Message"), Group_exports.add(messageDelete, messageEditText, messagePin, messageUnpin, messageSend, messageSendAnimation, messageSendAudio, messageSendChatAction, messageSendDocument, messageSendLocation, messageSendMediaGroup, messageSendPhoto, messageSendSticker, messageSendVideo)), updateTrigger));
1223
+
1224
+ // dist/channel/telegram-bot-definition.js
1225
+ var userKey = String3.check(isPattern(/^[1-9][0-9]{0,15}$/u));
1226
+ var chatKey = String3.check(isPattern(/^-?[1-9][0-9]{0,15}$/u));
1227
+ var groupScope = String3.check(isPattern(/^-[1-9][0-9]{0,15}(?:\/[1-9][0-9]{0,15})?$/u));
1228
+ var telegramBotToken = AuthMethod_exports.make("bot-token", {
1229
+ name: "Telegram bot token and webhook secret",
1230
+ schema: Struct({
1231
+ botToken: String3.check(isPattern(/^[0-9]+:[A-Za-z0-9_-]+$/u)),
1232
+ webhookSecret: String3.check(isPattern(/^[A-Za-z0-9_-]{1,256}$/u))
1233
+ })
1234
+ });
1235
+ var messagesDefinition = {
1236
+ authMethods: [telegramBotToken],
1237
+ definitionSettings: Record(String3, Never),
1238
+ deploymentSettings: Struct({
1239
+ chatIds: ArraySchema(groupScope).check(isMaxLength(1000)).annotate({
1240
+ description: "Group chat IDs (-100\u2026), or one forum topic as <chat ID>/<topic ID>, where the Agent can be activated. Leave empty for every group the bot is in.",
1241
+ title: "Groups and topics"
1242
+ }),
1243
+ directMessages: Boolean2.annotate({
1244
+ description: "Whether people can activate the Agent in a private chat with the bot.",
1245
+ title: "Direct messages"
1246
+ }),
1247
+ access: Literals(["open", "restricted"]).annotate({
1248
+ description: "Who can activate the Agent: anyone who can message the bot (open) or only the allowed people (restricted).",
1249
+ title: "Access"
1250
+ }),
1251
+ allowedSenderKeys: ArraySchema(userKey).check(isMaxLength(1000)).annotate({
1252
+ description: "Numeric Telegram user IDs who can activate the Agent when access is restricted.",
1253
+ title: "Allowed people"
1254
+ }),
1255
+ respondTo: Literals(["mentions", "all_messages"]).annotate({
1256
+ description: "Which group messages activate the Agent: only mentions, commands and replies to the bot, or every message in the chosen groups. Private chats always do.",
1257
+ title: "Respond to"
1258
+ })
1259
+ }),
1260
+ exposure: "webhook",
1261
+ features: {
1262
+ assets: false,
1263
+ deliveryMode: "at-most-once",
1264
+ deliveryState: false,
1265
+ directText: true,
1266
+ groups: true,
1267
+ maxTextLength: 4096,
1268
+ mentions: true,
1269
+ operations: [
1270
+ "present_outcome",
1271
+ "create_message",
1272
+ "update_message",
1273
+ "delete_message",
1274
+ "set_reaction",
1275
+ "set_activity"
1276
+ ],
1277
+ readContext: false,
1278
+ replies: true,
1279
+ threads: true
1280
+ },
1281
+ requiredChecks: ["access"],
1282
+ state: Struct({
1283
+ botId: userKey,
1284
+ botUsername: NonEmptyString,
1285
+ ingressUrl: String3,
1286
+ registrationUrl: String3
1287
+ })
1288
+ };
1289
+ var messagesChannel = AgentChannel_exports.make("messages", {
1290
+ ...messagesDefinition,
1291
+ description: "Telegram bot text messages in private chats and addressed groups, including forum topics.",
1292
+ name: "Telegram bot messages"
1293
+ });
1294
+ var telegramBotPluginBase = Plugin_exports.make("telegram").pipe(Plugin_exports.withName("Telegram Bot"), Plugin_exports.withDescription("A customer's Telegram bot, with its own token and webhook secret."), Plugin_exports.withAuthMethods([telegramBotToken]), Plugin_exports.withAgentChannel(messagesChannel));
1295
+
1296
+ // dist/definition.js
1297
+ var telegramPluginBase3 = telegramPluginBase2.pipe(Plugin_exports.withAuthMethod(telegramBotToken), Plugin_exports.withAgentChannel(messagesChannel));
1298
+ export { TelegramDefinition_exports, telegramAccessToken2, TelegramUpdateV22, TelegramUpdateConfigV22, telegramPluginBase2, userKey, chatKey, telegramBotToken, messagesChannel, telegramBotPluginBase, telegramPluginBase3 };
1299
+
1300
+ //# debugId=7FD15F6D13099C3664756E2164756E21
1301
+ //# sourceMappingURL=index-3ysdpnc6.js.map