@openclaw/whatsapp 2026.5.2 → 2026.5.3-beta.2
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/dist/access-control-BQ3tCkH8.js +288 -0
- package/dist/account-config-CNQ33oav.js +47 -0
- package/dist/account-ids-DG18xddX.js +5 -0
- package/dist/accounts-BDqgpFEB.js +116 -0
- package/dist/action-runtime-DTGNgG-i.js +74 -0
- package/dist/action-runtime-api.js +2 -0
- package/dist/action-runtime.runtime.js +2 -0
- package/dist/active-listener-N7GFKsuN.js +11 -0
- package/dist/agent-tools-login-DpRxLNRB.js +89 -0
- package/dist/api.js +148 -0
- package/dist/audio-preflight.runtime-Bcdsl_ri.js +7 -0
- package/dist/auth-presence.js +32 -0
- package/dist/auth-store-BjCb50Ry.js +381 -0
- package/dist/channel-DQ-5Xoj9.js +542 -0
- package/dist/channel-config-api.js +2 -0
- package/dist/channel-plugin-api.js +2 -0
- package/dist/channel-react-action-Df20qAy9.js +42 -0
- package/dist/channel.runtime-DKXRnA8x.js +55 -0
- package/dist/channel.setup-DOHR2BGp.js +20 -0
- package/dist/command-policy-O8sRnqUV.js +8 -0
- package/dist/config-schema-Dmo66Ubb.js +27 -0
- package/dist/connection-controller-BiHAsTM8.js +596 -0
- package/dist/connection-controller-registry-D_iIGz5m.js +22 -0
- package/dist/constants-DLGCIbfl.js +4 -0
- package/dist/constants.js +2 -0
- package/dist/contract-api.js +19 -0
- package/dist/creds-files-_2V8jzQa.js +19 -0
- package/dist/directory-config-DVs4ffXu.js +37 -0
- package/dist/directory-contract-api.js +2 -0
- package/dist/doctor-A9tXm9Om.js +48 -0
- package/dist/doctor-contract-api.js +10 -0
- package/dist/group-session-contract-B8QBn0I2.js +15 -0
- package/dist/identity-QHAlV7Fu.js +75 -0
- package/dist/index.js +18 -0
- package/dist/legacy-session-surface-api.js +8 -0
- package/dist/legacy-state-migrations-api.js +2 -0
- package/dist/light-runtime-api.js +5 -0
- package/dist/login-DymdrKca.js +52 -0
- package/dist/login-qr-DIS0Iv-7.js +378 -0
- package/dist/login-qr-api.js +2 -0
- package/dist/login-qr-runtime.js +16 -0
- package/dist/monitor-C4Fhg_lD.js +3349 -0
- package/dist/normalize-CWYiGkXw.js +2 -0
- package/dist/normalize-target-BPVHNsM5.js +74 -0
- package/dist/outbound-adapter-BssVnZdz.js +29 -0
- package/dist/outbound-base-Bq1UYEK5.js +119 -0
- package/dist/outbound-media-contract-CGss_QHy.js +163 -0
- package/dist/outbound-payload-test-api.js +2 -0
- package/dist/quoted-message-TENQzyxV.js +108 -0
- package/dist/reaction-level-CRVEVAfi.js +16 -0
- package/dist/reply-resolver.runtime-BRCgoO4C.js +2 -0
- package/dist/resolve-outbound-target-CN-Wo6IY.js +39 -0
- package/dist/rolldown-runtime-RkAeH_Qm.js +27 -0
- package/dist/runtime-6fZ67abR.js +8 -0
- package/dist/runtime-api.js +15 -0
- package/dist/runtime-group-policy-Gp1lQ0at.js +11 -0
- package/dist/secret-contract-api.js +5 -0
- package/dist/security-contract-DqH8JDX6.js +26 -0
- package/dist/security-contract-api.js +2 -0
- package/dist/send-CIyLFxdZ.js +234 -0
- package/dist/session-contract-B0efQf9P.js +27 -0
- package/dist/session-errors-CSuKZPub.js +63 -0
- package/dist/session.runtime-C1eSE_KK.js +13 -0
- package/dist/setup-core-DZKvpzbH.js +46 -0
- package/dist/setup-entry.js +23 -0
- package/dist/setup-plugin-api.js +2 -0
- package/dist/setup-surface-ieFnIW4g.js +344 -0
- package/dist/shared-D_wzSVar.js +307 -0
- package/dist/state-migrations-DnCdvoYD.js +39 -0
- package/dist/targets.js +2 -0
- package/dist/test-api.js +3 -0
- package/dist/text-runtime-C1zNiZeO.js +116 -0
- package/package.json +14 -6
- package/action-runtime-api.ts +0 -1
- package/action-runtime.runtime.ts +0 -1
- package/api.ts +0 -213
- package/auth-presence.ts +0 -80
- package/channel-config-api.ts +0 -1
- package/channel-plugin-api.ts +0 -3
- package/config-api.ts +0 -4
- package/constants.ts +0 -1
- package/contract-api.ts +0 -29
- package/directory-contract-api.ts +0 -4
- package/doctor-contract-api.ts +0 -8
- package/index.test.ts +0 -13
- package/index.ts +0 -16
- package/legacy-session-surface-api.ts +0 -6
- package/legacy-state-migrations-api.ts +0 -1
- package/light-runtime-api.ts +0 -12
- package/login-qr-api.ts +0 -1
- package/login-qr-runtime.ts +0 -23
- package/outbound-payload-test-api.ts +0 -1
- package/runtime-api.ts +0 -84
- package/secret-contract-api.ts +0 -4
- package/security-contract-api.ts +0 -4
- package/setup-entry.test.ts +0 -21
- package/setup-entry.ts +0 -21
- package/setup-plugin-api.ts +0 -3
- package/src/account-config.ts +0 -77
- package/src/account-ids.ts +0 -13
- package/src/account-types.ts +0 -5
- package/src/accounts.test.ts +0 -182
- package/src/accounts.ts +0 -176
- package/src/accounts.whatsapp-auth.test.ts +0 -59
- package/src/action-runtime-target-auth.ts +0 -27
- package/src/action-runtime.test.ts +0 -330
- package/src/action-runtime.ts +0 -76
- package/src/active-listener.test.ts +0 -65
- package/src/active-listener.ts +0 -17
- package/src/agent-tools-login.test.ts +0 -81
- package/src/agent-tools-login.ts +0 -113
- package/src/approval-auth.test.ts +0 -24
- package/src/approval-auth.ts +0 -27
- package/src/auth-store.runtime.ts +0 -1
- package/src/auth-store.test.ts +0 -311
- package/src/auth-store.ts +0 -502
- package/src/auto-reply/config.runtime.ts +0 -16
- package/src/auto-reply/constants.ts +0 -1
- package/src/auto-reply/deliver-reply.test.ts +0 -843
- package/src/auto-reply/deliver-reply.ts +0 -279
- package/src/auto-reply/loggers.ts +0 -6
- package/src/auto-reply/mentions.ts +0 -131
- package/src/auto-reply/monitor/ack-reaction.test.ts +0 -170
- package/src/auto-reply/monitor/ack-reaction.ts +0 -99
- package/src/auto-reply/monitor/audio-preflight.runtime.ts +0 -9
- package/src/auto-reply/monitor/broadcast.ts +0 -153
- package/src/auto-reply/monitor/commands.ts +0 -19
- package/src/auto-reply/monitor/echo.ts +0 -64
- package/src/auto-reply/monitor/group-activation.runtime.ts +0 -1
- package/src/auto-reply/monitor/group-activation.test.ts +0 -189
- package/src/auto-reply/monitor/group-activation.ts +0 -73
- package/src/auto-reply/monitor/group-gating.audio-preflight.test.ts +0 -103
- package/src/auto-reply/monitor/group-gating.runtime.ts +0 -8
- package/src/auto-reply/monitor/group-gating.ts +0 -217
- package/src/auto-reply/monitor/group-members.test.ts +0 -56
- package/src/auto-reply/monitor/group-members.ts +0 -65
- package/src/auto-reply/monitor/inbound-context.test.ts +0 -97
- package/src/auto-reply/monitor/inbound-context.ts +0 -92
- package/src/auto-reply/monitor/inbound-dispatch.runtime.ts +0 -21
- package/src/auto-reply/monitor/inbound-dispatch.test.ts +0 -895
- package/src/auto-reply/monitor/inbound-dispatch.ts +0 -422
- package/src/auto-reply/monitor/last-route.test.ts +0 -37
- package/src/auto-reply/monitor/last-route.ts +0 -61
- package/src/auto-reply/monitor/message-line.runtime.ts +0 -38
- package/src/auto-reply/monitor/message-line.ts +0 -54
- package/src/auto-reply/monitor/on-message.audio-preflight.test.ts +0 -354
- package/src/auto-reply/monitor/on-message.ts +0 -291
- package/src/auto-reply/monitor/peer.ts +0 -17
- package/src/auto-reply/monitor/process-message.audio-preflight.test.ts +0 -420
- package/src/auto-reply/monitor/process-message.test.ts +0 -355
- package/src/auto-reply/monitor/process-message.ts +0 -531
- package/src/auto-reply/monitor/runtime-api.ts +0 -30
- package/src/auto-reply/monitor-state.test.ts +0 -64
- package/src/auto-reply/monitor-state.ts +0 -106
- package/src/auto-reply/monitor.ts +0 -600
- package/src/auto-reply/reply-resolver.runtime.ts +0 -1
- package/src/auto-reply/types.ts +0 -48
- package/src/auto-reply/util.ts +0 -63
- package/src/auto-reply/web-auto-reply-monitor.test.ts +0 -687
- package/src/auto-reply/web-auto-reply-utils.test.ts +0 -392
- package/src/auto-reply.broadcast-groups.combined.test.ts +0 -246
- package/src/auto-reply.broadcast-groups.test-harness.ts +0 -47
- package/src/auto-reply.impl.ts +0 -6
- package/src/auto-reply.test-harness.ts +0 -421
- package/src/auto-reply.ts +0 -1
- package/src/auto-reply.web-auto-reply.compresses-common-formats-jpeg-cap.test.ts +0 -427
- package/src/auto-reply.web-auto-reply.connection-and-logging.e2e.test.ts +0 -908
- package/src/auto-reply.web-auto-reply.last-route.test.ts +0 -184
- package/src/channel-actions.runtime.ts +0 -7
- package/src/channel-actions.test.ts +0 -216
- package/src/channel-actions.ts +0 -84
- package/src/channel-outbound.test.ts +0 -131
- package/src/channel-outbound.ts +0 -36
- package/src/channel-react-action.runtime.ts +0 -7
- package/src/channel-react-action.test.ts +0 -294
- package/src/channel-react-action.ts +0 -84
- package/src/channel.runtime.ts +0 -117
- package/src/channel.setup.test.ts +0 -461
- package/src/channel.setup.ts +0 -28
- package/src/channel.ts +0 -339
- package/src/command-policy.ts +0 -7
- package/src/config-accessors.test.ts +0 -34
- package/src/config-accessors.ts +0 -22
- package/src/config-schema.test.ts +0 -121
- package/src/config-schema.ts +0 -6
- package/src/config-ui-hints.ts +0 -24
- package/src/connection-controller-registry.test.ts +0 -27
- package/src/connection-controller-registry.ts +0 -49
- package/src/connection-controller.test.ts +0 -282
- package/src/connection-controller.ts +0 -679
- package/src/creds-files.ts +0 -19
- package/src/creds-persistence.ts +0 -102
- package/src/directory-config.test.ts +0 -60
- package/src/directory-config.ts +0 -40
- package/src/directory-contract.test.ts +0 -56
- package/src/doctor-contract.ts +0 -11
- package/src/doctor.test.ts +0 -74
- package/src/doctor.ts +0 -56
- package/src/group-intro.ts +0 -15
- package/src/group-policy.test.ts +0 -36
- package/src/group-policy.ts +0 -40
- package/src/group-session-contract.ts +0 -20
- package/src/group-session-key.test.ts +0 -53
- package/src/group-session-key.ts +0 -41
- package/src/heartbeat.ts +0 -34
- package/src/identity.ts +0 -164
- package/src/inbound/access-control.test-harness.ts +0 -37
- package/src/inbound/access-control.test.ts +0 -375
- package/src/inbound/access-control.ts +0 -237
- package/src/inbound/dedupe.ts +0 -132
- package/src/inbound/extract.test.ts +0 -282
- package/src/inbound/extract.ts +0 -488
- package/src/inbound/lifecycle.ts +0 -39
- package/src/inbound/media.node.test.ts +0 -83
- package/src/inbound/media.ts +0 -102
- package/src/inbound/monitor.ts +0 -890
- package/src/inbound/runtime-api.ts +0 -7
- package/src/inbound/save-media.runtime.ts +0 -1
- package/src/inbound/send-api.test.ts +0 -319
- package/src/inbound/send-api.ts +0 -145
- package/src/inbound/send-result.ts +0 -61
- package/src/inbound/types.ts +0 -106
- package/src/inbound-context.contract.test.ts +0 -32
- package/src/inbound-policy.ts +0 -231
- package/src/inbound.media.test.ts +0 -320
- package/src/inbound.test.ts +0 -290
- package/src/inbound.ts +0 -9
- package/src/login-qr.test.ts +0 -483
- package/src/login-qr.ts +0 -542
- package/src/login.coverage.test.ts +0 -133
- package/src/login.test.ts +0 -89
- package/src/login.ts +0 -70
- package/src/logout.test.ts +0 -162
- package/src/media.test.ts +0 -480
- package/src/media.ts +0 -10
- package/src/monitor-inbox.allows-messages-from-senders-allowfrom-list.test-support.ts +0 -400
- package/src/monitor-inbox.append-upsert.test-support.ts +0 -133
- package/src/monitor-inbox.behavior.test.ts +0 -5
- package/src/monitor-inbox.blocks-messages-from-unauthorized-senders-not-allowfrom.test-support.ts +0 -362
- package/src/monitor-inbox.captures-media-path-image-messages.test-support.ts +0 -306
- package/src/monitor-inbox.streams-inbound-messages.test-support.ts +0 -729
- package/src/monitor-inbox.test-harness.ts +0 -304
- package/src/normalize-target.ts +0 -123
- package/src/normalize.ts +0 -7
- package/src/outbound-adapter.poll.test.ts +0 -62
- package/src/outbound-adapter.sendpayload.test.ts +0 -195
- package/src/outbound-adapter.ts +0 -36
- package/src/outbound-base.test.ts +0 -560
- package/src/outbound-base.ts +0 -244
- package/src/outbound-media-contract.ts +0 -278
- package/src/outbound-media.runtime.ts +0 -36
- package/src/outbound-payload.contract.test.ts +0 -61
- package/src/outbound-send-deps.ts +0 -1
- package/src/outbound-test-support.ts +0 -16
- package/src/pairing-security.test-harness.ts +0 -59
- package/src/qr-image.ts +0 -1
- package/src/qr-terminal.ts +0 -1
- package/src/quoted-message.test.ts +0 -83
- package/src/quoted-message.ts +0 -184
- package/src/reaction-level.test.ts +0 -94
- package/src/reaction-level.ts +0 -21
- package/src/reconnect.test.ts +0 -51
- package/src/reconnect.ts +0 -55
- package/src/resolve-outbound-target.test.ts +0 -288
- package/src/resolve-outbound-target.ts +0 -58
- package/src/resolve-target.test.ts +0 -120
- package/src/runtime-api.ts +0 -59
- package/src/runtime-group-policy.ts +0 -16
- package/src/runtime.ts +0 -9
- package/src/security-contract.ts +0 -47
- package/src/security-fix.ts +0 -71
- package/src/send.test.ts +0 -534
- package/src/send.ts +0 -292
- package/src/session-contract.test.ts +0 -31
- package/src/session-contract.ts +0 -43
- package/src/session-errors.ts +0 -125
- package/src/session-route.test.ts +0 -41
- package/src/session-route.ts +0 -32
- package/src/session.runtime.ts +0 -8
- package/src/session.test.ts +0 -559
- package/src/session.ts +0 -330
- package/src/setup-core.ts +0 -52
- package/src/setup-finalize.ts +0 -446
- package/src/setup-surface.test.ts +0 -367
- package/src/setup-surface.ts +0 -69
- package/src/setup-test-helpers.ts +0 -216
- package/src/shared.ts +0 -291
- package/src/socket-timing.test.ts +0 -49
- package/src/socket-timing.ts +0 -38
- package/src/state-migrations.ts +0 -54
- package/src/status-issues.test.ts +0 -137
- package/src/status-issues.ts +0 -185
- package/src/system-prompt.test.ts +0 -199
- package/src/system-prompt.ts +0 -31
- package/src/targets-runtime.ts +0 -180
- package/src/test-helpers.ts +0 -690
- package/src/text-runtime.test.ts +0 -162
- package/src/text-runtime.ts +0 -11
- package/src/vcard.ts +0 -84
- package/targets.ts +0 -5
- package/test-api.ts +0 -2
- package/tsconfig.json +0 -16
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { saveMediaBuffer } from "openclaw/plugin-sdk/media-store";
|
|
@@ -1,319 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
AnyMessageContent,
|
|
3
|
-
MiscMessageGenerationOptions,
|
|
4
|
-
WAMessage,
|
|
5
|
-
} from "@whiskeysockets/baileys";
|
|
6
|
-
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
7
|
-
import { createWebSendApi } from "./send-api.js";
|
|
8
|
-
|
|
9
|
-
const recordChannelActivity = vi.hoisted(() => vi.fn());
|
|
10
|
-
|
|
11
|
-
vi.mock("openclaw/plugin-sdk/channel-activity-runtime", async () => {
|
|
12
|
-
const actual = await vi.importActual<
|
|
13
|
-
typeof import("openclaw/plugin-sdk/channel-activity-runtime")
|
|
14
|
-
>("openclaw/plugin-sdk/channel-activity-runtime");
|
|
15
|
-
return {
|
|
16
|
-
...actual,
|
|
17
|
-
recordChannelActivity: (...args: unknown[]) => recordChannelActivity(...args),
|
|
18
|
-
};
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
describe("createWebSendApi", () => {
|
|
22
|
-
const sendMessage = vi.fn(
|
|
23
|
-
async (
|
|
24
|
-
_jid: string,
|
|
25
|
-
_content: AnyMessageContent,
|
|
26
|
-
_options?: MiscMessageGenerationOptions,
|
|
27
|
-
): Promise<WAMessage | undefined> => ({ key: { id: "msg-1" } }) as WAMessage,
|
|
28
|
-
);
|
|
29
|
-
const sendPresenceUpdate = vi.fn(async () => {});
|
|
30
|
-
let api: ReturnType<typeof createWebSendApi>;
|
|
31
|
-
|
|
32
|
-
beforeEach(() => {
|
|
33
|
-
vi.clearAllMocks();
|
|
34
|
-
api = createWebSendApi({
|
|
35
|
-
sock: { sendMessage, sendPresenceUpdate },
|
|
36
|
-
defaultAccountId: "main",
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it("uses sendOptions fileName for outbound documents", async () => {
|
|
41
|
-
const payload = Buffer.from("pdf");
|
|
42
|
-
await api.sendMessage("+1555", "doc", payload, "application/pdf", { fileName: "invoice.pdf" });
|
|
43
|
-
expect(sendMessage).toHaveBeenCalledWith(
|
|
44
|
-
"1555@s.whatsapp.net",
|
|
45
|
-
expect.objectContaining({
|
|
46
|
-
document: payload,
|
|
47
|
-
fileName: "invoice.pdf",
|
|
48
|
-
caption: "doc",
|
|
49
|
-
mimetype: "application/pdf",
|
|
50
|
-
}),
|
|
51
|
-
);
|
|
52
|
-
expect(recordChannelActivity).toHaveBeenCalledWith({
|
|
53
|
-
channel: "whatsapp",
|
|
54
|
-
accountId: "main",
|
|
55
|
-
direction: "outbound",
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it("falls back to default document filename when fileName is absent", async () => {
|
|
60
|
-
const payload = Buffer.from("pdf");
|
|
61
|
-
await api.sendMessage("+1555", "doc", payload, "application/pdf");
|
|
62
|
-
expect(sendMessage).toHaveBeenCalledWith(
|
|
63
|
-
"1555@s.whatsapp.net",
|
|
64
|
-
expect.objectContaining({
|
|
65
|
-
document: payload,
|
|
66
|
-
fileName: "file",
|
|
67
|
-
caption: "doc",
|
|
68
|
-
mimetype: "application/pdf",
|
|
69
|
-
}),
|
|
70
|
-
);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it("sends plain text messages", async () => {
|
|
74
|
-
const res = await api.sendMessage("+1555", "hello");
|
|
75
|
-
expect(sendMessage).toHaveBeenCalledWith("1555@s.whatsapp.net", { text: "hello" });
|
|
76
|
-
expect(res).toMatchObject({
|
|
77
|
-
kind: "text",
|
|
78
|
-
messageId: "msg-1",
|
|
79
|
-
messageIds: ["msg-1"],
|
|
80
|
-
providerAccepted: true,
|
|
81
|
-
});
|
|
82
|
-
expect(recordChannelActivity).toHaveBeenCalledWith({
|
|
83
|
-
channel: "whatsapp",
|
|
84
|
-
accountId: "main",
|
|
85
|
-
direction: "outbound",
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it("supports image media with caption", async () => {
|
|
90
|
-
const payload = Buffer.from("img");
|
|
91
|
-
await api.sendMessage("+1555", "cap", payload, "image/jpeg");
|
|
92
|
-
expect(sendMessage).toHaveBeenCalledWith(
|
|
93
|
-
"1555@s.whatsapp.net",
|
|
94
|
-
expect.objectContaining({
|
|
95
|
-
image: payload,
|
|
96
|
-
caption: "cap",
|
|
97
|
-
mimetype: "image/jpeg",
|
|
98
|
-
}),
|
|
99
|
-
);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it("supports audio as push-to-talk voice note", async () => {
|
|
103
|
-
const payload = Buffer.from("aud");
|
|
104
|
-
await api.sendMessage("+1555", "", payload, "audio/ogg", { accountId: "alt" });
|
|
105
|
-
expect(sendMessage).toHaveBeenCalledWith(
|
|
106
|
-
"1555@s.whatsapp.net",
|
|
107
|
-
expect.objectContaining({
|
|
108
|
-
audio: payload,
|
|
109
|
-
ptt: true,
|
|
110
|
-
mimetype: "audio/ogg",
|
|
111
|
-
}),
|
|
112
|
-
);
|
|
113
|
-
expect(recordChannelActivity).toHaveBeenCalledWith({
|
|
114
|
-
channel: "whatsapp",
|
|
115
|
-
accountId: "alt",
|
|
116
|
-
direction: "outbound",
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it("sends visible text separately from push-to-talk voice notes", async () => {
|
|
121
|
-
const payload = Buffer.from("aud");
|
|
122
|
-
sendMessage
|
|
123
|
-
.mockResolvedValueOnce({ key: { id: "voice-1" } })
|
|
124
|
-
.mockResolvedValueOnce({ key: { id: "voice-text-1" } });
|
|
125
|
-
const res = await api.sendMessage("+1555", "voice text", payload, "audio/ogg");
|
|
126
|
-
expect(sendMessage).toHaveBeenNthCalledWith(
|
|
127
|
-
1,
|
|
128
|
-
"1555@s.whatsapp.net",
|
|
129
|
-
expect.objectContaining({
|
|
130
|
-
audio: payload,
|
|
131
|
-
ptt: true,
|
|
132
|
-
mimetype: "audio/ogg",
|
|
133
|
-
}),
|
|
134
|
-
);
|
|
135
|
-
expect(sendMessage).toHaveBeenNthCalledWith(2, "1555@s.whatsapp.net", {
|
|
136
|
-
text: "voice text",
|
|
137
|
-
});
|
|
138
|
-
expect(res).toMatchObject({
|
|
139
|
-
kind: "media",
|
|
140
|
-
messageId: "voice-1",
|
|
141
|
-
messageIds: ["voice-1", "voice-text-1"],
|
|
142
|
-
providerAccepted: true,
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
it("supports video media and gifPlayback option", async () => {
|
|
147
|
-
const payload = Buffer.from("vid");
|
|
148
|
-
await api.sendMessage("+1555", "cap", payload, "video/mp4", { gifPlayback: true });
|
|
149
|
-
expect(sendMessage).toHaveBeenCalledWith(
|
|
150
|
-
"1555@s.whatsapp.net",
|
|
151
|
-
expect.objectContaining({
|
|
152
|
-
video: payload,
|
|
153
|
-
caption: "cap",
|
|
154
|
-
mimetype: "video/mp4",
|
|
155
|
-
gifPlayback: true,
|
|
156
|
-
}),
|
|
157
|
-
);
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
it("falls back to unknown messageId if Baileys result does not expose key.id", async () => {
|
|
161
|
-
sendMessage.mockResolvedValueOnce({ key: {} as { id: string } });
|
|
162
|
-
const res = await api.sendMessage("+1555", "hello");
|
|
163
|
-
expect(res.messageId).toBe("unknown");
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
it("sends polls and records outbound activity", async () => {
|
|
167
|
-
const res = await api.sendPoll("+1555", {
|
|
168
|
-
question: "Q?",
|
|
169
|
-
options: ["a", "b"],
|
|
170
|
-
maxSelections: 2,
|
|
171
|
-
});
|
|
172
|
-
expect(sendMessage).toHaveBeenCalledWith(
|
|
173
|
-
"1555@s.whatsapp.net",
|
|
174
|
-
expect.objectContaining({
|
|
175
|
-
poll: { name: "Q?", values: ["a", "b"], selectableCount: 2 },
|
|
176
|
-
}),
|
|
177
|
-
);
|
|
178
|
-
expect(res.messageId).toBe("msg-1");
|
|
179
|
-
expect(recordChannelActivity).toHaveBeenCalledWith({
|
|
180
|
-
channel: "whatsapp",
|
|
181
|
-
accountId: "main",
|
|
182
|
-
direction: "outbound",
|
|
183
|
-
});
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
it("sends reactions with participant JID normalization", async () => {
|
|
187
|
-
const res = await api.sendReaction("+1555", "msg-2", "👍", false, "+1999");
|
|
188
|
-
expect(sendMessage).toHaveBeenCalledWith(
|
|
189
|
-
"1555@s.whatsapp.net",
|
|
190
|
-
expect.objectContaining({
|
|
191
|
-
react: {
|
|
192
|
-
text: "👍",
|
|
193
|
-
key: expect.objectContaining({
|
|
194
|
-
remoteJid: "1555@s.whatsapp.net",
|
|
195
|
-
id: "msg-2",
|
|
196
|
-
fromMe: false,
|
|
197
|
-
participant: "1999@s.whatsapp.net",
|
|
198
|
-
}),
|
|
199
|
-
},
|
|
200
|
-
}),
|
|
201
|
-
);
|
|
202
|
-
expect(res).toMatchObject({
|
|
203
|
-
kind: "reaction",
|
|
204
|
-
messageId: "msg-1",
|
|
205
|
-
providerAccepted: true,
|
|
206
|
-
});
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
it("reports provider-unaccepted sends when Baileys returns no message", async () => {
|
|
210
|
-
sendMessage.mockResolvedValueOnce(undefined);
|
|
211
|
-
|
|
212
|
-
const res = await api.sendMessage("+1555", "hello");
|
|
213
|
-
|
|
214
|
-
expect(res).toMatchObject({
|
|
215
|
-
kind: "text",
|
|
216
|
-
messageId: "unknown",
|
|
217
|
-
messageIds: [],
|
|
218
|
-
providerAccepted: false,
|
|
219
|
-
});
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
it("keeps direct-chat reactions without a participant key", async () => {
|
|
223
|
-
await api.sendReaction("+1555", "msg-2", "👍", false);
|
|
224
|
-
expect(sendMessage).toHaveBeenCalledWith(
|
|
225
|
-
"1555@s.whatsapp.net",
|
|
226
|
-
expect.objectContaining({
|
|
227
|
-
react: {
|
|
228
|
-
text: "👍",
|
|
229
|
-
key: expect.objectContaining({
|
|
230
|
-
remoteJid: "1555@s.whatsapp.net",
|
|
231
|
-
id: "msg-2",
|
|
232
|
-
fromMe: false,
|
|
233
|
-
participant: undefined,
|
|
234
|
-
}),
|
|
235
|
-
},
|
|
236
|
-
}),
|
|
237
|
-
);
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
it("preserves LID participants in reaction keys", async () => {
|
|
241
|
-
await api.sendReaction("12345@g.us", "msg-2", "👍", false, "123@lid");
|
|
242
|
-
expect(sendMessage).toHaveBeenCalledWith(
|
|
243
|
-
"12345@g.us",
|
|
244
|
-
expect.objectContaining({
|
|
245
|
-
react: {
|
|
246
|
-
text: "👍",
|
|
247
|
-
key: expect.objectContaining({
|
|
248
|
-
remoteJid: "12345@g.us",
|
|
249
|
-
id: "msg-2",
|
|
250
|
-
fromMe: false,
|
|
251
|
-
participant: "123@lid",
|
|
252
|
-
}),
|
|
253
|
-
},
|
|
254
|
-
}),
|
|
255
|
-
);
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
it("sends composing presence updates to the recipient JID", async () => {
|
|
259
|
-
await api.sendComposingTo("+1555");
|
|
260
|
-
expect(sendPresenceUpdate).toHaveBeenCalledWith("composing", "1555@s.whatsapp.net");
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
it("does not send composing presence to newsletter JIDs", async () => {
|
|
264
|
-
await api.sendComposingTo("120363401234567890@newsletter");
|
|
265
|
-
expect(sendPresenceUpdate).not.toHaveBeenCalled();
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
it("preserves newsletter JIDs for outbound sends", async () => {
|
|
269
|
-
await api.sendMessage("120363401234567890@newsletter", "hello");
|
|
270
|
-
expect(sendMessage).toHaveBeenCalledWith("120363401234567890@newsletter", {
|
|
271
|
-
text: "hello",
|
|
272
|
-
});
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
it("sends media as document when mediaType is undefined", async () => {
|
|
276
|
-
const mediaBuffer = Buffer.from("test");
|
|
277
|
-
|
|
278
|
-
await api.sendMessage("123", "hello", mediaBuffer, undefined);
|
|
279
|
-
|
|
280
|
-
expect(sendMessage).toHaveBeenCalledWith(
|
|
281
|
-
"123@s.whatsapp.net",
|
|
282
|
-
expect.objectContaining({
|
|
283
|
-
document: mediaBuffer,
|
|
284
|
-
mimetype: "application/octet-stream",
|
|
285
|
-
}),
|
|
286
|
-
);
|
|
287
|
-
});
|
|
288
|
-
|
|
289
|
-
it("does not set mediaType when mediaBuffer is absent", async () => {
|
|
290
|
-
await api.sendMessage("123", "hello");
|
|
291
|
-
|
|
292
|
-
expect(sendMessage).toHaveBeenCalledWith("123@s.whatsapp.net", { text: "hello" });
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
it("preserves the quoted remoteJid provided by the outbound adapter", async () => {
|
|
296
|
-
await api.sendMessage("+1555", "hello", undefined, undefined, {
|
|
297
|
-
quotedMessageKey: {
|
|
298
|
-
id: "quoted-1",
|
|
299
|
-
remoteJid: "277038292303944@lid",
|
|
300
|
-
fromMe: false,
|
|
301
|
-
participant: "1234@s.whatsapp.net",
|
|
302
|
-
messageText: "quoted body",
|
|
303
|
-
},
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
expect(sendMessage).toHaveBeenCalledWith(
|
|
307
|
-
"1555@s.whatsapp.net",
|
|
308
|
-
{ text: "hello" },
|
|
309
|
-
expect.objectContaining({
|
|
310
|
-
quoted: expect.objectContaining({
|
|
311
|
-
key: expect.objectContaining({
|
|
312
|
-
remoteJid: "277038292303944@lid",
|
|
313
|
-
id: "quoted-1",
|
|
314
|
-
}),
|
|
315
|
-
}),
|
|
316
|
-
}),
|
|
317
|
-
);
|
|
318
|
-
});
|
|
319
|
-
});
|
package/src/inbound/send-api.ts
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
AnyMessageContent,
|
|
3
|
-
MiscMessageGenerationOptions,
|
|
4
|
-
WAMessage,
|
|
5
|
-
WAPresence,
|
|
6
|
-
} from "@whiskeysockets/baileys";
|
|
7
|
-
import { recordChannelActivity } from "openclaw/plugin-sdk/channel-activity-runtime";
|
|
8
|
-
import { isWhatsAppNewsletterJid } from "../normalize.js";
|
|
9
|
-
import { buildQuotedMessageOptions } from "../quoted-message.js";
|
|
10
|
-
import { toWhatsappJid } from "../text-runtime.js";
|
|
11
|
-
import {
|
|
12
|
-
combineWhatsAppSendResults,
|
|
13
|
-
normalizeWhatsAppSendResult,
|
|
14
|
-
type WhatsAppSendResult,
|
|
15
|
-
} from "./send-result.js";
|
|
16
|
-
import type { ActiveWebSendOptions } from "./types.js";
|
|
17
|
-
|
|
18
|
-
function recordWhatsAppOutbound(accountId: string) {
|
|
19
|
-
recordChannelActivity({
|
|
20
|
-
channel: "whatsapp",
|
|
21
|
-
accountId,
|
|
22
|
-
direction: "outbound",
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export function createWebSendApi(params: {
|
|
27
|
-
sock: {
|
|
28
|
-
sendMessage: (
|
|
29
|
-
jid: string,
|
|
30
|
-
content: AnyMessageContent,
|
|
31
|
-
options?: MiscMessageGenerationOptions,
|
|
32
|
-
) => Promise<WAMessage | undefined>;
|
|
33
|
-
sendPresenceUpdate: (presence: WAPresence, jid?: string) => Promise<unknown>;
|
|
34
|
-
};
|
|
35
|
-
defaultAccountId: string;
|
|
36
|
-
}) {
|
|
37
|
-
return {
|
|
38
|
-
sendMessage: async (
|
|
39
|
-
to: string,
|
|
40
|
-
text: string,
|
|
41
|
-
mediaBuffer?: Buffer,
|
|
42
|
-
mediaType?: string,
|
|
43
|
-
sendOptions?: ActiveWebSendOptions,
|
|
44
|
-
): Promise<WhatsAppSendResult> => {
|
|
45
|
-
const jid = toWhatsappJid(to);
|
|
46
|
-
let payload: AnyMessageContent;
|
|
47
|
-
if (mediaBuffer) {
|
|
48
|
-
mediaType ??= "application/octet-stream";
|
|
49
|
-
}
|
|
50
|
-
if (mediaBuffer && mediaType) {
|
|
51
|
-
if (mediaType.startsWith("image/")) {
|
|
52
|
-
payload = {
|
|
53
|
-
image: mediaBuffer,
|
|
54
|
-
caption: text || undefined,
|
|
55
|
-
mimetype: mediaType,
|
|
56
|
-
};
|
|
57
|
-
} else if (mediaType.startsWith("audio/")) {
|
|
58
|
-
payload = { audio: mediaBuffer, ptt: true, mimetype: mediaType };
|
|
59
|
-
} else if (mediaType.startsWith("video/")) {
|
|
60
|
-
const gifPlayback = sendOptions?.gifPlayback;
|
|
61
|
-
payload = {
|
|
62
|
-
video: mediaBuffer,
|
|
63
|
-
caption: text || undefined,
|
|
64
|
-
mimetype: mediaType,
|
|
65
|
-
...(gifPlayback ? { gifPlayback: true } : {}),
|
|
66
|
-
};
|
|
67
|
-
} else {
|
|
68
|
-
const fileName = sendOptions?.fileName?.trim() || "file";
|
|
69
|
-
payload = {
|
|
70
|
-
document: mediaBuffer,
|
|
71
|
-
fileName,
|
|
72
|
-
caption: text || undefined,
|
|
73
|
-
mimetype: mediaType,
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
} else {
|
|
77
|
-
payload = { text };
|
|
78
|
-
}
|
|
79
|
-
const quotedOpts = buildQuotedMessageOptions({
|
|
80
|
-
messageId: sendOptions?.quotedMessageKey?.id,
|
|
81
|
-
remoteJid: sendOptions?.quotedMessageKey?.remoteJid,
|
|
82
|
-
fromMe: sendOptions?.quotedMessageKey?.fromMe,
|
|
83
|
-
participant: sendOptions?.quotedMessageKey?.participant,
|
|
84
|
-
messageText: sendOptions?.quotedMessageKey?.messageText,
|
|
85
|
-
});
|
|
86
|
-
const result = quotedOpts
|
|
87
|
-
? await params.sock.sendMessage(jid, payload, quotedOpts)
|
|
88
|
-
: await params.sock.sendMessage(jid, payload);
|
|
89
|
-
const results = [normalizeWhatsAppSendResult(result, mediaBuffer ? "media" : "text")];
|
|
90
|
-
if (mediaBuffer && mediaType?.startsWith("audio/") && text.trim()) {
|
|
91
|
-
const textPayload: AnyMessageContent = { text };
|
|
92
|
-
const textResult = quotedOpts
|
|
93
|
-
? await params.sock.sendMessage(jid, textPayload, quotedOpts)
|
|
94
|
-
: await params.sock.sendMessage(jid, textPayload);
|
|
95
|
-
results.push(normalizeWhatsAppSendResult(textResult, "text"));
|
|
96
|
-
}
|
|
97
|
-
const accountId = sendOptions?.accountId ?? params.defaultAccountId;
|
|
98
|
-
recordWhatsAppOutbound(accountId);
|
|
99
|
-
return combineWhatsAppSendResults(mediaBuffer ? "media" : "text", results);
|
|
100
|
-
},
|
|
101
|
-
sendPoll: async (
|
|
102
|
-
to: string,
|
|
103
|
-
poll: { question: string; options: string[]; maxSelections?: number },
|
|
104
|
-
): Promise<WhatsAppSendResult> => {
|
|
105
|
-
const jid = toWhatsappJid(to);
|
|
106
|
-
const result = await params.sock.sendMessage(jid, {
|
|
107
|
-
poll: {
|
|
108
|
-
name: poll.question,
|
|
109
|
-
values: poll.options,
|
|
110
|
-
selectableCount: poll.maxSelections ?? 1,
|
|
111
|
-
},
|
|
112
|
-
} as AnyMessageContent);
|
|
113
|
-
recordWhatsAppOutbound(params.defaultAccountId);
|
|
114
|
-
return normalizeWhatsAppSendResult(result, "poll");
|
|
115
|
-
},
|
|
116
|
-
sendReaction: async (
|
|
117
|
-
chatJid: string,
|
|
118
|
-
messageId: string,
|
|
119
|
-
emoji: string,
|
|
120
|
-
fromMe: boolean,
|
|
121
|
-
participant?: string,
|
|
122
|
-
): Promise<WhatsAppSendResult> => {
|
|
123
|
-
const jid = toWhatsappJid(chatJid);
|
|
124
|
-
const result = await params.sock.sendMessage(jid, {
|
|
125
|
-
react: {
|
|
126
|
-
text: emoji,
|
|
127
|
-
key: {
|
|
128
|
-
remoteJid: jid,
|
|
129
|
-
id: messageId,
|
|
130
|
-
fromMe,
|
|
131
|
-
participant: participant ? toWhatsappJid(participant) : undefined,
|
|
132
|
-
},
|
|
133
|
-
},
|
|
134
|
-
} as AnyMessageContent);
|
|
135
|
-
return normalizeWhatsAppSendResult(result, "reaction");
|
|
136
|
-
},
|
|
137
|
-
sendComposingTo: async (to: string): Promise<void> => {
|
|
138
|
-
const jid = toWhatsappJid(to);
|
|
139
|
-
if (isWhatsAppNewsletterJid(jid)) {
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
await params.sock.sendPresenceUpdate("composing", jid);
|
|
143
|
-
},
|
|
144
|
-
} as const;
|
|
145
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import type { WAMessage, WAMessageKey } from "@whiskeysockets/baileys";
|
|
2
|
-
|
|
3
|
-
export type WhatsAppSendKind = "media" | "poll" | "reaction" | "text";
|
|
4
|
-
|
|
5
|
-
type WhatsAppSendKey = Omit<
|
|
6
|
-
Pick<WAMessageKey, "fromMe" | "id" | "participant" | "remoteJid">,
|
|
7
|
-
"id"
|
|
8
|
-
> & {
|
|
9
|
-
id: string;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export type WhatsAppSendResult = {
|
|
13
|
-
kind: WhatsAppSendKind;
|
|
14
|
-
messageId: string;
|
|
15
|
-
messageIds: string[];
|
|
16
|
-
keys: WhatsAppSendKey[];
|
|
17
|
-
providerAccepted: boolean;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
function normalizeKey(key: WAMessageKey | undefined): WhatsAppSendKey | undefined {
|
|
21
|
-
const id = typeof key?.id === "string" ? key.id.trim() : "";
|
|
22
|
-
if (!id) {
|
|
23
|
-
return undefined;
|
|
24
|
-
}
|
|
25
|
-
return {
|
|
26
|
-
id,
|
|
27
|
-
remoteJid: key?.remoteJid,
|
|
28
|
-
fromMe: key?.fromMe,
|
|
29
|
-
participant: key?.participant,
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function normalizeWhatsAppSendResult(
|
|
34
|
-
result: WAMessage | undefined,
|
|
35
|
-
kind: WhatsAppSendKind,
|
|
36
|
-
): WhatsAppSendResult {
|
|
37
|
-
const key = normalizeKey(result?.key);
|
|
38
|
-
const messageId = key?.id ?? "unknown";
|
|
39
|
-
return {
|
|
40
|
-
kind,
|
|
41
|
-
messageId,
|
|
42
|
-
messageIds: key ? [key.id] : [],
|
|
43
|
-
keys: key ? [key] : [],
|
|
44
|
-
providerAccepted: Boolean(key),
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export function combineWhatsAppSendResults(
|
|
49
|
-
kind: WhatsAppSendKind,
|
|
50
|
-
results: readonly WhatsAppSendResult[],
|
|
51
|
-
): WhatsAppSendResult {
|
|
52
|
-
const messageIds = [...new Set(results.flatMap((result) => result.messageIds))];
|
|
53
|
-
const keys = results.flatMap((result) => result.keys);
|
|
54
|
-
return {
|
|
55
|
-
kind,
|
|
56
|
-
messageId: messageIds[0] ?? "unknown",
|
|
57
|
-
messageIds,
|
|
58
|
-
keys,
|
|
59
|
-
providerAccepted: results.some((result) => result.providerAccepted),
|
|
60
|
-
};
|
|
61
|
-
}
|
package/src/inbound/types.ts
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import type { AnyMessageContent, MiscMessageGenerationOptions } from "@whiskeysockets/baileys";
|
|
2
|
-
import type { NormalizedLocation } from "openclaw/plugin-sdk/channel-inbound";
|
|
3
|
-
import type { PollInput } from "openclaw/plugin-sdk/poll-runtime";
|
|
4
|
-
import type { WhatsAppIdentity, WhatsAppReplyContext, WhatsAppSelfIdentity } from "../identity.js";
|
|
5
|
-
import type { WhatsAppSendResult } from "./send-result.js";
|
|
6
|
-
|
|
7
|
-
export type WebListenerCloseReason = {
|
|
8
|
-
status?: number;
|
|
9
|
-
isLoggedOut: boolean;
|
|
10
|
-
error?: unknown;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export type ActiveWebSendOptions = {
|
|
14
|
-
quotedMessageKey?: {
|
|
15
|
-
id: string;
|
|
16
|
-
remoteJid: string;
|
|
17
|
-
fromMe: boolean;
|
|
18
|
-
participant?: string;
|
|
19
|
-
messageText?: string;
|
|
20
|
-
};
|
|
21
|
-
gifPlayback?: boolean;
|
|
22
|
-
accountId?: string;
|
|
23
|
-
fileName?: string;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export type ActiveWebListener = {
|
|
27
|
-
sendMessage: (
|
|
28
|
-
to: string,
|
|
29
|
-
text: string,
|
|
30
|
-
mediaBuffer?: Buffer,
|
|
31
|
-
mediaType?: string,
|
|
32
|
-
options?: ActiveWebSendOptions,
|
|
33
|
-
) => Promise<WhatsAppSendResult>;
|
|
34
|
-
sendPoll: (to: string, poll: PollInput) => Promise<WhatsAppSendResult>;
|
|
35
|
-
sendReaction: (
|
|
36
|
-
chatJid: string,
|
|
37
|
-
messageId: string,
|
|
38
|
-
emoji: string,
|
|
39
|
-
fromMe: boolean,
|
|
40
|
-
participant?: string,
|
|
41
|
-
) => Promise<WhatsAppSendResult>;
|
|
42
|
-
sendComposingTo: (to: string) => Promise<void>;
|
|
43
|
-
close?: () => Promise<void>;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export type WhatsAppStructuredContactContext = {
|
|
47
|
-
kind: "contact" | "contacts";
|
|
48
|
-
total: number;
|
|
49
|
-
contacts: Array<{
|
|
50
|
-
name?: string;
|
|
51
|
-
phones?: string[];
|
|
52
|
-
}>;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export type WebInboundMessage = {
|
|
56
|
-
id?: string;
|
|
57
|
-
from: string; // conversation id: E.164 for direct chats, group JID for groups
|
|
58
|
-
conversationId: string; // alias for clarity (same as from)
|
|
59
|
-
to: string;
|
|
60
|
-
accountId: string;
|
|
61
|
-
/** Set by the real inbound monitor after access-control / pairing checks pass. */
|
|
62
|
-
accessControlPassed?: boolean;
|
|
63
|
-
body: string;
|
|
64
|
-
pushName?: string;
|
|
65
|
-
timestamp?: number;
|
|
66
|
-
chatType: "direct" | "group";
|
|
67
|
-
chatId: string;
|
|
68
|
-
sender?: WhatsAppIdentity;
|
|
69
|
-
senderJid?: string;
|
|
70
|
-
senderE164?: string;
|
|
71
|
-
senderName?: string;
|
|
72
|
-
replyTo?: WhatsAppReplyContext;
|
|
73
|
-
replyToId?: string;
|
|
74
|
-
replyToBody?: string;
|
|
75
|
-
replyToSender?: string;
|
|
76
|
-
replyToSenderJid?: string;
|
|
77
|
-
replyToSenderE164?: string;
|
|
78
|
-
groupSubject?: string;
|
|
79
|
-
groupParticipants?: string[];
|
|
80
|
-
mentions?: string[];
|
|
81
|
-
mentionedJids?: string[];
|
|
82
|
-
self?: WhatsAppSelfIdentity;
|
|
83
|
-
selfJid?: string | null;
|
|
84
|
-
selfLid?: string | null;
|
|
85
|
-
selfE164?: string | null;
|
|
86
|
-
fromMe?: boolean;
|
|
87
|
-
location?: NormalizedLocation;
|
|
88
|
-
sendComposing: () => Promise<void>;
|
|
89
|
-
reply: (text: string, options?: MiscMessageGenerationOptions) => Promise<WhatsAppSendResult>;
|
|
90
|
-
sendMedia: (
|
|
91
|
-
payload: AnyMessageContent,
|
|
92
|
-
options?: MiscMessageGenerationOptions,
|
|
93
|
-
) => Promise<WhatsAppSendResult>;
|
|
94
|
-
mediaPath?: string;
|
|
95
|
-
mediaType?: string;
|
|
96
|
-
mediaFileName?: string;
|
|
97
|
-
mediaUrl?: string;
|
|
98
|
-
untrustedStructuredContext?: Array<{
|
|
99
|
-
label: string;
|
|
100
|
-
source?: string;
|
|
101
|
-
type?: string;
|
|
102
|
-
payload: unknown;
|
|
103
|
-
}>;
|
|
104
|
-
wasMentioned?: boolean;
|
|
105
|
-
isBatched?: boolean;
|
|
106
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { expectChannelInboundContextContract } from "openclaw/plugin-sdk/channel-contract-testing";
|
|
2
|
-
import { describe, it } from "vitest";
|
|
3
|
-
|
|
4
|
-
describe("WhatsApp inbound context contract", () => {
|
|
5
|
-
it("keeps inbound context finalized", () => {
|
|
6
|
-
const ctx = {
|
|
7
|
-
Body: "Alice: hi",
|
|
8
|
-
BodyForAgent: "hi",
|
|
9
|
-
RawBody: "hi",
|
|
10
|
-
CommandBody: "hi",
|
|
11
|
-
BodyForCommands: "hi",
|
|
12
|
-
From: "123@g.us",
|
|
13
|
-
To: "+15550001111",
|
|
14
|
-
SessionKey: "agent:main:whatsapp:group:123",
|
|
15
|
-
AccountId: "default",
|
|
16
|
-
ChatType: "group",
|
|
17
|
-
ConversationLabel: "123@g.us",
|
|
18
|
-
GroupSubject: "Test Group",
|
|
19
|
-
SenderName: "Alice",
|
|
20
|
-
SenderId: "alice@s.whatsapp.net",
|
|
21
|
-
SenderE164: "+15550002222",
|
|
22
|
-
Provider: "whatsapp",
|
|
23
|
-
Surface: "whatsapp",
|
|
24
|
-
MessageSid: "msg1",
|
|
25
|
-
OriginatingChannel: "whatsapp",
|
|
26
|
-
OriginatingTo: "123@g.us",
|
|
27
|
-
CommandAuthorized: true,
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
expectChannelInboundContextContract(ctx);
|
|
31
|
-
});
|
|
32
|
-
});
|