@mastra/telegram 0.1.0 → 0.1.1-alpha.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.
- package/LICENSE.md +6 -4
- package/README.md +21 -109
- package/dist/index.cjs +23543 -18888
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +279 -275
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +687 -640
- package/dist/index.js.map +1 -1
- package/package.json +7 -8
- package/CHANGELOG.md +0 -55
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { ChannelAdapterConfig, ChannelConfig, ChannelConnectResult, ChannelHandlers, ChannelInstallationInfo, ChannelPlatformInfo, ChannelProvider, StreamingConfig, WaitUntilFn } from "@mastra/core/channels";
|
|
2
|
+
import { ChannelsStorage } from "@mastra/core/storage";
|
|
3
|
+
import { TelegramAdapter, TelegramAdapter as TelegramAdapter$1, TelegramAdapterConfig, TelegramUser, createTelegramAdapter } from "@chat-adapter/telegram";
|
|
4
|
+
import { Mastra } from "@mastra/core/mastra";
|
|
5
|
+
import { ApiRoute } from "@mastra/core/server";
|
|
6
|
+
//#region src/types.d.ts
|
|
8
7
|
/** Default Telegram Bot API origin. */
|
|
9
8
|
declare const TELEGRAM_API_BASE_URL = "https://api.telegram.org";
|
|
10
9
|
/**
|
|
@@ -18,21 +17,21 @@ type TelegramMode = 'auto' | 'webhook' | 'polling';
|
|
|
18
17
|
* Default update types requested from Telegram. `message_reaction` must be
|
|
19
18
|
* listed explicitly (Telegram omits it otherwise).
|
|
20
19
|
*/
|
|
21
|
-
declare const DEFAULT_ALLOWED_UPDATES: readonly [
|
|
20
|
+
declare const DEFAULT_ALLOWED_UPDATES: readonly ['message', 'edited_message', 'channel_post', 'edited_channel_post', 'callback_query', 'message_reaction'];
|
|
22
21
|
/**
|
|
23
22
|
* A Telegram bot command as it goes over the wire (`setMyCommands`).
|
|
24
23
|
* @see https://core.telegram.org/bots/api#botcommand
|
|
25
24
|
*/
|
|
26
25
|
interface BotCommand {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
/** 1-32 chars, lowercase `[a-z0-9_]`, no leading slash. */
|
|
27
|
+
command: string;
|
|
28
|
+
/** 1-256 chars. */
|
|
29
|
+
description: string;
|
|
31
30
|
}
|
|
32
31
|
/** Command input accepted by {@link TelegramProvider} — a bare name or a `{ command, description }`. */
|
|
33
32
|
type TelegramCommand = string | {
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
command: string;
|
|
34
|
+
description?: string;
|
|
36
35
|
};
|
|
37
36
|
/**
|
|
38
37
|
* Deep link that opens BotFather so an operator can create a new bot with
|
|
@@ -48,179 +47,180 @@ declare const BOTFATHER_DEEP_LINK = "https://t.me/botfather";
|
|
|
48
47
|
* store of bot tokens — see {@link TelegramInstallation}.
|
|
49
48
|
*/
|
|
50
49
|
interface TelegramProviderConfig {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Public HTTPS base URL used to register per-bot webhooks (`setWebhook`).
|
|
52
|
+
* May be omitted and auto-detected from the Mastra server config, or set later.
|
|
53
|
+
*/
|
|
54
|
+
baseUrl?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Persistence for bot installations. Defaults to Mastra's channels storage
|
|
57
|
+
* when the provider is attached to a Mastra instance with storage, and falls
|
|
58
|
+
* back to an in-memory store otherwise (dev/test — not persisted across restarts).
|
|
59
|
+
*/
|
|
60
|
+
storage?: ChannelsStorage;
|
|
61
|
+
/**
|
|
62
|
+
* Override the Telegram Bot API origin (e.g. a self-hosted Bot API server or
|
|
63
|
+
* a test mock).
|
|
64
|
+
*
|
|
65
|
+
* @default 'https://api.telegram.org'
|
|
66
|
+
*/
|
|
67
|
+
apiBaseUrl?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Passphrase for encrypting `botToken`/`secretToken` at rest (AES-256-GCM).
|
|
70
|
+
* Defaults to the `MASTRA_ENCRYPTION_KEY` env var. When unset, secrets are
|
|
71
|
+
* stored in plaintext (fine for the in-memory dev store; set a key for any
|
|
72
|
+
* persistent backend).
|
|
73
|
+
*/
|
|
74
|
+
encryptionKey?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Receive transport. Setting a webhook and long-polling are mutually
|
|
77
|
+
* exclusive; the provider manages the switch per bot.
|
|
78
|
+
*
|
|
79
|
+
* @default 'auto'
|
|
80
|
+
*/
|
|
81
|
+
mode?: TelegramMode;
|
|
82
|
+
/**
|
|
83
|
+
* Update types to request in `setWebhook`. Defaults to
|
|
84
|
+
* {@link DEFAULT_ALLOWED_UPDATES}.
|
|
85
|
+
*/
|
|
86
|
+
allowedUpdates?: string[];
|
|
87
|
+
/**
|
|
88
|
+
* Long-polling tuning forwarded to the adapter's `getUpdates` loop when running
|
|
89
|
+
* in polling mode (`timeout`, `limit`, `allowedUpdates`, `retryDelayMs`, …).
|
|
90
|
+
* Ignored in webhook mode.
|
|
91
|
+
*/
|
|
92
|
+
longPolling?: TelegramAdapterConfig['longPolling'];
|
|
93
|
+
/**
|
|
94
|
+
* Keep the serverless invocation alive while the agent stream runs after the
|
|
95
|
+
* webhook returns 200 (Vercel/AWS Lambda). Cloudflare/Netlify resolve this
|
|
96
|
+
* automatically. See `ChannelConfig.waitUntil`.
|
|
97
|
+
*/
|
|
98
|
+
waitUntil?: WaitUntilFn;
|
|
99
|
+
/**
|
|
100
|
+
* Default commands registered via `setMyCommands` for every connected agent
|
|
101
|
+
* (a per-agent list can override via {@link TelegramConnectOptions.commands}).
|
|
102
|
+
* Defaults to the conventional `/start` `/help` `/settings` seed.
|
|
103
|
+
*/
|
|
104
|
+
commands?: TelegramCommand[];
|
|
105
|
+
/**
|
|
106
|
+
* Command scope passed to `setMyCommands` (e.g. `{ type: 'all_private_chats' }`).
|
|
107
|
+
* Omitted → Telegram's default scope.
|
|
108
|
+
* @see https://core.telegram.org/bots/api#botcommandscope
|
|
109
|
+
*/
|
|
110
|
+
commandScope?: Record<string, unknown>;
|
|
111
|
+
/**
|
|
112
|
+
* Stream agent text to Telegram as it generates, via the adapter's
|
|
113
|
+
* post-and-edit (`editMessageText`) loop. Telegram has no native token
|
|
114
|
+
* streaming, so this chunk-edits the reply (4096-char cap handled by the
|
|
115
|
+
* adapter).
|
|
116
|
+
*
|
|
117
|
+
* @default true
|
|
118
|
+
*/
|
|
119
|
+
streaming?: StreamingConfig;
|
|
120
|
+
/**
|
|
121
|
+
* Keep a typing indicator alive during generation (`sendChatAction`, re-sent
|
|
122
|
+
* as it auto-clears). Set `false` to disable.
|
|
123
|
+
*
|
|
124
|
+
* @default true
|
|
125
|
+
*/
|
|
126
|
+
typingStatus?: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Override built-in event handlers (`onDirectMessage`, `onMention`,
|
|
129
|
+
* `onSubscribedMessage`). Forwarded to `AgentChannels`.
|
|
130
|
+
*/
|
|
131
|
+
handlers?: ChannelHandlers;
|
|
132
|
+
/** Which media types to send inline to the model. See `ChannelConfig.inlineMedia`. */
|
|
133
|
+
inlineMedia?: ChannelConfig['inlineMedia'];
|
|
134
|
+
/** Promote URLs in message text to file parts. See `ChannelConfig.inlineLinks`. */
|
|
135
|
+
inlineLinks?: ChannelConfig['inlineLinks'];
|
|
136
|
+
/** State adapter for deduplication, locking, and subscriptions. See `ChannelConfig.state`. */
|
|
137
|
+
state?: ChannelConfig['state'];
|
|
138
|
+
/** Fetch recent thread messages when the agent joins mid-conversation. See `ChannelConfig.threadContext`. */
|
|
139
|
+
threadContext?: ChannelConfig['threadContext'];
|
|
140
|
+
/** Additional options passed directly to the Chat SDK. See `ChannelConfig.chatOptions`. */
|
|
141
|
+
chatOptions?: ChannelConfig['chatOptions'];
|
|
142
|
+
/** Resolve the memory `resourceId` before a channel thread is created. See `ChannelConfig.resolveResourceId`. */
|
|
143
|
+
resolveResourceId?: ChannelConfig['resolveResourceId'];
|
|
144
|
+
/**
|
|
145
|
+
* Resolve `waitUntil` from the request's Hono `Context` (serverless runtimes
|
|
146
|
+
* whose `waitUntil` derives from the request). See `ChannelConfig.resolveWaitUntil`.
|
|
147
|
+
*/
|
|
148
|
+
resolveWaitUntil?: ChannelConfig['resolveWaitUntil'];
|
|
149
|
+
/** CORS configuration for the generated Telegram webhook route. */
|
|
150
|
+
cors?: ChannelAdapterConfig['cors'];
|
|
151
|
+
/** Override how errors are rendered in Telegram messages. See `ChannelAdapterConfig.formatError`. */
|
|
152
|
+
formatError?: ChannelAdapterConfig['formatError'];
|
|
153
|
+
/**
|
|
154
|
+
* How tool calls are rendered in the reply. Telegram has no Block Kit, so
|
|
155
|
+
* `'cards'`/`'grouped'`/`'timeline'` degrade to plain fallback text — this
|
|
156
|
+
* defaults to `'text'` (unlike Slack's `'grouped'`). See `ChannelAdapterConfig.toolDisplay`.
|
|
157
|
+
*
|
|
158
|
+
* @default 'text'
|
|
159
|
+
*/
|
|
160
|
+
toolDisplay?: ChannelAdapterConfig['toolDisplay'];
|
|
161
|
+
/**
|
|
162
|
+
* Whether to expose channel reaction tools (`add_reaction`/`remove_reaction`)
|
|
163
|
+
* to the agent. Set `false` for models without function calling. See `ChannelConfig.tools`.
|
|
164
|
+
*
|
|
165
|
+
* @default true
|
|
166
|
+
*/
|
|
167
|
+
tools?: ChannelConfig['tools'];
|
|
168
|
+
/** Logger forwarded to the underlying `TelegramAdapter` for internal error reporting. */
|
|
169
|
+
logger?: TelegramAdapterConfig['logger'];
|
|
170
|
+
/** Called after an agent successfully connects a bot and the installation is persisted. */
|
|
171
|
+
onInstall?: (installation: TelegramInstallation) => void | Promise<void>;
|
|
173
172
|
}
|
|
174
173
|
/** Options accepted by {@link TelegramProvider.connect}. */
|
|
175
174
|
interface TelegramConnectOptions {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
175
|
+
/**
|
|
176
|
+
* A BotFather bot token. When supplied it is validated via `getMe` and the
|
|
177
|
+
* installation becomes active immediately (`{ type: 'immediate' }`). Omit it
|
|
178
|
+
* to receive a BotFather deep link instead (`{ type: 'deep_link' }`).
|
|
179
|
+
*/
|
|
180
|
+
botToken?: string;
|
|
181
|
+
/** Display name for the bot. Defaults to the bot's `@username` from `getMe`. */
|
|
182
|
+
name?: string;
|
|
183
|
+
/**
|
|
184
|
+
* Commands to register via `setMyCommands` for this agent. Overrides
|
|
185
|
+
* {@link TelegramProviderConfig.commands}. Defaults to the `/start` `/help`
|
|
186
|
+
* `/settings` seed when neither is set.
|
|
187
|
+
*/
|
|
188
|
+
commands?: TelegramCommand[];
|
|
190
189
|
}
|
|
191
190
|
/**
|
|
192
191
|
* A registered Telegram bot bound to a single agent (one bot = one agent).
|
|
193
192
|
* Persisted through {@link TelegramInstallStore}.
|
|
194
193
|
*/
|
|
195
194
|
interface TelegramInstallation {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
195
|
+
/** Stable installation id. */
|
|
196
|
+
id: string;
|
|
197
|
+
/** The agent this bot is bound to. */
|
|
198
|
+
agentId: string;
|
|
199
|
+
/**
|
|
200
|
+
* Opaque id embedded in the webhook route path (`/telegram/events/:webhookId`).
|
|
201
|
+
* Never the secret — the secret travels only in the request header.
|
|
202
|
+
*/
|
|
203
|
+
webhookId: string;
|
|
204
|
+
/** Whether a bot token has been ingested and validated. */
|
|
205
|
+
status: 'active' | 'pending';
|
|
206
|
+
/** BotFather bot token — the full credential. Present once ingested. */
|
|
207
|
+
botToken?: string;
|
|
208
|
+
/**
|
|
209
|
+
* Per-bot webhook shared secret, echoed by Telegram as the
|
|
210
|
+
* `X-Telegram-Bot-Api-Secret-Token` header on every inbound POST.
|
|
211
|
+
*/
|
|
212
|
+
secretToken?: string;
|
|
213
|
+
/** The bot's `@username`, resolved from `getMe`. */
|
|
214
|
+
username?: string;
|
|
215
|
+
/** The webhook URL registered with `setWebhook` (M1 — issue `mastra-telegram-i2g.3`). */
|
|
216
|
+
webhookUrl?: string;
|
|
217
|
+
/** Normalized commands registered via `setMyCommands`. */
|
|
218
|
+
commands?: BotCommand[];
|
|
219
|
+
/** When the installation was created. */
|
|
220
|
+
installedAt: Date;
|
|
222
221
|
}
|
|
223
|
-
|
|
222
|
+
//#endregion
|
|
223
|
+
//#region src/telegram-provider.d.ts
|
|
224
224
|
/**
|
|
225
225
|
* Resolve the per-adapter streaming/typing config the provider applies to the
|
|
226
226
|
* Telegram entry in `AgentChannels.adapters`. This is the wrapper's stream
|
|
@@ -229,8 +229,8 @@ interface TelegramInstallation {
|
|
|
229
229
|
* indicator alive — both default on.
|
|
230
230
|
*/
|
|
231
231
|
declare function resolveTelegramAdapterConfig(config: Pick<TelegramProviderConfig, 'streaming' | 'typingStatus'>): {
|
|
232
|
-
|
|
233
|
-
|
|
232
|
+
streaming: StreamingConfig;
|
|
233
|
+
typingStatus: boolean;
|
|
234
234
|
};
|
|
235
235
|
/**
|
|
236
236
|
* Telegram channel provider for Mastra — a {@link ChannelProvider} over
|
|
@@ -255,71 +255,72 @@ declare function resolveTelegramAdapterConfig(config: Pick<TelegramProviderConfi
|
|
|
255
255
|
* ```
|
|
256
256
|
*/
|
|
257
257
|
declare class TelegramProvider implements ChannelProvider {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
258
|
+
#private;
|
|
259
|
+
readonly id = "telegram";
|
|
260
|
+
constructor(config?: TelegramProviderConfig);
|
|
261
|
+
/**
|
|
262
|
+
* Called by Mastra when this channel is registered.
|
|
263
|
+
* @internal
|
|
264
|
+
*/
|
|
265
|
+
__attach(mastra: Mastra): void;
|
|
266
|
+
/**
|
|
267
|
+
* Per-bot webhook route. A single POST endpoint keyed by an opaque
|
|
268
|
+
* `webhookId`; the per-bot secret is verified from the request header, never
|
|
269
|
+
* carried in the URL. Auto-initializes on first hit (mirrors `@mastra/slack`).
|
|
270
|
+
*/
|
|
271
|
+
getRoutes(): ApiRoute[];
|
|
272
|
+
/** Discovery metadata for the editor UI. */
|
|
273
|
+
getInfo(): ChannelPlatformInfo;
|
|
274
|
+
/**
|
|
275
|
+
* Restore installations from storage: rebuild an adapter per active bot and
|
|
276
|
+
* inject `AgentChannels` so the agent can receive events immediately.
|
|
277
|
+
* Idempotent. Does not re-register webhooks (they persist server-side across
|
|
278
|
+
* restarts); reconnect an agent if its `baseUrl` changed.
|
|
279
|
+
*/
|
|
280
|
+
initialize(): Promise<void>;
|
|
281
|
+
/**
|
|
282
|
+
* Update runtime provider settings. Telegram has no global auth credential to
|
|
283
|
+
* clear (per-bot tokens are managed via {@link connect}/{@link disconnect}),
|
|
284
|
+
* so `null` is a no-op; an object merges `apiBaseUrl`/`baseUrl` overrides.
|
|
285
|
+
*/
|
|
286
|
+
configure(credentials: {
|
|
287
|
+
apiBaseUrl?: string;
|
|
288
|
+
baseUrl?: string;
|
|
289
|
+
} | null): Promise<void>;
|
|
290
|
+
/**
|
|
291
|
+
* Connect an agent to a Telegram bot.
|
|
292
|
+
*
|
|
293
|
+
* - With `options.botToken`: validate via `getMe`, mint a per-bot webhook
|
|
294
|
+
* secret, persist the installation, register the transport (webhook or
|
|
295
|
+
* polling), and return `{ type: 'immediate' }`.
|
|
296
|
+
* - Without a token: persist a pending installation and return
|
|
297
|
+
* `{ type: 'deep_link' }` pointing at BotFather.
|
|
298
|
+
*/
|
|
299
|
+
connect(agentId: string, options?: TelegramConnectOptions): Promise<ChannelConnectResult>;
|
|
300
|
+
/** Disconnect an agent from Telegram, removing its webhook and installation. */
|
|
301
|
+
disconnect(agentId: string): Promise<void>;
|
|
302
|
+
/** List installations (public info only — no tokens or secrets). */
|
|
303
|
+
listInstallations(): Promise<ChannelInstallationInfo[]>;
|
|
304
|
+
/**
|
|
305
|
+
* Get the full installation for an agent (includes the bot token / secret).
|
|
306
|
+
* Returns `null` if the agent has no Telegram installation. Mirrors
|
|
307
|
+
* `SlackProvider.getInstallation`.
|
|
308
|
+
*/
|
|
309
|
+
getInstallation(agentId: string): Promise<TelegramInstallation | null>;
|
|
310
|
+
/**
|
|
311
|
+
* Whether at least one bot is actively registered. Mirrors
|
|
312
|
+
* `SlackProvider.isConfigured` (Telegram has no global credential to check —
|
|
313
|
+
* "configured" means an active installation exists).
|
|
314
|
+
*/
|
|
315
|
+
isConfigured(): boolean;
|
|
316
|
+
/**
|
|
317
|
+
* Get the live `TelegramAdapter` for an installation id, if one is active.
|
|
318
|
+
* Used for message formatting/posting. Mirrors `SlackProvider.getAdapter`.
|
|
319
|
+
*/
|
|
320
|
+
getAdapter(installationId: string): TelegramAdapter$1 | undefined;
|
|
321
321
|
}
|
|
322
|
-
|
|
322
|
+
//#endregion
|
|
323
|
+
//#region src/install-store.d.ts
|
|
323
324
|
/** Platform identifier used for every stored record and route. */
|
|
324
325
|
declare const PLATFORM = "telegram";
|
|
325
326
|
/**
|
|
@@ -330,24 +331,25 @@ declare const PLATFORM = "telegram";
|
|
|
330
331
|
* `secretToken` are AES-256-GCM encrypted at rest.
|
|
331
332
|
*/
|
|
332
333
|
declare class TelegramInstallStore {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
334
|
+
#private;
|
|
335
|
+
private readonly storage;
|
|
336
|
+
private readonly encryptionKey?;
|
|
337
|
+
constructor(storage: ChannelsStorage, encryptionKey?: string | undefined);
|
|
338
|
+
/** The active or pending installation for an agent, if any. */
|
|
339
|
+
getByAgent(agentId: string): Promise<TelegramInstallation | null>;
|
|
340
|
+
/** Look up an installation by the routing id in its webhook path (M1 dispatch). */
|
|
341
|
+
getByWebhookId(webhookId: string): Promise<TelegramInstallation | null>;
|
|
342
|
+
/** Insert or replace an installation. */
|
|
343
|
+
save(installation: TelegramInstallation): Promise<void>;
|
|
344
|
+
/** All Telegram installations (active and pending). */
|
|
345
|
+
list(): Promise<TelegramInstallation[]>;
|
|
346
|
+
/** Remove an agent's installation, if present. */
|
|
347
|
+
deleteByAgent(agentId: string): Promise<void>;
|
|
347
348
|
}
|
|
348
349
|
/** Project an installation to its public, secret-free info for the editor UI. */
|
|
349
350
|
declare function toInstallationInfo(install: TelegramInstallation): ChannelInstallationInfo;
|
|
350
|
-
|
|
351
|
+
//#endregion
|
|
352
|
+
//#region src/telegram-client.d.ts
|
|
351
353
|
/**
|
|
352
354
|
* Validate a bot token via `getMe` and resolve the bot's identity. Throws if
|
|
353
355
|
* the token is rejected or the returned user is not a bot.
|
|
@@ -357,14 +359,14 @@ declare function toInstallationInfo(install: TelegramInstallation): ChannelInsta
|
|
|
357
359
|
declare function getMe(botToken: string, apiBaseUrl?: string): Promise<TelegramUser>;
|
|
358
360
|
/** Options for {@link setWebhook}. */
|
|
359
361
|
interface SetWebhookOptions {
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
362
|
+
/** Public HTTPS URL Telegram will POST updates to. */
|
|
363
|
+
url: string;
|
|
364
|
+
/** Shared secret echoed back as `X-Telegram-Bot-Api-Secret-Token` on every POST. */
|
|
365
|
+
secretToken: string;
|
|
366
|
+
/** Update types to receive. Note: `message_reaction` must be listed explicitly. */
|
|
367
|
+
allowedUpdates?: string[];
|
|
368
|
+
/** Drop the backlog of updates queued while the bot was offline. */
|
|
369
|
+
dropPendingUpdates?: boolean;
|
|
368
370
|
}
|
|
369
371
|
/**
|
|
370
372
|
* Register a per-bot webhook. Setting a webhook disables `getUpdates`
|
|
@@ -382,12 +384,12 @@ declare function setWebhook(botToken: string, options: SetWebhookOptions, apiBas
|
|
|
382
384
|
declare function deleteWebhook(botToken: string, dropPendingUpdates?: boolean, apiBaseUrl?: string): Promise<void>;
|
|
383
385
|
/** Options for {@link setMyCommands}. */
|
|
384
386
|
interface SetMyCommandsOptions {
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
387
|
+
/** The command list to publish (replaces the existing set for the scope). */
|
|
388
|
+
commands: BotCommand[];
|
|
389
|
+
/** Command scope (e.g. `{ type: 'all_private_chats' }`). Omit for the default scope. */
|
|
390
|
+
scope?: Record<string, unknown>;
|
|
391
|
+
/** Two-letter language code for a localized command set. */
|
|
392
|
+
languageCode?: string;
|
|
391
393
|
}
|
|
392
394
|
/**
|
|
393
395
|
* Publish the bot's command list for a scope.
|
|
@@ -403,7 +405,8 @@ declare function setMyCommands(botToken: string, options: SetMyCommandsOptions,
|
|
|
403
405
|
* @see https://core.telegram.org/bots/api#setwebhook
|
|
404
406
|
*/
|
|
405
407
|
declare function generateSecretToken(): string;
|
|
406
|
-
|
|
408
|
+
//#endregion
|
|
409
|
+
//#region src/commands.d.ts
|
|
407
410
|
/**
|
|
408
411
|
* Conventional command seed registered when a connect provides none.
|
|
409
412
|
* @see https://core.telegram.org/bots/features#commands
|
|
@@ -417,5 +420,6 @@ declare const DEFAULT_COMMANDS: readonly TelegramCommand[];
|
|
|
417
420
|
* Empty or duplicate command names are dropped.
|
|
418
421
|
*/
|
|
419
422
|
declare function normalizeCommands(raw: readonly TelegramCommand[] | undefined): BotCommand[];
|
|
420
|
-
|
|
421
|
-
export { BOTFATHER_DEEP_LINK, type BotCommand, DEFAULT_ALLOWED_UPDATES, DEFAULT_COMMANDS, PLATFORM, type SetMyCommandsOptions, type SetWebhookOptions, TELEGRAM_API_BASE_URL, type TelegramCommand, type TelegramConnectOptions, TelegramInstallStore, type TelegramInstallation, type TelegramMode, TelegramProvider, type TelegramProviderConfig, deleteWebhook, generateSecretToken, getMe, normalizeCommands, resolveTelegramAdapterConfig, setMyCommands, setWebhook, toInstallationInfo };
|
|
423
|
+
//#endregion
|
|
424
|
+
export { BOTFATHER_DEEP_LINK, type BotCommand, DEFAULT_ALLOWED_UPDATES, DEFAULT_COMMANDS, PLATFORM, type SetMyCommandsOptions, type SetWebhookOptions, TELEGRAM_API_BASE_URL, TelegramAdapter, type TelegramCommand, type TelegramConnectOptions, TelegramInstallStore, type TelegramInstallation, type TelegramMode, TelegramProvider, type TelegramProviderConfig, createTelegramAdapter, deleteWebhook, generateSecretToken, getMe, normalizeCommands, resolveTelegramAdapterConfig, setMyCommands, setWebhook, toInstallationInfo };
|
|
425
|
+
//# sourceMappingURL=index.d.ts.map
|