@wsapichat/mcp-server 1.0.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/CLAUDE.md +96 -0
- package/LICENSE +21 -0
- package/README.md +403 -0
- package/dist/client/index.d.ts +16 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +154 -0
- package/dist/client/index.js.map +1 -0
- package/dist/config/index.d.ts +85 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +67 -0
- package/dist/config/index.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +46 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +20 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +173 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/account.d.ts +14 -0
- package/dist/tools/account.d.ts.map +1 -0
- package/dist/tools/account.js +78 -0
- package/dist/tools/account.js.map +1 -0
- package/dist/tools/chats.d.ts +14 -0
- package/dist/tools/chats.d.ts.map +1 -0
- package/dist/tools/chats.js +81 -0
- package/dist/tools/chats.js.map +1 -0
- package/dist/tools/contacts.d.ts +18 -0
- package/dist/tools/contacts.d.ts.map +1 -0
- package/dist/tools/contacts.js +213 -0
- package/dist/tools/contacts.js.map +1 -0
- package/dist/tools/groups.d.ts +12 -0
- package/dist/tools/groups.d.ts.map +1 -0
- package/dist/tools/groups.js +65 -0
- package/dist/tools/groups.js.map +1 -0
- package/dist/tools/instance.d.ts +12 -0
- package/dist/tools/instance.d.ts.map +1 -0
- package/dist/tools/instance.js +54 -0
- package/dist/tools/instance.js.map +1 -0
- package/dist/tools/messaging-advanced.d.ts +16 -0
- package/dist/tools/messaging-advanced.d.ts.map +1 -0
- package/dist/tools/messaging-advanced.js +386 -0
- package/dist/tools/messaging-advanced.js.map +1 -0
- package/dist/tools/messaging.d.ts +28 -0
- package/dist/tools/messaging.d.ts.map +1 -0
- package/dist/tools/messaging.js +491 -0
- package/dist/tools/messaging.js.map +1 -0
- package/dist/tools/session.d.ts +14 -0
- package/dist/tools/session.d.ts.map +1 -0
- package/dist/tools/session.js +61 -0
- package/dist/tools/session.js.map +1 -0
- package/dist/types/api.d.ts +2730 -0
- package/dist/types/api.d.ts.map +1 -0
- package/dist/types/api.js +6 -0
- package/dist/types/api.js.map +1 -0
- package/dist/types/webhooks.d.ts +1001 -0
- package/dist/types/webhooks.d.ts.map +1 -0
- package/dist/types/webhooks.js +6 -0
- package/dist/types/webhooks.js.map +1 -0
- package/dist/utils/errors.d.ts +39 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +151 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/logger.d.ts +12 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +99 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/validation/schemas.d.ts +732 -0
- package/dist/validation/schemas.d.ts.map +1 -0
- package/dist/validation/schemas.js +269 -0
- package/dist/validation/schemas.js.map +1 -0
- package/package.json +83 -0
|
@@ -0,0 +1,491 @@
|
|
|
1
|
+
import { wsapiClient } from '../client/index.js';
|
|
2
|
+
import { createLogger } from '../utils/logger.js';
|
|
3
|
+
import { validateInput, sendTextMessageSchema, sendImageMessageSchema, sendVideoMessageSchema, sendLinkMessageSchema, sendReactionMessageSchema, editMessageSchema, deleteMessageSchema, markMessageAsReadSchema, starMessageSchema, } from '../validation/schemas.js';
|
|
4
|
+
const logger = createLogger('messaging-tools');
|
|
5
|
+
// Send text message tool
|
|
6
|
+
export const sendTextMessage = {
|
|
7
|
+
name: 'whatsapp_send_text',
|
|
8
|
+
description: 'Send a text message to a WhatsApp contact or group. Supports mentions and replies.',
|
|
9
|
+
inputSchema: {
|
|
10
|
+
type: 'object',
|
|
11
|
+
properties: {
|
|
12
|
+
to: {
|
|
13
|
+
type: 'string',
|
|
14
|
+
description: 'Recipient phone number (with @s.whatsapp.net) or group ID (with @g.us)',
|
|
15
|
+
},
|
|
16
|
+
text: {
|
|
17
|
+
type: 'string',
|
|
18
|
+
description: 'Message text content (max 4096 characters)',
|
|
19
|
+
},
|
|
20
|
+
mentions: {
|
|
21
|
+
type: 'array',
|
|
22
|
+
items: { type: 'string' },
|
|
23
|
+
description: 'List of phone numbers to mention in the message',
|
|
24
|
+
optional: true,
|
|
25
|
+
},
|
|
26
|
+
replyTo: {
|
|
27
|
+
type: 'string',
|
|
28
|
+
description: 'ID of the message being replied to',
|
|
29
|
+
optional: true,
|
|
30
|
+
},
|
|
31
|
+
isForwarded: {
|
|
32
|
+
type: 'boolean',
|
|
33
|
+
description: 'Whether the message should be marked as forwarded',
|
|
34
|
+
optional: true,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
required: ['to', 'text'],
|
|
38
|
+
},
|
|
39
|
+
handler: async (args) => {
|
|
40
|
+
const input = validateInput(sendTextMessageSchema, args);
|
|
41
|
+
logger.info('Sending text message', { to: input.to, textLength: input.text.length });
|
|
42
|
+
const result = await wsapiClient.post('/messages/text', input);
|
|
43
|
+
logger.info('Text message sent successfully', { messageId: result.id });
|
|
44
|
+
return {
|
|
45
|
+
success: true,
|
|
46
|
+
messageId: result.id,
|
|
47
|
+
message: 'Text message sent successfully',
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
// Send image message tool
|
|
52
|
+
export const sendImageMessage = {
|
|
53
|
+
name: 'whatsapp_send_image',
|
|
54
|
+
description: 'Send an image message to a WhatsApp contact or group. Can send from URL or base64.',
|
|
55
|
+
inputSchema: {
|
|
56
|
+
type: 'object',
|
|
57
|
+
properties: {
|
|
58
|
+
to: {
|
|
59
|
+
type: 'string',
|
|
60
|
+
description: 'Recipient phone number (with @s.whatsapp.net) or group ID (with @g.us)',
|
|
61
|
+
},
|
|
62
|
+
imageBase64: {
|
|
63
|
+
type: 'string',
|
|
64
|
+
description: 'Base64 encoded image data (alternative to imageURL)',
|
|
65
|
+
optional: true,
|
|
66
|
+
},
|
|
67
|
+
imageURL: {
|
|
68
|
+
type: 'string',
|
|
69
|
+
description: 'URL of the image to send (alternative to imageBase64)',
|
|
70
|
+
optional: true,
|
|
71
|
+
},
|
|
72
|
+
mimeType: {
|
|
73
|
+
type: 'string',
|
|
74
|
+
enum: ['image/jpeg', 'image/png', 'image/webp', 'image/gif'],
|
|
75
|
+
description: 'MIME type of the image',
|
|
76
|
+
},
|
|
77
|
+
caption: {
|
|
78
|
+
type: 'string',
|
|
79
|
+
description: 'Caption for the image (max 1024 characters)',
|
|
80
|
+
optional: true,
|
|
81
|
+
},
|
|
82
|
+
mentions: {
|
|
83
|
+
type: 'array',
|
|
84
|
+
items: { type: 'string' },
|
|
85
|
+
description: 'List of phone numbers to mention in the caption',
|
|
86
|
+
optional: true,
|
|
87
|
+
},
|
|
88
|
+
replyTo: {
|
|
89
|
+
type: 'string',
|
|
90
|
+
description: 'ID of the message being replied to',
|
|
91
|
+
optional: true,
|
|
92
|
+
},
|
|
93
|
+
isForwarded: {
|
|
94
|
+
type: 'boolean',
|
|
95
|
+
description: 'Whether the message should be marked as forwarded',
|
|
96
|
+
optional: true,
|
|
97
|
+
},
|
|
98
|
+
viewOnce: {
|
|
99
|
+
type: 'boolean',
|
|
100
|
+
description: 'Whether the image should be sent as view-once',
|
|
101
|
+
optional: true,
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
required: ['to', 'mimeType'],
|
|
105
|
+
},
|
|
106
|
+
handler: async (args) => {
|
|
107
|
+
const input = validateInput(sendImageMessageSchema, args);
|
|
108
|
+
logger.info('Sending image message', {
|
|
109
|
+
to: input.to,
|
|
110
|
+
mimeType: input.mimeType,
|
|
111
|
+
hasCaption: !!input.caption,
|
|
112
|
+
viewOnce: input.viewOnce,
|
|
113
|
+
});
|
|
114
|
+
const result = await wsapiClient.post('/messages/image', input);
|
|
115
|
+
logger.info('Image message sent successfully', { messageId: result.id });
|
|
116
|
+
return {
|
|
117
|
+
success: true,
|
|
118
|
+
messageId: result.id,
|
|
119
|
+
message: 'Image message sent successfully',
|
|
120
|
+
};
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
// Send video message tool
|
|
124
|
+
export const sendVideoMessage = {
|
|
125
|
+
name: 'whatsapp_send_video',
|
|
126
|
+
description: 'Send a video message to a WhatsApp contact or group. Can send from URL or base64.',
|
|
127
|
+
inputSchema: {
|
|
128
|
+
type: 'object',
|
|
129
|
+
properties: {
|
|
130
|
+
to: {
|
|
131
|
+
type: 'string',
|
|
132
|
+
description: 'Recipient phone number (with @s.whatsapp.net) or group ID (with @g.us)',
|
|
133
|
+
},
|
|
134
|
+
videoBase64: {
|
|
135
|
+
type: 'string',
|
|
136
|
+
description: 'Base64 encoded video data (alternative to videoURL)',
|
|
137
|
+
optional: true,
|
|
138
|
+
},
|
|
139
|
+
videoURL: {
|
|
140
|
+
type: 'string',
|
|
141
|
+
description: 'URL of the video to send (alternative to videoBase64)',
|
|
142
|
+
optional: true,
|
|
143
|
+
},
|
|
144
|
+
mimeType: {
|
|
145
|
+
type: 'string',
|
|
146
|
+
enum: ['video/mp4', 'video/3gp', 'video/mov', 'video/avi'],
|
|
147
|
+
description: 'MIME type of the video',
|
|
148
|
+
},
|
|
149
|
+
caption: {
|
|
150
|
+
type: 'string',
|
|
151
|
+
description: 'Caption for the video (max 1024 characters)',
|
|
152
|
+
optional: true,
|
|
153
|
+
},
|
|
154
|
+
viewOnce: {
|
|
155
|
+
type: 'boolean',
|
|
156
|
+
description: 'Whether the video should be sent as view-once',
|
|
157
|
+
optional: true,
|
|
158
|
+
},
|
|
159
|
+
mentions: {
|
|
160
|
+
type: 'array',
|
|
161
|
+
items: { type: 'string' },
|
|
162
|
+
description: 'List of phone numbers to mention in the caption',
|
|
163
|
+
optional: true,
|
|
164
|
+
},
|
|
165
|
+
replyTo: {
|
|
166
|
+
type: 'string',
|
|
167
|
+
description: 'ID of the message being replied to',
|
|
168
|
+
optional: true,
|
|
169
|
+
},
|
|
170
|
+
isForwarded: {
|
|
171
|
+
type: 'boolean',
|
|
172
|
+
description: 'Whether the message should be marked as forwarded',
|
|
173
|
+
optional: true,
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
required: ['to', 'mimeType'],
|
|
177
|
+
},
|
|
178
|
+
handler: async (args) => {
|
|
179
|
+
const input = validateInput(sendVideoMessageSchema, args);
|
|
180
|
+
logger.info('Sending video message', {
|
|
181
|
+
to: input.to,
|
|
182
|
+
mimeType: input.mimeType,
|
|
183
|
+
hasCaption: !!input.caption,
|
|
184
|
+
viewOnce: input.viewOnce,
|
|
185
|
+
});
|
|
186
|
+
const result = await wsapiClient.post('/messages/video', input);
|
|
187
|
+
logger.info('Video message sent successfully', { messageId: result.id });
|
|
188
|
+
return {
|
|
189
|
+
success: true,
|
|
190
|
+
messageId: result.id,
|
|
191
|
+
message: 'Video message sent successfully',
|
|
192
|
+
};
|
|
193
|
+
},
|
|
194
|
+
};
|
|
195
|
+
// Send link message tool
|
|
196
|
+
export const sendLinkMessage = {
|
|
197
|
+
name: 'whatsapp_send_link',
|
|
198
|
+
description: 'Send a link message with optional preview to a WhatsApp contact or group.',
|
|
199
|
+
inputSchema: {
|
|
200
|
+
type: 'object',
|
|
201
|
+
properties: {
|
|
202
|
+
to: {
|
|
203
|
+
type: 'string',
|
|
204
|
+
description: 'Recipient phone number (with @s.whatsapp.net) or group ID (with @g.us)',
|
|
205
|
+
},
|
|
206
|
+
text: {
|
|
207
|
+
type: 'string',
|
|
208
|
+
description: 'Message text content (max 4096 characters)',
|
|
209
|
+
},
|
|
210
|
+
url: {
|
|
211
|
+
type: 'string',
|
|
212
|
+
description: 'URL to include in the message',
|
|
213
|
+
},
|
|
214
|
+
title: {
|
|
215
|
+
type: 'string',
|
|
216
|
+
description: 'Title for the link preview (max 500 characters)',
|
|
217
|
+
optional: true,
|
|
218
|
+
},
|
|
219
|
+
description: {
|
|
220
|
+
type: 'string',
|
|
221
|
+
description: 'Description for the link preview (max 1000 characters)',
|
|
222
|
+
optional: true,
|
|
223
|
+
},
|
|
224
|
+
jpegThumbnail: {
|
|
225
|
+
type: 'string',
|
|
226
|
+
description: 'Base64 encoded JPEG thumbnail for the link preview',
|
|
227
|
+
optional: true,
|
|
228
|
+
},
|
|
229
|
+
mentions: {
|
|
230
|
+
type: 'array',
|
|
231
|
+
items: { type: 'string' },
|
|
232
|
+
description: 'List of phone numbers to mention in the message',
|
|
233
|
+
optional: true,
|
|
234
|
+
},
|
|
235
|
+
replyTo: {
|
|
236
|
+
type: 'string',
|
|
237
|
+
description: 'ID of the message being replied to',
|
|
238
|
+
optional: true,
|
|
239
|
+
},
|
|
240
|
+
isForwarded: {
|
|
241
|
+
type: 'boolean',
|
|
242
|
+
description: 'Whether the message should be marked as forwarded',
|
|
243
|
+
optional: true,
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
required: ['to', 'text', 'url'],
|
|
247
|
+
},
|
|
248
|
+
handler: async (args) => {
|
|
249
|
+
const input = validateInput(sendLinkMessageSchema, args);
|
|
250
|
+
logger.info('Sending link message', {
|
|
251
|
+
to: input.to,
|
|
252
|
+
url: input.url,
|
|
253
|
+
hasTitle: !!input.title,
|
|
254
|
+
hasDescription: !!input.description,
|
|
255
|
+
});
|
|
256
|
+
const result = await wsapiClient.post('/messages/link', input);
|
|
257
|
+
logger.info('Link message sent successfully', { messageId: result.id });
|
|
258
|
+
return {
|
|
259
|
+
success: true,
|
|
260
|
+
messageId: result.id,
|
|
261
|
+
message: 'Link message sent successfully',
|
|
262
|
+
};
|
|
263
|
+
},
|
|
264
|
+
};
|
|
265
|
+
// Send reaction message tool
|
|
266
|
+
export const sendReactionMessage = {
|
|
267
|
+
name: 'whatsapp_send_reaction',
|
|
268
|
+
description: 'Send a reaction (emoji) to a specific message.',
|
|
269
|
+
inputSchema: {
|
|
270
|
+
type: 'object',
|
|
271
|
+
properties: {
|
|
272
|
+
messageId: {
|
|
273
|
+
type: 'string',
|
|
274
|
+
description: 'ID of the message to react to',
|
|
275
|
+
},
|
|
276
|
+
to: {
|
|
277
|
+
type: 'string',
|
|
278
|
+
description: 'Chat ID where the message is located',
|
|
279
|
+
},
|
|
280
|
+
senderId: {
|
|
281
|
+
type: 'string',
|
|
282
|
+
description: 'ID of the original message sender',
|
|
283
|
+
},
|
|
284
|
+
reaction: {
|
|
285
|
+
type: 'string',
|
|
286
|
+
description: 'Emoji reaction to send (max 10 characters)',
|
|
287
|
+
},
|
|
288
|
+
},
|
|
289
|
+
required: ['messageId', 'to', 'senderId', 'reaction'],
|
|
290
|
+
},
|
|
291
|
+
handler: async (args) => {
|
|
292
|
+
const input = validateInput(sendReactionMessageSchema, args);
|
|
293
|
+
logger.info('Sending reaction', {
|
|
294
|
+
messageId: input.messageId,
|
|
295
|
+
to: input.to,
|
|
296
|
+
reaction: input.reaction,
|
|
297
|
+
});
|
|
298
|
+
const result = await wsapiClient.post(`/messages/${input.messageId}/reaction`, {
|
|
299
|
+
to: input.to,
|
|
300
|
+
senderId: input.senderId,
|
|
301
|
+
reaction: input.reaction,
|
|
302
|
+
});
|
|
303
|
+
logger.info('Reaction sent successfully', { messageId: result.id });
|
|
304
|
+
return {
|
|
305
|
+
success: true,
|
|
306
|
+
messageId: result.id,
|
|
307
|
+
message: 'Reaction sent successfully',
|
|
308
|
+
};
|
|
309
|
+
},
|
|
310
|
+
};
|
|
311
|
+
// Edit message tool
|
|
312
|
+
export const editMessage = {
|
|
313
|
+
name: 'whatsapp_edit_message',
|
|
314
|
+
description: 'Edit a previously sent text message.',
|
|
315
|
+
inputSchema: {
|
|
316
|
+
type: 'object',
|
|
317
|
+
properties: {
|
|
318
|
+
messageId: {
|
|
319
|
+
type: 'string',
|
|
320
|
+
description: 'ID of the message to edit',
|
|
321
|
+
},
|
|
322
|
+
to: {
|
|
323
|
+
type: 'string',
|
|
324
|
+
description: 'Chat ID where the message is located',
|
|
325
|
+
},
|
|
326
|
+
text: {
|
|
327
|
+
type: 'string',
|
|
328
|
+
description: 'New text content for the message (max 4096 characters)',
|
|
329
|
+
},
|
|
330
|
+
},
|
|
331
|
+
required: ['messageId', 'to', 'text'],
|
|
332
|
+
},
|
|
333
|
+
handler: async (args) => {
|
|
334
|
+
const input = validateInput(editMessageSchema, args);
|
|
335
|
+
logger.info('Editing message', {
|
|
336
|
+
messageId: input.messageId,
|
|
337
|
+
to: input.to,
|
|
338
|
+
textLength: input.text.length,
|
|
339
|
+
});
|
|
340
|
+
const result = await wsapiClient.put(`/messages/${input.messageId}/text`, {
|
|
341
|
+
to: input.to,
|
|
342
|
+
text: input.text,
|
|
343
|
+
});
|
|
344
|
+
logger.info('Message edited successfully', { messageId: result.id });
|
|
345
|
+
return {
|
|
346
|
+
success: true,
|
|
347
|
+
messageId: result.id,
|
|
348
|
+
message: 'Message edited successfully',
|
|
349
|
+
};
|
|
350
|
+
},
|
|
351
|
+
};
|
|
352
|
+
// Delete message tool
|
|
353
|
+
export const deleteMessage = {
|
|
354
|
+
name: 'whatsapp_delete_message',
|
|
355
|
+
description: 'Delete a message for all participants in the chat.',
|
|
356
|
+
inputSchema: {
|
|
357
|
+
type: 'object',
|
|
358
|
+
properties: {
|
|
359
|
+
messageId: {
|
|
360
|
+
type: 'string',
|
|
361
|
+
description: 'ID of the message to delete',
|
|
362
|
+
},
|
|
363
|
+
chatId: {
|
|
364
|
+
type: 'string',
|
|
365
|
+
description: 'Chat ID where the message is located',
|
|
366
|
+
},
|
|
367
|
+
senderId: {
|
|
368
|
+
type: 'string',
|
|
369
|
+
description: 'ID of the message sender',
|
|
370
|
+
},
|
|
371
|
+
},
|
|
372
|
+
required: ['messageId', 'chatId', 'senderId'],
|
|
373
|
+
},
|
|
374
|
+
handler: async (args) => {
|
|
375
|
+
const input = validateInput(deleteMessageSchema, args);
|
|
376
|
+
logger.info('Deleting message', {
|
|
377
|
+
messageId: input.messageId,
|
|
378
|
+
chatId: input.chatId,
|
|
379
|
+
});
|
|
380
|
+
await wsapiClient.put(`/messages/${input.messageId}/delete`, {
|
|
381
|
+
chatId: input.chatId,
|
|
382
|
+
senderId: input.senderId,
|
|
383
|
+
});
|
|
384
|
+
logger.info('Message deleted successfully', { messageId: input.messageId });
|
|
385
|
+
return {
|
|
386
|
+
success: true,
|
|
387
|
+
message: 'Message deleted successfully',
|
|
388
|
+
};
|
|
389
|
+
},
|
|
390
|
+
};
|
|
391
|
+
// Mark message as read tool
|
|
392
|
+
export const markMessageAsRead = {
|
|
393
|
+
name: 'whatsapp_mark_message_read',
|
|
394
|
+
description: 'Mark a message as read.',
|
|
395
|
+
inputSchema: {
|
|
396
|
+
type: 'object',
|
|
397
|
+
properties: {
|
|
398
|
+
messageId: {
|
|
399
|
+
type: 'string',
|
|
400
|
+
description: 'ID of the message to mark as read',
|
|
401
|
+
},
|
|
402
|
+
chatId: {
|
|
403
|
+
type: 'string',
|
|
404
|
+
description: 'Chat ID where the message is located',
|
|
405
|
+
},
|
|
406
|
+
senderId: {
|
|
407
|
+
type: 'string',
|
|
408
|
+
description: 'ID of the message sender',
|
|
409
|
+
},
|
|
410
|
+
receiptType: {
|
|
411
|
+
type: 'string',
|
|
412
|
+
enum: ['delivered', 'sender', 'read', 'played'],
|
|
413
|
+
description: 'Type of receipt to send',
|
|
414
|
+
},
|
|
415
|
+
},
|
|
416
|
+
required: ['messageId', 'chatId', 'senderId', 'receiptType'],
|
|
417
|
+
},
|
|
418
|
+
handler: async (args) => {
|
|
419
|
+
const input = validateInput(markMessageAsReadSchema, args);
|
|
420
|
+
logger.info('Marking message as read', {
|
|
421
|
+
messageId: input.messageId,
|
|
422
|
+
chatId: input.chatId,
|
|
423
|
+
receiptType: input.receiptType,
|
|
424
|
+
});
|
|
425
|
+
await wsapiClient.put(`/messages/${input.messageId}/read`, {
|
|
426
|
+
chatId: input.chatId,
|
|
427
|
+
senderId: input.senderId,
|
|
428
|
+
receiptType: input.receiptType,
|
|
429
|
+
});
|
|
430
|
+
logger.info('Message marked as read successfully', { messageId: input.messageId });
|
|
431
|
+
return {
|
|
432
|
+
success: true,
|
|
433
|
+
message: 'Message marked as read successfully',
|
|
434
|
+
};
|
|
435
|
+
},
|
|
436
|
+
};
|
|
437
|
+
// Star message tool
|
|
438
|
+
export const starMessage = {
|
|
439
|
+
name: 'whatsapp_star_message',
|
|
440
|
+
description: 'Star or unstar a message.',
|
|
441
|
+
inputSchema: {
|
|
442
|
+
type: 'object',
|
|
443
|
+
properties: {
|
|
444
|
+
messageId: {
|
|
445
|
+
type: 'string',
|
|
446
|
+
description: 'ID of the message to star',
|
|
447
|
+
},
|
|
448
|
+
chatId: {
|
|
449
|
+
type: 'string',
|
|
450
|
+
description: 'Chat ID where the message is located',
|
|
451
|
+
},
|
|
452
|
+
senderId: {
|
|
453
|
+
type: 'string',
|
|
454
|
+
description: 'ID of the message sender',
|
|
455
|
+
},
|
|
456
|
+
},
|
|
457
|
+
required: ['messageId', 'chatId', 'senderId'],
|
|
458
|
+
},
|
|
459
|
+
handler: async (args) => {
|
|
460
|
+
const input = validateInput(starMessageSchema, args);
|
|
461
|
+
logger.info('Starring message', {
|
|
462
|
+
messageId: input.messageId,
|
|
463
|
+
chatId: input.chatId,
|
|
464
|
+
});
|
|
465
|
+
await wsapiClient.put(`/messages/${input.messageId}/star`, {
|
|
466
|
+
chatId: input.chatId,
|
|
467
|
+
senderId: input.senderId,
|
|
468
|
+
});
|
|
469
|
+
logger.info('Message starred successfully', { messageId: input.messageId });
|
|
470
|
+
return {
|
|
471
|
+
success: true,
|
|
472
|
+
message: 'Message starred successfully',
|
|
473
|
+
};
|
|
474
|
+
},
|
|
475
|
+
};
|
|
476
|
+
// Import advanced messaging tools
|
|
477
|
+
import { advancedMessagingTools } from './messaging-advanced.js';
|
|
478
|
+
// Export all messaging tools
|
|
479
|
+
export const messagingTools = {
|
|
480
|
+
sendTextMessage,
|
|
481
|
+
sendImageMessage,
|
|
482
|
+
sendVideoMessage,
|
|
483
|
+
sendLinkMessage,
|
|
484
|
+
sendReactionMessage,
|
|
485
|
+
editMessage,
|
|
486
|
+
deleteMessage,
|
|
487
|
+
markMessageAsRead,
|
|
488
|
+
starMessage,
|
|
489
|
+
...advancedMessagingTools,
|
|
490
|
+
};
|
|
491
|
+
//# sourceMappingURL=messaging.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messaging.js","sourceRoot":"","sources":["../../src/tools/messaging.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,yBAAyB,EACzB,iBAAiB,EACjB,mBAAmB,EACnB,uBAAuB,EACvB,iBAAiB,GAMlB,MAAM,0BAA0B,CAAC;AAElC,MAAM,MAAM,GAAG,YAAY,CAAC,iBAAiB,CAAC,CAAC;AAE/C,yBAAyB;AACzB,MAAM,CAAC,MAAM,eAAe,GAAgB;IAC1C,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EAAE,oFAAoF;IACjG,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,EAAE,EAAE;gBACF,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,wEAAwE;aACtF;YACD,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,4CAA4C;aAC1D;YACD,QAAQ,EAAE;gBACR,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACzB,WAAW,EAAE,iDAAiD;gBAC9D,QAAQ,EAAE,IAAI;aACf;YACD,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,oCAAoC;gBACjD,QAAQ,EAAE,IAAI;aACf;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,mDAAmD;gBAChE,QAAQ,EAAE,IAAI;aACf;S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WAAW;IACX,aAAa;IACb,iBAAiB;IACjB,WAAW;IACX,GAAG,sBAAsB;CAC1B,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ToolHandler } from '../server.js';
|
|
2
|
+
export declare const getSessionStatus: ToolHandler;
|
|
3
|
+
export declare const getQRCode: ToolHandler;
|
|
4
|
+
export declare const getQRCodeImage: ToolHandler;
|
|
5
|
+
export declare const getPairCode: ToolHandler;
|
|
6
|
+
export declare const logout: ToolHandler;
|
|
7
|
+
export declare const sessionTools: {
|
|
8
|
+
getSessionStatus: ToolHandler;
|
|
9
|
+
getQRCode: ToolHandler;
|
|
10
|
+
getQRCodeImage: ToolHandler;
|
|
11
|
+
getPairCode: ToolHandler;
|
|
12
|
+
logout: ToolHandler;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/tools/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAOhD,eAAO,MAAM,gBAAgB,EAAE,WAS9B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,WASvB,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,WAS5B,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,WAczB,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,WASpB,CAAC;AAEF,eAAO,MAAM,YAAY;;;;;;CAAuE,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { wsapiClient } from '../client/index.js';
|
|
2
|
+
import { createLogger } from '../utils/logger.js';
|
|
3
|
+
import { validateInput, getSessionLoginCodeSchema } from '../validation/schemas.js';
|
|
4
|
+
const logger = createLogger('session-tools');
|
|
5
|
+
export const getSessionStatus = {
|
|
6
|
+
name: 'whatsapp_get_session_status',
|
|
7
|
+
description: 'Get current WhatsApp session status.',
|
|
8
|
+
inputSchema: { type: 'object', properties: {} },
|
|
9
|
+
handler: async () => {
|
|
10
|
+
logger.info('Getting session status');
|
|
11
|
+
const result = await wsapiClient.get('/session/status');
|
|
12
|
+
return { success: true, status: result, message: 'Session status retrieved successfully' };
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
export const getQRCode = {
|
|
16
|
+
name: 'whatsapp_get_qr_code',
|
|
17
|
+
description: 'Get QR code for WhatsApp login.',
|
|
18
|
+
inputSchema: { type: 'object', properties: {} },
|
|
19
|
+
handler: async () => {
|
|
20
|
+
logger.info('Getting QR code');
|
|
21
|
+
const result = await wsapiClient.get('/session/login/qr/code');
|
|
22
|
+
return { success: true, qrCode: result, message: 'QR code retrieved successfully' };
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
export const getQRCodeImage = {
|
|
26
|
+
name: 'whatsapp_get_qr_code_image',
|
|
27
|
+
description: 'Get QR code image for WhatsApp login.',
|
|
28
|
+
inputSchema: { type: 'object', properties: {} },
|
|
29
|
+
handler: async () => {
|
|
30
|
+
logger.info('Getting QR code image');
|
|
31
|
+
const result = await wsapiClient.get('/session/login/qr/image');
|
|
32
|
+
return { success: true, image: result, message: 'QR code image retrieved successfully' };
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
export const getPairCode = {
|
|
36
|
+
name: 'whatsapp_get_pair_code',
|
|
37
|
+
description: 'Get pairing code for WhatsApp login.',
|
|
38
|
+
inputSchema: {
|
|
39
|
+
type: 'object',
|
|
40
|
+
properties: { phone: { type: 'string', description: 'Phone number (10-15 digits)' } },
|
|
41
|
+
required: ['phone'],
|
|
42
|
+
},
|
|
43
|
+
handler: async (args) => {
|
|
44
|
+
const input = validateInput(getSessionLoginCodeSchema, args);
|
|
45
|
+
logger.info('Getting pair code', { phone: input.phone });
|
|
46
|
+
const result = await wsapiClient.get(`/session/login/code/${input.phone}`);
|
|
47
|
+
return { success: true, pairCode: result, message: 'Pair code retrieved successfully' };
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
export const logout = {
|
|
51
|
+
name: 'whatsapp_logout',
|
|
52
|
+
description: 'Logout from WhatsApp.',
|
|
53
|
+
inputSchema: { type: 'object', properties: {} },
|
|
54
|
+
handler: async () => {
|
|
55
|
+
logger.info('Logging out');
|
|
56
|
+
await wsapiClient.post('/session/logout', {});
|
|
57
|
+
return { success: true, message: 'Logged out successfully' };
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
export const sessionTools = { getSessionStatus, getQRCode, getQRCodeImage, getPairCode, logout };
|
|
61
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/tools/session.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAEpF,MAAM,MAAM,GAAG,YAAY,CAAC,eAAe,CAAC,CAAC;AAE7C,MAAM,CAAC,MAAM,gBAAgB,GAAgB;IAC3C,IAAI,EAAE,6BAA6B;IACnC,WAAW,EAAE,sCAAsC;IACnD,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE;IAC/C,OAAO,EAAE,KAAK,IAAI,EAAE;QAClB,MAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;QACtC,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QACxD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,uCAAuC,EAAE,CAAC;IAC7F,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAgB;IACpC,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EAAE,iCAAiC;I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