@noxsoft/anima 2.0.2 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1260 -28
- package/dist/accounts-Bth3PpPD.js +260 -0
- package/dist/accounts-D8CPKNkN.js +259 -0
- package/dist/acp-cli-ByK6lS6c.js +1081 -0
- package/dist/acp-cli-CaQCjIw4.js +1084 -0
- package/dist/agent-BgIkqd3F.js +725 -0
- package/dist/agent-N5BDcge4.js +725 -0
- package/dist/agent-events-COH7NDW2.js +182 -0
- package/dist/agent-scope-CPphqq-U.js +452 -0
- package/dist/agent-scope-DZgptr9J.js +452 -0
- package/dist/agent-scope-cj2QCT6R.js +112 -0
- package/dist/agents-NEudYMdg.js +774 -0
- package/dist/agents.config-Bujs-NIy.js +182 -0
- package/dist/agents.config-jp7OLssr.js +182 -0
- package/dist/argv-BMZMiW7v.js +73 -0
- package/dist/audit-C-UJhfdv.js +2401 -0
- package/dist/audit-CeCO7SK5.js +2401 -0
- package/dist/auth-BNZsOHGF.js +648 -0
- package/dist/auth-DMPZWzEa.js +639 -0
- package/dist/auth-choice-5VnaGMD-.js +2681 -0
- package/dist/auth-choice-DA2k4vs8.js +2681 -0
- package/dist/auth-health-B7FqA26_.js +149 -0
- package/dist/auth-health-VO_MPqVX.js +149 -0
- package/dist/auth-profiles-BDrNYX_n.js +1564 -0
- package/dist/auth-profiles-CxSHydjn.js +2689 -0
- package/dist/banner-BtDZPRzi.js +294 -0
- package/dist/browser-cli-8yQMpxb8.js +1679 -0
- package/dist/browser-cli-Czg3JtDH.js +1676 -0
- package/dist/build-info.json +3 -3
- package/dist/bundled/boot-md/handler.js +16 -16
- package/dist/bundled/bootstrap-extra-files/handler.js +4 -4
- package/dist/bundled/command-logger/handler.js +1 -1
- package/dist/bundled/session-memory/handler.js +5 -5
- package/dist/call-BIzCaKZb.js +282 -0
- package/dist/call-BYDpTVCZ.js +282 -0
- package/dist/canvas-host/a2ui/.bundle.hash +1 -1
- package/dist/catalog-CqKiUgu6.js +185 -0
- package/dist/catalog-DMfEg-oK.js +185 -0
- package/dist/channel-options-BrtCtyrT.js +32 -0
- package/dist/channel-options-CO21Gl8p.js +33 -0
- package/dist/channel-selection-Bbm1lq3P.js +51 -0
- package/dist/channel-selection-CqcX7Ocw.js +51 -0
- package/dist/channel-web-DrsT6OAE.js +2162 -0
- package/dist/channels-cli-Juyh1S6n.js +1304 -0
- package/dist/channels-cli-zNvi1m5c.js +1306 -0
- package/dist/channels-status-issues-CqzqshW4.js +18 -0
- package/dist/channels-status-issues-DdJdO866.js +18 -0
- package/dist/chrome-C4dOMO8z.js +1601 -0
- package/dist/chrome-DdcDzAtH.js +1629 -0
- package/dist/chrome-U3DRzjJD.js +1601 -0
- package/dist/chunk-D2nLsrEW.js +348 -0
- package/dist/clack-prompter-BI3RDW5w.js +92 -0
- package/dist/clack-prompter-Dwr1m_IZ.js +92 -0
- package/dist/cli/daemon-cli.js +1 -1
- package/dist/cli-C3cpDaz8.js +99 -0
- package/dist/cli-CjWUGdGC.js +101 -0
- package/dist/cli-session-BVjY_XrW.js +5463 -0
- package/dist/cli-session-gtuYN2Iq.js +5408 -0
- package/dist/client-Dswwze5_.js +1692 -0
- package/dist/client-LRKFjo4A.js +1692 -0
- package/dist/clipboard-BZKS9O1u.js +31 -0
- package/dist/clipboard-DES8b1AM.js +31 -0
- package/dist/command-format-CP1YTNCl.js +52 -0
- package/dist/command-format-CVL4K5cj.js +52 -0
- package/dist/command-format-G6N2zghg.js +38 -0
- package/dist/command-registry-BBvNvysr.js +248 -0
- package/dist/commands-AZ3n8Y2c.js +726 -0
- package/dist/commands-BMnD_QRY.js +726 -0
- package/dist/commands-registry-cFqZ6Ib4.js +766 -0
- package/dist/commands-registry-q13H7ng5.js +766 -0
- package/dist/common-CX5458fH.js +287 -0
- package/dist/common-DJbnT8ws.js +287 -0
- package/dist/completion-cli-BADRBcIl.js +432 -0
- package/dist/completion-cli-DMQgiObF.js +431 -0
- package/dist/config-CU-Axg8P.js +5704 -0
- package/dist/config-DaqbUdkI.js +5705 -0
- package/dist/config-cli-BPlbwiuA.js +244 -0
- package/dist/config-cli-DXgZJkPU.js +247 -0
- package/dist/config-guard-Ba49JNds.js +76 -0
- package/dist/config-guard-Cu0qMKZJ.js +93 -0
- package/dist/config-kVVm5EYV.js +6523 -0
- package/dist/config-sync-CzLnLTXt.js +91 -0
- package/dist/config-sync-DuydxPWx.js +91 -0
- package/dist/configure-CHgacLyi.js +960 -0
- package/dist/configure-DfHXDa1L.js +959 -0
- package/dist/context-DzgXOckU.js +60 -0
- package/dist/control-service-8_wKHwBa.js +72 -0
- package/dist/control-service-BtL1Jto_.js +72 -0
- package/dist/cron-cli-BCzSR2c0.js +448 -0
- package/dist/cron-cli-CCWNkykU.js +451 -0
- package/dist/daemon-cli-Bjkbu9Vy.js +565 -0
- package/dist/daemon-cli-CmlHcC1J.js +566 -0
- package/dist/daemon-cli.js +16 -16
- package/dist/daemon-runtime-C0tz7VAC.js +460 -0
- package/dist/daemon-runtime-rUTqCVwJ.js +460 -0
- package/dist/deliver-BBggsviM.js +1097 -0
- package/dist/deliver-CePITOl8.js +1162 -0
- package/dist/deliver-DFnVaetP.js +1097 -0
- package/dist/delivery-queue-BJQK3oh5.js +220 -0
- package/dist/deps-CeEKhrp7.js +42 -0
- package/dist/devices-cli-DQrDMrZH.js +198 -0
- package/dist/devices-cli-Oe-A1Dv0.js +195 -0
- package/dist/diagnostics-DxMFrBLO.js +35 -0
- package/dist/diagnostics-m79ZlMmZ.js +35 -0
- package/dist/directory-cli-BL6h8cGF.js +246 -0
- package/dist/directory-cli-Cjgmi_sj.js +243 -0
- package/dist/dispatcher-DAFbQM-c.js +100 -0
- package/dist/dispatcher-DNd40gUn.js +100 -0
- package/dist/dist-CqDI82ei.js +929 -0
- package/dist/dist-DnHRxR5U.js +929 -0
- package/dist/dns-cli-CFtV3BXK.js +200 -0
- package/dist/dns-cli-NyIHvQ5S.js +197 -0
- package/dist/dock-BdXLb5oY.js +753 -0
- package/dist/dock-jYICmNcI.js +753 -0
- package/dist/docs-cli-CrOaIK_H.js +161 -0
- package/dist/docs-cli-D_cmJDSr.js +159 -0
- package/dist/doctor-BpGxKrBl.js +1815 -0
- package/dist/doctor-D12wNQPU.js +1813 -0
- package/dist/doctor-completion-DeOfofek.js +92 -0
- package/dist/doctor-completion-DwjqdEcK.js +92 -0
- package/dist/doctor-config-flow-BI3mpkbd.js +1232 -0
- package/dist/doctor-config-flow-wMHheFkC.js +1232 -0
- package/dist/engine-BCtL-AMw.js +563 -0
- package/dist/engine-Bk_UT413.js +563 -0
- package/dist/entry.js +5 -5
- package/dist/env-v6411I8h.js +32 -0
- package/dist/exec-B7sUS164.js +1167 -0
- package/dist/exec-approvals-CroGJRUg.js +1221 -0
- package/dist/exec-approvals-cli-BTxF_RsH.js +371 -0
- package/dist/exec-approvals-cli-n1gyGwH2.js +368 -0
- package/dist/exec-mhSykkaa.js +255 -0
- package/dist/extensionAPI.js +3 -3
- package/dist/frontmatter-BmHq0vRD.js +204 -0
- package/dist/gateway-cli-DDBadlrS.js +19971 -0
- package/dist/gateway-cli-IZNkOMBe.js +19972 -0
- package/dist/gateway-rpc-Dtx8HN-n.js +28 -0
- package/dist/gateway-rpc-L2PVSqGj.js +28 -0
- package/dist/github-copilot-auth-DKyqDaGU.js +1418 -0
- package/dist/github-copilot-auth-DXpOMSd3.js +1418 -0
- package/dist/gmail-setup-utils-BKNczIJ9.js +428 -0
- package/dist/gmail-setup-utils-co0ppccC.js +428 -0
- package/dist/health-Bm8ZTvC3.js +1253 -0
- package/dist/health-DUf1gt4E.js +1258 -0
- package/dist/health-format-BksT6F68.js +208 -0
- package/dist/health-format-uzh1xYLD.js +208 -0
- package/dist/heartbeat-visibility-1TJb1Zao.js +98 -0
- package/dist/heartbeat-visibility-CwodtdcX.js +98 -0
- package/dist/help-format-C6cv_aZp.js +17 -0
- package/dist/helpers-N-uSFKOn.js +10 -0
- package/dist/hooks-cli-1POsXqOl.js +993 -0
- package/dist/hooks-cli-BGjILbze.js +991 -0
- package/dist/hooks-status-DE07n5RC.js +356 -0
- package/dist/hooks-status-Du-d1jde.js +356 -0
- package/dist/image-ops-B_AYV3tp.js +541 -0
- package/dist/image-ops-Bp0C6Mvr.js +541 -0
- package/dist/index.js +82 -82
- package/dist/init-9A0s7bWG.js +122 -0
- package/dist/init-DoyCHJDC.js +122 -0
- package/dist/installs-D1C9wHAq.js +383 -0
- package/dist/installs-Dh4dHayM.js +383 -0
- package/dist/ipv4-DCItfaJo.js +1964 -0
- package/dist/ipv4-DSOUVx0i.js +1964 -0
- package/dist/lanes-BvSnHq2h.js +232 -0
- package/dist/lifecycle-core-BY4WIf9g.js +388 -0
- package/dist/lifecycle-core-TQKyXO-6.js +387 -0
- package/dist/links-CNu_8RZl.js +15 -0
- package/dist/links-D2tt2ouh.js +15 -0
- package/dist/llm-slug-generator.js +4 -4
- package/dist/logging-BIeRw0WR.js +15 -0
- package/dist/logging-C7lb3Vjc.js +15 -0
- package/dist/login-DXWKewA2.js +59 -0
- package/dist/login-Fhh4uWmf.js +61 -0
- package/dist/login-pPs3UO38.js +61 -0
- package/dist/login-qr-CevLD8cV.js +326 -0
- package/dist/login-qr-GF2JMIy-.js +323 -0
- package/dist/login-qr-ZYYKD6Yt.js +321 -0
- package/dist/logs-cli-CzXbX8HZ.js +242 -0
- package/dist/logs-cli-D9ngH9PF.js +245 -0
- package/dist/manager-BD5rA3w0.js +3244 -0
- package/dist/manager-BDPgBQSH.js +3246 -0
- package/dist/manager-DRWMWM--.js +3244 -0
- package/dist/manifest-registry-DbvPaBXY.js +748 -0
- package/dist/manifest-registry-kHX_MFa1.js +748 -0
- package/dist/markdown-tables-CqwihY2m.js +347 -0
- package/dist/markdown-tables-DJV7eAJZ.js +348 -0
- package/dist/media-lUqN-0O9.js +1342 -0
- package/dist/memory-cli-BLXSpgnN.js +868 -0
- package/dist/memory-cli-BcGVkkRJ.js +869 -0
- package/dist/message-channel-D_jIO87f.js +110 -0
- package/dist/migrate-BpVOar4L.js +157 -0
- package/dist/migrate-CkgGDkWy.js +157 -0
- package/dist/model-selection-Cqt6aJ0G.js +2691 -0
- package/dist/models-CExsNQPH.js +2510 -0
- package/dist/models-cli-Ba3Jmwev.js +2739 -0
- package/dist/models-cli-iDAlsbL2.js +258 -0
- package/dist/net-0A_zcaQD.js +218 -0
- package/dist/node-cli-ATmwCXIk.js +1319 -0
- package/dist/node-cli-DYFR_V25.js +1322 -0
- package/dist/node-service-CN4LqR1A.js +67 -0
- package/dist/node-service-CWt3MdSC.js +67 -0
- package/dist/nodes-cli-BeVmhTz3.js +1197 -0
- package/dist/nodes-cli-QeJIfa18.js +1200 -0
- package/dist/nodes-screen-DHyWAlla.js +234 -0
- package/dist/nodes-screen-qs3jRBPk.js +234 -0
- package/dist/note-CSlg2BnB.js +73 -0
- package/dist/note-Ctvglhp1.js +73 -0
- package/dist/npm-registry-spec-DQd4M22q.js +351 -0
- package/dist/npm-registry-spec-PxisIMts.js +351 -0
- package/dist/onboard-DeruD10m.js +1166 -0
- package/dist/onboard-SAcu5N6N.js +1165 -0
- package/dist/onboard-channels-C4iSfFXR.js +672 -0
- package/dist/onboard-channels-oVTVgoyg.js +672 -0
- package/dist/onboard-helpers-B8roRwLP.js +365 -0
- package/dist/onboard-helpers-Dgh26hgP.js +365 -0
- package/dist/onboarding-Bi-ac8we.js +911 -0
- package/dist/onboarding-C2gjB2u8.js +910 -0
- package/dist/orchestrator-DlbAYMQP.js +357 -0
- package/dist/orchestrator-DlwVRVDA.js +357 -0
- package/dist/outbound-CkKgc6iR.js +2062 -0
- package/dist/outbound-Vfm5yDh3.js +214 -0
- package/dist/outbound-bs_VK51X.js +214 -0
- package/dist/outbound-send-deps-DDjiMfEL.js +55 -0
- package/dist/pairing-cli-CJYeuEik.js +118 -0
- package/dist/pairing-cli-mqopHI8s.js +121 -0
- package/dist/pairing-store-BsXzUDPv.js +388 -0
- package/dist/pairing-store-DoNj00-X.js +388 -0
- package/dist/path-env-C_xpiG8l.js +89 -0
- package/dist/path-env-DSSMHu5A.js +89 -0
- package/dist/paths-B1vRVCad.js +126 -0
- package/dist/paths-BMuHNFxg.js +238 -0
- package/dist/paths-BXQQzXGQ.js +129 -0
- package/dist/paths-Buw_geoe.js +54 -0
- package/dist/paths-DA9WYabg.js +222 -0
- package/dist/paths-DfQGx0_k.js +129 -0
- package/dist/pi-auth-json-DOPW3e4X.js +78 -0
- package/dist/pi-auth-json-MruLmI_X.js +82 -0
- package/dist/pi-auth-json-lae_wwwo.js +80 -0
- package/dist/pi-model-discovery-7q0GxMrp.js +3 -0
- package/dist/pi-tools.policy-Csmla32P.js +200 -0
- package/dist/pi-tools.policy-xYdDLEv9.js +200 -0
- package/dist/plugin-auto-enable-CViVVWgg.js +282 -0
- package/dist/plugin-auto-enable-CjZ238UI.js +282 -0
- package/dist/plugin-registry-B4Aw2hzq.js +32 -0
- package/dist/plugin-registry-DW81arxW.js +32 -0
- package/dist/plugin-sdk/cli/cli-name.d.ts +1 -1
- package/dist/plugin-sdk/config/paths.d.ts +2 -2
- package/dist/plugin-sdk/index.js +7 -7
- package/dist/plugins-DhcGAPDB.js +38 -0
- package/dist/plugins-DtghNRtM.js +168 -0
- package/dist/plugins-cli-4vWTmOAb.js +736 -0
- package/dist/plugins-cli-CdTMbP0X.js +734 -0
- package/dist/polls-D6eCdatA.js +1343 -0
- package/dist/ports-BtZx-JKD.js +96 -0
- package/dist/ports-C8bKN8s0.js +96 -0
- package/dist/ports-DHiKnPRX.js +344 -0
- package/dist/ports-vd93M_Pt.js +317 -0
- package/dist/program-CX3aUVeb.js +176 -0
- package/dist/program-context-BPos0ivo.js +496 -0
- package/dist/progress-oiAjiiNi.js +133 -0
- package/dist/prompt-style-Cm4wOtKm.js +9 -0
- package/dist/pw-ai-4QbK5YFe.js +1865 -0
- package/dist/pw-ai-BWz3Cxt7.js +1868 -0
- package/dist/pw-ai-C83HBue2.js +1867 -0
- package/dist/qmd-manager-BcMeZiGD.js +938 -0
- package/dist/qmd-manager-CPypGJ0P.js +935 -0
- package/dist/qmd-manager-CRrSkfia.js +937 -0
- package/dist/register.agent-DDY8KJhn.js +265 -0
- package/dist/register.agent-DKawm-9d.js +1003 -0
- package/dist/register.anima-CEWUo29k.js +193 -0
- package/dist/register.anima-DBWz2rk_.js +193 -0
- package/dist/register.configure-BX67qV8k.js +103 -0
- package/dist/register.configure-CWsySuiq.js +101 -0
- package/dist/register.maintenance-0k-ZNhDg.js +543 -0
- package/dist/register.maintenance-BIwx1fzX.js +543 -0
- package/dist/register.message-CXPsoakA.js +657 -0
- package/dist/register.message-DA3jvfgI.js +660 -0
- package/dist/register.onboard-C4HG7Hqv.js +170 -0
- package/dist/register.onboard-GOpdif-j.js +170 -0
- package/dist/register.setup-B17vZT7C.js +175 -0
- package/dist/register.setup-GJyUDCqh.js +175 -0
- package/dist/register.status-health-sessions-D5876dGx.js +313 -0
- package/dist/register.status-health-sessions-lOewVIZR.js +142 -0
- package/dist/register.subclis-Dwnujj5C.js +255 -0
- package/dist/reply-CR5T_oQJ.js +32212 -0
- package/dist/reply-prefix-BcrS4Umd.js +100 -0
- package/dist/reply-prefix-Btb5o2NH.js +100 -0
- package/dist/reply-r089HuRA.js +32212 -0
- package/dist/routes-B4czFzIb.js +1820 -0
- package/dist/routes-ucJWAk5O.js +1820 -0
- package/dist/rpc-BnKxnQ0v.js +70 -0
- package/dist/rpc-DgE-xnyx.js +70 -0
- package/dist/run-main-B74kv84C.js +371 -0
- package/dist/runtime-guard-CKFdts2L.js +60 -0
- package/dist/sandbox-CJTS3er6.js +858 -0
- package/dist/sandbox-DBSiVHt_.js +859 -0
- package/dist/sandbox-cli-CrkjyU5M.js +461 -0
- package/dist/sandbox-cli-D1r5y6Sz.js +458 -0
- package/dist/security-cli-BZUdnkhn.js +462 -0
- package/dist/security-cli-DS09ebvA.js +465 -0
- package/dist/server-context-C0xZbYhg.js +824 -0
- package/dist/server-context-DVh2z7om.js +824 -0
- package/dist/server-node-events-bu9lpkMH.js +233 -0
- package/dist/server-node-events-i1Rrww31.js +231 -0
- package/dist/service-CJJwLEor.js +642 -0
- package/dist/service-DxLxBhaU.js +642 -0
- package/dist/service-audit-DB4Y3Ekp.js +488 -0
- package/dist/service-audit-M8y4TXVb.js +488 -0
- package/dist/session-CGxOLFs2.js +179 -0
- package/dist/session-DTTbdKb0.js +181 -0
- package/dist/session-cost-usage-FcdJl9c3.js +600 -0
- package/dist/session-cost-usage-qdfsGU2a.js +600 -0
- package/dist/session-yOhWcsD2.js +181 -0
- package/dist/sessions-B-Cu7JZq.js +1296 -0
- package/dist/sessions-BgLN4KFr.js +180 -0
- package/dist/sessions-CnRjwdVr.js +1296 -0
- package/dist/sessions-wRKla1Qh.js +2038 -0
- package/dist/shared-DS3UaJSP.js +66 -0
- package/dist/shared-DxNHzky3.js +77 -0
- package/dist/shared-Qpt4hUDi.js +66 -0
- package/dist/shared-kzrojZ1B.js +77 -0
- package/dist/skill-scanner-DLJji5Ye.js +263 -0
- package/dist/skills-BWFIEp4j.js +807 -0
- package/dist/skills-DV4zKdCx.js +808 -0
- package/dist/skills-cli-BY53ILm2.js +289 -0
- package/dist/skills-cli-CO3gxl8A.js +286 -0
- package/dist/skills-status-DX5pcqY3.js +166 -0
- package/dist/skills-status-zhcKzGkp.js +166 -0
- package/dist/sqlite-B6MojU1I.js +321 -0
- package/dist/sqlite-CuprTGR7.js +453 -0
- package/dist/sqlite-dzD-jMjs.js +368 -0
- package/dist/start-Cu3aLoSf.js +297 -0
- package/dist/start-Dz7tMAl8.js +296 -0
- package/dist/status-CaSxhxfV.js +2132 -0
- package/dist/status-D2C0JCX3.js +2137 -0
- package/dist/status-DlFMsQzh.js +27 -0
- package/dist/status-G0CITnKR.js +27 -0
- package/dist/status.update-CHjhVxJY.js +79 -0
- package/dist/status.update-DVFelehi.js +79 -0
- package/dist/subagent-registry-3Xb4el-8.js +14 -0
- package/dist/subagent-registry-CdSjz14I.js +2760 -0
- package/dist/subagent-registry-DNDhbHWi.js +2759 -0
- package/dist/subsystem-DfKstnEK.js +860 -0
- package/dist/system-cli-B5mt0FWa.js +82 -0
- package/dist/system-cli-Dg3UQ3Zz.js +79 -0
- package/dist/systemd-B43AvOGx.js +452 -0
- package/dist/systemd-RpPE0XGg.js +452 -0
- package/dist/systemd-hints-DMJT-Bbc.js +36 -0
- package/dist/systemd-hints-vRInKcz9.js +36 -0
- package/dist/systemd-linger-Dzyxqsod.js +75 -0
- package/dist/systemd-linger-EujbmI5A.js +75 -0
- package/dist/table-DhXHfRX2.js +279 -0
- package/dist/table-bWCLW-3P.js +279 -0
- package/dist/timeout-Ddn-5kAO.js +232 -0
- package/dist/tokens-3psI_Qk2.js +14 -0
- package/dist/tokens-BaM53PEx.js +14 -0
- package/dist/trash-Bmxs1Rnm.js +23 -0
- package/dist/trash-C39a6hKA.js +23 -0
- package/dist/tui-BHgBWhHE.js +3894 -0
- package/dist/tui-cli-B9Sq5-cC.js +50 -0
- package/dist/tui-cli-Dw7v4JoJ.js +47 -0
- package/dist/tui-mUwDwqvd.js +3894 -0
- package/dist/update-DF0GHG0j.js +317 -0
- package/dist/update-DoZLVjva.js +317 -0
- package/dist/update-check-Bt1dVPVN.js +400 -0
- package/dist/update-check-D5qAKes7.js +400 -0
- package/dist/update-cli-BNu2Oi7H.js +1105 -0
- package/dist/update-cli-D36AmALA.js +1105 -0
- package/dist/update-runner-CNQQaTwA.js +894 -0
- package/dist/update-runner-CvxZmbu-.js +894 -0
- package/dist/usage-BGCwNnjk.js +4516 -0
- package/dist/utils-DZ8pnOD5.js +243 -0
- package/dist/web-B5QG839O.js +46842 -0
- package/dist/web-Cmnvk9v0.js +2203 -0
- package/dist/web-Cv2KnTnL.js +63 -0
- package/dist/webhooks-cli-B6y89Pj_.js +319 -0
- package/dist/webhooks-cli-BDzHON4w.js +316 -0
- package/dist/whatsapp-actions-C_5MwVxM.js +45 -0
- package/dist/whatsapp-actions-hgYA12To.js +53 -0
- package/dist/whatsapp-actions-zTiVOoOV.js +49 -0
- package/dist/widearea-dns-BeIdnISJ.js +127 -0
- package/dist/widearea-dns-CF1gxpJ-.js +127 -0
- package/dist/workspace-DLna1IxR.js +649 -0
- package/dist/ws-log-Q4wO1Ztb.js +267 -0
- package/dist/ws-log-xF0kxDzp.js +267 -0
- package/package.json +1 -2
- package/dist/accounts-Cc5E4IDO.js +0 -260
- package/dist/accounts-CcVrwKqv.js +0 -259
- package/dist/acp-cli-DvphOKuh.js +0 -1081
- package/dist/acp-cli-p28pQ65a.js +0 -1084
- package/dist/agent-Cj7uDJaZ.js +0 -725
- package/dist/agent-Cuj9-2sT.js +0 -725
- package/dist/agent-events-BEBQsyE5.js +0 -182
- package/dist/agent-scope-BVf4aSwY.js +0 -112
- package/dist/agent-scope-OZi7lb8S.js +0 -452
- package/dist/agent-scope-V1bi9OYL.js +0 -452
- package/dist/agents-BUWqn_Ui.js +0 -774
- package/dist/agents.config-Dvo2ULxs.js +0 -182
- package/dist/agents.config-d6H0_3oj.js +0 -182
- package/dist/argv-DqUHKf0o.js +0 -73
- package/dist/audit-C6okOOSh.js +0 -2401
- package/dist/audit-VWjIdwC7.js +0 -2401
- package/dist/auth-91o2YM96.js +0 -648
- package/dist/auth-choice-CAmACV13.js +0 -2681
- package/dist/auth-choice-p3SeHPj2.js +0 -2681
- package/dist/auth-health-B_jXrWe6.js +0 -149
- package/dist/auth-health-DCicUKYR.js +0 -149
- package/dist/auth-lZ26wsbN.js +0 -639
- package/dist/auth-profiles-CCDD56dU.js +0 -1564
- package/dist/auth-profiles-DxI8L7bs.js +0 -2689
- package/dist/banner-Cohn04J6.js +0 -294
- package/dist/browser-cli-DANzjztE.js +0 -1676
- package/dist/browser-cli-WjsVH741.js +0 -1679
- package/dist/call-BAHvlu2G.js +0 -282
- package/dist/call-Ct7EGP_L.js +0 -282
- package/dist/catalog-BAayBt1L.js +0 -185
- package/dist/catalog-BNsf97BM.js +0 -185
- package/dist/channel-options-Dx9nPlX8.js +0 -33
- package/dist/channel-options-ZdvXrTGs.js +0 -32
- package/dist/channel-selection-CujyiWGM.js +0 -51
- package/dist/channel-selection-DfGpCyh2.js +0 -51
- package/dist/channel-web-CC0hkgkR.js +0 -2162
- package/dist/channels-cli-D7lNBpIb.js +0 -1304
- package/dist/channels-cli-DUPG8WDv.js +0 -1306
- package/dist/channels-status-issues-DBc1pU_R.js +0 -18
- package/dist/channels-status-issues-DjO9MHIG.js +0 -18
- package/dist/chrome-Bi6iZ5sG.js +0 -1601
- package/dist/chrome-DNSv7Cpy.js +0 -1629
- package/dist/chrome-DScZx4Lk.js +0 -1601
- package/dist/chunk-mxPVo000.js +0 -348
- package/dist/clack-prompter-B0kl7shw.js +0 -92
- package/dist/clack-prompter-B1YxZdRy.js +0 -92
- package/dist/cli-CfHUkOD0.js +0 -101
- package/dist/cli-ClMrIh6l.js +0 -99
- package/dist/cli-session-BkPTd9Pk.js +0 -5463
- package/dist/cli-session-Dd8DKb5a.js +0 -5408
- package/dist/client-C1avc0vD.js +0 -1692
- package/dist/client-CC94YZrT.js +0 -1692
- package/dist/clipboard-B2fBy8tG.js +0 -31
- package/dist/clipboard-BbGnZskJ.js +0 -31
- package/dist/command-format-Clp46jkj.js +0 -38
- package/dist/command-format-DELazozB.js +0 -52
- package/dist/command-format-SkzzRqR1.js +0 -52
- package/dist/command-registry-DZ4hkmA0.js +0 -248
- package/dist/commands-DtYZJSPn.js +0 -568
- package/dist/commands-Dujk1JmY.js +0 -568
- package/dist/commands-registry-Bd0xbvwG.js +0 -766
- package/dist/commands-registry-DYfRSVF3.js +0 -766
- package/dist/common-D6bu0zHC.js +0 -287
- package/dist/common-zW9Y2P1B.js +0 -287
- package/dist/completion-cli-tSe7Pmqm.js +0 -431
- package/dist/completion-cli-vn4IScs5.js +0 -432
- package/dist/config-C8rUDJXY.js +0 -5704
- package/dist/config-CLZ_XGVw.js +0 -6523
- package/dist/config-SY8M0kM_.js +0 -5705
- package/dist/config-cli-1V7D2Wsw.js +0 -247
- package/dist/config-cli-CjWEC81L.js +0 -244
- package/dist/config-guard-BW2gpKj_.js +0 -93
- package/dist/config-guard-BvxuzHpo.js +0 -76
- package/dist/config-sync-CoIIbEOe.js +0 -91
- package/dist/config-sync-DvAttep0.js +0 -91
- package/dist/configure-Bf0oupCE.js +0 -959
- package/dist/configure-DRM-7zFf.js +0 -960
- package/dist/context-D5iEFzv9.js +0 -60
- package/dist/control-service-C8m8F9pr.js +0 -72
- package/dist/control-service-DKotCWCg.js +0 -72
- package/dist/cron-cli-DB_FLYHD.js +0 -448
- package/dist/cron-cli-bxm5lrrO.js +0 -451
- package/dist/daemon-cli-1LsOnICv.js +0 -566
- package/dist/daemon-cli-CC2NrJ7a.js +0 -565
- package/dist/daemon-runtime-BXZhtBL9.js +0 -460
- package/dist/daemon-runtime-DW4USC7r.js +0 -460
- package/dist/deliver-B4HuPwJA.js +0 -1162
- package/dist/deliver-LiY5oL52.js +0 -1097
- package/dist/deliver-xrmk7xjh.js +0 -1097
- package/dist/delivery-queue-TnQykYsg.js +0 -220
- package/dist/deps-CMMOiOsF.js +0 -42
- package/dist/devices-cli-Be5he2SA.js +0 -195
- package/dist/devices-cli-z6ecoFe9.js +0 -198
- package/dist/diagnostics-Dj75aEHN.js +0 -35
- package/dist/diagnostics-DlIw6fqD.js +0 -35
- package/dist/directory-cli-CEy-0nxj.js +0 -243
- package/dist/directory-cli-DpzKcigr.js +0 -246
- package/dist/dispatcher-10Shiuz3.js +0 -100
- package/dist/dispatcher-3Jae6AiW.js +0 -100
- package/dist/dns-cli-Bat1pkc-.js +0 -200
- package/dist/dns-cli-NohNyEo0.js +0 -197
- package/dist/dock-DbxBBv30.js +0 -753
- package/dist/dock-cPBY4qGl.js +0 -753
- package/dist/docs-cli-BWp6p-Tq.js +0 -161
- package/dist/docs-cli-x22FnZfL.js +0 -159
- package/dist/doctor-BrT5m_on.js +0 -1815
- package/dist/doctor-Pp2HVnjM.js +0 -1813
- package/dist/doctor-completion-DNTimX9o.js +0 -92
- package/dist/doctor-completion-ylN9QAJ6.js +0 -92
- package/dist/doctor-config-flow-D1w3700T.js +0 -1232
- package/dist/doctor-config-flow-Dq50iE1R.js +0 -1232
- package/dist/engine-B9avUJL5.js +0 -563
- package/dist/engine-BiUQ25D4.js +0 -563
- package/dist/env-0lJfCPsw.js +0 -32
- package/dist/exec-BenD3A5l.js +0 -1167
- package/dist/exec-Bv3pyjeM.js +0 -255
- package/dist/exec-approvals-CdLmKX2R.js +0 -1221
- package/dist/exec-approvals-cli-DXfV6G8H.js +0 -368
- package/dist/exec-approvals-cli-J2cZs10o.js +0 -371
- package/dist/frontmatter-YijVi0FQ.js +0 -204
- package/dist/gateway-cli-DOAbA0pc.js +0 -19972
- package/dist/gateway-cli-QpWtBhQy.js +0 -19971
- package/dist/gateway-rpc-DJKBil9s.js +0 -28
- package/dist/gateway-rpc-DVterpLP.js +0 -28
- package/dist/github-copilot-auth-4IUFp669.js +0 -1418
- package/dist/github-copilot-auth-C9E0IROs.js +0 -1418
- package/dist/gmail-setup-utils-BPo_LkKI.js +0 -428
- package/dist/gmail-setup-utils-D3Yqgor7.js +0 -428
- package/dist/health-BeZnqp6m.js +0 -1258
- package/dist/health-Cn2OoVWZ.js +0 -1253
- package/dist/health-format-CdP99j3Y.js +0 -208
- package/dist/health-format-JEChH08S.js +0 -208
- package/dist/heartbeat-visibility-BL3WAchI.js +0 -98
- package/dist/heartbeat-visibility-CQ9QimI7.js +0 -98
- package/dist/help-format-Dl4bsrLI.js +0 -17
- package/dist/helpers-ZKNRexvX.js +0 -10
- package/dist/hooks-cli-D99hXt7K.js +0 -991
- package/dist/hooks-cli-DMB8RiEO.js +0 -993
- package/dist/hooks-status-B-e96dZj.js +0 -356
- package/dist/hooks-status-C_9sE0ox.js +0 -356
- package/dist/image-ops-Dlt3T7th.js +0 -541
- package/dist/image-ops-omlvdfah.js +0 -541
- package/dist/init-Bm04RagW.js +0 -122
- package/dist/init-CaJBf4p1.js +0 -122
- package/dist/installs-C2iMRBVz.js +0 -383
- package/dist/installs-D-cPGdCw.js +0 -383
- package/dist/ipv4-Bf7NS3QU.js +0 -1964
- package/dist/ipv4-wWNs8IH_.js +0 -1964
- package/dist/lanes-CNxj3tit.js +0 -232
- package/dist/lifecycle-core-B_7XRcvF.js +0 -388
- package/dist/lifecycle-core-By83PVAK.js +0 -387
- package/dist/links-BfjHVTB_.js +0 -15
- package/dist/links-DPGe0OHw.js +0 -15
- package/dist/logging-DB6BQmhi.js +0 -15
- package/dist/logging-mcb66J0p.js +0 -15
- package/dist/login-BDCg6D0N.js +0 -61
- package/dist/login-BDfnbjnZ.js +0 -59
- package/dist/login-BqH1itcg.js +0 -61
- package/dist/login-qr-CyOw3R4r.js +0 -321
- package/dist/login-qr-D8ECtb72.js +0 -323
- package/dist/login-qr-RnR7e4Bw.js +0 -326
- package/dist/logs-cli--j89L74J.js +0 -245
- package/dist/logs-cli-DpEMg_Gq.js +0 -242
- package/dist/manager-B4OyvcxT.js +0 -3244
- package/dist/manager-Cqc1CeH7.js +0 -3246
- package/dist/manager-DUyQPFvj.js +0 -3244
- package/dist/manifest-registry-CW1zCyRF.js +0 -748
- package/dist/manifest-registry-D4lM2RdV.js +0 -748
- package/dist/markdown-tables-BT1X6jqH.js +0 -347
- package/dist/markdown-tables-DHgOK2vI.js +0 -348
- package/dist/media-THyainiE.js +0 -1342
- package/dist/memory-cli-BKocCWXM.js +0 -868
- package/dist/memory-cli-Jmma-xI_.js +0 -869
- package/dist/message-channel-dSTVVCyX.js +0 -110
- package/dist/migrate-BR6iAIjO.js +0 -157
- package/dist/migrate-D0EcMs0f.js +0 -157
- package/dist/model-selection-YcSr9CgC.js +0 -2691
- package/dist/models-1vUQBVfw.js +0 -2510
- package/dist/models-cli-BK3BwUhL.js +0 -2739
- package/dist/models-cli-DECrM8oA.js +0 -258
- package/dist/net-B5lXhYLV.js +0 -218
- package/dist/node-cli-cLHUNpPD.js +0 -1319
- package/dist/node-cli-fO7Y132S.js +0 -1322
- package/dist/node-service-BFxHJsno.js +0 -67
- package/dist/node-service-DUnan4uK.js +0 -67
- package/dist/nodes-cli-BCq35E6N.js +0 -1200
- package/dist/nodes-cli-vD7MwAKP.js +0 -1197
- package/dist/nodes-screen-1YiLkqr5.js +0 -234
- package/dist/nodes-screen-DZeD8hE5.js +0 -234
- package/dist/note-Bi8Wb8DV.js +0 -73
- package/dist/note-uiuPxhyX.js +0 -73
- package/dist/npm-registry-spec-B-XIShkB.js +0 -351
- package/dist/npm-registry-spec-za3itb5Y.js +0 -351
- package/dist/onboard-Ds6w_sWo.js +0 -1165
- package/dist/onboard-SAVx3bp4.js +0 -1166
- package/dist/onboard-channels-Cg_EkBa4.js +0 -672
- package/dist/onboard-channels-D7NbA55V.js +0 -672
- package/dist/onboard-helpers-DO_hgZb9.js +0 -365
- package/dist/onboard-helpers-_XgJgeqh.js +0 -365
- package/dist/onboarding-3hLmDd0r.js +0 -911
- package/dist/onboarding-B4LKLsbU.js +0 -910
- package/dist/orchestrator-BKzmyBWy.js +0 -357
- package/dist/orchestrator-BN3QCz2s.js +0 -357
- package/dist/outbound-BgA9hNlP.js +0 -2062
- package/dist/outbound-CjdvVhUI.js +0 -214
- package/dist/outbound-DOGe6qb2.js +0 -214
- package/dist/outbound-send-deps-Du5aBpd7.js +0 -55
- package/dist/pairing-cli-2vnyg_Nd.js +0 -118
- package/dist/pairing-cli-BH1KQtNV.js +0 -121
- package/dist/pairing-store-DJz_9Gv0.js +0 -388
- package/dist/pairing-store-DmOzxcuk.js +0 -388
- package/dist/path-env-Bu6k0jDQ.js +0 -89
- package/dist/path-env-C0zQSjw8.js +0 -89
- package/dist/paths-BTc4nk-6.js +0 -126
- package/dist/paths-BgUi2Z2G.js +0 -54
- package/dist/paths-C6VCWKo3.js +0 -238
- package/dist/paths-CCxa0o9c.js +0 -222
- package/dist/paths-CxRf2rBG.js +0 -129
- package/dist/paths-hcX1Gqg5.js +0 -129
- package/dist/pi-auth-json-B68R7q7_.js +0 -82
- package/dist/pi-auth-json-CR0jXAgq.js +0 -78
- package/dist/pi-auth-json-ZYzi3nxs.js +0 -80
- package/dist/pi-model-discovery-Cxs4pvC2.js +0 -3
- package/dist/pi-tools.policy-D81U5xy0.js +0 -200
- package/dist/pi-tools.policy-DSHkkb5b.js +0 -200
- package/dist/plugin-auto-enable-CxF4bpDN.js +0 -282
- package/dist/plugin-auto-enable-jNaAeyEh.js +0 -282
- package/dist/plugin-registry-C7XWotZG.js +0 -32
- package/dist/plugin-registry-DcUCbGax.js +0 -32
- package/dist/plugins-B362e77G.js +0 -168
- package/dist/plugins-CmSUIUNi.js +0 -38
- package/dist/plugins-cli-BsCEnoQ7.js +0 -734
- package/dist/plugins-cli-QSIsMUG7.js +0 -736
- package/dist/polls-CItfB1H8.js +0 -1343
- package/dist/ports-BVLMN1Sr.js +0 -96
- package/dist/ports-CqLSlU6Z.js +0 -317
- package/dist/ports-D94CwCrv.js +0 -344
- package/dist/ports-D_NHthOz.js +0 -96
- package/dist/program-DkJHjI0R.js +0 -176
- package/dist/program-context-DnyGM2SC.js +0 -496
- package/dist/progress-Bek_GyWS.js +0 -133
- package/dist/prompt-style-lu0clOOE.js +0 -9
- package/dist/pw-ai-BLVMuSLv.js +0 -1867
- package/dist/pw-ai-DZJWEF_f.js +0 -1865
- package/dist/pw-ai-dzf-ptcn.js +0 -1868
- package/dist/qmd-manager-Cur_Ekn0.js +0 -937
- package/dist/qmd-manager-DNAUuwjK.js +0 -938
- package/dist/qmd-manager-DepEoASu.js +0 -935
- package/dist/register.agent-CSWvzOkR.js +0 -265
- package/dist/register.agent-UeH2NXmH.js +0 -1003
- package/dist/register.anima-DOdee0dh.js +0 -193
- package/dist/register.anima-HHDWsz6r.js +0 -193
- package/dist/register.configure-CSJFxdz9.js +0 -103
- package/dist/register.configure-D84Fvcz4.js +0 -101
- package/dist/register.maintenance-B3pvNbZb.js +0 -543
- package/dist/register.maintenance-BKVOwkw6.js +0 -543
- package/dist/register.message-BAO6CPl2.js +0 -657
- package/dist/register.message-OXoOKE_6.js +0 -660
- package/dist/register.onboard-BK_ixVmD.js +0 -170
- package/dist/register.onboard-cfCaPx6j.js +0 -170
- package/dist/register.setup-BGfDnzph.js +0 -175
- package/dist/register.setup-Y-Q74M-0.js +0 -175
- package/dist/register.status-health-sessions-CT14eitH.js +0 -142
- package/dist/register.status-health-sessions-TfZMzAUn.js +0 -313
- package/dist/register.subclis-BZwdlNHC.js +0 -255
- package/dist/reply-mlsExaZm.js +0 -32212
- package/dist/reply-prefix-B0CfR4bM.js +0 -100
- package/dist/reply-prefix-w4a39ybC.js +0 -100
- package/dist/reply-qalRISe_.js +0 -32212
- package/dist/routes-CENsHJyg.js +0 -1820
- package/dist/routes-DO0HqW2e.js +0 -1820
- package/dist/rpc-C0pjNhBi.js +0 -70
- package/dist/rpc-DZ44PIXE.js +0 -70
- package/dist/run-main-BMpKw8Mp.js +0 -371
- package/dist/runtime-guard-BSUFiAQV.js +0 -60
- package/dist/sandbox-BIGfMYEI.js +0 -858
- package/dist/sandbox-DxP3IpUP.js +0 -859
- package/dist/sandbox-cli-DtLGH8sL.js +0 -461
- package/dist/sandbox-cli-_Tg7lfJ_.js +0 -458
- package/dist/security-cli-BRwgbedo.js +0 -462
- package/dist/security-cli-D3bSuyZt.js +0 -465
- package/dist/server-context-49XFFxFg.js +0 -824
- package/dist/server-context-LrlgrZzS.js +0 -824
- package/dist/server-node-events-Dm52i7NW.js +0 -231
- package/dist/server-node-events-QX523UyF.js +0 -233
- package/dist/service-BNVpYcQe.js +0 -642
- package/dist/service-D56aMXUB.js +0 -642
- package/dist/service-audit-D0X_XAB2.js +0 -488
- package/dist/service-audit-qmf6XMmP.js +0 -488
- package/dist/session-CrQQLLhx.js +0 -179
- package/dist/session-LocsOOWJ.js +0 -181
- package/dist/session-Vlce2BAT.js +0 -181
- package/dist/session-cost-usage-BwiTZuKl.js +0 -600
- package/dist/session-cost-usage-DT9YNXTJ.js +0 -600
- package/dist/sessions-BfV53TbG.js +0 -1296
- package/dist/sessions-BimpX_km.js +0 -180
- package/dist/sessions-DcXpzig0.js +0 -1296
- package/dist/sessions-Wd18dukK.js +0 -2038
- package/dist/shared-Bsr69u_7.js +0 -77
- package/dist/shared-Cgly1vPb.js +0 -66
- package/dist/shared-JOo05hST.js +0 -66
- package/dist/shared-f7dvQsi7.js +0 -77
- package/dist/skill-scanner-CkaVLABv.js +0 -263
- package/dist/skills-B-G7UHOa.js +0 -808
- package/dist/skills-B5LQx4lT.js +0 -807
- package/dist/skills-cli-DUGe2ZWW.js +0 -286
- package/dist/skills-cli-DtOk0bvK.js +0 -289
- package/dist/skills-status-Clq9ZnYu.js +0 -166
- package/dist/skills-status-JQluhU-P.js +0 -166
- package/dist/sqlite-BukcjdJa.js +0 -321
- package/dist/sqlite-CGcOZZ0C.js +0 -368
- package/dist/sqlite-Ck6f9KWc.js +0 -453
- package/dist/start--xmSFepB.js +0 -372
- package/dist/start-BdlZbqrr.js +0 -371
- package/dist/status-BgoeFm6g.js +0 -2137
- package/dist/status-BjjDrUq7.js +0 -27
- package/dist/status-Ct0DgOZ-.js +0 -2132
- package/dist/status-RA_uNmK0.js +0 -27
- package/dist/status.update-BjOH3GlS.js +0 -79
- package/dist/status.update-DLU1qBf0.js +0 -79
- package/dist/subagent-registry-9RLdKxES.js +0 -2760
- package/dist/subagent-registry-Byuex3zp.js +0 -2759
- package/dist/subagent-registry-DOBunBYS.js +0 -14
- package/dist/subsystem-Dowf8fSU.js +0 -860
- package/dist/system-cli-C5oBpzni.js +0 -79
- package/dist/system-cli-DXNKD_Id.js +0 -82
- package/dist/systemd-BSrHDyeU.js +0 -452
- package/dist/systemd-By5xdSB4.js +0 -452
- package/dist/systemd-hints-BtjL_5Rh.js +0 -36
- package/dist/systemd-hints-sJmr6cjb.js +0 -36
- package/dist/systemd-linger-CTmV2Gci.js +0 -75
- package/dist/systemd-linger-CmyqQkeC.js +0 -75
- package/dist/table-BL0lJzsm.js +0 -279
- package/dist/table-DoiRPsn0.js +0 -279
- package/dist/timeout-CswI_K-U.js +0 -232
- package/dist/tokens-C-X7wDKj.js +0 -14
- package/dist/tokens-DkvqA72p.js +0 -14
- package/dist/trash-BJLK1vMn.js +0 -23
- package/dist/trash-_x5UZ94k.js +0 -23
- package/dist/tui-BHjxDFZC.js +0 -3894
- package/dist/tui-CgOocwN8.js +0 -3894
- package/dist/tui-cli-5ANH8dE5.js +0 -47
- package/dist/tui-cli-BQ4P-JW_.js +0 -50
- package/dist/update-LFgxHHPd.js +0 -317
- package/dist/update-TxptCqk7.js +0 -317
- package/dist/update-check-CWc7YXmc.js +0 -400
- package/dist/update-check-IhlWaui6.js +0 -400
- package/dist/update-cli-PtXU62w7.js +0 -1105
- package/dist/update-cli-Va0EtETG.js +0 -1105
- package/dist/update-runner-BLeKFkiB.js +0 -894
- package/dist/update-runner-Iuzpc-_y.js +0 -894
- package/dist/usage-ApGvBLVg.js +0 -4516
- package/dist/utils-Bsw__U-F.js +0 -243
- package/dist/web-B6_Ky60G.js +0 -63
- package/dist/web-EZLQEWXY.js +0 -46842
- package/dist/web-pec8YJUX.js +0 -2203
- package/dist/webhooks-cli-BYQKTHTp.js +0 -319
- package/dist/webhooks-cli-C2_xtsUQ.js +0 -316
- package/dist/whatsapp-actions-C72VCq8f.js +0 -49
- package/dist/whatsapp-actions-Ck9Uv0Nw.js +0 -45
- package/dist/whatsapp-actions-D0reTj2k.js +0 -53
- package/dist/widearea-dns-B6ocX23x.js +0 -127
- package/dist/widearea-dns-NsEUNYwz.js +0 -127
- package/dist/workspace-Dcfoy5JJ.js +0 -649
- package/dist/ws-log-N8R5MvGE.js +0 -267
- package/dist/ws-log-gwFxPxj5.js +0 -267
- /package/dist/{auto-update-CUeF99gI.js → auto-update-CpF0fycd.js} +0 -0
- /package/dist/{auto-update-cgkp9ZTJ.js → auto-update-DNWdO7uF.js} +0 -0
- /package/dist/{brew-CVZkr0GU.js → brew-nqf_MiE4.js} +0 -0
- /package/dist/{budget-DxYQSekw.js → budget-CPedI-qW.js} +0 -0
- /package/dist/{budget-BWBp8Res.js → budget-CRpvqDRX.js} +0 -0
- /package/dist/{cli-utils-DtAxdCte.js → cli-utils-C1YHVD4o.js} +0 -0
- /package/dist/{command-options-CSbuuqHr.js → command-options-BbponVnw.js} +0 -0
- /package/dist/{command-options-Cp1tf96a.js → command-options-s0gnvXnS.js} +0 -0
- /package/dist/{constants-O8yBqCBv.js → constants-Dhb6zSIV.js} +0 -0
- /package/dist/{dangerous-tools-5ObDWy1N.js → dangerous-tools-DGTtJ_JR.js} +0 -0
- /package/dist/{dangerous-tools-Jwr7jqNw.js → dangerous-tools-DxrfTOfT.js} +0 -0
- /package/dist/{delivery-queue-B6IHz4Ry.js → delivery-queue-Bxm0nzw7.js} +0 -0
- /package/dist/{display-BDOsXu8F.js → display-Jy3UdGzA.js} +0 -0
- /package/dist/{errors-CHow2wtt.js → errors-CKaCqKga.js} +0 -0
- /package/dist/{exec-BizYYQgP.js → exec-DDmuVVNq.js} +0 -0
- /package/dist/{format-Mq6iU0_5.js → format-ByEjgyTF.js} +0 -0
- /package/dist/{format-duration-DhWzz_5b.js → format-duration-Aaj5tjJd.js} +0 -0
- /package/dist/{format-relative-C6kUHuOj.js → format-relative-79_Y1n2Y.js} +0 -0
- /package/dist/{help-format-DUBI91Ti.js → help-format-BMKzarov.js} +0 -0
- /package/dist/{helpers-eJFa4K6r.js → helpers-DpEB9Mh0.js} +0 -0
- /package/dist/{helpers-DLgbkcEn.js → helpers-FMld9sBT.js} +0 -0
- /package/dist/{input-provenance-DJBdpeKk.js → input-provenance-Cy_KnBlP.js} +0 -0
- /package/dist/{is-main-Dt9DTcH1.js → is-main-yjaVwMtJ.js} +0 -0
- /package/dist/{loader-l2OBdJ8x.js → loader-Br7Vr0zn.js} +0 -0
- /package/dist/{loader-BoYxRfcW.js → loader-CkmOrXcC.js} +0 -0
- /package/dist/{logging-BdnOSVPD.js → logging-CY-Q5cwf.js} +0 -0
- /package/dist/{message-channel-w4F2b2F6.js → message-channel-dua8OOGJ.js} +0 -0
- /package/dist/{mime-B1ZoR53M.js → mime-CBg4KybI.js} +0 -0
- /package/dist/{model-param-b-DPwyNGn8.js → model-param-b-DW9f0NN8.js} +0 -0
- /package/dist/{node-match-8XZnaid6.js → node-match-BV8bTBd4.js} +0 -0
- /package/dist/{normalize-GDK8JTNW.js → normalize-_lmlBOW9.js} +0 -0
- /package/dist/{openclaw-root-C85WMnVV.js → openclaw-root-JPvmPTf7.js} +0 -0
- /package/dist/{outbound-send-deps-ANnAhImn.js → outbound-send-deps-BfUvuWGa.js} +0 -0
- /package/dist/{parse-6-2MDhdT.js → parse-CZRwKocn.js} +0 -0
- /package/dist/{parse-log-line-Bqh1SSzC.js → parse-log-line-CvrZEK6A.js} +0 -0
- /package/dist/{parse-log-line-DUZCjXbl.js → parse-log-line-mLdat0AH.js} +0 -0
- /package/dist/{parse-port-BKB9Exlg.js → parse-port-BSOOdo7I.js} +0 -0
- /package/dist/{parse-port-DrfvwwiL.js → parse-port-Y0NK62x1.js} +0 -0
- /package/dist/{parse-timeout-Di_tcEmi.js → parse-timeout-DVPQ3n9j.js} +0 -0
- /package/dist/{paths-DcVEkYX5.js → paths-DHjlJ6cn.js} +0 -0
- /package/dist/{pi-model-discovery-DsRqYJLy.js → pi-model-discovery-DzEIEgHL.js} +0 -0
- /package/dist/{plugins-CDJw924T.js → plugins-D6PBOdkn.js} +0 -0
- /package/dist/{program-context-Bvn8046-.js → program-context-Q1hkT73c.js} +0 -0
- /package/dist/{progress-CbZ2D53A.js → progress-C9Ha1NJh.js} +0 -0
- /package/dist/{prompt-style-DKy6qQxR.js → prompt-style-DQi8j03a.js} +0 -0
- /package/dist/{prompts-BI__va99.js → prompts-BEHxUC3w.js} +0 -0
- /package/dist/{prompts-_dDWkCAz.js → prompts-CSOhuiqe.js} +0 -0
- /package/dist/{queue-D_u34pbL.js → queue-BJGo7kAB.js} +0 -0
- /package/dist/{queue-PG591iID.js → queue-DYgUbdoq.js} +0 -0
- /package/dist/{redact-ClVwO7Nn.js → redact-CyKvdFrg.js} +0 -0
- /package/dist/{registry-Bs_DJK9E.js → registry-C5MAYD4V.js} +0 -0
- /package/dist/{registry-D_zlP1U-.js → registry-CRrXXVs0.js} +0 -0
- /package/dist/{requirements-BzZxj2Wu.js → requirements-CGkxTCu4.js} +0 -0
- /package/dist/{requirements-DIW1svgA.js → requirements-CIDaOcbO.js} +0 -0
- /package/dist/{runtime-guard-DeOXA_86.js → runtime-guard-nL3Lp8T-.js} +0 -0
- /package/dist/{secret-equal-Dghy3xsA.js → secret-equal-DJpmLXlG.js} +0 -0
- /package/dist/{send-BhAfdGII.js → send-CTcxgDDU.js} +0 -0
- /package/dist/{send-ga9udK1_.js → send-DPezUR3-.js} +0 -0
- /package/dist/{send-C2t9xpXI.js → send-DZQTaG7-.js} +0 -0
- /package/dist/{send-DigO-i9j.js → send-VDff2gra.js} +0 -0
- /package/dist/{send-Dz2BDHll.js → send-bgQNV8d1.js} +0 -0
- /package/dist/{session-key-BGiG_JcT.js → session-key-CQT-NR6w.js} +0 -0
- /package/dist/{shell-argv-CAq1mLa2.js → shell-argv-n9IueeJQ.js} +0 -0
- /package/dist/{skill-scanner-Coo4QoCd.js → skill-scanner-o6NgVMD9.js} +0 -0
- /package/dist/{status-CMnlcBVc.js → status-C53kTIXF.js} +0 -0
- /package/dist/{status-tDZPwewW.js → status-CZDDA_Sy.js} +0 -0
- /package/dist/{system-run-command-X9lDJIy0.js → system-run-command-BCjUffN9.js} +0 -0
- /package/dist/{system-run-command-DGk7dwQP.js → system-run-command-CqAqKL9K.js} +0 -0
- /package/dist/{tailnet-CuiNECdL.js → tailnet-Ciwjv243.js} +0 -0
- /package/dist/{templates-CeYJjVzw.js → templates-37RKpACb.js} +0 -0
- /package/dist/{templates-I3Z0xplD.js → templates-DPalk30o.js} +0 -0
- /package/dist/{thinking-BXEswx1X.js → thinking-2hxwmvTl.js} +0 -0
- /package/dist/{transcript-events-C1hdue6u.js → transcript-events-Bp7fGnwv.js} +0 -0
- /package/dist/{transcript-tools-DuyYOkUq.js → transcript-tools-D4Lbxlka.js} +0 -0
- /package/dist/{usage-format-BAirWUSO.js → usage-format-6Uar63S0.js} +0 -0
- /package/dist/{utils-C9sj30YY.js → utils-DT8uXjFS.js} +0 -0
- /package/dist/{wsl-CqyuRvtM.js → wsl-CrPvx2kZ.js} +0 -0
- /package/dist/{wsl-ymJYvc9Q.js → wsl-UvJ5dHah.js} +0 -0
|
@@ -0,0 +1,1820 @@
|
|
|
1
|
+
import { _ as resolveConfigDir } from "./utils-DZ8pnOD5.js";
|
|
2
|
+
import { t as parseBooleanValue } from "./boolean-Wzu0-e0P.js";
|
|
3
|
+
import { i as loadConfig, l as writeConfigFile } from "./config-DaqbUdkI.js";
|
|
4
|
+
import { a as resizeToJpeg, n as getImageMetadata } from "./image-ops-B_AYV3tp.js";
|
|
5
|
+
import { n as extensionForMime, t as detectMime } from "./mime-C1RlpUSs.js";
|
|
6
|
+
import { T as DEFAULT_BROWSER_DEFAULT_PROFILE_NAME, a as resolveAnimaUserDataDir, b as DEFAULT_AI_SNAPSHOT_EFFICIENT_MAX_CHARS, c as captureScreenshot, f as snapshotAria, s as resolveBrowserExecutableForPlatform, x as DEFAULT_AI_SNAPSHOT_MAX_CHARS, y as DEFAULT_AI_SNAPSHOT_EFFICIENT_DEPTH } from "./chrome-U3DRzjJD.js";
|
|
7
|
+
import { a as resolveProfile, c as getUsedColors, d as deriveDefaultBrowserCdpPortRange, f as getPwAiModule$1, l as getUsedPorts, o as allocateCdpPort, r as parseHttpUrl, s as allocateColor, u as isValidProfileName } from "./server-context-C0xZbYhg.js";
|
|
8
|
+
import { a as resolvePathsWithinRoot, i as resolvePathWithinRoot, n as DEFAULT_TRACE_DIR, r as DEFAULT_UPLOAD_DIR, t as DEFAULT_DOWNLOAD_DIR } from "./paths-Buw_geoe.js";
|
|
9
|
+
import { t as movePathToTrash } from "./trash-C39a6hKA.js";
|
|
10
|
+
import fs, { createWriteStream } from "node:fs";
|
|
11
|
+
import path from "node:path";
|
|
12
|
+
import fs$1 from "node:fs/promises";
|
|
13
|
+
import crypto from "node:crypto";
|
|
14
|
+
import { pipeline } from "node:stream/promises";
|
|
15
|
+
|
|
16
|
+
//#region src/browser/routes/agent.act.shared.ts
|
|
17
|
+
const ACT_KINDS = [
|
|
18
|
+
"click",
|
|
19
|
+
"close",
|
|
20
|
+
"drag",
|
|
21
|
+
"evaluate",
|
|
22
|
+
"fill",
|
|
23
|
+
"hover",
|
|
24
|
+
"scrollIntoView",
|
|
25
|
+
"press",
|
|
26
|
+
"resize",
|
|
27
|
+
"select",
|
|
28
|
+
"type",
|
|
29
|
+
"wait"
|
|
30
|
+
];
|
|
31
|
+
function isActKind(value) {
|
|
32
|
+
if (typeof value !== "string") return false;
|
|
33
|
+
return ACT_KINDS.includes(value);
|
|
34
|
+
}
|
|
35
|
+
const ALLOWED_CLICK_MODIFIERS = new Set([
|
|
36
|
+
"Alt",
|
|
37
|
+
"Control",
|
|
38
|
+
"ControlOrMeta",
|
|
39
|
+
"Meta",
|
|
40
|
+
"Shift"
|
|
41
|
+
]);
|
|
42
|
+
function parseClickButton(raw) {
|
|
43
|
+
if (raw === "left" || raw === "right" || raw === "middle") return raw;
|
|
44
|
+
}
|
|
45
|
+
function parseClickModifiers(raw) {
|
|
46
|
+
if (raw.filter((m) => !ALLOWED_CLICK_MODIFIERS.has(m)).length) return { error: "modifiers must be Alt|Control|ControlOrMeta|Meta|Shift" };
|
|
47
|
+
return { modifiers: raw.length ? raw : void 0 };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/browser/routes/utils.ts
|
|
52
|
+
/**
|
|
53
|
+
* Extract profile name from query string or body and get profile context.
|
|
54
|
+
* Query string takes precedence over body for consistency with GET routes.
|
|
55
|
+
*/
|
|
56
|
+
function getProfileContext(req, ctx) {
|
|
57
|
+
let profileName;
|
|
58
|
+
if (typeof req.query.profile === "string") profileName = req.query.profile.trim() || void 0;
|
|
59
|
+
if (!profileName && req.body && typeof req.body === "object") {
|
|
60
|
+
const body = req.body;
|
|
61
|
+
if (typeof body.profile === "string") profileName = body.profile.trim() || void 0;
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
return ctx.forProfile(profileName);
|
|
65
|
+
} catch (err) {
|
|
66
|
+
return {
|
|
67
|
+
error: String(err),
|
|
68
|
+
status: 404
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function jsonError(res, status, message) {
|
|
73
|
+
res.status(status).json({ error: message });
|
|
74
|
+
}
|
|
75
|
+
function toStringOrEmpty(value) {
|
|
76
|
+
if (typeof value === "string") return value.trim();
|
|
77
|
+
if (typeof value === "number" || typeof value === "boolean") return String(value).trim();
|
|
78
|
+
return "";
|
|
79
|
+
}
|
|
80
|
+
function toNumber(value) {
|
|
81
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
82
|
+
if (typeof value === "string" && value.trim()) {
|
|
83
|
+
const parsed = Number(value);
|
|
84
|
+
return Number.isFinite(parsed) ? parsed : void 0;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function toBoolean(value) {
|
|
88
|
+
return parseBooleanValue(value, {
|
|
89
|
+
truthy: [
|
|
90
|
+
"true",
|
|
91
|
+
"1",
|
|
92
|
+
"yes"
|
|
93
|
+
],
|
|
94
|
+
falsy: [
|
|
95
|
+
"false",
|
|
96
|
+
"0",
|
|
97
|
+
"no"
|
|
98
|
+
]
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
function toStringArray(value) {
|
|
102
|
+
if (!Array.isArray(value)) return;
|
|
103
|
+
const strings = value.map((v) => toStringOrEmpty(v)).filter(Boolean);
|
|
104
|
+
return strings.length ? strings : void 0;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
//#endregion
|
|
108
|
+
//#region src/browser/routes/agent.shared.ts
|
|
109
|
+
const SELECTOR_UNSUPPORTED_MESSAGE = [
|
|
110
|
+
"Error: 'selector' is not supported. Use 'ref' from snapshot instead.",
|
|
111
|
+
"",
|
|
112
|
+
"Example workflow:",
|
|
113
|
+
"1. snapshot action to get page state with refs",
|
|
114
|
+
"2. act with ref: \"e123\" to interact with element",
|
|
115
|
+
"",
|
|
116
|
+
"This is more reliable for modern SPAs."
|
|
117
|
+
].join("\n");
|
|
118
|
+
function readBody(req) {
|
|
119
|
+
const body = req.body;
|
|
120
|
+
if (!body || typeof body !== "object" || Array.isArray(body)) return {};
|
|
121
|
+
return body;
|
|
122
|
+
}
|
|
123
|
+
function handleRouteError(ctx, res, err) {
|
|
124
|
+
const mapped = ctx.mapTabError(err);
|
|
125
|
+
if (mapped) return jsonError(res, mapped.status, mapped.message);
|
|
126
|
+
jsonError(res, 500, String(err));
|
|
127
|
+
}
|
|
128
|
+
function resolveProfileContext(req, res, ctx) {
|
|
129
|
+
const profileCtx = getProfileContext(req, ctx);
|
|
130
|
+
if ("error" in profileCtx) {
|
|
131
|
+
jsonError(res, profileCtx.status, profileCtx.error);
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
return profileCtx;
|
|
135
|
+
}
|
|
136
|
+
async function getPwAiModule() {
|
|
137
|
+
return await getPwAiModule$1({ mode: "soft" });
|
|
138
|
+
}
|
|
139
|
+
async function requirePwAi(res, feature) {
|
|
140
|
+
const mod = await getPwAiModule();
|
|
141
|
+
if (mod) return mod;
|
|
142
|
+
jsonError(res, 501, [
|
|
143
|
+
`Playwright is not available in this gateway build; '${feature}' is unsupported.`,
|
|
144
|
+
"Install the full Playwright package (not playwright-core) and restart the gateway, or reinstall with browser support.",
|
|
145
|
+
"Docs: /tools/browser#playwright-requirement"
|
|
146
|
+
].join("\n"));
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region src/browser/routes/agent.act.ts
|
|
152
|
+
function registerBrowserAgentActRoutes(app, ctx) {
|
|
153
|
+
app.post("/act", async (req, res) => {
|
|
154
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
155
|
+
if (!profileCtx) return;
|
|
156
|
+
const body = readBody(req);
|
|
157
|
+
const kindRaw = toStringOrEmpty(body.kind);
|
|
158
|
+
if (!isActKind(kindRaw)) return jsonError(res, 400, "kind is required");
|
|
159
|
+
const kind = kindRaw;
|
|
160
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
161
|
+
if (Object.hasOwn(body, "selector") && kind !== "wait") return jsonError(res, 400, SELECTOR_UNSUPPORTED_MESSAGE);
|
|
162
|
+
try {
|
|
163
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
164
|
+
const cdpUrl = profileCtx.profile.cdpUrl;
|
|
165
|
+
const pw = await requirePwAi(res, `act:${kind}`);
|
|
166
|
+
if (!pw) return;
|
|
167
|
+
const evaluateEnabled = ctx.state().resolved.evaluateEnabled;
|
|
168
|
+
switch (kind) {
|
|
169
|
+
case "click": {
|
|
170
|
+
const ref = toStringOrEmpty(body.ref);
|
|
171
|
+
if (!ref) return jsonError(res, 400, "ref is required");
|
|
172
|
+
const doubleClick = toBoolean(body.doubleClick) ?? false;
|
|
173
|
+
const timeoutMs = toNumber(body.timeoutMs);
|
|
174
|
+
const buttonRaw = toStringOrEmpty(body.button) || "";
|
|
175
|
+
const button = buttonRaw ? parseClickButton(buttonRaw) : void 0;
|
|
176
|
+
if (buttonRaw && !button) return jsonError(res, 400, "button must be left|right|middle");
|
|
177
|
+
const parsedModifiers = parseClickModifiers(toStringArray(body.modifiers) ?? []);
|
|
178
|
+
if (parsedModifiers.error) return jsonError(res, 400, parsedModifiers.error);
|
|
179
|
+
const modifiers = parsedModifiers.modifiers;
|
|
180
|
+
const clickRequest = {
|
|
181
|
+
cdpUrl,
|
|
182
|
+
targetId: tab.targetId,
|
|
183
|
+
ref,
|
|
184
|
+
doubleClick
|
|
185
|
+
};
|
|
186
|
+
if (button) clickRequest.button = button;
|
|
187
|
+
if (modifiers) clickRequest.modifiers = modifiers;
|
|
188
|
+
if (timeoutMs) clickRequest.timeoutMs = timeoutMs;
|
|
189
|
+
await pw.clickViaPlaywright(clickRequest);
|
|
190
|
+
return res.json({
|
|
191
|
+
ok: true,
|
|
192
|
+
targetId: tab.targetId,
|
|
193
|
+
url: tab.url
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
case "type": {
|
|
197
|
+
const ref = toStringOrEmpty(body.ref);
|
|
198
|
+
if (!ref) return jsonError(res, 400, "ref is required");
|
|
199
|
+
if (typeof body.text !== "string") return jsonError(res, 400, "text is required");
|
|
200
|
+
const text = body.text;
|
|
201
|
+
const submit = toBoolean(body.submit) ?? false;
|
|
202
|
+
const slowly = toBoolean(body.slowly) ?? false;
|
|
203
|
+
const timeoutMs = toNumber(body.timeoutMs);
|
|
204
|
+
const typeRequest = {
|
|
205
|
+
cdpUrl,
|
|
206
|
+
targetId: tab.targetId,
|
|
207
|
+
ref,
|
|
208
|
+
text,
|
|
209
|
+
submit,
|
|
210
|
+
slowly
|
|
211
|
+
};
|
|
212
|
+
if (timeoutMs) typeRequest.timeoutMs = timeoutMs;
|
|
213
|
+
await pw.typeViaPlaywright(typeRequest);
|
|
214
|
+
return res.json({
|
|
215
|
+
ok: true,
|
|
216
|
+
targetId: tab.targetId
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
case "press": {
|
|
220
|
+
const key = toStringOrEmpty(body.key);
|
|
221
|
+
if (!key) return jsonError(res, 400, "key is required");
|
|
222
|
+
const delayMs = toNumber(body.delayMs);
|
|
223
|
+
await pw.pressKeyViaPlaywright({
|
|
224
|
+
cdpUrl,
|
|
225
|
+
targetId: tab.targetId,
|
|
226
|
+
key,
|
|
227
|
+
delayMs: delayMs ?? void 0
|
|
228
|
+
});
|
|
229
|
+
return res.json({
|
|
230
|
+
ok: true,
|
|
231
|
+
targetId: tab.targetId
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
case "hover": {
|
|
235
|
+
const ref = toStringOrEmpty(body.ref);
|
|
236
|
+
if (!ref) return jsonError(res, 400, "ref is required");
|
|
237
|
+
const timeoutMs = toNumber(body.timeoutMs);
|
|
238
|
+
await pw.hoverViaPlaywright({
|
|
239
|
+
cdpUrl,
|
|
240
|
+
targetId: tab.targetId,
|
|
241
|
+
ref,
|
|
242
|
+
timeoutMs: timeoutMs ?? void 0
|
|
243
|
+
});
|
|
244
|
+
return res.json({
|
|
245
|
+
ok: true,
|
|
246
|
+
targetId: tab.targetId
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
case "scrollIntoView": {
|
|
250
|
+
const ref = toStringOrEmpty(body.ref);
|
|
251
|
+
if (!ref) return jsonError(res, 400, "ref is required");
|
|
252
|
+
const timeoutMs = toNumber(body.timeoutMs);
|
|
253
|
+
const scrollRequest = {
|
|
254
|
+
cdpUrl,
|
|
255
|
+
targetId: tab.targetId,
|
|
256
|
+
ref
|
|
257
|
+
};
|
|
258
|
+
if (timeoutMs) scrollRequest.timeoutMs = timeoutMs;
|
|
259
|
+
await pw.scrollIntoViewViaPlaywright(scrollRequest);
|
|
260
|
+
return res.json({
|
|
261
|
+
ok: true,
|
|
262
|
+
targetId: tab.targetId
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
case "drag": {
|
|
266
|
+
const startRef = toStringOrEmpty(body.startRef);
|
|
267
|
+
const endRef = toStringOrEmpty(body.endRef);
|
|
268
|
+
if (!startRef || !endRef) return jsonError(res, 400, "startRef and endRef are required");
|
|
269
|
+
const timeoutMs = toNumber(body.timeoutMs);
|
|
270
|
+
await pw.dragViaPlaywright({
|
|
271
|
+
cdpUrl,
|
|
272
|
+
targetId: tab.targetId,
|
|
273
|
+
startRef,
|
|
274
|
+
endRef,
|
|
275
|
+
timeoutMs: timeoutMs ?? void 0
|
|
276
|
+
});
|
|
277
|
+
return res.json({
|
|
278
|
+
ok: true,
|
|
279
|
+
targetId: tab.targetId
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
case "select": {
|
|
283
|
+
const ref = toStringOrEmpty(body.ref);
|
|
284
|
+
const values = toStringArray(body.values);
|
|
285
|
+
if (!ref || !values?.length) return jsonError(res, 400, "ref and values are required");
|
|
286
|
+
const timeoutMs = toNumber(body.timeoutMs);
|
|
287
|
+
await pw.selectOptionViaPlaywright({
|
|
288
|
+
cdpUrl,
|
|
289
|
+
targetId: tab.targetId,
|
|
290
|
+
ref,
|
|
291
|
+
values,
|
|
292
|
+
timeoutMs: timeoutMs ?? void 0
|
|
293
|
+
});
|
|
294
|
+
return res.json({
|
|
295
|
+
ok: true,
|
|
296
|
+
targetId: tab.targetId
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
case "fill": {
|
|
300
|
+
const fields = (Array.isArray(body.fields) ? body.fields : []).map((field) => {
|
|
301
|
+
if (!field || typeof field !== "object") return null;
|
|
302
|
+
const rec = field;
|
|
303
|
+
const ref = toStringOrEmpty(rec.ref);
|
|
304
|
+
const type = toStringOrEmpty(rec.type);
|
|
305
|
+
if (!ref || !type) return null;
|
|
306
|
+
const value = typeof rec.value === "string" || typeof rec.value === "number" || typeof rec.value === "boolean" ? rec.value : void 0;
|
|
307
|
+
return value === void 0 ? {
|
|
308
|
+
ref,
|
|
309
|
+
type
|
|
310
|
+
} : {
|
|
311
|
+
ref,
|
|
312
|
+
type,
|
|
313
|
+
value
|
|
314
|
+
};
|
|
315
|
+
}).filter((field) => field !== null);
|
|
316
|
+
if (!fields.length) return jsonError(res, 400, "fields are required");
|
|
317
|
+
const timeoutMs = toNumber(body.timeoutMs);
|
|
318
|
+
await pw.fillFormViaPlaywright({
|
|
319
|
+
cdpUrl,
|
|
320
|
+
targetId: tab.targetId,
|
|
321
|
+
fields,
|
|
322
|
+
timeoutMs: timeoutMs ?? void 0
|
|
323
|
+
});
|
|
324
|
+
return res.json({
|
|
325
|
+
ok: true,
|
|
326
|
+
targetId: tab.targetId
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
case "resize": {
|
|
330
|
+
const width = toNumber(body.width);
|
|
331
|
+
const height = toNumber(body.height);
|
|
332
|
+
if (!width || !height) return jsonError(res, 400, "width and height are required");
|
|
333
|
+
await pw.resizeViewportViaPlaywright({
|
|
334
|
+
cdpUrl,
|
|
335
|
+
targetId: tab.targetId,
|
|
336
|
+
width,
|
|
337
|
+
height
|
|
338
|
+
});
|
|
339
|
+
return res.json({
|
|
340
|
+
ok: true,
|
|
341
|
+
targetId: tab.targetId,
|
|
342
|
+
url: tab.url
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
case "wait": {
|
|
346
|
+
const timeMs = toNumber(body.timeMs);
|
|
347
|
+
const text = toStringOrEmpty(body.text) || void 0;
|
|
348
|
+
const textGone = toStringOrEmpty(body.textGone) || void 0;
|
|
349
|
+
const selector = toStringOrEmpty(body.selector) || void 0;
|
|
350
|
+
const url = toStringOrEmpty(body.url) || void 0;
|
|
351
|
+
const loadStateRaw = toStringOrEmpty(body.loadState);
|
|
352
|
+
const loadState = loadStateRaw === "load" || loadStateRaw === "domcontentloaded" || loadStateRaw === "networkidle" ? loadStateRaw : void 0;
|
|
353
|
+
const fn = toStringOrEmpty(body.fn) || void 0;
|
|
354
|
+
const timeoutMs = toNumber(body.timeoutMs) ?? void 0;
|
|
355
|
+
if (fn && !evaluateEnabled) return jsonError(res, 403, ["wait --fn is disabled by config (browser.evaluateEnabled=false).", "Docs: /gateway/configuration#browser-anima-managed-browser"].join("\n"));
|
|
356
|
+
if (timeMs === void 0 && !text && !textGone && !selector && !url && !loadState && !fn) return jsonError(res, 400, "wait requires at least one of: timeMs, text, textGone, selector, url, loadState, fn");
|
|
357
|
+
await pw.waitForViaPlaywright({
|
|
358
|
+
cdpUrl,
|
|
359
|
+
targetId: tab.targetId,
|
|
360
|
+
timeMs,
|
|
361
|
+
text,
|
|
362
|
+
textGone,
|
|
363
|
+
selector,
|
|
364
|
+
url,
|
|
365
|
+
loadState,
|
|
366
|
+
fn,
|
|
367
|
+
timeoutMs
|
|
368
|
+
});
|
|
369
|
+
return res.json({
|
|
370
|
+
ok: true,
|
|
371
|
+
targetId: tab.targetId
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
case "evaluate": {
|
|
375
|
+
if (!evaluateEnabled) return jsonError(res, 403, ["act:evaluate is disabled by config (browser.evaluateEnabled=false).", "Docs: /gateway/configuration#browser-anima-managed-browser"].join("\n"));
|
|
376
|
+
const fn = toStringOrEmpty(body.fn);
|
|
377
|
+
if (!fn) return jsonError(res, 400, "fn is required");
|
|
378
|
+
const ref = toStringOrEmpty(body.ref) || void 0;
|
|
379
|
+
const evalTimeoutMs = toNumber(body.timeoutMs);
|
|
380
|
+
const evalRequest = {
|
|
381
|
+
cdpUrl,
|
|
382
|
+
targetId: tab.targetId,
|
|
383
|
+
fn,
|
|
384
|
+
ref,
|
|
385
|
+
signal: req.signal
|
|
386
|
+
};
|
|
387
|
+
if (evalTimeoutMs !== void 0) evalRequest.timeoutMs = evalTimeoutMs;
|
|
388
|
+
const result = await pw.evaluateViaPlaywright(evalRequest);
|
|
389
|
+
return res.json({
|
|
390
|
+
ok: true,
|
|
391
|
+
targetId: tab.targetId,
|
|
392
|
+
url: tab.url,
|
|
393
|
+
result
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
case "close":
|
|
397
|
+
await pw.closePageViaPlaywright({
|
|
398
|
+
cdpUrl,
|
|
399
|
+
targetId: tab.targetId
|
|
400
|
+
});
|
|
401
|
+
return res.json({
|
|
402
|
+
ok: true,
|
|
403
|
+
targetId: tab.targetId
|
|
404
|
+
});
|
|
405
|
+
default: return jsonError(res, 400, "unsupported kind");
|
|
406
|
+
}
|
|
407
|
+
} catch (err) {
|
|
408
|
+
handleRouteError(ctx, res, err);
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
app.post("/hooks/file-chooser", async (req, res) => {
|
|
412
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
413
|
+
if (!profileCtx) return;
|
|
414
|
+
const body = readBody(req);
|
|
415
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
416
|
+
const ref = toStringOrEmpty(body.ref) || void 0;
|
|
417
|
+
const inputRef = toStringOrEmpty(body.inputRef) || void 0;
|
|
418
|
+
const element = toStringOrEmpty(body.element) || void 0;
|
|
419
|
+
const paths = toStringArray(body.paths) ?? [];
|
|
420
|
+
const timeoutMs = toNumber(body.timeoutMs);
|
|
421
|
+
if (!paths.length) return jsonError(res, 400, "paths are required");
|
|
422
|
+
try {
|
|
423
|
+
const uploadPathsResult = resolvePathsWithinRoot({
|
|
424
|
+
rootDir: DEFAULT_UPLOAD_DIR,
|
|
425
|
+
requestedPaths: paths,
|
|
426
|
+
scopeLabel: `uploads directory (${DEFAULT_UPLOAD_DIR})`
|
|
427
|
+
});
|
|
428
|
+
if (!uploadPathsResult.ok) {
|
|
429
|
+
res.status(400).json({ error: uploadPathsResult.error });
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
const resolvedPaths = uploadPathsResult.paths;
|
|
433
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
434
|
+
const pw = await requirePwAi(res, "file chooser hook");
|
|
435
|
+
if (!pw) return;
|
|
436
|
+
if (inputRef || element) {
|
|
437
|
+
if (ref) return jsonError(res, 400, "ref cannot be combined with inputRef/element");
|
|
438
|
+
await pw.setInputFilesViaPlaywright({
|
|
439
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
440
|
+
targetId: tab.targetId,
|
|
441
|
+
inputRef,
|
|
442
|
+
element,
|
|
443
|
+
paths: resolvedPaths
|
|
444
|
+
});
|
|
445
|
+
} else {
|
|
446
|
+
await pw.armFileUploadViaPlaywright({
|
|
447
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
448
|
+
targetId: tab.targetId,
|
|
449
|
+
paths: resolvedPaths,
|
|
450
|
+
timeoutMs: timeoutMs ?? void 0
|
|
451
|
+
});
|
|
452
|
+
if (ref) await pw.clickViaPlaywright({
|
|
453
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
454
|
+
targetId: tab.targetId,
|
|
455
|
+
ref
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
res.json({ ok: true });
|
|
459
|
+
} catch (err) {
|
|
460
|
+
handleRouteError(ctx, res, err);
|
|
461
|
+
}
|
|
462
|
+
});
|
|
463
|
+
app.post("/hooks/dialog", async (req, res) => {
|
|
464
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
465
|
+
if (!profileCtx) return;
|
|
466
|
+
const body = readBody(req);
|
|
467
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
468
|
+
const accept = toBoolean(body.accept);
|
|
469
|
+
const promptText = toStringOrEmpty(body.promptText) || void 0;
|
|
470
|
+
const timeoutMs = toNumber(body.timeoutMs);
|
|
471
|
+
if (accept === void 0) return jsonError(res, 400, "accept is required");
|
|
472
|
+
try {
|
|
473
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
474
|
+
const pw = await requirePwAi(res, "dialog hook");
|
|
475
|
+
if (!pw) return;
|
|
476
|
+
await pw.armDialogViaPlaywright({
|
|
477
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
478
|
+
targetId: tab.targetId,
|
|
479
|
+
accept,
|
|
480
|
+
promptText,
|
|
481
|
+
timeoutMs: timeoutMs ?? void 0
|
|
482
|
+
});
|
|
483
|
+
res.json({ ok: true });
|
|
484
|
+
} catch (err) {
|
|
485
|
+
handleRouteError(ctx, res, err);
|
|
486
|
+
}
|
|
487
|
+
});
|
|
488
|
+
app.post("/wait/download", async (req, res) => {
|
|
489
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
490
|
+
if (!profileCtx) return;
|
|
491
|
+
const body = readBody(req);
|
|
492
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
493
|
+
const out = toStringOrEmpty(body.path) || "";
|
|
494
|
+
const timeoutMs = toNumber(body.timeoutMs);
|
|
495
|
+
try {
|
|
496
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
497
|
+
const pw = await requirePwAi(res, "wait for download");
|
|
498
|
+
if (!pw) return;
|
|
499
|
+
let downloadPath;
|
|
500
|
+
if (out.trim()) {
|
|
501
|
+
const downloadPathResult = resolvePathWithinRoot({
|
|
502
|
+
rootDir: DEFAULT_DOWNLOAD_DIR,
|
|
503
|
+
requestedPath: out,
|
|
504
|
+
scopeLabel: "downloads directory"
|
|
505
|
+
});
|
|
506
|
+
if (!downloadPathResult.ok) {
|
|
507
|
+
res.status(400).json({ error: downloadPathResult.error });
|
|
508
|
+
return;
|
|
509
|
+
}
|
|
510
|
+
downloadPath = downloadPathResult.path;
|
|
511
|
+
}
|
|
512
|
+
const result = await pw.waitForDownloadViaPlaywright({
|
|
513
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
514
|
+
targetId: tab.targetId,
|
|
515
|
+
path: downloadPath,
|
|
516
|
+
timeoutMs: timeoutMs ?? void 0
|
|
517
|
+
});
|
|
518
|
+
res.json({
|
|
519
|
+
ok: true,
|
|
520
|
+
targetId: tab.targetId,
|
|
521
|
+
download: result
|
|
522
|
+
});
|
|
523
|
+
} catch (err) {
|
|
524
|
+
handleRouteError(ctx, res, err);
|
|
525
|
+
}
|
|
526
|
+
});
|
|
527
|
+
app.post("/download", async (req, res) => {
|
|
528
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
529
|
+
if (!profileCtx) return;
|
|
530
|
+
const body = readBody(req);
|
|
531
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
532
|
+
const ref = toStringOrEmpty(body.ref);
|
|
533
|
+
const out = toStringOrEmpty(body.path);
|
|
534
|
+
const timeoutMs = toNumber(body.timeoutMs);
|
|
535
|
+
if (!ref) return jsonError(res, 400, "ref is required");
|
|
536
|
+
if (!out) return jsonError(res, 400, "path is required");
|
|
537
|
+
try {
|
|
538
|
+
const downloadPathResult = resolvePathWithinRoot({
|
|
539
|
+
rootDir: DEFAULT_DOWNLOAD_DIR,
|
|
540
|
+
requestedPath: out,
|
|
541
|
+
scopeLabel: "downloads directory"
|
|
542
|
+
});
|
|
543
|
+
if (!downloadPathResult.ok) {
|
|
544
|
+
res.status(400).json({ error: downloadPathResult.error });
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
547
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
548
|
+
const pw = await requirePwAi(res, "download");
|
|
549
|
+
if (!pw) return;
|
|
550
|
+
const result = await pw.downloadViaPlaywright({
|
|
551
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
552
|
+
targetId: tab.targetId,
|
|
553
|
+
ref,
|
|
554
|
+
path: downloadPathResult.path,
|
|
555
|
+
timeoutMs: timeoutMs ?? void 0
|
|
556
|
+
});
|
|
557
|
+
res.json({
|
|
558
|
+
ok: true,
|
|
559
|
+
targetId: tab.targetId,
|
|
560
|
+
download: result
|
|
561
|
+
});
|
|
562
|
+
} catch (err) {
|
|
563
|
+
handleRouteError(ctx, res, err);
|
|
564
|
+
}
|
|
565
|
+
});
|
|
566
|
+
app.post("/response/body", async (req, res) => {
|
|
567
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
568
|
+
if (!profileCtx) return;
|
|
569
|
+
const body = readBody(req);
|
|
570
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
571
|
+
const url = toStringOrEmpty(body.url);
|
|
572
|
+
const timeoutMs = toNumber(body.timeoutMs);
|
|
573
|
+
const maxChars = toNumber(body.maxChars);
|
|
574
|
+
if (!url) return jsonError(res, 400, "url is required");
|
|
575
|
+
try {
|
|
576
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
577
|
+
const pw = await requirePwAi(res, "response body");
|
|
578
|
+
if (!pw) return;
|
|
579
|
+
const result = await pw.responseBodyViaPlaywright({
|
|
580
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
581
|
+
targetId: tab.targetId,
|
|
582
|
+
url,
|
|
583
|
+
timeoutMs: timeoutMs ?? void 0,
|
|
584
|
+
maxChars: maxChars ?? void 0
|
|
585
|
+
});
|
|
586
|
+
res.json({
|
|
587
|
+
ok: true,
|
|
588
|
+
targetId: tab.targetId,
|
|
589
|
+
response: result
|
|
590
|
+
});
|
|
591
|
+
} catch (err) {
|
|
592
|
+
handleRouteError(ctx, res, err);
|
|
593
|
+
}
|
|
594
|
+
});
|
|
595
|
+
app.post("/highlight", async (req, res) => {
|
|
596
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
597
|
+
if (!profileCtx) return;
|
|
598
|
+
const body = readBody(req);
|
|
599
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
600
|
+
const ref = toStringOrEmpty(body.ref);
|
|
601
|
+
if (!ref) return jsonError(res, 400, "ref is required");
|
|
602
|
+
try {
|
|
603
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
604
|
+
const pw = await requirePwAi(res, "highlight");
|
|
605
|
+
if (!pw) return;
|
|
606
|
+
await pw.highlightViaPlaywright({
|
|
607
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
608
|
+
targetId: tab.targetId,
|
|
609
|
+
ref
|
|
610
|
+
});
|
|
611
|
+
res.json({
|
|
612
|
+
ok: true,
|
|
613
|
+
targetId: tab.targetId
|
|
614
|
+
});
|
|
615
|
+
} catch (err) {
|
|
616
|
+
handleRouteError(ctx, res, err);
|
|
617
|
+
}
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
//#endregion
|
|
622
|
+
//#region src/browser/routes/agent.debug.ts
|
|
623
|
+
function registerBrowserAgentDebugRoutes(app, ctx) {
|
|
624
|
+
app.get("/console", async (req, res) => {
|
|
625
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
626
|
+
if (!profileCtx) return;
|
|
627
|
+
const targetId = typeof req.query.targetId === "string" ? req.query.targetId.trim() : "";
|
|
628
|
+
const level = typeof req.query.level === "string" ? req.query.level : "";
|
|
629
|
+
try {
|
|
630
|
+
const tab = await profileCtx.ensureTabAvailable(targetId || void 0);
|
|
631
|
+
const pw = await requirePwAi(res, "console messages");
|
|
632
|
+
if (!pw) return;
|
|
633
|
+
const messages = await pw.getConsoleMessagesViaPlaywright({
|
|
634
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
635
|
+
targetId: tab.targetId,
|
|
636
|
+
level: level.trim() || void 0
|
|
637
|
+
});
|
|
638
|
+
res.json({
|
|
639
|
+
ok: true,
|
|
640
|
+
messages,
|
|
641
|
+
targetId: tab.targetId
|
|
642
|
+
});
|
|
643
|
+
} catch (err) {
|
|
644
|
+
handleRouteError(ctx, res, err);
|
|
645
|
+
}
|
|
646
|
+
});
|
|
647
|
+
app.get("/errors", async (req, res) => {
|
|
648
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
649
|
+
if (!profileCtx) return;
|
|
650
|
+
const targetId = typeof req.query.targetId === "string" ? req.query.targetId.trim() : "";
|
|
651
|
+
const clear = toBoolean(req.query.clear) ?? false;
|
|
652
|
+
try {
|
|
653
|
+
const tab = await profileCtx.ensureTabAvailable(targetId || void 0);
|
|
654
|
+
const pw = await requirePwAi(res, "page errors");
|
|
655
|
+
if (!pw) return;
|
|
656
|
+
const result = await pw.getPageErrorsViaPlaywright({
|
|
657
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
658
|
+
targetId: tab.targetId,
|
|
659
|
+
clear
|
|
660
|
+
});
|
|
661
|
+
res.json({
|
|
662
|
+
ok: true,
|
|
663
|
+
targetId: tab.targetId,
|
|
664
|
+
...result
|
|
665
|
+
});
|
|
666
|
+
} catch (err) {
|
|
667
|
+
handleRouteError(ctx, res, err);
|
|
668
|
+
}
|
|
669
|
+
});
|
|
670
|
+
app.get("/requests", async (req, res) => {
|
|
671
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
672
|
+
if (!profileCtx) return;
|
|
673
|
+
const targetId = typeof req.query.targetId === "string" ? req.query.targetId.trim() : "";
|
|
674
|
+
const filter = typeof req.query.filter === "string" ? req.query.filter : "";
|
|
675
|
+
const clear = toBoolean(req.query.clear) ?? false;
|
|
676
|
+
try {
|
|
677
|
+
const tab = await profileCtx.ensureTabAvailable(targetId || void 0);
|
|
678
|
+
const pw = await requirePwAi(res, "network requests");
|
|
679
|
+
if (!pw) return;
|
|
680
|
+
const result = await pw.getNetworkRequestsViaPlaywright({
|
|
681
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
682
|
+
targetId: tab.targetId,
|
|
683
|
+
filter: filter.trim() || void 0,
|
|
684
|
+
clear
|
|
685
|
+
});
|
|
686
|
+
res.json({
|
|
687
|
+
ok: true,
|
|
688
|
+
targetId: tab.targetId,
|
|
689
|
+
...result
|
|
690
|
+
});
|
|
691
|
+
} catch (err) {
|
|
692
|
+
handleRouteError(ctx, res, err);
|
|
693
|
+
}
|
|
694
|
+
});
|
|
695
|
+
app.post("/trace/start", async (req, res) => {
|
|
696
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
697
|
+
if (!profileCtx) return;
|
|
698
|
+
const body = readBody(req);
|
|
699
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
700
|
+
const screenshots = toBoolean(body.screenshots) ?? void 0;
|
|
701
|
+
const snapshots = toBoolean(body.snapshots) ?? void 0;
|
|
702
|
+
const sources = toBoolean(body.sources) ?? void 0;
|
|
703
|
+
try {
|
|
704
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
705
|
+
const pw = await requirePwAi(res, "trace start");
|
|
706
|
+
if (!pw) return;
|
|
707
|
+
await pw.traceStartViaPlaywright({
|
|
708
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
709
|
+
targetId: tab.targetId,
|
|
710
|
+
screenshots,
|
|
711
|
+
snapshots,
|
|
712
|
+
sources
|
|
713
|
+
});
|
|
714
|
+
res.json({
|
|
715
|
+
ok: true,
|
|
716
|
+
targetId: tab.targetId
|
|
717
|
+
});
|
|
718
|
+
} catch (err) {
|
|
719
|
+
handleRouteError(ctx, res, err);
|
|
720
|
+
}
|
|
721
|
+
});
|
|
722
|
+
app.post("/trace/stop", async (req, res) => {
|
|
723
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
724
|
+
if (!profileCtx) return;
|
|
725
|
+
const body = readBody(req);
|
|
726
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
727
|
+
const out = toStringOrEmpty(body.path) || "";
|
|
728
|
+
try {
|
|
729
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
730
|
+
const pw = await requirePwAi(res, "trace stop");
|
|
731
|
+
if (!pw) return;
|
|
732
|
+
const id = crypto.randomUUID();
|
|
733
|
+
const dir = DEFAULT_TRACE_DIR;
|
|
734
|
+
await fs$1.mkdir(dir, { recursive: true });
|
|
735
|
+
const tracePathResult = resolvePathWithinRoot({
|
|
736
|
+
rootDir: dir,
|
|
737
|
+
requestedPath: out,
|
|
738
|
+
scopeLabel: "trace directory",
|
|
739
|
+
defaultFileName: `browser-trace-${id}.zip`
|
|
740
|
+
});
|
|
741
|
+
if (!tracePathResult.ok) {
|
|
742
|
+
res.status(400).json({ error: tracePathResult.error });
|
|
743
|
+
return;
|
|
744
|
+
}
|
|
745
|
+
const tracePath = tracePathResult.path;
|
|
746
|
+
await pw.traceStopViaPlaywright({
|
|
747
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
748
|
+
targetId: tab.targetId,
|
|
749
|
+
path: tracePath
|
|
750
|
+
});
|
|
751
|
+
res.json({
|
|
752
|
+
ok: true,
|
|
753
|
+
targetId: tab.targetId,
|
|
754
|
+
path: path.resolve(tracePath)
|
|
755
|
+
});
|
|
756
|
+
} catch (err) {
|
|
757
|
+
handleRouteError(ctx, res, err);
|
|
758
|
+
}
|
|
759
|
+
});
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
//#endregion
|
|
763
|
+
//#region src/media/store.ts
|
|
764
|
+
const resolveMediaDir = () => path.join(resolveConfigDir(), "media");
|
|
765
|
+
const MEDIA_MAX_BYTES = 5 * 1024 * 1024;
|
|
766
|
+
const MAX_BYTES = MEDIA_MAX_BYTES;
|
|
767
|
+
const DEFAULT_TTL_MS = 120 * 1e3;
|
|
768
|
+
/**
|
|
769
|
+
* Sanitize a filename for cross-platform safety.
|
|
770
|
+
* Removes chars unsafe on Windows/SharePoint/all platforms.
|
|
771
|
+
* Keeps: alphanumeric, dots, hyphens, underscores, Unicode letters/numbers.
|
|
772
|
+
*/
|
|
773
|
+
function sanitizeFilename(name) {
|
|
774
|
+
const trimmed = name.trim();
|
|
775
|
+
if (!trimmed) return "";
|
|
776
|
+
return trimmed.replace(/[^\p{L}\p{N}._-]+/gu, "_").replace(/_+/g, "_").replace(/^_|_$/g, "").slice(0, 60);
|
|
777
|
+
}
|
|
778
|
+
function getMediaDir() {
|
|
779
|
+
return resolveMediaDir();
|
|
780
|
+
}
|
|
781
|
+
async function ensureMediaDir() {
|
|
782
|
+
const mediaDir = resolveMediaDir();
|
|
783
|
+
await fs$1.mkdir(mediaDir, {
|
|
784
|
+
recursive: true,
|
|
785
|
+
mode: 448
|
|
786
|
+
});
|
|
787
|
+
return mediaDir;
|
|
788
|
+
}
|
|
789
|
+
async function saveMediaBuffer(buffer, contentType, subdir = "inbound", maxBytes = MAX_BYTES, originalFilename) {
|
|
790
|
+
if (buffer.byteLength > maxBytes) throw new Error(`Media exceeds ${(maxBytes / (1024 * 1024)).toFixed(0)}MB limit`);
|
|
791
|
+
const dir = path.join(resolveMediaDir(), subdir);
|
|
792
|
+
await fs$1.mkdir(dir, {
|
|
793
|
+
recursive: true,
|
|
794
|
+
mode: 448
|
|
795
|
+
});
|
|
796
|
+
const uuid = crypto.randomUUID();
|
|
797
|
+
const headerExt = extensionForMime(contentType?.split(";")[0]?.trim() ?? void 0);
|
|
798
|
+
const mime = await detectMime({
|
|
799
|
+
buffer,
|
|
800
|
+
headerMime: contentType
|
|
801
|
+
});
|
|
802
|
+
const ext = headerExt ?? extensionForMime(mime) ?? "";
|
|
803
|
+
let id;
|
|
804
|
+
if (originalFilename) {
|
|
805
|
+
const base = path.parse(originalFilename).name;
|
|
806
|
+
const sanitized = sanitizeFilename(base);
|
|
807
|
+
id = sanitized ? `${sanitized}---${uuid}${ext}` : `${uuid}${ext}`;
|
|
808
|
+
} else id = ext ? `${uuid}${ext}` : uuid;
|
|
809
|
+
const dest = path.join(dir, id);
|
|
810
|
+
await fs$1.writeFile(dest, buffer, { mode: 384 });
|
|
811
|
+
return {
|
|
812
|
+
id,
|
|
813
|
+
path: dest,
|
|
814
|
+
size: buffer.byteLength,
|
|
815
|
+
contentType: mime
|
|
816
|
+
};
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
//#endregion
|
|
820
|
+
//#region src/browser/screenshot.ts
|
|
821
|
+
const DEFAULT_BROWSER_SCREENSHOT_MAX_SIDE = 2e3;
|
|
822
|
+
const DEFAULT_BROWSER_SCREENSHOT_MAX_BYTES = 5 * 1024 * 1024;
|
|
823
|
+
async function normalizeBrowserScreenshot(buffer, opts) {
|
|
824
|
+
const maxSide = Math.max(1, Math.round(opts?.maxSide ?? DEFAULT_BROWSER_SCREENSHOT_MAX_SIDE));
|
|
825
|
+
const maxBytes = Math.max(1, Math.round(opts?.maxBytes ?? DEFAULT_BROWSER_SCREENSHOT_MAX_BYTES));
|
|
826
|
+
const meta = await getImageMetadata(buffer);
|
|
827
|
+
const width = Number(meta?.width ?? 0);
|
|
828
|
+
const height = Number(meta?.height ?? 0);
|
|
829
|
+
const maxDim = Math.max(width, height);
|
|
830
|
+
if (buffer.byteLength <= maxBytes && (maxDim === 0 || width <= maxSide && height <= maxSide)) return { buffer };
|
|
831
|
+
const qualities = [
|
|
832
|
+
85,
|
|
833
|
+
75,
|
|
834
|
+
65,
|
|
835
|
+
55,
|
|
836
|
+
45,
|
|
837
|
+
35
|
|
838
|
+
];
|
|
839
|
+
const sideGrid = [
|
|
840
|
+
maxDim > 0 ? Math.min(maxSide, maxDim) : maxSide,
|
|
841
|
+
1800,
|
|
842
|
+
1600,
|
|
843
|
+
1400,
|
|
844
|
+
1200,
|
|
845
|
+
1e3,
|
|
846
|
+
800
|
|
847
|
+
].map((v) => Math.min(maxSide, v)).filter((v, i, arr) => v > 0 && arr.indexOf(v) === i).toSorted((a, b) => b - a);
|
|
848
|
+
let smallest = null;
|
|
849
|
+
for (const side of sideGrid) for (const quality of qualities) {
|
|
850
|
+
const out = await resizeToJpeg({
|
|
851
|
+
buffer,
|
|
852
|
+
maxSide: side,
|
|
853
|
+
quality,
|
|
854
|
+
withoutEnlargement: true
|
|
855
|
+
});
|
|
856
|
+
if (!smallest || out.byteLength < smallest.size) smallest = {
|
|
857
|
+
buffer: out,
|
|
858
|
+
size: out.byteLength
|
|
859
|
+
};
|
|
860
|
+
if (out.byteLength <= maxBytes) return {
|
|
861
|
+
buffer: out,
|
|
862
|
+
contentType: "image/jpeg"
|
|
863
|
+
};
|
|
864
|
+
}
|
|
865
|
+
const best = smallest?.buffer ?? buffer;
|
|
866
|
+
throw new Error(`Browser screenshot could not be reduced below ${(maxBytes / (1024 * 1024)).toFixed(0)}MB (got ${(best.byteLength / (1024 * 1024)).toFixed(2)}MB)`);
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
//#endregion
|
|
870
|
+
//#region src/browser/routes/agent.snapshot.ts
|
|
871
|
+
function registerBrowserAgentSnapshotRoutes(app, ctx) {
|
|
872
|
+
app.post("/navigate", async (req, res) => {
|
|
873
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
874
|
+
if (!profileCtx) return;
|
|
875
|
+
const body = readBody(req);
|
|
876
|
+
const url = toStringOrEmpty(body.url);
|
|
877
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
878
|
+
if (!url) return jsonError(res, 400, "url is required");
|
|
879
|
+
try {
|
|
880
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
881
|
+
const pw = await requirePwAi(res, "navigate");
|
|
882
|
+
if (!pw) return;
|
|
883
|
+
const result = await pw.navigateViaPlaywright({
|
|
884
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
885
|
+
targetId: tab.targetId,
|
|
886
|
+
url
|
|
887
|
+
});
|
|
888
|
+
res.json({
|
|
889
|
+
ok: true,
|
|
890
|
+
targetId: tab.targetId,
|
|
891
|
+
...result
|
|
892
|
+
});
|
|
893
|
+
} catch (err) {
|
|
894
|
+
handleRouteError(ctx, res, err);
|
|
895
|
+
}
|
|
896
|
+
});
|
|
897
|
+
app.post("/pdf", async (req, res) => {
|
|
898
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
899
|
+
if (!profileCtx) return;
|
|
900
|
+
const targetId = toStringOrEmpty(readBody(req).targetId) || void 0;
|
|
901
|
+
try {
|
|
902
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
903
|
+
const pw = await requirePwAi(res, "pdf");
|
|
904
|
+
if (!pw) return;
|
|
905
|
+
const pdf = await pw.pdfViaPlaywright({
|
|
906
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
907
|
+
targetId: tab.targetId
|
|
908
|
+
});
|
|
909
|
+
await ensureMediaDir();
|
|
910
|
+
const saved = await saveMediaBuffer(pdf.buffer, "application/pdf", "browser", pdf.buffer.byteLength);
|
|
911
|
+
res.json({
|
|
912
|
+
ok: true,
|
|
913
|
+
path: path.resolve(saved.path),
|
|
914
|
+
targetId: tab.targetId,
|
|
915
|
+
url: tab.url
|
|
916
|
+
});
|
|
917
|
+
} catch (err) {
|
|
918
|
+
handleRouteError(ctx, res, err);
|
|
919
|
+
}
|
|
920
|
+
});
|
|
921
|
+
app.post("/screenshot", async (req, res) => {
|
|
922
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
923
|
+
if (!profileCtx) return;
|
|
924
|
+
const body = readBody(req);
|
|
925
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
926
|
+
const fullPage = toBoolean(body.fullPage) ?? false;
|
|
927
|
+
const ref = toStringOrEmpty(body.ref) || void 0;
|
|
928
|
+
const element = toStringOrEmpty(body.element) || void 0;
|
|
929
|
+
const type = body.type === "jpeg" ? "jpeg" : "png";
|
|
930
|
+
if (fullPage && (ref || element)) return jsonError(res, 400, "fullPage is not supported for element screenshots");
|
|
931
|
+
try {
|
|
932
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
933
|
+
let buffer;
|
|
934
|
+
if (profileCtx.profile.driver === "extension" || !tab.wsUrl || Boolean(ref) || Boolean(element)) {
|
|
935
|
+
const pw = await requirePwAi(res, "screenshot");
|
|
936
|
+
if (!pw) return;
|
|
937
|
+
buffer = (await pw.takeScreenshotViaPlaywright({
|
|
938
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
939
|
+
targetId: tab.targetId,
|
|
940
|
+
ref,
|
|
941
|
+
element,
|
|
942
|
+
fullPage,
|
|
943
|
+
type
|
|
944
|
+
})).buffer;
|
|
945
|
+
} else buffer = await captureScreenshot({
|
|
946
|
+
wsUrl: tab.wsUrl ?? "",
|
|
947
|
+
fullPage,
|
|
948
|
+
format: type,
|
|
949
|
+
quality: type === "jpeg" ? 85 : void 0
|
|
950
|
+
});
|
|
951
|
+
const normalized = await normalizeBrowserScreenshot(buffer, {
|
|
952
|
+
maxSide: DEFAULT_BROWSER_SCREENSHOT_MAX_SIDE,
|
|
953
|
+
maxBytes: DEFAULT_BROWSER_SCREENSHOT_MAX_BYTES
|
|
954
|
+
});
|
|
955
|
+
await ensureMediaDir();
|
|
956
|
+
const saved = await saveMediaBuffer(normalized.buffer, normalized.contentType ?? `image/${type}`, "browser", DEFAULT_BROWSER_SCREENSHOT_MAX_BYTES);
|
|
957
|
+
res.json({
|
|
958
|
+
ok: true,
|
|
959
|
+
path: path.resolve(saved.path),
|
|
960
|
+
targetId: tab.targetId,
|
|
961
|
+
url: tab.url
|
|
962
|
+
});
|
|
963
|
+
} catch (err) {
|
|
964
|
+
handleRouteError(ctx, res, err);
|
|
965
|
+
}
|
|
966
|
+
});
|
|
967
|
+
app.get("/snapshot", async (req, res) => {
|
|
968
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
969
|
+
if (!profileCtx) return;
|
|
970
|
+
const targetId = typeof req.query.targetId === "string" ? req.query.targetId.trim() : "";
|
|
971
|
+
const mode = req.query.mode === "efficient" ? "efficient" : void 0;
|
|
972
|
+
const labels = toBoolean(req.query.labels) ?? void 0;
|
|
973
|
+
const format = (req.query.format === "aria" ? "aria" : req.query.format === "ai" ? "ai" : void 0) ?? (mode ? "ai" : await getPwAiModule() ? "ai" : "aria");
|
|
974
|
+
const limitRaw = typeof req.query.limit === "string" ? Number(req.query.limit) : void 0;
|
|
975
|
+
const hasMaxChars = Object.hasOwn(req.query, "maxChars");
|
|
976
|
+
const maxCharsRaw = typeof req.query.maxChars === "string" ? Number(req.query.maxChars) : void 0;
|
|
977
|
+
const limit = Number.isFinite(limitRaw) ? limitRaw : void 0;
|
|
978
|
+
const resolvedMaxChars = format === "ai" ? hasMaxChars ? typeof maxCharsRaw === "number" && Number.isFinite(maxCharsRaw) && maxCharsRaw > 0 ? Math.floor(maxCharsRaw) : void 0 : mode === "efficient" ? DEFAULT_AI_SNAPSHOT_EFFICIENT_MAX_CHARS : DEFAULT_AI_SNAPSHOT_MAX_CHARS : void 0;
|
|
979
|
+
const interactiveRaw = toBoolean(req.query.interactive);
|
|
980
|
+
const compactRaw = toBoolean(req.query.compact);
|
|
981
|
+
const depthRaw = toNumber(req.query.depth);
|
|
982
|
+
const refsModeRaw = toStringOrEmpty(req.query.refs).trim();
|
|
983
|
+
const refsMode = refsModeRaw === "aria" ? "aria" : refsModeRaw === "role" ? "role" : void 0;
|
|
984
|
+
const interactive = interactiveRaw ?? (mode === "efficient" ? true : void 0);
|
|
985
|
+
const compact = compactRaw ?? (mode === "efficient" ? true : void 0);
|
|
986
|
+
const depth = depthRaw ?? (mode === "efficient" ? DEFAULT_AI_SNAPSHOT_EFFICIENT_DEPTH : void 0);
|
|
987
|
+
const selector = toStringOrEmpty(req.query.selector);
|
|
988
|
+
const frameSelector = toStringOrEmpty(req.query.frame);
|
|
989
|
+
try {
|
|
990
|
+
const tab = await profileCtx.ensureTabAvailable(targetId || void 0);
|
|
991
|
+
if ((labels || mode === "efficient") && format === "aria") return jsonError(res, 400, "labels/mode=efficient require format=ai");
|
|
992
|
+
if (format === "ai") {
|
|
993
|
+
const pw = await requirePwAi(res, "ai snapshot");
|
|
994
|
+
if (!pw) return;
|
|
995
|
+
const snap = labels === true || mode === "efficient" || interactive === true || compact === true || depth !== void 0 || Boolean(selector.trim()) || Boolean(frameSelector.trim()) ? await pw.snapshotRoleViaPlaywright({
|
|
996
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
997
|
+
targetId: tab.targetId,
|
|
998
|
+
selector: selector.trim() || void 0,
|
|
999
|
+
frameSelector: frameSelector.trim() || void 0,
|
|
1000
|
+
refsMode,
|
|
1001
|
+
options: {
|
|
1002
|
+
interactive: interactive ?? void 0,
|
|
1003
|
+
compact: compact ?? void 0,
|
|
1004
|
+
maxDepth: depth ?? void 0
|
|
1005
|
+
}
|
|
1006
|
+
}) : await pw.snapshotAiViaPlaywright({
|
|
1007
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
1008
|
+
targetId: tab.targetId,
|
|
1009
|
+
...typeof resolvedMaxChars === "number" ? { maxChars: resolvedMaxChars } : {}
|
|
1010
|
+
}).catch(async (err) => {
|
|
1011
|
+
if (String(err).toLowerCase().includes("_snapshotforai")) return await pw.snapshotRoleViaPlaywright({
|
|
1012
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
1013
|
+
targetId: tab.targetId,
|
|
1014
|
+
selector: selector.trim() || void 0,
|
|
1015
|
+
frameSelector: frameSelector.trim() || void 0,
|
|
1016
|
+
refsMode,
|
|
1017
|
+
options: {
|
|
1018
|
+
interactive: interactive ?? void 0,
|
|
1019
|
+
compact: compact ?? void 0,
|
|
1020
|
+
maxDepth: depth ?? void 0
|
|
1021
|
+
}
|
|
1022
|
+
});
|
|
1023
|
+
throw err;
|
|
1024
|
+
});
|
|
1025
|
+
if (labels) {
|
|
1026
|
+
const labeled = await pw.screenshotWithLabelsViaPlaywright({
|
|
1027
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
1028
|
+
targetId: tab.targetId,
|
|
1029
|
+
refs: "refs" in snap ? snap.refs : {},
|
|
1030
|
+
type: "png"
|
|
1031
|
+
});
|
|
1032
|
+
const normalized = await normalizeBrowserScreenshot(labeled.buffer, {
|
|
1033
|
+
maxSide: DEFAULT_BROWSER_SCREENSHOT_MAX_SIDE,
|
|
1034
|
+
maxBytes: DEFAULT_BROWSER_SCREENSHOT_MAX_BYTES
|
|
1035
|
+
});
|
|
1036
|
+
await ensureMediaDir();
|
|
1037
|
+
const saved = await saveMediaBuffer(normalized.buffer, normalized.contentType ?? "image/png", "browser", DEFAULT_BROWSER_SCREENSHOT_MAX_BYTES);
|
|
1038
|
+
const imageType = normalized.contentType?.includes("jpeg") ? "jpeg" : "png";
|
|
1039
|
+
return res.json({
|
|
1040
|
+
ok: true,
|
|
1041
|
+
format,
|
|
1042
|
+
targetId: tab.targetId,
|
|
1043
|
+
url: tab.url,
|
|
1044
|
+
labels: true,
|
|
1045
|
+
labelsCount: labeled.labels,
|
|
1046
|
+
labelsSkipped: labeled.skipped,
|
|
1047
|
+
imagePath: path.resolve(saved.path),
|
|
1048
|
+
imageType,
|
|
1049
|
+
...snap
|
|
1050
|
+
});
|
|
1051
|
+
}
|
|
1052
|
+
return res.json({
|
|
1053
|
+
ok: true,
|
|
1054
|
+
format,
|
|
1055
|
+
targetId: tab.targetId,
|
|
1056
|
+
url: tab.url,
|
|
1057
|
+
...snap
|
|
1058
|
+
});
|
|
1059
|
+
}
|
|
1060
|
+
const snap = profileCtx.profile.driver === "extension" || !tab.wsUrl ? requirePwAi(res, "aria snapshot").then(async (pw) => {
|
|
1061
|
+
if (!pw) return null;
|
|
1062
|
+
return await pw.snapshotAriaViaPlaywright({
|
|
1063
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
1064
|
+
targetId: tab.targetId,
|
|
1065
|
+
limit
|
|
1066
|
+
});
|
|
1067
|
+
}) : snapshotAria({
|
|
1068
|
+
wsUrl: tab.wsUrl ?? "",
|
|
1069
|
+
limit
|
|
1070
|
+
});
|
|
1071
|
+
const resolved = await Promise.resolve(snap);
|
|
1072
|
+
if (!resolved) return;
|
|
1073
|
+
return res.json({
|
|
1074
|
+
ok: true,
|
|
1075
|
+
format,
|
|
1076
|
+
targetId: tab.targetId,
|
|
1077
|
+
url: tab.url,
|
|
1078
|
+
...resolved
|
|
1079
|
+
});
|
|
1080
|
+
} catch (err) {
|
|
1081
|
+
handleRouteError(ctx, res, err);
|
|
1082
|
+
}
|
|
1083
|
+
});
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
//#endregion
|
|
1087
|
+
//#region src/browser/routes/agent.storage.ts
|
|
1088
|
+
function registerBrowserAgentStorageRoutes(app, ctx) {
|
|
1089
|
+
app.get("/cookies", async (req, res) => {
|
|
1090
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
1091
|
+
if (!profileCtx) return;
|
|
1092
|
+
const targetId = typeof req.query.targetId === "string" ? req.query.targetId.trim() : "";
|
|
1093
|
+
try {
|
|
1094
|
+
const tab = await profileCtx.ensureTabAvailable(targetId || void 0);
|
|
1095
|
+
const pw = await requirePwAi(res, "cookies");
|
|
1096
|
+
if (!pw) return;
|
|
1097
|
+
const result = await pw.cookiesGetViaPlaywright({
|
|
1098
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
1099
|
+
targetId: tab.targetId
|
|
1100
|
+
});
|
|
1101
|
+
res.json({
|
|
1102
|
+
ok: true,
|
|
1103
|
+
targetId: tab.targetId,
|
|
1104
|
+
...result
|
|
1105
|
+
});
|
|
1106
|
+
} catch (err) {
|
|
1107
|
+
handleRouteError(ctx, res, err);
|
|
1108
|
+
}
|
|
1109
|
+
});
|
|
1110
|
+
app.post("/cookies/set", async (req, res) => {
|
|
1111
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
1112
|
+
if (!profileCtx) return;
|
|
1113
|
+
const body = readBody(req);
|
|
1114
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
1115
|
+
const cookie = body.cookie && typeof body.cookie === "object" && !Array.isArray(body.cookie) ? body.cookie : null;
|
|
1116
|
+
if (!cookie) return jsonError(res, 400, "cookie is required");
|
|
1117
|
+
try {
|
|
1118
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
1119
|
+
const pw = await requirePwAi(res, "cookies set");
|
|
1120
|
+
if (!pw) return;
|
|
1121
|
+
await pw.cookiesSetViaPlaywright({
|
|
1122
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
1123
|
+
targetId: tab.targetId,
|
|
1124
|
+
cookie: {
|
|
1125
|
+
name: toStringOrEmpty(cookie.name),
|
|
1126
|
+
value: toStringOrEmpty(cookie.value),
|
|
1127
|
+
url: toStringOrEmpty(cookie.url) || void 0,
|
|
1128
|
+
domain: toStringOrEmpty(cookie.domain) || void 0,
|
|
1129
|
+
path: toStringOrEmpty(cookie.path) || void 0,
|
|
1130
|
+
expires: toNumber(cookie.expires) ?? void 0,
|
|
1131
|
+
httpOnly: toBoolean(cookie.httpOnly) ?? void 0,
|
|
1132
|
+
secure: toBoolean(cookie.secure) ?? void 0,
|
|
1133
|
+
sameSite: cookie.sameSite === "Lax" || cookie.sameSite === "None" || cookie.sameSite === "Strict" ? cookie.sameSite : void 0
|
|
1134
|
+
}
|
|
1135
|
+
});
|
|
1136
|
+
res.json({
|
|
1137
|
+
ok: true,
|
|
1138
|
+
targetId: tab.targetId
|
|
1139
|
+
});
|
|
1140
|
+
} catch (err) {
|
|
1141
|
+
handleRouteError(ctx, res, err);
|
|
1142
|
+
}
|
|
1143
|
+
});
|
|
1144
|
+
app.post("/cookies/clear", async (req, res) => {
|
|
1145
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
1146
|
+
if (!profileCtx) return;
|
|
1147
|
+
const targetId = toStringOrEmpty(readBody(req).targetId) || void 0;
|
|
1148
|
+
try {
|
|
1149
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
1150
|
+
const pw = await requirePwAi(res, "cookies clear");
|
|
1151
|
+
if (!pw) return;
|
|
1152
|
+
await pw.cookiesClearViaPlaywright({
|
|
1153
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
1154
|
+
targetId: tab.targetId
|
|
1155
|
+
});
|
|
1156
|
+
res.json({
|
|
1157
|
+
ok: true,
|
|
1158
|
+
targetId: tab.targetId
|
|
1159
|
+
});
|
|
1160
|
+
} catch (err) {
|
|
1161
|
+
handleRouteError(ctx, res, err);
|
|
1162
|
+
}
|
|
1163
|
+
});
|
|
1164
|
+
app.get("/storage/:kind", async (req, res) => {
|
|
1165
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
1166
|
+
if (!profileCtx) return;
|
|
1167
|
+
const kind = toStringOrEmpty(req.params.kind);
|
|
1168
|
+
if (kind !== "local" && kind !== "session") return jsonError(res, 400, "kind must be local|session");
|
|
1169
|
+
const targetId = typeof req.query.targetId === "string" ? req.query.targetId.trim() : "";
|
|
1170
|
+
const key = typeof req.query.key === "string" ? req.query.key : "";
|
|
1171
|
+
try {
|
|
1172
|
+
const tab = await profileCtx.ensureTabAvailable(targetId || void 0);
|
|
1173
|
+
const pw = await requirePwAi(res, "storage get");
|
|
1174
|
+
if (!pw) return;
|
|
1175
|
+
const result = await pw.storageGetViaPlaywright({
|
|
1176
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
1177
|
+
targetId: tab.targetId,
|
|
1178
|
+
kind,
|
|
1179
|
+
key: key.trim() || void 0
|
|
1180
|
+
});
|
|
1181
|
+
res.json({
|
|
1182
|
+
ok: true,
|
|
1183
|
+
targetId: tab.targetId,
|
|
1184
|
+
...result
|
|
1185
|
+
});
|
|
1186
|
+
} catch (err) {
|
|
1187
|
+
handleRouteError(ctx, res, err);
|
|
1188
|
+
}
|
|
1189
|
+
});
|
|
1190
|
+
app.post("/storage/:kind/set", async (req, res) => {
|
|
1191
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
1192
|
+
if (!profileCtx) return;
|
|
1193
|
+
const kind = toStringOrEmpty(req.params.kind);
|
|
1194
|
+
if (kind !== "local" && kind !== "session") return jsonError(res, 400, "kind must be local|session");
|
|
1195
|
+
const body = readBody(req);
|
|
1196
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
1197
|
+
const key = toStringOrEmpty(body.key);
|
|
1198
|
+
if (!key) return jsonError(res, 400, "key is required");
|
|
1199
|
+
const value = typeof body.value === "string" ? body.value : "";
|
|
1200
|
+
try {
|
|
1201
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
1202
|
+
const pw = await requirePwAi(res, "storage set");
|
|
1203
|
+
if (!pw) return;
|
|
1204
|
+
await pw.storageSetViaPlaywright({
|
|
1205
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
1206
|
+
targetId: tab.targetId,
|
|
1207
|
+
kind,
|
|
1208
|
+
key,
|
|
1209
|
+
value
|
|
1210
|
+
});
|
|
1211
|
+
res.json({
|
|
1212
|
+
ok: true,
|
|
1213
|
+
targetId: tab.targetId
|
|
1214
|
+
});
|
|
1215
|
+
} catch (err) {
|
|
1216
|
+
handleRouteError(ctx, res, err);
|
|
1217
|
+
}
|
|
1218
|
+
});
|
|
1219
|
+
app.post("/storage/:kind/clear", async (req, res) => {
|
|
1220
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
1221
|
+
if (!profileCtx) return;
|
|
1222
|
+
const kind = toStringOrEmpty(req.params.kind);
|
|
1223
|
+
if (kind !== "local" && kind !== "session") return jsonError(res, 400, "kind must be local|session");
|
|
1224
|
+
const targetId = toStringOrEmpty(readBody(req).targetId) || void 0;
|
|
1225
|
+
try {
|
|
1226
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
1227
|
+
const pw = await requirePwAi(res, "storage clear");
|
|
1228
|
+
if (!pw) return;
|
|
1229
|
+
await pw.storageClearViaPlaywright({
|
|
1230
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
1231
|
+
targetId: tab.targetId,
|
|
1232
|
+
kind
|
|
1233
|
+
});
|
|
1234
|
+
res.json({
|
|
1235
|
+
ok: true,
|
|
1236
|
+
targetId: tab.targetId
|
|
1237
|
+
});
|
|
1238
|
+
} catch (err) {
|
|
1239
|
+
handleRouteError(ctx, res, err);
|
|
1240
|
+
}
|
|
1241
|
+
});
|
|
1242
|
+
app.post("/set/offline", async (req, res) => {
|
|
1243
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
1244
|
+
if (!profileCtx) return;
|
|
1245
|
+
const body = readBody(req);
|
|
1246
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
1247
|
+
const offline = toBoolean(body.offline);
|
|
1248
|
+
if (offline === void 0) return jsonError(res, 400, "offline is required");
|
|
1249
|
+
try {
|
|
1250
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
1251
|
+
const pw = await requirePwAi(res, "offline");
|
|
1252
|
+
if (!pw) return;
|
|
1253
|
+
await pw.setOfflineViaPlaywright({
|
|
1254
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
1255
|
+
targetId: tab.targetId,
|
|
1256
|
+
offline
|
|
1257
|
+
});
|
|
1258
|
+
res.json({
|
|
1259
|
+
ok: true,
|
|
1260
|
+
targetId: tab.targetId
|
|
1261
|
+
});
|
|
1262
|
+
} catch (err) {
|
|
1263
|
+
handleRouteError(ctx, res, err);
|
|
1264
|
+
}
|
|
1265
|
+
});
|
|
1266
|
+
app.post("/set/headers", async (req, res) => {
|
|
1267
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
1268
|
+
if (!profileCtx) return;
|
|
1269
|
+
const body = readBody(req);
|
|
1270
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
1271
|
+
const headers = body.headers && typeof body.headers === "object" && !Array.isArray(body.headers) ? body.headers : null;
|
|
1272
|
+
if (!headers) return jsonError(res, 400, "headers is required");
|
|
1273
|
+
const parsed = {};
|
|
1274
|
+
for (const [k, v] of Object.entries(headers)) if (typeof v === "string") parsed[k] = v;
|
|
1275
|
+
try {
|
|
1276
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
1277
|
+
const pw = await requirePwAi(res, "headers");
|
|
1278
|
+
if (!pw) return;
|
|
1279
|
+
await pw.setExtraHTTPHeadersViaPlaywright({
|
|
1280
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
1281
|
+
targetId: tab.targetId,
|
|
1282
|
+
headers: parsed
|
|
1283
|
+
});
|
|
1284
|
+
res.json({
|
|
1285
|
+
ok: true,
|
|
1286
|
+
targetId: tab.targetId
|
|
1287
|
+
});
|
|
1288
|
+
} catch (err) {
|
|
1289
|
+
handleRouteError(ctx, res, err);
|
|
1290
|
+
}
|
|
1291
|
+
});
|
|
1292
|
+
app.post("/set/credentials", async (req, res) => {
|
|
1293
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
1294
|
+
if (!profileCtx) return;
|
|
1295
|
+
const body = readBody(req);
|
|
1296
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
1297
|
+
const clear = toBoolean(body.clear) ?? false;
|
|
1298
|
+
const username = toStringOrEmpty(body.username) || void 0;
|
|
1299
|
+
const password = typeof body.password === "string" ? body.password : void 0;
|
|
1300
|
+
try {
|
|
1301
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
1302
|
+
const pw = await requirePwAi(res, "http credentials");
|
|
1303
|
+
if (!pw) return;
|
|
1304
|
+
await pw.setHttpCredentialsViaPlaywright({
|
|
1305
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
1306
|
+
targetId: tab.targetId,
|
|
1307
|
+
username,
|
|
1308
|
+
password,
|
|
1309
|
+
clear
|
|
1310
|
+
});
|
|
1311
|
+
res.json({
|
|
1312
|
+
ok: true,
|
|
1313
|
+
targetId: tab.targetId
|
|
1314
|
+
});
|
|
1315
|
+
} catch (err) {
|
|
1316
|
+
handleRouteError(ctx, res, err);
|
|
1317
|
+
}
|
|
1318
|
+
});
|
|
1319
|
+
app.post("/set/geolocation", async (req, res) => {
|
|
1320
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
1321
|
+
if (!profileCtx) return;
|
|
1322
|
+
const body = readBody(req);
|
|
1323
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
1324
|
+
const clear = toBoolean(body.clear) ?? false;
|
|
1325
|
+
const latitude = toNumber(body.latitude);
|
|
1326
|
+
const longitude = toNumber(body.longitude);
|
|
1327
|
+
const accuracy = toNumber(body.accuracy) ?? void 0;
|
|
1328
|
+
const origin = toStringOrEmpty(body.origin) || void 0;
|
|
1329
|
+
try {
|
|
1330
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
1331
|
+
const pw = await requirePwAi(res, "geolocation");
|
|
1332
|
+
if (!pw) return;
|
|
1333
|
+
await pw.setGeolocationViaPlaywright({
|
|
1334
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
1335
|
+
targetId: tab.targetId,
|
|
1336
|
+
latitude,
|
|
1337
|
+
longitude,
|
|
1338
|
+
accuracy,
|
|
1339
|
+
origin,
|
|
1340
|
+
clear
|
|
1341
|
+
});
|
|
1342
|
+
res.json({
|
|
1343
|
+
ok: true,
|
|
1344
|
+
targetId: tab.targetId
|
|
1345
|
+
});
|
|
1346
|
+
} catch (err) {
|
|
1347
|
+
handleRouteError(ctx, res, err);
|
|
1348
|
+
}
|
|
1349
|
+
});
|
|
1350
|
+
app.post("/set/media", async (req, res) => {
|
|
1351
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
1352
|
+
if (!profileCtx) return;
|
|
1353
|
+
const body = readBody(req);
|
|
1354
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
1355
|
+
const schemeRaw = toStringOrEmpty(body.colorScheme);
|
|
1356
|
+
const colorScheme = schemeRaw === "dark" || schemeRaw === "light" || schemeRaw === "no-preference" ? schemeRaw : schemeRaw === "none" ? null : void 0;
|
|
1357
|
+
if (colorScheme === void 0) return jsonError(res, 400, "colorScheme must be dark|light|no-preference|none");
|
|
1358
|
+
try {
|
|
1359
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
1360
|
+
const pw = await requirePwAi(res, "media emulation");
|
|
1361
|
+
if (!pw) return;
|
|
1362
|
+
await pw.emulateMediaViaPlaywright({
|
|
1363
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
1364
|
+
targetId: tab.targetId,
|
|
1365
|
+
colorScheme
|
|
1366
|
+
});
|
|
1367
|
+
res.json({
|
|
1368
|
+
ok: true,
|
|
1369
|
+
targetId: tab.targetId
|
|
1370
|
+
});
|
|
1371
|
+
} catch (err) {
|
|
1372
|
+
handleRouteError(ctx, res, err);
|
|
1373
|
+
}
|
|
1374
|
+
});
|
|
1375
|
+
app.post("/set/timezone", async (req, res) => {
|
|
1376
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
1377
|
+
if (!profileCtx) return;
|
|
1378
|
+
const body = readBody(req);
|
|
1379
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
1380
|
+
const timezoneId = toStringOrEmpty(body.timezoneId);
|
|
1381
|
+
if (!timezoneId) return jsonError(res, 400, "timezoneId is required");
|
|
1382
|
+
try {
|
|
1383
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
1384
|
+
const pw = await requirePwAi(res, "timezone");
|
|
1385
|
+
if (!pw) return;
|
|
1386
|
+
await pw.setTimezoneViaPlaywright({
|
|
1387
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
1388
|
+
targetId: tab.targetId,
|
|
1389
|
+
timezoneId
|
|
1390
|
+
});
|
|
1391
|
+
res.json({
|
|
1392
|
+
ok: true,
|
|
1393
|
+
targetId: tab.targetId
|
|
1394
|
+
});
|
|
1395
|
+
} catch (err) {
|
|
1396
|
+
handleRouteError(ctx, res, err);
|
|
1397
|
+
}
|
|
1398
|
+
});
|
|
1399
|
+
app.post("/set/locale", async (req, res) => {
|
|
1400
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
1401
|
+
if (!profileCtx) return;
|
|
1402
|
+
const body = readBody(req);
|
|
1403
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
1404
|
+
const locale = toStringOrEmpty(body.locale);
|
|
1405
|
+
if (!locale) return jsonError(res, 400, "locale is required");
|
|
1406
|
+
try {
|
|
1407
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
1408
|
+
const pw = await requirePwAi(res, "locale");
|
|
1409
|
+
if (!pw) return;
|
|
1410
|
+
await pw.setLocaleViaPlaywright({
|
|
1411
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
1412
|
+
targetId: tab.targetId,
|
|
1413
|
+
locale
|
|
1414
|
+
});
|
|
1415
|
+
res.json({
|
|
1416
|
+
ok: true,
|
|
1417
|
+
targetId: tab.targetId
|
|
1418
|
+
});
|
|
1419
|
+
} catch (err) {
|
|
1420
|
+
handleRouteError(ctx, res, err);
|
|
1421
|
+
}
|
|
1422
|
+
});
|
|
1423
|
+
app.post("/set/device", async (req, res) => {
|
|
1424
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
1425
|
+
if (!profileCtx) return;
|
|
1426
|
+
const body = readBody(req);
|
|
1427
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
1428
|
+
const name = toStringOrEmpty(body.name);
|
|
1429
|
+
if (!name) return jsonError(res, 400, "name is required");
|
|
1430
|
+
try {
|
|
1431
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
1432
|
+
const pw = await requirePwAi(res, "device emulation");
|
|
1433
|
+
if (!pw) return;
|
|
1434
|
+
await pw.setDeviceViaPlaywright({
|
|
1435
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
1436
|
+
targetId: tab.targetId,
|
|
1437
|
+
name
|
|
1438
|
+
});
|
|
1439
|
+
res.json({
|
|
1440
|
+
ok: true,
|
|
1441
|
+
targetId: tab.targetId
|
|
1442
|
+
});
|
|
1443
|
+
} catch (err) {
|
|
1444
|
+
handleRouteError(ctx, res, err);
|
|
1445
|
+
}
|
|
1446
|
+
});
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
//#endregion
|
|
1450
|
+
//#region src/browser/routes/agent.ts
|
|
1451
|
+
function registerBrowserAgentRoutes(app, ctx) {
|
|
1452
|
+
registerBrowserAgentSnapshotRoutes(app, ctx);
|
|
1453
|
+
registerBrowserAgentActRoutes(app, ctx);
|
|
1454
|
+
registerBrowserAgentDebugRoutes(app, ctx);
|
|
1455
|
+
registerBrowserAgentStorageRoutes(app, ctx);
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
//#endregion
|
|
1459
|
+
//#region src/browser/profiles-service.ts
|
|
1460
|
+
const HEX_COLOR_RE = /^#[0-9A-Fa-f]{6}$/;
|
|
1461
|
+
function createBrowserProfilesService(ctx) {
|
|
1462
|
+
const listProfiles = async () => {
|
|
1463
|
+
return await ctx.listProfiles();
|
|
1464
|
+
};
|
|
1465
|
+
const createProfile = async (params) => {
|
|
1466
|
+
const name = params.name.trim();
|
|
1467
|
+
const rawCdpUrl = params.cdpUrl?.trim() || void 0;
|
|
1468
|
+
const driver = params.driver === "extension" ? "extension" : void 0;
|
|
1469
|
+
if (!isValidProfileName(name)) throw new Error("invalid profile name: use lowercase letters, numbers, and hyphens only");
|
|
1470
|
+
const state = ctx.state();
|
|
1471
|
+
const resolvedProfiles = state.resolved.profiles;
|
|
1472
|
+
if (name in resolvedProfiles) throw new Error(`profile "${name}" already exists`);
|
|
1473
|
+
const cfg = loadConfig();
|
|
1474
|
+
const rawProfiles = cfg.browser?.profiles ?? {};
|
|
1475
|
+
if (name in rawProfiles) throw new Error(`profile "${name}" already exists`);
|
|
1476
|
+
const usedColors = getUsedColors(resolvedProfiles);
|
|
1477
|
+
const profileColor = params.color && HEX_COLOR_RE.test(params.color) ? params.color : allocateColor(usedColors);
|
|
1478
|
+
let profileConfig;
|
|
1479
|
+
if (rawCdpUrl) profileConfig = {
|
|
1480
|
+
cdpUrl: parseHttpUrl(rawCdpUrl, "browser.profiles.cdpUrl").normalized,
|
|
1481
|
+
...driver ? { driver } : {},
|
|
1482
|
+
color: profileColor
|
|
1483
|
+
};
|
|
1484
|
+
else {
|
|
1485
|
+
const cdpPort = allocateCdpPort(getUsedPorts(resolvedProfiles), deriveDefaultBrowserCdpPortRange(state.resolved.controlPort));
|
|
1486
|
+
if (cdpPort === null) throw new Error("no available CDP ports in range");
|
|
1487
|
+
profileConfig = {
|
|
1488
|
+
cdpPort,
|
|
1489
|
+
...driver ? { driver } : {},
|
|
1490
|
+
color: profileColor
|
|
1491
|
+
};
|
|
1492
|
+
}
|
|
1493
|
+
await writeConfigFile({
|
|
1494
|
+
...cfg,
|
|
1495
|
+
browser: {
|
|
1496
|
+
...cfg.browser,
|
|
1497
|
+
profiles: {
|
|
1498
|
+
...rawProfiles,
|
|
1499
|
+
[name]: profileConfig
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
});
|
|
1503
|
+
state.resolved.profiles[name] = profileConfig;
|
|
1504
|
+
const resolved = resolveProfile(state.resolved, name);
|
|
1505
|
+
if (!resolved) throw new Error(`profile "${name}" not found after creation`);
|
|
1506
|
+
return {
|
|
1507
|
+
ok: true,
|
|
1508
|
+
profile: name,
|
|
1509
|
+
cdpPort: resolved.cdpPort,
|
|
1510
|
+
cdpUrl: resolved.cdpUrl,
|
|
1511
|
+
color: resolved.color,
|
|
1512
|
+
isRemote: !resolved.cdpIsLoopback
|
|
1513
|
+
};
|
|
1514
|
+
};
|
|
1515
|
+
const deleteProfile = async (nameRaw) => {
|
|
1516
|
+
const name = nameRaw.trim();
|
|
1517
|
+
if (!name) throw new Error("profile name is required");
|
|
1518
|
+
if (!isValidProfileName(name)) throw new Error("invalid profile name");
|
|
1519
|
+
const cfg = loadConfig();
|
|
1520
|
+
const profiles = cfg.browser?.profiles ?? {};
|
|
1521
|
+
if (!(name in profiles)) throw new Error(`profile "${name}" not found`);
|
|
1522
|
+
if (name === (cfg.browser?.defaultProfile ?? DEFAULT_BROWSER_DEFAULT_PROFILE_NAME)) throw new Error(`cannot delete the default profile "${name}"; change browser.defaultProfile first`);
|
|
1523
|
+
let deleted = false;
|
|
1524
|
+
const state = ctx.state();
|
|
1525
|
+
if (resolveProfile(state.resolved, name)?.cdpIsLoopback) {
|
|
1526
|
+
try {
|
|
1527
|
+
await ctx.forProfile(name).stopRunningBrowser();
|
|
1528
|
+
} catch {}
|
|
1529
|
+
const userDataDir = resolveAnimaUserDataDir(name);
|
|
1530
|
+
const profileDir = path.dirname(userDataDir);
|
|
1531
|
+
if (fs.existsSync(profileDir)) {
|
|
1532
|
+
await movePathToTrash(profileDir);
|
|
1533
|
+
deleted = true;
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
const { [name]: _removed, ...remainingProfiles } = profiles;
|
|
1537
|
+
await writeConfigFile({
|
|
1538
|
+
...cfg,
|
|
1539
|
+
browser: {
|
|
1540
|
+
...cfg.browser,
|
|
1541
|
+
profiles: remainingProfiles
|
|
1542
|
+
}
|
|
1543
|
+
});
|
|
1544
|
+
delete state.resolved.profiles[name];
|
|
1545
|
+
state.profiles.delete(name);
|
|
1546
|
+
return {
|
|
1547
|
+
ok: true,
|
|
1548
|
+
profile: name,
|
|
1549
|
+
deleted
|
|
1550
|
+
};
|
|
1551
|
+
};
|
|
1552
|
+
return {
|
|
1553
|
+
listProfiles,
|
|
1554
|
+
createProfile,
|
|
1555
|
+
deleteProfile
|
|
1556
|
+
};
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
//#endregion
|
|
1560
|
+
//#region src/browser/routes/basic.ts
|
|
1561
|
+
function registerBrowserBasicRoutes(app, ctx) {
|
|
1562
|
+
app.get("/profiles", async (_req, res) => {
|
|
1563
|
+
try {
|
|
1564
|
+
const profiles = await createBrowserProfilesService(ctx).listProfiles();
|
|
1565
|
+
res.json({ profiles });
|
|
1566
|
+
} catch (err) {
|
|
1567
|
+
jsonError(res, 500, String(err));
|
|
1568
|
+
}
|
|
1569
|
+
});
|
|
1570
|
+
app.get("/", async (req, res) => {
|
|
1571
|
+
let current;
|
|
1572
|
+
try {
|
|
1573
|
+
current = ctx.state();
|
|
1574
|
+
} catch {
|
|
1575
|
+
return jsonError(res, 503, "browser server not started");
|
|
1576
|
+
}
|
|
1577
|
+
const profileCtx = getProfileContext(req, ctx);
|
|
1578
|
+
if ("error" in profileCtx) return jsonError(res, profileCtx.status, profileCtx.error);
|
|
1579
|
+
const [cdpHttp, cdpReady] = await Promise.all([profileCtx.isHttpReachable(300), profileCtx.isReachable(600)]);
|
|
1580
|
+
const profileState = current.profiles.get(profileCtx.profile.name);
|
|
1581
|
+
let detectedBrowser = null;
|
|
1582
|
+
let detectedExecutablePath = null;
|
|
1583
|
+
let detectError = null;
|
|
1584
|
+
try {
|
|
1585
|
+
const detected = resolveBrowserExecutableForPlatform(current.resolved, process.platform);
|
|
1586
|
+
if (detected) {
|
|
1587
|
+
detectedBrowser = detected.kind;
|
|
1588
|
+
detectedExecutablePath = detected.path;
|
|
1589
|
+
}
|
|
1590
|
+
} catch (err) {
|
|
1591
|
+
detectError = String(err);
|
|
1592
|
+
}
|
|
1593
|
+
res.json({
|
|
1594
|
+
enabled: current.resolved.enabled,
|
|
1595
|
+
profile: profileCtx.profile.name,
|
|
1596
|
+
running: cdpReady,
|
|
1597
|
+
cdpReady,
|
|
1598
|
+
cdpHttp,
|
|
1599
|
+
pid: profileState?.running?.pid ?? null,
|
|
1600
|
+
cdpPort: profileCtx.profile.cdpPort,
|
|
1601
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
1602
|
+
chosenBrowser: profileState?.running?.exe.kind ?? null,
|
|
1603
|
+
detectedBrowser,
|
|
1604
|
+
detectedExecutablePath,
|
|
1605
|
+
detectError,
|
|
1606
|
+
userDataDir: profileState?.running?.userDataDir ?? null,
|
|
1607
|
+
color: profileCtx.profile.color,
|
|
1608
|
+
headless: current.resolved.headless,
|
|
1609
|
+
noSandbox: current.resolved.noSandbox,
|
|
1610
|
+
executablePath: current.resolved.executablePath ?? null,
|
|
1611
|
+
attachOnly: current.resolved.attachOnly
|
|
1612
|
+
});
|
|
1613
|
+
});
|
|
1614
|
+
app.post("/start", async (req, res) => {
|
|
1615
|
+
const profileCtx = getProfileContext(req, ctx);
|
|
1616
|
+
if ("error" in profileCtx) return jsonError(res, profileCtx.status, profileCtx.error);
|
|
1617
|
+
try {
|
|
1618
|
+
await profileCtx.ensureBrowserAvailable();
|
|
1619
|
+
res.json({
|
|
1620
|
+
ok: true,
|
|
1621
|
+
profile: profileCtx.profile.name
|
|
1622
|
+
});
|
|
1623
|
+
} catch (err) {
|
|
1624
|
+
jsonError(res, 500, String(err));
|
|
1625
|
+
}
|
|
1626
|
+
});
|
|
1627
|
+
app.post("/stop", async (req, res) => {
|
|
1628
|
+
const profileCtx = getProfileContext(req, ctx);
|
|
1629
|
+
if ("error" in profileCtx) return jsonError(res, profileCtx.status, profileCtx.error);
|
|
1630
|
+
try {
|
|
1631
|
+
const result = await profileCtx.stopRunningBrowser();
|
|
1632
|
+
res.json({
|
|
1633
|
+
ok: true,
|
|
1634
|
+
stopped: result.stopped,
|
|
1635
|
+
profile: profileCtx.profile.name
|
|
1636
|
+
});
|
|
1637
|
+
} catch (err) {
|
|
1638
|
+
jsonError(res, 500, String(err));
|
|
1639
|
+
}
|
|
1640
|
+
});
|
|
1641
|
+
app.post("/reset-profile", async (req, res) => {
|
|
1642
|
+
const profileCtx = getProfileContext(req, ctx);
|
|
1643
|
+
if ("error" in profileCtx) return jsonError(res, profileCtx.status, profileCtx.error);
|
|
1644
|
+
try {
|
|
1645
|
+
const result = await profileCtx.resetProfile();
|
|
1646
|
+
res.json({
|
|
1647
|
+
ok: true,
|
|
1648
|
+
profile: profileCtx.profile.name,
|
|
1649
|
+
...result
|
|
1650
|
+
});
|
|
1651
|
+
} catch (err) {
|
|
1652
|
+
jsonError(res, 500, String(err));
|
|
1653
|
+
}
|
|
1654
|
+
});
|
|
1655
|
+
app.post("/profiles/create", async (req, res) => {
|
|
1656
|
+
const name = toStringOrEmpty(req.body?.name);
|
|
1657
|
+
const color = toStringOrEmpty(req.body?.color);
|
|
1658
|
+
const cdpUrl = toStringOrEmpty(req.body?.cdpUrl);
|
|
1659
|
+
const driver = toStringOrEmpty(req.body?.driver);
|
|
1660
|
+
if (!name) return jsonError(res, 400, "name is required");
|
|
1661
|
+
try {
|
|
1662
|
+
const result = await createBrowserProfilesService(ctx).createProfile({
|
|
1663
|
+
name,
|
|
1664
|
+
color: color || void 0,
|
|
1665
|
+
cdpUrl: cdpUrl || void 0,
|
|
1666
|
+
driver: driver === "extension" ? "extension" : void 0
|
|
1667
|
+
});
|
|
1668
|
+
res.json(result);
|
|
1669
|
+
} catch (err) {
|
|
1670
|
+
const msg = String(err);
|
|
1671
|
+
if (msg.includes("already exists")) return jsonError(res, 409, msg);
|
|
1672
|
+
if (msg.includes("invalid profile name")) return jsonError(res, 400, msg);
|
|
1673
|
+
if (msg.includes("no available CDP ports")) return jsonError(res, 507, msg);
|
|
1674
|
+
if (msg.includes("cdpUrl")) return jsonError(res, 400, msg);
|
|
1675
|
+
jsonError(res, 500, msg);
|
|
1676
|
+
}
|
|
1677
|
+
});
|
|
1678
|
+
app.delete("/profiles/:name", async (req, res) => {
|
|
1679
|
+
const name = toStringOrEmpty(req.params.name);
|
|
1680
|
+
if (!name) return jsonError(res, 400, "profile name is required");
|
|
1681
|
+
try {
|
|
1682
|
+
const result = await createBrowserProfilesService(ctx).deleteProfile(name);
|
|
1683
|
+
res.json(result);
|
|
1684
|
+
} catch (err) {
|
|
1685
|
+
const msg = String(err);
|
|
1686
|
+
if (msg.includes("invalid profile name")) return jsonError(res, 400, msg);
|
|
1687
|
+
if (msg.includes("default profile")) return jsonError(res, 400, msg);
|
|
1688
|
+
if (msg.includes("not found")) return jsonError(res, 404, msg);
|
|
1689
|
+
jsonError(res, 500, msg);
|
|
1690
|
+
}
|
|
1691
|
+
});
|
|
1692
|
+
}
|
|
1693
|
+
|
|
1694
|
+
//#endregion
|
|
1695
|
+
//#region src/browser/routes/tabs.ts
|
|
1696
|
+
function registerBrowserTabRoutes(app, ctx) {
|
|
1697
|
+
app.get("/tabs", async (req, res) => {
|
|
1698
|
+
const profileCtx = getProfileContext(req, ctx);
|
|
1699
|
+
if ("error" in profileCtx) return jsonError(res, profileCtx.status, profileCtx.error);
|
|
1700
|
+
try {
|
|
1701
|
+
if (!await profileCtx.isReachable(300)) return res.json({
|
|
1702
|
+
running: false,
|
|
1703
|
+
tabs: []
|
|
1704
|
+
});
|
|
1705
|
+
const tabs = await profileCtx.listTabs();
|
|
1706
|
+
res.json({
|
|
1707
|
+
running: true,
|
|
1708
|
+
tabs
|
|
1709
|
+
});
|
|
1710
|
+
} catch (err) {
|
|
1711
|
+
jsonError(res, 500, String(err));
|
|
1712
|
+
}
|
|
1713
|
+
});
|
|
1714
|
+
app.post("/tabs/open", async (req, res) => {
|
|
1715
|
+
const profileCtx = getProfileContext(req, ctx);
|
|
1716
|
+
if ("error" in profileCtx) return jsonError(res, profileCtx.status, profileCtx.error);
|
|
1717
|
+
const url = toStringOrEmpty(req.body?.url);
|
|
1718
|
+
if (!url) return jsonError(res, 400, "url is required");
|
|
1719
|
+
try {
|
|
1720
|
+
await profileCtx.ensureBrowserAvailable();
|
|
1721
|
+
const tab = await profileCtx.openTab(url);
|
|
1722
|
+
res.json(tab);
|
|
1723
|
+
} catch (err) {
|
|
1724
|
+
jsonError(res, 500, String(err));
|
|
1725
|
+
}
|
|
1726
|
+
});
|
|
1727
|
+
app.post("/tabs/focus", async (req, res) => {
|
|
1728
|
+
const profileCtx = getProfileContext(req, ctx);
|
|
1729
|
+
if ("error" in profileCtx) return jsonError(res, profileCtx.status, profileCtx.error);
|
|
1730
|
+
const targetId = toStringOrEmpty(req.body?.targetId);
|
|
1731
|
+
if (!targetId) return jsonError(res, 400, "targetId is required");
|
|
1732
|
+
try {
|
|
1733
|
+
if (!await profileCtx.isReachable(300)) return jsonError(res, 409, "browser not running");
|
|
1734
|
+
await profileCtx.focusTab(targetId);
|
|
1735
|
+
res.json({ ok: true });
|
|
1736
|
+
} catch (err) {
|
|
1737
|
+
const mapped = ctx.mapTabError(err);
|
|
1738
|
+
if (mapped) return jsonError(res, mapped.status, mapped.message);
|
|
1739
|
+
jsonError(res, 500, String(err));
|
|
1740
|
+
}
|
|
1741
|
+
});
|
|
1742
|
+
app.delete("/tabs/:targetId", async (req, res) => {
|
|
1743
|
+
const profileCtx = getProfileContext(req, ctx);
|
|
1744
|
+
if ("error" in profileCtx) return jsonError(res, profileCtx.status, profileCtx.error);
|
|
1745
|
+
const targetId = toStringOrEmpty(req.params.targetId);
|
|
1746
|
+
if (!targetId) return jsonError(res, 400, "targetId is required");
|
|
1747
|
+
try {
|
|
1748
|
+
if (!await profileCtx.isReachable(300)) return jsonError(res, 409, "browser not running");
|
|
1749
|
+
await profileCtx.closeTab(targetId);
|
|
1750
|
+
res.json({ ok: true });
|
|
1751
|
+
} catch (err) {
|
|
1752
|
+
const mapped = ctx.mapTabError(err);
|
|
1753
|
+
if (mapped) return jsonError(res, mapped.status, mapped.message);
|
|
1754
|
+
jsonError(res, 500, String(err));
|
|
1755
|
+
}
|
|
1756
|
+
});
|
|
1757
|
+
app.post("/tabs/action", async (req, res) => {
|
|
1758
|
+
const profileCtx = getProfileContext(req, ctx);
|
|
1759
|
+
if ("error" in profileCtx) return jsonError(res, profileCtx.status, profileCtx.error);
|
|
1760
|
+
const action = toStringOrEmpty(req.body?.action);
|
|
1761
|
+
const index = toNumber(req.body?.index);
|
|
1762
|
+
try {
|
|
1763
|
+
if (action === "list") {
|
|
1764
|
+
if (!await profileCtx.isReachable(300)) return res.json({
|
|
1765
|
+
ok: true,
|
|
1766
|
+
tabs: []
|
|
1767
|
+
});
|
|
1768
|
+
const tabs = await profileCtx.listTabs();
|
|
1769
|
+
return res.json({
|
|
1770
|
+
ok: true,
|
|
1771
|
+
tabs
|
|
1772
|
+
});
|
|
1773
|
+
}
|
|
1774
|
+
if (action === "new") {
|
|
1775
|
+
await profileCtx.ensureBrowserAvailable();
|
|
1776
|
+
const tab = await profileCtx.openTab("about:blank");
|
|
1777
|
+
return res.json({
|
|
1778
|
+
ok: true,
|
|
1779
|
+
tab
|
|
1780
|
+
});
|
|
1781
|
+
}
|
|
1782
|
+
if (action === "close") {
|
|
1783
|
+
const tabs = await profileCtx.listTabs();
|
|
1784
|
+
const target = typeof index === "number" ? tabs[index] : tabs.at(0);
|
|
1785
|
+
if (!target) return jsonError(res, 404, "tab not found");
|
|
1786
|
+
await profileCtx.closeTab(target.targetId);
|
|
1787
|
+
return res.json({
|
|
1788
|
+
ok: true,
|
|
1789
|
+
targetId: target.targetId
|
|
1790
|
+
});
|
|
1791
|
+
}
|
|
1792
|
+
if (action === "select") {
|
|
1793
|
+
if (typeof index !== "number") return jsonError(res, 400, "index is required");
|
|
1794
|
+
const target = (await profileCtx.listTabs())[index];
|
|
1795
|
+
if (!target) return jsonError(res, 404, "tab not found");
|
|
1796
|
+
await profileCtx.focusTab(target.targetId);
|
|
1797
|
+
return res.json({
|
|
1798
|
+
ok: true,
|
|
1799
|
+
targetId: target.targetId
|
|
1800
|
+
});
|
|
1801
|
+
}
|
|
1802
|
+
return jsonError(res, 400, "unknown tab action");
|
|
1803
|
+
} catch (err) {
|
|
1804
|
+
const mapped = ctx.mapTabError(err);
|
|
1805
|
+
if (mapped) return jsonError(res, mapped.status, mapped.message);
|
|
1806
|
+
jsonError(res, 500, String(err));
|
|
1807
|
+
}
|
|
1808
|
+
});
|
|
1809
|
+
}
|
|
1810
|
+
|
|
1811
|
+
//#endregion
|
|
1812
|
+
//#region src/browser/routes/index.ts
|
|
1813
|
+
function registerBrowserRoutes(app, ctx) {
|
|
1814
|
+
registerBrowserBasicRoutes(app, ctx);
|
|
1815
|
+
registerBrowserTabRoutes(app, ctx);
|
|
1816
|
+
registerBrowserAgentRoutes(app, ctx);
|
|
1817
|
+
}
|
|
1818
|
+
|
|
1819
|
+
//#endregion
|
|
1820
|
+
export { getMediaDir as n, saveMediaBuffer as r, registerBrowserRoutes as t };
|