@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.
- package/README.md +53 -338
- package/dist/client/index.d.ts +0 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +1 -5
- package/dist/client/index.js.map +1 -1
- package/dist/config/index.d.ts +18 -53
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +5 -1
- package/dist/config/index.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +70 -24
- 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 +24 -0
- package/dist/tools/calls.js.map +1 -0
- package/dist/tools/chats.d.ts +18 -0
- package/dist/tools/chats.d.ts.map +1 -1
- package/dist/tools/chats.js +156 -8
- 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 +263 -0
- package/dist/tools/communities.js.map +1 -0
- package/dist/tools/contacts.d.ts +8 -8
- package/dist/tools/contacts.d.ts.map +1 -1
- package/dist/tools/contacts.js +53 -158
- package/dist/tools/contacts.js.map +1 -1
- package/dist/tools/groups.d.ts +32 -0
- package/dist/tools/groups.d.ts.map +1 -1
- package/dist/tools/groups.js +272 -11
- 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 +23 -0
- package/dist/tools/media.js.map +1 -0
- package/dist/tools/messaging-advanced.d.ts.map +1 -1
- package/dist/tools/messaging-advanced.js +79 -295
- package/dist/tools/messaging-advanced.js.map +1 -1
- package/dist/tools/messaging.d.ts +4 -0
- package/dist/tools/messaging.d.ts.map +1 -1
- package/dist/tools/messaging.js +150 -337
- 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 +102 -0
- package/dist/tools/newsletters.js.map +1 -0
- package/dist/tools/session.d.ts +2 -0
- package/dist/tools/session.d.ts.map +1 -1
- package/dist/tools/session.js +18 -8
- 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 +86 -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 +129 -0
- package/dist/tools/users.js.map +1 -0
- package/dist/types/api.d.ts +4503 -1726
- package/dist/types/api.d.ts.map +1 -1
- package/dist/utils/logger.js +3 -3
- package/dist/utils/logger.js.map +1 -1
- package/dist/validation/schemas.d.ts +309 -650
- package/dist/validation/schemas.d.ts.map +1 -1
- package/dist/validation/schemas.js +209 -144
- package/dist/validation/schemas.js.map +1 -1
- package/package.json +24 -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,263 @@
|
|
|
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: { type: 'array', items: { type: 'string' }, description: 'Initial participant JIDs' },
|
|
23
|
+
approvalMode: { type: 'string', description: 'Join approval mode' },
|
|
24
|
+
},
|
|
25
|
+
required: ['name'],
|
|
26
|
+
},
|
|
27
|
+
handler: async (args) => {
|
|
28
|
+
const input = validateInput(createCommunitySchema, args);
|
|
29
|
+
logger.info('Creating community', { name: input.name });
|
|
30
|
+
const result = await wsapiClient.post('/communities', input);
|
|
31
|
+
return { success: true, communityId: result.id, message: 'Community created' };
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
export const getCommunity = {
|
|
35
|
+
name: 'whatsapp_get_community',
|
|
36
|
+
description: 'Get community info.',
|
|
37
|
+
inputSchema: {
|
|
38
|
+
type: 'object',
|
|
39
|
+
properties: { id: { type: 'string', description: 'Community JID' } },
|
|
40
|
+
required: ['id'],
|
|
41
|
+
},
|
|
42
|
+
handler: async (args) => {
|
|
43
|
+
const input = validateInput(getCommunitySchema, args);
|
|
44
|
+
const result = await wsapiClient.get(`/communities/${input.id}`);
|
|
45
|
+
return { success: true, community: result };
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
export const leaveCommunity = {
|
|
49
|
+
name: 'whatsapp_leave_community',
|
|
50
|
+
description: 'Leave a community.',
|
|
51
|
+
inputSchema: {
|
|
52
|
+
type: 'object',
|
|
53
|
+
properties: { id: { type: 'string', description: 'Community JID' } },
|
|
54
|
+
required: ['id'],
|
|
55
|
+
},
|
|
56
|
+
handler: async (args) => {
|
|
57
|
+
const input = validateInput(getCommunitySchema, args);
|
|
58
|
+
await wsapiClient.post(`/communities/${input.id}/leave`, {});
|
|
59
|
+
return { success: true, message: 'Left community' };
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
export const setCommunityName = {
|
|
63
|
+
name: 'whatsapp_set_community_name',
|
|
64
|
+
description: 'Set community name.',
|
|
65
|
+
inputSchema: {
|
|
66
|
+
type: 'object',
|
|
67
|
+
properties: {
|
|
68
|
+
id: { type: 'string', description: 'Community JID' },
|
|
69
|
+
name: { type: 'string', description: 'New name' },
|
|
70
|
+
},
|
|
71
|
+
required: ['id', 'name'],
|
|
72
|
+
},
|
|
73
|
+
handler: async (args) => {
|
|
74
|
+
const input = validateInput(updateGroupNameSchema, args);
|
|
75
|
+
await wsapiClient.put(`/communities/${input.id}/name`, { name: input.name });
|
|
76
|
+
return { success: true, message: 'Community name updated' };
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
export const setCommunityDescription = {
|
|
80
|
+
name: 'whatsapp_set_community_description',
|
|
81
|
+
description: 'Set community description.',
|
|
82
|
+
inputSchema: {
|
|
83
|
+
type: 'object',
|
|
84
|
+
properties: {
|
|
85
|
+
id: { type: 'string', description: 'Community JID' },
|
|
86
|
+
description: { type: 'string', description: 'New description' },
|
|
87
|
+
},
|
|
88
|
+
required: ['id'],
|
|
89
|
+
},
|
|
90
|
+
handler: async (args) => {
|
|
91
|
+
const input = validateInput(updateGroupDescriptionSchema, args);
|
|
92
|
+
await wsapiClient.put(`/communities/${input.id}/description`, { description: input.description });
|
|
93
|
+
return { success: true, message: 'Community description updated' };
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
export const setCommunityPicture = {
|
|
97
|
+
name: 'whatsapp_set_community_picture',
|
|
98
|
+
description: 'Set community profile picture.',
|
|
99
|
+
inputSchema: {
|
|
100
|
+
type: 'object',
|
|
101
|
+
properties: {
|
|
102
|
+
id: { type: 'string', description: 'Community JID' },
|
|
103
|
+
data: { type: 'string', description: 'Base64-encoded JPEG image' },
|
|
104
|
+
},
|
|
105
|
+
required: ['id', 'data'],
|
|
106
|
+
},
|
|
107
|
+
handler: async (args) => {
|
|
108
|
+
const input = validateInput(setGroupPictureSchema, args);
|
|
109
|
+
const result = await wsapiClient.post(`/communities/${input.id}/picture`, { data: input.data });
|
|
110
|
+
return { success: true, pictureId: result.pictureId, message: 'Community picture updated' };
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
export const setCommunityLocked = {
|
|
114
|
+
name: 'whatsapp_set_community_locked',
|
|
115
|
+
description: 'Set community locked mode (only admins can edit info).',
|
|
116
|
+
inputSchema: {
|
|
117
|
+
type: 'object',
|
|
118
|
+
properties: {
|
|
119
|
+
id: { type: 'string', description: 'Community JID' },
|
|
120
|
+
enabled: { type: 'boolean', description: 'Enable or disable' },
|
|
121
|
+
},
|
|
122
|
+
required: ['id', 'enabled'],
|
|
123
|
+
},
|
|
124
|
+
handler: async (args) => {
|
|
125
|
+
const input = validateInput(setBoolSettingSchema, args);
|
|
126
|
+
await wsapiClient.put(`/communities/${input.id}/settings/locked`, { enabled: input.enabled });
|
|
127
|
+
return { success: true, message: 'Community locked mode updated' };
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
export const getCommunityParticipants = {
|
|
131
|
+
name: 'whatsapp_get_community_participants',
|
|
132
|
+
description: 'Get community participants.',
|
|
133
|
+
inputSchema: {
|
|
134
|
+
type: 'object',
|
|
135
|
+
properties: { id: { type: 'string', description: 'Community JID' } },
|
|
136
|
+
required: ['id'],
|
|
137
|
+
},
|
|
138
|
+
handler: async (args) => {
|
|
139
|
+
const input = validateInput(getCommunitySchema, args);
|
|
140
|
+
const result = await wsapiClient.get(`/communities/${input.id}/participants`);
|
|
141
|
+
return { success: true, participants: result };
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
export const updateCommunityParticipants = {
|
|
145
|
+
name: 'whatsapp_update_community_participants',
|
|
146
|
+
description: 'Add, remove, promote, or demote community participants.',
|
|
147
|
+
inputSchema: {
|
|
148
|
+
type: 'object',
|
|
149
|
+
properties: {
|
|
150
|
+
id: { type: 'string', description: 'Community JID' },
|
|
151
|
+
participants: { type: 'array', items: { type: 'string' }, description: 'Participant JIDs' },
|
|
152
|
+
action: { type: 'string', enum: ['add', 'remove', 'promote', 'demote'], description: 'Action' },
|
|
153
|
+
},
|
|
154
|
+
required: ['id', 'participants', 'action'],
|
|
155
|
+
},
|
|
156
|
+
handler: async (args) => {
|
|
157
|
+
const input = validateInput(updateGroupParticipantsSchema, args);
|
|
158
|
+
await wsapiClient.put(`/communities/${input.id}/participants`, { participants: input.participants, action: input.action });
|
|
159
|
+
return { success: true, message: 'Community participants updated' };
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
export const getCommunityInviteLink = {
|
|
163
|
+
name: 'whatsapp_get_community_invite_link',
|
|
164
|
+
description: 'Get community invite link.',
|
|
165
|
+
inputSchema: {
|
|
166
|
+
type: 'object',
|
|
167
|
+
properties: { id: { type: 'string', description: 'Community JID' } },
|
|
168
|
+
required: ['id'],
|
|
169
|
+
},
|
|
170
|
+
handler: async (args) => {
|
|
171
|
+
const input = validateInput(getCommunitySchema, args);
|
|
172
|
+
const result = await wsapiClient.get(`/communities/${input.id}/invite-link`);
|
|
173
|
+
return { success: true, link: result.link };
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
export const resetCommunityInviteLink = {
|
|
177
|
+
name: 'whatsapp_reset_community_invite_link',
|
|
178
|
+
description: 'Reset community invite link.',
|
|
179
|
+
inputSchema: {
|
|
180
|
+
type: 'object',
|
|
181
|
+
properties: { id: { type: 'string', description: 'Community JID' } },
|
|
182
|
+
required: ['id'],
|
|
183
|
+
},
|
|
184
|
+
handler: async (args) => {
|
|
185
|
+
const input = validateInput(getCommunitySchema, args);
|
|
186
|
+
const result = await wsapiClient.post(`/communities/${input.id}/invite-link/reset`, {});
|
|
187
|
+
return { success: true, link: result.link };
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
export const getCommunitySubGroups = {
|
|
191
|
+
name: 'whatsapp_get_community_sub_groups',
|
|
192
|
+
description: 'Get community sub-groups.',
|
|
193
|
+
inputSchema: {
|
|
194
|
+
type: 'object',
|
|
195
|
+
properties: { id: { type: 'string', description: 'Community JID' } },
|
|
196
|
+
required: ['id'],
|
|
197
|
+
},
|
|
198
|
+
handler: async (args) => {
|
|
199
|
+
const input = validateInput(getCommunitySchema, args);
|
|
200
|
+
const result = await wsapiClient.get(`/communities/${input.id}/groups`);
|
|
201
|
+
return { success: true, groups: result };
|
|
202
|
+
},
|
|
203
|
+
};
|
|
204
|
+
export const createCommunityGroup = {
|
|
205
|
+
name: 'whatsapp_create_community_group',
|
|
206
|
+
description: 'Create a new sub-group inside a community.',
|
|
207
|
+
inputSchema: {
|
|
208
|
+
type: 'object',
|
|
209
|
+
properties: {
|
|
210
|
+
id: { type: 'string', description: 'Community JID' },
|
|
211
|
+
name: { type: 'string', description: 'Group name' },
|
|
212
|
+
participants: { type: 'array', items: { type: 'string' }, description: 'Participant JIDs' },
|
|
213
|
+
},
|
|
214
|
+
required: ['id', 'name'],
|
|
215
|
+
},
|
|
216
|
+
handler: async (args) => {
|
|
217
|
+
const input = validateInput(createCommunityGroupSchema, args);
|
|
218
|
+
const result = await wsapiClient.post(`/communities/${input.id}/groups`, { name: input.name, participants: input.participants });
|
|
219
|
+
return { success: true, groupId: result.id, message: 'Community group created' };
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
export const linkGroupToCommunity = {
|
|
223
|
+
name: 'whatsapp_link_group_to_community',
|
|
224
|
+
description: 'Link an existing group to a community.',
|
|
225
|
+
inputSchema: {
|
|
226
|
+
type: 'object',
|
|
227
|
+
properties: {
|
|
228
|
+
id: { type: 'string', description: 'Community JID' },
|
|
229
|
+
groupId: { type: 'string', description: 'Group JID to link' },
|
|
230
|
+
},
|
|
231
|
+
required: ['id', 'groupId'],
|
|
232
|
+
},
|
|
233
|
+
handler: async (args) => {
|
|
234
|
+
const input = validateInput(linkGroupToCommunitySchema, args);
|
|
235
|
+
await wsapiClient.post(`/communities/${input.id}/groups/link`, { groupId: input.groupId });
|
|
236
|
+
return { success: true, message: 'Group linked to community' };
|
|
237
|
+
},
|
|
238
|
+
};
|
|
239
|
+
export const unlinkCommunityGroup = {
|
|
240
|
+
name: 'whatsapp_unlink_community_group',
|
|
241
|
+
description: 'Unlink a group from a community.',
|
|
242
|
+
inputSchema: {
|
|
243
|
+
type: 'object',
|
|
244
|
+
properties: {
|
|
245
|
+
id: { type: 'string', description: 'Community JID' },
|
|
246
|
+
groupId: { type: 'string', description: 'Group JID to unlink' },
|
|
247
|
+
},
|
|
248
|
+
required: ['id', 'groupId'],
|
|
249
|
+
},
|
|
250
|
+
handler: async (args) => {
|
|
251
|
+
const input = validateInput(unlinkCommunityGroupSchema, args);
|
|
252
|
+
await wsapiClient.delete(`/communities/${input.id}/groups/${input.groupId}`);
|
|
253
|
+
return { success: true, message: 'Group unlinked from community' };
|
|
254
|
+
},
|
|
255
|
+
};
|
|
256
|
+
export const communityTools = {
|
|
257
|
+
listCommunities, createCommunity, getCommunity, leaveCommunity,
|
|
258
|
+
setCommunityName, setCommunityDescription, setCommunityPicture, setCommunityLocked,
|
|
259
|
+
getCommunityParticipants, updateCommunityParticipants,
|
|
260
|
+
getCommunityInviteLink, resetCommunityInviteLink,
|
|
261
|
+
getCommunitySubGroups, createCommunityGroup, linkGroupToCommunity, unlinkCommunityGroup,
|
|
262
|
+
};
|
|
263
|
+
//# sourceMappingURL=communities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"communities.js","sourceRoot":"","sources":["../../src/tools/communities.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,W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K,EAAE,IAAS,EAAE,EAAE;QAC3B,MAAM,KAAK,GAAG,aAAa,CAAC,0BAA0B,EAAE,IAAI,CAAC,CAAC;QAC9D,MAAM,WAAW,CAAC,MAAM,CAAC,gBAAgB,KAAK,CAAC,EAAE,WAAW,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC7E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,+BAA+B,EAAE,CAAC;IACrE,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,eAAe,EAAE,eAAe,EAAE,YAAY,EAAE,cAAc;IAC9D,gBAAgB,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,kBAAkB;IAClF,wBAAwB,EAAE,2BAA2B;IACrD,sBAAsB,EAAE,wBAAwB;IAChD,qBAAqB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,oBAAoB;CACxF,CAAC"}
|
package/dist/tools/contacts.d.ts
CHANGED
|
@@ -2,17 +2,17 @@ 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;AAOhD,eAAO,MAAM,WAAW,EAAE,WASzB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,WAcxB,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,WAkB3B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,WAS1B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,WAS1B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,WAc1B,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,WAc5B,CAAC;AAEF,eAAO,MAAM,YAAY;;;;;;;;CAQxB,CAAC"}
|
package/dist/tools/contacts.js
CHANGED
|
@@ -1,213 +1,108 @@
|
|
|
1
1
|
import { wsapiClient } from '../client/index.js';
|
|
2
2
|
import { createLogger } from '../utils/logger.js';
|
|
3
|
-
import { validateInput, getContactSchema, createContactSchema,
|
|
3
|
+
import { validateInput, getContactSchema, createContactSchema, blockContactSchema } from '../validation/schemas.js';
|
|
4
4
|
const logger = createLogger('contact-tools');
|
|
5
|
-
// Get contacts list tool
|
|
6
5
|
export const getContacts = {
|
|
7
6
|
name: 'whatsapp_get_contacts',
|
|
8
7
|
description: 'Get list of all WhatsApp contacts.',
|
|
9
|
-
inputSchema: {
|
|
10
|
-
type: 'object',
|
|
11
|
-
properties: {},
|
|
12
|
-
},
|
|
8
|
+
inputSchema: { type: 'object', properties: {} },
|
|
13
9
|
handler: async () => {
|
|
14
10
|
logger.info('Getting contacts list');
|
|
15
11
|
const result = await wsapiClient.get('/contacts');
|
|
16
|
-
|
|
17
|
-
return {
|
|
18
|
-
success: true,
|
|
19
|
-
contacts: result,
|
|
20
|
-
count: result.length,
|
|
21
|
-
message: `Retrieved ${result.length} contacts`,
|
|
22
|
-
};
|
|
12
|
+
return { success: true, contacts: result, count: result.length, message: `Retrieved ${result.length} contacts` };
|
|
23
13
|
},
|
|
24
14
|
};
|
|
25
|
-
// Get specific contact tool
|
|
26
15
|
export const getContact = {
|
|
27
16
|
name: 'whatsapp_get_contact',
|
|
28
17
|
description: 'Get information about a specific WhatsApp contact.',
|
|
29
18
|
inputSchema: {
|
|
30
19
|
type: 'object',
|
|
31
|
-
properties: {
|
|
32
|
-
|
|
33
|
-
type: 'string',
|
|
34
|
-
description: 'Contact ID (phone number with @s.whatsapp.net)',
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
required: ['contactId'],
|
|
20
|
+
properties: { id: { type: 'string', description: 'Contact JID' } },
|
|
21
|
+
required: ['id'],
|
|
38
22
|
},
|
|
39
23
|
handler: async (args) => {
|
|
40
24
|
const input = validateInput(getContactSchema, args);
|
|
41
|
-
logger.info('Getting contact info', {
|
|
42
|
-
const result = await wsapiClient.get(`/contacts/${input.
|
|
43
|
-
|
|
44
|
-
return {
|
|
45
|
-
success: true,
|
|
46
|
-
contact: result,
|
|
47
|
-
message: 'Contact information retrieved successfully',
|
|
48
|
-
};
|
|
25
|
+
logger.info('Getting contact info', { id: input.id });
|
|
26
|
+
const result = await wsapiClient.get(`/contacts/${input.id}`);
|
|
27
|
+
return { success: true, contact: result, message: 'Contact information retrieved successfully' };
|
|
49
28
|
},
|
|
50
29
|
};
|
|
51
|
-
// Create contact tool
|
|
52
30
|
export const createContact = {
|
|
53
31
|
name: 'whatsapp_create_contact',
|
|
54
|
-
description: 'Create a
|
|
32
|
+
description: 'Create or update a WhatsApp contact.',
|
|
55
33
|
inputSchema: {
|
|
56
34
|
type: 'object',
|
|
57
35
|
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
|
-
},
|
|
36
|
+
id: { type: 'string', description: 'Phone number or JID of the contact' },
|
|
37
|
+
fullName: { type: 'string', description: 'Full name of the contact' },
|
|
38
|
+
firstName: { type: 'string', description: 'First name (optional)' },
|
|
70
39
|
},
|
|
71
|
-
required: ['id', 'fullName'
|
|
40
|
+
required: ['id', 'fullName'],
|
|
72
41
|
},
|
|
73
42
|
handler: async (args) => {
|
|
74
43
|
const input = validateInput(createContactSchema, args);
|
|
75
|
-
logger.info('Creating contact', {
|
|
76
|
-
id: input.id,
|
|
77
|
-
fullName: input.fullName,
|
|
78
|
-
});
|
|
44
|
+
logger.info('Creating contact', { id: input.id });
|
|
79
45
|
await wsapiClient.post('/contacts', input);
|
|
80
|
-
|
|
81
|
-
return {
|
|
82
|
-
success: true,
|
|
83
|
-
message: 'Contact created successfully',
|
|
84
|
-
};
|
|
46
|
+
return { success: true, message: 'Contact created successfully' };
|
|
85
47
|
},
|
|
86
48
|
};
|
|
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
|
-
};
|
|
49
|
+
export const syncContacts = {
|
|
50
|
+
name: 'whatsapp_sync_contacts',
|
|
51
|
+
description: 'Trigger a full contact sync from the WhatsApp server.',
|
|
52
|
+
inputSchema: { type: 'object', properties: {} },
|
|
53
|
+
handler: async () => {
|
|
54
|
+
logger.info('Syncing contacts');
|
|
55
|
+
await wsapiClient.post('/contacts/sync', {});
|
|
56
|
+
return { success: true, message: 'Contact sync triggered' };
|
|
124
57
|
},
|
|
125
58
|
};
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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 });
|
|
145
|
-
return {
|
|
146
|
-
success: true,
|
|
147
|
-
picture: result,
|
|
148
|
-
message: 'Contact picture retrieved successfully',
|
|
149
|
-
};
|
|
59
|
+
export const getBlocklist = {
|
|
60
|
+
name: 'whatsapp_get_blocklist',
|
|
61
|
+
description: 'Get the list of all blocked contacts.',
|
|
62
|
+
inputSchema: { type: 'object', properties: {} },
|
|
63
|
+
handler: async () => {
|
|
64
|
+
logger.info('Getting blocklist');
|
|
65
|
+
const result = await wsapiClient.get('/contacts/blocklist');
|
|
66
|
+
return { success: true, blocklist: result, message: 'Blocklist retrieved successfully' };
|
|
150
67
|
},
|
|
151
68
|
};
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
description: 'Get the business profile information of a WhatsApp contact.',
|
|
69
|
+
export const blockContact = {
|
|
70
|
+
name: 'whatsapp_block_contact',
|
|
71
|
+
description: 'Block a contact.',
|
|
156
72
|
inputSchema: {
|
|
157
73
|
type: 'object',
|
|
158
|
-
properties: {
|
|
159
|
-
|
|
160
|
-
type: 'string',
|
|
161
|
-
description: 'Contact ID (phone number with @s.whatsapp.net)',
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
required: ['contactId'],
|
|
74
|
+
properties: { id: { type: 'string', description: 'Contact JID to block' } },
|
|
75
|
+
required: ['id'],
|
|
165
76
|
},
|
|
166
77
|
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
|
-
};
|
|
78
|
+
const input = validateInput(blockContactSchema, args);
|
|
79
|
+
logger.info('Blocking contact', { id: input.id });
|
|
80
|
+
await wsapiClient.put(`/contacts/${input.id}/block`, {});
|
|
81
|
+
return { success: true, message: 'Contact blocked successfully' };
|
|
176
82
|
},
|
|
177
83
|
};
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
description: 'Subscribe to presence updates for a specific contact.',
|
|
84
|
+
export const unblockContact = {
|
|
85
|
+
name: 'whatsapp_unblock_contact',
|
|
86
|
+
description: 'Unblock a contact.',
|
|
182
87
|
inputSchema: {
|
|
183
88
|
type: 'object',
|
|
184
|
-
properties: {
|
|
185
|
-
|
|
186
|
-
type: 'string',
|
|
187
|
-
description: 'Contact ID (phone number with @s.whatsapp.net)',
|
|
188
|
-
},
|
|
189
|
-
},
|
|
190
|
-
required: ['contactId'],
|
|
89
|
+
properties: { id: { type: 'string', description: 'Contact JID to unblock' } },
|
|
90
|
+
required: ['id'],
|
|
191
91
|
},
|
|
192
92
|
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
|
-
};
|
|
93
|
+
const input = validateInput(blockContactSchema, args);
|
|
94
|
+
logger.info('Unblocking contact', { id: input.id });
|
|
95
|
+
await wsapiClient.put(`/contacts/${input.id}/unblock`, {});
|
|
96
|
+
return { success: true, message: 'Contact unblocked successfully' };
|
|
201
97
|
},
|
|
202
98
|
};
|
|
203
|
-
// Export all contact tools
|
|
204
99
|
export const contactTools = {
|
|
205
100
|
getContacts,
|
|
206
101
|
getContact,
|
|
207
102
|
createContact,
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
103
|
+
syncContacts,
|
|
104
|
+
getBlocklist,
|
|
105
|
+
blockContact,
|
|
106
|
+
unblockContact,
|
|
212
107
|
};
|
|
213
108
|
//# sourceMappingURL=contacts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contacts.js","sourceRoot":"","sources":["../../src/tools/contacts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,
|
|
1
|
+
{"version":3,"file":"contacts.js","sourceRoot":"","sources":["../../src/tools/contacts.ts"],"names":[],"mappings":"AAC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