@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.
- package/README.md +1 -1
- package/dist/{access-control-pZcxTmd5.js → .setup/access-control-C0jumQuO.mjs} +5 -4
- package/dist/.setup/account-config-6PTOSfaI.mjs +47 -0
- package/dist/{accounts-CSqLvCY5.js → .setup/accounts-Dw16pdNl.mjs} +9 -47
- package/dist/{action-runtime-BzfDFPbH.js → .setup/action-runtime-DLK_9v4r.mjs} +3 -3
- package/dist/{active-listener-BEjWsCNM.js → .setup/active-listener-CloPBx0S.mjs} +3 -3
- package/dist/{agent-tools-login-DE9MU98T.js → .setup/agent-tools-login-DINqgaYo.mjs} +19 -7
- package/dist/{approval-handler.runtime-DrA59QSA.js → .setup/approval-handler.runtime-DtJZbu3y.mjs} +14 -20
- package/dist/{approval-resolver-DoeBBt22.js → .setup/approval-resolver-DF-lu8k5.mjs} +1 -2
- package/dist/{auth-store-DcEpIOmE.js → .setup/auth-store-BZKGa0tW.mjs} +25 -29
- package/dist/{channel-Dg62olhy.js → .setup/channel-9WGjBznd.mjs} +117 -132
- package/dist/{channel-react-action-J_YtyMGX.js → .setup/channel-react-action-mvIbAFhn.mjs} +15 -12
- package/dist/{channel.runtime-BP0xNmLi.js → .setup/channel.runtime-DmmMgRJQ.mjs} +6 -6
- package/dist/.setup/channel.setup-ByBYSeLd.mjs +22 -0
- package/dist/.setup/config-schema-mBX2nmn1.mjs +47 -0
- package/dist/{connection-controller-BOB2MVKY.js → .setup/connection-controller-Dt62u6fI.mjs} +29 -226
- package/dist/.setup/connection-controller-registry-TSX_udJp.mjs +22 -0
- package/dist/{constants-HU41RHGI.js → .setup/constants-C7m81BNe.mjs} +1 -1
- package/dist/.setup/directory-config-B7Obxrq2.mjs +37 -0
- package/dist/.setup/doctor-By3SB4lm.mjs +48 -0
- package/dist/{group-session-key-DVMZlO3x.js → .setup/group-session-key-CEwPRRRK.mjs} +5 -38
- package/dist/{identity-CPrT5aEU.js → .setup/identity-CDB1bT-p.mjs} +2 -2
- package/dist/.setup/legacy-session-surface-api-B2szjq4r.mjs +2 -0
- package/dist/.setup/legacy-state-migrations-api-DXCxufZz.mjs +3 -0
- package/dist/{login-CvY2Dhch.js → .setup/login-7b3M0iBp.mjs} +12 -51
- package/dist/{login-qr-Bncpb6js.js → .setup/login-qr-CbyA4QX5.mjs} +47 -23
- package/dist/{monitor-CfkaUSL2.js → .setup/monitor-Dh6Di_YO.mjs} +1451 -1843
- package/dist/.setup/normalize-eddWWsNV.mjs +2 -0
- package/dist/{normalize-target-CugRyONv.js → .setup/normalize-target-bVWjgftN.mjs} +10 -18
- package/dist/{resolve-outbound-target-1GqbT1uX.js → .setup/resolve-outbound-target-oI7VpU4w.mjs} +1 -1
- package/dist/.setup/runtime-BfAdAEYT.mjs +8 -0
- package/dist/.setup/send-BQjMC41n.mjs +777 -0
- package/dist/{send-api-7wk6eQyW.js → .setup/send-api-BiAkPLr3.mjs} +155 -105
- package/dist/{session-errors-JuazczrA.js → .setup/session-errors-BAj9D2La.mjs} +1 -2
- package/dist/.setup/session-vUI41Jel.mjs +252 -0
- package/dist/.setup/session.runtime-B-V3rXP6.mjs +12 -0
- package/dist/{shared-CAxd15bp.js → .setup/setup-core--FfzntMG.mjs} +94 -63
- package/dist/{setup-finalize-BZucx24W.js → .setup/setup-finalize-DCruIciL.mjs} +17 -46
- package/dist/.setup/setup-plugin-api-B6ck_20D.mjs +3 -0
- package/dist/{setup-surface-BkVcd769.js → .setup/setup-surface-Zvj2cLzz.mjs} +4 -4
- package/dist/.setup/socket-timing-DhbVFjah.mjs +77 -0
- package/dist/{state-migrations-CAMTrs2U.js → .setup/state-migrations-D_BmQUR9.mjs} +8 -1
- package/dist/.setup/targets-runtime-C-GiVn6Y.mjs +188 -0
- package/dist/.setup/text-runtime-CUrq1mFq.mjs +4 -0
- package/dist/action-runtime-api.js +1 -1
- package/dist/action-runtime.runtime.js +1 -1
- package/dist/{call-tool-api.js → agent-tools-api.js} +26 -11
- package/dist/api.js +27 -17
- package/dist/auth-presence.js +1 -1
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/constants.js +2 -0
- package/dist/contract-api.js +5 -5
- package/dist/directory-contract-api.js +1 -1
- package/dist/doctor-contract-api.js +5 -46
- package/dist/index.js +4 -4
- package/dist/legacy-session-surface-api.js +1 -1
- package/dist/legacy-state-migrations-api.js +1 -1
- package/dist/light-runtime-api.js +4 -4
- package/dist/login-qr-runtime.js +1 -1
- package/dist/runtime-api.js +14 -14
- package/dist/runtime-setter-api.js +1 -1
- package/dist/security-contract-api.js +1 -1
- package/dist/setup-entry.js +4 -3
- package/dist/setup-plugin-api.js +1 -1
- package/dist/targets.js +2 -0
- package/node_modules/audio-decode/node_modules/@thi.ng/bitstream/package.json +4 -4
- package/node_modules/audio-decode/node_modules/@thi.ng/errors/package.json +4 -4
- package/node_modules/audio-decode/node_modules/audio-type/package.json +2 -3
- package/node_modules/baileys/node_modules/@protobufjs/aspromise/LICENSE +26 -0
- package/node_modules/baileys/node_modules/@protobufjs/aspromise/README.md +13 -0
- package/node_modules/baileys/node_modules/{protobufjs/src/util/aspromise.d.ts → @protobufjs/aspromise/index.d.ts} +13 -13
- package/node_modules/baileys/node_modules/{protobufjs/src/util/aspromise.js → @protobufjs/aspromise/index.js} +52 -52
- package/node_modules/baileys/node_modules/@protobufjs/aspromise/package.json +21 -0
- package/node_modules/baileys/node_modules/@protobufjs/aspromise/tests/index.js +130 -0
- package/node_modules/baileys/node_modules/@protobufjs/base64/LICENSE +26 -0
- package/node_modules/baileys/node_modules/@protobufjs/base64/README.md +19 -0
- package/node_modules/baileys/node_modules/{protobufjs/src/util/base64.d.ts → @protobufjs/base64/index.d.ts} +32 -32
- package/node_modules/baileys/node_modules/{protobufjs/src/util/base64.js → @protobufjs/base64/index.js} +139 -146
- package/node_modules/baileys/node_modules/@protobufjs/base64/package.json +21 -0
- package/node_modules/baileys/node_modules/@protobufjs/base64/tests/index.js +46 -0
- package/node_modules/baileys/node_modules/@protobufjs/codegen/LICENSE +26 -0
- package/node_modules/baileys/node_modules/@protobufjs/codegen/README.md +49 -0
- package/node_modules/baileys/node_modules/{protobufjs/src/util/codegen.d.ts → @protobufjs/codegen/index.d.ts} +31 -31
- package/node_modules/baileys/node_modules/{protobufjs/src/util/codegen.js → @protobufjs/codegen/index.js} +112 -118
- package/node_modules/baileys/node_modules/@protobufjs/codegen/package.json +13 -0
- package/node_modules/baileys/node_modules/@protobufjs/codegen/tests/index.js +13 -0
- package/node_modules/baileys/node_modules/@protobufjs/eventemitter/CHANGELOG.md +8 -0
- package/node_modules/baileys/node_modules/@protobufjs/eventemitter/LICENSE +26 -0
- package/node_modules/baileys/node_modules/@protobufjs/eventemitter/README.md +22 -0
- package/node_modules/baileys/node_modules/{protobufjs/src/util/eventemitter.d.ts → @protobufjs/eventemitter/index.d.ts} +45 -45
- package/node_modules/baileys/node_modules/{protobufjs/src/util/eventemitter.js → @protobufjs/eventemitter/index.js} +86 -86
- package/node_modules/baileys/node_modules/@protobufjs/eventemitter/package.json +21 -0
- package/node_modules/baileys/node_modules/@protobufjs/eventemitter/tests/index.js +83 -0
- package/node_modules/baileys/node_modules/@protobufjs/fetch/CHANGELOG.md +8 -0
- package/node_modules/baileys/node_modules/@protobufjs/fetch/LICENSE +26 -0
- package/node_modules/baileys/node_modules/@protobufjs/fetch/README.md +13 -0
- package/node_modules/baileys/node_modules/{protobufjs/src/util/fetch.d.ts → @protobufjs/fetch/index.d.ts} +56 -56
- package/node_modules/baileys/node_modules/{protobufjs/src/util/fetch.js → @protobufjs/fetch/index.js} +112 -112
- package/node_modules/baileys/node_modules/@protobufjs/fetch/package.json +27 -0
- package/node_modules/baileys/node_modules/@protobufjs/fetch/tests/data/file.txt +1 -0
- package/node_modules/baileys/node_modules/@protobufjs/fetch/tests/index.js +158 -0
- package/node_modules/baileys/node_modules/@protobufjs/fetch/util/fs.js +11 -0
- package/node_modules/baileys/node_modules/@protobufjs/float/LICENSE +26 -0
- package/node_modules/baileys/node_modules/@protobufjs/float/README.md +102 -0
- package/node_modules/baileys/node_modules/@protobufjs/float/bench/index.js +87 -0
- package/node_modules/baileys/node_modules/@protobufjs/float/bench/suite.js +46 -0
- package/node_modules/baileys/node_modules/{protobufjs/src/util/float.js → @protobufjs/float/index.js} +335 -335
- package/node_modules/baileys/node_modules/@protobufjs/float/package.json +26 -0
- package/node_modules/baileys/node_modules/@protobufjs/float/tests/index.js +100 -0
- package/node_modules/baileys/node_modules/@protobufjs/inquire/CHANGELOG.md +8 -0
- package/node_modules/baileys/node_modules/@protobufjs/inquire/LICENSE +26 -0
- package/node_modules/baileys/node_modules/@protobufjs/inquire/README.md +13 -0
- package/node_modules/baileys/node_modules/@protobufjs/inquire/index.d.ts +10 -0
- package/node_modules/baileys/node_modules/@protobufjs/inquire/index.js +38 -0
- package/node_modules/baileys/node_modules/@protobufjs/inquire/package.json +21 -0
- package/node_modules/baileys/node_modules/@protobufjs/inquire/tests/data/array.js +1 -0
- package/node_modules/baileys/node_modules/@protobufjs/inquire/tests/data/emptyArray.js +1 -0
- package/node_modules/baileys/node_modules/@protobufjs/inquire/tests/data/emptyObject.js +1 -0
- package/node_modules/baileys/node_modules/@protobufjs/inquire/tests/data/object.js +1 -0
- package/node_modules/baileys/node_modules/@protobufjs/inquire/tests/index.js +20 -0
- package/node_modules/baileys/node_modules/@protobufjs/path/LICENSE +26 -0
- package/node_modules/baileys/node_modules/@protobufjs/path/README.md +19 -0
- package/node_modules/baileys/node_modules/{protobufjs/src/util/path.d.ts → @protobufjs/path/index.d.ts} +22 -22
- package/node_modules/baileys/node_modules/{protobufjs/src/util/path.js → @protobufjs/path/index.js} +65 -100
- package/node_modules/baileys/node_modules/@protobufjs/path/package.json +21 -0
- package/node_modules/baileys/node_modules/@protobufjs/path/tests/index.js +60 -0
- package/node_modules/baileys/node_modules/@protobufjs/pool/.npmignore +3 -0
- package/node_modules/baileys/node_modules/@protobufjs/pool/LICENSE +26 -0
- package/node_modules/baileys/node_modules/@protobufjs/pool/README.md +13 -0
- package/node_modules/baileys/node_modules/{protobufjs/src/util/pool.d.ts → @protobufjs/pool/index.d.ts} +32 -32
- package/node_modules/baileys/node_modules/{protobufjs/src/util/pool.js → @protobufjs/pool/index.js} +48 -48
- package/node_modules/baileys/node_modules/@protobufjs/pool/package.json +21 -0
- package/node_modules/baileys/node_modules/@protobufjs/pool/tests/index.js +33 -0
- package/node_modules/baileys/node_modules/@protobufjs/utf8/LICENSE +26 -0
- package/node_modules/baileys/node_modules/@protobufjs/utf8/README.md +20 -0
- package/node_modules/baileys/node_modules/{protobufjs/src/util/utf8.d.ts → @protobufjs/utf8/index.d.ts} +24 -24
- package/node_modules/baileys/node_modules/{protobufjs/src/util/utf8.js → @protobufjs/utf8/index.js} +104 -190
- package/node_modules/baileys/node_modules/@protobufjs/utf8/package.json +21 -0
- package/node_modules/baileys/node_modules/@protobufjs/utf8/tests/data/surrogate_pair_bug.txt +207 -0
- package/node_modules/baileys/node_modules/@protobufjs/utf8/tests/data/utf8.txt +216 -0
- package/node_modules/baileys/node_modules/@protobufjs/utf8/tests/index.js +74 -0
- package/node_modules/baileys/node_modules/@types/node/LICENSE +21 -0
- package/node_modules/baileys/node_modules/@types/node/README.md +15 -0
- package/node_modules/baileys/node_modules/@types/node/assert/strict.d.ts +68 -0
- package/node_modules/baileys/node_modules/@types/node/assert.d.ts +1077 -0
- package/node_modules/baileys/node_modules/@types/node/async_hooks.d.ts +711 -0
- package/node_modules/baileys/node_modules/@types/node/buffer.buffer.d.ts +466 -0
- package/node_modules/baileys/node_modules/@types/node/buffer.d.ts +1799 -0
- package/node_modules/baileys/node_modules/@types/node/child_process.d.ts +1362 -0
- package/node_modules/baileys/node_modules/@types/node/cluster.d.ts +432 -0
- package/node_modules/baileys/node_modules/@types/node/console.d.ts +93 -0
- package/node_modules/baileys/node_modules/@types/node/constants.d.ts +14 -0
- package/node_modules/baileys/node_modules/@types/node/crypto.d.ts +3954 -0
- package/node_modules/baileys/node_modules/@types/node/dgram.d.ts +537 -0
- package/node_modules/baileys/node_modules/@types/node/diagnostics_channel.d.ts +794 -0
- package/node_modules/baileys/node_modules/@types/node/dns/promises.d.ts +497 -0
- package/node_modules/baileys/node_modules/@types/node/dns.d.ts +876 -0
- package/node_modules/baileys/node_modules/@types/node/domain.d.ts +150 -0
- package/node_modules/baileys/node_modules/@types/node/events.d.ts +1008 -0
- package/node_modules/baileys/node_modules/@types/node/ffi.d.ts +486 -0
- package/node_modules/baileys/node_modules/@types/node/fs/promises.d.ts +1471 -0
- package/node_modules/baileys/node_modules/@types/node/fs.d.ts +4786 -0
- package/node_modules/baileys/node_modules/@types/node/globals.d.ts +150 -0
- package/node_modules/baileys/node_modules/@types/node/globals.typedarray.d.ts +101 -0
- package/node_modules/baileys/node_modules/@types/node/http.d.ts +2172 -0
- package/node_modules/baileys/node_modules/@types/node/http2.d.ts +2489 -0
- package/node_modules/baileys/node_modules/@types/node/https.d.ts +400 -0
- package/node_modules/baileys/node_modules/@types/node/index.d.ts +115 -0
- package/node_modules/baileys/node_modules/@types/node/inspector/promises.d.ts +35 -0
- package/node_modules/baileys/node_modules/@types/node/inspector.d.ts +264 -0
- package/node_modules/baileys/node_modules/@types/node/inspector.generated.d.ts +4406 -0
- package/node_modules/baileys/node_modules/@types/node/module.d.ts +726 -0
- package/node_modules/baileys/node_modules/@types/node/net.d.ts +970 -0
- package/node_modules/baileys/node_modules/@types/node/os.d.ts +498 -0
- package/node_modules/baileys/node_modules/@types/node/package.json +155 -0
- package/node_modules/baileys/node_modules/@types/node/path/posix.d.ts +8 -0
- package/node_modules/baileys/node_modules/@types/node/path/win32.d.ts +8 -0
- package/node_modules/baileys/node_modules/@types/node/path.d.ts +178 -0
- package/node_modules/baileys/node_modules/@types/node/perf_hooks.d.ts +604 -0
- package/node_modules/baileys/node_modules/@types/node/process.d.ts +2217 -0
- package/node_modules/baileys/node_modules/@types/node/punycode.d.ts +89 -0
- package/node_modules/baileys/node_modules/@types/node/querystring.d.ts +139 -0
- package/node_modules/baileys/node_modules/@types/node/quic.d.ts +978 -0
- package/node_modules/baileys/node_modules/@types/node/readline/promises.d.ts +158 -0
- package/node_modules/baileys/node_modules/@types/node/readline.d.ts +508 -0
- package/node_modules/baileys/node_modules/@types/node/repl.d.ts +420 -0
- package/node_modules/baileys/node_modules/@types/node/sea.d.ts +47 -0
- package/node_modules/baileys/node_modules/@types/node/sqlite.d.ts +1123 -0
- package/node_modules/baileys/node_modules/@types/node/stream/consumers.d.ts +114 -0
- package/node_modules/baileys/node_modules/@types/node/stream/iter.d.ts +451 -0
- package/node_modules/baileys/node_modules/@types/node/stream/promises.d.ts +211 -0
- package/node_modules/baileys/node_modules/@types/node/stream/web.d.ts +300 -0
- package/node_modules/baileys/node_modules/@types/node/stream.d.ts +1806 -0
- package/node_modules/baileys/node_modules/@types/node/string_decoder.d.ts +27 -0
- package/node_modules/baileys/node_modules/@types/node/test/reporters.d.ts +59 -0
- package/node_modules/baileys/node_modules/@types/node/test.d.ts +2389 -0
- package/node_modules/baileys/node_modules/@types/node/timers/promises.d.ts +93 -0
- package/node_modules/baileys/node_modules/@types/node/timers.d.ts +149 -0
- package/node_modules/baileys/node_modules/@types/node/tls.d.ts +1193 -0
- package/node_modules/baileys/node_modules/@types/node/trace_events.d.ts +103 -0
- package/node_modules/baileys/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +462 -0
- package/node_modules/baileys/node_modules/@types/node/ts5.6/compatibility/float16array.d.ts +71 -0
- package/node_modules/baileys/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +36 -0
- package/node_modules/baileys/node_modules/@types/node/ts5.6/index.d.ts +117 -0
- package/node_modules/baileys/node_modules/@types/node/ts5.7/compatibility/float16array.d.ts +72 -0
- package/node_modules/baileys/node_modules/@types/node/ts5.7/index.d.ts +117 -0
- package/node_modules/baileys/node_modules/@types/node/tty.d.ts +225 -0
- package/node_modules/baileys/node_modules/@types/node/url.d.ts +556 -0
- package/node_modules/baileys/node_modules/@types/node/util/types.d.ts +558 -0
- package/node_modules/baileys/node_modules/@types/node/util.d.ts +1677 -0
- package/node_modules/baileys/node_modules/@types/node/v8.d.ts +1062 -0
- package/node_modules/baileys/node_modules/@types/node/vm.d.ts +1136 -0
- package/node_modules/baileys/node_modules/@types/node/wasi.d.ts +131 -0
- package/node_modules/baileys/node_modules/@types/node/web-globals/abortcontroller.d.ts +59 -0
- package/node_modules/baileys/node_modules/@types/node/web-globals/blob.d.ts +23 -0
- package/node_modules/baileys/node_modules/@types/node/web-globals/console.d.ts +9 -0
- package/node_modules/baileys/node_modules/@types/node/web-globals/crypto.d.ts +39 -0
- package/node_modules/baileys/node_modules/@types/node/web-globals/domexception.d.ts +83 -0
- package/node_modules/baileys/node_modules/@types/node/web-globals/encoding.d.ts +11 -0
- package/node_modules/baileys/node_modules/@types/node/web-globals/events.d.ts +106 -0
- package/node_modules/baileys/node_modules/@types/node/web-globals/fetch.d.ts +69 -0
- package/node_modules/baileys/node_modules/@types/node/web-globals/importmeta.d.ts +13 -0
- package/node_modules/baileys/node_modules/@types/node/web-globals/messaging.d.ts +23 -0
- package/node_modules/baileys/node_modules/@types/node/web-globals/navigator.d.ts +25 -0
- package/node_modules/baileys/node_modules/@types/node/web-globals/performance.d.ts +45 -0
- package/node_modules/baileys/node_modules/@types/node/web-globals/storage.d.ts +24 -0
- package/node_modules/baileys/node_modules/@types/node/web-globals/streams.d.ts +115 -0
- package/node_modules/baileys/node_modules/@types/node/web-globals/timers.d.ts +44 -0
- package/node_modules/baileys/node_modules/@types/node/web-globals/url.d.ts +24 -0
- package/node_modules/baileys/node_modules/@types/node/worker_threads.d.ts +669 -0
- package/node_modules/baileys/node_modules/@types/node/zlib/iter.d.ts +131 -0
- package/node_modules/baileys/node_modules/@types/node/zlib.d.ts +589 -0
- package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/browser/index.d.ts.map +1 -1
- package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/browser/index.js +4 -11
- package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/browser/index.js.map +1 -1
- package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/browser/index.min.js +1 -1
- package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/browser/index.min.js.map +3 -3
- package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/index.d.ts.map +1 -1
- package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/index.js +4 -11
- package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/index.js.map +1 -1
- package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/index.min.js +1 -1
- package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/index.min.js.map +3 -3
- package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/node/index.d.ts.map +1 -1
- package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/node/index.js +4 -11
- package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/node/index.js.map +1 -1
- package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/node/index.min.js +1 -1
- package/node_modules/baileys/node_modules/lru-cache/dist/commonjs/node/index.min.js.map +3 -3
- package/node_modules/baileys/node_modules/lru-cache/dist/esm/browser/index.d.ts.map +1 -1
- package/node_modules/baileys/node_modules/lru-cache/dist/esm/browser/index.js +4 -11
- package/node_modules/baileys/node_modules/lru-cache/dist/esm/browser/index.js.map +1 -1
- package/node_modules/baileys/node_modules/lru-cache/dist/esm/browser/index.min.js +1 -1
- package/node_modules/baileys/node_modules/lru-cache/dist/esm/browser/index.min.js.map +3 -3
- package/node_modules/baileys/node_modules/lru-cache/dist/esm/index.d.ts.map +1 -1
- package/node_modules/baileys/node_modules/lru-cache/dist/esm/index.js +4 -11
- package/node_modules/baileys/node_modules/lru-cache/dist/esm/index.js.map +1 -1
- package/node_modules/baileys/node_modules/lru-cache/dist/esm/index.min.js +1 -1
- package/node_modules/baileys/node_modules/lru-cache/dist/esm/index.min.js.map +3 -3
- package/node_modules/baileys/node_modules/lru-cache/dist/esm/node/index.d.ts.map +1 -1
- package/node_modules/baileys/node_modules/lru-cache/dist/esm/node/index.js +4 -11
- package/node_modules/baileys/node_modules/lru-cache/dist/esm/node/index.js.map +1 -1
- package/node_modules/baileys/node_modules/lru-cache/dist/esm/node/index.min.js +1 -1
- package/node_modules/baileys/node_modules/lru-cache/dist/esm/node/index.min.js.map +3 -3
- package/node_modules/baileys/node_modules/lru-cache/package.json +1 -1
- package/node_modules/baileys/node_modules/music-metadata/lib/common/Util.d.ts +1 -1
- package/node_modules/baileys/node_modules/music-metadata/lib/common/Util.js +1 -7
- package/node_modules/baileys/node_modules/music-metadata/lib/id3v2/FrameHeader.js +3 -23
- package/node_modules/baileys/node_modules/music-metadata/lib/id3v2/FrameParser.js +2 -2
- package/node_modules/baileys/node_modules/music-metadata/lib/id3v2/ID3v2Token.js +1 -1
- package/node_modules/baileys/node_modules/music-metadata/lib/mp4/AtomToken.js +13 -38
- package/node_modules/baileys/node_modules/music-metadata/lib/mpeg/MpegParser.js +1 -1
- package/node_modules/baileys/node_modules/music-metadata/package.json +6 -6
- package/node_modules/baileys/node_modules/p-queue/dist/index.js +27 -37
- package/node_modules/baileys/node_modules/p-queue/package.json +1 -1
- package/node_modules/baileys/node_modules/protobufjs/README.md +553 -266
- package/node_modules/baileys/node_modules/protobufjs/dist/light/protobuf.js +1985 -3177
- package/node_modules/baileys/node_modules/protobufjs/dist/light/protobuf.js.map +1 -1
- package/node_modules/baileys/node_modules/protobufjs/dist/light/protobuf.min.js +3 -3
- package/node_modules/baileys/node_modules/protobufjs/dist/light/protobuf.min.js.map +1 -1
- package/node_modules/baileys/node_modules/protobufjs/dist/minimal/protobuf.js +1244 -1966
- package/node_modules/baileys/node_modules/protobufjs/dist/minimal/protobuf.js.map +1 -1
- package/node_modules/baileys/node_modules/protobufjs/dist/minimal/protobuf.min.js +3 -3
- package/node_modules/baileys/node_modules/protobufjs/dist/minimal/protobuf.min.js.map +1 -1
- package/node_modules/baileys/node_modules/protobufjs/dist/protobuf.js +2005 -3330
- package/node_modules/baileys/node_modules/protobufjs/dist/protobuf.js.map +1 -1
- package/node_modules/baileys/node_modules/protobufjs/dist/protobuf.min.js +3 -3
- package/node_modules/baileys/node_modules/protobufjs/dist/protobuf.min.js.map +1 -1
- package/node_modules/baileys/node_modules/protobufjs/ext/descriptor/README.md +70 -3
- package/node_modules/baileys/node_modules/protobufjs/ext/descriptor/index.d.ts +193 -0
- package/node_modules/baileys/node_modules/protobufjs/ext/descriptor/index.js +1185 -1
- package/node_modules/baileys/node_modules/protobufjs/ext/descriptor/test.js +54 -0
- package/node_modules/baileys/node_modules/protobufjs/google/api/annotations.json +1 -3
- package/node_modules/baileys/node_modules/protobufjs/google/api/http.json +1 -2
- package/node_modules/baileys/node_modules/protobufjs/google/protobuf/api.json +6 -12
- package/node_modules/baileys/node_modules/protobufjs/google/protobuf/descriptor.json +87 -170
- package/node_modules/baileys/node_modules/protobufjs/google/protobuf/descriptor.proto +8 -0
- package/node_modules/baileys/node_modules/protobufjs/google/protobuf/source_context.json +1 -2
- package/node_modules/baileys/node_modules/protobufjs/google/protobuf/type.json +7 -14
- package/node_modules/baileys/node_modules/protobufjs/index.d.ts +703 -1066
- package/node_modules/baileys/node_modules/protobufjs/package.json +52 -25
- package/node_modules/baileys/node_modules/protobufjs/scripts/postinstall.js +32 -0
- package/node_modules/baileys/node_modules/protobufjs/src/common.js +8 -14
- package/node_modules/baileys/node_modules/protobufjs/src/converter.js +51 -85
- package/node_modules/baileys/node_modules/protobufjs/src/decoder.js +61 -205
- package/node_modules/baileys/node_modules/protobufjs/src/encoder.js +7 -27
- package/node_modules/baileys/node_modules/protobufjs/src/enum.js +5 -18
- package/node_modules/baileys/node_modules/protobufjs/src/field.js +19 -71
- package/node_modules/baileys/node_modules/protobufjs/src/index-light.js +29 -29
- package/node_modules/baileys/node_modules/protobufjs/src/index-minimal.js +13 -12
- package/node_modules/baileys/node_modules/protobufjs/src/index.js +6 -6
- package/node_modules/baileys/node_modules/protobufjs/src/mapfield.js +8 -26
- package/node_modules/baileys/node_modules/protobufjs/src/message.js +11 -5
- package/node_modules/baileys/node_modules/protobufjs/src/method.js +7 -30
- package/node_modules/baileys/node_modules/protobufjs/src/namespace.js +10 -26
- package/node_modules/baileys/node_modules/protobufjs/src/object.js +31 -41
- package/node_modules/baileys/node_modules/protobufjs/src/oneof.js +1 -12
- package/node_modules/baileys/node_modules/protobufjs/src/parse.js +47 -169
- package/node_modules/baileys/node_modules/protobufjs/src/reader.js +50 -412
- package/node_modules/baileys/node_modules/protobufjs/src/reader_buffer.js +5 -31
- package/node_modules/baileys/node_modules/protobufjs/src/root.js +4 -16
- package/node_modules/baileys/node_modules/protobufjs/src/rpc/service.js +5 -18
- package/node_modules/baileys/node_modules/protobufjs/src/service.js +2 -15
- package/node_modules/baileys/node_modules/protobufjs/src/tokenize.js +1 -6
- package/node_modules/baileys/node_modules/protobufjs/src/type.js +36 -80
- package/node_modules/baileys/node_modules/protobufjs/src/typescript.jsdoc +15 -0
- package/node_modules/baileys/node_modules/protobufjs/src/util/longbits.js +6 -10
- package/node_modules/baileys/node_modules/protobufjs/src/util/minimal.js +54 -71
- package/node_modules/baileys/node_modules/protobufjs/src/util.js +17 -51
- package/node_modules/baileys/node_modules/protobufjs/src/verifier.js +14 -19
- package/node_modules/baileys/node_modules/protobufjs/src/wrappers.js +3 -2
- package/node_modules/baileys/node_modules/protobufjs/src/writer.js +191 -424
- package/node_modules/baileys/node_modules/protobufjs/src/writer_buffer.js +26 -41
- package/node_modules/baileys/node_modules/protobufjs/tsconfig.json +5 -3
- package/node_modules/baileys/node_modules/undici-types/LICENSE +21 -0
- package/node_modules/baileys/node_modules/undici-types/README.md +6 -0
- package/node_modules/baileys/node_modules/undici-types/agent.d.ts +30 -0
- package/node_modules/baileys/node_modules/undici-types/api.d.ts +43 -0
- package/node_modules/baileys/node_modules/undici-types/balanced-pool.d.ts +30 -0
- package/node_modules/baileys/node_modules/undici-types/cache-interceptor.d.ts +179 -0
- package/node_modules/baileys/node_modules/undici-types/cache.d.ts +36 -0
- package/node_modules/baileys/node_modules/undici-types/client-stats.d.ts +15 -0
- package/node_modules/baileys/node_modules/undici-types/client.d.ts +129 -0
- package/node_modules/baileys/node_modules/undici-types/connector.d.ts +36 -0
- package/node_modules/baileys/node_modules/undici-types/content-type.d.ts +21 -0
- package/node_modules/baileys/node_modules/undici-types/cookies.d.ts +30 -0
- package/node_modules/baileys/node_modules/undici-types/diagnostics-channel.d.ts +74 -0
- package/node_modules/baileys/node_modules/undici-types/dispatcher.d.ts +253 -0
- package/node_modules/baileys/node_modules/undici-types/dispatcher1-wrapper.d.ts +7 -0
- package/node_modules/baileys/node_modules/undici-types/env-http-proxy-agent.d.ts +22 -0
- package/node_modules/baileys/node_modules/undici-types/errors.d.ts +177 -0
- package/node_modules/baileys/node_modules/undici-types/eventsource.d.ts +66 -0
- package/node_modules/baileys/node_modules/undici-types/fetch.d.ts +231 -0
- package/node_modules/baileys/node_modules/undici-types/formdata.d.ts +108 -0
- package/node_modules/baileys/node_modules/undici-types/global-dispatcher.d.ts +9 -0
- package/node_modules/baileys/node_modules/undici-types/global-origin.d.ts +7 -0
- package/node_modules/baileys/node_modules/undici-types/h2c-client.d.ts +73 -0
- package/node_modules/baileys/node_modules/undici-types/handlers.d.ts +14 -0
- package/node_modules/baileys/node_modules/undici-types/header.d.ts +165 -0
- package/node_modules/baileys/node_modules/undici-types/index.d.ts +93 -0
- package/node_modules/baileys/node_modules/undici-types/interceptors.d.ts +80 -0
- package/node_modules/baileys/node_modules/undici-types/mock-agent.d.ts +68 -0
- package/node_modules/baileys/node_modules/undici-types/mock-call-history.d.ts +111 -0
- package/node_modules/baileys/node_modules/undici-types/mock-client.d.ts +27 -0
- package/node_modules/baileys/node_modules/undici-types/mock-errors.d.ts +12 -0
- package/node_modules/baileys/node_modules/undici-types/mock-interceptor.d.ts +94 -0
- package/node_modules/baileys/node_modules/undici-types/mock-pool.d.ts +27 -0
- package/node_modules/baileys/node_modules/undici-types/package.json +55 -0
- package/node_modules/baileys/node_modules/undici-types/patch.d.ts +29 -0
- package/node_modules/baileys/node_modules/undici-types/pool-stats.d.ts +19 -0
- package/node_modules/baileys/node_modules/undici-types/pool.d.ts +39 -0
- package/node_modules/baileys/node_modules/undici-types/proxy-agent.d.ts +29 -0
- package/node_modules/baileys/node_modules/undici-types/readable.d.ts +68 -0
- package/node_modules/baileys/node_modules/undici-types/retry-agent.d.ts +8 -0
- package/node_modules/baileys/node_modules/undici-types/retry-handler.d.ts +125 -0
- package/node_modules/baileys/node_modules/undici-types/round-robin-pool.d.ts +39 -0
- package/node_modules/baileys/node_modules/undici-types/snapshot-agent.d.ts +113 -0
- package/node_modules/baileys/node_modules/undici-types/socks5-proxy-agent.d.ts +25 -0
- package/node_modules/baileys/node_modules/undici-types/util.d.ts +18 -0
- package/node_modules/baileys/node_modules/undici-types/utility.d.ts +7 -0
- package/node_modules/baileys/node_modules/undici-types/webidl.d.ts +346 -0
- package/node_modules/baileys/node_modules/undici-types/websocket.d.ts +188 -0
- package/node_modules/baileys/node_modules/ws/lib/permessage-deflate.js +3 -1
- package/node_modules/baileys/node_modules/ws/package.json +1 -1
- package/node_modules/typebox/build/compile/validator.d.mts +4 -1
- package/node_modules/typebox/build/guard/guard.d.mts +1 -1
- package/node_modules/typebox/build/guard/guard.mjs +2 -5
- package/node_modules/typebox/build/guard/string.mjs +4 -16
- package/node_modules/typebox/build/schema/engine/_functions.mjs +15 -34
- package/node_modules/typebox/build/type/action/readonly_object.d.mts +0 -5
- package/node_modules/typebox/build/type/action/readonly_object.mjs +0 -8
- package/node_modules/typebox/build/typebox.d.mts +1 -1
- package/node_modules/typebox/build/typebox.mjs +1 -1
- package/node_modules/typebox/package.json +1 -1
- package/node_modules/typebox/readme.md +32 -29
- package/openclaw.plugin.json +239 -214
- package/package.json +11 -21
- package/dist/approval-reactions-Cu66aYdq.js +0 -373
- package/dist/channel.setup-pMwNVkCA.js +0 -19
- package/dist/config-schema-BQP5YCeK.js +0 -50
- package/dist/connection-controller-runtime-context-DG0tuYuw.js +0 -23
- package/dist/directory-config-DalGrfGN.js +0 -196
- package/dist/doctor-CwzVXKoE.js +0 -10
- package/dist/normalize-C7Hkc_vE.js +0 -2
- package/dist/question-reactions-CRsnyoMK.js +0 -142
- package/dist/runtime-BLlToOi6.js +0 -21
- package/dist/send-D37ddk22.js +0 -436
- package/dist/session.runtime-Nsqaehbd.js +0 -16
- package/dist/socket-close-DridEuzz.js +0 -622
- package/dist/targets-runtime-TMk0lGuy.js +0 -299
- package/dist/text-runtime-CaKLhowd.js +0 -4
- package/node_modules/baileys/node_modules/protobufjs/ext/README.md +0 -70
- package/node_modules/baileys/node_modules/protobufjs/ext/descriptor.d.ts +0 -87
- package/node_modules/baileys/node_modules/protobufjs/ext/descriptor.generated.d.ts +0 -417
- package/node_modules/baileys/node_modules/protobufjs/ext/descriptor.js +0 -1356
- package/node_modules/baileys/node_modules/protobufjs/ext/protojson.LICENSE +0 -201
- package/node_modules/baileys/node_modules/protobufjs/ext/protojson.d.ts +0 -20
- package/node_modules/baileys/node_modules/protobufjs/ext/protojson.generated.d.ts +0 -49
- package/node_modules/baileys/node_modules/protobufjs/ext/protojson.js +0 -951
- package/node_modules/baileys/node_modules/protobufjs/ext/textformat.d.ts +0 -19
- package/node_modules/baileys/node_modules/protobufjs/ext/textformat.generated.d.ts +0 -33
- package/node_modules/baileys/node_modules/protobufjs/ext/textformat.js +0 -1276
- package/node_modules/baileys/node_modules/protobufjs/google/protobuf/compiler/plugin.json +0 -126
- package/node_modules/baileys/node_modules/protobufjs/google/protobuf/compiler/plugin.proto +0 -47
- package/node_modules/baileys/node_modules/protobufjs/src/typescript.js +0 -25
- /package/dist/{account-ids-CB5SOWjc.js → .setup/account-ids-CB5SOWjc.mjs} +0 -0
- /package/dist/{audio-preflight.runtime-C_glQhZY.js → .setup/audio-preflight.runtime-C_glQhZY.mjs} +0 -0
- /package/dist/{command-policy-BIOSHySD.js → .setup/command-policy-BIOSHySD.mjs} +0 -0
- /package/dist/{creds-files-B1kSWtBg.js → .setup/creds-files-B1kSWtBg.mjs} +0 -0
- /package/dist/{group-config-path-BGyzT9Lg.js → .setup/group-config-path-BGyzT9Lg.mjs} +0 -0
- /package/dist/{group-session-contract-DDnZSsJ1.js → .setup/group-session-contract-DDnZSsJ1.mjs} +0 -0
- /package/dist/{reply-resolver.runtime-Ded8D58Y.js → .setup/reply-resolver.runtime-Ded8D58Y.mjs} +0 -0
- /package/dist/{rolldown-runtime-D7D4PA-g.js → .setup/rolldown-runtime-D7D4PA-g.mjs} +0 -0
- /package/dist/{security-contract-nAzD945y.js → .setup/security-contract-nAzD945y.mjs} +0 -0
- /package/dist/{session-contract-DMTm6Q_L.js → .setup/session-contract-DMTm6Q_L.mjs} +0 -0
- /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 };
|