@tool-bridge/server 0.21.1 → 0.22.1

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 (178) hide show
  1. package/dist/admin.js +170 -0
  2. package/dist/airtable-ML2GIGCH.js +790 -0
  3. package/dist/{alt_text_generator_ai-W7O34SNG.js → alt_text_generator_ai-FGYQAF2A.js} +12 -11
  4. package/dist/{amap-VOX4T2AW.js → amap-G7V65NGK.js} +221 -220
  5. package/dist/anthropic-6ZK24TBB.js +203 -0
  6. package/dist/apify-VDGYHP6W.js +248 -0
  7. package/dist/brave_search-TAATLZOS.js +302 -0
  8. package/dist/chunk-2IAI3XQM.js +302 -0
  9. package/dist/chunk-7ISGFRC6.js +161 -0
  10. package/dist/{chunk-E6JCVKW6.js → chunk-BNMLA2RC.js} +3 -3
  11. package/dist/chunk-HA4BGL6C.js +8429 -0
  12. package/dist/{chunk-KMTT3I6D.js → chunk-RMAWSG7E.js} +19172 -25717
  13. package/dist/{chunk-XYBU3WZH.js → chunk-RTW5VRTK.js} +3 -3
  14. package/dist/chunk-U7PTOA3U.js +7320 -0
  15. package/dist/chunk-UY6ANCOY.js +378 -0
  16. package/dist/{chunk-ATK45BXV.js → chunk-X7ZUTKHR.js} +4 -2
  17. package/dist/circleci-BQ2UWXL2.js +389 -0
  18. package/dist/clerk-2JYWQNOI.js +1019 -0
  19. package/dist/cohere-6MI7AQM4.js +185 -0
  20. package/dist/{confluence-B3EWPZVE.js → confluence-6Y6GDETF.js} +105 -104
  21. package/dist/{convertapi-EUWSQYPF.js → convertapi-HBZCSWOX.js} +32 -31
  22. package/dist/{currencyapi-KVTIK3GL.js → currencyapi-337U5TGI.js} +71 -71
  23. package/dist/deepseek-OSPASO7O.js +210 -0
  24. package/dist/docker_hub-3ATQOY5L.js +933 -0
  25. package/dist/dropbox-LSA4GM2Y.js +1305 -0
  26. package/dist/dub-VZPJSPI6.js +680 -0
  27. package/dist/e2b-6SDYQZL2.js +278 -0
  28. package/dist/exa-B6EUYDVP.js +332 -0
  29. package/dist/{fal_ai-23E7JPNT.js → fal_ai-K4Q27IME.js} +81 -80
  30. package/dist/{feishu-7QRIDUV6.js → feishu-4TKXG4SU.js} +528 -572
  31. package/dist/{feishu_custom_bot-TJ4K7QNJ.js → feishu_custom_bot-7CTEAKRB.js} +57 -53
  32. package/dist/figma-OUKSZLD5.js +777 -0
  33. package/dist/firehydrant-7MOYL7QH.js +563 -0
  34. package/dist/{fixer-BWON27UO.js → fixer-H2BV2NO4.js} +34 -33
  35. package/dist/fly-PXKY6PNH.js +469 -0
  36. package/dist/{front-QCGXYEDJ.js → front-UZYIV5DW.js} +104 -104
  37. package/dist/geocodio-NSYO7TFP.js +213 -0
  38. package/dist/ghost-QBKKQQMF.js +338 -0
  39. package/dist/github-ENLSJ4CL.js +5421 -0
  40. package/dist/gmail-KQSDEB47.js +1887 -0
  41. package/dist/googlecalendar-5YCX4SZF.js +2524 -0
  42. package/dist/{googledocs-BUHL4J2H.js → googledocs-SSWIVFKA.js} +341 -340
  43. package/dist/{grafana-GLU2DWF2.js → grafana-TF2LXDQA.js} +221 -220
  44. package/dist/graphhopper-CURBVHYK.js +325 -0
  45. package/dist/index.d.ts +1132 -332
  46. package/dist/index.js +31 -14
  47. package/dist/{ip2proxy-EZ64Y4ZH.js → ip2proxy-YNVMTZEM.js} +28 -27
  48. package/dist/ipgeolocation_io-NAU7VJ4J.js +315 -0
  49. package/dist/ipqualityscore-OT63L4TI.js +279 -0
  50. package/dist/{jina_ai-EFBHTBXL.js → jina_ai-6WBMBGWM.js} +23 -23
  51. package/dist/{jira-HQSHAA5K.js → jira-DVDVTHNO.js} +118 -117
  52. package/dist/langsmith-IM5N4YAU.js +593 -0
  53. package/dist/lemlist-277SHUQF.js +289 -0
  54. package/dist/{linear-K7RYFYAD.js → linear-AEPH7B5V.js} +327 -326
  55. package/dist/logsnag-VEWRAGBG.js +150 -0
  56. package/dist/main.js +57 -280
  57. package/dist/{mattermost-S2BRCWLQ.js → mattermost-Q3A2BIZA.js} +59 -58
  58. package/dist/mem0-AXS7GZGI.js +544 -0
  59. package/dist/memos-7TXG4ZTU.js +744 -0
  60. package/dist/{metabase-MMSEPCOF.js → metabase-NSVACWQM.js} +90 -89
  61. package/dist/mistral_ai-YZ52RGD4.js +1196 -0
  62. package/dist/{mother_duck-H7PCQNZ2.js → mother_duck-XLLL6FVL.js} +94 -93
  63. package/dist/ngrok-4O4W3WZW.js +356 -0
  64. package/dist/{notes-PFMKRO33.js → notes-YTB3TJOO.js} +11 -9
  65. package/dist/notion-4W4O7J7V.js +940 -0
  66. package/dist/open_exchange_rates-23QJXVO5.js +215 -0
  67. package/dist/openai-ZS7GLSLH.js +800 -0
  68. package/dist/opengraph_io-PMVH7OYI.js +362 -0
  69. package/dist/openrouter-ONRGFNB6.js +441 -0
  70. package/dist/outline-UCUYZZ7J.js +599 -0
  71. package/dist/paddle-35HTKTUL.js +454 -0
  72. package/dist/perplexity-NVOBYN24.js +220 -0
  73. package/dist/pinecone-55CJY73C.js +571 -0
  74. package/dist/{pipedrive-Y2O7QGFF.js → pipedrive-WMCAKS72.js} +99 -98
  75. package/dist/polar-SM4ZM53B.js +395 -0
  76. package/dist/posthog-NWCXVXNJ.js +3464 -0
  77. package/dist/postmark-QJV5PHUQ.js +427 -0
  78. package/dist/{prerender-MENYM2TY.js → prerender-2W7UT4SC.js} +31 -30
  79. package/dist/{pubmed-GOXUVVH5.js → pubmed-VVV7XYLU.js} +239 -238
  80. package/dist/{railway-V2SID4WV.js → railway-KGI57S3O.js} +118 -117
  81. package/dist/readwise-AGHTQB42.js +470 -0
  82. package/dist/render-O4HBROCK.js +461 -0
  83. package/dist/{replicate-756MXPYX.js → replicate-KWBOMX7D.js} +81 -80
  84. package/dist/{resend-ZKH3BTBI.js → resend-DRH6Y6I4.js} +20 -16
  85. package/dist/rootly-XGCUDW6X.js +336 -0
  86. package/dist/{scrapfly-NSRHFDIQ.js → scrapfly-OIQ3OY6L.js} +62 -61
  87. package/dist/{scrapingbee-OQHLAVEY.js → scrapingbee-OCZO4FHX.js} +56 -56
  88. package/dist/{screenshot_fyi-DVWG3AXC.js → screenshot_fyi-CUNGFZOC.js} +16 -16
  89. package/dist/semantic_scholar-3UJRLKES.js +611 -0
  90. package/dist/{sentry-546MNDJG.js → sentry-5BWVZFJV.js} +208 -207
  91. package/dist/{shodan-C3OON3Z3.js → shodan-HI37CTEW.js} +62 -61
  92. package/dist/shopify-LJ2EV2HH.js +610 -0
  93. package/dist/stripe-3LHMV55K.js +585 -0
  94. package/dist/{supabase-U2SL4D63.js → supabase-H2KPX3Q2.js} +245 -244
  95. package/dist/tavily-FBEWGH3Z.js +326 -0
  96. package/dist/telegram-MYYO3JND.js +1767 -0
  97. package/dist/{telnyx-CXQ4EZUX.js → telnyx-H4ALEGAX.js} +57 -56
  98. package/dist/todoist-OBWICA5Q.js +664 -0
  99. package/dist/trello-GUFUJRWO.js +1080 -0
  100. package/dist/turso-NIAK4UMS.js +416 -0
  101. package/dist/{twilio-4PDBJKWX.js → twilio-K6SLK2CX.js} +70 -69
  102. package/dist/umami-42RS2EPS.js +389 -0
  103. package/dist/unsplash-V7TOTETT.js +351 -0
  104. package/dist/{upstash_redis-G4LQBYHA.js → upstash_redis-AWQMB6Y3.js} +51 -50
  105. package/dist/uptimerobot-AZC2DHOT.js +483 -0
  106. package/dist/v2ex-4TVRNMLS.js +667 -0
  107. package/dist/vercel-DPHTJ3XR.js +1076 -0
  108. package/dist/{wolfram_alpha_api-3G4PUJWB.js → wolfram_alpha_api-XAG7IXBW.js} +36 -35
  109. package/dist/wordpress-KMPKVGUX.js +812 -0
  110. package/dist/workos-PKB2YR7S.js +664 -0
  111. package/dist/zhihu-Y4H4XYPB.js +254 -0
  112. package/package.json +18 -9
  113. package/dist/airtable-LLZDFN7M.js +0 -789
  114. package/dist/anthropic-G23NN3X5.js +0 -202
  115. package/dist/apify-Y3SS734K.js +0 -247
  116. package/dist/brave_search-ZC7OAPSZ.js +0 -301
  117. package/dist/chunk-R6P4XAE5.js +0 -248
  118. package/dist/chunk-U7B6DS2O.js +0 -977
  119. package/dist/chunk-UZM2RXZH.js +0 -23436
  120. package/dist/circleci-3BAX5FCG.js +0 -388
  121. package/dist/clerk-6LEM6TNU.js +0 -1019
  122. package/dist/cloudflare_dns-KINYTJUD.js +0 -588
  123. package/dist/cohere-XCJ5AJ6B.js +0 -185
  124. package/dist/deepseek-PC5YGNC5.js +0 -209
  125. package/dist/docker_hub-C3MA5FU6.js +0 -932
  126. package/dist/dropbox-XBV7Z2IR.js +0 -1304
  127. package/dist/dub-LDOFG3HC.js +0 -679
  128. package/dist/e2b-JMCPSVBW.js +0 -277
  129. package/dist/exa-RAK7O7RD.js +0 -331
  130. package/dist/figma-E6IX5DTH.js +0 -773
  131. package/dist/firehydrant-ZBLPQREE.js +0 -562
  132. package/dist/fly-ZH3HFCZJ.js +0 -468
  133. package/dist/geocodio-YGNI7DA4.js +0 -212
  134. package/dist/ghost-EVSGKH2Q.js +0 -337
  135. package/dist/github-MA2BGRCJ.js +0 -5420
  136. package/dist/gmail-E5E6AADE.js +0 -1886
  137. package/dist/googlecalendar-BTLFPXTD.js +0 -2523
  138. package/dist/graphhopper-WSMB3TCD.js +0 -324
  139. package/dist/ipgeolocation_io-AA7HAS22.js +0 -315
  140. package/dist/ipqualityscore-BHJXVTJT.js +0 -277
  141. package/dist/langsmith-5W6SCT6F.js +0 -592
  142. package/dist/lemlist-HJWH6UMK.js +0 -288
  143. package/dist/logsnag-4KFOHL37.js +0 -150
  144. package/dist/mem0-CAW43CIC.js +0 -543
  145. package/dist/memos-TWEGPKFM.js +0 -740
  146. package/dist/mistral_ai-64BGZQHP.js +0 -1195
  147. package/dist/ngrok-GQCUGZKJ.js +0 -356
  148. package/dist/notion-DQWZWP4N.js +0 -936
  149. package/dist/open_exchange_rates-QMMD735E.js +0 -214
  150. package/dist/openai-W6PX32NZ.js +0 -799
  151. package/dist/opengraph_io-HNDBXYNW.js +0 -361
  152. package/dist/openrouter-JJYMEAUL.js +0 -437
  153. package/dist/outline-MCBNQZYY.js +0 -595
  154. package/dist/paddle-D2SKLUDN.js +0 -453
  155. package/dist/perplexity-XIFMKUAE.js +0 -219
  156. package/dist/pinecone-HUFTALV2.js +0 -570
  157. package/dist/polar-TYTOMOSR.js +0 -394
  158. package/dist/posthog-43JAR3VW.js +0 -3463
  159. package/dist/postmark-KL2QJYSG.js +0 -426
  160. package/dist/readwise-CI4GIMMJ.js +0 -469
  161. package/dist/render-SUBJ6YRZ.js +0 -460
  162. package/dist/rootly-CD2LJHPI.js +0 -336
  163. package/dist/semantic_scholar-T4A252KW.js +0 -610
  164. package/dist/shopify-Y2HN2MCQ.js +0 -609
  165. package/dist/stripe-VE3CD3AY.js +0 -584
  166. package/dist/tavily-KCZHK6HE.js +0 -326
  167. package/dist/telegram-3URFBCMY.js +0 -1766
  168. package/dist/todoist-HNPWNYTD.js +0 -663
  169. package/dist/trello-3W2MIXRP.js +0 -1079
  170. package/dist/turso-2EQF7C2Z.js +0 -415
  171. package/dist/umami-5REN7TGP.js +0 -388
  172. package/dist/unsplash-EIXL424F.js +0 -350
  173. package/dist/uptimerobot-KNJ3EYLY.js +0 -482
  174. package/dist/v2ex-RHJ234PZ.js +0 -666
  175. package/dist/vercel-AS6NCIC7.js +0 -1075
  176. package/dist/wordpress-KNDAAUV7.js +0 -811
  177. package/dist/workos-R6UITSJ7.js +0 -663
  178. package/dist/zhihu-AGK4HILK.js +0 -253
@@ -0,0 +1,1767 @@
1
+ import {
2
+ createProviderHttpClient
3
+ } from "./chunk-BNMLA2RC.js";
4
+ import {
5
+ asJsonObject,
6
+ booleanValue,
7
+ compactDefined,
8
+ finiteNumber,
9
+ trimmedText
10
+ } from "./chunk-JXHMDBAY.js";
11
+ import {
12
+ createProviderPlugin,
13
+ requireApiKey,
14
+ upstreamError
15
+ } from "./chunk-X7ZUTKHR.js";
16
+ import {
17
+ assertPublicHttpUrl
18
+ } from "./chunk-7ISGFRC6.js";
19
+ import "./chunk-UY6ANCOY.js";
20
+ import {
21
+ TBError
22
+ } from "./chunk-HA4BGL6C.js";
23
+ import "./chunk-U67V476Y.js";
24
+
25
+ // ../plugins/src/telegram/api.ts
26
+ var SERVICE = "telegram";
27
+ var API_BASE = "https://api.telegram.org";
28
+ var REQUEST_TIMEOUT_MS = 3e4;
29
+ var http = createProviderHttpClient({ baseUrl: API_BASE, service: SERVICE });
30
+ function asRecord(value) {
31
+ const result = asJsonObject(value);
32
+ if (result === void 0) {
33
+ throw new TBError("unavailable", "Telegram \u8FD4\u56DE\u4E86\u975E\u9884\u671F\u7684\u5BF9\u8C61\u8D1F\u8F7D", { retryable: true });
34
+ }
35
+ return result;
36
+ }
37
+ function assertBotToken(botToken) {
38
+ if (botToken.length === 0 || /[/?#\s]/u.test(botToken)) {
39
+ throw new TBError("invalid_argument", "telegram bot token is malformed");
40
+ }
41
+ }
42
+ function methodUrl(botToken, method) {
43
+ assertBotToken(botToken);
44
+ return `${API_BASE}/bot${botToken}/${method}`;
45
+ }
46
+ function readEnvelope(response) {
47
+ if ((response.headers.get("content-type") ?? "").includes("application/json")) {
48
+ return response.bodyKind === "json" ? asJsonObject(response.data) ?? {} : {};
49
+ }
50
+ const body = typeof response.data === "string" ? response.data : "";
51
+ return {
52
+ ok: false,
53
+ description: body === "" ? `telegram request failed with ${response.status}` : body,
54
+ error_code: response.status
55
+ };
56
+ }
57
+ function telegramError(statusCode, responseOk, payload, method) {
58
+ const code = finiteNumber(payload.error_code) ?? (responseOk ? void 0 : statusCode);
59
+ const status = code ?? 502;
60
+ const description = trimmedText(payload.description) ?? `telegram ${method} request failed with ${status}`;
61
+ if (status === 429) {
62
+ const retryAfter = finiteNumber(asJsonObject(payload.parameters)?.retry_after);
63
+ return upstreamError(429, retryAfter === void 0 ? description : `${description} Retry after ${retryAfter} seconds.`);
64
+ }
65
+ return upstreamError(status, description);
66
+ }
67
+ async function request(ctx, method, body) {
68
+ const botToken = requireApiKey(ctx, SERVICE);
69
+ const result = await http.request({
70
+ path: methodUrl(botToken, method),
71
+ method: body === void 0 ? "GET" : "POST",
72
+ ...body === void 0 ? {} : { json: body },
73
+ responseType: "auto",
74
+ invalidJson: "text",
75
+ timeoutMs: REQUEST_TIMEOUT_MS,
76
+ sensitiveValues: [botToken],
77
+ mapError: (context) => {
78
+ const payload2 = readEnvelope(context);
79
+ return telegramError(context.status, false, payload2, method);
80
+ },
81
+ mapTransportError: ({ kind, message }) => kind === "timeout" ? upstreamError(504, `telegram ${method} \u8BF7\u6C42\u8D85\u65F6(${REQUEST_TIMEOUT_MS / 1e3} \u79D2)`) : upstreamError(502, `telegram ${method} \u8BF7\u6C42\u5931\u8D25: ${message ?? "\u672A\u77E5\u9519\u8BEF"}`)
82
+ });
83
+ const payload = readEnvelope(result);
84
+ if (payload.ok !== true) throw telegramError(result.status, true, payload, method);
85
+ if (payload.result === void 0) {
86
+ throw new TBError("unavailable", `telegram ${method} response did not include result`, { retryable: true });
87
+ }
88
+ return payload.result;
89
+ }
90
+ async function booleanAction(ctx, method, body) {
91
+ await request(ctx, method, body);
92
+ return { success: true };
93
+ }
94
+ function jsonLike(value) {
95
+ if (typeof value === "string") {
96
+ let parsed;
97
+ try {
98
+ parsed = JSON.parse(value);
99
+ } catch {
100
+ throw new TBError("invalid_argument", "invalid JSON string input");
101
+ }
102
+ const result = asJsonObject(parsed);
103
+ if (result === void 0) throw new TBError("invalid_argument", "JSON string input must decode to an object");
104
+ return result;
105
+ }
106
+ return asJsonObject(value);
107
+ }
108
+ function publicUrl(value) {
109
+ const candidate = trimmedText(value);
110
+ if (candidate === void 0) return void 0;
111
+ return assertPublicHttpUrl(candidate).toString();
112
+ }
113
+ function urlOrFileId(value) {
114
+ const candidate = trimmedText(value);
115
+ if (candidate === void 0 || !/^https?:\/\//iu.test(candidate)) return value;
116
+ return publicUrl(candidate);
117
+ }
118
+ function normalizeUser(value) {
119
+ return {
120
+ id: Number(value.id),
121
+ isBot: Boolean(value.is_bot),
122
+ firstName: String(value.first_name ?? ""),
123
+ username: trimmedText(value.username),
124
+ languageCode: trimmedText(value.language_code),
125
+ canJoinGroups: booleanValue(value.can_join_groups),
126
+ canReadAllGroupMessages: booleanValue(value.can_read_all_group_messages),
127
+ supportsInlineQueries: booleanValue(value.supports_inline_queries),
128
+ canConnectToBusiness: booleanValue(value.can_connect_to_business),
129
+ hasMainWebApp: booleanValue(value.has_main_web_app)
130
+ };
131
+ }
132
+ function normalizeChat(value) {
133
+ return {
134
+ id: Number(value.id),
135
+ type: String(value.type ?? ""),
136
+ title: trimmedText(value.title),
137
+ username: trimmedText(value.username),
138
+ firstName: trimmedText(value.first_name),
139
+ lastName: trimmedText(value.last_name),
140
+ isForum: booleanValue(value.is_forum)
141
+ };
142
+ }
143
+ function normalizePhotoSize(value) {
144
+ return {
145
+ fileId: String(value.file_id ?? ""),
146
+ fileUniqueId: String(value.file_unique_id ?? ""),
147
+ width: Number(value.width),
148
+ height: Number(value.height),
149
+ fileSize: finiteNumber(value.file_size)
150
+ };
151
+ }
152
+ function normalizeDocument(value) {
153
+ return {
154
+ fileId: String(value.file_id ?? ""),
155
+ fileUniqueId: String(value.file_unique_id ?? ""),
156
+ fileName: trimmedText(value.file_name),
157
+ mimeType: trimmedText(value.mime_type),
158
+ fileSize: finiteNumber(value.file_size)
159
+ };
160
+ }
161
+ function normalizeVideoQuality(value) {
162
+ return {
163
+ fileId: String(value.file_id ?? ""),
164
+ fileUniqueId: String(value.file_unique_id ?? ""),
165
+ width: Number(value.width),
166
+ height: Number(value.height),
167
+ codec: String(value.codec ?? ""),
168
+ fileSize: finiteNumber(value.file_size)
169
+ };
170
+ }
171
+ function normalizeVideo(value) {
172
+ return {
173
+ fileId: String(value.file_id ?? ""),
174
+ fileUniqueId: String(value.file_unique_id ?? ""),
175
+ width: Number(value.width),
176
+ height: Number(value.height),
177
+ duration: Number(value.duration),
178
+ thumbnail: value.thumbnail ? normalizePhotoSize(asRecord(value.thumbnail)) : void 0,
179
+ cover: Array.isArray(value.cover) ? value.cover.map((item) => normalizePhotoSize(asRecord(item))) : void 0,
180
+ startTimestamp: finiteNumber(value.start_timestamp),
181
+ qualities: Array.isArray(value.qualities) ? value.qualities.map((item) => normalizeVideoQuality(asRecord(item))) : void 0,
182
+ fileName: trimmedText(value.file_name),
183
+ mimeType: trimmedText(value.mime_type),
184
+ fileSize: finiteNumber(value.file_size)
185
+ };
186
+ }
187
+ function normalizeAudio(value) {
188
+ return {
189
+ fileId: String(value.file_id ?? ""),
190
+ fileUniqueId: String(value.file_unique_id ?? ""),
191
+ duration: Number(value.duration),
192
+ performer: trimmedText(value.performer),
193
+ title: trimmedText(value.title),
194
+ fileName: trimmedText(value.file_name),
195
+ mimeType: trimmedText(value.mime_type),
196
+ fileSize: finiteNumber(value.file_size),
197
+ thumbnail: value.thumbnail ? normalizePhotoSize(asRecord(value.thumbnail)) : void 0
198
+ };
199
+ }
200
+ function normalizeVoice(value) {
201
+ return {
202
+ fileId: String(value.file_id ?? ""),
203
+ fileUniqueId: String(value.file_unique_id ?? ""),
204
+ duration: Number(value.duration),
205
+ mimeType: trimmedText(value.mime_type),
206
+ fileSize: finiteNumber(value.file_size)
207
+ };
208
+ }
209
+ function normalizeAnimation(value) {
210
+ return {
211
+ fileId: String(value.file_id ?? ""),
212
+ fileUniqueId: String(value.file_unique_id ?? ""),
213
+ width: Number(value.width),
214
+ height: Number(value.height),
215
+ duration: Number(value.duration),
216
+ thumbnail: value.thumbnail ? normalizePhotoSize(asRecord(value.thumbnail)) : void 0,
217
+ fileName: trimmedText(value.file_name),
218
+ mimeType: trimmedText(value.mime_type),
219
+ fileSize: finiteNumber(value.file_size)
220
+ };
221
+ }
222
+ function normalizeContact(value) {
223
+ return {
224
+ phoneNumber: String(value.phone_number ?? ""),
225
+ firstName: String(value.first_name ?? ""),
226
+ lastName: trimmedText(value.last_name),
227
+ userId: finiteNumber(value.user_id),
228
+ vcard: trimmedText(value.vcard)
229
+ };
230
+ }
231
+ function normalizeLocation(value) {
232
+ return {
233
+ latitude: Number(value.latitude),
234
+ longitude: Number(value.longitude),
235
+ horizontalAccuracy: finiteNumber(value.horizontal_accuracy),
236
+ livePeriod: finiteNumber(value.live_period),
237
+ heading: finiteNumber(value.heading),
238
+ proximityAlertRadius: finiteNumber(value.proximity_alert_radius)
239
+ };
240
+ }
241
+ function normalizeVenue(value) {
242
+ return {
243
+ location: normalizeLocation(asRecord(value.location)),
244
+ title: String(value.title ?? ""),
245
+ address: String(value.address ?? ""),
246
+ foursquareId: trimmedText(value.foursquare_id),
247
+ foursquareType: trimmedText(value.foursquare_type),
248
+ googlePlaceId: trimmedText(value.google_place_id),
249
+ googlePlaceType: trimmedText(value.google_place_type)
250
+ };
251
+ }
252
+ function normalizeDice(value) {
253
+ return {
254
+ emoji: String(value.emoji ?? ""),
255
+ value: Number(value.value)
256
+ };
257
+ }
258
+ function normalizePoll(value) {
259
+ return {
260
+ id: String(value.id ?? ""),
261
+ question: String(value.question ?? ""),
262
+ options: Array.isArray(value.options) ? value.options.map((option) => ({
263
+ text: String(asRecord(option).text ?? ""),
264
+ voterCount: Number(asRecord(option).voter_count ?? 0)
265
+ })) : [],
266
+ totalVoterCount: Number(value.total_voter_count ?? 0),
267
+ isClosed: Boolean(value.is_closed),
268
+ isAnonymous: Boolean(value.is_anonymous),
269
+ type: value.type === "quiz" ? "quiz" : "regular",
270
+ allowsMultipleAnswers: Boolean(value.allows_multiple_answers),
271
+ closeDate: finiteNumber(value.close_date),
272
+ openPeriod: finiteNumber(value.open_period),
273
+ explanation: trimmedText(value.explanation),
274
+ correctOptionId: finiteNumber(value.correct_option_id)
275
+ };
276
+ }
277
+ function normalizeMessage(value) {
278
+ return {
279
+ messageId: Number(value.message_id),
280
+ date: Number(value.date),
281
+ chat: normalizeChat(asRecord(value.chat)),
282
+ from: value.from ? normalizeUser(asRecord(value.from)) : void 0,
283
+ senderChat: value.sender_chat ? normalizeChat(asRecord(value.sender_chat)) : void 0,
284
+ text: trimmedText(value.text),
285
+ caption: trimmedText(value.caption),
286
+ photo: Array.isArray(value.photo) ? value.photo.map((item) => normalizePhotoSize(asRecord(item))) : void 0,
287
+ document: value.document ? normalizeDocument(asRecord(value.document)) : void 0,
288
+ location: value.location ? normalizeLocation(asRecord(value.location)) : void 0,
289
+ poll: value.poll ? normalizePoll(asRecord(value.poll)) : void 0,
290
+ entities: Array.isArray(value.entities) ? value.entities.map((item) => asRecord(item)) : void 0,
291
+ captionEntities: Array.isArray(value.caption_entities) ? value.caption_entities.map((item) => asRecord(item)) : void 0,
292
+ forwardDate: finiteNumber(value.forward_date),
293
+ forwardFrom: value.forward_from ? normalizeUser(asRecord(value.forward_from)) : void 0,
294
+ forwardFromChat: value.forward_from_chat ? normalizeChat(asRecord(value.forward_from_chat)) : void 0,
295
+ forwardFromMessageId: finiteNumber(value.forward_from_message_id),
296
+ forwardSignature: trimmedText(value.forward_signature),
297
+ forwardSenderName: trimmedText(value.forward_sender_name),
298
+ linkPreviewOptions: value.link_preview_options ? asRecord(value.link_preview_options) : void 0,
299
+ businessConnectionId: trimmedText(value.business_connection_id),
300
+ video: value.video ? normalizeVideo(asRecord(value.video)) : void 0,
301
+ audio: value.audio ? normalizeAudio(asRecord(value.audio)) : void 0,
302
+ voice: value.voice ? normalizeVoice(asRecord(value.voice)) : void 0,
303
+ animation: value.animation ? normalizeAnimation(asRecord(value.animation)) : void 0,
304
+ contact: value.contact ? normalizeContact(asRecord(value.contact)) : void 0,
305
+ venue: value.venue ? normalizeVenue(asRecord(value.venue)) : void 0,
306
+ dice: value.dice ? normalizeDice(asRecord(value.dice)) : void 0
307
+ };
308
+ }
309
+ function normalizeBusinessBotRights(value) {
310
+ return {
311
+ canReply: booleanValue(value.can_reply),
312
+ canReadMessages: booleanValue(value.can_read_messages),
313
+ canDeleteSentMessages: booleanValue(value.can_delete_sent_messages),
314
+ canDeleteAllMessages: booleanValue(value.can_delete_all_messages),
315
+ canEditName: booleanValue(value.can_edit_name),
316
+ canEditBio: booleanValue(value.can_edit_bio),
317
+ canEditProfilePhoto: booleanValue(value.can_edit_profile_photo),
318
+ canEditUsername: booleanValue(value.can_edit_username),
319
+ canChangeGiftSettings: booleanValue(value.can_change_gift_settings),
320
+ canViewGiftsAndStars: booleanValue(value.can_view_gifts_and_stars),
321
+ canConvertGiftsToStars: booleanValue(value.can_convert_gifts_to_stars),
322
+ canTransferAndUpgradeGifts: booleanValue(value.can_transfer_and_upgrade_gifts),
323
+ canTransferStars: booleanValue(value.can_transfer_stars),
324
+ canManageStories: booleanValue(value.can_manage_stories)
325
+ };
326
+ }
327
+ function normalizeBusinessConnection(value) {
328
+ return {
329
+ id: String(value.id ?? ""),
330
+ user: normalizeUser(asRecord(value.user)),
331
+ userChatId: Number(value.user_chat_id),
332
+ date: Number(value.date),
333
+ rights: value.rights ? normalizeBusinessBotRights(asRecord(value.rights)) : void 0,
334
+ isEnabled: Boolean(value.is_enabled)
335
+ };
336
+ }
337
+ function normalizeBusinessMessagesDeleted(value) {
338
+ return {
339
+ businessConnectionId: String(value.business_connection_id ?? ""),
340
+ chat: normalizeChat(asRecord(value.chat)),
341
+ messageIds: Array.isArray(value.message_ids) ? value.message_ids.map((id) => Number(id)) : []
342
+ };
343
+ }
344
+ function normalizeUpdate(value) {
345
+ return {
346
+ updateId: Number(value.update_id),
347
+ message: value.message ? normalizeMessage(asRecord(value.message)) : void 0,
348
+ editedMessage: value.edited_message ? normalizeMessage(asRecord(value.edited_message)) : void 0,
349
+ channelPost: value.channel_post ? normalizeMessage(asRecord(value.channel_post)) : void 0,
350
+ editedChannelPost: value.edited_channel_post ? normalizeMessage(asRecord(value.edited_channel_post)) : void 0,
351
+ callbackQuery: value.callback_query ? asRecord(value.callback_query) : void 0,
352
+ businessConnection: value.business_connection ? normalizeBusinessConnection(asRecord(value.business_connection)) : void 0,
353
+ businessMessage: value.business_message ? normalizeMessage(asRecord(value.business_message)) : void 0,
354
+ editedBusinessMessage: value.edited_business_message ? normalizeMessage(asRecord(value.edited_business_message)) : void 0,
355
+ deletedBusinessMessages: value.deleted_business_messages ? normalizeBusinessMessagesDeleted(asRecord(value.deleted_business_messages)) : void 0
356
+ };
357
+ }
358
+ function normalizeWebhookInfo(value) {
359
+ return {
360
+ url: String(value.url ?? ""),
361
+ hasCustomCertificate: Boolean(value.has_custom_certificate),
362
+ pendingUpdateCount: Number(value.pending_update_count ?? 0),
363
+ ipAddress: trimmedText(value.ip_address),
364
+ lastErrorDate: finiteNumber(value.last_error_date),
365
+ lastErrorMessage: trimmedText(value.last_error_message),
366
+ lastSynchronizationErrorDate: finiteNumber(value.last_synchronization_error_date),
367
+ maxConnections: finiteNumber(value.max_connections),
368
+ allowedUpdates: Array.isArray(value.allowed_updates) ? value.allowed_updates.map((item) => String(item)) : void 0
369
+ };
370
+ }
371
+ function normalizeChatMember(value) {
372
+ return {
373
+ status: String(value.status ?? ""),
374
+ user: normalizeUser(asRecord(value.user)),
375
+ customTitle: trimmedText(value.custom_title),
376
+ isAnonymous: booleanValue(value.is_anonymous),
377
+ untilDate: finiteNumber(value.until_date),
378
+ canBeEdited: booleanValue(value.can_be_edited),
379
+ canChangeInfo: booleanValue(value.can_change_info),
380
+ canManageChat: booleanValue(value.can_manage_chat),
381
+ canInviteUsers: booleanValue(value.can_invite_users),
382
+ canPinMessages: booleanValue(value.can_pin_messages),
383
+ canEditMessages: booleanValue(value.can_edit_messages),
384
+ canPostMessages: booleanValue(value.can_post_messages),
385
+ canDeleteMessages: booleanValue(value.can_delete_messages),
386
+ canPromoteMembers: booleanValue(value.can_promote_members),
387
+ canRestrictMembers: booleanValue(value.can_restrict_members),
388
+ canManageVideoChats: booleanValue(value.can_manage_video_chats),
389
+ canManageTopics: booleanValue(value.can_manage_topics)
390
+ };
391
+ }
392
+ function normalizeChatPermissions(value) {
393
+ const permissions = asRecord(value);
394
+ return compactDefined({
395
+ can_send_messages: permissions.canSendMessages,
396
+ can_send_audios: permissions.canSendAudios,
397
+ can_send_documents: permissions.canSendDocuments,
398
+ can_send_photos: permissions.canSendPhotos,
399
+ can_send_videos: permissions.canSendVideos,
400
+ can_send_video_notes: permissions.canSendVideoNotes,
401
+ can_send_voice_notes: permissions.canSendVoiceNotes,
402
+ can_send_polls: permissions.canSendPolls,
403
+ can_send_other_messages: permissions.canSendOtherMessages,
404
+ can_add_web_page_previews: permissions.canAddWebPagePreviews,
405
+ can_change_info: permissions.canChangeInfo,
406
+ can_invite_users: permissions.canInviteUsers,
407
+ can_pin_messages: permissions.canPinMessages,
408
+ can_manage_topics: permissions.canManageTopics
409
+ });
410
+ }
411
+ function normalizeChatInviteLink(value) {
412
+ return {
413
+ inviteLink: String(value.invite_link ?? ""),
414
+ creator: normalizeUser(asRecord(value.creator)),
415
+ createsJoinRequest: Boolean(value.creates_join_request),
416
+ isPrimary: Boolean(value.is_primary),
417
+ isRevoked: Boolean(value.is_revoked),
418
+ name: trimmedText(value.name),
419
+ expireDate: finiteNumber(value.expire_date),
420
+ memberLimit: finiteNumber(value.member_limit),
421
+ pendingJoinRequestCount: finiteNumber(value.pending_join_request_count),
422
+ subscriptionPeriod: finiteNumber(value.subscription_period),
423
+ subscriptionPrice: finiteNumber(value.subscription_price)
424
+ };
425
+ }
426
+ function assertIncreasingMessageIds(value) {
427
+ const increasing = value.every((id, index) => index === 0 || value[index - 1] < id);
428
+ if (!increasing) throw new TBError("invalid_argument", "messageIds must be in strictly increasing order");
429
+ }
430
+ function assertEditMessageTarget(input) {
431
+ const hasInlineTarget = input.inlineMessageId != null;
432
+ const hasChatTarget = input.chatId != null || input.messageId != null;
433
+ if (hasInlineTarget && hasChatTarget) {
434
+ throw new TBError("invalid_argument", "edit_message_text accepts either inlineMessageId or chatId/messageId");
435
+ }
436
+ if (!hasInlineTarget && !(input.chatId != null && input.messageId != null)) {
437
+ throw new TBError("invalid_argument", "edit_message_text requires inlineMessageId or chatId with messageId");
438
+ }
439
+ }
440
+ async function getMe(_input, ctx) {
441
+ return normalizeUser(asRecord(await request(ctx, "getMe")));
442
+ }
443
+ async function getWebhookInfo(_input, ctx) {
444
+ return normalizeWebhookInfo(asRecord(await request(ctx, "getWebhookInfo")));
445
+ }
446
+ function asArray(value) {
447
+ if (!Array.isArray(value)) {
448
+ throw new TBError("unavailable", "Telegram \u8FD4\u56DE\u4E86\u975E\u9884\u671F\u7684\u6570\u7EC4\u8D1F\u8F7D", { retryable: true });
449
+ }
450
+ return value;
451
+ }
452
+ async function getUpdates(input, ctx) {
453
+ const result = await request(ctx, "getUpdates", compactDefined({
454
+ offset: input.offset,
455
+ limit: input.limit,
456
+ timeout: input.timeout,
457
+ allowed_updates: input.allowedUpdates
458
+ }));
459
+ return { updates: asArray(result).map((update) => normalizeUpdate(asRecord(update))) };
460
+ }
461
+ async function sendMessage(input, ctx) {
462
+ const result = await request(ctx, "sendMessage", compactDefined({
463
+ business_connection_id: input.businessConnectionId,
464
+ chat_id: input.chatId,
465
+ text: input.text,
466
+ parse_mode: input.parseMode,
467
+ disable_notification: input.disableNotification,
468
+ protect_content: input.protectContent,
469
+ message_thread_id: input.messageThreadId,
470
+ // Bot API 已经把 reply_to_message_id / disable_web_page_preview 换成了嵌套对象,
471
+ // 入参保留扁平写法是为了好用,转换只能在这里做。
472
+ reply_parameters: input.replyToMessageId != null ? { message_id: input.replyToMessageId } : void 0,
473
+ link_preview_options: input.disableWebPagePreview === true ? { is_disabled: true } : void 0
474
+ }));
475
+ return normalizeMessage(asRecord(result));
476
+ }
477
+ async function copyMessage(input, ctx) {
478
+ const result = asRecord(await request(ctx, "copyMessage", compactDefined({
479
+ chat_id: input.chatId,
480
+ from_chat_id: input.fromChatId,
481
+ message_id: input.messageId,
482
+ message_thread_id: input.messageThreadId,
483
+ caption: input.caption,
484
+ parse_mode: input.parseMode,
485
+ show_caption_above_media: input.showCaptionAboveMedia,
486
+ disable_notification: input.disableNotification,
487
+ protect_content: input.protectContent
488
+ })));
489
+ return { messageId: Number(result.message_id) };
490
+ }
491
+ async function transferMessages(ctx, method, input) {
492
+ assertIncreasingMessageIds(input.messageIds);
493
+ const result = await request(ctx, method, compactDefined({
494
+ chat_id: input.chatId,
495
+ from_chat_id: input.fromChatId,
496
+ message_ids: input.messageIds,
497
+ message_thread_id: input.messageThreadId,
498
+ disable_notification: input.disableNotification,
499
+ protect_content: input.protectContent,
500
+ remove_caption: method === "copyMessages" ? input.removeCaption : void 0
501
+ }));
502
+ return { messageIds: asArray(result).map((message) => Number(asRecord(message).message_id)) };
503
+ }
504
+ function copyMessages(input, ctx) {
505
+ return transferMessages(ctx, "copyMessages", input);
506
+ }
507
+ function forwardMessages(input, ctx) {
508
+ return transferMessages(ctx, "forwardMessages", input);
509
+ }
510
+ function deleteMessages(input, ctx) {
511
+ return booleanAction(ctx, "deleteMessages", {
512
+ chat_id: input.chatId,
513
+ message_ids: input.messageIds
514
+ });
515
+ }
516
+ function setMessageReaction(input, ctx) {
517
+ return booleanAction(ctx, "setMessageReaction", compactDefined({
518
+ chat_id: input.chatId,
519
+ message_id: input.messageId,
520
+ reaction: input.reaction,
521
+ is_big: input.isBig
522
+ }));
523
+ }
524
+ function sendChatAction(input, ctx) {
525
+ return booleanAction(ctx, "sendChatAction", compactDefined({
526
+ business_connection_id: input.businessConnectionId,
527
+ chat_id: input.chatId,
528
+ message_thread_id: input.messageThreadId,
529
+ action: input.action
530
+ }));
531
+ }
532
+ async function sendMedia(ctx, method, field, input) {
533
+ const source = input;
534
+ const result = await request(ctx, method, compactDefined({
535
+ business_connection_id: input.businessConnectionId,
536
+ chat_id: input.chatId,
537
+ message_thread_id: input.messageThreadId,
538
+ [field]: urlOrFileId(source[field]),
539
+ caption: source.caption,
540
+ parse_mode: source.parseMode,
541
+ duration: source.duration,
542
+ width: source.width,
543
+ height: source.height,
544
+ performer: source.performer,
545
+ title: source.title,
546
+ cover: urlOrFileId(source.cover),
547
+ start_timestamp: source.startTimestamp,
548
+ show_caption_above_media: source.showCaptionAboveMedia,
549
+ has_spoiler: source.hasSpoiler,
550
+ supports_streaming: source.supportsStreaming,
551
+ disable_notification: input.disableNotification,
552
+ protect_content: input.protectContent
553
+ }));
554
+ return normalizeMessage(asRecord(result));
555
+ }
556
+ function sendVideo(input, ctx) {
557
+ return sendMedia(ctx, "sendVideo", "video", input);
558
+ }
559
+ function sendAudio(input, ctx) {
560
+ return sendMedia(ctx, "sendAudio", "audio", input);
561
+ }
562
+ function sendVoice(input, ctx) {
563
+ return sendMedia(ctx, "sendVoice", "voice", input);
564
+ }
565
+ function sendAnimation(input, ctx) {
566
+ return sendMedia(ctx, "sendAnimation", "animation", input);
567
+ }
568
+ async function sendMediaGroup(input, ctx) {
569
+ const result = await request(ctx, "sendMediaGroup", compactDefined({
570
+ business_connection_id: input.businessConnectionId,
571
+ chat_id: input.chatId,
572
+ message_thread_id: input.messageThreadId,
573
+ media: input.media,
574
+ disable_notification: input.disableNotification,
575
+ protect_content: input.protectContent
576
+ }));
577
+ return { messages: asArray(result).map((message) => normalizeMessage(asRecord(message))) };
578
+ }
579
+ async function sendStructuredMessage(ctx, method, fields, input) {
580
+ const result = await request(ctx, method, compactDefined({
581
+ business_connection_id: input.businessConnectionId,
582
+ chat_id: input.chatId,
583
+ message_thread_id: input.messageThreadId,
584
+ ...fields,
585
+ disable_notification: input.disableNotification,
586
+ protect_content: input.protectContent
587
+ }));
588
+ return normalizeMessage(asRecord(result));
589
+ }
590
+ function sendContact(input, ctx) {
591
+ return sendStructuredMessage(ctx, "sendContact", {
592
+ phone_number: input.phoneNumber,
593
+ first_name: input.firstName,
594
+ last_name: input.lastName,
595
+ vcard: input.vcard
596
+ }, input);
597
+ }
598
+ function sendVenue(input, ctx) {
599
+ return sendStructuredMessage(ctx, "sendVenue", {
600
+ latitude: input.latitude,
601
+ longitude: input.longitude,
602
+ title: input.title,
603
+ address: input.address,
604
+ foursquare_id: input.foursquareId,
605
+ foursquare_type: input.foursquareType,
606
+ google_place_id: input.googlePlaceId,
607
+ google_place_type: input.googlePlaceType
608
+ }, input);
609
+ }
610
+ function sendDice(input, ctx) {
611
+ return sendStructuredMessage(ctx, "sendDice", { emoji: input.emoji }, input);
612
+ }
613
+ async function getBusinessConnection(input, ctx) {
614
+ const result = await request(ctx, "getBusinessConnection", {
615
+ business_connection_id: input.businessConnectionId
616
+ });
617
+ return normalizeBusinessConnection(asRecord(result));
618
+ }
619
+ function readBusinessMessage(input, ctx) {
620
+ return booleanAction(ctx, "readBusinessMessage", {
621
+ business_connection_id: input.businessConnectionId,
622
+ chat_id: input.chatId,
623
+ message_id: input.messageId
624
+ });
625
+ }
626
+ function deleteBusinessMessages(input, ctx) {
627
+ return booleanAction(ctx, "deleteBusinessMessages", {
628
+ business_connection_id: input.businessConnectionId,
629
+ message_ids: input.messageIds
630
+ });
631
+ }
632
+ async function editMessageText(input, ctx) {
633
+ assertEditMessageTarget(input);
634
+ const result = await request(ctx, "editMessageText", compactDefined({
635
+ chat_id: input.chatId,
636
+ message_id: input.messageId,
637
+ inline_message_id: input.inlineMessageId,
638
+ text: input.text,
639
+ parse_mode: input.parseMode,
640
+ link_preview_options: input.disableWebPagePreview === true ? { is_disabled: true } : void 0
641
+ }));
642
+ if (result === true) {
643
+ return { edited: true, message: null, inlineMessageId: trimmedText(input.inlineMessageId) ?? null };
644
+ }
645
+ return { edited: true, message: normalizeMessage(asRecord(result)), inlineMessageId: null };
646
+ }
647
+ async function sendPhoto(input, ctx) {
648
+ const result = await request(ctx, "sendPhoto", compactDefined({
649
+ chat_id: input.chatId,
650
+ photo: urlOrFileId(input.photo),
651
+ caption: input.caption,
652
+ parse_mode: input.parseMode,
653
+ disable_notification: input.disableNotification,
654
+ protect_content: input.protectContent,
655
+ message_thread_id: input.messageThreadId,
656
+ reply_parameters: input.replyToMessageId != null ? { message_id: input.replyToMessageId } : void 0
657
+ }));
658
+ return normalizeMessage(asRecord(result));
659
+ }
660
+ async function sendDocument(input, ctx) {
661
+ const result = await request(ctx, "sendDocument", compactDefined({
662
+ chat_id: input.chatId,
663
+ document: urlOrFileId(input.document),
664
+ caption: input.caption,
665
+ parse_mode: input.parseMode,
666
+ thumbnail: urlOrFileId(input.thumbnail),
667
+ reply_markup: jsonLike(input.replyMarkup),
668
+ reply_to_message_id: input.replyToMessageId,
669
+ disable_notification: input.disableNotification,
670
+ disable_content_type_detection: input.disableContentTypeDetection
671
+ }));
672
+ return normalizeMessage(asRecord(result));
673
+ }
674
+ async function sendPoll(input, ctx) {
675
+ if (input.openPeriod != null && input.closeDate != null) {
676
+ throw new TBError("invalid_argument", "send_poll accepts only one of openPeriod or closeDate");
677
+ }
678
+ if (input.type === "quiz" && input.correctOptionId == null) {
679
+ throw new TBError("invalid_argument", "send_poll quiz polls require correctOptionId");
680
+ }
681
+ const result = await request(ctx, "sendPoll", compactDefined({
682
+ chat_id: input.chatId,
683
+ question: input.question,
684
+ options: input.options,
685
+ type: input.type,
686
+ is_anonymous: input.isAnonymous,
687
+ allows_multiple_answers: input.allowsMultipleAnswers,
688
+ correct_option_id: input.correctOptionId,
689
+ explanation: input.explanation,
690
+ explanation_parse_mode: input.explanationParseMode,
691
+ open_period: input.openPeriod,
692
+ close_date: input.closeDate,
693
+ is_closed: input.isClosed,
694
+ disable_notification: input.disableNotification,
695
+ reply_to_message_id: input.replyToMessageId,
696
+ reply_markup: jsonLike(input.replyMarkup)
697
+ }));
698
+ return normalizeMessage(asRecord(result));
699
+ }
700
+ async function getChat(input, ctx) {
701
+ return normalizeChat(asRecord(await request(ctx, "getChat", { chat_id: input.chatId })));
702
+ }
703
+ async function getChatMember(input, ctx) {
704
+ const result = await request(ctx, "getChatMember", { chat_id: input.chatId, user_id: input.userId });
705
+ return normalizeChatMember(asRecord(result));
706
+ }
707
+ async function getChatAdministrators(input, ctx) {
708
+ const result = await request(ctx, "getChatAdministrators", { chat_id: input.chatId });
709
+ return { administrators: asArray(result).map((member) => normalizeChatMember(asRecord(member))) };
710
+ }
711
+ async function getChatMembersCount(input, ctx) {
712
+ const result = await request(ctx, "getChatMemberCount", { chat_id: input.chatId });
713
+ const count = finiteNumber(result);
714
+ if (count === void 0) {
715
+ throw new TBError("unavailable", "Telegram \u7684\u6210\u5458\u6570\u4E0D\u662F\u4E00\u4E2A\u6570\u5B57", { retryable: true });
716
+ }
717
+ return { memberCount: count };
718
+ }
719
+ function banChatMember(input, ctx) {
720
+ return booleanAction(ctx, "banChatMember", compactDefined({
721
+ chat_id: input.chatId,
722
+ user_id: input.userId,
723
+ until_date: input.untilDate,
724
+ revoke_messages: input.revokeMessages
725
+ }));
726
+ }
727
+ function unbanChatMember(input, ctx) {
728
+ return booleanAction(ctx, "unbanChatMember", compactDefined({
729
+ chat_id: input.chatId,
730
+ user_id: input.userId,
731
+ only_if_banned: input.onlyIfBanned
732
+ }));
733
+ }
734
+ function restrictChatMember(input, ctx) {
735
+ return booleanAction(ctx, "restrictChatMember", compactDefined({
736
+ chat_id: input.chatId,
737
+ user_id: input.userId,
738
+ permissions: normalizeChatPermissions(input.permissions),
739
+ use_independent_chat_permissions: input.useIndependentChatPermissions,
740
+ until_date: input.untilDate
741
+ }));
742
+ }
743
+ function promoteChatMember(input, ctx) {
744
+ return booleanAction(ctx, "promoteChatMember", compactDefined({
745
+ chat_id: input.chatId,
746
+ user_id: input.userId,
747
+ is_anonymous: input.isAnonymous,
748
+ can_manage_chat: input.canManageChat,
749
+ can_delete_messages: input.canDeleteMessages,
750
+ can_manage_video_chats: input.canManageVideoChats,
751
+ can_restrict_members: input.canRestrictMembers,
752
+ can_promote_members: input.canPromoteMembers,
753
+ can_change_info: input.canChangeInfo,
754
+ can_invite_users: input.canInviteUsers,
755
+ can_post_stories: input.canPostStories,
756
+ can_edit_stories: input.canEditStories,
757
+ can_delete_stories: input.canDeleteStories,
758
+ can_post_messages: input.canPostMessages,
759
+ can_edit_messages: input.canEditMessages,
760
+ can_pin_messages: input.canPinMessages,
761
+ can_manage_topics: input.canManageTopics,
762
+ can_manage_direct_messages: input.canManageDirectMessages,
763
+ can_manage_tags: input.canManageTags
764
+ }));
765
+ }
766
+ function setChatPermissions(input, ctx) {
767
+ return booleanAction(ctx, "setChatPermissions", compactDefined({
768
+ chat_id: input.chatId,
769
+ permissions: normalizeChatPermissions(input.permissions),
770
+ use_independent_chat_permissions: input.useIndependentChatPermissions
771
+ }));
772
+ }
773
+ function pinChatMessage(input, ctx) {
774
+ return booleanAction(ctx, "pinChatMessage", compactDefined({
775
+ business_connection_id: input.businessConnectionId,
776
+ chat_id: input.chatId,
777
+ message_id: input.messageId,
778
+ disable_notification: input.disableNotification
779
+ }));
780
+ }
781
+ function unpinChatMessage(input, ctx) {
782
+ return booleanAction(ctx, "unpinChatMessage", compactDefined({
783
+ business_connection_id: input.businessConnectionId,
784
+ chat_id: input.chatId,
785
+ message_id: input.messageId
786
+ }));
787
+ }
788
+ function unpinAllChatMessages(input, ctx) {
789
+ return booleanAction(ctx, "unpinAllChatMessages", { chat_id: input.chatId });
790
+ }
791
+ function approveChatJoinRequest(input, ctx) {
792
+ return booleanAction(ctx, "approveChatJoinRequest", { chat_id: input.chatId, user_id: input.userId });
793
+ }
794
+ function declineChatJoinRequest(input, ctx) {
795
+ return booleanAction(ctx, "declineChatJoinRequest", { chat_id: input.chatId, user_id: input.userId });
796
+ }
797
+ function deleteMessage(input, ctx) {
798
+ return booleanAction(ctx, "deleteMessage", { chat_id: input.chatId, message_id: input.messageId });
799
+ }
800
+ async function forwardMessage(input, ctx) {
801
+ const result = await request(ctx, "forwardMessage", compactDefined({
802
+ chat_id: input.chatId,
803
+ from_chat_id: input.fromChatId,
804
+ message_id: input.messageId,
805
+ disable_notification: input.disableNotification
806
+ }));
807
+ return normalizeMessage(asRecord(result));
808
+ }
809
+ async function sendLocation(input, ctx) {
810
+ const result = await request(ctx, "sendLocation", compactDefined({
811
+ chat_id: input.chatId,
812
+ latitude: input.latitude,
813
+ longitude: input.longitude,
814
+ horizontal_accuracy: input.horizontalAccuracy,
815
+ live_period: input.livePeriod,
816
+ heading: input.heading,
817
+ proximity_alert_radius: input.proximityAlertRadius,
818
+ disable_notification: input.disableNotification,
819
+ reply_to_message_id: input.replyToMessageId,
820
+ reply_markup: jsonLike(input.replyMarkup)
821
+ }));
822
+ return normalizeMessage(asRecord(result));
823
+ }
824
+ async function exportChatInviteLink(input, ctx) {
825
+ const result = await request(ctx, "exportChatInviteLink", { chat_id: input.chatId });
826
+ if (typeof result !== "string") {
827
+ throw new TBError("unavailable", "Telegram \u7684\u9080\u8BF7\u94FE\u63A5\u4E0D\u662F\u4E00\u4E2A\u5B57\u7B26\u4E32", { retryable: true });
828
+ }
829
+ return { inviteLink: result };
830
+ }
831
+ async function mutateChatInviteLink(ctx, method, input) {
832
+ const source = input;
833
+ if (source.memberLimit != null && source.createsJoinRequest === true) {
834
+ throw new TBError("invalid_argument", "memberLimit cannot be combined with createsJoinRequest");
835
+ }
836
+ const result = await request(ctx, method, compactDefined({
837
+ chat_id: input.chatId,
838
+ invite_link: source.inviteLink,
839
+ name: source.name,
840
+ expire_date: source.expireDate,
841
+ member_limit: source.memberLimit,
842
+ creates_join_request: source.createsJoinRequest
843
+ }));
844
+ return normalizeChatInviteLink(asRecord(result));
845
+ }
846
+ function createChatInviteLink(input, ctx) {
847
+ return mutateChatInviteLink(ctx, "createChatInviteLink", input);
848
+ }
849
+ function editChatInviteLink(input, ctx) {
850
+ return mutateChatInviteLink(ctx, "editChatInviteLink", input);
851
+ }
852
+ function revokeChatInviteLink(input, ctx) {
853
+ return mutateChatInviteLink(ctx, "revokeChatInviteLink", input);
854
+ }
855
+ function answerCallbackQuery(input, ctx) {
856
+ return booleanAction(ctx, "answerCallbackQuery", compactDefined({
857
+ callback_query_id: input.callbackQueryId,
858
+ text: input.text,
859
+ show_alert: input.showAlert,
860
+ url: publicUrl(input.url),
861
+ cache_time: input.cacheTime
862
+ }));
863
+ }
864
+ function setMyCommands(input, ctx) {
865
+ return booleanAction(ctx, "setMyCommands", compactDefined({
866
+ commands: input.commands,
867
+ scope: jsonLike(input.scope),
868
+ language_code: input.languageCode
869
+ }));
870
+ }
871
+ function setWebhook(input, ctx) {
872
+ return booleanAction(ctx, "setWebhook", compactDefined({
873
+ // Telegram 会主动回访这个地址,故它同样要过出站可达性判定(填内网地址等于让上游探我们的内网)。
874
+ url: publicUrl(input.url),
875
+ secret_token: input.secretToken,
876
+ max_connections: input.maxConnections,
877
+ allowed_updates: input.allowedUpdates,
878
+ drop_pending_updates: input.dropPendingUpdates
879
+ }));
880
+ }
881
+ function deleteWebhook(input, ctx) {
882
+ return booleanAction(ctx, "deleteWebhook", compactDefined({ drop_pending_updates: input.dropPendingUpdates }));
883
+ }
884
+
885
+ // ../plugins/src/telegram/schema.ts
886
+ import { z } from "zod/v4";
887
+ var getMeInput = z.strictObject({}).describe("Action input.");
888
+ var getMeOutput = z.looseObject({}).describe("A Telegram user or bot record.");
889
+ var getWebhookInfoInput = z.strictObject({}).describe("Action input.");
890
+ var getWebhookInfoOutput = z.looseObject({}).describe("Telegram webhook status information.");
891
+ var getUpdatesInput = z.strictObject({
892
+ offset: z.int().describe("The update ID offset to start polling from.").optional(),
893
+ limit: z.int().min(1).max(100).describe("The maximum number of updates to return.").optional(),
894
+ timeout: z.int().min(0).max(50).describe("The long-polling timeout in seconds.").optional(),
895
+ allowedUpdates: z.array(z.string().min(1)).describe("The update types to receive.").optional()
896
+ }).describe("Action input.");
897
+ var getUpdatesOutput = z.strictObject({
898
+ updates: z.array(z.looseObject({}).describe("A Telegram update payload.")).describe("The updates returned by Telegram.")
899
+ }).describe("Action output.");
900
+ var sendMessageInput = z.strictObject({
901
+ chatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username."),
902
+ text: z.string().min(1).max(4096).describe("The text of the message to send."),
903
+ businessConnectionId: z.string().min(1).describe("The unique identifier of the Telegram business connection.").optional(),
904
+ parseMode: z.enum(["Markdown", "MarkdownV2", "HTML"]).describe("The parse mode used for message entities.").optional(),
905
+ disableNotification: z.boolean().describe("Whether to send the message silently.").optional(),
906
+ protectContent: z.boolean().describe("Whether to protect the sent message from forwarding and saving.").optional(),
907
+ disableWebPagePreview: z.boolean().describe("Whether to disable link previews in the message.").optional(),
908
+ messageThreadId: z.int().min(1).describe("The forum topic ID for the target message thread.").optional(),
909
+ replyToMessageId: z.int().min(1).describe("The message ID to reply to.").optional()
910
+ }).describe("Action input.");
911
+ var sendMessageOutput = z.looseObject({}).describe("A normalized Telegram message record.");
912
+ var copyMessageInput = z.strictObject({
913
+ chatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username."),
914
+ fromChatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username."),
915
+ messageId: z.int().min(1).describe("A Telegram message identifier."),
916
+ messageThreadId: z.int().min(1).describe("The target forum topic identifier.").optional(),
917
+ caption: z.string().max(1024).describe("A replacement media caption.").optional(),
918
+ parseMode: z.enum(["Markdown", "MarkdownV2", "HTML"]).describe("The parse mode used for message entities.").optional(),
919
+ showCaptionAboveMedia: z.boolean().describe("Whether to show the replacement caption above the media.").optional(),
920
+ disableNotification: z.boolean().describe("Whether to copy the message silently.").optional(),
921
+ protectContent: z.boolean().describe("Whether to protect the copied message from forwarding and saving.").optional()
922
+ }).describe("Action input.");
923
+ var copyMessageOutput = z.strictObject({
924
+ messageId: z.int().min(1).describe("A Telegram message identifier.")
925
+ }).describe("Action output.");
926
+ var copyMessagesInput = z.strictObject({
927
+ chatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username."),
928
+ fromChatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username."),
929
+ messageIds: z.array(z.int().min(1).describe("A Telegram message identifier.")).min(1).max(100).describe("The identifiers of 1-100 Telegram messages."),
930
+ messageThreadId: z.int().min(1).describe("The target forum topic identifier.").optional(),
931
+ disableNotification: z.boolean().describe("Whether to deliver the messages silently.").optional(),
932
+ protectContent: z.boolean().describe("Whether to protect the messages from forwarding and saving.").optional(),
933
+ removeCaption: z.boolean().describe("Whether to remove captions from copied messages.").optional()
934
+ }).describe("Action input.");
935
+ var copyMessagesOutput = z.strictObject({
936
+ messageIds: z.array(z.int().min(1).describe("A Telegram message identifier.")).describe("The returned message identifiers.")
937
+ }).describe("Action output.");
938
+ var forwardMessagesInput = z.strictObject({
939
+ chatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username."),
940
+ fromChatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username."),
941
+ messageIds: z.array(z.int().min(1).describe("A Telegram message identifier.")).min(1).max(100).describe("The identifiers of 1-100 Telegram messages."),
942
+ messageThreadId: z.int().min(1).describe("The target forum topic identifier.").optional(),
943
+ disableNotification: z.boolean().describe("Whether to deliver the messages silently.").optional(),
944
+ protectContent: z.boolean().describe("Whether to protect the messages from forwarding and saving.").optional()
945
+ }).describe("Action input.");
946
+ var forwardMessagesOutput = z.strictObject({
947
+ messageIds: z.array(z.int().min(1).describe("A Telegram message identifier.")).describe("The returned message identifiers.")
948
+ }).describe("Action output.");
949
+ var deleteMessagesInput = z.strictObject({
950
+ chatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username."),
951
+ messageIds: z.array(z.int().min(1).describe("A Telegram message identifier.")).min(1).max(100).describe("The identifiers of 1-100 Telegram messages.")
952
+ }).describe("Action input.");
953
+ var deleteMessagesOutput = z.strictObject({
954
+ success: z.literal(true).describe("Whether the Telegram Bot API request succeeded.")
955
+ }).describe("A success response payload.");
956
+ var setMessageReactionInput = z.strictObject({
957
+ chatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username."),
958
+ messageId: z.int().min(1).describe("A Telegram message identifier."),
959
+ reaction: z.array(z.looseObject({}).describe("A Telegram ReactionType object.")).max(1).describe("The reaction types to set; an empty array removes the reaction.").optional(),
960
+ isBig: z.boolean().describe("Whether to display a large reaction animation.").optional()
961
+ }).describe("Action input.");
962
+ var setMessageReactionOutput = z.strictObject({
963
+ success: z.literal(true).describe("Whether the Telegram Bot API request succeeded.")
964
+ }).describe("A success response payload.");
965
+ var sendChatActionInput = z.strictObject({
966
+ chatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username."),
967
+ action: z.enum(["typing", "upload_photo", "record_video", "upload_video", "record_voice", "upload_voice", "upload_document", "choose_sticker", "find_location", "record_video_note", "upload_video_note"]).describe("The activity status to broadcast."),
968
+ businessConnectionId: z.string().min(1).describe("The unique identifier of the Telegram business connection.").optional(),
969
+ messageThreadId: z.int().min(1).describe("The target forum topic identifier.").optional()
970
+ }).describe("Action input.");
971
+ var sendChatActionOutput = z.strictObject({
972
+ success: z.literal(true).describe("Whether the Telegram Bot API request succeeded.")
973
+ }).describe("A success response payload.");
974
+ var sendVideoInput = z.strictObject({
975
+ chatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username."),
976
+ video: z.string().min(1).describe("The HTTP URL or Telegram file_id of the MPEG-4 video to send."),
977
+ businessConnectionId: z.string().min(1).describe("The unique identifier of the Telegram business connection.").optional(),
978
+ caption: z.string().max(1024).describe("The media caption.").optional(),
979
+ parseMode: z.enum(["Markdown", "MarkdownV2", "HTML"]).describe("The parse mode used for message entities.").optional(),
980
+ duration: z.int().min(0).describe("The media duration in seconds.").optional(),
981
+ width: z.int().min(1).describe("The video width.").optional(),
982
+ height: z.int().min(1).describe("The video height.").optional(),
983
+ cover: z.string().min(1).describe("The HTTP URL or Telegram file_id of the video cover.").optional(),
984
+ startTimestamp: z.int().min(0).describe("The start timestamp shown for the video.").optional(),
985
+ showCaptionAboveMedia: z.boolean().describe("Whether to show the caption above the video.").optional(),
986
+ hasSpoiler: z.boolean().describe("Whether to cover the video with a spoiler animation.").optional(),
987
+ supportsStreaming: z.boolean().describe("Whether the video supports streaming.").optional(),
988
+ messageThreadId: z.int().min(1).describe("The target forum topic identifier.").optional(),
989
+ disableNotification: z.boolean().describe("Whether to send the media silently.").optional(),
990
+ protectContent: z.boolean().describe("Whether to protect the media from forwarding and saving.").optional()
991
+ }).describe("Action input.");
992
+ var sendVideoOutput = z.looseObject({}).describe("A normalized Telegram message record.");
993
+ var sendAudioInput = z.strictObject({
994
+ chatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username."),
995
+ audio: z.string().min(1).describe("The HTTP URL or Telegram file_id of the MP3 or M4A audio to send."),
996
+ businessConnectionId: z.string().min(1).describe("The unique identifier of the Telegram business connection.").optional(),
997
+ caption: z.string().max(1024).describe("The media caption.").optional(),
998
+ parseMode: z.enum(["Markdown", "MarkdownV2", "HTML"]).describe("The parse mode used for message entities.").optional(),
999
+ duration: z.int().min(0).describe("The media duration in seconds.").optional(),
1000
+ performer: z.string().describe("The audio performer.").optional(),
1001
+ title: z.string().describe("The audio track name.").optional(),
1002
+ messageThreadId: z.int().min(1).describe("The target forum topic identifier.").optional(),
1003
+ disableNotification: z.boolean().describe("Whether to send the media silently.").optional(),
1004
+ protectContent: z.boolean().describe("Whether to protect the media from forwarding and saving.").optional()
1005
+ }).describe("Action input.");
1006
+ var sendAudioOutput = z.looseObject({}).describe("A normalized Telegram message record.");
1007
+ var sendVoiceInput = z.strictObject({
1008
+ chatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username."),
1009
+ voice: z.string().min(1).describe("The HTTP URL or Telegram file_id of the OGG, MP3, or M4A voice message."),
1010
+ businessConnectionId: z.string().min(1).describe("The unique identifier of the Telegram business connection.").optional(),
1011
+ caption: z.string().max(1024).describe("The media caption.").optional(),
1012
+ parseMode: z.enum(["Markdown", "MarkdownV2", "HTML"]).describe("The parse mode used for message entities.").optional(),
1013
+ duration: z.int().min(0).describe("The media duration in seconds.").optional(),
1014
+ messageThreadId: z.int().min(1).describe("The target forum topic identifier.").optional(),
1015
+ disableNotification: z.boolean().describe("Whether to send the media silently.").optional(),
1016
+ protectContent: z.boolean().describe("Whether to protect the media from forwarding and saving.").optional()
1017
+ }).describe("Action input.");
1018
+ var sendVoiceOutput = z.looseObject({}).describe("A normalized Telegram message record.");
1019
+ var sendAnimationInput = z.strictObject({
1020
+ chatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username."),
1021
+ animation: z.string().min(1).describe("The HTTP URL or Telegram file_id of the GIF or silent MPEG-4 animation."),
1022
+ businessConnectionId: z.string().min(1).describe("The unique identifier of the Telegram business connection.").optional(),
1023
+ caption: z.string().max(1024).describe("The media caption.").optional(),
1024
+ parseMode: z.enum(["Markdown", "MarkdownV2", "HTML"]).describe("The parse mode used for message entities.").optional(),
1025
+ duration: z.int().min(0).describe("The media duration in seconds.").optional(),
1026
+ width: z.int().min(1).describe("The animation width.").optional(),
1027
+ height: z.int().min(1).describe("The animation height.").optional(),
1028
+ showCaptionAboveMedia: z.boolean().describe("Whether to show the caption above the animation.").optional(),
1029
+ hasSpoiler: z.boolean().describe("Whether to cover the animation with a spoiler animation.").optional(),
1030
+ messageThreadId: z.int().min(1).describe("The target forum topic identifier.").optional(),
1031
+ disableNotification: z.boolean().describe("Whether to send the media silently.").optional(),
1032
+ protectContent: z.boolean().describe("Whether to protect the media from forwarding and saving.").optional()
1033
+ }).describe("Action input.");
1034
+ var sendAnimationOutput = z.looseObject({}).describe("A normalized Telegram message record.");
1035
+ var sendMediaGroupInput = z.strictObject({
1036
+ chatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username."),
1037
+ media: z.array(z.looseObject({
1038
+ type: z.enum(["photo", "video", "audio", "document"]).describe("The media type."),
1039
+ media: z.string().min(1).describe("The HTTP URL or Telegram file_id of the media.")
1040
+ }).describe("A Telegram InputMedia object.")).min(2).max(10).describe("The InputMedia objects in the album."),
1041
+ businessConnectionId: z.string().min(1).describe("The unique identifier of the Telegram business connection.").optional(),
1042
+ messageThreadId: z.int().min(1).describe("The target forum topic identifier.").optional(),
1043
+ disableNotification: z.boolean().describe("Whether to send the album silently.").optional(),
1044
+ protectContent: z.boolean().describe("Whether to protect the album from forwarding and saving.").optional()
1045
+ }).describe("Action input.");
1046
+ var sendMediaGroupOutput = z.strictObject({
1047
+ messages: z.array(z.looseObject({}).describe("A normalized Telegram message record.")).describe("The sent media messages.")
1048
+ }).describe("Action output.");
1049
+ var sendContactInput = z.strictObject({
1050
+ chatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username."),
1051
+ phoneNumber: z.string().min(1).describe("The contact phone number."),
1052
+ firstName: z.string().min(1).describe("The contact first name."),
1053
+ lastName: z.string().describe("The contact last name.").optional(),
1054
+ vcard: z.string().max(2048).describe("Additional contact data in vCard format.").optional(),
1055
+ businessConnectionId: z.string().min(1).describe("The unique identifier of the Telegram business connection.").optional(),
1056
+ messageThreadId: z.int().min(1).describe("The target forum topic identifier.").optional(),
1057
+ disableNotification: z.boolean().describe("Whether to send the contact silently.").optional(),
1058
+ protectContent: z.boolean().describe("Whether to protect the contact from forwarding and saving.").optional()
1059
+ }).describe("Action input.");
1060
+ var sendContactOutput = z.looseObject({}).describe("A normalized Telegram message record.");
1061
+ var sendVenueInput = z.strictObject({
1062
+ chatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username."),
1063
+ latitude: z.number().min(-90).max(90).describe("The venue latitude."),
1064
+ longitude: z.number().min(-180).max(180).describe("The venue longitude."),
1065
+ title: z.string().min(1).describe("The venue name."),
1066
+ address: z.string().min(1).describe("The venue address."),
1067
+ foursquareId: z.string().describe("The Foursquare place identifier.").optional(),
1068
+ foursquareType: z.string().describe("The Foursquare place type.").optional(),
1069
+ googlePlaceId: z.string().describe("The Google Places identifier.").optional(),
1070
+ googlePlaceType: z.string().describe("The Google Places type.").optional(),
1071
+ businessConnectionId: z.string().min(1).describe("The unique identifier of the Telegram business connection.").optional(),
1072
+ messageThreadId: z.int().min(1).describe("The target forum topic identifier.").optional(),
1073
+ disableNotification: z.boolean().describe("Whether to send the venue silently.").optional(),
1074
+ protectContent: z.boolean().describe("Whether to protect the venue from forwarding and saving.").optional()
1075
+ }).describe("Action input.");
1076
+ var sendVenueOutput = z.looseObject({}).describe("A normalized Telegram message record.");
1077
+ var sendDiceInput = z.strictObject({
1078
+ chatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username."),
1079
+ emoji: z.enum(["\u{1F3B2}", "\u{1F3AF}", "\u{1F3C0}", "\u26BD", "\u{1F3B3}", "\u{1F3B0}"]).describe("The dice animation emoji.").optional(),
1080
+ businessConnectionId: z.string().min(1).describe("The unique identifier of the Telegram business connection.").optional(),
1081
+ messageThreadId: z.int().min(1).describe("The target forum topic identifier.").optional(),
1082
+ disableNotification: z.boolean().describe("Whether to send the animation silently.").optional(),
1083
+ protectContent: z.boolean().describe("Whether to protect the animation from forwarding.").optional()
1084
+ }).describe("Action input.");
1085
+ var sendDiceOutput = z.looseObject({}).describe("A normalized Telegram message record.");
1086
+ var getBusinessConnectionInput = z.strictObject({
1087
+ businessConnectionId: z.string().min(1).describe("The unique identifier of the Telegram business connection.")
1088
+ }).describe("Action input.");
1089
+ var getBusinessConnectionOutput = z.looseObject({}).describe("A Telegram business connection record.");
1090
+ var readBusinessMessageInput = z.strictObject({
1091
+ businessConnectionId: z.string().min(1).describe("The unique identifier of the Telegram business connection."),
1092
+ chatId: z.int().describe("The identifier of the active private chat."),
1093
+ messageId: z.int().min(1).describe("A Telegram message identifier.")
1094
+ }).describe("Action input.");
1095
+ var readBusinessMessageOutput = z.strictObject({
1096
+ success: z.literal(true).describe("Whether the Telegram Bot API request succeeded.")
1097
+ }).describe("A success response payload.");
1098
+ var deleteBusinessMessagesInput = z.strictObject({
1099
+ businessConnectionId: z.string().min(1).describe("The unique identifier of the Telegram business connection."),
1100
+ messageIds: z.array(z.int().min(1).describe("A Telegram message identifier.")).min(1).max(100).describe("The identifiers of 1-100 Telegram messages.")
1101
+ }).describe("Action input.");
1102
+ var deleteBusinessMessagesOutput = z.strictObject({
1103
+ success: z.literal(true).describe("Whether the Telegram Bot API request succeeded.")
1104
+ }).describe("A success response payload.");
1105
+ var editMessageTextInput = z.strictObject({
1106
+ chatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username.").optional(),
1107
+ messageId: z.int().min(1).describe("The message ID to edit.").optional(),
1108
+ inlineMessageId: z.string().min(1).describe("The inline message ID to edit.").optional(),
1109
+ text: z.string().min(1).max(4096).describe("The new message text."),
1110
+ parseMode: z.enum(["Markdown", "MarkdownV2", "HTML"]).describe("The parse mode used for message entities.").optional(),
1111
+ disableWebPagePreview: z.boolean().describe("Whether to disable link previews in the edited message.").optional()
1112
+ }).describe("Action input.");
1113
+ var editMessageTextOutput = z.strictObject({
1114
+ edited: z.literal(true).describe("Whether the message edit succeeded."),
1115
+ message: z.looseObject({}).describe("A normalized Telegram message record.").nullable(),
1116
+ inlineMessageId: z.string().describe("The inline message ID when editing an inline message.").nullable()
1117
+ }).describe("Action output.");
1118
+ var sendPhotoInput = z.strictObject({
1119
+ chatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username."),
1120
+ photo: z.string().min(1).describe("The photo URL or existing Telegram file_id to send."),
1121
+ caption: z.string().max(1024).describe("The caption for the photo.").optional(),
1122
+ parseMode: z.enum(["Markdown", "MarkdownV2", "HTML"]).describe("The parse mode used for message entities.").optional(),
1123
+ disableNotification: z.boolean().describe("Whether to send the photo silently.").optional(),
1124
+ protectContent: z.boolean().describe("Whether to protect the photo from forwarding and saving.").optional(),
1125
+ messageThreadId: z.int().min(1).describe("The forum topic ID for the target message thread.").optional(),
1126
+ replyToMessageId: z.int().min(1).describe("The message ID to reply to.").optional()
1127
+ }).describe("Action input.");
1128
+ var sendPhotoOutput = z.looseObject({}).describe("A normalized Telegram message record.");
1129
+ var sendDocumentInput = z.strictObject({
1130
+ chatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username."),
1131
+ document: z.string().min(1).describe("The document URL or existing Telegram file_id to send."),
1132
+ caption: z.string().max(1024).describe("The caption for the document.").optional(),
1133
+ parseMode: z.enum(["Markdown", "MarkdownV2", "HTML"]).describe("The parse mode used for message entities.").optional(),
1134
+ thumbnail: z.string().min(1).describe("An optional thumbnail URL or file identifier.").optional(),
1135
+ replyMarkup: z.union([z.string().min(1).describe("A JSON-serialized object string."), z.looseObject({}).describe("A Telegram reply markup object.")]).describe("A Telegram reply markup object or JSON object string.").optional(),
1136
+ replyToMessageId: z.int().min(1).describe("The message ID to reply to.").optional(),
1137
+ disableNotification: z.boolean().describe("Whether to send the document silently.").optional(),
1138
+ disableContentTypeDetection: z.boolean().describe("Whether to disable server-side content type detection.").optional()
1139
+ }).describe("Action input.");
1140
+ var sendDocumentOutput = z.looseObject({}).describe("A normalized Telegram message record.");
1141
+ var sendPollInput = z.strictObject({
1142
+ chatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username."),
1143
+ question: z.string().min(1).max(300).describe("The question shown at the top of the poll."),
1144
+ options: z.array(z.string().min(1).max(100)).min(2).max(10).describe("The answer options available in the poll."),
1145
+ type: z.enum(["regular", "quiz"]).describe("The type of poll to send.").optional(),
1146
+ isAnonymous: z.boolean().describe("Whether the poll should be anonymous.").optional(),
1147
+ allowsMultipleAnswers: z.boolean().describe("Whether users can choose multiple answers.").optional(),
1148
+ correctOptionId: z.int().min(0).describe("The zero-based index of the correct option for quiz polls.").optional(),
1149
+ explanation: z.string().max(200).describe("The explanation shown for quiz polls.").optional(),
1150
+ explanationParseMode: z.enum(["Markdown", "MarkdownV2", "HTML"]).describe("The parse mode used for message entities.").optional(),
1151
+ openPeriod: z.int().min(5).max(600).describe("The number of seconds the poll should stay open.").optional(),
1152
+ closeDate: z.int().describe("The Unix timestamp when the poll should close.").optional(),
1153
+ isClosed: z.boolean().describe("Whether the poll should be sent already closed.").optional(),
1154
+ disableNotification: z.boolean().describe("Whether to send the poll silently.").optional(),
1155
+ replyToMessageId: z.int().min(1).describe("The message ID to reply to.").optional(),
1156
+ replyMarkup: z.union([z.string().min(1).describe("A JSON-serialized object string."), z.looseObject({}).describe("A Telegram reply markup object.")]).describe("A Telegram reply markup object or JSON object string.").optional()
1157
+ }).describe("Action input.");
1158
+ var sendPollOutput = z.looseObject({}).describe("A normalized Telegram message record.");
1159
+ var getChatInput = z.strictObject({
1160
+ chatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username.")
1161
+ }).describe("Action input.");
1162
+ var getChatOutput = z.looseObject({}).describe("A Telegram chat record.");
1163
+ var getChatMemberInput = z.strictObject({
1164
+ chatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username."),
1165
+ userId: z.int().describe("The user ID of the chat member to fetch.")
1166
+ }).describe("Action input.");
1167
+ var getChatMemberOutput = z.looseObject({}).describe("A Telegram chat member record.");
1168
+ var getChatAdministratorsInput = z.strictObject({
1169
+ chatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username.")
1170
+ }).describe("Action input.");
1171
+ var getChatAdministratorsOutput = z.strictObject({
1172
+ administrators: z.array(z.looseObject({}).describe("A Telegram chat member record.")).describe("The administrators visible to the bot in the chat.")
1173
+ }).describe("Action output.");
1174
+ var getChatMembersCountInput = z.strictObject({
1175
+ chatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username.")
1176
+ }).describe("Action input.");
1177
+ var getChatMembersCountOutput = z.strictObject({
1178
+ memberCount: z.int().describe("The number of members currently in the chat.")
1179
+ }).describe("Action output.");
1180
+ var banChatMemberInput = z.strictObject({
1181
+ chatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username."),
1182
+ userId: z.int().describe("The target user identifier."),
1183
+ untilDate: z.int().describe("The Unix timestamp when the ban ends.").optional(),
1184
+ revokeMessages: z.boolean().describe("Whether to delete all messages from the banned user.").optional()
1185
+ }).describe("Action input.");
1186
+ var banChatMemberOutput = z.strictObject({
1187
+ success: z.literal(true).describe("Whether the Telegram Bot API request succeeded.")
1188
+ }).describe("A success response payload.");
1189
+ var unbanChatMemberInput = z.strictObject({
1190
+ chatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username."),
1191
+ userId: z.int().describe("The target user identifier."),
1192
+ onlyIfBanned: z.boolean().describe("Whether to do nothing when the user is not currently banned.").optional()
1193
+ }).describe("Action input.");
1194
+ var unbanChatMemberOutput = z.strictObject({
1195
+ success: z.literal(true).describe("Whether the Telegram Bot API request succeeded.")
1196
+ }).describe("A success response payload.");
1197
+ var restrictChatMemberInput = z.strictObject({
1198
+ chatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username."),
1199
+ userId: z.int().describe("The target user identifier."),
1200
+ permissions: z.strictObject({
1201
+ canSendMessages: z.boolean().describe("Whether users may send text messages, contacts, giveaways, and locations.").optional(),
1202
+ canSendAudios: z.boolean().describe("Whether users may send audio files.").optional(),
1203
+ canSendDocuments: z.boolean().describe("Whether users may send documents.").optional(),
1204
+ canSendPhotos: z.boolean().describe("Whether users may send photos.").optional(),
1205
+ canSendVideos: z.boolean().describe("Whether users may send videos.").optional(),
1206
+ canSendVideoNotes: z.boolean().describe("Whether users may send video notes.").optional(),
1207
+ canSendVoiceNotes: z.boolean().describe("Whether users may send voice notes.").optional(),
1208
+ canSendPolls: z.boolean().describe("Whether users may send polls.").optional(),
1209
+ canSendOtherMessages: z.boolean().describe("Whether users may send animations, games, stickers, and other media.").optional(),
1210
+ canAddWebPagePreviews: z.boolean().describe("Whether users may add web page previews.").optional(),
1211
+ canChangeInfo: z.boolean().describe("Whether users may change chat information.").optional(),
1212
+ canInviteUsers: z.boolean().describe("Whether users may invite new users.").optional(),
1213
+ canPinMessages: z.boolean().describe("Whether users may pin messages.").optional(),
1214
+ canManageTopics: z.boolean().describe("Whether users may create and manage forum topics.").optional()
1215
+ }).describe("Action input."),
1216
+ useIndependentChatPermissions: z.boolean().describe("Whether each media permission is applied independently.").optional(),
1217
+ untilDate: z.int().describe("The Unix timestamp when the restrictions end.").optional()
1218
+ }).describe("Action input.");
1219
+ var restrictChatMemberOutput = z.strictObject({
1220
+ success: z.literal(true).describe("Whether the Telegram Bot API request succeeded.")
1221
+ }).describe("A success response payload.");
1222
+ var promoteChatMemberInput = z.strictObject({
1223
+ chatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username."),
1224
+ userId: z.int().describe("The target user identifier."),
1225
+ isAnonymous: z.boolean().describe("Whether the administrator is hidden.").optional(),
1226
+ canManageChat: z.boolean().describe("Whether the administrator can access general chat management features.").optional(),
1227
+ canDeleteMessages: z.boolean().describe("Whether the administrator can delete other users' messages.").optional(),
1228
+ canManageVideoChats: z.boolean().describe("Whether the administrator can manage video chats.").optional(),
1229
+ canRestrictMembers: z.boolean().describe("Whether the administrator can restrict or ban members.").optional(),
1230
+ canPromoteMembers: z.boolean().describe("Whether the administrator can appoint other administrators.").optional(),
1231
+ canChangeInfo: z.boolean().describe("Whether the administrator can change chat information.").optional(),
1232
+ canInviteUsers: z.boolean().describe("Whether the administrator can invite users.").optional(),
1233
+ canPostStories: z.boolean().describe("Whether the administrator can post stories.").optional(),
1234
+ canEditStories: z.boolean().describe("Whether the administrator can edit stories.").optional(),
1235
+ canDeleteStories: z.boolean().describe("Whether the administrator can delete stories.").optional(),
1236
+ canPostMessages: z.boolean().describe("Whether the administrator can post channel messages.").optional(),
1237
+ canEditMessages: z.boolean().describe("Whether the administrator can edit channel messages.").optional(),
1238
+ canPinMessages: z.boolean().describe("Whether the administrator can pin messages.").optional(),
1239
+ canManageTopics: z.boolean().describe("Whether the administrator can manage forum topics.").optional(),
1240
+ canManageDirectMessages: z.boolean().describe("Whether the administrator can manage channel direct messages.").optional(),
1241
+ canManageTags: z.boolean().describe("Whether the administrator can manage member tags.").optional()
1242
+ }).describe("Action input.");
1243
+ var promoteChatMemberOutput = z.strictObject({
1244
+ success: z.literal(true).describe("Whether the Telegram Bot API request succeeded.")
1245
+ }).describe("A success response payload.");
1246
+ var setChatPermissionsInput = z.strictObject({
1247
+ chatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username."),
1248
+ permissions: z.strictObject({
1249
+ canSendMessages: z.boolean().describe("Whether users may send text messages, contacts, giveaways, and locations.").optional(),
1250
+ canSendAudios: z.boolean().describe("Whether users may send audio files.").optional(),
1251
+ canSendDocuments: z.boolean().describe("Whether users may send documents.").optional(),
1252
+ canSendPhotos: z.boolean().describe("Whether users may send photos.").optional(),
1253
+ canSendVideos: z.boolean().describe("Whether users may send videos.").optional(),
1254
+ canSendVideoNotes: z.boolean().describe("Whether users may send video notes.").optional(),
1255
+ canSendVoiceNotes: z.boolean().describe("Whether users may send voice notes.").optional(),
1256
+ canSendPolls: z.boolean().describe("Whether users may send polls.").optional(),
1257
+ canSendOtherMessages: z.boolean().describe("Whether users may send animations, games, stickers, and other media.").optional(),
1258
+ canAddWebPagePreviews: z.boolean().describe("Whether users may add web page previews.").optional(),
1259
+ canChangeInfo: z.boolean().describe("Whether users may change chat information.").optional(),
1260
+ canInviteUsers: z.boolean().describe("Whether users may invite new users.").optional(),
1261
+ canPinMessages: z.boolean().describe("Whether users may pin messages.").optional(),
1262
+ canManageTopics: z.boolean().describe("Whether users may create and manage forum topics.").optional()
1263
+ }).describe("Action input."),
1264
+ useIndependentChatPermissions: z.boolean().describe("Whether each media permission is applied independently.").optional()
1265
+ }).describe("Action input.");
1266
+ var setChatPermissionsOutput = z.strictObject({
1267
+ success: z.literal(true).describe("Whether the Telegram Bot API request succeeded.")
1268
+ }).describe("A success response payload.");
1269
+ var pinChatMessageInput = z.strictObject({
1270
+ chatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username."),
1271
+ messageId: z.int().min(1).describe("A Telegram message identifier."),
1272
+ businessConnectionId: z.string().min(1).describe("The unique identifier of the Telegram business connection.").optional(),
1273
+ disableNotification: z.boolean().describe("Whether to suppress the pin notification.").optional()
1274
+ }).describe("Action input.");
1275
+ var pinChatMessageOutput = z.strictObject({
1276
+ success: z.literal(true).describe("Whether the Telegram Bot API request succeeded.")
1277
+ }).describe("A success response payload.");
1278
+ var unpinChatMessageInput = z.strictObject({
1279
+ chatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username."),
1280
+ messageId: z.int().min(1).describe("A Telegram message identifier.").optional(),
1281
+ businessConnectionId: z.string().min(1).describe("The unique identifier of the Telegram business connection.").optional()
1282
+ }).describe("Action input.");
1283
+ var unpinChatMessageOutput = z.strictObject({
1284
+ success: z.literal(true).describe("Whether the Telegram Bot API request succeeded.")
1285
+ }).describe("A success response payload.");
1286
+ var unpinAllChatMessagesInput = z.strictObject({
1287
+ chatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username.")
1288
+ }).describe("Action input.");
1289
+ var unpinAllChatMessagesOutput = z.strictObject({
1290
+ success: z.literal(true).describe("Whether the Telegram Bot API request succeeded.")
1291
+ }).describe("A success response payload.");
1292
+ var approveChatJoinRequestInput = z.strictObject({
1293
+ chatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username."),
1294
+ userId: z.int().describe("The user identifier from the join request.")
1295
+ }).describe("Action input.");
1296
+ var approveChatJoinRequestOutput = z.strictObject({
1297
+ success: z.literal(true).describe("Whether the Telegram Bot API request succeeded.")
1298
+ }).describe("A success response payload.");
1299
+ var declineChatJoinRequestInput = z.strictObject({
1300
+ chatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username."),
1301
+ userId: z.int().describe("The user identifier from the join request.")
1302
+ }).describe("Action input.");
1303
+ var declineChatJoinRequestOutput = z.strictObject({
1304
+ success: z.literal(true).describe("Whether the Telegram Bot API request succeeded.")
1305
+ }).describe("A success response payload.");
1306
+ var deleteMessageInput = z.strictObject({
1307
+ chatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username."),
1308
+ messageId: z.int().min(1).describe("The message ID to delete.")
1309
+ }).describe("Action input.");
1310
+ var deleteMessageOutput = z.strictObject({
1311
+ success: z.literal(true).describe("Whether the Telegram Bot API request succeeded.")
1312
+ }).describe("A success response payload.");
1313
+ var forwardMessageInput = z.strictObject({
1314
+ chatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username."),
1315
+ fromChatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username."),
1316
+ messageId: z.int().min(1).describe("The source message ID to forward."),
1317
+ disableNotification: z.boolean().describe("Whether to forward the message silently.").optional()
1318
+ }).describe("Action input.");
1319
+ var forwardMessageOutput = z.looseObject({}).describe("A normalized Telegram message record.");
1320
+ var sendLocationInput = z.strictObject({
1321
+ chatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username."),
1322
+ latitude: z.number().min(-90).max(90).describe("The latitude of the location."),
1323
+ longitude: z.number().min(-180).max(180).describe("The longitude of the location."),
1324
+ horizontalAccuracy: z.number().min(0).max(1500).describe("The radius of uncertainty for the location, in meters.").optional(),
1325
+ livePeriod: z.int().min(60).max(86400).describe("The live location update period in seconds.").optional(),
1326
+ heading: z.int().min(1).max(360).describe("The direction in which the user is moving, in degrees.").optional(),
1327
+ proximityAlertRadius: z.int().min(1).max(1e5).describe("The distance in meters for proximity alerts.").optional(),
1328
+ disableNotification: z.boolean().describe("Whether to send the location silently.").optional(),
1329
+ replyToMessageId: z.int().min(1).describe("The message ID to reply to.").optional(),
1330
+ replyMarkup: z.union([z.string().min(1).describe("A JSON-serialized object string."), z.looseObject({}).describe("A Telegram reply markup object.")]).describe("A Telegram reply markup object or JSON object string.").optional()
1331
+ }).describe("Action input.");
1332
+ var sendLocationOutput = z.looseObject({}).describe("A normalized Telegram message record.");
1333
+ var exportChatInviteLinkInput = z.strictObject({
1334
+ chatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username.")
1335
+ }).describe("Action input.");
1336
+ var exportChatInviteLinkOutput = z.strictObject({
1337
+ inviteLink: z.string().describe("The exported invite link for the chat.")
1338
+ }).describe("Action output.");
1339
+ var createChatInviteLinkInput = z.strictObject({
1340
+ chatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username."),
1341
+ name: z.string().max(32).describe("The invite link name.").optional(),
1342
+ expireDate: z.int().describe("The Unix timestamp when the link expires.").optional(),
1343
+ memberLimit: z.int().min(1).max(99999).describe("The maximum number of simultaneous members using the link.").optional(),
1344
+ createsJoinRequest: z.boolean().describe("Whether users joining through the link require administrator approval.").optional()
1345
+ }).describe("Action input.");
1346
+ var createChatInviteLinkOutput = z.looseObject({}).describe("A Telegram chat invite link record.");
1347
+ var editChatInviteLinkInput = z.strictObject({
1348
+ chatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username."),
1349
+ inviteLink: z.string().min(1).describe("The invite link to edit."),
1350
+ name: z.string().max(32).describe("The invite link name.").optional(),
1351
+ expireDate: z.int().describe("The Unix timestamp when the link expires.").optional(),
1352
+ memberLimit: z.int().min(1).max(99999).describe("The maximum number of simultaneous members using the link.").optional(),
1353
+ createsJoinRequest: z.boolean().describe("Whether users joining through the link require administrator approval.").optional()
1354
+ }).describe("Action input.");
1355
+ var editChatInviteLinkOutput = z.looseObject({}).describe("A Telegram chat invite link record.");
1356
+ var revokeChatInviteLinkInput = z.strictObject({
1357
+ chatId: z.union([z.int().describe("A numeric Telegram chat identifier."), z.string().regex(new RegExp("^-?\\d+$")).describe("A numeric Telegram chat identifier encoded as a string."), z.string().regex(new RegExp("^@[A-Za-z0-9_]+$")).describe("A Telegram @username for a public chat or channel.")]).describe("The target Telegram chat ID or channel username."),
1358
+ inviteLink: z.string().min(1).describe("The invite link to revoke.")
1359
+ }).describe("Action input.");
1360
+ var revokeChatInviteLinkOutput = z.looseObject({}).describe("A Telegram chat invite link record.");
1361
+ var answerCallbackQueryInput = z.strictObject({
1362
+ callbackQueryId: z.string().min(1).describe("The callback query ID to answer."),
1363
+ text: z.string().max(200).describe("The notification text to show to the user.").optional(),
1364
+ showAlert: z.boolean().describe("Whether to show an alert instead of a notification.").optional(),
1365
+ url: z.url().describe("The URL to open for the callback query.").optional(),
1366
+ cacheTime: z.int().min(0).describe("The maximum time in seconds that the result may be cached client-side.").optional()
1367
+ }).describe("Action input.");
1368
+ var answerCallbackQueryOutput = z.strictObject({
1369
+ success: z.literal(true).describe("Whether the Telegram Bot API request succeeded.")
1370
+ }).describe("A success response payload.");
1371
+ var setMyCommandsInput = z.strictObject({
1372
+ commands: z.array(z.strictObject({
1373
+ command: z.string().regex(new RegExp("^[a-z0-9_]+$")).describe("The command text without the leading slash.").optional(),
1374
+ description: z.string().min(1).max(256).describe("The description shown for the bot command.").optional()
1375
+ })).min(1).max(100).describe("The bot commands to register."),
1376
+ scope: z.union([z.string().min(1).describe("A JSON-serialized object string."), z.looseObject({}).describe("A Telegram reply markup object.")]).describe("A Telegram reply markup object or JSON object string.").optional(),
1377
+ languageCode: z.string().min(2).max(35).describe("The language code for localized commands.").optional()
1378
+ }).describe("Action input.");
1379
+ var setMyCommandsOutput = z.strictObject({
1380
+ success: z.literal(true).describe("Whether the Telegram Bot API request succeeded.")
1381
+ }).describe("A success response payload.");
1382
+ var setWebhookInput = z.strictObject({
1383
+ url: z.url().describe("The HTTPS webhook URL that Telegram should deliver updates to."),
1384
+ secretToken: z.string().min(1).max(256).describe("The secret token Telegram should include in webhook requests.").optional(),
1385
+ maxConnections: z.int().min(1).max(100).describe("The maximum number of concurrent webhook connections.").optional(),
1386
+ allowedUpdates: z.array(z.string().min(1)).describe("The update types that should be delivered to the webhook.").optional(),
1387
+ dropPendingUpdates: z.boolean().describe("Whether to drop all pending updates before setting the webhook.").optional()
1388
+ }).describe("Action input.");
1389
+ var setWebhookOutput = z.strictObject({
1390
+ success: z.literal(true).describe("Whether the Telegram Bot API request succeeded.")
1391
+ }).describe("A success response payload.");
1392
+ var deleteWebhookInput = z.strictObject({
1393
+ dropPendingUpdates: z.boolean().describe("Whether to drop all pending updates when deleting the webhook.").optional()
1394
+ }).describe("Action input.");
1395
+ var deleteWebhookOutput = z.strictObject({
1396
+ success: z.literal(true).describe("Whether the Telegram Bot API request succeeded.")
1397
+ }).describe("A success response payload.");
1398
+ var telegramActions = {
1399
+ get_me: {
1400
+ description: "Validate the bot token and return the bot profile from Telegram Bot API.",
1401
+ effect: "read",
1402
+ inputSchema: getMeInput,
1403
+ outputSchema: z.toJSONSchema(getMeOutput, { io: "output", unrepresentable: "any" })
1404
+ },
1405
+ get_webhook_info: {
1406
+ description: "Return the webhook status configured for the bot.",
1407
+ effect: "read",
1408
+ inputSchema: getWebhookInfoInput,
1409
+ outputSchema: z.toJSONSchema(getWebhookInfoOutput, { io: "output", unrepresentable: "any" })
1410
+ },
1411
+ get_updates: {
1412
+ description: "Poll pending updates for the bot. Use this only when webhook delivery is disabled or for debugging.",
1413
+ effect: "read",
1414
+ inputSchema: getUpdatesInput,
1415
+ outputSchema: z.toJSONSchema(getUpdatesOutput, { io: "output", unrepresentable: "any" })
1416
+ },
1417
+ send_message: {
1418
+ description: "Send a text message to a chat, group, supergroup, channel, or forum topic.",
1419
+ effect: "write",
1420
+ inputSchema: sendMessageInput,
1421
+ outputSchema: z.toJSONSchema(sendMessageOutput, { io: "output", unrepresentable: "any" })
1422
+ },
1423
+ copy_message: {
1424
+ description: "Copy one message without linking back to the original message.",
1425
+ effect: "write",
1426
+ inputSchema: copyMessageInput,
1427
+ outputSchema: z.toJSONSchema(copyMessageOutput, { io: "output", unrepresentable: "any" })
1428
+ },
1429
+ copy_messages: {
1430
+ description: "Copy 1-100 messages without links to the originals while preserving album grouping.",
1431
+ effect: "write",
1432
+ inputSchema: copyMessagesInput,
1433
+ outputSchema: z.toJSONSchema(copyMessagesOutput, { io: "output", unrepresentable: "any" })
1434
+ },
1435
+ forward_messages: {
1436
+ description: "Forward 1-100 messages while preserving links and album grouping.",
1437
+ effect: "write",
1438
+ inputSchema: forwardMessagesInput,
1439
+ outputSchema: z.toJSONSchema(forwardMessagesOutput, { io: "output", unrepresentable: "any" })
1440
+ },
1441
+ delete_messages: {
1442
+ description: "Delete 1-100 messages from one Telegram chat.",
1443
+ effect: "destructive",
1444
+ inputSchema: deleteMessagesInput,
1445
+ outputSchema: z.toJSONSchema(deleteMessagesOutput, { io: "output", unrepresentable: "any" })
1446
+ },
1447
+ set_message_reaction: {
1448
+ description: "Replace the bot's chosen reaction on a Telegram message.",
1449
+ effect: "write",
1450
+ inputSchema: setMessageReactionInput,
1451
+ outputSchema: z.toJSONSchema(setMessageReactionOutput, { io: "output", unrepresentable: "any" })
1452
+ },
1453
+ send_chat_action: {
1454
+ description: "Show a temporary typing, upload, recording, or location activity status in a chat.",
1455
+ effect: "write",
1456
+ inputSchema: sendChatActionInput,
1457
+ outputSchema: z.toJSONSchema(sendChatActionOutput, { io: "output", unrepresentable: "any" })
1458
+ },
1459
+ send_video: {
1460
+ description: "Send an MPEG-4 video by URL or Telegram file_id.",
1461
+ effect: "write",
1462
+ inputSchema: sendVideoInput,
1463
+ outputSchema: z.toJSONSchema(sendVideoOutput, { io: "output", unrepresentable: "any" })
1464
+ },
1465
+ send_audio: {
1466
+ description: "Send an MP3 or M4A audio track by URL or Telegram file_id.",
1467
+ effect: "write",
1468
+ inputSchema: sendAudioInput,
1469
+ outputSchema: z.toJSONSchema(sendAudioOutput, { io: "output", unrepresentable: "any" })
1470
+ },
1471
+ send_voice: {
1472
+ description: "Send a playable voice message by URL or Telegram file_id.",
1473
+ effect: "write",
1474
+ inputSchema: sendVoiceInput,
1475
+ outputSchema: z.toJSONSchema(sendVoiceOutput, { io: "output", unrepresentable: "any" })
1476
+ },
1477
+ send_animation: {
1478
+ description: "Send a GIF or silent MPEG-4 animation by URL or Telegram file_id.",
1479
+ effect: "write",
1480
+ inputSchema: sendAnimationInput,
1481
+ outputSchema: z.toJSONSchema(sendAnimationOutput, { io: "output", unrepresentable: "any" })
1482
+ },
1483
+ send_media_group: {
1484
+ description: "Send an album containing 2-10 photos, videos, documents, or audio items.",
1485
+ effect: "write",
1486
+ inputSchema: sendMediaGroupInput,
1487
+ outputSchema: z.toJSONSchema(sendMediaGroupOutput, { io: "output", unrepresentable: "any" })
1488
+ },
1489
+ send_contact: {
1490
+ description: "Send a phone contact to a Telegram chat.",
1491
+ effect: "write",
1492
+ inputSchema: sendContactInput,
1493
+ outputSchema: z.toJSONSchema(sendContactOutput, { io: "output", unrepresentable: "any" })
1494
+ },
1495
+ send_venue: {
1496
+ description: "Send a venue with coordinates, title, address, and optional place identifiers.",
1497
+ effect: "write",
1498
+ inputSchema: sendVenueInput,
1499
+ outputSchema: z.toJSONSchema(sendVenueOutput, { io: "output", unrepresentable: "any" })
1500
+ },
1501
+ send_dice: {
1502
+ description: "Send an animated dice, darts, basketball, football, bowling, or slot-machine emoji.",
1503
+ effect: "write",
1504
+ inputSchema: sendDiceInput,
1505
+ outputSchema: z.toJSONSchema(sendDiceOutput, { io: "output", unrepresentable: "any" })
1506
+ },
1507
+ get_business_connection: {
1508
+ description: "Return the current state and granted rights of a Telegram business connection.",
1509
+ effect: "read",
1510
+ inputSchema: getBusinessConnectionInput,
1511
+ outputSchema: z.toJSONSchema(getBusinessConnectionOutput, { io: "output", unrepresentable: "any" })
1512
+ },
1513
+ read_business_message: {
1514
+ description: "Mark an incoming message as read on behalf of a connected Telegram business account.",
1515
+ effect: "read",
1516
+ inputSchema: readBusinessMessageInput,
1517
+ outputSchema: z.toJSONSchema(readBusinessMessageOutput, { io: "output", unrepresentable: "any" })
1518
+ },
1519
+ delete_business_messages: {
1520
+ description: "Delete one or more messages on behalf of a connected Telegram business account.",
1521
+ effect: "destructive",
1522
+ inputSchema: deleteBusinessMessagesInput,
1523
+ outputSchema: z.toJSONSchema(deleteBusinessMessagesOutput, { io: "output", unrepresentable: "any" })
1524
+ },
1525
+ edit_message_text: {
1526
+ description: "Edit the text of a previously sent message or an inline message.",
1527
+ effect: "write",
1528
+ inputSchema: editMessageTextInput,
1529
+ outputSchema: z.toJSONSchema(editMessageTextOutput, { io: "output", unrepresentable: "any" })
1530
+ },
1531
+ send_photo: {
1532
+ description: "Send a photo by public URL or existing Telegram file_id.",
1533
+ effect: "write",
1534
+ inputSchema: sendPhotoInput,
1535
+ outputSchema: z.toJSONSchema(sendPhotoOutput, { io: "output", unrepresentable: "any" })
1536
+ },
1537
+ send_document: {
1538
+ description: "Send a document by public URL or existing Telegram file_id.",
1539
+ effect: "write",
1540
+ inputSchema: sendDocumentInput,
1541
+ outputSchema: z.toJSONSchema(sendDocumentOutput, { io: "output", unrepresentable: "any" })
1542
+ },
1543
+ send_poll: {
1544
+ description: "Send a native Telegram poll to a chat.",
1545
+ effect: "write",
1546
+ inputSchema: sendPollInput,
1547
+ outputSchema: z.toJSONSchema(sendPollOutput, { io: "output", unrepresentable: "any" })
1548
+ },
1549
+ get_chat: {
1550
+ description: "Return metadata for a chat the bot can access.",
1551
+ effect: "read",
1552
+ inputSchema: getChatInput,
1553
+ outputSchema: z.toJSONSchema(getChatOutput, { io: "output", unrepresentable: "any" })
1554
+ },
1555
+ get_chat_member: {
1556
+ description: "Return information about one chat member.",
1557
+ effect: "read",
1558
+ inputSchema: getChatMemberInput,
1559
+ outputSchema: z.toJSONSchema(getChatMemberOutput, { io: "output", unrepresentable: "any" })
1560
+ },
1561
+ get_chat_administrators: {
1562
+ description: "Return the chat administrators visible to the bot.",
1563
+ effect: "read",
1564
+ inputSchema: getChatAdministratorsInput,
1565
+ outputSchema: z.toJSONSchema(getChatAdministratorsOutput, { io: "output", unrepresentable: "any" })
1566
+ },
1567
+ get_chat_members_count: {
1568
+ description: "Return the number of members in a chat.",
1569
+ effect: "read",
1570
+ inputSchema: getChatMembersCountInput,
1571
+ outputSchema: z.toJSONSchema(getChatMembersCountOutput, { io: "output", unrepresentable: "any" })
1572
+ },
1573
+ ban_chat_member: {
1574
+ description: "Ban a user from a group, supergroup, or channel.",
1575
+ effect: "write",
1576
+ inputSchema: banChatMemberInput,
1577
+ outputSchema: z.toJSONSchema(banChatMemberOutput, { io: "output", unrepresentable: "any" })
1578
+ },
1579
+ unban_chat_member: {
1580
+ description: "Unban a user so they can join the chat again.",
1581
+ effect: "write",
1582
+ inputSchema: unbanChatMemberInput,
1583
+ outputSchema: z.toJSONSchema(unbanChatMemberOutput, { io: "output", unrepresentable: "any" })
1584
+ },
1585
+ restrict_chat_member: {
1586
+ description: "Set temporary or permanent permissions for one supergroup member.",
1587
+ effect: "write",
1588
+ inputSchema: restrictChatMemberInput,
1589
+ outputSchema: z.toJSONSchema(restrictChatMemberOutput, { io: "output", unrepresentable: "any" })
1590
+ },
1591
+ promote_chat_member: {
1592
+ description: "Promote, update, or demote a supergroup or channel administrator.",
1593
+ effect: "write",
1594
+ inputSchema: promoteChatMemberInput,
1595
+ outputSchema: z.toJSONSchema(promoteChatMemberOutput, { io: "output", unrepresentable: "any" })
1596
+ },
1597
+ set_chat_permissions: {
1598
+ description: "Set default permissions for all members of a group or supergroup.",
1599
+ effect: "write",
1600
+ inputSchema: setChatPermissionsInput,
1601
+ outputSchema: z.toJSONSchema(setChatPermissionsOutput, { io: "output", unrepresentable: "any" })
1602
+ },
1603
+ pin_chat_message: {
1604
+ description: "Pin a message in a Telegram chat.",
1605
+ effect: "write",
1606
+ inputSchema: pinChatMessageInput,
1607
+ outputSchema: z.toJSONSchema(pinChatMessageOutput, { io: "output", unrepresentable: "any" })
1608
+ },
1609
+ unpin_chat_message: {
1610
+ description: "Unpin one message, or the most recently pinned message, from a Telegram chat.",
1611
+ effect: "write",
1612
+ inputSchema: unpinChatMessageInput,
1613
+ outputSchema: z.toJSONSchema(unpinChatMessageOutput, { io: "output", unrepresentable: "any" })
1614
+ },
1615
+ unpin_all_chat_messages: {
1616
+ description: "Remove all pinned messages from a Telegram chat.",
1617
+ effect: "write",
1618
+ inputSchema: unpinAllChatMessagesInput,
1619
+ outputSchema: z.toJSONSchema(unpinAllChatMessagesOutput, { io: "output", unrepresentable: "any" })
1620
+ },
1621
+ approve_chat_join_request: {
1622
+ description: "Approve a user's pending request to join a Telegram chat.",
1623
+ effect: "write",
1624
+ inputSchema: approveChatJoinRequestInput,
1625
+ outputSchema: z.toJSONSchema(approveChatJoinRequestOutput, { io: "output", unrepresentable: "any" })
1626
+ },
1627
+ decline_chat_join_request: {
1628
+ description: "Decline a user's pending request to join a Telegram chat.",
1629
+ effect: "write",
1630
+ inputSchema: declineChatJoinRequestInput,
1631
+ outputSchema: z.toJSONSchema(declineChatJoinRequestOutput, { io: "output", unrepresentable: "any" })
1632
+ },
1633
+ delete_message: {
1634
+ description: "Delete a message from a chat.",
1635
+ effect: "destructive",
1636
+ inputSchema: deleteMessageInput,
1637
+ outputSchema: z.toJSONSchema(deleteMessageOutput, { io: "output", unrepresentable: "any" })
1638
+ },
1639
+ forward_message: {
1640
+ description: "Forward a message from one chat to another.",
1641
+ effect: "write",
1642
+ inputSchema: forwardMessageInput,
1643
+ outputSchema: z.toJSONSchema(forwardMessageOutput, { io: "output", unrepresentable: "any" })
1644
+ },
1645
+ send_location: {
1646
+ description: "Send a map location to a chat.",
1647
+ effect: "write",
1648
+ inputSchema: sendLocationInput,
1649
+ outputSchema: z.toJSONSchema(sendLocationOutput, { io: "output", unrepresentable: "any" })
1650
+ },
1651
+ export_chat_invite_link: {
1652
+ description: "Export the primary invite link for a Telegram chat.",
1653
+ effect: "read",
1654
+ inputSchema: exportChatInviteLinkInput,
1655
+ outputSchema: z.toJSONSchema(exportChatInviteLinkOutput, { io: "output", unrepresentable: "any" })
1656
+ },
1657
+ create_chat_invite_link: {
1658
+ description: "Create an additional Telegram chat invite link with optional expiry or approval rules.",
1659
+ effect: "write",
1660
+ inputSchema: createChatInviteLinkInput,
1661
+ outputSchema: z.toJSONSchema(createChatInviteLinkOutput, { io: "output", unrepresentable: "any" })
1662
+ },
1663
+ edit_chat_invite_link: {
1664
+ description: "Edit an additional Telegram chat invite link created by the bot.",
1665
+ effect: "write",
1666
+ inputSchema: editChatInviteLinkInput,
1667
+ outputSchema: z.toJSONSchema(editChatInviteLinkOutput, { io: "output", unrepresentable: "any" })
1668
+ },
1669
+ revoke_chat_invite_link: {
1670
+ description: "Revoke a Telegram chat invite link created by the bot.",
1671
+ effect: "destructive",
1672
+ inputSchema: revokeChatInviteLinkInput,
1673
+ outputSchema: z.toJSONSchema(revokeChatInviteLinkOutput, { io: "output", unrepresentable: "any" })
1674
+ },
1675
+ answer_callback_query: {
1676
+ description: "Answer an inline keyboard callback query.",
1677
+ effect: "write",
1678
+ inputSchema: answerCallbackQueryInput,
1679
+ outputSchema: z.toJSONSchema(answerCallbackQueryOutput, { io: "output", unrepresentable: "any" })
1680
+ },
1681
+ set_my_commands: {
1682
+ description: "Set the bot command list exposed in Telegram clients.",
1683
+ effect: "write",
1684
+ inputSchema: setMyCommandsInput,
1685
+ outputSchema: z.toJSONSchema(setMyCommandsOutput, { io: "output", unrepresentable: "any" })
1686
+ },
1687
+ set_webhook: {
1688
+ description: "Configure a webhook endpoint for update delivery.",
1689
+ effect: "write",
1690
+ inputSchema: setWebhookInput,
1691
+ outputSchema: z.toJSONSchema(setWebhookOutput, { io: "output", unrepresentable: "any" })
1692
+ },
1693
+ delete_webhook: {
1694
+ description: "Delete the configured webhook and optionally drop pending updates.",
1695
+ effect: "destructive",
1696
+ inputSchema: deleteWebhookInput,
1697
+ outputSchema: z.toJSONSchema(deleteWebhookOutput, { io: "output", unrepresentable: "any" })
1698
+ }
1699
+ };
1700
+
1701
+ // ../plugins/src/telegram/index.ts
1702
+ function createTelegramPlugin() {
1703
+ return createProviderPlugin({
1704
+ description: "Telegram Bot",
1705
+ actions: telegramActions,
1706
+ // 上游 credentialValidators 就是打 getMe 试 token,这里对应到同一个 action:
1707
+ // effect 是 read、入参是空 strictObject,满足探针的三个条件。
1708
+ credentialProbe: "get_me",
1709
+ handlers: {
1710
+ get_me: getMe,
1711
+ get_webhook_info: getWebhookInfo,
1712
+ get_updates: getUpdates,
1713
+ send_message: sendMessage,
1714
+ copy_message: copyMessage,
1715
+ copy_messages: copyMessages,
1716
+ forward_messages: forwardMessages,
1717
+ delete_messages: deleteMessages,
1718
+ set_message_reaction: setMessageReaction,
1719
+ send_chat_action: sendChatAction,
1720
+ send_video: sendVideo,
1721
+ send_audio: sendAudio,
1722
+ send_voice: sendVoice,
1723
+ send_animation: sendAnimation,
1724
+ send_media_group: sendMediaGroup,
1725
+ send_contact: sendContact,
1726
+ send_venue: sendVenue,
1727
+ send_dice: sendDice,
1728
+ get_business_connection: getBusinessConnection,
1729
+ read_business_message: readBusinessMessage,
1730
+ delete_business_messages: deleteBusinessMessages,
1731
+ edit_message_text: editMessageText,
1732
+ send_photo: sendPhoto,
1733
+ send_document: sendDocument,
1734
+ send_poll: sendPoll,
1735
+ get_chat: getChat,
1736
+ get_chat_member: getChatMember,
1737
+ get_chat_administrators: getChatAdministrators,
1738
+ get_chat_members_count: getChatMembersCount,
1739
+ ban_chat_member: banChatMember,
1740
+ unban_chat_member: unbanChatMember,
1741
+ restrict_chat_member: restrictChatMember,
1742
+ promote_chat_member: promoteChatMember,
1743
+ set_chat_permissions: setChatPermissions,
1744
+ pin_chat_message: pinChatMessage,
1745
+ unpin_chat_message: unpinChatMessage,
1746
+ unpin_all_chat_messages: unpinAllChatMessages,
1747
+ approve_chat_join_request: approveChatJoinRequest,
1748
+ decline_chat_join_request: declineChatJoinRequest,
1749
+ delete_message: deleteMessage,
1750
+ forward_message: forwardMessage,
1751
+ send_location: sendLocation,
1752
+ export_chat_invite_link: exportChatInviteLink,
1753
+ create_chat_invite_link: createChatInviteLink,
1754
+ edit_chat_invite_link: editChatInviteLink,
1755
+ revoke_chat_invite_link: revokeChatInviteLink,
1756
+ answer_callback_query: answerCallbackQuery,
1757
+ set_my_commands: setMyCommands,
1758
+ set_webhook: setWebhook,
1759
+ delete_webhook: deleteWebhook
1760
+ }
1761
+ });
1762
+ }
1763
+ var telegram_default = createTelegramPlugin();
1764
+ export {
1765
+ createTelegramPlugin,
1766
+ telegram_default as default
1767
+ };