@hostwebhook/node-types 1.69.0 → 1.70.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/calendar-toolkit.d.ts +1 -1
- package/dist/connections.d.ts +1 -1
- package/dist/discord-operations.d.ts +1 -1
- package/dist/discord-operations.js +4 -4
- package/dist/discord-toolkit.d.ts +1 -1
- package/dist/discord-toolkit.js +3 -3
- package/dist/dispatch.d.ts +1 -1
- package/dist/docs-toolkit.d.ts +1 -1
- package/dist/drive-toolkit.d.ts +1 -1
- package/dist/esm/calendar-operations.d.ts +67 -0
- package/dist/esm/calendar-operations.js +176 -0
- package/dist/esm/calendar-toolkit.d.ts +50 -0
- package/dist/esm/calendar-toolkit.js +152 -0
- package/dist/esm/capacidad-de-credencial.d.ts +75 -0
- package/dist/esm/capacidad-de-credencial.js +68 -0
- package/dist/esm/connections.d.ts +17 -0
- package/dist/esm/connections.js +106 -0
- package/dist/esm/credentials.d.ts +144 -0
- package/dist/esm/credentials.js +199 -0
- package/dist/esm/discord-operations.d.ts +104 -0
- package/dist/esm/discord-operations.js +407 -0
- package/dist/esm/discord-toolkit.d.ts +64 -0
- package/dist/esm/discord-toolkit.js +260 -0
- package/dist/esm/dispatch.d.ts +16 -0
- package/dist/esm/dispatch.js +76 -0
- package/dist/esm/docs-operations.d.ts +99 -0
- package/dist/esm/docs-operations.js +127 -0
- package/dist/esm/docs-toolkit.d.ts +42 -0
- package/dist/esm/docs-toolkit.js +97 -0
- package/dist/esm/drive-operations.d.ts +103 -0
- package/dist/esm/drive-operations.js +319 -0
- package/dist/esm/drive-toolkit.d.ts +54 -0
- package/dist/esm/drive-toolkit.js +177 -0
- package/dist/esm/github-operations.d.ts +147 -0
- package/dist/esm/github-operations.js +551 -0
- package/dist/esm/gmail-operations.d.ts +190 -0
- package/dist/esm/gmail-operations.js +560 -0
- package/dist/esm/google-analytics-operations.d.ts +99 -0
- package/dist/esm/google-analytics-operations.js +222 -0
- package/dist/esm/google-contacts-operations.d.ts +93 -0
- package/dist/esm/google-contacts-operations.js +363 -0
- package/dist/esm/index.d.ts +66 -0
- package/dist/esm/index.js +50 -0
- package/dist/esm/jira-operations.d.ts +164 -0
- package/dist/esm/jira-operations.js +470 -0
- package/dist/esm/llm-models.d.ts +101 -0
- package/dist/esm/llm-models.js +230 -0
- package/dist/esm/mailchimp-operations.d.ts +56 -0
- package/dist/esm/mailchimp-operations.js +155 -0
- package/dist/esm/mongo-operations.d.ts +61 -0
- package/dist/esm/mongo-operations.js +120 -0
- package/dist/esm/notion-operations.d.ts +125 -0
- package/dist/esm/notion-operations.js +511 -0
- package/dist/esm/openrouter.d.ts +142 -0
- package/dist/esm/openrouter.js +99 -0
- package/dist/esm/package.json +4 -0
- package/dist/esm/postgres-operations.d.ts +60 -0
- package/dist/esm/postgres-operations.js +75 -0
- package/dist/esm/registry.d.ts +160 -0
- package/dist/esm/registry.js +555 -0
- package/dist/esm/sheets-operations.d.ts +78 -0
- package/dist/esm/sheets-operations.js +150 -0
- package/dist/esm/sheets-toolkit.d.ts +49 -0
- package/dist/esm/sheets-toolkit.js +127 -0
- package/dist/esm/shopify-operations.d.ts +95 -0
- package/dist/esm/shopify-operations.js +259 -0
- package/dist/esm/slack-operations.d.ts +81 -0
- package/dist/esm/slack-operations.js +244 -0
- package/dist/esm/slack-toolkit.d.ts +60 -0
- package/dist/esm/slack-toolkit.js +235 -0
- package/dist/esm/telegram-operations.d.ts +104 -0
- package/dist/esm/telegram-operations.js +351 -0
- package/dist/esm/telegram-toolkit.d.ts +52 -0
- package/dist/esm/telegram-toolkit.js +183 -0
- package/dist/esm/types.d.ts +149 -0
- package/dist/esm/types.js +8 -0
- package/dist/esm/ui.d.ts +13 -0
- package/dist/esm/ui.js +150 -0
- package/dist/esm/whatsapp-operations.d.ts +23 -0
- package/dist/esm/whatsapp-operations.js +36 -0
- package/dist/index.d.ts +66 -66
- package/dist/index.js +185 -185
- package/dist/openrouter.d.ts +1 -1
- package/dist/registry.d.ts +1 -1
- package/dist/sheets-toolkit.d.ts +1 -1
- package/dist/slack-operations.d.ts +1 -1
- package/dist/slack-operations.js +4 -4
- package/dist/slack-toolkit.d.ts +1 -1
- package/dist/slack-toolkit.js +3 -3
- package/dist/telegram-toolkit.d.ts +1 -1
- package/dist/ui.d.ts +1 -1
- package/package.json +21 -3
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Discord Bot API operation enum — single source of truth across the
|
|
3
|
+
* API, Dashboard, and any future consumers (Message Broker, MCP server).
|
|
4
|
+
* Used by:
|
|
5
|
+
* - discordAction entity / DTO (api): operation field + validation
|
|
6
|
+
* - dashboard DiscordAction operation picker + form generation
|
|
7
|
+
* - MCP toolkit-specs expansion (one aiEnabled discordAction → N tools)
|
|
8
|
+
*
|
|
9
|
+
* Targets Discord API v10 (the current stable as of 2026). Each op maps
|
|
10
|
+
* to a single REST call — most go through the Bot Token to the channel/
|
|
11
|
+
* guild/user resource. createThread + createChannel + sendDM each have
|
|
12
|
+
* their own multi-step flows handled inside the dispatcher.
|
|
13
|
+
*
|
|
14
|
+
* Phase 1 covers 17 ops that handle the bulk of bot automation
|
|
15
|
+
* (messaging, channel CRUD, threads, DMs, role membership, lookups).
|
|
16
|
+
* Phase 1.5 candidates (kick / ban / timeout / role CRUD / bulk delete /
|
|
17
|
+
* forum-post create) extend this list — bump the package and re-install
|
|
18
|
+
* in consumers, same pattern as Gmail / Calendar / Drive / Telegram.
|
|
19
|
+
*/
|
|
20
|
+
import { camposNoDisponiblesPara, operacionesPara, puedeEjecutar, } from './capacidad-de-credencial.js';
|
|
21
|
+
export const DISCORD_OPERATIONS = [
|
|
22
|
+
// Messages
|
|
23
|
+
'sendMessage',
|
|
24
|
+
'editMessage',
|
|
25
|
+
'deleteMessage',
|
|
26
|
+
'getMessage',
|
|
27
|
+
'addReaction',
|
|
28
|
+
'removeReaction',
|
|
29
|
+
'pinMessage',
|
|
30
|
+
// Channels
|
|
31
|
+
'createChannel',
|
|
32
|
+
'editChannel',
|
|
33
|
+
'deleteChannel',
|
|
34
|
+
'getChannel',
|
|
35
|
+
'listChannels',
|
|
36
|
+
// Threads
|
|
37
|
+
'createThread',
|
|
38
|
+
// DMs
|
|
39
|
+
'sendDM',
|
|
40
|
+
// Members & roles
|
|
41
|
+
'addRole',
|
|
42
|
+
'removeRole',
|
|
43
|
+
'getMember',
|
|
44
|
+
];
|
|
45
|
+
/** Type guard — useful when validating untrusted input (DTOs, tool calls). */
|
|
46
|
+
export function isDiscordOperation(value) {
|
|
47
|
+
return (typeof value === 'string' &&
|
|
48
|
+
DISCORD_OPERATIONS.includes(value));
|
|
49
|
+
}
|
|
50
|
+
/* Fields several operations share. Each takes overrides because the same key
|
|
51
|
+
can want different wording per operation: messageId is a required "Message
|
|
52
|
+
ID" in six ops and an optional anchor in createThread. */
|
|
53
|
+
const channelId = (over = {}) => ({
|
|
54
|
+
name: 'channelId',
|
|
55
|
+
label: 'Channel ID',
|
|
56
|
+
type: 'channel',
|
|
57
|
+
required: true,
|
|
58
|
+
placeholder: '{{payload.channelId}}',
|
|
59
|
+
description: 'Snowflake of the channel. The picker auto-discovers the channels the bot can see; a template such as {{payload.channelId}} works too.',
|
|
60
|
+
...over,
|
|
61
|
+
});
|
|
62
|
+
const guildId = (over = {}) => ({
|
|
63
|
+
name: 'guildId',
|
|
64
|
+
label: 'Guild ID',
|
|
65
|
+
type: 'guild',
|
|
66
|
+
required: true,
|
|
67
|
+
description: 'Snowflake of the server. The picker auto-discovers the servers the bot belongs to; a template such as {{payload.guildId}} works too.',
|
|
68
|
+
...over,
|
|
69
|
+
});
|
|
70
|
+
const messageId = (over = {}) => ({
|
|
71
|
+
name: 'messageId',
|
|
72
|
+
label: 'Message ID',
|
|
73
|
+
type: 'string',
|
|
74
|
+
required: true,
|
|
75
|
+
placeholder: '{{payload.messageId}}',
|
|
76
|
+
description: 'Snowflake of the message.',
|
|
77
|
+
...over,
|
|
78
|
+
});
|
|
79
|
+
const userId = (over = {}) => ({
|
|
80
|
+
name: 'userId',
|
|
81
|
+
label: 'User ID',
|
|
82
|
+
type: 'member',
|
|
83
|
+
required: true,
|
|
84
|
+
description: 'Snowflake of the user. Listing members needs the Server Members Intent enabled in Developer Portal.',
|
|
85
|
+
...over,
|
|
86
|
+
});
|
|
87
|
+
const roleId = (over = {}) => ({
|
|
88
|
+
name: 'roleId',
|
|
89
|
+
label: 'Role ID',
|
|
90
|
+
type: 'role',
|
|
91
|
+
required: true,
|
|
92
|
+
description: 'Snowflake of the role. The role of the bot itself must sit above the target role in the hierarchy for grant and remove to work.',
|
|
93
|
+
...over,
|
|
94
|
+
});
|
|
95
|
+
const emoji = () => ({
|
|
96
|
+
name: 'emoji',
|
|
97
|
+
label: 'Emoji',
|
|
98
|
+
type: 'emoji',
|
|
99
|
+
required: true,
|
|
100
|
+
placeholder: 'name:id',
|
|
101
|
+
description: 'Unicode emoji, or a custom server emoji written as name:id. URL-encoding is handled.',
|
|
102
|
+
});
|
|
103
|
+
const content = () => ({
|
|
104
|
+
name: 'content',
|
|
105
|
+
label: 'Message content',
|
|
106
|
+
type: 'text',
|
|
107
|
+
required: true,
|
|
108
|
+
rows: 4,
|
|
109
|
+
placeholder: 'Hello! Anything I can help with?',
|
|
110
|
+
description: 'Message text. Markdown is supported, up to the 2000 characters Discord allows.',
|
|
111
|
+
});
|
|
112
|
+
const topic = (label) => ({
|
|
113
|
+
name: 'topic',
|
|
114
|
+
label,
|
|
115
|
+
type: 'text',
|
|
116
|
+
rows: 2,
|
|
117
|
+
placeholder: label.startsWith('New') ? 'New description' : 'Channel description',
|
|
118
|
+
description: 'Channel description, shown under its name in Discord.',
|
|
119
|
+
});
|
|
120
|
+
const slowmode = (label) => ({
|
|
121
|
+
name: 'slowmode',
|
|
122
|
+
label,
|
|
123
|
+
type: 'number',
|
|
124
|
+
min: 0,
|
|
125
|
+
max: 21600,
|
|
126
|
+
default: 0,
|
|
127
|
+
description: 'Seconds a member has to wait between messages. 0 turns slowmode off, 21600 is the six-hour maximum.',
|
|
128
|
+
});
|
|
129
|
+
const parentId = (label) => ({
|
|
130
|
+
name: 'parentId',
|
|
131
|
+
label,
|
|
132
|
+
type: 'channel',
|
|
133
|
+
allowCategories: true,
|
|
134
|
+
placeholder: 'Snowflake of a category',
|
|
135
|
+
description: 'Category to nest the channel under. Categories show in the picker with a folder icon.',
|
|
136
|
+
});
|
|
137
|
+
export const DISCORD_OPERATION_SPECS = {
|
|
138
|
+
// ── Messages ──────────────────────────────────────────────────────
|
|
139
|
+
sendMessage: {
|
|
140
|
+
label: 'Send message',
|
|
141
|
+
description: 'Post text/embed to a channel or thread. Optional reply-to + threadId.',
|
|
142
|
+
apiMethod: 'POST /channels/{channel.id}/messages',
|
|
143
|
+
params: [
|
|
144
|
+
channelId(),
|
|
145
|
+
content(),
|
|
146
|
+
{
|
|
147
|
+
name: 'replyToMessageId',
|
|
148
|
+
label: 'Reply to message ID (optional)',
|
|
149
|
+
type: 'string',
|
|
150
|
+
placeholder: '{{payload.messageId}}',
|
|
151
|
+
description: 'Snowflake of a message to quote-reply to.',
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
name: 'threadId',
|
|
155
|
+
label: 'Thread ID (optional)',
|
|
156
|
+
type: 'string',
|
|
157
|
+
placeholder: '{{payload.threadId}}',
|
|
158
|
+
description: 'Thread snowflake. When set, the message is posted into that thread instead of the parent channel.',
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
name: 'interactionReply',
|
|
162
|
+
label: 'Reply inline to slash command',
|
|
163
|
+
type: 'boolean',
|
|
164
|
+
/* Absent means on: an action downstream of a slash command should
|
|
165
|
+
answer the command by default, so only an explicit false opts out.
|
|
166
|
+
Renderers must compare against false rather than coerce. */
|
|
167
|
+
default: true,
|
|
168
|
+
switchLabel: 'Auto-reply to slash commands (recommended)',
|
|
169
|
+
description: 'When the run came from a Discord slash command, replace the "Bot is thinking" spinner with this message instead of posting a separate one. Falls back to a normal channel post otherwise.',
|
|
170
|
+
},
|
|
171
|
+
],
|
|
172
|
+
},
|
|
173
|
+
editMessage: {
|
|
174
|
+
label: 'Edit message',
|
|
175
|
+
description: 'Edit content/embeds of a message the bot owns.',
|
|
176
|
+
apiMethod: 'PATCH /channels/{channel.id}/messages/{message.id}',
|
|
177
|
+
params: [channelId(), messageId(), content()],
|
|
178
|
+
},
|
|
179
|
+
deleteMessage: {
|
|
180
|
+
label: 'Delete message',
|
|
181
|
+
description: 'Delete by id. Messages from other users need Manage Messages.',
|
|
182
|
+
apiMethod: 'DELETE /channels/{channel.id}/messages/{message.id}',
|
|
183
|
+
params: [channelId(), messageId()],
|
|
184
|
+
},
|
|
185
|
+
getMessage: {
|
|
186
|
+
label: 'Get message',
|
|
187
|
+
description: 'Fetch a single message plus its reactions and attachments.',
|
|
188
|
+
apiMethod: 'GET /channels/{channel.id}/messages/{message.id}',
|
|
189
|
+
params: [channelId(), messageId()],
|
|
190
|
+
},
|
|
191
|
+
addReaction: {
|
|
192
|
+
label: 'Add reaction',
|
|
193
|
+
description: 'React as the bot. Custom emoji format: name:id.',
|
|
194
|
+
apiMethod: 'PUT /channels/{channel.id}/messages/{message.id}/reactions/{emoji}/@me',
|
|
195
|
+
params: [channelId(), messageId(), emoji()],
|
|
196
|
+
},
|
|
197
|
+
removeReaction: {
|
|
198
|
+
label: 'Remove reaction',
|
|
199
|
+
description: 'Remove the reaction the bot itself added.',
|
|
200
|
+
apiMethod: 'DELETE /channels/{channel.id}/messages/{message.id}/reactions/{emoji}/@me',
|
|
201
|
+
params: [channelId(), messageId(), emoji()],
|
|
202
|
+
},
|
|
203
|
+
pinMessage: {
|
|
204
|
+
label: 'Pin message',
|
|
205
|
+
description: 'Pin a message in its channel. Needs Manage Messages.',
|
|
206
|
+
apiMethod: 'PUT /channels/{channel.id}/pins/{message.id}',
|
|
207
|
+
params: [channelId(), messageId()],
|
|
208
|
+
},
|
|
209
|
+
// ── Channels ──────────────────────────────────────────────────────
|
|
210
|
+
createChannel: {
|
|
211
|
+
label: 'Create channel',
|
|
212
|
+
description: 'Create text/voice/forum/announcement/category in a guild.',
|
|
213
|
+
apiMethod: 'POST /guilds/{guild.id}/channels',
|
|
214
|
+
params: [
|
|
215
|
+
guildId(),
|
|
216
|
+
{
|
|
217
|
+
name: 'name',
|
|
218
|
+
label: 'Name',
|
|
219
|
+
type: 'string',
|
|
220
|
+
required: true,
|
|
221
|
+
placeholder: 'ticket-1234',
|
|
222
|
+
description: 'Name for the new channel.',
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
name: 'type',
|
|
226
|
+
label: 'Channel type',
|
|
227
|
+
type: 'select',
|
|
228
|
+
default: 'text',
|
|
229
|
+
description: 'Kind of channel to create.',
|
|
230
|
+
options: [
|
|
231
|
+
{ value: 'text', label: 'Text' },
|
|
232
|
+
{ value: 'voice', label: 'Voice' },
|
|
233
|
+
{ value: 'forum', label: 'Forum' },
|
|
234
|
+
{ value: 'announcement', label: 'Announcement' },
|
|
235
|
+
{ value: 'category', label: 'Category' },
|
|
236
|
+
],
|
|
237
|
+
},
|
|
238
|
+
parentId('Parent category (optional)'),
|
|
239
|
+
topic('Topic (optional)'),
|
|
240
|
+
slowmode('Slowmode seconds (optional)'),
|
|
241
|
+
],
|
|
242
|
+
},
|
|
243
|
+
editChannel: {
|
|
244
|
+
label: 'Edit channel',
|
|
245
|
+
description: 'Rename, change topic, slowmode, parent category.',
|
|
246
|
+
apiMethod: 'PATCH /channels/{channel.id}',
|
|
247
|
+
params: [
|
|
248
|
+
channelId(),
|
|
249
|
+
{
|
|
250
|
+
name: 'name',
|
|
251
|
+
label: 'New name (optional)',
|
|
252
|
+
type: 'string',
|
|
253
|
+
placeholder: 'renamed-channel',
|
|
254
|
+
description: 'Replacement channel name.',
|
|
255
|
+
},
|
|
256
|
+
topic('New topic (optional)'),
|
|
257
|
+
slowmode('New slowmode seconds (optional)'),
|
|
258
|
+
parentId('New parent category (optional)'),
|
|
259
|
+
],
|
|
260
|
+
},
|
|
261
|
+
deleteChannel: {
|
|
262
|
+
label: 'Delete channel',
|
|
263
|
+
description: 'Permanently deletes a channel — irreversible.',
|
|
264
|
+
apiMethod: 'DELETE /channels/{channel.id}',
|
|
265
|
+
params: [channelId()],
|
|
266
|
+
},
|
|
267
|
+
getChannel: {
|
|
268
|
+
label: 'Get channel',
|
|
269
|
+
description: 'Fetch the full config and permissions of a channel.',
|
|
270
|
+
apiMethod: 'GET /channels/{channel.id}',
|
|
271
|
+
params: [channelId()],
|
|
272
|
+
},
|
|
273
|
+
listChannels: {
|
|
274
|
+
label: 'List channels',
|
|
275
|
+
description: 'Iterate every channel in a guild — output is iterable.',
|
|
276
|
+
apiMethod: 'GET /guilds/{guild.id}/channels',
|
|
277
|
+
params: [guildId()],
|
|
278
|
+
},
|
|
279
|
+
// ── Threads ───────────────────────────────────────────────────────
|
|
280
|
+
createThread: {
|
|
281
|
+
label: 'Create thread',
|
|
282
|
+
description: 'Off a message OR standalone (public/private/announcement).',
|
|
283
|
+
apiMethod: 'POST /channels/{channel.id}/threads',
|
|
284
|
+
params: [
|
|
285
|
+
channelId(),
|
|
286
|
+
{
|
|
287
|
+
name: 'name',
|
|
288
|
+
label: 'Name',
|
|
289
|
+
type: 'string',
|
|
290
|
+
required: true,
|
|
291
|
+
placeholder: 'Conversation about issue',
|
|
292
|
+
description: 'Name for the new thread.',
|
|
293
|
+
},
|
|
294
|
+
messageId({
|
|
295
|
+
label: 'Anchor message ID (optional)',
|
|
296
|
+
required: false,
|
|
297
|
+
description: 'Snowflake of a message to spawn the thread from. Leave blank for a standalone thread.',
|
|
298
|
+
}),
|
|
299
|
+
{
|
|
300
|
+
name: 'type',
|
|
301
|
+
label: 'Thread type',
|
|
302
|
+
type: 'select',
|
|
303
|
+
default: 'public',
|
|
304
|
+
description: 'Thread visibility. Ignored when an anchor message is set, since the thread then inherits from its parent.',
|
|
305
|
+
options: [
|
|
306
|
+
{ value: 'public', label: 'Public' },
|
|
307
|
+
{ value: 'private', label: 'Private' },
|
|
308
|
+
{ value: 'announcement', label: 'Announcement' },
|
|
309
|
+
],
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
name: 'autoArchiveMinutes',
|
|
313
|
+
label: 'Auto-archive minutes',
|
|
314
|
+
type: 'select',
|
|
315
|
+
default: 1440,
|
|
316
|
+
description: 'Idle time before Discord archives the thread.',
|
|
317
|
+
options: [
|
|
318
|
+
{ value: 60, label: '1 hour' },
|
|
319
|
+
{ value: 1440, label: '24 hours (default)' },
|
|
320
|
+
{ value: 4320, label: '3 days' },
|
|
321
|
+
{ value: 10080, label: '1 week' },
|
|
322
|
+
],
|
|
323
|
+
},
|
|
324
|
+
],
|
|
325
|
+
},
|
|
326
|
+
// ── DMs ───────────────────────────────────────────────────────────
|
|
327
|
+
sendDM: {
|
|
328
|
+
label: 'Send DM',
|
|
329
|
+
description: 'Direct message a user by id. Silently dropped if DMs disabled.',
|
|
330
|
+
apiMethod: 'POST /users/@me/channels then POST /channels/{channel.id}/messages',
|
|
331
|
+
params: [
|
|
332
|
+
userId({
|
|
333
|
+
description: 'Snowflake of the user to DM. The bot needs a server in common with them.',
|
|
334
|
+
}),
|
|
335
|
+
content(),
|
|
336
|
+
],
|
|
337
|
+
},
|
|
338
|
+
// ── Members & roles ───────────────────────────────────────────────
|
|
339
|
+
addRole: {
|
|
340
|
+
label: 'Add role to member',
|
|
341
|
+
description: 'The role of the bot must be ABOVE the target role in the hierarchy.',
|
|
342
|
+
apiMethod: 'PUT /guilds/{guild.id}/members/{user.id}/roles/{role.id}',
|
|
343
|
+
params: [guildId(), userId(), roleId()],
|
|
344
|
+
},
|
|
345
|
+
removeRole: {
|
|
346
|
+
label: 'Remove role from member',
|
|
347
|
+
description: 'Same hierarchy rule applies.',
|
|
348
|
+
apiMethod: 'DELETE /guilds/{guild.id}/members/{user.id}/roles/{role.id}',
|
|
349
|
+
params: [guildId(), userId(), roleId()],
|
|
350
|
+
},
|
|
351
|
+
getMember: {
|
|
352
|
+
label: 'Get member',
|
|
353
|
+
description: 'Fetch the nick, roles, joined_at and user object of a member.',
|
|
354
|
+
apiMethod: 'GET /guilds/{guild.id}/members/{user.id}',
|
|
355
|
+
params: [guildId(), userId()],
|
|
356
|
+
},
|
|
357
|
+
};
|
|
358
|
+
/**
|
|
359
|
+
* Lo que puede hacer una credencial de Discord que NO es de bot.
|
|
360
|
+
*
|
|
361
|
+
* Medido contra la documentación de Discord, no de memoria:
|
|
362
|
+
* https://docs.discord.com/developers/resources/webhook
|
|
363
|
+
*
|
|
364
|
+
* `Execute Webhook` publica, y `Get/Edit/Delete Webhook Message` leen, editan y
|
|
365
|
+
* borran mensajes — pero **sólo los que envió ese mismo webhook**, y sólo en el
|
|
366
|
+
* canal para el que se creó. Las otras 13 (reacciones, pins, CRUD de canales,
|
|
367
|
+
* crear hilos, DMs, roles, miembros) piden un Bot Token: la propia doc las
|
|
368
|
+
* marca con `MANAGE_WEBHOOKS` o con permisos de guild.
|
|
369
|
+
*
|
|
370
|
+
* Los tres campos que se caen de `sendMessage`, uno por uno:
|
|
371
|
+
*
|
|
372
|
+
* - `channelId`: la URL del webhook YA dice el canal. El endpoint ni siquiera
|
|
373
|
+
* acepta `channel_id`.
|
|
374
|
+
* - `replyToMessageId`: `Execute Webhook` no acepta `message_reference`. No
|
|
375
|
+
* es que venga fijado — es que responder no existe por esta vía.
|
|
376
|
+
* - `interactionReply`: contestar a un slash command es cosa de la
|
|
377
|
+
* aplicación, no de un webhook.
|
|
378
|
+
*
|
|
379
|
+
* `threadId` SÍ se queda: `?thread_id=` es parámetro de query del endpoint.
|
|
380
|
+
*/
|
|
381
|
+
export const DISCORD_CAPACIDADES_POR_CREDENCIAL = {
|
|
382
|
+
discord_webhook: {
|
|
383
|
+
operaciones: [
|
|
384
|
+
'sendMessage',
|
|
385
|
+
'editMessage',
|
|
386
|
+
'deleteMessage',
|
|
387
|
+
'getMessage',
|
|
388
|
+
],
|
|
389
|
+
camposNoDisponibles: [
|
|
390
|
+
'channelId',
|
|
391
|
+
'replyToMessageId',
|
|
392
|
+
'interactionReply',
|
|
393
|
+
],
|
|
394
|
+
},
|
|
395
|
+
};
|
|
396
|
+
/** Las operaciones que ofrecer para una credencial de Discord. */
|
|
397
|
+
export function operacionesDeDiscordPara(tipoDeCredencial) {
|
|
398
|
+
return operacionesPara(DISCORD_OPERATIONS, DISCORD_CAPACIDADES_POR_CREDENCIAL, tipoDeCredencial);
|
|
399
|
+
}
|
|
400
|
+
/** Si esa credencial puede ejecutar esa operación de Discord. */
|
|
401
|
+
export function discordPuedeEjecutar(tipoDeCredencial, operacion) {
|
|
402
|
+
return puedeEjecutar(DISCORD_OPERATIONS, DISCORD_CAPACIDADES_POR_CREDENCIAL, tipoDeCredencial, operacion);
|
|
403
|
+
}
|
|
404
|
+
/** Los campos que esa credencial de Discord no deja elegir. */
|
|
405
|
+
export function camposDeDiscordNoDisponibles(tipoDeCredencial) {
|
|
406
|
+
return camposNoDisponiblesPara(DISCORD_CAPACIDADES_POR_CREDENCIAL, tipoDeCredencial);
|
|
407
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Discord AI Toolkit — las herramientas que un discordAction expone cuando
|
|
3
|
+
* `aiEnabled` está encendido.
|
|
4
|
+
*
|
|
5
|
+
* **Se escribe una sola vez.** Antes vivía dos veces: una copia en
|
|
6
|
+
* `dashboard/components/discord-actions/discord-operations-schemas.ts` y otra en
|
|
7
|
+
* `api/src/mcp-servers/toolkit-specs.ts`, las dos a mano y en repos distintos,
|
|
8
|
+
* así que ningún test podía compararlas. Es la octava y novena mudanza de esta
|
|
9
|
+
* serie; de las siete anteriores, la de Contacts salió de que una copia
|
|
10
|
+
* anunciara 15 herramientas y expusiera una.
|
|
11
|
+
*
|
|
12
|
+
* Y sí había deriva, medida al mudar: la descripción de `addReaction` decía en
|
|
13
|
+
* el dashboard «URL-encoding is handled.» y en la api «URL-encoding is handled —
|
|
14
|
+
* pass the raw form.». Gana la de la api, que es la que el servidor MCP sirve
|
|
15
|
+
* hoy a clientes externos y la que dice qué hacer. Las 17 operaciones, sus
|
|
16
|
+
* nombres de herramienta y sus parámetros coincidían exactamente.
|
|
17
|
+
*
|
|
18
|
+
* Targets Discord API v10. Los parámetros snowflake son `string` porque los ids
|
|
19
|
+
* de Discord se pasan de la precisión de Number (17-20 dígitos).
|
|
20
|
+
*
|
|
21
|
+
* La forma es la que ya consume `toolkitSpecToMcpTool` en la api, para que
|
|
22
|
+
* pueda usarse sin adaptador. Los textos van en inglés porque los lee el modelo
|
|
23
|
+
* y quien mire la lista de herramientas del servidor MCP.
|
|
24
|
+
*/
|
|
25
|
+
import type { DiscordOperation } from './discord-operations.js';
|
|
26
|
+
export interface DiscordToolkitParameter {
|
|
27
|
+
name: string;
|
|
28
|
+
type: 'string' | 'number' | 'boolean';
|
|
29
|
+
description: string;
|
|
30
|
+
required: boolean;
|
|
31
|
+
}
|
|
32
|
+
export interface DiscordToolkitSpec {
|
|
33
|
+
operation: DiscordOperation;
|
|
34
|
+
/** Etiqueta corta de la fila en la lista de herramientas. */
|
|
35
|
+
label: string;
|
|
36
|
+
/** Nombre con el que el LLM llama a la herramienta. */
|
|
37
|
+
toolName: string;
|
|
38
|
+
/** Descripción (más reglas de uso) que ve el LLM. */
|
|
39
|
+
description: string;
|
|
40
|
+
parameters: DiscordToolkitParameter[];
|
|
41
|
+
/** Operaciones irreversibles o que cambian privilegios. La capa MCP las
|
|
42
|
+
* bloquea cuando el nodo de IA lleva `requireConfirmationForDestructive`,
|
|
43
|
+
* salvo que la llamada traiga confirmación explícita. */
|
|
44
|
+
destructive?: boolean;
|
|
45
|
+
}
|
|
46
|
+
export declare const DISCORD_TOOLKIT_SPECS: DiscordToolkitSpec[];
|
|
47
|
+
export declare const DISCORD_TOOLKIT_BY_TOOL_NAME: Record<string, DiscordToolkitSpec>;
|
|
48
|
+
/**
|
|
49
|
+
* Las herramientas que ofrecerle al modelo con ESTA credencial.
|
|
50
|
+
*
|
|
51
|
+
* Vive aquí y no en cada consumidor porque son dos —la expansión MCP de la api
|
|
52
|
+
* y el selector del AI Node del dashboard— y filtrar «casi igual» en dos sitios
|
|
53
|
+
* es exactamente la duplicación que costó tres PR quitar de este paquete.
|
|
54
|
+
*
|
|
55
|
+
* Filtra en los dos niveles, que es lo que hace falta y no es obvio:
|
|
56
|
+
*
|
|
57
|
+
* 1. **Operaciones**: sin esto, a un nodo con credencial de webhook se le
|
|
58
|
+
* entregan al modelo 17 herramientas de las que 13 fallan siempre. El
|
|
59
|
+
* modelo no tiene forma de saberlo: las ve anunciadas.
|
|
60
|
+
* 2. **Parámetros**: una herramienta que sigue pidiendo `channelId` invita al
|
|
61
|
+
* modelo a inventarse un canal que el webhook va a ignorar. Peor que
|
|
62
|
+
* fallar, porque parece que funcionó.
|
|
63
|
+
*/
|
|
64
|
+
export declare function herramientasDeDiscordPara(tipoDeCredencial: string | null | undefined): DiscordToolkitSpec[];
|