@elizaos/plugin-whatsapp 2.0.0-alpha.1 → 2.0.0-alpha.10

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 (56) hide show
  1. package/dist/index.js +1510 -27
  2. package/dist/index.js.map +25 -1
  3. package/dist/src/accounts.d.ts +199 -0
  4. package/dist/src/accounts.d.ts.map +1 -0
  5. package/dist/src/actions/index.d.ts +3 -0
  6. package/dist/src/actions/index.d.ts.map +1 -0
  7. package/dist/src/actions/sendMessage.d.ts +4 -0
  8. package/dist/src/actions/sendMessage.d.ts.map +1 -0
  9. package/dist/src/actions/sendReaction.d.ts +4 -0
  10. package/dist/src/actions/sendReaction.d.ts.map +1 -0
  11. package/dist/src/baileys/auth.d.ts +10 -0
  12. package/dist/src/baileys/auth.d.ts.map +1 -0
  13. package/dist/src/baileys/connection.d.ts +19 -0
  14. package/dist/src/baileys/connection.d.ts.map +1 -0
  15. package/dist/src/baileys/index.d.ts +5 -0
  16. package/dist/src/baileys/index.d.ts.map +1 -0
  17. package/dist/src/baileys/message-adapter.d.ts +13 -0
  18. package/dist/src/baileys/message-adapter.d.ts.map +1 -0
  19. package/dist/src/baileys/qr-code.d.ts +6 -0
  20. package/dist/src/baileys/qr-code.d.ts.map +1 -0
  21. package/dist/src/client.d.ts +88 -0
  22. package/dist/src/client.d.ts.map +1 -0
  23. package/dist/src/clients/baileys-client.d.ts +17 -0
  24. package/dist/src/clients/baileys-client.d.ts.map +1 -0
  25. package/dist/src/clients/factory.d.ts +6 -0
  26. package/dist/src/clients/factory.d.ts.map +1 -0
  27. package/dist/src/clients/index.d.ts +4 -0
  28. package/dist/src/clients/index.d.ts.map +1 -0
  29. package/dist/src/clients/interface.d.ts +10 -0
  30. package/dist/src/clients/interface.d.ts.map +1 -0
  31. package/dist/src/config.d.ts +135 -0
  32. package/dist/src/config.d.ts.map +1 -0
  33. package/dist/src/handlers/index.d.ts +3 -0
  34. package/dist/src/handlers/index.d.ts.map +1 -0
  35. package/dist/src/handlers/message.handler.d.ts +8 -0
  36. package/dist/src/handlers/message.handler.d.ts.map +1 -0
  37. package/dist/src/handlers/webhook.handler.d.ts +7 -0
  38. package/dist/src/handlers/webhook.handler.d.ts.map +1 -0
  39. package/dist/src/index.d.ts +27 -0
  40. package/dist/src/index.d.ts.map +1 -0
  41. package/dist/src/normalize.d.ts +69 -0
  42. package/dist/src/normalize.d.ts.map +1 -0
  43. package/dist/src/service.d.ts +117 -0
  44. package/dist/src/service.d.ts.map +1 -0
  45. package/dist/src/types.d.ts +367 -0
  46. package/dist/src/types.d.ts.map +1 -0
  47. package/dist/src/utils/config-detector.d.ts +3 -0
  48. package/dist/src/utils/config-detector.d.ts.map +1 -0
  49. package/dist/src/utils/index.d.ts +3 -0
  50. package/dist/src/utils/index.d.ts.map +1 -0
  51. package/dist/src/utils/validators.d.ts +10 -0
  52. package/dist/src/utils/validators.d.ts.map +1 -0
  53. package/package.json +129 -74
  54. package/LICENSE +0 -21
  55. package/README.md +0 -226
  56. package/dist/index.d.ts +0 -83
@@ -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,88 @@
1
+ import { type AxiosResponse } from "axios";
2
+ import { EventEmitter } from "node:events";
3
+ import type { IWhatsAppClient } from "./clients/interface";
4
+ import type { CloudAPIConfig, ConnectionStatus, SendReactionParams, SendReactionResult, WhatsAppMessage, WhatsAppMessageResponse } from "./types";
5
+ export declare class WhatsAppClient extends EventEmitter implements IWhatsAppClient {
6
+ private client;
7
+ private config;
8
+ private connectionStatus;
9
+ constructor(config: CloudAPIConfig);
10
+ start(): Promise<void>;
11
+ stop(): Promise<void>;
12
+ getConnectionStatus(): ConnectionStatus;
13
+ /**
14
+ * Get the configured phone number ID.
15
+ */
16
+ getPhoneNumberId(): string;
17
+ /**
18
+ * Send a message of any supported type.
19
+ */
20
+ sendMessage(message: WhatsAppMessage): Promise<AxiosResponse<WhatsAppMessageResponse>>;
21
+ /**
22
+ * Send a text message.
23
+ */
24
+ sendTextMessage(to: string, text: string, _previewUrl?: boolean): Promise<AxiosResponse<WhatsAppMessageResponse>>;
25
+ /**
26
+ * Send a reaction to a message.
27
+ */
28
+ sendReaction(params: SendReactionParams): Promise<SendReactionResult>;
29
+ /**
30
+ * Remove a reaction from a message (send empty emoji).
31
+ */
32
+ removeReaction(to: string, messageId: string): Promise<SendReactionResult>;
33
+ /**
34
+ * Send an image message.
35
+ */
36
+ sendImage(to: string, imageUrl: string, caption?: string): Promise<AxiosResponse<WhatsAppMessageResponse>>;
37
+ /**
38
+ * Send a video message.
39
+ */
40
+ sendVideo(to: string, videoUrl: string, caption?: string): Promise<AxiosResponse<WhatsAppMessageResponse>>;
41
+ /**
42
+ * Send an audio message.
43
+ */
44
+ sendAudio(to: string, audioUrl: string): Promise<AxiosResponse<WhatsAppMessageResponse>>;
45
+ /**
46
+ * Send a document message.
47
+ */
48
+ sendDocument(to: string, documentUrl: string, filename?: string, caption?: string): Promise<AxiosResponse<WhatsAppMessageResponse>>;
49
+ /**
50
+ * Send a location message.
51
+ */
52
+ sendLocation(to: string, latitude: number, longitude: number, name?: string, address?: string): Promise<AxiosResponse<WhatsAppMessageResponse>>;
53
+ /**
54
+ * Send an interactive button message.
55
+ */
56
+ sendButtonMessage(to: string, bodyText: string, buttons: Array<{
57
+ id: string;
58
+ title: string;
59
+ }>, headerText?: string, footerText?: string): Promise<AxiosResponse<WhatsAppMessageResponse>>;
60
+ /**
61
+ * Send an interactive list message.
62
+ */
63
+ sendListMessage(to: string, bodyText: string, buttonText: string, sections: Array<{
64
+ title?: string;
65
+ rows: Array<{
66
+ id: string;
67
+ title: string;
68
+ description?: string;
69
+ }>;
70
+ }>, headerText?: string, footerText?: string): Promise<AxiosResponse<WhatsAppMessageResponse>>;
71
+ /**
72
+ * Mark a message as read.
73
+ */
74
+ markMessageAsRead(messageId: string): Promise<boolean>;
75
+ /**
76
+ * Download media by ID.
77
+ */
78
+ getMediaUrl(mediaId: string): Promise<string | null>;
79
+ /**
80
+ * Verify webhook token.
81
+ */
82
+ verifyWebhook(token: string): Promise<boolean>;
83
+ /**
84
+ * Build the message payload based on message type.
85
+ */
86
+ private buildMessagePayload;
87
+ }
88
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAc,EAAsB,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,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,CAAC,IAAI,CAAC;IAMtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAK3B,mBAAmB,IAAI,gBAAgB;IAIvC;;OAEG;IACH,gBAAgB,IAAI,MAAM;IA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uB,CAAC,CAAC;IAalD;;OAEG;IACG,iBAAiB,CACrB,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,EAC7C,UAAU,CAAC,EAAE,MAAM,EACnB,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,aAAa,CAAC,uBAAuB,CAAC,CAAC;IA0BlD;;OAEG;IACG,eAAe,CACnB,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,KAAK,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,KAAK,CAAC;YAAE,EAAE,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAC;YAAC,WAAW,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KAClE,CAAC,EACF,UAAU,CAAC,EAAE,MAAM,EACnB,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,aAAa,CAAC,uBAAuB,CAAC,CAAC;IAwBlD;;OAEG;IACG,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAiB5D;;OAEG;IACG,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAS1D;;OAEG;IACG,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIpD;;OAEG;IACH,OAAO,CAAC,mBAAmB;CAoH5B"}
@@ -0,0 +1,17 @@
1
+ import { EventEmitter } from "node:events";
2
+ import type { IWhatsAppClient } from "./interface";
3
+ import type { BaileysConfig, ConnectionStatus, WhatsAppMessage, WhatsAppMessageResponse } from "../types";
4
+ export declare class BaileysClient extends EventEmitter implements IWhatsAppClient {
5
+ private readonly config;
6
+ private readonly authManager;
7
+ private readonly connection;
8
+ private readonly qrGenerator;
9
+ private readonly adapter;
10
+ constructor(config: BaileysConfig);
11
+ private setupEventForwarding;
12
+ start(): Promise<void>;
13
+ stop(): Promise<void>;
14
+ sendMessage(message: WhatsAppMessage): Promise<WhatsAppMessageResponse>;
15
+ getConnectionStatus(): ConnectionStatus;
16
+ }
17
+ //# 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,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAE1G,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;IAmCtB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAItB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAIrB,WAAW,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAiB7E,mBAAmB,IAAI,gBAAgB;CAGxC"}
@@ -0,0 +1,6 @@
1
+ import type { WhatsAppConfig } from "../types";
2
+ import type { IWhatsAppClient } from "./interface";
3
+ export declare class ClientFactory {
4
+ static 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,qBAAa,aAAa;IACxB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,GAAG,eAAe;CAOvD"}
@@ -0,0 +1,4 @@
1
+ export * from "./interface";
2
+ export * from "./factory";
3
+ export * from "./baileys-client";
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,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { 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,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,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"}
@@ -0,0 +1,135 @@
1
+ /**
2
+ * WhatsApp plugin configuration types.
3
+ *
4
+ * These types define the configuration schema for the WhatsApp plugin.
5
+ * Shared base types are imported from @elizaos/core.
6
+ */
7
+ import type { BlockStreamingCoalesceConfig, ChannelHeartbeatVisibilityConfig, DmConfig, DmPolicy, GroupPolicy, GroupToolPolicyBySenderConfig, GroupToolPolicyConfig, MarkdownConfig } from "@elizaos/core";
8
+ export type WhatsAppActionConfig = {
9
+ reactions?: boolean;
10
+ sendMessage?: boolean;
11
+ polls?: boolean;
12
+ };
13
+ export type WhatsAppAckReactionConfig = {
14
+ /** Emoji to use for acknowledgment (e.g., "👀"). Empty = disabled. */
15
+ emoji?: string;
16
+ /** Send reactions in direct chats. Default: true. */
17
+ direct?: boolean;
18
+ /**
19
+ * Send reactions in group chats:
20
+ * - "always": react to all group messages
21
+ * - "mentions": react only when bot is mentioned
22
+ * - "never": never react in groups
23
+ * Default: "mentions"
24
+ */
25
+ group?: "always" | "mentions" | "never";
26
+ };
27
+ export type WhatsAppGroupConfig = {
28
+ requireMention?: boolean;
29
+ tools?: GroupToolPolicyConfig;
30
+ toolsBySender?: GroupToolPolicyBySenderConfig;
31
+ };
32
+ export type WhatsAppAccountConfig = {
33
+ /** Optional display name for this account (used in CLI/UI lists). */
34
+ name?: string;
35
+ /** Optional provider capability tags used for agent/runtime guidance. */
36
+ capabilities?: string[];
37
+ /** Markdown formatting overrides (tables). */
38
+ markdown?: MarkdownConfig;
39
+ /** Allow channel-initiated config writes (default: true). */
40
+ configWrites?: boolean;
41
+ /** If false, do not start this WhatsApp account provider. Default: true. */
42
+ enabled?: boolean;
43
+ /** Send read receipts for incoming messages (default true). */
44
+ sendReadReceipts?: boolean;
45
+ /** Inbound message prefix override for this account (WhatsApp only). */
46
+ messagePrefix?: string;
47
+ /** Override auth directory (Baileys multi-file auth state). */
48
+ authDir?: string;
49
+ /** Direct message access policy (default: pairing). */
50
+ dmPolicy?: DmPolicy;
51
+ /** Same-phone setup for this account (bot uses your personal WhatsApp number). */
52
+ selfChatMode?: boolean;
53
+ allowFrom?: string[];
54
+ groupAllowFrom?: string[];
55
+ groupPolicy?: GroupPolicy;
56
+ /** Max group messages to keep as history context (0 disables). */
57
+ historyLimit?: number;
58
+ /** Max DM turns to keep as history context. */
59
+ dmHistoryLimit?: number;
60
+ /** Per-DM config overrides keyed by user ID. */
61
+ dms?: Record<string, DmConfig>;
62
+ textChunkLimit?: number;
63
+ /** Chunking mode: "length" (default) splits by size; "newline" splits on every newline. */
64
+ chunkMode?: "length" | "newline";
65
+ mediaMaxMb?: number;
66
+ blockStreaming?: boolean;
67
+ /** Merge streamed block replies before sending. */
68
+ blockStreamingCoalesce?: BlockStreamingCoalesceConfig;
69
+ groups?: Record<string, WhatsAppGroupConfig>;
70
+ /** Acknowledgment reaction sent immediately upon message receipt. */
71
+ ackReaction?: WhatsAppAckReactionConfig;
72
+ /** Debounce window (ms) for batching rapid consecutive messages from the same sender (0 to disable). */
73
+ debounceMs?: number;
74
+ /** Heartbeat visibility settings for this account. */
75
+ heartbeat?: ChannelHeartbeatVisibilityConfig;
76
+ };
77
+ export type WhatsAppChannelConfig = {
78
+ /** Optional per-account WhatsApp configuration (multi-account). */
79
+ accounts?: Record<string, WhatsAppAccountConfig>;
80
+ /** Optional provider capability tags used for agent/runtime guidance. */
81
+ capabilities?: string[];
82
+ /** Markdown formatting overrides (tables). */
83
+ markdown?: MarkdownConfig;
84
+ /** Allow channel-initiated config writes (default: true). */
85
+ configWrites?: boolean;
86
+ /** Send read receipts for incoming messages (default true). */
87
+ sendReadReceipts?: boolean;
88
+ /**
89
+ * Inbound message prefix (WhatsApp only).
90
+ * Default: `[{agents.list[].identity.name}]` (or `[otto]`) when allowFrom is empty, else `""`.
91
+ */
92
+ messagePrefix?: string;
93
+ /** Direct message access policy (default: pairing). */
94
+ dmPolicy?: DmPolicy;
95
+ /** Same-phone setup (bot uses your personal WhatsApp number). */
96
+ selfChatMode?: boolean;
97
+ /** Optional allowlist for WhatsApp direct chats (E.164). */
98
+ allowFrom?: string[];
99
+ /** Optional allowlist for WhatsApp group senders (E.164). */
100
+ groupAllowFrom?: string[];
101
+ /**
102
+ * Controls how group messages are handled:
103
+ * - "open": groups bypass allowFrom, only mention-gating applies
104
+ * - "disabled": block all group messages entirely
105
+ * - "allowlist": only allow group messages from senders in groupAllowFrom/allowFrom
106
+ */
107
+ groupPolicy?: GroupPolicy;
108
+ /** Max group messages to keep as history context (0 disables). */
109
+ historyLimit?: number;
110
+ /** Max DM turns to keep as history context. */
111
+ dmHistoryLimit?: number;
112
+ /** Per-DM config overrides keyed by user ID. */
113
+ dms?: Record<string, DmConfig>;
114
+ /** Outbound text chunk size (chars). Default: 4000. */
115
+ textChunkLimit?: number;
116
+ /** Chunking mode: "length" (default) splits by size; "newline" splits on every newline. */
117
+ chunkMode?: "length" | "newline";
118
+ /** Maximum media file size in MB. Default: 50. */
119
+ mediaMaxMb?: number;
120
+ /** Disable block streaming for this account. */
121
+ blockStreaming?: boolean;
122
+ /** Merge streamed block replies before sending. */
123
+ blockStreamingCoalesce?: BlockStreamingCoalesceConfig;
124
+ /** Per-action tool gating (default: true for all). */
125
+ actions?: WhatsAppActionConfig;
126
+ groups?: Record<string, WhatsAppGroupConfig>;
127
+ /** Acknowledgment reaction sent immediately upon message receipt. */
128
+ ackReaction?: WhatsAppAckReactionConfig;
129
+ /** Debounce window (ms) for batching rapid consecutive messages from the same sender (0 to disable). */
130
+ debounceMs?: number;
131
+ /** Heartbeat visibility settings for this channel. */
132
+ heartbeat?: ChannelHeartbeatVisibilityConfig;
133
+ };
134
+ export type { WhatsAppChannelConfig as WhatsAppConfig };
135
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1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CAAC,EAAE,MAAM,CAAC;IACvB,uDAAuD;IACvD,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,iEAAiE;IACjE,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,6DAA6D;IAC7D,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B;;;;;OAKG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,kEAAkE;IAClE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,+CAA+C;IAC/C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gDAAgD;IAChD,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC/B,uDAAuD;IACvD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,2FAA2F;IAC3F,SAAS,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IACjC,kDAAkD;IAClD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gDAAgD;IAChD,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,mDAAmD;IACnD,sBAAsB,CAAC,EAAE,4BAA4B,CAAC;IACtD,sDAAsD;IACtD,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IAC7C,qEAAqE;IACrE,WAAW,CAAC,EAAE,yBAAyB,CAAC;IACxC,wGAAwG;IACxG,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sDAAsD;IACtD,SAAS,CAAC,EAAE,gCAAgC,CAAC;CAC9C,CAAC;AAGF,YAAY,EAAE,qBAAqB,IAAI,cAAc,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./message.handler";
2
+ export * from "./webhook.handler";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/handlers/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { IWhatsAppClient } from "../clients/interface";
2
+ import type { WhatsAppMessage, WhatsAppMessageResponse } from "../types";
3
+ export declare class MessageHandler {
4
+ private client;
5
+ constructor(client: IWhatsAppClient);
6
+ send(message: WhatsAppMessage): Promise<WhatsAppMessageResponse>;
7
+ }
8
+ //# sourceMappingURL=message.handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message.handler.d.ts","sourceRoot":"","sources":["../../../src/handlers/message.handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAEzE,qBAAa,cAAc;IACb,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,eAAe;IAErC,IAAI,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,uBAAuB,CAAC;CAcvE"}
@@ -0,0 +1,7 @@
1
+ import type { WhatsAppWebhookEvent } from "../types";
2
+ export declare class WebhookHandler {
3
+ handle(event: WhatsAppWebhookEvent): Promise<void>;
4
+ private handleMessage;
5
+ private handleStatus;
6
+ }
7
+ //# sourceMappingURL=webhook.handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhook.handler.d.ts","sourceRoot":"","sources":["../../../src/handlers/webhook.handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiD,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEpG,qBAAa,cAAc;IACnB,MAAM,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;YAyB1C,aAAa;YAMb,YAAY;CAK3B"}
@@ -0,0 +1,27 @@
1
+ import { EventEmitter } from "node:events";
2
+ import type { Plugin } from "@elizaos/core";
3
+ import type { ConnectionStatus, WhatsAppConfig, WhatsAppMessage, WhatsAppMessageResponse, WhatsAppWebhookEvent } from "./types";
4
+ export declare class WhatsAppPlugin extends EventEmitter implements Plugin {
5
+ private readonly client;
6
+ private readonly messageHandler;
7
+ private readonly webhookHandler;
8
+ name: string;
9
+ description: string;
10
+ actions: import("@elizaos/core").Action[];
11
+ constructor(config: WhatsAppConfig);
12
+ private setupEventForwarding;
13
+ start(): Promise<void>;
14
+ stop(): Promise<void>;
15
+ getConnectionStatus(): ConnectionStatus;
16
+ sendMessage(message: WhatsAppMessage): Promise<WhatsAppMessageResponse>;
17
+ handleWebhook(event: WhatsAppWebhookEvent): Promise<void>;
18
+ verifyWebhook(token: string): Promise<boolean>;
19
+ }
20
+ declare const whatsappPlugin: Plugin;
21
+ export default whatsappPlugin;
22
+ export { checkWhatsAppUserAccess, DEFAULT_ACCOUNT_ID, isMultiAccountEnabled, isWhatsAppMentionRequired, isWhatsAppUserAllowed, listEnabledWhatsAppAccounts, listWhatsAppAccountIds, normalizeAccountId, type ResolvedWhatsAppAccount, resolveDefaultWhatsAppAccountId, resolveWhatsAppAccount, resolveWhatsAppGroupConfig, resolveWhatsAppToken, type WhatsAppAccessCheckResult, type WhatsAppAccountRuntimeConfig, type WhatsAppGroupRuntimeConfig, type WhatsAppMultiAccountConfig, type WhatsAppTokenResolution, type WhatsAppTokenSource, } from "./accounts";
23
+ export type { WhatsAppAccountConfig, WhatsAppAckReactionConfig, WhatsAppActionConfig, WhatsAppChannelConfig, WhatsAppGroupConfig, } from "./config";
24
+ export { buildWhatsAppUserJid, type ChunkWhatsAppTextOpts, chunkWhatsAppText, formatWhatsAppId, formatWhatsAppPhoneNumber, getWhatsAppChatType, isValidWhatsAppNumber, isWhatsAppGroup, isWhatsAppGroupJid, isWhatsAppUserTarget, normalizeE164, normalizeWhatsAppTarget, resolveWhatsAppSystemLocation, truncateText, WHATSAPP_TEXT_CHUNK_LIMIT, } from "./normalize";
25
+ export { ClientFactory } from "./clients/factory";
26
+ export * from "./types";
27
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAK5C,OAAO,KAAK,EACV,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,uBAAuB,EACvB,oBAAoB,EACrB,MAAM,SAAS,CAAC;AAEjB,qBAAa,cAAe,SAAQ,YAAa,YAAW,MAAM;IAChE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkB;IACzC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAiB;IAChD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAiB;IAEhD,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,mCAA2C;gBAEtC,MAAM,EAAE,cAAc;IAUlC,OAAO,CAAC,oBAAoB;IAQtB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAItB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,mBAAmB,IAAI,gBAAgB;IAIjC,WAAW,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAIvE,aAAa,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIzD,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAMrD;AAED,QAAA,MAAM,cAAc,EAAE,MAIrB,CAAC;AAEF,eAAe,cAAc,CAAC;AAG9B,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,qBAAqB,EACrB,yBAAyB,EACzB,qBAAqB,EACrB,2BAA2B,EAC3B,sBAAsB,EACtB,kBAAkB,EAClB,KAAK,uBAAuB,EAC5B,+BAA+B,EAC/B,sBAAsB,EACtB,0BAA0B,EAC1B,oBAAoB,EACpB,KAAK,yBAAyB,EAC9B,KAAK,4BAA4B,EACjC,KAAK,0BAA0B,EAC/B,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,GACzB,MAAM,YAAY,CAAC;AAGpB,YAAY,EACV,qBAAqB,EACrB,yBAAyB,EACzB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,UAAU,CAAC;AAGlB,OAAO,EACL,oBAAoB,EACpB,KAAK,qBAAqB,EAC1B,iBAAiB,EACjB,gBAAgB,EAChB,yBAAyB,EACzB,mBAAmB,EACnB,qBAAqB,EACrB,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,aAAa,EACb,uBAAuB,EACvB,6BAA6B,EAC7B,YAAY,EACZ,yBAAyB,GAC1B,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,cAAc,SAAS,CAAC"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * WhatsApp text chunk limit
3
+ */
4
+ export declare const WHATSAPP_TEXT_CHUNK_LIMIT = 4096;
5
+ /**
6
+ * Normalizes a phone number to E.164 format
7
+ */
8
+ export declare function normalizeE164(input: string): string;
9
+ /**
10
+ * Checks if a value is a WhatsApp group JID (e.g., "123456789-987654321@g.us")
11
+ */
12
+ export declare function isWhatsAppGroupJid(value: string): boolean;
13
+ /**
14
+ * Checks if a value looks like a WhatsApp user target
15
+ * (e.g., "41796666864:0@s.whatsapp.net" or "123@lid")
16
+ */
17
+ export declare function isWhatsAppUserTarget(value: string): boolean;
18
+ /**
19
+ * Normalizes a WhatsApp target (phone number, user JID, or group JID)
20
+ * Returns null if the target is invalid
21
+ */
22
+ export declare function normalizeWhatsAppTarget(value: string): string | null;
23
+ /**
24
+ * Formats a WhatsApp ID for display
25
+ */
26
+ export declare function formatWhatsAppId(id: string): string;
27
+ /**
28
+ * Checks if a WhatsApp ID is a group
29
+ */
30
+ export declare function isWhatsAppGroup(id: string): boolean;
31
+ /**
32
+ * Gets the chat type from a WhatsApp ID
33
+ */
34
+ export declare function getWhatsAppChatType(id: string): "group" | "user";
35
+ /**
36
+ * Builds a WhatsApp JID from a phone number
37
+ */
38
+ export declare function buildWhatsAppUserJid(phoneNumber: string): string;
39
+ /**
40
+ * Options for text chunking
41
+ */
42
+ export interface ChunkWhatsAppTextOpts {
43
+ limit?: number;
44
+ }
45
+ /**
46
+ * Chunks text for WhatsApp messages
47
+ */
48
+ export declare function chunkWhatsAppText(text: string, opts?: ChunkWhatsAppTextOpts): string[];
49
+ /**
50
+ * Truncates text to a maximum length with ellipsis
51
+ */
52
+ export declare function truncateText(text: string, maxLength: number): string;
53
+ /**
54
+ * Resolves the system location string for logging
55
+ */
56
+ export declare function resolveWhatsAppSystemLocation(params: {
57
+ chatType: "group" | "user";
58
+ chatId: string;
59
+ chatName?: string;
60
+ }): string;
61
+ /**
62
+ * Validates a WhatsApp phone number
63
+ */
64
+ export declare function isValidWhatsAppNumber(value: string): boolean;
65
+ /**
66
+ * Formats a phone number for WhatsApp display
67
+ */
68
+ export declare function formatWhatsAppPhoneNumber(phoneNumber: string): string;
69
+ //# sourceMappingURL=normalize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/normalize.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,yBAAyB,OAAO,CAAC;AA0B9C;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAyBnD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAWzD;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAG3D;AAmBD;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA+BpE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAMnD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAEnD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,CAEhE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAIhE;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AA2DD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,qBAA0B,GAAG,MAAM,EAAE,CAwB1F;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAQpE;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAAC,MAAM,EAAE;IACpD,QAAQ,EAAE,OAAO,GAAG,MAAM,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,MAAM,CAIT;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAW5D;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAcrE"}
@@ -0,0 +1,117 @@
1
+ import { WhatsAppClient } from "./client";
2
+ import type { CloudAPIConfig, SendReactionParams, SendReactionResult, WhatsAppEventType, WhatsAppMessage, WhatsAppMessageResponse, WhatsAppWebhookEvent } from "./types";
3
+ type EventHandler = (payload: unknown) => void | Promise<void>;
4
+ /**
5
+ * WhatsApp service for ElizaOS.
6
+ * Provides comprehensive WhatsApp Cloud API integration.
7
+ */
8
+ export declare class WhatsAppService {
9
+ static readonly serviceType = "whatsapp";
10
+ private config;
11
+ private client;
12
+ private messageHandler;
13
+ private webhookHandler;
14
+ private running;
15
+ private eventHandlers;
16
+ constructor(config: CloudAPIConfig);
17
+ /**
18
+ * Create service from environment variables.
19
+ */
20
+ static fromEnv(): WhatsAppService;
21
+ /**
22
+ * Get the underlying client.
23
+ */
24
+ getClient(): WhatsAppClient;
25
+ /**
26
+ * Start the WhatsApp service.
27
+ */
28
+ start(): Promise<void>;
29
+ /**
30
+ * Stop the WhatsApp service.
31
+ */
32
+ stop(): Promise<void>;
33
+ /**
34
+ * Check if the service is running.
35
+ */
36
+ isRunning(): boolean;
37
+ /**
38
+ * Register an event handler.
39
+ */
40
+ onEvent(eventType: WhatsAppEventType, handler: EventHandler): void;
41
+ /**
42
+ * Handle a webhook event.
43
+ */
44
+ handleWebhook(event: WhatsAppWebhookEvent): Promise<void>;
45
+ /**
46
+ * Verify a webhook subscription request.
47
+ */
48
+ verifyWebhook(mode: string, token: string, challenge: string): string | null;
49
+ /**
50
+ * Verify webhook payload signature.
51
+ */
52
+ verifyWebhookSignature(payload: Buffer | string, signature: string): boolean;
53
+ /**
54
+ * Send a message of any type.
55
+ */
56
+ sendMessage(message: WhatsAppMessage): Promise<WhatsAppMessageResponse>;
57
+ /**
58
+ * Send a text message.
59
+ */
60
+ sendText(to: string, text: string): Promise<WhatsAppMessageResponse>;
61
+ /**
62
+ * Send a reaction to a message.
63
+ */
64
+ sendReaction(params: SendReactionParams): Promise<SendReactionResult>;
65
+ /**
66
+ * Remove a reaction from a message.
67
+ */
68
+ removeReaction(to: string, messageId: string): Promise<SendReactionResult>;
69
+ /**
70
+ * Send an image message.
71
+ */
72
+ sendImage(to: string, imageUrl: string, caption?: string): Promise<WhatsAppMessageResponse>;
73
+ /**
74
+ * Send a video message.
75
+ */
76
+ sendVideo(to: string, videoUrl: string, caption?: string): Promise<WhatsAppMessageResponse>;
77
+ /**
78
+ * Send an audio message.
79
+ */
80
+ sendAudio(to: string, audioUrl: string): Promise<WhatsAppMessageResponse>;
81
+ /**
82
+ * Send a document message.
83
+ */
84
+ sendDocument(to: string, documentUrl: string, filename?: string, caption?: string): Promise<WhatsAppMessageResponse>;
85
+ /**
86
+ * Send a location message.
87
+ */
88
+ sendLocation(to: string, latitude: number, longitude: number, name?: string, address?: string): Promise<WhatsAppMessageResponse>;
89
+ /**
90
+ * Send an interactive button message.
91
+ */
92
+ sendButtonMessage(to: string, bodyText: string, buttons: Array<{
93
+ id: string;
94
+ title: string;
95
+ }>, headerText?: string, footerText?: string): Promise<WhatsAppMessageResponse>;
96
+ /**
97
+ * Send an interactive list message.
98
+ */
99
+ sendListMessage(to: string, bodyText: string, buttonText: string, sections: Array<{
100
+ title?: string;
101
+ rows: Array<{
102
+ id: string;
103
+ title: string;
104
+ description?: string;
105
+ }>;
106
+ }>, headerText?: string, footerText?: string): Promise<WhatsAppMessageResponse>;
107
+ /**
108
+ * Mark a message as read.
109
+ */
110
+ markAsRead(messageId: string): Promise<boolean>;
111
+ /**
112
+ * Get the download URL for a media file.
113
+ */
114
+ getMediaUrl(mediaId: string): Promise<string | null>;
115
+ }
116
+ export {};
117
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,uBAAuB,EACvB,oBAAoB,EACrB,MAAM,SAAS,CAAC;AAEjB,KAAK,YAAY,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAE/D;;;GAGG;AACH,qBAAa,eAAe;IAC1B,MAAM,CAAC,QAAQ,CAAC,WAAW,cAAc;IAEzC,OAAO,CAAC,MAAM,CAA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