remoteclaw 0.1.0-next.049f396 → 0.1.0-next.05abcca
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -9
- package/dist/accounts-79XhjwAj.js +32 -0
- package/dist/accounts-B1M3fOxL.js +272 -0
- package/dist/accounts-BwbvnKsW.js +205 -0
- package/dist/accounts-CIVjmTg9.js +270 -0
- package/dist/accounts-D1awQXKu.js +36 -0
- package/dist/accounts-DHkGVGUR.js +36 -0
- package/dist/accounts-P7cmIXUM.js +206 -0
- package/dist/accounts-XFgBY644.js +47 -0
- package/dist/accounts-_ZuNC5bz.js +47 -0
- package/dist/ack-reactions-BGJ9Vigf.js +621 -0
- package/dist/ack-reactions-Diu9O24z.js +621 -0
- package/dist/acp-cli-BwZ-va2P.js +1316 -0
- package/dist/acp-cli-eVKByz-j.js +1311 -0
- package/dist/active-listener--jrUO-8L.js +37 -0
- package/dist/active-listener-C7SyMcNY.js +37 -0
- package/dist/agent-BAxK2KQW.js +688 -0
- package/dist/agent-Dd5Yfhmq.js +687 -0
- package/dist/agent-helpers-5F0tdxud.js +400 -0
- package/dist/agent-helpers-Bs2nBXeI.js +400 -0
- package/dist/agent-scope-BA1HP4K6.js +114 -0
- package/dist/agent-scope-CAQLm3LP.js +116 -0
- package/dist/agents-D--9DD91.js +754 -0
- package/dist/agents.config-CmyzLYqW.js +116 -0
- package/dist/agents.config-DerBqRzk.js +116 -0
- package/dist/ansi-DtaiOnt1.js +107 -0
- package/dist/audio-ClIuKwkl.js +43 -0
- package/dist/audio-DqlIYYTb.js +43 -0
- package/dist/audit-Cn0cNCE4.js +3114 -0
- package/dist/audit-DXY4NHBC.js +3114 -0
- package/dist/auth-B-QK8JhI.js +315 -0
- package/dist/auth-C1zx1O24.js +314 -0
- package/dist/auth-DDmNYVMW.js +448 -0
- package/dist/auth-DH1wEw0w.js +448 -0
- package/dist/banner-CBWZhANO.js +294 -0
- package/dist/binaries-CYwLdubd.js +13 -0
- package/dist/bindings-DFAFatwT.js +69 -0
- package/dist/bindings-GUKIzFCp.js +69 -0
- package/dist/bonjour-discovery-AQMJqY4V.js +378 -0
- package/dist/bonjour-discovery-BLcPWHFJ.js +378 -0
- package/dist/boot/handler.js +41 -84
- package/dist/browser-cli-8Dv5ogFT.js +1690 -0
- package/dist/browser-cli-wNLo8SOy.js +1694 -0
- package/dist/build-info.json +3 -3
- package/dist/call-BTHzKFbN.js +518 -0
- package/dist/call-D_NchaCs.js +517 -0
- package/dist/canvas-host/a2ui/.bundle.hash +1 -1
- package/dist/catalog-DgpN5jxU.js +186 -0
- package/dist/catalog-k056Nh93.js +186 -0
- package/dist/channel-account-context-BHIy71Yh.js +133 -0
- package/dist/channel-account-context-DXU_-EkJ.js +133 -0
- package/dist/channel-activity-BatlvP_U.js +292 -0
- package/dist/channel-activity-BhT7NQ_v.js +94 -0
- package/dist/channel-activity-CvjEwpJz.js +94 -0
- package/dist/channel-options-BCccA2WC.js +32 -0
- package/dist/channel-options-VPR_pNyS.js +33 -0
- package/dist/channel-selection-AH6_y6RS.js +51 -0
- package/dist/channel-selection-ovohyJQZ.js +51 -0
- package/dist/channel-web-APDaQ_wp.js +2134 -0
- package/dist/channel-web-BW_YuNlT.js +2132 -0
- package/dist/channels-cli-DVsZyaU5.js +1436 -0
- package/dist/channels-cli-ubrg5vcL.js +1440 -0
- package/dist/channels-status-issues-BbYNzwLp.js +18 -0
- package/dist/channels-status-issues-DRybAijg.js +18 -0
- package/dist/chat-envelope-AJFUAuBM.js +248 -0
- package/dist/chat-envelope-BrfcPlDM.js +248 -0
- package/dist/chrome-Bv2UtAMQ.js +1732 -0
- package/dist/chrome-C6Vc_7su.js +1733 -0
- package/dist/chunk-BAMyFYtF.js +341 -0
- package/dist/chunk-BzVoFUZL.js +341 -0
- package/dist/clack-prompter-C6mBTOzE.js +122 -0
- package/dist/clack-prompter-DKcYqv3o.js +121 -0
- package/dist/cleanup-utils-Cb-leJcy.js +94 -0
- package/dist/cli/daemon-cli.js +1 -1
- package/dist/cli-Cs1n6-eD.js +135 -0
- package/dist/cli-Di3p1tLN.js +131 -0
- package/dist/client-B6h7bgbF.js +2311 -0
- package/dist/client-CMtdm9Ii.js +2311 -0
- package/dist/clipboard-A06eV_5C.js +31 -0
- package/dist/clipboard-DQBl3coj.js +31 -0
- package/dist/command-format-BiiNHkWG.js +18 -0
- package/dist/command-format-Dntg_tnC.js +32 -0
- package/dist/command-logger/handler.js +1 -1
- package/dist/command-registry-CCAvdWh2.js +215 -0
- package/dist/commands-D93TXYhv.js +41 -0
- package/dist/commands-UD7V7QC9.js +41 -0
- package/dist/commands-registry-CCbTtSSK.js +891 -0
- package/dist/commands-registry-De8JhZLG.js +890 -0
- package/dist/common-D4fL3S2m.js +156 -0
- package/dist/common-DXNisGxw.js +156 -0
- package/dist/completion-cli-CLo-r-UP.js +452 -0
- package/dist/completion-cli-D4ajG3yt.js +452 -0
- package/dist/config-BTH7fB_v.js +3345 -0
- package/dist/config-DwuBnd6D.js +3347 -0
- package/dist/config-cli-D0D1LSNt.js +243 -0
- package/dist/config-cli-tWsFNKQM.js +247 -0
- package/dist/config-guard-BcT7soTj.js +92 -0
- package/dist/config-guard-Bqak3bDc.js +75 -0
- package/dist/config-validation-CHEjSJ5K.js +18 -0
- package/dist/config-validation-CvgqLhyG.js +18 -0
- package/dist/configure-CK_0tFJG.js +889 -0
- package/dist/configure-D0z0kE-B.js +891 -0
- package/dist/constants-BBVTjb1j.js +75 -0
- package/dist/constants-PMRtHBHU.js +75 -0
- package/dist/control-auth-DrGYtMJM.js +397 -0
- package/dist/control-auth-KY4Qdr2I.js +397 -0
- package/dist/control-ui/assets/index-DdiU_ccM.css +1 -0
- package/dist/control-ui/assets/index-kVUYi64u.js +7723 -0
- package/dist/control-ui/assets/index-kVUYi64u.js.map +1 -0
- package/dist/control-ui/index.html +2 -2
- package/dist/control-ui-assets-DO1L6M0S.js +186 -0
- package/dist/control-ui-assets-S_TLo6Fs.js +186 -0
- package/dist/conversation-label-CDH4rKMG.js +36 -0
- package/dist/conversation-label-CMOfgCVl.js +36 -0
- package/dist/cron-cli-C7h_hLHu.js +495 -0
- package/dist/cron-cli-DTNg0Uvl.js +499 -0
- package/dist/daemon-cli-BlJS9zWM.js +737 -0
- package/dist/daemon-cli-Cfc1yszp.js +735 -0
- package/dist/daemon-cli.js +174 -1167
- package/dist/daemon-install-BbBLuLWg.js +60 -0
- package/dist/daemon-install-WEBvqVOj.js +56 -0
- package/dist/daemon-install-helpers-BVtPC2TK.js +504 -0
- package/dist/daemon-install-helpers-DVr51zvE.js +504 -0
- package/dist/deliver-EB272zWh.js +481 -0
- package/dist/deliver-iGD_woru.js +481 -0
- package/dist/delivery-queue-BDvalA10.js +244 -0
- package/dist/delivery-queue-BimvYz5E.js +244 -0
- package/dist/devices-cli-BXCOsNFc.js +323 -0
- package/dist/devices-cli-CHGdYfrz.js +319 -0
- package/dist/diagnostics-BzzhTQzK.js +35 -0
- package/dist/diagnostics-DILtxtcE.js +35 -0
- package/dist/directory-cli-COS40yI9.js +221 -0
- package/dist/directory-cli-Cb5j1JTC.js +225 -0
- package/dist/dispatcher-BUqxh_mA.js +174 -0
- package/dist/dispatcher-By-KZRWZ.js +173 -0
- package/dist/dm-policy-shared-BCp9_z3w.js +22 -0
- package/dist/dm-policy-shared-DgeKqjOu.js +22 -0
- package/dist/dns-cli-B8yyXB2N.js +203 -0
- package/dist/dns-cli-DAkTk-gM.js +199 -0
- package/dist/dock-B0bIIDS3.js +906 -0
- package/dist/dock-C3PzQ6CS.js +907 -0
- package/dist/doctor-completion-BXGEqLhU.js +92 -0
- package/dist/doctor-completion-D_mNzioP.js +92 -0
- package/dist/doctor-config-flow-BDDsR2J1.js +978 -0
- package/dist/doctor-config-flow-CwFFRUic.js +979 -0
- package/dist/enable-C3I9dWel.js +59 -0
- package/dist/enable-DnwKeWnR.js +59 -0
- package/dist/entry.js +75 -21
- package/dist/env-DyyqmxSM.js +60 -0
- package/dist/env-vars-CD2_baIP.js +43 -0
- package/dist/env-vars-a7S70ba7.js +43 -0
- package/dist/errors-0dfGxeYQ.js +35 -0
- package/dist/errors-C1kDByVU.js +35 -0
- package/dist/exec-CAk1dxq_.js +164 -0
- package/dist/exec-epNpA1aU.js +164 -0
- package/dist/export-html/template.css +0 -36
- package/dist/export-html/template.js +1 -32
- package/dist/extensionAPI.js +1765 -1590
- package/dist/fetch-BMQq41sB.js +281 -0
- package/dist/fetch-Cky99wYB.js +281 -0
- package/dist/fetch-D3tw4B4n.js +67 -0
- package/dist/fetch-DTsU2XnC.js +67 -0
- package/dist/fetch-Dgm9ZHFm.js +67 -0
- package/dist/file-lock-DWH0TfVu.js +107 -0
- package/dist/file-lock-DXW9h9ek.js +107 -0
- package/dist/fs-safe-BjSd07M4.js +115 -0
- package/dist/fs-safe-aWIhCWlb.js +125 -0
- package/dist/gateway-cli-C4y4H61g.js +24546 -0
- package/dist/gateway-cli-CtFr42NV.js +24550 -0
- package/dist/gateway-rpc-B92CH0D3.js +28 -0
- package/dist/gateway-rpc-DZNlWapO.js +28 -0
- package/dist/gmail-setup-utils-CKyh29_R.js +422 -0
- package/dist/gmail-setup-utils-DquflkMR.js +423 -0
- package/dist/health-BYl7T-4m.js +1417 -0
- package/dist/health-DdviISKg.js +1414 -0
- package/dist/health-format-BE5TK5bs.js +28 -0
- package/dist/heartbeat-visibility-BO3iRpB6.js +125 -0
- package/dist/heartbeat-visibility-Cwp4TrTv.js +125 -0
- package/dist/help-format-D3JhWp1E.js +17 -0
- package/dist/helpers-DAEoFkbn.js +10 -0
- package/dist/helpers-ndPQWl6m.js +10 -0
- package/dist/hook-runner-global-C1thol1d.js +527 -0
- package/dist/hooks-cli-BKS9uZ0H.js +1221 -0
- package/dist/hooks-cli-FLWcCr9q.js +1217 -0
- package/dist/host-env-security-BGibnCbS.js +106 -0
- package/dist/host-env-security-axRnIi8d.js +106 -0
- package/dist/image-ops-CX41n0v5.js +354 -0
- package/dist/image-ops-DSL3eFfQ.js +354 -0
- package/dist/import-BSFgt760.js +604 -0
- package/dist/import-Da1CHJJg.js +606 -0
- package/dist/inbound-context-BLy-G2Eq.js +68 -0
- package/dist/inbound-context-a5bzQvRt.js +68 -0
- package/dist/index.js +137 -108
- package/dist/inspect-BEpFbi0c.js +286 -0
- package/dist/inspect-BeNNpWna.js +286 -0
- package/dist/installs-CH7Qq_m_.js +319 -0
- package/dist/installs-CcM8H2YA.js +319 -0
- package/dist/ipv4-DNo9AFDu.js +46 -0
- package/dist/ipv4-VfoVR5uR.js +46 -0
- package/dist/ir-BPwP8hIc.js +972 -0
- package/dist/json-files-BI20PLIm.js +46 -0
- package/dist/lifecycle-core-5Zxqwa6V.js +476 -0
- package/dist/lifecycle-core-C1bGeLby.js +474 -0
- package/dist/links-CtGBIrG8.js +15 -0
- package/dist/loader-BoP3JA-r.js +22411 -0
- package/dist/loader-DXbpue-L.js +22414 -0
- package/dist/logger-ASsO5Nz-.js +49 -0
- package/dist/logging-Cd9y2AdQ.js +20 -0
- package/dist/logging-DRwtiLIS.js +1 -0
- package/dist/logging-fywhKCmE.js +1 -0
- package/dist/login-B2UXzgaB.js +61 -0
- package/dist/login-BEFL3xY9.js +62 -0
- package/dist/login-qr-C7wAz2fe.js +329 -0
- package/dist/login-qr-DWpUP1Ud.js +325 -0
- package/dist/logs-cli-CAcd-pXA.js +240 -0
- package/dist/logs-cli-D7Bzarht.js +236 -0
- package/dist/markdown-tables-BBNUZp4n.js +29 -0
- package/dist/markdown-tables-NgPcfXoF.js +29 -0
- package/dist/media-4-qOIjO-.js +971 -0
- package/dist/media-DTwJhAbE.js +9481 -0
- package/dist/message-action-names-BsNTjuBE.js +2520 -0
- package/dist/message-action-names-ocKcq8_3.js +2520 -0
- package/dist/message-channel-CtcVHawF.js +91 -0
- package/dist/message-channel-tuc9CdEw.js +91 -0
- package/dist/mime-CAqaK3kp.js +146 -0
- package/dist/mime-ViuhRuMM.js +146 -0
- package/dist/net-DSkFMHJ8.js +225 -0
- package/dist/net-DTqfFYzt.js +225 -0
- package/dist/node-cli-BeXU67eQ.js +1458 -0
- package/dist/node-cli-i2aCtnmM.js +1462 -0
- package/dist/node-service-RyMlWp8N.js +67 -0
- package/dist/node-service-TL9b6Qfz.js +67 -0
- package/dist/nodes-cli-CtqnXBMD.js +1346 -0
- package/dist/nodes-cli-DgQU3LrG.js +1350 -0
- package/dist/nodes-screen-B7HJugJ0.js +250 -0
- package/dist/nodes-screen-nCRd71Mk.js +250 -0
- package/dist/note-B6142LyJ.js +92 -0
- package/dist/note-D-EI0czq.js +92 -0
- package/dist/npm-registry-spec-PPyRXSpx.js +786 -0
- package/dist/npm-registry-spec-uUmDWe6v.js +786 -0
- package/dist/npm-resolution-BC1LqCm2.js +86 -0
- package/dist/npm-resolution-DhlhUmRF.js +86 -0
- package/dist/onboard-CGpC2ecw.js +647 -0
- package/dist/onboard-auth-cNtb3FTP.js +211 -0
- package/dist/onboard-auth-gwz-0mZ6.js +207 -0
- package/dist/onboard-channels-CXjJYzHC.js +2548 -0
- package/dist/onboard-channels-vtaIxYml.js +2549 -0
- package/dist/onboard-config-DOmXYEvJ.js +39 -0
- package/dist/onboard-config-JmR21VYa.js +39 -0
- package/dist/onboard-helpers-8afRV_Tm.js +364 -0
- package/dist/onboard-helpers-DTRrJLj-.js +363 -0
- package/dist/onboard-jLzfwoPx.js +649 -0
- package/dist/onboard-remote-CFkvVAYg.js +127 -0
- package/dist/onboard-remote-JfBnmK70.js +127 -0
- package/dist/onboarding-Dt0LKvZn.js +586 -0
- package/dist/onboarding-gMKlA2bP.js +588 -0
- package/dist/onboarding.finalize-BDML6Jx7.js +403 -0
- package/dist/onboarding.finalize-D850VgMA.js +405 -0
- package/dist/onboarding.gateway-config-DolBTXWT.js +196 -0
- package/dist/onboarding.gateway-config-rJkIamlG.js +202 -0
- package/dist/outbound-CPMaDtgC.js +220 -0
- package/dist/outbound-CYSuCMiW.js +221 -0
- package/dist/outbound-attachment-Ci02LXoq.js +18 -0
- package/dist/outbound-attachment-CqZ7Qc_o.js +18 -0
- package/dist/outbound-attachment-CuqWdsdV.js +18 -0
- package/dist/pairing-cli-B9JKvvST.js +126 -0
- package/dist/pairing-cli-C4HrfIHe.js +130 -0
- package/dist/pairing-labels-CBmGQ31P.js +9 -0
- package/dist/pairing-labels-D0xwC7Xb.js +9 -0
- package/dist/pairing-store-BoF0g-iN.js +459 -0
- package/dist/pairing-store-CseXj-5p.js +460 -0
- package/dist/path-env-CPZbb7me.js +89 -0
- package/dist/path-env-GTM4HXCN.js +89 -0
- package/dist/path-safety-BFE0XmGC.js +14 -0
- package/dist/path-safety-BJ8ge6Ho.js +14 -0
- package/dist/paths-DHuXVC00.js +229 -0
- package/dist/plugin-auto-enable-B_9J1XED.js +302 -0
- package/dist/plugin-auto-enable-DghjlFCL.js +301 -0
- package/dist/plugin-registry-68h2T8vi.js +33 -0
- package/dist/plugin-registry-BitdVPb4.js +33 -0
- package/dist/plugin-sdk/agents/agent-helpers.d.ts +0 -1
- package/dist/plugin-sdk/agents/agent-scope.d.ts +11 -0
- package/dist/plugin-sdk/agents/agent-types.d.ts +1 -6
- package/dist/plugin-sdk/agents/agent-utils.d.ts +0 -14
- package/dist/plugin-sdk/agents/provider-utils.d.ts +0 -1
- package/dist/plugin-sdk/agents/subagent-registry.store.d.ts +0 -1
- package/dist/plugin-sdk/agents/subagent-spawn.d.ts +0 -1
- package/dist/plugin-sdk/agents/tools/sessions-helpers.d.ts +0 -1
- package/dist/plugin-sdk/auth/constants.d.ts +15 -0
- package/dist/plugin-sdk/auth/display.d.ts +7 -0
- package/dist/plugin-sdk/auth/doctor.d.ts +8 -0
- package/dist/plugin-sdk/auth/env-injection.d.ts +38 -0
- package/dist/plugin-sdk/auth/index.d.ts +10 -0
- package/dist/plugin-sdk/auth/oauth.d.ts +13 -0
- package/dist/plugin-sdk/auth/order.d.ts +8 -0
- package/dist/plugin-sdk/auth/paths.d.ts +3 -0
- package/dist/plugin-sdk/auth/profiles.d.ts +11 -0
- package/dist/plugin-sdk/auth/provider-auth.d.ts +32 -0
- package/dist/plugin-sdk/auth/store.d.ts +7 -0
- package/dist/plugin-sdk/auth/types.d.ts +45 -0
- package/dist/plugin-sdk/auth/usage.d.ts +80 -0
- package/dist/plugin-sdk/auto-reply/reply/agent-runner-execution.d.ts +0 -1
- package/dist/plugin-sdk/auto-reply/reply/agent-runner-utils.d.ts +3 -36
- package/dist/plugin-sdk/auto-reply/reply/commands-status.d.ts +1 -7
- package/dist/plugin-sdk/auto-reply/reply/commands-subagents/shared.d.ts +1 -1
- package/dist/plugin-sdk/auto-reply/reply/commands-types.d.ts +1 -13
- package/dist/plugin-sdk/auto-reply/reply/directive-handling.levels.d.ts +1 -10
- package/dist/plugin-sdk/auto-reply/reply/directive-handling.params.d.ts +1 -11
- package/dist/plugin-sdk/auto-reply/reply/directive-handling.parse.d.ts +1 -29
- package/dist/plugin-sdk/auto-reply/reply/directive-handling.persist.d.ts +0 -3
- package/dist/plugin-sdk/auto-reply/reply/directive-handling.shared.d.ts +0 -25
- package/dist/plugin-sdk/auto-reply/reply/directives.d.ts +3 -42
- package/dist/plugin-sdk/auto-reply/reply/get-reply-directives-apply.d.ts +0 -9
- package/dist/plugin-sdk/auto-reply/reply/get-reply-directives-utils.d.ts +0 -1
- package/dist/plugin-sdk/auto-reply/reply/get-reply-directives.d.ts +1 -20
- package/dist/plugin-sdk/auto-reply/reply/get-reply-inline-actions.d.ts +1 -12
- package/dist/plugin-sdk/auto-reply/reply/get-reply-run.d.ts +1 -15
- package/dist/plugin-sdk/auto-reply/reply/queue/types.d.ts +1 -17
- package/dist/plugin-sdk/auto-reply/reply/response-prefix-template.d.ts +4 -6
- package/dist/plugin-sdk/auto-reply/reply/session-run-accounting.d.ts +0 -7
- package/dist/plugin-sdk/auto-reply/reply/session-updates.d.ts +0 -10
- package/dist/plugin-sdk/auto-reply/reply.d.ts +1 -1
- package/dist/plugin-sdk/auto-reply/status.d.ts +3 -12
- package/dist/plugin-sdk/auto-reply/templating.d.ts +0 -4
- package/dist/plugin-sdk/auto-reply/thinking.d.ts +0 -15
- package/dist/plugin-sdk/auto-reply/types.d.ts +1 -2
- package/dist/plugin-sdk/channels/dock.d.ts +1 -2
- package/dist/plugin-sdk/channels/plugins/types.adapters.d.ts +0 -6
- package/dist/plugin-sdk/channels/plugins/types.core.d.ts +1 -0
- package/dist/plugin-sdk/channels/plugins/types.d.ts +1 -1
- package/dist/plugin-sdk/channels/plugins/types.plugin.d.ts +1 -2
- package/dist/plugin-sdk/channels/voice-credentials.d.ts +26 -0
- package/dist/plugin-sdk/commands/agent/session.d.ts +1 -2
- package/dist/plugin-sdk/commands/onboard-helpers.d.ts +0 -1
- package/dist/plugin-sdk/commands/onboard-types.d.ts +2 -1
- package/dist/plugin-sdk/config/defaults.d.ts +0 -1
- package/dist/plugin-sdk/config/legacy.migrations.d.ts +2 -1
- package/dist/plugin-sdk/config/legacy.shared.d.ts +0 -9
- package/dist/plugin-sdk/config/sessions/types.d.ts +0 -17
- package/dist/plugin-sdk/config/types.agent-defaults.d.ts +28 -120
- package/dist/plugin-sdk/config/types.agents.d.ts +8 -0
- package/dist/plugin-sdk/config/types.base.d.ts +0 -1
- package/dist/plugin-sdk/config/types.messages.d.ts +1 -6
- package/dist/plugin-sdk/config/types.remoteclaw.d.ts +2 -2
- package/dist/plugin-sdk/config/types.tools.d.ts +1 -74
- package/dist/plugin-sdk/config/types.tts.d.ts +2 -1
- package/dist/plugin-sdk/config/zod-schema.agent-defaults.d.ts +9 -70
- package/dist/plugin-sdk/config/zod-schema.agent-runtime.d.ts +12 -210
- package/dist/plugin-sdk/config/zod-schema.agents.d.ts +14 -86
- package/dist/plugin-sdk/config/zod-schema.core.d.ts +6 -234
- package/dist/plugin-sdk/config/zod-schema.d.ts +111 -378
- package/dist/plugin-sdk/config/zod-schema.providers-core.d.ts +148 -160
- package/dist/plugin-sdk/config/zod-schema.providers-whatsapp.d.ts +12 -12
- package/dist/plugin-sdk/config/zod-schema.providers.d.ts +88 -96
- package/dist/plugin-sdk/config/zod-schema.session.d.ts +4 -10
- package/dist/plugin-sdk/daemon/constants.d.ts +2 -2
- package/dist/plugin-sdk/gateway/protocol/index.d.ts +10 -17
- package/dist/plugin-sdk/gateway/protocol/schema/sessions.d.ts +0 -7
- package/dist/plugin-sdk/gateway/server/ws-types.d.ts +2 -0
- package/dist/plugin-sdk/gateway/session-utils.types.d.ts +0 -3
- package/dist/plugin-sdk/index.js +722 -1283
- package/dist/plugin-sdk/infra/agent-events.d.ts +1 -1
- package/dist/plugin-sdk/infra/provider-usage.auth.d.ts +0 -1
- package/dist/plugin-sdk/infra/provider-usage.load.d.ts +0 -1
- package/dist/plugin-sdk/line/config-schema.d.ts +4 -4
- package/dist/plugin-sdk/logging/levels.d.ts +1 -1
- package/dist/plugin-sdk/middleware/auth-key-retry.d.ts +31 -0
- package/dist/plugin-sdk/middleware/channel-bridge.d.ts +4 -0
- package/dist/plugin-sdk/middleware/cli-runtime-base.d.ts +6 -0
- package/dist/plugin-sdk/middleware/error-classifier.d.ts +5 -0
- package/dist/plugin-sdk/middleware/media-capability.d.ts +21 -0
- package/dist/plugin-sdk/middleware/media-resolver.d.ts +12 -0
- package/dist/plugin-sdk/middleware/runtime-factory.d.ts +42 -0
- package/dist/plugin-sdk/middleware/runtimes/claude.d.ts +10 -0
- package/dist/plugin-sdk/middleware/runtimes/codex.d.ts +5 -0
- package/dist/plugin-sdk/middleware/runtimes/gemini.d.ts +11 -0
- package/dist/plugin-sdk/middleware/runtimes/opencode.d.ts +5 -0
- package/dist/plugin-sdk/middleware/types.d.ts +41 -1
- package/dist/plugin-sdk/plugin-sdk/index.d.ts +5 -1
- package/dist/plugin-sdk/plugins/manifest-registry.d.ts +2 -0
- package/dist/plugin-sdk/plugins/manifest.d.ts +4 -4
- package/dist/plugin-sdk/plugins/registry.d.ts +18 -0
- package/dist/plugin-sdk/plugins/types.d.ts +5 -1
- package/dist/plugin-sdk/stt/defaults.d.ts +2 -0
- package/dist/plugin-sdk/stt/preflight.d.ts +14 -0
- package/dist/plugin-sdk/stt/providers/deepgram/index.d.ts +2 -0
- package/dist/plugin-sdk/stt/providers/google/index.d.ts +2 -0
- package/dist/plugin-sdk/stt/providers/groq/index.d.ts +2 -0
- package/dist/plugin-sdk/stt/providers/index.d.ts +4 -0
- package/dist/plugin-sdk/stt/providers/mistral/index.d.ts +2 -0
- package/dist/plugin-sdk/stt/providers/openai/index.d.ts +2 -0
- package/dist/plugin-sdk/stt/stt.d.ts +27 -0
- package/dist/plugin-sdk/stt/types.d.ts +22 -0
- package/dist/plugin-sdk/terminal/palette.d.ts +2 -2
- package/dist/plugin-sdk/tts/providers/edge.d.ts +2 -0
- package/dist/plugin-sdk/tts/providers/elevenlabs.d.ts +2 -0
- package/dist/plugin-sdk/tts/providers/index.d.ts +4 -0
- package/dist/plugin-sdk/tts/providers/openai.d.ts +2 -0
- package/dist/plugin-sdk/tts/tts.d.ts +13 -5
- package/dist/plugin-sdk/tts/types.d.ts +21 -0
- package/dist/plugins-BviLFPLV.js +255 -0
- package/dist/plugins-CaudBUbl.js +254 -0
- package/dist/plugins-cli-CsLhphNr.js +803 -0
- package/dist/plugins-cli-CujSP9NS.js +807 -0
- package/dist/ports-BtuzUQHl.js +370 -0
- package/dist/ports-CMcHia07.js +96 -0
- package/dist/ports-DALdfBQy.js +96 -0
- package/dist/ports-gRBeuUtp.js +316 -0
- package/dist/preflight-Bq8rimP-.js +667 -0
- package/dist/preflight-DyYbEp9X.js +667 -0
- package/dist/program-D64vUv0b.js +250 -0
- package/dist/program-context-CTFkimUr.js +474 -0
- package/dist/progress-BcwxtM9Q.js +124 -0
- package/dist/prompt-DtWGd43j.js +21 -0
- package/dist/prompt-select-styled-GW2PexAK.js +1672 -0
- package/dist/prompt-select-styled-JOuWGHX7.js +1669 -0
- package/dist/prompt-style-BpUMhEHC.js +9 -0
- package/dist/provider-auth-B7QgxlKt.js +187 -0
- package/dist/provider-auth-j-EQvvIk.js +187 -0
- package/dist/provider-dispatcher-Bx6CaIoV.js +660 -0
- package/dist/provider-dispatcher-DhkvjhO5.js +659 -0
- package/dist/push-apns--nEiZmEN.js +711 -0
- package/dist/push-apns-BtS6B6lb.js +713 -0
- package/dist/pw-ai-BpCsXF-x.js +1908 -0
- package/dist/pw-ai-ud_Kbn5S.js +1911 -0
- package/dist/qr-cli-BCeVLGfz.js +353 -0
- package/dist/qr-cli-Crsqtw01.js +349 -0
- package/dist/redact-Ci96Gj0O.js +191 -0
- package/dist/redact-snapshot-B9nof-Pb.js +1952 -0
- package/dist/redact-snapshot-BKiS91Mj.js +1952 -0
- package/dist/register.agent-CcvOeVnL.js +292 -0
- package/dist/register.agent-azH_tdVX.js +1014 -0
- package/dist/register.configure-DAaZLjHs.js +130 -0
- package/dist/register.configure-lUl8O79m.js +135 -0
- package/dist/register.import-B83Dn36B.js +29 -0
- package/dist/register.import-wIYU2cVW.js +31 -0
- package/dist/register.maintenance-Bo-ooQDU.js +501 -0
- package/dist/register.maintenance-BwZ4OkK2.js +503 -0
- package/dist/register.message-BQhRoEQQ.js +687 -0
- package/dist/register.message-CvZKWeGb.js +691 -0
- package/dist/register.onboard---3EPh-O.js +98 -0
- package/dist/register.onboard-rsHSJUvQ.js +94 -0
- package/dist/register.setup-B0gc_lne.js +118 -0
- package/dist/register.setup-MWpb7jxL.js +114 -0
- package/dist/register.status-health-sessions-BZJ0wTSa.js +429 -0
- package/dist/register.status-health-sessions-CyrUwwtB.js +667 -0
- package/dist/register.subclis-i2d2ugaJ.js +267 -0
- package/dist/replies-BIx-MbQ7.js +136 -0
- package/dist/replies-DVU655H4.js +136 -0
- package/dist/reply-CL5VMSKN.js +12372 -0
- package/dist/reply-XKyfU3rS.js +12375 -0
- package/dist/reply-directives-DQfJ001O.js +182 -0
- package/dist/reply-directives-DfUITt7C.js +182 -0
- package/dist/reply-payloads-ZHo6kfTS.js +527 -0
- package/dist/reply-prefix-BSf3PC0x.js +37 -0
- package/dist/reply-prefix-DBTlMHLK.js +37 -0
- package/dist/resolve-route-B-_IgETc.js +249 -0
- package/dist/resolve-route-C8ZsgWDQ.js +249 -0
- package/dist/response-prefix-template-3LeqJx2X.js +134 -0
- package/dist/response-prefix-template-DBrUVx5V.js +134 -0
- package/dist/retry-CDrH81GP.js +77 -0
- package/dist/retry-Dar_7pCv.js +77 -0
- package/dist/run-main-rOudcbbs.js +308 -0
- package/dist/runtime-guard-CK80eucm.js +60 -0
- package/dist/runtime-status-CR9445g5.js +12 -0
- package/dist/runtime-status-hFVEC3wO.js +12 -0
- package/dist/secure-random-CLWSvf8A.js +44 -0
- package/dist/security-cli-B8lXw9ke.js +488 -0
- package/dist/security-cli-CRkS3VAf.js +483 -0
- package/dist/send-6g8QKfWj.js +374 -0
- package/dist/send-B5Hz1PIn.js +29 -0
- package/dist/send-B8eIlA1u.js +349 -0
- package/dist/send-BFZPQE4j.js +492 -0
- package/dist/send-BpTDvE0D.js +1779 -0
- package/dist/send-BxOrO1Wv.js +1776 -0
- package/dist/send-C6gPJu-Z.js +11 -0
- package/dist/send-C7MoKtkN.js +426 -0
- package/dist/send-CXzq2LI6.js +2245 -0
- package/dist/send-CYOZoObr.js +547 -0
- package/dist/send-CfQyIvcC.js +332 -0
- package/dist/send-DUtuuwhw.js +492 -0
- package/dist/send-DbafVwxp.js +2245 -0
- package/dist/send-DeZg8K7y.js +349 -0
- package/dist/send-DwkjxJlv.js +547 -0
- package/dist/send-iX9xbxlU.js +1178 -0
- package/dist/server-BKfCzEzd.js +206 -0
- package/dist/server-fmO4eo7K.js +202 -0
- package/dist/server-lifecycle-CgPpP10P.js +2437 -0
- package/dist/server-lifecycle-Cn8yY5MW.js +2437 -0
- package/dist/server-node-events-C-ZzSBYh.js +391 -0
- package/dist/server-node-events-DYlyfDHM.js +395 -0
- package/dist/service-C2j81L86.js +670 -0
- package/dist/service-C8a0SXHD.js +670 -0
- package/dist/session-AulYhqOb.js +170 -0
- package/dist/session-C6VKWvx6.js +170 -0
- package/dist/session-cost-usage-0Vs4hgMe.js +627 -0
- package/dist/session-cost-usage-C-DsaOfN.js +627 -0
- package/dist/session-dirs-CO1f2ArM.js +318 -0
- package/dist/session-dirs-DoboH7Oy.js +318 -0
- package/dist/session-utils-CRK8ToKG.js +621 -0
- package/dist/session-utils-DWlkmCX8.js +621 -0
- package/dist/sessions-DtqrmUJS.js +2553 -0
- package/dist/sessions-gT-4fcX-.js +245 -0
- package/dist/shell-env-DBS5su07.js +163 -0
- package/dist/shell-env-c3j5zcU9.js +163 -0
- package/dist/ssrf-8wNqPNzN.js +183 -0
- package/dist/ssrf-CJIdPXuS.js +183 -0
- package/dist/status-BI_-xpDt.js +1947 -0
- package/dist/status-PZVwjKjl.js +1943 -0
- package/dist/status.update-BmuDZ7E7.js +449 -0
- package/dist/status.update-Mf6HSRvU.js +449 -0
- package/dist/store-B7PGEdFf.js +2555 -0
- package/dist/store-CzhBjUCN.js +64 -0
- package/dist/store-YkSxKAey.js +53 -0
- package/dist/store-ZNeFv2Q7.js +64 -0
- package/dist/subagent-registry-R1DiAM4R.js +4839 -0
- package/dist/subagent-registry-xLRXC8Bg.js +4841 -0
- package/dist/subsystem-BAW_f3DI.js +1195 -0
- package/dist/subsystem-DGSHVL8I.js +1081 -0
- package/dist/system-cli-9SvRrT9D.js +77 -0
- package/dist/system-cli-yCa5Q1YM.js +73 -0
- package/dist/systemd-40Rij3QR.js +547 -0
- package/dist/systemd-5C97CSzd.js +547 -0
- package/dist/systemd-hints-3iQteJw-.js +278 -0
- package/dist/systemd-hints-CyQqHq1i.js +278 -0
- package/dist/systemd-linger-B2rPbnAi.js +75 -0
- package/dist/systemd-linger-DDvkfxH-.js +75 -0
- package/dist/table-DFx25vNb.js +279 -0
- package/dist/tables-C5fI0PmT.js +55 -0
- package/dist/tables-Cm9qvQ9D.js +55 -0
- package/dist/tables-fRe01eP1.js +55 -0
- package/dist/tailnet-Da-_9e8E.js +40 -0
- package/dist/tailnet-xt92Yaop.js +40 -0
- package/dist/tailscale-CnV0JWca.js +230 -0
- package/dist/tailscale-VkEC8dzj.js +230 -0
- package/dist/targets-C99szk_e.js +114 -0
- package/dist/targets-CPaTjbpp.js +2607 -0
- package/dist/targets-D-p4rJVS.js +650 -0
- package/dist/targets-D2OQt8-7.js +650 -0
- package/dist/targets-D94MtTiZ.js +2606 -0
- package/dist/targets-RajrXTl7.js +220 -0
- package/dist/targets-_UWmnyI9.js +53 -0
- package/dist/targets-tDrl_ioQ.js +46 -0
- package/dist/thinking-4nOZPunr.js +60 -0
- package/dist/thinking-ZfH2V9Os.js +60 -0
- package/dist/tokens-TtJJxzRr.js +21 -0
- package/dist/tool-display-Bxs_1jIn.js +785 -0
- package/dist/tool-display-D9p_Ttkq.js +785 -0
- package/dist/tool-images-9Ron321Q.js +263 -0
- package/dist/tool-images-BWhy6WRN.js +263 -0
- package/dist/trash-B5xyvBDf.js +125 -0
- package/dist/trash-BpB96kHe.js +125 -0
- package/dist/tui-Ba0uZDrg.js +3237 -0
- package/dist/tui-Biz0HqDj.js +3237 -0
- package/dist/tui-cli-C-UV6o2v.js +63 -0
- package/dist/tui-cli-Ds_bLT-h.js +67 -0
- package/dist/types.tools-BBb2rl3g.js +23 -0
- package/dist/types.tools-BDJw1yFx.js +23 -0
- package/dist/update-Barj5dsg.js +349 -0
- package/dist/update-D839Q8su.js +349 -0
- package/dist/update-cli-C0LnrpIt.js +1148 -0
- package/dist/update-cli-CUypa-T-.js +1150 -0
- package/dist/usage-BI9kergH.js +5465 -0
- package/dist/utils-DPoNpP7D.js +631 -0
- package/dist/version-3QUZW8EP.js +52 -0
- package/dist/version-CVMnqdzu.js +52 -0
- package/dist/voice-credentials-64XAMSJm.js +46 -0
- package/dist/voice-credentials-v-CQkTpD.js +46 -0
- package/dist/web-63IbbidQ.js +3051 -0
- package/dist/web-D9N764Da.js +80 -0
- package/dist/web-DUvNYLzr.js +75 -0
- package/dist/webhooks-cli-owhVNNkz.js +334 -0
- package/dist/webhooks-cli-zlvka6QD.js +330 -0
- package/dist/whatsapp-actions-8DejyRG5.js +126 -0
- package/dist/whatsapp-actions-DCzp5LKe.js +131 -0
- package/dist/widearea-dns-CQqZIeu8.js +127 -0
- package/dist/workspace-CB7pVojf.js +441 -0
- package/dist/workspace-DWEyzM0F.js +439 -0
- package/dist/zod-schema-CvFqwpNE.js +2719 -0
- package/dist/zod-schema-Y5SQgJLm.js +2719 -0
- package/extensions/matrix/src/matrix/monitor/replies.ts +0 -24
- package/extensions/mattermost/src/mattermost/monitor-helpers.ts +0 -1
- package/extensions/voice-call/index.ts +18 -1
- package/package.json +3 -4
- package/dist/accounts-7fm_KzPm.js +0 -32
- package/dist/accounts-BFy_Z3od.js +0 -272
- package/dist/accounts-BTXSfPWi.js +0 -270
- package/dist/accounts-BxGS70Do.js +0 -36
- package/dist/accounts-CNY1TGj1.js +0 -47
- package/dist/accounts-DqRQ75w3.js +0 -36
- package/dist/accounts-iODF3SK2.js +0 -47
- package/dist/ack-reactions-C1hk85VE.js +0 -446
- package/dist/ack-reactions-DRC2CiDQ.js +0 -446
- package/dist/acp-cli-DD-PD4NM.js +0 -1326
- package/dist/acp-cli-DIyRCOum.js +0 -1320
- package/dist/active-listener-VzhWW8W6.js +0 -37
- package/dist/active-listener-z0qVEcom.js +0 -37
- package/dist/agent-D2HeDFFR.js +0 -731
- package/dist/agent-Da_eZ5BP.js +0 -732
- package/dist/agent-helpers-B6VfZ9_u.js +0 -606
- package/dist/agent-helpers-CTx5KKJu.js +0 -606
- package/dist/agent-scope-BqPmD-Ax.js +0 -114
- package/dist/agent-scope-DgQzamQB.js +0 -116
- package/dist/agents-TB3QpHoo.js +0 -788
- package/dist/agents.config-BsAQTYe1.js +0 -116
- package/dist/agents.config-C9fyYfAh.js +0 -116
- package/dist/ansi-D04X81yq.js +0 -14
- package/dist/audio-DPOuhNq7.js +0 -43
- package/dist/audio-VBcVDa08.js +0 -43
- package/dist/audio-preflight-CK3EA3Dv.js +0 -69
- package/dist/audio-preflight-tdXtrutj.js +0 -64
- package/dist/audit-CJipUWDi.js +0 -3138
- package/dist/audit-COWzB9Y1.js +0 -3138
- package/dist/auth-CAczFgAO.js +0 -448
- package/dist/auth-Deh9i9Eg.js +0 -448
- package/dist/auth-profiles-BquJGKLC.js +0 -279
- package/dist/auth-profiles-D8vKiBPq.js +0 -281
- package/dist/banner-CUWBOR42.js +0 -294
- package/dist/binaries-DXW6oATV.js +0 -13
- package/dist/bindings-8YtSWb91.js +0 -69
- package/dist/bindings-l1R5LQQH.js +0 -69
- package/dist/bonjour-discovery-DdAk1VyO.js +0 -378
- package/dist/bonjour-discovery-DuhiIZZx.js +0 -378
- package/dist/browser-cli-5Q9lhGdd.js +0 -1687
- package/dist/browser-cli-D2qMeSx1.js +0 -1692
- package/dist/call-CZHVeMf1.js +0 -2828
- package/dist/call-CoMjY7ah.js +0 -2829
- package/dist/catalog-CYiAleBT.js +0 -185
- package/dist/catalog-pjPqB2hC.js +0 -185
- package/dist/channel-account-context-CvIDAtHS.js +0 -550
- package/dist/channel-account-context-q-o0pG1A.js +0 -550
- package/dist/channel-activity-BaCNOZpP.js +0 -94
- package/dist/channel-activity-Cd1JhIUj.js +0 -292
- package/dist/channel-activity-DTKGf3j5.js +0 -94
- package/dist/channel-options-8SjIcDDI.js +0 -33
- package/dist/channel-options-BtQGtMF4.js +0 -32
- package/dist/channel-selection-C4DzrynU.js +0 -51
- package/dist/channel-selection-DdfhwFuY.js +0 -51
- package/dist/channel-web-BKJSXnwf.js +0 -2136
- package/dist/channel-web-BUzvNE_A.js +0 -2134
- package/dist/channels-cli-CCXY796Z.js +0 -1421
- package/dist/channels-cli-DTfx1zFC.js +0 -1426
- package/dist/channels-status-issues-DnmuqPsi.js +0 -18
- package/dist/channels-status-issues-p1pCvTh8.js +0 -18
- package/dist/chat-envelope-DEZ-5RY8.js +0 -248
- package/dist/chat-envelope-el7Uo-Fe.js +0 -248
- package/dist/chrome-Dd4dv0Vh.js +0 -1732
- package/dist/chrome-DdNEInwI.js +0 -1733
- package/dist/chunk-CSQfUhgF.js +0 -341
- package/dist/chunk-D0Y_w4oX.js +0 -341
- package/dist/clack-prompter-B7tOxhJd.js +0 -122
- package/dist/clack-prompter-CCFnKP_1.js +0 -121
- package/dist/cleanup-utils-CqAVZz2b.js +0 -94
- package/dist/cli-BRwDPW0r.js +0 -125
- package/dist/cli-CV86F7iv.js +0 -130
- package/dist/clipboard-D7_SKHPK.js +0 -31
- package/dist/clipboard-Dzkx6Q2K.js +0 -31
- package/dist/command-format-CVfo8I5f.js +0 -18
- package/dist/command-format-DgXcqxBt.js +0 -32
- package/dist/command-registry-BvLC28b4.js +0 -215
- package/dist/commands-B49Lu-pa.js +0 -41
- package/dist/commands-DI1BCqnj.js +0 -41
- package/dist/commands-registry-Cr6SIR3n.js +0 -892
- package/dist/commands-registry-agiTEGDz.js +0 -893
- package/dist/common-CMI-qsF8.js +0 -156
- package/dist/common-DSVmydhm.js +0 -156
- package/dist/completion-cli-C7O4JU8t.js +0 -452
- package/dist/completion-cli-CQNXtEJ7.js +0 -452
- package/dist/config-ChYRSJQt.js +0 -6953
- package/dist/config-CwtWvygh.js +0 -6951
- package/dist/config-cli-Df5nJcfO.js +0 -241
- package/dist/config-cli-Dqe5O1pl.js +0 -246
- package/dist/config-guard-C6hyuH-z.js +0 -75
- package/dist/config-guard-kNMQS_tm.js +0 -97
- package/dist/config-validation-BZBaBH69.js +0 -18
- package/dist/config-validation-DkrbzCyL.js +0 -18
- package/dist/configure-CoJmCHqT.js +0 -891
- package/dist/configure-DJbojDRf.js +0 -889
- package/dist/constants-BmRFoHl0.js +0 -67
- package/dist/constants-C9WPAluB.js +0 -67
- package/dist/control-auth-7k6Cb2zH.js +0 -397
- package/dist/control-auth-DBxfkJ3g.js +0 -397
- package/dist/control-ui/assets/index-B4ZM1lW1.js +0 -7738
- package/dist/control-ui/assets/index-B4ZM1lW1.js.map +0 -1
- package/dist/control-ui/assets/index-PED72sKF.css +0 -1
- package/dist/control-ui-assets-Cx_mw4D0.js +0 -186
- package/dist/control-ui-assets-W1AUuGrO.js +0 -186
- package/dist/conversation-label-C4SDz4sT.js +0 -36
- package/dist/conversation-label-D1frnvYe.js +0 -36
- package/dist/cron-cli-BJXQKtR3.js +0 -495
- package/dist/cron-cli-CTIj0WPW.js +0 -490
- package/dist/daemon-cli-CZbHvkRG.js +0 -1197
- package/dist/daemon-cli-Cf_YKWvV.js +0 -1199
- package/dist/daemon-install-CcohRvKV.js +0 -55
- package/dist/daemon-install-DDshfT0J.js +0 -60
- package/dist/daemon-install-helpers-CFGAfRlj.js +0 -462
- package/dist/daemon-install-helpers-DIUzSFG1.js +0 -462
- package/dist/defaults-B5KStIBg.js +0 -7
- package/dist/defaults-xUAL2Z-F.js +0 -7
- package/dist/deliver-BDf2lIEK.js +0 -481
- package/dist/deliver-DvmkSwLt.js +0 -481
- package/dist/delivery-queue-Cfa9Wmxp.js +0 -244
- package/dist/delivery-queue-CxVRi4tw.js +0 -244
- package/dist/devices-cli-CRsW5WOw.js +0 -316
- package/dist/devices-cli-Crzrk5uf.js +0 -321
- package/dist/diagnostics-99iCgBUh.js +0 -46
- package/dist/diagnostics-VC0cz7kX.js +0 -46
- package/dist/directory-cli-BnoQqeOX.js +0 -222
- package/dist/directory-cli-DdBAX3AV.js +0 -217
- package/dist/dm-policy-shared-DNqPbnip.js +0 -22
- package/dist/dm-policy-shared-vCb_hnqo.js +0 -22
- package/dist/dns-cli-D410XQr9.js +0 -197
- package/dist/dns-cli-Fgg96Xkg.js +0 -202
- package/dist/dock-DXSgTbDw.js +0 -928
- package/dist/dock-FtQwUHXE.js +0 -929
- package/dist/doctor-completion-BWmtCiFR.js +0 -92
- package/dist/doctor-completion-DTM_wDxy.js +0 -92
- package/dist/doctor-config-flow-Ccna5fPs.js +0 -1934
- package/dist/doctor-config-flow-DqzrK_jh.js +0 -1933
- package/dist/enable-DcJnkzfz.js +0 -59
- package/dist/enable-ibNq4UWy.js +0 -59
- package/dist/env-DeF64iu0.js +0 -60
- package/dist/env-vars-7aZqKPhk.js +0 -93
- package/dist/env-vars-CLGbxdpL.js +0 -93
- package/dist/errors-8F-77i6m.js +0 -35
- package/dist/errors-DZ199hOo.js +0 -35
- package/dist/exec-DbKuYyM1.js +0 -164
- package/dist/exec-DkFE7lqU.js +0 -164
- package/dist/fetch-C6XKGA11.js +0 -67
- package/dist/fetch-CEDsOiql.js +0 -67
- package/dist/fetch-ePscvwi1.js +0 -67
- package/dist/file-lock-CIvloidc.js +0 -107
- package/dist/file-lock-CzBL_VIx.js +0 -107
- package/dist/fs-safe-DSwT85uK.js +0 -88
- package/dist/fs-safe-DkBhNAc3.js +0 -98
- package/dist/gateway-cli-BJooqlkO.js +0 -23747
- package/dist/gateway-cli-C2wPjxY4.js +0 -23742
- package/dist/gateway-rpc-BcT4FqJQ.js +0 -28
- package/dist/gateway-rpc-DhKAJ5EW.js +0 -28
- package/dist/gmail-setup-utils-Cnx8A5pW.js +0 -422
- package/dist/gmail-setup-utils-nkabbKOE.js +0 -423
- package/dist/health-BZX-PyP0.js +0 -1420
- package/dist/health-BgD0koJx.js +0 -1423
- package/dist/health-format-BG95OE6N.js +0 -28
- package/dist/heartbeat-visibility-DeW9EIeS.js +0 -125
- package/dist/heartbeat-visibility-DvogUlnZ.js +0 -125
- package/dist/help-format-DAxf0l_h.js +0 -17
- package/dist/helpers-R7bU5IBz.js +0 -10
- package/dist/helpers-kkeXif0Q.js +0 -10
- package/dist/hook-runner-global-cyaKukZP.js +0 -527
- package/dist/hooks-cli-DTygpzqS.js +0 -1217
- package/dist/hooks-cli-Dg853OdZ.js +0 -1222
- package/dist/host-env-security-Bms2_EMV.js +0 -92
- package/dist/host-env-security-szwfmhC4.js +0 -92
- package/dist/image-ops-Bi6JPSkD.js +0 -354
- package/dist/image-ops-DWytvdh_.js +0 -354
- package/dist/import-D8BBZQgl.js +0 -170
- package/dist/import-DQ6NI4Fz.js +0 -168
- package/dist/inbound-context-CPkkQW0i.js +0 -68
- package/dist/inbound-context-DS_kpIYI.js +0 -68
- package/dist/inbound-path-policy-Bg4gZBx-.js +0 -250
- package/dist/inbound-path-policy-sdr5Ji0k.js +0 -250
- package/dist/inspect-Dt8hogS3.js +0 -559
- package/dist/inspect-vYIL1oA0.js +0 -559
- package/dist/installs-ClX3qQmh.js +0 -325
- package/dist/installs-CxjOiLUM.js +0 -325
- package/dist/ipv4--2WXMVtE.js +0 -46
- package/dist/ipv4-CDQpx1A7.js +0 -46
- package/dist/ir-BvKdMuSP.js +0 -940
- package/dist/json-files-DzpTak5i.js +0 -46
- package/dist/links-C3soDNDH.js +0 -15
- package/dist/loader-BWZ_iRxI.js +0 -22624
- package/dist/loader-ClFP7wvS.js +0 -22621
- package/dist/local-roots-B6rSCu4U.js +0 -314
- package/dist/local-roots-v2HlOaG5.js +0 -313
- package/dist/logger-Bw3cFE5t.js +0 -49
- package/dist/logging-C-nxX2fn.js +0 -20
- package/dist/login-Cmpeb59f.js +0 -62
- package/dist/login-D1CV2eNF.js +0 -61
- package/dist/login-qr-B3tpFLRV.js +0 -327
- package/dist/login-qr-CSQzrtFX.js +0 -322
- package/dist/logs-cli-BSiUZwb2.js +0 -238
- package/dist/logs-cli-DDtoJ1Fr.js +0 -233
- package/dist/markdown-tables-PJUMrC4T.js +0 -29
- package/dist/markdown-tables-dDWBbtqd.js +0 -29
- package/dist/media-Dqv7Q0aS.js +0 -10492
- package/dist/media-DtN0R9A0.js +0 -940
- package/dist/message-action-names-Bs50Ia1g.js +0 -2521
- package/dist/message-action-names-Btd7cMvx.js +0 -2521
- package/dist/message-channel-DzJqHVZD.js +0 -91
- package/dist/message-channel-uWMAiywE.js +0 -91
- package/dist/mime-BS3jhcZE.js +0 -149
- package/dist/mime-Cxh_64P6.js +0 -149
- package/dist/net-Cg8AQeke.js +0 -225
- package/dist/net-D6D0wgcF.js +0 -225
- package/dist/node-cli-Q2-n3Fgv.js +0 -24
- package/dist/node-cli-Uf6lAntf.js +0 -24
- package/dist/nodes-cli-DVLvMgBV.js +0 -1343
- package/dist/nodes-cli-Dxf7vAKk.js +0 -1348
- package/dist/nodes-screen-BR9sYoPa.js +0 -250
- package/dist/nodes-screen-Cw7Hv7M2.js +0 -250
- package/dist/note-Dlv4NmlQ.js +0 -92
- package/dist/note-kvWV4xtw.js +0 -92
- package/dist/npm-registry-spec-0qiKawvv.js +0 -786
- package/dist/npm-registry-spec-COvUzy5J.js +0 -786
- package/dist/npm-resolution-DJnq5QBs.js +0 -86
- package/dist/npm-resolution-DVl2spoD.js +0 -86
- package/dist/onboard-BcQWYGY3.js +0 -405
- package/dist/onboard-RQ_FAMyg.js +0 -407
- package/dist/onboard-channels-CHh_BuxJ.js +0 -2547
- package/dist/onboard-channels-DXD-CK_M.js +0 -2548
- package/dist/onboard-config-BCTthQ7J.js +0 -24
- package/dist/onboard-config-y-2cgT0V.js +0 -24
- package/dist/onboard-helpers-BRMP8mup.js +0 -362
- package/dist/onboard-helpers-CUGbuZwH.js +0 -363
- package/dist/onboard-remote-D-qWujdL.js +0 -127
- package/dist/onboard-remote-o_OW-uzc.js +0 -127
- package/dist/onboarding-Bf9kVcef.js +0 -541
- package/dist/onboarding-CVlOLLp1.js +0 -543
- package/dist/onboarding.finalize-CQSt37fw.js +0 -398
- package/dist/onboarding.finalize-DggVL7Ay.js +0 -401
- package/dist/onboarding.gateway-config-BLca3Td2.js +0 -198
- package/dist/onboarding.gateway-config-C1mcOkRh.js +0 -191
- package/dist/outbound-DXXccLDS.js +0 -220
- package/dist/outbound-ZnVvUReT.js +0 -221
- package/dist/outbound-attachment-CfRb07J7.js +0 -18
- package/dist/outbound-attachment-DGXTtERK.js +0 -18
- package/dist/outbound-attachment-_jj74QBM.js +0 -18
- package/dist/pairing-cli-Bgm4fRA3.js +0 -127
- package/dist/pairing-cli-J0uGb1nU.js +0 -122
- package/dist/pairing-labels-CVm65Jkh.js +0 -9
- package/dist/pairing-labels-DD1mcvQG.js +0 -9
- package/dist/pairing-store-5qapT5-t.js +0 -460
- package/dist/pairing-store-MLceBEeL.js +0 -459
- package/dist/path-env-DR5vn3QL.js +0 -89
- package/dist/path-env-qRJbjJzj.js +0 -89
- package/dist/path-guards-CIx4hURU.js +0 -31
- package/dist/path-guards-CrQOUlsq.js +0 -31
- package/dist/path-safety-DkT9RmTG.js +0 -14
- package/dist/path-safety-juI2XbO1.js +0 -14
- package/dist/paths-BTaH3rLn.js +0 -232
- package/dist/plugin-auto-enable-BUSF117F.js +0 -301
- package/dist/plugin-auto-enable-CoDnqA0S.js +0 -302
- package/dist/plugin-registry-D2B6nbn1.js +0 -33
- package/dist/plugin-registry-fLaMC0ik.js +0 -33
- package/dist/plugin-sdk/agents/agent-helpers/thinking.d.ts +0 -5
- package/dist/plugin-sdk/agents/agent-paths.d.ts +0 -1
- package/dist/plugin-sdk/agents/auth-profiles/constants.d.ts +0 -16
- package/dist/plugin-sdk/agents/auth-profiles/display.d.ts +0 -7
- package/dist/plugin-sdk/agents/auth-profiles/doctor.d.ts +0 -8
- package/dist/plugin-sdk/agents/auth-profiles/oauth.d.ts +0 -14
- package/dist/plugin-sdk/agents/auth-profiles/paths.d.ts +0 -4
- package/dist/plugin-sdk/agents/auth-profiles/profiles.d.ts +0 -12
- package/dist/plugin-sdk/agents/auth-profiles/session-override.d.ts +0 -18
- package/dist/plugin-sdk/agents/auth-profiles/store.d.ts +0 -10
- package/dist/plugin-sdk/agents/auth-profiles/types.d.ts +0 -13
- package/dist/plugin-sdk/agents/auth-profiles.d.ts +0 -8
- package/dist/plugin-sdk/agents/defaults.d.ts +0 -3
- package/dist/plugin-sdk/agents/provider-auth.d.ts +0 -40
- package/dist/plugin-sdk/auto-reply/model-runtime.d.ts +0 -17
- package/dist/plugin-sdk/auto-reply/reply/directive-handling.auth.d.ts +0 -19
- package/dist/plugin-sdk/auto-reply/reply/elevated-allowlist-matcher.d.ts +0 -20
- package/dist/plugin-sdk/auto-reply/reply/elevated-unavailable.d.ts +0 -8
- package/dist/plugin-sdk/auto-reply/reply/reply-elevated.d.ts +0 -16
- package/dist/plugin-sdk/compat/legacy-names.d.ts +0 -8
- package/dist/plugin-sdk/config/legacy.migrations.part-1.d.ts +0 -2
- package/dist/plugin-sdk/config/legacy.migrations.part-2.d.ts +0 -2
- package/dist/plugin-sdk/config/legacy.migrations.part-3.d.ts +0 -2
- package/dist/plugin-sdk/config/model-input.d.ts +0 -9
- package/dist/plugin-sdk/config/zod-schema.agent-model.d.ts +0 -5
- package/dist/plugin-sdk/link-understanding/apply.d.ts +0 -10
- package/dist/plugin-sdk/link-understanding/defaults.d.ts +0 -2
- package/dist/plugin-sdk/link-understanding/detect.d.ts +0 -3
- package/dist/plugin-sdk/link-understanding/format.d.ts +0 -4
- package/dist/plugin-sdk/link-understanding/runner.d.ts +0 -11
- package/dist/plugin-sdk/media/input-files.d.ts +0 -95
- package/dist/plugin-sdk/media-understanding/apply.d.ts +0 -19
- package/dist/plugin-sdk/media-understanding/attachments.d.ts +0 -49
- package/dist/plugin-sdk/media-understanding/audio-preflight.d.ts +0 -16
- package/dist/plugin-sdk/media-understanding/concurrency.d.ts +0 -1
- package/dist/plugin-sdk/media-understanding/defaults.d.ts +0 -12
- package/dist/plugin-sdk/media-understanding/errors.d.ts +0 -6
- package/dist/plugin-sdk/media-understanding/format.d.ts +0 -7
- package/dist/plugin-sdk/media-understanding/fs.d.ts +0 -1
- package/dist/plugin-sdk/media-understanding/output-extract.d.ts +0 -2
- package/dist/plugin-sdk/media-understanding/providers/anthropic/index.d.ts +0 -2
- package/dist/plugin-sdk/media-understanding/providers/deepgram/index.d.ts +0 -2
- package/dist/plugin-sdk/media-understanding/providers/google/index.d.ts +0 -2
- package/dist/plugin-sdk/media-understanding/providers/google/video.d.ts +0 -3
- package/dist/plugin-sdk/media-understanding/providers/groq/index.d.ts +0 -2
- package/dist/plugin-sdk/media-understanding/providers/index.d.ts +0 -4
- package/dist/plugin-sdk/media-understanding/providers/minimax/index.d.ts +0 -2
- package/dist/plugin-sdk/media-understanding/providers/mistral/index.d.ts +0 -2
- package/dist/plugin-sdk/media-understanding/providers/moonshot/index.d.ts +0 -2
- package/dist/plugin-sdk/media-understanding/providers/moonshot/video.d.ts +0 -3
- package/dist/plugin-sdk/media-understanding/providers/openai/index.d.ts +0 -2
- package/dist/plugin-sdk/media-understanding/providers/zai/index.d.ts +0 -2
- package/dist/plugin-sdk/media-understanding/resolve.d.ts +0 -44
- package/dist/plugin-sdk/media-understanding/runner.d.ts +0 -34
- package/dist/plugin-sdk/media-understanding/runner.entries.d.ts +0 -33
- package/dist/plugin-sdk/media-understanding/scope.d.ts +0 -9
- package/dist/plugin-sdk/media-understanding/types.d.ts +0 -74
- package/dist/plugin-sdk/media-understanding/video.d.ts +0 -2
- package/dist/plugin-sdk/sessions/model-overrides.d.ts +0 -14
- package/dist/plugin-sdk/telegram/reasoning-lane-coordinator.d.ts +0 -18
- package/dist/plugin-sdk/utils/mask-api-key.d.ts +0 -1
- package/dist/plugin-sdk/utils/run-with-concurrency.d.ts +0 -11
- package/dist/plugins-CsYMlnVa.js +0 -455
- package/dist/plugins-Dhit-VHt.js +0 -453
- package/dist/plugins-cli-BwuvKtN-.js +0 -798
- package/dist/plugins-cli-D34k2VsI.js +0 -793
- package/dist/ports-DrruB2fK.js +0 -370
- package/dist/ports-GT1yV-Tg.js +0 -96
- package/dist/ports-NPqtlfp0.js +0 -316
- package/dist/ports-QMI4-F9m.js +0 -96
- package/dist/program-C5ukTU6N.js +0 -244
- package/dist/program-context-D55P0vBV.js +0 -474
- package/dist/progress-CBkSaM6z.js +0 -124
- package/dist/prompt-Bllj1dhc.js +0 -21
- package/dist/prompt-select-styled-WStiI-bz.js +0 -1647
- package/dist/prompt-select-styled-ram-aXWu.js +0 -1650
- package/dist/prompt-style-DVEm3BZW.js +0 -9
- package/dist/provider-dispatcher-epFKwpGK.js +0 -659
- package/dist/provider-dispatcher-vEBMmwZ0.js +0 -660
- package/dist/push-apns-C0LyG-WB.js +0 -713
- package/dist/push-apns-DuG95AKC.js +0 -711
- package/dist/pw-ai-TygsEDgY.js +0 -1906
- package/dist/pw-ai-eS0sIkZo.js +0 -1910
- package/dist/qr-cli-B8sYhugo.js +0 -352
- package/dist/qr-cli-yP8i4Iv1.js +0 -347
- package/dist/redact-eZq1uwNK.js +0 -191
- package/dist/redact-snapshot-gOLgfKp3.js +0 -2028
- package/dist/redact-snapshot-uT-CXbM8.js +0 -2028
- package/dist/register.agent-CSoigVGq.js +0 -1043
- package/dist/register.agent-GZLrbUPm.js +0 -286
- package/dist/register.configure-CXpiRohq.js +0 -124
- package/dist/register.configure-RaqiHe5L.js +0 -130
- package/dist/register.import-Bs-UkOs-.js +0 -27
- package/dist/register.import-DLng8g-e.js +0 -30
- package/dist/register.maintenance-B-ZLQ56Y.js +0 -494
- package/dist/register.maintenance-Bjr_SmG9.js +0 -497
- package/dist/register.message-BCQ8Vg4O.js +0 -686
- package/dist/register.message-ChhiSr7g.js +0 -681
- package/dist/register.onboard-DJCqNufv.js +0 -257
- package/dist/register.onboard-jlxjsrv6.js +0 -262
- package/dist/register.setup-C-sdixz5.js +0 -114
- package/dist/register.setup-Dwpe4ArC.js +0 -109
- package/dist/register.status-health-sessions-BWFRHBCZ.js +0 -669
- package/dist/register.status-health-sessions-D7noMz9y.js +0 -423
- package/dist/register.subclis-DFI5u4a6.js +0 -267
- package/dist/replies-Bzcj-R8d.js +0 -136
- package/dist/replies-uvTI-4lg.js +0 -136
- package/dist/reply-B9qz9Wwk.js +0 -13897
- package/dist/reply-CmGAXQKc.js +0 -13900
- package/dist/reply-directives-Be97YiyM.js +0 -182
- package/dist/reply-directives-DsLughUT.js +0 -182
- package/dist/reply-payloads-DW0YgT82.js +0 -527
- package/dist/reply-prefix-BzoT8h8o.js +0 -38
- package/dist/reply-prefix-CSaiVnkC.js +0 -38
- package/dist/resolve-route-2P40JKXk.js +0 -249
- package/dist/resolve-route-_CwEKLq6.js +0 -249
- package/dist/response-prefix-template-BAlvtSjL.js +0 -136
- package/dist/response-prefix-template-D-tls8tI.js +0 -136
- package/dist/retry-B042l5UJ.js +0 -77
- package/dist/retry-BhuXOEVR.js +0 -77
- package/dist/run-main-B-O5ZtbU.js +0 -320
- package/dist/runner-DGkTSlOS.js +0 -2294
- package/dist/runner-hs4uxAUP.js +0 -2294
- package/dist/runtime-DJNp29jv.js +0 -94
- package/dist/runtime-guard-DZ_xuCc4.js +0 -60
- package/dist/secure-random-DTcQnwrI.js +0 -44
- package/dist/security-cli-1iY1lW6F.js +0 -484
- package/dist/security-cli-BuiPPQYU.js +0 -478
- package/dist/send-3lgWtHHf.js +0 -349
- package/dist/send-6l2S1bcr.js +0 -11
- package/dist/send-9NV7sSlD.js +0 -2245
- package/dist/send-B0TcjZUD.js +0 -1778
- package/dist/send-Bb6K_10X.js +0 -2245
- package/dist/send-BzN7X1Om.js +0 -374
- package/dist/send-CLrRM0El.js +0 -426
- package/dist/send-Caz-txXK.js +0 -492
- package/dist/send-DJEr4rP6.js +0 -547
- package/dist/send-DJiDHXsu.js +0 -349
- package/dist/send-DOjg7kJj.js +0 -1775
- package/dist/send-DVXOiKT4.js +0 -1174
- package/dist/send-Dc_K995l.js +0 -547
- package/dist/send-Dh6d3CLl.js +0 -332
- package/dist/send-iPAfbiYM.js +0 -492
- package/dist/send-pwe9Gu8e.js +0 -29
- package/dist/server-B0IC-Osg.js +0 -205
- package/dist/server-MccRxMpb.js +0 -200
- package/dist/server-lifecycle-C_0CfoP7.js +0 -2437
- package/dist/server-lifecycle-IKdGw1kM.js +0 -2437
- package/dist/server-node-events-Czr2gXp_.js +0 -393
- package/dist/server-node-events-DFG6cXud.js +0 -398
- package/dist/service-Bjqii5nW.js +0 -670
- package/dist/service-fp29z5Ww.js +0 -670
- package/dist/session-DBL5nHDy.js +0 -170
- package/dist/session-cost-usage-DX09eTPU.js +0 -627
- package/dist/session-cost-usage-yYi525j3.js +0 -627
- package/dist/session-dirs-Cj5xi7zX.js +0 -947
- package/dist/session-dirs-DdF6TDsE.js +0 -947
- package/dist/session-utils-C7BtKlun.js +0 -625
- package/dist/session-utils-CLe1dano.js +0 -625
- package/dist/session-xKIW6gL2.js +0 -170
- package/dist/sessions-C65iUuN9.js +0 -2593
- package/dist/sessions-DjZ9IshB.js +0 -252
- package/dist/ssrf-Ck9HDZpv.js +0 -183
- package/dist/ssrf-m7kFIobZ.js +0 -183
- package/dist/status-C6ghjxvX.js +0 -2072
- package/dist/status-D-qTB8aZ.js +0 -2068
- package/dist/status.update-C55QM2xs.js +0 -79
- package/dist/status.update-CBmPXwYN.js +0 -79
- package/dist/store-Bjk6rTC_.js +0 -53
- package/dist/store-C3tOpizT.js +0 -64
- package/dist/store-uRA67h-o.js +0 -2595
- package/dist/store-v3P-OWhi.js +0 -64
- package/dist/subagent-registry-BTG1aAZ8.js +0 -4860
- package/dist/subagent-registry-CoclNL5c.js +0 -4858
- package/dist/subsystem-COd61u0P.js +0 -1139
- package/dist/subsystem-D9ZpRKFP.js +0 -1079
- package/dist/system-cli-C__5QOMX.js +0 -70
- package/dist/system-cli-Dr4XoVTq.js +0 -75
- package/dist/systemd-DSnlM3jX.js +0 -547
- package/dist/systemd-TfK8GuTx.js +0 -547
- package/dist/systemd-linger-Axnc1xCb.js +0 -75
- package/dist/systemd-linger-_0_-RY4v.js +0 -75
- package/dist/table-DPTzZyhu.js +0 -279
- package/dist/tables-BQ-CvUfT.js +0 -55
- package/dist/tables-D3a9iSU1.js +0 -55
- package/dist/tables-D3zdgEuK.js +0 -55
- package/dist/tailnet-CEudzG0i.js +0 -40
- package/dist/tailnet-PnMrjwGT.js +0 -40
- package/dist/tailscale-DTATQxAG.js +0 -230
- package/dist/tailscale-Dbyahx0J.js +0 -230
- package/dist/targets-B_0Y1i-1.js +0 -2173
- package/dist/targets-CMhBAn87.js +0 -120
- package/dist/targets-CTmhieRB.js +0 -650
- package/dist/targets-CcTME3bp.js +0 -46
- package/dist/targets-DfaVEd_u.js +0 -220
- package/dist/targets-DtiQgjEL.js +0 -2172
- package/dist/targets-DyybKefq.js +0 -53
- package/dist/targets-rDolm5YS.js +0 -650
- package/dist/tokens-DzFOtLlW.js +0 -21
- package/dist/tool-display-Br6mwaJc.js +0 -785
- package/dist/tool-display-sgNwLOBj.js +0 -785
- package/dist/tool-images-BNfIJ_Kj.js +0 -263
- package/dist/tool-images-kloBqxqK.js +0 -263
- package/dist/trash-DPi0aCCQ.js +0 -125
- package/dist/trash-D_Jd_yQZ.js +0 -125
- package/dist/tui-BSDCI2hh.js +0 -3392
- package/dist/tui-DT7hLOBk.js +0 -3392
- package/dist/tui-cli-DUWvLaoG.js +0 -58
- package/dist/tui-cli-Dn2iXQTO.js +0 -63
- package/dist/update-Bgl3Pk2N.js +0 -349
- package/dist/update-CFPFib4P.js +0 -349
- package/dist/update-cli-DSDSQ2Xi.js +0 -1373
- package/dist/update-cli-DYR_7NLy.js +0 -1370
- package/dist/usage-CS1zeIan.js +0 -5279
- package/dist/utils-LBKvDoPx.js +0 -631
- package/dist/web-BECD5Akw.js +0 -70
- package/dist/web-D4oENnAL.js +0 -3065
- package/dist/web-KP-TI2sO.js +0 -76
- package/dist/webhooks-cli-BqoG_i-D.js +0 -328
- package/dist/webhooks-cli-Ddu7dfdE.js +0 -333
- package/dist/whatsapp-actions-BZLIjQ8J.js +0 -122
- package/dist/whatsapp-actions-KCc1vHN5.js +0 -128
- package/dist/widearea-dns-DSoaA-eH.js +0 -127
- package/dist/workspace-4EaHHEWi.js +0 -447
- package/dist/workspace-B_1t_yq3.js +0 -449
- /package/dist/{account-lookup-0KDSp5Mj.js → account-lookup-C0ndrpt-.js} +0 -0
- /package/dist/{account-lookup-zvANGr2x.js → account-lookup-CIY_RKhi.js} +0 -0
- /package/dist/{api-BeQMq2iS.js → api-BE4ZCWWB.js} +0 -0
- /package/dist/{api-CxX8-gGz.js → api-wsk9zRVi.js} +0 -0
- /package/dist/{argv-Co-b9Zsc.js → argv-BY8EVMTP.js} +0 -0
- /package/dist/{brew-DbSbN8sD.js → brew-CmTYeZk1.js} +0 -0
- /package/dist/{brew-C4zKZsHX.js → brew-V4lMBeE3.js} +0 -0
- /package/dist/{chat-type-CYPyHAj-.js → chat-type-BP9akbag.js} +0 -0
- /package/dist/{chat-type-DKb2TlGZ.js → chat-type-CH3W-zKy.js} +0 -0
- /package/dist/{cleanup-utils-CwQvD73q.js → cleanup-utils-ZC2zvntc.js} +0 -0
- /package/dist/{cli-name-BicfmwQX.js → cli-name-BZsYSp9l.js} +0 -0
- /package/dist/{cli-name-C6rJGl18.js → cli-name-CRe5Ow_t.js} +0 -0
- /package/dist/{cli-utils-BhXbz2UF.js → cli-utils-BUOtyfnU.js} +0 -0
- /package/dist/{cli-utils-DZe_rVkZ.js → cli-utils-CGB3cBZm.js} +0 -0
- /package/dist/{client-C61M8zI3.js → client-9dK56xly.js} +0 -0
- /package/dist/{client-DdpmATKq.js → client-D-R1YdRD.js} +0 -0
- /package/dist/{command-options-C4paWSGf.js → command-options-CnHA4TzR.js} +0 -0
- /package/dist/{command-options-CA30lfLK.js → command-options-D2nN4AXX.js} +0 -0
- /package/dist/{config-eval-CjGZtLwx.js → config-eval-BQIR-wSg.js} +0 -0
- /package/dist/{config-eval-H_wlEYIG.js → config-eval-Bh82JoXK.js} +0 -0
- /package/dist/{constants-ChptG3d7.js → constants-C7j1VA2S.js} +0 -0
- /package/dist/{constants-DY6b-_Wl.js → constants-DoYLsBmv.js} +0 -0
- /package/dist/{credentials-BHWUBHMd.js → credentials-C_RoJFmK.js} +0 -0
- /package/dist/{credentials-DFsi1_e8.js → credentials-DM_Dj0m8.js} +0 -0
- /package/dist/{daemon-runtime-CMnbwryP.js → daemon-runtime-9oDBR7YW.js} +0 -0
- /package/dist/{daemon-runtime-CvqE4ysg.js → daemon-runtime-CzFI2dPw.js} +0 -0
- /package/dist/{dangerous-name-matching-BzmiLXmA.js → dangerous-name-matching-BlTBBZns.js} +0 -0
- /package/dist/{dangerous-name-matching-DaVRgwer.js → dangerous-name-matching-CSq9sJDG.js} +0 -0
- /package/dist/{dangerous-tools-BOLoCRv4.js → dangerous-tools-BRmbBvRf.js} +0 -0
- /package/dist/{dangerous-tools-Baq7Q-i6.js → dangerous-tools-D4jtl72G.js} +0 -0
- /package/dist/{fetch-timeout-DTIN7CGM.js → fetch-timeout-CytN1wiO.js} +0 -0
- /package/dist/{fetch-timeout-DoySHqfO.js → fetch-timeout-DBRRPNBi.js} +0 -0
- /package/dist/{file-identity-BxlKD8Ys.js → file-identity-CeRK5CJC.js} +0 -0
- /package/dist/{format-duration-CqUERz51.js → format-duration-B-Uv5nOi.js} +0 -0
- /package/dist/{format-duration-Ct-yiwkS.js → format-duration-D1M3Zxu6.js} +0 -0
- /package/dist/{format-relative-79_Y1n2Y.js → format-relative-Czf5fUjn.js} +0 -0
- /package/dist/{format-relative-CxLpEQOX.js → format-relative-zwkkXJvs.js} +0 -0
- /package/dist/{health-format-B_QRD8Si.js → health-format-DF54wvUU.js} +0 -0
- /package/dist/{heartbeat-wake-LGEgcXjs.js → heartbeat-wake-CvHncCjP.js} +0 -0
- /package/dist/{heartbeat-wake-Y97geucO.js → heartbeat-wake-DLxQm6-U.js} +0 -0
- /package/dist/{help-format-NNm_Ov4H.js → help-format-CJQ7APRn.js} +0 -0
- /package/dist/{helpers-BAsMXprO.js → helpers-BER76F_2.js} +0 -0
- /package/dist/{helpers-DLgbkcEn.js → helpers-n2CtWpm9.js} +0 -0
- /package/dist/{input-provenance-Bn6thJNm.js → input-provenance-gIfDn1ki.js} +0 -0
- /package/dist/{input-provenance-xUsSMOsz.js → input-provenance-wkso1o5V.js} +0 -0
- /package/dist/{ip-C9q3Oq20.js → ip-D4VG5EJO.js} +0 -0
- /package/dist/{ip-D0zgNmBV.js → ip-MwCwRA7c.js} +0 -0
- /package/dist/{is-main-DN8-sNR5.js → is-main-BmHYGRhd.js} +0 -0
- /package/dist/{json-file-B7l5-Xhr.js → json-file-BW22hGtf.js} +0 -0
- /package/dist/{json-file-ChO_R9yh.js → json-file-DwRAfAAy.js} +0 -0
- /package/dist/{json-files-CmpYSF4G.js → json-files-Dy52honG.js} +0 -0
- /package/dist/{lanes-ByWMUgrz.js → lanes-1CBKdsiR.js} +0 -0
- /package/dist/{lanes-cHJ5arWg.js → lanes-DqVYfPRG.js} +0 -0
- /package/dist/{links-Bz4V7R_p.js → links-CwTlzaPe.js} +0 -0
- /package/dist/{location-DBWCGNLq.js → location-50gaJF5Z.js} +0 -0
- /package/dist/{location-GbZ0bBRU.js → location-Qo8Ii1zo.js} +0 -0
- /package/dist/{logger-DyL5G2DO.js → logger-B8BE0PyS.js} +0 -0
- /package/dist/{logger-BWMPnILd.js → logger-CPvz-aPM.js} +0 -0
- /package/dist/{logger-GvipVDfh.js → logger-cL0D2DCr.js} +0 -0
- /package/dist/{logging-D8-Kozjc.js → logging-DTEoeoa3.js} +0 -0
- /package/dist/{mutable-allowlist-detectors-DiZDtmlZ.js → mutable-allowlist-detectors-BXE7Hr7F.js} +0 -0
- /package/dist/{mutable-allowlist-detectors-U5ThQr9V.js → mutable-allowlist-detectors-CtKavajp.js} +0 -0
- /package/dist/{parse-log-line-enq8pduH.js → parse-log-line-GisaZn5H.js} +0 -0
- /package/dist/{parse-log-line-mz9TG6ig.js → parse-log-line-ZsbwG_u7.js} +0 -0
- /package/dist/{parse-timeout-BMP8a0_a.js → parse-timeout-BpphuwYl.js} +0 -0
- /package/dist/{parse-timeout-CDkco8kd.js → parse-timeout-CE6BjmGU.js} +0 -0
- /package/dist/plugin-sdk/{agents → auth}/api-key-rotation.d.ts +0 -0
- /package/dist/plugin-sdk/{media-understanding → stt}/providers/deepgram/audio.d.ts +0 -0
- /package/dist/plugin-sdk/{media-understanding → stt}/providers/google/audio.d.ts +0 -0
- /package/dist/plugin-sdk/{media-understanding → stt}/providers/google/inline-data.d.ts +0 -0
- /package/dist/plugin-sdk/{media-understanding → stt}/providers/openai/audio.d.ts +0 -0
- /package/dist/plugin-sdk/{media-understanding → stt}/providers/shared.d.ts +0 -0
- /package/dist/{plugins-allowlist-BbTQ5Z2k.js → plugins-allowlist-A38nxBRG.js} +0 -0
- /package/dist/{plugins-allowlist-C20oaESO.js → plugins-allowlist-D2tS9tcu.js} +0 -0
- /package/dist/{polls-B0CCBDeR.js → polls-BLyT08ZI.js} +0 -0
- /package/dist/{polls-CwwHzYBM.js → polls-BmymsJEe.js} +0 -0
- /package/dist/{ports-lsof-Wteul3ju.js → ports-lsof-CDyv5GJd.js} +0 -0
- /package/dist/{process-scoped-map-CV9kDvfG.js → process-scoped-map-BCJR56ZB.js} +0 -0
- /package/dist/{process-scoped-map-PEvnG75N.js → process-scoped-map-Cb1EHPyN.js} +0 -0
- /package/dist/{program-context-jqeI5alP.js → program-context-DlXnmuB7.js} +0 -0
- /package/dist/{progress-C1kUfYL-.js → progress-DRLmcFiG.js} +0 -0
- /package/dist/{prompt-Yn2yClg1.js → prompt-BRGfic91.js} +0 -0
- /package/dist/{prompt-style-DjEYC_s-.js → prompt-style-CUuA6OCy.js} +0 -0
- /package/dist/{provider-utils-3JTMJroG.js → provider-utils-C9kBVF1f.js} +0 -0
- /package/dist/{provider-utils-FaBmofiq.js → provider-utils-DiLhkKQp.js} +0 -0
- /package/dist/{proxy-DL3MD6-P.js → proxy-BMJL0Qog.js} +0 -0
- /package/dist/{proxy-DpNv2cSV.js → proxy-D-qGA1vm.js} +0 -0
- /package/dist/{pw-ai-state-CGfLv6nV.js → pw-ai-state--TxTVwRW.js} +0 -0
- /package/dist/{pw-ai-state-Dynx20hr.js → pw-ai-state-CwXeO5d0.js} +0 -0
- /package/dist/{redact-Dx1Fue21.js → redact-BW8tobyp.js} +0 -0
- /package/dist/{redact-identifier-BTIWtaa-.js → redact-identifier-BJOQDEj0.js} +0 -0
- /package/dist/{redact-identifier-CAagcfWA.js → redact-identifier-Bv5SUUw-.js} +0 -0
- /package/dist/{remoteclaw-root-C2HV2VeC.js → remoteclaw-root-BfPjgewe.js} +0 -0
- /package/dist/{remoteclaw-root-DybYl8PL.js → remoteclaw-root-E4-hmb4E.js} +0 -0
- /package/dist/{render-CCLsW6Lz.js → render-BhKzKdV0.js} +0 -0
- /package/dist/{render-uf6PvGMV.js → render-e7fENCYH.js} +0 -0
- /package/dist/{retry-DnqPAqWp.js → retry-BWv_fy4u.js} +0 -0
- /package/dist/{runtime-guard-U-ewY_QH.js → runtime-guard-Bhx-pb8_.js} +0 -0
- /package/dist/{secret-equal-BbHdTtqY.js → secret-equal-D6AoXne1.js} +0 -0
- /package/dist/{secret-equal-CXJEZiWb.js → secret-equal-DLnUuWM3.js} +0 -0
- /package/dist/{secure-random-CS2mSdTn.js → secure-random-CJtykx_p.js} +0 -0
- /package/dist/{secure-random-_dzDDlFo.js → secure-random-CRVHgtmO.js} +0 -0
- /package/dist/{session-key-5YLnn_qf.js → session-key-BF-9YzxC.js} +0 -0
- /package/dist/{session-key-C2n-VILA.js → session-key-CgKWfjoZ.js} +0 -0
- /package/dist/{stagger-BXv_apuy.js → stagger--wvODnNe.js} +0 -0
- /package/dist/{stagger-MI9gd2rQ.js → stagger-BLmTO4cK.js} +0 -0
- /package/dist/{status-BmtCS3T1.js → status-1zVD-Clq.js} +0 -0
- /package/dist/{status-BrwHRn2B.js → status-BtRY0nXQ.js} +0 -0
- /package/dist/{strip-inbound-meta-DjKcSFaW.js → strip-inbound-meta-zmUXypSS.js} +0 -0
- /package/dist/{strip-inbound-meta-jy3bkUab.js → strip-inbound-meta-zqtN9FTK.js} +0 -0
- /package/dist/{table-C1rdyYl9.js → table-On3hkCqi.js} +0 -0
- /package/dist/{target-errors-BDpPcwh5.js → target-errors-DJVRKFcU.js} +0 -0
- /package/dist/{target-errors-DdIAPcMM.js → target-errors-GZXDqlUu.js} +0 -0
- /package/dist/{targets-C-2xwh9f.js → targets-B46m7u5J.js} +0 -0
- /package/dist/{targets-D-qLBpTA.js → targets-B_d_1z3N.js} +0 -0
- /package/dist/{targets-UncQvCVs.js → targets-D01MJGnh.js} +0 -0
- /package/dist/{targets-BMenhVHg.js → targets-D3r6Zgic.js} +0 -0
- /package/dist/{text-format-BQ3z_OXA.js → text-format-DarxU3JH.js} +0 -0
- /package/dist/{text-format-oWqzVmah.js → text-format-Ds92M9UT.js} +0 -0
- /package/dist/{tokens-B-jmvNR9.js → tokens-Dw7ZdYwT.js} +0 -0
- /package/dist/{usage-BdhBT0Vz.js → usage-BIzKZ5dT.js} +0 -0
- /package/dist/{usage-BtQcAnf6.js → usage-BvZOzIC7.js} +0 -0
- /package/dist/{usage-format-C3mNLfhI.js → usage-format-CmniSPCG.js} +0 -0
- /package/dist/{usage-format-DAaPzr_z.js → usage-format-D_KQYQ-w.js} +0 -0
- /package/dist/{widearea-dns-CsmBVbez.js → widearea-dns-D01FFYZ8.js} +0 -0
- /package/dist/{workspace-BzPeZDew.js → workspace-BJCKO8Ns.js} +0 -0
- /package/dist/{workspace-DkGLVfOl.js → workspace-BisvA9oA.js} +0 -0
- /package/dist/{wsl-B_sPlzWw.js → wsl-PDLKeX04.js} +0 -0
- /package/dist/{wsl-BCnYV9O0.js → wsl-kFaeW76c.js} +0 -0
|
@@ -1,2136 +0,0 @@
|
|
|
1
|
-
import { M as shouldLogVerbose, R as getChildLogger, S as toWhatsappJid, d as jidToE164, f as normalizeE164, g as resolveJidToE164, k as logVerbose, r as clamp, u as isSelfChatMode, x as sleep } from "./utils-LBKvDoPx.js";
|
|
2
|
-
import { A as buildMentionRegexes, N as normalizeMentionText, Q as parseActivationCommand, Z as normalizeGroupActivation, _ as shouldComputeCommandAuthorized, h as hasControlCommand, t as getReplyFromConfig } from "./reply-CmGAXQKc.js";
|
|
3
|
-
import { t as createSubsystemLogger } from "./subsystem-COd61u0P.js";
|
|
4
|
-
import { n as defaultRuntime } from "./runtime-DJNp29jv.js";
|
|
5
|
-
import { a as buildGroupHistoryKey, n as DEFAULT_MAIN_KEY, r as buildAgentMainSessionKey, s as normalizeAgentId } from "./session-key-5YLnn_qf.js";
|
|
6
|
-
import { i as loadConfig } from "./config-ChYRSJQt.js";
|
|
7
|
-
import { c as resolveChannelGroupPolicy, l as resolveChannelGroupRequireMention } from "./dock-FtQwUHXE.js";
|
|
8
|
-
import { t as finalizeInboundContext } from "./inbound-context-CPkkQW0i.js";
|
|
9
|
-
import { f as registerUnhandledRejectionHandler } from "./runner-hs4uxAUP.js";
|
|
10
|
-
import { t as getAgentScopedMediaLocalRoots } from "./local-roots-B6rSCu4U.js";
|
|
11
|
-
import { t as formatCliCommand } from "./command-format-DgXcqxBt.js";
|
|
12
|
-
import { i as resolveWhatsAppAccount, p as readWebSelfId, s as getWebAuthAgeMs } from "./accounts-BFy_Z3od.js";
|
|
13
|
-
import { h as enqueueSystemEvent } from "./targets-B_0Y1i-1.js";
|
|
14
|
-
import { i as readChannelAllowFromStore, s as upsertChannelPairingRequest } from "./pairing-store-5qapT5-t.js";
|
|
15
|
-
import { m as resolveStorePath } from "./chat-envelope-el7Uo-Fe.js";
|
|
16
|
-
import { a as recordSessionMetaFromInbound, c as updateLastRoute, i as readSessionUpdatedAt, n as loadSessionStore, rt as resolveGroupSessionKey } from "./store-uRA67h-o.js";
|
|
17
|
-
import { c as resolveIdentityNamePrefix, l as resolveMessagePrefix } from "./response-prefix-template-BAlvtSjL.js";
|
|
18
|
-
import { n as recordChannelActivity } from "./channel-activity-BaCNOZpP.js";
|
|
19
|
-
import { i as loadWebMedia } from "./ir-BvKdMuSP.js";
|
|
20
|
-
import { c as resolveChunkMode, i as chunkMarkdownTextWithMode, l as resolveTextChunkLimit } from "./chunk-D0Y_w4oX.js";
|
|
21
|
-
import { n as resolveMarkdownTableMode } from "./markdown-tables-PJUMrC4T.js";
|
|
22
|
-
import { t as convertMarkdownTables } from "./tables-BQ-CvUfT.js";
|
|
23
|
-
import { i as markdownToWhatsApp, r as sendReactionWhatsApp } from "./outbound-ZnVvUReT.js";
|
|
24
|
-
import { r as setActiveWebListener } from "./active-listener-VzhWW8W6.js";
|
|
25
|
-
import { C as computeBackoff, S as resolveInboundDebounceMs, _ as buildHistoryContextFromEntries, a as formatInboundEnvelope, b as recordPendingHistoryEntryIfEnabled, c as resolveMentionGating, g as DEFAULT_GROUP_HISTORY_LIMIT, h as warnMissingProviderGroupPolicyFallbackOnce, m as resolveOpenProviderRuntimeGroupPolicy, p as resolveDefaultGroupPolicy, r as shouldAckReactionForWhatsApp, s as resolveEnvelopeFormatOptions, u as buildPairingReply, w as sleepWithAbort, x as createInboundDebouncer } from "./ack-reactions-C1hk85VE.js";
|
|
26
|
-
import { i as waitForWaConnection, n as formatError, r as getStatusCode, t as createWaSocket } from "./session-xKIW6gL2.js";
|
|
27
|
-
import { n as formatDurationPrecise } from "./format-duration-Ct-yiwkS.js";
|
|
28
|
-
import { n as resolveAgentRoute, t as buildAgentSessionKey } from "./resolve-route-2P40JKXk.js";
|
|
29
|
-
import { l as createDedupeCache, t as dispatchReplyWithBufferedBlockDispatcher } from "./provider-dispatcher-vEBMmwZ0.js";
|
|
30
|
-
import { n as toLocationContext, t as formatLocationText } from "./location-DBWCGNLq.js";
|
|
31
|
-
import { n as saveMediaBuffer } from "./store-C3tOpizT.js";
|
|
32
|
-
import { t as createReplyPrefixOptions } from "./reply-prefix-BzoT8h8o.js";
|
|
33
|
-
import { randomUUID } from "node:crypto";
|
|
34
|
-
import { DisconnectReason, downloadMediaMessage, extractMessageContent, getContentType, isJidGroup, normalizeMessageContent } from "@whiskeysockets/baileys";
|
|
35
|
-
|
|
36
|
-
//#region src/web/auto-reply/constants.ts
|
|
37
|
-
const DEFAULT_WEB_MEDIA_BYTES = 5 * 1024 * 1024;
|
|
38
|
-
|
|
39
|
-
//#endregion
|
|
40
|
-
//#region src/web/reconnect.ts
|
|
41
|
-
const DEFAULT_HEARTBEAT_SECONDS = 60;
|
|
42
|
-
const DEFAULT_RECONNECT_POLICY = {
|
|
43
|
-
initialMs: 2e3,
|
|
44
|
-
maxMs: 3e4,
|
|
45
|
-
factor: 1.8,
|
|
46
|
-
jitter: .25,
|
|
47
|
-
maxAttempts: 12
|
|
48
|
-
};
|
|
49
|
-
function resolveHeartbeatSeconds(cfg, overrideSeconds) {
|
|
50
|
-
const candidate = overrideSeconds ?? cfg.web?.heartbeatSeconds;
|
|
51
|
-
if (typeof candidate === "number" && candidate > 0) return candidate;
|
|
52
|
-
return DEFAULT_HEARTBEAT_SECONDS;
|
|
53
|
-
}
|
|
54
|
-
function resolveReconnectPolicy(cfg, overrides) {
|
|
55
|
-
const reconnectOverrides = cfg.web?.reconnect ?? {};
|
|
56
|
-
const overrideConfig = overrides ?? {};
|
|
57
|
-
const merged = {
|
|
58
|
-
...DEFAULT_RECONNECT_POLICY,
|
|
59
|
-
...reconnectOverrides,
|
|
60
|
-
...overrideConfig
|
|
61
|
-
};
|
|
62
|
-
merged.initialMs = Math.max(250, merged.initialMs);
|
|
63
|
-
merged.maxMs = Math.max(merged.initialMs, merged.maxMs);
|
|
64
|
-
merged.factor = clamp(merged.factor, 1.1, 10);
|
|
65
|
-
merged.jitter = clamp(merged.jitter, 0, 1);
|
|
66
|
-
merged.maxAttempts = Math.max(0, Math.floor(merged.maxAttempts));
|
|
67
|
-
return merged;
|
|
68
|
-
}
|
|
69
|
-
function newConnectionId() {
|
|
70
|
-
return randomUUID();
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
//#endregion
|
|
74
|
-
//#region src/web/auto-reply/loggers.ts
|
|
75
|
-
const whatsappLog = createSubsystemLogger("gateway/channels/whatsapp");
|
|
76
|
-
const whatsappInboundLog = whatsappLog.child("inbound");
|
|
77
|
-
const whatsappOutboundLog = whatsappLog.child("outbound");
|
|
78
|
-
const whatsappHeartbeatLog = whatsappLog.child("heartbeat");
|
|
79
|
-
|
|
80
|
-
//#endregion
|
|
81
|
-
//#region src/cli/wait.ts
|
|
82
|
-
function waitForever() {
|
|
83
|
-
setInterval(() => {}, 1e6).unref();
|
|
84
|
-
return new Promise(() => {});
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
//#endregion
|
|
88
|
-
//#region src/web/inbound/dedupe.ts
|
|
89
|
-
const recentInboundMessages = createDedupeCache({
|
|
90
|
-
ttlMs: 20 * 6e4,
|
|
91
|
-
maxSize: 5e3
|
|
92
|
-
});
|
|
93
|
-
function isRecentInboundMessage(key) {
|
|
94
|
-
return recentInboundMessages.check(key);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
//#endregion
|
|
98
|
-
//#region src/web/vcard.ts
|
|
99
|
-
const ALLOWED_VCARD_KEYS = new Set([
|
|
100
|
-
"FN",
|
|
101
|
-
"N",
|
|
102
|
-
"TEL"
|
|
103
|
-
]);
|
|
104
|
-
function parseVcard(vcard) {
|
|
105
|
-
if (!vcard) return { phones: [] };
|
|
106
|
-
const lines = vcard.split(/\r?\n/);
|
|
107
|
-
let nameFromN;
|
|
108
|
-
let nameFromFn;
|
|
109
|
-
const phones = [];
|
|
110
|
-
for (const rawLine of lines) {
|
|
111
|
-
const line = rawLine.trim();
|
|
112
|
-
if (!line) continue;
|
|
113
|
-
const colonIndex = line.indexOf(":");
|
|
114
|
-
if (colonIndex === -1) continue;
|
|
115
|
-
const key = line.slice(0, colonIndex).toUpperCase();
|
|
116
|
-
const rawValue = line.slice(colonIndex + 1).trim();
|
|
117
|
-
if (!rawValue) continue;
|
|
118
|
-
const baseKey = normalizeVcardKey(key);
|
|
119
|
-
if (!baseKey || !ALLOWED_VCARD_KEYS.has(baseKey)) continue;
|
|
120
|
-
const value = cleanVcardValue(rawValue);
|
|
121
|
-
if (!value) continue;
|
|
122
|
-
if (baseKey === "FN" && !nameFromFn) {
|
|
123
|
-
nameFromFn = normalizeVcardName(value);
|
|
124
|
-
continue;
|
|
125
|
-
}
|
|
126
|
-
if (baseKey === "N" && !nameFromN) {
|
|
127
|
-
nameFromN = normalizeVcardName(value);
|
|
128
|
-
continue;
|
|
129
|
-
}
|
|
130
|
-
if (baseKey === "TEL") {
|
|
131
|
-
const phone = normalizeVcardPhone(value);
|
|
132
|
-
if (phone) phones.push(phone);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
return {
|
|
136
|
-
name: nameFromFn ?? nameFromN,
|
|
137
|
-
phones
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
function normalizeVcardKey(key) {
|
|
141
|
-
const [primary] = key.split(";");
|
|
142
|
-
if (!primary) return;
|
|
143
|
-
const segments = primary.split(".");
|
|
144
|
-
return segments[segments.length - 1] || void 0;
|
|
145
|
-
}
|
|
146
|
-
function cleanVcardValue(value) {
|
|
147
|
-
return value.replace(/\\n/gi, " ").replace(/\\,/g, ",").replace(/\\;/g, ";").trim();
|
|
148
|
-
}
|
|
149
|
-
function normalizeVcardName(value) {
|
|
150
|
-
return value.replace(/;/g, " ").replace(/\s+/g, " ").trim();
|
|
151
|
-
}
|
|
152
|
-
function normalizeVcardPhone(value) {
|
|
153
|
-
const trimmed = value.trim();
|
|
154
|
-
if (!trimmed) return "";
|
|
155
|
-
if (trimmed.toLowerCase().startsWith("tel:")) return trimmed.slice(4).trim();
|
|
156
|
-
return trimmed;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
//#endregion
|
|
160
|
-
//#region src/web/inbound/extract.ts
|
|
161
|
-
function unwrapMessage$1(message) {
|
|
162
|
-
return normalizeMessageContent(message);
|
|
163
|
-
}
|
|
164
|
-
function extractContextInfo(message) {
|
|
165
|
-
if (!message) return;
|
|
166
|
-
const contentType = getContentType(message);
|
|
167
|
-
const candidate = contentType ? message[contentType] : void 0;
|
|
168
|
-
const contextInfo = candidate && typeof candidate === "object" && "contextInfo" in candidate ? candidate.contextInfo : void 0;
|
|
169
|
-
if (contextInfo) return contextInfo;
|
|
170
|
-
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;
|
|
171
|
-
if (fallback) return fallback;
|
|
172
|
-
for (const value of Object.values(message)) {
|
|
173
|
-
if (!value || typeof value !== "object") continue;
|
|
174
|
-
if (!("contextInfo" in value)) continue;
|
|
175
|
-
const candidateContext = value.contextInfo;
|
|
176
|
-
if (candidateContext) return candidateContext;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
function extractMentionedJids(rawMessage) {
|
|
180
|
-
const message = unwrapMessage$1(rawMessage);
|
|
181
|
-
if (!message) return;
|
|
182
|
-
const flattened = [
|
|
183
|
-
message.extendedTextMessage?.contextInfo?.mentionedJid,
|
|
184
|
-
message.extendedTextMessage?.contextInfo?.quotedMessage?.extendedTextMessage?.contextInfo?.mentionedJid,
|
|
185
|
-
message.imageMessage?.contextInfo?.mentionedJid,
|
|
186
|
-
message.videoMessage?.contextInfo?.mentionedJid,
|
|
187
|
-
message.documentMessage?.contextInfo?.mentionedJid,
|
|
188
|
-
message.audioMessage?.contextInfo?.mentionedJid,
|
|
189
|
-
message.stickerMessage?.contextInfo?.mentionedJid,
|
|
190
|
-
message.buttonsResponseMessage?.contextInfo?.mentionedJid,
|
|
191
|
-
message.listResponseMessage?.contextInfo?.mentionedJid
|
|
192
|
-
].flatMap((arr) => arr ?? []).filter(Boolean);
|
|
193
|
-
if (flattened.length === 0) return;
|
|
194
|
-
return Array.from(new Set(flattened));
|
|
195
|
-
}
|
|
196
|
-
function extractText(rawMessage) {
|
|
197
|
-
const message = unwrapMessage$1(rawMessage);
|
|
198
|
-
if (!message) return;
|
|
199
|
-
const extracted = extractMessageContent(message);
|
|
200
|
-
const candidates = [message, extracted && extracted !== message ? extracted : void 0];
|
|
201
|
-
for (const candidate of candidates) {
|
|
202
|
-
if (!candidate) continue;
|
|
203
|
-
if (typeof candidate.conversation === "string" && candidate.conversation.trim()) return candidate.conversation.trim();
|
|
204
|
-
const extended = candidate.extendedTextMessage?.text;
|
|
205
|
-
if (extended?.trim()) return extended.trim();
|
|
206
|
-
const caption = candidate.imageMessage?.caption ?? candidate.videoMessage?.caption ?? candidate.documentMessage?.caption;
|
|
207
|
-
if (caption?.trim()) return caption.trim();
|
|
208
|
-
}
|
|
209
|
-
const contactPlaceholder = extractContactPlaceholder(message) ?? (extracted && extracted !== message ? extractContactPlaceholder(extracted) : void 0);
|
|
210
|
-
if (contactPlaceholder) return contactPlaceholder;
|
|
211
|
-
}
|
|
212
|
-
function extractMediaPlaceholder(rawMessage) {
|
|
213
|
-
const message = unwrapMessage$1(rawMessage);
|
|
214
|
-
if (!message) return;
|
|
215
|
-
if (message.imageMessage) return "<media:image>";
|
|
216
|
-
if (message.videoMessage) return "<media:video>";
|
|
217
|
-
if (message.audioMessage) return "<media:audio>";
|
|
218
|
-
if (message.documentMessage) return "<media:document>";
|
|
219
|
-
if (message.stickerMessage) return "<media:sticker>";
|
|
220
|
-
}
|
|
221
|
-
function extractContactPlaceholder(rawMessage) {
|
|
222
|
-
const message = unwrapMessage$1(rawMessage);
|
|
223
|
-
if (!message) return;
|
|
224
|
-
const contact = message.contactMessage ?? void 0;
|
|
225
|
-
if (contact) {
|
|
226
|
-
const { name, phones } = describeContact({
|
|
227
|
-
displayName: contact.displayName,
|
|
228
|
-
vcard: contact.vcard
|
|
229
|
-
});
|
|
230
|
-
return formatContactPlaceholder(name, phones);
|
|
231
|
-
}
|
|
232
|
-
const contactsArray = message.contactsArrayMessage?.contacts ?? void 0;
|
|
233
|
-
if (!contactsArray || contactsArray.length === 0) return;
|
|
234
|
-
return formatContactsPlaceholder(contactsArray.map((entry) => describeContact({
|
|
235
|
-
displayName: entry.displayName,
|
|
236
|
-
vcard: entry.vcard
|
|
237
|
-
})).map((entry) => formatContactLabel(entry.name, entry.phones)).filter((value) => Boolean(value)), contactsArray.length);
|
|
238
|
-
}
|
|
239
|
-
function describeContact(input) {
|
|
240
|
-
const displayName = (input.displayName ?? "").trim();
|
|
241
|
-
const parsed = parseVcard(input.vcard ?? void 0);
|
|
242
|
-
return {
|
|
243
|
-
name: displayName || parsed.name,
|
|
244
|
-
phones: parsed.phones
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
function formatContactPlaceholder(name, phones) {
|
|
248
|
-
const label = formatContactLabel(name, phones);
|
|
249
|
-
if (!label) return "<contact>";
|
|
250
|
-
return `<contact: ${label}>`;
|
|
251
|
-
}
|
|
252
|
-
function formatContactsPlaceholder(labels, total) {
|
|
253
|
-
const cleaned = labels.map((label) => label.trim()).filter(Boolean);
|
|
254
|
-
if (cleaned.length === 0) return `<contacts: ${total} ${total === 1 ? "contact" : "contacts"}>`;
|
|
255
|
-
const remaining = Math.max(total - cleaned.length, 0);
|
|
256
|
-
const suffix = remaining > 0 ? ` +${remaining} more` : "";
|
|
257
|
-
return `<contacts: ${cleaned.join(", ")}${suffix}>`;
|
|
258
|
-
}
|
|
259
|
-
function formatContactLabel(name, phones) {
|
|
260
|
-
const parts = [name, formatPhoneList(phones)].filter((value) => Boolean(value));
|
|
261
|
-
if (parts.length === 0) return;
|
|
262
|
-
return parts.join(", ");
|
|
263
|
-
}
|
|
264
|
-
function formatPhoneList(phones) {
|
|
265
|
-
const cleaned = phones?.map((phone) => phone.trim()).filter(Boolean) ?? [];
|
|
266
|
-
if (cleaned.length === 0) return;
|
|
267
|
-
const { shown, remaining } = summarizeList(cleaned, cleaned.length, 1);
|
|
268
|
-
const [primary] = shown;
|
|
269
|
-
if (!primary) return;
|
|
270
|
-
if (remaining === 0) return primary;
|
|
271
|
-
return `${primary} (+${remaining} more)`;
|
|
272
|
-
}
|
|
273
|
-
function summarizeList(values, total, maxShown) {
|
|
274
|
-
const shown = values.slice(0, maxShown);
|
|
275
|
-
return {
|
|
276
|
-
shown,
|
|
277
|
-
remaining: Math.max(total - shown.length, 0)
|
|
278
|
-
};
|
|
279
|
-
}
|
|
280
|
-
function extractLocationData(rawMessage) {
|
|
281
|
-
const message = unwrapMessage$1(rawMessage);
|
|
282
|
-
if (!message) return null;
|
|
283
|
-
const live = message.liveLocationMessage ?? void 0;
|
|
284
|
-
if (live) {
|
|
285
|
-
const latitudeRaw = live.degreesLatitude;
|
|
286
|
-
const longitudeRaw = live.degreesLongitude;
|
|
287
|
-
if (latitudeRaw != null && longitudeRaw != null) {
|
|
288
|
-
const latitude = Number(latitudeRaw);
|
|
289
|
-
const longitude = Number(longitudeRaw);
|
|
290
|
-
if (Number.isFinite(latitude) && Number.isFinite(longitude)) return {
|
|
291
|
-
latitude,
|
|
292
|
-
longitude,
|
|
293
|
-
accuracy: live.accuracyInMeters ?? void 0,
|
|
294
|
-
caption: live.caption ?? void 0,
|
|
295
|
-
source: "live",
|
|
296
|
-
isLive: true
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
const location = message.locationMessage ?? void 0;
|
|
301
|
-
if (location) {
|
|
302
|
-
const latitudeRaw = location.degreesLatitude;
|
|
303
|
-
const longitudeRaw = location.degreesLongitude;
|
|
304
|
-
if (latitudeRaw != null && longitudeRaw != null) {
|
|
305
|
-
const latitude = Number(latitudeRaw);
|
|
306
|
-
const longitude = Number(longitudeRaw);
|
|
307
|
-
if (Number.isFinite(latitude) && Number.isFinite(longitude)) {
|
|
308
|
-
const isLive = Boolean(location.isLive);
|
|
309
|
-
return {
|
|
310
|
-
latitude,
|
|
311
|
-
longitude,
|
|
312
|
-
accuracy: location.accuracyInMeters ?? void 0,
|
|
313
|
-
name: location.name ?? void 0,
|
|
314
|
-
address: location.address ?? void 0,
|
|
315
|
-
caption: location.comment ?? void 0,
|
|
316
|
-
source: isLive ? "live" : location.name || location.address ? "place" : "pin",
|
|
317
|
-
isLive
|
|
318
|
-
};
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
return null;
|
|
323
|
-
}
|
|
324
|
-
function describeReplyContext(rawMessage) {
|
|
325
|
-
const message = unwrapMessage$1(rawMessage);
|
|
326
|
-
if (!message) return null;
|
|
327
|
-
const contextInfo = extractContextInfo(message);
|
|
328
|
-
const quoted = normalizeMessageContent(contextInfo?.quotedMessage);
|
|
329
|
-
if (!quoted) return null;
|
|
330
|
-
const location = extractLocationData(quoted);
|
|
331
|
-
const locationText = location ? formatLocationText(location) : void 0;
|
|
332
|
-
let body = [extractText(quoted), locationText].filter(Boolean).join("\n").trim();
|
|
333
|
-
if (!body) body = extractMediaPlaceholder(quoted);
|
|
334
|
-
if (!body) {
|
|
335
|
-
const quotedType = quoted ? getContentType(quoted) : void 0;
|
|
336
|
-
logVerbose(`Quoted message missing extractable body${quotedType ? ` (type ${quotedType})` : ""}`);
|
|
337
|
-
return null;
|
|
338
|
-
}
|
|
339
|
-
const senderJid = contextInfo?.participant ?? void 0;
|
|
340
|
-
const senderE164 = senderJid ? jidToE164(senderJid) ?? senderJid : void 0;
|
|
341
|
-
const sender = senderE164 ?? "unknown sender";
|
|
342
|
-
return {
|
|
343
|
-
id: contextInfo?.stanzaId ? String(contextInfo.stanzaId) : void 0,
|
|
344
|
-
body,
|
|
345
|
-
sender,
|
|
346
|
-
senderJid,
|
|
347
|
-
senderE164
|
|
348
|
-
};
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
//#endregion
|
|
352
|
-
//#region src/web/inbound/access-control.ts
|
|
353
|
-
const PAIRING_REPLY_HISTORY_GRACE_MS = 3e4;
|
|
354
|
-
function resolveWhatsAppRuntimeGroupPolicy(params) {
|
|
355
|
-
return resolveOpenProviderRuntimeGroupPolicy({
|
|
356
|
-
providerConfigPresent: params.providerConfigPresent,
|
|
357
|
-
groupPolicy: params.groupPolicy,
|
|
358
|
-
defaultGroupPolicy: params.defaultGroupPolicy
|
|
359
|
-
});
|
|
360
|
-
}
|
|
361
|
-
async function checkInboundAccessControl(params) {
|
|
362
|
-
const cfg = loadConfig();
|
|
363
|
-
const account = resolveWhatsAppAccount({
|
|
364
|
-
cfg,
|
|
365
|
-
accountId: params.accountId
|
|
366
|
-
});
|
|
367
|
-
const dmPolicy = account.dmPolicy ?? "pairing";
|
|
368
|
-
const configuredAllowFrom = account.allowFrom;
|
|
369
|
-
const storeAllowFrom = dmPolicy === "allowlist" ? [] : await readChannelAllowFromStore("whatsapp", process.env, account.accountId).catch(() => []);
|
|
370
|
-
const combinedAllowFrom = Array.from(new Set([...configuredAllowFrom ?? [], ...storeAllowFrom]));
|
|
371
|
-
const defaultAllowFrom = combinedAllowFrom.length === 0 && params.selfE164 ? [params.selfE164] : void 0;
|
|
372
|
-
const allowFrom = combinedAllowFrom.length > 0 ? combinedAllowFrom : defaultAllowFrom;
|
|
373
|
-
const groupAllowFrom = account.groupAllowFrom ?? (configuredAllowFrom && configuredAllowFrom.length > 0 ? configuredAllowFrom : void 0);
|
|
374
|
-
const isSamePhone = params.from === params.selfE164;
|
|
375
|
-
const isSelfChat = account.selfChatMode ?? isSelfChatMode(params.selfE164, configuredAllowFrom);
|
|
376
|
-
const pairingGraceMs = typeof params.pairingGraceMs === "number" && params.pairingGraceMs > 0 ? params.pairingGraceMs : PAIRING_REPLY_HISTORY_GRACE_MS;
|
|
377
|
-
const suppressPairingReply = typeof params.connectedAtMs === "number" && typeof params.messageTimestampMs === "number" && params.messageTimestampMs < params.connectedAtMs - pairingGraceMs;
|
|
378
|
-
const dmHasWildcard = allowFrom?.includes("*") ?? false;
|
|
379
|
-
const normalizedAllowFrom = allowFrom && allowFrom.length > 0 ? allowFrom.filter((entry) => entry !== "*").map(normalizeE164) : [];
|
|
380
|
-
const groupHasWildcard = groupAllowFrom?.includes("*") ?? false;
|
|
381
|
-
const normalizedGroupAllowFrom = groupAllowFrom && groupAllowFrom.length > 0 ? groupAllowFrom.filter((entry) => entry !== "*").map(normalizeE164) : [];
|
|
382
|
-
const defaultGroupPolicy = resolveDefaultGroupPolicy(cfg);
|
|
383
|
-
const { groupPolicy, providerMissingFallbackApplied } = resolveWhatsAppRuntimeGroupPolicy({
|
|
384
|
-
providerConfigPresent: cfg.channels?.whatsapp !== void 0,
|
|
385
|
-
groupPolicy: account.groupPolicy,
|
|
386
|
-
defaultGroupPolicy
|
|
387
|
-
});
|
|
388
|
-
warnMissingProviderGroupPolicyFallbackOnce({
|
|
389
|
-
providerMissingFallbackApplied,
|
|
390
|
-
providerKey: "whatsapp",
|
|
391
|
-
accountId: account.accountId,
|
|
392
|
-
log: (message) => logVerbose(message)
|
|
393
|
-
});
|
|
394
|
-
if (params.group && groupPolicy === "disabled") {
|
|
395
|
-
logVerbose("Blocked group message (groupPolicy: disabled)");
|
|
396
|
-
return {
|
|
397
|
-
allowed: false,
|
|
398
|
-
shouldMarkRead: false,
|
|
399
|
-
isSelfChat,
|
|
400
|
-
resolvedAccountId: account.accountId
|
|
401
|
-
};
|
|
402
|
-
}
|
|
403
|
-
if (params.group && groupPolicy === "allowlist") {
|
|
404
|
-
if (!groupAllowFrom || groupAllowFrom.length === 0) {
|
|
405
|
-
logVerbose("Blocked group message (groupPolicy: allowlist, no groupAllowFrom)");
|
|
406
|
-
return {
|
|
407
|
-
allowed: false,
|
|
408
|
-
shouldMarkRead: false,
|
|
409
|
-
isSelfChat,
|
|
410
|
-
resolvedAccountId: account.accountId
|
|
411
|
-
};
|
|
412
|
-
}
|
|
413
|
-
if (!(groupHasWildcard || params.senderE164 != null && normalizedGroupAllowFrom.includes(params.senderE164))) {
|
|
414
|
-
logVerbose(`Blocked group message from ${params.senderE164 ?? "unknown sender"} (groupPolicy: allowlist)`);
|
|
415
|
-
return {
|
|
416
|
-
allowed: false,
|
|
417
|
-
shouldMarkRead: false,
|
|
418
|
-
isSelfChat,
|
|
419
|
-
resolvedAccountId: account.accountId
|
|
420
|
-
};
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
if (!params.group) {
|
|
424
|
-
if (params.isFromMe && !isSamePhone) {
|
|
425
|
-
logVerbose("Skipping outbound DM (fromMe); no pairing reply needed.");
|
|
426
|
-
return {
|
|
427
|
-
allowed: false,
|
|
428
|
-
shouldMarkRead: false,
|
|
429
|
-
isSelfChat,
|
|
430
|
-
resolvedAccountId: account.accountId
|
|
431
|
-
};
|
|
432
|
-
}
|
|
433
|
-
if (dmPolicy === "disabled") {
|
|
434
|
-
logVerbose("Blocked dm (dmPolicy: disabled)");
|
|
435
|
-
return {
|
|
436
|
-
allowed: false,
|
|
437
|
-
shouldMarkRead: false,
|
|
438
|
-
isSelfChat,
|
|
439
|
-
resolvedAccountId: account.accountId
|
|
440
|
-
};
|
|
441
|
-
}
|
|
442
|
-
if (dmPolicy !== "open" && !isSamePhone) {
|
|
443
|
-
const candidate = params.from;
|
|
444
|
-
if (!(dmHasWildcard || normalizedAllowFrom.length > 0 && normalizedAllowFrom.includes(candidate))) {
|
|
445
|
-
if (dmPolicy === "pairing") if (suppressPairingReply) logVerbose(`Skipping pairing reply for historical DM from ${candidate}.`);
|
|
446
|
-
else {
|
|
447
|
-
const { code, created } = await upsertChannelPairingRequest({
|
|
448
|
-
channel: "whatsapp",
|
|
449
|
-
id: candidate,
|
|
450
|
-
accountId: account.accountId,
|
|
451
|
-
meta: { name: (params.pushName ?? "").trim() || void 0 }
|
|
452
|
-
});
|
|
453
|
-
if (created) {
|
|
454
|
-
logVerbose(`whatsapp pairing request sender=${candidate} name=${params.pushName ?? "unknown"}`);
|
|
455
|
-
try {
|
|
456
|
-
await params.sock.sendMessage(params.remoteJid, { text: buildPairingReply({
|
|
457
|
-
channel: "whatsapp",
|
|
458
|
-
idLine: `Your WhatsApp phone number: ${candidate}`,
|
|
459
|
-
code
|
|
460
|
-
}) });
|
|
461
|
-
} catch (err) {
|
|
462
|
-
logVerbose(`whatsapp pairing reply failed for ${candidate}: ${String(err)}`);
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
else logVerbose(`Blocked unauthorized sender ${candidate} (dmPolicy=${dmPolicy})`);
|
|
467
|
-
return {
|
|
468
|
-
allowed: false,
|
|
469
|
-
shouldMarkRead: false,
|
|
470
|
-
isSelfChat,
|
|
471
|
-
resolvedAccountId: account.accountId
|
|
472
|
-
};
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
return {
|
|
477
|
-
allowed: true,
|
|
478
|
-
shouldMarkRead: true,
|
|
479
|
-
isSelfChat,
|
|
480
|
-
resolvedAccountId: account.accountId
|
|
481
|
-
};
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
//#endregion
|
|
485
|
-
//#region src/web/inbound/media.ts
|
|
486
|
-
function unwrapMessage(message) {
|
|
487
|
-
return normalizeMessageContent(message);
|
|
488
|
-
}
|
|
489
|
-
/**
|
|
490
|
-
* Resolve the MIME type for an inbound media message.
|
|
491
|
-
* Falls back to WhatsApp's standard formats when Baileys omits the MIME.
|
|
492
|
-
*/
|
|
493
|
-
function resolveMediaMimetype(message) {
|
|
494
|
-
const explicit = message.imageMessage?.mimetype ?? message.videoMessage?.mimetype ?? message.documentMessage?.mimetype ?? message.audioMessage?.mimetype ?? message.stickerMessage?.mimetype ?? void 0;
|
|
495
|
-
if (explicit) return explicit;
|
|
496
|
-
if (message.audioMessage) return "audio/ogg; codecs=opus";
|
|
497
|
-
if (message.imageMessage) return "image/jpeg";
|
|
498
|
-
if (message.videoMessage) return "video/mp4";
|
|
499
|
-
if (message.stickerMessage) return "image/webp";
|
|
500
|
-
}
|
|
501
|
-
async function downloadInboundMedia(msg, sock) {
|
|
502
|
-
const message = unwrapMessage(msg.message);
|
|
503
|
-
if (!message) return;
|
|
504
|
-
const mimetype = resolveMediaMimetype(message);
|
|
505
|
-
const fileName = message.documentMessage?.fileName ?? void 0;
|
|
506
|
-
if (!message.imageMessage && !message.videoMessage && !message.documentMessage && !message.audioMessage && !message.stickerMessage) return;
|
|
507
|
-
try {
|
|
508
|
-
return {
|
|
509
|
-
buffer: await downloadMediaMessage(msg, "buffer", {}, {
|
|
510
|
-
reuploadRequest: sock.updateMediaMessage,
|
|
511
|
-
logger: sock.logger
|
|
512
|
-
}),
|
|
513
|
-
mimetype,
|
|
514
|
-
fileName
|
|
515
|
-
};
|
|
516
|
-
} catch (err) {
|
|
517
|
-
logVerbose(`downloadMediaMessage failed: ${String(err)}`);
|
|
518
|
-
return;
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
//#endregion
|
|
523
|
-
//#region src/web/inbound/send-api.ts
|
|
524
|
-
function recordWhatsAppOutbound(accountId) {
|
|
525
|
-
recordChannelActivity({
|
|
526
|
-
channel: "whatsapp",
|
|
527
|
-
accountId,
|
|
528
|
-
direction: "outbound"
|
|
529
|
-
});
|
|
530
|
-
}
|
|
531
|
-
function resolveOutboundMessageId(result) {
|
|
532
|
-
return typeof result === "object" && result && "key" in result ? String(result.key?.id ?? "unknown") : "unknown";
|
|
533
|
-
}
|
|
534
|
-
function createWebSendApi(params) {
|
|
535
|
-
return {
|
|
536
|
-
sendMessage: async (to, text, mediaBuffer, mediaType, sendOptions) => {
|
|
537
|
-
const jid = toWhatsappJid(to);
|
|
538
|
-
let payload;
|
|
539
|
-
if (mediaBuffer && mediaType) if (mediaType.startsWith("image/")) payload = {
|
|
540
|
-
image: mediaBuffer,
|
|
541
|
-
caption: text || void 0,
|
|
542
|
-
mimetype: mediaType
|
|
543
|
-
};
|
|
544
|
-
else if (mediaType.startsWith("audio/")) payload = {
|
|
545
|
-
audio: mediaBuffer,
|
|
546
|
-
ptt: true,
|
|
547
|
-
mimetype: mediaType
|
|
548
|
-
};
|
|
549
|
-
else if (mediaType.startsWith("video/")) {
|
|
550
|
-
const gifPlayback = sendOptions?.gifPlayback;
|
|
551
|
-
payload = {
|
|
552
|
-
video: mediaBuffer,
|
|
553
|
-
caption: text || void 0,
|
|
554
|
-
mimetype: mediaType,
|
|
555
|
-
...gifPlayback ? { gifPlayback: true } : {}
|
|
556
|
-
};
|
|
557
|
-
} else payload = {
|
|
558
|
-
document: mediaBuffer,
|
|
559
|
-
fileName: sendOptions?.fileName?.trim() || "file",
|
|
560
|
-
caption: text || void 0,
|
|
561
|
-
mimetype: mediaType
|
|
562
|
-
};
|
|
563
|
-
else payload = { text };
|
|
564
|
-
const result = await params.sock.sendMessage(jid, payload);
|
|
565
|
-
recordWhatsAppOutbound(sendOptions?.accountId ?? params.defaultAccountId);
|
|
566
|
-
return { messageId: resolveOutboundMessageId(result) };
|
|
567
|
-
},
|
|
568
|
-
sendPoll: async (to, poll) => {
|
|
569
|
-
const jid = toWhatsappJid(to);
|
|
570
|
-
const result = await params.sock.sendMessage(jid, { poll: {
|
|
571
|
-
name: poll.question,
|
|
572
|
-
values: poll.options,
|
|
573
|
-
selectableCount: poll.maxSelections ?? 1
|
|
574
|
-
} });
|
|
575
|
-
recordWhatsAppOutbound(params.defaultAccountId);
|
|
576
|
-
return { messageId: resolveOutboundMessageId(result) };
|
|
577
|
-
},
|
|
578
|
-
sendReaction: async (chatJid, messageId, emoji, fromMe, participant) => {
|
|
579
|
-
const jid = toWhatsappJid(chatJid);
|
|
580
|
-
await params.sock.sendMessage(jid, { react: {
|
|
581
|
-
text: emoji,
|
|
582
|
-
key: {
|
|
583
|
-
remoteJid: jid,
|
|
584
|
-
id: messageId,
|
|
585
|
-
fromMe,
|
|
586
|
-
participant: participant ? toWhatsappJid(participant) : void 0
|
|
587
|
-
}
|
|
588
|
-
} });
|
|
589
|
-
},
|
|
590
|
-
sendComposingTo: async (to) => {
|
|
591
|
-
const jid = toWhatsappJid(to);
|
|
592
|
-
await params.sock.sendPresenceUpdate("composing", jid);
|
|
593
|
-
}
|
|
594
|
-
};
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
//#endregion
|
|
598
|
-
//#region src/web/inbound/monitor.ts
|
|
599
|
-
async function monitorWebInbox(options) {
|
|
600
|
-
const inboundLogger = getChildLogger({ module: "web-inbound" });
|
|
601
|
-
const inboundConsoleLog = createSubsystemLogger("gateway/channels/whatsapp").child("inbound");
|
|
602
|
-
const sock = await createWaSocket(false, options.verbose, { authDir: options.authDir });
|
|
603
|
-
await waitForWaConnection(sock);
|
|
604
|
-
const connectedAtMs = Date.now();
|
|
605
|
-
let onCloseResolve = null;
|
|
606
|
-
const onClose = new Promise((resolve) => {
|
|
607
|
-
onCloseResolve = resolve;
|
|
608
|
-
});
|
|
609
|
-
const resolveClose = (reason) => {
|
|
610
|
-
if (!onCloseResolve) return;
|
|
611
|
-
const resolver = onCloseResolve;
|
|
612
|
-
onCloseResolve = null;
|
|
613
|
-
resolver(reason);
|
|
614
|
-
};
|
|
615
|
-
try {
|
|
616
|
-
await sock.sendPresenceUpdate("available");
|
|
617
|
-
if (shouldLogVerbose()) logVerbose("Sent global 'available' presence on connect");
|
|
618
|
-
} catch (err) {
|
|
619
|
-
logVerbose(`Failed to send 'available' presence on connect: ${String(err)}`);
|
|
620
|
-
}
|
|
621
|
-
const selfJid = sock.user?.id;
|
|
622
|
-
const selfE164 = selfJid ? jidToE164(selfJid) : null;
|
|
623
|
-
const debouncer = createInboundDebouncer({
|
|
624
|
-
debounceMs: options.debounceMs ?? 0,
|
|
625
|
-
buildKey: (msg) => {
|
|
626
|
-
const senderKey = msg.chatType === "group" ? msg.senderJid ?? msg.senderE164 ?? msg.senderName ?? msg.from : msg.from;
|
|
627
|
-
if (!senderKey) return null;
|
|
628
|
-
const conversationKey = msg.chatType === "group" ? msg.chatId : msg.from;
|
|
629
|
-
return `${msg.accountId}:${conversationKey}:${senderKey}`;
|
|
630
|
-
},
|
|
631
|
-
shouldDebounce: options.shouldDebounce,
|
|
632
|
-
onFlush: async (entries) => {
|
|
633
|
-
const last = entries.at(-1);
|
|
634
|
-
if (!last) return;
|
|
635
|
-
if (entries.length === 1) {
|
|
636
|
-
await options.onMessage(last);
|
|
637
|
-
return;
|
|
638
|
-
}
|
|
639
|
-
const mentioned = /* @__PURE__ */ new Set();
|
|
640
|
-
for (const entry of entries) for (const jid of entry.mentionedJids ?? []) mentioned.add(jid);
|
|
641
|
-
const combinedBody = entries.map((entry) => entry.body).filter(Boolean).join("\n");
|
|
642
|
-
const combinedMessage = {
|
|
643
|
-
...last,
|
|
644
|
-
body: combinedBody,
|
|
645
|
-
mentionedJids: mentioned.size > 0 ? Array.from(mentioned) : void 0
|
|
646
|
-
};
|
|
647
|
-
await options.onMessage(combinedMessage);
|
|
648
|
-
},
|
|
649
|
-
onError: (err) => {
|
|
650
|
-
inboundLogger.error({ error: String(err) }, "failed handling inbound web message");
|
|
651
|
-
inboundConsoleLog.error(`Failed handling inbound web message: ${String(err)}`);
|
|
652
|
-
}
|
|
653
|
-
});
|
|
654
|
-
const groupMetaCache = /* @__PURE__ */ new Map();
|
|
655
|
-
const GROUP_META_TTL_MS = 300 * 1e3;
|
|
656
|
-
const lidLookup = sock.signalRepository?.lidMapping;
|
|
657
|
-
const resolveInboundJid = async (jid) => resolveJidToE164(jid, {
|
|
658
|
-
authDir: options.authDir,
|
|
659
|
-
lidLookup
|
|
660
|
-
});
|
|
661
|
-
const getGroupMeta = async (jid) => {
|
|
662
|
-
const cached = groupMetaCache.get(jid);
|
|
663
|
-
if (cached && cached.expires > Date.now()) return cached;
|
|
664
|
-
try {
|
|
665
|
-
const meta = await sock.groupMetadata(jid);
|
|
666
|
-
const participants = (await Promise.all(meta.participants?.map(async (p) => {
|
|
667
|
-
return await resolveInboundJid(p.id) ?? p.id;
|
|
668
|
-
}) ?? [])).filter(Boolean) ?? [];
|
|
669
|
-
const entry = {
|
|
670
|
-
subject: meta.subject,
|
|
671
|
-
participants,
|
|
672
|
-
expires: Date.now() + GROUP_META_TTL_MS
|
|
673
|
-
};
|
|
674
|
-
groupMetaCache.set(jid, entry);
|
|
675
|
-
return entry;
|
|
676
|
-
} catch (err) {
|
|
677
|
-
logVerbose(`Failed to fetch group metadata for ${jid}: ${String(err)}`);
|
|
678
|
-
return { expires: Date.now() + GROUP_META_TTL_MS };
|
|
679
|
-
}
|
|
680
|
-
};
|
|
681
|
-
const handleMessagesUpsert = async (upsert) => {
|
|
682
|
-
if (upsert.type !== "notify" && upsert.type !== "append") return;
|
|
683
|
-
for (const msg of upsert.messages ?? []) {
|
|
684
|
-
recordChannelActivity({
|
|
685
|
-
channel: "whatsapp",
|
|
686
|
-
accountId: options.accountId,
|
|
687
|
-
direction: "inbound"
|
|
688
|
-
});
|
|
689
|
-
const id = msg.key?.id ?? void 0;
|
|
690
|
-
const remoteJid = msg.key?.remoteJid;
|
|
691
|
-
if (!remoteJid) continue;
|
|
692
|
-
if (remoteJid.endsWith("@status") || remoteJid.endsWith("@broadcast")) continue;
|
|
693
|
-
const group = isJidGroup(remoteJid) === true;
|
|
694
|
-
if (id) {
|
|
695
|
-
if (isRecentInboundMessage(`${options.accountId}:${remoteJid}:${id}`)) continue;
|
|
696
|
-
}
|
|
697
|
-
const participantJid = msg.key?.participant ?? void 0;
|
|
698
|
-
const from = group ? remoteJid : await resolveInboundJid(remoteJid);
|
|
699
|
-
if (!from) continue;
|
|
700
|
-
const senderE164 = group ? participantJid ? await resolveInboundJid(participantJid) : null : from;
|
|
701
|
-
let groupSubject;
|
|
702
|
-
let groupParticipants;
|
|
703
|
-
if (group) {
|
|
704
|
-
const meta = await getGroupMeta(remoteJid);
|
|
705
|
-
groupSubject = meta.subject;
|
|
706
|
-
groupParticipants = meta.participants;
|
|
707
|
-
}
|
|
708
|
-
const messageTimestampMs = msg.messageTimestamp ? Number(msg.messageTimestamp) * 1e3 : void 0;
|
|
709
|
-
const access = await checkInboundAccessControl({
|
|
710
|
-
accountId: options.accountId,
|
|
711
|
-
from,
|
|
712
|
-
selfE164,
|
|
713
|
-
senderE164,
|
|
714
|
-
group,
|
|
715
|
-
pushName: msg.pushName ?? void 0,
|
|
716
|
-
isFromMe: Boolean(msg.key?.fromMe),
|
|
717
|
-
messageTimestampMs,
|
|
718
|
-
connectedAtMs,
|
|
719
|
-
sock: { sendMessage: (jid, content) => sock.sendMessage(jid, content) },
|
|
720
|
-
remoteJid
|
|
721
|
-
});
|
|
722
|
-
if (!access.allowed) continue;
|
|
723
|
-
if (id && !access.isSelfChat && options.sendReadReceipts !== false) {
|
|
724
|
-
const participant = msg.key?.participant;
|
|
725
|
-
try {
|
|
726
|
-
await sock.readMessages([{
|
|
727
|
-
remoteJid,
|
|
728
|
-
id,
|
|
729
|
-
participant,
|
|
730
|
-
fromMe: false
|
|
731
|
-
}]);
|
|
732
|
-
if (shouldLogVerbose()) logVerbose(`Marked message ${id} as read for ${remoteJid}${participant ? ` (participant ${participant})` : ""}`);
|
|
733
|
-
} catch (err) {
|
|
734
|
-
logVerbose(`Failed to mark message ${id} read: ${String(err)}`);
|
|
735
|
-
}
|
|
736
|
-
} else if (id && access.isSelfChat && shouldLogVerbose()) logVerbose(`Self-chat mode: skipping read receipt for ${id}`);
|
|
737
|
-
if (upsert.type === "append") continue;
|
|
738
|
-
const location = extractLocationData(msg.message ?? void 0);
|
|
739
|
-
const locationText = location ? formatLocationText(location) : void 0;
|
|
740
|
-
let body = extractText(msg.message ?? void 0);
|
|
741
|
-
if (locationText) body = [body, locationText].filter(Boolean).join("\n").trim();
|
|
742
|
-
if (!body) {
|
|
743
|
-
body = extractMediaPlaceholder(msg.message ?? void 0);
|
|
744
|
-
if (!body) continue;
|
|
745
|
-
}
|
|
746
|
-
const replyContext = describeReplyContext(msg.message);
|
|
747
|
-
let mediaPath;
|
|
748
|
-
let mediaType;
|
|
749
|
-
let mediaFileName;
|
|
750
|
-
try {
|
|
751
|
-
const inboundMedia = await downloadInboundMedia(msg, sock);
|
|
752
|
-
if (inboundMedia) {
|
|
753
|
-
const maxBytes = (typeof options.mediaMaxMb === "number" && options.mediaMaxMb > 0 ? options.mediaMaxMb : 50) * 1024 * 1024;
|
|
754
|
-
mediaPath = (await saveMediaBuffer(inboundMedia.buffer, inboundMedia.mimetype, "inbound", maxBytes, inboundMedia.fileName)).path;
|
|
755
|
-
mediaType = inboundMedia.mimetype;
|
|
756
|
-
mediaFileName = inboundMedia.fileName;
|
|
757
|
-
}
|
|
758
|
-
} catch (err) {
|
|
759
|
-
logVerbose(`Inbound media download failed: ${String(err)}`);
|
|
760
|
-
}
|
|
761
|
-
const chatJid = remoteJid;
|
|
762
|
-
const sendComposing = async () => {
|
|
763
|
-
try {
|
|
764
|
-
await sock.sendPresenceUpdate("composing", chatJid);
|
|
765
|
-
} catch (err) {
|
|
766
|
-
logVerbose(`Presence update failed: ${String(err)}`);
|
|
767
|
-
}
|
|
768
|
-
};
|
|
769
|
-
const reply = async (text) => {
|
|
770
|
-
await sock.sendMessage(chatJid, { text });
|
|
771
|
-
};
|
|
772
|
-
const sendMedia = async (payload) => {
|
|
773
|
-
await sock.sendMessage(chatJid, payload);
|
|
774
|
-
};
|
|
775
|
-
const timestamp = messageTimestampMs;
|
|
776
|
-
const mentionedJids = extractMentionedJids(msg.message);
|
|
777
|
-
const senderName = msg.pushName ?? void 0;
|
|
778
|
-
inboundLogger.info({
|
|
779
|
-
from,
|
|
780
|
-
to: selfE164 ?? "me",
|
|
781
|
-
body,
|
|
782
|
-
mediaPath,
|
|
783
|
-
mediaType,
|
|
784
|
-
mediaFileName,
|
|
785
|
-
timestamp
|
|
786
|
-
}, "inbound message");
|
|
787
|
-
const inboundMessage = {
|
|
788
|
-
id,
|
|
789
|
-
from,
|
|
790
|
-
conversationId: from,
|
|
791
|
-
to: selfE164 ?? "me",
|
|
792
|
-
accountId: access.resolvedAccountId,
|
|
793
|
-
body,
|
|
794
|
-
pushName: senderName,
|
|
795
|
-
timestamp,
|
|
796
|
-
chatType: group ? "group" : "direct",
|
|
797
|
-
chatId: remoteJid,
|
|
798
|
-
senderJid: participantJid,
|
|
799
|
-
senderE164: senderE164 ?? void 0,
|
|
800
|
-
senderName,
|
|
801
|
-
replyToId: replyContext?.id,
|
|
802
|
-
replyToBody: replyContext?.body,
|
|
803
|
-
replyToSender: replyContext?.sender,
|
|
804
|
-
replyToSenderJid: replyContext?.senderJid,
|
|
805
|
-
replyToSenderE164: replyContext?.senderE164,
|
|
806
|
-
groupSubject,
|
|
807
|
-
groupParticipants,
|
|
808
|
-
mentionedJids: mentionedJids ?? void 0,
|
|
809
|
-
selfJid,
|
|
810
|
-
selfE164,
|
|
811
|
-
location: location ?? void 0,
|
|
812
|
-
sendComposing,
|
|
813
|
-
reply,
|
|
814
|
-
sendMedia,
|
|
815
|
-
mediaPath,
|
|
816
|
-
mediaType,
|
|
817
|
-
mediaFileName
|
|
818
|
-
};
|
|
819
|
-
try {
|
|
820
|
-
Promise.resolve(debouncer.enqueue(inboundMessage)).catch((err) => {
|
|
821
|
-
inboundLogger.error({ error: String(err) }, "failed handling inbound web message");
|
|
822
|
-
inboundConsoleLog.error(`Failed handling inbound web message: ${String(err)}`);
|
|
823
|
-
});
|
|
824
|
-
} catch (err) {
|
|
825
|
-
inboundLogger.error({ error: String(err) }, "failed handling inbound web message");
|
|
826
|
-
inboundConsoleLog.error(`Failed handling inbound web message: ${String(err)}`);
|
|
827
|
-
}
|
|
828
|
-
}
|
|
829
|
-
};
|
|
830
|
-
sock.ev.on("messages.upsert", handleMessagesUpsert);
|
|
831
|
-
const handleConnectionUpdate = (update) => {
|
|
832
|
-
try {
|
|
833
|
-
if (update.connection === "close") {
|
|
834
|
-
const status = getStatusCode(update.lastDisconnect?.error);
|
|
835
|
-
resolveClose({
|
|
836
|
-
status,
|
|
837
|
-
isLoggedOut: status === DisconnectReason.loggedOut,
|
|
838
|
-
error: update.lastDisconnect?.error
|
|
839
|
-
});
|
|
840
|
-
}
|
|
841
|
-
} catch (err) {
|
|
842
|
-
inboundLogger.error({ error: String(err) }, "connection.update handler error");
|
|
843
|
-
resolveClose({
|
|
844
|
-
status: void 0,
|
|
845
|
-
isLoggedOut: false,
|
|
846
|
-
error: err
|
|
847
|
-
});
|
|
848
|
-
}
|
|
849
|
-
};
|
|
850
|
-
sock.ev.on("connection.update", handleConnectionUpdate);
|
|
851
|
-
return {
|
|
852
|
-
close: async () => {
|
|
853
|
-
try {
|
|
854
|
-
const ev = sock.ev;
|
|
855
|
-
const messagesUpsertHandler = handleMessagesUpsert;
|
|
856
|
-
const connectionUpdateHandler = handleConnectionUpdate;
|
|
857
|
-
if (typeof ev.off === "function") {
|
|
858
|
-
ev.off("messages.upsert", messagesUpsertHandler);
|
|
859
|
-
ev.off("connection.update", connectionUpdateHandler);
|
|
860
|
-
} else if (typeof ev.removeListener === "function") {
|
|
861
|
-
ev.removeListener("messages.upsert", messagesUpsertHandler);
|
|
862
|
-
ev.removeListener("connection.update", connectionUpdateHandler);
|
|
863
|
-
}
|
|
864
|
-
sock.ws?.close();
|
|
865
|
-
} catch (err) {
|
|
866
|
-
logVerbose(`Socket close failed: ${String(err)}`);
|
|
867
|
-
}
|
|
868
|
-
},
|
|
869
|
-
onClose,
|
|
870
|
-
signalClose: (reason) => {
|
|
871
|
-
resolveClose(reason ?? {
|
|
872
|
-
status: void 0,
|
|
873
|
-
isLoggedOut: false,
|
|
874
|
-
error: "closed"
|
|
875
|
-
});
|
|
876
|
-
},
|
|
877
|
-
...createWebSendApi({
|
|
878
|
-
sock: {
|
|
879
|
-
sendMessage: (jid, content) => sock.sendMessage(jid, content),
|
|
880
|
-
sendPresenceUpdate: (presence, jid) => sock.sendPresenceUpdate(presence, jid)
|
|
881
|
-
},
|
|
882
|
-
defaultAccountId: options.accountId
|
|
883
|
-
})
|
|
884
|
-
};
|
|
885
|
-
}
|
|
886
|
-
|
|
887
|
-
//#endregion
|
|
888
|
-
//#region src/web/auto-reply/mentions.ts
|
|
889
|
-
function buildMentionConfig(cfg, agentId) {
|
|
890
|
-
return {
|
|
891
|
-
mentionRegexes: buildMentionRegexes(cfg, agentId),
|
|
892
|
-
allowFrom: cfg.channels?.whatsapp?.allowFrom
|
|
893
|
-
};
|
|
894
|
-
}
|
|
895
|
-
function resolveMentionTargets(msg, authDir) {
|
|
896
|
-
const jidOptions = authDir ? { authDir } : void 0;
|
|
897
|
-
return {
|
|
898
|
-
normalizedMentions: msg.mentionedJids?.length ? msg.mentionedJids.map((jid) => jidToE164(jid, jidOptions) ?? jid).filter(Boolean) : [],
|
|
899
|
-
selfE164: msg.selfE164 ?? (msg.selfJid ? jidToE164(msg.selfJid, jidOptions) : null),
|
|
900
|
-
selfJid: msg.selfJid ? msg.selfJid.replace(/:\\d+/, "") : null
|
|
901
|
-
};
|
|
902
|
-
}
|
|
903
|
-
function isBotMentionedFromTargets(msg, mentionCfg, targets) {
|
|
904
|
-
const clean = (text) => normalizeMentionText(text);
|
|
905
|
-
const isSelfChat = isSelfChatMode(targets.selfE164, mentionCfg.allowFrom);
|
|
906
|
-
const hasMentions = (msg.mentionedJids?.length ?? 0) > 0;
|
|
907
|
-
if (hasMentions && !isSelfChat) {
|
|
908
|
-
if (targets.selfE164 && targets.normalizedMentions.includes(targets.selfE164)) return true;
|
|
909
|
-
if (targets.selfJid) {
|
|
910
|
-
if (targets.normalizedMentions.includes(targets.selfJid)) return true;
|
|
911
|
-
}
|
|
912
|
-
return false;
|
|
913
|
-
} else if (hasMentions && isSelfChat) {}
|
|
914
|
-
const bodyClean = clean(msg.body);
|
|
915
|
-
if (mentionCfg.mentionRegexes.some((re) => re.test(bodyClean))) return true;
|
|
916
|
-
if (targets.selfE164) {
|
|
917
|
-
const selfDigits = targets.selfE164.replace(/\D/g, "");
|
|
918
|
-
if (selfDigits) {
|
|
919
|
-
if (bodyClean.replace(/[^\d]/g, "").includes(selfDigits)) return true;
|
|
920
|
-
const bodyNoSpace = msg.body.replace(/[\s-]/g, "");
|
|
921
|
-
if (new RegExp(`\\+?${selfDigits}`, "i").test(bodyNoSpace)) return true;
|
|
922
|
-
}
|
|
923
|
-
}
|
|
924
|
-
return false;
|
|
925
|
-
}
|
|
926
|
-
function debugMention(msg, mentionCfg, authDir) {
|
|
927
|
-
const mentionTargets = resolveMentionTargets(msg, authDir);
|
|
928
|
-
return {
|
|
929
|
-
wasMentioned: isBotMentionedFromTargets(msg, mentionCfg, mentionTargets),
|
|
930
|
-
details: {
|
|
931
|
-
from: msg.from,
|
|
932
|
-
body: msg.body,
|
|
933
|
-
bodyClean: normalizeMentionText(msg.body),
|
|
934
|
-
mentionedJids: msg.mentionedJids ?? null,
|
|
935
|
-
normalizedMentionedJids: mentionTargets.normalizedMentions.length ? mentionTargets.normalizedMentions : null,
|
|
936
|
-
selfJid: msg.selfJid ?? null,
|
|
937
|
-
selfJidBare: mentionTargets.selfJid,
|
|
938
|
-
selfE164: msg.selfE164 ?? null,
|
|
939
|
-
resolvedSelfE164: mentionTargets.selfE164
|
|
940
|
-
}
|
|
941
|
-
};
|
|
942
|
-
}
|
|
943
|
-
function resolveOwnerList(mentionCfg, selfE164) {
|
|
944
|
-
const allowFrom = mentionCfg.allowFrom;
|
|
945
|
-
return (Array.isArray(allowFrom) && allowFrom.length > 0 ? allowFrom : selfE164 ? [selfE164] : []).filter((entry) => Boolean(entry && entry !== "*")).map((entry) => normalizeE164(entry)).filter((entry) => Boolean(entry));
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
//#endregion
|
|
949
|
-
//#region src/web/auto-reply/monitor/echo.ts
|
|
950
|
-
function createEchoTracker(params) {
|
|
951
|
-
const recentlySent = /* @__PURE__ */ new Set();
|
|
952
|
-
const maxItems = Math.max(1, params.maxItems ?? 100);
|
|
953
|
-
const buildCombinedKey = (p) => `combined:${p.sessionKey}:${p.combinedBody}`;
|
|
954
|
-
const trim = () => {
|
|
955
|
-
while (recentlySent.size > maxItems) {
|
|
956
|
-
const firstKey = recentlySent.values().next().value;
|
|
957
|
-
if (!firstKey) break;
|
|
958
|
-
recentlySent.delete(firstKey);
|
|
959
|
-
}
|
|
960
|
-
};
|
|
961
|
-
const rememberText = (text, opts) => {
|
|
962
|
-
if (!text) return;
|
|
963
|
-
recentlySent.add(text);
|
|
964
|
-
if (opts.combinedBody && opts.combinedBodySessionKey) recentlySent.add(buildCombinedKey({
|
|
965
|
-
sessionKey: opts.combinedBodySessionKey,
|
|
966
|
-
combinedBody: opts.combinedBody
|
|
967
|
-
}));
|
|
968
|
-
if (opts.logVerboseMessage) params.logVerbose?.(`Added to echo detection set (size now: ${recentlySent.size}): ${text.substring(0, 50)}...`);
|
|
969
|
-
trim();
|
|
970
|
-
};
|
|
971
|
-
return {
|
|
972
|
-
rememberText,
|
|
973
|
-
has: (key) => recentlySent.has(key),
|
|
974
|
-
forget: (key) => {
|
|
975
|
-
recentlySent.delete(key);
|
|
976
|
-
},
|
|
977
|
-
buildCombinedKey
|
|
978
|
-
};
|
|
979
|
-
}
|
|
980
|
-
|
|
981
|
-
//#endregion
|
|
982
|
-
//#region src/web/auto-reply/monitor/broadcast.ts
|
|
983
|
-
async function maybeBroadcastMessage(params) {
|
|
984
|
-
const broadcastAgents = params.cfg.broadcast?.[params.peerId];
|
|
985
|
-
if (!broadcastAgents || !Array.isArray(broadcastAgents)) return false;
|
|
986
|
-
if (broadcastAgents.length === 0) return false;
|
|
987
|
-
const strategy = params.cfg.broadcast?.strategy || "parallel";
|
|
988
|
-
whatsappInboundLog.info(`Broadcasting message to ${broadcastAgents.length} agents (${strategy})`);
|
|
989
|
-
const agentIds = params.cfg.agents?.list?.map((agent) => normalizeAgentId(agent.id));
|
|
990
|
-
const hasKnownAgents = (agentIds?.length ?? 0) > 0;
|
|
991
|
-
const groupHistorySnapshot = params.msg.chatType === "group" ? params.groupHistories.get(params.groupHistoryKey) ?? [] : void 0;
|
|
992
|
-
const processForAgent = async (agentId) => {
|
|
993
|
-
const normalizedAgentId = normalizeAgentId(agentId);
|
|
994
|
-
if (hasKnownAgents && !agentIds?.includes(normalizedAgentId)) {
|
|
995
|
-
whatsappInboundLog.warn(`Broadcast agent ${agentId} not found in agents.list; skipping`);
|
|
996
|
-
return false;
|
|
997
|
-
}
|
|
998
|
-
const agentRoute = {
|
|
999
|
-
...params.route,
|
|
1000
|
-
agentId: normalizedAgentId,
|
|
1001
|
-
sessionKey: buildAgentSessionKey({
|
|
1002
|
-
agentId: normalizedAgentId,
|
|
1003
|
-
channel: "whatsapp",
|
|
1004
|
-
accountId: params.route.accountId,
|
|
1005
|
-
peer: {
|
|
1006
|
-
kind: params.msg.chatType === "group" ? "group" : "direct",
|
|
1007
|
-
id: params.peerId
|
|
1008
|
-
},
|
|
1009
|
-
dmScope: params.cfg.session?.dmScope,
|
|
1010
|
-
identityLinks: params.cfg.session?.identityLinks
|
|
1011
|
-
}),
|
|
1012
|
-
mainSessionKey: buildAgentMainSessionKey({
|
|
1013
|
-
agentId: normalizedAgentId,
|
|
1014
|
-
mainKey: DEFAULT_MAIN_KEY
|
|
1015
|
-
})
|
|
1016
|
-
};
|
|
1017
|
-
try {
|
|
1018
|
-
return await params.processMessage(params.msg, agentRoute, params.groupHistoryKey, {
|
|
1019
|
-
groupHistory: groupHistorySnapshot,
|
|
1020
|
-
suppressGroupHistoryClear: true
|
|
1021
|
-
});
|
|
1022
|
-
} catch (err) {
|
|
1023
|
-
whatsappInboundLog.error(`Broadcast agent ${agentId} failed: ${formatError(err)}`);
|
|
1024
|
-
return false;
|
|
1025
|
-
}
|
|
1026
|
-
};
|
|
1027
|
-
if (strategy === "sequential") for (const agentId of broadcastAgents) await processForAgent(agentId);
|
|
1028
|
-
else await Promise.allSettled(broadcastAgents.map(processForAgent));
|
|
1029
|
-
if (params.msg.chatType === "group") params.groupHistories.set(params.groupHistoryKey, []);
|
|
1030
|
-
return true;
|
|
1031
|
-
}
|
|
1032
|
-
|
|
1033
|
-
//#endregion
|
|
1034
|
-
//#region src/web/auto-reply/monitor/commands.ts
|
|
1035
|
-
function stripMentionsForCommand(text, mentionRegexes, selfE164) {
|
|
1036
|
-
let result = text;
|
|
1037
|
-
for (const re of mentionRegexes) result = result.replace(re, " ");
|
|
1038
|
-
if (selfE164) {
|
|
1039
|
-
const digits = selfE164.replace(/\D/g, "");
|
|
1040
|
-
if (digits) {
|
|
1041
|
-
const pattern = new RegExp(`\\+?${digits}`, "g");
|
|
1042
|
-
result = result.replace(pattern, " ");
|
|
1043
|
-
}
|
|
1044
|
-
}
|
|
1045
|
-
return result.replace(/\s+/g, " ").trim();
|
|
1046
|
-
}
|
|
1047
|
-
|
|
1048
|
-
//#endregion
|
|
1049
|
-
//#region src/web/auto-reply/monitor/group-activation.ts
|
|
1050
|
-
function resolveGroupPolicyFor(cfg, conversationId) {
|
|
1051
|
-
const groupId = resolveGroupSessionKey({
|
|
1052
|
-
From: conversationId,
|
|
1053
|
-
ChatType: "group",
|
|
1054
|
-
Provider: "whatsapp"
|
|
1055
|
-
})?.id;
|
|
1056
|
-
const whatsappCfg = cfg.channels?.whatsapp;
|
|
1057
|
-
const hasGroupAllowFrom = Boolean(whatsappCfg?.groupAllowFrom?.length || whatsappCfg?.allowFrom?.length);
|
|
1058
|
-
return resolveChannelGroupPolicy({
|
|
1059
|
-
cfg,
|
|
1060
|
-
channel: "whatsapp",
|
|
1061
|
-
groupId: groupId ?? conversationId,
|
|
1062
|
-
hasGroupAllowFrom
|
|
1063
|
-
});
|
|
1064
|
-
}
|
|
1065
|
-
function resolveGroupRequireMentionFor(cfg, conversationId) {
|
|
1066
|
-
const groupId = resolveGroupSessionKey({
|
|
1067
|
-
From: conversationId,
|
|
1068
|
-
ChatType: "group",
|
|
1069
|
-
Provider: "whatsapp"
|
|
1070
|
-
})?.id;
|
|
1071
|
-
return resolveChannelGroupRequireMention({
|
|
1072
|
-
cfg,
|
|
1073
|
-
channel: "whatsapp",
|
|
1074
|
-
groupId: groupId ?? conversationId
|
|
1075
|
-
});
|
|
1076
|
-
}
|
|
1077
|
-
function resolveGroupActivationFor(params) {
|
|
1078
|
-
const entry = loadSessionStore(resolveStorePath(params.cfg.session?.store, { agentId: params.agentId }))[params.sessionKey];
|
|
1079
|
-
const defaultActivation = !resolveGroupRequireMentionFor(params.cfg, params.conversationId) ? "always" : "mention";
|
|
1080
|
-
return normalizeGroupActivation(entry?.groupActivation) ?? defaultActivation;
|
|
1081
|
-
}
|
|
1082
|
-
|
|
1083
|
-
//#endregion
|
|
1084
|
-
//#region src/web/auto-reply/monitor/group-members.ts
|
|
1085
|
-
function appendNormalizedUnique(entries, seen, ordered) {
|
|
1086
|
-
for (const entry of entries) {
|
|
1087
|
-
const normalized = normalizeE164(entry) ?? entry;
|
|
1088
|
-
if (!normalized || seen.has(normalized)) continue;
|
|
1089
|
-
seen.add(normalized);
|
|
1090
|
-
ordered.push(normalized);
|
|
1091
|
-
}
|
|
1092
|
-
}
|
|
1093
|
-
function noteGroupMember(groupMemberNames, conversationId, e164, name) {
|
|
1094
|
-
if (!e164 || !name) return;
|
|
1095
|
-
const key = normalizeE164(e164) ?? e164;
|
|
1096
|
-
if (!key) return;
|
|
1097
|
-
let roster = groupMemberNames.get(conversationId);
|
|
1098
|
-
if (!roster) {
|
|
1099
|
-
roster = /* @__PURE__ */ new Map();
|
|
1100
|
-
groupMemberNames.set(conversationId, roster);
|
|
1101
|
-
}
|
|
1102
|
-
roster.set(key, name);
|
|
1103
|
-
}
|
|
1104
|
-
function formatGroupMembers(params) {
|
|
1105
|
-
const { participants, roster, fallbackE164 } = params;
|
|
1106
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1107
|
-
const ordered = [];
|
|
1108
|
-
if (participants?.length) appendNormalizedUnique(participants, seen, ordered);
|
|
1109
|
-
if (roster) appendNormalizedUnique(roster.keys(), seen, ordered);
|
|
1110
|
-
if (ordered.length === 0 && fallbackE164) {
|
|
1111
|
-
const normalized = normalizeE164(fallbackE164) ?? fallbackE164;
|
|
1112
|
-
if (normalized) ordered.push(normalized);
|
|
1113
|
-
}
|
|
1114
|
-
if (ordered.length === 0) return;
|
|
1115
|
-
return ordered.map((entry) => {
|
|
1116
|
-
const name = roster?.get(entry);
|
|
1117
|
-
return name ? `${name} (${entry})` : entry;
|
|
1118
|
-
}).join(", ");
|
|
1119
|
-
}
|
|
1120
|
-
|
|
1121
|
-
//#endregion
|
|
1122
|
-
//#region src/web/auto-reply/monitor/group-gating.ts
|
|
1123
|
-
function isOwnerSender(baseMentionConfig, msg) {
|
|
1124
|
-
const sender = normalizeE164(msg.senderE164 ?? "");
|
|
1125
|
-
if (!sender) return false;
|
|
1126
|
-
return resolveOwnerList(baseMentionConfig, msg.selfE164 ?? void 0).includes(sender);
|
|
1127
|
-
}
|
|
1128
|
-
function recordPendingGroupHistoryEntry(params) {
|
|
1129
|
-
const sender = params.msg.senderName && params.msg.senderE164 ? `${params.msg.senderName} (${params.msg.senderE164})` : params.msg.senderName ?? params.msg.senderE164 ?? "Unknown";
|
|
1130
|
-
recordPendingHistoryEntryIfEnabled({
|
|
1131
|
-
historyMap: params.groupHistories,
|
|
1132
|
-
historyKey: params.groupHistoryKey,
|
|
1133
|
-
limit: params.groupHistoryLimit,
|
|
1134
|
-
entry: {
|
|
1135
|
-
sender,
|
|
1136
|
-
body: params.msg.body,
|
|
1137
|
-
timestamp: params.msg.timestamp,
|
|
1138
|
-
id: params.msg.id,
|
|
1139
|
-
senderJid: params.msg.senderJid
|
|
1140
|
-
}
|
|
1141
|
-
});
|
|
1142
|
-
}
|
|
1143
|
-
function skipGroupMessageAndStoreHistory(params, verboseMessage) {
|
|
1144
|
-
params.logVerbose(verboseMessage);
|
|
1145
|
-
recordPendingGroupHistoryEntry({
|
|
1146
|
-
msg: params.msg,
|
|
1147
|
-
groupHistories: params.groupHistories,
|
|
1148
|
-
groupHistoryKey: params.groupHistoryKey,
|
|
1149
|
-
groupHistoryLimit: params.groupHistoryLimit
|
|
1150
|
-
});
|
|
1151
|
-
return { shouldProcess: false };
|
|
1152
|
-
}
|
|
1153
|
-
function applyGroupGating(params) {
|
|
1154
|
-
const groupPolicy = resolveGroupPolicyFor(params.cfg, params.conversationId);
|
|
1155
|
-
if (groupPolicy.allowlistEnabled && !groupPolicy.allowed) {
|
|
1156
|
-
params.logVerbose(`Skipping group message ${params.conversationId} (not in allowlist)`);
|
|
1157
|
-
return { shouldProcess: false };
|
|
1158
|
-
}
|
|
1159
|
-
noteGroupMember(params.groupMemberNames, params.groupHistoryKey, params.msg.senderE164, params.msg.senderName);
|
|
1160
|
-
const mentionConfig = buildMentionConfig(params.cfg, params.agentId);
|
|
1161
|
-
const commandBody = stripMentionsForCommand(params.msg.body, mentionConfig.mentionRegexes, params.msg.selfE164);
|
|
1162
|
-
const activationCommand = parseActivationCommand(commandBody);
|
|
1163
|
-
const owner = isOwnerSender(params.baseMentionConfig, params.msg);
|
|
1164
|
-
const shouldBypassMention = owner && hasControlCommand(commandBody, params.cfg);
|
|
1165
|
-
if (activationCommand.hasCommand && !owner) return skipGroupMessageAndStoreHistory(params, `Ignoring /activation from non-owner in group ${params.conversationId}`);
|
|
1166
|
-
const mentionDebug = debugMention(params.msg, mentionConfig, params.authDir);
|
|
1167
|
-
params.replyLogger.debug({
|
|
1168
|
-
conversationId: params.conversationId,
|
|
1169
|
-
wasMentioned: mentionDebug.wasMentioned,
|
|
1170
|
-
...mentionDebug.details
|
|
1171
|
-
}, "group mention debug");
|
|
1172
|
-
const wasMentioned = mentionDebug.wasMentioned;
|
|
1173
|
-
const requireMention = resolveGroupActivationFor({
|
|
1174
|
-
cfg: params.cfg,
|
|
1175
|
-
agentId: params.agentId,
|
|
1176
|
-
sessionKey: params.sessionKey,
|
|
1177
|
-
conversationId: params.conversationId
|
|
1178
|
-
}) !== "always";
|
|
1179
|
-
const selfJid = params.msg.selfJid?.replace(/:\\d+/, "");
|
|
1180
|
-
const replySenderJid = params.msg.replyToSenderJid?.replace(/:\\d+/, "");
|
|
1181
|
-
const selfE164 = params.msg.selfE164 ? normalizeE164(params.msg.selfE164) : null;
|
|
1182
|
-
const replySenderE164 = params.msg.replyToSenderE164 ? normalizeE164(params.msg.replyToSenderE164) : null;
|
|
1183
|
-
const mentionGate = resolveMentionGating({
|
|
1184
|
-
requireMention,
|
|
1185
|
-
canDetectMention: true,
|
|
1186
|
-
wasMentioned,
|
|
1187
|
-
implicitMention: Boolean(selfJid && replySenderJid && selfJid === replySenderJid || selfE164 && replySenderE164 && selfE164 === replySenderE164),
|
|
1188
|
-
shouldBypassMention
|
|
1189
|
-
});
|
|
1190
|
-
params.msg.wasMentioned = mentionGate.effectiveWasMentioned;
|
|
1191
|
-
if (!shouldBypassMention && requireMention && mentionGate.shouldSkip) return skipGroupMessageAndStoreHistory(params, `Group message stored for context (no mention detected) in ${params.conversationId}: ${params.msg.body}`);
|
|
1192
|
-
return { shouldProcess: true };
|
|
1193
|
-
}
|
|
1194
|
-
|
|
1195
|
-
//#endregion
|
|
1196
|
-
//#region src/web/auto-reply/monitor/last-route.ts
|
|
1197
|
-
function trackBackgroundTask(backgroundTasks, task) {
|
|
1198
|
-
backgroundTasks.add(task);
|
|
1199
|
-
task.finally(() => {
|
|
1200
|
-
backgroundTasks.delete(task);
|
|
1201
|
-
});
|
|
1202
|
-
}
|
|
1203
|
-
function updateLastRouteInBackground(params) {
|
|
1204
|
-
const storePath = resolveStorePath(params.cfg.session?.store, { agentId: params.storeAgentId });
|
|
1205
|
-
const task = updateLastRoute({
|
|
1206
|
-
storePath,
|
|
1207
|
-
sessionKey: params.sessionKey,
|
|
1208
|
-
deliveryContext: {
|
|
1209
|
-
channel: params.channel,
|
|
1210
|
-
to: params.to,
|
|
1211
|
-
accountId: params.accountId
|
|
1212
|
-
},
|
|
1213
|
-
ctx: params.ctx
|
|
1214
|
-
}).catch((err) => {
|
|
1215
|
-
params.warn({
|
|
1216
|
-
error: formatError(err),
|
|
1217
|
-
storePath,
|
|
1218
|
-
sessionKey: params.sessionKey,
|
|
1219
|
-
to: params.to
|
|
1220
|
-
}, "failed updating last route");
|
|
1221
|
-
});
|
|
1222
|
-
trackBackgroundTask(params.backgroundTasks, task);
|
|
1223
|
-
}
|
|
1224
|
-
|
|
1225
|
-
//#endregion
|
|
1226
|
-
//#region src/web/auto-reply/monitor/peer.ts
|
|
1227
|
-
function resolvePeerId(msg) {
|
|
1228
|
-
if (msg.chatType === "group") return msg.conversationId ?? msg.from;
|
|
1229
|
-
if (msg.senderE164) return normalizeE164(msg.senderE164) ?? msg.senderE164;
|
|
1230
|
-
if (msg.from.includes("@")) return jidToE164(msg.from) ?? msg.from;
|
|
1231
|
-
return normalizeE164(msg.from) ?? msg.from;
|
|
1232
|
-
}
|
|
1233
|
-
|
|
1234
|
-
//#endregion
|
|
1235
|
-
//#region src/web/auto-reply/util.ts
|
|
1236
|
-
function elide(text, limit = 400) {
|
|
1237
|
-
if (!text) return text;
|
|
1238
|
-
if (text.length <= limit) return text;
|
|
1239
|
-
return `${text.slice(0, limit)}… (truncated ${text.length - limit} chars)`;
|
|
1240
|
-
}
|
|
1241
|
-
function isLikelyWhatsAppCryptoError(reason) {
|
|
1242
|
-
const formatReason = (value) => {
|
|
1243
|
-
if (value == null) return "";
|
|
1244
|
-
if (typeof value === "string") return value;
|
|
1245
|
-
if (value instanceof Error) return `${value.message}\n${value.stack ?? ""}`;
|
|
1246
|
-
if (typeof value === "object") try {
|
|
1247
|
-
return JSON.stringify(value);
|
|
1248
|
-
} catch {
|
|
1249
|
-
return Object.prototype.toString.call(value);
|
|
1250
|
-
}
|
|
1251
|
-
if (typeof value === "number") return String(value);
|
|
1252
|
-
if (typeof value === "boolean") return String(value);
|
|
1253
|
-
if (typeof value === "bigint") return String(value);
|
|
1254
|
-
if (typeof value === "symbol") return value.description ?? value.toString();
|
|
1255
|
-
if (typeof value === "function") return value.name ? `[function ${value.name}]` : "[function]";
|
|
1256
|
-
return Object.prototype.toString.call(value);
|
|
1257
|
-
};
|
|
1258
|
-
const haystack = (reason instanceof Error ? `${reason.message}\n${reason.stack ?? ""}` : formatReason(reason)).toLowerCase();
|
|
1259
|
-
if (!(haystack.includes("unsupported state or unable to authenticate data") || haystack.includes("bad mac"))) return false;
|
|
1260
|
-
return haystack.includes("@whiskeysockets/baileys") || haystack.includes("baileys") || haystack.includes("noise-handler") || haystack.includes("aesdecryptgcm");
|
|
1261
|
-
}
|
|
1262
|
-
|
|
1263
|
-
//#endregion
|
|
1264
|
-
//#region src/web/auto-reply/deliver-reply.ts
|
|
1265
|
-
const REASONING_PREFIX = "reasoning:";
|
|
1266
|
-
function shouldSuppressReasoningReply(payload) {
|
|
1267
|
-
if (payload.isReasoning === true) return true;
|
|
1268
|
-
const text = payload.text;
|
|
1269
|
-
if (typeof text !== "string") return false;
|
|
1270
|
-
return text.trimStart().toLowerCase().startsWith(REASONING_PREFIX);
|
|
1271
|
-
}
|
|
1272
|
-
async function deliverWebReply(params) {
|
|
1273
|
-
const { replyResult, msg, maxMediaBytes, textLimit, replyLogger, connectionId, skipLog } = params;
|
|
1274
|
-
const replyStarted = Date.now();
|
|
1275
|
-
if (shouldSuppressReasoningReply(replyResult)) {
|
|
1276
|
-
whatsappOutboundLog.debug(`Suppressed reasoning payload to ${msg.from}`);
|
|
1277
|
-
return;
|
|
1278
|
-
}
|
|
1279
|
-
const tableMode = params.tableMode ?? "code";
|
|
1280
|
-
const chunkMode = params.chunkMode ?? "length";
|
|
1281
|
-
const textChunks = chunkMarkdownTextWithMode(markdownToWhatsApp(convertMarkdownTables(replyResult.text || "", tableMode)), textLimit, chunkMode);
|
|
1282
|
-
const mediaList = replyResult.mediaUrls?.length ? replyResult.mediaUrls : replyResult.mediaUrl ? [replyResult.mediaUrl] : [];
|
|
1283
|
-
const sendWithRetry = async (fn, label, maxAttempts = 3) => {
|
|
1284
|
-
let lastErr;
|
|
1285
|
-
for (let attempt = 1; attempt <= maxAttempts; attempt++) try {
|
|
1286
|
-
return await fn();
|
|
1287
|
-
} catch (err) {
|
|
1288
|
-
lastErr = err;
|
|
1289
|
-
const errText = formatError(err);
|
|
1290
|
-
const isLast = attempt === maxAttempts;
|
|
1291
|
-
if (!/closed|reset|timed\s*out|disconnect/i.test(errText) || isLast) throw err;
|
|
1292
|
-
const backoffMs = 500 * attempt;
|
|
1293
|
-
logVerbose(`Retrying ${label} to ${msg.from} after failure (${attempt}/${maxAttempts - 1}) in ${backoffMs}ms: ${errText}`);
|
|
1294
|
-
await sleep(backoffMs);
|
|
1295
|
-
}
|
|
1296
|
-
throw lastErr;
|
|
1297
|
-
};
|
|
1298
|
-
if (mediaList.length === 0 && textChunks.length) {
|
|
1299
|
-
const totalChunks = textChunks.length;
|
|
1300
|
-
for (const [index, chunk] of textChunks.entries()) {
|
|
1301
|
-
const chunkStarted = Date.now();
|
|
1302
|
-
await sendWithRetry(() => msg.reply(chunk), "text");
|
|
1303
|
-
if (!skipLog) {
|
|
1304
|
-
const durationMs = Date.now() - chunkStarted;
|
|
1305
|
-
whatsappOutboundLog.debug(`Sent chunk ${index + 1}/${totalChunks} to ${msg.from} (${durationMs.toFixed(0)}ms)`);
|
|
1306
|
-
}
|
|
1307
|
-
}
|
|
1308
|
-
replyLogger.info({
|
|
1309
|
-
correlationId: msg.id ?? newConnectionId(),
|
|
1310
|
-
connectionId: connectionId ?? null,
|
|
1311
|
-
to: msg.from,
|
|
1312
|
-
from: msg.to,
|
|
1313
|
-
text: elide(replyResult.text, 240),
|
|
1314
|
-
mediaUrl: null,
|
|
1315
|
-
mediaSizeBytes: null,
|
|
1316
|
-
mediaKind: null,
|
|
1317
|
-
durationMs: Date.now() - replyStarted
|
|
1318
|
-
}, "auto-reply sent (text)");
|
|
1319
|
-
return;
|
|
1320
|
-
}
|
|
1321
|
-
const remainingText = [...textChunks];
|
|
1322
|
-
for (const [index, mediaUrl] of mediaList.entries()) {
|
|
1323
|
-
const caption = index === 0 ? remainingText.shift() || void 0 : void 0;
|
|
1324
|
-
try {
|
|
1325
|
-
const media = await loadWebMedia(mediaUrl, {
|
|
1326
|
-
maxBytes: maxMediaBytes,
|
|
1327
|
-
localRoots: params.mediaLocalRoots
|
|
1328
|
-
});
|
|
1329
|
-
if (shouldLogVerbose()) {
|
|
1330
|
-
logVerbose(`Web auto-reply media size: ${(media.buffer.length / (1024 * 1024)).toFixed(2)}MB`);
|
|
1331
|
-
logVerbose(`Web auto-reply media source: ${mediaUrl} (kind ${media.kind})`);
|
|
1332
|
-
}
|
|
1333
|
-
if (media.kind === "image") await sendWithRetry(() => msg.sendMedia({
|
|
1334
|
-
image: media.buffer,
|
|
1335
|
-
caption,
|
|
1336
|
-
mimetype: media.contentType
|
|
1337
|
-
}), "media:image");
|
|
1338
|
-
else if (media.kind === "audio") await sendWithRetry(() => msg.sendMedia({
|
|
1339
|
-
audio: media.buffer,
|
|
1340
|
-
ptt: true,
|
|
1341
|
-
mimetype: media.contentType,
|
|
1342
|
-
caption
|
|
1343
|
-
}), "media:audio");
|
|
1344
|
-
else if (media.kind === "video") await sendWithRetry(() => msg.sendMedia({
|
|
1345
|
-
video: media.buffer,
|
|
1346
|
-
caption,
|
|
1347
|
-
mimetype: media.contentType
|
|
1348
|
-
}), "media:video");
|
|
1349
|
-
else {
|
|
1350
|
-
const fileName = media.fileName ?? mediaUrl.split("/").pop() ?? "file";
|
|
1351
|
-
const mimetype = media.contentType ?? "application/octet-stream";
|
|
1352
|
-
await sendWithRetry(() => msg.sendMedia({
|
|
1353
|
-
document: media.buffer,
|
|
1354
|
-
fileName,
|
|
1355
|
-
caption,
|
|
1356
|
-
mimetype
|
|
1357
|
-
}), "media:document");
|
|
1358
|
-
}
|
|
1359
|
-
whatsappOutboundLog.info(`Sent media reply to ${msg.from} (${(media.buffer.length / (1024 * 1024)).toFixed(2)}MB)`);
|
|
1360
|
-
replyLogger.info({
|
|
1361
|
-
correlationId: msg.id ?? newConnectionId(),
|
|
1362
|
-
connectionId: connectionId ?? null,
|
|
1363
|
-
to: msg.from,
|
|
1364
|
-
from: msg.to,
|
|
1365
|
-
text: caption ?? null,
|
|
1366
|
-
mediaUrl,
|
|
1367
|
-
mediaSizeBytes: media.buffer.length,
|
|
1368
|
-
mediaKind: media.kind,
|
|
1369
|
-
durationMs: Date.now() - replyStarted
|
|
1370
|
-
}, "auto-reply sent (media)");
|
|
1371
|
-
} catch (err) {
|
|
1372
|
-
whatsappOutboundLog.error(`Failed sending web media to ${msg.from}: ${formatError(err)}`);
|
|
1373
|
-
replyLogger.warn({
|
|
1374
|
-
err,
|
|
1375
|
-
mediaUrl
|
|
1376
|
-
}, "failed to send web media reply");
|
|
1377
|
-
if (index === 0) {
|
|
1378
|
-
const warning = err instanceof Error ? `⚠️ Media failed: ${err.message}` : "⚠️ Media failed.";
|
|
1379
|
-
const fallbackText = [remainingText.shift() ?? caption ?? "", warning].filter(Boolean).join("\n");
|
|
1380
|
-
if (fallbackText) {
|
|
1381
|
-
whatsappOutboundLog.warn(`Media skipped; sent text-only to ${msg.from}`);
|
|
1382
|
-
await msg.reply(fallbackText);
|
|
1383
|
-
}
|
|
1384
|
-
}
|
|
1385
|
-
}
|
|
1386
|
-
}
|
|
1387
|
-
for (const chunk of remainingText) await msg.reply(chunk);
|
|
1388
|
-
}
|
|
1389
|
-
|
|
1390
|
-
//#endregion
|
|
1391
|
-
//#region src/web/auto-reply/monitor/ack-reaction.ts
|
|
1392
|
-
function maybeSendAckReaction(params) {
|
|
1393
|
-
if (!params.msg.id) return;
|
|
1394
|
-
const ackConfig = params.cfg.channels?.whatsapp?.ackReaction;
|
|
1395
|
-
const emoji = (ackConfig?.emoji ?? "").trim();
|
|
1396
|
-
const directEnabled = ackConfig?.direct ?? true;
|
|
1397
|
-
const groupMode = ackConfig?.group ?? "mentions";
|
|
1398
|
-
const conversationIdForCheck = params.msg.conversationId ?? params.msg.from;
|
|
1399
|
-
const activation = params.msg.chatType === "group" ? resolveGroupActivationFor({
|
|
1400
|
-
cfg: params.cfg,
|
|
1401
|
-
agentId: params.agentId,
|
|
1402
|
-
sessionKey: params.sessionKey,
|
|
1403
|
-
conversationId: conversationIdForCheck
|
|
1404
|
-
}) : null;
|
|
1405
|
-
const shouldSendReaction = () => shouldAckReactionForWhatsApp({
|
|
1406
|
-
emoji,
|
|
1407
|
-
isDirect: params.msg.chatType === "direct",
|
|
1408
|
-
isGroup: params.msg.chatType === "group",
|
|
1409
|
-
directEnabled,
|
|
1410
|
-
groupMode,
|
|
1411
|
-
wasMentioned: params.msg.wasMentioned === true,
|
|
1412
|
-
groupActivated: activation === "always"
|
|
1413
|
-
});
|
|
1414
|
-
if (!shouldSendReaction()) return;
|
|
1415
|
-
params.info({
|
|
1416
|
-
chatId: params.msg.chatId,
|
|
1417
|
-
messageId: params.msg.id,
|
|
1418
|
-
emoji
|
|
1419
|
-
}, "sending ack reaction");
|
|
1420
|
-
sendReactionWhatsApp(params.msg.chatId, params.msg.id, emoji, {
|
|
1421
|
-
verbose: params.verbose,
|
|
1422
|
-
fromMe: false,
|
|
1423
|
-
participant: params.msg.senderJid,
|
|
1424
|
-
accountId: params.accountId
|
|
1425
|
-
}).catch((err) => {
|
|
1426
|
-
params.warn({
|
|
1427
|
-
error: formatError(err),
|
|
1428
|
-
chatId: params.msg.chatId,
|
|
1429
|
-
messageId: params.msg.id
|
|
1430
|
-
}, "failed to send ack reaction");
|
|
1431
|
-
logVerbose(`WhatsApp ack reaction failed for chat ${params.msg.chatId}: ${formatError(err)}`);
|
|
1432
|
-
});
|
|
1433
|
-
}
|
|
1434
|
-
|
|
1435
|
-
//#endregion
|
|
1436
|
-
//#region src/web/auto-reply/monitor/message-line.ts
|
|
1437
|
-
function formatReplyContext(msg) {
|
|
1438
|
-
if (!msg.replyToBody) return null;
|
|
1439
|
-
return `[Replying to ${msg.replyToSender ?? "unknown sender"}${msg.replyToId ? ` id:${msg.replyToId}` : ""}]\n${msg.replyToBody}\n[/Replying]`;
|
|
1440
|
-
}
|
|
1441
|
-
function buildInboundLine(params) {
|
|
1442
|
-
const { cfg, msg, agentId, previousTimestamp, envelope } = params;
|
|
1443
|
-
const messagePrefix = resolveMessagePrefix(cfg, agentId, {
|
|
1444
|
-
configured: cfg.channels?.whatsapp?.messagePrefix,
|
|
1445
|
-
hasAllowFrom: (cfg.channels?.whatsapp?.allowFrom?.length ?? 0) > 0
|
|
1446
|
-
});
|
|
1447
|
-
const prefixStr = messagePrefix ? `${messagePrefix} ` : "";
|
|
1448
|
-
const replyContext = formatReplyContext(msg);
|
|
1449
|
-
const baseLine = `${prefixStr}${msg.body}${replyContext ? `\n\n${replyContext}` : ""}`;
|
|
1450
|
-
return formatInboundEnvelope({
|
|
1451
|
-
channel: "WhatsApp",
|
|
1452
|
-
from: msg.chatType === "group" ? msg.from : msg.from?.replace(/^whatsapp:/, ""),
|
|
1453
|
-
timestamp: msg.timestamp,
|
|
1454
|
-
body: baseLine,
|
|
1455
|
-
chatType: msg.chatType,
|
|
1456
|
-
sender: {
|
|
1457
|
-
name: msg.senderName,
|
|
1458
|
-
e164: msg.senderE164,
|
|
1459
|
-
id: msg.senderJid
|
|
1460
|
-
},
|
|
1461
|
-
previousTimestamp,
|
|
1462
|
-
envelope
|
|
1463
|
-
});
|
|
1464
|
-
}
|
|
1465
|
-
|
|
1466
|
-
//#endregion
|
|
1467
|
-
//#region src/web/auto-reply/monitor/process-message.ts
|
|
1468
|
-
function normalizeAllowFromE164(values) {
|
|
1469
|
-
return (Array.isArray(values) ? values : []).map((entry) => String(entry).trim()).filter((entry) => entry && entry !== "*").map((entry) => normalizeE164(entry)).filter((entry) => Boolean(entry));
|
|
1470
|
-
}
|
|
1471
|
-
async function resolveWhatsAppCommandAuthorized(params) {
|
|
1472
|
-
if (!(params.cfg.commands?.useAccessGroups !== false)) return true;
|
|
1473
|
-
const isGroup = params.msg.chatType === "group";
|
|
1474
|
-
const senderE164 = normalizeE164(isGroup ? params.msg.senderE164 ?? "" : params.msg.senderE164 ?? params.msg.from ?? "");
|
|
1475
|
-
if (!senderE164) return false;
|
|
1476
|
-
const account = resolveWhatsAppAccount({
|
|
1477
|
-
cfg: params.cfg,
|
|
1478
|
-
accountId: params.msg.accountId
|
|
1479
|
-
});
|
|
1480
|
-
const dmPolicy = account.dmPolicy ?? "pairing";
|
|
1481
|
-
const configuredAllowFrom = account.allowFrom ?? [];
|
|
1482
|
-
const configuredGroupAllowFrom = account.groupAllowFrom ?? (configuredAllowFrom.length > 0 ? configuredAllowFrom : void 0);
|
|
1483
|
-
if (isGroup) {
|
|
1484
|
-
if (!configuredGroupAllowFrom || configuredGroupAllowFrom.length === 0) return false;
|
|
1485
|
-
if (configuredGroupAllowFrom.some((v) => String(v).trim() === "*")) return true;
|
|
1486
|
-
return normalizeAllowFromE164(configuredGroupAllowFrom).includes(senderE164);
|
|
1487
|
-
}
|
|
1488
|
-
const storeAllowFrom = dmPolicy === "allowlist" ? [] : await readChannelAllowFromStore("whatsapp", process.env, params.msg.accountId).catch(() => []);
|
|
1489
|
-
const combinedAllowFrom = Array.from(new Set([...configuredAllowFrom ?? [], ...storeAllowFrom]));
|
|
1490
|
-
const allowFrom = combinedAllowFrom.length > 0 ? combinedAllowFrom : params.msg.selfE164 ? [params.msg.selfE164] : [];
|
|
1491
|
-
if (allowFrom.some((v) => String(v).trim() === "*")) return true;
|
|
1492
|
-
return normalizeAllowFromE164(allowFrom).includes(senderE164);
|
|
1493
|
-
}
|
|
1494
|
-
async function processMessage(params) {
|
|
1495
|
-
const conversationId = params.msg.conversationId ?? params.msg.from;
|
|
1496
|
-
const storePath = resolveStorePath(params.cfg.session?.store, { agentId: params.route.agentId });
|
|
1497
|
-
const envelopeOptions = resolveEnvelopeFormatOptions(params.cfg);
|
|
1498
|
-
const previousTimestamp = readSessionUpdatedAt({
|
|
1499
|
-
storePath,
|
|
1500
|
-
sessionKey: params.route.sessionKey
|
|
1501
|
-
});
|
|
1502
|
-
let combinedBody = buildInboundLine({
|
|
1503
|
-
cfg: params.cfg,
|
|
1504
|
-
msg: params.msg,
|
|
1505
|
-
agentId: params.route.agentId,
|
|
1506
|
-
previousTimestamp,
|
|
1507
|
-
envelope: envelopeOptions
|
|
1508
|
-
});
|
|
1509
|
-
let shouldClearGroupHistory = false;
|
|
1510
|
-
if (params.msg.chatType === "group") {
|
|
1511
|
-
const history = params.groupHistory ?? params.groupHistories.get(params.groupHistoryKey) ?? [];
|
|
1512
|
-
if (history.length > 0) combinedBody = buildHistoryContextFromEntries({
|
|
1513
|
-
entries: history.map((m) => ({
|
|
1514
|
-
sender: m.sender,
|
|
1515
|
-
body: m.body,
|
|
1516
|
-
timestamp: m.timestamp
|
|
1517
|
-
})),
|
|
1518
|
-
currentMessage: combinedBody,
|
|
1519
|
-
excludeLast: false,
|
|
1520
|
-
formatEntry: (entry) => {
|
|
1521
|
-
return formatInboundEnvelope({
|
|
1522
|
-
channel: "WhatsApp",
|
|
1523
|
-
from: conversationId,
|
|
1524
|
-
timestamp: entry.timestamp,
|
|
1525
|
-
body: entry.body,
|
|
1526
|
-
chatType: "group",
|
|
1527
|
-
senderLabel: entry.sender,
|
|
1528
|
-
envelope: envelopeOptions
|
|
1529
|
-
});
|
|
1530
|
-
}
|
|
1531
|
-
});
|
|
1532
|
-
shouldClearGroupHistory = !(params.suppressGroupHistoryClear ?? false);
|
|
1533
|
-
}
|
|
1534
|
-
const combinedEchoKey = params.buildCombinedEchoKey({
|
|
1535
|
-
sessionKey: params.route.sessionKey,
|
|
1536
|
-
combinedBody
|
|
1537
|
-
});
|
|
1538
|
-
if (params.echoHas(combinedEchoKey)) {
|
|
1539
|
-
logVerbose("Skipping auto-reply: detected echo for combined message");
|
|
1540
|
-
params.echoForget(combinedEchoKey);
|
|
1541
|
-
return false;
|
|
1542
|
-
}
|
|
1543
|
-
maybeSendAckReaction({
|
|
1544
|
-
cfg: params.cfg,
|
|
1545
|
-
msg: params.msg,
|
|
1546
|
-
agentId: params.route.agentId,
|
|
1547
|
-
sessionKey: params.route.sessionKey,
|
|
1548
|
-
conversationId,
|
|
1549
|
-
verbose: params.verbose,
|
|
1550
|
-
accountId: params.route.accountId,
|
|
1551
|
-
info: params.replyLogger.info.bind(params.replyLogger),
|
|
1552
|
-
warn: params.replyLogger.warn.bind(params.replyLogger)
|
|
1553
|
-
});
|
|
1554
|
-
const correlationId = params.msg.id ?? newConnectionId();
|
|
1555
|
-
params.replyLogger.info({
|
|
1556
|
-
connectionId: params.connectionId,
|
|
1557
|
-
correlationId,
|
|
1558
|
-
from: params.msg.chatType === "group" ? conversationId : params.msg.from,
|
|
1559
|
-
to: params.msg.to,
|
|
1560
|
-
body: elide(combinedBody, 240),
|
|
1561
|
-
mediaType: params.msg.mediaType ?? null,
|
|
1562
|
-
mediaPath: params.msg.mediaPath ?? null
|
|
1563
|
-
}, "inbound web message");
|
|
1564
|
-
const fromDisplay = params.msg.chatType === "group" ? conversationId : params.msg.from;
|
|
1565
|
-
const kindLabel = params.msg.mediaType ? `, ${params.msg.mediaType}` : "";
|
|
1566
|
-
whatsappInboundLog.info(`Inbound message ${fromDisplay} -> ${params.msg.to} (${params.msg.chatType}${kindLabel}, ${combinedBody.length} chars)`);
|
|
1567
|
-
if (shouldLogVerbose()) whatsappInboundLog.debug(`Inbound body: ${elide(combinedBody, 400)}`);
|
|
1568
|
-
const dmRouteTarget = params.msg.chatType !== "group" ? (() => {
|
|
1569
|
-
if (params.msg.senderE164) return normalizeE164(params.msg.senderE164);
|
|
1570
|
-
if (params.msg.from.includes("@")) return jidToE164(params.msg.from);
|
|
1571
|
-
return normalizeE164(params.msg.from);
|
|
1572
|
-
})() : void 0;
|
|
1573
|
-
const textLimit = params.maxMediaTextChunkLimit ?? resolveTextChunkLimit(params.cfg, "whatsapp");
|
|
1574
|
-
const chunkMode = resolveChunkMode(params.cfg, "whatsapp", params.route.accountId);
|
|
1575
|
-
const tableMode = resolveMarkdownTableMode({
|
|
1576
|
-
cfg: params.cfg,
|
|
1577
|
-
channel: "whatsapp",
|
|
1578
|
-
accountId: params.route.accountId
|
|
1579
|
-
});
|
|
1580
|
-
const mediaLocalRoots = getAgentScopedMediaLocalRoots(params.cfg, params.route.agentId);
|
|
1581
|
-
let didSendReply = false;
|
|
1582
|
-
const commandAuthorized = shouldComputeCommandAuthorized(params.msg.body, params.cfg) ? await resolveWhatsAppCommandAuthorized({
|
|
1583
|
-
cfg: params.cfg,
|
|
1584
|
-
msg: params.msg
|
|
1585
|
-
}) : void 0;
|
|
1586
|
-
const configuredResponsePrefix = params.cfg.messages?.responsePrefix;
|
|
1587
|
-
const { onModelSelected, ...prefixOptions } = createReplyPrefixOptions({
|
|
1588
|
-
cfg: params.cfg,
|
|
1589
|
-
agentId: params.route.agentId,
|
|
1590
|
-
channel: "whatsapp",
|
|
1591
|
-
accountId: params.route.accountId
|
|
1592
|
-
});
|
|
1593
|
-
const isSelfChat = params.msg.chatType !== "group" && Boolean(params.msg.selfE164) && normalizeE164(params.msg.from) === normalizeE164(params.msg.selfE164 ?? "");
|
|
1594
|
-
const responsePrefix = prefixOptions.responsePrefix ?? (configuredResponsePrefix === void 0 && isSelfChat ? resolveIdentityNamePrefix(params.cfg, params.route.agentId) ?? "[remoteclaw]" : void 0);
|
|
1595
|
-
const inboundHistory = params.msg.chatType === "group" ? (params.groupHistory ?? params.groupHistories.get(params.groupHistoryKey) ?? []).map((entry) => ({
|
|
1596
|
-
sender: entry.sender,
|
|
1597
|
-
body: entry.body,
|
|
1598
|
-
timestamp: entry.timestamp
|
|
1599
|
-
})) : void 0;
|
|
1600
|
-
const ctxPayload = finalizeInboundContext({
|
|
1601
|
-
Body: combinedBody,
|
|
1602
|
-
BodyForAgent: params.msg.body,
|
|
1603
|
-
InboundHistory: inboundHistory,
|
|
1604
|
-
RawBody: params.msg.body,
|
|
1605
|
-
CommandBody: params.msg.body,
|
|
1606
|
-
From: params.msg.from,
|
|
1607
|
-
To: params.msg.to,
|
|
1608
|
-
SessionKey: params.route.sessionKey,
|
|
1609
|
-
AccountId: params.route.accountId,
|
|
1610
|
-
MessageSid: params.msg.id,
|
|
1611
|
-
ReplyToId: params.msg.replyToId,
|
|
1612
|
-
ReplyToBody: params.msg.replyToBody,
|
|
1613
|
-
ReplyToSender: params.msg.replyToSender,
|
|
1614
|
-
MediaPath: params.msg.mediaPath,
|
|
1615
|
-
MediaUrl: params.msg.mediaUrl,
|
|
1616
|
-
MediaType: params.msg.mediaType,
|
|
1617
|
-
ChatType: params.msg.chatType,
|
|
1618
|
-
ConversationLabel: params.msg.chatType === "group" ? conversationId : params.msg.from,
|
|
1619
|
-
GroupSubject: params.msg.groupSubject,
|
|
1620
|
-
GroupMembers: formatGroupMembers({
|
|
1621
|
-
participants: params.msg.groupParticipants,
|
|
1622
|
-
roster: params.groupMemberNames.get(params.groupHistoryKey),
|
|
1623
|
-
fallbackE164: params.msg.senderE164
|
|
1624
|
-
}),
|
|
1625
|
-
SenderName: params.msg.senderName,
|
|
1626
|
-
SenderId: params.msg.senderJid?.trim() || params.msg.senderE164,
|
|
1627
|
-
SenderE164: params.msg.senderE164,
|
|
1628
|
-
CommandAuthorized: commandAuthorized,
|
|
1629
|
-
WasMentioned: params.msg.wasMentioned,
|
|
1630
|
-
...params.msg.location ? toLocationContext(params.msg.location) : {},
|
|
1631
|
-
Provider: "whatsapp",
|
|
1632
|
-
Surface: "whatsapp",
|
|
1633
|
-
OriginatingChannel: "whatsapp",
|
|
1634
|
-
OriginatingTo: params.msg.from
|
|
1635
|
-
});
|
|
1636
|
-
if (dmRouteTarget && params.route.sessionKey === params.route.mainSessionKey) updateLastRouteInBackground({
|
|
1637
|
-
cfg: params.cfg,
|
|
1638
|
-
backgroundTasks: params.backgroundTasks,
|
|
1639
|
-
storeAgentId: params.route.agentId,
|
|
1640
|
-
sessionKey: params.route.mainSessionKey,
|
|
1641
|
-
channel: "whatsapp",
|
|
1642
|
-
to: dmRouteTarget,
|
|
1643
|
-
accountId: params.route.accountId,
|
|
1644
|
-
ctx: ctxPayload,
|
|
1645
|
-
warn: params.replyLogger.warn.bind(params.replyLogger)
|
|
1646
|
-
});
|
|
1647
|
-
const metaTask = recordSessionMetaFromInbound({
|
|
1648
|
-
storePath,
|
|
1649
|
-
sessionKey: params.route.sessionKey,
|
|
1650
|
-
ctx: ctxPayload
|
|
1651
|
-
}).catch((err) => {
|
|
1652
|
-
params.replyLogger.warn({
|
|
1653
|
-
error: formatError(err),
|
|
1654
|
-
storePath,
|
|
1655
|
-
sessionKey: params.route.sessionKey
|
|
1656
|
-
}, "failed updating session meta");
|
|
1657
|
-
});
|
|
1658
|
-
trackBackgroundTask(params.backgroundTasks, metaTask);
|
|
1659
|
-
const { queuedFinal } = await dispatchReplyWithBufferedBlockDispatcher({
|
|
1660
|
-
ctx: ctxPayload,
|
|
1661
|
-
cfg: params.cfg,
|
|
1662
|
-
replyResolver: params.replyResolver,
|
|
1663
|
-
dispatcherOptions: {
|
|
1664
|
-
...prefixOptions,
|
|
1665
|
-
responsePrefix,
|
|
1666
|
-
deliver: async (payload, info) => {
|
|
1667
|
-
if (info.kind !== "final") return;
|
|
1668
|
-
await deliverWebReply({
|
|
1669
|
-
replyResult: payload,
|
|
1670
|
-
msg: params.msg,
|
|
1671
|
-
mediaLocalRoots,
|
|
1672
|
-
maxMediaBytes: params.maxMediaBytes,
|
|
1673
|
-
textLimit,
|
|
1674
|
-
chunkMode,
|
|
1675
|
-
replyLogger: params.replyLogger,
|
|
1676
|
-
connectionId: params.connectionId,
|
|
1677
|
-
skipLog: false,
|
|
1678
|
-
tableMode
|
|
1679
|
-
});
|
|
1680
|
-
didSendReply = true;
|
|
1681
|
-
const shouldLog = payload.text ? true : void 0;
|
|
1682
|
-
params.rememberSentText(payload.text, {
|
|
1683
|
-
combinedBody,
|
|
1684
|
-
combinedBodySessionKey: params.route.sessionKey,
|
|
1685
|
-
logVerboseMessage: shouldLog
|
|
1686
|
-
});
|
|
1687
|
-
const fromDisplay = params.msg.chatType === "group" ? conversationId : params.msg.from ?? "unknown";
|
|
1688
|
-
const hasMedia = Boolean(payload.mediaUrl || payload.mediaUrls?.length);
|
|
1689
|
-
whatsappOutboundLog.info(`Auto-replied to ${fromDisplay}${hasMedia ? " (media)" : ""}`);
|
|
1690
|
-
if (shouldLogVerbose()) {
|
|
1691
|
-
const preview = payload.text != null ? elide(payload.text, 400) : "<media>";
|
|
1692
|
-
whatsappOutboundLog.debug(`Reply body: ${preview}${hasMedia ? " (media)" : ""}`);
|
|
1693
|
-
}
|
|
1694
|
-
},
|
|
1695
|
-
onError: (err, info) => {
|
|
1696
|
-
const label = info.kind === "tool" ? "tool update" : info.kind === "block" ? "block update" : "auto-reply";
|
|
1697
|
-
whatsappOutboundLog.error(`Failed sending web ${label} to ${params.msg.from ?? conversationId}: ${formatError(err)}`);
|
|
1698
|
-
},
|
|
1699
|
-
onReplyStart: params.msg.sendComposing
|
|
1700
|
-
},
|
|
1701
|
-
replyOptions: {
|
|
1702
|
-
disableBlockStreaming: true,
|
|
1703
|
-
onModelSelected
|
|
1704
|
-
}
|
|
1705
|
-
});
|
|
1706
|
-
if (!queuedFinal) {
|
|
1707
|
-
if (shouldClearGroupHistory) params.groupHistories.set(params.groupHistoryKey, []);
|
|
1708
|
-
logVerbose("Skipping auto-reply: silent token or no text/media returned from resolver");
|
|
1709
|
-
return false;
|
|
1710
|
-
}
|
|
1711
|
-
if (shouldClearGroupHistory) params.groupHistories.set(params.groupHistoryKey, []);
|
|
1712
|
-
return didSendReply;
|
|
1713
|
-
}
|
|
1714
|
-
|
|
1715
|
-
//#endregion
|
|
1716
|
-
//#region src/web/auto-reply/monitor/on-message.ts
|
|
1717
|
-
function createWebOnMessageHandler(params) {
|
|
1718
|
-
const processForRoute = async (msg, route, groupHistoryKey, opts) => processMessage({
|
|
1719
|
-
cfg: params.cfg,
|
|
1720
|
-
msg,
|
|
1721
|
-
route,
|
|
1722
|
-
groupHistoryKey,
|
|
1723
|
-
groupHistories: params.groupHistories,
|
|
1724
|
-
groupMemberNames: params.groupMemberNames,
|
|
1725
|
-
connectionId: params.connectionId,
|
|
1726
|
-
verbose: params.verbose,
|
|
1727
|
-
maxMediaBytes: params.maxMediaBytes,
|
|
1728
|
-
replyResolver: params.replyResolver,
|
|
1729
|
-
replyLogger: params.replyLogger,
|
|
1730
|
-
backgroundTasks: params.backgroundTasks,
|
|
1731
|
-
rememberSentText: params.echoTracker.rememberText,
|
|
1732
|
-
echoHas: params.echoTracker.has,
|
|
1733
|
-
echoForget: params.echoTracker.forget,
|
|
1734
|
-
buildCombinedEchoKey: params.echoTracker.buildCombinedKey,
|
|
1735
|
-
groupHistory: opts?.groupHistory,
|
|
1736
|
-
suppressGroupHistoryClear: opts?.suppressGroupHistoryClear
|
|
1737
|
-
});
|
|
1738
|
-
return async (msg) => {
|
|
1739
|
-
const conversationId = msg.conversationId ?? msg.from;
|
|
1740
|
-
const peerId = resolvePeerId(msg);
|
|
1741
|
-
const route = resolveAgentRoute({
|
|
1742
|
-
cfg: loadConfig(),
|
|
1743
|
-
channel: "whatsapp",
|
|
1744
|
-
accountId: msg.accountId,
|
|
1745
|
-
peer: {
|
|
1746
|
-
kind: msg.chatType === "group" ? "group" : "direct",
|
|
1747
|
-
id: peerId
|
|
1748
|
-
}
|
|
1749
|
-
});
|
|
1750
|
-
const groupHistoryKey = msg.chatType === "group" ? buildGroupHistoryKey({
|
|
1751
|
-
channel: "whatsapp",
|
|
1752
|
-
accountId: route.accountId,
|
|
1753
|
-
peerKind: "group",
|
|
1754
|
-
peerId
|
|
1755
|
-
}) : route.sessionKey;
|
|
1756
|
-
if (msg.from === msg.to) logVerbose(`📱 Same-phone mode detected (from === to: ${msg.from})`);
|
|
1757
|
-
if (params.echoTracker.has(msg.body)) {
|
|
1758
|
-
logVerbose("Skipping auto-reply: detected echo (message matches recently sent text)");
|
|
1759
|
-
params.echoTracker.forget(msg.body);
|
|
1760
|
-
return;
|
|
1761
|
-
}
|
|
1762
|
-
if (msg.chatType === "group") {
|
|
1763
|
-
const metaCtx = {
|
|
1764
|
-
From: msg.from,
|
|
1765
|
-
To: msg.to,
|
|
1766
|
-
SessionKey: route.sessionKey,
|
|
1767
|
-
AccountId: route.accountId,
|
|
1768
|
-
ChatType: msg.chatType,
|
|
1769
|
-
ConversationLabel: conversationId,
|
|
1770
|
-
GroupSubject: msg.groupSubject,
|
|
1771
|
-
SenderName: msg.senderName,
|
|
1772
|
-
SenderId: msg.senderJid?.trim() || msg.senderE164,
|
|
1773
|
-
SenderE164: msg.senderE164,
|
|
1774
|
-
Provider: "whatsapp",
|
|
1775
|
-
Surface: "whatsapp",
|
|
1776
|
-
OriginatingChannel: "whatsapp",
|
|
1777
|
-
OriginatingTo: conversationId
|
|
1778
|
-
};
|
|
1779
|
-
updateLastRouteInBackground({
|
|
1780
|
-
cfg: params.cfg,
|
|
1781
|
-
backgroundTasks: params.backgroundTasks,
|
|
1782
|
-
storeAgentId: route.agentId,
|
|
1783
|
-
sessionKey: route.sessionKey,
|
|
1784
|
-
channel: "whatsapp",
|
|
1785
|
-
to: conversationId,
|
|
1786
|
-
accountId: route.accountId,
|
|
1787
|
-
ctx: metaCtx,
|
|
1788
|
-
warn: params.replyLogger.warn.bind(params.replyLogger)
|
|
1789
|
-
});
|
|
1790
|
-
if (!applyGroupGating({
|
|
1791
|
-
cfg: params.cfg,
|
|
1792
|
-
msg,
|
|
1793
|
-
conversationId,
|
|
1794
|
-
groupHistoryKey,
|
|
1795
|
-
agentId: route.agentId,
|
|
1796
|
-
sessionKey: route.sessionKey,
|
|
1797
|
-
baseMentionConfig: params.baseMentionConfig,
|
|
1798
|
-
authDir: params.account.authDir,
|
|
1799
|
-
groupHistories: params.groupHistories,
|
|
1800
|
-
groupHistoryLimit: params.groupHistoryLimit,
|
|
1801
|
-
groupMemberNames: params.groupMemberNames,
|
|
1802
|
-
logVerbose,
|
|
1803
|
-
replyLogger: params.replyLogger
|
|
1804
|
-
}).shouldProcess) return;
|
|
1805
|
-
} else if (!msg.senderE164 && peerId && peerId.startsWith("+")) msg.senderE164 = normalizeE164(peerId) ?? msg.senderE164;
|
|
1806
|
-
if (await maybeBroadcastMessage({
|
|
1807
|
-
cfg: params.cfg,
|
|
1808
|
-
msg,
|
|
1809
|
-
peerId,
|
|
1810
|
-
route,
|
|
1811
|
-
groupHistoryKey,
|
|
1812
|
-
groupHistories: params.groupHistories,
|
|
1813
|
-
processMessage: processForRoute
|
|
1814
|
-
})) return;
|
|
1815
|
-
await processForRoute(msg, route, groupHistoryKey);
|
|
1816
|
-
};
|
|
1817
|
-
}
|
|
1818
|
-
|
|
1819
|
-
//#endregion
|
|
1820
|
-
//#region src/web/auto-reply/monitor.ts
|
|
1821
|
-
function isNonRetryableWebCloseStatus(statusCode) {
|
|
1822
|
-
return statusCode === 440;
|
|
1823
|
-
}
|
|
1824
|
-
async function monitorWebChannel(verbose, listenerFactory = monitorWebInbox, keepAlive = true, replyResolver = getReplyFromConfig, runtime = defaultRuntime, abortSignal, tuning = {}) {
|
|
1825
|
-
const runId = newConnectionId();
|
|
1826
|
-
const replyLogger = getChildLogger({
|
|
1827
|
-
module: "web-auto-reply",
|
|
1828
|
-
runId
|
|
1829
|
-
});
|
|
1830
|
-
const heartbeatLogger = getChildLogger({
|
|
1831
|
-
module: "web-heartbeat",
|
|
1832
|
-
runId
|
|
1833
|
-
});
|
|
1834
|
-
const reconnectLogger = getChildLogger({
|
|
1835
|
-
module: "web-reconnect",
|
|
1836
|
-
runId
|
|
1837
|
-
});
|
|
1838
|
-
const status = {
|
|
1839
|
-
running: true,
|
|
1840
|
-
connected: false,
|
|
1841
|
-
reconnectAttempts: 0,
|
|
1842
|
-
lastConnectedAt: null,
|
|
1843
|
-
lastDisconnect: null,
|
|
1844
|
-
lastMessageAt: null,
|
|
1845
|
-
lastEventAt: null,
|
|
1846
|
-
lastError: null
|
|
1847
|
-
};
|
|
1848
|
-
const emitStatus = () => {
|
|
1849
|
-
tuning.statusSink?.({
|
|
1850
|
-
...status,
|
|
1851
|
-
lastDisconnect: status.lastDisconnect ? { ...status.lastDisconnect } : null
|
|
1852
|
-
});
|
|
1853
|
-
};
|
|
1854
|
-
emitStatus();
|
|
1855
|
-
const baseCfg = loadConfig();
|
|
1856
|
-
const account = resolveWhatsAppAccount({
|
|
1857
|
-
cfg: baseCfg,
|
|
1858
|
-
accountId: tuning.accountId
|
|
1859
|
-
});
|
|
1860
|
-
const cfg = {
|
|
1861
|
-
...baseCfg,
|
|
1862
|
-
channels: {
|
|
1863
|
-
...baseCfg.channels,
|
|
1864
|
-
whatsapp: {
|
|
1865
|
-
...baseCfg.channels?.whatsapp,
|
|
1866
|
-
ackReaction: account.ackReaction,
|
|
1867
|
-
messagePrefix: account.messagePrefix,
|
|
1868
|
-
allowFrom: account.allowFrom,
|
|
1869
|
-
groupAllowFrom: account.groupAllowFrom,
|
|
1870
|
-
groupPolicy: account.groupPolicy,
|
|
1871
|
-
textChunkLimit: account.textChunkLimit,
|
|
1872
|
-
chunkMode: account.chunkMode,
|
|
1873
|
-
mediaMaxMb: account.mediaMaxMb,
|
|
1874
|
-
blockStreaming: account.blockStreaming,
|
|
1875
|
-
groups: account.groups
|
|
1876
|
-
}
|
|
1877
|
-
}
|
|
1878
|
-
};
|
|
1879
|
-
const configuredMaxMb = cfg.agents?.defaults?.mediaMaxMb;
|
|
1880
|
-
const maxMediaBytes = typeof configuredMaxMb === "number" && configuredMaxMb > 0 ? configuredMaxMb * 1024 * 1024 : DEFAULT_WEB_MEDIA_BYTES;
|
|
1881
|
-
const heartbeatSeconds = resolveHeartbeatSeconds(cfg, tuning.heartbeatSeconds);
|
|
1882
|
-
const reconnectPolicy = resolveReconnectPolicy(cfg, tuning.reconnect);
|
|
1883
|
-
const baseMentionConfig = buildMentionConfig(cfg);
|
|
1884
|
-
const groupHistoryLimit = cfg.channels?.whatsapp?.accounts?.[tuning.accountId ?? ""]?.historyLimit ?? cfg.channels?.whatsapp?.historyLimit ?? cfg.messages?.groupChat?.historyLimit ?? DEFAULT_GROUP_HISTORY_LIMIT;
|
|
1885
|
-
const groupHistories = /* @__PURE__ */ new Map();
|
|
1886
|
-
const groupMemberNames = /* @__PURE__ */ new Map();
|
|
1887
|
-
const echoTracker = createEchoTracker({
|
|
1888
|
-
maxItems: 100,
|
|
1889
|
-
logVerbose
|
|
1890
|
-
});
|
|
1891
|
-
const sleep = tuning.sleep ?? ((ms, signal) => sleepWithAbort(ms, signal ?? abortSignal));
|
|
1892
|
-
const stopRequested = () => abortSignal?.aborted === true;
|
|
1893
|
-
const abortPromise = abortSignal && new Promise((resolve) => abortSignal.addEventListener("abort", () => resolve("aborted"), { once: true }));
|
|
1894
|
-
const currentMaxListeners = process.getMaxListeners?.() ?? 10;
|
|
1895
|
-
if (process.setMaxListeners && currentMaxListeners < 50) process.setMaxListeners(50);
|
|
1896
|
-
let sigintStop = false;
|
|
1897
|
-
const handleSigint = () => {
|
|
1898
|
-
sigintStop = true;
|
|
1899
|
-
};
|
|
1900
|
-
process.once("SIGINT", handleSigint);
|
|
1901
|
-
let reconnectAttempts = 0;
|
|
1902
|
-
while (true) {
|
|
1903
|
-
if (stopRequested()) break;
|
|
1904
|
-
const connectionId = newConnectionId();
|
|
1905
|
-
const startedAt = Date.now();
|
|
1906
|
-
let heartbeat = null;
|
|
1907
|
-
let watchdogTimer = null;
|
|
1908
|
-
let lastMessageAt = null;
|
|
1909
|
-
let handledMessages = 0;
|
|
1910
|
-
let unregisterUnhandled = null;
|
|
1911
|
-
const MESSAGE_TIMEOUT_MS = tuning.messageTimeoutMs ?? 1800 * 1e3;
|
|
1912
|
-
const WATCHDOG_CHECK_MS = tuning.watchdogCheckMs ?? 60 * 1e3;
|
|
1913
|
-
const backgroundTasks = /* @__PURE__ */ new Set();
|
|
1914
|
-
const onMessage = createWebOnMessageHandler({
|
|
1915
|
-
cfg,
|
|
1916
|
-
verbose,
|
|
1917
|
-
connectionId,
|
|
1918
|
-
maxMediaBytes,
|
|
1919
|
-
groupHistoryLimit,
|
|
1920
|
-
groupHistories,
|
|
1921
|
-
groupMemberNames,
|
|
1922
|
-
echoTracker,
|
|
1923
|
-
backgroundTasks,
|
|
1924
|
-
replyResolver: replyResolver ?? getReplyFromConfig,
|
|
1925
|
-
replyLogger,
|
|
1926
|
-
baseMentionConfig,
|
|
1927
|
-
account
|
|
1928
|
-
});
|
|
1929
|
-
const inboundDebounceMs = resolveInboundDebounceMs({
|
|
1930
|
-
cfg,
|
|
1931
|
-
channel: "whatsapp"
|
|
1932
|
-
});
|
|
1933
|
-
const shouldDebounce = (msg) => {
|
|
1934
|
-
if (msg.mediaPath || msg.mediaType) return false;
|
|
1935
|
-
if (msg.location) return false;
|
|
1936
|
-
if (msg.replyToId || msg.replyToBody) return false;
|
|
1937
|
-
return !hasControlCommand(msg.body, cfg);
|
|
1938
|
-
};
|
|
1939
|
-
const listener = await (listenerFactory ?? monitorWebInbox)({
|
|
1940
|
-
verbose,
|
|
1941
|
-
accountId: account.accountId,
|
|
1942
|
-
authDir: account.authDir,
|
|
1943
|
-
mediaMaxMb: account.mediaMaxMb,
|
|
1944
|
-
sendReadReceipts: account.sendReadReceipts,
|
|
1945
|
-
debounceMs: inboundDebounceMs,
|
|
1946
|
-
shouldDebounce,
|
|
1947
|
-
onMessage: async (msg) => {
|
|
1948
|
-
handledMessages += 1;
|
|
1949
|
-
lastMessageAt = Date.now();
|
|
1950
|
-
status.lastMessageAt = lastMessageAt;
|
|
1951
|
-
status.lastEventAt = lastMessageAt;
|
|
1952
|
-
emitStatus();
|
|
1953
|
-
await onMessage(msg);
|
|
1954
|
-
}
|
|
1955
|
-
});
|
|
1956
|
-
status.connected = true;
|
|
1957
|
-
status.lastConnectedAt = Date.now();
|
|
1958
|
-
status.lastEventAt = status.lastConnectedAt;
|
|
1959
|
-
status.lastError = null;
|
|
1960
|
-
emitStatus();
|
|
1961
|
-
const { e164: selfE164 } = readWebSelfId(account.authDir);
|
|
1962
|
-
const connectRoute = resolveAgentRoute({
|
|
1963
|
-
cfg,
|
|
1964
|
-
channel: "whatsapp",
|
|
1965
|
-
accountId: account.accountId
|
|
1966
|
-
});
|
|
1967
|
-
enqueueSystemEvent(`WhatsApp gateway connected${selfE164 ? ` as ${selfE164}` : ""}.`, { sessionKey: connectRoute.sessionKey });
|
|
1968
|
-
setActiveWebListener(account.accountId, listener);
|
|
1969
|
-
unregisterUnhandled = registerUnhandledRejectionHandler((reason) => {
|
|
1970
|
-
if (!isLikelyWhatsAppCryptoError(reason)) return false;
|
|
1971
|
-
const errorStr = formatError(reason);
|
|
1972
|
-
reconnectLogger.warn({
|
|
1973
|
-
connectionId,
|
|
1974
|
-
error: errorStr
|
|
1975
|
-
}, "web reconnect: unhandled rejection from WhatsApp socket; forcing reconnect");
|
|
1976
|
-
listener.signalClose?.({
|
|
1977
|
-
status: 499,
|
|
1978
|
-
isLoggedOut: false,
|
|
1979
|
-
error: reason
|
|
1980
|
-
});
|
|
1981
|
-
return true;
|
|
1982
|
-
});
|
|
1983
|
-
const closeListener = async () => {
|
|
1984
|
-
setActiveWebListener(account.accountId, null);
|
|
1985
|
-
if (unregisterUnhandled) {
|
|
1986
|
-
unregisterUnhandled();
|
|
1987
|
-
unregisterUnhandled = null;
|
|
1988
|
-
}
|
|
1989
|
-
if (heartbeat) clearInterval(heartbeat);
|
|
1990
|
-
if (watchdogTimer) clearInterval(watchdogTimer);
|
|
1991
|
-
if (backgroundTasks.size > 0) {
|
|
1992
|
-
await Promise.allSettled(backgroundTasks);
|
|
1993
|
-
backgroundTasks.clear();
|
|
1994
|
-
}
|
|
1995
|
-
try {
|
|
1996
|
-
await listener.close();
|
|
1997
|
-
} catch (err) {
|
|
1998
|
-
logVerbose(`Socket close failed: ${formatError(err)}`);
|
|
1999
|
-
}
|
|
2000
|
-
};
|
|
2001
|
-
if (keepAlive) {
|
|
2002
|
-
heartbeat = setInterval(() => {
|
|
2003
|
-
const authAgeMs = getWebAuthAgeMs(account.authDir);
|
|
2004
|
-
const minutesSinceLastMessage = lastMessageAt ? Math.floor((Date.now() - lastMessageAt) / 6e4) : null;
|
|
2005
|
-
const logData = {
|
|
2006
|
-
connectionId,
|
|
2007
|
-
reconnectAttempts,
|
|
2008
|
-
messagesHandled: handledMessages,
|
|
2009
|
-
lastMessageAt,
|
|
2010
|
-
authAgeMs,
|
|
2011
|
-
uptimeMs: Date.now() - startedAt,
|
|
2012
|
-
...minutesSinceLastMessage !== null && minutesSinceLastMessage > 30 ? { minutesSinceLastMessage } : {}
|
|
2013
|
-
};
|
|
2014
|
-
if (minutesSinceLastMessage && minutesSinceLastMessage > 30) heartbeatLogger.warn(logData, "⚠️ web gateway heartbeat - no messages in 30+ minutes");
|
|
2015
|
-
else heartbeatLogger.info(logData, "web gateway heartbeat");
|
|
2016
|
-
}, heartbeatSeconds * 1e3);
|
|
2017
|
-
watchdogTimer = setInterval(() => {
|
|
2018
|
-
if (!lastMessageAt) return;
|
|
2019
|
-
const timeSinceLastMessage = Date.now() - lastMessageAt;
|
|
2020
|
-
if (timeSinceLastMessage <= MESSAGE_TIMEOUT_MS) return;
|
|
2021
|
-
const minutesSinceLastMessage = Math.floor(timeSinceLastMessage / 6e4);
|
|
2022
|
-
heartbeatLogger.warn({
|
|
2023
|
-
connectionId,
|
|
2024
|
-
minutesSinceLastMessage,
|
|
2025
|
-
lastMessageAt: new Date(lastMessageAt),
|
|
2026
|
-
messagesHandled: handledMessages
|
|
2027
|
-
}, "Message timeout detected - forcing reconnect");
|
|
2028
|
-
whatsappHeartbeatLog.warn(`No messages received in ${minutesSinceLastMessage}m - restarting connection`);
|
|
2029
|
-
closeListener().catch((err) => {
|
|
2030
|
-
logVerbose(`Close listener failed: ${formatError(err)}`);
|
|
2031
|
-
});
|
|
2032
|
-
listener.signalClose?.({
|
|
2033
|
-
status: 499,
|
|
2034
|
-
isLoggedOut: false,
|
|
2035
|
-
error: "watchdog-timeout"
|
|
2036
|
-
});
|
|
2037
|
-
}, WATCHDOG_CHECK_MS);
|
|
2038
|
-
}
|
|
2039
|
-
whatsappLog.info("Listening for personal WhatsApp inbound messages.");
|
|
2040
|
-
if (process.stdout.isTTY || process.stderr.isTTY) whatsappLog.raw("Ctrl+C to stop.");
|
|
2041
|
-
if (!keepAlive) {
|
|
2042
|
-
await closeListener();
|
|
2043
|
-
process.removeListener("SIGINT", handleSigint);
|
|
2044
|
-
return;
|
|
2045
|
-
}
|
|
2046
|
-
const reason = await Promise.race([listener.onClose?.catch((err) => {
|
|
2047
|
-
reconnectLogger.error({ error: formatError(err) }, "listener.onClose rejected");
|
|
2048
|
-
return {
|
|
2049
|
-
status: 500,
|
|
2050
|
-
isLoggedOut: false,
|
|
2051
|
-
error: err
|
|
2052
|
-
};
|
|
2053
|
-
}) ?? waitForever(), abortPromise ?? waitForever()]);
|
|
2054
|
-
if (Date.now() - startedAt > heartbeatSeconds * 1e3) reconnectAttempts = 0;
|
|
2055
|
-
status.reconnectAttempts = reconnectAttempts;
|
|
2056
|
-
emitStatus();
|
|
2057
|
-
if (stopRequested() || sigintStop || reason === "aborted") {
|
|
2058
|
-
await closeListener();
|
|
2059
|
-
break;
|
|
2060
|
-
}
|
|
2061
|
-
const statusCode = (typeof reason === "object" && reason && "status" in reason ? reason.status : void 0) ?? "unknown";
|
|
2062
|
-
const loggedOut = typeof reason === "object" && reason && "isLoggedOut" in reason && reason.isLoggedOut;
|
|
2063
|
-
const errorStr = formatError(reason);
|
|
2064
|
-
status.connected = false;
|
|
2065
|
-
status.lastEventAt = Date.now();
|
|
2066
|
-
status.lastDisconnect = {
|
|
2067
|
-
at: status.lastEventAt,
|
|
2068
|
-
status: typeof statusCode === "number" ? statusCode : void 0,
|
|
2069
|
-
error: errorStr,
|
|
2070
|
-
loggedOut: Boolean(loggedOut)
|
|
2071
|
-
};
|
|
2072
|
-
status.lastError = errorStr;
|
|
2073
|
-
status.reconnectAttempts = reconnectAttempts;
|
|
2074
|
-
emitStatus();
|
|
2075
|
-
reconnectLogger.info({
|
|
2076
|
-
connectionId,
|
|
2077
|
-
status: statusCode,
|
|
2078
|
-
loggedOut,
|
|
2079
|
-
reconnectAttempts,
|
|
2080
|
-
error: errorStr
|
|
2081
|
-
}, "web reconnect: connection closed");
|
|
2082
|
-
enqueueSystemEvent(`WhatsApp gateway disconnected (status ${statusCode ?? "unknown"})`, { sessionKey: connectRoute.sessionKey });
|
|
2083
|
-
if (loggedOut) {
|
|
2084
|
-
runtime.error(`WhatsApp session logged out. Run \`${formatCliCommand("remoteclaw channels login --channel web")}\` to relink.`);
|
|
2085
|
-
await closeListener();
|
|
2086
|
-
break;
|
|
2087
|
-
}
|
|
2088
|
-
if (isNonRetryableWebCloseStatus(statusCode)) {
|
|
2089
|
-
reconnectLogger.warn({
|
|
2090
|
-
connectionId,
|
|
2091
|
-
status: statusCode,
|
|
2092
|
-
error: errorStr
|
|
2093
|
-
}, "web reconnect: non-retryable close status; stopping monitor");
|
|
2094
|
-
runtime.error(`WhatsApp Web connection closed (status ${statusCode}: session conflict). Resolve conflicting WhatsApp Web sessions, then relink with \`${formatCliCommand("remoteclaw channels login --channel web")}\`. Stopping web monitoring.`);
|
|
2095
|
-
await closeListener();
|
|
2096
|
-
break;
|
|
2097
|
-
}
|
|
2098
|
-
reconnectAttempts += 1;
|
|
2099
|
-
status.reconnectAttempts = reconnectAttempts;
|
|
2100
|
-
emitStatus();
|
|
2101
|
-
if (reconnectPolicy.maxAttempts > 0 && reconnectAttempts >= reconnectPolicy.maxAttempts) {
|
|
2102
|
-
reconnectLogger.warn({
|
|
2103
|
-
connectionId,
|
|
2104
|
-
status: statusCode,
|
|
2105
|
-
reconnectAttempts,
|
|
2106
|
-
maxAttempts: reconnectPolicy.maxAttempts
|
|
2107
|
-
}, "web reconnect: max attempts reached; continuing in degraded mode");
|
|
2108
|
-
runtime.error(`WhatsApp Web reconnect: max attempts reached (${reconnectAttempts}/${reconnectPolicy.maxAttempts}). Stopping web monitoring.`);
|
|
2109
|
-
await closeListener();
|
|
2110
|
-
break;
|
|
2111
|
-
}
|
|
2112
|
-
const delay = computeBackoff(reconnectPolicy, reconnectAttempts);
|
|
2113
|
-
reconnectLogger.info({
|
|
2114
|
-
connectionId,
|
|
2115
|
-
status: statusCode,
|
|
2116
|
-
reconnectAttempts,
|
|
2117
|
-
maxAttempts: reconnectPolicy.maxAttempts || "unlimited",
|
|
2118
|
-
delayMs: delay
|
|
2119
|
-
}, "web reconnect: scheduling retry");
|
|
2120
|
-
runtime.error(`WhatsApp Web connection closed (status ${statusCode}). Retry ${reconnectAttempts}/${reconnectPolicy.maxAttempts || "∞"} in ${formatDurationPrecise(delay)}… (${errorStr})`);
|
|
2121
|
-
await closeListener();
|
|
2122
|
-
try {
|
|
2123
|
-
await sleep(delay, abortSignal);
|
|
2124
|
-
} catch {
|
|
2125
|
-
break;
|
|
2126
|
-
}
|
|
2127
|
-
}
|
|
2128
|
-
status.running = false;
|
|
2129
|
-
status.connected = false;
|
|
2130
|
-
status.lastEventAt = Date.now();
|
|
2131
|
-
emitStatus();
|
|
2132
|
-
process.removeListener("SIGINT", handleSigint);
|
|
2133
|
-
}
|
|
2134
|
-
|
|
2135
|
-
//#endregion
|
|
2136
|
-
export { monitorWebInbox as n, waitForever as r, monitorWebChannel as t };
|