@openclaw/whatsapp 2026.7.2-beta.7 → 2026.7.34

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 (435) hide show
  1. package/README.md +1 -1
  2. package/dist/{access-control-pZcxTmd5.js → .setup/access-control-C0jumQuO.mjs} +5 -4
  3. package/dist/.setup/account-config-6PTOSfaI.mjs +47 -0
  4. package/dist/{accounts-CSqLvCY5.js → .setup/accounts-Dw16pdNl.mjs} +9 -47
  5. package/dist/{action-runtime-BzfDFPbH.js → .setup/action-runtime-DLK_9v4r.mjs} +3 -3
  6. package/dist/{active-listener-BEjWsCNM.js → .setup/active-listener-CloPBx0S.mjs} +3 -3
  7. package/dist/{agent-tools-login-DE9MU98T.js → .setup/agent-tools-login-DINqgaYo.mjs} +19 -7
  8. package/dist/{approval-handler.runtime-DrA59QSA.js → .setup/approval-handler.runtime-DtJZbu3y.mjs} +14 -20
  9. package/dist/{approval-resolver-DoeBBt22.js → .setup/approval-resolver-DF-lu8k5.mjs} +1 -2
  10. package/dist/{auth-store-DcEpIOmE.js → .setup/auth-store-BZKGa0tW.mjs} +25 -29
  11. package/dist/{channel-Dg62olhy.js → .setup/channel-9WGjBznd.mjs} +117 -132
  12. package/dist/{channel-react-action-J_YtyMGX.js → .setup/channel-react-action-mvIbAFhn.mjs} +15 -12
  13. package/dist/{channel.runtime-BP0xNmLi.js → .setup/channel.runtime-DmmMgRJQ.mjs} +6 -6
  14. package/dist/.setup/channel.setup-ByBYSeLd.mjs +22 -0
  15. package/dist/.setup/config-schema-mBX2nmn1.mjs +47 -0
  16. package/dist/{connection-controller-BOB2MVKY.js → .setup/connection-controller-Dt62u6fI.mjs} +29 -226
  17. package/dist/.setup/connection-controller-registry-TSX_udJp.mjs +22 -0
  18. package/dist/{constants-HU41RHGI.js → .setup/constants-C7m81BNe.mjs} +1 -1
  19. package/dist/.setup/directory-config-B7Obxrq2.mjs +37 -0
  20. package/dist/.setup/doctor-By3SB4lm.mjs +48 -0
  21. package/dist/{group-session-key-DVMZlO3x.js → .setup/group-session-key-CEwPRRRK.mjs} +5 -38
  22. package/dist/{identity-CPrT5aEU.js → .setup/identity-CDB1bT-p.mjs} +2 -2
  23. package/dist/.setup/legacy-session-surface-api-B2szjq4r.mjs +2 -0
  24. package/dist/.setup/legacy-state-migrations-api-DXCxufZz.mjs +3 -0
  25. package/dist/{login-CvY2Dhch.js → .setup/login-7b3M0iBp.mjs} +12 -51
  26. package/dist/{login-qr-Bncpb6js.js → .setup/login-qr-CbyA4QX5.mjs} +47 -23
  27. package/dist/{monitor-CfkaUSL2.js → .setup/monitor-Dh6Di_YO.mjs} +1451 -1843
  28. package/dist/.setup/normalize-eddWWsNV.mjs +2 -0
  29. package/dist/{normalize-target-CugRyONv.js → .setup/normalize-target-bVWjgftN.mjs} +10 -18
  30. package/dist/{resolve-outbound-target-1GqbT1uX.js → .setup/resolve-outbound-target-oI7VpU4w.mjs} +1 -1
  31. package/dist/.setup/runtime-BfAdAEYT.mjs +8 -0
  32. package/dist/.setup/send-BQjMC41n.mjs +777 -0
  33. package/dist/{send-api-7wk6eQyW.js → .setup/send-api-BiAkPLr3.mjs} +155 -105
  34. package/dist/{session-errors-JuazczrA.js → .setup/session-errors-BAj9D2La.mjs} +1 -2
  35. package/dist/.setup/session-vUI41Jel.mjs +252 -0
  36. package/dist/.setup/session.runtime-B-V3rXP6.mjs +12 -0
  37. package/dist/{shared-CAxd15bp.js → .setup/setup-core--FfzntMG.mjs} +94 -63
  38. package/dist/{setup-finalize-BZucx24W.js → .setup/setup-finalize-DCruIciL.mjs} +17 -46
  39. package/dist/.setup/setup-plugin-api-B6ck_20D.mjs +3 -0
  40. package/dist/{setup-surface-BkVcd769.js → .setup/setup-surface-Zvj2cLzz.mjs} +4 -4
  41. package/dist/.setup/socket-timing-DhbVFjah.mjs +77 -0
  42. package/dist/{state-migrations-CAMTrs2U.js → .setup/state-migrations-D_BmQUR9.mjs} +8 -1
  43. package/dist/.setup/targets-runtime-C-GiVn6Y.mjs +188 -0
  44. package/dist/.setup/text-runtime-CUrq1mFq.mjs +4 -0
  45. package/dist/action-runtime-api.js +1 -1
  46. package/dist/action-runtime.runtime.js +1 -1
  47. package/dist/{call-tool-api.js → agent-tools-api.js} +26 -11
  48. package/dist/api.js +27 -17
  49. package/dist/auth-presence.js +1 -1
  50. package/dist/channel-config-api.js +1 -1
  51. package/dist/channel-plugin-api.js +1 -1
  52. package/dist/constants.js +2 -0
  53. package/dist/contract-api.js +5 -5
  54. package/dist/directory-contract-api.js +1 -1
  55. package/dist/doctor-contract-api.js +5 -46
  56. package/dist/index.js +4 -4
  57. package/dist/legacy-session-surface-api.js +1 -1
  58. package/dist/legacy-state-migrations-api.js +1 -1
  59. package/dist/light-runtime-api.js +4 -4
  60. package/dist/login-qr-runtime.js +1 -1
  61. package/dist/runtime-api.js +14 -14
  62. package/dist/runtime-setter-api.js +1 -1
  63. package/dist/security-contract-api.js +1 -1
  64. package/dist/setup-entry.js +4 -3
  65. package/dist/setup-plugin-api.js +1 -1
  66. package/dist/targets.js +2 -0
  67. package/node_modules/audio-decode/node_modules/@thi.ng/bitstream/package.json +4 -4
  68. package/node_modules/audio-decode/node_modules/@thi.ng/errors/package.json +4 -4
  69. package/node_modules/audio-decode/node_modules/audio-type/package.json +2 -3
  70. package/node_modules/baileys/node_modules/@protobufjs/aspromise/LICENSE +26 -0
  71. package/node_modules/baileys/node_modules/@protobufjs/aspromise/README.md +13 -0
  72. package/node_modules/baileys/node_modules/{protobufjs/src/util/aspromise.d.ts → @protobufjs/aspromise/index.d.ts} +13 -13
  73. package/node_modules/baileys/node_modules/{protobufjs/src/util/aspromise.js → @protobufjs/aspromise/index.js} +52 -52
  74. package/node_modules/baileys/node_modules/@protobufjs/aspromise/package.json +21 -0
  75. package/node_modules/baileys/node_modules/@protobufjs/aspromise/tests/index.js +130 -0
  76. package/node_modules/baileys/node_modules/@protobufjs/base64/LICENSE +26 -0
  77. package/node_modules/baileys/node_modules/@protobufjs/base64/README.md +19 -0
  78. package/node_modules/baileys/node_modules/{protobufjs/src/util/base64.d.ts → @protobufjs/base64/index.d.ts} +32 -32
  79. package/node_modules/baileys/node_modules/{protobufjs/src/util/base64.js → @protobufjs/base64/index.js} +139 -146
  80. package/node_modules/baileys/node_modules/@protobufjs/base64/package.json +21 -0
  81. package/node_modules/baileys/node_modules/@protobufjs/base64/tests/index.js +46 -0
  82. package/node_modules/baileys/node_modules/@protobufjs/codegen/LICENSE +26 -0
  83. package/node_modules/baileys/node_modules/@protobufjs/codegen/README.md +49 -0
  84. package/node_modules/baileys/node_modules/{protobufjs/src/util/codegen.d.ts → @protobufjs/codegen/index.d.ts} +31 -31
  85. package/node_modules/baileys/node_modules/{protobufjs/src/util/codegen.js → @protobufjs/codegen/index.js} +112 -118
  86. package/node_modules/baileys/node_modules/@protobufjs/codegen/package.json +13 -0
  87. package/node_modules/baileys/node_modules/@protobufjs/codegen/tests/index.js +13 -0
  88. package/node_modules/baileys/node_modules/@protobufjs/eventemitter/CHANGELOG.md +8 -0
  89. package/node_modules/baileys/node_modules/@protobufjs/eventemitter/LICENSE +26 -0
  90. package/node_modules/baileys/node_modules/@protobufjs/eventemitter/README.md +22 -0
  91. package/node_modules/baileys/node_modules/{protobufjs/src/util/eventemitter.d.ts → @protobufjs/eventemitter/index.d.ts} +45 -45
  92. package/node_modules/baileys/node_modules/{protobufjs/src/util/eventemitter.js → @protobufjs/eventemitter/index.js} +86 -86
  93. package/node_modules/baileys/node_modules/@protobufjs/eventemitter/package.json +21 -0
  94. package/node_modules/baileys/node_modules/@protobufjs/eventemitter/tests/index.js +83 -0
  95. package/node_modules/baileys/node_modules/@protobufjs/fetch/CHANGELOG.md +8 -0
  96. package/node_modules/baileys/node_modules/@protobufjs/fetch/LICENSE +26 -0
  97. package/node_modules/baileys/node_modules/@protobufjs/fetch/README.md +13 -0
  98. package/node_modules/baileys/node_modules/{protobufjs/src/util/fetch.d.ts → @protobufjs/fetch/index.d.ts} +56 -56
  99. package/node_modules/baileys/node_modules/{protobufjs/src/util/fetch.js → @protobufjs/fetch/index.js} +112 -112
  100. package/node_modules/baileys/node_modules/@protobufjs/fetch/package.json +27 -0
  101. package/node_modules/baileys/node_modules/@protobufjs/fetch/tests/data/file.txt +1 -0
  102. package/node_modules/baileys/node_modules/@protobufjs/fetch/tests/index.js +158 -0
  103. package/node_modules/baileys/node_modules/@protobufjs/fetch/util/fs.js +11 -0
  104. package/node_modules/baileys/node_modules/@protobufjs/float/LICENSE +26 -0
  105. package/node_modules/baileys/node_modules/@protobufjs/float/README.md +102 -0
  106. package/node_modules/baileys/node_modules/@protobufjs/float/bench/index.js +87 -0
  107. package/node_modules/baileys/node_modules/@protobufjs/float/bench/suite.js +46 -0
  108. package/node_modules/baileys/node_modules/{protobufjs/src/util/float.js → @protobufjs/float/index.js} +335 -335
  109. package/node_modules/baileys/node_modules/@protobufjs/float/package.json +26 -0
  110. package/node_modules/baileys/node_modules/@protobufjs/float/tests/index.js +100 -0
  111. package/node_modules/baileys/node_modules/@protobufjs/inquire/CHANGELOG.md +8 -0
  112. package/node_modules/baileys/node_modules/@protobufjs/inquire/LICENSE +26 -0
  113. package/node_modules/baileys/node_modules/@protobufjs/inquire/README.md +13 -0
  114. package/node_modules/baileys/node_modules/@protobufjs/inquire/index.d.ts +10 -0
  115. package/node_modules/baileys/node_modules/@protobufjs/inquire/index.js +38 -0
  116. package/node_modules/baileys/node_modules/@protobufjs/inquire/package.json +21 -0
  117. package/node_modules/baileys/node_modules/@protobufjs/inquire/tests/data/array.js +1 -0
  118. package/node_modules/baileys/node_modules/@protobufjs/inquire/tests/data/emptyArray.js +1 -0
  119. package/node_modules/baileys/node_modules/@protobufjs/inquire/tests/data/emptyObject.js +1 -0
  120. package/node_modules/baileys/node_modules/@protobufjs/inquire/tests/data/object.js +1 -0
  121. package/node_modules/baileys/node_modules/@protobufjs/inquire/tests/index.js +20 -0
  122. package/node_modules/baileys/node_modules/@protobufjs/path/LICENSE +26 -0
  123. package/node_modules/baileys/node_modules/@protobufjs/path/README.md +19 -0
  124. package/node_modules/baileys/node_modules/{protobufjs/src/util/path.d.ts → @protobufjs/path/index.d.ts} +22 -22
  125. package/node_modules/baileys/node_modules/{protobufjs/src/util/path.js → @protobufjs/path/index.js} +65 -100
  126. package/node_modules/baileys/node_modules/@protobufjs/path/package.json +21 -0
  127. package/node_modules/baileys/node_modules/@protobufjs/path/tests/index.js +60 -0
  128. package/node_modules/baileys/node_modules/@protobufjs/pool/.npmignore +3 -0
  129. package/node_modules/baileys/node_modules/@protobufjs/pool/LICENSE +26 -0
  130. package/node_modules/baileys/node_modules/@protobufjs/pool/README.md +13 -0
  131. package/node_modules/baileys/node_modules/{protobufjs/src/util/pool.d.ts → @protobufjs/pool/index.d.ts} +32 -32
  132. package/node_modules/baileys/node_modules/{protobufjs/src/util/pool.js → @protobufjs/pool/index.js} +48 -48
  133. package/node_modules/baileys/node_modules/@protobufjs/pool/package.json +21 -0
  134. package/node_modules/baileys/node_modules/@protobufjs/pool/tests/index.js +33 -0
  135. package/node_modules/baileys/node_modules/@protobufjs/utf8/LICENSE +26 -0
  136. package/node_modules/baileys/node_modules/@protobufjs/utf8/README.md +20 -0
  137. package/node_modules/baileys/node_modules/{protobufjs/src/util/utf8.d.ts → @protobufjs/utf8/index.d.ts} +24 -24
  138. package/node_modules/baileys/node_modules/{protobufjs/src/util/utf8.js → @protobufjs/utf8/index.js} +104 -190
  139. package/node_modules/baileys/node_modules/@protobufjs/utf8/package.json +21 -0
  140. package/node_modules/baileys/node_modules/@protobufjs/utf8/tests/data/surrogate_pair_bug.txt +207 -0
  141. package/node_modules/baileys/node_modules/@protobufjs/utf8/tests/data/utf8.txt +216 -0
  142. package/node_modules/baileys/node_modules/@protobufjs/utf8/tests/index.js +74 -0
  143. package/node_modules/baileys/node_modules/@types/node/LICENSE +21 -0
  144. package/node_modules/baileys/node_modules/@types/node/README.md +15 -0
  145. package/node_modules/baileys/node_modules/@types/node/assert/strict.d.ts +68 -0
  146. package/node_modules/baileys/node_modules/@types/node/assert.d.ts +1077 -0
  147. package/node_modules/baileys/node_modules/@types/node/async_hooks.d.ts +711 -0
  148. package/node_modules/baileys/node_modules/@types/node/buffer.buffer.d.ts +466 -0
  149. package/node_modules/baileys/node_modules/@types/node/buffer.d.ts +1799 -0
  150. package/node_modules/baileys/node_modules/@types/node/child_process.d.ts +1362 -0
  151. package/node_modules/baileys/node_modules/@types/node/cluster.d.ts +432 -0
  152. package/node_modules/baileys/node_modules/@types/node/console.d.ts +93 -0
  153. package/node_modules/baileys/node_modules/@types/node/constants.d.ts +14 -0
  154. package/node_modules/baileys/node_modules/@types/node/crypto.d.ts +3954 -0
  155. package/node_modules/baileys/node_modules/@types/node/dgram.d.ts +537 -0
  156. package/node_modules/baileys/node_modules/@types/node/diagnostics_channel.d.ts +794 -0
  157. package/node_modules/baileys/node_modules/@types/node/dns/promises.d.ts +497 -0
  158. package/node_modules/baileys/node_modules/@types/node/dns.d.ts +876 -0
  159. package/node_modules/baileys/node_modules/@types/node/domain.d.ts +150 -0
  160. package/node_modules/baileys/node_modules/@types/node/events.d.ts +1008 -0
  161. package/node_modules/baileys/node_modules/@types/node/ffi.d.ts +486 -0
  162. package/node_modules/baileys/node_modules/@types/node/fs/promises.d.ts +1471 -0
  163. package/node_modules/baileys/node_modules/@types/node/fs.d.ts +4786 -0
  164. package/node_modules/baileys/node_modules/@types/node/globals.d.ts +150 -0
  165. package/node_modules/baileys/node_modules/@types/node/globals.typedarray.d.ts +101 -0
  166. package/node_modules/baileys/node_modules/@types/node/http.d.ts +2172 -0
  167. package/node_modules/baileys/node_modules/@types/node/http2.d.ts +2489 -0
  168. package/node_modules/baileys/node_modules/@types/node/https.d.ts +400 -0
  169. package/node_modules/baileys/node_modules/@types/node/index.d.ts +115 -0
  170. package/node_modules/baileys/node_modules/@types/node/inspector/promises.d.ts +35 -0
  171. package/node_modules/baileys/node_modules/@types/node/inspector.d.ts +264 -0
  172. package/node_modules/baileys/node_modules/@types/node/inspector.generated.d.ts +4406 -0
  173. package/node_modules/baileys/node_modules/@types/node/module.d.ts +726 -0
  174. package/node_modules/baileys/node_modules/@types/node/net.d.ts +970 -0
  175. package/node_modules/baileys/node_modules/@types/node/os.d.ts +498 -0
  176. package/node_modules/baileys/node_modules/@types/node/package.json +155 -0
  177. package/node_modules/baileys/node_modules/@types/node/path/posix.d.ts +8 -0
  178. package/node_modules/baileys/node_modules/@types/node/path/win32.d.ts +8 -0
  179. package/node_modules/baileys/node_modules/@types/node/path.d.ts +178 -0
  180. package/node_modules/baileys/node_modules/@types/node/perf_hooks.d.ts +604 -0
  181. package/node_modules/baileys/node_modules/@types/node/process.d.ts +2217 -0
  182. package/node_modules/baileys/node_modules/@types/node/punycode.d.ts +89 -0
  183. package/node_modules/baileys/node_modules/@types/node/querystring.d.ts +139 -0
  184. package/node_modules/baileys/node_modules/@types/node/quic.d.ts +978 -0
  185. package/node_modules/baileys/node_modules/@types/node/readline/promises.d.ts +158 -0
  186. package/node_modules/baileys/node_modules/@types/node/readline.d.ts +508 -0
  187. package/node_modules/baileys/node_modules/@types/node/repl.d.ts +420 -0
  188. package/node_modules/baileys/node_modules/@types/node/sea.d.ts +47 -0
  189. package/node_modules/baileys/node_modules/@types/node/sqlite.d.ts +1123 -0
  190. package/node_modules/baileys/node_modules/@types/node/stream/consumers.d.ts +114 -0
  191. package/node_modules/baileys/node_modules/@types/node/stream/iter.d.ts +451 -0
  192. package/node_modules/baileys/node_modules/@types/node/stream/promises.d.ts +211 -0
  193. package/node_modules/baileys/node_modules/@types/node/stream/web.d.ts +300 -0
  194. package/node_modules/baileys/node_modules/@types/node/stream.d.ts +1806 -0
  195. package/node_modules/baileys/node_modules/@types/node/string_decoder.d.ts +27 -0
  196. package/node_modules/baileys/node_modules/@types/node/test/reporters.d.ts +59 -0
  197. package/node_modules/baileys/node_modules/@types/node/test.d.ts +2389 -0
  198. package/node_modules/baileys/node_modules/@types/node/timers/promises.d.ts +93 -0
  199. package/node_modules/baileys/node_modules/@types/node/timers.d.ts +149 -0
  200. package/node_modules/baileys/node_modules/@types/node/tls.d.ts +1193 -0
  201. package/node_modules/baileys/node_modules/@types/node/trace_events.d.ts +103 -0
  202. package/node_modules/baileys/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +462 -0
  203. package/node_modules/baileys/node_modules/@types/node/ts5.6/compatibility/float16array.d.ts +71 -0
  204. package/node_modules/baileys/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +36 -0
  205. package/node_modules/baileys/node_modules/@types/node/ts5.6/index.d.ts +117 -0
  206. package/node_modules/baileys/node_modules/@types/node/ts5.7/compatibility/float16array.d.ts +72 -0
  207. package/node_modules/baileys/node_modules/@types/node/ts5.7/index.d.ts +117 -0
  208. package/node_modules/baileys/node_modules/@types/node/tty.d.ts +225 -0
  209. package/node_modules/baileys/node_modules/@types/node/url.d.ts +556 -0
  210. package/node_modules/baileys/node_modules/@types/node/util/types.d.ts +558 -0
  211. package/node_modules/baileys/node_modules/@types/node/util.d.ts +1677 -0
  212. package/node_modules/baileys/node_modules/@types/node/v8.d.ts +1062 -0
  213. package/node_modules/baileys/node_modules/@types/node/vm.d.ts +1136 -0
  214. package/node_modules/baileys/node_modules/@types/node/wasi.d.ts +131 -0
  215. package/node_modules/baileys/node_modules/@types/node/web-globals/abortcontroller.d.ts +59 -0
  216. package/node_modules/baileys/node_modules/@types/node/web-globals/blob.d.ts +23 -0
  217. package/node_modules/baileys/node_modules/@types/node/web-globals/console.d.ts +9 -0
  218. package/node_modules/baileys/node_modules/@types/node/web-globals/crypto.d.ts +39 -0
  219. package/node_modules/baileys/node_modules/@types/node/web-globals/domexception.d.ts +83 -0
  220. package/node_modules/baileys/node_modules/@types/node/web-globals/encoding.d.ts +11 -0
  221. package/node_modules/baileys/node_modules/@types/node/web-globals/events.d.ts +106 -0
  222. package/node_modules/baileys/node_modules/@types/node/web-globals/fetch.d.ts +69 -0
  223. package/node_modules/baileys/node_modules/@types/node/web-globals/importmeta.d.ts +13 -0
  224. package/node_modules/baileys/node_modules/@types/node/web-globals/messaging.d.ts +23 -0
  225. package/node_modules/baileys/node_modules/@types/node/web-globals/navigator.d.ts +25 -0
  226. package/node_modules/baileys/node_modules/@types/node/web-globals/performance.d.ts +45 -0
  227. package/node_modules/baileys/node_modules/@types/node/web-globals/storage.d.ts +24 -0
  228. package/node_modules/baileys/node_modules/@types/node/web-globals/streams.d.ts +115 -0
  229. package/node_modules/baileys/node_modules/@types/node/web-globals/timers.d.ts +44 -0
  230. package/node_modules/baileys/node_modules/@types/node/web-globals/url.d.ts +24 -0
  231. package/node_modules/baileys/node_modules/@types/node/worker_threads.d.ts +669 -0
  232. package/node_modules/baileys/node_modules/@types/node/zlib/iter.d.ts +131 -0
  233. package/node_modules/baileys/node_modules/@types/node/zlib.d.ts +589 -0
  234. package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/browser/index.d.ts.map +1 -1
  235. package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/browser/index.js +4 -11
  236. package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/browser/index.js.map +1 -1
  237. package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/browser/index.min.js +1 -1
  238. package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/browser/index.min.js.map +3 -3
  239. package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/index.d.ts.map +1 -1
  240. package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/index.js +4 -11
  241. package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/index.js.map +1 -1
  242. package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/index.min.js +1 -1
  243. package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/index.min.js.map +3 -3
  244. package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/node/index.d.ts.map +1 -1
  245. package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/node/index.js +4 -11
  246. package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/node/index.js.map +1 -1
  247. package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/node/index.min.js +1 -1
  248. package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/node/index.min.js.map +3 -3
  249. package/node_modules/baileys/node_modules/lru-cache/dist/esm/browser/index.d.ts.map +1 -1
  250. package/node_modules/baileys/node_modules/lru-cache/dist/esm/browser/index.js +4 -11
  251. package/node_modules/baileys/node_modules/lru-cache/dist/esm/browser/index.js.map +1 -1
  252. package/node_modules/baileys/node_modules/lru-cache/dist/esm/browser/index.min.js +1 -1
  253. package/node_modules/baileys/node_modules/lru-cache/dist/esm/browser/index.min.js.map +3 -3
  254. package/node_modules/baileys/node_modules/lru-cache/dist/esm/index.d.ts.map +1 -1
  255. package/node_modules/baileys/node_modules/lru-cache/dist/esm/index.js +4 -11
  256. package/node_modules/baileys/node_modules/lru-cache/dist/esm/index.js.map +1 -1
  257. package/node_modules/baileys/node_modules/lru-cache/dist/esm/index.min.js +1 -1
  258. package/node_modules/baileys/node_modules/lru-cache/dist/esm/index.min.js.map +3 -3
  259. package/node_modules/baileys/node_modules/lru-cache/dist/esm/node/index.d.ts.map +1 -1
  260. package/node_modules/baileys/node_modules/lru-cache/dist/esm/node/index.js +4 -11
  261. package/node_modules/baileys/node_modules/lru-cache/dist/esm/node/index.js.map +1 -1
  262. package/node_modules/baileys/node_modules/lru-cache/dist/esm/node/index.min.js +1 -1
  263. package/node_modules/baileys/node_modules/lru-cache/dist/esm/node/index.min.js.map +3 -3
  264. package/node_modules/baileys/node_modules/lru-cache/package.json +1 -1
  265. package/node_modules/baileys/node_modules/music-metadata/lib/common/Util.d.ts +1 -1
  266. package/node_modules/baileys/node_modules/music-metadata/lib/common/Util.js +1 -7
  267. package/node_modules/baileys/node_modules/music-metadata/lib/id3v2/FrameHeader.js +3 -23
  268. package/node_modules/baileys/node_modules/music-metadata/lib/id3v2/FrameParser.js +2 -2
  269. package/node_modules/baileys/node_modules/music-metadata/lib/id3v2/ID3v2Token.js +1 -1
  270. package/node_modules/baileys/node_modules/music-metadata/lib/mp4/AtomToken.js +13 -38
  271. package/node_modules/baileys/node_modules/music-metadata/lib/mpeg/MpegParser.js +1 -1
  272. package/node_modules/baileys/node_modules/music-metadata/package.json +6 -6
  273. package/node_modules/baileys/node_modules/p-queue/dist/index.js +27 -37
  274. package/node_modules/baileys/node_modules/p-queue/package.json +1 -1
  275. package/node_modules/baileys/node_modules/protobufjs/README.md +553 -266
  276. package/node_modules/baileys/node_modules/protobufjs/dist/light/protobuf.js +1985 -3177
  277. package/node_modules/baileys/node_modules/protobufjs/dist/light/protobuf.js.map +1 -1
  278. package/node_modules/baileys/node_modules/protobufjs/dist/light/protobuf.min.js +3 -3
  279. package/node_modules/baileys/node_modules/protobufjs/dist/light/protobuf.min.js.map +1 -1
  280. package/node_modules/baileys/node_modules/protobufjs/dist/minimal/protobuf.js +1244 -1966
  281. package/node_modules/baileys/node_modules/protobufjs/dist/minimal/protobuf.js.map +1 -1
  282. package/node_modules/baileys/node_modules/protobufjs/dist/minimal/protobuf.min.js +3 -3
  283. package/node_modules/baileys/node_modules/protobufjs/dist/minimal/protobuf.min.js.map +1 -1
  284. package/node_modules/baileys/node_modules/protobufjs/dist/protobuf.js +2005 -3330
  285. package/node_modules/baileys/node_modules/protobufjs/dist/protobuf.js.map +1 -1
  286. package/node_modules/baileys/node_modules/protobufjs/dist/protobuf.min.js +3 -3
  287. package/node_modules/baileys/node_modules/protobufjs/dist/protobuf.min.js.map +1 -1
  288. package/node_modules/baileys/node_modules/protobufjs/ext/descriptor/README.md +70 -3
  289. package/node_modules/baileys/node_modules/protobufjs/ext/descriptor/index.d.ts +193 -0
  290. package/node_modules/baileys/node_modules/protobufjs/ext/descriptor/index.js +1185 -1
  291. package/node_modules/baileys/node_modules/protobufjs/ext/descriptor/test.js +54 -0
  292. package/node_modules/baileys/node_modules/protobufjs/google/api/annotations.json +1 -3
  293. package/node_modules/baileys/node_modules/protobufjs/google/api/http.json +1 -2
  294. package/node_modules/baileys/node_modules/protobufjs/google/protobuf/api.json +6 -12
  295. package/node_modules/baileys/node_modules/protobufjs/google/protobuf/descriptor.json +87 -170
  296. package/node_modules/baileys/node_modules/protobufjs/google/protobuf/descriptor.proto +8 -0
  297. package/node_modules/baileys/node_modules/protobufjs/google/protobuf/source_context.json +1 -2
  298. package/node_modules/baileys/node_modules/protobufjs/google/protobuf/type.json +7 -14
  299. package/node_modules/baileys/node_modules/protobufjs/index.d.ts +703 -1066
  300. package/node_modules/baileys/node_modules/protobufjs/package.json +52 -25
  301. package/node_modules/baileys/node_modules/protobufjs/scripts/postinstall.js +32 -0
  302. package/node_modules/baileys/node_modules/protobufjs/src/common.js +8 -14
  303. package/node_modules/baileys/node_modules/protobufjs/src/converter.js +51 -85
  304. package/node_modules/baileys/node_modules/protobufjs/src/decoder.js +61 -205
  305. package/node_modules/baileys/node_modules/protobufjs/src/encoder.js +7 -27
  306. package/node_modules/baileys/node_modules/protobufjs/src/enum.js +5 -18
  307. package/node_modules/baileys/node_modules/protobufjs/src/field.js +19 -71
  308. package/node_modules/baileys/node_modules/protobufjs/src/index-light.js +29 -29
  309. package/node_modules/baileys/node_modules/protobufjs/src/index-minimal.js +13 -12
  310. package/node_modules/baileys/node_modules/protobufjs/src/index.js +6 -6
  311. package/node_modules/baileys/node_modules/protobufjs/src/mapfield.js +8 -26
  312. package/node_modules/baileys/node_modules/protobufjs/src/message.js +11 -5
  313. package/node_modules/baileys/node_modules/protobufjs/src/method.js +7 -30
  314. package/node_modules/baileys/node_modules/protobufjs/src/namespace.js +10 -26
  315. package/node_modules/baileys/node_modules/protobufjs/src/object.js +31 -41
  316. package/node_modules/baileys/node_modules/protobufjs/src/oneof.js +1 -12
  317. package/node_modules/baileys/node_modules/protobufjs/src/parse.js +47 -169
  318. package/node_modules/baileys/node_modules/protobufjs/src/reader.js +50 -412
  319. package/node_modules/baileys/node_modules/protobufjs/src/reader_buffer.js +5 -31
  320. package/node_modules/baileys/node_modules/protobufjs/src/root.js +4 -16
  321. package/node_modules/baileys/node_modules/protobufjs/src/rpc/service.js +5 -18
  322. package/node_modules/baileys/node_modules/protobufjs/src/service.js +2 -15
  323. package/node_modules/baileys/node_modules/protobufjs/src/tokenize.js +1 -6
  324. package/node_modules/baileys/node_modules/protobufjs/src/type.js +36 -80
  325. package/node_modules/baileys/node_modules/protobufjs/src/typescript.jsdoc +15 -0
  326. package/node_modules/baileys/node_modules/protobufjs/src/util/longbits.js +6 -10
  327. package/node_modules/baileys/node_modules/protobufjs/src/util/minimal.js +54 -71
  328. package/node_modules/baileys/node_modules/protobufjs/src/util.js +17 -51
  329. package/node_modules/baileys/node_modules/protobufjs/src/verifier.js +14 -19
  330. package/node_modules/baileys/node_modules/protobufjs/src/wrappers.js +3 -2
  331. package/node_modules/baileys/node_modules/protobufjs/src/writer.js +191 -424
  332. package/node_modules/baileys/node_modules/protobufjs/src/writer_buffer.js +26 -41
  333. package/node_modules/baileys/node_modules/protobufjs/tsconfig.json +5 -3
  334. package/node_modules/baileys/node_modules/undici-types/LICENSE +21 -0
  335. package/node_modules/baileys/node_modules/undici-types/README.md +6 -0
  336. package/node_modules/baileys/node_modules/undici-types/agent.d.ts +30 -0
  337. package/node_modules/baileys/node_modules/undici-types/api.d.ts +43 -0
  338. package/node_modules/baileys/node_modules/undici-types/balanced-pool.d.ts +30 -0
  339. package/node_modules/baileys/node_modules/undici-types/cache-interceptor.d.ts +179 -0
  340. package/node_modules/baileys/node_modules/undici-types/cache.d.ts +36 -0
  341. package/node_modules/baileys/node_modules/undici-types/client-stats.d.ts +15 -0
  342. package/node_modules/baileys/node_modules/undici-types/client.d.ts +129 -0
  343. package/node_modules/baileys/node_modules/undici-types/connector.d.ts +36 -0
  344. package/node_modules/baileys/node_modules/undici-types/content-type.d.ts +21 -0
  345. package/node_modules/baileys/node_modules/undici-types/cookies.d.ts +30 -0
  346. package/node_modules/baileys/node_modules/undici-types/diagnostics-channel.d.ts +74 -0
  347. package/node_modules/baileys/node_modules/undici-types/dispatcher.d.ts +253 -0
  348. package/node_modules/baileys/node_modules/undici-types/dispatcher1-wrapper.d.ts +7 -0
  349. package/node_modules/baileys/node_modules/undici-types/env-http-proxy-agent.d.ts +22 -0
  350. package/node_modules/baileys/node_modules/undici-types/errors.d.ts +177 -0
  351. package/node_modules/baileys/node_modules/undici-types/eventsource.d.ts +66 -0
  352. package/node_modules/baileys/node_modules/undici-types/fetch.d.ts +231 -0
  353. package/node_modules/baileys/node_modules/undici-types/formdata.d.ts +108 -0
  354. package/node_modules/baileys/node_modules/undici-types/global-dispatcher.d.ts +9 -0
  355. package/node_modules/baileys/node_modules/undici-types/global-origin.d.ts +7 -0
  356. package/node_modules/baileys/node_modules/undici-types/h2c-client.d.ts +73 -0
  357. package/node_modules/baileys/node_modules/undici-types/handlers.d.ts +14 -0
  358. package/node_modules/baileys/node_modules/undici-types/header.d.ts +165 -0
  359. package/node_modules/baileys/node_modules/undici-types/index.d.ts +93 -0
  360. package/node_modules/baileys/node_modules/undici-types/interceptors.d.ts +80 -0
  361. package/node_modules/baileys/node_modules/undici-types/mock-agent.d.ts +68 -0
  362. package/node_modules/baileys/node_modules/undici-types/mock-call-history.d.ts +111 -0
  363. package/node_modules/baileys/node_modules/undici-types/mock-client.d.ts +27 -0
  364. package/node_modules/baileys/node_modules/undici-types/mock-errors.d.ts +12 -0
  365. package/node_modules/baileys/node_modules/undici-types/mock-interceptor.d.ts +94 -0
  366. package/node_modules/baileys/node_modules/undici-types/mock-pool.d.ts +27 -0
  367. package/node_modules/baileys/node_modules/undici-types/package.json +55 -0
  368. package/node_modules/baileys/node_modules/undici-types/patch.d.ts +29 -0
  369. package/node_modules/baileys/node_modules/undici-types/pool-stats.d.ts +19 -0
  370. package/node_modules/baileys/node_modules/undici-types/pool.d.ts +39 -0
  371. package/node_modules/baileys/node_modules/undici-types/proxy-agent.d.ts +29 -0
  372. package/node_modules/baileys/node_modules/undici-types/readable.d.ts +68 -0
  373. package/node_modules/baileys/node_modules/undici-types/retry-agent.d.ts +8 -0
  374. package/node_modules/baileys/node_modules/undici-types/retry-handler.d.ts +125 -0
  375. package/node_modules/baileys/node_modules/undici-types/round-robin-pool.d.ts +39 -0
  376. package/node_modules/baileys/node_modules/undici-types/snapshot-agent.d.ts +113 -0
  377. package/node_modules/baileys/node_modules/undici-types/socks5-proxy-agent.d.ts +25 -0
  378. package/node_modules/baileys/node_modules/undici-types/util.d.ts +18 -0
  379. package/node_modules/baileys/node_modules/undici-types/utility.d.ts +7 -0
  380. package/node_modules/baileys/node_modules/undici-types/webidl.d.ts +346 -0
  381. package/node_modules/baileys/node_modules/undici-types/websocket.d.ts +188 -0
  382. package/node_modules/baileys/node_modules/ws/lib/permessage-deflate.js +3 -1
  383. package/node_modules/baileys/node_modules/ws/package.json +1 -1
  384. package/node_modules/typebox/build/compile/validator.d.mts +4 -1
  385. package/node_modules/typebox/build/guard/guard.d.mts +1 -1
  386. package/node_modules/typebox/build/guard/guard.mjs +2 -5
  387. package/node_modules/typebox/build/guard/string.mjs +4 -16
  388. package/node_modules/typebox/build/schema/engine/_functions.mjs +15 -34
  389. package/node_modules/typebox/build/type/action/readonly_object.d.mts +0 -5
  390. package/node_modules/typebox/build/type/action/readonly_object.mjs +0 -8
  391. package/node_modules/typebox/build/typebox.d.mts +1 -1
  392. package/node_modules/typebox/build/typebox.mjs +1 -1
  393. package/node_modules/typebox/package.json +1 -1
  394. package/node_modules/typebox/readme.md +32 -29
  395. package/openclaw.plugin.json +239 -214
  396. package/package.json +11 -21
  397. package/dist/approval-reactions-Cu66aYdq.js +0 -373
  398. package/dist/channel.setup-pMwNVkCA.js +0 -19
  399. package/dist/config-schema-BQP5YCeK.js +0 -50
  400. package/dist/connection-controller-runtime-context-DG0tuYuw.js +0 -23
  401. package/dist/directory-config-DalGrfGN.js +0 -196
  402. package/dist/doctor-CwzVXKoE.js +0 -10
  403. package/dist/normalize-C7Hkc_vE.js +0 -2
  404. package/dist/question-reactions-CRsnyoMK.js +0 -142
  405. package/dist/runtime-BLlToOi6.js +0 -21
  406. package/dist/send-D37ddk22.js +0 -436
  407. package/dist/session.runtime-Nsqaehbd.js +0 -16
  408. package/dist/socket-close-DridEuzz.js +0 -622
  409. package/dist/targets-runtime-TMk0lGuy.js +0 -299
  410. package/dist/text-runtime-CaKLhowd.js +0 -4
  411. package/node_modules/baileys/node_modules/protobufjs/ext/README.md +0 -70
  412. package/node_modules/baileys/node_modules/protobufjs/ext/descriptor.d.ts +0 -87
  413. package/node_modules/baileys/node_modules/protobufjs/ext/descriptor.generated.d.ts +0 -417
  414. package/node_modules/baileys/node_modules/protobufjs/ext/descriptor.js +0 -1356
  415. package/node_modules/baileys/node_modules/protobufjs/ext/protojson.LICENSE +0 -201
  416. package/node_modules/baileys/node_modules/protobufjs/ext/protojson.d.ts +0 -20
  417. package/node_modules/baileys/node_modules/protobufjs/ext/protojson.generated.d.ts +0 -49
  418. package/node_modules/baileys/node_modules/protobufjs/ext/protojson.js +0 -951
  419. package/node_modules/baileys/node_modules/protobufjs/ext/textformat.d.ts +0 -19
  420. package/node_modules/baileys/node_modules/protobufjs/ext/textformat.generated.d.ts +0 -33
  421. package/node_modules/baileys/node_modules/protobufjs/ext/textformat.js +0 -1276
  422. package/node_modules/baileys/node_modules/protobufjs/google/protobuf/compiler/plugin.json +0 -126
  423. package/node_modules/baileys/node_modules/protobufjs/google/protobuf/compiler/plugin.proto +0 -47
  424. package/node_modules/baileys/node_modules/protobufjs/src/typescript.js +0 -25
  425. /package/dist/{account-ids-CB5SOWjc.js → .setup/account-ids-CB5SOWjc.mjs} +0 -0
  426. /package/dist/{audio-preflight.runtime-C_glQhZY.js → .setup/audio-preflight.runtime-C_glQhZY.mjs} +0 -0
  427. /package/dist/{command-policy-BIOSHySD.js → .setup/command-policy-BIOSHySD.mjs} +0 -0
  428. /package/dist/{creds-files-B1kSWtBg.js → .setup/creds-files-B1kSWtBg.mjs} +0 -0
  429. /package/dist/{group-config-path-BGyzT9Lg.js → .setup/group-config-path-BGyzT9Lg.mjs} +0 -0
  430. /package/dist/{group-session-contract-DDnZSsJ1.js → .setup/group-session-contract-DDnZSsJ1.mjs} +0 -0
  431. /package/dist/{reply-resolver.runtime-Ded8D58Y.js → .setup/reply-resolver.runtime-Ded8D58Y.mjs} +0 -0
  432. /package/dist/{rolldown-runtime-D7D4PA-g.js → .setup/rolldown-runtime-D7D4PA-g.mjs} +0 -0
  433. /package/dist/{security-contract-nAzD945y.js → .setup/security-contract-nAzD945y.mjs} +0 -0
  434. /package/dist/{session-contract-DMTm6Q_L.js → .setup/session-contract-DMTm6Q_L.mjs} +0 -0
  435. /package/node_modules/baileys/node_modules/{protobufjs/src/util/float.d.ts → @protobufjs/float/index.d.ts} +0 -0
@@ -0,0 +1,777 @@
1
+ import { t as resolveMergedWhatsAppAccountConfig } from "./account-config-6PTOSfaI.mjs";
2
+ import { r as resolveDefaultWhatsAppAccountId } from "./account-ids-CB5SOWjc.mjs";
3
+ import { a as resolveWhatsAppAccount, s as resolveWhatsAppMediaMaxBytes } from "./accounts-Dw16pdNl.mjs";
4
+ import { c as normalizeWhatsAppTarget, n as isWhatsAppNewsletterJid } from "./normalize-target-bVWjgftN.mjs";
5
+ import "./normalize-eddWWsNV.mjs";
6
+ import { t as getOptionalWhatsAppRuntime } from "./runtime-BfAdAEYT.mjs";
7
+ import { t as getRegisteredWhatsAppConnectionController } from "./connection-controller-registry-TSX_udJp.mjs";
8
+ import { t as formatError } from "./session-errors-BAj9D2La.mjs";
9
+ import { r as isWhatsAppSocketOperationTimeoutError } from "./socket-timing-DhbVFjah.mjs";
10
+ import { i as markdownToWhatsApp, s as toWhatsappJid } from "./targets-runtime-C-GiVn6Y.mjs";
11
+ import { a as sanitizeAssistantVisibleTextWithProfile, i as sanitizeAssistantVisibleText, o as sleep, s as stripToolCallXmlTags } from "./text-runtime-CUrq1mFq.mjs";
12
+ import path from "node:path";
13
+ import { uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
14
+ import { sanitizeForPlainText } from "openclaw/plugin-sdk/channel-outbound";
15
+ import { writeExternalFileWithinRoot } from "openclaw/plugin-sdk/security-runtime";
16
+ import { resolveReactionLevel } from "openclaw/plugin-sdk/status-helpers";
17
+ import { formatCliCommand } from "openclaw/plugin-sdk/cli-runtime";
18
+ import { generateSecureUuid } from "openclaw/plugin-sdk/core";
19
+ import { redactIdentifier } from "openclaw/plugin-sdk/logging-core";
20
+ import { convertMarkdownTables, resolveMarkdownTableMode } from "openclaw/plugin-sdk/markdown-table-runtime";
21
+ import { requireRuntimeConfig } from "openclaw/plugin-sdk/plugin-config-runtime";
22
+ import { normalizePollInput } from "openclaw/plugin-sdk/poll-runtime";
23
+ import { createSubsystemLogger, getChildLogger as getChildLogger$1 } from "openclaw/plugin-sdk/runtime-env";
24
+ import { createApprovalReactionTargetStore, listApprovalReactionBindings, resolveApprovalReactionTarget } from "openclaw/plugin-sdk/approval-reaction-runtime";
25
+ import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
26
+ import { createResolvedApproverActionAuthAdapter, resolveApprovalApprovers } from "openclaw/plugin-sdk/approval-auth-runtime";
27
+ import { extensionForMime } from "openclaw/plugin-sdk/media-mime";
28
+ import { MEDIA_FFMPEG_MAX_AUDIO_DURATION_SECS, runFfmpeg } from "openclaw/plugin-sdk/media-runtime";
29
+ import { resolvePreferredOpenClawTmpDir, withTempWorkspace } from "openclaw/plugin-sdk/temp-path";
30
+ import { loadWebMedia } from "openclaw/plugin-sdk/web-media";
31
+ //#region extensions/whatsapp/src/reaction-level.ts
32
+ /** Resolve the effective reaction level and its implications for WhatsApp. */
33
+ function resolveWhatsAppReactionLevel(params) {
34
+ const account = resolveMergedWhatsAppAccountConfig({
35
+ cfg: params.cfg,
36
+ accountId: params.accountId
37
+ });
38
+ return resolveReactionLevel({
39
+ value: account.reactionLevel,
40
+ defaultLevel: "minimal",
41
+ invalidFallback: "minimal"
42
+ });
43
+ }
44
+ //#endregion
45
+ //#region extensions/whatsapp/src/approval-auth.ts
46
+ function normalizeWhatsAppApproverId(value) {
47
+ const normalized = normalizeWhatsAppTarget(String(value));
48
+ if (!normalized || normalized.endsWith("@g.us")) return;
49
+ return normalized;
50
+ }
51
+ function normalizeWhatsAppApproverEntry(value) {
52
+ return String(value).trim() === "*" ? "*" : normalizeWhatsAppApproverId(value);
53
+ }
54
+ function getWhatsAppApprovalApprovers(params) {
55
+ const account = resolveWhatsAppAccount({
56
+ cfg: params.cfg,
57
+ accountId: params.accountId
58
+ });
59
+ return resolveApprovalApprovers({
60
+ allowFrom: account.allowFrom,
61
+ normalizeApprover: normalizeWhatsAppApproverEntry
62
+ });
63
+ }
64
+ const whatsappResolvedApproverAuth = createResolvedApproverActionAuthAdapter({
65
+ channelLabel: "WhatsApp",
66
+ resolveApprovers: ({ cfg, accountId }) => getWhatsAppApprovalApprovers({
67
+ cfg,
68
+ accountId
69
+ }),
70
+ normalizeSenderId: (value) => normalizeWhatsAppApproverId(value)
71
+ });
72
+ const whatsappApprovalAuth = { authorizeActorAction({ cfg, accountId, senderId, approvalKind }) {
73
+ if (getWhatsAppApprovalApprovers({
74
+ cfg,
75
+ accountId
76
+ }).includes("*")) return { authorized: true };
77
+ return whatsappResolvedApproverAuth.authorizeActorAction({
78
+ cfg,
79
+ accountId,
80
+ senderId,
81
+ action: "approve",
82
+ approvalKind
83
+ });
84
+ } };
85
+ //#endregion
86
+ //#region extensions/whatsapp/src/approval-reactions.ts
87
+ const PERSISTENT_NAMESPACE = "whatsapp.approval-reactions";
88
+ const PERSISTENT_MAX_ENTRIES = 1e3;
89
+ const DEFAULT_REACTION_TARGET_TTL_MS = 864e5;
90
+ const resolverRuntimeLoader = createLazyRuntimeModule(() => import("./approval-resolver-DF-lu8k5.mjs"));
91
+ const whatsappApprovalReactionTargets = createApprovalReactionTargetStore({
92
+ namespace: PERSISTENT_NAMESPACE,
93
+ maxEntries: PERSISTENT_MAX_ENTRIES,
94
+ defaultTtlMs: DEFAULT_REACTION_TARGET_TTL_MS,
95
+ openStore: (storeParams) => getOptionalWhatsAppRuntime()?.state.openKeyedStore(storeParams),
96
+ logPersistentError: reportPersistentApprovalReactionError,
97
+ readPersistedTarget
98
+ });
99
+ const loadApprovalResolver = resolverRuntimeLoader;
100
+ function buildReactionTargetKey(params) {
101
+ const accountId = params.accountId.trim();
102
+ const remoteJid = params.remoteJid.trim();
103
+ const messageId = params.messageId.trim();
104
+ if (!accountId || !remoteJid || !messageId) return null;
105
+ return `${accountId}:${remoteJid}:${messageId}`;
106
+ }
107
+ function addCandidateRemoteJid(target, value) {
108
+ const remoteJid = value?.trim();
109
+ if (remoteJid && !target.includes(remoteJid)) target.push(remoteJid);
110
+ }
111
+ function reportPersistentApprovalReactionError(error) {
112
+ try {
113
+ getOptionalWhatsAppRuntime()?.logging.getChildLogger({
114
+ plugin: "whatsapp",
115
+ feature: "approval-reaction-state"
116
+ }).warn("WhatsApp persistent approval reaction state failed", { error: String(error) });
117
+ } catch {}
118
+ }
119
+ function readPersistedTarget(target) {
120
+ const value = target;
121
+ if (!value || typeof value.approvalId !== "string" || !Array.isArray(value.allowedDecisions)) return null;
122
+ return {
123
+ approvalId: value.approvalId,
124
+ ...value.approvalKind === "exec" || value.approvalKind === "plugin" ? { approvalKind: value.approvalKind } : {},
125
+ allowedDecisions: value.allowedDecisions
126
+ };
127
+ }
128
+ function listWhatsAppApprovalReactionBindings(allowedDecisions) {
129
+ return listApprovalReactionBindings({ allowedDecisions });
130
+ }
131
+ function normalizeApprovalDecision(value) {
132
+ const normalized = value.trim().toLowerCase();
133
+ if (normalized === "always") return "allow-always";
134
+ if (normalized === "allow-once" || normalized === "allow-always" || normalized === "deny") return normalized;
135
+ return null;
136
+ }
137
+ const APPROVAL_ID_LINE_RE = /^\s*ID:\s*([A-Za-z0-9][A-Za-z0-9._:-]*)\s*$/i;
138
+ const APPROVE_COMMAND_LINE_RE = /\/approve(?:@[^\s]+)?\s+([A-Za-z0-9][A-Za-z0-9._:-]*)\s+(.+)$/i;
139
+ function extractWhatsAppApprovalPromptBinding(text) {
140
+ const lines = text.split(/\r?\n/);
141
+ const idHeaderMatch = lines.map((line) => line.match(APPROVAL_ID_LINE_RE)).find((match) => Boolean(match));
142
+ if (!idHeaderMatch) return null;
143
+ const approvalId = idHeaderMatch[1];
144
+ const allowedDecisions = [];
145
+ for (const line of lines) {
146
+ const match = line.match(APPROVE_COMMAND_LINE_RE);
147
+ if (!match || match[1] !== approvalId) continue;
148
+ for (const decisionText of match[2].split(/[\s|,]+/)) {
149
+ const decision = normalizeApprovalDecision(decisionText);
150
+ if (decision && !allowedDecisions.includes(decision)) allowedDecisions.push(decision);
151
+ }
152
+ }
153
+ return allowedDecisions.length > 0 ? {
154
+ approvalId,
155
+ allowedDecisions
156
+ } : null;
157
+ }
158
+ function registerWhatsAppApprovalReactionTarget(params) {
159
+ const key = buildReactionTargetKey(params);
160
+ const approvalId = params.approvalId.trim();
161
+ const allowedDecisions = listWhatsAppApprovalReactionBindings(params.allowedDecisions).map((binding) => binding.decision);
162
+ if (!key || !approvalId || allowedDecisions.length === 0) return null;
163
+ const target = {
164
+ approvalId,
165
+ approvalKind: approvalId.startsWith("plugin:") ? "plugin" : "exec",
166
+ allowedDecisions
167
+ };
168
+ whatsappApprovalReactionTargets.register(key, target, { ttlMs: params.ttlMs });
169
+ return target;
170
+ }
171
+ function registerWhatsAppApprovalReactionTargetForOutboundMessage(params) {
172
+ const binding = extractWhatsAppApprovalPromptBinding(params.text);
173
+ if (!binding) return false;
174
+ return Boolean(registerWhatsAppApprovalReactionTarget({
175
+ accountId: params.accountId,
176
+ remoteJid: params.remoteJid,
177
+ messageId: params.messageId,
178
+ approvalId: binding.approvalId,
179
+ allowedDecisions: binding.allowedDecisions,
180
+ ttlMs: params.ttlMs
181
+ }));
182
+ }
183
+ function unregisterWhatsAppApprovalReactionTarget(params) {
184
+ const key = buildReactionTargetKey(params);
185
+ if (!key) return;
186
+ whatsappApprovalReactionTargets.delete(key);
187
+ }
188
+ function resolveTarget(params) {
189
+ const resolved = resolveApprovalReactionTarget({
190
+ target: params.target,
191
+ reactionKey: params.reactionKey
192
+ });
193
+ return resolved ? {
194
+ approvalId: resolved.approvalId,
195
+ decision: resolved.decision
196
+ } : null;
197
+ }
198
+ async function resolveWhatsAppApprovalReactionTargetWithPersistence(params) {
199
+ const key = buildReactionTargetKey(params);
200
+ if (!key) return null;
201
+ return resolveTarget({
202
+ target: await whatsappApprovalReactionTargets.lookup(key),
203
+ reactionKey: params.reactionKey
204
+ });
205
+ }
206
+ async function resolveWhatsAppApprovalReactionTargetFromCandidates(params) {
207
+ const candidateRemoteJids = [];
208
+ for (const observedRemoteJid of params.observedRemoteJids) {
209
+ addCandidateRemoteJid(candidateRemoteJids, observedRemoteJid);
210
+ try {
211
+ for (const candidate of await params.resolveReactionTargetJids?.(observedRemoteJid) ?? []) addCandidateRemoteJid(candidateRemoteJids, candidate);
212
+ } catch (error) {
213
+ params.logVerboseMessage?.(`whatsapp: approval reaction target JID mapping failed for ${observedRemoteJid}: ${String(error)}`);
214
+ }
215
+ }
216
+ for (const remoteJid of candidateRemoteJids) {
217
+ const target = await resolveWhatsAppApprovalReactionTargetWithPersistence({
218
+ accountId: params.accountId,
219
+ remoteJid,
220
+ messageId: params.messageId,
221
+ reactionKey: params.reactionKey
222
+ });
223
+ if (target) return {
224
+ ...target,
225
+ remoteJid
226
+ };
227
+ }
228
+ return null;
229
+ }
230
+ function readWhatsAppApprovalReactionEvent(params) {
231
+ const msg = params.msg;
232
+ const reaction = msg.message?.reactionMessage;
233
+ const reactionKey = reaction?.text?.trim() ?? "";
234
+ const messageId = reaction?.key?.id?.trim() ?? "";
235
+ const remoteJids = [];
236
+ addCandidateRemoteJid(remoteJids, reaction?.key?.remoteJid);
237
+ addCandidateRemoteJid(remoteJids, msg.key?.remoteJid);
238
+ const actorJid = msg.key?.participant?.trim() || (msg.key?.fromMe ? params.selfLid?.trim() ?? params.selfJid?.trim() ?? "" : msg.key?.remoteJid?.trim() ?? "");
239
+ if (!reactionKey || !messageId || remoteJids.length === 0 || !actorJid) return null;
240
+ return {
241
+ remoteJids,
242
+ messageId,
243
+ actorJid,
244
+ reactionKey
245
+ };
246
+ }
247
+ async function maybeResolveWhatsAppApprovalReaction(params) {
248
+ const event = readWhatsAppApprovalReactionEvent({
249
+ msg: params.msg,
250
+ selfJid: params.selfJid,
251
+ selfLid: params.selfLid
252
+ });
253
+ if (!event) return false;
254
+ const target = await resolveWhatsAppApprovalReactionTargetFromCandidates({
255
+ accountId: params.accountId,
256
+ observedRemoteJids: event.remoteJids,
257
+ messageId: event.messageId,
258
+ reactionKey: event.reactionKey,
259
+ resolveReactionTargetJids: params.resolveReactionTargetJids,
260
+ logVerboseMessage: params.logVerboseMessage
261
+ });
262
+ if (!target) return false;
263
+ const actorId = await params.resolveInboundJid(event.actorJid);
264
+ if (!actorId) {
265
+ params.logVerboseMessage?.(`whatsapp: approval reaction ignored for ${target.approvalId}; missing actor identity`);
266
+ return true;
267
+ }
268
+ const approvalKind = target.approvalId.startsWith("plugin:") ? "plugin" : "exec";
269
+ if (getWhatsAppApprovalApprovers({
270
+ cfg: params.cfg,
271
+ accountId: params.accountId
272
+ }).length === 0) {
273
+ params.logVerboseMessage?.(`whatsapp: approval reaction denied id=${target.approvalId}; reactions require explicit approvers`);
274
+ return true;
275
+ }
276
+ if (!whatsappApprovalAuth.authorizeActorAction({
277
+ cfg: params.cfg,
278
+ accountId: params.accountId,
279
+ senderId: actorId,
280
+ action: "approve",
281
+ approvalKind
282
+ }).authorized) {
283
+ params.logVerboseMessage?.(`whatsapp: approval reaction denied id=${target.approvalId} sender=${actorId}`);
284
+ return true;
285
+ }
286
+ const { isApprovalNotFoundError, resolveWhatsAppApproval } = await loadApprovalResolver();
287
+ try {
288
+ await resolveWhatsAppApproval({
289
+ cfg: params.cfg,
290
+ approvalId: target.approvalId,
291
+ decision: target.decision,
292
+ senderId: actorId,
293
+ gatewayUrl: params.gatewayUrl
294
+ });
295
+ params.logVerboseMessage?.(`whatsapp: approval reaction resolved id=${target.approvalId} sender=${actorId} decision=${target.decision}`);
296
+ return true;
297
+ } catch (error) {
298
+ if (isApprovalNotFoundError(error)) {
299
+ unregisterWhatsAppApprovalReactionTarget({
300
+ accountId: params.accountId,
301
+ remoteJid: target.remoteJid,
302
+ messageId: event.messageId
303
+ });
304
+ params.logVerboseMessage?.(`whatsapp: approval reaction ignored for expired approval id=${target.approvalId} sender=${actorId}`);
305
+ return true;
306
+ }
307
+ params.logVerboseMessage?.(`whatsapp: approval reaction failed id=${target.approvalId} sender=${actorId}: ${String(error)}`);
308
+ return true;
309
+ }
310
+ }
311
+ //#endregion
312
+ //#region extensions/whatsapp/src/document-filename.ts
313
+ const WHATSAPP_DEFAULT_DOCUMENT_FILE_NAME = "file";
314
+ function resolveWhatsAppDefaultDocumentFileName(mimetype) {
315
+ const extension = extensionForMime(mimetype);
316
+ return extension ? `${WHATSAPP_DEFAULT_DOCUMENT_FILE_NAME}${extension}` : WHATSAPP_DEFAULT_DOCUMENT_FILE_NAME;
317
+ }
318
+ function resolveWhatsAppDocumentFileName(params) {
319
+ const fallbackName = resolveWhatsAppDefaultDocumentFileName(params.mimetype);
320
+ return stripAsciiControlCharacters(params.fileName ?? "").trim() || fallbackName;
321
+ }
322
+ function stripAsciiControlCharacters(value) {
323
+ let stripped = "";
324
+ for (const char of value) {
325
+ const code = char.charCodeAt(0);
326
+ if (code > 31 && code !== 127) stripped += char;
327
+ }
328
+ return stripped;
329
+ }
330
+ //#endregion
331
+ //#region extensions/whatsapp/src/outbound-media-contract.ts
332
+ const WHATSAPP_VOICE_FILE_NAME = "voice.ogg";
333
+ const WHATSAPP_VOICE_SAMPLE_RATE_HZ = 48e3;
334
+ const WHATSAPP_VOICE_BITRATE = "64k";
335
+ const WHATSAPP_VOICE_MIMETYPE = "audio/ogg; codecs=opus";
336
+ function stripWhatsAppPluralToolXml(text) {
337
+ return stripToolCallXmlTags(text, { stripFunctionCallsXmlPayloads: true });
338
+ }
339
+ function finalizeWhatsAppVisibleText(text) {
340
+ return sanitizeForPlainText(stripWhatsAppPluralToolXml(text));
341
+ }
342
+ function normalizeWhatsAppPayloadText(text) {
343
+ return finalizeWhatsAppVisibleText(sanitizeAssistantVisibleText(text ?? "")).trimStart();
344
+ }
345
+ function stripLeadingBlankLines(text) {
346
+ return text.replace(/^(?:[ \t]*\r?\n)+/, "");
347
+ }
348
+ function normalizeWhatsAppPayloadTextPreservingIndentation(text) {
349
+ const normalized = stripLeadingBlankLines(finalizeWhatsAppVisibleText(sanitizeAssistantVisibleTextWithProfile(stripLeadingBlankLines(text ?? ""), "history")));
350
+ return normalized.trim() ? normalized : "";
351
+ }
352
+ function resolveWhatsAppOutboundMediaUrls(payload) {
353
+ const orderedMediaUrls = [payload.mediaUrl?.trim(), ...(payload.mediaUrls ? [...payload.mediaUrls] : []).map((entry) => entry.trim()).filter((entry) => Boolean(entry))].filter((entry) => Boolean(entry));
354
+ return uniqueStrings(orderedMediaUrls);
355
+ }
356
+ function normalizeWhatsAppOutboundPayload(payload, options) {
357
+ const mediaUrls = resolveWhatsAppOutboundMediaUrls(payload);
358
+ const normalizeText = options?.normalizeText ?? normalizeWhatsAppPayloadText;
359
+ return {
360
+ ...payload,
361
+ text: normalizeText(payload.text),
362
+ mediaUrl: mediaUrls[0],
363
+ mediaUrls: mediaUrls.length > 0 ? mediaUrls : void 0
364
+ };
365
+ }
366
+ function inferWhatsAppMediaKind(media) {
367
+ if (media.kind === "image" || media.kind === "audio" || media.kind === "video" || media.kind === "document") return media.kind;
368
+ const contentType = normalizeContentType(media.contentType);
369
+ if (contentType.startsWith("image/")) return "image";
370
+ if (contentType.startsWith("audio/")) return "audio";
371
+ if (contentType.startsWith("video/")) return "video";
372
+ return "document";
373
+ }
374
+ function normalizeWhatsAppLoadedMedia(media, mediaUrl) {
375
+ const kind = inferWhatsAppMediaKind(media);
376
+ const mimetype = kind === "audio" && isWhatsAppNativeVoiceAudio({
377
+ contentType: media.contentType,
378
+ mediaUrl
379
+ }) ? WHATSAPP_VOICE_MIMETYPE : media.contentType ?? "application/octet-stream";
380
+ const fileName = kind === "document" ? resolveWhatsAppDocumentFileName({
381
+ fileName: media.fileName ?? deriveWhatsAppDocumentFileName(mediaUrl),
382
+ mimetype
383
+ }) : media.fileName;
384
+ return {
385
+ buffer: media.buffer,
386
+ kind,
387
+ mimetype,
388
+ ...fileName ? { fileName } : {}
389
+ };
390
+ }
391
+ async function prepareWhatsAppOutboundMedia(media, mediaUrl) {
392
+ const normalized = normalizeWhatsAppLoadedMedia(media, mediaUrl);
393
+ if (normalized.kind !== "audio") return normalized;
394
+ if (isWhatsAppNativeVoiceAudio({
395
+ contentType: media.contentType,
396
+ fileName: media.fileName,
397
+ mediaUrl
398
+ })) return normalized;
399
+ return {
400
+ buffer: await transcodeToWhatsAppVoiceOpus({
401
+ buffer: media.buffer,
402
+ fileName: media.fileName ?? deriveWhatsAppDocumentFileName(mediaUrl) ?? "audio"
403
+ }),
404
+ kind: "audio",
405
+ mimetype: WHATSAPP_VOICE_MIMETYPE
406
+ };
407
+ }
408
+ function normalizeContentType(value) {
409
+ return value?.split(";", 1)[0]?.trim().toLowerCase() ?? "";
410
+ }
411
+ function isWhatsAppNativeVoiceAudio(params) {
412
+ const contentType = normalizeContentType(params.contentType);
413
+ if (contentType === "audio/ogg" || contentType === "audio/opus") return true;
414
+ const fileName = params.fileName ?? deriveWhatsAppDocumentFileName(params.mediaUrl) ?? "";
415
+ const ext = path.extname(fileName).toLowerCase();
416
+ return ext === ".ogg" || ext === ".opus";
417
+ }
418
+ async function transcodeToWhatsAppVoiceOpus(params) {
419
+ return await withTempWorkspace({
420
+ rootDir: resolvePreferredOpenClawTmpDir(),
421
+ prefix: "whatsapp-voice-"
422
+ }, async (workspace) => {
423
+ const ext = path.extname(params.fileName).toLowerCase();
424
+ const inputExt = ext && ext.length <= 12 ? ext : ".audio";
425
+ const inputPath = await workspace.write(`input${inputExt}`, params.buffer);
426
+ await writeExternalFileWithinRoot({
427
+ rootDir: workspace.dir,
428
+ path: WHATSAPP_VOICE_FILE_NAME,
429
+ write: async (outputPath) => {
430
+ await runFfmpeg([
431
+ "-hide_banner",
432
+ "-loglevel",
433
+ "error",
434
+ "-y",
435
+ "-i",
436
+ inputPath,
437
+ "-vn",
438
+ "-sn",
439
+ "-dn",
440
+ "-t",
441
+ String(MEDIA_FFMPEG_MAX_AUDIO_DURATION_SECS),
442
+ "-ar",
443
+ String(WHATSAPP_VOICE_SAMPLE_RATE_HZ),
444
+ "-ac",
445
+ "1",
446
+ "-c:a",
447
+ "libopus",
448
+ "-b:a",
449
+ WHATSAPP_VOICE_BITRATE,
450
+ "-f",
451
+ "ogg",
452
+ outputPath
453
+ ]);
454
+ }
455
+ });
456
+ return await workspace.read(WHATSAPP_VOICE_FILE_NAME);
457
+ });
458
+ }
459
+ function deriveWhatsAppDocumentFileName(mediaUrl) {
460
+ if (!mediaUrl) return;
461
+ try {
462
+ const parsed = new URL(mediaUrl);
463
+ const fileName = path.posix.basename(parsed.pathname);
464
+ return fileName ? decodeURIComponent(fileName) : void 0;
465
+ } catch {
466
+ return (mediaUrl.split(/[?#]/, 1)[0] ?? "").split(/[\\/]/).pop() || void 0;
467
+ }
468
+ }
469
+ function isRetryableWhatsAppOutboundError(error) {
470
+ if (isWhatsAppSocketOperationTimeoutError(error)) return false;
471
+ return /closed|reset|timed\s*out|disconnect/i.test(formatError(error));
472
+ }
473
+ async function sendWhatsAppOutboundWithRetry(params) {
474
+ const maxAttempts = params.maxAttempts ?? 3;
475
+ let lastError;
476
+ for (let attempt = 1; attempt <= maxAttempts; attempt += 1) try {
477
+ return await params.send();
478
+ } catch (error) {
479
+ lastError = error;
480
+ const errorText = formatError(error);
481
+ const isLastAttempt = attempt === maxAttempts;
482
+ if (!isRetryableWhatsAppOutboundError(error) || isLastAttempt) throw error;
483
+ const backoffMs = 500 * attempt;
484
+ await params.onRetry?.({
485
+ attempt,
486
+ maxAttempts,
487
+ backoffMs,
488
+ error,
489
+ errorText
490
+ });
491
+ await sleep(backoffMs);
492
+ }
493
+ throw lastError;
494
+ }
495
+ //#endregion
496
+ //#region extensions/whatsapp/src/outbound-media.runtime.ts
497
+ async function loadOutboundMediaFromUrl(mediaUrl, options = {}) {
498
+ const readFile = options.mediaAccess?.readFile ?? options.mediaReadFile;
499
+ const localRoots = options.mediaAccess?.localRoots?.length && options.mediaAccess.localRoots.length > 0 ? options.mediaAccess.localRoots : options.mediaLocalRoots && options.mediaLocalRoots.length > 0 ? options.mediaLocalRoots : void 0;
500
+ const sharedOptions = {
501
+ ...options.maxBytes !== void 0 ? { maxBytes: options.maxBytes } : {},
502
+ ...options.optimizeImages !== void 0 ? { optimizeImages: options.optimizeImages } : {}
503
+ };
504
+ return await loadWebMedia(mediaUrl, readFile ? {
505
+ ...sharedOptions,
506
+ localRoots: "any",
507
+ readFile,
508
+ hostReadCapability: true
509
+ } : {
510
+ ...sharedOptions,
511
+ ...localRoots ? { localRoots } : {}
512
+ });
513
+ }
514
+ //#endregion
515
+ //#region extensions/whatsapp/src/send.ts
516
+ const outboundLog = createSubsystemLogger("gateway/channels/whatsapp").child("outbound");
517
+ function supportsForcedDocumentDelivery(kind) {
518
+ return kind === "image" || kind === "video";
519
+ }
520
+ function buildWhatsAppMediaSendState(params) {
521
+ const { media, caption } = params;
522
+ const forceDocumentDelivery = Boolean(params.forceDocument && supportsForcedDocumentDelivery(media.kind));
523
+ let text = caption ?? "";
524
+ let documentFileName = media.kind === "document" ? media.fileName : void 0;
525
+ let visibleTextAfterVoice;
526
+ if (media.kind === "audio" && caption) {
527
+ visibleTextAfterVoice = caption;
528
+ text = "";
529
+ }
530
+ if (forceDocumentDelivery) documentFileName ??= resolveWhatsAppDocumentFileName({
531
+ fileName: media.fileName,
532
+ mimetype: media.mimetype
533
+ });
534
+ return {
535
+ mediaBuffer: media.buffer,
536
+ mediaType: media.mimetype,
537
+ text,
538
+ forceDocumentDelivery,
539
+ ...documentFileName ? { documentFileName } : {},
540
+ ...visibleTextAfterVoice ? { visibleTextAfterVoice } : {}
541
+ };
542
+ }
543
+ function resolveOutboundWhatsAppAccountId(params) {
544
+ const explicitAccountId = params.accountId?.trim();
545
+ if (explicitAccountId) return explicitAccountId;
546
+ return resolveDefaultWhatsAppAccountId(params.cfg);
547
+ }
548
+ function requireOutboundActiveWebListener(params) {
549
+ const resolvedAccountId = resolveOutboundWhatsAppAccountId(params) ?? resolveDefaultWhatsAppAccountId(params.cfg);
550
+ const listener = getRegisteredWhatsAppConnectionController(resolvedAccountId)?.getActiveListener() ?? null;
551
+ if (!listener) throw new Error(`No active WhatsApp Web listener (account: ${resolvedAccountId}). Start the gateway, then link WhatsApp with: ${formatCliCommand(`openclaw channels login --channel whatsapp --account ${resolvedAccountId}`)}.`);
552
+ return {
553
+ accountId: resolvedAccountId,
554
+ listener
555
+ };
556
+ }
557
+ function resolveActualSentRemoteJid(result, fallbackJid) {
558
+ if (!result || typeof result !== "object") return fallbackJid;
559
+ const rawKeys = result.keys;
560
+ const keys = Array.isArray(rawKeys) ? rawKeys : [];
561
+ for (const key of keys) if (typeof key?.remoteJid === "string" && key.remoteJid.trim()) return key.remoteJid.trim();
562
+ return fallbackJid;
563
+ }
564
+ async function sendMessageWhatsApp(to, body, options) {
565
+ let text = options.preserveLeadingWhitespace ? body : normalizeWhatsAppPayloadText(body);
566
+ const jid = toWhatsappJid(to);
567
+ const mediaUrls = resolveWhatsAppOutboundMediaUrls(options);
568
+ const mediaPayload = options.mediaPayload;
569
+ const primaryMediaUrl = mediaUrls[0] ?? mediaPayload?.fileName;
570
+ const hasMedia = Boolean(mediaPayload || primaryMediaUrl);
571
+ if (!text && !hasMedia) return {
572
+ messageId: "",
573
+ toJid: jid
574
+ };
575
+ const correlationId = generateSecureUuid();
576
+ const startedAt = Date.now();
577
+ const cfg = requireRuntimeConfig(options.cfg, "WhatsApp send");
578
+ const { listener: active, accountId: resolvedAccountId } = requireOutboundActiveWebListener({
579
+ cfg,
580
+ accountId: options.accountId
581
+ });
582
+ const account = resolveWhatsAppAccount({
583
+ cfg,
584
+ accountId: resolvedAccountId ?? options.accountId
585
+ });
586
+ const tableMode = resolveMarkdownTableMode({
587
+ cfg,
588
+ channel: "whatsapp",
589
+ accountId: resolvedAccountId ?? options.accountId
590
+ });
591
+ text = convertMarkdownTables(text ?? "", tableMode);
592
+ text = markdownToWhatsApp(text);
593
+ const redactedTo = redactIdentifier(to);
594
+ const logger = getChildLogger$1({
595
+ module: "web-outbound",
596
+ correlationId,
597
+ to: redactedTo
598
+ });
599
+ try {
600
+ const redactedJid = redactIdentifier(jid);
601
+ let mediaBuffer;
602
+ let mediaType;
603
+ let documentFileName;
604
+ let visibleTextAfterVoice;
605
+ let forceDocumentDelivery = false;
606
+ let media;
607
+ if (mediaPayload) media = await prepareWhatsAppOutboundMedia(mediaPayload, primaryMediaUrl);
608
+ else if (primaryMediaUrl) media = await prepareWhatsAppOutboundMedia(await loadOutboundMediaFromUrl(primaryMediaUrl, {
609
+ maxBytes: resolveWhatsAppMediaMaxBytes(account),
610
+ optimizeImages: options.forceDocument ? false : void 0,
611
+ mediaAccess: options.mediaAccess,
612
+ mediaLocalRoots: options.mediaLocalRoots,
613
+ mediaReadFile: options.mediaReadFile
614
+ }), primaryMediaUrl);
615
+ if (media) {
616
+ const mediaSendState = buildWhatsAppMediaSendState({
617
+ media,
618
+ caption: text || void 0,
619
+ forceDocument: options.forceDocument
620
+ });
621
+ mediaBuffer = mediaSendState.mediaBuffer;
622
+ mediaType = mediaSendState.mediaType;
623
+ documentFileName = mediaSendState.documentFileName;
624
+ visibleTextAfterVoice = mediaSendState.visibleTextAfterVoice;
625
+ forceDocumentDelivery = mediaSendState.forceDocumentDelivery;
626
+ text = mediaSendState.text;
627
+ }
628
+ outboundLog.info(`Sending message -> ${redactedJid}${hasMedia ? " (media)" : ""}`);
629
+ logger.info({
630
+ jid: redactedJid,
631
+ hasMedia
632
+ }, "sending message");
633
+ if (!isWhatsAppNewsletterJid(jid)) {
634
+ await active.assertSendReady?.(to);
635
+ await active.sendComposingTo(to);
636
+ }
637
+ const accountId = Boolean(options.accountId?.trim()) ? resolvedAccountId : void 0;
638
+ const sendOptions = options.gifPlayback || forceDocumentDelivery || accountId || documentFileName || options.quotedMessageKey ? {
639
+ ...options.gifPlayback ? { gifPlayback: true } : {},
640
+ ...forceDocumentDelivery ? { asDocument: true } : {},
641
+ ...documentFileName ? { fileName: documentFileName } : {},
642
+ ...options.quotedMessageKey ? { quotedMessageKey: options.quotedMessageKey } : {},
643
+ accountId
644
+ } : void 0;
645
+ const result = sendOptions ? await active.sendMessage(to, text, mediaBuffer, mediaType, sendOptions) : await active.sendMessage(to, text, mediaBuffer, mediaType);
646
+ const messageId = result?.messageId ?? "unknown";
647
+ const sentRemoteJid = resolveActualSentRemoteJid(result, jid);
648
+ if (visibleTextAfterVoice) {
649
+ await options.onDeliveryResult?.({
650
+ messageId,
651
+ toJid: sentRemoteJid
652
+ });
653
+ const captionResult = sendOptions ? await active.sendMessage(to, visibleTextAfterVoice, void 0, void 0, sendOptions) : await active.sendMessage(to, visibleTextAfterVoice, void 0, void 0);
654
+ await options.onDeliveryResult?.({
655
+ messageId: captionResult?.messageId ?? "unknown",
656
+ toJid: resolveActualSentRemoteJid(captionResult, jid)
657
+ });
658
+ }
659
+ if (messageId && messageId !== "unknown" && text) registerWhatsAppApprovalReactionTargetForOutboundMessage({
660
+ accountId: resolvedAccountId,
661
+ remoteJid: sentRemoteJid,
662
+ messageId,
663
+ text
664
+ });
665
+ const durationMs = Date.now() - startedAt;
666
+ outboundLog.info(`Sent message ${messageId} -> ${redactedJid}${hasMedia ? " (media)" : ""} (${durationMs}ms)`);
667
+ logger.info({
668
+ jid: redactedJid,
669
+ messageId
670
+ }, "sent message");
671
+ return {
672
+ messageId,
673
+ toJid: sentRemoteJid
674
+ };
675
+ } catch (err) {
676
+ logger.error({
677
+ err: String(err),
678
+ to: redactedTo,
679
+ hasMedia
680
+ }, "failed to send via web session");
681
+ throw err;
682
+ }
683
+ }
684
+ async function sendTypingWhatsApp(to, options) {
685
+ const { listener: active } = requireOutboundActiveWebListener({
686
+ cfg: requireRuntimeConfig(options.cfg, "WhatsApp typing send"),
687
+ accountId: options.accountId
688
+ });
689
+ if (!isWhatsAppNewsletterJid(toWhatsappJid(to))) {
690
+ await active.assertSendReady?.(to);
691
+ await active.sendComposingTo(to);
692
+ }
693
+ }
694
+ async function sendReactionWhatsApp(chatJid, messageId, emoji, options) {
695
+ const correlationId = generateSecureUuid();
696
+ const { listener: active } = requireOutboundActiveWebListener({
697
+ cfg: requireRuntimeConfig(options.cfg, "WhatsApp reaction"),
698
+ accountId: options.accountId
699
+ });
700
+ const redactedChatJid = redactIdentifier(chatJid);
701
+ const logger = getChildLogger$1({
702
+ module: "web-outbound",
703
+ correlationId,
704
+ chatJid: redactedChatJid,
705
+ messageId
706
+ });
707
+ try {
708
+ const jid = toWhatsappJid(chatJid);
709
+ const redactedJid = redactIdentifier(jid);
710
+ outboundLog.info(`Sending reaction "${emoji}" -> message ${messageId}`);
711
+ logger.info({
712
+ chatJid: redactedJid,
713
+ messageId,
714
+ emoji
715
+ }, "sending reaction");
716
+ await active.sendReaction(chatJid, messageId, emoji, options.fromMe ?? false, options.participant);
717
+ outboundLog.info(`Sent reaction "${emoji}" -> message ${messageId}`);
718
+ logger.info({
719
+ chatJid: redactedJid,
720
+ messageId,
721
+ emoji
722
+ }, "sent reaction");
723
+ } catch (err) {
724
+ logger.error({
725
+ err: String(err),
726
+ chatJid: redactedChatJid,
727
+ messageId,
728
+ emoji
729
+ }, "failed to send reaction via web session");
730
+ throw err;
731
+ }
732
+ }
733
+ async function sendPollWhatsApp(to, poll, options) {
734
+ const correlationId = generateSecureUuid();
735
+ const startedAt = Date.now();
736
+ const { listener: active } = requireOutboundActiveWebListener({
737
+ cfg: requireRuntimeConfig(options.cfg, "WhatsApp poll"),
738
+ accountId: options.accountId
739
+ });
740
+ const redactedTo = redactIdentifier(to);
741
+ const logger = getChildLogger$1({
742
+ module: "web-outbound",
743
+ correlationId,
744
+ to: redactedTo
745
+ });
746
+ try {
747
+ const jid = toWhatsappJid(to);
748
+ const redactedJid = redactIdentifier(jid);
749
+ const normalized = normalizePollInput(poll, { maxOptions: 12 });
750
+ outboundLog.info(`Sending poll -> ${redactedJid}`);
751
+ logger.info({
752
+ jid: redactedJid,
753
+ optionCount: normalized.options.length,
754
+ maxSelections: normalized.maxSelections
755
+ }, "sending poll");
756
+ if (!isWhatsAppNewsletterJid(jid)) await active.assertSendReady?.(to);
757
+ const messageId = (await active.sendPoll(to, normalized))?.messageId ?? "unknown";
758
+ const durationMs = Date.now() - startedAt;
759
+ outboundLog.info(`Sent poll ${messageId} -> ${redactedJid} (${durationMs}ms)`);
760
+ logger.info({
761
+ jid: redactedJid,
762
+ messageId
763
+ }, "sent poll");
764
+ return {
765
+ messageId,
766
+ toJid: jid
767
+ };
768
+ } catch (err) {
769
+ logger.error({
770
+ err: String(err),
771
+ to: redactedTo
772
+ }, "failed to send poll via web session");
773
+ throw err;
774
+ }
775
+ }
776
+ //#endregion
777
+ export { normalizeWhatsAppOutboundPayload as a, prepareWhatsAppOutboundMedia as c, maybeResolveWhatsAppApprovalReaction as d, registerWhatsAppApprovalReactionTarget as f, resolveWhatsAppReactionLevel as g, whatsappApprovalAuth as h, sendTypingWhatsApp as i, sendWhatsAppOutboundWithRetry as l, getWhatsAppApprovalApprovers as m, sendPollWhatsApp as n, normalizeWhatsAppPayloadText as o, unregisterWhatsAppApprovalReactionTarget as p, sendReactionWhatsApp as r, normalizeWhatsAppPayloadTextPreservingIndentation as s, sendMessageWhatsApp as t, resolveWhatsAppDocumentFileName as u };