@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.
Files changed (48) hide show
  1. package/dist/.setup/{action-runtime-CE3zGstN.mjs → action-runtime-DUSkWTiZ.mjs} +2 -2
  2. package/dist/.setup/{agent-tools-login-B7VEvJO7.mjs → agent-tools-login-CB7OQbli.mjs} +5 -15
  3. package/dist/.setup/{approval-handler.runtime-CKposl6w.mjs → approval-handler.runtime-BEaAKSoU.mjs} +3 -3
  4. package/dist/.setup/{approval-reactions-CD6CDF9k.mjs → approval-reactions-CWkZ_ham.mjs} +7 -16
  5. package/dist/.setup/audio-preflight.runtime-Dg8oZgre.mjs +2 -0
  6. package/dist/.setup/{auth-store-D2rN-hP5.mjs → auth-store-DOBi5BPe.mjs} +10 -11
  7. package/dist/.setup/{channel-DNgKHMCz.mjs → channel-DcHw3Up2.mjs} +136 -135
  8. package/dist/.setup/{channel-react-action-BaBV9X6M.mjs → channel-react-action-C5E8_iDk.mjs} +3 -3
  9. package/dist/.setup/{channel.runtime-BniF8Swm.mjs → channel.runtime-DTj-wkEP.mjs} +5 -11
  10. package/dist/.setup/channel.setup-BJWEyQlF.mjs +5 -0
  11. package/dist/.setup/{connection-controller-COkcq48K.mjs → connection-controller-CejM7bhn.mjs} +50 -84
  12. package/dist/.setup/{directory-config-RYQomHyB.mjs → directory-config-DPLTUAqy.mjs} +22 -29
  13. package/dist/.setup/{group-session-key-BV8Le9r8.mjs → group-session-key-BbTPosdy.mjs} +12 -18
  14. package/dist/.setup/{login-CV_4V021.mjs → login-DUx5JYuW.mjs} +3 -3
  15. package/dist/.setup/{login-qr-DFhGc5yH.mjs → login-qr-BAWbPonj.mjs} +24 -45
  16. package/dist/.setup/{monitor-B5DS4PDV.mjs → monitor-CmXEQad9.mjs} +218 -367
  17. package/dist/.setup/{normalize-target-BGra1ZnM.mjs → normalize-target-D67Kc3g6.mjs} +5 -8
  18. package/dist/.setup/{question-reactions-LMeijbaq.mjs → question-reactions-DywNaX8m.mjs} +3 -10
  19. package/dist/.setup/reaction-target-CSPO7gtu.mjs +11 -0
  20. package/dist/.setup/{resolve-outbound-target-CzyNKmrl.mjs → resolve-outbound-target-qikGL4r0.mjs} +3 -4
  21. package/dist/.setup/{send-CGUsUdoX.mjs → send-CLBfAzd6.mjs} +34 -42
  22. package/dist/.setup/{send-api-B03VDwZ1.mjs → send-api-COzRvqXx.mjs} +28 -60
  23. package/dist/.setup/{setup-finalize-GtBmrO8p.mjs → setup-finalize-DSiP_-wa.mjs} +53 -69
  24. package/dist/.setup/setup-plugin-api-8WdNCjRW.mjs +3 -0
  25. package/dist/.setup/{setup-surface-BuA39k6K.mjs → setup-surface-C_flQyHy.mjs} +2 -2
  26. package/dist/.setup/{shared-CP_zs2U7.mjs → shared-SqcOkt51.mjs} +4 -4
  27. package/dist/.setup/{socket-close-DU7eerAa.mjs → socket-close-C9OU9mVN.mjs} +67 -86
  28. package/dist/.setup/{targets-runtime-Dls-Xh4F.mjs → targets-runtime-D5ryyPxh.mjs} +16 -25
  29. package/dist/action-runtime-api.js +1 -1
  30. package/dist/action-runtime.runtime.js +1 -1
  31. package/dist/agent-tools-api.js +4 -8
  32. package/dist/api.js +13 -15
  33. package/dist/channel-plugin-api.js +1 -1
  34. package/dist/contract-api.js +1 -1
  35. package/dist/directory-contract-api.js +1 -1
  36. package/dist/doctor-contract-api.js +12 -32
  37. package/dist/light-runtime-api.js +2 -2
  38. package/dist/login-qr-runtime.js +2 -4
  39. package/dist/runtime-api.js +8 -8
  40. package/dist/setup-entry.js +1 -1
  41. package/dist/setup-plugin-api.js +1 -1
  42. package/node_modules/baileys/lib/Utils/messages-media.js +7 -11
  43. package/node_modules/baileys/node_modules/ws/lib/websocket.js +17 -3
  44. package/node_modules/baileys/node_modules/ws/package.json +1 -1
  45. package/package.json +4 -4
  46. package/dist/.setup/audio-preflight.runtime-C_glQhZY.mjs +0 -7
  47. package/dist/.setup/channel.setup-CsS_NAKQ.mjs +0 -5
  48. package/dist/.setup/setup-plugin-api-Bsp7jI-r.mjs +0 -3
@@ -1,6 +1,6 @@
1
1
  import { a as resolveWhatsAppAccount } from "./accounts-F0vHuze2.mjs";
2
- import { t as resolveWhatsAppOutboundTarget } from "./resolve-outbound-target-CzyNKmrl.mjs";
3
- import { r as sendReactionWhatsApp, y as resolveWhatsAppReactionLevel } from "./send-CGUsUdoX.mjs";
2
+ import { t as resolveWhatsAppOutboundTarget } from "./resolve-outbound-target-qikGL4r0.mjs";
3
+ import { r as sendReactionWhatsApp, v as resolveWhatsAppReactionLevel } from "./send-CLBfAzd6.mjs";
4
4
  import { ToolAuthorizationError, createActionGate, jsonResult, readReactionParams, readStringParam } from "openclaw/plugin-sdk/channel-actions";
5
5
  //#region extensions/whatsapp/src/action-runtime-target-auth.ts
6
6
  function resolveAuthorizedWhatsAppOutboundTarget(params) {
@@ -27,7 +27,8 @@ function createWhatsAppLoginTool(context) {
27
27
  context.assertInvocationCurrent?.();
28
28
  if (!signal || signal.aborted) throw new Error("WhatsApp login authority is no longer active.");
29
29
  };
30
- const renderQrReply = (params) => {
30
+ const renderReply = (params, noQrDetails) => {
31
+ if (!params.qrDataUrl) return textResult(params.message, noQrDetails);
31
32
  const text = [
32
33
  params.message,
33
34
  "",
@@ -49,26 +50,15 @@ function createWhatsAppLoginTool(context) {
49
50
  timeoutMs,
50
51
  currentQrDataUrl: readNonBlankString(args.currentQrDataUrl)
51
52
  });
52
- if (result.qrDataUrl) return renderQrReply({
53
- message: result.message,
54
- qrDataUrl: result.qrDataUrl,
55
- connected: result.connected
56
- });
57
- return textResult(result.message, { connected: result.connected });
53
+ return renderReply(result, { connected: result.connected });
58
54
  }
59
55
  await beforeCredentialPersistence();
60
- const result = await startWebLoginWithQr({
56
+ return renderReply(await startWebLoginWithQr({
61
57
  accountId,
62
58
  timeoutMs,
63
59
  beforeCredentialPersistence,
64
60
  force: typeof args.force === "boolean" ? args.force : false
65
- });
66
- if (!result.qrDataUrl) return textResult(result.message, { qr: false });
67
- return renderQrReply({
68
- message: result.message,
69
- qrDataUrl: result.qrDataUrl,
70
- connected: result.connected
71
- });
61
+ }), { qr: false });
72
62
  }
73
63
  };
74
64
  }
@@ -1,9 +1,9 @@
1
1
  import "./accounts-F0vHuze2.mjs";
2
2
  import { r as resolveDefaultWhatsAppAccountId } from "./account-ids-CB5SOWjc.mjs";
3
- import { s as normalizeWhatsAppMessagingTarget } from "./normalize-target-BGra1ZnM.mjs";
4
- import { i as sendTypingWhatsApp, t as sendMessageWhatsApp } from "./send-CGUsUdoX.mjs";
3
+ import { s as normalizeWhatsAppMessagingTarget } from "./normalize-target-D67Kc3g6.mjs";
4
+ import { i as sendTypingWhatsApp, t as sendMessageWhatsApp } from "./send-CLBfAzd6.mjs";
5
5
  import { i as getWhatsAppRuntime } from "./runtime-BLlToOi6.mjs";
6
- import { i as unregisterWhatsAppApprovalReactionTarget, r as registerWhatsAppApprovalReactionTarget } from "./approval-reactions-CD6CDF9k.mjs";
6
+ import { i as unregisterWhatsAppApprovalReactionTarget, r as registerWhatsAppApprovalReactionTarget } from "./approval-reactions-CWkZ_ham.mjs";
7
7
  import { createSubsystemLogger } from "openclaw/plugin-sdk/runtime-env";
8
8
  import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/account-id";
9
9
  import { buildApprovalReactionPendingContent } from "openclaw/plugin-sdk/approval-reaction-runtime";
@@ -1,10 +1,10 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BBjsoOtd.mjs";
2
2
  import { a as resolveWhatsAppAccount } from "./accounts-F0vHuze2.mjs";
3
- import { d as listWhatsAppDeliveredMessageIdentities } from "./send-CGUsUdoX.mjs";
3
+ import { u as listWhatsAppDeliveredMessageIdentities } from "./send-CLBfAzd6.mjs";
4
4
  import { n as getOptionalWhatsAppRuntime } from "./runtime-BLlToOi6.mjs";
5
- import { c as whatsappApprovalAuth, s as getWhatsAppApprovalApprovers } from "./group-session-key-BV8Le9r8.mjs";
5
+ import { c as whatsappApprovalAuth, s as getWhatsAppApprovalApprovers } from "./group-session-key-BbTPosdy.mjs";
6
+ import { t as buildWhatsAppReactionTargetKey } from "./reaction-target-CSPO7gtu.mjs";
6
7
  import { normalizeUniqueTrimmedStringList } from "openclaw/plugin-sdk/string-coerce-runtime";
7
- import { createLazyRuntimeSurface } from "openclaw/plugin-sdk/lazy-runtime";
8
8
  import { approvalReactionDecisionSetsMatch, buildApprovalReactionDeliveredBindingMarker, createApprovalReactionTargetStore, listApprovalReactionBindings, readApprovalReactionDecisionList, readApprovalReactionDeliveredBinding, readApprovalReactionPresentationBinding, readApprovalReactionTargetRecord, resolveTypedApprovalReactionTarget, settleApprovalReaction } from "openclaw/plugin-sdk/approval-reaction-runtime";
9
9
  import { createPluginStateErrorReporter } from "openclaw/plugin-sdk/plugin-state-runtime";
10
10
  //#region extensions/whatsapp/src/approval-reactions.ts
@@ -21,7 +21,6 @@ const PERSISTENT_NAMESPACE = "whatsapp.approval-reactions";
21
21
  const PERSISTENT_MAX_ENTRIES = 1e3;
22
22
  const DEFAULT_REACTION_TARGET_TTL_MS = 864e5;
23
23
  const DELIVERY_BINDING_CHANNEL_DATA_KEY = "whatsappApprovalReactionBindingV1";
24
- const loadResolveApprovalOverGateway = createLazyRuntimeSurface(() => import("openclaw/plugin-sdk/approval-gateway-runtime"), (runtime) => runtime.resolveApprovalOverGateway);
25
24
  const reportPersistentApprovalReactionError = createPluginStateErrorReporter(getOptionalWhatsAppRuntime, "whatsapp", "approval-reaction-state", "WhatsApp persistent approval reaction state failed");
26
25
  const whatsappApprovalReactionTargets = createApprovalReactionTargetStore({
27
26
  namespace: PERSISTENT_NAMESPACE,
@@ -31,13 +30,6 @@ const whatsappApprovalReactionTargets = createApprovalReactionTargetStore({
31
30
  logPersistentError: reportPersistentApprovalReactionError,
32
31
  readPersistedTarget: readApprovalReactionTargetRecord
33
32
  });
34
- function buildReactionTargetKey(params) {
35
- const accountId = params.accountId.trim();
36
- const remoteJid = params.remoteJid.trim();
37
- const messageId = params.messageId.trim();
38
- if (!accountId || !remoteJid || !messageId) return null;
39
- return `${accountId}:${remoteJid}:${messageId}`;
40
- }
41
33
  function reportApprovalBindingCorrelationMismatch(binding) {
42
34
  try {
43
35
  getOptionalWhatsAppRuntime()?.logging.getChildLogger({
@@ -97,7 +89,7 @@ function prepareWhatsAppApprovalPayloadForDelivery(params) {
97
89
  };
98
90
  }
99
91
  async function registerWhatsAppApprovalReactionTarget(params) {
100
- const key = buildReactionTargetKey(params);
92
+ const key = buildWhatsAppReactionTargetKey(params);
101
93
  const approvalId = params.approvalId.trim();
102
94
  const allowedDecisions = listApprovalReactionBindings({ allowedDecisions: params.allowedDecisions }).map((binding) => binding.decision);
103
95
  if (!key || !approvalId || params.approvalKind !== "exec" && params.approvalKind !== "plugin" && params.approvalKind !== "system-agent" || allowedDecisions.length === 0) return null;
@@ -138,12 +130,12 @@ async function registerWhatsAppApprovalReactionTargetForDeliveredPayload(params)
138
130
  return (await Promise.all(registrations)).some(Boolean);
139
131
  }
140
132
  async function unregisterWhatsAppApprovalReactionTarget(params) {
141
- const key = buildReactionTargetKey(params);
133
+ const key = buildWhatsAppReactionTargetKey(params);
142
134
  if (!key) return;
143
135
  await whatsappApprovalReactionTargets.delete(key);
144
136
  }
145
137
  async function resolveWhatsAppApprovalReactionTargetWithPersistence(params) {
146
- const key = buildReactionTargetKey(params);
138
+ const key = buildWhatsAppReactionTargetKey(params);
147
139
  if (!key) return null;
148
140
  const resolved = resolveTypedApprovalReactionTarget({
149
141
  target: await whatsappApprovalReactionTargets.lookup(key),
@@ -231,7 +223,7 @@ async function maybeResolveWhatsAppApprovalReaction(params) {
231
223
  accountId: params.accountId
232
224
  }),
233
225
  authorizeActorAction: (input) => whatsappApprovalAuth.authorizeActorAction(input),
234
- loadResolver: loadResolveApprovalOverGateway,
226
+ loadResolver: async () => (await import("openclaw/plugin-sdk/approval-gateway-runtime")).resolveApprovalOverGateway,
235
227
  clearTarget: () => unregisterWhatsAppApprovalReactionTarget({
236
228
  accountId: params.accountId,
237
229
  remoteJid: target.remoteJid,
@@ -247,7 +239,6 @@ async function maybeResolveWhatsAppApprovalReaction(params) {
247
239
  }
248
240
  function clearWhatsAppApprovalReactionTargetsForTest() {
249
241
  whatsappApprovalReactionTargets.clearForTest();
250
- loadResolveApprovalOverGateway.clear();
251
242
  }
252
243
  //#endregion
253
244
  export { unregisterWhatsAppApprovalReactionTarget as i, maybeResolveWhatsAppApprovalReaction as n, registerWhatsAppApprovalReactionTarget as r, approval_reactions_exports as t };
@@ -0,0 +1,2 @@
1
+ import { transcribeFirstAudio } from "openclaw/plugin-sdk/media-runtime";
2
+ export { transcribeFirstAudio };
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BBjsoOtd.mjs";
2
2
  import { a as readWebCredsJsonRawSync, c as statWebCredsFileSync, i as readWebCredsJsonRaw, n as hasWebCredsSync, o as resolveWebCredsBackupPath, r as isWhatsAppBaileysAuthFileName, s as resolveWebCredsPath, t as assertWebCredsPathRegularFileOrMissing } from "./creds-files-B8WcOAmE.mjs";
3
- import { r as jidToE164 } from "./targets-runtime-Dls-Xh4F.mjs";
3
+ import { r as jidToE164 } from "./targets-runtime-D5ryyPxh.mjs";
4
4
  import path from "node:path";
5
5
  import { resolveOAuthDir as resolveOAuthDir$1 } from "openclaw/plugin-sdk/state-paths";
6
6
  import { isPathStrictlyInside } from "openclaw/plugin-sdk/file-access-runtime";
@@ -371,16 +371,19 @@ async function logoutWeb(params) {
371
371
  runtime.log(success("Cleared WhatsApp Web credentials."));
372
372
  return true;
373
373
  }
374
+ function parseWebSelfIdentity(raw, authDir) {
375
+ const parsed = JSON.parse(raw);
376
+ return resolveComparableIdentity({
377
+ jid: parsed?.me?.id ?? null,
378
+ lid: parsed?.me?.lid ?? null
379
+ }, authDir);
380
+ }
374
381
  function readWebSelfId(authDir = resolveDefaultWebAuthDir()) {
375
382
  try {
376
383
  const credsPath = resolveWebCredsPath(resolveUserPath(authDir));
377
384
  const raw = readWebCredsJsonRawSync(credsPath);
378
385
  if (!raw) return emptyWebSelfId();
379
- const parsed = JSON.parse(raw);
380
- const identity = resolveComparableIdentity({
381
- jid: parsed?.me?.id ?? null,
382
- lid: parsed?.me?.lid ?? null
383
- }, authDir);
386
+ const identity = parseWebSelfIdentity(raw, authDir);
384
387
  return {
385
388
  e164: identity.e164 ?? null,
386
389
  jid: identity.jid ?? null,
@@ -394,11 +397,7 @@ async function readWebSelfIdentity(authDir = resolveDefaultWebAuthDir(), fallbac
394
397
  const resolvedAuthDir = resolveUserPath(authDir);
395
398
  const raw = await readWebCredsJsonRaw(resolveWebCredsPath(resolvedAuthDir));
396
399
  if (raw) try {
397
- const parsed = JSON.parse(raw);
398
- return resolveComparableIdentity({
399
- jid: parsed?.me?.id ?? null,
400
- lid: parsed?.me?.lid ?? null
401
- }, resolvedAuthDir);
400
+ return parseWebSelfIdentity(raw, resolvedAuthDir);
402
401
  } catch {}
403
402
  return resolveComparableIdentity({
404
403
  jid: fallback?.id ?? null,
@@ -1,14 +1,14 @@
1
1
  import { a as resolveWhatsAppAccount } from "./accounts-F0vHuze2.mjs";
2
2
  import { r as resolveDefaultWhatsAppAccountId, t as listAccountIds } from "./account-ids-CB5SOWjc.mjs";
3
- import { a as normalizeWhatsAppAllowFromEntries, c as normalizeWhatsAppTarget, i as looksLikeWhatsAppTargetId, n as isWhatsAppNewsletterJid, o as normalizeWhatsAppAllowFromEntry, s as normalizeWhatsAppMessagingTarget, t as isWhatsAppGroupJid } from "./normalize-target-BGra1ZnM.mjs";
4
- import { t as resolveWhatsAppOutboundTarget } from "./resolve-outbound-target-CzyNKmrl.mjs";
5
- import { c as normalizeWhatsAppPayloadTextPreservingIndentation, i as sendTypingWhatsApp, n as sendPollWhatsApp, o as normalizeWhatsAppOutboundPayload, s as normalizeWhatsAppPayloadText, t as sendMessageWhatsApp, y as resolveWhatsAppReactionLevel } from "./send-CGUsUdoX.mjs";
3
+ import { a as normalizeWhatsAppAllowFromEntries, c as normalizeWhatsAppTarget, i as looksLikeWhatsAppTargetId, n as isWhatsAppNewsletterJid, o as normalizeWhatsAppAllowFromEntry, s as normalizeWhatsAppMessagingTarget, t as isWhatsAppGroupJid } from "./normalize-target-D67Kc3g6.mjs";
4
+ import { t as resolveWhatsAppOutboundTarget } from "./resolve-outbound-target-qikGL4r0.mjs";
5
+ import { i as sendTypingWhatsApp, n as sendPollWhatsApp, o as normalizeWhatsAppOutboundPayload, s as normalizeWhatsAppPayloadTextPreservingIndentation, t as sendMessageWhatsApp, v as resolveWhatsAppReactionLevel } from "./send-CLBfAzd6.mjs";
6
6
  import { i as getWhatsAppRuntime } from "./runtime-BLlToOi6.mjs";
7
- import { c as toWhatsappJid } from "./targets-runtime-Dls-Xh4F.mjs";
8
- import { c as whatsappApprovalAuth, o as lookupInboundMessageMetaForTarget, s as getWhatsAppApprovalApprovers, t as resolveWhatsAppGroupSessionKey } from "./group-session-key-BV8Le9r8.mjs";
9
- import { a as loadWhatsAppChannelRuntime, t as createWhatsAppPluginBase } from "./shared-CP_zs2U7.mjs";
7
+ import { c as toWhatsappJid } from "./targets-runtime-D5ryyPxh.mjs";
8
+ import { c as whatsappApprovalAuth, o as lookupInboundMessageMetaForTarget, s as getWhatsAppApprovalApprovers, t as resolveWhatsAppGroupSessionKey } from "./group-session-key-BbTPosdy.mjs";
9
+ import { a as loadWhatsAppChannelRuntime, t as createWhatsAppPluginBase } from "./shared-SqcOkt51.mjs";
10
10
  import { t as whatsappCommandPolicy } from "./command-policy-BIOSHySD.mjs";
11
- import { d as readWebAuthExistsForDecision, n as WHATSAPP_AUTH_UNSTABLE_CODE } from "./auth-store-D2rN-hP5.mjs";
11
+ import { d as readWebAuthExistsForDecision, n as WHATSAPP_AUTH_UNSTABLE_CODE } from "./auth-store-DOBi5BPe.mjs";
12
12
  import { createActionGate } from "openclaw/plugin-sdk/channel-actions";
13
13
  import { normalizeOptionalAccountId } from "openclaw/plugin-sdk/account-core";
14
14
  import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
@@ -19,9 +19,9 @@ import { buildChannelOutboundSessionRoute } from "openclaw/plugin-sdk/core";
19
19
  import { sendTextMediaPayload } from "openclaw/plugin-sdk/reply-payload";
20
20
  import { escapeRegExp } from "openclaw/plugin-sdk/text-utility-runtime";
21
21
  import { DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID$1 } from "openclaw/plugin-sdk/account-id";
22
- import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
23
22
  import { buildDmGroupAccountAllowlistAdapter } from "openclaw/plugin-sdk/allowlist-config-edit";
24
23
  import { createChatChannelPlugin } from "openclaw/plugin-sdk/channel-core";
24
+ import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
25
25
  import { createApproverRestrictedNativeApprovalCapabilityFromForwardingRoutes } from "openclaw/plugin-sdk/approval-delivery-runtime";
26
26
  import { createLazyChannelApprovalNativeRuntimeAdapter } from "openclaw/plugin-sdk/approval-handler-adapter-runtime";
27
27
  import { buildApprovalReactionPromptPayloadForRequest } from "openclaw/plugin-sdk/approval-reaction-runtime";
@@ -82,7 +82,7 @@ const whatsappApproval = createApproverRestrictedNativeApprovalCapabilityFromFor
82
82
  approvalKind,
83
83
  request
84
84
  }),
85
- load: async () => (await import("./approval-handler.runtime-CKposl6w.mjs")).whatsappApprovalNativeRuntime
85
+ load: async () => (await import("./approval-handler.runtime-BEaAKSoU.mjs")).whatsappApprovalNativeRuntime
86
86
  })
87
87
  });
88
88
  function buildWhatsAppPendingPayload(params, approvalKind) {
@@ -127,120 +127,123 @@ function hasAnyWhatsAppAccountWithAgentReactionsEnabled(cfg) {
127
127
  function describeWhatsAppMessageActions(params) {
128
128
  if (!params.cfg.channels?.whatsapp) return null;
129
129
  const gate = createActionGate(params.cfg.channels.whatsapp.actions);
130
- const actions = /* @__PURE__ */ new Set();
130
+ const actions = [];
131
131
  if (params.accountId != null ? Boolean(resolveEnabledWhatsAppAgentReactions({
132
132
  cfg: params.cfg,
133
133
  accountId: params.accountId
134
- })) : hasAnyWhatsAppAccountWithAgentReactionsEnabled(params.cfg)) actions.add("react");
135
- if (gate("polls")) actions.add("poll");
136
- actions.add("upload-file");
137
- return { actions: Array.from(actions) };
134
+ })) : hasAnyWhatsAppAccountWithAgentReactionsEnabled(params.cfg)) actions.push("react");
135
+ if (gate("polls")) actions.push("poll");
136
+ actions.push("upload-file");
137
+ return { actions };
138
138
  }
139
139
  //#endregion
140
140
  //#region extensions/whatsapp/src/outbound-send-deps.ts
141
141
  const WHATSAPP_LEGACY_OUTBOUND_SEND_DEP_KEYS = ["sendWhatsApp"];
142
142
  //#endregion
143
143
  //#region extensions/whatsapp/src/outbound-base.ts
144
- function createWhatsAppOutboundBase({ sendMessageWhatsApp, sendPollWhatsApp, shouldLogVerbose, resolveTarget, normalizeText = normalizeWhatsAppPayloadText }) {
145
- const resolveQuotedMessageKey = (params) => {
146
- const replyToId = params.replyToId?.trim();
147
- if (!replyToId) return;
148
- const targetJid = toWhatsappJid(params.to);
149
- const cachedMeta = lookupInboundMessageMetaForTarget(params.accountId, targetJid, replyToId);
150
- return {
151
- id: replyToId,
152
- remoteJid: cachedMeta?.remoteJid ?? targetJid,
153
- fromMe: cachedMeta?.fromMe ?? false,
154
- participant: cachedMeta?.participant,
155
- ...cachedMeta && cachedMeta.remoteJid !== targetJid ? { lookupTargetJid: targetJid } : {},
156
- messageText: cachedMeta?.body,
157
- media: cachedMeta?.media
158
- };
159
- };
160
- const dispatchMessage = async (params, text, mediaOptions) => {
161
- const lookupAccountId = normalizeOptionalAccountId(params.accountId) ?? resolveDefaultWhatsAppAccountId(params.cfg);
162
- const quotedMessageKey = resolveQuotedMessageKey({
163
- accountId: lookupAccountId,
164
- to: params.to,
165
- replyToId: params.replyToId
166
- });
167
- const send = quotedMessageKey ? sendMessageWhatsApp : resolveOutboundSendDep(params.deps, "whatsapp", { legacyKeys: WHATSAPP_LEGACY_OUTBOUND_SEND_DEP_KEYS }) ?? sendMessageWhatsApp;
168
- const onDeliveryResult = params.onDeliveryResult;
169
- return await send(params.to, text ?? normalizeText(params.text), {
170
- verbose: false,
171
- cfg: params.cfg,
172
- ...mediaOptions,
173
- accountId: params.accountId ?? void 0,
174
- gifPlayback: params.gifPlayback,
175
- replyToIdSource: params.replyToIdSource,
176
- replyToMode: params.replyToMode,
177
- formatting: params.formatting,
178
- onPlatformSendDispatch: params.onPlatformSendDispatch,
179
- ...quotedMessageKey ? { quotedMessageKey } : {},
180
- ...onDeliveryResult ? { onDeliveryResult: async (result) => {
181
- await onDeliveryResult(attachChannelToResult("whatsapp", result));
182
- } } : {}
183
- });
144
+ const resolveQuotedMessageKey = (params) => {
145
+ const replyToId = params.replyToId?.trim();
146
+ if (!replyToId) return;
147
+ const targetJid = toWhatsappJid(params.to);
148
+ const cachedMeta = lookupInboundMessageMetaForTarget(params.accountId, targetJid, replyToId);
149
+ return {
150
+ id: replyToId,
151
+ remoteJid: cachedMeta?.remoteJid ?? targetJid,
152
+ fromMe: cachedMeta?.fromMe ?? false,
153
+ participant: cachedMeta?.participant,
154
+ ...cachedMeta && cachedMeta.remoteJid !== targetJid ? { lookupTargetJid: targetJid } : {},
155
+ messageText: cachedMeta?.body,
156
+ media: cachedMeta?.media
184
157
  };
185
- const outbound = {
186
- deliveryMode: "gateway",
187
- textChunkLimit: 4e3,
188
- sanitizeText: ({ text }) => normalizeText(text),
189
- deliveryCapabilities: { durableFinal: {
190
- text: true,
191
- replyTo: true,
192
- messageSendingHooks: true
193
- } },
194
- pollMaxOptions: 12,
195
- resolveTarget,
196
- ...createAttachedChannelResultAdapter({
197
- channel: "whatsapp",
198
- sendText: async (params) => {
199
- const normalizedText = normalizeText(params.text);
200
- if (!normalizedText) return { messageId: "" };
201
- return await dispatchMessage(params, normalizedText);
202
- },
203
- sendMedia: async (params) => await dispatchMessage(params, void 0, {
204
- mediaUrl: params.mediaUrl,
205
- mediaAccess: params.mediaAccess,
206
- mediaLocalRoots: params.mediaLocalRoots,
207
- mediaReadFile: params.mediaReadFile,
208
- ...params.audioAsVoice === void 0 ? {} : { audioAsVoice: params.audioAsVoice },
209
- forceDocument: params.forceDocument
210
- }),
211
- sendPoll: async ({ cfg, to, poll, accountId }) => await sendPollWhatsApp(to, poll, {
212
- verbose: shouldLogVerbose(),
213
- accountId: accountId ?? void 0,
214
- cfg
215
- })
158
+ };
159
+ const dispatchMessage = async (params, text, mediaOptions) => {
160
+ const lookupAccountId = normalizeOptionalAccountId(params.accountId) ?? resolveDefaultWhatsAppAccountId(params.cfg);
161
+ const quotedMessageKey = resolveQuotedMessageKey({
162
+ accountId: lookupAccountId,
163
+ to: params.to,
164
+ replyToId: params.replyToId
165
+ });
166
+ const send = quotedMessageKey ? void 0 : resolveOutboundSendDep(params.deps, "whatsapp", { legacyKeys: WHATSAPP_LEGACY_OUTBOUND_SEND_DEP_KEYS });
167
+ const onDeliveryResult = params.onDeliveryResult;
168
+ return await (send ?? sendMessageWhatsApp)(params.to, text ?? normalizeWhatsAppPayloadTextPreservingIndentation(params.text), {
169
+ verbose: false,
170
+ ...!send ? { preserveLeadingWhitespace: true } : {},
171
+ cfg: params.cfg,
172
+ ...mediaOptions,
173
+ accountId: params.accountId ?? void 0,
174
+ gifPlayback: params.gifPlayback,
175
+ replyToIdSource: params.replyToIdSource,
176
+ replyToMode: params.replyToMode,
177
+ formatting: params.formatting,
178
+ onPlatformSendDispatch: params.onPlatformSendDispatch,
179
+ ...quotedMessageKey ? { quotedMessageKey } : {},
180
+ ...onDeliveryResult ? { onDeliveryResult: async (result) => {
181
+ await onDeliveryResult(attachChannelToResult("whatsapp", result));
182
+ } } : {}
183
+ });
184
+ };
185
+ const outbound = {
186
+ deliveryMode: "gateway",
187
+ textChunkLimit: 4e3,
188
+ sanitizeText: ({ text }) => normalizeWhatsAppPayloadTextPreservingIndentation(text),
189
+ deliveryCapabilities: { durableFinal: {
190
+ text: true,
191
+ replyTo: true,
192
+ messageSendingHooks: true
193
+ } },
194
+ pollMaxOptions: 12,
195
+ resolveTarget: ({ to, allowFrom, mode }) => resolveWhatsAppOutboundTarget({
196
+ to,
197
+ allowFrom,
198
+ mode
199
+ }),
200
+ ...createAttachedChannelResultAdapter({
201
+ channel: "whatsapp",
202
+ sendText: async (params) => {
203
+ const normalizedText = normalizeWhatsAppPayloadTextPreservingIndentation(params.text);
204
+ if (!normalizedText) return { messageId: "" };
205
+ return await dispatchMessage(params, normalizedText);
206
+ },
207
+ sendMedia: async (params) => await dispatchMessage(params, void 0, {
208
+ mediaUrl: params.mediaUrl,
209
+ mediaAccess: params.mediaAccess,
210
+ mediaLocalRoots: params.mediaLocalRoots,
211
+ mediaReadFile: params.mediaReadFile,
212
+ ...params.audioAsVoice === void 0 ? {} : { audioAsVoice: params.audioAsVoice },
213
+ forceDocument: params.forceDocument
214
+ }),
215
+ sendPoll: async ({ cfg, to, poll, accountId }) => await sendPollWhatsApp(to, poll, {
216
+ verbose: getWhatsAppRuntime().logging.shouldLogVerbose(),
217
+ accountId: accountId ?? void 0,
218
+ cfg
216
219
  })
217
- };
218
- return {
219
- ...outbound,
220
- sendPayload: async (ctx) => {
221
- const payload = normalizeWhatsAppOutboundPayload(ctx.payload, { normalizeText });
222
- if (!payload.text && !(payload.mediaUrl || payload.mediaUrls?.length)) {
223
- if (ctx.payload.interactive || ctx.payload.presentation || ctx.payload.channelData) throw new Error("WhatsApp sendPayload does not support structured-only payloads without text or media.");
224
- return {
225
- channel: "whatsapp",
226
- messageId: ""
227
- };
228
- }
229
- return await sendTextMediaPayload({
220
+ })
221
+ };
222
+ const whatsappOutboundBase = {
223
+ ...outbound,
224
+ sendPayload: async (ctx) => {
225
+ const payload = normalizeWhatsAppOutboundPayload(ctx.payload, { normalizeText: normalizeWhatsAppPayloadTextPreservingIndentation });
226
+ if (!payload.text && !(payload.mediaUrl || payload.mediaUrls?.length)) {
227
+ if (ctx.payload.interactive || ctx.payload.presentation || ctx.payload.channelData) throw new Error("WhatsApp sendPayload does not support structured-only payloads without text or media.");
228
+ return {
230
229
  channel: "whatsapp",
231
- ctx: {
232
- ...ctx,
233
- payload
234
- },
235
- adapter: outbound
236
- });
230
+ messageId: ""
231
+ };
237
232
  }
238
- };
239
- }
233
+ return await sendTextMediaPayload({
234
+ channel: "whatsapp",
235
+ ctx: {
236
+ ...ctx,
237
+ payload
238
+ },
239
+ adapter: outbound
240
+ });
241
+ }
242
+ };
240
243
  //#endregion
241
244
  //#region extensions/whatsapp/src/channel-outbound.ts
242
- const loadWhatsAppApprovalReactionsModule = createLazyRuntimeModule(() => import("./approval-reactions-CD6CDF9k.mjs").then((n) => n.t));
243
- const loadWhatsAppQuestionReactionsModule = createLazyRuntimeModule(() => import("./question-reactions-LMeijbaq.mjs").then((n) => n.n));
245
+ const loadWhatsAppApprovalReactionsModule = createLazyRuntimeModule(() => import("./approval-reactions-CWkZ_ham.mjs").then((n) => n.t));
246
+ const loadWhatsAppQuestionReactionsModule = createLazyRuntimeModule(() => import("./question-reactions-DywNaX8m.mjs").then((n) => n.n));
244
247
  async function prepareWhatsAppApprovalPayloadForDelivery(params) {
245
248
  const questionPayload = questionGatewayRuntime.prepareReactionPayloadForDelivery({
246
249
  payload: params.payload,
@@ -257,20 +260,7 @@ async function registerDeliveredWhatsAppApprovalPayload(params) {
257
260
  await (await loadWhatsAppApprovalReactionsModule()).registerWhatsAppApprovalReactionTargetForDeliveredPayload(params);
258
261
  }
259
262
  const whatsappChannelOutbound = {
260
- ...createWhatsAppOutboundBase({
261
- sendMessageWhatsApp: async (to, text, options) => await sendMessageWhatsApp(to, text, {
262
- ...options,
263
- preserveLeadingWhitespace: true
264
- }),
265
- sendPollWhatsApp,
266
- shouldLogVerbose: () => getWhatsAppRuntime().logging.shouldLogVerbose(),
267
- resolveTarget: ({ to, allowFrom, mode }) => resolveWhatsAppOutboundTarget({
268
- to,
269
- allowFrom,
270
- mode
271
- }),
272
- normalizeText: normalizeWhatsAppPayloadTextPreservingIndentation
273
- }),
263
+ ...whatsappOutboundBase,
274
264
  sendTextOnlyErrorPayloads: true,
275
265
  renderPresentation: prepareWhatsAppApprovalPayloadForDelivery,
276
266
  afterDeliverPayload: registerDeliveredWhatsAppApprovalPayload,
@@ -353,8 +343,8 @@ async function checkWhatsAppHeartbeatReady(params) {
353
343
  function resolveWhatsAppOutboundSessionRoute(params) {
354
344
  const normalized = normalizeWhatsAppTarget(params.target);
355
345
  if (!normalized) return null;
356
- const isGroup = isWhatsAppGroupJid(normalized);
357
- const isNewsletter = isWhatsAppNewsletterJid(normalized);
346
+ const isGroup = normalized.endsWith("@g.us");
347
+ const isNewsletter = normalized.endsWith("@newsletter");
358
348
  const chatType = isGroup ? "group" : isNewsletter ? "channel" : "direct";
359
349
  const route = buildChannelOutboundSessionRoute({
360
350
  cfg: params.cfg,
@@ -434,31 +424,32 @@ function collectWhatsAppStatusIssues(accounts) {
434
424
  const relink = `Run: ${formatCliCommand("openclaw channels login")} (scan QR on the gateway host).`;
435
425
  const repair = `Run: ${formatCliCommand("openclaw doctor")} (or restart the gateway). If it persists, relink via channels login and check logs.`;
436
426
  const linkedRuntimePrefix = linked ? "Linked but " : "";
427
+ const addRuntimeIssue = (label, includeReconnectAttempts = true) => addIssue("runtime", `${linkedRuntimePrefix}${label}${includeReconnectAttempts && reconnectAttempts != null ? ` (reconnectAttempts=${reconnectAttempts})` : ""}${lastError ? `: ${lastError}` : "."}`, repair);
437
428
  if (statusState === "unstable") addIssue("auth", "Auth state is still stabilizing.", "Wait a moment for queued credential writes to finish, then retry the command or rerun health.");
438
429
  else if (healthState === "logged-out") addIssue("auth", `Session logged out${lastError ? `: ${lastError}` : "."}`, relink);
439
430
  else if (!linked) addIssue("auth", "Not linked (no WhatsApp Web session).", relink);
440
431
  if (healthState === "logged-out") return;
441
432
  if (!linked && healthState === "stopped" && !lastError && lastDisconnect?.at == null && (reconnectAttempts ?? 0) === 0) return;
442
433
  if (healthState === "stale") {
443
- addIssue("runtime", `${linkedRuntimePrefix}stale${lastInboundAt != null ? ` (last inbound ${Math.max(0, Math.floor((Date.now() - lastInboundAt) / 6e4))}m ago)` : ""}${lastError ? `: ${lastError}` : "."}`, repair);
434
+ addRuntimeIssue(`stale${lastInboundAt != null ? ` (last inbound ${Math.max(0, Math.floor((Date.now() - lastInboundAt) / 6e4))}m ago)` : ""}`, false);
444
435
  return;
445
436
  }
446
437
  if (healthState === "reconnecting" || healthState === "conflict" || healthState === "stopped") {
447
- addIssue("runtime", `${linkedRuntimePrefix}${healthState === "conflict" ? "session conflict" : healthState === "reconnecting" ? "reconnecting" : "stopped"}${reconnectAttempts != null ? ` (reconnectAttempts=${reconnectAttempts})` : ""}${lastError ? `: ${lastError}` : "."}`, repair);
438
+ addRuntimeIssue(healthState === "conflict" ? "session conflict" : healthState === "reconnecting" ? "reconnecting" : "stopped");
448
439
  return;
449
440
  }
450
441
  if (linked && running && connected && reconnectAttempts != null && reconnectAttempts > 0 && isRecentDisconnect(lastDisconnect)) {
451
442
  addIssue("runtime", `Linked but recently reconnected (reconnectAttempts=${reconnectAttempts})${lastError ? `: ${lastError}` : "."}`, `Watch: ${formatCliCommand("openclaw logs --follow")} and run ${formatCliCommand("openclaw channels status --probe")} if disconnects continue. If it keeps flapping, restart the gateway or relink via channels login.`);
452
443
  return;
453
444
  }
454
- if (running && !connected) addIssue("runtime", `${linkedRuntimePrefix}disconnected${reconnectAttempts != null ? ` (reconnectAttempts=${reconnectAttempts})` : ""}${lastError ? `: ${lastError}` : "."}`, repair);
445
+ if (running && !connected) addRuntimeIssue("disconnected");
455
446
  }
456
447
  });
457
448
  }
458
449
  //#endregion
459
450
  //#region extensions/whatsapp/src/channel.ts
460
- const loadWhatsAppDirectoryConfig = createLazyRuntimeModule(() => import("./directory-config-RYQomHyB.mjs").then((n) => n.t));
461
- const loadWhatsAppChannelReactAction = createLazyRuntimeModule(() => import("./channel-react-action-BaBV9X6M.mjs"));
451
+ const loadWhatsAppDirectoryConfig = createLazyRuntimeModule(() => import("./directory-config-DPLTUAqy.mjs").then((n) => n.t));
452
+ const loadWhatsAppChannelReactAction = createLazyRuntimeModule(() => import("./channel-react-action-C5E8_iDk.mjs"));
462
453
  function projectWhatsAppRuntimeStatus(runtime) {
463
454
  return {
464
455
  connected: runtime?.connected ?? false,
@@ -666,14 +657,24 @@ const whatsappPlugin = createChatChannelPlugin({
666
657
  gateway: {
667
658
  startAccount: async (ctx) => {
668
659
  const account = ctx.account;
669
- const { e164, jid } = (await loadWhatsAppChannelRuntime()).readWebSelfId(account.authDir);
660
+ const channelRuntime = await loadWhatsAppChannelRuntime();
661
+ const auth = await channelRuntime.readWebAuthSnapshot(account.authDir);
662
+ ctx.abortSignal.throwIfAborted();
663
+ const { e164, jid } = auth.selfId;
670
664
  const identity = e164 ? e164 : jid ? `jid ${jid}` : "unknown";
671
665
  ctx.log?.info(`[${account.accountId}] starting provider (${identity})`);
672
- return (await loadWhatsAppChannelRuntime()).monitorWebChannel(getWhatsAppRuntime().logging.shouldLogVerbose(), void 0, true, void 0, ctx.runtime, ctx.abortSignal, {
673
- statusSink: (next) => ctx.setStatus({
674
- accountId: ctx.accountId,
675
- ...next
676
- }),
666
+ return channelRuntime.monitorWebChannel(getWhatsAppRuntime().logging.shouldLogVerbose(), void 0, true, void 0, ctx.runtime, ctx.abortSignal, {
667
+ statusSink: (next) => {
668
+ const hasIdentity = next.running && next.healthState !== "logged-out";
669
+ const snapshot = {
670
+ accountId: ctx.accountId,
671
+ ...next,
672
+ self: hasIdentity ? auth.selfId : null,
673
+ authAgeMs: hasIdentity ? next.authAgeMs === void 0 ? auth.authAgeMs : next.authAgeMs : null,
674
+ ...next.healthState === "logged-out" ? { linked: false } : {}
675
+ };
676
+ ctx.setStatus(snapshot);
677
+ },
677
678
  accountId: account.accountId,
678
679
  channelRuntime: ctx.channelRuntime
679
680
  });
@@ -1,7 +1,7 @@
1
1
  import { a as resolveWhatsAppAccount, s as resolveWhatsAppMediaMaxBytes } from "./accounts-F0vHuze2.mjs";
2
- import { c as normalizeWhatsAppTarget, t as isWhatsAppGroupJid } from "./normalize-target-BGra1ZnM.mjs";
3
- import { r as resolveAuthorizedWhatsAppOutboundTarget, t as handleWhatsAppAction } from "./action-runtime-CE3zGstN.mjs";
4
- import { a as sendWhatsAppUploadFile } from "./send-CGUsUdoX.mjs";
2
+ import { c as normalizeWhatsAppTarget, t as isWhatsAppGroupJid } from "./normalize-target-D67Kc3g6.mjs";
3
+ import { r as resolveAuthorizedWhatsAppOutboundTarget, t as handleWhatsAppAction } from "./action-runtime-DUSkWTiZ.mjs";
4
+ import { a as sendWhatsAppUploadFile } from "./send-CLBfAzd6.mjs";
5
5
  import { jsonResult, readStringOrNumberParam, readStringParam as readStringParam$1, resolveReactionMessageId } from "openclaw/plugin-sdk/channel-actions";
6
6
  import { canonicalizeBase64, estimateBase64DecodedBytes } from "openclaw/plugin-sdk/media-runtime";
7
7
  import { readBooleanParam } from "openclaw/plugin-sdk/boolean-param";
@@ -1,16 +1,10 @@
1
- import { startWebLoginWithQr as startWebLoginWithQr$1, waitForWebLogin as waitForWebLogin$1 } from "../login-qr-runtime.js";
2
- import { b as webAuthExists, c as logoutWeb, d as readWebAuthExistsForDecision, f as readWebAuthSnapshot, h as readWebSelfId, m as readWebAuthState, o as getWebAuthAgeMs, p as readWebAuthSnapshotBestEffort, s as logWebSelfId, u as readWebAuthExistsBestEffort } from "./auth-store-D2rN-hP5.mjs";
1
+ import { startWebLoginWithQr, waitForWebLogin } from "../login-qr-runtime.js";
2
+ import { b as webAuthExists, c as logoutWeb, d as readWebAuthExistsForDecision, f as readWebAuthSnapshot, h as readWebSelfId, m as readWebAuthState, o as getWebAuthAgeMs, p as readWebAuthSnapshotBestEffort, s as logWebSelfId, u as readWebAuthExistsBestEffort } from "./auth-store-DOBi5BPe.mjs";
3
3
  import { t as getActiveWebListener } from "./active-listener-CDjoX9QR.mjs";
4
- import { t as monitorWebChannel } from "./monitor-B5DS4PDV.mjs";
5
- import { t as loginWeb } from "./login-CV_4V021.mjs";
6
- import { whatsappSetupWizard as whatsappSetupWizard$1 } from "./setup-surface-BuA39k6K.mjs";
4
+ import { t as monitorWebChannel } from "./monitor-CmXEQad9.mjs";
5
+ import { t as loginWeb } from "./login-DUx5JYuW.mjs";
6
+ import { whatsappSetupWizard as whatsappSetupWizard$1 } from "./setup-surface-C_flQyHy.mjs";
7
7
  //#region extensions/whatsapp/src/channel.runtime.ts
8
- async function startWebLoginWithQr(...args) {
9
- return await startWebLoginWithQr$1(...args);
10
- }
11
- async function waitForWebLogin(...args) {
12
- return await waitForWebLogin$1(...args);
13
- }
14
8
  const whatsappSetupWizard = { ...whatsappSetupWizard$1 };
15
9
  //#endregion
16
10
  export { getActiveWebListener, getWebAuthAgeMs, logWebSelfId, loginWeb, logoutWeb, monitorWebChannel, readWebAuthExistsBestEffort, readWebAuthExistsForDecision, readWebAuthSnapshot, readWebAuthSnapshotBestEffort, readWebAuthState, readWebSelfId, startWebLoginWithQr, waitForWebLogin, webAuthExists, whatsappSetupWizard };
@@ -0,0 +1,5 @@
1
+ import { t as createWhatsAppPluginBase } from "./shared-SqcOkt51.mjs";
2
+ //#region extensions/whatsapp/src/channel.setup.ts
3
+ const whatsappSetupPlugin = createWhatsAppPluginBase();
4
+ //#endregion
5
+ export { whatsappSetupPlugin as t };