@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
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import { wsapiClient } from "../client/index.js";
|
|
2
|
+
import { createLogger } from "../utils/logger.js";
|
|
3
|
+
import { validateInput, createCommunitySchema, getCommunitySchema, updateGroupNameSchema, updateGroupDescriptionSchema, setGroupPictureSchema, setBoolSettingSchema, updateGroupParticipantsSchema, createCommunityGroupSchema, linkGroupToCommunitySchema, unlinkCommunityGroupSchema, } from "../validation/schemas.js";
|
|
4
|
+
const logger = createLogger("community-tools");
|
|
5
|
+
export const listCommunities = {
|
|
6
|
+
name: "whatsapp_list_communities",
|
|
7
|
+
description: "List all joined communities.",
|
|
8
|
+
inputSchema: { type: "object", properties: {} },
|
|
9
|
+
handler: async () => {
|
|
10
|
+
logger.info("Listing communities");
|
|
11
|
+
const result = await wsapiClient.get("/communities");
|
|
12
|
+
return { success: true, communities: result, count: result.length };
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
export const createCommunity = {
|
|
16
|
+
name: "whatsapp_create_community",
|
|
17
|
+
description: "Create a new WhatsApp community.",
|
|
18
|
+
inputSchema: {
|
|
19
|
+
type: "object",
|
|
20
|
+
properties: {
|
|
21
|
+
name: { type: "string", description: "Community name" },
|
|
22
|
+
participants: {
|
|
23
|
+
type: "array",
|
|
24
|
+
items: { type: "string" },
|
|
25
|
+
description: "Initial participant JIDs",
|
|
26
|
+
},
|
|
27
|
+
approvalMode: { type: "string", description: "Join approval mode" },
|
|
28
|
+
},
|
|
29
|
+
required: ["name"],
|
|
30
|
+
},
|
|
31
|
+
handler: async (args) => {
|
|
32
|
+
const input = validateInput(createCommunitySchema, args);
|
|
33
|
+
logger.info("Creating community", { name: input.name });
|
|
34
|
+
const result = await wsapiClient.post("/communities", input);
|
|
35
|
+
return {
|
|
36
|
+
success: true,
|
|
37
|
+
communityId: result.id,
|
|
38
|
+
message: "Community created",
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
export const getCommunity = {
|
|
43
|
+
name: "whatsapp_get_community",
|
|
44
|
+
description: "Get community info.",
|
|
45
|
+
inputSchema: {
|
|
46
|
+
type: "object",
|
|
47
|
+
properties: { id: { type: "string", description: "Community JID" } },
|
|
48
|
+
required: ["id"],
|
|
49
|
+
},
|
|
50
|
+
handler: async (args) => {
|
|
51
|
+
const input = validateInput(getCommunitySchema, args);
|
|
52
|
+
const result = await wsapiClient.get(`/communities/${input.id}`);
|
|
53
|
+
return { success: true, community: result };
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
export const leaveCommunity = {
|
|
57
|
+
name: "whatsapp_leave_community",
|
|
58
|
+
description: "Leave a community.",
|
|
59
|
+
inputSchema: {
|
|
60
|
+
type: "object",
|
|
61
|
+
properties: { id: { type: "string", description: "Community JID" } },
|
|
62
|
+
required: ["id"],
|
|
63
|
+
},
|
|
64
|
+
handler: async (args) => {
|
|
65
|
+
const input = validateInput(getCommunitySchema, args);
|
|
66
|
+
await wsapiClient.post(`/communities/${input.id}/leave`, {});
|
|
67
|
+
return { success: true, message: "Left community" };
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
export const setCommunityName = {
|
|
71
|
+
name: "whatsapp_set_community_name",
|
|
72
|
+
description: "Set community name.",
|
|
73
|
+
inputSchema: {
|
|
74
|
+
type: "object",
|
|
75
|
+
properties: {
|
|
76
|
+
id: { type: "string", description: "Community JID" },
|
|
77
|
+
name: { type: "string", description: "New name" },
|
|
78
|
+
},
|
|
79
|
+
required: ["id", "name"],
|
|
80
|
+
},
|
|
81
|
+
handler: async (args) => {
|
|
82
|
+
const input = validateInput(updateGroupNameSchema, args);
|
|
83
|
+
await wsapiClient.put(`/communities/${input.id}/name`, {
|
|
84
|
+
name: input.name,
|
|
85
|
+
});
|
|
86
|
+
return { success: true, message: "Community name updated" };
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
export const setCommunityDescription = {
|
|
90
|
+
name: "whatsapp_set_community_description",
|
|
91
|
+
description: "Set community description.",
|
|
92
|
+
inputSchema: {
|
|
93
|
+
type: "object",
|
|
94
|
+
properties: {
|
|
95
|
+
id: { type: "string", description: "Community JID" },
|
|
96
|
+
description: { type: "string", description: "New description" },
|
|
97
|
+
},
|
|
98
|
+
required: ["id"],
|
|
99
|
+
},
|
|
100
|
+
handler: async (args) => {
|
|
101
|
+
const input = validateInput(updateGroupDescriptionSchema, args);
|
|
102
|
+
await wsapiClient.put(`/communities/${input.id}/description`, {
|
|
103
|
+
description: input.description,
|
|
104
|
+
});
|
|
105
|
+
return { success: true, message: "Community description updated" };
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
export const setCommunityPicture = {
|
|
109
|
+
name: "whatsapp_set_community_picture",
|
|
110
|
+
description: "Set community profile picture.",
|
|
111
|
+
inputSchema: {
|
|
112
|
+
type: "object",
|
|
113
|
+
properties: {
|
|
114
|
+
id: { type: "string", description: "Community JID" },
|
|
115
|
+
data: { type: "string", description: "Base64-encoded JPEG image" },
|
|
116
|
+
},
|
|
117
|
+
required: ["id", "data"],
|
|
118
|
+
},
|
|
119
|
+
handler: async (args) => {
|
|
120
|
+
const input = validateInput(setGroupPictureSchema, args);
|
|
121
|
+
const result = await wsapiClient.post(`/communities/${input.id}/picture`, {
|
|
122
|
+
data: input.data,
|
|
123
|
+
});
|
|
124
|
+
return {
|
|
125
|
+
success: true,
|
|
126
|
+
pictureId: result.pictureId,
|
|
127
|
+
message: "Community picture updated",
|
|
128
|
+
};
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
export const setCommunityLocked = {
|
|
132
|
+
name: "whatsapp_set_community_locked",
|
|
133
|
+
description: "Set community locked mode (only admins can edit info).",
|
|
134
|
+
inputSchema: {
|
|
135
|
+
type: "object",
|
|
136
|
+
properties: {
|
|
137
|
+
id: { type: "string", description: "Community JID" },
|
|
138
|
+
enabled: { type: "boolean", description: "Enable or disable" },
|
|
139
|
+
},
|
|
140
|
+
required: ["id", "enabled"],
|
|
141
|
+
},
|
|
142
|
+
handler: async (args) => {
|
|
143
|
+
const input = validateInput(setBoolSettingSchema, args);
|
|
144
|
+
await wsapiClient.put(`/communities/${input.id}/settings/locked`, {
|
|
145
|
+
enabled: input.enabled,
|
|
146
|
+
});
|
|
147
|
+
return { success: true, message: "Community locked mode updated" };
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
export const getCommunityParticipants = {
|
|
151
|
+
name: "whatsapp_get_community_participants",
|
|
152
|
+
description: "Get community participants.",
|
|
153
|
+
inputSchema: {
|
|
154
|
+
type: "object",
|
|
155
|
+
properties: { id: { type: "string", description: "Community JID" } },
|
|
156
|
+
required: ["id"],
|
|
157
|
+
},
|
|
158
|
+
handler: async (args) => {
|
|
159
|
+
const input = validateInput(getCommunitySchema, args);
|
|
160
|
+
const result = await wsapiClient.get(`/communities/${input.id}/participants`);
|
|
161
|
+
return { success: true, participants: result };
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
export const updateCommunityParticipants = {
|
|
165
|
+
name: "whatsapp_update_community_participants",
|
|
166
|
+
description: "Add, remove, promote, or demote community participants.",
|
|
167
|
+
inputSchema: {
|
|
168
|
+
type: "object",
|
|
169
|
+
properties: {
|
|
170
|
+
id: { type: "string", description: "Community JID" },
|
|
171
|
+
participants: {
|
|
172
|
+
type: "array",
|
|
173
|
+
items: { type: "string" },
|
|
174
|
+
description: "Participant JIDs",
|
|
175
|
+
},
|
|
176
|
+
action: {
|
|
177
|
+
type: "string",
|
|
178
|
+
enum: ["add", "remove", "promote", "demote"],
|
|
179
|
+
description: "Action",
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
required: ["id", "participants", "action"],
|
|
183
|
+
},
|
|
184
|
+
handler: async (args) => {
|
|
185
|
+
const input = validateInput(updateGroupParticipantsSchema, args);
|
|
186
|
+
await wsapiClient.put(`/communities/${input.id}/participants`, {
|
|
187
|
+
participants: input.participants,
|
|
188
|
+
action: input.action,
|
|
189
|
+
});
|
|
190
|
+
return { success: true, message: "Community participants updated" };
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
export const getCommunityInviteLink = {
|
|
194
|
+
name: "whatsapp_get_community_invite_link",
|
|
195
|
+
description: "Get community invite link.",
|
|
196
|
+
inputSchema: {
|
|
197
|
+
type: "object",
|
|
198
|
+
properties: { id: { type: "string", description: "Community JID" } },
|
|
199
|
+
required: ["id"],
|
|
200
|
+
},
|
|
201
|
+
handler: async (args) => {
|
|
202
|
+
const input = validateInput(getCommunitySchema, args);
|
|
203
|
+
const result = await wsapiClient.get(`/communities/${input.id}/invite-link`);
|
|
204
|
+
return { success: true, link: result.link };
|
|
205
|
+
},
|
|
206
|
+
};
|
|
207
|
+
export const resetCommunityInviteLink = {
|
|
208
|
+
name: "whatsapp_reset_community_invite_link",
|
|
209
|
+
description: "Reset community invite link.",
|
|
210
|
+
inputSchema: {
|
|
211
|
+
type: "object",
|
|
212
|
+
properties: { id: { type: "string", description: "Community JID" } },
|
|
213
|
+
required: ["id"],
|
|
214
|
+
},
|
|
215
|
+
handler: async (args) => {
|
|
216
|
+
const input = validateInput(getCommunitySchema, args);
|
|
217
|
+
const result = await wsapiClient.post(`/communities/${input.id}/invite-link/reset`, {});
|
|
218
|
+
return { success: true, link: result.link };
|
|
219
|
+
},
|
|
220
|
+
};
|
|
221
|
+
export const getCommunitySubGroups = {
|
|
222
|
+
name: "whatsapp_get_community_sub_groups",
|
|
223
|
+
description: "Get community sub-groups.",
|
|
224
|
+
inputSchema: {
|
|
225
|
+
type: "object",
|
|
226
|
+
properties: { id: { type: "string", description: "Community JID" } },
|
|
227
|
+
required: ["id"],
|
|
228
|
+
},
|
|
229
|
+
handler: async (args) => {
|
|
230
|
+
const input = validateInput(getCommunitySchema, args);
|
|
231
|
+
const result = await wsapiClient.get(`/communities/${input.id}/groups`);
|
|
232
|
+
return { success: true, groups: result };
|
|
233
|
+
},
|
|
234
|
+
};
|
|
235
|
+
export const createCommunityGroup = {
|
|
236
|
+
name: "whatsapp_create_community_group",
|
|
237
|
+
description: "Create a new sub-group inside a community.",
|
|
238
|
+
inputSchema: {
|
|
239
|
+
type: "object",
|
|
240
|
+
properties: {
|
|
241
|
+
id: { type: "string", description: "Community JID" },
|
|
242
|
+
name: { type: "string", description: "Group name" },
|
|
243
|
+
participants: {
|
|
244
|
+
type: "array",
|
|
245
|
+
items: { type: "string" },
|
|
246
|
+
description: "Participant JIDs",
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
required: ["id", "name"],
|
|
250
|
+
},
|
|
251
|
+
handler: async (args) => {
|
|
252
|
+
const input = validateInput(createCommunityGroupSchema, args);
|
|
253
|
+
const result = await wsapiClient.post(`/communities/${input.id}/groups`, {
|
|
254
|
+
name: input.name,
|
|
255
|
+
participants: input.participants,
|
|
256
|
+
});
|
|
257
|
+
return {
|
|
258
|
+
success: true,
|
|
259
|
+
groupId: result.id,
|
|
260
|
+
message: "Community group created",
|
|
261
|
+
};
|
|
262
|
+
},
|
|
263
|
+
};
|
|
264
|
+
export const linkGroupToCommunity = {
|
|
265
|
+
name: "whatsapp_link_group_to_community",
|
|
266
|
+
description: "Link an existing group to a community.",
|
|
267
|
+
inputSchema: {
|
|
268
|
+
type: "object",
|
|
269
|
+
properties: {
|
|
270
|
+
id: { type: "string", description: "Community JID" },
|
|
271
|
+
groupId: { type: "string", description: "Group JID to link" },
|
|
272
|
+
},
|
|
273
|
+
required: ["id", "groupId"],
|
|
274
|
+
},
|
|
275
|
+
handler: async (args) => {
|
|
276
|
+
const input = validateInput(linkGroupToCommunitySchema, args);
|
|
277
|
+
await wsapiClient.post(`/communities/${input.id}/groups/link`, {
|
|
278
|
+
groupId: input.groupId,
|
|
279
|
+
});
|
|
280
|
+
return { success: true, message: "Group linked to community" };
|
|
281
|
+
},
|
|
282
|
+
};
|
|
283
|
+
export const unlinkCommunityGroup = {
|
|
284
|
+
name: "whatsapp_unlink_community_group",
|
|
285
|
+
description: "Unlink a group from a community.",
|
|
286
|
+
inputSchema: {
|
|
287
|
+
type: "object",
|
|
288
|
+
properties: {
|
|
289
|
+
id: { type: "string", description: "Community JID" },
|
|
290
|
+
groupId: { type: "string", description: "Group JID to unlink" },
|
|
291
|
+
},
|
|
292
|
+
required: ["id", "groupId"],
|
|
293
|
+
},
|
|
294
|
+
handler: async (args) => {
|
|
295
|
+
const input = validateInput(unlinkCommunityGroupSchema, args);
|
|
296
|
+
await wsapiClient.delete(`/communities/${input.id}/groups/${input.groupId}`);
|
|
297
|
+
return { success: true, message: "Group unlinked from community" };
|
|
298
|
+
},
|
|
299
|
+
};
|
|
300
|
+
export const communityTools = {
|
|
301
|
+
listCommunities,
|
|
302
|
+
createCommunity,
|
|
303
|
+
getCommunity,
|
|
304
|
+
leaveCommunity,
|
|
305
|
+
setCommunityName,
|
|
306
|
+
setCommunityDescription,
|
|
307
|
+
setCommunityPicture,
|
|
308
|
+
setCommunityLocked,
|
|
309
|
+
getCommunityParticipants,
|
|
310
|
+
updateCommunityParticipants,
|
|
311
|
+
getCommunityInviteLink,
|
|
312
|
+
resetCommunityInviteLink,
|
|
313
|
+
getCommunitySubGroups,
|
|
314
|
+
createCommunityGroup,
|
|
315
|
+
linkGroupToCommunity,
|
|
316
|
+
unlinkCommunityGroup,
|
|
317
|
+
};
|
|
318
|
+
//# sourceMappingURL=communities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"communities.js","sourceRoot":"","sources":["../../src/tools/communities.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,kBAAkB,EAClB,qBAAqB,EACrB,4BAA4B,EAC5B,qBAAqB,EACrB,oBAAoB,EACpB,6BAA6B,EAC7B,0BAA0B,EAC1B,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,0BAA0B,CAAC;AAElC,MAAM,MAAM,GAAG,YAAY,CAAC,iBAAiB,CAAC,CAAC;AAE/C,MAAM,CAAC,MAAM,eAAe,GAAgB;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;IAChB,uBAAuB;IACvB,mBAAmB;IACnB,kBAAkB;IAClB,wBAAwB;IACxB,2BAA2B;IAC3B,sBAAsB;IACtB,wBAAwB;IACxB,qBAAqB;IACrB,oBAAoB;IACpB,oBAAoB;IACpB,oBAAoB;CACrB,CAAC"}
|
package/dist/tools/contacts.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import type { ToolHandler } from
|
|
1
|
+
import type { ToolHandler } from "../server.js";
|
|
2
2
|
export declare const getContacts: ToolHandler;
|
|
3
3
|
export declare const getContact: ToolHandler;
|
|
4
4
|
export declare const createContact: ToolHandler;
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
8
|
-
export declare const
|
|
5
|
+
export declare const syncContacts: ToolHandler;
|
|
6
|
+
export declare const getBlocklist: ToolHandler;
|
|
7
|
+
export declare const blockContact: ToolHandler;
|
|
8
|
+
export declare const unblockContact: ToolHandler;
|
|
9
9
|
export declare const contactTools: {
|
|
10
10
|
getContacts: ToolHandler;
|
|
11
11
|
getContact: ToolHandler;
|
|
12
12
|
createContact: ToolHandler;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
syncContacts: ToolHandler;
|
|
14
|
+
getBlocklist: ToolHandler;
|
|
15
|
+
blockContact: ToolHandler;
|
|
16
|
+
unblockContact: ToolHandler;
|
|
17
17
|
};
|
|
18
18
|
//# sourceMappingURL=contacts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contacts.d.ts","sourceRoot":"","sources":["../../src/tools/contacts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"contacts.d.ts","sourceRoot":"","sources":["../../src/tools/contacts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAYhD,eAAO,MAAM,WAAW,EAAE,WAczB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,WAkBxB,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,WAkB3B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,WAS1B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,WAa1B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,WAc1B,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,WAgB5B,CAAC;AAEF,eAAO,MAAM,YAAY;;;;;;;;CAQxB,CAAC"}
|
package/dist/tools/contacts.js
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
import { wsapiClient } from
|
|
2
|
-
import { createLogger } from
|
|
3
|
-
import { validateInput, getContactSchema, createContactSchema,
|
|
4
|
-
const logger = createLogger(
|
|
5
|
-
// Get contacts list tool
|
|
1
|
+
import { wsapiClient } from "../client/index.js";
|
|
2
|
+
import { createLogger } from "../utils/logger.js";
|
|
3
|
+
import { validateInput, getContactSchema, createContactSchema, blockContactSchema, } from "../validation/schemas.js";
|
|
4
|
+
const logger = createLogger("contact-tools");
|
|
6
5
|
export const getContacts = {
|
|
7
|
-
name:
|
|
8
|
-
description:
|
|
9
|
-
inputSchema: {
|
|
10
|
-
type: 'object',
|
|
11
|
-
properties: {},
|
|
12
|
-
},
|
|
6
|
+
name: "whatsapp_get_contacts",
|
|
7
|
+
description: "Get list of all WhatsApp contacts.",
|
|
8
|
+
inputSchema: { type: "object", properties: {} },
|
|
13
9
|
handler: async () => {
|
|
14
|
-
logger.info(
|
|
15
|
-
const result = await wsapiClient.get(
|
|
16
|
-
logger.info('Retrieved contacts successfully', { count: result.length });
|
|
10
|
+
logger.info("Getting contacts list");
|
|
11
|
+
const result = await wsapiClient.get("/contacts");
|
|
17
12
|
return {
|
|
18
13
|
success: true,
|
|
19
14
|
contacts: result,
|
|
@@ -22,192 +17,107 @@ export const getContacts = {
|
|
|
22
17
|
};
|
|
23
18
|
},
|
|
24
19
|
};
|
|
25
|
-
// Get specific contact tool
|
|
26
20
|
export const getContact = {
|
|
27
|
-
name:
|
|
28
|
-
description:
|
|
21
|
+
name: "whatsapp_get_contact",
|
|
22
|
+
description: "Get information about a specific WhatsApp contact.",
|
|
29
23
|
inputSchema: {
|
|
30
|
-
type:
|
|
31
|
-
properties: {
|
|
32
|
-
|
|
33
|
-
type: 'string',
|
|
34
|
-
description: 'Contact ID (phone number with @s.whatsapp.net)',
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
required: ['contactId'],
|
|
24
|
+
type: "object",
|
|
25
|
+
properties: { id: { type: "string", description: "Contact JID" } },
|
|
26
|
+
required: ["id"],
|
|
38
27
|
},
|
|
39
28
|
handler: async (args) => {
|
|
40
29
|
const input = validateInput(getContactSchema, args);
|
|
41
|
-
logger.info(
|
|
42
|
-
const result = await wsapiClient.get(`/contacts/${input.
|
|
43
|
-
logger.info('Retrieved contact successfully', { contactId: input.contactId });
|
|
30
|
+
logger.info("Getting contact info", { id: input.id });
|
|
31
|
+
const result = await wsapiClient.get(`/contacts/${input.id}`);
|
|
44
32
|
return {
|
|
45
33
|
success: true,
|
|
46
34
|
contact: result,
|
|
47
|
-
message:
|
|
35
|
+
message: "Contact information retrieved successfully",
|
|
48
36
|
};
|
|
49
37
|
},
|
|
50
38
|
};
|
|
51
|
-
// Create contact tool
|
|
52
39
|
export const createContact = {
|
|
53
|
-
name:
|
|
54
|
-
description:
|
|
40
|
+
name: "whatsapp_create_contact",
|
|
41
|
+
description: "Create or update a WhatsApp contact.",
|
|
55
42
|
inputSchema: {
|
|
56
|
-
type:
|
|
43
|
+
type: "object",
|
|
57
44
|
properties: {
|
|
58
|
-
id: {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
},
|
|
62
|
-
fullName: {
|
|
63
|
-
type: 'string',
|
|
64
|
-
description: 'Full name of the contact (max 255 characters)',
|
|
65
|
-
},
|
|
66
|
-
firstName: {
|
|
67
|
-
type: 'string',
|
|
68
|
-
description: 'First name of the contact (max 255 characters)',
|
|
69
|
-
},
|
|
45
|
+
id: { type: "string", description: "Phone number or JID of the contact" },
|
|
46
|
+
fullName: { type: "string", description: "Full name of the contact" },
|
|
47
|
+
firstName: { type: "string", description: "First name (optional)" },
|
|
70
48
|
},
|
|
71
|
-
required: [
|
|
49
|
+
required: ["id", "fullName"],
|
|
72
50
|
},
|
|
73
51
|
handler: async (args) => {
|
|
74
52
|
const input = validateInput(createContactSchema, args);
|
|
75
|
-
logger.info(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
});
|
|
79
|
-
await wsapiClient.post('/contacts', input);
|
|
80
|
-
logger.info('Contact created successfully', { id: input.id });
|
|
81
|
-
return {
|
|
82
|
-
success: true,
|
|
83
|
-
message: 'Contact created successfully',
|
|
84
|
-
};
|
|
53
|
+
logger.info("Creating contact", { id: input.id });
|
|
54
|
+
await wsapiClient.post("/contacts", input);
|
|
55
|
+
return { success: true, message: "Contact created successfully" };
|
|
85
56
|
},
|
|
86
57
|
};
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
type: 'string',
|
|
96
|
-
description: 'Contact ID (phone number with @s.whatsapp.net)',
|
|
97
|
-
},
|
|
98
|
-
fullName: {
|
|
99
|
-
type: 'string',
|
|
100
|
-
description: 'Full name of the contact (max 255 characters)',
|
|
101
|
-
},
|
|
102
|
-
firstName: {
|
|
103
|
-
type: 'string',
|
|
104
|
-
description: 'First name of the contact (max 255 characters)',
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
required: ['contactId', 'fullName', 'firstName'],
|
|
108
|
-
},
|
|
109
|
-
handler: async (args) => {
|
|
110
|
-
const input = validateInput(updateContactSchema, args);
|
|
111
|
-
logger.info('Updating contact', {
|
|
112
|
-
contactId: input.contactId,
|
|
113
|
-
fullName: input.fullName,
|
|
114
|
-
});
|
|
115
|
-
await wsapiClient.put(`/contacts/${input.contactId}`, {
|
|
116
|
-
fullName: input.fullName,
|
|
117
|
-
firstName: input.firstName,
|
|
118
|
-
});
|
|
119
|
-
logger.info('Contact updated successfully', { contactId: input.contactId });
|
|
120
|
-
return {
|
|
121
|
-
success: true,
|
|
122
|
-
message: 'Contact updated successfully',
|
|
123
|
-
};
|
|
58
|
+
export const syncContacts = {
|
|
59
|
+
name: "whatsapp_sync_contacts",
|
|
60
|
+
description: "Trigger a full contact sync from the WhatsApp server.",
|
|
61
|
+
inputSchema: { type: "object", properties: {} },
|
|
62
|
+
handler: async () => {
|
|
63
|
+
logger.info("Syncing contacts");
|
|
64
|
+
await wsapiClient.post("/contacts/sync", {});
|
|
65
|
+
return { success: true, message: "Contact sync triggered" };
|
|
124
66
|
},
|
|
125
67
|
};
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
contactId: {
|
|
134
|
-
type: 'string',
|
|
135
|
-
description: 'Contact ID (phone number with @s.whatsapp.net)',
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
required: ['contactId'],
|
|
139
|
-
},
|
|
140
|
-
handler: async (args) => {
|
|
141
|
-
const input = validateInput(getContactSchema, args);
|
|
142
|
-
logger.info('Getting contact picture', { contactId: input.contactId });
|
|
143
|
-
const result = await wsapiClient.get(`/contacts/${input.contactId}/picture`);
|
|
144
|
-
logger.info('Retrieved contact picture successfully', { contactId: input.contactId });
|
|
68
|
+
export const getBlocklist = {
|
|
69
|
+
name: "whatsapp_get_blocklist",
|
|
70
|
+
description: "Get the list of all blocked contacts.",
|
|
71
|
+
inputSchema: { type: "object", properties: {} },
|
|
72
|
+
handler: async () => {
|
|
73
|
+
logger.info("Getting blocklist");
|
|
74
|
+
const result = await wsapiClient.get("/contacts/blocklist");
|
|
145
75
|
return {
|
|
146
76
|
success: true,
|
|
147
|
-
|
|
148
|
-
message:
|
|
77
|
+
blocklist: result,
|
|
78
|
+
message: "Blocklist retrieved successfully",
|
|
149
79
|
};
|
|
150
80
|
},
|
|
151
81
|
};
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
description: 'Get the business profile information of a WhatsApp contact.',
|
|
82
|
+
export const blockContact = {
|
|
83
|
+
name: "whatsapp_block_contact",
|
|
84
|
+
description: "Block a contact.",
|
|
156
85
|
inputSchema: {
|
|
157
|
-
type:
|
|
158
|
-
properties: {
|
|
159
|
-
|
|
160
|
-
type: 'string',
|
|
161
|
-
description: 'Contact ID (phone number with @s.whatsapp.net)',
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
required: ['contactId'],
|
|
86
|
+
type: "object",
|
|
87
|
+
properties: { id: { type: "string", description: "Contact JID to block" } },
|
|
88
|
+
required: ["id"],
|
|
165
89
|
},
|
|
166
90
|
handler: async (args) => {
|
|
167
|
-
const input = validateInput(
|
|
168
|
-
logger.info(
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
return {
|
|
172
|
-
success: true,
|
|
173
|
-
businessProfile: result,
|
|
174
|
-
message: 'Contact business profile retrieved successfully',
|
|
175
|
-
};
|
|
91
|
+
const input = validateInput(blockContactSchema, args);
|
|
92
|
+
logger.info("Blocking contact", { id: input.id });
|
|
93
|
+
await wsapiClient.put(`/contacts/${input.id}/block`, {});
|
|
94
|
+
return { success: true, message: "Contact blocked successfully" };
|
|
176
95
|
},
|
|
177
96
|
};
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
description: 'Subscribe to presence updates for a specific contact.',
|
|
97
|
+
export const unblockContact = {
|
|
98
|
+
name: "whatsapp_unblock_contact",
|
|
99
|
+
description: "Unblock a contact.",
|
|
182
100
|
inputSchema: {
|
|
183
|
-
type:
|
|
101
|
+
type: "object",
|
|
184
102
|
properties: {
|
|
185
|
-
|
|
186
|
-
type: 'string',
|
|
187
|
-
description: 'Contact ID (phone number with @s.whatsapp.net)',
|
|
188
|
-
},
|
|
103
|
+
id: { type: "string", description: "Contact JID to unblock" },
|
|
189
104
|
},
|
|
190
|
-
required: [
|
|
105
|
+
required: ["id"],
|
|
191
106
|
},
|
|
192
107
|
handler: async (args) => {
|
|
193
|
-
const input = validateInput(
|
|
194
|
-
logger.info(
|
|
195
|
-
await wsapiClient.
|
|
196
|
-
|
|
197
|
-
return {
|
|
198
|
-
success: true,
|
|
199
|
-
message: 'Successfully subscribed to contact presence updates',
|
|
200
|
-
};
|
|
108
|
+
const input = validateInput(blockContactSchema, args);
|
|
109
|
+
logger.info("Unblocking contact", { id: input.id });
|
|
110
|
+
await wsapiClient.put(`/contacts/${input.id}/unblock`, {});
|
|
111
|
+
return { success: true, message: "Contact unblocked successfully" };
|
|
201
112
|
},
|
|
202
113
|
};
|
|
203
|
-
// Export all contact tools
|
|
204
114
|
export const contactTools = {
|
|
205
115
|
getContacts,
|
|
206
116
|
getContact,
|
|
207
117
|
createContact,
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
118
|
+
syncContacts,
|
|
119
|
+
getBlocklist,
|
|
120
|
+
blockContact,
|
|
121
|
+
unblockContact,
|
|
212
122
|
};
|
|
213
123
|
//# sourceMappingURL=contacts.js.map
|