@wsapichat/mcp-server 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +96 -0
- package/LICENSE +21 -0
- package/README.md +403 -0
- package/dist/client/index.d.ts +16 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +154 -0
- package/dist/client/index.js.map +1 -0
- package/dist/config/index.d.ts +85 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +67 -0
- package/dist/config/index.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +46 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +20 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +173 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/account.d.ts +14 -0
- package/dist/tools/account.d.ts.map +1 -0
- package/dist/tools/account.js +78 -0
- package/dist/tools/account.js.map +1 -0
- package/dist/tools/chats.d.ts +14 -0
- package/dist/tools/chats.d.ts.map +1 -0
- package/dist/tools/chats.js +81 -0
- package/dist/tools/chats.js.map +1 -0
- package/dist/tools/contacts.d.ts +18 -0
- package/dist/tools/contacts.d.ts.map +1 -0
- package/dist/tools/contacts.js +213 -0
- package/dist/tools/contacts.js.map +1 -0
- package/dist/tools/groups.d.ts +12 -0
- package/dist/tools/groups.d.ts.map +1 -0
- package/dist/tools/groups.js +65 -0
- package/dist/tools/groups.js.map +1 -0
- package/dist/tools/instance.d.ts +12 -0
- package/dist/tools/instance.d.ts.map +1 -0
- package/dist/tools/instance.js +54 -0
- package/dist/tools/instance.js.map +1 -0
- package/dist/tools/messaging-advanced.d.ts +16 -0
- package/dist/tools/messaging-advanced.d.ts.map +1 -0
- package/dist/tools/messaging-advanced.js +386 -0
- package/dist/tools/messaging-advanced.js.map +1 -0
- package/dist/tools/messaging.d.ts +28 -0
- package/dist/tools/messaging.d.ts.map +1 -0
- package/dist/tools/messaging.js +491 -0
- package/dist/tools/messaging.js.map +1 -0
- package/dist/tools/session.d.ts +14 -0
- package/dist/tools/session.d.ts.map +1 -0
- package/dist/tools/session.js +61 -0
- package/dist/tools/session.js.map +1 -0
- package/dist/types/api.d.ts +2730 -0
- package/dist/types/api.d.ts.map +1 -0
- package/dist/types/api.js +6 -0
- package/dist/types/api.js.map +1 -0
- package/dist/types/webhooks.d.ts +1001 -0
- package/dist/types/webhooks.d.ts.map +1 -0
- package/dist/types/webhooks.js +6 -0
- package/dist/types/webhooks.js.map +1 -0
- package/dist/utils/errors.d.ts +39 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +151 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/logger.d.ts +12 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +99 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/validation/schemas.d.ts +732 -0
- package/dist/validation/schemas.d.ts.map +1 -0
- package/dist/validation/schemas.js +269 -0
- package/dist/validation/schemas.js.map +1 -0
- package/package.json +83 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { wsapiClient } from '../client/index.js';
|
|
2
|
+
import { createLogger } from '../utils/logger.js';
|
|
3
|
+
import { validateInput, getChatSchema, setChatPresenceSchema, updateChatArchiveSchema, updateChatPinSchema } from '../validation/schemas.js';
|
|
4
|
+
const logger = createLogger('chat-tools');
|
|
5
|
+
export const getChats = {
|
|
6
|
+
name: 'whatsapp_get_chats',
|
|
7
|
+
description: 'Get list of all WhatsApp chats.',
|
|
8
|
+
inputSchema: { type: 'object', properties: {} },
|
|
9
|
+
handler: async () => {
|
|
10
|
+
logger.info('Getting chats list');
|
|
11
|
+
const result = await wsapiClient.get('/chats');
|
|
12
|
+
return { success: true, chats: result, count: result.length };
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
export const getChat = {
|
|
16
|
+
name: 'whatsapp_get_chat',
|
|
17
|
+
description: 'Get information about a specific chat.',
|
|
18
|
+
inputSchema: {
|
|
19
|
+
type: 'object',
|
|
20
|
+
properties: { chatId: { type: 'string', description: 'Chat ID' } },
|
|
21
|
+
required: ['chatId'],
|
|
22
|
+
},
|
|
23
|
+
handler: async (args) => {
|
|
24
|
+
const input = validateInput(getChatSchema, args);
|
|
25
|
+
const result = await wsapiClient.get(`/chats/${input.chatId}`);
|
|
26
|
+
return { success: true, chat: result };
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
export const setChatPresence = {
|
|
30
|
+
name: 'whatsapp_set_chat_presence',
|
|
31
|
+
description: 'Set presence status in a chat (typing, recording, paused).',
|
|
32
|
+
inputSchema: {
|
|
33
|
+
type: 'object',
|
|
34
|
+
properties: {
|
|
35
|
+
chatId: { type: 'string', description: 'Chat ID' },
|
|
36
|
+
state: { type: 'string', enum: ['typing', 'recording', 'paused'], description: 'Presence state' },
|
|
37
|
+
},
|
|
38
|
+
required: ['chatId', 'state'],
|
|
39
|
+
},
|
|
40
|
+
handler: async (args) => {
|
|
41
|
+
const input = validateInput(setChatPresenceSchema, args);
|
|
42
|
+
await wsapiClient.put(`/chats/${input.chatId}/presence`, { state: input.state });
|
|
43
|
+
return { success: true, message: 'Chat presence updated successfully' };
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
export const archiveChat = {
|
|
47
|
+
name: 'whatsapp_archive_chat',
|
|
48
|
+
description: 'Archive or unarchive a chat.',
|
|
49
|
+
inputSchema: {
|
|
50
|
+
type: 'object',
|
|
51
|
+
properties: {
|
|
52
|
+
chatId: { type: 'string', description: 'Chat ID' },
|
|
53
|
+
archived: { type: 'boolean', description: 'Whether to archive or unarchive' },
|
|
54
|
+
},
|
|
55
|
+
required: ['chatId', 'archived'],
|
|
56
|
+
},
|
|
57
|
+
handler: async (args) => {
|
|
58
|
+
const input = validateInput(updateChatArchiveSchema, args);
|
|
59
|
+
await wsapiClient.put(`/chats/${input.chatId}/archive`, { archived: input.archived });
|
|
60
|
+
return { success: true, message: `Chat ${input.archived ? 'archived' : 'unarchived'} successfully` };
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
export const pinChat = {
|
|
64
|
+
name: 'whatsapp_pin_chat',
|
|
65
|
+
description: 'Pin or unpin a chat.',
|
|
66
|
+
inputSchema: {
|
|
67
|
+
type: 'object',
|
|
68
|
+
properties: {
|
|
69
|
+
chatId: { type: 'string', description: 'Chat ID' },
|
|
70
|
+
pinned: { type: 'boolean', description: 'Whether to pin or unpin' },
|
|
71
|
+
},
|
|
72
|
+
required: ['chatId', 'pinned'],
|
|
73
|
+
},
|
|
74
|
+
handler: async (args) => {
|
|
75
|
+
const input = validateInput(updateChatPinSchema, args);
|
|
76
|
+
await wsapiClient.put(`/chats/${input.chatId}/pin`, { pinned: input.pinned });
|
|
77
|
+
return { success: true, message: `Chat ${input.pinned ? 'pinned' : 'unpinned'} successfully` };
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
export const chatTools = { getChats, getChat, setChatPresence, archiveChat, pinChat };
|
|
81
|
+
//# sourceMappingURL=chats.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chats.js","sourceRoot":"","sources":["../../src/tools/chats.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE7I,MAAM,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;AAE1C,MAAM,CAAC,MAAM,QAAQ,GAAgB;IACnC,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EAAE,iCAAiC;IAC9C,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE;IAC/C,OAAO,EAAE,KAAK,IAAI,EAAE;QAClB,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IACnC,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE;YAClD,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,yBAAyB,EAAE;SACpE;QACD,QAAQ,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC;KAC/B;IACD,OAAO,EAAE,KAAK,EAAE,IAAS,EAAE,EAAE;QAC3B,MAAM,KAAK,GAAG,aAAa,CAAC,mBAAmB,EAAE,IAAI,CAAC,CAAC;QACvD,MAAM,WAAW,CAAC,GAAG,CAAC,UAAU,KAAK,CAAC,MAAM,MAAM,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;QAC9E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,eAAe,EAAE,CAAC;IACjG,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ToolHandler } from '../server.js';
|
|
2
|
+
export declare const getContacts: ToolHandler;
|
|
3
|
+
export declare const getContact: ToolHandler;
|
|
4
|
+
export declare const createContact: ToolHandler;
|
|
5
|
+
export declare const updateContact: ToolHandler;
|
|
6
|
+
export declare const getContactPicture: ToolHandler;
|
|
7
|
+
export declare const getContactBusinessProfile: ToolHandler;
|
|
8
|
+
export declare const subscribeToContactPresence: ToolHandler;
|
|
9
|
+
export declare const contactTools: {
|
|
10
|
+
getContacts: ToolHandler;
|
|
11
|
+
getContact: ToolHandler;
|
|
12
|
+
createContact: ToolHandler;
|
|
13
|
+
updateContact: ToolHandler;
|
|
14
|
+
getContactPicture: ToolHandler;
|
|
15
|
+
getContactBusinessProfile: ToolHandler;
|
|
16
|
+
subscribeToContactPresence: ToolHandler;
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=contacts.d.ts.map
|
|
@@ -0,0 +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;AAchD,eAAO,MAAM,WAAW,EAAE,WAqBzB,CAAC;AAGF,eAAO,MAAM,UAAU,EAAE,WA4BxB,CAAC;AAGF,eAAO,MAAM,aAAa,EAAE,WAsC3B,CAAC;AAGF,eAAO,MAAM,aAAa,EAAE,WAyC3B,CAAC;AAGF,eAAO,MAAM,iBAAiB,EAAE,WA4B/B,CAAC;AAGF,eAAO,MAAM,yBAAyB,EAAE,WA4BvC,CAAC;AAGF,eAAO,MAAM,0BAA0B,EAAE,WA2BxC,CAAC;AAGF,eAAO,MAAM,YAAY;;;;;;;;CAQxB,CAAC"}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { wsapiClient } from '../client/index.js';
|
|
2
|
+
import { createLogger } from '../utils/logger.js';
|
|
3
|
+
import { validateInput, getContactSchema, createContactSchema, updateContactSchema, } from '../validation/schemas.js';
|
|
4
|
+
const logger = createLogger('contact-tools');
|
|
5
|
+
// Get contacts list tool
|
|
6
|
+
export const getContacts = {
|
|
7
|
+
name: 'whatsapp_get_contacts',
|
|
8
|
+
description: 'Get list of all WhatsApp contacts.',
|
|
9
|
+
inputSchema: {
|
|
10
|
+
type: 'object',
|
|
11
|
+
properties: {},
|
|
12
|
+
},
|
|
13
|
+
handler: async () => {
|
|
14
|
+
logger.info('Getting contacts list');
|
|
15
|
+
const result = await wsapiClient.get('/contacts');
|
|
16
|
+
logger.info('Retrieved contacts successfully', { count: result.length });
|
|
17
|
+
return {
|
|
18
|
+
success: true,
|
|
19
|
+
contacts: result,
|
|
20
|
+
count: result.length,
|
|
21
|
+
message: `Retrieved ${result.length} contacts`,
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
// Get specific contact tool
|
|
26
|
+
export const getContact = {
|
|
27
|
+
name: 'whatsapp_get_contact',
|
|
28
|
+
description: 'Get information about a specific WhatsApp contact.',
|
|
29
|
+
inputSchema: {
|
|
30
|
+
type: 'object',
|
|
31
|
+
properties: {
|
|
32
|
+
contactId: {
|
|
33
|
+
type: 'string',
|
|
34
|
+
description: 'Contact ID (phone number with @s.whatsapp.net)',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
required: ['contactId'],
|
|
38
|
+
},
|
|
39
|
+
handler: async (args) => {
|
|
40
|
+
const input = validateInput(getContactSchema, args);
|
|
41
|
+
logger.info('Getting contact info', { contactId: input.contactId });
|
|
42
|
+
const result = await wsapiClient.get(`/contacts/${input.contactId}`);
|
|
43
|
+
logger.info('Retrieved contact successfully', { contactId: input.contactId });
|
|
44
|
+
return {
|
|
45
|
+
success: true,
|
|
46
|
+
contact: result,
|
|
47
|
+
message: 'Contact information retrieved successfully',
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
// Create contact tool
|
|
52
|
+
export const createContact = {
|
|
53
|
+
name: 'whatsapp_create_contact',
|
|
54
|
+
description: 'Create a new WhatsApp contact.',
|
|
55
|
+
inputSchema: {
|
|
56
|
+
type: 'object',
|
|
57
|
+
properties: {
|
|
58
|
+
id: {
|
|
59
|
+
type: 'string',
|
|
60
|
+
description: 'Contact ID (phone number with @s.whatsapp.net)',
|
|
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
|
+
},
|
|
70
|
+
},
|
|
71
|
+
required: ['id', 'fullName', 'firstName'],
|
|
72
|
+
},
|
|
73
|
+
handler: async (args) => {
|
|
74
|
+
const input = validateInput(createContactSchema, args);
|
|
75
|
+
logger.info('Creating contact', {
|
|
76
|
+
id: input.id,
|
|
77
|
+
fullName: input.fullName,
|
|
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
|
+
};
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
// Update contact tool
|
|
88
|
+
export const updateContact = {
|
|
89
|
+
name: 'whatsapp_update_contact',
|
|
90
|
+
description: 'Update an existing WhatsApp contact.',
|
|
91
|
+
inputSchema: {
|
|
92
|
+
type: 'object',
|
|
93
|
+
properties: {
|
|
94
|
+
contactId: {
|
|
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
|
+
};
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
// Get contact picture tool
|
|
127
|
+
export const getContactPicture = {
|
|
128
|
+
name: 'whatsapp_get_contact_picture',
|
|
129
|
+
description: 'Get the profile picture of a WhatsApp contact.',
|
|
130
|
+
inputSchema: {
|
|
131
|
+
type: 'object',
|
|
132
|
+
properties: {
|
|
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 });
|
|
145
|
+
return {
|
|
146
|
+
success: true,
|
|
147
|
+
picture: result,
|
|
148
|
+
message: 'Contact picture retrieved successfully',
|
|
149
|
+
};
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
// Get contact business profile tool
|
|
153
|
+
export const getContactBusinessProfile = {
|
|
154
|
+
name: 'whatsapp_get_contact_business',
|
|
155
|
+
description: 'Get the business profile information of a WhatsApp contact.',
|
|
156
|
+
inputSchema: {
|
|
157
|
+
type: 'object',
|
|
158
|
+
properties: {
|
|
159
|
+
contactId: {
|
|
160
|
+
type: 'string',
|
|
161
|
+
description: 'Contact ID (phone number with @s.whatsapp.net)',
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
required: ['contactId'],
|
|
165
|
+
},
|
|
166
|
+
handler: async (args) => {
|
|
167
|
+
const input = validateInput(getContactSchema, args);
|
|
168
|
+
logger.info('Getting contact business profile', { contactId: input.contactId });
|
|
169
|
+
const result = await wsapiClient.get(`/contacts/${input.contactId}/business`);
|
|
170
|
+
logger.info('Retrieved contact business profile successfully', { contactId: input.contactId });
|
|
171
|
+
return {
|
|
172
|
+
success: true,
|
|
173
|
+
businessProfile: result,
|
|
174
|
+
message: 'Contact business profile retrieved successfully',
|
|
175
|
+
};
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
// Subscribe to contact presence updates
|
|
179
|
+
export const subscribeToContactPresence = {
|
|
180
|
+
name: 'whatsapp_subscribe_contact_presence',
|
|
181
|
+
description: 'Subscribe to presence updates for a specific contact.',
|
|
182
|
+
inputSchema: {
|
|
183
|
+
type: 'object',
|
|
184
|
+
properties: {
|
|
185
|
+
contactId: {
|
|
186
|
+
type: 'string',
|
|
187
|
+
description: 'Contact ID (phone number with @s.whatsapp.net)',
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
required: ['contactId'],
|
|
191
|
+
},
|
|
192
|
+
handler: async (args) => {
|
|
193
|
+
const input = validateInput(getContactSchema, args);
|
|
194
|
+
logger.info('Subscribing to contact presence', { contactId: input.contactId });
|
|
195
|
+
await wsapiClient.post(`/contacts/${input.contactId}/presence`, {});
|
|
196
|
+
logger.info('Subscribed to contact presence successfully', { contactId: input.contactId });
|
|
197
|
+
return {
|
|
198
|
+
success: true,
|
|
199
|
+
message: 'Successfully subscribed to contact presence updates',
|
|
200
|
+
};
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
// Export all contact tools
|
|
204
|
+
export const contactTools = {
|
|
205
|
+
getContacts,
|
|
206
|
+
getContact,
|
|
207
|
+
createContact,
|
|
208
|
+
updateContact,
|
|
209
|
+
getContactPicture,
|
|
210
|
+
getContactBusinessProfile,
|
|
211
|
+
subscribeToContactPresence,
|
|
212
|
+
};
|
|
213
|
+
//# sourceMappingURL=contacts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contacts.js","sourceRoot":"","sources":["../../src/tools/contacts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC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C3B,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,WAAW;IACX,UAAU;IACV,aAAa;IACb,aAAa;IACb,iBAAiB;IACjB,yBAAyB;IACzB,0BAA0B;CAC3B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ToolHandler } from '../server.js';
|
|
2
|
+
export declare const getGroups: ToolHandler;
|
|
3
|
+
export declare const createGroup: ToolHandler;
|
|
4
|
+
export declare const getGroup: ToolHandler;
|
|
5
|
+
export declare const updateGroupName: ToolHandler;
|
|
6
|
+
export declare const groupTools: {
|
|
7
|
+
getGroups: ToolHandler;
|
|
8
|
+
createGroup: ToolHandler;
|
|
9
|
+
getGroup: ToolHandler;
|
|
10
|
+
updateGroupName: ToolHandler;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=groups.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"groups.d.ts","sourceRoot":"","sources":["../../src/tools/groups.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAOhD,eAAO,MAAM,SAAS,EAAE,WASvB,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,WAiBzB,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,WAatB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,WAgB7B,CAAC;AAEF,eAAO,MAAM,UAAU;;;;;CAAwD,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { wsapiClient } from '../client/index.js';
|
|
2
|
+
import { createLogger } from '../utils/logger.js';
|
|
3
|
+
import { validateInput, createGroupSchema, getGroupSchema, updateGroupNameSchema } from '../validation/schemas.js';
|
|
4
|
+
const logger = createLogger('group-tools');
|
|
5
|
+
export const getGroups = {
|
|
6
|
+
name: 'whatsapp_get_groups',
|
|
7
|
+
description: 'Get list of all WhatsApp groups.',
|
|
8
|
+
inputSchema: { type: 'object', properties: {} },
|
|
9
|
+
handler: async () => {
|
|
10
|
+
logger.info('Getting groups list');
|
|
11
|
+
const result = await wsapiClient.get('/groups');
|
|
12
|
+
return { success: true, groups: result, count: result.length };
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
export const createGroup = {
|
|
16
|
+
name: 'whatsapp_create_group',
|
|
17
|
+
description: 'Create a new WhatsApp group.',
|
|
18
|
+
inputSchema: {
|
|
19
|
+
type: 'object',
|
|
20
|
+
properties: {
|
|
21
|
+
name: { type: 'string', description: 'Group name (max 255 characters)' },
|
|
22
|
+
participants: { type: 'array', items: { type: 'string' }, description: 'List of participant phone numbers' },
|
|
23
|
+
},
|
|
24
|
+
required: ['name', 'participants'],
|
|
25
|
+
},
|
|
26
|
+
handler: async (args) => {
|
|
27
|
+
const input = validateInput(createGroupSchema, args);
|
|
28
|
+
logger.info('Creating group', { name: input.name, participantCount: input.participants.length });
|
|
29
|
+
const result = await wsapiClient.post('/groups', input);
|
|
30
|
+
return { success: true, groupId: result.id, message: 'Group created successfully' };
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
export const getGroup = {
|
|
34
|
+
name: 'whatsapp_get_group',
|
|
35
|
+
description: 'Get information about a specific group.',
|
|
36
|
+
inputSchema: {
|
|
37
|
+
type: 'object',
|
|
38
|
+
properties: { groupId: { type: 'string', description: 'Group ID (with @g.us)' } },
|
|
39
|
+
required: ['groupId'],
|
|
40
|
+
},
|
|
41
|
+
handler: async (args) => {
|
|
42
|
+
const input = validateInput(getGroupSchema, args);
|
|
43
|
+
const result = await wsapiClient.get(`/groups/${input.groupId}`);
|
|
44
|
+
return { success: true, group: result };
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
export const updateGroupName = {
|
|
48
|
+
name: 'whatsapp_update_group_name',
|
|
49
|
+
description: 'Update group name.',
|
|
50
|
+
inputSchema: {
|
|
51
|
+
type: 'object',
|
|
52
|
+
properties: {
|
|
53
|
+
groupId: { type: 'string', description: 'Group ID (with @g.us)' },
|
|
54
|
+
name: { type: 'string', description: 'New group name' },
|
|
55
|
+
},
|
|
56
|
+
required: ['groupId', 'name'],
|
|
57
|
+
},
|
|
58
|
+
handler: async (args) => {
|
|
59
|
+
const input = validateInput(updateGroupNameSchema, args);
|
|
60
|
+
await wsapiClient.put(`/groups/${input.groupId}/name`, { name: input.name });
|
|
61
|
+
return { success: true, message: 'Group name updated successfully' };
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
export const groupTools = { getGroups, createGroup, getGroup, updateGroupName };
|
|
65
|
+
//# sourceMappingURL=groups.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"groups.js","sourceRoot":"","sources":["../../src/tools/groups.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,cAAc,EAAE,qBAAqB,EAAgC,MAAM,0BAA0B,CAAC;AAEjJ,MAAM,MAAM,GAAG,YAAY,CAAC,aAAa,CAAC,CAAC;AAE3C,MAAM,CAAC,MAAM,SAAS,GAAgB;IACpC,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EAAE,kCAAkC;IAC/C,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE;IAC/C,OAAO,EAAE,KAAK,IAAI,EAAE;QAClB,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QACnC,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAChD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;IACjE,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAgB;IACtC,IAAI,EAAE,uBAAuB;IAC7B,WAAW,EA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AAM,WAAW,CAAC,GAAG,CAAC,WAAW,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACjE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAC1C,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAgB;IAC1C,IAAI,EAAE,4BAA4B;IAClC,WAAW,EAAE,oBAAoB;IACjC,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,uBAAuB,EAAE;YACjE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,gBAAgB,EAAE;SACxD;QACD,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,CAAC;KAC9B;IACD,OAAO,EAAE,KAAK,EAAE,IAAS,EAAE,EAAE;QAC3B,MAAM,KAAK,GAAG,aAAa,CAAC,qBAAqB,EAAE,IAAI,CAAC,CAAC;QACzD,MAAM,WAAW,CAAC,GAAG,CAAC,WAAW,KAAK,CAAC,OAAO,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;QAC7E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,iCAAiC,EAAE,CAAC;IACvE,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ToolHandler } from '../server.js';
|
|
2
|
+
export declare const getInstanceSettings: ToolHandler;
|
|
3
|
+
export declare const updateInstanceSettings: ToolHandler;
|
|
4
|
+
export declare const restartInstance: ToolHandler;
|
|
5
|
+
export declare const updateApiKey: ToolHandler;
|
|
6
|
+
export declare const instanceTools: {
|
|
7
|
+
getInstanceSettings: ToolHandler;
|
|
8
|
+
updateInstanceSettings: ToolHandler;
|
|
9
|
+
restartInstance: ToolHandler;
|
|
10
|
+
updateApiKey: ToolHandler;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=instance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instance.d.ts","sourceRoot":"","sources":["../../src/tools/instance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAOhD,eAAO,MAAM,mBAAmB,EAAE,WASjC,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,WAiBpC,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,WAS7B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,WAS1B,CAAC;AAEF,eAAO,MAAM,aAAa;;;;;CAAiF,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { wsapiClient } from '../client/index.js';
|
|
2
|
+
import { createLogger } from '../utils/logger.js';
|
|
3
|
+
import { validateInput, updateInstanceSettingsSchema } from '../validation/schemas.js';
|
|
4
|
+
const logger = createLogger('instance-tools');
|
|
5
|
+
export const getInstanceSettings = {
|
|
6
|
+
name: 'whatsapp_get_instance_settings',
|
|
7
|
+
description: 'Get current instance settings.',
|
|
8
|
+
inputSchema: { type: 'object', properties: {} },
|
|
9
|
+
handler: async () => {
|
|
10
|
+
logger.info('Getting instance settings');
|
|
11
|
+
const result = await wsapiClient.get('/instance/settings');
|
|
12
|
+
return { success: true, settings: result, message: 'Instance settings retrieved successfully' };
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
export const updateInstanceSettings = {
|
|
16
|
+
name: 'whatsapp_update_instance_settings',
|
|
17
|
+
description: 'Update instance settings.',
|
|
18
|
+
inputSchema: {
|
|
19
|
+
type: 'object',
|
|
20
|
+
properties: {
|
|
21
|
+
name: { type: 'string', description: 'Instance name', optional: true },
|
|
22
|
+
description: { type: 'string', description: 'Instance description', optional: true },
|
|
23
|
+
pullMode: { type: 'boolean', description: 'Enable pull mode for events', optional: true },
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
handler: async (args) => {
|
|
27
|
+
const input = validateInput(updateInstanceSettingsSchema, args);
|
|
28
|
+
logger.info('Updating instance settings');
|
|
29
|
+
const result = await wsapiClient.put('/instance/settings', input);
|
|
30
|
+
return { success: true, settings: result, message: 'Instance settings updated successfully' };
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
export const restartInstance = {
|
|
34
|
+
name: 'whatsapp_restart_instance',
|
|
35
|
+
description: 'Restart the WhatsApp instance.',
|
|
36
|
+
inputSchema: { type: 'object', properties: {} },
|
|
37
|
+
handler: async () => {
|
|
38
|
+
logger.info('Restarting instance');
|
|
39
|
+
await wsapiClient.put('/instance/restart', {});
|
|
40
|
+
return { success: true, message: 'Instance restarted successfully' };
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
export const updateApiKey = {
|
|
44
|
+
name: 'whatsapp_update_api_key',
|
|
45
|
+
description: 'Generate a new API key for the instance.',
|
|
46
|
+
inputSchema: { type: 'object', properties: {} },
|
|
47
|
+
handler: async () => {
|
|
48
|
+
logger.info('Updating API key');
|
|
49
|
+
const result = await wsapiClient.put('/instance/apikey', {});
|
|
50
|
+
return { success: true, apiKey: result, message: 'API key updated successfully' };
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
export const instanceTools = { getInstanceSettings, updateInstanceSettings, restartInstance, updateApiKey };
|
|
54
|
+
//# sourceMappingURL=instance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instance.js","sourceRoot":"","sources":["../../src/tools/instance.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AAEvF,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Handler;
|
|
4
|
+
export declare const sendDocumentMessage: ToolHandler;
|
|
5
|
+
export declare const sendStickerMessage: ToolHandler;
|
|
6
|
+
export declare const sendLocationMessage: ToolHandler;
|
|
7
|
+
export declare const sendContactMessage: ToolHandler;
|
|
8
|
+
export declare const advancedMessagingTools: {
|
|
9
|
+
sendAudioMessage: ToolHandler;
|
|
10
|
+
sendVoiceMessage: ToolHandler;
|
|
11
|
+
sendDocumentMessage: ToolHandler;
|
|
12
|
+
sendStickerMessage: ToolHandler;
|
|
13
|
+
sendLocationMessage: ToolHandler;
|
|
14
|
+
sendContactMessage: ToolHandler;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=messaging-advanced.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messaging-advanced.d.ts","sourceRoot":"","sources":["../../src/tools/messaging-advanced.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAsBhD,eAAO,MAAM,gBAAgB,EAAE,WAoE9B,CAAC;AAGF,eAAO,MAAM,gBAAgB,EAAE,WA8D9B,CAAC;AAGF,eAAO,MAAM,mBAAmB,EAAE,WAmEjC,CAAC;AAGF,eAAO,MAAM,kBAAkB,EAAE,WAoEhC,CAAC;AAGF,eAAO,MAAM,mBAAmB,EAAE,WA6DjC,CAAC;AAGF,eAAO,MAAM,kBAAkB,EAAE,WA0DhC,CAAC;AAGF,eAAO,MAAM,sBAAsB;;;;;;;CAOlC,CAAC"}
|