@openclaw/whatsapp 2026.5.1-beta.1
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/action-runtime-api.ts +1 -0
- package/action-runtime.runtime.ts +1 -0
- package/api.ts +213 -0
- package/auth-presence.ts +80 -0
- package/channel-config-api.ts +1 -0
- package/channel-plugin-api.ts +3 -0
- package/config-api.ts +4 -0
- package/constants.ts +1 -0
- package/contract-api.ts +29 -0
- package/directory-contract-api.ts +4 -0
- package/dist/.boundary-tsc.stamp +1 -0
- package/dist/.boundary-tsc.tsbuildinfo +1 -0
- package/doctor-contract-api.ts +8 -0
- package/index.test.ts +13 -0
- package/index.ts +16 -0
- package/legacy-session-surface-api.ts +6 -0
- package/legacy-state-migrations-api.ts +1 -0
- package/light-runtime-api.ts +12 -0
- package/login-qr-api.ts +1 -0
- package/login-qr-runtime.ts +23 -0
- package/openclaw.plugin.json +742 -0
- package/outbound-payload-test-api.ts +1 -0
- package/package.json +74 -0
- package/runtime-api.ts +86 -0
- package/secret-contract-api.ts +4 -0
- package/security-contract-api.ts +4 -0
- package/setup-entry.test.ts +21 -0
- package/setup-entry.ts +21 -0
- package/setup-plugin-api.ts +3 -0
- package/src/account-config.ts +77 -0
- package/src/account-ids.ts +13 -0
- package/src/account-types.ts +5 -0
- package/src/accounts.test.ts +182 -0
- package/src/accounts.ts +176 -0
- package/src/accounts.whatsapp-auth.test.ts +59 -0
- package/src/action-runtime-target-auth.ts +27 -0
- package/src/action-runtime.test.ts +330 -0
- package/src/action-runtime.ts +76 -0
- package/src/active-listener.test.ts +65 -0
- package/src/active-listener.ts +17 -0
- package/src/agent-tools-login.test.ts +81 -0
- package/src/agent-tools-login.ts +113 -0
- package/src/approval-auth.test.ts +24 -0
- package/src/approval-auth.ts +27 -0
- package/src/auth-store.runtime.ts +1 -0
- package/src/auth-store.test.ts +311 -0
- package/src/auth-store.ts +502 -0
- package/src/auto-reply/config.runtime.ts +16 -0
- package/src/auto-reply/constants.ts +1 -0
- package/src/auto-reply/deliver-reply.test.ts +843 -0
- package/src/auto-reply/deliver-reply.ts +279 -0
- package/src/auto-reply/heartbeat-runner.runtime.ts +33 -0
- package/src/auto-reply/heartbeat-runner.test.ts +214 -0
- package/src/auto-reply/heartbeat-runner.ts +330 -0
- package/src/auto-reply/loggers.ts +6 -0
- package/src/auto-reply/mentions.ts +131 -0
- package/src/auto-reply/monitor/ack-reaction.test.ts +170 -0
- package/src/auto-reply/monitor/ack-reaction.ts +99 -0
- package/src/auto-reply/monitor/audio-preflight.runtime.ts +9 -0
- package/src/auto-reply/monitor/broadcast.ts +153 -0
- package/src/auto-reply/monitor/commands.ts +19 -0
- package/src/auto-reply/monitor/echo.ts +64 -0
- package/src/auto-reply/monitor/group-activation.runtime.ts +1 -0
- package/src/auto-reply/monitor/group-activation.test.ts +189 -0
- package/src/auto-reply/monitor/group-activation.ts +73 -0
- package/src/auto-reply/monitor/group-gating.audio-preflight.test.ts +103 -0
- package/src/auto-reply/monitor/group-gating.runtime.ts +8 -0
- package/src/auto-reply/monitor/group-gating.ts +217 -0
- package/src/auto-reply/monitor/group-members.test.ts +56 -0
- package/src/auto-reply/monitor/group-members.ts +65 -0
- package/src/auto-reply/monitor/inbound-context.test.ts +97 -0
- package/src/auto-reply/monitor/inbound-context.ts +92 -0
- package/src/auto-reply/monitor/inbound-dispatch.runtime.ts +21 -0
- package/src/auto-reply/monitor/inbound-dispatch.test.ts +895 -0
- package/src/auto-reply/monitor/inbound-dispatch.ts +422 -0
- package/src/auto-reply/monitor/last-route.test.ts +37 -0
- package/src/auto-reply/monitor/last-route.ts +61 -0
- package/src/auto-reply/monitor/message-line.runtime.ts +38 -0
- package/src/auto-reply/monitor/message-line.ts +54 -0
- package/src/auto-reply/monitor/on-message.audio-preflight.test.ts +354 -0
- package/src/auto-reply/monitor/on-message.ts +291 -0
- package/src/auto-reply/monitor/peer.ts +17 -0
- package/src/auto-reply/monitor/process-message.audio-preflight.test.ts +420 -0
- package/src/auto-reply/monitor/process-message.test.ts +355 -0
- package/src/auto-reply/monitor/process-message.ts +531 -0
- package/src/auto-reply/monitor/runtime-api.ts +30 -0
- package/src/auto-reply/monitor-state.test.ts +64 -0
- package/src/auto-reply/monitor-state.ts +106 -0
- package/src/auto-reply/monitor.ts +600 -0
- package/src/auto-reply/reply-resolver.runtime.ts +1 -0
- package/src/auto-reply/session-snapshot.ts +69 -0
- package/src/auto-reply/types.ts +48 -0
- package/src/auto-reply/util.ts +63 -0
- package/src/auto-reply/web-auto-reply-monitor.test.ts +687 -0
- package/src/auto-reply/web-auto-reply-utils.test.ts +327 -0
- package/src/auto-reply.broadcast-groups.combined.test.ts +246 -0
- package/src/auto-reply.broadcast-groups.test-harness.ts +47 -0
- package/src/auto-reply.impl.ts +7 -0
- package/src/auto-reply.test-harness.ts +421 -0
- package/src/auto-reply.ts +1 -0
- package/src/auto-reply.web-auto-reply.compresses-common-formats-jpeg-cap.test.ts +427 -0
- package/src/auto-reply.web-auto-reply.connection-and-logging.e2e.test.ts +908 -0
- package/src/auto-reply.web-auto-reply.last-route.test.ts +184 -0
- package/src/channel-actions.runtime.ts +7 -0
- package/src/channel-actions.test.ts +216 -0
- package/src/channel-actions.ts +84 -0
- package/src/channel-outbound.test.ts +131 -0
- package/src/channel-outbound.ts +36 -0
- package/src/channel-react-action.runtime.ts +7 -0
- package/src/channel-react-action.test.ts +294 -0
- package/src/channel-react-action.ts +84 -0
- package/src/channel.runtime.ts +117 -0
- package/src/channel.setup.test.ts +461 -0
- package/src/channel.setup.ts +28 -0
- package/src/channel.ts +336 -0
- package/src/command-policy.ts +7 -0
- package/src/config-accessors.test.ts +34 -0
- package/src/config-accessors.ts +22 -0
- package/src/config-schema.test.ts +121 -0
- package/src/config-schema.ts +6 -0
- package/src/config-ui-hints.ts +24 -0
- package/src/connection-controller-registry.test.ts +27 -0
- package/src/connection-controller-registry.ts +49 -0
- package/src/connection-controller.test.ts +282 -0
- package/src/connection-controller.ts +679 -0
- package/src/creds-files.ts +19 -0
- package/src/creds-persistence.ts +102 -0
- package/src/directory-config.test.ts +60 -0
- package/src/directory-config.ts +40 -0
- package/src/directory-contract.test.ts +56 -0
- package/src/doctor-contract.ts +11 -0
- package/src/doctor.test.ts +74 -0
- package/src/doctor.ts +56 -0
- package/src/group-intro.ts +15 -0
- package/src/group-policy.test.ts +36 -0
- package/src/group-policy.ts +40 -0
- package/src/group-session-contract.ts +20 -0
- package/src/group-session-key.test.ts +53 -0
- package/src/group-session-key.ts +41 -0
- package/src/heartbeat-recipients.runtime.ts +6 -0
- package/src/heartbeat-recipients.test.ts +203 -0
- package/src/heartbeat-recipients.ts +104 -0
- package/src/heartbeat.ts +34 -0
- package/src/identity.ts +164 -0
- package/src/inbound/access-control.test-harness.ts +37 -0
- package/src/inbound/access-control.test.ts +375 -0
- package/src/inbound/access-control.ts +237 -0
- package/src/inbound/dedupe.ts +132 -0
- package/src/inbound/extract.test.ts +282 -0
- package/src/inbound/extract.ts +488 -0
- package/src/inbound/lifecycle.ts +39 -0
- package/src/inbound/media.node.test.ts +83 -0
- package/src/inbound/media.ts +102 -0
- package/src/inbound/monitor.ts +890 -0
- package/src/inbound/runtime-api.ts +7 -0
- package/src/inbound/save-media.runtime.ts +1 -0
- package/src/inbound/send-api.test.ts +307 -0
- package/src/inbound/send-api.ts +141 -0
- package/src/inbound/send-result.ts +61 -0
- package/src/inbound/types.ts +106 -0
- package/src/inbound-context.contract.test.ts +32 -0
- package/src/inbound-policy.ts +231 -0
- package/src/inbound.media.test.ts +320 -0
- package/src/inbound.test.ts +290 -0
- package/src/inbound.ts +9 -0
- package/src/login-qr.test.ts +483 -0
- package/src/login-qr.ts +542 -0
- package/src/login.coverage.test.ts +133 -0
- package/src/login.test.ts +89 -0
- package/src/login.ts +70 -0
- package/src/logout.test.ts +162 -0
- package/src/media.test.ts +480 -0
- package/src/media.ts +10 -0
- package/src/monitor-inbox.allows-messages-from-senders-allowfrom-list.test-support.ts +400 -0
- package/src/monitor-inbox.append-upsert.test-support.ts +133 -0
- package/src/monitor-inbox.behavior.test.ts +5 -0
- package/src/monitor-inbox.blocks-messages-from-unauthorized-senders-not-allowfrom.test-support.ts +362 -0
- package/src/monitor-inbox.captures-media-path-image-messages.test-support.ts +306 -0
- package/src/monitor-inbox.streams-inbound-messages.test-support.ts +729 -0
- package/src/monitor-inbox.test-harness.ts +304 -0
- package/src/normalize-target.ts +112 -0
- package/src/normalize.ts +6 -0
- package/src/outbound-adapter.poll.test.ts +62 -0
- package/src/outbound-adapter.sendpayload.test.ts +195 -0
- package/src/outbound-adapter.ts +36 -0
- package/src/outbound-base.test.ts +560 -0
- package/src/outbound-base.ts +244 -0
- package/src/outbound-media-contract.ts +278 -0
- package/src/outbound-media.runtime.ts +36 -0
- package/src/outbound-payload.contract.test.ts +61 -0
- package/src/outbound-send-deps.ts +1 -0
- package/src/outbound-test-support.ts +16 -0
- package/src/pairing-security.test-harness.ts +59 -0
- package/src/qr-image.ts +1 -0
- package/src/qr-terminal.ts +1 -0
- package/src/quoted-message.test.ts +83 -0
- package/src/quoted-message.ts +184 -0
- package/src/reaction-level.test.ts +94 -0
- package/src/reaction-level.ts +21 -0
- package/src/reconnect.test.ts +51 -0
- package/src/reconnect.ts +55 -0
- package/src/resolve-outbound-target.test.ts +265 -0
- package/src/resolve-outbound-target.ts +54 -0
- package/src/resolve-target.test.ts +97 -0
- package/src/runtime-api.ts +60 -0
- package/src/runtime-group-policy.ts +16 -0
- package/src/runtime.ts +9 -0
- package/src/security-contract.ts +47 -0
- package/src/security-fix.ts +71 -0
- package/src/send.test.ts +515 -0
- package/src/send.ts +287 -0
- package/src/session-contract.test.ts +31 -0
- package/src/session-contract.ts +43 -0
- package/src/session-errors.ts +125 -0
- package/src/session-route.ts +26 -0
- package/src/session.runtime.ts +8 -0
- package/src/session.test.ts +559 -0
- package/src/session.ts +330 -0
- package/src/setup-core.ts +52 -0
- package/src/setup-finalize.ts +446 -0
- package/src/setup-surface.test.ts +367 -0
- package/src/setup-surface.ts +69 -0
- package/src/setup-test-helpers.ts +216 -0
- package/src/shared.ts +291 -0
- package/src/socket-timing.test.ts +49 -0
- package/src/socket-timing.ts +38 -0
- package/src/state-migrations.ts +54 -0
- package/src/status-issues.test.ts +137 -0
- package/src/status-issues.ts +185 -0
- package/src/system-prompt.test.ts +199 -0
- package/src/system-prompt.ts +31 -0
- package/src/targets-runtime.ts +180 -0
- package/src/test-helpers.ts +690 -0
- package/src/text-runtime.test.ts +162 -0
- package/src/text-runtime.ts +11 -0
- package/src/vcard.ts +84 -0
- package/targets.ts +5 -0
- package/test-api.ts +2 -0
- package/tsconfig.json +16 -0
package/src/channel.ts
ADDED
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/account-id";
|
|
2
|
+
import { buildDmGroupAccountAllowlistAdapter } from "openclaw/plugin-sdk/allowlist-config-edit";
|
|
3
|
+
import { createChatChannelPlugin, type ChannelPlugin } from "openclaw/plugin-sdk/channel-core";
|
|
4
|
+
import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
|
|
5
|
+
import {
|
|
6
|
+
createAsyncComputedAccountStatusAdapter,
|
|
7
|
+
createDefaultChannelRuntimeState,
|
|
8
|
+
} from "openclaw/plugin-sdk/status-helpers";
|
|
9
|
+
import { resolveWhatsAppAccount, type ResolvedWhatsAppAccount } from "./accounts.js";
|
|
10
|
+
import { createWhatsAppLoginTool } from "./agent-tools-login.js";
|
|
11
|
+
import { whatsappApprovalAuth } from "./approval-auth.js";
|
|
12
|
+
import type { WebChannelStatus } from "./auto-reply/types.js";
|
|
13
|
+
import {
|
|
14
|
+
describeWhatsAppMessageActions,
|
|
15
|
+
resolveWhatsAppAgentReactionGuidance,
|
|
16
|
+
} from "./channel-actions.js";
|
|
17
|
+
import { whatsappChannelOutbound } from "./channel-outbound.js";
|
|
18
|
+
import { whatsappCommandPolicy } from "./command-policy.js";
|
|
19
|
+
import { formatWhatsAppConfigAllowFromEntries } from "./config-accessors.js";
|
|
20
|
+
import {
|
|
21
|
+
resolveWhatsAppGroupIntroHint,
|
|
22
|
+
resolveWhatsAppMentionStripRegexes,
|
|
23
|
+
} from "./group-intro.js";
|
|
24
|
+
import {
|
|
25
|
+
resolveWhatsAppGroupRequireMention,
|
|
26
|
+
resolveWhatsAppGroupToolPolicy,
|
|
27
|
+
} from "./group-policy.js";
|
|
28
|
+
import { resolveWhatsAppHeartbeatRecipients } from "./heartbeat-recipients.js";
|
|
29
|
+
import { checkWhatsAppHeartbeatReady } from "./heartbeat.js";
|
|
30
|
+
import {
|
|
31
|
+
isWhatsAppGroupJid,
|
|
32
|
+
looksLikeWhatsAppTargetId,
|
|
33
|
+
normalizeWhatsAppMessagingTarget,
|
|
34
|
+
normalizeWhatsAppTarget,
|
|
35
|
+
} from "./normalize.js";
|
|
36
|
+
import { getWhatsAppRuntime } from "./runtime.js";
|
|
37
|
+
import { sendTypingWhatsApp } from "./send.js";
|
|
38
|
+
import { resolveWhatsAppOutboundSessionRoute } from "./session-route.js";
|
|
39
|
+
import { whatsappSetupAdapter } from "./setup-core.js";
|
|
40
|
+
import {
|
|
41
|
+
createWhatsAppPluginBase,
|
|
42
|
+
loadWhatsAppChannelRuntime,
|
|
43
|
+
whatsappSetupWizardProxy,
|
|
44
|
+
} from "./shared.js";
|
|
45
|
+
import { detectWhatsAppLegacyStateMigrations } from "./state-migrations.js";
|
|
46
|
+
import { collectWhatsAppStatusIssues } from "./status-issues.js";
|
|
47
|
+
|
|
48
|
+
const loadWhatsAppDirectoryConfig = createLazyRuntimeModule(() => import("./directory-config.js"));
|
|
49
|
+
const loadWhatsAppChannelReactAction = createLazyRuntimeModule(
|
|
50
|
+
() => import("./channel-react-action.js"),
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
function parseWhatsAppExplicitTarget(raw: string) {
|
|
54
|
+
const normalized = normalizeWhatsAppTarget(raw);
|
|
55
|
+
if (!normalized) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
to: normalized,
|
|
60
|
+
chatType: isWhatsAppGroupJid(normalized) ? ("group" as const) : ("direct" as const),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export const whatsappPlugin: ChannelPlugin<ResolvedWhatsAppAccount> =
|
|
65
|
+
createChatChannelPlugin<ResolvedWhatsAppAccount>({
|
|
66
|
+
pairing: {
|
|
67
|
+
idLabel: "whatsappSenderId",
|
|
68
|
+
},
|
|
69
|
+
outbound: whatsappChannelOutbound,
|
|
70
|
+
threading: {
|
|
71
|
+
scopedAccountReplyToMode: {
|
|
72
|
+
resolveAccount: (cfg, accountId) => resolveWhatsAppAccount({ cfg, accountId }),
|
|
73
|
+
resolveReplyToMode: (account) => account.replyToMode,
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
base: {
|
|
77
|
+
...createWhatsAppPluginBase({
|
|
78
|
+
groups: {
|
|
79
|
+
resolveRequireMention: resolveWhatsAppGroupRequireMention,
|
|
80
|
+
resolveToolPolicy: resolveWhatsAppGroupToolPolicy,
|
|
81
|
+
resolveGroupIntroHint: resolveWhatsAppGroupIntroHint,
|
|
82
|
+
},
|
|
83
|
+
setupWizard: whatsappSetupWizardProxy,
|
|
84
|
+
setup: whatsappSetupAdapter,
|
|
85
|
+
isConfigured: async (account) => {
|
|
86
|
+
const channelRuntime = await loadWhatsAppChannelRuntime();
|
|
87
|
+
return (await channelRuntime.readWebAuthState(account.authDir)) === "linked";
|
|
88
|
+
},
|
|
89
|
+
}),
|
|
90
|
+
agentTools: () => [createWhatsAppLoginTool()],
|
|
91
|
+
allowlist: buildDmGroupAccountAllowlistAdapter({
|
|
92
|
+
channelId: "whatsapp",
|
|
93
|
+
resolveAccount: resolveWhatsAppAccount,
|
|
94
|
+
normalize: ({ values }) => formatWhatsAppConfigAllowFromEntries(values),
|
|
95
|
+
resolveDmAllowFrom: (account) => account.allowFrom,
|
|
96
|
+
resolveGroupAllowFrom: (account) => account.groupAllowFrom,
|
|
97
|
+
resolveDmPolicy: (account) => account.dmPolicy,
|
|
98
|
+
resolveGroupPolicy: (account) => account.groupPolicy,
|
|
99
|
+
}),
|
|
100
|
+
mentions: {
|
|
101
|
+
stripRegexes: ({ ctx }) => resolveWhatsAppMentionStripRegexes(ctx),
|
|
102
|
+
},
|
|
103
|
+
commands: whatsappCommandPolicy,
|
|
104
|
+
agentPrompt: {
|
|
105
|
+
reactionGuidance: ({ cfg, accountId }) => {
|
|
106
|
+
const level = resolveWhatsAppAgentReactionGuidance({
|
|
107
|
+
cfg,
|
|
108
|
+
accountId: accountId ?? undefined,
|
|
109
|
+
});
|
|
110
|
+
return level ? { level, channelLabel: "WhatsApp" } : undefined;
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
messaging: {
|
|
114
|
+
targetPrefixes: ["whatsapp"],
|
|
115
|
+
normalizeTarget: normalizeWhatsAppMessagingTarget,
|
|
116
|
+
resolveOutboundSessionRoute: (params) => resolveWhatsAppOutboundSessionRoute(params),
|
|
117
|
+
parseExplicitTarget: ({ raw }) => parseWhatsAppExplicitTarget(raw),
|
|
118
|
+
inferTargetChatType: ({ to }) => parseWhatsAppExplicitTarget(to)?.chatType,
|
|
119
|
+
targetResolver: {
|
|
120
|
+
looksLikeId: looksLikeWhatsAppTargetId,
|
|
121
|
+
hint: "<E.164|group JID>",
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
directory: {
|
|
125
|
+
self: async ({ cfg, accountId }) => {
|
|
126
|
+
const account = resolveWhatsAppAccount({ cfg, accountId });
|
|
127
|
+
const { e164, jid } = (await loadWhatsAppChannelRuntime()).readWebSelfId(account.authDir);
|
|
128
|
+
const id = e164 ?? jid;
|
|
129
|
+
if (!id) {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
kind: "user",
|
|
134
|
+
id,
|
|
135
|
+
name: account.name,
|
|
136
|
+
raw: { e164, jid },
|
|
137
|
+
};
|
|
138
|
+
},
|
|
139
|
+
listPeers: async (params) =>
|
|
140
|
+
(await loadWhatsAppDirectoryConfig()).listWhatsAppDirectoryPeersFromConfig(params),
|
|
141
|
+
listGroups: async (params) =>
|
|
142
|
+
(await loadWhatsAppDirectoryConfig()).listWhatsAppDirectoryGroupsFromConfig(params),
|
|
143
|
+
},
|
|
144
|
+
actions: {
|
|
145
|
+
describeMessageTool: ({ cfg, accountId }) =>
|
|
146
|
+
describeWhatsAppMessageActions({ cfg, accountId }),
|
|
147
|
+
supportsAction: ({ action }) => action === "react",
|
|
148
|
+
resolveExecutionMode: ({ action }) => (action === "react" ? "gateway" : "local"),
|
|
149
|
+
handleAction: async ({ action, params, cfg, accountId, requesterSenderId, toolContext }) =>
|
|
150
|
+
await (
|
|
151
|
+
await loadWhatsAppChannelReactAction()
|
|
152
|
+
).handleWhatsAppReactAction({
|
|
153
|
+
action,
|
|
154
|
+
params,
|
|
155
|
+
cfg,
|
|
156
|
+
accountId,
|
|
157
|
+
requesterSenderId,
|
|
158
|
+
toolContext,
|
|
159
|
+
}),
|
|
160
|
+
},
|
|
161
|
+
approvalCapability: whatsappApprovalAuth,
|
|
162
|
+
auth: {
|
|
163
|
+
login: async ({ cfg, accountId, runtime, verbose }) => {
|
|
164
|
+
const resolvedAccountId =
|
|
165
|
+
accountId?.trim() ||
|
|
166
|
+
whatsappPlugin.config.defaultAccountId?.(cfg) ||
|
|
167
|
+
DEFAULT_ACCOUNT_ID;
|
|
168
|
+
await (
|
|
169
|
+
await loadWhatsAppChannelRuntime()
|
|
170
|
+
).loginWeb(Boolean(verbose), undefined, runtime, resolvedAccountId);
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
lifecycle: {
|
|
174
|
+
detectLegacyStateMigrations: ({ oauthDir }) =>
|
|
175
|
+
detectWhatsAppLegacyStateMigrations({ oauthDir }),
|
|
176
|
+
},
|
|
177
|
+
heartbeat: {
|
|
178
|
+
checkReady: async ({ cfg, accountId, deps }) =>
|
|
179
|
+
await checkWhatsAppHeartbeatReady({ cfg, accountId: accountId ?? undefined, deps }),
|
|
180
|
+
sendTyping: async ({ cfg, to, accountId }) => {
|
|
181
|
+
await sendTypingWhatsApp(to, {
|
|
182
|
+
cfg,
|
|
183
|
+
...(accountId ? { accountId } : {}),
|
|
184
|
+
});
|
|
185
|
+
},
|
|
186
|
+
resolveRecipients: ({ cfg, opts }) => resolveWhatsAppHeartbeatRecipients(cfg, opts),
|
|
187
|
+
},
|
|
188
|
+
status: createAsyncComputedAccountStatusAdapter<ResolvedWhatsAppAccount>({
|
|
189
|
+
defaultRuntime: createDefaultChannelRuntimeState(DEFAULT_ACCOUNT_ID, {
|
|
190
|
+
connected: false,
|
|
191
|
+
reconnectAttempts: 0,
|
|
192
|
+
lastConnectedAt: null,
|
|
193
|
+
lastDisconnect: null,
|
|
194
|
+
lastInboundAt: null,
|
|
195
|
+
lastMessageAt: null,
|
|
196
|
+
lastEventAt: null,
|
|
197
|
+
healthState: "stopped",
|
|
198
|
+
}),
|
|
199
|
+
collectStatusIssues: collectWhatsAppStatusIssues,
|
|
200
|
+
buildChannelSummary: async ({ account, snapshot }) => {
|
|
201
|
+
const channelRuntime = await loadWhatsAppChannelRuntime();
|
|
202
|
+
const authDir = account.authDir;
|
|
203
|
+
const auth = authDir
|
|
204
|
+
? await channelRuntime.readWebAuthSnapshot(authDir)
|
|
205
|
+
: {
|
|
206
|
+
state: "not-linked" as const,
|
|
207
|
+
authAgeMs: null,
|
|
208
|
+
selfId: { e164: null, jid: null, lid: null },
|
|
209
|
+
};
|
|
210
|
+
const linked =
|
|
211
|
+
typeof snapshot.linked === "boolean"
|
|
212
|
+
? snapshot.linked
|
|
213
|
+
: auth.state === "unstable"
|
|
214
|
+
? undefined
|
|
215
|
+
: auth.state === "linked";
|
|
216
|
+
const summaryAuthState =
|
|
217
|
+
auth.state === "unstable"
|
|
218
|
+
? auth.state
|
|
219
|
+
: linked === true
|
|
220
|
+
? "linked"
|
|
221
|
+
: linked === false
|
|
222
|
+
? "not-linked"
|
|
223
|
+
: undefined;
|
|
224
|
+
const statusState = summaryAuthState === undefined ? undefined : summaryAuthState;
|
|
225
|
+
const configured =
|
|
226
|
+
auth.state === "unstable"
|
|
227
|
+
? typeof snapshot.configured === "boolean"
|
|
228
|
+
? snapshot.configured
|
|
229
|
+
: true
|
|
230
|
+
: typeof linked === "boolean"
|
|
231
|
+
? linked
|
|
232
|
+
: auth.state === "linked";
|
|
233
|
+
const authAgeMs = typeof linked === "boolean" && linked ? auth.authAgeMs : null;
|
|
234
|
+
const self =
|
|
235
|
+
typeof linked === "boolean" && linked
|
|
236
|
+
? auth.selfId
|
|
237
|
+
: { e164: null, jid: null, lid: null };
|
|
238
|
+
return {
|
|
239
|
+
configured,
|
|
240
|
+
...(statusState ? { statusState } : {}),
|
|
241
|
+
...(typeof linked === "boolean" ? { linked } : {}),
|
|
242
|
+
authAgeMs,
|
|
243
|
+
self,
|
|
244
|
+
running: snapshot.running ?? false,
|
|
245
|
+
connected: snapshot.connected ?? false,
|
|
246
|
+
lastConnectedAt: snapshot.lastConnectedAt ?? null,
|
|
247
|
+
lastDisconnect: snapshot.lastDisconnect ?? null,
|
|
248
|
+
reconnectAttempts: snapshot.reconnectAttempts,
|
|
249
|
+
lastInboundAt: snapshot.lastInboundAt ?? snapshot.lastMessageAt ?? null,
|
|
250
|
+
lastMessageAt: snapshot.lastMessageAt ?? null,
|
|
251
|
+
lastEventAt: snapshot.lastEventAt ?? null,
|
|
252
|
+
lastError: snapshot.lastError ?? null,
|
|
253
|
+
healthState: snapshot.healthState ?? undefined,
|
|
254
|
+
};
|
|
255
|
+
},
|
|
256
|
+
resolveAccountSnapshot: async ({ account, runtime }) => {
|
|
257
|
+
const channelRuntime = await loadWhatsAppChannelRuntime();
|
|
258
|
+
const authState = await channelRuntime.readWebAuthState(account.authDir);
|
|
259
|
+
return {
|
|
260
|
+
accountId: account.accountId,
|
|
261
|
+
name: account.name,
|
|
262
|
+
enabled: account.enabled,
|
|
263
|
+
configured: true,
|
|
264
|
+
extra: {
|
|
265
|
+
statusState: authState,
|
|
266
|
+
...(authState === "linked"
|
|
267
|
+
? { linked: true }
|
|
268
|
+
: authState === "not-linked"
|
|
269
|
+
? { linked: false }
|
|
270
|
+
: {}),
|
|
271
|
+
connected: runtime?.connected ?? false,
|
|
272
|
+
reconnectAttempts: runtime?.reconnectAttempts,
|
|
273
|
+
lastConnectedAt: runtime?.lastConnectedAt ?? null,
|
|
274
|
+
lastDisconnect: runtime?.lastDisconnect ?? null,
|
|
275
|
+
lastInboundAt: runtime?.lastInboundAt ?? runtime?.lastMessageAt ?? null,
|
|
276
|
+
lastMessageAt: runtime?.lastMessageAt ?? null,
|
|
277
|
+
lastEventAt: runtime?.lastEventAt ?? null,
|
|
278
|
+
healthState: runtime?.healthState ?? undefined,
|
|
279
|
+
dmPolicy: account.dmPolicy,
|
|
280
|
+
allowFrom: account.allowFrom,
|
|
281
|
+
},
|
|
282
|
+
};
|
|
283
|
+
},
|
|
284
|
+
resolveAccountState: ({ configured }) => (configured ? "linked" : "not linked"),
|
|
285
|
+
logSelfId: ({ account, runtime, includeChannelPrefix }) => {
|
|
286
|
+
void loadWhatsAppChannelRuntime().then((runtimeExports) =>
|
|
287
|
+
runtimeExports.logWebSelfId(account.authDir, runtime, includeChannelPrefix),
|
|
288
|
+
);
|
|
289
|
+
},
|
|
290
|
+
}),
|
|
291
|
+
gateway: {
|
|
292
|
+
startAccount: async (ctx) => {
|
|
293
|
+
const account = ctx.account;
|
|
294
|
+
const { e164, jid } = (await loadWhatsAppChannelRuntime()).readWebSelfId(account.authDir);
|
|
295
|
+
const identity = e164 ? e164 : jid ? `jid ${jid}` : "unknown";
|
|
296
|
+
ctx.log?.info(`[${account.accountId}] starting provider (${identity})`);
|
|
297
|
+
return (await loadWhatsAppChannelRuntime()).monitorWebChannel(
|
|
298
|
+
getWhatsAppRuntime().logging.shouldLogVerbose(),
|
|
299
|
+
undefined,
|
|
300
|
+
true,
|
|
301
|
+
undefined,
|
|
302
|
+
ctx.runtime,
|
|
303
|
+
ctx.abortSignal,
|
|
304
|
+
{
|
|
305
|
+
statusSink: (next: WebChannelStatus) =>
|
|
306
|
+
ctx.setStatus({ accountId: ctx.accountId, ...next }),
|
|
307
|
+
accountId: account.accountId,
|
|
308
|
+
},
|
|
309
|
+
);
|
|
310
|
+
},
|
|
311
|
+
loginWithQrStart: async ({ accountId, force, timeoutMs, verbose }) =>
|
|
312
|
+
await (
|
|
313
|
+
await loadWhatsAppChannelRuntime()
|
|
314
|
+
).startWebLoginWithQr({
|
|
315
|
+
accountId,
|
|
316
|
+
force,
|
|
317
|
+
timeoutMs,
|
|
318
|
+
verbose,
|
|
319
|
+
}),
|
|
320
|
+
loginWithQrWait: async ({ accountId, timeoutMs, currentQrDataUrl }) =>
|
|
321
|
+
await (
|
|
322
|
+
await loadWhatsAppChannelRuntime()
|
|
323
|
+
).waitForWebLogin({ accountId, timeoutMs, currentQrDataUrl }),
|
|
324
|
+
logoutAccount: async ({ account, runtime }) => {
|
|
325
|
+
const cleared = await (
|
|
326
|
+
await loadWhatsAppChannelRuntime()
|
|
327
|
+
).logoutWeb({
|
|
328
|
+
authDir: account.authDir,
|
|
329
|
+
isLegacyAuthDir: account.isLegacyAuthDir,
|
|
330
|
+
runtime,
|
|
331
|
+
});
|
|
332
|
+
return { cleared, loggedOut: cleared };
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
},
|
|
336
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
formatWhatsAppConfigAllowFromEntries,
|
|
4
|
+
resolveWhatsAppConfigAllowFrom,
|
|
5
|
+
resolveWhatsAppConfigDefaultTo,
|
|
6
|
+
} from "./config-accessors.js";
|
|
7
|
+
|
|
8
|
+
describe("whatsapp config accessors", () => {
|
|
9
|
+
it("reads merged allowFrom/defaultTo from resolved account config", () => {
|
|
10
|
+
const cfg = {
|
|
11
|
+
channels: {
|
|
12
|
+
whatsapp: {
|
|
13
|
+
defaultTo: " root:chat ",
|
|
14
|
+
allowFrom: ["+49111"],
|
|
15
|
+
accounts: {
|
|
16
|
+
alt: {
|
|
17
|
+
defaultTo: " alt:chat ",
|
|
18
|
+
allowFrom: ["+49222", "+49333"],
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
expect(resolveWhatsAppConfigAllowFrom({ cfg, accountId: "alt" })).toEqual(["+49222", "+49333"]);
|
|
26
|
+
expect(resolveWhatsAppConfigDefaultTo({ cfg, accountId: "alt" })).toBe("alt:chat");
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("normalizes allowFrom entries like the channel plugin", () => {
|
|
30
|
+
expect(
|
|
31
|
+
formatWhatsAppConfigAllowFromEntries([" whatsapp:+49123 ", "*", "49124@s.whatsapp.net"]),
|
|
32
|
+
).toEqual(["+49123", "*", "+49124"]);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types";
|
|
2
|
+
import { resolveWhatsAppAccount } from "./accounts.js";
|
|
3
|
+
import { normalizeWhatsAppAllowFromEntries } from "./normalize-target.js";
|
|
4
|
+
|
|
5
|
+
export function resolveWhatsAppConfigAllowFrom(params: {
|
|
6
|
+
cfg: OpenClawConfig;
|
|
7
|
+
accountId?: string | null;
|
|
8
|
+
}): string[] {
|
|
9
|
+
return [...(resolveWhatsAppAccount(params).allowFrom ?? [])];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function formatWhatsAppConfigAllowFromEntries(allowFrom: Array<string | number>): string[] {
|
|
13
|
+
return normalizeWhatsAppAllowFromEntries(allowFrom);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function resolveWhatsAppConfigDefaultTo(params: {
|
|
17
|
+
cfg: OpenClawConfig;
|
|
18
|
+
accountId?: string | null;
|
|
19
|
+
}): string | undefined {
|
|
20
|
+
const defaultTo = resolveWhatsAppAccount(params).defaultTo?.trim();
|
|
21
|
+
return defaultTo || undefined;
|
|
22
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { WhatsAppConfigSchema } from "../config-api.js";
|
|
3
|
+
|
|
4
|
+
function expectWhatsAppConfigValid(config: unknown) {
|
|
5
|
+
const res = WhatsAppConfigSchema.safeParse(config);
|
|
6
|
+
expect(res.success).toBe(true);
|
|
7
|
+
return res;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
describe("whatsapp config schema", () => {
|
|
11
|
+
it('rejects dmPolicy="open" without allowFrom "*"', () => {
|
|
12
|
+
const res = WhatsAppConfigSchema.safeParse({
|
|
13
|
+
dmPolicy: "open",
|
|
14
|
+
allowFrom: ["+15555550123"],
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
expect(res.success).toBe(false);
|
|
18
|
+
if (!res.success) {
|
|
19
|
+
expect(res.error.issues[0]?.path.join(".")).toBe("allowFrom");
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('accepts dmPolicy="open" with allowFrom "*"', () => {
|
|
24
|
+
const res = WhatsAppConfigSchema.safeParse({ dmPolicy: "open", allowFrom: ["*"] });
|
|
25
|
+
|
|
26
|
+
expect(res.success).toBe(true);
|
|
27
|
+
if (res.success) {
|
|
28
|
+
expect(res.data.dmPolicy).toBe("open");
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("defaults dm/group policy", () => {
|
|
33
|
+
const res = WhatsAppConfigSchema.safeParse({});
|
|
34
|
+
|
|
35
|
+
expect(res.success).toBe(true);
|
|
36
|
+
if (res.success) {
|
|
37
|
+
expect(res.data.dmPolicy).toBe("pairing");
|
|
38
|
+
expect(res.data.groupPolicy).toBe("allowlist");
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("accepts historyLimit overrides per account", () => {
|
|
43
|
+
const res = WhatsAppConfigSchema.safeParse({
|
|
44
|
+
historyLimit: 9,
|
|
45
|
+
accounts: { work: { historyLimit: 4 } },
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
expect(res.success).toBe(true);
|
|
49
|
+
if (res.success) {
|
|
50
|
+
expect(res.data.historyLimit).toBe(9);
|
|
51
|
+
expect(res.data.accounts?.work?.historyLimit).toBe(4);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("accepts textChunkLimit", () => {
|
|
56
|
+
const res = expectWhatsAppConfigValid({
|
|
57
|
+
allowFrom: ["+15555550123"],
|
|
58
|
+
textChunkLimit: 4444,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
if (res.success) {
|
|
62
|
+
expect(res.data.textChunkLimit).toBe(4444);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("accepts enabled", () => {
|
|
67
|
+
expectWhatsAppConfigValid({
|
|
68
|
+
enabled: true,
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("keeps inherited account defaults unset at account scope", () => {
|
|
73
|
+
const res = expectWhatsAppConfigValid({
|
|
74
|
+
dmPolicy: "allowlist",
|
|
75
|
+
groupPolicy: "open",
|
|
76
|
+
debounceMs: 250,
|
|
77
|
+
allowFrom: ["+15550001111"],
|
|
78
|
+
accounts: {
|
|
79
|
+
work: {
|
|
80
|
+
allowFrom: ["+15550002222"],
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
if (!res.success) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
expect(res.data.dmPolicy).toBe("allowlist");
|
|
89
|
+
expect(res.data.groupPolicy).toBe("open");
|
|
90
|
+
expect(res.data.debounceMs).toBe(250);
|
|
91
|
+
expect(res.data.accounts?.work?.dmPolicy).toBeUndefined();
|
|
92
|
+
expect(res.data.accounts?.work?.groupPolicy).toBeUndefined();
|
|
93
|
+
expect(res.data.accounts?.work?.debounceMs).toBeUndefined();
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it("accepts allowlist accounts inheriting allowFrom from accounts.default", () => {
|
|
97
|
+
expectWhatsAppConfigValid({
|
|
98
|
+
accounts: {
|
|
99
|
+
default: {
|
|
100
|
+
allowFrom: ["+15550001111"],
|
|
101
|
+
},
|
|
102
|
+
work: {
|
|
103
|
+
dmPolicy: "allowlist",
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it("accepts allowlist accounts inheriting allowFrom from mixed-case accounts.Default", () => {
|
|
110
|
+
expectWhatsAppConfigValid({
|
|
111
|
+
accounts: {
|
|
112
|
+
Default: {
|
|
113
|
+
allowFrom: ["+15550001111"],
|
|
114
|
+
},
|
|
115
|
+
work: {
|
|
116
|
+
dmPolicy: "allowlist",
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { buildChannelConfigSchema, WhatsAppConfigSchema } from "../config-api.js";
|
|
2
|
+
import { whatsAppChannelConfigUiHints } from "./config-ui-hints.js";
|
|
3
|
+
|
|
4
|
+
export const WhatsAppChannelConfigSchema = buildChannelConfigSchema(WhatsAppConfigSchema, {
|
|
5
|
+
uiHints: whatsAppChannelConfigUiHints,
|
|
6
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ChannelConfigUiHint } from "openclaw/plugin-sdk/core";
|
|
2
|
+
|
|
3
|
+
export const whatsAppChannelConfigUiHints = {
|
|
4
|
+
"": {
|
|
5
|
+
label: "WhatsApp",
|
|
6
|
+
help: "WhatsApp channel provider configuration for access policy and message batching behavior. Use this section to tune responsiveness and direct-message routing safety for WhatsApp chats.",
|
|
7
|
+
},
|
|
8
|
+
dmPolicy: {
|
|
9
|
+
label: "WhatsApp DM Policy",
|
|
10
|
+
help: 'Direct message access control ("pairing" recommended). "open" requires channels.whatsapp.allowFrom=["*"].',
|
|
11
|
+
},
|
|
12
|
+
selfChatMode: {
|
|
13
|
+
label: "WhatsApp Self-Phone Mode",
|
|
14
|
+
help: "Same-phone setup (bot uses your personal WhatsApp number).",
|
|
15
|
+
},
|
|
16
|
+
debounceMs: {
|
|
17
|
+
label: "WhatsApp Message Debounce (ms)",
|
|
18
|
+
help: "Debounce window (ms) for batching rapid consecutive messages from the same sender (0 to disable).",
|
|
19
|
+
},
|
|
20
|
+
configWrites: {
|
|
21
|
+
label: "WhatsApp Config Writes",
|
|
22
|
+
help: "Allow WhatsApp to write config in response to channel events/commands (default: true).",
|
|
23
|
+
},
|
|
24
|
+
} satisfies Record<string, ChannelConfigUiHint>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
|
|
3
|
+
type RegistryModule = typeof import("./connection-controller-registry.js");
|
|
4
|
+
|
|
5
|
+
const registryModuleUrl = new URL("./connection-controller-registry.ts", import.meta.url).href;
|
|
6
|
+
|
|
7
|
+
async function importRegistryModule(cacheBust: string): Promise<RegistryModule> {
|
|
8
|
+
return (await import(`${registryModuleUrl}?t=${cacheBust}`)) as RegistryModule;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
describe("WhatsApp connection controller registry", () => {
|
|
12
|
+
it("shares registered controllers across duplicate module instances", async () => {
|
|
13
|
+
const first = await importRegistryModule(`first-${Date.now()}`);
|
|
14
|
+
const second = await importRegistryModule(`second-${Date.now()}`);
|
|
15
|
+
const controller = {
|
|
16
|
+
getActiveListener: vi.fn(() => null),
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
first.registerWhatsAppConnectionController("work", controller);
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
expect(second.getRegisteredWhatsAppConnectionController("work")).toBe(controller);
|
|
23
|
+
} finally {
|
|
24
|
+
first.unregisterWhatsAppConnectionController("work", controller);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { ActiveWebListener } from "./inbound/types.js";
|
|
2
|
+
|
|
3
|
+
type WhatsAppConnectionControllerHandle = {
|
|
4
|
+
getActiveListener(): ActiveWebListener | null;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
type ConnectionRegistryState = {
|
|
8
|
+
controllers: Map<string, WhatsAppConnectionControllerHandle>;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const CONNECTION_REGISTRY_KEY = Symbol.for("openclaw.whatsapp.connectionControllerRegistry");
|
|
12
|
+
|
|
13
|
+
function getConnectionRegistryState(): ConnectionRegistryState {
|
|
14
|
+
const globalState = globalThis as typeof globalThis & {
|
|
15
|
+
[CONNECTION_REGISTRY_KEY]?: ConnectionRegistryState;
|
|
16
|
+
};
|
|
17
|
+
const existing = globalState[CONNECTION_REGISTRY_KEY];
|
|
18
|
+
if (existing) {
|
|
19
|
+
return existing;
|
|
20
|
+
}
|
|
21
|
+
const created: ConnectionRegistryState = {
|
|
22
|
+
controllers: new Map<string, WhatsAppConnectionControllerHandle>(),
|
|
23
|
+
};
|
|
24
|
+
globalState[CONNECTION_REGISTRY_KEY] = created;
|
|
25
|
+
return created;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function getRegisteredWhatsAppConnectionController(
|
|
29
|
+
accountId: string,
|
|
30
|
+
): WhatsAppConnectionControllerHandle | null {
|
|
31
|
+
return getConnectionRegistryState().controllers.get(accountId) ?? null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function registerWhatsAppConnectionController(
|
|
35
|
+
accountId: string,
|
|
36
|
+
controller: WhatsAppConnectionControllerHandle,
|
|
37
|
+
): void {
|
|
38
|
+
getConnectionRegistryState().controllers.set(accountId, controller);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function unregisterWhatsAppConnectionController(
|
|
42
|
+
accountId: string,
|
|
43
|
+
controller: WhatsAppConnectionControllerHandle,
|
|
44
|
+
): void {
|
|
45
|
+
const controllers = getConnectionRegistryState().controllers;
|
|
46
|
+
if (controllers.get(accountId) === controller) {
|
|
47
|
+
controllers.delete(accountId);
|
|
48
|
+
}
|
|
49
|
+
}
|