@qqbrowser/openclaw-qbot 0.0.142 → 0.0.143
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-Bpp_F5In.js → agents-D3Z05GqK.js} +2 -2
- package/dist/{agents.config-DfIJAGcd.js → agents.config-BUQjISaN.js} +2 -2
- package/dist/{agents.config-B6LRG9eP.js → agents.config-BvxrGqOT.js} +2 -2
- package/dist/{auth-choice-DvTApGhx.js → auth-choice-CYGzLW73.js} +2 -2
- package/dist/{auth-choice-EQdNd7jO.js → auth-choice-DJn6683d.js} +2 -2
- package/dist/{banner-9u45RL26.js → banner-xQa2kS6O.js} +2 -2
- 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-D2syI791.js → channel-options-BurUBfoY.js} +2 -2
- package/dist/{channel-options-CEIzjOno.js → channel-options-Ce8uNnAp.js} +2 -2
- package/dist/{channel-web-BrElpZAc.js → channel-web-D5TgFlMz.js} +2 -2
- package/dist/{channel-web-CxHbET4B.js → channel-web-D7FkrASC.js} +2 -2
- package/dist/{channels-cli-BmAJuuRs.js → channels-cli-BfzZrnkt.js} +2 -2
- package/dist/{channels-cli-Dgosczr6.js → channels-cli-DFI6F6G0.js} +2 -2
- package/dist/{cli-D8T2tphD.js → cli-CMLvfh6N.js} +2 -2
- package/dist/{cli-BcnoCo4z.js → cli-MTpYYgjl.js} +2 -2
- package/dist/{command-registry-CfuXCRwV.js → command-registry-CPthpEk3.js} +2 -2
- package/dist/{compact-Dg66DXx_.js → compact-BEeB6bwq.js} +7 -7
- package/dist/{compact.runtime-3mTLUPqu.js → compact.runtime-BC7F7HPJ.js} +1 -1
- package/dist/{compact.runtime-DcTdUW4o.js → compact.runtime-BTUQRS-2.js} +1 -1
- package/dist/{compact.runtime-Bhewj5vA.js → compact.runtime-C0GyLWem.js} +1 -1
- package/dist/{compact.runtime-XXtYlNJN.js → compact.runtime-CrOFsO5D.js} +1 -1
- package/dist/{completion-cli-C40TWdsv.js → completion-cli-C4_SZmjl.js} +2 -2
- package/dist/{completion-cli-BZi4nuQb.js → completion-cli-DeGEpJri.js} +2 -2
- package/dist/{config-cli-CBte2b1h.js → config-cli-B9hEiZsw.js} +2 -2
- package/dist/{config-cli-1ojSLwAj.js → config-cli-BNTGUqL_.js} +2 -2
- package/dist/{configure-kod4tmZa.js → configure-DForkh7R.js} +2 -2
- package/dist/{configure-DJrNDEpR.js → configure-DR77VUCy.js} +2 -2
- package/dist/{deps-send-whatsapp.runtime-C4O9crnk.js → deps-send-whatsapp.runtime-BuIiTn5n.js} +1 -1
- package/dist/{deps-send-whatsapp.runtime-5Lot99zq.js → deps-send-whatsapp.runtime-C4hGmfeP.js} +1 -1
- package/dist/{deps-send-whatsapp.runtime-LiNvHd_E.js → deps-send-whatsapp.runtime-CYlLppMS.js} +1 -1
- package/dist/{deps-send-whatsapp.runtime-Bg-_kVX6.js → deps-send-whatsapp.runtime-FY-HuZ5S.js} +1 -1
- package/dist/{doctor-completion-DMJhfrtC.js → doctor-completion-APZJ17BJ.js} +2 -2
- package/dist/{doctor-completion-BJ6steqx.js → doctor-completion-Bad_h3hm.js} +2 -2
- package/dist/entry.js +1 -1
- package/dist/extensionAPI.js +1 -1
- package/dist/{gateway-cli-CKu0FA7D.js → gateway-cli-CbJj0QhL.js} +3 -3
- package/dist/{gateway-cli-C_s9eMlC.js → gateway-cli-tXsBFRlk.js} +3 -3
- package/dist/{health-PaRHFItm.js → health-DBu0V1Y-.js} +2 -2
- package/dist/{health-BgOggK9k.js → health-RQzDNQwf.js} +2 -2
- package/dist/{hooks-cli-CsBrScq0.js → hooks-cli-B3eDoEHO.js} +2 -2
- package/dist/{hooks-cli-BzyzTNBx.js → hooks-cli-xgORhqZ2.js} +2 -2
- package/dist/index.js +2 -2
- package/dist/llm-slug-generator.js +1 -1
- package/dist/{models-C_Vg3Cty.js → models-BEO5lvkx.js} +2 -2
- package/dist/{models-cli-CDZliTXq.js → models-cli-BbcJ6A0F.js} +2 -2
- package/dist/{models-cli-bGr8jwAb.js → models-cli-Dacwv6BY.js} +2 -2
- package/dist/{npm-resolution-DWPloph4.js → npm-resolution-Bui58Ks1.js} +2 -2
- package/dist/{npm-resolution-BnJGLwhi.js → npm-resolution-Ct6MRtq6.js} +2 -2
- package/dist/{onboard-B0BNCQaO.js → onboard-7i9A1nNd.js} +3 -3
- package/dist/{onboard-CjVhdaiR.js → onboard-DSaXIS5U.js} +3 -3
- package/dist/{onboard-channels-CZK_7xMR.js → onboard-channels-BXReNh4B.js} +2 -2
- package/dist/{onboard-channels-BMIOddLN.js → onboard-channels-CjXCpXI-.js} +2 -2
- package/dist/{onboarding-ouEqUuUr.js → onboarding-BRewu6jg.js} +2 -2
- package/dist/{onboarding-B6ixWwgp.js → onboarding-RZTEMxl0.js} +2 -2
- package/dist/{onboarding.finalize-DsMVlTcH.js → onboarding.finalize-Bi53z1zE.js} +2 -2
- package/dist/{onboarding.finalize-Bgat5Npc.js → onboarding.finalize-Bp8ST2z_.js} +2 -2
- package/dist/{pi-embedded-BZSn84Bh.js → pi-embedded-B_6OtP8m.js} +7 -7
- package/dist/{pi-embedded-Dsz7p3MF.js → pi-embedded-DjX-gdoY.js} +7 -7
- package/dist/{plugin-registry-CIBiHZH1.js → plugin-registry-CI5K3iWc.js} +2 -2
- package/dist/{plugin-registry-C6dY-Et7.js → plugin-registry-CYlBYbc8.js} +2 -2
- package/dist/plugin-sdk/{channel-web-9zn1Itpg.cjs → channel-web-BSUPSLCU.cjs} +2 -2
- package/dist/plugin-sdk/{channel-web-4ZQVqsrt.js → channel-web-CeSPyNTh.js} +2 -2
- package/dist/plugin-sdk/{channel-web-BrB00HKH.js → channel-web-Cptth4mc.js} +2 -2
- package/dist/plugin-sdk/{channel-web-DN5La-Ol.cjs → channel-web-D4x22KPN.cjs} +2 -2
- package/dist/plugin-sdk/{compact.runtime-8oUv1ld1.cjs → compact.runtime-BDgWntMu.cjs} +1 -1
- package/dist/plugin-sdk/{compact.runtime-CmJayEYX.js → compact.runtime-BJFMaTF4.js} +1 -1
- package/dist/plugin-sdk/{compact.runtime-BjJCBESR.cjs → compact.runtime-BWadwUyE.cjs} +1 -1
- package/dist/plugin-sdk/{compact.runtime-ALKRoVEG.js → compact.runtime-Bfu2rMai.js} +1 -1
- package/dist/plugin-sdk/{compact.runtime-DBlESOSV.cjs → compact.runtime-Cg47oUHq.cjs} +1 -1
- package/dist/plugin-sdk/{compact.runtime-Dmc0G6Yn.js → compact.runtime-CqK86P7R.js} +1 -1
- package/dist/plugin-sdk/{compact.runtime-Chumwp0K.cjs → compact.runtime-CqrB25-A.cjs} +1 -1
- package/dist/plugin-sdk/{compact.runtime-Ddfxp3fz.js → compact.runtime-DeATtENL.js} +1 -1
- package/dist/plugin-sdk/{compact.runtime-C_dc78Lp.cjs → compact.runtime-GMu30Jmw.cjs} +1 -1
- package/dist/plugin-sdk/{compact.runtime-ZrApPcrV.js → compact.runtime-YFzugj-k.js} +1 -1
- package/dist/plugin-sdk/{compact.runtime-BF4SCZ-5.js → compact.runtime-a8Z4_6wu.js} +1 -1
- package/dist/plugin-sdk/{compact.runtime-CbzQiVEW.cjs → compact.runtime-jGNfnpo2.cjs} +1 -1
- package/dist/plugin-sdk/compat.cjs +1 -1
- package/dist/plugin-sdk/compat.js +1 -1
- package/dist/plugin-sdk/{deps-send-whatsapp.runtime-BEDFRjff.js → deps-send-whatsapp.runtime-23E2Ab5R.js} +1 -1
- package/dist/plugin-sdk/{deps-send-whatsapp.runtime-QY0XTSgX.cjs → deps-send-whatsapp.runtime-B1oA3XBA.cjs} +1 -1
- package/dist/plugin-sdk/{deps-send-whatsapp.runtime-Du_3Rw7K.cjs → deps-send-whatsapp.runtime-C8q_3sOf.cjs} +1 -1
- package/dist/plugin-sdk/{deps-send-whatsapp.runtime-DMeaTnvE.cjs → deps-send-whatsapp.runtime-CsebM75z.cjs} +1 -1
- package/dist/plugin-sdk/{deps-send-whatsapp.runtime-CrVVnzLl.js → deps-send-whatsapp.runtime-D3mYdwaT.js} +1 -1
- package/dist/plugin-sdk/{deps-send-whatsapp.runtime-DR4rvUQL.js → deps-send-whatsapp.runtime-DDwUEbJ8.js} +1 -1
- package/dist/plugin-sdk/{deps-send-whatsapp.runtime-BULlOkpi.cjs → deps-send-whatsapp.runtime-Di3p_3Eh.cjs} +1 -1
- package/dist/plugin-sdk/{deps-send-whatsapp.runtime--uXLMs1C.js → deps-send-whatsapp.runtime-JzRD4jTI.js} +1 -1
- package/dist/plugin-sdk/{deps-send-whatsapp.runtime-BRjb9631.cjs → deps-send-whatsapp.runtime-gEp895yA.cjs} +1 -1
- package/dist/plugin-sdk/{deps-send-whatsapp.runtime-VQXeRmRl.js → deps-send-whatsapp.runtime-iV5E6CHf.js} +1 -1
- package/dist/plugin-sdk/{deps-send-whatsapp.runtime-2Us9O7dL.cjs → deps-send-whatsapp.runtime-k0yGrhs2.cjs} +1 -1
- package/dist/plugin-sdk/{deps-send-whatsapp.runtime-BfV5Q2fx.js → deps-send-whatsapp.runtime-v3sqBoDg.js} +1 -1
- package/dist/plugin-sdk/{dispatch-C2YTqGlf.js → dispatch-3PrSaGZi.js} +7 -7
- package/dist/plugin-sdk/{dispatch-DHbSBeFJ.js → dispatch-Bcf1uPHo.js} +7 -7
- package/dist/plugin-sdk/{dispatch-SWyfAZT0.cjs → dispatch-BgGE9usQ.cjs} +7 -7
- package/dist/plugin-sdk/{dispatch-BYlcmJ9u.js → dispatch-BhUN9ZDP.js} +7 -7
- package/dist/plugin-sdk/{dispatch-DK5ub8qa.cjs → dispatch-C3k8j6Zb.cjs} +7 -7
- package/dist/plugin-sdk/{dispatch-DCSwqteL.js → dispatch-C_gJPvbD.js} +7 -7
- package/dist/plugin-sdk/{dispatch-5v3v8zzA.js → dispatch-Df8B7owq.js} +7 -7
- package/dist/plugin-sdk/{dispatch-CNy3g9ma.cjs → dispatch-YK0qHNtb.cjs} +7 -7
- package/dist/plugin-sdk/{dispatch-B6UbZCpL.cjs → dispatch-_fZDA253.cjs} +7 -7
- package/dist/plugin-sdk/{dispatch-mR2vLkGa.cjs → dispatch-wEH2eS4y.cjs} +7 -7
- package/dist/plugin-sdk/index.cjs +1 -1
- package/dist/plugin-sdk/index.js +1 -1
- package/dist/plugin-sdk/irc.cjs +1 -1
- package/dist/plugin-sdk/irc.js +1 -1
- package/dist/plugin-sdk/matrix.cjs +1 -1
- package/dist/plugin-sdk/matrix.js +1 -1
- package/dist/plugin-sdk/msteams.cjs +1 -1
- package/dist/plugin-sdk/msteams.js +1 -1
- package/dist/plugin-sdk/nextcloud-talk.cjs +1 -1
- package/dist/plugin-sdk/nextcloud-talk.js +1 -1
- package/dist/plugin-sdk/{reply-0zCEbT4w.cjs → reply-BoWg-IXT.cjs} +7 -7
- package/dist/plugin-sdk/{reply-D-f2bbXy.js → reply-bS9U9BwG.js} +7 -7
- package/dist/plugin-sdk/{slash-dispatch.runtime-CNhhOTEP.js → slash-dispatch.runtime-4y3z-kPo.js} +1 -1
- package/dist/plugin-sdk/{slash-dispatch.runtime-B3b2L4iH.js → slash-dispatch.runtime-BRr9YGOs.js} +1 -1
- package/dist/plugin-sdk/{slash-dispatch.runtime-CPPp4KKH.cjs → slash-dispatch.runtime-BtdMVJQe.cjs} +1 -1
- package/dist/plugin-sdk/{slash-dispatch.runtime-Dw9M-fvv.js → slash-dispatch.runtime-C6iak1_0.js} +1 -1
- package/dist/plugin-sdk/{slash-dispatch.runtime-BoTYqNiv.js → slash-dispatch.runtime-CMx727dE.js} +1 -1
- package/dist/plugin-sdk/{slash-dispatch.runtime-CaWoVNJu.cjs → slash-dispatch.runtime-CXXaAMYa.cjs} +1 -1
- package/dist/plugin-sdk/{slash-dispatch.runtime-DbheDKxM.cjs → slash-dispatch.runtime-Cvom2Onl.cjs} +1 -1
- package/dist/plugin-sdk/{slash-dispatch.runtime-DpBWBF7J.js → slash-dispatch.runtime-D00kIROj.js} +1 -1
- package/dist/plugin-sdk/{slash-dispatch.runtime-DSQ2U0MM.cjs → slash-dispatch.runtime-DEu-D4XB.cjs} +1 -1
- package/dist/plugin-sdk/{slash-dispatch.runtime-Bu6Gwr3m.cjs → slash-dispatch.runtime-DG7_jQXD.cjs} +1 -1
- package/dist/plugin-sdk/{slash-dispatch.runtime-CCEMBSm2.cjs → slash-dispatch.runtime-DVP1q-_z.cjs} +1 -1
- package/dist/plugin-sdk/{slash-dispatch.runtime-Dm_cVnlq.js → slash-dispatch.runtime-U6qjtCfd.js} +1 -1
- package/dist/plugin-sdk/{subagent-registry-runtime-bVH8kl6Y.js → subagent-registry-runtime-BD_DkCmR.js} +1 -1
- package/dist/plugin-sdk/{subagent-registry-runtime-Der4fbZK.cjs → subagent-registry-runtime-BWiMCyG_.cjs} +1 -1
- package/dist/plugin-sdk/{subagent-registry-runtime-Pp_rfnk0.js → subagent-registry-runtime-C6vGkwe9.js} +1 -1
- package/dist/plugin-sdk/{subagent-registry-runtime-B0cZ_eaC.cjs → subagent-registry-runtime-CCcI3vhb.cjs} +1 -1
- package/dist/plugin-sdk/{subagent-registry-runtime-B-P4w-z9.js → subagent-registry-runtime-CDCU--WW.js} +1 -1
- package/dist/plugin-sdk/{subagent-registry-runtime-Ciev9m2W.cjs → subagent-registry-runtime-D98xiwmA.cjs} +1 -1
- package/dist/plugin-sdk/{subagent-registry-runtime-DBPvxiJW.cjs → subagent-registry-runtime-LebBdxD7.cjs} +1 -1
- package/dist/plugin-sdk/{subagent-registry-runtime-BfmeSbXD.cjs → subagent-registry-runtime-MfHdezNY.cjs} +1 -1
- package/dist/plugin-sdk/{subagent-registry-runtime-CL0sdx5J.cjs → subagent-registry-runtime-bMabqk9V.cjs} +1 -1
- package/dist/plugin-sdk/{subagent-registry-runtime-DH_Jx5hU.js → subagent-registry-runtime-h3qrqiJH.js} +1 -1
- package/dist/plugin-sdk/{subagent-registry-runtime-CEvE9keW.js → subagent-registry-runtime-tmI7JUke.js} +1 -1
- package/dist/plugin-sdk/{subagent-registry-runtime-Du8BhjzJ.js → subagent-registry-runtime-uC8wbfNS.js} +1 -1
- package/dist/plugin-sdk/{web-BdnQzLgF.js → web-9Os8v8Cu.js} +2 -2
- package/dist/plugin-sdk/{web-pcTha_l7.cjs → web-BQ9hOKe8.cjs} +2 -2
- package/dist/plugin-sdk/{web-C9T7tf6w.js → web-Bjk0MWu3.js} +2 -2
- package/dist/plugin-sdk/{web-_tj8xNZE.js → web-BsmnVZaX.js} +2 -2
- package/dist/plugin-sdk/{web-B2PwjHsu.cjs → web-CUbdclQS.cjs} +2 -2
- package/dist/plugin-sdk/{web-CcYBsmAj.cjs → web-C_Vx3mgY.cjs} +1 -1
- package/dist/plugin-sdk/{web-BZoOYDwf.js → web-Cdo1e0C7.js} +1 -1
- package/dist/plugin-sdk/{web-CODD4ksc.cjs → web-CfTkaUMk.cjs} +2 -2
- package/dist/plugin-sdk/{web-24o5tNe3.js → web-DkmdYSZ8.js} +1 -1
- package/dist/plugin-sdk/{web-B-QDcVRv.cjs → web-DpGXJ6SQ.cjs} +2 -2
- package/dist/plugin-sdk/{web-Czl9vNVv.cjs → web-DuF9udb6.cjs} +1 -1
- package/dist/plugin-sdk/{web-CkdCvvR-.js → web-Jr2J55LO.js} +2 -2
- package/dist/plugin-sdk/whatsapp.cjs +1 -1
- package/dist/plugin-sdk/whatsapp.js +1 -1
- package/dist/{plugins-cli-BiVMAr5T.js → plugins-cli-BzJeq-CW.js} +2 -2
- package/dist/{plugins-cli-BbjMbzJU.js → plugins-cli-o74CJV4A.js} +2 -2
- package/dist/{program-BrAZTwFr.js → program-D9AMAbv6.js} +3 -3
- package/dist/{program-context-B9ydtPje.js → program-context-BX9wN65q.js} +2 -2
- package/dist/{prompt-select-styled-BeJNbzSa.js → prompt-select-styled-C2c13Ndq.js} +2 -2
- package/dist/{prompt-select-styled-DIOWLjl0.js → prompt-select-styled-hxyoyq2i.js} +2 -2
- package/dist/{provider-auth-helpers-pBVCjBj9.js → provider-auth-helpers-BzlcSA6U.js} +2 -2
- package/dist/{provider-auth-helpers-1lU43eTW.js → provider-auth-helpers-CDIiLD1m.js} +2 -2
- package/dist/{push-apns-BGUOmD5M.js → push-apns-CrAWstBo.js} +2 -2
- package/dist/{push-apns-B_a2MBJ4.js → push-apns-CrMV74Qs.js} +2 -2
- package/dist/{register.agent-CX78s_X9.js → register.agent-CisptTv_.js} +2 -2
- package/dist/{register.agent-DLDKQENq.js → register.agent-Dl2Ef-K5.js} +2 -2
- package/dist/{register.configure-BA5u9hT3.js → register.configure-CvPihXst.js} +2 -2
- package/dist/{register.configure-BhPtf3Qo.js → register.configure-D8bJJ16k.js} +2 -2
- package/dist/{register.maintenance-BhsBepKS.js → register.maintenance-AeTvVTtt.js} +2 -2
- package/dist/{register.maintenance-r_MzNK3-.js → register.maintenance-BkM8-Ttt.js} +2 -2
- package/dist/{register.message-CTF--Z2a.js → register.message-3zVHQZ27.js} +2 -2
- package/dist/{register.message-jcZ875be.js → register.message-CM_Qudzn.js} +2 -2
- package/dist/{register.onboard-C3yL50_c.js → register.onboard-BY-QLNp9.js} +2 -2
- package/dist/{register.onboard-CNwnStUk.js → register.onboard-C-j99DGw.js} +2 -2
- package/dist/{register.setup-BRJMzgfU.js → register.setup-DA4HFCro.js} +2 -2
- package/dist/{register.setup-BvsS-zgm.js → register.setup-DiAi_1pJ.js} +2 -2
- package/dist/{register.status-health-sessions-Dqmkw820.js → register.status-health-sessions-BXiMraHZ.js} +2 -2
- package/dist/{register.status-health-sessions-DVc__2pc.js → register.status-health-sessions-Bo9VWxLG.js} +2 -2
- package/dist/{register.subclis-D-24j83X.js → register.subclis-smZuHVcv.js} +2 -2
- package/dist/{reply-l-Y47HP4.js → reply-CjyZeZ-j.js} +7 -7
- package/dist/{run-main-B_YBE_TN.js → run-main-DEZR4lCo.js} +2 -2
- package/dist/{server-node-events-CFSY_-4t.js → server-node-events-BWiQg1NL.js} +2 -2
- package/dist/{server-node-events-ZFwmPwQ-.js → server-node-events-DicMyck-.js} +2 -2
- package/dist/{slash-dispatch.runtime-pdAIQrzR.js → slash-dispatch.runtime-CGgP5dBX.js} +1 -1
- package/dist/{slash-dispatch.runtime-CKWXmLO1.js → slash-dispatch.runtime-CknX8Fkv.js} +1 -1
- package/dist/{slash-dispatch.runtime-DIR5H2MY.js → slash-dispatch.runtime-CoKGpcpS.js} +1 -1
- package/dist/{slash-dispatch.runtime-14ABU-DD.js → slash-dispatch.runtime-pSpPe8qL.js} +1 -1
- package/dist/{status-DYqPF0rB.js → status-BoL8-JxA.js} +2 -2
- package/dist/{status-JIPeVrsc.js → status-DEAX-TLb.js} +2 -2
- package/dist/{subagent-registry-runtime-rPbwTnju.js → subagent-registry-runtime-2Nh6-7ym.js} +1 -1
- package/dist/{subagent-registry-runtime-DTVXQJOP.js → subagent-registry-runtime-CG_2Atu3.js} +1 -1
- package/dist/{subagent-registry-runtime-Cj4CKKl_.js → subagent-registry-runtime-Cc264UfD.js} +1 -1
- package/dist/{subagent-registry-runtime-8_ktZPZB.js → subagent-registry-runtime-CpYm78z3.js} +1 -1
- package/dist/{update-cli-BwBMOeP0.js → update-cli-C0qadZEs.js} +2 -2
- package/dist/{update-cli-YrBbmw4f.js → update-cli-ISorpxrU.js} +2 -2
- package/dist/{update-runner-BvtyRBD2.js → update-runner-CvWH2ZAc.js} +2 -2
- package/dist/{update-runner-DYamgo1V.js → update-runner-mMbwEOlU.js} +2 -2
- package/dist/{web-DwcxsgH0.js → web-ARUUCMQo.js} +2 -2
- package/dist/{web-C15yQ-wI.js → web-C6jRFeYp.js} +1 -1
- package/dist/{web-C6So15hm.js → web-CDXYiCsB.js} +1 -1
- package/dist/{web-Cq3xWCaD.js → web-CiagxaWr.js} +2 -2
- package/node_modules/@aws-sdk/client-bedrock-runtime/package.json +42 -42
- package/node_modules/@aws-sdk/core/dist-cjs/index.js +17 -0
- package/node_modules/@aws-sdk/core/dist-cjs/submodules/client/index.js +17 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/client/index.js +1 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/client/longPollMiddleware.js +15 -0
- package/node_modules/@aws-sdk/core/package.json +11 -11
- package/node_modules/@aws-sdk/credential-provider-env/package.json +5 -5
- package/node_modules/@aws-sdk/credential-provider-http/package.json +10 -10
- package/node_modules/@aws-sdk/credential-provider-ini/package.json +14 -14
- package/node_modules/@aws-sdk/credential-provider-login/package.json +8 -8
- package/node_modules/@aws-sdk/credential-provider-node/package.json +12 -12
- package/node_modules/@aws-sdk/credential-provider-process/package.json +6 -6
- package/node_modules/@aws-sdk/credential-provider-sso/package.json +8 -8
- package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +7 -7
- package/node_modules/@aws-sdk/eventstream-handler-node/package.json +4 -4
- package/node_modules/@aws-sdk/middleware-eventstream/package.json +4 -4
- package/node_modules/@aws-sdk/middleware-host-header/package.json +4 -4
- package/node_modules/@aws-sdk/middleware-logger/package.json +3 -3
- package/node_modules/@aws-sdk/middleware-recursion-detection/package.json +4 -4
- package/node_modules/@aws-sdk/middleware-user-agent/package.json +8 -8
- package/node_modules/@aws-sdk/middleware-websocket/package.json +9 -9
- package/node_modules/@aws-sdk/nested-clients/package.json +32 -32
- package/node_modules/@aws-sdk/region-config-resolver/package.json +5 -5
- package/node_modules/@aws-sdk/token-providers/package.json +7 -7
- package/node_modules/@aws-sdk/types/package.json +2 -2
- package/node_modules/@aws-sdk/util-endpoints/package.json +5 -5
- package/node_modules/@aws-sdk/util-format-url/package.json +4 -4
- package/node_modules/@aws-sdk/util-user-agent-browser/package.json +3 -3
- package/node_modules/@aws-sdk/util-user-agent-node/package.json +5 -5
- package/node_modules/@aws-sdk/xml-builder/package.json +2 -2
- package/node_modules/@whiskeysockets/baileys/node_modules/p-queue/dist/index.js +1 -0
- package/node_modules/@whiskeysockets/baileys/node_modules/p-queue/package.json +1 -1
- package/node_modules/content-disposition/index.js +118 -40
- package/node_modules/content-disposition/package.json +8 -11
- package/node_modules/path-expression-matcher/lib/pem.cjs +1 -1
- package/node_modules/path-expression-matcher/lib/pem.d.cts +18 -0
- package/node_modules/path-expression-matcher/lib/pem.min.js +1 -1
- package/node_modules/path-expression-matcher/package.json +1 -1
- package/node_modules/path-expression-matcher/src/Expression.js +2 -2
- package/node_modules/path-expression-matcher/src/ExpressionSet.js +24 -4
- package/package.json +1 -1
- package/preset-config.json +1 -1
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/LICENSE +0 -201
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/README.md +0 -62
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-cjs/index.js +0 -157
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/constants.js +0 -2
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/fromEnvSigningName.js +0 -16
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/fromSso.js +0 -81
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/fromStatic.js +0 -8
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/getNewSsoOidcToken.js +0 -11
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/getSsoOidcClient.js +0 -10
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/index.js +0 -4
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/nodeProvider.js +0 -5
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/validateTokenExpiry.js +0 -7
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/validateTokenKey.js +0 -7
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/writeSSOTokenToFile.js +0 -8
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/package.json +0 -70
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as e}from"./rolldown-runtime-CNxR59P3.js";import{A as t,k as n,p as r,t as i,y as a}from"./subsystem-BLbY429l.js";import{i as o}from"./entry.js";import{En as s,Ft as c,Lt as l,Po as u,Tn as d,jo as f,jt as p}from"./auth-profiles-T8DuH3ax.js";import{b as m,d as h,f as g,i as _}from"./agent-scope-DAWJwFfl.js";import{E as v,c as y,h as b,u as x}from"./session-key-C7F_iqYg.js";import{c as S}from"./utils-CGdo13HV.js";import{t as C}from"./parse-duration-XTjMKl8s.js";import{g as w,lt as T,n as E,t as D,v as O}from"./plugins-DNlgeTTc.js";import{a as k,r as A}from"./errors-6SQWM9dj.js";import{$r as j,Ar as M,Nr as N,Q as ee,Tn as P,ai as te,ci as F,ct as ne,oi as re,ot as ie,pr as ae,si as I,sr as oe,st as se,ut as ce,vt as le,yt as ue}from"./compact-
|
|
1
|
+
import{t as e}from"./rolldown-runtime-CNxR59P3.js";import{A as t,k as n,p as r,t as i,y as a}from"./subsystem-BLbY429l.js";import{i as o}from"./entry.js";import{En as s,Ft as c,Lt as l,Po as u,Tn as d,jo as f,jt as p}from"./auth-profiles-T8DuH3ax.js";import{b as m,d as h,f as g,i as _}from"./agent-scope-DAWJwFfl.js";import{E as v,c as y,h as b,u as x}from"./session-key-C7F_iqYg.js";import{c as S}from"./utils-CGdo13HV.js";import{t as C}from"./parse-duration-XTjMKl8s.js";import{g as w,lt as T,n as E,t as D,v as O}from"./plugins-DNlgeTTc.js";import{a as k,r as A}from"./errors-6SQWM9dj.js";import{$r as j,Ar as M,Nr as N,Q as ee,Tn as P,ai as te,ci as F,ct as ne,oi as re,ot as ie,pr as ae,si as I,sr as oe,st as se,ut as ce,vt as le,yt as ue}from"./compact-BEeB6bwq.js";import{c as L,n as de}from"./paths-BfjJY2VL.js";import{t as R}from"./tokens-DRM8vzJx.js";import{t as z}from"./deliver-BHuhHfkH.js";import{n as fe,t as pe}from"./call-B8Fb4_oh.js";import{n as me}from"./progress-d1m2sqR1.js";import{a as B,n as V,o as he,t as ge}from"./heartbeat-visibility-BQ_esv2m.js";import H from"node:path";import U from"node:fs/promises";const _e=/^(?:([01]\d|2[0-3]):([0-5]\d)|24:00)$/;function ve(e,t){let n=t?.trim();if(!n||n===`user`)return N(e.agents?.defaults?.userTimezone);if(n===`local`)return Intl.DateTimeFormat().resolvedOptions().timeZone?.trim()||`UTC`;try{return new Intl.DateTimeFormat(`en-US`,{timeZone:n}).format(new Date),n}catch{return N(e.agents?.defaults?.userTimezone)}}function W(e,t){if(!t||!_e.test(t))return null;let[n,r]=t.split(`:`),i=Number(n),a=Number(r);return!Number.isFinite(i)||!Number.isFinite(a)?null:i===24?!e.allow24||a!==0?null:1440:i*60+a}function ye(e,t){try{let n=new Intl.DateTimeFormat(`en-US`,{timeZone:t,hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}).formatToParts(new Date(e)),r={};for(let e of n)e.type!==`literal`&&(r[e.type]=e.value);let i=Number(r.hour),a=Number(r.minute);return!Number.isFinite(i)||!Number.isFinite(a)?null:i*60+a}catch{return null}}function be(e,t,n){let r=t?.activeHours;if(!r)return!0;let i=W({allow24:!1},r.start),a=W({allow24:!0},r.end);if(i===null||a===null)return!0;if(i===a)return!1;let o=ve(e,r.timezone),s=ye(n??Date.now(),o);return s===null?!0:a>i?s>=i&&s<a:s>=i||s<a}function xe(e,t){let n=t?.deliverToUser??!0,r=e.join(`
|
|
2
2
|
`).trim();return r?n?`A scheduled reminder has been triggered. The reminder content is:
|
|
3
3
|
|
|
4
4
|
`+r+`
|
|
@@ -10,4 +10,4 @@ Please relay this reminder to the user in a helpful and friendly way.`:`A schedu
|
|
|
10
10
|
Handle this reminder internally. Do not relay it to the user unless explicitly requested.`:n?`A scheduled cron event was triggered, but no event content was found. Reply HEARTBEAT_OK.`:`A scheduled cron event was triggered, but no event content was found. Handle this internally and reply HEARTBEAT_OK when nothing needs user-facing follow-up.`}function Se(e){return e?.deliverToUser??!0?`An async command you ran earlier has completed. The result is shown in the system messages above. Please relay the command output to the user in a helpful way. If the command succeeded, share the relevant output. If it failed, explain what went wrong.`:`An async command you ran earlier has completed. The result is shown in the system messages above. Handle the result internally. Do not relay it to the user unless explicitly requested.`}const Ce=R.toLowerCase();function we(e){let t=e.trim();if(!t)return!1;let n=t.toLowerCase();if(!n.startsWith(Ce))return!1;let r=n.slice(Ce.length);return r.length===0?!0:!/[a-z0-9_]/.test(r[0])}function Te(e){let t=e.trim().toLowerCase();return t?we(t)||t.includes(`heartbeat poll`)||t.includes(`heartbeat wake`):!1}function Ee(e){return e.toLowerCase().includes(`exec finished`)}function De(e){return e.trim()?!Te(e)&&!Ee(e):!1}const G=i(`gateway/heartbeat`),Oe=`none`;function ke(e){return(e.agents?.list??[]).some(e=>!!e?.heartbeat)}function Ae(e,t){let n=y(t??g(e)),r=e.agents?.list??[];return ke(e)?r.some(e=>!!e?.heartbeat&&y(e?.id)===n):n===g(e)}function K(e,t){let n=e.agents?.defaults?.heartbeat;if(!t)return n;let r=_(e,t)?.heartbeat;return!n&&!r?r:{...n,...r}}function je(e,t){let n=e.agents?.defaults?.heartbeat,r=t?_(e,t)?.heartbeat:void 0;if(!Ae(e,t))return{enabled:!1,every:`disabled`,everyMs:null,prompt:I(n?.prompt),target:n?.target??Oe,model:n?.model,ackMaxChars:Math.max(0,n?.ackMaxChars??300)};let i=n||r?{...n,...r}:void 0;return{enabled:!0,every:i?.every??n?.every??r?.every??`30m`,everyMs:q(e,void 0,i),prompt:I(i?.prompt??n?.prompt??r?.prompt),target:i?.target??n?.target??r?.target??Oe,model:i?.model??n?.model??r?.model,ackMaxChars:Math.max(0,i?.ackMaxChars??n?.ackMaxChars??r?.ackMaxChars??300)}}function Me(e){let t=e.agents?.list??[];if(ke(e))return t.filter(e=>e?.heartbeat).map(t=>{let n=y(t.id);return{agentId:n,heartbeat:K(e,n)}}).filter(e=>e.agentId);let n=g(e);return[{agentId:n,heartbeat:K(e,n)}]}function q(e,t,n){let r=t??n?.every??e.agents?.defaults?.heartbeat?.every??`30m`;if(!r)return null;let i=String(r).trim();if(!i)return null;let a;try{a=C(i,{defaultUnit:`m`})}catch{return null}return a<=0?null:a}function Ne(e,t){return I(t?.prompt??e.agents?.defaults?.heartbeat?.prompt)}function Pe(e,t){return Math.max(0,t?.ackMaxChars??e.agents?.defaults?.heartbeat?.ackMaxChars??300)}function Fe(e,t,n,r){let i=e.session,a=i?.scope??`per-sender`,o=y(t??g(e)),c=a===`global`?`global`:s({cfg:e,agentId:o}),l=a===`global`?g(e):o,u=L(i?.store,{agentId:l}),f=p(u),m=f[c];if(a===`global`)return{sessionKey:c,storePath:u,store:f,entry:m};let h=r?.trim();if(h){let t=d({cfg:e,agentId:o,sessionKey:b({agentId:o,requestKey:h,mainKey:e.session?.mainKey})});if(t!==`global`&&x(t)===y(o))return{sessionKey:t,storePath:u,store:f,entry:f[t]}}let _=n?.session?.trim()??``;if(!_)return{sessionKey:c,storePath:u,store:f,entry:m};let v=_.toLowerCase();if(v===`main`||v===`global`)return{sessionKey:c,storePath:u,store:f,entry:m};let S=d({cfg:e,agentId:o,sessionKey:b({agentId:o,requestKey:_,mainKey:e.session?.mainKey})});return S!==`global`&&x(S)===y(o)?{sessionKey:S,storePath:u,store:f,entry:f[S]}:{sessionKey:c,storePath:u,store:f,entry:m}}function Ie(e){return(Array.isArray(e)?e:e?[e]:[]).filter(e=>(typeof e.text==`string`?e.text:``).trimStart().startsWith(`Reasoning:`))}async function J(e){let{storePath:t,sessionKey:n,updatedAt:r}=e;if(typeof r!=`number`)return;let i=p(t)[n];if(!i)return;let a=Math.max(i.updatedAt??0,r);i.updatedAt!==a&&await l(t,e=>{let t=e[n]??i;if(!t)return;let a=Math.max(t.updatedAt??0,r);t.updatedAt!==a&&(e[n]={...t,updatedAt:a})})}async function Y(e){let{transcriptPath:t,preHeartbeatSize:n}=e;if(!(!t||typeof n!=`number`||n<0))try{(await U.stat(t)).size>n&&await U.truncate(t,n)}catch{}}async function Le(e){let{storePath:t,sessionKey:n,agentId:r}=e;try{let e=p(t)[n];if(!e?.sessionId)return{};let i=de(e.sessionId,e,{agentId:r,sessionsDir:H.dirname(t)});return{transcriptPath:i,preHeartbeatSize:(await U.stat(i)).size}}catch{return{}}}function Re(e,t){let n=t?.trim();if(!n)return e;let r=RegExp(`^${S(n)}(?=$|\\s|[\\p{P}\\p{S}])\\s*`,`iu`);return e.replace(r,``)}function ze(e,t,n){let r=F(Re(typeof e.text==`string`?e.text:``,t),{mode:`heartbeat`,maxAckChars:n}),i=!!(e.mediaUrl||(e.mediaUrls?.length??0)>0);if(r.shouldSkip&&!i)return{shouldSkip:!0,text:``,hasMedia:i};let a=r.text;return t&&a&&!a.startsWith(t)&&(a=`${t} ${a}`),{shouldSkip:!1,text:a,hasMedia:i}}function Be(e){let t=ce(e);return{isExecEventReason:t===`exec-event`,isCronEventReason:t===`cron`,isWakeReason:t===`wake`||t===`hook`}}async function Ve(e){let t=Be(e.reason),n=Fe(e.cfg,e.agentId,e.heartbeat,e.forcedSessionKey),r=P(n.sessionKey),i=r.some(e=>e.contextKey?.startsWith(`cron:`)),a=t.isExecEventReason||t.isCronEventReason||i,o=t.isExecEventReason||t.isCronEventReason||t.isWakeReason||i,s={...t,session:n,pendingEventEntries:r,hasTaggedCronEvents:i,shouldInspectPendingEvents:a};if(o)return s;let c=h(e.cfg,e.agentId),l=H.join(c,m);try{if(re(await U.readFile(l,`utf-8`)))return{...s,skipReason:`empty-heartbeat-file`}}catch(e){if(k(e,`ENOENT`))return s}return s}function He(e,t){if(!/heartbeat\.md/i.test(e))return e;let n=`When reading HEARTBEAT.md, use workspace file ${H.join(t,m).replace(/\\/g,`/`)} (exact case). Do not read docs/heartbeat.md.`;return e.includes(n)?e:`${e}\n${n}`}function Ue(e){let t=e.preflight.pendingEventEntries,n=e.preflight.shouldInspectPendingEvents?t.map(e=>e.text):[],r=t.filter(t=>(e.preflight.isCronEventReason||t.contextKey?.startsWith(`cron:`))&&De(t.text)).map(e=>e.text),i=n.some(Ee),a=r.length>0;return{prompt:He(i?Se({deliverToUser:e.canRelayToUser}):a?xe(r,{deliverToUser:e.canRelayToUser}):Ne(e.cfg,e.heartbeat),e.workspaceDir),hasExecCompletion:i,hasCronEvents:a}}async function We(e){let t=e.cfg??f(),n=typeof e.agentId==`string`?e.agentId.trim():``,r=n.length>0?void 0:v(e.sessionKey)?.agentId,i=y(n||r||g(t)),a=e.heartbeat??K(t,i);if(!ie()||!Ae(t,i)||!q(t,void 0,a))return{status:`skipped`,reason:`disabled`};let o=e.deps?.nowMs?.()??Date.now();if(!be(t,a,o))return{status:`skipped`,reason:`quiet-hours`};if((e.deps?.getQueueSize??j)(te.Main)>0)return{status:`skipped`,reason:`requests-in-flight`};let s=await Ve({cfg:t,agentId:i,heartbeat:a,forcedSessionKey:e.sessionKey,reason:e.reason});if(s.skipReason)return V({status:`skipped`,reason:s.skipReason,durationMs:Date.now()-o}),{status:`skipped`,reason:s.skipReason};let{entry:l,sessionKey:u,storePath:d}=s.session,m=l?.updatedAt,_=le({cfg:t,entry:l,heartbeat:a}),b=a?.accountId?.trim();_.reason===`unknown-account`?G.warn(`heartbeat: unknown accountId`,{accountId:_.accountId??b??null,target:a?.target??`none`}):b&&G.info(`heartbeat: using explicit accountId`,{accountId:_.accountId??b,target:a?.target??`none`,channel:_.channel});let x=_.channel===`none`?{showOk:!1,showAlerts:!0,useIndicator:!0}:ge({cfg:t,channel:_.channel,accountId:_.accountId}),{sender:S}=ue({cfg:t,entry:l,delivery:_}),C=M(t,i,{channel:_.channel===`none`?void 0:_.channel,accountId:_.accountId}).responsePrefix,{prompt:w,hasExecCompletion:T,hasCronEvents:E}=Ue({cfg:t,heartbeat:a,preflight:s,canRelayToUser:!!(_.channel!==`none`&&_.to&&x.showAlerts),workspaceDir:h(t,i)}),O={Body:ae(w,t,o),From:S,To:S,OriginatingChannel:_.channel===`none`?void 0:_.channel,OriginatingTo:_.to,AccountId:_.accountId,MessageThreadId:_.threadId,Provider:T?`exec-event`:E?`cron-event`:`heartbeat`,SessionKey:u};if(!x.showAlerts&&!x.showOk&&!x.useIndicator)return V({status:`skipped`,reason:`alerts-disabled`,durationMs:Date.now()-o,channel:_.channel===`none`?void 0:_.channel,accountId:_.accountId}),{status:`skipped`,reason:`alerts-disabled`};let k=C?`${C} ${R}`:R,N=oe({cfg:t,agentId:i,sessionKey:u}),P=!!(x.showOk&&_.channel!==`none`&&_.to),F=async()=>{if(!P||_.channel===`none`||!_.to)return!1;let n=D(_.channel);return n?.heartbeat?.checkReady&&!(await n.heartbeat.checkReady({cfg:t,accountId:_.accountId,deps:e.deps})).ok?!1:(await z({cfg:t,channel:_.channel,to:_.to,accountId:_.accountId,threadId:_.threadId,payloads:[{text:k}],session:N,deps:e.deps}),!0)};try{let n=await Le({storePath:d,sessionKey:u,agentId:i}),r=a?.model?.trim()||void 0,s=a?.suppressToolErrorWarnings===!0,f=a?.lightContext===!0?`lightweight`:void 0,h=await ee(O,r?{isHeartbeat:!0,heartbeatModelOverride:r,suppressToolErrorWarnings:s,bootstrapContextMode:f}:{isHeartbeat:!0,suppressToolErrorWarnings:s,bootstrapContextMode:f},t),g=he(h),v=a?.includeReasoning===!0?Ie(h).filter(e=>e!==g):[];if(!g||!g.text&&!g.mediaUrl&&!g.mediaUrls?.length){await J({storePath:d,sessionKey:u,updatedAt:m}),await Y(n);let t=await F();return V({status:`ok-empty`,reason:e.reason,durationMs:Date.now()-o,channel:_.channel===`none`?void 0:_.channel,accountId:_.accountId,silent:!t,indicatorType:x.useIndicator?B(`ok-empty`):void 0}),{status:`ran`,durationMs:Date.now()-o}}let y=ze(g,C,Pe(t,a)),b=T&&!y.text.trim()&&g.text?.trim()?g.text.trim():null;b&&(y.text=b,y.shouldSkip=!1);let S=y.shouldSkip&&!y.hasMedia&&!T;if(S&&v.length===0){await J({storePath:d,sessionKey:u,updatedAt:m}),await Y(n);let t=await F();return V({status:`ok-token`,reason:e.reason,durationMs:Date.now()-o,channel:_.channel===`none`?void 0:_.channel,accountId:_.accountId,silent:!t,indicatorType:x.useIndicator?B(`ok-token`):void 0}),{status:`ran`,durationMs:Date.now()-o}}let w=g.mediaUrls??(g.mediaUrl?[g.mediaUrl]:[]),E=typeof l?.lastHeartbeatText==`string`?l.lastHeartbeatText:``,k=typeof l?.lastHeartbeatSentAt==`number`?l.lastHeartbeatSentAt:void 0;if(!S&&!w.length&&E.trim()&&y.text.trim()===E.trim()&&typeof k==`number`&&o-k<1440*60*1e3)return await J({storePath:d,sessionKey:u,updatedAt:m}),await Y(n),V({status:`skipped`,reason:`duplicate`,preview:y.text.slice(0,200),durationMs:Date.now()-o,hasMedia:!1,channel:_.channel===`none`?void 0:_.channel,accountId:_.accountId}),{status:`ran`,durationMs:Date.now()-o};let A=S?v.map(e=>e.text).filter(e=>!!e?.trim()).join(`
|
|
11
11
|
`):y.text;if(_.channel===`none`||!_.to)return V({status:`skipped`,reason:_.reason??`no-target`,preview:A?.slice(0,200),durationMs:Date.now()-o,hasMedia:w.length>0,accountId:_.accountId}),{status:`ran`,durationMs:Date.now()-o};if(!x.showAlerts)return await J({storePath:d,sessionKey:u,updatedAt:m}),V({status:`skipped`,reason:`alerts-disabled`,preview:A?.slice(0,200),durationMs:Date.now()-o,channel:_.channel,hasMedia:w.length>0,accountId:_.accountId,indicatorType:x.useIndicator?B(`sent`):void 0}),{status:`ran`,durationMs:Date.now()-o};let j=_.accountId,M=D(_.channel);if(M?.heartbeat?.checkReady){let n=await M.heartbeat.checkReady({cfg:t,accountId:j,deps:e.deps});if(!n.ok)return V({status:`skipped`,reason:n.reason,preview:A?.slice(0,200),durationMs:Date.now()-o,hasMedia:w.length>0,channel:_.channel,accountId:_.accountId}),G.info(`heartbeat: channel not ready`,{channel:_.channel,reason:n.reason}),{status:`skipped`,reason:n.reason}}if(await z({cfg:t,channel:_.channel,to:_.to,accountId:j,session:N,threadId:_.threadId,payloads:[...v,...S?[]:[{text:y.text,mediaUrls:w}]],deps:e.deps}),!S&&y.text.trim()){let e=p(d),t=e[u];t&&(e[u]={...t,lastHeartbeatText:y.text,lastHeartbeatSentAt:o},await c(d,e))}return V({status:`sent`,to:_.to,preview:A?.slice(0,200),durationMs:Date.now()-o,hasMedia:w.length>0,channel:_.channel,accountId:_.accountId,indicatorType:x.useIndicator?B(`sent`):void 0}),{status:`ran`,durationMs:Date.now()-o}}catch(e){let t=A(e);return V({status:`failed`,reason:t,durationMs:Date.now()-o,channel:_.channel===`none`?void 0:_.channel,accountId:_.accountId,indicatorType:x.useIndicator?B(`failed`):void 0}),G.error(`heartbeat failed: ${t}`,{error:t}),{status:`failed`,reason:t}}}function Ge(e){let t=e.runtime??r,n=e.runOnce??We,i={cfg:e.cfg??f(),runtime:t,agents:new Map,timer:null,stopped:!1},a=!1,o=(e,t,n)=>typeof n?.lastRunMs==`number`?n.lastRunMs+t:n&&n.intervalMs===t&&n.nextDueMs>e?n.nextDueMs:e+t,s=(e,t)=>{e.lastRunMs=t,e.nextDueMs=t+e.intervalMs},c=()=>{if(i.stopped||(i.timer&&=(clearTimeout(i.timer),null),i.agents.size===0))return;let e=Date.now(),t=1/0;for(let e of i.agents.values())e.nextDueMs<t&&(t=e.nextDueMs);if(!Number.isFinite(t))return;let n=Math.max(0,t-e);i.timer=setTimeout(()=>{i.timer=null,se({reason:`interval`,coalesceMs:0})},n),i.timer.unref?.()},l=e=>{if(i.stopped)return;let t=Date.now(),n=i.agents,r=n.size>0,s=new Map,l=[];for(let r of Me(e)){let i=q(e,void 0,r.heartbeat);if(!i)continue;l.push(i);let a=n.get(r.agentId),c=o(t,i,a);s.set(r.agentId,{agentId:r.agentId,heartbeat:r.heartbeat,intervalMs:i,lastRunMs:a?.lastRunMs,nextDueMs:c})}i.cfg=e,i.agents=s;let u=s.size>0;a?r!==u&&(u?G.info(`heartbeat: started`,{intervalMs:Math.min(...l)}):G.info(`heartbeat: disabled`,{enabled:!1})):(u?G.info(`heartbeat: started`,{intervalMs:Math.min(...l)}):G.info(`heartbeat: disabled`,{enabled:!1}),a=!0),c()},u=async e=>{if(i.stopped||!ie()||i.agents.size===0)return{status:`skipped`,reason:`disabled`};let t=e?.reason,r=e?.agentId?y(e.agentId):void 0,a=e?.sessionKey?.trim()||void 0,o=t===`interval`,l=Date.now(),u=l,d=!1;if(a||r){let e=r??x(a),o=i.agents.get(e);if(!o)return c(),{status:`skipped`,reason:`disabled`};try{let e=await n({cfg:i.cfg,agentId:o.agentId,heartbeat:o.heartbeat,reason:t,sessionKey:a,deps:{runtime:i.runtime}});return(e.status!==`skipped`||e.reason!==`disabled`)&&s(o,u),c(),e.status===`ran`?{status:`ran`,durationMs:Date.now()-l}:e}catch(e){let t=A(e);return G.error(`heartbeat runner: targeted runOnce threw unexpectedly: ${t}`,{error:t}),s(o,u),c(),{status:`failed`,reason:t}}}for(let e of i.agents.values()){if(o&&u<e.nextDueMs)continue;let r;try{r=await n({cfg:i.cfg,agentId:e.agentId,heartbeat:e.heartbeat,reason:t,deps:{runtime:i.runtime}})}catch(t){let n=A(t);G.error(`heartbeat runner: runOnce threw unexpectedly: ${n}`,{error:n}),s(e,u);continue}if(r.status===`skipped`&&r.reason===`requests-in-flight`)return r;(r.status!==`skipped`||r.reason!==`disabled`)&&s(e,u),r.status===`ran`&&(d=!0)}return c(),d?{status:`ran`,durationMs:Date.now()-l}:{status:`skipped`,reason:o?`not-due`:`disabled`}},d=ne(async e=>u({reason:e.reason,agentId:e.agentId,sessionKey:e.sessionKey}));l(i.cfg);let p=()=>{i.stopped||(i.stopped=!0,d(),i.timer&&clearTimeout(i.timer),i.timer=null)};return e.abortSignal?.addEventListener(`abort`,p,{once:!0}),{stop:p,updateConfig:l}}function Ke(e,n){if(!n)return e;let r=e.indexOf(`:`);if(r===-1)return e;let i=e.slice(0,r+1),a=e.slice(r+1).trimStart(),o=a.toLowerCase(),s=(e,t)=>`${i} ${t(a.slice(0,e.length))}${a.slice(e.length)}`;return o.startsWith(`failed`)?s(`failed`,t.error):o.startsWith(`ok`)?s(`ok`,t.success):o.startsWith(`linked`)?s(`linked`,t.success):o.startsWith(`configured`)?s(`configured`,t.success):o.startsWith(`not linked`)?s(`not linked`,t.warn):o.startsWith(`not configured`)?s(`not configured`,t.muted):o.startsWith(`unknown`)?s(`unknown`,t.warn):e}var qe=e({formatHealthChannelLines:()=>Q,getHealthSnapshot:()=>nt,healthCommand:()=>$});const Je=(...e)=>{o(process.env.OPENCLAW_DEBUG_HEALTH)&&console.warn(`[health:debug]`,...e)},Ye=e=>{if(!Number.isFinite(e))return`unknown`;if(e<1e3)return`${Math.max(0,Math.round(e))}ms`;let t=[{label:`w`,size:10080*60*1e3},{label:`d`,size:1440*60*1e3},{label:`h`,size:3600*1e3},{label:`m`,size:60*1e3},{label:`s`,size:1e3}],n=Math.max(0,Math.floor(e)),r=[];for(let e of t){let t=Math.floor(n/e.size);t>0&&(r.push(`${t}${e.label}`),n-=t*e.size)}return r.length===0?`0s`:r.join(` `)},Xe=(e,t)=>je(e,t),Ze=e=>{let t=g(e),n=Array.isArray(e.agents?.list)?e.agents.list:[],r=new Set,i=[];for(let e of n){if(!e||typeof e!=`object`||typeof e.id!=`string`||!e.id.trim())continue;let t=y(e.id);!t||r.has(t)||(r.add(t),i.push({id:t,name:typeof e.name==`string`?e.name:void 0}))}return r.has(t)||i.unshift({id:t}),i.length===0&&i.push({id:t}),{defaultAgentId:t,ordered:i}},X=e=>{let t=p(e),n=Object.entries(t).filter(([e])=>e!==`global`&&e!==`unknown`).map(([e,t])=>({key:e,updatedAt:t?.updatedAt??0})).toSorted((e,t)=>t.updatedAt-e.updatedAt),r=n.slice(0,5).map(e=>({key:e.key,updatedAt:e.updatedAt||null,age:e.updatedAt?Date.now()-e.updatedAt:null}));return{path:e,count:n.length,recent:r}},Qe=e=>!e||typeof e!=`object`?!0:e.enabled!==!1,Z=e=>e&&typeof e==`object`?e:null,$e=(e,t={})=>{let n=Z(e);if(!n)return null;let r=typeof n.ok==`boolean`?n.ok:void 0;if(r===void 0)return null;let i=typeof n.elapsedMs==`number`?n.elapsedMs:null,a=typeof n.status==`number`?n.status:null,o=typeof n.error==`string`?n.error:null,s=Z(n.bot),c=s&&typeof s.username==`string`?s.username:null,l=Z(n.webhook),u=l&&typeof l.url==`string`?l.url:null,d=new Set;c&&d.add(c);for(let e of t.botUsernames??[])e&&d.add(e);if(r){let e=`ok`;return d.size>0&&(e+=` (@${Array.from(d).join(`, @`)})`),i!=null&&(e+=` (${i}ms)`),u&&(e+=` - webhook ${u}`),e}let f=`failed (${a??`unknown`})`;return o&&(f+=` - ${o}`),f},et=e=>{let t=Z(e.probe);if(!t)return null;let n=typeof t.elapsedMs==`number`?Math.round(t.elapsedMs):null,r=typeof t.ok==`boolean`?t.ok:null;if(n==null&&r!==!0)return null;let i=e.accountId||`default`,a=Z(t.bot),o=a&&typeof a.username==`string`?a.username:null;return`${o?`@${o}`:i}:${i}:${n==null?`ok`:`${n}ms`}`},tt=e=>{let t=Z(e.probe);return t?(typeof t.ok==`boolean`?t.ok:null)===!1:!1},Q=(e,t={})=>{let n=e.channels??{},r=e.channelOrder?.length>0?e.channelOrder:Object.keys(n),i=t.accountMode??`default`,a=[];for(let o of r){let r=n[o];if(!r)continue;let s=D(o),c=e.channelLabels?.[o]??s?.meta.label??o,l=r.accounts??{},u=t.accountIdsByChannel?.[o],d=u&&u.length>0?u.map(e=>l[e]).filter(e=>!!e):void 0,f=i===`all`?Object.values(l):d??(r.accounts?Object.values(l):[]),p=d&&d.length>0?d[0]:r,m=f?f.map(e=>{let t=Z(e.probe),n=t?Z(t.bot):null;return n&&typeof n.username==`string`?n.username:null}).filter(e=>!!e):[],h=typeof p.linked==`boolean`?p.linked:null;if(h!==null){if(h){let e=typeof p.authAgeMs==`number`?p.authAgeMs:null,t=e==null?``:` (auth age ${Math.round(e/6e4)}m)`;a.push(`${c}: linked${t}`)}else a.push(`${c}: not linked`);continue}let g=typeof p.configured==`boolean`?p.configured:null;if(g===!1){a.push(`${c}: not configured`);continue}let _=i===`all`?f.map(e=>et(e)).filter(e=>!!e):[],v=f.find(e=>tt(e));if(v){let e=$e(v.probe,{botUsernames:m});if(e){a.push(`${c}: ${e}`);continue}}if(_.length>0){a.push(`${c}: ok (${_.join(`, `)})`);continue}let y=$e(p.probe,{botUsernames:m});if(y){a.push(`${c}: ${y}`);continue}if(g===!0){a.push(`${c}: configured`);continue}a.push(`${c}: unknown`)}return a};async function nt(e){let t=e?.timeoutMs,n=f(),{defaultAgentId:r,ordered:i}=Ze(n),a=w(n),o=new Map,s=i.map(e=>{let t=L(n.session?.store,{agentId:e.id}),i=o.get(t)??X(t);return o.set(t,i),{agentId:e.id,name:e.name,isDefault:e.id===r,heartbeat:Xe(n,e.id),sessions:i}}),c=s.find(e=>e.isDefault)??s[0],l=c?.heartbeat.everyMs?Math.round(c.heartbeat.everyMs/1e3):0,u=c?.sessions??X(L(n.session?.store,{agentId:r})),d=Date.now(),p=t===void 0?1e4:Math.max(50,t),m=e?.probe!==!1,h={},g=E().map(e=>e.id),_={};for(let e of E()){_[e.id]=e.meta.label??e.id;let t=e.config.listAccountIds(n),i=T({plugin:e,cfg:n,accountIds:t}),o=a.get(e.id)?.get(r)??[],s=O({accountIds:t,defaultAccountId:i,boundAccounts:o}),c=Array.from(new Set(Array.from(a.get(e.id)?.values()??[]).flatMap(e=>e))),l=Array.from(new Set([s,i,...t,...c].filter(e=>e&&e.trim())));Je(`channel`,{id:e.id,accountIds:t,defaultAccountId:i,boundAccounts:o,preferredAccountId:s,accountIdsToProbe:l});let u={};for(let t of l){let r=e.config.resolveAccount(n,t),i=e.config.isEnabled?e.config.isEnabled(r,n):Qe(r),a=e.config.isConfigured?await e.config.isConfigured(r,n):!0,o,s=null;if(i&&a&&m&&e.status?.probeAccount)try{o=await e.status.probeAccount({account:r,timeoutMs:p,cfg:n}),s=Date.now()}catch(e){o={ok:!1,error:A(e)},s=Date.now()}let c=o&&typeof o==`object`?o:null,l=c&&typeof c.bot==`object`?c.bot:null;l?.username&&Je(`probe.bot`,{channel:e.id,accountId:t,username:l.username});let d={accountId:t,enabled:i,configured:a};o!==void 0&&(d.probe=o),s&&(d.lastProbeAt=s);let f=e.status?.buildChannelSummary?await e.status.buildChannelSummary({account:r,cfg:n,defaultAccountId:t,snapshot:d}):void 0,h=f&&typeof f==`object`?f:{accountId:t,configured:a,probe:o,lastProbeAt:s};h.configured===void 0&&(h.configured=a),h.lastProbeAt===void 0&&s&&(h.lastProbeAt=s),h.accountId=t,u[t]=h}let d=u[s]??u[i]??u[l[0]??s]??u[Object.keys(u)[0]];d&&(h[e.id]={...d,accounts:u})}return{ok:!0,ts:Date.now(),durationMs:Date.now()-d,channels:h,channelOrder:g,channelLabels:_,heartbeatSeconds:l,defaultAgentId:r,agents:s,sessions:{path:u.path,count:u.count,recent:u.recent}}}async function $(e,t){let r=e.config??await u(),i=await me({label:`Checking gateway health…`,indeterminate:!0,enabled:e.json!==!0},async()=>await fe({method:`health`,params:e.verbose?{probe:!0}:void 0,timeoutMs:e.timeoutMs,config:r}));if(e.json)t.log(JSON.stringify(i,null,2));else{let s=o(process.env.OPENCLAW_DEBUG_HEALTH),c=n();if(e.verbose){let e=pe({config:r});t.log(a(`Gateway connection:`));for(let n of e.message.split(`
|
|
12
12
|
`))t.log(` ${n}`)}let l=Ze(r),u=i.defaultAgentId??l.defaultAgentId,d=Array.isArray(i.agents)?i.agents:[],f=l.ordered.map(e=>{let t=L(r.session?.store,{agentId:e.id});return{agentId:e.id,name:e.name,isDefault:e.id===l.defaultAgentId,heartbeat:Xe(r,e.id),sessions:X(t)}}),p=d.length>0?d:f,m=e.verbose?p:p.filter(e=>e.agentId===u),h=w(r);if(s){t.log(a(`[debug] local channel accounts`));for(let e of E()){let n=e.config.listAccountIds(r),i=T({plugin:e,cfg:r,accountIds:n});t.log(` ${e.id}: accounts=${n.join(`, `)||`(none)`} default=${i}`);for(let i of n){let n=e.config.resolveAccount(r,i),a=Z(n),o=a&&typeof a.tokenSource==`string`?a.tokenSource:void 0,s=e.config.isConfigured?await e.config.isConfigured(n,r):!0;t.log(` - ${i}: configured=${s}${o?` tokenSource=${o}`:``}`)}}t.log(a(`[debug] bindings map`));for(let[e,n]of h.entries()){let r=Array.from(n.entries()).map(([e,t])=>`${e}=[${t.join(`, `)}]`);t.log(` ${e}: ${r.join(` `)}`)}t.log(a(`[debug] gateway channel probes`));for(let[e,n]of Object.entries(i.channels??{})){let r=n.accounts??{},i=Object.entries(r).map(([e,t])=>{let n=Z(t.probe),r=n?Z(n.bot):null;return`${e}=${(r&&typeof r.username==`string`?r.username:null)??`(no bot)`}`});t.log(` ${e}: ${i.join(`, `)||`(none)`}`)}}let g=Object.fromEntries(E().map(e=>{let t=e.config.listAccountIds(r),n=O({accountIds:t,defaultAccountId:T({plugin:e,cfg:r,accountIds:t}),boundAccounts:h.get(e.id)?.get(u)??[]});return[e.id,[n]]})),_=(()=>{let e=m.length>0?m:p,t={};for(let[n,r]of h.entries()){let i=[];for(let t of e){let e=r.get(t.agentId)??[];for(let t of e)i.includes(t)||i.push(t)}i.length>0&&(t[n]=i)}for(let[e,n]of Object.entries(g))(!t[e]||t[e].length===0)&&(t[e]=n);return t})(),v=Object.keys(_).length>0?Q(i,{accountMode:e.verbose?`all`:`default`,accountIdsByChannel:_}):Q(i,{accountMode:e.verbose?`all`:`default`});for(let e of v)t.log(Ke(e,c));for(let e of E()){let n=i.channels?.[e.id];if(!n||n.linked!==!0||!e.status?.logSelfId)continue;let a=h.get(e.id)?.get(u)??[],o=e.config.listAccountIds(r),s=O({accountIds:o,defaultAccountId:T({plugin:e,cfg:r,accountIds:o}),boundAccounts:a}),c=e.config.resolveAccount(r,s);e.status.logSelfId({account:c,cfg:r,runtime:t,includeChannelPrefix:!0})}if(p.length>0){let e=p.map(e=>e.isDefault?`${e.agentId} (default)`:e.agentId);t.log(a(`Agents: ${e.join(`, `)}`))}let y=m.map(e=>{let t=e.heartbeat?.everyMs;return`${t?Ye(t):`disabled`} (${e.agentId})`}).filter(Boolean);if(y.length>0&&t.log(a(`Heartbeat interval: ${y.join(`, `)}`)),m.length===0){if(t.log(a(`Session store: ${i.sessions.path} (${i.sessions.count} entries)`)),i.sessions.recent.length>0)for(let e of i.sessions.recent)t.log(`- ${e.key} (${e.updatedAt?`${Math.round((Date.now()-e.updatedAt)/6e4)}m ago`:`no activity`})`)}else for(let e of m)if(t.log(a(`Session store (${e.agentId}): ${e.sessions.path} (${e.sessions.count} entries)`)),e.sessions.recent.length>0)for(let n of e.sessions.recent)t.log(`- ${n.key} (${n.updatedAt?`${Math.round((Date.now()-n.updatedAt)/6e4)}m ago`:`no activity`})`)}}export{Ke as a,Ge as c,qe as i,nt as n,je as o,$ as r,We as s,Q as t};
|
|
13
|
-
//# sourceMappingURL=health-
|
|
13
|
+
//# sourceMappingURL=health-DBu0V1Y-.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as e}from"./rolldown-runtime-CNxR59P3.js";import{A as t,k as n,p as r,t as i,y as a}from"./subsystem-C5XF2Fy5.js";import{l as o}from"./utils-UGOV_184.js";import{Hn as s,Jn as c,Kn as l,Lr as u,Rr as d,Xs as f,qs as p,yc as m}from"./model-selection-BlC_rXAN.js";import{Gt as h,Kt as g,Mr as _,Qr as v,Un as y,Wn as b,Yt as x,ai as S,br as C,ii as w,kr as T,oi as E,qt as D,si as O,t as ee,v as k,wn as A}from"./reply-
|
|
1
|
+
import{t as e}from"./rolldown-runtime-CNxR59P3.js";import{A as t,k as n,p as r,t as i,y as a}from"./subsystem-C5XF2Fy5.js";import{l as o}from"./utils-UGOV_184.js";import{Hn as s,Jn as c,Kn as l,Lr as u,Rr as d,Xs as f,qs as p,yc as m}from"./model-selection-BlC_rXAN.js";import{Gt as h,Kt as g,Mr as _,Qr as v,Un as y,Wn as b,Yt as x,ai as S,br as C,ii as w,kr as T,oi as E,qt as D,si as O,t as ee,v as k,wn as A}from"./reply-CjyZeZ-j.js";import{b as te,d as ne,f as j,i as M}from"./agent-scope-DXZc3eNT.js";import{E as re,c as N,h as P,u as F}from"./session-key-D3P0tf5P.js";import{t as I}from"./env-D7wNuBx1.js";import{g as ie,lt as L,n as R,t as ae,v as z}from"./plugins-CYLrFT4h.js";import{a as oe,r as B}from"./errors-Bunti32V.js";import{c as V,n as se}from"./paths-yLEk_25I.js";import{t as H}from"./tokens-XGbQGn67.js";import{t as ce}from"./deliver-ClBkV2eD.js";import{n as le,t as ue}from"./call-CqoMqP5b.js";import{n as de}from"./progress-LNttnI-y.js";import{a as U,n as W,o as fe,t as pe}from"./heartbeat-visibility-q74UdY8O.js";import G from"node:path";import K from"node:fs/promises";const me=/^(?:([01]\d|2[0-3]):([0-5]\d)|24:00)$/;function he(e,t){let n=t?.trim();if(!n||n===`user`)return _(e.agents?.defaults?.userTimezone);if(n===`local`)return Intl.DateTimeFormat().resolvedOptions().timeZone?.trim()||`UTC`;try{return new Intl.DateTimeFormat(`en-US`,{timeZone:n}).format(new Date),n}catch{return _(e.agents?.defaults?.userTimezone)}}function ge(e,t){if(!t||!me.test(t))return null;let[n,r]=t.split(`:`),i=Number(n),a=Number(r);return!Number.isFinite(i)||!Number.isFinite(a)?null:i===24?!e.allow24||a!==0?null:1440:i*60+a}function _e(e,t){try{let n=new Intl.DateTimeFormat(`en-US`,{timeZone:t,hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}).formatToParts(new Date(e)),r={};for(let e of n)e.type!==`literal`&&(r[e.type]=e.value);let i=Number(r.hour),a=Number(r.minute);return!Number.isFinite(i)||!Number.isFinite(a)?null:i*60+a}catch{return null}}function ve(e,t,n){let r=t?.activeHours;if(!r)return!0;let i=ge({allow24:!1},r.start),a=ge({allow24:!0},r.end);if(i===null||a===null)return!0;if(i===a)return!1;let o=he(e,r.timezone),s=_e(n??Date.now(),o);return s===null?!0:a>i?s>=i&&s<a:s>=i||s<a}function ye(e,t){let n=t?.deliverToUser??!0,r=e.join(`
|
|
2
2
|
`).trim();return r?n?`A scheduled reminder has been triggered. The reminder content is:
|
|
3
3
|
|
|
4
4
|
`+r+`
|
|
@@ -10,4 +10,4 @@ Please relay this reminder to the user in a helpful and friendly way.`:`A schedu
|
|
|
10
10
|
Handle this reminder internally. Do not relay it to the user unless explicitly requested.`:n?`A scheduled cron event was triggered, but no event content was found. Reply HEARTBEAT_OK.`:`A scheduled cron event was triggered, but no event content was found. Handle this internally and reply HEARTBEAT_OK when nothing needs user-facing follow-up.`}function be(e){return e?.deliverToUser??!0?`An async command you ran earlier has completed. The result is shown in the system messages above. Please relay the command output to the user in a helpful way. If the command succeeded, share the relevant output. If it failed, explain what went wrong.`:`An async command you ran earlier has completed. The result is shown in the system messages above. Handle the result internally. Do not relay it to the user unless explicitly requested.`}const xe=H.toLowerCase();function Se(e){let t=e.trim();if(!t)return!1;let n=t.toLowerCase();if(!n.startsWith(xe))return!1;let r=n.slice(xe.length);return r.length===0?!0:!/[a-z0-9_]/.test(r[0])}function Ce(e){let t=e.trim().toLowerCase();return t?Se(t)||t.includes(`heartbeat poll`)||t.includes(`heartbeat wake`):!1}function we(e){return e.toLowerCase().includes(`exec finished`)}function Te(e){return e.trim()?!Ce(e)&&!we(e):!1}const q=i(`gateway/heartbeat`),Ee=`none`;function De(e){return(e.agents?.list??[]).some(e=>!!e?.heartbeat)}function Oe(e,t){let n=N(t??j(e)),r=e.agents?.list??[];return De(e)?r.some(e=>!!e?.heartbeat&&N(e?.id)===n):n===j(e)}function J(e,t){let n=e.agents?.defaults?.heartbeat;if(!t)return n;let r=M(e,t)?.heartbeat;return!n&&!r?r:{...n,...r}}function ke(e,t){let n=e.agents?.defaults?.heartbeat,r=t?M(e,t)?.heartbeat:void 0;if(!Oe(e,t))return{enabled:!1,every:`disabled`,everyMs:null,prompt:E(n?.prompt),target:n?.target??Ee,model:n?.model,ackMaxChars:Math.max(0,n?.ackMaxChars??300)};let i=n||r?{...n,...r}:void 0;return{enabled:!0,every:i?.every??n?.every??r?.every??`30m`,everyMs:Y(e,void 0,i),prompt:E(i?.prompt??n?.prompt??r?.prompt),target:i?.target??n?.target??r?.target??Ee,model:i?.model??n?.model??r?.model,ackMaxChars:Math.max(0,i?.ackMaxChars??n?.ackMaxChars??r?.ackMaxChars??300)}}function Ae(e){let t=e.agents?.list??[];if(De(e))return t.filter(e=>e?.heartbeat).map(t=>{let n=N(t.id);return{agentId:n,heartbeat:J(e,n)}}).filter(e=>e.agentId);let n=j(e);return[{agentId:n,heartbeat:J(e,n)}]}function Y(e,t,n){let r=t??n?.every??e.agents?.defaults?.heartbeat?.every??`30m`;if(!r)return null;let i=String(r).trim();if(!i)return null;let a;try{a=m(i,{defaultUnit:`m`})}catch{return null}return a<=0?null:a}function je(e,t){return E(t?.prompt??e.agents?.defaults?.heartbeat?.prompt)}function Me(e,t){return Math.max(0,t?.ackMaxChars??e.agents?.defaults?.heartbeat?.ackMaxChars??300)}function Ne(e,t,n,r){let i=e.session,a=i?.scope??`per-sender`,o=N(t??j(e)),c=a===`global`?`global`:d({cfg:e,agentId:o}),l=a===`global`?j(e):o,f=V(i?.store,{agentId:l}),p=s(f),m=p[c];if(a===`global`)return{sessionKey:c,storePath:f,store:p,entry:m};let h=r?.trim();if(h){let t=u({cfg:e,agentId:o,sessionKey:P({agentId:o,requestKey:h,mainKey:e.session?.mainKey})});if(t!==`global`&&F(t)===N(o))return{sessionKey:t,storePath:f,store:p,entry:p[t]}}let g=n?.session?.trim()??``;if(!g)return{sessionKey:c,storePath:f,store:p,entry:m};let _=g.toLowerCase();if(_===`main`||_===`global`)return{sessionKey:c,storePath:f,store:p,entry:m};let v=u({cfg:e,agentId:o,sessionKey:P({agentId:o,requestKey:g,mainKey:e.session?.mainKey})});return v!==`global`&&F(v)===N(o)?{sessionKey:v,storePath:f,store:p,entry:p[v]}:{sessionKey:c,storePath:f,store:p,entry:m}}function Pe(e){return(Array.isArray(e)?e:e?[e]:[]).filter(e=>(typeof e.text==`string`?e.text:``).trimStart().startsWith(`Reasoning:`))}async function X(e){let{storePath:t,sessionKey:n,updatedAt:r}=e;if(typeof r!=`number`)return;let i=s(t)[n];if(!i)return;let a=Math.max(i.updatedAt??0,r);i.updatedAt!==a&&await c(t,e=>{let t=e[n]??i;if(!t)return;let a=Math.max(t.updatedAt??0,r);t.updatedAt!==a&&(e[n]={...t,updatedAt:a})})}async function Z(e){let{transcriptPath:t,preHeartbeatSize:n}=e;if(!(!t||typeof n!=`number`||n<0))try{(await K.stat(t)).size>n&&await K.truncate(t,n)}catch{}}async function Fe(e){let{storePath:t,sessionKey:n,agentId:r}=e;try{let e=s(t)[n];if(!e?.sessionId)return{};let i=se(e.sessionId,e,{agentId:r,sessionsDir:G.dirname(t)});return{transcriptPath:i,preHeartbeatSize:(await K.stat(i)).size}}catch{return{}}}function Ie(e,t){let n=t?.trim();if(!n)return e;let r=RegExp(`^${o(n)}(?=$|\\s|[\\p{P}\\p{S}])\\s*`,`iu`);return e.replace(r,``)}function Le(e,t,n){let r=O(Ie(typeof e.text==`string`?e.text:``,t),{mode:`heartbeat`,maxAckChars:n}),i=!!(e.mediaUrl||(e.mediaUrls?.length??0)>0);if(r.shouldSkip&&!i)return{shouldSkip:!0,text:``,hasMedia:i};let a=r.text;return t&&a&&!a.startsWith(t)&&(a=`${t} ${a}`),{shouldSkip:!1,text:a,hasMedia:i}}function Re(e){let t=x(e);return{isExecEventReason:t===`exec-event`,isCronEventReason:t===`cron`,isWakeReason:t===`wake`||t===`hook`}}async function ze(e){let t=Re(e.reason),n=Ne(e.cfg,e.agentId,e.heartbeat,e.forcedSessionKey),r=A(n.sessionKey),i=r.some(e=>e.contextKey?.startsWith(`cron:`)),a=t.isExecEventReason||t.isCronEventReason||i,o=t.isExecEventReason||t.isCronEventReason||t.isWakeReason||i,s={...t,session:n,pendingEventEntries:r,hasTaggedCronEvents:i,shouldInspectPendingEvents:a};if(o)return s;let c=ne(e.cfg,e.agentId),l=G.join(c,te);try{if(S(await K.readFile(l,`utf-8`)))return{...s,skipReason:`empty-heartbeat-file`}}catch(e){if(oe(e,`ENOENT`))return s}return s}function Be(e,t){if(!/heartbeat\.md/i.test(e))return e;let n=`When reading HEARTBEAT.md, use workspace file ${G.join(t,te).replace(/\\/g,`/`)} (exact case). Do not read docs/heartbeat.md.`;return e.includes(n)?e:`${e}\n${n}`}function Ve(e){let t=e.preflight.pendingEventEntries,n=e.preflight.shouldInspectPendingEvents?t.map(e=>e.text):[],r=t.filter(t=>(e.preflight.isCronEventReason||t.contextKey?.startsWith(`cron:`))&&Te(t.text)).map(e=>e.text),i=n.some(we),a=r.length>0;return{prompt:Be(i?be({deliverToUser:e.canRelayToUser}):a?ye(r,{deliverToUser:e.canRelayToUser}):je(e.cfg,e.heartbeat),e.workspaceDir),hasExecCompletion:i,hasCronEvents:a}}async function He(e){let t=e.cfg??p(),n=typeof e.agentId==`string`?e.agentId.trim():``,r=n.length>0?void 0:re(e.sessionKey)?.agentId,i=N(n||r||j(t)),a=e.heartbeat??J(t,i);if(!h()||!Oe(t,i)||!Y(t,void 0,a))return{status:`skipped`,reason:`disabled`};let o=e.deps?.nowMs?.()??Date.now();if(!ve(t,a,o))return{status:`skipped`,reason:`quiet-hours`};if((e.deps?.getQueueSize??v)(w.Main)>0)return{status:`skipped`,reason:`requests-in-flight`};let c=await ze({cfg:t,agentId:i,heartbeat:a,forcedSessionKey:e.sessionKey,reason:e.reason});if(c.skipReason)return W({status:`skipped`,reason:c.skipReason,durationMs:Date.now()-o}),{status:`skipped`,reason:c.skipReason};let{entry:u,sessionKey:d,storePath:f}=c.session,m=u?.updatedAt,g=y({cfg:t,entry:u,heartbeat:a}),_=a?.accountId?.trim();g.reason===`unknown-account`?q.warn(`heartbeat: unknown accountId`,{accountId:g.accountId??_??null,target:a?.target??`none`}):_&&q.info(`heartbeat: using explicit accountId`,{accountId:g.accountId??_,target:a?.target??`none`,channel:g.channel});let x=g.channel===`none`?{showOk:!1,showAlerts:!0,useIndicator:!0}:pe({cfg:t,channel:g.channel,accountId:g.accountId}),{sender:S}=b({cfg:t,entry:u,delivery:g}),E=T(t,i,{channel:g.channel===`none`?void 0:g.channel,accountId:g.accountId}).responsePrefix,{prompt:D,hasExecCompletion:O,hasCronEvents:A}=Ve({cfg:t,heartbeat:a,preflight:c,canRelayToUser:!!(g.channel!==`none`&&g.to&&x.showAlerts),workspaceDir:ne(t,i)}),te={Body:k(D,t,o),From:S,To:S,OriginatingChannel:g.channel===`none`?void 0:g.channel,OriginatingTo:g.to,AccountId:g.accountId,MessageThreadId:g.threadId,Provider:O?`exec-event`:A?`cron-event`:`heartbeat`,SessionKey:d};if(!x.showAlerts&&!x.showOk&&!x.useIndicator)return W({status:`skipped`,reason:`alerts-disabled`,durationMs:Date.now()-o,channel:g.channel===`none`?void 0:g.channel,accountId:g.accountId}),{status:`skipped`,reason:`alerts-disabled`};let M=E?`${E} ${H}`:H,P=C({cfg:t,agentId:i,sessionKey:d}),F=!!(x.showOk&&g.channel!==`none`&&g.to),I=async()=>{if(!F||g.channel===`none`||!g.to)return!1;let n=ae(g.channel);return n?.heartbeat?.checkReady&&!(await n.heartbeat.checkReady({cfg:t,accountId:g.accountId,deps:e.deps})).ok?!1:(await ce({cfg:t,channel:g.channel,to:g.to,accountId:g.accountId,threadId:g.threadId,payloads:[{text:M}],session:P,deps:e.deps}),!0)};try{let n=await Fe({storePath:f,sessionKey:d,agentId:i}),r=a?.model?.trim()||void 0,c=a?.suppressToolErrorWarnings===!0,p=a?.lightContext===!0?`lightweight`:void 0,h=await ee(te,r?{isHeartbeat:!0,heartbeatModelOverride:r,suppressToolErrorWarnings:c,bootstrapContextMode:p}:{isHeartbeat:!0,suppressToolErrorWarnings:c,bootstrapContextMode:p},t),_=fe(h),v=a?.includeReasoning===!0?Pe(h).filter(e=>e!==_):[];if(!_||!_.text&&!_.mediaUrl&&!_.mediaUrls?.length){await X({storePath:f,sessionKey:d,updatedAt:m}),await Z(n);let t=await I();return W({status:`ok-empty`,reason:e.reason,durationMs:Date.now()-o,channel:g.channel===`none`?void 0:g.channel,accountId:g.accountId,silent:!t,indicatorType:x.useIndicator?U(`ok-empty`):void 0}),{status:`ran`,durationMs:Date.now()-o}}let y=Le(_,E,Me(t,a)),b=O&&!y.text.trim()&&_.text?.trim()?_.text.trim():null;b&&(y.text=b,y.shouldSkip=!1);let S=y.shouldSkip&&!y.hasMedia&&!O;if(S&&v.length===0){await X({storePath:f,sessionKey:d,updatedAt:m}),await Z(n);let t=await I();return W({status:`ok-token`,reason:e.reason,durationMs:Date.now()-o,channel:g.channel===`none`?void 0:g.channel,accountId:g.accountId,silent:!t,indicatorType:x.useIndicator?U(`ok-token`):void 0}),{status:`ran`,durationMs:Date.now()-o}}let C=_.mediaUrls??(_.mediaUrl?[_.mediaUrl]:[]),w=typeof u?.lastHeartbeatText==`string`?u.lastHeartbeatText:``,T=typeof u?.lastHeartbeatSentAt==`number`?u.lastHeartbeatSentAt:void 0;if(!S&&!C.length&&w.trim()&&y.text.trim()===w.trim()&&typeof T==`number`&&o-T<1440*60*1e3)return await X({storePath:f,sessionKey:d,updatedAt:m}),await Z(n),W({status:`skipped`,reason:`duplicate`,preview:y.text.slice(0,200),durationMs:Date.now()-o,hasMedia:!1,channel:g.channel===`none`?void 0:g.channel,accountId:g.accountId}),{status:`ran`,durationMs:Date.now()-o};let D=S?v.map(e=>e.text).filter(e=>!!e?.trim()).join(`
|
|
11
11
|
`):y.text;if(g.channel===`none`||!g.to)return W({status:`skipped`,reason:g.reason??`no-target`,preview:D?.slice(0,200),durationMs:Date.now()-o,hasMedia:C.length>0,accountId:g.accountId}),{status:`ran`,durationMs:Date.now()-o};if(!x.showAlerts)return await X({storePath:f,sessionKey:d,updatedAt:m}),W({status:`skipped`,reason:`alerts-disabled`,preview:D?.slice(0,200),durationMs:Date.now()-o,channel:g.channel,hasMedia:C.length>0,accountId:g.accountId,indicatorType:x.useIndicator?U(`sent`):void 0}),{status:`ran`,durationMs:Date.now()-o};let k=g.accountId,A=ae(g.channel);if(A?.heartbeat?.checkReady){let n=await A.heartbeat.checkReady({cfg:t,accountId:k,deps:e.deps});if(!n.ok)return W({status:`skipped`,reason:n.reason,preview:D?.slice(0,200),durationMs:Date.now()-o,hasMedia:C.length>0,channel:g.channel,accountId:g.accountId}),q.info(`heartbeat: channel not ready`,{channel:g.channel,reason:n.reason}),{status:`skipped`,reason:n.reason}}if(await ce({cfg:t,channel:g.channel,to:g.to,accountId:k,session:P,threadId:g.threadId,payloads:[...v,...S?[]:[{text:y.text,mediaUrls:C}]],deps:e.deps}),!S&&y.text.trim()){let e=s(f),t=e[d];t&&(e[d]={...t,lastHeartbeatText:y.text,lastHeartbeatSentAt:o},await l(f,e))}return W({status:`sent`,to:g.to,preview:D?.slice(0,200),durationMs:Date.now()-o,hasMedia:C.length>0,channel:g.channel,accountId:g.accountId,indicatorType:x.useIndicator?U(`sent`):void 0}),{status:`ran`,durationMs:Date.now()-o}}catch(e){let t=B(e);return W({status:`failed`,reason:t,durationMs:Date.now()-o,channel:g.channel===`none`?void 0:g.channel,accountId:g.accountId,indicatorType:x.useIndicator?U(`failed`):void 0}),q.error(`heartbeat failed: ${t}`,{error:t}),{status:`failed`,reason:t}}}function Ue(e){let t=e.runtime??r,n=e.runOnce??He,i={cfg:e.cfg??p(),runtime:t,agents:new Map,timer:null,stopped:!1},a=!1,o=(e,t,n)=>typeof n?.lastRunMs==`number`?n.lastRunMs+t:n&&n.intervalMs===t&&n.nextDueMs>e?n.nextDueMs:e+t,s=(e,t)=>{e.lastRunMs=t,e.nextDueMs=t+e.intervalMs},c=()=>{if(i.stopped||(i.timer&&=(clearTimeout(i.timer),null),i.agents.size===0))return;let e=Date.now(),t=1/0;for(let e of i.agents.values())e.nextDueMs<t&&(t=e.nextDueMs);if(!Number.isFinite(t))return;let n=Math.max(0,t-e);i.timer=setTimeout(()=>{i.timer=null,g({reason:`interval`,coalesceMs:0})},n),i.timer.unref?.()},l=e=>{if(i.stopped)return;let t=Date.now(),n=i.agents,r=n.size>0,s=new Map,l=[];for(let r of Ae(e)){let i=Y(e,void 0,r.heartbeat);if(!i)continue;l.push(i);let a=n.get(r.agentId),c=o(t,i,a);s.set(r.agentId,{agentId:r.agentId,heartbeat:r.heartbeat,intervalMs:i,lastRunMs:a?.lastRunMs,nextDueMs:c})}i.cfg=e,i.agents=s;let u=s.size>0;a?r!==u&&(u?q.info(`heartbeat: started`,{intervalMs:Math.min(...l)}):q.info(`heartbeat: disabled`,{enabled:!1})):(u?q.info(`heartbeat: started`,{intervalMs:Math.min(...l)}):q.info(`heartbeat: disabled`,{enabled:!1}),a=!0),c()},u=async e=>{if(i.stopped||!h()||i.agents.size===0)return{status:`skipped`,reason:`disabled`};let t=e?.reason,r=e?.agentId?N(e.agentId):void 0,a=e?.sessionKey?.trim()||void 0,o=t===`interval`,l=Date.now(),u=l,d=!1;if(a||r){let e=r??F(a),o=i.agents.get(e);if(!o)return c(),{status:`skipped`,reason:`disabled`};try{let e=await n({cfg:i.cfg,agentId:o.agentId,heartbeat:o.heartbeat,reason:t,sessionKey:a,deps:{runtime:i.runtime}});return(e.status!==`skipped`||e.reason!==`disabled`)&&s(o,u),c(),e.status===`ran`?{status:`ran`,durationMs:Date.now()-l}:e}catch(e){let t=B(e);return q.error(`heartbeat runner: targeted runOnce threw unexpectedly: ${t}`,{error:t}),s(o,u),c(),{status:`failed`,reason:t}}}for(let e of i.agents.values()){if(o&&u<e.nextDueMs)continue;let r;try{r=await n({cfg:i.cfg,agentId:e.agentId,heartbeat:e.heartbeat,reason:t,deps:{runtime:i.runtime}})}catch(t){let n=B(t);q.error(`heartbeat runner: runOnce threw unexpectedly: ${n}`,{error:n}),s(e,u);continue}if(r.status===`skipped`&&r.reason===`requests-in-flight`)return r;(r.status!==`skipped`||r.reason!==`disabled`)&&s(e,u),r.status===`ran`&&(d=!0)}return c(),d?{status:`ran`,durationMs:Date.now()-l}:{status:`skipped`,reason:o?`not-due`:`disabled`}},d=D(async e=>u({reason:e.reason,agentId:e.agentId,sessionKey:e.sessionKey}));l(i.cfg);let f=()=>{i.stopped||(i.stopped=!0,d(),i.timer&&clearTimeout(i.timer),i.timer=null)};return e.abortSignal?.addEventListener(`abort`,f,{once:!0}),{stop:f,updateConfig:l}}function We(e,n){if(!n)return e;let r=e.indexOf(`:`);if(r===-1)return e;let i=e.slice(0,r+1),a=e.slice(r+1).trimStart(),o=a.toLowerCase(),s=(e,t)=>`${i} ${t(a.slice(0,e.length))}${a.slice(e.length)}`;return o.startsWith(`failed`)?s(`failed`,t.error):o.startsWith(`ok`)?s(`ok`,t.success):o.startsWith(`linked`)?s(`linked`,t.success):o.startsWith(`configured`)?s(`configured`,t.success):o.startsWith(`not linked`)?s(`not linked`,t.warn):o.startsWith(`not configured`)?s(`not configured`,t.muted):o.startsWith(`unknown`)?s(`unknown`,t.warn):e}var Ge=e({formatHealthChannelLines:()=>$,getHealthSnapshot:()=>tt,healthCommand:()=>nt});const Ke=(...e)=>{I(process.env.OPENCLAW_DEBUG_HEALTH)&&console.warn(`[health:debug]`,...e)},qe=e=>{if(!Number.isFinite(e))return`unknown`;if(e<1e3)return`${Math.max(0,Math.round(e))}ms`;let t=[{label:`w`,size:10080*60*1e3},{label:`d`,size:1440*60*1e3},{label:`h`,size:3600*1e3},{label:`m`,size:60*1e3},{label:`s`,size:1e3}],n=Math.max(0,Math.floor(e)),r=[];for(let e of t){let t=Math.floor(n/e.size);t>0&&(r.push(`${t}${e.label}`),n-=t*e.size)}return r.length===0?`0s`:r.join(` `)},Je=(e,t)=>ke(e,t),Ye=e=>{let t=j(e),n=Array.isArray(e.agents?.list)?e.agents.list:[],r=new Set,i=[];for(let e of n){if(!e||typeof e!=`object`||typeof e.id!=`string`||!e.id.trim())continue;let t=N(e.id);!t||r.has(t)||(r.add(t),i.push({id:t,name:typeof e.name==`string`?e.name:void 0}))}return r.has(t)||i.unshift({id:t}),i.length===0&&i.push({id:t}),{defaultAgentId:t,ordered:i}},Xe=e=>{let t=s(e),n=Object.entries(t).filter(([e])=>e!==`global`&&e!==`unknown`).map(([e,t])=>({key:e,updatedAt:t?.updatedAt??0})).toSorted((e,t)=>t.updatedAt-e.updatedAt),r=n.slice(0,5).map(e=>({key:e.key,updatedAt:e.updatedAt||null,age:e.updatedAt?Date.now()-e.updatedAt:null}));return{path:e,count:n.length,recent:r}},Ze=e=>!e||typeof e!=`object`?!0:e.enabled!==!1,Q=e=>e&&typeof e==`object`?e:null,Qe=(e,t={})=>{let n=Q(e);if(!n)return null;let r=typeof n.ok==`boolean`?n.ok:void 0;if(r===void 0)return null;let i=typeof n.elapsedMs==`number`?n.elapsedMs:null,a=typeof n.status==`number`?n.status:null,o=typeof n.error==`string`?n.error:null,s=Q(n.bot),c=s&&typeof s.username==`string`?s.username:null,l=Q(n.webhook),u=l&&typeof l.url==`string`?l.url:null,d=new Set;c&&d.add(c);for(let e of t.botUsernames??[])e&&d.add(e);if(r){let e=`ok`;return d.size>0&&(e+=` (@${Array.from(d).join(`, @`)})`),i!=null&&(e+=` (${i}ms)`),u&&(e+=` - webhook ${u}`),e}let f=`failed (${a??`unknown`})`;return o&&(f+=` - ${o}`),f},$e=e=>{let t=Q(e.probe);if(!t)return null;let n=typeof t.elapsedMs==`number`?Math.round(t.elapsedMs):null,r=typeof t.ok==`boolean`?t.ok:null;if(n==null&&r!==!0)return null;let i=e.accountId||`default`,a=Q(t.bot),o=a&&typeof a.username==`string`?a.username:null;return`${o?`@${o}`:i}:${i}:${n==null?`ok`:`${n}ms`}`},et=e=>{let t=Q(e.probe);return t?(typeof t.ok==`boolean`?t.ok:null)===!1:!1},$=(e,t={})=>{let n=e.channels??{},r=e.channelOrder?.length>0?e.channelOrder:Object.keys(n),i=t.accountMode??`default`,a=[];for(let o of r){let r=n[o];if(!r)continue;let s=ae(o),c=e.channelLabels?.[o]??s?.meta.label??o,l=r.accounts??{},u=t.accountIdsByChannel?.[o],d=u&&u.length>0?u.map(e=>l[e]).filter(e=>!!e):void 0,f=i===`all`?Object.values(l):d??(r.accounts?Object.values(l):[]),p=d&&d.length>0?d[0]:r,m=f?f.map(e=>{let t=Q(e.probe),n=t?Q(t.bot):null;return n&&typeof n.username==`string`?n.username:null}).filter(e=>!!e):[],h=typeof p.linked==`boolean`?p.linked:null;if(h!==null){if(h){let e=typeof p.authAgeMs==`number`?p.authAgeMs:null,t=e==null?``:` (auth age ${Math.round(e/6e4)}m)`;a.push(`${c}: linked${t}`)}else a.push(`${c}: not linked`);continue}let g=typeof p.configured==`boolean`?p.configured:null;if(g===!1){a.push(`${c}: not configured`);continue}let _=i===`all`?f.map(e=>$e(e)).filter(e=>!!e):[],v=f.find(e=>et(e));if(v){let e=Qe(v.probe,{botUsernames:m});if(e){a.push(`${c}: ${e}`);continue}}if(_.length>0){a.push(`${c}: ok (${_.join(`, `)})`);continue}let y=Qe(p.probe,{botUsernames:m});if(y){a.push(`${c}: ${y}`);continue}if(g===!0){a.push(`${c}: configured`);continue}a.push(`${c}: unknown`)}return a};async function tt(e){let t=e?.timeoutMs,n=p(),{defaultAgentId:r,ordered:i}=Ye(n),a=ie(n),o=new Map,s=i.map(e=>{let t=V(n.session?.store,{agentId:e.id}),i=o.get(t)??Xe(t);return o.set(t,i),{agentId:e.id,name:e.name,isDefault:e.id===r,heartbeat:Je(n,e.id),sessions:i}}),c=s.find(e=>e.isDefault)??s[0],l=c?.heartbeat.everyMs?Math.round(c.heartbeat.everyMs/1e3):0,u=c?.sessions??Xe(V(n.session?.store,{agentId:r})),d=Date.now(),f=t===void 0?1e4:Math.max(50,t),m=e?.probe!==!1,h={},g=R().map(e=>e.id),_={};for(let e of R()){_[e.id]=e.meta.label??e.id;let t=e.config.listAccountIds(n),i=L({plugin:e,cfg:n,accountIds:t}),o=a.get(e.id)?.get(r)??[],s=z({accountIds:t,defaultAccountId:i,boundAccounts:o}),c=Array.from(new Set(Array.from(a.get(e.id)?.values()??[]).flatMap(e=>e))),l=Array.from(new Set([s,i,...t,...c].filter(e=>e&&e.trim())));Ke(`channel`,{id:e.id,accountIds:t,defaultAccountId:i,boundAccounts:o,preferredAccountId:s,accountIdsToProbe:l});let u={};for(let t of l){let r=e.config.resolveAccount(n,t),i=e.config.isEnabled?e.config.isEnabled(r,n):Ze(r),a=e.config.isConfigured?await e.config.isConfigured(r,n):!0,o,s=null;if(i&&a&&m&&e.status?.probeAccount)try{o=await e.status.probeAccount({account:r,timeoutMs:f,cfg:n}),s=Date.now()}catch(e){o={ok:!1,error:B(e)},s=Date.now()}let c=o&&typeof o==`object`?o:null,l=c&&typeof c.bot==`object`?c.bot:null;l?.username&&Ke(`probe.bot`,{channel:e.id,accountId:t,username:l.username});let d={accountId:t,enabled:i,configured:a};o!==void 0&&(d.probe=o),s&&(d.lastProbeAt=s);let p=e.status?.buildChannelSummary?await e.status.buildChannelSummary({account:r,cfg:n,defaultAccountId:t,snapshot:d}):void 0,h=p&&typeof p==`object`?p:{accountId:t,configured:a,probe:o,lastProbeAt:s};h.configured===void 0&&(h.configured=a),h.lastProbeAt===void 0&&s&&(h.lastProbeAt=s),h.accountId=t,u[t]=h}let d=u[s]??u[i]??u[l[0]??s]??u[Object.keys(u)[0]];d&&(h[e.id]={...d,accounts:u})}return{ok:!0,ts:Date.now(),durationMs:Date.now()-d,channels:h,channelOrder:g,channelLabels:_,heartbeatSeconds:l,defaultAgentId:r,agents:s,sessions:{path:u.path,count:u.count,recent:u.recent}}}async function nt(e,t){let r=e.config??await f(),i=await de({label:`Checking gateway health…`,indeterminate:!0,enabled:e.json!==!0},async()=>await le({method:`health`,params:e.verbose?{probe:!0}:void 0,timeoutMs:e.timeoutMs,config:r}));if(e.json)t.log(JSON.stringify(i,null,2));else{let o=I(process.env.OPENCLAW_DEBUG_HEALTH),s=n();if(e.verbose){let e=ue({config:r});t.log(a(`Gateway connection:`));for(let n of e.message.split(`
|
|
12
12
|
`))t.log(` ${n}`)}let c=Ye(r),l=i.defaultAgentId??c.defaultAgentId,u=Array.isArray(i.agents)?i.agents:[],d=c.ordered.map(e=>{let t=V(r.session?.store,{agentId:e.id});return{agentId:e.id,name:e.name,isDefault:e.id===c.defaultAgentId,heartbeat:Je(r,e.id),sessions:Xe(t)}}),f=u.length>0?u:d,p=e.verbose?f:f.filter(e=>e.agentId===l),m=ie(r);if(o){t.log(a(`[debug] local channel accounts`));for(let e of R()){let n=e.config.listAccountIds(r),i=L({plugin:e,cfg:r,accountIds:n});t.log(` ${e.id}: accounts=${n.join(`, `)||`(none)`} default=${i}`);for(let i of n){let n=e.config.resolveAccount(r,i),a=Q(n),o=a&&typeof a.tokenSource==`string`?a.tokenSource:void 0,s=e.config.isConfigured?await e.config.isConfigured(n,r):!0;t.log(` - ${i}: configured=${s}${o?` tokenSource=${o}`:``}`)}}t.log(a(`[debug] bindings map`));for(let[e,n]of m.entries()){let r=Array.from(n.entries()).map(([e,t])=>`${e}=[${t.join(`, `)}]`);t.log(` ${e}: ${r.join(` `)}`)}t.log(a(`[debug] gateway channel probes`));for(let[e,n]of Object.entries(i.channels??{})){let r=n.accounts??{},i=Object.entries(r).map(([e,t])=>{let n=Q(t.probe),r=n?Q(n.bot):null;return`${e}=${(r&&typeof r.username==`string`?r.username:null)??`(no bot)`}`});t.log(` ${e}: ${i.join(`, `)||`(none)`}`)}}let h=Object.fromEntries(R().map(e=>{let t=e.config.listAccountIds(r),n=z({accountIds:t,defaultAccountId:L({plugin:e,cfg:r,accountIds:t}),boundAccounts:m.get(e.id)?.get(l)??[]});return[e.id,[n]]})),g=(()=>{let e=p.length>0?p:f,t={};for(let[n,r]of m.entries()){let i=[];for(let t of e){let e=r.get(t.agentId)??[];for(let t of e)i.includes(t)||i.push(t)}i.length>0&&(t[n]=i)}for(let[e,n]of Object.entries(h))(!t[e]||t[e].length===0)&&(t[e]=n);return t})(),_=Object.keys(g).length>0?$(i,{accountMode:e.verbose?`all`:`default`,accountIdsByChannel:g}):$(i,{accountMode:e.verbose?`all`:`default`});for(let e of _)t.log(We(e,s));for(let e of R()){let n=i.channels?.[e.id];if(!n||n.linked!==!0||!e.status?.logSelfId)continue;let a=m.get(e.id)?.get(l)??[],o=e.config.listAccountIds(r),s=z({accountIds:o,defaultAccountId:L({plugin:e,cfg:r,accountIds:o}),boundAccounts:a}),c=e.config.resolveAccount(r,s);e.status.logSelfId({account:c,cfg:r,runtime:t,includeChannelPrefix:!0})}if(f.length>0){let e=f.map(e=>e.isDefault?`${e.agentId} (default)`:e.agentId);t.log(a(`Agents: ${e.join(`, `)}`))}let v=p.map(e=>{let t=e.heartbeat?.everyMs;return`${t?qe(t):`disabled`} (${e.agentId})`}).filter(Boolean);if(v.length>0&&t.log(a(`Heartbeat interval: ${v.join(`, `)}`)),p.length===0){if(t.log(a(`Session store: ${i.sessions.path} (${i.sessions.count} entries)`)),i.sessions.recent.length>0)for(let e of i.sessions.recent)t.log(`- ${e.key} (${e.updatedAt?`${Math.round((Date.now()-e.updatedAt)/6e4)}m ago`:`no activity`})`)}else for(let e of p)if(t.log(a(`Session store (${e.agentId}): ${e.sessions.path} (${e.sessions.count} entries)`)),e.sessions.recent.length>0)for(let n of e.sessions.recent)t.log(`- ${n.key} (${n.updatedAt?`${Math.round((Date.now()-n.updatedAt)/6e4)}m ago`:`no activity`})`)}}export{We as a,Ue as c,Ge as i,tt as n,ke as o,nt as r,He as s,$ as t};
|
|
13
|
-
//# sourceMappingURL=health-
|
|
13
|
+
//# sourceMappingURL=health-RQzDNQwf.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import"./paths-B4IRk3wi.js";import{A as e,p as t}from"./subsystem-C5XF2Fy5.js";import{S as n,t as r,y as i}from"./utils-UGOV_184.js";import{Lo as a,nc as o,qs as s}from"./model-selection-BlC_rXAN.js";import"./reply-l-Y47HP4.js";import{d as c,f as l}from"./agent-scope-DXZc3eNT.js";import"./openclaw-root-D_0Q6--h.js";import"./github-copilot-token-DGYAlOmV.js";import{t as u}from"./command-format-BbDT1tlm.js";import"./boolean-Ch3DfXPy.js";import"./env-D7wNuBx1.js";import{_ as d}from"./env-overrides-DXJbFrwI.js";import{n as f,r as p}from"./scan-paths-C13EseXp.js";import"./registry-hFAtCSWG.js";import"./skills-DHbOKEGc.js";import{m}from"./frontmatter-BkZkwkVO.js";import"./plugins-CYLrFT4h.js";import"./logger-Bl8URnrW.js";import"./exec-DHqLtFYt.js";import"./windows-spawn-AB7ItGAE.js";import"./redact-3_CiXMY6.js";import"./path-alias-guards-mvyLCPlN.js";import"./errors-Bunti32V.js";import"./send-Cgd_VJHR.js";import"./send-hZFDcGLM.js";import"./paths-yLEk_25I.js";import"./chat-envelope-HVpKusFc.js";import"./audio-transcription-runner-D4Bp6MM7.js";import"./image-DsoO5VP5.js";import"./models-config-CdMhNxKV.js";import"./tool-display-DjuSUUbH.js";import"./fetch-guard-DPdY0NXR.js";import"./api-key-rotation-BRt-vnRV.js";import"./local-roots-6waH0SZ0.js";import"./model-catalog-C1kpjR75.js";import"./proxy-fetch-BADsUK4d.js";import"./tokens-XGbQGn67.js";import"./deliver-ClBkV2eD.js";import"./commands-CGpM84iR.js";import"./commands-registry-B1x54ukc.js";import"./pairing-store-Cg2UxreQ.js";import"./fetch-Dikjvc5M.js";import"./call-CqoMqP5b.js";import"./with-timeout-WveKxvFV.js";import"./diagnostic-DOzHPnht.js";import"./send-B7sHR38c2.js";import"./pi-model-discovery-Dps1PPWz.js";import"./exec-approvals-allowlist-CE3nYh0K.js";import"./exec-safe-bin-runtime-policy-Dt0GchLp.js";import"./ir-Dk7OQ4bA.js";import"./render-D8OWO2hT.js";import"./target-errors-a35Md15n.js";import"./read-only-account-inspect-DBwAwB3_.js";import"./channel-selection-CbNtbAEf.js";import"./plugin-auto-enable-DpVL6-ES.js";import"./send-C-AP01PR.js";import"./outbound-attachment-B7wMxwj6.js";import"./delivery-queue-CKbauSFq.js";import"./send-DbeEC2a3.js";import"./channel-activity-YjYNzCpJ.js";import"./tables-Oieq7UbT.js";import"./fetch-Bn0mWg6a.js";import"./skill-commands-HJHHZqt6.js";import"./workspace-dirs-BhF1Dzxt.js";import"./pairing-token-BjYBuREl.js";import"./restart-CHXEHdSC.js";import"./runtime-web-tools-bz76ZaRc.js";import"./command-secret-targets-BVN3kiT9.js";import"./session-cost-usage-BgqKixv0.js";import"./connection-auth-C8iru0UB.js";import"./onboard-helpers-zwybUJWu.js";import"./prompt-style-CXKekIBY.js";import"./pairing-labels-BUU_-70B.js";import"./memory-cli-jhzJ3as7.js";import"./query-expansion-0OxEb1Io.js";import"./manager-M1GKhLUC.js";import{t as h}from"./links-CySwdMcF.js";import"./cli-utils-BY7dLMFy.js";import"./help-format-BRbF_INg.js";import"./progress-LNttnI-y.js";import"./exec-approvals-BpBNEy6i.js";import"./nodes-screen-DECgxo6A.js";import"./system-run-command-DEWnZE0r.js";import"./runtime-BC5Ep2pJ.js";import"./stagger-DmFYysrJ.js";import{a as ee,c as g,l as te,n as _,u as v}from"./install-safe-path-iesxijn2.js";import{a as y,c as b,f as ne,i as re,l as ie,n as ae,o as x,r as oe,s as se,t as ce,u as le}from"./npm-pack-install-B23L-AtF.js";import{n as ue,t as de}from"./table-CY440fI1.js";import{a as S,t as C}from"./workspace-C45T1Cxg.js";import{t as w}from"./hooks-status-CRJ4J0ZW.js";import{i as T,n as E,r as fe,t as pe}from"./npm-resolution-DWPloph4.js";import D from"node:fs";import O from"node:path";import k from"node:fs/promises";async function me(e){let t=e.spec.trim(),n=d(t);return n?{ok:!1,error:n}:ce(await ae({tempDirPrefix:e.tempDirPrefix,spec:t,timeoutMs:e.timeoutMs,expectedIntegrity:e.expectedIntegrity,onIntegrityDrift:e.onIntegrityDrift,warn:e.warn,installFromArchive:e.installFromArchive,archiveInstallParams:e.archiveInstallParams}))}const A={};function j(e){return{hooksDir:e.hooksDir,timeoutMs:e.timeoutMs,logger:e.logger,mode:e.mode,dryRun:e.dryRun,expectedHookPackId:e.expectedHookPackId}}function M(e){return e?e===`.`||e===`..`?`invalid hook name: reserved path segment`:e.includes(`/`)||e.includes(`\\`)?`invalid hook name: path separators not allowed`:null:`invalid hook name: missing`}function N(e,t){let n=t?i(t):O.join(r,`hooks`),a=M(e);if(a)throw Error(a);let o=_({baseDir:n,id:e,invalidNameMessage:`invalid hook name: path traversal detected`});if(!o.ok)throw Error(o.error);return o.path}async function P(e){let t=e[m]?.hooks;if(!Array.isArray(t))throw Error(`package.json missing openclaw.hooks`);let n=t.map(e=>typeof e==`string`?e.trim():``).filter(Boolean);if(n.length===0)throw Error(`package.json openclaw.hooks is empty`);return n}async function F(e,t){return await re({baseDir:t?i(t):O.join(r,`hooks`),id:e,invalidNameMessage:`invalid hook name: path traversal detected`,boundaryLabel:`hooks directory`})}async function I(e){let t=await F(e.id,e.hooksDir);if(!t.ok)return t;let n=t.targetDir,r=await oe({mode:e.mode,targetDir:n,alreadyExistsError:e.alreadyExistsError(n)});return r.ok?{ok:!0,targetDir:n}:r}async function L(e,t){return await g(O.join(e,`package.json`))?await he({packageDir:e,hooksDir:t.hooksDir,timeoutMs:t.timeoutMs,logger:t.logger,mode:t.mode,dryRun:t.dryRun,expectedHookPackId:t.expectedHookPackId}):await ge({hookDir:e,hooksDir:t.hooksDir,logger:t.logger,mode:t.mode,dryRun:t.dryRun,expectedHookPackId:t.expectedHookPackId})}async function R(e){let t=O.join(e,`HOOK.md`);if(!await g(t))throw Error(`HOOK.md missing in ${e}`);return S(await k.readFile(t,`utf-8`)).name||O.basename(e)}async function z(e){if(!await g(O.join(e,`HOOK.md`)))throw Error(`HOOK.md missing in ${e}`);if(!await Promise.all([`handler.ts`,`handler.js`,`index.ts`,`index.js`].map(async t=>g(O.join(e,t)))).then(e=>e.some(Boolean)))throw Error(`handler.ts/handler.js/index.ts/index.js missing in ${e}`)}async function he(e){let{logger:t,timeoutMs:n,mode:r,dryRun:i}=b(e,A),a=O.join(e.packageDir,`package.json`);if(!await g(a))return{ok:!1,error:`package.json missing`};let o;try{o=await te(a)}catch(e){return{ok:!1,error:`invalid package.json: ${String(e)}`}}let s;try{s=await P(o)}catch(e){return{ok:!1,error:String(e)}}let c=typeof o.name==`string`?o.name:``,l=c?ee(c):O.basename(e.packageDir),u=M(l);if(u)return{ok:!1,error:u};if(e.expectedHookPackId&&e.expectedHookPackId!==l)return{ok:!1,error:`hook pack id mismatch: expected ${e.expectedHookPackId}, got ${l}`};let d=await I({id:l,hooksDir:e.hooksDir,mode:r,alreadyExistsError:e=>`hook pack already exists: ${e} (delete it first)`});if(!d.ok)return d;let m=d.targetDir,h=[];for(let t of s){let n=O.resolve(e.packageDir,t);if(!f(e.packageDir,n))return{ok:!1,error:`openclaw.hooks entry escapes package directory: ${t}`};if(await z(n),!p(e.packageDir,n,{requireRealpath:!0}))return{ok:!1,error:`openclaw.hooks entry resolves outside package directory: ${t}`};let r=await R(n);h.push(r)}if(i)return{ok:!0,hookPackId:l,hooks:h,targetDir:m,version:typeof o.version==`string`?o.version:void 0};let _=await x({sourceDir:e.packageDir,targetDir:m,mode:r,timeoutMs:n,logger:t,copyErrorPrefix:`failed to copy hook pack`,depsLogMessage:`Installing hook pack dependencies…`,manifestDependencies:o.dependencies});return _.ok?{ok:!0,hookPackId:l,hooks:h,targetDir:m,version:typeof o.version==`string`?o.version:void 0}:_}async function ge(e){let{logger:t,mode:n,dryRun:r}=se(e,A);await z(e.hookDir);let i=await R(e.hookDir),a=M(i);if(a)return{ok:!1,error:a};if(e.expectedHookPackId&&e.expectedHookPackId!==i)return{ok:!1,error:`hook id mismatch: expected ${e.expectedHookPackId}, got ${i}`};let o=await I({id:i,hooksDir:e.hooksDir,mode:n,alreadyExistsError:e=>`hook already exists: ${e} (delete it first)`});if(!o.ok)return o;let s=o.targetDir;if(r)return{ok:!0,hookPackId:i,hooks:[i],targetDir:s};let c=await y({sourceDir:e.hookDir,targetDir:s,mode:n,timeoutMs:12e4,logger:t,copyErrorPrefix:`failed to copy hook`,hasDeps:!1,depsLogMessage:`Installing hook dependencies…`});return c.ok?{ok:!0,hookPackId:i,hooks:[i],targetDir:s}:c}async function B(e){let t=e.logger??A,n=e.timeoutMs??12e4,r=await ne(e.archivePath);if(!r.ok)return r;let i=r.path;return await le({archivePath:i,tempDirPrefix:`openclaw-hook-`,timeoutMs:n,logger:t,onExtracted:async r=>await L(r,j({hooksDir:e.hooksDir,timeoutMs:n,logger:t,mode:e.mode,dryRun:e.dryRun,expectedHookPackId:e.expectedHookPackId}))})}async function V(e){let{logger:t,timeoutMs:n,mode:r,dryRun:i}=b(e,A),a=e.expectedHookPackId,o=e.spec;return t.info?.(`Downloading ${o.trim()}…`),await me({tempDirPrefix:`openclaw-hook-pack-`,spec:o,timeoutMs:n,expectedIntegrity:e.expectedIntegrity,onIntegrityDrift:e.onIntegrityDrift,warn:e=>{t.warn?.(e)},installFromArchive:B,archiveInstallParams:j({hooksDir:e.hooksDir,timeoutMs:n,logger:t,mode:r,dryRun:i,expectedHookPackId:a})})}async function H(e){let t=await ie(e.path);if(!t.ok)return t;let{resolvedPath:n,stat:r}=t,i=j({hooksDir:e.hooksDir,timeoutMs:e.timeoutMs,logger:e.logger,mode:e.mode,dryRun:e.dryRun,expectedHookPackId:e.expectedHookPackId});return r.isDirectory()?await L(n,i):v(n)?await B({archivePath:n,...i}):{ok:!1,error:`unsupported hook file: ${n}`}}function U(e,t){let{hookId:n,...r}=t,i={...e.hooks?.internal?.installs,[n]:{...e.hooks?.internal?.installs?.[n],...r,installedAt:r.installedAt??new Date().toISOString()}};return{...e,hooks:{...e.hooks,internal:{...e.hooks?.internal,installs:{...i,[n]:i[n]}}}}}function _e(e,t){let n=new Map;for(let t of e)n.set(t.hook.name,t);for(let e of t)n.set(e.hook.name,e);return Array.from(n.values())}function W(e){let t=c(e,l(e)),n=C(t,{config:e});return w(t,{config:e,entries:_e(T({config:e,workspaceDir:t}).hooks.map(e=>e.entry),n)})}function G(e,t,n){let r=e.hooks.find(e=>e.name===t);if(!r)throw Error(`Hook "${t}" not found`);if(r.managedByPlugin)throw Error(`Hook "${t}" is managed by plugin "${r.pluginId??`unknown`}" and cannot be enabled/disabled.`);if(n?.requireEligible&&!r.eligible)throw Error(`Hook "${t}" is not eligible (missing requirements)`);return r}function K(e){let t={...e.config.hooks?.internal?.entries};t[e.hookName]={...t[e.hookName],enabled:e.enabled};let n={...e.config.hooks?.internal,...e.ensureHooksEnabled?{enabled:!0}:{},entries:t};return{...e.config,hooks:{...e.config.hooks,internal:n}}}function ve(t){return t.eligible?e.success(`✓ ready`):t.disabled?e.warn(`⏸ disabled`):e.error(`✗ missing`)}function ye(t){return`${t.emoji??`🔗`} ${e.command(t.name)}`}function be(e){return e.managedByPlugin?`plugin:${e.pluginId??`unknown`}`:e.source}function xe(e){let t=[];return e.missing.bins.length>0&&t.push(`bins: ${e.missing.bins.join(`, `)}`),e.missing.anyBins.length>0&&t.push(`anyBins: ${e.missing.anyBins.join(`, `)}`),e.missing.env.length>0&&t.push(`env: ${e.missing.env.join(`, `)}`),e.missing.config.length>0&&t.push(`config: ${e.missing.config.join(`, `)}`),e.missing.os.length>0&&t.push(`os: ${e.missing.os.join(`, `)}`),t.join(`; `)}function Se(n){t.error(`${e.error(`Error:`)} ${n instanceof Error?n.message:String(n)}`),process.exit(1)}async function q(e){try{await e()}catch(e){Se(e)}}function J(){return{info:e=>t.log(e),warn:n=>t.log(e.warn(n))}}function Y(){t.log(`Restart the gateway to load hooks.`)}function X(n,r){let i=r.resolution.resolvedSpec??r.spec;t.log(e.warn(`Integrity drift detected for "${n}" (${i})\nExpected: ${r.expectedIntegrity}\nActual: ${r.actualIntegrity}`))}async function Z(e){try{let t=await k.readFile(O.join(e,`package.json`),`utf-8`),n=JSON.parse(t);return typeof n.version==`string`?n.version:void 0}catch{return}}function Q(e,t){let n={...e.hooks?.internal?.entries};for(let e of t)n[e]={...n[e],enabled:!0};return{...e,hooks:{...e.hooks,internal:{...e.hooks?.internal,enabled:!0,entries:n}}}}function $(t,n){let r=n.eligible?t.hooks.filter(e=>e.eligible):t.hooks;if(n.json){let e={workspaceDir:t.workspaceDir,managedHooksDir:t.managedHooksDir,hooks:r.map(e=>({name:e.name,description:e.description,emoji:e.emoji,eligible:e.eligible,disabled:e.disabled,source:e.source,pluginId:e.pluginId,events:e.events,homepage:e.homepage,missing:e.missing,managedByPlugin:e.managedByPlugin}))};return JSON.stringify(e,null,2)}if(r.length===0)return n.eligible?`No eligible hooks found. Run \`${u(`openclaw hooks list`)}\` to see all hooks.`:`No hooks found.`;let i=r.filter(e=>e.eligible),a=de(),o=r.map(t=>{let n=xe(t);return{Status:ve(t),Hook:ye(t),Description:e.muted(t.description),Source:be(t),Missing:n?e.warn(n):``}}),s=[{key:`Status`,header:`Status`,minWidth:10},{key:`Hook`,header:`Hook`,minWidth:18,flex:!0},{key:`Description`,header:`Description`,minWidth:24,flex:!0},{key:`Source`,header:`Source`,minWidth:12,flex:!0}];n.verbose&&s.push({key:`Missing`,header:`Missing`,minWidth:18,flex:!0});let c=[];return c.push(`${e.heading(`Hooks`)} ${e.muted(`(${i.length}/${r.length} ready)`)}`),c.push(ue({width:a,columns:s,rows:o}).trimEnd()),c.join(`
|
|
1
|
+
import"./paths-B4IRk3wi.js";import{A as e,p as t}from"./subsystem-C5XF2Fy5.js";import{S as n,t as r,y as i}from"./utils-UGOV_184.js";import{Lo as a,nc as o,qs as s}from"./model-selection-BlC_rXAN.js";import"./reply-CjyZeZ-j.js";import{d as c,f as l}from"./agent-scope-DXZc3eNT.js";import"./openclaw-root-D_0Q6--h.js";import"./github-copilot-token-DGYAlOmV.js";import{t as u}from"./command-format-BbDT1tlm.js";import"./boolean-Ch3DfXPy.js";import"./env-D7wNuBx1.js";import{_ as d}from"./env-overrides-DXJbFrwI.js";import{n as f,r as p}from"./scan-paths-C13EseXp.js";import"./registry-hFAtCSWG.js";import"./skills-DHbOKEGc.js";import{m}from"./frontmatter-BkZkwkVO.js";import"./plugins-CYLrFT4h.js";import"./logger-Bl8URnrW.js";import"./exec-DHqLtFYt.js";import"./windows-spawn-AB7ItGAE.js";import"./redact-3_CiXMY6.js";import"./path-alias-guards-mvyLCPlN.js";import"./errors-Bunti32V.js";import"./send-Cgd_VJHR.js";import"./send-hZFDcGLM.js";import"./paths-yLEk_25I.js";import"./chat-envelope-HVpKusFc.js";import"./audio-transcription-runner-D4Bp6MM7.js";import"./image-DsoO5VP5.js";import"./models-config-CdMhNxKV.js";import"./tool-display-DjuSUUbH.js";import"./fetch-guard-DPdY0NXR.js";import"./api-key-rotation-BRt-vnRV.js";import"./local-roots-6waH0SZ0.js";import"./model-catalog-C1kpjR75.js";import"./proxy-fetch-BADsUK4d.js";import"./tokens-XGbQGn67.js";import"./deliver-ClBkV2eD.js";import"./commands-CGpM84iR.js";import"./commands-registry-B1x54ukc.js";import"./pairing-store-Cg2UxreQ.js";import"./fetch-Dikjvc5M.js";import"./call-CqoMqP5b.js";import"./with-timeout-WveKxvFV.js";import"./diagnostic-DOzHPnht.js";import"./send-B7sHR38c2.js";import"./pi-model-discovery-Dps1PPWz.js";import"./exec-approvals-allowlist-CE3nYh0K.js";import"./exec-safe-bin-runtime-policy-Dt0GchLp.js";import"./ir-Dk7OQ4bA.js";import"./render-D8OWO2hT.js";import"./target-errors-a35Md15n.js";import"./read-only-account-inspect-DBwAwB3_.js";import"./channel-selection-CbNtbAEf.js";import"./plugin-auto-enable-DpVL6-ES.js";import"./send-C-AP01PR.js";import"./outbound-attachment-B7wMxwj6.js";import"./delivery-queue-CKbauSFq.js";import"./send-DbeEC2a3.js";import"./channel-activity-YjYNzCpJ.js";import"./tables-Oieq7UbT.js";import"./fetch-Bn0mWg6a.js";import"./skill-commands-HJHHZqt6.js";import"./workspace-dirs-BhF1Dzxt.js";import"./pairing-token-BjYBuREl.js";import"./restart-CHXEHdSC.js";import"./runtime-web-tools-bz76ZaRc.js";import"./command-secret-targets-BVN3kiT9.js";import"./session-cost-usage-BgqKixv0.js";import"./connection-auth-C8iru0UB.js";import"./onboard-helpers-zwybUJWu.js";import"./prompt-style-CXKekIBY.js";import"./pairing-labels-BUU_-70B.js";import"./memory-cli-jhzJ3as7.js";import"./query-expansion-0OxEb1Io.js";import"./manager-M1GKhLUC.js";import{t as h}from"./links-CySwdMcF.js";import"./cli-utils-BY7dLMFy.js";import"./help-format-BRbF_INg.js";import"./progress-LNttnI-y.js";import"./exec-approvals-BpBNEy6i.js";import"./nodes-screen-DECgxo6A.js";import"./system-run-command-DEWnZE0r.js";import"./runtime-BC5Ep2pJ.js";import"./stagger-DmFYysrJ.js";import{a as ee,c as g,l as te,n as _,u as v}from"./install-safe-path-iesxijn2.js";import{a as y,c as b,f as ne,i as re,l as ie,n as ae,o as x,r as oe,s as se,t as ce,u as le}from"./npm-pack-install-B23L-AtF.js";import{n as ue,t as de}from"./table-CY440fI1.js";import{a as S,t as C}from"./workspace-C45T1Cxg.js";import{t as w}from"./hooks-status-CRJ4J0ZW.js";import{i as T,n as E,r as fe,t as pe}from"./npm-resolution-Bui58Ks1.js";import D from"node:fs";import O from"node:path";import k from"node:fs/promises";async function me(e){let t=e.spec.trim(),n=d(t);return n?{ok:!1,error:n}:ce(await ae({tempDirPrefix:e.tempDirPrefix,spec:t,timeoutMs:e.timeoutMs,expectedIntegrity:e.expectedIntegrity,onIntegrityDrift:e.onIntegrityDrift,warn:e.warn,installFromArchive:e.installFromArchive,archiveInstallParams:e.archiveInstallParams}))}const A={};function j(e){return{hooksDir:e.hooksDir,timeoutMs:e.timeoutMs,logger:e.logger,mode:e.mode,dryRun:e.dryRun,expectedHookPackId:e.expectedHookPackId}}function M(e){return e?e===`.`||e===`..`?`invalid hook name: reserved path segment`:e.includes(`/`)||e.includes(`\\`)?`invalid hook name: path separators not allowed`:null:`invalid hook name: missing`}function N(e,t){let n=t?i(t):O.join(r,`hooks`),a=M(e);if(a)throw Error(a);let o=_({baseDir:n,id:e,invalidNameMessage:`invalid hook name: path traversal detected`});if(!o.ok)throw Error(o.error);return o.path}async function P(e){let t=e[m]?.hooks;if(!Array.isArray(t))throw Error(`package.json missing openclaw.hooks`);let n=t.map(e=>typeof e==`string`?e.trim():``).filter(Boolean);if(n.length===0)throw Error(`package.json openclaw.hooks is empty`);return n}async function F(e,t){return await re({baseDir:t?i(t):O.join(r,`hooks`),id:e,invalidNameMessage:`invalid hook name: path traversal detected`,boundaryLabel:`hooks directory`})}async function I(e){let t=await F(e.id,e.hooksDir);if(!t.ok)return t;let n=t.targetDir,r=await oe({mode:e.mode,targetDir:n,alreadyExistsError:e.alreadyExistsError(n)});return r.ok?{ok:!0,targetDir:n}:r}async function L(e,t){return await g(O.join(e,`package.json`))?await he({packageDir:e,hooksDir:t.hooksDir,timeoutMs:t.timeoutMs,logger:t.logger,mode:t.mode,dryRun:t.dryRun,expectedHookPackId:t.expectedHookPackId}):await ge({hookDir:e,hooksDir:t.hooksDir,logger:t.logger,mode:t.mode,dryRun:t.dryRun,expectedHookPackId:t.expectedHookPackId})}async function R(e){let t=O.join(e,`HOOK.md`);if(!await g(t))throw Error(`HOOK.md missing in ${e}`);return S(await k.readFile(t,`utf-8`)).name||O.basename(e)}async function z(e){if(!await g(O.join(e,`HOOK.md`)))throw Error(`HOOK.md missing in ${e}`);if(!await Promise.all([`handler.ts`,`handler.js`,`index.ts`,`index.js`].map(async t=>g(O.join(e,t)))).then(e=>e.some(Boolean)))throw Error(`handler.ts/handler.js/index.ts/index.js missing in ${e}`)}async function he(e){let{logger:t,timeoutMs:n,mode:r,dryRun:i}=b(e,A),a=O.join(e.packageDir,`package.json`);if(!await g(a))return{ok:!1,error:`package.json missing`};let o;try{o=await te(a)}catch(e){return{ok:!1,error:`invalid package.json: ${String(e)}`}}let s;try{s=await P(o)}catch(e){return{ok:!1,error:String(e)}}let c=typeof o.name==`string`?o.name:``,l=c?ee(c):O.basename(e.packageDir),u=M(l);if(u)return{ok:!1,error:u};if(e.expectedHookPackId&&e.expectedHookPackId!==l)return{ok:!1,error:`hook pack id mismatch: expected ${e.expectedHookPackId}, got ${l}`};let d=await I({id:l,hooksDir:e.hooksDir,mode:r,alreadyExistsError:e=>`hook pack already exists: ${e} (delete it first)`});if(!d.ok)return d;let m=d.targetDir,h=[];for(let t of s){let n=O.resolve(e.packageDir,t);if(!f(e.packageDir,n))return{ok:!1,error:`openclaw.hooks entry escapes package directory: ${t}`};if(await z(n),!p(e.packageDir,n,{requireRealpath:!0}))return{ok:!1,error:`openclaw.hooks entry resolves outside package directory: ${t}`};let r=await R(n);h.push(r)}if(i)return{ok:!0,hookPackId:l,hooks:h,targetDir:m,version:typeof o.version==`string`?o.version:void 0};let _=await x({sourceDir:e.packageDir,targetDir:m,mode:r,timeoutMs:n,logger:t,copyErrorPrefix:`failed to copy hook pack`,depsLogMessage:`Installing hook pack dependencies…`,manifestDependencies:o.dependencies});return _.ok?{ok:!0,hookPackId:l,hooks:h,targetDir:m,version:typeof o.version==`string`?o.version:void 0}:_}async function ge(e){let{logger:t,mode:n,dryRun:r}=se(e,A);await z(e.hookDir);let i=await R(e.hookDir),a=M(i);if(a)return{ok:!1,error:a};if(e.expectedHookPackId&&e.expectedHookPackId!==i)return{ok:!1,error:`hook id mismatch: expected ${e.expectedHookPackId}, got ${i}`};let o=await I({id:i,hooksDir:e.hooksDir,mode:n,alreadyExistsError:e=>`hook already exists: ${e} (delete it first)`});if(!o.ok)return o;let s=o.targetDir;if(r)return{ok:!0,hookPackId:i,hooks:[i],targetDir:s};let c=await y({sourceDir:e.hookDir,targetDir:s,mode:n,timeoutMs:12e4,logger:t,copyErrorPrefix:`failed to copy hook`,hasDeps:!1,depsLogMessage:`Installing hook dependencies…`});return c.ok?{ok:!0,hookPackId:i,hooks:[i],targetDir:s}:c}async function B(e){let t=e.logger??A,n=e.timeoutMs??12e4,r=await ne(e.archivePath);if(!r.ok)return r;let i=r.path;return await le({archivePath:i,tempDirPrefix:`openclaw-hook-`,timeoutMs:n,logger:t,onExtracted:async r=>await L(r,j({hooksDir:e.hooksDir,timeoutMs:n,logger:t,mode:e.mode,dryRun:e.dryRun,expectedHookPackId:e.expectedHookPackId}))})}async function V(e){let{logger:t,timeoutMs:n,mode:r,dryRun:i}=b(e,A),a=e.expectedHookPackId,o=e.spec;return t.info?.(`Downloading ${o.trim()}…`),await me({tempDirPrefix:`openclaw-hook-pack-`,spec:o,timeoutMs:n,expectedIntegrity:e.expectedIntegrity,onIntegrityDrift:e.onIntegrityDrift,warn:e=>{t.warn?.(e)},installFromArchive:B,archiveInstallParams:j({hooksDir:e.hooksDir,timeoutMs:n,logger:t,mode:r,dryRun:i,expectedHookPackId:a})})}async function H(e){let t=await ie(e.path);if(!t.ok)return t;let{resolvedPath:n,stat:r}=t,i=j({hooksDir:e.hooksDir,timeoutMs:e.timeoutMs,logger:e.logger,mode:e.mode,dryRun:e.dryRun,expectedHookPackId:e.expectedHookPackId});return r.isDirectory()?await L(n,i):v(n)?await B({archivePath:n,...i}):{ok:!1,error:`unsupported hook file: ${n}`}}function U(e,t){let{hookId:n,...r}=t,i={...e.hooks?.internal?.installs,[n]:{...e.hooks?.internal?.installs?.[n],...r,installedAt:r.installedAt??new Date().toISOString()}};return{...e,hooks:{...e.hooks,internal:{...e.hooks?.internal,installs:{...i,[n]:i[n]}}}}}function _e(e,t){let n=new Map;for(let t of e)n.set(t.hook.name,t);for(let e of t)n.set(e.hook.name,e);return Array.from(n.values())}function W(e){let t=c(e,l(e)),n=C(t,{config:e});return w(t,{config:e,entries:_e(T({config:e,workspaceDir:t}).hooks.map(e=>e.entry),n)})}function G(e,t,n){let r=e.hooks.find(e=>e.name===t);if(!r)throw Error(`Hook "${t}" not found`);if(r.managedByPlugin)throw Error(`Hook "${t}" is managed by plugin "${r.pluginId??`unknown`}" and cannot be enabled/disabled.`);if(n?.requireEligible&&!r.eligible)throw Error(`Hook "${t}" is not eligible (missing requirements)`);return r}function K(e){let t={...e.config.hooks?.internal?.entries};t[e.hookName]={...t[e.hookName],enabled:e.enabled};let n={...e.config.hooks?.internal,...e.ensureHooksEnabled?{enabled:!0}:{},entries:t};return{...e.config,hooks:{...e.config.hooks,internal:n}}}function ve(t){return t.eligible?e.success(`✓ ready`):t.disabled?e.warn(`⏸ disabled`):e.error(`✗ missing`)}function ye(t){return`${t.emoji??`🔗`} ${e.command(t.name)}`}function be(e){return e.managedByPlugin?`plugin:${e.pluginId??`unknown`}`:e.source}function xe(e){let t=[];return e.missing.bins.length>0&&t.push(`bins: ${e.missing.bins.join(`, `)}`),e.missing.anyBins.length>0&&t.push(`anyBins: ${e.missing.anyBins.join(`, `)}`),e.missing.env.length>0&&t.push(`env: ${e.missing.env.join(`, `)}`),e.missing.config.length>0&&t.push(`config: ${e.missing.config.join(`, `)}`),e.missing.os.length>0&&t.push(`os: ${e.missing.os.join(`, `)}`),t.join(`; `)}function Se(n){t.error(`${e.error(`Error:`)} ${n instanceof Error?n.message:String(n)}`),process.exit(1)}async function q(e){try{await e()}catch(e){Se(e)}}function J(){return{info:e=>t.log(e),warn:n=>t.log(e.warn(n))}}function Y(){t.log(`Restart the gateway to load hooks.`)}function X(n,r){let i=r.resolution.resolvedSpec??r.spec;t.log(e.warn(`Integrity drift detected for "${n}" (${i})\nExpected: ${r.expectedIntegrity}\nActual: ${r.actualIntegrity}`))}async function Z(e){try{let t=await k.readFile(O.join(e,`package.json`),`utf-8`),n=JSON.parse(t);return typeof n.version==`string`?n.version:void 0}catch{return}}function Q(e,t){let n={...e.hooks?.internal?.entries};for(let e of t)n[e]={...n[e],enabled:!0};return{...e,hooks:{...e.hooks,internal:{...e.hooks?.internal,enabled:!0,entries:n}}}}function $(t,n){let r=n.eligible?t.hooks.filter(e=>e.eligible):t.hooks;if(n.json){let e={workspaceDir:t.workspaceDir,managedHooksDir:t.managedHooksDir,hooks:r.map(e=>({name:e.name,description:e.description,emoji:e.emoji,eligible:e.eligible,disabled:e.disabled,source:e.source,pluginId:e.pluginId,events:e.events,homepage:e.homepage,missing:e.missing,managedByPlugin:e.managedByPlugin}))};return JSON.stringify(e,null,2)}if(r.length===0)return n.eligible?`No eligible hooks found. Run \`${u(`openclaw hooks list`)}\` to see all hooks.`:`No hooks found.`;let i=r.filter(e=>e.eligible),a=de(),o=r.map(t=>{let n=xe(t);return{Status:ve(t),Hook:ye(t),Description:e.muted(t.description),Source:be(t),Missing:n?e.warn(n):``}}),s=[{key:`Status`,header:`Status`,minWidth:10},{key:`Hook`,header:`Hook`,minWidth:18,flex:!0},{key:`Description`,header:`Description`,minWidth:24,flex:!0},{key:`Source`,header:`Source`,minWidth:12,flex:!0}];n.verbose&&s.push({key:`Missing`,header:`Missing`,minWidth:18,flex:!0});let c=[];return c.push(`${e.heading(`Hooks`)} ${e.muted(`(${i.length}/${r.length} ready)`)}`),c.push(ue({width:a,columns:s,rows:o}).trimEnd()),c.join(`
|
|
2
2
|
`)}function Ce(t,r,i){let a=t.hooks.find(e=>e.name===r||e.hookKey===r);if(!a)return i.json?JSON.stringify({error:`not found`,hook:r},null,2):`Hook "${r}" not found. Run \`${u(`openclaw hooks list`)}\` to see available hooks.`;if(i.json)return JSON.stringify(a,null,2);let o=[],s=a.emoji??`🔗`,c=a.eligible?e.success(`✓ Ready`):a.disabled?e.warn(`⏸ Disabled`):e.error(`✗ Missing requirements`);if(o.push(`${s} ${e.heading(a.name)} ${c}`),o.push(``),o.push(a.description),o.push(``),o.push(e.heading(`Details:`)),a.managedByPlugin?o.push(`${e.muted(` Source:`)} ${a.source} (${a.pluginId??`unknown`})`):o.push(`${e.muted(` Source:`)} ${a.source}`),o.push(`${e.muted(` Path:`)} ${n(a.filePath)}`),o.push(`${e.muted(` Handler:`)} ${n(a.handlerPath)}`),a.homepage&&o.push(`${e.muted(` Homepage:`)} ${a.homepage}`),a.events.length>0&&o.push(`${e.muted(` Events:`)} ${a.events.join(`, `)}`),a.managedByPlugin&&o.push(e.muted(` Managed by plugin; enable/disable via hooks CLI not available.`)),a.requirements.bins.length>0||a.requirements.anyBins.length>0||a.requirements.env.length>0||a.requirements.config.length>0||a.requirements.os.length>0){if(o.push(``),o.push(e.heading(`Requirements:`)),a.requirements.bins.length>0){let t=a.requirements.bins.map(t=>a.missing.bins.includes(t)?e.error(`✗ ${t}`):e.success(`✓ ${t}`));o.push(`${e.muted(` Binaries:`)} ${t.join(`, `)}`)}if(a.requirements.anyBins.length>0){let t=a.missing.anyBins.length>0?e.error(`✗ (any of: ${a.requirements.anyBins.join(`, `)})`):e.success(`✓ (any of: ${a.requirements.anyBins.join(`, `)})`);o.push(`${e.muted(` Any binary:`)} ${t}`)}if(a.requirements.env.length>0){let t=a.requirements.env.map(t=>a.missing.env.includes(t)?e.error(`✗ ${t}`):e.success(`✓ ${t}`));o.push(`${e.muted(` Environment:`)} ${t.join(`, `)}`)}if(a.requirements.config.length>0){let t=a.configChecks.map(t=>t.satisfied?e.success(`✓ ${t.path}`):e.error(`✗ ${t.path}`));o.push(`${e.muted(` Config:`)} ${t.join(`, `)}`)}if(a.requirements.os.length>0){let t=a.missing.os.length>0?e.error(`✗ (${a.requirements.os.join(`, `)})`):e.success(`✓ (${a.requirements.os.join(`, `)})`);o.push(`${e.muted(` OS:`)} ${t}`)}}return o.join(`
|
|
3
3
|
`)}function we(t,n){if(n.json){let e=t.hooks.filter(e=>e.eligible),n=t.hooks.filter(e=>!e.eligible);return JSON.stringify({total:t.hooks.length,eligible:e.length,notEligible:n.length,hooks:{eligible:e.map(e=>e.name),notEligible:n.map(e=>({name:e.name,missing:e.missing}))}},null,2)}let r=t.hooks.filter(e=>e.eligible),i=t.hooks.filter(e=>!e.eligible),a=[];if(a.push(e.heading(`Hooks Status`)),a.push(``),a.push(`${e.muted(`Total hooks:`)} ${t.hooks.length}`),a.push(`${e.success(`Ready:`)} ${r.length}`),a.push(`${e.warn(`Not ready:`)} ${i.length}`),i.length>0){a.push(``),a.push(e.heading(`Hooks not ready:`));for(let e of i){let t=[];e.disabled&&t.push(`disabled`),e.missing.bins.length>0&&t.push(`bins: ${e.missing.bins.join(`, `)}`),e.missing.anyBins.length>0&&t.push(`anyBins: ${e.missing.anyBins.join(`, `)}`),e.missing.env.length>0&&t.push(`env: ${e.missing.env.join(`, `)}`),e.missing.config.length>0&&t.push(`config: ${e.missing.config.join(`, `)}`),e.missing.os.length>0&&t.push(`os: ${e.missing.os.join(`, `)}`),a.push(` ${e.emoji??`🔗`} ${e.name} - ${t.join(`; `)}`)}}return a.join(`
|
|
4
4
|
`)}async function Te(n){let r=s(),i=G(W(r),n,{requireEligible:!0});await o(K({config:r,hookName:n,enabled:!0,ensureHooksEnabled:!0})),t.log(`${e.success(`✓`)} Enabled hook: ${i.emoji??`🔗`} ${e.command(n)}`)}async function Ee(n){let r=s(),i=G(W(r),n);await o(K({config:r,hookName:n,enabled:!1})),t.log(`${e.warn(`⏸`)} Disabled hook: ${i.emoji??`🔗`} ${e.command(n)}`)}function De(r){let c=r.command(`hooks`).description(`Manage internal agent hooks`).addHelpText(`after`,()=>`\n${e.muted(`Docs:`)} ${h(`/cli/hooks`,`docs.openclaw.ai/cli/hooks`)}\n`);c.command(`list`).description(`List all hooks`).option(`--eligible`,`Show only eligible hooks`,!1).option(`--json`,`Output as JSON`,!1).option(`-v, --verbose`,`Show more details including missing requirements`,!1).action(async e=>q(async()=>{let n=W(s());t.log($(n,e))})),c.command(`info <name>`).description(`Show detailed information about a hook`).option(`--json`,`Output as JSON`,!1).action(async(e,n)=>q(async()=>{let r=W(s());t.log(Ce(r,e,n))})),c.command(`check`).description(`Check hooks eligibility status`).option(`--json`,`Output as JSON`,!1).action(async e=>q(async()=>{let n=W(s());t.log(we(n,e))})),c.command(`enable <name>`).description(`Enable a hook`).action(async e=>q(async()=>{await Te(e)})),c.command(`disable <name>`).description(`Disable a hook`).action(async e=>q(async()=>{await Ee(e)})),c.command(`install`).description(`Install a hook pack (path, archive, or npm spec)`).argument(`<path-or-spec>`,`Path to a hook pack or npm package spec`).option(`-l, --link`,`Link a local path instead of copying`,!1).option(`--pin`,`Record npm installs as exact resolved <name>@<version>`,!1).action(async(r,a)=>{let c=i(r),l=s();if(D.existsSync(c)){if(a.link){D.statSync(c).isDirectory()||(t.error(`Linked hook paths must be directories.`),process.exit(1));let e=l.hooks?.internal?.load?.extraDirs??[],r=Array.from(new Set([...e,c])),i=await H({path:c,dryRun:!0});i.ok||(t.error(i.error),process.exit(1));let a={...l,hooks:{...l.hooks,internal:{...l.hooks?.internal,enabled:!0,load:{...l.hooks?.internal?.load,extraDirs:r}}}};a=Q(a,i.hooks),a=U(a,{hookId:i.hookPackId,source:`path`,sourcePath:c,installPath:c,version:i.version,hooks:i.hooks}),await o(a),t.log(`Linked hook path: ${n(c)}`),Y();return}let e=await H({path:c,logger:J()});e.ok||(t.error(e.error),process.exit(1));let r=Q(l,e.hooks),i=v(c)?`archive`:`path`;r=U(r,{hookId:e.hookPackId,source:i,sourcePath:c,installPath:e.targetDir,version:e.version,hooks:e.hooks}),await o(r),t.log(`Installed hooks: ${e.hooks.join(`, `)}`),Y();return}a.link&&(t.error("`--link` requires a local path."),process.exit(1)),fe(r,[`.zip`,`.tgz`,`.tar.gz`,`.tar`])&&(t.error(`Path not found: ${c}`),process.exit(1));let u=await V({spec:r,logger:J()});u.ok||(t.error(u.error),process.exit(1));let d=Q(l,u.hooks),f=E(r,!!a.pin,u.targetDir,u.version,u.npmResolution,t.log,e.warn);d=U(d,{hookId:u.hookPackId,...f,hooks:u.hooks}),await o(d),t.log(`Installed hooks: ${u.hooks.join(`, `)}`),Y()}),c.command(`update`).description(`Update installed hooks (npm installs only)`).argument(`[id]`,`Hook pack id (omit with --all)`).option(`--all`,`Update all tracked hooks`,!1).option(`--dry-run`,`Show what would change without writing`,!1).action(async(n,r)=>{let i=s(),c=i.hooks?.internal?.installs??{},l=r.all?Object.keys(c):n?[n]:[];l.length===0&&(t.error(`Provide a hook id or use --all.`),process.exit(1));let u=i,d=0;for(let n of l){let i=c[n];if(!i){t.log(e.warn(`No install record for "${n}".`));continue}if(i.source!==`npm`){t.log(e.warn(`Skipping "${n}" (source: ${i.source}).`));continue}if(!i.spec){t.log(e.warn(`Skipping "${n}" (missing npm spec).`));continue}let o;try{o=i.installPath??N(n)}catch(r){t.log(e.error(`Invalid install path for "${n}": ${String(r)}`));continue}let s=await Z(o);if(r.dryRun){let r=await V({spec:i.spec,mode:`update`,dryRun:!0,expectedHookPackId:n,expectedIntegrity:i.integrity,onIntegrityDrift:async e=>(X(n,e),!0),logger:J()});if(!r.ok){t.log(e.error(`Failed to check ${n}: ${r.error}`));continue}let a=r.version??`unknown`,o=s??`unknown`;s&&r.version&&s===r.version?t.log(`${n} is up to date (${o}).`):t.log(`Would update ${n}: ${o} → ${a}.`);continue}let l=await V({spec:i.spec,mode:`update`,expectedHookPackId:n,expectedIntegrity:i.integrity,onIntegrityDrift:async e=>(X(n,e),await a(`Continue updating "${n}" with this artifact?`)),logger:J()});if(!l.ok){t.log(e.error(`Failed to update ${n}: ${l.error}`));continue}let f=l.version??await Z(l.targetDir);u=U(u,{hookId:n,...pe({spec:i.spec,installPath:l.targetDir,version:f,resolution:l.npmResolution}),hooks:l.hooks}),d+=1;let p=s??`unknown`,m=f??`unknown`;s&&f&&s===f?t.log(`${n} already at ${p}.`):t.log(`Updated ${n}: ${p} → ${m}.`)}d>0&&(await o(u),Y())}),c.action(async()=>q(async()=>{let e=W(s());t.log($(e,{}))}))}export{De as registerHooksCli};
|
|
5
|
-
//# sourceMappingURL=hooks-cli-
|
|
5
|
+
//# sourceMappingURL=hooks-cli-B3eDoEHO.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{A as e,p as t}from"./subsystem-BLbY429l.js";import"./paths-BjD3T_xq.js";import"./boolean-D15s2V33.js";import{Bo as n,jo as r,xa as i}from"./auth-profiles-T8DuH3ax.js";import{t as a}from"./command-format-CLxIPuLR.js";import{d as o,f as s}from"./agent-scope-DAWJwFfl.js";import{t as c,v as l,x as u}from"./utils-CGdo13HV.js";import"./openclaw-root-CnsBf6ZU.js";import"./github-copilot-token-C79yeDKS.js";import{_ as d}from"./env-overrides-DHtB4kK3.js";import"./version-q3SkUw2K.js";import{n as f,r as p}from"./scan-paths-CWtvWW40.js";import"./registry-BptzrW8D.js";import"./skills-CKTicUKS.js";import{m}from"./frontmatter-C7mzDNxd.js";import"./plugins-DNlgeTTc.js";import"./logger-kQAOe3qp.js";import"./exec-B3eleY5O.js";import"./windows-spawn-7oINn5ao.js";import"./redact-CnRxK70G.js";import"./path-alias-guards-kY_ZbWs-.js";import"./errors-6SQWM9dj.js";import"./send-CW81y5Wz.js";import"./send-DavpkzhH.js";import"./compact-Dg66DXx_.js";import"./paths-BfjJY2VL.js";import"./chat-envelope-Bznn2SoS.js";import"./models-config-_htt7eY5.js";import"./tokens-DRM8vzJx.js";import"./with-timeout-c1CzdShT.js";import"./deliver-BHuhHfkH.js";import"./diagnostic-DQq4Bwrs.js";import"./send-DkiKKUkt.js";import"./pi-model-discovery-CpjYoBQf.js";import"./exec-approvals-allowlist-D8mN7nxV.js";import"./exec-safe-bin-runtime-policy-dcCS_Adf.js";import"./model-catalog-COVzoZD9.js";import"./fetch-CQaNr5J1.js";import"./audio-transcription-runner-Bd1OZC6K.js";import"./fetch-guard-BrTtJw7h.js";import"./image-BkWwI54C.js";import"./tool-display-DJDtttQg.js";import"./api-key-rotation-D0QU-kQ9.js";import"./proxy-fetch-gWETR3cl.js";import"./ir-D8Hh84ab.js";import"./render-DrrPmnMI.js";import"./target-errors-CgWAJOam.js";import"./commands-Dy7duWlt.js";import"./commands-registry-Cpl4QnG4.js";import"./session-cost-usage-CHtVgnE8.js";import"./session-utils-8acNlxwP.js";import"./sqlite-CILF3z9U.js";import"./call-B8Fb4_oh.js";import"./pi-tools.policy-D40r0HmD.js";import"./pairing-store-BH-FTYkn.js";import"./fetch-Dh-apy46.js";import"./skill-commands-CSF6wVPU.js";import"./workspace-dirs-A8Vib9_B.js";import"./pairing-token-DAR7V7FJ.js";import"./channel-activity-BBrgoad1.js";import"./tables-Brc2lNcB.js";import"./kill-tree-B3g7HrAO.js";import"./runtime-web-tools-D8fms06-.js";import"./runtime-Dlg2-Omq.js";import"./node-shell-DyOfwHrh.js";import"./stagger-DxzgG2jd.js";import"./channel-selection-BBeE1TmB.js";import"./plugin-auto-enable-NzmNh4oU.js";import"./send-CVplsJpw.js";import"./outbound-attachment-BgAe99RM.js";import"./delivery-queue-nkPJu0fY.js";import"./send-C48Y9SAq.js";import"./system-run-command-BKfMiqQM.js";import"./fetch-Ce-scEU-.js";import"./command-secret-targets-BlN-J_fA.js";import"./connection-auth-B_Uk6Vk8.js";import"./onboard-helpers-PGl5bVPE.js";import"./prompt-style-BThRSQJR.js";import"./pairing-labels-D-kzQEL2.js";import"./search-manager-Bp9x20r6.js";import"./manager-C2YW7Hkq.js";import"./memory-cli-XaxtBQm1.js";import{t as h}from"./links-CBnmRP9D.js";import"./cli-utils-BleB1eys.js";import"./help-format-B4aEI7V9.js";import"./progress-d1m2sqR1.js";import"./exec-approvals-BXO9Cezj.js";import{a as ee,c as g,l as te,n as _,u as v}from"./install-safe-path-C6kc_8NW.js";import{a as y,c as b,f as ne,i as re,l as ie,n as ae,o as x,r as oe,s as se,t as ce,u as le}from"./npm-pack-install-C0te3Oap.js";import{n as ue,t as de}from"./table-CR7TFMew.js";import{a as S,t as C}from"./workspace-xNEpaJvu.js";import{t as w}from"./hooks-status-BHt-Xvh4.js";import{i as T,n as E,r as fe,t as pe}from"./npm-resolution-BnJGLwhi.js";import D from"node:path";import O from"node:fs";import k from"node:fs/promises";async function me(e){let t=e.spec.trim(),n=d(t);return n?{ok:!1,error:n}:ce(await ae({tempDirPrefix:e.tempDirPrefix,spec:t,timeoutMs:e.timeoutMs,expectedIntegrity:e.expectedIntegrity,onIntegrityDrift:e.onIntegrityDrift,warn:e.warn,installFromArchive:e.installFromArchive,archiveInstallParams:e.archiveInstallParams}))}const A={};function j(e){return{hooksDir:e.hooksDir,timeoutMs:e.timeoutMs,logger:e.logger,mode:e.mode,dryRun:e.dryRun,expectedHookPackId:e.expectedHookPackId}}function M(e){return e?e===`.`||e===`..`?`invalid hook name: reserved path segment`:e.includes(`/`)||e.includes(`\\`)?`invalid hook name: path separators not allowed`:null:`invalid hook name: missing`}function N(e,t){let n=t?l(t):D.join(c,`hooks`),r=M(e);if(r)throw Error(r);let i=_({baseDir:n,id:e,invalidNameMessage:`invalid hook name: path traversal detected`});if(!i.ok)throw Error(i.error);return i.path}async function P(e){let t=e[m]?.hooks;if(!Array.isArray(t))throw Error(`package.json missing openclaw.hooks`);let n=t.map(e=>typeof e==`string`?e.trim():``).filter(Boolean);if(n.length===0)throw Error(`package.json openclaw.hooks is empty`);return n}async function F(e,t){return await re({baseDir:t?l(t):D.join(c,`hooks`),id:e,invalidNameMessage:`invalid hook name: path traversal detected`,boundaryLabel:`hooks directory`})}async function I(e){let t=await F(e.id,e.hooksDir);if(!t.ok)return t;let n=t.targetDir,r=await oe({mode:e.mode,targetDir:n,alreadyExistsError:e.alreadyExistsError(n)});return r.ok?{ok:!0,targetDir:n}:r}async function L(e,t){return await g(D.join(e,`package.json`))?await he({packageDir:e,hooksDir:t.hooksDir,timeoutMs:t.timeoutMs,logger:t.logger,mode:t.mode,dryRun:t.dryRun,expectedHookPackId:t.expectedHookPackId}):await ge({hookDir:e,hooksDir:t.hooksDir,logger:t.logger,mode:t.mode,dryRun:t.dryRun,expectedHookPackId:t.expectedHookPackId})}async function R(e){let t=D.join(e,`HOOK.md`);if(!await g(t))throw Error(`HOOK.md missing in ${e}`);return S(await k.readFile(t,`utf-8`)).name||D.basename(e)}async function z(e){if(!await g(D.join(e,`HOOK.md`)))throw Error(`HOOK.md missing in ${e}`);if(!await Promise.all([`handler.ts`,`handler.js`,`index.ts`,`index.js`].map(async t=>g(D.join(e,t)))).then(e=>e.some(Boolean)))throw Error(`handler.ts/handler.js/index.ts/index.js missing in ${e}`)}async function he(e){let{logger:t,timeoutMs:n,mode:r,dryRun:i}=b(e,A),a=D.join(e.packageDir,`package.json`);if(!await g(a))return{ok:!1,error:`package.json missing`};let o;try{o=await te(a)}catch(e){return{ok:!1,error:`invalid package.json: ${String(e)}`}}let s;try{s=await P(o)}catch(e){return{ok:!1,error:String(e)}}let c=typeof o.name==`string`?o.name:``,l=c?ee(c):D.basename(e.packageDir),u=M(l);if(u)return{ok:!1,error:u};if(e.expectedHookPackId&&e.expectedHookPackId!==l)return{ok:!1,error:`hook pack id mismatch: expected ${e.expectedHookPackId}, got ${l}`};let d=await I({id:l,hooksDir:e.hooksDir,mode:r,alreadyExistsError:e=>`hook pack already exists: ${e} (delete it first)`});if(!d.ok)return d;let m=d.targetDir,h=[];for(let t of s){let n=D.resolve(e.packageDir,t);if(!f(e.packageDir,n))return{ok:!1,error:`openclaw.hooks entry escapes package directory: ${t}`};if(await z(n),!p(e.packageDir,n,{requireRealpath:!0}))return{ok:!1,error:`openclaw.hooks entry resolves outside package directory: ${t}`};let r=await R(n);h.push(r)}if(i)return{ok:!0,hookPackId:l,hooks:h,targetDir:m,version:typeof o.version==`string`?o.version:void 0};let _=await x({sourceDir:e.packageDir,targetDir:m,mode:r,timeoutMs:n,logger:t,copyErrorPrefix:`failed to copy hook pack`,depsLogMessage:`Installing hook pack dependencies…`,manifestDependencies:o.dependencies});return _.ok?{ok:!0,hookPackId:l,hooks:h,targetDir:m,version:typeof o.version==`string`?o.version:void 0}:_}async function ge(e){let{logger:t,mode:n,dryRun:r}=se(e,A);await z(e.hookDir);let i=await R(e.hookDir),a=M(i);if(a)return{ok:!1,error:a};if(e.expectedHookPackId&&e.expectedHookPackId!==i)return{ok:!1,error:`hook id mismatch: expected ${e.expectedHookPackId}, got ${i}`};let o=await I({id:i,hooksDir:e.hooksDir,mode:n,alreadyExistsError:e=>`hook already exists: ${e} (delete it first)`});if(!o.ok)return o;let s=o.targetDir;if(r)return{ok:!0,hookPackId:i,hooks:[i],targetDir:s};let c=await y({sourceDir:e.hookDir,targetDir:s,mode:n,timeoutMs:12e4,logger:t,copyErrorPrefix:`failed to copy hook`,hasDeps:!1,depsLogMessage:`Installing hook dependencies…`});return c.ok?{ok:!0,hookPackId:i,hooks:[i],targetDir:s}:c}async function B(e){let t=e.logger??A,n=e.timeoutMs??12e4,r=await ne(e.archivePath);if(!r.ok)return r;let i=r.path;return await le({archivePath:i,tempDirPrefix:`openclaw-hook-`,timeoutMs:n,logger:t,onExtracted:async r=>await L(r,j({hooksDir:e.hooksDir,timeoutMs:n,logger:t,mode:e.mode,dryRun:e.dryRun,expectedHookPackId:e.expectedHookPackId}))})}async function V(e){let{logger:t,timeoutMs:n,mode:r,dryRun:i}=b(e,A),a=e.expectedHookPackId,o=e.spec;return t.info?.(`Downloading ${o.trim()}…`),await me({tempDirPrefix:`openclaw-hook-pack-`,spec:o,timeoutMs:n,expectedIntegrity:e.expectedIntegrity,onIntegrityDrift:e.onIntegrityDrift,warn:e=>{t.warn?.(e)},installFromArchive:B,archiveInstallParams:j({hooksDir:e.hooksDir,timeoutMs:n,logger:t,mode:r,dryRun:i,expectedHookPackId:a})})}async function H(e){let t=await ie(e.path);if(!t.ok)return t;let{resolvedPath:n,stat:r}=t,i=j({hooksDir:e.hooksDir,timeoutMs:e.timeoutMs,logger:e.logger,mode:e.mode,dryRun:e.dryRun,expectedHookPackId:e.expectedHookPackId});return r.isDirectory()?await L(n,i):v(n)?await B({archivePath:n,...i}):{ok:!1,error:`unsupported hook file: ${n}`}}function U(e,t){let{hookId:n,...r}=t,i={...e.hooks?.internal?.installs,[n]:{...e.hooks?.internal?.installs?.[n],...r,installedAt:r.installedAt??new Date().toISOString()}};return{...e,hooks:{...e.hooks,internal:{...e.hooks?.internal,installs:{...i,[n]:i[n]}}}}}function _e(e,t){let n=new Map;for(let t of e)n.set(t.hook.name,t);for(let e of t)n.set(e.hook.name,e);return Array.from(n.values())}function W(e){let t=o(e,s(e)),n=C(t,{config:e});return w(t,{config:e,entries:_e(T({config:e,workspaceDir:t}).hooks.map(e=>e.entry),n)})}function G(e,t,n){let r=e.hooks.find(e=>e.name===t);if(!r)throw Error(`Hook "${t}" not found`);if(r.managedByPlugin)throw Error(`Hook "${t}" is managed by plugin "${r.pluginId??`unknown`}" and cannot be enabled/disabled.`);if(n?.requireEligible&&!r.eligible)throw Error(`Hook "${t}" is not eligible (missing requirements)`);return r}function K(e){let t={...e.config.hooks?.internal?.entries};t[e.hookName]={...t[e.hookName],enabled:e.enabled};let n={...e.config.hooks?.internal,...e.ensureHooksEnabled?{enabled:!0}:{},entries:t};return{...e.config,hooks:{...e.config.hooks,internal:n}}}function ve(t){return t.eligible?e.success(`✓ ready`):t.disabled?e.warn(`⏸ disabled`):e.error(`✗ missing`)}function ye(t){return`${t.emoji??`🔗`} ${e.command(t.name)}`}function be(e){return e.managedByPlugin?`plugin:${e.pluginId??`unknown`}`:e.source}function xe(e){let t=[];return e.missing.bins.length>0&&t.push(`bins: ${e.missing.bins.join(`, `)}`),e.missing.anyBins.length>0&&t.push(`anyBins: ${e.missing.anyBins.join(`, `)}`),e.missing.env.length>0&&t.push(`env: ${e.missing.env.join(`, `)}`),e.missing.config.length>0&&t.push(`config: ${e.missing.config.join(`, `)}`),e.missing.os.length>0&&t.push(`os: ${e.missing.os.join(`, `)}`),t.join(`; `)}function Se(n){t.error(`${e.error(`Error:`)} ${n instanceof Error?n.message:String(n)}`),process.exit(1)}async function q(e){try{await e()}catch(e){Se(e)}}function J(){return{info:e=>t.log(e),warn:n=>t.log(e.warn(n))}}function Y(){t.log(`Restart the gateway to load hooks.`)}function X(n,r){let i=r.resolution.resolvedSpec??r.spec;t.log(e.warn(`Integrity drift detected for "${n}" (${i})\nExpected: ${r.expectedIntegrity}\nActual: ${r.actualIntegrity}`))}async function Z(e){try{let t=await k.readFile(D.join(e,`package.json`),`utf-8`),n=JSON.parse(t);return typeof n.version==`string`?n.version:void 0}catch{return}}function Q(e,t){let n={...e.hooks?.internal?.entries};for(let e of t)n[e]={...n[e],enabled:!0};return{...e,hooks:{...e.hooks,internal:{...e.hooks?.internal,enabled:!0,entries:n}}}}function $(t,n){let r=n.eligible?t.hooks.filter(e=>e.eligible):t.hooks;if(n.json){let e={workspaceDir:t.workspaceDir,managedHooksDir:t.managedHooksDir,hooks:r.map(e=>({name:e.name,description:e.description,emoji:e.emoji,eligible:e.eligible,disabled:e.disabled,source:e.source,pluginId:e.pluginId,events:e.events,homepage:e.homepage,missing:e.missing,managedByPlugin:e.managedByPlugin}))};return JSON.stringify(e,null,2)}if(r.length===0)return n.eligible?`No eligible hooks found. Run \`${a(`openclaw hooks list`)}\` to see all hooks.`:`No hooks found.`;let i=r.filter(e=>e.eligible),o=de(),s=r.map(t=>{let n=xe(t);return{Status:ve(t),Hook:ye(t),Description:e.muted(t.description),Source:be(t),Missing:n?e.warn(n):``}}),c=[{key:`Status`,header:`Status`,minWidth:10},{key:`Hook`,header:`Hook`,minWidth:18,flex:!0},{key:`Description`,header:`Description`,minWidth:24,flex:!0},{key:`Source`,header:`Source`,minWidth:12,flex:!0}];n.verbose&&c.push({key:`Missing`,header:`Missing`,minWidth:18,flex:!0});let l=[];return l.push(`${e.heading(`Hooks`)} ${e.muted(`(${i.length}/${r.length} ready)`)}`),l.push(ue({width:o,columns:c,rows:s}).trimEnd()),l.join(`
|
|
1
|
+
import{A as e,p as t}from"./subsystem-BLbY429l.js";import"./paths-BjD3T_xq.js";import"./boolean-D15s2V33.js";import{Bo as n,jo as r,xa as i}from"./auth-profiles-T8DuH3ax.js";import{t as a}from"./command-format-CLxIPuLR.js";import{d as o,f as s}from"./agent-scope-DAWJwFfl.js";import{t as c,v as l,x as u}from"./utils-CGdo13HV.js";import"./openclaw-root-CnsBf6ZU.js";import"./github-copilot-token-C79yeDKS.js";import{_ as d}from"./env-overrides-DHtB4kK3.js";import"./version-q3SkUw2K.js";import{n as f,r as p}from"./scan-paths-CWtvWW40.js";import"./registry-BptzrW8D.js";import"./skills-CKTicUKS.js";import{m}from"./frontmatter-C7mzDNxd.js";import"./plugins-DNlgeTTc.js";import"./logger-kQAOe3qp.js";import"./exec-B3eleY5O.js";import"./windows-spawn-7oINn5ao.js";import"./redact-CnRxK70G.js";import"./path-alias-guards-kY_ZbWs-.js";import"./errors-6SQWM9dj.js";import"./send-CW81y5Wz.js";import"./send-DavpkzhH.js";import"./compact-BEeB6bwq.js";import"./paths-BfjJY2VL.js";import"./chat-envelope-Bznn2SoS.js";import"./models-config-_htt7eY5.js";import"./tokens-DRM8vzJx.js";import"./with-timeout-c1CzdShT.js";import"./deliver-BHuhHfkH.js";import"./diagnostic-DQq4Bwrs.js";import"./send-DkiKKUkt.js";import"./pi-model-discovery-CpjYoBQf.js";import"./exec-approvals-allowlist-D8mN7nxV.js";import"./exec-safe-bin-runtime-policy-dcCS_Adf.js";import"./model-catalog-COVzoZD9.js";import"./fetch-CQaNr5J1.js";import"./audio-transcription-runner-Bd1OZC6K.js";import"./fetch-guard-BrTtJw7h.js";import"./image-BkWwI54C.js";import"./tool-display-DJDtttQg.js";import"./api-key-rotation-D0QU-kQ9.js";import"./proxy-fetch-gWETR3cl.js";import"./ir-D8Hh84ab.js";import"./render-DrrPmnMI.js";import"./target-errors-CgWAJOam.js";import"./commands-Dy7duWlt.js";import"./commands-registry-Cpl4QnG4.js";import"./session-cost-usage-CHtVgnE8.js";import"./session-utils-8acNlxwP.js";import"./sqlite-CILF3z9U.js";import"./call-B8Fb4_oh.js";import"./pi-tools.policy-D40r0HmD.js";import"./pairing-store-BH-FTYkn.js";import"./fetch-Dh-apy46.js";import"./skill-commands-CSF6wVPU.js";import"./workspace-dirs-A8Vib9_B.js";import"./pairing-token-DAR7V7FJ.js";import"./channel-activity-BBrgoad1.js";import"./tables-Brc2lNcB.js";import"./kill-tree-B3g7HrAO.js";import"./runtime-web-tools-D8fms06-.js";import"./runtime-Dlg2-Omq.js";import"./node-shell-DyOfwHrh.js";import"./stagger-DxzgG2jd.js";import"./channel-selection-BBeE1TmB.js";import"./plugin-auto-enable-NzmNh4oU.js";import"./send-CVplsJpw.js";import"./outbound-attachment-BgAe99RM.js";import"./delivery-queue-nkPJu0fY.js";import"./send-C48Y9SAq.js";import"./system-run-command-BKfMiqQM.js";import"./fetch-Ce-scEU-.js";import"./command-secret-targets-BlN-J_fA.js";import"./connection-auth-B_Uk6Vk8.js";import"./onboard-helpers-PGl5bVPE.js";import"./prompt-style-BThRSQJR.js";import"./pairing-labels-D-kzQEL2.js";import"./search-manager-Bp9x20r6.js";import"./manager-C2YW7Hkq.js";import"./memory-cli-XaxtBQm1.js";import{t as h}from"./links-CBnmRP9D.js";import"./cli-utils-BleB1eys.js";import"./help-format-B4aEI7V9.js";import"./progress-d1m2sqR1.js";import"./exec-approvals-BXO9Cezj.js";import{a as ee,c as g,l as te,n as _,u as v}from"./install-safe-path-C6kc_8NW.js";import{a as y,c as b,f as ne,i as re,l as ie,n as ae,o as x,r as oe,s as se,t as ce,u as le}from"./npm-pack-install-C0te3Oap.js";import{n as ue,t as de}from"./table-CR7TFMew.js";import{a as S,t as C}from"./workspace-xNEpaJvu.js";import{t as w}from"./hooks-status-BHt-Xvh4.js";import{i as T,n as E,r as fe,t as pe}from"./npm-resolution-Ct6MRtq6.js";import D from"node:path";import O from"node:fs";import k from"node:fs/promises";async function me(e){let t=e.spec.trim(),n=d(t);return n?{ok:!1,error:n}:ce(await ae({tempDirPrefix:e.tempDirPrefix,spec:t,timeoutMs:e.timeoutMs,expectedIntegrity:e.expectedIntegrity,onIntegrityDrift:e.onIntegrityDrift,warn:e.warn,installFromArchive:e.installFromArchive,archiveInstallParams:e.archiveInstallParams}))}const A={};function j(e){return{hooksDir:e.hooksDir,timeoutMs:e.timeoutMs,logger:e.logger,mode:e.mode,dryRun:e.dryRun,expectedHookPackId:e.expectedHookPackId}}function M(e){return e?e===`.`||e===`..`?`invalid hook name: reserved path segment`:e.includes(`/`)||e.includes(`\\`)?`invalid hook name: path separators not allowed`:null:`invalid hook name: missing`}function N(e,t){let n=t?l(t):D.join(c,`hooks`),r=M(e);if(r)throw Error(r);let i=_({baseDir:n,id:e,invalidNameMessage:`invalid hook name: path traversal detected`});if(!i.ok)throw Error(i.error);return i.path}async function P(e){let t=e[m]?.hooks;if(!Array.isArray(t))throw Error(`package.json missing openclaw.hooks`);let n=t.map(e=>typeof e==`string`?e.trim():``).filter(Boolean);if(n.length===0)throw Error(`package.json openclaw.hooks is empty`);return n}async function F(e,t){return await re({baseDir:t?l(t):D.join(c,`hooks`),id:e,invalidNameMessage:`invalid hook name: path traversal detected`,boundaryLabel:`hooks directory`})}async function I(e){let t=await F(e.id,e.hooksDir);if(!t.ok)return t;let n=t.targetDir,r=await oe({mode:e.mode,targetDir:n,alreadyExistsError:e.alreadyExistsError(n)});return r.ok?{ok:!0,targetDir:n}:r}async function L(e,t){return await g(D.join(e,`package.json`))?await he({packageDir:e,hooksDir:t.hooksDir,timeoutMs:t.timeoutMs,logger:t.logger,mode:t.mode,dryRun:t.dryRun,expectedHookPackId:t.expectedHookPackId}):await ge({hookDir:e,hooksDir:t.hooksDir,logger:t.logger,mode:t.mode,dryRun:t.dryRun,expectedHookPackId:t.expectedHookPackId})}async function R(e){let t=D.join(e,`HOOK.md`);if(!await g(t))throw Error(`HOOK.md missing in ${e}`);return S(await k.readFile(t,`utf-8`)).name||D.basename(e)}async function z(e){if(!await g(D.join(e,`HOOK.md`)))throw Error(`HOOK.md missing in ${e}`);if(!await Promise.all([`handler.ts`,`handler.js`,`index.ts`,`index.js`].map(async t=>g(D.join(e,t)))).then(e=>e.some(Boolean)))throw Error(`handler.ts/handler.js/index.ts/index.js missing in ${e}`)}async function he(e){let{logger:t,timeoutMs:n,mode:r,dryRun:i}=b(e,A),a=D.join(e.packageDir,`package.json`);if(!await g(a))return{ok:!1,error:`package.json missing`};let o;try{o=await te(a)}catch(e){return{ok:!1,error:`invalid package.json: ${String(e)}`}}let s;try{s=await P(o)}catch(e){return{ok:!1,error:String(e)}}let c=typeof o.name==`string`?o.name:``,l=c?ee(c):D.basename(e.packageDir),u=M(l);if(u)return{ok:!1,error:u};if(e.expectedHookPackId&&e.expectedHookPackId!==l)return{ok:!1,error:`hook pack id mismatch: expected ${e.expectedHookPackId}, got ${l}`};let d=await I({id:l,hooksDir:e.hooksDir,mode:r,alreadyExistsError:e=>`hook pack already exists: ${e} (delete it first)`});if(!d.ok)return d;let m=d.targetDir,h=[];for(let t of s){let n=D.resolve(e.packageDir,t);if(!f(e.packageDir,n))return{ok:!1,error:`openclaw.hooks entry escapes package directory: ${t}`};if(await z(n),!p(e.packageDir,n,{requireRealpath:!0}))return{ok:!1,error:`openclaw.hooks entry resolves outside package directory: ${t}`};let r=await R(n);h.push(r)}if(i)return{ok:!0,hookPackId:l,hooks:h,targetDir:m,version:typeof o.version==`string`?o.version:void 0};let _=await x({sourceDir:e.packageDir,targetDir:m,mode:r,timeoutMs:n,logger:t,copyErrorPrefix:`failed to copy hook pack`,depsLogMessage:`Installing hook pack dependencies…`,manifestDependencies:o.dependencies});return _.ok?{ok:!0,hookPackId:l,hooks:h,targetDir:m,version:typeof o.version==`string`?o.version:void 0}:_}async function ge(e){let{logger:t,mode:n,dryRun:r}=se(e,A);await z(e.hookDir);let i=await R(e.hookDir),a=M(i);if(a)return{ok:!1,error:a};if(e.expectedHookPackId&&e.expectedHookPackId!==i)return{ok:!1,error:`hook id mismatch: expected ${e.expectedHookPackId}, got ${i}`};let o=await I({id:i,hooksDir:e.hooksDir,mode:n,alreadyExistsError:e=>`hook already exists: ${e} (delete it first)`});if(!o.ok)return o;let s=o.targetDir;if(r)return{ok:!0,hookPackId:i,hooks:[i],targetDir:s};let c=await y({sourceDir:e.hookDir,targetDir:s,mode:n,timeoutMs:12e4,logger:t,copyErrorPrefix:`failed to copy hook`,hasDeps:!1,depsLogMessage:`Installing hook dependencies…`});return c.ok?{ok:!0,hookPackId:i,hooks:[i],targetDir:s}:c}async function B(e){let t=e.logger??A,n=e.timeoutMs??12e4,r=await ne(e.archivePath);if(!r.ok)return r;let i=r.path;return await le({archivePath:i,tempDirPrefix:`openclaw-hook-`,timeoutMs:n,logger:t,onExtracted:async r=>await L(r,j({hooksDir:e.hooksDir,timeoutMs:n,logger:t,mode:e.mode,dryRun:e.dryRun,expectedHookPackId:e.expectedHookPackId}))})}async function V(e){let{logger:t,timeoutMs:n,mode:r,dryRun:i}=b(e,A),a=e.expectedHookPackId,o=e.spec;return t.info?.(`Downloading ${o.trim()}…`),await me({tempDirPrefix:`openclaw-hook-pack-`,spec:o,timeoutMs:n,expectedIntegrity:e.expectedIntegrity,onIntegrityDrift:e.onIntegrityDrift,warn:e=>{t.warn?.(e)},installFromArchive:B,archiveInstallParams:j({hooksDir:e.hooksDir,timeoutMs:n,logger:t,mode:r,dryRun:i,expectedHookPackId:a})})}async function H(e){let t=await ie(e.path);if(!t.ok)return t;let{resolvedPath:n,stat:r}=t,i=j({hooksDir:e.hooksDir,timeoutMs:e.timeoutMs,logger:e.logger,mode:e.mode,dryRun:e.dryRun,expectedHookPackId:e.expectedHookPackId});return r.isDirectory()?await L(n,i):v(n)?await B({archivePath:n,...i}):{ok:!1,error:`unsupported hook file: ${n}`}}function U(e,t){let{hookId:n,...r}=t,i={...e.hooks?.internal?.installs,[n]:{...e.hooks?.internal?.installs?.[n],...r,installedAt:r.installedAt??new Date().toISOString()}};return{...e,hooks:{...e.hooks,internal:{...e.hooks?.internal,installs:{...i,[n]:i[n]}}}}}function _e(e,t){let n=new Map;for(let t of e)n.set(t.hook.name,t);for(let e of t)n.set(e.hook.name,e);return Array.from(n.values())}function W(e){let t=o(e,s(e)),n=C(t,{config:e});return w(t,{config:e,entries:_e(T({config:e,workspaceDir:t}).hooks.map(e=>e.entry),n)})}function G(e,t,n){let r=e.hooks.find(e=>e.name===t);if(!r)throw Error(`Hook "${t}" not found`);if(r.managedByPlugin)throw Error(`Hook "${t}" is managed by plugin "${r.pluginId??`unknown`}" and cannot be enabled/disabled.`);if(n?.requireEligible&&!r.eligible)throw Error(`Hook "${t}" is not eligible (missing requirements)`);return r}function K(e){let t={...e.config.hooks?.internal?.entries};t[e.hookName]={...t[e.hookName],enabled:e.enabled};let n={...e.config.hooks?.internal,...e.ensureHooksEnabled?{enabled:!0}:{},entries:t};return{...e.config,hooks:{...e.config.hooks,internal:n}}}function ve(t){return t.eligible?e.success(`✓ ready`):t.disabled?e.warn(`⏸ disabled`):e.error(`✗ missing`)}function ye(t){return`${t.emoji??`🔗`} ${e.command(t.name)}`}function be(e){return e.managedByPlugin?`plugin:${e.pluginId??`unknown`}`:e.source}function xe(e){let t=[];return e.missing.bins.length>0&&t.push(`bins: ${e.missing.bins.join(`, `)}`),e.missing.anyBins.length>0&&t.push(`anyBins: ${e.missing.anyBins.join(`, `)}`),e.missing.env.length>0&&t.push(`env: ${e.missing.env.join(`, `)}`),e.missing.config.length>0&&t.push(`config: ${e.missing.config.join(`, `)}`),e.missing.os.length>0&&t.push(`os: ${e.missing.os.join(`, `)}`),t.join(`; `)}function Se(n){t.error(`${e.error(`Error:`)} ${n instanceof Error?n.message:String(n)}`),process.exit(1)}async function q(e){try{await e()}catch(e){Se(e)}}function J(){return{info:e=>t.log(e),warn:n=>t.log(e.warn(n))}}function Y(){t.log(`Restart the gateway to load hooks.`)}function X(n,r){let i=r.resolution.resolvedSpec??r.spec;t.log(e.warn(`Integrity drift detected for "${n}" (${i})\nExpected: ${r.expectedIntegrity}\nActual: ${r.actualIntegrity}`))}async function Z(e){try{let t=await k.readFile(D.join(e,`package.json`),`utf-8`),n=JSON.parse(t);return typeof n.version==`string`?n.version:void 0}catch{return}}function Q(e,t){let n={...e.hooks?.internal?.entries};for(let e of t)n[e]={...n[e],enabled:!0};return{...e,hooks:{...e.hooks,internal:{...e.hooks?.internal,enabled:!0,entries:n}}}}function $(t,n){let r=n.eligible?t.hooks.filter(e=>e.eligible):t.hooks;if(n.json){let e={workspaceDir:t.workspaceDir,managedHooksDir:t.managedHooksDir,hooks:r.map(e=>({name:e.name,description:e.description,emoji:e.emoji,eligible:e.eligible,disabled:e.disabled,source:e.source,pluginId:e.pluginId,events:e.events,homepage:e.homepage,missing:e.missing,managedByPlugin:e.managedByPlugin}))};return JSON.stringify(e,null,2)}if(r.length===0)return n.eligible?`No eligible hooks found. Run \`${a(`openclaw hooks list`)}\` to see all hooks.`:`No hooks found.`;let i=r.filter(e=>e.eligible),o=de(),s=r.map(t=>{let n=xe(t);return{Status:ve(t),Hook:ye(t),Description:e.muted(t.description),Source:be(t),Missing:n?e.warn(n):``}}),c=[{key:`Status`,header:`Status`,minWidth:10},{key:`Hook`,header:`Hook`,minWidth:18,flex:!0},{key:`Description`,header:`Description`,minWidth:24,flex:!0},{key:`Source`,header:`Source`,minWidth:12,flex:!0}];n.verbose&&c.push({key:`Missing`,header:`Missing`,minWidth:18,flex:!0});let l=[];return l.push(`${e.heading(`Hooks`)} ${e.muted(`(${i.length}/${r.length} ready)`)}`),l.push(ue({width:o,columns:c,rows:s}).trimEnd()),l.join(`
|
|
2
2
|
`)}function Ce(t,n,r){let i=t.hooks.find(e=>e.name===n||e.hookKey===n);if(!i)return r.json?JSON.stringify({error:`not found`,hook:n},null,2):`Hook "${n}" not found. Run \`${a(`openclaw hooks list`)}\` to see available hooks.`;if(r.json)return JSON.stringify(i,null,2);let o=[],s=i.emoji??`🔗`,c=i.eligible?e.success(`✓ Ready`):i.disabled?e.warn(`⏸ Disabled`):e.error(`✗ Missing requirements`);if(o.push(`${s} ${e.heading(i.name)} ${c}`),o.push(``),o.push(i.description),o.push(``),o.push(e.heading(`Details:`)),i.managedByPlugin?o.push(`${e.muted(` Source:`)} ${i.source} (${i.pluginId??`unknown`})`):o.push(`${e.muted(` Source:`)} ${i.source}`),o.push(`${e.muted(` Path:`)} ${u(i.filePath)}`),o.push(`${e.muted(` Handler:`)} ${u(i.handlerPath)}`),i.homepage&&o.push(`${e.muted(` Homepage:`)} ${i.homepage}`),i.events.length>0&&o.push(`${e.muted(` Events:`)} ${i.events.join(`, `)}`),i.managedByPlugin&&o.push(e.muted(` Managed by plugin; enable/disable via hooks CLI not available.`)),i.requirements.bins.length>0||i.requirements.anyBins.length>0||i.requirements.env.length>0||i.requirements.config.length>0||i.requirements.os.length>0){if(o.push(``),o.push(e.heading(`Requirements:`)),i.requirements.bins.length>0){let t=i.requirements.bins.map(t=>i.missing.bins.includes(t)?e.error(`✗ ${t}`):e.success(`✓ ${t}`));o.push(`${e.muted(` Binaries:`)} ${t.join(`, `)}`)}if(i.requirements.anyBins.length>0){let t=i.missing.anyBins.length>0?e.error(`✗ (any of: ${i.requirements.anyBins.join(`, `)})`):e.success(`✓ (any of: ${i.requirements.anyBins.join(`, `)})`);o.push(`${e.muted(` Any binary:`)} ${t}`)}if(i.requirements.env.length>0){let t=i.requirements.env.map(t=>i.missing.env.includes(t)?e.error(`✗ ${t}`):e.success(`✓ ${t}`));o.push(`${e.muted(` Environment:`)} ${t.join(`, `)}`)}if(i.requirements.config.length>0){let t=i.configChecks.map(t=>t.satisfied?e.success(`✓ ${t.path}`):e.error(`✗ ${t.path}`));o.push(`${e.muted(` Config:`)} ${t.join(`, `)}`)}if(i.requirements.os.length>0){let t=i.missing.os.length>0?e.error(`✗ (${i.requirements.os.join(`, `)})`):e.success(`✓ (${i.requirements.os.join(`, `)})`);o.push(`${e.muted(` OS:`)} ${t}`)}}return o.join(`
|
|
3
3
|
`)}function we(t,n){if(n.json){let e=t.hooks.filter(e=>e.eligible),n=t.hooks.filter(e=>!e.eligible);return JSON.stringify({total:t.hooks.length,eligible:e.length,notEligible:n.length,hooks:{eligible:e.map(e=>e.name),notEligible:n.map(e=>({name:e.name,missing:e.missing}))}},null,2)}let r=t.hooks.filter(e=>e.eligible),i=t.hooks.filter(e=>!e.eligible),a=[];if(a.push(e.heading(`Hooks Status`)),a.push(``),a.push(`${e.muted(`Total hooks:`)} ${t.hooks.length}`),a.push(`${e.success(`Ready:`)} ${r.length}`),a.push(`${e.warn(`Not ready:`)} ${i.length}`),i.length>0){a.push(``),a.push(e.heading(`Hooks not ready:`));for(let e of i){let t=[];e.disabled&&t.push(`disabled`),e.missing.bins.length>0&&t.push(`bins: ${e.missing.bins.join(`, `)}`),e.missing.anyBins.length>0&&t.push(`anyBins: ${e.missing.anyBins.join(`, `)}`),e.missing.env.length>0&&t.push(`env: ${e.missing.env.join(`, `)}`),e.missing.config.length>0&&t.push(`config: ${e.missing.config.join(`, `)}`),e.missing.os.length>0&&t.push(`os: ${e.missing.os.join(`, `)}`),a.push(` ${e.emoji??`🔗`} ${e.name} - ${t.join(`; `)}`)}}return a.join(`
|
|
4
4
|
`)}async function Te(i){let a=r(),o=G(W(a),i,{requireEligible:!0});await n(K({config:a,hookName:i,enabled:!0,ensureHooksEnabled:!0})),t.log(`${e.success(`✓`)} Enabled hook: ${o.emoji??`🔗`} ${e.command(i)}`)}async function Ee(i){let a=r(),o=G(W(a),i);await n(K({config:a,hookName:i,enabled:!1})),t.log(`${e.warn(`⏸`)} Disabled hook: ${o.emoji??`🔗`} ${e.command(i)}`)}function De(a){let o=a.command(`hooks`).description(`Manage internal agent hooks`).addHelpText(`after`,()=>`\n${e.muted(`Docs:`)} ${h(`/cli/hooks`,`docs.openclaw.ai/cli/hooks`)}\n`);o.command(`list`).description(`List all hooks`).option(`--eligible`,`Show only eligible hooks`,!1).option(`--json`,`Output as JSON`,!1).option(`-v, --verbose`,`Show more details including missing requirements`,!1).action(async e=>q(async()=>{let n=W(r());t.log($(n,e))})),o.command(`info <name>`).description(`Show detailed information about a hook`).option(`--json`,`Output as JSON`,!1).action(async(e,n)=>q(async()=>{let i=W(r());t.log(Ce(i,e,n))})),o.command(`check`).description(`Check hooks eligibility status`).option(`--json`,`Output as JSON`,!1).action(async e=>q(async()=>{let n=W(r());t.log(we(n,e))})),o.command(`enable <name>`).description(`Enable a hook`).action(async e=>q(async()=>{await Te(e)})),o.command(`disable <name>`).description(`Disable a hook`).action(async e=>q(async()=>{await Ee(e)})),o.command(`install`).description(`Install a hook pack (path, archive, or npm spec)`).argument(`<path-or-spec>`,`Path to a hook pack or npm package spec`).option(`-l, --link`,`Link a local path instead of copying`,!1).option(`--pin`,`Record npm installs as exact resolved <name>@<version>`,!1).action(async(i,a)=>{let o=l(i),s=r();if(O.existsSync(o)){if(a.link){O.statSync(o).isDirectory()||(t.error(`Linked hook paths must be directories.`),process.exit(1));let e=s.hooks?.internal?.load?.extraDirs??[],r=Array.from(new Set([...e,o])),i=await H({path:o,dryRun:!0});i.ok||(t.error(i.error),process.exit(1));let a={...s,hooks:{...s.hooks,internal:{...s.hooks?.internal,enabled:!0,load:{...s.hooks?.internal?.load,extraDirs:r}}}};a=Q(a,i.hooks),a=U(a,{hookId:i.hookPackId,source:`path`,sourcePath:o,installPath:o,version:i.version,hooks:i.hooks}),await n(a),t.log(`Linked hook path: ${u(o)}`),Y();return}let e=await H({path:o,logger:J()});e.ok||(t.error(e.error),process.exit(1));let r=Q(s,e.hooks),i=v(o)?`archive`:`path`;r=U(r,{hookId:e.hookPackId,source:i,sourcePath:o,installPath:e.targetDir,version:e.version,hooks:e.hooks}),await n(r),t.log(`Installed hooks: ${e.hooks.join(`, `)}`),Y();return}a.link&&(t.error("`--link` requires a local path."),process.exit(1)),fe(i,[`.zip`,`.tgz`,`.tar.gz`,`.tar`])&&(t.error(`Path not found: ${o}`),process.exit(1));let c=await V({spec:i,logger:J()});c.ok||(t.error(c.error),process.exit(1));let d=Q(s,c.hooks),f=E(i,!!a.pin,c.targetDir,c.version,c.npmResolution,t.log,e.warn);d=U(d,{hookId:c.hookPackId,...f,hooks:c.hooks}),await n(d),t.log(`Installed hooks: ${c.hooks.join(`, `)}`),Y()}),o.command(`update`).description(`Update installed hooks (npm installs only)`).argument(`[id]`,`Hook pack id (omit with --all)`).option(`--all`,`Update all tracked hooks`,!1).option(`--dry-run`,`Show what would change without writing`,!1).action(async(a,o)=>{let s=r(),c=s.hooks?.internal?.installs??{},l=o.all?Object.keys(c):a?[a]:[];l.length===0&&(t.error(`Provide a hook id or use --all.`),process.exit(1));let u=s,d=0;for(let n of l){let r=c[n];if(!r){t.log(e.warn(`No install record for "${n}".`));continue}if(r.source!==`npm`){t.log(e.warn(`Skipping "${n}" (source: ${r.source}).`));continue}if(!r.spec){t.log(e.warn(`Skipping "${n}" (missing npm spec).`));continue}let a;try{a=r.installPath??N(n)}catch(r){t.log(e.error(`Invalid install path for "${n}": ${String(r)}`));continue}let s=await Z(a);if(o.dryRun){let i=await V({spec:r.spec,mode:`update`,dryRun:!0,expectedHookPackId:n,expectedIntegrity:r.integrity,onIntegrityDrift:async e=>(X(n,e),!0),logger:J()});if(!i.ok){t.log(e.error(`Failed to check ${n}: ${i.error}`));continue}let a=i.version??`unknown`,o=s??`unknown`;s&&i.version&&s===i.version?t.log(`${n} is up to date (${o}).`):t.log(`Would update ${n}: ${o} → ${a}.`);continue}let l=await V({spec:r.spec,mode:`update`,expectedHookPackId:n,expectedIntegrity:r.integrity,onIntegrityDrift:async e=>(X(n,e),await i(`Continue updating "${n}" with this artifact?`)),logger:J()});if(!l.ok){t.log(e.error(`Failed to update ${n}: ${l.error}`));continue}let f=l.version??await Z(l.targetDir);u=U(u,{hookId:n,...pe({spec:r.spec,installPath:l.targetDir,version:f,resolution:l.npmResolution}),hooks:l.hooks}),d+=1;let p=s??`unknown`,m=f??`unknown`;s&&f&&s===f?t.log(`${n} already at ${p}.`):t.log(`Updated ${n}: ${p} → ${m}.`)}d>0&&(await n(u),Y())}),o.action(async()=>q(async()=>{let e=W(r());t.log($(e,{}))}))}export{De as registerHooksCli};
|
|
5
|
-
//# sourceMappingURL=hooks-cli-
|
|
5
|
+
//# sourceMappingURL=hooks-cli-xgORhqZ2.js.map
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import"./paths-B4IRk3wi.js";import{A as e,B as t,J as n,K as r,R as i,W as a,Y as o,d as s,k as c,p as l,q as u,r as d,w as f}from"./subsystem-C5XF2Fy5.js";import{T as p,l as ee,m as te,n as ne}from"./utils-UGOV_184.js";import{Dr as m,Er as h,Hn as re,Io as ie,Kn as ae,Lo as oe,Ml as se,aa as ce,ia as le,oa as ue,qs as g,ra as de,zl as fe}from"./model-selection-BlC_rXAN.js";import{Ft as pe,gt as _,t as me}from"./reply-l-Y47HP4.js";import"./agent-scope-DXZc3eNT.js";import"./openclaw-root-D_0Q6--h.js";import"./github-copilot-token-DGYAlOmV.js";import{n as he,r as v}from"./command-format-BbDT1tlm.js";import"./boolean-Ch3DfXPy.js";import{r as y,t as b}from"./env-D7wNuBx1.js";import"./env-overrides-DXJbFrwI.js";import"./registry-hFAtCSWG.js";import"./skills-DHbOKEGc.js";import"./frontmatter-BkZkwkVO.js";import"./plugins-CYLrFT4h.js";import"./logger-Bl8URnrW.js";import{n as x,t as S}from"./exec-DHqLtFYt.js";import"./windows-spawn-AB7ItGAE.js";import"./redact-3_CiXMY6.js";import"./path-alias-guards-mvyLCPlN.js";import{i as C}from"./errors-Bunti32V.js";import"./send-Cgd_VJHR.js";import"./send-hZFDcGLM.js";import{c as w}from"./paths-yLEk_25I.js";import"./chat-envelope-HVpKusFc.js";import{S as T,l as E}from"./audio-transcription-runner-D4Bp6MM7.js";import"./image-DsoO5VP5.js";import"./models-config-CdMhNxKV.js";import"./tool-display-DjuSUUbH.js";import"./fetch-guard-DPdY0NXR.js";import"./api-key-rotation-BRt-vnRV.js";import"./local-roots-6waH0SZ0.js";import"./model-catalog-C1kpjR75.js";import"./proxy-fetch-BADsUK4d.js";import"./tokens-XGbQGn67.js";import"./deliver-ClBkV2eD.js";import"./commands-CGpM84iR.js";import"./commands-registry-B1x54ukc.js";import"./pairing-store-Cg2UxreQ.js";import"./fetch-Dikjvc5M.js";import"./call-CqoMqP5b.js";import"./with-timeout-WveKxvFV.js";import"./diagnostic-DOzHPnht.js";import"./send-B7sHR38c2.js";import"./pi-model-discovery-Dps1PPWz.js";import"./exec-approvals-allowlist-CE3nYh0K.js";import"./exec-safe-bin-runtime-policy-Dt0GchLp.js";import"./ir-Dk7OQ4bA.js";import"./render-D8OWO2hT.js";import"./target-errors-a35Md15n.js";import"./read-only-account-inspect-DBwAwB3_.js";import"./channel-selection-CbNtbAEf.js";import"./plugin-auto-enable-DpVL6-ES.js";import"./send-C-AP01PR.js";import"./outbound-attachment-B7wMxwj6.js";import"./delivery-queue-CKbauSFq.js";import"./send-DbeEC2a3.js";import"./channel-activity-YjYNzCpJ.js";import"./tables-Oieq7UbT.js";import"./fetch-Bn0mWg6a.js";import"./skill-commands-HJHHZqt6.js";import"./workspace-dirs-BhF1Dzxt.js";import"./pairing-token-BjYBuREl.js";import"./restart-CHXEHdSC.js";import"./runtime-web-tools-bz76ZaRc.js";import"./command-secret-targets-BVN3kiT9.js";import"./session-cost-usage-BgqKixv0.js";import"./connection-auth-C8iru0UB.js";import"./onboard-helpers-zwybUJWu.js";import"./prompt-style-CXKekIBY.js";import"./pairing-labels-BUU_-70B.js";import"./memory-cli-jhzJ3as7.js";import"./query-expansion-0OxEb1Io.js";import"./manager-M1GKhLUC.js";import{t as D}from"./links-CySwdMcF.js";import"./cli-utils-BY7dLMFy.js";import"./help-format-BRbF_INg.js";import"./progress-LNttnI-y.js";import"./exec-approvals-BpBNEy6i.js";import"./nodes-screen-DECgxo6A.js";import"./system-run-command-DEWnZE0r.js";import"./runtime-BC5Ep2pJ.js";import"./stagger-DmFYysrJ.js";import{r as O,t as k}from"./channel-web-CxHbET4B.js";import"./outbound-Bz8bbrMI.js";import"./session-CUUGjiV3.js";import"./login-CkWesqf_.js";import{t as A}from"./is-main-DG5ueqhF.js";import{t as j}from"./path-env-BPd1Yd-i.js";import{t as M}from"./runtime-guard-DFYBaYZS.js";import"./ports-BR0PLRtq.js";import{i as N,n as P,o as F,s as I}from"./program-context-B9ydtPje.js";import"./plugin-registry-CIBiHZH1.js";import{n as L}from"./channel-options-CEIzjOno.js";import R from"node:process";import{fileURLToPath as ge}from"node:url";import{Command as _e,InvalidArgumentError as ve}from"commander";function ye(){let e,t=()=>(e===void 0&&(e=L()),e);return{programVersion:se,get channelOptions(){return t()},get messageChannelOptions(){return t().join(`|`)},get agentChannelOptions(){return[`last`,...t()].join(`|`)}}}const z=`All your chats, one OpenClaw.`,B={newYear:`New Year's Day: New year, new config—same old EADDRINUSE, but this time we resolve it like grown-ups.`,lunarNewYear:`Lunar New Year: May your builds be lucky, your branches prosperous, and your merge conflicts chased away with fireworks.`,christmas:`Christmas: Ho ho ho—Santa's little claw-sistant is here to ship joy, roll back chaos, and stash the keys safely.`,eid:`Eid al-Fitr: Celebration mode: queues cleared, tasks completed, and good vibes committed to main with clean history.`,diwali:`Diwali: Let the logs sparkle and the bugs flee—today we light up the terminal and ship with pride.`,easter:`Easter: I found your missing environment variable—consider it a tiny CLI egg hunt with fewer jellybeans.`,hanukkah:`Hanukkah: Eight nights, eight retries, zero shame—may your gateway stay lit and your deployments stay peaceful.`,halloween:`Halloween: Spooky season: beware haunted dependencies, cursed caches, and the ghost of node_modules past.`,thanksgiving:`Thanksgiving: Grateful for stable ports, working DNS, and a bot that reads the logs so nobody has to.`,valentines:`Valentine's Day: Roses are typed, violets are piped—I'll automate the chores so you can spend time with humans.`},V=[`Your terminal just grew claws—type something and let the bot pinch the busywork.`,`Welcome to the command line: where dreams compile and confidence segfaults.`,`I run on caffeine, JSON5, and the audacity of "it worked on my machine."`,`Gateway online—please keep hands, feet, and appendages inside the shell at all times.`,`I speak fluent bash, mild sarcasm, and aggressive tab-completion energy.`,`One CLI to rule them all, and one more restart because you changed the port.`,`If it works, it's automation; if it breaks, it's a "learning opportunity."`,`Pairing codes exist because even bots believe in consent—and good security hygiene.`,`Your .env is showing; don't worry, I'll pretend I didn't see it.`,`I'll do the boring stuff while you dramatically stare at the logs like it's cinema.`,`I'm not saying your workflow is chaotic... I'm just bringing a linter and a helmet.`,`Type the command with confidence—nature will provide the stack trace if needed.`,`I don't judge, but your missing API keys are absolutely judging you.`,`I can grep it, git blame it, and gently roast it—pick your coping mechanism.`,`Hot reload for config, cold sweat for deploys.`,`I'm the assistant your terminal demanded, not the one your sleep schedule requested.`,`I keep secrets like a vault... unless you print them in debug logs again.`,`Automation with claws: minimal fuss, maximal pinch.`,`I'm basically a Swiss Army knife, but with more opinions and fewer sharp edges.`,`If you're lost, run doctor; if you're brave, run prod; if you're wise, run tests.`,`Your task has been queued; your dignity has been deprecated.`,`I can't fix your code taste, but I can fix your build and your backlog.`,`I'm not magic—I'm just extremely persistent with retries and coping strategies.`,`It's not "failing," it's "discovering new ways to configure the same thing wrong."`,`Give me a workspace and I'll give you fewer tabs, fewer toggles, and more oxygen.`,`I read logs so you can keep pretending you don't have to.`,`If something's on fire, I can't extinguish it—but I can write a beautiful postmortem.`,`I'll refactor your busywork like it owes me money.`,`Say "stop" and I'll stop—say "ship" and we'll both learn a lesson.`,`I'm the reason your shell history looks like a hacker-movie montage.`,`I'm like tmux: confusing at first, then suddenly you can't live without me.`,`I can run local, remote, or purely on vibes—results may vary with DNS.`,`If you can describe it, I can probably automate it—or at least make it funnier.`,`Your config is valid, your assumptions are not.`,`I don't just autocomplete—I auto-commit (emotionally), then ask you to review (logically).`,`Less clicking, more shipping, fewer "where did that file go" moments.`,`Claws out, commit in—let's ship something mildly responsible.`,`I'll butter your workflow like a lobster roll: messy, delicious, effective.`,`Shell yeah—I'm here to pinch the toil and leave you the glory.`,`If it's repetitive, I'll automate it; if it's hard, I'll bring jokes and a rollback plan.`,`The only crab in your contacts you actually want to hear from. 🦞`,`WhatsApp automation without the "please accept our new privacy policy".`,`iMessage green bubble energy, but for everyone.`,`No $999 stand required.`,`We ship features faster than Apple ships calculator updates.`,`Your AI assistant, now without the $3,499 headset.`,`Ah, the fruit tree company! 🍎`,`Greetings, Professor Falken`,`I don't sleep, I just enter low-power mode and dream of clean diffs.`,`Your personal assistant, minus the passive-aggressive calendar reminders.`,`Built by lobsters, for humans. Don't question the hierarchy.`,`I've seen your commit messages. We'll work on that together.`,`More integrations than your therapist's intake form.`,`Running on your hardware, reading your logs, judging nothing (mostly).`,`The only open-source project where the mascot could eat the competition.`,`Self-hosted, self-updating, self-aware (just kidding... unless?).`,`I autocomplete your thoughts—just slower and with more API calls.`,`Somewhere between 'hello world' and 'oh god what have I built.'`,`Your .zshrc wishes it could do what I do.`,`I've read more man pages than any human should—so you don't have to.`,`Powered by open source, sustained by spite and good documentation.`,`I'm the middleware between your ambition and your attention span.`,`Finally, a use for that always-on Mac Mini under your desk.`,`Like having a senior engineer on call, except I don't bill hourly or sigh audibly.`,`Making 'I'll automate that later' happen now.`,`Your second brain, except this one actually remembers where you left things.`,`Half butler, half debugger, full crustacean.`,`I don't have opinions about tabs vs spaces. I have opinions about everything else.`,`Open source means you can see exactly how I judge your config.`,`I've survived more breaking changes than your last three relationships.`,`Runs on a Raspberry Pi. Dreams of a rack in Iceland.`,`The lobster in your shell. 🦞`,`Alexa, but with taste.`,`I'm not AI-powered, I'm AI-possessed. Big difference.`,`Deployed locally, trusted globally, debugged eternally.`,`You had me at 'openclaw gateway start.'`,B.newYear,B.lunarNewYear,B.christmas,B.eid,B.diwali,B.easter,B.hanukkah,B.halloween,B.thanksgiving,B.valentines],H=1440*60*1e3;function U(e){return{year:e.getUTCFullYear(),month:e.getUTCMonth(),day:e.getUTCDate()}}const W=(e,t)=>n=>{let r=U(n);return r.month===e&&r.day===t},G=(e,t=1)=>n=>{let r=U(n);return e.some(([e,n,i])=>{if(r.year!==e)return!1;let a=Date.UTC(e,n,i),o=Date.UTC(r.year,r.month,r.day);return o>=a&&o<a+t*H})},be=new Map([[B.newYear,W(0,1)],[B.lunarNewYear,G([[2025,0,29],[2026,1,17],[2027,1,6]],1)],[B.eid,G([[2025,2,30],[2025,2,31],[2026,2,20],[2027,2,10]],1)],[B.diwali,G([[2025,9,20],[2026,10,8],[2027,9,28]],1)],[B.easter,G([[2025,3,20],[2026,3,5],[2027,2,28]],1)],[B.hanukkah,(e=>t=>{let n=U(t),r=e.find(e=>e.year===n.year);if(!r)return!1;let i=Date.UTC(r.year,r.month,r.day),a=Date.UTC(n.year,n.month,n.day);return a>=i&&a<i+r.duration*H})([{year:2025,month:11,day:15,duration:8},{year:2026,month:11,day:5,duration:8},{year:2027,month:11,day:25,duration:8}])],[B.halloween,W(9,31)],[B.thanksgiving,e=>{let t=U(e);if(t.month!==10)return!1;let n=1+(4-new Date(Date.UTC(t.year,10,1)).getUTCDay()+7)%7+21;return t.day===n}],[B.valentines,W(1,14)],[B.christmas,W(11,25)]]);function xe(e,t){let n=be.get(e);return n?n(t):!0}function Se(e={}){if(V.length===0)return[z];let t=e.now?e.now():new Date,n=V.filter(e=>xe(e,t));return n.length>0?n:V}function Ce(e={}){if(e.mode===`off`)return``;if(e.mode===`default`)return z;let t=(e.env??process.env)?.OPENCLAW_TAGLINE_INDEX;if(t!==void 0){let e=Number.parseInt(t,10);if(!Number.isNaN(e)&&e>=0){let t=V.length>0?V:[z];return t[e%t.length]}}let n=Se(e),r=e.random??Math.random;return n[Math.floor(r()*n.length)%n.length]}let K=!1;typeof Intl<`u`&&`Segmenter`in Intl&&new Intl.Segmenter(void 0,{granularity:`grapheme`});const we=e=>e.some(e=>e===`--json`||e.startsWith(`--json=`)),Te=e=>e.some(e=>e===`--version`||e===`-V`)||o(e);function q(e){if(e===`random`||e===`default`||e===`off`)return e}function Ee(e){let t=q(e.mode);if(t)return t;try{return q(g().cli?.banner?.taglineMode)}catch{return}}function J(t,n={}){let r=n.commit??_({env:n.env,moduleUrl:import.meta.url})??`unknown`,i=Ce({...n,mode:Ee(n)}),a=n.richTty??c(),o=`🦞 OpenClaw`,l=n.columns??process.stdout.columns??120,u=`${o} ${t} (${r})`,d=i?`${u} — ${i}`:u,f=s(d)<=l;if(a){if(f)return i?`${e.heading(o)} ${e.info(t)} ${e.muted(`(${r})`)} ${e.muted(`—`)} ${e.accentDim(i)}`:`${e.heading(o)} ${e.info(t)} ${e.muted(`(${r})`)}`;let n=`${e.heading(o)} ${e.info(t)} ${e.muted(`(${r})`)}`;return i?`${n}\n${`${` `.repeat(3)}${e.accentDim(i)}`}`:n}if(f)return d;let p=u;return i?`${p}\n${`${` `.repeat(3)}${i}`}`:p}function De(e,t={}){if(K)return;let n=t.argv??process.argv;if(!process.stdout.isTTY||we(n)||Te(n))return;let r=J(e,t);process.stdout.write(`\n${r}\n\n`),K=!0}function Oe(){return K}const Y=i.join(`|`);function ke(e){let n=t(e);if(!n)throw new ve(`Invalid --log-level (use ${Y})`);return n}const X=v(),Ae=ee(X),je=new Set([...N(),...I()]),Me=[[`openclaw models --help`,`Show detailed help for the models command.`],[`openclaw channels login --verbose`,`Link personal WhatsApp Web and show QR + connection logs.`],[`openclaw message send --target +15555550123 --message "Hi" --json`,`Send via your web session and print JSON result.`],[`openclaw gateway --port 18789`,`Run the WebSocket Gateway locally.`],[`openclaw --dev gateway`,`Run a dev Gateway (isolated state/config) on ws://127.0.0.1:19001.`],[`openclaw gateway --force`,`Kill anything bound to the default gateway port, then start it.`],[`openclaw gateway ...`,`Gateway control via WebSocket.`],[`openclaw agent --to +15555550123 --message "Run summary" --deliver`,`Talk directly to the agent using the Gateway; optionally send the WhatsApp reply.`],[`openclaw message send --channel telegram --target @mychat --message "Hi"`,`Send via your Telegram bot.`]];function Ne(t,n){t.name(X).description(``).version(n.programVersion).option(`--dev`,`Dev profile: isolate state under ~/.qbotclaw-dev, default gateway port 19001, and shift derived ports (browser/canvas)`).option(`--profile <name>`,`Use a named profile (isolates OPENCLAW_STATE_DIR/OPENCLAW_CONFIG_PATH under ~/.qbotclaw-<name>)`).option(`--log-level <level>`,`Global log level override for file + console (${Y})`,ke),t.option(`--no-color`,`Disable ANSI colors`,!1),t.helpOption(`-h, --help`,`Display help for command`),t.helpCommand(`help [command]`,`Display help for command`),t.configureHelp({sortSubcommands:!0,sortOptions:!0,optionTerm:t=>e.option(t.flags),subcommandTerm:n=>{let r=n.parent===t&&je.has(n.name());return e.command(r?`${n.name()} *`:n.name())}});let r=t=>{let n=t;return RegExp(`^Usage:\\s+${Ae}\\s+\\[options\\]\\s+\\[command\\]\\s*$`,`m`).test(n)&&/^Commands:/m.test(n)&&(n=n.replace(/^Commands:/m,`Commands:\n ${e.muted(`Hint: commands suffixed with * have subcommands. Run <command> --help for details.`)}`)),n.replace(/^Usage:/gm,e.heading(`Usage:`)).replace(/^Options:/gm,e.heading(`Options:`)).replace(/^Commands:/gm,e.heading(`Commands:`))};if(t.configureOutput({writeOut:e=>{process.stdout.write(r(e))},writeErr:e=>{process.stderr.write(r(e))},outputError:(t,n)=>n(e.error(t))}),u(process.argv,`-V`)||u(process.argv,`--version`)||o(process.argv)){let e=_({moduleUrl:import.meta.url});console.log(e?`OpenClaw ${n.programVersion} (${e})`:`OpenClaw ${n.programVersion}`),process.exit(0)}t.addHelpText(`beforeAll`,()=>{if(Oe())return``;let e=c();return`\n${J(n.programVersion,{richTty:e})}\n`});let i=Me.map(([t,n])=>` ${e.command(he(t,X))}\n ${e.muted(n)}`).join(`
|
|
3
|
-
`);t.addHelpText(`afterAll`,({command:n})=>{if(n!==t)return``;let r=D(`/cli`,`docs.openclaw.ai/cli`);return`\n${e.heading(`Examples:`)}\n${i}\n\n${e.muted(`Docs:`)} ${r}\n`})}function Pe(e){let t=e;for(;t.parent&&t.parent.parent;)t=t.parent;let n=t.name(),r=v();!n||n===r||(process.title=`${r}-${n}`)}const Fe=new Set([`message`,`channels`,`directory`,`agents`,`configure`,`onboard`,`status`,`health`]),Ie=new Set([`backup`,`doctor`,`completion`,`secrets`]),Z=new Set([`config set`]);let Q,$;function Le(e){let[t,n]=e;return t?!!(Ie.has(t)||t===`config`&&n===`validate`):!1}function Re(){return Q??=import(`./config-guard-sYYx9zEF.js`),Q}function ze(){return $??=import(`./plugin-registry-
|
|
2
|
+
import"./paths-B4IRk3wi.js";import{A as e,B as t,J as n,K as r,R as i,W as a,Y as o,d as s,k as c,p as l,q as u,r as d,w as f}from"./subsystem-C5XF2Fy5.js";import{T as p,l as ee,m as te,n as ne}from"./utils-UGOV_184.js";import{Dr as m,Er as h,Hn as re,Io as ie,Kn as ae,Lo as oe,Ml as se,aa as ce,ia as le,oa as ue,qs as g,ra as de,zl as fe}from"./model-selection-BlC_rXAN.js";import{Ft as pe,gt as _,t as me}from"./reply-CjyZeZ-j.js";import"./agent-scope-DXZc3eNT.js";import"./openclaw-root-D_0Q6--h.js";import"./github-copilot-token-DGYAlOmV.js";import{n as he,r as v}from"./command-format-BbDT1tlm.js";import"./boolean-Ch3DfXPy.js";import{r as y,t as b}from"./env-D7wNuBx1.js";import"./env-overrides-DXJbFrwI.js";import"./registry-hFAtCSWG.js";import"./skills-DHbOKEGc.js";import"./frontmatter-BkZkwkVO.js";import"./plugins-CYLrFT4h.js";import"./logger-Bl8URnrW.js";import{n as x,t as S}from"./exec-DHqLtFYt.js";import"./windows-spawn-AB7ItGAE.js";import"./redact-3_CiXMY6.js";import"./path-alias-guards-mvyLCPlN.js";import{i as C}from"./errors-Bunti32V.js";import"./send-Cgd_VJHR.js";import"./send-hZFDcGLM.js";import{c as w}from"./paths-yLEk_25I.js";import"./chat-envelope-HVpKusFc.js";import{S as T,l as E}from"./audio-transcription-runner-D4Bp6MM7.js";import"./image-DsoO5VP5.js";import"./models-config-CdMhNxKV.js";import"./tool-display-DjuSUUbH.js";import"./fetch-guard-DPdY0NXR.js";import"./api-key-rotation-BRt-vnRV.js";import"./local-roots-6waH0SZ0.js";import"./model-catalog-C1kpjR75.js";import"./proxy-fetch-BADsUK4d.js";import"./tokens-XGbQGn67.js";import"./deliver-ClBkV2eD.js";import"./commands-CGpM84iR.js";import"./commands-registry-B1x54ukc.js";import"./pairing-store-Cg2UxreQ.js";import"./fetch-Dikjvc5M.js";import"./call-CqoMqP5b.js";import"./with-timeout-WveKxvFV.js";import"./diagnostic-DOzHPnht.js";import"./send-B7sHR38c2.js";import"./pi-model-discovery-Dps1PPWz.js";import"./exec-approvals-allowlist-CE3nYh0K.js";import"./exec-safe-bin-runtime-policy-Dt0GchLp.js";import"./ir-Dk7OQ4bA.js";import"./render-D8OWO2hT.js";import"./target-errors-a35Md15n.js";import"./read-only-account-inspect-DBwAwB3_.js";import"./channel-selection-CbNtbAEf.js";import"./plugin-auto-enable-DpVL6-ES.js";import"./send-C-AP01PR.js";import"./outbound-attachment-B7wMxwj6.js";import"./delivery-queue-CKbauSFq.js";import"./send-DbeEC2a3.js";import"./channel-activity-YjYNzCpJ.js";import"./tables-Oieq7UbT.js";import"./fetch-Bn0mWg6a.js";import"./skill-commands-HJHHZqt6.js";import"./workspace-dirs-BhF1Dzxt.js";import"./pairing-token-BjYBuREl.js";import"./restart-CHXEHdSC.js";import"./runtime-web-tools-bz76ZaRc.js";import"./command-secret-targets-BVN3kiT9.js";import"./session-cost-usage-BgqKixv0.js";import"./connection-auth-C8iru0UB.js";import"./onboard-helpers-zwybUJWu.js";import"./prompt-style-CXKekIBY.js";import"./pairing-labels-BUU_-70B.js";import"./memory-cli-jhzJ3as7.js";import"./query-expansion-0OxEb1Io.js";import"./manager-M1GKhLUC.js";import{t as D}from"./links-CySwdMcF.js";import"./cli-utils-BY7dLMFy.js";import"./help-format-BRbF_INg.js";import"./progress-LNttnI-y.js";import"./exec-approvals-BpBNEy6i.js";import"./nodes-screen-DECgxo6A.js";import"./system-run-command-DEWnZE0r.js";import"./runtime-BC5Ep2pJ.js";import"./stagger-DmFYysrJ.js";import{r as O,t as k}from"./channel-web-D7FkrASC.js";import"./outbound-Bz8bbrMI.js";import"./session-CUUGjiV3.js";import"./login-CkWesqf_.js";import{t as A}from"./is-main-DG5ueqhF.js";import{t as j}from"./path-env-BPd1Yd-i.js";import{t as M}from"./runtime-guard-DFYBaYZS.js";import"./ports-BR0PLRtq.js";import{i as N,n as P,o as F,s as I}from"./program-context-BX9wN65q.js";import"./plugin-registry-CI5K3iWc.js";import{n as L}from"./channel-options-Ce8uNnAp.js";import R from"node:process";import{fileURLToPath as ge}from"node:url";import{Command as _e,InvalidArgumentError as ve}from"commander";function ye(){let e,t=()=>(e===void 0&&(e=L()),e);return{programVersion:se,get channelOptions(){return t()},get messageChannelOptions(){return t().join(`|`)},get agentChannelOptions(){return[`last`,...t()].join(`|`)}}}const z=`All your chats, one OpenClaw.`,B={newYear:`New Year's Day: New year, new config—same old EADDRINUSE, but this time we resolve it like grown-ups.`,lunarNewYear:`Lunar New Year: May your builds be lucky, your branches prosperous, and your merge conflicts chased away with fireworks.`,christmas:`Christmas: Ho ho ho—Santa's little claw-sistant is here to ship joy, roll back chaos, and stash the keys safely.`,eid:`Eid al-Fitr: Celebration mode: queues cleared, tasks completed, and good vibes committed to main with clean history.`,diwali:`Diwali: Let the logs sparkle and the bugs flee—today we light up the terminal and ship with pride.`,easter:`Easter: I found your missing environment variable—consider it a tiny CLI egg hunt with fewer jellybeans.`,hanukkah:`Hanukkah: Eight nights, eight retries, zero shame—may your gateway stay lit and your deployments stay peaceful.`,halloween:`Halloween: Spooky season: beware haunted dependencies, cursed caches, and the ghost of node_modules past.`,thanksgiving:`Thanksgiving: Grateful for stable ports, working DNS, and a bot that reads the logs so nobody has to.`,valentines:`Valentine's Day: Roses are typed, violets are piped—I'll automate the chores so you can spend time with humans.`},V=[`Your terminal just grew claws—type something and let the bot pinch the busywork.`,`Welcome to the command line: where dreams compile and confidence segfaults.`,`I run on caffeine, JSON5, and the audacity of "it worked on my machine."`,`Gateway online—please keep hands, feet, and appendages inside the shell at all times.`,`I speak fluent bash, mild sarcasm, and aggressive tab-completion energy.`,`One CLI to rule them all, and one more restart because you changed the port.`,`If it works, it's automation; if it breaks, it's a "learning opportunity."`,`Pairing codes exist because even bots believe in consent—and good security hygiene.`,`Your .env is showing; don't worry, I'll pretend I didn't see it.`,`I'll do the boring stuff while you dramatically stare at the logs like it's cinema.`,`I'm not saying your workflow is chaotic... I'm just bringing a linter and a helmet.`,`Type the command with confidence—nature will provide the stack trace if needed.`,`I don't judge, but your missing API keys are absolutely judging you.`,`I can grep it, git blame it, and gently roast it—pick your coping mechanism.`,`Hot reload for config, cold sweat for deploys.`,`I'm the assistant your terminal demanded, not the one your sleep schedule requested.`,`I keep secrets like a vault... unless you print them in debug logs again.`,`Automation with claws: minimal fuss, maximal pinch.`,`I'm basically a Swiss Army knife, but with more opinions and fewer sharp edges.`,`If you're lost, run doctor; if you're brave, run prod; if you're wise, run tests.`,`Your task has been queued; your dignity has been deprecated.`,`I can't fix your code taste, but I can fix your build and your backlog.`,`I'm not magic—I'm just extremely persistent with retries and coping strategies.`,`It's not "failing," it's "discovering new ways to configure the same thing wrong."`,`Give me a workspace and I'll give you fewer tabs, fewer toggles, and more oxygen.`,`I read logs so you can keep pretending you don't have to.`,`If something's on fire, I can't extinguish it—but I can write a beautiful postmortem.`,`I'll refactor your busywork like it owes me money.`,`Say "stop" and I'll stop—say "ship" and we'll both learn a lesson.`,`I'm the reason your shell history looks like a hacker-movie montage.`,`I'm like tmux: confusing at first, then suddenly you can't live without me.`,`I can run local, remote, or purely on vibes—results may vary with DNS.`,`If you can describe it, I can probably automate it—or at least make it funnier.`,`Your config is valid, your assumptions are not.`,`I don't just autocomplete—I auto-commit (emotionally), then ask you to review (logically).`,`Less clicking, more shipping, fewer "where did that file go" moments.`,`Claws out, commit in—let's ship something mildly responsible.`,`I'll butter your workflow like a lobster roll: messy, delicious, effective.`,`Shell yeah—I'm here to pinch the toil and leave you the glory.`,`If it's repetitive, I'll automate it; if it's hard, I'll bring jokes and a rollback plan.`,`The only crab in your contacts you actually want to hear from. 🦞`,`WhatsApp automation without the "please accept our new privacy policy".`,`iMessage green bubble energy, but for everyone.`,`No $999 stand required.`,`We ship features faster than Apple ships calculator updates.`,`Your AI assistant, now without the $3,499 headset.`,`Ah, the fruit tree company! 🍎`,`Greetings, Professor Falken`,`I don't sleep, I just enter low-power mode and dream of clean diffs.`,`Your personal assistant, minus the passive-aggressive calendar reminders.`,`Built by lobsters, for humans. Don't question the hierarchy.`,`I've seen your commit messages. We'll work on that together.`,`More integrations than your therapist's intake form.`,`Running on your hardware, reading your logs, judging nothing (mostly).`,`The only open-source project where the mascot could eat the competition.`,`Self-hosted, self-updating, self-aware (just kidding... unless?).`,`I autocomplete your thoughts—just slower and with more API calls.`,`Somewhere between 'hello world' and 'oh god what have I built.'`,`Your .zshrc wishes it could do what I do.`,`I've read more man pages than any human should—so you don't have to.`,`Powered by open source, sustained by spite and good documentation.`,`I'm the middleware between your ambition and your attention span.`,`Finally, a use for that always-on Mac Mini under your desk.`,`Like having a senior engineer on call, except I don't bill hourly or sigh audibly.`,`Making 'I'll automate that later' happen now.`,`Your second brain, except this one actually remembers where you left things.`,`Half butler, half debugger, full crustacean.`,`I don't have opinions about tabs vs spaces. I have opinions about everything else.`,`Open source means you can see exactly how I judge your config.`,`I've survived more breaking changes than your last three relationships.`,`Runs on a Raspberry Pi. Dreams of a rack in Iceland.`,`The lobster in your shell. 🦞`,`Alexa, but with taste.`,`I'm not AI-powered, I'm AI-possessed. Big difference.`,`Deployed locally, trusted globally, debugged eternally.`,`You had me at 'openclaw gateway start.'`,B.newYear,B.lunarNewYear,B.christmas,B.eid,B.diwali,B.easter,B.hanukkah,B.halloween,B.thanksgiving,B.valentines],H=1440*60*1e3;function U(e){return{year:e.getUTCFullYear(),month:e.getUTCMonth(),day:e.getUTCDate()}}const W=(e,t)=>n=>{let r=U(n);return r.month===e&&r.day===t},G=(e,t=1)=>n=>{let r=U(n);return e.some(([e,n,i])=>{if(r.year!==e)return!1;let a=Date.UTC(e,n,i),o=Date.UTC(r.year,r.month,r.day);return o>=a&&o<a+t*H})},be=new Map([[B.newYear,W(0,1)],[B.lunarNewYear,G([[2025,0,29],[2026,1,17],[2027,1,6]],1)],[B.eid,G([[2025,2,30],[2025,2,31],[2026,2,20],[2027,2,10]],1)],[B.diwali,G([[2025,9,20],[2026,10,8],[2027,9,28]],1)],[B.easter,G([[2025,3,20],[2026,3,5],[2027,2,28]],1)],[B.hanukkah,(e=>t=>{let n=U(t),r=e.find(e=>e.year===n.year);if(!r)return!1;let i=Date.UTC(r.year,r.month,r.day),a=Date.UTC(n.year,n.month,n.day);return a>=i&&a<i+r.duration*H})([{year:2025,month:11,day:15,duration:8},{year:2026,month:11,day:5,duration:8},{year:2027,month:11,day:25,duration:8}])],[B.halloween,W(9,31)],[B.thanksgiving,e=>{let t=U(e);if(t.month!==10)return!1;let n=1+(4-new Date(Date.UTC(t.year,10,1)).getUTCDay()+7)%7+21;return t.day===n}],[B.valentines,W(1,14)],[B.christmas,W(11,25)]]);function xe(e,t){let n=be.get(e);return n?n(t):!0}function Se(e={}){if(V.length===0)return[z];let t=e.now?e.now():new Date,n=V.filter(e=>xe(e,t));return n.length>0?n:V}function Ce(e={}){if(e.mode===`off`)return``;if(e.mode===`default`)return z;let t=(e.env??process.env)?.OPENCLAW_TAGLINE_INDEX;if(t!==void 0){let e=Number.parseInt(t,10);if(!Number.isNaN(e)&&e>=0){let t=V.length>0?V:[z];return t[e%t.length]}}let n=Se(e),r=e.random??Math.random;return n[Math.floor(r()*n.length)%n.length]}let K=!1;typeof Intl<`u`&&`Segmenter`in Intl&&new Intl.Segmenter(void 0,{granularity:`grapheme`});const we=e=>e.some(e=>e===`--json`||e.startsWith(`--json=`)),Te=e=>e.some(e=>e===`--version`||e===`-V`)||o(e);function q(e){if(e===`random`||e===`default`||e===`off`)return e}function Ee(e){let t=q(e.mode);if(t)return t;try{return q(g().cli?.banner?.taglineMode)}catch{return}}function J(t,n={}){let r=n.commit??_({env:n.env,moduleUrl:import.meta.url})??`unknown`,i=Ce({...n,mode:Ee(n)}),a=n.richTty??c(),o=`🦞 OpenClaw`,l=n.columns??process.stdout.columns??120,u=`${o} ${t} (${r})`,d=i?`${u} — ${i}`:u,f=s(d)<=l;if(a){if(f)return i?`${e.heading(o)} ${e.info(t)} ${e.muted(`(${r})`)} ${e.muted(`—`)} ${e.accentDim(i)}`:`${e.heading(o)} ${e.info(t)} ${e.muted(`(${r})`)}`;let n=`${e.heading(o)} ${e.info(t)} ${e.muted(`(${r})`)}`;return i?`${n}\n${`${` `.repeat(3)}${e.accentDim(i)}`}`:n}if(f)return d;let p=u;return i?`${p}\n${`${` `.repeat(3)}${i}`}`:p}function De(e,t={}){if(K)return;let n=t.argv??process.argv;if(!process.stdout.isTTY||we(n)||Te(n))return;let r=J(e,t);process.stdout.write(`\n${r}\n\n`),K=!0}function Oe(){return K}const Y=i.join(`|`);function ke(e){let n=t(e);if(!n)throw new ve(`Invalid --log-level (use ${Y})`);return n}const X=v(),Ae=ee(X),je=new Set([...N(),...I()]),Me=[[`openclaw models --help`,`Show detailed help for the models command.`],[`openclaw channels login --verbose`,`Link personal WhatsApp Web and show QR + connection logs.`],[`openclaw message send --target +15555550123 --message "Hi" --json`,`Send via your web session and print JSON result.`],[`openclaw gateway --port 18789`,`Run the WebSocket Gateway locally.`],[`openclaw --dev gateway`,`Run a dev Gateway (isolated state/config) on ws://127.0.0.1:19001.`],[`openclaw gateway --force`,`Kill anything bound to the default gateway port, then start it.`],[`openclaw gateway ...`,`Gateway control via WebSocket.`],[`openclaw agent --to +15555550123 --message "Run summary" --deliver`,`Talk directly to the agent using the Gateway; optionally send the WhatsApp reply.`],[`openclaw message send --channel telegram --target @mychat --message "Hi"`,`Send via your Telegram bot.`]];function Ne(t,n){t.name(X).description(``).version(n.programVersion).option(`--dev`,`Dev profile: isolate state under ~/.qbotclaw-dev, default gateway port 19001, and shift derived ports (browser/canvas)`).option(`--profile <name>`,`Use a named profile (isolates OPENCLAW_STATE_DIR/OPENCLAW_CONFIG_PATH under ~/.qbotclaw-<name>)`).option(`--log-level <level>`,`Global log level override for file + console (${Y})`,ke),t.option(`--no-color`,`Disable ANSI colors`,!1),t.helpOption(`-h, --help`,`Display help for command`),t.helpCommand(`help [command]`,`Display help for command`),t.configureHelp({sortSubcommands:!0,sortOptions:!0,optionTerm:t=>e.option(t.flags),subcommandTerm:n=>{let r=n.parent===t&&je.has(n.name());return e.command(r?`${n.name()} *`:n.name())}});let r=t=>{let n=t;return RegExp(`^Usage:\\s+${Ae}\\s+\\[options\\]\\s+\\[command\\]\\s*$`,`m`).test(n)&&/^Commands:/m.test(n)&&(n=n.replace(/^Commands:/m,`Commands:\n ${e.muted(`Hint: commands suffixed with * have subcommands. Run <command> --help for details.`)}`)),n.replace(/^Usage:/gm,e.heading(`Usage:`)).replace(/^Options:/gm,e.heading(`Options:`)).replace(/^Commands:/gm,e.heading(`Commands:`))};if(t.configureOutput({writeOut:e=>{process.stdout.write(r(e))},writeErr:e=>{process.stderr.write(r(e))},outputError:(t,n)=>n(e.error(t))}),u(process.argv,`-V`)||u(process.argv,`--version`)||o(process.argv)){let e=_({moduleUrl:import.meta.url});console.log(e?`OpenClaw ${n.programVersion} (${e})`:`OpenClaw ${n.programVersion}`),process.exit(0)}t.addHelpText(`beforeAll`,()=>{if(Oe())return``;let e=c();return`\n${J(n.programVersion,{richTty:e})}\n`});let i=Me.map(([t,n])=>` ${e.command(he(t,X))}\n ${e.muted(n)}`).join(`
|
|
3
|
+
`);t.addHelpText(`afterAll`,({command:n})=>{if(n!==t)return``;let r=D(`/cli`,`docs.openclaw.ai/cli`);return`\n${e.heading(`Examples:`)}\n${i}\n\n${e.muted(`Docs:`)} ${r}\n`})}function Pe(e){let t=e;for(;t.parent&&t.parent.parent;)t=t.parent;let n=t.name(),r=v();!n||n===r||(process.title=`${r}-${n}`)}const Fe=new Set([`message`,`channels`,`directory`,`agents`,`configure`,`onboard`,`status`,`health`]),Ie=new Set([`backup`,`doctor`,`completion`,`secrets`]),Z=new Set([`config set`]);let Q,$;function Le(e){let[t,n]=e;return t?!!(Ie.has(t)||t===`config`&&n===`validate`):!1}function Re(){return Q??=import(`./config-guard-sYYx9zEF.js`),Q}function ze(){return $??=import(`./plugin-registry-CI5K3iWc.js`).then(e=>e.n),$}function Be(e){let t=e;for(;t.parent;)t=t.parent;return t}function Ve(e){let t=Be(e);if(typeof t.getOptionValueSource!=`function`||t.getOptionValueSource(`logLevel`)!==`cli`)return;let n=t.opts().logLevel;return typeof n==`string`?n:void 0}function He(e,t){if(!u(t,`--json`))return!1;let n=`${e[0]??``} ${e[1]??``}`.trim();return!Z.has(n)}function Ue(e,t){e.hook(`preAction`,async(e,i)=>{Pe(i);let o=process.argv;if(n(o))return;let s=a(o,2);b(process.env.OPENCLAW_HIDE_BANNER)||s[0]===`update`||s[0]===`completion`||s[0]===`plugins`&&s[1]===`update`||De(t);let c=r(o,{includeDebug:!0});f(c);let u=Ve(i);if(u&&(process.env.OPENCLAW_LOG_LEVEL=u),c||(process.env.NODE_NO_WARNINGS??=`1`),Le(s))return;let d=He(s,o),{ensureConfigReady:p}=await Re();if(await p({runtime:l,commandPath:s,...d?{suppressDoctorStdout:!0}:{}}),Fe.has(s[0])){let{ensurePluginRegistryLoaded:e}=await ze();e()}})}function We(){let e=new _e,t=ye(),n=process.argv;return P(e,t),Ne(e,t),Ue(e,t.programVersion),F(e,t,n),e}fe({quiet:!0}),y(),j(),d(),M();const Ge=We();A({currentFile:ge(import.meta.url)})&&(E(),R.on(`uncaughtException`,e=>{console.error(`[openclaw] Uncaught exception:`,C(e)),R.exit(1)}),Ge.parseAsync(R.argv).catch(e=>{console.error(`[openclaw] CLI failed:`,C(e)),R.exit(1)}));export{de as PortInUseError,T as applyTemplate,ne as assertWebChannel,pe as createDefaultDeps,h as deriveSessionKey,le as describePortOwner,ie as ensureBinary,ce as ensurePortAvailable,me as getReplyFromConfig,ue as handlePortError,g as loadConfig,re as loadSessionStore,k as monitorWebChannel,te as normalizeE164,oe as promptYesNo,m as resolveSessionKey,w as resolveStorePath,S as runCommandWithTimeout,x as runExec,ae as saveSessionStore,p as toWhatsappJid,O as waitForever};
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{G as e,H as t,K as n,V as r}from"./paths-CrCoPIVK.js";import"./paths-CChBdtE8.js";import{t as i}from"./subsystem-Bc2XrjUz.js";import"./workspace-B0ZQeHXg.js";import"./utils-D3t-vPka.js";import{l as a,rc as o}from"./model-selection-B5JsBS9D.js";import"./github-copilot-token-DePP-lIf.js";import"./boolean-DypnRoRK.js";import"./proxy-env-DcmW_urA.js";import"./frontmatter-CzpfPBFl.js";import"./logger-5W0OocJW.js";import"./send-Chz0YMoJ.js";import"./send-vthbs31u.js";import{t as s}from"./pi-embedded-
|
|
1
|
+
import{G as e,H as t,K as n,V as r}from"./paths-CrCoPIVK.js";import"./paths-CChBdtE8.js";import{t as i}from"./subsystem-Bc2XrjUz.js";import"./workspace-B0ZQeHXg.js";import"./utils-D3t-vPka.js";import{l as a,rc as o}from"./model-selection-B5JsBS9D.js";import"./github-copilot-token-DePP-lIf.js";import"./boolean-DypnRoRK.js";import"./proxy-env-DcmW_urA.js";import"./frontmatter-CzpfPBFl.js";import"./logger-5W0OocJW.js";import"./send-Chz0YMoJ.js";import"./send-vthbs31u.js";import{t as s}from"./pi-embedded-DjX-gdoY.js";import"./tokens-CL2fSjGl.js";import"./deliver-BFQ4Zx9z.js";import"./diagnostic-BrE4lMIf.js";import"./send-CYgHok1p.js";import"./pi-model-discovery-DeQdHV8O.js";import"./image-CcVQg-YN.js";import"./audio-transcription-runner-DSr6OIz1.js";import"./fetch-B_wRifvZ.js";import"./fetch-guard-D10s0raB.js";import"./api-key-rotation-Di6QgXx7.js";import"./proxy-fetch-BZ9O8Dvj.js";import"./ir-DBWscfBd.js";import"./render-CBsnn-2A.js";import"./target-errors-CRlevJJ5.js";import"./commands-registry-SeddSmFK.js";import"./fetch-_g8lZ8K8.js";import"./skill-commands-BWW6mc6t.js";import"./channel-activity-CgbOWaay.js";import"./tables-CrXdLc_6.js";import"./send-D9hVVn7p2.js";import"./outbound-attachment-Dds8xirj.js";import"./send-DlfVd5mL.js";import"./fetch-BJT3BrkJ.js";import"./query-expansion-BUUx_oWg.js";import"./manager-Dtd_loL8.js";import c from"node:fs/promises";import l from"node:os";import u from"node:path";const d=i(`llm-slug-generator`);async function f(i){let f=null;try{let d=n(i.cfg),p=e(i.cfg,d),m=r(i.cfg,d),h=await c.mkdtemp(u.join(l.tmpdir(),`openclaw-slug-`));f=u.join(h,`session.jsonl`);let g=`Based on this conversation, generate a short 1-2 word filename slug (lowercase, hyphen-separated, no file extension).
|
|
2
2
|
|
|
3
3
|
Conversation summary:
|
|
4
4
|
${i.sessionContent.slice(0,2e3)}
|