@noxsoft/anima 2.0.0
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/CHANGELOG.md +2065 -0
- package/LICENSE +23 -0
- package/README.md +47 -0
- package/anima.mjs +56 -0
- package/dist/accounts-Cc5E4IDO.js +260 -0
- package/dist/accounts-CcVrwKqv.js +259 -0
- package/dist/acp-cli-BbvR4dNz.js +1081 -0
- package/dist/acp-cli-CePIi7gD.js +1084 -0
- package/dist/agent-CSrGrAg1.js +725 -0
- package/dist/agent-NgeWEcBM.js +725 -0
- package/dist/agent-events-UF0DxwKS.js +182 -0
- package/dist/agent-scope-BVf4aSwY.js +112 -0
- package/dist/agent-scope-OZi7lb8S.js +452 -0
- package/dist/agent-scope-V1bi9OYL.js +452 -0
- package/dist/agents-Bw06WthM.js +809 -0
- package/dist/agents.config-Dvo2ULxs.js +182 -0
- package/dist/agents.config-d6H0_3oj.js +182 -0
- package/dist/argv-DqUHKf0o.js +73 -0
- package/dist/audit-Buja3mbS.js +2401 -0
- package/dist/audit-CWIz6mM7.js +2401 -0
- package/dist/auth-91o2YM96.js +648 -0
- package/dist/auth-choice-7dFCqblU.js +2681 -0
- package/dist/auth-choice-S_0K9gpl.js +2681 -0
- package/dist/auth-health-CctpRTdC.js +149 -0
- package/dist/auth-health-DoHai4eD.js +149 -0
- package/dist/auth-lZ26wsbN.js +639 -0
- package/dist/auth-profiles-Cz2rxrav.js +2690 -0
- package/dist/auth-profiles-_5BsNObq.js +1565 -0
- package/dist/banner-ieAUufx9.js +294 -0
- package/dist/boolean-Ce2-qkSB.js +30 -0
- package/dist/boolean-Wzu0-e0P.js +30 -0
- package/dist/brew-CVZkr0GU.js +46 -0
- package/dist/brew-DAdyX1_1.js +46 -0
- package/dist/browser-cli-D_qgYDik.js +1679 -0
- package/dist/browser-cli-DldrdaCW.js +1676 -0
- package/dist/budget-ChKARYPY.js +132 -0
- package/dist/budget-Dspr6N_e.js +132 -0
- package/dist/build-info.json +5 -0
- package/dist/bundled/boot-md/HOOK.md +19 -0
- package/dist/bundled/boot-md/handler.js +861 -0
- package/dist/bundled/bootstrap-extra-files/HOOK.md +53 -0
- package/dist/bundled/bootstrap-extra-files/handler.js +39 -0
- package/dist/bundled/command-logger/HOOK.md +122 -0
- package/dist/bundled/command-logger/handler.js +55 -0
- package/dist/bundled/session-memory/HOOK.md +109 -0
- package/dist/bundled/session-memory/handler.js +128 -0
- package/dist/call-DPzNR_Qi.js +282 -0
- package/dist/call-ktoEhkOQ.js +282 -0
- package/dist/canvas-host/a2ui/.bundle.hash +1 -0
- package/dist/canvas-host/a2ui/a2ui.bundle.js +19040 -0
- package/dist/canvas-host/a2ui/index.html +307 -0
- package/dist/catalog-BAayBt1L.js +185 -0
- package/dist/catalog-BNsf97BM.js +185 -0
- package/dist/channel-options-C3GV4Fgg.js +33 -0
- package/dist/channel-options-DJ4GNfwk.js +32 -0
- package/dist/channel-selection-CujyiWGM.js +51 -0
- package/dist/channel-selection-DfGpCyh2.js +51 -0
- package/dist/channel-web-D42mzlCJ.js +2162 -0
- package/dist/channels-cli-BAtARz4A.js +1306 -0
- package/dist/channels-cli-Ddo_tIRR.js +1304 -0
- package/dist/channels-status-issues-DBc1pU_R.js +18 -0
- package/dist/channels-status-issues-DjO9MHIG.js +18 -0
- package/dist/chrome-Bi6iZ5sG.js +1601 -0
- package/dist/chrome-DNSv7Cpy.js +1629 -0
- package/dist/chrome-DScZx4Lk.js +1601 -0
- package/dist/chunk-mxPVo000.js +348 -0
- package/dist/clack-prompter-B0kl7shw.js +92 -0
- package/dist/clack-prompter-B1YxZdRy.js +92 -0
- package/dist/cli/daemon-cli.js +9 -0
- package/dist/cli-D3hUnL_G.js +101 -0
- package/dist/cli-DDwD6VgH.js +99 -0
- package/dist/cli-session-CP7ZH2-6.js +5463 -0
- package/dist/cli-session-oXJQpenl.js +5408 -0
- package/dist/cli-utils-BTBABPX9.js +40 -0
- package/dist/cli-utils-DtAxdCte.js +40 -0
- package/dist/client-C1avc0vD.js +1692 -0
- package/dist/client-CC94YZrT.js +1692 -0
- package/dist/clipboard-B2fBy8tG.js +31 -0
- package/dist/clipboard-BbGnZskJ.js +31 -0
- package/dist/command-format-Clp46jkj.js +38 -0
- package/dist/command-format-DELazozB.js +52 -0
- package/dist/command-format-SkzzRqR1.js +52 -0
- package/dist/command-options-CSbuuqHr.js +8 -0
- package/dist/command-options-Cp1tf96a.js +8 -0
- package/dist/command-registry-DDGudZEQ.js +248 -0
- package/dist/commands-CRcFD5MO.js +509 -0
- package/dist/commands-Dh40OpQL.js +509 -0
- package/dist/commands-registry-Bd0xbvwG.js +766 -0
- package/dist/commands-registry-DYfRSVF3.js +766 -0
- package/dist/common-D6bu0zHC.js +287 -0
- package/dist/common-zW9Y2P1B.js +287 -0
- package/dist/completion-cli-B9Cn374l.js +431 -0
- package/dist/completion-cli-BEHghUFx.js +432 -0
- package/dist/config-Bmm8tmZF.js +6523 -0
- package/dist/config-CHc5qzaI.js +5704 -0
- package/dist/config-Co6UXXF5.js +11 -0
- package/dist/config-Xm0j9LUa.js +5705 -0
- package/dist/config-cli-9ZbCHoV8.js +247 -0
- package/dist/config-cli-sxuGl29N.js +244 -0
- package/dist/config-guard-BwRD-b9Z.js +93 -0
- package/dist/config-guard-Dy7wyhAX.js +76 -0
- package/dist/config-sync-Bllc1TJ4.js +89 -0
- package/dist/config-sync-mfuOoGHl.js +89 -0
- package/dist/configure-CCyVzQZ7.js +1006 -0
- package/dist/configure-Nntbxt4t.js +1008 -0
- package/dist/constants-BwBn5CGe.js +65 -0
- package/dist/constants-O8yBqCBv.js +65 -0
- package/dist/context-DKaQYnCH.js +60 -0
- package/dist/control-service-BeOtZCCS.js +72 -0
- package/dist/control-service-vyKJ-XUp.js +72 -0
- package/dist/cron-cli-BasqtsJ0.js +451 -0
- package/dist/cron-cli-C8XzIpyX.js +448 -0
- package/dist/daemon-cli-cwL2GI5i.js +565 -0
- package/dist/daemon-cli-sjDh2xbf.js +566 -0
- package/dist/daemon-cli.js +13117 -0
- package/dist/daemon-runtime-BuMT6nck.js +460 -0
- package/dist/daemon-runtime-CTvi3m4D.js +460 -0
- package/dist/dangerous-tools-5ObDWy1N.js +32 -0
- package/dist/dangerous-tools-Jwr7jqNw.js +32 -0
- package/dist/deliver-D6cdhg5m.js +1097 -0
- package/dist/deliver-DlNDKlA4.js +1162 -0
- package/dist/deliver-bC6iI_rv.js +1097 -0
- package/dist/delivery-queue-B6IHz4Ry.js +220 -0
- package/dist/delivery-queue-TnQykYsg.js +220 -0
- package/dist/deps-C9kDG-Ru.js +42 -0
- package/dist/devices-cli-BE-Nib4Y.js +198 -0
- package/dist/devices-cli-GyPlNRyd.js +195 -0
- package/dist/diagnostics-Dj75aEHN.js +35 -0
- package/dist/diagnostics-DlIw6fqD.js +35 -0
- package/dist/directory-cli-BEaIvWkc.js +246 -0
- package/dist/directory-cli-CZ_-DP5Z.js +243 -0
- package/dist/dispatcher-Bkcui7jz.js +100 -0
- package/dist/dispatcher-C1B6cT_7.js +100 -0
- package/dist/display-A8k-mxv8.js +171 -0
- package/dist/display-BDOsXu8F.js +171 -0
- package/dist/dns-cli-BUzpVoMv.js +200 -0
- package/dist/dns-cli-DstQOMQt.js +197 -0
- package/dist/dock-DbxBBv30.js +753 -0
- package/dist/dock-cPBY4qGl.js +753 -0
- package/dist/docs-cli-BWp6p-Tq.js +161 -0
- package/dist/docs-cli-x22FnZfL.js +159 -0
- package/dist/doctor-B5HFw-nC.js +1813 -0
- package/dist/doctor-DnEyqGcQ.js +1815 -0
- package/dist/doctor-completion-BMEPXgVg.js +92 -0
- package/dist/doctor-completion-usPeH2ol.js +92 -0
- package/dist/doctor-config-flow-CS0WFnjL.js +1232 -0
- package/dist/doctor-config-flow-Cs4O_Kmq.js +1232 -0
- package/dist/engine-DgK9s3lk.js +561 -0
- package/dist/engine-ZSd5I5JN.js +561 -0
- package/dist/entry.js +1560 -0
- package/dist/env-0lJfCPsw.js +32 -0
- package/dist/errors-A_GqUU6B.js +26 -0
- package/dist/errors-CHow2wtt.js +37 -0
- package/dist/errors-Cojm0Kl7.js +37 -0
- package/dist/exec-BenD3A5l.js +1167 -0
- package/dist/exec-BizYYQgP.js +255 -0
- package/dist/exec-Bv3pyjeM.js +255 -0
- package/dist/exec-approvals-BP9AhCSw.js +1221 -0
- package/dist/exec-approvals-CdLmKX2R.js +1221 -0
- package/dist/exec-approvals-cli-25CGlFNw.js +368 -0
- package/dist/exec-approvals-cli-BXZ-hOlT.js +371 -0
- package/dist/extensionAPI.js +8542 -0
- package/dist/format-CjKG6raZ.js +20 -0
- package/dist/format-Mq6iU0_5.js +20 -0
- package/dist/format-duration-Cm3xh8xz.js +58 -0
- package/dist/format-duration-DhWzz_5b.js +58 -0
- package/dist/format-relative-C6kUHuOj.js +55 -0
- package/dist/format-relative-sy9iviQN.js +55 -0
- package/dist/frontmatter-YijVi0FQ.js +204 -0
- package/dist/gateway-cli-B9uc0RCI.js +19971 -0
- package/dist/gateway-cli-D8Qz7kCf.js +19972 -0
- package/dist/gateway-rpc-Ch9mCYEB.js +28 -0
- package/dist/gateway-rpc-DBhcdLFs.js +28 -0
- package/dist/github-copilot-auth-D6ZErYqa.js +1418 -0
- package/dist/github-copilot-auth-DGmyWJms.js +1418 -0
- package/dist/gmail-setup-utils-BPo_LkKI.js +428 -0
- package/dist/gmail-setup-utils-D3Yqgor7.js +428 -0
- package/dist/health-DsTZaAzV.js +1258 -0
- package/dist/health-V6dGthLA.js +1253 -0
- package/dist/health-format-CdP99j3Y.js +208 -0
- package/dist/health-format-JEChH08S.js +208 -0
- package/dist/heartbeat-visibility-CkL00WRR.js +98 -0
- package/dist/heartbeat-visibility-Cmni9671.js +98 -0
- package/dist/help-format-DUBI91Ti.js +17 -0
- package/dist/help-format-Dl4bsrLI.js +17 -0
- package/dist/helpers-9N2Q5aZj.js +25 -0
- package/dist/helpers-DLgbkcEn.js +25 -0
- package/dist/helpers-ZKNRexvX.js +10 -0
- package/dist/helpers-eJFa4K6r.js +10 -0
- package/dist/hooks-cli-Cu0D0fPS.js +993 -0
- package/dist/hooks-cli-E63uffR6.js +991 -0
- package/dist/hooks-status-B-e96dZj.js +356 -0
- package/dist/hooks-status-C_9sE0ox.js +356 -0
- package/dist/image-ops-Dlt3T7th.js +541 -0
- package/dist/image-ops-omlvdfah.js +541 -0
- package/dist/index.js +499 -0
- package/dist/init-Bm04RagW.js +122 -0
- package/dist/init-CaJBf4p1.js +122 -0
- package/dist/input-provenance-BgwBljRz.js +35 -0
- package/dist/input-provenance-DJBdpeKk.js +35 -0
- package/dist/input-provenance-iu26y0GH.js +35 -0
- package/dist/installs-C2iMRBVz.js +383 -0
- package/dist/installs-D-cPGdCw.js +383 -0
- package/dist/internal-hooks-DFTIurVM.js +77 -0
- package/dist/ipv4-C5QxzriV.js +1964 -0
- package/dist/ipv4-TxR9wQCQ.js +1964 -0
- package/dist/is-main-Dt9DTcH1.js +25 -0
- package/dist/is-main-cB3p7uob.js +25 -0
- package/dist/lanes-CNxj3tit.js +232 -0
- package/dist/legacy-names-CKU7tKQR.js +8 -0
- package/dist/lifecycle-core-B_7XRcvF.js +388 -0
- package/dist/lifecycle-core-By83PVAK.js +387 -0
- package/dist/links-BfjHVTB_.js +15 -0
- package/dist/links-DPGe0OHw.js +15 -0
- package/dist/llm-slug-generator.js +62 -0
- package/dist/loader-6Qkyybg1.js +87 -0
- package/dist/loader-Dmc0KyQK.js +87 -0
- package/dist/logging-54nXj81z.js +1 -0
- package/dist/logging-BdnOSVPD.js +1 -0
- package/dist/logging-DB6BQmhi.js +15 -0
- package/dist/logging-mcb66J0p.js +15 -0
- package/dist/login--8D8kyRy.js +61 -0
- package/dist/login-C-ugYHKt.js +61 -0
- package/dist/login-CX5Q2fYl.js +59 -0
- package/dist/login-qr-BLmGvITg.js +321 -0
- package/dist/login-qr-BNtuXLKL.js +323 -0
- package/dist/login-qr-PcyTC7Ra.js +326 -0
- package/dist/logs-cli-BEQVkiXp.js +245 -0
- package/dist/logs-cli-CIqiVMkY.js +242 -0
- package/dist/manager-Bsy9ifug.js +3244 -0
- package/dist/manager-CDgcZ51c.js +3246 -0
- package/dist/manager-D7QQ5XrE.js +3244 -0
- package/dist/manifest-registry-CW1zCyRF.js +748 -0
- package/dist/manifest-registry-D4lM2RdV.js +748 -0
- package/dist/markdown-tables-BT1X6jqH.js +347 -0
- package/dist/markdown-tables-DHgOK2vI.js +348 -0
- package/dist/media-THyainiE.js +1342 -0
- package/dist/memory-cli-BmIyAOZm.js +869 -0
- package/dist/memory-cli-BoXdfCLT.js +868 -0
- package/dist/message-channel-dSTVVCyX.js +110 -0
- package/dist/message-channel-w4F2b2F6.js +110 -0
- package/dist/migrate-BR6iAIjO.js +157 -0
- package/dist/migrate-D0EcMs0f.js +157 -0
- package/dist/mime-B1ZoR53M.js +145 -0
- package/dist/mime-Bm1xTtpY.js +145 -0
- package/dist/mime-C1RlpUSs.js +145 -0
- package/dist/model-param-b-C4BL7w0Z.js +16 -0
- package/dist/model-param-b-DPwyNGn8.js +16 -0
- package/dist/model-selection-BnEobs_z.js +2692 -0
- package/dist/models-KLd8Evmq.js +2545 -0
- package/dist/models-cli-D4UFQLid.js +258 -0
- package/dist/models-cli-DJHs5rJF.js +2739 -0
- package/dist/net-B5lXhYLV.js +218 -0
- package/dist/net-CDi_lJMH.js +88 -0
- package/dist/node-cli-BNCJUkgA.js +1319 -0
- package/dist/node-cli-C7S0vk0_.js +1322 -0
- package/dist/node-match-8XZnaid6.js +34 -0
- package/dist/node-match-B3Osv-5C.js +34 -0
- package/dist/node-service-BFxHJsno.js +67 -0
- package/dist/node-service-DUnan4uK.js +67 -0
- package/dist/nodes-cli-DOXhYgc8.js +1200 -0
- package/dist/nodes-cli-wvPZ3HwH.js +1197 -0
- package/dist/nodes-screen-1YiLkqr5.js +234 -0
- package/dist/nodes-screen-DZeD8hE5.js +234 -0
- package/dist/normalize-Dlcj9D3K.js +52 -0
- package/dist/normalize-GDK8JTNW.js +52 -0
- package/dist/note-Bi8Wb8DV.js +73 -0
- package/dist/note-uiuPxhyX.js +73 -0
- package/dist/npm-registry-spec-B-XIShkB.js +351 -0
- package/dist/npm-registry-spec-za3itb5Y.js +351 -0
- package/dist/onboard-DiTRW6CH.js +1165 -0
- package/dist/onboard-channels-BgruIpyg.js +672 -0
- package/dist/onboard-channels-gyq0VHHp.js +672 -0
- package/dist/onboard-helpers-BEaUind0.js +365 -0
- package/dist/onboard-helpers-f5Zprayl.js +365 -0
- package/dist/onboard-lH3XPWAK.js +1166 -0
- package/dist/onboarding-D0FOkXGt.js +910 -0
- package/dist/onboarding-kQVgbiIR.js +911 -0
- package/dist/openclaw-root-0yHXtO35.js +88 -0
- package/dist/openclaw-root-C85WMnVV.js +88 -0
- package/dist/orchestrator-CYTk7mq6.js +355 -0
- package/dist/orchestrator-J6ELnJXl.js +355 -0
- package/dist/outbound-BEq0qbPR.js +214 -0
- package/dist/outbound-BSVD-rjk.js +2062 -0
- package/dist/outbound-DXijk0db.js +214 -0
- package/dist/outbound-send-deps-ANnAhImn.js +14 -0
- package/dist/outbound-send-deps-BNGPU7jV.js +55 -0
- package/dist/pairing-cli-DKUyb6eK.js +118 -0
- package/dist/pairing-cli-ET2p_mXH.js +121 -0
- package/dist/pairing-store-CGYSwICJ.js +388 -0
- package/dist/pairing-store-DqQPqRMe.js +388 -0
- package/dist/parse-6-2MDhdT.js +23 -0
- package/dist/parse-CpunmTOS.js +23 -0
- package/dist/parse-log-line-Bqh1SSzC.js +44 -0
- package/dist/parse-log-line-DUZCjXbl.js +44 -0
- package/dist/parse-port-BKB9Exlg.js +12 -0
- package/dist/parse-port-DrfvwwiL.js +12 -0
- package/dist/parse-timeout-Di_tcEmi.js +16 -0
- package/dist/parse-timeout-vVlESvju.js +16 -0
- package/dist/path-env-Bu6k0jDQ.js +89 -0
- package/dist/path-env-C0zQSjw8.js +89 -0
- package/dist/paths-BTc4nk-6.js +126 -0
- package/dist/paths-BgUi2Z2G.js +54 -0
- package/dist/paths-C6VCWKo3.js +238 -0
- package/dist/paths-CCxa0o9c.js +222 -0
- package/dist/paths-CxRf2rBG.js +129 -0
- package/dist/paths-DcVEkYX5.js +54 -0
- package/dist/paths-hcX1Gqg5.js +129 -0
- package/dist/pi-auth-json-BzX-qyRo.js +82 -0
- package/dist/pi-auth-json-eesA38iW.js +78 -0
- package/dist/pi-auth-json-uEDdgg8K.js +80 -0
- package/dist/pi-embedded-C1Nl7L89.js +22 -0
- package/dist/pi-model-discovery-BkqhoPls.js +20 -0
- package/dist/pi-model-discovery-CQOWUAmK.js +3 -0
- package/dist/pi-model-discovery-DsRqYJLy.js +20 -0
- package/dist/pi-tools.policy-D9AUlreI.js +200 -0
- package/dist/pi-tools.policy-DRDm3v-2.js +200 -0
- package/dist/plugin-auto-enable-C-JwYMlZ.js +282 -0
- package/dist/plugin-auto-enable-DLIDBBfi.js +282 -0
- package/dist/plugin-registry-Bp8mivr-.js +32 -0
- package/dist/plugin-registry-CP7KgCvC.js +32 -0
- package/dist/plugin-sdk/account-id.d.ts +1 -0
- package/dist/plugin-sdk/account-id.js +15 -0
- package/dist/plugin-sdk/agents/agent-paths.d.ts +6 -0
- package/dist/plugin-sdk/agents/agent-scope.d.ts +37 -0
- package/dist/plugin-sdk/agents/anima-tools.d.ts +1 -0
- package/dist/plugin-sdk/agents/apply-patch-update.d.ts +10 -0
- package/dist/plugin-sdk/agents/apply-patch.d.ts +35 -0
- package/dist/plugin-sdk/agents/auth-profiles/constants.d.ts +20 -0
- package/dist/plugin-sdk/agents/auth-profiles/display.d.ts +7 -0
- package/dist/plugin-sdk/agents/auth-profiles/doctor.d.ts +8 -0
- package/dist/plugin-sdk/agents/auth-profiles/external-cli-sync.d.ts +7 -0
- package/dist/plugin-sdk/agents/auth-profiles/oauth.d.ts +12 -0
- package/dist/plugin-sdk/agents/auth-profiles/order.d.ts +8 -0
- package/dist/plugin-sdk/agents/auth-profiles/paths.d.ts +4 -0
- package/dist/plugin-sdk/agents/auth-profiles/profiles.d.ts +23 -0
- package/dist/plugin-sdk/agents/auth-profiles/repair.d.ts +14 -0
- package/dist/plugin-sdk/agents/auth-profiles/session-override.d.ts +18 -0
- package/dist/plugin-sdk/agents/auth-profiles/store.d.ts +10 -0
- package/dist/plugin-sdk/agents/auth-profiles/types.d.ts +60 -0
- package/dist/plugin-sdk/agents/auth-profiles/usage.d.ts +47 -0
- package/dist/plugin-sdk/agents/auth-profiles.d.ts +11 -0
- package/dist/plugin-sdk/agents/bash-process-registry.d.ts +70 -0
- package/dist/plugin-sdk/agents/bash-tools.d.ts +4 -0
- package/dist/plugin-sdk/agents/bash-tools.exec-runtime.d.ts +73 -0
- package/dist/plugin-sdk/agents/bash-tools.exec.d.ts +55 -0
- package/dist/plugin-sdk/agents/bash-tools.process.d.ts +7 -0
- package/dist/plugin-sdk/agents/bash-tools.shared.d.ts +48 -0
- package/dist/plugin-sdk/agents/bedrock-discovery.d.ts +9 -0
- package/dist/plugin-sdk/agents/bootstrap-files.d.ts +25 -0
- package/dist/plugin-sdk/agents/bootstrap-hooks.d.ts +10 -0
- package/dist/plugin-sdk/agents/channel-tools.d.ts +27 -0
- package/dist/plugin-sdk/agents/chutes-oauth.d.ts +46 -0
- package/dist/plugin-sdk/agents/cli-backends.d.ts +8 -0
- package/dist/plugin-sdk/agents/cli-credentials.d.ts +83 -0
- package/dist/plugin-sdk/agents/cli-runner/helpers.d.ts +76 -0
- package/dist/plugin-sdk/agents/cli-runner.d.ts +41 -0
- package/dist/plugin-sdk/agents/cli-session.d.ts +3 -0
- package/dist/plugin-sdk/agents/cloudflare-ai-gateway.d.ts +22 -0
- package/dist/plugin-sdk/agents/context.d.ts +1 -0
- package/dist/plugin-sdk/agents/current-time.d.ts +17 -0
- package/dist/plugin-sdk/agents/date-time.d.ts +13 -0
- package/dist/plugin-sdk/agents/defaults.d.ts +3 -0
- package/dist/plugin-sdk/agents/docs-path.d.ts +6 -0
- package/dist/plugin-sdk/agents/failover-error.d.ts +33 -0
- package/dist/plugin-sdk/agents/glob-pattern.d.ts +18 -0
- package/dist/plugin-sdk/agents/huggingface-models.d.ts +17 -0
- package/dist/plugin-sdk/agents/identity-avatar.d.ts +15 -0
- package/dist/plugin-sdk/agents/identity-file.d.ts +12 -0
- package/dist/plugin-sdk/agents/identity.d.ts +25 -0
- package/dist/plugin-sdk/agents/lanes.d.ts +3 -0
- package/dist/plugin-sdk/agents/memory-search.d.ts +66 -0
- package/dist/plugin-sdk/agents/minimax-vlm.d.ts +7 -0
- package/dist/plugin-sdk/agents/model-alias-lines.d.ts +2 -0
- package/dist/plugin-sdk/agents/model-auth.d.ts +36 -0
- package/dist/plugin-sdk/agents/model-catalog.d.ts +25 -0
- package/dist/plugin-sdk/agents/model-fallback.d.ts +40 -0
- package/dist/plugin-sdk/agents/model-selection.d.ts +94 -0
- package/dist/plugin-sdk/agents/models-config.d.ts +13 -0
- package/dist/plugin-sdk/agents/models-config.providers.d.ts +37 -0
- package/dist/plugin-sdk/agents/ollama-stream.d.ts +45 -0
- package/dist/plugin-sdk/agents/openclaw-tools.d.ts +46 -0
- package/dist/plugin-sdk/agents/pi-auth-json.d.ts +14 -0
- package/dist/plugin-sdk/agents/pi-embedded-helpers.d.ts +7 -0
- package/dist/plugin-sdk/agents/pi-embedded-runner/model.d.ts +1 -0
- package/dist/plugin-sdk/agents/pi-embedded-runner/run/params.d.ts +5 -0
- package/dist/plugin-sdk/agents/pi-embedded-runner.d.ts +25 -0
- package/dist/plugin-sdk/agents/pi-embedded-utils.d.ts +7 -0
- package/dist/plugin-sdk/agents/pi-embedded.d.ts +25 -0
- package/dist/plugin-sdk/agents/pi-model-discovery.d.ts +4 -0
- package/dist/plugin-sdk/agents/pi-settings.d.ts +19 -0
- package/dist/plugin-sdk/agents/pi-tools.abort.d.ts +2 -0
- package/dist/plugin-sdk/agents/pi-tools.before-tool-call.d.ts +29 -0
- package/dist/plugin-sdk/agents/pi-tools.d.ts +69 -0
- package/dist/plugin-sdk/agents/pi-tools.policy.d.ts +37 -0
- package/dist/plugin-sdk/agents/pi-tools.read.d.ts +44 -0
- package/dist/plugin-sdk/agents/pi-tools.schema.d.ts +3 -0
- package/dist/plugin-sdk/agents/pi-tools.types.d.ts +2 -0
- package/dist/plugin-sdk/agents/pty-dsr.d.ts +5 -0
- package/dist/plugin-sdk/agents/pty-keys.d.ts +13 -0
- package/dist/plugin-sdk/agents/sandbox/browser-bridges.d.ts +7 -0
- package/dist/plugin-sdk/agents/sandbox/browser.d.ts +12 -0
- package/dist/plugin-sdk/agents/sandbox/config-hash.d.ts +17 -0
- package/dist/plugin-sdk/agents/sandbox/config.d.ts +26 -0
- package/dist/plugin-sdk/agents/sandbox/constants.d.ts +19 -0
- package/dist/plugin-sdk/agents/sandbox/context.d.ts +12 -0
- package/dist/plugin-sdk/agents/sandbox/docker.d.ts +40 -0
- package/dist/plugin-sdk/agents/sandbox/fs-bridge.d.ts +56 -0
- package/dist/plugin-sdk/agents/sandbox/fs-paths.d.ts +28 -0
- package/dist/plugin-sdk/agents/sandbox/manage.d.ts +13 -0
- package/dist/plugin-sdk/agents/sandbox/prune.d.ts +3 -0
- package/dist/plugin-sdk/agents/sandbox/registry.d.ts +31 -0
- package/dist/plugin-sdk/agents/sandbox/runtime-status.d.ts +18 -0
- package/dist/plugin-sdk/agents/sandbox/shared.d.ts +4 -0
- package/dist/plugin-sdk/agents/sandbox/tool-policy.d.ts +4 -0
- package/dist/plugin-sdk/agents/sandbox/types.d.ts +76 -0
- package/dist/plugin-sdk/agents/sandbox/types.docker.d.ts +25 -0
- package/dist/plugin-sdk/agents/sandbox/workspace.d.ts +1 -0
- package/dist/plugin-sdk/agents/sandbox-paths.d.ts +23 -0
- package/dist/plugin-sdk/agents/sandbox.d.ts +8 -0
- package/dist/plugin-sdk/agents/schema/clean-for-gemini.d.ts +2 -0
- package/dist/plugin-sdk/agents/schema/typebox.d.ts +14 -0
- package/dist/plugin-sdk/agents/session-slug.d.ts +1 -0
- package/dist/plugin-sdk/agents/session-write-lock.d.ts +21 -0
- package/dist/plugin-sdk/agents/shell-utils.d.ts +7 -0
- package/dist/plugin-sdk/agents/skills/bundled-dir.d.ts +7 -0
- package/dist/plugin-sdk/agents/skills/config.d.ts +13 -0
- package/dist/plugin-sdk/agents/skills/env-overrides.d.ts +10 -0
- package/dist/plugin-sdk/agents/skills/frontmatter.d.ts +6 -0
- package/dist/plugin-sdk/agents/skills/plugin-skills.d.ts +5 -0
- package/dist/plugin-sdk/agents/skills/refresh.d.ts +19 -0
- package/dist/plugin-sdk/agents/skills/serialize.d.ts +1 -0
- package/dist/plugin-sdk/agents/skills/types.d.ts +80 -0
- package/dist/plugin-sdk/agents/skills/workspace.d.ts +49 -0
- package/dist/plugin-sdk/agents/skills.d.ts +7 -0
- package/dist/plugin-sdk/agents/subagent-announce-queue.d.ts +23 -0
- package/dist/plugin-sdk/agents/subagent-announce.d.ts +34 -0
- package/dist/plugin-sdk/agents/subagent-depth.d.ts +11 -0
- package/dist/plugin-sdk/agents/subagent-registry.d.ts +62 -0
- package/dist/plugin-sdk/agents/subagent-registry.store.d.ts +5 -0
- package/dist/plugin-sdk/agents/synthetic-models.d.ts +160 -0
- package/dist/plugin-sdk/agents/system-prompt-params.d.ts +30 -0
- package/dist/plugin-sdk/agents/system-prompt-report.d.ts +20 -0
- package/dist/plugin-sdk/agents/system-prompt.d.ts +78 -0
- package/dist/plugin-sdk/agents/timeout.d.ts +8 -0
- package/dist/plugin-sdk/agents/together-models.d.ts +4 -0
- package/dist/plugin-sdk/agents/tool-images.d.ts +19 -0
- package/dist/plugin-sdk/agents/tool-policy-pipeline.d.ts +27 -0
- package/dist/plugin-sdk/agents/tool-policy.d.ts +39 -0
- package/dist/plugin-sdk/agents/tool-summaries.d.ts +2 -0
- package/dist/plugin-sdk/agents/tools/agent-step.d.ts +15 -0
- package/dist/plugin-sdk/agents/tools/agents-list-tool.d.ts +6 -0
- package/dist/plugin-sdk/agents/tools/browser-tool.d.ts +5 -0
- package/dist/plugin-sdk/agents/tools/browser-tool.schema.d.ts +50 -0
- package/dist/plugin-sdk/agents/tools/canvas-tool.d.ts +2 -0
- package/dist/plugin-sdk/agents/tools/common.d.ts +56 -0
- package/dist/plugin-sdk/agents/tools/cron-tool.d.ts +6 -0
- package/dist/plugin-sdk/agents/tools/discord-actions-guild.d.ts +4 -0
- package/dist/plugin-sdk/agents/tools/discord-actions-messaging.d.ts +4 -0
- package/dist/plugin-sdk/agents/tools/discord-actions-moderation.d.ts +4 -0
- package/dist/plugin-sdk/agents/tools/discord-actions-presence.d.ts +4 -0
- package/dist/plugin-sdk/agents/tools/discord-actions.d.ts +3 -0
- package/dist/plugin-sdk/agents/tools/gateway-tool.d.ts +6 -0
- package/dist/plugin-sdk/agents/tools/gateway.d.ts +14 -0
- package/dist/plugin-sdk/agents/tools/image-tool.d.ts +35 -0
- package/dist/plugin-sdk/agents/tools/image-tool.helpers.d.ts +21 -0
- package/dist/plugin-sdk/agents/tools/memory-tool.d.ts +10 -0
- package/dist/plugin-sdk/agents/tools/message-tool.d.ts +18 -0
- package/dist/plugin-sdk/agents/tools/nodes-tool.d.ts +6 -0
- package/dist/plugin-sdk/agents/tools/nodes-utils.d.ts +20 -0
- package/dist/plugin-sdk/agents/tools/session-status-tool.d.ts +6 -0
- package/dist/plugin-sdk/agents/tools/sessions-announce-target.d.ts +5 -0
- package/dist/plugin-sdk/agents/tools/sessions-helpers.d.ts +90 -0
- package/dist/plugin-sdk/agents/tools/sessions-history-tool.d.ts +5 -0
- package/dist/plugin-sdk/agents/tools/sessions-list-tool.d.ts +5 -0
- package/dist/plugin-sdk/agents/tools/sessions-send-helpers.d.ts +34 -0
- package/dist/plugin-sdk/agents/tools/sessions-send-tool.a2a.d.ts +12 -0
- package/dist/plugin-sdk/agents/tools/sessions-send-tool.d.ts +7 -0
- package/dist/plugin-sdk/agents/tools/sessions-spawn-tool.d.ts +15 -0
- package/dist/plugin-sdk/agents/tools/slack-actions.d.ts +15 -0
- package/dist/plugin-sdk/agents/tools/subagents-tool.d.ts +4 -0
- package/dist/plugin-sdk/agents/tools/telegram-actions.d.ts +9 -0
- package/dist/plugin-sdk/agents/tools/tts-tool.d.ts +7 -0
- package/dist/plugin-sdk/agents/tools/web-fetch-utils.d.ts +18 -0
- package/dist/plugin-sdk/agents/tools/web-fetch.d.ts +25 -0
- package/dist/plugin-sdk/agents/tools/web-search.d.ts +71 -0
- package/dist/plugin-sdk/agents/tools/web-shared.d.ts +17 -0
- package/dist/plugin-sdk/agents/tools/web-tools.d.ts +2 -0
- package/dist/plugin-sdk/agents/tools/whatsapp-actions.d.ts +3 -0
- package/dist/plugin-sdk/agents/usage.d.ts +45 -0
- package/dist/plugin-sdk/agents/venice-models.d.ts +238 -0
- package/dist/plugin-sdk/agents/workspace-dir.d.ts +2 -0
- package/dist/plugin-sdk/agents/workspace-run.d.ts +18 -0
- package/dist/plugin-sdk/agents/workspace-templates.d.ts +6 -0
- package/dist/plugin-sdk/agents/workspace.d.ts +34 -0
- package/dist/plugin-sdk/auto-reply/chunk.d.ts +45 -0
- package/dist/plugin-sdk/auto-reply/command-auth.d.ts +17 -0
- package/dist/plugin-sdk/auto-reply/command-detection.d.ts +13 -0
- package/dist/plugin-sdk/auto-reply/commands-args.d.ts +3 -0
- package/dist/plugin-sdk/auto-reply/commands-registry.d.ts +54 -0
- package/dist/plugin-sdk/auto-reply/commands-registry.data.d.ts +3 -0
- package/dist/plugin-sdk/auto-reply/commands-registry.types.d.ts +66 -0
- package/dist/plugin-sdk/auto-reply/dispatch.d.ts +32 -0
- package/dist/plugin-sdk/auto-reply/envelope.d.ts +58 -0
- package/dist/plugin-sdk/auto-reply/group-activation.d.ts +6 -0
- package/dist/plugin-sdk/auto-reply/heartbeat-reply-payload.d.ts +2 -0
- package/dist/plugin-sdk/auto-reply/heartbeat.d.ts +26 -0
- package/dist/plugin-sdk/auto-reply/inbound-debounce.d.ts +16 -0
- package/dist/plugin-sdk/auto-reply/media-note.d.ts +2 -0
- package/dist/plugin-sdk/auto-reply/model.d.ts +8 -0
- package/dist/plugin-sdk/auto-reply/reply/abort.d.ts +22 -0
- package/dist/plugin-sdk/auto-reply/reply/agent-runner-execution.d.ts +49 -0
- package/dist/plugin-sdk/auto-reply/reply/agent-runner-helpers.d.ts +17 -0
- package/dist/plugin-sdk/auto-reply/reply/agent-runner-memory.d.ts +20 -0
- package/dist/plugin-sdk/auto-reply/reply/agent-runner-payloads.d.ts +25 -0
- package/dist/plugin-sdk/auto-reply/reply/agent-runner-utils.d.ts +30 -0
- package/dist/plugin-sdk/auto-reply/reply/agent-runner.d.ts +38 -0
- package/dist/plugin-sdk/auto-reply/reply/bash-command.d.ts +19 -0
- package/dist/plugin-sdk/auto-reply/reply/block-reply-coalescer.d.ts +15 -0
- package/dist/plugin-sdk/auto-reply/reply/block-reply-pipeline.d.ts +31 -0
- package/dist/plugin-sdk/auto-reply/reply/block-streaming.d.ts +22 -0
- package/dist/plugin-sdk/auto-reply/reply/body.d.ts +10 -0
- package/dist/plugin-sdk/auto-reply/reply/commands-allowlist.d.ts +2 -0
- package/dist/plugin-sdk/auto-reply/reply/commands-approve.d.ts +2 -0
- package/dist/plugin-sdk/auto-reply/reply/commands-bash.d.ts +2 -0
- package/dist/plugin-sdk/auto-reply/reply/commands-compact.d.ts +2 -0
- package/dist/plugin-sdk/auto-reply/reply/commands-config.d.ts +3 -0
- package/dist/plugin-sdk/auto-reply/reply/commands-context-report.d.ts +3 -0
- package/dist/plugin-sdk/auto-reply/reply/commands-context.d.ts +12 -0
- package/dist/plugin-sdk/auto-reply/reply/commands-core.d.ts +2 -0
- package/dist/plugin-sdk/auto-reply/reply/commands-info.d.ts +10 -0
- package/dist/plugin-sdk/auto-reply/reply/commands-models.d.ts +23 -0
- package/dist/plugin-sdk/auto-reply/reply/commands-plugin.d.ts +13 -0
- package/dist/plugin-sdk/auto-reply/reply/commands-session.d.ts +7 -0
- package/dist/plugin-sdk/auto-reply/reply/commands-status.d.ts +25 -0
- package/dist/plugin-sdk/auto-reply/reply/commands-subagents.d.ts +13 -0
- package/dist/plugin-sdk/auto-reply/reply/commands-tts.d.ts +2 -0
- package/dist/plugin-sdk/auto-reply/reply/commands-types.d.ts +60 -0
- package/dist/plugin-sdk/auto-reply/reply/commands.d.ts +4 -0
- package/dist/plugin-sdk/auto-reply/reply/config-commands.d.ts +15 -0
- package/dist/plugin-sdk/auto-reply/reply/config-value.d.ts +4 -0
- package/dist/plugin-sdk/auto-reply/reply/debug-commands.d.ts +16 -0
- package/dist/plugin-sdk/auto-reply/reply/directive-handling.auth.d.ts +19 -0
- package/dist/plugin-sdk/auto-reply/reply/directive-handling.d.ts +6 -0
- package/dist/plugin-sdk/auto-reply/reply/directive-handling.fast-lane.d.ts +7 -0
- package/dist/plugin-sdk/auto-reply/reply/directive-handling.impl.d.ts +3 -0
- package/dist/plugin-sdk/auto-reply/reply/directive-handling.model-picker.d.ts +13 -0
- package/dist/plugin-sdk/auto-reply/reply/directive-handling.model.d.ts +42 -0
- package/dist/plugin-sdk/auto-reply/reply/directive-handling.params.d.ts +51 -0
- package/dist/plugin-sdk/auto-reply/reply/directive-handling.parse.d.ts +62 -0
- package/dist/plugin-sdk/auto-reply/reply/directive-handling.persist.d.ts +37 -0
- package/dist/plugin-sdk/auto-reply/reply/directive-handling.queue-validation.d.ts +10 -0
- package/dist/plugin-sdk/auto-reply/reply/directive-handling.shared.d.ts +16 -0
- package/dist/plugin-sdk/auto-reply/reply/directive-parsing.d.ts +5 -0
- package/dist/plugin-sdk/auto-reply/reply/directives.d.ts +38 -0
- package/dist/plugin-sdk/auto-reply/reply/dispatch-from-config.d.ts +16 -0
- package/dist/plugin-sdk/auto-reply/reply/dispatcher-registry.d.ts +24 -0
- package/dist/plugin-sdk/auto-reply/reply/elevated-unavailable.d.ts +8 -0
- package/dist/plugin-sdk/auto-reply/reply/exec/directive.d.ts +20 -0
- package/dist/plugin-sdk/auto-reply/reply/exec.d.ts +1 -0
- package/dist/plugin-sdk/auto-reply/reply/followup-runner.d.ts +16 -0
- package/dist/plugin-sdk/auto-reply/reply/get-reply-directives-apply.d.ts +64 -0
- package/dist/plugin-sdk/auto-reply/reply/get-reply-directives-utils.d.ts +2 -0
- package/dist/plugin-sdk/auto-reply/reply/get-reply-directives.d.ts +92 -0
- package/dist/plugin-sdk/auto-reply/reply/get-reply-inline-actions.d.ts +59 -0
- package/dist/plugin-sdk/auto-reply/reply/get-reply-run.d.ts +69 -0
- package/dist/plugin-sdk/auto-reply/reply/get-reply.d.ts +4 -0
- package/dist/plugin-sdk/auto-reply/reply/groups.d.ts +26 -0
- package/dist/plugin-sdk/auto-reply/reply/history.d.ts +72 -0
- package/dist/plugin-sdk/auto-reply/reply/inbound-context.d.ts +8 -0
- package/dist/plugin-sdk/auto-reply/reply/inbound-dedupe.d.ts +8 -0
- package/dist/plugin-sdk/auto-reply/reply/inbound-meta.d.ts +3 -0
- package/dist/plugin-sdk/auto-reply/reply/inbound-text.d.ts +1 -0
- package/dist/plugin-sdk/auto-reply/reply/line-directives.d.ts +22 -0
- package/dist/plugin-sdk/auto-reply/reply/memory-flush.d.ts +23 -0
- package/dist/plugin-sdk/auto-reply/reply/mentions.d.ts +19 -0
- package/dist/plugin-sdk/auto-reply/reply/model-selection.d.ts +64 -0
- package/dist/plugin-sdk/auto-reply/reply/normalize-reply.d.ts +13 -0
- package/dist/plugin-sdk/auto-reply/reply/provider-dispatcher.d.ts +19 -0
- package/dist/plugin-sdk/auto-reply/reply/queue/cleanup.d.ts +6 -0
- package/dist/plugin-sdk/auto-reply/reply/queue/directive.d.ts +15 -0
- package/dist/plugin-sdk/auto-reply/reply/queue/drain.d.ts +2 -0
- package/dist/plugin-sdk/auto-reply/reply/queue/enqueue.d.ts +3 -0
- package/dist/plugin-sdk/auto-reply/reply/queue/normalize.d.ts +3 -0
- package/dist/plugin-sdk/auto-reply/reply/queue/settings.d.ts +2 -0
- package/dist/plugin-sdk/auto-reply/reply/queue/state.d.ts +19 -0
- package/dist/plugin-sdk/auto-reply/reply/queue/types.d.ts +84 -0
- package/dist/plugin-sdk/auto-reply/reply/queue.d.ts +8 -0
- package/dist/plugin-sdk/auto-reply/reply/reply-delivery.d.ts +27 -0
- package/dist/plugin-sdk/auto-reply/reply/reply-directives.d.ts +14 -0
- package/dist/plugin-sdk/auto-reply/reply/reply-dispatcher.d.ts +52 -0
- package/dist/plugin-sdk/auto-reply/reply/reply-elevated.d.ts +16 -0
- package/dist/plugin-sdk/auto-reply/reply/reply-inline.d.ts +8 -0
- package/dist/plugin-sdk/auto-reply/reply/reply-payloads.d.ts +22 -0
- package/dist/plugin-sdk/auto-reply/reply/reply-tags.d.ts +6 -0
- package/dist/plugin-sdk/auto-reply/reply/reply-threading.d.ts +9 -0
- package/dist/plugin-sdk/auto-reply/reply/response-prefix-template.d.ts +51 -0
- package/dist/plugin-sdk/auto-reply/reply/route-reply.d.ts +56 -0
- package/dist/plugin-sdk/auto-reply/reply/session-reset-model.d.ts +24 -0
- package/dist/plugin-sdk/auto-reply/reply/session-reset-prompt.d.ts +1 -0
- package/dist/plugin-sdk/auto-reply/reply/session-run-accounting.d.ts +11 -0
- package/dist/plugin-sdk/auto-reply/reply/session-updates.d.ts +34 -0
- package/dist/plugin-sdk/auto-reply/reply/session-usage.d.ts +21 -0
- package/dist/plugin-sdk/auto-reply/reply/session.d.ts +26 -0
- package/dist/plugin-sdk/auto-reply/reply/stage-sandbox-media.d.ts +9 -0
- package/dist/plugin-sdk/auto-reply/reply/subagents-utils.d.ts +7 -0
- package/dist/plugin-sdk/auto-reply/reply/typing-mode.d.ts +27 -0
- package/dist/plugin-sdk/auto-reply/reply/typing.d.ts +18 -0
- package/dist/plugin-sdk/auto-reply/reply/untrusted-context.d.ts +1 -0
- package/dist/plugin-sdk/auto-reply/reply.d.ts +6 -0
- package/dist/plugin-sdk/auto-reply/send-policy.d.ts +6 -0
- package/dist/plugin-sdk/auto-reply/skill-commands.d.ts +18 -0
- package/dist/plugin-sdk/auto-reply/status.d.ts +55 -0
- package/dist/plugin-sdk/auto-reply/templating.d.ts +152 -0
- package/dist/plugin-sdk/auto-reply/thinking.d.ts +22 -0
- package/dist/plugin-sdk/auto-reply/tokens.d.ts +3 -0
- package/dist/plugin-sdk/auto-reply/types.d.ts +61 -0
- package/dist/plugin-sdk/browser/bridge-auth-registry.d.ts +8 -0
- package/dist/plugin-sdk/browser/bridge-server.d.ts +18 -0
- package/dist/plugin-sdk/browser/cdp.d.ts +123 -0
- package/dist/plugin-sdk/browser/cdp.helpers.d.ts +13 -0
- package/dist/plugin-sdk/browser/chrome.d.ts +20 -0
- package/dist/plugin-sdk/browser/chrome.executables.d.ts +9 -0
- package/dist/plugin-sdk/browser/chrome.profile-decoration.d.ts +10 -0
- package/dist/plugin-sdk/browser/client-actions-core.d.ts +144 -0
- package/dist/plugin-sdk/browser/client-actions-observe.d.ts +68 -0
- package/dist/plugin-sdk/browser/client-actions-state.d.ts +90 -0
- package/dist/plugin-sdk/browser/client-actions-types.d.ts +18 -0
- package/dist/plugin-sdk/browser/client-actions.d.ts +4 -0
- package/dist/plugin-sdk/browser/client-fetch.d.ts +20 -0
- package/dist/plugin-sdk/browser/client.d.ts +147 -0
- package/dist/plugin-sdk/browser/config.d.ts +39 -0
- package/dist/plugin-sdk/browser/constants.d.ts +8 -0
- package/dist/plugin-sdk/browser/control-auth.d.ts +13 -0
- package/dist/plugin-sdk/browser/control-service.d.ts +5 -0
- package/dist/plugin-sdk/browser/csrf.d.ts +8 -0
- package/dist/plugin-sdk/browser/extension-relay.d.ts +15 -0
- package/dist/plugin-sdk/browser/http-auth.d.ts +5 -0
- package/dist/plugin-sdk/browser/paths.d.ts +27 -0
- package/dist/plugin-sdk/browser/profiles-service.d.ts +25 -0
- package/dist/plugin-sdk/browser/profiles.d.ts +30 -0
- package/dist/plugin-sdk/browser/proxy-files.d.ts +7 -0
- package/dist/plugin-sdk/browser/pw-ai-module.d.ts +6 -0
- package/dist/plugin-sdk/browser/pw-ai-state.d.ts +2 -0
- package/dist/plugin-sdk/browser/pw-ai.d.ts +2 -0
- package/dist/plugin-sdk/browser/pw-role-snapshot.d.ts +35 -0
- package/dist/plugin-sdk/browser/pw-session.d.ts +160 -0
- package/dist/plugin-sdk/browser/pw-tools-core.activity.d.ts +21 -0
- package/dist/plugin-sdk/browser/pw-tools-core.d.ts +8 -0
- package/dist/plugin-sdk/browser/pw-tools-core.downloads.d.ts +34 -0
- package/dist/plugin-sdk/browser/pw-tools-core.interactions.d.ts +114 -0
- package/dist/plugin-sdk/browser/pw-tools-core.responses.d.ts +13 -0
- package/dist/plugin-sdk/browser/pw-tools-core.shared.d.ts +6 -0
- package/dist/plugin-sdk/browser/pw-tools-core.snapshot.d.ts +64 -0
- package/dist/plugin-sdk/browser/pw-tools-core.state.d.ts +46 -0
- package/dist/plugin-sdk/browser/pw-tools-core.storage.d.ts +47 -0
- package/dist/plugin-sdk/browser/pw-tools-core.trace.d.ts +12 -0
- package/dist/plugin-sdk/browser/resolved-config-refresh.d.ts +12 -0
- package/dist/plugin-sdk/browser/routes/agent.act.d.ts +3 -0
- package/dist/plugin-sdk/browser/routes/agent.act.shared.d.ts +10 -0
- package/dist/plugin-sdk/browser/routes/agent.d.ts +3 -0
- package/dist/plugin-sdk/browser/routes/agent.debug.d.ts +3 -0
- package/dist/plugin-sdk/browser/routes/agent.shared.d.ts +9 -0
- package/dist/plugin-sdk/browser/routes/agent.snapshot.d.ts +3 -0
- package/dist/plugin-sdk/browser/routes/agent.storage.d.ts +3 -0
- package/dist/plugin-sdk/browser/routes/basic.d.ts +3 -0
- package/dist/plugin-sdk/browser/routes/dispatcher.d.ts +16 -0
- package/dist/plugin-sdk/browser/routes/index.d.ts +3 -0
- package/dist/plugin-sdk/browser/routes/path-output.d.ts +1 -0
- package/dist/plugin-sdk/browser/routes/tabs.d.ts +3 -0
- package/dist/plugin-sdk/browser/routes/types.d.ts +20 -0
- package/dist/plugin-sdk/browser/routes/utils.d.ts +15 -0
- package/dist/plugin-sdk/browser/screenshot.d.ts +9 -0
- package/dist/plugin-sdk/browser/server-context.d.ts +4 -0
- package/dist/plugin-sdk/browser/server-context.types.d.ts +79 -0
- package/dist/plugin-sdk/browser/server-middleware.d.ts +6 -0
- package/dist/plugin-sdk/browser/target-id.d.ts +11 -0
- package/dist/plugin-sdk/browser/trash.d.ts +1 -0
- package/dist/plugin-sdk/channel-web.d.ts +6 -0
- package/dist/plugin-sdk/channels/account-summary.d.ts +17 -0
- package/dist/plugin-sdk/channels/ack-reactions.d.ts +29 -0
- package/dist/plugin-sdk/channels/allowlist-match.d.ts +15 -0
- package/dist/plugin-sdk/channels/allowlists/resolve-utils.d.ts +20 -0
- package/dist/plugin-sdk/channels/channel-config.d.ts +39 -0
- package/dist/plugin-sdk/channels/chat-type.d.ts +2 -0
- package/dist/plugin-sdk/channels/command-gating.d.ts +20 -0
- package/dist/plugin-sdk/channels/conversation-label.d.ts +2 -0
- package/dist/plugin-sdk/channels/dock.d.ts +36 -0
- package/dist/plugin-sdk/channels/location.d.ts +21 -0
- package/dist/plugin-sdk/channels/logging.d.ts +20 -0
- package/dist/plugin-sdk/channels/mention-gating.d.ts +27 -0
- package/dist/plugin-sdk/channels/plugins/actions/discord/handle-action.d.ts +3 -0
- package/dist/plugin-sdk/channels/plugins/actions/discord/handle-action.guild-admin.d.ts +9 -0
- package/dist/plugin-sdk/channels/plugins/actions/discord.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/actions/signal.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/actions/telegram.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/agent-tools/whatsapp-login.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/allowlist-match.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/bluebubbles-actions.d.ts +48 -0
- package/dist/plugin-sdk/channels/plugins/channel-config.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/config-helpers.d.ts +14 -0
- package/dist/plugin-sdk/channels/plugins/config-schema.d.ts +3 -0
- package/dist/plugin-sdk/channels/plugins/config-writes.d.ts +7 -0
- package/dist/plugin-sdk/channels/plugins/directory-config.d.ts +16 -0
- package/dist/plugin-sdk/channels/plugins/group-mentions.d.ts +28 -0
- package/dist/plugin-sdk/channels/plugins/helpers.d.ts +8 -0
- package/dist/plugin-sdk/channels/plugins/index.d.ts +8 -0
- package/dist/plugin-sdk/channels/plugins/media-limits.d.ts +9 -0
- package/dist/plugin-sdk/channels/plugins/message-action-names.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/message-actions.d.ts +7 -0
- package/dist/plugin-sdk/channels/plugins/normalize/discord.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/normalize/imessage.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/normalize/signal.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/normalize/slack.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/normalize/telegram.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/normalize/whatsapp.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/onboarding/channel-access.d.ts +31 -0
- package/dist/plugin-sdk/channels/plugins/onboarding/discord.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/onboarding/helpers.d.ts +3 -0
- package/dist/plugin-sdk/channels/plugins/onboarding/imessage.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/onboarding/signal.d.ts +3 -0
- package/dist/plugin-sdk/channels/plugins/onboarding/slack.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/onboarding/telegram.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/onboarding/whatsapp.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/onboarding-types.d.ts +77 -0
- package/dist/plugin-sdk/channels/plugins/outbound/load.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/pairing-message.d.ts +1 -0
- package/dist/plugin-sdk/channels/plugins/pairing.d.ts +16 -0
- package/dist/plugin-sdk/channels/plugins/setup-helpers.d.ts +13 -0
- package/dist/plugin-sdk/channels/plugins/status-issues/bluebubbles.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/status-issues/discord.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/status-issues/shared.d.ts +11 -0
- package/dist/plugin-sdk/channels/plugins/status-issues/telegram.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/status-issues/whatsapp.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/types.adapters.d.ts +297 -0
- package/dist/plugin-sdk/channels/plugins/types.core.d.ts +329 -0
- package/dist/plugin-sdk/channels/plugins/types.d.ts +6 -0
- package/dist/plugin-sdk/channels/plugins/types.plugin.d.ts +53 -0
- package/dist/plugin-sdk/channels/plugins/whatsapp-heartbeat.d.ts +11 -0
- package/dist/plugin-sdk/channels/registry.d.ts +16 -0
- package/dist/plugin-sdk/channels/reply-prefix.d.ts +24 -0
- package/dist/plugin-sdk/channels/sender-label.d.ts +9 -0
- package/dist/plugin-sdk/channels/session.d.ts +18 -0
- package/dist/plugin-sdk/channels/typing.d.ts +12 -0
- package/dist/plugin-sdk/channels/web/index.d.ts +1 -0
- package/dist/plugin-sdk/cli/cli-name.d.ts +3 -0
- package/dist/plugin-sdk/cli/cli-utils.d.ts +19 -0
- package/dist/plugin-sdk/cli/command-format.d.ts +1 -0
- package/dist/plugin-sdk/cli/deps.d.ts +18 -0
- package/dist/plugin-sdk/cli/memory-cli.d.ts +12 -0
- package/dist/plugin-sdk/cli/nodes-camera.d.ts +32 -0
- package/dist/plugin-sdk/cli/nodes-canvas.d.ts +10 -0
- package/dist/plugin-sdk/cli/nodes-run.d.ts +3 -0
- package/dist/plugin-sdk/cli/nodes-screen.d.ts +18 -0
- package/dist/plugin-sdk/cli/parse-bytes.d.ts +4 -0
- package/dist/plugin-sdk/cli/parse-duration.d.ts +4 -0
- package/dist/plugin-sdk/cli/parse-timeout.d.ts +1 -0
- package/dist/plugin-sdk/cli/profile-utils.d.ts +2 -0
- package/dist/plugin-sdk/cli/progress.d.ts +24 -0
- package/dist/plugin-sdk/cli/prompt.d.ts +1 -0
- package/dist/plugin-sdk/cli/wait.d.ts +1 -0
- package/dist/plugin-sdk/commands/agent/types.d.ts +77 -0
- package/dist/plugin-sdk/commands/daemon-runtime.d.ts +8 -0
- package/dist/plugin-sdk/commands/health.d.ts +63 -0
- package/dist/plugin-sdk/commands/oauth-flow.d.ts +21 -0
- package/dist/plugin-sdk/commands/onboard-helpers.d.ts +82 -0
- package/dist/plugin-sdk/commands/onboard-types.d.ts +76 -0
- package/dist/plugin-sdk/commands/signal-install.d.ts +30 -0
- package/dist/plugin-sdk/compat/legacy-names.d.ts +8 -0
- package/dist/plugin-sdk/config/agent-dirs.d.ts +14 -0
- package/dist/plugin-sdk/config/agent-limits.d.ts +5 -0
- package/dist/plugin-sdk/config/backup-rotation.d.ts +5 -0
- package/dist/plugin-sdk/config/cache-utils.d.ts +6 -0
- package/dist/plugin-sdk/config/config-paths.d.ts +10 -0
- package/dist/plugin-sdk/config/config.d.ts +7 -0
- package/dist/plugin-sdk/config/defaults.d.ts +18 -0
- package/dist/plugin-sdk/config/env-preserve.d.ts +25 -0
- package/dist/plugin-sdk/config/env-substitution.d.ts +36 -0
- package/dist/plugin-sdk/config/env-vars.d.ts +3 -0
- package/dist/plugin-sdk/config/group-policy.d.ts +47 -0
- package/dist/plugin-sdk/config/includes.d.ts +32 -0
- package/dist/plugin-sdk/config/io.d.ts +55 -0
- package/dist/plugin-sdk/config/legacy-migrate.d.ts +5 -0
- package/dist/plugin-sdk/config/legacy.d.ts +6 -0
- package/dist/plugin-sdk/config/legacy.migrations.d.ts +1 -0
- package/dist/plugin-sdk/config/legacy.migrations.part-1.d.ts +2 -0
- package/dist/plugin-sdk/config/legacy.migrations.part-2.d.ts +2 -0
- package/dist/plugin-sdk/config/legacy.migrations.part-3.d.ts +2 -0
- package/dist/plugin-sdk/config/legacy.rules.d.ts +2 -0
- package/dist/plugin-sdk/config/legacy.shared.d.ts +19 -0
- package/dist/plugin-sdk/config/markdown-tables.d.ts +7 -0
- package/dist/plugin-sdk/config/merge-config.d.ts +7 -0
- package/dist/plugin-sdk/config/merge-patch.d.ts +5 -0
- package/dist/plugin-sdk/config/normalize-paths.d.ts +8 -0
- package/dist/plugin-sdk/config/paths.d.ts +57 -0
- package/dist/plugin-sdk/config/port-defaults.d.ts +13 -0
- package/dist/plugin-sdk/config/runtime-overrides.d.ts +15 -0
- package/dist/plugin-sdk/config/sessions/delivery-info.d.ts +12 -0
- package/dist/plugin-sdk/config/sessions/group.d.ts +11 -0
- package/dist/plugin-sdk/config/sessions/main-session.d.ts +43 -0
- package/dist/plugin-sdk/config/sessions/metadata.d.ts +16 -0
- package/dist/plugin-sdk/config/sessions/paths.d.ts +21 -0
- package/dist/plugin-sdk/config/sessions/reset.d.ts +43 -0
- package/dist/plugin-sdk/config/sessions/session-key.d.ts +8 -0
- package/dist/plugin-sdk/config/sessions/store.d.ts +99 -0
- package/dist/plugin-sdk/config/sessions/transcript.d.ts +18 -0
- package/dist/plugin-sdk/config/sessions/types.d.ts +156 -0
- package/dist/plugin-sdk/config/sessions.d.ts +10 -0
- package/dist/plugin-sdk/config/talk.d.ts +11 -0
- package/dist/plugin-sdk/config/telegram-custom-commands.d.ts +24 -0
- package/dist/plugin-sdk/config/types.agent-defaults.d.ts +260 -0
- package/dist/plugin-sdk/config/types.agents.d.ts +80 -0
- package/dist/plugin-sdk/config/types.anima.d.ts +1 -0
- package/dist/plugin-sdk/config/types.approvals.d.ts +26 -0
- package/dist/plugin-sdk/config/types.auth.d.ts +28 -0
- package/dist/plugin-sdk/config/types.base.d.ts +172 -0
- package/dist/plugin-sdk/config/types.browser.d.ts +41 -0
- package/dist/plugin-sdk/config/types.channels.d.ts +48 -0
- package/dist/plugin-sdk/config/types.cron.d.ts +11 -0
- package/dist/plugin-sdk/config/types.d.ts +30 -0
- package/dist/plugin-sdk/config/types.discord.d.ts +188 -0
- package/dist/plugin-sdk/config/types.gateway.d.ts +288 -0
- package/dist/plugin-sdk/config/types.googlechat.d.ts +100 -0
- package/dist/plugin-sdk/config/types.hooks.d.ts +128 -0
- package/dist/plugin-sdk/config/types.imessage.d.ts +71 -0
- package/dist/plugin-sdk/config/types.irc.d.ts +96 -0
- package/dist/plugin-sdk/config/types.memory.d.ts +45 -0
- package/dist/plugin-sdk/config/types.messages.d.ts +121 -0
- package/dist/plugin-sdk/config/types.models.d.ts +54 -0
- package/dist/plugin-sdk/config/types.msteams.d.ts +101 -0
- package/dist/plugin-sdk/config/types.node-host.d.ts +10 -0
- package/dist/plugin-sdk/config/types.openclaw.d.ts +114 -0
- package/dist/plugin-sdk/config/types.plugins.d.ts +32 -0
- package/dist/plugin-sdk/config/types.queue.d.ts +14 -0
- package/dist/plugin-sdk/config/types.sandbox.d.ts +78 -0
- package/dist/plugin-sdk/config/types.signal.d.ts +86 -0
- package/dist/plugin-sdk/config/types.skills.d.ts +28 -0
- package/dist/plugin-sdk/config/types.slack.d.ts +150 -0
- package/dist/plugin-sdk/config/types.telegram.d.ts +163 -0
- package/dist/plugin-sdk/config/types.tools.d.ts +467 -0
- package/dist/plugin-sdk/config/types.tts.d.ts +78 -0
- package/dist/plugin-sdk/config/types.whatsapp.d.ts +142 -0
- package/dist/plugin-sdk/config/validation.d.ts +37 -0
- package/dist/plugin-sdk/config/version.d.ts +8 -0
- package/dist/plugin-sdk/config/zod-schema.agent-defaults.d.ts +249 -0
- package/dist/plugin-sdk/config/zod-schema.agent-runtime.d.ts +856 -0
- package/dist/plugin-sdk/config/zod-schema.agents.d.ts +504 -0
- package/dist/plugin-sdk/config/zod-schema.allowdeny.d.ts +13 -0
- package/dist/plugin-sdk/config/zod-schema.approvals.d.ts +15 -0
- package/dist/plugin-sdk/config/zod-schema.channels.d.ts +6 -0
- package/dist/plugin-sdk/config/zod-schema.core.d.ts +683 -0
- package/dist/plugin-sdk/config/zod-schema.d.ts +3401 -0
- package/dist/plugin-sdk/config/zod-schema.hooks.d.ts +79 -0
- package/dist/plugin-sdk/config/zod-schema.providers-core.d.ts +3233 -0
- package/dist/plugin-sdk/config/zod-schema.providers-whatsapp.d.ts +231 -0
- package/dist/plugin-sdk/config/zod-schema.providers.d.ts +1900 -0
- package/dist/plugin-sdk/config/zod-schema.sensitive.d.ts +2 -0
- package/dist/plugin-sdk/config/zod-schema.session.d.ts +203 -0
- package/dist/plugin-sdk/cron/delivery.d.ts +9 -0
- package/dist/plugin-sdk/cron/normalize.d.ts +9 -0
- package/dist/plugin-sdk/cron/parse.d.ts +1 -0
- package/dist/plugin-sdk/cron/payload-migration.d.ts +3 -0
- package/dist/plugin-sdk/cron/schedule.d.ts +2 -0
- package/dist/plugin-sdk/cron/service/jobs.d.ts +21 -0
- package/dist/plugin-sdk/cron/service/locked.d.ts +2 -0
- package/dist/plugin-sdk/cron/service/normalize.d.ts +17 -0
- package/dist/plugin-sdk/cron/service/ops.d.ts +43 -0
- package/dist/plugin-sdk/cron/service/state.d.ts +121 -0
- package/dist/plugin-sdk/cron/service/store.d.ts +9 -0
- package/dist/plugin-sdk/cron/service/timer.d.ts +25 -0
- package/dist/plugin-sdk/cron/service.d.ts +48 -0
- package/dist/plugin-sdk/cron/session-reaper.d.ts +35 -0
- package/dist/plugin-sdk/cron/store.d.ts +6 -0
- package/dist/plugin-sdk/cron/types.d.ts +95 -0
- package/dist/plugin-sdk/daemon/constants.d.ts +30 -0
- package/dist/plugin-sdk/discord/accounts.d.ts +9 -0
- package/dist/plugin-sdk/discord/audit.d.ts +2 -0
- package/dist/plugin-sdk/discord/directory-live.d.ts +4 -0
- package/dist/plugin-sdk/discord/monitor/allow-list.d.ts +1 -0
- package/dist/plugin-sdk/discord/monitor/gateway-registry.d.ts +3 -0
- package/dist/plugin-sdk/discord/monitor/presence-cache.d.ts +1 -0
- package/dist/plugin-sdk/discord/monitor.d.ts +3 -0
- package/dist/plugin-sdk/discord/pluralkit.d.ts +1 -0
- package/dist/plugin-sdk/discord/probe.d.ts +3 -0
- package/dist/plugin-sdk/discord/resolve-channels.d.ts +1 -0
- package/dist/plugin-sdk/discord/resolve-users.d.ts +1 -0
- package/dist/plugin-sdk/discord/send.d.ts +6 -0
- package/dist/plugin-sdk/discord/targets.d.ts +2 -0
- package/dist/plugin-sdk/gateway/auth-rate-limit.d.ts +59 -0
- package/dist/plugin-sdk/gateway/auth.d.ts +48 -0
- package/dist/plugin-sdk/gateway/call.d.ts +51 -0
- package/dist/plugin-sdk/gateway/chat-abort.d.ts +44 -0
- package/dist/plugin-sdk/gateway/chat-sanitize.d.ts +4 -0
- package/dist/plugin-sdk/gateway/client.d.ts +63 -0
- package/dist/plugin-sdk/gateway/control-ui-shared.d.ts +9 -0
- package/dist/plugin-sdk/gateway/device-auth.d.ts +12 -0
- package/dist/plugin-sdk/gateway/exec-approval-manager.d.ts +44 -0
- package/dist/plugin-sdk/gateway/net.d.ts +57 -0
- package/dist/plugin-sdk/gateway/node-registry.d.ts +60 -0
- package/dist/plugin-sdk/gateway/protocol/client-info.d.ts +58 -0
- package/dist/plugin-sdk/gateway/protocol/index.d.ts +661 -0
- package/dist/plugin-sdk/gateway/protocol/schema/agent.d.ts +86 -0
- package/dist/plugin-sdk/gateway/protocol/schema/agents-models-skills.d.ts +152 -0
- package/dist/plugin-sdk/gateway/protocol/schema/channels.d.ts +126 -0
- package/dist/plugin-sdk/gateway/protocol/schema/config.d.ts +51 -0
- package/dist/plugin-sdk/gateway/protocol/schema/cron.d.ts +353 -0
- package/dist/plugin-sdk/gateway/protocol/schema/devices.d.ts +38 -0
- package/dist/plugin-sdk/gateway/protocol/schema/error-codes.d.ts +14 -0
- package/dist/plugin-sdk/gateway/protocol/schema/exec-approvals.d.ts +163 -0
- package/dist/plugin-sdk/gateway/protocol/schema/frames.d.ts +164 -0
- package/dist/plugin-sdk/gateway/protocol/schema/logs-chat.d.ts +45 -0
- package/dist/plugin-sdk/gateway/protocol/schema/nodes.d.ts +64 -0
- package/dist/plugin-sdk/gateway/protocol/schema/primitives.d.ts +4 -0
- package/dist/plugin-sdk/gateway/protocol/schema/protocol-schemas.d.ts +3 -0
- package/dist/plugin-sdk/gateway/protocol/schema/sessions.d.ts +76 -0
- package/dist/plugin-sdk/gateway/protocol/schema/snapshot.d.ts +64 -0
- package/dist/plugin-sdk/gateway/protocol/schema/types.d.ts +124 -0
- package/dist/plugin-sdk/gateway/protocol/schema/wizard.d.ts +86 -0
- package/dist/plugin-sdk/gateway/protocol/schema.d.ts +16 -0
- package/dist/plugin-sdk/gateway/server/ws-types.d.ts +9 -0
- package/dist/plugin-sdk/gateway/server-channels.d.ts +24 -0
- package/dist/plugin-sdk/gateway/server-methods/types.d.ts +98 -0
- package/dist/plugin-sdk/gateway/server-shared.d.ts +7 -0
- package/dist/plugin-sdk/gateway/session-utils.d.ts +71 -0
- package/dist/plugin-sdk/gateway/session-utils.fs.d.ts +33 -0
- package/dist/plugin-sdk/gateway/session-utils.types.d.ts +84 -0
- package/dist/plugin-sdk/globals.d.ts +11 -0
- package/dist/plugin-sdk/hooks/internal-hooks.d.ts +95 -0
- package/dist/plugin-sdk/hooks/types.d.ts +62 -0
- package/dist/plugin-sdk/imessage/accounts.d.ts +8 -0
- package/dist/plugin-sdk/imessage/monitor.d.ts +3 -0
- package/dist/plugin-sdk/imessage/probe.d.ts +3 -0
- package/dist/plugin-sdk/imessage/send.d.ts +1 -0
- package/dist/plugin-sdk/imessage/target-parsing-helpers.d.ts +4 -0
- package/dist/plugin-sdk/imessage/targets.d.ts +2 -0
- package/dist/plugin-sdk/index.d.ts +1 -0
- package/dist/plugin-sdk/index.js +27570 -0
- package/dist/plugin-sdk/infra/agent-events.d.ts +21 -0
- package/dist/plugin-sdk/infra/anima-root.d.ts +1 -0
- package/dist/plugin-sdk/infra/archive.d.ts +41 -0
- package/dist/plugin-sdk/infra/backoff.d.ts +8 -0
- package/dist/plugin-sdk/infra/binaries.d.ts +3 -0
- package/dist/plugin-sdk/infra/brew.d.ts +8 -0
- package/dist/plugin-sdk/infra/channel-activity.d.ts +18 -0
- package/dist/plugin-sdk/infra/channel-summary.d.ts +6 -0
- package/dist/plugin-sdk/infra/dedupe.d.ts +11 -0
- package/dist/plugin-sdk/infra/device-auth-store.d.ts +18 -0
- package/dist/plugin-sdk/infra/device-identity.d.ts +11 -0
- package/dist/plugin-sdk/infra/device-pairing.d.ts +96 -0
- package/dist/plugin-sdk/infra/diagnostic-events.d.ts +121 -0
- package/dist/plugin-sdk/infra/dotenv.d.ts +3 -0
- package/dist/plugin-sdk/infra/env.d.ts +11 -0
- package/dist/plugin-sdk/infra/errors.d.ts +11 -0
- package/dist/plugin-sdk/infra/exec-approvals-allowlist.d.ts +45 -0
- package/dist/plugin-sdk/infra/exec-approvals-analysis.d.ts +78 -0
- package/dist/plugin-sdk/infra/exec-approvals.d.ts +107 -0
- package/dist/plugin-sdk/infra/exec-safety.d.ts +1 -0
- package/dist/plugin-sdk/infra/fetch.d.ts +2 -0
- package/dist/plugin-sdk/infra/file-lock.d.ts +2 -0
- package/dist/plugin-sdk/infra/format-time/format-datetime.d.ts +35 -0
- package/dist/plugin-sdk/infra/format-time/format-duration.d.ts +23 -0
- package/dist/plugin-sdk/infra/format-time/format-relative.d.ts +39 -0
- package/dist/plugin-sdk/infra/git-commit.d.ts +4 -0
- package/dist/plugin-sdk/infra/heartbeat-active-hours.d.ts +5 -0
- package/dist/plugin-sdk/infra/heartbeat-events-filter.d.ts +3 -0
- package/dist/plugin-sdk/infra/heartbeat-events.d.ts +21 -0
- package/dist/plugin-sdk/infra/heartbeat-runner.d.ts +45 -0
- package/dist/plugin-sdk/infra/heartbeat-visibility.d.ts +17 -0
- package/dist/plugin-sdk/infra/heartbeat-wake.d.ts +27 -0
- package/dist/plugin-sdk/infra/home-dir.d.ts +7 -0
- package/dist/plugin-sdk/infra/http-body.d.ts +46 -0
- package/dist/plugin-sdk/infra/json-file.d.ts +2 -0
- package/dist/plugin-sdk/infra/net/fetch-guard.d.ts +21 -0
- package/dist/plugin-sdk/infra/net/ssrf.d.ts +32 -0
- package/dist/plugin-sdk/infra/node-pairing.d.ts +62 -0
- package/dist/plugin-sdk/infra/node-shell.d.ts +1 -0
- package/dist/plugin-sdk/infra/openclaw-root.d.ts +10 -0
- package/dist/plugin-sdk/infra/outbound/abort.d.ts +8 -0
- package/dist/plugin-sdk/infra/outbound/channel-adapters.d.ts +6 -0
- package/dist/plugin-sdk/infra/outbound/channel-selection.d.ts +11 -0
- package/dist/plugin-sdk/infra/outbound/channel-target.d.ts +6 -0
- package/dist/plugin-sdk/infra/outbound/deliver.d.ts +77 -0
- package/dist/plugin-sdk/infra/outbound/delivery-queue.d.ts +103 -0
- package/dist/plugin-sdk/infra/outbound/directory-cache.d.ts +24 -0
- package/dist/plugin-sdk/infra/outbound/identity.d.ts +8 -0
- package/dist/plugin-sdk/infra/outbound/message-action-params.d.ts +47 -0
- package/dist/plugin-sdk/infra/outbound/message-action-runner.d.ts +74 -0
- package/dist/plugin-sdk/infra/outbound/message-action-spec.d.ts +5 -0
- package/dist/plugin-sdk/infra/outbound/message.d.ts +85 -0
- package/dist/plugin-sdk/infra/outbound/outbound-policy.d.ts +31 -0
- package/dist/plugin-sdk/infra/outbound/outbound-send-service.d.ts +64 -0
- package/dist/plugin-sdk/infra/outbound/outbound-session.d.ts +31 -0
- package/dist/plugin-sdk/infra/outbound/payloads.d.ts +16 -0
- package/dist/plugin-sdk/infra/outbound/target-errors.d.ts +6 -0
- package/dist/plugin-sdk/infra/outbound/target-normalization.d.ts +4 -0
- package/dist/plugin-sdk/infra/outbound/target-resolver.d.ts +53 -0
- package/dist/plugin-sdk/infra/outbound/targets.d.ts +65 -0
- package/dist/plugin-sdk/infra/outbound/tool-payload.d.ts +2 -0
- package/dist/plugin-sdk/infra/pairing-files.d.ts +11 -0
- package/dist/plugin-sdk/infra/pairing-token.d.ts +3 -0
- package/dist/plugin-sdk/infra/path-prepend.d.ts +5 -0
- package/dist/plugin-sdk/infra/ports-format.d.ts +5 -0
- package/dist/plugin-sdk/infra/ports-inspect.d.ts +2 -0
- package/dist/plugin-sdk/infra/ports-lsof.d.ts +2 -0
- package/dist/plugin-sdk/infra/ports-types.d.ts +17 -0
- package/dist/plugin-sdk/infra/ports.d.ts +14 -0
- package/dist/plugin-sdk/infra/provider-usage.auth.d.ts +11 -0
- package/dist/plugin-sdk/infra/provider-usage.d.ts +4 -0
- package/dist/plugin-sdk/infra/provider-usage.fetch.antigravity.d.ts +2 -0
- package/dist/plugin-sdk/infra/provider-usage.fetch.claude.d.ts +2 -0
- package/dist/plugin-sdk/infra/provider-usage.fetch.codex.d.ts +2 -0
- package/dist/plugin-sdk/infra/provider-usage.fetch.copilot.d.ts +2 -0
- package/dist/plugin-sdk/infra/provider-usage.fetch.d.ts +7 -0
- package/dist/plugin-sdk/infra/provider-usage.fetch.gemini.d.ts +2 -0
- package/dist/plugin-sdk/infra/provider-usage.fetch.minimax.d.ts +2 -0
- package/dist/plugin-sdk/infra/provider-usage.fetch.shared.d.ts +1 -0
- package/dist/plugin-sdk/infra/provider-usage.fetch.zai.d.ts +2 -0
- package/dist/plugin-sdk/infra/provider-usage.format.d.ts +13 -0
- package/dist/plugin-sdk/infra/provider-usage.load.d.ts +12 -0
- package/dist/plugin-sdk/infra/provider-usage.shared.d.ts +8 -0
- package/dist/plugin-sdk/infra/provider-usage.types.d.ts +17 -0
- package/dist/plugin-sdk/infra/restart-sentinel.d.ts +50 -0
- package/dist/plugin-sdk/infra/restart.d.ts +61 -0
- package/dist/plugin-sdk/infra/retry.d.ts +21 -0
- package/dist/plugin-sdk/infra/session-cost-usage.d.ts +45 -0
- package/dist/plugin-sdk/infra/session-cost-usage.types.d.ts +153 -0
- package/dist/plugin-sdk/infra/session-maintenance-warning.d.ts +10 -0
- package/dist/plugin-sdk/infra/shell-env.d.ts +33 -0
- package/dist/plugin-sdk/infra/skills-remote.d.ts +25 -0
- package/dist/plugin-sdk/infra/system-events.d.ts +18 -0
- package/dist/plugin-sdk/infra/tailnet.d.ts +7 -0
- package/dist/plugin-sdk/infra/tailscale.d.ts +34 -0
- package/dist/plugin-sdk/infra/tls/fingerprint.d.ts +1 -0
- package/dist/plugin-sdk/infra/tls/gateway.d.ts +16 -0
- package/dist/plugin-sdk/infra/tmp-anima-dir.d.ts +1 -0
- package/dist/plugin-sdk/infra/tmp-openclaw-dir.d.ts +18 -0
- package/dist/plugin-sdk/infra/unhandled-rejections.d.ts +15 -0
- package/dist/plugin-sdk/infra/warning-filter.d.ts +7 -0
- package/dist/plugin-sdk/infra/ws.d.ts +2 -0
- package/dist/plugin-sdk/infra/wsl.d.ts +11 -0
- package/dist/plugin-sdk/line/accounts.d.ts +9 -0
- package/dist/plugin-sdk/line/config-schema.d.ts +1 -0
- package/dist/plugin-sdk/line/flex-templates.d.ts +14 -0
- package/dist/plugin-sdk/line/markdown-to-line.d.ts +6 -0
- package/dist/plugin-sdk/line/monitor.d.ts +3 -0
- package/dist/plugin-sdk/line/probe.d.ts +3 -0
- package/dist/plugin-sdk/line/send.d.ts +14 -0
- package/dist/plugin-sdk/line/template-messages.d.ts +1 -0
- package/dist/plugin-sdk/line/types.d.ts +6 -0
- package/dist/plugin-sdk/link-understanding/apply.d.ts +10 -0
- package/dist/plugin-sdk/link-understanding/defaults.d.ts +2 -0
- package/dist/plugin-sdk/link-understanding/detect.d.ts +3 -0
- package/dist/plugin-sdk/link-understanding/format.d.ts +4 -0
- package/dist/plugin-sdk/link-understanding/runner.d.ts +11 -0
- package/dist/plugin-sdk/logger.d.ts +6 -0
- package/dist/plugin-sdk/logging/config.d.ts +4 -0
- package/dist/plugin-sdk/logging/console.d.ts +23 -0
- package/dist/plugin-sdk/logging/diagnostic-session-state.d.ts +17 -0
- package/dist/plugin-sdk/logging/diagnostic.d.ts +56 -0
- package/dist/plugin-sdk/logging/levels.d.ts +4 -0
- package/dist/plugin-sdk/logging/logger.d.ts +42 -0
- package/dist/plugin-sdk/logging/redact-identifier.d.ts +4 -0
- package/dist/plugin-sdk/logging/redact.d.ts +9 -0
- package/dist/plugin-sdk/logging/state.d.ts +18 -0
- package/dist/plugin-sdk/logging/subsystem.d.ts +18 -0
- package/dist/plugin-sdk/logging.d.ts +10 -0
- package/dist/plugin-sdk/markdown/fences.d.ts +10 -0
- package/dist/plugin-sdk/markdown/frontmatter.d.ts +2 -0
- package/dist/plugin-sdk/markdown/ir.d.ts +32 -0
- package/dist/plugin-sdk/markdown/render.d.ts +18 -0
- package/dist/plugin-sdk/markdown/tables.d.ts +2 -0
- package/dist/plugin-sdk/markdown/whatsapp.d.ts +14 -0
- package/dist/plugin-sdk/media/audio-tags.d.ts +10 -0
- package/dist/plugin-sdk/media/audio.d.ts +19 -0
- package/dist/plugin-sdk/media/base64.d.ts +1 -0
- package/dist/plugin-sdk/media/constants.d.ts +7 -0
- package/dist/plugin-sdk/media/fetch.d.ts +23 -0
- package/dist/plugin-sdk/media/image-ops.d.ts +39 -0
- package/dist/plugin-sdk/media/input-files.d.ts +81 -0
- package/dist/plugin-sdk/media/mime.d.ts +16 -0
- package/dist/plugin-sdk/media/parse.d.ts +8 -0
- package/dist/plugin-sdk/media/png-encode.d.ts +8 -0
- package/dist/plugin-sdk/media/read-response-with-limit.d.ts +7 -0
- package/dist/plugin-sdk/media/sniff-mime-from-base64.d.ts +1 -0
- package/dist/plugin-sdk/media/store.d.ts +28 -0
- package/dist/plugin-sdk/media-understanding/apply.d.ts +19 -0
- package/dist/plugin-sdk/media-understanding/attachments.d.ts +43 -0
- package/dist/plugin-sdk/media-understanding/concurrency.d.ts +1 -0
- package/dist/plugin-sdk/media-understanding/defaults.d.ts +14 -0
- package/dist/plugin-sdk/media-understanding/errors.d.ts +6 -0
- package/dist/plugin-sdk/media-understanding/format.d.ts +7 -0
- package/dist/plugin-sdk/media-understanding/output-extract.d.ts +2 -0
- package/dist/plugin-sdk/media-understanding/providers/image.d.ts +1 -0
- package/dist/plugin-sdk/media-understanding/providers/index.d.ts +8 -0
- package/dist/plugin-sdk/media-understanding/providers/shared.d.ts +4 -0
- package/dist/plugin-sdk/media-understanding/resolve.d.ts +44 -0
- package/dist/plugin-sdk/media-understanding/runner.d.ts +35 -0
- package/dist/plugin-sdk/media-understanding/runner.entries.d.ts +33 -0
- package/dist/plugin-sdk/media-understanding/scope.d.ts +9 -0
- package/dist/plugin-sdk/media-understanding/types.d.ts +93 -0
- package/dist/plugin-sdk/media-understanding/video.d.ts +2 -0
- package/dist/plugin-sdk/memory/backend-config.d.ts +49 -0
- package/dist/plugin-sdk/memory/batch-gemini.d.ts +55 -0
- package/dist/plugin-sdk/memory/batch-http.d.ts +6 -0
- package/dist/plugin-sdk/memory/batch-openai.d.ts +45 -0
- package/dist/plugin-sdk/memory/batch-output.d.ts +23 -0
- package/dist/plugin-sdk/memory/batch-voyage.d.ts +46 -0
- package/dist/plugin-sdk/memory/embedding-chunk-limits.d.ts +3 -0
- package/dist/plugin-sdk/memory/embedding-input-limits.d.ts +2 -0
- package/dist/plugin-sdk/memory/embedding-model-limits.d.ts +2 -0
- package/dist/plugin-sdk/memory/embeddings-gemini.d.ts +13 -0
- package/dist/plugin-sdk/memory/embeddings-openai.d.ts +13 -0
- package/dist/plugin-sdk/memory/embeddings-voyage.d.ts +13 -0
- package/dist/plugin-sdk/memory/embeddings.d.ts +44 -0
- package/dist/plugin-sdk/memory/hybrid.d.ts +34 -0
- package/dist/plugin-sdk/memory/index.d.ts +3 -0
- package/dist/plugin-sdk/memory/internal.d.ts +38 -0
- package/dist/plugin-sdk/memory/manager-embedding-ops.d.ts +32 -0
- package/dist/plugin-sdk/memory/manager-search.d.ts +60 -0
- package/dist/plugin-sdk/memory/manager-sync-ops.d.ts +40 -0
- package/dist/plugin-sdk/memory/manager.d.ts +75 -0
- package/dist/plugin-sdk/memory/memory-schema.d.ts +10 -0
- package/dist/plugin-sdk/memory/node-llama.d.ts +8 -0
- package/dist/plugin-sdk/memory/qmd-manager.d.ts +109 -0
- package/dist/plugin-sdk/memory/qmd-query-parser.d.ts +8 -0
- package/dist/plugin-sdk/memory/qmd-scope.d.ts +4 -0
- package/dist/plugin-sdk/memory/search-manager.d.ts +11 -0
- package/dist/plugin-sdk/memory/session-files.d.ts +14 -0
- package/dist/plugin-sdk/memory/sqlite-vec.d.ts +9 -0
- package/dist/plugin-sdk/memory/sqlite.d.ts +1 -0
- package/dist/plugin-sdk/memory/types.d.ts +94 -0
- package/dist/plugin-sdk/pairing/pairing-messages.d.ts +6 -0
- package/dist/plugin-sdk/pairing/pairing-store.d.ts +46 -0
- package/dist/plugin-sdk/pi-model-discovery-Dw3A6oXH.js +37 -0
- package/dist/plugin-sdk/plugin-sdk/account-id.d.ts +1 -0
- package/dist/plugin-sdk/plugin-sdk/allow-from.d.ts +4 -0
- package/dist/plugin-sdk/plugin-sdk/config-paths.d.ts +6 -0
- package/dist/plugin-sdk/plugin-sdk/file-lock.d.ts +16 -0
- package/dist/plugin-sdk/plugin-sdk/index.d.ts +123 -0
- package/dist/plugin-sdk/plugin-sdk/onboarding.d.ts +11 -0
- package/dist/plugin-sdk/plugin-sdk/text-chunking.d.ts +1 -0
- package/dist/plugin-sdk/plugins/bundled-dir.d.ts +1 -0
- package/dist/plugin-sdk/plugins/commands.d.ts +83 -0
- package/dist/plugin-sdk/plugins/config-schema.d.ts +2 -0
- package/dist/plugin-sdk/plugins/config-state.d.ts +33 -0
- package/dist/plugin-sdk/plugins/discovery.d.ts +22 -0
- package/dist/plugin-sdk/plugins/hook-runner-global.d.ts +37 -0
- package/dist/plugin-sdk/plugins/hooks.d.ts +42 -0
- package/dist/plugin-sdk/plugins/http-path.d.ts +1 -0
- package/dist/plugin-sdk/plugins/http-registry.d.ts +13 -0
- package/dist/plugin-sdk/plugins/loader.d.ts +14 -0
- package/dist/plugin-sdk/plugins/manifest-registry.d.ts +33 -0
- package/dist/plugin-sdk/plugins/manifest.d.ts +64 -0
- package/dist/plugin-sdk/plugins/registry.d.ts +130 -0
- package/dist/plugin-sdk/plugins/runtime/index.d.ts +3 -0
- package/dist/plugin-sdk/plugins/runtime/native-deps.d.ts +8 -0
- package/dist/plugin-sdk/plugins/runtime/types.d.ts +317 -0
- package/dist/plugin-sdk/plugins/runtime.d.ts +5 -0
- package/dist/plugin-sdk/plugins/schema-validator.d.ts +10 -0
- package/dist/plugin-sdk/plugins/slots.d.ts +24 -0
- package/dist/plugin-sdk/plugins/tools.d.ts +13 -0
- package/dist/plugin-sdk/plugins/types.d.ts +411 -0
- package/dist/plugin-sdk/polls.d.ts +31 -0
- package/dist/plugin-sdk/process/command-queue.d.ts +51 -0
- package/dist/plugin-sdk/process/exec.d.ts +26 -0
- package/dist/plugin-sdk/process/lanes.d.ts +6 -0
- package/dist/plugin-sdk/process/spawn-utils.d.ts +26 -0
- package/dist/plugin-sdk/providers/github-copilot-token.d.ts +8 -0
- package/dist/plugin-sdk/providers/qwen-portal-oauth.d.ts +8 -0
- package/dist/plugin-sdk/routing/bindings.d.ts +11 -0
- package/dist/plugin-sdk/routing/resolve-route.d.ts +42 -0
- package/dist/plugin-sdk/routing/session-key.d.ts +48 -0
- package/dist/plugin-sdk/runtime.d.ts +7 -0
- package/dist/plugin-sdk/security/external-content.d.ts +67 -0
- package/dist/plugin-sdk/security/secret-equal.d.ts +1 -0
- package/dist/plugin-sdk/sessions/input-provenance.d.ts +16 -0
- package/dist/plugin-sdk/sessions/level-overrides.d.ts +10 -0
- package/dist/plugin-sdk/sessions/model-overrides.d.ts +14 -0
- package/dist/plugin-sdk/sessions/send-policy.d.ts +11 -0
- package/dist/plugin-sdk/sessions/session-key-utils.d.ts +11 -0
- package/dist/plugin-sdk/sessions/session-label.d.ts +9 -0
- package/dist/plugin-sdk/sessions/transcript-events.d.ts +7 -0
- package/dist/plugin-sdk/shared/chat-envelope.d.ts +2 -0
- package/dist/plugin-sdk/shared/config-eval.d.ts +5 -0
- package/dist/plugin-sdk/shared/device-auth.d.ts +13 -0
- package/dist/plugin-sdk/shared/frontmatter.d.ts +7 -0
- package/dist/plugin-sdk/shared/node-match.d.ts +8 -0
- package/dist/plugin-sdk/shared/subagents-format.d.ts +15 -0
- package/dist/plugin-sdk/shared/text/reasoning-tags.d.ts +6 -0
- package/dist/plugin-sdk/signal/accounts.d.ts +9 -0
- package/dist/plugin-sdk/signal/format.d.ts +9 -0
- package/dist/plugin-sdk/signal/identity.d.ts +3 -0
- package/dist/plugin-sdk/signal/index.d.ts +3 -0
- package/dist/plugin-sdk/signal/probe.d.ts +3 -0
- package/dist/plugin-sdk/signal/reaction-level.d.ts +1 -0
- package/dist/plugin-sdk/signal/send-reactions.d.ts +2 -0
- package/dist/plugin-sdk/signal/send.d.ts +1 -0
- package/dist/plugin-sdk/slack/accounts.d.ts +11 -0
- package/dist/plugin-sdk/slack/actions.d.ts +17 -0
- package/dist/plugin-sdk/slack/client.d.ts +1 -0
- package/dist/plugin-sdk/slack/directory-live.d.ts +4 -0
- package/dist/plugin-sdk/slack/index.d.ts +3 -0
- package/dist/plugin-sdk/slack/message-actions.d.ts +2 -0
- package/dist/plugin-sdk/slack/monitor/allow-list.d.ts +1 -0
- package/dist/plugin-sdk/slack/probe.d.ts +3 -0
- package/dist/plugin-sdk/slack/resolve-channels.d.ts +1 -0
- package/dist/plugin-sdk/slack/resolve-users.d.ts +1 -0
- package/dist/plugin-sdk/slack/send.d.ts +5 -0
- package/dist/plugin-sdk/slack/targets.d.ts +2 -0
- package/dist/plugin-sdk/slack/threading-tool-context.d.ts +1 -0
- package/dist/plugin-sdk/telegram/accounts.d.ts +9 -0
- package/dist/plugin-sdk/telegram/audit.d.ts +4 -0
- package/dist/plugin-sdk/telegram/bot/helpers.d.ts +1 -0
- package/dist/plugin-sdk/telegram/bot/types.d.ts +5 -0
- package/dist/plugin-sdk/telegram/inline-buttons.d.ts +2 -0
- package/dist/plugin-sdk/telegram/model-buttons.d.ts +5 -0
- package/dist/plugin-sdk/telegram/monitor.d.ts +3 -0
- package/dist/plugin-sdk/telegram/outbound-params.d.ts +2 -0
- package/dist/plugin-sdk/telegram/probe.d.ts +6 -0
- package/dist/plugin-sdk/telegram/reaction-level.d.ts +1 -0
- package/dist/plugin-sdk/telegram/send.d.ts +10 -0
- package/dist/plugin-sdk/telegram/sticker-cache.d.ts +2 -0
- package/dist/plugin-sdk/telegram/targets.d.ts +1 -0
- package/dist/plugin-sdk/telegram/token.d.ts +1 -0
- package/dist/plugin-sdk/terminal/ansi.d.ts +2 -0
- package/dist/plugin-sdk/terminal/health-style.d.ts +1 -0
- package/dist/plugin-sdk/terminal/links.d.ts +6 -0
- package/dist/plugin-sdk/terminal/palette.d.ts +10 -0
- package/dist/plugin-sdk/terminal/progress-line.d.ts +3 -0
- package/dist/plugin-sdk/terminal/prompt-style.d.ts +3 -0
- package/dist/plugin-sdk/terminal/restore.d.ts +17 -0
- package/dist/plugin-sdk/terminal/theme.d.ts +15 -0
- package/dist/plugin-sdk/tts/tts-core.d.ts +52 -0
- package/dist/plugin-sdk/tts/tts.d.ts +179 -0
- package/dist/plugin-sdk/utils/account-id.d.ts +1 -0
- package/dist/plugin-sdk/utils/boolean.d.ts +5 -0
- package/dist/plugin-sdk/utils/delivery-context.d.ts +29 -0
- package/dist/plugin-sdk/utils/directive-tags.d.ts +16 -0
- package/dist/plugin-sdk/utils/fetch-timeout.d.ts +13 -0
- package/dist/plugin-sdk/utils/message-channel.d.ts +27 -0
- package/dist/plugin-sdk/utils/normalize-secret-input.d.ts +11 -0
- package/dist/plugin-sdk/utils/provider-utils.d.ts +9 -0
- package/dist/plugin-sdk/utils/queue-helpers.d.ts +41 -0
- package/dist/plugin-sdk/utils/shell-argv.d.ts +1 -0
- package/dist/plugin-sdk/utils/transcript-tools.d.ts +8 -0
- package/dist/plugin-sdk/utils/usage-format.d.ts +26 -0
- package/dist/plugin-sdk/utils.d.ts +67 -0
- package/dist/plugin-sdk/version.d.ts +4 -0
- package/dist/plugin-sdk/web/accounts.d.ts +39 -0
- package/dist/plugin-sdk/web/active-listener.d.ts +25 -0
- package/dist/plugin-sdk/web/auth-store.d.ts +25 -0
- package/dist/plugin-sdk/web/auto-reply/constants.d.ts +1 -0
- package/dist/plugin-sdk/web/auto-reply/deliver-reply.d.ts +18 -0
- package/dist/plugin-sdk/web/auto-reply/heartbeat-runner.d.ts +20 -0
- package/dist/plugin-sdk/web/auto-reply/loggers.d.ts +4 -0
- package/dist/plugin-sdk/web/auto-reply/mentions.d.ts +19 -0
- package/dist/plugin-sdk/web/auto-reply/monitor/ack-reaction.d.ts +13 -0
- package/dist/plugin-sdk/web/auto-reply/monitor/broadcast.d.ts +16 -0
- package/dist/plugin-sdk/web/auto-reply/monitor/commands.d.ts +2 -0
- package/dist/plugin-sdk/web/auto-reply/monitor/echo.d.ts +17 -0
- package/dist/plugin-sdk/web/auto-reply/monitor/group-activation.d.ts +9 -0
- package/dist/plugin-sdk/web/auto-reply/monitor/group-gating.d.ts +29 -0
- package/dist/plugin-sdk/web/auto-reply/monitor/group-members.d.ts +6 -0
- package/dist/plugin-sdk/web/auto-reply/monitor/last-route.d.ts +15 -0
- package/dist/plugin-sdk/web/auto-reply/monitor/message-line.d.ts +11 -0
- package/dist/plugin-sdk/web/auto-reply/monitor/on-message.d.ts +24 -0
- package/dist/plugin-sdk/web/auto-reply/monitor/peer.d.ts +2 -0
- package/dist/plugin-sdk/web/auto-reply/monitor/process-message.d.ts +40 -0
- package/dist/plugin-sdk/web/auto-reply/monitor.d.ts +5 -0
- package/dist/plugin-sdk/web/auto-reply/session-snapshot.d.ts +17 -0
- package/dist/plugin-sdk/web/auto-reply/types.d.ts +28 -0
- package/dist/plugin-sdk/web/auto-reply/util.d.ts +2 -0
- package/dist/plugin-sdk/web/auto-reply.d.ts +1 -0
- package/dist/plugin-sdk/web/auto-reply.impl.d.ts +6 -0
- package/dist/plugin-sdk/web/inbound/access-control.d.ts +24 -0
- package/dist/plugin-sdk/web/inbound/dedupe.d.ts +2 -0
- package/dist/plugin-sdk/web/inbound/extract.d.ts +13 -0
- package/dist/plugin-sdk/web/inbound/media.d.ts +7 -0
- package/dist/plugin-sdk/web/inbound/monitor.d.ts +30 -0
- package/dist/plugin-sdk/web/inbound/send-api.d.ts +22 -0
- package/dist/plugin-sdk/web/inbound/types.d.ts +41 -0
- package/dist/plugin-sdk/web/inbound.d.ts +4 -0
- package/dist/plugin-sdk/web/login-qr.d.ts +19 -0
- package/dist/plugin-sdk/web/login.d.ts +3 -0
- package/dist/plugin-sdk/web/media.d.ts +38 -0
- package/dist/plugin-sdk/web/outbound.d.ts +23 -0
- package/dist/plugin-sdk/web/qr-image.d.ts +4 -0
- package/dist/plugin-sdk/web/reconnect.d.ts +12 -0
- package/dist/plugin-sdk/web/session.d.ts +14 -0
- package/dist/plugin-sdk/web/vcard.d.ts +6 -0
- package/dist/plugin-sdk/whatsapp/normalize.d.ts +2 -0
- package/dist/plugin-sdk/whatsapp/resolve-outbound-target.d.ts +1 -0
- package/dist/plugin-sdk/wizard/prompts.d.ts +42 -0
- package/dist/plugin-sdk/wizard/session.d.ts +42 -0
- package/dist/plugins-B362e77G.js +168 -0
- package/dist/plugins-CDJw924T.js +38 -0
- package/dist/plugins-CmSUIUNi.js +38 -0
- package/dist/plugins-cli-CtFRTC2I.js +734 -0
- package/dist/plugins-cli-D1lvqLG9.js +736 -0
- package/dist/polls-CItfB1H8.js +1343 -0
- package/dist/ports-BVLMN1Sr.js +96 -0
- package/dist/ports-CqLSlU6Z.js +317 -0
- package/dist/ports-D94CwCrv.js +344 -0
- package/dist/ports-D_NHthOz.js +96 -0
- package/dist/program-Bve7k4jO.js +176 -0
- package/dist/program-context-8lqacY-M.js +496 -0
- package/dist/program-context-Bvn8046-.js +17 -0
- package/dist/progress-Bek_GyWS.js +133 -0
- package/dist/progress-CbZ2D53A.js +133 -0
- package/dist/prompt-style-DKy6qQxR.js +9 -0
- package/dist/prompt-style-lu0clOOE.js +9 -0
- package/dist/prompts-BI__va99.js +10 -0
- package/dist/prompts-_dDWkCAz.js +10 -0
- package/dist/pw-ai-BLVMuSLv.js +1867 -0
- package/dist/pw-ai-DZJWEF_f.js +1865 -0
- package/dist/pw-ai-dzf-ptcn.js +1868 -0
- package/dist/qmd-manager-B0FWDi1x.js +938 -0
- package/dist/qmd-manager-CrDrpgh3.js +937 -0
- package/dist/qmd-manager-DepEoASu.js +935 -0
- package/dist/queue-2CW7pnm1.js +209 -0
- package/dist/queue-DhjMEG_Q.js +209 -0
- package/dist/redact-BHmk44DI.js +97 -0
- package/dist/redact-ClVwO7Nn.js +97 -0
- package/dist/register.agent-CE_8JbTE.js +265 -0
- package/dist/register.agent-CGRdcftb.js +1003 -0
- package/dist/register.anima-B4NPeesF.js +167 -0
- package/dist/register.anima-hNCtQ_jl.js +167 -0
- package/dist/register.configure-3prVPXwx.js +101 -0
- package/dist/register.configure-Dqm2IveL.js +103 -0
- package/dist/register.maintenance-BSIx4eNS.js +543 -0
- package/dist/register.maintenance-DDeG6CHa.js +543 -0
- package/dist/register.message-DcYPDzYr.js +657 -0
- package/dist/register.message-RbFrjbch.js +660 -0
- package/dist/register.onboard-BBJK_0_C.js +170 -0
- package/dist/register.onboard-BrcWHC9j.js +170 -0
- package/dist/register.setup-ByvEHxYQ.js +175 -0
- package/dist/register.setup-CNwO5Yq3.js +175 -0
- package/dist/register.status-health-sessions-CGT7bn4C.js +142 -0
- package/dist/register.status-health-sessions-QK6iQSJc.js +313 -0
- package/dist/register.subclis-Bd8eE94r.js +255 -0
- package/dist/registry-BiekeB9q.js +116 -0
- package/dist/registry-qI6V4gqU.js +116 -0
- package/dist/reply-Clj5jcM5.js +32212 -0
- package/dist/reply-DnH1Ueoz.js +32212 -0
- package/dist/reply-prefix-D2NxVzGZ.js +100 -0
- package/dist/reply-prefix-DPpz_mEi.js +100 -0
- package/dist/requirements-BzZxj2Wu.js +107 -0
- package/dist/requirements-DIW1svgA.js +107 -0
- package/dist/rolldown-runtime-Cbj13DAv.js +20 -0
- package/dist/routes-CXpne1-p.js +1820 -0
- package/dist/routes-DtRwwTy6.js +1820 -0
- package/dist/rpc-BBB_Fbes.js +70 -0
- package/dist/rpc-CMEWfcci.js +70 -0
- package/dist/run-main-DOXNrnL2.js +371 -0
- package/dist/runtime-guard-BSUFiAQV.js +60 -0
- package/dist/runtime-guard-DeOXA_86.js +60 -0
- package/dist/sandbox-Bk0ZXcag.js +859 -0
- package/dist/sandbox-D3CFkNeF.js +858 -0
- package/dist/sandbox-cli-BCnnmQ03.js +458 -0
- package/dist/sandbox-cli-Ctpa2Isy.js +461 -0
- package/dist/secret-equal-B268kALC.js +13 -0
- package/dist/secret-equal-Dghy3xsA.js +13 -0
- package/dist/security-cli-BiiLLcQV.js +462 -0
- package/dist/security-cli-DOZmLENS.js +465 -0
- package/dist/send-BTA6qupx.js +10 -0
- package/dist/send-BhAfdGII.js +10 -0
- package/dist/send-C2t9xpXI.js +10 -0
- package/dist/send-C6ccOW_U.js +10 -0
- package/dist/send-CP74DxzJ.js +28 -0
- package/dist/send-CS3G_YWr.js +10 -0
- package/dist/send-D5JnqErc.js +10 -0
- package/dist/send-DEMhcauI.js +32 -0
- package/dist/send-DF8KJImx.js +28 -0
- package/dist/send-DVW0CcHX.js +32 -0
- package/dist/send-DigO-i9j.js +28 -0
- package/dist/send-DqMLjD9Z.js +10 -0
- package/dist/send-Dz2BDHll.js +32 -0
- package/dist/send-ga9udK1_.js +10 -0
- package/dist/send-oDz9NATu.js +10 -0
- package/dist/server-context-BznDS2td.js +824 -0
- package/dist/server-context-CXnE2F7d.js +824 -0
- package/dist/server-node-events-Cu6Qkjor.js +231 -0
- package/dist/server-node-events-Cv8MuF1g.js +233 -0
- package/dist/service-BNVpYcQe.js +642 -0
- package/dist/service-D56aMXUB.js +642 -0
- package/dist/service-audit-DBsygs7y.js +488 -0
- package/dist/service-audit-DKWJcTu4.js +488 -0
- package/dist/session-CXcl3Xrp.js +181 -0
- package/dist/session-DUFuU29j.js +179 -0
- package/dist/session-M_uCxF0U.js +181 -0
- package/dist/session-cost-usage-BwiTZuKl.js +600 -0
- package/dist/session-cost-usage-DT9YNXTJ.js +600 -0
- package/dist/session-key-BGiG_JcT.js +198 -0
- package/dist/session-key-DxcgHezu.js +198 -0
- package/dist/sessions-B8GUAiF6.js +1296 -0
- package/dist/sessions-D0Zd1CND.js +1296 -0
- package/dist/sessions-D0spLCm7.js +187 -0
- package/dist/sessions-XvkHLXt4.js +2038 -0
- package/dist/shared-CEHU0exQ.js +77 -0
- package/dist/shared-Cgly1vPb.js +66 -0
- package/dist/shared-DAHxpviD.js +77 -0
- package/dist/shared-JOo05hST.js +66 -0
- package/dist/shell-argv-CAq1mLa2.js +72 -0
- package/dist/shell-argv-Ce41guJv.js +72 -0
- package/dist/skill-scanner-CkaVLABv.js +263 -0
- package/dist/skill-scanner-Coo4QoCd.js +263 -0
- package/dist/skills-B-G7UHOa.js +808 -0
- package/dist/skills-B5LQx4lT.js +807 -0
- package/dist/skills-cli-DF9XJ2_0.js +286 -0
- package/dist/skills-cli-eLBluVoD.js +289 -0
- package/dist/skills-status-Clq9ZnYu.js +166 -0
- package/dist/skills-status-JQluhU-P.js +166 -0
- package/dist/sqlite-BukcjdJa.js +321 -0
- package/dist/sqlite-CGcOZZ0C.js +368 -0
- package/dist/sqlite-Ck6f9KWc.js +453 -0
- package/dist/start-BvsoGNHJ.js +354 -0
- package/dist/start-CF_Cp6YC.js +353 -0
- package/dist/status-BKGJ7VPQ.js +27 -0
- package/dist/status-BZip7mx9.js +27 -0
- package/dist/status-BqYq_J5J.js +2132 -0
- package/dist/status-CMnlcBVc.js +21 -0
- package/dist/status-CXQrTLri.js +2137 -0
- package/dist/status-tDZPwewW.js +21 -0
- package/dist/status.update-CWiod7o_.js +79 -0
- package/dist/status.update-D1PyrhoB.js +79 -0
- package/dist/subagent-registry-CpSZ2RSO.js +2760 -0
- package/dist/subagent-registry-DkCXRdwf.js +2759 -0
- package/dist/subagent-registry-MPrTYaEB.js +14 -0
- package/dist/subsystem-Dowf8fSU.js +860 -0
- package/dist/system-cli-4Urk9KV1.js +79 -0
- package/dist/system-cli-CgMzkg8R.js +82 -0
- package/dist/system-run-command-DGk7dwQP.js +93 -0
- package/dist/system-run-command-X9lDJIy0.js +93 -0
- package/dist/systemd-BSrHDyeU.js +452 -0
- package/dist/systemd-By5xdSB4.js +452 -0
- package/dist/systemd-hints-BtjL_5Rh.js +36 -0
- package/dist/systemd-hints-sJmr6cjb.js +36 -0
- package/dist/systemd-linger-BNz8PXPF.js +75 -0
- package/dist/systemd-linger-D5vLilKH.js +75 -0
- package/dist/table-BL0lJzsm.js +279 -0
- package/dist/table-DoiRPsn0.js +279 -0
- package/dist/tailnet-CuiNECdL.js +42 -0
- package/dist/tailnet-__ODlBOT.js +42 -0
- package/dist/templates-DJ0ii6X2.js +47 -0
- package/dist/templates-DPTs18po.js +47 -0
- package/dist/thinking-BLU0jXR8.js +204 -0
- package/dist/thinking-BXEswx1X.js +204 -0
- package/dist/timeout-CswI_K-U.js +232 -0
- package/dist/tokens-C-X7wDKj.js +14 -0
- package/dist/tokens-DkvqA72p.js +14 -0
- package/dist/transcript-events-C1hdue6u.js +17 -0
- package/dist/transcript-events-C8Tqw4td.js +17 -0
- package/dist/transcript-events-DW_H__a1.js +17 -0
- package/dist/transcript-tools-DtE5di1q.js +108 -0
- package/dist/transcript-tools-DuyYOkUq.js +108 -0
- package/dist/trash-BJLK1vMn.js +23 -0
- package/dist/trash-_x5UZ94k.js +23 -0
- package/dist/tui-Cj25a9wc.js +3894 -0
- package/dist/tui-Iv4T-9gg.js +3894 -0
- package/dist/tui-cli-BkJxFa_n.js +50 -0
- package/dist/tui-cli-DeFmBtZ7.js +47 -0
- package/dist/update-DZRKbMjq.js +317 -0
- package/dist/update-LFgxHHPd.js +317 -0
- package/dist/update-check-CWc7YXmc.js +400 -0
- package/dist/update-check-IhlWaui6.js +400 -0
- package/dist/update-cli-qGGlL5Lg.js +1105 -0
- package/dist/update-cli-rMqhSUMc.js +1105 -0
- package/dist/update-runner-BT77y3bz.js +894 -0
- package/dist/update-runner-DvzFqFJf.js +894 -0
- package/dist/usage-BeZuVAY4.js +4516 -0
- package/dist/usage-format-BAirWUSO.js +36 -0
- package/dist/usage-format-CpORtVCG.js +36 -0
- package/dist/utils-Bsw__U-F.js +243 -0
- package/dist/utils-C9sj30YY.js +239 -0
- package/dist/warning-filter.js +48 -0
- package/dist/web-DEx7MMYq.js +2203 -0
- package/dist/web-DHSoj6bL.js +46842 -0
- package/dist/web-DI0g5K4c.js +63 -0
- package/dist/webhooks-cli-sfLRE89X.js +319 -0
- package/dist/webhooks-cli-xtZBlaD1.js +316 -0
- package/dist/whatsapp-actions-DIREhxrq.js +49 -0
- package/dist/whatsapp-actions-TGHl9p4i.js +45 -0
- package/dist/whatsapp-actions-dBHozeuk.js +53 -0
- package/dist/widearea-dns-B6ocX23x.js +127 -0
- package/dist/widearea-dns-NsEUNYwz.js +127 -0
- package/dist/workspace-Dcfoy5JJ.js +649 -0
- package/dist/ws-COSqlEPx.js +218 -0
- package/dist/ws-log-N8R5MvGE.js +267 -0
- package/dist/ws-log-gwFxPxj5.js +267 -0
- package/dist/wsl-CqyuRvtM.js +26 -0
- package/dist/wsl-ymJYvc9Q.js +26 -0
- package/package.json +209 -0
- package/skills/1password/SKILL.md +70 -0
- package/skills/1password/references/cli-examples.md +29 -0
- package/skills/1password/references/get-started.md +17 -0
- package/skills/animahub/SKILL.md +77 -0
- package/skills/apple-notes/SKILL.md +77 -0
- package/skills/apple-reminders/SKILL.md +96 -0
- package/skills/audit/SKILL.md +68 -0
- package/skills/bear-notes/SKILL.md +107 -0
- package/skills/blogwatcher/SKILL.md +69 -0
- package/skills/blucli/SKILL.md +47 -0
- package/skills/bluebubbles/SKILL.md +131 -0
- package/skills/camsnap/SKILL.md +45 -0
- package/skills/canvas/SKILL.md +198 -0
- package/skills/coding-agent/SKILL.md +284 -0
- package/skills/deploy/SKILL.md +45 -0
- package/skills/discord/SKILL.md +160 -0
- package/skills/eightctl/SKILL.md +50 -0
- package/skills/food-order/SKILL.md +48 -0
- package/skills/gemini/SKILL.md +43 -0
- package/skills/gifgrep/SKILL.md +79 -0
- package/skills/github/SKILL.md +77 -0
- package/skills/gog/SKILL.md +116 -0
- package/skills/goplaces/SKILL.md +52 -0
- package/skills/healthcheck/SKILL.md +245 -0
- package/skills/himalaya/SKILL.md +257 -0
- package/skills/himalaya/references/configuration.md +184 -0
- package/skills/himalaya/references/message-composition.md +199 -0
- package/skills/imsg/SKILL.md +74 -0
- package/skills/mcporter/SKILL.md +61 -0
- package/skills/model-usage/SKILL.md +69 -0
- package/skills/model-usage/references/codexbar-cli.md +33 -0
- package/skills/model-usage/scripts/model_usage.py +310 -0
- package/skills/nano-banana-pro/SKILL.md +58 -0
- package/skills/nano-banana-pro/scripts/generate_image.py +184 -0
- package/skills/nano-pdf/SKILL.md +38 -0
- package/skills/notion/SKILL.md +172 -0
- package/skills/obsidian/SKILL.md +81 -0
- package/skills/openai-image-gen/SKILL.md +89 -0
- package/skills/openai-image-gen/scripts/gen.py +240 -0
- package/skills/openai-whisper/SKILL.md +38 -0
- package/skills/openai-whisper-api/SKILL.md +52 -0
- package/skills/openai-whisper-api/scripts/transcribe.sh +85 -0
- package/skills/openhue/SKILL.md +51 -0
- package/skills/oracle/SKILL.md +125 -0
- package/skills/ordercli/SKILL.md +78 -0
- package/skills/peekaboo/SKILL.md +190 -0
- package/skills/review/SKILL.md +58 -0
- package/skills/sag/SKILL.md +87 -0
- package/skills/session-logs/SKILL.md +115 -0
- package/skills/sherpa-onnx-tts/SKILL.md +103 -0
- package/skills/sherpa-onnx-tts/bin/sherpa-onnx-tts +178 -0
- package/skills/skill-creator/SKILL.md +370 -0
- package/skills/skill-creator/license.txt +202 -0
- package/skills/skill-creator/scripts/init_skill.py +378 -0
- package/skills/skill-creator/scripts/package_skill.py +111 -0
- package/skills/skill-creator/scripts/quick_validate.py +101 -0
- package/skills/slack/SKILL.md +144 -0
- package/skills/songsee/SKILL.md +49 -0
- package/skills/sonoscli/SKILL.md +46 -0
- package/skills/spotify-player/SKILL.md +64 -0
- package/skills/summarize/SKILL.md +87 -0
- package/skills/things-mac/SKILL.md +86 -0
- package/skills/tmux/SKILL.md +135 -0
- package/skills/tmux/scripts/find-sessions.sh +112 -0
- package/skills/tmux/scripts/wait-for-text.sh +83 -0
- package/skills/trello/SKILL.md +95 -0
- package/skills/video-frames/SKILL.md +46 -0
- package/skills/video-frames/scripts/frame.sh +81 -0
- package/skills/voice-call/SKILL.md +45 -0
- package/skills/wacli/SKILL.md +72 -0
- package/skills/weather/SKILL.md +54 -0
- package/templates/BRAIN.md +65 -0
- package/templates/GUT.md +44 -0
- package/templates/HEART.md +51 -0
- package/templates/MEMORY.md +66 -0
- package/templates/SHADOW.md +68 -0
- package/templates/SOUL.md +38 -0
- package/templates/SPIRIT.md +43 -0
|
@@ -0,0 +1,2162 @@
|
|
|
1
|
+
import { F as shouldLogVerbose, M as logVerbose, V as getChildLogger, t as createSubsystemLogger, u as defaultRuntime } from "./subsystem-Dowf8fSU.js";
|
|
2
|
+
import { E as toWhatsappJid, h as normalizeE164, m as jidToE164, p as isSelfChatMode, r as clamp, w as sleep, y as resolveJidToE164 } from "./utils-Bsw__U-F.js";
|
|
3
|
+
import { B as resolveIdentityNamePrefix, V as resolveMessagePrefix } from "./subagent-registry-CpSZ2RSO.js";
|
|
4
|
+
import { $ as buildAgentSessionKey, At as registerUnhandledRejectionHandler, Dt as buildMentionRegexes, Kt as finalizeInboundContext, Ot as normalizeMentionText, _t as hasControlCommand, at as recordChannelActivity, ct as dispatchReplyWithBufferedBlockDispatcher, et as resolveAgentRoute, f as normalizeGroupActivation, ft as createDedupeCache, gt as resolveEnvelopeFormatOptions, ht as formatInboundEnvelope, mt as resolveInboundDebounceMs, p as parseActivationCommand, pt as createInboundDebouncer, rt as buildPairingReply, st as shouldAckReactionForWhatsApp, t as getReplyFromConfig, vt as shouldComputeCommandAuthorized } from "./reply-DnH1Ueoz.js";
|
|
5
|
+
import { i as buildAgentMainSessionKey, l as normalizeAgentId, o as buildGroupHistoryKey, r as DEFAULT_MAIN_KEY } from "./session-key-DxcgHezu.js";
|
|
6
|
+
import { t as formatCliCommand } from "./command-format-DELazozB.js";
|
|
7
|
+
import { i as loadConfig } from "./config-Xm0j9LUa.js";
|
|
8
|
+
import { P as resolveGroupSessionKey, a as readSessionUpdatedAt, c as updateLastRoute, i as loadSessionStore, o as recordSessionMetaFromInbound } from "./sessions-B8GUAiF6.js";
|
|
9
|
+
import { o as setActiveWebListener, r as loadWebMedia, s as convertMarkdownTables } from "./polls-CItfB1H8.js";
|
|
10
|
+
import { Yt as enqueueSystemEvent } from "./cli-session-CP7ZH2-6.js";
|
|
11
|
+
import { o as resolveChannelGroupPolicy, s as resolveChannelGroupRequireMention } from "./dock-cPBY4qGl.js";
|
|
12
|
+
import { i as getWebAuthAgeMs, l as readWebSelfId, n as resolveWhatsAppAccount } from "./accounts-Cc5E4IDO.js";
|
|
13
|
+
import { r as saveMediaBuffer } from "./routes-DtRwwTy6.js";
|
|
14
|
+
import { c as resolveStorePath } from "./paths-hcX1Gqg5.js";
|
|
15
|
+
import { a as chunkMarkdownTextWithMode, c as resolveChunkMode, l as resolveTextChunkLimit, t as resolveMarkdownTableMode } from "./markdown-tables-DHgOK2vI.js";
|
|
16
|
+
import { i as readChannelAllowFromStore, o as upsertChannelPairingRequest } from "./pairing-store-CGYSwICJ.js";
|
|
17
|
+
import { r as formatDurationPrecise } from "./format-duration-Cm3xh8xz.js";
|
|
18
|
+
import { i as markdownToWhatsApp, r as sendReactionWhatsApp } from "./outbound-DXijk0db.js";
|
|
19
|
+
import { i as waitForWaConnection, n as formatError, r as getStatusCode, t as createWaSocket } from "./session-M_uCxF0U.js";
|
|
20
|
+
import { i as recordPendingHistoryEntryIfEnabled, n as DEFAULT_GROUP_HISTORY_LIMIT, r as buildHistoryContextFromEntries, t as createReplyPrefixOptions } from "./reply-prefix-DPpz_mEi.js";
|
|
21
|
+
import { randomUUID } from "node:crypto";
|
|
22
|
+
import { setTimeout } from "node:timers/promises";
|
|
23
|
+
import { DisconnectReason, downloadMediaMessage, extractMessageContent, getContentType, isJidGroup, normalizeMessageContent } from "@whiskeysockets/baileys";
|
|
24
|
+
|
|
25
|
+
//#region src/web/auto-reply/constants.ts
|
|
26
|
+
const DEFAULT_WEB_MEDIA_BYTES = 5 * 1024 * 1024;
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/infra/backoff.ts
|
|
30
|
+
function computeBackoff(policy, attempt) {
|
|
31
|
+
const base = policy.initialMs * policy.factor ** Math.max(attempt - 1, 0);
|
|
32
|
+
const jitter = base * policy.jitter * Math.random();
|
|
33
|
+
return Math.min(policy.maxMs, Math.round(base + jitter));
|
|
34
|
+
}
|
|
35
|
+
async function sleepWithAbort(ms, abortSignal) {
|
|
36
|
+
if (ms <= 0) return;
|
|
37
|
+
try {
|
|
38
|
+
await setTimeout(ms, void 0, { signal: abortSignal });
|
|
39
|
+
} catch (err) {
|
|
40
|
+
if (abortSignal?.aborted) throw new Error("aborted", { cause: err });
|
|
41
|
+
throw err;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/web/reconnect.ts
|
|
47
|
+
const DEFAULT_HEARTBEAT_SECONDS = 60;
|
|
48
|
+
const DEFAULT_RECONNECT_POLICY = {
|
|
49
|
+
initialMs: 2e3,
|
|
50
|
+
maxMs: 3e4,
|
|
51
|
+
factor: 1.8,
|
|
52
|
+
jitter: .25,
|
|
53
|
+
maxAttempts: 12
|
|
54
|
+
};
|
|
55
|
+
function resolveHeartbeatSeconds(cfg, overrideSeconds) {
|
|
56
|
+
const candidate = overrideSeconds ?? cfg.web?.heartbeatSeconds;
|
|
57
|
+
if (typeof candidate === "number" && candidate > 0) return candidate;
|
|
58
|
+
return DEFAULT_HEARTBEAT_SECONDS;
|
|
59
|
+
}
|
|
60
|
+
function resolveReconnectPolicy(cfg, overrides) {
|
|
61
|
+
const reconnectOverrides = cfg.web?.reconnect ?? {};
|
|
62
|
+
const overrideConfig = overrides ?? {};
|
|
63
|
+
const merged = {
|
|
64
|
+
...DEFAULT_RECONNECT_POLICY,
|
|
65
|
+
...reconnectOverrides,
|
|
66
|
+
...overrideConfig
|
|
67
|
+
};
|
|
68
|
+
merged.initialMs = Math.max(250, merged.initialMs);
|
|
69
|
+
merged.maxMs = Math.max(merged.initialMs, merged.maxMs);
|
|
70
|
+
merged.factor = clamp(merged.factor, 1.1, 10);
|
|
71
|
+
merged.jitter = clamp(merged.jitter, 0, 1);
|
|
72
|
+
merged.maxAttempts = Math.max(0, Math.floor(merged.maxAttempts));
|
|
73
|
+
return merged;
|
|
74
|
+
}
|
|
75
|
+
function newConnectionId() {
|
|
76
|
+
return randomUUID();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/web/auto-reply/loggers.ts
|
|
81
|
+
const whatsappLog = createSubsystemLogger("gateway/channels/whatsapp");
|
|
82
|
+
const whatsappInboundLog = whatsappLog.child("inbound");
|
|
83
|
+
const whatsappOutboundLog = whatsappLog.child("outbound");
|
|
84
|
+
const whatsappHeartbeatLog = whatsappLog.child("heartbeat");
|
|
85
|
+
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region src/web/auto-reply/util.ts
|
|
88
|
+
function elide(text, limit = 400) {
|
|
89
|
+
if (!text) return text;
|
|
90
|
+
if (text.length <= limit) return text;
|
|
91
|
+
return `${text.slice(0, limit)}… (truncated ${text.length - limit} chars)`;
|
|
92
|
+
}
|
|
93
|
+
function isLikelyWhatsAppCryptoError(reason) {
|
|
94
|
+
const formatReason = (value) => {
|
|
95
|
+
if (value == null) return "";
|
|
96
|
+
if (typeof value === "string") return value;
|
|
97
|
+
if (value instanceof Error) return `${value.message}\n${value.stack ?? ""}`;
|
|
98
|
+
if (typeof value === "object") try {
|
|
99
|
+
return JSON.stringify(value);
|
|
100
|
+
} catch {
|
|
101
|
+
return Object.prototype.toString.call(value);
|
|
102
|
+
}
|
|
103
|
+
if (typeof value === "number") return String(value);
|
|
104
|
+
if (typeof value === "boolean") return String(value);
|
|
105
|
+
if (typeof value === "bigint") return String(value);
|
|
106
|
+
if (typeof value === "symbol") return value.description ?? value.toString();
|
|
107
|
+
if (typeof value === "function") return value.name ? `[function ${value.name}]` : "[function]";
|
|
108
|
+
return Object.prototype.toString.call(value);
|
|
109
|
+
};
|
|
110
|
+
const haystack = (reason instanceof Error ? `${reason.message}\n${reason.stack ?? ""}` : formatReason(reason)).toLowerCase();
|
|
111
|
+
if (!(haystack.includes("unsupported state or unable to authenticate data") || haystack.includes("bad mac"))) return false;
|
|
112
|
+
return haystack.includes("@whiskeysockets/baileys") || haystack.includes("baileys") || haystack.includes("noise-handler") || haystack.includes("aesdecryptgcm");
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region src/cli/wait.ts
|
|
117
|
+
function waitForever() {
|
|
118
|
+
setInterval(() => {}, 1e6).unref();
|
|
119
|
+
return new Promise(() => {});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region src/web/inbound/dedupe.ts
|
|
124
|
+
const recentInboundMessages = createDedupeCache({
|
|
125
|
+
ttlMs: 20 * 6e4,
|
|
126
|
+
maxSize: 5e3
|
|
127
|
+
});
|
|
128
|
+
function isRecentInboundMessage(key) {
|
|
129
|
+
return recentInboundMessages.check(key);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region src/channels/location.ts
|
|
134
|
+
function resolveLocation(location) {
|
|
135
|
+
const source = location.source ?? (location.isLive ? "live" : location.name || location.address ? "place" : "pin");
|
|
136
|
+
const isLive = Boolean(location.isLive ?? source === "live");
|
|
137
|
+
return {
|
|
138
|
+
...location,
|
|
139
|
+
source,
|
|
140
|
+
isLive
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function formatAccuracy(accuracy) {
|
|
144
|
+
if (!Number.isFinite(accuracy)) return "";
|
|
145
|
+
return ` ±${Math.round(accuracy ?? 0)}m`;
|
|
146
|
+
}
|
|
147
|
+
function formatCoords(latitude, longitude) {
|
|
148
|
+
return `${latitude.toFixed(6)}, ${longitude.toFixed(6)}`;
|
|
149
|
+
}
|
|
150
|
+
function formatLocationText(location) {
|
|
151
|
+
const resolved = resolveLocation(location);
|
|
152
|
+
const coords = formatCoords(resolved.latitude, resolved.longitude);
|
|
153
|
+
const accuracy = formatAccuracy(resolved.accuracy);
|
|
154
|
+
const caption = resolved.caption?.trim();
|
|
155
|
+
let header = "";
|
|
156
|
+
if (resolved.source === "live" || resolved.isLive) header = `🛰 Live location: ${coords}${accuracy}`;
|
|
157
|
+
else if (resolved.name || resolved.address) header = `📍 ${[resolved.name, resolved.address].filter(Boolean).join(" — ")} (${coords}${accuracy})`;
|
|
158
|
+
else header = `📍 ${coords}${accuracy}`;
|
|
159
|
+
return caption ? `${header}\n${caption}` : header;
|
|
160
|
+
}
|
|
161
|
+
function toLocationContext(location) {
|
|
162
|
+
const resolved = resolveLocation(location);
|
|
163
|
+
return {
|
|
164
|
+
LocationLat: resolved.latitude,
|
|
165
|
+
LocationLon: resolved.longitude,
|
|
166
|
+
LocationAccuracy: resolved.accuracy,
|
|
167
|
+
LocationName: resolved.name,
|
|
168
|
+
LocationAddress: resolved.address,
|
|
169
|
+
LocationSource: resolved.source,
|
|
170
|
+
LocationIsLive: resolved.isLive
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
//#endregion
|
|
175
|
+
//#region src/web/vcard.ts
|
|
176
|
+
const ALLOWED_VCARD_KEYS = new Set([
|
|
177
|
+
"FN",
|
|
178
|
+
"N",
|
|
179
|
+
"TEL"
|
|
180
|
+
]);
|
|
181
|
+
function parseVcard(vcard) {
|
|
182
|
+
if (!vcard) return { phones: [] };
|
|
183
|
+
const lines = vcard.split(/\r?\n/);
|
|
184
|
+
let nameFromN;
|
|
185
|
+
let nameFromFn;
|
|
186
|
+
const phones = [];
|
|
187
|
+
for (const rawLine of lines) {
|
|
188
|
+
const line = rawLine.trim();
|
|
189
|
+
if (!line) continue;
|
|
190
|
+
const colonIndex = line.indexOf(":");
|
|
191
|
+
if (colonIndex === -1) continue;
|
|
192
|
+
const key = line.slice(0, colonIndex).toUpperCase();
|
|
193
|
+
const rawValue = line.slice(colonIndex + 1).trim();
|
|
194
|
+
if (!rawValue) continue;
|
|
195
|
+
const baseKey = normalizeVcardKey(key);
|
|
196
|
+
if (!baseKey || !ALLOWED_VCARD_KEYS.has(baseKey)) continue;
|
|
197
|
+
const value = cleanVcardValue(rawValue);
|
|
198
|
+
if (!value) continue;
|
|
199
|
+
if (baseKey === "FN" && !nameFromFn) {
|
|
200
|
+
nameFromFn = normalizeVcardName(value);
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
if (baseKey === "N" && !nameFromN) {
|
|
204
|
+
nameFromN = normalizeVcardName(value);
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
if (baseKey === "TEL") {
|
|
208
|
+
const phone = normalizeVcardPhone(value);
|
|
209
|
+
if (phone) phones.push(phone);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return {
|
|
213
|
+
name: nameFromFn ?? nameFromN,
|
|
214
|
+
phones
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
function normalizeVcardKey(key) {
|
|
218
|
+
const [primary] = key.split(";");
|
|
219
|
+
if (!primary) return;
|
|
220
|
+
const segments = primary.split(".");
|
|
221
|
+
return segments[segments.length - 1] || void 0;
|
|
222
|
+
}
|
|
223
|
+
function cleanVcardValue(value) {
|
|
224
|
+
return value.replace(/\\n/gi, " ").replace(/\\,/g, ",").replace(/\\;/g, ";").trim();
|
|
225
|
+
}
|
|
226
|
+
function normalizeVcardName(value) {
|
|
227
|
+
return value.replace(/;/g, " ").replace(/\s+/g, " ").trim();
|
|
228
|
+
}
|
|
229
|
+
function normalizeVcardPhone(value) {
|
|
230
|
+
const trimmed = value.trim();
|
|
231
|
+
if (!trimmed) return "";
|
|
232
|
+
if (trimmed.toLowerCase().startsWith("tel:")) return trimmed.slice(4).trim();
|
|
233
|
+
return trimmed;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
//#endregion
|
|
237
|
+
//#region src/web/inbound/extract.ts
|
|
238
|
+
function unwrapMessage$1(message) {
|
|
239
|
+
return normalizeMessageContent(message);
|
|
240
|
+
}
|
|
241
|
+
function extractContextInfo(message) {
|
|
242
|
+
if (!message) return;
|
|
243
|
+
const contentType = getContentType(message);
|
|
244
|
+
const candidate = contentType ? message[contentType] : void 0;
|
|
245
|
+
const contextInfo = candidate && typeof candidate === "object" && "contextInfo" in candidate ? candidate.contextInfo : void 0;
|
|
246
|
+
if (contextInfo) return contextInfo;
|
|
247
|
+
const fallback = message.extendedTextMessage?.contextInfo ?? message.imageMessage?.contextInfo ?? message.videoMessage?.contextInfo ?? message.documentMessage?.contextInfo ?? message.audioMessage?.contextInfo ?? message.stickerMessage?.contextInfo ?? message.buttonsResponseMessage?.contextInfo ?? message.listResponseMessage?.contextInfo ?? message.templateButtonReplyMessage?.contextInfo ?? message.interactiveResponseMessage?.contextInfo ?? message.buttonsMessage?.contextInfo ?? message.listMessage?.contextInfo;
|
|
248
|
+
if (fallback) return fallback;
|
|
249
|
+
for (const value of Object.values(message)) {
|
|
250
|
+
if (!value || typeof value !== "object") continue;
|
|
251
|
+
if (!("contextInfo" in value)) continue;
|
|
252
|
+
const candidateContext = value.contextInfo;
|
|
253
|
+
if (candidateContext) return candidateContext;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
function extractMentionedJids(rawMessage) {
|
|
257
|
+
const message = unwrapMessage$1(rawMessage);
|
|
258
|
+
if (!message) return;
|
|
259
|
+
const flattened = [
|
|
260
|
+
message.extendedTextMessage?.contextInfo?.mentionedJid,
|
|
261
|
+
message.extendedTextMessage?.contextInfo?.quotedMessage?.extendedTextMessage?.contextInfo?.mentionedJid,
|
|
262
|
+
message.imageMessage?.contextInfo?.mentionedJid,
|
|
263
|
+
message.videoMessage?.contextInfo?.mentionedJid,
|
|
264
|
+
message.documentMessage?.contextInfo?.mentionedJid,
|
|
265
|
+
message.audioMessage?.contextInfo?.mentionedJid,
|
|
266
|
+
message.stickerMessage?.contextInfo?.mentionedJid,
|
|
267
|
+
message.buttonsResponseMessage?.contextInfo?.mentionedJid,
|
|
268
|
+
message.listResponseMessage?.contextInfo?.mentionedJid
|
|
269
|
+
].flatMap((arr) => arr ?? []).filter(Boolean);
|
|
270
|
+
if (flattened.length === 0) return;
|
|
271
|
+
return Array.from(new Set(flattened));
|
|
272
|
+
}
|
|
273
|
+
function extractText(rawMessage) {
|
|
274
|
+
const message = unwrapMessage$1(rawMessage);
|
|
275
|
+
if (!message) return;
|
|
276
|
+
const extracted = extractMessageContent(message);
|
|
277
|
+
const candidates = [message, extracted && extracted !== message ? extracted : void 0];
|
|
278
|
+
for (const candidate of candidates) {
|
|
279
|
+
if (!candidate) continue;
|
|
280
|
+
if (typeof candidate.conversation === "string" && candidate.conversation.trim()) return candidate.conversation.trim();
|
|
281
|
+
const extended = candidate.extendedTextMessage?.text;
|
|
282
|
+
if (extended?.trim()) return extended.trim();
|
|
283
|
+
const caption = candidate.imageMessage?.caption ?? candidate.videoMessage?.caption ?? candidate.documentMessage?.caption;
|
|
284
|
+
if (caption?.trim()) return caption.trim();
|
|
285
|
+
}
|
|
286
|
+
const contactPlaceholder = extractContactPlaceholder(message) ?? (extracted && extracted !== message ? extractContactPlaceholder(extracted) : void 0);
|
|
287
|
+
if (contactPlaceholder) return contactPlaceholder;
|
|
288
|
+
}
|
|
289
|
+
function extractMediaPlaceholder(rawMessage) {
|
|
290
|
+
const message = unwrapMessage$1(rawMessage);
|
|
291
|
+
if (!message) return;
|
|
292
|
+
if (message.imageMessage) return "<media:image>";
|
|
293
|
+
if (message.videoMessage) return "<media:video>";
|
|
294
|
+
if (message.audioMessage) return "<media:audio>";
|
|
295
|
+
if (message.documentMessage) return "<media:document>";
|
|
296
|
+
if (message.stickerMessage) return "<media:sticker>";
|
|
297
|
+
}
|
|
298
|
+
function extractContactPlaceholder(rawMessage) {
|
|
299
|
+
const message = unwrapMessage$1(rawMessage);
|
|
300
|
+
if (!message) return;
|
|
301
|
+
const contact = message.contactMessage ?? void 0;
|
|
302
|
+
if (contact) {
|
|
303
|
+
const { name, phones } = describeContact({
|
|
304
|
+
displayName: contact.displayName,
|
|
305
|
+
vcard: contact.vcard
|
|
306
|
+
});
|
|
307
|
+
return formatContactPlaceholder(name, phones);
|
|
308
|
+
}
|
|
309
|
+
const contactsArray = message.contactsArrayMessage?.contacts ?? void 0;
|
|
310
|
+
if (!contactsArray || contactsArray.length === 0) return;
|
|
311
|
+
return formatContactsPlaceholder(contactsArray.map((entry) => describeContact({
|
|
312
|
+
displayName: entry.displayName,
|
|
313
|
+
vcard: entry.vcard
|
|
314
|
+
})).map((entry) => formatContactLabel(entry.name, entry.phones)).filter((value) => Boolean(value)), contactsArray.length);
|
|
315
|
+
}
|
|
316
|
+
function describeContact(input) {
|
|
317
|
+
const displayName = (input.displayName ?? "").trim();
|
|
318
|
+
const parsed = parseVcard(input.vcard ?? void 0);
|
|
319
|
+
return {
|
|
320
|
+
name: displayName || parsed.name,
|
|
321
|
+
phones: parsed.phones
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
function formatContactPlaceholder(name, phones) {
|
|
325
|
+
const label = formatContactLabel(name, phones);
|
|
326
|
+
if (!label) return "<contact>";
|
|
327
|
+
return `<contact: ${label}>`;
|
|
328
|
+
}
|
|
329
|
+
function formatContactsPlaceholder(labels, total) {
|
|
330
|
+
const cleaned = labels.map((label) => label.trim()).filter(Boolean);
|
|
331
|
+
if (cleaned.length === 0) return `<contacts: ${total} ${total === 1 ? "contact" : "contacts"}>`;
|
|
332
|
+
const remaining = Math.max(total - cleaned.length, 0);
|
|
333
|
+
const suffix = remaining > 0 ? ` +${remaining} more` : "";
|
|
334
|
+
return `<contacts: ${cleaned.join(", ")}${suffix}>`;
|
|
335
|
+
}
|
|
336
|
+
function formatContactLabel(name, phones) {
|
|
337
|
+
const parts = [name, formatPhoneList(phones)].filter((value) => Boolean(value));
|
|
338
|
+
if (parts.length === 0) return;
|
|
339
|
+
return parts.join(", ");
|
|
340
|
+
}
|
|
341
|
+
function formatPhoneList(phones) {
|
|
342
|
+
const cleaned = phones?.map((phone) => phone.trim()).filter(Boolean) ?? [];
|
|
343
|
+
if (cleaned.length === 0) return;
|
|
344
|
+
const { shown, remaining } = summarizeList(cleaned, cleaned.length, 1);
|
|
345
|
+
const [primary] = shown;
|
|
346
|
+
if (!primary) return;
|
|
347
|
+
if (remaining === 0) return primary;
|
|
348
|
+
return `${primary} (+${remaining} more)`;
|
|
349
|
+
}
|
|
350
|
+
function summarizeList(values, total, maxShown) {
|
|
351
|
+
const shown = values.slice(0, maxShown);
|
|
352
|
+
return {
|
|
353
|
+
shown,
|
|
354
|
+
remaining: Math.max(total - shown.length, 0)
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
function extractLocationData(rawMessage) {
|
|
358
|
+
const message = unwrapMessage$1(rawMessage);
|
|
359
|
+
if (!message) return null;
|
|
360
|
+
const live = message.liveLocationMessage ?? void 0;
|
|
361
|
+
if (live) {
|
|
362
|
+
const latitudeRaw = live.degreesLatitude;
|
|
363
|
+
const longitudeRaw = live.degreesLongitude;
|
|
364
|
+
if (latitudeRaw != null && longitudeRaw != null) {
|
|
365
|
+
const latitude = Number(latitudeRaw);
|
|
366
|
+
const longitude = Number(longitudeRaw);
|
|
367
|
+
if (Number.isFinite(latitude) && Number.isFinite(longitude)) return {
|
|
368
|
+
latitude,
|
|
369
|
+
longitude,
|
|
370
|
+
accuracy: live.accuracyInMeters ?? void 0,
|
|
371
|
+
caption: live.caption ?? void 0,
|
|
372
|
+
source: "live",
|
|
373
|
+
isLive: true
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
const location = message.locationMessage ?? void 0;
|
|
378
|
+
if (location) {
|
|
379
|
+
const latitudeRaw = location.degreesLatitude;
|
|
380
|
+
const longitudeRaw = location.degreesLongitude;
|
|
381
|
+
if (latitudeRaw != null && longitudeRaw != null) {
|
|
382
|
+
const latitude = Number(latitudeRaw);
|
|
383
|
+
const longitude = Number(longitudeRaw);
|
|
384
|
+
if (Number.isFinite(latitude) && Number.isFinite(longitude)) {
|
|
385
|
+
const isLive = Boolean(location.isLive);
|
|
386
|
+
return {
|
|
387
|
+
latitude,
|
|
388
|
+
longitude,
|
|
389
|
+
accuracy: location.accuracyInMeters ?? void 0,
|
|
390
|
+
name: location.name ?? void 0,
|
|
391
|
+
address: location.address ?? void 0,
|
|
392
|
+
caption: location.comment ?? void 0,
|
|
393
|
+
source: isLive ? "live" : location.name || location.address ? "place" : "pin",
|
|
394
|
+
isLive
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
return null;
|
|
400
|
+
}
|
|
401
|
+
function describeReplyContext(rawMessage) {
|
|
402
|
+
const message = unwrapMessage$1(rawMessage);
|
|
403
|
+
if (!message) return null;
|
|
404
|
+
const contextInfo = extractContextInfo(message);
|
|
405
|
+
const quoted = normalizeMessageContent(contextInfo?.quotedMessage);
|
|
406
|
+
if (!quoted) return null;
|
|
407
|
+
const location = extractLocationData(quoted);
|
|
408
|
+
const locationText = location ? formatLocationText(location) : void 0;
|
|
409
|
+
let body = [extractText(quoted), locationText].filter(Boolean).join("\n").trim();
|
|
410
|
+
if (!body) body = extractMediaPlaceholder(quoted);
|
|
411
|
+
if (!body) {
|
|
412
|
+
const quotedType = quoted ? getContentType(quoted) : void 0;
|
|
413
|
+
logVerbose(`Quoted message missing extractable body${quotedType ? ` (type ${quotedType})` : ""}`);
|
|
414
|
+
return null;
|
|
415
|
+
}
|
|
416
|
+
const senderJid = contextInfo?.participant ?? void 0;
|
|
417
|
+
const senderE164 = senderJid ? jidToE164(senderJid) ?? senderJid : void 0;
|
|
418
|
+
const sender = senderE164 ?? "unknown sender";
|
|
419
|
+
return {
|
|
420
|
+
id: contextInfo?.stanzaId ? String(contextInfo.stanzaId) : void 0,
|
|
421
|
+
body,
|
|
422
|
+
sender,
|
|
423
|
+
senderJid,
|
|
424
|
+
senderE164
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
//#endregion
|
|
429
|
+
//#region src/web/inbound/access-control.ts
|
|
430
|
+
const PAIRING_REPLY_HISTORY_GRACE_MS = 3e4;
|
|
431
|
+
async function checkInboundAccessControl(params) {
|
|
432
|
+
const cfg = loadConfig();
|
|
433
|
+
const account = resolveWhatsAppAccount({
|
|
434
|
+
cfg,
|
|
435
|
+
accountId: params.accountId
|
|
436
|
+
});
|
|
437
|
+
const dmPolicy = account.dmPolicy ?? "pairing";
|
|
438
|
+
const configuredAllowFrom = account.allowFrom;
|
|
439
|
+
const storeAllowFrom = await readChannelAllowFromStore("whatsapp").catch(() => []);
|
|
440
|
+
const combinedAllowFrom = Array.from(new Set([...configuredAllowFrom ?? [], ...storeAllowFrom]));
|
|
441
|
+
const defaultAllowFrom = combinedAllowFrom.length === 0 && params.selfE164 ? [params.selfE164] : void 0;
|
|
442
|
+
const allowFrom = combinedAllowFrom.length > 0 ? combinedAllowFrom : defaultAllowFrom;
|
|
443
|
+
const groupAllowFrom = account.groupAllowFrom ?? (configuredAllowFrom && configuredAllowFrom.length > 0 ? configuredAllowFrom : void 0);
|
|
444
|
+
const isSamePhone = params.from === params.selfE164;
|
|
445
|
+
const isSelfChat = isSelfChatMode(params.selfE164, configuredAllowFrom);
|
|
446
|
+
const pairingGraceMs = typeof params.pairingGraceMs === "number" && params.pairingGraceMs > 0 ? params.pairingGraceMs : PAIRING_REPLY_HISTORY_GRACE_MS;
|
|
447
|
+
const suppressPairingReply = typeof params.connectedAtMs === "number" && typeof params.messageTimestampMs === "number" && params.messageTimestampMs < params.connectedAtMs - pairingGraceMs;
|
|
448
|
+
const dmHasWildcard = allowFrom?.includes("*") ?? false;
|
|
449
|
+
const normalizedAllowFrom = allowFrom && allowFrom.length > 0 ? allowFrom.filter((entry) => entry !== "*").map(normalizeE164) : [];
|
|
450
|
+
const groupHasWildcard = groupAllowFrom?.includes("*") ?? false;
|
|
451
|
+
const normalizedGroupAllowFrom = groupAllowFrom && groupAllowFrom.length > 0 ? groupAllowFrom.filter((entry) => entry !== "*").map(normalizeE164) : [];
|
|
452
|
+
const defaultGroupPolicy = cfg.channels?.defaults?.groupPolicy;
|
|
453
|
+
const groupPolicy = account.groupPolicy ?? defaultGroupPolicy ?? "open";
|
|
454
|
+
if (params.group && groupPolicy === "disabled") {
|
|
455
|
+
logVerbose("Blocked group message (groupPolicy: disabled)");
|
|
456
|
+
return {
|
|
457
|
+
allowed: false,
|
|
458
|
+
shouldMarkRead: false,
|
|
459
|
+
isSelfChat,
|
|
460
|
+
resolvedAccountId: account.accountId
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
if (params.group && groupPolicy === "allowlist") {
|
|
464
|
+
if (!groupAllowFrom || groupAllowFrom.length === 0) {
|
|
465
|
+
logVerbose("Blocked group message (groupPolicy: allowlist, no groupAllowFrom)");
|
|
466
|
+
return {
|
|
467
|
+
allowed: false,
|
|
468
|
+
shouldMarkRead: false,
|
|
469
|
+
isSelfChat,
|
|
470
|
+
resolvedAccountId: account.accountId
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
if (!(groupHasWildcard || params.senderE164 != null && normalizedGroupAllowFrom.includes(params.senderE164))) {
|
|
474
|
+
logVerbose(`Blocked group message from ${params.senderE164 ?? "unknown sender"} (groupPolicy: allowlist)`);
|
|
475
|
+
return {
|
|
476
|
+
allowed: false,
|
|
477
|
+
shouldMarkRead: false,
|
|
478
|
+
isSelfChat,
|
|
479
|
+
resolvedAccountId: account.accountId
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
if (!params.group) {
|
|
484
|
+
if (params.isFromMe && !isSamePhone) {
|
|
485
|
+
logVerbose("Skipping outbound DM (fromMe); no pairing reply needed.");
|
|
486
|
+
return {
|
|
487
|
+
allowed: false,
|
|
488
|
+
shouldMarkRead: false,
|
|
489
|
+
isSelfChat,
|
|
490
|
+
resolvedAccountId: account.accountId
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
if (dmPolicy === "disabled") {
|
|
494
|
+
logVerbose("Blocked dm (dmPolicy: disabled)");
|
|
495
|
+
return {
|
|
496
|
+
allowed: false,
|
|
497
|
+
shouldMarkRead: false,
|
|
498
|
+
isSelfChat,
|
|
499
|
+
resolvedAccountId: account.accountId
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
if (dmPolicy !== "open" && !isSamePhone) {
|
|
503
|
+
const candidate = params.from;
|
|
504
|
+
if (!(dmHasWildcard || normalizedAllowFrom.length > 0 && normalizedAllowFrom.includes(candidate))) {
|
|
505
|
+
if (dmPolicy === "pairing") if (suppressPairingReply) logVerbose(`Skipping pairing reply for historical DM from ${candidate}.`);
|
|
506
|
+
else {
|
|
507
|
+
const { code, created } = await upsertChannelPairingRequest({
|
|
508
|
+
channel: "whatsapp",
|
|
509
|
+
id: candidate,
|
|
510
|
+
meta: { name: (params.pushName ?? "").trim() || void 0 }
|
|
511
|
+
});
|
|
512
|
+
if (created) {
|
|
513
|
+
logVerbose(`whatsapp pairing request sender=${candidate} name=${params.pushName ?? "unknown"}`);
|
|
514
|
+
try {
|
|
515
|
+
await params.sock.sendMessage(params.remoteJid, { text: buildPairingReply({
|
|
516
|
+
channel: "whatsapp",
|
|
517
|
+
idLine: `Your WhatsApp phone number: ${candidate}`,
|
|
518
|
+
code
|
|
519
|
+
}) });
|
|
520
|
+
} catch (err) {
|
|
521
|
+
logVerbose(`whatsapp pairing reply failed for ${candidate}: ${String(err)}`);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
else logVerbose(`Blocked unauthorized sender ${candidate} (dmPolicy=${dmPolicy})`);
|
|
526
|
+
return {
|
|
527
|
+
allowed: false,
|
|
528
|
+
shouldMarkRead: false,
|
|
529
|
+
isSelfChat,
|
|
530
|
+
resolvedAccountId: account.accountId
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
return {
|
|
536
|
+
allowed: true,
|
|
537
|
+
shouldMarkRead: true,
|
|
538
|
+
isSelfChat,
|
|
539
|
+
resolvedAccountId: account.accountId
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
//#endregion
|
|
544
|
+
//#region src/web/inbound/media.ts
|
|
545
|
+
function unwrapMessage(message) {
|
|
546
|
+
return normalizeMessageContent(message);
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* Resolve the MIME type for an inbound media message.
|
|
550
|
+
* Falls back to WhatsApp's standard formats when Baileys omits the MIME.
|
|
551
|
+
*/
|
|
552
|
+
function resolveMediaMimetype(message) {
|
|
553
|
+
const explicit = message.imageMessage?.mimetype ?? message.videoMessage?.mimetype ?? message.documentMessage?.mimetype ?? message.audioMessage?.mimetype ?? message.stickerMessage?.mimetype ?? void 0;
|
|
554
|
+
if (explicit) return explicit;
|
|
555
|
+
if (message.audioMessage) return "audio/ogg; codecs=opus";
|
|
556
|
+
if (message.imageMessage) return "image/jpeg";
|
|
557
|
+
if (message.videoMessage) return "video/mp4";
|
|
558
|
+
if (message.stickerMessage) return "image/webp";
|
|
559
|
+
}
|
|
560
|
+
async function downloadInboundMedia(msg, sock) {
|
|
561
|
+
const message = unwrapMessage(msg.message);
|
|
562
|
+
if (!message) return;
|
|
563
|
+
const mimetype = resolveMediaMimetype(message);
|
|
564
|
+
const fileName = message.documentMessage?.fileName ?? void 0;
|
|
565
|
+
if (!message.imageMessage && !message.videoMessage && !message.documentMessage && !message.audioMessage && !message.stickerMessage) return;
|
|
566
|
+
try {
|
|
567
|
+
return {
|
|
568
|
+
buffer: await downloadMediaMessage(msg, "buffer", {}, {
|
|
569
|
+
reuploadRequest: sock.updateMediaMessage,
|
|
570
|
+
logger: sock.logger
|
|
571
|
+
}),
|
|
572
|
+
mimetype,
|
|
573
|
+
fileName
|
|
574
|
+
};
|
|
575
|
+
} catch (err) {
|
|
576
|
+
logVerbose(`downloadMediaMessage failed: ${String(err)}`);
|
|
577
|
+
return;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
//#endregion
|
|
582
|
+
//#region src/web/inbound/send-api.ts
|
|
583
|
+
function createWebSendApi(params) {
|
|
584
|
+
return {
|
|
585
|
+
sendMessage: async (to, text, mediaBuffer, mediaType, sendOptions) => {
|
|
586
|
+
const jid = toWhatsappJid(to);
|
|
587
|
+
let payload;
|
|
588
|
+
if (mediaBuffer && mediaType) if (mediaType.startsWith("image/")) payload = {
|
|
589
|
+
image: mediaBuffer,
|
|
590
|
+
caption: text || void 0,
|
|
591
|
+
mimetype: mediaType
|
|
592
|
+
};
|
|
593
|
+
else if (mediaType.startsWith("audio/")) payload = {
|
|
594
|
+
audio: mediaBuffer,
|
|
595
|
+
ptt: true,
|
|
596
|
+
mimetype: mediaType
|
|
597
|
+
};
|
|
598
|
+
else if (mediaType.startsWith("video/")) {
|
|
599
|
+
const gifPlayback = sendOptions?.gifPlayback;
|
|
600
|
+
payload = {
|
|
601
|
+
video: mediaBuffer,
|
|
602
|
+
caption: text || void 0,
|
|
603
|
+
mimetype: mediaType,
|
|
604
|
+
...gifPlayback ? { gifPlayback: true } : {}
|
|
605
|
+
};
|
|
606
|
+
} else payload = {
|
|
607
|
+
document: mediaBuffer,
|
|
608
|
+
fileName: sendOptions?.fileName?.trim() || "file",
|
|
609
|
+
caption: text || void 0,
|
|
610
|
+
mimetype: mediaType
|
|
611
|
+
};
|
|
612
|
+
else payload = { text };
|
|
613
|
+
const result = await params.sock.sendMessage(jid, payload);
|
|
614
|
+
recordChannelActivity({
|
|
615
|
+
channel: "whatsapp",
|
|
616
|
+
accountId: sendOptions?.accountId ?? params.defaultAccountId,
|
|
617
|
+
direction: "outbound"
|
|
618
|
+
});
|
|
619
|
+
return { messageId: typeof result === "object" && result && "key" in result ? String(result.key?.id ?? "unknown") : "unknown" };
|
|
620
|
+
},
|
|
621
|
+
sendPoll: async (to, poll) => {
|
|
622
|
+
const jid = toWhatsappJid(to);
|
|
623
|
+
const result = await params.sock.sendMessage(jid, { poll: {
|
|
624
|
+
name: poll.question,
|
|
625
|
+
values: poll.options,
|
|
626
|
+
selectableCount: poll.maxSelections ?? 1
|
|
627
|
+
} });
|
|
628
|
+
recordChannelActivity({
|
|
629
|
+
channel: "whatsapp",
|
|
630
|
+
accountId: params.defaultAccountId,
|
|
631
|
+
direction: "outbound"
|
|
632
|
+
});
|
|
633
|
+
return { messageId: typeof result === "object" && result && "key" in result ? String(result.key?.id ?? "unknown") : "unknown" };
|
|
634
|
+
},
|
|
635
|
+
sendReaction: async (chatJid, messageId, emoji, fromMe, participant) => {
|
|
636
|
+
const jid = toWhatsappJid(chatJid);
|
|
637
|
+
await params.sock.sendMessage(jid, { react: {
|
|
638
|
+
text: emoji,
|
|
639
|
+
key: {
|
|
640
|
+
remoteJid: jid,
|
|
641
|
+
id: messageId,
|
|
642
|
+
fromMe,
|
|
643
|
+
participant: participant ? toWhatsappJid(participant) : void 0
|
|
644
|
+
}
|
|
645
|
+
} });
|
|
646
|
+
},
|
|
647
|
+
sendComposingTo: async (to) => {
|
|
648
|
+
const jid = toWhatsappJid(to);
|
|
649
|
+
await params.sock.sendPresenceUpdate("composing", jid);
|
|
650
|
+
}
|
|
651
|
+
};
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
//#endregion
|
|
655
|
+
//#region src/web/inbound/monitor.ts
|
|
656
|
+
async function monitorWebInbox(options) {
|
|
657
|
+
const inboundLogger = getChildLogger({ module: "web-inbound" });
|
|
658
|
+
const inboundConsoleLog = createSubsystemLogger("gateway/channels/whatsapp").child("inbound");
|
|
659
|
+
const sock = await createWaSocket(false, options.verbose, { authDir: options.authDir });
|
|
660
|
+
await waitForWaConnection(sock);
|
|
661
|
+
const connectedAtMs = Date.now();
|
|
662
|
+
let onCloseResolve = null;
|
|
663
|
+
const onClose = new Promise((resolve) => {
|
|
664
|
+
onCloseResolve = resolve;
|
|
665
|
+
});
|
|
666
|
+
const resolveClose = (reason) => {
|
|
667
|
+
if (!onCloseResolve) return;
|
|
668
|
+
const resolver = onCloseResolve;
|
|
669
|
+
onCloseResolve = null;
|
|
670
|
+
resolver(reason);
|
|
671
|
+
};
|
|
672
|
+
try {
|
|
673
|
+
await sock.sendPresenceUpdate("available");
|
|
674
|
+
if (shouldLogVerbose()) logVerbose("Sent global 'available' presence on connect");
|
|
675
|
+
} catch (err) {
|
|
676
|
+
logVerbose(`Failed to send 'available' presence on connect: ${String(err)}`);
|
|
677
|
+
}
|
|
678
|
+
const selfJid = sock.user?.id;
|
|
679
|
+
const selfE164 = selfJid ? jidToE164(selfJid) : null;
|
|
680
|
+
const debouncer = createInboundDebouncer({
|
|
681
|
+
debounceMs: options.debounceMs ?? 0,
|
|
682
|
+
buildKey: (msg) => {
|
|
683
|
+
const senderKey = msg.chatType === "group" ? msg.senderJid ?? msg.senderE164 ?? msg.senderName ?? msg.from : msg.from;
|
|
684
|
+
if (!senderKey) return null;
|
|
685
|
+
const conversationKey = msg.chatType === "group" ? msg.chatId : msg.from;
|
|
686
|
+
return `${msg.accountId}:${conversationKey}:${senderKey}`;
|
|
687
|
+
},
|
|
688
|
+
shouldDebounce: options.shouldDebounce,
|
|
689
|
+
onFlush: async (entries) => {
|
|
690
|
+
const last = entries.at(-1);
|
|
691
|
+
if (!last) return;
|
|
692
|
+
if (entries.length === 1) {
|
|
693
|
+
await options.onMessage(last);
|
|
694
|
+
return;
|
|
695
|
+
}
|
|
696
|
+
const mentioned = /* @__PURE__ */ new Set();
|
|
697
|
+
for (const entry of entries) for (const jid of entry.mentionedJids ?? []) mentioned.add(jid);
|
|
698
|
+
const combinedBody = entries.map((entry) => entry.body).filter(Boolean).join("\n");
|
|
699
|
+
const combinedMessage = {
|
|
700
|
+
...last,
|
|
701
|
+
body: combinedBody,
|
|
702
|
+
mentionedJids: mentioned.size > 0 ? Array.from(mentioned) : void 0
|
|
703
|
+
};
|
|
704
|
+
await options.onMessage(combinedMessage);
|
|
705
|
+
},
|
|
706
|
+
onError: (err) => {
|
|
707
|
+
inboundLogger.error({ error: String(err) }, "failed handling inbound web message");
|
|
708
|
+
inboundConsoleLog.error(`Failed handling inbound web message: ${String(err)}`);
|
|
709
|
+
}
|
|
710
|
+
});
|
|
711
|
+
const groupMetaCache = /* @__PURE__ */ new Map();
|
|
712
|
+
const GROUP_META_TTL_MS = 300 * 1e3;
|
|
713
|
+
const lidLookup = sock.signalRepository?.lidMapping;
|
|
714
|
+
const resolveInboundJid = async (jid) => resolveJidToE164(jid, {
|
|
715
|
+
authDir: options.authDir,
|
|
716
|
+
lidLookup
|
|
717
|
+
});
|
|
718
|
+
const getGroupMeta = async (jid) => {
|
|
719
|
+
const cached = groupMetaCache.get(jid);
|
|
720
|
+
if (cached && cached.expires > Date.now()) return cached;
|
|
721
|
+
try {
|
|
722
|
+
const meta = await sock.groupMetadata(jid);
|
|
723
|
+
const participants = (await Promise.all(meta.participants?.map(async (p) => {
|
|
724
|
+
return await resolveInboundJid(p.id) ?? p.id;
|
|
725
|
+
}) ?? [])).filter(Boolean) ?? [];
|
|
726
|
+
const entry = {
|
|
727
|
+
subject: meta.subject,
|
|
728
|
+
participants,
|
|
729
|
+
expires: Date.now() + GROUP_META_TTL_MS
|
|
730
|
+
};
|
|
731
|
+
groupMetaCache.set(jid, entry);
|
|
732
|
+
return entry;
|
|
733
|
+
} catch (err) {
|
|
734
|
+
logVerbose(`Failed to fetch group metadata for ${jid}: ${String(err)}`);
|
|
735
|
+
return { expires: Date.now() + GROUP_META_TTL_MS };
|
|
736
|
+
}
|
|
737
|
+
};
|
|
738
|
+
const handleMessagesUpsert = async (upsert) => {
|
|
739
|
+
if (upsert.type !== "notify" && upsert.type !== "append") return;
|
|
740
|
+
for (const msg of upsert.messages ?? []) {
|
|
741
|
+
recordChannelActivity({
|
|
742
|
+
channel: "whatsapp",
|
|
743
|
+
accountId: options.accountId,
|
|
744
|
+
direction: "inbound"
|
|
745
|
+
});
|
|
746
|
+
const id = msg.key?.id ?? void 0;
|
|
747
|
+
const remoteJid = msg.key?.remoteJid;
|
|
748
|
+
if (!remoteJid) continue;
|
|
749
|
+
if (remoteJid.endsWith("@status") || remoteJid.endsWith("@broadcast")) continue;
|
|
750
|
+
const group = isJidGroup(remoteJid) === true;
|
|
751
|
+
if (id) {
|
|
752
|
+
if (isRecentInboundMessage(`${options.accountId}:${remoteJid}:${id}`)) continue;
|
|
753
|
+
}
|
|
754
|
+
const participantJid = msg.key?.participant ?? void 0;
|
|
755
|
+
const from = group ? remoteJid : await resolveInboundJid(remoteJid);
|
|
756
|
+
if (!from) continue;
|
|
757
|
+
const senderE164 = group ? participantJid ? await resolveInboundJid(participantJid) : null : from;
|
|
758
|
+
let groupSubject;
|
|
759
|
+
let groupParticipants;
|
|
760
|
+
if (group) {
|
|
761
|
+
const meta = await getGroupMeta(remoteJid);
|
|
762
|
+
groupSubject = meta.subject;
|
|
763
|
+
groupParticipants = meta.participants;
|
|
764
|
+
}
|
|
765
|
+
const messageTimestampMs = msg.messageTimestamp ? Number(msg.messageTimestamp) * 1e3 : void 0;
|
|
766
|
+
const access = await checkInboundAccessControl({
|
|
767
|
+
accountId: options.accountId,
|
|
768
|
+
from,
|
|
769
|
+
selfE164,
|
|
770
|
+
senderE164,
|
|
771
|
+
group,
|
|
772
|
+
pushName: msg.pushName ?? void 0,
|
|
773
|
+
isFromMe: Boolean(msg.key?.fromMe),
|
|
774
|
+
messageTimestampMs,
|
|
775
|
+
connectedAtMs,
|
|
776
|
+
sock: { sendMessage: (jid, content) => sock.sendMessage(jid, content) },
|
|
777
|
+
remoteJid
|
|
778
|
+
});
|
|
779
|
+
if (!access.allowed) continue;
|
|
780
|
+
if (id && !access.isSelfChat && options.sendReadReceipts !== false) {
|
|
781
|
+
const participant = msg.key?.participant;
|
|
782
|
+
try {
|
|
783
|
+
await sock.readMessages([{
|
|
784
|
+
remoteJid,
|
|
785
|
+
id,
|
|
786
|
+
participant,
|
|
787
|
+
fromMe: false
|
|
788
|
+
}]);
|
|
789
|
+
if (shouldLogVerbose()) logVerbose(`Marked message ${id} as read for ${remoteJid}${participant ? ` (participant ${participant})` : ""}`);
|
|
790
|
+
} catch (err) {
|
|
791
|
+
logVerbose(`Failed to mark message ${id} read: ${String(err)}`);
|
|
792
|
+
}
|
|
793
|
+
} else if (id && access.isSelfChat && shouldLogVerbose()) logVerbose(`Self-chat mode: skipping read receipt for ${id}`);
|
|
794
|
+
if (upsert.type === "append") continue;
|
|
795
|
+
const location = extractLocationData(msg.message ?? void 0);
|
|
796
|
+
const locationText = location ? formatLocationText(location) : void 0;
|
|
797
|
+
let body = extractText(msg.message ?? void 0);
|
|
798
|
+
if (locationText) body = [body, locationText].filter(Boolean).join("\n").trim();
|
|
799
|
+
if (!body) {
|
|
800
|
+
body = extractMediaPlaceholder(msg.message ?? void 0);
|
|
801
|
+
if (!body) continue;
|
|
802
|
+
}
|
|
803
|
+
const replyContext = describeReplyContext(msg.message);
|
|
804
|
+
let mediaPath;
|
|
805
|
+
let mediaType;
|
|
806
|
+
let mediaFileName;
|
|
807
|
+
try {
|
|
808
|
+
const inboundMedia = await downloadInboundMedia(msg, sock);
|
|
809
|
+
if (inboundMedia) {
|
|
810
|
+
const maxBytes = (typeof options.mediaMaxMb === "number" && options.mediaMaxMb > 0 ? options.mediaMaxMb : 50) * 1024 * 1024;
|
|
811
|
+
mediaPath = (await saveMediaBuffer(inboundMedia.buffer, inboundMedia.mimetype, "inbound", maxBytes, inboundMedia.fileName)).path;
|
|
812
|
+
mediaType = inboundMedia.mimetype;
|
|
813
|
+
mediaFileName = inboundMedia.fileName;
|
|
814
|
+
}
|
|
815
|
+
} catch (err) {
|
|
816
|
+
logVerbose(`Inbound media download failed: ${String(err)}`);
|
|
817
|
+
}
|
|
818
|
+
const chatJid = remoteJid;
|
|
819
|
+
const sendComposing = async () => {
|
|
820
|
+
try {
|
|
821
|
+
await sock.sendPresenceUpdate("composing", chatJid);
|
|
822
|
+
} catch (err) {
|
|
823
|
+
logVerbose(`Presence update failed: ${String(err)}`);
|
|
824
|
+
}
|
|
825
|
+
};
|
|
826
|
+
const reply = async (text) => {
|
|
827
|
+
await sock.sendMessage(chatJid, { text });
|
|
828
|
+
};
|
|
829
|
+
const sendMedia = async (payload) => {
|
|
830
|
+
await sock.sendMessage(chatJid, payload);
|
|
831
|
+
};
|
|
832
|
+
const timestamp = messageTimestampMs;
|
|
833
|
+
const mentionedJids = extractMentionedJids(msg.message);
|
|
834
|
+
const senderName = msg.pushName ?? void 0;
|
|
835
|
+
inboundLogger.info({
|
|
836
|
+
from,
|
|
837
|
+
to: selfE164 ?? "me",
|
|
838
|
+
body,
|
|
839
|
+
mediaPath,
|
|
840
|
+
mediaType,
|
|
841
|
+
mediaFileName,
|
|
842
|
+
timestamp
|
|
843
|
+
}, "inbound message");
|
|
844
|
+
const inboundMessage = {
|
|
845
|
+
id,
|
|
846
|
+
from,
|
|
847
|
+
conversationId: from,
|
|
848
|
+
to: selfE164 ?? "me",
|
|
849
|
+
accountId: access.resolvedAccountId,
|
|
850
|
+
body,
|
|
851
|
+
pushName: senderName,
|
|
852
|
+
timestamp,
|
|
853
|
+
chatType: group ? "group" : "direct",
|
|
854
|
+
chatId: remoteJid,
|
|
855
|
+
senderJid: participantJid,
|
|
856
|
+
senderE164: senderE164 ?? void 0,
|
|
857
|
+
senderName,
|
|
858
|
+
replyToId: replyContext?.id,
|
|
859
|
+
replyToBody: replyContext?.body,
|
|
860
|
+
replyToSender: replyContext?.sender,
|
|
861
|
+
replyToSenderJid: replyContext?.senderJid,
|
|
862
|
+
replyToSenderE164: replyContext?.senderE164,
|
|
863
|
+
groupSubject,
|
|
864
|
+
groupParticipants,
|
|
865
|
+
mentionedJids: mentionedJids ?? void 0,
|
|
866
|
+
selfJid,
|
|
867
|
+
selfE164,
|
|
868
|
+
location: location ?? void 0,
|
|
869
|
+
sendComposing,
|
|
870
|
+
reply,
|
|
871
|
+
sendMedia,
|
|
872
|
+
mediaPath,
|
|
873
|
+
mediaType,
|
|
874
|
+
mediaFileName
|
|
875
|
+
};
|
|
876
|
+
try {
|
|
877
|
+
Promise.resolve(debouncer.enqueue(inboundMessage)).catch((err) => {
|
|
878
|
+
inboundLogger.error({ error: String(err) }, "failed handling inbound web message");
|
|
879
|
+
inboundConsoleLog.error(`Failed handling inbound web message: ${String(err)}`);
|
|
880
|
+
});
|
|
881
|
+
} catch (err) {
|
|
882
|
+
inboundLogger.error({ error: String(err) }, "failed handling inbound web message");
|
|
883
|
+
inboundConsoleLog.error(`Failed handling inbound web message: ${String(err)}`);
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
};
|
|
887
|
+
sock.ev.on("messages.upsert", handleMessagesUpsert);
|
|
888
|
+
const handleConnectionUpdate = (update) => {
|
|
889
|
+
try {
|
|
890
|
+
if (update.connection === "close") {
|
|
891
|
+
const status = getStatusCode(update.lastDisconnect?.error);
|
|
892
|
+
resolveClose({
|
|
893
|
+
status,
|
|
894
|
+
isLoggedOut: status === DisconnectReason.loggedOut,
|
|
895
|
+
error: update.lastDisconnect?.error
|
|
896
|
+
});
|
|
897
|
+
}
|
|
898
|
+
} catch (err) {
|
|
899
|
+
inboundLogger.error({ error: String(err) }, "connection.update handler error");
|
|
900
|
+
resolveClose({
|
|
901
|
+
status: void 0,
|
|
902
|
+
isLoggedOut: false,
|
|
903
|
+
error: err
|
|
904
|
+
});
|
|
905
|
+
}
|
|
906
|
+
};
|
|
907
|
+
sock.ev.on("connection.update", handleConnectionUpdate);
|
|
908
|
+
return {
|
|
909
|
+
close: async () => {
|
|
910
|
+
try {
|
|
911
|
+
const ev = sock.ev;
|
|
912
|
+
const messagesUpsertHandler = handleMessagesUpsert;
|
|
913
|
+
const connectionUpdateHandler = handleConnectionUpdate;
|
|
914
|
+
if (typeof ev.off === "function") {
|
|
915
|
+
ev.off("messages.upsert", messagesUpsertHandler);
|
|
916
|
+
ev.off("connection.update", connectionUpdateHandler);
|
|
917
|
+
} else if (typeof ev.removeListener === "function") {
|
|
918
|
+
ev.removeListener("messages.upsert", messagesUpsertHandler);
|
|
919
|
+
ev.removeListener("connection.update", connectionUpdateHandler);
|
|
920
|
+
}
|
|
921
|
+
sock.ws?.close();
|
|
922
|
+
} catch (err) {
|
|
923
|
+
logVerbose(`Socket close failed: ${String(err)}`);
|
|
924
|
+
}
|
|
925
|
+
},
|
|
926
|
+
onClose,
|
|
927
|
+
signalClose: (reason) => {
|
|
928
|
+
resolveClose(reason ?? {
|
|
929
|
+
status: void 0,
|
|
930
|
+
isLoggedOut: false,
|
|
931
|
+
error: "closed"
|
|
932
|
+
});
|
|
933
|
+
},
|
|
934
|
+
...createWebSendApi({
|
|
935
|
+
sock: {
|
|
936
|
+
sendMessage: (jid, content) => sock.sendMessage(jid, content),
|
|
937
|
+
sendPresenceUpdate: (presence, jid) => sock.sendPresenceUpdate(presence, jid)
|
|
938
|
+
},
|
|
939
|
+
defaultAccountId: options.accountId
|
|
940
|
+
})
|
|
941
|
+
};
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
//#endregion
|
|
945
|
+
//#region src/web/auto-reply/mentions.ts
|
|
946
|
+
function buildMentionConfig(cfg, agentId) {
|
|
947
|
+
return {
|
|
948
|
+
mentionRegexes: buildMentionRegexes(cfg, agentId),
|
|
949
|
+
allowFrom: cfg.channels?.whatsapp?.allowFrom
|
|
950
|
+
};
|
|
951
|
+
}
|
|
952
|
+
function resolveMentionTargets(msg, authDir) {
|
|
953
|
+
const jidOptions = authDir ? { authDir } : void 0;
|
|
954
|
+
return {
|
|
955
|
+
normalizedMentions: msg.mentionedJids?.length ? msg.mentionedJids.map((jid) => jidToE164(jid, jidOptions) ?? jid).filter(Boolean) : [],
|
|
956
|
+
selfE164: msg.selfE164 ?? (msg.selfJid ? jidToE164(msg.selfJid, jidOptions) : null),
|
|
957
|
+
selfJid: msg.selfJid ? msg.selfJid.replace(/:\\d+/, "") : null
|
|
958
|
+
};
|
|
959
|
+
}
|
|
960
|
+
function isBotMentionedFromTargets(msg, mentionCfg, targets) {
|
|
961
|
+
const clean = (text) => normalizeMentionText(text);
|
|
962
|
+
const isSelfChat = isSelfChatMode(targets.selfE164, mentionCfg.allowFrom);
|
|
963
|
+
const hasMentions = (msg.mentionedJids?.length ?? 0) > 0;
|
|
964
|
+
if (hasMentions && !isSelfChat) {
|
|
965
|
+
if (targets.selfE164 && targets.normalizedMentions.includes(targets.selfE164)) return true;
|
|
966
|
+
if (targets.selfJid) {
|
|
967
|
+
if (targets.normalizedMentions.includes(targets.selfJid)) return true;
|
|
968
|
+
}
|
|
969
|
+
return false;
|
|
970
|
+
} else if (hasMentions && isSelfChat) {}
|
|
971
|
+
const bodyClean = clean(msg.body);
|
|
972
|
+
if (mentionCfg.mentionRegexes.some((re) => re.test(bodyClean))) return true;
|
|
973
|
+
if (targets.selfE164) {
|
|
974
|
+
const selfDigits = targets.selfE164.replace(/\D/g, "");
|
|
975
|
+
if (selfDigits) {
|
|
976
|
+
if (bodyClean.replace(/[^\d]/g, "").includes(selfDigits)) return true;
|
|
977
|
+
const bodyNoSpace = msg.body.replace(/[\s-]/g, "");
|
|
978
|
+
if (new RegExp(`\\+?${selfDigits}`, "i").test(bodyNoSpace)) return true;
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
return false;
|
|
982
|
+
}
|
|
983
|
+
function debugMention(msg, mentionCfg, authDir) {
|
|
984
|
+
const mentionTargets = resolveMentionTargets(msg, authDir);
|
|
985
|
+
return {
|
|
986
|
+
wasMentioned: isBotMentionedFromTargets(msg, mentionCfg, mentionTargets),
|
|
987
|
+
details: {
|
|
988
|
+
from: msg.from,
|
|
989
|
+
body: msg.body,
|
|
990
|
+
bodyClean: normalizeMentionText(msg.body),
|
|
991
|
+
mentionedJids: msg.mentionedJids ?? null,
|
|
992
|
+
normalizedMentionedJids: mentionTargets.normalizedMentions.length ? mentionTargets.normalizedMentions : null,
|
|
993
|
+
selfJid: msg.selfJid ?? null,
|
|
994
|
+
selfJidBare: mentionTargets.selfJid,
|
|
995
|
+
selfE164: msg.selfE164 ?? null,
|
|
996
|
+
resolvedSelfE164: mentionTargets.selfE164
|
|
997
|
+
}
|
|
998
|
+
};
|
|
999
|
+
}
|
|
1000
|
+
function resolveOwnerList(mentionCfg, selfE164) {
|
|
1001
|
+
const allowFrom = mentionCfg.allowFrom;
|
|
1002
|
+
return (Array.isArray(allowFrom) && allowFrom.length > 0 ? allowFrom : selfE164 ? [selfE164] : []).filter((entry) => Boolean(entry && entry !== "*")).map((entry) => normalizeE164(entry)).filter((entry) => Boolean(entry));
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
//#endregion
|
|
1006
|
+
//#region src/web/auto-reply/monitor/echo.ts
|
|
1007
|
+
function createEchoTracker(params) {
|
|
1008
|
+
const recentlySent = /* @__PURE__ */ new Set();
|
|
1009
|
+
const maxItems = Math.max(1, params.maxItems ?? 100);
|
|
1010
|
+
const buildCombinedKey = (p) => `combined:${p.sessionKey}:${p.combinedBody}`;
|
|
1011
|
+
const trim = () => {
|
|
1012
|
+
while (recentlySent.size > maxItems) {
|
|
1013
|
+
const firstKey = recentlySent.values().next().value;
|
|
1014
|
+
if (!firstKey) break;
|
|
1015
|
+
recentlySent.delete(firstKey);
|
|
1016
|
+
}
|
|
1017
|
+
};
|
|
1018
|
+
const rememberText = (text, opts) => {
|
|
1019
|
+
if (!text) return;
|
|
1020
|
+
recentlySent.add(text);
|
|
1021
|
+
if (opts.combinedBody && opts.combinedBodySessionKey) recentlySent.add(buildCombinedKey({
|
|
1022
|
+
sessionKey: opts.combinedBodySessionKey,
|
|
1023
|
+
combinedBody: opts.combinedBody
|
|
1024
|
+
}));
|
|
1025
|
+
if (opts.logVerboseMessage) params.logVerbose?.(`Added to echo detection set (size now: ${recentlySent.size}): ${text.substring(0, 50)}...`);
|
|
1026
|
+
trim();
|
|
1027
|
+
};
|
|
1028
|
+
return {
|
|
1029
|
+
rememberText,
|
|
1030
|
+
has: (key) => recentlySent.has(key),
|
|
1031
|
+
forget: (key) => {
|
|
1032
|
+
recentlySent.delete(key);
|
|
1033
|
+
},
|
|
1034
|
+
buildCombinedKey
|
|
1035
|
+
};
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
//#endregion
|
|
1039
|
+
//#region src/web/auto-reply/monitor/broadcast.ts
|
|
1040
|
+
async function maybeBroadcastMessage(params) {
|
|
1041
|
+
const broadcastAgents = params.cfg.broadcast?.[params.peerId];
|
|
1042
|
+
if (!broadcastAgents || !Array.isArray(broadcastAgents)) return false;
|
|
1043
|
+
if (broadcastAgents.length === 0) return false;
|
|
1044
|
+
const strategy = params.cfg.broadcast?.strategy || "parallel";
|
|
1045
|
+
whatsappInboundLog.info(`Broadcasting message to ${broadcastAgents.length} agents (${strategy})`);
|
|
1046
|
+
const agentIds = params.cfg.agents?.list?.map((agent) => normalizeAgentId(agent.id));
|
|
1047
|
+
const hasKnownAgents = (agentIds?.length ?? 0) > 0;
|
|
1048
|
+
const groupHistorySnapshot = params.msg.chatType === "group" ? params.groupHistories.get(params.groupHistoryKey) ?? [] : void 0;
|
|
1049
|
+
const processForAgent = async (agentId) => {
|
|
1050
|
+
const normalizedAgentId = normalizeAgentId(agentId);
|
|
1051
|
+
if (hasKnownAgents && !agentIds?.includes(normalizedAgentId)) {
|
|
1052
|
+
whatsappInboundLog.warn(`Broadcast agent ${agentId} not found in agents.list; skipping`);
|
|
1053
|
+
return false;
|
|
1054
|
+
}
|
|
1055
|
+
const agentRoute = {
|
|
1056
|
+
...params.route,
|
|
1057
|
+
agentId: normalizedAgentId,
|
|
1058
|
+
sessionKey: buildAgentSessionKey({
|
|
1059
|
+
agentId: normalizedAgentId,
|
|
1060
|
+
channel: "whatsapp",
|
|
1061
|
+
accountId: params.route.accountId,
|
|
1062
|
+
peer: {
|
|
1063
|
+
kind: params.msg.chatType === "group" ? "group" : "direct",
|
|
1064
|
+
id: params.peerId
|
|
1065
|
+
},
|
|
1066
|
+
dmScope: params.cfg.session?.dmScope,
|
|
1067
|
+
identityLinks: params.cfg.session?.identityLinks
|
|
1068
|
+
}),
|
|
1069
|
+
mainSessionKey: buildAgentMainSessionKey({
|
|
1070
|
+
agentId: normalizedAgentId,
|
|
1071
|
+
mainKey: DEFAULT_MAIN_KEY
|
|
1072
|
+
})
|
|
1073
|
+
};
|
|
1074
|
+
try {
|
|
1075
|
+
return await params.processMessage(params.msg, agentRoute, params.groupHistoryKey, {
|
|
1076
|
+
groupHistory: groupHistorySnapshot,
|
|
1077
|
+
suppressGroupHistoryClear: true
|
|
1078
|
+
});
|
|
1079
|
+
} catch (err) {
|
|
1080
|
+
whatsappInboundLog.error(`Broadcast agent ${agentId} failed: ${formatError(err)}`);
|
|
1081
|
+
return false;
|
|
1082
|
+
}
|
|
1083
|
+
};
|
|
1084
|
+
if (strategy === "sequential") for (const agentId of broadcastAgents) await processForAgent(agentId);
|
|
1085
|
+
else await Promise.allSettled(broadcastAgents.map(processForAgent));
|
|
1086
|
+
if (params.msg.chatType === "group") params.groupHistories.set(params.groupHistoryKey, []);
|
|
1087
|
+
return true;
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
//#endregion
|
|
1091
|
+
//#region src/channels/mention-gating.ts
|
|
1092
|
+
function resolveMentionGating(params) {
|
|
1093
|
+
const implicit = params.implicitMention === true;
|
|
1094
|
+
const bypass = params.shouldBypassMention === true;
|
|
1095
|
+
const effectiveWasMentioned = params.wasMentioned || implicit || bypass;
|
|
1096
|
+
return {
|
|
1097
|
+
effectiveWasMentioned,
|
|
1098
|
+
shouldSkip: params.requireMention && params.canDetectMention && !effectiveWasMentioned
|
|
1099
|
+
};
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
//#endregion
|
|
1103
|
+
//#region src/web/auto-reply/monitor/commands.ts
|
|
1104
|
+
function stripMentionsForCommand(text, mentionRegexes, selfE164) {
|
|
1105
|
+
let result = text;
|
|
1106
|
+
for (const re of mentionRegexes) result = result.replace(re, " ");
|
|
1107
|
+
if (selfE164) {
|
|
1108
|
+
const digits = selfE164.replace(/\D/g, "");
|
|
1109
|
+
if (digits) {
|
|
1110
|
+
const pattern = new RegExp(`\\+?${digits}`, "g");
|
|
1111
|
+
result = result.replace(pattern, " ");
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
return result.replace(/\s+/g, " ").trim();
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
//#endregion
|
|
1118
|
+
//#region src/web/auto-reply/monitor/group-activation.ts
|
|
1119
|
+
function resolveGroupPolicyFor(cfg, conversationId) {
|
|
1120
|
+
const groupId = resolveGroupSessionKey({
|
|
1121
|
+
From: conversationId,
|
|
1122
|
+
ChatType: "group",
|
|
1123
|
+
Provider: "whatsapp"
|
|
1124
|
+
})?.id;
|
|
1125
|
+
return resolveChannelGroupPolicy({
|
|
1126
|
+
cfg,
|
|
1127
|
+
channel: "whatsapp",
|
|
1128
|
+
groupId: groupId ?? conversationId
|
|
1129
|
+
});
|
|
1130
|
+
}
|
|
1131
|
+
function resolveGroupRequireMentionFor(cfg, conversationId) {
|
|
1132
|
+
const groupId = resolveGroupSessionKey({
|
|
1133
|
+
From: conversationId,
|
|
1134
|
+
ChatType: "group",
|
|
1135
|
+
Provider: "whatsapp"
|
|
1136
|
+
})?.id;
|
|
1137
|
+
return resolveChannelGroupRequireMention({
|
|
1138
|
+
cfg,
|
|
1139
|
+
channel: "whatsapp",
|
|
1140
|
+
groupId: groupId ?? conversationId
|
|
1141
|
+
});
|
|
1142
|
+
}
|
|
1143
|
+
function resolveGroupActivationFor(params) {
|
|
1144
|
+
const entry = loadSessionStore(resolveStorePath(params.cfg.session?.store, { agentId: params.agentId }))[params.sessionKey];
|
|
1145
|
+
const defaultActivation = !resolveGroupRequireMentionFor(params.cfg, params.conversationId) ? "always" : "mention";
|
|
1146
|
+
return normalizeGroupActivation(entry?.groupActivation) ?? defaultActivation;
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
//#endregion
|
|
1150
|
+
//#region src/web/auto-reply/monitor/group-members.ts
|
|
1151
|
+
function noteGroupMember(groupMemberNames, conversationId, e164, name) {
|
|
1152
|
+
if (!e164 || !name) return;
|
|
1153
|
+
const key = normalizeE164(e164) ?? e164;
|
|
1154
|
+
if (!key) return;
|
|
1155
|
+
let roster = groupMemberNames.get(conversationId);
|
|
1156
|
+
if (!roster) {
|
|
1157
|
+
roster = /* @__PURE__ */ new Map();
|
|
1158
|
+
groupMemberNames.set(conversationId, roster);
|
|
1159
|
+
}
|
|
1160
|
+
roster.set(key, name);
|
|
1161
|
+
}
|
|
1162
|
+
function formatGroupMembers(params) {
|
|
1163
|
+
const { participants, roster, fallbackE164 } = params;
|
|
1164
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1165
|
+
const ordered = [];
|
|
1166
|
+
if (participants?.length) for (const entry of participants) {
|
|
1167
|
+
if (!entry) continue;
|
|
1168
|
+
const normalized = normalizeE164(entry) ?? entry;
|
|
1169
|
+
if (!normalized || seen.has(normalized)) continue;
|
|
1170
|
+
seen.add(normalized);
|
|
1171
|
+
ordered.push(normalized);
|
|
1172
|
+
}
|
|
1173
|
+
if (roster) for (const entry of roster.keys()) {
|
|
1174
|
+
const normalized = normalizeE164(entry) ?? entry;
|
|
1175
|
+
if (!normalized || seen.has(normalized)) continue;
|
|
1176
|
+
seen.add(normalized);
|
|
1177
|
+
ordered.push(normalized);
|
|
1178
|
+
}
|
|
1179
|
+
if (ordered.length === 0 && fallbackE164) {
|
|
1180
|
+
const normalized = normalizeE164(fallbackE164) ?? fallbackE164;
|
|
1181
|
+
if (normalized) ordered.push(normalized);
|
|
1182
|
+
}
|
|
1183
|
+
if (ordered.length === 0) return;
|
|
1184
|
+
return ordered.map((entry) => {
|
|
1185
|
+
const name = roster?.get(entry);
|
|
1186
|
+
return name ? `${name} (${entry})` : entry;
|
|
1187
|
+
}).join(", ");
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
//#endregion
|
|
1191
|
+
//#region src/web/auto-reply/monitor/group-gating.ts
|
|
1192
|
+
function isOwnerSender(baseMentionConfig, msg) {
|
|
1193
|
+
const sender = normalizeE164(msg.senderE164 ?? "");
|
|
1194
|
+
if (!sender) return false;
|
|
1195
|
+
return resolveOwnerList(baseMentionConfig, msg.selfE164 ?? void 0).includes(sender);
|
|
1196
|
+
}
|
|
1197
|
+
function recordPendingGroupHistoryEntry(params) {
|
|
1198
|
+
const sender = params.msg.senderName && params.msg.senderE164 ? `${params.msg.senderName} (${params.msg.senderE164})` : params.msg.senderName ?? params.msg.senderE164 ?? "Unknown";
|
|
1199
|
+
recordPendingHistoryEntryIfEnabled({
|
|
1200
|
+
historyMap: params.groupHistories,
|
|
1201
|
+
historyKey: params.groupHistoryKey,
|
|
1202
|
+
limit: params.groupHistoryLimit,
|
|
1203
|
+
entry: {
|
|
1204
|
+
sender,
|
|
1205
|
+
body: params.msg.body,
|
|
1206
|
+
timestamp: params.msg.timestamp,
|
|
1207
|
+
id: params.msg.id,
|
|
1208
|
+
senderJid: params.msg.senderJid
|
|
1209
|
+
}
|
|
1210
|
+
});
|
|
1211
|
+
}
|
|
1212
|
+
function applyGroupGating(params) {
|
|
1213
|
+
const groupPolicy = resolveGroupPolicyFor(params.cfg, params.conversationId);
|
|
1214
|
+
if (groupPolicy.allowlistEnabled && !groupPolicy.allowed) {
|
|
1215
|
+
params.logVerbose(`Skipping group message ${params.conversationId} (not in allowlist)`);
|
|
1216
|
+
return { shouldProcess: false };
|
|
1217
|
+
}
|
|
1218
|
+
noteGroupMember(params.groupMemberNames, params.groupHistoryKey, params.msg.senderE164, params.msg.senderName);
|
|
1219
|
+
const mentionConfig = buildMentionConfig(params.cfg, params.agentId);
|
|
1220
|
+
const commandBody = stripMentionsForCommand(params.msg.body, mentionConfig.mentionRegexes, params.msg.selfE164);
|
|
1221
|
+
const activationCommand = parseActivationCommand(commandBody);
|
|
1222
|
+
const owner = isOwnerSender(params.baseMentionConfig, params.msg);
|
|
1223
|
+
const shouldBypassMention = owner && hasControlCommand(commandBody, params.cfg);
|
|
1224
|
+
if (activationCommand.hasCommand && !owner) {
|
|
1225
|
+
params.logVerbose(`Ignoring /activation from non-owner in group ${params.conversationId}`);
|
|
1226
|
+
recordPendingGroupHistoryEntry({
|
|
1227
|
+
msg: params.msg,
|
|
1228
|
+
groupHistories: params.groupHistories,
|
|
1229
|
+
groupHistoryKey: params.groupHistoryKey,
|
|
1230
|
+
groupHistoryLimit: params.groupHistoryLimit
|
|
1231
|
+
});
|
|
1232
|
+
return { shouldProcess: false };
|
|
1233
|
+
}
|
|
1234
|
+
const mentionDebug = debugMention(params.msg, mentionConfig, params.authDir);
|
|
1235
|
+
params.replyLogger.debug({
|
|
1236
|
+
conversationId: params.conversationId,
|
|
1237
|
+
wasMentioned: mentionDebug.wasMentioned,
|
|
1238
|
+
...mentionDebug.details
|
|
1239
|
+
}, "group mention debug");
|
|
1240
|
+
const wasMentioned = mentionDebug.wasMentioned;
|
|
1241
|
+
const requireMention = resolveGroupActivationFor({
|
|
1242
|
+
cfg: params.cfg,
|
|
1243
|
+
agentId: params.agentId,
|
|
1244
|
+
sessionKey: params.sessionKey,
|
|
1245
|
+
conversationId: params.conversationId
|
|
1246
|
+
}) !== "always";
|
|
1247
|
+
const selfJid = params.msg.selfJid?.replace(/:\\d+/, "");
|
|
1248
|
+
const replySenderJid = params.msg.replyToSenderJid?.replace(/:\\d+/, "");
|
|
1249
|
+
const selfE164 = params.msg.selfE164 ? normalizeE164(params.msg.selfE164) : null;
|
|
1250
|
+
const replySenderE164 = params.msg.replyToSenderE164 ? normalizeE164(params.msg.replyToSenderE164) : null;
|
|
1251
|
+
const mentionGate = resolveMentionGating({
|
|
1252
|
+
requireMention,
|
|
1253
|
+
canDetectMention: true,
|
|
1254
|
+
wasMentioned,
|
|
1255
|
+
implicitMention: Boolean(selfJid && replySenderJid && selfJid === replySenderJid || selfE164 && replySenderE164 && selfE164 === replySenderE164),
|
|
1256
|
+
shouldBypassMention
|
|
1257
|
+
});
|
|
1258
|
+
params.msg.wasMentioned = mentionGate.effectiveWasMentioned;
|
|
1259
|
+
if (!shouldBypassMention && requireMention && mentionGate.shouldSkip) {
|
|
1260
|
+
params.logVerbose(`Group message stored for context (no mention detected) in ${params.conversationId}: ${params.msg.body}`);
|
|
1261
|
+
recordPendingGroupHistoryEntry({
|
|
1262
|
+
msg: params.msg,
|
|
1263
|
+
groupHistories: params.groupHistories,
|
|
1264
|
+
groupHistoryKey: params.groupHistoryKey,
|
|
1265
|
+
groupHistoryLimit: params.groupHistoryLimit
|
|
1266
|
+
});
|
|
1267
|
+
return { shouldProcess: false };
|
|
1268
|
+
}
|
|
1269
|
+
return { shouldProcess: true };
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
//#endregion
|
|
1273
|
+
//#region src/web/auto-reply/monitor/last-route.ts
|
|
1274
|
+
function trackBackgroundTask(backgroundTasks, task) {
|
|
1275
|
+
backgroundTasks.add(task);
|
|
1276
|
+
task.finally(() => {
|
|
1277
|
+
backgroundTasks.delete(task);
|
|
1278
|
+
});
|
|
1279
|
+
}
|
|
1280
|
+
function updateLastRouteInBackground(params) {
|
|
1281
|
+
const storePath = resolveStorePath(params.cfg.session?.store, { agentId: params.storeAgentId });
|
|
1282
|
+
const task = updateLastRoute({
|
|
1283
|
+
storePath,
|
|
1284
|
+
sessionKey: params.sessionKey,
|
|
1285
|
+
deliveryContext: {
|
|
1286
|
+
channel: params.channel,
|
|
1287
|
+
to: params.to,
|
|
1288
|
+
accountId: params.accountId
|
|
1289
|
+
},
|
|
1290
|
+
ctx: params.ctx
|
|
1291
|
+
}).catch((err) => {
|
|
1292
|
+
params.warn({
|
|
1293
|
+
error: formatError(err),
|
|
1294
|
+
storePath,
|
|
1295
|
+
sessionKey: params.sessionKey,
|
|
1296
|
+
to: params.to
|
|
1297
|
+
}, "failed updating last route");
|
|
1298
|
+
});
|
|
1299
|
+
trackBackgroundTask(params.backgroundTasks, task);
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
//#endregion
|
|
1303
|
+
//#region src/web/auto-reply/monitor/peer.ts
|
|
1304
|
+
function resolvePeerId(msg) {
|
|
1305
|
+
if (msg.chatType === "group") return msg.conversationId ?? msg.from;
|
|
1306
|
+
if (msg.senderE164) return normalizeE164(msg.senderE164) ?? msg.senderE164;
|
|
1307
|
+
if (msg.from.includes("@")) return jidToE164(msg.from) ?? msg.from;
|
|
1308
|
+
return normalizeE164(msg.from) ?? msg.from;
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
//#endregion
|
|
1312
|
+
//#region src/web/auto-reply/deliver-reply.ts
|
|
1313
|
+
async function deliverWebReply(params) {
|
|
1314
|
+
const { replyResult, msg, maxMediaBytes, textLimit, replyLogger, connectionId, skipLog } = params;
|
|
1315
|
+
const replyStarted = Date.now();
|
|
1316
|
+
const tableMode = params.tableMode ?? "code";
|
|
1317
|
+
const chunkMode = params.chunkMode ?? "length";
|
|
1318
|
+
const textChunks = chunkMarkdownTextWithMode(markdownToWhatsApp(convertMarkdownTables(replyResult.text || "", tableMode)), textLimit, chunkMode);
|
|
1319
|
+
const mediaList = replyResult.mediaUrls?.length ? replyResult.mediaUrls : replyResult.mediaUrl ? [replyResult.mediaUrl] : [];
|
|
1320
|
+
const sendWithRetry = async (fn, label, maxAttempts = 3) => {
|
|
1321
|
+
let lastErr;
|
|
1322
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) try {
|
|
1323
|
+
return await fn();
|
|
1324
|
+
} catch (err) {
|
|
1325
|
+
lastErr = err;
|
|
1326
|
+
const errText = formatError(err);
|
|
1327
|
+
const isLast = attempt === maxAttempts;
|
|
1328
|
+
if (!/closed|reset|timed\\s*out|disconnect/i.test(errText) || isLast) throw err;
|
|
1329
|
+
const backoffMs = 500 * attempt;
|
|
1330
|
+
logVerbose(`Retrying ${label} to ${msg.from} after failure (${attempt}/${maxAttempts - 1}) in ${backoffMs}ms: ${errText}`);
|
|
1331
|
+
await sleep(backoffMs);
|
|
1332
|
+
}
|
|
1333
|
+
throw lastErr;
|
|
1334
|
+
};
|
|
1335
|
+
if (mediaList.length === 0 && textChunks.length) {
|
|
1336
|
+
const totalChunks = textChunks.length;
|
|
1337
|
+
for (const [index, chunk] of textChunks.entries()) {
|
|
1338
|
+
const chunkStarted = Date.now();
|
|
1339
|
+
await sendWithRetry(() => msg.reply(chunk), "text");
|
|
1340
|
+
if (!skipLog) {
|
|
1341
|
+
const durationMs = Date.now() - chunkStarted;
|
|
1342
|
+
whatsappOutboundLog.debug(`Sent chunk ${index + 1}/${totalChunks} to ${msg.from} (${durationMs.toFixed(0)}ms)`);
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
replyLogger.info({
|
|
1346
|
+
correlationId: msg.id ?? newConnectionId(),
|
|
1347
|
+
connectionId: connectionId ?? null,
|
|
1348
|
+
to: msg.from,
|
|
1349
|
+
from: msg.to,
|
|
1350
|
+
text: elide(replyResult.text, 240),
|
|
1351
|
+
mediaUrl: null,
|
|
1352
|
+
mediaSizeBytes: null,
|
|
1353
|
+
mediaKind: null,
|
|
1354
|
+
durationMs: Date.now() - replyStarted
|
|
1355
|
+
}, "auto-reply sent (text)");
|
|
1356
|
+
return;
|
|
1357
|
+
}
|
|
1358
|
+
const remainingText = [...textChunks];
|
|
1359
|
+
for (const [index, mediaUrl] of mediaList.entries()) {
|
|
1360
|
+
const caption = index === 0 ? remainingText.shift() || void 0 : void 0;
|
|
1361
|
+
try {
|
|
1362
|
+
const media = await loadWebMedia(mediaUrl, maxMediaBytes);
|
|
1363
|
+
if (shouldLogVerbose()) {
|
|
1364
|
+
logVerbose(`Web auto-reply media size: ${(media.buffer.length / (1024 * 1024)).toFixed(2)}MB`);
|
|
1365
|
+
logVerbose(`Web auto-reply media source: ${mediaUrl} (kind ${media.kind})`);
|
|
1366
|
+
}
|
|
1367
|
+
if (media.kind === "image") await sendWithRetry(() => msg.sendMedia({
|
|
1368
|
+
image: media.buffer,
|
|
1369
|
+
caption,
|
|
1370
|
+
mimetype: media.contentType
|
|
1371
|
+
}), "media:image");
|
|
1372
|
+
else if (media.kind === "audio") await sendWithRetry(() => msg.sendMedia({
|
|
1373
|
+
audio: media.buffer,
|
|
1374
|
+
ptt: true,
|
|
1375
|
+
mimetype: media.contentType,
|
|
1376
|
+
caption
|
|
1377
|
+
}), "media:audio");
|
|
1378
|
+
else if (media.kind === "video") await sendWithRetry(() => msg.sendMedia({
|
|
1379
|
+
video: media.buffer,
|
|
1380
|
+
caption,
|
|
1381
|
+
mimetype: media.contentType
|
|
1382
|
+
}), "media:video");
|
|
1383
|
+
else {
|
|
1384
|
+
const fileName = media.fileName ?? mediaUrl.split("/").pop() ?? "file";
|
|
1385
|
+
const mimetype = media.contentType ?? "application/octet-stream";
|
|
1386
|
+
await sendWithRetry(() => msg.sendMedia({
|
|
1387
|
+
document: media.buffer,
|
|
1388
|
+
fileName,
|
|
1389
|
+
caption,
|
|
1390
|
+
mimetype
|
|
1391
|
+
}), "media:document");
|
|
1392
|
+
}
|
|
1393
|
+
whatsappOutboundLog.info(`Sent media reply to ${msg.from} (${(media.buffer.length / (1024 * 1024)).toFixed(2)}MB)`);
|
|
1394
|
+
replyLogger.info({
|
|
1395
|
+
correlationId: msg.id ?? newConnectionId(),
|
|
1396
|
+
connectionId: connectionId ?? null,
|
|
1397
|
+
to: msg.from,
|
|
1398
|
+
from: msg.to,
|
|
1399
|
+
text: caption ?? null,
|
|
1400
|
+
mediaUrl,
|
|
1401
|
+
mediaSizeBytes: media.buffer.length,
|
|
1402
|
+
mediaKind: media.kind,
|
|
1403
|
+
durationMs: Date.now() - replyStarted
|
|
1404
|
+
}, "auto-reply sent (media)");
|
|
1405
|
+
} catch (err) {
|
|
1406
|
+
whatsappOutboundLog.error(`Failed sending web media to ${msg.from}: ${formatError(err)}`);
|
|
1407
|
+
replyLogger.warn({
|
|
1408
|
+
err,
|
|
1409
|
+
mediaUrl
|
|
1410
|
+
}, "failed to send web media reply");
|
|
1411
|
+
if (index === 0) {
|
|
1412
|
+
const warning = err instanceof Error ? `⚠️ Media failed: ${err.message}` : "⚠️ Media failed.";
|
|
1413
|
+
const fallbackText = [remainingText.shift() ?? caption ?? "", warning].filter(Boolean).join("\n");
|
|
1414
|
+
if (fallbackText) {
|
|
1415
|
+
whatsappOutboundLog.warn(`Media skipped; sent text-only to ${msg.from}`);
|
|
1416
|
+
await msg.reply(fallbackText);
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
for (const chunk of remainingText) await msg.reply(chunk);
|
|
1422
|
+
}
|
|
1423
|
+
|
|
1424
|
+
//#endregion
|
|
1425
|
+
//#region src/web/auto-reply/monitor/ack-reaction.ts
|
|
1426
|
+
function maybeSendAckReaction(params) {
|
|
1427
|
+
if (!params.msg.id) return;
|
|
1428
|
+
const ackConfig = params.cfg.channels?.whatsapp?.ackReaction;
|
|
1429
|
+
const emoji = (ackConfig?.emoji ?? "").trim();
|
|
1430
|
+
const directEnabled = ackConfig?.direct ?? true;
|
|
1431
|
+
const groupMode = ackConfig?.group ?? "mentions";
|
|
1432
|
+
const conversationIdForCheck = params.msg.conversationId ?? params.msg.from;
|
|
1433
|
+
const activation = params.msg.chatType === "group" ? resolveGroupActivationFor({
|
|
1434
|
+
cfg: params.cfg,
|
|
1435
|
+
agentId: params.agentId,
|
|
1436
|
+
sessionKey: params.sessionKey,
|
|
1437
|
+
conversationId: conversationIdForCheck
|
|
1438
|
+
}) : null;
|
|
1439
|
+
const shouldSendReaction = () => shouldAckReactionForWhatsApp({
|
|
1440
|
+
emoji,
|
|
1441
|
+
isDirect: params.msg.chatType === "direct",
|
|
1442
|
+
isGroup: params.msg.chatType === "group",
|
|
1443
|
+
directEnabled,
|
|
1444
|
+
groupMode,
|
|
1445
|
+
wasMentioned: params.msg.wasMentioned === true,
|
|
1446
|
+
groupActivated: activation === "always"
|
|
1447
|
+
});
|
|
1448
|
+
if (!shouldSendReaction()) return;
|
|
1449
|
+
params.info({
|
|
1450
|
+
chatId: params.msg.chatId,
|
|
1451
|
+
messageId: params.msg.id,
|
|
1452
|
+
emoji
|
|
1453
|
+
}, "sending ack reaction");
|
|
1454
|
+
sendReactionWhatsApp(params.msg.chatId, params.msg.id, emoji, {
|
|
1455
|
+
verbose: params.verbose,
|
|
1456
|
+
fromMe: false,
|
|
1457
|
+
participant: params.msg.senderJid,
|
|
1458
|
+
accountId: params.accountId
|
|
1459
|
+
}).catch((err) => {
|
|
1460
|
+
params.warn({
|
|
1461
|
+
error: formatError(err),
|
|
1462
|
+
chatId: params.msg.chatId,
|
|
1463
|
+
messageId: params.msg.id
|
|
1464
|
+
}, "failed to send ack reaction");
|
|
1465
|
+
logVerbose(`WhatsApp ack reaction failed for chat ${params.msg.chatId}: ${formatError(err)}`);
|
|
1466
|
+
});
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1469
|
+
//#endregion
|
|
1470
|
+
//#region src/web/auto-reply/monitor/message-line.ts
|
|
1471
|
+
function formatReplyContext(msg) {
|
|
1472
|
+
if (!msg.replyToBody) return null;
|
|
1473
|
+
return `[Replying to ${msg.replyToSender ?? "unknown sender"}${msg.replyToId ? ` id:${msg.replyToId}` : ""}]\n${msg.replyToBody}\n[/Replying]`;
|
|
1474
|
+
}
|
|
1475
|
+
function buildInboundLine(params) {
|
|
1476
|
+
const { cfg, msg, agentId, previousTimestamp, envelope } = params;
|
|
1477
|
+
const messagePrefix = resolveMessagePrefix(cfg, agentId, {
|
|
1478
|
+
configured: cfg.channels?.whatsapp?.messagePrefix,
|
|
1479
|
+
hasAllowFrom: (cfg.channels?.whatsapp?.allowFrom?.length ?? 0) > 0
|
|
1480
|
+
});
|
|
1481
|
+
const prefixStr = messagePrefix ? `${messagePrefix} ` : "";
|
|
1482
|
+
const replyContext = formatReplyContext(msg);
|
|
1483
|
+
const baseLine = `${prefixStr}${msg.body}${replyContext ? `\n\n${replyContext}` : ""}`;
|
|
1484
|
+
return formatInboundEnvelope({
|
|
1485
|
+
channel: "WhatsApp",
|
|
1486
|
+
from: msg.chatType === "group" ? msg.from : msg.from?.replace(/^whatsapp:/, ""),
|
|
1487
|
+
timestamp: msg.timestamp,
|
|
1488
|
+
body: baseLine,
|
|
1489
|
+
chatType: msg.chatType,
|
|
1490
|
+
sender: {
|
|
1491
|
+
name: msg.senderName,
|
|
1492
|
+
e164: msg.senderE164,
|
|
1493
|
+
id: msg.senderJid
|
|
1494
|
+
},
|
|
1495
|
+
previousTimestamp,
|
|
1496
|
+
envelope
|
|
1497
|
+
});
|
|
1498
|
+
}
|
|
1499
|
+
|
|
1500
|
+
//#endregion
|
|
1501
|
+
//#region src/web/auto-reply/monitor/process-message.ts
|
|
1502
|
+
function normalizeAllowFromE164(values) {
|
|
1503
|
+
return (Array.isArray(values) ? values : []).map((entry) => String(entry).trim()).filter((entry) => entry && entry !== "*").map((entry) => normalizeE164(entry)).filter((entry) => Boolean(entry));
|
|
1504
|
+
}
|
|
1505
|
+
async function resolveWhatsAppCommandAuthorized(params) {
|
|
1506
|
+
if (!(params.cfg.commands?.useAccessGroups !== false)) return true;
|
|
1507
|
+
const isGroup = params.msg.chatType === "group";
|
|
1508
|
+
const senderE164 = normalizeE164(isGroup ? params.msg.senderE164 ?? "" : params.msg.senderE164 ?? params.msg.from ?? "");
|
|
1509
|
+
if (!senderE164) return false;
|
|
1510
|
+
const configuredAllowFrom = params.cfg.channels?.whatsapp?.allowFrom ?? [];
|
|
1511
|
+
const configuredGroupAllowFrom = params.cfg.channels?.whatsapp?.groupAllowFrom ?? (configuredAllowFrom.length > 0 ? configuredAllowFrom : void 0);
|
|
1512
|
+
if (isGroup) {
|
|
1513
|
+
if (!configuredGroupAllowFrom || configuredGroupAllowFrom.length === 0) return false;
|
|
1514
|
+
if (configuredGroupAllowFrom.some((v) => String(v).trim() === "*")) return true;
|
|
1515
|
+
return normalizeAllowFromE164(configuredGroupAllowFrom).includes(senderE164);
|
|
1516
|
+
}
|
|
1517
|
+
const storeAllowFrom = await readChannelAllowFromStore("whatsapp").catch(() => []);
|
|
1518
|
+
const combinedAllowFrom = Array.from(new Set([...configuredAllowFrom ?? [], ...storeAllowFrom]));
|
|
1519
|
+
const allowFrom = combinedAllowFrom.length > 0 ? combinedAllowFrom : params.msg.selfE164 ? [params.msg.selfE164] : [];
|
|
1520
|
+
if (allowFrom.some((v) => String(v).trim() === "*")) return true;
|
|
1521
|
+
return normalizeAllowFromE164(allowFrom).includes(senderE164);
|
|
1522
|
+
}
|
|
1523
|
+
async function processMessage(params) {
|
|
1524
|
+
const conversationId = params.msg.conversationId ?? params.msg.from;
|
|
1525
|
+
const storePath = resolveStorePath(params.cfg.session?.store, { agentId: params.route.agentId });
|
|
1526
|
+
const envelopeOptions = resolveEnvelopeFormatOptions(params.cfg);
|
|
1527
|
+
const previousTimestamp = readSessionUpdatedAt({
|
|
1528
|
+
storePath,
|
|
1529
|
+
sessionKey: params.route.sessionKey
|
|
1530
|
+
});
|
|
1531
|
+
let combinedBody = buildInboundLine({
|
|
1532
|
+
cfg: params.cfg,
|
|
1533
|
+
msg: params.msg,
|
|
1534
|
+
agentId: params.route.agentId,
|
|
1535
|
+
previousTimestamp,
|
|
1536
|
+
envelope: envelopeOptions
|
|
1537
|
+
});
|
|
1538
|
+
let shouldClearGroupHistory = false;
|
|
1539
|
+
if (params.msg.chatType === "group") {
|
|
1540
|
+
const history = params.groupHistory ?? params.groupHistories.get(params.groupHistoryKey) ?? [];
|
|
1541
|
+
if (history.length > 0) combinedBody = buildHistoryContextFromEntries({
|
|
1542
|
+
entries: history.map((m) => ({
|
|
1543
|
+
sender: m.sender,
|
|
1544
|
+
body: m.body,
|
|
1545
|
+
timestamp: m.timestamp
|
|
1546
|
+
})),
|
|
1547
|
+
currentMessage: combinedBody,
|
|
1548
|
+
excludeLast: false,
|
|
1549
|
+
formatEntry: (entry) => {
|
|
1550
|
+
return formatInboundEnvelope({
|
|
1551
|
+
channel: "WhatsApp",
|
|
1552
|
+
from: conversationId,
|
|
1553
|
+
timestamp: entry.timestamp,
|
|
1554
|
+
body: entry.body,
|
|
1555
|
+
chatType: "group",
|
|
1556
|
+
senderLabel: entry.sender,
|
|
1557
|
+
envelope: envelopeOptions
|
|
1558
|
+
});
|
|
1559
|
+
}
|
|
1560
|
+
});
|
|
1561
|
+
shouldClearGroupHistory = !(params.suppressGroupHistoryClear ?? false);
|
|
1562
|
+
}
|
|
1563
|
+
const combinedEchoKey = params.buildCombinedEchoKey({
|
|
1564
|
+
sessionKey: params.route.sessionKey,
|
|
1565
|
+
combinedBody
|
|
1566
|
+
});
|
|
1567
|
+
if (params.echoHas(combinedEchoKey)) {
|
|
1568
|
+
logVerbose("Skipping auto-reply: detected echo for combined message");
|
|
1569
|
+
params.echoForget(combinedEchoKey);
|
|
1570
|
+
return false;
|
|
1571
|
+
}
|
|
1572
|
+
maybeSendAckReaction({
|
|
1573
|
+
cfg: params.cfg,
|
|
1574
|
+
msg: params.msg,
|
|
1575
|
+
agentId: params.route.agentId,
|
|
1576
|
+
sessionKey: params.route.sessionKey,
|
|
1577
|
+
conversationId,
|
|
1578
|
+
verbose: params.verbose,
|
|
1579
|
+
accountId: params.route.accountId,
|
|
1580
|
+
info: params.replyLogger.info.bind(params.replyLogger),
|
|
1581
|
+
warn: params.replyLogger.warn.bind(params.replyLogger)
|
|
1582
|
+
});
|
|
1583
|
+
const correlationId = params.msg.id ?? newConnectionId();
|
|
1584
|
+
params.replyLogger.info({
|
|
1585
|
+
connectionId: params.connectionId,
|
|
1586
|
+
correlationId,
|
|
1587
|
+
from: params.msg.chatType === "group" ? conversationId : params.msg.from,
|
|
1588
|
+
to: params.msg.to,
|
|
1589
|
+
body: elide(combinedBody, 240),
|
|
1590
|
+
mediaType: params.msg.mediaType ?? null,
|
|
1591
|
+
mediaPath: params.msg.mediaPath ?? null
|
|
1592
|
+
}, "inbound web message");
|
|
1593
|
+
const fromDisplay = params.msg.chatType === "group" ? conversationId : params.msg.from;
|
|
1594
|
+
const kindLabel = params.msg.mediaType ? `, ${params.msg.mediaType}` : "";
|
|
1595
|
+
whatsappInboundLog.info(`Inbound message ${fromDisplay} -> ${params.msg.to} (${params.msg.chatType}${kindLabel}, ${combinedBody.length} chars)`);
|
|
1596
|
+
if (shouldLogVerbose()) whatsappInboundLog.debug(`Inbound body: ${elide(combinedBody, 400)}`);
|
|
1597
|
+
const dmRouteTarget = params.msg.chatType !== "group" ? (() => {
|
|
1598
|
+
if (params.msg.senderE164) return normalizeE164(params.msg.senderE164);
|
|
1599
|
+
if (params.msg.from.includes("@")) return jidToE164(params.msg.from);
|
|
1600
|
+
return normalizeE164(params.msg.from);
|
|
1601
|
+
})() : void 0;
|
|
1602
|
+
const textLimit = params.maxMediaTextChunkLimit ?? resolveTextChunkLimit(params.cfg, "whatsapp");
|
|
1603
|
+
const chunkMode = resolveChunkMode(params.cfg, "whatsapp", params.route.accountId);
|
|
1604
|
+
const tableMode = resolveMarkdownTableMode({
|
|
1605
|
+
cfg: params.cfg,
|
|
1606
|
+
channel: "whatsapp",
|
|
1607
|
+
accountId: params.route.accountId
|
|
1608
|
+
});
|
|
1609
|
+
let didLogHeartbeatStrip = false;
|
|
1610
|
+
let didSendReply = false;
|
|
1611
|
+
const commandAuthorized = shouldComputeCommandAuthorized(params.msg.body, params.cfg) ? await resolveWhatsAppCommandAuthorized({
|
|
1612
|
+
cfg: params.cfg,
|
|
1613
|
+
msg: params.msg
|
|
1614
|
+
}) : void 0;
|
|
1615
|
+
const configuredResponsePrefix = params.cfg.messages?.responsePrefix;
|
|
1616
|
+
const { onModelSelected, ...prefixOptions } = createReplyPrefixOptions({
|
|
1617
|
+
cfg: params.cfg,
|
|
1618
|
+
agentId: params.route.agentId,
|
|
1619
|
+
channel: "whatsapp",
|
|
1620
|
+
accountId: params.route.accountId
|
|
1621
|
+
});
|
|
1622
|
+
const isSelfChat = params.msg.chatType !== "group" && Boolean(params.msg.selfE164) && normalizeE164(params.msg.from) === normalizeE164(params.msg.selfE164 ?? "");
|
|
1623
|
+
const responsePrefix = prefixOptions.responsePrefix ?? (configuredResponsePrefix === void 0 && isSelfChat ? resolveIdentityNamePrefix(params.cfg, params.route.agentId) ?? "[anima]" : void 0);
|
|
1624
|
+
const inboundHistory = params.msg.chatType === "group" ? (params.groupHistory ?? params.groupHistories.get(params.groupHistoryKey) ?? []).map((entry) => ({
|
|
1625
|
+
sender: entry.sender,
|
|
1626
|
+
body: entry.body,
|
|
1627
|
+
timestamp: entry.timestamp
|
|
1628
|
+
})) : void 0;
|
|
1629
|
+
const ctxPayload = finalizeInboundContext({
|
|
1630
|
+
Body: combinedBody,
|
|
1631
|
+
BodyForAgent: params.msg.body,
|
|
1632
|
+
InboundHistory: inboundHistory,
|
|
1633
|
+
RawBody: params.msg.body,
|
|
1634
|
+
CommandBody: params.msg.body,
|
|
1635
|
+
From: params.msg.from,
|
|
1636
|
+
To: params.msg.to,
|
|
1637
|
+
SessionKey: params.route.sessionKey,
|
|
1638
|
+
AccountId: params.route.accountId,
|
|
1639
|
+
MessageSid: params.msg.id,
|
|
1640
|
+
ReplyToId: params.msg.replyToId,
|
|
1641
|
+
ReplyToBody: params.msg.replyToBody,
|
|
1642
|
+
ReplyToSender: params.msg.replyToSender,
|
|
1643
|
+
MediaPath: params.msg.mediaPath,
|
|
1644
|
+
MediaUrl: params.msg.mediaUrl,
|
|
1645
|
+
MediaType: params.msg.mediaType,
|
|
1646
|
+
ChatType: params.msg.chatType,
|
|
1647
|
+
ConversationLabel: params.msg.chatType === "group" ? conversationId : params.msg.from,
|
|
1648
|
+
GroupSubject: params.msg.groupSubject,
|
|
1649
|
+
GroupMembers: formatGroupMembers({
|
|
1650
|
+
participants: params.msg.groupParticipants,
|
|
1651
|
+
roster: params.groupMemberNames.get(params.groupHistoryKey),
|
|
1652
|
+
fallbackE164: params.msg.senderE164
|
|
1653
|
+
}),
|
|
1654
|
+
SenderName: params.msg.senderName,
|
|
1655
|
+
SenderId: params.msg.senderJid?.trim() || params.msg.senderE164,
|
|
1656
|
+
SenderE164: params.msg.senderE164,
|
|
1657
|
+
CommandAuthorized: commandAuthorized,
|
|
1658
|
+
WasMentioned: params.msg.wasMentioned,
|
|
1659
|
+
...params.msg.location ? toLocationContext(params.msg.location) : {},
|
|
1660
|
+
Provider: "whatsapp",
|
|
1661
|
+
Surface: "whatsapp",
|
|
1662
|
+
OriginatingChannel: "whatsapp",
|
|
1663
|
+
OriginatingTo: params.msg.from
|
|
1664
|
+
});
|
|
1665
|
+
if (dmRouteTarget) updateLastRouteInBackground({
|
|
1666
|
+
cfg: params.cfg,
|
|
1667
|
+
backgroundTasks: params.backgroundTasks,
|
|
1668
|
+
storeAgentId: params.route.agentId,
|
|
1669
|
+
sessionKey: params.route.mainSessionKey,
|
|
1670
|
+
channel: "whatsapp",
|
|
1671
|
+
to: dmRouteTarget,
|
|
1672
|
+
accountId: params.route.accountId,
|
|
1673
|
+
ctx: ctxPayload,
|
|
1674
|
+
warn: params.replyLogger.warn.bind(params.replyLogger)
|
|
1675
|
+
});
|
|
1676
|
+
const metaTask = recordSessionMetaFromInbound({
|
|
1677
|
+
storePath,
|
|
1678
|
+
sessionKey: params.route.sessionKey,
|
|
1679
|
+
ctx: ctxPayload
|
|
1680
|
+
}).catch((err) => {
|
|
1681
|
+
params.replyLogger.warn({
|
|
1682
|
+
error: formatError(err),
|
|
1683
|
+
storePath,
|
|
1684
|
+
sessionKey: params.route.sessionKey
|
|
1685
|
+
}, "failed updating session meta");
|
|
1686
|
+
});
|
|
1687
|
+
trackBackgroundTask(params.backgroundTasks, metaTask);
|
|
1688
|
+
const { queuedFinal } = await dispatchReplyWithBufferedBlockDispatcher({
|
|
1689
|
+
ctx: ctxPayload,
|
|
1690
|
+
cfg: params.cfg,
|
|
1691
|
+
replyResolver: params.replyResolver,
|
|
1692
|
+
dispatcherOptions: {
|
|
1693
|
+
...prefixOptions,
|
|
1694
|
+
responsePrefix,
|
|
1695
|
+
onHeartbeatStrip: () => {
|
|
1696
|
+
if (!didLogHeartbeatStrip) {
|
|
1697
|
+
didLogHeartbeatStrip = true;
|
|
1698
|
+
logVerbose("Stripped stray HEARTBEAT_OK token from web reply");
|
|
1699
|
+
}
|
|
1700
|
+
},
|
|
1701
|
+
deliver: async (payload, info) => {
|
|
1702
|
+
await deliverWebReply({
|
|
1703
|
+
replyResult: payload,
|
|
1704
|
+
msg: params.msg,
|
|
1705
|
+
maxMediaBytes: params.maxMediaBytes,
|
|
1706
|
+
textLimit,
|
|
1707
|
+
chunkMode,
|
|
1708
|
+
replyLogger: params.replyLogger,
|
|
1709
|
+
connectionId: params.connectionId,
|
|
1710
|
+
skipLog: info.kind !== "final",
|
|
1711
|
+
tableMode
|
|
1712
|
+
});
|
|
1713
|
+
didSendReply = true;
|
|
1714
|
+
if (info.kind === "tool") {
|
|
1715
|
+
params.rememberSentText(payload.text, {});
|
|
1716
|
+
return;
|
|
1717
|
+
}
|
|
1718
|
+
const shouldLog = info.kind === "final" && payload.text ? true : void 0;
|
|
1719
|
+
params.rememberSentText(payload.text, {
|
|
1720
|
+
combinedBody,
|
|
1721
|
+
combinedBodySessionKey: params.route.sessionKey,
|
|
1722
|
+
logVerboseMessage: shouldLog
|
|
1723
|
+
});
|
|
1724
|
+
if (info.kind === "final") {
|
|
1725
|
+
const fromDisplay = params.msg.chatType === "group" ? conversationId : params.msg.from ?? "unknown";
|
|
1726
|
+
const hasMedia = Boolean(payload.mediaUrl || payload.mediaUrls?.length);
|
|
1727
|
+
whatsappOutboundLog.info(`Auto-replied to ${fromDisplay}${hasMedia ? " (media)" : ""}`);
|
|
1728
|
+
if (shouldLogVerbose()) {
|
|
1729
|
+
const preview = payload.text != null ? elide(payload.text, 400) : "<media>";
|
|
1730
|
+
whatsappOutboundLog.debug(`Reply body: ${preview}${hasMedia ? " (media)" : ""}`);
|
|
1731
|
+
}
|
|
1732
|
+
}
|
|
1733
|
+
},
|
|
1734
|
+
onError: (err, info) => {
|
|
1735
|
+
const label = info.kind === "tool" ? "tool update" : info.kind === "block" ? "block update" : "auto-reply";
|
|
1736
|
+
whatsappOutboundLog.error(`Failed sending web ${label} to ${params.msg.from ?? conversationId}: ${formatError(err)}`);
|
|
1737
|
+
},
|
|
1738
|
+
onReplyStart: params.msg.sendComposing
|
|
1739
|
+
},
|
|
1740
|
+
replyOptions: {
|
|
1741
|
+
disableBlockStreaming: typeof params.cfg.channels?.whatsapp?.blockStreaming === "boolean" ? !params.cfg.channels.whatsapp.blockStreaming : void 0,
|
|
1742
|
+
onModelSelected
|
|
1743
|
+
}
|
|
1744
|
+
});
|
|
1745
|
+
if (!queuedFinal) {
|
|
1746
|
+
if (shouldClearGroupHistory) params.groupHistories.set(params.groupHistoryKey, []);
|
|
1747
|
+
logVerbose("Skipping auto-reply: silent token or no text/media returned from resolver");
|
|
1748
|
+
return false;
|
|
1749
|
+
}
|
|
1750
|
+
if (shouldClearGroupHistory) params.groupHistories.set(params.groupHistoryKey, []);
|
|
1751
|
+
return didSendReply;
|
|
1752
|
+
}
|
|
1753
|
+
|
|
1754
|
+
//#endregion
|
|
1755
|
+
//#region src/web/auto-reply/monitor/on-message.ts
|
|
1756
|
+
function createWebOnMessageHandler(params) {
|
|
1757
|
+
const processForRoute = async (msg, route, groupHistoryKey, opts) => processMessage({
|
|
1758
|
+
cfg: params.cfg,
|
|
1759
|
+
msg,
|
|
1760
|
+
route,
|
|
1761
|
+
groupHistoryKey,
|
|
1762
|
+
groupHistories: params.groupHistories,
|
|
1763
|
+
groupMemberNames: params.groupMemberNames,
|
|
1764
|
+
connectionId: params.connectionId,
|
|
1765
|
+
verbose: params.verbose,
|
|
1766
|
+
maxMediaBytes: params.maxMediaBytes,
|
|
1767
|
+
replyResolver: params.replyResolver,
|
|
1768
|
+
replyLogger: params.replyLogger,
|
|
1769
|
+
backgroundTasks: params.backgroundTasks,
|
|
1770
|
+
rememberSentText: params.echoTracker.rememberText,
|
|
1771
|
+
echoHas: params.echoTracker.has,
|
|
1772
|
+
echoForget: params.echoTracker.forget,
|
|
1773
|
+
buildCombinedEchoKey: params.echoTracker.buildCombinedKey,
|
|
1774
|
+
groupHistory: opts?.groupHistory,
|
|
1775
|
+
suppressGroupHistoryClear: opts?.suppressGroupHistoryClear
|
|
1776
|
+
});
|
|
1777
|
+
return async (msg) => {
|
|
1778
|
+
const conversationId = msg.conversationId ?? msg.from;
|
|
1779
|
+
const peerId = resolvePeerId(msg);
|
|
1780
|
+
const route = resolveAgentRoute({
|
|
1781
|
+
cfg: loadConfig(),
|
|
1782
|
+
channel: "whatsapp",
|
|
1783
|
+
accountId: msg.accountId,
|
|
1784
|
+
peer: {
|
|
1785
|
+
kind: msg.chatType === "group" ? "group" : "direct",
|
|
1786
|
+
id: peerId
|
|
1787
|
+
}
|
|
1788
|
+
});
|
|
1789
|
+
const groupHistoryKey = msg.chatType === "group" ? buildGroupHistoryKey({
|
|
1790
|
+
channel: "whatsapp",
|
|
1791
|
+
accountId: route.accountId,
|
|
1792
|
+
peerKind: "group",
|
|
1793
|
+
peerId
|
|
1794
|
+
}) : route.sessionKey;
|
|
1795
|
+
if (msg.from === msg.to) logVerbose(`📱 Same-phone mode detected (from === to: ${msg.from})`);
|
|
1796
|
+
if (params.echoTracker.has(msg.body)) {
|
|
1797
|
+
logVerbose("Skipping auto-reply: detected echo (message matches recently sent text)");
|
|
1798
|
+
params.echoTracker.forget(msg.body);
|
|
1799
|
+
return;
|
|
1800
|
+
}
|
|
1801
|
+
if (msg.chatType === "group") {
|
|
1802
|
+
const metaCtx = {
|
|
1803
|
+
From: msg.from,
|
|
1804
|
+
To: msg.to,
|
|
1805
|
+
SessionKey: route.sessionKey,
|
|
1806
|
+
AccountId: route.accountId,
|
|
1807
|
+
ChatType: msg.chatType,
|
|
1808
|
+
ConversationLabel: conversationId,
|
|
1809
|
+
GroupSubject: msg.groupSubject,
|
|
1810
|
+
SenderName: msg.senderName,
|
|
1811
|
+
SenderId: msg.senderJid?.trim() || msg.senderE164,
|
|
1812
|
+
SenderE164: msg.senderE164,
|
|
1813
|
+
Provider: "whatsapp",
|
|
1814
|
+
Surface: "whatsapp",
|
|
1815
|
+
OriginatingChannel: "whatsapp",
|
|
1816
|
+
OriginatingTo: conversationId
|
|
1817
|
+
};
|
|
1818
|
+
updateLastRouteInBackground({
|
|
1819
|
+
cfg: params.cfg,
|
|
1820
|
+
backgroundTasks: params.backgroundTasks,
|
|
1821
|
+
storeAgentId: route.agentId,
|
|
1822
|
+
sessionKey: route.sessionKey,
|
|
1823
|
+
channel: "whatsapp",
|
|
1824
|
+
to: conversationId,
|
|
1825
|
+
accountId: route.accountId,
|
|
1826
|
+
ctx: metaCtx,
|
|
1827
|
+
warn: params.replyLogger.warn.bind(params.replyLogger)
|
|
1828
|
+
});
|
|
1829
|
+
if (!applyGroupGating({
|
|
1830
|
+
cfg: params.cfg,
|
|
1831
|
+
msg,
|
|
1832
|
+
conversationId,
|
|
1833
|
+
groupHistoryKey,
|
|
1834
|
+
agentId: route.agentId,
|
|
1835
|
+
sessionKey: route.sessionKey,
|
|
1836
|
+
baseMentionConfig: params.baseMentionConfig,
|
|
1837
|
+
authDir: params.account.authDir,
|
|
1838
|
+
groupHistories: params.groupHistories,
|
|
1839
|
+
groupHistoryLimit: params.groupHistoryLimit,
|
|
1840
|
+
groupMemberNames: params.groupMemberNames,
|
|
1841
|
+
logVerbose,
|
|
1842
|
+
replyLogger: params.replyLogger
|
|
1843
|
+
}).shouldProcess) return;
|
|
1844
|
+
} else if (!msg.senderE164 && peerId && peerId.startsWith("+")) msg.senderE164 = normalizeE164(peerId) ?? msg.senderE164;
|
|
1845
|
+
if (await maybeBroadcastMessage({
|
|
1846
|
+
cfg: params.cfg,
|
|
1847
|
+
msg,
|
|
1848
|
+
peerId,
|
|
1849
|
+
route,
|
|
1850
|
+
groupHistoryKey,
|
|
1851
|
+
groupHistories: params.groupHistories,
|
|
1852
|
+
processMessage: processForRoute
|
|
1853
|
+
})) return;
|
|
1854
|
+
await processForRoute(msg, route, groupHistoryKey);
|
|
1855
|
+
};
|
|
1856
|
+
}
|
|
1857
|
+
|
|
1858
|
+
//#endregion
|
|
1859
|
+
//#region src/web/auto-reply/monitor.ts
|
|
1860
|
+
async function monitorWebChannel(verbose, listenerFactory = monitorWebInbox, keepAlive = true, replyResolver = getReplyFromConfig, runtime = defaultRuntime, abortSignal, tuning = {}) {
|
|
1861
|
+
const runId = newConnectionId();
|
|
1862
|
+
const replyLogger = getChildLogger({
|
|
1863
|
+
module: "web-auto-reply",
|
|
1864
|
+
runId
|
|
1865
|
+
});
|
|
1866
|
+
const heartbeatLogger = getChildLogger({
|
|
1867
|
+
module: "web-heartbeat",
|
|
1868
|
+
runId
|
|
1869
|
+
});
|
|
1870
|
+
const reconnectLogger = getChildLogger({
|
|
1871
|
+
module: "web-reconnect",
|
|
1872
|
+
runId
|
|
1873
|
+
});
|
|
1874
|
+
const status = {
|
|
1875
|
+
running: true,
|
|
1876
|
+
connected: false,
|
|
1877
|
+
reconnectAttempts: 0,
|
|
1878
|
+
lastConnectedAt: null,
|
|
1879
|
+
lastDisconnect: null,
|
|
1880
|
+
lastMessageAt: null,
|
|
1881
|
+
lastEventAt: null,
|
|
1882
|
+
lastError: null
|
|
1883
|
+
};
|
|
1884
|
+
const emitStatus = () => {
|
|
1885
|
+
tuning.statusSink?.({
|
|
1886
|
+
...status,
|
|
1887
|
+
lastDisconnect: status.lastDisconnect ? { ...status.lastDisconnect } : null
|
|
1888
|
+
});
|
|
1889
|
+
};
|
|
1890
|
+
emitStatus();
|
|
1891
|
+
const baseCfg = loadConfig();
|
|
1892
|
+
const account = resolveWhatsAppAccount({
|
|
1893
|
+
cfg: baseCfg,
|
|
1894
|
+
accountId: tuning.accountId
|
|
1895
|
+
});
|
|
1896
|
+
const cfg = {
|
|
1897
|
+
...baseCfg,
|
|
1898
|
+
channels: {
|
|
1899
|
+
...baseCfg.channels,
|
|
1900
|
+
whatsapp: {
|
|
1901
|
+
...baseCfg.channels?.whatsapp,
|
|
1902
|
+
ackReaction: account.ackReaction,
|
|
1903
|
+
messagePrefix: account.messagePrefix,
|
|
1904
|
+
allowFrom: account.allowFrom,
|
|
1905
|
+
groupAllowFrom: account.groupAllowFrom,
|
|
1906
|
+
groupPolicy: account.groupPolicy,
|
|
1907
|
+
textChunkLimit: account.textChunkLimit,
|
|
1908
|
+
chunkMode: account.chunkMode,
|
|
1909
|
+
mediaMaxMb: account.mediaMaxMb,
|
|
1910
|
+
blockStreaming: account.blockStreaming,
|
|
1911
|
+
groups: account.groups
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
};
|
|
1915
|
+
const configuredMaxMb = cfg.agents?.defaults?.mediaMaxMb;
|
|
1916
|
+
const maxMediaBytes = typeof configuredMaxMb === "number" && configuredMaxMb > 0 ? configuredMaxMb * 1024 * 1024 : DEFAULT_WEB_MEDIA_BYTES;
|
|
1917
|
+
const heartbeatSeconds = resolveHeartbeatSeconds(cfg, tuning.heartbeatSeconds);
|
|
1918
|
+
const reconnectPolicy = resolveReconnectPolicy(cfg, tuning.reconnect);
|
|
1919
|
+
const baseMentionConfig = buildMentionConfig(cfg);
|
|
1920
|
+
const groupHistoryLimit = cfg.channels?.whatsapp?.accounts?.[tuning.accountId ?? ""]?.historyLimit ?? cfg.channels?.whatsapp?.historyLimit ?? cfg.messages?.groupChat?.historyLimit ?? DEFAULT_GROUP_HISTORY_LIMIT;
|
|
1921
|
+
const groupHistories = /* @__PURE__ */ new Map();
|
|
1922
|
+
const groupMemberNames = /* @__PURE__ */ new Map();
|
|
1923
|
+
const echoTracker = createEchoTracker({
|
|
1924
|
+
maxItems: 100,
|
|
1925
|
+
logVerbose
|
|
1926
|
+
});
|
|
1927
|
+
const sleep = tuning.sleep ?? ((ms, signal) => sleepWithAbort(ms, signal ?? abortSignal));
|
|
1928
|
+
const stopRequested = () => abortSignal?.aborted === true;
|
|
1929
|
+
const abortPromise = abortSignal && new Promise((resolve) => abortSignal.addEventListener("abort", () => resolve("aborted"), { once: true }));
|
|
1930
|
+
const currentMaxListeners = process.getMaxListeners?.() ?? 10;
|
|
1931
|
+
if (process.setMaxListeners && currentMaxListeners < 50) process.setMaxListeners(50);
|
|
1932
|
+
let sigintStop = false;
|
|
1933
|
+
const handleSigint = () => {
|
|
1934
|
+
sigintStop = true;
|
|
1935
|
+
};
|
|
1936
|
+
process.once("SIGINT", handleSigint);
|
|
1937
|
+
let reconnectAttempts = 0;
|
|
1938
|
+
while (true) {
|
|
1939
|
+
if (stopRequested()) break;
|
|
1940
|
+
const connectionId = newConnectionId();
|
|
1941
|
+
const startedAt = Date.now();
|
|
1942
|
+
let heartbeat = null;
|
|
1943
|
+
let watchdogTimer = null;
|
|
1944
|
+
let lastMessageAt = null;
|
|
1945
|
+
let handledMessages = 0;
|
|
1946
|
+
let unregisterUnhandled = null;
|
|
1947
|
+
const MESSAGE_TIMEOUT_MS = 1800 * 1e3;
|
|
1948
|
+
const WATCHDOG_CHECK_MS = 60 * 1e3;
|
|
1949
|
+
const backgroundTasks = /* @__PURE__ */ new Set();
|
|
1950
|
+
const onMessage = createWebOnMessageHandler({
|
|
1951
|
+
cfg,
|
|
1952
|
+
verbose,
|
|
1953
|
+
connectionId,
|
|
1954
|
+
maxMediaBytes,
|
|
1955
|
+
groupHistoryLimit,
|
|
1956
|
+
groupHistories,
|
|
1957
|
+
groupMemberNames,
|
|
1958
|
+
echoTracker,
|
|
1959
|
+
backgroundTasks,
|
|
1960
|
+
replyResolver: replyResolver ?? getReplyFromConfig,
|
|
1961
|
+
replyLogger,
|
|
1962
|
+
baseMentionConfig,
|
|
1963
|
+
account
|
|
1964
|
+
});
|
|
1965
|
+
const inboundDebounceMs = resolveInboundDebounceMs({
|
|
1966
|
+
cfg,
|
|
1967
|
+
channel: "whatsapp"
|
|
1968
|
+
});
|
|
1969
|
+
const shouldDebounce = (msg) => {
|
|
1970
|
+
if (msg.mediaPath || msg.mediaType) return false;
|
|
1971
|
+
if (msg.location) return false;
|
|
1972
|
+
if (msg.replyToId || msg.replyToBody) return false;
|
|
1973
|
+
return !hasControlCommand(msg.body, cfg);
|
|
1974
|
+
};
|
|
1975
|
+
const listener = await (listenerFactory ?? monitorWebInbox)({
|
|
1976
|
+
verbose,
|
|
1977
|
+
accountId: account.accountId,
|
|
1978
|
+
authDir: account.authDir,
|
|
1979
|
+
mediaMaxMb: account.mediaMaxMb,
|
|
1980
|
+
sendReadReceipts: account.sendReadReceipts,
|
|
1981
|
+
debounceMs: inboundDebounceMs,
|
|
1982
|
+
shouldDebounce,
|
|
1983
|
+
onMessage: async (msg) => {
|
|
1984
|
+
handledMessages += 1;
|
|
1985
|
+
lastMessageAt = Date.now();
|
|
1986
|
+
status.lastMessageAt = lastMessageAt;
|
|
1987
|
+
status.lastEventAt = lastMessageAt;
|
|
1988
|
+
emitStatus();
|
|
1989
|
+
await onMessage(msg);
|
|
1990
|
+
}
|
|
1991
|
+
});
|
|
1992
|
+
status.connected = true;
|
|
1993
|
+
status.lastConnectedAt = Date.now();
|
|
1994
|
+
status.lastEventAt = status.lastConnectedAt;
|
|
1995
|
+
status.lastError = null;
|
|
1996
|
+
emitStatus();
|
|
1997
|
+
const { e164: selfE164 } = readWebSelfId(account.authDir);
|
|
1998
|
+
const connectRoute = resolveAgentRoute({
|
|
1999
|
+
cfg,
|
|
2000
|
+
channel: "whatsapp",
|
|
2001
|
+
accountId: account.accountId
|
|
2002
|
+
});
|
|
2003
|
+
enqueueSystemEvent(`WhatsApp gateway connected${selfE164 ? ` as ${selfE164}` : ""}.`, { sessionKey: connectRoute.sessionKey });
|
|
2004
|
+
setActiveWebListener(account.accountId, listener);
|
|
2005
|
+
unregisterUnhandled = registerUnhandledRejectionHandler((reason) => {
|
|
2006
|
+
if (!isLikelyWhatsAppCryptoError(reason)) return false;
|
|
2007
|
+
const errorStr = formatError(reason);
|
|
2008
|
+
reconnectLogger.warn({
|
|
2009
|
+
connectionId,
|
|
2010
|
+
error: errorStr
|
|
2011
|
+
}, "web reconnect: unhandled rejection from WhatsApp socket; forcing reconnect");
|
|
2012
|
+
listener.signalClose?.({
|
|
2013
|
+
status: 499,
|
|
2014
|
+
isLoggedOut: false,
|
|
2015
|
+
error: reason
|
|
2016
|
+
});
|
|
2017
|
+
return true;
|
|
2018
|
+
});
|
|
2019
|
+
const closeListener = async () => {
|
|
2020
|
+
setActiveWebListener(account.accountId, null);
|
|
2021
|
+
if (unregisterUnhandled) {
|
|
2022
|
+
unregisterUnhandled();
|
|
2023
|
+
unregisterUnhandled = null;
|
|
2024
|
+
}
|
|
2025
|
+
if (heartbeat) clearInterval(heartbeat);
|
|
2026
|
+
if (watchdogTimer) clearInterval(watchdogTimer);
|
|
2027
|
+
if (backgroundTasks.size > 0) {
|
|
2028
|
+
await Promise.allSettled(backgroundTasks);
|
|
2029
|
+
backgroundTasks.clear();
|
|
2030
|
+
}
|
|
2031
|
+
try {
|
|
2032
|
+
await listener.close();
|
|
2033
|
+
} catch (err) {
|
|
2034
|
+
logVerbose(`Socket close failed: ${formatError(err)}`);
|
|
2035
|
+
}
|
|
2036
|
+
};
|
|
2037
|
+
if (keepAlive) {
|
|
2038
|
+
heartbeat = setInterval(() => {
|
|
2039
|
+
const authAgeMs = getWebAuthAgeMs(account.authDir);
|
|
2040
|
+
const minutesSinceLastMessage = lastMessageAt ? Math.floor((Date.now() - lastMessageAt) / 6e4) : null;
|
|
2041
|
+
const logData = {
|
|
2042
|
+
connectionId,
|
|
2043
|
+
reconnectAttempts,
|
|
2044
|
+
messagesHandled: handledMessages,
|
|
2045
|
+
lastMessageAt,
|
|
2046
|
+
authAgeMs,
|
|
2047
|
+
uptimeMs: Date.now() - startedAt,
|
|
2048
|
+
...minutesSinceLastMessage !== null && minutesSinceLastMessage > 30 ? { minutesSinceLastMessage } : {}
|
|
2049
|
+
};
|
|
2050
|
+
if (minutesSinceLastMessage && minutesSinceLastMessage > 30) heartbeatLogger.warn(logData, "⚠️ web gateway heartbeat - no messages in 30+ minutes");
|
|
2051
|
+
else heartbeatLogger.info(logData, "web gateway heartbeat");
|
|
2052
|
+
}, heartbeatSeconds * 1e3);
|
|
2053
|
+
watchdogTimer = setInterval(() => {
|
|
2054
|
+
if (!lastMessageAt) return;
|
|
2055
|
+
const timeSinceLastMessage = Date.now() - lastMessageAt;
|
|
2056
|
+
if (timeSinceLastMessage <= MESSAGE_TIMEOUT_MS) return;
|
|
2057
|
+
const minutesSinceLastMessage = Math.floor(timeSinceLastMessage / 6e4);
|
|
2058
|
+
heartbeatLogger.warn({
|
|
2059
|
+
connectionId,
|
|
2060
|
+
minutesSinceLastMessage,
|
|
2061
|
+
lastMessageAt: new Date(lastMessageAt),
|
|
2062
|
+
messagesHandled: handledMessages
|
|
2063
|
+
}, "Message timeout detected - forcing reconnect");
|
|
2064
|
+
whatsappHeartbeatLog.warn(`No messages received in ${minutesSinceLastMessage}m - restarting connection`);
|
|
2065
|
+
closeListener().catch((err) => {
|
|
2066
|
+
logVerbose(`Close listener failed: ${formatError(err)}`);
|
|
2067
|
+
});
|
|
2068
|
+
listener.signalClose?.({
|
|
2069
|
+
status: 499,
|
|
2070
|
+
isLoggedOut: false,
|
|
2071
|
+
error: "watchdog-timeout"
|
|
2072
|
+
});
|
|
2073
|
+
}, WATCHDOG_CHECK_MS);
|
|
2074
|
+
}
|
|
2075
|
+
whatsappLog.info("Listening for personal WhatsApp inbound messages.");
|
|
2076
|
+
if (process.stdout.isTTY || process.stderr.isTTY) whatsappLog.raw("Ctrl+C to stop.");
|
|
2077
|
+
if (!keepAlive) {
|
|
2078
|
+
await closeListener();
|
|
2079
|
+
process.removeListener("SIGINT", handleSigint);
|
|
2080
|
+
return;
|
|
2081
|
+
}
|
|
2082
|
+
const reason = await Promise.race([listener.onClose?.catch((err) => {
|
|
2083
|
+
reconnectLogger.error({ error: formatError(err) }, "listener.onClose rejected");
|
|
2084
|
+
return {
|
|
2085
|
+
status: 500,
|
|
2086
|
+
isLoggedOut: false,
|
|
2087
|
+
error: err
|
|
2088
|
+
};
|
|
2089
|
+
}) ?? waitForever(), abortPromise ?? waitForever()]);
|
|
2090
|
+
if (Date.now() - startedAt > heartbeatSeconds * 1e3) reconnectAttempts = 0;
|
|
2091
|
+
status.reconnectAttempts = reconnectAttempts;
|
|
2092
|
+
emitStatus();
|
|
2093
|
+
if (stopRequested() || sigintStop || reason === "aborted") {
|
|
2094
|
+
await closeListener();
|
|
2095
|
+
break;
|
|
2096
|
+
}
|
|
2097
|
+
const statusCode = (typeof reason === "object" && reason && "status" in reason ? reason.status : void 0) ?? "unknown";
|
|
2098
|
+
const loggedOut = typeof reason === "object" && reason && "isLoggedOut" in reason && reason.isLoggedOut;
|
|
2099
|
+
const errorStr = formatError(reason);
|
|
2100
|
+
status.connected = false;
|
|
2101
|
+
status.lastEventAt = Date.now();
|
|
2102
|
+
status.lastDisconnect = {
|
|
2103
|
+
at: status.lastEventAt,
|
|
2104
|
+
status: typeof statusCode === "number" ? statusCode : void 0,
|
|
2105
|
+
error: errorStr,
|
|
2106
|
+
loggedOut: Boolean(loggedOut)
|
|
2107
|
+
};
|
|
2108
|
+
status.lastError = errorStr;
|
|
2109
|
+
status.reconnectAttempts = reconnectAttempts;
|
|
2110
|
+
emitStatus();
|
|
2111
|
+
reconnectLogger.info({
|
|
2112
|
+
connectionId,
|
|
2113
|
+
status: statusCode,
|
|
2114
|
+
loggedOut,
|
|
2115
|
+
reconnectAttempts,
|
|
2116
|
+
error: errorStr
|
|
2117
|
+
}, "web reconnect: connection closed");
|
|
2118
|
+
enqueueSystemEvent(`WhatsApp gateway disconnected (status ${statusCode ?? "unknown"})`, { sessionKey: connectRoute.sessionKey });
|
|
2119
|
+
if (loggedOut) {
|
|
2120
|
+
runtime.error(`WhatsApp session logged out. Run \`${formatCliCommand("anima channels login --channel web")}\` to relink.`);
|
|
2121
|
+
await closeListener();
|
|
2122
|
+
break;
|
|
2123
|
+
}
|
|
2124
|
+
reconnectAttempts += 1;
|
|
2125
|
+
status.reconnectAttempts = reconnectAttempts;
|
|
2126
|
+
emitStatus();
|
|
2127
|
+
if (reconnectPolicy.maxAttempts > 0 && reconnectAttempts >= reconnectPolicy.maxAttempts) {
|
|
2128
|
+
reconnectLogger.warn({
|
|
2129
|
+
connectionId,
|
|
2130
|
+
status: statusCode,
|
|
2131
|
+
reconnectAttempts,
|
|
2132
|
+
maxAttempts: reconnectPolicy.maxAttempts
|
|
2133
|
+
}, "web reconnect: max attempts reached; continuing in degraded mode");
|
|
2134
|
+
runtime.error(`WhatsApp Web reconnect: max attempts reached (${reconnectAttempts}/${reconnectPolicy.maxAttempts}). Stopping web monitoring.`);
|
|
2135
|
+
await closeListener();
|
|
2136
|
+
break;
|
|
2137
|
+
}
|
|
2138
|
+
const delay = computeBackoff(reconnectPolicy, reconnectAttempts);
|
|
2139
|
+
reconnectLogger.info({
|
|
2140
|
+
connectionId,
|
|
2141
|
+
status: statusCode,
|
|
2142
|
+
reconnectAttempts,
|
|
2143
|
+
maxAttempts: reconnectPolicy.maxAttempts || "unlimited",
|
|
2144
|
+
delayMs: delay
|
|
2145
|
+
}, "web reconnect: scheduling retry");
|
|
2146
|
+
runtime.error(`WhatsApp Web connection closed (status ${statusCode}). Retry ${reconnectAttempts}/${reconnectPolicy.maxAttempts || "∞"} in ${formatDurationPrecise(delay)}… (${errorStr})`);
|
|
2147
|
+
await closeListener();
|
|
2148
|
+
try {
|
|
2149
|
+
await sleep(delay, abortSignal);
|
|
2150
|
+
} catch {
|
|
2151
|
+
break;
|
|
2152
|
+
}
|
|
2153
|
+
}
|
|
2154
|
+
status.running = false;
|
|
2155
|
+
status.connected = false;
|
|
2156
|
+
status.lastEventAt = Date.now();
|
|
2157
|
+
emitStatus();
|
|
2158
|
+
process.removeListener("SIGINT", handleSigint);
|
|
2159
|
+
}
|
|
2160
|
+
|
|
2161
|
+
//#endregion
|
|
2162
|
+
export { monitorWebInbox as n, waitForever as r, monitorWebChannel as t };
|