@elizaos/plugin-whatsapp 2.0.0-alpha.4 → 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.
Files changed (62) hide show
  1. package/README.md +278 -0
  2. package/dist/.tsbuildinfo +1 -0
  3. package/dist/index.js +2298 -0
  4. package/dist/index.js.map +26 -0
  5. package/dist/src/accounts.d.ts +217 -0
  6. package/dist/src/accounts.d.ts.map +1 -0
  7. package/dist/src/actions/index.d.ts +6 -0
  8. package/dist/src/actions/index.d.ts.map +1 -0
  9. package/dist/src/actions/sendMessage.d.ts +4 -0
  10. package/dist/src/actions/sendMessage.d.ts.map +1 -0
  11. package/dist/src/actions/sendReaction.d.ts +4 -0
  12. package/dist/src/actions/sendReaction.d.ts.map +1 -0
  13. package/dist/src/baileys/auth.d.ts +10 -0
  14. package/dist/src/baileys/auth.d.ts.map +1 -0
  15. package/dist/src/baileys/connection.d.ts +19 -0
  16. package/dist/src/baileys/connection.d.ts.map +1 -0
  17. package/dist/src/baileys/index.d.ts +5 -0
  18. package/dist/src/baileys/index.d.ts.map +1 -0
  19. package/dist/src/baileys/message-adapter.d.ts +14 -0
  20. package/dist/src/baileys/message-adapter.d.ts.map +1 -0
  21. package/dist/src/baileys/qr-code.d.ts +6 -0
  22. package/dist/src/baileys/qr-code.d.ts.map +1 -0
  23. package/dist/src/client.d.ts +139 -0
  24. package/dist/src/client.d.ts.map +1 -0
  25. package/dist/src/clients/baileys-client.d.ts +26 -0
  26. package/dist/src/clients/baileys-client.d.ts.map +1 -0
  27. package/dist/src/clients/factory.d.ts +6 -0
  28. package/dist/src/clients/factory.d.ts.map +1 -0
  29. package/dist/src/clients/index.d.ts +4 -0
  30. package/dist/src/clients/index.d.ts.map +1 -0
  31. package/dist/src/clients/interface.d.ts +10 -0
  32. package/dist/src/clients/interface.d.ts.map +1 -0
  33. package/dist/src/config.d.ts +144 -0
  34. package/dist/src/config.d.ts.map +1 -0
  35. package/dist/src/handlers/index.d.ts +3 -0
  36. package/dist/src/handlers/index.d.ts.map +1 -0
  37. package/dist/src/handlers/message.handler.d.ts +8 -0
  38. package/dist/src/handlers/message.handler.d.ts.map +1 -0
  39. package/dist/src/handlers/webhook.handler.d.ts +7 -0
  40. package/dist/src/handlers/webhook.handler.d.ts.map +1 -0
  41. package/dist/src/index.d.ts +62 -0
  42. package/dist/src/index.d.ts.map +1 -0
  43. package/dist/src/normalize.d.ts +72 -0
  44. package/dist/src/normalize.d.ts.map +1 -0
  45. package/dist/src/pairing-service.d.ts +54 -0
  46. package/dist/src/pairing-service.d.ts.map +1 -0
  47. package/dist/src/runtime-service.d.ts +50 -0
  48. package/dist/src/runtime-service.d.ts.map +1 -0
  49. package/dist/src/service.d.ts +157 -0
  50. package/dist/src/service.d.ts.map +1 -0
  51. package/dist/src/setup-routes.d.ts +26 -0
  52. package/dist/src/setup-routes.d.ts.map +1 -0
  53. package/dist/src/types.d.ts +396 -0
  54. package/dist/src/types.d.ts.map +1 -0
  55. package/dist/src/utils/config-detector.d.ts +5 -0
  56. package/dist/src/utils/config-detector.d.ts.map +1 -0
  57. package/dist/src/utils/index.d.ts +3 -0
  58. package/dist/src/utils/index.d.ts.map +1 -0
  59. package/dist/src/utils/validators.d.ts +14 -0
  60. package/dist/src/utils/validators.d.ts.map +1 -0
  61. package/package.json +84 -14
  62. package/dist/index.d.ts +0 -2
@@ -0,0 +1,217 @@
1
+ import type { IAgentRuntime } from "@elizaos/core";
2
+ /**
3
+ * Default account identifier used when no specific account is configured
4
+ */
5
+ export declare const DEFAULT_ACCOUNT_ID = "default";
6
+ /**
7
+ * Token source indicator
8
+ */
9
+ export type WhatsAppTokenSource = "config" | "env" | "character" | "none";
10
+ /**
11
+ * Group-specific runtime configuration (for account resolution)
12
+ */
13
+ export interface WhatsAppGroupRuntimeConfig {
14
+ /** If false, ignore messages from this group */
15
+ enabled?: boolean;
16
+ /** Allowlist for users in this group */
17
+ allowFrom?: Array<string | number>;
18
+ /** Require bot mention to respond */
19
+ requireMention?: boolean;
20
+ /** Custom system prompt for this group */
21
+ systemPrompt?: string;
22
+ /** Skills enabled for this group */
23
+ skills?: string[];
24
+ }
25
+ /**
26
+ * Configuration for a single WhatsApp account (runtime resolution)
27
+ */
28
+ export interface WhatsAppAccountRuntimeConfig {
29
+ /** Optional display name for this account */
30
+ name?: string;
31
+ /** If false, do not start this WhatsApp account */
32
+ enabled?: boolean;
33
+ /** WhatsApp Cloud API access token */
34
+ accessToken?: string;
35
+ /** Phone number ID from WhatsApp Business */
36
+ phoneNumberId?: string;
37
+ /** Business account ID */
38
+ businessAccountId?: string;
39
+ /** Webhook verification token */
40
+ webhookVerifyToken?: string;
41
+ /** API version to use */
42
+ apiVersion?: string;
43
+ /** Allowlist for DM senders */
44
+ allowFrom?: Array<string | number>;
45
+ /** Allowlist for groups */
46
+ groupAllowFrom?: Array<string | number>;
47
+ /** DM access policy */
48
+ dmPolicy?: "open" | "allowlist" | "pairing" | "disabled";
49
+ /** Group message access policy */
50
+ groupPolicy?: "open" | "allowlist" | "disabled";
51
+ /** Max media size in MB */
52
+ mediaMaxMb?: number;
53
+ /** Text chunk limit for messages */
54
+ textChunkLimit?: number;
55
+ /** Group-specific configurations */
56
+ groups?: Record<string, WhatsAppGroupRuntimeConfig>;
57
+ }
58
+ /**
59
+ * Multi-account WhatsApp configuration structure
60
+ */
61
+ export interface WhatsAppMultiAccountConfig {
62
+ /** Default/base configuration applied to all accounts */
63
+ enabled?: boolean;
64
+ accessToken?: string;
65
+ phoneNumberId?: string;
66
+ businessAccountId?: string;
67
+ webhookVerifyToken?: string;
68
+ apiVersion?: string;
69
+ dmPolicy?: "open" | "allowlist" | "pairing" | "disabled";
70
+ groupPolicy?: "open" | "allowlist" | "disabled";
71
+ mediaMaxMb?: number;
72
+ textChunkLimit?: number;
73
+ /** Per-account configuration overrides */
74
+ accounts?: Record<string, WhatsAppAccountRuntimeConfig>;
75
+ /** Group configurations at base level */
76
+ groups?: Record<string, WhatsAppGroupRuntimeConfig>;
77
+ }
78
+ /**
79
+ * Token resolution result
80
+ */
81
+ export interface WhatsAppTokenResolution {
82
+ token: string;
83
+ source: WhatsAppTokenSource;
84
+ }
85
+ /**
86
+ * Resolved WhatsApp account with all configuration merged
87
+ */
88
+ export interface ResolvedWhatsAppAccount {
89
+ accountId: string;
90
+ enabled: boolean;
91
+ name?: string;
92
+ accessToken: string;
93
+ phoneNumberId: string;
94
+ businessAccountId?: string;
95
+ tokenSource: WhatsAppTokenSource;
96
+ configured: boolean;
97
+ config: WhatsAppAccountRuntimeConfig;
98
+ }
99
+ /**
100
+ * Normalizes an account ID, returning the default if not provided
101
+ */
102
+ export declare function normalizeAccountId(accountId?: string | null): string;
103
+ /**
104
+ * Gets the multi-account configuration from runtime settings
105
+ */
106
+ export declare function getMultiAccountConfig(
107
+ runtime: IAgentRuntime,
108
+ ): WhatsAppMultiAccountConfig;
109
+ /**
110
+ * Lists all configured account IDs
111
+ */
112
+ export declare function listWhatsAppAccountIds(
113
+ runtime: IAgentRuntime,
114
+ ): string[];
115
+ /**
116
+ * Resolves the default account ID to use
117
+ */
118
+ export declare function resolveDefaultWhatsAppAccountId(
119
+ runtime: IAgentRuntime,
120
+ ): string;
121
+ /**
122
+ * Resolves the access token for a WhatsApp account
123
+ */
124
+ export declare function resolveWhatsAppToken(
125
+ runtime: IAgentRuntime,
126
+ accountId: string,
127
+ ): WhatsAppTokenResolution;
128
+ /**
129
+ * Resolves a complete WhatsApp account configuration
130
+ */
131
+ export declare function resolveWhatsAppAccount(
132
+ runtime: IAgentRuntime,
133
+ accountId?: string | null,
134
+ ): ResolvedWhatsAppAccount;
135
+ /**
136
+ * Lists all enabled WhatsApp accounts
137
+ */
138
+ export declare function listEnabledWhatsAppAccounts(
139
+ runtime: IAgentRuntime,
140
+ ): ResolvedWhatsAppAccount[];
141
+ /**
142
+ * Checks if multi-account mode is enabled
143
+ */
144
+ export declare function isMultiAccountEnabled(runtime: IAgentRuntime): boolean;
145
+ /**
146
+ * Resolves group configuration for a specific group
147
+ */
148
+ export declare function resolveWhatsAppGroupConfig(
149
+ runtime: IAgentRuntime,
150
+ accountId: string,
151
+ groupId: string,
152
+ ): WhatsAppGroupRuntimeConfig | undefined;
153
+ /**
154
+ * Checks if a user is allowed based on policy and allowlist
155
+ */
156
+ export declare function isWhatsAppUserAllowed(params: {
157
+ identifier: string;
158
+ accountConfig: WhatsAppAccountRuntimeConfig;
159
+ isGroup: boolean;
160
+ groupId?: string;
161
+ groupConfig?: WhatsAppGroupRuntimeConfig;
162
+ }): boolean;
163
+ /**
164
+ * Checks if mention is required in a group
165
+ */
166
+ export declare function isWhatsAppMentionRequired(params: {
167
+ accountConfig: WhatsAppAccountRuntimeConfig;
168
+ groupConfig?: WhatsAppGroupRuntimeConfig;
169
+ }): boolean;
170
+ /**
171
+ * Result of an async WhatsApp access check
172
+ */
173
+ export interface WhatsAppAccessCheckResult {
174
+ /** Whether the sender is allowed to proceed */
175
+ allowed: boolean;
176
+ /** If not allowed (pairing policy), the pairing code */
177
+ pairingCode?: string;
178
+ /** Whether a new pairing request was created */
179
+ newPairingRequest?: boolean;
180
+ /** Human-readable message to send to the user when blocked */
181
+ replyMessage?: string;
182
+ }
183
+ /**
184
+ * Checks if a user is allowed based on policy and allowlist, with async pairing support.
185
+ *
186
+ * For non-pairing policies, this behaves identically to `isWhatsAppUserAllowed`.
187
+ * For the "pairing" policy, this actually checks the PairingService allowlist
188
+ * and creates pairing requests when needed.
189
+ *
190
+ * @example
191
+ * ```typescript
192
+ * const result = await checkWhatsAppUserAccess({
193
+ * runtime,
194
+ * identifier: message.from,
195
+ * accountConfig,
196
+ * isGroup: false,
197
+ * metadata: { name: contact.name },
198
+ * });
199
+ *
200
+ * if (!result.allowed) {
201
+ * if (result.replyMessage) {
202
+ * await sendMessage(result.replyMessage);
203
+ * }
204
+ * return; // Block message processing
205
+ * }
206
+ * ```
207
+ */
208
+ export declare function checkWhatsAppUserAccess(params: {
209
+ runtime: IAgentRuntime;
210
+ identifier: string;
211
+ accountConfig: WhatsAppAccountRuntimeConfig;
212
+ isGroup: boolean;
213
+ groupId?: string;
214
+ groupConfig?: WhatsAppGroupRuntimeConfig;
215
+ metadata?: Record<string, string>;
216
+ }): Promise<WhatsAppAccessCheckResult>;
217
+ //# sourceMappingURL=accounts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../src/accounts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAGnD;;GAEG;AACH,eAAO,MAAM,kBAAkB,YAAY,CAAC;AAE5C;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,KAAK,GAAG,WAAW,GAAG,MAAM,CAAC;AAE1E;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,gDAAgD;IAChD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,wCAAwC;IACxC,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IACnC,qCAAqC;IACrC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,0CAA0C;IAC1C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oCAAoC;IACpC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C,6CAA6C;IAC7C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mDAAmD;IACnD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,sCAAsC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6CAA6C;IAC7C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,0BAA0B;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iCAAiC;IACjC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,yBAAyB;IACzB,UAAU,CAAC,EAAE,MAAM,CA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,GAAG,SAAS,CAYxC;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE;IAC5C,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,4BAA4B,CAAC;IAC5C,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,0BAA0B,CAAC;CAC1C,GAAG,OAAO,CA8CV;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE;IAChD,aAAa,EAAE,4BAA4B,CAAC;IAC5C,WAAW,CAAC,EAAE,0BAA0B,CAAC;CAC1C,GAAG,OAAO,CAGV;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,+CAA+C;IAC/C,OAAO,EAAE,OAAO,CAAC;IACjB,wDAAwD;IACxD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gDAAgD;IAChD,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,8DAA8D;IAC9D,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,uBAAuB,CAAC,MAAM,EAAE;IACpD,OAAO,EAAE,aAAa,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,4BAA4B,CAAC;IAC5C,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,0BAA0B,CAAC;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAkErC"}
@@ -0,0 +1,6 @@
1
+ export { sendMessageAction, WHATSAPP_SEND_MESSAGE_ACTION } from "./sendMessage";
2
+ export {
3
+ sendReactionAction,
4
+ WHATSAPP_SEND_REACTION_ACTION,
5
+ } from "./sendReaction";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,4BAA4B,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EACL,kBAAkB,EAClB,6BAA6B,GAC9B,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { Action } from "@elizaos/core";
2
+ export declare const WHATSAPP_SEND_MESSAGE_ACTION = "WHATSAPP_SEND_MESSAGE";
3
+ export declare const sendMessageAction: Action;
4
+ //# sourceMappingURL=sendMessage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sendMessage.d.ts","sourceRoot":"","sources":["../../../src/actions/sendMessage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EAQP,MAAM,eAAe,CAAC;AAGvB,eAAO,MAAM,4BAA4B,0BAA0B,CAAC;AAyBpE,eAAO,MAAM,iBAAiB,EAAE,MA4K/B,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { Action } from "@elizaos/core";
2
+ export declare const WHATSAPP_SEND_REACTION_ACTION = "WHATSAPP_SEND_REACTION";
3
+ export declare const sendReactionAction: Action;
4
+ //# sourceMappingURL=sendReaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sendReaction.d.ts","sourceRoot":"","sources":["../../../src/actions/sendReaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EAQP,MAAM,eAAe,CAAC;AAGvB,eAAO,MAAM,6BAA6B,2BAA2B,CAAC;AAyBtE,eAAO,MAAM,kBAAkB,EAAE,MA4JhC,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { AuthenticationState } from "@whiskeysockets/baileys";
2
+ export declare class BaileysAuthManager {
3
+ private readonly authDir;
4
+ private state?;
5
+ private saveCreds?;
6
+ constructor(authDir: string);
7
+ initialize(): Promise<AuthenticationState>;
8
+ save(): Promise<void>;
9
+ }
10
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/baileys/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAGnE,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,KAAK,CAAC,CAAsB;IACpC,OAAO,CAAC,SAAS,CAAC,CAAsB;gBAE5B,OAAO,EAAE,MAAM;IAIrB,UAAU,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAO1C,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAK5B"}
@@ -0,0 +1,19 @@
1
+ import { EventEmitter } from "node:events";
2
+ import { type WASocket } from "@whiskeysockets/baileys";
3
+ import type { ConnectionStatus } from "../types";
4
+ import type { BaileysAuthManager } from "./auth";
5
+ export declare class BaileysConnection extends EventEmitter {
6
+ private socket?;
7
+ private readonly authManager;
8
+ private connectionStatus;
9
+ private reconnecting;
10
+ private reconnectAttempts;
11
+ private readonly maxReconnectAttempts;
12
+ constructor(authManager: BaileysAuthManager);
13
+ connect(): Promise<WASocket>;
14
+ private setupEventHandlers;
15
+ getSocket(): WASocket | undefined;
16
+ getStatus(): ConnectionStatus;
17
+ disconnect(): Promise<void>;
18
+ }
19
+ //# sourceMappingURL=connection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../../src/baileys/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAqB,EAAoB,KAAK,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAEjD,qBAAa,iBAAkB,SAAQ,YAAY;IACjD,OAAO,CAAC,MAAM,CAAC,CAAW;IAC1B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAqB;IACjD,OAAO,CAAC,gBAAgB,CAA6B;IACrD,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,iBAAiB,CAAK;IAC9B,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAM;gBAE/B,WAAW,EAAE,kBAAkB;IAKrC,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC;IAgBlC,OAAO,CAAC,kBAAkB;IAsE1B,SAAS,IAAI,QAAQ,GAAG,SAAS;IAIjC,SAAS,IAAI,gBAAgB;IAIvB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CAelC"}
@@ -0,0 +1,5 @@
1
+ export * from "./auth";
2
+ export * from "./connection";
3
+ export * from "./message-adapter";
4
+ export * from "./qr-code";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/baileys/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { proto } from "@whiskeysockets/baileys";
2
+ import type { NormalizedMessage, WhatsAppMessage } from "../types";
3
+ export declare class MessageAdapter {
4
+ toNormalized(msg: proto.IWebMessageInfo): NormalizedMessage;
5
+ toBaileys(msg: WhatsAppMessage): Record<string, unknown>;
6
+ private mediaWithCaption;
7
+ private mediaNoCaption;
8
+ private mediaWithFilename;
9
+ private detectType;
10
+ private extractContent;
11
+ private extractReplyToId;
12
+ private renderTemplate;
13
+ }
14
+ //# sourceMappingURL=message-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message-adapter.d.ts","sourceRoot":"","sources":["../../../src/baileys/message-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,EACV,iBAAiB,EAEjB,eAAe,EAEhB,MAAM,UAAU,CAAC;AAElB,qBAAa,cAAc;IACzB,YAAY,CAAC,GAAG,EAAE,KAAK,CAAC,eAAe,GAAG,iBAAiB;IAgB3D,SAAS,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAmBxD,OAAO,CAAC,gBAAgB;IAaxB,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,iBAAiB;IAWzB,OAAO,CAAC,UAAU;IAqBlB,OAAO,CAAC,cAAc;IAWtB,OAAO,CAAC,gBAAgB;IAUxB,OAAO,CAAC,cAAc;CAMvB"}
@@ -0,0 +1,6 @@
1
+ import type { QRCodeData } from "../types";
2
+ export declare class QRCodeGenerator {
3
+ generate(qrString: string): Promise<QRCodeData>;
4
+ private generateTerminal;
5
+ }
6
+ //# sourceMappingURL=qr-code.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"qr-code.d.ts","sourceRoot":"","sources":["../../../src/baileys/qr-code.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,qBAAa,eAAe;IACpB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;YAQvC,gBAAgB;CAO/B"}
@@ -0,0 +1,139 @@
1
+ import { EventEmitter } from "node:events";
2
+ import { type AxiosResponse } from "axios";
3
+ import type { IWhatsAppClient } from "./clients/interface";
4
+ import type {
5
+ CloudAPIConfig,
6
+ ConnectionStatus,
7
+ SendReactionParams,
8
+ SendReactionResult,
9
+ WhatsAppMessage,
10
+ WhatsAppMessageResponse,
11
+ } from "./types";
12
+ export declare class WhatsAppClient
13
+ extends EventEmitter
14
+ implements IWhatsAppClient
15
+ {
16
+ private client;
17
+ private config;
18
+ private connectionStatus;
19
+ constructor(config: CloudAPIConfig);
20
+ start(): Promise<void>;
21
+ stop(): Promise<void>;
22
+ getConnectionStatus(): ConnectionStatus;
23
+ /**
24
+ * Get the configured phone number ID.
25
+ */
26
+ getPhoneNumberId(): string;
27
+ /**
28
+ * Send a message of any supported type.
29
+ */
30
+ sendMessage(
31
+ message: WhatsAppMessage,
32
+ ): Promise<AxiosResponse<WhatsAppMessageResponse>>;
33
+ /**
34
+ * Send a text message.
35
+ */
36
+ sendTextMessage(
37
+ to: string,
38
+ text: string,
39
+ _previewUrl?: boolean,
40
+ ): Promise<AxiosResponse<WhatsAppMessageResponse>>;
41
+ /**
42
+ * Send a reaction to a message.
43
+ */
44
+ sendReaction(params: SendReactionParams): Promise<SendReactionResult>;
45
+ /**
46
+ * Remove a reaction from a message (send empty emoji).
47
+ */
48
+ removeReaction(to: string, messageId: string): Promise<SendReactionResult>;
49
+ /**
50
+ * Send an image message.
51
+ */
52
+ sendImage(
53
+ to: string,
54
+ imageUrl: string,
55
+ caption?: string,
56
+ ): Promise<AxiosResponse<WhatsAppMessageResponse>>;
57
+ /**
58
+ * Send a video message.
59
+ */
60
+ sendVideo(
61
+ to: string,
62
+ videoUrl: string,
63
+ caption?: string,
64
+ ): Promise<AxiosResponse<WhatsAppMessageResponse>>;
65
+ /**
66
+ * Send an audio message.
67
+ */
68
+ sendAudio(
69
+ to: string,
70
+ audioUrl: string,
71
+ ): Promise<AxiosResponse<WhatsAppMessageResponse>>;
72
+ /**
73
+ * Send a document message.
74
+ */
75
+ sendDocument(
76
+ to: string,
77
+ documentUrl: string,
78
+ filename?: string,
79
+ caption?: string,
80
+ ): Promise<AxiosResponse<WhatsAppMessageResponse>>;
81
+ /**
82
+ * Send a location message.
83
+ */
84
+ sendLocation(
85
+ to: string,
86
+ latitude: number,
87
+ longitude: number,
88
+ name?: string,
89
+ address?: string,
90
+ ): Promise<AxiosResponse<WhatsAppMessageResponse>>;
91
+ /**
92
+ * Send an interactive button message.
93
+ */
94
+ sendButtonMessage(
95
+ to: string,
96
+ bodyText: string,
97
+ buttons: Array<{
98
+ id: string;
99
+ title: string;
100
+ }>,
101
+ headerText?: string,
102
+ footerText?: string,
103
+ ): Promise<AxiosResponse<WhatsAppMessageResponse>>;
104
+ /**
105
+ * Send an interactive list message.
106
+ */
107
+ sendListMessage(
108
+ to: string,
109
+ bodyText: string,
110
+ buttonText: string,
111
+ sections: Array<{
112
+ title?: string;
113
+ rows: Array<{
114
+ id: string;
115
+ title: string;
116
+ description?: string;
117
+ }>;
118
+ }>,
119
+ headerText?: string,
120
+ footerText?: string,
121
+ ): Promise<AxiosResponse<WhatsAppMessageResponse>>;
122
+ /**
123
+ * Mark a message as read.
124
+ */
125
+ markMessageAsRead(messageId: string): Promise<boolean>;
126
+ /**
127
+ * Download media by ID.
128
+ */
129
+ getMediaUrl(mediaId: string): Promise<string | null>;
130
+ /**
131
+ * Verify webhook token.
132
+ */
133
+ verifyWebhook(token: string): Promise<boolean>;
134
+ /**
135
+ * Build the message payload based on message type.
136
+ */
137
+ private buildMessagePayload;
138
+ }
139
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAc,EAAsB,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAIlB,eAAe,EACf,uBAAuB,EAExB,MAAM,SAAS,CAAC;AAIjB,qBAAa,cAAe,SAAQ,YAAa,YAAW,eAAe;IACzE,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,gBAAgB,CAA6B;gBAEzC,MAAM,EAAE,cAAc;IAc5B,KAAK,IAAI,OAAO,CAA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Config,
4
+ ConnectionStatus,
5
+ WhatsAppMessage,
6
+ WhatsAppMessageResponse,
7
+ } from "../types";
8
+ import type { IWhatsAppClient } from "./interface";
9
+ export declare class BaileysClient
10
+ extends EventEmitter
11
+ implements IWhatsAppClient
12
+ {
13
+ private readonly config;
14
+ private readonly authManager;
15
+ private readonly connection;
16
+ private readonly qrGenerator;
17
+ private readonly adapter;
18
+ constructor(config: BaileysConfig);
19
+ private setupEventForwarding;
20
+ start(): Promise<void>;
21
+ stop(): Promise<void>;
22
+ sendMessage(message: WhatsAppMessage): Promise<WhatsAppMessageResponse>;
23
+ getConnectionStatus(): ConnectionStatus;
24
+ getPhoneNumber(): string | null;
25
+ }
26
+ //# sourceMappingURL=baileys-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"baileys-client.d.ts","sourceRoot":"","sources":["../../../src/clients/baileys-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAK3C,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,uBAAuB,EACxB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,qBAAa,aAAc,SAAQ,YAAa,YAAW,eAAe;IACxE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;IACvC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAqB;IACjD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAoB;IAC/C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAkB;IAC9C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiB;gBAE7B,MAAM,EAAE,aAAa;IAUjC,OAAO,CAAC,oBAAoB;IAyCtB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAItB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAIrB,WAAW,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAoB7E,mBAAmB,IAAI,gBAAgB;IAIvC,cAAc,IAAI,MAAM,GAAG,IAAI;CAGhC"}
@@ -0,0 +1,6 @@
1
+ import type { WhatsAppConfig } from "../types";
2
+ import type { IWhatsAppClient } from "./interface";
3
+ export declare const ClientFactory: {
4
+ create(config: WhatsAppConfig): IWhatsAppClient;
5
+ };
6
+ //# sourceMappingURL=factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/clients/factory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAiC,cAAc,EAAE,MAAM,UAAU,CAAC;AAG9E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,eAAO,MAAM,aAAa;mBACT,cAAc,GAAG,eAAe;CAOhD,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from "./baileys-client";
2
+ export * from "./factory";
3
+ export * from "./interface";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/clients/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { EventEmitter } from "node:events";
2
+ import type { ConnectionStatus, WhatsAppMessage } from "../types";
3
+ export interface IWhatsAppClient extends EventEmitter {
4
+ start(): Promise<void>;
5
+ stop(): Promise<void>;
6
+ sendMessage(message: WhatsAppMessage): Promise<unknown>;
7
+ verifyWebhook?(token: string): Promise<boolean>;
8
+ getConnectionStatus(): ConnectionStatus;
9
+ }
10
+ //# sourceMappingURL=interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../src/clients/interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAElE,MAAM,WAAW,eAAgB,SAAQ,YAAY;IACnD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,WAAW,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACxD,aAAa,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAChD,mBAAmB,IAAI,gBAAgB,CAAC;CACzC"}