@openclaw/whatsapp 2026.10.1 → 2026.10.5-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/.setup/{action-runtime-CE3zGstN.mjs → action-runtime-DUSkWTiZ.mjs} +2 -2
- package/dist/.setup/{agent-tools-login-B7VEvJO7.mjs → agent-tools-login-CB7OQbli.mjs} +5 -15
- package/dist/.setup/{approval-handler.runtime-CKposl6w.mjs → approval-handler.runtime-BEaAKSoU.mjs} +3 -3
- package/dist/.setup/{approval-reactions-CD6CDF9k.mjs → approval-reactions-CWkZ_ham.mjs} +7 -16
- package/dist/.setup/audio-preflight.runtime-Dg8oZgre.mjs +2 -0
- package/dist/.setup/{auth-store-D2rN-hP5.mjs → auth-store-DOBi5BPe.mjs} +10 -11
- package/dist/.setup/{channel-DNgKHMCz.mjs → channel-DcHw3Up2.mjs} +136 -135
- package/dist/.setup/{channel-react-action-BaBV9X6M.mjs → channel-react-action-C5E8_iDk.mjs} +3 -3
- package/dist/.setup/{channel.runtime-BniF8Swm.mjs → channel.runtime-DTj-wkEP.mjs} +5 -11
- package/dist/.setup/channel.setup-BJWEyQlF.mjs +5 -0
- package/dist/.setup/{connection-controller-COkcq48K.mjs → connection-controller-CejM7bhn.mjs} +50 -84
- package/dist/.setup/{directory-config-RYQomHyB.mjs → directory-config-DPLTUAqy.mjs} +22 -29
- package/dist/.setup/{group-session-key-BV8Le9r8.mjs → group-session-key-BbTPosdy.mjs} +12 -18
- package/dist/.setup/{login-CV_4V021.mjs → login-DUx5JYuW.mjs} +3 -3
- package/dist/.setup/{login-qr-DFhGc5yH.mjs → login-qr-BAWbPonj.mjs} +24 -45
- package/dist/.setup/{monitor-B5DS4PDV.mjs → monitor-CmXEQad9.mjs} +218 -367
- package/dist/.setup/{normalize-target-BGra1ZnM.mjs → normalize-target-D67Kc3g6.mjs} +5 -8
- package/dist/.setup/{question-reactions-LMeijbaq.mjs → question-reactions-DywNaX8m.mjs} +3 -10
- package/dist/.setup/reaction-target-CSPO7gtu.mjs +11 -0
- package/dist/.setup/{resolve-outbound-target-CzyNKmrl.mjs → resolve-outbound-target-qikGL4r0.mjs} +3 -4
- package/dist/.setup/{send-CGUsUdoX.mjs → send-CLBfAzd6.mjs} +34 -42
- package/dist/.setup/{send-api-B03VDwZ1.mjs → send-api-COzRvqXx.mjs} +28 -60
- package/dist/.setup/{setup-finalize-GtBmrO8p.mjs → setup-finalize-DSiP_-wa.mjs} +53 -69
- package/dist/.setup/setup-plugin-api-8WdNCjRW.mjs +3 -0
- package/dist/.setup/{setup-surface-BuA39k6K.mjs → setup-surface-C_flQyHy.mjs} +2 -2
- package/dist/.setup/{shared-CP_zs2U7.mjs → shared-SqcOkt51.mjs} +4 -4
- package/dist/.setup/{socket-close-DU7eerAa.mjs → socket-close-C9OU9mVN.mjs} +67 -86
- package/dist/.setup/{targets-runtime-Dls-Xh4F.mjs → targets-runtime-D5ryyPxh.mjs} +16 -25
- package/dist/action-runtime-api.js +1 -1
- package/dist/action-runtime.runtime.js +1 -1
- package/dist/agent-tools-api.js +4 -8
- package/dist/api.js +13 -15
- package/dist/channel-plugin-api.js +1 -1
- package/dist/contract-api.js +1 -1
- package/dist/directory-contract-api.js +1 -1
- package/dist/doctor-contract-api.js +12 -32
- package/dist/light-runtime-api.js +2 -2
- package/dist/login-qr-runtime.js +2 -4
- package/dist/runtime-api.js +8 -8
- package/dist/setup-entry.js +1 -1
- package/dist/setup-plugin-api.js +1 -1
- package/node_modules/baileys/lib/Utils/messages-media.js +7 -11
- package/node_modules/baileys/node_modules/ws/lib/websocket.js +17 -3
- package/node_modules/baileys/node_modules/ws/package.json +1 -1
- package/package.json +4 -4
- package/dist/.setup/audio-preflight.runtime-C_glQhZY.mjs +0 -7
- package/dist/.setup/channel.setup-CsS_NAKQ.mjs +0 -5
- package/dist/.setup/setup-plugin-api-Bsp7jI-r.mjs +0 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as readWebCredsJsonRawSync, o as resolveWebCredsBackupPath, s as resolveWebCredsPath, t as assertWebCredsPathRegularFileOrMissing } from "./creds-files-B8WcOAmE.mjs";
|
|
2
|
-
import { M as writeCredsJsonAtomically, N as writeWebCredsRawAtomically, j as waitForCredsSaveQueueWithTimeout, k as enqueueCredsSave, v as resolveDefaultWebAuthDir, y as restoreCredsFromBackupIfNeeded } from "./auth-store-
|
|
2
|
+
import { M as writeCredsJsonAtomically, N as writeWebCredsRawAtomically, j as waitForCredsSaveQueueWithTimeout, k as enqueueCredsSave, v as resolveDefaultWebAuthDir, y as restoreCredsFromBackupIfNeeded } from "./auth-store-DOBi5BPe.mjs";
|
|
3
3
|
import { n as getStatusCode } from "./session-errors-B8UcAnZN.mjs";
|
|
4
4
|
import { a as makeWASocket, i as makeCacheableSignalKeyStore, n as createBaileysSignalRepository, r as fetchLatestBaileysVersion, s as useMultiFileAuthState } from "./session.runtime-st1konFI.mjs";
|
|
5
5
|
import { VERSION, formatCliCommand } from "openclaw/plugin-sdk/cli-runtime";
|
|
@@ -13,7 +13,7 @@ import { parseStrictPositiveInteger, resolveTimerTimeoutMs } from "openclaw/plug
|
|
|
13
13
|
import { raceWithTimeout, withTimeout } from "openclaw/plugin-sdk/time-runtime";
|
|
14
14
|
import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
|
|
15
15
|
import { FILE_LOCK_STALE_ERROR_CODE, FILE_LOCK_TIMEOUT_ERROR_CODE, acquireFileLock } from "openclaw/plugin-sdk/file-lock";
|
|
16
|
-
import { createNodeProxyAgent } from "openclaw/plugin-sdk/fetch-runtime";
|
|
16
|
+
import { captureEffectAuthority, createNodeProxyAgent } from "openclaw/plugin-sdk/fetch-runtime";
|
|
17
17
|
import { randomUUID } from "node:crypto";
|
|
18
18
|
//#region extensions/whatsapp/src/connection-owner.ts
|
|
19
19
|
const WHATSAPP_CONNECTION_OWNER_BUSY_CODE = "whatsapp_connection_owner_busy";
|
|
@@ -40,35 +40,23 @@ async function reserveProcessOwner(params) {
|
|
|
40
40
|
const released = createDeferred();
|
|
41
41
|
const owner = {
|
|
42
42
|
released: released.promise,
|
|
43
|
-
resolveReleased: released.resolve
|
|
44
|
-
token: Symbol(params.ownerPath)
|
|
43
|
+
resolveReleased: released.resolve
|
|
45
44
|
};
|
|
46
45
|
processOwners.set(params.ownerPath, owner);
|
|
47
46
|
return owner;
|
|
48
47
|
}
|
|
49
48
|
if (!params.waitForLocalOwner) throw new WhatsAppConnectionOwnerBusyError(params.authDir);
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
new Promise((resolve) => {
|
|
55
|
-
timer = setTimeout(() => resolve("timed_out"), GATEWAY_LOCAL_OWNER_WAIT_MS);
|
|
56
|
-
timer.unref?.();
|
|
57
|
-
}),
|
|
58
|
-
new Promise((resolve) => {
|
|
59
|
-
onAbort = () => resolve("aborted");
|
|
60
|
-
params.signal?.addEventListener("abort", onAbort, { once: true });
|
|
61
|
-
})
|
|
62
|
-
]).finally(() => {
|
|
63
|
-
if (timer) clearTimeout(timer);
|
|
64
|
-
if (onAbort) params.signal?.removeEventListener("abort", onAbort);
|
|
49
|
+
const outcome = await raceWithTimeout(current.released.then(() => "released"), GATEWAY_LOCAL_OWNER_WAIT_MS, () => "timed_out", {
|
|
50
|
+
ref: false,
|
|
51
|
+
signal: params.signal,
|
|
52
|
+
onAbort: () => "aborted"
|
|
65
53
|
});
|
|
66
54
|
if (outcome === "aborted") throw ownershipCancelledError(params.signal);
|
|
67
55
|
if (outcome === "timed_out") throw new WhatsAppConnectionOwnerBusyError(params.authDir);
|
|
68
56
|
}
|
|
69
57
|
}
|
|
70
58
|
function abandonProcessOwner(ownerPath, owner) {
|
|
71
|
-
if (processOwners.get(ownerPath)
|
|
59
|
+
if (processOwners.get(ownerPath) !== owner) return;
|
|
72
60
|
processOwners.delete(ownerPath);
|
|
73
61
|
owner.resolveReleased();
|
|
74
62
|
}
|
|
@@ -84,41 +72,37 @@ async function acquireOwnerLease(params) {
|
|
|
84
72
|
});
|
|
85
73
|
let fileLock;
|
|
86
74
|
let attempt = 0;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
})
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
throw error;
|
|
75
|
+
try {
|
|
76
|
+
while (true) {
|
|
77
|
+
if (params.signal?.aborted) throw ownershipCancelledError(params.signal);
|
|
78
|
+
try {
|
|
79
|
+
fileLock = await acquireFileLock(ownerPath, {
|
|
80
|
+
retries: {
|
|
81
|
+
retries: 0,
|
|
82
|
+
factor: 1,
|
|
83
|
+
minTimeout: 1,
|
|
84
|
+
maxTimeout: 1
|
|
85
|
+
},
|
|
86
|
+
stale: OWNER_LOCK_STALE_MS,
|
|
87
|
+
staleRecovery: "remove-if-unchanged"
|
|
88
|
+
});
|
|
89
|
+
break;
|
|
90
|
+
} catch (error) {
|
|
91
|
+
const code = error.code;
|
|
92
|
+
if (code !== FILE_LOCK_TIMEOUT_ERROR_CODE || attempt >= params.retries) {
|
|
93
|
+
if (code === FILE_LOCK_TIMEOUT_ERROR_CODE || code === FILE_LOCK_STALE_ERROR_CODE) throw new WhatsAppConnectionOwnerBusyError(params.authDir, { cause: error });
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
96
|
+
const delayMs = Math.min(100 * 1.5 ** attempt, 1e3);
|
|
97
|
+
attempt += 1;
|
|
98
|
+
await sleepWithAbort(delayMs, params.signal).catch(() => {
|
|
99
|
+
throw ownershipCancelledError(params.signal);
|
|
100
|
+
});
|
|
114
101
|
}
|
|
115
|
-
const delayMs = Math.min(100 * 1.5 ** attempt, 1e3);
|
|
116
|
-
attempt += 1;
|
|
117
|
-
await sleepWithAbort(delayMs, params.signal).catch(() => {
|
|
118
|
-
abandonProcessOwner(ownerPath, processOwner);
|
|
119
|
-
throw ownershipCancelledError(params.signal);
|
|
120
|
-
});
|
|
121
102
|
}
|
|
103
|
+
} catch (error) {
|
|
104
|
+
abandonProcessOwner(ownerPath, processOwner);
|
|
105
|
+
throw error;
|
|
122
106
|
}
|
|
123
107
|
let releasePromise = null;
|
|
124
108
|
return { release: async () => {
|
|
@@ -195,19 +179,28 @@ async function withWhatsAppSocketOperationTimeout(operation, promise, timeoutMs,
|
|
|
195
179
|
}
|
|
196
180
|
function createWhatsAppSocketOperationTimeoutAdapter(sock, timeoutMs, hooks) {
|
|
197
181
|
const operationTimeoutMs = resolveWhatsAppSocketOperationTimeoutMs(timeoutMs);
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
182
|
+
const runOperation = (operation, send, onTimeout) => {
|
|
183
|
+
const effect = captureEffectAuthority();
|
|
184
|
+
const run = () => {
|
|
185
|
+
let active = true;
|
|
186
|
+
const promise = effect.initiate(() => {
|
|
187
|
+
if (!active) throw new WhatsAppSocketOperationTimeoutError(operation, operationTimeoutMs);
|
|
188
|
+
hooks?.assertCurrent?.();
|
|
189
|
+
return send();
|
|
206
190
|
});
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
191
|
+
return withWhatsAppSocketOperationTimeout(operation, promise, operationTimeoutMs, () => {
|
|
192
|
+
active = false;
|
|
193
|
+
onTimeout?.(promise);
|
|
194
|
+
});
|
|
195
|
+
};
|
|
196
|
+
return operation === "sendMessage" ? runSerializedSocketSendMessage(sock, run) : run();
|
|
197
|
+
};
|
|
198
|
+
return {
|
|
199
|
+
sendMessage: (jid, content, options) => runOperation("sendMessage", () => options ? sock.sendMessage(jid, content, options) : sock.sendMessage(jid, content), (promise) => hooks?.onSendMessageTimeout?.({
|
|
200
|
+
jid,
|
|
201
|
+
promise
|
|
202
|
+
})),
|
|
203
|
+
sendPresenceUpdate: (presence, jid) => runOperation("sendPresenceUpdate", () => jid === void 0 ? sock.sendPresenceUpdate(presence) : sock.sendPresenceUpdate(presence, jid))
|
|
211
204
|
};
|
|
212
205
|
}
|
|
213
206
|
//#endregion
|
|
@@ -313,10 +306,6 @@ function resolveEnvWaWebSocketUrl() {
|
|
|
313
306
|
if (url.protocol !== "ws:" && url.protocol !== "wss:") throw new Error(`${OPENCLAW_WHATSAPP_WEB_SOCKET_URL_ENV} must use ws:// or wss://.`);
|
|
314
307
|
return url.toString();
|
|
315
308
|
}
|
|
316
|
-
/**
|
|
317
|
-
* Create a Baileys socket backed by the multi-file auth store we keep on disk.
|
|
318
|
-
* Consumers can opt into QR printing for interactive login flows.
|
|
319
|
-
*/
|
|
320
309
|
async function createWaSocket(printQr, verbose, opts = {}) {
|
|
321
310
|
return await createWaSocketInternal(printQr, verbose, opts, "normal");
|
|
322
311
|
}
|
|
@@ -357,6 +346,11 @@ async function createWaSocketInternal(printQr, verbose, opts, receiveMode) {
|
|
|
357
346
|
else pendingSocketAbort = { error };
|
|
358
347
|
opts.onCredentialPersistenceError?.(error);
|
|
359
348
|
};
|
|
349
|
+
const observeCredentialPersistence = (task, reportError = false) => {
|
|
350
|
+
opts.onCredentialPersistenceTask?.(task);
|
|
351
|
+
if (reportError) task.then(void 0, reportCredentialPersistenceError);
|
|
352
|
+
return task;
|
|
353
|
+
};
|
|
360
354
|
const persistedSignalKeys = opts.beforeCredentialPersistence ? {
|
|
361
355
|
...state.keys,
|
|
362
356
|
async set(data) {
|
|
@@ -368,9 +362,7 @@ async function createWaSocketInternal(printQr, verbose, opts, receiveMode) {
|
|
|
368
362
|
const signalKeys = opts.beforeCredentialPersistence ? {
|
|
369
363
|
...cachedSignalKeys,
|
|
370
364
|
get(type, ids) {
|
|
371
|
-
|
|
372
|
-
opts.onCredentialPersistenceTask?.(task);
|
|
373
|
-
return task;
|
|
365
|
+
return observeCredentialPersistence(Promise.resolve(cachedSignalKeys.get(type, ids)));
|
|
374
366
|
},
|
|
375
367
|
set(data) {
|
|
376
368
|
const task = (async () => {
|
|
@@ -381,26 +373,15 @@ async function createWaSocketInternal(printQr, verbose, opts, receiveMode) {
|
|
|
381
373
|
throw error;
|
|
382
374
|
}
|
|
383
375
|
})();
|
|
384
|
-
|
|
385
|
-
return task;
|
|
376
|
+
return observeCredentialPersistence(task);
|
|
386
377
|
}
|
|
387
378
|
} : cachedSignalKeys;
|
|
388
379
|
const makeSignalRepository = opts.onCredentialPersistenceTask ? (...args) => {
|
|
389
380
|
const repository = createBaileysSignalRepository(...args);
|
|
390
381
|
const storeLidPnMappings = repository.lidMapping.storeLIDPNMappings.bind(repository.lidMapping);
|
|
391
|
-
repository.lidMapping.storeLIDPNMappings = (...storeArgs) =>
|
|
392
|
-
const task = storeLidPnMappings(...storeArgs);
|
|
393
|
-
opts.onCredentialPersistenceTask?.(task);
|
|
394
|
-
task.then(void 0, reportCredentialPersistenceError);
|
|
395
|
-
return task;
|
|
396
|
-
};
|
|
382
|
+
repository.lidMapping.storeLIDPNMappings = (...storeArgs) => observeCredentialPersistence(storeLidPnMappings(...storeArgs), true);
|
|
397
383
|
const migrateSession = repository.migrateSession.bind(repository);
|
|
398
|
-
repository.migrateSession = (...migrateArgs) =>
|
|
399
|
-
const task = migrateSession(...migrateArgs);
|
|
400
|
-
opts.onCredentialPersistenceTask?.(task);
|
|
401
|
-
task.then(void 0, reportCredentialPersistenceError);
|
|
402
|
-
return task;
|
|
403
|
-
};
|
|
384
|
+
repository.migrateSession = (...migrateArgs) => observeCredentialPersistence(migrateSession(...migrateArgs), true);
|
|
404
385
|
return repository;
|
|
405
386
|
} : void 0;
|
|
406
387
|
const sock = makeWASocket({
|
|
@@ -79,12 +79,11 @@ function addUniqueString(target, value) {
|
|
|
79
79
|
const normalized = value?.trim();
|
|
80
80
|
if (normalized && !target.includes(normalized)) target.push(normalized);
|
|
81
81
|
}
|
|
82
|
-
async function tryLookupMappedJid(lookup) {
|
|
83
|
-
if (!lookup) return null;
|
|
82
|
+
async function tryLookupMappedJid(lookup, failureContext = "") {
|
|
84
83
|
try {
|
|
85
84
|
return await lookup() ?? null;
|
|
86
85
|
} catch (err) {
|
|
87
|
-
if (shouldLogVerbose()) logVerbose(`LID mapping lookup failed: ${String(err)}`);
|
|
86
|
+
if (shouldLogVerbose()) logVerbose(`LID mapping lookup failed${failureContext}: ${String(err)}`);
|
|
88
87
|
return null;
|
|
89
88
|
}
|
|
90
89
|
}
|
|
@@ -101,29 +100,25 @@ async function resolveEquivalentWhatsAppDirectChatJids(jid, opts) {
|
|
|
101
100
|
const candidates = [];
|
|
102
101
|
addEquivalentDirectChatCandidate(candidates, normalized);
|
|
103
102
|
const pnMatch = normalized.match(DIRECT_PN_JID_RE);
|
|
103
|
+
const match = pnMatch ?? normalized.match(DIRECT_LID_JID_RE);
|
|
104
|
+
if (!match) return candidates;
|
|
105
|
+
addEquivalentDirectChatCandidate(candidates, await tryLookupMappedJid(() => pnMatch ? opts?.lidLookup?.getLIDForPN?.(normalized) : opts?.lidLookup?.getPNForLID?.(normalized)));
|
|
106
|
+
const digits = match[1];
|
|
107
|
+
const domain = match[2];
|
|
108
|
+
if (!digits || !domain) return candidates;
|
|
104
109
|
if (pnMatch) {
|
|
105
|
-
addEquivalentDirectChatCandidate(candidates, await tryLookupMappedJid(() => opts?.lidLookup?.getLIDForPN?.(normalized)));
|
|
106
|
-
const phoneDigits = pnMatch[1];
|
|
107
|
-
const pnDomain = pnMatch[2];
|
|
108
|
-
if (!phoneDigits || !pnDomain) return candidates;
|
|
109
110
|
const mappedLocalLid = readLidForwardMapping({
|
|
110
|
-
phoneDigits,
|
|
111
|
+
phoneDigits: digits,
|
|
111
112
|
opts
|
|
112
113
|
});
|
|
113
|
-
const localLidDomain =
|
|
114
|
+
const localLidDomain = domain.toLowerCase() === "hosted" ? "hosted.lid" : "lid";
|
|
114
115
|
addUniqueString(candidates, mappedLocalLid ? `${mappedLocalLid}@${localLidDomain}` : null);
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
const lidMatch = normalized.match(DIRECT_LID_JID_RE);
|
|
118
|
-
if (lidMatch) {
|
|
119
|
-
addEquivalentDirectChatCandidate(candidates, await tryLookupMappedJid(() => opts?.lidLookup?.getPNForLID?.(normalized)));
|
|
120
|
-
const lidDomain = lidMatch[2];
|
|
121
|
-
if (!lidMatch[1] || !lidDomain) return candidates;
|
|
116
|
+
} else {
|
|
122
117
|
const e164 = jidToE164(normalized, {
|
|
123
118
|
...opts,
|
|
124
119
|
logMissing: false
|
|
125
120
|
});
|
|
126
|
-
addUniqueString(candidates, e164 &&
|
|
121
|
+
addUniqueString(candidates, e164 && domain.toLowerCase() === "hosted.lid" ? `${e164.replace(/\D/g, "")}@hosted` : e164 ? toWhatsappJid(e164) : null);
|
|
127
122
|
}
|
|
128
123
|
return candidates;
|
|
129
124
|
}
|
|
@@ -172,14 +167,10 @@ async function resolveJidToE164(jid, opts) {
|
|
|
172
167
|
const direct = jidToE164(jid, opts);
|
|
173
168
|
if (direct) return direct;
|
|
174
169
|
if (!/(@lid|@hosted\.lid)$/.test(jid) || !opts?.lidLookup?.getPNForLID) return null;
|
|
175
|
-
|
|
176
|
-
const pnJid = await opts.lidLookup
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
} catch (err) {
|
|
180
|
-
if (shouldLogVerbose()) logVerbose(`LID mapping lookup failed for ${jid}: ${String(err)}`);
|
|
181
|
-
return null;
|
|
182
|
-
}
|
|
170
|
+
return await tryLookupMappedJid(async () => {
|
|
171
|
+
const pnJid = await opts.lidLookup?.getPNForLID?.(jid);
|
|
172
|
+
return pnJid ? jidToE164(pnJid, opts) : null;
|
|
173
|
+
}, ` for ${jid}`);
|
|
183
174
|
}
|
|
184
175
|
function protectWhatsAppEscapedMarkers(text) {
|
|
185
176
|
const placeholders = [];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as handleWhatsAppAction } from "./.setup/action-runtime-
|
|
1
|
+
import { t as handleWhatsAppAction } from "./.setup/action-runtime-DUSkWTiZ.mjs";
|
|
2
2
|
export { handleWhatsAppAction };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as handleWhatsAppAction } from "./.setup/action-runtime-
|
|
1
|
+
import { t as handleWhatsAppAction } from "./.setup/action-runtime-DUSkWTiZ.mjs";
|
|
2
2
|
export { handleWhatsAppAction };
|
package/dist/agent-tools-api.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as resolveWhatsAppAccount } from "./.setup/accounts-F0vHuze2.mjs";
|
|
2
2
|
import { r as getWhatsAppConnectionController } from "./.setup/connection-controller-runtime-context-hgLJoRc8.mjs";
|
|
3
|
-
import { s as resolveJidToE164 } from "./.setup/targets-runtime-
|
|
4
|
-
import { n as registerWhatsAppLoginTool } from "./.setup/agent-tools-login-
|
|
3
|
+
import { s as resolveJidToE164 } from "./.setup/targets-runtime-D5ryyPxh.mjs";
|
|
4
|
+
import { n as registerWhatsAppLoginTool } from "./.setup/agent-tools-login-CB7OQbli.mjs";
|
|
5
5
|
import { createActionGate, stringEnum } from "openclaw/plugin-sdk/channel-actions";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import { resolveOAuthDir } from "openclaw/plugin-sdk/state-paths";
|
|
@@ -81,11 +81,7 @@ function resolveCallWindowMs(pcmBytes, sampleRate) {
|
|
|
81
81
|
}
|
|
82
82
|
async function resolveRequesterE164(params) {
|
|
83
83
|
const senderId = params.requesterSenderId.trim();
|
|
84
|
-
if (!senderId.includes("@"))
|
|
85
|
-
return normalizeE164(senderId.replace(/^whatsapp:/i, ""));
|
|
86
|
-
} catch {
|
|
87
|
-
return null;
|
|
88
|
-
}
|
|
84
|
+
if (!senderId.includes("@")) return normalizeE164(senderId.replace(/^whatsapp:/i, ""));
|
|
89
85
|
const account = resolveWhatsAppAccount({
|
|
90
86
|
cfg: params.cfg,
|
|
91
87
|
accountId: params.accountId
|
|
@@ -101,7 +97,7 @@ async function resolveLinkedWhatsAppSelfE164(params) {
|
|
|
101
97
|
if (!controller) return null;
|
|
102
98
|
const identity = controller.getSelfIdentity();
|
|
103
99
|
if (!identity) return null;
|
|
104
|
-
if (identity.e164) return
|
|
100
|
+
if (identity.e164) return identity.e164;
|
|
105
101
|
const account = resolveWhatsAppAccount({
|
|
106
102
|
cfg: params.cfg,
|
|
107
103
|
accountId: params.accountId
|
package/dist/api.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { a as resolveWhatsAppAccount, i as listWhatsAppAuthDirs, n as hasAnyWhatsAppAuth, o as resolveWhatsAppAuthDir, r as listEnabledWhatsAppAccounts, s as resolveWhatsAppMediaMaxBytes, t as DEFAULT_WHATSAPP_MEDIA_MAX_MB } from "./.setup/accounts-F0vHuze2.mjs";
|
|
2
2
|
import { r as resolveDefaultWhatsAppAccountId, t as listAccountIds } from "./.setup/account-ids-CB5SOWjc.mjs";
|
|
3
|
-
import { a as normalizeWhatsAppAllowFromEntries, c as normalizeWhatsAppTarget, i as looksLikeWhatsAppTargetId, r as isWhatsAppUserTarget, s as normalizeWhatsAppMessagingTarget, t as isWhatsAppGroupJid } from "./.setup/normalize-target-
|
|
4
|
-
import { t as resolveWhatsAppOutboundTarget } from "./.setup/resolve-outbound-target-
|
|
5
|
-
import { c as toWhatsappJid, i as markdownToWhatsApp, l as toWhatsappJidWithLid, n as isSelfChatMode, r as jidToE164, s as resolveJidToE164, t as assertWebChannel } from "./.setup/targets-runtime-
|
|
6
|
-
import { n as WHATSAPP_LEGACY_OUTBOUND_SEND_DEP_KEYS, t as whatsappPlugin } from "./.setup/channel-
|
|
7
|
-
import { i as resolveWhatsAppGroupToolPolicy, r as resolveWhatsAppGroupRequireMention } from "./.setup/shared-
|
|
3
|
+
import { a as normalizeWhatsAppAllowFromEntries, c as normalizeWhatsAppTarget, i as looksLikeWhatsAppTargetId, r as isWhatsAppUserTarget, s as normalizeWhatsAppMessagingTarget, t as isWhatsAppGroupJid } from "./.setup/normalize-target-D67Kc3g6.mjs";
|
|
4
|
+
import { t as resolveWhatsAppOutboundTarget } from "./.setup/resolve-outbound-target-qikGL4r0.mjs";
|
|
5
|
+
import { c as toWhatsappJid, i as markdownToWhatsApp, l as toWhatsappJidWithLid, n as isSelfChatMode, r as jidToE164, s as resolveJidToE164, t as assertWebChannel } from "./.setup/targets-runtime-D5ryyPxh.mjs";
|
|
6
|
+
import { n as WHATSAPP_LEGACY_OUTBOUND_SEND_DEP_KEYS, t as whatsappPlugin } from "./.setup/channel-DcHw3Up2.mjs";
|
|
7
|
+
import { i as resolveWhatsAppGroupToolPolicy, r as resolveWhatsAppGroupRequireMention } from "./.setup/shared-SqcOkt51.mjs";
|
|
8
8
|
import { t as whatsappCommandPolicy } from "./.setup/command-policy-BIOSHySD.mjs";
|
|
9
|
-
import { t as whatsappSetupPlugin } from "./.setup/channel.setup-
|
|
9
|
+
import { t as whatsappSetupPlugin } from "./.setup/channel.setup-BJWEyQlF.mjs";
|
|
10
10
|
import { t as DEFAULT_WEB_MEDIA_BYTES } from "./.setup/constants-C7m81BNe.mjs";
|
|
11
|
-
import { d as DEFAULT_WHATSAPP_SOCKET_TIMING, f as createWhatsAppSocketOperationTimeoutAdapter, i as waitForWaConnection, r as createWaSocket } from "./.setup/socket-close-
|
|
11
|
+
import { d as DEFAULT_WHATSAPP_SOCKET_TIMING, f as createWhatsAppSocketOperationTimeoutAdapter, i as waitForWaConnection, r as createWaSocket } from "./.setup/socket-close-C9OU9mVN.mjs";
|
|
12
12
|
import { n as getStatusCode, t as formatError } from "./.setup/session-errors-B8UcAnZN.mjs";
|
|
13
|
-
import { n as listWhatsAppDirectoryGroupsFromConfig, r as listWhatsAppDirectoryPeersFromConfig } from "./.setup/directory-config-
|
|
14
|
-
import { _ as resolveInboundMediaMimetype, c as extractContextInfo, m as findMessageSection, o as describeReplyContext, p as extractText, t as createWebSendApi, u as extractLocationData } from "./.setup/send-api-
|
|
13
|
+
import { n as listWhatsAppDirectoryGroupsFromConfig, r as listWhatsAppDirectoryPeersFromConfig } from "./.setup/directory-config-DPLTUAqy.mjs";
|
|
14
|
+
import { _ as resolveInboundMediaMimetype, c as extractContextInfo, m as findMessageSection, o as describeReplyContext, p as extractText, t as createWebSendApi, u as extractLocationData } from "./.setup/send-api-COzRvqXx.mjs";
|
|
15
15
|
import { asBoolean, isRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
16
16
|
import { formatLocationText } from "openclaw/plugin-sdk/channel-inbound";
|
|
17
17
|
import { normalizeE164, resolveUserPath } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
@@ -108,7 +108,6 @@ async function startWhatsAppQaDriverSession(params) {
|
|
|
108
108
|
const observedMessages = [];
|
|
109
109
|
const waiters = /* @__PURE__ */ new Set();
|
|
110
110
|
let pendingNotificationsWaiter;
|
|
111
|
-
let closed = false;
|
|
112
111
|
let closedError;
|
|
113
112
|
let receivedPendingNotifications = false;
|
|
114
113
|
const removeWaiter = (waiter) => {
|
|
@@ -149,8 +148,7 @@ async function startWhatsAppQaDriverSession(params) {
|
|
|
149
148
|
sock.ev.off("connection.update", onConnectionUpdate);
|
|
150
149
|
};
|
|
151
150
|
const closeSessionResources = (waiterError) => {
|
|
152
|
-
if (
|
|
153
|
-
closed = true;
|
|
151
|
+
if (closedError) return;
|
|
154
152
|
closedError = waiterError;
|
|
155
153
|
settlePendingNotifications(waiterError);
|
|
156
154
|
for (const waiter of waiters) {
|
|
@@ -169,8 +167,8 @@ async function startWhatsAppQaDriverSession(params) {
|
|
|
169
167
|
resolve();
|
|
170
168
|
return;
|
|
171
169
|
}
|
|
172
|
-
if (
|
|
173
|
-
reject(closedError
|
|
170
|
+
if (closedError) {
|
|
171
|
+
reject(closedError);
|
|
174
172
|
return;
|
|
175
173
|
}
|
|
176
174
|
const timeoutMs = params.connectionTimeoutMs ?? 45e3;
|
|
@@ -224,7 +222,7 @@ async function startWhatsAppQaDriverSession(params) {
|
|
|
224
222
|
const predicate = (message) => (!paramsLocal.observedAfter || new Date(message.observedAt).getTime() >= paramsLocal.observedAfter.getTime()) && paramsLocal.match(message);
|
|
225
223
|
const existing = observedMessages.find(predicate);
|
|
226
224
|
if (existing) return existing;
|
|
227
|
-
if (
|
|
225
|
+
if (closedError) throw closedError;
|
|
228
226
|
return await new Promise((resolve, reject) => {
|
|
229
227
|
const waiter = {
|
|
230
228
|
predicate,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as whatsappPlugin } from "./.setup/channel-
|
|
1
|
+
import { t as whatsappPlugin } from "./.setup/channel-DcHw3Up2.mjs";
|
|
2
2
|
export { whatsappPlugin };
|
package/dist/contract-api.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as normalizeWhatsAppTarget$1, t as isWhatsAppGroupJid$1 } from "./.setup/normalize-target-
|
|
1
|
+
import { c as normalizeWhatsAppTarget$1, t as isWhatsAppGroupJid$1 } from "./.setup/normalize-target-D67Kc3g6.mjs";
|
|
2
2
|
import { t as whatsappCommandPolicy$1 } from "./.setup/command-policy-BIOSHySD.mjs";
|
|
3
3
|
import { t as resolveLegacyGroupSessionKey$1 } from "./.setup/group-session-contract-DDnZSsJ1.mjs";
|
|
4
4
|
import { r as isLegacyGroupSessionKey$1, t as canonicalizeLegacySessionKey$1 } from "./.setup/session-contract-DMTm6Q_L.mjs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as listWhatsAppDirectoryGroupsFromConfig, r as listWhatsAppDirectoryPeersFromConfig } from "./.setup/directory-config-
|
|
1
|
+
import { n as listWhatsAppDirectoryGroupsFromConfig, r as listWhatsAppDirectoryPeersFromConfig } from "./.setup/directory-config-DPLTUAqy.mjs";
|
|
2
2
|
//#region extensions/whatsapp/directory-contract-api.ts
|
|
3
3
|
const whatsappDirectoryContractPlugin = {
|
|
4
4
|
id: "whatsapp",
|
|
@@ -69,16 +69,18 @@ const whatsappLegacyStateMigration = {
|
|
|
69
69
|
const sources = await listSources(params);
|
|
70
70
|
const changes = [];
|
|
71
71
|
const warnings = [];
|
|
72
|
+
const warn = (message, recoverable = false) => ({
|
|
73
|
+
changes,
|
|
74
|
+
warnings: [message],
|
|
75
|
+
...recoverable ? { warningDisposition: "recoverable" } : {}
|
|
76
|
+
});
|
|
72
77
|
if (sources.length === 0) return {
|
|
73
78
|
changes,
|
|
74
79
|
warnings
|
|
75
80
|
};
|
|
76
81
|
const assertCurrent = params.context.channelIngressQueues?.find((entry) => entry.channelId === "whatsapp")?.assertCurrent;
|
|
77
82
|
const { backupLegacyStateSource } = runtime_doctor_migrations_exports;
|
|
78
|
-
if (!assertCurrent || !backupLegacyStateSource) return
|
|
79
|
-
changes,
|
|
80
|
-
warnings: ["WhatsApp credential import requires offline Doctor repair. Update OpenClaw core and run openclaw doctor --fix; original files remain unchanged."]
|
|
81
|
-
};
|
|
83
|
+
if (!assertCurrent || !backupLegacyStateSource) return warn("WhatsApp credential import requires offline Doctor repair. Update OpenClaw core and run openclaw doctor --fix; original files remain unchanged.");
|
|
82
84
|
const backups = [];
|
|
83
85
|
for (const source of sources) backups.push({
|
|
84
86
|
source,
|
|
@@ -102,16 +104,8 @@ const whatsappLegacyStateMigration = {
|
|
|
102
104
|
const targetCreds = path.join(targetDir, "creds.json");
|
|
103
105
|
const canonical = await credentials.exists(targetCreds) ? await credentials.read(targetCreds) : void 0;
|
|
104
106
|
const legacy = backups.find(({ source }) => source.name === "creds.json");
|
|
105
|
-
if (!legacy) return
|
|
106
|
-
|
|
107
|
-
warnings: ["WhatsApp shared-root key files have no creds.json identity. Kept all original files and private .migrated backups; restore the original creds.json before retrying Doctor."],
|
|
108
|
-
...canonical ? { warningDisposition: "recoverable" } : {}
|
|
109
|
-
};
|
|
110
|
-
if (canonical && !canonical.buffer.equals(legacy.backup.bytes)) return {
|
|
111
|
-
changes,
|
|
112
|
-
warnings: ["WhatsApp canonical credentials differ from the legacy shared root. Kept both complete sets and private .migrated backups; choose the intended authDir before removing either set."],
|
|
113
|
-
warningDisposition: "recoverable"
|
|
114
|
-
};
|
|
107
|
+
if (!legacy) return warn("WhatsApp shared-root key files have no creds.json identity. Kept all original files and private .migrated backups; restore the original creds.json before retrying Doctor.", Boolean(canonical));
|
|
108
|
+
if (canonical && !canonical.buffer.equals(legacy.backup.bytes)) return warn("WhatsApp canonical credentials differ from the legacy shared root. Kept both complete sets and private .migrated backups; choose the intended authDir before removing either set.", true);
|
|
115
109
|
const targetNames = await fs$1.readdir(path.join(params.oauthDir, targetDir)).catch((error) => {
|
|
116
110
|
if (extractErrorCode(error) === "ENOENT") return [];
|
|
117
111
|
throw error;
|
|
@@ -126,32 +120,18 @@ const whatsappLegacyStateMigration = {
|
|
|
126
120
|
maxEntries: 4096,
|
|
127
121
|
overflowPolicy: "reject-new"
|
|
128
122
|
});
|
|
129
|
-
if (!receiptStore.withCurrent) return
|
|
130
|
-
changes,
|
|
131
|
-
warnings: ["WhatsApp credential import requires current offline storage authority. Update OpenClaw core and rerun Doctor; original credentials remain unchanged."]
|
|
132
|
-
};
|
|
123
|
+
if (!receiptStore.withCurrent) return warn("WhatsApp credential import requires current offline storage authority. Update OpenClaw core and rerun Doctor; original credentials remain unchanged.");
|
|
133
124
|
const receipts = receiptStore.withCurrent({ assertCurrent });
|
|
134
125
|
const sourceIdentity = legacy.backup.snapshot.sha256;
|
|
135
126
|
const previous = await receipts.lookup(sourceIdentity);
|
|
136
|
-
if (previous && (!canonical || previous.targetDigest !== credentialSetDigest(targetFiles))) return
|
|
137
|
-
changes,
|
|
138
|
-
warnings: ["WhatsApp credential migration previously started, but its complete canonical credential set is absent or changed. Kept source files and backups; restore the complete intended account or select its authDir explicitly. Doctor will not recreate credentials after logout."],
|
|
139
|
-
...canonical ? { warningDisposition: "recoverable" } : {}
|
|
140
|
-
};
|
|
127
|
+
if (previous && (!canonical || previous.targetDigest !== credentialSetDigest(targetFiles))) return warn("WhatsApp credential migration previously started, but its complete canonical credential set is absent or changed. Kept source files and backups; restore the complete intended account or select its authDir explicitly. Doctor will not recreate credentials after logout.", Boolean(canonical));
|
|
141
128
|
if (!canonical) {
|
|
142
129
|
const sourceNames = new Set(sources.map((source) => source.name));
|
|
143
|
-
if (targetNames.some((name) => isWhatsAppBaileysAuthFileName(name) && !sourceNames.has(name))) return
|
|
144
|
-
changes,
|
|
145
|
-
warnings: ["WhatsApp default account contains unmatched auth files without creds.json. Kept the incomplete account and legacy credentials separate; choose the intended credential set before retrying Doctor."]
|
|
146
|
-
};
|
|
130
|
+
if (targetNames.some((name) => isWhatsAppBaileysAuthFileName(name) && !sourceNames.has(name))) return warn("WhatsApp default account contains unmatched auth files without creds.json. Kept the incomplete account and legacy credentials separate; choose the intended credential set before retrying Doctor.");
|
|
147
131
|
}
|
|
148
132
|
for (const { source, backup } of backups) {
|
|
149
133
|
const relativePath = path.join(targetDir, source.name);
|
|
150
|
-
if (await credentials.exists(relativePath) && !(await credentials.read(relativePath)).buffer.equals(backup.bytes)) return {
|
|
151
|
-
changes,
|
|
152
|
-
warnings: [`WhatsApp auth ${source.name} differs between the default account and legacy shared root. Kept both copies and a private .migrated backup; choose the intended credential set before retrying Doctor.`],
|
|
153
|
-
...canonical ? { warningDisposition: "recoverable" } : {}
|
|
154
|
-
};
|
|
134
|
+
if (await credentials.exists(relativePath) && !(await credentials.read(relativePath)).buffer.equals(backup.bytes)) return warn(`WhatsApp auth ${source.name} differs between the default account and legacy shared root. Kept both copies and a private .migrated backup; choose the intended credential set before retrying Doctor.`, Boolean(canonical));
|
|
155
135
|
}
|
|
156
136
|
if (!previous) {
|
|
157
137
|
const expected = new Map(targetFiles);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as createWhatsAppLoginTool } from "./.setup/agent-tools-login-
|
|
2
|
-
import { b as webAuthExists, c as logoutWeb, h as readWebSelfId, l as pickWebChannel, o as getWebAuthAgeMs, s as logWebSelfId, t as WA_WEB_AUTH_DIR, v as resolveDefaultWebAuthDir } from "./.setup/auth-store-
|
|
1
|
+
import { t as createWhatsAppLoginTool } from "./.setup/agent-tools-login-CB7OQbli.mjs";
|
|
2
|
+
import { b as webAuthExists, c as logoutWeb, h as readWebSelfId, l as pickWebChannel, o as getWebAuthAgeMs, s as logWebSelfId, t as WA_WEB_AUTH_DIR, v as resolveDefaultWebAuthDir } from "./.setup/auth-store-DOBi5BPe.mjs";
|
|
3
3
|
import { t as getActiveWebListener } from "./.setup/active-listener-CDjoX9QR.mjs";
|
|
4
4
|
import { n as getStatusCode, t as formatError } from "./.setup/session-errors-B8UcAnZN.mjs";
|
|
5
5
|
export { WA_WEB_AUTH_DIR, createWhatsAppLoginTool, formatError, getActiveWebListener, getStatusCode, getWebAuthAgeMs, logWebSelfId, logoutWeb, pickWebChannel, readWebSelfId, resolveDefaultWebAuthDir, webAuthExists };
|
package/dist/login-qr-runtime.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
|
|
2
1
|
//#region extensions/whatsapp/login-qr-runtime.ts
|
|
3
|
-
const loadLoginQrModule = createLazyRuntimeModule(() => import("./.setup/login-qr-DFhGc5yH.mjs"));
|
|
4
2
|
async function startWebLoginWithQr(...args) {
|
|
5
|
-
const { startWebLoginWithQr: startWebLoginWithQrLocal } = await
|
|
3
|
+
const { startWebLoginWithQr: startWebLoginWithQrLocal } = await import("./.setup/login-qr-BAWbPonj.mjs");
|
|
6
4
|
return await startWebLoginWithQrLocal(...args);
|
|
7
5
|
}
|
|
8
6
|
async function waitForWebLogin(...args) {
|
|
9
|
-
const { waitForWebLogin: waitForWebLoginLocal } = await
|
|
7
|
+
const { waitForWebLogin: waitForWebLoginLocal } = await import("./.setup/login-qr-BAWbPonj.mjs");
|
|
10
8
|
return await waitForWebLoginLocal(...args);
|
|
11
9
|
}
|
|
12
10
|
//#endregion
|
package/dist/runtime-api.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { a as readWebCredsJsonRawSync, n as hasWebCredsSync, o as resolveWebCredsBackupPath, s as resolveWebCredsPath } from "./.setup/creds-files-B8WcOAmE.mjs";
|
|
2
|
-
import { n as whatsAppActionRuntime, t as handleWhatsAppAction } from "./.setup/action-runtime-
|
|
3
|
-
import { i as sendTypingWhatsApp, n as sendPollWhatsApp, r as sendReactionWhatsApp, t as sendMessageWhatsApp } from "./.setup/send-
|
|
2
|
+
import { n as whatsAppActionRuntime, t as handleWhatsAppAction } from "./.setup/action-runtime-DUSkWTiZ.mjs";
|
|
3
|
+
import { i as sendTypingWhatsApp, n as sendPollWhatsApp, r as sendReactionWhatsApp, t as sendMessageWhatsApp } from "./.setup/send-CLBfAzd6.mjs";
|
|
4
4
|
import { a as setWhatsAppRuntime } from "./.setup/runtime-BLlToOi6.mjs";
|
|
5
5
|
import { startWebLoginWithQr, waitForWebLogin } from "./login-qr-runtime.js";
|
|
6
|
-
import { t as createWhatsAppLoginTool } from "./.setup/agent-tools-login-
|
|
7
|
-
import { A as waitForCredsSaveQueue, M as writeCredsJsonAtomically, _ as readWebSelfIdentityForDecision, a as formatWhatsAppWebAuthStatusState, b as webAuthExists, c as logoutWeb, d as readWebAuthExistsForDecision, f as readWebAuthSnapshot, g as readWebSelfIdentity, h as readWebSelfId, j as waitForCredsSaveQueueWithTimeout, l as pickWebChannel, m as readWebAuthState, n as WHATSAPP_AUTH_UNSTABLE_CODE, o as getWebAuthAgeMs, p as readWebAuthSnapshotBestEffort, r as WhatsAppAuthUnstableError, s as logWebSelfId, t as WA_WEB_AUTH_DIR, u as readWebAuthExistsBestEffort, v as resolveDefaultWebAuthDir, y as restoreCredsFromBackupIfNeeded } from "./.setup/auth-store-
|
|
6
|
+
import { t as createWhatsAppLoginTool } from "./.setup/agent-tools-login-CB7OQbli.mjs";
|
|
7
|
+
import { A as waitForCredsSaveQueue, M as writeCredsJsonAtomically, _ as readWebSelfIdentityForDecision, a as formatWhatsAppWebAuthStatusState, b as webAuthExists, c as logoutWeb, d as readWebAuthExistsForDecision, f as readWebAuthSnapshot, g as readWebSelfIdentity, h as readWebSelfId, j as waitForCredsSaveQueueWithTimeout, l as pickWebChannel, m as readWebAuthState, n as WHATSAPP_AUTH_UNSTABLE_CODE, o as getWebAuthAgeMs, p as readWebAuthSnapshotBestEffort, r as WhatsAppAuthUnstableError, s as logWebSelfId, t as WA_WEB_AUTH_DIR, u as readWebAuthExistsBestEffort, v as resolveDefaultWebAuthDir, y as restoreCredsFromBackupIfNeeded } from "./.setup/auth-store-DOBi5BPe.mjs";
|
|
8
8
|
import { t as DEFAULT_WEB_MEDIA_BYTES } from "./.setup/constants-C7m81BNe.mjs";
|
|
9
9
|
import { n as resolveWebAccountId, t as getActiveWebListener } from "./.setup/active-listener-CDjoX9QR.mjs";
|
|
10
|
-
import { i as waitForWaConnection, r as createWaSocket, s as newConnectionId } from "./.setup/socket-close-
|
|
10
|
+
import { i as waitForWaConnection, r as createWaSocket, s as newConnectionId } from "./.setup/socket-close-C9OU9mVN.mjs";
|
|
11
11
|
import { n as getStatusCode, t as formatError } from "./.setup/session-errors-B8UcAnZN.mjs";
|
|
12
|
-
import { p as extractText, s as extractContactContext, u as extractLocationData } from "./.setup/send-api-
|
|
13
|
-
import { a as loadWebMediaRaw, c as monitorWebInbox, i as loadWebMedia, l as resetWebInboundDedupe, n as LocalMediaAccessError, o as optimizeImageToJpeg, r as getDefaultLocalRoots, s as optimizeImageToPng, t as monitorWebChannel } from "./.setup/monitor-
|
|
14
|
-
import { t as loginWeb } from "./.setup/login-
|
|
12
|
+
import { p as extractText, s as extractContactContext, u as extractLocationData } from "./.setup/send-api-COzRvqXx.mjs";
|
|
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 "./.setup/monitor-CmXEQad9.mjs";
|
|
14
|
+
import { t as loginWeb } from "./.setup/login-DUx5JYuW.mjs";
|
|
15
15
|
import { HEARTBEAT_PROMPT, HEARTBEAT_TOKEN, SILENT_REPLY_TOKEN, stripHeartbeatToken } from "openclaw/plugin-sdk/reply-runtime";
|
|
16
16
|
export { DEFAULT_WEB_MEDIA_BYTES, HEARTBEAT_PROMPT, HEARTBEAT_TOKEN, LocalMediaAccessError, SILENT_REPLY_TOKEN, WA_WEB_AUTH_DIR, WHATSAPP_AUTH_UNSTABLE_CODE, WhatsAppAuthUnstableError, createWaSocket, createWhatsAppLoginTool, extractContactContext, extractLocationData, extractText, formatError, formatWhatsAppWebAuthStatusState, getActiveWebListener, getDefaultLocalRoots, getStatusCode, getWebAuthAgeMs, handleWhatsAppAction, hasWebCredsSync, loadWebMedia, loadWebMediaRaw, logWebSelfId, loginWeb, logoutWeb, monitorWebChannel, monitorWebInbox, newConnectionId, optimizeImageToJpeg, optimizeImageToPng, pickWebChannel, readWebCredsJsonRawSync as 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 };
|
package/dist/setup-entry.js
CHANGED
|
@@ -5,7 +5,7 @@ var setup_entry_default = defineBundledChannelSetupEntry({
|
|
|
5
5
|
importMetaUrl: import.meta.url,
|
|
6
6
|
features: { legacySessionSurfaces: true },
|
|
7
7
|
plugin: {
|
|
8
|
-
specifier: fileURLToPath(new URL(".setup/setup-plugin-api-
|
|
8
|
+
specifier: fileURLToPath(new URL(".setup/setup-plugin-api-8WdNCjRW.mjs", import.meta.url).href),
|
|
9
9
|
exportName: "whatsappSetupPlugin"
|
|
10
10
|
},
|
|
11
11
|
legacySessionSurface: {
|
package/dist/setup-plugin-api.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as whatsappSetupPlugin } from "./.setup/channel.setup-
|
|
1
|
+
import { t as whatsappSetupPlugin } from "./.setup/channel.setup-BJWEyQlF.mjs";
|
|
2
2
|
export { whatsappSetupPlugin };
|
|
@@ -527,10 +527,9 @@ export function extensionForMediaMessage(message) {
|
|
|
527
527
|
}
|
|
528
528
|
return extension;
|
|
529
529
|
}
|
|
530
|
-
const
|
|
530
|
+
const supportsNodeHttpUpload = () => {
|
|
531
531
|
return (typeof process !== 'undefined' &&
|
|
532
|
-
process.versions?.node
|
|
533
|
-
typeof process.versions.bun === 'undefined' &&
|
|
532
|
+
typeof process.versions?.node === 'string' &&
|
|
534
533
|
typeof globalThis.Deno === 'undefined');
|
|
535
534
|
};
|
|
536
535
|
export const uploadWithNodeHttp = async ({ url, filePath, headers, timeoutMs, agent }, redirectCount = 0) => {
|
|
@@ -623,15 +622,12 @@ const uploadWithFetch = async ({ url, filePath, headers, timeoutMs, agent }) =>
|
|
|
623
622
|
* This causes memory issues with large files (e.g., 1GB file = 1GB+ memory usage).
|
|
624
623
|
* See: https://github.com/nodejs/undici/issues/4058
|
|
625
624
|
*
|
|
626
|
-
*
|
|
627
|
-
*
|
|
628
|
-
*
|
|
629
|
-
* ## Future considerations:
|
|
630
|
-
* Once the undici bug is fixed, we can simplify this to use only the Fetch API
|
|
631
|
-
* across all runtimes. Monitor the GitHub issue for updates.
|
|
625
|
+
* Bun also uses Node HTTP to retain agent routing and replay files on redirects.
|
|
626
|
+
* Other runtimes use the web-standard Fetch API.
|
|
627
|
+
* Native fetch cannot consume generic Node agents or replay streamed bodies.
|
|
632
628
|
*/
|
|
633
629
|
const uploadMedia = async (params, logger) => {
|
|
634
|
-
if (
|
|
630
|
+
if (supportsNodeHttpUpload()) {
|
|
635
631
|
logger?.debug('Using Node.js https module for upload (avoids undici buffering bug)');
|
|
636
632
|
return uploadWithNodeHttp(params);
|
|
637
633
|
}
|
|
@@ -689,7 +685,7 @@ export const getWAUploadToServer = ({ customUploadHosts, fetchAgent, logger, opt
|
|
|
689
685
|
}
|
|
690
686
|
catch (error) {
|
|
691
687
|
const isLast = hostname === hosts[uploadInfo.hosts.length - 1]?.hostname;
|
|
692
|
-
logger.warn({ trace: error?.stack, uploadResult: result }, `Error in uploading to ${hostname} ${isLast ? '' : ', retrying...'}`);
|
|
688
|
+
logger.warn({ trace: error?.stack ?? error?.message ?? String(error), uploadResult: result }, `Error in uploading to ${hostname} ${isLast ? '' : ', retrying...'}`);
|
|
693
689
|
}
|
|
694
690
|
}
|
|
695
691
|
if (!urls) {
|