@openclaw/whatsapp 2026.10.2 → 2026.10.5-beta.2

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 (212) 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/audio-decode/node_modules/@audio/decode/package.json +7 -7
  43. package/node_modules/audio-decode/node_modules/@audio/decode/readme.md +2 -1
  44. package/node_modules/audio-decode/node_modules/@audio/decode-aac/README.md +10 -0
  45. package/node_modules/audio-decode/node_modules/@audio/decode-aac/decode-aac.d.ts +22 -0
  46. package/node_modules/audio-decode/node_modules/@audio/decode-aac/decode-aac.js +142 -7
  47. package/node_modules/audio-decode/node_modules/@audio/decode-aac/package.json +1 -1
  48. package/node_modules/audio-decode/node_modules/@audio/decode-caf/README.md +2 -0
  49. package/node_modules/audio-decode/node_modules/@audio/decode-caf/decode-caf.js +4 -1
  50. package/node_modules/audio-decode/node_modules/@audio/decode-caf/package.json +1 -1
  51. package/node_modules/audio-decode/node_modules/@audio/decode-flac/decode-flac.js +161 -29
  52. package/node_modules/audio-decode/node_modules/@audio/decode-flac/package.json +1 -1
  53. package/node_modules/audio-decode/node_modules/@audio/decode-mp4/README.md +1 -1
  54. package/node_modules/audio-decode/node_modules/@audio/decode-mp4/decode-mp4.js +127 -28
  55. package/node_modules/audio-decode/node_modules/@audio/decode-mp4/package.json +3 -3
  56. package/node_modules/audio-decode/node_modules/@audio/decode-opus/package.json +1 -1
  57. package/node_modules/audio-decode/node_modules/@audio/decode-opus/src/decode-opus.js +2 -2
  58. package/node_modules/audio-decode/node_modules/@audio/decode-qoa/README.md +1 -1
  59. package/node_modules/audio-decode/node_modules/@audio/decode-qoa/decode-qoa.js +79 -227
  60. package/node_modules/audio-decode/node_modules/@audio/decode-qoa/package.json +1 -1
  61. package/node_modules/audio-decode/node_modules/@audio/decode-vorbis/decode-vorbis.js +51 -10
  62. package/node_modules/audio-decode/node_modules/@audio/decode-vorbis/package.json +1 -1
  63. package/node_modules/audio-decode/node_modules/@audio/decode-wav/decode-wav.js +40 -18
  64. package/node_modules/audio-decode/node_modules/@audio/decode-wav/package.json +1 -1
  65. package/node_modules/audio-decode/node_modules/@audio/decode-wma/LICENSE.ffmpeg +502 -0
  66. package/node_modules/audio-decode/node_modules/@audio/decode-wma/README.md +5 -5
  67. package/node_modules/audio-decode/node_modules/@audio/decode-wma/decode-wma.js +15 -3
  68. package/node_modules/audio-decode/node_modules/@audio/decode-wma/package.json +5 -4
  69. package/node_modules/audio-decode/node_modules/@audio/decode-wma/src/wma.wasm.js +0 -0
  70. package/node_modules/audio-decode/node_modules/audio-type/audio-type.js +13 -0
  71. package/node_modules/audio-decode/node_modules/audio-type/package.json +1 -1
  72. package/node_modules/audio-decode/node_modules/audio-type/readme.md +1 -1
  73. package/node_modules/baileys/lib/Utils/messages-media.js +7 -11
  74. package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/react-native/diagnostics-channel-react-native.d.ts.map +1 -0
  75. package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/react-native/diagnostics-channel-react-native.js.map +1 -0
  76. package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/react-native/diagnostics-channel.d.ts +5 -0
  77. package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/react-native/diagnostics-channel.js +7 -0
  78. package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/react-native/index.d.ts +1400 -0
  79. package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/react-native/index.d.ts.map +1 -0
  80. package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/react-native/index.js +1733 -0
  81. package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/react-native/index.js.map +1 -0
  82. package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/react-native/perf.d.ts +12 -0
  83. package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/react-native/perf.d.ts.map +1 -0
  84. package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/react-native/perf.js +10 -0
  85. package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/react-native/perf.js.map +1 -0
  86. package/node_modules/baileys/node_modules/lru-cache/dist/esm/react-native/diagnostics-channel-react-native.d.ts.map +1 -0
  87. package/node_modules/baileys/node_modules/lru-cache/dist/esm/react-native/diagnostics-channel-react-native.js.map +1 -0
  88. package/node_modules/baileys/node_modules/lru-cache/dist/esm/react-native/diagnostics-channel.d.ts +5 -0
  89. package/node_modules/baileys/node_modules/lru-cache/dist/esm/react-native/diagnostics-channel.js +4 -0
  90. package/node_modules/baileys/node_modules/lru-cache/dist/esm/react-native/index.d.ts +1400 -0
  91. package/node_modules/baileys/node_modules/lru-cache/dist/esm/react-native/index.d.ts.map +1 -0
  92. package/node_modules/baileys/node_modules/lru-cache/dist/esm/react-native/index.js +1729 -0
  93. package/node_modules/baileys/node_modules/lru-cache/dist/esm/react-native/index.js.map +1 -0
  94. package/node_modules/baileys/node_modules/lru-cache/dist/esm/react-native/perf.d.ts +12 -0
  95. package/node_modules/baileys/node_modules/lru-cache/dist/esm/react-native/perf.d.ts.map +1 -0
  96. package/node_modules/baileys/node_modules/lru-cache/dist/esm/react-native/perf.js +7 -0
  97. package/node_modules/baileys/node_modules/lru-cache/dist/esm/react-native/perf.js.map +1 -0
  98. package/node_modules/baileys/node_modules/lru-cache/package.json +27 -1
  99. package/node_modules/baileys/node_modules/music-metadata/README.md +35 -32
  100. package/node_modules/baileys/node_modules/music-metadata/lib/ParserFactory.d.ts +1 -1
  101. package/node_modules/baileys/node_modules/music-metadata/lib/ParserFactory.js +17 -13
  102. package/node_modules/baileys/node_modules/music-metadata/lib/aiff/AiffParser.js +19 -12
  103. package/node_modules/baileys/node_modules/music-metadata/lib/aiff/AiffToken.d.ts +1 -1
  104. package/node_modules/baileys/node_modules/music-metadata/lib/aiff/AiffToken.js +2 -1
  105. package/node_modules/baileys/node_modules/music-metadata/lib/apev2/APEv2Parser.d.ts +4 -3
  106. package/node_modules/baileys/node_modules/music-metadata/lib/apev2/APEv2Parser.js +59 -16
  107. package/node_modules/baileys/node_modules/music-metadata/lib/apev2/APEv2TagMapper.js +1 -0
  108. package/node_modules/baileys/node_modules/music-metadata/lib/apev2/APEv2Token.d.ts +1 -1
  109. package/node_modules/baileys/node_modules/music-metadata/lib/apev2/APEv2Token.js +1 -1
  110. package/node_modules/baileys/node_modules/music-metadata/lib/asf/AsfGuid.js +56 -50
  111. package/node_modules/baileys/node_modules/music-metadata/lib/asf/AsfObject.d.ts +1 -1
  112. package/node_modules/baileys/node_modules/music-metadata/lib/asf/AsfObject.js +3 -2
  113. package/node_modules/baileys/node_modules/music-metadata/lib/asf/AsfParser.js +15 -7
  114. package/node_modules/baileys/node_modules/music-metadata/lib/asf/AsfTagMapper.d.ts +3 -2
  115. package/node_modules/baileys/node_modules/music-metadata/lib/asf/AsfTagMapper.js +21 -4
  116. package/node_modules/baileys/node_modules/music-metadata/lib/common/CaseInsensitiveTagMap.d.ts +1 -1
  117. package/node_modules/baileys/node_modules/music-metadata/lib/common/CombinedTagMapper.d.ts +2 -2
  118. package/node_modules/baileys/node_modules/music-metadata/lib/common/CombinedTagMapper.js +6 -6
  119. package/node_modules/baileys/node_modules/music-metadata/lib/common/FourCC.js +3 -2
  120. package/node_modules/baileys/node_modules/music-metadata/lib/common/GenericTagMapper.d.ts +1 -1
  121. package/node_modules/baileys/node_modules/music-metadata/lib/common/GenericTagTypes.js +1 -1
  122. package/node_modules/baileys/node_modules/music-metadata/lib/common/MetadataCollector.d.ts +3 -1
  123. package/node_modules/baileys/node_modules/music-metadata/lib/common/MetadataCollector.js +28 -9
  124. package/node_modules/baileys/node_modules/music-metadata/lib/common/Util.js +25 -17
  125. package/node_modules/baileys/node_modules/music-metadata/lib/core.d.ts +4 -4
  126. package/node_modules/baileys/node_modules/music-metadata/lib/core.js +18 -11
  127. package/node_modules/baileys/node_modules/music-metadata/lib/dsdiff/DsdiffParser.js +29 -16
  128. package/node_modules/baileys/node_modules/music-metadata/lib/dsf/DsfChunk.d.ts +1 -1
  129. package/node_modules/baileys/node_modules/music-metadata/lib/dsf/DsfParser.js +3 -5
  130. package/node_modules/baileys/node_modules/music-metadata/lib/ebml/EbmlIterator.d.ts +1 -1
  131. package/node_modules/baileys/node_modules/music-metadata/lib/ebml/EbmlIterator.js +35 -6
  132. package/node_modules/baileys/node_modules/music-metadata/lib/ebml/types.d.ts +1 -1
  133. package/node_modules/baileys/node_modules/music-metadata/lib/ebml/types.js +1 -1
  134. package/node_modules/baileys/node_modules/music-metadata/lib/flac/FlacParser.d.ts +1 -1
  135. package/node_modules/baileys/node_modules/music-metadata/lib/flac/FlacParser.js +6 -5
  136. package/node_modules/baileys/node_modules/music-metadata/lib/flac/FlacToken.d.ts +1 -1
  137. package/node_modules/baileys/node_modules/music-metadata/lib/flac/FlacToken.js +1 -1
  138. package/node_modules/baileys/node_modules/music-metadata/lib/id3v1/ID3v1Parser.d.ts +1 -1
  139. package/node_modules/baileys/node_modules/music-metadata/lib/id3v1/ID3v1Parser.js +212 -42
  140. package/node_modules/baileys/node_modules/music-metadata/lib/id3v2/AbstractID3Parser.js +5 -5
  141. package/node_modules/baileys/node_modules/music-metadata/lib/id3v2/FrameHeader.d.ts +1 -1
  142. package/node_modules/baileys/node_modules/music-metadata/lib/id3v2/FrameHeader.js +8 -5
  143. package/node_modules/baileys/node_modules/music-metadata/lib/id3v2/FrameParser.d.ts +2 -1
  144. package/node_modules/baileys/node_modules/music-metadata/lib/id3v2/FrameParser.js +54 -23
  145. package/node_modules/baileys/node_modules/music-metadata/lib/id3v2/ID3v22TagMapper.d.ts +1 -1
  146. package/node_modules/baileys/node_modules/music-metadata/lib/id3v2/ID3v22TagMapper.js +1 -1
  147. package/node_modules/baileys/node_modules/music-metadata/lib/id3v2/ID3v24TagMapper.js +3 -3
  148. package/node_modules/baileys/node_modules/music-metadata/lib/id3v2/ID3v2ChapterToken.js +2 -2
  149. package/node_modules/baileys/node_modules/music-metadata/lib/id3v2/ID3v2Parser.d.ts +1 -1
  150. package/node_modules/baileys/node_modules/music-metadata/lib/id3v2/ID3v2Parser.js +32 -16
  151. package/node_modules/baileys/node_modules/music-metadata/lib/id3v2/ID3v2Token.d.ts +2 -2
  152. package/node_modules/baileys/node_modules/music-metadata/lib/id3v2/ID3v2Token.js +2 -3
  153. package/node_modules/baileys/node_modules/music-metadata/lib/index.js +6 -3
  154. package/node_modules/baileys/node_modules/music-metadata/lib/lrc/LyricsParser.js +3 -5
  155. package/node_modules/baileys/node_modules/music-metadata/lib/matroska/MatroskaDtd.js +7 -3
  156. package/node_modules/baileys/node_modules/music-metadata/lib/matroska/MatroskaParser.js +22 -11
  157. package/node_modules/baileys/node_modules/music-metadata/lib/matroska/types.d.ts +2 -2
  158. package/node_modules/baileys/node_modules/music-metadata/lib/mp4/Atom.d.ts +4 -3
  159. package/node_modules/baileys/node_modules/music-metadata/lib/mp4/Atom.js +44 -11
  160. package/node_modules/baileys/node_modules/music-metadata/lib/mp4/AtomToken.d.ts +1 -1
  161. package/node_modules/baileys/node_modules/music-metadata/lib/mp4/AtomToken.js +30 -8
  162. package/node_modules/baileys/node_modules/music-metadata/lib/mp4/MP4Parser.d.ts +2 -0
  163. package/node_modules/baileys/node_modules/music-metadata/lib/mp4/MP4Parser.js +79 -54
  164. package/node_modules/baileys/node_modules/music-metadata/lib/mp4/MP4TagMapper.d.ts +2 -2
  165. package/node_modules/baileys/node_modules/music-metadata/lib/mpeg/MpegLoader.js +1 -1
  166. package/node_modules/baileys/node_modules/music-metadata/lib/mpeg/MpegParser.js +41 -19
  167. package/node_modules/baileys/node_modules/music-metadata/lib/mpeg/ReplayGainDataFormat.d.ts +2 -2
  168. package/node_modules/baileys/node_modules/music-metadata/lib/mpeg/ReplayGainDataFormat.js +1 -1
  169. package/node_modules/baileys/node_modules/music-metadata/lib/mpeg/XingTag.d.ts +1 -1
  170. package/node_modules/baileys/node_modules/music-metadata/lib/musepack/MusepackParser.js +2 -2
  171. package/node_modules/baileys/node_modules/music-metadata/lib/musepack/sv7/BitReader.js +1 -1
  172. package/node_modules/baileys/node_modules/music-metadata/lib/musepack/sv7/MpcSv7Parser.js +4 -3
  173. package/node_modules/baileys/node_modules/music-metadata/lib/musepack/sv7/StreamVersion7.js +3 -3
  174. package/node_modules/baileys/node_modules/music-metadata/lib/musepack/sv8/MpcSv8Parser.js +7 -5
  175. package/node_modules/baileys/node_modules/music-metadata/lib/musepack/sv8/StreamVersion8.js +2 -2
  176. package/node_modules/baileys/node_modules/music-metadata/lib/ogg/OggParser.js +23 -13
  177. package/node_modules/baileys/node_modules/music-metadata/lib/ogg/OggToken.d.ts +2 -0
  178. package/node_modules/baileys/node_modules/music-metadata/lib/ogg/OggToken.js +1 -1
  179. package/node_modules/baileys/node_modules/music-metadata/lib/ogg/flac/FlacStream.d.ts +2 -2
  180. package/node_modules/baileys/node_modules/music-metadata/lib/ogg/flac/FlacStream.js +2 -2
  181. package/node_modules/baileys/node_modules/music-metadata/lib/ogg/opus/OpusStream.d.ts +2 -2
  182. package/node_modules/baileys/node_modules/music-metadata/lib/ogg/opus/OpusStream.js +8 -4
  183. package/node_modules/baileys/node_modules/music-metadata/lib/ogg/speex/SpeexStream.d.ts +2 -2
  184. package/node_modules/baileys/node_modules/music-metadata/lib/ogg/speex/SpeexStream.js +2 -1
  185. package/node_modules/baileys/node_modules/music-metadata/lib/ogg/theora/TheoraStream.d.ts +2 -2
  186. package/node_modules/baileys/node_modules/music-metadata/lib/ogg/vorbis/Vorbis.d.ts +1 -1
  187. package/node_modules/baileys/node_modules/music-metadata/lib/ogg/vorbis/VorbisDecoder.js +1 -1
  188. package/node_modules/baileys/node_modules/music-metadata/lib/ogg/vorbis/VorbisStream.d.ts +4 -3
  189. package/node_modules/baileys/node_modules/music-metadata/lib/ogg/vorbis/VorbisStream.js +16 -9
  190. package/node_modules/baileys/node_modules/music-metadata/lib/ogg/vorbis/VorbisTagMapper.js +4 -0
  191. package/node_modules/baileys/node_modules/music-metadata/lib/riff/RiffChunk.d.ts +3 -1
  192. package/node_modules/baileys/node_modules/music-metadata/lib/riff/RiffChunk.js +3 -2
  193. package/node_modules/baileys/node_modules/music-metadata/lib/riff/RiffInfoTagMap.d.ts +1 -1
  194. package/node_modules/baileys/node_modules/music-metadata/lib/type.d.ts +3 -3
  195. package/node_modules/baileys/node_modules/music-metadata/lib/type.js +1 -1
  196. package/node_modules/baileys/node_modules/music-metadata/lib/wav/WaveChunk.d.ts +1 -1
  197. package/node_modules/baileys/node_modules/music-metadata/lib/wav/WaveChunk.js +3 -2
  198. package/node_modules/baileys/node_modules/music-metadata/lib/wav/WaveParser.d.ts +6 -2
  199. package/node_modules/baileys/node_modules/music-metadata/lib/wav/WaveParser.js +75 -22
  200. package/node_modules/baileys/node_modules/music-metadata/lib/wavpack/WavPackParser.js +22 -13
  201. package/node_modules/baileys/node_modules/music-metadata/lib/wavpack/WavPackToken.js +3 -2
  202. package/node_modules/baileys/node_modules/music-metadata/package.json +3 -2
  203. package/node_modules/baileys/node_modules/uint8array-extras/index.d.ts +7 -7
  204. package/node_modules/baileys/node_modules/uint8array-extras/index.js +27 -13
  205. package/node_modules/baileys/node_modules/uint8array-extras/package.json +6 -6
  206. package/node_modules/baileys/node_modules/uint8array-extras/readme.md +7 -7
  207. package/node_modules/baileys/node_modules/ws/lib/websocket.js +17 -3
  208. package/node_modules/baileys/node_modules/ws/package.json +1 -1
  209. package/package.json +4 -4
  210. package/dist/.setup/audio-preflight.runtime-C_glQhZY.mjs +0 -7
  211. package/dist/.setup/channel.setup-CsS_NAKQ.mjs +0 -5
  212. package/dist/.setup/setup-plugin-api-Bsp7jI-r.mjs +0 -3
@@ -1,7 +1,7 @@
1
1
  import { r as getWhatsAppChannelRuntime } from "./runtime-BLlToOi6.mjs";
2
2
  import { n as WHATSAPP_CONNECTION_OWNER_PENDING_CAPABILITY, t as WHATSAPP_CONNECTION_CONTROLLER_CAPABILITY } from "./connection-controller-runtime-context-hgLJoRc8.mjs";
3
- import { O as resolveComparableIdentity, c as logoutWeb, d as readWebAuthExistsForDecision, j as waitForCredsSaveQueueWithTimeout, r as WhatsAppAuthUnstableError } from "./auth-store-D2rN-hP5.mjs";
4
- import { d as DEFAULT_WHATSAPP_SOCKET_TIMING, i as waitForWaConnection, o as computeBackoff, r as createWaSocket, t as closeWhatsAppSocketAndWait, u as sleepWithAbort$1, y as acquireWhatsAppGatewayConnectionOwner } from "./socket-close-DU7eerAa.mjs";
3
+ import { O as resolveComparableIdentity, c as logoutWeb, d as readWebAuthExistsForDecision, j as waitForCredsSaveQueueWithTimeout, r as WhatsAppAuthUnstableError } from "./auth-store-DOBi5BPe.mjs";
4
+ import { d as DEFAULT_WHATSAPP_SOCKET_TIMING, i as waitForWaConnection, o as computeBackoff, r as createWaSocket, t as closeWhatsAppSocketAndWait, u as sleepWithAbort$1, y as acquireWhatsAppGatewayConnectionOwner } from "./socket-close-C9OU9mVN.mjs";
5
5
  import { n as getStatusCode, t as formatError } from "./session-errors-B8UcAnZN.mjs";
6
6
  import { info } from "openclaw/plugin-sdk/runtime-env";
7
7
  import { registerChannelRuntimeContext } from "openclaw/plugin-sdk/channel-runtime-context";
@@ -22,35 +22,6 @@ const WHATSAPP_WATCHDOG_TIMEOUT_ERROR = "watchdog-timeout";
22
22
  function createNeverResolvePromise() {
23
23
  return new Promise(() => {});
24
24
  }
25
- function getLoginSocketRestartKind(statusCode) {
26
- if (statusCode === POST_PAIRING_RESTART_STATUS) return "post-pairing";
27
- if (statusCode === TIMED_OUT_STATUS) return "timeout";
28
- return null;
29
- }
30
- function getLoginSocketRestartMessage(kind) {
31
- return kind === "timeout" ? WHATSAPP_LOGIN_TIMEOUT_RESTART_MESSAGE : WHATSAPP_LOGIN_RESTART_MESSAGE;
32
- }
33
- function createLiveConnection(params) {
34
- const close = createDeferred();
35
- return {
36
- connectionId: params.connectionId,
37
- startedAt: Date.now(),
38
- sock: params.sock,
39
- listener: params.listener,
40
- heartbeat: null,
41
- watchdogTimer: null,
42
- lastInboundAt: null,
43
- lastTransportActivityAt: Date.now(),
44
- handledMessages: 0,
45
- unregisterUnhandled: null,
46
- unregisterTransportActivity: null,
47
- openedAfterRecentInbound: params.openedAfterRecentInbound,
48
- backgroundTasks: /* @__PURE__ */ new Set(),
49
- closePromise: close.promise,
50
- resolveClose: close.resolve,
51
- socketClosed: false
52
- };
53
- }
54
25
  async function closeWebSocketBestEffort(sock) {
55
26
  try {
56
27
  await sock.ws?.close?.();
@@ -94,11 +65,8 @@ async function waitForWhatsAppLoginResult(params) {
94
65
  const wait = params.waitForConnection ?? waitForWaConnection;
95
66
  const createSocket = params.createSocket ?? createWaSocket;
96
67
  let currentSock = params.sock;
97
- let postPairingRestarted = false;
98
- let timeoutRestarted = false;
99
- let loggedOutRestarted = false;
100
- const replaceLoginSocket = async (opts = {}) => {
101
- if (opts.closeCurrent ?? true) closeWaSocket(currentSock);
68
+ const restartedStatuses = /* @__PURE__ */ new Set();
69
+ const replaceLoginSocket = async () => {
102
70
  try {
103
71
  currentSock = await createSocket(false, params.verbose, {
104
72
  authDir: params.authDir,
@@ -140,22 +108,17 @@ async function waitForWhatsAppLoginResult(params) {
140
108
  };
141
109
  return {
142
110
  outcome: "connected",
143
- restarted: postPairingRestarted || timeoutRestarted || loggedOutRestarted,
111
+ restarted: restartedStatuses.size > 0,
144
112
  sock: currentSock
145
113
  };
146
114
  } catch (err) {
147
115
  const statusCode = getStatusCode(err);
148
- const restartKind = getLoginSocketRestartKind(statusCode);
149
- if (restartKind && (restartKind === "post-pairing" && !postPairingRestarted || restartKind === "timeout" && !timeoutRestarted)) {
150
- if (restartKind === "post-pairing") postPairingRestarted = true;
151
- else timeoutRestarted = true;
152
- params.runtime.log(info(getLoginSocketRestartMessage(restartKind)));
153
- const replacementFailure = await replaceLoginSocket();
154
- if (replacementFailure) return replacementFailure;
155
- continue;
156
- }
157
- if (statusCode === LOGGED_OUT_STATUS) {
158
- if (loggedOutRestarted) return {
116
+ if ((statusCode === POST_PAIRING_RESTART_STATUS || statusCode === TIMED_OUT_STATUS) && !restartedStatuses.has(statusCode)) {
117
+ restartedStatuses.add(statusCode);
118
+ params.runtime.log(info(statusCode === TIMED_OUT_STATUS ? WHATSAPP_LOGIN_TIMEOUT_RESTART_MESSAGE : WHATSAPP_LOGIN_RESTART_MESSAGE));
119
+ closeWaSocket(currentSock);
120
+ } else if (statusCode === LOGGED_OUT_STATUS) {
121
+ if (restartedStatuses.has(LOGGED_OUT_STATUS)) return {
159
122
  outcome: "logged-out",
160
123
  message: WHATSAPP_LOGGED_OUT_RELINK_MESSAGE,
161
124
  statusCode: LOGGED_OUT_STATUS,
@@ -180,21 +143,20 @@ async function waitForWhatsAppLoginResult(params) {
180
143
  error: err
181
144
  };
182
145
  }
183
- loggedOutRestarted = true;
184
- const replacementFailure = await replaceLoginSocket({ closeCurrent: false });
185
- if (replacementFailure) return replacementFailure;
186
- continue;
187
- }
188
- return {
146
+ restartedStatuses.add(LOGGED_OUT_STATUS);
147
+ } else return {
189
148
  outcome: "failed",
190
149
  message: formatError(err),
191
150
  statusCode,
192
151
  error: err
193
152
  };
153
+ const replacementFailure = await replaceLoginSocket();
154
+ if (replacementFailure) return replacementFailure;
194
155
  }
195
156
  }
196
157
  var WhatsAppConnectionController = class {
197
158
  constructor(params) {
159
+ this.params = params;
198
160
  this.disconnectRetryController = new AbortController();
199
161
  this.current = null;
200
162
  this.runtimeContextLease = null;
@@ -209,17 +171,10 @@ var WhatsAppConnectionController = class {
209
171
  this.setupAbortController = new AbortController();
210
172
  this.reconnectAttempts = 0;
211
173
  this.lastHandledInboundAt = null;
174
+ this.params = { ...params };
212
175
  this.accountId = params.accountId;
213
176
  this.authDir = params.authDir;
214
- this.verbose = params.verbose;
215
- this.keepAlive = params.keepAlive;
216
- this.heartbeatSeconds = params.heartbeatSeconds;
217
- this.transportTimeoutMs = params.transportTimeoutMs;
218
- this.messageTimeoutMs = params.messageTimeoutMs;
219
177
  this.appSilenceTimeoutMs = params.messageTimeoutMs * 4;
220
- this.watchdogCheckMs = params.watchdogCheckMs;
221
- this.reconnectPolicy = params.reconnectPolicy;
222
- this.abortSignal = params.abortSignal;
223
178
  this.sleep = params.sleep ?? sleepWithAbort$1;
224
179
  this.isNonRetryableStatus = params.isNonRetryableStatus ?? (() => false);
225
180
  this.socketTiming = {
@@ -265,10 +220,10 @@ var WhatsAppConnectionController = class {
265
220
  return this.reconnectAttempts;
266
221
  }
267
222
  isStopRequested() {
268
- return this.abortSignal?.aborted === true;
223
+ return this.params.abortSignal?.aborted === true;
269
224
  }
270
225
  shouldRetryDisconnect() {
271
- return this.keepAlive && !this.isStopRequested() && !this.disconnectRetryController.signal.aborted;
226
+ return this.params.keepAlive && !this.isStopRequested() && !this.disconnectRetryController.signal.aborted;
272
227
  }
273
228
  getDisconnectRetryAbortSignal() {
274
229
  return this.disconnectRetryController.signal;
@@ -326,7 +281,7 @@ var WhatsAppConnectionController = class {
326
281
  let sock = null;
327
282
  let connection = null;
328
283
  try {
329
- sock = await createWaSocket(false, this.verbose, {
284
+ sock = await createWaSocket(false, this.params.verbose, {
330
285
  authDir: this.authDir,
331
286
  ...this.socketTiming,
332
287
  ...params.getMessage ? { getMessage: params.getMessage } : {},
@@ -336,12 +291,27 @@ var WhatsAppConnectionController = class {
336
291
  await this.waitForSetupStep(waitForWaConnection(sock, { timeoutMs: this.socketTiming.connectTimeoutMs }));
337
292
  this.throwIfSetupStopped();
338
293
  this.socketRef.current = sock;
339
- connection = createLiveConnection({
294
+ const placeholderListener = {};
295
+ const openedAfterRecentInbound = this.reconnectAttempts > 0 && this.lastHandledInboundAt !== null && Date.now() - this.lastHandledInboundAt <= this.appSilenceTimeoutMs;
296
+ const close = createDeferred();
297
+ connection = {
340
298
  connectionId: params.connectionId,
299
+ startedAt: Date.now(),
341
300
  sock,
342
- listener: {},
343
- openedAfterRecentInbound: this.isOpeningAfterRecentInbound()
344
- });
301
+ listener: placeholderListener,
302
+ heartbeat: null,
303
+ watchdogTimer: null,
304
+ lastInboundAt: null,
305
+ lastTransportActivityAt: Date.now(),
306
+ handledMessages: 0,
307
+ unregisterUnhandled: null,
308
+ unregisterTransportActivity: null,
309
+ openedAfterRecentInbound,
310
+ backgroundTasks: /* @__PURE__ */ new Set(),
311
+ closePromise: close.promise,
312
+ resolveClose: close.resolve,
313
+ socketClosed: false
314
+ };
345
315
  const listenerTask = params.createListener({
346
316
  sock,
347
317
  connection
@@ -364,7 +334,7 @@ var WhatsAppConnectionController = class {
364
334
  accountId: this.accountId,
365
335
  capability: WHATSAPP_CONNECTION_CONTROLLER_CAPABILITY,
366
336
  context: this,
367
- abortSignal: this.abortSignal
337
+ abortSignal: this.params.abortSignal
368
338
  });
369
339
  previousRuntimeContextLease?.dispose();
370
340
  this.pendingOwnerContextLease?.dispose();
@@ -429,7 +399,7 @@ var WhatsAppConnectionController = class {
429
399
  resolveCloseDecision(reason) {
430
400
  if (reason === "aborted" || this.isStopRequested()) return "aborted";
431
401
  const current = this.current;
432
- if (current && Date.now() - current.startedAt > this.heartbeatSeconds * 1e3) this.reconnectAttempts = 0;
402
+ if (current && Date.now() - current.startedAt > this.params.heartbeatSeconds * 1e3) this.reconnectAttempts = 0;
433
403
  const normalized = this.normalizeCloseReason(reason);
434
404
  if (normalized.isLoggedOut) return {
435
405
  action: "stop",
@@ -459,14 +429,14 @@ var WhatsAppConnectionController = class {
459
429
  }
460
430
  consumeReconnectAttempt() {
461
431
  this.reconnectAttempts += 1;
462
- if (this.reconnectPolicy.maxAttempts > 0 && this.reconnectAttempts >= this.reconnectPolicy.maxAttempts) return {
432
+ if (this.params.reconnectPolicy.maxAttempts > 0 && this.reconnectAttempts >= this.params.reconnectPolicy.maxAttempts) return {
463
433
  action: "stop",
464
434
  reconnectAttempts: this.reconnectAttempts,
465
435
  healthState: "stopped"
466
436
  };
467
437
  return {
468
438
  action: "retry",
469
- delayMs: computeBackoff(this.reconnectPolicy, this.reconnectAttempts),
439
+ delayMs: computeBackoff(this.params.reconnectPolicy, this.reconnectAttempts),
470
440
  reconnectAttempts: this.reconnectAttempts,
471
441
  healthState: "reconnecting"
472
442
  };
@@ -498,7 +468,7 @@ var WhatsAppConnectionController = class {
498
468
  if (this.pendingSocketCleanup === connection) this.pendingSocketCleanup = null;
499
469
  }
500
470
  async waitBeforeRetry(delayMs) {
501
- await this.sleep(delayMs, this.abortSignal);
471
+ await this.sleep(delayMs, this.params.abortSignal);
502
472
  }
503
473
  async shutdown() {
504
474
  this.shuttingDown = true;
@@ -565,7 +535,7 @@ var WhatsAppConnectionController = class {
565
535
  accountId: this.accountId,
566
536
  capability: WHATSAPP_CONNECTION_OWNER_PENDING_CAPABILITY,
567
537
  context: true,
568
- abortSignal: this.abortSignal
538
+ abortSignal: this.params.abortSignal
569
539
  });
570
540
  this.connectionOwnerLease = ownerLease;
571
541
  } catch (error) {
@@ -583,18 +553,18 @@ var WhatsAppConnectionController = class {
583
553
  await this.connectionOwnerLeasePromise;
584
554
  }
585
555
  startTimers(connection, hooks) {
586
- if (!this.keepAlive) return;
556
+ if (!this.params.keepAlive) return;
587
557
  connection.heartbeat = setInterval(() => {
588
558
  const snapshot = this.getCurrentSnapshot(connection);
589
559
  if (!snapshot) return;
590
560
  hooks.onHeartbeat?.(snapshot);
591
- }, this.heartbeatSeconds * 1e3);
561
+ }, this.params.heartbeatSeconds * 1e3);
592
562
  connection.watchdogTimer = setInterval(() => {
593
563
  const now = Date.now();
594
564
  const transportStaleForMs = now - connection.lastTransportActivityAt;
595
565
  const appSilentForMs = now - (connection.lastInboundAt ?? connection.startedAt);
596
- const appSilenceTimeoutMs = connection.openedAfterRecentInbound ? this.messageTimeoutMs : this.appSilenceTimeoutMs;
597
- if (transportStaleForMs <= this.transportTimeoutMs && appSilentForMs <= appSilenceTimeoutMs) return;
566
+ const appSilenceTimeoutMs = connection.openedAfterRecentInbound ? this.params.messageTimeoutMs : this.appSilenceTimeoutMs;
567
+ if (transportStaleForMs <= this.params.transportTimeoutMs && appSilentForMs <= appSilenceTimeoutMs) return;
598
568
  const snapshot = this.getCurrentSnapshot(connection);
599
569
  if (!snapshot) return;
600
570
  hooks.onWatchdogTimeout?.(snapshot);
@@ -603,7 +573,7 @@ var WhatsAppConnectionController = class {
603
573
  isLoggedOut: false,
604
574
  error: WHATSAPP_WATCHDOG_TIMEOUT_ERROR
605
575
  });
606
- }, this.watchdogCheckMs);
576
+ }, this.params.watchdogCheckMs);
607
577
  }
608
578
  attachTransportActivityListener(sock) {
609
579
  const ws = sock.ws;
@@ -618,10 +588,6 @@ var WhatsAppConnectionController = class {
618
588
  ws.removeListener?.("frame", noteActivity);
619
589
  };
620
590
  }
621
- isOpeningAfterRecentInbound() {
622
- if (this.reconnectAttempts <= 0 || this.lastHandledInboundAt === null) return false;
623
- return Date.now() - this.lastHandledInboundAt <= this.appSilenceTimeoutMs;
624
- }
625
591
  stopDisconnectRetries() {
626
592
  if (!this.disconnectRetryController.signal.aborted) this.disconnectRetryController.abort();
627
593
  }
@@ -1,10 +1,10 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BBjsoOtd.mjs";
2
2
  import { c as resolveMergedWhatsAppAccountConfig, o as resolveWhatsAppAuthDir } from "./accounts-F0vHuze2.mjs";
3
- import { c as normalizeWhatsAppTarget, t as isWhatsAppGroupJid } from "./normalize-target-BGra1ZnM.mjs";
3
+ import { c as normalizeWhatsAppTarget, t as isWhatsAppGroupJid } from "./normalize-target-D67Kc3g6.mjs";
4
4
  import { i as hasPendingWhatsAppConnectionOwner, r as getWhatsAppConnectionController } from "./connection-controller-runtime-context-hgLJoRc8.mjs";
5
- import { d as readWebAuthExistsForDecision, j as waitForCredsSaveQueueWithTimeout } from "./auth-store-D2rN-hP5.mjs";
5
+ import { d as readWebAuthExistsForDecision, j as waitForCredsSaveQueueWithTimeout } from "./auth-store-DOBi5BPe.mjs";
6
6
  import { n as resolveWebAccountId } from "./active-listener-CDjoX9QR.mjs";
7
- import { b as acquireWhatsAppStandaloneConnectionOwner, i as waitForWaConnection, n as createWaDirectorySocket, t as closeWhatsAppSocketAndWait, v as WhatsAppConnectionOwnerBusyError } from "./socket-close-DU7eerAa.mjs";
7
+ import { b as acquireWhatsAppStandaloneConnectionOwner, i as waitForWaConnection, n as createWaDirectorySocket, t as closeWhatsAppSocketAndWait, v as WhatsAppConnectionOwnerBusyError } from "./socket-close-C9OU9mVN.mjs";
8
8
  import { listResolvedDirectoryGroupEntriesFromMapKeys, listResolvedDirectoryUserEntriesFromAllowFrom } from "openclaw/plugin-sdk/directory-config-runtime";
9
9
  //#region extensions/whatsapp/src/directory-config.ts
10
10
  var directory_config_exports = /* @__PURE__ */ __exportAll({
@@ -49,18 +49,22 @@ var WhatsAppDirectoryUnavailableError = class extends Error {
49
49
  }
50
50
  };
51
51
  async function fetchLiveGroups(sock, params) {
52
- const groups = await sock.groupFetchAllParticipating();
53
- const query = params.query?.trim().toLowerCase() ?? "";
54
- const limit = typeof params.limit === "number" && params.limit > 0 ? params.limit : void 0;
55
- const entries = Object.entries(groups).map(([jid, metadata]) => ({
56
- kind: "group",
57
- id: jid,
58
- name: metadata?.subject?.trim() || void 0
59
- })).filter((entry) => {
60
- if (!query) return true;
61
- return entry.id.toLowerCase().includes(query) || entry.name?.toLowerCase().includes(query);
62
- }).toSorted((left, right) => left.id.localeCompare(right.id));
63
- return limit ? entries.slice(0, limit) : entries;
52
+ try {
53
+ const groups = await sock.groupFetchAllParticipating();
54
+ const query = params.query?.trim().toLowerCase() ?? "";
55
+ const limit = typeof params.limit === "number" && params.limit > 0 ? params.limit : void 0;
56
+ const entries = Object.entries(groups).map(([jid, metadata]) => ({
57
+ kind: "group",
58
+ id: jid,
59
+ name: metadata?.subject?.trim() || void 0
60
+ })).filter((entry) => {
61
+ if (!query) return true;
62
+ return entry.id.toLowerCase().includes(query) || entry.name?.toLowerCase().includes(query);
63
+ }).toSorted((left, right) => left.id.localeCompare(right.id));
64
+ return limit ? entries.slice(0, limit) : entries;
65
+ } catch (error) {
66
+ throw unavailable("lookup_failed", "WhatsApp live group lookup failed.", error);
67
+ }
64
68
  }
65
69
  function unavailable(reason, message, cause) {
66
70
  return new WhatsAppDirectoryUnavailableError(reason, message, cause ? { cause } : void 0);
@@ -106,12 +110,9 @@ async function finishStandaloneCleanupOrThrow(cleanup, operationError) {
106
110
  } catch (cleanupError) {
107
111
  pendingStandaloneCleanups.set(cleanup.authDir, cleanup);
108
112
  scheduleStandaloneCleanupRetry(cleanup);
109
- throw cleanupUnavailable(operationError === void 0 ? cleanupError : new AggregateError([operationError, cleanupError], "WhatsApp live group lookup and cleanup failed", { cause: operationError }));
113
+ throw unavailable("cleanup_failed", "WhatsApp live group lookup could not safely close its standalone connection.", operationError === void 0 ? cleanupError : new AggregateError([operationError, cleanupError], "WhatsApp live group lookup and cleanup failed", { cause: operationError }));
110
114
  }
111
115
  }
112
- function cleanupUnavailable(error) {
113
- return unavailable("cleanup_failed", "WhatsApp live group lookup could not safely close its standalone connection.", error);
114
- }
115
116
  async function finishPriorStandaloneCleanup(authDir) {
116
117
  const cleanup = pendingStandaloneCleanups.get(authDir);
117
118
  if (!cleanup) return;
@@ -156,11 +157,7 @@ async function listGroupsThroughStandaloneOwner(params) {
156
157
  } catch (error) {
157
158
  throw unavailable("connection_failed", "WhatsApp live groups are unavailable because the standalone connection failed.", error);
158
159
  }
159
- try {
160
- groups = await fetchLiveGroups(cleanup.sock, params);
161
- } catch (error) {
162
- throw unavailable("lookup_failed", "WhatsApp live group lookup failed.", error);
163
- }
160
+ groups = await fetchLiveGroups(cleanup.sock, params);
164
161
  } catch (error) {
165
162
  await finishStandaloneCleanupOrThrow(cleanup, error);
166
163
  throw error;
@@ -177,11 +174,7 @@ async function listWhatsAppDirectoryGroupsLive(params) {
177
174
  if (!controller && !hasPendingWhatsAppConnectionOwner(accountId)) return await listGroupsThroughStandaloneOwner(params);
178
175
  const sock = controller?.getCurrentSock();
179
176
  if (!sock) throw unavailable("active_owner_unavailable", "WhatsApp live groups are unavailable while the gateway connection is offline.");
180
- try {
181
- return await fetchLiveGroups(sock, params);
182
- } catch (error) {
183
- throw unavailable("lookup_failed", "WhatsApp live group lookup failed.", error);
184
- }
177
+ return await fetchLiveGroups(sock, params);
185
178
  }
186
179
  //#endregion
187
180
  export { listWhatsAppDirectoryGroupsFromConfig as n, listWhatsAppDirectoryPeersFromConfig as r, directory_config_exports as t };
@@ -1,6 +1,6 @@
1
1
  import { a as resolveWhatsAppAccount } from "./accounts-F0vHuze2.mjs";
2
- import { c as normalizeWhatsAppTarget } from "./normalize-target-BGra1ZnM.mjs";
3
- import { r as jidToE164 } from "./targets-runtime-Dls-Xh4F.mjs";
2
+ import { c as normalizeWhatsAppTarget } from "./normalize-target-D67Kc3g6.mjs";
3
+ import { r as jidToE164 } from "./targets-runtime-D5ryyPxh.mjs";
4
4
  import { formatMediaPlaceholderText } from "openclaw/plugin-sdk/channel-inbound";
5
5
  import { createChannelApprovalAuth } from "openclaw/plugin-sdk/approval-auth-runtime";
6
6
  import { isHostedLidUser, isHostedPnUser, isLidUser, isPnUser } from "baileys";
@@ -45,7 +45,9 @@ function cacheInboundMessageMeta(accountId, remoteJid, messageId, meta) {
45
45
  });
46
46
  }
47
47
  function lookupInboundMessageMeta(accountId, remoteJid, messageId) {
48
- const cacheKey = makeCacheKey(accountId, remoteJid, messageId);
48
+ return readCachedMessageMeta(makeCacheKey(accountId, remoteJid, messageId));
49
+ }
50
+ function readCachedMessageMeta(cacheKey) {
49
51
  const entry = cache.get(cacheKey);
50
52
  if (!entry) return;
51
53
  if (Date.now() - entry.ts > CACHE_TTL_MS) {
@@ -96,19 +98,14 @@ function lookupInboundMessageMetaForTarget(accountId, targetJid, messageId) {
96
98
  const prefix = `${accountId}:`;
97
99
  const suffix = `:${messageId}`;
98
100
  let matched;
99
- for (const [cacheKey, entry] of cache.entries()) {
101
+ for (const cacheKey of cache.keys()) {
100
102
  if (!cacheKey.startsWith(prefix) || !cacheKey.endsWith(suffix)) continue;
101
- if (Date.now() - entry.ts > CACHE_TTL_MS) {
102
- cache.delete(cacheKey);
103
- continue;
104
- }
103
+ const remoteJid = cacheKey.slice(prefix.length, cacheKey.length - suffix.length);
104
+ const meta = readCachedMessageMeta(cacheKey);
105
+ if (!meta) continue;
105
106
  const candidate = {
106
- remoteJid: cacheKey.slice(prefix.length, cacheKey.length - suffix.length),
107
- participant: entry.participant,
108
- participantE164: entry.participantE164,
109
- body: entry.body,
110
- media: entry.media,
111
- fromMe: entry.fromMe
107
+ remoteJid,
108
+ ...meta
112
109
  };
113
110
  if (!matchesQuotedConversationTarget(targetJid, candidate)) continue;
114
111
  if (matched) return;
@@ -150,15 +147,12 @@ function buildQuotedMessageOptions(params) {
150
147
  }
151
148
  //#endregion
152
149
  //#region extensions/whatsapp/src/group-session-key.ts
153
- function resolveWhatsAppGroupAccountThreadId(accountId) {
154
- return `whatsapp-account-${normalizeAccountId(accountId)}`;
155
- }
156
150
  function resolveWhatsAppGroupSessionKey(params) {
157
151
  const accountId = normalizeAccountId(params.accountId);
158
152
  if (accountId === DEFAULT_ACCOUNT_ID || !params.sessionKey.includes(":group:")) return params.sessionKey;
159
153
  return resolveThreadSessionKeys({
160
154
  baseSessionKey: params.sessionKey,
161
- threadId: resolveWhatsAppGroupAccountThreadId(accountId)
155
+ threadId: `whatsapp-account-${accountId}`
162
156
  }).sessionKey;
163
157
  }
164
158
  function resolveWhatsAppGroupSessionRoute(route) {
@@ -1,8 +1,8 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BBjsoOtd.mjs";
2
2
  import { a as resolveWhatsAppAccount } from "./accounts-F0vHuze2.mjs";
3
- import { y as restoreCredsFromBackupIfNeeded } from "./auth-store-D2rN-hP5.mjs";
4
- import { _ as renderQrTerminal, h as resolveWhatsAppSocketTiming, r as createWaSocket } from "./socket-close-DU7eerAa.mjs";
5
- import { a as closeWaSocketSoon, o as waitForWhatsAppLoginResult } from "./connection-controller-COkcq48K.mjs";
3
+ import { y as restoreCredsFromBackupIfNeeded } from "./auth-store-DOBi5BPe.mjs";
4
+ import { _ as renderQrTerminal, h as resolveWhatsAppSocketTiming, r as createWaSocket } from "./socket-close-C9OU9mVN.mjs";
5
+ import { a as closeWaSocketSoon, o as waitForWhatsAppLoginResult } from "./connection-controller-CejM7bhn.mjs";
6
6
  import { formatCliCommand } from "openclaw/plugin-sdk/cli-runtime";
7
7
  import { logInfo } from "openclaw/plugin-sdk/logging-core";
8
8
  import { danger, defaultRuntime, success } from "openclaw/plugin-sdk/runtime-env";
@@ -1,9 +1,9 @@
1
1
  import { a as resolveWhatsAppAccount } from "./accounts-F0vHuze2.mjs";
2
- import { c as logoutWeb, d as readWebAuthExistsForDecision, h as readWebSelfId, n as WHATSAPP_AUTH_UNSTABLE_CODE } from "./auth-store-D2rN-hP5.mjs";
2
+ import { c as logoutWeb, d as readWebAuthExistsForDecision, h as readWebSelfId, n as WHATSAPP_AUTH_UNSTABLE_CODE } from "./auth-store-DOBi5BPe.mjs";
3
3
  import { t as getActiveWebListener } from "./active-listener-CDjoX9QR.mjs";
4
- import { h as resolveWhatsAppSocketTiming, r as createWaSocket } from "./socket-close-DU7eerAa.mjs";
4
+ import { h as resolveWhatsAppSocketTiming, r as createWaSocket } from "./socket-close-C9OU9mVN.mjs";
5
5
  import { t as formatError } from "./session-errors-B8UcAnZN.mjs";
6
- import { i as closeWaSocket, o as waitForWhatsAppLoginResult, t as WHATSAPP_LOGGED_OUT_QR_MESSAGE } from "./connection-controller-COkcq48K.mjs";
6
+ import { i as closeWaSocket, o as waitForWhatsAppLoginResult, t as WHATSAPP_LOGGED_OUT_QR_MESSAGE } from "./connection-controller-CejM7bhn.mjs";
7
7
  import { logInfo } from "openclaw/plugin-sdk/logging-core";
8
8
  import { danger, defaultRuntime, info, success } from "openclaw/plugin-sdk/runtime-env";
9
9
  import { renderQrPngDataUrl } from "openclaw/plugin-sdk/media-runtime";
@@ -33,10 +33,16 @@ function notifyQrUpdate(login) {
33
33
  login.qrUpdate = createDeferred();
34
34
  previous.resolve();
35
35
  }
36
- function updateLoginQrState(login, qr) {
36
+ function updateLoginQrState(accountId, login, qr, notify = false) {
37
37
  login.qr = qr;
38
38
  login.qrVersion += 1;
39
- return login.qrVersion;
39
+ if (notify) notifyQrUpdate(login);
40
+ ensureQrDataUrl({
41
+ accountId,
42
+ loginId: login.id,
43
+ qr,
44
+ qrVersion: login.qrVersion
45
+ }).catch(() => {});
40
46
  }
41
47
  async function ensureQrDataUrl(params) {
42
48
  const current = activeLogins.get(params.accountId);
@@ -70,9 +76,6 @@ async function ensureQrDataUrl(params) {
70
76
  if (latest?.id === params.loginId && latest.qrRenderPromise === renderPromise) latest.qrRenderPromise = null;
71
77
  }
72
78
  }
73
- function renderLatestQrDataUrlInBackground(params) {
74
- ensureQrDataUrl(params).catch(() => {});
75
- }
76
79
  function attachLoginWaiter(accountId, login) {
77
80
  login.waitPromise = waitForWhatsAppLoginResult({
78
81
  sock: login.sock,
@@ -85,14 +88,7 @@ function attachLoginWaiter(accountId, login) {
85
88
  onQr: (qr) => {
86
89
  const current = activeLogins.get(accountId);
87
90
  if (!current || current.id !== login.id) return;
88
- const qrVersion = updateLoginQrState(current, qr);
89
- notifyQrUpdate(current);
90
- renderLatestQrDataUrlInBackground({
91
- accountId,
92
- loginId: login.id,
93
- qr,
94
- qrVersion
95
- });
91
+ updateLoginQrState(accountId, current, qr, true);
96
92
  },
97
93
  onSocketReplaced: (sock) => {
98
94
  const current = activeLogins.get(accountId);
@@ -121,13 +117,6 @@ function attachLoginWaiter(accountId, login) {
121
117
  });
122
118
  }
123
119
  async function waitForQrOrRecoveredLogin(params) {
124
- const qrResult = params.qrPromise.then((qr) => ({
125
- outcome: "qr",
126
- qr
127
- }), (err) => ({
128
- outcome: "failed",
129
- message: `Failed to get QR: ${String(err)}`
130
- }));
131
120
  const readLoginResult = (fallbackMessage) => {
132
121
  const current = activeLogins.get(params.accountId);
133
122
  if (current?.id !== params.login.id) return {
@@ -150,7 +139,7 @@ async function waitForQrOrRecoveredLogin(params) {
150
139
  });
151
140
  const qrUpdateResult = params.login.qrUpdate.promise.then(() => readLoginResult("WhatsApp QR update ended without an active QR."));
152
141
  return await Promise.race([
153
- qrResult,
142
+ params.qrResult,
154
143
  loginResult,
155
144
  qrUpdateResult
156
145
  ]);
@@ -190,7 +179,10 @@ async function startWebLoginWithQr(opts = {}) {
190
179
  await resetActiveLogin(account.accountId);
191
180
  const qrReady = createDeferred();
192
181
  const qrTimer = setTimeout(() => {
193
- qrReady.reject(/* @__PURE__ */ new Error("Timed out waiting for WhatsApp QR"));
182
+ qrReady.resolve({
183
+ outcome: "failed",
184
+ message: "Failed to get QR: Error: Timed out waiting for WhatsApp QR"
185
+ });
194
186
  }, resolveTimerTimeoutMs(opts.timeoutMs, 3e4, 5e3));
195
187
  let sock;
196
188
  let pendingQr = null;
@@ -212,17 +204,12 @@ async function startWebLoginWithQr(opts = {}) {
212
204
  onQr: (qr) => {
213
205
  pendingQr = qr;
214
206
  const current = activeLogins.get(account.accountId);
215
- if (current && current.id === loginId) {
216
- const qrVersion = updateLoginQrState(current, qr);
217
- renderLatestQrDataUrlInBackground({
218
- accountId: account.accountId,
219
- loginId,
220
- qr,
221
- qrVersion
222
- });
223
- }
207
+ if (current && current.id === loginId) updateLoginQrState(account.accountId, current, qr);
224
208
  clearTimeout(qrTimer);
225
- qrReady.resolve(qr);
209
+ qrReady.resolve({
210
+ outcome: "qr",
211
+ qr
212
+ });
226
213
  runtime.log(info("WhatsApp QR received."));
227
214
  }
228
215
  });
@@ -256,20 +243,12 @@ async function startWebLoginWithQr(opts = {}) {
256
243
  }
257
244
  operationOwner.current = nextLogin;
258
245
  activeLogins.set(account.accountId, nextLogin);
259
- if (pendingQr) {
260
- const qrVersion = updateLoginQrState(nextLogin, pendingQr);
261
- renderLatestQrDataUrlInBackground({
262
- accountId: account.accountId,
263
- loginId: nextLogin.id,
264
- qr: pendingQr,
265
- qrVersion
266
- });
267
- }
246
+ if (pendingQr) updateLoginQrState(account.accountId, nextLogin, pendingQr);
268
247
  attachLoginWaiter(account.accountId, nextLogin);
269
248
  const loginStartResult = await waitForQrOrRecoveredLogin({
270
249
  accountId: account.accountId,
271
250
  login: nextLogin,
272
- qrPromise: qrReady.promise
251
+ qrResult: qrReady.promise
273
252
  });
274
253
  clearTimeout(qrTimer);
275
254
  if (loginStartResult.outcome === "connected") {