@wsapichat/mcp-server 1.0.5 → 2.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.
Files changed (80) hide show
  1. package/README.md +53 -338
  2. package/dist/client/index.d.ts +0 -1
  3. package/dist/client/index.d.ts.map +1 -1
  4. package/dist/client/index.js +1 -5
  5. package/dist/client/index.js.map +1 -1
  6. package/dist/config/index.d.ts +18 -53
  7. package/dist/config/index.d.ts.map +1 -1
  8. package/dist/config/index.js +5 -1
  9. package/dist/config/index.js.map +1 -1
  10. package/dist/server.d.ts.map +1 -1
  11. package/dist/server.js +70 -24
  12. package/dist/server.js.map +1 -1
  13. package/dist/tools/calls.d.ts +6 -0
  14. package/dist/tools/calls.d.ts.map +1 -0
  15. package/dist/tools/calls.js +24 -0
  16. package/dist/tools/calls.js.map +1 -0
  17. package/dist/tools/chats.d.ts +18 -0
  18. package/dist/tools/chats.d.ts.map +1 -1
  19. package/dist/tools/chats.js +156 -8
  20. package/dist/tools/chats.js.map +1 -1
  21. package/dist/tools/communities.d.ts +36 -0
  22. package/dist/tools/communities.d.ts.map +1 -0
  23. package/dist/tools/communities.js +263 -0
  24. package/dist/tools/communities.js.map +1 -0
  25. package/dist/tools/contacts.d.ts +8 -8
  26. package/dist/tools/contacts.d.ts.map +1 -1
  27. package/dist/tools/contacts.js +53 -158
  28. package/dist/tools/contacts.js.map +1 -1
  29. package/dist/tools/groups.d.ts +32 -0
  30. package/dist/tools/groups.d.ts.map +1 -1
  31. package/dist/tools/groups.js +272 -11
  32. package/dist/tools/groups.js.map +1 -1
  33. package/dist/tools/media.d.ts +6 -0
  34. package/dist/tools/media.d.ts.map +1 -0
  35. package/dist/tools/media.js +23 -0
  36. package/dist/tools/media.js.map +1 -0
  37. package/dist/tools/messaging-advanced.d.ts.map +1 -1
  38. package/dist/tools/messaging-advanced.js +79 -295
  39. package/dist/tools/messaging-advanced.js.map +1 -1
  40. package/dist/tools/messaging.d.ts +4 -0
  41. package/dist/tools/messaging.d.ts.map +1 -1
  42. package/dist/tools/messaging.js +150 -337
  43. package/dist/tools/messaging.js.map +1 -1
  44. package/dist/tools/newsletters.d.ts +16 -0
  45. package/dist/tools/newsletters.d.ts.map +1 -0
  46. package/dist/tools/newsletters.js +102 -0
  47. package/dist/tools/newsletters.js.map +1 -0
  48. package/dist/tools/session.d.ts +2 -0
  49. package/dist/tools/session.d.ts.map +1 -1
  50. package/dist/tools/session.js +18 -8
  51. package/dist/tools/session.js.map +1 -1
  52. package/dist/tools/status.d.ts +14 -0
  53. package/dist/tools/status.d.ts.map +1 -0
  54. package/dist/tools/status.js +86 -0
  55. package/dist/tools/status.js.map +1 -0
  56. package/dist/tools/users.d.ts +20 -0
  57. package/dist/tools/users.d.ts.map +1 -0
  58. package/dist/tools/users.js +129 -0
  59. package/dist/tools/users.js.map +1 -0
  60. package/dist/types/api.d.ts +4503 -1726
  61. package/dist/types/api.d.ts.map +1 -1
  62. package/dist/utils/logger.js +3 -3
  63. package/dist/utils/logger.js.map +1 -1
  64. package/dist/validation/schemas.d.ts +309 -650
  65. package/dist/validation/schemas.d.ts.map +1 -1
  66. package/dist/validation/schemas.js +209 -144
  67. package/dist/validation/schemas.js.map +1 -1
  68. package/package.json +24 -25
  69. package/dist/tools/account.d.ts +0 -14
  70. package/dist/tools/account.d.ts.map +0 -1
  71. package/dist/tools/account.js +0 -78
  72. package/dist/tools/account.js.map +0 -1
  73. package/dist/tools/instance.d.ts +0 -12
  74. package/dist/tools/instance.d.ts.map +0 -1
  75. package/dist/tools/instance.js +0 -54
  76. package/dist/tools/instance.js.map +0 -1
  77. package/dist/types/webhooks.d.ts +0 -1001
  78. package/dist/types/webhooks.d.ts.map +0 -1
  79. package/dist/types/webhooks.js +0 -6
  80. package/dist/types/webhooks.js.map +0 -1
@@ -1,38 +1,20 @@
1
1
  import { wsapiClient } from '../client/index.js';
2
2
  import { createLogger } from '../utils/logger.js';
3
- import { validateInput, sendTextMessageSchema, sendImageMessageSchema, sendVideoMessageSchema, sendLinkMessageSchema, sendReactionMessageSchema, editMessageSchema, deleteMessageSchema, markMessageAsReadSchema, starMessageSchema, } from '../validation/schemas.js';
3
+ import { validateInput, sendTextMessageSchema, sendMediaMessageSchema, sendLinkMessageSchema, sendReactionMessageSchema, editMessageSchema, deleteMessageSchema, deleteMessageForMeSchema, markMessageAsReadSchema, starMessageSchema, pinMessageSchema, } from '../validation/schemas.js';
4
4
  const logger = createLogger('messaging-tools');
5
- // Send text message tool
6
5
  export const sendTextMessage = {
7
6
  name: 'whatsapp_send_text',
8
- description: 'Send a text message to a WhatsApp contact or group. Supports mentions and replies.',
7
+ description: 'Send a text message to a WhatsApp contact or group. Supports mentions, replies, and ephemeral expiration.',
9
8
  inputSchema: {
10
9
  type: 'object',
11
10
  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
- },
11
+ to: { type: 'string', description: 'Recipient JID (user or group)' },
12
+ text: { type: 'string', description: 'Message text content (max 4096 characters)' },
13
+ mentions: { type: 'array', items: { type: 'string' }, description: 'JIDs of mentioned users' },
14
+ replyTo: { type: 'string', description: 'ID of the message being replied to' },
15
+ replyToSenderId: { type: 'string', description: 'Sender JID of the message being replied to' },
16
+ isForwarded: { type: 'boolean', description: 'Mark as forwarded' },
17
+ ephemeralExpiration: { type: 'string', enum: ['off', '24h', '7d', '90d'], description: 'Disappearing message timer' },
36
18
  },
37
19
  required: ['to', 'text'],
38
20
  },
@@ -41,441 +23,270 @@ export const sendTextMessage = {
41
23
  logger.info('Sending text message', { to: input.to, textLength: input.text.length });
42
24
  const result = await wsapiClient.post('/messages/text', input);
43
25
  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
- };
26
+ return { success: true, messageId: result.id, message: 'Text message sent successfully' };
49
27
  },
50
28
  };
51
- // Send image message tool
52
29
  export const sendImageMessage = {
53
30
  name: 'whatsapp_send_image',
54
- description: 'Send an image message to a WhatsApp contact or group. Can send from URL or base64.',
31
+ description: 'Send an image message. Provide either data (base64) or url.',
55
32
  inputSchema: {
56
33
  type: 'object',
57
34
  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
- },
35
+ to: { type: 'string', description: 'Recipient JID' },
36
+ data: { type: 'string', description: 'Base64 encoded image data' },
37
+ url: { type: 'string', description: 'URL of the image' },
38
+ mimeType: { type: 'string', description: 'MIME type (auto-detected if omitted)' },
39
+ caption: { type: 'string', description: 'Caption for the image' },
40
+ mentions: { type: 'array', items: { type: 'string' }, description: 'JIDs of mentioned users' },
41
+ replyTo: { type: 'string', description: 'Message ID to reply to' },
42
+ replyToSenderId: { type: 'string', description: 'Sender JID of the replied message' },
43
+ isForwarded: { type: 'boolean', description: 'Mark as forwarded' },
44
+ viewOnce: { type: 'boolean', description: 'Send as view-once' },
45
+ ephemeralExpiration: { type: 'string', enum: ['off', '24h', '7d', '90d'] },
103
46
  },
104
- required: ['to', 'mimeType'],
47
+ required: ['to'],
105
48
  },
106
49
  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
- });
50
+ const input = validateInput(sendMediaMessageSchema, args);
51
+ logger.info('Sending image message', { to: input.to, hasCaption: !!input.caption });
114
52
  const result = await wsapiClient.post('/messages/image', input);
115
53
  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
- };
54
+ return { success: true, messageId: result.id, message: 'Image message sent successfully' };
121
55
  },
122
56
  };
123
- // Send video message tool
124
57
  export const sendVideoMessage = {
125
58
  name: 'whatsapp_send_video',
126
- description: 'Send a video message to a WhatsApp contact or group. Can send from URL or base64.',
59
+ description: 'Send a video message. Provide either data (base64) or url.',
127
60
  inputSchema: {
128
61
  type: 'object',
129
62
  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
- },
63
+ to: { type: 'string', description: 'Recipient JID' },
64
+ data: { type: 'string', description: 'Base64 encoded video data' },
65
+ url: { type: 'string', description: 'URL of the video' },
66
+ mimeType: { type: 'string', description: 'MIME type (auto-detected if omitted)' },
67
+ caption: { type: 'string', description: 'Caption for the video' },
68
+ mentions: { type: 'array', items: { type: 'string' } },
69
+ replyTo: { type: 'string', description: 'Message ID to reply to' },
70
+ replyToSenderId: { type: 'string', description: 'Sender JID of the replied message' },
71
+ isForwarded: { type: 'boolean' },
72
+ viewOnce: { type: 'boolean', description: 'Send as view-once' },
73
+ ephemeralExpiration: { type: 'string', enum: ['off', '24h', '7d', '90d'] },
175
74
  },
176
- required: ['to', 'mimeType'],
75
+ required: ['to'],
177
76
  },
178
77
  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
- });
78
+ const input = validateInput(sendMediaMessageSchema, args);
79
+ logger.info('Sending video message', { to: input.to });
186
80
  const result = await wsapiClient.post('/messages/video', input);
187
81
  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
- };
82
+ return { success: true, messageId: result.id, message: 'Video message sent successfully' };
193
83
  },
194
84
  };
195
- // Send link message tool
196
85
  export const sendLinkMessage = {
197
86
  name: 'whatsapp_send_link',
198
- description: 'Send a link message with optional preview to a WhatsApp contact or group.',
87
+ description: 'Send a link message with optional preview.',
199
88
  inputSchema: {
200
89
  type: 'object',
201
90
  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
- },
91
+ to: { type: 'string', description: 'Recipient JID' },
92
+ text: { type: 'string', description: 'Message text (max 4096 characters)' },
93
+ url: { type: 'string', description: 'URL to include' },
94
+ title: { type: 'string', description: 'Link preview title' },
95
+ description: { type: 'string', description: 'Link preview description' },
96
+ jpegThumbnail: { type: 'string', description: 'Base64 JPEG thumbnail' },
97
+ mentions: { type: 'array', items: { type: 'string' } },
98
+ replyTo: { type: 'string' },
99
+ replyToSenderId: { type: 'string' },
100
+ isForwarded: { type: 'boolean' },
101
+ ephemeralExpiration: { type: 'string', enum: ['off', '24h', '7d', '90d'] },
245
102
  },
246
103
  required: ['to', 'text', 'url'],
247
104
  },
248
105
  handler: async (args) => {
249
106
  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
- });
107
+ logger.info('Sending link message', { to: input.to, url: input.url });
256
108
  const result = await wsapiClient.post('/messages/link', input);
257
109
  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
- };
110
+ return { success: true, messageId: result.id, message: 'Link message sent successfully' };
263
111
  },
264
112
  };
265
- // Send reaction message tool
266
113
  export const sendReactionMessage = {
267
114
  name: 'whatsapp_send_reaction',
268
- description: 'Send a reaction (emoji) to a specific message.',
115
+ description: 'Send a reaction (emoji) to a message. Send empty string to remove reaction.',
269
116
  inputSchema: {
270
117
  type: 'object',
271
118
  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
- },
119
+ messageId: { type: 'string', description: 'ID of the message to react to' },
120
+ to: { type: 'string', description: 'Chat JID' },
121
+ senderId: { type: 'string', description: 'Sender of the original message (for groups)' },
122
+ reaction: { type: 'string', description: 'Emoji reaction (empty string to remove)' },
288
123
  },
289
- required: ['messageId', 'to', 'senderId', 'reaction'],
124
+ required: ['messageId', 'to', 'reaction'],
290
125
  },
291
126
  handler: async (args) => {
292
127
  const input = validateInput(sendReactionMessageSchema, args);
293
- logger.info('Sending reaction', {
294
- messageId: input.messageId,
295
- to: input.to,
296
- reaction: input.reaction,
297
- });
128
+ logger.info('Sending reaction', { messageId: input.messageId, to: input.to });
298
129
  const result = await wsapiClient.post(`/messages/${input.messageId}/reaction`, {
299
130
  to: input.to,
300
131
  senderId: input.senderId,
301
132
  reaction: input.reaction,
302
133
  });
303
- logger.info('Reaction sent successfully', { messageId: result.id });
304
- return {
305
- success: true,
306
- messageId: result.id,
307
- message: 'Reaction sent successfully',
308
- };
134
+ logger.info('Reaction sent successfully');
135
+ return { success: true, messageId: result.id, message: 'Reaction sent successfully' };
309
136
  },
310
137
  };
311
- // Edit message tool
312
138
  export const editMessage = {
313
139
  name: 'whatsapp_edit_message',
314
140
  description: 'Edit a previously sent text message.',
315
141
  inputSchema: {
316
142
  type: 'object',
317
143
  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
- },
144
+ messageId: { type: 'string', description: 'ID of the message to edit' },
145
+ to: { type: 'string', description: 'Chat JID' },
146
+ text: { type: 'string', description: 'New text content (max 4096 characters)' },
147
+ mentions: { type: 'array', items: { type: 'string' } },
148
+ ephemeralExpiration: { type: 'string', enum: ['off', '24h', '7d', '90d'] },
330
149
  },
331
150
  required: ['messageId', 'to', 'text'],
332
151
  },
333
152
  handler: async (args) => {
334
153
  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`, {
154
+ logger.info('Editing message', { messageId: input.messageId });
155
+ const result = await wsapiClient.post(`/messages/${input.messageId}/edit`, {
341
156
  to: input.to,
342
157
  text: input.text,
158
+ mentions: input.mentions,
159
+ ephemeralExpiration: input.ephemeralExpiration,
343
160
  });
344
- logger.info('Message edited successfully', { messageId: result.id });
345
- return {
346
- success: true,
347
- messageId: result.id,
348
- message: 'Message edited successfully',
349
- };
161
+ logger.info('Message edited successfully');
162
+ return { success: true, messageId: result.id, message: 'Message edited successfully' };
350
163
  },
351
164
  };
352
- // Delete message tool
353
165
  export const deleteMessage = {
354
166
  name: 'whatsapp_delete_message',
355
- description: 'Delete a message for all participants in the chat.',
167
+ description: 'Delete a message for all participants.',
356
168
  inputSchema: {
357
169
  type: 'object',
358
170
  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
- },
171
+ messageId: { type: 'string', description: 'ID of the message to delete' },
172
+ chatId: { type: 'string', description: 'Chat JID' },
173
+ senderId: { type: 'string', description: 'Message sender JID' },
371
174
  },
372
175
  required: ['messageId', 'chatId', 'senderId'],
373
176
  },
374
177
  handler: async (args) => {
375
178
  const input = validateInput(deleteMessageSchema, args);
376
- logger.info('Deleting message', {
377
- messageId: input.messageId,
179
+ logger.info('Deleting message', { messageId: input.messageId });
180
+ await wsapiClient.post(`/messages/${input.messageId}/delete`, {
378
181
  chatId: input.chatId,
182
+ senderId: input.senderId,
379
183
  });
380
- await wsapiClient.put(`/messages/${input.messageId}/delete`, {
184
+ logger.info('Message deleted successfully');
185
+ return { success: true, message: 'Message deleted successfully' };
186
+ },
187
+ };
188
+ export const deleteMessageForMe = {
189
+ name: 'whatsapp_delete_message_for_me',
190
+ description: 'Delete a message only for yourself.',
191
+ inputSchema: {
192
+ type: 'object',
193
+ properties: {
194
+ messageId: { type: 'string', description: 'ID of the message to delete' },
195
+ chatId: { type: 'string', description: 'Chat JID' },
196
+ senderId: { type: 'string', description: 'Message sender JID' },
197
+ isFromMe: { type: 'boolean', description: 'Whether the message was sent by you' },
198
+ timestamp: { type: 'string', description: 'Message timestamp (ISO 8601)' },
199
+ },
200
+ required: ['messageId', 'chatId'],
201
+ },
202
+ handler: async (args) => {
203
+ const input = validateInput(deleteMessageForMeSchema, args);
204
+ logger.info('Deleting message for me', { messageId: input.messageId });
205
+ await wsapiClient.post(`/messages/${input.messageId}/delete-for-me`, {
381
206
  chatId: input.chatId,
382
207
  senderId: input.senderId,
208
+ isFromMe: input.isFromMe,
209
+ timestamp: input.timestamp,
383
210
  });
384
- logger.info('Message deleted successfully', { messageId: input.messageId });
385
- return {
386
- success: true,
387
- message: 'Message deleted successfully',
388
- };
211
+ logger.info('Message deleted for me successfully');
212
+ return { success: true, message: 'Message deleted for me successfully' };
389
213
  },
390
214
  };
391
- // Mark message as read tool
392
215
  export const markMessageAsRead = {
393
216
  name: 'whatsapp_mark_message_read',
394
217
  description: 'Mark a message as read.',
395
218
  inputSchema: {
396
219
  type: 'object',
397
220
  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
- },
221
+ messageId: { type: 'string', description: 'Message ID' },
222
+ chatId: { type: 'string', description: 'Chat JID' },
223
+ senderId: { type: 'string', description: 'Message sender JID' },
224
+ receiptType: { type: 'string', enum: ['delivered', 'sender', 'read', 'played'], description: 'Receipt type' },
415
225
  },
416
226
  required: ['messageId', 'chatId', 'senderId', 'receiptType'],
417
227
  },
418
228
  handler: async (args) => {
419
229
  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`, {
230
+ logger.info('Marking message as read', { messageId: input.messageId });
231
+ await wsapiClient.post(`/messages/${input.messageId}/read`, {
426
232
  chatId: input.chatId,
427
233
  senderId: input.senderId,
428
234
  receiptType: input.receiptType,
429
235
  });
430
- logger.info('Message marked as read successfully', { messageId: input.messageId });
431
- return {
432
- success: true,
433
- message: 'Message marked as read successfully',
434
- };
236
+ return { success: true, message: 'Message marked as read successfully' };
435
237
  },
436
238
  };
437
- // Star message tool
438
239
  export const starMessage = {
439
240
  name: 'whatsapp_star_message',
440
241
  description: 'Star or unstar a message.',
441
242
  inputSchema: {
442
243
  type: 'object',
443
244
  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
- },
245
+ messageId: { type: 'string', description: 'Message ID' },
246
+ chatId: { type: 'string', description: 'Chat JID' },
247
+ senderId: { type: 'string', description: 'Message sender JID' },
248
+ starred: { type: 'boolean', description: 'True to star, false to unstar' },
456
249
  },
457
250
  required: ['messageId', 'chatId', 'senderId'],
458
251
  },
459
252
  handler: async (args) => {
460
253
  const input = validateInput(starMessageSchema, args);
461
- logger.info('Starring message', {
462
- messageId: input.messageId,
254
+ logger.info('Starring message', { messageId: input.messageId });
255
+ await wsapiClient.post(`/messages/${input.messageId}/star`, {
463
256
  chatId: input.chatId,
257
+ senderId: input.senderId,
258
+ starred: input.starred,
464
259
  });
465
- await wsapiClient.put(`/messages/${input.messageId}/star`, {
260
+ return { success: true, message: 'Message starred successfully' };
261
+ },
262
+ };
263
+ export const pinMessage = {
264
+ name: 'whatsapp_pin_message',
265
+ description: 'Pin or unpin a message in a chat.',
266
+ inputSchema: {
267
+ type: 'object',
268
+ properties: {
269
+ messageId: { type: 'string', description: 'Message ID' },
270
+ chatId: { type: 'string', description: 'Chat JID' },
271
+ senderId: { type: 'string', description: 'Message sender JID' },
272
+ pinned: { type: 'boolean', description: 'True to pin, false to unpin' },
273
+ pinExpiration: { type: 'string', description: 'Pin expiration (e.g. 24h, 7d, 30d)' },
274
+ },
275
+ required: ['messageId', 'chatId', 'senderId'],
276
+ },
277
+ handler: async (args) => {
278
+ const input = validateInput(pinMessageSchema, args);
279
+ logger.info('Pinning message', { messageId: input.messageId });
280
+ await wsapiClient.post(`/messages/${input.messageId}/pin`, {
466
281
  chatId: input.chatId,
467
282
  senderId: input.senderId,
283
+ pinned: input.pinned,
284
+ pinExpiration: input.pinExpiration,
468
285
  });
469
- logger.info('Message starred successfully', { messageId: input.messageId });
470
- return {
471
- success: true,
472
- message: 'Message starred successfully',
473
- };
286
+ return { success: true, message: 'Message pin updated successfully' };
474
287
  },
475
288
  };
476
- // Import advanced messaging tools
477
289
  import { advancedMessagingTools } from './messaging-advanced.js';
478
- // Export all messaging tools
479
290
  export const messagingTools = {
480
291
  sendTextMessage,
481
292
  sendImageMessage,
@@ -484,8 +295,10 @@ export const messagingTools = {
484
295
  sendReactionMessage,
485
296
  editMessage,
486
297
  deleteMessage,
298
+ deleteMessageForMe,
487
299
  markMessageAsRead,
488
300
  starMessage,
301
+ pinMessage,
489
302
  ...advancedMessagingTools,
490
303
  };
491
304
  //# sourceMappingURL=messaging.js.map