@elizaos/plugin-discord 2.0.0-alpha.9 → 2.0.0-beta.2
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/LICENSE +21 -0
- package/README.md +532 -0
- package/dist/account-client-pool.d.ts +35 -0
- package/dist/account-client-pool.d.ts.map +1 -0
- package/dist/accounts.d.ts.map +1 -1
- package/dist/actions/actionResultSemantics.d.ts +9 -0
- package/dist/actions/actionResultSemantics.d.ts.map +1 -0
- package/dist/actions/setup-credentials.d.ts +25 -0
- package/dist/actions/setup-credentials.d.ts.map +1 -0
- package/dist/addressing.d.ts +15 -0
- package/dist/addressing.d.ts.map +1 -0
- package/dist/allowlist.d.ts.map +1 -1
- package/dist/attachments.d.ts +1 -0
- package/dist/attachments.d.ts.map +1 -1
- package/dist/auto-enable.d.ts +4 -0
- package/dist/auto-enable.d.ts.map +1 -0
- package/dist/banner.d.ts.map +1 -1
- package/dist/compat.d.ts +4 -3
- package/dist/compat.d.ts.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/connector-account-provider.d.ts +26 -0
- package/dist/connector-account-provider.d.ts.map +1 -0
- package/dist/debouncer.d.ts +28 -0
- package/dist/debouncer.d.ts.map +1 -0
- package/dist/discord-avatar-cache.d.ts +10 -0
- package/dist/discord-avatar-cache.d.ts.map +1 -0
- package/dist/discord-commands.d.ts +16 -0
- package/dist/discord-commands.d.ts.map +1 -0
- package/dist/discord-events.d.ts +56 -0
- package/dist/discord-events.d.ts.map +1 -0
- package/dist/discord-history.d.ts +56 -0
- package/dist/discord-history.d.ts.map +1 -0
- package/dist/discord-interactions.d.ts +47 -0
- package/dist/discord-interactions.d.ts.map +1 -0
- package/dist/discord-local-service.d.ts +94 -0
- package/dist/discord-local-service.d.ts.map +1 -0
- package/dist/discord-profiles.d.ts +26 -0
- package/dist/discord-profiles.d.ts.map +1 -0
- package/dist/discord-reactions.d.ts +30 -0
- package/dist/discord-reactions.d.ts.map +1 -0
- package/dist/draft-chunking.d.ts +9 -0
- package/dist/draft-chunking.d.ts.map +1 -0
- package/dist/draft-stream.d.ts +23 -0
- package/dist/draft-stream.d.ts.map +1 -0
- package/dist/environment.d.ts +1 -0
- package/dist/environment.d.ts.map +1 -1
- package/dist/generated/specs/spec-helpers.d.ts +4 -17
- package/dist/generated/specs/spec-helpers.d.ts.map +1 -1
- package/dist/generated/specs/specs.d.ts +13 -48
- package/dist/generated/specs/specs.d.ts.map +1 -1
- package/dist/identity.d.ts +8 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/inbound-envelope.d.ts +8 -0
- package/dist/inbound-envelope.d.ts.map +1 -0
- package/dist/index.browser.d.ts.map +1 -1
- package/dist/index.d.ts +22 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10171 -10073
- package/dist/index.js.map +49 -125
- package/dist/message-coalesce.d.ts +31 -0
- package/dist/message-coalesce.d.ts.map +1 -0
- package/dist/messages.d.ts +13 -2
- package/dist/messages.d.ts.map +1 -1
- package/dist/messaging.d.ts.map +1 -1
- package/dist/native-commands.d.ts.map +1 -1
- package/dist/owner-pairing-service.d.ts +73 -0
- package/dist/owner-pairing-service.d.ts.map +1 -0
- package/dist/permissionEvents.d.ts.map +1 -1
- package/dist/permissions.d.ts.map +1 -1
- package/dist/profileSync.d.ts +8 -0
- package/dist/profileSync.d.ts.map +1 -0
- package/dist/reasoning-tags.d.ts +2 -0
- package/dist/reasoning-tags.d.ts.map +1 -0
- package/dist/service.d.ts +156 -261
- package/dist/service.d.ts.map +1 -1
- package/dist/setup-routes.d.ts +23 -0
- package/dist/setup-routes.d.ts.map +1 -0
- package/dist/slash-commands.d.ts +39 -0
- package/dist/slash-commands.d.ts.map +1 -0
- package/dist/staleness.d.ts +25 -0
- package/dist/staleness.d.ts.map +1 -0
- package/dist/status-reactions.d.ts +11 -0
- package/dist/status-reactions.d.ts.map +1 -0
- package/dist/tests.d.ts.map +1 -1
- package/dist/types.d.ts +27 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/typing.d.ts +7 -0
- package/dist/typing.d.ts.map +1 -0
- package/dist/user-account-scraper/discord-browser-scraper.d.ts +118 -0
- package/dist/user-account-scraper/discord-browser-scraper.d.ts.map +1 -0
- package/dist/user-account-scraper/discord-desktop-cdp.d.ts +33 -0
- package/dist/user-account-scraper/discord-desktop-cdp.d.ts.map +1 -0
- package/dist/user-account-scraper/index.d.ts +15 -0
- package/dist/user-account-scraper/index.d.ts.map +1 -0
- package/dist/user-account-scraper/service.d.ts +92 -0
- package/dist/user-account-scraper/service.d.ts.map +1 -0
- package/dist/utils.d.ts +11 -4
- package/dist/utils.d.ts.map +1 -1
- package/dist/vitest.config.d.ts +3 -0
- package/dist/vitest.config.d.ts.map +1 -0
- package/dist/voice.d.ts +8 -3
- package/dist/voice.d.ts.map +1 -1
- package/package.json +23 -21
- package/dist/actions/chatWithAttachments.d.ts +0 -4
- package/dist/actions/chatWithAttachments.d.ts.map +0 -1
- package/dist/actions/createPoll.d.ts +0 -4
- package/dist/actions/createPoll.d.ts.map +0 -1
- package/dist/actions/deleteMessage.d.ts +0 -4
- package/dist/actions/deleteMessage.d.ts.map +0 -1
- package/dist/actions/downloadMedia.d.ts +0 -4
- package/dist/actions/downloadMedia.d.ts.map +0 -1
- package/dist/actions/editMessage.d.ts +0 -4
- package/dist/actions/editMessage.d.ts.map +0 -1
- package/dist/actions/getUserInfo.d.ts +0 -4
- package/dist/actions/getUserInfo.d.ts.map +0 -1
- package/dist/actions/joinChannel.d.ts +0 -4
- package/dist/actions/joinChannel.d.ts.map +0 -1
- package/dist/actions/leaveChannel.d.ts +0 -4
- package/dist/actions/leaveChannel.d.ts.map +0 -1
- package/dist/actions/listChannels.d.ts +0 -4
- package/dist/actions/listChannels.d.ts.map +0 -1
- package/dist/actions/pinMessage.d.ts +0 -4
- package/dist/actions/pinMessage.d.ts.map +0 -1
- package/dist/actions/reactToMessage.d.ts +0 -4
- package/dist/actions/reactToMessage.d.ts.map +0 -1
- package/dist/actions/readChannel.d.ts +0 -4
- package/dist/actions/readChannel.d.ts.map +0 -1
- package/dist/actions/searchMessages.d.ts +0 -4
- package/dist/actions/searchMessages.d.ts.map +0 -1
- package/dist/actions/sendDM.d.ts +0 -4
- package/dist/actions/sendDM.d.ts.map +0 -1
- package/dist/actions/sendMessage.d.ts +0 -4
- package/dist/actions/sendMessage.d.ts.map +0 -1
- package/dist/actions/serverInfo.d.ts +0 -4
- package/dist/actions/serverInfo.d.ts.map +0 -1
- package/dist/actions/summarizeConversation.d.ts +0 -4
- package/dist/actions/summarizeConversation.d.ts.map +0 -1
- package/dist/actions/transcribeMedia.d.ts +0 -4
- package/dist/actions/transcribeMedia.d.ts.map +0 -1
- package/dist/actions/unpinMessage.d.ts +0 -4
- package/dist/actions/unpinMessage.d.ts.map +0 -1
- package/dist/generated/prompts/typescript/prompts.d.ts +0 -44
- package/dist/generated/prompts/typescript/prompts.d.ts.map +0 -1
- package/dist/providers/channelState.d.ts +0 -14
- package/dist/providers/channelState.d.ts.map +0 -1
- package/dist/providers/guildInfo.d.ts +0 -15
- package/dist/providers/guildInfo.d.ts.map +0 -1
- package/dist/providers/voiceState.d.ts +0 -12
- 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 {
|
|
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 {
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
*
|
|
329
|
-
|
|
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
|
-
|
|
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
|
-
*
|
|
334
|
-
*
|
|
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
|
-
|
|
260
|
+
resolveDiscordEntityId(userId: string): UUID;
|
|
337
261
|
/**
|
|
338
|
-
*
|
|
339
|
-
* @private
|
|
262
|
+
* Handles reaction addition. Delegates to extracted module.
|
|
340
263
|
*/
|
|
341
|
-
|
|
264
|
+
handleReactionAdd(reaction: MessageReaction | PartialMessageReaction, user: User | PartialUser): Promise<void>;
|
|
265
|
+
private handleReactionAddForAccount;
|
|
342
266
|
/**
|
|
343
|
-
*
|
|
344
|
-
* @private
|
|
267
|
+
* Handles reaction removal. Delegates to extracted module.
|
|
345
268
|
*/
|
|
346
|
-
|
|
269
|
+
handleReactionRemove(reaction: MessageReaction | PartialMessageReaction, user: User | PartialUser): Promise<void>;
|
|
270
|
+
private handleReactionRemoveForAccount;
|
|
347
271
|
/**
|
|
348
|
-
*
|
|
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
|
-
|
|
274
|
+
handleGuildCreate(guild: Guild): Promise<void>;
|
|
275
|
+
private handleGuildCreateForAccount;
|
|
362
276
|
/**
|
|
363
|
-
*
|
|
364
|
-
*
|
|
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
|
-
|
|
375
|
-
|
|
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
|
-
*
|
|
382
|
-
*
|
|
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
|
-
|
|
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
|
|
297
|
+
export {};
|
|
403
298
|
//# sourceMappingURL=service.d.ts.map
|
package/dist/service.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../service.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../service.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,WAAW,EACX,KAAK,SAAS,EACd,KAAK,OAAO,EAIZ,KAAK,aAAa,EAClB,KAAK,KAAK,EACV,KAAK,MAAM,EAEX,KAAK,2BAA2B,EAChC,KAAK,4BAA4B,EACjC,KAAK,sBAAsB,EAC3B,KAAK,2BAA2B,EAChC,KAAK,IAAI,EACT,OAAO,EAGP,KAAK,UAAU,EACf,KAAK,IAAI,EACT,KAAK,KAAK,EACV,MAAM,eAAe,CAAC;AACvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,EAEN,KAAK,OAAO,EAGZ,MAAM,IAAI,eAAe,EAGzB,KAAK,KAAK,EACV,KAAK,WAAW,EAEhB,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAE3B,KAAK,WAAW,EAGhB,KAAK,IAAI,EACT,MAAM,YAAY,CAAC;AAYpB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAkC/C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAEX,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,MAAM,SAAS,CAAC;AAQjB,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAmCvC,KAAK,4BAA4B,GAAG;IACnC,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC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nD;;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"}
|