@openclaw/whatsapp 2026.7.2-beta.2 → 2026.7.2-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{access-control-DazDX3RB.js → access-control-CRz_v6bR.js} +4 -5
- package/dist/{accounts-CKOFMPf-.js → accounts-CxPuEFi-.js} +44 -4
- package/dist/{action-runtime-Bf-12TIH.js → action-runtime-CHU7xb6o.js} +2 -2
- package/dist/action-runtime-api.js +1 -1
- package/dist/action-runtime.runtime.js +1 -1
- package/dist/{active-listener-5kHap439.js → active-listener-BEjWsCNM.js} +1 -1
- package/dist/api.js +12 -15
- package/dist/{approval-handler.runtime-CBiGQuZ5.js → approval-handler.runtime-C4ddB7Kc.js} +4 -4
- package/dist/{approval-reactions-BGQoz25s.js → approval-reactions-P2HXjmln.js} +3 -3
- package/dist/{auth-store-BQi9pZqQ.js → auth-store-DirYMTbo.js} +4 -3
- package/dist/call-tool-api.js +4 -4
- package/dist/{channel-DbadDUDD.js → channel-B9xjrOGG.js} +37 -19
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel-react-action-PoRWfP9x.js → channel-react-action-CBW-PA8q.js} +10 -13
- package/dist/{channel.runtime-BDDy4Lhz.js → channel.runtime-DdKuhlNu.js} +5 -5
- package/dist/{channel.setup-BZ-po8fg.js → channel.setup-DXUCPHel.js} +3 -6
- package/dist/{config-schema-BZ8h1hWA.js → config-schema-C6IeKIC0.js} +6 -0
- package/dist/{connection-controller-C1rwfWb4.js → connection-controller-BVRExqrB.js} +186 -27
- package/dist/connection-controller-runtime-context-DG0tuYuw.js +23 -0
- package/dist/contract-api.js +1 -1
- package/dist/directory-config-BTbJkV1W.js +196 -0
- package/dist/directory-contract-api.js +1 -1
- package/dist/doctor-CwzVXKoE.js +10 -0
- package/dist/doctor-contract-api.js +35 -79
- package/dist/{group-session-key-CLTZeH_F.js → group-session-key-DJSdYfnb.js} +9 -4
- package/dist/{identity-D7L8LCuH.js → identity-BM4_wZeM.js} +2 -2
- package/dist/light-runtime-api.js +2 -2
- package/dist/{login-DGIoToX8.js → login-BKUm7KSk.js} +6 -7
- package/dist/{login-qr-X-CZHOk9.js → login-qr-DagJvMbg.js} +7 -8
- package/dist/login-qr-runtime.js +1 -1
- package/dist/{monitor-BZ8QvCeV.js → monitor-CBVNJ2lb.js} +623 -400
- package/dist/question-reactions-CaOrSYzU.js +142 -0
- package/dist/runtime-BLlToOi6.js +21 -0
- package/dist/runtime-api.js +10 -10
- package/dist/runtime-setter-api.js +1 -1
- package/dist/{send-D9Ydnn4o.js → send-DhJVN30g.js} +38 -85
- package/dist/{send-api-W33lI2nR.js → send-api-CpHwbor_.js} +38 -32
- package/dist/{setup-finalize-DBf1jjBj.js → setup-finalize-9XzKdFq6.js} +3 -3
- package/dist/setup-plugin-api.js +1 -1
- package/dist/{setup-surface-CiKGdNJv.js → setup-surface-Kv3mPki2.js} +3 -3
- package/dist/{setup-core-3aSOoK2T.js → shared-CuqHFnKd.js} +78 -56
- package/dist/{session-mxWFn0eS.js → socket-close-BoSHhQNJ.js} +226 -7
- package/dist/{targets-runtime-Bsh0HR9y.js → targets-runtime-CKFrhoX4.js} +142 -29
- package/dist/text-runtime-CU_IlbK5.js +4 -0
- package/node_modules/@protobufjs/utf8/CHANGELOG.md +8 -0
- package/node_modules/@protobufjs/utf8/index.js +29 -18
- package/node_modules/@protobufjs/utf8/package.json +2 -2
- package/node_modules/@protobufjs/utf8/tests/index.js +5 -0
- package/node_modules/@thi.ng/bitstream/package.json +4 -4
- package/node_modules/@thi.ng/errors/package.json +4 -4
- package/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/node/fs/promises.d.ts +16 -6
- package/node_modules/@types/node/package.json +2 -2
- package/node_modules/audio-type/package.json +3 -2
- package/node_modules/lru-cache/dist/commonjs/browser/index.d.ts.map +1 -1
- package/node_modules/lru-cache/dist/commonjs/browser/index.js +11 -4
- package/node_modules/lru-cache/dist/commonjs/browser/index.js.map +1 -1
- package/node_modules/lru-cache/dist/commonjs/browser/index.min.js +1 -1
- package/node_modules/lru-cache/dist/commonjs/browser/index.min.js.map +3 -3
- package/node_modules/lru-cache/dist/commonjs/index.d.ts.map +1 -1
- package/node_modules/lru-cache/dist/commonjs/index.js +11 -4
- package/node_modules/lru-cache/dist/commonjs/index.js.map +1 -1
- package/node_modules/lru-cache/dist/commonjs/index.min.js +1 -1
- package/node_modules/lru-cache/dist/commonjs/index.min.js.map +3 -3
- package/node_modules/lru-cache/dist/commonjs/node/index.d.ts.map +1 -1
- package/node_modules/lru-cache/dist/commonjs/node/index.js +11 -4
- package/node_modules/lru-cache/dist/commonjs/node/index.js.map +1 -1
- package/node_modules/lru-cache/dist/commonjs/node/index.min.js +1 -1
- package/node_modules/lru-cache/dist/commonjs/node/index.min.js.map +3 -3
- package/node_modules/lru-cache/dist/esm/browser/index.d.ts.map +1 -1
- package/node_modules/lru-cache/dist/esm/browser/index.js +11 -4
- package/node_modules/lru-cache/dist/esm/browser/index.js.map +1 -1
- package/node_modules/lru-cache/dist/esm/browser/index.min.js +1 -1
- package/node_modules/lru-cache/dist/esm/browser/index.min.js.map +3 -3
- package/node_modules/lru-cache/dist/esm/index.d.ts.map +1 -1
- package/node_modules/lru-cache/dist/esm/index.js +11 -4
- package/node_modules/lru-cache/dist/esm/index.js.map +1 -1
- package/node_modules/lru-cache/dist/esm/index.min.js +1 -1
- package/node_modules/lru-cache/dist/esm/index.min.js.map +3 -3
- package/node_modules/lru-cache/dist/esm/node/index.d.ts.map +1 -1
- package/node_modules/lru-cache/dist/esm/node/index.js +11 -4
- package/node_modules/lru-cache/dist/esm/node/index.js.map +1 -1
- package/node_modules/lru-cache/dist/esm/node/index.min.js +1 -1
- package/node_modules/lru-cache/dist/esm/node/index.min.js.map +3 -3
- package/node_modules/lru-cache/package.json +1 -1
- package/node_modules/music-metadata/lib/common/Util.d.ts +1 -1
- package/node_modules/music-metadata/lib/common/Util.js +7 -1
- package/node_modules/music-metadata/lib/id3v2/FrameHeader.js +23 -3
- package/node_modules/music-metadata/lib/id3v2/FrameParser.js +2 -2
- package/node_modules/music-metadata/lib/id3v2/ID3v2Token.js +1 -1
- package/node_modules/music-metadata/lib/mp4/AtomToken.js +38 -13
- package/node_modules/music-metadata/lib/mpeg/MpegParser.js +1 -1
- package/node_modules/music-metadata/package.json +6 -6
- package/node_modules/p-queue/dist/index.js +17 -6
- package/node_modules/p-queue/package.json +1 -1
- package/node_modules/protobufjs/dist/light/protobuf.js +145 -188
- package/node_modules/protobufjs/dist/light/protobuf.js.map +1 -1
- package/node_modules/protobufjs/dist/light/protobuf.min.js +3 -3
- package/node_modules/protobufjs/dist/light/protobuf.min.js.map +1 -1
- package/node_modules/protobufjs/dist/minimal/protobuf.js +33 -76
- package/node_modules/protobufjs/dist/minimal/protobuf.js.map +1 -1
- package/node_modules/protobufjs/dist/minimal/protobuf.min.js +3 -3
- package/node_modules/protobufjs/dist/minimal/protobuf.min.js.map +1 -1
- package/node_modules/protobufjs/dist/protobuf.js +168 -208
- package/node_modules/protobufjs/dist/protobuf.js.map +1 -1
- package/node_modules/protobufjs/dist/protobuf.min.js +3 -3
- package/node_modules/protobufjs/dist/protobuf.min.js.map +1 -1
- package/node_modules/protobufjs/index.d.ts +0 -8
- package/node_modules/protobufjs/package.json +2 -3
- package/node_modules/protobufjs/src/parse.js +3 -0
- package/node_modules/protobufjs/src/util/minimal.js +0 -3
- package/node_modules/typebox/build/compile/validator.d.mts +1 -4
- package/node_modules/typebox/build/guard/guard.d.mts +1 -1
- package/node_modules/typebox/build/guard/guard.mjs +5 -2
- package/node_modules/typebox/build/guard/string.mjs +16 -4
- package/node_modules/typebox/build/schema/engine/_functions.mjs +34 -15
- package/node_modules/typebox/build/type/action/readonly_object.d.mts +5 -0
- package/node_modules/typebox/build/type/action/readonly_object.mjs +8 -0
- package/node_modules/typebox/build/typebox.d.mts +1 -1
- package/node_modules/typebox/build/typebox.mjs +1 -1
- package/node_modules/typebox/package.json +1 -1
- package/node_modules/typebox/readme.md +29 -32
- package/node_modules/ws/lib/receiver.js +15 -32
- package/node_modules/ws/lib/websocket-server.js +4 -4
- package/node_modules/ws/lib/websocket.js +4 -4
- package/node_modules/ws/package.json +5 -1
- package/npm-shrinkwrap.json +41 -45
- package/openclaw.plugin.json +139 -179
- package/package.json +21 -11
- package/dist/account-config-LiT9wWH9.js +0 -43
- package/dist/connection-controller-runtime-context-CbTsqmPT.js +0 -14
- package/dist/directory-config-CLBQrjtC.js +0 -37
- package/dist/doctor-By3SB4lm.js +0 -48
- package/dist/runtime-BfAdAEYT.js +0 -8
- package/dist/text-runtime-BTGkMN0o.js +0 -4
- package/node_modules/@protobufjs/inquire/CHANGELOG.md +0 -8
- package/node_modules/@protobufjs/inquire/LICENSE +0 -26
- package/node_modules/@protobufjs/inquire/README.md +0 -13
- package/node_modules/@protobufjs/inquire/index.d.ts +0 -10
- package/node_modules/@protobufjs/inquire/index.js +0 -38
- package/node_modules/@protobufjs/inquire/package.json +0 -21
- package/node_modules/@protobufjs/inquire/tests/data/array.js +0 -1
- package/node_modules/@protobufjs/inquire/tests/data/emptyArray.js +0 -1
- package/node_modules/@protobufjs/inquire/tests/data/emptyObject.js +0 -1
- package/node_modules/@protobufjs/inquire/tests/data/object.js +0 -1
- package/node_modules/@protobufjs/inquire/tests/index.js +0 -20
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
|
|
2
|
+
import { a as resolveWhatsAppAccount } from "./accounts-CxPuEFi-.js";
|
|
3
|
+
import { questionGatewayRuntime } from "openclaw/plugin-sdk/question-gateway-runtime";
|
|
4
|
+
//#region extensions/whatsapp/src/question-reactions.ts
|
|
5
|
+
var question_reactions_exports = /* @__PURE__ */ __exportAll({
|
|
6
|
+
clearWhatsAppQuestionReactionTargetsForTest: () => clearWhatsAppQuestionReactionTargetsForTest,
|
|
7
|
+
maybeResolveWhatsAppQuestionReaction: () => maybeResolveWhatsAppQuestionReaction,
|
|
8
|
+
registerWhatsAppQuestionReactionTargetForDeliveredPayload: () => registerWhatsAppQuestionReactionTargetForDeliveredPayload
|
|
9
|
+
});
|
|
10
|
+
const TARGET_TTL_MS = 1440 * 60 * 1e3;
|
|
11
|
+
const targets = /* @__PURE__ */ new Map();
|
|
12
|
+
function storeTarget(key, binding) {
|
|
13
|
+
const existing = targets.get(key);
|
|
14
|
+
if (existing) clearTimeout(existing.cleanupTimer);
|
|
15
|
+
const target = {
|
|
16
|
+
...binding,
|
|
17
|
+
terminal: false,
|
|
18
|
+
expiresAtMs: Date.now() + TARGET_TTL_MS,
|
|
19
|
+
cleanupTimer: setTimeout(() => {
|
|
20
|
+
if (targets.get(key) === target) targets.delete(key);
|
|
21
|
+
}, TARGET_TTL_MS)
|
|
22
|
+
};
|
|
23
|
+
target.cleanupTimer.unref?.();
|
|
24
|
+
targets.set(key, target);
|
|
25
|
+
questionGatewayRuntime.registerChannelDelivery({
|
|
26
|
+
questionId: binding.questionId,
|
|
27
|
+
deliveryId: `whatsapp-reaction:${key}`,
|
|
28
|
+
finalize: () => {
|
|
29
|
+
target.terminal = true;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function buildKey(accountId, remoteJid, messageId) {
|
|
34
|
+
const parts = [
|
|
35
|
+
accountId,
|
|
36
|
+
remoteJid,
|
|
37
|
+
messageId
|
|
38
|
+
].map((part) => part.trim());
|
|
39
|
+
return parts.every(Boolean) ? parts.join(":") : void 0;
|
|
40
|
+
}
|
|
41
|
+
function addCandidate(values, value) {
|
|
42
|
+
const normalized = value?.trim();
|
|
43
|
+
if (normalized && !values.includes(normalized)) values.push(normalized);
|
|
44
|
+
}
|
|
45
|
+
function listDeliveredIdentities(results) {
|
|
46
|
+
const identities = [];
|
|
47
|
+
const seen = /* @__PURE__ */ new Set();
|
|
48
|
+
const add = (messageId, remoteJid) => {
|
|
49
|
+
const id = messageId?.trim() ?? "";
|
|
50
|
+
const jid = remoteJid?.trim() ?? "";
|
|
51
|
+
const key = `${jid}:${id}`;
|
|
52
|
+
if (id && id !== "unknown" && jid && !seen.has(key)) {
|
|
53
|
+
seen.add(key);
|
|
54
|
+
identities.push({
|
|
55
|
+
messageId: id,
|
|
56
|
+
remoteJid: jid
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
for (const result of results) {
|
|
61
|
+
if (result.channel !== "whatsapp") continue;
|
|
62
|
+
add(result.messageId, result.toJid);
|
|
63
|
+
for (const raw of result.receipt?.raw ?? []) add(raw.messageId, raw.toJid);
|
|
64
|
+
for (const part of result.receipt?.parts ?? []) add(part.raw?.messageId ?? part.platformMessageId, part.raw?.toJid);
|
|
65
|
+
}
|
|
66
|
+
return identities;
|
|
67
|
+
}
|
|
68
|
+
function registerWhatsAppQuestionReactionTargetForDeliveredPayload(params) {
|
|
69
|
+
const binding = questionGatewayRuntime.readReactionBinding(params.payload);
|
|
70
|
+
if (params.target.channel !== "whatsapp" || !binding) return false;
|
|
71
|
+
const accountId = resolveWhatsAppAccount({
|
|
72
|
+
cfg: params.cfg,
|
|
73
|
+
accountId: params.target.accountId
|
|
74
|
+
}).accountId;
|
|
75
|
+
let registered = false;
|
|
76
|
+
for (const identity of listDeliveredIdentities(params.results)) {
|
|
77
|
+
const key = buildKey(accountId, identity.remoteJid, identity.messageId);
|
|
78
|
+
if (!key) continue;
|
|
79
|
+
storeTarget(key, binding);
|
|
80
|
+
registered = true;
|
|
81
|
+
}
|
|
82
|
+
return registered;
|
|
83
|
+
}
|
|
84
|
+
async function maybeResolveWhatsAppQuestionReaction(params) {
|
|
85
|
+
const reaction = params.msg.message?.reactionMessage;
|
|
86
|
+
const reactionKey = reaction?.text?.trim() ?? "";
|
|
87
|
+
const messageId = reaction?.key?.id?.trim() ?? "";
|
|
88
|
+
const optionIndex = questionGatewayRuntime.resolveReactionIndex(reactionKey);
|
|
89
|
+
if (optionIndex === void 0 || !messageId) return false;
|
|
90
|
+
const remoteJids = [];
|
|
91
|
+
addCandidate(remoteJids, reaction?.key?.remoteJid);
|
|
92
|
+
addCandidate(remoteJids, params.msg.key?.remoteJid);
|
|
93
|
+
const candidates = [];
|
|
94
|
+
for (const remoteJid of remoteJids) {
|
|
95
|
+
addCandidate(candidates, remoteJid);
|
|
96
|
+
for (const mapped of await params.resolveReactionTargetJids?.(remoteJid) ?? []) addCandidate(candidates, mapped);
|
|
97
|
+
}
|
|
98
|
+
let matched;
|
|
99
|
+
for (const remoteJid of candidates) {
|
|
100
|
+
const key = buildKey(params.accountId, remoteJid, messageId);
|
|
101
|
+
const target = key ? targets.get(key) : void 0;
|
|
102
|
+
if (key && target) {
|
|
103
|
+
matched = {
|
|
104
|
+
key,
|
|
105
|
+
target
|
|
106
|
+
};
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (!matched) return false;
|
|
111
|
+
if (matched.target.expiresAtMs <= Date.now() || matched.target.terminal) {
|
|
112
|
+
matched.target.terminal = true;
|
|
113
|
+
params.logDebug?.(`whatsapp: stale question reaction ignored id=${matched.target.questionId}`);
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
const optionValue = matched.target.optionValues[optionIndex];
|
|
117
|
+
if (!optionValue) {
|
|
118
|
+
params.logDebug?.(`whatsapp: out-of-range question reaction ignored id=${matched.target.questionId}`);
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
try {
|
|
122
|
+
const result = await questionGatewayRuntime.resolveReaction({
|
|
123
|
+
cfg: params.cfg,
|
|
124
|
+
questionId: matched.target.questionId,
|
|
125
|
+
optionValue,
|
|
126
|
+
senderId: params.senderId,
|
|
127
|
+
gatewayUrl: params.gatewayUrl,
|
|
128
|
+
clientDisplayName: `WhatsApp question (${params.senderId})`
|
|
129
|
+
});
|
|
130
|
+
matched.target.terminal = result?.status === "answered" || result?.status === "already-terminal";
|
|
131
|
+
if (result?.status === "already-terminal") params.logDebug?.(`whatsapp: stale question reaction ignored id=${matched.target.questionId}`);
|
|
132
|
+
} catch (error) {
|
|
133
|
+
params.logDebug?.(`whatsapp: question reaction failed id=${matched.target.questionId}: ${String(error)}`);
|
|
134
|
+
}
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
function clearWhatsAppQuestionReactionTargetsForTest() {
|
|
138
|
+
for (const target of targets.values()) clearTimeout(target.cleanupTimer);
|
|
139
|
+
targets.clear();
|
|
140
|
+
}
|
|
141
|
+
//#endregion
|
|
142
|
+
export { question_reactions_exports as n, maybeResolveWhatsAppQuestionReaction as t };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createPluginRuntimeStore } from "openclaw/plugin-sdk/runtime-store";
|
|
2
|
+
//#region extensions/whatsapp/src/runtime.ts
|
|
3
|
+
const runtimeStore = createPluginRuntimeStore({
|
|
4
|
+
pluginId: "whatsapp",
|
|
5
|
+
errorMessage: "WhatsApp runtime not initialized"
|
|
6
|
+
});
|
|
7
|
+
const channelRuntimeStore = createPluginRuntimeStore({
|
|
8
|
+
key: "plugin-runtime:whatsapp:channel-context-owner",
|
|
9
|
+
errorMessage: "WhatsApp channel runtime not initialized"
|
|
10
|
+
});
|
|
11
|
+
/** Injects current helpers while preserving the process-lifetime channel context owner. */
|
|
12
|
+
function setWhatsAppRuntime(next) {
|
|
13
|
+
if (!channelRuntimeStore.tryGetRuntime()) channelRuntimeStore.setRuntime(next.channel);
|
|
14
|
+
runtimeStore.setRuntime(next);
|
|
15
|
+
}
|
|
16
|
+
const getWhatsAppRuntime = runtimeStore.getRuntime;
|
|
17
|
+
const getOptionalWhatsAppRuntime = runtimeStore.tryGetRuntime;
|
|
18
|
+
const getWhatsAppChannelRuntime = channelRuntimeStore.getRuntime;
|
|
19
|
+
const getOptionalWhatsAppChannelRuntime = channelRuntimeStore.tryGetRuntime;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { setWhatsAppRuntime as a, getWhatsAppRuntime as i, getOptionalWhatsAppRuntime as n, getWhatsAppChannelRuntime as r, getOptionalWhatsAppChannelRuntime as t };
|
package/dist/runtime-api.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { o as resolveWebCredsBackupPath, r as hasWebCredsSync, s as resolveWebCredsPath } from "./creds-files-B1kSWtBg.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-
|
|
4
|
-
import {
|
|
2
|
+
import { n as whatsAppActionRuntime, t as handleWhatsAppAction } from "./action-runtime-CHU7xb6o.js";
|
|
3
|
+
import { i as sendTypingWhatsApp, n as sendPollWhatsApp, r as sendReactionWhatsApp, t as sendMessageWhatsApp } from "./send-DhJVN30g.js";
|
|
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-DfyToBpG.js";
|
|
7
|
-
import { C as waitForCredsSaveQueue, T 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, 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, w as waitForCredsSaveQueueWithTimeout, x as webAuthExists, y as resolveDefaultWebAuthDir } from "./auth-store-
|
|
7
|
+
import { C as waitForCredsSaveQueue, T 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, 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, w as waitForCredsSaveQueueWithTimeout, x as webAuthExists, y as resolveDefaultWebAuthDir } from "./auth-store-DirYMTbo.js";
|
|
8
8
|
import { t as DEFAULT_WEB_MEDIA_BYTES } from "./constants-HU41RHGI.js";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
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-BoSHhQNJ.js";
|
|
11
11
|
import { n as getStatusCode, t as formatError } from "./session-errors-JuazczrA.js";
|
|
12
|
-
import {
|
|
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 { g as extractLocationData, p as extractContactContext, y as extractText } from "./send-api-CpHwbor_.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-CBVNJ2lb.js";
|
|
14
|
+
import { t as loginWeb } from "./login-BKUm7KSk.js";
|
|
15
15
|
import { HEARTBEAT_PROMPT, HEARTBEAT_TOKEN, SILENT_REPLY_TOKEN, stripHeartbeatToken } from "openclaw/plugin-sdk/reply-runtime";
|
|
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,
|
|
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 };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as setWhatsAppRuntime } from "./runtime-BLlToOi6.js";
|
|
2
2
|
export { setWhatsAppRuntime };
|
|
@@ -1,29 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as resolveWhatsAppAccount, c as resolveMergedWhatsAppAccountConfig, s as resolveWhatsAppMediaMaxBytes } from "./accounts-CxPuEFi-.js";
|
|
2
2
|
import { r as resolveDefaultWhatsAppAccountId } from "./account-ids-CB5SOWjc.js";
|
|
3
|
-
import { a as resolveWhatsAppAccount, s as resolveWhatsAppMediaMaxBytes } from "./accounts-CKOFMPf-.js";
|
|
4
3
|
import { n as isWhatsAppNewsletterJid } from "./normalize-target-DSZnHkKF.js";
|
|
5
|
-
import {
|
|
4
|
+
import { r as getWhatsAppConnectionController } from "./connection-controller-runtime-context-DG0tuYuw.js";
|
|
6
5
|
import "./normalize-C-Z16y7Q.js";
|
|
7
|
-
import {
|
|
8
|
-
import { a as
|
|
6
|
+
import { a as markdownToWhatsAppChunks, c as toWhatsappJid } from "./targets-runtime-CKFrhoX4.js";
|
|
7
|
+
import { a as stripToolCallXmlTags, i as sanitizeAssistantVisibleTextWithProfile, r as sanitizeAssistantVisibleText } from "./text-runtime-CU_IlbK5.js";
|
|
9
8
|
import path from "node:path";
|
|
10
9
|
import { normalizeUniqueStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
11
|
-
import { writeExternalFileWithinRoot } from "openclaw/plugin-sdk/security-runtime";
|
|
12
10
|
import { resolveReactionLevel } from "openclaw/plugin-sdk/status-helpers";
|
|
13
11
|
import { formatCliCommand } from "openclaw/plugin-sdk/cli-runtime";
|
|
14
12
|
import { generateSecureUuid } from "openclaw/plugin-sdk/core";
|
|
15
13
|
import { PlatformMessageNotDispatchedError } from "openclaw/plugin-sdk/error-runtime";
|
|
16
14
|
import { redactIdentifier } from "openclaw/plugin-sdk/logging-core";
|
|
17
|
-
import {
|
|
15
|
+
import { resolveMarkdownTableMode } from "openclaw/plugin-sdk/markdown-table-runtime";
|
|
16
|
+
import { loadOutboundMediaFromUrl } from "openclaw/plugin-sdk/outbound-media";
|
|
18
17
|
import { requireRuntimeConfig } from "openclaw/plugin-sdk/plugin-config-runtime";
|
|
19
18
|
import { normalizePollInput } from "openclaw/plugin-sdk/poll-runtime";
|
|
19
|
+
import { resolveChunkMode, resolveTextChunkLimit } from "openclaw/plugin-sdk/reply-chunking";
|
|
20
20
|
import { createSubsystemLogger, getChildLogger as getChildLogger$1 } from "openclaw/plugin-sdk/runtime-env";
|
|
21
|
-
import { extensionForMime } from "openclaw/plugin-sdk/media-mime";
|
|
21
|
+
import { extensionForMime, mediaKindFromMime, normalizeMimeType } from "openclaw/plugin-sdk/media-mime";
|
|
22
22
|
import { sanitizeForPlainText } from "openclaw/plugin-sdk/channel-outbound";
|
|
23
|
-
import { MEDIA_FFMPEG_MAX_AUDIO_DURATION_SECS,
|
|
23
|
+
import { MEDIA_FFMPEG_MAX_AUDIO_DURATION_SECS, transcodeAudioBufferToOpus } from "openclaw/plugin-sdk/media-runtime";
|
|
24
24
|
import { resolveOutboundMediaUrls } from "openclaw/plugin-sdk/reply-payload";
|
|
25
|
-
import { resolvePreferredOpenClawTmpDir, withTempWorkspace } from "openclaw/plugin-sdk/temp-path";
|
|
26
|
-
import { loadWebMedia } from "openclaw/plugin-sdk/web-media";
|
|
27
25
|
//#region extensions/whatsapp/src/reaction-level.ts
|
|
28
26
|
/** Resolve the effective reaction level and its implications for WhatsApp. */
|
|
29
27
|
function resolveWhatsAppReactionLevel(params) {
|
|
@@ -96,11 +94,8 @@ function normalizeWhatsAppOutboundPayload(payload, options) {
|
|
|
96
94
|
}
|
|
97
95
|
function inferWhatsAppMediaKind(media) {
|
|
98
96
|
if (media.kind === "image" || media.kind === "audio" || media.kind === "video" || media.kind === "document") return media.kind;
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
if (contentType.startsWith("audio/")) return "audio";
|
|
102
|
-
if (contentType.startsWith("video/")) return "video";
|
|
103
|
-
return "document";
|
|
97
|
+
const inferredKind = mediaKindFromMime(normalizeMimeType(media.contentType));
|
|
98
|
+
return !inferredKind || inferredKind === "sticker" || inferredKind === "unknown" ? "document" : inferredKind;
|
|
104
99
|
}
|
|
105
100
|
function normalizeWhatsAppLoadedMedia(media, mediaUrl) {
|
|
106
101
|
const kind = inferWhatsAppMediaKind(media);
|
|
@@ -136,55 +131,23 @@ async function prepareWhatsAppOutboundMedia(media, mediaUrl) {
|
|
|
136
131
|
mimetype: WHATSAPP_VOICE_MIMETYPE
|
|
137
132
|
};
|
|
138
133
|
}
|
|
139
|
-
function normalizeContentType(value) {
|
|
140
|
-
return value?.split(";", 1)[0]?.trim().toLowerCase() ?? "";
|
|
141
|
-
}
|
|
142
134
|
function isWhatsAppNativeVoiceAudio(params) {
|
|
143
|
-
const contentType =
|
|
135
|
+
const contentType = normalizeMimeType(params.contentType);
|
|
144
136
|
if (contentType === "audio/ogg" || contentType === "audio/opus") return true;
|
|
145
137
|
const fileName = params.fileName ?? deriveWhatsAppDocumentFileName(params.mediaUrl) ?? "";
|
|
146
138
|
const ext = path.extname(fileName).toLowerCase();
|
|
147
139
|
return ext === ".ogg" || ext === ".opus";
|
|
148
140
|
}
|
|
149
141
|
async function transcodeToWhatsAppVoiceOpus(params) {
|
|
150
|
-
return await
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
path: WHATSAPP_VOICE_FILE_NAME,
|
|
160
|
-
write: async (outputPath) => {
|
|
161
|
-
await runFfmpeg([
|
|
162
|
-
"-hide_banner",
|
|
163
|
-
"-loglevel",
|
|
164
|
-
"error",
|
|
165
|
-
"-y",
|
|
166
|
-
"-i",
|
|
167
|
-
inputPath,
|
|
168
|
-
"-vn",
|
|
169
|
-
"-sn",
|
|
170
|
-
"-dn",
|
|
171
|
-
"-t",
|
|
172
|
-
String(MEDIA_FFMPEG_MAX_AUDIO_DURATION_SECS),
|
|
173
|
-
"-ar",
|
|
174
|
-
String(WHATSAPP_VOICE_SAMPLE_RATE_HZ),
|
|
175
|
-
"-ac",
|
|
176
|
-
"1",
|
|
177
|
-
"-c:a",
|
|
178
|
-
"libopus",
|
|
179
|
-
"-b:a",
|
|
180
|
-
WHATSAPP_VOICE_BITRATE,
|
|
181
|
-
"-f",
|
|
182
|
-
"ogg",
|
|
183
|
-
outputPath
|
|
184
|
-
]);
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
return await workspace.read(WHATSAPP_VOICE_FILE_NAME);
|
|
142
|
+
return await transcodeAudioBufferToOpus({
|
|
143
|
+
audioBuffer: params.buffer,
|
|
144
|
+
inputFileName: params.fileName,
|
|
145
|
+
tempPrefix: "whatsapp-voice-",
|
|
146
|
+
outputFileName: WHATSAPP_VOICE_FILE_NAME,
|
|
147
|
+
maxDurationSeconds: MEDIA_FFMPEG_MAX_AUDIO_DURATION_SECS,
|
|
148
|
+
sampleRateHz: WHATSAPP_VOICE_SAMPLE_RATE_HZ,
|
|
149
|
+
channels: 1,
|
|
150
|
+
bitrate: WHATSAPP_VOICE_BITRATE
|
|
188
151
|
});
|
|
189
152
|
}
|
|
190
153
|
function deriveWhatsAppDocumentFileName(mediaUrl) {
|
|
@@ -198,25 +161,6 @@ function deriveWhatsAppDocumentFileName(mediaUrl) {
|
|
|
198
161
|
}
|
|
199
162
|
}
|
|
200
163
|
//#endregion
|
|
201
|
-
//#region extensions/whatsapp/src/outbound-media.runtime.ts
|
|
202
|
-
async function loadOutboundMediaFromUrl(mediaUrl, options = {}) {
|
|
203
|
-
const readFile = options.mediaAccess?.readFile ?? options.mediaReadFile;
|
|
204
|
-
const localRoots = options.mediaAccess?.localRoots?.length && options.mediaAccess.localRoots.length > 0 ? options.mediaAccess.localRoots : options.mediaLocalRoots && options.mediaLocalRoots.length > 0 ? options.mediaLocalRoots : void 0;
|
|
205
|
-
const sharedOptions = {
|
|
206
|
-
...options.maxBytes !== void 0 ? { maxBytes: options.maxBytes } : {},
|
|
207
|
-
...options.optimizeImages !== void 0 ? { optimizeImages: options.optimizeImages } : {}
|
|
208
|
-
};
|
|
209
|
-
return await loadWebMedia(mediaUrl, readFile ? {
|
|
210
|
-
...sharedOptions,
|
|
211
|
-
localRoots: "any",
|
|
212
|
-
readFile,
|
|
213
|
-
hostReadCapability: true
|
|
214
|
-
} : {
|
|
215
|
-
...sharedOptions,
|
|
216
|
-
...localRoots ? { localRoots } : {}
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
//#endregion
|
|
220
164
|
//#region extensions/whatsapp/src/send.ts
|
|
221
165
|
const outboundLog = createSubsystemLogger("gateway/channels/whatsapp").child("outbound");
|
|
222
166
|
function supportsForcedDocumentDelivery(kind) {
|
|
@@ -296,8 +240,14 @@ async function sendMessageWhatsApp(to, body, options) {
|
|
|
296
240
|
channel: "whatsapp",
|
|
297
241
|
accountId: resolvedAccountId ?? options.accountId
|
|
298
242
|
});
|
|
299
|
-
|
|
300
|
-
|
|
243
|
+
const accountIdForFormatting = resolvedAccountId ?? options.accountId;
|
|
244
|
+
const textLimit = Math.min(resolveTextChunkLimit(cfg, "whatsapp", accountIdForFormatting, { fallbackLimit: 4e3 }), 4096);
|
|
245
|
+
const textChunks = markdownToWhatsAppChunks(text, textLimit, tableMode, resolveChunkMode(cfg, "whatsapp", accountIdForFormatting));
|
|
246
|
+
text = textChunks.shift() ?? "";
|
|
247
|
+
if (!text && !hasMedia) return {
|
|
248
|
+
messageId: "",
|
|
249
|
+
toJid: jid
|
|
250
|
+
};
|
|
301
251
|
const redactedTo = redactIdentifier(to);
|
|
302
252
|
const logger = getChildLogger$1({
|
|
303
253
|
module: "web-outbound",
|
|
@@ -353,16 +303,19 @@ async function sendMessageWhatsApp(to, body, options) {
|
|
|
353
303
|
const result = sendOptions ? await active.sendMessage(to, text, mediaBuffer, mediaType, sendOptions) : await active.sendMessage(to, text, mediaBuffer, mediaType);
|
|
354
304
|
const messageId = result?.messageId ?? "unknown";
|
|
355
305
|
const sentRemoteJid = resolveActualSentRemoteJid(result, jid);
|
|
356
|
-
|
|
306
|
+
const trailingTextChunks = [visibleTextAfterVoice, ...textChunks].filter((chunk) => Boolean(chunk));
|
|
307
|
+
if (trailingTextChunks.length > 0) {
|
|
357
308
|
await options.onDeliveryResult?.({
|
|
358
309
|
messageId,
|
|
359
310
|
toJid: sentRemoteJid
|
|
360
311
|
});
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
312
|
+
for (const trailingText of trailingTextChunks) {
|
|
313
|
+
const trailingResult = sendOptions ? await active.sendMessage(to, trailingText, void 0, void 0, sendOptions) : await active.sendMessage(to, trailingText, void 0, void 0);
|
|
314
|
+
await options.onDeliveryResult?.({
|
|
315
|
+
messageId: trailingResult?.messageId ?? "unknown",
|
|
316
|
+
toJid: resolveActualSentRemoteJid(trailingResult, jid)
|
|
317
|
+
});
|
|
318
|
+
}
|
|
366
319
|
}
|
|
367
320
|
const durationMs = Date.now() - startedAt;
|
|
368
321
|
outboundLog.info(`Sent message ${messageId} -> ${redactedJid}${hasMedia ? " (media)" : ""} (${durationMs}ms)`);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { n as isWhatsAppNewsletterJid } from "./normalize-target-DSZnHkKF.js";
|
|
2
|
-
import { l as resolveWhatsAppDocumentFileName } from "./send-
|
|
2
|
+
import { l as resolveWhatsAppDocumentFileName } from "./send-DhJVN30g.js";
|
|
3
3
|
import "./normalize-C-Z16y7Q.js";
|
|
4
|
-
import { c as
|
|
5
|
-
import "./text-runtime-
|
|
6
|
-
import { i as buildQuotedMessageOptions } from "./group-session-key-
|
|
7
|
-
import { c as resolveComparableIdentity } from "./identity-
|
|
4
|
+
import { c as toWhatsappJid, l as toWhatsappJidWithLid, r as jidToE164 } from "./targets-runtime-CKFrhoX4.js";
|
|
5
|
+
import "./text-runtime-CU_IlbK5.js";
|
|
6
|
+
import { i as buildQuotedMessageOptions } from "./group-session-key-DJSdYfnb.js";
|
|
7
|
+
import { c as resolveComparableIdentity } from "./identity-BM4_wZeM.js";
|
|
8
8
|
import { normalizeLowercaseStringOrEmpty, normalizeStringEntries, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
9
9
|
import { logVerbose } from "openclaw/plugin-sdk/runtime-env";
|
|
10
10
|
import { createMessageReceiptFromOutboundResults, listMessageReceiptPlatformIds } from "openclaw/plugin-sdk/channel-outbound";
|
|
@@ -73,6 +73,20 @@ function normalizeVcardPhone(value) {
|
|
|
73
73
|
return trimmed;
|
|
74
74
|
}
|
|
75
75
|
//#endregion
|
|
76
|
+
//#region extensions/whatsapp/src/inbound/media-mimetype.ts
|
|
77
|
+
/**
|
|
78
|
+
* Resolve the MIME type for an inbound media message.
|
|
79
|
+
* Falls back to WhatsApp's standard formats when Baileys omits the MIME.
|
|
80
|
+
*/
|
|
81
|
+
function resolveInboundMediaMimetype(message) {
|
|
82
|
+
const explicit = message.imageMessage?.mimetype ?? message.videoMessage?.mimetype ?? message.documentMessage?.mimetype ?? message.audioMessage?.mimetype ?? message.stickerMessage?.mimetype ?? void 0;
|
|
83
|
+
if (explicit) return explicit;
|
|
84
|
+
if (message.audioMessage) return "audio/ogg; codecs=opus";
|
|
85
|
+
if (message.imageMessage) return "image/jpeg";
|
|
86
|
+
if (message.videoMessage) return "video/mp4";
|
|
87
|
+
if (message.stickerMessage) return "image/webp";
|
|
88
|
+
}
|
|
89
|
+
//#endregion
|
|
76
90
|
//#region extensions/whatsapp/src/inbound/extract.ts
|
|
77
91
|
function getFutureProofInnerMessage(message) {
|
|
78
92
|
const contentType = getContentType(message);
|
|
@@ -170,14 +184,14 @@ function extractExternalAdReplyContext(rawMessage) {
|
|
|
170
184
|
body
|
|
171
185
|
} : void 0;
|
|
172
186
|
}
|
|
173
|
-
function
|
|
187
|
+
function extractMediaKind(rawMessage) {
|
|
174
188
|
const message = unwrapMessage(rawMessage);
|
|
175
189
|
if (!message) return;
|
|
176
|
-
if (message.imageMessage) return "
|
|
177
|
-
if (message.videoMessage) return
|
|
178
|
-
if (message.audioMessage) return "
|
|
179
|
-
if (message.documentMessage) return "
|
|
180
|
-
if (message.stickerMessage) return "
|
|
190
|
+
if (message.imageMessage) return "image";
|
|
191
|
+
if (message.videoMessage) return "video";
|
|
192
|
+
if (message.audioMessage) return "audio";
|
|
193
|
+
if (message.documentMessage) return "document";
|
|
194
|
+
if (message.stickerMessage) return "sticker";
|
|
181
195
|
}
|
|
182
196
|
function extractContactPlaceholder(rawMessage) {
|
|
183
197
|
const contactContext = extractContactContext(rawMessage);
|
|
@@ -275,9 +289,13 @@ function describeReplyContext(rawMessage) {
|
|
|
275
289
|
if (!quoted) return null;
|
|
276
290
|
const location = extractLocationData(quoted);
|
|
277
291
|
const locationText = location ? formatLocationText(location) : void 0;
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
292
|
+
const body = [extractText(quoted), locationText].filter(Boolean).join("\n").trim();
|
|
293
|
+
const mediaKind = extractMediaKind(quoted);
|
|
294
|
+
const media = mediaKind ? {
|
|
295
|
+
kind: mediaKind,
|
|
296
|
+
contentType: resolveInboundMediaMimetype(quoted)
|
|
297
|
+
} : void 0;
|
|
298
|
+
if (!body && !media) {
|
|
281
299
|
const quotedType = quoted ? getContentType(quoted) : void 0;
|
|
282
300
|
logVerbose(`Quoted message missing extractable body${quotedType ? ` (type ${quotedType})` : ""}`);
|
|
283
301
|
return null;
|
|
@@ -289,7 +307,8 @@ function describeReplyContext(rawMessage) {
|
|
|
289
307
|
});
|
|
290
308
|
return {
|
|
291
309
|
id: contextInfo?.stanzaId || void 0,
|
|
292
|
-
body,
|
|
310
|
+
body: body ?? "",
|
|
311
|
+
media,
|
|
293
312
|
sender
|
|
294
313
|
};
|
|
295
314
|
}
|
|
@@ -307,26 +326,12 @@ function hasInteractiveResponseContent(message) {
|
|
|
307
326
|
function hasInboundUserContent(rawMessage) {
|
|
308
327
|
if (!rawMessage) return false;
|
|
309
328
|
if (extractText(rawMessage)) return true;
|
|
310
|
-
if (
|
|
329
|
+
if (extractMediaKind(rawMessage)) return true;
|
|
311
330
|
if (extractLocationData(rawMessage)) return true;
|
|
312
331
|
for (const candidate of buildMessageChain(rawMessage)) if (hasInteractiveResponseContent(candidate)) return true;
|
|
313
332
|
return false;
|
|
314
333
|
}
|
|
315
334
|
//#endregion
|
|
316
|
-
//#region extensions/whatsapp/src/inbound/media-mimetype.ts
|
|
317
|
-
/**
|
|
318
|
-
* Resolve the MIME type for an inbound media message.
|
|
319
|
-
* Falls back to WhatsApp's standard formats when Baileys omits the MIME.
|
|
320
|
-
*/
|
|
321
|
-
function resolveInboundMediaMimetype(message) {
|
|
322
|
-
const explicit = message.imageMessage?.mimetype ?? message.videoMessage?.mimetype ?? message.documentMessage?.mimetype ?? message.audioMessage?.mimetype ?? message.stickerMessage?.mimetype ?? void 0;
|
|
323
|
-
if (explicit) return explicit;
|
|
324
|
-
if (message.audioMessage) return "audio/ogg; codecs=opus";
|
|
325
|
-
if (message.imageMessage) return "image/jpeg";
|
|
326
|
-
if (message.videoMessage) return "video/mp4";
|
|
327
|
-
if (message.stickerMessage) return "image/webp";
|
|
328
|
-
}
|
|
329
|
-
//#endregion
|
|
330
335
|
//#region extensions/whatsapp/src/image-preview.ts
|
|
331
336
|
const WHATSAPP_IMAGE_THUMBNAIL_SIDE = 32;
|
|
332
337
|
const WHATSAPP_IMAGE_THUMBNAIL_QUALITY = 50;
|
|
@@ -673,7 +678,8 @@ function createWebSendApi(params) {
|
|
|
673
678
|
remoteJid: sendOptions?.quotedMessageKey?.remoteJid,
|
|
674
679
|
fromMe: sendOptions?.quotedMessageKey?.fromMe,
|
|
675
680
|
participant: sendOptions?.quotedMessageKey?.participant,
|
|
676
|
-
messageText: sendOptions?.quotedMessageKey?.messageText
|
|
681
|
+
messageText: sendOptions?.quotedMessageKey?.messageText,
|
|
682
|
+
media: sendOptions?.quotedMessageKey?.media
|
|
677
683
|
});
|
|
678
684
|
const results = [normalizeWhatsAppSendResult(quotedOpts ? await params.sock.sendMessage(jid, payload, quotedOpts) : await params.sock.sendMessage(jid, payload), mediaBuffer ? "media" : "text")];
|
|
679
685
|
if (shouldSendAudioText) {
|
|
@@ -735,4 +741,4 @@ function createWebSendApi(params) {
|
|
|
735
741
|
};
|
|
736
742
|
}
|
|
737
743
|
//#endregion
|
|
738
|
-
export {
|
|
744
|
+
export { extractMediaKind as _, mayContainWhatsAppOutboundMention as a, hasInboundUserContent as b, DisconnectReason as c, normalizeMessageContent$1 as d, describeReplyContext as f, extractLocationData as g, extractExternalAdReplyContext as h, addWhatsAppOutboundMentionsToContent as i, downloadMediaMessage as l, extractContextInfo as m, listWhatsAppSendResultMessageIds as n, resolveWhatsAppOutboundMentions as o, extractContactContext as p, normalizeWhatsAppSendResult as r, addWhatsAppImagePreviewFields as s, createWebSendApi as t, isJidGroup as u, extractMentionedJids as v, resolveInboundMediaMimetype as x, extractText as y };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { a as resolveWhatsAppAccount, o as resolveWhatsAppAuthDir } from "./accounts-CxPuEFi-.js";
|
|
1
2
|
import { r as resolveDefaultWhatsAppAccountId } from "./account-ids-CB5SOWjc.js";
|
|
2
3
|
import { r as hasWebCredsSync } from "./creds-files-B1kSWtBg.js";
|
|
3
|
-
import { a as resolveWhatsAppAccount, o as resolveWhatsAppAuthDir } from "./accounts-CKOFMPf-.js";
|
|
4
4
|
import { a as normalizeWhatsAppAllowFromEntries, o as normalizeWhatsAppAllowFromEntry } from "./normalize-target-DSZnHkKF.js";
|
|
5
|
-
import {
|
|
5
|
+
import { r as whatsappSetupAdapter } from "./shared-CuqHFnKd.js";
|
|
6
6
|
import { DEFAULT_ACCOUNT_ID, createSetupTranslator, splitSetupEntries } from "openclaw/plugin-sdk/setup";
|
|
7
7
|
import { formatCliCommand, formatDocsLink } from "openclaw/plugin-sdk/setup-tools";
|
|
8
8
|
//#region extensions/whatsapp/src/setup-finalize.ts
|
|
@@ -295,7 +295,7 @@ async function finalizeWhatsAppSetup(params) {
|
|
|
295
295
|
};
|
|
296
296
|
let loginWeb;
|
|
297
297
|
try {
|
|
298
|
-
({loginWeb} = await import("./login-
|
|
298
|
+
({loginWeb} = await import("./login-BKUm7KSk.js").then((n) => n.n));
|
|
299
299
|
} catch (error) {
|
|
300
300
|
await reportLoginFailure(error);
|
|
301
301
|
}
|
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-DXUCPHel.js";
|
|
2
2
|
export { whatsappSetupPlugin };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { o as resolveWhatsAppAuthDir } from "./accounts-CxPuEFi-.js";
|
|
1
2
|
import { t as listAccountIds } from "./account-ids-CB5SOWjc.js";
|
|
2
|
-
import {
|
|
3
|
-
import { a as formatWhatsAppWebAuthStatusState, h as readWebAuthState } from "./auth-store-BQi9pZqQ.js";
|
|
3
|
+
import { a as formatWhatsAppWebAuthStatusState, h as readWebAuthState } from "./auth-store-DirYMTbo.js";
|
|
4
4
|
import { DEFAULT_ACCOUNT_ID, createSetupTranslator, setSetupChannelEnabled } from "openclaw/plugin-sdk/setup";
|
|
5
5
|
//#region extensions/whatsapp/src/setup-surface.ts
|
|
6
6
|
const t = createSetupTranslator();
|
|
@@ -36,7 +36,7 @@ const whatsappSetupWizard = {
|
|
|
36
36
|
},
|
|
37
37
|
resolveShouldPromptAccountIds: ({ shouldPromptAccountIds }) => shouldPromptAccountIds,
|
|
38
38
|
credentials: [],
|
|
39
|
-
finalize: async (params) => await (await import("./setup-finalize-
|
|
39
|
+
finalize: async (params) => await (await import("./setup-finalize-9XzKdFq6.js")).finalizeWhatsAppSetup(params),
|
|
40
40
|
disable: (cfg) => setSetupChannelEnabled(cfg, channel, false),
|
|
41
41
|
onAccountRecorded: (accountId, options) => {
|
|
42
42
|
options?.onAccountId?.(channel, accountId);
|