@openclaw/whatsapp 2026.8.1 → 2026.8.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/{action-runtime-YA_Yvunu.js → action-runtime-Bw0loEdy.js} +1 -1
- package/dist/action-runtime-api.js +1 -1
- package/dist/action-runtime.runtime.js +1 -1
- package/dist/agent-tools-api.js +2 -2
- package/dist/api.js +9 -9
- package/dist/{approval-handler.runtime-C7jZ8rsD.js → approval-handler.runtime-DeyPb57-.js} +2 -2
- package/dist/{approval-reactions-rpaNVHzZ.js → approval-reactions-DGDA6hQ7.js} +6 -4
- package/dist/{auth-store-CtpBqH5S.js → auth-store-DTj1H9pv.js} +5 -3
- package/dist/{channel-Dx09AAmX.js → channel-DxMmDjqK.js} +23 -19
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel-react-action-n9a8Hk5i.js → channel-react-action-BUp7Wbfr.js} +2 -2
- package/dist/{channel.runtime-D_PjmeMT.js → channel.runtime-BwSnyXRX.js} +4 -4
- package/dist/{channel.setup-CRJQiWbh.js → channel.setup-aOFLSQyw.js} +1 -1
- package/dist/{config-schema-BQP5YCeK.js → config-schema-BYA6e_Ii.js} +6 -4
- package/dist/{connection-controller-CIYuBJrs.js → connection-controller-BvkxsbWi.js} +2 -2
- package/dist/{constants-HU41RHGI.js → constants-C7m81BNe.js} +1 -1
- package/dist/{directory-config-Ci8Jjsw4.js → directory-config-LgxYJLWY.js} +2 -2
- package/dist/directory-contract-api.js +1 -1
- package/dist/{group-session-key-CH9jJIVQ.js → group-session-key-KUguLmSZ.js} +3 -3
- package/dist/light-runtime-api.js +1 -1
- package/dist/{login-1u5WcfTn.js → login-Bk_jiXKD.js} +5 -4
- package/dist/{login-qr-B_1sr0hk.js → login-qr-B3m61NqA.js} +8 -6
- package/dist/login-qr-runtime.js +1 -1
- package/dist/{monitor-CySzv38g.js → monitor-CTsyo-HE.js} +77 -61
- package/dist/runtime-api.js +8 -8
- package/dist/{send-C3S-NqyO.js → send-DiPjiygK.js} +52 -27
- package/dist/{send-api-C-FFC1p_.js → send-api-kFcuhSiY.js} +42 -40
- package/dist/{setup-finalize-CRzMpx84.js → setup-finalize-CqH5wTK5.js} +5 -4
- package/dist/setup-plugin-api.js +1 -1
- package/dist/{setup-surface-ym4doiv3.js → setup-surface-Dm3T6S8t.js} +2 -2
- package/dist/{shared-D3B14d45.js → shared-DDjonGys.js} +6 -5
- package/dist/{socket-close-2T0_jZTN.js → socket-close-CpkkJZCU.js} +9 -6
- package/dist/{targets-runtime-TMk0lGuy.js → targets-runtime-RBjx3pg_.js} +1 -2
- package/dist/{text-runtime-CaKLhowd.js → text-runtime-DyfmcATV.js} +1 -1
- package/node_modules/baileys/node_modules/process-warning/.github/dependabot.yml +42 -2
- package/node_modules/baileys/node_modules/process-warning/.github/workflows/ci.yml +12 -1
- package/node_modules/baileys/node_modules/process-warning/.github/workflows/lock-threads.yml +19 -0
- package/node_modules/baileys/node_modules/process-warning/LICENSE +1 -1
- package/node_modules/baileys/node_modules/process-warning/README.md +41 -2
- package/node_modules/baileys/node_modules/process-warning/index.js +85 -17
- package/node_modules/baileys/node_modules/process-warning/package.json +6 -7
- package/node_modules/baileys/node_modules/process-warning/test/emit-once-only.test.js +3 -3
- package/node_modules/baileys/node_modules/process-warning/test/emit-reset.test.js +4 -4
- package/node_modules/baileys/node_modules/process-warning/test/emit-unlimited.test.js +2 -2
- package/node_modules/baileys/node_modules/process-warning/test/spy-warning.test.js +143 -0
- package/node_modules/baileys/node_modules/process-warning/types/index.d.ts +15 -1
- package/node_modules/baileys/node_modules/process-warning/types/index.tst.ts +48 -0
- package/node_modules/baileys/node_modules/ws/lib/permessage-deflate.js +3 -1
- package/node_modules/baileys/node_modules/ws/package.json +1 -1
- package/node_modules/typebox/build/format/email.mjs +1 -1
- package/node_modules/typebox/build/format/idna/idn-hostname.mjs +19 -1
- package/node_modules/typebox/package.json +1 -1
- package/package.json +5 -5
- package/node_modules/baileys/node_modules/process-warning/types/index.test-d.ts +0 -36
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
import { a as resolveWhatsAppAccount, s as resolveWhatsAppMediaMaxBytes } from "./accounts-CeKQbu_s.js";
|
|
2
|
-
import { c as normalizeWhatsAppPayloadTextPreservingIndentation, d as listWhatsAppSendResultMessageIds, f as mergeWhatsAppAcceptedSendError, g as withWhatsAppLogicalDeliveryActivity, h as rememberWhatsAppPartialSend, l as prepareWhatsAppOutboundMedia, m as rememberWhatsAppAcceptedSend, o as normalizeWhatsAppOutboundPayload, p as normalizeWhatsAppSendResult, r as sendReactionWhatsApp, v as resolveWhatsAppReactionLevel } from "./send-
|
|
2
|
+
import { c as normalizeWhatsAppPayloadTextPreservingIndentation, d as listWhatsAppSendResultMessageIds, f as mergeWhatsAppAcceptedSendError, g as withWhatsAppLogicalDeliveryActivity, h as rememberWhatsAppPartialSend, l as prepareWhatsAppOutboundMedia, m as rememberWhatsAppAcceptedSend, o as normalizeWhatsAppOutboundPayload, p as normalizeWhatsAppSendResult, r as sendReactionWhatsApp, v as resolveWhatsAppReactionLevel } from "./send-DiPjiygK.js";
|
|
3
3
|
import { i as getWhatsAppRuntime } from "./runtime-BLlToOi6.js";
|
|
4
4
|
import { r as getWhatsAppConnectionController } from "./connection-controller-runtime-context-DG0tuYuw.js";
|
|
5
|
-
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-
|
|
6
|
-
import { t as normalizeE164 } from "./text-runtime-
|
|
7
|
-
import { a as cacheInboundMessageMeta, i as buildQuotedMessageOptions, n as resolveWhatsAppGroupSessionRoute, o as lookupInboundMessageMeta, r as resolveWhatsAppLegacyGroupSessionKey } from "./group-session-key-
|
|
8
|
-
import { C as getMentionIdentities, D as getSenderIdentity, E as getSelfIdentity, O as identitiesOverlap, S as getComparableIdentityValues, T as getReplyContext, g as readWebSelfId, k as resolveComparableIdentity, o as getWebAuthAgeMs, r as WhatsAppAuthUnstableError, v as readWebSelfIdentityForDecision, w as getPrimaryIdentityId } from "./auth-store-
|
|
5
|
+
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-RBjx3pg_.js";
|
|
6
|
+
import { t as normalizeE164 } from "./text-runtime-DyfmcATV.js";
|
|
7
|
+
import { a as cacheInboundMessageMeta, i as buildQuotedMessageOptions, n as resolveWhatsAppGroupSessionRoute, o as lookupInboundMessageMeta, r as resolveWhatsAppLegacyGroupSessionKey } from "./group-session-key-KUguLmSZ.js";
|
|
8
|
+
import { C as getMentionIdentities, D as getSenderIdentity, E as getSelfIdentity, O as identitiesOverlap, S as getComparableIdentityValues, T as getReplyContext, g as readWebSelfId, k as resolveComparableIdentity, o as getWebAuthAgeMs, r as WhatsAppAuthUnstableError, v as readWebSelfIdentityForDecision, w as getPrimaryIdentityId } from "./auth-store-DTj1H9pv.js";
|
|
9
9
|
import { n as resolveWhatsAppGroupsConfigPath } from "./group-config-path-BGyzT9Lg.js";
|
|
10
|
-
import { a as waitForWaConnection, c as isWhatsAppSocketOperationTimeoutError, d as withWhatsAppSocketOperationTimeout, l as resolveWhatsAppSocketOperationTimeoutMs, r as createWaSocket, s as createWhatsAppSocketOperationTimeoutAdapter, u as resolveWhatsAppSocketTiming } from "./socket-close-
|
|
10
|
+
import { a as waitForWaConnection, c as isWhatsAppSocketOperationTimeoutError, d as withWhatsAppSocketOperationTimeout, l as resolveWhatsAppSocketOperationTimeoutMs, r as createWaSocket, s as createWhatsAppSocketOperationTimeoutAdapter, u as resolveWhatsAppSocketTiming } from "./socket-close-CpkkJZCU.js";
|
|
11
11
|
import { n as getStatusCode, t as formatError } from "./session-errors-JuazczrA.js";
|
|
12
12
|
import { t as BufferJSON } from "./session.runtime-Nsqaehbd.js";
|
|
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-
|
|
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-kFcuhSiY.js";
|
|
14
14
|
import { t as resolveWhatsAppRuntimeGroupPolicy } from "./runtime-group-policy-DeSRFXEV.js";
|
|
15
|
-
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-
|
|
16
|
-
import { n as maybeResolveWhatsAppApprovalReaction } from "./approval-reactions-
|
|
15
|
+
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-BvkxsbWi.js";
|
|
16
|
+
import { n as maybeResolveWhatsAppApprovalReaction } from "./approval-reactions-DGDA6hQ7.js";
|
|
17
17
|
import { t as maybeResolveWhatsAppQuestionReaction } from "./question-reactions-B9D6MHXZ.js";
|
|
18
18
|
import { normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
19
19
|
import { filterSupplementalContextItems, resolvePinnedMainDmOwnerFromAllowlist } from "openclaw/plugin-sdk/security-runtime";
|
|
20
20
|
import { createAckReactionHandle, createStatusReactionController, logAckFailure, removeAckReactionHandleAfterReply, shouldAckReaction } from "openclaw/plugin-sdk/channel-feedback";
|
|
21
|
+
import { bindIngressLifecycleToReplyOptions, createChannelIngressMonitor, createChannelMessageReplyPipeline, createMessageReceiptFromOutboundResults, listMessageReceiptPlatformIds, resolveChannelMessageSourceReplyDeliveryMode, resolveChannelStreamingBlockEnabled } from "openclaw/plugin-sdk/channel-outbound";
|
|
21
22
|
import { formatCliCommand } from "openclaw/plugin-sdk/cli-runtime";
|
|
22
23
|
import { PlatformMessageNotDispatchedError } from "openclaw/plugin-sdk/error-runtime";
|
|
23
24
|
import { createSubsystemLogger, getChildLogger, redactToolPayloadText } from "openclaw/plugin-sdk/logging-core";
|
|
@@ -26,7 +27,6 @@ import { createSubsystemLogger as createSubsystemLogger$1, defaultRuntime, forma
|
|
|
26
27
|
import { registerChannelRuntimeContext } from "openclaw/plugin-sdk/channel-runtime-context";
|
|
27
28
|
import { recordChannelActivity } from "openclaw/plugin-sdk/channel-activity-runtime";
|
|
28
29
|
import { buildChannelInboundEventContext, createChannelPartialDeliveryError, filterChannelInboundQuoteContext, formatInboundEnvelope, formatInboundEnvelope as formatInboundEnvelope$1, formatInboundMediaUnavailableText, formatLocationText, formatMediaPlaceholderText, hasVisibleInboundReplyDispatch, isChannelPartialDeliveryError, readAgentRunTerminalOutcome, resolveInboundSessionEnvelopeContext, resolveInboundSupplementalSenderAllowed, runChannelInboundEvent, shouldDebounceTextInbound, toInboundMediaFactsWithMetadata, toLocationContext } from "openclaw/plugin-sdk/channel-inbound";
|
|
29
|
-
import { bindIngressLifecycleToReplyOptions, createChannelIngressMonitor, createChannelMessageReplyPipeline, createMessageReceiptFromOutboundResults, listMessageReceiptPlatformIds, resolveChannelMessageSourceReplyDeliveryMode, resolveChannelStreamingBlockEnabled } from "openclaw/plugin-sdk/channel-outbound";
|
|
30
30
|
import { getAgentScopedMediaLocalRoots } from "openclaw/plugin-sdk/media-runtime";
|
|
31
31
|
import { isReasoningReplyPayload, resolveSendableOutboundReplyParts, resolveTextChunksWithFallback, sendMediaWithLeadingCaption } from "openclaw/plugin-sdk/reply-payload";
|
|
32
32
|
import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
@@ -357,7 +357,7 @@ function createWhatsAppIngressMonitor(params) {
|
|
|
357
357
|
deliver: (admission, lifecycle) => params.dispatch(admission, lifecycle),
|
|
358
358
|
pollIntervalMs: params.pollIntervalMs,
|
|
359
359
|
retention: {
|
|
360
|
-
completedTtlMs:
|
|
360
|
+
completedTtlMs: 6048e5,
|
|
361
361
|
completedMaxEntries: 5e3,
|
|
362
362
|
failedMaxEntries: 450
|
|
363
363
|
},
|
|
@@ -381,7 +381,7 @@ function createWhatsAppIngressMonitor(params) {
|
|
|
381
381
|
}
|
|
382
382
|
//#endregion
|
|
383
383
|
//#region extensions/whatsapp/src/inbound/group-metadata-cache.ts
|
|
384
|
-
const GROUP_META_TTL_MS =
|
|
384
|
+
const GROUP_META_TTL_MS = 3e5;
|
|
385
385
|
const WHATSAPP_GROUP_METADATA_CACHE_MAX_ENTRIES = 500;
|
|
386
386
|
function resolveGroupMetadataExpiresAt(nowRaw = Date.now()) {
|
|
387
387
|
const now = asDateTimestampMs(nowRaw);
|
|
@@ -498,10 +498,11 @@ function createWhatsAppGroupMetadataCacheOwner(params) {
|
|
|
498
498
|
text,
|
|
499
499
|
mentionedJids: []
|
|
500
500
|
};
|
|
501
|
+
const meta = await get(jid);
|
|
501
502
|
return resolveWhatsAppOutboundMentions({
|
|
502
503
|
chatJid: jid,
|
|
503
504
|
text,
|
|
504
|
-
participants:
|
|
505
|
+
participants: meta.mentionParticipants
|
|
505
506
|
});
|
|
506
507
|
};
|
|
507
508
|
const applyOutboundMentions = async (jid, content) => {
|
|
@@ -748,26 +749,28 @@ function createWhatsAppInboundMessageDebouncer(options) {
|
|
|
748
749
|
function unwrapMessage(message) {
|
|
749
750
|
return normalizeMessageContent$1(message);
|
|
750
751
|
}
|
|
751
|
-
async function downloadInboundMedia(msg, sock, maxBytes =
|
|
752
|
+
async function downloadInboundMedia(msg, sock, maxBytes = 52428800, normalizedMessage) {
|
|
752
753
|
const message = normalizedMessage ?? unwrapMessage(msg.message);
|
|
753
754
|
if (!message) return;
|
|
754
755
|
const mimetype = resolveInboundMediaMimetype(message);
|
|
755
756
|
const fileName = message.documentMessage?.fileName ?? void 0;
|
|
756
757
|
if (!message.imageMessage && !message.videoMessage && !message.ptvMessage && !message.documentMessage && !message.audioMessage && !message.stickerMessage) return;
|
|
758
|
+
const stream = await downloadMediaMessage(msg, "stream", {}, {
|
|
759
|
+
reuploadRequest: sock.updateMediaMessage,
|
|
760
|
+
logger: sock.logger
|
|
761
|
+
});
|
|
757
762
|
return {
|
|
758
|
-
saved: await saveMediaStream(
|
|
759
|
-
|
|
760
|
-
logger: sock.logger
|
|
761
|
-
}), mimetype, "inbound", maxBytes, fileName).catch((err) => {
|
|
762
|
-
if (err instanceof Error && /Media exceeds/i.test(err.message)) throw new Error(`Media exceeds ${Math.round(maxBytes / (1024 * 1024))}MB limit`);
|
|
763
|
+
saved: await saveMediaStream(stream, mimetype, "inbound", maxBytes, fileName).catch((err) => {
|
|
764
|
+
if (err instanceof Error && /Media exceeds/i.test(err.message)) throw new Error(`Media exceeds ${Math.round(maxBytes / 1048576)}MB limit`);
|
|
763
765
|
throw err;
|
|
764
766
|
}),
|
|
765
767
|
mimetype,
|
|
766
768
|
fileName
|
|
767
769
|
};
|
|
768
770
|
}
|
|
769
|
-
async function downloadQuotedInboundMedia(msg, sock, maxBytes =
|
|
770
|
-
const
|
|
771
|
+
async function downloadQuotedInboundMedia(msg, sock, maxBytes = 52428800) {
|
|
772
|
+
const message = unwrapMessage(msg.message);
|
|
773
|
+
const contextInfo = extractContextInfo(message);
|
|
771
774
|
if (!contextInfo?.quotedMessage) return;
|
|
772
775
|
const quotedMessage = contextInfo.quotedMessage;
|
|
773
776
|
const self = sock.user;
|
|
@@ -792,7 +795,9 @@ async function downloadQuotedInboundMedia(msg, sock, maxBytes = 50 * 1024 * 1024
|
|
|
792
795
|
const inboundMediaLogger = createSubsystemLogger("gateway/channels/whatsapp").child("inbound");
|
|
793
796
|
const MAX_MEDIA_ERROR_MESSAGE_CHARS = 256;
|
|
794
797
|
function sanitizeMediaErrorMessage(error) {
|
|
795
|
-
|
|
798
|
+
const rawMessage = error instanceof Error ? error.message : String(error);
|
|
799
|
+
const redacted = redactToolPayloadText(rawMessage).replace(/https?:\/\/\S+/giu, "[redacted-url]").replace(/\b[^@\s]+@[a-z][a-z\d.-]*\b/giu, "[redacted-jid]").replace(/\+?\d[\d ().-]{6,}\d/gu, "[redacted-phone]");
|
|
800
|
+
return truncateUtf16Safe(redacted.split("\n", 1)[0]?.trim() || "unknown error", MAX_MEDIA_ERROR_MESSAGE_CHARS);
|
|
796
801
|
}
|
|
797
802
|
function logMediaMaterializationFailure(params) {
|
|
798
803
|
const errorClass = params.error instanceof Error && /^[A-Za-z][A-Za-z0-9_.-]{0,63}$/u.test(params.error.name) ? params.error.name : "Error";
|
|
@@ -1001,7 +1006,7 @@ async function checkInboundAccessControl(params) {
|
|
|
1001
1006
|
//#endregion
|
|
1002
1007
|
//#region extensions/whatsapp/src/inbound/dedupe.ts
|
|
1003
1008
|
const recentOutboundMessages = createDedupeCache({
|
|
1004
|
-
ttlMs:
|
|
1009
|
+
ttlMs: 12e5,
|
|
1005
1010
|
maxSize: 5e3
|
|
1006
1011
|
});
|
|
1007
1012
|
function buildMessageKey(params) {
|
|
@@ -1215,11 +1220,13 @@ function createWhatsAppMessageDeliveryCoordinator(options) {
|
|
|
1215
1220
|
};
|
|
1216
1221
|
const reply = async (text, optionsResult) => {
|
|
1217
1222
|
const resolved = await groupMetadata.resolveOutboundMentions(chatJid, text);
|
|
1218
|
-
|
|
1223
|
+
const result = await sendTrackedMessage(chatJid, addWhatsAppOutboundMentionsToContent({ text: resolved.text }, resolved.mentionedJids), optionsResult);
|
|
1224
|
+
return normalizeWhatsAppSendResult(result, "text");
|
|
1219
1225
|
};
|
|
1220
1226
|
const sendMedia = async (payload, optionsValue) => {
|
|
1221
1227
|
const previewPayload = await addWhatsAppImagePreviewFields(payload);
|
|
1222
|
-
|
|
1228
|
+
const result = await sendTrackedMessage(chatJid, await groupMetadata.applyOutboundMentions(chatJid, previewPayload), optionsValue);
|
|
1229
|
+
return normalizeWhatsAppSendResult(result, "media");
|
|
1223
1230
|
};
|
|
1224
1231
|
const timestamp = inbound.messageTimestampMs;
|
|
1225
1232
|
const mentionedJids = enriched.mentionedJids;
|
|
@@ -1439,14 +1446,15 @@ function createWhatsAppMessageDeliveryCoordinator(options) {
|
|
|
1439
1446
|
finishPreparation(void 0);
|
|
1440
1447
|
const inbound = await normalizeInboundMessage(msg);
|
|
1441
1448
|
if (inbound) await maybeMarkNonSelfChatReadReceipt(inbound, buildReadReceiptTarget(inbound));
|
|
1442
|
-
} else if (result.kind === "durable" && result.queueResult.kind === "accepted")
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1449
|
+
} else if (result.kind === "durable" && result.queueResult.kind === "accepted") {
|
|
1450
|
+
if (skipRecentOutboundEcho) finishPreparation(null);
|
|
1451
|
+
else try {
|
|
1452
|
+
finishPreparation(await normalizeInboundMessage(msg), true);
|
|
1453
|
+
} catch (error) {
|
|
1454
|
+
finishPreparation(void 0);
|
|
1455
|
+
inboundLogger.warn({ error: formatError(error) }, "failed preparing WhatsApp inbound identity; durable drain will normalize again");
|
|
1456
|
+
}
|
|
1457
|
+
} else finishPreparation(void 0);
|
|
1450
1458
|
}
|
|
1451
1459
|
};
|
|
1452
1460
|
const handleMessagesUpsertEvent = (upsert) => {
|
|
@@ -1514,7 +1522,7 @@ function createWhatsAppMessageDeliveryCoordinator(options) {
|
|
|
1514
1522
|
//#region extensions/whatsapp/src/inbound/socket-session.ts
|
|
1515
1523
|
const LOGGED_OUT_STATUS = DisconnectReason.loggedOut;
|
|
1516
1524
|
const RECONNECT_IN_PROGRESS_ERROR = "no active socket - reconnection in progress";
|
|
1517
|
-
const BAILEYS_MESSAGE_TTL_MS =
|
|
1525
|
+
const BAILEYS_MESSAGE_TTL_MS = 6e5;
|
|
1518
1526
|
function isDirectUserJid(jid) {
|
|
1519
1527
|
return /^(\d+)(?::\d+)?@(s\.whatsapp\.net|c\.us|lid|hosted|hosted\.lid)$/i.test(jid.trim());
|
|
1520
1528
|
}
|
|
@@ -2470,11 +2478,13 @@ async function applyGroupGating(params) {
|
|
|
2470
2478
|
conversationId
|
|
2471
2479
|
}) !== "always";
|
|
2472
2480
|
const replyContext = getReplyContext(params.msg, params.authDir);
|
|
2481
|
+
const implicitReplyToSelf = params.selfChatMode === true && identitiesOverlap(self, sender);
|
|
2482
|
+
const implicitMentionKinds = implicitMentionKindWhen("quoted_bot", !implicitReplyToSelf && identitiesOverlap(self, replyContext?.sender));
|
|
2473
2483
|
const mentionDecision = resolveInboundMentionDecision({
|
|
2474
2484
|
facts: {
|
|
2475
2485
|
canDetectMention: true,
|
|
2476
2486
|
wasMentioned,
|
|
2477
|
-
implicitMentionKinds
|
|
2487
|
+
implicitMentionKinds
|
|
2478
2488
|
},
|
|
2479
2489
|
policy: {
|
|
2480
2490
|
isGroup: true,
|
|
@@ -2652,7 +2662,8 @@ function isLikelyWhatsAppCryptoError(reason) {
|
|
|
2652
2662
|
if (typeof value === "function") return value.name ? `[function ${value.name}]` : "[function]";
|
|
2653
2663
|
return Object.prototype.toString.call(value);
|
|
2654
2664
|
};
|
|
2655
|
-
const
|
|
2665
|
+
const raw = reason instanceof Error ? `${reason.message}\n${reason.stack ?? ""}` : formatReason(reason);
|
|
2666
|
+
const haystack = normalizeLowercaseStringOrEmpty(raw);
|
|
2656
2667
|
if (!(haystack.includes("unsupported state or unable to authenticate data") || haystack.includes("bad mac"))) return false;
|
|
2657
2668
|
return haystack.includes("baileys") || haystack.includes("noise-handler") || haystack.includes("aesdecryptgcm");
|
|
2658
2669
|
}
|
|
@@ -2823,16 +2834,17 @@ async function deliverWebReplyInActivityScope(params) {
|
|
|
2823
2834
|
return delivery;
|
|
2824
2835
|
}
|
|
2825
2836
|
const remainingText = [...textChunks];
|
|
2837
|
+
const leadingCaption = remainingText.shift() || "";
|
|
2826
2838
|
await sendMediaWithLeadingCaption({
|
|
2827
2839
|
mediaUrls: mediaList,
|
|
2828
|
-
caption:
|
|
2840
|
+
caption: leadingCaption,
|
|
2829
2841
|
send: async ({ mediaUrl, caption }) => {
|
|
2830
2842
|
const media = await prepareWhatsAppOutboundMedia(await loadWebMedia(mediaUrl, {
|
|
2831
2843
|
maxBytes: maxMediaBytes,
|
|
2832
2844
|
localRoots: params.mediaLocalRoots
|
|
2833
2845
|
}), mediaUrl);
|
|
2834
2846
|
if (shouldLogVerbose()) {
|
|
2835
|
-
logVerbose(`Web auto-reply media size: ${(media.buffer.length /
|
|
2847
|
+
logVerbose(`Web auto-reply media size: ${(media.buffer.length / 1048576).toFixed(2)}MB`);
|
|
2836
2848
|
logVerbose(`Web auto-reply media source: ${mediaUrl} (kind ${media.kind})`);
|
|
2837
2849
|
}
|
|
2838
2850
|
const quote = getQuote();
|
|
@@ -2855,7 +2867,7 @@ async function deliverWebReplyInActivityScope(params) {
|
|
|
2855
2867
|
mimetype: media.mimetype
|
|
2856
2868
|
}, quote), `media:${media.kind}`, "media", mediaUrl), mediaUrl);
|
|
2857
2869
|
if (media.kind === "audio" && caption) rememberSendResult(await sendWithRetry(() => transport.reply(caption, quote), "media:audio-text", "text"));
|
|
2858
|
-
whatsappOutboundLog.info(`Sent media reply to ${conversationId} (${(media.buffer.length /
|
|
2870
|
+
whatsappOutboundLog.info(`Sent media reply to ${conversationId} (${(media.buffer.length / 1048576).toFixed(2)}MB)`);
|
|
2859
2871
|
replyLogger.info({
|
|
2860
2872
|
correlationId: transport.correlationId ?? newConnectionId(),
|
|
2861
2873
|
connectionId: connectionId ?? null,
|
|
@@ -3321,7 +3333,8 @@ function createWhatsAppReplyPlan(params) {
|
|
|
3321
3333
|
didSendReply = true;
|
|
3322
3334
|
if (shouldLogVerbose$1()) {
|
|
3323
3335
|
const reply = resolveSendableOutboundReplyParts(payload);
|
|
3324
|
-
|
|
3336
|
+
const preview = payload.text != null ? reply.text : "<media>";
|
|
3337
|
+
logVerbose$1(`Reply body: ${preview}${reply.hasMedia ? " (media)" : ""} -> ${conversationId}`);
|
|
3325
3338
|
}
|
|
3326
3339
|
};
|
|
3327
3340
|
const deliverNormalizedPayload = async (normalizedDeliveryPayload, info, options) => {
|
|
@@ -3718,27 +3731,30 @@ async function processMessage(params) {
|
|
|
3718
3731
|
}) : void 0;
|
|
3719
3732
|
if (conversationKind === "group") {
|
|
3720
3733
|
const history = visibleGroupHistory ?? [];
|
|
3721
|
-
if (history.length > 0)
|
|
3722
|
-
|
|
3734
|
+
if (history.length > 0) {
|
|
3735
|
+
const historyEntries = history.map((m) => ({
|
|
3723
3736
|
sender: m.sender,
|
|
3724
3737
|
body: m.body,
|
|
3725
3738
|
timestamp: m.timestamp,
|
|
3726
3739
|
media: m.media
|
|
3727
|
-
}))
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3740
|
+
}));
|
|
3741
|
+
combinedBody = buildHistoryContextFromEntries({
|
|
3742
|
+
entries: historyEntries,
|
|
3743
|
+
currentMessage: combinedBody,
|
|
3744
|
+
excludeLast: false,
|
|
3745
|
+
formatEntry: (entry) => {
|
|
3746
|
+
return formatInboundEnvelope$1({
|
|
3747
|
+
channel: "WhatsApp",
|
|
3748
|
+
from: conversationId,
|
|
3749
|
+
timestamp: entry.timestamp,
|
|
3750
|
+
body: [entry.body, formatMediaPlaceholderText(entry.media ?? [])].filter(Boolean).join("\n"),
|
|
3751
|
+
chatType: "group",
|
|
3752
|
+
senderLabel: entry.sender,
|
|
3753
|
+
envelope: envelopeOptions
|
|
3754
|
+
});
|
|
3755
|
+
}
|
|
3756
|
+
});
|
|
3757
|
+
}
|
|
3742
3758
|
shouldClearGroupHistory = !(params.suppressGroupHistoryClear ?? false);
|
|
3743
3759
|
}
|
|
3744
3760
|
const statusReactionController = params.statusReactionController ?? (params.cfg.messages?.statusReactions?.enabled === true && !params.ackAlreadySent ? await createWhatsAppStatusReactionController({
|
|
@@ -4265,8 +4281,8 @@ function normalizeReconnectAccountId(accountId) {
|
|
|
4265
4281
|
function isRetryableAuthUnstableError(error) {
|
|
4266
4282
|
return error instanceof WhatsAppAuthUnstableError || typeof error === "object" && error !== null && "code" in error && error.code === "whatsapp-auth-unstable";
|
|
4267
4283
|
}
|
|
4268
|
-
const DEFAULT_TRANSPORT_TIMEOUT_MS =
|
|
4269
|
-
const WHATSAPP_RECONNECT_CATCH_UP_MAX_MS =
|
|
4284
|
+
const DEFAULT_TRANSPORT_TIMEOUT_MS = 3e5;
|
|
4285
|
+
const WHATSAPP_RECONNECT_CATCH_UP_MAX_MS = 12e5;
|
|
4270
4286
|
async function monitorWebChannel(verbose, listenerFactory = attachWebInboxToSocket, keepAlive = true, replyResolver, runtime = defaultRuntime, abortSignal, tuning = {}) {
|
|
4271
4287
|
const activeReplyResolver = replyResolver ?? (await loadReplyResolverRuntime()).getReplyFromConfig;
|
|
4272
4288
|
const runId = newConnectionId();
|
|
@@ -4311,9 +4327,9 @@ async function monitorWebChannel(verbose, listenerFactory = attachWebInboxToSock
|
|
|
4311
4327
|
};
|
|
4312
4328
|
process.once("SIGINT", handleSigint);
|
|
4313
4329
|
const transportTimeoutMs = tuning.transportTimeoutMs ?? DEFAULT_TRANSPORT_TIMEOUT_MS;
|
|
4314
|
-
const messageTimeoutMs = tuning.messageTimeoutMs ??
|
|
4330
|
+
const messageTimeoutMs = tuning.messageTimeoutMs ?? 18e5;
|
|
4315
4331
|
const reconnectCatchUpWindowMs = Math.min(Math.max(messageTimeoutMs, 6e4), WHATSAPP_RECONNECT_CATCH_UP_MAX_MS);
|
|
4316
|
-
const watchdogCheckMs = tuning.watchdogCheckMs ??
|
|
4332
|
+
const watchdogCheckMs = tuning.watchdogCheckMs ?? 6e4;
|
|
4317
4333
|
const controller = new WhatsAppConnectionController({
|
|
4318
4334
|
accountId: account.accountId,
|
|
4319
4335
|
authDir: account.authDir,
|
package/dist/runtime-api.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { c as resolveWebCredsPath, r as hasWebCredsSync, s as resolveWebCredsBackupPath } from "./creds-files-W6B3EMZ8.js";
|
|
2
|
-
import { n as whatsAppActionRuntime, t as handleWhatsAppAction } from "./action-runtime-
|
|
3
|
-
import { i as sendTypingWhatsApp, n as sendPollWhatsApp, r as sendReactionWhatsApp, t as sendMessageWhatsApp } from "./send-
|
|
2
|
+
import { n as whatsAppActionRuntime, t as handleWhatsAppAction } from "./action-runtime-Bw0loEdy.js";
|
|
3
|
+
import { i as sendTypingWhatsApp, n as sendPollWhatsApp, r as sendReactionWhatsApp, t as sendMessageWhatsApp } from "./send-DiPjiygK.js";
|
|
4
4
|
import { a as setWhatsAppRuntime } from "./runtime-BLlToOi6.js";
|
|
5
5
|
import { startWebLoginWithQr, waitForWebLogin } from "./login-qr-runtime.js";
|
|
6
6
|
import { t as createWhatsAppLoginTool } from "./agent-tools-login-B-2qZPzc.js";
|
|
7
|
-
import { M as waitForCredsSaveQueueWithTimeout, N as writeCredsJsonAtomically, _ as readWebSelfIdentity, a as formatWhatsAppWebAuthStatusState, b as restoreCredsFromBackupIfNeeded, c as logoutWeb, d as readWebAuthExistsBestEffort, f as readWebAuthExistsForDecision, g as readWebSelfId, h as readWebAuthState, j as waitForCredsSaveQueue, l as pickWebChannel, m as readWebAuthSnapshotBestEffort, n as WHATSAPP_AUTH_UNSTABLE_CODE, o as getWebAuthAgeMs, p as readWebAuthSnapshot, r as WhatsAppAuthUnstableError, s as logWebSelfId, t as WA_WEB_AUTH_DIR, u as readCredsJsonRaw, v as readWebSelfIdentityForDecision, x as webAuthExists, y as resolveDefaultWebAuthDir } from "./auth-store-
|
|
8
|
-
import { t as DEFAULT_WEB_MEDIA_BYTES } from "./constants-
|
|
7
|
+
import { M as waitForCredsSaveQueueWithTimeout, N as writeCredsJsonAtomically, _ as readWebSelfIdentity, a as formatWhatsAppWebAuthStatusState, b as restoreCredsFromBackupIfNeeded, c as logoutWeb, d as readWebAuthExistsBestEffort, f as readWebAuthExistsForDecision, g as readWebSelfId, h as readWebAuthState, j as waitForCredsSaveQueue, l as pickWebChannel, m as readWebAuthSnapshotBestEffort, n as WHATSAPP_AUTH_UNSTABLE_CODE, o as getWebAuthAgeMs, p as readWebAuthSnapshot, r as WhatsAppAuthUnstableError, s as logWebSelfId, t as WA_WEB_AUTH_DIR, u as readCredsJsonRaw, v as readWebSelfIdentityForDecision, x as webAuthExists, y as resolveDefaultWebAuthDir } from "./auth-store-DTj1H9pv.js";
|
|
8
|
+
import { t as DEFAULT_WEB_MEDIA_BYTES } from "./constants-C7m81BNe.js";
|
|
9
9
|
import { n as resolveWebAccountId, t as getActiveWebListener } from "./active-listener-BEjWsCNM.js";
|
|
10
|
-
import { a as waitForWaConnection, i as newConnectionId, r as createWaSocket } from "./socket-close-
|
|
10
|
+
import { a as waitForWaConnection, i as newConnectionId, r as createWaSocket } from "./socket-close-CpkkJZCU.js";
|
|
11
11
|
import { n as getStatusCode, t as formatError } from "./session-errors-JuazczrA.js";
|
|
12
|
-
import { p as extractText, s as extractContactContext, u as extractLocationData } from "./send-api-
|
|
13
|
-
import { a as loadWebMediaRaw, c as monitorWebInbox, i as loadWebMedia, l as resetWebInboundDedupe, n as LocalMediaAccessError, o as optimizeImageToJpeg, r as getDefaultLocalRoots, s as optimizeImageToPng, t as monitorWebChannel } from "./monitor-
|
|
14
|
-
import { t as loginWeb } from "./login-
|
|
12
|
+
import { p as extractText, s as extractContactContext, u as extractLocationData } from "./send-api-kFcuhSiY.js";
|
|
13
|
+
import { a as loadWebMediaRaw, c as monitorWebInbox, i as loadWebMedia, l as resetWebInboundDedupe, n as LocalMediaAccessError, o as optimizeImageToJpeg, r as getDefaultLocalRoots, s as optimizeImageToPng, t as monitorWebChannel } from "./monitor-CTsyo-HE.js";
|
|
14
|
+
import { t as loginWeb } from "./login-Bk_jiXKD.js";
|
|
15
15
|
import { HEARTBEAT_PROMPT, HEARTBEAT_TOKEN, SILENT_REPLY_TOKEN, stripHeartbeatToken } from "openclaw/plugin-sdk/reply-runtime";
|
|
16
16
|
export { DEFAULT_WEB_MEDIA_BYTES, HEARTBEAT_PROMPT, HEARTBEAT_TOKEN, LocalMediaAccessError, SILENT_REPLY_TOKEN, WA_WEB_AUTH_DIR, WHATSAPP_AUTH_UNSTABLE_CODE, WhatsAppAuthUnstableError, createWaSocket, createWhatsAppLoginTool, extractContactContext, extractLocationData, extractText, formatError, formatWhatsAppWebAuthStatusState, getActiveWebListener, getDefaultLocalRoots, getStatusCode, getWebAuthAgeMs, handleWhatsAppAction, hasWebCredsSync, loadWebMedia, loadWebMediaRaw, logWebSelfId, loginWeb, logoutWeb, monitorWebChannel, monitorWebInbox, newConnectionId, optimizeImageToJpeg, optimizeImageToPng, pickWebChannel, readCredsJsonRaw, readWebAuthExistsBestEffort, readWebAuthExistsForDecision, readWebAuthSnapshot, readWebAuthSnapshotBestEffort, readWebAuthState, readWebSelfId, readWebSelfIdentity, readWebSelfIdentityForDecision, resetWebInboundDedupe, resolveDefaultWebAuthDir, resolveWebAccountId, resolveWebCredsBackupPath, resolveWebCredsPath, restoreCredsFromBackupIfNeeded, sendMessageWhatsApp, sendPollWhatsApp, sendReactionWhatsApp, sendTypingWhatsApp, setWhatsAppRuntime, startWebLoginWithQr, stripHeartbeatToken, waitForCredsSaveQueue, waitForCredsSaveQueueWithTimeout, waitForWaConnection, waitForWebLogin, webAuthExists, whatsAppActionRuntime, writeCredsJsonAtomically };
|
|
@@ -3,11 +3,12 @@ import { r as resolveDefaultWhatsAppAccountId } from "./account-ids-CB5SOWjc.js"
|
|
|
3
3
|
import { n as isWhatsAppNewsletterJid } from "./normalize-target-CugRyONv.js";
|
|
4
4
|
import { r as getWhatsAppConnectionController } from "./connection-controller-runtime-context-DG0tuYuw.js";
|
|
5
5
|
import "./normalize-C7Hkc_vE.js";
|
|
6
|
-
import { a as markdownToWhatsAppChunks, c as toWhatsappJid } from "./targets-runtime-
|
|
7
|
-
import { a as stripToolCallXmlTags, i as sanitizeAssistantVisibleTextWithProfile, r as sanitizeAssistantVisibleText } from "./text-runtime-
|
|
6
|
+
import { a as markdownToWhatsAppChunks, c as toWhatsappJid } from "./targets-runtime-RBjx3pg_.js";
|
|
7
|
+
import { a as stripToolCallXmlTags, i as sanitizeAssistantVisibleTextWithProfile, r as sanitizeAssistantVisibleText } from "./text-runtime-DyfmcATV.js";
|
|
8
8
|
import path from "node:path";
|
|
9
9
|
import { normalizeStringEntries, normalizeUniqueStringEntries, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
10
10
|
import { resolveReactionLevel } from "openclaw/plugin-sdk/status-helpers";
|
|
11
|
+
import { createMessageReceiptFromOutboundResults, createReplyToFanout, listMessageReceiptPlatformIds, sanitizeForPlainText } from "openclaw/plugin-sdk/channel-outbound";
|
|
11
12
|
import { formatCliCommand } from "openclaw/plugin-sdk/cli-runtime";
|
|
12
13
|
import { generateSecureUuid } from "openclaw/plugin-sdk/core";
|
|
13
14
|
import { PlatformMessageNotDispatchedError } from "openclaw/plugin-sdk/error-runtime";
|
|
@@ -22,17 +23,17 @@ import { extensionForMime, mediaKindFromMime, mimeTypeFromFilePath, normalizeMim
|
|
|
22
23
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
23
24
|
import { recordChannelActivity } from "openclaw/plugin-sdk/channel-activity-runtime";
|
|
24
25
|
import { createChannelPartialDeliveryError, isChannelPartialDeliveryError } from "openclaw/plugin-sdk/channel-inbound";
|
|
25
|
-
import { createMessageReceiptFromOutboundResults, listMessageReceiptPlatformIds, sanitizeForPlainText } from "openclaw/plugin-sdk/channel-outbound";
|
|
26
26
|
import { MEDIA_FFMPEG_MAX_AUDIO_DURATION_SECS, transcodeAudioBufferToOpus } from "openclaw/plugin-sdk/media-runtime";
|
|
27
27
|
import { resolveOutboundMediaUrls } from "openclaw/plugin-sdk/reply-payload";
|
|
28
28
|
//#region extensions/whatsapp/src/reaction-level.ts
|
|
29
29
|
/** Resolve the effective reaction level and its implications for WhatsApp. */
|
|
30
30
|
function resolveWhatsAppReactionLevel(params) {
|
|
31
|
+
const account = resolveMergedWhatsAppAccountConfig({
|
|
32
|
+
cfg: params.cfg,
|
|
33
|
+
accountId: params.accountId
|
|
34
|
+
});
|
|
31
35
|
return resolveReactionLevel({
|
|
32
|
-
value:
|
|
33
|
-
cfg: params.cfg,
|
|
34
|
-
accountId: params.accountId
|
|
35
|
-
}).reactionLevel,
|
|
36
|
+
value: account.reactionLevel,
|
|
36
37
|
defaultLevel: "minimal",
|
|
37
38
|
invalidFallback: "minimal"
|
|
38
39
|
});
|
|
@@ -494,8 +495,9 @@ async function sendMessageWhatsAppInActivityScope(to, body, options) {
|
|
|
494
495
|
accountId: resolvedAccountId ?? options.accountId
|
|
495
496
|
});
|
|
496
497
|
const accountIdForFormatting = resolvedAccountId ?? options.accountId;
|
|
497
|
-
const
|
|
498
|
-
const
|
|
498
|
+
const requestedLimit = options.formatting?.textLimit ?? Infinity;
|
|
499
|
+
const textLimit = Math.min(requestedLimit > 0 ? requestedLimit : Infinity, resolveTextChunkLimit(cfg, "whatsapp", accountIdForFormatting, { fallbackLimit: 4e3 }), 4096);
|
|
500
|
+
const textChunks = markdownToWhatsAppChunks(text, textLimit, tableMode, options.formatting?.chunkMode ?? resolveChunkMode(cfg, "whatsapp", accountIdForFormatting));
|
|
499
501
|
text = textChunks.shift() ?? text;
|
|
500
502
|
if (!text && !hasMedia) return {
|
|
501
503
|
messageId: "",
|
|
@@ -565,30 +567,52 @@ async function sendMessageWhatsAppInActivityScope(to, body, options) {
|
|
|
565
567
|
}
|
|
566
568
|
}
|
|
567
569
|
const accountId = Boolean(options.accountId?.trim()) ? resolvedAccountId : void 0;
|
|
568
|
-
const
|
|
570
|
+
const trailingTextChunks = [visibleTextAfterVoice, ...textChunks].filter((chunk) => Boolean(chunk));
|
|
571
|
+
const reportProgress = trailingTextChunks.length > 0 ? options.onDeliveryResult : void 0;
|
|
572
|
+
const sendOptions = options.gifPlayback || forceDocumentDelivery || accountId || documentFileName ? {
|
|
569
573
|
...options.gifPlayback ? { gifPlayback: true } : {},
|
|
570
574
|
...forceDocumentDelivery ? { asDocument: true } : {},
|
|
571
575
|
...documentFileName ? { fileName: documentFileName } : {},
|
|
572
|
-
...options.quotedMessageKey ? { quotedMessageKey: options.quotedMessageKey } : {},
|
|
573
576
|
accountId
|
|
574
577
|
} : void 0;
|
|
575
|
-
const
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
const
|
|
578
|
+
const quotedSendOptions = options.quotedMessageKey ? {
|
|
579
|
+
...sendOptions,
|
|
580
|
+
quotedMessageKey: options.quotedMessageKey
|
|
581
|
+
} : sendOptions;
|
|
582
|
+
const nextReplyToId = createReplyToFanout({
|
|
583
|
+
replyToId: options.quotedMessageKey?.id,
|
|
584
|
+
replyToIdSource: options.replyToIdSource,
|
|
585
|
+
replyToMode: options.replyToMode
|
|
586
|
+
});
|
|
587
|
+
const sendPart = async (part, buffer, mime) => {
|
|
588
|
+
await options.onPlatformSendDispatch?.();
|
|
589
|
+
const replyToId = nextReplyToId();
|
|
590
|
+
const partOptions = replyToId ? quotedSendOptions : sendOptions;
|
|
591
|
+
const accepted = requireWhatsAppAcceptedSendResult(partOptions ? await active.sendMessage(to, part, buffer, mime, partOptions) : await active.sendMessage(to, part, buffer, mime));
|
|
592
|
+
acceptedResults.push(accepted);
|
|
593
|
+
const result = {
|
|
594
|
+
messageId: accepted.messageId,
|
|
595
|
+
toJid: resolveActualSentRemoteJid(accepted, jid)
|
|
596
|
+
};
|
|
597
|
+
return {
|
|
598
|
+
...result,
|
|
599
|
+
...reportProgress ? { receipt: createMessageReceiptFromOutboundResults({
|
|
600
|
+
results: [{
|
|
601
|
+
channel: "whatsapp",
|
|
602
|
+
...result
|
|
603
|
+
}],
|
|
604
|
+
kind: buffer ? "media" : "text",
|
|
605
|
+
replyToId
|
|
606
|
+
}) } : {}
|
|
607
|
+
};
|
|
608
|
+
};
|
|
609
|
+
const result = await sendPart(text, mediaBuffer, mediaType);
|
|
610
|
+
const { messageId, toJid: sentRemoteJid } = result;
|
|
580
611
|
if (trailingTextChunks.length > 0) {
|
|
581
|
-
await
|
|
582
|
-
messageId,
|
|
583
|
-
toJid: sentRemoteJid
|
|
584
|
-
});
|
|
612
|
+
await reportProgress?.(result);
|
|
585
613
|
for (const trailingText of trailingTextChunks) {
|
|
586
|
-
const trailingResult =
|
|
587
|
-
|
|
588
|
-
await options.onDeliveryResult?.({
|
|
589
|
-
messageId: trailingResult.messageId,
|
|
590
|
-
toJid: resolveActualSentRemoteJid(trailingResult, jid)
|
|
591
|
-
});
|
|
614
|
+
const trailingResult = await sendPart(trailingText);
|
|
615
|
+
await reportProgress?.(trailingResult);
|
|
592
616
|
}
|
|
593
617
|
}
|
|
594
618
|
const durationMs = Date.now() - startedAt;
|
|
@@ -639,7 +663,8 @@ async function sendReactionWhatsApp(chatJid, messageId, emoji, options) {
|
|
|
639
663
|
messageId
|
|
640
664
|
});
|
|
641
665
|
try {
|
|
642
|
-
const
|
|
666
|
+
const jid = toWhatsappJid(chatJid);
|
|
667
|
+
const redactedJid = redactIdentifier(jid);
|
|
643
668
|
outboundLog.info(`Sending reaction "${emoji}" -> message ${messageId}`);
|
|
644
669
|
logger.info({
|
|
645
670
|
chatJid: redactedJid,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { n as isWhatsAppNewsletterJid } from "./normalize-target-CugRyONv.js";
|
|
2
|
-
import { _ as resolveWhatsAppDocumentFileName, f as mergeWhatsAppAcceptedSendError, m as rememberWhatsAppAcceptedSend, p as normalizeWhatsAppSendResult, u as combineWhatsAppSendResults } from "./send-
|
|
2
|
+
import { _ as resolveWhatsAppDocumentFileName, f as mergeWhatsAppAcceptedSendError, m as rememberWhatsAppAcceptedSend, p as normalizeWhatsAppSendResult, u as combineWhatsAppSendResults } from "./send-DiPjiygK.js";
|
|
3
3
|
import "./normalize-C7Hkc_vE.js";
|
|
4
|
-
import { c as toWhatsappJid, l as toWhatsappJidWithLid, r as jidToE164 } from "./targets-runtime-
|
|
5
|
-
import "./text-runtime-
|
|
6
|
-
import { i as buildQuotedMessageOptions } from "./group-session-key-
|
|
7
|
-
import { k as resolveComparableIdentity } from "./auth-store-
|
|
4
|
+
import { c as toWhatsappJid, l as toWhatsappJidWithLid, r as jidToE164 } from "./targets-runtime-RBjx3pg_.js";
|
|
5
|
+
import "./text-runtime-DyfmcATV.js";
|
|
6
|
+
import { i as buildQuotedMessageOptions } from "./group-session-key-KUguLmSZ.js";
|
|
7
|
+
import { k as resolveComparableIdentity } from "./auth-store-DTj1H9pv.js";
|
|
8
8
|
import { isRecord, normalizeLowercaseStringOrEmpty, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
9
9
|
import { logVerbose } from "openclaw/plugin-sdk/runtime-env";
|
|
10
10
|
import { formatLocationText } from "openclaw/plugin-sdk/channel-inbound";
|
|
@@ -625,43 +625,44 @@ function createWebSendApi(params) {
|
|
|
625
625
|
text,
|
|
626
626
|
mentionedJids: []
|
|
627
627
|
} : await resolveMentions(jid, text);
|
|
628
|
-
if (mediaBuffer && mediaType)
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
fileName:
|
|
628
|
+
if (mediaBuffer && mediaType) {
|
|
629
|
+
if (sendOptions?.asDocument === true && supportsForcedDocumentMediaType(mediaType)) payload = {
|
|
630
|
+
document: mediaBuffer,
|
|
631
|
+
fileName: resolveWhatsAppDocumentFileName({
|
|
632
|
+
fileName: sendOptions?.fileName,
|
|
633
|
+
mimetype: mediaType
|
|
634
|
+
}),
|
|
635
|
+
caption: resolvedPayloadText.text || void 0,
|
|
632
636
|
mimetype: mediaType
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
};
|
|
637
|
-
else if (mediaType.startsWith("image/")) payload = await addWhatsAppImagePreviewFields({
|
|
638
|
-
image: mediaBuffer,
|
|
639
|
-
caption: resolvedPayloadText.text || void 0,
|
|
640
|
-
mimetype: mediaType
|
|
641
|
-
});
|
|
642
|
-
else if (mediaType.startsWith("audio/")) payload = {
|
|
643
|
-
audio: mediaBuffer,
|
|
644
|
-
ptt: true,
|
|
645
|
-
mimetype: mediaType
|
|
646
|
-
};
|
|
647
|
-
else if (mediaType.startsWith("video/")) {
|
|
648
|
-
const gifPlayback = sendOptions?.gifPlayback;
|
|
649
|
-
payload = {
|
|
650
|
-
video: mediaBuffer,
|
|
637
|
+
};
|
|
638
|
+
else if (mediaType.startsWith("image/")) payload = await addWhatsAppImagePreviewFields({
|
|
639
|
+
image: mediaBuffer,
|
|
651
640
|
caption: resolvedPayloadText.text || void 0,
|
|
652
|
-
mimetype: mediaType
|
|
653
|
-
|
|
641
|
+
mimetype: mediaType
|
|
642
|
+
});
|
|
643
|
+
else if (mediaType.startsWith("audio/")) payload = {
|
|
644
|
+
audio: mediaBuffer,
|
|
645
|
+
ptt: true,
|
|
646
|
+
mimetype: mediaType
|
|
654
647
|
};
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
648
|
+
else if (mediaType.startsWith("video/")) {
|
|
649
|
+
const gifPlayback = sendOptions?.gifPlayback;
|
|
650
|
+
payload = {
|
|
651
|
+
video: mediaBuffer,
|
|
652
|
+
caption: resolvedPayloadText.text || void 0,
|
|
653
|
+
mimetype: mediaType,
|
|
654
|
+
...gifPlayback ? { gifPlayback: true } : {}
|
|
655
|
+
};
|
|
656
|
+
} else payload = {
|
|
657
|
+
document: mediaBuffer,
|
|
658
|
+
fileName: resolveWhatsAppDocumentFileName({
|
|
659
|
+
fileName: sendOptions?.fileName,
|
|
660
|
+
mimetype: mediaType
|
|
661
|
+
}),
|
|
662
|
+
caption: resolvedPayloadText.text || void 0,
|
|
659
663
|
mimetype: mediaType
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
mimetype: mediaType
|
|
663
|
-
};
|
|
664
|
-
else payload = { text: resolvedPayloadText.text };
|
|
664
|
+
};
|
|
665
|
+
} else payload = { text: resolvedPayloadText.text };
|
|
665
666
|
payload = addWhatsAppOutboundMentionsToContent(payload, resolvedPayloadText.mentionedJids);
|
|
666
667
|
const quotedOpts = buildQuotedMessageOptions({
|
|
667
668
|
messageId: sendOptions?.quotedMessageKey?.id,
|
|
@@ -717,7 +718,7 @@ function createWebSendApi(params) {
|
|
|
717
718
|
},
|
|
718
719
|
sendReaction: async (chatJid, messageId, emoji, fromMe, participant) => {
|
|
719
720
|
const jid = resolveOutboundJid(chatJid);
|
|
720
|
-
|
|
721
|
+
const result = await params.sock.sendMessage(jid, { react: {
|
|
721
722
|
text: emoji,
|
|
722
723
|
key: {
|
|
723
724
|
remoteJid: jid,
|
|
@@ -725,7 +726,8 @@ function createWebSendApi(params) {
|
|
|
725
726
|
fromMe,
|
|
726
727
|
participant: participant ? toWhatsappJid(participant) : void 0
|
|
727
728
|
}
|
|
728
|
-
} })
|
|
729
|
+
} });
|
|
730
|
+
return normalizeWhatsAppSendResult(result, "reaction");
|
|
729
731
|
},
|
|
730
732
|
sendComposingTo: async (to) => {
|
|
731
733
|
const jid = resolveOutboundJid(to);
|
|
@@ -2,7 +2,7 @@ import { a as resolveWhatsAppAccount, o as resolveWhatsAppAuthDir } from "./acco
|
|
|
2
2
|
import { r as resolveDefaultWhatsAppAccountId } from "./account-ids-CB5SOWjc.js";
|
|
3
3
|
import { r as hasWebCredsSync } from "./creds-files-W6B3EMZ8.js";
|
|
4
4
|
import { a as normalizeWhatsAppAllowFromEntries, o as normalizeWhatsAppAllowFromEntry } from "./normalize-target-CugRyONv.js";
|
|
5
|
-
import { r as whatsappSetupAdapter } from "./shared-
|
|
5
|
+
import { r as whatsappSetupAdapter } from "./shared-DDjonGys.js";
|
|
6
6
|
import { formatCliCommand, formatDocsLink } from "openclaw/plugin-sdk/setup-tools";
|
|
7
7
|
import { DEFAULT_ACCOUNT_ID, createSetupTranslator, splitSetupEntries } from "openclaw/plugin-sdk/setup";
|
|
8
8
|
//#region extensions/whatsapp/src/setup-finalize.ts
|
|
@@ -94,7 +94,7 @@ async function detectWhatsAppLinked(cfg, accountId) {
|
|
|
94
94
|
async function promptWhatsAppOwnerAllowFrom(params) {
|
|
95
95
|
const { prompter, existingAllowFrom } = params;
|
|
96
96
|
await prompter.note(t("wizard.whatsapp.ownerNumberNote"), t("wizard.whatsapp.numberTitle"));
|
|
97
|
-
const
|
|
97
|
+
const entry = await prompter.text({
|
|
98
98
|
message: t("wizard.whatsapp.personalNumberPrompt"),
|
|
99
99
|
placeholder: "+15555550123",
|
|
100
100
|
initialValue: existingAllowFrom[0],
|
|
@@ -103,7 +103,8 @@ async function promptWhatsAppOwnerAllowFrom(params) {
|
|
|
103
103
|
if (!raw) return t("common.required");
|
|
104
104
|
if (!normalizeWhatsAppAllowFromEntry(raw)) return `Invalid number: ${raw}`;
|
|
105
105
|
}
|
|
106
|
-
})
|
|
106
|
+
});
|
|
107
|
+
const normalized = normalizeWhatsAppAllowFromEntry(trimPromptText(entry));
|
|
107
108
|
if (!normalized) throw new Error("Invalid WhatsApp owner number (expected E.164 after validation).");
|
|
108
109
|
return {
|
|
109
110
|
normalized,
|
|
@@ -295,7 +296,7 @@ async function finalizeWhatsAppSetup(params) {
|
|
|
295
296
|
};
|
|
296
297
|
let loginWeb;
|
|
297
298
|
try {
|
|
298
|
-
({loginWeb} = await import("./login-
|
|
299
|
+
({loginWeb} = await import("./login-Bk_jiXKD.js").then((n) => n.n));
|
|
299
300
|
} catch (error) {
|
|
300
301
|
await reportLoginFailure(error);
|
|
301
302
|
}
|
package/dist/setup-plugin-api.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as whatsappSetupPlugin } from "./channel.setup-
|
|
1
|
+
import { t as whatsappSetupPlugin } from "./channel.setup-aOFLSQyw.js";
|
|
2
2
|
export { whatsappSetupPlugin };
|