@mastra/discord 1.3.1 → 1.3.2-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.cts CHANGED
@@ -3,16 +3,15 @@ import { ChannelsStorage } from "@mastra/core/storage";
3
3
  import { DiscordAdapter, DiscordAdapter as DiscordAdapter$1, DiscordAdapterConfig, DiscordAdapterConfig as DiscordAdapterConfig$1, createDiscordAdapter } from "@chat-adapter/discord";
4
4
  import { Mastra } from "@mastra/core/mastra";
5
5
  import { ApiRoute } from "@mastra/core/server";
6
- //#region src/types.d.ts
7
6
  /**
8
7
  * Default Discord REST base — **including** the `/api/v10` version segment. The
9
8
  * client concatenates this with the request path verbatim, so an override must
10
9
  * carry its own version segment (`https://example.test/api/v10`); passing a bare
11
10
  * origin produces unversioned request URLs.
12
11
  */
13
- declare const DISCORD_API_BASE_URL = "https://discord.com/api/v10";
12
+ export declare const DISCORD_API_BASE_URL = "https://discord.com/api/v10";
14
13
  /** Base for the OAuth2 authorize (bot-invite) URL. */
15
- declare const DISCORD_OAUTH_AUTHORIZE_URL = "https://discord.com/oauth2/authorize";
14
+ export declare const DISCORD_OAUTH_AUTHORIZE_URL = "https://discord.com/oauth2/authorize";
16
15
  /**
17
16
  * Named Discord permission bits (a subset). Discord permissions are a 53+ bit
18
17
  * field, so they are represented as `bigint` and serialized to a decimal string
@@ -20,7 +19,7 @@ declare const DISCORD_OAUTH_AUTHORIZE_URL = "https://discord.com/oauth2/authoriz
20
19
  *
21
20
  * @see https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags
22
21
  */
23
- declare const DISCORD_PERMISSIONS: {
22
+ export declare const DISCORD_PERMISSIONS: {
24
23
  readonly ADD_REACTIONS: bigint;
25
24
  readonly VIEW_CHANNEL: bigint;
26
25
  readonly SEND_MESSAGES: bigint;
@@ -37,9 +36,9 @@ declare const DISCORD_PERMISSIONS: {
37
36
  * permissions. Callers can override via {@link DiscordConnectOptions.permissions}
38
37
  * or {@link DiscordProviderConfig.permissions}.
39
38
  */
40
- declare const DEFAULT_INVITE_PERMISSIONS: bigint;
39
+ export declare const DEFAULT_INVITE_PERMISSIONS: bigint;
41
40
  /** OAuth2 scopes requested by the bot-invite URL. */
42
- declare const DEFAULT_INVITE_SCOPES: readonly ['bot', 'applications.commands'];
41
+ export declare const DEFAULT_INVITE_SCOPES: readonly ['bot', 'applications.commands'];
43
42
  /**
44
43
  * A Discord application command as it goes over the wire (bulk-overwrite
45
44
  * registration). Only the `CHAT_INPUT` (slash) shape is modeled here.
@@ -302,8 +301,6 @@ interface DiscordInstallation {
302
301
  */
303
302
  targetGuildId?: string;
304
303
  }
305
- //#endregion
306
- //#region src/discord-provider.d.ts
307
304
  /**
308
305
  * Resolve the per-adapter config the provider applies to the Discord entry in
309
306
  * `AgentChannels.adapters`. Discord has native embeds + action-row buttons, so
@@ -313,7 +310,7 @@ interface DiscordInstallation {
313
310
  * handed to `AgentChannels` always carries `gateway: false` — core's loop must
314
311
  * never start; see `#createAgentChannels`.)
315
312
  */
316
- declare function resolveDiscordAdapterConfig(config: Pick<DiscordProviderConfig, 'streaming' | 'typingStatus' | 'toolDisplay' | 'gateway'>): {
313
+ export declare function resolveDiscordAdapterConfig(config: Pick<DiscordProviderConfig, 'streaming' | 'typingStatus' | 'toolDisplay' | 'gateway'>): {
317
314
  streaming: StreamingConfig;
318
315
  typingStatus: boolean;
319
316
  toolDisplay: ChannelAdapterConfig['toolDisplay'];
@@ -348,7 +345,7 @@ declare function resolveDiscordAdapterConfig(config: Pick<DiscordProviderConfig,
348
345
  * generation, the interactions route (raw-body delegation), and adapter/Gateway
349
346
  * wiring. Command registration lands in `mastra-discord-13x.4`.
350
347
  */
351
- declare class DiscordProvider implements ChannelProvider {
348
+ export declare class DiscordProvider implements ChannelProvider {
352
349
  #private;
353
350
  readonly id = "discord";
354
351
  constructor(config?: DiscordProviderConfig);
@@ -452,10 +449,8 @@ declare class DiscordProvider implements ChannelProvider {
452
449
  /** The live `DiscordAdapter` for an installation id, if one is active. */
453
450
  getAdapter(installationId: string): DiscordAdapter$1 | undefined;
454
451
  }
455
- //#endregion
456
- //#region src/install-store.d.ts
457
452
  /** Platform identifier used for every stored record, config, and route. */
458
- declare const PLATFORM = "discord";
453
+ export declare const PLATFORM = "discord";
459
454
  /**
460
455
  * Two-tier persistence for Discord, layered over the platform-agnostic
461
456
  * `ChannelsStorage` (the same store `@mastra/slack` / `@mastra/telegram` use).
@@ -468,7 +463,7 @@ declare const PLATFORM = "discord";
468
463
  * — one row per agent, keyed by agent, tracking the `guildIds` the bot is live
469
464
  * in. Secrets are **not** duplicated per row.
470
465
  */
471
- declare class DiscordInstallStore {
466
+ export declare class DiscordInstallStore {
472
467
  #private;
473
468
  private readonly storage;
474
469
  private readonly encryptionKey?;
@@ -507,9 +502,7 @@ declare class DiscordInstallStore {
507
502
  deleteByAgent(agentId: string): Promise<void>;
508
503
  }
509
504
  /** Project an installation to its public, secret-free info for the editor UI. */
510
- declare function toInstallationInfo(install: DiscordInstallation): ChannelInstallationInfo;
511
- //#endregion
512
- //#region src/discord-client.d.ts
505
+ export declare function toInstallationInfo(install: DiscordInstallation): ChannelInstallationInfo;
513
506
  /**
514
507
  * The subset of Discord's application object the control plane reads back from
515
508
  * `GET /applications/@me`.
@@ -537,14 +530,14 @@ interface DiscordApplication {
537
530
  * membership. Sending replies uses the interaction token inside the adapter,
538
531
  * never this bot-token path.
539
532
  */
540
- declare function discordRequest(botToken: string, method: string, path: string, apiBaseUrl?: string, body?: unknown): Promise<Response>;
533
+ export declare function discordRequest(botToken: string, method: string, path: string, apiBaseUrl?: string, body?: unknown): Promise<Response>;
541
534
  /**
542
535
  * Validate the app's bot token and resolve the application identity via
543
536
  * `GET /applications/@me` (Bot auth). Throws if the token is rejected.
544
537
  *
545
538
  * @see https://discord.com/developers/docs/resources/application#get-current-application
546
539
  */
547
- declare function validateApp(botToken: string, apiBaseUrl?: string): Promise<DiscordApplication>;
540
+ export declare function validateApp(botToken: string, apiBaseUrl?: string): Promise<DiscordApplication>;
548
541
  /**
549
542
  * Whether the bot is already a member of a guild. `GET /guilds/{id}` (Bot auth)
550
543
  * returns `200` only when the bot is in the guild. Absence is `404` (`10004
@@ -558,7 +551,7 @@ declare function validateApp(botToken: string, apiBaseUrl?: string): Promise<Dis
558
551
  *
559
552
  * @see https://discord.com/developers/docs/resources/guild#get-guild
560
553
  */
561
- declare function guildHealthCheck(botToken: string, guildId: string, apiBaseUrl?: string): Promise<boolean>;
554
+ export declare function guildHealthCheck(botToken: string, guildId: string, apiBaseUrl?: string): Promise<boolean>;
562
555
  /**
563
556
  * Bulk-overwrite a **guild's** slash commands (`PUT …/guilds/{guildId}/commands`).
564
557
  * Guild-scoped commands update **instantly**. Register on first-seen guild;
@@ -566,7 +559,7 @@ declare function guildHealthCheck(botToken: string, guildId: string, apiBaseUrl?
566
559
  *
567
560
  * @see https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands
568
561
  */
569
- declare function registerGuildCommands(botToken: string, applicationId: string, guildId: string, commands: readonly DiscordCommand[], apiBaseUrl?: string): Promise<void>;
562
+ export declare function registerGuildCommands(botToken: string, applicationId: string, guildId: string, commands: readonly DiscordCommand[], apiBaseUrl?: string): Promise<void>;
570
563
  /**
571
564
  * Bulk-overwrite the app's **global** slash commands (`PUT …/commands`).
572
565
  * Eventually consistent (propagation is not instant — don't quote a fixed
@@ -574,7 +567,7 @@ declare function registerGuildCommands(botToken: string, applicationId: string,
574
567
  *
575
568
  * @see https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-global-application-commands
576
569
  */
577
- declare function registerGlobalCommands(botToken: string, applicationId: string, commands: readonly DiscordCommand[], apiBaseUrl?: string): Promise<void>;
570
+ export declare function registerGlobalCommands(botToken: string, applicationId: string, commands: readonly DiscordCommand[], apiBaseUrl?: string): Promise<void>;
578
571
  /** Inputs for {@link buildInviteUrl}. */
579
572
  interface BuildInviteUrlOptions {
580
573
  /** The application (client) id — becomes `client_id`. */
@@ -596,16 +589,14 @@ interface BuildInviteUrlOptions {
596
589
  *
597
590
  * @see https://discord.com/developers/docs/topics/oauth2#bot-authorization-flow
598
591
  */
599
- declare function buildInviteUrl(options: BuildInviteUrlOptions): string;
600
- //#endregion
601
- //#region src/commands.d.ts
592
+ export declare function buildInviteUrl(options: BuildInviteUrlOptions): string;
602
593
  /**
603
594
  * Conventional command seed registered when a connect provides none. Discord
604
595
  * surfaces `/help` in the command picker; the built-in DM/mention handling
605
596
  * covers everything else, so the seed is intentionally tiny.
606
597
  * @see https://discord.com/developers/docs/interactions/application-commands
607
598
  */
608
- declare const DEFAULT_COMMANDS: readonly DiscordCommandInput[];
599
+ export declare const DEFAULT_COMMANDS: readonly DiscordCommandInput[];
609
600
  /**
610
601
  * Map user-supplied commands to Discord `CHAT_INPUT` command shapes, enforcing
611
602
  * the API constraints: `name` is lowercased, stripped of a leading slash,
@@ -615,22 +606,19 @@ declare const DEFAULT_COMMANDS: readonly DiscordCommandInput[];
615
606
  *
616
607
  * @see https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-naming
617
608
  */
618
- declare function normalizeCommands(raw: readonly DiscordCommandInput[] | undefined): DiscordCommand[];
609
+ export declare function normalizeCommands(raw: readonly DiscordCommandInput[] | undefined): DiscordCommand[];
619
610
  /**
620
611
  * Stable content hash of a normalized command list, used to skip re-`PUT`ting a
621
612
  * guild/global command set that hasn't changed (Discord allows only 200
622
613
  * application-command creates per day, per guild). Order-independent: commands
623
614
  * are sorted by name before hashing.
624
615
  */
625
- declare function hashCommands(commands: readonly DiscordCommand[]): string;
626
- //#endregion
627
- //#region src/crypto.d.ts
616
+ export declare function hashCommands(commands: readonly DiscordCommand[]): string;
628
617
  /** Whether a stored value was produced by {@link encrypt}. */
629
- declare function isEncrypted(value: string): boolean;
618
+ export declare function isEncrypted(value: string): boolean;
630
619
  /** Encrypt a UTF-8 string with a per-value random salt + IV. */
631
- declare function encrypt(plaintext: string, passphrase: string): string;
620
+ export declare function encrypt(plaintext: string, passphrase: string): string;
632
621
  /** Decrypt a value from {@link encrypt}. Plaintext (unprefixed) is returned unchanged. */
633
- declare function decrypt(value: string, passphrase: string): string;
634
- //#endregion
635
- export { type BuildInviteUrlOptions, DEFAULT_COMMANDS, DEFAULT_INVITE_PERMISSIONS, DEFAULT_INVITE_SCOPES, DISCORD_API_BASE_URL, DISCORD_OAUTH_AUTHORIZE_URL, DISCORD_PERMISSIONS, DiscordAdapter, type DiscordAdapterConfig, type DiscordAppConfig, type DiscordApplication, type DiscordCommand, type DiscordCommandInput, type DiscordConnectOptions, DiscordInstallStore, type DiscordInstallation, DiscordProvider, type DiscordProviderConfig, PLATFORM, buildInviteUrl, createDiscordAdapter, decrypt, discordRequest, encrypt, guildHealthCheck, hashCommands, isEncrypted, normalizeCommands, registerGlobalCommands, registerGuildCommands, resolveDiscordAdapterConfig, toInstallationInfo, validateApp };
622
+ export declare function decrypt(value: string, passphrase: string): string;
623
+ export { type BuildInviteUrlOptions, DiscordAdapter, type DiscordAdapterConfig, type DiscordAppConfig, type DiscordApplication, type DiscordCommand, type DiscordCommandInput, type DiscordConnectOptions, type DiscordInstallation, type DiscordProviderConfig, createDiscordAdapter };
636
624
  //# sourceMappingURL=index.d.ts.map
package/dist/index.d.ts CHANGED
@@ -3,16 +3,15 @@ import { ChannelsStorage } from "@mastra/core/storage";
3
3
  import { DiscordAdapter, DiscordAdapter as DiscordAdapter$1, DiscordAdapterConfig, DiscordAdapterConfig as DiscordAdapterConfig$1, createDiscordAdapter } from "@chat-adapter/discord";
4
4
  import { Mastra } from "@mastra/core/mastra";
5
5
  import { ApiRoute } from "@mastra/core/server";
6
- //#region src/types.d.ts
7
6
  /**
8
7
  * Default Discord REST base — **including** the `/api/v10` version segment. The
9
8
  * client concatenates this with the request path verbatim, so an override must
10
9
  * carry its own version segment (`https://example.test/api/v10`); passing a bare
11
10
  * origin produces unversioned request URLs.
12
11
  */
13
- declare const DISCORD_API_BASE_URL = "https://discord.com/api/v10";
12
+ export declare const DISCORD_API_BASE_URL = "https://discord.com/api/v10";
14
13
  /** Base for the OAuth2 authorize (bot-invite) URL. */
15
- declare const DISCORD_OAUTH_AUTHORIZE_URL = "https://discord.com/oauth2/authorize";
14
+ export declare const DISCORD_OAUTH_AUTHORIZE_URL = "https://discord.com/oauth2/authorize";
16
15
  /**
17
16
  * Named Discord permission bits (a subset). Discord permissions are a 53+ bit
18
17
  * field, so they are represented as `bigint` and serialized to a decimal string
@@ -20,7 +19,7 @@ declare const DISCORD_OAUTH_AUTHORIZE_URL = "https://discord.com/oauth2/authoriz
20
19
  *
21
20
  * @see https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags
22
21
  */
23
- declare const DISCORD_PERMISSIONS: {
22
+ export declare const DISCORD_PERMISSIONS: {
24
23
  readonly ADD_REACTIONS: bigint;
25
24
  readonly VIEW_CHANNEL: bigint;
26
25
  readonly SEND_MESSAGES: bigint;
@@ -37,9 +36,9 @@ declare const DISCORD_PERMISSIONS: {
37
36
  * permissions. Callers can override via {@link DiscordConnectOptions.permissions}
38
37
  * or {@link DiscordProviderConfig.permissions}.
39
38
  */
40
- declare const DEFAULT_INVITE_PERMISSIONS: bigint;
39
+ export declare const DEFAULT_INVITE_PERMISSIONS: bigint;
41
40
  /** OAuth2 scopes requested by the bot-invite URL. */
42
- declare const DEFAULT_INVITE_SCOPES: readonly ['bot', 'applications.commands'];
41
+ export declare const DEFAULT_INVITE_SCOPES: readonly ['bot', 'applications.commands'];
43
42
  /**
44
43
  * A Discord application command as it goes over the wire (bulk-overwrite
45
44
  * registration). Only the `CHAT_INPUT` (slash) shape is modeled here.
@@ -302,8 +301,6 @@ interface DiscordInstallation {
302
301
  */
303
302
  targetGuildId?: string;
304
303
  }
305
- //#endregion
306
- //#region src/discord-provider.d.ts
307
304
  /**
308
305
  * Resolve the per-adapter config the provider applies to the Discord entry in
309
306
  * `AgentChannels.adapters`. Discord has native embeds + action-row buttons, so
@@ -313,7 +310,7 @@ interface DiscordInstallation {
313
310
  * handed to `AgentChannels` always carries `gateway: false` — core's loop must
314
311
  * never start; see `#createAgentChannels`.)
315
312
  */
316
- declare function resolveDiscordAdapterConfig(config: Pick<DiscordProviderConfig, 'streaming' | 'typingStatus' | 'toolDisplay' | 'gateway'>): {
313
+ export declare function resolveDiscordAdapterConfig(config: Pick<DiscordProviderConfig, 'streaming' | 'typingStatus' | 'toolDisplay' | 'gateway'>): {
317
314
  streaming: StreamingConfig;
318
315
  typingStatus: boolean;
319
316
  toolDisplay: ChannelAdapterConfig['toolDisplay'];
@@ -348,7 +345,7 @@ declare function resolveDiscordAdapterConfig(config: Pick<DiscordProviderConfig,
348
345
  * generation, the interactions route (raw-body delegation), and adapter/Gateway
349
346
  * wiring. Command registration lands in `mastra-discord-13x.4`.
350
347
  */
351
- declare class DiscordProvider implements ChannelProvider {
348
+ export declare class DiscordProvider implements ChannelProvider {
352
349
  #private;
353
350
  readonly id = "discord";
354
351
  constructor(config?: DiscordProviderConfig);
@@ -452,10 +449,8 @@ declare class DiscordProvider implements ChannelProvider {
452
449
  /** The live `DiscordAdapter` for an installation id, if one is active. */
453
450
  getAdapter(installationId: string): DiscordAdapter$1 | undefined;
454
451
  }
455
- //#endregion
456
- //#region src/install-store.d.ts
457
452
  /** Platform identifier used for every stored record, config, and route. */
458
- declare const PLATFORM = "discord";
453
+ export declare const PLATFORM = "discord";
459
454
  /**
460
455
  * Two-tier persistence for Discord, layered over the platform-agnostic
461
456
  * `ChannelsStorage` (the same store `@mastra/slack` / `@mastra/telegram` use).
@@ -468,7 +463,7 @@ declare const PLATFORM = "discord";
468
463
  * — one row per agent, keyed by agent, tracking the `guildIds` the bot is live
469
464
  * in. Secrets are **not** duplicated per row.
470
465
  */
471
- declare class DiscordInstallStore {
466
+ export declare class DiscordInstallStore {
472
467
  #private;
473
468
  private readonly storage;
474
469
  private readonly encryptionKey?;
@@ -507,9 +502,7 @@ declare class DiscordInstallStore {
507
502
  deleteByAgent(agentId: string): Promise<void>;
508
503
  }
509
504
  /** Project an installation to its public, secret-free info for the editor UI. */
510
- declare function toInstallationInfo(install: DiscordInstallation): ChannelInstallationInfo;
511
- //#endregion
512
- //#region src/discord-client.d.ts
505
+ export declare function toInstallationInfo(install: DiscordInstallation): ChannelInstallationInfo;
513
506
  /**
514
507
  * The subset of Discord's application object the control plane reads back from
515
508
  * `GET /applications/@me`.
@@ -537,14 +530,14 @@ interface DiscordApplication {
537
530
  * membership. Sending replies uses the interaction token inside the adapter,
538
531
  * never this bot-token path.
539
532
  */
540
- declare function discordRequest(botToken: string, method: string, path: string, apiBaseUrl?: string, body?: unknown): Promise<Response>;
533
+ export declare function discordRequest(botToken: string, method: string, path: string, apiBaseUrl?: string, body?: unknown): Promise<Response>;
541
534
  /**
542
535
  * Validate the app's bot token and resolve the application identity via
543
536
  * `GET /applications/@me` (Bot auth). Throws if the token is rejected.
544
537
  *
545
538
  * @see https://discord.com/developers/docs/resources/application#get-current-application
546
539
  */
547
- declare function validateApp(botToken: string, apiBaseUrl?: string): Promise<DiscordApplication>;
540
+ export declare function validateApp(botToken: string, apiBaseUrl?: string): Promise<DiscordApplication>;
548
541
  /**
549
542
  * Whether the bot is already a member of a guild. `GET /guilds/{id}` (Bot auth)
550
543
  * returns `200` only when the bot is in the guild. Absence is `404` (`10004
@@ -558,7 +551,7 @@ declare function validateApp(botToken: string, apiBaseUrl?: string): Promise<Dis
558
551
  *
559
552
  * @see https://discord.com/developers/docs/resources/guild#get-guild
560
553
  */
561
- declare function guildHealthCheck(botToken: string, guildId: string, apiBaseUrl?: string): Promise<boolean>;
554
+ export declare function guildHealthCheck(botToken: string, guildId: string, apiBaseUrl?: string): Promise<boolean>;
562
555
  /**
563
556
  * Bulk-overwrite a **guild's** slash commands (`PUT …/guilds/{guildId}/commands`).
564
557
  * Guild-scoped commands update **instantly**. Register on first-seen guild;
@@ -566,7 +559,7 @@ declare function guildHealthCheck(botToken: string, guildId: string, apiBaseUrl?
566
559
  *
567
560
  * @see https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands
568
561
  */
569
- declare function registerGuildCommands(botToken: string, applicationId: string, guildId: string, commands: readonly DiscordCommand[], apiBaseUrl?: string): Promise<void>;
562
+ export declare function registerGuildCommands(botToken: string, applicationId: string, guildId: string, commands: readonly DiscordCommand[], apiBaseUrl?: string): Promise<void>;
570
563
  /**
571
564
  * Bulk-overwrite the app's **global** slash commands (`PUT …/commands`).
572
565
  * Eventually consistent (propagation is not instant — don't quote a fixed
@@ -574,7 +567,7 @@ declare function registerGuildCommands(botToken: string, applicationId: string,
574
567
  *
575
568
  * @see https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-global-application-commands
576
569
  */
577
- declare function registerGlobalCommands(botToken: string, applicationId: string, commands: readonly DiscordCommand[], apiBaseUrl?: string): Promise<void>;
570
+ export declare function registerGlobalCommands(botToken: string, applicationId: string, commands: readonly DiscordCommand[], apiBaseUrl?: string): Promise<void>;
578
571
  /** Inputs for {@link buildInviteUrl}. */
579
572
  interface BuildInviteUrlOptions {
580
573
  /** The application (client) id — becomes `client_id`. */
@@ -596,16 +589,14 @@ interface BuildInviteUrlOptions {
596
589
  *
597
590
  * @see https://discord.com/developers/docs/topics/oauth2#bot-authorization-flow
598
591
  */
599
- declare function buildInviteUrl(options: BuildInviteUrlOptions): string;
600
- //#endregion
601
- //#region src/commands.d.ts
592
+ export declare function buildInviteUrl(options: BuildInviteUrlOptions): string;
602
593
  /**
603
594
  * Conventional command seed registered when a connect provides none. Discord
604
595
  * surfaces `/help` in the command picker; the built-in DM/mention handling
605
596
  * covers everything else, so the seed is intentionally tiny.
606
597
  * @see https://discord.com/developers/docs/interactions/application-commands
607
598
  */
608
- declare const DEFAULT_COMMANDS: readonly DiscordCommandInput[];
599
+ export declare const DEFAULT_COMMANDS: readonly DiscordCommandInput[];
609
600
  /**
610
601
  * Map user-supplied commands to Discord `CHAT_INPUT` command shapes, enforcing
611
602
  * the API constraints: `name` is lowercased, stripped of a leading slash,
@@ -615,22 +606,19 @@ declare const DEFAULT_COMMANDS: readonly DiscordCommandInput[];
615
606
  *
616
607
  * @see https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-naming
617
608
  */
618
- declare function normalizeCommands(raw: readonly DiscordCommandInput[] | undefined): DiscordCommand[];
609
+ export declare function normalizeCommands(raw: readonly DiscordCommandInput[] | undefined): DiscordCommand[];
619
610
  /**
620
611
  * Stable content hash of a normalized command list, used to skip re-`PUT`ting a
621
612
  * guild/global command set that hasn't changed (Discord allows only 200
622
613
  * application-command creates per day, per guild). Order-independent: commands
623
614
  * are sorted by name before hashing.
624
615
  */
625
- declare function hashCommands(commands: readonly DiscordCommand[]): string;
626
- //#endregion
627
- //#region src/crypto.d.ts
616
+ export declare function hashCommands(commands: readonly DiscordCommand[]): string;
628
617
  /** Whether a stored value was produced by {@link encrypt}. */
629
- declare function isEncrypted(value: string): boolean;
618
+ export declare function isEncrypted(value: string): boolean;
630
619
  /** Encrypt a UTF-8 string with a per-value random salt + IV. */
631
- declare function encrypt(plaintext: string, passphrase: string): string;
620
+ export declare function encrypt(plaintext: string, passphrase: string): string;
632
621
  /** Decrypt a value from {@link encrypt}. Plaintext (unprefixed) is returned unchanged. */
633
- declare function decrypt(value: string, passphrase: string): string;
634
- //#endregion
635
- export { type BuildInviteUrlOptions, DEFAULT_COMMANDS, DEFAULT_INVITE_PERMISSIONS, DEFAULT_INVITE_SCOPES, DISCORD_API_BASE_URL, DISCORD_OAUTH_AUTHORIZE_URL, DISCORD_PERMISSIONS, DiscordAdapter, type DiscordAdapterConfig, type DiscordAppConfig, type DiscordApplication, type DiscordCommand, type DiscordCommandInput, type DiscordConnectOptions, DiscordInstallStore, type DiscordInstallation, DiscordProvider, type DiscordProviderConfig, PLATFORM, buildInviteUrl, createDiscordAdapter, decrypt, discordRequest, encrypt, guildHealthCheck, hashCommands, isEncrypted, normalizeCommands, registerGlobalCommands, registerGuildCommands, resolveDiscordAdapterConfig, toInstallationInfo, validateApp };
622
+ export declare function decrypt(value: string, passphrase: string): string;
623
+ export { type BuildInviteUrlOptions, DiscordAdapter, type DiscordAdapterConfig, type DiscordAppConfig, type DiscordApplication, type DiscordCommand, type DiscordCommandInput, type DiscordConnectOptions, type DiscordInstallation, type DiscordProviderConfig, createDiscordAdapter };
636
624
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["DiscordAdapterConfig","DiscordAdapter"],"sources":["../src/types.ts","../src/discord-provider.ts","../src/install-store.ts","../src/discord-client.ts","../src/commands.ts","../src/crypto.ts"],"mappings":";;;;;;;;;;;;cAgBa;;cAGA;;;;;;;;cASA;WACX;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;;;;;;;;cAUW;;cAWA;;;;;;UAOI;;EAEf;;EAEA;;;KAIU;EAAiC;EAAc;;;;;;;;UAQ1C;;EAEf;;EAEA;;EAEA;;;;;;;;;;UAWe;;;;;;;;;EASf,MAAM,QAAQ;;;;;EAKd;;;;;;EAMA,UAAU;;;;;EAKV;;;;;;;EAOA;;;;;EAKA;;;;;;EAMA,WAAW;;;;;;;;;;EAUX;;;;;EAKA,YAAY;;;;;;;;EAQZ;;;;;EAKA;;;;;;EAMA,mBAAmBA;;EAEnB,SAASA;;;;;;;;EAQT,YAAY;;;;;;EAMZ;;EASA,WAAW;;EAEX,cAAc;;EAEd,cAAc;;EAEd,QAAQ;;EAER,gBAAgB;;EAEhB,cAAc;;EAEd,oBAAoB;;EAEpB,mBAAmB;;EAEnB,OAAO;;EAEP,cAAc;;;;;;;;EAQd,cAAc;;;;;;;EAOd,QAAQ;;EAER,aAAa,cAAc,+BAA+B;;;UAI3C;;;;;;;EAOf;;EAEA;;;;;EAKA,WAAW;;EAEX;;;;;;;;;UAUe;;EAEf;;EAEA;;;;;EAKA;;;;;EAKA;;EAEA;;EAEA;;EAEA,WAAW;;;;;;EAMX,kBAAkB;;EAElB,aAAa;;;;;;;;;;;EAWb;;;;;;;;;EASA,aAAa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sBACC;;;;;;;;iBAcmB,uBACpB,kBACA,uBACA,mBAAmB,kBACnB,sBACC;;UAOc;;EAEf;;EAEA;;EAEA;;;;;EAKA;;;;;;;;;iBAUc,eAAe,SAAS;;;;;;;;;cCzS3B,2BAA2B;;;;;;;;;;iBAaxB,kBAAkB,cAAc,oCAAoC;;;;;;;iBAyBpE,aAAa,mBAAmB;;;;iBC3BhC,YAAY;;iBAKZ,QAAQ,mBAAmB;;iBAU3B,QAAQ,eAAe"}
1
+ {"version":3,"file":"index.d.ts","names":["DiscordAdapterConfig","DiscordAdapter"],"sources":["../src/types.ts","../src/discord-provider.ts","../src/install-store.ts","../src/discord-client.ts","../src/commands.ts","../src/crypto.ts"],"mappings":";;;;;;;;;;;qBAgBa;;qBAGA;;;;;;;;qBASA;WACX;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;;;;;;;;qBAUW;;qBAWA;;;;;;UAOI;;EAEf;;EAEA;;;KAIU;EAAiC;EAAc;;;;;;;;UAQ1C;;EAEf;;EAEA;;EAEA;;;;;;;;;;UAWe;;;;;;;;;EASf,MAAM,QAAQ;;;;;EAKd;;;;;;EAMA,UAAU;;;;;EAKV;;;;;;;EAOA;;;;;EAKA;;;;;;EAMA,WAAW;;;;;;;;;;EAUX;;;;;EAKA,YAAY;;;;;;;;EAQZ;;;;;EAKA;;;;;;EAMA,mBAAmBA;;EAEnB,SAASA;;;;;;;;EAQT,YAAY;;;;;;EAMZ;;EASA,WAAW;;EAEX,cAAc;;EAEd,cAAc;;EAEd,QAAQ;;EAER,gBAAgB;;EAEhB,cAAc;;EAEd,oBAAoB;;EAEpB,mBAAmB;;EAEnB,OAAO;;EAEP,cAAc;;;;;;;;EAQd,cAAc;;;;;;;EAOd,QAAQ;;EAER,aAAa,cAAc,+BAA+B;;;UAI3C;;;;;;;EAOf;;EAEA;;;;;EAKA,WAAW;;EAEX;;;;;;;;;UAUe;;EAEf;;EAEA;;;;;EAKA;;;;;EAKA;;EAEA;;EAEA;;EAEA,W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,iBACA,sBACC;;;;;;;;wBAsHmB,sBACpB,kBACA,uBACA,iBACA,mBAAmB,kBACnB,sBACC;;;;;;;;wBAcmB,uBACpB,kBACA,uBACA,mBAAmB,kBACnB,sBACC;;UAOc;;EAEf;;EAEA;;EAEA;;;;;EAKA;;;;;;;;;wBAUc,eAAe,SAAS;;;;;;;qBCzS3B,2BAA2B;;;;;;;;;;wBAaxB,kBAAkB,cAAc,oCAAoC;;;;;;;wBAyBpE,aAAa,mBAAmB;;wBC3BhC,YAAY;;wBAKZ,QAAQ,mBAAmB;;wBAU3B,QAAQ,eAAe"}
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import { AgentChannels, resolveWaitUntil } from "@mastra/core/channels";
2
2
  import { InMemoryChannelsStorage } from "@mastra/core/storage";
3
3
  import { DiscordAdapter, createDiscordAdapter, createDiscordAdapter as createDiscordAdapter$1 } from "@chat-adapter/discord";
4
4
  import { createCipheriv, createDecipheriv, createHash, hkdfSync } from "crypto";
5
- //#region src/types.ts
5
+ // src/types.ts
6
6
  /**
7
7
  * Default Discord REST base — **including** the `/api/v10` version segment. The
8
8
  * client concatenates this with the request path verbatim, so an override must
@@ -39,8 +39,7 @@ const DISCORD_PERMISSIONS = {
39
39
  const DEFAULT_INVITE_PERMISSIONS = DISCORD_PERMISSIONS.VIEW_CHANNEL | DISCORD_PERMISSIONS.SEND_MESSAGES | DISCORD_PERMISSIONS.SEND_MESSAGES_IN_THREADS | DISCORD_PERMISSIONS.EMBED_LINKS | DISCORD_PERMISSIONS.ATTACH_FILES | DISCORD_PERMISSIONS.READ_MESSAGE_HISTORY | DISCORD_PERMISSIONS.ADD_REACTIONS | DISCORD_PERMISSIONS.USE_APPLICATION_COMMANDS;
40
40
  /** OAuth2 scopes requested by the bot-invite URL. */
41
41
  const DEFAULT_INVITE_SCOPES = ["bot", "applications.commands"];
42
- //#endregion
43
- //#region src/discord-client.ts
42
+ // src/discord-client.ts
44
43
  /** `CHAT_INPUT` (slash) application command type. */
45
44
  const APPLICATION_COMMAND_TYPE_CHAT_INPUT = 1;
46
45
  /** Per-request ceiling for control-plane calls, so a hung API can't stall the provider. */
@@ -249,8 +248,7 @@ function buildInviteUrl(options) {
249
248
  }
250
249
  return url.toString();
251
250
  }
252
- //#endregion
253
- //#region src/commands.ts
251
+ // src/commands.ts
254
252
  /**
255
253
  * Conventional command seed registered when a connect provides none. Discord
256
254
  * surfaces `/help` in the command picker; the built-in DM/mention handling
@@ -382,8 +380,7 @@ function sleep(ms, signal) {
382
380
  signal.addEventListener("abort", onAbort, { once: true });
383
381
  });
384
382
  }
385
- //#endregion
386
- //#region src/crypto.ts
383
+ // src/crypto.ts
387
384
  /**
388
385
  * Opt-in AES-256-GCM encryption for the app's bot token at rest, with
389
386
  * HKDF-SHA256 key derivation (mirrors `@mastra/telegram` / `@mastra/slack`'s
@@ -425,8 +422,7 @@ function decrypt(value, passphrase) {
425
422
  throw new Error("Failed to decrypt a stored Discord secret — either the configured encryption key does not match the one it was encrypted with, or the stored value is corrupt. Check `encryptionKey` on DiscordProvider or MASTRA_ENCRYPTION_KEY.", { cause });
426
423
  }
427
424
  }
428
- //#endregion
429
- //#region src/install-store.ts
425
+ // src/install-store.ts
430
426
  /** Platform identifier used for every stored record, config, and route. */
431
427
  const PLATFORM = "discord";
432
428
  /**
@@ -662,8 +658,7 @@ function planReconcile(input) {
662
658
  }
663
659
  return activations;
664
660
  }
665
- //#endregion
666
- //#region src/discord-provider.ts
661
+ // src/discord-provider.ts
667
662
  /**
668
663
  * Resolve the per-adapter config the provider applies to the Discord entry in
669
664
  * `AgentChannels.adapters`. Discord has native embeds + action-row buttons, so
@@ -1561,7 +1556,6 @@ var DiscordProvider = class {
1561
1556
  };
1562
1557
  }
1563
1558
  };
1564
- //#endregion
1565
1559
  export { DEFAULT_COMMANDS, DEFAULT_INVITE_PERMISSIONS, DEFAULT_INVITE_SCOPES, DISCORD_API_BASE_URL, DISCORD_OAUTH_AUTHORIZE_URL, DISCORD_PERMISSIONS, DiscordAdapter, DiscordInstallStore, DiscordProvider, PLATFORM, buildInviteUrl, createDiscordAdapter, decrypt, discordRequest, encrypt, guildHealthCheck, hashCommands, isEncrypted, normalizeCommands, registerGlobalCommands, registerGuildCommands, resolveDiscordAdapterConfig, toInstallationInfo, validateApp };
1566
1560
 
1567
1561
  //# sourceMappingURL=index.js.map