@hostwebhook/node-types 1.68.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.
Files changed (94) hide show
  1. package/dist/calendar-toolkit.d.ts +1 -1
  2. package/dist/connections.d.ts +1 -1
  3. package/dist/credentials.d.ts +89 -2
  4. package/dist/credentials.js +31 -4
  5. package/dist/discord-operations.d.ts +1 -1
  6. package/dist/discord-operations.js +4 -4
  7. package/dist/discord-toolkit.d.ts +1 -1
  8. package/dist/discord-toolkit.js +3 -3
  9. package/dist/dispatch.d.ts +1 -1
  10. package/dist/docs-toolkit.d.ts +1 -1
  11. package/dist/drive-toolkit.d.ts +1 -1
  12. package/dist/esm/calendar-operations.d.ts +67 -0
  13. package/dist/esm/calendar-operations.js +176 -0
  14. package/dist/esm/calendar-toolkit.d.ts +50 -0
  15. package/dist/esm/calendar-toolkit.js +152 -0
  16. package/dist/esm/capacidad-de-credencial.d.ts +75 -0
  17. package/dist/esm/capacidad-de-credencial.js +68 -0
  18. package/dist/esm/connections.d.ts +17 -0
  19. package/dist/esm/connections.js +106 -0
  20. package/dist/esm/credentials.d.ts +144 -0
  21. package/dist/esm/credentials.js +199 -0
  22. package/dist/esm/discord-operations.d.ts +104 -0
  23. package/dist/esm/discord-operations.js +407 -0
  24. package/dist/esm/discord-toolkit.d.ts +64 -0
  25. package/dist/esm/discord-toolkit.js +260 -0
  26. package/dist/esm/dispatch.d.ts +16 -0
  27. package/dist/esm/dispatch.js +76 -0
  28. package/dist/esm/docs-operations.d.ts +99 -0
  29. package/dist/esm/docs-operations.js +127 -0
  30. package/dist/esm/docs-toolkit.d.ts +42 -0
  31. package/dist/esm/docs-toolkit.js +97 -0
  32. package/dist/esm/drive-operations.d.ts +103 -0
  33. package/dist/esm/drive-operations.js +319 -0
  34. package/dist/esm/drive-toolkit.d.ts +54 -0
  35. package/dist/esm/drive-toolkit.js +177 -0
  36. package/dist/esm/github-operations.d.ts +147 -0
  37. package/dist/esm/github-operations.js +551 -0
  38. package/dist/esm/gmail-operations.d.ts +190 -0
  39. package/dist/esm/gmail-operations.js +560 -0
  40. package/dist/esm/google-analytics-operations.d.ts +99 -0
  41. package/dist/esm/google-analytics-operations.js +222 -0
  42. package/dist/esm/google-contacts-operations.d.ts +93 -0
  43. package/dist/esm/google-contacts-operations.js +363 -0
  44. package/dist/esm/index.d.ts +66 -0
  45. package/dist/esm/index.js +50 -0
  46. package/dist/esm/jira-operations.d.ts +164 -0
  47. package/dist/esm/jira-operations.js +470 -0
  48. package/dist/esm/llm-models.d.ts +101 -0
  49. package/dist/esm/llm-models.js +230 -0
  50. package/dist/esm/mailchimp-operations.d.ts +56 -0
  51. package/dist/esm/mailchimp-operations.js +155 -0
  52. package/dist/esm/mongo-operations.d.ts +61 -0
  53. package/dist/esm/mongo-operations.js +120 -0
  54. package/dist/esm/notion-operations.d.ts +125 -0
  55. package/dist/esm/notion-operations.js +511 -0
  56. package/dist/esm/openrouter.d.ts +142 -0
  57. package/dist/esm/openrouter.js +99 -0
  58. package/dist/esm/package.json +4 -0
  59. package/dist/esm/postgres-operations.d.ts +60 -0
  60. package/dist/esm/postgres-operations.js +75 -0
  61. package/dist/esm/registry.d.ts +160 -0
  62. package/dist/esm/registry.js +555 -0
  63. package/dist/esm/sheets-operations.d.ts +78 -0
  64. package/dist/esm/sheets-operations.js +150 -0
  65. package/dist/esm/sheets-toolkit.d.ts +49 -0
  66. package/dist/esm/sheets-toolkit.js +127 -0
  67. package/dist/esm/shopify-operations.d.ts +95 -0
  68. package/dist/esm/shopify-operations.js +259 -0
  69. package/dist/esm/slack-operations.d.ts +81 -0
  70. package/dist/esm/slack-operations.js +244 -0
  71. package/dist/esm/slack-toolkit.d.ts +60 -0
  72. package/dist/esm/slack-toolkit.js +235 -0
  73. package/dist/esm/telegram-operations.d.ts +104 -0
  74. package/dist/esm/telegram-operations.js +351 -0
  75. package/dist/esm/telegram-toolkit.d.ts +52 -0
  76. package/dist/esm/telegram-toolkit.js +183 -0
  77. package/dist/esm/types.d.ts +149 -0
  78. package/dist/esm/types.js +8 -0
  79. package/dist/esm/ui.d.ts +13 -0
  80. package/dist/esm/ui.js +150 -0
  81. package/dist/esm/whatsapp-operations.d.ts +23 -0
  82. package/dist/esm/whatsapp-operations.js +36 -0
  83. package/dist/index.d.ts +66 -66
  84. package/dist/index.js +185 -185
  85. package/dist/openrouter.d.ts +1 -1
  86. package/dist/registry.d.ts +1 -1
  87. package/dist/sheets-toolkit.d.ts +1 -1
  88. package/dist/slack-operations.d.ts +1 -1
  89. package/dist/slack-operations.js +4 -4
  90. package/dist/slack-toolkit.d.ts +1 -1
  91. package/dist/slack-toolkit.js +3 -3
  92. package/dist/telegram-toolkit.d.ts +1 -1
  93. package/dist/ui.d.ts +1 -1
  94. package/package.json +21 -3
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Slack Web API operation enum — single source of truth across the
3
+ * api, dashboard, and downstream consumers (Message Broker, MCP server).
4
+ * Used by:
5
+ * - slackAction entity / DTO (api): operation field + validation
6
+ * - dashboard SlackAction operation picker + form generation
7
+ * - MCP toolkit-specs expansion (one aiEnabled slackAction → N tools)
8
+ *
9
+ * v1 covers 16 ops — messaging, channel CRUD, members, reactions, files.
10
+ * Future additions (pin / unpin, files.list, conversations.archive, app
11
+ * publish, scheduled.list, etc.) extend this list — bump the package and
12
+ * re-install in consumers, same pattern as Gmail / Calendar / Discord.
13
+ */
14
+ import { type CapacidadesPorCredencial } from './capacidad-de-credencial.js';
15
+ export declare const SLACK_OPERATIONS: readonly ["sendMessage", "updateMessage", "deleteMessage", "sendEphemeral", "scheduleMessage", "getMessage", "listChannels", "getChannelHistory", "getThreadReplies", "createChannel", "inviteToChannel", "addReaction", "removeReaction", "listUsers", "getUserInfo", "uploadFile"];
16
+ export type SlackOperation = (typeof SLACK_OPERATIONS)[number];
17
+ /** Type guard — useful when validating untrusted input (DTOs, AI tool calls). */
18
+ export declare function isSlackOperation(value: unknown): value is SlackOperation;
19
+ /**
20
+ * Per-operation parameter schema. Drives:
21
+ * 1. Form auto-generation in the SlackAction detail page (dashboard).
22
+ * 2. AI tool argument schema when `aiEnabled === true`.
23
+ * 3. MCP tools/list expansion (one slackAction → N MCP tools).
24
+ *
25
+ * Field types kept narrow on purpose so the dashboard form picker can
26
+ * render the right control (channel-picker vs free text vs number).
27
+ * The api side `SlackOperationsService` accepts the same shapes.
28
+ */
29
+ export interface SlackParamSpec {
30
+ /** Field key — also the property name on operationConfig / payload. */
31
+ name: string;
32
+ /** UI label. */
33
+ label: string;
34
+ /** Param type for form rendering + AI tool schema. */
35
+ type: 'channel' | 'user' | 'string' | 'text' | 'number' | 'boolean' | 'emoji' | 'blocks' | 'json' | 'fileUrl';
36
+ /** Required at submit time. */
37
+ required?: boolean;
38
+ /** Human description — also used as the AI tool param description. */
39
+ description: string;
40
+ /** Hint shown under the input. */
41
+ placeholder?: string;
42
+ }
43
+ export interface SlackOperationSpec {
44
+ /** UI label for the operation picker. */
45
+ label: string;
46
+ /** Description shown in the picker + reused by the AI tool description
47
+ * when the user hasn't set a custom one on the entity. */
48
+ description: string;
49
+ /** Verb the operation maps to in Slack's docs (slack.com/methods/...). */
50
+ apiMethod: string;
51
+ /** Parameter schema. Order matters for form rendering. */
52
+ params: SlackParamSpec[];
53
+ }
54
+ export declare const SLACK_OPERATION_SPECS: Record<SlackOperation, SlackOperationSpec>;
55
+ /**
56
+ * Lo que puede hacer una credencial de Slack que NO es OAuth.
57
+ *
58
+ * Medido contra la documentación de Slack, no de memoria:
59
+ * https://docs.slack.dev/messaging/sending-messages-using-incoming-webhooks
60
+ *
61
+ * Es el caso extremo, y conviene que se lea así de crudo: **una** operación de
62
+ * las 16. Un incoming webhook publica y nada más. Textualmente: «Incoming
63
+ * webhooks do not allow you to delete a message after it's been posted», no
64
+ * lee, no sube ficheros, y editar exige `chat.update`, que es token.
65
+ *
66
+ * Y el campo que se cae es el que más duele, porque no parece una restricción
67
+ * hasta que lo es: **`channel` no se puede elegir**. «You cannot override the
68
+ * default channel (chosen by the user who installed your app)». El destino se
69
+ * decide al crear la credencial, así que ofrecer el campo sería ofrecer una
70
+ * pregunta cuya respuesta se ignora — que es peor que no ofrecerla.
71
+ *
72
+ * `text` y `blocks` se quedan (Block Kit está soportado), y `threadTs` también:
73
+ * la doc lo admite si ya tienes el `ts` del padre por otra vía.
74
+ */
75
+ export declare const SLACK_CAPACIDADES_POR_CREDENCIAL: CapacidadesPorCredencial<SlackOperation>;
76
+ /** Las operaciones que ofrecer para una credencial de Slack. */
77
+ export declare function operacionesDeSlackPara(tipoDeCredencial: string | null | undefined): readonly SlackOperation[];
78
+ /** Si esa credencial puede ejecutar esa operación de Slack. */
79
+ export declare function slackPuedeEjecutar(tipoDeCredencial: string | null | undefined, operacion: SlackOperation): boolean;
80
+ /** Los campos que esa credencial de Slack no deja elegir. */
81
+ export declare function camposDeSlackNoDisponibles(tipoDeCredencial: string | null | undefined): ReadonlySet<string>;
@@ -0,0 +1,244 @@
1
+ /**
2
+ * Slack Web API operation enum — single source of truth across the
3
+ * api, dashboard, and downstream consumers (Message Broker, MCP server).
4
+ * Used by:
5
+ * - slackAction entity / DTO (api): operation field + validation
6
+ * - dashboard SlackAction operation picker + form generation
7
+ * - MCP toolkit-specs expansion (one aiEnabled slackAction → N tools)
8
+ *
9
+ * v1 covers 16 ops — messaging, channel CRUD, members, reactions, files.
10
+ * Future additions (pin / unpin, files.list, conversations.archive, app
11
+ * publish, scheduled.list, etc.) extend this list — bump the package and
12
+ * re-install in consumers, same pattern as Gmail / Calendar / Discord.
13
+ */
14
+ import { camposNoDisponiblesPara, operacionesPara, puedeEjecutar, } from './capacidad-de-credencial.js';
15
+ export const SLACK_OPERATIONS = [
16
+ // Messages
17
+ 'sendMessage',
18
+ 'updateMessage',
19
+ 'deleteMessage',
20
+ 'sendEphemeral',
21
+ 'scheduleMessage',
22
+ 'getMessage',
23
+ // Channels
24
+ 'listChannels',
25
+ 'getChannelHistory',
26
+ 'getThreadReplies',
27
+ 'createChannel',
28
+ 'inviteToChannel',
29
+ // Reactions
30
+ 'addReaction',
31
+ 'removeReaction',
32
+ // Users
33
+ 'listUsers',
34
+ 'getUserInfo',
35
+ // Files
36
+ 'uploadFile',
37
+ ];
38
+ /** Type guard — useful when validating untrusted input (DTOs, AI tool calls). */
39
+ export function isSlackOperation(value) {
40
+ return (typeof value === 'string' &&
41
+ SLACK_OPERATIONS.includes(value));
42
+ }
43
+ export const SLACK_OPERATION_SPECS = {
44
+ sendMessage: {
45
+ label: 'Send message',
46
+ description: 'Post a message to a channel, group, or DM.',
47
+ apiMethod: 'chat.postMessage',
48
+ params: [
49
+ { name: 'channel', label: 'Channel', type: 'channel', required: true, description: 'Channel id (C…) or DM id (D…) where the message will be posted.' },
50
+ { name: 'text', label: 'Text', type: 'text', description: 'Message text. Supports Slack mrkdwn. Required when blocks is empty.' },
51
+ { name: 'blocks', label: 'Blocks (optional)', type: 'blocks', description: 'Slack Block Kit JSON for rich layouts. Overrides text rendering when set.' },
52
+ { name: 'threadTs', label: 'Thread ts (optional)', type: 'string', description: 'When set, the message replies inside an existing thread. Use the parent message timestamp.' },
53
+ ],
54
+ },
55
+ updateMessage: {
56
+ label: 'Update message',
57
+ description: 'Edit a message the bot posted earlier.',
58
+ apiMethod: 'chat.update',
59
+ params: [
60
+ { name: 'channel', label: 'Channel', type: 'channel', required: true, description: 'Channel where the original message lives.' },
61
+ { name: 'ts', label: 'Message ts', type: 'string', required: true, description: 'Timestamp of the message to edit (returned by sendMessage).' },
62
+ { name: 'text', label: 'New text', type: 'text', description: 'Replacement text. Required when blocks is empty.' },
63
+ { name: 'blocks', label: 'New blocks (optional)', type: 'blocks', description: 'Replacement Block Kit layout.' },
64
+ ],
65
+ },
66
+ deleteMessage: {
67
+ label: 'Delete message',
68
+ description: 'Delete a message the bot posted earlier.',
69
+ apiMethod: 'chat.delete',
70
+ params: [
71
+ { name: 'channel', label: 'Channel', type: 'channel', required: true, description: 'Channel where the message lives.' },
72
+ { name: 'ts', label: 'Message ts', type: 'string', required: true, description: 'Timestamp of the message to delete.' },
73
+ ],
74
+ },
75
+ sendEphemeral: {
76
+ label: 'Send ephemeral',
77
+ description: 'Post a message visible only to a single user (the rest of the channel does not see it).',
78
+ apiMethod: 'chat.postEphemeral',
79
+ params: [
80
+ { name: 'channel', label: 'Channel', type: 'channel', required: true, description: 'Channel where the ephemeral message will appear.' },
81
+ { name: 'user', label: 'User', type: 'user', required: true, description: 'User id (U…) — only this user sees the message.' },
82
+ { name: 'text', label: 'Text', type: 'text', description: 'Message text. Required when blocks is empty.' },
83
+ { name: 'blocks', label: 'Blocks (optional)', type: 'blocks', description: 'Block Kit layout.' },
84
+ ],
85
+ },
86
+ scheduleMessage: {
87
+ label: 'Schedule message',
88
+ description: 'Schedule a message to be posted at a future time.',
89
+ apiMethod: 'chat.scheduleMessage',
90
+ params: [
91
+ { name: 'channel', label: 'Channel', type: 'channel', required: true, description: 'Channel where the scheduled message will be posted.' },
92
+ { name: 'postAt', label: 'Post at (unix sec)', type: 'number', required: true, description: 'When Slack should post the message — unix timestamp in seconds.' },
93
+ { name: 'text', label: 'Text', type: 'text', description: 'Message text. Required when blocks is empty.' },
94
+ { name: 'blocks', label: 'Blocks (optional)', type: 'blocks', description: 'Block Kit layout.' },
95
+ ],
96
+ },
97
+ getMessage: {
98
+ label: 'Get message',
99
+ description: 'Fetch a single message by its timestamp.',
100
+ apiMethod: 'conversations.history',
101
+ params: [
102
+ { name: 'channel', label: 'Channel', type: 'channel', required: true, description: 'Channel where the message lives.' },
103
+ { name: 'ts', label: 'Message ts', type: 'string', required: true, description: 'Timestamp of the message to fetch.' },
104
+ ],
105
+ },
106
+ listChannels: {
107
+ label: 'List channels',
108
+ description: 'List public + private channels the bot can see in the workspace.',
109
+ apiMethod: 'conversations.list',
110
+ params: [
111
+ { name: 'limit', label: 'Limit', type: 'number', description: 'Max channels to return (1-1000). Default 200.' },
112
+ { name: 'excludeArchived', label: 'Exclude archived', type: 'boolean', description: 'Hide archived channels. Default true.' },
113
+ ],
114
+ },
115
+ getChannelHistory: {
116
+ label: 'Get channel history',
117
+ description: 'Read recent messages from a channel.',
118
+ apiMethod: 'conversations.history',
119
+ params: [
120
+ { name: 'channel', label: 'Channel', type: 'channel', required: true, description: 'Channel to read from.' },
121
+ { name: 'limit', label: 'Limit', type: 'number', description: 'Max messages to return (1-200). Default 50.' },
122
+ { name: 'oldest', label: 'Oldest ts', type: 'string', description: 'Only messages after this timestamp.' },
123
+ { name: 'latest', label: 'Latest ts', type: 'string', description: 'Only messages before this timestamp.' },
124
+ ],
125
+ },
126
+ getThreadReplies: {
127
+ label: 'Get thread replies',
128
+ description: 'Fetch replies to a thread.',
129
+ apiMethod: 'conversations.replies',
130
+ params: [
131
+ { name: 'channel', label: 'Channel', type: 'channel', required: true, description: 'Channel where the thread lives.' },
132
+ { name: 'ts', label: 'Parent ts', type: 'string', required: true, description: 'Timestamp of the thread parent message.' },
133
+ { name: 'limit', label: 'Limit', type: 'number', description: 'Max replies to return (1-1000). Default 100.' },
134
+ ],
135
+ },
136
+ createChannel: {
137
+ label: 'Create channel',
138
+ description: 'Create a new public or private channel.',
139
+ apiMethod: 'conversations.create',
140
+ params: [
141
+ { name: 'name', label: 'Name', type: 'string', required: true, description: 'Channel name (lowercase, no spaces, < 80 chars).' },
142
+ { name: 'isPrivate', label: 'Private', type: 'boolean', description: 'Create a private channel instead of public. Default false.' },
143
+ ],
144
+ },
145
+ inviteToChannel: {
146
+ label: 'Invite to channel',
147
+ description: 'Invite one or more users to a channel.',
148
+ apiMethod: 'conversations.invite',
149
+ params: [
150
+ { name: 'channel', label: 'Channel', type: 'channel', required: true, description: 'Channel id to invite users to.' },
151
+ { name: 'users', label: 'Users', type: 'string', required: true, description: 'Comma-separated user ids (U…) to invite.' },
152
+ ],
153
+ },
154
+ addReaction: {
155
+ label: 'Add reaction',
156
+ description: 'Add an emoji reaction to a message.',
157
+ apiMethod: 'reactions.add',
158
+ params: [
159
+ { name: 'channel', label: 'Channel', type: 'channel', required: true, description: 'Channel where the message lives.' },
160
+ { name: 'ts', label: 'Message ts', type: 'string', required: true, description: 'Timestamp of the message to react to.' },
161
+ { name: 'name', label: 'Emoji name', type: 'emoji', required: true, description: 'Emoji name without colons (e.g. thumbsup, white_check_mark).' },
162
+ ],
163
+ },
164
+ removeReaction: {
165
+ label: 'Remove reaction',
166
+ description: 'Remove an emoji reaction from a message.',
167
+ apiMethod: 'reactions.remove',
168
+ params: [
169
+ { name: 'channel', label: 'Channel', type: 'channel', required: true, description: 'Channel where the message lives.' },
170
+ { name: 'ts', label: 'Message ts', type: 'string', required: true, description: 'Timestamp of the message.' },
171
+ { name: 'name', label: 'Emoji name', type: 'emoji', required: true, description: 'Emoji name without colons.' },
172
+ ],
173
+ },
174
+ listUsers: {
175
+ label: 'List users',
176
+ description: 'List human members of the workspace (excludes deleted users + bots by default).',
177
+ apiMethod: 'users.list',
178
+ params: [
179
+ { name: 'limit', label: 'Limit', type: 'number', description: 'Max users to return (1-1000). Default 200.' },
180
+ { name: 'includeDeleted', label: 'Include deleted', type: 'boolean', description: 'Include deactivated users. Default false.' },
181
+ { name: 'includeBots', label: 'Include bots', type: 'boolean', description: 'Include bot users + app users. Default false.' },
182
+ ],
183
+ },
184
+ getUserInfo: {
185
+ label: 'Get user info',
186
+ description: 'Fetch a user profile (name, email, timezone, status).',
187
+ apiMethod: 'users.info',
188
+ params: [
189
+ { name: 'user', label: 'User', type: 'user', required: true, description: 'User id (U…) to look up.' },
190
+ ],
191
+ },
192
+ uploadFile: {
193
+ label: 'Upload file',
194
+ description: 'Upload a file (PDF, image, anything) and optionally share it in a channel.',
195
+ apiMethod: 'files.uploadV2',
196
+ params: [
197
+ { name: 'url', label: 'File URL', type: 'fileUrl', description: 'Public URL or HW file _file.downloadUrl that HW will fetch and re-upload.' },
198
+ { name: 'contentBase64', label: 'File content (base64)', type: 'text', description: 'Inline file content as base64 — alternative to url for small payloads.' },
199
+ { name: 'filename', label: 'Filename', type: 'string', description: 'Display name in Slack. Auto-derived from URL when omitted.' },
200
+ { name: 'channel', label: 'Channel (optional)', type: 'channel', description: 'Channel to share the uploaded file in.' },
201
+ { name: 'title', label: 'Title (optional)', type: 'string', description: 'Title shown above the file in Slack.' },
202
+ { name: 'initialComment', label: 'Initial comment (optional)', type: 'text', description: 'Message Slack posts together with the file.' },
203
+ { name: 'threadTs', label: 'Thread ts (optional)', type: 'string', description: 'Attach the file to an existing thread.' },
204
+ ],
205
+ },
206
+ };
207
+ /**
208
+ * Lo que puede hacer una credencial de Slack que NO es OAuth.
209
+ *
210
+ * Medido contra la documentación de Slack, no de memoria:
211
+ * https://docs.slack.dev/messaging/sending-messages-using-incoming-webhooks
212
+ *
213
+ * Es el caso extremo, y conviene que se lea así de crudo: **una** operación de
214
+ * las 16. Un incoming webhook publica y nada más. Textualmente: «Incoming
215
+ * webhooks do not allow you to delete a message after it's been posted», no
216
+ * lee, no sube ficheros, y editar exige `chat.update`, que es token.
217
+ *
218
+ * Y el campo que se cae es el que más duele, porque no parece una restricción
219
+ * hasta que lo es: **`channel` no se puede elegir**. «You cannot override the
220
+ * default channel (chosen by the user who installed your app)». El destino se
221
+ * decide al crear la credencial, así que ofrecer el campo sería ofrecer una
222
+ * pregunta cuya respuesta se ignora — que es peor que no ofrecerla.
223
+ *
224
+ * `text` y `blocks` se quedan (Block Kit está soportado), y `threadTs` también:
225
+ * la doc lo admite si ya tienes el `ts` del padre por otra vía.
226
+ */
227
+ export const SLACK_CAPACIDADES_POR_CREDENCIAL = {
228
+ slack_webhook: {
229
+ operaciones: ['sendMessage'],
230
+ camposNoDisponibles: ['channel'],
231
+ },
232
+ };
233
+ /** Las operaciones que ofrecer para una credencial de Slack. */
234
+ export function operacionesDeSlackPara(tipoDeCredencial) {
235
+ return operacionesPara(SLACK_OPERATIONS, SLACK_CAPACIDADES_POR_CREDENCIAL, tipoDeCredencial);
236
+ }
237
+ /** Si esa credencial puede ejecutar esa operación de Slack. */
238
+ export function slackPuedeEjecutar(tipoDeCredencial, operacion) {
239
+ return puedeEjecutar(SLACK_OPERATIONS, SLACK_CAPACIDADES_POR_CREDENCIAL, tipoDeCredencial, operacion);
240
+ }
241
+ /** Los campos que esa credencial de Slack no deja elegir. */
242
+ export function camposDeSlackNoDisponibles(tipoDeCredencial) {
243
+ return camposNoDisponiblesPara(SLACK_CAPACIDADES_POR_CREDENCIAL, tipoDeCredencial);
244
+ }
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Slack AI Toolkit — las herramientas que un slackAction expone cuando
3
+ * `aiEnabled` está encendido.
4
+ *
5
+ * **Se escribe una sola vez.** Antes vivía dos veces: una copia en
6
+ * `dashboard/components/slack-actions/slack-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
+ * La deriva aquí era gorda: **14 de las 16 descripciones** diferían. Gana la de
13
+ * la api en todas —es sistemáticamente la más completa y es la que sirve el MCP
14
+ * hoy—, y una no era cosmética: en `deleteMessage` la api nombra el permiso que
15
+ * hace falta (`chat:write.public` + admin) y el dashboard sólo decía «admin
16
+ * perms». Operaciones, nombres de herramienta y parámetros sí coincidían.
17
+ *
18
+ * Los nombres llevan `_slack_` para no chocar con los de Telegram y Discord
19
+ * cuando un mismo AI Node tiene varios toolkits encendidos.
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 { SlackOperation } from './slack-operations.js';
26
+ export interface SlackToolkitParameter {
27
+ name: string;
28
+ type: 'string' | 'number' | 'boolean';
29
+ description: string;
30
+ required: boolean;
31
+ }
32
+ export interface SlackToolkitSpec {
33
+ operation: SlackOperation;
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: SlackToolkitParameter[];
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 SLACK_TOOLKIT_SPECS: SlackToolkitSpec[];
47
+ export declare const SLACK_TOOLKIT_BY_TOOL_NAME: Record<string, SlackToolkitSpec>;
48
+ /**
49
+ * Las herramientas que ofrecerle al modelo con ESTA credencial.
50
+ *
51
+ * Gemelo de `herramientasDeDiscordPara`, y por la misma razón: los dos
52
+ * consumidores —la expansión MCP de la api y el selector del AI Node del
53
+ * dashboard— filtrarían por su cuenta y acabarían discrepando.
54
+ *
55
+ * En Slack el recorte es brutal y conviene verlo escrito: con un webhook el
56
+ * modelo pasa de **16 herramientas a una**, y esa una pierde el `channel`,
57
+ * porque el destino lo fijó quien instaló la credencial. Dejarle el campo sería
58
+ * invitarle a elegir un canal que Slack va a ignorar sin decir nada.
59
+ */
60
+ export declare function herramientasDeSlackPara(tipoDeCredencial: string | null | undefined): SlackToolkitSpec[];
@@ -0,0 +1,235 @@
1
+ /**
2
+ * Slack AI Toolkit — las herramientas que un slackAction expone cuando
3
+ * `aiEnabled` está encendido.
4
+ *
5
+ * **Se escribe una sola vez.** Antes vivía dos veces: una copia en
6
+ * `dashboard/components/slack-actions/slack-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
+ * La deriva aquí era gorda: **14 de las 16 descripciones** diferían. Gana la de
13
+ * la api en todas —es sistemáticamente la más completa y es la que sirve el MCP
14
+ * hoy—, y una no era cosmética: en `deleteMessage` la api nombra el permiso que
15
+ * hace falta (`chat:write.public` + admin) y el dashboard sólo decía «admin
16
+ * perms». Operaciones, nombres de herramienta y parámetros sí coincidían.
17
+ *
18
+ * Los nombres llevan `_slack_` para no chocar con los de Telegram y Discord
19
+ * cuando un mismo AI Node tiene varios toolkits encendidos.
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 { camposDeSlackNoDisponibles, operacionesDeSlackPara, } from './slack-operations.js';
26
+ const p = (name, description, required = true, type = 'string') => ({ name, type, description, required });
27
+ export const SLACK_TOOLKIT_SPECS = [
28
+ // ── Messages ─────────────────────────────────────────────────────
29
+ {
30
+ operation: 'sendMessage',
31
+ label: 'Send message',
32
+ toolName: 'send_slack_message',
33
+ description: 'Post a message to a Slack channel, group, or DM. ' +
34
+ 'USAGE RULES: ' +
35
+ '(1) `channel` is a Slack channel id (C…), group id (G…), or DM id (D…). Get it from the trigger payload, listChannels, or the user. Never invent one. ' +
36
+ '(2) For a thread reply, set `threadTs` to the parent message timestamp. ' +
37
+ '(3) Either `text` or `blocks` is required. Use blocks for rich layouts.',
38
+ parameters: [
39
+ p('channel', 'Channel/group/DM id where the message will be posted.'),
40
+ p('text', 'Message text. Slack mrkdwn supported. Required when blocks is empty.', false),
41
+ p('blocks', 'Block Kit JSON for rich layouts. Stringified JSON or JSON array.', false),
42
+ p('threadTs', 'Parent message timestamp to reply inside an existing thread.', false),
43
+ ],
44
+ },
45
+ {
46
+ operation: 'updateMessage',
47
+ label: 'Update message',
48
+ toolName: 'update_slack_message',
49
+ description: 'Edit a message previously posted by the bot. The bot can only edit its own messages — editing another user/bot message returns cant_update_message.',
50
+ parameters: [
51
+ p('channel', 'Channel where the original message lives.'),
52
+ p('ts', 'Timestamp of the message to edit (returned by sendMessage).'),
53
+ p('text', 'New message text. Required when blocks is empty.', false),
54
+ p('blocks', 'New Block Kit JSON. Replaces the existing layout.', false),
55
+ ],
56
+ },
57
+ {
58
+ operation: 'deleteMessage',
59
+ label: 'Delete message',
60
+ toolName: 'delete_slack_message',
61
+ description: "Delete a message the bot posted. Other users' messages need chat:write.public + admin perms — usually fails for AI-driven calls. Confirm before destructive use.",
62
+ parameters: [
63
+ p('channel', 'Channel where the message lives.'),
64
+ p('ts', 'Timestamp of the message to delete.'),
65
+ ],
66
+ destructive: true,
67
+ },
68
+ {
69
+ operation: 'sendEphemeral',
70
+ label: 'Send ephemeral',
71
+ toolName: 'send_slack_ephemeral',
72
+ description: 'Post a message visible only to a specific user — the rest of the channel does not see it. Useful for per-user prompts, errors, or warnings.',
73
+ parameters: [
74
+ p('channel', 'Channel where the ephemeral message will appear.'),
75
+ p('user', 'User id (U…) — the only viewer of the message.'),
76
+ p('text', 'Message text. Required when blocks is empty.', false),
77
+ p('blocks', 'Block Kit JSON for rich layouts.', false),
78
+ ],
79
+ },
80
+ {
81
+ operation: 'scheduleMessage',
82
+ label: 'Schedule message',
83
+ toolName: 'schedule_slack_message',
84
+ description: 'Schedule a Slack message to be posted at a future time. Returns a scheduled_message_id useful for cancellation later.',
85
+ parameters: [
86
+ p('channel', 'Channel where the message will be posted.'),
87
+ p('postAt', 'When to post — unix timestamp in SECONDS, not milliseconds.', true, 'number'),
88
+ p('text', 'Message text. Required when blocks is empty.', false),
89
+ p('blocks', 'Block Kit JSON for rich layouts.', false),
90
+ ],
91
+ },
92
+ {
93
+ operation: 'getMessage',
94
+ label: 'Get message',
95
+ toolName: 'get_slack_message',
96
+ description: 'Fetch a single message by its timestamp. Returns the message text + author + reactions + attachments. Use BEFORE editing or reacting to verify state.',
97
+ parameters: [
98
+ p('channel', 'Channel where the message lives.'),
99
+ p('ts', 'Timestamp of the message to fetch.'),
100
+ ],
101
+ },
102
+ // ── Channels ─────────────────────────────────────────────────────
103
+ {
104
+ operation: 'listChannels',
105
+ label: 'List channels',
106
+ toolName: 'list_slack_channels',
107
+ description: 'List public + private channels the bot can see in the workspace. Returns id, name, isMember, memberCount per channel. Pre-pick a channel before sendMessage.',
108
+ parameters: [
109
+ p('limit', 'Max channels to return (1-1000). Default 200.', false, 'number'),
110
+ p('excludeArchived', 'Hide archived channels. Default true.', false, 'boolean'),
111
+ ],
112
+ },
113
+ {
114
+ operation: 'getChannelHistory',
115
+ label: 'Get channel history',
116
+ toolName: 'get_slack_channel_history',
117
+ description: 'Read recent messages from a Slack channel. Useful for summarization, context retrieval, or finding a message by content before editing/reacting.',
118
+ parameters: [
119
+ p('channel', 'Channel id to read from.'),
120
+ p('limit', 'Max messages to return (1-200). Default 50.', false, 'number'),
121
+ p('oldest', 'Only messages newer than this timestamp.', false),
122
+ p('latest', 'Only messages older than this timestamp.', false),
123
+ ],
124
+ },
125
+ {
126
+ operation: 'getThreadReplies',
127
+ label: 'Get thread replies',
128
+ toolName: 'get_slack_thread_replies',
129
+ description: 'Fetch the replies inside a Slack thread, given the parent message timestamp. Use for summarizing or continuing a thread.',
130
+ parameters: [
131
+ p('channel', 'Channel where the thread lives.'),
132
+ p('ts', 'Timestamp of the thread parent message.'),
133
+ p('limit', 'Max replies to return (1-1000). Default 100.', false, 'number'),
134
+ ],
135
+ },
136
+ {
137
+ operation: 'createChannel',
138
+ label: 'Create channel',
139
+ toolName: 'create_slack_channel',
140
+ description: 'Create a new public or private Slack channel. Names must be lowercase, no spaces, max 80 chars. Confirm with the user before creating channels — they are usually long-lived org artifacts.',
141
+ parameters: [
142
+ p('name', 'Channel name — lowercase, no spaces, max 80 chars.'),
143
+ p('isPrivate', 'Create a private channel instead of public. Default false.', false, 'boolean'),
144
+ ],
145
+ destructive: true,
146
+ },
147
+ {
148
+ operation: 'inviteToChannel',
149
+ label: 'Invite to channel',
150
+ toolName: 'invite_to_slack_channel',
151
+ description: 'Invite one or more users to a Slack channel by user id. Comma-separated `users` argument.',
152
+ parameters: [
153
+ p('channel', 'Channel id to invite users to.'),
154
+ p('users', 'Comma-separated user ids (U…) to invite.'),
155
+ ],
156
+ },
157
+ // ── Reactions ────────────────────────────────────────────────────
158
+ {
159
+ operation: 'addReaction',
160
+ label: 'Add reaction',
161
+ toolName: 'add_slack_reaction',
162
+ description: 'Add an emoji reaction to a Slack message as the bot. Use the emoji NAME without colons (e.g. `thumbsup`, `white_check_mark`, `eyes`).',
163
+ parameters: [
164
+ p('channel', 'Channel where the message lives.'),
165
+ p('ts', 'Timestamp of the message to react to.'),
166
+ p('name', 'Emoji name without colons.'),
167
+ ],
168
+ },
169
+ {
170
+ operation: 'removeReaction',
171
+ label: 'Remove reaction',
172
+ toolName: 'remove_slack_reaction',
173
+ description: "Remove the bot's own emoji reaction from a Slack message. Cannot remove other users' reactions.",
174
+ parameters: [
175
+ p('channel', 'Channel where the message lives.'),
176
+ p('ts', 'Timestamp of the message.'),
177
+ p('name', 'Emoji name without colons.'),
178
+ ],
179
+ },
180
+ // ── Users ────────────────────────────────────────────────────────
181
+ {
182
+ operation: 'listUsers',
183
+ label: 'List users',
184
+ toolName: 'list_slack_users',
185
+ description: 'List human members of the Slack workspace. Returns id, name, real_name, email, avatarUrl. Excludes deleted users + bots by default.',
186
+ parameters: [
187
+ p('limit', 'Max users to return (1-1000). Default 200.', false, 'number'),
188
+ p('includeDeleted', 'Include deactivated users. Default false.', false, 'boolean'),
189
+ p('includeBots', 'Include bot users + app users. Default false.', false, 'boolean'),
190
+ ],
191
+ },
192
+ {
193
+ operation: 'getUserInfo',
194
+ label: 'Get user info',
195
+ toolName: 'get_slack_user_info',
196
+ description: 'Fetch a Slack user profile (real_name, email, timezone, status, avatar). Use BEFORE sendEphemeral to confirm the user id is valid.',
197
+ parameters: [p('user', 'User id (U…) to look up.')],
198
+ },
199
+ // ── Files ────────────────────────────────────────────────────────
200
+ {
201
+ operation: 'uploadFile',
202
+ label: 'Upload file',
203
+ toolName: 'upload_slack_file',
204
+ description: 'Upload a file to Slack and optionally share it in a channel. Provide either a public `url` to fetch or inline `contentBase64` for small payloads. Optionally attach to a thread via `threadTs`.',
205
+ parameters: [
206
+ p('url', 'Public URL or HW _file.downloadUrl that HW will fetch and re-upload.', false),
207
+ p('contentBase64', 'Inline base64 file content (alternative to url).', false),
208
+ p('filename', 'Display name in Slack. Auto-derived from URL when omitted.', false),
209
+ p('channel', 'Channel id to share the uploaded file in.', false),
210
+ p('title', 'Title shown above the file.', false),
211
+ p('initialComment', 'Message Slack posts together with the file.', false),
212
+ p('threadTs', 'Thread to attach the file to.', false),
213
+ ],
214
+ },
215
+ ];
216
+ export const SLACK_TOOLKIT_BY_TOOL_NAME = Object.fromEntries(SLACK_TOOLKIT_SPECS.map((s) => [s.toolName, s]));
217
+ /**
218
+ * Las herramientas que ofrecerle al modelo con ESTA credencial.
219
+ *
220
+ * Gemelo de `herramientasDeDiscordPara`, y por la misma razón: los dos
221
+ * consumidores —la expansión MCP de la api y el selector del AI Node del
222
+ * dashboard— filtrarían por su cuenta y acabarían discrepando.
223
+ *
224
+ * En Slack el recorte es brutal y conviene verlo escrito: con un webhook el
225
+ * modelo pasa de **16 herramientas a una**, y esa una pierde el `channel`,
226
+ * porque el destino lo fijó quien instaló la credencial. Dejarle el campo sería
227
+ * invitarle a elegir un canal que Slack va a ignorar sin decir nada.
228
+ */
229
+ export function herramientasDeSlackPara(tipoDeCredencial) {
230
+ const permitidas = new Set(operacionesDeSlackPara(tipoDeCredencial));
231
+ const fuera = camposDeSlackNoDisponibles(tipoDeCredencial);
232
+ return SLACK_TOOLKIT_SPECS.filter((s) => permitidas.has(s.operation)).map((s) => fuera.size === 0
233
+ ? s
234
+ : { ...s, parameters: s.parameters.filter((p) => !fuera.has(p.name)) });
235
+ }