@elizaos/plugin-discord 2.0.3-beta.2 → 2.0.3-beta.3

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.
Files changed (124) hide show
  1. package/dist/account-client-pool.d.ts +35 -0
  2. package/dist/account-client-pool.d.ts.map +1 -0
  3. package/dist/accounts.d.ts +164 -0
  4. package/dist/accounts.d.ts.map +1 -0
  5. package/dist/actions/actionResultSemantics.d.ts +9 -0
  6. package/dist/actions/actionResultSemantics.d.ts.map +1 -0
  7. package/dist/actions/setup-credentials.d.ts +22 -0
  8. package/dist/actions/setup-credentials.d.ts.map +1 -0
  9. package/dist/addressing.d.ts +15 -0
  10. package/dist/addressing.d.ts.map +1 -0
  11. package/dist/allowlist.d.ts +198 -0
  12. package/dist/allowlist.d.ts.map +1 -0
  13. package/dist/attachments.d.ts +93 -0
  14. package/dist/attachments.d.ts.map +1 -0
  15. package/dist/auto-enable.d.ts +4 -0
  16. package/dist/auto-enable.d.ts.map +1 -0
  17. package/dist/banner.d.ts +39 -0
  18. package/dist/banner.d.ts.map +1 -0
  19. package/dist/catalog-commands.d.ts +65 -0
  20. package/dist/catalog-commands.d.ts.map +1 -0
  21. package/dist/compat.d.ts +32 -0
  22. package/dist/compat.d.ts.map +1 -0
  23. package/dist/config.d.ts +156 -0
  24. package/dist/config.d.ts.map +1 -0
  25. package/dist/connector-account-provider.d.ts +27 -0
  26. package/dist/connector-account-provider.d.ts.map +1 -0
  27. package/dist/constants.d.ts +2 -0
  28. package/dist/constants.d.ts.map +1 -0
  29. package/dist/data-routes.d.ts +22 -0
  30. package/dist/data-routes.d.ts.map +1 -0
  31. package/dist/debouncer.d.ts +42 -0
  32. package/dist/debouncer.d.ts.map +1 -0
  33. package/dist/discord-avatar-cache.d.ts +10 -0
  34. package/dist/discord-avatar-cache.d.ts.map +1 -0
  35. package/dist/discord-commands.d.ts +16 -0
  36. package/dist/discord-commands.d.ts.map +1 -0
  37. package/dist/discord-events.d.ts +57 -0
  38. package/dist/discord-events.d.ts.map +1 -0
  39. package/dist/discord-history.d.ts +56 -0
  40. package/dist/discord-history.d.ts.map +1 -0
  41. package/dist/discord-interactions.d.ts +47 -0
  42. package/dist/discord-interactions.d.ts.map +1 -0
  43. package/dist/discord-local-service.d.ts +102 -0
  44. package/dist/discord-local-service.d.ts.map +1 -0
  45. package/dist/discord-profiles.d.ts +26 -0
  46. package/dist/discord-profiles.d.ts.map +1 -0
  47. package/dist/discord-reactions.d.ts +30 -0
  48. package/dist/discord-reactions.d.ts.map +1 -0
  49. package/dist/draft-chunking.d.ts +9 -0
  50. package/dist/draft-chunking.d.ts.map +1 -0
  51. package/dist/draft-stream.d.ts +23 -0
  52. package/dist/draft-stream.d.ts.map +1 -0
  53. package/dist/environment.d.ts +23 -0
  54. package/dist/environment.d.ts.map +1 -0
  55. package/dist/generated/specs/spec-helpers.d.ts +36 -0
  56. package/dist/generated/specs/spec-helpers.d.ts.map +1 -0
  57. package/dist/generated/specs/specs.d.ts +40 -0
  58. package/dist/generated/specs/specs.d.ts.map +1 -0
  59. package/dist/identity.d.ts +8 -0
  60. package/dist/identity.d.ts.map +1 -0
  61. package/dist/inbound-envelope.d.ts +15 -0
  62. package/dist/inbound-envelope.d.ts.map +1 -0
  63. package/dist/index.browser.d.ts +34 -0
  64. package/dist/index.browser.d.ts.map +1 -0
  65. package/dist/index.d.ts +23 -0
  66. package/dist/index.d.ts.map +1 -0
  67. package/dist/index.js +14414 -0
  68. package/dist/index.js.map +59 -0
  69. package/dist/interactions.d.ts +35 -0
  70. package/dist/interactions.d.ts.map +1 -0
  71. package/dist/message-coalesce.d.ts +31 -0
  72. package/dist/message-coalesce.d.ts.map +1 -0
  73. package/dist/messages.d.ts +70 -0
  74. package/dist/messages.d.ts.map +1 -0
  75. package/dist/messaging.d.ts +129 -0
  76. package/dist/messaging.d.ts.map +1 -0
  77. package/dist/native-commands.d.ts +142 -0
  78. package/dist/native-commands.d.ts.map +1 -0
  79. package/dist/owner-pairing-service.d.ts +73 -0
  80. package/dist/owner-pairing-service.d.ts.map +1 -0
  81. package/dist/permissionEvents.d.ts +42 -0
  82. package/dist/permissionEvents.d.ts.map +1 -0
  83. package/dist/permissions.d.ts +36 -0
  84. package/dist/permissions.d.ts.map +1 -0
  85. package/dist/profileSync.d.ts +8 -0
  86. package/dist/profileSync.d.ts.map +1 -0
  87. package/dist/reasoning-tags.d.ts +2 -0
  88. package/dist/reasoning-tags.d.ts.map +1 -0
  89. package/dist/sensitive-request-adapter.d.ts +19 -0
  90. package/dist/sensitive-request-adapter.d.ts.map +1 -0
  91. package/dist/service.d.ts +315 -0
  92. package/dist/service.d.ts.map +1 -0
  93. package/dist/setup-routes.d.ts +28 -0
  94. package/dist/setup-routes.d.ts.map +1 -0
  95. package/dist/slash-commands.d.ts +38 -0
  96. package/dist/slash-commands.d.ts.map +1 -0
  97. package/dist/staleness.d.ts +25 -0
  98. package/dist/staleness.d.ts.map +1 -0
  99. package/dist/status-reactions.d.ts +11 -0
  100. package/dist/status-reactions.d.ts.map +1 -0
  101. package/dist/test-setup.d.ts +1 -0
  102. package/dist/test-setup.d.ts.map +1 -0
  103. package/dist/tests.d.ts +123 -0
  104. package/dist/tests.d.ts.map +1 -0
  105. package/dist/types.d.ts +345 -0
  106. package/dist/types.d.ts.map +1 -0
  107. package/dist/typing.d.ts +7 -0
  108. package/dist/typing.d.ts.map +1 -0
  109. package/dist/user-account-scraper/discord-browser-scraper.d.ts +118 -0
  110. package/dist/user-account-scraper/discord-browser-scraper.d.ts.map +1 -0
  111. package/dist/user-account-scraper/discord-desktop-cdp.d.ts +33 -0
  112. package/dist/user-account-scraper/discord-desktop-cdp.d.ts.map +1 -0
  113. package/dist/user-account-scraper/index.d.ts +15 -0
  114. package/dist/user-account-scraper/index.d.ts.map +1 -0
  115. package/dist/user-account-scraper/service.d.ts +92 -0
  116. package/dist/user-account-scraper/service.d.ts.map +1 -0
  117. package/dist/utils.d.ts +53 -0
  118. package/dist/utils.d.ts.map +1 -0
  119. package/dist/vitest.config.d.ts +3 -0
  120. package/dist/vitest.config.d.ts.map +1 -0
  121. package/dist/voice.d.ts +242 -0
  122. package/dist/voice.d.ts.map +1 -0
  123. package/package.json +14 -6
  124. package/registry-entry.json +120 -0
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Universal slash-command catalog → Discord native commands.
3
+ *
4
+ * Maps the connector-neutral command catalog from `@elizaos/plugin-commands`
5
+ * (`getConnectorCommands("discord")`) onto the plugin's in-process
6
+ * `SlashCommand` registry so the catalog's navigation + agent-capability
7
+ * commands appear alongside the hand-written Discord built-ins.
8
+ *
9
+ * This is Discord's implementation of the shared `ConnectorCommandBridge`
10
+ * contract (#8790): the same register/dispatch shape and the same auth-gating
11
+ * decision Telegram uses, so both connectors behave consistently.
12
+ *
13
+ * Dedupe decision: the existing Discord built-ins (`help`, `status`, `model`,
14
+ * `settings`, `search`, `clear`, `setup`) already have working, role-gated
15
+ * handlers (some with autocomplete and Discord-specific behavior). To PRESERVE
16
+ * all existing behavior we register only the catalog commands whose sanitized
17
+ * name does NOT already exist in the registry — built-ins always win. This adds
18
+ * the new catalog commands (think, reasoning, views, orchestrator, knowledge,
19
+ * plugins, …) without touching the tested built-in command surface.
20
+ *
21
+ * Per-target dispatch:
22
+ * - `agent` → deterministic commands
23
+ * (help/status/think/model/reset/…) resolve to a local reply
24
+ * via `resolveCommand`; pipeline-owned agent commands route
25
+ * the reconstructed command text through the runtime's message
26
+ * pipeline and reply with the agent's answer.
27
+ * - `navigate` → reply (ephemeral) describing the destination, resolving the
28
+ * `/settings <section>` argument when present.
29
+ * - `client` → GUI/TUI-only behaviors are filtered out of the discord
30
+ * surface upstream; handled defensively with a short reply.
31
+ *
32
+ * Auth gating: `requiresAuth` / `requiresElevated` commands are gated at the
33
+ * connector boundary using the agent's role model (`hasRoleAccess`) — the same
34
+ * mechanism the built-in slash commands use. The Discord sender is mapped to a
35
+ * runtime entity, and a command is refused with a clear reply when the sender
36
+ * is not an owner (for `requiresAuth`) or admin (for `requiresElevated`).
37
+ */
38
+ import { type IAgentRuntime } from "@elizaos/core";
39
+ import { type ConnectorCommand, type ConnectorSenderAuth } from "@elizaos/plugin-commands";
40
+ import type { ChatInputCommandInteraction } from "discord.js";
41
+ import { type SlashCommand } from "./slash-commands.js";
42
+ /**
43
+ * Resolve the Discord sender's trust level using the agent's role model — the
44
+ * same `hasRoleAccess` check the built-in slash commands run. OWNER access
45
+ * satisfies `requiresAuth`; ADMIN access satisfies `requiresElevated`. Role
46
+ * resolution maps the Discord user id through `createUniqueUuid` and reads the
47
+ * canonical-owner / connector-admin whitelist the Discord service populates.
48
+ */
49
+ export declare function resolveDiscordSenderAuth(interaction: ChatInputCommandInteraction, runtime: IAgentRuntime): Promise<ConnectorSenderAuth>;
50
+ /** Map one catalog command onto an in-process `SlashCommand`. */
51
+ export declare function mapCatalogCommand(command: ConnectorCommand): SlashCommand;
52
+ /**
53
+ * Build the catalog commands for the Discord surface, deduped against an
54
+ * existing set of command names (built-ins win). Pure — no side effects.
55
+ */
56
+ export declare function buildCatalogSlashCommands(existingNames?: ReadonlySet<string>, agentId?: string | null): SlashCommand[];
57
+ /**
58
+ * Register the universal catalog commands into the in-process registry and
59
+ * return them. Names already present (built-ins) are skipped so existing
60
+ * behavior is preserved. Called from `onReady` right after the built-ins are
61
+ * registered; the returned commands are folded into the
62
+ * `DISCORD_REGISTER_COMMANDS` payload by `registerSlashCommands`.
63
+ */
64
+ export declare function registerCatalogSlashCommands(runtime: IAgentRuntime): SlashCommand[];
65
+ //# sourceMappingURL=catalog-commands.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog-commands.d.ts","sourceRoot":"","sources":["../catalog-commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAGH,OAAO,EAGN,KAAK,aAAa,EAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EAKxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AAE9D,OAAO,EAGN,KAAK,YAAY,EAEjB,MAAM,kBAAkB,CAAC;AAkD1B;;;;;;GAMG;AACH,wBAAsB,wBAAwB,CAC7C,WAAW,EAAE,2BAA2B,EACxC,OAAO,EAAE,aAAa,GACpB,OAAO,CAAC,mBAAmB,CAAC,CAW9B;AA+ND,iEAAiE;AACjE,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,gBAAgB,GAAG,YAAY,CAQzE;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACxC,aAAa,GAAE,WAAW,CAAC,MAAM,CAAa,EAC9C,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,GACrB,YAAY,EAAE,CAShB;AAED;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC3C,OAAO,EAAE,aAAa,GACpB,YAAY,EAAE,CAehB"}
@@ -0,0 +1,32 @@
1
+ import type { ChannelType, Entity, IAgentRuntime, Metadata, Room, UUID, World } from "@elizaos/core";
2
+ export type WorldCompat = Omit<World, "serverId"> & {
3
+ serverId?: string;
4
+ messageServerId?: UUID;
5
+ };
6
+ export type RoomCompat = Omit<Room, "serverId"> & {
7
+ serverId?: string;
8
+ messageServerId?: UUID;
9
+ };
10
+ export interface EnsureConnectionParams {
11
+ entityId: UUID;
12
+ roomId: UUID;
13
+ roomName?: string;
14
+ userName?: string;
15
+ name?: string;
16
+ worldName?: string;
17
+ source?: string;
18
+ channelId?: string;
19
+ serverId?: string;
20
+ messageServerId?: UUID;
21
+ type?: ChannelType | string;
22
+ worldId?: UUID;
23
+ userId?: UUID;
24
+ metadata?: Metadata;
25
+ }
26
+ export interface ICompatRuntime extends Omit<IAgentRuntime, "ensureWorldExists" | "ensureRoomExists" | "ensureConnection" | "ensureConnections"> {
27
+ ensureWorldExists(world: WorldCompat): Promise<void>;
28
+ ensureRoomExists(room: RoomCompat): Promise<void>;
29
+ ensureConnection(params: EnsureConnectionParams): Promise<void>;
30
+ ensureConnections(entities: Entity[], rooms: RoomCompat[], source: string, world: WorldCompat): Promise<void>;
31
+ }
32
+ //# sourceMappingURL=compat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compat.d.ts","sourceRoot":"","sources":["../compat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,WAAW,EACX,MAAM,EACN,aAAa,EACb,QAAQ,EACR,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,MAAM,eAAe,CAAC;AAEvB,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC,GAAG;IACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,IAAI,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,GAAG;IACjD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,IAAI,CAAC;CACvB,CAAC;AAEF,MAAM,WAAW,sBAAsB;IACtC,QAAQ,EAAE,IAAI,CAAC;IACf,MAAM,EAAE,IAAI,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,IAAI,CAAC;IACvB,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,CAAC;IAC5B,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,MAAM,CAAC,EAAE,IAAI,CAAC;IACd,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACpB;AAED,MAAM,WAAW,cAChB,SAAQ,IAAI,CACX,aAAa,EACX,mBAAmB,GACnB,kBAAkB,GAClB,kBAAkB,GAClB,mBAAmB,CACrB;IACD,iBAAiB,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClD,gBAAgB,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChE,iBAAiB,CAChB,QAAQ,EAAE,MAAM,EAAE,EAClB,KAAK,EAAE,UAAU,EAAE,EACnB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,WAAW,GAChB,OAAO,CAAC,IAAI,CAAC,CAAC;CACjB"}
@@ -0,0 +1,156 @@
1
+ /**
2
+ * Discord plugin configuration types.
3
+ *
4
+ * These types define the configuration schema for the Discord plugin.
5
+ * Shared base types are imported from @elizaos/core.
6
+ */
7
+ import type { BlockStreamingCoalesceConfig, ChannelHeartbeatVisibilityConfig, DmConfig, DmPolicy, GroupPolicy, GroupToolPolicyBySenderConfig, GroupToolPolicyConfig, MarkdownConfig, OutboundRetryConfig, ProviderCommandsConfig, ReplyToMode } from "@elizaos/core";
8
+ export type DiscordPluralKitConfig = {
9
+ enabled?: boolean;
10
+ detectProxied?: boolean;
11
+ cacheUsers?: boolean;
12
+ };
13
+ export type DiscordDmConfig = {
14
+ /** If false, ignore all incoming Discord DMs. Default: true. */
15
+ enabled?: boolean;
16
+ /** Direct message access policy (default: pairing). */
17
+ policy?: DmPolicy;
18
+ /** Allowlist for DM senders (ids or names). */
19
+ allowFrom?: Array<string | number>;
20
+ /** If true, allow group DMs (default: false). */
21
+ groupEnabled?: boolean;
22
+ /** Optional allowlist for group DM channels (ids or slugs). */
23
+ groupChannels?: Array<string | number>;
24
+ };
25
+ export type DiscordGuildChannelConfig = {
26
+ allow?: boolean;
27
+ requireMention?: boolean;
28
+ /** Optional tool policy overrides for this channel. */
29
+ tools?: GroupToolPolicyConfig;
30
+ toolsBySender?: GroupToolPolicyBySenderConfig;
31
+ /** If specified, only load these skills for this channel. Omit = all skills; empty = no skills. */
32
+ skills?: string[];
33
+ /** If false, disable the bot for this channel. */
34
+ enabled?: boolean;
35
+ /** Optional allowlist for channel senders (ids or names). */
36
+ users?: Array<string | number>;
37
+ /** Optional system prompt snippet for this channel. */
38
+ systemPrompt?: string;
39
+ };
40
+ export type DiscordReactionNotificationMode = "off" | "own" | "all" | "allowlist";
41
+ export type DiscordGuildEntry = {
42
+ slug?: string;
43
+ requireMention?: boolean;
44
+ /** Optional tool policy overrides for this guild (used when channel override is missing). */
45
+ tools?: GroupToolPolicyConfig;
46
+ toolsBySender?: GroupToolPolicyBySenderConfig;
47
+ /** Reaction notification mode (off|own|all|allowlist). Default: own. */
48
+ reactionNotifications?: DiscordReactionNotificationMode;
49
+ users?: Array<string | number>;
50
+ channels?: Record<string, DiscordGuildChannelConfig>;
51
+ };
52
+ export type DiscordActionConfig = {
53
+ reactions?: boolean;
54
+ stickers?: boolean;
55
+ polls?: boolean;
56
+ permissions?: boolean;
57
+ messages?: boolean;
58
+ threads?: boolean;
59
+ pins?: boolean;
60
+ search?: boolean;
61
+ memberInfo?: boolean;
62
+ roleInfo?: boolean;
63
+ roles?: boolean;
64
+ channelInfo?: boolean;
65
+ voiceStatus?: boolean;
66
+ events?: boolean;
67
+ moderation?: boolean;
68
+ emojiUploads?: boolean;
69
+ stickerUploads?: boolean;
70
+ channels?: boolean;
71
+ /** Enable bot presence/activity changes (default: false). */
72
+ presence?: boolean;
73
+ };
74
+ export type DiscordIntentsConfig = {
75
+ /** Enable Guild Presences privileged intent (requires Portal opt-in). Default: false. */
76
+ presence?: boolean;
77
+ /** Enable Guild Members privileged intent (requires Portal opt-in). Default: false. */
78
+ guildMembers?: boolean;
79
+ };
80
+ export type DiscordExecApprovalConfig = {
81
+ /** Enable exec approval forwarding to Discord DMs. Default: false. */
82
+ enabled?: boolean;
83
+ /** Discord user IDs to receive approval prompts. Required if enabled. */
84
+ approvers?: Array<string | number>;
85
+ /** Only forward approvals for these agent IDs. Omit = all agents. */
86
+ agentFilter?: string[];
87
+ /** Only forward approvals matching these session key patterns (substring or regex). */
88
+ sessionFilter?: string[];
89
+ };
90
+ export type DiscordAccountConfig = {
91
+ /** Optional display name for this account (used in CLI/UI lists). */
92
+ name?: string;
93
+ /** Optional provider capability tags used for agent/runtime guidance. */
94
+ capabilities?: string[];
95
+ /** Markdown formatting overrides (tables). */
96
+ markdown?: MarkdownConfig;
97
+ /** Override native command registration for Discord (bool or "auto"). */
98
+ commands?: ProviderCommandsConfig;
99
+ /** Allow channel-initiated config writes (default: true). */
100
+ configWrites?: boolean;
101
+ /** If false, do not start this Discord account. Default: true. */
102
+ enabled?: boolean;
103
+ token?: string;
104
+ /** Allow bot-authored messages to trigger replies (default: false). */
105
+ allowBots?: boolean;
106
+ /**
107
+ * Controls how guild channel messages are handled:
108
+ * - "open": guild channels bypass allowlists; mention-gating applies
109
+ * - "disabled": block all guild channel messages
110
+ * - "allowlist": only allow channels present in discord.guilds.*.channels
111
+ */
112
+ groupPolicy?: GroupPolicy;
113
+ /** Outbound text chunk size (chars). Default: 2000. */
114
+ textChunkLimit?: number;
115
+ /** Chunking mode: "length" (default) splits by size; "newline" splits on every newline. */
116
+ chunkMode?: "length" | "newline";
117
+ /** Disable block streaming for this account. */
118
+ blockStreaming?: boolean;
119
+ /** Merge streamed block replies before sending. */
120
+ blockStreamingCoalesce?: BlockStreamingCoalesceConfig;
121
+ /**
122
+ * Soft max line count per Discord message.
123
+ * Discord clients can clip/collapse very tall messages; splitting by lines
124
+ * keeps replies readable in-channel. Default: 17.
125
+ */
126
+ maxLinesPerMessage?: number;
127
+ mediaMaxMb?: number;
128
+ historyLimit?: number;
129
+ /** Max DM turns to keep as history context. */
130
+ dmHistoryLimit?: number;
131
+ /** Per-DM config overrides keyed by user ID. */
132
+ dms?: Record<string, DmConfig>;
133
+ /** Retry policy for outbound Discord API calls. */
134
+ retry?: OutboundRetryConfig;
135
+ /** Per-action tool gating (default: true for all). */
136
+ actions?: DiscordActionConfig;
137
+ /** Control reply threading when reply tags are present (off|first|all). */
138
+ replyToMode?: ReplyToMode;
139
+ dm?: DiscordDmConfig;
140
+ /** New per-guild config keyed by guild id or slug. */
141
+ guilds?: Record<string, DiscordGuildEntry>;
142
+ /** Heartbeat visibility settings for this channel. */
143
+ heartbeat?: ChannelHeartbeatVisibilityConfig;
144
+ /** Exec approval forwarding configuration. */
145
+ execApprovals?: DiscordExecApprovalConfig;
146
+ /** Privileged Gateway Intents (must also be enabled in Discord Developer Portal). */
147
+ intents?: DiscordIntentsConfig;
148
+ /** PluralKit identity resolution for proxied messages. */
149
+ pluralkit?: DiscordPluralKitConfig;
150
+ };
151
+ export type DiscordChannelConfig = {
152
+ /** Optional named Discord account configuration records. */
153
+ accounts?: Record<string, DiscordAccountConfig>;
154
+ } & DiscordAccountConfig;
155
+ export type { DiscordChannelConfig as DiscordConfig };
156
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACX,4BAA4B,EAC5B,gCAAgC,EAChC,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,6BAA6B,EAC7B,qBAAqB,EACrB,cAAc,EACd,mBAAmB,EACnB,sBAAsB,EACtB,WAAW,EACX,MAAM,eAAe,CAAC;AAMvB,MAAM,MAAM,sBAAsB,GAAG;IACpC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,UAAU,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAMF,MAAM,MAAM,eAAe,GAAG;IAC7B,gEAAgE;IAChE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,uDAAuD;IACvD,MAAM,CAAC,EAAE,QAAQ,CAAC;IAClB,+CAA+C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C,qFAAqF;IACrF,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,0DAA0D;IAC1D,SAAS,CAAC,EAAE,sBAAsB,CAAC;CACnC,CAAC;AAMF,MAAM,MAAM,oBAAoB,GAAG;IAClC,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;CAChD,GAAG,oBAAoB,CAAC;AAGzB,YAAY,EAAE,oBAAoB,IAAI,aAAa,EAAE,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Discord ConnectorAccountManager provider.
3
+ *
4
+ * Adapts the existing multi-account resolution in `accounts.ts` to the
5
+ * `ConnectorAccountProvider` contract from
6
+ * `@elizaos/core/connectors/account-manager`.
7
+ *
8
+ * Source of truth for accounts is character settings (`character.settings.discord`)
9
+ * plus the legacy env-only DISCORD_API_TOKEN. The manager observes those via
10
+ * `listAccounts`. `createAccount`/`patchAccount`/`deleteAccount` here are
11
+ * adapters that surface a `ConnectorAccount` shape; persistent storage is
12
+ * delegated to the manager's `ConnectorAccountStorage`.
13
+ *
14
+ * OAuth: Discord uses bot installation (out-of-band) plus an in-app pairing
15
+ * flow handled by `owner-pairing-service.ts`. `startOAuth` returns a Discord
16
+ * application install URL; `completeOAuth` only reports that callback
17
+ * completion is handled through the `/eliza-pair` slash command, not a
18
+ * redirect.
19
+ */
20
+ import type { ConnectorAccountProvider, IAgentRuntime } from "@elizaos/core";
21
+ export declare const DISCORD_PROVIDER_ID = "discord";
22
+ /**
23
+ * Builds the Discord provider for the ConnectorAccountManager. The provider's
24
+ * lifecycle is owned by the manager; the plugin only registers it.
25
+ */
26
+ export declare function createDiscordConnectorAccountProvider(runtime: IAgentRuntime): ConnectorAccountProvider;
27
+ //# sourceMappingURL=connector-account-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connector-account-provider.d.ts","sourceRoot":"","sources":["../connector-account-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAIX,wBAAwB,EAKxB,aAAa,EACb,MAAM,eAAe,CAAC;AASvB,eAAO,MAAM,mBAAmB,YAAY,CAAC;AA8C7C;;;GAGG;AACH,wBAAgB,qCAAqC,CACpD,OAAO,EAAE,aAAa,GACpB,wBAAwB,CA+F1B"}
@@ -0,0 +1,2 @@
1
+ export declare const DISCORD_SERVICE_NAME = "discord";
2
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,YAAY,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Discord local connector post-setup data routes.
3
+ *
4
+ * These endpoints live under `/api/discord/` (not `/api/setup/discord/`)
5
+ * because they're invoked after the connector is authorized to drive the
6
+ * channel-picker UI — they are not part of the setup state machine.
7
+ *
8
+ * GET /api/discord/guilds list guilds the user can manage
9
+ * GET /api/discord/channels list channels for a given guildId
10
+ * POST /api/discord/subscriptions subscribe to a set of channel IDs
11
+ *
12
+ * These routes are registered with `rawPath: true` so they mount at their
13
+ * canonical paths without the plugin-name prefix.
14
+ */
15
+ import type { Route } from "@elizaos/core";
16
+ /**
17
+ * Plugin routes for Discord local post-setup data fetches.
18
+ *
19
+ * These run after the connector is authorized to drive the channel-picker UI.
20
+ */
21
+ export declare const discordDataRoutes: Route[];
22
+ //# sourceMappingURL=data-routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-routes.d.ts","sourceRoot":"","sources":["../data-routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAEX,KAAK,EAGL,MAAM,eAAe,CAAC;AA2RvB;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,KAAK,EAmBpC,CAAC"}
@@ -0,0 +1,42 @@
1
+ import type { Message as DiscordMessage } from "discord.js";
2
+ export type DebouncerFlushCallback = (messages: DiscordMessage[]) => void;
3
+ export interface MessageDebouncer {
4
+ enqueue: (message: DiscordMessage) => void;
5
+ flushAll: () => void;
6
+ pendingCount: () => number;
7
+ destroy: () => void;
8
+ }
9
+ export interface ChannelDebouncerOptions {
10
+ debounceMs?: number;
11
+ responseCooldownMs?: number;
12
+ botUserId?: string;
13
+ getBotUserId?: () => string | undefined;
14
+ coalesceEnabled?: boolean;
15
+ maxBatch?: number;
16
+ /**
17
+ * Only when true (strict / mention-only mode) do we carry recent unaddressed
18
+ * messages forward into the next addressed batch. In respond-to-all mode the
19
+ * agent already answers those messages on their own flush, so buffering them
20
+ * would prepend already-handled chatter onto a later addressed turn.
21
+ */
22
+ shouldRespondOnlyToMentions?: boolean;
23
+ /**
24
+ * How long a recent unaddressed message stays eligible to be folded into a
25
+ * following addressed message's "[Recent channel context]". Must be >= the
26
+ * channel debounce window so a just-flushed unaddressed message is still live
27
+ * when the addressed anchor lands a beat later.
28
+ */
29
+ bufferTtlMs?: number;
30
+ }
31
+ export interface ChannelDebouncer {
32
+ enqueue: (message: DiscordMessage) => void;
33
+ markResponded: (channelId: string) => void;
34
+ flushAll: () => void;
35
+ pendingCount: () => number;
36
+ destroy: () => void;
37
+ }
38
+ export declare function createChannelDebouncer(onFlush: DebouncerFlushCallback, options?: ChannelDebouncerOptions): ChannelDebouncer;
39
+ export declare function createMessageDebouncer(onFlush: DebouncerFlushCallback, debounceMs?: number, options?: {
40
+ maxBatch?: number;
41
+ }): MessageDebouncer;
42
+ //# sourceMappingURL=debouncer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debouncer.d.ts","sourceRoot":"","sources":["../debouncer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,YAAY,CAAC;AAG5D,MAAM,MAAM,sBAAsB,GAAG,CAAC,QAAQ,EAAE,cAAc,EAAE,KAAK,IAAI,CAAC;AAE1E,MAAM,WAAW,gBAAgB;IAChC,OAAO,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,CAAC;IAC3C,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,YAAY,EAAE,MAAM,MAAM,CAAC;IAC3B,OAAO,EAAE,MAAM,IAAI,CAAC;CACpB;AAkBD,MAAM,WAAW,uBAAuB;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;IACxC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;OAKG;IACH,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB;IAChC,OAAO,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,CAAC;IAC3C,aAAa,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,YAAY,EAAE,MAAM,MAAM,CAAC;IAC3B,OAAO,EAAE,MAAM,IAAI,CAAC;CACpB;AAOD,wBAAgB,sBAAsB,CACrC,OAAO,EAAE,sBAAsB,EAC/B,OAAO,GAAE,uBAA4B,GACnC,gBAAgB,CAiOlB;AAED,wBAAgB,sBAAsB,CACrC,OAAO,EAAE,sBAAsB,EAC/B,UAAU,GAAE,MAA4B,EACxC,OAAO,GAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAO,GACjC,gBAAgB,CA2ElB"}
@@ -0,0 +1,10 @@
1
+ export declare function isDiscordAvatarUrl(url: string): boolean;
2
+ export declare function getDiscordAvatarCacheDir(): string;
3
+ export declare function getDiscordAvatarPublicPath(fileName: string): string;
4
+ export declare function getDiscordAvatarCachePath(fileName: string): string;
5
+ export declare function buildDiscordAvatarCacheFileName(url: string, userId?: string): string;
6
+ export declare function cacheDiscordAvatarUrl(url: string | undefined, options?: {
7
+ fetchImpl?: typeof fetch;
8
+ userId?: string;
9
+ }): Promise<string | undefined>;
10
+ //# sourceMappingURL=discord-avatar-cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discord-avatar-cache.d.ts","sourceRoot":"","sources":["../discord-avatar-cache.ts"],"names":[],"mappings":"AAuDA,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAUvD;AAED,wBAAgB,wBAAwB,IAAI,MAAM,CAEjD;AAED,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEnE;AAED,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAElE;AAED,wBAAgB,+BAA+B,CAC9C,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,MAAM,GACb,MAAM,CAWR;AAED,wBAAsB,qBAAqB,CAC1C,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,OAAO,GAAE;IACR,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;CACX,GACJ,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAqF7B"}
@@ -0,0 +1,16 @@
1
+ import type { ApplicationCommandDataResolvable, Guild } from "discord.js";
2
+ import type { InteractionServiceInternals } from "./discord-interactions.js";
3
+ import type { DiscordSlashCommand } from "./types.js";
4
+ /**
5
+ * Transforms an ElizaOS slash command to Discord API format.
6
+ */
7
+ export declare function transformCommandToDiscordApi(cmd: DiscordSlashCommand): ApplicationCommandDataResolvable;
8
+ /**
9
+ * Checks if a command is guild-only.
10
+ */
11
+ export declare function isGuildOnlyCommand(cmd: DiscordSlashCommand): boolean;
12
+ /**
13
+ * Handles the event when the bot joins a guild.
14
+ */
15
+ export declare function handleGuildCreate(service: InteractionServiceInternals, guild: Guild): Promise<void>;
16
+ //# sourceMappingURL=discord-commands.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discord-commands.d.ts","sourceRoot":"","sources":["../discord-commands.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACX,gCAAgC,EAEhC,KAAK,EACL,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAM1E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAGnD;;GAEG;AACH,wBAAgB,4BAA4B,CAC3C,GAAG,EAAE,mBAAmB,GACtB,gCAAgC,CAwBlC;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAKpE;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CACtC,OAAO,EAAE,2BAA2B,EACpC,KAAK,EAAE,KAAK,GACV,OAAO,CAAC,IAAI,CAAC,CAqFf"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Discord event listener setup — extracted from service.ts
3
+ *
4
+ * Contains the body of `setupEventListeners()`: all `client.on(...)` registrations
5
+ * for messageCreate, reactions, guild events, interactions, voice streams,
6
+ * and permission audit events.
7
+ */
8
+ import { type ChannelType as ElizaChannelType, type UUID } from "@elizaos/core";
9
+ import { type Channel, type GuildMember, type Interaction, type Message, type User } from "discord.js";
10
+ import { type ChannelDebouncer, type MessageDebouncer } from "./debouncer.js";
11
+ import type { DiscordService } from "./service.js";
12
+ import { type DiscordSlashCommand } from "./types.js";
13
+ /**
14
+ * Subset of DiscordService fields needed by the event listeners.
15
+ * Because many of the relevant fields are private, the caller passes
16
+ * `this as DiscordServiceInternals`.
17
+ */
18
+ export interface DiscordServiceInternals {
19
+ accountId?: string;
20
+ client: NonNullable<DiscordService["client"]>;
21
+ runtime: DiscordService["runtime"];
22
+ character: DiscordService["character"];
23
+ messageManager: DiscordService["messageManager"];
24
+ voiceManager: DiscordService["voiceManager"];
25
+ messageDebouncer: MessageDebouncer | undefined;
26
+ channelDebouncer: ChannelDebouncer | undefined;
27
+ discordSettings: {
28
+ shouldIgnoreBotMessages: boolean;
29
+ shouldRespondOnlyToMentions?: boolean;
30
+ };
31
+ allowedChannelIds: string[] | undefined;
32
+ listenChannelIds?: string[];
33
+ allowAllSlashCommands: Set<string>;
34
+ slashCommands: DiscordSlashCommand[];
35
+ timeouts: ReturnType<typeof setTimeout>[];
36
+ userSelections: Map<string, Record<string, unknown>>;
37
+ isChannelAllowed(channelId: string): boolean;
38
+ resolveDiscordEntityId(userId: string): UUID;
39
+ buildMemoryFromMessage(message: Message): Promise<import("@elizaos/core").Memory | null>;
40
+ getChannelType(channel: Channel): Promise<ElizaChannelType>;
41
+ handleInteractionCreate(interaction: Interaction): Promise<void>;
42
+ handleGuildCreate(guild: import("discord.js").Guild): Promise<void>;
43
+ handleGuildMemberAdd(member: GuildMember): Promise<void>;
44
+ handleReactionAdd(reaction: import("discord.js").MessageReaction | import("discord.js").PartialMessageReaction, user: User | import("discord.js").PartialUser): Promise<void>;
45
+ handleReactionRemove(reaction: import("discord.js").MessageReaction | import("discord.js").PartialMessageReaction, user: User | import("discord.js").PartialUser): Promise<void>;
46
+ }
47
+ /**
48
+ * Wire up all Discord.js event listeners on `service.client`.
49
+ *
50
+ * Returns the created debouncers so the caller can store them on the service
51
+ * instance (they must be destroyed on stop).
52
+ */
53
+ export declare function setupDiscordEventListeners(service: DiscordServiceInternals): {
54
+ messageDebouncer: MessageDebouncer;
55
+ channelDebouncer: ChannelDebouncer;
56
+ };
57
+ //# sourceMappingURL=discord-events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discord-events.d.ts","sourceRoot":"","sources":["../discord-events.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAEN,KAAK,WAAW,IAAI,gBAAgB,EAEpC,KAAK,IAAI,EACT,MAAM,eAAe,CAAC;AACvB,OAAO,EAE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AAC;IAC7C,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7C,sBAAsB,CACrB,OAAO,EAAE,OAAO,GACd,OAAO,CAAC,OAAO,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;IAClD,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC5D,uBAAuB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjE,iBAAiB,CAAC,KAAK,EAAE,OAAO,YAAY,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpE,oBAAoB,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD,iBAAiB,CAChB,QAAQ,EACL,OAAO,YAAY,EAAE,eAAe,GACpC,OAAO,YAAY,EAAE,sBAAsB,EAC9C,IAAI,EAAE,IAAI,GAAG,OAAO,YAAY,EAAE,WAAW,GAC3C,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,oBAAoB,CACnB,QAAQ,EACL,OAAO,YAAY,EAAE,eAAe,GACpC,OAAO,YAAY,EAAE,sBAAsB,EAC9C,IAAI,EAAE,IAAI,GAAG,OAAO,YAAY,EAAE,WAAW,GAC3C,OAAO,CAAC,IAAI,CAAC,CAAC;CACjB;AA8FD;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,uBAAuB,GAAG;IAC7E,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,gBAAgB,EAAE,gBAAgB,CAAC;CACnC,CA+5BA"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Discord message history / spidering — extracted from service.ts
3
+ *
4
+ * Contains fetchChannelHistory(), getSpiderState(), saveSpiderState(),
5
+ * buildMemoryFromMessage(), ensureConnectionsForMessages().
6
+ */
7
+ import { ChannelType, type Media, type Memory, type UUID } from "@elizaos/core";
8
+ import type { Channel, GuildTextBasedChannel, Message } from "discord.js";
9
+ import type { ICompatRuntime } from "./compat.js";
10
+ import type { MessageManager } from "./messages.js";
11
+ import type { DiscordService } from "./service.js";
12
+ import type { ChannelHistoryOptions, ChannelHistoryResult, ChannelSpiderState } from "./types.js";
13
+ /**
14
+ * Subset of DiscordService fields needed by history functions.
15
+ */
16
+ export interface HistoryServiceInternals {
17
+ accountId?: string;
18
+ client: NonNullable<DiscordService["client"]>;
19
+ runtime: ICompatRuntime;
20
+ messageManager: MessageManager | undefined;
21
+ resolveDiscordEntityId(userId: string): UUID;
22
+ getChannelType(channel: Channel): Promise<ChannelType>;
23
+ isGuildTextBasedChannel(channel: Channel | null): channel is GuildTextBasedChannel;
24
+ }
25
+ /**
26
+ * Get spider state for a channel from the database.
27
+ */
28
+ export declare function getSpiderState(service: HistoryServiceInternals, channelId: string): Promise<ChannelSpiderState | null>;
29
+ /**
30
+ * Save spider state for a channel to the database.
31
+ */
32
+ export declare function saveSpiderState(service: HistoryServiceInternals, state: ChannelSpiderState): Promise<void>;
33
+ /**
34
+ * Builds a Memory object from a Discord Message.
35
+ */
36
+ export declare function buildMemoryFromMessage(service: HistoryServiceInternals, message: Message, options?: {
37
+ processedContent?: string;
38
+ processedAttachments?: Media[];
39
+ extraContent?: Record<string, unknown>;
40
+ extraMetadata?: Record<string, unknown>;
41
+ /**
42
+ * Connector account ID this message arrived on. Stamped into
43
+ * `Memory.metadata.accountId` so downstream actions (and policy
44
+ * evaluation) can route outbound replies through the same account.
45
+ */
46
+ accountId?: string;
47
+ }): Promise<Memory | null>;
48
+ /**
49
+ * Ensures entity connections exist for a batch of Discord messages using batch API.
50
+ */
51
+ export declare function ensureConnectionsForMessages(service: HistoryServiceInternals, messages: Message[], ensuredEntityIds?: Set<string>): Promise<void>;
52
+ /**
53
+ * Fetches and persists message history from a Discord channel.
54
+ */
55
+ export declare function fetchChannelHistory(service: HistoryServiceInternals, channelId: string, options?: ChannelHistoryOptions): Promise<ChannelHistoryResult>;
56
+ //# sourceMappingURL=discord-history.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discord-history.d.ts","sourceRoot":"","sources":["../discord-history.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACN,WAAW,EAGX,KAAK,KAAK,EACV,KAAK,MAAM,EAGX,KAAK,IAAI,EACT,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1E,OAAO,KAAK,EAAE,cAAc,EAAe,MAAM,UAAU,CAAC;AAK5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,KAAK,EACX,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,MAAM,SAAS,CAAC;AA4BjB;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,WAAW,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC9C,OAAO,EAAE,cAAc,CAAC;IACxB,cAAc,EAAE,cAAc,GAAG,SAAS,CAAC;IAE3C,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7C,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IACvD,uBAAuB,CACtB,OAAO,EAAE,OAAO,GAAG,IAAI,GACrB,OAAO,IAAI,qBAAqB,CAAC;CACpC;AASD;;GAEG;AACH,wBAAsB,cAAc,CACnC,OAAO,EAAE,uBAAuB,EAChC,SAAS,EAAE,MAAM,GACf,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAmCpC;AAED;;GAEG;AACH,wBAAsB,eAAe,CACpC,OAAO,EAAE,uBAAuB,EAChC,KAAK,EAAE,kBAAkB,GACvB,OAAO,CAAC,IAAI,CAAC,CAyNf;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAC3C,OAAO,EAAE,uBAAuB,EAChC,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE;IACT,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,oBAAoB,CAAC,EAAE,KAAK,EAAE,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB,GACC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAwHxB;AAED;;GAEG;AACH,wBAAsB,4BAA4B,CACjD,OAAO,EAAE,uBAAuB,EAChC,QAAQ,EAAE,OAAO,EAAE,EACnB,gBAAgB,GAAE,GAAG,CAAC,MAAM,CAAa,GACvC,OAAO,CAAC,IAAI,CAAC,CA0Gf;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CACxC,OAAO,EAAE,uBAAuB,EAChC,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,qBAA0B,GACjC,OAAO,CAAC,oBAAoB,CAAC,CA4jB/B"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Discord interaction handling — extracted from service.ts
3
+ *
4
+ * Contains handleInteractionCreate(), buildStandardizedRooms(),
5
+ * buildStandardizedUsers(), and onReady().
6
+ */
7
+ import { ChannelType, type Entity, type Room, type UUID } from "@elizaos/core";
8
+ import { type Channel, type Client as DiscordClient, type Guild, type Interaction } from "discord.js";
9
+ import type { ICompatRuntime } from "./compat.js";
10
+ import type { DiscordService } from "./service.js";
11
+ import { type DiscordSettings, type DiscordSlashCommand } from "./types.js";
12
+ /**
13
+ * Subset of DiscordService fields needed by interaction handling.
14
+ */
15
+ export interface InteractionServiceInternals {
16
+ accountId?: string;
17
+ accountToken?: string;
18
+ client: NonNullable<DiscordService["client"]>;
19
+ runtime: ICompatRuntime;
20
+ character: DiscordService["character"];
21
+ slashCommands: DiscordSlashCommand[];
22
+ userSelections: Map<string, Record<string, unknown>>;
23
+ timeouts: ReturnType<typeof setTimeout>[];
24
+ discordSettings: DiscordSettings;
25
+ clientReadyPromise: Promise<void> | null;
26
+ resolveDiscordEntityId(userId: string): UUID;
27
+ getChannelType(channel: Channel): Promise<ChannelType>;
28
+ registerSlashCommands(commands: DiscordSlashCommand[]): Promise<void>;
29
+ refreshOwnerDiscordUserIds(client: DiscordClient): Promise<void>;
30
+ }
31
+ /**
32
+ * Handles interactions created by the user (commands, message components).
33
+ */
34
+ export declare function handleInteractionCreate(service: InteractionServiceInternals, interaction: Interaction): Promise<void>;
35
+ /**
36
+ * Builds a standardized list of rooms from Discord guild channels.
37
+ */
38
+ export declare function buildStandardizedRooms(service: InteractionServiceInternals, guild: Guild, _worldId: UUID): Promise<Room[]>;
39
+ /**
40
+ * Builds a standardized list of users (entities) from Discord guild members.
41
+ */
42
+ export declare function buildStandardizedUsers(service: InteractionServiceInternals, guild: Guild): Promise<Entity[]>;
43
+ /**
44
+ * Handles tasks to be performed once the Discord client is fully ready.
45
+ */
46
+ export declare function onReady(service: InteractionServiceInternals, readyClient: DiscordClient<true>): Promise<void>;
47
+ //# sourceMappingURL=discord-interactions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discord-interactions.d.ts","sourceRoot":"","sources":["../discord-interactions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACN,WAAW,EAGX,KAAK,MAAM,EAOX,KAAK,IAAI,EAET,KAAK,IAAI,EAET,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,KAAK,OAAO,EAEZ,KAAK,MAAM,IAAI,aAAa,EAC5B,KAAK,KAAK,EAEV,KAAK,WAAW,EAGhB,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAQ/C,OAAO,KAAK,EAAE,c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