squidclaw 3.0.2 → 3.0.3
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/{accounts-LA308FHj.js → accounts-CK_sHUyT.js} +2 -2
- package/dist/{accounts-CL_NXliB.js → accounts-CkF7YwoF.js} +17 -17
- package/dist/{accounts-F7tGwezI.js → accounts-DbloMfwT.js} +2 -2
- package/dist/{active-listener-DJv1FZqf.js → active-listener-AepfNSUY.js} +2 -2
- package/dist/{agents-DdixSPs3.js → agents-JnnOlm2G.js} +5 -5
- package/dist/{agents.config-Cn_vTN1v.js → agents.config-BeGeS2jv.js} +1 -1
- package/dist/{agents.config-C6KTwnde.js → agents.config-DHJBQ7uA.js} +1 -1
- package/dist/{plugin-sdk/api-key-rotation-DE4gr5YM.js → api-key-rotation-BHFJiYbw.js} +2 -2
- package/dist/{audio-preflight-AEM744TY.js → audio-preflight-BTYxAJjy.js} +32 -32
- package/dist/{audio-preflight-DpCWFB4z.js → audio-preflight-Dkl6Z32z.js} +4 -4
- package/dist/{audio-transcription-runner-CItniQDZ.js → audio-transcription-runner-DBkDgluo.js} +12 -12
- package/dist/{audio-transcription-runner-B2BdTEps.js → audio-transcription-runner-Gi_h5HEE.js} +1 -1
- package/dist/{audit-membership-runtime-w23FnNAN.js → audit-membership-runtime-DyLj-uhz.js} +4 -4
- package/dist/{auth-choice-7WVhiM9J.js → auth-choice-DQbCl-4F.js} +2 -2
- package/dist/{auth-choice-17U1cGPH.js → auth-choice-xwYK6txn.js} +2 -2
- package/dist/{banner-CJTrU-HC.js → banner-BxibaqUz.js} +1 -1
- package/dist/build-info.json +3 -3
- package/dist/bundled/boot-md/handler.js +51 -51
- package/dist/bundled/bootstrap-extra-files/handler.js +6 -6
- package/dist/bundled/command-logger/handler.js +2 -2
- package/dist/bundled/session-memory/handler.js +51 -51
- package/dist/canvas-host/a2ui/.bundle.hash +1 -1
- package/dist/{channel-activity-DPrXawu4.js → channel-activity-C5kTj83_.js} +3 -3
- package/dist/{channel-options-x47KAgAV.js → channel-options-BKsCYdHu.js} +1 -1
- package/dist/{channel-options-BM7IEY5X.js → channel-options-FdCN4cFo.js} +1 -1
- package/dist/{channel-web-B48pVgke.js → channel-web-BFUPrpIe.js} +1 -1
- package/dist/{channel-web-HM1q5FP_.js → channel-web-BkYtM8H5.js} +1 -1
- package/dist/{channels-cli-iPiD6449.js → channels-cli-BxhfVD-R.js} +7 -7
- package/dist/{channels-cli-y66ZCzYf.js → channels-cli-CZzGaGvG.js} +7 -7
- package/dist/{chrome-BQDCalPp.js → chrome-CAd6FQEn.js} +8 -8
- package/dist/{chrome-BFfAGQtd.js → chrome-pBkBuWci.js} +26 -26
- package/dist/cli/daemon-cli.js +1 -1
- package/dist/{cli-C-neGkM4.js → cli-GSev2Q95.js} +2 -2
- package/dist/{cli-BzpBs_KI.js → cli-bXiYaLre.js} +2 -2
- package/dist/{command-registry-BL80-JCV.js → command-registry-CvgCFxfY.js} +9 -9
- package/dist/{commands-registry-C2t2bcZ6.js → commands-registry-D6ZOTo1C.js} +4 -4
- package/dist/{completion-cli-CJ_L_gYr.js → completion-cli-BGM1V6EN.js} +2 -2
- package/dist/{completion-cli-Bi2s1mq8.js → completion-cli-OrgUDc2S.js} +1 -1
- package/dist/{config-cli-FhKX7MOY.js → config-cli-DbBvjvpS.js} +1 -1
- package/dist/{config-cli-BVpzzhoY.js → config-cli-uIP4r17f.js} +1 -1
- package/dist/{configure-ChiLGQo6.js → configure-BGvoAfbs.js} +6 -6
- package/dist/{configure-t9fm4x9H.js → configure-BOsTXjBw.js} +6 -6
- package/dist/{daemon-cli-DK8fQgAw.js → daemon-cli-CNi-QjEX.js} +1 -1
- package/dist/{daemon-cli-CO09shIt.js → daemon-cli-DN2TnjHQ.js} +1 -1
- package/dist/{deliver-aL8yOYS1.js → deliver-BJuiq0GS.js} +1 -1
- package/dist/{deliver-neVJ7AU9.js → deliver-DBXe-ZmL.js} +21 -21
- package/dist/{deliver-runtime-ChVR6sR3.js → deliver-runtime-DHKcNQzq.js} +3 -3
- package/dist/deliver-runtime-GlnBJNCj.js +36 -0
- package/dist/deps-send-discord.runtime-BRE0s2nz.js +26 -0
- package/dist/deps-send-imessage.runtime-DbIRBnmD.js +25 -0
- package/dist/deps-send-signal.runtime-B4h6X3o4.js +24 -0
- package/dist/deps-send-slack.runtime-BWXOnOxS.js +22 -0
- package/dist/deps-send-telegram.runtime-YvauJtgv.js +27 -0
- package/dist/{deps-send-whatsapp.runtime-WND2o1Mr.js → deps-send-whatsapp.runtime-BcxCalPD.js} +4 -4
- package/dist/deps-send-whatsapp.runtime-CslTuV47.js +60 -0
- package/dist/{deps-send-whatsapp.runtime-CZj97m5A.js → deps-send-whatsapp.runtime-DdxKewuy.js} +7 -7
- package/dist/{deps-send-whatsapp.runtime-DSbrPzxG.js → deps-send-whatsapp.runtime-Dl4ro-Df.js} +4 -4
- package/dist/{diagnostic-DoguEiWW.js → diagnostic-ySwZga6c.js} +2 -2
- package/dist/{doctor-completion-CKaQEebJ.js → doctor-completion-42wcUATu.js} +1 -1
- package/dist/{doctor-completion-Ctqsu6Y2.js → doctor-completion-D6RGDBD5.js} +1 -1
- package/dist/entry.js +2 -2
- package/dist/{plugin-sdk/errors-9oVz7reJ.js → errors-kkRuS2Cs.js} +1 -1
- package/dist/extensionAPI.js +6 -6
- package/dist/{fetch-DdiB5_OX.js → fetch-BLS7EMnx.js} +5 -5
- package/dist/{fetch-guard-CEV5qBHc.js → fetch-guard-D0fXNJls.js} +2 -2
- package/dist/{frontmatter-CjKtFduT.js → frontmatter-Cq1TcIQ2.js} +3 -3
- package/dist/{fs-safe-CwHbZdFH.js → fs-safe-BoB4X3GD.js} +4 -4
- package/dist/{gateway-cli-CSIyrhFg.js → gateway-cli-BbPfLLT6.js} +10 -10
- package/dist/{gateway-cli-xX1CTw9n.js → gateway-cli-CG3mshpO.js} +10 -10
- package/dist/{github-copilot-token-Cw3tAXM9.js → github-copilot-token-B5cPlwaz.js} +7 -7
- package/dist/{health-D9Pie2kF.js → health-CJgEuWuG.js} +1 -1
- package/dist/{health-D7mPTab_.js → health-dZqyhpdR.js} +1 -1
- package/dist/{hooks-cli-C6aI9HU7.js → hooks-cli-BD4Ww1dF.js} +3 -3
- package/dist/{hooks-cli-_1zdKcZA.js → hooks-cli-C0wWJOBW.js} +3 -3
- package/dist/{image-ecaECpjT.js → image-j_UomzVG.js} +6 -6
- package/dist/{image-ops-bdrMTILs.js → image-ops-CdgypS_g.js} +2 -2
- package/dist/image-runtime-BNh3IfMj.js +29 -0
- package/dist/{image-runtime-poRypm-b.js → image-runtime-SUtf9jqh.js} +3 -3
- package/dist/{image-DKZCmkET.js → image-sRW3RpTY.js} +1 -1
- package/dist/index.js +7 -7
- package/dist/{ir-D_GD01cg.js → ir-BvisJWXv.js} +8 -8
- package/dist/{legacy-names-B0wgIP0Q.js → legacy-names-aGJJuzM_.js} +1 -1
- package/dist/llm-slug-generator.js +51 -51
- package/dist/{logger-oGKcCLZ5.js → logger-CnTSBL7T.js} +7 -7
- package/dist/{login-gJWPqN66.js → login-BMeLPUiO.js} +5 -5
- package/dist/{login-qr-CgmlF7zK.js → login-qr-B2B67qqQ.js} +10 -10
- package/dist/{manager-CD69uguS.js → manager-DdxMYEDd.js} +13 -13
- package/dist/manager-runtime-BMygJEz3.js +18 -0
- package/dist/{model-selection-DMjtmGZP.js → model-selection-ag9BmVct.js} +43 -43
- package/dist/{models-BviRe-_7.js → models-BXT0s4KJ.js} +3 -3
- package/dist/{models-cli-BM5yo_mo.js → models-cli-BtLc9uPC.js} +3 -3
- package/dist/{models-cli-pvYVl1i-.js → models-cli-BwPFxWK2.js} +4 -4
- package/dist/{npm-resolution-DMM9Hopy.js → npm-resolution-DWpNPsBF.js} +1 -1
- package/dist/{npm-resolution-BTFMooVS.js → npm-resolution-Djbuzx6o.js} +1 -1
- package/dist/{onboard-DVuhj8ub.js → onboard-1KfKwvMR.js} +3 -3
- package/dist/{onboard-DTsgFKIa.js → onboard-ChxvwUze.js} +3 -3
- package/dist/{onboard-channels-W9UHiBQg.js → onboard-channels-CHrtFmhi.js} +2 -2
- package/dist/{onboard-channels-B1D9LqV_.js → onboard-channels-CXjnFvP1.js} +2 -2
- package/dist/{onboard-helpers-DVaF21TE.js → onboard-helpers-Bvpkyuwm.js} +6 -6
- package/dist/{onboard-helpers-PRhg7ZY5.js → onboard-helpers-ByttGRIZ.js} +6 -6
- package/dist/{onboard-remote-h-aHSDJ1.js → onboard-remote-Cfx2v9OI.js} +1 -1
- package/dist/{onboard-remote-DkIrV4Hx.js → onboard-remote-DxBaaS6o.js} +1 -1
- package/dist/{onboard-skills-fFSuiv21.js → onboard-skills-B7pHg1lN.js} +1 -1
- package/dist/{onboard-skills-fgrVmjJP.js → onboard-skills-PCnCZ6Od.js} +1 -1
- package/dist/{onboarding-D1nCnc_t.js → onboarding-D6kMb3yv.js} +7 -7
- package/dist/{onboarding-CYWs766P.js → onboarding-DuUMPrqA.js} +7 -7
- package/dist/{onboarding.finalize-Bcan6_vA.js → onboarding.finalize-KTOhO1-l.js} +7 -7
- package/dist/{onboarding.finalize-bAiXf9D6.js → onboarding.finalize-bphDUwZy.js} +6 -6
- package/dist/{onboarding.gateway-config-61E9xXYF.js → onboarding.gateway-config-DDdX0W74.js} +1 -1
- package/dist/{onboarding.gateway-config-Dyaqc_M7.js → onboarding.gateway-config-DNUJ0seU.js} +1 -1
- package/dist/{outbound-Cboz5UyH.js → outbound-DHDBvGLA.js} +6 -6
- package/dist/{outbound-attachment-PwEbEhAL.js → outbound-attachment-CqXiWbKN.js} +2 -2
- package/dist/{path-alias-guards-Cpsiv2KL.js → path-alias-guards-DORgbZ1w.js} +1 -1
- package/dist/{paths-CSdAWKDO.js → paths-DA5srn0U.js} +5 -5
- package/dist/{paths-CXClY8zC.js → paths-DSd911Oe.js} +4 -4
- package/dist/{pi-embedded-MktS4l8v.js → pi-embedded-BGz_qdCc.js} +24 -24
- package/dist/{pi-embedded-CkTlmTq8.js → pi-embedded-BP2UlUm_.js} +171 -171
- package/dist/{pi-embedded-helpers-DYWYzEOC.js → pi-embedded-helpers-BruaFB5l.js} +3 -3
- package/dist/{pi-embedded-helpers-Bfm_CvEb.js → pi-embedded-helpers-CmLnmKlb.js} +52 -52
- package/dist/{pi-model-discovery-DEps5Exd.js → pi-model-discovery-DAzuqPoG.js} +7 -7
- package/dist/pi-model-discovery-runtime-Dpu7Jm2L.js +11 -0
- package/dist/{pi-tools.before-tool-call.runtime-4wPdP7Br.js → pi-tools.before-tool-call.runtime-2Sp1jmlg.js} +9 -9
- package/dist/{plugin-registry-CvMvSI8O.js → plugin-registry-CLEhrKYA.js} +1 -1
- package/dist/{plugin-registry-DL2ClHLQ.js → plugin-registry-DtuxmgWx.js} +1 -1
- package/dist/plugin-sdk/{accounts-kr-Gz1hk.js → accounts-DghIDNk2.js} +2 -2
- package/dist/plugin-sdk/{accounts-CxUSDHsT.js → accounts-YTdQYQFr.js} +3 -3
- package/dist/plugin-sdk/{accounts-PSzw-z3S.js → accounts-h__dTrLK.js} +2 -2
- package/dist/plugin-sdk/{active-listener-BQNrTcR3.js → active-listener-_PRYjtJv.js} +2 -2
- package/dist/plugin-sdk/{api-key-rotation-Bhck7wki.js → api-key-rotation-mVDSAkKQ.js} +2 -2
- package/dist/plugin-sdk/{audio-preflight-_xgGaeho.js → audio-preflight-BZlQM-qX.js} +26 -26
- package/dist/plugin-sdk/{audio-transcription-runner-Dwc0Eh-B.js → audio-transcription-runner-CrYTX8py.js} +11 -11
- package/dist/plugin-sdk/{audit-membership-runtime-DHQDvH4u.js → audit-membership-runtime-Xl20kCBe.js} +2 -2
- package/dist/plugin-sdk/{channel-activity-XajEg_DL.js → channel-activity-gwxRn4wF.js} +3 -3
- package/dist/plugin-sdk/{channel-web-KtqCp4mz.js → channel-web-1WF-Nabe.js} +18 -18
- package/dist/plugin-sdk/{chrome-diV5m81I.js → chrome-BXbYwXRH.js} +6 -6
- package/dist/plugin-sdk/{commands-registry-DwZAJuut.js → commands-registry-0w-aZenK.js} +4 -4
- package/dist/plugin-sdk/{common-CqnO92P8.js → common-DBOCt6Yv.js} +2 -2
- package/dist/plugin-sdk/{config-DYbtdrsT.js → config-pRtEoVyZ.js} +7 -7
- package/dist/plugin-sdk/{deliver-DG_7Uagn.js → deliver-FjlJrtZk.js} +10 -10
- package/dist/plugin-sdk/deliver-runtime-DEzvpBW1.js +32 -0
- package/dist/plugin-sdk/deps-send-discord.runtime-Bhusa_Hi.js +23 -0
- package/dist/plugin-sdk/deps-send-imessage.runtime-bmakPm5f.js +22 -0
- package/dist/plugin-sdk/deps-send-signal.runtime-n00sfFto.js +21 -0
- package/dist/plugin-sdk/deps-send-slack.runtime-BvM3Z-Mr.js +19 -0
- package/dist/plugin-sdk/deps-send-telegram.runtime-CPuMkcmo.js +24 -0
- package/dist/plugin-sdk/deps-send-whatsapp.runtime-BzO6S-KX.js +57 -0
- package/dist/plugin-sdk/{diagnostic-CT7v_kM2.js → diagnostic-Dt2i3afe.js} +2 -2
- package/dist/plugin-sdk/{errors-B8oJXuCF.js → errors-CgRPdp3o.js} +1 -1
- package/dist/plugin-sdk/{fetch-guard-Or5BCq0E.js → fetch-guard-DyPZh8r2.js} +2 -2
- package/dist/plugin-sdk/{fs-safe-DFbwq9CS.js → fs-safe-DqCO1D4C.js} +3 -3
- package/dist/plugin-sdk/{image-rycGCqJO.js → image-CQ9TZ9vq.js} +6 -6
- package/dist/plugin-sdk/{image-ops-CMsocOob.js → image-ops-sw0uZ0GN.js} +2 -2
- package/dist/plugin-sdk/image-runtime-17_mTqsy.js +25 -0
- package/dist/plugin-sdk/index.js +50 -50
- package/dist/plugin-sdk/{ir-DihI2SIz.js → ir-BVZ5kUMb.js} +7 -7
- package/dist/plugin-sdk/{local-roots-1xVosTZ4.js → local-roots-fO3ZgW3G.js} +4 -4
- package/dist/plugin-sdk/{logger-Bg4vIUJn.js → logger-DIb2cGHp.js} +2 -2
- package/dist/plugin-sdk/{login-YhFrVUWo.js → login-Dg5cxB_3.js} +4 -4
- package/dist/plugin-sdk/{login-qr-SpUTuwYv.js → login-qr-C3Vn30cq.js} +5 -5
- package/dist/plugin-sdk/{manager-DrzOPeMD.js → manager-BR-TwWTH.js} +8 -8
- package/dist/plugin-sdk/manager-runtime-CvI9wF8N.js +15 -0
- package/dist/plugin-sdk/{outbound-Cc4cUn9K.js → outbound-1a3Z_QJ2.js} +5 -5
- package/dist/plugin-sdk/{outbound-attachment-Dtp3hQgc.js → outbound-attachment-BTQjD4YE.js} +2 -2
- package/dist/plugin-sdk/{path-alias-guards-DA0MhfkG.js → path-alias-guards-TnxupPQC.js} +1 -1
- package/dist/plugin-sdk/{paths-CP67O8eN.js → paths-B7_75Pdr.js} +1 -1
- package/dist/plugin-sdk/{pi-embedded-helpers-BDJ_4Plh.js → pi-embedded-helpers-DZRNadD8.js} +16 -16
- package/dist/plugin-sdk/{pi-model-discovery-Mk0GTDJl.js → pi-model-discovery-DGh6xekX.js} +1 -1
- package/dist/plugin-sdk/pi-model-discovery-runtime-DjjBdPYt.js +8 -0
- package/dist/plugin-sdk/{pi-tools.before-tool-call.runtime-DV72wTDb.js → pi-tools.before-tool-call.runtime-BZ9XgG_x.js} +4 -4
- package/dist/plugin-sdk/{plugins-DSs2-fnK.js → plugins-B8pWVYug.js} +4 -4
- package/dist/plugin-sdk/{proxy-env-Ib4-LUh-.js → proxy-env-BOlkiW1-.js} +1 -1
- package/dist/plugin-sdk/{proxy-fetch-ZPEvp58f.js → proxy-fetch-Dt5BedH8.js} +1 -1
- package/dist/plugin-sdk/{pw-ai-DIx2wpkY.js → pw-ai-C17A1o4w.js} +9 -9
- package/dist/plugin-sdk/{qmd-manager-Ov9ElEfG.js → qmd-manager-Bei6TaFq.js} +7 -7
- package/dist/plugin-sdk/{query-expansion-CzjwW461.js → query-expansion-POz2za8a.js} +4 -4
- package/dist/plugin-sdk/{redact-BoNEjbpF.js → redact-9WsNyb7S.js} +1 -1
- package/dist/plugin-sdk/{reply-CWWUd_JS.js → reply-BFbijn6_.js} +73 -73
- package/dist/plugin-sdk/{resolve-outbound-target-BOkvxZtM.js → resolve-outbound-target-B9iFEh0y.js} +2 -2
- package/dist/plugin-sdk/{run-with-concurrency-kVooFCVo.js → run-with-concurrency-DmTrN5JG.js} +1 -1
- package/dist/plugin-sdk/runtime-whatsapp-login.runtime-DzhkSmLi.js +10 -0
- package/dist/plugin-sdk/runtime-whatsapp-outbound.runtime-DyILWezU.js +19 -0
- package/dist/plugin-sdk/{send-BP1fSEBR.js → send-BGZo6HW1.js} +5 -5
- package/dist/plugin-sdk/{send-D9CSOGul.js → send-BisREGBZ.js} +6 -6
- package/dist/plugin-sdk/{send-BeLBlAsQ.js → send-BqkUDZed.js} +13 -13
- package/dist/plugin-sdk/{send-DLKxJJYV.js → send-D6_nNvi0.js} +8 -8
- package/dist/plugin-sdk/{send-XZ6IXCtL.js → send-Dj7XEcZN.js} +7 -7
- package/dist/plugin-sdk/{session-DtLUYWvY.js → session-D4KDs7Hq.js} +3 -3
- package/dist/plugin-sdk/{skill-commands-Bv7EZypt.js → skill-commands-D_xeseiI.js} +4 -4
- package/dist/plugin-sdk/{skills-BzXN4uev.js → skills-Bs2b3JfV.js} +6 -6
- package/dist/plugin-sdk/slash-commands.runtime-CUb5sqqf.js +13 -0
- package/dist/plugin-sdk/slash-dispatch.runtime-DCB6bGjB.js +52 -0
- package/dist/plugin-sdk/slash-skill-commands.runtime-BqEweE4K.js +16 -0
- package/dist/plugin-sdk/{store-DnJhFFW5.js → store-B7ESm9_L.js} +2 -2
- package/dist/plugin-sdk/subagent-registry-runtime-CCUW4SbM.js +52 -0
- package/dist/plugin-sdk/{tables-CpmqssLF.js → tables-1vhBJPK_.js} +1 -1
- package/dist/plugin-sdk/{thinking-1UCPuD9d.js → thinking-DjaClmzi.js} +7 -7
- package/dist/plugin-sdk/{tokens-DAL_5WHL.js → tokens-CLE20fRI.js} +1 -1
- package/dist/plugin-sdk/{tool-images-RX4QTMnt.js → tool-images-B95xcwiR.js} +2 -2
- package/dist/plugin-sdk/web-DeRmHQ4_.js +56 -0
- package/dist/plugin-sdk/{whatsapp-actions-BF6ih4Gi.js → whatsapp-actions-BYpcWkTN.js} +17 -17
- package/dist/plugin-sdk/whatsapp.js +50 -50
- package/dist/{plugins-CmdmAU0K.js → plugins-DXkm70nK.js} +11 -11
- package/dist/{plugins-cli-DBtLtIsQ.js → plugins-cli-Cs3UUJew.js} +3 -3
- package/dist/{plugins-cli-BMPvpwSo.js → plugins-cli-KPz6APX0.js} +3 -3
- package/dist/{program-context-KSeqVkRM.js → program-context-J_FyEsaS.js} +18 -18
- package/dist/{program-C6sTShRB.js → program-xNEHPhT8.js} +8 -8
- package/dist/{prompt-select-styled-Ba5fC0g1.js → prompt-select-styled-B1LjjgQ0.js} +5 -5
- package/dist/{prompt-select-styled-DFhJPiqx.js → prompt-select-styled-BRiogP_P.js} +5 -5
- package/dist/{provider-auth-helpers-S2rdI85T.js → provider-auth-helpers-CxUWqt95.js} +1 -1
- package/dist/{provider-auth-helpers-BPvZ8xkJ.js → provider-auth-helpers-hhFVhZdv.js} +1 -1
- package/dist/{proxy-env-QUJz9VEJ.js → proxy-env-D75CWSOo.js} +1 -1
- package/dist/{proxy-fetch-C2v-Utgg.js → proxy-fetch-lH6RsRTE.js} +1 -1
- package/dist/{push-apns-BQEPMPtG.js → push-apns-BBkpZyNR.js} +1 -1
- package/dist/{push-apns-CGibQhps.js → push-apns-BQjV_93G.js} +1 -1
- package/dist/{pw-ai-SYjuzbV6.js → pw-ai-7kHgUGj0.js} +14 -14
- package/dist/{pw-ai-zFPBSxaL.js → pw-ai-BmGrTicP.js} +1 -1
- package/dist/{qmd-manager-CO-shcLU.js → qmd-manager-BN0siR2Z.js} +10 -10
- package/dist/{query-expansion-DlQOkf-g.js → query-expansion-Dzxt6kXo.js} +6 -6
- package/dist/{redact-NmPEVjIo.js → redact-DvzicBMu.js} +1 -1
- package/dist/{register.agent-DP_2xCaO.js → register.agent-DYq06QHS.js} +8 -8
- package/dist/{register.agent-BwhWwpRX.js → register.agent-reU63wQ5.js} +7 -7
- package/dist/{register.configure-D8TE-yQn.js → register.configure-C4p9ad2q.js} +10 -10
- package/dist/{register.configure-C5i661J4.js → register.configure-DezZ4Q1p.js} +10 -10
- package/dist/{register.maintenance-BS2i3S5V.js → register.maintenance-CTvFmkAm.js} +9 -9
- package/dist/{register.maintenance-BA4UOg2_.js → register.maintenance-CzMKTC2a.js} +8 -8
- package/dist/{register.message-oFI2Mzrd.js → register.message-BmsovYS6.js} +3 -3
- package/dist/{register.message-D9hVI5b6.js → register.message-Bp4SDXWk.js} +3 -3
- package/dist/{register.onboard-D6wqijOl.js → register.onboard-C39xhpv1.js} +3 -3
- package/dist/{register.onboard-OaKr3SnU.js → register.onboard-DZt2kSAg.js} +3 -3
- package/dist/{register.setup-DsK_7zih.js → register.setup-04L_8wfA.js} +3 -3
- package/dist/{register.setup-Dygx-glo.js → register.setup-DWctFmOd.js} +3 -3
- package/dist/{register.status-health-sessions-C6VfEhho.js → register.status-health-sessions-CBPZoj51.js} +4 -4
- package/dist/{register.status-health-sessions-BmWcbWPR.js → register.status-health-sessions-N6SFc-UY.js} +4 -4
- package/dist/{register.subclis-CLf32krW.js → register.subclis-C3TphbCF.js} +10 -10
- package/dist/{reply-ZWkzBiSb.js → reply-CB1p166g.js} +5 -5
- package/dist/{run-main-asKkGUqy.js → run-main-7tknx04F.js} +15 -15
- package/dist/{run-with-concurrency-FczpX8ng.js → run-with-concurrency-BFR3ReeF.js} +4 -4
- package/dist/runtime-whatsapp-login.runtime-DSR-m0FW.js +13 -0
- package/dist/runtime-whatsapp-outbound.runtime-Blywd_bv.js +22 -0
- package/dist/{send-oS3t6gE6.js → send-C98RfcAb.js} +5 -5
- package/dist/{send-DX_O1OHH.js → send-Co5Bqwuo.js} +6 -6
- package/dist/{send-BNsV-D2Y.js → send-DjL7KlMV.js} +8 -8
- package/dist/{send-C-jb8X9I.js → send-Do7hKDL9.js} +7 -7
- package/dist/{send-D-Rnbdzz.js → send-bW7jDv8D.js} +26 -26
- package/dist/{server-node-events-DV2yeAp-.js → server-node-events-Ctjzvlem.js} +3 -3
- package/dist/{server-node-events-BHv7a_ll.js → server-node-events-DrCKK0J4.js} +3 -3
- package/dist/{session-DRyURckG.js → session-QSn69XeJ.js} +8 -8
- package/dist/{skill-commands-BrlAf_CG.js → skill-commands-Bi_jchJn.js} +9 -9
- package/dist/{skills-DWrRJwa-.js → skills-CTV78w4q.js} +22 -22
- package/dist/slash-commands.runtime-63MUmCBt.js +16 -0
- package/dist/{slash-dispatch.runtime-DkcAYuyK.js → slash-dispatch.runtime-BL3qA1O3.js} +6 -6
- package/dist/{slash-dispatch.runtime-BJOuQOeN.js → slash-dispatch.runtime-DRGqAgwa.js} +2 -2
- package/dist/slash-dispatch.runtime-Dh2L_3Tg.js +56 -0
- package/dist/{slash-dispatch.runtime-CEAbkOCI.js → slash-dispatch.runtime-uqWhoI6q.js} +2 -2
- package/dist/slash-skill-commands.runtime-B3MSSAQ-.js +20 -0
- package/dist/{status-Ck8-aQIF.js → status-BkfSGlOi.js} +3 -3
- package/dist/{status-CMhW6nGs.js → status-DdW571-j.js} +3 -3
- package/dist/{store-BFNH5fXG.js → store-B89Hj8Ub.js} +2 -2
- package/dist/{subagent-registry-DQpeidFk.js → subagent-registry-DGrfQVN3.js} +5 -5
- package/dist/subagent-registry-runtime-BRNDawlJ.js +56 -0
- package/dist/{subagent-registry-runtime-C-jjppV6.js → subagent-registry-runtime-DatTO2LD.js} +2 -2
- package/dist/{subagent-registry-runtime-tRRyFZL8.js → subagent-registry-runtime-Dsrz3yIh.js} +2 -2
- package/dist/{subagent-registry-runtime-BlRAnw80.js → subagent-registry-runtime-MtjBCcgn.js} +6 -6
- package/dist/{subsystem-BaLYRf7D.js → subsystem-6v7sWnAD.js} +14 -14
- package/dist/{tables-CnlmCLb3.js → tables-DGHzaXQz.js} +1 -1
- package/dist/{target-errors-Df1wB-I7.js → target-errors-CweAa7L9.js} +2 -2
- package/dist/{thinking-CTpcVnlx.js → thinking-SdNGqtJE.js} +7 -7
- package/dist/{tokens-D2XhLqIz.js → tokens-DfbMVF9y.js} +1 -1
- package/dist/{tool-images-CElPu2en.js → tool-images-8BKrL7Bn.js} +2 -2
- package/dist/{update-cli-5KzuA6pa.js → update-cli-0UiUaT3q.js} +10 -10
- package/dist/{update-cli-CEghYBNP.js → update-cli-C-uyQcFS.js} +9 -9
- package/dist/{update-runner-C5XgCwj2.js → update-runner-CT9YRLtn.js} +1 -1
- package/dist/{update-runner-C0q8aGFd.js → update-runner-CqVLeGYA.js} +1 -1
- package/dist/{web-DBm_uXOl.js → web-B2qXyOb9.js} +3 -3
- package/dist/{web-DdrUn13G.js → web-B7kbCskR.js} +55 -55
- package/dist/{web-DddJa7ZT.js → web-D1ZoRVB0.js} +6 -6
- package/dist/{web-O2WkG3cH.js → web-FqoNMI-k.js} +3 -3
- package/dist/{whatsapp-actions-DPszRJ8b.js → whatsapp-actions-BDkbnZVH.js} +21 -21
- package/dist/{workspace-TqfVSQuO.js → workspace-kVMIaBrV.js} +20 -20
- package/package.json +1 -1
- package/dist/api-key-rotation-Dzvqp3Dc.js +0 -181
- package/dist/deliver-runtime-BdUlqV9E.js +0 -36
- package/dist/deps-send-discord.runtime-R8jUd_2I.js +0 -26
- package/dist/deps-send-imessage.runtime-Die0aWtU.js +0 -25
- package/dist/deps-send-signal.runtime-Biux_4v4.js +0 -24
- package/dist/deps-send-slack.runtime-CkUST2Ky.js +0 -22
- package/dist/deps-send-telegram.runtime-CIN5ILBe.js +0 -27
- package/dist/deps-send-whatsapp.runtime-DUff9bWS.js +0 -60
- package/dist/errors-DfgAh2Ml.js +0 -54
- package/dist/image-runtime-irHu11-U.js +0 -29
- package/dist/manager-runtime-BISxj7HK.js +0 -18
- package/dist/pi-model-discovery-runtime-bzJViQLK.js +0 -11
- package/dist/plugin-sdk/accounts-BNuRM3rG.js +0 -288
- package/dist/plugin-sdk/accounts-CGTYP7Rh.js +0 -46
- package/dist/plugin-sdk/accounts-CcS9IAhD.js +0 -35
- package/dist/plugin-sdk/active-listener-CTsLn1AX.js +0 -50
- package/dist/plugin-sdk/audio-preflight-CRGLqp-g.js +0 -69
- package/dist/plugin-sdk/audio-transcription-runner-RXsskMMk.js +0 -2176
- package/dist/plugin-sdk/audit-membership-runtime-B9b-zRwg.js +0 -58
- package/dist/plugin-sdk/channel-activity-gPvD1D7S.js +0 -94
- package/dist/plugin-sdk/channel-web-LGl1zPJt.js +0 -2256
- package/dist/plugin-sdk/chrome-9Y_LcUg1.js +0 -2415
- package/dist/plugin-sdk/commands-registry-CcdEPxVg.js +0 -1125
- package/dist/plugin-sdk/config-CrQ5bCrw.js +0 -17912
- package/dist/plugin-sdk/deliver-D3xr5AkB.js +0 -1694
- package/dist/plugin-sdk/deliver-runtime-B79ZQu69.js +0 -32
- package/dist/plugin-sdk/deliver-runtime-BdTC7uKE.js +0 -32
- package/dist/plugin-sdk/deps-send-discord.runtime-BOQZIqC8.js +0 -23
- package/dist/plugin-sdk/deps-send-discord.runtime-CObCNMt3.js +0 -23
- package/dist/plugin-sdk/deps-send-imessage.runtime-CuHOc9Ka.js +0 -22
- package/dist/plugin-sdk/deps-send-imessage.runtime-DlWgi2DH.js +0 -22
- package/dist/plugin-sdk/deps-send-signal.runtime-Cz7FT8J8.js +0 -21
- package/dist/plugin-sdk/deps-send-signal.runtime-iPynghkE.js +0 -21
- package/dist/plugin-sdk/deps-send-slack.runtime-D4vDoRsg.js +0 -19
- package/dist/plugin-sdk/deps-send-slack.runtime-DNTbE5jS.js +0 -19
- package/dist/plugin-sdk/deps-send-telegram.runtime-7CR-xtCF.js +0 -24
- package/dist/plugin-sdk/deps-send-telegram.runtime-DjTVED_m.js +0 -24
- package/dist/plugin-sdk/deps-send-whatsapp.runtime-CRWOIKRC.js +0 -57
- package/dist/plugin-sdk/deps-send-whatsapp.runtime-bUi8kghi.js +0 -57
- package/dist/plugin-sdk/diagnostic-BXkLYs_9.js +0 -319
- package/dist/plugin-sdk/fetch-guard-C55uvn27.js +0 -156
- package/dist/plugin-sdk/fs-safe-Dqmpk-Fr.js +0 -352
- package/dist/plugin-sdk/image-3xW7IJdq.js +0 -2310
- package/dist/plugin-sdk/image-ops-BjK2qZZn.js +0 -584
- package/dist/plugin-sdk/image-runtime-CZZJJqcW.js +0 -25
- package/dist/plugin-sdk/image-runtime-Cjz368oj.js +0 -25
- package/dist/plugin-sdk/ir-CS7uuQhN.js +0 -1296
- package/dist/plugin-sdk/local-roots-DmOKwiNW.js +0 -186
- package/dist/plugin-sdk/logger-DDdrdbDu.js +0 -1163
- package/dist/plugin-sdk/login-BSEeU27Y.js +0 -57
- package/dist/plugin-sdk/login-qr-BwWJsDSj.js +0 -320
- package/dist/plugin-sdk/manager-DiXPCubI.js +0 -3917
- package/dist/plugin-sdk/manager-runtime-CF55pBNe.js +0 -15
- package/dist/plugin-sdk/manager-runtime-Ct0m9UJC.js +0 -15
- package/dist/plugin-sdk/outbound-attachment-BoFx05zw.js +0 -19
- package/dist/plugin-sdk/outbound-cpqK1GFe.js +0 -212
- package/dist/plugin-sdk/path-alias-guards-gBhrAn14.js +0 -43
- package/dist/plugin-sdk/paths-C6W4VHoa.js +0 -166
- package/dist/plugin-sdk/pi-embedded-helpers-C-B9B6Sp.js +0 -9627
- package/dist/plugin-sdk/pi-model-discovery-BGEeoPzN.js +0 -134
- package/dist/plugin-sdk/pi-model-discovery-runtime-BHZ_Htob.js +0 -8
- package/dist/plugin-sdk/pi-model-discovery-runtime-BrwtJHPU.js +0 -8
- package/dist/plugin-sdk/pi-tools.before-tool-call.runtime-ByN_xThw.js +0 -354
- package/dist/plugin-sdk/plugins-D5cdn70e.js +0 -864
- package/dist/plugin-sdk/proxy-fetch-Cf3IUSDw.js +0 -38
- package/dist/plugin-sdk/pw-ai-C_QOIuin.js +0 -1938
- package/dist/plugin-sdk/qmd-manager-6bozlfFg.js +0 -1448
- package/dist/plugin-sdk/query-expansion-eeVz_aEm.js +0 -1011
- package/dist/plugin-sdk/redact-DfACyt0X.js +0 -319
- package/dist/plugin-sdk/reply-CQUX_haM.js +0 -98828
- package/dist/plugin-sdk/resolve-outbound-target-Dbz0O8cR.js +0 -40
- package/dist/plugin-sdk/run-with-concurrency-5DMu9szx.js +0 -1994
- package/dist/plugin-sdk/runtime-whatsapp-login.runtime-DitS0I1z.js +0 -10
- package/dist/plugin-sdk/runtime-whatsapp-login.runtime-OthrtsLL.js +0 -10
- package/dist/plugin-sdk/runtime-whatsapp-outbound.runtime-CYCr6A3v.js +0 -19
- package/dist/plugin-sdk/runtime-whatsapp-outbound.runtime-Q2HL0zL3.js +0 -19
- package/dist/plugin-sdk/send-BACEu1Un.js +0 -414
- package/dist/plugin-sdk/send-BU4OoR7u.js +0 -2587
- package/dist/plugin-sdk/send-DbxOJ_BC.js +0 -3135
- package/dist/plugin-sdk/send-n932vjT5.js +0 -540
- package/dist/plugin-sdk/send-uCPS53j8.js +0 -503
- package/dist/plugin-sdk/session-DenDKR_-.js +0 -169
- package/dist/plugin-sdk/skill-commands-BK1KDKmS.js +0 -342
- package/dist/plugin-sdk/skills-D4am-zkO.js +0 -1428
- package/dist/plugin-sdk/slash-commands.runtime-Bx1K1iqP.js +0 -13
- package/dist/plugin-sdk/slash-commands.runtime-DWfFqMZw.js +0 -13
- package/dist/plugin-sdk/slash-dispatch.runtime-DVn338JI.js +0 -52
- package/dist/plugin-sdk/slash-dispatch.runtime-pnWH5AjM.js +0 -52
- package/dist/plugin-sdk/slash-skill-commands.runtime-Dbi_YzPO.js +0 -16
- package/dist/plugin-sdk/slash-skill-commands.runtime-DxvNWv_E.js +0 -16
- package/dist/plugin-sdk/ssrf-2WBi1Tzx.js +0 -202
- package/dist/plugin-sdk/store-BKDMuvyn.js +0 -81
- package/dist/plugin-sdk/subagent-registry-runtime-FhP0l-Rw.js +0 -52
- package/dist/plugin-sdk/subagent-registry-runtime-hH9ADku1.js +0 -52
- package/dist/plugin-sdk/tables-CrDYcv_b.js +0 -55
- package/dist/plugin-sdk/target-errors-aOwE-MIU.js +0 -195
- package/dist/plugin-sdk/thinking-D41FMh9T.js +0 -1206
- package/dist/plugin-sdk/tokens-CTIYTLWu.js +0 -52
- package/dist/plugin-sdk/tool-images-CWc54lpI.js +0 -274
- package/dist/plugin-sdk/web-AtEy-48y.js +0 -56
- package/dist/plugin-sdk/web-DjKONHqF.js +0 -56
- package/dist/plugin-sdk/whatsapp-actions-DEZcm_CZ.js +0 -80
- package/dist/runtime-whatsapp-login.runtime-BqOsE5As.js +0 -13
- package/dist/runtime-whatsapp-outbound.runtime-D5S6mxFT.js +0 -22
- package/dist/slash-commands.runtime-JqCsKeu2.js +0 -16
- package/dist/slash-dispatch.runtime-h9I6EDYB.js +0 -56
- package/dist/slash-skill-commands.runtime-C0QZlkpu.js +0 -20
- package/dist/subagent-registry-runtime-BxvwRp_3.js +0 -56
|
@@ -1,1163 +0,0 @@
|
|
|
1
|
-
import { d as resolveRequiredHomeDir, l as expandHomePrefix, o as resolveOAuthDir, r as resolveConfigPath, u as resolveEffectiveHomeDir } from "./paths-8xF5kDne.js";
|
|
2
|
-
import fs from "node:fs";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import os from "node:os";
|
|
5
|
-
import util from "node:util";
|
|
6
|
-
import JSON5 from "json5";
|
|
7
|
-
import { Logger } from "tslog";
|
|
8
|
-
import chalk, { Chalk } from "chalk";
|
|
9
|
-
|
|
10
|
-
//#region src/infra/cli-root-options.ts
|
|
11
|
-
const FLAG_TERMINATOR = "--";
|
|
12
|
-
const ROOT_BOOLEAN_FLAGS = new Set(["--dev", "--no-color"]);
|
|
13
|
-
const ROOT_VALUE_FLAGS = new Set(["--profile", "--log-level"]);
|
|
14
|
-
function isValueToken(arg) {
|
|
15
|
-
if (!arg || arg === FLAG_TERMINATOR) return false;
|
|
16
|
-
if (!arg.startsWith("-")) return true;
|
|
17
|
-
return /^-\d+(?:\.\d+)?$/.test(arg);
|
|
18
|
-
}
|
|
19
|
-
function consumeRootOptionToken(args, index) {
|
|
20
|
-
const arg = args[index];
|
|
21
|
-
if (!arg) return 0;
|
|
22
|
-
if (ROOT_BOOLEAN_FLAGS.has(arg)) return 1;
|
|
23
|
-
if (arg.startsWith("--profile=") || arg.startsWith("--log-level=")) return 1;
|
|
24
|
-
if (ROOT_VALUE_FLAGS.has(arg)) return isValueToken(args[index + 1]) ? 2 : 1;
|
|
25
|
-
return 0;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
//#endregion
|
|
29
|
-
//#region src/cli/argv.ts
|
|
30
|
-
function getCommandPathWithRootOptions(argv, depth = 2) {
|
|
31
|
-
return getCommandPathInternal(argv, depth, { skipRootOptions: true });
|
|
32
|
-
}
|
|
33
|
-
function getCommandPathInternal(argv, depth, opts) {
|
|
34
|
-
const args = argv.slice(2);
|
|
35
|
-
const path = [];
|
|
36
|
-
for (let i = 0; i < args.length; i += 1) {
|
|
37
|
-
const arg = args[i];
|
|
38
|
-
if (!arg) continue;
|
|
39
|
-
if (arg === "--") break;
|
|
40
|
-
if (opts.skipRootOptions) {
|
|
41
|
-
const consumed = consumeRootOptionToken(args, i);
|
|
42
|
-
if (consumed > 0) {
|
|
43
|
-
i += consumed - 1;
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
if (arg.startsWith("-")) continue;
|
|
48
|
-
path.push(arg);
|
|
49
|
-
if (path.length >= depth) break;
|
|
50
|
-
}
|
|
51
|
-
return path;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
//#endregion
|
|
55
|
-
//#region src/infra/tmp-squidclaw-dir.ts
|
|
56
|
-
const POSIX_SQUIDCLAW_TMP_DIR = "/tmp/squidclaw";
|
|
57
|
-
const TMP_DIR_ACCESS_MODE = fs.constants.W_OK | fs.constants.X_OK;
|
|
58
|
-
function isNodeErrorWithCode(err, code) {
|
|
59
|
-
return typeof err === "object" && err !== null && "code" in err && err.code === code;
|
|
60
|
-
}
|
|
61
|
-
function resolvePreferredSquidClawTmpDir(options = {}) {
|
|
62
|
-
const accessSync = options.accessSync ?? fs.accessSync;
|
|
63
|
-
const chmodSync = options.chmodSync ?? fs.chmodSync;
|
|
64
|
-
const lstatSync = options.lstatSync ?? fs.lstatSync;
|
|
65
|
-
const mkdirSync = options.mkdirSync ?? fs.mkdirSync;
|
|
66
|
-
const warn = options.warn ?? ((message) => console.warn(message));
|
|
67
|
-
const getuid = options.getuid ?? (() => {
|
|
68
|
-
try {
|
|
69
|
-
return typeof process.getuid === "function" ? process.getuid() : void 0;
|
|
70
|
-
} catch {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
const tmpdir = options.tmpdir ?? os.tmpdir;
|
|
75
|
-
const uid = getuid();
|
|
76
|
-
const isSecureDirForUser = (st) => {
|
|
77
|
-
if (uid === void 0) return true;
|
|
78
|
-
if (typeof st.uid === "number" && st.uid !== uid) return false;
|
|
79
|
-
if (typeof st.mode === "number" && (st.mode & 18) !== 0) return false;
|
|
80
|
-
return true;
|
|
81
|
-
};
|
|
82
|
-
const fallback = () => {
|
|
83
|
-
const base = tmpdir();
|
|
84
|
-
const suffix = uid === void 0 ? "squidclaw" : `squidclaw-${uid}`;
|
|
85
|
-
return path.join(base, suffix);
|
|
86
|
-
};
|
|
87
|
-
const isTrustedTmpDir = (st) => {
|
|
88
|
-
return st.isDirectory() && !st.isSymbolicLink() && isSecureDirForUser(st);
|
|
89
|
-
};
|
|
90
|
-
const resolveDirState = (candidatePath) => {
|
|
91
|
-
try {
|
|
92
|
-
if (!isTrustedTmpDir(lstatSync(candidatePath))) return "invalid";
|
|
93
|
-
accessSync(candidatePath, TMP_DIR_ACCESS_MODE);
|
|
94
|
-
return "available";
|
|
95
|
-
} catch (err) {
|
|
96
|
-
if (isNodeErrorWithCode(err, "ENOENT")) return "missing";
|
|
97
|
-
return "invalid";
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
const tryRepairWritableBits = (candidatePath) => {
|
|
101
|
-
try {
|
|
102
|
-
const st = lstatSync(candidatePath);
|
|
103
|
-
if (!st.isDirectory() || st.isSymbolicLink()) return false;
|
|
104
|
-
if (uid !== void 0 && typeof st.uid === "number" && st.uid !== uid) return false;
|
|
105
|
-
if (typeof st.mode !== "number" || (st.mode & 18) === 0) return false;
|
|
106
|
-
chmodSync(candidatePath, 448);
|
|
107
|
-
warn(`[squidclaw] tightened permissions on temp dir: ${candidatePath}`);
|
|
108
|
-
return resolveDirState(candidatePath) === "available";
|
|
109
|
-
} catch {
|
|
110
|
-
return false;
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
const ensureTrustedFallbackDir = () => {
|
|
114
|
-
const fallbackPath = fallback();
|
|
115
|
-
const state = resolveDirState(fallbackPath);
|
|
116
|
-
if (state === "available") return fallbackPath;
|
|
117
|
-
if (state === "invalid") {
|
|
118
|
-
if (tryRepairWritableBits(fallbackPath)) return fallbackPath;
|
|
119
|
-
throw new Error(`Unsafe fallback SquidClaw temp dir: ${fallbackPath}`);
|
|
120
|
-
}
|
|
121
|
-
try {
|
|
122
|
-
mkdirSync(fallbackPath, {
|
|
123
|
-
recursive: true,
|
|
124
|
-
mode: 448
|
|
125
|
-
});
|
|
126
|
-
chmodSync(fallbackPath, 448);
|
|
127
|
-
} catch {
|
|
128
|
-
throw new Error(`Unable to create fallback SquidClaw temp dir: ${fallbackPath}`);
|
|
129
|
-
}
|
|
130
|
-
if (resolveDirState(fallbackPath) !== "available" && !tryRepairWritableBits(fallbackPath)) throw new Error(`Unsafe fallback SquidClaw temp dir: ${fallbackPath}`);
|
|
131
|
-
return fallbackPath;
|
|
132
|
-
};
|
|
133
|
-
const existingPreferredState = resolveDirState(POSIX_SQUIDCLAW_TMP_DIR);
|
|
134
|
-
if (existingPreferredState === "available") return POSIX_SQUIDCLAW_TMP_DIR;
|
|
135
|
-
if (existingPreferredState === "invalid") {
|
|
136
|
-
if (tryRepairWritableBits(POSIX_SQUIDCLAW_TMP_DIR)) return POSIX_SQUIDCLAW_TMP_DIR;
|
|
137
|
-
return ensureTrustedFallbackDir();
|
|
138
|
-
}
|
|
139
|
-
try {
|
|
140
|
-
accessSync("/tmp", TMP_DIR_ACCESS_MODE);
|
|
141
|
-
mkdirSync(POSIX_SQUIDCLAW_TMP_DIR, {
|
|
142
|
-
recursive: true,
|
|
143
|
-
mode: 448
|
|
144
|
-
});
|
|
145
|
-
chmodSync(POSIX_SQUIDCLAW_TMP_DIR, 448);
|
|
146
|
-
if (resolveDirState(POSIX_SQUIDCLAW_TMP_DIR) !== "available" && !tryRepairWritableBits(POSIX_SQUIDCLAW_TMP_DIR)) return ensureTrustedFallbackDir();
|
|
147
|
-
return POSIX_SQUIDCLAW_TMP_DIR;
|
|
148
|
-
} catch {
|
|
149
|
-
return ensureTrustedFallbackDir();
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
//#endregion
|
|
154
|
-
//#region src/logging/config.ts
|
|
155
|
-
function readLoggingConfig() {
|
|
156
|
-
const configPath = resolveConfigPath();
|
|
157
|
-
try {
|
|
158
|
-
if (!fs.existsSync(configPath)) return;
|
|
159
|
-
const raw = fs.readFileSync(configPath, "utf-8");
|
|
160
|
-
const logging = JSON5.parse(raw)?.logging;
|
|
161
|
-
if (!logging || typeof logging !== "object" || Array.isArray(logging)) return;
|
|
162
|
-
return logging;
|
|
163
|
-
} catch {
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
//#endregion
|
|
169
|
-
//#region src/logging/levels.ts
|
|
170
|
-
const ALLOWED_LOG_LEVELS = [
|
|
171
|
-
"silent",
|
|
172
|
-
"fatal",
|
|
173
|
-
"error",
|
|
174
|
-
"warn",
|
|
175
|
-
"info",
|
|
176
|
-
"debug",
|
|
177
|
-
"trace"
|
|
178
|
-
];
|
|
179
|
-
function tryParseLogLevel(level) {
|
|
180
|
-
if (typeof level !== "string") return;
|
|
181
|
-
const candidate = level.trim();
|
|
182
|
-
return ALLOWED_LOG_LEVELS.includes(candidate) ? candidate : void 0;
|
|
183
|
-
}
|
|
184
|
-
function normalizeLogLevel(level, fallback = "info") {
|
|
185
|
-
return tryParseLogLevel(level) ?? fallback;
|
|
186
|
-
}
|
|
187
|
-
function levelToMinLevel(level) {
|
|
188
|
-
return {
|
|
189
|
-
fatal: 0,
|
|
190
|
-
error: 1,
|
|
191
|
-
warn: 2,
|
|
192
|
-
info: 3,
|
|
193
|
-
debug: 4,
|
|
194
|
-
trace: 5,
|
|
195
|
-
silent: Number.POSITIVE_INFINITY
|
|
196
|
-
}[level];
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
//#endregion
|
|
200
|
-
//#region src/logging/state.ts
|
|
201
|
-
const loggingState = {
|
|
202
|
-
cachedLogger: null,
|
|
203
|
-
cachedSettings: null,
|
|
204
|
-
cachedConsoleSettings: null,
|
|
205
|
-
overrideSettings: null,
|
|
206
|
-
invalidEnvLogLevelValue: null,
|
|
207
|
-
consolePatched: false,
|
|
208
|
-
forceConsoleToStderr: false,
|
|
209
|
-
consoleTimestampPrefix: false,
|
|
210
|
-
consoleSubsystemFilter: null,
|
|
211
|
-
resolvingConsoleSettings: false,
|
|
212
|
-
streamErrorHandlersInstalled: false,
|
|
213
|
-
rawConsole: null
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
//#endregion
|
|
217
|
-
//#region src/logging/env-log-level.ts
|
|
218
|
-
function resolveEnvLogLevelOverride() {
|
|
219
|
-
const raw = process.env.SQUIDCLAW_LOG_LEVEL;
|
|
220
|
-
const trimmed = typeof raw === "string" ? raw.trim() : "";
|
|
221
|
-
if (!trimmed) {
|
|
222
|
-
loggingState.invalidEnvLogLevelValue = null;
|
|
223
|
-
return;
|
|
224
|
-
}
|
|
225
|
-
const parsed = tryParseLogLevel(trimmed);
|
|
226
|
-
if (parsed) {
|
|
227
|
-
loggingState.invalidEnvLogLevelValue = null;
|
|
228
|
-
return parsed;
|
|
229
|
-
}
|
|
230
|
-
if (loggingState.invalidEnvLogLevelValue !== trimmed) {
|
|
231
|
-
loggingState.invalidEnvLogLevelValue = trimmed;
|
|
232
|
-
process.stderr.write(`[squidclaw] Ignoring invalid SQUIDCLAW_LOG_LEVEL="${trimmed}" (allowed: ${ALLOWED_LOG_LEVELS.join("|")}).\n`);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
//#endregion
|
|
237
|
-
//#region src/logging/node-require.ts
|
|
238
|
-
function resolveNodeRequireFromMeta(metaUrl) {
|
|
239
|
-
const getBuiltinModule = process.getBuiltinModule;
|
|
240
|
-
if (typeof getBuiltinModule !== "function") return null;
|
|
241
|
-
try {
|
|
242
|
-
const moduleNamespace = getBuiltinModule("module");
|
|
243
|
-
const createRequire = typeof moduleNamespace.createRequire === "function" ? moduleNamespace.createRequire : null;
|
|
244
|
-
return createRequire ? createRequire(metaUrl) : null;
|
|
245
|
-
} catch {
|
|
246
|
-
return null;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
//#endregion
|
|
251
|
-
//#region src/logging/timestamps.ts
|
|
252
|
-
function isValidTimeZone(tz) {
|
|
253
|
-
try {
|
|
254
|
-
new Intl.DateTimeFormat("en", { timeZone: tz });
|
|
255
|
-
return true;
|
|
256
|
-
} catch {
|
|
257
|
-
return false;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
function formatLocalIsoWithOffset(now, timeZone) {
|
|
261
|
-
const explicit = timeZone ?? process.env.TZ;
|
|
262
|
-
const tz = explicit && isValidTimeZone(explicit) ? explicit : Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
263
|
-
const fmt = new Intl.DateTimeFormat("en", {
|
|
264
|
-
timeZone: tz,
|
|
265
|
-
year: "numeric",
|
|
266
|
-
month: "2-digit",
|
|
267
|
-
day: "2-digit",
|
|
268
|
-
hour: "2-digit",
|
|
269
|
-
minute: "2-digit",
|
|
270
|
-
second: "2-digit",
|
|
271
|
-
hour12: false,
|
|
272
|
-
fractionalSecondDigits: 3,
|
|
273
|
-
timeZoneName: "longOffset"
|
|
274
|
-
});
|
|
275
|
-
const parts = Object.fromEntries(fmt.formatToParts(now).map((p) => [p.type, p.value]));
|
|
276
|
-
const offsetRaw = parts.timeZoneName ?? "GMT";
|
|
277
|
-
const offset = offsetRaw === "GMT" ? "+00:00" : offsetRaw.slice(3);
|
|
278
|
-
return `${parts.year}-${parts.month}-${parts.day}T${parts.hour}:${parts.minute}:${parts.second}.${parts.fractionalSecond}${offset}`;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
//#endregion
|
|
282
|
-
//#region src/logging/logger.ts
|
|
283
|
-
const DEFAULT_LOG_DIR = resolvePreferredSquidClawTmpDir();
|
|
284
|
-
const DEFAULT_LOG_FILE = path.join(DEFAULT_LOG_DIR, "squidclaw.log");
|
|
285
|
-
const LOG_PREFIX = "squidclaw";
|
|
286
|
-
const LOG_SUFFIX = ".log";
|
|
287
|
-
const MAX_LOG_AGE_MS = 1440 * 60 * 1e3;
|
|
288
|
-
const DEFAULT_MAX_LOG_FILE_BYTES = 500 * 1024 * 1024;
|
|
289
|
-
const requireConfig$1 = resolveNodeRequireFromMeta(import.meta.url);
|
|
290
|
-
const externalTransports = /* @__PURE__ */ new Set();
|
|
291
|
-
function shouldSkipLoadConfigFallback(argv = process.argv) {
|
|
292
|
-
const [primary, secondary] = getCommandPathWithRootOptions(argv, 2);
|
|
293
|
-
return primary === "config" && secondary === "validate";
|
|
294
|
-
}
|
|
295
|
-
function attachExternalTransport(logger, transport) {
|
|
296
|
-
logger.attachTransport((logObj) => {
|
|
297
|
-
if (!externalTransports.has(transport)) return;
|
|
298
|
-
try {
|
|
299
|
-
transport(logObj);
|
|
300
|
-
} catch {}
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
function canUseSilentVitestFileLogFastPath(envLevel) {
|
|
304
|
-
return process.env.VITEST === "true" && process.env.SQUIDCLAW_TEST_FILE_LOG !== "1" && !envLevel && !loggingState.overrideSettings;
|
|
305
|
-
}
|
|
306
|
-
function resolveSettings() {
|
|
307
|
-
const envLevel = resolveEnvLogLevelOverride();
|
|
308
|
-
if (canUseSilentVitestFileLogFastPath(envLevel)) return {
|
|
309
|
-
level: "silent",
|
|
310
|
-
file: defaultRollingPathForToday(),
|
|
311
|
-
maxFileBytes: DEFAULT_MAX_LOG_FILE_BYTES
|
|
312
|
-
};
|
|
313
|
-
let cfg = loggingState.overrideSettings ?? readLoggingConfig();
|
|
314
|
-
if (!cfg && !shouldSkipLoadConfigFallback()) try {
|
|
315
|
-
cfg = (requireConfig$1?.("../config/config.js"))?.loadConfig?.().logging;
|
|
316
|
-
} catch {
|
|
317
|
-
cfg = void 0;
|
|
318
|
-
}
|
|
319
|
-
const defaultLevel = process.env.VITEST === "true" && process.env.SQUIDCLAW_TEST_FILE_LOG !== "1" ? "silent" : "info";
|
|
320
|
-
const fromConfig = normalizeLogLevel(cfg?.level, defaultLevel);
|
|
321
|
-
return {
|
|
322
|
-
level: envLevel ?? fromConfig,
|
|
323
|
-
file: cfg?.file ?? defaultRollingPathForToday(),
|
|
324
|
-
maxFileBytes: resolveMaxLogFileBytes(cfg?.maxFileBytes)
|
|
325
|
-
};
|
|
326
|
-
}
|
|
327
|
-
function settingsChanged(a, b) {
|
|
328
|
-
if (!a) return true;
|
|
329
|
-
return a.level !== b.level || a.file !== b.file || a.maxFileBytes !== b.maxFileBytes;
|
|
330
|
-
}
|
|
331
|
-
function isFileLogLevelEnabled(level) {
|
|
332
|
-
const settings = loggingState.cachedSettings ?? resolveSettings();
|
|
333
|
-
if (!loggingState.cachedSettings) loggingState.cachedSettings = settings;
|
|
334
|
-
if (settings.level === "silent") return false;
|
|
335
|
-
return levelToMinLevel(level) <= levelToMinLevel(settings.level);
|
|
336
|
-
}
|
|
337
|
-
function buildLogger(settings) {
|
|
338
|
-
const logger = new Logger({
|
|
339
|
-
name: "squidclaw",
|
|
340
|
-
minLevel: levelToMinLevel(settings.level),
|
|
341
|
-
type: "hidden"
|
|
342
|
-
});
|
|
343
|
-
if (settings.level === "silent") {
|
|
344
|
-
for (const transport of externalTransports) attachExternalTransport(logger, transport);
|
|
345
|
-
return logger;
|
|
346
|
-
}
|
|
347
|
-
fs.mkdirSync(path.dirname(settings.file), { recursive: true });
|
|
348
|
-
if (isRollingPath(settings.file)) pruneOldRollingLogs(path.dirname(settings.file));
|
|
349
|
-
let currentFileBytes = getCurrentLogFileBytes(settings.file);
|
|
350
|
-
let warnedAboutSizeCap = false;
|
|
351
|
-
logger.attachTransport((logObj) => {
|
|
352
|
-
try {
|
|
353
|
-
const time = formatLocalIsoWithOffset(logObj.date ?? /* @__PURE__ */ new Date());
|
|
354
|
-
const payload = `${JSON.stringify({
|
|
355
|
-
...logObj,
|
|
356
|
-
time
|
|
357
|
-
})}\n`;
|
|
358
|
-
const payloadBytes = Buffer.byteLength(payload, "utf8");
|
|
359
|
-
const nextBytes = currentFileBytes + payloadBytes;
|
|
360
|
-
if (nextBytes > settings.maxFileBytes) {
|
|
361
|
-
if (!warnedAboutSizeCap) {
|
|
362
|
-
warnedAboutSizeCap = true;
|
|
363
|
-
const warningLine = JSON.stringify({
|
|
364
|
-
time: formatLocalIsoWithOffset(/* @__PURE__ */ new Date()),
|
|
365
|
-
level: "warn",
|
|
366
|
-
subsystem: "logging",
|
|
367
|
-
message: `log file size cap reached; suppressing writes file=${settings.file} maxFileBytes=${settings.maxFileBytes}`
|
|
368
|
-
});
|
|
369
|
-
appendLogLine(settings.file, `${warningLine}\n`);
|
|
370
|
-
process.stderr.write(`[squidclaw] log file size cap reached; suppressing writes file=${settings.file} maxFileBytes=${settings.maxFileBytes}\n`);
|
|
371
|
-
}
|
|
372
|
-
return;
|
|
373
|
-
}
|
|
374
|
-
if (appendLogLine(settings.file, payload)) currentFileBytes = nextBytes;
|
|
375
|
-
} catch {}
|
|
376
|
-
});
|
|
377
|
-
for (const transport of externalTransports) attachExternalTransport(logger, transport);
|
|
378
|
-
return logger;
|
|
379
|
-
}
|
|
380
|
-
function resolveMaxLogFileBytes(raw) {
|
|
381
|
-
if (typeof raw === "number" && Number.isFinite(raw) && raw > 0) return Math.floor(raw);
|
|
382
|
-
return DEFAULT_MAX_LOG_FILE_BYTES;
|
|
383
|
-
}
|
|
384
|
-
function getCurrentLogFileBytes(file) {
|
|
385
|
-
try {
|
|
386
|
-
return fs.statSync(file).size;
|
|
387
|
-
} catch {
|
|
388
|
-
return 0;
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
function appendLogLine(file, line) {
|
|
392
|
-
try {
|
|
393
|
-
fs.appendFileSync(file, line, { encoding: "utf8" });
|
|
394
|
-
return true;
|
|
395
|
-
} catch {
|
|
396
|
-
return false;
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
function getLogger() {
|
|
400
|
-
const settings = resolveSettings();
|
|
401
|
-
const cachedLogger = loggingState.cachedLogger;
|
|
402
|
-
const cachedSettings = loggingState.cachedSettings;
|
|
403
|
-
if (!cachedLogger || settingsChanged(cachedSettings, settings)) {
|
|
404
|
-
loggingState.cachedLogger = buildLogger(settings);
|
|
405
|
-
loggingState.cachedSettings = settings;
|
|
406
|
-
}
|
|
407
|
-
return loggingState.cachedLogger;
|
|
408
|
-
}
|
|
409
|
-
function getChildLogger(bindings, opts) {
|
|
410
|
-
const base = getLogger();
|
|
411
|
-
const minLevel = opts?.level ? levelToMinLevel(opts.level) : void 0;
|
|
412
|
-
const name = bindings ? JSON.stringify(bindings) : void 0;
|
|
413
|
-
return base.getSubLogger({
|
|
414
|
-
name,
|
|
415
|
-
minLevel,
|
|
416
|
-
prefix: bindings ? [name ?? ""] : []
|
|
417
|
-
});
|
|
418
|
-
}
|
|
419
|
-
function toPinoLikeLogger(logger, level) {
|
|
420
|
-
const buildChild = (bindings) => toPinoLikeLogger(logger.getSubLogger({ name: bindings ? JSON.stringify(bindings) : void 0 }), level);
|
|
421
|
-
return {
|
|
422
|
-
level,
|
|
423
|
-
child: buildChild,
|
|
424
|
-
trace: (...args) => logger.trace(...args),
|
|
425
|
-
debug: (...args) => logger.debug(...args),
|
|
426
|
-
info: (...args) => logger.info(...args),
|
|
427
|
-
warn: (...args) => logger.warn(...args),
|
|
428
|
-
error: (...args) => logger.error(...args),
|
|
429
|
-
fatal: (...args) => logger.fatal(...args)
|
|
430
|
-
};
|
|
431
|
-
}
|
|
432
|
-
function registerLogTransport(transport) {
|
|
433
|
-
externalTransports.add(transport);
|
|
434
|
-
const logger = loggingState.cachedLogger;
|
|
435
|
-
if (logger) attachExternalTransport(logger, transport);
|
|
436
|
-
return () => {
|
|
437
|
-
externalTransports.delete(transport);
|
|
438
|
-
};
|
|
439
|
-
}
|
|
440
|
-
function formatLocalDate(date) {
|
|
441
|
-
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
|
|
442
|
-
}
|
|
443
|
-
function defaultRollingPathForToday() {
|
|
444
|
-
const today = formatLocalDate(/* @__PURE__ */ new Date());
|
|
445
|
-
return path.join(DEFAULT_LOG_DIR, `${LOG_PREFIX}-${today}${LOG_SUFFIX}`);
|
|
446
|
-
}
|
|
447
|
-
function isRollingPath(file) {
|
|
448
|
-
const base = path.basename(file);
|
|
449
|
-
return base.startsWith(`${LOG_PREFIX}-`) && base.endsWith(LOG_SUFFIX) && base.length === `${LOG_PREFIX}-YYYY-MM-DD${LOG_SUFFIX}`.length;
|
|
450
|
-
}
|
|
451
|
-
function pruneOldRollingLogs(dir) {
|
|
452
|
-
try {
|
|
453
|
-
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
454
|
-
const cutoff = Date.now() - MAX_LOG_AGE_MS;
|
|
455
|
-
for (const entry of entries) {
|
|
456
|
-
if (!entry.isFile()) continue;
|
|
457
|
-
if (!entry.name.startsWith(`${LOG_PREFIX}-`) || !entry.name.endsWith(LOG_SUFFIX)) continue;
|
|
458
|
-
const fullPath = path.join(dir, entry.name);
|
|
459
|
-
try {
|
|
460
|
-
if (fs.statSync(fullPath).mtimeMs < cutoff) fs.rmSync(fullPath, { force: true });
|
|
461
|
-
} catch {}
|
|
462
|
-
}
|
|
463
|
-
} catch {}
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
//#endregion
|
|
467
|
-
//#region src/terminal/palette.ts
|
|
468
|
-
const LOBSTER_PALETTE = {
|
|
469
|
-
accent: "#FF5A2D",
|
|
470
|
-
accentBright: "#FF7A3D",
|
|
471
|
-
accentDim: "#D14A22",
|
|
472
|
-
info: "#FF8A5B",
|
|
473
|
-
success: "#2FBF71",
|
|
474
|
-
warn: "#FFB020",
|
|
475
|
-
error: "#E23D2D",
|
|
476
|
-
muted: "#8B7F77"
|
|
477
|
-
};
|
|
478
|
-
|
|
479
|
-
//#endregion
|
|
480
|
-
//#region src/terminal/theme.ts
|
|
481
|
-
const hasForceColor = typeof process.env.FORCE_COLOR === "string" && process.env.FORCE_COLOR.trim().length > 0 && process.env.FORCE_COLOR.trim() !== "0";
|
|
482
|
-
const baseChalk = process.env.NO_COLOR && !hasForceColor ? new Chalk({ level: 0 }) : chalk;
|
|
483
|
-
const hex = (value) => baseChalk.hex(value);
|
|
484
|
-
const theme = {
|
|
485
|
-
accent: hex(LOBSTER_PALETTE.accent),
|
|
486
|
-
accentBright: hex(LOBSTER_PALETTE.accentBright),
|
|
487
|
-
accentDim: hex(LOBSTER_PALETTE.accentDim),
|
|
488
|
-
info: hex(LOBSTER_PALETTE.info),
|
|
489
|
-
success: hex(LOBSTER_PALETTE.success),
|
|
490
|
-
warn: hex(LOBSTER_PALETTE.warn),
|
|
491
|
-
error: hex(LOBSTER_PALETTE.error),
|
|
492
|
-
muted: hex(LOBSTER_PALETTE.muted),
|
|
493
|
-
heading: baseChalk.bold.hex(LOBSTER_PALETTE.accent),
|
|
494
|
-
command: hex(LOBSTER_PALETTE.accentBright),
|
|
495
|
-
option: hex(LOBSTER_PALETTE.warn)
|
|
496
|
-
};
|
|
497
|
-
const isRich = () => Boolean(baseChalk.level > 0);
|
|
498
|
-
const colorize = (rich, color, value) => rich ? color(value) : value;
|
|
499
|
-
|
|
500
|
-
//#endregion
|
|
501
|
-
//#region src/globals.ts
|
|
502
|
-
let globalVerbose = false;
|
|
503
|
-
function setVerbose(v) {
|
|
504
|
-
globalVerbose = v;
|
|
505
|
-
}
|
|
506
|
-
function isVerbose() {
|
|
507
|
-
return globalVerbose;
|
|
508
|
-
}
|
|
509
|
-
function shouldLogVerbose() {
|
|
510
|
-
return globalVerbose || isFileLogLevelEnabled("debug");
|
|
511
|
-
}
|
|
512
|
-
function logVerbose(message) {
|
|
513
|
-
if (!shouldLogVerbose()) return;
|
|
514
|
-
try {
|
|
515
|
-
getLogger().debug({ message }, "verbose");
|
|
516
|
-
} catch {}
|
|
517
|
-
if (!globalVerbose) return;
|
|
518
|
-
console.log(theme.muted(message));
|
|
519
|
-
}
|
|
520
|
-
function logVerboseConsole(message) {
|
|
521
|
-
if (!globalVerbose) return;
|
|
522
|
-
console.log(theme.muted(message));
|
|
523
|
-
}
|
|
524
|
-
const success = theme.success;
|
|
525
|
-
const warn = theme.warn;
|
|
526
|
-
const info = theme.info;
|
|
527
|
-
const danger = theme.error;
|
|
528
|
-
|
|
529
|
-
//#endregion
|
|
530
|
-
//#region src/infra/plain-object.ts
|
|
531
|
-
/**
|
|
532
|
-
* Strict plain-object guard (excludes arrays and host objects).
|
|
533
|
-
*/
|
|
534
|
-
function isPlainObject(value) {
|
|
535
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.prototype.toString.call(value) === "[object Object]";
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
//#endregion
|
|
539
|
-
//#region src/utils.ts
|
|
540
|
-
async function ensureDir(dir) {
|
|
541
|
-
await fs.promises.mkdir(dir, { recursive: true });
|
|
542
|
-
}
|
|
543
|
-
/**
|
|
544
|
-
* Check if a file or directory exists at the given path.
|
|
545
|
-
*/
|
|
546
|
-
async function pathExists(targetPath) {
|
|
547
|
-
try {
|
|
548
|
-
await fs.promises.access(targetPath);
|
|
549
|
-
return true;
|
|
550
|
-
} catch {
|
|
551
|
-
return false;
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
function clampNumber(value, min, max) {
|
|
555
|
-
return Math.max(min, Math.min(max, value));
|
|
556
|
-
}
|
|
557
|
-
function clampInt(value, min, max) {
|
|
558
|
-
return clampNumber(Math.floor(value), min, max);
|
|
559
|
-
}
|
|
560
|
-
/** Alias for clampNumber (shorter, more common name) */
|
|
561
|
-
const clamp = clampNumber;
|
|
562
|
-
/**
|
|
563
|
-
* Escapes special regex characters in a string so it can be used in a RegExp constructor.
|
|
564
|
-
*/
|
|
565
|
-
function escapeRegExp(value) {
|
|
566
|
-
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
567
|
-
}
|
|
568
|
-
/**
|
|
569
|
-
* Safely parse JSON, returning null on error instead of throwing.
|
|
570
|
-
*/
|
|
571
|
-
function safeParseJson(raw) {
|
|
572
|
-
try {
|
|
573
|
-
return JSON.parse(raw);
|
|
574
|
-
} catch {
|
|
575
|
-
return null;
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
/**
|
|
579
|
-
* Type guard for Record<string, unknown> (less strict than isPlainObject).
|
|
580
|
-
* Accepts any non-null object that isn't an array.
|
|
581
|
-
*/
|
|
582
|
-
function isRecord(value) {
|
|
583
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
584
|
-
}
|
|
585
|
-
function normalizeE164(number) {
|
|
586
|
-
const digits = number.replace(/^whatsapp:/, "").trim().replace(/[^\d+]/g, "");
|
|
587
|
-
if (digits.startsWith("+")) return `+${digits.slice(1)}`;
|
|
588
|
-
return `+${digits}`;
|
|
589
|
-
}
|
|
590
|
-
/**
|
|
591
|
-
* "Self-chat mode" heuristic (single phone): the gateway is logged in as the owner's own WhatsApp account,
|
|
592
|
-
* and `channels.whatsapp.allowFrom` includes that same number. Used to avoid side-effects that make no sense when the
|
|
593
|
-
* "bot" and the human are the same WhatsApp identity (e.g. auto read receipts, @mention JID triggers).
|
|
594
|
-
*/
|
|
595
|
-
function isSelfChatMode(selfE164, allowFrom) {
|
|
596
|
-
if (!selfE164) return false;
|
|
597
|
-
if (!Array.isArray(allowFrom) || allowFrom.length === 0) return false;
|
|
598
|
-
const normalizedSelf = normalizeE164(selfE164);
|
|
599
|
-
return allowFrom.some((n) => {
|
|
600
|
-
if (n === "*") return false;
|
|
601
|
-
try {
|
|
602
|
-
return normalizeE164(String(n)) === normalizedSelf;
|
|
603
|
-
} catch {
|
|
604
|
-
return false;
|
|
605
|
-
}
|
|
606
|
-
});
|
|
607
|
-
}
|
|
608
|
-
function toWhatsappJid(number) {
|
|
609
|
-
const withoutPrefix = number.replace(/^whatsapp:/, "").trim();
|
|
610
|
-
if (withoutPrefix.includes("@")) return withoutPrefix;
|
|
611
|
-
return `${normalizeE164(withoutPrefix).replace(/\D/g, "")}@s.whatsapp.net`;
|
|
612
|
-
}
|
|
613
|
-
function resolveLidMappingDirs(opts) {
|
|
614
|
-
const dirs = /* @__PURE__ */ new Set();
|
|
615
|
-
const addDir = (dir) => {
|
|
616
|
-
if (!dir) return;
|
|
617
|
-
dirs.add(resolveUserPath(dir));
|
|
618
|
-
};
|
|
619
|
-
addDir(opts?.authDir);
|
|
620
|
-
for (const dir of opts?.lidMappingDirs ?? []) addDir(dir);
|
|
621
|
-
addDir(resolveOAuthDir());
|
|
622
|
-
addDir(path.join(CONFIG_DIR, "credentials"));
|
|
623
|
-
return [...dirs];
|
|
624
|
-
}
|
|
625
|
-
function readLidReverseMapping(lid, opts) {
|
|
626
|
-
const mappingFilename = `lid-mapping-${lid}_reverse.json`;
|
|
627
|
-
const mappingDirs = resolveLidMappingDirs(opts);
|
|
628
|
-
for (const dir of mappingDirs) {
|
|
629
|
-
const mappingPath = path.join(dir, mappingFilename);
|
|
630
|
-
try {
|
|
631
|
-
const data = fs.readFileSync(mappingPath, "utf8");
|
|
632
|
-
const phone = JSON.parse(data);
|
|
633
|
-
if (phone === null || phone === void 0) continue;
|
|
634
|
-
return normalizeE164(String(phone));
|
|
635
|
-
} catch {}
|
|
636
|
-
}
|
|
637
|
-
return null;
|
|
638
|
-
}
|
|
639
|
-
function jidToE164(jid, opts) {
|
|
640
|
-
const match = jid.match(/^(\d+)(?::\d+)?@(s\.whatsapp\.net|hosted)$/);
|
|
641
|
-
if (match) return `+${match[1]}`;
|
|
642
|
-
const lidMatch = jid.match(/^(\d+)(?::\d+)?@(lid|hosted\.lid)$/);
|
|
643
|
-
if (lidMatch) {
|
|
644
|
-
const lid = lidMatch[1];
|
|
645
|
-
const phone = readLidReverseMapping(lid, opts);
|
|
646
|
-
if (phone) return phone;
|
|
647
|
-
if (opts?.logMissing ?? shouldLogVerbose()) logVerbose(`LID mapping not found for ${lid}; skipping inbound message`);
|
|
648
|
-
}
|
|
649
|
-
return null;
|
|
650
|
-
}
|
|
651
|
-
async function resolveJidToE164(jid, opts) {
|
|
652
|
-
if (!jid) return null;
|
|
653
|
-
const direct = jidToE164(jid, opts);
|
|
654
|
-
if (direct) return direct;
|
|
655
|
-
if (!/(@lid|@hosted\.lid)$/.test(jid)) return null;
|
|
656
|
-
if (!opts?.lidLookup?.getPNForLID) return null;
|
|
657
|
-
try {
|
|
658
|
-
const pnJid = await opts.lidLookup.getPNForLID(jid);
|
|
659
|
-
if (!pnJid) return null;
|
|
660
|
-
return jidToE164(pnJid, opts);
|
|
661
|
-
} catch (err) {
|
|
662
|
-
if (shouldLogVerbose()) logVerbose(`LID mapping lookup failed for ${jid}: ${String(err)}`);
|
|
663
|
-
return null;
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
function sleep(ms) {
|
|
667
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
668
|
-
}
|
|
669
|
-
function isHighSurrogate(codeUnit) {
|
|
670
|
-
return codeUnit >= 55296 && codeUnit <= 56319;
|
|
671
|
-
}
|
|
672
|
-
function isLowSurrogate(codeUnit) {
|
|
673
|
-
return codeUnit >= 56320 && codeUnit <= 57343;
|
|
674
|
-
}
|
|
675
|
-
function sliceUtf16Safe(input, start, end) {
|
|
676
|
-
const len = input.length;
|
|
677
|
-
let from = start < 0 ? Math.max(len + start, 0) : Math.min(start, len);
|
|
678
|
-
let to = end === void 0 ? len : end < 0 ? Math.max(len + end, 0) : Math.min(end, len);
|
|
679
|
-
if (to < from) {
|
|
680
|
-
const tmp = from;
|
|
681
|
-
from = to;
|
|
682
|
-
to = tmp;
|
|
683
|
-
}
|
|
684
|
-
if (from > 0 && from < len) {
|
|
685
|
-
if (isLowSurrogate(input.charCodeAt(from)) && isHighSurrogate(input.charCodeAt(from - 1))) from += 1;
|
|
686
|
-
}
|
|
687
|
-
if (to > 0 && to < len) {
|
|
688
|
-
if (isHighSurrogate(input.charCodeAt(to - 1)) && isLowSurrogate(input.charCodeAt(to))) to -= 1;
|
|
689
|
-
}
|
|
690
|
-
return input.slice(from, to);
|
|
691
|
-
}
|
|
692
|
-
function truncateUtf16Safe(input, maxLen) {
|
|
693
|
-
const limit = Math.max(0, Math.floor(maxLen));
|
|
694
|
-
if (input.length <= limit) return input;
|
|
695
|
-
return sliceUtf16Safe(input, 0, limit);
|
|
696
|
-
}
|
|
697
|
-
function resolveUserPath(input) {
|
|
698
|
-
if (!input) return "";
|
|
699
|
-
const trimmed = input.trim();
|
|
700
|
-
if (!trimmed) return trimmed;
|
|
701
|
-
if (trimmed.startsWith("~")) {
|
|
702
|
-
const expanded = expandHomePrefix(trimmed, {
|
|
703
|
-
home: resolveRequiredHomeDir(process.env, os.homedir),
|
|
704
|
-
env: process.env,
|
|
705
|
-
homedir: os.homedir
|
|
706
|
-
});
|
|
707
|
-
return path.resolve(expanded);
|
|
708
|
-
}
|
|
709
|
-
return path.resolve(trimmed);
|
|
710
|
-
}
|
|
711
|
-
function resolveConfigDir(env = process.env, homedir = os.homedir) {
|
|
712
|
-
const override = env.SQUIDCLAW_STATE_DIR?.trim() || env.CLAWDBOT_STATE_DIR?.trim();
|
|
713
|
-
if (override) return resolveUserPath(override);
|
|
714
|
-
const newDir = path.join(resolveRequiredHomeDir(env, homedir), ".squidclaw");
|
|
715
|
-
try {
|
|
716
|
-
if (fs.existsSync(newDir)) return newDir;
|
|
717
|
-
} catch {}
|
|
718
|
-
return newDir;
|
|
719
|
-
}
|
|
720
|
-
function resolveHomeDir() {
|
|
721
|
-
return resolveEffectiveHomeDir(process.env, os.homedir);
|
|
722
|
-
}
|
|
723
|
-
function resolveHomeDisplayPrefix() {
|
|
724
|
-
const home = resolveHomeDir();
|
|
725
|
-
if (!home) return;
|
|
726
|
-
if (process.env.SQUIDCLAW_HOME?.trim()) return {
|
|
727
|
-
home,
|
|
728
|
-
prefix: "$SQUIDCLAW_HOME"
|
|
729
|
-
};
|
|
730
|
-
return {
|
|
731
|
-
home,
|
|
732
|
-
prefix: "~"
|
|
733
|
-
};
|
|
734
|
-
}
|
|
735
|
-
function shortenHomePath(input) {
|
|
736
|
-
if (!input) return input;
|
|
737
|
-
const display = resolveHomeDisplayPrefix();
|
|
738
|
-
if (!display) return input;
|
|
739
|
-
const { home, prefix } = display;
|
|
740
|
-
if (input === home) return prefix;
|
|
741
|
-
if (input.startsWith(`${home}/`) || input.startsWith(`${home}\\`)) return `${prefix}${input.slice(home.length)}`;
|
|
742
|
-
return input;
|
|
743
|
-
}
|
|
744
|
-
function shortenHomeInString(input) {
|
|
745
|
-
if (!input) return input;
|
|
746
|
-
const display = resolveHomeDisplayPrefix();
|
|
747
|
-
if (!display) return input;
|
|
748
|
-
return input.split(display.home).join(display.prefix);
|
|
749
|
-
}
|
|
750
|
-
function formatTerminalLink(label, url, opts) {
|
|
751
|
-
const esc = "\x1B";
|
|
752
|
-
const safeLabel = label.replaceAll(esc, "");
|
|
753
|
-
const safeUrl = url.replaceAll(esc, "");
|
|
754
|
-
if (!(opts?.force === true ? true : opts?.force === false ? false : Boolean(process.stdout.isTTY))) return opts?.fallback ?? `${safeLabel} (${safeUrl})`;
|
|
755
|
-
return `\u001b]8;;${safeUrl}\u0007${safeLabel}\u001b]8;;\u0007`;
|
|
756
|
-
}
|
|
757
|
-
const CONFIG_DIR = resolveConfigDir();
|
|
758
|
-
|
|
759
|
-
//#endregion
|
|
760
|
-
//#region src/terminal/progress-line.ts
|
|
761
|
-
let activeStream = null;
|
|
762
|
-
function registerActiveProgressLine(stream) {
|
|
763
|
-
if (!stream.isTTY) return;
|
|
764
|
-
activeStream = stream;
|
|
765
|
-
}
|
|
766
|
-
function clearActiveProgressLine() {
|
|
767
|
-
if (!activeStream?.isTTY) return;
|
|
768
|
-
activeStream.write("\r\x1B[2K");
|
|
769
|
-
}
|
|
770
|
-
function unregisterActiveProgressLine(stream) {
|
|
771
|
-
if (!activeStream) return;
|
|
772
|
-
if (stream && activeStream !== stream) return;
|
|
773
|
-
activeStream = null;
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
//#endregion
|
|
777
|
-
//#region src/terminal/restore.ts
|
|
778
|
-
const RESET_SEQUENCE = "\x1B[0m\x1B[?25h\x1B[?1000l\x1B[?1002l\x1B[?1003l\x1B[?1006l\x1B[?2004l";
|
|
779
|
-
function reportRestoreFailure(scope, err, reason) {
|
|
780
|
-
const suffix = reason ? ` (${reason})` : "";
|
|
781
|
-
const message = `[terminal] restore ${scope} failed${suffix}: ${String(err)}`;
|
|
782
|
-
try {
|
|
783
|
-
process.stderr.write(`${message}\n`);
|
|
784
|
-
} catch (writeErr) {
|
|
785
|
-
console.error(`[terminal] restore reporting failed${suffix}: ${String(writeErr)}`);
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
function restoreTerminalState(reason, options = {}) {
|
|
789
|
-
const resumeStdin = options.resumeStdinIfPaused ?? options.resumeStdin ?? false;
|
|
790
|
-
try {
|
|
791
|
-
clearActiveProgressLine();
|
|
792
|
-
} catch (err) {
|
|
793
|
-
reportRestoreFailure("progress line", err, reason);
|
|
794
|
-
}
|
|
795
|
-
const stdin = process.stdin;
|
|
796
|
-
if (stdin.isTTY && typeof stdin.setRawMode === "function") {
|
|
797
|
-
try {
|
|
798
|
-
stdin.setRawMode(false);
|
|
799
|
-
} catch (err) {
|
|
800
|
-
reportRestoreFailure("raw mode", err, reason);
|
|
801
|
-
}
|
|
802
|
-
if (resumeStdin && typeof stdin.isPaused === "function" && stdin.isPaused()) try {
|
|
803
|
-
stdin.resume();
|
|
804
|
-
} catch (err) {
|
|
805
|
-
reportRestoreFailure("stdin resume", err, reason);
|
|
806
|
-
}
|
|
807
|
-
}
|
|
808
|
-
if (process.stdout.isTTY) try {
|
|
809
|
-
process.stdout.write(RESET_SEQUENCE);
|
|
810
|
-
} catch (err) {
|
|
811
|
-
reportRestoreFailure("stdout reset", err, reason);
|
|
812
|
-
}
|
|
813
|
-
}
|
|
814
|
-
|
|
815
|
-
//#endregion
|
|
816
|
-
//#region src/runtime.ts
|
|
817
|
-
function shouldEmitRuntimeLog(env = process.env) {
|
|
818
|
-
if (env.VITEST !== "true") return true;
|
|
819
|
-
if (env.SQUIDCLAW_TEST_RUNTIME_LOG === "1") return true;
|
|
820
|
-
return typeof console.log.mock === "object";
|
|
821
|
-
}
|
|
822
|
-
function createRuntimeIo() {
|
|
823
|
-
return {
|
|
824
|
-
log: (...args) => {
|
|
825
|
-
if (!shouldEmitRuntimeLog()) return;
|
|
826
|
-
clearActiveProgressLine();
|
|
827
|
-
console.log(...args);
|
|
828
|
-
},
|
|
829
|
-
error: (...args) => {
|
|
830
|
-
clearActiveProgressLine();
|
|
831
|
-
console.error(...args);
|
|
832
|
-
}
|
|
833
|
-
};
|
|
834
|
-
}
|
|
835
|
-
const defaultRuntime = {
|
|
836
|
-
...createRuntimeIo(),
|
|
837
|
-
exit: (code) => {
|
|
838
|
-
restoreTerminalState("runtime exit", { resumeStdinIfPaused: false });
|
|
839
|
-
process.exit(code);
|
|
840
|
-
throw new Error("unreachable");
|
|
841
|
-
}
|
|
842
|
-
};
|
|
843
|
-
function createNonExitingRuntime() {
|
|
844
|
-
return {
|
|
845
|
-
...createRuntimeIo(),
|
|
846
|
-
exit: (code) => {
|
|
847
|
-
throw new Error(`exit ${code}`);
|
|
848
|
-
}
|
|
849
|
-
};
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
//#endregion
|
|
853
|
-
//#region src/terminal/ansi.ts
|
|
854
|
-
const ANSI_SGR_PATTERN = "\\x1b\\[[0-9;]*m";
|
|
855
|
-
const OSC8_PATTERN = "\\x1b\\]8;;.*?\\x1b\\\\|\\x1b\\]8;;\\x1b\\\\";
|
|
856
|
-
const ANSI_REGEX = new RegExp(ANSI_SGR_PATTERN, "g");
|
|
857
|
-
const OSC8_REGEX = new RegExp(OSC8_PATTERN, "g");
|
|
858
|
-
function stripAnsi(input) {
|
|
859
|
-
return input.replace(OSC8_REGEX, "").replace(ANSI_REGEX, "");
|
|
860
|
-
}
|
|
861
|
-
|
|
862
|
-
//#endregion
|
|
863
|
-
//#region src/logging/console.ts
|
|
864
|
-
const requireConfig = resolveNodeRequireFromMeta(import.meta.url);
|
|
865
|
-
const loadConfigFallbackDefault = () => {
|
|
866
|
-
try {
|
|
867
|
-
return (requireConfig?.("../config/config.js"))?.loadConfig?.().logging;
|
|
868
|
-
} catch {
|
|
869
|
-
return;
|
|
870
|
-
}
|
|
871
|
-
};
|
|
872
|
-
let loadConfigFallback = loadConfigFallbackDefault;
|
|
873
|
-
function normalizeConsoleLevel(level) {
|
|
874
|
-
if (isVerbose()) return "debug";
|
|
875
|
-
if (!level && process.env.VITEST === "true" && process.env.SQUIDCLAW_TEST_CONSOLE !== "1") return "silent";
|
|
876
|
-
return normalizeLogLevel(level, "info");
|
|
877
|
-
}
|
|
878
|
-
function normalizeConsoleStyle(style) {
|
|
879
|
-
if (style === "compact" || style === "json" || style === "pretty") return style;
|
|
880
|
-
if (!process.stdout.isTTY) return "compact";
|
|
881
|
-
return "pretty";
|
|
882
|
-
}
|
|
883
|
-
function resolveConsoleSettings() {
|
|
884
|
-
const envLevel = resolveEnvLogLevelOverride();
|
|
885
|
-
if (process.env.VITEST === "true" && process.env.SQUIDCLAW_TEST_CONSOLE !== "1" && !isVerbose() && !envLevel && !loggingState.overrideSettings) return {
|
|
886
|
-
level: "silent",
|
|
887
|
-
style: normalizeConsoleStyle(void 0)
|
|
888
|
-
};
|
|
889
|
-
let cfg = loggingState.overrideSettings ?? readLoggingConfig();
|
|
890
|
-
if (!cfg) if (loggingState.resolvingConsoleSettings) cfg = void 0;
|
|
891
|
-
else {
|
|
892
|
-
loggingState.resolvingConsoleSettings = true;
|
|
893
|
-
try {
|
|
894
|
-
cfg = loadConfigFallback();
|
|
895
|
-
} finally {
|
|
896
|
-
loggingState.resolvingConsoleSettings = false;
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
return {
|
|
900
|
-
level: envLevel ?? normalizeConsoleLevel(cfg?.consoleLevel),
|
|
901
|
-
style: normalizeConsoleStyle(cfg?.consoleStyle)
|
|
902
|
-
};
|
|
903
|
-
}
|
|
904
|
-
function consoleSettingsChanged(a, b) {
|
|
905
|
-
if (!a) return true;
|
|
906
|
-
return a.level !== b.level || a.style !== b.style;
|
|
907
|
-
}
|
|
908
|
-
function getConsoleSettings() {
|
|
909
|
-
const settings = resolveConsoleSettings();
|
|
910
|
-
const cached = loggingState.cachedConsoleSettings;
|
|
911
|
-
if (!cached || consoleSettingsChanged(cached, settings)) loggingState.cachedConsoleSettings = settings;
|
|
912
|
-
return loggingState.cachedConsoleSettings;
|
|
913
|
-
}
|
|
914
|
-
function shouldLogSubsystemToConsole(subsystem) {
|
|
915
|
-
const filter = loggingState.consoleSubsystemFilter;
|
|
916
|
-
if (!filter || filter.length === 0) return true;
|
|
917
|
-
return filter.some((prefix) => subsystem === prefix || subsystem.startsWith(`${prefix}/`));
|
|
918
|
-
}
|
|
919
|
-
function formatConsoleTimestamp(style) {
|
|
920
|
-
const now = /* @__PURE__ */ new Date();
|
|
921
|
-
if (style === "pretty") return `${String(now.getHours()).padStart(2, "0")}:${String(now.getMinutes()).padStart(2, "0")}:${String(now.getSeconds()).padStart(2, "0")}`;
|
|
922
|
-
return formatLocalIsoWithOffset(now);
|
|
923
|
-
}
|
|
924
|
-
|
|
925
|
-
//#endregion
|
|
926
|
-
//#region src/logging/subsystem.ts
|
|
927
|
-
function shouldLogToConsole(level, settings) {
|
|
928
|
-
if (settings.level === "silent") return false;
|
|
929
|
-
return levelToMinLevel(level) <= levelToMinLevel(settings.level);
|
|
930
|
-
}
|
|
931
|
-
const inspectValue = (() => {
|
|
932
|
-
const getBuiltinModule = process.getBuiltinModule;
|
|
933
|
-
if (typeof getBuiltinModule !== "function") return null;
|
|
934
|
-
try {
|
|
935
|
-
const utilNamespace = getBuiltinModule("util");
|
|
936
|
-
return typeof utilNamespace.inspect === "function" ? utilNamespace.inspect : null;
|
|
937
|
-
} catch {
|
|
938
|
-
return null;
|
|
939
|
-
}
|
|
940
|
-
})();
|
|
941
|
-
function isRichConsoleEnv() {
|
|
942
|
-
const term = (process.env.TERM ?? "").toLowerCase();
|
|
943
|
-
if (process.env.COLORTERM || process.env.TERM_PROGRAM) return true;
|
|
944
|
-
return term.length > 0 && term !== "dumb";
|
|
945
|
-
}
|
|
946
|
-
function getColorForConsole() {
|
|
947
|
-
const hasForceColor = typeof process.env.FORCE_COLOR === "string" && process.env.FORCE_COLOR.trim().length > 0 && process.env.FORCE_COLOR.trim() !== "0";
|
|
948
|
-
if (process.env.NO_COLOR && !hasForceColor) return new Chalk({ level: 0 });
|
|
949
|
-
return Boolean(process.stdout.isTTY || process.stderr.isTTY) || isRichConsoleEnv() ? new Chalk({ level: 1 }) : new Chalk({ level: 0 });
|
|
950
|
-
}
|
|
951
|
-
const SUBSYSTEM_COLORS = [
|
|
952
|
-
"cyan",
|
|
953
|
-
"green",
|
|
954
|
-
"yellow",
|
|
955
|
-
"blue",
|
|
956
|
-
"magenta",
|
|
957
|
-
"red"
|
|
958
|
-
];
|
|
959
|
-
const SUBSYSTEM_COLOR_OVERRIDES = { "gmail-watcher": "blue" };
|
|
960
|
-
const SUBSYSTEM_PREFIXES_TO_DROP = [
|
|
961
|
-
"gateway",
|
|
962
|
-
"channels",
|
|
963
|
-
"providers"
|
|
964
|
-
];
|
|
965
|
-
const SUBSYSTEM_MAX_SEGMENTS = 2;
|
|
966
|
-
const CHANNEL_SUBSYSTEM_PREFIXES = new Set([
|
|
967
|
-
"telegram",
|
|
968
|
-
"whatsapp",
|
|
969
|
-
"discord",
|
|
970
|
-
"irc",
|
|
971
|
-
"googlechat",
|
|
972
|
-
"slack",
|
|
973
|
-
"signal",
|
|
974
|
-
"imessage"
|
|
975
|
-
]);
|
|
976
|
-
function pickSubsystemColor(color, subsystem) {
|
|
977
|
-
const override = SUBSYSTEM_COLOR_OVERRIDES[subsystem];
|
|
978
|
-
if (override) return color[override];
|
|
979
|
-
let hash = 0;
|
|
980
|
-
for (let i = 0; i < subsystem.length; i += 1) hash = hash * 31 + subsystem.charCodeAt(i) | 0;
|
|
981
|
-
return color[SUBSYSTEM_COLORS[Math.abs(hash) % SUBSYSTEM_COLORS.length]];
|
|
982
|
-
}
|
|
983
|
-
function formatSubsystemForConsole(subsystem) {
|
|
984
|
-
const parts = subsystem.split("/").filter(Boolean);
|
|
985
|
-
const original = parts.join("/") || subsystem;
|
|
986
|
-
while (parts.length > 0 && SUBSYSTEM_PREFIXES_TO_DROP.includes(parts[0])) parts.shift();
|
|
987
|
-
if (parts.length === 0) return original;
|
|
988
|
-
if (CHANNEL_SUBSYSTEM_PREFIXES.has(parts[0])) return parts[0];
|
|
989
|
-
if (parts.length > SUBSYSTEM_MAX_SEGMENTS) return parts.slice(-SUBSYSTEM_MAX_SEGMENTS).join("/");
|
|
990
|
-
return parts.join("/");
|
|
991
|
-
}
|
|
992
|
-
function stripRedundantSubsystemPrefixForConsole(message, displaySubsystem) {
|
|
993
|
-
if (!displaySubsystem) return message;
|
|
994
|
-
if (message.startsWith("[")) {
|
|
995
|
-
const closeIdx = message.indexOf("]");
|
|
996
|
-
if (closeIdx > 1) {
|
|
997
|
-
if (message.slice(1, closeIdx).toLowerCase() === displaySubsystem.toLowerCase()) {
|
|
998
|
-
let i = closeIdx + 1;
|
|
999
|
-
while (message[i] === " ") i += 1;
|
|
1000
|
-
return message.slice(i);
|
|
1001
|
-
}
|
|
1002
|
-
}
|
|
1003
|
-
}
|
|
1004
|
-
if (message.slice(0, displaySubsystem.length).toLowerCase() !== displaySubsystem.toLowerCase()) return message;
|
|
1005
|
-
const next = message.slice(displaySubsystem.length, displaySubsystem.length + 1);
|
|
1006
|
-
if (next !== ":" && next !== " ") return message;
|
|
1007
|
-
let i = displaySubsystem.length;
|
|
1008
|
-
while (message[i] === " ") i += 1;
|
|
1009
|
-
if (message[i] === ":") i += 1;
|
|
1010
|
-
while (message[i] === " ") i += 1;
|
|
1011
|
-
return message.slice(i);
|
|
1012
|
-
}
|
|
1013
|
-
function formatConsoleLine(opts) {
|
|
1014
|
-
const displaySubsystem = opts.style === "json" ? opts.subsystem : formatSubsystemForConsole(opts.subsystem);
|
|
1015
|
-
if (opts.style === "json") return JSON.stringify({
|
|
1016
|
-
time: formatConsoleTimestamp("json"),
|
|
1017
|
-
level: opts.level,
|
|
1018
|
-
subsystem: displaySubsystem,
|
|
1019
|
-
message: opts.message,
|
|
1020
|
-
...opts.meta
|
|
1021
|
-
});
|
|
1022
|
-
const color = getColorForConsole();
|
|
1023
|
-
const prefix = `[${displaySubsystem}]`;
|
|
1024
|
-
const prefixColor = pickSubsystemColor(color, displaySubsystem);
|
|
1025
|
-
const levelColor = opts.level === "error" || opts.level === "fatal" ? color.red : opts.level === "warn" ? color.yellow : opts.level === "debug" || opts.level === "trace" ? color.gray : color.cyan;
|
|
1026
|
-
const displayMessage = stripRedundantSubsystemPrefixForConsole(opts.message, displaySubsystem);
|
|
1027
|
-
return `${[(() => {
|
|
1028
|
-
if (opts.style === "pretty") return color.gray(formatConsoleTimestamp("pretty"));
|
|
1029
|
-
if (loggingState.consoleTimestampPrefix) return color.gray(formatConsoleTimestamp(opts.style));
|
|
1030
|
-
return "";
|
|
1031
|
-
})(), prefixColor(prefix)].filter(Boolean).join(" ")} ${levelColor(displayMessage)}`;
|
|
1032
|
-
}
|
|
1033
|
-
function writeConsoleLine(level, line) {
|
|
1034
|
-
clearActiveProgressLine();
|
|
1035
|
-
const sanitized = process.platform === "win32" && process.env.GITHUB_ACTIONS === "true" ? line.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, "?").replace(/[\uD800-\uDFFF]/g, "?") : line;
|
|
1036
|
-
const sink = loggingState.rawConsole ?? console;
|
|
1037
|
-
if (loggingState.forceConsoleToStderr || level === "error" || level === "fatal") (sink.error ?? console.error)(sanitized);
|
|
1038
|
-
else if (level === "warn") (sink.warn ?? console.warn)(sanitized);
|
|
1039
|
-
else (sink.log ?? console.log)(sanitized);
|
|
1040
|
-
}
|
|
1041
|
-
function logToFile(fileLogger, level, message, meta) {
|
|
1042
|
-
if (level === "silent") return;
|
|
1043
|
-
const method = fileLogger[level];
|
|
1044
|
-
if (typeof method !== "function") return;
|
|
1045
|
-
if (meta && Object.keys(meta).length > 0) method.call(fileLogger, meta, message);
|
|
1046
|
-
else method.call(fileLogger, message);
|
|
1047
|
-
}
|
|
1048
|
-
function createSubsystemLogger(subsystem) {
|
|
1049
|
-
let fileLogger = null;
|
|
1050
|
-
const getFileLogger = () => {
|
|
1051
|
-
if (!fileLogger) fileLogger = getChildLogger({ subsystem });
|
|
1052
|
-
return fileLogger;
|
|
1053
|
-
};
|
|
1054
|
-
const emit = (level, message, meta) => {
|
|
1055
|
-
const consoleSettings = getConsoleSettings();
|
|
1056
|
-
const consoleEnabled = shouldLogToConsole(level, { level: consoleSettings.level }) && shouldLogSubsystemToConsole(subsystem);
|
|
1057
|
-
const fileEnabled = isFileLogLevelEnabled(level);
|
|
1058
|
-
if (!consoleEnabled && !fileEnabled) return;
|
|
1059
|
-
let consoleMessageOverride;
|
|
1060
|
-
let fileMeta = meta;
|
|
1061
|
-
if (meta && Object.keys(meta).length > 0) {
|
|
1062
|
-
const { consoleMessage, ...rest } = meta;
|
|
1063
|
-
if (typeof consoleMessage === "string") consoleMessageOverride = consoleMessage;
|
|
1064
|
-
fileMeta = Object.keys(rest).length > 0 ? rest : void 0;
|
|
1065
|
-
}
|
|
1066
|
-
if (fileEnabled) logToFile(getFileLogger(), level, message, fileMeta);
|
|
1067
|
-
if (!consoleEnabled) return;
|
|
1068
|
-
const consoleMessage = consoleMessageOverride ?? message;
|
|
1069
|
-
if (!isVerbose() && subsystem === "agent/embedded" && /(sessionId|runId)=probe-/.test(consoleMessage)) return;
|
|
1070
|
-
writeConsoleLine(level, formatConsoleLine({
|
|
1071
|
-
level,
|
|
1072
|
-
subsystem,
|
|
1073
|
-
message: consoleSettings.style === "json" ? message : consoleMessage,
|
|
1074
|
-
style: consoleSettings.style,
|
|
1075
|
-
meta: fileMeta
|
|
1076
|
-
}));
|
|
1077
|
-
};
|
|
1078
|
-
const isConsoleEnabled = (level) => {
|
|
1079
|
-
return shouldLogToConsole(level, { level: getConsoleSettings().level }) && shouldLogSubsystemToConsole(subsystem);
|
|
1080
|
-
};
|
|
1081
|
-
const isFileEnabled = (level) => isFileLogLevelEnabled(level);
|
|
1082
|
-
return {
|
|
1083
|
-
subsystem,
|
|
1084
|
-
isEnabled: (level, target = "any") => {
|
|
1085
|
-
if (target === "console") return isConsoleEnabled(level);
|
|
1086
|
-
if (target === "file") return isFileEnabled(level);
|
|
1087
|
-
return isConsoleEnabled(level) || isFileEnabled(level);
|
|
1088
|
-
},
|
|
1089
|
-
trace: (message, meta) => emit("trace", message, meta),
|
|
1090
|
-
debug: (message, meta) => emit("debug", message, meta),
|
|
1091
|
-
info: (message, meta) => emit("info", message, meta),
|
|
1092
|
-
warn: (message, meta) => emit("warn", message, meta),
|
|
1093
|
-
error: (message, meta) => emit("error", message, meta),
|
|
1094
|
-
fatal: (message, meta) => emit("fatal", message, meta),
|
|
1095
|
-
raw: (message) => {
|
|
1096
|
-
if (isFileEnabled("info")) logToFile(getFileLogger(), "info", message, { raw: true });
|
|
1097
|
-
if (isConsoleEnabled("info")) {
|
|
1098
|
-
if (!isVerbose() && subsystem === "agent/embedded" && /(sessionId|runId)=probe-/.test(message)) return;
|
|
1099
|
-
writeConsoleLine("info", message);
|
|
1100
|
-
}
|
|
1101
|
-
},
|
|
1102
|
-
child: (name) => createSubsystemLogger(`${subsystem}/${name}`)
|
|
1103
|
-
};
|
|
1104
|
-
}
|
|
1105
|
-
|
|
1106
|
-
//#endregion
|
|
1107
|
-
//#region src/logger.ts
|
|
1108
|
-
const subsystemPrefixRe = /^([a-z][a-z0-9-]{1,20}):\s+(.*)$/i;
|
|
1109
|
-
function splitSubsystem(message) {
|
|
1110
|
-
const match = message.match(subsystemPrefixRe);
|
|
1111
|
-
if (!match) return null;
|
|
1112
|
-
const [, subsystem, rest] = match;
|
|
1113
|
-
return {
|
|
1114
|
-
subsystem,
|
|
1115
|
-
rest
|
|
1116
|
-
};
|
|
1117
|
-
}
|
|
1118
|
-
function logWithSubsystem(params) {
|
|
1119
|
-
const parsed = params.runtime === defaultRuntime ? splitSubsystem(params.message) : null;
|
|
1120
|
-
if (parsed) {
|
|
1121
|
-
createSubsystemLogger(parsed.subsystem)[params.subsystemMethod](parsed.rest);
|
|
1122
|
-
return;
|
|
1123
|
-
}
|
|
1124
|
-
params.runtime[params.runtimeMethod](params.runtimeFormatter(params.message));
|
|
1125
|
-
getLogger()[params.loggerMethod](params.message);
|
|
1126
|
-
}
|
|
1127
|
-
function logInfo(message, runtime = defaultRuntime) {
|
|
1128
|
-
logWithSubsystem({
|
|
1129
|
-
message,
|
|
1130
|
-
runtime,
|
|
1131
|
-
runtimeMethod: "log",
|
|
1132
|
-
runtimeFormatter: info,
|
|
1133
|
-
loggerMethod: "info",
|
|
1134
|
-
subsystemMethod: "info"
|
|
1135
|
-
});
|
|
1136
|
-
}
|
|
1137
|
-
function logWarn(message, runtime = defaultRuntime) {
|
|
1138
|
-
logWithSubsystem({
|
|
1139
|
-
message,
|
|
1140
|
-
runtime,
|
|
1141
|
-
runtimeMethod: "log",
|
|
1142
|
-
runtimeFormatter: warn,
|
|
1143
|
-
loggerMethod: "warn",
|
|
1144
|
-
subsystemMethod: "warn"
|
|
1145
|
-
});
|
|
1146
|
-
}
|
|
1147
|
-
function logError(message, runtime = defaultRuntime) {
|
|
1148
|
-
logWithSubsystem({
|
|
1149
|
-
message,
|
|
1150
|
-
runtime,
|
|
1151
|
-
runtimeMethod: "error",
|
|
1152
|
-
runtimeFormatter: danger,
|
|
1153
|
-
loggerMethod: "error",
|
|
1154
|
-
subsystemMethod: "error"
|
|
1155
|
-
});
|
|
1156
|
-
}
|
|
1157
|
-
function logDebug(message) {
|
|
1158
|
-
getLogger().debug(message);
|
|
1159
|
-
logVerboseConsole(message);
|
|
1160
|
-
}
|
|
1161
|
-
|
|
1162
|
-
//#endregion
|
|
1163
|
-
export { sleep as A, success as B, pathExists as C, safeParseJson as D, resolveUserPath as E, danger as F, getChildLogger as G, colorize as H, info as I, resolveNodeRequireFromMeta as J, registerLogTransport as K, logVerbose as L, toWhatsappJid as M, truncateUtf16Safe as N, shortenHomeInString as O, isPlainObject as P, consumeRootOptionToken as Q, setVerbose as R, normalizeE164 as S, resolveJidToE164 as T, isRich as U, warn as V, theme as W, resolvePreferredSquidClawTmpDir as X, normalizeLogLevel as Y, FLAG_TERMINATOR as Z, escapeRegExp as _, createSubsystemLogger as a, isSelfChatMode as b, defaultRuntime as c, unregisterActiveProgressLine as d, CONFIG_DIR as f, ensureDir as g, clampNumber as h, logWarn as i, sliceUtf16Safe as j, shortenHomePath as k, clearActiveProgressLine as l, clampInt as m, logError as n, stripAnsi as o, clamp as p, toPinoLikeLogger as q, logInfo as r, createNonExitingRuntime as s, logDebug as t, registerActiveProgressLine as u, formatTerminalLink as v, resolveConfigDir as w, jidToE164 as x, isRecord as y, shouldLogVerbose as z };
|