@noxsoft/anima 2.0.0
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/CHANGELOG.md +2065 -0
- package/LICENSE +23 -0
- package/README.md +47 -0
- package/anima.mjs +56 -0
- package/dist/accounts-Cc5E4IDO.js +260 -0
- package/dist/accounts-CcVrwKqv.js +259 -0
- package/dist/acp-cli-BbvR4dNz.js +1081 -0
- package/dist/acp-cli-CePIi7gD.js +1084 -0
- package/dist/agent-CSrGrAg1.js +725 -0
- package/dist/agent-NgeWEcBM.js +725 -0
- package/dist/agent-events-UF0DxwKS.js +182 -0
- package/dist/agent-scope-BVf4aSwY.js +112 -0
- package/dist/agent-scope-OZi7lb8S.js +452 -0
- package/dist/agent-scope-V1bi9OYL.js +452 -0
- package/dist/agents-Bw06WthM.js +809 -0
- package/dist/agents.config-Dvo2ULxs.js +182 -0
- package/dist/agents.config-d6H0_3oj.js +182 -0
- package/dist/argv-DqUHKf0o.js +73 -0
- package/dist/audit-Buja3mbS.js +2401 -0
- package/dist/audit-CWIz6mM7.js +2401 -0
- package/dist/auth-91o2YM96.js +648 -0
- package/dist/auth-choice-7dFCqblU.js +2681 -0
- package/dist/auth-choice-S_0K9gpl.js +2681 -0
- package/dist/auth-health-CctpRTdC.js +149 -0
- package/dist/auth-health-DoHai4eD.js +149 -0
- package/dist/auth-lZ26wsbN.js +639 -0
- package/dist/auth-profiles-Cz2rxrav.js +2690 -0
- package/dist/auth-profiles-_5BsNObq.js +1565 -0
- package/dist/banner-ieAUufx9.js +294 -0
- package/dist/boolean-Ce2-qkSB.js +30 -0
- package/dist/boolean-Wzu0-e0P.js +30 -0
- package/dist/brew-CVZkr0GU.js +46 -0
- package/dist/brew-DAdyX1_1.js +46 -0
- package/dist/browser-cli-D_qgYDik.js +1679 -0
- package/dist/browser-cli-DldrdaCW.js +1676 -0
- package/dist/budget-ChKARYPY.js +132 -0
- package/dist/budget-Dspr6N_e.js +132 -0
- package/dist/build-info.json +5 -0
- package/dist/bundled/boot-md/HOOK.md +19 -0
- package/dist/bundled/boot-md/handler.js +861 -0
- package/dist/bundled/bootstrap-extra-files/HOOK.md +53 -0
- package/dist/bundled/bootstrap-extra-files/handler.js +39 -0
- package/dist/bundled/command-logger/HOOK.md +122 -0
- package/dist/bundled/command-logger/handler.js +55 -0
- package/dist/bundled/session-memory/HOOK.md +109 -0
- package/dist/bundled/session-memory/handler.js +128 -0
- package/dist/call-DPzNR_Qi.js +282 -0
- package/dist/call-ktoEhkOQ.js +282 -0
- package/dist/canvas-host/a2ui/.bundle.hash +1 -0
- package/dist/canvas-host/a2ui/a2ui.bundle.js +19040 -0
- package/dist/canvas-host/a2ui/index.html +307 -0
- package/dist/catalog-BAayBt1L.js +185 -0
- package/dist/catalog-BNsf97BM.js +185 -0
- package/dist/channel-options-C3GV4Fgg.js +33 -0
- package/dist/channel-options-DJ4GNfwk.js +32 -0
- package/dist/channel-selection-CujyiWGM.js +51 -0
- package/dist/channel-selection-DfGpCyh2.js +51 -0
- package/dist/channel-web-D42mzlCJ.js +2162 -0
- package/dist/channels-cli-BAtARz4A.js +1306 -0
- package/dist/channels-cli-Ddo_tIRR.js +1304 -0
- package/dist/channels-status-issues-DBc1pU_R.js +18 -0
- package/dist/channels-status-issues-DjO9MHIG.js +18 -0
- package/dist/chrome-Bi6iZ5sG.js +1601 -0
- package/dist/chrome-DNSv7Cpy.js +1629 -0
- package/dist/chrome-DScZx4Lk.js +1601 -0
- package/dist/chunk-mxPVo000.js +348 -0
- package/dist/clack-prompter-B0kl7shw.js +92 -0
- package/dist/clack-prompter-B1YxZdRy.js +92 -0
- package/dist/cli/daemon-cli.js +9 -0
- package/dist/cli-D3hUnL_G.js +101 -0
- package/dist/cli-DDwD6VgH.js +99 -0
- package/dist/cli-session-CP7ZH2-6.js +5463 -0
- package/dist/cli-session-oXJQpenl.js +5408 -0
- package/dist/cli-utils-BTBABPX9.js +40 -0
- package/dist/cli-utils-DtAxdCte.js +40 -0
- package/dist/client-C1avc0vD.js +1692 -0
- package/dist/client-CC94YZrT.js +1692 -0
- package/dist/clipboard-B2fBy8tG.js +31 -0
- package/dist/clipboard-BbGnZskJ.js +31 -0
- package/dist/command-format-Clp46jkj.js +38 -0
- package/dist/command-format-DELazozB.js +52 -0
- package/dist/command-format-SkzzRqR1.js +52 -0
- package/dist/command-options-CSbuuqHr.js +8 -0
- package/dist/command-options-Cp1tf96a.js +8 -0
- package/dist/command-registry-DDGudZEQ.js +248 -0
- package/dist/commands-CRcFD5MO.js +509 -0
- package/dist/commands-Dh40OpQL.js +509 -0
- package/dist/commands-registry-Bd0xbvwG.js +766 -0
- package/dist/commands-registry-DYfRSVF3.js +766 -0
- package/dist/common-D6bu0zHC.js +287 -0
- package/dist/common-zW9Y2P1B.js +287 -0
- package/dist/completion-cli-B9Cn374l.js +431 -0
- package/dist/completion-cli-BEHghUFx.js +432 -0
- package/dist/config-Bmm8tmZF.js +6523 -0
- package/dist/config-CHc5qzaI.js +5704 -0
- package/dist/config-Co6UXXF5.js +11 -0
- package/dist/config-Xm0j9LUa.js +5705 -0
- package/dist/config-cli-9ZbCHoV8.js +247 -0
- package/dist/config-cli-sxuGl29N.js +244 -0
- package/dist/config-guard-BwRD-b9Z.js +93 -0
- package/dist/config-guard-Dy7wyhAX.js +76 -0
- package/dist/config-sync-Bllc1TJ4.js +89 -0
- package/dist/config-sync-mfuOoGHl.js +89 -0
- package/dist/configure-CCyVzQZ7.js +1006 -0
- package/dist/configure-Nntbxt4t.js +1008 -0
- package/dist/constants-BwBn5CGe.js +65 -0
- package/dist/constants-O8yBqCBv.js +65 -0
- package/dist/context-DKaQYnCH.js +60 -0
- package/dist/control-service-BeOtZCCS.js +72 -0
- package/dist/control-service-vyKJ-XUp.js +72 -0
- package/dist/cron-cli-BasqtsJ0.js +451 -0
- package/dist/cron-cli-C8XzIpyX.js +448 -0
- package/dist/daemon-cli-cwL2GI5i.js +565 -0
- package/dist/daemon-cli-sjDh2xbf.js +566 -0
- package/dist/daemon-cli.js +13117 -0
- package/dist/daemon-runtime-BuMT6nck.js +460 -0
- package/dist/daemon-runtime-CTvi3m4D.js +460 -0
- package/dist/dangerous-tools-5ObDWy1N.js +32 -0
- package/dist/dangerous-tools-Jwr7jqNw.js +32 -0
- package/dist/deliver-D6cdhg5m.js +1097 -0
- package/dist/deliver-DlNDKlA4.js +1162 -0
- package/dist/deliver-bC6iI_rv.js +1097 -0
- package/dist/delivery-queue-B6IHz4Ry.js +220 -0
- package/dist/delivery-queue-TnQykYsg.js +220 -0
- package/dist/deps-C9kDG-Ru.js +42 -0
- package/dist/devices-cli-BE-Nib4Y.js +198 -0
- package/dist/devices-cli-GyPlNRyd.js +195 -0
- package/dist/diagnostics-Dj75aEHN.js +35 -0
- package/dist/diagnostics-DlIw6fqD.js +35 -0
- package/dist/directory-cli-BEaIvWkc.js +246 -0
- package/dist/directory-cli-CZ_-DP5Z.js +243 -0
- package/dist/dispatcher-Bkcui7jz.js +100 -0
- package/dist/dispatcher-C1B6cT_7.js +100 -0
- package/dist/display-A8k-mxv8.js +171 -0
- package/dist/display-BDOsXu8F.js +171 -0
- package/dist/dns-cli-BUzpVoMv.js +200 -0
- package/dist/dns-cli-DstQOMQt.js +197 -0
- package/dist/dock-DbxBBv30.js +753 -0
- package/dist/dock-cPBY4qGl.js +753 -0
- package/dist/docs-cli-BWp6p-Tq.js +161 -0
- package/dist/docs-cli-x22FnZfL.js +159 -0
- package/dist/doctor-B5HFw-nC.js +1813 -0
- package/dist/doctor-DnEyqGcQ.js +1815 -0
- package/dist/doctor-completion-BMEPXgVg.js +92 -0
- package/dist/doctor-completion-usPeH2ol.js +92 -0
- package/dist/doctor-config-flow-CS0WFnjL.js +1232 -0
- package/dist/doctor-config-flow-Cs4O_Kmq.js +1232 -0
- package/dist/engine-DgK9s3lk.js +561 -0
- package/dist/engine-ZSd5I5JN.js +561 -0
- package/dist/entry.js +1560 -0
- package/dist/env-0lJfCPsw.js +32 -0
- package/dist/errors-A_GqUU6B.js +26 -0
- package/dist/errors-CHow2wtt.js +37 -0
- package/dist/errors-Cojm0Kl7.js +37 -0
- package/dist/exec-BenD3A5l.js +1167 -0
- package/dist/exec-BizYYQgP.js +255 -0
- package/dist/exec-Bv3pyjeM.js +255 -0
- package/dist/exec-approvals-BP9AhCSw.js +1221 -0
- package/dist/exec-approvals-CdLmKX2R.js +1221 -0
- package/dist/exec-approvals-cli-25CGlFNw.js +368 -0
- package/dist/exec-approvals-cli-BXZ-hOlT.js +371 -0
- package/dist/extensionAPI.js +8542 -0
- package/dist/format-CjKG6raZ.js +20 -0
- package/dist/format-Mq6iU0_5.js +20 -0
- package/dist/format-duration-Cm3xh8xz.js +58 -0
- package/dist/format-duration-DhWzz_5b.js +58 -0
- package/dist/format-relative-C6kUHuOj.js +55 -0
- package/dist/format-relative-sy9iviQN.js +55 -0
- package/dist/frontmatter-YijVi0FQ.js +204 -0
- package/dist/gateway-cli-B9uc0RCI.js +19971 -0
- package/dist/gateway-cli-D8Qz7kCf.js +19972 -0
- package/dist/gateway-rpc-Ch9mCYEB.js +28 -0
- package/dist/gateway-rpc-DBhcdLFs.js +28 -0
- package/dist/github-copilot-auth-D6ZErYqa.js +1418 -0
- package/dist/github-copilot-auth-DGmyWJms.js +1418 -0
- package/dist/gmail-setup-utils-BPo_LkKI.js +428 -0
- package/dist/gmail-setup-utils-D3Yqgor7.js +428 -0
- package/dist/health-DsTZaAzV.js +1258 -0
- package/dist/health-V6dGthLA.js +1253 -0
- package/dist/health-format-CdP99j3Y.js +208 -0
- package/dist/health-format-JEChH08S.js +208 -0
- package/dist/heartbeat-visibility-CkL00WRR.js +98 -0
- package/dist/heartbeat-visibility-Cmni9671.js +98 -0
- package/dist/help-format-DUBI91Ti.js +17 -0
- package/dist/help-format-Dl4bsrLI.js +17 -0
- package/dist/helpers-9N2Q5aZj.js +25 -0
- package/dist/helpers-DLgbkcEn.js +25 -0
- package/dist/helpers-ZKNRexvX.js +10 -0
- package/dist/helpers-eJFa4K6r.js +10 -0
- package/dist/hooks-cli-Cu0D0fPS.js +993 -0
- package/dist/hooks-cli-E63uffR6.js +991 -0
- package/dist/hooks-status-B-e96dZj.js +356 -0
- package/dist/hooks-status-C_9sE0ox.js +356 -0
- package/dist/image-ops-Dlt3T7th.js +541 -0
- package/dist/image-ops-omlvdfah.js +541 -0
- package/dist/index.js +499 -0
- package/dist/init-Bm04RagW.js +122 -0
- package/dist/init-CaJBf4p1.js +122 -0
- package/dist/input-provenance-BgwBljRz.js +35 -0
- package/dist/input-provenance-DJBdpeKk.js +35 -0
- package/dist/input-provenance-iu26y0GH.js +35 -0
- package/dist/installs-C2iMRBVz.js +383 -0
- package/dist/installs-D-cPGdCw.js +383 -0
- package/dist/internal-hooks-DFTIurVM.js +77 -0
- package/dist/ipv4-C5QxzriV.js +1964 -0
- package/dist/ipv4-TxR9wQCQ.js +1964 -0
- package/dist/is-main-Dt9DTcH1.js +25 -0
- package/dist/is-main-cB3p7uob.js +25 -0
- package/dist/lanes-CNxj3tit.js +232 -0
- package/dist/legacy-names-CKU7tKQR.js +8 -0
- package/dist/lifecycle-core-B_7XRcvF.js +388 -0
- package/dist/lifecycle-core-By83PVAK.js +387 -0
- package/dist/links-BfjHVTB_.js +15 -0
- package/dist/links-DPGe0OHw.js +15 -0
- package/dist/llm-slug-generator.js +62 -0
- package/dist/loader-6Qkyybg1.js +87 -0
- package/dist/loader-Dmc0KyQK.js +87 -0
- package/dist/logging-54nXj81z.js +1 -0
- package/dist/logging-BdnOSVPD.js +1 -0
- package/dist/logging-DB6BQmhi.js +15 -0
- package/dist/logging-mcb66J0p.js +15 -0
- package/dist/login--8D8kyRy.js +61 -0
- package/dist/login-C-ugYHKt.js +61 -0
- package/dist/login-CX5Q2fYl.js +59 -0
- package/dist/login-qr-BLmGvITg.js +321 -0
- package/dist/login-qr-BNtuXLKL.js +323 -0
- package/dist/login-qr-PcyTC7Ra.js +326 -0
- package/dist/logs-cli-BEQVkiXp.js +245 -0
- package/dist/logs-cli-CIqiVMkY.js +242 -0
- package/dist/manager-Bsy9ifug.js +3244 -0
- package/dist/manager-CDgcZ51c.js +3246 -0
- package/dist/manager-D7QQ5XrE.js +3244 -0
- package/dist/manifest-registry-CW1zCyRF.js +748 -0
- package/dist/manifest-registry-D4lM2RdV.js +748 -0
- package/dist/markdown-tables-BT1X6jqH.js +347 -0
- package/dist/markdown-tables-DHgOK2vI.js +348 -0
- package/dist/media-THyainiE.js +1342 -0
- package/dist/memory-cli-BmIyAOZm.js +869 -0
- package/dist/memory-cli-BoXdfCLT.js +868 -0
- package/dist/message-channel-dSTVVCyX.js +110 -0
- package/dist/message-channel-w4F2b2F6.js +110 -0
- package/dist/migrate-BR6iAIjO.js +157 -0
- package/dist/migrate-D0EcMs0f.js +157 -0
- package/dist/mime-B1ZoR53M.js +145 -0
- package/dist/mime-Bm1xTtpY.js +145 -0
- package/dist/mime-C1RlpUSs.js +145 -0
- package/dist/model-param-b-C4BL7w0Z.js +16 -0
- package/dist/model-param-b-DPwyNGn8.js +16 -0
- package/dist/model-selection-BnEobs_z.js +2692 -0
- package/dist/models-KLd8Evmq.js +2545 -0
- package/dist/models-cli-D4UFQLid.js +258 -0
- package/dist/models-cli-DJHs5rJF.js +2739 -0
- package/dist/net-B5lXhYLV.js +218 -0
- package/dist/net-CDi_lJMH.js +88 -0
- package/dist/node-cli-BNCJUkgA.js +1319 -0
- package/dist/node-cli-C7S0vk0_.js +1322 -0
- package/dist/node-match-8XZnaid6.js +34 -0
- package/dist/node-match-B3Osv-5C.js +34 -0
- package/dist/node-service-BFxHJsno.js +67 -0
- package/dist/node-service-DUnan4uK.js +67 -0
- package/dist/nodes-cli-DOXhYgc8.js +1200 -0
- package/dist/nodes-cli-wvPZ3HwH.js +1197 -0
- package/dist/nodes-screen-1YiLkqr5.js +234 -0
- package/dist/nodes-screen-DZeD8hE5.js +234 -0
- package/dist/normalize-Dlcj9D3K.js +52 -0
- package/dist/normalize-GDK8JTNW.js +52 -0
- package/dist/note-Bi8Wb8DV.js +73 -0
- package/dist/note-uiuPxhyX.js +73 -0
- package/dist/npm-registry-spec-B-XIShkB.js +351 -0
- package/dist/npm-registry-spec-za3itb5Y.js +351 -0
- package/dist/onboard-DiTRW6CH.js +1165 -0
- package/dist/onboard-channels-BgruIpyg.js +672 -0
- package/dist/onboard-channels-gyq0VHHp.js +672 -0
- package/dist/onboard-helpers-BEaUind0.js +365 -0
- package/dist/onboard-helpers-f5Zprayl.js +365 -0
- package/dist/onboard-lH3XPWAK.js +1166 -0
- package/dist/onboarding-D0FOkXGt.js +910 -0
- package/dist/onboarding-kQVgbiIR.js +911 -0
- package/dist/openclaw-root-0yHXtO35.js +88 -0
- package/dist/openclaw-root-C85WMnVV.js +88 -0
- package/dist/orchestrator-CYTk7mq6.js +355 -0
- package/dist/orchestrator-J6ELnJXl.js +355 -0
- package/dist/outbound-BEq0qbPR.js +214 -0
- package/dist/outbound-BSVD-rjk.js +2062 -0
- package/dist/outbound-DXijk0db.js +214 -0
- package/dist/outbound-send-deps-ANnAhImn.js +14 -0
- package/dist/outbound-send-deps-BNGPU7jV.js +55 -0
- package/dist/pairing-cli-DKUyb6eK.js +118 -0
- package/dist/pairing-cli-ET2p_mXH.js +121 -0
- package/dist/pairing-store-CGYSwICJ.js +388 -0
- package/dist/pairing-store-DqQPqRMe.js +388 -0
- package/dist/parse-6-2MDhdT.js +23 -0
- package/dist/parse-CpunmTOS.js +23 -0
- package/dist/parse-log-line-Bqh1SSzC.js +44 -0
- package/dist/parse-log-line-DUZCjXbl.js +44 -0
- package/dist/parse-port-BKB9Exlg.js +12 -0
- package/dist/parse-port-DrfvwwiL.js +12 -0
- package/dist/parse-timeout-Di_tcEmi.js +16 -0
- package/dist/parse-timeout-vVlESvju.js +16 -0
- package/dist/path-env-Bu6k0jDQ.js +89 -0
- package/dist/path-env-C0zQSjw8.js +89 -0
- package/dist/paths-BTc4nk-6.js +126 -0
- package/dist/paths-BgUi2Z2G.js +54 -0
- package/dist/paths-C6VCWKo3.js +238 -0
- package/dist/paths-CCxa0o9c.js +222 -0
- package/dist/paths-CxRf2rBG.js +129 -0
- package/dist/paths-DcVEkYX5.js +54 -0
- package/dist/paths-hcX1Gqg5.js +129 -0
- package/dist/pi-auth-json-BzX-qyRo.js +82 -0
- package/dist/pi-auth-json-eesA38iW.js +78 -0
- package/dist/pi-auth-json-uEDdgg8K.js +80 -0
- package/dist/pi-embedded-C1Nl7L89.js +22 -0
- package/dist/pi-model-discovery-BkqhoPls.js +20 -0
- package/dist/pi-model-discovery-CQOWUAmK.js +3 -0
- package/dist/pi-model-discovery-DsRqYJLy.js +20 -0
- package/dist/pi-tools.policy-D9AUlreI.js +200 -0
- package/dist/pi-tools.policy-DRDm3v-2.js +200 -0
- package/dist/plugin-auto-enable-C-JwYMlZ.js +282 -0
- package/dist/plugin-auto-enable-DLIDBBfi.js +282 -0
- package/dist/plugin-registry-Bp8mivr-.js +32 -0
- package/dist/plugin-registry-CP7KgCvC.js +32 -0
- package/dist/plugin-sdk/account-id.d.ts +1 -0
- package/dist/plugin-sdk/account-id.js +15 -0
- package/dist/plugin-sdk/agents/agent-paths.d.ts +6 -0
- package/dist/plugin-sdk/agents/agent-scope.d.ts +37 -0
- package/dist/plugin-sdk/agents/anima-tools.d.ts +1 -0
- package/dist/plugin-sdk/agents/apply-patch-update.d.ts +10 -0
- package/dist/plugin-sdk/agents/apply-patch.d.ts +35 -0
- package/dist/plugin-sdk/agents/auth-profiles/constants.d.ts +20 -0
- package/dist/plugin-sdk/agents/auth-profiles/display.d.ts +7 -0
- package/dist/plugin-sdk/agents/auth-profiles/doctor.d.ts +8 -0
- package/dist/plugin-sdk/agents/auth-profiles/external-cli-sync.d.ts +7 -0
- package/dist/plugin-sdk/agents/auth-profiles/oauth.d.ts +12 -0
- package/dist/plugin-sdk/agents/auth-profiles/order.d.ts +8 -0
- package/dist/plugin-sdk/agents/auth-profiles/paths.d.ts +4 -0
- package/dist/plugin-sdk/agents/auth-profiles/profiles.d.ts +23 -0
- package/dist/plugin-sdk/agents/auth-profiles/repair.d.ts +14 -0
- package/dist/plugin-sdk/agents/auth-profiles/session-override.d.ts +18 -0
- package/dist/plugin-sdk/agents/auth-profiles/store.d.ts +10 -0
- package/dist/plugin-sdk/agents/auth-profiles/types.d.ts +60 -0
- package/dist/plugin-sdk/agents/auth-profiles/usage.d.ts +47 -0
- package/dist/plugin-sdk/agents/auth-profiles.d.ts +11 -0
- package/dist/plugin-sdk/agents/bash-process-registry.d.ts +70 -0
- package/dist/plugin-sdk/agents/bash-tools.d.ts +4 -0
- package/dist/plugin-sdk/agents/bash-tools.exec-runtime.d.ts +73 -0
- package/dist/plugin-sdk/agents/bash-tools.exec.d.ts +55 -0
- package/dist/plugin-sdk/agents/bash-tools.process.d.ts +7 -0
- package/dist/plugin-sdk/agents/bash-tools.shared.d.ts +48 -0
- package/dist/plugin-sdk/agents/bedrock-discovery.d.ts +9 -0
- package/dist/plugin-sdk/agents/bootstrap-files.d.ts +25 -0
- package/dist/plugin-sdk/agents/bootstrap-hooks.d.ts +10 -0
- package/dist/plugin-sdk/agents/channel-tools.d.ts +27 -0
- package/dist/plugin-sdk/agents/chutes-oauth.d.ts +46 -0
- package/dist/plugin-sdk/agents/cli-backends.d.ts +8 -0
- package/dist/plugin-sdk/agents/cli-credentials.d.ts +83 -0
- package/dist/plugin-sdk/agents/cli-runner/helpers.d.ts +76 -0
- package/dist/plugin-sdk/agents/cli-runner.d.ts +41 -0
- package/dist/plugin-sdk/agents/cli-session.d.ts +3 -0
- package/dist/plugin-sdk/agents/cloudflare-ai-gateway.d.ts +22 -0
- package/dist/plugin-sdk/agents/context.d.ts +1 -0
- package/dist/plugin-sdk/agents/current-time.d.ts +17 -0
- package/dist/plugin-sdk/agents/date-time.d.ts +13 -0
- package/dist/plugin-sdk/agents/defaults.d.ts +3 -0
- package/dist/plugin-sdk/agents/docs-path.d.ts +6 -0
- package/dist/plugin-sdk/agents/failover-error.d.ts +33 -0
- package/dist/plugin-sdk/agents/glob-pattern.d.ts +18 -0
- package/dist/plugin-sdk/agents/huggingface-models.d.ts +17 -0
- package/dist/plugin-sdk/agents/identity-avatar.d.ts +15 -0
- package/dist/plugin-sdk/agents/identity-file.d.ts +12 -0
- package/dist/plugin-sdk/agents/identity.d.ts +25 -0
- package/dist/plugin-sdk/agents/lanes.d.ts +3 -0
- package/dist/plugin-sdk/agents/memory-search.d.ts +66 -0
- package/dist/plugin-sdk/agents/minimax-vlm.d.ts +7 -0
- package/dist/plugin-sdk/agents/model-alias-lines.d.ts +2 -0
- package/dist/plugin-sdk/agents/model-auth.d.ts +36 -0
- package/dist/plugin-sdk/agents/model-catalog.d.ts +25 -0
- package/dist/plugin-sdk/agents/model-fallback.d.ts +40 -0
- package/dist/plugin-sdk/agents/model-selection.d.ts +94 -0
- package/dist/plugin-sdk/agents/models-config.d.ts +13 -0
- package/dist/plugin-sdk/agents/models-config.providers.d.ts +37 -0
- package/dist/plugin-sdk/agents/ollama-stream.d.ts +45 -0
- package/dist/plugin-sdk/agents/openclaw-tools.d.ts +46 -0
- package/dist/plugin-sdk/agents/pi-auth-json.d.ts +14 -0
- package/dist/plugin-sdk/agents/pi-embedded-helpers.d.ts +7 -0
- package/dist/plugin-sdk/agents/pi-embedded-runner/model.d.ts +1 -0
- package/dist/plugin-sdk/agents/pi-embedded-runner/run/params.d.ts +5 -0
- package/dist/plugin-sdk/agents/pi-embedded-runner.d.ts +25 -0
- package/dist/plugin-sdk/agents/pi-embedded-utils.d.ts +7 -0
- package/dist/plugin-sdk/agents/pi-embedded.d.ts +25 -0
- package/dist/plugin-sdk/agents/pi-model-discovery.d.ts +4 -0
- package/dist/plugin-sdk/agents/pi-settings.d.ts +19 -0
- package/dist/plugin-sdk/agents/pi-tools.abort.d.ts +2 -0
- package/dist/plugin-sdk/agents/pi-tools.before-tool-call.d.ts +29 -0
- package/dist/plugin-sdk/agents/pi-tools.d.ts +69 -0
- package/dist/plugin-sdk/agents/pi-tools.policy.d.ts +37 -0
- package/dist/plugin-sdk/agents/pi-tools.read.d.ts +44 -0
- package/dist/plugin-sdk/agents/pi-tools.schema.d.ts +3 -0
- package/dist/plugin-sdk/agents/pi-tools.types.d.ts +2 -0
- package/dist/plugin-sdk/agents/pty-dsr.d.ts +5 -0
- package/dist/plugin-sdk/agents/pty-keys.d.ts +13 -0
- package/dist/plugin-sdk/agents/sandbox/browser-bridges.d.ts +7 -0
- package/dist/plugin-sdk/agents/sandbox/browser.d.ts +12 -0
- package/dist/plugin-sdk/agents/sandbox/config-hash.d.ts +17 -0
- package/dist/plugin-sdk/agents/sandbox/config.d.ts +26 -0
- package/dist/plugin-sdk/agents/sandbox/constants.d.ts +19 -0
- package/dist/plugin-sdk/agents/sandbox/context.d.ts +12 -0
- package/dist/plugin-sdk/agents/sandbox/docker.d.ts +40 -0
- package/dist/plugin-sdk/agents/sandbox/fs-bridge.d.ts +56 -0
- package/dist/plugin-sdk/agents/sandbox/fs-paths.d.ts +28 -0
- package/dist/plugin-sdk/agents/sandbox/manage.d.ts +13 -0
- package/dist/plugin-sdk/agents/sandbox/prune.d.ts +3 -0
- package/dist/plugin-sdk/agents/sandbox/registry.d.ts +31 -0
- package/dist/plugin-sdk/agents/sandbox/runtime-status.d.ts +18 -0
- package/dist/plugin-sdk/agents/sandbox/shared.d.ts +4 -0
- package/dist/plugin-sdk/agents/sandbox/tool-policy.d.ts +4 -0
- package/dist/plugin-sdk/agents/sandbox/types.d.ts +76 -0
- package/dist/plugin-sdk/agents/sandbox/types.docker.d.ts +25 -0
- package/dist/plugin-sdk/agents/sandbox/workspace.d.ts +1 -0
- package/dist/plugin-sdk/agents/sandbox-paths.d.ts +23 -0
- package/dist/plugin-sdk/agents/sandbox.d.ts +8 -0
- package/dist/plugin-sdk/agents/schema/clean-for-gemini.d.ts +2 -0
- package/dist/plugin-sdk/agents/schema/typebox.d.ts +14 -0
- package/dist/plugin-sdk/agents/session-slug.d.ts +1 -0
- package/dist/plugin-sdk/agents/session-write-lock.d.ts +21 -0
- package/dist/plugin-sdk/agents/shell-utils.d.ts +7 -0
- package/dist/plugin-sdk/agents/skills/bundled-dir.d.ts +7 -0
- package/dist/plugin-sdk/agents/skills/config.d.ts +13 -0
- package/dist/plugin-sdk/agents/skills/env-overrides.d.ts +10 -0
- package/dist/plugin-sdk/agents/skills/frontmatter.d.ts +6 -0
- package/dist/plugin-sdk/agents/skills/plugin-skills.d.ts +5 -0
- package/dist/plugin-sdk/agents/skills/refresh.d.ts +19 -0
- package/dist/plugin-sdk/agents/skills/serialize.d.ts +1 -0
- package/dist/plugin-sdk/agents/skills/types.d.ts +80 -0
- package/dist/plugin-sdk/agents/skills/workspace.d.ts +49 -0
- package/dist/plugin-sdk/agents/skills.d.ts +7 -0
- package/dist/plugin-sdk/agents/subagent-announce-queue.d.ts +23 -0
- package/dist/plugin-sdk/agents/subagent-announce.d.ts +34 -0
- package/dist/plugin-sdk/agents/subagent-depth.d.ts +11 -0
- package/dist/plugin-sdk/agents/subagent-registry.d.ts +62 -0
- package/dist/plugin-sdk/agents/subagent-registry.store.d.ts +5 -0
- package/dist/plugin-sdk/agents/synthetic-models.d.ts +160 -0
- package/dist/plugin-sdk/agents/system-prompt-params.d.ts +30 -0
- package/dist/plugin-sdk/agents/system-prompt-report.d.ts +20 -0
- package/dist/plugin-sdk/agents/system-prompt.d.ts +78 -0
- package/dist/plugin-sdk/agents/timeout.d.ts +8 -0
- package/dist/plugin-sdk/agents/together-models.d.ts +4 -0
- package/dist/plugin-sdk/agents/tool-images.d.ts +19 -0
- package/dist/plugin-sdk/agents/tool-policy-pipeline.d.ts +27 -0
- package/dist/plugin-sdk/agents/tool-policy.d.ts +39 -0
- package/dist/plugin-sdk/agents/tool-summaries.d.ts +2 -0
- package/dist/plugin-sdk/agents/tools/agent-step.d.ts +15 -0
- package/dist/plugin-sdk/agents/tools/agents-list-tool.d.ts +6 -0
- package/dist/plugin-sdk/agents/tools/browser-tool.d.ts +5 -0
- package/dist/plugin-sdk/agents/tools/browser-tool.schema.d.ts +50 -0
- package/dist/plugin-sdk/agents/tools/canvas-tool.d.ts +2 -0
- package/dist/plugin-sdk/agents/tools/common.d.ts +56 -0
- package/dist/plugin-sdk/agents/tools/cron-tool.d.ts +6 -0
- package/dist/plugin-sdk/agents/tools/discord-actions-guild.d.ts +4 -0
- package/dist/plugin-sdk/agents/tools/discord-actions-messaging.d.ts +4 -0
- package/dist/plugin-sdk/agents/tools/discord-actions-moderation.d.ts +4 -0
- package/dist/plugin-sdk/agents/tools/discord-actions-presence.d.ts +4 -0
- package/dist/plugin-sdk/agents/tools/discord-actions.d.ts +3 -0
- package/dist/plugin-sdk/agents/tools/gateway-tool.d.ts +6 -0
- package/dist/plugin-sdk/agents/tools/gateway.d.ts +14 -0
- package/dist/plugin-sdk/agents/tools/image-tool.d.ts +35 -0
- package/dist/plugin-sdk/agents/tools/image-tool.helpers.d.ts +21 -0
- package/dist/plugin-sdk/agents/tools/memory-tool.d.ts +10 -0
- package/dist/plugin-sdk/agents/tools/message-tool.d.ts +18 -0
- package/dist/plugin-sdk/agents/tools/nodes-tool.d.ts +6 -0
- package/dist/plugin-sdk/agents/tools/nodes-utils.d.ts +20 -0
- package/dist/plugin-sdk/agents/tools/session-status-tool.d.ts +6 -0
- package/dist/plugin-sdk/agents/tools/sessions-announce-target.d.ts +5 -0
- package/dist/plugin-sdk/agents/tools/sessions-helpers.d.ts +90 -0
- package/dist/plugin-sdk/agents/tools/sessions-history-tool.d.ts +5 -0
- package/dist/plugin-sdk/agents/tools/sessions-list-tool.d.ts +5 -0
- package/dist/plugin-sdk/agents/tools/sessions-send-helpers.d.ts +34 -0
- package/dist/plugin-sdk/agents/tools/sessions-send-tool.a2a.d.ts +12 -0
- package/dist/plugin-sdk/agents/tools/sessions-send-tool.d.ts +7 -0
- package/dist/plugin-sdk/agents/tools/sessions-spawn-tool.d.ts +15 -0
- package/dist/plugin-sdk/agents/tools/slack-actions.d.ts +15 -0
- package/dist/plugin-sdk/agents/tools/subagents-tool.d.ts +4 -0
- package/dist/plugin-sdk/agents/tools/telegram-actions.d.ts +9 -0
- package/dist/plugin-sdk/agents/tools/tts-tool.d.ts +7 -0
- package/dist/plugin-sdk/agents/tools/web-fetch-utils.d.ts +18 -0
- package/dist/plugin-sdk/agents/tools/web-fetch.d.ts +25 -0
- package/dist/plugin-sdk/agents/tools/web-search.d.ts +71 -0
- package/dist/plugin-sdk/agents/tools/web-shared.d.ts +17 -0
- package/dist/plugin-sdk/agents/tools/web-tools.d.ts +2 -0
- package/dist/plugin-sdk/agents/tools/whatsapp-actions.d.ts +3 -0
- package/dist/plugin-sdk/agents/usage.d.ts +45 -0
- package/dist/plugin-sdk/agents/venice-models.d.ts +238 -0
- package/dist/plugin-sdk/agents/workspace-dir.d.ts +2 -0
- package/dist/plugin-sdk/agents/workspace-run.d.ts +18 -0
- package/dist/plugin-sdk/agents/workspace-templates.d.ts +6 -0
- package/dist/plugin-sdk/agents/workspace.d.ts +34 -0
- package/dist/plugin-sdk/auto-reply/chunk.d.ts +45 -0
- package/dist/plugin-sdk/auto-reply/command-auth.d.ts +17 -0
- package/dist/plugin-sdk/auto-reply/command-detection.d.ts +13 -0
- package/dist/plugin-sdk/auto-reply/commands-args.d.ts +3 -0
- package/dist/plugin-sdk/auto-reply/commands-registry.d.ts +54 -0
- package/dist/plugin-sdk/auto-reply/commands-registry.data.d.ts +3 -0
- package/dist/plugin-sdk/auto-reply/commands-registry.types.d.ts +66 -0
- package/dist/plugin-sdk/auto-reply/dispatch.d.ts +32 -0
- package/dist/plugin-sdk/auto-reply/envelope.d.ts +58 -0
- package/dist/plugin-sdk/auto-reply/group-activation.d.ts +6 -0
- package/dist/plugin-sdk/auto-reply/heartbeat-reply-payload.d.ts +2 -0
- package/dist/plugin-sdk/auto-reply/heartbeat.d.ts +26 -0
- package/dist/plugin-sdk/auto-reply/inbound-debounce.d.ts +16 -0
- package/dist/plugin-sdk/auto-reply/media-note.d.ts +2 -0
- package/dist/plugin-sdk/auto-reply/model.d.ts +8 -0
- package/dist/plugin-sdk/auto-reply/reply/abort.d.ts +22 -0
- package/dist/plugin-sdk/auto-reply/reply/agent-runner-execution.d.ts +49 -0
- package/dist/plugin-sdk/auto-reply/reply/agent-runner-helpers.d.ts +17 -0
- package/dist/plugin-sdk/auto-reply/reply/agent-runner-memory.d.ts +20 -0
- package/dist/plugin-sdk/auto-reply/reply/agent-runner-payloads.d.ts +25 -0
- package/dist/plugin-sdk/auto-reply/reply/agent-runner-utils.d.ts +30 -0
- package/dist/plugin-sdk/auto-reply/reply/agent-runner.d.ts +38 -0
- package/dist/plugin-sdk/auto-reply/reply/bash-command.d.ts +19 -0
- package/dist/plugin-sdk/auto-reply/reply/block-reply-coalescer.d.ts +15 -0
- package/dist/plugin-sdk/auto-reply/reply/block-reply-pipeline.d.ts +31 -0
- package/dist/plugin-sdk/auto-reply/reply/block-streaming.d.ts +22 -0
- package/dist/plugin-sdk/auto-reply/reply/body.d.ts +10 -0
- package/dist/plugin-sdk/auto-reply/reply/commands-allowlist.d.ts +2 -0
- package/dist/plugin-sdk/auto-reply/reply/commands-approve.d.ts +2 -0
- package/dist/plugin-sdk/auto-reply/reply/commands-bash.d.ts +2 -0
- package/dist/plugin-sdk/auto-reply/reply/commands-compact.d.ts +2 -0
- package/dist/plugin-sdk/auto-reply/reply/commands-config.d.ts +3 -0
- package/dist/plugin-sdk/auto-reply/reply/commands-context-report.d.ts +3 -0
- package/dist/plugin-sdk/auto-reply/reply/commands-context.d.ts +12 -0
- package/dist/plugin-sdk/auto-reply/reply/commands-core.d.ts +2 -0
- package/dist/plugin-sdk/auto-reply/reply/commands-info.d.ts +10 -0
- package/dist/plugin-sdk/auto-reply/reply/commands-models.d.ts +23 -0
- package/dist/plugin-sdk/auto-reply/reply/commands-plugin.d.ts +13 -0
- package/dist/plugin-sdk/auto-reply/reply/commands-session.d.ts +7 -0
- package/dist/plugin-sdk/auto-reply/reply/commands-status.d.ts +25 -0
- package/dist/plugin-sdk/auto-reply/reply/commands-subagents.d.ts +13 -0
- package/dist/plugin-sdk/auto-reply/reply/commands-tts.d.ts +2 -0
- package/dist/plugin-sdk/auto-reply/reply/commands-types.d.ts +60 -0
- package/dist/plugin-sdk/auto-reply/reply/commands.d.ts +4 -0
- package/dist/plugin-sdk/auto-reply/reply/config-commands.d.ts +15 -0
- package/dist/plugin-sdk/auto-reply/reply/config-value.d.ts +4 -0
- package/dist/plugin-sdk/auto-reply/reply/debug-commands.d.ts +16 -0
- package/dist/plugin-sdk/auto-reply/reply/directive-handling.auth.d.ts +19 -0
- package/dist/plugin-sdk/auto-reply/reply/directive-handling.d.ts +6 -0
- package/dist/plugin-sdk/auto-reply/reply/directive-handling.fast-lane.d.ts +7 -0
- package/dist/plugin-sdk/auto-reply/reply/directive-handling.impl.d.ts +3 -0
- package/dist/plugin-sdk/auto-reply/reply/directive-handling.model-picker.d.ts +13 -0
- package/dist/plugin-sdk/auto-reply/reply/directive-handling.model.d.ts +42 -0
- package/dist/plugin-sdk/auto-reply/reply/directive-handling.params.d.ts +51 -0
- package/dist/plugin-sdk/auto-reply/reply/directive-handling.parse.d.ts +62 -0
- package/dist/plugin-sdk/auto-reply/reply/directive-handling.persist.d.ts +37 -0
- package/dist/plugin-sdk/auto-reply/reply/directive-handling.queue-validation.d.ts +10 -0
- package/dist/plugin-sdk/auto-reply/reply/directive-handling.shared.d.ts +16 -0
- package/dist/plugin-sdk/auto-reply/reply/directive-parsing.d.ts +5 -0
- package/dist/plugin-sdk/auto-reply/reply/directives.d.ts +38 -0
- package/dist/plugin-sdk/auto-reply/reply/dispatch-from-config.d.ts +16 -0
- package/dist/plugin-sdk/auto-reply/reply/dispatcher-registry.d.ts +24 -0
- package/dist/plugin-sdk/auto-reply/reply/elevated-unavailable.d.ts +8 -0
- package/dist/plugin-sdk/auto-reply/reply/exec/directive.d.ts +20 -0
- package/dist/plugin-sdk/auto-reply/reply/exec.d.ts +1 -0
- package/dist/plugin-sdk/auto-reply/reply/followup-runner.d.ts +16 -0
- package/dist/plugin-sdk/auto-reply/reply/get-reply-directives-apply.d.ts +64 -0
- package/dist/plugin-sdk/auto-reply/reply/get-reply-directives-utils.d.ts +2 -0
- package/dist/plugin-sdk/auto-reply/reply/get-reply-directives.d.ts +92 -0
- package/dist/plugin-sdk/auto-reply/reply/get-reply-inline-actions.d.ts +59 -0
- package/dist/plugin-sdk/auto-reply/reply/get-reply-run.d.ts +69 -0
- package/dist/plugin-sdk/auto-reply/reply/get-reply.d.ts +4 -0
- package/dist/plugin-sdk/auto-reply/reply/groups.d.ts +26 -0
- package/dist/plugin-sdk/auto-reply/reply/history.d.ts +72 -0
- package/dist/plugin-sdk/auto-reply/reply/inbound-context.d.ts +8 -0
- package/dist/plugin-sdk/auto-reply/reply/inbound-dedupe.d.ts +8 -0
- package/dist/plugin-sdk/auto-reply/reply/inbound-meta.d.ts +3 -0
- package/dist/plugin-sdk/auto-reply/reply/inbound-text.d.ts +1 -0
- package/dist/plugin-sdk/auto-reply/reply/line-directives.d.ts +22 -0
- package/dist/plugin-sdk/auto-reply/reply/memory-flush.d.ts +23 -0
- package/dist/plugin-sdk/auto-reply/reply/mentions.d.ts +19 -0
- package/dist/plugin-sdk/auto-reply/reply/model-selection.d.ts +64 -0
- package/dist/plugin-sdk/auto-reply/reply/normalize-reply.d.ts +13 -0
- package/dist/plugin-sdk/auto-reply/reply/provider-dispatcher.d.ts +19 -0
- package/dist/plugin-sdk/auto-reply/reply/queue/cleanup.d.ts +6 -0
- package/dist/plugin-sdk/auto-reply/reply/queue/directive.d.ts +15 -0
- package/dist/plugin-sdk/auto-reply/reply/queue/drain.d.ts +2 -0
- package/dist/plugin-sdk/auto-reply/reply/queue/enqueue.d.ts +3 -0
- package/dist/plugin-sdk/auto-reply/reply/queue/normalize.d.ts +3 -0
- package/dist/plugin-sdk/auto-reply/reply/queue/settings.d.ts +2 -0
- package/dist/plugin-sdk/auto-reply/reply/queue/state.d.ts +19 -0
- package/dist/plugin-sdk/auto-reply/reply/queue/types.d.ts +84 -0
- package/dist/plugin-sdk/auto-reply/reply/queue.d.ts +8 -0
- package/dist/plugin-sdk/auto-reply/reply/reply-delivery.d.ts +27 -0
- package/dist/plugin-sdk/auto-reply/reply/reply-directives.d.ts +14 -0
- package/dist/plugin-sdk/auto-reply/reply/reply-dispatcher.d.ts +52 -0
- package/dist/plugin-sdk/auto-reply/reply/reply-elevated.d.ts +16 -0
- package/dist/plugin-sdk/auto-reply/reply/reply-inline.d.ts +8 -0
- package/dist/plugin-sdk/auto-reply/reply/reply-payloads.d.ts +22 -0
- package/dist/plugin-sdk/auto-reply/reply/reply-tags.d.ts +6 -0
- package/dist/plugin-sdk/auto-reply/reply/reply-threading.d.ts +9 -0
- package/dist/plugin-sdk/auto-reply/reply/response-prefix-template.d.ts +51 -0
- package/dist/plugin-sdk/auto-reply/reply/route-reply.d.ts +56 -0
- package/dist/plugin-sdk/auto-reply/reply/session-reset-model.d.ts +24 -0
- package/dist/plugin-sdk/auto-reply/reply/session-reset-prompt.d.ts +1 -0
- package/dist/plugin-sdk/auto-reply/reply/session-run-accounting.d.ts +11 -0
- package/dist/plugin-sdk/auto-reply/reply/session-updates.d.ts +34 -0
- package/dist/plugin-sdk/auto-reply/reply/session-usage.d.ts +21 -0
- package/dist/plugin-sdk/auto-reply/reply/session.d.ts +26 -0
- package/dist/plugin-sdk/auto-reply/reply/stage-sandbox-media.d.ts +9 -0
- package/dist/plugin-sdk/auto-reply/reply/subagents-utils.d.ts +7 -0
- package/dist/plugin-sdk/auto-reply/reply/typing-mode.d.ts +27 -0
- package/dist/plugin-sdk/auto-reply/reply/typing.d.ts +18 -0
- package/dist/plugin-sdk/auto-reply/reply/untrusted-context.d.ts +1 -0
- package/dist/plugin-sdk/auto-reply/reply.d.ts +6 -0
- package/dist/plugin-sdk/auto-reply/send-policy.d.ts +6 -0
- package/dist/plugin-sdk/auto-reply/skill-commands.d.ts +18 -0
- package/dist/plugin-sdk/auto-reply/status.d.ts +55 -0
- package/dist/plugin-sdk/auto-reply/templating.d.ts +152 -0
- package/dist/plugin-sdk/auto-reply/thinking.d.ts +22 -0
- package/dist/plugin-sdk/auto-reply/tokens.d.ts +3 -0
- package/dist/plugin-sdk/auto-reply/types.d.ts +61 -0
- package/dist/plugin-sdk/browser/bridge-auth-registry.d.ts +8 -0
- package/dist/plugin-sdk/browser/bridge-server.d.ts +18 -0
- package/dist/plugin-sdk/browser/cdp.d.ts +123 -0
- package/dist/plugin-sdk/browser/cdp.helpers.d.ts +13 -0
- package/dist/plugin-sdk/browser/chrome.d.ts +20 -0
- package/dist/plugin-sdk/browser/chrome.executables.d.ts +9 -0
- package/dist/plugin-sdk/browser/chrome.profile-decoration.d.ts +10 -0
- package/dist/plugin-sdk/browser/client-actions-core.d.ts +144 -0
- package/dist/plugin-sdk/browser/client-actions-observe.d.ts +68 -0
- package/dist/plugin-sdk/browser/client-actions-state.d.ts +90 -0
- package/dist/plugin-sdk/browser/client-actions-types.d.ts +18 -0
- package/dist/plugin-sdk/browser/client-actions.d.ts +4 -0
- package/dist/plugin-sdk/browser/client-fetch.d.ts +20 -0
- package/dist/plugin-sdk/browser/client.d.ts +147 -0
- package/dist/plugin-sdk/browser/config.d.ts +39 -0
- package/dist/plugin-sdk/browser/constants.d.ts +8 -0
- package/dist/plugin-sdk/browser/control-auth.d.ts +13 -0
- package/dist/plugin-sdk/browser/control-service.d.ts +5 -0
- package/dist/plugin-sdk/browser/csrf.d.ts +8 -0
- package/dist/plugin-sdk/browser/extension-relay.d.ts +15 -0
- package/dist/plugin-sdk/browser/http-auth.d.ts +5 -0
- package/dist/plugin-sdk/browser/paths.d.ts +27 -0
- package/dist/plugin-sdk/browser/profiles-service.d.ts +25 -0
- package/dist/plugin-sdk/browser/profiles.d.ts +30 -0
- package/dist/plugin-sdk/browser/proxy-files.d.ts +7 -0
- package/dist/plugin-sdk/browser/pw-ai-module.d.ts +6 -0
- package/dist/plugin-sdk/browser/pw-ai-state.d.ts +2 -0
- package/dist/plugin-sdk/browser/pw-ai.d.ts +2 -0
- package/dist/plugin-sdk/browser/pw-role-snapshot.d.ts +35 -0
- package/dist/plugin-sdk/browser/pw-session.d.ts +160 -0
- package/dist/plugin-sdk/browser/pw-tools-core.activity.d.ts +21 -0
- package/dist/plugin-sdk/browser/pw-tools-core.d.ts +8 -0
- package/dist/plugin-sdk/browser/pw-tools-core.downloads.d.ts +34 -0
- package/dist/plugin-sdk/browser/pw-tools-core.interactions.d.ts +114 -0
- package/dist/plugin-sdk/browser/pw-tools-core.responses.d.ts +13 -0
- package/dist/plugin-sdk/browser/pw-tools-core.shared.d.ts +6 -0
- package/dist/plugin-sdk/browser/pw-tools-core.snapshot.d.ts +64 -0
- package/dist/plugin-sdk/browser/pw-tools-core.state.d.ts +46 -0
- package/dist/plugin-sdk/browser/pw-tools-core.storage.d.ts +47 -0
- package/dist/plugin-sdk/browser/pw-tools-core.trace.d.ts +12 -0
- package/dist/plugin-sdk/browser/resolved-config-refresh.d.ts +12 -0
- package/dist/plugin-sdk/browser/routes/agent.act.d.ts +3 -0
- package/dist/plugin-sdk/browser/routes/agent.act.shared.d.ts +10 -0
- package/dist/plugin-sdk/browser/routes/agent.d.ts +3 -0
- package/dist/plugin-sdk/browser/routes/agent.debug.d.ts +3 -0
- package/dist/plugin-sdk/browser/routes/agent.shared.d.ts +9 -0
- package/dist/plugin-sdk/browser/routes/agent.snapshot.d.ts +3 -0
- package/dist/plugin-sdk/browser/routes/agent.storage.d.ts +3 -0
- package/dist/plugin-sdk/browser/routes/basic.d.ts +3 -0
- package/dist/plugin-sdk/browser/routes/dispatcher.d.ts +16 -0
- package/dist/plugin-sdk/browser/routes/index.d.ts +3 -0
- package/dist/plugin-sdk/browser/routes/path-output.d.ts +1 -0
- package/dist/plugin-sdk/browser/routes/tabs.d.ts +3 -0
- package/dist/plugin-sdk/browser/routes/types.d.ts +20 -0
- package/dist/plugin-sdk/browser/routes/utils.d.ts +15 -0
- package/dist/plugin-sdk/browser/screenshot.d.ts +9 -0
- package/dist/plugin-sdk/browser/server-context.d.ts +4 -0
- package/dist/plugin-sdk/browser/server-context.types.d.ts +79 -0
- package/dist/plugin-sdk/browser/server-middleware.d.ts +6 -0
- package/dist/plugin-sdk/browser/target-id.d.ts +11 -0
- package/dist/plugin-sdk/browser/trash.d.ts +1 -0
- package/dist/plugin-sdk/channel-web.d.ts +6 -0
- package/dist/plugin-sdk/channels/account-summary.d.ts +17 -0
- package/dist/plugin-sdk/channels/ack-reactions.d.ts +29 -0
- package/dist/plugin-sdk/channels/allowlist-match.d.ts +15 -0
- package/dist/plugin-sdk/channels/allowlists/resolve-utils.d.ts +20 -0
- package/dist/plugin-sdk/channels/channel-config.d.ts +39 -0
- package/dist/plugin-sdk/channels/chat-type.d.ts +2 -0
- package/dist/plugin-sdk/channels/command-gating.d.ts +20 -0
- package/dist/plugin-sdk/channels/conversation-label.d.ts +2 -0
- package/dist/plugin-sdk/channels/dock.d.ts +36 -0
- package/dist/plugin-sdk/channels/location.d.ts +21 -0
- package/dist/plugin-sdk/channels/logging.d.ts +20 -0
- package/dist/plugin-sdk/channels/mention-gating.d.ts +27 -0
- package/dist/plugin-sdk/channels/plugins/actions/discord/handle-action.d.ts +3 -0
- package/dist/plugin-sdk/channels/plugins/actions/discord/handle-action.guild-admin.d.ts +9 -0
- package/dist/plugin-sdk/channels/plugins/actions/discord.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/actions/signal.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/actions/telegram.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/agent-tools/whatsapp-login.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/allowlist-match.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/bluebubbles-actions.d.ts +48 -0
- package/dist/plugin-sdk/channels/plugins/channel-config.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/config-helpers.d.ts +14 -0
- package/dist/plugin-sdk/channels/plugins/config-schema.d.ts +3 -0
- package/dist/plugin-sdk/channels/plugins/config-writes.d.ts +7 -0
- package/dist/plugin-sdk/channels/plugins/directory-config.d.ts +16 -0
- package/dist/plugin-sdk/channels/plugins/group-mentions.d.ts +28 -0
- package/dist/plugin-sdk/channels/plugins/helpers.d.ts +8 -0
- package/dist/plugin-sdk/channels/plugins/index.d.ts +8 -0
- package/dist/plugin-sdk/channels/plugins/media-limits.d.ts +9 -0
- package/dist/plugin-sdk/channels/plugins/message-action-names.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/message-actions.d.ts +7 -0
- package/dist/plugin-sdk/channels/plugins/normalize/discord.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/normalize/imessage.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/normalize/signal.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/normalize/slack.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/normalize/telegram.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/normalize/whatsapp.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/onboarding/channel-access.d.ts +31 -0
- package/dist/plugin-sdk/channels/plugins/onboarding/discord.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/onboarding/helpers.d.ts +3 -0
- package/dist/plugin-sdk/channels/plugins/onboarding/imessage.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/onboarding/signal.d.ts +3 -0
- package/dist/plugin-sdk/channels/plugins/onboarding/slack.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/onboarding/telegram.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/onboarding/whatsapp.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/onboarding-types.d.ts +77 -0
- package/dist/plugin-sdk/channels/plugins/outbound/load.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/pairing-message.d.ts +1 -0
- package/dist/plugin-sdk/channels/plugins/pairing.d.ts +16 -0
- package/dist/plugin-sdk/channels/plugins/setup-helpers.d.ts +13 -0
- package/dist/plugin-sdk/channels/plugins/status-issues/bluebubbles.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/status-issues/discord.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/status-issues/shared.d.ts +11 -0
- package/dist/plugin-sdk/channels/plugins/status-issues/telegram.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/status-issues/whatsapp.d.ts +2 -0
- package/dist/plugin-sdk/channels/plugins/types.adapters.d.ts +297 -0
- package/dist/plugin-sdk/channels/plugins/types.core.d.ts +329 -0
- package/dist/plugin-sdk/channels/plugins/types.d.ts +6 -0
- package/dist/plugin-sdk/channels/plugins/types.plugin.d.ts +53 -0
- package/dist/plugin-sdk/channels/plugins/whatsapp-heartbeat.d.ts +11 -0
- package/dist/plugin-sdk/channels/registry.d.ts +16 -0
- package/dist/plugin-sdk/channels/reply-prefix.d.ts +24 -0
- package/dist/plugin-sdk/channels/sender-label.d.ts +9 -0
- package/dist/plugin-sdk/channels/session.d.ts +18 -0
- package/dist/plugin-sdk/channels/typing.d.ts +12 -0
- package/dist/plugin-sdk/channels/web/index.d.ts +1 -0
- package/dist/plugin-sdk/cli/cli-name.d.ts +3 -0
- package/dist/plugin-sdk/cli/cli-utils.d.ts +19 -0
- package/dist/plugin-sdk/cli/command-format.d.ts +1 -0
- package/dist/plugin-sdk/cli/deps.d.ts +18 -0
- package/dist/plugin-sdk/cli/memory-cli.d.ts +12 -0
- package/dist/plugin-sdk/cli/nodes-camera.d.ts +32 -0
- package/dist/plugin-sdk/cli/nodes-canvas.d.ts +10 -0
- package/dist/plugin-sdk/cli/nodes-run.d.ts +3 -0
- package/dist/plugin-sdk/cli/nodes-screen.d.ts +18 -0
- package/dist/plugin-sdk/cli/parse-bytes.d.ts +4 -0
- package/dist/plugin-sdk/cli/parse-duration.d.ts +4 -0
- package/dist/plugin-sdk/cli/parse-timeout.d.ts +1 -0
- package/dist/plugin-sdk/cli/profile-utils.d.ts +2 -0
- package/dist/plugin-sdk/cli/progress.d.ts +24 -0
- package/dist/plugin-sdk/cli/prompt.d.ts +1 -0
- package/dist/plugin-sdk/cli/wait.d.ts +1 -0
- package/dist/plugin-sdk/commands/agent/types.d.ts +77 -0
- package/dist/plugin-sdk/commands/daemon-runtime.d.ts +8 -0
- package/dist/plugin-sdk/commands/health.d.ts +63 -0
- package/dist/plugin-sdk/commands/oauth-flow.d.ts +21 -0
- package/dist/plugin-sdk/commands/onboard-helpers.d.ts +82 -0
- package/dist/plugin-sdk/commands/onboard-types.d.ts +76 -0
- package/dist/plugin-sdk/commands/signal-install.d.ts +30 -0
- package/dist/plugin-sdk/compat/legacy-names.d.ts +8 -0
- package/dist/plugin-sdk/config/agent-dirs.d.ts +14 -0
- package/dist/plugin-sdk/config/agent-limits.d.ts +5 -0
- package/dist/plugin-sdk/config/backup-rotation.d.ts +5 -0
- package/dist/plugin-sdk/config/cache-utils.d.ts +6 -0
- package/dist/plugin-sdk/config/config-paths.d.ts +10 -0
- package/dist/plugin-sdk/config/config.d.ts +7 -0
- package/dist/plugin-sdk/config/defaults.d.ts +18 -0
- package/dist/plugin-sdk/config/env-preserve.d.ts +25 -0
- package/dist/plugin-sdk/config/env-substitution.d.ts +36 -0
- package/dist/plugin-sdk/config/env-vars.d.ts +3 -0
- package/dist/plugin-sdk/config/group-policy.d.ts +47 -0
- package/dist/plugin-sdk/config/includes.d.ts +32 -0
- package/dist/plugin-sdk/config/io.d.ts +55 -0
- package/dist/plugin-sdk/config/legacy-migrate.d.ts +5 -0
- package/dist/plugin-sdk/config/legacy.d.ts +6 -0
- package/dist/plugin-sdk/config/legacy.migrations.d.ts +1 -0
- package/dist/plugin-sdk/config/legacy.migrations.part-1.d.ts +2 -0
- package/dist/plugin-sdk/config/legacy.migrations.part-2.d.ts +2 -0
- package/dist/plugin-sdk/config/legacy.migrations.part-3.d.ts +2 -0
- package/dist/plugin-sdk/config/legacy.rules.d.ts +2 -0
- package/dist/plugin-sdk/config/legacy.shared.d.ts +19 -0
- package/dist/plugin-sdk/config/markdown-tables.d.ts +7 -0
- package/dist/plugin-sdk/config/merge-config.d.ts +7 -0
- package/dist/plugin-sdk/config/merge-patch.d.ts +5 -0
- package/dist/plugin-sdk/config/normalize-paths.d.ts +8 -0
- package/dist/plugin-sdk/config/paths.d.ts +57 -0
- package/dist/plugin-sdk/config/port-defaults.d.ts +13 -0
- package/dist/plugin-sdk/config/runtime-overrides.d.ts +15 -0
- package/dist/plugin-sdk/config/sessions/delivery-info.d.ts +12 -0
- package/dist/plugin-sdk/config/sessions/group.d.ts +11 -0
- package/dist/plugin-sdk/config/sessions/main-session.d.ts +43 -0
- package/dist/plugin-sdk/config/sessions/metadata.d.ts +16 -0
- package/dist/plugin-sdk/config/sessions/paths.d.ts +21 -0
- package/dist/plugin-sdk/config/sessions/reset.d.ts +43 -0
- package/dist/plugin-sdk/config/sessions/session-key.d.ts +8 -0
- package/dist/plugin-sdk/config/sessions/store.d.ts +99 -0
- package/dist/plugin-sdk/config/sessions/transcript.d.ts +18 -0
- package/dist/plugin-sdk/config/sessions/types.d.ts +156 -0
- package/dist/plugin-sdk/config/sessions.d.ts +10 -0
- package/dist/plugin-sdk/config/talk.d.ts +11 -0
- package/dist/plugin-sdk/config/telegram-custom-commands.d.ts +24 -0
- package/dist/plugin-sdk/config/types.agent-defaults.d.ts +260 -0
- package/dist/plugin-sdk/config/types.agents.d.ts +80 -0
- package/dist/plugin-sdk/config/types.anima.d.ts +1 -0
- package/dist/plugin-sdk/config/types.approvals.d.ts +26 -0
- package/dist/plugin-sdk/config/types.auth.d.ts +28 -0
- package/dist/plugin-sdk/config/types.base.d.ts +172 -0
- package/dist/plugin-sdk/config/types.browser.d.ts +41 -0
- package/dist/plugin-sdk/config/types.channels.d.ts +48 -0
- package/dist/plugin-sdk/config/types.cron.d.ts +11 -0
- package/dist/plugin-sdk/config/types.d.ts +30 -0
- package/dist/plugin-sdk/config/types.discord.d.ts +188 -0
- package/dist/plugin-sdk/config/types.gateway.d.ts +288 -0
- package/dist/plugin-sdk/config/types.googlechat.d.ts +100 -0
- package/dist/plugin-sdk/config/types.hooks.d.ts +128 -0
- package/dist/plugin-sdk/config/types.imessage.d.ts +71 -0
- package/dist/plugin-sdk/config/types.irc.d.ts +96 -0
- package/dist/plugin-sdk/config/types.memory.d.ts +45 -0
- package/dist/plugin-sdk/config/types.messages.d.ts +121 -0
- package/dist/plugin-sdk/config/types.models.d.ts +54 -0
- package/dist/plugin-sdk/config/types.msteams.d.ts +101 -0
- package/dist/plugin-sdk/config/types.node-host.d.ts +10 -0
- package/dist/plugin-sdk/config/types.openclaw.d.ts +114 -0
- package/dist/plugin-sdk/config/types.plugins.d.ts +32 -0
- package/dist/plugin-sdk/config/types.queue.d.ts +14 -0
- package/dist/plugin-sdk/config/types.sandbox.d.ts +78 -0
- package/dist/plugin-sdk/config/types.signal.d.ts +86 -0
- package/dist/plugin-sdk/config/types.skills.d.ts +28 -0
- package/dist/plugin-sdk/config/types.slack.d.ts +150 -0
- package/dist/plugin-sdk/config/types.telegram.d.ts +163 -0
- package/dist/plugin-sdk/config/types.tools.d.ts +467 -0
- package/dist/plugin-sdk/config/types.tts.d.ts +78 -0
- package/dist/plugin-sdk/config/types.whatsapp.d.ts +142 -0
- package/dist/plugin-sdk/config/validation.d.ts +37 -0
- package/dist/plugin-sdk/config/version.d.ts +8 -0
- package/dist/plugin-sdk/config/zod-schema.agent-defaults.d.ts +249 -0
- package/dist/plugin-sdk/config/zod-schema.agent-runtime.d.ts +856 -0
- package/dist/plugin-sdk/config/zod-schema.agents.d.ts +504 -0
- package/dist/plugin-sdk/config/zod-schema.allowdeny.d.ts +13 -0
- package/dist/plugin-sdk/config/zod-schema.approvals.d.ts +15 -0
- package/dist/plugin-sdk/config/zod-schema.channels.d.ts +6 -0
- package/dist/plugin-sdk/config/zod-schema.core.d.ts +683 -0
- package/dist/plugin-sdk/config/zod-schema.d.ts +3401 -0
- package/dist/plugin-sdk/config/zod-schema.hooks.d.ts +79 -0
- package/dist/plugin-sdk/config/zod-schema.providers-core.d.ts +3233 -0
- package/dist/plugin-sdk/config/zod-schema.providers-whatsapp.d.ts +231 -0
- package/dist/plugin-sdk/config/zod-schema.providers.d.ts +1900 -0
- package/dist/plugin-sdk/config/zod-schema.sensitive.d.ts +2 -0
- package/dist/plugin-sdk/config/zod-schema.session.d.ts +203 -0
- package/dist/plugin-sdk/cron/delivery.d.ts +9 -0
- package/dist/plugin-sdk/cron/normalize.d.ts +9 -0
- package/dist/plugin-sdk/cron/parse.d.ts +1 -0
- package/dist/plugin-sdk/cron/payload-migration.d.ts +3 -0
- package/dist/plugin-sdk/cron/schedule.d.ts +2 -0
- package/dist/plugin-sdk/cron/service/jobs.d.ts +21 -0
- package/dist/plugin-sdk/cron/service/locked.d.ts +2 -0
- package/dist/plugin-sdk/cron/service/normalize.d.ts +17 -0
- package/dist/plugin-sdk/cron/service/ops.d.ts +43 -0
- package/dist/plugin-sdk/cron/service/state.d.ts +121 -0
- package/dist/plugin-sdk/cron/service/store.d.ts +9 -0
- package/dist/plugin-sdk/cron/service/timer.d.ts +25 -0
- package/dist/plugin-sdk/cron/service.d.ts +48 -0
- package/dist/plugin-sdk/cron/session-reaper.d.ts +35 -0
- package/dist/plugin-sdk/cron/store.d.ts +6 -0
- package/dist/plugin-sdk/cron/types.d.ts +95 -0
- package/dist/plugin-sdk/daemon/constants.d.ts +30 -0
- package/dist/plugin-sdk/discord/accounts.d.ts +9 -0
- package/dist/plugin-sdk/discord/audit.d.ts +2 -0
- package/dist/plugin-sdk/discord/directory-live.d.ts +4 -0
- package/dist/plugin-sdk/discord/monitor/allow-list.d.ts +1 -0
- package/dist/plugin-sdk/discord/monitor/gateway-registry.d.ts +3 -0
- package/dist/plugin-sdk/discord/monitor/presence-cache.d.ts +1 -0
- package/dist/plugin-sdk/discord/monitor.d.ts +3 -0
- package/dist/plugin-sdk/discord/pluralkit.d.ts +1 -0
- package/dist/plugin-sdk/discord/probe.d.ts +3 -0
- package/dist/plugin-sdk/discord/resolve-channels.d.ts +1 -0
- package/dist/plugin-sdk/discord/resolve-users.d.ts +1 -0
- package/dist/plugin-sdk/discord/send.d.ts +6 -0
- package/dist/plugin-sdk/discord/targets.d.ts +2 -0
- package/dist/plugin-sdk/gateway/auth-rate-limit.d.ts +59 -0
- package/dist/plugin-sdk/gateway/auth.d.ts +48 -0
- package/dist/plugin-sdk/gateway/call.d.ts +51 -0
- package/dist/plugin-sdk/gateway/chat-abort.d.ts +44 -0
- package/dist/plugin-sdk/gateway/chat-sanitize.d.ts +4 -0
- package/dist/plugin-sdk/gateway/client.d.ts +63 -0
- package/dist/plugin-sdk/gateway/control-ui-shared.d.ts +9 -0
- package/dist/plugin-sdk/gateway/device-auth.d.ts +12 -0
- package/dist/plugin-sdk/gateway/exec-approval-manager.d.ts +44 -0
- package/dist/plugin-sdk/gateway/net.d.ts +57 -0
- package/dist/plugin-sdk/gateway/node-registry.d.ts +60 -0
- package/dist/plugin-sdk/gateway/protocol/client-info.d.ts +58 -0
- package/dist/plugin-sdk/gateway/protocol/index.d.ts +661 -0
- package/dist/plugin-sdk/gateway/protocol/schema/agent.d.ts +86 -0
- package/dist/plugin-sdk/gateway/protocol/schema/agents-models-skills.d.ts +152 -0
- package/dist/plugin-sdk/gateway/protocol/schema/channels.d.ts +126 -0
- package/dist/plugin-sdk/gateway/protocol/schema/config.d.ts +51 -0
- package/dist/plugin-sdk/gateway/protocol/schema/cron.d.ts +353 -0
- package/dist/plugin-sdk/gateway/protocol/schema/devices.d.ts +38 -0
- package/dist/plugin-sdk/gateway/protocol/schema/error-codes.d.ts +14 -0
- package/dist/plugin-sdk/gateway/protocol/schema/exec-approvals.d.ts +163 -0
- package/dist/plugin-sdk/gateway/protocol/schema/frames.d.ts +164 -0
- package/dist/plugin-sdk/gateway/protocol/schema/logs-chat.d.ts +45 -0
- package/dist/plugin-sdk/gateway/protocol/schema/nodes.d.ts +64 -0
- package/dist/plugin-sdk/gateway/protocol/schema/primitives.d.ts +4 -0
- package/dist/plugin-sdk/gateway/protocol/schema/protocol-schemas.d.ts +3 -0
- package/dist/plugin-sdk/gateway/protocol/schema/sessions.d.ts +76 -0
- package/dist/plugin-sdk/gateway/protocol/schema/snapshot.d.ts +64 -0
- package/dist/plugin-sdk/gateway/protocol/schema/types.d.ts +124 -0
- package/dist/plugin-sdk/gateway/protocol/schema/wizard.d.ts +86 -0
- package/dist/plugin-sdk/gateway/protocol/schema.d.ts +16 -0
- package/dist/plugin-sdk/gateway/server/ws-types.d.ts +9 -0
- package/dist/plugin-sdk/gateway/server-channels.d.ts +24 -0
- package/dist/plugin-sdk/gateway/server-methods/types.d.ts +98 -0
- package/dist/plugin-sdk/gateway/server-shared.d.ts +7 -0
- package/dist/plugin-sdk/gateway/session-utils.d.ts +71 -0
- package/dist/plugin-sdk/gateway/session-utils.fs.d.ts +33 -0
- package/dist/plugin-sdk/gateway/session-utils.types.d.ts +84 -0
- package/dist/plugin-sdk/globals.d.ts +11 -0
- package/dist/plugin-sdk/hooks/internal-hooks.d.ts +95 -0
- package/dist/plugin-sdk/hooks/types.d.ts +62 -0
- package/dist/plugin-sdk/imessage/accounts.d.ts +8 -0
- package/dist/plugin-sdk/imessage/monitor.d.ts +3 -0
- package/dist/plugin-sdk/imessage/probe.d.ts +3 -0
- package/dist/plugin-sdk/imessage/send.d.ts +1 -0
- package/dist/plugin-sdk/imessage/target-parsing-helpers.d.ts +4 -0
- package/dist/plugin-sdk/imessage/targets.d.ts +2 -0
- package/dist/plugin-sdk/index.d.ts +1 -0
- package/dist/plugin-sdk/index.js +27570 -0
- package/dist/plugin-sdk/infra/agent-events.d.ts +21 -0
- package/dist/plugin-sdk/infra/anima-root.d.ts +1 -0
- package/dist/plugin-sdk/infra/archive.d.ts +41 -0
- package/dist/plugin-sdk/infra/backoff.d.ts +8 -0
- package/dist/plugin-sdk/infra/binaries.d.ts +3 -0
- package/dist/plugin-sdk/infra/brew.d.ts +8 -0
- package/dist/plugin-sdk/infra/channel-activity.d.ts +18 -0
- package/dist/plugin-sdk/infra/channel-summary.d.ts +6 -0
- package/dist/plugin-sdk/infra/dedupe.d.ts +11 -0
- package/dist/plugin-sdk/infra/device-auth-store.d.ts +18 -0
- package/dist/plugin-sdk/infra/device-identity.d.ts +11 -0
- package/dist/plugin-sdk/infra/device-pairing.d.ts +96 -0
- package/dist/plugin-sdk/infra/diagnostic-events.d.ts +121 -0
- package/dist/plugin-sdk/infra/dotenv.d.ts +3 -0
- package/dist/plugin-sdk/infra/env.d.ts +11 -0
- package/dist/plugin-sdk/infra/errors.d.ts +11 -0
- package/dist/plugin-sdk/infra/exec-approvals-allowlist.d.ts +45 -0
- package/dist/plugin-sdk/infra/exec-approvals-analysis.d.ts +78 -0
- package/dist/plugin-sdk/infra/exec-approvals.d.ts +107 -0
- package/dist/plugin-sdk/infra/exec-safety.d.ts +1 -0
- package/dist/plugin-sdk/infra/fetch.d.ts +2 -0
- package/dist/plugin-sdk/infra/file-lock.d.ts +2 -0
- package/dist/plugin-sdk/infra/format-time/format-datetime.d.ts +35 -0
- package/dist/plugin-sdk/infra/format-time/format-duration.d.ts +23 -0
- package/dist/plugin-sdk/infra/format-time/format-relative.d.ts +39 -0
- package/dist/plugin-sdk/infra/git-commit.d.ts +4 -0
- package/dist/plugin-sdk/infra/heartbeat-active-hours.d.ts +5 -0
- package/dist/plugin-sdk/infra/heartbeat-events-filter.d.ts +3 -0
- package/dist/plugin-sdk/infra/heartbeat-events.d.ts +21 -0
- package/dist/plugin-sdk/infra/heartbeat-runner.d.ts +45 -0
- package/dist/plugin-sdk/infra/heartbeat-visibility.d.ts +17 -0
- package/dist/plugin-sdk/infra/heartbeat-wake.d.ts +27 -0
- package/dist/plugin-sdk/infra/home-dir.d.ts +7 -0
- package/dist/plugin-sdk/infra/http-body.d.ts +46 -0
- package/dist/plugin-sdk/infra/json-file.d.ts +2 -0
- package/dist/plugin-sdk/infra/net/fetch-guard.d.ts +21 -0
- package/dist/plugin-sdk/infra/net/ssrf.d.ts +32 -0
- package/dist/plugin-sdk/infra/node-pairing.d.ts +62 -0
- package/dist/plugin-sdk/infra/node-shell.d.ts +1 -0
- package/dist/plugin-sdk/infra/openclaw-root.d.ts +10 -0
- package/dist/plugin-sdk/infra/outbound/abort.d.ts +8 -0
- package/dist/plugin-sdk/infra/outbound/channel-adapters.d.ts +6 -0
- package/dist/plugin-sdk/infra/outbound/channel-selection.d.ts +11 -0
- package/dist/plugin-sdk/infra/outbound/channel-target.d.ts +6 -0
- package/dist/plugin-sdk/infra/outbound/deliver.d.ts +77 -0
- package/dist/plugin-sdk/infra/outbound/delivery-queue.d.ts +103 -0
- package/dist/plugin-sdk/infra/outbound/directory-cache.d.ts +24 -0
- package/dist/plugin-sdk/infra/outbound/identity.d.ts +8 -0
- package/dist/plugin-sdk/infra/outbound/message-action-params.d.ts +47 -0
- package/dist/plugin-sdk/infra/outbound/message-action-runner.d.ts +74 -0
- package/dist/plugin-sdk/infra/outbound/message-action-spec.d.ts +5 -0
- package/dist/plugin-sdk/infra/outbound/message.d.ts +85 -0
- package/dist/plugin-sdk/infra/outbound/outbound-policy.d.ts +31 -0
- package/dist/plugin-sdk/infra/outbound/outbound-send-service.d.ts +64 -0
- package/dist/plugin-sdk/infra/outbound/outbound-session.d.ts +31 -0
- package/dist/plugin-sdk/infra/outbound/payloads.d.ts +16 -0
- package/dist/plugin-sdk/infra/outbound/target-errors.d.ts +6 -0
- package/dist/plugin-sdk/infra/outbound/target-normalization.d.ts +4 -0
- package/dist/plugin-sdk/infra/outbound/target-resolver.d.ts +53 -0
- package/dist/plugin-sdk/infra/outbound/targets.d.ts +65 -0
- package/dist/plugin-sdk/infra/outbound/tool-payload.d.ts +2 -0
- package/dist/plugin-sdk/infra/pairing-files.d.ts +11 -0
- package/dist/plugin-sdk/infra/pairing-token.d.ts +3 -0
- package/dist/plugin-sdk/infra/path-prepend.d.ts +5 -0
- package/dist/plugin-sdk/infra/ports-format.d.ts +5 -0
- package/dist/plugin-sdk/infra/ports-inspect.d.ts +2 -0
- package/dist/plugin-sdk/infra/ports-lsof.d.ts +2 -0
- package/dist/plugin-sdk/infra/ports-types.d.ts +17 -0
- package/dist/plugin-sdk/infra/ports.d.ts +14 -0
- package/dist/plugin-sdk/infra/provider-usage.auth.d.ts +11 -0
- package/dist/plugin-sdk/infra/provider-usage.d.ts +4 -0
- package/dist/plugin-sdk/infra/provider-usage.fetch.antigravity.d.ts +2 -0
- package/dist/plugin-sdk/infra/provider-usage.fetch.claude.d.ts +2 -0
- package/dist/plugin-sdk/infra/provider-usage.fetch.codex.d.ts +2 -0
- package/dist/plugin-sdk/infra/provider-usage.fetch.copilot.d.ts +2 -0
- package/dist/plugin-sdk/infra/provider-usage.fetch.d.ts +7 -0
- package/dist/plugin-sdk/infra/provider-usage.fetch.gemini.d.ts +2 -0
- package/dist/plugin-sdk/infra/provider-usage.fetch.minimax.d.ts +2 -0
- package/dist/plugin-sdk/infra/provider-usage.fetch.shared.d.ts +1 -0
- package/dist/plugin-sdk/infra/provider-usage.fetch.zai.d.ts +2 -0
- package/dist/plugin-sdk/infra/provider-usage.format.d.ts +13 -0
- package/dist/plugin-sdk/infra/provider-usage.load.d.ts +12 -0
- package/dist/plugin-sdk/infra/provider-usage.shared.d.ts +8 -0
- package/dist/plugin-sdk/infra/provider-usage.types.d.ts +17 -0
- package/dist/plugin-sdk/infra/restart-sentinel.d.ts +50 -0
- package/dist/plugin-sdk/infra/restart.d.ts +61 -0
- package/dist/plugin-sdk/infra/retry.d.ts +21 -0
- package/dist/plugin-sdk/infra/session-cost-usage.d.ts +45 -0
- package/dist/plugin-sdk/infra/session-cost-usage.types.d.ts +153 -0
- package/dist/plugin-sdk/infra/session-maintenance-warning.d.ts +10 -0
- package/dist/plugin-sdk/infra/shell-env.d.ts +33 -0
- package/dist/plugin-sdk/infra/skills-remote.d.ts +25 -0
- package/dist/plugin-sdk/infra/system-events.d.ts +18 -0
- package/dist/plugin-sdk/infra/tailnet.d.ts +7 -0
- package/dist/plugin-sdk/infra/tailscale.d.ts +34 -0
- package/dist/plugin-sdk/infra/tls/fingerprint.d.ts +1 -0
- package/dist/plugin-sdk/infra/tls/gateway.d.ts +16 -0
- package/dist/plugin-sdk/infra/tmp-anima-dir.d.ts +1 -0
- package/dist/plugin-sdk/infra/tmp-openclaw-dir.d.ts +18 -0
- package/dist/plugin-sdk/infra/unhandled-rejections.d.ts +15 -0
- package/dist/plugin-sdk/infra/warning-filter.d.ts +7 -0
- package/dist/plugin-sdk/infra/ws.d.ts +2 -0
- package/dist/plugin-sdk/infra/wsl.d.ts +11 -0
- package/dist/plugin-sdk/line/accounts.d.ts +9 -0
- package/dist/plugin-sdk/line/config-schema.d.ts +1 -0
- package/dist/plugin-sdk/line/flex-templates.d.ts +14 -0
- package/dist/plugin-sdk/line/markdown-to-line.d.ts +6 -0
- package/dist/plugin-sdk/line/monitor.d.ts +3 -0
- package/dist/plugin-sdk/line/probe.d.ts +3 -0
- package/dist/plugin-sdk/line/send.d.ts +14 -0
- package/dist/plugin-sdk/line/template-messages.d.ts +1 -0
- package/dist/plugin-sdk/line/types.d.ts +6 -0
- package/dist/plugin-sdk/link-understanding/apply.d.ts +10 -0
- package/dist/plugin-sdk/link-understanding/defaults.d.ts +2 -0
- package/dist/plugin-sdk/link-understanding/detect.d.ts +3 -0
- package/dist/plugin-sdk/link-understanding/format.d.ts +4 -0
- package/dist/plugin-sdk/link-understanding/runner.d.ts +11 -0
- package/dist/plugin-sdk/logger.d.ts +6 -0
- package/dist/plugin-sdk/logging/config.d.ts +4 -0
- package/dist/plugin-sdk/logging/console.d.ts +23 -0
- package/dist/plugin-sdk/logging/diagnostic-session-state.d.ts +17 -0
- package/dist/plugin-sdk/logging/diagnostic.d.ts +56 -0
- package/dist/plugin-sdk/logging/levels.d.ts +4 -0
- package/dist/plugin-sdk/logging/logger.d.ts +42 -0
- package/dist/plugin-sdk/logging/redact-identifier.d.ts +4 -0
- package/dist/plugin-sdk/logging/redact.d.ts +9 -0
- package/dist/plugin-sdk/logging/state.d.ts +18 -0
- package/dist/plugin-sdk/logging/subsystem.d.ts +18 -0
- package/dist/plugin-sdk/logging.d.ts +10 -0
- package/dist/plugin-sdk/markdown/fences.d.ts +10 -0
- package/dist/plugin-sdk/markdown/frontmatter.d.ts +2 -0
- package/dist/plugin-sdk/markdown/ir.d.ts +32 -0
- package/dist/plugin-sdk/markdown/render.d.ts +18 -0
- package/dist/plugin-sdk/markdown/tables.d.ts +2 -0
- package/dist/plugin-sdk/markdown/whatsapp.d.ts +14 -0
- package/dist/plugin-sdk/media/audio-tags.d.ts +10 -0
- package/dist/plugin-sdk/media/audio.d.ts +19 -0
- package/dist/plugin-sdk/media/base64.d.ts +1 -0
- package/dist/plugin-sdk/media/constants.d.ts +7 -0
- package/dist/plugin-sdk/media/fetch.d.ts +23 -0
- package/dist/plugin-sdk/media/image-ops.d.ts +39 -0
- package/dist/plugin-sdk/media/input-files.d.ts +81 -0
- package/dist/plugin-sdk/media/mime.d.ts +16 -0
- package/dist/plugin-sdk/media/parse.d.ts +8 -0
- package/dist/plugin-sdk/media/png-encode.d.ts +8 -0
- package/dist/plugin-sdk/media/read-response-with-limit.d.ts +7 -0
- package/dist/plugin-sdk/media/sniff-mime-from-base64.d.ts +1 -0
- package/dist/plugin-sdk/media/store.d.ts +28 -0
- package/dist/plugin-sdk/media-understanding/apply.d.ts +19 -0
- package/dist/plugin-sdk/media-understanding/attachments.d.ts +43 -0
- package/dist/plugin-sdk/media-understanding/concurrency.d.ts +1 -0
- package/dist/plugin-sdk/media-understanding/defaults.d.ts +14 -0
- package/dist/plugin-sdk/media-understanding/errors.d.ts +6 -0
- package/dist/plugin-sdk/media-understanding/format.d.ts +7 -0
- package/dist/plugin-sdk/media-understanding/output-extract.d.ts +2 -0
- package/dist/plugin-sdk/media-understanding/providers/image.d.ts +1 -0
- package/dist/plugin-sdk/media-understanding/providers/index.d.ts +8 -0
- package/dist/plugin-sdk/media-understanding/providers/shared.d.ts +4 -0
- package/dist/plugin-sdk/media-understanding/resolve.d.ts +44 -0
- package/dist/plugin-sdk/media-understanding/runner.d.ts +35 -0
- package/dist/plugin-sdk/media-understanding/runner.entries.d.ts +33 -0
- package/dist/plugin-sdk/media-understanding/scope.d.ts +9 -0
- package/dist/plugin-sdk/media-understanding/types.d.ts +93 -0
- package/dist/plugin-sdk/media-understanding/video.d.ts +2 -0
- package/dist/plugin-sdk/memory/backend-config.d.ts +49 -0
- package/dist/plugin-sdk/memory/batch-gemini.d.ts +55 -0
- package/dist/plugin-sdk/memory/batch-http.d.ts +6 -0
- package/dist/plugin-sdk/memory/batch-openai.d.ts +45 -0
- package/dist/plugin-sdk/memory/batch-output.d.ts +23 -0
- package/dist/plugin-sdk/memory/batch-voyage.d.ts +46 -0
- package/dist/plugin-sdk/memory/embedding-chunk-limits.d.ts +3 -0
- package/dist/plugin-sdk/memory/embedding-input-limits.d.ts +2 -0
- package/dist/plugin-sdk/memory/embedding-model-limits.d.ts +2 -0
- package/dist/plugin-sdk/memory/embeddings-gemini.d.ts +13 -0
- package/dist/plugin-sdk/memory/embeddings-openai.d.ts +13 -0
- package/dist/plugin-sdk/memory/embeddings-voyage.d.ts +13 -0
- package/dist/plugin-sdk/memory/embeddings.d.ts +44 -0
- package/dist/plugin-sdk/memory/hybrid.d.ts +34 -0
- package/dist/plugin-sdk/memory/index.d.ts +3 -0
- package/dist/plugin-sdk/memory/internal.d.ts +38 -0
- package/dist/plugin-sdk/memory/manager-embedding-ops.d.ts +32 -0
- package/dist/plugin-sdk/memory/manager-search.d.ts +60 -0
- package/dist/plugin-sdk/memory/manager-sync-ops.d.ts +40 -0
- package/dist/plugin-sdk/memory/manager.d.ts +75 -0
- package/dist/plugin-sdk/memory/memory-schema.d.ts +10 -0
- package/dist/plugin-sdk/memory/node-llama.d.ts +8 -0
- package/dist/plugin-sdk/memory/qmd-manager.d.ts +109 -0
- package/dist/plugin-sdk/memory/qmd-query-parser.d.ts +8 -0
- package/dist/plugin-sdk/memory/qmd-scope.d.ts +4 -0
- package/dist/plugin-sdk/memory/search-manager.d.ts +11 -0
- package/dist/plugin-sdk/memory/session-files.d.ts +14 -0
- package/dist/plugin-sdk/memory/sqlite-vec.d.ts +9 -0
- package/dist/plugin-sdk/memory/sqlite.d.ts +1 -0
- package/dist/plugin-sdk/memory/types.d.ts +94 -0
- package/dist/plugin-sdk/pairing/pairing-messages.d.ts +6 -0
- package/dist/plugin-sdk/pairing/pairing-store.d.ts +46 -0
- package/dist/plugin-sdk/pi-model-discovery-Dw3A6oXH.js +37 -0
- package/dist/plugin-sdk/plugin-sdk/account-id.d.ts +1 -0
- package/dist/plugin-sdk/plugin-sdk/allow-from.d.ts +4 -0
- package/dist/plugin-sdk/plugin-sdk/config-paths.d.ts +6 -0
- package/dist/plugin-sdk/plugin-sdk/file-lock.d.ts +16 -0
- package/dist/plugin-sdk/plugin-sdk/index.d.ts +123 -0
- package/dist/plugin-sdk/plugin-sdk/onboarding.d.ts +11 -0
- package/dist/plugin-sdk/plugin-sdk/text-chunking.d.ts +1 -0
- package/dist/plugin-sdk/plugins/bundled-dir.d.ts +1 -0
- package/dist/plugin-sdk/plugins/commands.d.ts +83 -0
- package/dist/plugin-sdk/plugins/config-schema.d.ts +2 -0
- package/dist/plugin-sdk/plugins/config-state.d.ts +33 -0
- package/dist/plugin-sdk/plugins/discovery.d.ts +22 -0
- package/dist/plugin-sdk/plugins/hook-runner-global.d.ts +37 -0
- package/dist/plugin-sdk/plugins/hooks.d.ts +42 -0
- package/dist/plugin-sdk/plugins/http-path.d.ts +1 -0
- package/dist/plugin-sdk/plugins/http-registry.d.ts +13 -0
- package/dist/plugin-sdk/plugins/loader.d.ts +14 -0
- package/dist/plugin-sdk/plugins/manifest-registry.d.ts +33 -0
- package/dist/plugin-sdk/plugins/manifest.d.ts +64 -0
- package/dist/plugin-sdk/plugins/registry.d.ts +130 -0
- package/dist/plugin-sdk/plugins/runtime/index.d.ts +3 -0
- package/dist/plugin-sdk/plugins/runtime/native-deps.d.ts +8 -0
- package/dist/plugin-sdk/plugins/runtime/types.d.ts +317 -0
- package/dist/plugin-sdk/plugins/runtime.d.ts +5 -0
- package/dist/plugin-sdk/plugins/schema-validator.d.ts +10 -0
- package/dist/plugin-sdk/plugins/slots.d.ts +24 -0
- package/dist/plugin-sdk/plugins/tools.d.ts +13 -0
- package/dist/plugin-sdk/plugins/types.d.ts +411 -0
- package/dist/plugin-sdk/polls.d.ts +31 -0
- package/dist/plugin-sdk/process/command-queue.d.ts +51 -0
- package/dist/plugin-sdk/process/exec.d.ts +26 -0
- package/dist/plugin-sdk/process/lanes.d.ts +6 -0
- package/dist/plugin-sdk/process/spawn-utils.d.ts +26 -0
- package/dist/plugin-sdk/providers/github-copilot-token.d.ts +8 -0
- package/dist/plugin-sdk/providers/qwen-portal-oauth.d.ts +8 -0
- package/dist/plugin-sdk/routing/bindings.d.ts +11 -0
- package/dist/plugin-sdk/routing/resolve-route.d.ts +42 -0
- package/dist/plugin-sdk/routing/session-key.d.ts +48 -0
- package/dist/plugin-sdk/runtime.d.ts +7 -0
- package/dist/plugin-sdk/security/external-content.d.ts +67 -0
- package/dist/plugin-sdk/security/secret-equal.d.ts +1 -0
- package/dist/plugin-sdk/sessions/input-provenance.d.ts +16 -0
- package/dist/plugin-sdk/sessions/level-overrides.d.ts +10 -0
- package/dist/plugin-sdk/sessions/model-overrides.d.ts +14 -0
- package/dist/plugin-sdk/sessions/send-policy.d.ts +11 -0
- package/dist/plugin-sdk/sessions/session-key-utils.d.ts +11 -0
- package/dist/plugin-sdk/sessions/session-label.d.ts +9 -0
- package/dist/plugin-sdk/sessions/transcript-events.d.ts +7 -0
- package/dist/plugin-sdk/shared/chat-envelope.d.ts +2 -0
- package/dist/plugin-sdk/shared/config-eval.d.ts +5 -0
- package/dist/plugin-sdk/shared/device-auth.d.ts +13 -0
- package/dist/plugin-sdk/shared/frontmatter.d.ts +7 -0
- package/dist/plugin-sdk/shared/node-match.d.ts +8 -0
- package/dist/plugin-sdk/shared/subagents-format.d.ts +15 -0
- package/dist/plugin-sdk/shared/text/reasoning-tags.d.ts +6 -0
- package/dist/plugin-sdk/signal/accounts.d.ts +9 -0
- package/dist/plugin-sdk/signal/format.d.ts +9 -0
- package/dist/plugin-sdk/signal/identity.d.ts +3 -0
- package/dist/plugin-sdk/signal/index.d.ts +3 -0
- package/dist/plugin-sdk/signal/probe.d.ts +3 -0
- package/dist/plugin-sdk/signal/reaction-level.d.ts +1 -0
- package/dist/plugin-sdk/signal/send-reactions.d.ts +2 -0
- package/dist/plugin-sdk/signal/send.d.ts +1 -0
- package/dist/plugin-sdk/slack/accounts.d.ts +11 -0
- package/dist/plugin-sdk/slack/actions.d.ts +17 -0
- package/dist/plugin-sdk/slack/client.d.ts +1 -0
- package/dist/plugin-sdk/slack/directory-live.d.ts +4 -0
- package/dist/plugin-sdk/slack/index.d.ts +3 -0
- package/dist/plugin-sdk/slack/message-actions.d.ts +2 -0
- package/dist/plugin-sdk/slack/monitor/allow-list.d.ts +1 -0
- package/dist/plugin-sdk/slack/probe.d.ts +3 -0
- package/dist/plugin-sdk/slack/resolve-channels.d.ts +1 -0
- package/dist/plugin-sdk/slack/resolve-users.d.ts +1 -0
- package/dist/plugin-sdk/slack/send.d.ts +5 -0
- package/dist/plugin-sdk/slack/targets.d.ts +2 -0
- package/dist/plugin-sdk/slack/threading-tool-context.d.ts +1 -0
- package/dist/plugin-sdk/telegram/accounts.d.ts +9 -0
- package/dist/plugin-sdk/telegram/audit.d.ts +4 -0
- package/dist/plugin-sdk/telegram/bot/helpers.d.ts +1 -0
- package/dist/plugin-sdk/telegram/bot/types.d.ts +5 -0
- package/dist/plugin-sdk/telegram/inline-buttons.d.ts +2 -0
- package/dist/plugin-sdk/telegram/model-buttons.d.ts +5 -0
- package/dist/plugin-sdk/telegram/monitor.d.ts +3 -0
- package/dist/plugin-sdk/telegram/outbound-params.d.ts +2 -0
- package/dist/plugin-sdk/telegram/probe.d.ts +6 -0
- package/dist/plugin-sdk/telegram/reaction-level.d.ts +1 -0
- package/dist/plugin-sdk/telegram/send.d.ts +10 -0
- package/dist/plugin-sdk/telegram/sticker-cache.d.ts +2 -0
- package/dist/plugin-sdk/telegram/targets.d.ts +1 -0
- package/dist/plugin-sdk/telegram/token.d.ts +1 -0
- package/dist/plugin-sdk/terminal/ansi.d.ts +2 -0
- package/dist/plugin-sdk/terminal/health-style.d.ts +1 -0
- package/dist/plugin-sdk/terminal/links.d.ts +6 -0
- package/dist/plugin-sdk/terminal/palette.d.ts +10 -0
- package/dist/plugin-sdk/terminal/progress-line.d.ts +3 -0
- package/dist/plugin-sdk/terminal/prompt-style.d.ts +3 -0
- package/dist/plugin-sdk/terminal/restore.d.ts +17 -0
- package/dist/plugin-sdk/terminal/theme.d.ts +15 -0
- package/dist/plugin-sdk/tts/tts-core.d.ts +52 -0
- package/dist/plugin-sdk/tts/tts.d.ts +179 -0
- package/dist/plugin-sdk/utils/account-id.d.ts +1 -0
- package/dist/plugin-sdk/utils/boolean.d.ts +5 -0
- package/dist/plugin-sdk/utils/delivery-context.d.ts +29 -0
- package/dist/plugin-sdk/utils/directive-tags.d.ts +16 -0
- package/dist/plugin-sdk/utils/fetch-timeout.d.ts +13 -0
- package/dist/plugin-sdk/utils/message-channel.d.ts +27 -0
- package/dist/plugin-sdk/utils/normalize-secret-input.d.ts +11 -0
- package/dist/plugin-sdk/utils/provider-utils.d.ts +9 -0
- package/dist/plugin-sdk/utils/queue-helpers.d.ts +41 -0
- package/dist/plugin-sdk/utils/shell-argv.d.ts +1 -0
- package/dist/plugin-sdk/utils/transcript-tools.d.ts +8 -0
- package/dist/plugin-sdk/utils/usage-format.d.ts +26 -0
- package/dist/plugin-sdk/utils.d.ts +67 -0
- package/dist/plugin-sdk/version.d.ts +4 -0
- package/dist/plugin-sdk/web/accounts.d.ts +39 -0
- package/dist/plugin-sdk/web/active-listener.d.ts +25 -0
- package/dist/plugin-sdk/web/auth-store.d.ts +25 -0
- package/dist/plugin-sdk/web/auto-reply/constants.d.ts +1 -0
- package/dist/plugin-sdk/web/auto-reply/deliver-reply.d.ts +18 -0
- package/dist/plugin-sdk/web/auto-reply/heartbeat-runner.d.ts +20 -0
- package/dist/plugin-sdk/web/auto-reply/loggers.d.ts +4 -0
- package/dist/plugin-sdk/web/auto-reply/mentions.d.ts +19 -0
- package/dist/plugin-sdk/web/auto-reply/monitor/ack-reaction.d.ts +13 -0
- package/dist/plugin-sdk/web/auto-reply/monitor/broadcast.d.ts +16 -0
- package/dist/plugin-sdk/web/auto-reply/monitor/commands.d.ts +2 -0
- package/dist/plugin-sdk/web/auto-reply/monitor/echo.d.ts +17 -0
- package/dist/plugin-sdk/web/auto-reply/monitor/group-activation.d.ts +9 -0
- package/dist/plugin-sdk/web/auto-reply/monitor/group-gating.d.ts +29 -0
- package/dist/plugin-sdk/web/auto-reply/monitor/group-members.d.ts +6 -0
- package/dist/plugin-sdk/web/auto-reply/monitor/last-route.d.ts +15 -0
- package/dist/plugin-sdk/web/auto-reply/monitor/message-line.d.ts +11 -0
- package/dist/plugin-sdk/web/auto-reply/monitor/on-message.d.ts +24 -0
- package/dist/plugin-sdk/web/auto-reply/monitor/peer.d.ts +2 -0
- package/dist/plugin-sdk/web/auto-reply/monitor/process-message.d.ts +40 -0
- package/dist/plugin-sdk/web/auto-reply/monitor.d.ts +5 -0
- package/dist/plugin-sdk/web/auto-reply/session-snapshot.d.ts +17 -0
- package/dist/plugin-sdk/web/auto-reply/types.d.ts +28 -0
- package/dist/plugin-sdk/web/auto-reply/util.d.ts +2 -0
- package/dist/plugin-sdk/web/auto-reply.d.ts +1 -0
- package/dist/plugin-sdk/web/auto-reply.impl.d.ts +6 -0
- package/dist/plugin-sdk/web/inbound/access-control.d.ts +24 -0
- package/dist/plugin-sdk/web/inbound/dedupe.d.ts +2 -0
- package/dist/plugin-sdk/web/inbound/extract.d.ts +13 -0
- package/dist/plugin-sdk/web/inbound/media.d.ts +7 -0
- package/dist/plugin-sdk/web/inbound/monitor.d.ts +30 -0
- package/dist/plugin-sdk/web/inbound/send-api.d.ts +22 -0
- package/dist/plugin-sdk/web/inbound/types.d.ts +41 -0
- package/dist/plugin-sdk/web/inbound.d.ts +4 -0
- package/dist/plugin-sdk/web/login-qr.d.ts +19 -0
- package/dist/plugin-sdk/web/login.d.ts +3 -0
- package/dist/plugin-sdk/web/media.d.ts +38 -0
- package/dist/plugin-sdk/web/outbound.d.ts +23 -0
- package/dist/plugin-sdk/web/qr-image.d.ts +4 -0
- package/dist/plugin-sdk/web/reconnect.d.ts +12 -0
- package/dist/plugin-sdk/web/session.d.ts +14 -0
- package/dist/plugin-sdk/web/vcard.d.ts +6 -0
- package/dist/plugin-sdk/whatsapp/normalize.d.ts +2 -0
- package/dist/plugin-sdk/whatsapp/resolve-outbound-target.d.ts +1 -0
- package/dist/plugin-sdk/wizard/prompts.d.ts +42 -0
- package/dist/plugin-sdk/wizard/session.d.ts +42 -0
- package/dist/plugins-B362e77G.js +168 -0
- package/dist/plugins-CDJw924T.js +38 -0
- package/dist/plugins-CmSUIUNi.js +38 -0
- package/dist/plugins-cli-CtFRTC2I.js +734 -0
- package/dist/plugins-cli-D1lvqLG9.js +736 -0
- package/dist/polls-CItfB1H8.js +1343 -0
- package/dist/ports-BVLMN1Sr.js +96 -0
- package/dist/ports-CqLSlU6Z.js +317 -0
- package/dist/ports-D94CwCrv.js +344 -0
- package/dist/ports-D_NHthOz.js +96 -0
- package/dist/program-Bve7k4jO.js +176 -0
- package/dist/program-context-8lqacY-M.js +496 -0
- package/dist/program-context-Bvn8046-.js +17 -0
- package/dist/progress-Bek_GyWS.js +133 -0
- package/dist/progress-CbZ2D53A.js +133 -0
- package/dist/prompt-style-DKy6qQxR.js +9 -0
- package/dist/prompt-style-lu0clOOE.js +9 -0
- package/dist/prompts-BI__va99.js +10 -0
- package/dist/prompts-_dDWkCAz.js +10 -0
- package/dist/pw-ai-BLVMuSLv.js +1867 -0
- package/dist/pw-ai-DZJWEF_f.js +1865 -0
- package/dist/pw-ai-dzf-ptcn.js +1868 -0
- package/dist/qmd-manager-B0FWDi1x.js +938 -0
- package/dist/qmd-manager-CrDrpgh3.js +937 -0
- package/dist/qmd-manager-DepEoASu.js +935 -0
- package/dist/queue-2CW7pnm1.js +209 -0
- package/dist/queue-DhjMEG_Q.js +209 -0
- package/dist/redact-BHmk44DI.js +97 -0
- package/dist/redact-ClVwO7Nn.js +97 -0
- package/dist/register.agent-CE_8JbTE.js +265 -0
- package/dist/register.agent-CGRdcftb.js +1003 -0
- package/dist/register.anima-B4NPeesF.js +167 -0
- package/dist/register.anima-hNCtQ_jl.js +167 -0
- package/dist/register.configure-3prVPXwx.js +101 -0
- package/dist/register.configure-Dqm2IveL.js +103 -0
- package/dist/register.maintenance-BSIx4eNS.js +543 -0
- package/dist/register.maintenance-DDeG6CHa.js +543 -0
- package/dist/register.message-DcYPDzYr.js +657 -0
- package/dist/register.message-RbFrjbch.js +660 -0
- package/dist/register.onboard-BBJK_0_C.js +170 -0
- package/dist/register.onboard-BrcWHC9j.js +170 -0
- package/dist/register.setup-ByvEHxYQ.js +175 -0
- package/dist/register.setup-CNwO5Yq3.js +175 -0
- package/dist/register.status-health-sessions-CGT7bn4C.js +142 -0
- package/dist/register.status-health-sessions-QK6iQSJc.js +313 -0
- package/dist/register.subclis-Bd8eE94r.js +255 -0
- package/dist/registry-BiekeB9q.js +116 -0
- package/dist/registry-qI6V4gqU.js +116 -0
- package/dist/reply-Clj5jcM5.js +32212 -0
- package/dist/reply-DnH1Ueoz.js +32212 -0
- package/dist/reply-prefix-D2NxVzGZ.js +100 -0
- package/dist/reply-prefix-DPpz_mEi.js +100 -0
- package/dist/requirements-BzZxj2Wu.js +107 -0
- package/dist/requirements-DIW1svgA.js +107 -0
- package/dist/rolldown-runtime-Cbj13DAv.js +20 -0
- package/dist/routes-CXpne1-p.js +1820 -0
- package/dist/routes-DtRwwTy6.js +1820 -0
- package/dist/rpc-BBB_Fbes.js +70 -0
- package/dist/rpc-CMEWfcci.js +70 -0
- package/dist/run-main-DOXNrnL2.js +371 -0
- package/dist/runtime-guard-BSUFiAQV.js +60 -0
- package/dist/runtime-guard-DeOXA_86.js +60 -0
- package/dist/sandbox-Bk0ZXcag.js +859 -0
- package/dist/sandbox-D3CFkNeF.js +858 -0
- package/dist/sandbox-cli-BCnnmQ03.js +458 -0
- package/dist/sandbox-cli-Ctpa2Isy.js +461 -0
- package/dist/secret-equal-B268kALC.js +13 -0
- package/dist/secret-equal-Dghy3xsA.js +13 -0
- package/dist/security-cli-BiiLLcQV.js +462 -0
- package/dist/security-cli-DOZmLENS.js +465 -0
- package/dist/send-BTA6qupx.js +10 -0
- package/dist/send-BhAfdGII.js +10 -0
- package/dist/send-C2t9xpXI.js +10 -0
- package/dist/send-C6ccOW_U.js +10 -0
- package/dist/send-CP74DxzJ.js +28 -0
- package/dist/send-CS3G_YWr.js +10 -0
- package/dist/send-D5JnqErc.js +10 -0
- package/dist/send-DEMhcauI.js +32 -0
- package/dist/send-DF8KJImx.js +28 -0
- package/dist/send-DVW0CcHX.js +32 -0
- package/dist/send-DigO-i9j.js +28 -0
- package/dist/send-DqMLjD9Z.js +10 -0
- package/dist/send-Dz2BDHll.js +32 -0
- package/dist/send-ga9udK1_.js +10 -0
- package/dist/send-oDz9NATu.js +10 -0
- package/dist/server-context-BznDS2td.js +824 -0
- package/dist/server-context-CXnE2F7d.js +824 -0
- package/dist/server-node-events-Cu6Qkjor.js +231 -0
- package/dist/server-node-events-Cv8MuF1g.js +233 -0
- package/dist/service-BNVpYcQe.js +642 -0
- package/dist/service-D56aMXUB.js +642 -0
- package/dist/service-audit-DBsygs7y.js +488 -0
- package/dist/service-audit-DKWJcTu4.js +488 -0
- package/dist/session-CXcl3Xrp.js +181 -0
- package/dist/session-DUFuU29j.js +179 -0
- package/dist/session-M_uCxF0U.js +181 -0
- package/dist/session-cost-usage-BwiTZuKl.js +600 -0
- package/dist/session-cost-usage-DT9YNXTJ.js +600 -0
- package/dist/session-key-BGiG_JcT.js +198 -0
- package/dist/session-key-DxcgHezu.js +198 -0
- package/dist/sessions-B8GUAiF6.js +1296 -0
- package/dist/sessions-D0Zd1CND.js +1296 -0
- package/dist/sessions-D0spLCm7.js +187 -0
- package/dist/sessions-XvkHLXt4.js +2038 -0
- package/dist/shared-CEHU0exQ.js +77 -0
- package/dist/shared-Cgly1vPb.js +66 -0
- package/dist/shared-DAHxpviD.js +77 -0
- package/dist/shared-JOo05hST.js +66 -0
- package/dist/shell-argv-CAq1mLa2.js +72 -0
- package/dist/shell-argv-Ce41guJv.js +72 -0
- package/dist/skill-scanner-CkaVLABv.js +263 -0
- package/dist/skill-scanner-Coo4QoCd.js +263 -0
- package/dist/skills-B-G7UHOa.js +808 -0
- package/dist/skills-B5LQx4lT.js +807 -0
- package/dist/skills-cli-DF9XJ2_0.js +286 -0
- package/dist/skills-cli-eLBluVoD.js +289 -0
- package/dist/skills-status-Clq9ZnYu.js +166 -0
- package/dist/skills-status-JQluhU-P.js +166 -0
- package/dist/sqlite-BukcjdJa.js +321 -0
- package/dist/sqlite-CGcOZZ0C.js +368 -0
- package/dist/sqlite-Ck6f9KWc.js +453 -0
- package/dist/start-BvsoGNHJ.js +354 -0
- package/dist/start-CF_Cp6YC.js +353 -0
- package/dist/status-BKGJ7VPQ.js +27 -0
- package/dist/status-BZip7mx9.js +27 -0
- package/dist/status-BqYq_J5J.js +2132 -0
- package/dist/status-CMnlcBVc.js +21 -0
- package/dist/status-CXQrTLri.js +2137 -0
- package/dist/status-tDZPwewW.js +21 -0
- package/dist/status.update-CWiod7o_.js +79 -0
- package/dist/status.update-D1PyrhoB.js +79 -0
- package/dist/subagent-registry-CpSZ2RSO.js +2760 -0
- package/dist/subagent-registry-DkCXRdwf.js +2759 -0
- package/dist/subagent-registry-MPrTYaEB.js +14 -0
- package/dist/subsystem-Dowf8fSU.js +860 -0
- package/dist/system-cli-4Urk9KV1.js +79 -0
- package/dist/system-cli-CgMzkg8R.js +82 -0
- package/dist/system-run-command-DGk7dwQP.js +93 -0
- package/dist/system-run-command-X9lDJIy0.js +93 -0
- package/dist/systemd-BSrHDyeU.js +452 -0
- package/dist/systemd-By5xdSB4.js +452 -0
- package/dist/systemd-hints-BtjL_5Rh.js +36 -0
- package/dist/systemd-hints-sJmr6cjb.js +36 -0
- package/dist/systemd-linger-BNz8PXPF.js +75 -0
- package/dist/systemd-linger-D5vLilKH.js +75 -0
- package/dist/table-BL0lJzsm.js +279 -0
- package/dist/table-DoiRPsn0.js +279 -0
- package/dist/tailnet-CuiNECdL.js +42 -0
- package/dist/tailnet-__ODlBOT.js +42 -0
- package/dist/templates-DJ0ii6X2.js +47 -0
- package/dist/templates-DPTs18po.js +47 -0
- package/dist/thinking-BLU0jXR8.js +204 -0
- package/dist/thinking-BXEswx1X.js +204 -0
- package/dist/timeout-CswI_K-U.js +232 -0
- package/dist/tokens-C-X7wDKj.js +14 -0
- package/dist/tokens-DkvqA72p.js +14 -0
- package/dist/transcript-events-C1hdue6u.js +17 -0
- package/dist/transcript-events-C8Tqw4td.js +17 -0
- package/dist/transcript-events-DW_H__a1.js +17 -0
- package/dist/transcript-tools-DtE5di1q.js +108 -0
- package/dist/transcript-tools-DuyYOkUq.js +108 -0
- package/dist/trash-BJLK1vMn.js +23 -0
- package/dist/trash-_x5UZ94k.js +23 -0
- package/dist/tui-Cj25a9wc.js +3894 -0
- package/dist/tui-Iv4T-9gg.js +3894 -0
- package/dist/tui-cli-BkJxFa_n.js +50 -0
- package/dist/tui-cli-DeFmBtZ7.js +47 -0
- package/dist/update-DZRKbMjq.js +317 -0
- package/dist/update-LFgxHHPd.js +317 -0
- package/dist/update-check-CWc7YXmc.js +400 -0
- package/dist/update-check-IhlWaui6.js +400 -0
- package/dist/update-cli-qGGlL5Lg.js +1105 -0
- package/dist/update-cli-rMqhSUMc.js +1105 -0
- package/dist/update-runner-BT77y3bz.js +894 -0
- package/dist/update-runner-DvzFqFJf.js +894 -0
- package/dist/usage-BeZuVAY4.js +4516 -0
- package/dist/usage-format-BAirWUSO.js +36 -0
- package/dist/usage-format-CpORtVCG.js +36 -0
- package/dist/utils-Bsw__U-F.js +243 -0
- package/dist/utils-C9sj30YY.js +239 -0
- package/dist/warning-filter.js +48 -0
- package/dist/web-DEx7MMYq.js +2203 -0
- package/dist/web-DHSoj6bL.js +46842 -0
- package/dist/web-DI0g5K4c.js +63 -0
- package/dist/webhooks-cli-sfLRE89X.js +319 -0
- package/dist/webhooks-cli-xtZBlaD1.js +316 -0
- package/dist/whatsapp-actions-DIREhxrq.js +49 -0
- package/dist/whatsapp-actions-TGHl9p4i.js +45 -0
- package/dist/whatsapp-actions-dBHozeuk.js +53 -0
- package/dist/widearea-dns-B6ocX23x.js +127 -0
- package/dist/widearea-dns-NsEUNYwz.js +127 -0
- package/dist/workspace-Dcfoy5JJ.js +649 -0
- package/dist/ws-COSqlEPx.js +218 -0
- package/dist/ws-log-N8R5MvGE.js +267 -0
- package/dist/ws-log-gwFxPxj5.js +267 -0
- package/dist/wsl-CqyuRvtM.js +26 -0
- package/dist/wsl-ymJYvc9Q.js +26 -0
- package/package.json +209 -0
- package/skills/1password/SKILL.md +70 -0
- package/skills/1password/references/cli-examples.md +29 -0
- package/skills/1password/references/get-started.md +17 -0
- package/skills/animahub/SKILL.md +77 -0
- package/skills/apple-notes/SKILL.md +77 -0
- package/skills/apple-reminders/SKILL.md +96 -0
- package/skills/audit/SKILL.md +68 -0
- package/skills/bear-notes/SKILL.md +107 -0
- package/skills/blogwatcher/SKILL.md +69 -0
- package/skills/blucli/SKILL.md +47 -0
- package/skills/bluebubbles/SKILL.md +131 -0
- package/skills/camsnap/SKILL.md +45 -0
- package/skills/canvas/SKILL.md +198 -0
- package/skills/coding-agent/SKILL.md +284 -0
- package/skills/deploy/SKILL.md +45 -0
- package/skills/discord/SKILL.md +160 -0
- package/skills/eightctl/SKILL.md +50 -0
- package/skills/food-order/SKILL.md +48 -0
- package/skills/gemini/SKILL.md +43 -0
- package/skills/gifgrep/SKILL.md +79 -0
- package/skills/github/SKILL.md +77 -0
- package/skills/gog/SKILL.md +116 -0
- package/skills/goplaces/SKILL.md +52 -0
- package/skills/healthcheck/SKILL.md +245 -0
- package/skills/himalaya/SKILL.md +257 -0
- package/skills/himalaya/references/configuration.md +184 -0
- package/skills/himalaya/references/message-composition.md +199 -0
- package/skills/imsg/SKILL.md +74 -0
- package/skills/mcporter/SKILL.md +61 -0
- package/skills/model-usage/SKILL.md +69 -0
- package/skills/model-usage/references/codexbar-cli.md +33 -0
- package/skills/model-usage/scripts/model_usage.py +310 -0
- package/skills/nano-banana-pro/SKILL.md +58 -0
- package/skills/nano-banana-pro/scripts/generate_image.py +184 -0
- package/skills/nano-pdf/SKILL.md +38 -0
- package/skills/notion/SKILL.md +172 -0
- package/skills/obsidian/SKILL.md +81 -0
- package/skills/openai-image-gen/SKILL.md +89 -0
- package/skills/openai-image-gen/scripts/gen.py +240 -0
- package/skills/openai-whisper/SKILL.md +38 -0
- package/skills/openai-whisper-api/SKILL.md +52 -0
- package/skills/openai-whisper-api/scripts/transcribe.sh +85 -0
- package/skills/openhue/SKILL.md +51 -0
- package/skills/oracle/SKILL.md +125 -0
- package/skills/ordercli/SKILL.md +78 -0
- package/skills/peekaboo/SKILL.md +190 -0
- package/skills/review/SKILL.md +58 -0
- package/skills/sag/SKILL.md +87 -0
- package/skills/session-logs/SKILL.md +115 -0
- package/skills/sherpa-onnx-tts/SKILL.md +103 -0
- package/skills/sherpa-onnx-tts/bin/sherpa-onnx-tts +178 -0
- package/skills/skill-creator/SKILL.md +370 -0
- package/skills/skill-creator/license.txt +202 -0
- package/skills/skill-creator/scripts/init_skill.py +378 -0
- package/skills/skill-creator/scripts/package_skill.py +111 -0
- package/skills/skill-creator/scripts/quick_validate.py +101 -0
- package/skills/slack/SKILL.md +144 -0
- package/skills/songsee/SKILL.md +49 -0
- package/skills/sonoscli/SKILL.md +46 -0
- package/skills/spotify-player/SKILL.md +64 -0
- package/skills/summarize/SKILL.md +87 -0
- package/skills/things-mac/SKILL.md +86 -0
- package/skills/tmux/SKILL.md +135 -0
- package/skills/tmux/scripts/find-sessions.sh +112 -0
- package/skills/tmux/scripts/wait-for-text.sh +83 -0
- package/skills/trello/SKILL.md +95 -0
- package/skills/video-frames/SKILL.md +46 -0
- package/skills/video-frames/scripts/frame.sh +81 -0
- package/skills/voice-call/SKILL.md +45 -0
- package/skills/wacli/SKILL.md +72 -0
- package/skills/weather/SKILL.md +54 -0
- package/templates/BRAIN.md +65 -0
- package/templates/GUT.md +44 -0
- package/templates/HEART.md +51 -0
- package/templates/MEMORY.md +66 -0
- package/templates/SHADOW.md +68 -0
- package/templates/SOUL.md +38 -0
- package/templates/SPIRIT.md +43 -0
|
@@ -0,0 +1,2062 @@
|
|
|
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-Bmm8tmZF.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 };
|