@toolpack-sdk/agents 2.0.0-alpha.1 → 2.1.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/README.md +11 -7
- package/dist/{base-agent-Cx2kWzLF.d.ts → base-agent-DPdK4Pnl.d.cts} +100 -5
- package/dist/{base-agent-CjrUlo6Y.d.cts → base-agent-nU8pr4nu.d.ts} +100 -5
- package/dist/capabilities/index.cjs +19 -14
- package/dist/capabilities/index.d.cts +4 -3
- package/dist/capabilities/index.d.ts +4 -3
- package/dist/capabilities/index.js +19 -14
- package/dist/channels/index.cjs +2 -2
- package/dist/channels/index.d.cts +3 -615
- package/dist/channels/index.d.ts +3 -615
- package/dist/channels/index.js +2 -2
- package/dist/index-Du6S0eG7.d.cts +927 -0
- package/dist/index-o8Lbzv5N.d.ts +927 -0
- package/dist/index.cjs +111 -12
- package/dist/index.d.cts +71 -8
- package/dist/index.d.ts +71 -8
- package/dist/index.js +111 -12
- package/dist/{intent-classifier-agent-BLpDwKVf.d.ts → intent-classifier-agent-0JZDlhpk.d.ts} +2 -2
- package/dist/{intent-classifier-agent-BLXXcbNJ.d.cts → intent-classifier-agent-DxyfJWcm.d.cts} +2 -2
- package/dist/interceptors/index.d.cts +5 -4
- package/dist/interceptors/index.d.ts +5 -4
- package/dist/testing/index.d.cts +2 -2
- package/dist/testing/index.d.ts +2 -2
- package/dist/{types-BWoRx1ZE.d.cts → types-TB6yypig.d.cts} +38 -1
- package/dist/{types-BWoRx1ZE.d.ts → types-TB6yypig.d.ts} +38 -1
- package/package.json +5 -5
package/dist/channels/index.d.ts
CHANGED
|
@@ -1,616 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
export { B as BaseChannel, D as DiscordChannel, b as DiscordChannelConfig, E as EmailChannel, c as EmailChannelConfig, d as SMSChannel, e as SMSChannelConfig, f as ScheduledChannel, g as ScheduledChannelConfig, i as SlackChannel, j as SlackChannelConfig, T as TelegramChannel, k as TelegramChannelConfig, W as WebhookChannel, l as WebhookChannelConfig } from '../index-o8Lbzv5N.js';
|
|
2
|
+
import '../types-TB6yypig.js';
|
|
3
|
+
import 'toolpack-sdk';
|
|
3
4
|
import 'events';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Abstract base class for all agent channels.
|
|
7
|
-
* Channels handle the two-way communication between the external world and agents.
|
|
8
|
-
*/
|
|
9
|
-
declare abstract class BaseChannel {
|
|
10
|
-
/** Optional name for the channel - required for sendTo() routing */
|
|
11
|
-
name?: string;
|
|
12
|
-
/**
|
|
13
|
-
* Whether this is a trigger channel (no human recipient).
|
|
14
|
-
* Trigger channels like ScheduledChannel cannot use this.ask() since there's no human to answer.
|
|
15
|
-
* Conversation channels (Slack, Telegram, Webhook) can use this.ask().
|
|
16
|
-
*/
|
|
17
|
-
abstract readonly isTriggerChannel: boolean;
|
|
18
|
-
/** Message handler set by AgentRegistry */
|
|
19
|
-
protected _handler?: (input: AgentInput) => Promise<void>;
|
|
20
|
-
/**
|
|
21
|
-
* Start listening for incoming messages.
|
|
22
|
-
* Called by AgentRegistry when the SDK initializes.
|
|
23
|
-
*/
|
|
24
|
-
abstract listen(): void;
|
|
25
|
-
/**
|
|
26
|
-
* Send output back to the external world.
|
|
27
|
-
* @param output The agent's output to deliver
|
|
28
|
-
*/
|
|
29
|
-
abstract send(output: AgentOutput): Promise<void>;
|
|
30
|
-
/**
|
|
31
|
-
* Normalize an incoming event into AgentInput.
|
|
32
|
-
* Each channel implementation maps its specific event format.
|
|
33
|
-
* @param incoming Raw event from the external source
|
|
34
|
-
* @returns Normalized AgentInput
|
|
35
|
-
*/
|
|
36
|
-
abstract normalize(incoming: unknown): AgentInput;
|
|
37
|
-
/**
|
|
38
|
-
* Set the message handler. Called by AgentRegistry.
|
|
39
|
-
* @param handler Function to call when a message arrives
|
|
40
|
-
*/
|
|
41
|
-
onMessage(handler: (input: AgentInput) => Promise<void>): void;
|
|
42
|
-
/**
|
|
43
|
-
* Helper to call the handler if set.
|
|
44
|
-
* @param input The normalized agent input
|
|
45
|
-
*/
|
|
46
|
-
protected handleMessage(input: AgentInput): Promise<void>;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Configuration options for SlackChannel.
|
|
51
|
-
*/
|
|
52
|
-
interface SlackChannelConfig {
|
|
53
|
-
/** Optional name for the channel - required for sendTo() routing */
|
|
54
|
-
name?: string;
|
|
55
|
-
/**
|
|
56
|
-
* Which Slack channel(s) this instance listens to and replies into.
|
|
57
|
-
*
|
|
58
|
-
* - `string` (e.g. `'#support'` or `'C12345'`) — single channel (back-compat).
|
|
59
|
-
* - `string[]` — multiple channels; inbound events outside this list are dropped.
|
|
60
|
-
* - `null` / omitted — listen to every channel the bot is invited to.
|
|
61
|
-
*
|
|
62
|
-
* **Matching:** compared verbatim against `event.channel` from the Slack payload.
|
|
63
|
-
* Slack events carry channel IDs (`C...`), so pass IDs here for deterministic
|
|
64
|
-
* filtering. If you pass a display name like `'#general'`, it must match the
|
|
65
|
-
* raw string Slack sends — usually an ID, not a name. DMs (`im`/`mpim`) are
|
|
66
|
-
* always accepted regardless of this list.
|
|
67
|
-
*
|
|
68
|
-
* **Outbound:** when sending, `metadata.channelId` (set by `normalize()`) wins.
|
|
69
|
-
* If absent, the fallback is: `string` → itself; `string[]` → first element;
|
|
70
|
-
* `null` → error (must provide `metadata.channelId`).
|
|
71
|
-
*/
|
|
72
|
-
channel?: string | string[] | null;
|
|
73
|
-
/** Slack bot token (starts with 'xoxb-') */
|
|
74
|
-
token: string;
|
|
75
|
-
/** Slack app signing secret for request verification */
|
|
76
|
-
signingSecret: string;
|
|
77
|
-
/** Optional port for the HTTP server (default: 3000) */
|
|
78
|
-
port?: number;
|
|
79
|
-
/**
|
|
80
|
-
* Allowlist of bot identities whose Slack messages should be processed when
|
|
81
|
-
* strict mode is desired.
|
|
82
|
-
*
|
|
83
|
-
* Behavior:
|
|
84
|
-
* - Omitted: non-self bot messages are accepted by default (Option B).
|
|
85
|
-
* - Provided (including empty array): only listed bots are accepted.
|
|
86
|
-
*
|
|
87
|
-
* Each entry is matched against **both** `event.bot_id` (a `B...` integration
|
|
88
|
-
* id) and `event.user` (a `U...` user id), since Slack events carry both and
|
|
89
|
-
* developers frequently know one but not the other. Pass whichever you have —
|
|
90
|
-
* typically the peer agent's `SlackChannel.botUserId` (a `U...` value).
|
|
91
|
-
*
|
|
92
|
-
* Note: for normal multi-agent teams you do **not** need to list peers here —
|
|
93
|
-
* non-self bot messages are allowed by default. Use this field only when you
|
|
94
|
-
* want strict, allowlist-only acceptance. To suppress specific noisy bots
|
|
95
|
-
* (e.g. GitHub, CI) while keeping the default-allow behavior, prefer
|
|
96
|
-
* {@link SlackChannelConfig.blockedBotIds}.
|
|
97
|
-
*
|
|
98
|
-
* Example (strict mode): `allowedBotIds: [ramDevAgent.slackChannel.botUserId, 'B_YALINA_BOT']`
|
|
99
|
-
*/
|
|
100
|
-
allowedBotIds?: string[];
|
|
101
|
-
/**
|
|
102
|
-
* Blocklist of bot identities that should always be ignored.
|
|
103
|
-
*
|
|
104
|
-
* Matched against both `event.bot_id` (B...) and `event.user` (U...).
|
|
105
|
-
* Takes precedence over `allowedBotIds` and the default allow behavior.
|
|
106
|
-
*/
|
|
107
|
-
blockedBotIds?: string[];
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Slack channel for two-way Slack integration.
|
|
111
|
-
* Receives messages from users and replies in-thread.
|
|
112
|
-
*/
|
|
113
|
-
declare class SlackChannel extends BaseChannel {
|
|
114
|
-
readonly isTriggerChannel = false;
|
|
115
|
-
private config;
|
|
116
|
-
private server?;
|
|
117
|
-
/**
|
|
118
|
-
* Per-process cache of resolved participants keyed by Slack user id.
|
|
119
|
-
* Populated lazily by `resolveParticipant()`. Invalidated on `user_change`
|
|
120
|
-
* events via `invalidateParticipant()`.
|
|
121
|
-
*/
|
|
122
|
-
private participantCache;
|
|
123
|
-
/**
|
|
124
|
-
* The bot's Slack user id (e.g. `'U_BOT123'`), populated by the startup
|
|
125
|
-
* self-check (`auth.test`) when `listen()` is called.
|
|
126
|
-
*
|
|
127
|
-
* Pass this to `AssemblerOptions.agentAliases` so the assembler's
|
|
128
|
-
* addressed-only mode can match `<@U_BOT123>` mentions against this agent:
|
|
129
|
-
* ```ts
|
|
130
|
-
* assemblePrompt(store, conversationId, agent.name, agent.name, {
|
|
131
|
-
* agentAliases: [slackChannel.botUserId].filter(Boolean) as string[],
|
|
132
|
-
* });
|
|
133
|
-
* ```
|
|
134
|
-
*/
|
|
135
|
-
botUserId?: string;
|
|
136
|
-
/**
|
|
137
|
-
* Normalized allowlist of channel identifiers, or `null` to accept any channel.
|
|
138
|
-
* Derived from `config.channel` at construction time.
|
|
139
|
-
*/
|
|
140
|
-
private allowedChannels;
|
|
141
|
-
constructor(config: SlackChannelConfig);
|
|
142
|
-
/**
|
|
143
|
-
* Start listening for Slack events via HTTP webhook.
|
|
144
|
-
*
|
|
145
|
-
* Performs a startup self-check (`auth.test`) after the server is ready.
|
|
146
|
-
* The bot user id is stored on `this.botUserId` for use in `agentAliases`.
|
|
147
|
-
*/
|
|
148
|
-
listen(): void;
|
|
149
|
-
/**
|
|
150
|
-
* Calls Slack's `auth.test` API to verify credentials and log the bot's
|
|
151
|
-
* identity. Stores `botUserId` for use in `AssemblerOptions.agentAliases`.
|
|
152
|
-
* Non-fatal — a failed check logs a warning but does not stop the server.
|
|
153
|
-
*/
|
|
154
|
-
private runStartupCheck;
|
|
155
|
-
/**
|
|
156
|
-
* Verify a Slack request signature using HMAC-SHA256.
|
|
157
|
-
*
|
|
158
|
-
* Implements Slack's signing secret verification spec:
|
|
159
|
-
* https://api.slack.com/authentication/verifying-requests-from-slack
|
|
160
|
-
*
|
|
161
|
-
* - Rejects requests with a timestamp older than 5 minutes (replay protection).
|
|
162
|
-
* - Uses `timingSafeEqual` to prevent timing-oracle attacks.
|
|
163
|
-
*
|
|
164
|
-
* Returns `false` for any missing, malformed, or invalid input so that the
|
|
165
|
-
* caller can respond with 401 without leaking which check failed.
|
|
166
|
-
*/
|
|
167
|
-
verifySignature(headers: Record<string, string | string[] | undefined>, rawBody: string): boolean;
|
|
168
|
-
/**
|
|
169
|
-
* Send a message back to Slack.
|
|
170
|
-
* @param output The agent output to send
|
|
171
|
-
*/
|
|
172
|
-
send(output: AgentOutput): Promise<void>;
|
|
173
|
-
/**
|
|
174
|
-
* Normalize a Slack event into AgentInput.
|
|
175
|
-
* @param incoming Slack event payload
|
|
176
|
-
* @returns Normalized AgentInput
|
|
177
|
-
*/
|
|
178
|
-
normalize(incoming: unknown): AgentInput;
|
|
179
|
-
/**
|
|
180
|
-
* Resolve a richer `Participant` (with `displayName`) for a normalized input.
|
|
181
|
-
*
|
|
182
|
-
* Uses Slack's `users.info` API and an in-process cache. Returns `undefined`
|
|
183
|
-
* if the input has no user id or if the lookup fails; callers fall back to
|
|
184
|
-
* the bare id. Never throws.
|
|
185
|
-
*
|
|
186
|
-
* Cache invalidation is handled externally via `invalidateParticipant()`,
|
|
187
|
-
* typically wired to the Slack `user_change` event.
|
|
188
|
-
*/
|
|
189
|
-
resolveParticipant(input: AgentInput): Promise<Participant | undefined>;
|
|
190
|
-
/**
|
|
191
|
-
* Invalidate a cached participant. Call this from a `user_change`
|
|
192
|
-
* Slack event handler to force a refresh on the next lookup.
|
|
193
|
-
*/
|
|
194
|
-
invalidateParticipant(userId: string): void;
|
|
195
|
-
/**
|
|
196
|
-
* Decide whether an incoming Slack event should be normalised and dispatched
|
|
197
|
-
* to the agent.
|
|
198
|
-
*
|
|
199
|
-
* Rules, applied in order:
|
|
200
|
-
* 1. Only `message` and `app_mention` events are processed; others are dropped.
|
|
201
|
-
* 2. Channel allowlist (from `config.channel`): events outside the allowlist
|
|
202
|
-
* are dropped. DMs (`im`/`mpim`) always pass because they are per-user, not
|
|
203
|
-
* per-channel. Skipped entirely when `config.channel` is null/omitted.
|
|
204
|
-
* 3. **Self-suppression (automatic):** events where `event.user` matches this
|
|
205
|
-
* channel's own `botUserId` are dropped. This prevents agents from looping
|
|
206
|
-
* on their own posts and requires no configuration — `botUserId` is
|
|
207
|
-
* discovered via `auth.test` at startup.
|
|
208
|
-
* 4. Events without `bot_id` (human messages) pass.
|
|
209
|
-
* 5. Explicit blocklist check (`blockedBotIds`) runs first for bot messages.
|
|
210
|
-
* 6. If `allowedBotIds` is provided, strict mode applies: only listed bots
|
|
211
|
-
* pass (matched against both `bot_id` and `user`).
|
|
212
|
-
* 7. If `allowedBotIds` is omitted, other bot messages pass by default.
|
|
213
|
-
*
|
|
214
|
-
* Exposed for direct unit testing; not intended as a public API.
|
|
215
|
-
*/
|
|
216
|
-
shouldProcessEvent(event: Record<string, unknown>): boolean;
|
|
217
|
-
/**
|
|
218
|
-
* Handle incoming HTTP requests from Slack.
|
|
219
|
-
*/
|
|
220
|
-
private handleRequest;
|
|
221
|
-
/**
|
|
222
|
-
* Stop the HTTP server.
|
|
223
|
-
*/
|
|
224
|
-
stop(): Promise<void>;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Configuration options for WebhookChannel.
|
|
229
|
-
*/
|
|
230
|
-
interface WebhookChannelConfig {
|
|
231
|
-
/** Optional name for the channel - required for sendTo() routing */
|
|
232
|
-
name?: string;
|
|
233
|
-
/** HTTP path to listen on (e.g., '/agent/support') */
|
|
234
|
-
path: string;
|
|
235
|
-
/** Optional port for the HTTP server (default: 3000) */
|
|
236
|
-
port?: number;
|
|
237
|
-
}
|
|
238
|
-
/**
|
|
239
|
-
* Webhook channel that exposes an HTTP endpoint.
|
|
240
|
-
* Receives HTTP requests and responds with agent output.
|
|
241
|
-
*/
|
|
242
|
-
declare class WebhookChannel extends BaseChannel {
|
|
243
|
-
readonly isTriggerChannel = false;
|
|
244
|
-
private config;
|
|
245
|
-
private server?;
|
|
246
|
-
private pendingResponses;
|
|
247
|
-
constructor(config: WebhookChannelConfig);
|
|
248
|
-
/**
|
|
249
|
-
* Start listening for HTTP requests.
|
|
250
|
-
*/
|
|
251
|
-
listen(): void;
|
|
252
|
-
/**
|
|
253
|
-
* Send the agent output as an HTTP response.
|
|
254
|
-
* @param output The agent output to send
|
|
255
|
-
*/
|
|
256
|
-
send(output: AgentOutput): Promise<void>;
|
|
257
|
-
/**
|
|
258
|
-
* Normalize an HTTP request into AgentInput.
|
|
259
|
-
* @param incoming HTTP request body with headers
|
|
260
|
-
* @returns Normalized AgentInput
|
|
261
|
-
*/
|
|
262
|
-
normalize(incoming: unknown): AgentInput;
|
|
263
|
-
/**
|
|
264
|
-
* Handle incoming HTTP requests.
|
|
265
|
-
*/
|
|
266
|
-
private handleRequest;
|
|
267
|
-
/**
|
|
268
|
-
* Generate a unique session ID.
|
|
269
|
-
*/
|
|
270
|
-
private generateSessionId;
|
|
271
|
-
/**
|
|
272
|
-
* Stop the HTTP server.
|
|
273
|
-
*/
|
|
274
|
-
stop(): Promise<void>;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* Configuration options for ScheduledChannel.
|
|
279
|
-
*/
|
|
280
|
-
interface ScheduledChannelConfig {
|
|
281
|
-
/** Optional name for the channel - required for sendTo() routing */
|
|
282
|
-
name?: string;
|
|
283
|
-
/**
|
|
284
|
-
* Cron expression - supports full cron syntax including wildcards, ranges, steps, and lists.
|
|
285
|
-
* Supports both 5-field (min hour dom month dow) and 6-field (sec min hour dom month dow) expressions.
|
|
286
|
-
* Examples: '0 9 * * 1-5' for 9am weekdays, or '0 * /15 * * * *' for every 15 minutes (6-field)
|
|
287
|
-
*/
|
|
288
|
-
cron: string;
|
|
289
|
-
/** Optional intent to pre-set in AgentInput */
|
|
290
|
-
intent?: string;
|
|
291
|
-
/** Optional message to send to the agent on each trigger */
|
|
292
|
-
message?: string;
|
|
293
|
-
/**
|
|
294
|
-
* Where to deliver the output. Supported protocols:
|
|
295
|
-
*
|
|
296
|
-
* - `webhook:<https-url>` — POSTs JSON `{ output, metadata, timestamp }` to the URL.
|
|
297
|
-
*
|
|
298
|
-
* For Slack delivery, attach a named `SlackChannel` to the same agent and
|
|
299
|
-
* route from inside `run()`:
|
|
300
|
-
*
|
|
301
|
-
* ```ts
|
|
302
|
-
* agent.channels = [
|
|
303
|
-
* new ScheduledChannel({ name: 'daily', cron: '0 9 * * 1-5', notify: 'webhook:...' }),
|
|
304
|
-
* new SlackChannel({ name: 'kore-slack', channel: '#project-kore', token, signingSecret }),
|
|
305
|
-
* ];
|
|
306
|
-
*
|
|
307
|
-
* async run(input) {
|
|
308
|
-
* const report = await this.buildReport();
|
|
309
|
-
* await this.sendTo('kore-slack', report);
|
|
310
|
-
* return { output: report };
|
|
311
|
-
* }
|
|
312
|
-
* ```
|
|
313
|
-
*
|
|
314
|
-
* This keeps Slack credentials, thread routing, and multi-channel listening
|
|
315
|
-
* in one place (`SlackChannel`) instead of duplicated inside `ScheduledChannel`.
|
|
316
|
-
*/
|
|
317
|
-
notify: string;
|
|
318
|
-
}
|
|
319
|
-
/**
|
|
320
|
-
* Scheduled channel that runs agents on a cron schedule.
|
|
321
|
-
* Delivers output to the configured notification destination.
|
|
322
|
-
*/
|
|
323
|
-
declare class ScheduledChannel extends BaseChannel {
|
|
324
|
-
readonly isTriggerChannel = true;
|
|
325
|
-
private config;
|
|
326
|
-
private timer?;
|
|
327
|
-
constructor(config: ScheduledChannelConfig);
|
|
328
|
-
/**
|
|
329
|
-
* Start the cron scheduler.
|
|
330
|
-
*/
|
|
331
|
-
listen(): void;
|
|
332
|
-
/**
|
|
333
|
-
* Send the agent output to the configured notify destination.
|
|
334
|
-
* @param output The agent output to send
|
|
335
|
-
*/
|
|
336
|
-
send(output: AgentOutput): Promise<void>;
|
|
337
|
-
/**
|
|
338
|
-
* Normalize the scheduled trigger into AgentInput.
|
|
339
|
-
* Sets the intent and generates a date-keyed conversationId.
|
|
340
|
-
* @param _incoming Ignored for scheduled triggers
|
|
341
|
-
* @returns Normalized AgentInput
|
|
342
|
-
*/
|
|
343
|
-
normalize(_incoming: unknown): AgentInput;
|
|
344
|
-
/**
|
|
345
|
-
* Send output to a webhook URL.
|
|
346
|
-
*/
|
|
347
|
-
private sendToWebhook;
|
|
348
|
-
/**
|
|
349
|
-
* Calculate next run time using cron-parser.
|
|
350
|
-
*/
|
|
351
|
-
private getNextRunTime;
|
|
352
|
-
/**
|
|
353
|
-
* Schedule the next run.
|
|
354
|
-
*/
|
|
355
|
-
private scheduleNextRun;
|
|
356
|
-
/**
|
|
357
|
-
* Trigger the scheduled task.
|
|
358
|
-
*/
|
|
359
|
-
private trigger;
|
|
360
|
-
/**
|
|
361
|
-
* Stop the scheduler.
|
|
362
|
-
*/
|
|
363
|
-
stop(): Promise<void>;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
/**
|
|
367
|
-
* Configuration options for TelegramChannel.
|
|
368
|
-
*/
|
|
369
|
-
interface TelegramChannelConfig {
|
|
370
|
-
/** Optional name for the channel - required for sendTo() routing */
|
|
371
|
-
name?: string;
|
|
372
|
-
/** Telegram bot token (from @BotFather) */
|
|
373
|
-
token: string;
|
|
374
|
-
/** Optional webhook URL for receiving updates (if not using polling) */
|
|
375
|
-
webhookUrl?: string;
|
|
376
|
-
}
|
|
377
|
-
/**
|
|
378
|
-
* Telegram channel for two-way Telegram bot integration.
|
|
379
|
-
* Receives messages from users and sends replies.
|
|
380
|
-
*/
|
|
381
|
-
declare class TelegramChannel extends BaseChannel {
|
|
382
|
-
readonly isTriggerChannel = false;
|
|
383
|
-
private config;
|
|
384
|
-
private offset;
|
|
385
|
-
private pollingInterval?;
|
|
386
|
-
private server?;
|
|
387
|
-
/**
|
|
388
|
-
* The bot's Telegram user id (numeric, as a string), populated by the
|
|
389
|
-
* startup self-check (`getMe`) when `listen()` is called.
|
|
390
|
-
*
|
|
391
|
-
* Pass this to `AssemblerOptions.agentAliases` so the assembler's
|
|
392
|
-
* addressed-only mode can match `text_mention` entities whose user id
|
|
393
|
-
* equals this value.
|
|
394
|
-
*/
|
|
395
|
-
botUserId?: string;
|
|
396
|
-
/** The bot's @username (without the @), populated by the `getMe` check. */
|
|
397
|
-
botUsername?: string;
|
|
398
|
-
constructor(config: TelegramChannelConfig);
|
|
399
|
-
/**
|
|
400
|
-
* Start listening for Telegram updates.
|
|
401
|
-
* Uses either webhook or polling mode depending on configuration.
|
|
402
|
-
*/
|
|
403
|
-
listen(): void;
|
|
404
|
-
/**
|
|
405
|
-
* Calls Telegram's `getMe` API to verify the token and log the bot's
|
|
406
|
-
* identity. Stores `botUserId` and `botUsername` for use in
|
|
407
|
-
* `AssemblerOptions.agentAliases`. Non-fatal — a failed check logs a
|
|
408
|
-
* warning but does not stop the channel.
|
|
409
|
-
*/
|
|
410
|
-
private runStartupCheck;
|
|
411
|
-
/**
|
|
412
|
-
* Send a message back to Telegram.
|
|
413
|
-
* @param output The agent output to send
|
|
414
|
-
*/
|
|
415
|
-
send(output: AgentOutput): Promise<void>;
|
|
416
|
-
/**
|
|
417
|
-
* Normalize a Telegram update into AgentInput.
|
|
418
|
-
* @param incoming Telegram update object
|
|
419
|
-
* @returns Normalized AgentInput
|
|
420
|
-
*/
|
|
421
|
-
normalize(incoming: unknown): AgentInput;
|
|
422
|
-
/**
|
|
423
|
-
* Start polling for updates.
|
|
424
|
-
*/
|
|
425
|
-
private startPolling;
|
|
426
|
-
/**
|
|
427
|
-
* Poll for updates from Telegram.
|
|
428
|
-
*/
|
|
429
|
-
private pollUpdates;
|
|
430
|
-
/**
|
|
431
|
-
* Start webhook server for receiving updates.
|
|
432
|
-
*/
|
|
433
|
-
private startWebhook;
|
|
434
|
-
/**
|
|
435
|
-
* Set webhook URL with Telegram.
|
|
436
|
-
*/
|
|
437
|
-
private setWebhook;
|
|
438
|
-
/**
|
|
439
|
-
* Handle incoming webhook requests from Telegram.
|
|
440
|
-
*/
|
|
441
|
-
private handleWebhookRequest;
|
|
442
|
-
/**
|
|
443
|
-
* Stop the channel (polling or webhook).
|
|
444
|
-
*/
|
|
445
|
-
stop(): Promise<void>;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
/**
|
|
449
|
-
* Configuration options for DiscordChannel.
|
|
450
|
-
*/
|
|
451
|
-
interface DiscordChannelConfig {
|
|
452
|
-
/** Optional name for the channel - required for sendTo() routing */
|
|
453
|
-
name?: string;
|
|
454
|
-
/** Discord bot token */
|
|
455
|
-
token: string;
|
|
456
|
-
/** Target guild (server) ID */
|
|
457
|
-
guildId: string;
|
|
458
|
-
/** Target channel ID */
|
|
459
|
-
channelId: string;
|
|
460
|
-
}
|
|
461
|
-
/**
|
|
462
|
-
* Discord channel for two-way Discord bot integration.
|
|
463
|
-
* Receives messages from guild channels or DMs and replies in-thread.
|
|
464
|
-
*/
|
|
465
|
-
declare class DiscordChannel extends BaseChannel {
|
|
466
|
-
readonly isTriggerChannel = false;
|
|
467
|
-
private config;
|
|
468
|
-
private client?;
|
|
469
|
-
constructor(config: DiscordChannelConfig);
|
|
470
|
-
/**
|
|
471
|
-
* Start listening for Discord messages.
|
|
472
|
-
*/
|
|
473
|
-
listen(): void;
|
|
474
|
-
/**
|
|
475
|
-
* Send a message to Discord.
|
|
476
|
-
* @param output The agent output to send
|
|
477
|
-
*/
|
|
478
|
-
send(output: AgentOutput): Promise<void>;
|
|
479
|
-
/**
|
|
480
|
-
* Normalize a Discord message into AgentInput.
|
|
481
|
-
* @param incoming Discord message object
|
|
482
|
-
* @returns Normalized AgentInput
|
|
483
|
-
*/
|
|
484
|
-
normalize(incoming: unknown): AgentInput;
|
|
485
|
-
/**
|
|
486
|
-
* Handle incoming Discord messages.
|
|
487
|
-
*/
|
|
488
|
-
private handleDiscordMessage;
|
|
489
|
-
/**
|
|
490
|
-
* Stop the Discord client.
|
|
491
|
-
*/
|
|
492
|
-
stop(): Promise<void>;
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
/**
|
|
496
|
-
* Configuration options for EmailChannel.
|
|
497
|
-
*/
|
|
498
|
-
interface EmailChannelConfig {
|
|
499
|
-
/** Optional name for the channel - required for sendTo() routing */
|
|
500
|
-
name?: string;
|
|
501
|
-
/** Sender email address */
|
|
502
|
-
from: string;
|
|
503
|
-
/** Recipient email address(es) - for scheduled/outbound emails */
|
|
504
|
-
to: string | string[];
|
|
505
|
-
/** SMTP configuration */
|
|
506
|
-
smtp: {
|
|
507
|
-
host: string;
|
|
508
|
-
port: number;
|
|
509
|
-
auth: {
|
|
510
|
-
user: string;
|
|
511
|
-
pass: string;
|
|
512
|
-
};
|
|
513
|
-
secure?: boolean;
|
|
514
|
-
};
|
|
515
|
-
/** Optional subject line template */
|
|
516
|
-
subject?: string;
|
|
517
|
-
}
|
|
518
|
-
/**
|
|
519
|
-
* Email channel for sending outbound emails via SMTP.
|
|
520
|
-
* This is an outbound-only channel - for inbound email handling,
|
|
521
|
-
* use a custom email-reader tool + WebhookChannel.
|
|
522
|
-
*/
|
|
523
|
-
declare class EmailChannel extends BaseChannel {
|
|
524
|
-
readonly isTriggerChannel = true;
|
|
525
|
-
private config;
|
|
526
|
-
private transporter?;
|
|
527
|
-
constructor(config: EmailChannelConfig);
|
|
528
|
-
/**
|
|
529
|
-
* Initialize the email transporter.
|
|
530
|
-
* EmailChannel is outbound-only, so listen() just sets up the transporter.
|
|
531
|
-
*/
|
|
532
|
-
listen(): void;
|
|
533
|
-
/**
|
|
534
|
-
* Send an email with the agent's output.
|
|
535
|
-
* @param output The agent output to send
|
|
536
|
-
*/
|
|
537
|
-
send(output: AgentOutput): Promise<void>;
|
|
538
|
-
/**
|
|
539
|
-
* EmailChannel is outbound-only and doesn't receive messages.
|
|
540
|
-
* This method should not be called.
|
|
541
|
-
*/
|
|
542
|
-
normalize(_incoming: unknown): never;
|
|
543
|
-
/**
|
|
544
|
-
* Format plain text as HTML for better email rendering.
|
|
545
|
-
*/
|
|
546
|
-
private formatAsHtml;
|
|
547
|
-
/**
|
|
548
|
-
* Close the email transporter.
|
|
549
|
-
*/
|
|
550
|
-
stop(): Promise<void>;
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
/**
|
|
554
|
-
* Configuration options for SMSChannel (Twilio).
|
|
555
|
-
*/
|
|
556
|
-
interface SMSChannelConfig {
|
|
557
|
-
/** Optional name for the channel - required for sendTo() routing */
|
|
558
|
-
name?: string;
|
|
559
|
-
/** Twilio Account SID */
|
|
560
|
-
accountSid: string;
|
|
561
|
-
/** Twilio Auth Token */
|
|
562
|
-
authToken: string;
|
|
563
|
-
/** Twilio phone number (sender) */
|
|
564
|
-
from: string;
|
|
565
|
-
/** Recipient phone number - for outbound/scheduled SMS */
|
|
566
|
-
to?: string;
|
|
567
|
-
/** Optional webhook path for inbound SMS (e.g., '/sms/webhook') */
|
|
568
|
-
webhookPath?: string;
|
|
569
|
-
/** Optional port for the HTTP server (default: 3000) */
|
|
570
|
-
port?: number;
|
|
571
|
-
}
|
|
572
|
-
/**
|
|
573
|
-
* SMS channel for Twilio integration.
|
|
574
|
-
* Can be configured as:
|
|
575
|
-
* - Two-way: Set webhookPath to receive inbound SMS and reply
|
|
576
|
-
* - Outbound-only: Set 'to' without webhookPath for scheduled/triggered SMS
|
|
577
|
-
*/
|
|
578
|
-
declare class SMSChannel extends BaseChannel {
|
|
579
|
-
private config;
|
|
580
|
-
private twilioClient?;
|
|
581
|
-
private server?;
|
|
582
|
-
constructor(config: SMSChannelConfig);
|
|
583
|
-
/**
|
|
584
|
-
* Two-way when webhookPath is set, outbound-only otherwise.
|
|
585
|
-
*/
|
|
586
|
-
get isTriggerChannel(): boolean;
|
|
587
|
-
/**
|
|
588
|
-
* Start listening for inbound SMS via Twilio webhook (if webhookPath is set).
|
|
589
|
-
*/
|
|
590
|
-
listen(): void;
|
|
591
|
-
/**
|
|
592
|
-
* Send an SMS message.
|
|
593
|
-
* @param output The agent output to send
|
|
594
|
-
*/
|
|
595
|
-
send(output: AgentOutput): Promise<void>;
|
|
596
|
-
/**
|
|
597
|
-
* Normalize a Twilio webhook payload into AgentInput.
|
|
598
|
-
* @param incoming Twilio webhook payload
|
|
599
|
-
* @returns Normalized AgentInput
|
|
600
|
-
*/
|
|
601
|
-
normalize(incoming: unknown): AgentInput;
|
|
602
|
-
/**
|
|
603
|
-
* Start HTTP server to receive Twilio webhooks.
|
|
604
|
-
*/
|
|
605
|
-
private startWebhookServer;
|
|
606
|
-
/**
|
|
607
|
-
* Handle incoming webhook requests from Twilio.
|
|
608
|
-
*/
|
|
609
|
-
private handleWebhookRequest;
|
|
610
|
-
/**
|
|
611
|
-
* Stop the webhook server.
|
|
612
|
-
*/
|
|
613
|
-
stop(): Promise<void>;
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
export { BaseChannel, DiscordChannel, type DiscordChannelConfig, EmailChannel, type EmailChannelConfig, SMSChannel, type SMSChannelConfig, ScheduledChannel, type ScheduledChannelConfig, SlackChannel, type SlackChannelConfig, TelegramChannel, type TelegramChannelConfig, WebhookChannel, type WebhookChannelConfig };
|