@openclaw/whatsapp 2026.5.10-beta.2 → 2026.5.10-beta.4
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-CdP8S3rJ.js → access-control-BEpPB-Jx.js} +6 -6
- package/dist/{accounts-BDqgpFEB.js → accounts-B4oR6Dhx.js} +1 -1
- package/dist/action-runtime-api.js +1 -1
- package/dist/{action-runtime-CMhO8liB.js → action-runtime-lppOTCTN.js} +4 -4
- package/dist/action-runtime.runtime.js +1 -1
- package/dist/api.js +18 -145
- package/dist/{auth-store-CjEimXKX.js → auth-store-_ScMvp7r.js} +10 -10
- package/dist/{channel-BxntAClG.js → channel-D8JseTzy.js} +18 -18
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel-react-action-DJvzhIPw.js → channel-react-action-C1wufQtL.js} +3 -3
- package/dist/{channel.runtime-CNdPCK3G.js → channel.runtime-BHVFPFlu.js} +5 -5
- package/dist/{channel.setup-BqlcEVzR.js → channel.setup-BuK8IaLl.js} +4 -4
- package/dist/{connection-controller-DX2phM7V.js → connection-controller-Ik54eV0p.js} +7 -6
- package/dist/constants.js +1 -1
- package/dist/contract-api.js +8 -8
- package/dist/{directory-config-o-muXLgk.js → directory-config-CE74HYlw.js} +3 -3
- package/dist/directory-contract-api.js +1 -1
- package/dist/doctor-contract-api.js +1 -1
- package/dist/{group-session-contract-DL-SLclv.js → group-session-contract-DdqigLJl.js} +1 -1
- package/dist/{identity-KxdJfH7p.js → identity-BNDkpR8N.js} +2 -2
- package/dist/legacy-session-surface-api.js +1 -1
- package/dist/legacy-state-migrations-api.js +1 -1
- package/dist/light-runtime-api.js +3 -3
- package/dist/{login-DV99D0IN.js → login-eiyCwLI5.js} +6 -6
- package/dist/{login-qr-cKndAXTv.js → login-qr-CSEa1_wH.js} +5 -5
- package/dist/login-qr-runtime.js +1 -1
- package/dist/{monitor-mfy3Mmq-.js → monitor-BUZiKfTw.js} +139 -72
- package/dist/normalize-f31evwm8.js +2 -0
- package/dist/{normalize-target-nXxC_hxG.js → normalize-target-ePanEpfY.js} +1 -1
- package/dist/{outbound-adapter-B9ZW8sht.js → outbound-adapter-Bs0e4qVd.js} +4 -4
- package/dist/{outbound-base-MVpg2zU2.js → outbound-base-BgtywpNm.js} +3 -3
- package/dist/{outbound-media-contract-BzWwBppP.js → outbound-media-contract-zq9aNgT8.js} +5 -5
- package/dist/outbound-payload-test-api.js +1 -1
- package/dist/{quoted-message-DQ6hAr34.js → quoted-message-BQsRXnac.js} +1 -1
- package/dist/{reaction-level-CRVEVAfi.js → reaction-level-2m9sWGCw.js} +1 -1
- package/dist/{resolve-outbound-target-CQ3Y1i0g.js → resolve-outbound-target-BKcv4ofn.js} +1 -1
- package/dist/rolldown-runtime-CiIaOW0V.js +13 -0
- package/dist/runtime-api.js +11 -11
- package/dist/{security-contract-BzlZFreO.js → security-contract-CvfWex9e.js} +1 -1
- package/dist/security-contract-api.js +1 -1
- package/dist/{send-u88yh8Hw.js → send-DBfXQDd4.js} +10 -9
- package/dist/{send-api-DsbCqDre.js → send-api-DD93aPIQ.js} +7 -7
- package/dist/{session-DeIU_vjJ.js → session-CVCKPoQN.js} +6 -6
- package/dist/{session.runtime-B9VlYnWQ.js → session.runtime-CZQ0ycCg.js} +2 -2
- package/dist/{setup-finalize-D3YuMUBs.js → setup-finalize-WYnZjedw.js} +4 -4
- package/dist/setup-plugin-api.js +1 -1
- package/dist/{setup-surface-CHjYlKJc.js → setup-surface-DJAu-uxi.js} +3 -3
- package/dist/{shared-CgYT3IzU.js → shared-Ihk-Sj__.js} +9 -9
- package/dist/targets.js +1 -1
- package/dist/test-api.js +2 -2
- package/dist/{text-runtime-DBKC9uEi.js → text-runtime-CMxQczvs.js} +4 -42
- package/package.json +5 -5
- package/dist/normalize-Y3eBdM8a.js +0 -2
- /package/dist/{active-listener-D2NHQ5Og.js → active-listener-DTbKS-j-.js} +0 -0
- /package/dist/{agent-tools-login-DYKYW5Nh.js → agent-tools-login-DpRxLNRB.js} +0 -0
- /package/dist/{audio-preflight.runtime-CIFjeaEN.js → audio-preflight.runtime-MmkB-pgX.js} +0 -0
- /package/dist/{command-policy-BgZRZ31o.js → command-policy-O8sRnqUV.js} +0 -0
- /package/dist/{config-schema-cSC7M4YA.js → config-schema-Dmo66Ubb.js} +0 -0
- /package/dist/{constants-yKXGCGU9.js → constants-DLGCIbfl.js} +0 -0
- /package/dist/{doctor-BrgepDUP.js → doctor-A9tXm9Om.js} +0 -0
- /package/dist/{reply-resolver.runtime-CROyXXQh.js → reply-resolver.runtime-rIVWohXr.js} +0 -0
- /package/dist/{runtime-DdodQB8G.js → runtime-6fZ67abR.js} +0 -0
- /package/dist/{runtime-group-policy-BH_U23qp.js → runtime-group-policy-Gp1lQ0at.js} +0 -0
- /package/dist/{session-contract-BNUscPf4.js → session-contract-B0efQf9P.js} +0 -0
- /package/dist/{setup-core-DnhO0PjG.js → setup-core-DZKvpzbH.js} +0 -0
- /package/dist/{state-migrations-CtdIArlK.js → state-migrations-Bm0S67yH.js} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as resolveWhatsAppAccount } from "./accounts-
|
|
2
|
-
import { d as readWebAuthExistsForDecision, h as readWebSelfId, n as WHATSAPP_AUTH_UNSTABLE_CODE } from "./auth-store-
|
|
3
|
-
import { i as resolveWhatsAppSocketTiming, t as createWaSocket } from "./session-
|
|
4
|
-
import {
|
|
5
|
-
import { logInfo } from "openclaw/plugin-sdk/
|
|
1
|
+
import { a as resolveWhatsAppAccount } from "./accounts-B4oR6Dhx.js";
|
|
2
|
+
import { d as readWebAuthExistsForDecision, h as readWebSelfId, n as WHATSAPP_AUTH_UNSTABLE_CODE } from "./auth-store-_ScMvp7r.js";
|
|
3
|
+
import { i as resolveWhatsAppSocketTiming, t as createWaSocket } from "./session-CVCKPoQN.js";
|
|
4
|
+
import { i as closeWaSocket, o as waitForWhatsAppLoginResult, t as WHATSAPP_LOGGED_OUT_QR_MESSAGE } from "./connection-controller-Ik54eV0p.js";
|
|
5
|
+
import { logInfo } from "openclaw/plugin-sdk/logging-core";
|
|
6
6
|
import { danger, defaultRuntime, info, success } from "openclaw/plugin-sdk/runtime-env";
|
|
7
7
|
import { renderQrPngDataUrl } from "openclaw/plugin-sdk/media-runtime";
|
|
8
8
|
import { randomUUID } from "node:crypto";
|
package/dist/login-qr-runtime.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//#region extensions/whatsapp/login-qr-runtime.ts
|
|
2
2
|
let loginQrModulePromise = null;
|
|
3
3
|
function loadLoginQrModule() {
|
|
4
|
-
loginQrModulePromise ??= import("./login-qr-
|
|
4
|
+
loginQrModulePromise ??= import("./login-qr-CSEa1_wH.js");
|
|
5
5
|
return loginQrModulePromise;
|
|
6
6
|
}
|
|
7
7
|
async function startWebLoginWithQr(...args) {
|
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import {
|
|
3
|
-
import { t as
|
|
4
|
-
import { t as resolveWhatsAppReactionLevel } from "./reaction-level-CRVEVAfi.js";
|
|
1
|
+
import { a as resolveWhatsAppAccount, s as resolveWhatsAppMediaMaxBytes } from "./accounts-B4oR6Dhx.js";
|
|
2
|
+
import { t as isWhatsAppGroupJid } from "./normalize-target-ePanEpfY.js";
|
|
3
|
+
import { t as resolveWhatsAppReactionLevel } from "./reaction-level-2m9sWGCw.js";
|
|
5
4
|
import { n as getStatusCode, t as formatError } from "./session-errors-CSuKZPub.js";
|
|
6
|
-
import {
|
|
7
|
-
import { r as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { i as
|
|
12
|
-
import {
|
|
13
|
-
import { i as
|
|
14
|
-
import {
|
|
5
|
+
import { d as markdownToWhatsApp, f as resolveJidToE164, l as isSelfChatMode, n as normalizeE164, t as convertMarkdownTables$1, u as jidToE164 } from "./text-runtime-CMxQczvs.js";
|
|
6
|
+
import { i as prepareWhatsAppOutboundMedia, o as sendWhatsAppOutboundWithRetry, r as normalizeWhatsAppPayloadTextPreservingIndentation, t as normalizeWhatsAppOutboundPayload } from "./outbound-media-contract-zq9aNgT8.js";
|
|
7
|
+
import { r as sendReactionWhatsApp } from "./send-DBfXQDd4.js";
|
|
8
|
+
import { n as cacheInboundMessageMeta, r as lookupInboundMessageMeta, t as buildQuotedMessageOptions } from "./quoted-message-BQsRXnac.js";
|
|
9
|
+
import { _ as readWebSelfIdentityForDecision, a as getWebAuthAgeMs, h as readWebSelfId, r as WhatsAppAuthUnstableError, s as logoutWeb } from "./auth-store-_ScMvp7r.js";
|
|
10
|
+
import { a as getSelfIdentity, c as resolveComparableIdentity, i as getReplyContext, n as getMentionIdentities, o as getSenderIdentity, r as getPrimaryIdentityId, s as identitiesOverlap, t as getComparableIdentityValues } from "./identity-BNDkpR8N.js";
|
|
11
|
+
import { i as resolveWhatsAppInboundPolicy, n as checkInboundAccessControl, r as resolveWhatsAppCommandAuthorized } from "./access-control-BEpPB-Jx.js";
|
|
12
|
+
import { a as mayContainWhatsAppOutboundMention, c as extractContactContext, d as extractMediaPlaceholder, f as extractMentionedJids, i as addWhatsAppOutboundMentionsToContent, l as extractContextInfo, m as hasInboundUserContent, n as listWhatsAppSendResultMessageIds, o as resolveWhatsAppOutboundMentions, p as extractText, r as normalizeWhatsAppSendResult, s as describeReplyContext, t as createWebSendApi, u as extractLocationData } from "./send-api-DD93aPIQ.js";
|
|
13
|
+
import { i as resolveWhatsAppSocketTiming, r as waitForWaConnection, t as createWaSocket } from "./session-CVCKPoQN.js";
|
|
14
|
+
import { c as computeBackoff, d as resolveReconnectPolicy, f as sleepWithAbort, l as newConnectionId, n as WHATSAPP_WATCHDOG_TIMEOUT_ERROR, r as WhatsAppConnectionController, s as DEFAULT_RECONNECT_POLICY, u as resolveHeartbeatSeconds } from "./connection-controller-Ik54eV0p.js";
|
|
15
15
|
import { resolveAccountEntry } from "openclaw/plugin-sdk/account-core";
|
|
16
|
-
import {
|
|
16
|
+
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
17
17
|
import { createAckReactionHandle, logAckFailure, removeAckReactionHandleAfterReply, shouldAckReactionForWhatsApp } from "openclaw/plugin-sdk/channel-feedback";
|
|
18
18
|
import { formatCliCommand } from "openclaw/plugin-sdk/cli-runtime";
|
|
19
|
+
import { getChildLogger } from "openclaw/plugin-sdk/logging-core";
|
|
19
20
|
import { resolveMarkdownTableMode as resolveMarkdownTableMode$1 } from "openclaw/plugin-sdk/markdown-table-runtime";
|
|
20
|
-
import { createSubsystemLogger, defaultRuntime, formatDurationPrecise, getChildLogger as getChildLogger$1, logVerbose, logVerbose as logVerbose$1, registerUnhandledRejectionHandler, shouldLogVerbose, shouldLogVerbose as shouldLogVerbose$1 } from "openclaw/plugin-sdk/runtime-env";
|
|
21
|
+
import { createSubsystemLogger, defaultRuntime, formatDurationPrecise, getChildLogger as getChildLogger$1, logVerbose, logVerbose as logVerbose$1, registerUnhandledRejectionHandler, shouldLogVerbose, shouldLogVerbose as shouldLogVerbose$1, warn } from "openclaw/plugin-sdk/runtime-env";
|
|
21
22
|
import { getAgentScopedMediaLocalRoots } from "openclaw/plugin-sdk/media-runtime";
|
|
22
23
|
import { evaluateSupplementalContextVisibility, filterSupplementalContextItems, resolvePinnedMainDmOwnerFromAllowlist } from "openclaw/plugin-sdk/security-runtime";
|
|
23
24
|
import { LocalMediaAccessError, getDefaultLocalRoots, loadWebMedia as loadWebMedia$1, loadWebMediaRaw, optimizeImageToJpeg, optimizeImageToPng } from "openclaw/plugin-sdk/web-media";
|
|
@@ -27,7 +28,7 @@ import { isReasoningReplyPayload, resolveSendableOutboundReplyParts, sendMediaWi
|
|
|
27
28
|
import { DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID$1, DEFAULT_MAIN_KEY, buildAgentMainSessionKey, buildAgentSessionKey, buildGroupHistoryKey, deriveLastRoutePolicy, normalizeAccountId as normalizeAccountId$1, normalizeAgentId, resolveAgentRoute, resolveInboundLastRouteSessionKey, resolveThreadSessionKeys } from "openclaw/plugin-sdk/routing";
|
|
28
29
|
import { recordInboundSession } from "openclaw/plugin-sdk/conversation-runtime";
|
|
29
30
|
import { loadSessionStore, resolveStorePath, updateLastRoute, updateSessionStore } from "openclaw/plugin-sdk/session-store-runtime";
|
|
30
|
-
import { DisconnectReason as DisconnectReason$1, downloadMediaMessage, isJidGroup, normalizeMessageContent as normalizeMessageContent$1 } from "
|
|
31
|
+
import { DisconnectReason as DisconnectReason$1, downloadMediaMessage, isJidGroup, normalizeMessageContent as normalizeMessageContent$1 } from "baileys";
|
|
31
32
|
import { formatLocationText, resolveInboundSessionEnvelopeContext } from "openclaw/plugin-sdk/channel-inbound";
|
|
32
33
|
import { recordChannelActivity } from "openclaw/plugin-sdk/channel-activity-runtime";
|
|
33
34
|
import { dispatchReplyWithBufferedBlockDispatcher, finalizeInboundContext, resolveChunkMode, resolveTextChunkLimit } from "openclaw/plugin-sdk/reply-runtime";
|
|
@@ -481,7 +482,7 @@ async function attachWebInboxToSocket(options) {
|
|
|
481
482
|
}
|
|
482
483
|
const messageTimestampMs = msg.messageTimestamp ? Number(msg.messageTimestamp) * 1e3 : void 0;
|
|
483
484
|
const access = await checkInboundAccessControl({
|
|
484
|
-
cfg: options.cfg,
|
|
485
|
+
cfg: options.loadConfig?.() ?? options.cfg,
|
|
485
486
|
accountId: options.accountId,
|
|
486
487
|
from,
|
|
487
488
|
selfE164: self.e164 ?? null,
|
|
@@ -817,7 +818,7 @@ function debugMention(msg, mentionCfg, authDir) {
|
|
|
817
818
|
}
|
|
818
819
|
function resolveOwnerList(mentionCfg, selfE164) {
|
|
819
820
|
const allowFrom = mentionCfg.allowFrom;
|
|
820
|
-
return (Array.isArray(allowFrom) && allowFrom.length > 0 ? allowFrom : selfE164 ? [selfE164] : []).filter((entry) => Boolean(entry && entry !== "*")).map((entry) =>
|
|
821
|
+
return (Array.isArray(allowFrom) && allowFrom.length > 0 ? allowFrom : selfE164 ? [selfE164] : []).filter((entry) => Boolean(entry && entry !== "*")).map((entry) => normalizeE164(entry)).filter((entry) => Boolean(entry));
|
|
821
822
|
}
|
|
822
823
|
//#endregion
|
|
823
824
|
//#region extensions/whatsapp/src/auto-reply/monitor-state.ts
|
|
@@ -831,6 +832,7 @@ function isTerminalHealthState(healthState) {
|
|
|
831
832
|
return healthState === "conflict" || healthState === "logged-out" || healthState === "stopped";
|
|
832
833
|
}
|
|
833
834
|
function createWebChannelStatusController(statusSink) {
|
|
835
|
+
let lastDisconnectWasWatchdogRecovery = false;
|
|
834
836
|
const status = {
|
|
835
837
|
running: true,
|
|
836
838
|
connected: false,
|
|
@@ -852,6 +854,11 @@ function createWebChannelStatusController(statusSink) {
|
|
|
852
854
|
noteConnected(at = Date.now()) {
|
|
853
855
|
Object.assign(status, createConnectedChannelStatusPatch(at));
|
|
854
856
|
Object.assign(status, createTransportActivityStatusPatch(at));
|
|
857
|
+
if (lastDisconnectWasWatchdogRecovery) {
|
|
858
|
+
status.lastDisconnect = null;
|
|
859
|
+
status.reconnectAttempts = 0;
|
|
860
|
+
lastDisconnectWasWatchdogRecovery = false;
|
|
861
|
+
}
|
|
855
862
|
status.lastError = null;
|
|
856
863
|
status.healthState = "healthy";
|
|
857
864
|
emit();
|
|
@@ -880,6 +887,7 @@ function createWebChannelStatusController(statusSink) {
|
|
|
880
887
|
},
|
|
881
888
|
noteClose(params) {
|
|
882
889
|
const at = params.at ?? Date.now();
|
|
890
|
+
lastDisconnectWasWatchdogRecovery = params.watchdogRecovery === true;
|
|
883
891
|
status.connected = false;
|
|
884
892
|
status.lastEventAt = at;
|
|
885
893
|
status.lastDisconnect = {
|
|
@@ -1137,7 +1145,7 @@ function stripMentionsForCommand(text, mentionRegexes, selfE164) {
|
|
|
1137
1145
|
//#region extensions/whatsapp/src/auto-reply/monitor/group-members.ts
|
|
1138
1146
|
function appendNormalizedUnique(entries, seen, ordered) {
|
|
1139
1147
|
for (const entry of entries) {
|
|
1140
|
-
const normalized =
|
|
1148
|
+
const normalized = normalizeE164(entry) ?? entry;
|
|
1141
1149
|
if (!normalized || seen.has(normalized)) continue;
|
|
1142
1150
|
seen.add(normalized);
|
|
1143
1151
|
ordered.push(normalized);
|
|
@@ -1145,7 +1153,7 @@ function appendNormalizedUnique(entries, seen, ordered) {
|
|
|
1145
1153
|
}
|
|
1146
1154
|
function noteGroupMember(groupMemberNames, conversationId, e164, name) {
|
|
1147
1155
|
if (!e164 || !name) return;
|
|
1148
|
-
const key =
|
|
1156
|
+
const key = normalizeE164(e164) ?? e164;
|
|
1149
1157
|
if (!key) return;
|
|
1150
1158
|
let roster = groupMemberNames.get(conversationId);
|
|
1151
1159
|
if (!roster) {
|
|
@@ -1161,7 +1169,7 @@ function formatGroupMembers(params) {
|
|
|
1161
1169
|
if (participants?.length) appendNormalizedUnique(participants, seen, ordered);
|
|
1162
1170
|
if (roster) appendNormalizedUnique(roster.keys(), seen, ordered);
|
|
1163
1171
|
if (ordered.length === 0 && fallbackE164) {
|
|
1164
|
-
const normalized =
|
|
1172
|
+
const normalized = normalizeE164(fallbackE164) ?? fallbackE164;
|
|
1165
1173
|
if (normalized) ordered.push(normalized);
|
|
1166
1174
|
}
|
|
1167
1175
|
if (ordered.length === 0) return;
|
|
@@ -1173,7 +1181,7 @@ function formatGroupMembers(params) {
|
|
|
1173
1181
|
//#endregion
|
|
1174
1182
|
//#region extensions/whatsapp/src/auto-reply/monitor/group-gating.ts
|
|
1175
1183
|
function isOwnerSender(baseMentionConfig, msg) {
|
|
1176
|
-
const sender =
|
|
1184
|
+
const sender = normalizeE164(getSenderIdentity(msg).e164 ?? "");
|
|
1177
1185
|
if (!sender) return false;
|
|
1178
1186
|
return resolveOwnerList(baseMentionConfig, getSelfIdentity(msg).e164 ?? void 0).includes(sender);
|
|
1179
1187
|
}
|
|
@@ -1313,9 +1321,9 @@ function updateLastRouteInBackground(params) {
|
|
|
1313
1321
|
function resolvePeerId(msg) {
|
|
1314
1322
|
if (msg.chatType === "group") return msg.conversationId ?? msg.from;
|
|
1315
1323
|
const sender = getSenderIdentity(msg);
|
|
1316
|
-
if (sender.e164) return
|
|
1324
|
+
if (sender.e164) return normalizeE164(sender.e164) ?? sender.e164;
|
|
1317
1325
|
if (msg.from.includes("@")) return jidToE164(msg.from) ?? msg.from;
|
|
1318
|
-
return
|
|
1326
|
+
return normalizeE164(msg.from) ?? msg.from;
|
|
1319
1327
|
}
|
|
1320
1328
|
//#endregion
|
|
1321
1329
|
//#region extensions/whatsapp/src/system-prompt.ts
|
|
@@ -1361,7 +1369,7 @@ function isLikelyWhatsAppCryptoError(reason) {
|
|
|
1361
1369
|
};
|
|
1362
1370
|
const haystack = normalizeLowercaseStringOrEmpty(reason instanceof Error ? `${reason.message}\n${reason.stack ?? ""}` : formatReason(reason));
|
|
1363
1371
|
if (!(haystack.includes("unsupported state or unable to authenticate data") || haystack.includes("bad mac"))) return false;
|
|
1364
|
-
return haystack.includes("
|
|
1372
|
+
return haystack.includes("baileys") || haystack.includes("noise-handler") || haystack.includes("aesdecryptgcm");
|
|
1365
1373
|
}
|
|
1366
1374
|
//#endregion
|
|
1367
1375
|
//#region extensions/whatsapp/src/auto-reply/deliver-reply.ts
|
|
@@ -1422,7 +1430,7 @@ async function deliverWebReply(params) {
|
|
|
1422
1430
|
const tableMode = params.tableMode ?? "code";
|
|
1423
1431
|
const chunkMode = params.chunkMode ?? "length";
|
|
1424
1432
|
const normalizedReply = params.normalizedReplyResult ?? normalizeWhatsAppOutboundPayload(replyResult, { normalizeText: normalizeWhatsAppPayloadTextPreservingIndentation });
|
|
1425
|
-
const textChunks = chunkMarkdownTextWithMode(markdownToWhatsApp(
|
|
1433
|
+
const textChunks = chunkMarkdownTextWithMode(markdownToWhatsApp(convertMarkdownTables$1(normalizedReply.text ?? "", tableMode)), textLimit, chunkMode);
|
|
1426
1434
|
const mediaList = normalizedReply.mediaUrls ?? [];
|
|
1427
1435
|
const getQuote = () => {
|
|
1428
1436
|
if (!replyResult.replyToId) return;
|
|
@@ -1553,7 +1561,7 @@ function isWhatsAppSupplementalSenderAllowed(params) {
|
|
|
1553
1561
|
for (const entry of params.allowFrom) {
|
|
1554
1562
|
const rawEntry = entry.trim();
|
|
1555
1563
|
if (!rawEntry) continue;
|
|
1556
|
-
const normalizedEntry =
|
|
1564
|
+
const normalizedEntry = normalizeE164(rawEntry);
|
|
1557
1565
|
if (normalizedEntry && senderValues.has(normalizedEntry) || senderValues.has(rawEntry)) return true;
|
|
1558
1566
|
}
|
|
1559
1567
|
return false;
|
|
@@ -1978,7 +1986,7 @@ function resolvePinnedMainDmRecipient(params) {
|
|
|
1978
1986
|
return resolvePinnedMainDmOwnerFromAllowlist({
|
|
1979
1987
|
dmScope: params.cfg.session?.dmScope,
|
|
1980
1988
|
allowFrom: params.allowFrom,
|
|
1981
|
-
normalizeEntry: (entry) =>
|
|
1989
|
+
normalizeEntry: (entry) => normalizeE164(entry)
|
|
1982
1990
|
});
|
|
1983
1991
|
}
|
|
1984
1992
|
async function processMessage(params) {
|
|
@@ -2003,7 +2011,7 @@ async function processMessage(params) {
|
|
|
2003
2011
|
let audioTranscript = params.preflightAudioTranscript ?? void 0;
|
|
2004
2012
|
const hasAudioBody = params.msg.mediaType?.startsWith("audio/") === true && params.msg.body === "<media:audio>";
|
|
2005
2013
|
if (params.preflightAudioTranscript === void 0 && hasAudioBody && params.msg.mediaPath) try {
|
|
2006
|
-
const { transcribeFirstAudio } = await import("./audio-preflight.runtime-
|
|
2014
|
+
const { transcribeFirstAudio } = await import("./audio-preflight.runtime-MmkB-pgX.js");
|
|
2007
2015
|
audioTranscript = await transcribeFirstAudio({
|
|
2008
2016
|
ctx: {
|
|
2009
2017
|
MediaPaths: [params.msg.mediaPath],
|
|
@@ -2109,7 +2117,7 @@ async function processMessage(params) {
|
|
|
2109
2117
|
const dmRouteTarget = resolveWhatsAppDmRouteTarget({
|
|
2110
2118
|
msg: params.msg,
|
|
2111
2119
|
senderE164: sender.e164 ?? void 0,
|
|
2112
|
-
normalizeE164
|
|
2120
|
+
normalizeE164
|
|
2113
2121
|
});
|
|
2114
2122
|
const commandAuthorized = shouldComputeCommandAuthorized(params.msg.body, params.cfg) ? await resolveWhatsAppCommandAuthorized({
|
|
2115
2123
|
cfg: params.cfg,
|
|
@@ -2253,9 +2261,9 @@ async function processMessage(params) {
|
|
|
2253
2261
|
//#endregion
|
|
2254
2262
|
//#region extensions/whatsapp/src/auto-reply/monitor/on-message.ts
|
|
2255
2263
|
function createWebOnMessageHandler(params) {
|
|
2256
|
-
const processForRoute = async (msg, route, groupHistoryKey, opts) => {
|
|
2264
|
+
const processForRoute = async (cfg, msg, route, groupHistoryKey, opts) => {
|
|
2257
2265
|
const processParams = {
|
|
2258
|
-
cfg
|
|
2266
|
+
cfg,
|
|
2259
2267
|
msg,
|
|
2260
2268
|
route,
|
|
2261
2269
|
groupHistoryKey,
|
|
@@ -2280,10 +2288,11 @@ function createWebOnMessageHandler(params) {
|
|
|
2280
2288
|
return processMessage(processParams);
|
|
2281
2289
|
};
|
|
2282
2290
|
return async (msg) => {
|
|
2291
|
+
const cfg = params.loadConfig?.() ?? params.cfg;
|
|
2283
2292
|
const conversationId = msg.conversationId ?? msg.from;
|
|
2284
2293
|
const peerId = resolvePeerId(msg);
|
|
2285
2294
|
const baseRoute = resolveAgentRoute({
|
|
2286
|
-
cfg
|
|
2295
|
+
cfg,
|
|
2287
2296
|
channel: "whatsapp",
|
|
2288
2297
|
accountId: msg.accountId,
|
|
2289
2298
|
peer: {
|
|
@@ -2298,6 +2307,11 @@ function createWebOnMessageHandler(params) {
|
|
|
2298
2307
|
peerKind: "group",
|
|
2299
2308
|
peerId
|
|
2300
2309
|
}) : route.sessionKey;
|
|
2310
|
+
const account = resolveWhatsAppAccount({
|
|
2311
|
+
cfg,
|
|
2312
|
+
accountId: route.accountId ?? msg.accountId ?? params.account.accountId
|
|
2313
|
+
});
|
|
2314
|
+
const baseMentionConfig = buildMentionConfig(cfg);
|
|
2301
2315
|
if (msg.from === msg.to) logVerbose(`📱 Same-phone mode detected (from === to: ${msg.from})`);
|
|
2302
2316
|
if (params.echoTracker.has(msg.body)) {
|
|
2303
2317
|
logVerbose("Skipping auto-reply: detected echo (message matches recently sent text)");
|
|
@@ -2312,7 +2326,7 @@ function createWebOnMessageHandler(params) {
|
|
|
2312
2326
|
const runAudioPreflightOnce = async () => {
|
|
2313
2327
|
if (preflightAudioTranscript !== void 0 || !canRunEarlyAudioPreflight || !hasAudioBody || !msg.mediaPath) return;
|
|
2314
2328
|
ackReaction = await maybeSendAckReaction({
|
|
2315
|
-
cfg
|
|
2329
|
+
cfg,
|
|
2316
2330
|
msg,
|
|
2317
2331
|
agentId: route.agentId,
|
|
2318
2332
|
sessionKey: route.sessionKey,
|
|
@@ -2324,7 +2338,7 @@ function createWebOnMessageHandler(params) {
|
|
|
2324
2338
|
});
|
|
2325
2339
|
ackAlreadySent = ackReaction !== null;
|
|
2326
2340
|
try {
|
|
2327
|
-
const { transcribeFirstAudio } = await import("./audio-preflight.runtime-
|
|
2341
|
+
const { transcribeFirstAudio } = await import("./audio-preflight.runtime-MmkB-pgX.js");
|
|
2328
2342
|
preflightAudioTranscript = await transcribeFirstAudio({
|
|
2329
2343
|
ctx: {
|
|
2330
2344
|
MediaPaths: [msg.mediaPath],
|
|
@@ -2337,7 +2351,7 @@ function createWebOnMessageHandler(params) {
|
|
|
2337
2351
|
OriginatingTo: conversationId,
|
|
2338
2352
|
AccountId: route.accountId
|
|
2339
2353
|
},
|
|
2340
|
-
cfg
|
|
2354
|
+
cfg
|
|
2341
2355
|
}) ?? null;
|
|
2342
2356
|
} catch {
|
|
2343
2357
|
preflightAudioTranscript = null;
|
|
@@ -2362,7 +2376,7 @@ function createWebOnMessageHandler(params) {
|
|
|
2362
2376
|
OriginatingTo: conversationId
|
|
2363
2377
|
};
|
|
2364
2378
|
updateLastRouteInBackground({
|
|
2365
|
-
cfg
|
|
2379
|
+
cfg,
|
|
2366
2380
|
backgroundTasks: params.backgroundTasks,
|
|
2367
2381
|
storeAgentId: route.agentId,
|
|
2368
2382
|
sessionKey: route.sessionKey,
|
|
@@ -2373,16 +2387,16 @@ function createWebOnMessageHandler(params) {
|
|
|
2373
2387
|
warn: params.replyLogger.warn.bind(params.replyLogger)
|
|
2374
2388
|
});
|
|
2375
2389
|
let gating = await applyGroupGating({
|
|
2376
|
-
cfg
|
|
2390
|
+
cfg,
|
|
2377
2391
|
msg,
|
|
2378
2392
|
deferMissingMention: hasAudioBody && Boolean(msg.mediaPath),
|
|
2379
2393
|
conversationId,
|
|
2380
2394
|
groupHistoryKey,
|
|
2381
2395
|
agentId: route.agentId,
|
|
2382
2396
|
sessionKey: route.sessionKey,
|
|
2383
|
-
baseMentionConfig
|
|
2384
|
-
authDir:
|
|
2385
|
-
selfChatMode:
|
|
2397
|
+
baseMentionConfig,
|
|
2398
|
+
authDir: account.authDir,
|
|
2399
|
+
selfChatMode: account.selfChatMode,
|
|
2386
2400
|
groupHistories: params.groupHistories,
|
|
2387
2401
|
groupHistoryLimit: params.groupHistoryLimit,
|
|
2388
2402
|
groupMemberNames: params.groupMemberNames,
|
|
@@ -2392,16 +2406,16 @@ function createWebOnMessageHandler(params) {
|
|
|
2392
2406
|
if (!gating.shouldProcess && "needsMentionText" in gating && gating.needsMentionText === true) {
|
|
2393
2407
|
await runAudioPreflightOnce();
|
|
2394
2408
|
gating = await applyGroupGating({
|
|
2395
|
-
cfg
|
|
2409
|
+
cfg,
|
|
2396
2410
|
msg,
|
|
2397
2411
|
...typeof preflightAudioTranscript === "string" ? { mentionText: preflightAudioTranscript } : {},
|
|
2398
2412
|
conversationId,
|
|
2399
2413
|
groupHistoryKey,
|
|
2400
2414
|
agentId: route.agentId,
|
|
2401
2415
|
sessionKey: route.sessionKey,
|
|
2402
|
-
baseMentionConfig
|
|
2403
|
-
authDir:
|
|
2404
|
-
selfChatMode:
|
|
2416
|
+
baseMentionConfig,
|
|
2417
|
+
authDir: account.authDir,
|
|
2418
|
+
selfChatMode: account.selfChatMode,
|
|
2405
2419
|
groupHistories: params.groupHistories,
|
|
2406
2420
|
groupHistoryLimit: params.groupHistoryLimit,
|
|
2407
2421
|
groupMemberNames: params.groupMemberNames,
|
|
@@ -2411,7 +2425,7 @@ function createWebOnMessageHandler(params) {
|
|
|
2411
2425
|
}
|
|
2412
2426
|
if (!gating.shouldProcess) return;
|
|
2413
2427
|
} else if (!msg.sender?.e164 && !msg.senderE164 && peerId && peerId.startsWith("+")) {
|
|
2414
|
-
const normalized =
|
|
2428
|
+
const normalized = normalizeE164(peerId);
|
|
2415
2429
|
if (normalized) {
|
|
2416
2430
|
msg.sender = {
|
|
2417
2431
|
...msg.sender,
|
|
@@ -2422,7 +2436,7 @@ function createWebOnMessageHandler(params) {
|
|
|
2422
2436
|
}
|
|
2423
2437
|
await runAudioPreflightOnce();
|
|
2424
2438
|
if (await maybeBroadcastMessage({
|
|
2425
|
-
cfg
|
|
2439
|
+
cfg,
|
|
2426
2440
|
msg,
|
|
2427
2441
|
peerId,
|
|
2428
2442
|
route,
|
|
@@ -2431,9 +2445,9 @@ function createWebOnMessageHandler(params) {
|
|
|
2431
2445
|
...preflightAudioTranscript !== void 0 ? { preflightAudioTranscript } : {},
|
|
2432
2446
|
...ackAlreadySent && msg.chatType !== "group" ? { ackAlreadySent: true } : {},
|
|
2433
2447
|
...ackReaction && msg.chatType !== "group" ? { ackReaction } : {},
|
|
2434
|
-
processMessage: (m, r, k, opts) => processForRoute(m, r, k, opts)
|
|
2448
|
+
processMessage: (m, r, k, opts) => processForRoute(cfg, m, r, k, opts)
|
|
2435
2449
|
})) return;
|
|
2436
|
-
await processForRoute(msg, route, groupHistoryKey, {
|
|
2450
|
+
await processForRoute(cfg, msg, route, groupHistoryKey, {
|
|
2437
2451
|
...preflightAudioTranscript !== void 0 ? { preflightAudioTranscript } : {},
|
|
2438
2452
|
...ackAlreadySent ? { ackAlreadySent: true } : {},
|
|
2439
2453
|
...ackReaction ? { ackReaction } : {}
|
|
@@ -2447,9 +2461,37 @@ function isNonRetryableWebCloseStatus(statusCode) {
|
|
|
2447
2461
|
}
|
|
2448
2462
|
let replyResolverRuntimePromise = null;
|
|
2449
2463
|
function loadReplyResolverRuntime() {
|
|
2450
|
-
replyResolverRuntimePromise ??= import("./reply-resolver.runtime-
|
|
2464
|
+
replyResolverRuntimePromise ??= import("./reply-resolver.runtime-rIVWohXr.js");
|
|
2451
2465
|
return replyResolverRuntimePromise;
|
|
2452
2466
|
}
|
|
2467
|
+
function resolveWebMonitorConfigSnapshot(params) {
|
|
2468
|
+
const account = resolveWhatsAppAccount({
|
|
2469
|
+
cfg: params.cfg,
|
|
2470
|
+
accountId: params.accountId
|
|
2471
|
+
});
|
|
2472
|
+
return {
|
|
2473
|
+
cfg: {
|
|
2474
|
+
...params.cfg,
|
|
2475
|
+
channels: {
|
|
2476
|
+
...params.cfg.channels,
|
|
2477
|
+
whatsapp: {
|
|
2478
|
+
...params.cfg.channels?.whatsapp,
|
|
2479
|
+
ackReaction: account.ackReaction,
|
|
2480
|
+
messagePrefix: account.messagePrefix,
|
|
2481
|
+
allowFrom: account.allowFrom,
|
|
2482
|
+
groupAllowFrom: account.groupAllowFrom,
|
|
2483
|
+
groupPolicy: account.groupPolicy,
|
|
2484
|
+
textChunkLimit: account.textChunkLimit,
|
|
2485
|
+
chunkMode: account.chunkMode,
|
|
2486
|
+
mediaMaxMb: account.mediaMaxMb,
|
|
2487
|
+
blockStreaming: account.blockStreaming,
|
|
2488
|
+
groups: account.groups
|
|
2489
|
+
}
|
|
2490
|
+
}
|
|
2491
|
+
},
|
|
2492
|
+
account
|
|
2493
|
+
};
|
|
2494
|
+
}
|
|
2453
2495
|
function normalizeReconnectAccountId(accountId) {
|
|
2454
2496
|
return (accountId ?? "").trim() || "default";
|
|
2455
2497
|
}
|
|
@@ -2514,29 +2556,14 @@ async function monitorWebChannel(verbose, listenerFactory = attachWebInboxToSock
|
|
|
2514
2556
|
statusController.emit();
|
|
2515
2557
|
const baseCfg = getRuntimeConfig$1();
|
|
2516
2558
|
const sourceCfg = getRuntimeConfigSourceSnapshot();
|
|
2517
|
-
const account =
|
|
2559
|
+
const { cfg, account } = resolveWebMonitorConfigSnapshot({
|
|
2518
2560
|
cfg: baseCfg,
|
|
2519
2561
|
accountId: tuning.accountId
|
|
2520
2562
|
});
|
|
2521
|
-
const
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
whatsapp: {
|
|
2526
|
-
...baseCfg.channels?.whatsapp,
|
|
2527
|
-
ackReaction: account.ackReaction,
|
|
2528
|
-
messagePrefix: account.messagePrefix,
|
|
2529
|
-
allowFrom: account.allowFrom,
|
|
2530
|
-
groupAllowFrom: account.groupAllowFrom,
|
|
2531
|
-
groupPolicy: account.groupPolicy,
|
|
2532
|
-
textChunkLimit: account.textChunkLimit,
|
|
2533
|
-
chunkMode: account.chunkMode,
|
|
2534
|
-
mediaMaxMb: account.mediaMaxMb,
|
|
2535
|
-
blockStreaming: account.blockStreaming,
|
|
2536
|
-
groups: account.groups
|
|
2537
|
-
}
|
|
2538
|
-
}
|
|
2539
|
-
};
|
|
2563
|
+
const loadCurrentMonitorConfig = () => resolveWebMonitorConfigSnapshot({
|
|
2564
|
+
cfg: getRuntimeConfig$1(),
|
|
2565
|
+
accountId: account.accountId
|
|
2566
|
+
}).cfg;
|
|
2540
2567
|
const maxMediaBytes = resolveWhatsAppMediaMaxBytes(account);
|
|
2541
2568
|
const heartbeatSeconds = resolveHeartbeatSeconds(cfg, tuning.heartbeatSeconds);
|
|
2542
2569
|
const reconnectPolicy = resolveReconnectPolicy(cfg, tuning.reconnect);
|
|
@@ -2603,6 +2630,7 @@ async function monitorWebChannel(verbose, listenerFactory = attachWebInboxToSock
|
|
|
2603
2630
|
createListener: async ({ sock, connection }) => {
|
|
2604
2631
|
const onMessage = createWebOnMessageHandler({
|
|
2605
2632
|
cfg,
|
|
2633
|
+
loadConfig: loadCurrentMonitorConfig,
|
|
2606
2634
|
verbose,
|
|
2607
2635
|
connectionId,
|
|
2608
2636
|
maxMediaBytes,
|
|
@@ -2618,6 +2646,7 @@ async function monitorWebChannel(verbose, listenerFactory = attachWebInboxToSock
|
|
|
2618
2646
|
});
|
|
2619
2647
|
return await (listenerFactory ?? attachWebInboxToSocket)({
|
|
2620
2648
|
cfg,
|
|
2649
|
+
loadConfig: loadCurrentMonitorConfig,
|
|
2621
2650
|
verbose,
|
|
2622
2651
|
accountId: account.accountId,
|
|
2623
2652
|
authDir: account.authDir,
|
|
@@ -2678,6 +2707,40 @@ async function monitorWebChannel(verbose, listenerFactory = attachWebInboxToSock
|
|
|
2678
2707
|
}
|
|
2679
2708
|
});
|
|
2680
2709
|
} catch (error) {
|
|
2710
|
+
if (getStatusCode(error) === 428) {
|
|
2711
|
+
const retryDecision = controller.consumeReconnectAttempt();
|
|
2712
|
+
statusController.noteReconnectAttempts(retryDecision.reconnectAttempts);
|
|
2713
|
+
statusController.noteClose({
|
|
2714
|
+
statusCode: 428,
|
|
2715
|
+
error: formatError(error),
|
|
2716
|
+
reconnectAttempts: retryDecision.reconnectAttempts,
|
|
2717
|
+
healthState: retryDecision.healthState
|
|
2718
|
+
});
|
|
2719
|
+
if (retryDecision.action === "stop") {
|
|
2720
|
+
reconnectLogger.warn({
|
|
2721
|
+
connectionId,
|
|
2722
|
+
status: 428,
|
|
2723
|
+
reconnectAttempts: retryDecision.reconnectAttempts,
|
|
2724
|
+
maxAttempts: reconnectPolicy.maxAttempts
|
|
2725
|
+
}, "web reconnect: 428 during opening; max attempts reached");
|
|
2726
|
+
runtime.error(`WhatsApp Web connection closed during setup (status 428) after ${retryDecision.reconnectAttempts}/${reconnectPolicy.maxAttempts} attempts. Relink with \`${formatCliCommand("openclaw channels login --channel whatsapp")}\` if the issue persists.`);
|
|
2727
|
+
await controller.shutdown();
|
|
2728
|
+
break;
|
|
2729
|
+
}
|
|
2730
|
+
reconnectLogger.info({
|
|
2731
|
+
connectionId,
|
|
2732
|
+
status: 428,
|
|
2733
|
+
reconnectAttempts: retryDecision.reconnectAttempts,
|
|
2734
|
+
delayMs: retryDecision.delayMs
|
|
2735
|
+
}, "web reconnect: 428 during opening; retrying");
|
|
2736
|
+
runtime.error(`WhatsApp Web connection closed during setup (status 428). Retry ${retryDecision.reconnectAttempts}/${reconnectPolicy.maxAttempts || "∞"} in ${formatDurationPrecise(retryDecision.delayMs ?? 0)}.`);
|
|
2737
|
+
try {
|
|
2738
|
+
await controller.waitBeforeRetry(retryDecision.delayMs ?? 0);
|
|
2739
|
+
} catch {
|
|
2740
|
+
break;
|
|
2741
|
+
}
|
|
2742
|
+
continue;
|
|
2743
|
+
}
|
|
2681
2744
|
if (!isRetryableAuthUnstableError(error)) throw error;
|
|
2682
2745
|
const retryDecision = controller.consumeReconnectAttempt();
|
|
2683
2746
|
statusController.noteReconnectAttempts(retryDecision.reconnectAttempts);
|
|
@@ -2822,11 +2885,13 @@ async function monitorWebChannel(verbose, listenerFactory = attachWebInboxToSock
|
|
|
2822
2885
|
await controller.shutdown();
|
|
2823
2886
|
break;
|
|
2824
2887
|
}
|
|
2888
|
+
const isWatchdogRecoveryReconnect = decision.normalized.error === WHATSAPP_WATCHDOG_TIMEOUT_ERROR;
|
|
2825
2889
|
statusController.noteClose({
|
|
2826
2890
|
statusCode: decision.normalized.statusCode,
|
|
2827
2891
|
error: decision.normalized.errorText,
|
|
2828
2892
|
reconnectAttempts: decision.reconnectAttempts,
|
|
2829
|
-
healthState: decision.healthState
|
|
2893
|
+
healthState: decision.healthState,
|
|
2894
|
+
watchdogRecovery: isWatchdogRecoveryReconnect
|
|
2830
2895
|
});
|
|
2831
2896
|
reconnectLogger.info({
|
|
2832
2897
|
connectionId: connection.connectionId,
|
|
@@ -2835,7 +2900,9 @@ async function monitorWebChannel(verbose, listenerFactory = attachWebInboxToSock
|
|
|
2835
2900
|
maxAttempts: reconnectPolicy.maxAttempts || "unlimited",
|
|
2836
2901
|
delayMs: decision.delayMs
|
|
2837
2902
|
}, "web reconnect: scheduling retry");
|
|
2838
|
-
|
|
2903
|
+
const reconnectMessage = isWatchdogRecoveryReconnect ? `WhatsApp Web watchdog is recovering a stale connection (status ${decision.normalized.statusLabel}). Retry ${decision.reconnectAttempts}/${reconnectPolicy.maxAttempts || "∞"} in ${formatDurationPrecise(decision.delayMs ?? 0)}.` : `WhatsApp Web connection closed (status ${decision.normalized.statusLabel}). Retry ${decision.reconnectAttempts}/${reconnectPolicy.maxAttempts || "∞"} in ${formatDurationPrecise(decision.delayMs ?? 0)}… (${decision.normalized.errorText})`;
|
|
2904
|
+
if (isWatchdogRecoveryReconnect) runtime.log(warn(reconnectMessage));
|
|
2905
|
+
else runtime.error(reconnectMessage);
|
|
2839
2906
|
await controller.closeCurrentConnection();
|
|
2840
2907
|
try {
|
|
2841
2908
|
await controller.waitBeforeRetry(decision.delayMs ?? 0);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/
|
|
1
|
+
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
2
2
|
import { normalizeE164 } from "openclaw/plugin-sdk/account-resolution";
|
|
3
3
|
//#region extensions/whatsapp/src/normalize-target.ts
|
|
4
4
|
const WHATSAPP_USER_JID_RE = /^(\d+)(?::\d+)?@s\.whatsapp\.net$/i;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { t as resolveWhatsAppOutboundTarget } from "./resolve-outbound-target-
|
|
2
|
-
import { n as normalizeWhatsAppPayloadText } from "./outbound-media-contract-
|
|
3
|
-
import { t as createWhatsAppOutboundBase } from "./outbound-base-
|
|
1
|
+
import { t as resolveWhatsAppOutboundTarget } from "./resolve-outbound-target-BKcv4ofn.js";
|
|
2
|
+
import { n as normalizeWhatsAppPayloadText } from "./outbound-media-contract-zq9aNgT8.js";
|
|
3
|
+
import { t as createWhatsAppOutboundBase } from "./outbound-base-BgtywpNm.js";
|
|
4
4
|
import { shouldLogVerbose } from "openclaw/plugin-sdk/runtime-env";
|
|
5
5
|
import { chunkText } from "openclaw/plugin-sdk/reply-chunking";
|
|
6
6
|
//#region extensions/whatsapp/src/outbound-adapter.ts
|
|
7
7
|
let whatsAppSendModulePromise;
|
|
8
8
|
function loadWhatsAppSendModule() {
|
|
9
|
-
whatsAppSendModulePromise ??= import("./send-
|
|
9
|
+
whatsAppSendModulePromise ??= import("./send-DBfXQDd4.js").then((n) => n.a);
|
|
10
10
|
return whatsAppSendModulePromise;
|
|
11
11
|
}
|
|
12
12
|
function normalizeOutboundText(text) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as normalizeWhatsAppPayloadText, t as normalizeWhatsAppOutboundPayload } from "./outbound-media-contract-
|
|
3
|
-
import { i as lookupInboundMessageMetaForTarget } from "./quoted-message-
|
|
1
|
+
import { p as toWhatsappJid } from "./text-runtime-CMxQczvs.js";
|
|
2
|
+
import { n as normalizeWhatsAppPayloadText, t as normalizeWhatsAppOutboundPayload } from "./outbound-media-contract-zq9aNgT8.js";
|
|
3
|
+
import { i as lookupInboundMessageMetaForTarget } from "./quoted-message-BQsRXnac.js";
|
|
4
4
|
import { DEFAULT_ACCOUNT_ID, listCombinedAccountIds, normalizeOptionalAccountId, resolveListedDefaultAccountId } from "openclaw/plugin-sdk/account-core";
|
|
5
5
|
import { createAttachedChannelResultAdapter } from "openclaw/plugin-sdk/channel-send-result";
|
|
6
6
|
import { resolveOutboundSendDep } from "openclaw/plugin-sdk/outbound-send-deps";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as text_runtime_exports } from "./text-runtime-DBKC9uEi.js";
|
|
2
1
|
import { t as formatError } from "./session-errors-CSuKZPub.js";
|
|
2
|
+
import { a as sanitizeAssistantVisibleTextWithProfile, i as sanitizeAssistantVisibleText, o as sleep, s as stripToolCallXmlTags } from "./text-runtime-CMxQczvs.js";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { MEDIA_FFMPEG_MAX_AUDIO_DURATION_SECS, runFfmpeg } from "openclaw/plugin-sdk/media-runtime";
|
|
5
5
|
import { sanitizeForPlainText } from "openclaw/plugin-sdk/outbound-runtime";
|
|
@@ -11,19 +11,19 @@ const WHATSAPP_VOICE_SAMPLE_RATE_HZ = 48e3;
|
|
|
11
11
|
const WHATSAPP_VOICE_BITRATE = "64k";
|
|
12
12
|
const WHATSAPP_VOICE_MIMETYPE = "audio/ogg; codecs=opus";
|
|
13
13
|
function stripWhatsAppPluralToolXml(text) {
|
|
14
|
-
return
|
|
14
|
+
return stripToolCallXmlTags(text, { stripFunctionCallsXmlPayloads: true });
|
|
15
15
|
}
|
|
16
16
|
function finalizeWhatsAppVisibleText(text) {
|
|
17
17
|
return sanitizeForPlainText(stripWhatsAppPluralToolXml(text));
|
|
18
18
|
}
|
|
19
19
|
function normalizeWhatsAppPayloadText(text) {
|
|
20
|
-
return finalizeWhatsAppVisibleText(
|
|
20
|
+
return finalizeWhatsAppVisibleText(sanitizeAssistantVisibleText(text ?? "")).trimStart();
|
|
21
21
|
}
|
|
22
22
|
function stripLeadingBlankLines(text) {
|
|
23
23
|
return text.replace(/^(?:[ \t]*\r?\n)+/, "");
|
|
24
24
|
}
|
|
25
25
|
function normalizeWhatsAppPayloadTextPreservingIndentation(text) {
|
|
26
|
-
const normalized = stripLeadingBlankLines(finalizeWhatsAppVisibleText(
|
|
26
|
+
const normalized = stripLeadingBlankLines(finalizeWhatsAppVisibleText(sanitizeAssistantVisibleTextWithProfile(stripLeadingBlankLines(text ?? ""), "history")));
|
|
27
27
|
return normalized.trim() ? normalized : "";
|
|
28
28
|
}
|
|
29
29
|
function resolveWhatsAppOutboundMediaUrls(payload) {
|
|
@@ -151,7 +151,7 @@ async function sendWhatsAppOutboundWithRetry(params) {
|
|
|
151
151
|
error,
|
|
152
152
|
errorText
|
|
153
153
|
});
|
|
154
|
-
await
|
|
154
|
+
await sleep(backoffMs);
|
|
155
155
|
}
|
|
156
156
|
throw lastError;
|
|
157
157
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as whatsappOutbound } from "./outbound-adapter-
|
|
1
|
+
import { t as whatsappOutbound } from "./outbound-adapter-Bs0e4qVd.js";
|
|
2
2
|
export { whatsappOutbound };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as resolveMergedWhatsAppAccountConfig } from "./account-config-CNQ33oav.js";
|
|
2
|
-
import { resolveReactionLevel } from "openclaw/plugin-sdk/
|
|
2
|
+
import { resolveReactionLevel } from "openclaw/plugin-sdk/status-helpers";
|
|
3
3
|
//#region extensions/whatsapp/src/reaction-level.ts
|
|
4
4
|
/** Resolve the effective reaction level and its implications for WhatsApp. */
|
|
5
5
|
function resolveWhatsAppReactionLevel(params) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as normalizeWhatsAppTarget, n as isWhatsAppNewsletterJid, t as isWhatsAppGroupJid } from "./normalize-target-
|
|
1
|
+
import { c as normalizeWhatsAppTarget, n as isWhatsAppNewsletterJid, t as isWhatsAppGroupJid } from "./normalize-target-ePanEpfY.js";
|
|
2
2
|
import { missingTargetError } from "openclaw/plugin-sdk/channel-feedback";
|
|
3
3
|
//#region extensions/whatsapp/src/resolve-outbound-target.ts
|
|
4
4
|
function whatsappAllowFromPolicyError(target) {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __exportAll = (all, no_symbols) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) __defProp(target, name, {
|
|
6
|
+
get: all[name],
|
|
7
|
+
enumerable: true
|
|
8
|
+
});
|
|
9
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
10
|
+
return target;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { __exportAll as t };
|