@elizaos/plugin-discord 2.0.0-alpha.8 → 2.0.0-beta.1

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 (149) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +532 -0
  3. package/dist/account-client-pool.d.ts +35 -0
  4. package/dist/account-client-pool.d.ts.map +1 -0
  5. package/dist/accounts.d.ts.map +1 -1
  6. package/dist/actions/actionResultSemantics.d.ts +9 -0
  7. package/dist/actions/actionResultSemantics.d.ts.map +1 -0
  8. package/dist/actions/setup-credentials.d.ts +25 -0
  9. package/dist/actions/setup-credentials.d.ts.map +1 -0
  10. package/dist/addressing.d.ts +15 -0
  11. package/dist/addressing.d.ts.map +1 -0
  12. package/dist/allowlist.d.ts.map +1 -1
  13. package/dist/attachments.d.ts +1 -0
  14. package/dist/attachments.d.ts.map +1 -1
  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.map +1 -1
  18. package/dist/compat.d.ts +4 -3
  19. package/dist/compat.d.ts.map +1 -1
  20. package/dist/config.d.ts.map +1 -1
  21. package/dist/connector-account-provider.d.ts +26 -0
  22. package/dist/connector-account-provider.d.ts.map +1 -0
  23. package/dist/debouncer.d.ts +28 -0
  24. package/dist/debouncer.d.ts.map +1 -0
  25. package/dist/discord-avatar-cache.d.ts +10 -0
  26. package/dist/discord-avatar-cache.d.ts.map +1 -0
  27. package/dist/discord-commands.d.ts +16 -0
  28. package/dist/discord-commands.d.ts.map +1 -0
  29. package/dist/discord-events.d.ts +56 -0
  30. package/dist/discord-events.d.ts.map +1 -0
  31. package/dist/discord-history.d.ts +56 -0
  32. package/dist/discord-history.d.ts.map +1 -0
  33. package/dist/discord-interactions.d.ts +47 -0
  34. package/dist/discord-interactions.d.ts.map +1 -0
  35. package/dist/discord-local-service.d.ts +94 -0
  36. package/dist/discord-local-service.d.ts.map +1 -0
  37. package/dist/discord-profiles.d.ts +26 -0
  38. package/dist/discord-profiles.d.ts.map +1 -0
  39. package/dist/discord-reactions.d.ts +30 -0
  40. package/dist/discord-reactions.d.ts.map +1 -0
  41. package/dist/draft-chunking.d.ts +9 -0
  42. package/dist/draft-chunking.d.ts.map +1 -0
  43. package/dist/draft-stream.d.ts +23 -0
  44. package/dist/draft-stream.d.ts.map +1 -0
  45. package/dist/environment.d.ts +1 -0
  46. package/dist/environment.d.ts.map +1 -1
  47. package/dist/generated/specs/spec-helpers.d.ts +4 -17
  48. package/dist/generated/specs/spec-helpers.d.ts.map +1 -1
  49. package/dist/generated/specs/specs.d.ts +13 -48
  50. package/dist/generated/specs/specs.d.ts.map +1 -1
  51. package/dist/identity.d.ts +8 -0
  52. package/dist/identity.d.ts.map +1 -0
  53. package/dist/inbound-envelope.d.ts +8 -0
  54. package/dist/inbound-envelope.d.ts.map +1 -0
  55. package/dist/index.browser.d.ts.map +1 -1
  56. package/dist/index.d.ts +22 -2
  57. package/dist/index.d.ts.map +1 -1
  58. package/dist/index.js +10173 -10074
  59. package/dist/index.js.map +49 -125
  60. package/dist/message-coalesce.d.ts +31 -0
  61. package/dist/message-coalesce.d.ts.map +1 -0
  62. package/dist/messages.d.ts +13 -2
  63. package/dist/messages.d.ts.map +1 -1
  64. package/dist/messaging.d.ts.map +1 -1
  65. package/dist/native-commands.d.ts.map +1 -1
  66. package/dist/owner-pairing-service.d.ts +73 -0
  67. package/dist/owner-pairing-service.d.ts.map +1 -0
  68. package/dist/permissionEvents.d.ts.map +1 -1
  69. package/dist/permissions.d.ts.map +1 -1
  70. package/dist/profileSync.d.ts +8 -0
  71. package/dist/profileSync.d.ts.map +1 -0
  72. package/dist/reasoning-tags.d.ts +2 -0
  73. package/dist/reasoning-tags.d.ts.map +1 -0
  74. package/dist/service.d.ts +156 -261
  75. package/dist/service.d.ts.map +1 -1
  76. package/dist/setup-routes.d.ts +23 -0
  77. package/dist/setup-routes.d.ts.map +1 -0
  78. package/dist/slash-commands.d.ts +39 -0
  79. package/dist/slash-commands.d.ts.map +1 -0
  80. package/dist/staleness.d.ts +25 -0
  81. package/dist/staleness.d.ts.map +1 -0
  82. package/dist/status-reactions.d.ts +11 -0
  83. package/dist/status-reactions.d.ts.map +1 -0
  84. package/dist/tests.d.ts.map +1 -1
  85. package/dist/types.d.ts +27 -3
  86. package/dist/types.d.ts.map +1 -1
  87. package/dist/typing.d.ts +7 -0
  88. package/dist/typing.d.ts.map +1 -0
  89. package/dist/user-account-scraper/discord-browser-scraper.d.ts +118 -0
  90. package/dist/user-account-scraper/discord-browser-scraper.d.ts.map +1 -0
  91. package/dist/user-account-scraper/discord-desktop-cdp.d.ts +33 -0
  92. package/dist/user-account-scraper/discord-desktop-cdp.d.ts.map +1 -0
  93. package/dist/user-account-scraper/index.d.ts +15 -0
  94. package/dist/user-account-scraper/index.d.ts.map +1 -0
  95. package/dist/user-account-scraper/service.d.ts +92 -0
  96. package/dist/user-account-scraper/service.d.ts.map +1 -0
  97. package/dist/utils.d.ts +11 -4
  98. package/dist/utils.d.ts.map +1 -1
  99. package/dist/vitest.config.d.ts +3 -0
  100. package/dist/vitest.config.d.ts.map +1 -0
  101. package/dist/voice.d.ts +8 -3
  102. package/dist/voice.d.ts.map +1 -1
  103. package/package.json +23 -20
  104. package/dist/actions/chatWithAttachments.d.ts +0 -4
  105. package/dist/actions/chatWithAttachments.d.ts.map +0 -1
  106. package/dist/actions/createPoll.d.ts +0 -4
  107. package/dist/actions/createPoll.d.ts.map +0 -1
  108. package/dist/actions/deleteMessage.d.ts +0 -4
  109. package/dist/actions/deleteMessage.d.ts.map +0 -1
  110. package/dist/actions/downloadMedia.d.ts +0 -4
  111. package/dist/actions/downloadMedia.d.ts.map +0 -1
  112. package/dist/actions/editMessage.d.ts +0 -4
  113. package/dist/actions/editMessage.d.ts.map +0 -1
  114. package/dist/actions/getUserInfo.d.ts +0 -4
  115. package/dist/actions/getUserInfo.d.ts.map +0 -1
  116. package/dist/actions/joinChannel.d.ts +0 -4
  117. package/dist/actions/joinChannel.d.ts.map +0 -1
  118. package/dist/actions/leaveChannel.d.ts +0 -4
  119. package/dist/actions/leaveChannel.d.ts.map +0 -1
  120. package/dist/actions/listChannels.d.ts +0 -4
  121. package/dist/actions/listChannels.d.ts.map +0 -1
  122. package/dist/actions/pinMessage.d.ts +0 -4
  123. package/dist/actions/pinMessage.d.ts.map +0 -1
  124. package/dist/actions/reactToMessage.d.ts +0 -4
  125. package/dist/actions/reactToMessage.d.ts.map +0 -1
  126. package/dist/actions/readChannel.d.ts +0 -4
  127. package/dist/actions/readChannel.d.ts.map +0 -1
  128. package/dist/actions/searchMessages.d.ts +0 -4
  129. package/dist/actions/searchMessages.d.ts.map +0 -1
  130. package/dist/actions/sendDM.d.ts +0 -4
  131. package/dist/actions/sendDM.d.ts.map +0 -1
  132. package/dist/actions/sendMessage.d.ts +0 -4
  133. package/dist/actions/sendMessage.d.ts.map +0 -1
  134. package/dist/actions/serverInfo.d.ts +0 -4
  135. package/dist/actions/serverInfo.d.ts.map +0 -1
  136. package/dist/actions/summarizeConversation.d.ts +0 -4
  137. package/dist/actions/summarizeConversation.d.ts.map +0 -1
  138. package/dist/actions/transcribeMedia.d.ts +0 -4
  139. package/dist/actions/transcribeMedia.d.ts.map +0 -1
  140. package/dist/actions/unpinMessage.d.ts +0 -4
  141. package/dist/actions/unpinMessage.d.ts.map +0 -1
  142. package/dist/generated/prompts/typescript/prompts.d.ts +0 -44
  143. package/dist/generated/prompts/typescript/prompts.d.ts.map +0 -1
  144. package/dist/providers/channelState.d.ts +0 -14
  145. package/dist/providers/channelState.d.ts.map +0 -1
  146. package/dist/providers/guildInfo.d.ts +0 -15
  147. package/dist/providers/guildInfo.d.ts.map +0 -1
  148. package/dist/providers/voiceState.d.ts +0 -12
  149. package/dist/providers/voiceState.d.ts.map +0 -1
package/dist/service.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ChannelType, type Character, type Content, type IAgentRuntime, type Media, type Memory, Service, type TargetInfo } from "@elizaos/core";
1
+ import { ChannelType, type Character, type Content, type IAgentRuntime, type Media, type Memory, type MessageConnectorChatContext, type MessageConnectorQueryContext, type MessageConnectorTarget, type MessageConnectorUserContext, type Room, Service, type TargetInfo, type UUID, type World } from "@elizaos/core";
2
2
  /**
3
3
  * IMPORTANT: Discord ID Handling - Why stringToUuid() instead of asUUID()
4
4
  *
@@ -31,11 +31,53 @@ import { ChannelType, type Character, type Content, type IAgentRuntime, type Med
31
31
  * EventPayloadMap. When emitting these events, cast to `string[]` and payload to `any`
32
32
  * to use the generic emitEvent overload.
33
33
  */
34
- import { type Channel, Client as DiscordJsClient, type Message } from "discord.js";
35
- import { type ICompatRuntime } from "./compat";
34
+ import { type Channel, Client as DiscordJsClient, type Guild, type GuildMember, type Interaction, type Message, type MessageReaction, type PartialMessageReaction, type PartialUser, type User } from "discord.js";
35
+ import type { ICompatRuntime } from "./compat";
36
36
  import { MessageManager } from "./messages";
37
- import { type ChannelHistoryOptions, type ChannelHistoryResult, type IDiscordService } from "./types";
37
+ import type { ChannelHistoryOptions, ChannelHistoryResult, DiscordSettings, DiscordSlashCommand, IDiscordService } from "./types";
38
38
  import { VoiceManager } from "./voice";
39
+ type ConnectorFetchMessagesParams = {
40
+ target?: TargetInfo;
41
+ accountId?: string;
42
+ limit?: number;
43
+ before?: string;
44
+ after?: string;
45
+ cursor?: string;
46
+ channelId?: string;
47
+ roomId?: UUID;
48
+ threadId?: string;
49
+ };
50
+ type ConnectorSearchMessagesParams = ConnectorFetchMessagesParams & {
51
+ query?: string;
52
+ author?: string;
53
+ };
54
+ type ConnectorMessageMutationParams = {
55
+ target?: TargetInfo;
56
+ accountId?: string;
57
+ channelId?: string;
58
+ roomId?: UUID;
59
+ threadId?: string;
60
+ messageId?: string;
61
+ emoji?: string;
62
+ remove?: boolean;
63
+ pin?: boolean;
64
+ text?: string;
65
+ content?: Content;
66
+ };
67
+ type ConnectorChannelMutationParams = {
68
+ target?: TargetInfo;
69
+ accountId?: string;
70
+ channelId?: string;
71
+ roomId?: UUID;
72
+ alias?: string;
73
+ };
74
+ type ConnectorUserLookupParams = {
75
+ accountId?: string;
76
+ userId?: string;
77
+ username?: string;
78
+ handle?: string;
79
+ query?: string;
80
+ };
39
81
  /**
40
82
  * DiscordService class representing a service for interacting with Discord.
41
83
  * @extends Service
@@ -51,20 +93,25 @@ export declare class DiscordService extends Service implements IDiscordService {
51
93
  protected runtime: ICompatRuntime;
52
94
  static serviceType: string;
53
95
  capabilityDescription: string;
96
+ /**
97
+ * Connector account ID this service instance speaks for. Single-account
98
+ * env-only deployments use DEFAULT_ACCOUNT_ID. When the multi-account
99
+ * pool is wired in, each pool slot owns one client and one accountId.
100
+ */
101
+ accountId: string;
102
+ private defaultAccountId;
103
+ private readonly accountPool;
54
104
  client: DiscordJsClient | null;
55
105
  character: Character;
106
+ discordSettings: DiscordSettings;
56
107
  messageManager?: MessageManager;
57
108
  voiceManager?: VoiceManager;
58
- private discordSettings;
109
+ private messageDebouncer?;
110
+ private channelDebouncer?;
111
+ private _loginFailed;
59
112
  private userSelections;
60
113
  private timeouts;
61
114
  clientReadyPromise: Promise<void> | null;
62
- private slashCommands;
63
- private commandRegistrationQueue;
64
- /**
65
- * Slash command names that should bypass allowed channel restrictions.
66
- */
67
- private allowAllSlashCommands;
68
115
  /**
69
116
  * List of allowed channel IDs (parsed from CHANNEL_IDS env var).
70
117
  * If undefined, all channels are allowed.
@@ -75,6 +122,40 @@ export declare class DiscordService extends Service implements IDiscordService {
75
122
  * These are merged with allowedChannelIds for runtime channel management.
76
123
  */
77
124
  private dynamicChannelIds;
125
+ private ownerDiscordUserIds;
126
+ slashCommands: DiscordSlashCommand[];
127
+ private commandRegistrationQueue;
128
+ allowAllSlashCommands: Set<string>;
129
+ /**
130
+ * Resolves owner Discord user IDs from either the explicit
131
+ * ELIZA_DISCORD_OWNER_USER_IDS_JSON setting or the Discord application's
132
+ * team/owner metadata, and registers them as Discord connector admins.
133
+ * Called from the extracted onReady handler once the client is ready.
134
+ */
135
+ refreshOwnerDiscordUserIds(client: DiscordJsClient): Promise<void>;
136
+ /**
137
+ * Registers slash commands with Discord. Called from the onReady event
138
+ * handler via the DISCORD_REGISTER_COMMANDS event emitted by
139
+ * registerBuiltinSlashCommands(). Merges incoming commands with the
140
+ * existing set, then pushes them to Discord both globally (for DMs) and
141
+ * per-guild (for instant availability).
142
+ */
143
+ registerSlashCommands(commands: DiscordSlashCommand[], accountId?: string | null): Promise<void>;
144
+ private resolveDiscordTargetUserId;
145
+ private resolveDiscordSettingsForAccount;
146
+ private resolveListenChannelIdsForAccount;
147
+ private createDiscordJsClient;
148
+ private syncLegacyDefaultAliases;
149
+ private getAccountState;
150
+ private getDefaultAccountState;
151
+ private requireAccountState;
152
+ private resolveAccountIdFromTarget;
153
+ getDefaultAccountId(): string;
154
+ getAccountIds(): string[];
155
+ getClient(accountId?: string | null): DiscordJsClient | null;
156
+ getAccountLabel(accountId?: string | null): string;
157
+ private createAccountServiceFacade;
158
+ private initializeAccount;
78
159
  /**
79
160
  * Constructor for Discord client.
80
161
  * Initializes the Discord client with specified intents and partials,
@@ -83,6 +164,7 @@ export declare class DiscordService extends Service implements IDiscordService {
83
164
  * @param {IAgentRuntime} runtime - The AgentRuntime instance
84
165
  */
85
166
  constructor(runtime: IAgentRuntime);
167
+ isHealthy(): boolean;
86
168
  static start(runtime: IAgentRuntime): Promise<DiscordService>;
87
169
  /**
88
170
  * The SendHandlerFunction implementation for Discord.
@@ -93,311 +175,124 @@ export declare class DiscordService extends Service implements IDiscordService {
93
175
  * @throws {Error} If the client is not ready, target is invalid, or sending fails.
94
176
  */
95
177
  handleSendMessage(runtime: IAgentRuntime, target: TargetInfo, content: Content): Promise<void>;
178
+ private buildConnectorChannelTarget;
179
+ private buildConnectorUserTarget;
180
+ private dedupeConnectorTargets;
181
+ resolveConnectorTargets(query: string, context: MessageConnectorQueryContext): Promise<MessageConnectorTarget[]>;
182
+ listConnectorRooms(context: MessageConnectorQueryContext): Promise<MessageConnectorTarget[]>;
183
+ listRecentConnectorTargets(context: MessageConnectorQueryContext): Promise<MessageConnectorTarget[]>;
184
+ getConnectorChatContext(target: TargetInfo, context: MessageConnectorQueryContext): Promise<MessageConnectorChatContext | null>;
185
+ getConnectorUserContext(entityId: UUID | string, context: MessageConnectorQueryContext): Promise<MessageConnectorUserContext | null>;
186
+ private resolveConnectorTextChannel;
187
+ private fetchConnectorDiscordMessage;
188
+ listConnectorServers(context: MessageConnectorQueryContext): Promise<World[]>;
189
+ fetchConnectorMessages(_context: MessageConnectorQueryContext, params: ConnectorFetchMessagesParams): Promise<Memory[]>;
190
+ searchConnectorMessages(context: MessageConnectorQueryContext, params: ConnectorSearchMessagesParams): Promise<Memory[]>;
191
+ reactConnectorMessage(_runtime: IAgentRuntime, params: ConnectorMessageMutationParams): Promise<void>;
192
+ editConnectorMessage(_runtime: IAgentRuntime, params: ConnectorMessageMutationParams): Promise<Memory>;
193
+ deleteConnectorMessage(_runtime: IAgentRuntime, params: ConnectorMessageMutationParams): Promise<void>;
194
+ pinConnectorMessage(_runtime: IAgentRuntime, params: ConnectorMessageMutationParams): Promise<void>;
195
+ joinConnectorChannel(_runtime: IAgentRuntime, params: ConnectorChannelMutationParams): Promise<Room | null>;
196
+ leaveConnectorChannel(_runtime: IAgentRuntime, params: ConnectorChannelMutationParams): Promise<void>;
197
+ getConnectorUser(_runtime: IAgentRuntime, params: ConnectorUserLookupParams): Promise<unknown>;
96
198
  /**
97
199
  * Set up event listeners for the client.
200
+ * Delegates to the extracted setupDiscordEventListeners() function.
98
201
  * @private
99
202
  */
100
- private setupEventListeners;
101
- /**
102
- * Handles the event when a new member joins a guild.
103
- *
104
- * **Event Design Note:**
105
- * We intentionally do NOT emit the standardized `EventType.ENTITY_JOINED` here.
106
- * In ElizaOS's abstraction model:
107
- * - A Discord "guild" maps to a "world" (the server/community)
108
- * - A Discord "channel" maps to a "room" (a specific conversation space)
109
- *
110
- * `EventType.ENTITY_JOINED` requires a `roomId` because the bootstrap plugin's
111
- * handler calls `syncSingleUser()` to sync the entity to a specific room. When
112
- * a member joins a guild, they've joined the "world" but haven't joined any
113
- * specific "room" yet - they're just a potential participant.
114
- *
115
- * The entity will be properly synced to rooms when they first interact:
116
- * - First message in a channel → message handler calls `ensureConnection()`
117
- * - Joining a voice channel → voice handler syncs them to that room
118
- *
119
- * We still emit the Discord-specific `DiscordEventTypes.ENTITY_JOINED` so that
120
- * Discord-aware plugins can react to guild member joins (e.g., welcome messages,
121
- * role assignment, moderation checks).
122
- *
123
- * @param {GuildMember} member - The GuildMember object representing the new member.
124
- * @returns {Promise<void>} - A Promise that resolves once the event handling is complete.
125
- * @private
126
- */
127
- private handleGuildMemberAdd;
128
- /**
129
- * Registers slash commands with Discord.
130
- *
131
- * This method uses a hybrid permission system that combines:
132
- * 1. Discord's native permission features (default_member_permissions, contexts)
133
- * 2. ElizaOS channel whitelist bypass (bypassChannelWhitelist flag)
134
- * 3. Custom validation functions (validator callback)
135
- *
136
- * ## Design Decisions
137
- *
138
- * ### Why Hybrid Approach?
139
- * - Discord's native permissions are powerful but limited to role-based access
140
- * - ElizaOS needs programmatic control for channel restrictions and custom logic
141
- * - Combining both gives developers the best of both worlds
142
- *
143
- * ### Why Transform Simple Flags?
144
- * - Developer experience: `guildOnly: true` is clearer than `contexts: [0]`
145
- * - Abstraction: Shields developers from Discord API changes
146
- * - Sensible defaults: Zero config should "just work"
147
- *
148
- * ### Why Three Registration Categories?
149
- *
150
- * Commands are categorized based on where they should be available:
151
- *
152
- * 1. **Global commands** (no guildOnly, no guildIds):
153
- * - Registered globally via `application.commands.set()` for DM access
154
- * - ALSO registered per-guild for instant availability in guilds
155
- * - Guild version overrides global (no duplicates shown in Discord)
156
- * - Best of both worlds: instant in guilds + works in DMs
157
- *
158
- * 2. **Guild-only commands** (guildOnly: true or contexts: [0]):
159
- * - Registered per-guild via `application.commands.set(cmds, guildId)`
160
- * - NOT available in DMs (correct behavior)
161
- * - Instant availability in guilds
162
- * - New guilds get commands via guildCreate event
163
- *
164
- * 3. **Targeted commands** (has guildIds array):
165
- * - Registered only to specified guilds via `.create()` or `.edit()`
166
- * - Useful for testing or server-specific features
167
- * - Instant updates
168
- *
169
- * ### Why Register Global Commands Both Globally AND Per-Guild?
170
- * - Global registration alone takes up to 1 hour to propagate (Discord limitation)
171
- * - Per-guild registration gives instant availability
172
- * - Guild commands override global ones in that guild (no duplicates)
173
- * - Global registration still needed for DM access (no guild context in DMs)
174
- *
175
- * ### Why Not Register Everything Per-Guild Only?
176
- * - Commands that work in DMs MUST be registered globally
177
- * - There's no guild context in DMs, so per-guild commands don't appear there
178
- *
179
- * @param commands - Array of slash commands to register
180
- * @returns Promise that resolves when registration is complete
181
- * @private
182
- */
183
- private registerSlashCommands;
184
- /**
185
- * Transforms an ElizaOS slash command to Discord API format.
186
- * This bridges our developer-friendly API with Discord's native requirements.
187
- * @param {DiscordSlashCommand} cmd - The ElizaOS command definition
188
- * @returns {object} Discord API compatible command object
189
- * @private
190
- */
191
- private transformCommandToDiscordApi;
192
- /**
193
- * Checks if a command is guild-only (shouldn't appear in DMs).
194
- *
195
- * A command is considered guild-only if:
196
- * - `contexts: [0]` is set (Discord's native format, where 0 = Guild only)
197
- * - `guildOnly: true` is set AND no contexts override is provided
198
- *
199
- * `contexts` takes precedence over `guildOnly` to be consistent with
200
- * `transformCommandToDiscordApi`. { guildOnly: true, contexts: [0, 1] }
201
- * will correctly enable DM access (not be treated as guild-only).
202
- *
203
- * @param {DiscordSlashCommand} cmd - The command to check
204
- * @returns {boolean} True if the command should only be available in guilds
205
- * @private
206
- */
207
- private isGuildOnlyCommand;
208
- /**
209
- * Handles the event when the bot joins a guild. It logs the guild name, fetches additional information about the guild, scans the guild for voice data, creates standardized world data structure, generates unique IDs, and emits events to the runtime.
210
- * @param {Guild} guild - The guild that the bot has joined.
211
- * @returns {Promise<void>} A promise that resolves when the guild creation is handled.
212
- * @private
213
- */
214
- private handleGuildCreate;
215
- /**
216
- * Handles interactions created by the user, specifically commands and message components.
217
- * @param {Interaction} interaction - The interaction object received.
218
- * @returns {Promise<void>} A promise that resolves when the interaction is handled.
219
- * @private
220
- */
221
- private handleInteractionCreate;
222
- /**
223
- * Builds a standardized list of rooms from Discord guild channels.
224
- *
225
- * @param {Guild} guild The guild to build rooms for.
226
- * @param {UUID} _worldId The ID of the world to associate with the rooms (currently unused in favor of direct channel to room mapping).
227
- * @returns {Promise<Array<{ id: UUID; name: string; type: ChannelType; channelId: string; participants: UUID[] }>>} An array of standardized room objects.
228
- * @private
229
- */
230
- private buildStandardizedRooms;
231
- /**
232
- * Builds a standardized list of users (entities) from Discord guild members.
233
- * Implements different strategies based on guild size for performance.
234
- *
235
- * @param {Guild} guild - The guild from which to build the user list.
236
- * @returns {Promise<Entity[]>} A promise that resolves with an array of standardized entity objects.
237
- * @private
238
- */
239
- private buildStandardizedUsers;
203
+ private setupEventListenersForAccount;
240
204
  /**
241
- * Handles tasks to be performed once the Discord client is fully ready and connected.
242
- * This includes fetching guilds, scanning for voice data, and emitting connection events.
205
+ * Handles tasks to be performed once the Discord client is fully ready. Delegates to extracted module.
243
206
  * @private
244
- * @returns {Promise<void>} A promise that resolves when all on-ready tasks are completed.
245
207
  */
246
- private onReady;
208
+ private onReadyForAccount;
247
209
  /**
248
210
  * Registers send handlers for the Discord service instance.
249
- * This allows the runtime to correctly dispatch messages to this service.
250
- * @param {IAgentRuntime} runtime - The agent runtime instance.
251
- * @param {DiscordService} serviceInstance - The instance of the DiscordService.
252
211
  * @static
253
212
  */
254
213
  static registerSendHandlers(runtime: IAgentRuntime, serviceInstance: DiscordService): void;
255
214
  /**
256
215
  * Fetches all members who have access to a specific text channel.
257
- *
258
- * @param {string} channelId - The Discord ID of the text channel.
259
- * @param {boolean} [useCache=true] - Whether to prioritize cached data. Defaults to true.
260
- * @returns {Promise<Array<{id: string, username: string, displayName: string}>>} A promise that resolves with an array of channel member objects, each containing id, username, and displayName.
261
216
  */
262
- getTextChannelMembers(channelId: string, useCache?: boolean): Promise<Array<{
217
+ getTextChannelMembers(channelId: string, useCache?: boolean, accountId?: string | null): Promise<Array<{
263
218
  id: string;
264
219
  username: string;
265
220
  displayName: string;
266
221
  }>>;
267
222
  /**
268
223
  * Fetches the topic/description of a Discord text channel.
269
- *
270
- * WHY THIS METHOD EXISTS:
271
- * =======================
272
- * Room metadata contains topic from initial sync, but channel topics can change.
273
- * This method lets plugins fetch FRESH topic data directly from Discord API.
274
- *
275
- * Used by plugin-content-seeder to get authoritative topic data for discussion seeding.
276
- *
277
- * WHY NOT JUST USE METADATA:
278
- * Room.metadata.topic is set at sync time and may be stale if the Discord admin
279
- * updates the channel topic. For plugins that care about freshness, this method
280
- * provides a way to get current data.
281
- *
282
- * TRADEOFF: This makes an API call, so it's slower than reading metadata.
283
- * Use metadata for most cases, this method when freshness matters.
284
- *
285
- * @param {string} channelId - The Discord ID of the text channel.
286
- * @returns {Promise<string | null>} The channel topic, or null if not available.
287
224
  */
288
- getChannelTopic(channelId: string): Promise<string | null>;
289
- /**
290
- * Generic handler for reaction events (add/remove).
291
- * @private
292
- */
293
- private handleReaction;
294
- /**
295
- * Handles reaction addition.
296
- * @private
297
- */
298
- private handleReactionAdd;
299
- /**
300
- * Handles reaction removal.
301
- * @private
302
- */
303
- private handleReactionRemove;
225
+ getChannelTopic(channelId: string, accountId?: string | null): Promise<string | null>;
304
226
  /**
305
227
  * Checks if a channel ID is allowed based on both env config and dynamic additions.
306
- * @param {string} channelId - The channel ID to check
307
- * @returns {boolean} Whether the channel is allowed
308
228
  */
309
- isChannelAllowed(channelId: string): boolean;
229
+ isChannelAllowed(channelId: string, accountId?: string | null): boolean;
310
230
  /**
311
231
  * Adds a channel to the dynamic allowed list.
312
- * @param {string} channelId - The channel ID to add
313
- * @returns {boolean} Whether the channel was successfully added
314
232
  */
315
- addAllowedChannel(channelId: string): boolean;
233
+ addAllowedChannel(channelId: string, accountId?: string | null): boolean;
316
234
  /**
317
235
  * Removes a channel from the dynamic allowed list.
318
- * @param {string} channelId - The channel ID to remove
319
- * @returns {boolean} Whether the channel was in the list and removed
320
236
  */
321
- removeAllowedChannel(channelId: string): boolean;
237
+ removeAllowedChannel(channelId: string, accountId?: string | null): boolean;
322
238
  /**
323
239
  * Gets the list of all allowed channels (env + dynamic).
324
- * @returns {string[]} Array of allowed channel IDs
325
240
  */
326
- getAllowedChannels(): string[];
241
+ getAllowedChannels(accountId?: string | null): string[];
327
242
  /**
328
- * Type guard to check if a channel is a guild text-based channel
329
- * @private
243
+ * Fetches and persists message history from a Discord channel. Delegates to extracted module.
244
+ */
245
+ fetchChannelHistory(channelId: string, options?: ChannelHistoryOptions): Promise<ChannelHistoryResult>;
246
+ /**
247
+ * Builds a Memory object from a Discord Message. Delegates to extracted module.
330
248
  */
331
- private isGuildTextBasedChannel;
249
+ buildMemoryFromMessage(message: Message, options?: {
250
+ processedContent?: string;
251
+ processedAttachments?: Media[];
252
+ extraContent?: Record<string, unknown>;
253
+ extraMetadata?: Record<string, unknown>;
254
+ accountId?: string;
255
+ }): Promise<Memory | null>;
332
256
  /**
333
- * Helper to delay execution
334
- * @private
257
+ * Maps a Discord snowflake user id to the runtime entity UUID, substituting
258
+ * the canonical Eliza owner entity when the user is a known Discord owner.
335
259
  */
336
- private delay;
260
+ resolveDiscordEntityId(userId: string): UUID;
337
261
  /**
338
- * Get spider state for a channel from the database
339
- * @private
262
+ * Handles reaction addition. Delegates to extracted module.
340
263
  */
341
- private getSpiderState;
264
+ handleReactionAdd(reaction: MessageReaction | PartialMessageReaction, user: User | PartialUser): Promise<void>;
265
+ private handleReactionAddForAccount;
342
266
  /**
343
- * Save spider state for a channel to the database
344
- * @private
267
+ * Handles reaction removal. Delegates to extracted module.
345
268
  */
346
- private saveSpiderState;
269
+ handleReactionRemove(reaction: MessageReaction | PartialMessageReaction, user: User | PartialUser): Promise<void>;
270
+ private handleReactionRemoveForAccount;
347
271
  /**
348
- * Fetches and persists message history from a Discord channel.
349
- * Supports pagination, state tracking, and streaming via callback.
350
- *
351
- * Persistence behavior:
352
- * - When `onBatch` callback is NOT provided: Messages are automatically persisted
353
- * to the database and accumulated in the returned `messages` array.
354
- * - When `onBatch` callback IS provided: Messages are passed to the callback and
355
- * the caller is responsible for persistence. This allows for custom handling.
356
- *
357
- * @param {string} channelId - The Discord channel ID to fetch from
358
- * @param {ChannelHistoryOptions} options - Options for the fetch operation
359
- * @returns {Promise<ChannelHistoryResult>} The result with messages and stats
272
+ * Handles guild creation (bot joined a guild). Delegates to extracted module.
360
273
  */
361
- fetchChannelHistory(channelId: string, options?: ChannelHistoryOptions): Promise<ChannelHistoryResult>;
274
+ handleGuildCreate(guild: Guild): Promise<void>;
275
+ private handleGuildCreateForAccount;
362
276
  /**
363
- * Builds a Memory object from a Discord Message.
364
- * This is a reusable helper for converting Discord messages to ElizaOS Memory format.
365
- *
366
- * @param {Message} message - The Discord message to convert
367
- * @param {Object} options - Optional parameters
368
- * @param {string} options.processedContent - Pre-processed text content (if already processed, to avoid double-processing)
369
- * @param {Media[]} options.processedAttachments - Pre-processed attachments (if already processed)
370
- * @param {Object} options.extraContent - Additional content fields to merge into the memory content
371
- * @param {Object} options.extraMetadata - Additional metadata fields to merge into the memory metadata
372
- * @returns {Promise<Memory | null>} The Memory object, or null if the message is invalid
277
+ * Handles interaction creation (slash commands, modals, etc). Delegates to
278
+ * extracted module.
373
279
  */
374
- buildMemoryFromMessage(message: Message, options?: {
375
- processedContent?: string;
376
- processedAttachments?: Media[];
377
- extraContent?: Record<string, unknown>;
378
- extraMetadata?: Record<string, unknown>;
379
- }): Promise<Memory | null>;
280
+ handleInteractionCreate(interaction: Interaction): Promise<void>;
281
+ private handleInteractionCreateForAccount;
380
282
  /**
381
- * Ensures entity connections exist for a batch of Discord messages using batch API.
382
- * This should be called before persisting memories to avoid FK constraint failures.
383
- *
384
- * @param {Message[]} messages - The Discord messages to ensure connections for
385
- * @param {Set<string>} ensuredEntityIds - Optional set of already-ensured entity IDs (for caching across batches)
386
- * @returns {Promise<void>}
283
+ * Handles a new guild member joining emits an ENTITY_JOINED event so the
284
+ * runtime can create the entity record.
387
285
  */
388
- private ensureConnectionsForMessages;
286
+ handleGuildMemberAdd(member: GuildMember): Promise<void>;
287
+ private handleGuildMemberAddForAccount;
389
288
  /**
390
289
  * Stops the Discord service and cleans up resources.
391
- * Implements the abstract method from the Service class.
392
290
  */
393
291
  stop(): Promise<void>;
394
292
  /**
395
293
  * Asynchronously retrieves the type of a given channel.
396
- *
397
- * @param {Channel} channel - The channel for which to determine the type.
398
- * @returns {Promise<ChannelType>} A Promise that resolves with the type of the channel.
399
294
  */
400
295
  getChannelType(channel: Channel): Promise<ChannelType>;
401
296
  }
402
- export default DiscordService;
297
+ export {};
403
298
  //# sourceMappingURL=service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../service.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,KAAK,SAAS,EACd,KAAK,OAAO,EAOZ,KAAK,aAAa,EAClB,KAAK,KAAK,EACV,KAAK,MAAM,EAIX,OAAO,EAEP,KAAK,UAAU,EAGhB,MAAM,eAAe,CAAC;AAEvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,EAKL,KAAK,OAAO,EAIZ,MAAM,IAAI,eAAe,EASzB,KAAK,OAAO,EAQb,MAAM,YAAY,CAAC;AACpB,OAAO,EAAuB,KAAK,cAAc,EAAoB,MAAM,UAAU,CAAC;AAGtF,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAQ5C,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EAUzB,KAAK,eAAe,EACrB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC;;;;;;;;;;GAUG;AAEH,qBAAa,cAAe,SAAQ,OAAQ,YAAW,eAAe;IAEpE,UAAkB,OAAO,EAAE,cAAc,CAAC;IAE1C,MAAM,CA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QAC/B,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACvC,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACxC,SAAS,CAAC,EAAE,MAAM,CAAC;KACnB,GACC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAczB;;;OAGG;IACI,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAQnD;;OAEG;IACU,iBAAiB,CAC7B,QAAQ,EAAE,eAAe,GAAG,sBAAsB,EAClD,IAAI,EAAE,IAAI,GAAG,WAAW,GACtB,OAAO,CAAC,IAAI,CAAC;YAQF,2BAA2B;IAazC;;OAEG;IACU,oBAAoB,CAChC,QAAQ,EAAE,eAAe,GAAG,sBAAsB,EAClD,IAAI,EAAE,IAAI,GAAG,WAAW,GACtB,OAAO,CAAC,IAAI,CAAC;YAQF,8BAA8B;IAa5C;;OAEG;IACU,iBAAiB,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC;YAI7C,2BAA2B;IAUzC;;;OAGG;IACU,uBAAuB,CACnC,WAAW,EAAE,WAAW,GACtB,OAAO,CAAC,IAAI,CAAC;YAOF,iCAAiC;IAW/C;;;OAGG;IACU,oBAAoB,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;YAIvD,8BAA8B;IAuC5C;;OAEG;IACU,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IA0DlC;;OAEG;IACG,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC;CAgC5D"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Discord local setup HTTP routes.
3
+ *
4
+ * Provides status, authorization, and subscription management for the
5
+ * Discord local IPC connector:
6
+ *
7
+ * GET /api/discord-local/status connection + auth status
8
+ * POST /api/discord-local/authorize start OAuth authorize flow
9
+ * POST /api/discord-local/disconnect tear down session
10
+ * GET /api/discord-local/guilds list guilds (requires auth)
11
+ * GET /api/discord-local/channels list channels for a guild
12
+ * POST /api/discord-local/subscriptions subscribe to channel messages
13
+ *
14
+ * These routes are registered with `rawPath: true` so they mount at their
15
+ * legacy paths without the plugin-name prefix.
16
+ */
17
+ import type { Route } from "@elizaos/core";
18
+ /**
19
+ * Plugin routes for Discord local setup.
20
+ * Registered with `rawPath: true` to preserve legacy `/api/discord-local/*` paths.
21
+ */
22
+ export declare const discordSetupRoutes: Route[];
23
+ //# sourceMappingURL=setup-routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup-routes.d.ts","sourceRoot":"","sources":["../setup-routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAEX,KAAK,EAGL,MAAM,eAAe,CAAC;AA6RvB;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,KAAK,EAqCrC,CAAC"}
@@ -0,0 +1,39 @@
1
+ import { type IAgentRuntime } from "@elizaos/core";
2
+ import type { AutocompleteInteraction, ChatInputCommandInteraction } from "discord.js";
3
+ type SlashCommandRole = "OWNER" | "ADMIN" | "USER" | "GUEST";
4
+ interface SlashCommand {
5
+ name: string;
6
+ description: string;
7
+ options?: SlashCommandOption[];
8
+ ephemeral?: boolean;
9
+ cooldown?: number;
10
+ ownerOnly?: boolean;
11
+ /** Minimum elizaOS role required to execute this command. */
12
+ requiredRole?: SlashCommandRole;
13
+ execute: (interaction: ChatInputCommandInteraction, runtime: IAgentRuntime) => Promise<void>;
14
+ autocomplete?: (interaction: AutocompleteInteraction) => Promise<void>;
15
+ }
16
+ /** Context resolved by the Discord service before dispatching built-in commands. */
17
+ export interface SlashCommandContext {
18
+ entityId: string;
19
+ roomId: string;
20
+ }
21
+ interface SlashCommandOption {
22
+ name: string;
23
+ description: string;
24
+ type: "string" | "number" | "boolean" | "user" | "channel" | "role";
25
+ required?: boolean;
26
+ choices?: Array<{
27
+ name: string;
28
+ value: string;
29
+ }>;
30
+ autocomplete?: boolean;
31
+ }
32
+ export declare function registerSlashCommands(runtime: IAgentRuntime): Promise<void>;
33
+ export declare function handleSlashCommand(interaction: ChatInputCommandInteraction, runtime: IAgentRuntime, context?: SlashCommandContext): Promise<void>;
34
+ export declare function handleAutocomplete(interaction: AutocompleteInteraction): Promise<void>;
35
+ export declare function getRegisteredCommands(): ReadonlyMap<string, SlashCommand>;
36
+ export declare function addCommand(command: SlashCommand): void;
37
+ export declare function removeCommand(name: string): boolean;
38
+ export {};
39
+ //# sourceMappingURL=slash-commands.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slash-commands.d.ts","sourceRoot":"","sources":["../slash-commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,KAAK,EACX,uBAAuB,EACvB,2BAA2B,EAC3B,MAAM,YAAY,CAAC;AAKpB,KAAK,gBAAgB,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;AAE7D,UAAU,YAAY;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAC/B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,6DAA6D;IAC7D,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAChC,OAAO,EAAE,CACR,WAAW,EAAE,2BAA2B,EACxC,OAAO,EAAE,aAAa,KAClB,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,YAAY,CAAC,EAAE,CAAC,WAAW,EAAE,uBAAuB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACvE;AAED,oFAAoF;AACpF,MAAM,WAAW,mBAAmB;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CACf;AAED,UAAU,kBAAkB;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC;IACpE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACjD,YAAY,CAAC,EAAE,OAAO,CAAC;CACvB;AAmZD,wBAAsB,qBAAqB,CAC1C,OAAO,EAAE,aAAa,GACpB,OAAO,CAAC,IAAI,CAAC,CAmBf;AAED,wBAAsB,kBAAkB,CACvC,WAAW,EAAE,2BAA2B,EACxC,OAAO,EAAE,aAAa,EACtB,OAAO,CAAC,EAAE,mBAAmB,GAC3B,OAAO,CAAC,IAAI,CAAC,CA2Gf;AAED,wBAAsB,kBAAkB,CACvC,WAAW,EAAE,uBAAuB,GAClC,OAAO,CAAC,IAAI,CAAC,CAgBf;AAED,wBAAgB,qBAAqB,IAAI,WAAW,CAAC,MAAM,EAAE,YAAY,CAAC,CAEzE;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI,CAEtD;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEnD"}
@@ -0,0 +1,25 @@
1
+ import type { Content } from "@elizaos/core";
2
+ import type { Message as DiscordMessage } from "discord.js";
3
+ export type DiscordStalenessBehavior = "tag" | "skip" | "ignore";
4
+ export interface DiscordStalenessConfig {
5
+ enabled: boolean;
6
+ behavior: DiscordStalenessBehavior;
7
+ threshold: number;
8
+ }
9
+ export declare function getDiscordStalenessConfig(getSetting: (key: string) => unknown): DiscordStalenessConfig;
10
+ export declare function recordDiscordChannelMessageSeen(owner: object | undefined, channelId: string | undefined, messageId?: string): number;
11
+ export declare function getDiscordChannelMessageSequence(owner: object | undefined, channelId: string | undefined): number;
12
+ export interface DiscordStalenessDecision {
13
+ shouldSend: boolean;
14
+ stale: boolean;
15
+ messagesSinceTurnStart: number;
16
+ behavior: DiscordStalenessBehavior;
17
+ }
18
+ export declare function applyDiscordStalenessGuard(options: {
19
+ config: DiscordStalenessConfig;
20
+ owner: object | undefined;
21
+ message: DiscordMessage;
22
+ startSequence: number;
23
+ content: Content;
24
+ }): DiscordStalenessDecision;
25
+ //# sourceMappingURL=staleness.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"staleness.d.ts","sourceRoot":"","sources":["../staleness.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5D,MAAM,MAAM,wBAAwB,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEjE,MAAM,WAAW,sBAAsB;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,wBAAwB,CAAC;IACnC,SAAS,EAAE,MAAM,CAAC;CAClB;AAsCD,wBAAgB,yBAAyB,CACxC,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,GAClC,sBAAsB,CASxB;AAED,wBAAgB,+BAA+B,CAC9C,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,SAAS,CAAC,EAAE,MAAM,GAChB,MAAM,CAgBR;AAED,wBAAgB,gCAAgC,CAC/C,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,SAAS,EAAE,MAAM,GAAG,SAAS,GAC3B,MAAM,CAKR;AAED,MAAM,WAAW,wBAAwB;IACxC,UAAU,EAAE,OAAO,CAAC;IACpB,KAAK,EAAE,OAAO,CAAC;IACf,sBAAsB,EAAE,MAAM,CAAC;IAC/B,QAAQ,EAAE,wBAAwB,CAAC;CACnC;AAED,wBAAgB,0BAA0B,CAAC,OAAO,EAAE;IACnD,MAAM,EAAE,sBAAsB,CAAC;IAC/B,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,OAAO,EAAE,cAAc,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;CACjB,GAAG,wBAAwB,CAkD3B"}