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