@elizaos/plugin-whatsapp 2.0.0-alpha.5 → 2.0.0-alpha.537
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 +278 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/index.js +2298 -0
- package/dist/index.js.map +26 -0
- package/dist/src/accounts.d.ts +217 -0
- package/dist/src/accounts.d.ts.map +1 -0
- package/dist/src/actions/index.d.ts +6 -0
- package/dist/src/actions/index.d.ts.map +1 -0
- package/dist/src/actions/sendMessage.d.ts +4 -0
- package/dist/src/actions/sendMessage.d.ts.map +1 -0
- package/dist/src/actions/sendReaction.d.ts +4 -0
- package/dist/src/actions/sendReaction.d.ts.map +1 -0
- package/dist/src/baileys/auth.d.ts +10 -0
- package/dist/src/baileys/auth.d.ts.map +1 -0
- package/dist/src/baileys/connection.d.ts +19 -0
- package/dist/src/baileys/connection.d.ts.map +1 -0
- package/dist/src/baileys/index.d.ts +5 -0
- package/dist/src/baileys/index.d.ts.map +1 -0
- package/dist/src/baileys/message-adapter.d.ts +14 -0
- package/dist/src/baileys/message-adapter.d.ts.map +1 -0
- package/dist/src/baileys/qr-code.d.ts +6 -0
- package/dist/src/baileys/qr-code.d.ts.map +1 -0
- package/dist/src/client.d.ts +139 -0
- package/dist/src/client.d.ts.map +1 -0
- package/dist/src/clients/baileys-client.d.ts +26 -0
- package/dist/src/clients/baileys-client.d.ts.map +1 -0
- package/dist/src/clients/factory.d.ts +6 -0
- package/dist/src/clients/factory.d.ts.map +1 -0
- package/dist/src/clients/index.d.ts +4 -0
- package/dist/src/clients/index.d.ts.map +1 -0
- package/dist/src/clients/interface.d.ts +10 -0
- package/dist/src/clients/interface.d.ts.map +1 -0
- package/dist/src/config.d.ts +144 -0
- package/dist/src/config.d.ts.map +1 -0
- package/dist/src/handlers/index.d.ts +3 -0
- package/dist/src/handlers/index.d.ts.map +1 -0
- package/dist/src/handlers/message.handler.d.ts +8 -0
- package/dist/src/handlers/message.handler.d.ts.map +1 -0
- package/dist/src/handlers/webhook.handler.d.ts +7 -0
- package/dist/src/handlers/webhook.handler.d.ts.map +1 -0
- package/dist/src/index.d.ts +62 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/normalize.d.ts +72 -0
- package/dist/src/normalize.d.ts.map +1 -0
- package/dist/src/pairing-service.d.ts +54 -0
- package/dist/src/pairing-service.d.ts.map +1 -0
- package/dist/src/runtime-service.d.ts +50 -0
- package/dist/src/runtime-service.d.ts.map +1 -0
- package/dist/src/service.d.ts +157 -0
- package/dist/src/service.d.ts.map +1 -0
- package/dist/src/setup-routes.d.ts +26 -0
- package/dist/src/setup-routes.d.ts.map +1 -0
- package/dist/src/types.d.ts +396 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/utils/config-detector.d.ts +5 -0
- package/dist/src/utils/config-detector.d.ts.map +1 -0
- package/dist/src/utils/index.d.ts +3 -0
- package/dist/src/utils/index.d.ts.map +1 -0
- package/dist/src/utils/validators.d.ts +14 -0
- package/dist/src/utils/validators.d.ts.map +1 -0
- package/package.json +41 -17
- package/dist/index.d.ts +0 -2
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
export type WhatsAppConfig = CloudAPIConfig | BaileysConfig;
|
|
2
|
+
export interface CloudAPIConfig {
|
|
3
|
+
authMethod?: "cloudapi";
|
|
4
|
+
accessToken: string;
|
|
5
|
+
phoneNumberId: string;
|
|
6
|
+
webhookVerifyToken?: string;
|
|
7
|
+
businessAccountId?: string;
|
|
8
|
+
apiVersion?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface BaileysConfig {
|
|
11
|
+
authMethod?: "baileys";
|
|
12
|
+
authDir: string;
|
|
13
|
+
printQRInTerminal?: boolean;
|
|
14
|
+
sessionPath?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Message types supported by WhatsApp Cloud API.
|
|
18
|
+
*/
|
|
19
|
+
export type WhatsAppMessageType =
|
|
20
|
+
| "text"
|
|
21
|
+
| "template"
|
|
22
|
+
| "image"
|
|
23
|
+
| "audio"
|
|
24
|
+
| "video"
|
|
25
|
+
| "document"
|
|
26
|
+
| "sticker"
|
|
27
|
+
| "location"
|
|
28
|
+
| "contacts"
|
|
29
|
+
| "interactive"
|
|
30
|
+
| "reaction";
|
|
31
|
+
export interface WhatsAppMessage {
|
|
32
|
+
type: WhatsAppMessageType;
|
|
33
|
+
to: string;
|
|
34
|
+
content:
|
|
35
|
+
| string
|
|
36
|
+
| WhatsAppTemplate
|
|
37
|
+
| WhatsAppMediaMessage
|
|
38
|
+
| WhatsAppInteractiveMessage
|
|
39
|
+
| WhatsAppReactionMessage
|
|
40
|
+
| WhatsAppLocationMessage;
|
|
41
|
+
replyToMessageId?: string;
|
|
42
|
+
}
|
|
43
|
+
export interface WhatsAppTemplate {
|
|
44
|
+
name: string;
|
|
45
|
+
language: {
|
|
46
|
+
code: string;
|
|
47
|
+
};
|
|
48
|
+
components?: Array<{
|
|
49
|
+
type: string;
|
|
50
|
+
parameters: Array<{
|
|
51
|
+
type: string;
|
|
52
|
+
text?: string;
|
|
53
|
+
image?: {
|
|
54
|
+
link: string;
|
|
55
|
+
};
|
|
56
|
+
document?: {
|
|
57
|
+
link: string;
|
|
58
|
+
filename?: string;
|
|
59
|
+
};
|
|
60
|
+
video?: {
|
|
61
|
+
link: string;
|
|
62
|
+
};
|
|
63
|
+
}>;
|
|
64
|
+
}>;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Media message content.
|
|
68
|
+
*/
|
|
69
|
+
export interface WhatsAppMediaMessage {
|
|
70
|
+
link?: string;
|
|
71
|
+
id?: string;
|
|
72
|
+
caption?: string;
|
|
73
|
+
filename?: string;
|
|
74
|
+
mimeType?: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Reaction message content.
|
|
78
|
+
*/
|
|
79
|
+
export interface WhatsAppReactionMessage {
|
|
80
|
+
messageId: string;
|
|
81
|
+
emoji: string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Location message content.
|
|
85
|
+
*/
|
|
86
|
+
export interface WhatsAppLocationMessage {
|
|
87
|
+
latitude: number;
|
|
88
|
+
longitude: number;
|
|
89
|
+
name?: string;
|
|
90
|
+
address?: string;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Interactive message types.
|
|
94
|
+
*/
|
|
95
|
+
export type InteractiveMessageType =
|
|
96
|
+
| "button"
|
|
97
|
+
| "list"
|
|
98
|
+
| "product"
|
|
99
|
+
| "product_list"
|
|
100
|
+
| "flow";
|
|
101
|
+
/**
|
|
102
|
+
* Interactive message content.
|
|
103
|
+
*/
|
|
104
|
+
export interface WhatsAppInteractiveMessage {
|
|
105
|
+
type: InteractiveMessageType;
|
|
106
|
+
header?: {
|
|
107
|
+
type: "text" | "image" | "video" | "document";
|
|
108
|
+
text?: string;
|
|
109
|
+
image?: {
|
|
110
|
+
link: string;
|
|
111
|
+
};
|
|
112
|
+
video?: {
|
|
113
|
+
link: string;
|
|
114
|
+
};
|
|
115
|
+
document?: {
|
|
116
|
+
link: string;
|
|
117
|
+
filename?: string;
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
body: {
|
|
121
|
+
text: string;
|
|
122
|
+
};
|
|
123
|
+
footer?: {
|
|
124
|
+
text: string;
|
|
125
|
+
};
|
|
126
|
+
action: WhatsAppInteractiveAction;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Interactive action based on message type.
|
|
130
|
+
*/
|
|
131
|
+
export type WhatsAppInteractiveAction =
|
|
132
|
+
| WhatsAppButtonAction
|
|
133
|
+
| WhatsAppListAction
|
|
134
|
+
| WhatsAppFlowAction;
|
|
135
|
+
/**
|
|
136
|
+
* Button action for interactive messages.
|
|
137
|
+
*/
|
|
138
|
+
export interface WhatsAppButtonAction {
|
|
139
|
+
buttons: Array<{
|
|
140
|
+
type: "reply";
|
|
141
|
+
reply: {
|
|
142
|
+
id: string;
|
|
143
|
+
title: string;
|
|
144
|
+
};
|
|
145
|
+
}>;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* List action for interactive messages.
|
|
149
|
+
*/
|
|
150
|
+
export interface WhatsAppListAction {
|
|
151
|
+
button: string;
|
|
152
|
+
sections: Array<{
|
|
153
|
+
title?: string;
|
|
154
|
+
rows: Array<{
|
|
155
|
+
id: string;
|
|
156
|
+
title: string;
|
|
157
|
+
description?: string;
|
|
158
|
+
}>;
|
|
159
|
+
}>;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Flow action for interactive messages.
|
|
163
|
+
*/
|
|
164
|
+
export interface WhatsAppFlowAction {
|
|
165
|
+
name: "flow";
|
|
166
|
+
parameters: {
|
|
167
|
+
flow_message_version: string;
|
|
168
|
+
flow_token: string;
|
|
169
|
+
flow_id: string;
|
|
170
|
+
flow_cta: string;
|
|
171
|
+
flow_action: "navigate" | "data_exchange";
|
|
172
|
+
flow_action_payload?: {
|
|
173
|
+
screen: string;
|
|
174
|
+
data?: Record<string, unknown>;
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
export interface WhatsAppIncomingMessage {
|
|
179
|
+
from: string;
|
|
180
|
+
id: string;
|
|
181
|
+
timestamp: string;
|
|
182
|
+
text?: {
|
|
183
|
+
body: string;
|
|
184
|
+
};
|
|
185
|
+
image?: {
|
|
186
|
+
caption?: string;
|
|
187
|
+
mime_type: string;
|
|
188
|
+
sha256: string;
|
|
189
|
+
id: string;
|
|
190
|
+
};
|
|
191
|
+
video?: {
|
|
192
|
+
caption?: string;
|
|
193
|
+
mime_type: string;
|
|
194
|
+
sha256: string;
|
|
195
|
+
id: string;
|
|
196
|
+
};
|
|
197
|
+
audio?: {
|
|
198
|
+
mime_type: string;
|
|
199
|
+
sha256: string;
|
|
200
|
+
id: string;
|
|
201
|
+
voice?: boolean;
|
|
202
|
+
};
|
|
203
|
+
document?: {
|
|
204
|
+
caption?: string;
|
|
205
|
+
filename: string;
|
|
206
|
+
mime_type: string;
|
|
207
|
+
sha256: string;
|
|
208
|
+
id: string;
|
|
209
|
+
};
|
|
210
|
+
sticker?: {
|
|
211
|
+
mime_type: string;
|
|
212
|
+
sha256: string;
|
|
213
|
+
id: string;
|
|
214
|
+
animated?: boolean;
|
|
215
|
+
};
|
|
216
|
+
location?: {
|
|
217
|
+
latitude: number;
|
|
218
|
+
longitude: number;
|
|
219
|
+
name?: string;
|
|
220
|
+
address?: string;
|
|
221
|
+
};
|
|
222
|
+
contacts?: Array<{
|
|
223
|
+
name: {
|
|
224
|
+
formatted_name: string;
|
|
225
|
+
first_name?: string;
|
|
226
|
+
last_name?: string;
|
|
227
|
+
};
|
|
228
|
+
phones?: Array<{
|
|
229
|
+
phone: string;
|
|
230
|
+
type: string;
|
|
231
|
+
}>;
|
|
232
|
+
}>;
|
|
233
|
+
interactive?: {
|
|
234
|
+
type: "button_reply" | "list_reply" | "nfm_reply";
|
|
235
|
+
button_reply?: {
|
|
236
|
+
id: string;
|
|
237
|
+
title: string;
|
|
238
|
+
};
|
|
239
|
+
list_reply?: {
|
|
240
|
+
id: string;
|
|
241
|
+
title: string;
|
|
242
|
+
description?: string;
|
|
243
|
+
};
|
|
244
|
+
nfm_reply?: {
|
|
245
|
+
response_json: string;
|
|
246
|
+
body: string;
|
|
247
|
+
name: string;
|
|
248
|
+
};
|
|
249
|
+
};
|
|
250
|
+
reaction?: {
|
|
251
|
+
message_id: string;
|
|
252
|
+
emoji: string;
|
|
253
|
+
};
|
|
254
|
+
context?: {
|
|
255
|
+
from: string;
|
|
256
|
+
id: string;
|
|
257
|
+
referred_product?: {
|
|
258
|
+
catalog_id: string;
|
|
259
|
+
product_retailer_id: string;
|
|
260
|
+
};
|
|
261
|
+
};
|
|
262
|
+
type: string;
|
|
263
|
+
}
|
|
264
|
+
export interface WhatsAppStatusUpdate {
|
|
265
|
+
id: string;
|
|
266
|
+
status: "sent" | "delivered" | "read" | "failed";
|
|
267
|
+
timestamp: string;
|
|
268
|
+
recipient_id: string;
|
|
269
|
+
conversation?: {
|
|
270
|
+
id: string;
|
|
271
|
+
origin?: {
|
|
272
|
+
type: string;
|
|
273
|
+
};
|
|
274
|
+
expiration_timestamp?: string;
|
|
275
|
+
};
|
|
276
|
+
pricing?: {
|
|
277
|
+
billable: boolean;
|
|
278
|
+
pricing_model: string;
|
|
279
|
+
category: string;
|
|
280
|
+
};
|
|
281
|
+
errors?: Array<{
|
|
282
|
+
code: number;
|
|
283
|
+
title: string;
|
|
284
|
+
message?: string;
|
|
285
|
+
error_data?: {
|
|
286
|
+
details: string;
|
|
287
|
+
};
|
|
288
|
+
}>;
|
|
289
|
+
}
|
|
290
|
+
export interface WhatsAppWebhookEvent {
|
|
291
|
+
object: string;
|
|
292
|
+
entry: Array<{
|
|
293
|
+
id: string;
|
|
294
|
+
changes: Array<{
|
|
295
|
+
value: {
|
|
296
|
+
messaging_product: string;
|
|
297
|
+
metadata: {
|
|
298
|
+
display_phone_number: string;
|
|
299
|
+
phone_number_id: string;
|
|
300
|
+
};
|
|
301
|
+
statuses?: WhatsAppStatusUpdate[];
|
|
302
|
+
messages?: WhatsAppIncomingMessage[];
|
|
303
|
+
contacts?: Array<{
|
|
304
|
+
profile: {
|
|
305
|
+
name: string;
|
|
306
|
+
};
|
|
307
|
+
wa_id: string;
|
|
308
|
+
}>;
|
|
309
|
+
errors?: Array<{
|
|
310
|
+
code: number;
|
|
311
|
+
title: string;
|
|
312
|
+
message?: string;
|
|
313
|
+
error_data?: {
|
|
314
|
+
details: string;
|
|
315
|
+
};
|
|
316
|
+
}>;
|
|
317
|
+
};
|
|
318
|
+
field: string;
|
|
319
|
+
}>;
|
|
320
|
+
}>;
|
|
321
|
+
}
|
|
322
|
+
export interface WhatsAppMessageResponse {
|
|
323
|
+
messaging_product: string;
|
|
324
|
+
contacts: Array<{
|
|
325
|
+
input: string;
|
|
326
|
+
wa_id: string;
|
|
327
|
+
}>;
|
|
328
|
+
messages: Array<{
|
|
329
|
+
id: string;
|
|
330
|
+
message_status?: string;
|
|
331
|
+
}>;
|
|
332
|
+
}
|
|
333
|
+
export interface QRCodeData {
|
|
334
|
+
terminal: string;
|
|
335
|
+
dataURL: string;
|
|
336
|
+
raw: string;
|
|
337
|
+
}
|
|
338
|
+
export type ConnectionStatus = "connecting" | "open" | "close";
|
|
339
|
+
export interface NormalizedMessage {
|
|
340
|
+
id: string;
|
|
341
|
+
from: string;
|
|
342
|
+
timestamp: number;
|
|
343
|
+
type: "text" | "image" | "audio" | "video" | "document";
|
|
344
|
+
content: string;
|
|
345
|
+
chatId?: string;
|
|
346
|
+
senderId?: string;
|
|
347
|
+
replyToId?: string;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Send reaction parameters.
|
|
351
|
+
*/
|
|
352
|
+
export interface SendReactionParams {
|
|
353
|
+
to: string;
|
|
354
|
+
messageId: string;
|
|
355
|
+
emoji: string;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Send reaction result.
|
|
359
|
+
*/
|
|
360
|
+
export interface SendReactionResult {
|
|
361
|
+
success: boolean;
|
|
362
|
+
messageId?: string;
|
|
363
|
+
error?: string;
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* WhatsApp event types.
|
|
367
|
+
*/
|
|
368
|
+
export declare enum WhatsAppEventType {
|
|
369
|
+
MESSAGE_RECEIVED = "WHATSAPP_MESSAGE_RECEIVED",
|
|
370
|
+
MESSAGE_SENT = "WHATSAPP_MESSAGE_SENT",
|
|
371
|
+
MESSAGE_DELIVERED = "WHATSAPP_MESSAGE_DELIVERED",
|
|
372
|
+
MESSAGE_READ = "WHATSAPP_MESSAGE_READ",
|
|
373
|
+
MESSAGE_FAILED = "WHATSAPP_MESSAGE_FAILED",
|
|
374
|
+
REACTION_RECEIVED = "WHATSAPP_REACTION_RECEIVED",
|
|
375
|
+
REACTION_SENT = "WHATSAPP_REACTION_SENT",
|
|
376
|
+
INTERACTIVE_REPLY = "WHATSAPP_INTERACTIVE_REPLY",
|
|
377
|
+
WEBHOOK_VERIFIED = "WHATSAPP_WEBHOOK_VERIFIED",
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Common WhatsApp reaction emojis.
|
|
381
|
+
*/
|
|
382
|
+
export declare const WHATSAPP_REACTIONS: {
|
|
383
|
+
readonly THUMBS_UP: "👍";
|
|
384
|
+
readonly THUMBS_DOWN: "👎";
|
|
385
|
+
readonly HEART: "❤️";
|
|
386
|
+
readonly LAUGHING: "😂";
|
|
387
|
+
readonly SURPRISED: "😮";
|
|
388
|
+
readonly SAD: "😢";
|
|
389
|
+
readonly PRAYING: "🙏";
|
|
390
|
+
readonly CLAPPING: "👏";
|
|
391
|
+
readonly FIRE: "🔥";
|
|
392
|
+
readonly CELEBRATION: "🎉";
|
|
393
|
+
};
|
|
394
|
+
export type WhatsAppReactionEmoji =
|
|
395
|
+
(typeof WHATSAPP_REACTIONS)[keyof typeof WHATSAPP_REACTIONS];
|
|
396
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,cAAc,GAAG,aAAa,CAAC;AAE5D,MAAM,WAAW,cAAc;IAC7B,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;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C,GAC/C,SAAS,GAAG,UAAU,CAsBxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
WhatsAppConfig,
|
|
3
|
+
WhatsAppMessage,
|
|
4
|
+
WhatsAppTemplate,
|
|
5
|
+
} from "../types";
|
|
6
|
+
export declare function validateConfig(config: WhatsAppConfig): void;
|
|
7
|
+
export declare function validateMessage(message: WhatsAppMessage): void;
|
|
8
|
+
export declare function validateTemplate(template: WhatsAppTemplate): void;
|
|
9
|
+
/**
|
|
10
|
+
* Validates a WhatsApp phone number using robust E.164 format checking.
|
|
11
|
+
* Requires at minimum 10 digits and validates against WhatsApp JID normalization rules.
|
|
12
|
+
*/
|
|
13
|
+
export declare function validatePhoneNumber(phoneNumber: string): boolean;
|
|
14
|
+
//# sourceMappingURL=validators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../../src/utils/validators.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAGlF,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAgB3D;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI,CAgB9D;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI,CAQjE;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAEhE"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elizaos/plugin-whatsapp",
|
|
3
|
-
"description": "WhatsApp Cloud API
|
|
4
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"description": "WhatsApp plugin for ElizaOS (Cloud API + Baileys QR auth)",
|
|
4
|
+
"version": "2.0.0-alpha.537",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
8
|
-
"types": "dist/index.d.ts",
|
|
8
|
+
"types": "dist/src/index.d.ts",
|
|
9
9
|
"packageType": "plugin",
|
|
10
10
|
"platform": "node",
|
|
11
11
|
"license": "MIT",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"./package.json": "./package.json",
|
|
23
23
|
".": {
|
|
24
24
|
"import": {
|
|
25
|
-
"types": "./dist/index.d.ts",
|
|
25
|
+
"types": "./dist/src/index.d.ts",
|
|
26
26
|
"default": "./dist/index.js"
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -33,27 +33,33 @@
|
|
|
33
33
|
"package.json"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"
|
|
36
|
+
"@hapi/boom": "^10.0.1",
|
|
37
|
+
"@whiskeysockets/baileys": "^7.0.0-rc.9",
|
|
38
|
+
"axios": "^1.16.0",
|
|
39
|
+
"pino": "^10.3.1",
|
|
40
|
+
"qrcode": "^1.5.4",
|
|
41
|
+
"qrcode-terminal": "^0.12.0"
|
|
37
42
|
},
|
|
38
43
|
"peerDependencies": {
|
|
39
|
-
"@elizaos/core": "2.0.0-alpha.
|
|
44
|
+
"@elizaos/core": "^2.0.0-alpha.537"
|
|
40
45
|
},
|
|
41
46
|
"devDependencies": {
|
|
42
|
-
"@biomejs/biome": "^2.
|
|
47
|
+
"@biomejs/biome": "^2.4.14",
|
|
43
48
|
"@types/node": "^25.0.3",
|
|
44
|
-
"typescript": "^
|
|
49
|
+
"typescript": "^6.0.0",
|
|
50
|
+
"vitest": "^4.0.0"
|
|
45
51
|
},
|
|
46
52
|
"scripts": {
|
|
47
53
|
"dev": "bun --hot build.ts",
|
|
48
|
-
"test": "vitest run
|
|
49
|
-
"lint": "bunx @biomejs/biome check --write --
|
|
50
|
-
"typecheck": "tsc --noEmit",
|
|
54
|
+
"test": "vitest run --config ./vitest.config.ts",
|
|
55
|
+
"lint": "bunx @biomejs/biome check --write --config-path ./biome.json .",
|
|
56
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
51
57
|
"clean": "rm -rf dist .turbo",
|
|
52
|
-
"lint:check": "bunx @biomejs/biome check .",
|
|
58
|
+
"lint:check": "bunx @biomejs/biome check --config-path ./biome.json .",
|
|
53
59
|
"build": "bun run build.ts",
|
|
54
60
|
"build:ts": "bun run build.ts",
|
|
55
|
-
"format": "bunx @biomejs/biome format --write .",
|
|
56
|
-
"format:check": "bunx @biomejs/biome format ."
|
|
61
|
+
"format": "bunx @biomejs/biome format --write --config-path ./biome.json .",
|
|
62
|
+
"format:check": "bunx @biomejs/biome format --config-path ./biome.json ."
|
|
57
63
|
},
|
|
58
64
|
"publishConfig": {
|
|
59
65
|
"access": "public"
|
|
@@ -62,13 +68,31 @@
|
|
|
62
68
|
"pluginParameters": {
|
|
63
69
|
"WHATSAPP_ACCESS_TOKEN": {
|
|
64
70
|
"type": "string",
|
|
65
|
-
"description": "Access token for
|
|
66
|
-
"required":
|
|
71
|
+
"description": "Access token for WhatsApp Cloud API (required for cloudapi auth)",
|
|
72
|
+
"required": false,
|
|
67
73
|
"sensitive": true
|
|
68
74
|
},
|
|
69
75
|
"WHATSAPP_PHONE_NUMBER_ID": {
|
|
70
76
|
"type": "string",
|
|
71
|
-
"description": "Phone number ID",
|
|
77
|
+
"description": "Phone number ID for WhatsApp Cloud API (required for cloudapi auth)",
|
|
78
|
+
"required": false,
|
|
79
|
+
"sensitive": false
|
|
80
|
+
},
|
|
81
|
+
"WHATSAPP_AUTH_METHOD": {
|
|
82
|
+
"type": "string",
|
|
83
|
+
"description": "Authentication method: cloudapi or baileys",
|
|
84
|
+
"required": false,
|
|
85
|
+
"sensitive": false
|
|
86
|
+
},
|
|
87
|
+
"WHATSAPP_AUTH_DIR": {
|
|
88
|
+
"type": "string",
|
|
89
|
+
"description": "Directory used to persist Baileys session files (required for baileys auth)",
|
|
90
|
+
"required": false,
|
|
91
|
+
"sensitive": false
|
|
92
|
+
},
|
|
93
|
+
"WHATSAPP_PRINT_QR": {
|
|
94
|
+
"type": "boolean",
|
|
95
|
+
"description": "Print QR code in terminal when using Baileys auth",
|
|
72
96
|
"required": false,
|
|
73
97
|
"sensitive": false
|
|
74
98
|
},
|
package/dist/index.d.ts
DELETED