@openclaw/whatsapp 2026.8.1-beta.3 → 2026.9.1-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. package/dist/{action-runtime-pM-ExU0l.js → action-runtime-C075e6OP.js} +1 -1
  2. package/dist/action-runtime-api.js +1 -1
  3. package/dist/action-runtime.runtime.js +1 -1
  4. package/dist/{call-tool-api.js → agent-tools-api.js} +10 -3
  5. package/dist/{agent-tools-login-BjRpD-JQ.js → agent-tools-login-B-2qZPzc.js} +12 -3
  6. package/dist/api.js +4 -4
  7. package/dist/{approval-handler.runtime-CkMMvUjk.js → approval-handler.runtime-CljxfPJz.js} +1 -1
  8. package/dist/{channel-DRMYRfZ8.js → channel-C4FMOZTE.js} +5 -7
  9. package/dist/channel-plugin-api.js +1 -1
  10. package/dist/{channel-react-action-CstrR0CT.js → channel-react-action-Bhp2BYRr.js} +2 -2
  11. package/dist/{channel.runtime-X3JC2gaq.js → channel.runtime-CrahUvcb.js} +2 -2
  12. package/dist/{channel.setup-DhBBhbQv.js → channel.setup-CGcBvnpP.js} +1 -1
  13. package/dist/index.js +4 -4
  14. package/dist/light-runtime-api.js +1 -1
  15. package/dist/{login-qr-1dpv6jjT.js → login-qr-DY4VFgOq.js} +34 -13
  16. package/dist/login-qr-runtime.js +1 -1
  17. package/dist/{monitor-IzwQKizW.js → monitor-C_Nw23PZ.js} +42 -37
  18. package/dist/runtime-api.js +5 -5
  19. package/dist/{send-CwvTU4RI.js → send-DLMUc2uZ.js} +1 -1
  20. package/dist/{send-api-obOSm2cC.js → send-api-BtK45TmZ.js} +2 -2
  21. package/dist/{setup-finalize-n4K2I2gJ.js → setup-finalize-C1nij8NS.js} +2 -2
  22. package/dist/setup-plugin-api.js +1 -1
  23. package/dist/{setup-surface-Cwn3zyxK.js → setup-surface-CjjqIxQP.js} +1 -1
  24. package/dist/{shared-wg42NKFB.js → shared-BekHi69d.js} +2 -2
  25. package/node_modules/baileys/lib/Defaults/index.js +1 -1
  26. package/node_modules/baileys/lib/Socket/business.d.ts.map +1 -1
  27. package/node_modules/baileys/lib/Socket/chats.d.ts +1 -0
  28. package/node_modules/baileys/lib/Socket/chats.d.ts.map +1 -1
  29. package/node_modules/baileys/lib/Socket/chats.js +10 -5
  30. package/node_modules/baileys/lib/Socket/chats.js.map +1 -1
  31. package/node_modules/baileys/lib/Socket/communities.d.ts.map +1 -1
  32. package/node_modules/baileys/lib/Socket/groups.d.ts.map +1 -1
  33. package/node_modules/baileys/lib/Socket/index.d.ts.map +1 -1
  34. package/node_modules/baileys/lib/Socket/messages-recv.d.ts.map +1 -1
  35. package/node_modules/baileys/lib/Socket/messages-send.d.ts.map +1 -1
  36. package/node_modules/baileys/lib/Socket/newsletter.d.ts.map +1 -1
  37. package/node_modules/baileys/lib/Socket/socket.d.ts.map +1 -1
  38. package/node_modules/baileys/lib/Socket/socket.js +3 -0
  39. package/node_modules/baileys/lib/Socket/socket.js.map +1 -1
  40. package/node_modules/baileys/lib/Types/index.d.ts +1 -0
  41. package/node_modules/baileys/lib/Types/index.d.ts.map +1 -1
  42. package/node_modules/baileys/lib/Types/index.js.map +1 -1
  43. package/node_modules/baileys/lib/Utils/browser-utils.d.ts.map +1 -1
  44. package/node_modules/baileys/lib/Utils/browser-utils.js +1 -0
  45. package/node_modules/baileys/lib/Utils/browser-utils.js.map +1 -1
  46. package/node_modules/baileys/lib/Utils/generics.d.ts +1 -0
  47. package/node_modules/baileys/lib/Utils/generics.d.ts.map +1 -1
  48. package/node_modules/baileys/lib/Utils/generics.js +1 -1
  49. package/node_modules/baileys/lib/Utils/generics.js.map +1 -1
  50. package/node_modules/baileys/lib/Utils/tc-token-utils.d.ts.map +1 -1
  51. package/node_modules/baileys/lib/Utils/tc-token-utils.js +3 -2
  52. package/node_modules/baileys/lib/Utils/tc-token-utils.js.map +1 -1
  53. package/node_modules/baileys/lib/Utils/validate-connection.d.ts.map +1 -1
  54. package/node_modules/baileys/lib/Utils/validate-connection.js +9 -2
  55. package/node_modules/baileys/lib/Utils/validate-connection.js.map +1 -1
  56. package/node_modules/baileys/node_modules/content-type/README.md +2 -0
  57. package/node_modules/baileys/node_modules/content-type/dist/index.d.ts +20 -0
  58. package/node_modules/baileys/node_modules/content-type/dist/index.js +20 -14
  59. package/node_modules/baileys/node_modules/content-type/dist/index.js.map +1 -1
  60. package/node_modules/baileys/node_modules/content-type/package.json +1 -1
  61. package/node_modules/baileys/node_modules/file-type/package.json +1 -1
  62. package/node_modules/baileys/node_modules/file-type/readme.md +3 -0
  63. package/node_modules/baileys/node_modules/file-type/source/detectors/zip.js +6 -1
  64. package/node_modules/baileys/node_modules/file-type/source/index.d.ts +3 -0
  65. package/node_modules/baileys/node_modules/file-type/source/index.js +25 -13
  66. package/node_modules/baileys/node_modules/music-metadata/LICENSE.txt +9 -9
  67. package/node_modules/baileys/node_modules/music-metadata/README.md +878 -878
  68. package/node_modules/baileys/node_modules/music-metadata/lib/ParseError.d.ts +1 -1
  69. package/node_modules/baileys/node_modules/music-metadata/lib/ParseError.js +1 -1
  70. package/node_modules/baileys/node_modules/music-metadata/lib/asf/AsfObject.d.ts +1 -4
  71. package/node_modules/baileys/node_modules/music-metadata/lib/asf/AsfObject.js +66 -30
  72. package/node_modules/baileys/node_modules/music-metadata/lib/asf/AsfParser.d.ts +5 -1
  73. package/node_modules/baileys/node_modules/music-metadata/lib/asf/AsfParser.js +94 -25
  74. package/node_modules/baileys/node_modules/music-metadata/lib/dsf/DsfChunk.js +2 -2
  75. package/node_modules/baileys/node_modules/music-metadata/lib/dsf/DsfParser.js +38 -13
  76. package/node_modules/baileys/node_modules/music-metadata/lib/mp4/AtomToken.js +2 -1
  77. package/node_modules/baileys/node_modules/music-metadata/lib/mp4/MP4Parser.js +34 -7
  78. package/node_modules/baileys/node_modules/music-metadata/lib/ogg/speex/SpeexStream.d.ts +7 -0
  79. package/node_modules/baileys/node_modules/music-metadata/lib/ogg/speex/SpeexStream.js +13 -0
  80. package/node_modules/baileys/node_modules/music-metadata/lib/riff/RiffChunk.js +1 -1
  81. package/node_modules/baileys/node_modules/music-metadata/package.json +156 -156
  82. package/node_modules/baileys/node_modules/protobufjs/README.md +61 -84
  83. package/node_modules/baileys/node_modules/protobufjs/dist/light/protobuf.js +66 -45
  84. package/node_modules/baileys/node_modules/protobufjs/dist/light/protobuf.js.map +1 -1
  85. package/node_modules/baileys/node_modules/protobufjs/dist/light/protobuf.min.js +3 -3
  86. package/node_modules/baileys/node_modules/protobufjs/dist/light/protobuf.min.js.map +1 -1
  87. package/node_modules/baileys/node_modules/protobufjs/dist/minimal/protobuf.js +47 -40
  88. package/node_modules/baileys/node_modules/protobufjs/dist/minimal/protobuf.js.map +1 -1
  89. package/node_modules/baileys/node_modules/protobufjs/dist/minimal/protobuf.min.js +3 -3
  90. package/node_modules/baileys/node_modules/protobufjs/dist/minimal/protobuf.min.js.map +1 -1
  91. package/node_modules/baileys/node_modules/protobufjs/dist/protobuf.js +92 -68
  92. package/node_modules/baileys/node_modules/protobufjs/dist/protobuf.js.map +1 -1
  93. package/node_modules/baileys/node_modules/protobufjs/dist/protobuf.min.js +3 -3
  94. package/node_modules/baileys/node_modules/protobufjs/dist/protobuf.min.js.map +1 -1
  95. package/node_modules/baileys/node_modules/protobufjs/ext/descriptor.js +26 -10
  96. package/node_modules/baileys/node_modules/protobufjs/index.d.ts +3 -0
  97. package/node_modules/baileys/node_modules/protobufjs/package.json +1 -1
  98. package/node_modules/baileys/node_modules/protobufjs/src/converter.js +5 -1
  99. package/node_modules/baileys/node_modules/protobufjs/src/enum.js +5 -2
  100. package/node_modules/baileys/node_modules/protobufjs/src/field.js +6 -1
  101. package/node_modules/baileys/node_modules/protobufjs/src/parse.js +26 -23
  102. package/node_modules/baileys/node_modules/protobufjs/src/reader.js +36 -9
  103. package/node_modules/baileys/node_modules/protobufjs/src/util/codegen.js +3 -1
  104. package/node_modules/baileys/node_modules/protobufjs/src/util/utf8.js +2 -28
  105. package/node_modules/baileys/node_modules/protobufjs/src/writer.js +7 -1
  106. package/node_modules/baileys/package.json +1 -1
  107. package/node_modules/typebox/build/format/date.d.mts +1 -1
  108. package/node_modules/typebox/build/format/date.mjs +1 -1
  109. package/node_modules/typebox/build/format/date_time.d.mts +2 -2
  110. package/node_modules/typebox/build/format/date_time.mjs +3 -3
  111. package/node_modules/typebox/build/format/email.d.mts +1 -1
  112. package/node_modules/typebox/build/format/email.mjs +2 -2
  113. package/node_modules/typebox/build/format/hostname.mjs +2 -10
  114. package/node_modules/typebox/build/format/idn_email.d.mts +1 -1
  115. package/node_modules/typebox/build/format/idn_email.mjs +3 -3
  116. package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -0
  117. package/node_modules/typebox/build/format/idn_hostname.mjs +3 -11
  118. package/node_modules/typebox/build/format/idna/format/bidi.d.mts +3 -0
  119. package/node_modules/typebox/build/format/idna/format/bidi.mjs +98 -0
  120. package/node_modules/typebox/build/format/idna/format/puny.d.mts +3 -0
  121. package/node_modules/typebox/build/format/idna/format/puny.mjs +144 -0
  122. package/node_modules/typebox/build/format/idna/hostname.d.mts +1 -0
  123. package/node_modules/typebox/build/format/idna/hostname.mjs +16 -0
  124. package/node_modules/typebox/build/format/idna/idn-hostname.d.mts +1 -0
  125. package/node_modules/typebox/build/format/idna/idn-hostname.mjs +23 -0
  126. package/node_modules/typebox/build/format/idna/index.d.mts +2 -0
  127. package/node_modules/typebox/build/format/idna/index.mjs +2 -0
  128. package/node_modules/typebox/build/format/idna/label/ascii.d.mts +1 -0
  129. package/node_modules/typebox/build/format/idna/label/ascii.mjs +9 -0
  130. package/node_modules/typebox/build/format/idna/label/puny.d.mts +1 -0
  131. package/node_modules/typebox/build/format/idna/label/puny.mjs +28 -0
  132. package/node_modules/typebox/build/format/idna/label/unicode.d.mts +1 -0
  133. package/node_modules/typebox/build/format/idna/label/unicode.mjs +106 -0
  134. package/node_modules/typebox/build/format/idna/pattern/pattern.d.mts +30 -0
  135. package/node_modules/typebox/build/format/idna/pattern/pattern.mjs +70 -0
  136. package/node_modules/typebox/build/format/ipv4.d.mts +0 -1
  137. package/node_modules/typebox/build/format/ipv4.mjs +2 -32
  138. package/node_modules/typebox/build/format/ipv6.mjs +2 -61
  139. package/node_modules/typebox/build/format/iri.d.mts +2 -2
  140. package/node_modules/typebox/build/format/iri.mjs +26 -8
  141. package/node_modules/typebox/build/format/iri_reference.d.mts +2 -2
  142. package/node_modules/typebox/build/format/iri_reference.mjs +9 -55
  143. package/node_modules/typebox/build/format/regex.d.mts +1 -2
  144. package/node_modules/typebox/build/format/regex.mjs +2 -6
  145. package/node_modules/typebox/build/format/time.d.mts +2 -2
  146. package/node_modules/typebox/build/format/time.mjs +19 -14
  147. package/node_modules/typebox/build/format/uri.d.mts +1 -1
  148. package/node_modules/typebox/build/format/uri.mjs +3 -130
  149. package/node_modules/typebox/build/format/uri_reference.d.mts +1 -1
  150. package/node_modules/typebox/build/format/uri_reference.mjs +2 -3
  151. package/node_modules/typebox/build/format/uri_template.d.mts +2 -3
  152. package/node_modules/typebox/build/format/uri_template.mjs +4 -5
  153. package/node_modules/typebox/build/format/url.d.mts +3 -3
  154. package/node_modules/typebox/build/format/url.mjs +4 -5
  155. package/node_modules/typebox/build/guard/emit.d.mts +3 -1
  156. package/node_modules/typebox/build/guard/emit.mjs +12 -5
  157. package/node_modules/typebox/build/guard/guard.d.mts +8 -2
  158. package/node_modules/typebox/build/guard/guard.mjs +25 -4
  159. package/node_modules/typebox/build/guard/string.d.mts +2 -2
  160. package/node_modules/typebox/build/guard/string.mjs +7 -7
  161. package/node_modules/typebox/build/schema/engine/_context.mjs +3 -3
  162. package/node_modules/typebox/build/schema/engine/_functions.mjs +1 -2
  163. package/node_modules/typebox/build/schema/engine/_regexp.d.mts +2 -0
  164. package/node_modules/typebox/build/schema/engine/_regexp.mjs +4 -0
  165. package/node_modules/typebox/build/schema/engine/_stack.mjs +12 -13
  166. package/node_modules/typebox/build/schema/engine/additionalItems.mjs +17 -7
  167. package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +4 -3
  168. package/node_modules/typebox/build/schema/engine/contains.mjs +18 -6
  169. package/node_modules/typebox/build/schema/engine/enum.mjs +1 -1
  170. package/node_modules/typebox/build/schema/engine/items.mjs +26 -6
  171. package/node_modules/typebox/build/schema/engine/maxContains.mjs +3 -3
  172. package/node_modules/typebox/build/schema/engine/minContains.mjs +14 -4
  173. package/node_modules/typebox/build/schema/engine/not.mjs +4 -2
  174. package/node_modules/typebox/build/schema/engine/oneOf.mjs +7 -6
  175. package/node_modules/typebox/build/schema/engine/pattern.mjs +3 -2
  176. package/node_modules/typebox/build/schema/engine/patternProperties.mjs +4 -3
  177. package/node_modules/typebox/build/schema/engine/ref.mjs +1 -7
  178. package/node_modules/typebox/build/schema/engine/schema.mjs +13 -4
  179. package/node_modules/typebox/build/schema/engine/type.mjs +1 -1
  180. package/node_modules/typebox/build/schema/resolve/resolve.d.mts +4 -1
  181. package/node_modules/typebox/build/schema/resolve/resolve.mjs +202 -1
  182. package/node_modules/typebox/build/schema/static/propertyNames.d.mts +5 -0
  183. package/node_modules/typebox/build/schema/static/propertyNames.mjs +3 -0
  184. package/node_modules/typebox/build/schema/static/schema.d.mts +3 -0
  185. package/node_modules/typebox/build/schema/types/index.d.mts +0 -2
  186. package/node_modules/typebox/build/schema/types/index.mjs +0 -2
  187. package/node_modules/typebox/build/system/memory/clone.mjs +14 -11
  188. package/node_modules/typebox/build/system/memory/discard.mjs +6 -5
  189. package/node_modules/typebox/build/system/settings/settings.d.mts +9 -0
  190. package/node_modules/typebox/build/system/settings/settings.mjs +2 -0
  191. package/node_modules/typebox/build/type/engine/call/distribute_arguments.d.mts +6 -1
  192. package/node_modules/typebox/build/type/engine/call/distribute_arguments.mjs +16 -3
  193. package/node_modules/typebox/build/type/engine/call/instantiate.mjs +34 -4
  194. package/node_modules/typebox/build/type/engine/evaluate/broaden.d.mts +5 -5
  195. package/node_modules/typebox/build/type/engine/evaluate/broaden.mjs +20 -26
  196. package/node_modules/typebox/build/type/engine/evaluate/compare.d.mts +6 -10
  197. package/node_modules/typebox/build/type/engine/evaluate/compare.mjs +9 -13
  198. package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +7 -4
  199. package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +12 -19
  200. package/node_modules/typebox/build/type/engine/evaluate/distribute.d.mts +4 -20
  201. package/node_modules/typebox/build/type/engine/evaluate/distribute.mjs +8 -20
  202. package/node_modules/typebox/build/type/engine/evaluate/evaluate.d.mts +4 -4
  203. package/node_modules/typebox/build/type/engine/evaluate/evaluate.mjs +11 -8
  204. package/node_modules/typebox/build/type/engine/evaluate/flatten.d.mts +1 -1
  205. package/node_modules/typebox/build/type/engine/evaluate/flatten.mjs +3 -4
  206. package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +17 -2
  207. package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +26 -6
  208. package/node_modules/typebox/build/type/engine/exclude/operation.mjs +3 -4
  209. package/node_modules/typebox/build/type/engine/extract/operation.d.mts +1 -1
  210. package/node_modules/typebox/build/type/engine/extract/operation.mjs +3 -4
  211. package/node_modules/typebox/build/type/engine/priority/priority.d.mts +2 -2
  212. package/node_modules/typebox/build/type/engine/priority/priority.mjs +3 -4
  213. package/node_modules/typebox/build/type/script/mapping.d.mts +32 -29
  214. package/node_modules/typebox/build/type/script/mapping.mjs +18 -25
  215. package/node_modules/typebox/build/type/script/parser.d.mts +19 -25
  216. package/node_modules/typebox/build/type/script/parser.mjs +27 -23
  217. package/node_modules/typebox/build/value/errors/errors.d.mts +2 -2
  218. package/node_modules/typebox/build/value/errors/errors.mjs +1 -1
  219. package/node_modules/typebox/package.json +27 -27
  220. package/node_modules/typebox/readme.md +79 -82
  221. package/openclaw.plugin.json +2 -1
  222. package/package.json +6 -6
  223. package/node_modules/typebox/build/format/_idna.d.mts +0 -2
  224. package/node_modules/typebox/build/format/_idna.mjs +0 -246
  225. package/node_modules/typebox/build/format/_puny.d.mts +0 -1
  226. package/node_modules/typebox/build/format/_puny.mjs +0 -77
  227. package/node_modules/typebox/build/schema/resolve/ref.d.mts +0 -3
  228. package/node_modules/typebox/build/schema/resolve/ref.mjs +0 -146
  229. package/node_modules/typebox/build/schema/types/contentEncoding.d.mts +0 -9
  230. package/node_modules/typebox/build/schema/types/contentEncoding.mjs +0 -13
  231. package/node_modules/typebox/build/schema/types/contentMediaType.d.mts +0 -9
  232. package/node_modules/typebox/build/schema/types/contentMediaType.mjs +0 -13
@@ -1,6 +1,6 @@
1
1
  import { a as resolveWhatsAppAccount } from "./accounts-BX2fZUyR.js";
2
2
  import { t as resolveWhatsAppOutboundTarget } from "./resolve-outbound-target-1GqbT1uX.js";
3
- import { r as sendReactionWhatsApp, v as resolveWhatsAppReactionLevel } from "./send-CwvTU4RI.js";
3
+ import { r as sendReactionWhatsApp, v as resolveWhatsAppReactionLevel } from "./send-DLMUc2uZ.js";
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) {
@@ -1,2 +1,2 @@
1
- import { t as handleWhatsAppAction } from "./action-runtime-pM-ExU0l.js";
1
+ import { t as handleWhatsAppAction } from "./action-runtime-C075e6OP.js";
2
2
  export { handleWhatsAppAction };
@@ -1,2 +1,2 @@
1
- import { t as handleWhatsAppAction } from "./action-runtime-pM-ExU0l.js";
1
+ import { t as handleWhatsAppAction } from "./action-runtime-C075e6OP.js";
2
2
  export { handleWhatsAppAction };
@@ -1,17 +1,18 @@
1
1
  import { a as resolveWhatsAppAccount } from "./accounts-BX2fZUyR.js";
2
2
  import { r as getWhatsAppConnectionController } from "./connection-controller-runtime-context-DG0tuYuw.js";
3
3
  import { s as resolveJidToE164 } from "./targets-runtime-TMk0lGuy.js";
4
+ import { n as registerWhatsAppLoginTool } from "./agent-tools-login-B-2qZPzc.js";
4
5
  import { createActionGate, stringEnum } from "openclaw/plugin-sdk/channel-actions";
5
6
  import path from "node:path";
6
7
  import { resolveOAuthDir } from "openclaw/plugin-sdk/state-paths";
7
8
  import { normalizeE164 } from "openclaw/plugin-sdk/account-resolution";
8
- import { normalizeAccountId } from "openclaw/plugin-sdk/account-id";
9
- import { Type } from "typebox";
10
9
  import fs from "node:fs/promises";
10
+ import { normalizeAccountId } from "openclaw/plugin-sdk/account-id";
11
11
  import { mulawToPcm } from "openclaw/plugin-sdk/realtime-voice";
12
12
  import { detectBinary } from "openclaw/plugin-sdk/setup-tools";
13
13
  import { resolvePreferredOpenClawTmpDir } from "openclaw/plugin-sdk/temp-path";
14
14
  import { jsonResult as jsonResult$1 } from "openclaw/plugin-sdk/tool-results";
15
+ import { Type } from "typebox";
15
16
  //#region extensions/whatsapp/src/agent-tools-call.ts
16
17
  const MEOWCALLER_COMMAND = "meowcaller";
17
18
  const SESSION_DATABASE = "wa-voip.db";
@@ -222,4 +223,10 @@ function registerWhatsAppCallTool(api) {
222
223
  api.registerTool((context) => createWhatsAppCallTool(api, context), { name: "whatsapp_call" });
223
224
  }
224
225
  //#endregion
225
- export { registerWhatsAppCallTool };
226
+ //#region extensions/whatsapp/agent-tools-api.ts
227
+ function registerWhatsAppAgentTools(api) {
228
+ registerWhatsAppCallTool(api);
229
+ registerWhatsAppLoginTool(api);
230
+ }
231
+ //#endregion
232
+ export { registerWhatsAppAgentTools };
@@ -8,7 +8,8 @@ const QR_DATA_URL_MAX_LENGTH = 16384;
8
8
  function readLoginStringPreservingWhitespace(value) {
9
9
  return hasNonEmptyString(value) ? value : void 0;
10
10
  }
11
- function createWhatsAppLoginTool() {
11
+ function createWhatsAppLoginTool(context) {
12
+ if (context.senderIsOwner !== true) return null;
12
13
  return {
13
14
  label: "WhatsApp Login",
14
15
  name: "whatsapp_login",
@@ -23,7 +24,10 @@ function createWhatsAppLoginTool() {
23
24
  pattern: "^data:image/png;base64,.+$"
24
25
  }))
25
26
  }),
26
- execute: async (_toolCallId, args) => {
27
+ execute: async (_toolCallId, args, signal) => {
28
+ const beforeCredentialPersistence = async () => {
29
+ if (!signal || signal.aborted) throw new Error("WhatsApp login authority is no longer active.");
30
+ };
27
31
  const renderQrReply = (params) => {
28
32
  return {
29
33
  content: [{
@@ -64,9 +68,11 @@ function createWhatsAppLoginTool() {
64
68
  details: { connected: result.connected }
65
69
  };
66
70
  }
71
+ await beforeCredentialPersistence();
67
72
  const result = await startWebLoginWithQr({
68
73
  accountId,
69
74
  timeoutMs,
75
+ beforeCredentialPersistence,
70
76
  force: typeof args.force === "boolean" ? args.force : false
71
77
  });
72
78
  if (!result.qrDataUrl) return {
@@ -84,5 +90,8 @@ function createWhatsAppLoginTool() {
84
90
  }
85
91
  };
86
92
  }
93
+ function registerWhatsAppLoginTool(api) {
94
+ api.registerTool((context) => createWhatsAppLoginTool(context), { name: "whatsapp_login" });
95
+ }
87
96
  //#endregion
88
- export { createWhatsAppLoginTool as t };
97
+ export { registerWhatsAppLoginTool as n, createWhatsAppLoginTool as t };
package/dist/api.js CHANGED
@@ -4,15 +4,15 @@ import { a as normalizeWhatsAppAllowFromEntries, c as normalizeWhatsAppTarget, i
4
4
  import { t as resolveWhatsAppOutboundTarget } from "./resolve-outbound-target-1GqbT1uX.js";
5
5
  import { c as toWhatsappJid, i as markdownToWhatsApp, l as toWhatsappJidWithLid, n as isSelfChatMode, r as jidToE164, s as resolveJidToE164, t as assertWebChannel } from "./targets-runtime-TMk0lGuy.js";
6
6
  import { n as resolveUserPath, t as normalizeE164 } from "./text-runtime-CaKLhowd.js";
7
- import { n as WHATSAPP_LEGACY_OUTBOUND_SEND_DEP_KEYS, t as whatsappPlugin } from "./channel-DRMYRfZ8.js";
8
- import { a as resolveWhatsAppGroupRequireMention, o as resolveWhatsAppGroupToolPolicy } from "./shared-wg42NKFB.js";
7
+ import { n as WHATSAPP_LEGACY_OUTBOUND_SEND_DEP_KEYS, t as whatsappPlugin } from "./channel-C4FMOZTE.js";
8
+ import { a as resolveWhatsAppGroupRequireMention, o as resolveWhatsAppGroupToolPolicy } from "./shared-BekHi69d.js";
9
9
  import { t as whatsappCommandPolicy } from "./command-policy-BIOSHySD.js";
10
- import { t as whatsappSetupPlugin } from "./channel.setup-DhBBhbQv.js";
10
+ import { t as whatsappSetupPlugin } from "./channel.setup-CGcBvnpP.js";
11
11
  import { t as DEFAULT_WEB_MEDIA_BYTES } from "./constants-HU41RHGI.js";
12
12
  import { a as waitForWaConnection, o as DEFAULT_WHATSAPP_SOCKET_TIMING, r as createWaSocket, s as createWhatsAppSocketOperationTimeoutAdapter } from "./socket-close-2T0_jZTN.js";
13
13
  import { n as getStatusCode, t as formatError } from "./session-errors-JuazczrA.js";
14
14
  import { n as listWhatsAppDirectoryGroupsFromConfig, r as listWhatsAppDirectoryPeersFromConfig } from "./directory-config-P7_3U73Z.js";
15
- import { _ as resolveInboundMediaMimetype, c as extractContextInfo, m as findMessageSection, o as describeReplyContext, p as extractText, t as createWebSendApi, u as extractLocationData } from "./send-api-obOSm2cC.js";
15
+ import { _ as resolveInboundMediaMimetype, c as extractContextInfo, m as findMessageSection, o as describeReplyContext, p as extractText, t as createWebSendApi, u as extractLocationData } from "./send-api-BtK45TmZ.js";
16
16
  import { asBoolean, isRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
17
17
  import { formatLocationText } from "openclaw/plugin-sdk/channel-inbound";
18
18
  //#region extensions/whatsapp/src/qa-driver.runtime.ts
@@ -1,7 +1,7 @@
1
1
  import "./accounts-BX2fZUyR.js";
2
2
  import { r as resolveDefaultWhatsAppAccountId } from "./account-ids-CB5SOWjc.js";
3
3
  import { s as normalizeWhatsAppMessagingTarget } from "./normalize-target-CugRyONv.js";
4
- import { i as sendTypingWhatsApp, t as sendMessageWhatsApp } from "./send-CwvTU4RI.js";
4
+ import { i as sendTypingWhatsApp, t as sendMessageWhatsApp } from "./send-DLMUc2uZ.js";
5
5
  import { i as getWhatsAppRuntime } from "./runtime-BLlToOi6.js";
6
6
  import "./normalize-C7Hkc_vE.js";
7
7
  import { i as unregisterWhatsAppApprovalReactionTarget, r as registerWhatsAppApprovalReactionTarget } from "./approval-reactions-Jyr1JaAK.js";
@@ -2,14 +2,13 @@ import { a as resolveWhatsAppAccount } from "./accounts-BX2fZUyR.js";
2
2
  import { r as resolveDefaultWhatsAppAccountId, t as listAccountIds } from "./account-ids-CB5SOWjc.js";
3
3
  import { c as normalizeWhatsAppTarget, i as looksLikeWhatsAppTargetId, n as isWhatsAppNewsletterJid, o as normalizeWhatsAppAllowFromEntry, s as normalizeWhatsAppMessagingTarget, t as isWhatsAppGroupJid } from "./normalize-target-CugRyONv.js";
4
4
  import { t as resolveWhatsAppOutboundTarget } from "./resolve-outbound-target-1GqbT1uX.js";
5
- import { c as normalizeWhatsAppPayloadTextPreservingIndentation, i as sendTypingWhatsApp, n as sendPollWhatsApp, o as normalizeWhatsAppOutboundPayload, s as normalizeWhatsAppPayloadText, t as sendMessageWhatsApp, v as resolveWhatsAppReactionLevel } from "./send-CwvTU4RI.js";
5
+ import { c as normalizeWhatsAppPayloadTextPreservingIndentation, i as sendTypingWhatsApp, n as sendPollWhatsApp, o as normalizeWhatsAppOutboundPayload, s as normalizeWhatsAppPayloadText, t as sendMessageWhatsApp, v as resolveWhatsAppReactionLevel } from "./send-DLMUc2uZ.js";
6
6
  import { i as getWhatsAppRuntime } from "./runtime-BLlToOi6.js";
7
7
  import "./normalize-C7Hkc_vE.js";
8
8
  import { c as toWhatsappJid } from "./targets-runtime-TMk0lGuy.js";
9
9
  import "./text-runtime-CaKLhowd.js";
10
- import { t as createWhatsAppLoginTool } from "./agent-tools-login-BjRpD-JQ.js";
11
10
  import { c as getWhatsAppApprovalApprovers, l as whatsappApprovalAuth, s as lookupInboundMessageMetaForTarget, t as resolveWhatsAppGroupSessionKey } from "./group-session-key-DmFc_Cqi.js";
12
- import { a as resolveWhatsAppGroupRequireMention, c as loadWhatsAppChannelRuntime, i as whatsappSetupContract, l as readWhatsAppAccountLinkState, n as whatsappSetupWizardProxy, o as resolveWhatsAppGroupToolPolicy, s as formatWhatsAppConfigAllowFromEntries, t as createWhatsAppPluginBase } from "./shared-wg42NKFB.js";
11
+ import { a as resolveWhatsAppGroupRequireMention, c as loadWhatsAppChannelRuntime, i as whatsappSetupContract, l as readWhatsAppAccountLinkState, n as whatsappSetupWizardProxy, o as resolveWhatsAppGroupToolPolicy, s as formatWhatsAppConfigAllowFromEntries, t as createWhatsAppPluginBase } from "./shared-BekHi69d.js";
13
12
  import { t as whatsappCommandPolicy } from "./command-policy-BIOSHySD.js";
14
13
  import { f as readWebAuthExistsForDecision, n as WHATSAPP_AUTH_UNSTABLE_CODE } from "./auth-store-CtpBqH5S.js";
15
14
  import { createActionGate as createActionGate$1 } from "openclaw/plugin-sdk/channel-actions";
@@ -22,9 +21,9 @@ import { chunkText } from "openclaw/plugin-sdk/reply-chunking";
22
21
  import { createMessageReceiptFromOutboundResults, defineChannelMessageAdapter, resolveOutboundSendDep } from "openclaw/plugin-sdk/channel-outbound";
23
22
  import { sendTextMediaPayload } from "openclaw/plugin-sdk/reply-payload";
24
23
  import { DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID$1 } from "openclaw/plugin-sdk/account-id";
24
+ import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
25
25
  import { buildDmGroupAccountAllowlistAdapter } from "openclaw/plugin-sdk/allowlist-config-edit";
26
26
  import { createChatChannelPlugin } from "openclaw/plugin-sdk/channel-core";
27
- import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
28
27
  import { createApproverRestrictedNativeApprovalCapabilityFromForwardingRoutes } from "openclaw/plugin-sdk/approval-delivery-runtime";
29
28
  import { createLazyChannelApprovalNativeRuntimeAdapter } from "openclaw/plugin-sdk/approval-handler-adapter-runtime";
30
29
  import { buildApprovalReactionPromptPayloadForRequest } from "openclaw/plugin-sdk/approval-reaction-runtime";
@@ -80,7 +79,7 @@ const whatsappApproval = createApproverRestrictedNativeApprovalCapabilityFromFor
80
79
  approvalKind,
81
80
  request
82
81
  }),
83
- load: async () => (await import("./approval-handler.runtime-CkMMvUjk.js")).whatsappApprovalNativeRuntime
82
+ load: async () => (await import("./approval-handler.runtime-CljxfPJz.js")).whatsappApprovalNativeRuntime
84
83
  })
85
84
  });
86
85
  function buildWhatsAppPendingPayload(params, approvalKind) {
@@ -526,7 +525,7 @@ function collectWhatsAppStatusIssues(accounts) {
526
525
  //#endregion
527
526
  //#region extensions/whatsapp/src/channel.ts
528
527
  const loadWhatsAppDirectoryConfig = createLazyRuntimeModule(() => import("./directory-config-P7_3U73Z.js").then((n) => n.t));
529
- const loadWhatsAppChannelReactAction = createLazyRuntimeModule(() => import("./channel-react-action-CstrR0CT.js"));
528
+ const loadWhatsAppChannelReactAction = createLazyRuntimeModule(() => import("./channel-react-action-Bhp2BYRr.js"));
530
529
  function resolveWhatsAppTargetInfo(raw) {
531
530
  const normalized = normalizeWhatsAppTarget(raw);
532
531
  if (!normalized) return null;
@@ -563,7 +562,6 @@ const whatsappPlugin = createChatChannelPlugin({
563
562
  isConfigured: (account) => Boolean(account.authDir),
564
563
  isLinked: async (account) => await readWhatsAppAccountLinkState(account.authDir)
565
564
  }),
566
- agentTools: () => [createWhatsAppLoginTool()],
567
565
  allowlist: buildDmGroupAccountAllowlistAdapter({
568
566
  channelId: "whatsapp",
569
567
  resolveAccount: resolveWhatsAppAccount,
@@ -1,2 +1,2 @@
1
- import { t as whatsappPlugin } from "./channel-DRMYRfZ8.js";
1
+ import { t as whatsappPlugin } from "./channel-C4FMOZTE.js";
2
2
  export { whatsappPlugin };
@@ -1,7 +1,7 @@
1
1
  import { a as resolveWhatsAppAccount, s as resolveWhatsAppMediaMaxBytes } from "./accounts-BX2fZUyR.js";
2
2
  import { c as normalizeWhatsAppTarget, t as isWhatsAppGroupJid } from "./normalize-target-CugRyONv.js";
3
- import { r as resolveAuthorizedWhatsAppOutboundTarget, t as handleWhatsAppAction } from "./action-runtime-pM-ExU0l.js";
4
- import { a as sendWhatsAppUploadFile } from "./send-CwvTU4RI.js";
3
+ import { r as resolveAuthorizedWhatsAppOutboundTarget, t as handleWhatsAppAction } from "./action-runtime-C075e6OP.js";
4
+ import { a as sendWhatsAppUploadFile } from "./send-DLMUc2uZ.js";
5
5
  import "./normalize-C7Hkc_vE.js";
6
6
  import { jsonResult, readStringOrNumberParam, readStringParam as readStringParam$1, resolveReactionMessageId } from "openclaw/plugin-sdk/channel-actions";
7
7
  import { canonicalizeBase64, estimateBase64DecodedBytes } from "openclaw/plugin-sdk/media-runtime";
@@ -1,9 +1,9 @@
1
1
  import { startWebLoginWithQr as startWebLoginWithQr$1, waitForWebLogin as waitForWebLogin$1 } from "./login-qr-runtime.js";
2
2
  import { c as logoutWeb$1, d as readWebAuthExistsBestEffort$1, f as readWebAuthExistsForDecision$1, g as readWebSelfId$1, h as readWebAuthState$1, m as readWebAuthSnapshotBestEffort$1, o as getWebAuthAgeMs$1, p as readWebAuthSnapshot$1, s as logWebSelfId$1, x as webAuthExists$1 } from "./auth-store-CtpBqH5S.js";
3
3
  import { t as getActiveWebListener$1 } from "./active-listener-BEjWsCNM.js";
4
- import { t as monitorWebChannel$1 } from "./monitor-IzwQKizW.js";
4
+ import { t as monitorWebChannel$1 } from "./monitor-C_Nw23PZ.js";
5
5
  import { t as loginWeb$1 } from "./login-BkpKpndm.js";
6
- import { whatsappSetupWizard as whatsappSetupWizard$1 } from "./setup-surface-Cwn3zyxK.js";
6
+ import { whatsappSetupWizard as whatsappSetupWizard$1 } from "./setup-surface-CjjqIxQP.js";
7
7
  //#region extensions/whatsapp/src/channel.runtime.ts
8
8
  function getActiveWebListener(...args) {
9
9
  return getActiveWebListener$1(...args);
@@ -1,4 +1,4 @@
1
- import { a as resolveWhatsAppGroupRequireMention, i as whatsappSetupContract, l as readWhatsAppAccountLinkState, n as whatsappSetupWizardProxy, o as resolveWhatsAppGroupToolPolicy, t as createWhatsAppPluginBase } from "./shared-wg42NKFB.js";
1
+ import { a as resolveWhatsAppGroupRequireMention, i as whatsappSetupContract, l as readWhatsAppAccountLinkState, n as whatsappSetupWizardProxy, o as resolveWhatsAppGroupToolPolicy, t as createWhatsAppPluginBase } from "./shared-BekHi69d.js";
2
2
  //#region extensions/whatsapp/src/channel.setup.ts
3
3
  const whatsappSetupPlugin = { ...createWhatsAppPluginBase({
4
4
  groups: {
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { defineBundledChannelEntry, loadBundledEntryExportSync } from "openclaw/plugin-sdk/channel-entry-contract";
2
2
  //#region extensions/whatsapp/index.ts
3
- function registerWhatsAppCallTool(api) {
3
+ function registerWhatsAppAgentTools(api) {
4
4
  loadBundledEntryExportSync(import.meta.url, {
5
- specifier: "./call-tool-api.js",
6
- exportName: "registerWhatsAppCallTool"
5
+ specifier: "./agent-tools-api.js",
6
+ exportName: "registerWhatsAppAgentTools"
7
7
  })(api);
8
8
  }
9
9
  var whatsapp_default = defineBundledChannelEntry({
@@ -19,7 +19,7 @@ var whatsapp_default = defineBundledChannelEntry({
19
19
  specifier: "./runtime-setter-api.js",
20
20
  exportName: "setWhatsAppRuntime"
21
21
  },
22
- registerFull: registerWhatsAppCallTool
22
+ registerFull: registerWhatsAppAgentTools
23
23
  });
24
24
  //#endregion
25
25
  export { whatsapp_default as default };
@@ -1,4 +1,4 @@
1
- import { t as createWhatsAppLoginTool } from "./agent-tools-login-BjRpD-JQ.js";
1
+ import { t as createWhatsAppLoginTool } from "./agent-tools-login-B-2qZPzc.js";
2
2
  import { c as logoutWeb, g as readWebSelfId, l as pickWebChannel, o as getWebAuthAgeMs, s as logWebSelfId, t as WA_WEB_AUTH_DIR, x as webAuthExists, y as resolveDefaultWebAuthDir } from "./auth-store-CtpBqH5S.js";
3
3
  import { t as getActiveWebListener } from "./active-listener-BEjWsCNM.js";
4
4
  import { n as getStatusCode, t as formatError } from "./session-errors-JuazczrA.js";
@@ -28,8 +28,8 @@ function closeSocket(sock) {
28
28
  async function resetActiveLogin(accountId, reason) {
29
29
  const login = activeLogins.get(accountId);
30
30
  if (login) {
31
- closeSocket(login.sock);
32
31
  activeLogins.delete(accountId);
32
+ closeSocket(login.sock);
33
33
  }
34
34
  if (reason) logInfo(reason);
35
35
  }
@@ -94,6 +94,7 @@ function attachLoginWaiter(accountId, login) {
94
94
  verbose: login.verbose,
95
95
  runtime: login.runtime,
96
96
  socketTiming: login.socketTiming,
97
+ beforeCredentialPersistence: login.beforeCredentialPersistence,
97
98
  onQr: (qr) => {
98
99
  const current = activeLogins.get(accountId);
99
100
  if (!current || current.id !== login.id) return;
@@ -203,7 +204,8 @@ async function startWebLoginWithQr(opts = {}) {
203
204
  if (!await logoutWeb({
204
205
  authDir: account.authDir,
205
206
  isLegacyAuthDir: account.isLegacyAuthDir,
206
- runtime
207
+ runtime,
208
+ beforeCredentialPersistence: opts.beforeCredentialPersistence
207
209
  })) return { message: "WhatsApp login failed: existing auth could not be cleared. Remove or fix the configured WhatsApp auth directory, then retry login." };
208
210
  } catch (err) {
209
211
  return { message: `WhatsApp login failed: ${formatError(err)}` };
@@ -226,10 +228,20 @@ async function startWebLoginWithQr(opts = {}) {
226
228
  let sock;
227
229
  let pendingQr = null;
228
230
  const loginId = randomUUID();
231
+ const operationOwner = {};
232
+ const beforeCredentialPersistence = async () => {
233
+ const login = operationOwner.current;
234
+ if (!login) {
235
+ await opts.beforeCredentialPersistence?.();
236
+ return;
237
+ }
238
+ if (activeLogins.get(account.accountId) !== login || !isLoginFresh(login)) throw new Error("WhatsApp login is no longer active.");
239
+ };
229
240
  try {
230
241
  sock = await createWaSocket(false, Boolean(opts.verbose), {
231
242
  authDir: account.authDir,
232
243
  ...socketTiming,
244
+ beforeCredentialPersistence,
233
245
  onQr: (qr) => {
234
246
  pendingQr = qr;
235
247
  const current = activeLogins.get(account.accountId);
@@ -256,7 +268,7 @@ async function startWebLoginWithQr(opts = {}) {
256
268
  await resetActiveLogin(account.accountId);
257
269
  return { message: `Failed to start WhatsApp login: ${String(err)}` };
258
270
  }
259
- const login = {
271
+ const nextLogin = {
260
272
  accountId: account.accountId,
261
273
  authDir: account.authDir,
262
274
  isLegacyAuthDir: account.isLegacyAuthDir,
@@ -271,23 +283,32 @@ async function startWebLoginWithQr(opts = {}) {
271
283
  qrRenderPromise: null,
272
284
  verbose: Boolean(opts.verbose),
273
285
  runtime,
274
- socketTiming
286
+ socketTiming,
287
+ beforeCredentialPersistence
275
288
  };
276
- resetQrUpdateSignal(login);
277
- activeLogins.set(account.accountId, login);
289
+ try {
290
+ await opts.beforeCredentialPersistence?.();
291
+ } catch (err) {
292
+ clearTimeout(qrTimer);
293
+ closeSocket(sock);
294
+ return { message: `Failed to start WhatsApp login: ${String(err)}` };
295
+ }
296
+ operationOwner.current = nextLogin;
297
+ resetQrUpdateSignal(nextLogin);
298
+ activeLogins.set(account.accountId, nextLogin);
278
299
  if (pendingQr) {
279
- const qrVersion = updateLoginQrState(login, pendingQr);
300
+ const qrVersion = updateLoginQrState(nextLogin, pendingQr);
280
301
  renderLatestQrDataUrlInBackground({
281
302
  accountId: account.accountId,
282
- loginId: login.id,
303
+ loginId: nextLogin.id,
283
304
  qr: pendingQr,
284
305
  qrVersion
285
306
  });
286
307
  }
287
- attachLoginWaiter(account.accountId, login);
308
+ attachLoginWaiter(account.accountId, nextLogin);
288
309
  const loginStartResult = await waitForQrOrRecoveredLogin({
289
310
  accountId: account.accountId,
290
- login,
311
+ login: nextLogin,
291
312
  qrPromise
292
313
  });
293
314
  clearTimeout(qrTimer);
@@ -304,8 +325,8 @@ async function startWebLoginWithQr(opts = {}) {
304
325
  await resetActiveLogin(account.accountId);
305
326
  return { message: loginStartResult.message };
306
327
  }
307
- const qr = login.qr ?? loginStartResult.qr;
308
- const qrVersion = login.qrVersion;
328
+ const qr = nextLogin.qr ?? loginStartResult.qr;
329
+ const qrVersion = nextLogin.qrVersion;
309
330
  if (qrVersion === 0) {
310
331
  await resetActiveLogin(account.accountId);
311
332
  return { message: "Failed to capture the active WhatsApp QR. Ask me to generate a new one." };
@@ -314,7 +335,7 @@ async function startWebLoginWithQr(opts = {}) {
314
335
  try {
315
336
  qrDataUrl = await ensureQrDataUrl({
316
337
  accountId: account.accountId,
317
- loginId: login.id,
338
+ loginId: nextLogin.id,
318
339
  qr,
319
340
  qrVersion
320
341
  });
@@ -1,6 +1,6 @@
1
1
  import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
2
2
  //#region extensions/whatsapp/login-qr-runtime.ts
3
- const loadLoginQrModule = createLazyRuntimeModule(() => import("./login-qr-1dpv6jjT.js"));
3
+ const loadLoginQrModule = createLazyRuntimeModule(() => import("./login-qr-DY4VFgOq.js"));
4
4
  async function startWebLoginWithQr(...args) {
5
5
  const { startWebLoginWithQr: startWebLoginWithQrLocal } = await loadLoginQrModule();
6
6
  return await startWebLoginWithQrLocal(...args);
@@ -1,5 +1,5 @@
1
1
  import { a as resolveWhatsAppAccount, s as resolveWhatsAppMediaMaxBytes } from "./accounts-BX2fZUyR.js";
2
- import { c as normalizeWhatsAppPayloadTextPreservingIndentation, d as listWhatsAppSendResultMessageIds, f as mergeWhatsAppAcceptedSendError, g as withWhatsAppLogicalDeliveryActivity, h as rememberWhatsAppPartialSend, l as prepareWhatsAppOutboundMedia, m as rememberWhatsAppAcceptedSend, o as normalizeWhatsAppOutboundPayload, p as normalizeWhatsAppSendResult, r as sendReactionWhatsApp, v as resolveWhatsAppReactionLevel } from "./send-CwvTU4RI.js";
2
+ import { c as normalizeWhatsAppPayloadTextPreservingIndentation, d as listWhatsAppSendResultMessageIds, f as mergeWhatsAppAcceptedSendError, g as withWhatsAppLogicalDeliveryActivity, h as rememberWhatsAppPartialSend, l as prepareWhatsAppOutboundMedia, m as rememberWhatsAppAcceptedSend, o as normalizeWhatsAppOutboundPayload, p as normalizeWhatsAppSendResult, r as sendReactionWhatsApp, v as resolveWhatsAppReactionLevel } from "./send-DLMUc2uZ.js";
3
3
  import { i as getWhatsAppRuntime } from "./runtime-BLlToOi6.js";
4
4
  import { r as getWhatsAppConnectionController } from "./connection-controller-runtime-context-DG0tuYuw.js";
5
5
  import { a as markdownToWhatsAppChunks, c as toWhatsappJid, l as toWhatsappJidWithLid, n as isSelfChatMode, o as resolveEquivalentWhatsAppDirectChatJids, r as jidToE164, s as resolveJidToE164 } from "./targets-runtime-TMk0lGuy.js";
@@ -10,7 +10,7 @@ import { n as resolveWhatsAppGroupsConfigPath } from "./group-config-path-BGyzT9
10
10
  import { a as waitForWaConnection, c as isWhatsAppSocketOperationTimeoutError, d as withWhatsAppSocketOperationTimeout, l as resolveWhatsAppSocketOperationTimeoutMs, r as createWaSocket, s as createWhatsAppSocketOperationTimeoutAdapter, u as resolveWhatsAppSocketTiming } from "./socket-close-2T0_jZTN.js";
11
11
  import { n as getStatusCode, t as formatError } from "./session-errors-JuazczrA.js";
12
12
  import { t as BufferJSON } from "./session.runtime-Nsqaehbd.js";
13
- import { _ as resolveInboundMediaMimetype, a as addWhatsAppImagePreviewFields, c as extractContextInfo, d as extractMediaKind, f as extractMentionedJids, g as projectWhatsAppInboundMessage, h as hasInboundUserContent, i as resolveWhatsAppOutboundMentions, l as extractExternalAdReplyContext, n as addWhatsAppOutboundMentionsToContent, o as describeReplyContext, p as extractText, r as mayContainWhatsAppOutboundMention, s as extractContactContext, t as createWebSendApi, u as extractLocationData } from "./send-api-obOSm2cC.js";
13
+ import { _ as resolveInboundMediaMimetype, a as addWhatsAppImagePreviewFields, c as extractContextInfo, d as extractMediaKind, f as extractMentionedJids, g as projectWhatsAppInboundMessage, h as hasInboundUserContent, i as resolveWhatsAppOutboundMentions, l as extractExternalAdReplyContext, n as addWhatsAppOutboundMentionsToContent, o as describeReplyContext, p as extractText, r as mayContainWhatsAppOutboundMention, s as extractContactContext, t as createWebSendApi, u as extractLocationData } from "./send-api-BtK45TmZ.js";
14
14
  import { t as resolveWhatsAppRuntimeGroupPolicy } from "./runtime-group-policy-DeSRFXEV.js";
15
15
  import { c as computeBackoff, d as resolveReconnectPolicy, f as sleepWithAbort, l as newConnectionId, n as WHATSAPP_WATCHDOG_TIMEOUT_ERROR, r as WhatsAppConnectionController, s as DEFAULT_RECONNECT_POLICY, u as resolveHeartbeatSeconds } from "./connection-controller-CIYuBJrs.js";
16
16
  import { n as maybeResolveWhatsAppApprovalReaction } from "./approval-reactions-Jyr1JaAK.js";
@@ -28,7 +28,7 @@ import { recordChannelActivity } from "openclaw/plugin-sdk/channel-activity-runt
28
28
  import { buildChannelInboundEventContext, createChannelPartialDeliveryError, filterChannelInboundQuoteContext, formatInboundEnvelope, formatInboundEnvelope as formatInboundEnvelope$1, formatInboundMediaUnavailableText, formatLocationText, formatMediaPlaceholderText, hasVisibleInboundReplyDispatch, isChannelPartialDeliveryError, readAgentRunTerminalOutcome, resolveInboundSessionEnvelopeContext, resolveInboundSupplementalSenderAllowed, runChannelInboundEvent, shouldDebounceTextInbound, toInboundMediaFactsWithMetadata, toLocationContext } from "openclaw/plugin-sdk/channel-inbound";
29
29
  import { bindIngressLifecycleToReplyOptions, createChannelIngressMonitor, createChannelMessageReplyPipeline, createMessageReceiptFromOutboundResults, listMessageReceiptPlatformIds, resolveChannelMessageSourceReplyDeliveryMode, resolveChannelStreamingBlockEnabled } from "openclaw/plugin-sdk/channel-outbound";
30
30
  import { getAgentScopedMediaLocalRoots } from "openclaw/plugin-sdk/media-runtime";
31
- import { isReasoningReplyPayload, resolveSendableOutboundReplyParts, sendMediaWithLeadingCaption } from "openclaw/plugin-sdk/reply-payload";
31
+ import { isReasoningReplyPayload, resolveSendableOutboundReplyParts, resolveTextChunksWithFallback, sendMediaWithLeadingCaption } from "openclaw/plugin-sdk/reply-payload";
32
32
  import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
33
33
  import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
34
34
  import { DisconnectReason, downloadMediaMessage, isHostedLidUser, isHostedPnUser, isJidGroup, isJidGroup as isJidGroup$1, jidDecode, jidEncode, jidNormalizedUser, normalizeMessageContent as normalizeMessageContent$1 } from "baileys";
@@ -416,8 +416,7 @@ function readGroupMetadataCacheEntry(cache, jid) {
416
416
  function createWhatsAppGroupMetadataCacheOwner(params) {
417
417
  const reconnectCache = params.reconnectCache ?? /* @__PURE__ */ new Map();
418
418
  const localCache = /* @__PURE__ */ new Map();
419
- const publishedJids = /* @__PURE__ */ new Set();
420
- const invalidatedJids = /* @__PURE__ */ new Set();
419
+ const groupMetadataGenerations = /* @__PURE__ */ new Map();
421
420
  const detachListeners = [];
422
421
  let closed = false;
423
422
  let started = false;
@@ -447,46 +446,51 @@ function createWhatsAppGroupMetadataCacheOwner(params) {
447
446
  });
448
447
  const rememberFullUpdate = (jid, meta) => {
449
448
  if (closed) return;
449
+ groupMetadataGenerations.set(jid, {});
450
450
  rememberWhatsAppBaileysCacheEntry(params.baileysCache, jid, meta, GROUP_META_TTL_MS);
451
- publishedJids.add(jid);
452
- invalidatedJids.delete(jid);
453
451
  rememberGroupMetadataCacheEntry(reconnectCache, jid, summarizeForReconnect(meta));
454
452
  localCache.delete(jid);
455
453
  };
456
454
  const forgetFullMetadata = (jid) => {
455
+ groupMetadataGenerations.set(jid, {});
457
456
  params.baileysCache?.delete(jid);
458
457
  reconnectCache.delete(jid);
459
458
  localCache.delete(jid);
460
- publishedJids.delete(jid);
461
- invalidatedJids.add(jid);
462
459
  };
463
460
  const get = async (jid) => {
464
- const cached = readGroupMetadataCacheEntry(localCache, jid);
465
- if (cached) return cached;
466
- try {
467
- const hydratedEntry = params.baileysCache?.get(jid);
468
- const providerMetadata = params.baileysCache ? readWhatsAppBaileysCacheEntry(params.baileysCache, jid) : void 0;
469
- const hydratedMetadata = providerMetadata?.participants?.length ? providerMetadata : void 0;
470
- const meta = hydratedMetadata ?? await (params.getCurrentSock() ?? params.sock).groupMetadata(jid);
471
- if (!hydratedMetadata) rememberWhatsAppBaileysCacheEntry(params.baileysCache, jid, meta, GROUP_META_TTL_MS);
472
- publishedJids.add(jid);
473
- const entry = await summarize(meta);
474
- if (hydratedMetadata && hydratedEntry) entry.expires = hydratedEntry.expiresAt;
475
- rememberGroupMetadataCacheEntry(reconnectCache, jid, {
476
- subject: entry.subject,
477
- expires: entry.expires
478
- });
479
- rememberGroupMetadataCacheEntry(localCache, jid, entry);
480
- return entry;
481
- } catch (error) {
482
- const hydrated = readGroupMetadataCacheEntry(reconnectCache, jid);
483
- if (hydrated) {
484
- rememberGroupMetadataCacheEntry(localCache, jid, hydrated);
485
- params.logVerbose(`Using cached group metadata for ${jid} after fetch failure: ${String(error)}`);
486
- return hydrated;
461
+ for (;;) {
462
+ if (closed) return { expires: resolveGroupMetadataExpiresAt() ?? 0 };
463
+ const cached = readGroupMetadataCacheEntry(localCache, jid);
464
+ if (cached) return cached;
465
+ const generation = groupMetadataGenerations.get(jid);
466
+ try {
467
+ const hydratedEntry = params.baileysCache?.get(jid);
468
+ const providerMetadata = params.baileysCache ? readWhatsAppBaileysCacheEntry(params.baileysCache, jid) : void 0;
469
+ const hydratedMetadata = providerMetadata?.participants?.length ? providerMetadata : void 0;
470
+ const meta = hydratedMetadata ?? await (params.getCurrentSock() ?? params.sock).groupMetadata(jid);
471
+ if (closed || groupMetadataGenerations.get(jid) !== generation) continue;
472
+ const entry = await summarize(meta);
473
+ if (closed || groupMetadataGenerations.get(jid) !== generation) continue;
474
+ if (hydratedMetadata && hydratedEntry) entry.expires = hydratedEntry.expiresAt;
475
+ else rememberWhatsAppBaileysCacheEntry(params.baileysCache, jid, meta, GROUP_META_TTL_MS);
476
+ groupMetadataGenerations.set(jid, {});
477
+ rememberGroupMetadataCacheEntry(reconnectCache, jid, {
478
+ subject: entry.subject,
479
+ expires: entry.expires
480
+ });
481
+ rememberGroupMetadataCacheEntry(localCache, jid, entry);
482
+ return entry;
483
+ } catch (error) {
484
+ if (closed || groupMetadataGenerations.get(jid) !== generation) continue;
485
+ const hydrated = readGroupMetadataCacheEntry(reconnectCache, jid);
486
+ if (hydrated) {
487
+ rememberGroupMetadataCacheEntry(localCache, jid, hydrated);
488
+ params.logVerbose(`Using cached group metadata for ${jid} after fetch failure: ${String(error)}`);
489
+ return hydrated;
490
+ }
491
+ params.logVerbose(`Failed to fetch group metadata for ${jid}: ${String(error)}`);
492
+ return { expires: resolveGroupMetadataExpiresAt() ?? 0 };
487
493
  }
488
- params.logVerbose(`Failed to fetch group metadata for ${jid}: ${String(error)}`);
489
- return { expires: resolveGroupMetadataExpiresAt() ?? 0 };
490
494
  }
491
495
  };
492
496
  const resolveOutboundMentions = async (jid, text) => {
@@ -544,10 +548,10 @@ function createWhatsAppGroupMetadataCacheOwner(params) {
544
548
  try {
545
549
  const groups = await params.sock.groupFetchAllParticipating();
546
550
  if (closed) return;
547
- for (const [jid, meta] of Object.entries(groups ?? {})) if (meta && !publishedJids.has(jid) && !invalidatedJids.has(jid)) {
551
+ for (const [jid, meta] of Object.entries(groups ?? {})) if (meta && !groupMetadataGenerations.has(jid)) {
548
552
  rememberGroupMetadataCacheEntry(reconnectCache, jid, summarizeForReconnect(meta));
549
553
  rememberWhatsAppBaileysCacheEntry(params.baileysCache, jid, meta, GROUP_META_TTL_MS);
550
- publishedJids.add(jid);
554
+ groupMetadataGenerations.set(jid, {});
551
555
  }
552
556
  params.logVerbose(`Hydrated ${Object.keys(groups ?? {}).length} participating groups on connect`);
553
557
  } catch (error) {
@@ -2754,7 +2758,8 @@ async function deliverWebReplyInActivityScope(params) {
2754
2758
  const tableMode = params.tableMode ?? "code";
2755
2759
  const chunkMode = params.chunkMode ?? "length";
2756
2760
  const normalizedReply = params.normalizedReplyResult ?? normalizeWhatsAppOutboundPayload(replyResult, { normalizeText: normalizeWhatsAppPayloadTextPreservingIndentation });
2757
- const textChunks = markdownToWhatsAppChunks(normalizedReply.text ?? "", textLimit, tableMode, chunkMode);
2761
+ const text = normalizedReply.text ?? "";
2762
+ const textChunks = resolveTextChunksWithFallback(text, markdownToWhatsAppChunks(text, textLimit, tableMode, chunkMode));
2758
2763
  const mediaList = normalizedReply.mediaUrls ?? [];
2759
2764
  const getQuote = () => {
2760
2765
  if (!replyResult.replyToId) return;
@@ -1,16 +1,16 @@
1
1
  import { c as resolveWebCredsPath, r as hasWebCredsSync, s as resolveWebCredsBackupPath } from "./creds-files-W6B3EMZ8.js";
2
- import { n as whatsAppActionRuntime, t as handleWhatsAppAction } from "./action-runtime-pM-ExU0l.js";
3
- import { i as sendTypingWhatsApp, n as sendPollWhatsApp, r as sendReactionWhatsApp, t as sendMessageWhatsApp } from "./send-CwvTU4RI.js";
2
+ import { n as whatsAppActionRuntime, t as handleWhatsAppAction } from "./action-runtime-C075e6OP.js";
3
+ import { i as sendTypingWhatsApp, n as sendPollWhatsApp, r as sendReactionWhatsApp, t as sendMessageWhatsApp } from "./send-DLMUc2uZ.js";
4
4
  import { a as setWhatsAppRuntime } from "./runtime-BLlToOi6.js";
5
5
  import { startWebLoginWithQr, waitForWebLogin } from "./login-qr-runtime.js";
6
- import { t as createWhatsAppLoginTool } from "./agent-tools-login-BjRpD-JQ.js";
6
+ import { t as createWhatsAppLoginTool } from "./agent-tools-login-B-2qZPzc.js";
7
7
  import { M as waitForCredsSaveQueueWithTimeout, N as writeCredsJsonAtomically, _ as readWebSelfIdentity, a as formatWhatsAppWebAuthStatusState, b as restoreCredsFromBackupIfNeeded, c as logoutWeb, d as readWebAuthExistsBestEffort, f as readWebAuthExistsForDecision, g as readWebSelfId, h as readWebAuthState, j as waitForCredsSaveQueue, l as pickWebChannel, m as readWebAuthSnapshotBestEffort, n as WHATSAPP_AUTH_UNSTABLE_CODE, o as getWebAuthAgeMs, p as readWebAuthSnapshot, r as WhatsAppAuthUnstableError, s as logWebSelfId, t as WA_WEB_AUTH_DIR, u as readCredsJsonRaw, v as readWebSelfIdentityForDecision, x as webAuthExists, y as resolveDefaultWebAuthDir } from "./auth-store-CtpBqH5S.js";
8
8
  import { t as DEFAULT_WEB_MEDIA_BYTES } from "./constants-HU41RHGI.js";
9
9
  import { n as resolveWebAccountId, t as getActiveWebListener } from "./active-listener-BEjWsCNM.js";
10
10
  import { a as waitForWaConnection, i as newConnectionId, r as createWaSocket } from "./socket-close-2T0_jZTN.js";
11
11
  import { n as getStatusCode, t as formatError } from "./session-errors-JuazczrA.js";
12
- import { p as extractText, s as extractContactContext, u as extractLocationData } from "./send-api-obOSm2cC.js";
13
- import { a as loadWebMediaRaw, c as monitorWebInbox, i as loadWebMedia, l as resetWebInboundDedupe, n as LocalMediaAccessError, o as optimizeImageToJpeg, r as getDefaultLocalRoots, s as optimizeImageToPng, t as monitorWebChannel } from "./monitor-IzwQKizW.js";
12
+ import { p as extractText, s as extractContactContext, u as extractLocationData } from "./send-api-BtK45TmZ.js";
13
+ import { a as loadWebMediaRaw, c as monitorWebInbox, i as loadWebMedia, l as resetWebInboundDedupe, n as LocalMediaAccessError, o as optimizeImageToJpeg, r as getDefaultLocalRoots, s as optimizeImageToPng, t as monitorWebChannel } from "./monitor-C_Nw23PZ.js";
14
14
  import { t as loginWeb } from "./login-BkpKpndm.js";
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, 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 };
@@ -496,7 +496,7 @@ async function sendMessageWhatsAppInActivityScope(to, body, options) {
496
496
  const accountIdForFormatting = resolvedAccountId ?? options.accountId;
497
497
  const textLimit = Math.min(resolveTextChunkLimit(cfg, "whatsapp", accountIdForFormatting, { fallbackLimit: 4e3 }), 4096);
498
498
  const textChunks = markdownToWhatsAppChunks(text, textLimit, tableMode, resolveChunkMode(cfg, "whatsapp", accountIdForFormatting));
499
- text = textChunks.shift() ?? "";
499
+ text = textChunks.shift() ?? text;
500
500
  if (!text && !hasMedia) return {
501
501
  messageId: "",
502
502
  toJid: jid
@@ -1,5 +1,5 @@
1
1
  import { n as isWhatsAppNewsletterJid } from "./normalize-target-CugRyONv.js";
2
- import { _ as resolveWhatsAppDocumentFileName, f as mergeWhatsAppAcceptedSendError, m as rememberWhatsAppAcceptedSend, p as normalizeWhatsAppSendResult, u as combineWhatsAppSendResults } from "./send-CwvTU4RI.js";
2
+ import { _ as resolveWhatsAppDocumentFileName, f as mergeWhatsAppAcceptedSendError, m as rememberWhatsAppAcceptedSend, p as normalizeWhatsAppSendResult, u as combineWhatsAppSendResults } from "./send-DLMUc2uZ.js";
3
3
  import "./normalize-C7Hkc_vE.js";
4
4
  import { c as toWhatsappJid, l as toWhatsappJidWithLid, r as jidToE164 } from "./targets-runtime-TMk0lGuy.js";
5
5
  import "./text-runtime-CaKLhowd.js";
@@ -401,7 +401,7 @@ async function addWhatsAppImagePreviewFields(content) {
401
401
  //#endregion
402
402
  //#region extensions/whatsapp/src/inbound/outbound-mentions.ts
403
403
  const CODE_FENCE_RE = /```[\s\S]*?```/g;
404
- const INLINE_CODE_RE = /`[^`\n]+`/g;
404
+ const INLINE_CODE_RE = /(?<=(?:^|[^\\])(?:\\\\)*)(`+)[\s\S]*?(?:(?<!`)\1(?!`)|$)/g;
405
405
  const OUTBOUND_MENTION_RE = /@(\+?\d+)/g;
406
406
  const KNOWN_USER_JID_RE = /^(\d+)(?::\d+)?@(s\.whatsapp\.net|hosted|lid|hosted\.lid|c\.us)$/i;
407
407
  const PHONE_JID_DOMAIN_RE = /^(s\.whatsapp\.net|hosted|c\.us)$/i;
@@ -2,9 +2,9 @@ import { a as resolveWhatsAppAccount, o as resolveWhatsAppAuthDir } from "./acco
2
2
  import { r as resolveDefaultWhatsAppAccountId } from "./account-ids-CB5SOWjc.js";
3
3
  import { r as hasWebCredsSync } from "./creds-files-W6B3EMZ8.js";
4
4
  import { a as normalizeWhatsAppAllowFromEntries, o as normalizeWhatsAppAllowFromEntry } from "./normalize-target-CugRyONv.js";
5
- import { r as whatsappSetupAdapter } from "./shared-wg42NKFB.js";
6
- import { DEFAULT_ACCOUNT_ID, createSetupTranslator, splitSetupEntries } from "openclaw/plugin-sdk/setup";
5
+ import { r as whatsappSetupAdapter } from "./shared-BekHi69d.js";
7
6
  import { formatCliCommand, formatDocsLink } from "openclaw/plugin-sdk/setup-tools";
7
+ import { DEFAULT_ACCOUNT_ID, createSetupTranslator, splitSetupEntries } from "openclaw/plugin-sdk/setup";
8
8
  //#region extensions/whatsapp/src/setup-finalize.ts
9
9
  const t = createSetupTranslator();
10
10
  function trimPromptText(value) {
@@ -1,2 +1,2 @@
1
- import { t as whatsappSetupPlugin } from "./channel.setup-DhBBhbQv.js";
1
+ import { t as whatsappSetupPlugin } from "./channel.setup-CGcBvnpP.js";
2
2
  export { whatsappSetupPlugin };
@@ -36,7 +36,7 @@ const whatsappSetupWizard = {
36
36
  },
37
37
  resolveShouldPromptAccountIds: ({ shouldPromptAccountIds }) => shouldPromptAccountIds,
38
38
  credentials: [],
39
- finalize: async (params) => await (await import("./setup-finalize-n4K2I2gJ.js")).finalizeWhatsAppSetup(params),
39
+ finalize: async (params) => await (await import("./setup-finalize-C1nij8NS.js")).finalizeWhatsAppSetup(params),
40
40
  disable: (cfg) => setSetupChannelEnabled(cfg, channel, false),
41
41
  onAccountRecorded: (accountId, options) => {
42
42
  options?.onAccountId?.(channel, accountId);
@@ -27,7 +27,7 @@ async function readWhatsAppAccountLinkState(authDir) {
27
27
  }
28
28
  const loadWhatsAppChannelRuntime = createLazyRuntimeModule(async () => {
29
29
  await loadWhatsAppAuthStore();
30
- return await import("./channel.runtime-X3JC2gaq.js");
30
+ return await import("./channel.runtime-CrahUvcb.js");
31
31
  });
32
32
  //#endregion
33
33
  //#region extensions/whatsapp/src/config-accessors.ts
@@ -115,7 +115,7 @@ async function applyWhatsAppSecurityConfigFixes(params) {
115
115
  //#region extensions/whatsapp/src/shared.ts
116
116
  const WHATSAPP_CHANNEL = "whatsapp";
117
117
  async function loadWhatsAppSetupSurface() {
118
- return await import("./setup-surface-Cwn3zyxK.js");
118
+ return await import("./setup-surface-CjjqIxQP.js");
119
119
  }
120
120
  const whatsappSetupWizardProxy = createWhatsAppSetupWizardProxy(async () => (await loadWhatsAppSetupSurface()).whatsappSetupWizard);
121
121
  const whatsappConfigAdapter = createScopedChannelConfigAdapter({