@mastra/telegram 0.1.0 → 0.1.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,10 +1,9 @@
1
- import { WaitUntilFn, StreamingConfig, ChannelHandlers, ChannelConfig, ChannelAdapterConfig, ChannelProvider, ChannelPlatformInfo, ChannelConnectResult, ChannelInstallationInfo } from '@mastra/core/channels';
2
- import { Mastra } from '@mastra/core/mastra';
3
- import { ApiRoute } from '@mastra/core/server';
4
- import { TelegramAdapterConfig, TelegramAdapter, TelegramUser } from '@chat-adapter/telegram';
5
- export { TelegramAdapter, createTelegramAdapter } from '@chat-adapter/telegram';
6
- import { ChannelsStorage } from '@mastra/core/storage';
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 ["message", "edited_message", "channel_post", "edited_channel_post", "callback_query", "message_reaction"];
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
- /** 1-32 chars, lowercase `[a-z0-9_]`, no leading slash. */
28
- command: string;
29
- /** 1-256 chars. */
30
- description: string;
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
- command: string;
35
- description?: string;
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
- * Public HTTPS base URL used to register per-bot webhooks (`setWebhook`).
53
- * May be omitted and auto-detected from the Mastra server config, or set later.
54
- */
55
- baseUrl?: string;
56
- /**
57
- * Persistence for bot installations. Defaults to Mastra's channels storage
58
- * when the provider is attached to a Mastra instance with storage, and falls
59
- * back to an in-memory store otherwise (dev/test — not persisted across restarts).
60
- */
61
- storage?: ChannelsStorage;
62
- /**
63
- * Override the Telegram Bot API origin (e.g. a self-hosted Bot API server or
64
- * a test mock).
65
- *
66
- * @default 'https://api.telegram.org'
67
- */
68
- apiBaseUrl?: string;
69
- /**
70
- * Passphrase for encrypting `botToken`/`secretToken` at rest (AES-256-GCM).
71
- * Defaults to the `MASTRA_ENCRYPTION_KEY` env var. When unset, secrets are
72
- * stored in plaintext (fine for the in-memory dev store; set a key for any
73
- * persistent backend).
74
- */
75
- encryptionKey?: string;
76
- /**
77
- * Receive transport. Setting a webhook and long-polling are mutually
78
- * exclusive; the provider manages the switch per bot.
79
- *
80
- * @default 'auto'
81
- */
82
- mode?: TelegramMode;
83
- /**
84
- * Update types to request in `setWebhook`. Defaults to
85
- * {@link DEFAULT_ALLOWED_UPDATES}.
86
- */
87
- allowedUpdates?: string[];
88
- /**
89
- * Long-polling tuning forwarded to the adapter's `getUpdates` loop when running
90
- * in polling mode (`timeout`, `limit`, `allowedUpdates`, `retryDelayMs`, …).
91
- * Ignored in webhook mode.
92
- */
93
- longPolling?: TelegramAdapterConfig['longPolling'];
94
- /**
95
- * Keep the serverless invocation alive while the agent stream runs after the
96
- * webhook returns 200 (Vercel/AWS Lambda). Cloudflare/Netlify resolve this
97
- * automatically. See `ChannelConfig.waitUntil`.
98
- */
99
- waitUntil?: WaitUntilFn;
100
- /**
101
- * Default commands registered via `setMyCommands` for every connected agent
102
- * (a per-agent list can override via {@link TelegramConnectOptions.commands}).
103
- * Defaults to the conventional `/start` `/help` `/settings` seed.
104
- */
105
- commands?: TelegramCommand[];
106
- /**
107
- * Command scope passed to `setMyCommands` (e.g. `{ type: 'all_private_chats' }`).
108
- * Omitted → Telegram's default scope.
109
- * @see https://core.telegram.org/bots/api#botcommandscope
110
- */
111
- commandScope?: Record<string, unknown>;
112
- /**
113
- * Stream agent text to Telegram as it generates, via the adapter's
114
- * post-and-edit (`editMessageText`) loop. Telegram has no native token
115
- * streaming, so this chunk-edits the reply (4096-char cap handled by the
116
- * adapter).
117
- *
118
- * @default true
119
- */
120
- streaming?: StreamingConfig;
121
- /**
122
- * Keep a typing indicator alive during generation (`sendChatAction`, re-sent
123
- * as it auto-clears). Set `false` to disable.
124
- *
125
- * @default true
126
- */
127
- typingStatus?: boolean;
128
- /**
129
- * Override built-in event handlers (`onDirectMessage`, `onMention`,
130
- * `onSubscribedMessage`). Forwarded to `AgentChannels`.
131
- */
132
- handlers?: ChannelHandlers;
133
- /** Which media types to send inline to the model. See `ChannelConfig.inlineMedia`. */
134
- inlineMedia?: ChannelConfig['inlineMedia'];
135
- /** Promote URLs in message text to file parts. See `ChannelConfig.inlineLinks`. */
136
- inlineLinks?: ChannelConfig['inlineLinks'];
137
- /** State adapter for deduplication, locking, and subscriptions. See `ChannelConfig.state`. */
138
- state?: ChannelConfig['state'];
139
- /** Fetch recent thread messages when the agent joins mid-conversation. See `ChannelConfig.threadContext`. */
140
- threadContext?: ChannelConfig['threadContext'];
141
- /** Additional options passed directly to the Chat SDK. See `ChannelConfig.chatOptions`. */
142
- chatOptions?: ChannelConfig['chatOptions'];
143
- /** Resolve the memory `resourceId` before a channel thread is created. See `ChannelConfig.resolveResourceId`. */
144
- resolveResourceId?: ChannelConfig['resolveResourceId'];
145
- /**
146
- * Resolve `waitUntil` from the request's Hono `Context` (serverless runtimes
147
- * whose `waitUntil` derives from the request). See `ChannelConfig.resolveWaitUntil`.
148
- */
149
- resolveWaitUntil?: ChannelConfig['resolveWaitUntil'];
150
- /** CORS configuration for the generated Telegram webhook route. */
151
- cors?: ChannelAdapterConfig['cors'];
152
- /** Override how errors are rendered in Telegram messages. See `ChannelAdapterConfig.formatError`. */
153
- formatError?: ChannelAdapterConfig['formatError'];
154
- /**
155
- * How tool calls are rendered in the reply. Telegram has no Block Kit, so
156
- * `'cards'`/`'grouped'`/`'timeline'` degrade to plain fallback text — this
157
- * defaults to `'text'` (unlike Slack's `'grouped'`). See `ChannelAdapterConfig.toolDisplay`.
158
- *
159
- * @default 'text'
160
- */
161
- toolDisplay?: ChannelAdapterConfig['toolDisplay'];
162
- /**
163
- * Whether to expose channel reaction tools (`add_reaction`/`remove_reaction`)
164
- * to the agent. Set `false` for models without function calling. See `ChannelConfig.tools`.
165
- *
166
- * @default true
167
- */
168
- tools?: ChannelConfig['tools'];
169
- /** Logger forwarded to the underlying `TelegramAdapter` for internal error reporting. */
170
- logger?: TelegramAdapterConfig['logger'];
171
- /** Called after an agent successfully connects a bot and the installation is persisted. */
172
- onInstall?: (installation: TelegramInstallation) => void | Promise<void>;
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
- * A BotFather bot token. When supplied it is validated via `getMe` and the
178
- * installation becomes active immediately (`{ type: 'immediate' }`). Omit it
179
- * to receive a BotFather deep link instead (`{ type: 'deep_link' }`).
180
- */
181
- botToken?: string;
182
- /** Display name for the bot. Defaults to the bot's `@username` from `getMe`. */
183
- name?: string;
184
- /**
185
- * Commands to register via `setMyCommands` for this agent. Overrides
186
- * {@link TelegramProviderConfig.commands}. Defaults to the `/start` `/help`
187
- * `/settings` seed when neither is set.
188
- */
189
- commands?: TelegramCommand[];
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
- /** Stable installation id. */
197
- id: string;
198
- /** The agent this bot is bound to. */
199
- agentId: string;
200
- /**
201
- * Opaque id embedded in the webhook route path (`/telegram/events/:webhookId`).
202
- * Never the secret — the secret travels only in the request header.
203
- */
204
- webhookId: string;
205
- /** Whether a bot token has been ingested and validated. */
206
- status: 'active' | 'pending';
207
- /** BotFather bot token — the full credential. Present once ingested. */
208
- botToken?: string;
209
- /**
210
- * Per-bot webhook shared secret, echoed by Telegram as the
211
- * `X-Telegram-Bot-Api-Secret-Token` header on every inbound POST.
212
- */
213
- secretToken?: string;
214
- /** The bot's `@username`, resolved from `getMe`. */
215
- username?: string;
216
- /** The webhook URL registered with `setWebhook` (M1 — issue `mastra-telegram-i2g.3`). */
217
- webhookUrl?: string;
218
- /** Normalized commands registered via `setMyCommands`. */
219
- commands?: BotCommand[];
220
- /** When the installation was created. */
221
- installedAt: Date;
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
- streaming: StreamingConfig;
233
- typingStatus: boolean;
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
- #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 | undefined;
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
- #private;
334
- private readonly storage;
335
- private readonly encryptionKey?;
336
- constructor(storage: ChannelsStorage, encryptionKey?: string | undefined);
337
- /** The active or pending installation for an agent, if any. */
338
- getByAgent(agentId: string): Promise<TelegramInstallation | null>;
339
- /** Look up an installation by the routing id in its webhook path (M1 dispatch). */
340
- getByWebhookId(webhookId: string): Promise<TelegramInstallation | null>;
341
- /** Insert or replace an installation. */
342
- save(installation: TelegramInstallation): Promise<void>;
343
- /** All Telegram installations (active and pending). */
344
- list(): Promise<TelegramInstallation[]>;
345
- /** Remove an agent's installation, if present. */
346
- deleteByAgent(agentId: string): Promise<void>;
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
- /** Public HTTPS URL Telegram will POST updates to. */
361
- url: string;
362
- /** Shared secret echoed back as `X-Telegram-Bot-Api-Secret-Token` on every POST. */
363
- secretToken: string;
364
- /** Update types to receive. Note: `message_reaction` must be listed explicitly. */
365
- allowedUpdates?: string[];
366
- /** Drop the backlog of updates queued while the bot was offline. */
367
- dropPendingUpdates?: boolean;
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
- /** The command list to publish (replaces the existing set for the scope). */
386
- commands: BotCommand[];
387
- /** Command scope (e.g. `{ type: 'all_private_chats' }`). Omit for the default scope. */
388
- scope?: Record<string, unknown>;
389
- /** Two-letter language code for a localized command set. */
390
- languageCode?: string;
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