@noxsoft/anima 2.0.2 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1260 -28
- package/dist/accounts-Bth3PpPD.js +260 -0
- package/dist/accounts-D8CPKNkN.js +259 -0
- package/dist/acp-cli-ByK6lS6c.js +1081 -0
- package/dist/acp-cli-CaQCjIw4.js +1084 -0
- package/dist/agent-BgIkqd3F.js +725 -0
- package/dist/agent-N5BDcge4.js +725 -0
- package/dist/agent-events-COH7NDW2.js +182 -0
- package/dist/agent-scope-CPphqq-U.js +452 -0
- package/dist/agent-scope-DZgptr9J.js +452 -0
- package/dist/agent-scope-cj2QCT6R.js +112 -0
- package/dist/agents-NEudYMdg.js +774 -0
- package/dist/agents.config-Bujs-NIy.js +182 -0
- package/dist/agents.config-jp7OLssr.js +182 -0
- package/dist/argv-BMZMiW7v.js +73 -0
- package/dist/audit-C-UJhfdv.js +2401 -0
- package/dist/audit-CeCO7SK5.js +2401 -0
- package/dist/auth-BNZsOHGF.js +648 -0
- package/dist/auth-DMPZWzEa.js +639 -0
- package/dist/auth-choice-5VnaGMD-.js +2681 -0
- package/dist/auth-choice-DA2k4vs8.js +2681 -0
- package/dist/auth-health-B7FqA26_.js +149 -0
- package/dist/auth-health-VO_MPqVX.js +149 -0
- package/dist/auth-profiles-BDrNYX_n.js +1564 -0
- package/dist/auth-profiles-CxSHydjn.js +2689 -0
- package/dist/banner-BtDZPRzi.js +294 -0
- package/dist/browser-cli-8yQMpxb8.js +1679 -0
- package/dist/browser-cli-Czg3JtDH.js +1676 -0
- package/dist/build-info.json +3 -3
- package/dist/bundled/boot-md/handler.js +16 -16
- package/dist/bundled/bootstrap-extra-files/handler.js +4 -4
- package/dist/bundled/command-logger/handler.js +1 -1
- package/dist/bundled/session-memory/handler.js +5 -5
- package/dist/call-BIzCaKZb.js +282 -0
- package/dist/call-BYDpTVCZ.js +282 -0
- package/dist/canvas-host/a2ui/.bundle.hash +1 -1
- package/dist/catalog-CqKiUgu6.js +185 -0
- package/dist/catalog-DMfEg-oK.js +185 -0
- package/dist/channel-options-BrtCtyrT.js +32 -0
- package/dist/channel-options-CO21Gl8p.js +33 -0
- package/dist/channel-selection-Bbm1lq3P.js +51 -0
- package/dist/channel-selection-CqcX7Ocw.js +51 -0
- package/dist/channel-web-DrsT6OAE.js +2162 -0
- package/dist/channels-cli-Juyh1S6n.js +1304 -0
- package/dist/channels-cli-zNvi1m5c.js +1306 -0
- package/dist/channels-status-issues-CqzqshW4.js +18 -0
- package/dist/channels-status-issues-DdJdO866.js +18 -0
- package/dist/chrome-C4dOMO8z.js +1601 -0
- package/dist/chrome-DdcDzAtH.js +1629 -0
- package/dist/chrome-U3DRzjJD.js +1601 -0
- package/dist/chunk-D2nLsrEW.js +348 -0
- package/dist/clack-prompter-BI3RDW5w.js +92 -0
- package/dist/clack-prompter-Dwr1m_IZ.js +92 -0
- package/dist/cli/daemon-cli.js +1 -1
- package/dist/cli-C3cpDaz8.js +99 -0
- package/dist/cli-CjWUGdGC.js +101 -0
- package/dist/cli-session-BVjY_XrW.js +5463 -0
- package/dist/cli-session-gtuYN2Iq.js +5408 -0
- package/dist/client-Dswwze5_.js +1692 -0
- package/dist/client-LRKFjo4A.js +1692 -0
- package/dist/clipboard-BZKS9O1u.js +31 -0
- package/dist/clipboard-DES8b1AM.js +31 -0
- package/dist/command-format-CP1YTNCl.js +52 -0
- package/dist/command-format-CVL4K5cj.js +52 -0
- package/dist/command-format-G6N2zghg.js +38 -0
- package/dist/command-registry-BBvNvysr.js +248 -0
- package/dist/commands-AZ3n8Y2c.js +726 -0
- package/dist/commands-BMnD_QRY.js +726 -0
- package/dist/commands-registry-cFqZ6Ib4.js +766 -0
- package/dist/commands-registry-q13H7ng5.js +766 -0
- package/dist/common-CX5458fH.js +287 -0
- package/dist/common-DJbnT8ws.js +287 -0
- package/dist/completion-cli-BADRBcIl.js +432 -0
- package/dist/completion-cli-DMQgiObF.js +431 -0
- package/dist/config-CU-Axg8P.js +5704 -0
- package/dist/config-DaqbUdkI.js +5705 -0
- package/dist/config-cli-BPlbwiuA.js +244 -0
- package/dist/config-cli-DXgZJkPU.js +247 -0
- package/dist/config-guard-Ba49JNds.js +76 -0
- package/dist/config-guard-Cu0qMKZJ.js +93 -0
- package/dist/config-kVVm5EYV.js +6523 -0
- package/dist/config-sync-CzLnLTXt.js +91 -0
- package/dist/config-sync-DuydxPWx.js +91 -0
- package/dist/configure-CHgacLyi.js +960 -0
- package/dist/configure-DfHXDa1L.js +959 -0
- package/dist/context-DzgXOckU.js +60 -0
- package/dist/control-service-8_wKHwBa.js +72 -0
- package/dist/control-service-BtL1Jto_.js +72 -0
- package/dist/cron-cli-BCzSR2c0.js +448 -0
- package/dist/cron-cli-CCWNkykU.js +451 -0
- package/dist/daemon-cli-Bjkbu9Vy.js +565 -0
- package/dist/daemon-cli-CmlHcC1J.js +566 -0
- package/dist/daemon-cli.js +16 -16
- package/dist/daemon-runtime-C0tz7VAC.js +460 -0
- package/dist/daemon-runtime-rUTqCVwJ.js +460 -0
- package/dist/deliver-BBggsviM.js +1097 -0
- package/dist/deliver-CePITOl8.js +1162 -0
- package/dist/deliver-DFnVaetP.js +1097 -0
- package/dist/delivery-queue-BJQK3oh5.js +220 -0
- package/dist/deps-CeEKhrp7.js +42 -0
- package/dist/devices-cli-DQrDMrZH.js +198 -0
- package/dist/devices-cli-Oe-A1Dv0.js +195 -0
- package/dist/diagnostics-DxMFrBLO.js +35 -0
- package/dist/diagnostics-m79ZlMmZ.js +35 -0
- package/dist/directory-cli-BL6h8cGF.js +246 -0
- package/dist/directory-cli-Cjgmi_sj.js +243 -0
- package/dist/dispatcher-DAFbQM-c.js +100 -0
- package/dist/dispatcher-DNd40gUn.js +100 -0
- package/dist/dist-CqDI82ei.js +929 -0
- package/dist/dist-DnHRxR5U.js +929 -0
- package/dist/dns-cli-CFtV3BXK.js +200 -0
- package/dist/dns-cli-NyIHvQ5S.js +197 -0
- package/dist/dock-BdXLb5oY.js +753 -0
- package/dist/dock-jYICmNcI.js +753 -0
- package/dist/docs-cli-CrOaIK_H.js +161 -0
- package/dist/docs-cli-D_cmJDSr.js +159 -0
- package/dist/doctor-BpGxKrBl.js +1815 -0
- package/dist/doctor-D12wNQPU.js +1813 -0
- package/dist/doctor-completion-DeOfofek.js +92 -0
- package/dist/doctor-completion-DwjqdEcK.js +92 -0
- package/dist/doctor-config-flow-BI3mpkbd.js +1232 -0
- package/dist/doctor-config-flow-wMHheFkC.js +1232 -0
- package/dist/engine-BCtL-AMw.js +563 -0
- package/dist/engine-Bk_UT413.js +563 -0
- package/dist/entry.js +5 -5
- package/dist/env-v6411I8h.js +32 -0
- package/dist/exec-B7sUS164.js +1167 -0
- package/dist/exec-approvals-CroGJRUg.js +1221 -0
- package/dist/exec-approvals-cli-BTxF_RsH.js +371 -0
- package/dist/exec-approvals-cli-n1gyGwH2.js +368 -0
- package/dist/exec-mhSykkaa.js +255 -0
- package/dist/extensionAPI.js +3 -3
- package/dist/frontmatter-BmHq0vRD.js +204 -0
- package/dist/gateway-cli-DDBadlrS.js +19971 -0
- package/dist/gateway-cli-IZNkOMBe.js +19972 -0
- package/dist/gateway-rpc-Dtx8HN-n.js +28 -0
- package/dist/gateway-rpc-L2PVSqGj.js +28 -0
- package/dist/github-copilot-auth-DKyqDaGU.js +1418 -0
- package/dist/github-copilot-auth-DXpOMSd3.js +1418 -0
- package/dist/gmail-setup-utils-BKNczIJ9.js +428 -0
- package/dist/gmail-setup-utils-co0ppccC.js +428 -0
- package/dist/health-Bm8ZTvC3.js +1253 -0
- package/dist/health-DUf1gt4E.js +1258 -0
- package/dist/health-format-BksT6F68.js +208 -0
- package/dist/health-format-uzh1xYLD.js +208 -0
- package/dist/heartbeat-visibility-1TJb1Zao.js +98 -0
- package/dist/heartbeat-visibility-CwodtdcX.js +98 -0
- package/dist/help-format-C6cv_aZp.js +17 -0
- package/dist/helpers-N-uSFKOn.js +10 -0
- package/dist/hooks-cli-1POsXqOl.js +993 -0
- package/dist/hooks-cli-BGjILbze.js +991 -0
- package/dist/hooks-status-DE07n5RC.js +356 -0
- package/dist/hooks-status-Du-d1jde.js +356 -0
- package/dist/image-ops-B_AYV3tp.js +541 -0
- package/dist/image-ops-Bp0C6Mvr.js +541 -0
- package/dist/index.js +82 -82
- package/dist/init-9A0s7bWG.js +122 -0
- package/dist/init-DoyCHJDC.js +122 -0
- package/dist/installs-D1C9wHAq.js +383 -0
- package/dist/installs-Dh4dHayM.js +383 -0
- package/dist/ipv4-DCItfaJo.js +1964 -0
- package/dist/ipv4-DSOUVx0i.js +1964 -0
- package/dist/lanes-BvSnHq2h.js +232 -0
- package/dist/lifecycle-core-BY4WIf9g.js +388 -0
- package/dist/lifecycle-core-TQKyXO-6.js +387 -0
- package/dist/links-CNu_8RZl.js +15 -0
- package/dist/links-D2tt2ouh.js +15 -0
- package/dist/llm-slug-generator.js +4 -4
- package/dist/logging-BIeRw0WR.js +15 -0
- package/dist/logging-C7lb3Vjc.js +15 -0
- package/dist/login-DXWKewA2.js +59 -0
- package/dist/login-Fhh4uWmf.js +61 -0
- package/dist/login-pPs3UO38.js +61 -0
- package/dist/login-qr-CevLD8cV.js +326 -0
- package/dist/login-qr-GF2JMIy-.js +323 -0
- package/dist/login-qr-ZYYKD6Yt.js +321 -0
- package/dist/logs-cli-CzXbX8HZ.js +242 -0
- package/dist/logs-cli-D9ngH9PF.js +245 -0
- package/dist/manager-BD5rA3w0.js +3244 -0
- package/dist/manager-BDPgBQSH.js +3246 -0
- package/dist/manager-DRWMWM--.js +3244 -0
- package/dist/manifest-registry-DbvPaBXY.js +748 -0
- package/dist/manifest-registry-kHX_MFa1.js +748 -0
- package/dist/markdown-tables-CqwihY2m.js +347 -0
- package/dist/markdown-tables-DJV7eAJZ.js +348 -0
- package/dist/media-lUqN-0O9.js +1342 -0
- package/dist/memory-cli-BLXSpgnN.js +868 -0
- package/dist/memory-cli-BcGVkkRJ.js +869 -0
- package/dist/message-channel-D_jIO87f.js +110 -0
- package/dist/migrate-BpVOar4L.js +157 -0
- package/dist/migrate-CkgGDkWy.js +157 -0
- package/dist/model-selection-Cqt6aJ0G.js +2691 -0
- package/dist/models-CExsNQPH.js +2510 -0
- package/dist/models-cli-Ba3Jmwev.js +2739 -0
- package/dist/models-cli-iDAlsbL2.js +258 -0
- package/dist/net-0A_zcaQD.js +218 -0
- package/dist/node-cli-ATmwCXIk.js +1319 -0
- package/dist/node-cli-DYFR_V25.js +1322 -0
- package/dist/node-service-CN4LqR1A.js +67 -0
- package/dist/node-service-CWt3MdSC.js +67 -0
- package/dist/nodes-cli-BeVmhTz3.js +1197 -0
- package/dist/nodes-cli-QeJIfa18.js +1200 -0
- package/dist/nodes-screen-DHyWAlla.js +234 -0
- package/dist/nodes-screen-qs3jRBPk.js +234 -0
- package/dist/note-CSlg2BnB.js +73 -0
- package/dist/note-Ctvglhp1.js +73 -0
- package/dist/npm-registry-spec-DQd4M22q.js +351 -0
- package/dist/npm-registry-spec-PxisIMts.js +351 -0
- package/dist/onboard-DeruD10m.js +1166 -0
- package/dist/onboard-SAcu5N6N.js +1165 -0
- package/dist/onboard-channels-C4iSfFXR.js +672 -0
- package/dist/onboard-channels-oVTVgoyg.js +672 -0
- package/dist/onboard-helpers-B8roRwLP.js +365 -0
- package/dist/onboard-helpers-Dgh26hgP.js +365 -0
- package/dist/onboarding-Bi-ac8we.js +911 -0
- package/dist/onboarding-C2gjB2u8.js +910 -0
- package/dist/orchestrator-DlbAYMQP.js +357 -0
- package/dist/orchestrator-DlwVRVDA.js +357 -0
- package/dist/outbound-CkKgc6iR.js +2062 -0
- package/dist/outbound-Vfm5yDh3.js +214 -0
- package/dist/outbound-bs_VK51X.js +214 -0
- package/dist/outbound-send-deps-DDjiMfEL.js +55 -0
- package/dist/pairing-cli-CJYeuEik.js +118 -0
- package/dist/pairing-cli-mqopHI8s.js +121 -0
- package/dist/pairing-store-BsXzUDPv.js +388 -0
- package/dist/pairing-store-DoNj00-X.js +388 -0
- package/dist/path-env-C_xpiG8l.js +89 -0
- package/dist/path-env-DSSMHu5A.js +89 -0
- package/dist/paths-B1vRVCad.js +126 -0
- package/dist/paths-BMuHNFxg.js +238 -0
- package/dist/paths-BXQQzXGQ.js +129 -0
- package/dist/paths-Buw_geoe.js +54 -0
- package/dist/paths-DA9WYabg.js +222 -0
- package/dist/paths-DfQGx0_k.js +129 -0
- package/dist/pi-auth-json-DOPW3e4X.js +78 -0
- package/dist/pi-auth-json-MruLmI_X.js +82 -0
- package/dist/pi-auth-json-lae_wwwo.js +80 -0
- package/dist/pi-model-discovery-7q0GxMrp.js +3 -0
- package/dist/pi-tools.policy-Csmla32P.js +200 -0
- package/dist/pi-tools.policy-xYdDLEv9.js +200 -0
- package/dist/plugin-auto-enable-CViVVWgg.js +282 -0
- package/dist/plugin-auto-enable-CjZ238UI.js +282 -0
- package/dist/plugin-registry-B4Aw2hzq.js +32 -0
- package/dist/plugin-registry-DW81arxW.js +32 -0
- package/dist/plugin-sdk/cli/cli-name.d.ts +1 -1
- package/dist/plugin-sdk/config/paths.d.ts +2 -2
- package/dist/plugin-sdk/index.js +7 -7
- package/dist/plugins-DhcGAPDB.js +38 -0
- package/dist/plugins-DtghNRtM.js +168 -0
- package/dist/plugins-cli-4vWTmOAb.js +736 -0
- package/dist/plugins-cli-CdTMbP0X.js +734 -0
- package/dist/polls-D6eCdatA.js +1343 -0
- package/dist/ports-BtZx-JKD.js +96 -0
- package/dist/ports-C8bKN8s0.js +96 -0
- package/dist/ports-DHiKnPRX.js +344 -0
- package/dist/ports-vd93M_Pt.js +317 -0
- package/dist/program-CX3aUVeb.js +176 -0
- package/dist/program-context-BPos0ivo.js +496 -0
- package/dist/progress-oiAjiiNi.js +133 -0
- package/dist/prompt-style-Cm4wOtKm.js +9 -0
- package/dist/pw-ai-4QbK5YFe.js +1865 -0
- package/dist/pw-ai-BWz3Cxt7.js +1868 -0
- package/dist/pw-ai-C83HBue2.js +1867 -0
- package/dist/qmd-manager-BcMeZiGD.js +938 -0
- package/dist/qmd-manager-CPypGJ0P.js +935 -0
- package/dist/qmd-manager-CRrSkfia.js +937 -0
- package/dist/register.agent-DDY8KJhn.js +265 -0
- package/dist/register.agent-DKawm-9d.js +1003 -0
- package/dist/register.anima-CEWUo29k.js +193 -0
- package/dist/register.anima-DBWz2rk_.js +193 -0
- package/dist/register.configure-BX67qV8k.js +103 -0
- package/dist/register.configure-CWsySuiq.js +101 -0
- package/dist/register.maintenance-0k-ZNhDg.js +543 -0
- package/dist/register.maintenance-BIwx1fzX.js +543 -0
- package/dist/register.message-CXPsoakA.js +657 -0
- package/dist/register.message-DA3jvfgI.js +660 -0
- package/dist/register.onboard-C4HG7Hqv.js +170 -0
- package/dist/register.onboard-GOpdif-j.js +170 -0
- package/dist/register.setup-B17vZT7C.js +175 -0
- package/dist/register.setup-GJyUDCqh.js +175 -0
- package/dist/register.status-health-sessions-D5876dGx.js +313 -0
- package/dist/register.status-health-sessions-lOewVIZR.js +142 -0
- package/dist/register.subclis-Dwnujj5C.js +255 -0
- package/dist/reply-CR5T_oQJ.js +32212 -0
- package/dist/reply-prefix-BcrS4Umd.js +100 -0
- package/dist/reply-prefix-Btb5o2NH.js +100 -0
- package/dist/reply-r089HuRA.js +32212 -0
- package/dist/routes-B4czFzIb.js +1820 -0
- package/dist/routes-ucJWAk5O.js +1820 -0
- package/dist/rpc-BnKxnQ0v.js +70 -0
- package/dist/rpc-DgE-xnyx.js +70 -0
- package/dist/run-main-B74kv84C.js +371 -0
- package/dist/runtime-guard-CKFdts2L.js +60 -0
- package/dist/sandbox-CJTS3er6.js +858 -0
- package/dist/sandbox-DBSiVHt_.js +859 -0
- package/dist/sandbox-cli-CrkjyU5M.js +461 -0
- package/dist/sandbox-cli-D1r5y6Sz.js +458 -0
- package/dist/security-cli-BZUdnkhn.js +462 -0
- package/dist/security-cli-DS09ebvA.js +465 -0
- package/dist/server-context-C0xZbYhg.js +824 -0
- package/dist/server-context-DVh2z7om.js +824 -0
- package/dist/server-node-events-bu9lpkMH.js +233 -0
- package/dist/server-node-events-i1Rrww31.js +231 -0
- package/dist/service-CJJwLEor.js +642 -0
- package/dist/service-DxLxBhaU.js +642 -0
- package/dist/service-audit-DB4Y3Ekp.js +488 -0
- package/dist/service-audit-M8y4TXVb.js +488 -0
- package/dist/session-CGxOLFs2.js +179 -0
- package/dist/session-DTTbdKb0.js +181 -0
- package/dist/session-cost-usage-FcdJl9c3.js +600 -0
- package/dist/session-cost-usage-qdfsGU2a.js +600 -0
- package/dist/session-yOhWcsD2.js +181 -0
- package/dist/sessions-B-Cu7JZq.js +1296 -0
- package/dist/sessions-BgLN4KFr.js +180 -0
- package/dist/sessions-CnRjwdVr.js +1296 -0
- package/dist/sessions-wRKla1Qh.js +2038 -0
- package/dist/shared-DS3UaJSP.js +66 -0
- package/dist/shared-DxNHzky3.js +77 -0
- package/dist/shared-Qpt4hUDi.js +66 -0
- package/dist/shared-kzrojZ1B.js +77 -0
- package/dist/skill-scanner-DLJji5Ye.js +263 -0
- package/dist/skills-BWFIEp4j.js +807 -0
- package/dist/skills-DV4zKdCx.js +808 -0
- package/dist/skills-cli-BY53ILm2.js +289 -0
- package/dist/skills-cli-CO3gxl8A.js +286 -0
- package/dist/skills-status-DX5pcqY3.js +166 -0
- package/dist/skills-status-zhcKzGkp.js +166 -0
- package/dist/sqlite-B6MojU1I.js +321 -0
- package/dist/sqlite-CuprTGR7.js +453 -0
- package/dist/sqlite-dzD-jMjs.js +368 -0
- package/dist/start-Cu3aLoSf.js +297 -0
- package/dist/start-Dz7tMAl8.js +296 -0
- package/dist/status-CaSxhxfV.js +2132 -0
- package/dist/status-D2C0JCX3.js +2137 -0
- package/dist/status-DlFMsQzh.js +27 -0
- package/dist/status-G0CITnKR.js +27 -0
- package/dist/status.update-CHjhVxJY.js +79 -0
- package/dist/status.update-DVFelehi.js +79 -0
- package/dist/subagent-registry-3Xb4el-8.js +14 -0
- package/dist/subagent-registry-CdSjz14I.js +2760 -0
- package/dist/subagent-registry-DNDhbHWi.js +2759 -0
- package/dist/subsystem-DfKstnEK.js +860 -0
- package/dist/system-cli-B5mt0FWa.js +82 -0
- package/dist/system-cli-Dg3UQ3Zz.js +79 -0
- package/dist/systemd-B43AvOGx.js +452 -0
- package/dist/systemd-RpPE0XGg.js +452 -0
- package/dist/systemd-hints-DMJT-Bbc.js +36 -0
- package/dist/systemd-hints-vRInKcz9.js +36 -0
- package/dist/systemd-linger-Dzyxqsod.js +75 -0
- package/dist/systemd-linger-EujbmI5A.js +75 -0
- package/dist/table-DhXHfRX2.js +279 -0
- package/dist/table-bWCLW-3P.js +279 -0
- package/dist/timeout-Ddn-5kAO.js +232 -0
- package/dist/tokens-3psI_Qk2.js +14 -0
- package/dist/tokens-BaM53PEx.js +14 -0
- package/dist/trash-Bmxs1Rnm.js +23 -0
- package/dist/trash-C39a6hKA.js +23 -0
- package/dist/tui-BHgBWhHE.js +3894 -0
- package/dist/tui-cli-B9Sq5-cC.js +50 -0
- package/dist/tui-cli-Dw7v4JoJ.js +47 -0
- package/dist/tui-mUwDwqvd.js +3894 -0
- package/dist/update-DF0GHG0j.js +317 -0
- package/dist/update-DoZLVjva.js +317 -0
- package/dist/update-check-Bt1dVPVN.js +400 -0
- package/dist/update-check-D5qAKes7.js +400 -0
- package/dist/update-cli-BNu2Oi7H.js +1105 -0
- package/dist/update-cli-D36AmALA.js +1105 -0
- package/dist/update-runner-CNQQaTwA.js +894 -0
- package/dist/update-runner-CvxZmbu-.js +894 -0
- package/dist/usage-BGCwNnjk.js +4516 -0
- package/dist/utils-DZ8pnOD5.js +243 -0
- package/dist/web-B5QG839O.js +46842 -0
- package/dist/web-Cmnvk9v0.js +2203 -0
- package/dist/web-Cv2KnTnL.js +63 -0
- package/dist/webhooks-cli-B6y89Pj_.js +319 -0
- package/dist/webhooks-cli-BDzHON4w.js +316 -0
- package/dist/whatsapp-actions-C_5MwVxM.js +45 -0
- package/dist/whatsapp-actions-hgYA12To.js +53 -0
- package/dist/whatsapp-actions-zTiVOoOV.js +49 -0
- package/dist/widearea-dns-BeIdnISJ.js +127 -0
- package/dist/widearea-dns-CF1gxpJ-.js +127 -0
- package/dist/workspace-DLna1IxR.js +649 -0
- package/dist/ws-log-Q4wO1Ztb.js +267 -0
- package/dist/ws-log-xF0kxDzp.js +267 -0
- package/package.json +1 -2
- package/dist/accounts-Cc5E4IDO.js +0 -260
- package/dist/accounts-CcVrwKqv.js +0 -259
- package/dist/acp-cli-DvphOKuh.js +0 -1081
- package/dist/acp-cli-p28pQ65a.js +0 -1084
- package/dist/agent-Cj7uDJaZ.js +0 -725
- package/dist/agent-Cuj9-2sT.js +0 -725
- package/dist/agent-events-BEBQsyE5.js +0 -182
- package/dist/agent-scope-BVf4aSwY.js +0 -112
- package/dist/agent-scope-OZi7lb8S.js +0 -452
- package/dist/agent-scope-V1bi9OYL.js +0 -452
- package/dist/agents-BUWqn_Ui.js +0 -774
- package/dist/agents.config-Dvo2ULxs.js +0 -182
- package/dist/agents.config-d6H0_3oj.js +0 -182
- package/dist/argv-DqUHKf0o.js +0 -73
- package/dist/audit-C6okOOSh.js +0 -2401
- package/dist/audit-VWjIdwC7.js +0 -2401
- package/dist/auth-91o2YM96.js +0 -648
- package/dist/auth-choice-CAmACV13.js +0 -2681
- package/dist/auth-choice-p3SeHPj2.js +0 -2681
- package/dist/auth-health-B_jXrWe6.js +0 -149
- package/dist/auth-health-DCicUKYR.js +0 -149
- package/dist/auth-lZ26wsbN.js +0 -639
- package/dist/auth-profiles-CCDD56dU.js +0 -1564
- package/dist/auth-profiles-DxI8L7bs.js +0 -2689
- package/dist/banner-Cohn04J6.js +0 -294
- package/dist/browser-cli-DANzjztE.js +0 -1676
- package/dist/browser-cli-WjsVH741.js +0 -1679
- package/dist/call-BAHvlu2G.js +0 -282
- package/dist/call-Ct7EGP_L.js +0 -282
- package/dist/catalog-BAayBt1L.js +0 -185
- package/dist/catalog-BNsf97BM.js +0 -185
- package/dist/channel-options-Dx9nPlX8.js +0 -33
- package/dist/channel-options-ZdvXrTGs.js +0 -32
- package/dist/channel-selection-CujyiWGM.js +0 -51
- package/dist/channel-selection-DfGpCyh2.js +0 -51
- package/dist/channel-web-CC0hkgkR.js +0 -2162
- package/dist/channels-cli-D7lNBpIb.js +0 -1304
- package/dist/channels-cli-DUPG8WDv.js +0 -1306
- package/dist/channels-status-issues-DBc1pU_R.js +0 -18
- package/dist/channels-status-issues-DjO9MHIG.js +0 -18
- package/dist/chrome-Bi6iZ5sG.js +0 -1601
- package/dist/chrome-DNSv7Cpy.js +0 -1629
- package/dist/chrome-DScZx4Lk.js +0 -1601
- package/dist/chunk-mxPVo000.js +0 -348
- package/dist/clack-prompter-B0kl7shw.js +0 -92
- package/dist/clack-prompter-B1YxZdRy.js +0 -92
- package/dist/cli-CfHUkOD0.js +0 -101
- package/dist/cli-ClMrIh6l.js +0 -99
- package/dist/cli-session-BkPTd9Pk.js +0 -5463
- package/dist/cli-session-Dd8DKb5a.js +0 -5408
- package/dist/client-C1avc0vD.js +0 -1692
- package/dist/client-CC94YZrT.js +0 -1692
- package/dist/clipboard-B2fBy8tG.js +0 -31
- package/dist/clipboard-BbGnZskJ.js +0 -31
- package/dist/command-format-Clp46jkj.js +0 -38
- package/dist/command-format-DELazozB.js +0 -52
- package/dist/command-format-SkzzRqR1.js +0 -52
- package/dist/command-registry-DZ4hkmA0.js +0 -248
- package/dist/commands-DtYZJSPn.js +0 -568
- package/dist/commands-Dujk1JmY.js +0 -568
- package/dist/commands-registry-Bd0xbvwG.js +0 -766
- package/dist/commands-registry-DYfRSVF3.js +0 -766
- package/dist/common-D6bu0zHC.js +0 -287
- package/dist/common-zW9Y2P1B.js +0 -287
- package/dist/completion-cli-tSe7Pmqm.js +0 -431
- package/dist/completion-cli-vn4IScs5.js +0 -432
- package/dist/config-C8rUDJXY.js +0 -5704
- package/dist/config-CLZ_XGVw.js +0 -6523
- package/dist/config-SY8M0kM_.js +0 -5705
- package/dist/config-cli-1V7D2Wsw.js +0 -247
- package/dist/config-cli-CjWEC81L.js +0 -244
- package/dist/config-guard-BW2gpKj_.js +0 -93
- package/dist/config-guard-BvxuzHpo.js +0 -76
- package/dist/config-sync-CoIIbEOe.js +0 -91
- package/dist/config-sync-DvAttep0.js +0 -91
- package/dist/configure-Bf0oupCE.js +0 -959
- package/dist/configure-DRM-7zFf.js +0 -960
- package/dist/context-D5iEFzv9.js +0 -60
- package/dist/control-service-C8m8F9pr.js +0 -72
- package/dist/control-service-DKotCWCg.js +0 -72
- package/dist/cron-cli-DB_FLYHD.js +0 -448
- package/dist/cron-cli-bxm5lrrO.js +0 -451
- package/dist/daemon-cli-1LsOnICv.js +0 -566
- package/dist/daemon-cli-CC2NrJ7a.js +0 -565
- package/dist/daemon-runtime-BXZhtBL9.js +0 -460
- package/dist/daemon-runtime-DW4USC7r.js +0 -460
- package/dist/deliver-B4HuPwJA.js +0 -1162
- package/dist/deliver-LiY5oL52.js +0 -1097
- package/dist/deliver-xrmk7xjh.js +0 -1097
- package/dist/delivery-queue-TnQykYsg.js +0 -220
- package/dist/deps-CMMOiOsF.js +0 -42
- package/dist/devices-cli-Be5he2SA.js +0 -195
- package/dist/devices-cli-z6ecoFe9.js +0 -198
- package/dist/diagnostics-Dj75aEHN.js +0 -35
- package/dist/diagnostics-DlIw6fqD.js +0 -35
- package/dist/directory-cli-CEy-0nxj.js +0 -243
- package/dist/directory-cli-DpzKcigr.js +0 -246
- package/dist/dispatcher-10Shiuz3.js +0 -100
- package/dist/dispatcher-3Jae6AiW.js +0 -100
- package/dist/dns-cli-Bat1pkc-.js +0 -200
- package/dist/dns-cli-NohNyEo0.js +0 -197
- package/dist/dock-DbxBBv30.js +0 -753
- package/dist/dock-cPBY4qGl.js +0 -753
- package/dist/docs-cli-BWp6p-Tq.js +0 -161
- package/dist/docs-cli-x22FnZfL.js +0 -159
- package/dist/doctor-BrT5m_on.js +0 -1815
- package/dist/doctor-Pp2HVnjM.js +0 -1813
- package/dist/doctor-completion-DNTimX9o.js +0 -92
- package/dist/doctor-completion-ylN9QAJ6.js +0 -92
- package/dist/doctor-config-flow-D1w3700T.js +0 -1232
- package/dist/doctor-config-flow-Dq50iE1R.js +0 -1232
- package/dist/engine-B9avUJL5.js +0 -563
- package/dist/engine-BiUQ25D4.js +0 -563
- package/dist/env-0lJfCPsw.js +0 -32
- package/dist/exec-BenD3A5l.js +0 -1167
- package/dist/exec-Bv3pyjeM.js +0 -255
- package/dist/exec-approvals-CdLmKX2R.js +0 -1221
- package/dist/exec-approvals-cli-DXfV6G8H.js +0 -368
- package/dist/exec-approvals-cli-J2cZs10o.js +0 -371
- package/dist/frontmatter-YijVi0FQ.js +0 -204
- package/dist/gateway-cli-DOAbA0pc.js +0 -19972
- package/dist/gateway-cli-QpWtBhQy.js +0 -19971
- package/dist/gateway-rpc-DJKBil9s.js +0 -28
- package/dist/gateway-rpc-DVterpLP.js +0 -28
- package/dist/github-copilot-auth-4IUFp669.js +0 -1418
- package/dist/github-copilot-auth-C9E0IROs.js +0 -1418
- package/dist/gmail-setup-utils-BPo_LkKI.js +0 -428
- package/dist/gmail-setup-utils-D3Yqgor7.js +0 -428
- package/dist/health-BeZnqp6m.js +0 -1258
- package/dist/health-Cn2OoVWZ.js +0 -1253
- package/dist/health-format-CdP99j3Y.js +0 -208
- package/dist/health-format-JEChH08S.js +0 -208
- package/dist/heartbeat-visibility-BL3WAchI.js +0 -98
- package/dist/heartbeat-visibility-CQ9QimI7.js +0 -98
- package/dist/help-format-Dl4bsrLI.js +0 -17
- package/dist/helpers-ZKNRexvX.js +0 -10
- package/dist/hooks-cli-D99hXt7K.js +0 -991
- package/dist/hooks-cli-DMB8RiEO.js +0 -993
- package/dist/hooks-status-B-e96dZj.js +0 -356
- package/dist/hooks-status-C_9sE0ox.js +0 -356
- package/dist/image-ops-Dlt3T7th.js +0 -541
- package/dist/image-ops-omlvdfah.js +0 -541
- package/dist/init-Bm04RagW.js +0 -122
- package/dist/init-CaJBf4p1.js +0 -122
- package/dist/installs-C2iMRBVz.js +0 -383
- package/dist/installs-D-cPGdCw.js +0 -383
- package/dist/ipv4-Bf7NS3QU.js +0 -1964
- package/dist/ipv4-wWNs8IH_.js +0 -1964
- package/dist/lanes-CNxj3tit.js +0 -232
- package/dist/lifecycle-core-B_7XRcvF.js +0 -388
- package/dist/lifecycle-core-By83PVAK.js +0 -387
- package/dist/links-BfjHVTB_.js +0 -15
- package/dist/links-DPGe0OHw.js +0 -15
- package/dist/logging-DB6BQmhi.js +0 -15
- package/dist/logging-mcb66J0p.js +0 -15
- package/dist/login-BDCg6D0N.js +0 -61
- package/dist/login-BDfnbjnZ.js +0 -59
- package/dist/login-BqH1itcg.js +0 -61
- package/dist/login-qr-CyOw3R4r.js +0 -321
- package/dist/login-qr-D8ECtb72.js +0 -323
- package/dist/login-qr-RnR7e4Bw.js +0 -326
- package/dist/logs-cli--j89L74J.js +0 -245
- package/dist/logs-cli-DpEMg_Gq.js +0 -242
- package/dist/manager-B4OyvcxT.js +0 -3244
- package/dist/manager-Cqc1CeH7.js +0 -3246
- package/dist/manager-DUyQPFvj.js +0 -3244
- package/dist/manifest-registry-CW1zCyRF.js +0 -748
- package/dist/manifest-registry-D4lM2RdV.js +0 -748
- package/dist/markdown-tables-BT1X6jqH.js +0 -347
- package/dist/markdown-tables-DHgOK2vI.js +0 -348
- package/dist/media-THyainiE.js +0 -1342
- package/dist/memory-cli-BKocCWXM.js +0 -868
- package/dist/memory-cli-Jmma-xI_.js +0 -869
- package/dist/message-channel-dSTVVCyX.js +0 -110
- package/dist/migrate-BR6iAIjO.js +0 -157
- package/dist/migrate-D0EcMs0f.js +0 -157
- package/dist/model-selection-YcSr9CgC.js +0 -2691
- package/dist/models-1vUQBVfw.js +0 -2510
- package/dist/models-cli-BK3BwUhL.js +0 -2739
- package/dist/models-cli-DECrM8oA.js +0 -258
- package/dist/net-B5lXhYLV.js +0 -218
- package/dist/node-cli-cLHUNpPD.js +0 -1319
- package/dist/node-cli-fO7Y132S.js +0 -1322
- package/dist/node-service-BFxHJsno.js +0 -67
- package/dist/node-service-DUnan4uK.js +0 -67
- package/dist/nodes-cli-BCq35E6N.js +0 -1200
- package/dist/nodes-cli-vD7MwAKP.js +0 -1197
- package/dist/nodes-screen-1YiLkqr5.js +0 -234
- package/dist/nodes-screen-DZeD8hE5.js +0 -234
- package/dist/note-Bi8Wb8DV.js +0 -73
- package/dist/note-uiuPxhyX.js +0 -73
- package/dist/npm-registry-spec-B-XIShkB.js +0 -351
- package/dist/npm-registry-spec-za3itb5Y.js +0 -351
- package/dist/onboard-Ds6w_sWo.js +0 -1165
- package/dist/onboard-SAVx3bp4.js +0 -1166
- package/dist/onboard-channels-Cg_EkBa4.js +0 -672
- package/dist/onboard-channels-D7NbA55V.js +0 -672
- package/dist/onboard-helpers-DO_hgZb9.js +0 -365
- package/dist/onboard-helpers-_XgJgeqh.js +0 -365
- package/dist/onboarding-3hLmDd0r.js +0 -911
- package/dist/onboarding-B4LKLsbU.js +0 -910
- package/dist/orchestrator-BKzmyBWy.js +0 -357
- package/dist/orchestrator-BN3QCz2s.js +0 -357
- package/dist/outbound-BgA9hNlP.js +0 -2062
- package/dist/outbound-CjdvVhUI.js +0 -214
- package/dist/outbound-DOGe6qb2.js +0 -214
- package/dist/outbound-send-deps-Du5aBpd7.js +0 -55
- package/dist/pairing-cli-2vnyg_Nd.js +0 -118
- package/dist/pairing-cli-BH1KQtNV.js +0 -121
- package/dist/pairing-store-DJz_9Gv0.js +0 -388
- package/dist/pairing-store-DmOzxcuk.js +0 -388
- package/dist/path-env-Bu6k0jDQ.js +0 -89
- package/dist/path-env-C0zQSjw8.js +0 -89
- package/dist/paths-BTc4nk-6.js +0 -126
- package/dist/paths-BgUi2Z2G.js +0 -54
- package/dist/paths-C6VCWKo3.js +0 -238
- package/dist/paths-CCxa0o9c.js +0 -222
- package/dist/paths-CxRf2rBG.js +0 -129
- package/dist/paths-hcX1Gqg5.js +0 -129
- package/dist/pi-auth-json-B68R7q7_.js +0 -82
- package/dist/pi-auth-json-CR0jXAgq.js +0 -78
- package/dist/pi-auth-json-ZYzi3nxs.js +0 -80
- package/dist/pi-model-discovery-Cxs4pvC2.js +0 -3
- package/dist/pi-tools.policy-D81U5xy0.js +0 -200
- package/dist/pi-tools.policy-DSHkkb5b.js +0 -200
- package/dist/plugin-auto-enable-CxF4bpDN.js +0 -282
- package/dist/plugin-auto-enable-jNaAeyEh.js +0 -282
- package/dist/plugin-registry-C7XWotZG.js +0 -32
- package/dist/plugin-registry-DcUCbGax.js +0 -32
- package/dist/plugins-B362e77G.js +0 -168
- package/dist/plugins-CmSUIUNi.js +0 -38
- package/dist/plugins-cli-BsCEnoQ7.js +0 -734
- package/dist/plugins-cli-QSIsMUG7.js +0 -736
- package/dist/polls-CItfB1H8.js +0 -1343
- package/dist/ports-BVLMN1Sr.js +0 -96
- package/dist/ports-CqLSlU6Z.js +0 -317
- package/dist/ports-D94CwCrv.js +0 -344
- package/dist/ports-D_NHthOz.js +0 -96
- package/dist/program-DkJHjI0R.js +0 -176
- package/dist/program-context-DnyGM2SC.js +0 -496
- package/dist/progress-Bek_GyWS.js +0 -133
- package/dist/prompt-style-lu0clOOE.js +0 -9
- package/dist/pw-ai-BLVMuSLv.js +0 -1867
- package/dist/pw-ai-DZJWEF_f.js +0 -1865
- package/dist/pw-ai-dzf-ptcn.js +0 -1868
- package/dist/qmd-manager-Cur_Ekn0.js +0 -937
- package/dist/qmd-manager-DNAUuwjK.js +0 -938
- package/dist/qmd-manager-DepEoASu.js +0 -935
- package/dist/register.agent-CSWvzOkR.js +0 -265
- package/dist/register.agent-UeH2NXmH.js +0 -1003
- package/dist/register.anima-DOdee0dh.js +0 -193
- package/dist/register.anima-HHDWsz6r.js +0 -193
- package/dist/register.configure-CSJFxdz9.js +0 -103
- package/dist/register.configure-D84Fvcz4.js +0 -101
- package/dist/register.maintenance-B3pvNbZb.js +0 -543
- package/dist/register.maintenance-BKVOwkw6.js +0 -543
- package/dist/register.message-BAO6CPl2.js +0 -657
- package/dist/register.message-OXoOKE_6.js +0 -660
- package/dist/register.onboard-BK_ixVmD.js +0 -170
- package/dist/register.onboard-cfCaPx6j.js +0 -170
- package/dist/register.setup-BGfDnzph.js +0 -175
- package/dist/register.setup-Y-Q74M-0.js +0 -175
- package/dist/register.status-health-sessions-CT14eitH.js +0 -142
- package/dist/register.status-health-sessions-TfZMzAUn.js +0 -313
- package/dist/register.subclis-BZwdlNHC.js +0 -255
- package/dist/reply-mlsExaZm.js +0 -32212
- package/dist/reply-prefix-B0CfR4bM.js +0 -100
- package/dist/reply-prefix-w4a39ybC.js +0 -100
- package/dist/reply-qalRISe_.js +0 -32212
- package/dist/routes-CENsHJyg.js +0 -1820
- package/dist/routes-DO0HqW2e.js +0 -1820
- package/dist/rpc-C0pjNhBi.js +0 -70
- package/dist/rpc-DZ44PIXE.js +0 -70
- package/dist/run-main-BMpKw8Mp.js +0 -371
- package/dist/runtime-guard-BSUFiAQV.js +0 -60
- package/dist/sandbox-BIGfMYEI.js +0 -858
- package/dist/sandbox-DxP3IpUP.js +0 -859
- package/dist/sandbox-cli-DtLGH8sL.js +0 -461
- package/dist/sandbox-cli-_Tg7lfJ_.js +0 -458
- package/dist/security-cli-BRwgbedo.js +0 -462
- package/dist/security-cli-D3bSuyZt.js +0 -465
- package/dist/server-context-49XFFxFg.js +0 -824
- package/dist/server-context-LrlgrZzS.js +0 -824
- package/dist/server-node-events-Dm52i7NW.js +0 -231
- package/dist/server-node-events-QX523UyF.js +0 -233
- package/dist/service-BNVpYcQe.js +0 -642
- package/dist/service-D56aMXUB.js +0 -642
- package/dist/service-audit-D0X_XAB2.js +0 -488
- package/dist/service-audit-qmf6XMmP.js +0 -488
- package/dist/session-CrQQLLhx.js +0 -179
- package/dist/session-LocsOOWJ.js +0 -181
- package/dist/session-Vlce2BAT.js +0 -181
- package/dist/session-cost-usage-BwiTZuKl.js +0 -600
- package/dist/session-cost-usage-DT9YNXTJ.js +0 -600
- package/dist/sessions-BfV53TbG.js +0 -1296
- package/dist/sessions-BimpX_km.js +0 -180
- package/dist/sessions-DcXpzig0.js +0 -1296
- package/dist/sessions-Wd18dukK.js +0 -2038
- package/dist/shared-Bsr69u_7.js +0 -77
- package/dist/shared-Cgly1vPb.js +0 -66
- package/dist/shared-JOo05hST.js +0 -66
- package/dist/shared-f7dvQsi7.js +0 -77
- package/dist/skill-scanner-CkaVLABv.js +0 -263
- package/dist/skills-B-G7UHOa.js +0 -808
- package/dist/skills-B5LQx4lT.js +0 -807
- package/dist/skills-cli-DUGe2ZWW.js +0 -286
- package/dist/skills-cli-DtOk0bvK.js +0 -289
- package/dist/skills-status-Clq9ZnYu.js +0 -166
- package/dist/skills-status-JQluhU-P.js +0 -166
- package/dist/sqlite-BukcjdJa.js +0 -321
- package/dist/sqlite-CGcOZZ0C.js +0 -368
- package/dist/sqlite-Ck6f9KWc.js +0 -453
- package/dist/start--xmSFepB.js +0 -372
- package/dist/start-BdlZbqrr.js +0 -371
- package/dist/status-BgoeFm6g.js +0 -2137
- package/dist/status-BjjDrUq7.js +0 -27
- package/dist/status-Ct0DgOZ-.js +0 -2132
- package/dist/status-RA_uNmK0.js +0 -27
- package/dist/status.update-BjOH3GlS.js +0 -79
- package/dist/status.update-DLU1qBf0.js +0 -79
- package/dist/subagent-registry-9RLdKxES.js +0 -2760
- package/dist/subagent-registry-Byuex3zp.js +0 -2759
- package/dist/subagent-registry-DOBunBYS.js +0 -14
- package/dist/subsystem-Dowf8fSU.js +0 -860
- package/dist/system-cli-C5oBpzni.js +0 -79
- package/dist/system-cli-DXNKD_Id.js +0 -82
- package/dist/systemd-BSrHDyeU.js +0 -452
- package/dist/systemd-By5xdSB4.js +0 -452
- package/dist/systemd-hints-BtjL_5Rh.js +0 -36
- package/dist/systemd-hints-sJmr6cjb.js +0 -36
- package/dist/systemd-linger-CTmV2Gci.js +0 -75
- package/dist/systemd-linger-CmyqQkeC.js +0 -75
- package/dist/table-BL0lJzsm.js +0 -279
- package/dist/table-DoiRPsn0.js +0 -279
- package/dist/timeout-CswI_K-U.js +0 -232
- package/dist/tokens-C-X7wDKj.js +0 -14
- package/dist/tokens-DkvqA72p.js +0 -14
- package/dist/trash-BJLK1vMn.js +0 -23
- package/dist/trash-_x5UZ94k.js +0 -23
- package/dist/tui-BHjxDFZC.js +0 -3894
- package/dist/tui-CgOocwN8.js +0 -3894
- package/dist/tui-cli-5ANH8dE5.js +0 -47
- package/dist/tui-cli-BQ4P-JW_.js +0 -50
- package/dist/update-LFgxHHPd.js +0 -317
- package/dist/update-TxptCqk7.js +0 -317
- package/dist/update-check-CWc7YXmc.js +0 -400
- package/dist/update-check-IhlWaui6.js +0 -400
- package/dist/update-cli-PtXU62w7.js +0 -1105
- package/dist/update-cli-Va0EtETG.js +0 -1105
- package/dist/update-runner-BLeKFkiB.js +0 -894
- package/dist/update-runner-Iuzpc-_y.js +0 -894
- package/dist/usage-ApGvBLVg.js +0 -4516
- package/dist/utils-Bsw__U-F.js +0 -243
- package/dist/web-B6_Ky60G.js +0 -63
- package/dist/web-EZLQEWXY.js +0 -46842
- package/dist/web-pec8YJUX.js +0 -2203
- package/dist/webhooks-cli-BYQKTHTp.js +0 -319
- package/dist/webhooks-cli-C2_xtsUQ.js +0 -316
- package/dist/whatsapp-actions-C72VCq8f.js +0 -49
- package/dist/whatsapp-actions-Ck9Uv0Nw.js +0 -45
- package/dist/whatsapp-actions-D0reTj2k.js +0 -53
- package/dist/widearea-dns-B6ocX23x.js +0 -127
- package/dist/widearea-dns-NsEUNYwz.js +0 -127
- package/dist/workspace-Dcfoy5JJ.js +0 -649
- package/dist/ws-log-N8R5MvGE.js +0 -267
- package/dist/ws-log-gwFxPxj5.js +0 -267
- /package/dist/{auto-update-CUeF99gI.js → auto-update-CpF0fycd.js} +0 -0
- /package/dist/{auto-update-cgkp9ZTJ.js → auto-update-DNWdO7uF.js} +0 -0
- /package/dist/{brew-CVZkr0GU.js → brew-nqf_MiE4.js} +0 -0
- /package/dist/{budget-DxYQSekw.js → budget-CPedI-qW.js} +0 -0
- /package/dist/{budget-BWBp8Res.js → budget-CRpvqDRX.js} +0 -0
- /package/dist/{cli-utils-DtAxdCte.js → cli-utils-C1YHVD4o.js} +0 -0
- /package/dist/{command-options-CSbuuqHr.js → command-options-BbponVnw.js} +0 -0
- /package/dist/{command-options-Cp1tf96a.js → command-options-s0gnvXnS.js} +0 -0
- /package/dist/{constants-O8yBqCBv.js → constants-Dhb6zSIV.js} +0 -0
- /package/dist/{dangerous-tools-5ObDWy1N.js → dangerous-tools-DGTtJ_JR.js} +0 -0
- /package/dist/{dangerous-tools-Jwr7jqNw.js → dangerous-tools-DxrfTOfT.js} +0 -0
- /package/dist/{delivery-queue-B6IHz4Ry.js → delivery-queue-Bxm0nzw7.js} +0 -0
- /package/dist/{display-BDOsXu8F.js → display-Jy3UdGzA.js} +0 -0
- /package/dist/{errors-CHow2wtt.js → errors-CKaCqKga.js} +0 -0
- /package/dist/{exec-BizYYQgP.js → exec-DDmuVVNq.js} +0 -0
- /package/dist/{format-Mq6iU0_5.js → format-ByEjgyTF.js} +0 -0
- /package/dist/{format-duration-DhWzz_5b.js → format-duration-Aaj5tjJd.js} +0 -0
- /package/dist/{format-relative-C6kUHuOj.js → format-relative-79_Y1n2Y.js} +0 -0
- /package/dist/{help-format-DUBI91Ti.js → help-format-BMKzarov.js} +0 -0
- /package/dist/{helpers-eJFa4K6r.js → helpers-DpEB9Mh0.js} +0 -0
- /package/dist/{helpers-DLgbkcEn.js → helpers-FMld9sBT.js} +0 -0
- /package/dist/{input-provenance-DJBdpeKk.js → input-provenance-Cy_KnBlP.js} +0 -0
- /package/dist/{is-main-Dt9DTcH1.js → is-main-yjaVwMtJ.js} +0 -0
- /package/dist/{loader-l2OBdJ8x.js → loader-Br7Vr0zn.js} +0 -0
- /package/dist/{loader-BoYxRfcW.js → loader-CkmOrXcC.js} +0 -0
- /package/dist/{logging-BdnOSVPD.js → logging-CY-Q5cwf.js} +0 -0
- /package/dist/{message-channel-w4F2b2F6.js → message-channel-dua8OOGJ.js} +0 -0
- /package/dist/{mime-B1ZoR53M.js → mime-CBg4KybI.js} +0 -0
- /package/dist/{model-param-b-DPwyNGn8.js → model-param-b-DW9f0NN8.js} +0 -0
- /package/dist/{node-match-8XZnaid6.js → node-match-BV8bTBd4.js} +0 -0
- /package/dist/{normalize-GDK8JTNW.js → normalize-_lmlBOW9.js} +0 -0
- /package/dist/{openclaw-root-C85WMnVV.js → openclaw-root-JPvmPTf7.js} +0 -0
- /package/dist/{outbound-send-deps-ANnAhImn.js → outbound-send-deps-BfUvuWGa.js} +0 -0
- /package/dist/{parse-6-2MDhdT.js → parse-CZRwKocn.js} +0 -0
- /package/dist/{parse-log-line-Bqh1SSzC.js → parse-log-line-CvrZEK6A.js} +0 -0
- /package/dist/{parse-log-line-DUZCjXbl.js → parse-log-line-mLdat0AH.js} +0 -0
- /package/dist/{parse-port-BKB9Exlg.js → parse-port-BSOOdo7I.js} +0 -0
- /package/dist/{parse-port-DrfvwwiL.js → parse-port-Y0NK62x1.js} +0 -0
- /package/dist/{parse-timeout-Di_tcEmi.js → parse-timeout-DVPQ3n9j.js} +0 -0
- /package/dist/{paths-DcVEkYX5.js → paths-DHjlJ6cn.js} +0 -0
- /package/dist/{pi-model-discovery-DsRqYJLy.js → pi-model-discovery-DzEIEgHL.js} +0 -0
- /package/dist/{plugins-CDJw924T.js → plugins-D6PBOdkn.js} +0 -0
- /package/dist/{program-context-Bvn8046-.js → program-context-Q1hkT73c.js} +0 -0
- /package/dist/{progress-CbZ2D53A.js → progress-C9Ha1NJh.js} +0 -0
- /package/dist/{prompt-style-DKy6qQxR.js → prompt-style-DQi8j03a.js} +0 -0
- /package/dist/{prompts-BI__va99.js → prompts-BEHxUC3w.js} +0 -0
- /package/dist/{prompts-_dDWkCAz.js → prompts-CSOhuiqe.js} +0 -0
- /package/dist/{queue-D_u34pbL.js → queue-BJGo7kAB.js} +0 -0
- /package/dist/{queue-PG591iID.js → queue-DYgUbdoq.js} +0 -0
- /package/dist/{redact-ClVwO7Nn.js → redact-CyKvdFrg.js} +0 -0
- /package/dist/{registry-Bs_DJK9E.js → registry-C5MAYD4V.js} +0 -0
- /package/dist/{registry-D_zlP1U-.js → registry-CRrXXVs0.js} +0 -0
- /package/dist/{requirements-BzZxj2Wu.js → requirements-CGkxTCu4.js} +0 -0
- /package/dist/{requirements-DIW1svgA.js → requirements-CIDaOcbO.js} +0 -0
- /package/dist/{runtime-guard-DeOXA_86.js → runtime-guard-nL3Lp8T-.js} +0 -0
- /package/dist/{secret-equal-Dghy3xsA.js → secret-equal-DJpmLXlG.js} +0 -0
- /package/dist/{send-BhAfdGII.js → send-CTcxgDDU.js} +0 -0
- /package/dist/{send-ga9udK1_.js → send-DPezUR3-.js} +0 -0
- /package/dist/{send-C2t9xpXI.js → send-DZQTaG7-.js} +0 -0
- /package/dist/{send-DigO-i9j.js → send-VDff2gra.js} +0 -0
- /package/dist/{send-Dz2BDHll.js → send-bgQNV8d1.js} +0 -0
- /package/dist/{session-key-BGiG_JcT.js → session-key-CQT-NR6w.js} +0 -0
- /package/dist/{shell-argv-CAq1mLa2.js → shell-argv-n9IueeJQ.js} +0 -0
- /package/dist/{skill-scanner-Coo4QoCd.js → skill-scanner-o6NgVMD9.js} +0 -0
- /package/dist/{status-CMnlcBVc.js → status-C53kTIXF.js} +0 -0
- /package/dist/{status-tDZPwewW.js → status-CZDDA_Sy.js} +0 -0
- /package/dist/{system-run-command-X9lDJIy0.js → system-run-command-BCjUffN9.js} +0 -0
- /package/dist/{system-run-command-DGk7dwQP.js → system-run-command-CqAqKL9K.js} +0 -0
- /package/dist/{tailnet-CuiNECdL.js → tailnet-Ciwjv243.js} +0 -0
- /package/dist/{templates-CeYJjVzw.js → templates-37RKpACb.js} +0 -0
- /package/dist/{templates-I3Z0xplD.js → templates-DPalk30o.js} +0 -0
- /package/dist/{thinking-BXEswx1X.js → thinking-2hxwmvTl.js} +0 -0
- /package/dist/{transcript-events-C1hdue6u.js → transcript-events-Bp7fGnwv.js} +0 -0
- /package/dist/{transcript-tools-DuyYOkUq.js → transcript-tools-D4Lbxlka.js} +0 -0
- /package/dist/{usage-format-BAirWUSO.js → usage-format-6Uar63S0.js} +0 -0
- /package/dist/{utils-C9sj30YY.js → utils-DT8uXjFS.js} +0 -0
- /package/dist/{wsl-CqyuRvtM.js → wsl-CrPvx2kZ.js} +0 -0
- /package/dist/{wsl-ymJYvc9Q.js → wsl-UvJ5dHah.js} +0 -0
|
@@ -1,2062 +0,0 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-Cbj13DAv.js";
|
|
2
|
-
import { t as STATE_DIR } from "./paths-CCxa0o9c.js";
|
|
3
|
-
import { g as DEFAULT_ACCOUNT_ID } from "./workspace-Dcfoy5JJ.js";
|
|
4
|
-
import { G as toWhatsappJid, Y as logVerbose, Z as shouldLogVerbose, c as logWarn, k as escapeRegExp, l as createSubsystemLogger, n as runExec, nt as getChildLogger, z as resolveUserPath } from "./exec-BenD3A5l.js";
|
|
5
|
-
import { t as formatCliCommand } from "./command-format-SkzzRqR1.js";
|
|
6
|
-
import { n as loadConfig } from "./config-CLZ_XGVw.js";
|
|
7
|
-
import { c as maxBytesForKind, l as mediaKindFromMime, n as extensionForMime, t as detectMime } from "./mime-Bm1xTtpY.js";
|
|
8
|
-
import { t as resolveMarkdownTableMode } from "./markdown-tables-BT1X6jqH.js";
|
|
9
|
-
import fs from "node:fs/promises";
|
|
10
|
-
import os from "node:os";
|
|
11
|
-
import path from "node:path";
|
|
12
|
-
import { fileURLToPath } from "node:url";
|
|
13
|
-
import { randomUUID } from "node:crypto";
|
|
14
|
-
import MarkdownIt from "markdown-it";
|
|
15
|
-
import { lookup } from "node:dns";
|
|
16
|
-
import { lookup as lookup$1 } from "node:dns/promises";
|
|
17
|
-
import { Agent } from "undici";
|
|
18
|
-
|
|
19
|
-
//#region src/markdown/ir.ts
|
|
20
|
-
function createMarkdownIt(options) {
|
|
21
|
-
const md = new MarkdownIt({
|
|
22
|
-
html: false,
|
|
23
|
-
linkify: options.linkify ?? true,
|
|
24
|
-
breaks: false,
|
|
25
|
-
typographer: false
|
|
26
|
-
});
|
|
27
|
-
md.enable("strikethrough");
|
|
28
|
-
if (options.tableMode && options.tableMode !== "off") md.enable("table");
|
|
29
|
-
else md.disable("table");
|
|
30
|
-
if (options.autolink === false) md.disable("autolink");
|
|
31
|
-
return md;
|
|
32
|
-
}
|
|
33
|
-
function getAttr(token, name) {
|
|
34
|
-
if (token.attrGet) return token.attrGet(name);
|
|
35
|
-
if (token.attrs) {
|
|
36
|
-
for (const [key, value] of token.attrs) if (key === name) return value;
|
|
37
|
-
}
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
function createTextToken(base, content) {
|
|
41
|
-
return {
|
|
42
|
-
...base,
|
|
43
|
-
type: "text",
|
|
44
|
-
content,
|
|
45
|
-
children: void 0
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
function applySpoilerTokens(tokens) {
|
|
49
|
-
for (const token of tokens) if (token.children && token.children.length > 0) token.children = injectSpoilersIntoInline(token.children);
|
|
50
|
-
}
|
|
51
|
-
function injectSpoilersIntoInline(tokens) {
|
|
52
|
-
const result = [];
|
|
53
|
-
const state = { spoilerOpen: false };
|
|
54
|
-
for (const token of tokens) {
|
|
55
|
-
if (token.type !== "text") {
|
|
56
|
-
result.push(token);
|
|
57
|
-
continue;
|
|
58
|
-
}
|
|
59
|
-
const content = token.content ?? "";
|
|
60
|
-
if (!content.includes("||")) {
|
|
61
|
-
result.push(token);
|
|
62
|
-
continue;
|
|
63
|
-
}
|
|
64
|
-
let index = 0;
|
|
65
|
-
while (index < content.length) {
|
|
66
|
-
const next = content.indexOf("||", index);
|
|
67
|
-
if (next === -1) {
|
|
68
|
-
if (index < content.length) result.push(createTextToken(token, content.slice(index)));
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
if (next > index) result.push(createTextToken(token, content.slice(index, next)));
|
|
72
|
-
state.spoilerOpen = !state.spoilerOpen;
|
|
73
|
-
result.push({ type: state.spoilerOpen ? "spoiler_open" : "spoiler_close" });
|
|
74
|
-
index = next + 2;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return result;
|
|
78
|
-
}
|
|
79
|
-
function initRenderTarget() {
|
|
80
|
-
return {
|
|
81
|
-
text: "",
|
|
82
|
-
styles: [],
|
|
83
|
-
openStyles: [],
|
|
84
|
-
links: [],
|
|
85
|
-
linkStack: []
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
function resolveRenderTarget(state) {
|
|
89
|
-
return state.table?.currentCell ?? state;
|
|
90
|
-
}
|
|
91
|
-
function appendText(state, value) {
|
|
92
|
-
if (!value) return;
|
|
93
|
-
const target = resolveRenderTarget(state);
|
|
94
|
-
target.text += value;
|
|
95
|
-
}
|
|
96
|
-
function openStyle(state, style) {
|
|
97
|
-
const target = resolveRenderTarget(state);
|
|
98
|
-
target.openStyles.push({
|
|
99
|
-
style,
|
|
100
|
-
start: target.text.length
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
function closeStyle(state, style) {
|
|
104
|
-
const target = resolveRenderTarget(state);
|
|
105
|
-
for (let i = target.openStyles.length - 1; i >= 0; i -= 1) if (target.openStyles[i]?.style === style) {
|
|
106
|
-
const start = target.openStyles[i].start;
|
|
107
|
-
target.openStyles.splice(i, 1);
|
|
108
|
-
const end = target.text.length;
|
|
109
|
-
if (end > start) target.styles.push({
|
|
110
|
-
start,
|
|
111
|
-
end,
|
|
112
|
-
style
|
|
113
|
-
});
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
function appendParagraphSeparator(state) {
|
|
118
|
-
if (state.env.listStack.length > 0) return;
|
|
119
|
-
if (state.table) return;
|
|
120
|
-
state.text += "\n\n";
|
|
121
|
-
}
|
|
122
|
-
function appendListPrefix(state) {
|
|
123
|
-
const stack = state.env.listStack;
|
|
124
|
-
const top = stack[stack.length - 1];
|
|
125
|
-
if (!top) return;
|
|
126
|
-
top.index += 1;
|
|
127
|
-
const indent = " ".repeat(Math.max(0, stack.length - 1));
|
|
128
|
-
const prefix = top.type === "ordered" ? `${top.index}. ` : "• ";
|
|
129
|
-
state.text += `${indent}${prefix}`;
|
|
130
|
-
}
|
|
131
|
-
function renderInlineCode(state, content) {
|
|
132
|
-
if (!content) return;
|
|
133
|
-
const target = resolveRenderTarget(state);
|
|
134
|
-
const start = target.text.length;
|
|
135
|
-
target.text += content;
|
|
136
|
-
target.styles.push({
|
|
137
|
-
start,
|
|
138
|
-
end: start + content.length,
|
|
139
|
-
style: "code"
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
function renderCodeBlock(state, content) {
|
|
143
|
-
let code = content ?? "";
|
|
144
|
-
if (!code.endsWith("\n")) code = `${code}\n`;
|
|
145
|
-
const target = resolveRenderTarget(state);
|
|
146
|
-
const start = target.text.length;
|
|
147
|
-
target.text += code;
|
|
148
|
-
target.styles.push({
|
|
149
|
-
start,
|
|
150
|
-
end: start + code.length,
|
|
151
|
-
style: "code_block"
|
|
152
|
-
});
|
|
153
|
-
if (state.env.listStack.length === 0) target.text += "\n";
|
|
154
|
-
}
|
|
155
|
-
function handleLinkClose(state) {
|
|
156
|
-
const target = resolveRenderTarget(state);
|
|
157
|
-
const link = target.linkStack.pop();
|
|
158
|
-
if (!link?.href) return;
|
|
159
|
-
const href = link.href.trim();
|
|
160
|
-
if (!href) return;
|
|
161
|
-
const start = link.labelStart;
|
|
162
|
-
const end = target.text.length;
|
|
163
|
-
if (end <= start) {
|
|
164
|
-
target.links.push({
|
|
165
|
-
start,
|
|
166
|
-
end,
|
|
167
|
-
href
|
|
168
|
-
});
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
target.links.push({
|
|
172
|
-
start,
|
|
173
|
-
end,
|
|
174
|
-
href
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
function initTableState() {
|
|
178
|
-
return {
|
|
179
|
-
headers: [],
|
|
180
|
-
rows: [],
|
|
181
|
-
currentRow: [],
|
|
182
|
-
currentCell: null,
|
|
183
|
-
inHeader: false
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
function finishTableCell(cell) {
|
|
187
|
-
closeRemainingStyles(cell);
|
|
188
|
-
return {
|
|
189
|
-
text: cell.text,
|
|
190
|
-
styles: cell.styles,
|
|
191
|
-
links: cell.links
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
function trimCell(cell) {
|
|
195
|
-
const text = cell.text;
|
|
196
|
-
let start = 0;
|
|
197
|
-
let end = text.length;
|
|
198
|
-
while (start < end && /\s/.test(text[start] ?? "")) start += 1;
|
|
199
|
-
while (end > start && /\s/.test(text[end - 1] ?? "")) end -= 1;
|
|
200
|
-
if (start === 0 && end === text.length) return cell;
|
|
201
|
-
const trimmedText = text.slice(start, end);
|
|
202
|
-
const trimmedLength = trimmedText.length;
|
|
203
|
-
const trimmedStyles = [];
|
|
204
|
-
for (const span of cell.styles) {
|
|
205
|
-
const sliceStart = Math.max(0, span.start - start);
|
|
206
|
-
const sliceEnd = Math.min(trimmedLength, span.end - start);
|
|
207
|
-
if (sliceEnd > sliceStart) trimmedStyles.push({
|
|
208
|
-
start: sliceStart,
|
|
209
|
-
end: sliceEnd,
|
|
210
|
-
style: span.style
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
const trimmedLinks = [];
|
|
214
|
-
for (const span of cell.links) {
|
|
215
|
-
const sliceStart = Math.max(0, span.start - start);
|
|
216
|
-
const sliceEnd = Math.min(trimmedLength, span.end - start);
|
|
217
|
-
if (sliceEnd > sliceStart) trimmedLinks.push({
|
|
218
|
-
start: sliceStart,
|
|
219
|
-
end: sliceEnd,
|
|
220
|
-
href: span.href
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
return {
|
|
224
|
-
text: trimmedText,
|
|
225
|
-
styles: trimmedStyles,
|
|
226
|
-
links: trimmedLinks
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
function appendCell(state, cell) {
|
|
230
|
-
if (!cell.text) return;
|
|
231
|
-
const start = state.text.length;
|
|
232
|
-
state.text += cell.text;
|
|
233
|
-
for (const span of cell.styles) state.styles.push({
|
|
234
|
-
start: start + span.start,
|
|
235
|
-
end: start + span.end,
|
|
236
|
-
style: span.style
|
|
237
|
-
});
|
|
238
|
-
for (const link of cell.links) state.links.push({
|
|
239
|
-
start: start + link.start,
|
|
240
|
-
end: start + link.end,
|
|
241
|
-
href: link.href
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
function appendCellTextOnly(state, cell) {
|
|
245
|
-
if (!cell.text) return;
|
|
246
|
-
state.text += cell.text;
|
|
247
|
-
}
|
|
248
|
-
function renderTableAsBullets(state) {
|
|
249
|
-
if (!state.table) return;
|
|
250
|
-
const headers = state.table.headers.map(trimCell);
|
|
251
|
-
const rows = state.table.rows.map((row) => row.map(trimCell));
|
|
252
|
-
if (headers.length === 0 && rows.length === 0) return;
|
|
253
|
-
if (headers.length > 1 && rows.length > 0) for (const row of rows) {
|
|
254
|
-
if (row.length === 0) continue;
|
|
255
|
-
const rowLabel = row[0];
|
|
256
|
-
if (rowLabel?.text) {
|
|
257
|
-
const labelStart = state.text.length;
|
|
258
|
-
appendCell(state, rowLabel);
|
|
259
|
-
const labelEnd = state.text.length;
|
|
260
|
-
if (labelEnd > labelStart) state.styles.push({
|
|
261
|
-
start: labelStart,
|
|
262
|
-
end: labelEnd,
|
|
263
|
-
style: "bold"
|
|
264
|
-
});
|
|
265
|
-
state.text += "\n";
|
|
266
|
-
}
|
|
267
|
-
for (let i = 1; i < row.length; i++) {
|
|
268
|
-
const header = headers[i];
|
|
269
|
-
const value = row[i];
|
|
270
|
-
if (!value?.text) continue;
|
|
271
|
-
state.text += "• ";
|
|
272
|
-
if (header?.text) {
|
|
273
|
-
appendCell(state, header);
|
|
274
|
-
state.text += ": ";
|
|
275
|
-
} else state.text += `Column ${i}: `;
|
|
276
|
-
appendCell(state, value);
|
|
277
|
-
state.text += "\n";
|
|
278
|
-
}
|
|
279
|
-
state.text += "\n";
|
|
280
|
-
}
|
|
281
|
-
else for (const row of rows) {
|
|
282
|
-
for (let i = 0; i < row.length; i++) {
|
|
283
|
-
const header = headers[i];
|
|
284
|
-
const value = row[i];
|
|
285
|
-
if (!value?.text) continue;
|
|
286
|
-
state.text += "• ";
|
|
287
|
-
if (header?.text) {
|
|
288
|
-
appendCell(state, header);
|
|
289
|
-
state.text += ": ";
|
|
290
|
-
}
|
|
291
|
-
appendCell(state, value);
|
|
292
|
-
state.text += "\n";
|
|
293
|
-
}
|
|
294
|
-
state.text += "\n";
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
function renderTableAsCode(state) {
|
|
298
|
-
if (!state.table) return;
|
|
299
|
-
const headers = state.table.headers.map(trimCell);
|
|
300
|
-
const rows = state.table.rows.map((row) => row.map(trimCell));
|
|
301
|
-
const columnCount = Math.max(headers.length, ...rows.map((row) => row.length));
|
|
302
|
-
if (columnCount === 0) return;
|
|
303
|
-
const widths = Array.from({ length: columnCount }, () => 0);
|
|
304
|
-
const updateWidths = (cells) => {
|
|
305
|
-
for (let i = 0; i < columnCount; i += 1) {
|
|
306
|
-
const width = cells[i]?.text.length ?? 0;
|
|
307
|
-
if (widths[i] < width) widths[i] = width;
|
|
308
|
-
}
|
|
309
|
-
};
|
|
310
|
-
updateWidths(headers);
|
|
311
|
-
for (const row of rows) updateWidths(row);
|
|
312
|
-
const codeStart = state.text.length;
|
|
313
|
-
const appendRow = (cells) => {
|
|
314
|
-
state.text += "|";
|
|
315
|
-
for (let i = 0; i < columnCount; i += 1) {
|
|
316
|
-
state.text += " ";
|
|
317
|
-
const cell = cells[i];
|
|
318
|
-
if (cell) appendCellTextOnly(state, cell);
|
|
319
|
-
const pad = widths[i] - (cell?.text.length ?? 0);
|
|
320
|
-
if (pad > 0) state.text += " ".repeat(pad);
|
|
321
|
-
state.text += " |";
|
|
322
|
-
}
|
|
323
|
-
state.text += "\n";
|
|
324
|
-
};
|
|
325
|
-
const appendDivider = () => {
|
|
326
|
-
state.text += "|";
|
|
327
|
-
for (let i = 0; i < columnCount; i += 1) {
|
|
328
|
-
const dashCount = Math.max(3, widths[i]);
|
|
329
|
-
state.text += ` ${"-".repeat(dashCount)} |`;
|
|
330
|
-
}
|
|
331
|
-
state.text += "\n";
|
|
332
|
-
};
|
|
333
|
-
appendRow(headers);
|
|
334
|
-
appendDivider();
|
|
335
|
-
for (const row of rows) appendRow(row);
|
|
336
|
-
const codeEnd = state.text.length;
|
|
337
|
-
if (codeEnd > codeStart) state.styles.push({
|
|
338
|
-
start: codeStart,
|
|
339
|
-
end: codeEnd,
|
|
340
|
-
style: "code_block"
|
|
341
|
-
});
|
|
342
|
-
if (state.env.listStack.length === 0) state.text += "\n";
|
|
343
|
-
}
|
|
344
|
-
function renderTokens(tokens, state) {
|
|
345
|
-
for (const token of tokens) switch (token.type) {
|
|
346
|
-
case "inline":
|
|
347
|
-
if (token.children) renderTokens(token.children, state);
|
|
348
|
-
break;
|
|
349
|
-
case "text":
|
|
350
|
-
appendText(state, token.content ?? "");
|
|
351
|
-
break;
|
|
352
|
-
case "em_open":
|
|
353
|
-
openStyle(state, "italic");
|
|
354
|
-
break;
|
|
355
|
-
case "em_close":
|
|
356
|
-
closeStyle(state, "italic");
|
|
357
|
-
break;
|
|
358
|
-
case "strong_open":
|
|
359
|
-
openStyle(state, "bold");
|
|
360
|
-
break;
|
|
361
|
-
case "strong_close":
|
|
362
|
-
closeStyle(state, "bold");
|
|
363
|
-
break;
|
|
364
|
-
case "s_open":
|
|
365
|
-
openStyle(state, "strikethrough");
|
|
366
|
-
break;
|
|
367
|
-
case "s_close":
|
|
368
|
-
closeStyle(state, "strikethrough");
|
|
369
|
-
break;
|
|
370
|
-
case "code_inline":
|
|
371
|
-
renderInlineCode(state, token.content ?? "");
|
|
372
|
-
break;
|
|
373
|
-
case "spoiler_open":
|
|
374
|
-
if (state.enableSpoilers) openStyle(state, "spoiler");
|
|
375
|
-
break;
|
|
376
|
-
case "spoiler_close":
|
|
377
|
-
if (state.enableSpoilers) closeStyle(state, "spoiler");
|
|
378
|
-
break;
|
|
379
|
-
case "link_open": {
|
|
380
|
-
const href = getAttr(token, "href") ?? "";
|
|
381
|
-
const target = resolveRenderTarget(state);
|
|
382
|
-
target.linkStack.push({
|
|
383
|
-
href,
|
|
384
|
-
labelStart: target.text.length
|
|
385
|
-
});
|
|
386
|
-
break;
|
|
387
|
-
}
|
|
388
|
-
case "link_close":
|
|
389
|
-
handleLinkClose(state);
|
|
390
|
-
break;
|
|
391
|
-
case "image":
|
|
392
|
-
appendText(state, token.content ?? "");
|
|
393
|
-
break;
|
|
394
|
-
case "softbreak":
|
|
395
|
-
case "hardbreak":
|
|
396
|
-
appendText(state, "\n");
|
|
397
|
-
break;
|
|
398
|
-
case "paragraph_close":
|
|
399
|
-
appendParagraphSeparator(state);
|
|
400
|
-
break;
|
|
401
|
-
case "heading_open":
|
|
402
|
-
if (state.headingStyle === "bold") openStyle(state, "bold");
|
|
403
|
-
break;
|
|
404
|
-
case "heading_close":
|
|
405
|
-
if (state.headingStyle === "bold") closeStyle(state, "bold");
|
|
406
|
-
appendParagraphSeparator(state);
|
|
407
|
-
break;
|
|
408
|
-
case "blockquote_open":
|
|
409
|
-
if (state.blockquotePrefix) state.text += state.blockquotePrefix;
|
|
410
|
-
openStyle(state, "blockquote");
|
|
411
|
-
break;
|
|
412
|
-
case "blockquote_close":
|
|
413
|
-
closeStyle(state, "blockquote");
|
|
414
|
-
break;
|
|
415
|
-
case "bullet_list_open":
|
|
416
|
-
if (state.env.listStack.length > 0) state.text += "\n";
|
|
417
|
-
state.env.listStack.push({
|
|
418
|
-
type: "bullet",
|
|
419
|
-
index: 0
|
|
420
|
-
});
|
|
421
|
-
break;
|
|
422
|
-
case "bullet_list_close":
|
|
423
|
-
state.env.listStack.pop();
|
|
424
|
-
if (state.env.listStack.length === 0) state.text += "\n";
|
|
425
|
-
break;
|
|
426
|
-
case "ordered_list_open": {
|
|
427
|
-
if (state.env.listStack.length > 0) state.text += "\n";
|
|
428
|
-
const start = Number(getAttr(token, "start") ?? "1");
|
|
429
|
-
state.env.listStack.push({
|
|
430
|
-
type: "ordered",
|
|
431
|
-
index: start - 1
|
|
432
|
-
});
|
|
433
|
-
break;
|
|
434
|
-
}
|
|
435
|
-
case "ordered_list_close":
|
|
436
|
-
state.env.listStack.pop();
|
|
437
|
-
if (state.env.listStack.length === 0) state.text += "\n";
|
|
438
|
-
break;
|
|
439
|
-
case "list_item_open":
|
|
440
|
-
appendListPrefix(state);
|
|
441
|
-
break;
|
|
442
|
-
case "list_item_close":
|
|
443
|
-
if (!state.text.endsWith("\n")) state.text += "\n";
|
|
444
|
-
break;
|
|
445
|
-
case "code_block":
|
|
446
|
-
case "fence":
|
|
447
|
-
renderCodeBlock(state, token.content ?? "");
|
|
448
|
-
break;
|
|
449
|
-
case "html_block":
|
|
450
|
-
case "html_inline":
|
|
451
|
-
appendText(state, token.content ?? "");
|
|
452
|
-
break;
|
|
453
|
-
case "table_open":
|
|
454
|
-
if (state.tableMode !== "off") {
|
|
455
|
-
state.table = initTableState();
|
|
456
|
-
state.hasTables = true;
|
|
457
|
-
}
|
|
458
|
-
break;
|
|
459
|
-
case "table_close":
|
|
460
|
-
if (state.table) {
|
|
461
|
-
if (state.tableMode === "bullets") renderTableAsBullets(state);
|
|
462
|
-
else if (state.tableMode === "code") renderTableAsCode(state);
|
|
463
|
-
}
|
|
464
|
-
state.table = null;
|
|
465
|
-
break;
|
|
466
|
-
case "thead_open":
|
|
467
|
-
if (state.table) state.table.inHeader = true;
|
|
468
|
-
break;
|
|
469
|
-
case "thead_close":
|
|
470
|
-
if (state.table) state.table.inHeader = false;
|
|
471
|
-
break;
|
|
472
|
-
case "tbody_open":
|
|
473
|
-
case "tbody_close": break;
|
|
474
|
-
case "tr_open":
|
|
475
|
-
if (state.table) state.table.currentRow = [];
|
|
476
|
-
break;
|
|
477
|
-
case "tr_close":
|
|
478
|
-
if (state.table) {
|
|
479
|
-
if (state.table.inHeader) state.table.headers = state.table.currentRow;
|
|
480
|
-
else state.table.rows.push(state.table.currentRow);
|
|
481
|
-
state.table.currentRow = [];
|
|
482
|
-
}
|
|
483
|
-
break;
|
|
484
|
-
case "th_open":
|
|
485
|
-
case "td_open":
|
|
486
|
-
if (state.table) state.table.currentCell = initRenderTarget();
|
|
487
|
-
break;
|
|
488
|
-
case "th_close":
|
|
489
|
-
case "td_close":
|
|
490
|
-
if (state.table?.currentCell) {
|
|
491
|
-
state.table.currentRow.push(finishTableCell(state.table.currentCell));
|
|
492
|
-
state.table.currentCell = null;
|
|
493
|
-
}
|
|
494
|
-
break;
|
|
495
|
-
case "hr":
|
|
496
|
-
state.text += "───\n\n";
|
|
497
|
-
break;
|
|
498
|
-
default:
|
|
499
|
-
if (token.children) renderTokens(token.children, state);
|
|
500
|
-
break;
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
function closeRemainingStyles(target) {
|
|
504
|
-
for (let i = target.openStyles.length - 1; i >= 0; i -= 1) {
|
|
505
|
-
const open = target.openStyles[i];
|
|
506
|
-
const end = target.text.length;
|
|
507
|
-
if (end > open.start) target.styles.push({
|
|
508
|
-
start: open.start,
|
|
509
|
-
end,
|
|
510
|
-
style: open.style
|
|
511
|
-
});
|
|
512
|
-
}
|
|
513
|
-
target.openStyles = [];
|
|
514
|
-
}
|
|
515
|
-
function clampStyleSpans(spans, maxLength) {
|
|
516
|
-
const clamped = [];
|
|
517
|
-
for (const span of spans) {
|
|
518
|
-
const start = Math.max(0, Math.min(span.start, maxLength));
|
|
519
|
-
const end = Math.max(start, Math.min(span.end, maxLength));
|
|
520
|
-
if (end > start) clamped.push({
|
|
521
|
-
start,
|
|
522
|
-
end,
|
|
523
|
-
style: span.style
|
|
524
|
-
});
|
|
525
|
-
}
|
|
526
|
-
return clamped;
|
|
527
|
-
}
|
|
528
|
-
function clampLinkSpans(spans, maxLength) {
|
|
529
|
-
const clamped = [];
|
|
530
|
-
for (const span of spans) {
|
|
531
|
-
const start = Math.max(0, Math.min(span.start, maxLength));
|
|
532
|
-
const end = Math.max(start, Math.min(span.end, maxLength));
|
|
533
|
-
if (end > start) clamped.push({
|
|
534
|
-
start,
|
|
535
|
-
end,
|
|
536
|
-
href: span.href
|
|
537
|
-
});
|
|
538
|
-
}
|
|
539
|
-
return clamped;
|
|
540
|
-
}
|
|
541
|
-
function mergeStyleSpans(spans) {
|
|
542
|
-
const sorted = [...spans].toSorted((a, b) => {
|
|
543
|
-
if (a.start !== b.start) return a.start - b.start;
|
|
544
|
-
if (a.end !== b.end) return a.end - b.end;
|
|
545
|
-
return a.style.localeCompare(b.style);
|
|
546
|
-
});
|
|
547
|
-
const merged = [];
|
|
548
|
-
for (const span of sorted) {
|
|
549
|
-
const prev = merged[merged.length - 1];
|
|
550
|
-
if (prev && prev.style === span.style && (span.start < prev.end || span.start === prev.end && span.style !== "blockquote")) {
|
|
551
|
-
prev.end = Math.max(prev.end, span.end);
|
|
552
|
-
continue;
|
|
553
|
-
}
|
|
554
|
-
merged.push({ ...span });
|
|
555
|
-
}
|
|
556
|
-
return merged;
|
|
557
|
-
}
|
|
558
|
-
function markdownToIRWithMeta(markdown, options = {}) {
|
|
559
|
-
const env = { listStack: [] };
|
|
560
|
-
const tokens = createMarkdownIt(options).parse(markdown ?? "", env);
|
|
561
|
-
if (options.enableSpoilers) applySpoilerTokens(tokens);
|
|
562
|
-
const tableMode = options.tableMode ?? "off";
|
|
563
|
-
const state = {
|
|
564
|
-
text: "",
|
|
565
|
-
styles: [],
|
|
566
|
-
openStyles: [],
|
|
567
|
-
links: [],
|
|
568
|
-
linkStack: [],
|
|
569
|
-
env,
|
|
570
|
-
headingStyle: options.headingStyle ?? "none",
|
|
571
|
-
blockquotePrefix: options.blockquotePrefix ?? "",
|
|
572
|
-
enableSpoilers: options.enableSpoilers ?? false,
|
|
573
|
-
tableMode,
|
|
574
|
-
table: null,
|
|
575
|
-
hasTables: false
|
|
576
|
-
};
|
|
577
|
-
renderTokens(tokens, state);
|
|
578
|
-
closeRemainingStyles(state);
|
|
579
|
-
const trimmedLength = state.text.trimEnd().length;
|
|
580
|
-
let codeBlockEnd = 0;
|
|
581
|
-
for (const span of state.styles) {
|
|
582
|
-
if (span.style !== "code_block") continue;
|
|
583
|
-
if (span.end > codeBlockEnd) codeBlockEnd = span.end;
|
|
584
|
-
}
|
|
585
|
-
const finalLength = Math.max(trimmedLength, codeBlockEnd);
|
|
586
|
-
return {
|
|
587
|
-
ir: {
|
|
588
|
-
text: finalLength === state.text.length ? state.text : state.text.slice(0, finalLength),
|
|
589
|
-
styles: mergeStyleSpans(clampStyleSpans(state.styles, finalLength)),
|
|
590
|
-
links: clampLinkSpans(state.links, finalLength)
|
|
591
|
-
},
|
|
592
|
-
hasTables: state.hasTables
|
|
593
|
-
};
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
//#endregion
|
|
597
|
-
//#region src/markdown/render.ts
|
|
598
|
-
const STYLE_RANK = new Map([
|
|
599
|
-
"blockquote",
|
|
600
|
-
"code_block",
|
|
601
|
-
"code",
|
|
602
|
-
"bold",
|
|
603
|
-
"italic",
|
|
604
|
-
"strikethrough",
|
|
605
|
-
"spoiler"
|
|
606
|
-
].map((style, index) => [style, index]));
|
|
607
|
-
function sortStyleSpans(spans) {
|
|
608
|
-
return [...spans].toSorted((a, b) => {
|
|
609
|
-
if (a.start !== b.start) return a.start - b.start;
|
|
610
|
-
if (a.end !== b.end) return b.end - a.end;
|
|
611
|
-
return (STYLE_RANK.get(a.style) ?? 0) - (STYLE_RANK.get(b.style) ?? 0);
|
|
612
|
-
});
|
|
613
|
-
}
|
|
614
|
-
function renderMarkdownWithMarkers(ir, options) {
|
|
615
|
-
const text = ir.text ?? "";
|
|
616
|
-
if (!text) return "";
|
|
617
|
-
const styleMarkers = options.styleMarkers;
|
|
618
|
-
const styled = sortStyleSpans(ir.styles.filter((span) => Boolean(styleMarkers[span.style])));
|
|
619
|
-
const boundaries = /* @__PURE__ */ new Set();
|
|
620
|
-
boundaries.add(0);
|
|
621
|
-
boundaries.add(text.length);
|
|
622
|
-
const startsAt = /* @__PURE__ */ new Map();
|
|
623
|
-
for (const span of styled) {
|
|
624
|
-
if (span.start === span.end) continue;
|
|
625
|
-
boundaries.add(span.start);
|
|
626
|
-
boundaries.add(span.end);
|
|
627
|
-
const bucket = startsAt.get(span.start);
|
|
628
|
-
if (bucket) bucket.push(span);
|
|
629
|
-
else startsAt.set(span.start, [span]);
|
|
630
|
-
}
|
|
631
|
-
for (const spans of startsAt.values()) spans.sort((a, b) => {
|
|
632
|
-
if (a.end !== b.end) return b.end - a.end;
|
|
633
|
-
return (STYLE_RANK.get(a.style) ?? 0) - (STYLE_RANK.get(b.style) ?? 0);
|
|
634
|
-
});
|
|
635
|
-
const linkStarts = /* @__PURE__ */ new Map();
|
|
636
|
-
if (options.buildLink) for (const link of ir.links) {
|
|
637
|
-
if (link.start === link.end) continue;
|
|
638
|
-
const rendered = options.buildLink(link, text);
|
|
639
|
-
if (!rendered) continue;
|
|
640
|
-
boundaries.add(rendered.start);
|
|
641
|
-
boundaries.add(rendered.end);
|
|
642
|
-
const openBucket = linkStarts.get(rendered.start);
|
|
643
|
-
if (openBucket) openBucket.push(rendered);
|
|
644
|
-
else linkStarts.set(rendered.start, [rendered]);
|
|
645
|
-
}
|
|
646
|
-
const points = [...boundaries].toSorted((a, b) => a - b);
|
|
647
|
-
const stack = [];
|
|
648
|
-
let out = "";
|
|
649
|
-
for (let i = 0; i < points.length; i += 1) {
|
|
650
|
-
const pos = points[i];
|
|
651
|
-
while (stack.length && stack[stack.length - 1]?.end === pos) {
|
|
652
|
-
const item = stack.pop();
|
|
653
|
-
if (item) out += item.close;
|
|
654
|
-
}
|
|
655
|
-
const openingItems = [];
|
|
656
|
-
const openingLinks = linkStarts.get(pos);
|
|
657
|
-
if (openingLinks && openingLinks.length > 0) for (const [index, link] of openingLinks.entries()) openingItems.push({
|
|
658
|
-
end: link.end,
|
|
659
|
-
open: link.open,
|
|
660
|
-
close: link.close,
|
|
661
|
-
kind: "link",
|
|
662
|
-
index
|
|
663
|
-
});
|
|
664
|
-
const openingStyles = startsAt.get(pos);
|
|
665
|
-
if (openingStyles) for (const [index, span] of openingStyles.entries()) {
|
|
666
|
-
const marker = styleMarkers[span.style];
|
|
667
|
-
if (!marker) continue;
|
|
668
|
-
openingItems.push({
|
|
669
|
-
end: span.end,
|
|
670
|
-
open: marker.open,
|
|
671
|
-
close: marker.close,
|
|
672
|
-
kind: "style",
|
|
673
|
-
style: span.style,
|
|
674
|
-
index
|
|
675
|
-
});
|
|
676
|
-
}
|
|
677
|
-
if (openingItems.length > 0) {
|
|
678
|
-
openingItems.sort((a, b) => {
|
|
679
|
-
if (a.end !== b.end) return b.end - a.end;
|
|
680
|
-
if (a.kind !== b.kind) return a.kind === "link" ? -1 : 1;
|
|
681
|
-
if (a.kind === "style" && b.kind === "style") return (STYLE_RANK.get(a.style) ?? 0) - (STYLE_RANK.get(b.style) ?? 0);
|
|
682
|
-
return a.index - b.index;
|
|
683
|
-
});
|
|
684
|
-
for (const item of openingItems) {
|
|
685
|
-
out += item.open;
|
|
686
|
-
stack.push({
|
|
687
|
-
close: item.close,
|
|
688
|
-
end: item.end
|
|
689
|
-
});
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
const next = points[i + 1];
|
|
693
|
-
if (next === void 0) break;
|
|
694
|
-
if (next > pos) out += options.escapeText(text.slice(pos, next));
|
|
695
|
-
}
|
|
696
|
-
return out;
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
//#endregion
|
|
700
|
-
//#region src/markdown/tables.ts
|
|
701
|
-
const MARKDOWN_STYLE_MARKERS = {
|
|
702
|
-
bold: {
|
|
703
|
-
open: "**",
|
|
704
|
-
close: "**"
|
|
705
|
-
},
|
|
706
|
-
italic: {
|
|
707
|
-
open: "_",
|
|
708
|
-
close: "_"
|
|
709
|
-
},
|
|
710
|
-
strikethrough: {
|
|
711
|
-
open: "~~",
|
|
712
|
-
close: "~~"
|
|
713
|
-
},
|
|
714
|
-
code: {
|
|
715
|
-
open: "`",
|
|
716
|
-
close: "`"
|
|
717
|
-
},
|
|
718
|
-
code_block: {
|
|
719
|
-
open: "```\n",
|
|
720
|
-
close: "```"
|
|
721
|
-
}
|
|
722
|
-
};
|
|
723
|
-
function convertMarkdownTables(markdown, mode) {
|
|
724
|
-
if (!markdown || mode === "off") return markdown;
|
|
725
|
-
const { ir, hasTables } = markdownToIRWithMeta(markdown, {
|
|
726
|
-
linkify: false,
|
|
727
|
-
autolink: false,
|
|
728
|
-
headingStyle: "none",
|
|
729
|
-
blockquotePrefix: "",
|
|
730
|
-
tableMode: mode
|
|
731
|
-
});
|
|
732
|
-
if (!hasTables) return markdown;
|
|
733
|
-
return renderMarkdownWithMarkers(ir, {
|
|
734
|
-
styleMarkers: MARKDOWN_STYLE_MARKERS,
|
|
735
|
-
escapeText: (text) => text,
|
|
736
|
-
buildLink: (link, text) => {
|
|
737
|
-
const href = link.href.trim();
|
|
738
|
-
if (!href) return null;
|
|
739
|
-
if (!text.slice(link.start, link.end)) return null;
|
|
740
|
-
return {
|
|
741
|
-
start: link.start,
|
|
742
|
-
end: link.end,
|
|
743
|
-
open: "[",
|
|
744
|
-
close: `](${href})`
|
|
745
|
-
};
|
|
746
|
-
}
|
|
747
|
-
});
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
//#endregion
|
|
751
|
-
//#region src/markdown/whatsapp.ts
|
|
752
|
-
/**
|
|
753
|
-
* Convert standard Markdown formatting to WhatsApp-compatible markup.
|
|
754
|
-
*
|
|
755
|
-
* WhatsApp uses its own formatting syntax:
|
|
756
|
-
* bold: *text*
|
|
757
|
-
* italic: _text_
|
|
758
|
-
* strikethrough: ~text~
|
|
759
|
-
* monospace: ```text```
|
|
760
|
-
*
|
|
761
|
-
* Standard Markdown uses:
|
|
762
|
-
* bold: **text** or __text__
|
|
763
|
-
* italic: *text* or _text_
|
|
764
|
-
* strikethrough: ~~text~~
|
|
765
|
-
* code: `text` (inline) or ```text``` (block)
|
|
766
|
-
*
|
|
767
|
-
* The conversion preserves fenced code blocks and inline code,
|
|
768
|
-
* then converts bold and strikethrough markers.
|
|
769
|
-
*/
|
|
770
|
-
/** Placeholder tokens used during conversion to protect code spans. */
|
|
771
|
-
const FENCE_PLACEHOLDER = "\0FENCE";
|
|
772
|
-
const INLINE_CODE_PLACEHOLDER = "\0CODE";
|
|
773
|
-
/**
|
|
774
|
-
* Convert standard Markdown bold/italic/strikethrough to WhatsApp formatting.
|
|
775
|
-
*
|
|
776
|
-
* Order of operations matters:
|
|
777
|
-
* 1. Protect fenced code blocks (```...```) — already WhatsApp-compatible
|
|
778
|
-
* 2. Protect inline code (`...`) — leave as-is
|
|
779
|
-
* 3. Convert **bold** → *bold* and __bold__ → *bold*
|
|
780
|
-
* 4. Convert ~~strike~~ → ~strike~
|
|
781
|
-
* 5. Restore protected spans
|
|
782
|
-
*
|
|
783
|
-
* Italic *text* and _text_ are left alone since WhatsApp uses _text_ for italic
|
|
784
|
-
* and single * is already WhatsApp bold — no conversion needed for single markers.
|
|
785
|
-
*/
|
|
786
|
-
function markdownToWhatsApp(text) {
|
|
787
|
-
if (!text) return text;
|
|
788
|
-
const fences = [];
|
|
789
|
-
let result = text.replace(/```[\s\S]*?```/g, (match) => {
|
|
790
|
-
fences.push(match);
|
|
791
|
-
return `${FENCE_PLACEHOLDER}${fences.length - 1}`;
|
|
792
|
-
});
|
|
793
|
-
const inlineCodes = [];
|
|
794
|
-
result = result.replace(/`[^`\n]+`/g, (match) => {
|
|
795
|
-
inlineCodes.push(match);
|
|
796
|
-
return `${INLINE_CODE_PLACEHOLDER}${inlineCodes.length - 1}`;
|
|
797
|
-
});
|
|
798
|
-
result = result.replace(/\*\*(.+?)\*\*/g, "*$1*");
|
|
799
|
-
result = result.replace(/__(.+?)__/g, "*$1*");
|
|
800
|
-
result = result.replace(/~~(.+?)~~/g, "~$1~");
|
|
801
|
-
result = result.replace(new RegExp(`${escapeRegExp(INLINE_CODE_PLACEHOLDER)}(\\d+)`, "g"), (_, idx) => inlineCodes[Number(idx)] ?? "");
|
|
802
|
-
result = result.replace(new RegExp(`${escapeRegExp(FENCE_PLACEHOLDER)}(\\d+)`, "g"), (_, idx) => fences[Number(idx)] ?? "");
|
|
803
|
-
return result;
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
//#endregion
|
|
807
|
-
//#region src/polls.ts
|
|
808
|
-
function normalizePollInput(input, options = {}) {
|
|
809
|
-
const question = input.question.trim();
|
|
810
|
-
if (!question) throw new Error("Poll question is required");
|
|
811
|
-
const cleaned = (input.options ?? []).map((option) => option.trim()).filter(Boolean);
|
|
812
|
-
if (cleaned.length < 2) throw new Error("Poll requires at least 2 options");
|
|
813
|
-
if (options.maxOptions !== void 0 && cleaned.length > options.maxOptions) throw new Error(`Poll supports at most ${options.maxOptions} options`);
|
|
814
|
-
const maxSelectionsRaw = input.maxSelections;
|
|
815
|
-
const maxSelections = typeof maxSelectionsRaw === "number" && Number.isFinite(maxSelectionsRaw) ? Math.floor(maxSelectionsRaw) : 1;
|
|
816
|
-
if (maxSelections < 1) throw new Error("maxSelections must be at least 1");
|
|
817
|
-
if (maxSelections > cleaned.length) throw new Error("maxSelections cannot exceed option count");
|
|
818
|
-
const durationSecondsRaw = input.durationSeconds;
|
|
819
|
-
const durationSeconds = typeof durationSecondsRaw === "number" && Number.isFinite(durationSecondsRaw) ? Math.floor(durationSecondsRaw) : void 0;
|
|
820
|
-
if (durationSeconds !== void 0 && durationSeconds < 1) throw new Error("durationSeconds must be at least 1");
|
|
821
|
-
const durationRaw = input.durationHours;
|
|
822
|
-
const durationHours = typeof durationRaw === "number" && Number.isFinite(durationRaw) ? Math.floor(durationRaw) : void 0;
|
|
823
|
-
if (durationHours !== void 0 && durationHours < 1) throw new Error("durationHours must be at least 1");
|
|
824
|
-
if (durationSeconds !== void 0 && durationHours !== void 0) throw new Error("durationSeconds and durationHours are mutually exclusive");
|
|
825
|
-
return {
|
|
826
|
-
question,
|
|
827
|
-
options: cleaned,
|
|
828
|
-
maxSelections,
|
|
829
|
-
durationSeconds,
|
|
830
|
-
durationHours
|
|
831
|
-
};
|
|
832
|
-
}
|
|
833
|
-
|
|
834
|
-
//#endregion
|
|
835
|
-
//#region src/web/active-listener.ts
|
|
836
|
-
const listeners = /* @__PURE__ */ new Map();
|
|
837
|
-
function resolveWebAccountId(accountId) {
|
|
838
|
-
return (accountId ?? "").trim() || DEFAULT_ACCOUNT_ID;
|
|
839
|
-
}
|
|
840
|
-
function requireActiveWebListener(accountId) {
|
|
841
|
-
const id = resolveWebAccountId(accountId);
|
|
842
|
-
const listener = listeners.get(id) ?? null;
|
|
843
|
-
if (!listener) throw new Error(`No active WhatsApp Web listener (account: ${id}). Start the gateway, then link WhatsApp with: ${formatCliCommand(`anima channels login --channel whatsapp --account ${id}`)}.`);
|
|
844
|
-
return {
|
|
845
|
-
accountId: id,
|
|
846
|
-
listener
|
|
847
|
-
};
|
|
848
|
-
}
|
|
849
|
-
function setActiveWebListener(accountIdOrListener, maybeListener) {
|
|
850
|
-
const { accountId, listener } = typeof accountIdOrListener === "string" ? {
|
|
851
|
-
accountId: accountIdOrListener,
|
|
852
|
-
listener: maybeListener ?? null
|
|
853
|
-
} : {
|
|
854
|
-
accountId: DEFAULT_ACCOUNT_ID,
|
|
855
|
-
listener: accountIdOrListener ?? null
|
|
856
|
-
};
|
|
857
|
-
const id = resolveWebAccountId(accountId);
|
|
858
|
-
if (!listener) listeners.delete(id);
|
|
859
|
-
else listeners.set(id, listener);
|
|
860
|
-
if (id === DEFAULT_ACCOUNT_ID) {}
|
|
861
|
-
}
|
|
862
|
-
function getActiveWebListener(accountId) {
|
|
863
|
-
const id = resolveWebAccountId(accountId);
|
|
864
|
-
return listeners.get(id) ?? null;
|
|
865
|
-
}
|
|
866
|
-
|
|
867
|
-
//#endregion
|
|
868
|
-
//#region src/utils/fetch-timeout.ts
|
|
869
|
-
/**
|
|
870
|
-
* Relay abort without forwarding the Event argument as the abort reason.
|
|
871
|
-
* Using .bind() avoids closure scope capture (memory leak prevention).
|
|
872
|
-
*/
|
|
873
|
-
function relayAbort() {
|
|
874
|
-
this.abort();
|
|
875
|
-
}
|
|
876
|
-
/** Returns a bound abort relay for use as an event listener. */
|
|
877
|
-
function bindAbortRelay(controller) {
|
|
878
|
-
return relayAbort.bind(controller);
|
|
879
|
-
}
|
|
880
|
-
|
|
881
|
-
//#endregion
|
|
882
|
-
//#region src/infra/net/ssrf.ts
|
|
883
|
-
var SsrFBlockedError = class extends Error {
|
|
884
|
-
constructor(message) {
|
|
885
|
-
super(message);
|
|
886
|
-
this.name = "SsrFBlockedError";
|
|
887
|
-
}
|
|
888
|
-
};
|
|
889
|
-
const BLOCKED_HOSTNAMES = new Set(["localhost", "metadata.google.internal"]);
|
|
890
|
-
function normalizeHostname(hostname) {
|
|
891
|
-
const normalized = hostname.trim().toLowerCase().replace(/\.$/, "");
|
|
892
|
-
if (normalized.startsWith("[") && normalized.endsWith("]")) return normalized.slice(1, -1);
|
|
893
|
-
return normalized;
|
|
894
|
-
}
|
|
895
|
-
function normalizeHostnameSet(values) {
|
|
896
|
-
if (!values || values.length === 0) return /* @__PURE__ */ new Set();
|
|
897
|
-
return new Set(values.map((value) => normalizeHostname(value)).filter(Boolean));
|
|
898
|
-
}
|
|
899
|
-
function normalizeHostnameAllowlist(values) {
|
|
900
|
-
if (!values || values.length === 0) return [];
|
|
901
|
-
return Array.from(new Set(values.map((value) => normalizeHostname(value)).filter((value) => value !== "*" && value !== "*." && value.length > 0)));
|
|
902
|
-
}
|
|
903
|
-
function isHostnameAllowedByPattern(hostname, pattern) {
|
|
904
|
-
if (pattern.startsWith("*.")) {
|
|
905
|
-
const suffix = pattern.slice(2);
|
|
906
|
-
if (!suffix || hostname === suffix) return false;
|
|
907
|
-
return hostname.endsWith(`.${suffix}`);
|
|
908
|
-
}
|
|
909
|
-
return hostname === pattern;
|
|
910
|
-
}
|
|
911
|
-
function matchesHostnameAllowlist(hostname, allowlist) {
|
|
912
|
-
if (allowlist.length === 0) return true;
|
|
913
|
-
return allowlist.some((pattern) => isHostnameAllowedByPattern(hostname, pattern));
|
|
914
|
-
}
|
|
915
|
-
function parseIpv4(address) {
|
|
916
|
-
const parts = address.split(".");
|
|
917
|
-
if (parts.length !== 4) return null;
|
|
918
|
-
const numbers = parts.map((part) => Number.parseInt(part, 10));
|
|
919
|
-
if (numbers.some((value) => Number.isNaN(value) || value < 0 || value > 255)) return null;
|
|
920
|
-
return numbers;
|
|
921
|
-
}
|
|
922
|
-
function stripIpv6ZoneId(address) {
|
|
923
|
-
const index = address.indexOf("%");
|
|
924
|
-
return index >= 0 ? address.slice(0, index) : address;
|
|
925
|
-
}
|
|
926
|
-
function parseIpv6Hextets(address) {
|
|
927
|
-
let input = stripIpv6ZoneId(address.trim().toLowerCase());
|
|
928
|
-
if (!input) return null;
|
|
929
|
-
if (input.includes(".")) {
|
|
930
|
-
const lastColon = input.lastIndexOf(":");
|
|
931
|
-
if (lastColon < 0) return null;
|
|
932
|
-
const ipv4 = parseIpv4(input.slice(lastColon + 1));
|
|
933
|
-
if (!ipv4) return null;
|
|
934
|
-
const high = (ipv4[0] << 8) + ipv4[1];
|
|
935
|
-
const low = (ipv4[2] << 8) + ipv4[3];
|
|
936
|
-
input = `${input.slice(0, lastColon)}:${high.toString(16)}:${low.toString(16)}`;
|
|
937
|
-
}
|
|
938
|
-
const doubleColonParts = input.split("::");
|
|
939
|
-
if (doubleColonParts.length > 2) return null;
|
|
940
|
-
const headParts = doubleColonParts[0]?.length > 0 ? doubleColonParts[0].split(":").filter(Boolean) : [];
|
|
941
|
-
const tailParts = doubleColonParts.length === 2 && doubleColonParts[1]?.length > 0 ? doubleColonParts[1].split(":").filter(Boolean) : [];
|
|
942
|
-
const missingParts = 8 - headParts.length - tailParts.length;
|
|
943
|
-
if (missingParts < 0) return null;
|
|
944
|
-
const fullParts = doubleColonParts.length === 1 ? input.split(":") : [
|
|
945
|
-
...headParts,
|
|
946
|
-
...Array.from({ length: missingParts }, () => "0"),
|
|
947
|
-
...tailParts
|
|
948
|
-
];
|
|
949
|
-
if (fullParts.length !== 8) return null;
|
|
950
|
-
const hextets = [];
|
|
951
|
-
for (const part of fullParts) {
|
|
952
|
-
if (!part) return null;
|
|
953
|
-
const value = Number.parseInt(part, 16);
|
|
954
|
-
if (Number.isNaN(value) || value < 0 || value > 65535) return null;
|
|
955
|
-
hextets.push(value);
|
|
956
|
-
}
|
|
957
|
-
return hextets;
|
|
958
|
-
}
|
|
959
|
-
function extractIpv4FromEmbeddedIpv6(hextets) {
|
|
960
|
-
if (!(hextets[0] === 0 && hextets[1] === 0 && hextets[2] === 0 && hextets[3] === 0) || hextets[4] !== 0) return null;
|
|
961
|
-
if (hextets[5] !== 65535 && hextets[5] !== 0) return null;
|
|
962
|
-
const high = hextets[6];
|
|
963
|
-
const low = hextets[7];
|
|
964
|
-
return [
|
|
965
|
-
high >>> 8 & 255,
|
|
966
|
-
high & 255,
|
|
967
|
-
low >>> 8 & 255,
|
|
968
|
-
low & 255
|
|
969
|
-
];
|
|
970
|
-
}
|
|
971
|
-
function isPrivateIpv4(parts) {
|
|
972
|
-
const [octet1, octet2] = parts;
|
|
973
|
-
if (octet1 === 0) return true;
|
|
974
|
-
if (octet1 === 10) return true;
|
|
975
|
-
if (octet1 === 127) return true;
|
|
976
|
-
if (octet1 === 169 && octet2 === 254) return true;
|
|
977
|
-
if (octet1 === 172 && octet2 >= 16 && octet2 <= 31) return true;
|
|
978
|
-
if (octet1 === 192 && octet2 === 168) return true;
|
|
979
|
-
if (octet1 === 100 && octet2 >= 64 && octet2 <= 127) return true;
|
|
980
|
-
return false;
|
|
981
|
-
}
|
|
982
|
-
function isPrivateIpAddress(address) {
|
|
983
|
-
let normalized = address.trim().toLowerCase();
|
|
984
|
-
if (normalized.startsWith("[") && normalized.endsWith("]")) normalized = normalized.slice(1, -1);
|
|
985
|
-
if (!normalized) return false;
|
|
986
|
-
if (normalized.includes(":")) {
|
|
987
|
-
const hextets = parseIpv6Hextets(normalized);
|
|
988
|
-
if (!hextets) return false;
|
|
989
|
-
const isUnspecified = hextets[0] === 0 && hextets[1] === 0 && hextets[2] === 0 && hextets[3] === 0 && hextets[4] === 0 && hextets[5] === 0 && hextets[6] === 0 && hextets[7] === 0;
|
|
990
|
-
const isLoopback = hextets[0] === 0 && hextets[1] === 0 && hextets[2] === 0 && hextets[3] === 0 && hextets[4] === 0 && hextets[5] === 0 && hextets[6] === 0 && hextets[7] === 1;
|
|
991
|
-
if (isUnspecified || isLoopback) return true;
|
|
992
|
-
const embeddedIpv4 = extractIpv4FromEmbeddedIpv6(hextets);
|
|
993
|
-
if (embeddedIpv4) return isPrivateIpv4(embeddedIpv4);
|
|
994
|
-
const first = hextets[0];
|
|
995
|
-
if ((first & 65472) === 65152) return true;
|
|
996
|
-
if ((first & 65472) === 65216) return true;
|
|
997
|
-
if ((first & 65024) === 64512) return true;
|
|
998
|
-
return false;
|
|
999
|
-
}
|
|
1000
|
-
const ipv4 = parseIpv4(normalized);
|
|
1001
|
-
if (!ipv4) return false;
|
|
1002
|
-
return isPrivateIpv4(ipv4);
|
|
1003
|
-
}
|
|
1004
|
-
function isBlockedHostname(hostname) {
|
|
1005
|
-
const normalized = normalizeHostname(hostname);
|
|
1006
|
-
if (!normalized) return false;
|
|
1007
|
-
if (BLOCKED_HOSTNAMES.has(normalized)) return true;
|
|
1008
|
-
return normalized.endsWith(".localhost") || normalized.endsWith(".local") || normalized.endsWith(".internal");
|
|
1009
|
-
}
|
|
1010
|
-
function createPinnedLookup(params) {
|
|
1011
|
-
const normalizedHost = normalizeHostname(params.hostname);
|
|
1012
|
-
const fallback = params.fallback ?? lookup;
|
|
1013
|
-
const fallbackLookup = fallback;
|
|
1014
|
-
const fallbackWithOptions = fallback;
|
|
1015
|
-
const records = params.addresses.map((address) => ({
|
|
1016
|
-
address,
|
|
1017
|
-
family: address.includes(":") ? 6 : 4
|
|
1018
|
-
}));
|
|
1019
|
-
let index = 0;
|
|
1020
|
-
return ((host, options, callback) => {
|
|
1021
|
-
const cb = typeof options === "function" ? options : callback;
|
|
1022
|
-
if (!cb) return;
|
|
1023
|
-
const normalized = normalizeHostname(host);
|
|
1024
|
-
if (!normalized || normalized !== normalizedHost) {
|
|
1025
|
-
if (typeof options === "function" || options === void 0) return fallbackLookup(host, cb);
|
|
1026
|
-
return fallbackWithOptions(host, options, cb);
|
|
1027
|
-
}
|
|
1028
|
-
const opts = typeof options === "object" && options !== null ? options : {};
|
|
1029
|
-
const requestedFamily = typeof options === "number" ? options : typeof opts.family === "number" ? opts.family : 0;
|
|
1030
|
-
const candidates = requestedFamily === 4 || requestedFamily === 6 ? records.filter((entry) => entry.family === requestedFamily) : records;
|
|
1031
|
-
const usable = candidates.length > 0 ? candidates : records;
|
|
1032
|
-
if (opts.all) {
|
|
1033
|
-
cb(null, usable);
|
|
1034
|
-
return;
|
|
1035
|
-
}
|
|
1036
|
-
const chosen = usable[index % usable.length];
|
|
1037
|
-
index += 1;
|
|
1038
|
-
cb(null, chosen.address, chosen.family);
|
|
1039
|
-
});
|
|
1040
|
-
}
|
|
1041
|
-
async function resolvePinnedHostnameWithPolicy(hostname, params = {}) {
|
|
1042
|
-
const normalized = normalizeHostname(hostname);
|
|
1043
|
-
if (!normalized) throw new Error("Invalid hostname");
|
|
1044
|
-
const allowPrivateNetwork = Boolean(params.policy?.allowPrivateNetwork);
|
|
1045
|
-
const allowedHostnames = normalizeHostnameSet(params.policy?.allowedHostnames);
|
|
1046
|
-
const hostnameAllowlist = normalizeHostnameAllowlist(params.policy?.hostnameAllowlist);
|
|
1047
|
-
const isExplicitAllowed = allowedHostnames.has(normalized);
|
|
1048
|
-
if (!matchesHostnameAllowlist(normalized, hostnameAllowlist)) throw new SsrFBlockedError(`Blocked hostname (not in allowlist): ${hostname}`);
|
|
1049
|
-
if (!allowPrivateNetwork && !isExplicitAllowed) {
|
|
1050
|
-
if (isBlockedHostname(normalized)) throw new SsrFBlockedError(`Blocked hostname: ${hostname}`);
|
|
1051
|
-
if (isPrivateIpAddress(normalized)) throw new SsrFBlockedError("Blocked: private/internal IP address");
|
|
1052
|
-
}
|
|
1053
|
-
const results = await (params.lookupFn ?? lookup$1)(normalized, { all: true });
|
|
1054
|
-
if (results.length === 0) throw new Error(`Unable to resolve hostname: ${hostname}`);
|
|
1055
|
-
if (!allowPrivateNetwork && !isExplicitAllowed) {
|
|
1056
|
-
for (const entry of results) if (isPrivateIpAddress(entry.address)) throw new SsrFBlockedError("Blocked: resolves to private/internal IP address");
|
|
1057
|
-
}
|
|
1058
|
-
const addresses = Array.from(new Set(results.map((entry) => entry.address)));
|
|
1059
|
-
if (addresses.length === 0) throw new Error(`Unable to resolve hostname: ${hostname}`);
|
|
1060
|
-
return {
|
|
1061
|
-
hostname: normalized,
|
|
1062
|
-
addresses,
|
|
1063
|
-
lookup: createPinnedLookup({
|
|
1064
|
-
hostname: normalized,
|
|
1065
|
-
addresses
|
|
1066
|
-
})
|
|
1067
|
-
};
|
|
1068
|
-
}
|
|
1069
|
-
function createPinnedDispatcher(pinned) {
|
|
1070
|
-
return new Agent({ connect: { lookup: pinned.lookup } });
|
|
1071
|
-
}
|
|
1072
|
-
async function closeDispatcher(dispatcher) {
|
|
1073
|
-
if (!dispatcher) return;
|
|
1074
|
-
const candidate = dispatcher;
|
|
1075
|
-
try {
|
|
1076
|
-
if (typeof candidate.close === "function") {
|
|
1077
|
-
await candidate.close();
|
|
1078
|
-
return;
|
|
1079
|
-
}
|
|
1080
|
-
if (typeof candidate.destroy === "function") candidate.destroy();
|
|
1081
|
-
} catch {}
|
|
1082
|
-
}
|
|
1083
|
-
|
|
1084
|
-
//#endregion
|
|
1085
|
-
//#region src/infra/net/fetch-guard.ts
|
|
1086
|
-
const DEFAULT_MAX_REDIRECTS = 3;
|
|
1087
|
-
function isRedirectStatus(status) {
|
|
1088
|
-
return status === 301 || status === 302 || status === 303 || status === 307 || status === 308;
|
|
1089
|
-
}
|
|
1090
|
-
function buildAbortSignal(params) {
|
|
1091
|
-
const { timeoutMs, signal } = params;
|
|
1092
|
-
if (!timeoutMs && !signal) return {
|
|
1093
|
-
signal: void 0,
|
|
1094
|
-
cleanup: () => {}
|
|
1095
|
-
};
|
|
1096
|
-
if (!timeoutMs) return {
|
|
1097
|
-
signal,
|
|
1098
|
-
cleanup: () => {}
|
|
1099
|
-
};
|
|
1100
|
-
const controller = new AbortController();
|
|
1101
|
-
const timeoutId = setTimeout(controller.abort.bind(controller), timeoutMs);
|
|
1102
|
-
const onAbort = bindAbortRelay(controller);
|
|
1103
|
-
if (signal) if (signal.aborted) controller.abort();
|
|
1104
|
-
else signal.addEventListener("abort", onAbort, { once: true });
|
|
1105
|
-
const cleanup = () => {
|
|
1106
|
-
clearTimeout(timeoutId);
|
|
1107
|
-
if (signal) signal.removeEventListener("abort", onAbort);
|
|
1108
|
-
};
|
|
1109
|
-
return {
|
|
1110
|
-
signal: controller.signal,
|
|
1111
|
-
cleanup
|
|
1112
|
-
};
|
|
1113
|
-
}
|
|
1114
|
-
async function fetchWithSsrFGuard(params) {
|
|
1115
|
-
const fetcher = params.fetchImpl ?? globalThis.fetch;
|
|
1116
|
-
if (!fetcher) throw new Error("fetch is not available");
|
|
1117
|
-
const maxRedirects = typeof params.maxRedirects === "number" && Number.isFinite(params.maxRedirects) ? Math.max(0, Math.floor(params.maxRedirects)) : DEFAULT_MAX_REDIRECTS;
|
|
1118
|
-
const { signal, cleanup } = buildAbortSignal({
|
|
1119
|
-
timeoutMs: params.timeoutMs,
|
|
1120
|
-
signal: params.signal
|
|
1121
|
-
});
|
|
1122
|
-
let released = false;
|
|
1123
|
-
const release = async (dispatcher) => {
|
|
1124
|
-
if (released) return;
|
|
1125
|
-
released = true;
|
|
1126
|
-
cleanup();
|
|
1127
|
-
await closeDispatcher(dispatcher ?? void 0);
|
|
1128
|
-
};
|
|
1129
|
-
const visited = /* @__PURE__ */ new Set();
|
|
1130
|
-
let currentUrl = params.url;
|
|
1131
|
-
let redirectCount = 0;
|
|
1132
|
-
while (true) {
|
|
1133
|
-
let parsedUrl;
|
|
1134
|
-
try {
|
|
1135
|
-
parsedUrl = new URL(currentUrl);
|
|
1136
|
-
} catch {
|
|
1137
|
-
await release();
|
|
1138
|
-
throw new Error("Invalid URL: must be http or https");
|
|
1139
|
-
}
|
|
1140
|
-
if (!["http:", "https:"].includes(parsedUrl.protocol)) {
|
|
1141
|
-
await release();
|
|
1142
|
-
throw new Error("Invalid URL: must be http or https");
|
|
1143
|
-
}
|
|
1144
|
-
let dispatcher = null;
|
|
1145
|
-
try {
|
|
1146
|
-
const pinned = await resolvePinnedHostnameWithPolicy(parsedUrl.hostname, {
|
|
1147
|
-
lookupFn: params.lookupFn,
|
|
1148
|
-
policy: params.policy
|
|
1149
|
-
});
|
|
1150
|
-
if (params.pinDns !== false) dispatcher = createPinnedDispatcher(pinned);
|
|
1151
|
-
const init = {
|
|
1152
|
-
...params.init ? { ...params.init } : {},
|
|
1153
|
-
redirect: "manual",
|
|
1154
|
-
...dispatcher ? { dispatcher } : {},
|
|
1155
|
-
...signal ? { signal } : {}
|
|
1156
|
-
};
|
|
1157
|
-
const response = await fetcher(parsedUrl.toString(), init);
|
|
1158
|
-
if (isRedirectStatus(response.status)) {
|
|
1159
|
-
const location = response.headers.get("location");
|
|
1160
|
-
if (!location) {
|
|
1161
|
-
await release(dispatcher);
|
|
1162
|
-
throw new Error(`Redirect missing location header (${response.status})`);
|
|
1163
|
-
}
|
|
1164
|
-
redirectCount += 1;
|
|
1165
|
-
if (redirectCount > maxRedirects) {
|
|
1166
|
-
await release(dispatcher);
|
|
1167
|
-
throw new Error(`Too many redirects (limit: ${maxRedirects})`);
|
|
1168
|
-
}
|
|
1169
|
-
const nextUrl = new URL(location, parsedUrl).toString();
|
|
1170
|
-
if (visited.has(nextUrl)) {
|
|
1171
|
-
await release(dispatcher);
|
|
1172
|
-
throw new Error("Redirect loop detected");
|
|
1173
|
-
}
|
|
1174
|
-
visited.add(nextUrl);
|
|
1175
|
-
response.body?.cancel();
|
|
1176
|
-
await closeDispatcher(dispatcher);
|
|
1177
|
-
currentUrl = nextUrl;
|
|
1178
|
-
continue;
|
|
1179
|
-
}
|
|
1180
|
-
return {
|
|
1181
|
-
response,
|
|
1182
|
-
finalUrl: currentUrl,
|
|
1183
|
-
release: async () => release(dispatcher)
|
|
1184
|
-
};
|
|
1185
|
-
} catch (err) {
|
|
1186
|
-
if (err instanceof SsrFBlockedError) logWarn(`security: blocked URL fetch (${params.auditContext ?? "url-fetch"}) target=${parsedUrl.origin}${parsedUrl.pathname} reason=${err.message}`);
|
|
1187
|
-
await release(dispatcher);
|
|
1188
|
-
throw err;
|
|
1189
|
-
}
|
|
1190
|
-
}
|
|
1191
|
-
}
|
|
1192
|
-
|
|
1193
|
-
//#endregion
|
|
1194
|
-
//#region src/media/read-response-with-limit.ts
|
|
1195
|
-
async function readResponseWithLimit(res, maxBytes, opts) {
|
|
1196
|
-
const onOverflow = opts?.onOverflow ?? ((params) => /* @__PURE__ */ new Error(`Content too large: ${params.size} bytes (limit: ${params.maxBytes} bytes)`));
|
|
1197
|
-
const body = res.body;
|
|
1198
|
-
if (!body || typeof body.getReader !== "function") {
|
|
1199
|
-
const fallback = Buffer.from(await res.arrayBuffer());
|
|
1200
|
-
if (fallback.length > maxBytes) throw onOverflow({
|
|
1201
|
-
size: fallback.length,
|
|
1202
|
-
maxBytes,
|
|
1203
|
-
res
|
|
1204
|
-
});
|
|
1205
|
-
return fallback;
|
|
1206
|
-
}
|
|
1207
|
-
const reader = body.getReader();
|
|
1208
|
-
const chunks = [];
|
|
1209
|
-
let total = 0;
|
|
1210
|
-
try {
|
|
1211
|
-
while (true) {
|
|
1212
|
-
const { done, value } = await reader.read();
|
|
1213
|
-
if (done) break;
|
|
1214
|
-
if (value?.length) {
|
|
1215
|
-
total += value.length;
|
|
1216
|
-
if (total > maxBytes) {
|
|
1217
|
-
try {
|
|
1218
|
-
await reader.cancel();
|
|
1219
|
-
} catch {}
|
|
1220
|
-
throw onOverflow({
|
|
1221
|
-
size: total,
|
|
1222
|
-
maxBytes,
|
|
1223
|
-
res
|
|
1224
|
-
});
|
|
1225
|
-
}
|
|
1226
|
-
chunks.push(value);
|
|
1227
|
-
}
|
|
1228
|
-
}
|
|
1229
|
-
} finally {
|
|
1230
|
-
try {
|
|
1231
|
-
reader.releaseLock();
|
|
1232
|
-
} catch {}
|
|
1233
|
-
}
|
|
1234
|
-
return Buffer.concat(chunks.map((chunk) => Buffer.from(chunk)), total);
|
|
1235
|
-
}
|
|
1236
|
-
|
|
1237
|
-
//#endregion
|
|
1238
|
-
//#region src/media/fetch.ts
|
|
1239
|
-
var MediaFetchError = class extends Error {
|
|
1240
|
-
constructor(code, message) {
|
|
1241
|
-
super(message);
|
|
1242
|
-
this.code = code;
|
|
1243
|
-
this.name = "MediaFetchError";
|
|
1244
|
-
}
|
|
1245
|
-
};
|
|
1246
|
-
function stripQuotes(value) {
|
|
1247
|
-
return value.replace(/^["']|["']$/g, "");
|
|
1248
|
-
}
|
|
1249
|
-
function parseContentDispositionFileName(header) {
|
|
1250
|
-
if (!header) return;
|
|
1251
|
-
const starMatch = /filename\*\s*=\s*([^;]+)/i.exec(header);
|
|
1252
|
-
if (starMatch?.[1]) {
|
|
1253
|
-
const cleaned = stripQuotes(starMatch[1].trim());
|
|
1254
|
-
const encoded = cleaned.split("''").slice(1).join("''") || cleaned;
|
|
1255
|
-
try {
|
|
1256
|
-
return path.basename(decodeURIComponent(encoded));
|
|
1257
|
-
} catch {
|
|
1258
|
-
return path.basename(encoded);
|
|
1259
|
-
}
|
|
1260
|
-
}
|
|
1261
|
-
const match = /filename\s*=\s*([^;]+)/i.exec(header);
|
|
1262
|
-
if (match?.[1]) return path.basename(stripQuotes(match[1].trim()));
|
|
1263
|
-
}
|
|
1264
|
-
async function readErrorBodySnippet(res, maxChars = 200) {
|
|
1265
|
-
try {
|
|
1266
|
-
const text = await res.text();
|
|
1267
|
-
if (!text) return;
|
|
1268
|
-
const collapsed = text.replace(/\s+/g, " ").trim();
|
|
1269
|
-
if (!collapsed) return;
|
|
1270
|
-
if (collapsed.length <= maxChars) return collapsed;
|
|
1271
|
-
return `${collapsed.slice(0, maxChars)}…`;
|
|
1272
|
-
} catch {
|
|
1273
|
-
return;
|
|
1274
|
-
}
|
|
1275
|
-
}
|
|
1276
|
-
async function fetchRemoteMedia(options) {
|
|
1277
|
-
const { url, fetchImpl, filePathHint, maxBytes, maxRedirects, ssrfPolicy, lookupFn } = options;
|
|
1278
|
-
let res;
|
|
1279
|
-
let finalUrl = url;
|
|
1280
|
-
let release = null;
|
|
1281
|
-
try {
|
|
1282
|
-
const result = await fetchWithSsrFGuard({
|
|
1283
|
-
url,
|
|
1284
|
-
fetchImpl,
|
|
1285
|
-
maxRedirects,
|
|
1286
|
-
policy: ssrfPolicy,
|
|
1287
|
-
lookupFn
|
|
1288
|
-
});
|
|
1289
|
-
res = result.response;
|
|
1290
|
-
finalUrl = result.finalUrl;
|
|
1291
|
-
release = result.release;
|
|
1292
|
-
} catch (err) {
|
|
1293
|
-
throw new MediaFetchError("fetch_failed", `Failed to fetch media from ${url}: ${String(err)}`);
|
|
1294
|
-
}
|
|
1295
|
-
try {
|
|
1296
|
-
if (!res.ok) {
|
|
1297
|
-
const statusText = res.statusText ? ` ${res.statusText}` : "";
|
|
1298
|
-
const redirected = finalUrl !== url ? ` (redirected to ${finalUrl})` : "";
|
|
1299
|
-
let detail = `HTTP ${res.status}${statusText}`;
|
|
1300
|
-
if (!res.body) detail = `HTTP ${res.status}${statusText}; empty response body`;
|
|
1301
|
-
else {
|
|
1302
|
-
const snippet = await readErrorBodySnippet(res);
|
|
1303
|
-
if (snippet) detail += `; body: ${snippet}`;
|
|
1304
|
-
}
|
|
1305
|
-
throw new MediaFetchError("http_error", `Failed to fetch media from ${url}${redirected}: ${detail}`);
|
|
1306
|
-
}
|
|
1307
|
-
const contentLength = res.headers.get("content-length");
|
|
1308
|
-
if (maxBytes && contentLength) {
|
|
1309
|
-
const length = Number(contentLength);
|
|
1310
|
-
if (Number.isFinite(length) && length > maxBytes) throw new MediaFetchError("max_bytes", `Failed to fetch media from ${url}: content length ${length} exceeds maxBytes ${maxBytes}`);
|
|
1311
|
-
}
|
|
1312
|
-
const buffer = maxBytes ? await readResponseWithLimit(res, maxBytes, { onOverflow: ({ maxBytes, res }) => new MediaFetchError("max_bytes", `Failed to fetch media from ${res.url || url}: payload exceeds maxBytes ${maxBytes}`) }) : Buffer.from(await res.arrayBuffer());
|
|
1313
|
-
let fileNameFromUrl;
|
|
1314
|
-
try {
|
|
1315
|
-
const parsed = new URL(finalUrl);
|
|
1316
|
-
fileNameFromUrl = path.basename(parsed.pathname) || void 0;
|
|
1317
|
-
} catch {}
|
|
1318
|
-
const headerFileName = parseContentDispositionFileName(res.headers.get("content-disposition"));
|
|
1319
|
-
let fileName = headerFileName || fileNameFromUrl || (filePathHint ? path.basename(filePathHint) : void 0);
|
|
1320
|
-
const filePathForMime = headerFileName && path.extname(headerFileName) ? headerFileName : filePathHint ?? finalUrl;
|
|
1321
|
-
const contentType = await detectMime({
|
|
1322
|
-
buffer,
|
|
1323
|
-
headerMime: res.headers.get("content-type"),
|
|
1324
|
-
filePath: filePathForMime
|
|
1325
|
-
});
|
|
1326
|
-
if (fileName && !path.extname(fileName) && contentType) {
|
|
1327
|
-
const ext = extensionForMime(contentType);
|
|
1328
|
-
if (ext) fileName = `${fileName}${ext}`;
|
|
1329
|
-
}
|
|
1330
|
-
return {
|
|
1331
|
-
buffer,
|
|
1332
|
-
contentType: contentType ?? void 0,
|
|
1333
|
-
fileName
|
|
1334
|
-
};
|
|
1335
|
-
} finally {
|
|
1336
|
-
if (release) await release();
|
|
1337
|
-
}
|
|
1338
|
-
}
|
|
1339
|
-
|
|
1340
|
-
//#endregion
|
|
1341
|
-
//#region src/media/image-ops.ts
|
|
1342
|
-
function isBun() {
|
|
1343
|
-
return typeof process.versions.bun === "string";
|
|
1344
|
-
}
|
|
1345
|
-
function prefersSips() {
|
|
1346
|
-
return process.env.ANIMA_IMAGE_BACKEND === "sips" || process.env.ANIMA_IMAGE_BACKEND !== "sharp" && isBun() && process.platform === "darwin";
|
|
1347
|
-
}
|
|
1348
|
-
async function loadSharp() {
|
|
1349
|
-
const mod = await import("sharp");
|
|
1350
|
-
const sharp = mod.default ?? mod;
|
|
1351
|
-
return (buffer) => sharp(buffer, { failOnError: false });
|
|
1352
|
-
}
|
|
1353
|
-
/**
|
|
1354
|
-
* Reads EXIF orientation from JPEG buffer.
|
|
1355
|
-
* Returns orientation value 1-8, or null if not found/not JPEG.
|
|
1356
|
-
*
|
|
1357
|
-
* EXIF orientation values:
|
|
1358
|
-
* 1 = Normal, 2 = Flip H, 3 = Rotate 180, 4 = Flip V,
|
|
1359
|
-
* 5 = Rotate 270 CW + Flip H, 6 = Rotate 90 CW, 7 = Rotate 90 CW + Flip H, 8 = Rotate 270 CW
|
|
1360
|
-
*/
|
|
1361
|
-
function readJpegExifOrientation(buffer) {
|
|
1362
|
-
if (buffer.length < 2 || buffer[0] !== 255 || buffer[1] !== 216) return null;
|
|
1363
|
-
let offset = 2;
|
|
1364
|
-
while (offset < buffer.length - 4) {
|
|
1365
|
-
if (buffer[offset] !== 255) {
|
|
1366
|
-
offset++;
|
|
1367
|
-
continue;
|
|
1368
|
-
}
|
|
1369
|
-
const marker = buffer[offset + 1];
|
|
1370
|
-
if (marker === 255) {
|
|
1371
|
-
offset++;
|
|
1372
|
-
continue;
|
|
1373
|
-
}
|
|
1374
|
-
if (marker === 225) {
|
|
1375
|
-
const exifStart = offset + 4;
|
|
1376
|
-
if (buffer.length > exifStart + 6 && buffer.toString("ascii", exifStart, exifStart + 4) === "Exif" && buffer[exifStart + 4] === 0 && buffer[exifStart + 5] === 0) {
|
|
1377
|
-
const tiffStart = exifStart + 6;
|
|
1378
|
-
if (buffer.length < tiffStart + 8) return null;
|
|
1379
|
-
const isLittleEndian = buffer.toString("ascii", tiffStart, tiffStart + 2) === "II";
|
|
1380
|
-
const readU16 = (pos) => isLittleEndian ? buffer.readUInt16LE(pos) : buffer.readUInt16BE(pos);
|
|
1381
|
-
const readU32 = (pos) => isLittleEndian ? buffer.readUInt32LE(pos) : buffer.readUInt32BE(pos);
|
|
1382
|
-
const ifd0Start = tiffStart + readU32(tiffStart + 4);
|
|
1383
|
-
if (buffer.length < ifd0Start + 2) return null;
|
|
1384
|
-
const numEntries = readU16(ifd0Start);
|
|
1385
|
-
for (let i = 0; i < numEntries; i++) {
|
|
1386
|
-
const entryOffset = ifd0Start + 2 + i * 12;
|
|
1387
|
-
if (buffer.length < entryOffset + 12) break;
|
|
1388
|
-
if (readU16(entryOffset) === 274) {
|
|
1389
|
-
const value = readU16(entryOffset + 8);
|
|
1390
|
-
return value >= 1 && value <= 8 ? value : null;
|
|
1391
|
-
}
|
|
1392
|
-
}
|
|
1393
|
-
}
|
|
1394
|
-
return null;
|
|
1395
|
-
}
|
|
1396
|
-
if (marker >= 224 && marker <= 239) {
|
|
1397
|
-
const segmentLength = buffer.readUInt16BE(offset + 2);
|
|
1398
|
-
offset += 2 + segmentLength;
|
|
1399
|
-
continue;
|
|
1400
|
-
}
|
|
1401
|
-
if (marker === 192 || marker === 218) break;
|
|
1402
|
-
offset++;
|
|
1403
|
-
}
|
|
1404
|
-
return null;
|
|
1405
|
-
}
|
|
1406
|
-
async function withTempDir(fn) {
|
|
1407
|
-
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "anima-img-"));
|
|
1408
|
-
try {
|
|
1409
|
-
return await fn(dir);
|
|
1410
|
-
} finally {
|
|
1411
|
-
await fs.rm(dir, {
|
|
1412
|
-
recursive: true,
|
|
1413
|
-
force: true
|
|
1414
|
-
}).catch(() => {});
|
|
1415
|
-
}
|
|
1416
|
-
}
|
|
1417
|
-
async function sipsMetadataFromBuffer(buffer) {
|
|
1418
|
-
return await withTempDir(async (dir) => {
|
|
1419
|
-
const input = path.join(dir, "in.img");
|
|
1420
|
-
await fs.writeFile(input, buffer);
|
|
1421
|
-
const { stdout } = await runExec("/usr/bin/sips", [
|
|
1422
|
-
"-g",
|
|
1423
|
-
"pixelWidth",
|
|
1424
|
-
"-g",
|
|
1425
|
-
"pixelHeight",
|
|
1426
|
-
input
|
|
1427
|
-
], {
|
|
1428
|
-
timeoutMs: 1e4,
|
|
1429
|
-
maxBuffer: 512 * 1024
|
|
1430
|
-
});
|
|
1431
|
-
const w = stdout.match(/pixelWidth:\s*([0-9]+)/);
|
|
1432
|
-
const h = stdout.match(/pixelHeight:\s*([0-9]+)/);
|
|
1433
|
-
if (!w?.[1] || !h?.[1]) return null;
|
|
1434
|
-
const width = Number.parseInt(w[1], 10);
|
|
1435
|
-
const height = Number.parseInt(h[1], 10);
|
|
1436
|
-
if (!Number.isFinite(width) || !Number.isFinite(height)) return null;
|
|
1437
|
-
if (width <= 0 || height <= 0) return null;
|
|
1438
|
-
return {
|
|
1439
|
-
width,
|
|
1440
|
-
height
|
|
1441
|
-
};
|
|
1442
|
-
});
|
|
1443
|
-
}
|
|
1444
|
-
async function sipsResizeToJpeg(params) {
|
|
1445
|
-
return await withTempDir(async (dir) => {
|
|
1446
|
-
const input = path.join(dir, "in.img");
|
|
1447
|
-
const output = path.join(dir, "out.jpg");
|
|
1448
|
-
await fs.writeFile(input, params.buffer);
|
|
1449
|
-
await runExec("/usr/bin/sips", [
|
|
1450
|
-
"-Z",
|
|
1451
|
-
String(Math.max(1, Math.round(params.maxSide))),
|
|
1452
|
-
"-s",
|
|
1453
|
-
"format",
|
|
1454
|
-
"jpeg",
|
|
1455
|
-
"-s",
|
|
1456
|
-
"formatOptions",
|
|
1457
|
-
String(Math.max(1, Math.min(100, Math.round(params.quality)))),
|
|
1458
|
-
input,
|
|
1459
|
-
"--out",
|
|
1460
|
-
output
|
|
1461
|
-
], {
|
|
1462
|
-
timeoutMs: 2e4,
|
|
1463
|
-
maxBuffer: 1024 * 1024
|
|
1464
|
-
});
|
|
1465
|
-
return await fs.readFile(output);
|
|
1466
|
-
});
|
|
1467
|
-
}
|
|
1468
|
-
async function sipsConvertToJpeg(buffer) {
|
|
1469
|
-
return await withTempDir(async (dir) => {
|
|
1470
|
-
const input = path.join(dir, "in.heic");
|
|
1471
|
-
const output = path.join(dir, "out.jpg");
|
|
1472
|
-
await fs.writeFile(input, buffer);
|
|
1473
|
-
await runExec("/usr/bin/sips", [
|
|
1474
|
-
"-s",
|
|
1475
|
-
"format",
|
|
1476
|
-
"jpeg",
|
|
1477
|
-
input,
|
|
1478
|
-
"--out",
|
|
1479
|
-
output
|
|
1480
|
-
], {
|
|
1481
|
-
timeoutMs: 2e4,
|
|
1482
|
-
maxBuffer: 1024 * 1024
|
|
1483
|
-
});
|
|
1484
|
-
return await fs.readFile(output);
|
|
1485
|
-
});
|
|
1486
|
-
}
|
|
1487
|
-
async function getImageMetadata(buffer) {
|
|
1488
|
-
if (prefersSips()) return await sipsMetadataFromBuffer(buffer).catch(() => null);
|
|
1489
|
-
try {
|
|
1490
|
-
const meta = await (await loadSharp())(buffer).metadata();
|
|
1491
|
-
const width = Number(meta.width ?? 0);
|
|
1492
|
-
const height = Number(meta.height ?? 0);
|
|
1493
|
-
if (!Number.isFinite(width) || !Number.isFinite(height)) return null;
|
|
1494
|
-
if (width <= 0 || height <= 0) return null;
|
|
1495
|
-
return {
|
|
1496
|
-
width,
|
|
1497
|
-
height
|
|
1498
|
-
};
|
|
1499
|
-
} catch {
|
|
1500
|
-
return null;
|
|
1501
|
-
}
|
|
1502
|
-
}
|
|
1503
|
-
/**
|
|
1504
|
-
* Applies rotation/flip to image buffer using sips based on EXIF orientation.
|
|
1505
|
-
*/
|
|
1506
|
-
async function sipsApplyOrientation(buffer, orientation) {
|
|
1507
|
-
const ops = [];
|
|
1508
|
-
switch (orientation) {
|
|
1509
|
-
case 2:
|
|
1510
|
-
ops.push("-f", "horizontal");
|
|
1511
|
-
break;
|
|
1512
|
-
case 3:
|
|
1513
|
-
ops.push("-r", "180");
|
|
1514
|
-
break;
|
|
1515
|
-
case 4:
|
|
1516
|
-
ops.push("-f", "vertical");
|
|
1517
|
-
break;
|
|
1518
|
-
case 5:
|
|
1519
|
-
ops.push("-r", "270", "-f", "horizontal");
|
|
1520
|
-
break;
|
|
1521
|
-
case 6:
|
|
1522
|
-
ops.push("-r", "90");
|
|
1523
|
-
break;
|
|
1524
|
-
case 7:
|
|
1525
|
-
ops.push("-r", "90", "-f", "horizontal");
|
|
1526
|
-
break;
|
|
1527
|
-
case 8:
|
|
1528
|
-
ops.push("-r", "270");
|
|
1529
|
-
break;
|
|
1530
|
-
default: return buffer;
|
|
1531
|
-
}
|
|
1532
|
-
return await withTempDir(async (dir) => {
|
|
1533
|
-
const input = path.join(dir, "in.jpg");
|
|
1534
|
-
const output = path.join(dir, "out.jpg");
|
|
1535
|
-
await fs.writeFile(input, buffer);
|
|
1536
|
-
await runExec("/usr/bin/sips", [
|
|
1537
|
-
...ops,
|
|
1538
|
-
input,
|
|
1539
|
-
"--out",
|
|
1540
|
-
output
|
|
1541
|
-
], {
|
|
1542
|
-
timeoutMs: 2e4,
|
|
1543
|
-
maxBuffer: 1024 * 1024
|
|
1544
|
-
});
|
|
1545
|
-
return await fs.readFile(output);
|
|
1546
|
-
});
|
|
1547
|
-
}
|
|
1548
|
-
async function resizeToJpeg(params) {
|
|
1549
|
-
if (prefersSips()) {
|
|
1550
|
-
const normalized = await normalizeExifOrientationSips(params.buffer);
|
|
1551
|
-
if (params.withoutEnlargement !== false) {
|
|
1552
|
-
const meta = await getImageMetadata(normalized);
|
|
1553
|
-
if (meta) {
|
|
1554
|
-
const maxDim = Math.max(meta.width, meta.height);
|
|
1555
|
-
if (maxDim > 0 && maxDim <= params.maxSide) return await sipsResizeToJpeg({
|
|
1556
|
-
buffer: normalized,
|
|
1557
|
-
maxSide: maxDim,
|
|
1558
|
-
quality: params.quality
|
|
1559
|
-
});
|
|
1560
|
-
}
|
|
1561
|
-
}
|
|
1562
|
-
return await sipsResizeToJpeg({
|
|
1563
|
-
buffer: normalized,
|
|
1564
|
-
maxSide: params.maxSide,
|
|
1565
|
-
quality: params.quality
|
|
1566
|
-
});
|
|
1567
|
-
}
|
|
1568
|
-
return await (await loadSharp())(params.buffer).rotate().resize({
|
|
1569
|
-
width: params.maxSide,
|
|
1570
|
-
height: params.maxSide,
|
|
1571
|
-
fit: "inside",
|
|
1572
|
-
withoutEnlargement: params.withoutEnlargement !== false
|
|
1573
|
-
}).jpeg({
|
|
1574
|
-
quality: params.quality,
|
|
1575
|
-
mozjpeg: true
|
|
1576
|
-
}).toBuffer();
|
|
1577
|
-
}
|
|
1578
|
-
async function convertHeicToJpeg(buffer) {
|
|
1579
|
-
if (prefersSips()) return await sipsConvertToJpeg(buffer);
|
|
1580
|
-
return await (await loadSharp())(buffer).jpeg({
|
|
1581
|
-
quality: 90,
|
|
1582
|
-
mozjpeg: true
|
|
1583
|
-
}).toBuffer();
|
|
1584
|
-
}
|
|
1585
|
-
/**
|
|
1586
|
-
* Checks if an image has an alpha channel (transparency).
|
|
1587
|
-
* Returns true if the image has alpha, false otherwise.
|
|
1588
|
-
*/
|
|
1589
|
-
async function hasAlphaChannel(buffer) {
|
|
1590
|
-
try {
|
|
1591
|
-
const meta = await (await loadSharp())(buffer).metadata();
|
|
1592
|
-
return meta.hasAlpha || meta.channels === 4;
|
|
1593
|
-
} catch {
|
|
1594
|
-
return false;
|
|
1595
|
-
}
|
|
1596
|
-
}
|
|
1597
|
-
/**
|
|
1598
|
-
* Resizes an image to PNG format, preserving alpha channel (transparency).
|
|
1599
|
-
* Falls back to sharp only (no sips fallback for PNG with alpha).
|
|
1600
|
-
*/
|
|
1601
|
-
async function resizeToPng(params) {
|
|
1602
|
-
const sharp = await loadSharp();
|
|
1603
|
-
const compressionLevel = params.compressionLevel ?? 6;
|
|
1604
|
-
return await sharp(params.buffer).rotate().resize({
|
|
1605
|
-
width: params.maxSide,
|
|
1606
|
-
height: params.maxSide,
|
|
1607
|
-
fit: "inside",
|
|
1608
|
-
withoutEnlargement: params.withoutEnlargement !== false
|
|
1609
|
-
}).png({ compressionLevel }).toBuffer();
|
|
1610
|
-
}
|
|
1611
|
-
async function optimizeImageToPng(buffer, maxBytes) {
|
|
1612
|
-
const sides = [
|
|
1613
|
-
2048,
|
|
1614
|
-
1536,
|
|
1615
|
-
1280,
|
|
1616
|
-
1024,
|
|
1617
|
-
800
|
|
1618
|
-
];
|
|
1619
|
-
const compressionLevels = [
|
|
1620
|
-
6,
|
|
1621
|
-
7,
|
|
1622
|
-
8,
|
|
1623
|
-
9
|
|
1624
|
-
];
|
|
1625
|
-
let smallest = null;
|
|
1626
|
-
for (const side of sides) for (const compressionLevel of compressionLevels) try {
|
|
1627
|
-
const out = await resizeToPng({
|
|
1628
|
-
buffer,
|
|
1629
|
-
maxSide: side,
|
|
1630
|
-
compressionLevel,
|
|
1631
|
-
withoutEnlargement: true
|
|
1632
|
-
});
|
|
1633
|
-
const size = out.length;
|
|
1634
|
-
if (!smallest || size < smallest.size) smallest = {
|
|
1635
|
-
buffer: out,
|
|
1636
|
-
size,
|
|
1637
|
-
resizeSide: side,
|
|
1638
|
-
compressionLevel
|
|
1639
|
-
};
|
|
1640
|
-
if (size <= maxBytes) return {
|
|
1641
|
-
buffer: out,
|
|
1642
|
-
optimizedSize: size,
|
|
1643
|
-
resizeSide: side,
|
|
1644
|
-
compressionLevel
|
|
1645
|
-
};
|
|
1646
|
-
} catch {}
|
|
1647
|
-
if (smallest) return {
|
|
1648
|
-
buffer: smallest.buffer,
|
|
1649
|
-
optimizedSize: smallest.size,
|
|
1650
|
-
resizeSide: smallest.resizeSide,
|
|
1651
|
-
compressionLevel: smallest.compressionLevel
|
|
1652
|
-
};
|
|
1653
|
-
throw new Error("Failed to optimize PNG image");
|
|
1654
|
-
}
|
|
1655
|
-
/**
|
|
1656
|
-
* Internal sips-only EXIF normalization (no sharp fallback).
|
|
1657
|
-
* Used by resizeToJpeg to normalize before sips resize.
|
|
1658
|
-
*/
|
|
1659
|
-
async function normalizeExifOrientationSips(buffer) {
|
|
1660
|
-
try {
|
|
1661
|
-
const orientation = readJpegExifOrientation(buffer);
|
|
1662
|
-
if (!orientation || orientation === 1) return buffer;
|
|
1663
|
-
return await sipsApplyOrientation(buffer, orientation);
|
|
1664
|
-
} catch {
|
|
1665
|
-
return buffer;
|
|
1666
|
-
}
|
|
1667
|
-
}
|
|
1668
|
-
|
|
1669
|
-
//#endregion
|
|
1670
|
-
//#region src/web/media.ts
|
|
1671
|
-
function getDefaultLocalRoots() {
|
|
1672
|
-
return [
|
|
1673
|
-
os.tmpdir(),
|
|
1674
|
-
path.join(STATE_DIR, "media"),
|
|
1675
|
-
path.join(STATE_DIR, "agents"),
|
|
1676
|
-
path.join(STATE_DIR, "workspace"),
|
|
1677
|
-
path.join(STATE_DIR, "sandboxes")
|
|
1678
|
-
];
|
|
1679
|
-
}
|
|
1680
|
-
async function assertLocalMediaAllowed(mediaPath, localRoots) {
|
|
1681
|
-
if (localRoots === "any") return;
|
|
1682
|
-
const roots = localRoots ?? getDefaultLocalRoots();
|
|
1683
|
-
let resolved;
|
|
1684
|
-
try {
|
|
1685
|
-
resolved = await fs.realpath(mediaPath);
|
|
1686
|
-
} catch {
|
|
1687
|
-
resolved = path.resolve(mediaPath);
|
|
1688
|
-
}
|
|
1689
|
-
for (const root of roots) {
|
|
1690
|
-
let resolvedRoot;
|
|
1691
|
-
try {
|
|
1692
|
-
resolvedRoot = await fs.realpath(root);
|
|
1693
|
-
} catch {
|
|
1694
|
-
resolvedRoot = path.resolve(root);
|
|
1695
|
-
}
|
|
1696
|
-
if (resolvedRoot === path.parse(resolvedRoot).root) throw new Error(`Invalid localRoots entry (refuses filesystem root): ${root}. Pass a narrower directory.`);
|
|
1697
|
-
if (resolved === resolvedRoot || resolved.startsWith(resolvedRoot + path.sep)) return;
|
|
1698
|
-
}
|
|
1699
|
-
throw new Error(`Local media path is not under an allowed directory: ${mediaPath}`);
|
|
1700
|
-
}
|
|
1701
|
-
const HEIC_MIME_RE = /^image\/hei[cf]$/i;
|
|
1702
|
-
const HEIC_EXT_RE = /\.(heic|heif)$/i;
|
|
1703
|
-
const MB = 1024 * 1024;
|
|
1704
|
-
function formatMb(bytes, digits = 2) {
|
|
1705
|
-
return (bytes / MB).toFixed(digits);
|
|
1706
|
-
}
|
|
1707
|
-
function formatCapLimit(label, cap, size) {
|
|
1708
|
-
return `${label} exceeds ${formatMb(cap, 0)}MB limit (got ${formatMb(size)}MB)`;
|
|
1709
|
-
}
|
|
1710
|
-
function formatCapReduce(label, cap, size) {
|
|
1711
|
-
return `${label} could not be reduced below ${formatMb(cap, 0)}MB (got ${formatMb(size)}MB)`;
|
|
1712
|
-
}
|
|
1713
|
-
function isHeicSource(opts) {
|
|
1714
|
-
if (opts.contentType && HEIC_MIME_RE.test(opts.contentType.trim())) return true;
|
|
1715
|
-
if (opts.fileName && HEIC_EXT_RE.test(opts.fileName.trim())) return true;
|
|
1716
|
-
return false;
|
|
1717
|
-
}
|
|
1718
|
-
function toJpegFileName(fileName) {
|
|
1719
|
-
if (!fileName) return;
|
|
1720
|
-
const trimmed = fileName.trim();
|
|
1721
|
-
if (!trimmed) return fileName;
|
|
1722
|
-
const parsed = path.parse(trimmed);
|
|
1723
|
-
if (!parsed.ext || HEIC_EXT_RE.test(parsed.ext)) return path.format({
|
|
1724
|
-
dir: parsed.dir,
|
|
1725
|
-
name: parsed.name || trimmed,
|
|
1726
|
-
ext: ".jpg"
|
|
1727
|
-
});
|
|
1728
|
-
return path.format({
|
|
1729
|
-
dir: parsed.dir,
|
|
1730
|
-
name: parsed.name,
|
|
1731
|
-
ext: ".jpg"
|
|
1732
|
-
});
|
|
1733
|
-
}
|
|
1734
|
-
function logOptimizedImage(params) {
|
|
1735
|
-
if (!shouldLogVerbose()) return;
|
|
1736
|
-
if (params.optimized.optimizedSize >= params.originalSize) return;
|
|
1737
|
-
if (params.optimized.format === "png") {
|
|
1738
|
-
logVerbose(`Optimized PNG (preserving alpha) from ${formatMb(params.originalSize)}MB to ${formatMb(params.optimized.optimizedSize)}MB (side≤${params.optimized.resizeSide}px)`);
|
|
1739
|
-
return;
|
|
1740
|
-
}
|
|
1741
|
-
logVerbose(`Optimized media from ${formatMb(params.originalSize)}MB to ${formatMb(params.optimized.optimizedSize)}MB (side≤${params.optimized.resizeSide}px, q=${params.optimized.quality})`);
|
|
1742
|
-
}
|
|
1743
|
-
async function optimizeImageWithFallback(params) {
|
|
1744
|
-
const { buffer, cap, meta } = params;
|
|
1745
|
-
if ((meta?.contentType === "image/png" || meta?.fileName?.toLowerCase().endsWith(".png")) && await hasAlphaChannel(buffer)) {
|
|
1746
|
-
const optimized = await optimizeImageToPng(buffer, cap);
|
|
1747
|
-
if (optimized.buffer.length <= cap) return {
|
|
1748
|
-
...optimized,
|
|
1749
|
-
format: "png"
|
|
1750
|
-
};
|
|
1751
|
-
if (shouldLogVerbose()) logVerbose(`PNG with alpha still exceeds ${formatMb(cap, 0)}MB after optimization; falling back to JPEG`);
|
|
1752
|
-
}
|
|
1753
|
-
return {
|
|
1754
|
-
...await optimizeImageToJpeg(buffer, cap, meta),
|
|
1755
|
-
format: "jpeg"
|
|
1756
|
-
};
|
|
1757
|
-
}
|
|
1758
|
-
async function loadWebMediaInternal(mediaUrl, options = {}) {
|
|
1759
|
-
const { maxBytes, optimizeImages = true, ssrfPolicy, localRoots, sandboxValidated = false, readFile: readFileOverride } = options;
|
|
1760
|
-
mediaUrl = mediaUrl.replace(/^\s*MEDIA\s*:\s*/i, "");
|
|
1761
|
-
if (mediaUrl.startsWith("file://")) try {
|
|
1762
|
-
mediaUrl = fileURLToPath(mediaUrl);
|
|
1763
|
-
} catch {
|
|
1764
|
-
throw new Error(`Invalid file:// URL: ${mediaUrl}`);
|
|
1765
|
-
}
|
|
1766
|
-
const optimizeAndClampImage = async (buffer, cap, meta) => {
|
|
1767
|
-
const originalSize = buffer.length;
|
|
1768
|
-
const optimized = await optimizeImageWithFallback({
|
|
1769
|
-
buffer,
|
|
1770
|
-
cap,
|
|
1771
|
-
meta
|
|
1772
|
-
});
|
|
1773
|
-
logOptimizedImage({
|
|
1774
|
-
originalSize,
|
|
1775
|
-
optimized
|
|
1776
|
-
});
|
|
1777
|
-
if (optimized.buffer.length > cap) throw new Error(formatCapReduce("Media", cap, optimized.buffer.length));
|
|
1778
|
-
const contentType = optimized.format === "png" ? "image/png" : "image/jpeg";
|
|
1779
|
-
const fileName = optimized.format === "jpeg" && meta && isHeicSource(meta) ? toJpegFileName(meta.fileName) : meta?.fileName;
|
|
1780
|
-
return {
|
|
1781
|
-
buffer: optimized.buffer,
|
|
1782
|
-
contentType,
|
|
1783
|
-
kind: "image",
|
|
1784
|
-
fileName
|
|
1785
|
-
};
|
|
1786
|
-
};
|
|
1787
|
-
const clampAndFinalize = async (params) => {
|
|
1788
|
-
const cap = maxBytes !== void 0 ? maxBytes : maxBytesForKind(params.kind);
|
|
1789
|
-
if (params.kind === "image") {
|
|
1790
|
-
const isGif = params.contentType === "image/gif";
|
|
1791
|
-
if (isGif || !optimizeImages) {
|
|
1792
|
-
if (params.buffer.length > cap) throw new Error(formatCapLimit(isGif ? "GIF" : "Media", cap, params.buffer.length));
|
|
1793
|
-
return {
|
|
1794
|
-
buffer: params.buffer,
|
|
1795
|
-
contentType: params.contentType,
|
|
1796
|
-
kind: params.kind,
|
|
1797
|
-
fileName: params.fileName
|
|
1798
|
-
};
|
|
1799
|
-
}
|
|
1800
|
-
return { ...await optimizeAndClampImage(params.buffer, cap, {
|
|
1801
|
-
contentType: params.contentType,
|
|
1802
|
-
fileName: params.fileName
|
|
1803
|
-
}) };
|
|
1804
|
-
}
|
|
1805
|
-
if (params.buffer.length > cap) throw new Error(formatCapLimit("Media", cap, params.buffer.length));
|
|
1806
|
-
return {
|
|
1807
|
-
buffer: params.buffer,
|
|
1808
|
-
contentType: params.contentType ?? void 0,
|
|
1809
|
-
kind: params.kind,
|
|
1810
|
-
fileName: params.fileName
|
|
1811
|
-
};
|
|
1812
|
-
};
|
|
1813
|
-
if (/^https?:\/\//i.test(mediaUrl)) {
|
|
1814
|
-
const defaultFetchCap = maxBytesForKind("unknown");
|
|
1815
|
-
const { buffer, contentType, fileName } = await fetchRemoteMedia({
|
|
1816
|
-
url: mediaUrl,
|
|
1817
|
-
maxBytes: maxBytes === void 0 ? defaultFetchCap : optimizeImages ? Math.max(maxBytes, defaultFetchCap) : maxBytes,
|
|
1818
|
-
ssrfPolicy
|
|
1819
|
-
});
|
|
1820
|
-
return await clampAndFinalize({
|
|
1821
|
-
buffer,
|
|
1822
|
-
contentType,
|
|
1823
|
-
kind: mediaKindFromMime(contentType),
|
|
1824
|
-
fileName
|
|
1825
|
-
});
|
|
1826
|
-
}
|
|
1827
|
-
if (mediaUrl.startsWith("~")) mediaUrl = resolveUserPath(mediaUrl);
|
|
1828
|
-
if ((sandboxValidated || localRoots === "any") && !readFileOverride) throw new Error("Refusing localRoots bypass without readFile override. Use sandboxValidated with readFile, or pass explicit localRoots.");
|
|
1829
|
-
if (!(sandboxValidated || localRoots === "any")) await assertLocalMediaAllowed(mediaUrl, localRoots);
|
|
1830
|
-
const data = readFileOverride ? await readFileOverride(mediaUrl) : await fs.readFile(mediaUrl);
|
|
1831
|
-
const mime = await detectMime({
|
|
1832
|
-
buffer: data,
|
|
1833
|
-
filePath: mediaUrl
|
|
1834
|
-
});
|
|
1835
|
-
const kind = mediaKindFromMime(mime);
|
|
1836
|
-
let fileName = path.basename(mediaUrl) || void 0;
|
|
1837
|
-
if (fileName && !path.extname(fileName) && mime) {
|
|
1838
|
-
const ext = extensionForMime(mime);
|
|
1839
|
-
if (ext) fileName = `${fileName}${ext}`;
|
|
1840
|
-
}
|
|
1841
|
-
return await clampAndFinalize({
|
|
1842
|
-
buffer: data,
|
|
1843
|
-
contentType: mime,
|
|
1844
|
-
kind,
|
|
1845
|
-
fileName
|
|
1846
|
-
});
|
|
1847
|
-
}
|
|
1848
|
-
async function loadWebMedia(mediaUrl, maxBytesOrOptions, options) {
|
|
1849
|
-
if (typeof maxBytesOrOptions === "number" || maxBytesOrOptions === void 0) return await loadWebMediaInternal(mediaUrl, {
|
|
1850
|
-
maxBytes: maxBytesOrOptions,
|
|
1851
|
-
optimizeImages: true,
|
|
1852
|
-
ssrfPolicy: options?.ssrfPolicy,
|
|
1853
|
-
localRoots: options?.localRoots
|
|
1854
|
-
});
|
|
1855
|
-
return await loadWebMediaInternal(mediaUrl, {
|
|
1856
|
-
...maxBytesOrOptions,
|
|
1857
|
-
optimizeImages: maxBytesOrOptions.optimizeImages ?? true
|
|
1858
|
-
});
|
|
1859
|
-
}
|
|
1860
|
-
async function optimizeImageToJpeg(buffer, maxBytes, opts = {}) {
|
|
1861
|
-
let source = buffer;
|
|
1862
|
-
if (isHeicSource(opts)) try {
|
|
1863
|
-
source = await convertHeicToJpeg(buffer);
|
|
1864
|
-
} catch (err) {
|
|
1865
|
-
throw new Error(`HEIC image conversion failed: ${String(err)}`, { cause: err });
|
|
1866
|
-
}
|
|
1867
|
-
const sides = [
|
|
1868
|
-
2048,
|
|
1869
|
-
1536,
|
|
1870
|
-
1280,
|
|
1871
|
-
1024,
|
|
1872
|
-
800
|
|
1873
|
-
];
|
|
1874
|
-
const qualities = [
|
|
1875
|
-
80,
|
|
1876
|
-
70,
|
|
1877
|
-
60,
|
|
1878
|
-
50,
|
|
1879
|
-
40
|
|
1880
|
-
];
|
|
1881
|
-
let smallest = null;
|
|
1882
|
-
for (const side of sides) for (const quality of qualities) try {
|
|
1883
|
-
const out = await resizeToJpeg({
|
|
1884
|
-
buffer: source,
|
|
1885
|
-
maxSide: side,
|
|
1886
|
-
quality,
|
|
1887
|
-
withoutEnlargement: true
|
|
1888
|
-
});
|
|
1889
|
-
const size = out.length;
|
|
1890
|
-
if (!smallest || size < smallest.size) smallest = {
|
|
1891
|
-
buffer: out,
|
|
1892
|
-
size,
|
|
1893
|
-
resizeSide: side,
|
|
1894
|
-
quality
|
|
1895
|
-
};
|
|
1896
|
-
if (size <= maxBytes) return {
|
|
1897
|
-
buffer: out,
|
|
1898
|
-
optimizedSize: size,
|
|
1899
|
-
resizeSide: side,
|
|
1900
|
-
quality
|
|
1901
|
-
};
|
|
1902
|
-
} catch {}
|
|
1903
|
-
if (smallest) return {
|
|
1904
|
-
buffer: smallest.buffer,
|
|
1905
|
-
optimizedSize: smallest.size,
|
|
1906
|
-
resizeSide: smallest.resizeSide,
|
|
1907
|
-
quality: smallest.quality
|
|
1908
|
-
};
|
|
1909
|
-
throw new Error("Failed to optimize image");
|
|
1910
|
-
}
|
|
1911
|
-
|
|
1912
|
-
//#endregion
|
|
1913
|
-
//#region src/web/outbound.ts
|
|
1914
|
-
var outbound_exports = /* @__PURE__ */ __exportAll({
|
|
1915
|
-
sendMessageWhatsApp: () => sendMessageWhatsApp,
|
|
1916
|
-
sendPollWhatsApp: () => sendPollWhatsApp,
|
|
1917
|
-
sendReactionWhatsApp: () => sendReactionWhatsApp
|
|
1918
|
-
});
|
|
1919
|
-
const outboundLog = createSubsystemLogger("gateway/channels/whatsapp").child("outbound");
|
|
1920
|
-
async function sendMessageWhatsApp(to, body, options) {
|
|
1921
|
-
let text = body;
|
|
1922
|
-
const correlationId = randomUUID();
|
|
1923
|
-
const startedAt = Date.now();
|
|
1924
|
-
const { listener: active, accountId: resolvedAccountId } = requireActiveWebListener(options.accountId);
|
|
1925
|
-
const tableMode = resolveMarkdownTableMode({
|
|
1926
|
-
cfg: loadConfig(),
|
|
1927
|
-
channel: "whatsapp",
|
|
1928
|
-
accountId: resolvedAccountId ?? options.accountId
|
|
1929
|
-
});
|
|
1930
|
-
text = convertMarkdownTables(text ?? "", tableMode);
|
|
1931
|
-
text = markdownToWhatsApp(text);
|
|
1932
|
-
const logger = getChildLogger({
|
|
1933
|
-
module: "web-outbound",
|
|
1934
|
-
correlationId,
|
|
1935
|
-
to
|
|
1936
|
-
});
|
|
1937
|
-
try {
|
|
1938
|
-
const jid = toWhatsappJid(to);
|
|
1939
|
-
let mediaBuffer;
|
|
1940
|
-
let mediaType;
|
|
1941
|
-
let documentFileName;
|
|
1942
|
-
if (options.mediaUrl) {
|
|
1943
|
-
const media = await loadWebMedia(options.mediaUrl);
|
|
1944
|
-
const caption = text || void 0;
|
|
1945
|
-
mediaBuffer = media.buffer;
|
|
1946
|
-
mediaType = media.contentType;
|
|
1947
|
-
if (media.kind === "audio") mediaType = media.contentType === "audio/ogg" ? "audio/ogg; codecs=opus" : media.contentType ?? "application/octet-stream";
|
|
1948
|
-
else if (media.kind === "video") text = caption ?? "";
|
|
1949
|
-
else if (media.kind === "image") text = caption ?? "";
|
|
1950
|
-
else {
|
|
1951
|
-
text = caption ?? "";
|
|
1952
|
-
documentFileName = media.fileName;
|
|
1953
|
-
}
|
|
1954
|
-
}
|
|
1955
|
-
outboundLog.info(`Sending message -> ${jid}${options.mediaUrl ? " (media)" : ""}`);
|
|
1956
|
-
logger.info({
|
|
1957
|
-
jid,
|
|
1958
|
-
hasMedia: Boolean(options.mediaUrl)
|
|
1959
|
-
}, "sending message");
|
|
1960
|
-
await active.sendComposingTo(to);
|
|
1961
|
-
const accountId = Boolean(options.accountId?.trim()) ? resolvedAccountId : void 0;
|
|
1962
|
-
const sendOptions = options.gifPlayback || accountId || documentFileName ? {
|
|
1963
|
-
...options.gifPlayback ? { gifPlayback: true } : {},
|
|
1964
|
-
...documentFileName ? { fileName: documentFileName } : {},
|
|
1965
|
-
accountId
|
|
1966
|
-
} : void 0;
|
|
1967
|
-
const messageId = (sendOptions ? await active.sendMessage(to, text, mediaBuffer, mediaType, sendOptions) : await active.sendMessage(to, text, mediaBuffer, mediaType))?.messageId ?? "unknown";
|
|
1968
|
-
const durationMs = Date.now() - startedAt;
|
|
1969
|
-
outboundLog.info(`Sent message ${messageId} -> ${jid}${options.mediaUrl ? " (media)" : ""} (${durationMs}ms)`);
|
|
1970
|
-
logger.info({
|
|
1971
|
-
jid,
|
|
1972
|
-
messageId
|
|
1973
|
-
}, "sent message");
|
|
1974
|
-
return {
|
|
1975
|
-
messageId,
|
|
1976
|
-
toJid: jid
|
|
1977
|
-
};
|
|
1978
|
-
} catch (err) {
|
|
1979
|
-
logger.error({
|
|
1980
|
-
err: String(err),
|
|
1981
|
-
to,
|
|
1982
|
-
hasMedia: Boolean(options.mediaUrl)
|
|
1983
|
-
}, "failed to send via web session");
|
|
1984
|
-
throw err;
|
|
1985
|
-
}
|
|
1986
|
-
}
|
|
1987
|
-
async function sendReactionWhatsApp(chatJid, messageId, emoji, options) {
|
|
1988
|
-
const correlationId = randomUUID();
|
|
1989
|
-
const { listener: active } = requireActiveWebListener(options.accountId);
|
|
1990
|
-
const logger = getChildLogger({
|
|
1991
|
-
module: "web-outbound",
|
|
1992
|
-
correlationId,
|
|
1993
|
-
chatJid,
|
|
1994
|
-
messageId
|
|
1995
|
-
});
|
|
1996
|
-
try {
|
|
1997
|
-
const jid = toWhatsappJid(chatJid);
|
|
1998
|
-
outboundLog.info(`Sending reaction "${emoji}" -> message ${messageId}`);
|
|
1999
|
-
logger.info({
|
|
2000
|
-
chatJid: jid,
|
|
2001
|
-
messageId,
|
|
2002
|
-
emoji
|
|
2003
|
-
}, "sending reaction");
|
|
2004
|
-
await active.sendReaction(chatJid, messageId, emoji, options.fromMe ?? false, options.participant);
|
|
2005
|
-
outboundLog.info(`Sent reaction "${emoji}" -> message ${messageId}`);
|
|
2006
|
-
logger.info({
|
|
2007
|
-
chatJid: jid,
|
|
2008
|
-
messageId,
|
|
2009
|
-
emoji
|
|
2010
|
-
}, "sent reaction");
|
|
2011
|
-
} catch (err) {
|
|
2012
|
-
logger.error({
|
|
2013
|
-
err: String(err),
|
|
2014
|
-
chatJid,
|
|
2015
|
-
messageId,
|
|
2016
|
-
emoji
|
|
2017
|
-
}, "failed to send reaction via web session");
|
|
2018
|
-
throw err;
|
|
2019
|
-
}
|
|
2020
|
-
}
|
|
2021
|
-
async function sendPollWhatsApp(to, poll, options) {
|
|
2022
|
-
const correlationId = randomUUID();
|
|
2023
|
-
const startedAt = Date.now();
|
|
2024
|
-
const { listener: active } = requireActiveWebListener(options.accountId);
|
|
2025
|
-
const logger = getChildLogger({
|
|
2026
|
-
module: "web-outbound",
|
|
2027
|
-
correlationId,
|
|
2028
|
-
to
|
|
2029
|
-
});
|
|
2030
|
-
try {
|
|
2031
|
-
const jid = toWhatsappJid(to);
|
|
2032
|
-
const normalized = normalizePollInput(poll, { maxOptions: 12 });
|
|
2033
|
-
outboundLog.info(`Sending poll -> ${jid}: "${normalized.question}"`);
|
|
2034
|
-
logger.info({
|
|
2035
|
-
jid,
|
|
2036
|
-
question: normalized.question,
|
|
2037
|
-
optionCount: normalized.options.length,
|
|
2038
|
-
maxSelections: normalized.maxSelections
|
|
2039
|
-
}, "sending poll");
|
|
2040
|
-
const messageId = (await active.sendPoll(to, normalized))?.messageId ?? "unknown";
|
|
2041
|
-
const durationMs = Date.now() - startedAt;
|
|
2042
|
-
outboundLog.info(`Sent poll ${messageId} -> ${jid} (${durationMs}ms)`);
|
|
2043
|
-
logger.info({
|
|
2044
|
-
jid,
|
|
2045
|
-
messageId
|
|
2046
|
-
}, "sent poll");
|
|
2047
|
-
return {
|
|
2048
|
-
messageId,
|
|
2049
|
-
toJid: jid
|
|
2050
|
-
};
|
|
2051
|
-
} catch (err) {
|
|
2052
|
-
logger.error({
|
|
2053
|
-
err: String(err),
|
|
2054
|
-
to,
|
|
2055
|
-
question: poll.question
|
|
2056
|
-
}, "failed to send poll via web session");
|
|
2057
|
-
throw err;
|
|
2058
|
-
}
|
|
2059
|
-
}
|
|
2060
|
-
|
|
2061
|
-
//#endregion
|
|
2062
|
-
export { setActiveWebListener as _, loadWebMedia as a, convertMarkdownTables as b, MediaFetchError as c, fetchWithSsrFGuard as d, SsrFBlockedError as f, getActiveWebListener as g, bindAbortRelay as h, getDefaultLocalRoots as i, fetchRemoteMedia as l, isPrivateIpAddress as m, sendMessageWhatsApp as n, getImageMetadata as o, isBlockedHostname as p, sendReactionWhatsApp as r, resizeToJpeg as s, outbound_exports as t, readResponseWithLimit as u, normalizePollInput as v, markdownToWhatsApp as y };
|