@elizaos/plugin-discord 2.0.0-alpha.5 → 2.0.0-alpha.537
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 +549 -0
- package/dist/accounts.d.ts +164 -0
- package/dist/accounts.d.ts.map +1 -0
- package/dist/actions/actionResultSemantics.d.ts +9 -0
- package/dist/actions/actionResultSemantics.d.ts.map +1 -0
- package/dist/actions/chatWithAttachments.d.ts +4 -0
- package/dist/actions/chatWithAttachments.d.ts.map +1 -0
- package/dist/actions/createPoll.d.ts +4 -0
- package/dist/actions/createPoll.d.ts.map +1 -0
- package/dist/actions/deleteMessage.d.ts +4 -0
- package/dist/actions/deleteMessage.d.ts.map +1 -0
- package/dist/actions/downloadMedia.d.ts +4 -0
- package/dist/actions/downloadMedia.d.ts.map +1 -0
- package/dist/actions/editMessage.d.ts +4 -0
- package/dist/actions/editMessage.d.ts.map +1 -0
- package/dist/actions/getUserInfo.d.ts +4 -0
- package/dist/actions/getUserInfo.d.ts.map +1 -0
- package/dist/actions/joinChannel.d.ts +4 -0
- package/dist/actions/joinChannel.d.ts.map +1 -0
- package/dist/actions/leaveChannel.d.ts +4 -0
- package/dist/actions/leaveChannel.d.ts.map +1 -0
- package/dist/actions/listChannels.d.ts +4 -0
- package/dist/actions/listChannels.d.ts.map +1 -0
- package/dist/actions/pinMessage.d.ts +4 -0
- package/dist/actions/pinMessage.d.ts.map +1 -0
- package/dist/actions/reactToMessage.d.ts +4 -0
- package/dist/actions/reactToMessage.d.ts.map +1 -0
- package/dist/actions/readChannel.d.ts +4 -0
- package/dist/actions/readChannel.d.ts.map +1 -0
- package/dist/actions/searchMessages.d.ts +4 -0
- package/dist/actions/searchMessages.d.ts.map +1 -0
- package/dist/actions/sendDM.d.ts +4 -0
- package/dist/actions/sendDM.d.ts.map +1 -0
- package/dist/actions/sendMessage.d.ts +4 -0
- package/dist/actions/sendMessage.d.ts.map +1 -0
- package/dist/actions/serverInfo.d.ts +4 -0
- package/dist/actions/serverInfo.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/actions/summarizeConversation.d.ts +4 -0
- package/dist/actions/summarizeConversation.d.ts.map +1 -0
- package/dist/actions/transcribeMedia.d.ts +4 -0
- package/dist/actions/transcribeMedia.d.ts.map +1 -0
- package/dist/actions/unpinMessage.d.ts +4 -0
- package/dist/actions/unpinMessage.d.ts.map +1 -0
- package/dist/allowlist.d.ts +198 -0
- package/dist/allowlist.d.ts.map +1 -0
- package/dist/attachments.d.ts +93 -0
- package/dist/attachments.d.ts.map +1 -0
- package/dist/banner.d.ts +39 -0
- package/dist/banner.d.ts.map +1 -0
- package/dist/compat.d.ts +57 -0
- package/dist/compat.d.ts.map +1 -0
- package/dist/config.d.ts +156 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/debouncer.d.ts +25 -0
- package/dist/debouncer.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 +54 -0
- package/dist/discord-events.d.ts.map +1 -0
- package/dist/discord-history.d.ts +49 -0
- package/dist/discord-history.d.ts.map +1 -0
- package/dist/discord-interactions.d.ts +45 -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-reactions.d.ts +29 -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 +23 -0
- package/dist/environment.d.ts.map +1 -0
- package/dist/generated/prompts/typescript/prompts.d.ts +44 -0
- package/dist/generated/prompts/typescript/prompts.d.ts.map +1 -0
- package/dist/generated/specs/spec-helpers.d.ts +49 -0
- package/dist/generated/specs/spec-helpers.d.ts.map +1 -0
- package/dist/generated/specs/specs.d.ts +90 -0
- package/dist/generated/specs/specs.d.ts.map +1 -0
- 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 +34 -0
- package/dist/index.browser.d.ts.map +1 -0
- package/dist/index.d.ts +19 -2
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15379 -0
- package/dist/index.js.map +72 -0
- package/dist/messages.d.ts +62 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messaging.d.ts +129 -0
- package/dist/messaging.d.ts.map +1 -0
- package/dist/native-commands.d.ts +142 -0
- package/dist/native-commands.d.ts.map +1 -0
- package/dist/owner-pairing-service.d.ts +73 -0
- package/dist/owner-pairing-service.d.ts.map +1 -0
- package/dist/permissionEvents.d.ts +42 -0
- package/dist/permissionEvents.d.ts.map +1 -0
- package/dist/permissions.d.ts +36 -0
- package/dist/permissions.d.ts.map +1 -0
- package/dist/profileSync.d.ts +8 -0
- package/dist/profileSync.d.ts.map +1 -0
- package/dist/providers/channelState.d.ts +14 -0
- package/dist/providers/channelState.d.ts.map +1 -0
- package/dist/providers/guildInfo.d.ts +15 -0
- package/dist/providers/guildInfo.d.ts.map +1 -0
- package/dist/providers/voiceState.d.ts +12 -0
- package/dist/providers/voiceState.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 +207 -0
- package/dist/service.d.ts.map +1 -0
- 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/status-reactions.d.ts +11 -0
- package/dist/status-reactions.d.ts.map +1 -0
- package/dist/test-setup.d.ts +1 -0
- package/dist/test-setup.d.ts.map +1 -0
- package/dist/tests.d.ts +123 -0
- package/dist/tests.d.ts.map +1 -0
- package/dist/types.d.ts +329 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/typing.d.ts +7 -0
- package/dist/typing.d.ts.map +1 -0
- package/dist/utils.d.ts +48 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/vitest.config.d.ts +3 -0
- package/dist/vitest.config.d.ts.map +1 -0
- package/dist/voice.d.ts +234 -0
- package/dist/voice.d.ts.map +1 -0
- package/package.json +25 -20
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { type Media } from "@elizaos/core";
|
|
2
|
+
import { type Message as DiscordMessage } from "discord.js";
|
|
3
|
+
import type { ICompatRuntime } from "./compat";
|
|
4
|
+
import type { IDiscordService } from "./types";
|
|
5
|
+
/**
|
|
6
|
+
* Class representing a Message Manager for handling Discord messages.
|
|
7
|
+
*/
|
|
8
|
+
export declare class MessageManager {
|
|
9
|
+
private client;
|
|
10
|
+
private runtime;
|
|
11
|
+
private attachmentManager;
|
|
12
|
+
private getChannelType;
|
|
13
|
+
private discordSettings;
|
|
14
|
+
private discordService;
|
|
15
|
+
private statusReactionScope;
|
|
16
|
+
private envelopeEnabled;
|
|
17
|
+
private draftStreamingEnabled;
|
|
18
|
+
private recentlyProcessedMessageIds;
|
|
19
|
+
private static readonly PROCESSED_MESSAGE_TTL_MS;
|
|
20
|
+
/**
|
|
21
|
+
* Constructor for a new instance of MessageManager.
|
|
22
|
+
* @param {IDiscordService} discordService - The Discord service instance.
|
|
23
|
+
* @param {ICompatRuntime} runtime - The agent runtime instance (with cross-core compat).
|
|
24
|
+
* @throws {Error} If the Discord client is not initialized
|
|
25
|
+
*/
|
|
26
|
+
constructor(discordService: IDiscordService, runtime: ICompatRuntime);
|
|
27
|
+
/**
|
|
28
|
+
* Check DM access based on the configured dmPolicy.
|
|
29
|
+
*
|
|
30
|
+
* @param message - The Discord DM message
|
|
31
|
+
* @returns Access check result with allowed status and optional reply message
|
|
32
|
+
*/
|
|
33
|
+
private checkDmAccess;
|
|
34
|
+
private persistInboundMemory;
|
|
35
|
+
private markMessageAsProcessing;
|
|
36
|
+
/**
|
|
37
|
+
* Handles incoming Discord messages and processes them accordingly.
|
|
38
|
+
*
|
|
39
|
+
* @param {DiscordMessage} message - The Discord message to be handled
|
|
40
|
+
*/
|
|
41
|
+
handleMessage(message: DiscordMessage): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Processes the message content, mentions, code blocks, attachments, and URLs to generate
|
|
44
|
+
* processed content and media attachments.
|
|
45
|
+
*
|
|
46
|
+
* @param {DiscordMessage} message The message to process
|
|
47
|
+
* @returns {Promise<{ processedContent: string; attachments: Media[] }>} Processed content and media attachments
|
|
48
|
+
*/
|
|
49
|
+
processMessage(message: DiscordMessage): Promise<{
|
|
50
|
+
processedContent: string;
|
|
51
|
+
attachments: Media[];
|
|
52
|
+
}>;
|
|
53
|
+
/**
|
|
54
|
+
* Asynchronously fetches the bot's username and discriminator from Discord API.
|
|
55
|
+
*
|
|
56
|
+
* @param {string} botToken The token of the bot to authenticate the request
|
|
57
|
+
* @returns {Promise<string>} A promise that resolves with the bot's username and discriminator
|
|
58
|
+
* @throws {Error} If there is an error while fetching the bot details
|
|
59
|
+
*/
|
|
60
|
+
fetchBotName(botToken: string): Promise<string>;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAUN,KAAK,KAAK,EAMV,MAAM,eAAe,CAAC;AACvB,OAAO,EAKN,KAAK,OAAO,IAAI,cAAc,EAE9B,MAAM,YAAY,CAAC;AAKpB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAW/C,OAAO,KAAK,EAAmB,eAAe,EAAE,MAAM,SAAS,CAAC;AAgDhE;;GAEG;AAEH,qBAAa,cAAc;IAC1B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,iBAAiB,CAAoB;IAC7C,OAAO,CAAC,cAAc,CAA6C;IACnE,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,cAAc,CAAkB;IACxC,OAAO,CAAC,mBAAmB,CAAsB;IACjD,OAAO,CAAC,eAAe,CAAU;IACjC,OAAO,CAAC,qBAAqB,CAAU;IACvC,OAAO,CAAC,2BAA2B,CAA6B;IAChE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,wBAAwB,CAAiB;IACjE;;;;;OAKG;gBACS,cAAc,EAAE,eAAe,EAAE,OAAO,EAAE,cAAc;IAyCpE;;;;;OAKG;YACW,aAAa;YAkGb,oBAAoB;IAalC,OAAO,CAAC,uBAAuB;IAgB/B;;;;OAIG;IACG,aAAa,CAAC,OAAO,EAAE,cAAc;IAwuB3C;;;;;;OAMG;IACG,cAAc,CACnB,OAAO,EAAE,cAAc,GACrB,OAAO,CAAC;QAAE,gBAAgB,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,KAAK,EAAE,CAAA;KAAE,CAAC;IA8J9D;;;;;;OAMG;IAEG,YAAY,CAAC,QAAQ,EAAE,MAAM;CAoBnC"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import type { Guild, MessageReaction } from "discord.js";
|
|
2
|
+
/**
|
|
3
|
+
* Options for chunking Discord text
|
|
4
|
+
*/
|
|
5
|
+
export interface ChunkDiscordTextOpts {
|
|
6
|
+
/** Max characters per Discord message. Default: 2000. */
|
|
7
|
+
maxChars?: number;
|
|
8
|
+
/**
|
|
9
|
+
* Soft max line count per message. Default: 17.
|
|
10
|
+
* Discord clients can clip/collapse very tall messages in the UI.
|
|
11
|
+
*/
|
|
12
|
+
maxLines?: number;
|
|
13
|
+
/** Chunking mode: "length" (default) or "newline" */
|
|
14
|
+
chunkMode?: "length" | "newline";
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Chunks outbound Discord text by both character count and (soft) line count,
|
|
18
|
+
* while keeping fenced code blocks balanced across chunks.
|
|
19
|
+
*/
|
|
20
|
+
export declare function chunkDiscordText(text: string, opts?: ChunkDiscordTextOpts): string[];
|
|
21
|
+
/**
|
|
22
|
+
* Chunks Discord text with configurable chunking mode
|
|
23
|
+
*/
|
|
24
|
+
export declare function chunkDiscordTextWithMode(text: string, opts?: ChunkDiscordTextOpts): string[];
|
|
25
|
+
/**
|
|
26
|
+
* Resolves the system location string for logging/display
|
|
27
|
+
*/
|
|
28
|
+
export declare function resolveDiscordSystemLocation(params: {
|
|
29
|
+
isDirectMessage: boolean;
|
|
30
|
+
isGroupDm: boolean;
|
|
31
|
+
guild?: Guild | null;
|
|
32
|
+
channelName: string;
|
|
33
|
+
}): string;
|
|
34
|
+
/**
|
|
35
|
+
* Formats a Discord reaction emoji for display
|
|
36
|
+
*/
|
|
37
|
+
export declare function formatDiscordReactionEmoji(emoji: {
|
|
38
|
+
id?: string | null;
|
|
39
|
+
name?: string | null;
|
|
40
|
+
}): string;
|
|
41
|
+
/**
|
|
42
|
+
* Formats a Discord reaction emoji from a MessageReaction
|
|
43
|
+
*/
|
|
44
|
+
export declare function formatMessageReactionEmoji(reaction: MessageReaction): string;
|
|
45
|
+
/**
|
|
46
|
+
* Formats a Discord user mention
|
|
47
|
+
*/
|
|
48
|
+
export declare function formatDiscordUserMention(userId: string): string;
|
|
49
|
+
/**
|
|
50
|
+
* Formats a Discord channel mention
|
|
51
|
+
*/
|
|
52
|
+
export declare function formatDiscordChannelMention(channelId: string): string;
|
|
53
|
+
/**
|
|
54
|
+
* Formats a Discord role mention
|
|
55
|
+
*/
|
|
56
|
+
export declare function formatDiscordRoleMention(roleId: string): string;
|
|
57
|
+
/**
|
|
58
|
+
* Extracts user ID from a mention string
|
|
59
|
+
*/
|
|
60
|
+
export declare function extractUserIdFromMention(mention: string): string | null;
|
|
61
|
+
/**
|
|
62
|
+
* Extracts channel ID from a mention string
|
|
63
|
+
*/
|
|
64
|
+
export declare function extractChannelIdFromMention(mention: string): string | null;
|
|
65
|
+
/**
|
|
66
|
+
* Extracts role ID from a mention string
|
|
67
|
+
*/
|
|
68
|
+
export declare function extractRoleIdFromMention(mention: string): string | null;
|
|
69
|
+
/**
|
|
70
|
+
* Resolves a timestamp string to milliseconds
|
|
71
|
+
*/
|
|
72
|
+
export declare function resolveTimestampMs(timestamp?: string | null): number | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* Formats a timestamp for Discord (Discord timestamp format)
|
|
75
|
+
*/
|
|
76
|
+
export declare function formatDiscordTimestamp(timestamp: Date | number, format?: "t" | "T" | "d" | "D" | "f" | "F" | "R"): string;
|
|
77
|
+
/**
|
|
78
|
+
* Strips Discord formatting from text
|
|
79
|
+
*/
|
|
80
|
+
export declare function stripDiscordFormatting(text: string): string;
|
|
81
|
+
/**
|
|
82
|
+
* Escapes special Discord markdown characters
|
|
83
|
+
*/
|
|
84
|
+
export declare function escapeDiscordMarkdown(text: string): string;
|
|
85
|
+
/**
|
|
86
|
+
* Truncates text to a maximum length with an ellipsis
|
|
87
|
+
*/
|
|
88
|
+
export declare function truncateText(text: string, maxLength: number, ellipsis?: string): string;
|
|
89
|
+
/**
|
|
90
|
+
* Truncates text at a UTF-16 boundary safely
|
|
91
|
+
*/
|
|
92
|
+
export declare function truncateUtf16Safe(text: string, maxLength: number, ellipsis?: string): string;
|
|
93
|
+
/**
|
|
94
|
+
* Checks if a message mentions a specific user
|
|
95
|
+
*/
|
|
96
|
+
export declare function messageContainsMention(text: string, userId: string): boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Extracts all user mentions from a message
|
|
99
|
+
*/
|
|
100
|
+
export declare function extractAllUserMentions(text: string): string[];
|
|
101
|
+
/**
|
|
102
|
+
* Extracts all channel mentions from a message
|
|
103
|
+
*/
|
|
104
|
+
export declare function extractAllChannelMentions(text: string): string[];
|
|
105
|
+
/**
|
|
106
|
+
* Extracts all role mentions from a message
|
|
107
|
+
*/
|
|
108
|
+
export declare function extractAllRoleMentions(text: string): string[];
|
|
109
|
+
/**
|
|
110
|
+
* Sanitizes a thread name for Discord (max 100 chars, no invalid chars)
|
|
111
|
+
*/
|
|
112
|
+
export declare function sanitizeThreadName(name: string): string;
|
|
113
|
+
/**
|
|
114
|
+
* Builds a message link URL
|
|
115
|
+
*/
|
|
116
|
+
export declare function buildMessageLink(guildId: string, channelId: string, messageId: string): string;
|
|
117
|
+
/**
|
|
118
|
+
* Builds a channel link URL
|
|
119
|
+
*/
|
|
120
|
+
export declare function buildChannelLink(guildId: string, channelId: string): string;
|
|
121
|
+
/**
|
|
122
|
+
* Parses a Discord message link URL
|
|
123
|
+
*/
|
|
124
|
+
export declare function parseMessageLink(url: string): {
|
|
125
|
+
guildId: string;
|
|
126
|
+
channelId: string;
|
|
127
|
+
messageId: string;
|
|
128
|
+
} | null;
|
|
129
|
+
//# sourceMappingURL=messaging.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messaging.d.ts","sourceRoot":"","sources":["../messaging.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC,yDAAyD;IACzD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qDAAqD;IACrD,SAAS,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;CACjC;AAgJD;;;GAGG;AACH,wBAAgB,gBAAgB,CAC/B,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE,oBAAyB,GAC7B,MAAM,EAAE,CAmHV;AA0BD;;GAEG;AACH,wBAAgB,wBAAwB,CACvC,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE,oBAAyB,GAC7B,MAAM,EAAE,CAuBV;AAED;;GA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}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { ApplicationCommandOptionType, ButtonStyle, type RESTPostAPIChatInputApplicationCommandsJSONBody } from "discord-api-types/v10";
|
|
2
|
+
/**
|
|
3
|
+
* Command argument definition
|
|
4
|
+
*/
|
|
5
|
+
export interface CommandArgDefinition {
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
type: "string" | "number" | "boolean";
|
|
9
|
+
required?: boolean;
|
|
10
|
+
choices?: Array<{
|
|
11
|
+
label: string;
|
|
12
|
+
value: string;
|
|
13
|
+
}>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Native command specification
|
|
17
|
+
*/
|
|
18
|
+
export interface NativeCommandSpec {
|
|
19
|
+
name: string;
|
|
20
|
+
description: string;
|
|
21
|
+
acceptsArgs?: boolean;
|
|
22
|
+
args?: CommandArgDefinition[];
|
|
23
|
+
ephemeralDefault?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Command argument values
|
|
27
|
+
*/
|
|
28
|
+
export type CommandArgValues = Record<string, string | number | boolean>;
|
|
29
|
+
/**
|
|
30
|
+
* Parsed command arguments
|
|
31
|
+
*/
|
|
32
|
+
export interface CommandArgs {
|
|
33
|
+
values: CommandArgValues;
|
|
34
|
+
raw?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Result of building command options
|
|
38
|
+
*/
|
|
39
|
+
export interface BuiltCommandOption {
|
|
40
|
+
name: string;
|
|
41
|
+
description: string;
|
|
42
|
+
type: ApplicationCommandOptionType;
|
|
43
|
+
required?: boolean;
|
|
44
|
+
choices?: Array<{
|
|
45
|
+
name: string;
|
|
46
|
+
value: string | number;
|
|
47
|
+
}>;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Button specification for argument menus
|
|
51
|
+
*/
|
|
52
|
+
export interface CommandArgButton {
|
|
53
|
+
label: string;
|
|
54
|
+
customId: string;
|
|
55
|
+
style: ButtonStyle;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Row of buttons for argument menus
|
|
59
|
+
*/
|
|
60
|
+
export interface CommandArgButtonRow {
|
|
61
|
+
buttons: CommandArgButton[];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Argument menu specification
|
|
65
|
+
*/
|
|
66
|
+
export interface CommandArgMenu {
|
|
67
|
+
content: string;
|
|
68
|
+
rows: CommandArgButtonRow[];
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Key for command argument custom IDs
|
|
72
|
+
*/
|
|
73
|
+
export declare const COMMAND_ARG_CUSTOM_ID_KEY = "cmdarg";
|
|
74
|
+
/**
|
|
75
|
+
* Builds Discord command options from argument definitions
|
|
76
|
+
*/
|
|
77
|
+
export declare function buildDiscordCommandOptions(args?: CommandArgDefinition[]): BuiltCommandOption[] | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* Builds a complete Discord slash command JSON body
|
|
80
|
+
*/
|
|
81
|
+
export declare function buildDiscordSlashCommand(spec: NativeCommandSpec): RESTPostAPIChatInputApplicationCommandsJSONBody;
|
|
82
|
+
/**
|
|
83
|
+
* Encodes a command argument value for use in custom IDs
|
|
84
|
+
*/
|
|
85
|
+
export declare function encodeCommandArgValue(value: string): string;
|
|
86
|
+
/**
|
|
87
|
+
* Decodes a command argument value from a custom ID
|
|
88
|
+
*/
|
|
89
|
+
export declare function decodeCommandArgValue(value: string): string;
|
|
90
|
+
/**
|
|
91
|
+
* Builds a custom ID for a command argument button
|
|
92
|
+
*/
|
|
93
|
+
export declare function buildCommandArgCustomId(params: {
|
|
94
|
+
command: string;
|
|
95
|
+
arg: string;
|
|
96
|
+
value: string;
|
|
97
|
+
userId: string;
|
|
98
|
+
}): string;
|
|
99
|
+
/**
|
|
100
|
+
* Parses command argument data from a custom ID
|
|
101
|
+
*/
|
|
102
|
+
export declare function parseCommandArgCustomId(customId: string): {
|
|
103
|
+
command: string;
|
|
104
|
+
arg: string;
|
|
105
|
+
value: string;
|
|
106
|
+
userId: string;
|
|
107
|
+
} | null;
|
|
108
|
+
/**
|
|
109
|
+
* Builds an argument menu with buttons for command selection
|
|
110
|
+
*/
|
|
111
|
+
export declare function buildCommandArgMenu(params: {
|
|
112
|
+
commandName: string;
|
|
113
|
+
arg: CommandArgDefinition;
|
|
114
|
+
choices: Array<{
|
|
115
|
+
value: string;
|
|
116
|
+
label: string;
|
|
117
|
+
}>;
|
|
118
|
+
userId: string;
|
|
119
|
+
title?: string;
|
|
120
|
+
buttonsPerRow?: number;
|
|
121
|
+
}): CommandArgMenu;
|
|
122
|
+
/**
|
|
123
|
+
* Checks if an error is a Discord "Unknown Interaction" error
|
|
124
|
+
*/
|
|
125
|
+
export declare function isUnknownInteractionError(error: unknown): boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Safely executes a Discord interaction call, catching expired interaction errors
|
|
128
|
+
*/
|
|
129
|
+
export declare function safeInteractionCall<T>(fn: () => Promise<T>, onExpired?: () => void): Promise<T | null>;
|
|
130
|
+
/**
|
|
131
|
+
* Creates command arguments from a single value
|
|
132
|
+
*/
|
|
133
|
+
export declare function createCommandArgs(argName: string, value: string | number | boolean): CommandArgs;
|
|
134
|
+
/**
|
|
135
|
+
* Serializes command arguments to a string
|
|
136
|
+
*/
|
|
137
|
+
export declare function serializeCommandArgs(args?: CommandArgs): string;
|
|
138
|
+
/**
|
|
139
|
+
* Builds the full command text from arguments
|
|
140
|
+
*/
|
|
141
|
+
export declare function buildCommandText(commandName: string, args?: CommandArgs): string;
|
|
142
|
+
//# sourceMappingURL=native-commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-commands.d.ts","sourceRoot":"","sources":["../native-commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,4BAA4B,EAC5B,WAAW,EACX,KAAK,+CAA+C,EACpD,MAAM,uBAAuB,CAAC;AAE/B;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC,IAAI,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AAC;CACvB,GAAG,cAAc,CA6BjB;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CA0BjE;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,CAAC,EAC1C,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,SAAS,CAAC,EAAE,MAAM,IAAI,GACpB,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAUnB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAChC,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAC9B,WAAW,CAIb;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,CAQ/D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC/B,WAAW,EAAE,MAAM,EACnB,IAAI,CAAC,EAAE,WAAW,GAChB,MAAM,CAGR"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DiscordOwnerPairingService
|
|
3
|
+
*
|
|
4
|
+
* Implements the connector side of the owner-pairing flow for Discord:
|
|
5
|
+
* - `/eliza-pair <code>` slash command: relays a 6-digit pair code to the
|
|
6
|
+
* backend `verifyOwnerBindFromConnector` service and reports the result.
|
|
7
|
+
* - `sendOwnerLoginDmLink({ externalId, link })`: called by the backend's
|
|
8
|
+
* `/api/auth/login/owner/dm-link/request` handler to DM a login link to
|
|
9
|
+
* the Discord user identified by their snowflake ID.
|
|
10
|
+
*
|
|
11
|
+
* Hard rules:
|
|
12
|
+
* - Backend is the authority. The connector only relays; it never decides
|
|
13
|
+
* whether a binding succeeds.
|
|
14
|
+
* - Fail closed: if the backend service is unreachable, we reply with an
|
|
15
|
+
* explicit error message and do NOT silently succeed.
|
|
16
|
+
* - Per-user rate limit on `/eliza-pair` invocations: 5 attempts per minute.
|
|
17
|
+
* - DM-link sender never pre-fetches or auto-redeems the link.
|
|
18
|
+
* - Webhook signature verification: Discord slash-command payloads are
|
|
19
|
+
* verified by discord.js before reaching this handler (the library handles
|
|
20
|
+
* it for gateway-connected bots). No additional verification needed here.
|
|
21
|
+
*/
|
|
22
|
+
import { type IAgentRuntime, Service } from "@elizaos/core";
|
|
23
|
+
import type { ChatInputCommandInteraction } from "discord.js";
|
|
24
|
+
/** Service type string used by the backend to look up this service. */
|
|
25
|
+
export declare const DISCORD_OWNER_PAIRING_SERVICE_TYPE = "OWNER_PAIRING_DISCORD";
|
|
26
|
+
/**
|
|
27
|
+
* Clears all in-memory rate-limit state. Exposed for testing only.
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
export declare function _resetRateLimitStateForTesting(): void;
|
|
31
|
+
/**
|
|
32
|
+
* Handler for the `/eliza-pair <code>` slash command.
|
|
33
|
+
* Called by the Discord slash-command dispatcher after it has already
|
|
34
|
+
* applied cooldown and role checks. Exported for unit testing.
|
|
35
|
+
*/
|
|
36
|
+
export declare function handleElizaPairCommand(interaction: ChatInputCommandInteraction, runtime: IAgentRuntime): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Public service interface exposed via the runtime service registry.
|
|
39
|
+
* The backend's `owner-binding.ts` calls `sendOwnerLoginDmLink` when the
|
|
40
|
+
* user requests a DM login link via the dashboard.
|
|
41
|
+
*/
|
|
42
|
+
export interface DiscordOwnerPairingService {
|
|
43
|
+
/**
|
|
44
|
+
* DMs the Discord user identified by `externalId` (a Discord snowflake)
|
|
45
|
+
* with a login link. The link is presented as-is; this method never
|
|
46
|
+
* pre-fetches or auto-redeems it.
|
|
47
|
+
*
|
|
48
|
+
* Throws if the DM cannot be delivered (user has DMs closed, bot lacks
|
|
49
|
+
* permission, Discord API error). The caller is responsible for surfacing
|
|
50
|
+
* the error to the dashboard.
|
|
51
|
+
*/
|
|
52
|
+
sendOwnerLoginDmLink(params: {
|
|
53
|
+
externalId: string;
|
|
54
|
+
link: string;
|
|
55
|
+
}): Promise<void>;
|
|
56
|
+
}
|
|
57
|
+
export declare class DiscordOwnerPairingServiceImpl extends Service implements DiscordOwnerPairingService {
|
|
58
|
+
static serviceType: string;
|
|
59
|
+
capabilityDescription: string;
|
|
60
|
+
static start(runtime: IAgentRuntime): Promise<Service>;
|
|
61
|
+
stop(): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Registers the /eliza-pair slash command with the Discord plugin's
|
|
64
|
+
* slash-command dispatcher. Calling this multiple times is idempotent
|
|
65
|
+
* because `addCommand` overwrites existing entries by name.
|
|
66
|
+
*/
|
|
67
|
+
private registerPairCommand;
|
|
68
|
+
sendOwnerLoginDmLink(params: {
|
|
69
|
+
externalId: string;
|
|
70
|
+
link: string;
|
|
71
|
+
}): Promise<void>;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=owner-pairing-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"owner-pairing-service.d.ts","sourceRoot":"","sources":["../owner-pairing-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,KAAK,aAAa,EAAU,OAAO,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AAG9D,uEAAuE;AACvE,eAAO,MAAM,kCAAkC,0BAA0B,CAAC;AAmD1E;;;GAGG;AACH,wBAAgB,8BAA8B,IAAI,IAAI,CAErD;AAiDD;;;;GAIG;AACH,wBAAsB,sBAAsB,CAC3C,WAAW,EAAE,2BAA2B,EACxC,OAAO,EAAE,aAAa,GACpB,OAAO,CAAC,IAAI,CAAC,CAmIf;AAED;;;;GAIG;AACH,MAAM,WAAW,0BAA0B;IAC1C;;;;;;;;OAQG;IACH,oBAAoB,CAAC,MAAM,EAAE;QAC5B,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,EAAE,MAAM,CAAC;KACb,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAClB;AAED,qBAAa,8BACZ,SAAQ,OACR,YAAW,0BAA0B;IAErC,MAAM,CAAC,WAAW,SAAsC;IACxD,qBAAqB,SACoG;WAE5G,KAAK,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC;IAuBtD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAK3B;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;IAoBrB,oBAAoB,CAAC,MAAM,EAAE;QAClC,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,EAAE,MAAM,CAAC;KACb,GAAG,OAAO,CAAC,IAAI,CAAC;CAoDjB"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { IAgentRuntime } from "@elizaos/core";
|
|
2
|
+
import type { AuditLogEvent, Guild, GuildMember, PermissionOverwrites, Role } from "discord.js";
|
|
3
|
+
import type { AuditInfo, PermissionDiff } from "./types";
|
|
4
|
+
/**
|
|
5
|
+
* Permissions that indicate moderation/admin capabilities.
|
|
6
|
+
* Changes to these permissions are considered elevated and worth tracking.
|
|
7
|
+
*/
|
|
8
|
+
export declare const ELEVATED_PERMISSIONS: readonly ["Administrator", "ManageGuild", "ManageChannels", "ManageRoles", "KickMembers", "BanMembers", "ModerateMembers", "ManageMessages", "ManageWebhooks", "ManageNicknames", "MuteMembers", "DeafenMembers", "MoveMembers", "ManageEvents", "ManageThreads"];
|
|
9
|
+
/**
|
|
10
|
+
* Check if a role has any elevated (moderation/admin) permissions
|
|
11
|
+
*/
|
|
12
|
+
export declare function isElevatedRole(role: Role): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Check if an array of permission names contains any elevated permissions
|
|
15
|
+
*/
|
|
16
|
+
export declare function hasElevatedPermissions(permissions: string[]): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Fetch the most recent matching audit log entry for an action.
|
|
19
|
+
* Matches by target ID and filters to entries within 10 seconds.
|
|
20
|
+
* Returns null gracefully on errors (rate limits, missing permissions, etc.)
|
|
21
|
+
*/
|
|
22
|
+
export declare function fetchAuditEntry(guild: Guild, actionType: AuditLogEvent, target: string, runtime: IAgentRuntime): Promise<AuditInfo | null>;
|
|
23
|
+
/**
|
|
24
|
+
* Diff two permission overwrites and determine what changed.
|
|
25
|
+
* Returns the list of changes and the action type (CREATE/UPDATE/DELETE).
|
|
26
|
+
*/
|
|
27
|
+
export declare function diffOverwrites(oldOw: PermissionOverwrites | undefined | null, newOw: PermissionOverwrites | undefined | null): {
|
|
28
|
+
changes: PermissionDiff[];
|
|
29
|
+
action: "CREATE" | "UPDATE" | "DELETE";
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Diff two role permission sets and return what changed.
|
|
33
|
+
*/
|
|
34
|
+
export declare function diffRolePermissions(oldRole: Role, newRole: Role): PermissionDiff[];
|
|
35
|
+
/**
|
|
36
|
+
* Diff member roles to find added and removed roles.
|
|
37
|
+
*/
|
|
38
|
+
export declare function diffMemberRoles(oldMember: GuildMember, newMember: GuildMember): {
|
|
39
|
+
added: Role[];
|
|
40
|
+
removed: Role[];
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=permissionEvents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permissionEvents.d.ts","sourceRoot":"","sources":["../permissionEvents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EACX,aAAa,EACb,KAAK,EACL,WAAW,EACX,oBAAoB,EACpB,IAAI,EACJ,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAmB,MAAM,SAAS,CAAC;AAE1E;;;GAGG;AACH,eAAO,MAAM,oBAAoB,mQAgBvB,CAAC;AAEX;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAElD;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,OAAO,CAIrE;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CACpC,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,aAAa,EACzB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,aAAa,GACpB,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAuB3B;AA8CD;;;GAGG;AACH,wBAAgB,cAAc,CAC7B,KAAK,EAAE,oBAAoB,GAAG,SAAS,GAAG,IAAI,EAC9C,KAAK,EAAE,oBAAoB,GAAG,SAAS,GAAG,IAAI,GAC5C;IAAE,OAAO,EAAE,cAAc,EAAE,CAAC;IAAC,MAAM,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAA;CAAE,CAmCvE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAClC,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,IAAI,GACX,cAAc,EAAE,CAoBlB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC9B,SAAS,EAAE,WAAW,EACtB,SAAS,EAAE,WAAW,GACpB;IAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IAAC,OAAO,EAAE,IAAI,EAAE,CAAA;CAAE,CAQpC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export declare const PERMISSIONS_BASIC: bigint;
|
|
2
|
+
export declare const PERMISSIONS_BASIC_VOICE: bigint;
|
|
3
|
+
export declare const PERMISSIONS_MODERATOR: bigint;
|
|
4
|
+
export declare const PERMISSIONS_MODERATOR_VOICE: bigint;
|
|
5
|
+
export declare const PERMISSIONS_ADMIN: bigint;
|
|
6
|
+
export declare const PERMISSIONS_ADMIN_VOICE: bigint;
|
|
7
|
+
export declare const DiscordPermissionTiers: {
|
|
8
|
+
readonly BASIC: number;
|
|
9
|
+
readonly BASIC_VOICE: number;
|
|
10
|
+
readonly MODERATOR: number;
|
|
11
|
+
readonly MODERATOR_VOICE: number;
|
|
12
|
+
readonly ADMIN: number;
|
|
13
|
+
readonly ADMIN_VOICE: number;
|
|
14
|
+
};
|
|
15
|
+
export type DiscordPermissionTier = keyof typeof DiscordPermissionTiers;
|
|
16
|
+
export declare function generateInviteUrl(applicationId: string, tier?: DiscordPermissionTier): string;
|
|
17
|
+
export interface DiscordPermissionValues {
|
|
18
|
+
basic: number;
|
|
19
|
+
basicVoice: number;
|
|
20
|
+
moderator: number;
|
|
21
|
+
moderatorVoice: number;
|
|
22
|
+
admin: number;
|
|
23
|
+
adminVoice: number;
|
|
24
|
+
}
|
|
25
|
+
export declare function getPermissionValues(): DiscordPermissionValues;
|
|
26
|
+
export interface DiscordInviteUrls {
|
|
27
|
+
basic: string;
|
|
28
|
+
basicVoice: string;
|
|
29
|
+
moderator: string;
|
|
30
|
+
moderatorVoice: string;
|
|
31
|
+
admin: string;
|
|
32
|
+
adminVoice: string;
|
|
33
|
+
}
|
|
34
|
+
export declare function generateAllInviteUrls(applicationId: string): DiscordInviteUrls;
|
|
35
|
+
export declare const REQUIRED_PERMISSIONS: bigint;
|
|
36
|
+
//# sourceMappingURL=permissions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../permissions.ts"],"names":[],"mappings":"AAqFA,eAAO,MAAM,iBAAiB,QAAa,CAAC;AAC5C,eAAO,MAAM,uBAAuB,QAA2B,CAAC;AAChE,eAAO,MAAM,qBAAqB,QAAiB,CAAC;AACpD,eAAO,MAAM,2BAA2B,QAA+B,CAAC;AACxE,eAAO,MAAM,iBAAiB,QAAa,CAAC;AAC5C,eAAO,MAAM,uBAAuB,QAAiC,CAAC;AAEtE,eAAO,MAAM,sBAAsB;;;;;;;CAOzB,CAAC;AAEX,MAAM,MAAM,qBAAqB,GAAG,MAAM,OAAO,sBAAsB,CAAC;AAExE,wBAAgB,iBAAiB,CAChC,aAAa,EAAE,MAAM,EACrB,IAAI,GAAE,qBAAyC,GAC7C,MAAM,CAGR;AAED,MAAM,WAAW,uBAAuB;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,mBAAmB,IAAI,uBAAuB,CAS7D;AAED,MAAM,WAAW,iBAAiB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,qBAAqB,CACpC,aAAa,EAAE,MAAM,GACnB,iBAAiB,CASnB;AAED,eAAO,MAAM,oBAAoB,QAA8B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IAgentRuntime } from "@elizaos/core";
|
|
2
|
+
import type { ClientUser } from "discord.js";
|
|
3
|
+
import type { DiscordSettings } from "./types";
|
|
4
|
+
export declare function syncDiscordClientProfile(runtime: IAgentRuntime, clientUser: Pick<ClientUser, "username"> & {
|
|
5
|
+
setAvatar?: (avatar: Buffer | string | null) => Promise<unknown>;
|
|
6
|
+
setUsername?: (username: string) => Promise<unknown>;
|
|
7
|
+
}, settings: DiscordSettings): Promise<void>;
|
|
8
|
+
//# sourceMappingURL=profileSync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profileSync.d.ts","sourceRoot":"","sources":["../profileSync.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AA0P/C,wBAAsB,wBAAwB,CAC7C,OAAO,EAAE,aAAa,EACtB,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,GAAG;IAC1C,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACjE,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CACrD,EACD,QAAQ,EAAE,eAAe,GACvB,OAAO,CAAC,IAAI,CAAC,CA8Df"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Provider } from "@elizaos/core";
|
|
2
|
+
/**
|
|
3
|
+
* Represents a provider for retrieving channel state information.
|
|
4
|
+
* @type {Provider}
|
|
5
|
+
* @property {string} name - The name of the channel state provider.
|
|
6
|
+
* @property {Function} get - Asynchronous function that retrieves channel state information based on the provided runtime, message, and optional state parameters.
|
|
7
|
+
* @param {IAgentRuntime} runtime - The agent runtime.
|
|
8
|
+
* @param {Memory} message - The message object.
|
|
9
|
+
* @param {State} [state] - Optional state object.
|
|
10
|
+
* @returns {Promise<Object>} A promise that resolves to an object containing channel state data, values, and text.
|
|
11
|
+
*/
|
|
12
|
+
export declare const channelStateProvider: Provider;
|
|
13
|
+
export default channelStateProvider;
|
|
14
|
+
//# sourceMappingURL=channelState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channelState.d.ts","sourceRoot":"","sources":["../../providers/channelState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyB,QAAQ,EAAS,MAAM,eAAe,CAAC;AAqE5E;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,EAAE,QA8JlC,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Provider } from "@elizaos/core";
|
|
2
|
+
/**
|
|
3
|
+
* Represents a provider for retrieving guild/server information.
|
|
4
|
+
* @type {Provider}
|
|
5
|
+
* @property {string} name - The name of the guild info provider.
|
|
6
|
+
* @property {Function} get - Asynchronous function that retrieves guild information
|
|
7
|
+
* based on the provided runtime, message, and optional state parameters.
|
|
8
|
+
* @param {IAgentRuntime} runtime - The agent runtime.
|
|
9
|
+
* @param {Memory} message - The message object.
|
|
10
|
+
* @param {State} [state] - Optional state object.
|
|
11
|
+
* @returns {Promise<Object>} A promise that resolves to an object containing guild data, values, and text.
|
|
12
|
+
*/
|
|
13
|
+
export declare const guildInfoProvider: Provider;
|
|
14
|
+
export default guildInfoProvider;
|
|
15
|
+
//# sourceMappingURL=guildInfo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guildInfo.d.ts","sourceRoot":"","sources":["../../providers/guildInfo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyB,QAAQ,EAAS,MAAM,eAAe,CAAC;AAQ5E;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,EAAE,QAyG/B,CAAC;AA4HF,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Provider } from "@elizaos/core";
|
|
2
|
+
/**
|
|
3
|
+
* Provides information about the voice state of the user, including whether they are currently in a voice channel.
|
|
4
|
+
*
|
|
5
|
+
* @param {IAgentRuntime} runtime - The runtime object for the agent
|
|
6
|
+
* @param {Memory} message - The message object containing room ID
|
|
7
|
+
* @param {State} [state] - Optional state object for the user
|
|
8
|
+
* @returns {Object} An object containing information about the voice state of the user
|
|
9
|
+
*/
|
|
10
|
+
export declare const voiceStateProvider: Provider;
|
|
11
|
+
export default voiceStateProvider;
|
|
12
|
+
//# sourceMappingURL=voiceState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"voiceState.d.ts","sourceRoot":"","sources":["../../providers/voiceState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGX,QAAQ,EAIR,MAAM,eAAe,CAAC;AASvB;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,EAAE,QA2JhC,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reasoning-tags.d.ts","sourceRoot":"","sources":["../reasoning-tags.ts"],"names":[],"mappings":"AAgBA,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAgCvD"}
|