@openclaw/whatsapp 2026.9.8 → 2026.10.1-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/.setup/{accounts-CtRPAQCL.mjs → accounts-F0vHuze2.mjs} +3 -11
- package/dist/.setup/{action-runtime-DeVk5V7r.mjs → action-runtime-CE3zGstN.mjs} +4 -5
- package/dist/.setup/{agent-tools-login-CL5C1rA2.mjs → agent-tools-login-B7VEvJO7.mjs} +17 -36
- package/dist/.setup/{approval-handler.runtime-CjqMlPOX.mjs → approval-handler.runtime-CKposl6w.mjs} +3 -3
- package/dist/.setup/{approval-reactions-DiOFvb1s.mjs → approval-reactions-CD6CDF9k.mjs} +9 -40
- package/dist/.setup/{auth-store-BBonwKks.mjs → auth-store-D2rN-hP5.mjs} +12 -19
- package/dist/.setup/{channel-CJFE0kD_.mjs → channel-DNgKHMCz.mjs} +15 -24
- package/dist/.setup/{channel-react-action-2r_hjLZV.mjs → channel-react-action-BaBV9X6M.mjs} +3 -3
- package/dist/.setup/{channel.runtime-C94goLw9.mjs → channel.runtime-BniF8Swm.mjs} +4 -4
- package/dist/.setup/{channel.setup-CfN1UfdY.mjs → channel.setup-CsS_NAKQ.mjs} +1 -1
- package/dist/.setup/{connection-controller-CHo1oRJA.mjs → connection-controller-COkcq48K.mjs} +5 -14
- package/dist/.setup/{creds-files-CDATZWWM.mjs → creds-files-B8WcOAmE.mjs} +1 -10
- package/dist/.setup/{directory-config-DUiJ5d8I.mjs → directory-config-RYQomHyB.mjs} +6 -14
- package/dist/.setup/{doctor-iMwg0Vhr.mjs → doctor-DKzeBEmH.mjs} +7 -1
- package/dist/.setup/{group-config-path-DZr3ucUO.mjs → group-config-path-BPrak_bJ.mjs} +3 -9
- package/dist/.setup/{group-session-key-2-mja4OF.mjs → group-session-key-BV8Le9r8.mjs} +5 -14
- package/dist/.setup/{login-BFlvSh9h.mjs → login-CV_4V021.mjs} +4 -4
- package/dist/.setup/{login-qr-Ayb8i25J.mjs → login-qr-DFhGc5yH.mjs} +11 -27
- package/dist/.setup/{monitor-CGpV2VNN.mjs → monitor-B5DS4PDV.mjs} +65 -186
- package/dist/.setup/{question-reactions-CPyyi5AY.mjs → question-reactions-LMeijbaq.mjs} +7 -37
- package/dist/.setup/{resolve-outbound-target-C2eUvsTc.mjs → resolve-outbound-target-CzyNKmrl.mjs} +2 -13
- package/dist/.setup/{send-BGdvf5cC.mjs → send-CGUsUdoX.mjs} +31 -6
- package/dist/.setup/{send-api-H4AkQJjT.mjs → send-api-B03VDwZ1.mjs} +35 -53
- package/dist/.setup/{setup-finalize-DmPX4EaW.mjs → setup-finalize-GtBmrO8p.mjs} +8 -20
- package/dist/.setup/setup-plugin-api-Bsp7jI-r.mjs +3 -0
- package/dist/.setup/{setup-surface-43fj197P.mjs → setup-surface-BuA39k6K.mjs} +3 -3
- package/dist/.setup/{shared-DgOG5Iqr.mjs → shared-CP_zs2U7.mjs} +12 -13
- package/dist/.setup/{socket-close-CT__V2fz.mjs → socket-close-DU7eerAa.mjs} +26 -54
- package/dist/.setup/{targets-runtime-DmiqXIXO.mjs → targets-runtime-Dls-Xh4F.mjs} +10 -34
- package/dist/action-runtime-api.js +1 -1
- package/dist/action-runtime.runtime.js +1 -1
- package/dist/agent-tools-api.js +3 -3
- package/dist/api.js +10 -10
- package/dist/auth-presence.js +3 -4
- package/dist/channel-plugin-api.js +1 -1
- package/dist/directory-contract-api.js +1 -1
- package/dist/doctor-contract-api.js +234 -59
- package/dist/light-runtime-api.js +2 -2
- package/dist/login-qr-runtime.js +1 -1
- package/dist/runtime-api.js +10 -10
- package/dist/setup-entry.js +1 -1
- package/dist/setup-plugin-api.js +1 -1
- package/package.json +5 -5
- package/dist/.setup/setup-plugin-api-vJlxKzca.mjs +0 -3
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/account-
|
|
1
|
+
import { DEFAULT_ACCOUNT_ID, resolveAccountKey } from "openclaw/plugin-sdk/account-resolution";
|
|
2
2
|
//#region extensions/whatsapp/src/group-config-path.ts
|
|
3
3
|
const WHATSAPP_GROUP_SCOPE_FIELDS = [
|
|
4
4
|
"groupPolicy",
|
|
5
5
|
"groupAllowFrom",
|
|
6
6
|
"groups"
|
|
7
7
|
];
|
|
8
|
-
function resolveWhatsAppAccountKey(accounts, accountId) {
|
|
9
|
-
if (!accounts) return;
|
|
10
|
-
if (Object.hasOwn(accounts, accountId)) return accountId;
|
|
11
|
-
const normalizedAccountId = accountId.trim().toLowerCase();
|
|
12
|
-
return Object.keys(accounts).find((key) => key.trim().toLowerCase() === normalizedAccountId);
|
|
13
|
-
}
|
|
14
8
|
function normalizePathAccountId(accountId) {
|
|
15
9
|
return typeof accountId === "string" ? accountId.trim() || DEFAULT_ACCOUNT_ID : DEFAULT_ACCOUNT_ID;
|
|
16
10
|
}
|
|
@@ -21,8 +15,8 @@ function resolveWhatsAppGroupScopeBasePath(params, fields = WHATSAPP_GROUP_SCOPE
|
|
|
21
15
|
const accountId = normalizePathAccountId(params.accountId);
|
|
22
16
|
const whatsapp = params.cfg.channels?.whatsapp;
|
|
23
17
|
const accounts = whatsapp?.accounts;
|
|
24
|
-
const accountKey =
|
|
25
|
-
const defaultAccountKey =
|
|
18
|
+
const accountKey = resolveAccountKey(accounts, accountId);
|
|
19
|
+
const defaultAccountKey = resolveAccountKey(accounts, DEFAULT_ACCOUNT_ID);
|
|
26
20
|
const accountConfig = accountKey ? accounts?.[accountKey] : void 0;
|
|
27
21
|
const defaultAccountConfig = defaultAccountKey ? accounts?.[defaultAccountKey] : void 0;
|
|
28
22
|
const hasField = (config) => fields.some((field) => hasConfiguredField(config, field));
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { a as resolveWhatsAppAccount } from "./accounts-
|
|
1
|
+
import { a as resolveWhatsAppAccount } from "./accounts-F0vHuze2.mjs";
|
|
2
2
|
import { c as normalizeWhatsAppTarget } from "./normalize-target-BGra1ZnM.mjs";
|
|
3
|
-
import { r as jidToE164 } from "./targets-runtime-
|
|
3
|
+
import { r as jidToE164 } from "./targets-runtime-Dls-Xh4F.mjs";
|
|
4
4
|
import { formatMediaPlaceholderText } from "openclaw/plugin-sdk/channel-inbound";
|
|
5
5
|
import { createChannelApprovalAuth } from "openclaw/plugin-sdk/approval-auth-runtime";
|
|
6
6
|
import { isHostedLidUser, isHostedPnUser, isLidUser, isPnUser } from "baileys";
|
|
7
|
+
import { pruneMapToMaxSize } from "openclaw/plugin-sdk/collection-runtime";
|
|
7
8
|
import { DEFAULT_ACCOUNT_ID, normalizeAccountId, resolveThreadSessionKeys } from "openclaw/plugin-sdk/routing";
|
|
8
9
|
//#region extensions/whatsapp/src/approval-auth.ts
|
|
9
10
|
function normalizeWhatsAppApproverId(value) {
|
|
@@ -31,17 +32,13 @@ const whatsappApprovalAuth = whatsappApproval.approvalAuth;
|
|
|
31
32
|
//#endregion
|
|
32
33
|
//#region extensions/whatsapp/src/quoted-message.ts
|
|
33
34
|
const CACHE_TTL_MS = 6e5;
|
|
34
|
-
const MAX_ENTRIES = 500;
|
|
35
35
|
const cache = /* @__PURE__ */ new Map();
|
|
36
36
|
function makeCacheKey(accountId, remoteJid, messageId) {
|
|
37
37
|
return `${accountId}:${remoteJid}:${messageId}`;
|
|
38
38
|
}
|
|
39
39
|
function cacheInboundMessageMeta(accountId, remoteJid, messageId, meta) {
|
|
40
40
|
if (!accountId || !messageId || !remoteJid) return;
|
|
41
|
-
|
|
42
|
-
const oldest = cache.keys().next().value;
|
|
43
|
-
if (oldest) cache.delete(oldest);
|
|
44
|
-
}
|
|
41
|
+
pruneMapToMaxSize(cache, 499);
|
|
45
42
|
cache.set(makeCacheKey(accountId, remoteJid, messageId), {
|
|
46
43
|
...meta,
|
|
47
44
|
ts: Date.now()
|
|
@@ -164,12 +161,6 @@ function resolveWhatsAppGroupSessionKey(params) {
|
|
|
164
161
|
threadId: resolveWhatsAppGroupAccountThreadId(accountId)
|
|
165
162
|
}).sessionKey;
|
|
166
163
|
}
|
|
167
|
-
function resolveWhatsAppLegacyGroupSessionKey(params) {
|
|
168
|
-
const accountId = normalizeAccountId(params.accountId);
|
|
169
|
-
if (!accountId || accountId === DEFAULT_ACCOUNT_ID || !params.sessionKey.includes(":group:")) return null;
|
|
170
|
-
const suffix = `:thread:${resolveWhatsAppGroupAccountThreadId(accountId)}`;
|
|
171
|
-
return params.sessionKey.endsWith(suffix) ? params.sessionKey.slice(0, -suffix.length) : null;
|
|
172
|
-
}
|
|
173
164
|
function resolveWhatsAppGroupSessionRoute(route) {
|
|
174
165
|
const sessionKey = resolveWhatsAppGroupSessionKey(route);
|
|
175
166
|
if (sessionKey === route.sessionKey) return route;
|
|
@@ -179,4 +170,4 @@ function resolveWhatsAppGroupSessionRoute(route) {
|
|
|
179
170
|
};
|
|
180
171
|
}
|
|
181
172
|
//#endregion
|
|
182
|
-
export {
|
|
173
|
+
export { lookupInboundMessageMeta as a, whatsappApprovalAuth as c, cacheInboundMessageMeta as i, resolveWhatsAppGroupSessionRoute as n, lookupInboundMessageMetaForTarget as o, buildQuotedMessageOptions as r, getWhatsAppApprovalApprovers as s, resolveWhatsAppGroupSessionKey as t };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BBjsoOtd.mjs";
|
|
2
|
-
import { a as resolveWhatsAppAccount } from "./accounts-
|
|
3
|
-
import {
|
|
4
|
-
import { _ as renderQrTerminal, h as resolveWhatsAppSocketTiming, r as createWaSocket } from "./socket-close-
|
|
5
|
-
import { a as closeWaSocketSoon, o as waitForWhatsAppLoginResult } from "./connection-controller-
|
|
2
|
+
import { a as resolveWhatsAppAccount } from "./accounts-F0vHuze2.mjs";
|
|
3
|
+
import { y as restoreCredsFromBackupIfNeeded } from "./auth-store-D2rN-hP5.mjs";
|
|
4
|
+
import { _ as renderQrTerminal, h as resolveWhatsAppSocketTiming, r as createWaSocket } from "./socket-close-DU7eerAa.mjs";
|
|
5
|
+
import { a as closeWaSocketSoon, o as waitForWhatsAppLoginResult } from "./connection-controller-COkcq48K.mjs";
|
|
6
6
|
import { formatCliCommand } from "openclaw/plugin-sdk/cli-runtime";
|
|
7
7
|
import { logInfo } from "openclaw/plugin-sdk/logging-core";
|
|
8
8
|
import { danger, defaultRuntime, success } from "openclaw/plugin-sdk/runtime-env";
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { a as resolveWhatsAppAccount } from "./accounts-
|
|
2
|
-
import { c as logoutWeb,
|
|
1
|
+
import { a as resolveWhatsAppAccount } from "./accounts-F0vHuze2.mjs";
|
|
2
|
+
import { c as logoutWeb, d as readWebAuthExistsForDecision, h as readWebSelfId, n as WHATSAPP_AUTH_UNSTABLE_CODE } from "./auth-store-D2rN-hP5.mjs";
|
|
3
3
|
import { t as getActiveWebListener } from "./active-listener-CDjoX9QR.mjs";
|
|
4
|
-
import { h as resolveWhatsAppSocketTiming, r as createWaSocket } from "./socket-close-
|
|
4
|
+
import { h as resolveWhatsAppSocketTiming, r as createWaSocket } from "./socket-close-DU7eerAa.mjs";
|
|
5
5
|
import { t as formatError } from "./session-errors-B8UcAnZN.mjs";
|
|
6
|
-
import { i as closeWaSocket, o as waitForWhatsAppLoginResult, t as WHATSAPP_LOGGED_OUT_QR_MESSAGE } from "./connection-controller-
|
|
6
|
+
import { i as closeWaSocket, o as waitForWhatsAppLoginResult, t as WHATSAPP_LOGGED_OUT_QR_MESSAGE } from "./connection-controller-COkcq48K.mjs";
|
|
7
7
|
import { logInfo } from "openclaw/plugin-sdk/logging-core";
|
|
8
8
|
import { danger, defaultRuntime, info, success } from "openclaw/plugin-sdk/runtime-env";
|
|
9
9
|
import { renderQrPngDataUrl } from "openclaw/plugin-sdk/media-runtime";
|
|
10
10
|
import { resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
|
|
11
|
+
import { raceWithTimeout } from "openclaw/plugin-sdk/time-runtime";
|
|
11
12
|
import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
|
|
12
13
|
import { randomUUID } from "node:crypto";
|
|
13
14
|
import { getRuntimeConfig } from "openclaw/plugin-sdk/runtime-config-snapshot";
|
|
@@ -187,14 +188,9 @@ async function startWebLoginWithQr(opts = {}) {
|
|
|
187
188
|
message: "QR already active. Scan it in WhatsApp → Linked Devices."
|
|
188
189
|
};
|
|
189
190
|
await resetActiveLogin(account.accountId);
|
|
190
|
-
|
|
191
|
-
let rejectQr = null;
|
|
192
|
-
const qrPromise = new Promise((resolve, reject) => {
|
|
193
|
-
resolveQr = resolve;
|
|
194
|
-
rejectQr = reject;
|
|
195
|
-
});
|
|
191
|
+
const qrReady = createDeferred();
|
|
196
192
|
const qrTimer = setTimeout(() => {
|
|
197
|
-
|
|
193
|
+
qrReady.reject(/* @__PURE__ */ new Error("Timed out waiting for WhatsApp QR"));
|
|
198
194
|
}, resolveTimerTimeoutMs(opts.timeoutMs, 3e4, 5e3));
|
|
199
195
|
let sock;
|
|
200
196
|
let pendingQr = null;
|
|
@@ -225,12 +221,8 @@ async function startWebLoginWithQr(opts = {}) {
|
|
|
225
221
|
qrVersion
|
|
226
222
|
});
|
|
227
223
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
resolveQr(qr);
|
|
231
|
-
resolveQr = null;
|
|
232
|
-
rejectQr = null;
|
|
233
|
-
}
|
|
224
|
+
clearTimeout(qrTimer);
|
|
225
|
+
qrReady.resolve(qr);
|
|
234
226
|
runtime.log(info("WhatsApp QR received."));
|
|
235
227
|
}
|
|
236
228
|
});
|
|
@@ -277,7 +269,7 @@ async function startWebLoginWithQr(opts = {}) {
|
|
|
277
269
|
const loginStartResult = await waitForQrOrRecoveredLogin({
|
|
278
270
|
accountId: account.accountId,
|
|
279
271
|
login: nextLogin,
|
|
280
|
-
qrPromise
|
|
272
|
+
qrPromise: qrReady.promise
|
|
281
273
|
});
|
|
282
274
|
clearTimeout(qrTimer);
|
|
283
275
|
if (loginStartResult.outcome === "connected") {
|
|
@@ -369,15 +361,7 @@ async function waitForWebLogin(opts = {}) {
|
|
|
369
361
|
connected: false,
|
|
370
362
|
message: "Still waiting for the QR scan. Let me know when you’ve scanned it."
|
|
371
363
|
};
|
|
372
|
-
|
|
373
|
-
const timeout = new Promise((resolve) => {
|
|
374
|
-
timer = setTimeout(() => resolve("timeout"), remaining);
|
|
375
|
-
});
|
|
376
|
-
const result = await Promise.race([
|
|
377
|
-
login.waitPromise.then(() => "done"),
|
|
378
|
-
login.qrUpdate.promise.then(() => "qr-update"),
|
|
379
|
-
timeout
|
|
380
|
-
]).finally(() => clearTimeout(timer));
|
|
364
|
+
const result = await raceWithTimeout(Promise.race([login.waitPromise.then(() => "done"), login.qrUpdate.promise.then(() => "qr-update")]), remaining, () => "timeout");
|
|
381
365
|
if (result === "timeout") return {
|
|
382
366
|
connected: false,
|
|
383
367
|
message: "Still waiting for the QR scan. Let me know when you’ve scanned it."
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { n as __reExport, t as __exportAll } from "./rolldown-runtime-BBjsoOtd.mjs";
|
|
2
|
-
import { a as resolveWhatsAppAccount, s as resolveWhatsAppMediaMaxBytes } from "./accounts-
|
|
3
|
-
import {
|
|
2
|
+
import { a as resolveWhatsAppAccount, s as resolveWhatsAppMediaMaxBytes } from "./accounts-F0vHuze2.mjs";
|
|
3
|
+
import { _ as withWhatsAppLogicalDeliveryActivity, c as normalizeWhatsAppPayloadTextPreservingIndentation, f as listWhatsAppSendResultMessageIds, g as rememberWhatsAppPartialSend, h as rememberWhatsAppAcceptedSend, l as prepareWhatsAppOutboundMedia, m as normalizeWhatsAppSendResult, o as normalizeWhatsAppOutboundPayload, p as mergeWhatsAppAcceptedSendError, r as sendReactionWhatsApp, y as resolveWhatsAppReactionLevel } from "./send-CGUsUdoX.mjs";
|
|
4
4
|
import { i as getWhatsAppRuntime } from "./runtime-BLlToOi6.mjs";
|
|
5
5
|
import { r as getWhatsAppConnectionController } from "./connection-controller-runtime-context-hgLJoRc8.mjs";
|
|
6
|
-
import { a as markdownToWhatsAppChunks, c as toWhatsappJid, l as toWhatsappJidWithLid, n as isSelfChatMode, o as resolveEquivalentWhatsAppDirectChatJids, r as jidToE164, s as resolveJidToE164 } from "./targets-runtime-
|
|
7
|
-
import { a as
|
|
8
|
-
import { C as
|
|
9
|
-
import { n as resolveWhatsAppGroupsConfigPath } from "./group-config-path-
|
|
10
|
-
import { a as DEFAULT_RECONNECT_POLICY, c as resolveHeartbeatSeconds, f as createWhatsAppSocketOperationTimeoutAdapter, g as withWhatsAppSocketOperationTimeout, h as resolveWhatsAppSocketTiming, i as waitForWaConnection, l as resolveReconnectPolicy, m as resolveWhatsAppSocketOperationTimeoutMs, o as computeBackoff, p as isWhatsAppSocketOperationTimeoutError, r as createWaSocket, s as newConnectionId, u as sleepWithAbort } from "./socket-close-
|
|
6
|
+
import { a as markdownToWhatsAppChunks, c as toWhatsappJid, l as toWhatsappJidWithLid, n as isSelfChatMode, o as resolveEquivalentWhatsAppDirectChatJids, r as jidToE164, s as resolveJidToE164 } from "./targets-runtime-Dls-Xh4F.mjs";
|
|
7
|
+
import { a as lookupInboundMessageMeta, i as cacheInboundMessageMeta, n as resolveWhatsAppGroupSessionRoute, r as buildQuotedMessageOptions } from "./group-session-key-BV8Le9r8.mjs";
|
|
8
|
+
import { C as getPrimaryIdentityId, D as identitiesOverlap, E as getSenderIdentity, O as resolveComparableIdentity, S as getMentionIdentities, T as getSelfIdentity, _ as readWebSelfIdentityForDecision, h as readWebSelfId, o as getWebAuthAgeMs, r as WhatsAppAuthUnstableError, w as getReplyContext, x as getComparableIdentityValues } from "./auth-store-D2rN-hP5.mjs";
|
|
9
|
+
import { n as resolveWhatsAppGroupsConfigPath } from "./group-config-path-BPrak_bJ.mjs";
|
|
10
|
+
import { a as DEFAULT_RECONNECT_POLICY, c as resolveHeartbeatSeconds, f as createWhatsAppSocketOperationTimeoutAdapter, g as withWhatsAppSocketOperationTimeout, h as resolveWhatsAppSocketTiming, i as waitForWaConnection, l as resolveReconnectPolicy, m as resolveWhatsAppSocketOperationTimeoutMs, o as computeBackoff, p as isWhatsAppSocketOperationTimeoutError, r as createWaSocket, s as newConnectionId, u as sleepWithAbort$1 } from "./socket-close-DU7eerAa.mjs";
|
|
11
11
|
import { n as getStatusCode, t as formatError } from "./session-errors-B8UcAnZN.mjs";
|
|
12
12
|
import { t as BufferJSON } from "./session.runtime-st1konFI.mjs";
|
|
13
|
-
import { _ as resolveInboundMediaMimetype, a as addWhatsAppImagePreviewFields, c as extractContextInfo, d as extractMediaKind, f as extractMentionedJids, g as projectWhatsAppInboundMessage, h as hasInboundUserContent, i as resolveWhatsAppOutboundMentions, l as extractExternalAdReplyContext, n as addWhatsAppOutboundMentionsToContent, o as describeReplyContext, p as extractText, r as mayContainWhatsAppOutboundMention, s as extractContactContext, t as createWebSendApi, u as extractLocationData } from "./send-api-
|
|
14
|
-
import { n as WHATSAPP_WATCHDOG_TIMEOUT_ERROR, r as WhatsAppConnectionController } from "./connection-controller-
|
|
15
|
-
import { n as maybeResolveWhatsAppApprovalReaction } from "./approval-reactions-
|
|
16
|
-
import { t as maybeResolveWhatsAppQuestionReaction } from "./question-reactions-
|
|
17
|
-
import { normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
18
|
-
import { createAckReactionHandle, createStatusReactionController,
|
|
13
|
+
import { _ as resolveInboundMediaMimetype, a as addWhatsAppImagePreviewFields, c as extractContextInfo, d as extractMediaKind, f as extractMentionedJids, g as projectWhatsAppInboundMessage, h as hasInboundUserContent, i as resolveWhatsAppOutboundMentions, l as extractExternalAdReplyContext, n as addWhatsAppOutboundMentionsToContent, o as describeReplyContext, p as extractText, r as mayContainWhatsAppOutboundMention, s as extractContactContext, t as createWebSendApi, u as extractLocationData } from "./send-api-B03VDwZ1.mjs";
|
|
14
|
+
import { n as WHATSAPP_WATCHDOG_TIMEOUT_ERROR, r as WhatsAppConnectionController } from "./connection-controller-COkcq48K.mjs";
|
|
15
|
+
import { n as maybeResolveWhatsAppApprovalReaction } from "./approval-reactions-CD6CDF9k.mjs";
|
|
16
|
+
import { t as maybeResolveWhatsAppQuestionReaction } from "./question-reactions-LMeijbaq.mjs";
|
|
17
|
+
import { isRecord, normalizeLowercaseStringOrEmpty, normalizeOptionalString, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
18
|
+
import { createAckReactionHandle, createStatusReactionController, shouldAckReaction } from "openclaw/plugin-sdk/channel-feedback";
|
|
19
19
|
import { bindIngressLifecycleToReplyOptions, createChannelIngressMonitor, createChannelMessageReplyPipeline, createMessageReceiptFromOutboundResults, listMessageReceiptPlatformIds, resolveChannelMessageSourceReplyDeliveryMode, resolveChannelStreamingBlockEnabled } from "openclaw/plugin-sdk/channel-outbound";
|
|
20
20
|
import { formatCliCommand } from "openclaw/plugin-sdk/cli-runtime";
|
|
21
21
|
import { PlatformMessageNotDispatchedError } from "openclaw/plugin-sdk/error-runtime";
|
|
@@ -30,9 +30,11 @@ import { isReasoningReplyPayload, resolveSendableOutboundReplyParts, resolveText
|
|
|
30
30
|
import { normalizeE164, normalizeE164 as normalizeE164$1, normalizeE164 as normalizeE164$2, truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
31
31
|
import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
|
|
32
32
|
import { DisconnectReason, downloadMediaMessage, isHostedLidUser, isHostedPnUser, isJidGroup, isJidGroup as isJidGroup$1, jidDecode, jidEncode, jidNormalizedUser, normalizeMessageContent as normalizeMessageContent$1 } from "baileys";
|
|
33
|
-
import {
|
|
33
|
+
import { pruneMapToMaxSize } from "openclaw/plugin-sdk/collection-runtime";
|
|
34
|
+
import { DEFAULT_MAIN_KEY, buildAgentMainSessionKey, buildAgentSessionKey, buildGroupHistoryKey, deriveLastRoutePolicy, resolveAgentRoute, resolveInboundLastRouteSessionKey } from "openclaw/plugin-sdk/routing";
|
|
34
35
|
import { asDateTimestampMs, parseStrictFiniteNumber, resolveExpiresAtMsFromDurationMs, resolvePromptHistoryLimit } from "openclaw/plugin-sdk/number-runtime";
|
|
35
36
|
import { filterSupplementalContextItems, resolvePinnedMainDmOwnerFromAllowlist } from "openclaw/plugin-sdk/security-runtime";
|
|
37
|
+
import { raceWithTimeout } from "openclaw/plugin-sdk/time-runtime";
|
|
36
38
|
import { resolveChannelGroupPolicy, resolveChannelGroupRequireMention } from "openclaw/plugin-sdk/channel-policy";
|
|
37
39
|
import { createChannelPairingChallengeIssuer } from "openclaw/plugin-sdk/channel-pairing";
|
|
38
40
|
import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
|
|
@@ -42,8 +44,7 @@ import { resolveChunkMode, resolveTextChunkLimit } from "openclaw/plugin-sdk/rep
|
|
|
42
44
|
import { CHANNEL_APPROVAL_NATIVE_RUNTIME_CONTEXT_CAPABILITY } from "openclaw/plugin-sdk/approval-handler-runtime";
|
|
43
45
|
import { drainPendingDeliveries } from "openclaw/plugin-sdk/delivery-queue-runtime";
|
|
44
46
|
import { enqueueSystemEvent } from "openclaw/plugin-sdk/system-event-runtime";
|
|
45
|
-
import { getSessionEntry,
|
|
46
|
-
import { pruneMapToMaxSize } from "openclaw/plugin-sdk/collection-runtime";
|
|
47
|
+
import { getSessionEntry, resolveGroupSessionKey, resolveStorePath, resolveStorePath as resolveStorePath$1, updateLastRoute } from "openclaw/plugin-sdk/session-store-runtime";
|
|
47
48
|
import { createInboundDebouncer, resolveInboundDebounceMs } from "openclaw/plugin-sdk/channel-inbound-debounce";
|
|
48
49
|
import { fanInChannelIngressLifecycles } from "openclaw/plugin-sdk/channel-ingress-runtime";
|
|
49
50
|
import { saveMediaStream } from "openclaw/plugin-sdk/media-store";
|
|
@@ -1488,16 +1489,11 @@ function createWhatsAppMessageDeliveryCoordinator(options) {
|
|
|
1488
1489
|
await durableInboundMonitor.stop();
|
|
1489
1490
|
};
|
|
1490
1491
|
const drainInboundBeforeSocketCloseWithTimeout = async () => {
|
|
1491
|
-
let timeout = null;
|
|
1492
1492
|
try {
|
|
1493
|
-
await
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
}, INBOUND_CLOSE_DRAIN_TIMEOUT_MS);
|
|
1497
|
-
timeout.unref?.();
|
|
1498
|
-
})]);
|
|
1493
|
+
await raceWithTimeout(drainInboundBeforeSocketClose(), INBOUND_CLOSE_DRAIN_TIMEOUT_MS, () => {
|
|
1494
|
+
throw new Error(`Timed out draining WhatsApp inbound debounce after ${INBOUND_CLOSE_DRAIN_TIMEOUT_MS}ms`);
|
|
1495
|
+
}, { ref: false });
|
|
1499
1496
|
} finally {
|
|
1500
|
-
if (timeout) clearTimeout(timeout);
|
|
1501
1497
|
durableInboundMonitor.stop();
|
|
1502
1498
|
}
|
|
1503
1499
|
};
|
|
@@ -1674,7 +1670,7 @@ async function createWhatsAppAttachedSocketSession(options) {
|
|
|
1674
1670
|
const delayMs = computeBackoff(disconnectRetryPolicy, attempt);
|
|
1675
1671
|
options.logVerbose(`Waiting ${delayMs}ms for WhatsApp reconnect before retrying send to ${jid}: ${formatError(lastError)}`);
|
|
1676
1672
|
try {
|
|
1677
|
-
await sleepWithAbort(delayMs, options.disconnectRetryAbortSignal);
|
|
1673
|
+
await sleepWithAbort$1(delayMs, options.disconnectRetryAbortSignal);
|
|
1678
1674
|
} catch {
|
|
1679
1675
|
throw lastError;
|
|
1680
1676
|
}
|
|
@@ -1769,16 +1765,7 @@ async function attachWebInboxToSocket(options) {
|
|
|
1769
1765
|
const inboundLogger = getChildLogger({ module: "web-inbound" });
|
|
1770
1766
|
const inboundConsoleLog = createSubsystemLogger$1("gateway/channels/whatsapp").child("inbound");
|
|
1771
1767
|
const socketSession = await createWhatsAppAttachedSocketSession({
|
|
1772
|
-
|
|
1773
|
-
socketRef: options.socketRef,
|
|
1774
|
-
accountId: options.accountId,
|
|
1775
|
-
authDir: options.authDir,
|
|
1776
|
-
selfChatMode: options.selfChatMode,
|
|
1777
|
-
socketTiming: options.socketTiming,
|
|
1778
|
-
shouldRetryDisconnect: options.shouldRetryDisconnect,
|
|
1779
|
-
disconnectRetryPolicy: options.disconnectRetryPolicy,
|
|
1780
|
-
disconnectRetryAbortSignal: options.disconnectRetryAbortSignal,
|
|
1781
|
-
recentMessageKeys: options.recentMessageKeys,
|
|
1768
|
+
...options,
|
|
1782
1769
|
logVerbose: (message) => logWhatsAppVerbose(options.verbose, message),
|
|
1783
1770
|
logConnectionError: (error) => {
|
|
1784
1771
|
inboundLogger.error({ error: String(error) }, "connection.update handler error");
|
|
@@ -1798,21 +1785,9 @@ async function attachWebInboxToSocket(options) {
|
|
|
1798
1785
|
}
|
|
1799
1786
|
});
|
|
1800
1787
|
const delivery = createWhatsAppMessageDeliveryCoordinator({
|
|
1801
|
-
|
|
1802
|
-
loadConfig: options.loadConfig,
|
|
1803
|
-
verbose: options.verbose,
|
|
1804
|
-
accountId: options.accountId,
|
|
1805
|
-
sock: options.sock,
|
|
1788
|
+
...options,
|
|
1806
1789
|
socketSession,
|
|
1807
|
-
groupMetadata
|
|
1808
|
-
onMessage: options.onMessage,
|
|
1809
|
-
mediaMaxMb: options.mediaMaxMb,
|
|
1810
|
-
sendReadReceipts: options.sendReadReceipts,
|
|
1811
|
-
debounceMs: options.debounceMs,
|
|
1812
|
-
appendReplyWindow: options.appendReplyWindow,
|
|
1813
|
-
shouldDebounce: options.shouldDebounce,
|
|
1814
|
-
onPendingWorkChanged: options.onPendingWorkChanged,
|
|
1815
|
-
durableInboundQueue: options.durableInboundQueue
|
|
1790
|
+
groupMetadata
|
|
1816
1791
|
});
|
|
1817
1792
|
const sendApi = createWebSendApi({
|
|
1818
1793
|
sock: socketSession.socketOperations,
|
|
@@ -2055,15 +2030,8 @@ function isBotMentionedFromTargets(msg, mentionCfg, targets) {
|
|
|
2055
2030
|
const bodyClean = (0, channel_mention_gating_exports.normalizeMentionText)(msg.payload.body);
|
|
2056
2031
|
if (mentionCfg.mentionRegexes.some((re) => re.test(bodyClean))) return true;
|
|
2057
2032
|
if (hasNativeMentionsOutsideSelfChat) return false;
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
if (selfDigits) {
|
|
2061
|
-
if (bodyClean.replace(/[^\d]/g, "").includes(selfDigits)) return true;
|
|
2062
|
-
const bodyNoSpace = msg.payload.body.replace(/[\s-]/g, "");
|
|
2063
|
-
if (new RegExp(`\\+?${selfDigits}`, "i").test(bodyNoSpace)) return true;
|
|
2064
|
-
}
|
|
2065
|
-
}
|
|
2066
|
-
return false;
|
|
2033
|
+
const selfDigits = targets.self.e164?.replace(/\D/g, "");
|
|
2034
|
+
return Boolean(selfDigits && bodyClean.replace(/\D/g, "").includes(selfDigits));
|
|
2067
2035
|
}
|
|
2068
2036
|
function debugMention(msg, mentionCfg, authDir) {
|
|
2069
2037
|
const mentionTargets = {
|
|
@@ -2094,57 +2062,22 @@ function resolveOwnerList(mentionCfg, selfE164) {
|
|
|
2094
2062
|
const DEFAULT_WHATSAPP_ACK_REACTION = "👀";
|
|
2095
2063
|
function resolveWhatsAppAckEmoji(params) {
|
|
2096
2064
|
if (!params.ackConfig) return "";
|
|
2097
|
-
return (typeof params.ackConfig === "string" ? params.ackConfig : params.ackConfig.emoji)?.trim() ||
|
|
2098
|
-
}
|
|
2099
|
-
function resolveAgentIdentityEmoji(cfg, agentId) {
|
|
2100
|
-
return resolveAgentIdentity(cfg, agentId)?.emoji?.trim() || void 0;
|
|
2065
|
+
return (typeof params.ackConfig === "string" ? params.ackConfig : params.ackConfig.emoji)?.trim() || resolveAgentIdentity(params.cfg, params.agentId)?.emoji?.trim() || DEFAULT_WHATSAPP_ACK_REACTION;
|
|
2101
2066
|
}
|
|
2102
2067
|
//#endregion
|
|
2103
2068
|
//#region extensions/whatsapp/src/auto-reply/monitor/group-activation.ts
|
|
2104
|
-
function hasNamedWhatsAppAccounts(cfg) {
|
|
2105
|
-
return Object.keys(cfg.channels?.whatsapp?.accounts ?? {}).some((accountId) => normalizeAccountId(accountId) !== DEFAULT_ACCOUNT_ID);
|
|
2106
|
-
}
|
|
2107
|
-
function isActivationOnlyEntry(entry) {
|
|
2108
|
-
return entry?.groupActivation !== void 0 && typeof entry?.sessionId !== "string" && typeof entry?.updatedAt !== "number";
|
|
2109
|
-
}
|
|
2110
|
-
/** Resolves group activation for a WhatsApp conversation and backfills scoped session metadata. */
|
|
2111
2069
|
async function resolveGroupActivationFor(params) {
|
|
2112
|
-
const
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
const legacySessionKey = resolveWhatsAppLegacyGroupSessionKey({
|
|
2117
|
-
sessionKey: params.sessionKey,
|
|
2118
|
-
accountId: params.accountId
|
|
2119
|
-
});
|
|
2120
|
-
const legacyEntry = legacySessionKey ? getSessionEntry({
|
|
2121
|
-
...sessionScope,
|
|
2122
|
-
sessionKey: legacySessionKey
|
|
2123
|
-
}) : void 0;
|
|
2124
|
-
const scopedEntry = getSessionEntry({
|
|
2125
|
-
...sessionScope,
|
|
2070
|
+
const storePath = resolveStorePath(params.cfg.session?.store, { agentId: params.agentId });
|
|
2071
|
+
const entry = getSessionEntry({
|
|
2072
|
+
storePath,
|
|
2073
|
+
agentId: params.agentId,
|
|
2126
2074
|
sessionKey: params.sessionKey
|
|
2127
2075
|
});
|
|
2128
|
-
const activation = (normalizeAccountId(params.accountId) === DEFAULT_ACCOUNT_ID && hasNamedWhatsAppAccounts(params.cfg) && isActivationOnlyEntry(scopedEntry) ? void 0 : scopedEntry?.groupActivation) ?? legacyEntry?.groupActivation;
|
|
2129
|
-
if (activation !== void 0 && scopedEntry?.groupActivation === void 0) {
|
|
2130
|
-
if (scopedEntry) await patchSessionEntry({
|
|
2131
|
-
...sessionScope,
|
|
2132
|
-
sessionKey: params.sessionKey,
|
|
2133
|
-
replaceEntry: true,
|
|
2134
|
-
update: (entry) => {
|
|
2135
|
-
if (entry.groupActivation !== void 0) return null;
|
|
2136
|
-
return {
|
|
2137
|
-
...entry,
|
|
2138
|
-
groupActivation: activation
|
|
2139
|
-
};
|
|
2140
|
-
}
|
|
2141
|
-
});
|
|
2142
|
-
}
|
|
2143
2076
|
const defaultActivation = !resolveWhatsAppInboundPolicy({
|
|
2144
2077
|
cfg: params.cfg,
|
|
2145
2078
|
accountId: params.accountId
|
|
2146
2079
|
}).resolveConversationRequireMention(params.conversationId) ? "always" : "mention";
|
|
2147
|
-
return normalizeGroupActivation(
|
|
2080
|
+
return normalizeGroupActivation(entry?.groupActivation) ?? defaultActivation;
|
|
2148
2081
|
}
|
|
2149
2082
|
//#endregion
|
|
2150
2083
|
//#region extensions/whatsapp/src/auto-reply/monitor/reaction-participant.ts
|
|
@@ -2346,17 +2279,9 @@ function stripMentionsForCommand(text, mentionRegexes, selfE164) {
|
|
|
2346
2279
|
}
|
|
2347
2280
|
//#endregion
|
|
2348
2281
|
//#region extensions/whatsapp/src/auto-reply/monitor/group-members.ts
|
|
2349
|
-
function appendNormalizedUnique(entries, seen, ordered) {
|
|
2350
|
-
for (const entry of entries) {
|
|
2351
|
-
const normalized = normalizeE164(entry) ?? entry;
|
|
2352
|
-
if (!normalized || seen.has(normalized)) continue;
|
|
2353
|
-
seen.add(normalized);
|
|
2354
|
-
ordered.push(normalized);
|
|
2355
|
-
}
|
|
2356
|
-
}
|
|
2357
2282
|
function noteGroupMember(groupMemberNames, conversationId, e164, name) {
|
|
2358
2283
|
if (!e164 || !name) return;
|
|
2359
|
-
const key = normalizeE164(e164)
|
|
2284
|
+
const key = normalizeE164(e164);
|
|
2360
2285
|
if (!key) return;
|
|
2361
2286
|
let roster = groupMemberNames.get(conversationId);
|
|
2362
2287
|
if (!roster) {
|
|
@@ -2367,12 +2292,9 @@ function noteGroupMember(groupMemberNames, conversationId, e164, name) {
|
|
|
2367
2292
|
}
|
|
2368
2293
|
function formatGroupMembers(params) {
|
|
2369
2294
|
const { participants, roster, fallbackE164 } = params;
|
|
2370
|
-
const
|
|
2371
|
-
const ordered = [];
|
|
2372
|
-
if (participants?.length) appendNormalizedUnique(participants, seen, ordered);
|
|
2373
|
-
if (roster) appendNormalizedUnique(roster.keys(), seen, ordered);
|
|
2295
|
+
const ordered = uniqueStrings([...participants ?? [], ...roster?.keys() ?? []].map(normalizeE164).filter(Boolean));
|
|
2374
2296
|
if (ordered.length === 0 && fallbackE164) {
|
|
2375
|
-
const normalized = normalizeE164(fallbackE164)
|
|
2297
|
+
const normalized = normalizeE164(fallbackE164);
|
|
2376
2298
|
if (normalized) ordered.push(normalized);
|
|
2377
2299
|
}
|
|
2378
2300
|
if (ordered.length === 0) return;
|
|
@@ -2392,7 +2314,8 @@ function isOwnerSender(baseMentionConfig, msg, authDir) {
|
|
|
2392
2314
|
if (!sender) return false;
|
|
2393
2315
|
return resolveOwnerList(baseMentionConfig, getSelfIdentity(msg, authDir).e164 ?? void 0).includes(sender);
|
|
2394
2316
|
}
|
|
2395
|
-
function
|
|
2317
|
+
function skipGroupMessageAndStoreHistory(params, verboseMessage, body) {
|
|
2318
|
+
params.logVerbose(verboseMessage);
|
|
2396
2319
|
const senderIdentity = getSenderIdentity(params.msg);
|
|
2397
2320
|
const sender = senderIdentity.name && senderIdentity.e164 ? `${senderIdentity.name} (${senderIdentity.e164})` : senderIdentity.name ?? senderIdentity.e164 ?? getPrimaryIdentityId(senderIdentity) ?? "Unknown";
|
|
2398
2321
|
createChannelHistoryWindow({ historyMap: params.groupHistories }).record({
|
|
@@ -2400,7 +2323,7 @@ function recordPendingGroupHistoryEntry(params) {
|
|
|
2400
2323
|
limit: params.groupHistoryLimit,
|
|
2401
2324
|
entry: {
|
|
2402
2325
|
sender,
|
|
2403
|
-
body:
|
|
2326
|
+
body: body ?? params.msg.payload.body,
|
|
2404
2327
|
timestamp: params.msg.event.timestamp,
|
|
2405
2328
|
id: params.msg.event.id,
|
|
2406
2329
|
senderJid: senderIdentity.jid ?? params.msg.platform.senderJid,
|
|
@@ -2412,16 +2335,6 @@ function recordPendingGroupHistoryEntry(params) {
|
|
|
2412
2335
|
}] } : {}
|
|
2413
2336
|
}
|
|
2414
2337
|
});
|
|
2415
|
-
}
|
|
2416
|
-
function skipGroupMessageAndStoreHistory(params, verboseMessage, body) {
|
|
2417
|
-
params.logVerbose(verboseMessage);
|
|
2418
|
-
recordPendingGroupHistoryEntry({
|
|
2419
|
-
msg: params.msg,
|
|
2420
|
-
body,
|
|
2421
|
-
groupHistories: params.groupHistories,
|
|
2422
|
-
groupHistoryKey: params.groupHistoryKey,
|
|
2423
|
-
groupHistoryLimit: params.groupHistoryLimit
|
|
2424
|
-
});
|
|
2425
2338
|
return { shouldProcess: false };
|
|
2426
2339
|
}
|
|
2427
2340
|
async function applyGroupGating(params) {
|
|
@@ -2659,7 +2572,7 @@ function elide(text, limit = 400) {
|
|
|
2659
2572
|
return `${truncated}… (truncated ${text.length - truncated.length} chars)`;
|
|
2660
2573
|
}
|
|
2661
2574
|
function markWhatsAppVisibleDeliveryError(error) {
|
|
2662
|
-
if (
|
|
2575
|
+
if (isRecord(error)) try {
|
|
2663
2576
|
Object.assign(error, {
|
|
2664
2577
|
sentBeforeError: true,
|
|
2665
2578
|
visibleReplySent: true
|
|
@@ -3062,10 +2975,7 @@ function createWhatsAppChannelDeliveryResult(params) {
|
|
|
3062
2975
|
};
|
|
3063
2976
|
}
|
|
3064
2977
|
function isWhatsAppVisibleDeliveryError(error) {
|
|
3065
|
-
return
|
|
3066
|
-
}
|
|
3067
|
-
function readTrimmedString(value) {
|
|
3068
|
-
return normalizeOptionalString(value) ?? "";
|
|
2978
|
+
return isRecord(error) && error.visibleReplySent === true || isChannelPartialDeliveryError(error) && error.deliveryResult.visibleReplySent;
|
|
3069
2979
|
}
|
|
3070
2980
|
function markWhatsAppReplyDeliveryErrorVisibleAfterFlush(error, flushResult) {
|
|
3071
2981
|
if (flushResult.delivered === 0) return error;
|
|
@@ -3086,10 +2996,10 @@ function logWhatsAppReplyDeliveryError(params) {
|
|
|
3086
2996
|
}
|
|
3087
2997
|
function resolveWhatsAppDurableReplyToId(params) {
|
|
3088
2998
|
if (params.payload.replyToId === null) return null;
|
|
3089
|
-
const explicitPayloadReplyToId =
|
|
2999
|
+
const explicitPayloadReplyToId = normalizeOptionalString(params.payload.replyToId);
|
|
3090
3000
|
if (explicitPayloadReplyToId) return explicitPayloadReplyToId;
|
|
3091
|
-
const hasVisibleInboundReplyTarget = Boolean(
|
|
3092
|
-
const currentInboundMessageId =
|
|
3001
|
+
const hasVisibleInboundReplyTarget = Boolean(normalizeOptionalString(params.context.ReplyToId)) || Boolean(normalizeOptionalString(params.context.ReplyToIdFull));
|
|
3002
|
+
const currentInboundMessageId = normalizeOptionalString(params.currentMessageId);
|
|
3093
3003
|
if (params.info.kind === "final" && hasVisibleInboundReplyTarget && currentInboundMessageId) return currentInboundMessageId;
|
|
3094
3004
|
return null;
|
|
3095
3005
|
}
|
|
@@ -3689,30 +3599,22 @@ async function processMessage(params) {
|
|
|
3689
3599
|
}) : void 0;
|
|
3690
3600
|
if (conversationKind === "group") {
|
|
3691
3601
|
const history = visibleGroupHistory ?? [];
|
|
3692
|
-
if (history.length > 0) {
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
body: [entry.body, formatMediaPlaceholderText(entry.media ?? [])].filter(Boolean).join("\n"),
|
|
3709
|
-
chatType: "group",
|
|
3710
|
-
senderLabel: entry.sender,
|
|
3711
|
-
envelope: envelopeOptions
|
|
3712
|
-
});
|
|
3713
|
-
}
|
|
3714
|
-
});
|
|
3715
|
-
}
|
|
3602
|
+
if (history.length > 0) combinedBody = buildHistoryContextFromEntries({
|
|
3603
|
+
entries: history,
|
|
3604
|
+
currentMessage: combinedBody,
|
|
3605
|
+
excludeLast: false,
|
|
3606
|
+
formatEntry: (entry) => {
|
|
3607
|
+
return formatInboundEnvelope$1({
|
|
3608
|
+
channel: "WhatsApp",
|
|
3609
|
+
from: conversationId,
|
|
3610
|
+
timestamp: entry.timestamp,
|
|
3611
|
+
body: [entry.body, formatMediaPlaceholderText(entry.media ?? [])].filter(Boolean).join("\n"),
|
|
3612
|
+
chatType: "group",
|
|
3613
|
+
senderLabel: entry.sender,
|
|
3614
|
+
envelope: envelopeOptions
|
|
3615
|
+
});
|
|
3616
|
+
}
|
|
3617
|
+
});
|
|
3716
3618
|
}
|
|
3717
3619
|
const statusReactionController = params.statusReactionController ?? (params.cfg.messages?.statusReactions?.enabled === true && !params.ackAlreadySent ? await createWhatsAppStatusReactionController({
|
|
3718
3620
|
cfg: params.cfg,
|
|
@@ -3722,8 +3624,7 @@ async function processMessage(params) {
|
|
|
3722
3624
|
verbose: params.verbose
|
|
3723
3625
|
}) : null);
|
|
3724
3626
|
if (statusReactionController && !params.statusReactionController) statusReactionController.setQueued();
|
|
3725
|
-
|
|
3726
|
-
if (!statusReactionController && !ackReaction && params.ackAlreadySent !== true) ackReaction = await maybeSendAckReaction({
|
|
3627
|
+
if (!statusReactionController && !params.ackReaction && params.ackAlreadySent !== true) await maybeSendAckReaction({
|
|
3727
3628
|
cfg: params.cfg,
|
|
3728
3629
|
msg: params.msg,
|
|
3729
3630
|
agentId: params.route.agentId,
|
|
@@ -3895,20 +3796,7 @@ async function processMessage(params) {
|
|
|
3895
3796
|
}
|
|
3896
3797
|
}
|
|
3897
3798
|
});
|
|
3898
|
-
|
|
3899
|
-
removeAckReactionHandleAfterReply({
|
|
3900
|
-
removeAfterReply: false,
|
|
3901
|
-
ackReaction,
|
|
3902
|
-
onError: (err) => {
|
|
3903
|
-
logAckFailure({
|
|
3904
|
-
log: logVerbose$1,
|
|
3905
|
-
channel: "whatsapp",
|
|
3906
|
-
target: `${params.msg.platform.chatJid ?? conversationId}/${params.msg.event.id ?? "unknown"}`,
|
|
3907
|
-
error: err
|
|
3908
|
-
});
|
|
3909
|
-
}
|
|
3910
|
-
});
|
|
3911
|
-
return didSendReply;
|
|
3799
|
+
return turnResult.dispatched ? finalizeReply?.(turnResult.dispatchResult) ?? false : false;
|
|
3912
3800
|
}
|
|
3913
3801
|
//#endregion
|
|
3914
3802
|
//#region extensions/whatsapp/src/auto-reply/monitor/on-message.ts
|
|
@@ -3931,21 +3819,12 @@ function createWebOnMessageHandler(params) {
|
|
|
3931
3819
|
};
|
|
3932
3820
|
const processForRoute = async (cfg, msg, route, groupHistoryKey, opts) => {
|
|
3933
3821
|
return processMessage({
|
|
3822
|
+
...params,
|
|
3934
3823
|
cfg,
|
|
3935
3824
|
msg,
|
|
3936
3825
|
route,
|
|
3937
3826
|
groupHistoryKey,
|
|
3938
|
-
groupHistories: params.groupHistories,
|
|
3939
|
-
groupHistoryLimit: params.groupHistoryLimit,
|
|
3940
|
-
groupMemberNames: params.groupMemberNames,
|
|
3941
|
-
connectionId: params.connectionId,
|
|
3942
|
-
verbose: params.verbose,
|
|
3943
|
-
maxMediaBytes: params.maxMediaBytes,
|
|
3944
|
-
replyResolver: params.replyResolver,
|
|
3945
|
-
replyLogger: params.replyLogger,
|
|
3946
|
-
backgroundTasks: params.backgroundTasks,
|
|
3947
3827
|
buildContext: params.buildContext,
|
|
3948
|
-
dispatchReplyFromConfig: params.dispatchReplyFromConfig,
|
|
3949
3828
|
...opts
|
|
3950
3829
|
});
|
|
3951
3830
|
};
|
|
@@ -4217,8 +4096,8 @@ async function monitorWebChannel(verbose, listenerFactory = attachWebInboxToSock
|
|
|
4217
4096
|
accountId: account.accountId
|
|
4218
4097
|
}).cfg;
|
|
4219
4098
|
const maxMediaBytes = resolveWhatsAppMediaMaxBytes(account);
|
|
4220
|
-
const heartbeatSeconds = resolveHeartbeatSeconds(
|
|
4221
|
-
const reconnectPolicy = resolveReconnectPolicy(
|
|
4099
|
+
const heartbeatSeconds = resolveHeartbeatSeconds(tuning.heartbeatSeconds);
|
|
4100
|
+
const reconnectPolicy = resolveReconnectPolicy(tuning.reconnect);
|
|
4222
4101
|
const socketTiming = resolveWhatsAppSocketTiming(tuning.socketTiming);
|
|
4223
4102
|
const groupHistoryLimit = resolvePromptHistoryLimit(account.historyLimit ?? cfg.channels?.whatsapp?.historyLimit ?? cfg.messages?.groupChat?.historyLimit);
|
|
4224
4103
|
const groupHistories = /* @__PURE__ */ new Map();
|
|
@@ -4226,7 +4105,7 @@ async function monitorWebChannel(verbose, listenerFactory = attachWebInboxToSock
|
|
|
4226
4105
|
const groupMetadataCache = /* @__PURE__ */ new Map();
|
|
4227
4106
|
const recentMessageKeys = /* @__PURE__ */ new Map();
|
|
4228
4107
|
const baileysGroupMetaCache = /* @__PURE__ */ new Map();
|
|
4229
|
-
const sleep = tuning.sleep ?? ((ms, signal) => sleepWithAbort(ms, signal ?? abortSignal));
|
|
4108
|
+
const sleep = tuning.sleep ?? ((ms, signal) => sleepWithAbort$1(ms, signal ?? abortSignal));
|
|
4230
4109
|
const stopRequested = () => abortSignal?.aborted === true;
|
|
4231
4110
|
const currentMaxListeners = process.getMaxListeners?.() ?? 10;
|
|
4232
4111
|
if (process.setMaxListeners && currentMaxListeners < 50) process.setMaxListeners(50);
|