@qqbrowser/openclaw-qbot 0.0.88 → 0.0.89
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/dist/{agents-Dxk5oWw_.js → agents-BBYlUP5T.js} +1 -1
- package/dist/{agents.config-CXoN8qvY.js → agents.config-CoZtnyKH.js} +1 -1
- package/dist/{agents.config-D6kg-4Ct.js → agents.config-Dyqz-Sk-.js} +1 -1
- package/dist/{auth-choice-COKpi33u.js → auth-choice-CVvPBerD.js} +1 -1
- package/dist/{auth-choice-K5eGX1sj.js → auth-choice-DSNX3Hdu.js} +1 -1
- package/dist/{banner-DsZegXc3.js → banner-C4Bgn_Gf.js} +1 -1
- package/dist/build-info.json +3 -3
- package/dist/bundled/boot-md/handler.js +1 -1
- package/dist/bundled/session-memory/handler.js +1 -1
- package/dist/canvas-host/a2ui/.bundle.hash +1 -1
- package/dist/{channel-options-BU9Qf5Cq.js → channel-options-9lP0IBR0.js} +1 -1
- package/dist/{channel-options-C-h17ZYO.js → channel-options-C9PHeVlU.js} +1 -1
- package/dist/{channel-web-DmmMXUdc.js → channel-web-DhNCVKla.js} +1 -1
- package/dist/{channel-web-C2Z4xKq3.js → channel-web-NeSGV-e7.js} +1 -1
- package/dist/{channels-cli-WBY_CB2-.js → channels-cli-CWu-PrIl.js} +1 -1
- package/dist/{channels-cli-DM6DIc_P.js → channels-cli-DHD8V6-q.js} +1 -1
- package/dist/{cli-DXZKyKLK.js → cli-BWE7sLVx.js} +1 -1
- package/dist/{cli-RLbxgNsy.js → cli-DF5ZcuuX.js} +1 -1
- package/dist/{command-registry-CIBlcDrG.js → command-registry-DIOnYWDt.js} +1 -1
- package/dist/{compact-BfHim3cA.js → compact-DgbuvsDF.js} +6 -6
- package/dist/{compact.runtime-C_urV0W5.js → compact.runtime-B5zaMKSa.js} +1 -1
- package/dist/{compact.runtime-eUr8DtWw.js → compact.runtime-B6qfwW6l.js} +1 -1
- package/dist/{compact.runtime-DtLl0dZ5.js → compact.runtime-BofMQvNu.js} +1 -1
- package/dist/{compact.runtime-BpYpUiXf.js → compact.runtime-C-OsuZNM.js} +1 -1
- package/dist/{completion-cli-BYf6ef-t.js → completion-cli-CckNzelT.js} +1 -1
- package/dist/{completion-cli-Dsi5-gGE.js → completion-cli-F60ntV7X.js} +1 -1
- package/dist/{config-cli-GwzrxUR-.js → config-cli-1Ut82gjz.js} +1 -1
- package/dist/{config-cli-IpFnLniP.js → config-cli-BVtPmTcO.js} +1 -1
- package/dist/{configure-Cx7WvgVM.js → configure-3Kgwf3gj.js} +1 -1
- package/dist/{configure-DIVEkxxF.js → configure-Bpy51qkb.js} +1 -1
- package/dist/{deps-send-whatsapp.runtime-CdAcLrxO.js → deps-send-whatsapp.runtime-CI4UsY0E.js} +1 -1
- package/dist/{deps-send-whatsapp.runtime-Dj_dh7mb.js → deps-send-whatsapp.runtime-CJbg_i22.js} +1 -1
- package/dist/{deps-send-whatsapp.runtime-DJOAewju.js → deps-send-whatsapp.runtime-CPhSRgv3.js} +1 -1
- package/dist/{deps-send-whatsapp.runtime-BfuHSQxE.js → deps-send-whatsapp.runtime-DLRNnLUS.js} +1 -1
- package/dist/{doctor-completion-BcvWFszV.js → doctor-completion-CucfTzWR.js} +1 -1
- package/dist/{doctor-completion-CQMvGm9I.js → doctor-completion-D76qqYqG.js} +1 -1
- package/dist/entry.js +1 -1
- package/dist/extensionAPI.js +1 -1
- package/dist/{gateway-cli-CBK9IHgW.js → gateway-cli-BKWQlBHk.js} +2 -2
- package/dist/{gateway-cli-BUcUT6It.js → gateway-cli-DtqcCdL7.js} +2 -2
- package/dist/{health-CiTej6rM.js → health-BXDoFh4Q.js} +1 -1
- package/dist/{health-Pqtl8jCk.js → health-xCl2atiY.js} +1 -1
- package/dist/{hooks-cli-C6nsAzQh.js → hooks-cli-B2j44Nvk.js} +1 -1
- package/dist/{hooks-cli-BR-m9Vxi.js → hooks-cli-DT0Hmbz-.js} +1 -1
- package/dist/index.js +2 -2
- package/dist/llm-slug-generator.js +1 -1
- package/dist/{models-CxaUXLzo.js → models-DhX1F_Pj.js} +1 -1
- package/dist/{models-cli-DuamSrQA.js → models-cli-B-kAey2t.js} +1 -1
- package/dist/{models-cli-DM55mW-t.js → models-cli-B53yy1mw.js} +1 -1
- package/dist/{npm-resolution-CKwFeFIB.js → npm-resolution-BIifLd1f.js} +1 -1
- package/dist/{npm-resolution-9bO0TPQF.js → npm-resolution-C2Ow0mqR.js} +1 -1
- package/dist/{onboard-BU0gG29k.js → onboard-D9IefEER.js} +2 -2
- package/dist/{onboard-channels-CsKyM82H.js → onboard-channels-B8JZHEaQ.js} +1 -1
- package/dist/{onboard-channels-BK5KINY9.js → onboard-channels-ByD6UdVu.js} +1 -1
- package/dist/{onboard-BlGJhhEF.js → onboard-qMIhLeRM.js} +2 -2
- package/dist/{onboarding-CM_9Fyo2.js → onboarding-CddGtlY5.js} +1 -1
- package/dist/{onboarding-Kz5K9mKB.js → onboarding-CgqsAteJ.js} +1 -1
- package/dist/{onboarding.finalize-DstFPCVD.js → onboarding.finalize-BgCWB7kF.js} +1 -1
- package/dist/{onboarding.finalize-C96gv5GP.js → onboarding.finalize-CkHWKgcF.js} +1 -1
- package/dist/{pi-embedded-BHryO0s2.js → pi-embedded-C6L57IhI.js} +6 -6
- package/dist/{pi-embedded-D_03X4gB.js → pi-embedded-CN25rQwp.js} +6 -6
- package/dist/{plugin-registry-DyreKTxc.js → plugin-registry-Cido8VxT.js} +1 -1
- package/dist/{plugin-registry-Dsb86j5r.js → plugin-registry-CpPyaWT0.js} +1 -1
- package/dist/plugin-sdk/{channel-web-BDO73YAY.js → channel-web-DgBEXyWx.js} +1 -1
- package/dist/plugin-sdk/{channel-web-C0hljM9U.js → channel-web-T7e1VB_g.js} +1 -1
- package/dist/plugin-sdk/{compact.runtime-B-jUdCSu.js → compact.runtime-B0qhTLAN.js} +1 -1
- package/dist/plugin-sdk/{compact.runtime-iEjcWTOi.js → compact.runtime-C5aI5KIg.js} +1 -1
- package/dist/plugin-sdk/{compact.runtime-BspLSIc1.js → compact.runtime-Da9JL-Re.js} +1 -1
- package/dist/plugin-sdk/{compact.runtime-CMWw2lwa.js → compact.runtime-DuWXCPO4.js} +1 -1
- package/dist/plugin-sdk/{compact.runtime-HnqzVAl7.js → compact.runtime-F35snTaz.js} +1 -1
- package/dist/plugin-sdk/{compact.runtime-C2keFFLA.js → compact.runtime-kL8PhhSi.js} +1 -1
- package/dist/plugin-sdk/compat.js +1 -1
- package/dist/plugin-sdk/{deps-send-whatsapp.runtime-BRm24Qy-.js → deps-send-whatsapp.runtime-BWVV9ImJ.js} +1 -1
- package/dist/plugin-sdk/{deps-send-whatsapp.runtime-Bw9eegUO.js → deps-send-whatsapp.runtime-BdOLZ0P3.js} +1 -1
- package/dist/plugin-sdk/{deps-send-whatsapp.runtime-DdS9G3TR.js → deps-send-whatsapp.runtime-DMD-mrgL.js} +1 -1
- package/dist/plugin-sdk/{deps-send-whatsapp.runtime-ClvlojBM.js → deps-send-whatsapp.runtime-DNaHPuYl.js} +1 -1
- package/dist/plugin-sdk/{deps-send-whatsapp.runtime-DjAB5JP0.js → deps-send-whatsapp.runtime-DkmDJ3eX.js} +1 -1
- package/dist/plugin-sdk/{deps-send-whatsapp.runtime-yd5qmNGP.js → deps-send-whatsapp.runtime-nRQWODTL.js} +1 -1
- package/dist/plugin-sdk/{dispatch-BtGxkC47.js → dispatch--4Vuy9oL.js} +6 -6
- package/dist/plugin-sdk/{dispatch-BO5EIrCx.js → dispatch-DPafUBvi.js} +6 -6
- package/dist/plugin-sdk/{dispatch-DABpoSJj.js → dispatch-DzdnDix3.js} +6 -6
- package/dist/plugin-sdk/{dispatch-DfBUhUa2.js → dispatch-_3aPMKVc.js} +6 -6
- package/dist/plugin-sdk/{dispatch-BFVL83hy.js → dispatch-v8f5j6tA.js} +6 -6
- package/dist/plugin-sdk/index.js +1 -1
- package/dist/plugin-sdk/irc.js +1 -1
- package/dist/plugin-sdk/matrix.js +1 -1
- package/dist/plugin-sdk/msteams.js +1 -1
- package/dist/plugin-sdk/nextcloud-talk.js +1 -1
- package/dist/plugin-sdk/{reply-0QJVop5g.js → reply-FZOMaPdT.js} +6 -6
- package/dist/plugin-sdk/{slash-dispatch.runtime-I6_T20Yd.js → slash-dispatch.runtime-CV3coyWo.js} +1 -1
- package/dist/plugin-sdk/{slash-dispatch.runtime-BwEZoF7O.js → slash-dispatch.runtime-CYrhiT19.js} +1 -1
- package/dist/plugin-sdk/{slash-dispatch.runtime-W9VRo3lf.js → slash-dispatch.runtime-CkVpd9xh.js} +1 -1
- package/dist/plugin-sdk/{slash-dispatch.runtime-CaemgmaW.js → slash-dispatch.runtime-CzBVRyba.js} +1 -1
- package/dist/plugin-sdk/{slash-dispatch.runtime-B4nePbcc.js → slash-dispatch.runtime-DjGJDpWI.js} +1 -1
- package/dist/plugin-sdk/{slash-dispatch.runtime-ByQEhvcx.js → slash-dispatch.runtime-WIHCc0nP.js} +1 -1
- package/dist/plugin-sdk/{subagent-registry-runtime-pjzgZyiw.js → subagent-registry-runtime-4o_8yfyB.js} +1 -1
- package/dist/plugin-sdk/{subagent-registry-runtime-ikSo08Bh.js → subagent-registry-runtime-BJxZkq6N.js} +1 -1
- package/dist/plugin-sdk/{subagent-registry-runtime-BPHOIYnR.js → subagent-registry-runtime-BRl0zIp-.js} +1 -1
- package/dist/plugin-sdk/{subagent-registry-runtime-C2TUyWmj.js → subagent-registry-runtime-C-2UF0IM.js} +1 -1
- package/dist/plugin-sdk/{subagent-registry-runtime-Co3rxlYB.js → subagent-registry-runtime-bCP-yDZd.js} +1 -1
- package/dist/plugin-sdk/{subagent-registry-runtime-Wu14xqj_.js → subagent-registry-runtime-lM2A6bas.js} +1 -1
- package/dist/plugin-sdk/{web-Bgl0ILbD.js → web--MzzmLKe.js} +1 -1
- package/dist/plugin-sdk/{web-BzRQSS8R.js → web-BoQezxCE.js} +1 -1
- package/dist/plugin-sdk/{web-CK9n5ZfK.js → web-CgFT-LB5.js} +1 -1
- package/dist/plugin-sdk/{web-3TYyfPQG.js → web-CskfGkR8.js} +1 -1
- package/dist/plugin-sdk/{web-WIpdyZZQ.js → web-KZ3WEX08.js} +1 -1
- package/dist/plugin-sdk/{web-BCOXLnUB.js → web-sUKMDnvE.js} +1 -1
- package/dist/plugin-sdk/whatsapp.js +1 -1
- package/dist/{plugins-cli-B_m-0xTz.js → plugins-cli-7Rom2MRn.js} +1 -1
- package/dist/{plugins-cli-fpI_fBTE.js → plugins-cli-ULYhpcRr.js} +1 -1
- package/dist/{program-B52FJo5X.js → program-C8M8kVC0.js} +2 -2
- package/dist/{program-context-9FmjmgRi.js → program-context-DNheupaq.js} +1 -1
- package/dist/{prompt-select-styled-7bpPt2PG.js → prompt-select-styled-BfSAWDfm.js} +1 -1
- package/dist/{prompt-select-styled-bL9scez3.js → prompt-select-styled-Qtie1Z5m.js} +1 -1
- package/dist/{provider-auth-helpers-CatlYQ1x.js → provider-auth-helpers-PSez6fyE.js} +1 -1
- package/dist/{provider-auth-helpers-DgQEZQZm.js → provider-auth-helpers-fIKVMJmj.js} +1 -1
- package/dist/{push-apns-Bc0uTUFe.js → push-apns-CZ3x5b7S.js} +1 -1
- package/dist/{push-apns-Dq1z7GKZ.js → push-apns-D4QwEU4o.js} +1 -1
- package/dist/{register.agent-Cjvn_JC_.js → register.agent-CQCSZoM3.js} +1 -1
- package/dist/{register.agent-DZ68nNV_.js → register.agent-CkdmFMol.js} +1 -1
- package/dist/{register.configure-DAq-OZQ_.js → register.configure-CY7jH_t-.js} +1 -1
- package/dist/{register.configure-DNeVIlZk.js → register.configure-jvsFtsEY.js} +1 -1
- package/dist/{register.maintenance-Cx5TbFUH.js → register.maintenance-Cn2-JBxc.js} +1 -1
- package/dist/{register.maintenance-BGD-EdYb.js → register.maintenance-DbdyMqnN.js} +1 -1
- package/dist/{register.message-BVBF2xBA.js → register.message-8Pxm1wyr.js} +1 -1
- package/dist/{register.message-BahjRagK.js → register.message-DxNX0-7A.js} +1 -1
- package/dist/{register.onboard-BYsU9URi.js → register.onboard-BeuVHdxu.js} +1 -1
- package/dist/{register.onboard-CsUvw9JY.js → register.onboard-D9LNxSOp.js} +1 -1
- package/dist/{register.setup-DUGQ3LjU.js → register.setup-AyriKZAD.js} +1 -1
- package/dist/{register.setup-Czz8kiz8.js → register.setup-D6sjApkR.js} +1 -1
- package/dist/{register.status-health-sessions-DwQDXdjY.js → register.status-health-sessions-C3YEi9ej.js} +1 -1
- package/dist/{register.status-health-sessions-C-6pt1vC.js → register.status-health-sessions-DLibm4n2.js} +1 -1
- package/dist/{register.subclis-nr-J0DsM.js → register.subclis-DMwBX73g.js} +1 -1
- package/dist/{reply-Bv0w_dst.js → reply-JaJmymld.js} +6 -6
- package/dist/{run-main-C9SR6tqO.js → run-main-BtJ9Rvkf.js} +1 -1
- package/dist/{server-node-events-DBU3p4Am.js → server-node-events-B1xc0xHC.js} +1 -1
- package/dist/{server-node-events-duTsLOu5.js → server-node-events-DkYb_tMY.js} +1 -1
- package/dist/{slash-dispatch.runtime-BKW0b-z4.js → slash-dispatch.runtime-5FhvH4vs.js} +1 -1
- package/dist/{slash-dispatch.runtime-Dllhj5El.js → slash-dispatch.runtime-8bdhjt7e.js} +1 -1
- package/dist/{slash-dispatch.runtime-BykVo525.js → slash-dispatch.runtime-BSGNAoT3.js} +1 -1
- package/dist/{slash-dispatch.runtime-CwKA-3Mz.js → slash-dispatch.runtime-DzFzghS8.js} +1 -1
- package/dist/{status-BUdDRE9f.js → status-Ln-hRgxh.js} +1 -1
- package/dist/{status-QCEyD_DK.js → status-XJoKJIPd.js} +1 -1
- package/dist/{subagent-registry-runtime-ANqbVbfo.js → subagent-registry-runtime-CMgr0_UE.js} +1 -1
- package/dist/{subagent-registry-runtime-CWrWUjll.js → subagent-registry-runtime-DA3RtD85.js} +1 -1
- package/dist/{subagent-registry-runtime-CA_UwsAM.js → subagent-registry-runtime-DDF1mHS2.js} +1 -1
- package/dist/{subagent-registry-runtime-DjLSmsYn.js → subagent-registry-runtime-DTliYOy2.js} +1 -1
- package/dist/{update-cli-2Prf30Co.js → update-cli-DhZZ9nIA.js} +1 -1
- package/dist/{update-cli-BZ7xaJXP.js → update-cli-T5qjfgGh.js} +1 -1
- package/dist/{update-runner-Dmea_7oZ.js → update-runner-C6Z9RGJ6.js} +1 -1
- package/dist/{update-runner-CzyTP7xB.js → update-runner-DThdoQ9_.js} +1 -1
- package/dist/{web-BYWPQTzp.js → web-BinddLZf.js} +1 -1
- package/dist/{web-B90WZv9Y.js → web-CWJIsRZO.js} +1 -1
- package/dist/{web-DTS3rwm1.js → web-D995jmBq.js} +1 -1
- package/dist/{web-BvZz642s.js → web-F5nE_LwQ.js} +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./rolldown-runtime-CNxR59P3.js";import{t}from"./subsystem-B35lZH6M.js";import{Gs as n}from"./model-selection-D_WMcs-m.js";import{S as r}from"./reply-
|
|
1
|
+
import{t as e}from"./rolldown-runtime-CNxR59P3.js";import{t}from"./subsystem-B35lZH6M.js";import{Gs as n}from"./model-selection-D_WMcs-m.js";import{S as r}from"./reply-JaJmymld.js";import{d as i,f as a}from"./agent-scope-DauKPN2a.js";import{u as o}from"./registry-DwigmP92.js";var s=e({ensurePluginRegistryLoaded:()=>u});const c=t(`plugins`);let l=!1;function u(){if(l)return;let e=o();if(e&&(e.plugins.length>0||e.channels.length>0||e.tools.length>0)){l=!0;return}let t=n();r({config:t,workspaceDir:i(t,a(t)),logger:{info:e=>c.info(e),warn:e=>c.warn(e),error:e=>c.error(e),debug:e=>c.debug(e)}}),l=!0}export{s as n,u as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./rolldown-runtime-CNxR59P3.js";import{t}from"./subsystem-C7tbdlOl.js";import{ko as n}from"./auth-profiles-BkhVHtgY.js";import{d as r,f as i}from"./agent-scope-DjUQMckI.js";import{u as a}from"./registry-Bfa_Ykoc.js";import{l as o}from"./compact-
|
|
1
|
+
import{t as e}from"./rolldown-runtime-CNxR59P3.js";import{t}from"./subsystem-C7tbdlOl.js";import{ko as n}from"./auth-profiles-BkhVHtgY.js";import{d as r,f as i}from"./agent-scope-DjUQMckI.js";import{u as a}from"./registry-Bfa_Ykoc.js";import{l as o}from"./compact-DgbuvsDF.js";var s=e({ensurePluginRegistryLoaded:()=>u});const c=t(`plugins`);let l=!1;function u(){if(l)return;let e=a();if(e&&(e.plugins.length>0||e.channels.length>0||e.tools.length>0)){l=!0;return}let t=n();o({config:t,workspaceDir:r(t,i(t)),logger:{info:e=>c.info(e),warn:e=>c.warn(e),error:e=>c.error(e),debug:e=>c.debug(e)}}),l=!0}export{s as n,u as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Dt as e,Et as t,Mt as n,Rt as r,kt as i,s as a}from"./paths-CB5IsdXc.js";import{Ci as o,Fs as s,Go as c,Ns as l,Qs as u,To as d,Vs as f,Wo as p,Y as m,_c as h,c as g,f as _,js as v,u as y}from"./sessions-vCe4wPa1.js";import{B as b,C as x,K as S,M as C,O as w,R as T,T as E,h as D,m as O,o as k,p as A,v as j}from"./logger-CMRRf9cz.js";import{Ft as ee,It as M,Lt as N}from"./send-B6HPDK7K.js";import{A as P,B as te,C as ne,D as re,F as ie,G as ae,H as F,I as oe,J as I,K as se,L,M as ce,N as R,O as le,R as z,S as ue,T as B,U as V,V as de,W as H,_ as U,b as W,g as G,h as K,j as fe,k as pe,m as me,p as he,q as ge,t as _e,v as ve,w as ye,x as be,y as xe,z as Se}from"./reply-
|
|
1
|
+
import{Dt as e,Et as t,Mt as n,Rt as r,kt as i,s as a}from"./paths-CB5IsdXc.js";import{Ci as o,Fs as s,Go as c,Ns as l,Qs as u,To as d,Vs as f,Wo as p,Y as m,_c as h,c as g,f as _,js as v,u as y}from"./sessions-vCe4wPa1.js";import{B as b,C as x,K as S,M as C,O as w,R as T,T as E,h as D,m as O,o as k,p as A,v as j}from"./logger-CMRRf9cz.js";import{Ft as ee,It as M,Lt as N}from"./send-B6HPDK7K.js";import{A as P,B as te,C as ne,D as re,F as ie,G as ae,H as F,I as oe,J as I,K as se,L,M as ce,N as R,O as le,R as z,S as ue,T as B,U as V,V as de,W as H,_ as U,b as W,g as G,h as K,j as fe,k as pe,m as me,p as he,q as ge,t as _e,v as ve,w as ye,x as be,y as xe,z as Se}from"./reply-FZOMaPdT.js";import{$ as Ce,et as we,it as Te,ot as Ee}from"./send-bO2luPtA.js";import{f as De}from"./audio-transcription-runner-CZeLqyn8.js";import{t as Oe}from"./local-roots-mIwSmMlz.js";import{a as ke,d as Ae,h as je,m as Me,s as Ne}from"./ir-CmAyPA_x.js";import{n as Pe}from"./channel-activity-CYknJxeB.js";import{t as Fe}from"./tables-BaKxrCzf.js";import{r as Ie}from"./active-listener-n86WJt8R.js";import{i as Le,r as Re}from"./outbound-BkJMbfAc.js";import{i as ze,n as q,r as Be,t as Ve}from"./session-D_RY5hZ0.js";import{randomUUID as He}from"node:crypto";import{DisconnectReason as Ue,downloadMediaMessage as We,extractMessageContent as Ge,getContentType as Ke,isJidGroup as qe,normalizeMessageContent as Je}from"@whiskeysockets/baileys";function Ye(e){if((e.session?.scope??`per-sender`)===`global`)return[];let t=g(a(e.session?.store)),n=e=>e.includes(`:group:`)||e.includes(`:channel:`)||e.includes(`@g.us`),r=e=>e.startsWith(`cron:`),i=Object.entries(t).filter(([e])=>e!==`global`&&e!==`unknown`).filter(([e])=>!n(e)&&!r(e)).map(([e,t])=>({to:u(t?.lastChannel)===`whatsapp`&&t?.lastTo?D(t.lastTo):``,updatedAt:t?.updatedAt??0})).filter(({to:e})=>e.length>1).toSorted((e,t)=>t.updatedAt-e.updatedAt),o=new Set;return i.filter(e=>o.has(e.to)?!1:(o.add(e.to),!0))}function Xe(e,t={}){if(t.to)return{recipients:[D(t.to)],source:`flag`};let n=Ye(e),i=Array.isArray(e.channels?.whatsapp?.allowFrom)&&e.channels.whatsapp.allowFrom.length>0?e.channels.whatsapp.allowFrom.filter(e=>e!==`*`).map(D):[],a=Te(`whatsapp`,process.env,r).map(D),o=e=>[...new Set(e.filter(Boolean))],s=o([...i,...a]);if(t.all)return{recipients:o([...n.map(e=>e.to),...s]),source:`all`};if(s.length>0){let e=new Set(s),t=n.map(e=>e.to).filter(t=>e.has(t));return t.length===1?{recipients:[t[0]],source:`session-single`}:t.length>1?{recipients:t,source:`session-ambiguous`}:{recipients:s,source:`allowFrom`}}return n.length===1?{recipients:[n[0].to],source:`session-single`}:n.length>1?{recipients:n.map(e=>e.to),source:`session-ambiguous`}:{recipients:s,source:`allowFrom`}}const Ze={initialMs:2e3,maxMs:3e4,factor:1.8,jitter:.25,maxAttempts:12};function Qe(e,t){let n=t??e.web?.heartbeatSeconds;return typeof n==`number`&&n>0?n:60}function $e(e,t){let n=e.web?.reconnect??{},r=t??{},i={...Ze,...n,...r};return i.initialMs=Math.max(250,i.initialMs),i.maxMs=Math.max(i.initialMs,i.maxMs),i.factor=k(i.factor,1.1,10),i.jitter=k(i.jitter,0,1),i.maxAttempts=Math.max(0,Math.floor(i.maxAttempts)),i}function J(){return He()}const Y=w(`gateway/channels/whatsapp`),X=Y.child(`inbound`),Z=Y.child(`outbound`),et=Y.child(`heartbeat`);function tt(){return setInterval(()=>{},1e6).unref(),new Promise(()=>{})}const nt=L({ttlMs:20*6e4,maxSize:5e3});function rt(e){return nt.check(e)}const it=new Set([`FN`,`N`,`TEL`]);function at(e){if(!e)return{phones:[]};let t=e.split(/\r?\n/),n,r,i=[];for(let e of t){let t=e.trim();if(!t)continue;let a=t.indexOf(`:`);if(a===-1)continue;let o=t.slice(0,a).toUpperCase(),s=t.slice(a+1).trim();if(!s)continue;let c=ot(o);if(!c||!it.has(c))continue;let l=st(s);if(l){if(c===`FN`&&!r){r=ct(l);continue}if(c===`N`&&!n){n=ct(l);continue}if(c===`TEL`){let e=lt(l);e&&i.push(e)}}}return{name:r??n,phones:i}}function ot(e){let[t]=e.split(`;`);if(!t)return;let n=t.split(`.`);return n[n.length-1]||void 0}function st(e){return e.replace(/\\n/gi,` `).replace(/\\,/g,`,`).replace(/\\;/g,`;`).trim()}function ct(e){return e.replace(/;/g,` `).replace(/\s+/g,` `).trim()}function lt(e){let t=e.trim();return t?t.toLowerCase().startsWith(`tel:`)?t.slice(4).trim():t:``}function Q(e){return Je(e)}function ut(e){if(!e)return;let t=Ke(e),n=t?e[t]:void 0,r=n&&typeof n==`object`&&`contextInfo`in n?n.contextInfo:void 0;if(r)return r;let i=e.extendedTextMessage?.contextInfo??e.imageMessage?.contextInfo??e.videoMessage?.contextInfo??e.documentMessage?.contextInfo??e.audioMessage?.contextInfo??e.stickerMessage?.contextInfo??e.buttonsResponseMessage?.contextInfo??e.listResponseMessage?.contextInfo??e.templateButtonReplyMessage?.contextInfo??e.interactiveResponseMessage?.contextInfo??e.buttonsMessage?.contextInfo??e.listMessage?.contextInfo;if(i)return i;for(let t of Object.values(e)){if(!t||typeof t!=`object`||!(`contextInfo`in t))continue;let e=t.contextInfo;if(e)return e}}function dt(e){let t=Q(e);if(!t)return;let n=[t.extendedTextMessage?.contextInfo?.mentionedJid,t.extendedTextMessage?.contextInfo?.quotedMessage?.extendedTextMessage?.contextInfo?.mentionedJid,t.imageMessage?.contextInfo?.mentionedJid,t.videoMessage?.contextInfo?.mentionedJid,t.documentMessage?.contextInfo?.mentionedJid,t.audioMessage?.contextInfo?.mentionedJid,t.stickerMessage?.contextInfo?.mentionedJid,t.buttonsResponseMessage?.contextInfo?.mentionedJid,t.listResponseMessage?.contextInfo?.mentionedJid].flatMap(e=>e??[]).filter(Boolean);if(n.length!==0)return Array.from(new Set(n))}function ft(e){let t=Q(e);if(!t)return;let n=Ge(t),r=[t,n&&n!==t?n:void 0];for(let e of r){if(!e)continue;if(typeof e.conversation==`string`&&e.conversation.trim())return e.conversation.trim();let t=e.extendedTextMessage?.text;if(t?.trim())return t.trim();let n=e.imageMessage?.caption??e.videoMessage?.caption??e.documentMessage?.caption;if(n?.trim())return n.trim()}let i=mt(t)??(n&&n!==t?mt(n):void 0);if(i)return i}function pt(e){let t=Q(e);if(t){if(t.imageMessage)return`<media:image>`;if(t.videoMessage)return`<media:video>`;if(t.audioMessage)return`<media:audio>`;if(t.documentMessage)return`<media:document>`;if(t.stickerMessage)return`<media:sticker>`}}function mt(e){let t=Q(e);if(!t)return;let n=t.contactMessage??void 0;if(n){let{name:e,phones:t}=ht({displayName:n.displayName,vcard:n.vcard});return gt(e,t)}let r=t.contactsArrayMessage?.contacts??void 0;if(!(!r||r.length===0))return _t(r.map(e=>ht({displayName:e.displayName,vcard:e.vcard})).map(e=>vt(e.name,e.phones)).filter(e=>!!e),r.length)}function ht(e){let t=(e.displayName??``).trim(),n=at(e.vcard??void 0);return{name:t||n.name,phones:n.phones}}function gt(e,t){let n=vt(e,t);return n?`<contact: ${n}>`:`<contact>`}function _t(e,t){let n=e.map(e=>e.trim()).filter(Boolean);if(n.length===0)return`<contacts: ${t} ${t===1?`contact`:`contacts`}>`;let r=Math.max(t-n.length,0),i=r>0?` +${r} more`:``;return`<contacts: ${n.join(`, `)}${i}>`}function vt(e,t){let n=[e,yt(t)].filter(e=>!!e);if(n.length!==0)return n.join(`, `)}function yt(e){let t=e?.map(e=>e.trim()).filter(Boolean)??[];if(t.length===0)return;let{shown:n,remaining:r}=bt(t,t.length,1),[i]=n;if(i)return r===0?i:`${i} (+${r} more)`}function bt(e,t,n){let r=e.slice(0,n);return{shown:r,remaining:Math.max(t-r.length,0)}}function xt(e){let t=Q(e);if(!t)return null;let n=t.liveLocationMessage??void 0;if(n){let e=n.degreesLatitude,t=n.degreesLongitude;if(e!=null&&t!=null){let r=Number(e),i=Number(t);if(Number.isFinite(r)&&Number.isFinite(i))return{latitude:r,longitude:i,accuracy:n.accuracyInMeters??void 0,caption:n.caption??void 0,source:`live`,isLive:!0}}}let r=t.locationMessage??void 0;if(r){let e=r.degreesLatitude,t=r.degreesLongitude;if(e!=null&&t!=null){let n=Number(e),i=Number(t);if(Number.isFinite(n)&&Number.isFinite(i)){let e=!!r.isLive;return{latitude:n,longitude:i,accuracy:r.accuracyInMeters??void 0,name:r.name??void 0,address:r.address??void 0,caption:r.comment??void 0,source:e?`live`:r.name||r.address?`place`:`pin`,isLive:e}}}}return null}function St(e){let t=Q(e);if(!t)return null;let n=ut(t),r=Je(n?.quotedMessage);if(!r)return null;let i=xt(r),a=i?Ce(i):void 0,o=[ft(r),a].filter(Boolean).join(`
|
|
2
2
|
`).trim();if(o||=pt(r),!o){let e=r?Ke(r):void 0;return T(`Quoted message missing extractable body${e?` (type ${e})`:``}`),null}let s=n?.participant??void 0,c=s?O(s)??s:void 0,l=c??`unknown sender`;return{id:n?.stanzaId?String(n.stanzaId):void 0,body:o,sender:l,senderJid:s,senderE164:c}}function Ct(e){return M({providerConfigPresent:e.providerConfigPresent,groupPolicy:e.groupPolicy,defaultGroupPolicy:e.defaultGroupPolicy})}async function wt(e){let t=m(),n=v({cfg:t,accountId:e.accountId}),r=n.dmPolicy??`pairing`,i=n.allowFrom??[],a=await W({provider:`whatsapp`,accountId:n.accountId,dmPolicy:r}),o=i.length===0&&e.selfE164?[e.selfE164]:[],s=i.length>0?i:o,c=n.groupAllowFrom??(i.length>0?i:void 0),l=e.from===e.selfE164,u=n.selfChatMode??A(e.selfE164,i),d=typeof e.pairingGraceMs==`number`&&e.pairingGraceMs>0?e.pairingGraceMs:3e4,f=typeof e.connectedAtMs==`number`&&typeof e.messageTimestampMs==`number`&&e.messageTimestampMs<e.connectedAtMs-d,p=ee(t),{groupPolicy:h,providerMissingFallbackApplied:g}=Ct({providerConfigPresent:t.channels?.whatsapp!==void 0,groupPolicy:n.groupPolicy,defaultGroupPolicy:p});N({providerMissingFallbackApplied:g,providerKey:`whatsapp`,accountId:n.accountId,log:e=>T(e)});let _=D(e.from),y=typeof e.senderE164==`string`?D(e.senderE164):null,b=ue({isGroup:e.group,dmPolicy:r,groupPolicy:h,allowFrom:e.group?i:s,groupAllowFrom:c,storeAllowFrom:a,isSenderAllowed:t=>{if(t.includes(`*`))return!0;let n=new Set(t.map(e=>D(String(e))).filter(e=>!!e));return!e.group&&l?!0:e.group?!!(y&&n.has(y)):n.has(_)}});if(e.group&&b.decision!==`allow`)return b.reason===`groupPolicy=disabled`?T(`Blocked group message (groupPolicy: disabled)`):b.reason===`groupPolicy=allowlist (empty allowlist)`?T(`Blocked group message (groupPolicy: allowlist, no groupAllowFrom)`):T(`Blocked group message from ${e.senderE164??`unknown sender`} (groupPolicy: allowlist)`),{allowed:!1,shouldMarkRead:!1,isSelfChat:u,resolvedAccountId:n.accountId};if(!e.group){if(e.isFromMe&&!l)return T(`Skipping outbound DM (fromMe); no pairing reply needed.`),{allowed:!1,shouldMarkRead:!1,isSelfChat:u,resolvedAccountId:n.accountId};if(b.decision===`block`&&b.reason===`dmPolicy=disabled`)return T(`Blocked dm (dmPolicy: disabled)`),{allowed:!1,shouldMarkRead:!1,isSelfChat:u,resolvedAccountId:n.accountId};if(b.decision===`pairing`&&!l){let t=e.from;return f?T(`Skipping pairing reply for historical DM from ${t}.`):await K({channel:`whatsapp`,senderId:t,senderIdLine:`Your WhatsApp phone number: ${t}`,meta:{name:(e.pushName??``).trim()||void 0},upsertPairingRequest:async({id:e,meta:t})=>await Ee({channel:`whatsapp`,id:e,accountId:n.accountId,meta:t}),onCreated:()=>{T(`whatsapp pairing request sender=${t} name=${e.pushName??`unknown`}`)},sendPairingReply:async t=>{await e.sock.sendMessage(e.remoteJid,{text:t})},onReplyError:e=>{T(`whatsapp pairing reply failed for ${t}: ${String(e)}`)}}),{allowed:!1,shouldMarkRead:!1,isSelfChat:u,resolvedAccountId:n.accountId}}if(b.decision!==`allow`)return T(`Blocked unauthorized sender ${e.from} (dmPolicy=${r})`),{allowed:!1,shouldMarkRead:!1,isSelfChat:u,resolvedAccountId:n.accountId}}return{allowed:!0,shouldMarkRead:!0,isSelfChat:u,resolvedAccountId:n.accountId}}function Tt(e){return Je(e)}function Et(e){let t=e.imageMessage?.mimetype??e.videoMessage?.mimetype??e.documentMessage?.mimetype??e.audioMessage?.mimetype??e.stickerMessage?.mimetype??void 0;if(t)return t;if(e.audioMessage)return`audio/ogg; codecs=opus`;if(e.imageMessage)return`image/jpeg`;if(e.videoMessage)return`video/mp4`;if(e.stickerMessage)return`image/webp`}async function Dt(e,t){let n=Tt(e.message);if(!n)return;let r=Et(n),i=n.documentMessage?.fileName??void 0;if(!(!n.imageMessage&&!n.videoMessage&&!n.documentMessage&&!n.audioMessage&&!n.stickerMessage))try{return{buffer:await We(e,`buffer`,{},{reuploadRequest:t.updateMediaMessage,logger:t.logger}),mimetype:r,fileName:i}}catch(e){T(`downloadMediaMessage failed: ${String(e)}`);return}}function Ot(e){Pe({channel:`whatsapp`,accountId:e,direction:`outbound`})}function kt(e){return typeof e==`object`&&e&&`key`in e?String(e.key?.id??`unknown`):`unknown`}function At(e){return{sendMessage:async(t,n,r,i,a)=>{let o=E(t),s;if(r&&i)if(i.startsWith(`image/`))s={image:r,caption:n||void 0,mimetype:i};else if(i.startsWith(`audio/`))s={audio:r,ptt:!0,mimetype:i};else if(i.startsWith(`video/`)){let e=a?.gifPlayback;s={video:r,caption:n||void 0,mimetype:i,...e?{gifPlayback:!0}:{}}}else s={document:r,fileName:a?.fileName?.trim()||`file`,caption:n||void 0,mimetype:i};else s={text:n};let c=await e.sock.sendMessage(o,s);return Ot(a?.accountId??e.defaultAccountId),{messageId:kt(c)}},sendPoll:async(t,n)=>{let r=E(t),i=await e.sock.sendMessage(r,{poll:{name:n.question,values:n.options,selectableCount:n.maxSelections??1}});return Ot(e.defaultAccountId),{messageId:kt(i)}},sendReaction:async(t,n,r,i,a)=>{let o=E(t);await e.sock.sendMessage(o,{react:{text:r,key:{remoteJid:o,id:n,fromMe:i,participant:a?E(a):void 0}}})},sendComposingTo:async t=>{let n=E(t);await e.sock.sendPresenceUpdate(`composing`,n)}}}async function jt(e){let t=S({module:`web-inbound`}),n=w(`gateway/channels/whatsapp`).child(`inbound`),r=await Ve(!1,e.verbose,{authDir:e.authDir});await ze(r);let i=Date.now(),a=null,s=new Promise(e=>{a=e}),c=e=>{if(!a)return;let t=a;a=null,t(e)};try{await r.sendPresenceUpdate(`available`),b()&&T(`Sent global 'available' presence on connect`)}catch(e){T(`Failed to send 'available' presence on connect: ${String(e)}`)}let l=r.user?.id,u=l?O(l):null,d=re({debounceMs:e.debounceMs??0,buildKey:e=>{let t=e.chatType===`group`?e.senderJid??e.senderE164??e.senderName??e.from:e.from;if(!t)return null;let n=e.chatType===`group`?e.chatId:e.from;return`${e.accountId}:${n}:${t}`},shouldDebounce:e.shouldDebounce,onFlush:async t=>{let n=t.at(-1);if(!n)return;if(t.length===1){await e.onMessage(n);return}let r=new Set;for(let e of t)for(let t of e.mentionedJids??[])r.add(t);let i=t.map(e=>e.body).filter(Boolean).join(`
|
|
3
3
|
`),a={...n,body:i,mentionedJids:r.size>0?Array.from(r):void 0};await e.onMessage(a)},onError:e=>{t.error({error:String(e)},`failed handling inbound web message`),n.error(`Failed handling inbound web message: ${String(e)}`)}}),f=new Map,p=300*1e3,m=r.signalRepository?.lidMapping,h=async t=>j(t,{authDir:e.authDir,lidLookup:m}),g=async e=>{let t=f.get(e);if(t&&t.expires>Date.now())return t;try{let t=await r.groupMetadata(e),n=(await Promise.all(t.participants?.map(async e=>await h(e.id)??e.id)??[])).filter(Boolean)??[],i={subject:t.subject,participants:n,expires:Date.now()+p};return f.set(e,i),i}catch(t){return T(`Failed to fetch group metadata for ${e}: ${String(t)}`),{expires:Date.now()+p}}},_=async t=>{let n=t.key?.id??void 0,a=t.key?.remoteJid;if(!a||a.endsWith(`@status`)||a.endsWith(`@broadcast`))return null;let o=qe(a)===!0;if(n&&rt(`${e.accountId}:${a}:${n}`))return null;let s=t.key?.participant??void 0,c=o?a:await h(a);if(!c)return null;let l=o?s?await h(s):null:c,d,f;if(o){let e=await g(a);d=e.subject,f=e.participants}let p=t.messageTimestamp?Number(t.messageTimestamp)*1e3:void 0,m=await wt({accountId:e.accountId,from:c,selfE164:u,senderE164:l,group:o,pushName:t.pushName??void 0,isFromMe:!!t.key?.fromMe,messageTimestampMs:p,connectedAtMs:i,sock:{sendMessage:(e,t)=>r.sendMessage(e,t)},remoteJid:a});return m.allowed?{id:n,remoteJid:a,group:o,participantJid:s,from:c,senderE164:l,groupSubject:d,groupParticipants:f,messageTimestampMs:p,access:m}:null},v=async t=>{let{id:n,remoteJid:i,participantJid:a,access:o}=t;if(n&&!o.isSelfChat&&e.sendReadReceipts!==!1)try{await r.readMessages([{remoteJid:i,id:n,participant:a,fromMe:!1}]),b()&&T(`Marked message ${n} as read for ${i}${a?` (participant ${a})`:``}`)}catch(e){T(`Failed to mark message ${n} read: ${String(e)}`)}else n&&o.isSelfChat&&b()&&T(`Self-chat mode: skipping read receipt for ${n}`)},y=async t=>{let n=xt(t.message??void 0),i=n?Ce(n):void 0,a=ft(t.message??void 0);if(i&&(a=[a,i].filter(Boolean).join(`
|
|
4
4
|
`).trim()),!a&&(a=pt(t.message??void 0),!a))return null;let s=St(t.message),c,l,u;try{let n=await Dt(t,r);if(n){let t=(typeof e.mediaMaxMb==`number`&&e.mediaMaxMb>0?e.mediaMaxMb:50)*1024*1024;c=(await o(n.buffer,n.mimetype,`inbound`,t,n.fileName)).path,l=n.mimetype,u=n.fileName}}catch(e){T(`Inbound media download failed: ${String(e)}`)}return{body:a,location:n??void 0,replyContext:s,mediaPath:c,mediaType:l,mediaFileName:u}},x=async(e,i,a)=>{let o=i.remoteJid,s=async()=>{try{await r.sendPresenceUpdate(`composing`,o)}catch(e){T(`Presence update failed: ${String(e)}`)}},c=async e=>{await r.sendMessage(o,{text:e})},f=async e=>{await r.sendMessage(o,e)},p=i.messageTimestampMs,m=dt(e.message),h=e.pushName??void 0;t.info({from:i.from,to:u??`me`,body:a.body,mediaPath:a.mediaPath,mediaType:a.mediaType,mediaFileName:a.mediaFileName,timestamp:p},`inbound message`);let g={id:i.id,from:i.from,conversationId:i.from,to:u??`me`,accountId:i.access.resolvedAccountId,body:a.body,pushName:h,timestamp:p,chatType:i.group?`group`:`direct`,chatId:i.remoteJid,senderJid:i.participantJid,senderE164:i.senderE164??void 0,senderName:h,replyToId:a.replyContext?.id,replyToBody:a.replyContext?.body,replyToSender:a.replyContext?.sender,replyToSenderJid:a.replyContext?.senderJid,replyToSenderE164:a.replyContext?.senderE164,groupSubject:i.groupSubject,groupParticipants:i.groupParticipants,mentionedJids:m??void 0,selfJid:l,selfE164:u,fromMe:!!e.key?.fromMe,location:a.location??void 0,sendComposing:s,reply:c,sendMedia:f,mediaPath:a.mediaPath,mediaType:a.mediaType,mediaFileName:a.mediaFileName};try{Promise.resolve(d.enqueue(g)).catch(e=>{t.error({error:String(e)},`failed handling inbound web message`),n.error(`Failed handling inbound web message: ${String(e)}`)})}catch(e){t.error({error:String(e)},`failed handling inbound web message`),n.error(`Failed handling inbound web message: ${String(e)}`)}},C=async t=>{if(!(t.type!==`notify`&&t.type!==`append`))for(let n of t.messages??[]){Pe({channel:`whatsapp`,accountId:e.accountId,direction:`inbound`});let r=await _(n);if(!r||(await v(r),t.type===`append`))continue;let i=await y(n);i&&await x(n,r,i)}};r.ev.on(`messages.upsert`,C);let E=e=>{try{if(e.connection===`close`){let t=Be(e.lastDisconnect?.error);c({status:t,isLoggedOut:t===Ue.loggedOut,error:e.lastDisconnect?.error})}}catch(e){t.error({error:String(e)},`connection.update handler error`),c({status:void 0,isLoggedOut:!1,error:e})}};return r.ev.on(`connection.update`,E),{close:async()=>{try{let e=r.ev,t=C,n=E;typeof e.off==`function`?(e.off(`messages.upsert`,t),e.off(`connection.update`,n)):typeof e.removeListener==`function`&&(e.removeListener(`messages.upsert`,t),e.removeListener(`connection.update`,n)),r.ws?.close()}catch(e){T(`Socket close failed: ${String(e)}`)}},onClose:s,signalClose:e=>{c(e??{status:void 0,isLoggedOut:!1,error:`closed`})},...At({sock:{sendMessage:(e,t)=>r.sendMessage(e,t),sendPresenceUpdate:(e,t)=>r.sendPresenceUpdate(e,t)},defaultAccountId:e.accountId})}}function Mt(e,t){return{mentionRegexes:ce(e,t),allowFrom:e.channels?.whatsapp?.allowFrom}}function Nt(e,t){let n=t?{authDir:t}:void 0;return{normalizedMentions:e.mentionedJids?.length?e.mentionedJids.map(e=>O(e,n)??e).filter(Boolean):[],selfE164:e.selfE164??(e.selfJid?O(e.selfJid,n):null),selfJid:e.selfJid?e.selfJid.replace(/:\\d+/,``):null}}function Pt(e,t,n){let r=e=>R(e),i=A(n.selfE164,t.allowFrom);if((e.mentionedJids?.length??0)>0&&!i)return!!(n.selfE164&&n.normalizedMentions.includes(n.selfE164)||n.selfJid&&n.normalizedMentions.includes(n.selfJid));let a=r(e.body);if(t.mentionRegexes.some(e=>e.test(a)))return!0;if(n.selfE164){let t=n.selfE164.replace(/\D/g,``);if(t){if(a.replace(/[^\d]/g,``).includes(t))return!0;let n=e.body.replace(/[\s-]/g,``);if(RegExp(`\\+?${t}`,`i`).test(n))return!0}}return!1}function Ft(e,t,n){let r=Nt(e,n);return{wasMentioned:Pt(e,t,r),details:{from:e.from,body:e.body,bodyClean:R(e.body),mentionedJids:e.mentionedJids??null,normalizedMentionedJids:r.normalizedMentions.length?r.normalizedMentions:null,selfJid:e.selfJid??null,selfJidBare:r.selfJid,selfE164:e.selfE164??null,resolvedSelfE164:r.selfE164}}}function It(e,t){let n=e.allowFrom;return(Array.isArray(n)&&n.length>0?n:t?[t]:[]).filter(e=>!!(e&&e!==`*`)).map(e=>D(e)).filter(e=>!!e)}function Lt(e){let t=new Set,n=Math.max(1,e.maxItems??100),r=e=>`combined:${e.sessionKey}:${e.combinedBody}`,i=()=>{for(;t.size>n;){let e=t.values().next().value;if(!e)break;t.delete(e)}};return{rememberText:(n,a)=>{n&&(t.add(n),a.combinedBody&&a.combinedBodySessionKey&&t.add(r({sessionKey:a.combinedBodySessionKey,combinedBody:a.combinedBody})),a.logVerboseMessage&&e.logVerbose?.(`Added to echo detection set (size now: ${t.size}): ${n.substring(0,50)}...`),i())},has:e=>t.has(e),forget:e=>{t.delete(e)},buildCombinedKey:r}}function Rt(n){let r=H({agentId:n.agentId,channel:`whatsapp`,accountId:n.route.accountId,peer:{kind:n.msg.chatType===`group`?`group`:`direct`,id:n.peerId},dmScope:n.cfg.session?.dmScope,identityLinks:n.cfg.session?.identityLinks}),i=e({agentId:n.agentId,mainKey:t});return{sessionKey:r,mainSessionKey:i,lastRoutePolicy:ae({sessionKey:r,mainSessionKey:i})}}async function zt(e){let t=e.cfg.broadcast?.[e.peerId];if(!t||!Array.isArray(t)||t.length===0)return!1;let r=e.cfg.broadcast?.strategy||`parallel`;X.info(`Broadcasting message to ${t.length} agents (${r})`);let i=e.cfg.agents?.list?.map(e=>n(e.id)),a=(i?.length??0)>0,o=e.msg.chatType===`group`?e.groupHistories.get(e.groupHistoryKey)??[]:void 0,s=async t=>{let r=n(t);if(a&&!i?.includes(r))return X.warn(`Broadcast agent ${t} not found in agents.list; skipping`),!1;let s=Rt({cfg:e.cfg,msg:e.msg,route:e.route,peerId:e.peerId,agentId:r}),c={...e.route,agentId:r,...s};try{return await e.processMessage(e.msg,c,e.groupHistoryKey,{groupHistory:o,suppressGroupHistoryClear:!0})}catch(e){return X.error(`Broadcast agent ${t} failed: ${q(e)}`),!1}};if(r===`sequential`)for(let e of t)await s(e);else await Promise.allSettled(t.map(s));return e.msg.chatType===`group`&&e.groupHistories.set(e.groupHistoryKey,[]),!0}function Bt(e,t,n){let r=e;for(let e of t)r=r.replace(e,` `);if(n){let e=n.replace(/\D/g,``);if(e){let t=RegExp(`\\+?${e}`,`g`);r=r.replace(t,` `)}}return r.replace(/\s+/g,` `).trim()}function Vt(e,t){let n=d({From:t,ChatType:`group`,Provider:`whatsapp`})?.id,r=e.channels?.whatsapp,i=!!(r?.groupAllowFrom?.length||r?.allowFrom?.length);return p({cfg:e,channel:`whatsapp`,groupId:n??t,hasGroupAllowFrom:i})}function Ht(e,t){let n=d({From:t,ChatType:`group`,Provider:`whatsapp`})?.id;return c({cfg:e,channel:`whatsapp`,groupId:n??t})}function Ut(e){let t=g(a(e.cfg.session?.store,{agentId:e.agentId}))[e.sessionKey],n=Ht(e.cfg,e.conversationId)?`mention`:`always`;return z(t?.groupActivation)??n}function Wt(e,t,n){for(let r of e){let e=D(r)??r;!e||t.has(e)||(t.add(e),n.push(e))}}function Gt(e,t,n,r){if(!n||!r)return;let i=D(n)??n;if(!i)return;let a=e.get(t);a||(a=new Map,e.set(t,a)),a.set(i,r)}function Kt(e){let{participants:t,roster:n,fallbackE164:r}=e,i=new Set,a=[];if(t?.length&&Wt(t,i,a),n&&Wt(n.keys(),i,a),a.length===0&&r){let e=D(r)??r;e&&a.push(e)}if(a.length!==0)return a.map(e=>{let t=n?.get(e);return t?`${t} (${e})`:e}).join(`, `)}function qt(e,t){let n=D(t.senderE164??``);return n?It(e,t.selfE164??void 0).includes(n):!1}function Jt(e){let t=e.msg.senderName&&e.msg.senderE164?`${e.msg.senderName} (${e.msg.senderE164})`:e.msg.senderName??e.msg.senderE164??`Unknown`;xe({historyMap:e.groupHistories,historyKey:e.groupHistoryKey,limit:e.groupHistoryLimit,entry:{sender:t,body:e.msg.body,timestamp:e.msg.timestamp,id:e.msg.id,senderJid:e.msg.senderJid}})}function Yt(e,t){return e.logVerbose(t),Jt({msg:e.msg,groupHistories:e.groupHistories,groupHistoryKey:e.groupHistoryKey,groupHistoryLimit:e.groupHistoryLimit}),{shouldProcess:!1}}function Xt(e){let t=Vt(e.cfg,e.conversationId);if(t.allowlistEnabled&&!t.allowed)return e.logVerbose(`Skipping group message ${e.conversationId} (not in allowlist)`),{shouldProcess:!1};Gt(e.groupMemberNames,e.groupHistoryKey,e.msg.senderE164,e.msg.senderName);let n=Mt(e.cfg,e.agentId),r=Bt(e.msg.body,n.mentionRegexes,e.msg.selfE164),i=Se(r),a=qt(e.baseMentionConfig,e.msg),o=a&&P(r,e.cfg);if(i.hasCommand&&!a)return Yt(e,`Ignoring /activation from non-owner in group ${e.conversationId}`);let s=Ft(e.msg,n,e.authDir);e.replyLogger.debug({conversationId:e.conversationId,wasMentioned:s.wasMentioned,...s.details},`group mention debug`);let c=s.wasMentioned,l=Ut({cfg:e.cfg,agentId:e.agentId,sessionKey:e.sessionKey,conversationId:e.conversationId})!==`always`,u=e.msg.selfJid?.replace(/:\\d+/,``),d=e.msg.replyToSenderJid?.replace(/:\\d+/,``),f=e.msg.selfE164?D(e.msg.selfE164):null,p=e.msg.replyToSenderE164?D(e.msg.replyToSenderE164):null,m=G({requireMention:l,canDetectMention:!0,wasMentioned:c,implicitMention:!!(u&&d&&u===d||f&&p&&f===p),shouldBypassMention:o});return e.msg.wasMentioned=m.effectiveWasMentioned,!o&&l&&m.shouldSkip?Yt(e,`Group message stored for context (no mention detected) in ${e.conversationId}: ${e.msg.body}`):{shouldProcess:!0}}function Zt(e,t){e.add(t),t.finally(()=>{e.delete(t)})}function Qt(e){let t=a(e.cfg.session?.store,{agentId:e.storeAgentId}),n=_({storePath:t,sessionKey:e.sessionKey,deliveryContext:{channel:e.channel,to:e.to,accountId:e.accountId},ctx:e.ctx}).catch(n=>{e.warn({error:q(n),storePath:t,sessionKey:e.sessionKey,to:e.to},`failed updating last route`)});Zt(e.backgroundTasks,n)}function $t(e){return e.chatType===`group`?e.conversationId??e.from:e.senderE164?D(e.senderE164)??e.senderE164:e.from.includes(`@`)?O(e.from)??e.from:D(e.from)??e.from}function $(e,t=400){return!e||e.length<=t?e:`${e.slice(0,t)}… (truncated ${e.length-t} chars)`}function en(e){let t=(e instanceof Error?`${e.message}\n${e.stack??``}`:(e=>{if(e==null)return``;if(typeof e==`string`)return e;if(e instanceof Error)return`${e.message}\n${e.stack??``}`;if(typeof e==`object`)try{return JSON.stringify(e)}catch{return Object.prototype.toString.call(e)}return typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`?String(e):typeof e==`symbol`?e.description??e.toString():typeof e==`function`?e.name?`[function ${e.name}]`:`[function]`:Object.prototype.toString.call(e)})(e)).toLowerCase();return t.includes(`unsupported state or unable to authenticate data`)||t.includes(`bad mac`)?t.includes(`@whiskeysockets/baileys`)||t.includes(`baileys`)||t.includes(`noise-handler`)||t.includes(`aesdecryptgcm`):!1}function tn(e){if(e.isReasoning===!0)return!0;let t=e.text;return typeof t==`string`?t.trimStart().toLowerCase().startsWith(`reasoning:`):!1}async function nn(e){let{replyResult:t,msg:n,maxMediaBytes:r,textLimit:i,replyLogger:a,connectionId:o,skipLog:s}=e,c=Date.now();if(tn(t)){Z.debug(`Suppressed reasoning payload to ${n.from}`);return}let l=e.tableMode??`code`,u=e.chunkMode??`length`,d=Ae(Le(Fe(t.text||``,l)),i,u),f=t.mediaUrls?.length?t.mediaUrls:t.mediaUrl?[t.mediaUrl]:[],p=async(e,t,r=3)=>{let i;for(let a=1;a<=r;a++)try{return await e()}catch(e){i=e;let o=q(e),s=a===r;if(!/closed|reset|timed\s*out|disconnect/i.test(o)||s)throw e;let c=500*a;T(`Retrying ${t} to ${n.from} after failure (${a}/${r-1}) in ${c}ms: ${o}`),await x(c)}throw i};if(f.length===0&&d.length){let e=d.length;for(let[t,r]of d.entries()){let i=Date.now();if(await p(()=>n.reply(r),`text`),!s){let r=Date.now()-i;Z.debug(`Sent chunk ${t+1}/${e} to ${n.from} (${r.toFixed(0)}ms)`)}}a.info({correlationId:n.id??J(),connectionId:o??null,to:n.from,from:n.to,text:$(t.text,240),mediaUrl:null,mediaSizeBytes:null,mediaKind:null,durationMs:Date.now()-c},`auto-reply sent (text)`);return}let m=[...d];for(let[t,i]of f.entries()){let s=t===0&&m.shift()||void 0;try{let t=await ke(i,{maxBytes:r,localRoots:e.mediaLocalRoots});if(b()&&(T(`Web auto-reply media size: ${(t.buffer.length/(1024*1024)).toFixed(2)}MB`),T(`Web auto-reply media source: ${i} (kind ${t.kind})`)),t.kind===`image`)await p(()=>n.sendMedia({image:t.buffer,caption:s,mimetype:t.contentType}),`media:image`);else if(t.kind===`audio`)await p(()=>n.sendMedia({audio:t.buffer,ptt:!0,mimetype:t.contentType,caption:s}),`media:audio`);else if(t.kind===`video`)await p(()=>n.sendMedia({video:t.buffer,caption:s,mimetype:t.contentType}),`media:video`);else{let e=t.fileName??i.split(`/`).pop()??`file`,r=t.contentType??`application/octet-stream`;await p(()=>n.sendMedia({document:t.buffer,fileName:e,caption:s,mimetype:r}),`media:document`)}Z.info(`Sent media reply to ${n.from} (${(t.buffer.length/(1024*1024)).toFixed(2)}MB)`),a.info({correlationId:n.id??J(),connectionId:o??null,to:n.from,from:n.to,text:s??null,mediaUrl:i,mediaSizeBytes:t.buffer.length,mediaKind:t.kind,durationMs:Date.now()-c},`auto-reply sent (media)`)}catch(e){if(Z.error(`Failed sending web media to ${n.from}: ${q(e)}`),a.warn({err:e,mediaUrl:i},`failed to send web media reply`),t===0){let t=e instanceof Error?`⚠️ Media failed: ${e.message}`:`⚠️ Media failed.`,r=[m.shift()??s??``,t].filter(Boolean).join(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Lt as e,Mt as t,Pt as n,Ut as r,jt as i,s as a}from"./paths-CSbOOCsu.js";import{Fr as o,Gc as s,Gl as c,Io as l,Lo as u,Lr as d,Nr as f,Uo as p,Ya as m,Za as h,js as g,qa as _,r as v,ro as y}from"./config-B-UcenbQ.js";import{$ as b,Ct as x,D as S,E as C,Gt as ee,H as w,Ht as T,I as te,J as E,Mt as ne,Nt as re,Q as D,St as ie,Ut as O,Y as ae,Z as k,_t as oe,at as A,bt as j,ct as M,et as N,ht as se,it as ce,j as P,jt as le,mt as ue,nt as F,ot as I,r as de,st as fe,tt as pe,vt as L,wt as R,xt as me,zt as z}from"./dispatch-
|
|
1
|
+
import{Lt as e,Mt as t,Pt as n,Ut as r,jt as i,s as a}from"./paths-CSbOOCsu.js";import{Fr as o,Gc as s,Gl as c,Io as l,Lo as u,Lr as d,Nr as f,Uo as p,Ya as m,Za as h,js as g,qa as _,r as v,ro as y}from"./config-B-UcenbQ.js";import{$ as b,Ct as x,D as S,E as C,Gt as ee,H as w,Ht as T,I as te,J as E,Mt as ne,Nt as re,Q as D,St as ie,Ut as O,Y as ae,Z as k,_t as oe,at as A,bt as j,ct as M,et as N,ht as se,it as ce,j as P,jt as le,mt as ue,nt as F,ot as I,r as de,st as fe,tt as pe,vt as L,wt as R,xt as me,zt as z}from"./dispatch-DzdnDix3.js";import{B,C as V,E as H,K as U,N as W,R as G,S as K,a as he,j as ge,l as _e,m as ve,x as ye}from"./logger-C9qBS3pT.js";import{It as be,Nt as xe,Pt as Se}from"./send-Cm3DUp7B.js";import{n as Ce}from"./channel-activity-BmtBYQiY.js";import{t as we}from"./local-roots-CJmQubXD.js";import{c as Te,d as Ee,f as De,i as Oe,v as ke}from"./ir-CtV16xaT.js";import{t as Ae}from"./tables-BSCz74OW.js";import{X as je,Y as Me,et as Ne,nt as Pe}from"./send-BZLHNxgv.js";import{p as Fe}from"./audio-transcription-runner-CDEClJ7w.js";import{r as Ie}from"./active-listener-Djm3luQD.js";import{i as Le,r as Re}from"./outbound-RGOrt1pb.js";import{i as ze,n as q,r as Be,t as Ve}from"./session-DfMpA14O.js";import{randomUUID as He}from"node:crypto";import{DisconnectReason as Ue,downloadMediaMessage as We,extractMessageContent as Ge,getContentType as Ke,isJidGroup as qe,normalizeMessageContent as Je}from"@whiskeysockets/baileys";function Ye(e){if((e.session?.scope??`per-sender`)===`global`)return[];let t=f(a(e.session?.store)),n=e=>e.includes(`:group:`)||e.includes(`:channel:`)||e.includes(`@g.us`),r=e=>e.startsWith(`cron:`),i=Object.entries(t).filter(([e])=>e!==`global`&&e!==`unknown`).filter(([e])=>!n(e)&&!r(e)).map(([e,t])=>({to:s(t?.lastChannel)===`whatsapp`&&t?.lastTo?V(t.lastTo):``,updatedAt:t?.updatedAt??0})).filter(({to:e})=>e.length>1).toSorted((e,t)=>t.updatedAt-e.updatedAt),o=new Set;return i.filter(e=>o.has(e.to)?!1:(o.add(e.to),!0))}function Xe(e,t={}){if(t.to)return{recipients:[V(t.to)],source:`flag`};let n=Ye(e),i=Array.isArray(e.channels?.whatsapp?.allowFrom)&&e.channels.whatsapp.allowFrom.length>0?e.channels.whatsapp.allowFrom.filter(e=>e!==`*`).map(V):[],a=Ne(`whatsapp`,process.env,r).map(V),o=e=>[...new Set(e.filter(Boolean))],s=o([...i,...a]);if(t.all)return{recipients:o([...n.map(e=>e.to),...s]),source:`all`};if(s.length>0){let e=new Set(s),t=n.map(e=>e.to).filter(t=>e.has(t));return t.length===1?{recipients:[t[0]],source:`session-single`}:t.length>1?{recipients:t,source:`session-ambiguous`}:{recipients:s,source:`allowFrom`}}return n.length===1?{recipients:[n[0].to],source:`session-single`}:n.length>1?{recipients:n.map(e=>e.to),source:`session-ambiguous`}:{recipients:s,source:`allowFrom`}}const Ze={initialMs:2e3,maxMs:3e4,factor:1.8,jitter:.25,maxAttempts:12};function Qe(e,t){let n=t??e.web?.heartbeatSeconds;return typeof n==`number`&&n>0?n:60}function $e(e,t){let n=e.web?.reconnect??{},r=t??{},i={...Ze,...n,...r};return i.initialMs=Math.max(250,i.initialMs),i.maxMs=Math.max(i.initialMs,i.maxMs),i.factor=ve(i.factor,1.1,10),i.jitter=ve(i.jitter,0,1),i.maxAttempts=Math.max(0,Math.floor(i.maxAttempts)),i}function J(){return He()}const Y=he(`gateway/channels/whatsapp`),X=Y.child(`inbound`),Z=Y.child(`outbound`),et=Y.child(`heartbeat`);function tt(){return setInterval(()=>{},1e6).unref(),new Promise(()=>{})}const nt=I({ttlMs:20*6e4,maxSize:5e3});function rt(e){return nt.check(e)}const it=new Set([`FN`,`N`,`TEL`]);function at(e){if(!e)return{phones:[]};let t=e.split(/\r?\n/),n,r,i=[];for(let e of t){let t=e.trim();if(!t)continue;let a=t.indexOf(`:`);if(a===-1)continue;let o=t.slice(0,a).toUpperCase(),s=t.slice(a+1).trim();if(!s)continue;let c=ot(o);if(!c||!it.has(c))continue;let l=st(s);if(l){if(c===`FN`&&!r){r=ct(l);continue}if(c===`N`&&!n){n=ct(l);continue}if(c===`TEL`){let e=lt(l);e&&i.push(e)}}}return{name:r??n,phones:i}}function ot(e){let[t]=e.split(`;`);if(!t)return;let n=t.split(`.`);return n[n.length-1]||void 0}function st(e){return e.replace(/\\n/gi,` `).replace(/\\,/g,`,`).replace(/\\;/g,`;`).trim()}function ct(e){return e.replace(/;/g,` `).replace(/\s+/g,` `).trim()}function lt(e){let t=e.trim();return t?t.toLowerCase().startsWith(`tel:`)?t.slice(4).trim():t:``}function Q(e){return Je(e)}function ut(e){if(!e)return;let t=Ke(e),n=t?e[t]:void 0,r=n&&typeof n==`object`&&`contextInfo`in n?n.contextInfo:void 0;if(r)return r;let i=e.extendedTextMessage?.contextInfo??e.imageMessage?.contextInfo??e.videoMessage?.contextInfo??e.documentMessage?.contextInfo??e.audioMessage?.contextInfo??e.stickerMessage?.contextInfo??e.buttonsResponseMessage?.contextInfo??e.listResponseMessage?.contextInfo??e.templateButtonReplyMessage?.contextInfo??e.interactiveResponseMessage?.contextInfo??e.buttonsMessage?.contextInfo??e.listMessage?.contextInfo;if(i)return i;for(let t of Object.values(e)){if(!t||typeof t!=`object`||!(`contextInfo`in t))continue;let e=t.contextInfo;if(e)return e}}function dt(e){let t=Q(e);if(!t)return;let n=[t.extendedTextMessage?.contextInfo?.mentionedJid,t.extendedTextMessage?.contextInfo?.quotedMessage?.extendedTextMessage?.contextInfo?.mentionedJid,t.imageMessage?.contextInfo?.mentionedJid,t.videoMessage?.contextInfo?.mentionedJid,t.documentMessage?.contextInfo?.mentionedJid,t.audioMessage?.contextInfo?.mentionedJid,t.stickerMessage?.contextInfo?.mentionedJid,t.buttonsResponseMessage?.contextInfo?.mentionedJid,t.listResponseMessage?.contextInfo?.mentionedJid].flatMap(e=>e??[]).filter(Boolean);if(n.length!==0)return Array.from(new Set(n))}function ft(e){let t=Q(e);if(!t)return;let n=Ge(t),r=[t,n&&n!==t?n:void 0];for(let e of r){if(!e)continue;if(typeof e.conversation==`string`&&e.conversation.trim())return e.conversation.trim();let t=e.extendedTextMessage?.text;if(t?.trim())return t.trim();let n=e.imageMessage?.caption??e.videoMessage?.caption??e.documentMessage?.caption;if(n?.trim())return n.trim()}let i=mt(t)??(n&&n!==t?mt(n):void 0);if(i)return i}function pt(e){let t=Q(e);if(t){if(t.imageMessage)return`<media:image>`;if(t.videoMessage)return`<media:video>`;if(t.audioMessage)return`<media:audio>`;if(t.documentMessage)return`<media:document>`;if(t.stickerMessage)return`<media:sticker>`}}function mt(e){let t=Q(e);if(!t)return;let n=t.contactMessage??void 0;if(n){let{name:e,phones:t}=ht({displayName:n.displayName,vcard:n.vcard});return gt(e,t)}let r=t.contactsArrayMessage?.contacts??void 0;if(!(!r||r.length===0))return _t(r.map(e=>ht({displayName:e.displayName,vcard:e.vcard})).map(e=>vt(e.name,e.phones)).filter(e=>!!e),r.length)}function ht(e){let t=(e.displayName??``).trim(),n=at(e.vcard??void 0);return{name:t||n.name,phones:n.phones}}function gt(e,t){let n=vt(e,t);return n?`<contact: ${n}>`:`<contact>`}function _t(e,t){let n=e.map(e=>e.trim()).filter(Boolean);if(n.length===0)return`<contacts: ${t} ${t===1?`contact`:`contacts`}>`;let r=Math.max(t-n.length,0),i=r>0?` +${r} more`:``;return`<contacts: ${n.join(`, `)}${i}>`}function vt(e,t){let n=[e,yt(t)].filter(e=>!!e);if(n.length!==0)return n.join(`, `)}function yt(e){let t=e?.map(e=>e.trim()).filter(Boolean)??[];if(t.length===0)return;let{shown:n,remaining:r}=bt(t,t.length,1),[i]=n;if(i)return r===0?i:`${i} (+${r} more)`}function bt(e,t,n){let r=e.slice(0,n);return{shown:r,remaining:Math.max(t-r.length,0)}}function xt(e){let t=Q(e);if(!t)return null;let n=t.liveLocationMessage??void 0;if(n){let e=n.degreesLatitude,t=n.degreesLongitude;if(e!=null&&t!=null){let r=Number(e),i=Number(t);if(Number.isFinite(r)&&Number.isFinite(i))return{latitude:r,longitude:i,accuracy:n.accuracyInMeters??void 0,caption:n.caption??void 0,source:`live`,isLive:!0}}}let r=t.locationMessage??void 0;if(r){let e=r.degreesLatitude,t=r.degreesLongitude;if(e!=null&&t!=null){let n=Number(e),i=Number(t);if(Number.isFinite(n)&&Number.isFinite(i)){let e=!!r.isLive;return{latitude:n,longitude:i,accuracy:r.accuracyInMeters??void 0,name:r.name??void 0,address:r.address??void 0,caption:r.comment??void 0,source:e?`live`:r.name||r.address?`place`:`pin`,isLive:e}}}}return null}function St(e){let t=Q(e);if(!t)return null;let n=ut(t),r=Je(n?.quotedMessage);if(!r)return null;let i=xt(r),a=i?Me(i):void 0,o=[ft(r),a].filter(Boolean).join(`
|
|
2
2
|
`).trim();if(o||=pt(r),!o){let e=r?Ke(r):void 0;return G(`Quoted message missing extractable body${e?` (type ${e})`:``}`),null}let s=n?.participant??void 0,c=s?K(s)??s:void 0,l=c??`unknown sender`;return{id:n?.stanzaId?String(n.stanzaId):void 0,body:o,sender:l,senderJid:s,senderE164:c}}function Ct(e){return Se({providerConfigPresent:e.providerConfigPresent,groupPolicy:e.groupPolicy,defaultGroupPolicy:e.defaultGroupPolicy})}async function wt(e){let t=v(),n=_({cfg:t,accountId:e.accountId}),r=n.dmPolicy??`pairing`,i=n.allowFrom??[],a=await z({provider:`whatsapp`,accountId:n.accountId,dmPolicy:r}),o=i.length===0&&e.selfE164?[e.selfE164]:[],s=i.length>0?i:o,c=n.groupAllowFrom??(i.length>0?i:void 0),l=e.from===e.selfE164,u=n.selfChatMode??ye(e.selfE164,i),d=typeof e.pairingGraceMs==`number`&&e.pairingGraceMs>0?e.pairingGraceMs:3e4,f=typeof e.connectedAtMs==`number`&&typeof e.messageTimestampMs==`number`&&e.messageTimestampMs<e.connectedAtMs-d,p=xe(t),{groupPolicy:m,providerMissingFallbackApplied:h}=Ct({providerConfigPresent:t.channels?.whatsapp!==void 0,groupPolicy:n.groupPolicy,defaultGroupPolicy:p});be({providerMissingFallbackApplied:h,providerKey:`whatsapp`,accountId:n.accountId,log:e=>G(e)});let g=V(e.from),y=typeof e.senderE164==`string`?V(e.senderE164):null,b=O({isGroup:e.group,dmPolicy:r,groupPolicy:m,allowFrom:e.group?i:s,groupAllowFrom:c,storeAllowFrom:a,isSenderAllowed:t=>{if(t.includes(`*`))return!0;let n=new Set(t.map(e=>V(String(e))).filter(e=>!!e));return!e.group&&l?!0:e.group?!!(y&&n.has(y)):n.has(g)}});if(e.group&&b.decision!==`allow`)return b.reason===`groupPolicy=disabled`?G(`Blocked group message (groupPolicy: disabled)`):b.reason===`groupPolicy=allowlist (empty allowlist)`?G(`Blocked group message (groupPolicy: allowlist, no groupAllowFrom)`):G(`Blocked group message from ${e.senderE164??`unknown sender`} (groupPolicy: allowlist)`),{allowed:!1,shouldMarkRead:!1,isSelfChat:u,resolvedAccountId:n.accountId};if(!e.group){if(e.isFromMe&&!l)return G(`Skipping outbound DM (fromMe); no pairing reply needed.`),{allowed:!1,shouldMarkRead:!1,isSelfChat:u,resolvedAccountId:n.accountId};if(b.decision===`block`&&b.reason===`dmPolicy=disabled`)return G(`Blocked dm (dmPolicy: disabled)`),{allowed:!1,shouldMarkRead:!1,isSelfChat:u,resolvedAccountId:n.accountId};if(b.decision===`pairing`&&!l){let t=e.from;return f?G(`Skipping pairing reply for historical DM from ${t}.`):await le({channel:`whatsapp`,senderId:t,senderIdLine:`Your WhatsApp phone number: ${t}`,meta:{name:(e.pushName??``).trim()||void 0},upsertPairingRequest:async({id:e,meta:t})=>await Pe({channel:`whatsapp`,id:e,accountId:n.accountId,meta:t}),onCreated:()=>{G(`whatsapp pairing request sender=${t} name=${e.pushName??`unknown`}`)},sendPairingReply:async t=>{await e.sock.sendMessage(e.remoteJid,{text:t})},onReplyError:e=>{G(`whatsapp pairing reply failed for ${t}: ${String(e)}`)}}),{allowed:!1,shouldMarkRead:!1,isSelfChat:u,resolvedAccountId:n.accountId}}if(b.decision!==`allow`)return G(`Blocked unauthorized sender ${e.from} (dmPolicy=${r})`),{allowed:!1,shouldMarkRead:!1,isSelfChat:u,resolvedAccountId:n.accountId}}return{allowed:!0,shouldMarkRead:!0,isSelfChat:u,resolvedAccountId:n.accountId}}function Tt(e){return Je(e)}function Et(e){let t=e.imageMessage?.mimetype??e.videoMessage?.mimetype??e.documentMessage?.mimetype??e.audioMessage?.mimetype??e.stickerMessage?.mimetype??void 0;if(t)return t;if(e.audioMessage)return`audio/ogg; codecs=opus`;if(e.imageMessage)return`image/jpeg`;if(e.videoMessage)return`video/mp4`;if(e.stickerMessage)return`image/webp`}async function Dt(e,t){let n=Tt(e.message);if(!n)return;let r=Et(n),i=n.documentMessage?.fileName??void 0;if(!(!n.imageMessage&&!n.videoMessage&&!n.documentMessage&&!n.audioMessage&&!n.stickerMessage))try{return{buffer:await We(e,`buffer`,{},{reuploadRequest:t.updateMediaMessage,logger:t.logger}),mimetype:r,fileName:i}}catch(e){G(`downloadMediaMessage failed: ${String(e)}`);return}}function Ot(e){Ce({channel:`whatsapp`,accountId:e,direction:`outbound`})}function kt(e){return typeof e==`object`&&e&&`key`in e?String(e.key?.id??`unknown`):`unknown`}function At(e){return{sendMessage:async(t,n,r,i,a)=>{let o=W(t),s;if(r&&i)if(i.startsWith(`image/`))s={image:r,caption:n||void 0,mimetype:i};else if(i.startsWith(`audio/`))s={audio:r,ptt:!0,mimetype:i};else if(i.startsWith(`video/`)){let e=a?.gifPlayback;s={video:r,caption:n||void 0,mimetype:i,...e?{gifPlayback:!0}:{}}}else s={document:r,fileName:a?.fileName?.trim()||`file`,caption:n||void 0,mimetype:i};else s={text:n};let c=await e.sock.sendMessage(o,s);return Ot(a?.accountId??e.defaultAccountId),{messageId:kt(c)}},sendPoll:async(t,n)=>{let r=W(t),i=await e.sock.sendMessage(r,{poll:{name:n.question,values:n.options,selectableCount:n.maxSelections??1}});return Ot(e.defaultAccountId),{messageId:kt(i)}},sendReaction:async(t,n,r,i,a)=>{let o=W(t);await e.sock.sendMessage(o,{react:{text:r,key:{remoteJid:o,id:n,fromMe:i,participant:a?W(a):void 0}}})},sendComposingTo:async t=>{let n=W(t);await e.sock.sendPresenceUpdate(`composing`,n)}}}async function jt(e){let t=U({module:`web-inbound`}),n=he(`gateway/channels/whatsapp`).child(`inbound`),r=await Ve(!1,e.verbose,{authDir:e.authDir});await ze(r);let i=Date.now(),a=null,o=new Promise(e=>{a=e}),s=e=>{if(!a)return;let t=a;a=null,t(e)};try{await r.sendPresenceUpdate(`available`),B()&&G(`Sent global 'available' presence on connect`)}catch(e){G(`Failed to send 'available' presence on connect: ${String(e)}`)}let c=r.user?.id,l=c?K(c):null,u=k({debounceMs:e.debounceMs??0,buildKey:e=>{let t=e.chatType===`group`?e.senderJid??e.senderE164??e.senderName??e.from:e.from;if(!t)return null;let n=e.chatType===`group`?e.chatId:e.from;return`${e.accountId}:${n}:${t}`},shouldDebounce:e.shouldDebounce,onFlush:async t=>{let n=t.at(-1);if(!n)return;if(t.length===1){await e.onMessage(n);return}let r=new Set;for(let e of t)for(let t of e.mentionedJids??[])r.add(t);let i=t.map(e=>e.body).filter(Boolean).join(`
|
|
3
3
|
`),a={...n,body:i,mentionedJids:r.size>0?Array.from(r):void 0};await e.onMessage(a)},onError:e=>{t.error({error:String(e)},`failed handling inbound web message`),n.error(`Failed handling inbound web message: ${String(e)}`)}}),d=new Map,f=300*1e3,p=r.signalRepository?.lidMapping,m=async t=>H(t,{authDir:e.authDir,lidLookup:p}),h=async e=>{let t=d.get(e);if(t&&t.expires>Date.now())return t;try{let t=await r.groupMetadata(e),n=(await Promise.all(t.participants?.map(async e=>await m(e.id)??e.id)??[])).filter(Boolean)??[],i={subject:t.subject,participants:n,expires:Date.now()+f};return d.set(e,i),i}catch(t){return G(`Failed to fetch group metadata for ${e}: ${String(t)}`),{expires:Date.now()+f}}},_=async t=>{let n=t.key?.id??void 0,a=t.key?.remoteJid;if(!a||a.endsWith(`@status`)||a.endsWith(`@broadcast`))return null;let o=qe(a)===!0;if(n&&rt(`${e.accountId}:${a}:${n}`))return null;let s=t.key?.participant??void 0,c=o?a:await m(a);if(!c)return null;let u=o?s?await m(s):null:c,d,f;if(o){let e=await h(a);d=e.subject,f=e.participants}let p=t.messageTimestamp?Number(t.messageTimestamp)*1e3:void 0,g=await wt({accountId:e.accountId,from:c,selfE164:l,senderE164:u,group:o,pushName:t.pushName??void 0,isFromMe:!!t.key?.fromMe,messageTimestampMs:p,connectedAtMs:i,sock:{sendMessage:(e,t)=>r.sendMessage(e,t)},remoteJid:a});return g.allowed?{id:n,remoteJid:a,group:o,participantJid:s,from:c,senderE164:u,groupSubject:d,groupParticipants:f,messageTimestampMs:p,access:g}:null},v=async t=>{let{id:n,remoteJid:i,participantJid:a,access:o}=t;if(n&&!o.isSelfChat&&e.sendReadReceipts!==!1)try{await r.readMessages([{remoteJid:i,id:n,participant:a,fromMe:!1}]),B()&&G(`Marked message ${n} as read for ${i}${a?` (participant ${a})`:``}`)}catch(e){G(`Failed to mark message ${n} read: ${String(e)}`)}else n&&o.isSelfChat&&B()&&G(`Self-chat mode: skipping read receipt for ${n}`)},y=async t=>{let n=xt(t.message??void 0),i=n?Me(n):void 0,a=ft(t.message??void 0);if(i&&(a=[a,i].filter(Boolean).join(`
|
|
4
4
|
`).trim()),!a&&(a=pt(t.message??void 0),!a))return null;let o=St(t.message),s,c,l;try{let n=await Dt(t,r);if(n){let t=(typeof e.mediaMaxMb==`number`&&e.mediaMaxMb>0?e.mediaMaxMb:50)*1024*1024;s=(await g(n.buffer,n.mimetype,`inbound`,t,n.fileName)).path,c=n.mimetype,l=n.fileName}}catch(e){G(`Inbound media download failed: ${String(e)}`)}return{body:a,location:n??void 0,replyContext:o,mediaPath:s,mediaType:c,mediaFileName:l}},b=async(e,i,a)=>{let o=i.remoteJid,s=async()=>{try{await r.sendPresenceUpdate(`composing`,o)}catch(e){G(`Presence update failed: ${String(e)}`)}},d=async e=>{await r.sendMessage(o,{text:e})},f=async e=>{await r.sendMessage(o,e)},p=i.messageTimestampMs,m=dt(e.message),h=e.pushName??void 0;t.info({from:i.from,to:l??`me`,body:a.body,mediaPath:a.mediaPath,mediaType:a.mediaType,mediaFileName:a.mediaFileName,timestamp:p},`inbound message`);let g={id:i.id,from:i.from,conversationId:i.from,to:l??`me`,accountId:i.access.resolvedAccountId,body:a.body,pushName:h,timestamp:p,chatType:i.group?`group`:`direct`,chatId:i.remoteJid,senderJid:i.participantJid,senderE164:i.senderE164??void 0,senderName:h,replyToId:a.replyContext?.id,replyToBody:a.replyContext?.body,replyToSender:a.replyContext?.sender,replyToSenderJid:a.replyContext?.senderJid,replyToSenderE164:a.replyContext?.senderE164,groupSubject:i.groupSubject,groupParticipants:i.groupParticipants,mentionedJids:m??void 0,selfJid:c,selfE164:l,fromMe:!!e.key?.fromMe,location:a.location??void 0,sendComposing:s,reply:d,sendMedia:f,mediaPath:a.mediaPath,mediaType:a.mediaType,mediaFileName:a.mediaFileName};try{Promise.resolve(u.enqueue(g)).catch(e=>{t.error({error:String(e)},`failed handling inbound web message`),n.error(`Failed handling inbound web message: ${String(e)}`)})}catch(e){t.error({error:String(e)},`failed handling inbound web message`),n.error(`Failed handling inbound web message: ${String(e)}`)}},x=async t=>{if(!(t.type!==`notify`&&t.type!==`append`))for(let n of t.messages??[]){Ce({channel:`whatsapp`,accountId:e.accountId,direction:`inbound`});let r=await _(n);if(!r||(await v(r),t.type===`append`))continue;let i=await y(n);i&&await b(n,r,i)}};r.ev.on(`messages.upsert`,x);let S=e=>{try{if(e.connection===`close`){let t=Be(e.lastDisconnect?.error);s({status:t,isLoggedOut:t===Ue.loggedOut,error:e.lastDisconnect?.error})}}catch(e){t.error({error:String(e)},`connection.update handler error`),s({status:void 0,isLoggedOut:!1,error:e})}};return r.ev.on(`connection.update`,S),{close:async()=>{try{let e=r.ev,t=x,n=S;typeof e.off==`function`?(e.off(`messages.upsert`,t),e.off(`connection.update`,n)):typeof e.removeListener==`function`&&(e.removeListener(`messages.upsert`,t),e.removeListener(`connection.update`,n)),r.ws?.close()}catch(e){G(`Socket close failed: ${String(e)}`)}},onClose:o,signalClose:e=>{s(e??{status:void 0,isLoggedOut:!1,error:`closed`})},...At({sock:{sendMessage:(e,t)=>r.sendMessage(e,t),sendPresenceUpdate:(e,t)=>r.sendPresenceUpdate(e,t)},defaultAccountId:e.accountId})}}function Mt(e,t){return{mentionRegexes:pe(e,t),allowFrom:e.channels?.whatsapp?.allowFrom}}function Nt(e,t){let n=t?{authDir:t}:void 0;return{normalizedMentions:e.mentionedJids?.length?e.mentionedJids.map(e=>K(e,n)??e).filter(Boolean):[],selfE164:e.selfE164??(e.selfJid?K(e.selfJid,n):null),selfJid:e.selfJid?e.selfJid.replace(/:\\d+/,``):null}}function Pt(e,t,n){let r=e=>F(e),i=ye(n.selfE164,t.allowFrom);if((e.mentionedJids?.length??0)>0&&!i)return!!(n.selfE164&&n.normalizedMentions.includes(n.selfE164)||n.selfJid&&n.normalizedMentions.includes(n.selfJid));let a=r(e.body);if(t.mentionRegexes.some(e=>e.test(a)))return!0;if(n.selfE164){let t=n.selfE164.replace(/\D/g,``);if(t){if(a.replace(/[^\d]/g,``).includes(t))return!0;let n=e.body.replace(/[\s-]/g,``);if(RegExp(`\\+?${t}`,`i`).test(n))return!0}}return!1}function Ft(e,t,n){let r=Nt(e,n);return{wasMentioned:Pt(e,t,r),details:{from:e.from,body:e.body,bodyClean:F(e.body),mentionedJids:e.mentionedJids??null,normalizedMentionedJids:r.normalizedMentions.length?r.normalizedMentions:null,selfJid:e.selfJid??null,selfJidBare:r.selfJid,selfE164:e.selfE164??null,resolvedSelfE164:r.selfE164}}}function It(e,t){let n=e.allowFrom;return(Array.isArray(n)&&n.length>0?n:t?[t]:[]).filter(e=>!!(e&&e!==`*`)).map(e=>V(e)).filter(e=>!!e)}function Lt(e){let t=new Set,n=Math.max(1,e.maxItems??100),r=e=>`combined:${e.sessionKey}:${e.combinedBody}`,i=()=>{for(;t.size>n;){let e=t.values().next().value;if(!e)break;t.delete(e)}};return{rememberText:(n,a)=>{n&&(t.add(n),a.combinedBody&&a.combinedBodySessionKey&&t.add(r({sessionKey:a.combinedBodySessionKey,combinedBody:a.combinedBody})),a.logVerboseMessage&&e.logVerbose?.(`Added to echo detection set (size now: ${t.size}): ${n.substring(0,50)}...`),i())},has:e=>t.has(e),forget:e=>{t.delete(e)},buildCombinedKey:r}}function Rt(e){let n=j({agentId:e.agentId,channel:`whatsapp`,accountId:e.route.accountId,peer:{kind:e.msg.chatType===`group`?`group`:`direct`,id:e.peerId},dmScope:e.cfg.session?.dmScope,identityLinks:e.cfg.session?.identityLinks}),r=t({agentId:e.agentId,mainKey:i});return{sessionKey:n,mainSessionKey:r,lastRoutePolicy:me({sessionKey:n,mainSessionKey:r})}}async function zt(t){let n=t.cfg.broadcast?.[t.peerId];if(!n||!Array.isArray(n)||n.length===0)return!1;let r=t.cfg.broadcast?.strategy||`parallel`;X.info(`Broadcasting message to ${n.length} agents (${r})`);let i=t.cfg.agents?.list?.map(t=>e(t.id)),a=(i?.length??0)>0,o=t.msg.chatType===`group`?t.groupHistories.get(t.groupHistoryKey)??[]:void 0,s=async n=>{let r=e(n);if(a&&!i?.includes(r))return X.warn(`Broadcast agent ${n} not found in agents.list; skipping`),!1;let s=Rt({cfg:t.cfg,msg:t.msg,route:t.route,peerId:t.peerId,agentId:r}),c={...t.route,agentId:r,...s};try{return await t.processMessage(t.msg,c,t.groupHistoryKey,{groupHistory:o,suppressGroupHistoryClear:!0})}catch(e){return X.error(`Broadcast agent ${n} failed: ${q(e)}`),!1}};if(r===`sequential`)for(let e of n)await s(e);else await Promise.allSettled(n.map(s));return t.msg.chatType===`group`&&t.groupHistories.set(t.groupHistoryKey,[]),!0}function Bt(e,t,n){let r=e;for(let e of t)r=r.replace(e,` `);if(n){let e=n.replace(/\D/g,``);if(e){let t=RegExp(`\\+?${e}`,`g`);r=r.replace(t,` `)}}return r.replace(/\s+/g,` `).trim()}function Vt(e,t){let n=p({From:t,ChatType:`group`,Provider:`whatsapp`})?.id,r=e.channels?.whatsapp,i=!!(r?.groupAllowFrom?.length||r?.allowFrom?.length);return l({cfg:e,channel:`whatsapp`,groupId:n??t,hasGroupAllowFrom:i})}function Ht(e,t){let n=p({From:t,ChatType:`group`,Provider:`whatsapp`})?.id;return u({cfg:e,channel:`whatsapp`,groupId:n??t})}function Ut(e){let t=f(a(e.cfg.session?.store,{agentId:e.agentId}))[e.sessionKey],n=Ht(e.cfg,e.conversationId)?`mention`:`always`;return fe(t?.groupActivation)??n}function Wt(e,t,n){for(let r of e){let e=V(r)??r;!e||t.has(e)||(t.add(e),n.push(e))}}function Gt(e,t,n,r){if(!n||!r)return;let i=V(n)??n;if(!i)return;let a=e.get(t);a||(a=new Map,e.set(t,a)),a.set(i,r)}function Kt(e){let{participants:t,roster:n,fallbackE164:r}=e,i=new Set,a=[];if(t?.length&&Wt(t,i,a),n&&Wt(n.keys(),i,a),a.length===0&&r){let e=V(r)??r;e&&a.push(e)}if(a.length!==0)return a.map(e=>{let t=n?.get(e);return t?`${t} (${e})`:e}).join(`, `)}function qt(e,t){let n=V(t.senderE164??``);return n?It(e,t.selfE164??void 0).includes(n):!1}function Jt(e){let t=e.msg.senderName&&e.msg.senderE164?`${e.msg.senderName} (${e.msg.senderE164})`:e.msg.senderName??e.msg.senderE164??`Unknown`;w({historyMap:e.groupHistories,historyKey:e.groupHistoryKey,limit:e.groupHistoryLimit,entry:{sender:t,body:e.msg.body,timestamp:e.msg.timestamp,id:e.msg.id,senderJid:e.msg.senderJid}})}function Yt(e,t){return e.logVerbose(t),Jt({msg:e.msg,groupHistories:e.groupHistories,groupHistoryKey:e.groupHistoryKey,groupHistoryLimit:e.groupHistoryLimit}),{shouldProcess:!1}}function Xt(e){let t=Vt(e.cfg,e.conversationId);if(t.allowlistEnabled&&!t.allowed)return e.logVerbose(`Skipping group message ${e.conversationId} (not in allowlist)`),{shouldProcess:!1};Gt(e.groupMemberNames,e.groupHistoryKey,e.msg.senderE164,e.msg.senderName);let n=Mt(e.cfg,e.agentId),r=Bt(e.msg.body,n.mentionRegexes,e.msg.selfE164),i=M(r),a=qt(e.baseMentionConfig,e.msg),o=a&&b(r,e.cfg);if(i.hasCommand&&!a)return Yt(e,`Ignoring /activation from non-owner in group ${e.conversationId}`);let s=Ft(e.msg,n,e.authDir);e.replyLogger.debug({conversationId:e.conversationId,wasMentioned:s.wasMentioned,...s.details},`group mention debug`);let c=s.wasMentioned,l=Ut({cfg:e.cfg,agentId:e.agentId,sessionKey:e.sessionKey,conversationId:e.conversationId})!==`always`,u=e.msg.selfJid?.replace(/:\\d+/,``),d=e.msg.replyToSenderJid?.replace(/:\\d+/,``),f=e.msg.selfE164?V(e.msg.selfE164):null,p=e.msg.replyToSenderE164?V(e.msg.replyToSenderE164):null,m=S({requireMention:l,canDetectMention:!0,wasMentioned:c,implicitMention:!!(u&&d&&u===d||f&&p&&f===p),shouldBypassMention:o});return e.msg.wasMentioned=m.effectiveWasMentioned,!o&&l&&m.shouldSkip?Yt(e,`Group message stored for context (no mention detected) in ${e.conversationId}: ${e.msg.body}`):{shouldProcess:!0}}function Zt(e,t){e.add(t),t.finally(()=>{e.delete(t)})}function Qt(e){let t=a(e.cfg.session?.store,{agentId:e.storeAgentId}),n=d({storePath:t,sessionKey:e.sessionKey,deliveryContext:{channel:e.channel,to:e.to,accountId:e.accountId},ctx:e.ctx}).catch(n=>{e.warn({error:q(n),storePath:t,sessionKey:e.sessionKey,to:e.to},`failed updating last route`)});Zt(e.backgroundTasks,n)}function $t(e){return e.chatType===`group`?e.conversationId??e.from:e.senderE164?V(e.senderE164)??e.senderE164:e.from.includes(`@`)?K(e.from)??e.from:V(e.from)??e.from}function $(e,t=400){return!e||e.length<=t?e:`${e.slice(0,t)}… (truncated ${e.length-t} chars)`}function en(e){let t=(e instanceof Error?`${e.message}\n${e.stack??``}`:(e=>{if(e==null)return``;if(typeof e==`string`)return e;if(e instanceof Error)return`${e.message}\n${e.stack??``}`;if(typeof e==`object`)try{return JSON.stringify(e)}catch{return Object.prototype.toString.call(e)}return typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`?String(e):typeof e==`symbol`?e.description??e.toString():typeof e==`function`?e.name?`[function ${e.name}]`:`[function]`:Object.prototype.toString.call(e)})(e)).toLowerCase();return t.includes(`unsupported state or unable to authenticate data`)||t.includes(`bad mac`)?t.includes(`@whiskeysockets/baileys`)||t.includes(`baileys`)||t.includes(`noise-handler`)||t.includes(`aesdecryptgcm`):!1}function tn(e){if(e.isReasoning===!0)return!0;let t=e.text;return typeof t==`string`?t.trimStart().toLowerCase().startsWith(`reasoning:`):!1}async function nn(e){let{replyResult:t,msg:n,maxMediaBytes:r,textLimit:i,replyLogger:a,connectionId:o,skipLog:s}=e,c=Date.now();if(tn(t)){Z.debug(`Suppressed reasoning payload to ${n.from}`);return}let l=e.tableMode??`code`,u=e.chunkMode??`length`,d=Te(Le(Ae(t.text||``,l)),i,u),f=t.mediaUrls?.length?t.mediaUrls:t.mediaUrl?[t.mediaUrl]:[],p=async(e,t,r=3)=>{let i;for(let a=1;a<=r;a++)try{return await e()}catch(e){i=e;let o=q(e),s=a===r;if(!/closed|reset|timed\s*out|disconnect/i.test(o)||s)throw e;let c=500*a;G(`Retrying ${t} to ${n.from} after failure (${a}/${r-1}) in ${c}ms: ${o}`),await ge(c)}throw i};if(f.length===0&&d.length){let e=d.length;for(let[t,r]of d.entries()){let i=Date.now();if(await p(()=>n.reply(r),`text`),!s){let r=Date.now()-i;Z.debug(`Sent chunk ${t+1}/${e} to ${n.from} (${r.toFixed(0)}ms)`)}}a.info({correlationId:n.id??J(),connectionId:o??null,to:n.from,from:n.to,text:$(t.text,240),mediaUrl:null,mediaSizeBytes:null,mediaKind:null,durationMs:Date.now()-c},`auto-reply sent (text)`);return}let m=[...d];for(let[t,i]of f.entries()){let s=t===0&&m.shift()||void 0;try{let t=await ke(i,{maxBytes:r,localRoots:e.mediaLocalRoots});if(B()&&(G(`Web auto-reply media size: ${(t.buffer.length/(1024*1024)).toFixed(2)}MB`),G(`Web auto-reply media source: ${i} (kind ${t.kind})`)),t.kind===`image`)await p(()=>n.sendMedia({image:t.buffer,caption:s,mimetype:t.contentType}),`media:image`);else if(t.kind===`audio`)await p(()=>n.sendMedia({audio:t.buffer,ptt:!0,mimetype:t.contentType,caption:s}),`media:audio`);else if(t.kind===`video`)await p(()=>n.sendMedia({video:t.buffer,caption:s,mimetype:t.contentType}),`media:video`);else{let e=t.fileName??i.split(`/`).pop()??`file`,r=t.contentType??`application/octet-stream`;await p(()=>n.sendMedia({document:t.buffer,fileName:e,caption:s,mimetype:r}),`media:document`)}Z.info(`Sent media reply to ${n.from} (${(t.buffer.length/(1024*1024)).toFixed(2)}MB)`),a.info({correlationId:n.id??J(),connectionId:o??null,to:n.from,from:n.to,text:s??null,mediaUrl:i,mediaSizeBytes:t.buffer.length,mediaKind:t.kind,durationMs:Date.now()-c},`auto-reply sent (media)`)}catch(e){if(Z.error(`Failed sending web media to ${n.from}: ${q(e)}`),a.warn({err:e,mediaUrl:i},`failed to send web media reply`),t===0){let t=e instanceof Error?`⚠️ Media failed: ${e.message}`:`⚠️ Media failed.`,r=[m.shift()??s??``,t].filter(Boolean).join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./paths-CSbOOCsu.js";import"./config-B-UcenbQ.js";import{rt as e}from"./dispatch-
|
|
1
|
+
import"./paths-CSbOOCsu.js";import"./config-B-UcenbQ.js";import{rt as e}from"./dispatch-DzdnDix3.js";import"./paths-BZu7pylC.js";import"./github-copilot-token-CZKe5l5K.js";import"./logger-C9qBS3pT.js";import"./proxy-env-CPkJIzpH.js";import"./send-Cm3DUp7B.js";import"./fetch-DBRI0sKI.js";import"./channel-activity-BmtBYQiY.js";import"./fetch-guard-DFkrvefb.js";import"./local-roots-CJmQubXD.js";import"./ir-CtV16xaT.js";import"./render-DGmfCIRG.js";import"./tables-BSCz74OW.js";import"./send-BZLHNxgv.js";import"./target-errors-IUyUVvTY.js";import"./send-DEXJLpyz.js";import"./deliver-C_gmqump.js";import"./diagnostic-BjNsv_MZ.js";import"./pi-model-discovery-KbgCHo1f.js";import"./audio-transcription-runner-CDEClJ7w.js";import"./image-Bkivxhr_.js";import"./api-key-rotation-C2RTMqbG.js";import"./proxy-fetch-zQZYbMVb.js";import"./tokens-BzJXWHOV.js";import"./commands-registry-DueC2CXY.js";import"./send-NZQ7cj5i.js";import"./outbound-attachment-Diu_o1ga.js";import"./send-_fKv95OZ.js";import"./sqlite-9K32c8mU.js";import"./fetch-DMcdYoAa.js";import"./skill-commands-B06QVSkm.js";import"./manager-DDgXS0Q8.js";export{e as compactEmbeddedPiSessionDirect};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./paths-Ck_GIp7q.js";import"./utils-CfTrvEp0.js";import"./paths-D_Oppcui.js";import"./model-auth-BJBZCtjT.js";import"./target-errors-BOqeJ_3F.js";import{k as e}from"./dispatch
|
|
1
|
+
import"./paths-Ck_GIp7q.js";import"./utils-CfTrvEp0.js";import"./paths-D_Oppcui.js";import"./model-auth-BJBZCtjT.js";import"./target-errors-BOqeJ_3F.js";import{k as e}from"./dispatch--4Vuy9oL.js";import"./send-CO2UHcEv.js";import"./send-DE5nZ2st.js";import"./proxy-env-BnKSJOGR.js";import"./github-copilot-token-DmcuLuc7.js";import"./send-BUrpCp2y.js";import"./fetch-guard-BSsJgDhB.js";import"./deliver-VMHoHBzn.js";import"./diagnostic-DVzH_MLb.js";import"./pi-model-discovery-Db7ABtcq.js";import"./audio-transcription-runner-DhJf4m1B.js";import"./image-D2kjZFi6.js";import"./api-key-rotation-CDbYWBVm.js";import"./local-roots-BH5tSQLl.js";import"./proxy-fetch-o_y6bhRh.js";import"./tokens-Bh7fgb-2.js";import"./commands-registry-CqcYbN0q.js";import"./ir-BtYOx2uz.js";import"./render-DhTJXP1U.js";import"./send-B31irjnU.js";import"./outbound-attachment-Fq-8ay7E.js";import"./fetch-p43DsBwY.js";import"./send-ITDY5IkL.js";import"./sqlite-DcxSH4wB.js";import"./channel-activity-Dka0S6Hm.js";import"./tables-B-mnbiT0.js";import"./fetch-BmdDzZ-O.js";import"./skill-commands-B75FKFYa.js";import"./manager-uBkiNkiS.js";export{e as compactEmbeddedPiSessionDirect};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{D as e}from"./dispatch-
|
|
1
|
+
import{D as e}from"./dispatch-_3aPMKVc.js";import"./paths-BMI3JiOI.js";import"./model-auth-BbZAgf5F.js";import"./logger-D7NYTfYR.js";import"./paths-DumT91r9.js";import"./proxy-env-Bz2Z8zYd.js";import"./github-copilot-token-B-n-jIjX.js";import"./send-CbKUBgfD.js";import"./send-BRcOy7d-.js";import"./send-wZQahIxo.js";import"./deliver-BOhWRuAc.js";import"./diagnostic-DVLBFxSl.js";import"./pi-model-discovery-DPml1ezH.js";import"./audio-transcription-runner-DnUZA3zd.js";import"./image-YjdiaYzj.js";import"./fetch-guard-Ddmjnr9q.js";import"./api-key-rotation-D5VrjOf1.js";import"./local-roots-D2BFeJX5.js";import"./proxy-fetch-nA0PxLDm.js";import"./tokens-CSkDa5HP.js";import"./commands-registry-BmTuvGJF.js";import"./ir-lBa1tN3e.js";import"./render-CC0AV0OP.js";import"./target-errors-D2mtlQc6.js";import"./send-DISaNhwJ.js";import"./outbound-attachment-C-WNUYRe.js";import"./fetch-C-3ngqxG.js";import"./send-B6p34YOy.js";import"./sqlite-C8QKImip.js";import"./channel-activity-CGpLziCG.js";import"./tables-7iwXnKB3.js";import"./fetch-D36SsL31.js";import"./skill-commands-Bv_AgJSD.js";import"./manager-BAawai7j.js";export{e as compactEmbeddedPiSessionDirect};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{E as e}from"./dispatch-
|
|
1
|
+
import{E as e}from"./dispatch-v8f5j6tA.js";import"./send-Bb-c2Wfw.js";import"./paths-DJeQBg0P.js";import"./model-auth-dsGPdWPW.js";import"./logger-DeJtHfIZ.js";import"./paths-BAheUa28.js";import"./proxy-env-B8lWNmLK.js";import"./github-copilot-token-Be6rNfqm.js";import"./send-B1GxVX6l.js";import"./fetch-guard-PzaEpcQ7.js";import"./send-CwkiYqPX.js";import"./deliver-BxZhcYJx.js";import"./diagnostic-BwtamUsr.js";import"./pi-model-discovery-CqWtTmQH.js";import"./audio-transcription-runner-aZJ9cNlA.js";import"./image-DD04cXIg.js";import"./api-key-rotation-CsGG9jhG.js";import"./local-roots-DUN2ttYv.js";import"./proxy-fetch--DcTyl5K.js";import"./tokens-_Nmie3Ug.js";import"./commands-registry-Dw8t__8o.js";import"./ir-DLYol2vv.js";import"./render-CC0AV0OP.js";import"./target-errors-BTSekDWl.js";import"./send-V3uD9QA4.js";import"./outbound-attachment-nlK2LbIg.js";import"./fetch-rIayI79w.js";import"./send-CRV-DPpI.js";import"./sqlite-DnpnF8rT.js";import"./channel-activity-Bco4vhqQ.js";import"./tables-CsIFrUA3.js";import"./fetch-B0zJKaR8.js";import"./skill-commands-BGdnhkBW.js";import"./manager-Bpp6SEQN.js";export{e as compactEmbeddedPiSessionDirect};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./paths-DHIowy7j.js";import"./paths-Ilv7GN3y.js";import"./logger-Bzsdb9ed.js";import"./model-auth-m6awkcmr.js";import"./proxy-env-CjA5va0Q.js";import"./send-CJGwOpaf.js";import"./send-DfKN3gPU.js";import{T as e}from"./dispatch-
|
|
1
|
+
import"./paths-DHIowy7j.js";import"./paths-Ilv7GN3y.js";import"./logger-Bzsdb9ed.js";import"./model-auth-m6awkcmr.js";import"./proxy-env-CjA5va0Q.js";import"./send-CJGwOpaf.js";import"./send-DfKN3gPU.js";import{T as e}from"./dispatch-DPafUBvi.js";import"./tokens-D-G23Eih.js";import"./deliver-Cr9WnblM.js";import"./github-copilot-token-DjID6pAD.js";import"./fetch-guard-Ch-GE1q6.js";import"./send-Jtkjjoez.js";import"./local-roots-cD4rtFUT.js";import"./ir-C9bnqCN4.js";import"./diagnostic-D_z4RTdJ.js";import"./pi-model-discovery-BoCQComb.js";import"./audio-transcription-runner-C-1wfN5V.js";import"./image-CswbRypx.js";import"./api-key-rotation-ByGrFLLf.js";import"./proxy-fetch-DLkHTNrK.js";import"./commands-registry-sdEAg35R.js";import"./render-CC0AV0OP.js";import"./target-errors-CBtuprlS.js";import"./send-DUpWCxkR.js";import"./outbound-attachment-nHeYVKR0.js";import"./fetch-p43DsBwY.js";import"./send-BvX-weT-.js";import"./sqlite-nOhwJUyO.js";import"./channel-activity-CrUKMrr9.js";import"./tables-tvhhES0m.js";import"./fetch-p-KNjCrj.js";import"./skill-commands-D3NahROf.js";import"./manager-B6qIRY7W.js";export{e as compactEmbeddedPiSessionDirect};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./paths-CB5IsdXc.js";import"./sessions-vCe4wPa1.js";import"./logger-CMRRf9cz.js";import"./paths-DhHYGQZt.js";import"./proxy-env-C-8R9SbI.js";import"./send-Dw9KZtdY.js";import"./common-CKZ-UdaB.js";import"./send-B6HPDK7K.js";import{P as e}from"./reply-
|
|
1
|
+
import"./paths-CB5IsdXc.js";import"./sessions-vCe4wPa1.js";import"./logger-CMRRf9cz.js";import"./paths-DhHYGQZt.js";import"./proxy-env-C-8R9SbI.js";import"./send-Dw9KZtdY.js";import"./common-CKZ-UdaB.js";import"./send-B6HPDK7K.js";import{P as e}from"./reply-FZOMaPdT.js";import"./github-copilot-token-C1rb4n4g.js";import"./send-bO2luPtA.js";import"./tokens-B_ctrNLr.js";import"./audio-transcription-runner-CZeLqyn8.js";import"./image-DCRZu6B9.js";import"./fetch-guard-CeY6FLmB.js";import"./api-key-rotation-C1Zn1KSQ.js";import"./local-roots-mIwSmMlz.js";import"./proxy-fetch-Z4EVQXTq.js";import"./deliver-BzC2TfhO.js";import"./commands-registry-BRHbSR-Q.js";import"./pi-model-discovery-DFcVdEXI.js";import"./ir-CmAyPA_x.js";import"./render-Djx15dPh.js";import"./diagnostic-BygIW7fL.js";import"./send-CuDJ-nVd.js";import"./outbound-attachment-vo_FJhnQ.js";import"./fetch-DmxjtY1D.js";import"./send-BPtLy3DR2.js";import"./sqlite-Dc2ZB7Ip.js";import"./channel-activity-CYknJxeB.js";import"./tables-BaKxrCzf.js";import"./fetch-C1uUpK5t.js";import"./skill-commands-DnImLYRw.js";import"./manager-Dnvt2fsN.js";export{e as compactEmbeddedPiSessionDirect};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Bt as e,E as t,L as n,Lt as r,O as i,Ut as a,Wt as o,_t as s,bt as c,c as l,d as u,f as d,h as f,k as p,l as m,m as ee,p as te,u as h,w as ne,yt as re}from"./paths-CSbOOCsu.js";import{$c as ie,$i as ae,$l as g,$t as oe,A as se,Aa as ce,Ai as le,Al as ue,B as de,Ba as fe,Bi as pe,Ca as me,Ci as he,Co as ge,Di as _e,Dl as ve,Do as ye,Ds as be,Ea as xe,Ei as Se,Eo as Ce,F as we,Fa as Te,Ga as Ee,Gi as De,Gl as _,H as Oe,Ha as ke,Hi as Ae,I as je,Ia as Me,Ja as Ne,Ji as Pe,Ka as Fe,Ki as Ie,Ks as Le,L as Re,La as ze,Lo as Be,M as Ve,Ma as v,Mi as He,Ml as Ue,Mo as We,N as Ge,Na as Ke,Nl as y,No as b,Oi as qe,Ol as Je,P as Ye,Pa as Xe,Qi as Ze,R as Qe,Ra as $e,Rs as et,Sa as tt,So as nt,Ta as x,Ti as rt,To as it,U as at,Ua as ot,Ui as st,Ul as ct,V as lt,Va as ut,Vc as dt,Vi as ft,Wi as pt,Wl as mt,Xi as ht,Xs as gt,Yi as _t,Ys as vt,Zi as yt,Zl as bt,Zs as xt,_ as St,_a as Ct,_l as wt,_o as Tt,as as Et,ba as Dt,bo as Ot,co as kt,d as At,da as jt,do as Mt,ea as Nt,eu as Pt,f as Ft,fo as It,g as Lt,go as Rt,h as zt,ho as Bt,is as Vt,j as Ht,ja as Ut,ji as Wt,k as Gt,ki as Kt,kl as qt,ko as Jt,ks as Yt,la as Xt,lo as Zt,m as Qt,mo as $t,mu as en,na as tn,nu as nn,oa as rn,os as an,p as on,po as sn,qa as cn,qi as ln,ra as un,ru as dn,sl as fn,ta as pn,tu as mn,ua as hn,uo as gn,v as _n,va as vn,vo as yn,wa as bn,wi as xn,wo as Sn,xa as Cn,xo as wn,yo as Tn,z as En,za as Dn,zo as On}from"./config-B-UcenbQ.js";import{$t as kn,A as An,At as jn,B as Mn,Bt as Nn,C as Pn,Cn as Fn,D as In,Dt as Ln,Et as Rn,F as zn,Ft as Bn,G as Vn,H as Hn,Ht as Un,It as Wn,J as Gn,Jt as Kn,K as qn,Kt as Jn,L as Yn,Lt as Xn,M as Zn,Mt as Qn,N as $n,O as er,Ot as tr,P as nr,Pt as rr,Qt as ir,R as ar,Rt as or,S as sr,Sn as cr,T as lr,Tt as ur,U as dr,Ut as fr,V as pr,Vt as mr,W as hr,Wt as gr,Xt as _r,Yt as vr,Zt as yr,_ as br,_n as xr,an as Sr,b as Cr,bn as wr,cn as Tr,dn as Er,dt as Dr,en as Or,f as S,fn as kr,ft as Ar,g as jr,gn as Mr,gt as Nr,h as Pr,hn as Fr,in as Ir,j as Lr,jt as Rr,k as zr,kt as Br,ln as Vr,lt as Hr,mn as Ur,n as Wr,nn as Gr,on as Kr,ot as qr,pn as Jr,pt as Yr,q as Xr,qt as C,rn as Zr,sn as Qr,t as $r,tn as w,un as ei,ut as ti,v as ni,vn as ri,w as ii,x as T,xn as ai,y as oi,yn as si,yt as ci,z as li,zt as ui}from"./dispatch-DABpoSJj.js";import"./paths-BZu7pylC.js";import"./github-copilot-token-CZKe5l5K.js";import{C as E,O as di,Q as fi,b as D,j as pi,m as mi,p as hi,q as gi,s as _i,v as vi,w as yi}from"./logger-C9qBS3pT.js";import{r as bi}from"./proxy-env-CPkJIzpH.js";import{At as xi,Bt as Si,Dt as Ci,Et as wi,Ft as Ti,Ht as Ei,It as Di,Mt as Oi,Nt as ki,Ot as Ai,Pt as ji,Tt as Mi,Ut as Ni,Vt as Pi,Wt as Fi,at as Ii,dt as Li,jt as Ri,kt as zi}from"./send-Cm3DUp7B.js";import"./fetch-DBRI0sKI.js";import"./channel-activity-BmtBYQiY.js";import{t as Bi}from"./fetch-guard-DFkrvefb.js";import"./local-roots-CJmQubXD.js";import{p as Vi,v as Hi}from"./ir-CtV16xaT.js";import"./render-DGmfCIRG.js";import"./tables-BSCz74OW.js";import{X as Ui,Y as Wi,it as Gi,rt as Ki}from"./send-BZLHNxgv.js";import{d as O,f as qi,h as k,l as Ji,n as Yi,o as Xi}from"./target-errors-IUyUVvTY.js";import{s as Zi}from"./send-DEXJLpyz.js";import{h as Qi}from"./deliver-C_gmqump.js";import{g as $i,h as ea,m as ta}from"./diagnostic-BjNsv_MZ.js";import"./pi-model-discovery-KbgCHo1f.js";import{d as na,f as ra}from"./audio-transcription-runner-CDEClJ7w.js";import"./image-Bkivxhr_.js";import"./api-key-rotation-C2RTMqbG.js";import"./proxy-fetch-zQZYbMVb.js";import{i as ia,n as aa}from"./tokens-BzJXWHOV.js";import"./commands-registry-DueC2CXY.js";import{n as oa,r as sa}from"./targets-CVEYTFPQ.js";import"./send-NZQ7cj5i.js";import"./outbound-attachment-Diu_o1ga.js";import{c as ca,d as la,f as ua,l as da,m as fa,o as pa,p as ma,u as ha}from"./send-_fKv95OZ.js";import"./sqlite-9K32c8mU.js";import{i as ga,n as _a,r as va}from"./fetch-DMcdYoAa.js";import{c as ya,l as ba,n as xa,o as Sa,s as Ca}from"./skill-commands-B06QVSkm.js";import"./manager-DDgXS0Q8.js";import{t as wa}from"./resolve-outbound-target-CTyYBRiK.js";import{r as Ta}from"./channel-web-C0hljM9U.js";import"./outbound-RGOrt1pb.js";import"./session-DfMpA14O.js";import{t as Ea}from"./login-CnJL85zg.js";import Da,{constants as A,createWriteStream as Oa}from"node:fs";import j from"node:path";import ka from"node:os";import M from"node:fs/promises";import{createHash as Aa,randomBytes as ja,randomUUID as Ma}from"node:crypto";import{format as Na}from"node:util";import{pipeline as Pa}from"node:stream/promises";import{request as Fa}from"node:https";import{z as N}from"zod";import{Readable as Ia,Transform as La}from"node:stream";import Ra from"jszip";import*as za from"tar";function Ba(e){return{success:!1,error:{issues:[{path:[],message:e}]}}}function Va(){return{safeParse(e){return e===void 0?{success:!0,data:void 0}:!e||typeof e!=`object`||Array.isArray(e)?Ba(`expected config object`):Object.keys(e).length>0?Ba(`config must be empty`):{success:!0,data:e}},jsonSchema:{type:`object`,additionalProperties:!1,properties:{}}}}function Ha(e){return e.map(e=>({input:e.input,resolved:e.resolved,id:e.id,name:e.name,note:e.note}))}async function Ua(e){let t=[];for(let n of e.inputs)t.push(await e.mapInput(n));return t}function Wa(e){return typeof e==`string`?e:e instanceof URL?e.toString():typeof e==`object`&&e&&`url`in e&&typeof e.url==`string`?e.url:``}function Ga(e){return{verbose:!1,replyTo:e.replyToId??void 0,accountId:e.accountId??void 0,silent:e.silent??void 0}}function Ka(e){return{...Ga(e),mediaUrl:e.mediaUrl,mediaLocalRoots:e.mediaLocalRoots}}function qa(e){return{channel:`discord`,...e}}function P(e){let t=e.trim();if(!t)return`/`;let n=t.startsWith(`/`)?t:`/${t}`;return n.length>1&&n.endsWith(`/`)?n.slice(0,-1):n}function Ja(e){let t=e.webhookPath?.trim();if(t)return P(t);if(e.webhookUrl?.trim())try{return P(new URL(e.webhookUrl).pathname||`/`)}catch{return null}return e.defaultPath??null}const Ya=Object.freeze({preAuth:{maxBytes:64*1024,timeoutMs:5e3},postAuth:{maxBytes:1024*1024,timeoutMs:3e4}}),Xa=Object.freeze({maxInFlightPerKey:8,maxTrackedKeys:4096});function Za(e){let t=e.profile===`pre-auth`?Ya.preAuth:Ya.postAuth;return{maxBytes:typeof e.maxBytes==`number`&&Number.isFinite(e.maxBytes)&&e.maxBytes>0?Math.floor(e.maxBytes):t.maxBytes,timeoutMs:typeof e.timeoutMs==`number`&&Number.isFinite(e.timeoutMs)&&e.timeoutMs>0?Math.floor(e.timeoutMs):t.timeoutMs}}function Qa(e){let{res:t,code:n,invalidMessage:r}=e;return n===`PAYLOAD_TOO_LARGE`?(t.statusCode=413,t.end(w(`PAYLOAD_TOO_LARGE`)),{ok:!1}):n===`REQUEST_BODY_TIMEOUT`?(t.statusCode=408,t.end(w(`REQUEST_BODY_TIMEOUT`)),{ok:!1}):n===`CONNECTION_CLOSED`?(t.statusCode=400,t.end(w(`CONNECTION_CLOSED`)),{ok:!1}):(t.statusCode=400,t.end(r??`Bad Request`),{ok:!1})}function $a(e){let t=Math.max(1,Math.floor(e?.maxInFlightPerKey??Xa.maxInFlightPerKey)),n=Math.max(1,Math.floor(e?.maxTrackedKeys??Xa.maxTrackedKeys)),r=new Map;return{tryAcquire:e=>{if(!e)return!0;let i=r.get(e)??0;return i>=t?!1:(r.set(e,i+1),C(r,n),!0)},release:e=>{if(!e)return;let t=r.get(e);if(t!==void 0){if(t<=1){r.delete(e);return}r.set(e,t-1)}},size:()=>r.size,clear:()=>r.clear()}}function eo(e){let t=Array.isArray(e)?e[0]:e;if(!t)return!1;let n=t.split(`;`,1)[0]?.trim().toLowerCase();return n===`application/json`||!!n?.endsWith(`+json`)}function to(e){let t=e.allowMethods?.length?e.allowMethods:null;return t&&!t.includes(e.req.method??``)?(e.res.statusCode=405,e.res.setHeader(`Allow`,t.join(`, `)),e.res.end(`Method Not Allowed`),!1):e.rateLimiter&&e.rateLimitKey&&e.rateLimiter.isRateLimited(e.rateLimitKey,e.nowMs??Date.now())?(e.res.statusCode=429,e.res.end(`Too Many Requests`),!1):e.requireJsonContentType&&e.req.method===`POST`&&!eo(e.req.headers[`content-type`])?(e.res.statusCode=415,e.res.end(`Unsupported Media Type`),!1):!0}function no(e){if(!to({req:e.req,res:e.res,allowMethods:e.allowMethods,rateLimiter:e.rateLimiter,rateLimitKey:e.rateLimitKey,nowMs:e.nowMs,requireJsonContentType:e.requireJsonContentType}))return{ok:!1};let t=e.inFlightKey??``,n=e.inFlightLimiter;if(n&&t&&!n.tryAcquire(t))return e.res.statusCode=e.inFlightLimitStatusCode??429,e.res.end(e.inFlightLimitMessage??`Too Many Requests`),{ok:!1};let r=!1;return{ok:!0,release:()=>{r||(r=!0,n&&t&&n.release(t))}}}async function ro(e){let t=Za({maxBytes:e.maxBytes,timeoutMs:e.timeoutMs,profile:e.profile});try{return{ok:!0,value:await Or(e.req,t)}}catch(t){return ir(t)?Qa({res:e.res,code:t.code,invalidMessage:e.invalidBodyMessage}):Qa({res:e.res,code:`INVALID_BODY`,invalidMessage:e.invalidBodyMessage??(t instanceof Error?t.message:String(t))})}}async function io(e){let t=Za({maxBytes:e.maxBytes,timeoutMs:e.timeoutMs,profile:e.profile}),n=await kn(e.req,{maxBytes:t.maxBytes,timeoutMs:t.timeoutMs,emptyObjectOnEmpty:e.emptyObjectOnEmpty});return n.ok?{ok:!0,value:n.value}:Qa({res:e.res,code:n.code,invalidMessage:e.invalidJsonMessage})}function ao(e){return co(e.targetsByPath,e.target,{onFirstPathTarget:({path:t})=>Sr({...e.route,path:t,replaceExisting:e.route.replaceExisting??!0}),onLastPathTargetRemoved:e.onLastPathTargetRemoved})}const oo=new WeakMap;function so(e){let t=e,n=oo.get(t);if(n)return n;let r=new Map;return oo.set(t,r),r}function co(e,t,n){let r=P(t.path),i={...t,path:r},a=e.get(r)??[];if(a.length===0){let t=n?.onFirstPathTarget?.({path:r,target:i});typeof t==`function`&&so(e).set(r,t)}e.set(r,[...a,i]);let o=!0;return{target:i,unregister:()=>{if(!o)return;o=!1;let t=(e.get(r)??[]).filter(e=>e!==i);if(t.length>0){e.set(r,t);return}e.delete(r);let a=so(e).get(r);a&&(so(e).delete(r),a()),n?.onLastPathTargetRemoved?.({path:r})}}}function lo(e,t){let n=P(new URL(e.url??`/`,`http://localhost`).pathname),r=t.get(n);return!r||r.length===0?null:{path:n,targets:r}}async function uo(e){let t=lo(e.req,e.targetsByPath);if(!t)return!1;let n=typeof e.inFlightKey==`function`?e.inFlightKey({req:e.req,path:t.path,targets:t.targets}):e.inFlightKey??`${t.path}:${e.req.socket?.remoteAddress??`unknown`}`,r=no({req:e.req,res:e.res,allowMethods:e.allowMethods,rateLimiter:e.rateLimiter,rateLimitKey:e.rateLimitKey,nowMs:e.nowMs,requireJsonContentType:e.requireJsonContentType,inFlightLimiter:e.inFlightLimiter,inFlightKey:n,inFlightLimitStatusCode:e.inFlightLimitStatusCode,inFlightLimitMessage:e.inFlightLimitMessage});if(!r.ok)return!0;try{return await e.handle(t),!0}finally{r.release()}}function fo(e,t){return e?{ok:!1,result:{kind:`ambiguous`}}:{ok:!0,matched:t}}function po(e){return e?{kind:`single`,target:e}:{kind:`none`}}function mo(e,t){let n;for(let r of e){if(!t(r))continue;let e=fo(n,r);if(!e.ok)return e.result;n=e.matched}return po(n)}async function ho(e,t){let n;for(let r of e){if(!await t(r))continue;let e=fo(n,r);if(!e.ok)return e.result;n=e.matched}return po(n)}async function go(e){return vo(e,await ho(e.targets,async t=>!!await e.isMatch(t)))}function _o(e){return vo(e,mo(e.targets,e.isMatch))}function vo(e,t){return t.kind===`single`?t.target:t.kind===`ambiguous`?(e.res.statusCode=e.ambiguousStatusCode??401,e.res.end(e.ambiguousMessage??`ambiguous webhook target`),null):(e.res.statusCode=e.unauthorizedStatusCode??401,e.res.end(e.unauthorizedMessage??`unauthorized`),null)}function yo(e,t){return e.method===`POST`?!1:(t.statusCode=405,t.setHeader(`Allow`,`POST`),t.end(`Method Not Allowed`),!0)}function bo(e){return t=>{e.setStatus({accountId:e.accountId,...t})}}function xo(e,t){return new Promise((n,r)=>{let i=()=>{Promise.resolve(t?.()).then(()=>n(),r)};if(e){if(e.aborted){i();return}e.addEventListener(`abort`,i,{once:!0})}})}async function So(e){let t=await e.start();try{await xo(e.abortSignal)}finally{await e.stop?.(t),await e.onStop?.()}}async function Co(e){let{server:t,abortSignal:n,onAbort:r}=e,i=Promise.resolve(),a=!1,o=()=>{a||(a=!0,i=Promise.resolve(r?.()).then(()=>void 0))},s=()=>{o()};n&&(n.aborted?o():n.addEventListener(`abort`,s,{once:!0})),await new Promise(e=>{t.once(`close`,()=>e())}),n&&n.removeEventListener(`abort`,s),await i}function wo(e){let t=e[0],n=e.map(e=>e.path),r=e.map(e=>e.contentType).filter(Boolean);return{MediaPath:t?.path,MediaType:t?.contentType??void 0,MediaUrl:t?.path,MediaPaths:n.length>0?n:void 0,MediaUrls:n.length>0?n:void 0,MediaTypes:r.length>0?r:void 0}}function To(e,t){return{accountId:e,running:!1,lastStartAt:null,lastStopAt:null,lastError:null,...t??{}}}function Eo(e){return{configured:e.configured??!1,running:e.running??!1,lastStartAt:e.lastStartAt??null,lastStopAt:e.lastStopAt??null,lastError:e.lastError??null}}function Do(e,t){return{...Eo(e),...t??{},probe:e.probe,lastProbeAt:e.lastProbeAt??null}}function Oo(e){let{account:t,runtime:n,probe:r}=e;return{accountId:t.accountId,name:t.name,enabled:t.enabled,configured:t.configured,...Ao({runtime:n,probe:r}),lastInboundAt:n?.lastInboundAt??null,lastOutboundAt:n?.lastOutboundAt??null}}function ko(e){let{accountId:t,name:n,enabled:r,configured:i,runtime:a,probe:o}=e;return Oo({account:{accountId:t,name:n,enabled:r,configured:i},runtime:a,probe:o})}function Ao(e){let{runtime:t,probe:n}=e;return{running:t?.running??!1,lastStartAt:t?.lastStartAt??null,lastStopAt:t?.lastStopAt??null,lastError:t?.lastError??null,probe:n}}function jo(e,t){let n={...Eo(e),tokenSource:e.tokenSource??`none`,probe:e.probe,lastProbeAt:e.lastProbeAt??null};return t?.includeMode===!1?n:{...n,mode:e.mode??null}}function Mo(e,t){return t.flatMap(t=>{let n=typeof t.lastError==`string`?t.lastError.trim():``;return n?[{channel:e,accountId:t.accountId,kind:`runtime`,message:`Channel error: ${n}`}]:[]})}const No={openai:[`OPENAI_API_KEY`],anthropic:[`ANTHROPIC_API_KEY`],google:[`GEMINI_API_KEY`],minimax:[`MINIMAX_API_KEY`],"minimax-cn":[`MINIMAX_API_KEY`],moonshot:[`MOONSHOT_API_KEY`],"kimi-coding":[`KIMI_API_KEY`,`KIMICODE_API_KEY`],synthetic:[`SYNTHETIC_API_KEY`],venice:[`VENICE_API_KEY`],zai:[`ZAI_API_KEY`,`Z_AI_API_KEY`],xiaomi:[`XIAOMI_API_KEY`],openrouter:[`OPENROUTER_API_KEY`],"cloudflare-ai-gateway":[`CLOUDFLARE_AI_GATEWAY_API_KEY`],litellm:[`LITELLM_API_KEY`],"vercel-ai-gateway":[`AI_GATEWAY_API_KEY`],opencode:[`OPENCODE_API_KEY`,`OPENCODE_ZEN_API_KEY`],"opencode-go":[`OPENCODE_API_KEY`,`OPENCODE_ZEN_API_KEY`],together:[`TOGETHER_API_KEY`],huggingface:[`HUGGINGFACE_HUB_TOKEN`,`HF_TOKEN`],qianfan:[`QIANFAN_API_KEY`],xai:[`XAI_API_KEY`],mistral:[`MISTRAL_API_KEY`],kilocode:[`KILOCODE_API_KEY`],modelstudio:[`MODELSTUDIO_API_KEY`],volcengine:[`VOLCANO_ENGINE_API_KEY`],byteplus:[`BYTEPLUS_API_KEY`]},Po=[`VOYAGE_API_KEY`,`GROQ_API_KEY`,`DEEPGRAM_API_KEY`,`CEREBRAS_API_KEY`,`NVIDIA_API_KEY`,`COPILOT_GITHUB_TOKEN`,`GH_TOKEN`,`GITHUB_TOKEN`,`ANTHROPIC_OAUTH_TOKEN`,`CHUTES_OAUTH_TOKEN`,`CHUTES_API_KEY`,`QWEN_OAUTH_TOKEN`,`QWEN_PORTAL_API_KEY`,`MINIMAX_OAUTH_TOKEN`,`OLLAMA_API_KEY`,`VLLM_API_KEY`],Fo=[...new Set(Object.values(No).flatMap(e=>e))];[...new Set([...Fo,...Po])];function Io(e){return e instanceof Error&&typeof e.message==`string`&&e.message.trim()?e.message:String(e)}function Lo(e){return No[e]?.find(e=>e.trim().length>0)}function Ro(e){return`/providers/${Ue(e)}/apiKey`}async function zo(e){let t=e.preferredEnvVar??Lo(e.provider)??``,n=Ro(e.provider),r=`env`;for(;;){let i=await e.prompter.select({message:e.copy?.sourceMessage??`Where is this API key stored?`,initialValue:r,options:[{value:`env`,label:`Environment variable`,hint:`Reference a variable from your runtime environment`},{value:`provider`,label:`Configured secret provider`,hint:`Use a configured file or exec secret provider`}]})===`provider`?`provider`:`env`;if(r=i,i===`env`){let n=await e.prompter.text({message:e.copy?.envVarMessage??`Environment variable name`,initialValue:t||void 0,placeholder:e.copy?.envVarPlaceholder??`OPENAI_API_KEY`,validate:t=>{let n=t.trim();if(!mn(n))return e.copy?.envVarFormatError??`Use an env var name like "OPENAI_API_KEY" (uppercase letters, numbers, underscores).`;if(!process.env[n]?.trim())return e.copy?.envVarMissingError?.(n)??`Environment variable "${n}" is missing or empty in this session.`}}),r=String(n??``).trim(),i=r&&mn(r)?r:t;if(!i)throw Error(`No valid environment variable name provided for provider "${e.provider}".`);let a={source:`env`,provider:ue(e.config,`env`,{preferFirstProviderForSource:!0}),id:i},o=await wt(a,{config:e.config,env:process.env});return await e.prompter.note(e.copy?.envValidatedMessage?.(i)??`Validated environment variable ${i}. OpenClaw will store a reference, not the key value.`,`Reference validated`),{ref:a,resolvedValue:o}}let a=Object.entries(e.config.secrets?.providers??{}).filter(([,e])=>e?.source===`file`||e?.source===`exec`);if(a.length===0){await e.prompter.note(e.copy?.noProvidersMessage??`No file/exec secret providers are configured yet. Add one under secrets.providers, or select Environment variable.`,`No providers configured`);continue}let o=ue(e.config,`file`,{preferFirstProviderForSource:!0}),s=await e.prompter.select({message:`Select secret provider`,initialValue:a.find(([e])=>e===o)?.[0]??a[0]?.[0],options:a.map(([e,t])=>({value:e,label:e,hint:t?.source===`exec`?`Exec provider`:`File provider`}))}),c=e.config.secrets?.providers?.[s];if(!c||c.source!==`file`&&c.source!==`exec`){await e.prompter.note(`Provider "${s}" is not a file/exec provider.`,`Invalid provider`);continue}let l=c.source===`file`?`Secret id (JSON pointer for json mode, or 'value' for singleValue mode)`:`Secret id for the exec provider`,u=c.source===`file`?c.mode===`singleValue`?`value`:n:`${e.provider}/apiKey`,d=await e.prompter.text({message:l,initialValue:u,placeholder:c.source===`file`?`/providers/openai/apiKey`:`openai/api-key`,validate:e=>{let t=e.trim();if(!t)return`Secret id cannot be empty.`;if(c.source===`file`&&c.mode!==`singleValue`&&!qt(t))return`Use an absolute JSON pointer like "/providers/openai/apiKey".`;if(c.source===`file`&&c.mode===`singleValue`&&t!==`value`)return`singleValue mode expects id "value".`;if(c.source===`exec`&&!Je(t))return ve()}}),f=String(d??``).trim()||u,p={source:c.source,provider:s,id:f};try{let t=await wt(p,{config:e.config,env:process.env});return await e.prompter.note(e.copy?.providerValidatedMessage?.(s,f,c.source)??`Validated ${c.source} reference ${s}:${f}. OpenClaw will store a reference, not the key value.`,`Reference validated`),{ref:p,resolvedValue:t}}catch(t){await e.prompter.note([`Could not validate provider reference ${s}:${f}.`,Io(t),`Check your provider configuration and try again.`].join(`
|
|
1
|
+
import{Bt as e,E as t,L as n,Lt as r,O as i,Ut as a,Wt as o,_t as s,bt as c,c as l,d as u,f as d,h as f,k as p,l as m,m as ee,p as te,u as h,w as ne,yt as re}from"./paths-CSbOOCsu.js";import{$c as ie,$i as ae,$l as g,$t as oe,A as se,Aa as ce,Ai as le,Al as ue,B as de,Ba as fe,Bi as pe,Ca as me,Ci as he,Co as ge,Di as _e,Dl as ve,Do as ye,Ds as be,Ea as xe,Ei as Se,Eo as Ce,F as we,Fa as Te,Ga as Ee,Gi as De,Gl as _,H as Oe,Ha as ke,Hi as Ae,I as je,Ia as Me,Ja as Ne,Ji as Pe,Ka as Fe,Ki as Ie,Ks as Le,L as Re,La as ze,Lo as Be,M as Ve,Ma as v,Mi as He,Ml as Ue,Mo as We,N as Ge,Na as Ke,Nl as y,No as b,Oi as qe,Ol as Je,P as Ye,Pa as Xe,Qi as Ze,R as Qe,Ra as $e,Rs as et,Sa as tt,So as nt,Ta as x,Ti as rt,To as it,U as at,Ua as ot,Ui as st,Ul as ct,V as lt,Va as ut,Vc as dt,Vi as ft,Wi as pt,Wl as mt,Xi as ht,Xs as gt,Yi as _t,Ys as vt,Zi as yt,Zl as bt,Zs as xt,_ as St,_a as Ct,_l as wt,_o as Tt,as as Et,ba as Dt,bo as Ot,co as kt,d as At,da as jt,do as Mt,ea as Nt,eu as Pt,f as Ft,fo as It,g as Lt,go as Rt,h as zt,ho as Bt,is as Vt,j as Ht,ja as Ut,ji as Wt,k as Gt,ki as Kt,kl as qt,ko as Jt,ks as Yt,la as Xt,lo as Zt,m as Qt,mo as $t,mu as en,na as tn,nu as nn,oa as rn,os as an,p as on,po as sn,qa as cn,qi as ln,ra as un,ru as dn,sl as fn,ta as pn,tu as mn,ua as hn,uo as gn,v as _n,va as vn,vo as yn,wa as bn,wi as xn,wo as Sn,xa as Cn,xo as wn,yo as Tn,z as En,za as Dn,zo as On}from"./config-B-UcenbQ.js";import{$t as kn,A as An,At as jn,B as Mn,Bt as Nn,C as Pn,Cn as Fn,D as In,Dt as Ln,Et as Rn,F as zn,Ft as Bn,G as Vn,H as Hn,Ht as Un,It as Wn,J as Gn,Jt as Kn,K as qn,Kt as Jn,L as Yn,Lt as Xn,M as Zn,Mt as Qn,N as $n,O as er,Ot as tr,P as nr,Pt as rr,Qt as ir,R as ar,Rt as or,S as sr,Sn as cr,T as lr,Tt as ur,U as dr,Ut as fr,V as pr,Vt as mr,W as hr,Wt as gr,Xt as _r,Yt as vr,Zt as yr,_ as br,_n as xr,an as Sr,b as Cr,bn as wr,cn as Tr,dn as Er,dt as Dr,en as Or,f as S,fn as kr,ft as Ar,g as jr,gn as Mr,gt as Nr,h as Pr,hn as Fr,in as Ir,j as Lr,jt as Rr,k as zr,kt as Br,ln as Vr,lt as Hr,mn as Ur,n as Wr,nn as Gr,on as Kr,ot as qr,pn as Jr,pt as Yr,q as Xr,qt as C,rn as Zr,sn as Qr,t as $r,tn as w,un as ei,ut as ti,v as ni,vn as ri,w as ii,x as T,xn as ai,y as oi,yn as si,yt as ci,z as li,zt as ui}from"./dispatch-DzdnDix3.js";import"./paths-BZu7pylC.js";import"./github-copilot-token-CZKe5l5K.js";import{C as E,O as di,Q as fi,b as D,j as pi,m as mi,p as hi,q as gi,s as _i,v as vi,w as yi}from"./logger-C9qBS3pT.js";import{r as bi}from"./proxy-env-CPkJIzpH.js";import{At as xi,Bt as Si,Dt as Ci,Et as wi,Ft as Ti,Ht as Ei,It as Di,Mt as Oi,Nt as ki,Ot as Ai,Pt as ji,Tt as Mi,Ut as Ni,Vt as Pi,Wt as Fi,at as Ii,dt as Li,jt as Ri,kt as zi}from"./send-Cm3DUp7B.js";import"./fetch-DBRI0sKI.js";import"./channel-activity-BmtBYQiY.js";import{t as Bi}from"./fetch-guard-DFkrvefb.js";import"./local-roots-CJmQubXD.js";import{p as Vi,v as Hi}from"./ir-CtV16xaT.js";import"./render-DGmfCIRG.js";import"./tables-BSCz74OW.js";import{X as Ui,Y as Wi,it as Gi,rt as Ki}from"./send-BZLHNxgv.js";import{d as O,f as qi,h as k,l as Ji,n as Yi,o as Xi}from"./target-errors-IUyUVvTY.js";import{s as Zi}from"./send-DEXJLpyz.js";import{h as Qi}from"./deliver-C_gmqump.js";import{g as $i,h as ea,m as ta}from"./diagnostic-BjNsv_MZ.js";import"./pi-model-discovery-KbgCHo1f.js";import{d as na,f as ra}from"./audio-transcription-runner-CDEClJ7w.js";import"./image-Bkivxhr_.js";import"./api-key-rotation-C2RTMqbG.js";import"./proxy-fetch-zQZYbMVb.js";import{i as ia,n as aa}from"./tokens-BzJXWHOV.js";import"./commands-registry-DueC2CXY.js";import{n as oa,r as sa}from"./targets-CVEYTFPQ.js";import"./send-NZQ7cj5i.js";import"./outbound-attachment-Diu_o1ga.js";import{c as ca,d as la,f as ua,l as da,m as fa,o as pa,p as ma,u as ha}from"./send-_fKv95OZ.js";import"./sqlite-9K32c8mU.js";import{i as ga,n as _a,r as va}from"./fetch-DMcdYoAa.js";import{c as ya,l as ba,n as xa,o as Sa,s as Ca}from"./skill-commands-B06QVSkm.js";import"./manager-DDgXS0Q8.js";import{t as wa}from"./resolve-outbound-target-CTyYBRiK.js";import{r as Ta}from"./channel-web-T7e1VB_g.js";import"./outbound-RGOrt1pb.js";import"./session-DfMpA14O.js";import{t as Ea}from"./login-CnJL85zg.js";import Da,{constants as A,createWriteStream as Oa}from"node:fs";import j from"node:path";import ka from"node:os";import M from"node:fs/promises";import{createHash as Aa,randomBytes as ja,randomUUID as Ma}from"node:crypto";import{format as Na}from"node:util";import{pipeline as Pa}from"node:stream/promises";import{request as Fa}from"node:https";import{z as N}from"zod";import{Readable as Ia,Transform as La}from"node:stream";import Ra from"jszip";import*as za from"tar";function Ba(e){return{success:!1,error:{issues:[{path:[],message:e}]}}}function Va(){return{safeParse(e){return e===void 0?{success:!0,data:void 0}:!e||typeof e!=`object`||Array.isArray(e)?Ba(`expected config object`):Object.keys(e).length>0?Ba(`config must be empty`):{success:!0,data:e}},jsonSchema:{type:`object`,additionalProperties:!1,properties:{}}}}function Ha(e){return e.map(e=>({input:e.input,resolved:e.resolved,id:e.id,name:e.name,note:e.note}))}async function Ua(e){let t=[];for(let n of e.inputs)t.push(await e.mapInput(n));return t}function Wa(e){return typeof e==`string`?e:e instanceof URL?e.toString():typeof e==`object`&&e&&`url`in e&&typeof e.url==`string`?e.url:``}function Ga(e){return{verbose:!1,replyTo:e.replyToId??void 0,accountId:e.accountId??void 0,silent:e.silent??void 0}}function Ka(e){return{...Ga(e),mediaUrl:e.mediaUrl,mediaLocalRoots:e.mediaLocalRoots}}function qa(e){return{channel:`discord`,...e}}function P(e){let t=e.trim();if(!t)return`/`;let n=t.startsWith(`/`)?t:`/${t}`;return n.length>1&&n.endsWith(`/`)?n.slice(0,-1):n}function Ja(e){let t=e.webhookPath?.trim();if(t)return P(t);if(e.webhookUrl?.trim())try{return P(new URL(e.webhookUrl).pathname||`/`)}catch{return null}return e.defaultPath??null}const Ya=Object.freeze({preAuth:{maxBytes:64*1024,timeoutMs:5e3},postAuth:{maxBytes:1024*1024,timeoutMs:3e4}}),Xa=Object.freeze({maxInFlightPerKey:8,maxTrackedKeys:4096});function Za(e){let t=e.profile===`pre-auth`?Ya.preAuth:Ya.postAuth;return{maxBytes:typeof e.maxBytes==`number`&&Number.isFinite(e.maxBytes)&&e.maxBytes>0?Math.floor(e.maxBytes):t.maxBytes,timeoutMs:typeof e.timeoutMs==`number`&&Number.isFinite(e.timeoutMs)&&e.timeoutMs>0?Math.floor(e.timeoutMs):t.timeoutMs}}function Qa(e){let{res:t,code:n,invalidMessage:r}=e;return n===`PAYLOAD_TOO_LARGE`?(t.statusCode=413,t.end(w(`PAYLOAD_TOO_LARGE`)),{ok:!1}):n===`REQUEST_BODY_TIMEOUT`?(t.statusCode=408,t.end(w(`REQUEST_BODY_TIMEOUT`)),{ok:!1}):n===`CONNECTION_CLOSED`?(t.statusCode=400,t.end(w(`CONNECTION_CLOSED`)),{ok:!1}):(t.statusCode=400,t.end(r??`Bad Request`),{ok:!1})}function $a(e){let t=Math.max(1,Math.floor(e?.maxInFlightPerKey??Xa.maxInFlightPerKey)),n=Math.max(1,Math.floor(e?.maxTrackedKeys??Xa.maxTrackedKeys)),r=new Map;return{tryAcquire:e=>{if(!e)return!0;let i=r.get(e)??0;return i>=t?!1:(r.set(e,i+1),C(r,n),!0)},release:e=>{if(!e)return;let t=r.get(e);if(t!==void 0){if(t<=1){r.delete(e);return}r.set(e,t-1)}},size:()=>r.size,clear:()=>r.clear()}}function eo(e){let t=Array.isArray(e)?e[0]:e;if(!t)return!1;let n=t.split(`;`,1)[0]?.trim().toLowerCase();return n===`application/json`||!!n?.endsWith(`+json`)}function to(e){let t=e.allowMethods?.length?e.allowMethods:null;return t&&!t.includes(e.req.method??``)?(e.res.statusCode=405,e.res.setHeader(`Allow`,t.join(`, `)),e.res.end(`Method Not Allowed`),!1):e.rateLimiter&&e.rateLimitKey&&e.rateLimiter.isRateLimited(e.rateLimitKey,e.nowMs??Date.now())?(e.res.statusCode=429,e.res.end(`Too Many Requests`),!1):e.requireJsonContentType&&e.req.method===`POST`&&!eo(e.req.headers[`content-type`])?(e.res.statusCode=415,e.res.end(`Unsupported Media Type`),!1):!0}function no(e){if(!to({req:e.req,res:e.res,allowMethods:e.allowMethods,rateLimiter:e.rateLimiter,rateLimitKey:e.rateLimitKey,nowMs:e.nowMs,requireJsonContentType:e.requireJsonContentType}))return{ok:!1};let t=e.inFlightKey??``,n=e.inFlightLimiter;if(n&&t&&!n.tryAcquire(t))return e.res.statusCode=e.inFlightLimitStatusCode??429,e.res.end(e.inFlightLimitMessage??`Too Many Requests`),{ok:!1};let r=!1;return{ok:!0,release:()=>{r||(r=!0,n&&t&&n.release(t))}}}async function ro(e){let t=Za({maxBytes:e.maxBytes,timeoutMs:e.timeoutMs,profile:e.profile});try{return{ok:!0,value:await Or(e.req,t)}}catch(t){return ir(t)?Qa({res:e.res,code:t.code,invalidMessage:e.invalidBodyMessage}):Qa({res:e.res,code:`INVALID_BODY`,invalidMessage:e.invalidBodyMessage??(t instanceof Error?t.message:String(t))})}}async function io(e){let t=Za({maxBytes:e.maxBytes,timeoutMs:e.timeoutMs,profile:e.profile}),n=await kn(e.req,{maxBytes:t.maxBytes,timeoutMs:t.timeoutMs,emptyObjectOnEmpty:e.emptyObjectOnEmpty});return n.ok?{ok:!0,value:n.value}:Qa({res:e.res,code:n.code,invalidMessage:e.invalidJsonMessage})}function ao(e){return co(e.targetsByPath,e.target,{onFirstPathTarget:({path:t})=>Sr({...e.route,path:t,replaceExisting:e.route.replaceExisting??!0}),onLastPathTargetRemoved:e.onLastPathTargetRemoved})}const oo=new WeakMap;function so(e){let t=e,n=oo.get(t);if(n)return n;let r=new Map;return oo.set(t,r),r}function co(e,t,n){let r=P(t.path),i={...t,path:r},a=e.get(r)??[];if(a.length===0){let t=n?.onFirstPathTarget?.({path:r,target:i});typeof t==`function`&&so(e).set(r,t)}e.set(r,[...a,i]);let o=!0;return{target:i,unregister:()=>{if(!o)return;o=!1;let t=(e.get(r)??[]).filter(e=>e!==i);if(t.length>0){e.set(r,t);return}e.delete(r);let a=so(e).get(r);a&&(so(e).delete(r),a()),n?.onLastPathTargetRemoved?.({path:r})}}}function lo(e,t){let n=P(new URL(e.url??`/`,`http://localhost`).pathname),r=t.get(n);return!r||r.length===0?null:{path:n,targets:r}}async function uo(e){let t=lo(e.req,e.targetsByPath);if(!t)return!1;let n=typeof e.inFlightKey==`function`?e.inFlightKey({req:e.req,path:t.path,targets:t.targets}):e.inFlightKey??`${t.path}:${e.req.socket?.remoteAddress??`unknown`}`,r=no({req:e.req,res:e.res,allowMethods:e.allowMethods,rateLimiter:e.rateLimiter,rateLimitKey:e.rateLimitKey,nowMs:e.nowMs,requireJsonContentType:e.requireJsonContentType,inFlightLimiter:e.inFlightLimiter,inFlightKey:n,inFlightLimitStatusCode:e.inFlightLimitStatusCode,inFlightLimitMessage:e.inFlightLimitMessage});if(!r.ok)return!0;try{return await e.handle(t),!0}finally{r.release()}}function fo(e,t){return e?{ok:!1,result:{kind:`ambiguous`}}:{ok:!0,matched:t}}function po(e){return e?{kind:`single`,target:e}:{kind:`none`}}function mo(e,t){let n;for(let r of e){if(!t(r))continue;let e=fo(n,r);if(!e.ok)return e.result;n=e.matched}return po(n)}async function ho(e,t){let n;for(let r of e){if(!await t(r))continue;let e=fo(n,r);if(!e.ok)return e.result;n=e.matched}return po(n)}async function go(e){return vo(e,await ho(e.targets,async t=>!!await e.isMatch(t)))}function _o(e){return vo(e,mo(e.targets,e.isMatch))}function vo(e,t){return t.kind===`single`?t.target:t.kind===`ambiguous`?(e.res.statusCode=e.ambiguousStatusCode??401,e.res.end(e.ambiguousMessage??`ambiguous webhook target`),null):(e.res.statusCode=e.unauthorizedStatusCode??401,e.res.end(e.unauthorizedMessage??`unauthorized`),null)}function yo(e,t){return e.method===`POST`?!1:(t.statusCode=405,t.setHeader(`Allow`,`POST`),t.end(`Method Not Allowed`),!0)}function bo(e){return t=>{e.setStatus({accountId:e.accountId,...t})}}function xo(e,t){return new Promise((n,r)=>{let i=()=>{Promise.resolve(t?.()).then(()=>n(),r)};if(e){if(e.aborted){i();return}e.addEventListener(`abort`,i,{once:!0})}})}async function So(e){let t=await e.start();try{await xo(e.abortSignal)}finally{await e.stop?.(t),await e.onStop?.()}}async function Co(e){let{server:t,abortSignal:n,onAbort:r}=e,i=Promise.resolve(),a=!1,o=()=>{a||(a=!0,i=Promise.resolve(r?.()).then(()=>void 0))},s=()=>{o()};n&&(n.aborted?o():n.addEventListener(`abort`,s,{once:!0})),await new Promise(e=>{t.once(`close`,()=>e())}),n&&n.removeEventListener(`abort`,s),await i}function wo(e){let t=e[0],n=e.map(e=>e.path),r=e.map(e=>e.contentType).filter(Boolean);return{MediaPath:t?.path,MediaType:t?.contentType??void 0,MediaUrl:t?.path,MediaPaths:n.length>0?n:void 0,MediaUrls:n.length>0?n:void 0,MediaTypes:r.length>0?r:void 0}}function To(e,t){return{accountId:e,running:!1,lastStartAt:null,lastStopAt:null,lastError:null,...t??{}}}function Eo(e){return{configured:e.configured??!1,running:e.running??!1,lastStartAt:e.lastStartAt??null,lastStopAt:e.lastStopAt??null,lastError:e.lastError??null}}function Do(e,t){return{...Eo(e),...t??{},probe:e.probe,lastProbeAt:e.lastProbeAt??null}}function Oo(e){let{account:t,runtime:n,probe:r}=e;return{accountId:t.accountId,name:t.name,enabled:t.enabled,configured:t.configured,...Ao({runtime:n,probe:r}),lastInboundAt:n?.lastInboundAt??null,lastOutboundAt:n?.lastOutboundAt??null}}function ko(e){let{accountId:t,name:n,enabled:r,configured:i,runtime:a,probe:o}=e;return Oo({account:{accountId:t,name:n,enabled:r,configured:i},runtime:a,probe:o})}function Ao(e){let{runtime:t,probe:n}=e;return{running:t?.running??!1,lastStartAt:t?.lastStartAt??null,lastStopAt:t?.lastStopAt??null,lastError:t?.lastError??null,probe:n}}function jo(e,t){let n={...Eo(e),tokenSource:e.tokenSource??`none`,probe:e.probe,lastProbeAt:e.lastProbeAt??null};return t?.includeMode===!1?n:{...n,mode:e.mode??null}}function Mo(e,t){return t.flatMap(t=>{let n=typeof t.lastError==`string`?t.lastError.trim():``;return n?[{channel:e,accountId:t.accountId,kind:`runtime`,message:`Channel error: ${n}`}]:[]})}const No={openai:[`OPENAI_API_KEY`],anthropic:[`ANTHROPIC_API_KEY`],google:[`GEMINI_API_KEY`],minimax:[`MINIMAX_API_KEY`],"minimax-cn":[`MINIMAX_API_KEY`],moonshot:[`MOONSHOT_API_KEY`],"kimi-coding":[`KIMI_API_KEY`,`KIMICODE_API_KEY`],synthetic:[`SYNTHETIC_API_KEY`],venice:[`VENICE_API_KEY`],zai:[`ZAI_API_KEY`,`Z_AI_API_KEY`],xiaomi:[`XIAOMI_API_KEY`],openrouter:[`OPENROUTER_API_KEY`],"cloudflare-ai-gateway":[`CLOUDFLARE_AI_GATEWAY_API_KEY`],litellm:[`LITELLM_API_KEY`],"vercel-ai-gateway":[`AI_GATEWAY_API_KEY`],opencode:[`OPENCODE_API_KEY`,`OPENCODE_ZEN_API_KEY`],"opencode-go":[`OPENCODE_API_KEY`,`OPENCODE_ZEN_API_KEY`],together:[`TOGETHER_API_KEY`],huggingface:[`HUGGINGFACE_HUB_TOKEN`,`HF_TOKEN`],qianfan:[`QIANFAN_API_KEY`],xai:[`XAI_API_KEY`],mistral:[`MISTRAL_API_KEY`],kilocode:[`KILOCODE_API_KEY`],modelstudio:[`MODELSTUDIO_API_KEY`],volcengine:[`VOLCANO_ENGINE_API_KEY`],byteplus:[`BYTEPLUS_API_KEY`]},Po=[`VOYAGE_API_KEY`,`GROQ_API_KEY`,`DEEPGRAM_API_KEY`,`CEREBRAS_API_KEY`,`NVIDIA_API_KEY`,`COPILOT_GITHUB_TOKEN`,`GH_TOKEN`,`GITHUB_TOKEN`,`ANTHROPIC_OAUTH_TOKEN`,`CHUTES_OAUTH_TOKEN`,`CHUTES_API_KEY`,`QWEN_OAUTH_TOKEN`,`QWEN_PORTAL_API_KEY`,`MINIMAX_OAUTH_TOKEN`,`OLLAMA_API_KEY`,`VLLM_API_KEY`],Fo=[...new Set(Object.values(No).flatMap(e=>e))];[...new Set([...Fo,...Po])];function Io(e){return e instanceof Error&&typeof e.message==`string`&&e.message.trim()?e.message:String(e)}function Lo(e){return No[e]?.find(e=>e.trim().length>0)}function Ro(e){return`/providers/${Ue(e)}/apiKey`}async function zo(e){let t=e.preferredEnvVar??Lo(e.provider)??``,n=Ro(e.provider),r=`env`;for(;;){let i=await e.prompter.select({message:e.copy?.sourceMessage??`Where is this API key stored?`,initialValue:r,options:[{value:`env`,label:`Environment variable`,hint:`Reference a variable from your runtime environment`},{value:`provider`,label:`Configured secret provider`,hint:`Use a configured file or exec secret provider`}]})===`provider`?`provider`:`env`;if(r=i,i===`env`){let n=await e.prompter.text({message:e.copy?.envVarMessage??`Environment variable name`,initialValue:t||void 0,placeholder:e.copy?.envVarPlaceholder??`OPENAI_API_KEY`,validate:t=>{let n=t.trim();if(!mn(n))return e.copy?.envVarFormatError??`Use an env var name like "OPENAI_API_KEY" (uppercase letters, numbers, underscores).`;if(!process.env[n]?.trim())return e.copy?.envVarMissingError?.(n)??`Environment variable "${n}" is missing or empty in this session.`}}),r=String(n??``).trim(),i=r&&mn(r)?r:t;if(!i)throw Error(`No valid environment variable name provided for provider "${e.provider}".`);let a={source:`env`,provider:ue(e.config,`env`,{preferFirstProviderForSource:!0}),id:i},o=await wt(a,{config:e.config,env:process.env});return await e.prompter.note(e.copy?.envValidatedMessage?.(i)??`Validated environment variable ${i}. OpenClaw will store a reference, not the key value.`,`Reference validated`),{ref:a,resolvedValue:o}}let a=Object.entries(e.config.secrets?.providers??{}).filter(([,e])=>e?.source===`file`||e?.source===`exec`);if(a.length===0){await e.prompter.note(e.copy?.noProvidersMessage??`No file/exec secret providers are configured yet. Add one under secrets.providers, or select Environment variable.`,`No providers configured`);continue}let o=ue(e.config,`file`,{preferFirstProviderForSource:!0}),s=await e.prompter.select({message:`Select secret provider`,initialValue:a.find(([e])=>e===o)?.[0]??a[0]?.[0],options:a.map(([e,t])=>({value:e,label:e,hint:t?.source===`exec`?`Exec provider`:`File provider`}))}),c=e.config.secrets?.providers?.[s];if(!c||c.source!==`file`&&c.source!==`exec`){await e.prompter.note(`Provider "${s}" is not a file/exec provider.`,`Invalid provider`);continue}let l=c.source===`file`?`Secret id (JSON pointer for json mode, or 'value' for singleValue mode)`:`Secret id for the exec provider`,u=c.source===`file`?c.mode===`singleValue`?`value`:n:`${e.provider}/apiKey`,d=await e.prompter.text({message:l,initialValue:u,placeholder:c.source===`file`?`/providers/openai/apiKey`:`openai/api-key`,validate:e=>{let t=e.trim();if(!t)return`Secret id cannot be empty.`;if(c.source===`file`&&c.mode!==`singleValue`&&!qt(t))return`Use an absolute JSON pointer like "/providers/openai/apiKey".`;if(c.source===`file`&&c.mode===`singleValue`&&t!==`value`)return`singleValue mode expects id "value".`;if(c.source===`exec`&&!Je(t))return ve()}}),f=String(d??``).trim()||u,p={source:c.source,provider:s,id:f};try{let t=await wt(p,{config:e.config,env:process.env});return await e.prompter.note(e.copy?.providerValidatedMessage?.(s,f,c.source)??`Validated ${c.source} reference ${s}:${f}. OpenClaw will store a reference, not the key value.`,`Reference validated`),{ref:p,resolvedValue:t}}catch(t){await e.prompter.note([`Could not validate provider reference ${s}:${f}.`,Io(t),`Check your provider configuration and try again.`].join(`
|
|
2
2
|
`),`Reference check failed`)}}}async function Bo(e){return e.explicitMode?e.explicitMode:typeof e.prompter.select==`function`&&await e.prompter.select({message:e.copy?.modeMessage??`How do you want to provide this API key?`,initialValue:`plaintext`,options:[{value:`plaintext`,label:e.copy?.plaintextLabel??`Paste API key now`,hint:e.copy?.plaintextHint??`Stores the key directly in OpenClaw config`},{value:`ref`,label:e.copy?.refLabel??`Use external secret provider`,hint:e.copy?.refHint??`Stores a reference to env or configured external secret providers`}]})===`ref`?`ref`:`plaintext`}async function Vo(e){let t=e.listAccountIds(e.cfg),n=e.currentId?.trim()||e.defaultAccountId||`default`,r=await e.prompter.select({message:`${e.label} account`,options:[...t.map(e=>({value:e,label:e===`default`?`default (primary)`:e})),{value:`__new__`,label:`Add a new account`}],initialValue:n});if(r!==`__new__`)return o(r);let i=await e.prompter.text({message:`New ${e.label} account id`,validate:e=>e?.trim()?void 0:`Required`}),a=o(String(i));return String(i).trim()!==a&&await e.prompter.note(`Normalized account id to "${a}".`,`${e.label} account`),a}function Ho(e,t){let n=e.channels?.[t];return!!(n?.accounts&&Object.keys(n.accounts).length>0)}function Uo(e){return e.alwaysUseAccounts||e.accountId!==`default`?!0:Ho(e.cfg,e.channelKey)}function Wo(e){let t=e.name?.trim();if(!t)return e.cfg;let n=o(e.accountId),r=e.cfg.channels?.[e.channelKey],i=typeof r==`object`&&r?r:void 0;if(!Uo({cfg:e.cfg,channelKey:e.channelKey,accountId:n,alwaysUseAccounts:e.alwaysUseAccounts})&&n===`default`){let n=i??{};return{...e.cfg,channels:{...e.cfg.channels,[e.channelKey]:{...n,name:t}}}}let a=i?.accounts??{},s=a[n]??{},c=n===`default`?(({name:e,...t})=>t)(i??{}):i??{};return{...e.cfg,channels:{...e.cfg.channels,[e.channelKey]:{...c,accounts:{...a,[n]:{...s,name:t}}}}}}function Go(e){if(e.alwaysUseAccounts)return e.cfg;let t=e.cfg.channels?.[e.channelKey],n=t?.name?.trim();if(!n)return e.cfg;let r={...t?.accounts},i=r.default??{};i.name||(r[a]={...i,name:n});let{name:o,...s}=t??{};return{...e.cfg,channels:{...e.cfg.channels,[e.channelKey]:{...s,accounts:r}}}}function Ko(e){return qo({cfg:e.cfg,channelKey:e.channelKey,accountId:e.accountId,patch:e.patch})}function qo(e){let t=o(e.accountId),n=e.cfg.channels?.[e.channelKey],r=typeof n==`object`&&n?n:void 0,i=e.ensureChannelEnabled??!0,a=e.ensureAccountEnabled??i,s=e.patch,c=e.accountPatch??s;if(t===`default`)return{...e.cfg,channels:{...e.cfg.channels,[e.channelKey]:{...r,...i?{enabled:!0}:{},...s}}};let l=r?.accounts??{},u=l[t]??{};return{...e.cfg,channels:{...e.cfg.channels,[e.channelKey]:{...r,...i?{enabled:!0}:{},accounts:{...l,[t]:{...u,...a?{enabled:typeof u.enabled==`boolean`?u.enabled:!0}:{},...c}}}}}}const Jo=new Set(`name.token.tokenFile.botToken.appToken.account.signalNumber.authDir.cliPath.dbPath.httpUrl.httpHost.httpPort.webhookPath.webhookUrl.webhookSecret.service.region.homeserver.userId.accessToken.password.deviceName.url.code.dmPolicy.allowFrom.groupPolicy.groupAllowFrom.defaultTo`.split(`.`)),Yo={telegram:new Set([`streaming`])};function Xo(e){return Jo.has(e.key)?!0:Yo[e.channelKey]?.has(e.key)??!1}function Zo(e){return e&&typeof e==`object`?structuredClone(e):e}function Qo(e){let t=e.cfg.channels?.[e.channelKey],n=typeof t==`object`&&t?t:void 0;if(!n)return e.cfg;let r=n.accounts??{};if(Object.keys(r).length>0)return e.cfg;let i=Object.entries(n).filter(([t,n])=>t!==`accounts`&&t!==`enabled`&&n!==void 0&&Xo({channelKey:e.channelKey,key:t})).map(([e])=>e),o={};for(let e of i){let t=n[e];o[e]=Zo(t)}let s={...n};for(let e of i)delete s[e];return{...e.cfg,channels:{...e.cfg.channels,[e.channelKey]:{...s,accounts:{...r,[a]:o}}}}}const $o=async e=>await Vo(e);function F(e){let t=(e??[]).map(e=>String(e).trim()).filter(Boolean);return t.includes(`*`)||t.push(`*`),t}function I(e,t){let n=[...e??[],...t].map(e=>String(e).trim()).filter(Boolean);return[...new Set(n)]}function L(e){return e.split(/[\n,;]+/g).map(e=>e.trim()).filter(Boolean)}function es(e,t){let n=L(String(e??``)),r=[];for(let e of n){let n=t(e);if(`error`in n)return{entries:[],error:n.error};r.push(n.value)}return{entries:R(r)}}function ts(e,t){return es(e,e=>e===`*`?{value:`*`}:t(e))}function ns(e){let t=e.value.trim();if(!t)return null;let n=t.match(e.mentionPattern);if(n?.[1])return e.normalizeId?e.normalizeId(n[1]):n[1];let r=e.prefixPattern?t.replace(e.prefixPattern,``):t;return e.idPattern.test(r)?e.normalizeId?e.normalizeId(r):r:null}function R(e,t){let n=e.map(e=>String(e).trim()).filter(Boolean).map(e=>{if(e===`*`)return`*`;if(!t)return e;let n=t(e);return typeof n==`string`?n.trim():``}).filter(Boolean);return[...new Set(n)]}function z(e){return e.accountId?.trim()?o(e.accountId):e.defaultAccountId}async function B(e){let t=e.accountOverride?.trim(),n=t?o(t):e.defaultAccountId;return e.shouldPromptAccountIds&&!t&&(n=await $o({cfg:e.cfg,prompter:e.prompter,label:e.label,currentId:n,listAccountIds:e.listAccountIds,defaultAccountId:e.defaultAccountId})),n}function rs(e){let{cfg:t,channel:n,accountId:r,allowFrom:i}=e;return fs({cfg:t,channel:n,accountId:r,patch:{allowFrom:i},ensureEnabled:!1})}function is(e){let t=e.cfg.channels?.[e.channel]??{};return{...e.cfg,channels:{...e.cfg.channels,[e.channel]:{...t,...e.enabled?{enabled:!0}:{},allowFrom:e.allowFrom}}}}function as(e){let t=e.cfg.channels?.[e.channel]??{},n=e.getAllowFrom?.(e.cfg)??t.allowFrom??void 0,r=e.dmPolicy===`open`?F(n):void 0;return{...e.cfg,channels:{...e.cfg.channels,[e.channel]:{...t,dmPolicy:e.dmPolicy,...r?{allowFrom:r}:{}}}}}function os(e){let t=e.cfg.channels?.[e.channel]??{};return{...e.cfg,channels:{...e.cfg.channels,[e.channel]:{...t,...e.enabled?{enabled:!0}:{},groupPolicy:e.groupPolicy}}}}function ss(e){let{cfg:t,channel:n,dmPolicy:r}=e,i=r===`open`?F(t.channels?.[n]?.allowFrom):void 0;return{...t,channels:{...t.channels,[n]:{...t.channels?.[n],dmPolicy:r,...i?{allowFrom:i}:{}}}}}function cs(e){let t=e.cfg.channels?.[e.channel]??{allowFrom:void 0,dm:void 0},n=t.allowFrom??t.dm?.allowFrom,r=e.dmPolicy===`open`?F(n):void 0;return ds({cfg:e.cfg,channel:e.channel,patch:{dmPolicy:e.dmPolicy,...r?{allowFrom:r}:{}}})}function ls(e){return ds({cfg:e.cfg,channel:e.channel,patch:{allowFrom:e.allowFrom}})}function us(e){return H({cfg:e.cfg,channel:e.channel,accountId:e.accountId,patch:{groupPolicy:e.groupPolicy}})}function ds(e){let{cfg:t,channel:n,patch:r}=e,i=t.channels?.[n]??{},a=i.dm??{};return{...t,channels:{...t.channels,[n]:{...i,...r,dm:{...a,enabled:typeof a.enabled==`boolean`?a.enabled:!0}}}}}function V(e,t,n){let r=e.channels?.[t]??{};return{...e,channels:{...e.channels,[t]:{...r,enabled:n}}}}function fs(e){let{cfg:t,channel:n,accountId:r,patch:i,ensureEnabled:a}=e;return qo({cfg:r===`default`?t:Qo({cfg:t,channelKey:n}),channelKey:n,accountId:r,patch:i,ensureChannelEnabled:a,ensureAccountEnabled:a})}function H(e){return fs({...e,ensureEnabled:!0})}function U(e){let t=e.cfg;return e.tokenResult.useEnv&&(t=H({cfg:t,channel:e.channel,accountId:e.accountId,patch:{}})),e.tokenResult.token&&(t=H({cfg:t,channel:e.channel,accountId:e.accountId,patch:{[e.tokenPatchKey]:e.tokenResult.token}})),t}function ps(e){return{accountConfigured:e.accountConfigured,hasConfigToken:e.hasConfigToken,canUseEnv:e.allowEnv&&!!e.envValue?.trim()&&!e.hasConfigToken}}async function ms(e){let t=async()=>String(await e.prompter.text({message:e.inputPrompt,validate:e=>e?.trim()?void 0:`Required`})).trim();return e.canUseEnv?await e.prompter.confirm({message:e.envPrompt,initialValue:!0})?{useEnv:!0,token:null}:{useEnv:!1,token:await t()}:e.hasConfigToken&&e.accountConfigured&&await e.prompter.confirm({message:e.keepPrompt,initialValue:!0})?{useEnv:!1,token:null}:{useEnv:!1,token:await t()}}async function W(e){let t=ps({accountConfigured:e.accountConfigured,hasConfigToken:e.hasConfigToken,allowEnv:e.allowEnv,envValue:e.envValue});!t.accountConfigured&&e.onMissingConfigured&&await e.onMissingConfigured();let n=await hs({cfg:e.cfg,prompter:e.prompter,providerHint:e.providerHint,credentialLabel:e.credentialLabel,secretInputMode:e.secretInputMode,accountConfigured:t.accountConfigured,canUseEnv:t.canUseEnv,hasConfigToken:t.hasConfigToken,envPrompt:e.envPrompt,keepPrompt:e.keepPrompt,inputPrompt:e.inputPrompt,preferredEnvVar:e.preferredEnvVar});return n.action===`use-env`?{cfg:e.applyUseEnv?await e.applyUseEnv(e.cfg):e.cfg,action:n.action,resolvedValue:e.envValue?.trim()||void 0}:n.action===`set`?{cfg:e.applySet?await e.applySet(e.cfg,n.value,n.resolvedValue):e.cfg,action:n.action,resolvedValue:n.resolvedValue}:{cfg:e.cfg,action:n.action}}async function hs(e){if(await Bo({prompter:e.prompter,explicitMode:e.secretInputMode,copy:{modeMessage:`How do you want to provide this ${e.credentialLabel}?`,plaintextLabel:`Enter ${e.credentialLabel}`,plaintextHint:`Stores the credential directly in OpenClaw config`,refLabel:`Use external secret provider`,refHint:`Stores a reference to env or configured external secret providers`}})===`plaintext`){let t=await ms({prompter:e.prompter,accountConfigured:e.accountConfigured,canUseEnv:e.canUseEnv,hasConfigToken:e.hasConfigToken,envPrompt:e.envPrompt,keepPrompt:e.keepPrompt,inputPrompt:e.inputPrompt});return t.useEnv?{action:`use-env`}:t.token?{action:`set`,value:t.token,resolvedValue:t.token}:{action:`keep`}}if(e.hasConfigToken&&e.accountConfigured&&await e.prompter.confirm({message:e.keepPrompt,initialValue:!0}))return{action:`keep`};let t=await zo({provider:e.providerHint,config:e.cfg,prompter:e.prompter,preferredEnvVar:e.preferredEnvVar,copy:{sourceMessage:`Where is this ${e.credentialLabel} stored?`,envVarPlaceholder:e.preferredEnvVar??`OPENCLAW_SECRET`,envVarFormatError:`Use an env var name like "OPENCLAW_SECRET" (uppercase letters, numbers, underscores).`,noProvidersMessage:`No file/exec secret providers are configured yet. Add one under secrets.providers, or select Environment variable.`}});return{action:`set`,value:t.ref,resolvedValue:t.resolvedValue}}async function gs(e){let t=z({accountId:e.accountId,defaultAccountId:e.defaultAccountId}),n=e.getExistingAllowFrom({cfg:e.cfg,accountId:t});await e.prompter.note(e.noteLines.join(`
|
|
3
3
|
`),e.noteTitle);let r=await e.prompter.text({message:e.message,placeholder:e.placeholder,initialValue:n[0]?String(n[0]):void 0,validate:t=>{let n=String(t??``).trim();return n?e.parseEntries(n).error:`Required`}}),i=I(void 0,e.parseEntries(String(r)).entries);return rs({cfg:e.cfg,channel:e.channel,accountId:t,allowFrom:i})}async function _s(e){let t=[];for(let n of e.resolvedSections)n.values.length!==0&&t.push(`${n.title}: ${n.values.join(`, `)}`);e.unresolved&&e.unresolved.length>0&&t.push(`Unresolved (kept as typed): ${e.unresolved.join(`, `)}`),t.length>0&&await e.prompter.note(t.join(`
|
|
4
4
|
`),e.label)}async function vs(e){await e.prompter.note(`Channel lookup failed; keeping entries as typed. ${String(e.error)}`,e.label)}async function ys(e){for(;;){let t=await e.prompter.text({message:e.message,placeholder:e.placeholder,initialValue:e.existing[0]?String(e.existing[0]):void 0,validate:e=>String(e??``).trim()?void 0:`Required`}),n=e.parseInputs(String(t));if(!e.token){let t=n.map(e.parseId).filter(Boolean);if(t.length!==n.length){await e.prompter.note(e.invalidWithoutTokenNote,e.label);continue}return I(e.existing,t)}let r=await e.resolveEntries({token:e.token,entries:n}).catch(()=>null);if(!r){await e.prompter.note(`Failed to resolve usernames. Try again.`,e.label);continue}let i=r.filter(e=>!e.resolved||!e.id);if(i.length>0){await e.prompter.note(`Could not resolve: ${i.map(e=>e.input).join(`, `)}`,e.label);continue}let a=r.map(e=>e.id);return I(e.existing,a)}}async function bs(e){await e.prompter.note(e.noteLines.join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./paths-CSbOOCsu.js";import"./config-B-UcenbQ.js";import"./dispatch-
|
|
1
|
+
import"./paths-CSbOOCsu.js";import"./config-B-UcenbQ.js";import"./dispatch-DzdnDix3.js";import"./paths-BZu7pylC.js";import"./github-copilot-token-CZKe5l5K.js";import"./logger-C9qBS3pT.js";import"./proxy-env-CPkJIzpH.js";import"./send-Cm3DUp7B.js";import"./fetch-DBRI0sKI.js";import"./channel-activity-BmtBYQiY.js";import"./fetch-guard-DFkrvefb.js";import"./local-roots-CJmQubXD.js";import"./ir-CtV16xaT.js";import"./render-DGmfCIRG.js";import"./tables-BSCz74OW.js";import"./send-BZLHNxgv.js";import"./target-errors-IUyUVvTY.js";import"./send-DEXJLpyz.js";import"./deliver-C_gmqump.js";import"./diagnostic-BjNsv_MZ.js";import"./pi-model-discovery-KbgCHo1f.js";import"./audio-transcription-runner-CDEClJ7w.js";import"./image-Bkivxhr_.js";import"./api-key-rotation-C2RTMqbG.js";import"./proxy-fetch-zQZYbMVb.js";import"./tokens-BzJXWHOV.js";import"./commands-registry-DueC2CXY.js";import"./send-NZQ7cj5i.js";import"./outbound-attachment-Diu_o1ga.js";import"./send-_fKv95OZ.js";import"./sqlite-9K32c8mU.js";import"./fetch-DMcdYoAa.js";import"./skill-commands-B06QVSkm.js";import"./manager-DDgXS0Q8.js";import"./channel-web-T7e1VB_g.js";import{t as e}from"./outbound-RGOrt1pb.js";import"./session-DfMpA14O.js";import"./login-CnJL85zg.js";import"./web-BoQezxCE.js";export{e as sendMessageWhatsApp};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./paths-Ck_GIp7q.js";import"./utils-CfTrvEp0.js";import"./paths-D_Oppcui.js";import"./model-auth-BJBZCtjT.js";import"./target-errors-BOqeJ_3F.js";import"./dispatch
|
|
1
|
+
import"./paths-Ck_GIp7q.js";import"./utils-CfTrvEp0.js";import"./paths-D_Oppcui.js";import"./model-auth-BJBZCtjT.js";import"./target-errors-BOqeJ_3F.js";import"./dispatch--4Vuy9oL.js";import"./send-CO2UHcEv.js";import"./send-DE5nZ2st.js";import"./proxy-env-BnKSJOGR.js";import"./github-copilot-token-DmcuLuc7.js";import"./send-BUrpCp2y.js";import"./fetch-guard-BSsJgDhB.js";import"./deliver-VMHoHBzn.js";import"./diagnostic-DVzH_MLb.js";import"./pi-model-discovery-Db7ABtcq.js";import"./audio-transcription-runner-DhJf4m1B.js";import"./image-D2kjZFi6.js";import"./api-key-rotation-CDbYWBVm.js";import"./local-roots-BH5tSQLl.js";import"./proxy-fetch-o_y6bhRh.js";import"./tokens-Bh7fgb-2.js";import"./commands-registry-CqcYbN0q.js";import"./ir-BtYOx2uz.js";import"./render-DhTJXP1U.js";import"./send-B31irjnU.js";import"./outbound-attachment-Fq-8ay7E.js";import"./fetch-p43DsBwY.js";import"./send-ITDY5IkL.js";import"./sqlite-DcxSH4wB.js";import"./channel-activity-Dka0S6Hm.js";import"./tables-B-mnbiT0.js";import"./fetch-BmdDzZ-O.js";import"./skill-commands-B75FKFYa.js";import"./manager-uBkiNkiS.js";import{t as e}from"./outbound-NPBHGutj.js";import"./session-qFBaqGPJ.js";import"./login-JSBmsJlB.js";import"./web-CgFT-LB5.js";export{e as sendMessageWhatsApp};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./dispatch-
|
|
1
|
+
import"./dispatch-v8f5j6tA.js";import"./send-Bb-c2Wfw.js";import"./paths-DJeQBg0P.js";import"./model-auth-dsGPdWPW.js";import"./logger-DeJtHfIZ.js";import"./paths-BAheUa28.js";import"./proxy-env-B8lWNmLK.js";import"./github-copilot-token-Be6rNfqm.js";import"./send-B1GxVX6l.js";import"./fetch-guard-PzaEpcQ7.js";import"./send-CwkiYqPX.js";import"./deliver-BxZhcYJx.js";import"./diagnostic-BwtamUsr.js";import"./pi-model-discovery-CqWtTmQH.js";import"./audio-transcription-runner-aZJ9cNlA.js";import"./image-DD04cXIg.js";import"./api-key-rotation-CsGG9jhG.js";import"./local-roots-DUN2ttYv.js";import"./proxy-fetch--DcTyl5K.js";import"./tokens-_Nmie3Ug.js";import"./commands-registry-Dw8t__8o.js";import"./ir-DLYol2vv.js";import"./render-CC0AV0OP.js";import"./target-errors-BTSekDWl.js";import"./send-V3uD9QA4.js";import"./outbound-attachment-nlK2LbIg.js";import"./fetch-rIayI79w.js";import"./send-CRV-DPpI.js";import"./sqlite-DnpnF8rT.js";import"./channel-activity-Bco4vhqQ.js";import"./tables-CsIFrUA3.js";import"./fetch-B0zJKaR8.js";import"./skill-commands-BGdnhkBW.js";import"./manager-Bpp6SEQN.js";import{t as e}from"./outbound-Dx62hg78.js";import"./session-GTab5xF7.js";import"./login-hW9p9jux.js";import"./web-CskfGkR8.js";export{e as sendMessageWhatsApp};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./paths-CB5IsdXc.js";import"./sessions-vCe4wPa1.js";import"./logger-CMRRf9cz.js";import"./paths-DhHYGQZt.js";import"./proxy-env-C-8R9SbI.js";import"./send-Dw9KZtdY.js";import"./common-CKZ-UdaB.js";import"./send-B6HPDK7K.js";import"./reply-
|
|
1
|
+
import"./paths-CB5IsdXc.js";import"./sessions-vCe4wPa1.js";import"./logger-CMRRf9cz.js";import"./paths-DhHYGQZt.js";import"./proxy-env-C-8R9SbI.js";import"./send-Dw9KZtdY.js";import"./common-CKZ-UdaB.js";import"./send-B6HPDK7K.js";import"./reply-FZOMaPdT.js";import"./github-copilot-token-C1rb4n4g.js";import"./send-bO2luPtA.js";import"./channel-web-DgBEXyWx.js";import"./tokens-B_ctrNLr.js";import"./audio-transcription-runner-CZeLqyn8.js";import"./image-DCRZu6B9.js";import"./fetch-guard-CeY6FLmB.js";import"./api-key-rotation-C1Zn1KSQ.js";import"./local-roots-mIwSmMlz.js";import"./proxy-fetch-Z4EVQXTq.js";import"./deliver-BzC2TfhO.js";import"./commands-registry-BRHbSR-Q.js";import"./pi-model-discovery-DFcVdEXI.js";import"./ir-CmAyPA_x.js";import"./render-Djx15dPh.js";import"./diagnostic-BygIW7fL.js";import"./send-CuDJ-nVd.js";import"./outbound-attachment-vo_FJhnQ.js";import"./fetch-DmxjtY1D.js";import"./send-BPtLy3DR2.js";import"./sqlite-Dc2ZB7Ip.js";import"./channel-activity-CYknJxeB.js";import"./tables-BaKxrCzf.js";import"./fetch-C1uUpK5t.js";import"./skill-commands-DnImLYRw.js";import"./manager-Dnvt2fsN.js";import{t as e}from"./outbound-BkJMbfAc.js";import"./session-D_RY5hZ0.js";import"./login-CX_oCPm4.js";import"./web-KZ3WEX08.js";export{e as sendMessageWhatsApp};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./dispatch-
|
|
1
|
+
import"./dispatch-_3aPMKVc.js";import"./paths-BMI3JiOI.js";import"./model-auth-BbZAgf5F.js";import"./logger-D7NYTfYR.js";import"./paths-DumT91r9.js";import"./proxy-env-Bz2Z8zYd.js";import"./github-copilot-token-B-n-jIjX.js";import"./send-CbKUBgfD.js";import"./send-BRcOy7d-.js";import"./send-wZQahIxo.js";import"./deliver-BOhWRuAc.js";import"./diagnostic-DVLBFxSl.js";import"./pi-model-discovery-DPml1ezH.js";import"./audio-transcription-runner-DnUZA3zd.js";import"./image-YjdiaYzj.js";import"./fetch-guard-Ddmjnr9q.js";import"./api-key-rotation-D5VrjOf1.js";import"./local-roots-D2BFeJX5.js";import"./proxy-fetch-nA0PxLDm.js";import"./tokens-CSkDa5HP.js";import"./commands-registry-BmTuvGJF.js";import"./ir-lBa1tN3e.js";import"./render-CC0AV0OP.js";import"./target-errors-D2mtlQc6.js";import"./send-DISaNhwJ.js";import"./outbound-attachment-C-WNUYRe.js";import"./fetch-C-3ngqxG.js";import"./send-B6p34YOy.js";import"./sqlite-C8QKImip.js";import"./channel-activity-CGpLziCG.js";import"./tables-7iwXnKB3.js";import"./fetch-D36SsL31.js";import"./skill-commands-Bv_AgJSD.js";import"./manager-BAawai7j.js";import{t as e}from"./outbound-CHDzLqOk.js";import"./session-9CASLgGs.js";import"./login-DFQHdh0f.js";import"./web--MzzmLKe.js";export{e as sendMessageWhatsApp};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./paths-DHIowy7j.js";import"./paths-Ilv7GN3y.js";import"./logger-Bzsdb9ed.js";import"./model-auth-m6awkcmr.js";import"./proxy-env-CjA5va0Q.js";import"./send-CJGwOpaf.js";import"./send-DfKN3gPU.js";import"./dispatch-
|
|
1
|
+
import"./paths-DHIowy7j.js";import"./paths-Ilv7GN3y.js";import"./logger-Bzsdb9ed.js";import"./model-auth-m6awkcmr.js";import"./proxy-env-CjA5va0Q.js";import"./send-CJGwOpaf.js";import"./send-DfKN3gPU.js";import"./dispatch-DPafUBvi.js";import"./tokens-D-G23Eih.js";import"./deliver-Cr9WnblM.js";import"./github-copilot-token-DjID6pAD.js";import"./fetch-guard-Ch-GE1q6.js";import"./send-Jtkjjoez.js";import"./local-roots-cD4rtFUT.js";import"./ir-C9bnqCN4.js";import"./diagnostic-D_z4RTdJ.js";import"./pi-model-discovery-BoCQComb.js";import"./audio-transcription-runner-C-1wfN5V.js";import"./image-CswbRypx.js";import"./api-key-rotation-ByGrFLLf.js";import"./proxy-fetch-DLkHTNrK.js";import"./commands-registry-sdEAg35R.js";import"./render-CC0AV0OP.js";import"./target-errors-CBtuprlS.js";import"./send-DUpWCxkR.js";import"./outbound-attachment-nHeYVKR0.js";import"./fetch-p43DsBwY.js";import"./send-BvX-weT-.js";import"./sqlite-nOhwJUyO.js";import"./channel-activity-CrUKMrr9.js";import"./tables-tvhhES0m.js";import"./fetch-p-KNjCrj.js";import"./skill-commands-D3NahROf.js";import"./manager-B6qIRY7W.js";import{t as e}from"./outbound-nE9g9HWI.js";import"./session-DbpGSWIV.js";import"./login-TBUuvDlG.js";import"./web-sUKMDnvE.js";export{e as sendMessageWhatsApp};
|