@theokit/gateway 0.4.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.
@@ -0,0 +1,528 @@
1
+ /**
2
+ * `MessageEvent` — canonical inbound shape every adapter emits (T1.1, ADR D173).
3
+ *
4
+ * Discriminated union keyed by `platform`. Platform-specific extensions live
5
+ * in optional sibling fields (`telegram?`, `discord?`) typed by the adapter
6
+ * package. The default narrow pattern is:
7
+ *
8
+ * ```typescript
9
+ * switch (event.platform) {
10
+ * case "telegram": return event.telegram.threadId; // narrowed
11
+ * case "discord": return event.discord.guildId; // narrowed
12
+ * }
13
+ * ```
14
+ *
15
+ * @public
16
+ */
17
+ /** Closed enum of supported transport platforms. */
18
+ type PlatformName = "telegram" | "discord" | "slack" | "whatsapp" | "teams" | "email" | "sms" | "mattermost" | "line" | "matrix";
19
+ /** Fields common to every platform's inbound event. */
20
+ interface BaseMessageEvent {
21
+ /** Stable id used as a session-key segment and for dedup. */
22
+ readonly id: string;
23
+ /** Discriminator. */
24
+ readonly platform: PlatformName;
25
+ /** Sender identity (opaque, platform-namespaced). */
26
+ readonly sender: {
27
+ readonly id: string;
28
+ readonly username?: string;
29
+ readonly displayName?: string;
30
+ };
31
+ /** Channel / chat scope (opaque, platform-namespaced). */
32
+ readonly channel: {
33
+ readonly id: string;
34
+ readonly type: "dm" | "group" | "thread";
35
+ readonly topicId?: string;
36
+ };
37
+ /** Plain-text content (caption for media-only messages; empty string when absent). */
38
+ readonly text: string;
39
+ /** Receipt timestamp (ms since epoch). */
40
+ readonly receivedAt: number;
41
+ /** Optional reply-target message id. */
42
+ readonly replyTo?: string;
43
+ }
44
+ /** Telegram-specific event variant. */
45
+ interface TelegramMessageEvent extends BaseMessageEvent {
46
+ readonly platform: "telegram";
47
+ readonly telegram: {
48
+ readonly chatId: number;
49
+ readonly messageId: number;
50
+ readonly threadId?: number;
51
+ /** Raw grammy `Context` — narrowed by the adapter package. */
52
+ readonly raw: unknown;
53
+ };
54
+ }
55
+ /** Discord-specific event variant. */
56
+ interface DiscordMessageEvent extends BaseMessageEvent {
57
+ readonly platform: "discord";
58
+ readonly discord: {
59
+ readonly guildId: string | null;
60
+ readonly channelId: string;
61
+ readonly messageId: string;
62
+ /** Raw discord.js `Message` — narrowed by the adapter package. */
63
+ readonly raw: unknown;
64
+ };
65
+ }
66
+ /** Slack-specific event variant (ADR D274). */
67
+ interface SlackMessageEvent extends BaseMessageEvent {
68
+ readonly platform: "slack";
69
+ readonly slack: {
70
+ /** Slack workspace id (a.k.a. team_id). May be `undefined` for some legacy events. */
71
+ readonly teamId: string | undefined;
72
+ /** Slack channel id (Cxxxxxxxx | Gxxxxxxxx | Dxxxxxxxx). */
73
+ readonly channelId: string;
74
+ /** Slack user id (Uxxxxxxxx) or `"anonymous"` if absent. */
75
+ readonly userId: string;
76
+ /** Message timestamp = canonical Slack message id. */
77
+ readonly ts: string;
78
+ /** Set only when the message belongs to a thread. */
79
+ readonly threadTs?: string;
80
+ /** Slack message subtype (e.g. `"thread_broadcast"`). */
81
+ readonly subtype?: string;
82
+ /** Raw Bolt event body — narrowed by the adapter package. */
83
+ readonly raw: unknown;
84
+ };
85
+ }
86
+ /** WhatsApp-specific event variant (ADR D308). */
87
+ interface WhatsAppMessageEvent extends BaseMessageEvent {
88
+ readonly platform: "whatsapp";
89
+ readonly whatsapp: {
90
+ /** WhatsApp message id — `wamid.xxx` for cloud, `msg.id._serialized` for web. */
91
+ readonly wamid: string;
92
+ /** Meta-issued phone-number-id (cloud only; undefined for web bridge). */
93
+ readonly phoneNumberId?: string;
94
+ /** Contact's profile name when Meta provides it. */
95
+ readonly contactName?: string;
96
+ /** Which backend produced this event. */
97
+ readonly backend: "cloud" | "web";
98
+ /** Raw envelope — backend-specific, narrowed by the adapter package. */
99
+ readonly raw: unknown;
100
+ };
101
+ }
102
+ /** Microsoft Teams-specific event variant (ADR D325). */
103
+ interface TeamsMessageEvent extends BaseMessageEvent {
104
+ readonly platform: "teams";
105
+ readonly teams: {
106
+ /** Teams activity id (`MessageActivity.id`). */
107
+ readonly activityId: string;
108
+ /** Teams conversation id. */
109
+ readonly conversationId: string;
110
+ /** Teams conversation classification — open string per SDK type. */
111
+ readonly conversationType: "personal" | "groupChat" | "channel" | (string & {});
112
+ /** Tenant id of the sender (Azure AD). */
113
+ readonly tenantId?: string;
114
+ /** Channel id (only when conversationType === "channel"). */
115
+ readonly channelId?: string;
116
+ /** Team id (only when conversationType === "channel"). */
117
+ readonly teamId?: string;
118
+ /** Raw Teams `MessageActivity` — narrowed by the adapter package. */
119
+ readonly raw: unknown;
120
+ };
121
+ }
122
+ /** Email-specific event variant (ADR D339). */
123
+ interface EmailMessageEvent extends BaseMessageEvent {
124
+ readonly platform: "email";
125
+ readonly email: {
126
+ /** Message-ID without `<>` braces. Use as `channel.topicId` for threading. */
127
+ readonly messageId: string;
128
+ /** Previous Message-ID this message replies to (without `<>`). */
129
+ readonly inReplyTo?: string;
130
+ /** Full References chain (oldest → newest, no braces). */
131
+ readonly references?: readonly string[];
132
+ /** Decoded Subject (fallback `"(no subject)"`). */
133
+ readonly subject: string;
134
+ /** Sender address (lowercased, normalized). */
135
+ readonly fromAddress: string;
136
+ /** Sender display name when present. */
137
+ readonly fromName?: string;
138
+ /** All To/Cc recipients lowercased; bot's own address EXCLUDED. */
139
+ readonly recipients: readonly string[];
140
+ /** Count of attachments (v0.1 drops payloads — see D335). */
141
+ readonly attachmentCount: number;
142
+ /** Raw `mailparser.ParsedMail` — escape hatch. */
143
+ readonly raw: unknown;
144
+ };
145
+ }
146
+ /** SMS-specific event variant (ADR D389). */
147
+ interface SMSMessageEvent extends BaseMessageEvent {
148
+ readonly platform: "sms";
149
+ readonly sms: {
150
+ /** Which backend processed this inbound. */
151
+ readonly backend: "twilio" | "plivo" | "vonage";
152
+ /** Provider message id (Twilio MessageSid, Plivo MessageUuid, Vonage messageId). */
153
+ readonly messageId: string;
154
+ /** Sender phone in E.164 format (D391). */
155
+ readonly from: string;
156
+ /** Recipient phone in E.164 format (D391). */
157
+ readonly to: string;
158
+ /** Raw webhook payload — backend-specific, narrowed by the adapter package. */
159
+ readonly raw: unknown;
160
+ };
161
+ }
162
+ /** Mattermost-specific event variant (ADR D397). */
163
+ interface MattermostMessageEvent extends BaseMessageEvent {
164
+ readonly platform: "mattermost";
165
+ readonly mattermost: {
166
+ /** Mattermost post id. */
167
+ readonly postId: string;
168
+ /** Channel id (Mattermost internal id). */
169
+ readonly channelId: string;
170
+ /** Team id the channel belongs to. */
171
+ readonly teamId: string;
172
+ /** When set, the message is a thread reply rooted at this post id (D399). */
173
+ readonly rootId?: string;
174
+ /** Original Mattermost channel type (`D`/`G`/`O`/`P`) before normalization (D402). */
175
+ readonly channelType: "D" | "G" | "O" | "P" | (string & {});
176
+ /** Raw `@mattermost/client` Post — escape hatch. */
177
+ readonly raw: unknown;
178
+ };
179
+ }
180
+ /** LINE-specific event variant (ADR D405). */
181
+ interface LineMessageEvent extends BaseMessageEvent {
182
+ readonly platform: "line";
183
+ readonly line: {
184
+ /** LINE source classification (D410). */
185
+ readonly sourceType: "user" | "group" | "room";
186
+ /** LINE source id (userId / groupId / roomId). */
187
+ readonly sourceId: string;
188
+ /** LINE message id. */
189
+ readonly messageId: string;
190
+ /** UserIds mentioned in the message (D409 — never inline). */
191
+ readonly mentionees: ReadonlyArray<string>;
192
+ /** Reply token (one-shot, 60s TTL). Adapter manages cache — caller should not use directly. */
193
+ readonly replyToken?: string;
194
+ /** Raw LINE webhook event — escape hatch. */
195
+ readonly raw: unknown;
196
+ };
197
+ }
198
+ /** Matrix-specific event variant (ADR D413). */
199
+ interface MatrixMessageEvent extends BaseMessageEvent {
200
+ readonly platform: "matrix";
201
+ readonly matrix: {
202
+ /** Matrix room id (`!xxx:server`). */
203
+ readonly roomId: string;
204
+ /** Matrix event id (`$xxx:server`). */
205
+ readonly eventId: string;
206
+ /** Number of joined members in the room — used for DM detection (D416). */
207
+ readonly memberCount: number;
208
+ /** Raw `matrix-js-sdk` `MatrixEvent` — escape hatch (D421). */
209
+ readonly raw: unknown;
210
+ };
211
+ }
212
+ /** Discriminated union of all platform variants. */
213
+ type MessageEvent = TelegramMessageEvent | DiscordMessageEvent | SlackMessageEvent | WhatsAppMessageEvent | TeamsMessageEvent | EmailMessageEvent | SMSMessageEvent | MattermostMessageEvent | LineMessageEvent | MatrixMessageEvent;
214
+
215
+ /**
216
+ * `BasePlatformAdapter` — contract every transport adapter implements
217
+ * (T1.2, ADR D172).
218
+ *
219
+ * Adapters share ~30% of lifecycle code (typing indicators, event
220
+ * normalization patterns). An abstract class with concrete defaults
221
+ * + abstract hooks is the right shape — interface-only would force
222
+ * every adapter to copy the defaults.
223
+ *
224
+ * Consumers use it via `instanceof` and the public subclass exports
225
+ * (`TelegramAdapter`, `DiscordAdapter`, ...).
226
+ */
227
+
228
+ /** Outbound message shape — what `sendMessage` accepts. */
229
+ interface OutboundMessage {
230
+ readonly channel: {
231
+ readonly id: string;
232
+ readonly type: "dm" | "group" | "thread";
233
+ readonly topicId?: string;
234
+ };
235
+ readonly text: string;
236
+ /** Markdown / HTML rendering hint. Default "plain". */
237
+ readonly format?: "plain" | "markdown" | "html";
238
+ /** Optional reply target. */
239
+ readonly replyTo?: string;
240
+ }
241
+ /** Send result — adapters return this instead of throwing on platform errors. */
242
+ interface SendResult {
243
+ readonly ok: boolean;
244
+ readonly messageId?: string;
245
+ readonly error?: {
246
+ readonly code: string;
247
+ readonly message: string;
248
+ };
249
+ }
250
+ /**
251
+ * Abstract base for all platform adapters.
252
+ *
253
+ * Subclasses implement `connect`, `disconnect`, `sendMessage`, `onInbound`.
254
+ * Lifecycle defaults (`startTyping`, `stopTyping`) noop unless overridden.
255
+ *
256
+ * **Contract:**
257
+ * - `connect()` is idempotent. Calling twice returns true the second time.
258
+ * - `disconnect()` is idempotent.
259
+ * - `sendMessage` returns a `SendResult`; it MUST NOT throw on platform errors
260
+ * (rate-limit, 4xx, network). Programmer errors (missing config) MAY throw.
261
+ * - `onInbound(handler)` returns an unsubscribe function. EC-H: calling
262
+ * `onInbound` twice replaces the previous handler — does NOT stack.
263
+ * - `sendMessage` with empty text returns `{ ok: false, code: "empty_text" }`.
264
+ *
265
+ * @public
266
+ */
267
+ declare abstract class BasePlatformAdapter {
268
+ abstract readonly platform: PlatformName;
269
+ /** Open the connection. Returns `true` on success; never throws. */
270
+ abstract connect(): Promise<boolean>;
271
+ /** Close the connection. Idempotent; safe to call when never connected. */
272
+ abstract disconnect(): Promise<void>;
273
+ /** Send a message. Returns a `SendResult`; never throws on platform errors. */
274
+ abstract sendMessage(out: OutboundMessage): Promise<SendResult>;
275
+ /**
276
+ * Subscribe to inbound events. Returns an unsubscribe function.
277
+ * EC-H: second call REPLACES the previous handler (does not stack).
278
+ */
279
+ abstract onInbound(handler: (event: MessageEvent) => Promise<void>): () => void;
280
+ /** Lifecycle: emit a typing indicator. Default: noop. */
281
+ startTyping(_channelId: string): Promise<void>;
282
+ /** Lifecycle: stop the typing indicator. Default: noop. */
283
+ stopTyping(_channelId: string): Promise<void>;
284
+ }
285
+
286
+ /**
287
+ * `DeliveryRouter` — outbound dispatch by platform (T3.1, ADR D175).
288
+ *
289
+ * The router holds a map of `platform → adapter` and forwards
290
+ * `DeliveryRequest` to the right adapter's `sendMessage`. Composes
291
+ * with `Cron` from `@theokit/sdk` for scheduled delivery — the
292
+ * router is the "WHERE to send", Cron is the "WHEN to fire".
293
+ *
294
+ * @public
295
+ */
296
+
297
+ /** Target for an outbound delivery. */
298
+ interface DeliveryTarget {
299
+ readonly platform: PlatformName;
300
+ readonly channel: {
301
+ readonly id: string;
302
+ readonly type: "dm" | "group" | "thread";
303
+ readonly topicId?: string;
304
+ };
305
+ }
306
+ /** Full outbound request: target + content. */
307
+ interface DeliveryRequest extends DeliveryTarget {
308
+ readonly text: string;
309
+ readonly format?: "plain" | "markdown" | "html";
310
+ readonly replyTo?: string;
311
+ }
312
+ /**
313
+ * Routes outbound requests to the correct adapter.
314
+ *
315
+ * **Contract:**
316
+ * - `register` is last-writer-wins by platform.
317
+ * - `send` with unknown platform returns `{ ok: false, code: "no_adapter" }`.
318
+ * - `send` never throws on platform errors (delegates to adapter's SendResult).
319
+ *
320
+ * @public
321
+ */
322
+ declare class DeliveryRouter {
323
+ private readonly adapters;
324
+ register(adapter: BasePlatformAdapter): void;
325
+ send(req: DeliveryRequest): Promise<SendResult>;
326
+ }
327
+
328
+ /**
329
+ * Gateway hooks — own contract, not a `Plugin.kind` extension
330
+ * (T4.1, ADRs D176, D177).
331
+ *
332
+ * Three fire points:
333
+ * - `pre_inbound` — runs sequentially; first `{ block: true }` short-circuits.
334
+ * - `post_outbound` — fire-and-forget; errors logged.
335
+ * - `on_error` — fire-and-forget; called when the handler throws.
336
+ *
337
+ * Signature mirrors the SDK's `pre_tool_call` veto (D101) so consumers
338
+ * have a single mental model for "block or continue" hooks.
339
+ *
340
+ * @public
341
+ */
342
+
343
+ /** Closed enum of hook fire points. */
344
+ type HookName = "pre_inbound" | "post_outbound" | "on_error";
345
+ /**
346
+ * Decision returned by a `pre_inbound` hook.
347
+ *
348
+ * - `block: true` short-circuits the chain — handler does NOT run.
349
+ * - `message` set → runner calls `ctx.reply(message)` BEFORE short-circuit (EC-D).
350
+ * - `block: false` or `undefined` → continue.
351
+ */
352
+ interface HookDecision {
353
+ readonly block?: boolean;
354
+ readonly message?: string;
355
+ }
356
+ /** Context passed to `pre_inbound` hooks. */
357
+ interface PreInboundContext {
358
+ readonly event: MessageEvent;
359
+ }
360
+ /** Context passed to `post_outbound` hooks. */
361
+ interface PostOutboundContext {
362
+ readonly event: MessageEvent;
363
+ readonly outbound: OutboundMessage;
364
+ readonly result: SendResult;
365
+ }
366
+ /** Context passed to `on_error` hooks. */
367
+ interface OnErrorContext {
368
+ readonly event: MessageEvent;
369
+ readonly error: Error;
370
+ }
371
+ /** A gateway hook: any of the three fire-point methods are optional. */
372
+ interface GatewayHook {
373
+ readonly name: string;
374
+ pre_inbound?(ctx: PreInboundContext): Promise<HookDecision | void> | HookDecision | void;
375
+ post_outbound?(ctx: PostOutboundContext): Promise<void> | void;
376
+ on_error?(ctx: OnErrorContext): Promise<void> | void;
377
+ }
378
+ /**
379
+ * Runs registered hooks at the right fire points. Stateless — safe to
380
+ * construct per-event if hooks need event-scoped storage.
381
+ *
382
+ * @public
383
+ */
384
+ declare class HookExecutor {
385
+ private readonly hooks;
386
+ constructor(hooks: ReadonlyArray<GatewayHook>);
387
+ /**
388
+ * Fire `pre_inbound` hooks sequentially. First `{ block: true }` short-circuits.
389
+ * A hook throwing is treated as `{ block: true }` (logged via the runner).
390
+ */
391
+ firePreInbound(ctx: PreInboundContext): Promise<HookDecision>;
392
+ /** Fire all `post_outbound` hooks; errors logged via stderr. */
393
+ firePostOutbound(ctx: PostOutboundContext): Promise<void>;
394
+ /** Fire all `on_error` hooks; errors logged via stderr. */
395
+ fireOnError(ctx: OnErrorContext): Promise<void>;
396
+ }
397
+
398
+ /**
399
+ * `GatewayRunner` — top-level orchestrator (T1.3, ADR D170+ family).
400
+ *
401
+ * Owns the adapter map, dispatches inbound events through the hook chain,
402
+ * builds a per-event `GatewayContext` whose `reply` auto-routes to the
403
+ * adapter matching `event.platform` (EC-G).
404
+ *
405
+ * **Lifecycle:**
406
+ * - `start()` connects all adapters in parallel via `Promise.all`. Partial
407
+ * failure rolls back: connected adapters get `disconnect()`, then the
408
+ * aggregate error rethrows.
409
+ * - `stop()` drains in-flight handlers up to `drainTimeoutMs` (default 10s)
410
+ * BEFORE disconnecting (EC-E). Idempotent.
411
+ *
412
+ * **Hook chain on inbound:**
413
+ * 1. `firePreInbound({ event })`
414
+ * 2. If `block: true` + `message`: call `ctx.reply(message)` (EC-D), short-circuit.
415
+ * 3. If `block: true` only: short-circuit silently.
416
+ * 4. Otherwise: call user handler.
417
+ * 5. On handler throw: fire `on_error`, log via `Security.redact` (EC-F).
418
+ *
419
+ * @public
420
+ */
421
+
422
+ /** Per-event context passed to the user handler. */
423
+ interface GatewayContext {
424
+ /** Send a reply to the originating channel (auto-routed by `event.platform`). */
425
+ reply(text: string, opts?: {
426
+ format?: "plain" | "markdown" | "html";
427
+ }): Promise<SendResult>;
428
+ /** The triggering event. */
429
+ readonly event: MessageEvent;
430
+ }
431
+ /** User-supplied handler. */
432
+ type GatewayHandler = (event: MessageEvent, ctx: GatewayContext) => Promise<void>;
433
+ /** Runner configuration. */
434
+ interface GatewayRunnerOptions {
435
+ readonly adapters: ReadonlyArray<BasePlatformAdapter>;
436
+ readonly handler: GatewayHandler;
437
+ readonly hooks?: ReadonlyArray<GatewayHook>;
438
+ /** Drain timeout for in-flight handlers on stop(). Default 10_000ms (EC-E). */
439
+ readonly drainTimeoutMs?: number;
440
+ /**
441
+ * Prefixes that `runner.command(name, h)` matches on. Default `["/"]`
442
+ * (Telegram-style). Pass `["!"]` for Discord, `["/", "!"]` to accept
443
+ * both. Word-boundary match (EC-A) applies to every prefix.
444
+ *
445
+ * @public
446
+ */
447
+ readonly commandPrefixes?: ReadonlyArray<string>;
448
+ }
449
+ /**
450
+ * Holds the registered adapters and dispatches inbound events through
451
+ * the hook chain to the user handler. Use the sugar `runner.command(...)`
452
+ * for slash command dispatch with word-boundary matching (EC-A).
453
+ *
454
+ * @public
455
+ */
456
+ declare class GatewayRunner {
457
+ private readonly opts;
458
+ private readonly adaptersByPlatform;
459
+ private readonly hookExecutor;
460
+ private readonly inflight;
461
+ private readonly unsubs;
462
+ /** Slash command registry: name → handler (word-boundary match, EC-A). */
463
+ private readonly commands;
464
+ private connected;
465
+ private stopped;
466
+ constructor(opts: GatewayRunnerOptions);
467
+ /**
468
+ * Register a slash command. Match rule (EC-A): text === "/" + name
469
+ * OR text.startsWith("/" + name + " ") OR text.startsWith("/" + name + "@").
470
+ *
471
+ * @public
472
+ */
473
+ command(name: string, handler: GatewayHandler): void;
474
+ /** Connect all adapters and wire inbound dispatch. */
475
+ start(): Promise<void>;
476
+ /**
477
+ * Stop the runner. Drains in-flight handlers up to `drainTimeoutMs`,
478
+ * then disconnects adapters. Idempotent (EC-E).
479
+ */
480
+ stop(): Promise<void>;
481
+ /**
482
+ * EC-A: word-boundary slash command match. Prevents `/skill` from
483
+ * shadowing `/skills`. Returns the handler if a command matches,
484
+ * undefined otherwise.
485
+ */
486
+ private matchSlashCommand;
487
+ /** EC-G: per-event ctx whose reply routes to the matching adapter. */
488
+ private buildContext;
489
+ }
490
+
491
+ /**
492
+ * `SessionRouter` — pure routing logic: `MessageEvent → agentId`
493
+ * (T2.1, ADR D174).
494
+ *
495
+ * The SDK already owns session persistence (`Agent.resume` + `agent-registry`).
496
+ * The router's job is to produce a stable, deterministic key — the SDK then
497
+ * hydrates the actual session.
498
+ *
499
+ * Default strategy format: `<platform>-<channelType>-<...key parts>`.
500
+ *
501
+ * **EC-B:** thread events without a `topicId` (adapter bug or non-thread
502
+ * forum message) fall back to the group key — prevents `...-undefined`
503
+ * split-brain sessions.
504
+ *
505
+ * @public
506
+ */
507
+
508
+ /** Strategy function: pure mapping from event to agentId string. */
509
+ type AgentIdStrategy = (event: MessageEvent) => string;
510
+ /**
511
+ * Default strategy. Sanitizes `-` to `_` inside ids so the format
512
+ * remains parseable by `-` segments.
513
+ */
514
+ declare function defaultStrategy(event: MessageEvent): string;
515
+ /**
516
+ * Routes inbound events to agent ids. Defaults to `defaultStrategy`;
517
+ * callers override per-bot to preserve legacy keys (telegram-pro keeps
518
+ * the `tg-pro-` prefix; new bots use the default `telegram-` prefix).
519
+ *
520
+ * @public
521
+ */
522
+ declare class SessionRouter {
523
+ private readonly strategy;
524
+ constructor(strategy?: AgentIdStrategy);
525
+ resolveAgentId(event: MessageEvent): string;
526
+ }
527
+
528
+ export { type AgentIdStrategy, type BaseMessageEvent, BasePlatformAdapter, type DeliveryRequest, DeliveryRouter, type DeliveryTarget, type DiscordMessageEvent, type EmailMessageEvent, type GatewayContext, type GatewayHandler, type GatewayHook, GatewayRunner, type GatewayRunnerOptions, type HookDecision, HookExecutor, type HookName, type LineMessageEvent, type MatrixMessageEvent, type MattermostMessageEvent, type MessageEvent, type OnErrorContext, type OutboundMessage, type PlatformName, type PostOutboundContext, type PreInboundContext, type SMSMessageEvent, type SendResult, SessionRouter, type SlackMessageEvent, type TeamsMessageEvent, type TelegramMessageEvent, type WhatsAppMessageEvent, defaultStrategy };