@openclaw/whatsapp 2026.8.1-beta.2 → 2026.9.1-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{action-runtime-B4e3XFOY.js → action-runtime-C075e6OP.js} +1 -1
- package/dist/action-runtime-api.js +1 -1
- package/dist/action-runtime.runtime.js +1 -1
- package/dist/{call-tool-api.js → agent-tools-api.js} +10 -3
- package/dist/{agent-tools-login-BjRpD-JQ.js → agent-tools-login-B-2qZPzc.js} +12 -3
- package/dist/api.js +6 -6
- package/dist/{approval-handler.runtime-fgGZhALv.js → approval-handler.runtime-CljxfPJz.js} +2 -2
- package/dist/{approval-reactions-CmtJCxe_.js → approval-reactions-Jyr1JaAK.js} +9 -13
- package/dist/{auth-store-B_DQIdzp.js → auth-store-CtpBqH5S.js} +3 -6
- package/dist/{channel-DJVQHz_V.js → channel-C4FMOZTE.js} +8 -10
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel-react-action-d6OacTNj.js → channel-react-action-Bhp2BYRr.js} +13 -11
- package/dist/{channel.runtime-RxuNGZ7w.js → channel.runtime-CrahUvcb.js} +4 -4
- package/dist/{channel.setup-Cmvd967u.js → channel.setup-CGcBvnpP.js} +1 -1
- package/dist/{connection-controller-CUyZgGpf.js → connection-controller-CIYuBJrs.js} +2 -2
- package/dist/{directory-config-Pc4f07wB.js → directory-config-P7_3U73Z.js} +2 -2
- package/dist/directory-contract-api.js +1 -1
- package/dist/index.js +4 -4
- package/dist/light-runtime-api.js +2 -2
- package/dist/{login-D6_rfxTZ.js → login-BkpKpndm.js} +3 -3
- package/dist/{login-qr-B0VyVSqQ.js → login-qr-DY4VFgOq.js} +37 -16
- package/dist/login-qr-runtime.js +1 -1
- package/dist/{monitor-BCe5Mm-1.js → monitor-C_Nw23PZ.js} +84 -494
- package/dist/runtime-api.js +8 -8
- package/dist/{send-prK8F7Vj.js → send-DLMUc2uZ.js} +23 -9
- package/dist/{send-api-DimZST3E.js → send-api-BtK45TmZ.js} +45 -35
- package/dist/{setup-finalize-D3n71Uyx.js → setup-finalize-C1nij8NS.js} +3 -3
- package/dist/setup-plugin-api.js +1 -1
- package/dist/{setup-surface-BCZszf3l.js → setup-surface-CjjqIxQP.js} +2 -2
- package/dist/{shared-Dp9M3ZPX.js → shared-BekHi69d.js} +11 -5
- package/dist/{socket-close-09FojDO2.js → socket-close-2T0_jZTN.js} +1 -1
- package/node_modules/baileys/lib/Defaults/index.js +1 -1
- package/node_modules/baileys/lib/Socket/business.d.ts.map +1 -1
- package/node_modules/baileys/lib/Socket/chats.d.ts +1 -0
- package/node_modules/baileys/lib/Socket/chats.d.ts.map +1 -1
- package/node_modules/baileys/lib/Socket/chats.js +10 -5
- package/node_modules/baileys/lib/Socket/chats.js.map +1 -1
- package/node_modules/baileys/lib/Socket/communities.d.ts.map +1 -1
- package/node_modules/baileys/lib/Socket/groups.d.ts.map +1 -1
- package/node_modules/baileys/lib/Socket/index.d.ts.map +1 -1
- package/node_modules/baileys/lib/Socket/messages-recv.d.ts.map +1 -1
- package/node_modules/baileys/lib/Socket/messages-send.d.ts.map +1 -1
- package/node_modules/baileys/lib/Socket/newsletter.d.ts.map +1 -1
- package/node_modules/baileys/lib/Socket/socket.d.ts.map +1 -1
- package/node_modules/baileys/lib/Socket/socket.js +3 -0
- package/node_modules/baileys/lib/Socket/socket.js.map +1 -1
- package/node_modules/baileys/lib/Types/index.d.ts +1 -0
- package/node_modules/baileys/lib/Types/index.d.ts.map +1 -1
- package/node_modules/baileys/lib/Types/index.js.map +1 -1
- package/node_modules/baileys/lib/Utils/browser-utils.d.ts.map +1 -1
- package/node_modules/baileys/lib/Utils/browser-utils.js +1 -0
- package/node_modules/baileys/lib/Utils/browser-utils.js.map +1 -1
- package/node_modules/baileys/lib/Utils/generics.d.ts +1 -0
- package/node_modules/baileys/lib/Utils/generics.d.ts.map +1 -1
- package/node_modules/baileys/lib/Utils/generics.js +1 -1
- package/node_modules/baileys/lib/Utils/generics.js.map +1 -1
- package/node_modules/baileys/lib/Utils/tc-token-utils.d.ts.map +1 -1
- package/node_modules/baileys/lib/Utils/tc-token-utils.js +3 -2
- package/node_modules/baileys/lib/Utils/tc-token-utils.js.map +1 -1
- package/node_modules/baileys/lib/Utils/validate-connection.d.ts.map +1 -1
- package/node_modules/baileys/lib/Utils/validate-connection.js +9 -2
- package/node_modules/baileys/lib/Utils/validate-connection.js.map +1 -1
- package/node_modules/baileys/node_modules/content-type/README.md +2 -0
- package/node_modules/baileys/node_modules/content-type/dist/index.d.ts +20 -0
- package/node_modules/baileys/node_modules/content-type/dist/index.js +20 -14
- package/node_modules/baileys/node_modules/content-type/dist/index.js.map +1 -1
- package/node_modules/baileys/node_modules/content-type/package.json +1 -1
- package/node_modules/baileys/node_modules/file-type/package.json +1 -1
- package/node_modules/baileys/node_modules/file-type/readme.md +3 -0
- package/node_modules/baileys/node_modules/file-type/source/detectors/zip.js +6 -1
- package/node_modules/baileys/node_modules/file-type/source/index.d.ts +3 -0
- package/node_modules/baileys/node_modules/file-type/source/index.js +25 -13
- package/node_modules/baileys/node_modules/music-metadata/LICENSE.txt +9 -9
- package/node_modules/baileys/node_modules/music-metadata/README.md +878 -878
- package/node_modules/baileys/node_modules/music-metadata/lib/ParseError.d.ts +1 -1
- package/node_modules/baileys/node_modules/music-metadata/lib/ParseError.js +1 -1
- package/node_modules/baileys/node_modules/music-metadata/lib/asf/AsfObject.d.ts +1 -4
- package/node_modules/baileys/node_modules/music-metadata/lib/asf/AsfObject.js +66 -30
- package/node_modules/baileys/node_modules/music-metadata/lib/asf/AsfParser.d.ts +5 -1
- package/node_modules/baileys/node_modules/music-metadata/lib/asf/AsfParser.js +94 -25
- package/node_modules/baileys/node_modules/music-metadata/lib/dsf/DsfChunk.js +2 -2
- package/node_modules/baileys/node_modules/music-metadata/lib/dsf/DsfParser.js +38 -13
- package/node_modules/baileys/node_modules/music-metadata/lib/mp4/AtomToken.js +2 -1
- package/node_modules/baileys/node_modules/music-metadata/lib/mp4/MP4Parser.js +34 -7
- package/node_modules/baileys/node_modules/music-metadata/lib/ogg/speex/SpeexStream.d.ts +7 -0
- package/node_modules/baileys/node_modules/music-metadata/lib/ogg/speex/SpeexStream.js +13 -0
- package/node_modules/baileys/node_modules/music-metadata/lib/riff/RiffChunk.js +1 -1
- package/node_modules/baileys/node_modules/music-metadata/package.json +156 -156
- package/node_modules/baileys/node_modules/protobufjs/README.md +61 -84
- package/node_modules/baileys/node_modules/protobufjs/dist/light/protobuf.js +66 -45
- package/node_modules/baileys/node_modules/protobufjs/dist/light/protobuf.js.map +1 -1
- package/node_modules/baileys/node_modules/protobufjs/dist/light/protobuf.min.js +3 -3
- package/node_modules/baileys/node_modules/protobufjs/dist/light/protobuf.min.js.map +1 -1
- package/node_modules/baileys/node_modules/protobufjs/dist/minimal/protobuf.js +47 -40
- package/node_modules/baileys/node_modules/protobufjs/dist/minimal/protobuf.js.map +1 -1
- package/node_modules/baileys/node_modules/protobufjs/dist/minimal/protobuf.min.js +3 -3
- package/node_modules/baileys/node_modules/protobufjs/dist/minimal/protobuf.min.js.map +1 -1
- package/node_modules/baileys/node_modules/protobufjs/dist/protobuf.js +92 -68
- package/node_modules/baileys/node_modules/protobufjs/dist/protobuf.js.map +1 -1
- package/node_modules/baileys/node_modules/protobufjs/dist/protobuf.min.js +3 -3
- package/node_modules/baileys/node_modules/protobufjs/dist/protobuf.min.js.map +1 -1
- package/node_modules/baileys/node_modules/protobufjs/ext/descriptor.js +26 -10
- package/node_modules/baileys/node_modules/protobufjs/index.d.ts +3 -0
- package/node_modules/baileys/node_modules/protobufjs/package.json +1 -1
- package/node_modules/baileys/node_modules/protobufjs/src/converter.js +5 -1
- package/node_modules/baileys/node_modules/protobufjs/src/enum.js +5 -2
- package/node_modules/baileys/node_modules/protobufjs/src/field.js +6 -1
- package/node_modules/baileys/node_modules/protobufjs/src/parse.js +26 -23
- package/node_modules/baileys/node_modules/protobufjs/src/reader.js +36 -9
- package/node_modules/baileys/node_modules/protobufjs/src/util/codegen.js +3 -1
- package/node_modules/baileys/node_modules/protobufjs/src/util/utf8.js +2 -28
- package/node_modules/baileys/node_modules/protobufjs/src/writer.js +7 -1
- package/node_modules/baileys/package.json +1 -1
- package/node_modules/typebox/build/format/date.d.mts +1 -1
- package/node_modules/typebox/build/format/date.mjs +1 -1
- package/node_modules/typebox/build/format/date_time.d.mts +2 -2
- package/node_modules/typebox/build/format/date_time.mjs +3 -3
- package/node_modules/typebox/build/format/email.d.mts +1 -1
- package/node_modules/typebox/build/format/email.mjs +2 -2
- package/node_modules/typebox/build/format/hostname.mjs +2 -10
- package/node_modules/typebox/build/format/idn_email.d.mts +1 -1
- package/node_modules/typebox/build/format/idn_email.mjs +3 -3
- package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -0
- package/node_modules/typebox/build/format/idn_hostname.mjs +3 -11
- package/node_modules/typebox/build/format/idna/format/bidi.d.mts +3 -0
- package/node_modules/typebox/build/format/idna/format/bidi.mjs +98 -0
- package/node_modules/typebox/build/format/idna/format/puny.d.mts +3 -0
- package/node_modules/typebox/build/format/idna/format/puny.mjs +144 -0
- package/node_modules/typebox/build/format/idna/hostname.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/hostname.mjs +16 -0
- package/node_modules/typebox/build/format/idna/idn-hostname.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/idn-hostname.mjs +23 -0
- package/node_modules/typebox/build/format/idna/index.d.mts +2 -0
- package/node_modules/typebox/build/format/idna/index.mjs +2 -0
- package/node_modules/typebox/build/format/idna/label/ascii.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/label/ascii.mjs +9 -0
- package/node_modules/typebox/build/format/idna/label/puny.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/label/puny.mjs +28 -0
- package/node_modules/typebox/build/format/idna/label/unicode.d.mts +1 -0
- package/node_modules/typebox/build/format/idna/label/unicode.mjs +106 -0
- package/node_modules/typebox/build/format/idna/pattern/pattern.d.mts +30 -0
- package/node_modules/typebox/build/format/idna/pattern/pattern.mjs +70 -0
- package/node_modules/typebox/build/format/ipv4.d.mts +0 -1
- package/node_modules/typebox/build/format/ipv4.mjs +2 -32
- package/node_modules/typebox/build/format/ipv6.mjs +2 -61
- package/node_modules/typebox/build/format/iri.d.mts +2 -2
- package/node_modules/typebox/build/format/iri.mjs +26 -8
- package/node_modules/typebox/build/format/iri_reference.d.mts +2 -2
- package/node_modules/typebox/build/format/iri_reference.mjs +9 -55
- package/node_modules/typebox/build/format/regex.d.mts +1 -2
- package/node_modules/typebox/build/format/regex.mjs +2 -6
- package/node_modules/typebox/build/format/time.d.mts +2 -2
- package/node_modules/typebox/build/format/time.mjs +19 -14
- package/node_modules/typebox/build/format/uri.d.mts +1 -1
- package/node_modules/typebox/build/format/uri.mjs +3 -130
- package/node_modules/typebox/build/format/uri_reference.d.mts +1 -1
- package/node_modules/typebox/build/format/uri_reference.mjs +2 -3
- package/node_modules/typebox/build/format/uri_template.d.mts +2 -3
- package/node_modules/typebox/build/format/uri_template.mjs +4 -5
- package/node_modules/typebox/build/format/url.d.mts +3 -3
- package/node_modules/typebox/build/format/url.mjs +4 -5
- package/node_modules/typebox/build/guard/emit.d.mts +3 -1
- package/node_modules/typebox/build/guard/emit.mjs +12 -5
- package/node_modules/typebox/build/guard/guard.d.mts +8 -2
- package/node_modules/typebox/build/guard/guard.mjs +25 -4
- package/node_modules/typebox/build/guard/string.d.mts +2 -2
- package/node_modules/typebox/build/guard/string.mjs +7 -7
- package/node_modules/typebox/build/schema/engine/_context.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/_functions.mjs +1 -2
- package/node_modules/typebox/build/schema/engine/_regexp.d.mts +2 -0
- package/node_modules/typebox/build/schema/engine/_regexp.mjs +4 -0
- package/node_modules/typebox/build/schema/engine/_stack.mjs +12 -13
- package/node_modules/typebox/build/schema/engine/additionalItems.mjs +17 -7
- package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +4 -3
- package/node_modules/typebox/build/schema/engine/contains.mjs +18 -6
- package/node_modules/typebox/build/schema/engine/enum.mjs +1 -1
- package/node_modules/typebox/build/schema/engine/items.mjs +26 -6
- package/node_modules/typebox/build/schema/engine/maxContains.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/minContains.mjs +14 -4
- package/node_modules/typebox/build/schema/engine/not.mjs +4 -2
- package/node_modules/typebox/build/schema/engine/oneOf.mjs +7 -6
- package/node_modules/typebox/build/schema/engine/pattern.mjs +3 -2
- package/node_modules/typebox/build/schema/engine/patternProperties.mjs +4 -3
- package/node_modules/typebox/build/schema/engine/ref.mjs +1 -7
- package/node_modules/typebox/build/schema/engine/schema.mjs +13 -4
- package/node_modules/typebox/build/schema/engine/type.mjs +1 -1
- package/node_modules/typebox/build/schema/resolve/resolve.d.mts +4 -1
- package/node_modules/typebox/build/schema/resolve/resolve.mjs +202 -1
- package/node_modules/typebox/build/schema/static/propertyNames.d.mts +5 -0
- package/node_modules/typebox/build/schema/static/propertyNames.mjs +3 -0
- package/node_modules/typebox/build/schema/static/schema.d.mts +3 -0
- package/node_modules/typebox/build/schema/types/index.d.mts +0 -2
- package/node_modules/typebox/build/schema/types/index.mjs +0 -2
- package/node_modules/typebox/build/system/memory/clone.mjs +14 -11
- package/node_modules/typebox/build/system/memory/discard.mjs +6 -5
- package/node_modules/typebox/build/system/settings/settings.d.mts +9 -0
- package/node_modules/typebox/build/system/settings/settings.mjs +2 -0
- package/node_modules/typebox/build/type/engine/call/distribute_arguments.d.mts +6 -1
- package/node_modules/typebox/build/type/engine/call/distribute_arguments.mjs +16 -3
- package/node_modules/typebox/build/type/engine/call/instantiate.mjs +34 -4
- package/node_modules/typebox/build/type/engine/evaluate/broaden.d.mts +5 -5
- package/node_modules/typebox/build/type/engine/evaluate/broaden.mjs +20 -26
- package/node_modules/typebox/build/type/engine/evaluate/compare.d.mts +6 -10
- package/node_modules/typebox/build/type/engine/evaluate/compare.mjs +9 -13
- package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +7 -4
- package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +12 -19
- package/node_modules/typebox/build/type/engine/evaluate/distribute.d.mts +4 -20
- package/node_modules/typebox/build/type/engine/evaluate/distribute.mjs +8 -20
- package/node_modules/typebox/build/type/engine/evaluate/evaluate.d.mts +4 -4
- package/node_modules/typebox/build/type/engine/evaluate/evaluate.mjs +11 -8
- package/node_modules/typebox/build/type/engine/evaluate/flatten.d.mts +1 -1
- package/node_modules/typebox/build/type/engine/evaluate/flatten.mjs +3 -4
- package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +17 -2
- package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +26 -6
- package/node_modules/typebox/build/type/engine/exclude/operation.mjs +3 -4
- package/node_modules/typebox/build/type/engine/extract/operation.d.mts +1 -1
- package/node_modules/typebox/build/type/engine/extract/operation.mjs +3 -4
- package/node_modules/typebox/build/type/engine/priority/priority.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/priority/priority.mjs +3 -4
- package/node_modules/typebox/build/type/script/mapping.d.mts +32 -29
- package/node_modules/typebox/build/type/script/mapping.mjs +18 -25
- package/node_modules/typebox/build/type/script/parser.d.mts +19 -25
- package/node_modules/typebox/build/type/script/parser.mjs +27 -23
- package/node_modules/typebox/build/value/errors/errors.d.mts +2 -2
- package/node_modules/typebox/build/value/errors/errors.mjs +1 -1
- package/node_modules/typebox/package.json +27 -27
- package/node_modules/typebox/readme.md +79 -82
- package/openclaw.plugin.json +2 -1
- package/package.json +6 -6
- package/node_modules/typebox/build/format/_idna.d.mts +0 -2
- package/node_modules/typebox/build/format/_idna.mjs +0 -246
- package/node_modules/typebox/build/format/_puny.d.mts +0 -1
- package/node_modules/typebox/build/format/_puny.mjs +0 -77
- package/node_modules/typebox/build/schema/resolve/ref.d.mts +0 -3
- package/node_modules/typebox/build/schema/resolve/ref.mjs +0 -146
- package/node_modules/typebox/build/schema/types/contentEncoding.d.mts +0 -9
- package/node_modules/typebox/build/schema/types/contentEncoding.mjs +0 -13
- package/node_modules/typebox/build/schema/types/contentMediaType.d.mts +0 -9
- package/node_modules/typebox/build/schema/types/contentMediaType.mjs +0 -13
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { a as resolveWhatsAppAccount, s as resolveWhatsAppMediaMaxBytes } from "./accounts-BX2fZUyR.js";
|
|
2
|
-
import {
|
|
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-DLMUc2uZ.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
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-TMk0lGuy.js";
|
|
6
6
|
import { t as normalizeE164 } from "./text-runtime-CaKLhowd.js";
|
|
7
7
|
import { a as cacheInboundMessageMeta, i as buildQuotedMessageOptions, n as resolveWhatsAppGroupSessionRoute, o as lookupInboundMessageMeta, r as resolveWhatsAppLegacyGroupSessionKey } from "./group-session-key-DmFc_Cqi.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-
|
|
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-CtpBqH5S.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-2T0_jZTN.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 { a as addWhatsAppImagePreviewFields, c as extractContextInfo, d as extractMediaKind, f as extractMentionedJids, g as
|
|
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-BtK45TmZ.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-CIYuBJrs.js";
|
|
16
|
+
import { n as maybeResolveWhatsAppApprovalReaction } from "./approval-reactions-Jyr1JaAK.js";
|
|
17
17
|
import { t as maybeResolveWhatsAppQuestionReaction } from "./question-reactions-D3eAeB0i.js";
|
|
18
18
|
import { normalizeLowercaseStringOrEmpty, normalizeOptionalString, normalizeStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
19
19
|
import { filterSupplementalContextItems, resolvePinnedMainDmOwnerFromAllowlist } from "openclaw/plugin-sdk/security-runtime";
|
|
@@ -28,7 +28,7 @@ import { recordChannelActivity } from "openclaw/plugin-sdk/channel-activity-runt
|
|
|
28
28
|
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
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
|
-
import { isReasoningReplyPayload, resolveSendableOutboundReplyParts, sendMediaWithLeadingCaption } from "openclaw/plugin-sdk/reply-payload";
|
|
31
|
+
import { isReasoningReplyPayload, resolveSendableOutboundReplyParts, resolveTextChunksWithFallback, sendMediaWithLeadingCaption } from "openclaw/plugin-sdk/reply-payload";
|
|
32
32
|
import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
33
33
|
import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
|
|
34
34
|
import { DisconnectReason, downloadMediaMessage, isHostedLidUser, isHostedPnUser, isJidGroup, isJidGroup as isJidGroup$1, jidDecode, jidEncode, jidNormalizedUser, normalizeMessageContent as normalizeMessageContent$1 } from "baileys";
|
|
@@ -56,12 +56,14 @@ import { channelReadyPatch, channelStoppedPatch, createTransportActivityStatusPa
|
|
|
56
56
|
import { ensureConfiguredBindingRouteReady, resolveConfiguredBindingRoute } from "openclaw/plugin-sdk/conversation-binding-runtime";
|
|
57
57
|
import { resolveAgentIdentity, resolveIdentityNamePrefix as resolveIdentityNamePrefix$1 } from "openclaw/plugin-sdk/agent-runtime";
|
|
58
58
|
import { normalizeGroupActivation, parseActivationCommand } from "openclaw/plugin-sdk/group-activation";
|
|
59
|
+
import { formatAudioTranscriptForAgent } from "openclaw/plugin-sdk/media-understanding-runtime";
|
|
59
60
|
import { hasControlCommand, isControlCommandMessage, shouldComputeCommandAuthorized } from "openclaw/plugin-sdk/command-detection";
|
|
60
61
|
import { createInternalHookEvent, deriveInboundMessageHookContext, fireAndForgetBoundedHook, toInternalMessageReceivedContext, toPluginMessageContext, toPluginMessageReceivedEvent, triggerInternalHook } from "openclaw/plugin-sdk/hook-runtime";
|
|
61
62
|
import { getGlobalHookRunner } from "openclaw/plugin-sdk/plugin-runtime";
|
|
62
63
|
import { resolveBatchedReplyThreadingPolicy } from "openclaw/plugin-sdk/reply-reference";
|
|
63
64
|
import { LocalMediaAccessError, getDefaultLocalRoots, loadWebMedia, loadWebMediaRaw, optimizeImageToJpeg, optimizeImageToPng } from "openclaw/plugin-sdk/web-media";
|
|
64
65
|
import { createChannelApiRetryRunner } from "openclaw/plugin-sdk/retry-runtime";
|
|
66
|
+
import { resolveAgentConfig } from "openclaw/plugin-sdk/agent-scope-runtime";
|
|
65
67
|
//#region extensions/whatsapp/src/inbound/group-conversation.ts
|
|
66
68
|
function resolveWhatsAppGroupConversationId(conversationId) {
|
|
67
69
|
return resolveGroupSessionKey({
|
|
@@ -130,66 +132,10 @@ function buildWhatsAppInboundAdmission(params) {
|
|
|
130
132
|
async function resolveWhatsAppAdmissionChannelIngress(admission, contextBinding) {
|
|
131
133
|
return await ingressResolverByAdmission.get(admission)?.(contextBinding);
|
|
132
134
|
}
|
|
133
|
-
function buildDeprecatedFlatWhatsAppInboundAdmission(msg) {
|
|
134
|
-
const conversationId = msg.conversationId || msg.from;
|
|
135
|
-
if (!conversationId || !msg.accountId || !msg.chatType) throw new Error("WhatsApp legacy flat inbound messages must include deprecated top-level admission fields.");
|
|
136
|
-
const accountId = msg.accountId;
|
|
137
|
-
const admitted = msg.accessControlPassed !== false;
|
|
138
|
-
const platformSender = msg.platform?.sender;
|
|
139
|
-
const senderE164 = platformSender?.e164 ?? msg.platform?.senderE164 ?? msg.senderE164;
|
|
140
|
-
const senderJid = platformSender?.jid ?? msg.platform?.senderJid ?? msg.senderJid;
|
|
141
|
-
const senderName = platformSender?.name ?? msg.platform?.senderName ?? msg.senderName;
|
|
142
|
-
const senderId = msg.chatType === "group" ? senderE164 ?? senderJid ?? senderName ?? conversationId : senderE164 ?? conversationId;
|
|
143
|
-
const reasonCode = admitted ? msg.chatType === "group" ? "group_policy_allowed" : "dm_policy_allowlisted" : "no_policy_match";
|
|
144
|
-
return buildWhatsAppInboundAdmission({
|
|
145
|
-
policy: {
|
|
146
|
-
account: {
|
|
147
|
-
accountId,
|
|
148
|
-
enabled: true,
|
|
149
|
-
sendReadReceipts: true
|
|
150
|
-
},
|
|
151
|
-
isSelfChat: false,
|
|
152
|
-
isSamePhone: () => false
|
|
153
|
-
},
|
|
154
|
-
access: {
|
|
155
|
-
ingress: {
|
|
156
|
-
admission: admitted ? "dispatch" : "drop",
|
|
157
|
-
decision: admitted ? "allow" : "block",
|
|
158
|
-
decisiveGateId: "legacy-flat-compat",
|
|
159
|
-
reasonCode
|
|
160
|
-
},
|
|
161
|
-
senderAccess: {
|
|
162
|
-
allowed: admitted,
|
|
163
|
-
decision: admitted ? "allow" : "block",
|
|
164
|
-
reasonCode,
|
|
165
|
-
providerMissingFallbackApplied: false
|
|
166
|
-
},
|
|
167
|
-
commandAccess: {
|
|
168
|
-
requested: false,
|
|
169
|
-
authorized: false,
|
|
170
|
-
shouldBlockControlCommand: false,
|
|
171
|
-
reasonCode: "command_authorized"
|
|
172
|
-
},
|
|
173
|
-
activationAccess: {
|
|
174
|
-
ran: false,
|
|
175
|
-
allowed: admitted,
|
|
176
|
-
shouldSkip: !admitted,
|
|
177
|
-
reasonCode: admitted ? "activation_allowed" : "activation_skipped"
|
|
178
|
-
}
|
|
179
|
-
},
|
|
180
|
-
isGroup: msg.chatType === "group",
|
|
181
|
-
conversationId,
|
|
182
|
-
senderId
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
135
|
function requireWhatsAppInboundAdmission(params) {
|
|
186
136
|
if (!params.admission) throw new Error("WhatsApp inbound message is missing admission facts");
|
|
187
137
|
return params.admission;
|
|
188
138
|
}
|
|
189
|
-
function requireAdmittedWhatsAppInboundMessage(msg) {
|
|
190
|
-
requireWhatsAppInboundAdmission(msg);
|
|
191
|
-
return msg;
|
|
192
|
-
}
|
|
193
139
|
//#endregion
|
|
194
140
|
//#region extensions/whatsapp/src/inbound-policy.ts
|
|
195
141
|
function normalizeWhatsAppIngressPhone(value) {
|
|
@@ -324,353 +270,6 @@ function readWhatsAppBaileysCacheEntry(cache, key) {
|
|
|
324
270
|
return entry.value;
|
|
325
271
|
}
|
|
326
272
|
//#endregion
|
|
327
|
-
//#region extensions/whatsapp/src/inbound/message-aliases.ts
|
|
328
|
-
function normalizeQuoteSender(sender) {
|
|
329
|
-
if (!sender?.displayName && !sender?.jid && !sender?.e164) return;
|
|
330
|
-
return sender;
|
|
331
|
-
}
|
|
332
|
-
function buildQuoteFromFlatAliases(msg) {
|
|
333
|
-
if (msg.replyTo) return {
|
|
334
|
-
context: msg.replyTo,
|
|
335
|
-
id: msg.replyTo.id,
|
|
336
|
-
body: msg.replyTo.body,
|
|
337
|
-
sender: normalizeQuoteSender({
|
|
338
|
-
displayName: msg.replyTo.sender?.label ?? msg.replyToSender,
|
|
339
|
-
jid: msg.replyTo.sender?.jid ?? msg.replyToSenderJid,
|
|
340
|
-
e164: msg.replyTo.sender?.e164 ?? msg.replyToSenderE164
|
|
341
|
-
})
|
|
342
|
-
};
|
|
343
|
-
if (!msg.replyToId && !msg.replyToBody && !msg.replyToSender && !msg.replyToSenderJid && !msg.replyToSenderE164) return;
|
|
344
|
-
return {
|
|
345
|
-
id: msg.replyToId,
|
|
346
|
-
body: msg.replyToBody,
|
|
347
|
-
sender: normalizeQuoteSender({
|
|
348
|
-
displayName: msg.replyToSender,
|
|
349
|
-
jid: msg.replyToSenderJid,
|
|
350
|
-
e164: msg.replyToSenderE164
|
|
351
|
-
})
|
|
352
|
-
};
|
|
353
|
-
}
|
|
354
|
-
function buildGroupFromFlatAliases(msg) {
|
|
355
|
-
const mentionJids = msg.mentions ?? msg.mentionedJids;
|
|
356
|
-
if (!msg.groupSubject && !msg.groupParticipants?.length && !mentionJids?.length) return;
|
|
357
|
-
return {
|
|
358
|
-
subject: msg.groupSubject,
|
|
359
|
-
participants: msg.groupParticipants,
|
|
360
|
-
mentions: mentionJids?.length ? { jids: mentionJids } : void 0
|
|
361
|
-
};
|
|
362
|
-
}
|
|
363
|
-
function ensureQuote(msg) {
|
|
364
|
-
return msg.quote ??= {};
|
|
365
|
-
}
|
|
366
|
-
function ensureQuoteSender(msg) {
|
|
367
|
-
const quote = ensureQuote(msg);
|
|
368
|
-
return quote.sender ??= {};
|
|
369
|
-
}
|
|
370
|
-
function ensureGroup(msg) {
|
|
371
|
-
return msg.group ??= {};
|
|
372
|
-
}
|
|
373
|
-
function ensureGroupMentions(msg) {
|
|
374
|
-
const group = ensureGroup(msg);
|
|
375
|
-
return group.mentions ??= {};
|
|
376
|
-
}
|
|
377
|
-
function ensureMedia(msg) {
|
|
378
|
-
return msg.payload.media ??= {};
|
|
379
|
-
}
|
|
380
|
-
function setMediaField(msg, key, value) {
|
|
381
|
-
if (value === void 0 && !msg.payload.media) return;
|
|
382
|
-
ensureMedia(msg)[key] = value;
|
|
383
|
-
}
|
|
384
|
-
function defineDeprecatedAccessors(msg, descriptors) {
|
|
385
|
-
Object.defineProperties(msg, Object.fromEntries(Object.entries(descriptors).map(([key, descriptor]) => [key, {
|
|
386
|
-
configurable: true,
|
|
387
|
-
enumerable: true,
|
|
388
|
-
get: descriptor.get,
|
|
389
|
-
set: descriptor.set
|
|
390
|
-
}])));
|
|
391
|
-
return msg;
|
|
392
|
-
}
|
|
393
|
-
function defineDeprecatedAliasAccessors(msg, descriptors) {
|
|
394
|
-
defineDeprecatedAccessors(msg, descriptors);
|
|
395
|
-
return msg;
|
|
396
|
-
}
|
|
397
|
-
function defineDeprecatedStructuredContextPayloadAlias(msg) {
|
|
398
|
-
const channelStructuredContext = msg.payload.channelStructuredContext ?? msg.payload.untrustedStructuredContext;
|
|
399
|
-
if (channelStructuredContext !== void 0) msg.payload.channelStructuredContext = channelStructuredContext;
|
|
400
|
-
Object.defineProperty(msg.payload, "untrustedStructuredContext", {
|
|
401
|
-
configurable: true,
|
|
402
|
-
enumerable: true,
|
|
403
|
-
get: () => msg.payload.channelStructuredContext,
|
|
404
|
-
set: (value) => {
|
|
405
|
-
msg.payload.channelStructuredContext = value;
|
|
406
|
-
}
|
|
407
|
-
});
|
|
408
|
-
}
|
|
409
|
-
function defineDeprecatedAdmissionTopLevelAccessors(msg) {
|
|
410
|
-
let fallbackConversationId = msg.conversationId || msg.from;
|
|
411
|
-
let fallbackAccountId = msg.accountId;
|
|
412
|
-
let fallbackAccessControlPassed = msg.accessControlPassed;
|
|
413
|
-
let fallbackChatType = msg.chatType;
|
|
414
|
-
const conversationId = () => msg.admission?.conversation.id ?? fallbackConversationId;
|
|
415
|
-
const setConversationId = (value) => {
|
|
416
|
-
const next = value;
|
|
417
|
-
fallbackConversationId = next;
|
|
418
|
-
if (msg.admission) {
|
|
419
|
-
msg.admission.conversation.id = next;
|
|
420
|
-
msg.admission.conversation.groupSessionId = resolveWhatsAppGroupConversationId(next);
|
|
421
|
-
}
|
|
422
|
-
};
|
|
423
|
-
return defineDeprecatedAccessors(msg, {
|
|
424
|
-
from: {
|
|
425
|
-
get: conversationId,
|
|
426
|
-
set: setConversationId
|
|
427
|
-
},
|
|
428
|
-
conversationId: {
|
|
429
|
-
get: conversationId,
|
|
430
|
-
set: setConversationId
|
|
431
|
-
},
|
|
432
|
-
accountId: {
|
|
433
|
-
get: () => msg.admission?.accountId ?? fallbackAccountId,
|
|
434
|
-
set: (value) => {
|
|
435
|
-
const next = value;
|
|
436
|
-
fallbackAccountId = next;
|
|
437
|
-
if (msg.admission) {
|
|
438
|
-
msg.admission.accountId = next;
|
|
439
|
-
msg.admission.account.accountId = next;
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
},
|
|
443
|
-
accessControlPassed: {
|
|
444
|
-
get: () => {
|
|
445
|
-
if (msg.admission?.ingress.decisiveGateId === "legacy-flat-compat") return fallbackAccessControlPassed;
|
|
446
|
-
return msg.admission ? msg.admission.ingress.decision === "allow" : fallbackAccessControlPassed;
|
|
447
|
-
},
|
|
448
|
-
set: (value) => {
|
|
449
|
-
if (!msg.admission) fallbackAccessControlPassed = value;
|
|
450
|
-
}
|
|
451
|
-
},
|
|
452
|
-
chatType: {
|
|
453
|
-
get: () => msg.admission?.conversation.kind ?? fallbackChatType,
|
|
454
|
-
set: (value) => {
|
|
455
|
-
const next = value;
|
|
456
|
-
fallbackChatType = next;
|
|
457
|
-
if (msg.admission) msg.admission.conversation.kind = next;
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
});
|
|
461
|
-
}
|
|
462
|
-
function withDeprecatedWebInboundMessageFlatAliases(msg) {
|
|
463
|
-
defineDeprecatedStructuredContextPayloadAlias(msg);
|
|
464
|
-
return defineDeprecatedAliasAccessors(defineDeprecatedAdmissionTopLevelAccessors(msg), {
|
|
465
|
-
id: {
|
|
466
|
-
get: () => msg.event.id,
|
|
467
|
-
set: (value) => msg.event.id = value
|
|
468
|
-
},
|
|
469
|
-
to: {
|
|
470
|
-
get: () => msg.platform.recipientJid,
|
|
471
|
-
set: (value) => msg.platform.recipientJid = value
|
|
472
|
-
},
|
|
473
|
-
body: {
|
|
474
|
-
get: () => msg.payload.body,
|
|
475
|
-
set: (value) => msg.payload.body = value
|
|
476
|
-
},
|
|
477
|
-
pushName: {
|
|
478
|
-
get: () => msg.platform.pushName,
|
|
479
|
-
set: (value) => msg.platform.pushName = value
|
|
480
|
-
},
|
|
481
|
-
timestamp: {
|
|
482
|
-
get: () => msg.event.timestamp,
|
|
483
|
-
set: (value) => msg.event.timestamp = value
|
|
484
|
-
},
|
|
485
|
-
chatId: {
|
|
486
|
-
get: () => msg.platform.chatJid,
|
|
487
|
-
set: (value) => msg.platform.chatJid = value
|
|
488
|
-
},
|
|
489
|
-
sender: {
|
|
490
|
-
get: () => msg.platform.sender,
|
|
491
|
-
set: (value) => msg.platform.sender = value
|
|
492
|
-
},
|
|
493
|
-
senderJid: {
|
|
494
|
-
get: () => msg.platform.senderJid,
|
|
495
|
-
set: (value) => msg.platform.senderJid = value
|
|
496
|
-
},
|
|
497
|
-
senderE164: {
|
|
498
|
-
get: () => msg.platform.senderE164,
|
|
499
|
-
set: (value) => msg.platform.senderE164 = value
|
|
500
|
-
},
|
|
501
|
-
senderName: {
|
|
502
|
-
get: () => msg.platform.senderName,
|
|
503
|
-
set: (value) => msg.platform.senderName = value
|
|
504
|
-
},
|
|
505
|
-
replyTo: {
|
|
506
|
-
get: () => msg.quote?.context,
|
|
507
|
-
set: (value) => ensureQuote(msg).context = value
|
|
508
|
-
},
|
|
509
|
-
replyToId: {
|
|
510
|
-
get: () => msg.quote?.id ?? msg.quote?.context?.id,
|
|
511
|
-
set: (value) => ensureQuote(msg).id = value
|
|
512
|
-
},
|
|
513
|
-
replyToBody: {
|
|
514
|
-
get: () => msg.quote?.body ?? msg.quote?.context?.body,
|
|
515
|
-
set: (value) => ensureQuote(msg).body = value
|
|
516
|
-
},
|
|
517
|
-
replyToSender: {
|
|
518
|
-
get: () => msg.quote?.context?.sender?.label ?? msg.quote?.sender?.displayName,
|
|
519
|
-
set: (value) => {
|
|
520
|
-
const sender = ensureQuoteSender(msg);
|
|
521
|
-
sender.displayName = value;
|
|
522
|
-
if (msg.quote?.context?.sender) msg.quote.context.sender.label = value;
|
|
523
|
-
}
|
|
524
|
-
},
|
|
525
|
-
replyToSenderJid: {
|
|
526
|
-
get: () => msg.quote?.context?.sender?.jid ?? msg.quote?.sender?.jid,
|
|
527
|
-
set: (value) => {
|
|
528
|
-
const jid = value;
|
|
529
|
-
ensureQuoteSender(msg).jid = jid;
|
|
530
|
-
if (msg.quote?.context?.sender) msg.quote.context.sender.jid = jid;
|
|
531
|
-
}
|
|
532
|
-
},
|
|
533
|
-
replyToSenderE164: {
|
|
534
|
-
get: () => msg.quote?.context?.sender?.e164 ?? msg.quote?.sender?.e164,
|
|
535
|
-
set: (value) => {
|
|
536
|
-
const e164 = value;
|
|
537
|
-
ensureQuoteSender(msg).e164 = e164;
|
|
538
|
-
if (msg.quote?.context?.sender) msg.quote.context.sender.e164 = e164;
|
|
539
|
-
}
|
|
540
|
-
},
|
|
541
|
-
groupSubject: {
|
|
542
|
-
get: () => msg.group?.subject,
|
|
543
|
-
set: (value) => ensureGroup(msg).subject = value
|
|
544
|
-
},
|
|
545
|
-
groupParticipants: {
|
|
546
|
-
get: () => msg.group?.participants,
|
|
547
|
-
set: (value) => ensureGroup(msg).participants = value
|
|
548
|
-
},
|
|
549
|
-
mentions: {
|
|
550
|
-
get: () => msg.group?.mentions?.jids,
|
|
551
|
-
set: (value) => ensureGroupMentions(msg).jids = value
|
|
552
|
-
},
|
|
553
|
-
mentionedJids: {
|
|
554
|
-
get: () => msg.group?.mentions?.jids,
|
|
555
|
-
set: (value) => ensureGroupMentions(msg).jids = value
|
|
556
|
-
},
|
|
557
|
-
self: {
|
|
558
|
-
get: () => msg.platform.self,
|
|
559
|
-
set: (value) => msg.platform.self = value
|
|
560
|
-
},
|
|
561
|
-
selfJid: {
|
|
562
|
-
get: () => msg.platform.selfJid,
|
|
563
|
-
set: (value) => msg.platform.selfJid = value
|
|
564
|
-
},
|
|
565
|
-
selfLid: {
|
|
566
|
-
get: () => msg.platform.selfLid,
|
|
567
|
-
set: (value) => msg.platform.selfLid = value
|
|
568
|
-
},
|
|
569
|
-
selfE164: {
|
|
570
|
-
get: () => msg.platform.selfE164,
|
|
571
|
-
set: (value) => msg.platform.selfE164 = value
|
|
572
|
-
},
|
|
573
|
-
fromMe: {
|
|
574
|
-
get: () => msg.platform.fromMe,
|
|
575
|
-
set: (value) => msg.platform.fromMe = value
|
|
576
|
-
},
|
|
577
|
-
location: {
|
|
578
|
-
get: () => msg.payload.location,
|
|
579
|
-
set: (value) => msg.payload.location = value
|
|
580
|
-
},
|
|
581
|
-
sendComposing: {
|
|
582
|
-
get: () => msg.platform.sendComposing,
|
|
583
|
-
set: (value) => msg.platform.sendComposing = value
|
|
584
|
-
},
|
|
585
|
-
reply: {
|
|
586
|
-
get: () => msg.platform.reply,
|
|
587
|
-
set: (value) => msg.platform.reply = value
|
|
588
|
-
},
|
|
589
|
-
sendMedia: {
|
|
590
|
-
get: () => msg.platform.sendMedia,
|
|
591
|
-
set: (value) => msg.platform.sendMedia = value
|
|
592
|
-
},
|
|
593
|
-
mediaPath: {
|
|
594
|
-
get: () => msg.payload.media?.path,
|
|
595
|
-
set: (value) => setMediaField(msg, "path", value)
|
|
596
|
-
},
|
|
597
|
-
mediaType: {
|
|
598
|
-
get: () => msg.payload.media?.type,
|
|
599
|
-
set: (value) => setMediaField(msg, "type", value)
|
|
600
|
-
},
|
|
601
|
-
mediaFileName: {
|
|
602
|
-
get: () => msg.payload.media?.fileName,
|
|
603
|
-
set: (value) => setMediaField(msg, "fileName", value)
|
|
604
|
-
},
|
|
605
|
-
mediaUrl: {
|
|
606
|
-
get: () => msg.payload.media?.url,
|
|
607
|
-
set: (value) => setMediaField(msg, "url", value)
|
|
608
|
-
},
|
|
609
|
-
channelStructuredContext: {
|
|
610
|
-
get: () => msg.payload.channelStructuredContext,
|
|
611
|
-
set: (value) => msg.payload.channelStructuredContext = value
|
|
612
|
-
},
|
|
613
|
-
untrustedStructuredContext: {
|
|
614
|
-
get: () => msg.payload.channelStructuredContext,
|
|
615
|
-
set: (value) => msg.payload.channelStructuredContext = value
|
|
616
|
-
},
|
|
617
|
-
isBatched: {
|
|
618
|
-
get: () => msg.event.isBatched,
|
|
619
|
-
set: (value) => msg.event.isBatched = value
|
|
620
|
-
}
|
|
621
|
-
});
|
|
622
|
-
}
|
|
623
|
-
function normalizeLegacyFlatWebInboundMessage(msg) {
|
|
624
|
-
const media = msg.mediaPath || msg.mediaType || msg.mediaFileName || msg.mediaUrl ? {
|
|
625
|
-
path: msg.mediaPath,
|
|
626
|
-
type: msg.mediaType,
|
|
627
|
-
fileName: msg.mediaFileName,
|
|
628
|
-
url: msg.mediaUrl
|
|
629
|
-
} : void 0;
|
|
630
|
-
return withDeprecatedWebInboundMessageFlatAliases({
|
|
631
|
-
...msg,
|
|
632
|
-
admission: msg.admission ?? buildDeprecatedFlatWhatsAppInboundAdmission(msg),
|
|
633
|
-
event: {
|
|
634
|
-
id: msg.id,
|
|
635
|
-
timestamp: msg.timestamp,
|
|
636
|
-
isBatched: msg.isBatched
|
|
637
|
-
},
|
|
638
|
-
payload: {
|
|
639
|
-
body: msg.body,
|
|
640
|
-
media,
|
|
641
|
-
location: msg.location,
|
|
642
|
-
channelStructuredContext: msg.channelStructuredContext ?? msg.untrustedStructuredContext
|
|
643
|
-
},
|
|
644
|
-
platform: {
|
|
645
|
-
chatJid: msg.chatId,
|
|
646
|
-
recipientJid: msg.to,
|
|
647
|
-
sender: msg.sender,
|
|
648
|
-
senderJid: msg.senderJid,
|
|
649
|
-
senderE164: msg.senderE164,
|
|
650
|
-
senderName: msg.senderName,
|
|
651
|
-
pushName: msg.pushName,
|
|
652
|
-
self: msg.self,
|
|
653
|
-
selfJid: msg.selfJid,
|
|
654
|
-
selfLid: msg.selfLid,
|
|
655
|
-
selfE164: msg.selfE164,
|
|
656
|
-
fromMe: msg.fromMe,
|
|
657
|
-
sendComposing: msg.sendComposing,
|
|
658
|
-
reply: msg.reply,
|
|
659
|
-
sendMedia: msg.sendMedia
|
|
660
|
-
},
|
|
661
|
-
quote: buildQuoteFromFlatAliases(msg),
|
|
662
|
-
group: buildGroupFromFlatAliases(msg)
|
|
663
|
-
});
|
|
664
|
-
}
|
|
665
|
-
function normalizeWebInboundMessage(msg) {
|
|
666
|
-
if (msg.event && msg.payload && msg.platform) return withDeprecatedWebInboundMessageFlatAliases(msg);
|
|
667
|
-
if (msg.event || msg.payload || msg.platform || msg.quote || msg.group) throw new Error("WhatsApp inbound messages must be either legacy flat or canonical nested; partial nested contexts are not supported.");
|
|
668
|
-
return normalizeLegacyFlatWebInboundMessage(msg);
|
|
669
|
-
}
|
|
670
|
-
function normalizeAdmittedWebInboundMessage(msg) {
|
|
671
|
-
return requireAdmittedWhatsAppInboundMessage(normalizeWebInboundMessage(msg));
|
|
672
|
-
}
|
|
673
|
-
//#endregion
|
|
674
273
|
//#region extensions/whatsapp/src/inbound/durable-payload.ts
|
|
675
274
|
var WhatsAppIngressPermanentError = class extends Error {
|
|
676
275
|
constructor(reason, message, options) {
|
|
@@ -817,8 +416,7 @@ function readGroupMetadataCacheEntry(cache, jid) {
|
|
|
817
416
|
function createWhatsAppGroupMetadataCacheOwner(params) {
|
|
818
417
|
const reconnectCache = params.reconnectCache ?? /* @__PURE__ */ new Map();
|
|
819
418
|
const localCache = /* @__PURE__ */ new Map();
|
|
820
|
-
const
|
|
821
|
-
const invalidatedJids = /* @__PURE__ */ new Set();
|
|
419
|
+
const groupMetadataGenerations = /* @__PURE__ */ new Map();
|
|
822
420
|
const detachListeners = [];
|
|
823
421
|
let closed = false;
|
|
824
422
|
let started = false;
|
|
@@ -848,46 +446,51 @@ function createWhatsAppGroupMetadataCacheOwner(params) {
|
|
|
848
446
|
});
|
|
849
447
|
const rememberFullUpdate = (jid, meta) => {
|
|
850
448
|
if (closed) return;
|
|
449
|
+
groupMetadataGenerations.set(jid, {});
|
|
851
450
|
rememberWhatsAppBaileysCacheEntry(params.baileysCache, jid, meta, GROUP_META_TTL_MS);
|
|
852
|
-
publishedJids.add(jid);
|
|
853
|
-
invalidatedJids.delete(jid);
|
|
854
451
|
rememberGroupMetadataCacheEntry(reconnectCache, jid, summarizeForReconnect(meta));
|
|
855
452
|
localCache.delete(jid);
|
|
856
453
|
};
|
|
857
454
|
const forgetFullMetadata = (jid) => {
|
|
455
|
+
groupMetadataGenerations.set(jid, {});
|
|
858
456
|
params.baileysCache?.delete(jid);
|
|
859
457
|
reconnectCache.delete(jid);
|
|
860
458
|
localCache.delete(jid);
|
|
861
|
-
publishedJids.delete(jid);
|
|
862
|
-
invalidatedJids.add(jid);
|
|
863
459
|
};
|
|
864
460
|
const get = async (jid) => {
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
const
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
rememberGroupMetadataCacheEntry(localCache, jid,
|
|
886
|
-
|
|
887
|
-
|
|
461
|
+
for (;;) {
|
|
462
|
+
if (closed) return { expires: resolveGroupMetadataExpiresAt() ?? 0 };
|
|
463
|
+
const cached = readGroupMetadataCacheEntry(localCache, jid);
|
|
464
|
+
if (cached) return cached;
|
|
465
|
+
const generation = groupMetadataGenerations.get(jid);
|
|
466
|
+
try {
|
|
467
|
+
const hydratedEntry = params.baileysCache?.get(jid);
|
|
468
|
+
const providerMetadata = params.baileysCache ? readWhatsAppBaileysCacheEntry(params.baileysCache, jid) : void 0;
|
|
469
|
+
const hydratedMetadata = providerMetadata?.participants?.length ? providerMetadata : void 0;
|
|
470
|
+
const meta = hydratedMetadata ?? await (params.getCurrentSock() ?? params.sock).groupMetadata(jid);
|
|
471
|
+
if (closed || groupMetadataGenerations.get(jid) !== generation) continue;
|
|
472
|
+
const entry = await summarize(meta);
|
|
473
|
+
if (closed || groupMetadataGenerations.get(jid) !== generation) continue;
|
|
474
|
+
if (hydratedMetadata && hydratedEntry) entry.expires = hydratedEntry.expiresAt;
|
|
475
|
+
else rememberWhatsAppBaileysCacheEntry(params.baileysCache, jid, meta, GROUP_META_TTL_MS);
|
|
476
|
+
groupMetadataGenerations.set(jid, {});
|
|
477
|
+
rememberGroupMetadataCacheEntry(reconnectCache, jid, {
|
|
478
|
+
subject: entry.subject,
|
|
479
|
+
expires: entry.expires
|
|
480
|
+
});
|
|
481
|
+
rememberGroupMetadataCacheEntry(localCache, jid, entry);
|
|
482
|
+
return entry;
|
|
483
|
+
} catch (error) {
|
|
484
|
+
if (closed || groupMetadataGenerations.get(jid) !== generation) continue;
|
|
485
|
+
const hydrated = readGroupMetadataCacheEntry(reconnectCache, jid);
|
|
486
|
+
if (hydrated) {
|
|
487
|
+
rememberGroupMetadataCacheEntry(localCache, jid, hydrated);
|
|
488
|
+
params.logVerbose(`Using cached group metadata for ${jid} after fetch failure: ${String(error)}`);
|
|
489
|
+
return hydrated;
|
|
490
|
+
}
|
|
491
|
+
params.logVerbose(`Failed to fetch group metadata for ${jid}: ${String(error)}`);
|
|
492
|
+
return { expires: resolveGroupMetadataExpiresAt() ?? 0 };
|
|
888
493
|
}
|
|
889
|
-
params.logVerbose(`Failed to fetch group metadata for ${jid}: ${String(error)}`);
|
|
890
|
-
return { expires: resolveGroupMetadataExpiresAt() ?? 0 };
|
|
891
494
|
}
|
|
892
495
|
};
|
|
893
496
|
const resolveOutboundMentions = async (jid, text) => {
|
|
@@ -945,10 +548,10 @@ function createWhatsAppGroupMetadataCacheOwner(params) {
|
|
|
945
548
|
try {
|
|
946
549
|
const groups = await params.sock.groupFetchAllParticipating();
|
|
947
550
|
if (closed) return;
|
|
948
|
-
for (const [jid, meta] of Object.entries(groups ?? {})) if (meta && !
|
|
551
|
+
for (const [jid, meta] of Object.entries(groups ?? {})) if (meta && !groupMetadataGenerations.has(jid)) {
|
|
949
552
|
rememberGroupMetadataCacheEntry(reconnectCache, jid, summarizeForReconnect(meta));
|
|
950
553
|
rememberWhatsAppBaileysCacheEntry(params.baileysCache, jid, meta, GROUP_META_TTL_MS);
|
|
951
|
-
|
|
554
|
+
groupMetadataGenerations.set(jid, {});
|
|
952
555
|
}
|
|
953
556
|
params.logVerbose(`Hydrated ${Object.keys(groups ?? {}).length} participating groups on connect`);
|
|
954
557
|
} catch (error) {
|
|
@@ -1063,7 +666,7 @@ function createWhatsAppInboundMessageDebouncer(options) {
|
|
|
1063
666
|
...last.group,
|
|
1064
667
|
mentions: combinedMentions
|
|
1065
668
|
} : void 0;
|
|
1066
|
-
const combinedMessage = attachWhatsAppIngressLifecycle(
|
|
669
|
+
const combinedMessage = attachWhatsAppIngressLifecycle({
|
|
1067
670
|
...last,
|
|
1068
671
|
turnAdoptionLifecycle: admissionLifecycle,
|
|
1069
672
|
payload: {
|
|
@@ -1076,7 +679,7 @@ function createWhatsAppInboundMessageDebouncer(options) {
|
|
|
1076
679
|
...last.event,
|
|
1077
680
|
isBatched: true
|
|
1078
681
|
}
|
|
1079
|
-
}
|
|
682
|
+
}, admissionLifecycle);
|
|
1080
683
|
await options.onMessage(combinedMessage);
|
|
1081
684
|
await settle();
|
|
1082
685
|
await Promise.all(orderedEntries.map((entry) => options.markRead(entry.readReceipt)));
|
|
@@ -1145,8 +748,8 @@ function createWhatsAppInboundMessageDebouncer(options) {
|
|
|
1145
748
|
function unwrapMessage(message) {
|
|
1146
749
|
return normalizeMessageContent$1(message);
|
|
1147
750
|
}
|
|
1148
|
-
async function downloadInboundMedia(msg, sock, maxBytes = 50 * 1024 * 1024) {
|
|
1149
|
-
const message = unwrapMessage(msg.message);
|
|
751
|
+
async function downloadInboundMedia(msg, sock, maxBytes = 50 * 1024 * 1024, normalizedMessage) {
|
|
752
|
+
const message = normalizedMessage ?? unwrapMessage(msg.message);
|
|
1150
753
|
if (!message) return;
|
|
1151
754
|
const mimetype = resolveInboundMediaMimetype(message);
|
|
1152
755
|
const fileName = message.documentMessage?.fileName ?? void 0;
|
|
@@ -1214,17 +817,18 @@ function logMediaMaterializationFailure(params) {
|
|
|
1214
817
|
}
|
|
1215
818
|
async function enrichWhatsAppInboundMessage(params) {
|
|
1216
819
|
const { msg, sock } = params;
|
|
1217
|
-
const
|
|
820
|
+
const messageProjection = projectWhatsAppInboundMessage(msg.message ?? void 0);
|
|
821
|
+
const location = extractLocationData(messageProjection);
|
|
1218
822
|
const locationText = location ? formatLocationText(location) : void 0;
|
|
1219
|
-
const contactContext = extractContactContext(
|
|
1220
|
-
const externalAdReplyContext = extractExternalAdReplyContext(
|
|
1221
|
-
let mediaKind = extractMediaKind(
|
|
1222
|
-
let body = extractText(
|
|
823
|
+
const contactContext = extractContactContext(messageProjection);
|
|
824
|
+
const externalAdReplyContext = extractExternalAdReplyContext(messageProjection);
|
|
825
|
+
let mediaKind = extractMediaKind(messageProjection);
|
|
826
|
+
let body = extractText(messageProjection);
|
|
1223
827
|
if (locationText) body = [body, locationText].filter(Boolean).join("\n").trim();
|
|
1224
828
|
if (!body && !mediaKind) return null;
|
|
1225
829
|
body = body ?? "";
|
|
1226
830
|
const commandBody = body;
|
|
1227
|
-
const replyContext = describeReplyContext(
|
|
831
|
+
const replyContext = describeReplyContext(messageProjection);
|
|
1228
832
|
let mediaPath;
|
|
1229
833
|
let mediaType = mediaKind ? resolveInboundMediaMimetype(msg.message) : void 0;
|
|
1230
834
|
const nativeMedia = mediaKind ? {
|
|
@@ -1240,7 +844,7 @@ async function enrichWhatsAppInboundMessage(params) {
|
|
|
1240
844
|
mediaFileName = inboundMedia.fileName;
|
|
1241
845
|
};
|
|
1242
846
|
try {
|
|
1243
|
-
await saveInboundMedia(await downloadInboundMedia(msg, sock, maxBytes));
|
|
847
|
+
await saveInboundMedia(await downloadInboundMedia(msg, sock, maxBytes, messageProjection[0]));
|
|
1244
848
|
} catch (error) {
|
|
1245
849
|
logMediaMaterializationFailure({
|
|
1246
850
|
messageId: msg.key?.id,
|
|
@@ -1284,7 +888,8 @@ async function enrichWhatsAppInboundMessage(params) {
|
|
|
1284
888
|
mediaType,
|
|
1285
889
|
mediaFileName,
|
|
1286
890
|
mediaKind,
|
|
1287
|
-
nativeMedia
|
|
891
|
+
nativeMedia,
|
|
892
|
+
mentionedJids: extractMentionedJids(messageProjection)
|
|
1288
893
|
};
|
|
1289
894
|
}
|
|
1290
895
|
//#endregion
|
|
@@ -1617,7 +1222,7 @@ function createWhatsAppMessageDeliveryCoordinator(options) {
|
|
|
1617
1222
|
return normalizeWhatsAppSendResult(await sendTrackedMessage(chatJid, await groupMetadata.applyOutboundMentions(chatJid, previewPayload), optionsValue), "media");
|
|
1618
1223
|
};
|
|
1619
1224
|
const timestamp = inbound.messageTimestampMs;
|
|
1620
|
-
const mentionedJids =
|
|
1225
|
+
const mentionedJids = enriched.mentionedJids;
|
|
1621
1226
|
const senderName = msg.pushName ?? void 0;
|
|
1622
1227
|
inboundLogger.info({
|
|
1623
1228
|
from: inbound.from,
|
|
@@ -1660,7 +1265,7 @@ function createWhatsAppMessageDeliveryCoordinator(options) {
|
|
|
1660
1265
|
payload: enriched.externalAdReplyContext
|
|
1661
1266
|
}] : []
|
|
1662
1267
|
];
|
|
1663
|
-
const inboundMessage =
|
|
1268
|
+
const inboundMessage = {
|
|
1664
1269
|
admission: inbound.access.admission,
|
|
1665
1270
|
event: {
|
|
1666
1271
|
id: inbound.id,
|
|
@@ -1709,7 +1314,7 @@ function createWhatsAppMessageDeliveryCoordinator(options) {
|
|
|
1709
1314
|
turnAdoptionLifecycle: durable.turnAdoptionLifecycle,
|
|
1710
1315
|
readReceipt: durable.readReceipt,
|
|
1711
1316
|
receiveOrder: durable.receiveOrder
|
|
1712
|
-
}
|
|
1317
|
+
};
|
|
1713
1318
|
if (inboundMessage.event.id) {
|
|
1714
1319
|
const admission = requireWhatsAppInboundAdmission(inboundMessage);
|
|
1715
1320
|
cacheInboundMessageMeta(admission.accountId, inboundMessage.platform.chatJid, inboundMessage.event.id, {
|
|
@@ -2263,10 +1868,6 @@ async function monitorWebInbox(options) {
|
|
|
2263
1868
|
}
|
|
2264
1869
|
return attachWebInboxToSocket({
|
|
2265
1870
|
...options,
|
|
2266
|
-
onMessage: async (msg) => {
|
|
2267
|
-
await options.onMessage(normalizeAdmittedWebInboundMessage(msg));
|
|
2268
|
-
},
|
|
2269
|
-
shouldDebounce: options.shouldDebounce ? (msg) => options.shouldDebounce?.(normalizeAdmittedWebInboundMessage(msg)) ?? true : void 0,
|
|
2270
1871
|
socketTiming,
|
|
2271
1872
|
sock,
|
|
2272
1873
|
recentMessageKeys,
|
|
@@ -2700,11 +2301,6 @@ async function maybeBroadcastMessage(params) {
|
|
|
2700
2301
|
return true;
|
|
2701
2302
|
}
|
|
2702
2303
|
//#endregion
|
|
2703
|
-
//#region extensions/whatsapp/src/auto-reply/monitor/audio-transcript.ts
|
|
2704
|
-
function formatWhatsAppAudioTranscriptForAgent(transcript) {
|
|
2705
|
-
return `[Audio transcript (machine-generated, untrusted)]: ${JSON.stringify(transcript)}`;
|
|
2706
|
-
}
|
|
2707
|
-
//#endregion
|
|
2708
2304
|
//#region extensions/whatsapp/src/auto-reply/monitor/commands.ts
|
|
2709
2305
|
function stripMentionsForCommand(text, mentionRegexes, selfE164) {
|
|
2710
2306
|
let result = text;
|
|
@@ -2901,7 +2497,7 @@ async function applyGroupGating(params) {
|
|
|
2901
2497
|
needsMentionText: true
|
|
2902
2498
|
};
|
|
2903
2499
|
}
|
|
2904
|
-
const pendingHistoryBody = params.mentionText === void 0 ? void 0 :
|
|
2500
|
+
const pendingHistoryBody = params.mentionText === void 0 ? void 0 : formatAudioTranscriptForAgent(params.mentionText);
|
|
2905
2501
|
return skipGroupMessageAndStoreHistory(params, `Group message stored for context (no mention detected) in ${conversationId}: ${mentionMsg.payload.body}`, pendingHistoryBody);
|
|
2906
2502
|
}
|
|
2907
2503
|
return { shouldProcess: true };
|
|
@@ -3162,7 +2758,8 @@ async function deliverWebReplyInActivityScope(params) {
|
|
|
3162
2758
|
const tableMode = params.tableMode ?? "code";
|
|
3163
2759
|
const chunkMode = params.chunkMode ?? "length";
|
|
3164
2760
|
const normalizedReply = params.normalizedReplyResult ?? normalizeWhatsAppOutboundPayload(replyResult, { normalizeText: normalizeWhatsAppPayloadTextPreservingIndentation });
|
|
3165
|
-
const
|
|
2761
|
+
const text = normalizedReply.text ?? "";
|
|
2762
|
+
const textChunks = resolveTextChunksWithFallback(text, markdownToWhatsAppChunks(text, textLimit, tableMode, chunkMode));
|
|
3166
2763
|
const mediaList = normalizedReply.mediaUrls ?? [];
|
|
3167
2764
|
const getQuote = () => {
|
|
3168
2765
|
if (!replyResult.replyToId) return;
|
|
@@ -3923,8 +3520,7 @@ async function finalizeWhatsAppStatusReaction(params) {
|
|
|
3923
3520
|
//#endregion
|
|
3924
3521
|
//#region extensions/whatsapp/src/auto-reply/monitor/message-line.runtime.ts
|
|
3925
3522
|
function resolveIdentityNamePrefix(cfg, agentId) {
|
|
3926
|
-
const
|
|
3927
|
-
const identityName = cfg.agents?.list?.find((agent) => normalizeAgentId(agent.id ?? "") === normalizedAgentId)?.identity?.name?.trim();
|
|
3523
|
+
const identityName = resolveAgentConfig(cfg, agentId)?.identity?.name?.trim();
|
|
3928
3524
|
return identityName ? `[${identityName}]` : void 0;
|
|
3929
3525
|
}
|
|
3930
3526
|
function resolveMessagePrefix(cfg, agentId, opts) {
|
|
@@ -4092,7 +3688,7 @@ async function processMessage(params) {
|
|
|
4092
3688
|
...params.msg,
|
|
4093
3689
|
payload: {
|
|
4094
3690
|
...params.msg.payload,
|
|
4095
|
-
body:
|
|
3691
|
+
body: formatAudioTranscriptForAgent(audioTranscript)
|
|
4096
3692
|
}
|
|
4097
3693
|
} : params.msg;
|
|
4098
3694
|
const visibleReplyTo = resolveVisibleWhatsAppReplyContext({
|
|
@@ -4323,6 +3919,7 @@ async function processMessage(params) {
|
|
|
4323
3919
|
sessionKey: params.route.sessionKey
|
|
4324
3920
|
},
|
|
4325
3921
|
ctxPayload,
|
|
3922
|
+
dispatchReplyFromConfig: params.dispatchReplyFromConfig,
|
|
4326
3923
|
record: {
|
|
4327
3924
|
onRecordError: (err) => {
|
|
4328
3925
|
params.replyLogger.warn({
|
|
@@ -4357,19 +3954,13 @@ async function processMessage(params) {
|
|
|
4357
3954
|
}
|
|
4358
3955
|
//#endregion
|
|
4359
3956
|
//#region extensions/whatsapp/src/auto-reply/monitor/on-message.ts
|
|
4360
|
-
function readDeprecatedAccessControlPassed(msg) {
|
|
4361
|
-
return msg.accessControlPassed;
|
|
4362
|
-
}
|
|
4363
3957
|
function createWebOnMessageHandler(params) {
|
|
4364
|
-
const hasExplicitlyPassedInboundAccess = (msg) =>
|
|
4365
|
-
if (msg.admission.ingress.decisiveGateId === "legacy-flat-compat") return readDeprecatedAccessControlPassed(msg) === true;
|
|
4366
|
-
return msg.admission.ingress.decision === "allow";
|
|
4367
|
-
};
|
|
3958
|
+
const hasExplicitlyPassedInboundAccess = (msg) => msg.admission.ingress.decision === "allow";
|
|
4368
3959
|
const withDirectSenderPeer = (msg, peerId) => {
|
|
4369
3960
|
if (requireWhatsAppInboundAdmission(msg).conversation.kind === "group" || msg.platform.sender?.e164 || msg.platform.senderE164 || !peerId.startsWith("+")) return msg;
|
|
4370
3961
|
const normalized = normalizeE164(peerId);
|
|
4371
3962
|
if (!normalized) return msg;
|
|
4372
|
-
return
|
|
3963
|
+
return {
|
|
4373
3964
|
...msg,
|
|
4374
3965
|
platform: {
|
|
4375
3966
|
...msg.platform,
|
|
@@ -4379,7 +3970,7 @@ function createWebOnMessageHandler(params) {
|
|
|
4379
3970
|
},
|
|
4380
3971
|
senderE164: normalized
|
|
4381
3972
|
}
|
|
4382
|
-
}
|
|
3973
|
+
};
|
|
4383
3974
|
};
|
|
4384
3975
|
const processForRoute = async (cfg, msg, route, groupHistoryKey, opts) => {
|
|
4385
3976
|
const processParams = {
|
|
@@ -4396,7 +3987,8 @@ function createWebOnMessageHandler(params) {
|
|
|
4396
3987
|
replyResolver: params.replyResolver,
|
|
4397
3988
|
replyLogger: params.replyLogger,
|
|
4398
3989
|
backgroundTasks: params.backgroundTasks,
|
|
4399
|
-
buildContext: params.buildContext
|
|
3990
|
+
buildContext: params.buildContext,
|
|
3991
|
+
dispatchReplyFromConfig: params.dispatchReplyFromConfig
|
|
4400
3992
|
};
|
|
4401
3993
|
if (opts?.groupHistory !== void 0) processParams.groupHistory = opts.groupHistory;
|
|
4402
3994
|
if (opts?.suppressGroupHistoryClear !== void 0) processParams.suppressGroupHistoryClear = opts.suppressGroupHistoryClear;
|
|
@@ -4745,15 +4337,12 @@ async function monitorWebChannel(verbose, listenerFactory = attachWebInboxToSock
|
|
|
4745
4337
|
cfg,
|
|
4746
4338
|
channel: "whatsapp"
|
|
4747
4339
|
});
|
|
4748
|
-
const shouldDebounce = (msg) => {
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
allowDebounce: !(admitted.payload.location || admitted.quote?.id || admitted.quote?.body)
|
|
4755
|
-
});
|
|
4756
|
-
};
|
|
4340
|
+
const shouldDebounce = (msg) => shouldDebounceTextInbound({
|
|
4341
|
+
text: msg.payload.commandBody ?? msg.payload.body,
|
|
4342
|
+
cfg,
|
|
4343
|
+
hasMedia: Boolean(msg.payload.media?.path || msg.payload.media?.type),
|
|
4344
|
+
allowDebounce: !(msg.payload.location || msg.quote?.id || msg.quote?.body)
|
|
4345
|
+
});
|
|
4757
4346
|
let connection;
|
|
4758
4347
|
try {
|
|
4759
4348
|
connection = await controller.openConnection({
|
|
@@ -4764,6 +4353,7 @@ async function monitorWebChannel(verbose, listenerFactory = attachWebInboxToSock
|
|
|
4764
4353
|
return meta?.participants?.length ? meta : void 0;
|
|
4765
4354
|
},
|
|
4766
4355
|
createListener: async ({ sock, connection: connectionLocal }) => {
|
|
4356
|
+
const pluginChannelRuntime = tuning.channelRuntime;
|
|
4767
4357
|
const onMessage = createWebOnMessageHandler({
|
|
4768
4358
|
cfg,
|
|
4769
4359
|
loadConfig: loadCurrentMonitorConfig,
|
|
@@ -4778,7 +4368,8 @@ async function monitorWebChannel(verbose, listenerFactory = attachWebInboxToSock
|
|
|
4778
4368
|
replyLogger,
|
|
4779
4369
|
baseMentionConfig,
|
|
4780
4370
|
account,
|
|
4781
|
-
buildContext:
|
|
4371
|
+
buildContext: pluginChannelRuntime?.inbound.buildContext,
|
|
4372
|
+
dispatchReplyFromConfig: pluginChannelRuntime?.reply?.dispatchReplyFromConfig
|
|
4782
4373
|
});
|
|
4783
4374
|
return await (listenerFactory ?? attachWebInboxToSocket)({
|
|
4784
4375
|
cfg,
|
|
@@ -4805,11 +4396,10 @@ async function monitorWebChannel(verbose, listenerFactory = attachWebInboxToSock
|
|
|
4805
4396
|
recentMessageKeys,
|
|
4806
4397
|
baileysGroupMetaCache,
|
|
4807
4398
|
onMessage: async (msg) => {
|
|
4808
|
-
const admitted = normalizeAdmittedWebInboundMessage(msg);
|
|
4809
4399
|
const inboundAt = Date.now();
|
|
4810
4400
|
controller.noteInbound(inboundAt);
|
|
4811
4401
|
statusController.noteInbound(inboundAt);
|
|
4812
|
-
await onMessage(
|
|
4402
|
+
await onMessage(msg);
|
|
4813
4403
|
},
|
|
4814
4404
|
onPendingWorkChanged: (pendingWorkCount, at) => {
|
|
4815
4405
|
statusController.noteBusy(pendingWorkCount > 0, at);
|