@openclaw/whatsapp 2026.5.7 → 2026.5.10-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/{access-control-CTj7P7WP.js → access-control-CdP8S3rJ.js} +66 -111
- package/dist/{action-runtime-BqYZmBX_.js → action-runtime-CMhO8liB.js} +1 -1
- package/dist/action-runtime-api.js +1 -1
- package/dist/action-runtime.runtime.js +1 -1
- package/dist/api.js +120 -12
- package/dist/{auth-store-BNZmNP-s.js → auth-store-CjEimXKX.js} +19 -41
- package/dist/{channel-CTr3YjO8.js → channel-BxntAClG.js} +39 -12
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel-react-action-BuSTzmDX.js → channel-react-action-DJvzhIPw.js} +1 -1
- package/dist/{channel.runtime-C3i9Svfj.js → channel.runtime-CNdPCK3G.js} +5 -5
- package/dist/{channel.setup-BYtkDwHe.js → channel.setup-BqlcEVzR.js} +4 -4
- package/dist/{connection-controller-BCIuChXD.js → connection-controller-DX2phM7V.js} +6 -197
- package/dist/constants.js +1 -1
- package/dist/contract-api.js +7 -7
- package/dist/{directory-config-BNCbgnmy.js → directory-config-o-muXLgk.js} +1 -1
- package/dist/directory-contract-api.js +1 -1
- package/dist/doctor-contract-api.js +1 -1
- package/dist/{identity-DhaC0MoD.js → identity-KxdJfH7p.js} +1 -1
- package/dist/legacy-session-surface-api.js +1 -1
- package/dist/legacy-state-migrations-api.js +1 -1
- package/dist/light-runtime-api.js +3 -3
- package/dist/{login-DSUTCcJ7.js → login-DV99D0IN.js} +4 -3
- package/dist/{login-qr-dfs8tfGo.js → login-qr-cKndAXTv.js} +3 -2
- package/dist/login-qr-runtime.js +1 -1
- package/dist/{monitor-C5_C_RGJ.js → monitor-mfy3Mmq-.js} +111 -687
- package/dist/{outbound-adapter-CbR17Ehj.js → outbound-adapter-B9ZW8sht.js} +3 -3
- package/dist/{outbound-base-BmzhutvF.js → outbound-base-MVpg2zU2.js} +8 -3
- package/dist/{outbound-media-contract-BPdOq7Hb.js → outbound-media-contract-BzWwBppP.js} +37 -41
- package/dist/outbound-payload-test-api.js +1 -1
- package/dist/{quoted-message-BXs55Teh.js → quoted-message-DQ6hAr34.js} +1 -1
- package/dist/runtime-api.js +11 -10
- package/dist/security-contract-api.js +1 -1
- package/dist/send-api-DsbCqDre.js +697 -0
- package/dist/{send-CxctcFGT.js → send-u88yh8Hw.js} +2 -3
- package/dist/session-DeIU_vjJ.js +198 -0
- package/dist/{session.runtime-C1eSE_KK.js → session.runtime-B9VlYnWQ.js} +1 -1
- package/dist/{setup-surface-CF3l3gEZ.js → setup-finalize-D3YuMUBs.js} +5 -52
- package/dist/setup-plugin-api.js +1 -1
- package/dist/setup-surface-CHjYlKJc.js +45 -0
- package/dist/{shared-CTSTwprn.js → shared-CgYT3IzU.js} +7 -7
- package/dist/{state-migrations-DnCdvoYD.js → state-migrations-CtdIArlK.js} +2 -1
- package/dist/test-api.js +2 -2
- package/dist/{text-runtime-DFFwk5z6.js → text-runtime-DBKC9uEi.js} +27 -2
- package/package.json +6 -6
- package/dist/rolldown-runtime-RkAeH_Qm.js +0 -27
- /package/dist/{active-listener-N7GFKsuN.js → active-listener-D2NHQ5Og.js} +0 -0
- /package/dist/{agent-tools-login-DpRxLNRB.js → agent-tools-login-DYKYW5Nh.js} +0 -0
- /package/dist/{audio-preflight.runtime-Bcdsl_ri.js → audio-preflight.runtime-CIFjeaEN.js} +0 -0
- /package/dist/{command-policy-O8sRnqUV.js → command-policy-BgZRZ31o.js} +0 -0
- /package/dist/{config-schema-Dmo66Ubb.js → config-schema-cSC7M4YA.js} +0 -0
- /package/dist/{constants-DLGCIbfl.js → constants-yKXGCGU9.js} +0 -0
- /package/dist/{doctor-A9tXm9Om.js → doctor-BrgepDUP.js} +0 -0
- /package/dist/{group-session-contract-B8QBn0I2.js → group-session-contract-DL-SLclv.js} +0 -0
- /package/dist/{reply-resolver.runtime-BRCgoO4C.js → reply-resolver.runtime-CROyXXQh.js} +0 -0
- /package/dist/{runtime-6fZ67abR.js → runtime-DdodQB8G.js} +0 -0
- /package/dist/{runtime-group-policy-Gp1lQ0at.js → runtime-group-policy-BH_U23qp.js} +0 -0
- /package/dist/{security-contract-DqH8JDX6.js → security-contract-BzlZFreO.js} +0 -0
- /package/dist/{session-contract-B0efQf9P.js → session-contract-BNUscPf4.js} +0 -0
- /package/dist/{setup-core-DZKvpzbH.js → setup-core-DnhO0PjG.js} +0 -0
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as markdownToWhatsApp, l as __exportAll, s as toWhatsappJid } from "./text-runtime-DBKC9uEi.js";
|
|
2
2
|
import { r as resolveDefaultWhatsAppAccountId } from "./account-ids-DG18xddX.js";
|
|
3
3
|
import { a as resolveWhatsAppAccount, s as resolveWhatsAppMediaMaxBytes } from "./accounts-BDqgpFEB.js";
|
|
4
4
|
import { n as isWhatsAppNewsletterJid } from "./normalize-target-nXxC_hxG.js";
|
|
5
5
|
import { t as getRegisteredWhatsAppConnectionController } from "./connection-controller-registry-D_iIGz5m.js";
|
|
6
6
|
import "./normalize-Y3eBdM8a.js";
|
|
7
|
-
import { a as
|
|
8
|
-
import { a as resolveWhatsAppOutboundMediaUrls, i as prepareWhatsAppOutboundMedia, n as normalizeWhatsAppPayloadText } from "./outbound-media-contract-BPdOq7Hb.js";
|
|
7
|
+
import { a as resolveWhatsAppOutboundMediaUrls, i as prepareWhatsAppOutboundMedia, n as normalizeWhatsAppPayloadText } from "./outbound-media-contract-BzWwBppP.js";
|
|
9
8
|
import { formatCliCommand } from "openclaw/plugin-sdk/cli-runtime";
|
|
10
9
|
import { generateSecureUuid } from "openclaw/plugin-sdk/core";
|
|
11
10
|
import { redactIdentifier } from "openclaw/plugin-sdk/logging-core";
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { n as resolveWebCredsBackupPath, r as resolveWebCredsPath } from "./creds-files-_2V8jzQa.js";
|
|
2
|
+
import { n as getStatusCode } from "./session-errors-CSuKZPub.js";
|
|
3
|
+
import { C as waitForCredsSaveQueueWithTimeout, l as readCredsJsonRaw, v as resolveDefaultWebAuthDir, w as writeCredsJsonAtomically, x as enqueueCredsSave, y as restoreCredsFromBackupIfNeeded } from "./auth-store-CjEimXKX.js";
|
|
4
|
+
import { i as makeWASocket, n as fetchLatestBaileysVersion, o as useMultiFileAuthState, r as makeCacheableSignalKeyStore, t as DisconnectReason } from "./session.runtime-B9VlYnWQ.js";
|
|
5
|
+
import fs from "node:fs";
|
|
6
|
+
import { ensureDir, resolveUserPath } from "openclaw/plugin-sdk/text-runtime";
|
|
7
|
+
import { VERSION, formatCliCommand } from "openclaw/plugin-sdk/cli-runtime";
|
|
8
|
+
import { danger, getChildLogger as getChildLogger$1, success, toPinoLikeLogger } from "openclaw/plugin-sdk/runtime-env";
|
|
9
|
+
import { renderQrTerminal } from "openclaw/plugin-sdk/media-runtime";
|
|
10
|
+
import { randomUUID } from "node:crypto";
|
|
11
|
+
import { HttpsProxyAgent } from "https-proxy-agent";
|
|
12
|
+
import { resolveEnvHttpProxyUrl, shouldUseEnvHttpProxyForUrl } from "openclaw/plugin-sdk/fetch-runtime";
|
|
13
|
+
//#region extensions/whatsapp/src/socket-timing.ts
|
|
14
|
+
const DEFAULT_WHATSAPP_SOCKET_TIMING = {
|
|
15
|
+
keepAliveIntervalMs: 25e3,
|
|
16
|
+
connectTimeoutMs: 6e4,
|
|
17
|
+
defaultQueryTimeoutMs: 6e4
|
|
18
|
+
};
|
|
19
|
+
function positiveInteger(value) {
|
|
20
|
+
return typeof value === "number" && Number.isInteger(value) && value > 0 ? value : void 0;
|
|
21
|
+
}
|
|
22
|
+
function resolveWhatsAppSocketTiming(cfg, overrides) {
|
|
23
|
+
const configured = cfg.web?.whatsapp;
|
|
24
|
+
return {
|
|
25
|
+
keepAliveIntervalMs: positiveInteger(overrides?.keepAliveIntervalMs) ?? positiveInteger(configured?.keepAliveIntervalMs) ?? DEFAULT_WHATSAPP_SOCKET_TIMING.keepAliveIntervalMs,
|
|
26
|
+
connectTimeoutMs: positiveInteger(overrides?.connectTimeoutMs) ?? positiveInteger(configured?.connectTimeoutMs) ?? DEFAULT_WHATSAPP_SOCKET_TIMING.connectTimeoutMs,
|
|
27
|
+
defaultQueryTimeoutMs: positiveInteger(overrides?.defaultQueryTimeoutMs) ?? positiveInteger(configured?.defaultQueryTimeoutMs) ?? DEFAULT_WHATSAPP_SOCKET_TIMING.defaultQueryTimeoutMs
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region extensions/whatsapp/src/session.ts
|
|
32
|
+
const LOGGED_OUT_STATUS = DisconnectReason?.loggedOut ?? 401;
|
|
33
|
+
const WHATSAPP_WEBSOCKET_PROXY_TARGET = "https://mmg.whatsapp.net/";
|
|
34
|
+
const CREDS_FLUSH_TIMEOUT_MESSAGE = "Queued WhatsApp creds save did not finish before auth bootstrap; skipping repair and continuing with primary creds.";
|
|
35
|
+
function enqueueSaveCreds(authDir, saveCreds, logger) {
|
|
36
|
+
enqueueCredsSave(authDir, () => safeSaveCreds(authDir, saveCreds, logger), (err) => {
|
|
37
|
+
logger.warn({ error: String(err) }, "WhatsApp creds save queue error");
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
async function safeSaveCreds(authDir, saveCreds, logger) {
|
|
41
|
+
try {
|
|
42
|
+
const credsPath = resolveWebCredsPath(authDir);
|
|
43
|
+
const backupPath = resolveWebCredsBackupPath(authDir);
|
|
44
|
+
const raw = readCredsJsonRaw(credsPath);
|
|
45
|
+
if (raw) try {
|
|
46
|
+
JSON.parse(raw);
|
|
47
|
+
fs.copyFileSync(credsPath, backupPath);
|
|
48
|
+
try {
|
|
49
|
+
fs.chmodSync(backupPath, 384);
|
|
50
|
+
} catch {}
|
|
51
|
+
} catch {}
|
|
52
|
+
} catch {}
|
|
53
|
+
try {
|
|
54
|
+
await Promise.resolve(saveCreds());
|
|
55
|
+
} catch (err) {
|
|
56
|
+
logger.warn({ error: String(err) }, "failed saving WhatsApp creds");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async function printTerminalQr(qr) {
|
|
60
|
+
const output = await renderQrTerminal(qr, { small: true });
|
|
61
|
+
process.stdout.write(output.endsWith("\n") ? output : `${output}\n`);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Create a Baileys socket backed by the multi-file auth store we keep on disk.
|
|
65
|
+
* Consumers can opt into QR printing for interactive login flows.
|
|
66
|
+
*/
|
|
67
|
+
async function createWaSocket(printQr, verbose, opts = {}) {
|
|
68
|
+
const logger = toPinoLikeLogger(getChildLogger$1({ module: "baileys" }, { level: verbose ? "info" : "silent" }), verbose ? "info" : "silent");
|
|
69
|
+
const authDir = resolveUserPath(opts.authDir ?? resolveDefaultWebAuthDir());
|
|
70
|
+
await ensureDir(authDir);
|
|
71
|
+
const sessionLogger = getChildLogger$1({ module: "web-session" });
|
|
72
|
+
if (await waitForCredsSaveQueueWithTimeout(authDir) === "timed_out") sessionLogger.warn({ authDir }, CREDS_FLUSH_TIMEOUT_MESSAGE);
|
|
73
|
+
else await restoreCredsFromBackupIfNeeded(authDir);
|
|
74
|
+
const { state } = await useMultiFileAuthState(authDir);
|
|
75
|
+
const saveCreds = async () => {
|
|
76
|
+
await writeCredsJsonAtomically(authDir, state.creds);
|
|
77
|
+
};
|
|
78
|
+
const { version } = await fetchLatestBaileysVersion();
|
|
79
|
+
const agent = await resolveEnvProxyAgent(sessionLogger);
|
|
80
|
+
const fetchAgent = await resolveEnvFetchDispatcher(sessionLogger, agent);
|
|
81
|
+
const socketTiming = {
|
|
82
|
+
keepAliveIntervalMs: opts.keepAliveIntervalMs ?? DEFAULT_WHATSAPP_SOCKET_TIMING.keepAliveIntervalMs,
|
|
83
|
+
connectTimeoutMs: opts.connectTimeoutMs ?? DEFAULT_WHATSAPP_SOCKET_TIMING.connectTimeoutMs,
|
|
84
|
+
defaultQueryTimeoutMs: opts.defaultQueryTimeoutMs ?? DEFAULT_WHATSAPP_SOCKET_TIMING.defaultQueryTimeoutMs
|
|
85
|
+
};
|
|
86
|
+
const sock = makeWASocket({
|
|
87
|
+
auth: {
|
|
88
|
+
creds: state.creds,
|
|
89
|
+
keys: makeCacheableSignalKeyStore(state.keys, logger)
|
|
90
|
+
},
|
|
91
|
+
version,
|
|
92
|
+
logger,
|
|
93
|
+
printQRInTerminal: false,
|
|
94
|
+
browser: [
|
|
95
|
+
"openclaw",
|
|
96
|
+
"cli",
|
|
97
|
+
VERSION
|
|
98
|
+
],
|
|
99
|
+
syncFullHistory: false,
|
|
100
|
+
markOnlineOnConnect: false,
|
|
101
|
+
...socketTiming,
|
|
102
|
+
agent,
|
|
103
|
+
fetchAgent
|
|
104
|
+
});
|
|
105
|
+
sock.ev.on("creds.update", () => enqueueSaveCreds(authDir, saveCreds, sessionLogger));
|
|
106
|
+
sock.ev.on("connection.update", async (update) => {
|
|
107
|
+
try {
|
|
108
|
+
const { connection, lastDisconnect, qr } = update;
|
|
109
|
+
if (qr) {
|
|
110
|
+
opts.onQr?.(qr);
|
|
111
|
+
if (printQr) {
|
|
112
|
+
console.log("Open the WhatsApp app, go to Linked Devices, then scan this QR:");
|
|
113
|
+
printTerminalQr(qr).catch((err) => {
|
|
114
|
+
sessionLogger.warn({ error: String(err) }, "failed rendering WhatsApp QR");
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (connection === "close") {
|
|
119
|
+
if (getStatusCode(lastDisconnect?.error) === LOGGED_OUT_STATUS) console.error(danger(`WhatsApp session logged out. Run: ${formatCliCommand("openclaw channels login")}`));
|
|
120
|
+
}
|
|
121
|
+
if (connection === "open" && verbose) console.log(success("WhatsApp Web connected."));
|
|
122
|
+
} catch (err) {
|
|
123
|
+
sessionLogger.error({ error: String(err) }, "connection.update handler error");
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
if (sock.ws && typeof sock.ws.on === "function") sock.ws.on("error", (err) => {
|
|
127
|
+
sessionLogger.error({ error: String(err) }, "WebSocket error");
|
|
128
|
+
});
|
|
129
|
+
return sock;
|
|
130
|
+
}
|
|
131
|
+
async function resolveEnvProxyAgent(logger) {
|
|
132
|
+
if (!shouldUseEnvHttpProxyForUrl(WHATSAPP_WEBSOCKET_PROXY_TARGET)) return;
|
|
133
|
+
const proxyUrl = resolveEnvHttpProxyUrl("https");
|
|
134
|
+
if (!proxyUrl) return;
|
|
135
|
+
try {
|
|
136
|
+
const agent = new HttpsProxyAgent(proxyUrl);
|
|
137
|
+
logger.info("Using ambient env proxy for WhatsApp WebSocket connection");
|
|
138
|
+
return agent;
|
|
139
|
+
} catch (error) {
|
|
140
|
+
logger.warn({ error: String(error) }, "Failed to initialize env proxy agent for WhatsApp WebSocket connection");
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
async function resolveEnvFetchDispatcher(logger, agent) {
|
|
145
|
+
const proxyUrl = resolveProxyUrlFromAgent(agent);
|
|
146
|
+
const envProxyUrl = resolveEnvHttpsProxyUrl();
|
|
147
|
+
if (!proxyUrl && !envProxyUrl) return;
|
|
148
|
+
try {
|
|
149
|
+
const { EnvHttpProxyAgent, ProxyAgent } = await import("undici");
|
|
150
|
+
return proxyUrl ? new ProxyAgent({
|
|
151
|
+
allowH2: false,
|
|
152
|
+
uri: proxyUrl
|
|
153
|
+
}) : new EnvHttpProxyAgent({ allowH2: false });
|
|
154
|
+
} catch (error) {
|
|
155
|
+
logger.warn({ error: String(error) }, "Failed to initialize env proxy dispatcher for WhatsApp media uploads");
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
function resolveProxyUrlFromAgent(agent) {
|
|
160
|
+
if (typeof agent !== "object" || agent === null || !("proxy" in agent)) return;
|
|
161
|
+
const proxy = agent.proxy;
|
|
162
|
+
if (proxy instanceof URL) return proxy.toString();
|
|
163
|
+
return typeof proxy === "string" && proxy.length > 0 ? proxy : void 0;
|
|
164
|
+
}
|
|
165
|
+
function resolveEnvHttpsProxyUrl(env = process.env) {
|
|
166
|
+
const lowerHttpsProxy = normalizeEnvProxyValue(env.https_proxy);
|
|
167
|
+
const lowerHttpProxy = normalizeEnvProxyValue(env.http_proxy);
|
|
168
|
+
const httpsProxy = lowerHttpsProxy !== void 0 ? lowerHttpsProxy : normalizeEnvProxyValue(env.HTTPS_PROXY);
|
|
169
|
+
const httpProxy = lowerHttpProxy !== void 0 ? lowerHttpProxy : normalizeEnvProxyValue(env.HTTP_PROXY);
|
|
170
|
+
return httpsProxy ?? httpProxy ?? void 0;
|
|
171
|
+
}
|
|
172
|
+
function normalizeEnvProxyValue(value) {
|
|
173
|
+
if (typeof value !== "string") return;
|
|
174
|
+
const trimmed = value.trim();
|
|
175
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
176
|
+
}
|
|
177
|
+
async function waitForWaConnection(sock) {
|
|
178
|
+
return new Promise((resolve, reject) => {
|
|
179
|
+
const evWithOff = sock.ev;
|
|
180
|
+
const handler = (...args) => {
|
|
181
|
+
const update = args[0] ?? {};
|
|
182
|
+
if (update.connection === "open") {
|
|
183
|
+
evWithOff.off?.("connection.update", handler);
|
|
184
|
+
resolve();
|
|
185
|
+
}
|
|
186
|
+
if (update.connection === "close") {
|
|
187
|
+
evWithOff.off?.("connection.update", handler);
|
|
188
|
+
reject(update.lastDisconnect ?? /* @__PURE__ */ new Error("Connection closed"));
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
sock.ev.on("connection.update", handler);
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
function newConnectionId() {
|
|
195
|
+
return randomUUID();
|
|
196
|
+
}
|
|
197
|
+
//#endregion
|
|
198
|
+
export { renderQrTerminal as a, resolveWhatsAppSocketTiming as i, newConnectionId as n, waitForWaConnection as r, createWaSocket as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { l as __exportAll } from "./text-runtime-DBKC9uEi.js";
|
|
2
2
|
import { BufferJSON, DisconnectReason as DisconnectReason$1, fetchLatestBaileysVersion, makeCacheableSignalKeyStore, makeWASocket, useMultiFileAuthState } from "@whiskeysockets/baileys";
|
|
3
3
|
//#region extensions/whatsapp/src/session.runtime.ts
|
|
4
4
|
var session_runtime_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { r as resolveDefaultWhatsAppAccountId
|
|
1
|
+
import { r as resolveDefaultWhatsAppAccountId } from "./account-ids-DG18xddX.js";
|
|
2
2
|
import { a as resolveWhatsAppAccount, o as resolveWhatsAppAuthDir } from "./accounts-BDqgpFEB.js";
|
|
3
3
|
import { a as normalizeWhatsAppAllowFromEntries, o as normalizeWhatsAppAllowFromEntry } from "./normalize-target-nXxC_hxG.js";
|
|
4
|
-
import {
|
|
5
|
-
import { t as whatsappSetupAdapter } from "./setup-core-DZKvpzbH.js";
|
|
4
|
+
import { t as whatsappSetupAdapter } from "./setup-core-DnhO0PjG.js";
|
|
6
5
|
import path from "node:path";
|
|
7
|
-
import { DEFAULT_ACCOUNT_ID, pathExists,
|
|
6
|
+
import { DEFAULT_ACCOUNT_ID, pathExists, splitSetupEntries } from "openclaw/plugin-sdk/setup";
|
|
8
7
|
import { formatCliCommand, formatDocsLink } from "openclaw/plugin-sdk/setup-tools";
|
|
9
8
|
//#region extensions/whatsapp/src/setup-finalize.ts
|
|
10
9
|
function trimPromptText(value) {
|
|
@@ -280,7 +279,7 @@ async function finalizeWhatsAppSetup(params) {
|
|
|
280
279
|
message: linked ? "WhatsApp already linked. Re-link now?" : "Link WhatsApp now (QR)?",
|
|
281
280
|
initialValue: !linked
|
|
282
281
|
})) try {
|
|
283
|
-
const { loginWeb } = await import("./login-
|
|
282
|
+
const { loginWeb } = await import("./login-DV99D0IN.js").then((n) => n.n);
|
|
284
283
|
await loginWeb(false, void 0, params.runtime, accountId);
|
|
285
284
|
} catch (error) {
|
|
286
285
|
params.runtime.error(`WhatsApp login failed: ${String(error)}`);
|
|
@@ -296,50 +295,4 @@ async function finalizeWhatsAppSetup(params) {
|
|
|
296
295
|
return { cfg: next };
|
|
297
296
|
}
|
|
298
297
|
//#endregion
|
|
299
|
-
|
|
300
|
-
const channel = "whatsapp";
|
|
301
|
-
async function readWhatsAppSetupLinkState(cfg, accountId) {
|
|
302
|
-
const { authDir } = resolveWhatsAppAuthDir({
|
|
303
|
-
cfg,
|
|
304
|
-
accountId
|
|
305
|
-
});
|
|
306
|
-
return await readWebAuthState(authDir);
|
|
307
|
-
}
|
|
308
|
-
const whatsappSetupWizard = {
|
|
309
|
-
channel,
|
|
310
|
-
status: {
|
|
311
|
-
configuredLabel: "linked",
|
|
312
|
-
unconfiguredLabel: "not linked",
|
|
313
|
-
configuredHint: "linked",
|
|
314
|
-
unconfiguredHint: "not linked",
|
|
315
|
-
configuredScore: 5,
|
|
316
|
-
unconfiguredScore: 4,
|
|
317
|
-
resolveConfigured: async ({ cfg, accountId }) => {
|
|
318
|
-
for (const resolvedAccountId of accountId ? [accountId] : listAccountIds(cfg)) if (await readWhatsAppSetupLinkState(cfg, resolvedAccountId) === "linked") return true;
|
|
319
|
-
return false;
|
|
320
|
-
},
|
|
321
|
-
resolveStatusLines: async ({ cfg, accountId, configured }) => {
|
|
322
|
-
const linkedAccountId = (await Promise.all((accountId ? [accountId] : listAccountIds(cfg)).map(async (resolvedAccountId) => ({
|
|
323
|
-
accountId: resolvedAccountId,
|
|
324
|
-
state: await readWhatsAppSetupLinkState(cfg, resolvedAccountId)
|
|
325
|
-
})))).find((entry) => entry.state === "linked" || entry.state === "unstable");
|
|
326
|
-
const labelAccountId = accountId ?? linkedAccountId?.accountId;
|
|
327
|
-
return [`${labelAccountId ? `WhatsApp (${labelAccountId === DEFAULT_ACCOUNT_ID ? "default" : labelAccountId})` : "WhatsApp"}: ${configured ? formatWhatsAppWebAuthStatusState("linked") : formatWhatsAppWebAuthStatusState(linkedAccountId?.state ?? "not-linked")}`];
|
|
328
|
-
}
|
|
329
|
-
},
|
|
330
|
-
resolveShouldPromptAccountIds: ({ shouldPromptAccountIds }) => shouldPromptAccountIds,
|
|
331
|
-
credentials: [],
|
|
332
|
-
finalize: async ({ cfg, accountId, forceAllowFrom, prompter, runtime }) => await finalizeWhatsAppSetup({
|
|
333
|
-
cfg,
|
|
334
|
-
accountId,
|
|
335
|
-
forceAllowFrom,
|
|
336
|
-
prompter,
|
|
337
|
-
runtime
|
|
338
|
-
}),
|
|
339
|
-
disable: (cfg) => setSetupChannelEnabled(cfg, channel, false),
|
|
340
|
-
onAccountRecorded: (accountId, options) => {
|
|
341
|
-
options?.onAccountId?.(channel, accountId);
|
|
342
|
-
}
|
|
343
|
-
};
|
|
344
|
-
//#endregion
|
|
345
|
-
export { whatsappSetupWizard };
|
|
298
|
+
export { finalizeWhatsAppSetup };
|
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-BqlcEVzR.js";
|
|
2
2
|
export { whatsappSetupPlugin };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { t as listAccountIds } from "./account-ids-DG18xddX.js";
|
|
2
|
+
import { o as resolveWhatsAppAuthDir } from "./accounts-BDqgpFEB.js";
|
|
3
|
+
import { i as formatWhatsAppWebAuthStatusState, m as readWebAuthState } from "./auth-store-CjEimXKX.js";
|
|
4
|
+
import { DEFAULT_ACCOUNT_ID, setSetupChannelEnabled } from "openclaw/plugin-sdk/setup";
|
|
5
|
+
//#region extensions/whatsapp/src/setup-surface.ts
|
|
6
|
+
const channel = "whatsapp";
|
|
7
|
+
async function readWhatsAppSetupLinkState(cfg, accountId) {
|
|
8
|
+
const { authDir } = resolveWhatsAppAuthDir({
|
|
9
|
+
cfg,
|
|
10
|
+
accountId
|
|
11
|
+
});
|
|
12
|
+
return await readWebAuthState(authDir);
|
|
13
|
+
}
|
|
14
|
+
const whatsappSetupWizard = {
|
|
15
|
+
channel,
|
|
16
|
+
status: {
|
|
17
|
+
configuredLabel: "linked",
|
|
18
|
+
unconfiguredLabel: "not linked",
|
|
19
|
+
configuredHint: "linked",
|
|
20
|
+
unconfiguredHint: "not linked",
|
|
21
|
+
configuredScore: 5,
|
|
22
|
+
unconfiguredScore: 4,
|
|
23
|
+
resolveConfigured: async ({ cfg, accountId }) => {
|
|
24
|
+
for (const resolvedAccountId of accountId ? [accountId] : listAccountIds(cfg)) if (await readWhatsAppSetupLinkState(cfg, resolvedAccountId) === "linked") return true;
|
|
25
|
+
return false;
|
|
26
|
+
},
|
|
27
|
+
resolveStatusLines: async ({ cfg, accountId, configured }) => {
|
|
28
|
+
const linkedAccountId = (await Promise.all((accountId ? [accountId] : listAccountIds(cfg)).map(async (resolvedAccountId) => ({
|
|
29
|
+
accountId: resolvedAccountId,
|
|
30
|
+
state: await readWhatsAppSetupLinkState(cfg, resolvedAccountId)
|
|
31
|
+
})))).find((entry) => entry.state === "linked" || entry.state === "unstable");
|
|
32
|
+
const labelAccountId = accountId ?? linkedAccountId?.accountId;
|
|
33
|
+
return [`${labelAccountId ? `WhatsApp (${labelAccountId === DEFAULT_ACCOUNT_ID ? "default" : labelAccountId})` : "WhatsApp"}: ${configured ? formatWhatsAppWebAuthStatusState("linked") : formatWhatsAppWebAuthStatusState(linkedAccountId?.state ?? "not-linked")}`];
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
resolveShouldPromptAccountIds: ({ shouldPromptAccountIds }) => shouldPromptAccountIds,
|
|
37
|
+
credentials: [],
|
|
38
|
+
finalize: async (params) => await (await import("./setup-finalize-D3YuMUBs.js")).finalizeWhatsAppSetup(params),
|
|
39
|
+
disable: (cfg) => setSetupChannelEnabled(cfg, channel, false),
|
|
40
|
+
onAccountRecorded: (accountId, options) => {
|
|
41
|
+
options?.onAccountId?.(channel, accountId);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
//#endregion
|
|
45
|
+
export { whatsappSetupWizard };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { r as resolveDefaultWhatsAppAccountId, t as listAccountIds } from "./account-ids-DG18xddX.js";
|
|
2
2
|
import { a as resolveWhatsAppAccount, n as hasAnyWhatsAppAuth } from "./accounts-BDqgpFEB.js";
|
|
3
3
|
import { a as normalizeWhatsAppAllowFromEntries } from "./normalize-target-nXxC_hxG.js";
|
|
4
|
-
import { t as WhatsAppChannelConfigSchema } from "./config-schema-
|
|
5
|
-
import { n as whatsappDoctor } from "./doctor-
|
|
6
|
-
import { t as resolveLegacyGroupSessionKey } from "./group-session-contract-
|
|
7
|
-
import { n as unsupportedSecretRefSurfacePatterns, t as collectUnsupportedSecretRefConfigCandidates } from "./security-contract-
|
|
8
|
-
import { n as deriveLegacySessionChatType, r as isLegacyGroupSessionKey, t as canonicalizeLegacySessionKey } from "./session-contract-
|
|
4
|
+
import { t as WhatsAppChannelConfigSchema } from "./config-schema-cSC7M4YA.js";
|
|
5
|
+
import { n as whatsappDoctor } from "./doctor-BrgepDUP.js";
|
|
6
|
+
import { t as resolveLegacyGroupSessionKey } from "./group-session-contract-DL-SLclv.js";
|
|
7
|
+
import { n as unsupportedSecretRefSurfacePatterns, t as collectUnsupportedSecretRefConfigCandidates } from "./security-contract-BzlZFreO.js";
|
|
8
|
+
import { n as deriveLegacySessionChatType, r as isLegacyGroupSessionKey, t as canonicalizeLegacySessionKey } from "./session-contract-BNUscPf4.js";
|
|
9
9
|
import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/account-core";
|
|
10
10
|
import { normalizeE164 } from "openclaw/plugin-sdk/account-resolution";
|
|
11
11
|
import { createChannelPluginBase, getChatChannelMeta } from "openclaw/plugin-sdk/core";
|
|
@@ -124,10 +124,10 @@ function resolveWhatsAppConfigPath(params) {
|
|
|
124
124
|
return `${resolveWhatsAppGroupScopeBasePath(params)}.${params.field}`;
|
|
125
125
|
}
|
|
126
126
|
async function loadWhatsAppChannelRuntime() {
|
|
127
|
-
return await import("./channel.runtime-
|
|
127
|
+
return await import("./channel.runtime-CNdPCK3G.js");
|
|
128
128
|
}
|
|
129
129
|
async function loadWhatsAppSetupSurface() {
|
|
130
|
-
return await import("./setup-surface-
|
|
130
|
+
return await import("./setup-surface-CHjYlKJc.js");
|
|
131
131
|
}
|
|
132
132
|
const whatsappSetupWizardProxy = createWhatsAppSetupWizardProxy(async () => (await loadWhatsAppSetupSurface()).whatsappSetupWizard);
|
|
133
133
|
const whatsappConfigAdapter = createScopedChannelConfigAdapter({
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import { statRegularFileSync } from "openclaw/plugin-sdk/security-runtime";
|
|
3
4
|
import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/account-id";
|
|
4
5
|
//#region extensions/whatsapp/src/state-migrations.ts
|
|
5
6
|
function fileExists(pathValue) {
|
|
6
7
|
try {
|
|
7
|
-
return
|
|
8
|
+
return !statRegularFileSync(pathValue).missing;
|
|
8
9
|
} catch {
|
|
9
10
|
return false;
|
|
10
11
|
}
|
package/dist/test-api.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { t as resolveWhatsAppRuntimeGroupPolicy } from "./runtime-group-policy-
|
|
2
|
-
import { t as whatsappOutbound } from "./outbound-adapter-
|
|
1
|
+
import { t as resolveWhatsAppRuntimeGroupPolicy } from "./runtime-group-policy-BH_U23qp.js";
|
|
2
|
+
import { t as whatsappOutbound } from "./outbound-adapter-B9ZW8sht.js";
|
|
3
3
|
export { resolveWhatsAppRuntimeGroupPolicy, whatsappOutbound };
|
|
@@ -1,9 +1,34 @@
|
|
|
1
|
-
import { n as __reExport, t as __exportAll } from "./rolldown-runtime-RkAeH_Qm.js";
|
|
2
1
|
import fs from "node:fs";
|
|
3
2
|
import path from "node:path";
|
|
4
3
|
import { CONFIG_DIR, escapeRegExp, resolveUserPath } from "openclaw/plugin-sdk/text-runtime";
|
|
5
4
|
import { normalizeE164 } from "openclaw/plugin-sdk/account-resolution";
|
|
6
5
|
import { logVerbose, shouldLogVerbose } from "openclaw/plugin-sdk/runtime-env";
|
|
6
|
+
//#region \0rolldown/runtime.js
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
9
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
10
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __exportAll = (all, no_symbols) => {
|
|
12
|
+
let target = {};
|
|
13
|
+
for (var name in all) __defProp(target, name, {
|
|
14
|
+
get: all[name],
|
|
15
|
+
enumerable: true
|
|
16
|
+
});
|
|
17
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
22
|
+
key = keys[i];
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
24
|
+
get: ((k) => from[k]).bind(null, key),
|
|
25
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return to;
|
|
29
|
+
};
|
|
30
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
31
|
+
//#endregion
|
|
7
32
|
//#region extensions/whatsapp/src/targets-runtime.ts
|
|
8
33
|
const WHATSAPP_FENCE_PLACEHOLDER = "\0FENCE";
|
|
9
34
|
const WHATSAPP_INLINE_CODE_PLACEHOLDER = "\0CODE";
|
|
@@ -139,4 +164,4 @@ var text_runtime_exports = /* @__PURE__ */ __exportAll({
|
|
|
139
164
|
import * as import_openclaw_plugin_sdk_text_runtime from "openclaw/plugin-sdk/text-runtime";
|
|
140
165
|
__reExport(text_runtime_exports, import_openclaw_plugin_sdk_text_runtime);
|
|
141
166
|
//#endregion
|
|
142
|
-
export { markdownToWhatsApp as a, toWhatsappJidWithLid as c, jidToE164 as i, assertWebChannel as n, resolveJidToE164 as o, isSelfChatMode as r, toWhatsappJid as s, text_runtime_exports as t };
|
|
167
|
+
export { markdownToWhatsApp as a, toWhatsappJidWithLid as c, jidToE164 as i, __exportAll as l, assertWebChannel as n, resolveJidToE164 as o, isSelfChatMode as r, toWhatsappJid as s, text_runtime_exports as t };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/whatsapp",
|
|
3
|
-
"version": "2026.5.
|
|
3
|
+
"version": "2026.5.10-beta.1",
|
|
4
4
|
"description": "OpenClaw WhatsApp channel plugin",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
},
|
|
9
9
|
"type": "module",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@whiskeysockets/baileys": "7.0.0-
|
|
11
|
+
"@whiskeysockets/baileys": "7.0.0-rc10",
|
|
12
12
|
"https-proxy-agent": "^9.0.0",
|
|
13
13
|
"jimp": "^1.6.1",
|
|
14
|
-
"typebox": "1.1.
|
|
14
|
+
"typebox": "1.1.38",
|
|
15
15
|
"undici": "8.2.0"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"openclaw": "workspace:*"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
|
-
"openclaw": ">=2026.5.
|
|
22
|
+
"openclaw": ">=2026.5.10-beta.1"
|
|
23
23
|
},
|
|
24
24
|
"peerDependenciesMeta": {
|
|
25
25
|
"openclaw": {
|
|
@@ -61,10 +61,10 @@
|
|
|
61
61
|
"minHostVersion": ">=2026.4.25"
|
|
62
62
|
},
|
|
63
63
|
"compat": {
|
|
64
|
-
"pluginApi": ">=2026.5.
|
|
64
|
+
"pluginApi": ">=2026.5.10-beta.1"
|
|
65
65
|
},
|
|
66
66
|
"build": {
|
|
67
|
-
"openclawVersion": "2026.5.
|
|
67
|
+
"openclawVersion": "2026.5.10-beta.1"
|
|
68
68
|
},
|
|
69
69
|
"release": {
|
|
70
70
|
"publishToClawHub": true,
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
//#region \0rolldown/runtime.js
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __exportAll = (all, no_symbols) => {
|
|
7
|
-
let target = {};
|
|
8
|
-
for (var name in all) __defProp(target, name, {
|
|
9
|
-
get: all[name],
|
|
10
|
-
enumerable: true
|
|
11
|
-
});
|
|
12
|
-
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
13
|
-
return target;
|
|
14
|
-
};
|
|
15
|
-
var __copyProps = (to, from, except, desc) => {
|
|
16
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
17
|
-
key = keys[i];
|
|
18
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
19
|
-
get: ((k) => from[k]).bind(null, key),
|
|
20
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
return to;
|
|
24
|
-
};
|
|
25
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
26
|
-
//#endregion
|
|
27
|
-
export { __reExport as n, __exportAll as t };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|