shadow-claw 1.59.7 → 1.60.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.well-known/mcp/server-card.json +4 -12
- package/.well-known/mcp.json +4 -12
- package/README.md +6 -2
- package/dist/cli/build/build.js +1 -1
- package/dist/cli/{chunk-DDvuLVfW.js → chunk-3C5izdQW.js} +1 -1
- package/dist/cli/chunk-B-75h9gX.js +1 -0
- package/dist/cli/{chunk-hVf839t7.js → chunk-B7Kn-otm.js} +1 -1
- package/dist/cli/{chunk-YX32FcN7.js → chunk-BBczgswQ.js} +1 -1
- package/dist/cli/{chunk-DcNxjqH6.js → chunk-BE-lYWcn.js} +1 -1
- package/dist/cli/{chunk-CQaCgswD.js → chunk-BECr0WxI.js} +11 -11
- package/dist/cli/chunk-BEz1PD1_.js +1 -0
- package/dist/cli/chunk-BLzI1Fp2.js +1 -0
- package/dist/cli/{chunk-B3TrWbca.js → chunk-BVSC1MNQ.js} +11 -11
- package/dist/cli/{chunk-D_te8ufL.js → chunk-BdWcep6o.js} +1 -1
- package/dist/cli/{chunk-SRBRVorc.js → chunk-BfTpnSS4.js} +1 -1
- package/dist/cli/{chunk-D2_eAO83.js → chunk-BgvqTf7w.js} +1 -1
- package/dist/cli/chunk-BwsJfUT3.js +1 -0
- package/dist/cli/{chunk--PFY91kE.js → chunk-C9b4b7c_.js} +1 -1
- package/dist/cli/{chunk-SxK79JmB.js → chunk-CAw9XYFe.js} +1 -1
- package/dist/cli/chunk-CFCcbFs2.js +396 -0
- package/dist/cli/{chunk-Cnjb8Usu.js → chunk-CTarF4FC.js} +1 -1
- package/dist/cli/{chunk-3vNYrs_L.js → chunk-Cbq5hpjb.js} +4 -4
- package/dist/cli/chunk-CjTjKy_v.js +310 -0
- package/dist/cli/chunk-Cjyu4cr_.js +36 -0
- package/dist/cli/{chunk-DUGZPka_.js → chunk-ClMKygjZ.js} +1 -1
- package/dist/cli/chunk-Cppnq1KF.js +1 -0
- package/dist/cli/{chunk-DvemF16v.js → chunk-D9QCNFMO.js} +1 -1
- package/dist/cli/{chunk-iB8OoMmW.js → chunk-DB21BMqt.js} +1 -1
- package/dist/cli/{chunk-_Vo-o_e3.js → chunk-DHoIWvCc.js} +1 -1
- package/dist/cli/chunk-DZEN9T5y.js +1 -0
- package/dist/cli/{chunk-5rLO4DWS.js → chunk-Dl14OyYO.js} +9 -9
- package/dist/cli/chunk-Dl_vv0dI.js +1 -0
- package/dist/cli/chunk-Dpmfhlyl.js +1 -0
- package/dist/cli/{chunk-BrR1DOBS.js → chunk-Du7Xtucq.js} +1 -1
- package/dist/cli/{chunk-B88Z8T_9.js → chunk-DxcDFUi_.js} +1 -1
- package/dist/cli/{chunk-Dt7-hzJU.js → chunk-DyyEWbV7.js} +1 -1
- package/dist/cli/chunk-N0x3mXU0.js +1 -0
- package/dist/cli/{chunk-CGoE4llV.js → chunk-V-w0Bata.js} +1 -1
- package/dist/cli/{chunk-CncW6_WL.js → chunk-ZxDxSSn-.js} +1 -1
- package/dist/cli/{chunk-CZdCRqNe.js → chunk-lPvFUkd5.js} +1 -1
- package/dist/cli/{chunk-66BvqAV0.js → chunk-n5s-sCdU.js} +1 -1
- package/dist/cli/{chunk-CAAeGOdy.js → chunk-nD9VPVMq.js} +1 -1
- package/dist/cli/{chunk-DMs7kREC.js → chunk-rFuy8aS_.js} +1 -1
- package/dist/cli/{chunk-B0qusANw.js → chunk-wjM6JXWa.js} +1 -1
- package/dist/cli/{chunk-DhOU6GYX.js → chunk-zcES9rut.js} +1 -1
- package/dist/cli/cli.js +3 -3
- package/dist/headless-agent.js +1 -1
- package/dist/lib/{channel-mmdGzPkT.js → channel-DB77spML.js} +2 -2
- package/dist/lib/{channel-mmdGzPkT.js.map → channel-DB77spML.js.map} +1 -1
- package/dist/lib/{compact-context-CY9BBlUQ.js → compact-context-Q9t9aL1e.js} +7 -7
- package/dist/lib/{compact-context-CY9BBlUQ.js.map → compact-context-Q9t9aL1e.js.map} +1 -1
- package/dist/lib/components/index.js +21 -21
- package/dist/lib/components/settings/shadow-claw-channel-config.js +1 -1
- package/dist/lib/components/settings/shadow-claw-control-plane.js +1 -1
- package/dist/lib/components/settings/shadow-claw-git.js +1 -1
- package/dist/lib/components/settings/shadow-claw-llm.js +1 -1
- package/dist/lib/components/settings/shadow-claw-networking.js +1 -1
- package/dist/lib/components/settings/shadow-claw-notifications.js +1 -1
- package/dist/lib/components/settings/shadow-claw-peerjs.js +1 -1
- package/dist/lib/components/settings/shadow-claw-storage.js +1 -1
- package/dist/lib/components/settings/shadow-claw-task-server.js +1 -1
- package/dist/lib/components/settings/shadow-claw-webvm.js +1 -1
- package/dist/lib/components/shadow-claw-channel-config.js +1 -1
- package/dist/lib/components/shadow-claw-channels.js +1 -1
- package/dist/lib/components/shadow-claw-chat.js +1 -1
- package/dist/lib/components/shadow-claw-control-plane.js +1 -1
- package/dist/lib/components/shadow-claw-conversations.js +1 -1
- package/dist/lib/components/shadow-claw-file-viewer.js +1 -1
- package/dist/lib/components/shadow-claw-files.js +1 -1
- package/dist/lib/components/shadow-claw-git.js +1 -1
- package/dist/lib/components/shadow-claw-llm.js +1 -1
- package/dist/lib/components/shadow-claw-networking.js +1 -1
- package/dist/lib/components/shadow-claw-notifications.js +1 -1
- package/dist/lib/components/shadow-claw-pages.js +1 -1
- package/dist/lib/components/shadow-claw-peerjs.js +1 -1
- package/dist/lib/components/shadow-claw-settings.js +1 -1
- package/dist/lib/components/shadow-claw-storage.js +1 -1
- package/dist/lib/components/shadow-claw-task-server.js +1 -1
- package/dist/lib/components/shadow-claw-tasks.js +1 -1
- package/dist/lib/components/shadow-claw-terminal.js +1 -1
- package/dist/lib/components/shadow-claw-tools.js +1 -1
- package/dist/lib/components/shadow-claw-webvm.js +1 -1
- package/dist/lib/components/shadow-claw.js +1 -1
- package/dist/lib/{configure-peer-js-ccNvax2N.js → configure-peer-js-CgFiwoxY.js} +2 -2
- package/dist/lib/{configure-peer-js-ccNvax2N.js.map → configure-peer-js-CgFiwoxY.js.map} +1 -1
- package/dist/lib/content/build-attachment-content-blocks.d.ts +2 -0
- package/dist/lib/{discover-skills-OwlQ2sXA.js → discover-skills-CXyaWHKi.js} +5 -5
- package/dist/lib/{discover-skills-OwlQ2sXA.js.map → discover-skills-CXyaWHKi.js.map} +1 -1
- package/dist/lib/{git-D2J_j9X9.js → git-CogDRlEz.js} +2 -2
- package/dist/lib/{git-D2J_j9X9.js.map → git-CogDRlEz.js.map} +1 -1
- package/dist/lib/index.js +21 -21
- package/dist/lib/{init-control-plane-B7blDVIE.js → init-control-plane-CEGdzgWX.js} +7 -7
- package/dist/lib/{init-control-plane-B7blDVIE.js.map → init-control-plane-CEGdzgWX.js.map} +1 -1
- package/dist/lib/{invoke-agent-SxvudiDT.js → invoke-agent-cac3gCsj.js} +6 -6
- package/dist/lib/{invoke-agent-SxvudiDT.js.map → invoke-agent-cac3gCsj.js.map} +1 -1
- package/dist/lib/{move-group-entry-DDpjxa10.js → move-group-entry-D8dptMg0.js} +2 -2
- package/dist/lib/{move-group-entry-DDpjxa10.js.map → move-group-entry-D8dptMg0.js.map} +1 -1
- package/dist/lib/{orchestrator-C7fkh7T7.js → orchestrator-BBAwy9Nm.js} +12 -12
- package/dist/lib/{orchestrator-C7fkh7T7.js.map → orchestrator-BBAwy9Nm.js.map} +1 -1
- package/dist/lib/{orchestrator-CCARkxQC.js → orchestrator-cRBe3lhq.js} +2 -2
- package/dist/lib/{orchestrator-CCARkxQC.js.map → orchestrator-cRBe3lhq.js.map} +1 -1
- package/dist/lib/{peerjs-Bfw_FWLB.js → peerjs-BLg8aGUj.js} +3 -3
- package/dist/lib/{peerjs-Bfw_FWLB.js.map → peerjs-BLg8aGUj.js.map} +1 -1
- package/dist/lib/{process-peer-query-param-BxYiZNdf.js → process-peer-query-param-BnsVnxzH.js} +5 -5
- package/dist/lib/{process-peer-query-param-BxYiZNdf.js.map → process-peer-query-param-BnsVnxzH.js.map} +1 -1
- package/dist/lib/{process-pending-shared-payloads-DPIbwRb3.js → process-pending-shared-payloads-DBZfZOOa.js} +2 -2
- package/dist/lib/{process-pending-shared-payloads-DPIbwRb3.js.map → process-pending-shared-payloads-DBZfZOOa.js.map} +1 -1
- package/dist/lib/{process-room-query-param-B2_d50nE.js → process-room-query-param-B8EYg_-r.js} +4 -4
- package/dist/lib/{process-room-query-param-B2_d50nE.js.map → process-room-query-param-B8EYg_-r.js.map} +1 -1
- package/dist/lib/{push-client-rrjTdc-U.js → push-client-CAm6UMvE.js} +3 -3
- package/dist/lib/{push-client-rrjTdc-U.js.map → push-client-CAm6UMvE.js.map} +1 -1
- package/dist/lib/{rooms-bwGoYb1q.js → rooms-Dzphx3rK.js} +2 -2
- package/dist/lib/{rooms-bwGoYb1q.js.map → rooms-Dzphx3rK.js.map} +1 -1
- package/dist/lib/{shadow-claw-CypGVlVO.js → shadow-claw-CGl8tXtG.js} +6 -6
- package/dist/lib/{shadow-claw-CypGVlVO.js.map → shadow-claw-CGl8tXtG.js.map} +1 -1
- package/dist/lib/{shadow-claw-channel-config-DJpDovkF.js → shadow-claw-channel-config-BNIWCdsL.js} +4 -4
- package/dist/lib/{shadow-claw-channel-config-DJpDovkF.js.map → shadow-claw-channel-config-BNIWCdsL.js.map} +1 -1
- package/dist/lib/{shadow-claw-channels-DJLwRovH.js → shadow-claw-channels-C2QSn4Ew.js} +2 -2
- package/dist/lib/{shadow-claw-channels-DJLwRovH.js.map → shadow-claw-channels-C2QSn4Ew.js.map} +1 -1
- package/dist/lib/{shadow-claw-chat-B92cPaft.js → shadow-claw-chat-Wx3y9y6c.js} +3 -3
- package/dist/lib/{shadow-claw-chat-B92cPaft.js.map → shadow-claw-chat-Wx3y9y6c.js.map} +1 -1
- package/dist/lib/{shadow-claw-control-plane-fvn-qyHj.js → shadow-claw-control-plane-D5E4cFGu.js} +6 -6
- package/dist/lib/{shadow-claw-control-plane-fvn-qyHj.js.map → shadow-claw-control-plane-D5E4cFGu.js.map} +1 -1
- package/dist/lib/{shadow-claw-conversations-CsVyDOny.js → shadow-claw-conversations-BtDv7GRW.js} +2 -2
- package/dist/lib/{shadow-claw-conversations-CsVyDOny.js.map → shadow-claw-conversations-BtDv7GRW.js.map} +1 -1
- package/dist/lib/{shadow-claw-file-viewer-DFfyP7s5.js → shadow-claw-file-viewer-CG40kwWV.js} +2 -2
- package/dist/lib/{shadow-claw-file-viewer-DFfyP7s5.js.map → shadow-claw-file-viewer-CG40kwWV.js.map} +1 -1
- package/dist/lib/{shadow-claw-files-cT6HL7ye.js → shadow-claw-files-BOUULrlX.js} +3 -3
- package/dist/lib/{shadow-claw-files-cT6HL7ye.js.map → shadow-claw-files-BOUULrlX.js.map} +1 -1
- package/dist/lib/{shadow-claw-git-Cv9mQgTx.js → shadow-claw-git-BeHV73_9.js} +3 -3
- package/dist/lib/{shadow-claw-git-Cv9mQgTx.js.map → shadow-claw-git-BeHV73_9.js.map} +1 -1
- package/dist/lib/{shadow-claw-llm-CKOYzPDp.js → shadow-claw-llm-KONyWKZM.js} +2 -2
- package/dist/lib/{shadow-claw-llm-CKOYzPDp.js.map → shadow-claw-llm-KONyWKZM.js.map} +1 -1
- package/dist/lib/{shadow-claw-networking-DYfiUQaH.js → shadow-claw-networking-Diy3JJkc.js} +2 -2
- package/dist/lib/{shadow-claw-networking-DYfiUQaH.js.map → shadow-claw-networking-Diy3JJkc.js.map} +1 -1
- package/dist/lib/{shadow-claw-notifications-JJlzriuX.js → shadow-claw-notifications-C-upPa-4.js} +2 -2
- package/dist/lib/{shadow-claw-notifications-JJlzriuX.js.map → shadow-claw-notifications-C-upPa-4.js.map} +1 -1
- package/dist/lib/{shadow-claw-pages-BCo3ihZI.js → shadow-claw-pages-CfAjUKgd.js} +2 -2
- package/dist/lib/{shadow-claw-pages-BCo3ihZI.js.map → shadow-claw-pages-CfAjUKgd.js.map} +1 -1
- package/dist/lib/{shadow-claw-peerjs-CFNjfrY5.js → shadow-claw-peerjs-t4YibS9s.js} +5 -5
- package/dist/lib/{shadow-claw-peerjs-CFNjfrY5.js.map → shadow-claw-peerjs-t4YibS9s.js.map} +1 -1
- package/dist/lib/{shadow-claw-settings-BMwne0bh.js → shadow-claw-settings-Cg5V0e9g.js} +2 -2
- package/dist/lib/{shadow-claw-settings-BMwne0bh.js.map → shadow-claw-settings-Cg5V0e9g.js.map} +1 -1
- package/dist/lib/{shadow-claw-storage-DUY8B9m-.js → shadow-claw-storage-C7tCnsSG.js} +2 -2
- package/dist/lib/{shadow-claw-storage-DUY8B9m-.js.map → shadow-claw-storage-C7tCnsSG.js.map} +1 -1
- package/dist/lib/{shadow-claw-task-server-yWeoA3eL.js → shadow-claw-task-server-BObsRdf8.js} +2 -2
- package/dist/lib/{shadow-claw-task-server-yWeoA3eL.js.map → shadow-claw-task-server-BObsRdf8.js.map} +1 -1
- package/dist/lib/{shadow-claw-tasks-Bg0uM15I.js → shadow-claw-tasks-B2EEqrcY.js} +3 -3
- package/dist/lib/{shadow-claw-tasks-Bg0uM15I.js.map → shadow-claw-tasks-B2EEqrcY.js.map} +1 -1
- package/dist/lib/{shadow-claw-terminal-fyJPppY_.js → shadow-claw-terminal-DSHfO2b9.js} +2 -2
- package/dist/lib/{shadow-claw-terminal-fyJPppY_.js.map → shadow-claw-terminal-DSHfO2b9.js.map} +1 -1
- package/dist/lib/{shadow-claw-tools-D0T8m3go.js → shadow-claw-tools-DwPBADua.js} +3 -3
- package/dist/lib/{shadow-claw-tools-D0T8m3go.js.map → shadow-claw-tools-DwPBADua.js.map} +1 -1
- package/dist/lib/{shadow-claw-webvm-CQvzJwKI.js → shadow-claw-webvm-CY4qGaMB.js} +2 -2
- package/dist/lib/{shadow-claw-webvm-CQvzJwKI.js.map → shadow-claw-webvm-CY4qGaMB.js.map} +1 -1
- package/dist/lib/{sync-web-mcp-registration-BFtG_4kx.js → sync-web-mcp-registration-BiOZvW-R.js} +3 -3
- package/dist/lib/{sync-web-mcp-registration-BFtG_4kx.js.map → sync-web-mcp-registration-BiOZvW-R.js.map} +1 -1
- package/dist/lib/{system-prompt-bhGRLoL2.js → system-prompt-CxJ3Nx4c.js} +4 -3
- package/dist/lib/system-prompt-CxJ3Nx4c.js.map +1 -0
- package/dist/public/.well-known/mcp/server-card.json +4 -12
- package/dist/public/.well-known/mcp.json +4 -12
- package/dist/public/AGENTS.md +3 -1
- package/dist/public/README.md +6 -2
- package/dist/public/agent.worker.js +1 -1
- package/dist/public/{channel-Dk7wl-Av.js → channel-DIpDQekL.js} +1 -1
- package/dist/public/{chat-template-BwAnTFKf.js → chat-template-CXKs8lFR.js} +1 -1
- package/dist/public/compact-context-BQ2ZXoAc.js +5 -0
- package/dist/public/{compact-context-fOTqwKF6.js → compact-context-dHitmPsV.js} +2 -2
- package/dist/public/{configure-peer-js-BOV0tR6G.js → configure-peer-js-DV1rqvFX.js} +1 -1
- package/dist/public/{create-model-cache-fetch-DSAFjOwc.js → create-model-cache-fetch-B0mSCEk6.js} +1 -1
- package/dist/public/{discover-skills-D1sNTy2r.js → discover-skills-BWJB8HUA.js} +1 -1
- package/dist/public/docs/architecture/overview.md +1 -1
- package/dist/public/docs/example/article/index.html +21 -21
- package/dist/public/docs/example/article.html +21 -21
- package/dist/public/docs/publishing/index.html +21 -21
- package/dist/public/docs/publishing.html +21 -21
- package/dist/public/docs/skill-creator/index.html +21 -21
- package/dist/public/docs/skill-creator.html +21 -21
- package/dist/public/docs/subsystems/attachment-capabilities.md +14 -1
- package/dist/public/docs/subsystems/cli.md +95 -51
- package/dist/public/docs/subsystems/pages.md +5 -0
- package/dist/public/e2e/README.md +1 -1
- package/dist/public/{e2e-bridge-Cz95DLlb.js → e2e-bridge-lP2qqiv3.js} +1 -1
- package/dist/public/{git-BmMlwIMP.js → git-DjmQ16rm.js} +1 -1
- package/dist/public/{iframe-bridge-scripts-Cibg0m6A.js → iframe-bridge-scripts-CO0izGjW.js} +1 -1
- package/dist/public/index.html +21 -21
- package/dist/public/index.js +1 -1
- package/dist/public/{init-control-plane-Cb31yLTY.js → init-control-plane-Ctz7FI8M.js} +1 -1
- package/dist/public/{invoke-agent-CN7mSV0Z.js → invoke-agent-C_geruwq.js} +1 -1
- package/dist/public/llms.txt +1 -1
- package/dist/public/main/index.html +21 -21
- package/dist/public/main/memory/index.html +21 -21
- package/dist/public/main/memory.html +21 -21
- package/dist/public/main.html +21 -21
- package/dist/public/{move-group-entry-CXneuNVa.js → move-group-entry-QQ9Hkk54.js} +1 -1
- package/dist/public/{orchestrator-Dyylc8IU.js → orchestrator-C1kaTltu.js} +2 -2
- package/dist/public/{orchestrator-DBO4NZqd.js → orchestrator-Li1UAsv7.js} +1 -1
- package/dist/public/{peerjs-l0jiBoh6.js → peerjs-DbBryE-9.js} +1 -1
- package/dist/public/{process-peer-query-param-s-aSP1Rq.js → process-peer-query-param-DQIgr3KL.js} +1 -1
- package/dist/public/{process-pending-shared-payloads-BN3GigPT.js → process-pending-shared-payloads-Ctb-TFqB.js} +1 -1
- package/dist/public/{process-room-query-param-B2Qe0F0M.js → process-room-query-param-F-XnIVoZ.js} +1 -1
- package/dist/public/{push-client-B2LC8Qp9.js → push-client-DRx9Eggz.js} +1 -1
- package/dist/public/{rooms-ChCEOvkw.js → rooms-BurBI7is.js} +1 -1
- package/dist/public/service-worker/init.js +1 -1
- package/dist/public/service-worker.js +1 -1
- package/dist/public/{shadow-claw-Br8mWDUx.js → shadow-claw-Bg9AQ5x_.js} +2 -2
- package/dist/public/{shadow-claw-accounts-Dm6G7KMP.js → shadow-claw-accounts-B3mjYI0M.js} +1 -1
- package/dist/public/{shadow-claw-card-CggS8uSa.js → shadow-claw-card-tcXRS1GF.js} +1 -1
- package/dist/public/{shadow-claw-channels-088vhuWO.js → shadow-claw-channels-BiSfLvWv.js} +1 -1
- package/dist/public/{shadow-claw-chat-BRwRlq-n.js → shadow-claw-chat-N5jMsXZZ.js} +1 -1
- package/dist/public/{shadow-claw-control-plane-rhKACK85.js → shadow-claw-control-plane-DFVe_Xdq.js} +2 -2
- package/dist/public/{shadow-claw-conversations-CF_yUfKl.js → shadow-claw-conversations-wAR06_ya.js} +1 -1
- package/dist/public/{shadow-claw-empty-state-CkpOSXCS.js → shadow-claw-empty-state-CnPm3NVM.js} +1 -1
- package/dist/public/{shadow-claw-file-viewer-DWCejuY3.js → shadow-claw-file-viewer-sZN_FCDW.js} +2 -2
- package/dist/public/{shadow-claw-files-L6_ioyzh.js → shadow-claw-files-CnvkCbd4.js} +2 -2
- package/dist/public/{shadow-claw-git-DsdkwLqQ.js → shadow-claw-git-BBHfClGk.js} +2 -2
- package/dist/public/{shadow-claw-integrations-CSbRTOm3.js → shadow-claw-integrations-DvdBqzRJ.js} +1 -1
- package/dist/public/{shadow-claw-llm-BitaeAVc.js → shadow-claw-llm-YfohG519.js} +1 -1
- package/dist/public/{shadow-claw-mcp-remote-gSbV5riy.js → shadow-claw-mcp-remote-BAVbf5pi.js} +1 -1
- package/dist/public/{shadow-claw-networking-Dn_y6Cl9.js → shadow-claw-networking-CZ4LWPW7.js} +1 -1
- package/dist/public/{shadow-claw-notifications-Cj4Lqx8U.js → shadow-claw-notifications-BHwyREkG.js} +1 -1
- package/dist/public/{shadow-claw-page-header-DR4OZFt2.js → shadow-claw-page-header-De6Qf6eY.js} +1 -1
- package/dist/public/{shadow-claw-page-header-action-button-BnCV_2Kb.js → shadow-claw-page-header-action-button-FSOhTc9z.js} +1 -1
- package/dist/public/{shadow-claw-pages-mpDOtNYj.js → shadow-claw-pages-D_oPyDca.js} +1 -1
- package/dist/public/{shadow-claw-pdf-viewer-DZ_84qJH.js → shadow-claw-pdf-viewer-CrU4wqRq.js} +1 -1
- package/dist/public/{shadow-claw-settings-CfFTYTEy.js → shadow-claw-settings-DkUhvxVr.js} +2 -2
- package/dist/public/{shadow-claw-storage-DLmiT4bG.js → shadow-claw-storage-D0o56Tjw.js} +1 -1
- package/dist/public/{shadow-claw-task-server-BoMBCsiS.js → shadow-claw-task-server-4rkroO9K.js} +1 -1
- package/dist/public/{shadow-claw-tasks-ChEp1j7x.js → shadow-claw-tasks-BdP7lmvu.js} +1 -1
- package/dist/public/{shadow-claw-terminal-BaoVbOda.js → shadow-claw-terminal-DVHX7Fsu.js} +1 -1
- package/dist/public/{shadow-claw-toast-e8oz7z6Z.js → shadow-claw-toast-B9Y9tSkW.js} +1 -1
- package/dist/public/{shadow-claw-tools-BYjUBiJz.js → shadow-claw-tools-BwwY53Lr.js} +1 -1
- package/dist/public/{shadow-claw-webvm-xGb13TME.js → shadow-claw-webvm-CXGdkCNM.js} +1 -1
- package/dist/public/{sync-web-mcp-registration-CQluj-Kz.js → sync-web-mcp-registration-DVK_IhXZ.js} +1 -1
- package/dist/public/{system-prompt-CTJn0tK-.js → system-prompt-BmswoQwF.js} +2 -2
- package/dist/public/{workbox-92eae37e.js → workbox-e4022e15.js} +1 -1
- package/dist/public/{zip-reader-DN7FB-Q0.js → zip-reader-JHoTbATw.js} +1 -1
- package/dist/server.js +5 -5
- package/package.json +1 -1
- package/dist/cli/chunk-2gZFafgY.js +0 -1
- package/dist/cli/chunk-BCjL0JXf.js +0 -1
- package/dist/cli/chunk-BNcu1oiT.js +0 -1
- package/dist/cli/chunk-BUNoeMKY.js +0 -36
- package/dist/cli/chunk-C5ypckWC.js +0 -225
- package/dist/cli/chunk-CFxww5Yz.js +0 -1
- package/dist/cli/chunk-CGIgtL6R.js +0 -1
- package/dist/cli/chunk-CafdvLx-.js +0 -1
- package/dist/cli/chunk-Dhap1VwA.js +0 -1
- package/dist/cli/chunk-Ds5-K-9o.js +0 -1
- package/dist/cli/chunk-DwvavohW.js +0 -1
- package/dist/cli/chunk-_a0CkUNS.js +0 -139
- package/dist/lib/system-prompt-bhGRLoL2.js.map +0 -1
- package/dist/public/compact-context-CX4H8V57.js +0 -5
package/dist/headless-agent.js
CHANGED
|
@@ -247,7 +247,7 @@ actions:
|
|
|
247
247
|
updateDataModel — update a single path in the data model (re-renders bound components)
|
|
248
248
|
deleteSurface — remove the surface from the chat`,input_schema:{type:`object`,properties:{action:{type:`string`,enum:[`createSurface`,`updateComponents`,`updateDataModel`,`deleteSurface`],description:`The A2UI operation to perform`},surfaceId:{type:`string`,description:`Unique identifier for this surface. Use a stable ID so you can update it later.`},components:{type:`array`,description:`Flat array of component objects (required for createSurface/updateComponents). Each object MUST have an 'id' field and a 'component' field. The component with id 'root' is the tree root (required for createSurface). Component field values: Text | Row | Column | Button | TextField | Image | Icon | Video | AudioPlayer | List | Card | Tabs | Modal | Divider | CheckBox | ChoicePicker | Slider | DateTimeInput. Put all properties at the TOP LEVEL alongside 'component' and 'id'. DO NOT nest properties under a 'properties' key. Children arrays contain other component ID strings, not nested objects.`,items:{type:`object`,additionalProperties:!0}},dataModel:{type:`object`,description:`Initial data model for the surface (used with createSurface). Components can reference values via { "path": "/key" }.`,properties:{},additionalProperties:!0},path:{type:`string`,description:`JSON Pointer path to update (required for updateDataModel). Examples: "/result", "/user/name", "/count". Use "/" to replace the entire data model.`},value:{type:`string`,description:`New value to set at the specified path (used with updateDataModel). Omit to delete the key at the given path.`},surfaceProperties:{type:`object`,description:`Optional display/branding properties for this surface (e.g. agentDisplayName).`,properties:{},additionalProperties:!0}},required:[`action`,`surfaceId`]}}})),Ou,ku=k((()=>{Ou={name:`spawn_subagent`,description:`Spawn one or more independent agent loops to work on subtasks in parallel and collect their results. Each subagent has its own tool-use loop, inherits the current API key, and can optionally override provider/model. and runs concurrently with other subagents via Promise.all. Use spawn_subagent when a task has independent parallel workstreams — for example: researching multiple topics simultaneously, processing a list of items in parallel, or delegating isolated subtasks to specialized agents. Do NOT use spawn_subagent for sequential tasks where step 2 depends on step 1's output — just do those steps directly. Do NOT use spawn_subagent for simple single-step work that takes one tool call. Use the parallel_agents field to fan out multiple subagents in a single call.`,input_schema:{type:`object`,properties:{prompt:{type:`string`,description:`The task prompt for a single subagent. Required unless using parallel_agents for multi-agent fan-out.`},tools:{type:`array`,description:`Optional list of tool names to allow in the subagent. If omitted, the subagent inherits the current tool set (minus spawn_subagent to prevent recursion). If provided, only these tools are available to the subagent.`,items:{type:`string`}},profile:{type:`string`,enum:[`current`,`fast`,`smart`,`powerful`],description:`Optional model profile to run the subagent on. Use 'fast' for simple/cheap subtasks (e.g., text formatting, basic search), 'smart' for moderate reasoning, 'powerful' for deep thinking or complex coding, and 'current' to inherit the parent model. Defaults to 'current'.`},workspace_group_id:{type:`string`,description:`Optional workspace group id override for subagent file/tool scope. Use 'parent' to reuse the parent workspace in automatic mode. When omitted, subagents use an isolated workspace by default.`},system_prompt:{type:`string`,description:`Optional system prompt override for the subagent. Defaults to the current system prompt.`},parallel_agents:{type:`array`,description:`Optional list of subagent specifications to run in parallel. When provided, all agents are launched concurrently and their results are combined. Note: There is a configurable maximum limit on parallel subagents (default 5). Each entry can specify a prompt, optional tools list, optional profile, and optional system_prompt.`,items:{type:`object`,properties:{prompt:{type:`string`,description:`The task prompt for this subagent.`},tools:{type:`array`,description:`Optional tool names for this subagent.`,items:{type:`string`}},profile:{type:`string`,enum:[`current`,`fast`,`smart`,`powerful`],description:`Optional model profile for this subagent. Defaults to 'current'.`},workspace_group_id:{type:`string`,description:`Optional workspace group id for this subagent. Use 'parent' for parent workspace in automatic mode.`},system_prompt:{type:`string`,description:`Optional system prompt override for this subagent.`}},required:[`prompt`]}}},required:[`prompt`]}}})),Au,ju=k((()=>{Au={name:`get_current_time`,description:`Get the current date and time. Returns an ISO 8601 string representing the current date and time. Use this tool whenever you need to know the current time, instead of relying on shell tools which may be unavailable.`,input_schema:{type:`object`,properties:{timezone:{type:`string`,description:`Optional timezone to format the time in (e.g. 'America/New_York'). If omitted, returns UTC.`}}}}})),Mu,Nu,Pu,Fu,Iu,Lu,Ru,zu,Bu,Vu,Hu,Uu,Wu,Gu=k((()=>{Mu={name:`attach_file_to_chat`,description:`Prepare a workspace file for chat delivery by generating an exact markdown attachment snippet. Validates the file path and returns markdown that works for inline image rendering in ShadowClaw and attachment upload in external channels like Telegram/iMessage.`,input_schema:{type:`object`,properties:{path:{type:`string`,description:`File path relative to the group workspace root`},alt:{type:`string`,description:`Optional alt/caption text to use in the generated markdown`}},required:[`path`]}},Nu={name:`copy_file`,description:`Copy a file or directory in the group workspace to a new destination path. Supports copying single files or nested directories. Optionally supports copying between different conversation workspaces via source_group_id or target_group_id.`,input_schema:{type:`object`,properties:{source_path:{type:`string`,description:`Source file or directory path relative to workspace root`},target_path:{type:`string`,description:`Destination file or directory path relative to workspace root`},source_group_id:{type:`string`,description:`Optional source conversation group ID (defaults to current workspace)`},target_group_id:{type:`string`,description:`Optional target conversation group ID (defaults to current workspace)`}},required:[`source_path`,`target_path`]}},Pu={name:`create_directory`,description:`Create a new directory (and any missing parent directories) in the group workspace.`,input_schema:{type:`object`,properties:{path:{type:`string`,description:`Directory path relative to the group workspace root`}},required:[`path`]}},Fu={name:`delete_file`,description:`Delete a file or directory from the group workspace. If the target path is a directory, it will be recursively deleted.`,input_schema:{type:`object`,properties:{path:{type:`string`,description:`File or directory path relative to the group workspace root`}},required:[`path`]}},Iu={name:`diff_files`,description:`Compare two files in the workspace and output the differences. Useful for comparing generated code, checking before patching, or finding changes outside of git repositories.`,input_schema:{type:`object`,properties:{path_a:{type:`string`,description:`Path to the first file relative to the group workspace root.`},path_b:{type:`string`,description:`Path to the second file relative to the group workspace root.`}},required:[`path_a`,`path_b`]}},Lu={name:`list_files`,description:`List files and directories in the group workspace. Directory names end with /. Returns sorted entries.`,input_schema:{type:`object`,properties:{path:{type:`string`,description:`Directory path relative to workspace root (default: root)`}}}},Ru={name:`move_file`,description:`Move or rename a file or directory in the group workspace to a target path. Supports moving single files or nested directories. Optionally supports moving between different conversation workspaces via source_group_id or target_group_id.`,input_schema:{type:`object`,properties:{source_path:{type:`string`,description:`Source file or directory path relative to workspace root`},target_path:{type:`string`,description:`Destination file or directory path relative to workspace root`},source_group_id:{type:`string`,description:`Optional source conversation group ID (defaults to current workspace)`},target_group_id:{type:`string`,description:`Optional target conversation group ID (defaults to current workspace)`}},required:[`source_path`,`target_path`]}},zu={name:`open_file`,description:`Open a file from the group workspace in the UI file viewer dialog. Use this only when the user explicitly asks to inspect a file visually with preview support. Do not use this tool to send or attach files in chat responses.`,input_schema:{type:`object`,properties:{path:{type:`string`,description:`File path relative to the group workspace root`}},required:[`path`]}},Bu={name:`patch_file`,description:`Make a targeted text replacement in a file. Finds the single occurrence of old_string and replaces it with new_string. Fails if old_string is not found or matches more than once. Use this instead of write_file when you only need to change part of a file — it is safer and works well with large files. Include enough surrounding context in old_string to make the match unique. IMPORTANT: You must provide 'path', 'old_string', and 'new_string' parameters.`,input_schema:{type:`object`,properties:{path:{type:`string`,description:`File path relative to the group workspace root`},old_string:{type:`string`,description:`The exact text to find in the file. Must match exactly once. Include 2-3 lines of surrounding context to ensure a unique match.`},new_string:{type:`string`,description:`The replacement text. Can be empty to delete old_string.`}},required:[`path`,`old_string`,`new_string`]}},Vu={name:`read_file`,description:`Read the contents of one or more files from the group workspace. IMPORTANT: You must specify either the 'path' parameter (for a single file) or the 'paths' parameter (an array of file paths for multiple files). When paths is provided, returns all file contents concatenated with --- filename --- headers. Prefer paths to batch reads in a single call. Image files (png, jpg, gif, webp, etc.) are returned as native image content that the model can see directly. Other binary files will be detected and an error returned suggesting alternative tools.`,input_schema:{type:`object`,properties:{path:{type:`string`,description:`Single file path relative to the group workspace root`},paths:{type:`array`,items:{type:`string`},description:`Array of file paths relative to the group workspace root. Use this to read multiple files in a single tool call.`}}}},Hu={name:`search_files`,description:`Search for a pattern (regex or exact text) in files across the workspace. Useful for finding code references, function definitions, or specific content without needing to rely on a shell environment.`,input_schema:{type:`object`,properties:{pattern:{type:`string`,description:`The text or regular expression to search for.`},path:{type:`string`,description:`Optional directory path to restrict the search to (e.g. 'src/'). Defaults to workspace root.`},file_glob:{type:`string`,description:`Optional simple glob to filter files (e.g. '*.ts'). Supports * as wildcard.`},is_regex:{type:`boolean`,description:`Set to true to parse the pattern as a regular expression.`}},required:[`pattern`]}},Uu={name:`send_file`,description:`Send a workspace file directly to connected peer(s) over the P2P (PeerJS/WebRTC) data channel. Use this when the user is in a peer conversation or room, or specify peer_id to send to a remote peer directly. The file is read from the current workspace and transferred over WebRTC in binary chunks so there is no size limit.`,input_schema:{type:`object`,properties:{path:{type:`string`,description:`File path relative to the group workspace root`},peer_id:{type:`string`,description:`Optional target PeerJS peer ID (or peer: groupId). If omitted, sends to the current peer/room conversation.`}},required:[`path`]}},Wu={name:`write_file`,description:`Write content to a file in the group workspace. Creates the file and any intermediate directories if they don't exist. Overwrites the file if it already exists. IMPORTANT: You must provide both the 'path' and 'content' parameters when calling this tool.`,input_schema:{type:`object`,properties:{path:{type:`string`,description:`File path relative to the group workspace root`},content:{type:`string`,description:`Content to write to the file`}},required:[`path`,`content`]}}})),Ku,qu,Ju,Yu,Xu,Zu,Qu,$u,ed,td,nd,rd,id,ad,od,sd,cd,ld,ud,dd,fd,pd,md,hd,gd=k((()=>{Ku={name:`git_add`,description:`Stage files in a cloned repo. Accepts an array of filepaths. If omitted or empty, stages the repo root.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},filepaths:{type:`array`,items:{type:`string`},description:`Array of file paths to stage (relative to repo root). Pass a single item for one file.`}},required:[`repo`]}},qu={name:`git_branch`,description:`Create a new branch in a cloned repo. Optionally switch to it immediately (like git checkout -b).`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name (returned by git_clone)`},name:{type:`string`,description:`Name for the new branch`},checkout:{type:`boolean`,description:`Switch to the new branch after creating it (default: false)`},start_point:{type:`string`,description:`Branch, tag, or commit SHA to branch from (default: HEAD)`}},required:[`repo`,`name`]}},Ju={name:`git_branches`,description:`List branches in a cloned repo. Current branch is marked with *.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},remote:{type:`boolean`,description:`List remote-tracking branches instead (default: false)`}},required:[`repo`]}},Yu={name:`git_checkout`,description:`Checkout a branch, tag, or commit SHA in a cloned repo.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name (returned by git_clone)`},ref:{type:`string`,description:`Branch name, tag, or commit SHA to checkout`}},required:[`repo`,`ref`]}},Xu={name:`git_clone`,description:`Clone a git repository into browser-persistent OPFS storage. Files are stored directly under repos/<repo-name>/ in the workspace and are immediately accessible to other git_* tools without any extra sync step. Works with public and private repos (GitHub, GitLab, GitHub Enterprise, etc.). If a Git PAT is configured in Settings, it is used automatically for authentication. Uses a CORS proxy. Returns the short repo name used for subsequent git_* operations.`,input_schema:{type:`object`,properties:{url:{type:`string`,description:`Full HTTPS repo URL (e.g. https://github.com/user/repo)`},name:{type:`string`,description:`Optional short repo name to use for the clone directory; defaults to the repository name parsed from the URL.`},branch:{type:`string`,description:`Branch to clone (default: default branch)`},depth:{type:`number`,description:`Shallow clone depth (default: 20)`}},required:[`url`]}},Zu={name:`git_commit`,description:`Stage all changes and create a commit in a cloned repo. Uses configured git author name/email or defaults.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},message:{type:`string`,description:`Commit message`},author_name:{type:`string`,description:`Author name (optional, uses configured default)`},author_email:{type:`string`,description:`Author email (optional, uses configured default)`}},required:[`repo`,`message`]}},Qu={name:`git_config`,description:`Get or set a git config value for a repo (e.g. user.name, user.email). Persistent per-repo identity avoids specifying author on every commit.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},command:{type:`string`,enum:[`get`,`set`],description:`Operation: get or set a config value`},key:{type:`string`,description:`Config key path (e.g. user.name, user.email, core.autocrlf)`},value:{type:`string`,description:`Value to set — required when command is set`}},required:[`repo`,`command`,`key`]}},$u={name:`git_delete_branch`,description:`Delete a local branch from a cloned repo.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},name:{type:`string`,description:`Name of the branch to delete`}},required:[`repo`,`name`]}},ed={name:`git_delete_repo`,description:"Delete the git metadata for a cloned repository while leaving the working tree files in place. Use this to clean up corrupted or stale repos that fail to re-clone. The repo directory remains under repos/<repo>, but the `.git/` metadata is removed.",input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name (as returned by git_clone or git_list_repos)`}},required:[`repo`]}},td={name:`git_diff`,description:`Show changed files between HEAD and working tree, or between two refs.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},ref1:{type:`string`,description:`First ref (default: HEAD)`},ref2:{type:`string`,description:`Second ref (if omitted, diffs HEAD vs workdir)`}},required:[`repo`]}},nd={name:`git_fetch`,description:`Fetch commits from the remote without merging. Safe for inspecting remote state before deciding to merge or rebase.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},branch:{type:`string`,description:`Remote branch to fetch (default: default branch)`},remote:{type:`string`,description:`Remote name (default: origin)`}},required:[`repo`]}},rd={name:`git_init`,description:`Initialize a new empty git repository in browser storage. Use this to create a new project from scratch before using git_push to push to a remote.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short name for the new repo (used for all subsequent git_ operations)`}},required:[`repo`]}},id={name:`git_list_repos`,description:`List all git repositories currently cloned in browser storage.`,input_schema:{type:`object`,properties:{}}},ad={name:`git_log`,description:`Show the commit log for a cloned repo. Returns commit SHA, date, author, and message.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},ref:{type:`string`,description:`Ref to log from (default: HEAD)`},depth:{type:`number`,description:`Number of commits to show (default: 10)`}},required:[`repo`]}},od={name:`git_merge`,description:`Merge a branch or ref into the current branch. Supports fast-forward and three-way merges. If the merge has conflicts, a detailed report is returned with the conflicted files and their conflict regions inline. To resolve: use read_file on each conflicted file, then write_file with the complete resolved content (no conflict markers). After all files are resolved, use git_add for each, then git_commit. Do NOT use bash/sed for conflict resolution.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},theirs:{type:`string`,description:`Branch name, tag, or commit SHA to merge into the current branch`},author_name:{type:`string`,description:`Author name (optional, uses configured default)`},author_email:{type:`string`,description:`Author email (optional, uses configured default)`}},required:[`repo`,`theirs`]}},sd={name:`git_pull`,description:`Fetch and merge commits from the remote repository. Uses configured git author name/email for merge commits if needed.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},branch:{type:`string`,description:`Branch to pull (default: current branch)`},author_name:{type:`string`,description:`Author name (optional, uses configured default)`},author_email:{type:`string`,description:`Author email (optional, uses configured default)`}},required:[`repo`]}},cd={name:`git_push`,description:`Push commits to the remote repository. Requires a GitHub personal access token (PAT) to be configured. The token is loaded from the encrypted credential store.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},branch:{type:`string`,description:`Local branch to push (default: current branch)`},remote_ref:{type:`string`,description:`Remote branch name to push to, if different from local branch. Example: push local 'feature-rebased' to remote 'feature/original'.`},force:{type:`boolean`,description:`Force push (default: false)`},tags:{type:`boolean`,description:`Also push all local tags to the remote (default: false)`}},required:[`repo`]}},ld={name:`git_read_file_at_ref`,description:`Read a file's contents at a specific ref (branch, tag, or commit SHA) without checking it out. Useful for code review across branches.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},ref:{type:`string`,description:`Branch name, tag, or commit SHA`},filepath:{type:`string`,description:`File path relative to the repo root`}},required:[`repo`,`ref`,`filepath`]}},ud={name:`git_remote`,description:`Manage git remotes: list, add, or remove a remote in a cloned repo.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},command:{type:`string`,enum:[`list`,`add`,`remove`],description:`Operation to perform`},remote:{type:`string`,description:`Remote name (e.g. origin, upstream) — required for add/remove`},url:{type:`string`,description:`Remote URL — required for add`}},required:[`repo`,`command`]}},dd={name:`git_reset`,description:`Reset the current branch HEAD to a specific ref or commit SHA. Updates the branch pointer and checks out the target, discarding local changes. Equivalent to 'git reset --hard <ref>'.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},ref:{type:`string`,description:`Branch name, tag, or commit SHA to reset to`}},required:[`repo`,`ref`]}},fd={name:`git_show`,description:`Show the metadata and diff of a specific commit. Returns author, date, message, and a unified diff against the parent commit.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},ref:{type:`string`,description:`Commit SHA, branch, or tag to inspect (default: HEAD)`}},required:[`repo`,`ref`]}},pd={name:`git_status`,description:`Show the working tree status of a cloned repo. Reports modified, added, deleted, and unstaged files.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`}},required:[`repo`]}},md={name:`git_tag`,description:`Create a lightweight or annotated tag at HEAD. Use git_push with tags=true to push tags to the remote.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},tag:{type:`string`,description:`Tag name (e.g. v1.2.3)`},message:{type:`string`,description:`Annotation message — if provided, creates an annotated tag; otherwise lightweight`},author_name:{type:`string`,description:`Tagger name (optional, uses configured default)`},author_email:{type:`string`,description:`Tagger email (optional, uses configured default)`}},required:[`repo`,`tag`]}},hd={name:`git_unstage`,description:`Remove one or more staged files from the index without touching the working tree. The inverse of git_add — use to undo accidental staging.`,input_schema:{type:`object`,properties:{repo:{type:`string`,description:`Short repo name`},filepath:{type:`string`,description:`File path or array of file paths to unstage (relative to repo root)`}},required:[`repo`,`filepath`]}}})),_d,vd,yd,bd,xd,Sd,Cd,wd=k((()=>{_d={name:`create_task`,description:`Create a scheduled recurring task. The task will run automatically on the specified schedule and send the result back to this group. Uses cron expressions (minute hour day-of-month month day-of-week).`,input_schema:{type:`object`,properties:{schedule:{type:`string`,description:`Cron expression, e.g. "0 9 * * 1-5" for 9am weekdays`},prompt:{type:`string`,description:`The prompt/instruction to execute on each run (used if type is 'prompt')`},type:{type:`string`,enum:[`prompt`,`tools`],description:`The type of task to create. Defaults to 'prompt'.`},tools:{type:`array`,description:`A list of tools to execute sequentially (used if type is 'tools')`,items:{type:`object`,properties:{name:{type:`string`},input:{type:`object`}},required:[`name`,`input`]}},name:{type:`string`,description:`The optional title/name for the task, helping to identify its purpose.`}},required:[`prompt`,`type`]}},vd={name:`list_tasks`,description:`List all scheduled recurring tasks for this group. Returns a list of tasks with their IDs, schedules, and prompts.`,input_schema:{type:`object`,properties:{}}},yd={name:`update_task`,description:`Update an existing scheduled task's schedule or prompt.`,input_schema:{type:`object`,properties:{id:{type:`string`,description:`The unique ID of the task to update`},schedule:{type:`string`,description:`Standard cron expression (e.g. '0 9 * * *'). Leave empty for an unscheduled task.`},prompt:{type:`string`,description:`New prompt/instruction (optional)`},type:{type:`string`,enum:[`prompt`,`tools`],description:`New task type (optional)`},tools:{type:`array`,description:`New list of tools (optional)`,items:{type:`object`,properties:{name:{type:`string`},input:{type:`object`}},required:[`name`,`input`]}},enabled:{type:`boolean`,description:`Whether the task is enabled (optional)`},name:{type:`string`,description:`New name/title for the task (optional).`}},required:[`id`]}},bd={name:`delete_task`,description:`Delete a scheduled task by its ID.`,input_schema:{type:`object`,properties:{id:{type:`string`,description:`The unique ID of the task to delete`}},required:[`id`]}},xd={name:`enable_task`,description:`Enable a scheduled task so it runs on its schedule.`,input_schema:{type:`object`,properties:{id:{type:`string`,description:`The unique ID of the task to enable`}},required:[`id`]}},Sd={name:`disable_task`,description:`Disable a scheduled task so it stops running.`,input_schema:{type:`object`,properties:{id:{type:`string`,description:`The unique ID of the task to disable`}},required:[`id`]}},Cd={name:`run_task`,description:`Immediately trigger a scheduled task by its ID, outside of its normal cron schedule. Use this to manually fire a task on demand. Use list_tasks to find the task ID first.`,input_schema:{type:`object`,properties:{id:{type:`string`,description:`The unique ID of the task to run immediately`}},required:[`id`]}}})),Td,Ed,Dd,Od,kd=k((()=>{Td={name:`create_room`,description:`Create a new multi-party room (a shared PeerJS conversation) hosted by this device. Other agents or humans can then be invited to participate. Returns the room so you can share or invite peers into it.`,input_schema:{type:`object`,properties:{name:{type:`string`,description:`A human-readable name for the room.`}},required:[`name`]}},Ed={name:`invite_to_room`,description:`Invite a peer (another agent or human, identified by their PeerJS peer ID) into a room so they can join the shared conversation. If room_id is omitted and the current conversation is a room, that room is used.`,input_schema:{type:`object`,properties:{peer_id:{type:`string`,description:`The PeerJS peer ID of the participant to invite.`},room_id:{type:`string`,description:`The room id to invite into. Defaults to the current room conversation.`}},required:[`peer_id`]}},Dd={name:`leave_room`,description:`Leave a room. If you are the host, the room is disbanded for all members. If room_id is omitted and the current conversation is a room, that room is used.`,input_schema:{type:`object`,properties:{room_id:{type:`string`,description:`The room id to leave. Defaults to the current room conversation.`}}}},Od={name:`list_room_members`,description:`List the participants (humans and agents) currently in a room. If room_id is omitted and the current conversation is a room, that room is used.`,input_schema:{type:`object`,properties:{room_id:{type:`string`,description:`The room id to inspect. Defaults to the current room conversation.`}}}}})),Ad,jd,Md,Nd,Pd,Fd,Id=k((()=>{Ad={name:`summarize_text`,description:`Summarize text using Web Platform's Summarizer API (or polyfill fallback). Produces key points, TLDR, teaser, or headline.`,input_schema:{type:`object`,properties:{text:{type:`string`,description:`The text content to summarize.`},type:{type:`string`,enum:[`key-points`,`tldr`,`teaser`,`headline`],description:`The summary type (default: key-points).`},format:{type:`string`,enum:[`plain-text`,`markdown`],description:`Output format (default: markdown).`},length:{type:`string`,enum:[`short`,`medium`,`long`],description:`Summary length (default: short).`},preference:{type:`string`,enum:[`capability`,`speed`,`auto`],description:`Summarizer performance preference (default: auto).`},context:{type:`string`,description:`Optional background context for summarization.`},outputLanguage:{type:`string`,description:`Optional target language code (e.g. 'en', 'es').`},sharedContext:{type:`string`,description:`Optional shared context passed to the underlying model.`},overridePrompt:{type:`string`,description:`Optional custom system prompt overriding default summarization instructions.`}},required:[`text`]}},jd={name:`write_text`,description:`Generate or draft text using Web Platform's Writer API (or polyfill fallback).`,input_schema:{type:`object`,properties:{prompt:{type:`string`,description:`The prompt or writing instructions.`},tone:{type:`string`,enum:[`formal`,`neutral`,`casual`],description:`Tone for drafting (default: neutral).`},format:{type:`string`,enum:[`plain-text`,`markdown`],description:`Output format (default: plain-text).`},length:{type:`string`,enum:[`short`,`medium`,`long`],description:`Target length (default: short).`},context:{type:`string`,description:`Optional background context for writing.`},outputLanguage:{type:`string`,description:`Optional target language code (e.g. 'en', 'es').`},sharedContext:{type:`string`,description:`Optional shared context passed to the underlying model.`}},required:[`prompt`]}},Md={name:`rewrite_text`,description:`Rewrite or rephrase text using Web Platform's Rewriter API (or polyfill fallback). Can adjust tone or length.`,input_schema:{type:`object`,properties:{text:{type:`string`,description:`The text to rewrite.`},tone:{type:`string`,enum:[`as-is`,`more-formal`,`more-casual`],description:`Tone adjustment (default: as-is).`},format:{type:`string`,enum:[`as-is`,`plain-text`,`markdown`],description:`Format adjustment (default: as-is).`},length:{type:`string`,enum:[`as-is`,`shorter`,`longer`],description:`Length adjustment (default: as-is).`},context:{type:`string`,description:`Optional background context for rewriting.`},outputLanguage:{type:`string`,description:`Optional target language code (e.g. 'en', 'es').`},sharedContext:{type:`string`,description:`Optional shared context passed to the underlying model.`}},required:[`text`]}},Nd={name:`proofread_text`,description:`Proofread and correct grammar, spelling, and phrasing errors using Web Platform's Proofreader API (or polyfill fallback).`,input_schema:{type:`object`,properties:{text:{type:`string`,description:`The text to proofread.`},context:{type:`string`,description:`Optional background context for proofreading.`}},required:[`text`]}},Pd={name:`detect_language`,description:`Detect the language of input text using Web Platform's Language Detector API (or polyfill fallback).`,input_schema:{type:`object`,properties:{text:{type:`string`,description:`The text to analyze for language detection.`}},required:[`text`]}},Fd={name:`translate_text`,description:`Translate text using Web Platform's Translator API (or polyfill fallback).`,input_schema:{type:`object`,properties:{text:{type:`string`,description:`The text to translate.`},sourceLanguage:{type:`string`,description:`Source language BCP 47 code (e.g. 'en', 'es', 'ja').`},targetLanguage:{type:`string`,description:`Target language BCP 47 code (e.g. 'en', 'es', 'ja').`}},required:[`text`,`sourceLanguage`,`targetLanguage`]}}})),Ld,Rd,zd=k((()=>{Ld={name:`prompt_peer`,description:`Send a prompt or message directly to another connected ShadowClaw peer or agent over WebRTC, triggering their orchestration loop and returning their answer. Use this to ask another agent to perform a task, answer a question, or analyze data.`,input_schema:{type:`object`,properties:{peer_id:{type:`string`,description:`The PeerJS peer ID or client ID of the target agent to prompt.`},prompt:{type:`string`,description:`The prompt, question, or instruction for the peer agent.`},timeout_seconds:{type:`number`,description:`Optional timeout in seconds to wait for the peer agent's response (default: 120).`}},required:[`peer_id`,`prompt`]}},Rd={name:`list_peers`,description:`List the currently connected peers or clients available over WebRTC and the control plane. Returns peer IDs and device labels so you know which peers you can prompt or collaborate with.`,input_schema:{type:`object`,properties:{}}}})),Bd,Vd=k((()=>{Yee(),Xee(),Zee(),Qee(),$ee(),ete(),tte(),vu(),xu(),Du(),ku(),ju(),Gu(),gd(),wd(),kd(),Id(),zd(),Bd=[au,Mu,ru,iu,Nu,Pu,Td,_d,Fu,bd,Pd,Iu,Sd,su,cu,xd,uu,lu,Au,Ku,qu,Ju,Yu,Xu,Zu,Qu,$u,ed,td,nd,rd,id,ad,od,sd,cd,ld,ud,dd,fd,pd,md,hd,Ed,fu,Dd,Tu,Lu,Rd,Od,vd,gu,ou,hu,Ru,zu,Bu,Ld,Nd,Vu,mu,pu,Eu,Md,Cd,Hu,Uu,bu,yu,Ou,Ad,Fd,_u,yd,du,Wu,jd]})),Hd=k((()=>{Vd()})),Ud,Wd=k((()=>{Ud={id:`__builtin_default`,name:`Default`,providerId:`prompt_api`,enabledToolNames:[`javascript`,`list_files`,`open_file`,`read_file`,`write_file`],customTools:[],systemPromptOverride:"You are a helpful coding assistant.\nContent intended to be rendered as a `Page` (HTML or Markdown) SHOULD include frontmatter (title, created, updated, and slug).\nHTML content intended to be rendered as a `Page` SHOULD USE `<article><h2>${subTitle}</h2>...</article>` for its main body content."}}));function Gd(e,t){if(!t||typeof t!=`object`)throw Error(`Tool at ${e} must be a JSON object`);let n=t,r=typeof n.name==`string`?n.name.trim():``,i=typeof n.description==`string`?n.description.trim():``,a=n.input_schema??n.parameters,o=n.execution??n.evaluation;if(!Jd.test(r))throw Error(`Tool name is invalid: ${r||`(missing)`}`);if(!i)throw Error(`Tool ${r} requires a description`);if(!a||typeof a!=`object`)throw Error(`Tool ${r} requires input_schema`);if(!o||typeof o!=`object`)throw Error(`Tool ${r} requires execution`);let s=o,c=s.type;if(c!==`bash`&&c!==`javascript`&&c!==`tool`)throw Error(`Tool ${r} execution type must be bash, javascript, or tool`);if(c===`tool`){if(typeof s.name!=`string`||!Jd.test(s.name))throw Error(`Tool ${r} execution requires a valid tool name`);return{name:r,description:i,input_schema:a,execution:{type:c,name:s.name,...s.input&&typeof s.input==`object`?{input:s.input}:{}},path:e}}let l=c===`bash`?`command`:`code`,u=s[l]??s.expression;if(typeof u!=`string`||u.trim()===``)throw Error(`Tool ${r} execution requires ${l}`);return{name:r,description:i,input_schema:a,execution:{type:c,[l]:u},path:e}}async function Kd(e,t=dt){let n=[],r=[],i=Jt()||t===`br:main`?[t]:[t,dt];for(let t of i)try{let i=await En(e,t),a=[];async function o(e,t){for await(let[n,r]of e.entries()){let e=`${t}/${n}`;r.kind===`directory`?await o(r,e):n.endsWith(`.json`)&&e.startsWith(`.agents/tools/`)&&a.push(e)}}try{await o(await(await i.getDirectoryHandle(`.agents`)).getDirectoryHandle(`tools`),`.agents/tools`)}catch{continue}let s=a.sort((e,t)=>{let n=!e.startsWith(`.agents/tools/main/`);return n===!t.startsWith(`.agents/tools/main/`)?e.localeCompare(t):n?-1:1});for(let i of s)try{let r=Gd(i,JSON.parse(await qo(e,t,i)));n.some(e=>e.name===r.name)||n.push(r)}catch(e){r.push(e instanceof Error?e.message:String(e))}}catch{}return{tools:n,diagnostics:r}}async function qd(e,t=dt,n){try{let{tools:r}=await Kd(e,t),i=r.find(e=>e.name===n)||null;if(!i)return null;let a=await R(e,L.DECLARATIVE_TOOLS_ENABLED);return Array.isArray(a)&&!a.includes(n)?null:i}catch{return null}}var Jd,Yd=k((()=>{Ot(),Qt(),Gt(),Dn(),Jo(),Jd=/^[a-z][a-z0-9_]{0,63}$/}));async function Xd(e){if(typeof e==`string`)return new TextEncoder().encode(e).buffer;if(typeof Blob<`u`&&e instanceof Blob)return e.arrayBuffer();if(e instanceof ArrayBuffer)return e.slice(0);if(ArrayBuffer.isView(e)){let{buffer:t,byteOffset:n,byteLength:r}=e;return t.slice(n,n+r)}return/* @__PURE__ */ new ArrayBuffer(0)}function Zd(e){return Array.from(new Uint8Array(e)).map(e=>e.toString(16).padStart(2,`0`)).join(``)}async function Qd(e){let t=await Xd(e),r=globalThis.crypto?.subtle??globalThis.window?.crypto?.subtle??(n===void 0?void 0:(await import(`node:crypto`)).webcrypto?.subtle);if(!r)throw Error(`crypto.subtle is not available in current environment`);return Zd(await r.digest(`SHA-256`,t))}var $d=k((()=>{}));function ef(e){try{let t=a(e);return{data:t.data&&typeof t.data==`object`?t.data:{},content:t.content||``}}catch{let t=e.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/);if(t){let e=t[1],n=t[2]||``,r=e.split(/\r?\n/).map(e=>{let t=e.match(/^([a-zA-Z0-9_-]+):\s*(.+)$/);if(t){let[,e,n]=t,r=n.trim();if(r&&r!==`true`&&r!==`false`&&r!==`null`&&!r.startsWith(`"`)&&!r.startsWith(`'`)&&!r.startsWith(`[`)&&!r.startsWith(`{`)&&r!==`>`&&r!==`|`&&r!==`>-`&&r!==`|-`&&!/^-?\d+(?:\.\d+)?$/.test(r))return`${e}: ${JSON.stringify(r)}`}return e});try{let e=`---\n${r.join(`
|
|
249
249
|
`)}\n---\n${n}`,t=a(e);return{data:t.data&&typeof t.data==`object`?t.data:{},content:t.content||``}}catch{}let i={},o=e.match(/^name:\s*["']?([^"'\r\n]+)["']?/m);o&&(i.name=o[1].trim());let s=e.match(/^description:\s*(.+)$/m);if(s){let e=s[1].trim();(e.startsWith(`"`)&&e.endsWith(`"`)||e.startsWith(`'`)&&e.endsWith(`'`))&&(e=e.slice(1,-1)),i.description=e}let c=e.match(/^user-invocable:\s*(true|false)/im);c&&(i[`user-invocable`]=c[1].toLowerCase()===`true`);let l=e.match(/^disable-model-invocation:\s*(true|false)/im);l&&(i[`disable-model-invocation`]=l[1].toLowerCase()===`true`);let u=e.match(/^allowed-tools:\s*["']?([^"'\r\n]+)["']?/m);u&&(i[`allowed-tools`]=u[1].trim());let d=e.match(/allowed-tools:\s*\n((?:\s*-\s*[^\r\n]+\r?\n?)+)/m);if(d){let e=d[1].split(/\r?\n/).map(e=>e.replace(/^\s*-\s*/,``).trim()).filter(Boolean);e.length>0&&(i[`allowed-tools`]=e)}return{data:i,content:n}}return{data:{},content:e}}}function tf(e){if(typeof e==`string`){let t=e.trim();return t.length>0?t:void 0}if(Array.isArray(e)){let t=e.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(e=>e.length>0);return t.length>0?t.join(` `):void 0}}function nf(e,t){let n=ef(t),r=n.data,i=typeof r.name==`string`?r.name.trim():``,a=typeof r.description==`string`?r.description.trim():``;if(!i)throw Error(`Skill at ${e} requires a name`);if(!a)throw Error(`Skill ${i} requires a description`);if(i.length>64||!rf.test(i))throw Error(`Skill name must be 1-64 lowercase characters and hyphens: ${i}`);if(a.length>1024)throw Error(`Skill ${i} description must be 1024 characters or fewer`);let o=e.replace(/\/SKILL\.md$/u,``),s=r.metadata&&typeof r.metadata==`object`?r.metadata:void 0,c=tf(s?.[`allowed-tools`])||tf(s?.allowedTools)||tf(r[`allowed-tools`])||tf(r.allowedTools),l=[];if(s){for(let[e,t]of Object.entries(s))if(e!==`execution`&&t!=null){if(e===`allowed-tools`||e===`allowedTools`)c&&l.push([e,c]);else if(typeof t==`string`||typeof t==`number`||typeof t==`boolean`)l.push([e,String(t)]);else if(Array.isArray(t)){let n=t.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(Boolean);n.length>0&&l.push([e,n.join(` `)])}}}let u=l.length>0?Object.fromEntries(l):void 0,d=s?.execution,f;if(d!==void 0){if(!d||typeof d!=`object`||d.type!==`tools`||!Array.isArray(d.tools))throw Error(`Skill ${i} has invalid tools execution`);let e=d,t=typeof e.suppressToast==`boolean`?e.suppressToast:void 0,n=typeof e.suppressOutput==`boolean`?e.suppressOutput:void 0,r=e.tools.map(e=>({...e,...t!==void 0&&e.suppressToast===void 0?{suppressToast:t}:{},...n!==void 0&&e.suppressOutput===void 0?{suppressOutput:n}:{}}));f={type:`tools`,...t===void 0?{}:{suppressToast:t},...n===void 0?{}:{suppressOutput:n},tools:r}}return{name:i,description:a,...typeof r.license==`string`?{license:r.license}:{},...typeof r.compatibility==`string`?{compatibility:r.compatibility}:{},...u?{metadata:u}:{},...typeof c==`string`?{allowedTools:c}:{},...typeof r[`user-invocable`]==`boolean`?{userInvocable:r[`user-invocable`]}:typeof r[`user-invocable`]==`string`&&(r[`user-invocable`].toLowerCase()===`true`||r[`user-invocable`].toLowerCase()===`false`)?{userInvocable:r[`user-invocable`].toLowerCase()===`true`}:{},...typeof r[`disable-model-invocation`]==`boolean`?{disableModelInvocation:r[`disable-model-invocation`]}:typeof r[`disable-model-invocation`]==`string`&&(r[`disable-model-invocation`].toLowerCase()===`true`||r[`disable-model-invocation`].toLowerCase()===`false`)?{disableModelInvocation:r[`disable-model-invocation`].toLowerCase()===`true`}:{},...f?{execution:f}:{},body:n.content.trim(),path:e,basePath:o}}var rf,af=k((()=>{rf=/^[a-z0-9](?:[a-z0-9]|-(?!-))*[a-z0-9]$|^[a-z0-9]$/}));function of(e){let t=e.trim().replace(/\/+$/,``);if(!t)return null;let n=t.match(/^https?:\/\/github\.com\/([a-zA-Z0-9_.-]+)\/([a-zA-Z0-9_.-]+?)(?:\.git)?(?:\/tree\/([^/]+)(?:\/(.+))?)?(?:@([a-zA-Z0-9_.-]+))?$/i);if(n)return{owner:n[1],repo:n[2],ref:n[3]||`HEAD`,subpath:n[4],skillFilter:n[5]};if(!t.includes(`://`)){let e=t.match(/^([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_.-]+?)(?:@([a-zA-Z0-9_.-]+))?$/);if(e&&!e[1].includes(`.`))return{owner:e[1],repo:e[2],ref:`HEAD`,skillFilter:e[3]}}return null}function sf(e){let t=e.trim();if(!t)throw Error(`URL cannot be empty`);let n=t;!n.startsWith(`http://`)&&!n.startsWith(`https://`)&&(n=`https://${n}`),n=n.replace(/\/+$/,``);let r=n.match(/^https?:\/\/github\.com\/([^/]+)\/([^/]+)\/blob\/([^/]+)\/(.+\/skill\.md)$/i);if(r&&(n=`https://raw.githubusercontent.com/${r[1]}/${r[2]}/${r[3]}/${r[4]}`),/\/skill\.md$/i.test(n)){let e=n.replace(/\/skill\.md$/i,``);return{baseUrl:e,siteUrl:e,manifestUrl:n}}if(n.endsWith(mf)){let e=n.slice(0,-35).replace(/\/+$/,``);return{baseUrl:e,siteUrl:e,manifestUrl:n}}return{baseUrl:n,siteUrl:n,manifestUrl:`${n}/${mf}`}}function cf(e,t){if(!e)return``;try{return new URL(e,t).href}catch{return e}}function lf(e,t){let n=JSON.parse(JSON.stringify(e));return Array.isArray(n.tools)&&(n.tools=n.tools.map(e=>({...e,url:cf(e.url,t)}))),Array.isArray(n.scripts)&&(n.scripts=n.scripts.map(e=>({...e,url:cf(e.url,t)}))),Array.isArray(n.skills)&&(n.skills=n.skills.map(e=>({...e,url:cf(e.url,t),tools:Array.isArray(e.tools)?e.tools.map(e=>({...e,url:e.url?cf(e.url,t):void 0})):void 0,scripts:Array.isArray(e.scripts)?e.scripts.map(e=>({...e,url:e.url?cf(e.url,t):void 0})):void 0}))),n}async function uf(e,t){if(!t||!t.startsWith(`sha256:`))return!0;let n=t.slice(7).trim().toLowerCase();return!n||(await Qd(typeof e==`string`?new TextEncoder().encode(e):e)).toLowerCase()===n}async function df(e,t,n,r){let i=nf(e,n),a={name:i.name,type:`skill-md`,description:i.description,url:e,...r&&r.length>0?{files:r}:{}};return{manifest:{name:i.name,description:i.description,skills:[a]},siteUrl:t,manifestUrl:e}}async function ff(e,t){let n=`https://raw.githubusercontent.com/${e.owner}/${e.repo}/${e.ref}`,r=`https://github.com/${e.owner}/${e.repo}`;if(e.subpath){let r=e.subpath.replace(/^\/+|\/+$/g,``).replace(/\/skill\.md$/i,``),i=`${n}/${r}/SKILL.md`,a=await t(i);if(!a.ok)throw Error(`Failed to fetch discovery manifest: HTTP ${a.status} ${a.statusText||``}`.trim());return df(i,`${n}/${r}`,await a.text())}if(e.skillFilter){let r=[`skills/${e.skillFilter}/SKILL.md`,`.agents/skills/${e.skillFilter}/SKILL.md`,`.agents/skills/main/${e.skillFilter}/SKILL.md`,`${e.skillFilter}/SKILL.md`];for(let e of r){let r=`${n}/${e}`,i=await t(r);if(i.ok)return df(r,r.replace(/\/skill\.md$/i,``),await i.text())}throw Error(`Failed to fetch skill "${e.skillFilter}" from ${e.owner}/${e.repo}`)}let i=`${n}/${mf}`;try{let e=await t(i,{headers:{Accept:`application/json`}});if(e.ok){let t=await e.json();if(t&&typeof t==`object`)return{manifest:lf(t,i),siteUrl:n,manifestUrl:i}}}catch{}let a=`https://api.github.com/repos/${e.owner}/${e.repo}/git/trees/${e.ref}?recursive=1`;try{let i=await t(a,{headers:{Accept:`application/vnd.github+json`}});if(i.ok){let o=((await i.json())?.tree||[]).filter(e=>e?.type===`blob`&&typeof e.path==`string`).map(e=>e.path),s=o.filter(e=>e===`SKILL.md`||e.endsWith(`/SKILL.md`));if(s.length>0){let i=[];for(let e of s){let r=e===`SKILL.md`?``:e.slice(0,-9),a=r?`${r}/`:``,s=o.filter(t=>(r?t.startsWith(a):!t.includes(`/`))&&t!==e).map(e=>r?e.slice(a.length):e),c=`${n}/${e}`,l=await t(c);if(!l.ok)continue;let u=await l.text();try{let t=nf(e,u);i.push({name:t.name,type:`skill-md`,description:t.description,url:c,...s.length>0?{files:[`SKILL.md`,...s]}:{}})}catch{}}if(i.length>0)return{manifest:{name:`${e.owner}/${e.repo}`,description:`Agent skills from ${e.owner}/${e.repo}`,skills:i},siteUrl:r,manifestUrl:a}}}}catch{}let o=`${n}/SKILL.md`,s=await t(o);if(s.ok)return df(o,n,await s.text());throw Error(`Failed to fetch discovery manifest from GitHub repository ${e.owner}/${e.repo}`)}async function pf(e,t=globalThis.fetch){let n=of(e);if(n)return ff(n,t);let{baseUrl:r,manifestUrl:i}=sf(e);if(/\/skill\.md$/i.test(i)){let e=await t(i);if(!e.ok)throw Error(`Failed to fetch discovery manifest: HTTP ${e.status} ${e.statusText}`.trim());return df(i,r,await e.text())}let a=await t(i,{headers:{Accept:`application/json`}});if(!a.ok)throw Error(`Failed to fetch discovery manifest: HTTP ${a.status} ${a.statusText}`.trim());let o=await a.json();if(!o||typeof o!=`object`)throw Error(`Invalid discovery manifest: expected a JSON object`);return{manifest:lf(o,i),siteUrl:r,manifestUrl:i}}var mf,hf=k((()=>{$d(),af(),mf=`.well-known/agent-skills/index.json`}));function gf(e,t){return t?.targetSubdir?`.agents/${e}/${t.targetSubdir}`:t?.siteSlug?`.agents/${e}/imported/${t.siteSlug}`:`.agents/${e}`}async function _f(e,t=dt,n,r){let i=(n.name||``).trim();if(xf.has(i))return{name:i,path:``,status:`failed`,error:`Cannot shadow built-in tool: ${i}`};if(!Sf.test(i))return{name:i,path:``,status:`failed`,error:`Invalid tool name: ${i}`};let a=`${gf(`tools`,r)}/${i}.json`;try{if(await Yo(e,t,a)&&!r?.overwrite)return{name:i,path:a,status:`skipped`};let o=await(r?.fetchFn||globalThis.fetch)(n.url);if(!o.ok)return{name:i,path:a,status:`failed`,error:`HTTP ${o.status} ${o.statusText}`};let s=await o.text();if(n.digest&&!await uf(s,n.digest))return{name:i,path:a,status:`failed`,error:`Integrity verification failed for tool definition`};let c;try{c=JSON.parse(s)}catch{return{name:i,path:a,status:`failed`,error:`Downloaded tool definition is not valid JSON`}}if(Gd(a,c),await Ho(e,t,a,JSON.stringify(c,null,2)),r?.autoEnable){let t=await R(e,L.DECLARATIVE_TOOLS_ENABLED),n=new Set(Array.isArray(t)?t:[]);n.add(i),await B(e,L.DECLARATIVE_TOOLS_ENABLED,Array.from(n))}return{name:i,path:a,status:`imported`}}catch(e){return{name:i,path:a,status:`failed`,error:e instanceof Error?e.message:String(e)}}}async function vf(e,t=dt,n,r){let i=(n.name||``).trim(),a=i.endsWith(`.js`)||i.endsWith(`.mjs`)?i:`${i}.js`,o=`${gf(`scripts`,r)}/${a}`;try{if(await Yo(e,t,o)&&!r?.overwrite)return{name:i,path:o,status:`skipped`};let a=await(r?.fetchFn||globalThis.fetch)(n.url);if(!a.ok)return{name:i,path:o,status:`failed`,error:`HTTP ${a.status} ${a.statusText}`};let s=await a.text();return n.digest&&!await uf(s,n.digest)?{name:i,path:o,status:`failed`,error:`Integrity verification failed for script`}:(await Ho(e,t,o,s),{name:i,path:o,status:`imported`})}catch(e){return{name:i,path:o,status:`failed`,error:e instanceof Error?e.message:String(e)}}}async function yf(e,t=dt,n,r){let i=(n.name||``).trim(),a=`${gf(`skills`,r)}/${i}`,o=`${a}/SKILL.md`;try{if(await Yo(e,t,o)&&!r?.overwrite)return{name:i,path:o,status:`skipped`};let s=r?.fetchFn||globalThis.fetch,c=await s(n.url);if(!c.ok)return{name:i,path:o,status:`failed`,error:`HTTP ${c.status} ${c.statusText}`};let l=await c.text();if(n.digest&&!await uf(l,n.digest))return{name:i,path:o,status:`failed`,error:`Integrity verification failed for skill`};if(nf(o,l),await Ho(e,t,o,l),Array.isArray(n.files)&&n.files.length>0){let r=n.url.replace(/\/skill\.md$/i,`/`);for(let i of n.files){if(typeof i!=`string`)continue;let n=i.replace(/^\/+/,``).replace(/\\/g,`/`);if(n&&n.toLowerCase()!==`skill.md`&&!n.split(`/`).some(e=>e===`..`||e===`.`))try{let i=new URL(n,r.endsWith(`/`)?r:`${r}/`).href,o=await s(i);if(o.ok){let r=await o.text();await Ho(e,t,`${a}/${n}`,r)}}catch{}}}return{name:i,path:o,status:`imported`}}catch(e){return{name:i,path:o,status:`failed`,error:e instanceof Error?e.message:String(e)}}}async function bf(e,t=dt,n,r,i){let a={tools:[],skills:[],scripts:[],diagnostics:[]},o=new Set(r.toolNames||[]),s=new Set(r.skillNames||[]),c=new Set(r.scriptNames||[]),l=n.tools||[],u=n.skills||[],d=n.scripts||[];for(let e of u)if(s.has(e.name)){if(Array.isArray(e.tools))for(let t of e.tools)o.add(t.name);if(Array.isArray(e.scripts))for(let t of e.scripts)c.add(t.name)}for(let n of d)if(c.has(n.name)){let r=await vf(e,t,n,i);a.scripts.push(r),r.status===`failed`&&r.error&&a.diagnostics.push(`Script ${n.name}: ${r.error}`)}for(let n of l)if(o.has(n.name)){let r=await _f(e,t,n,i);a.tools.push(r),r.status===`failed`&&r.error&&a.diagnostics.push(`Tool ${n.name}: ${r.error}`)}for(let n of u)if(s.has(n.name)){let r=await yf(e,t,n,i);a.skills.push(r),r.status===`failed`&&r.error&&a.diagnostics.push(`Skill ${n.name}: ${r.error}`)}return a}var xf,Sf,Cf=k((()=>{Ot(),Gt(),Wo(),Uo(),Xo(),Yd(),Hd(),af(),hf(),xf=new Set(Bd.map(e=>e.name)),Sf=/^[a-z][a-z0-9_]{0,63}$/})),wf,Tf,Ef=k((()=>{Xs(),Ot(),Gt(),Wo(),Hd(),Wd(),Yd(),hf(),Cf(),wf=class{_activeProfile;_activeProfileId;_allTools;_customTools;_declarativeTools;_declarativeToolNamesEnabled;_enabledDeclarativeTools;_enabledToolNames;_enabledTools;_profiles;_systemPromptOverride;_webSearchProxyUrl;_webSearchUrl;_webSearchUseProxy;_searchFilesMaxFileBytes;_searchFilesMaxFilesVisited;_searchFilesSkipDirs;constructor(){this._enabledToolNames=new Ys.State(new Set(Ud.enabledToolNames)),this._customTools=new Ys.State([]),this._declarativeTools=new Ys.State([]),this._declarativeToolNamesEnabled=new Ys.State(null),this._systemPromptOverride=new Ys.State(``),this._profiles=new Ys.State([]),this._activeProfileId=new Ys.State(Ud.id),this._webSearchUseProxy=new Ys.State(!1),this._webSearchProxyUrl=new Ys.State(`/proxy`),this._webSearchUrl=new Ys.State(`https://html.duckduckgo.com/html/?q={query}`),this._searchFilesMaxFileBytes=new Ys.State(524288),this._searchFilesMaxFilesVisited=new Ys.State(1e3),this._searchFilesSkipDirs=new Ys.State(`.git,node_modules,dist,dist-electron,.cache,.nx,.turbo,__pycache__,.venv,venv`),this._allTools=new Ys.Computed(()=>[...Bd,...this._customTools.get()]),this._enabledTools=new Ys.Computed(()=>{let e=this._enabledToolNames.get();return this._allTools.get().filter(t=>e.has(t.name))}),this._enabledDeclarativeTools=new Ys.Computed(()=>{let e=this._declarativeTools.get(),t=this._declarativeToolNamesEnabled.get();return!t||t.size===0?[]:e.filter(e=>t.has(e.name))}),this._activeProfile=new Ys.Computed(()=>{let e=this._activeProfileId.get();return e?Ud.id===e?Ud:this._profiles.get().find(t=>t.id===e)||null:null})}get activeProfile(){return this._activeProfile.get()}get activeProfileId(){return this._activeProfileId.get()}get allTools(){return this._allTools.get()}get customTools(){return this._customTools.get()}get declarativeTools(){return this._declarativeTools.get()}get declarativeToolNamesEnabled(){return this._declarativeToolNamesEnabled.get()}get enabledDeclarativeTools(){return this._enabledDeclarativeTools.get()}get enabledToolNames(){return this._enabledToolNames.get()}get enabledTools(){return this._enabledTools.get()}isDeclarativeToolEnabled(e){let t=this._declarativeToolNamesEnabled.get();return t?t.has(e):!1}async refreshDeclarativeTools(e,t){try{let n=await Kd(e,t||`br:main`),r=this.allTools,i=(n?.tools||[]).filter(e=>!r.some(t=>t.name===e.name)),a=this._declarativeTools.get();return a.length===i.length&&a.every((e,t)=>e.name===i[t].name&&e.description===i[t].description&&JSON.stringify(e.execution)===JSON.stringify(i[t].execution))||this._declarativeTools.set(i),i}catch{return this._declarativeTools.get().length>0&&this._declarativeTools.set([]),[]}}async setDeclarativeToolEnabled(e,t,n){let r=this._declarativeToolNamesEnabled.get(),i=new Set(r===null?[]:r);n?i.add(t):i.delete(t),this._declarativeToolNamesEnabled.set(i),await B(e,L.DECLARATIVE_TOOLS_ENABLED,Array.from(i))}async setAllDeclarativeEnabled(e,t){let n=new Set(t);this._declarativeToolNamesEnabled.set(n),await B(e,L.DECLARATIVE_TOOLS_ENABLED,t)}async fetchRemoteDiscoveryManifest(e){return await pf(e)}async importFromRemoteSite(e,t,n,r){let i=r?.groupId||`br:main`,a=await bf(e,i,t,n,r);return await this.refreshDeclarativeTools(e,i),a}exportBackup(){return JSON.stringify({enabledTools:[...this._enabledToolNames.get()],customTools:this._customTools.get(),declarativeToolsEnabled:this._declarativeToolNamesEnabled.get()?Array.from(this._declarativeToolNamesEnabled.get()):null,systemPromptOverride:this._systemPromptOverride.get(),profiles:this._profiles.get(),activeProfileId:this._activeProfileId.get(),webSearchUseProxy:this._webSearchUseProxy.get(),webSearchProxyUrl:this._webSearchProxyUrl.get(),webSearchUrl:this._webSearchUrl.get(),searchFilesMaxFileBytes:this._searchFilesMaxFileBytes.get(),searchFilesMaxFilesVisited:this._searchFilesMaxFilesVisited.get(),searchFilesSkipDirs:this._searchFilesSkipDirs.get()},null,2)}findProfilesForProvider(e,t){return this.profiles.filter(n=>!(n.providerId&&n.providerId!==e||n.model&&n.model!==t))}get profiles(){return[Ud,...this._profiles.get()]}get systemPromptOverride(){return this._systemPromptOverride.get()}get webSearchProxyUrl(){return this._webSearchProxyUrl.get()}get webSearchUrl(){return this._webSearchUrl.get()}get webSearchUseProxy(){return this._webSearchUseProxy.get()}get searchFilesMaxFileBytes(){return this._searchFilesMaxFileBytes.get()}get searchFilesMaxFilesVisited(){return this._searchFilesMaxFilesVisited.get()}get searchFilesSkipDirs(){return this._searchFilesSkipDirs.get()}get searchFilesSkipDirsSet(){return new Set(this._searchFilesSkipDirs.get().split(`,`).map(e=>e.trim()).filter(Boolean))}async activateProfile(e,t){let n=this.profiles.find(e=>e.id===t);n&&(this._activeProfileId.set(t),this._enabledToolNames.set(new Set(n.enabledToolNames)),this._customTools.set(n.customTools),this._systemPromptOverride.set(n.systemPromptOverride||``),await Promise.all([B(e,L.ACTIVE_TOOL_PROFILE,t),B(e,L.ENABLED_TOOLS,n.enabledToolNames),B(e,L.CUSTOM_TOOLS,n.customTools),B(e,L.SYSTEM_PROMPT_OVERRIDE,n.systemPromptOverride||``)]))}async addCustomTool(e,t){let n=[...this._customTools.get(),t];this._customTools.set(n);let r=new Set(this._enabledToolNames.get());r.add(t.name),this._enabledToolNames.set(r),await Promise.all([B(e,L.CUSTOM_TOOLS,n),B(e,L.ENABLED_TOOLS,[...r])])}async addProfile(e,t){let n=[...this._profiles.get(),t];this._profiles.set(n),await B(e,L.TOOL_PROFILES,n)}async cloneTool(e,t,n,r){let i=this.allTools.find(e=>e.name===t);if(!i||this.allTools.some(e=>e.name===n))return!1;let a={name:n,description:r||i.description,input_schema:JSON.parse(JSON.stringify(i.input_schema))};return await this.addCustomTool(e,a),!0}async deactivateProfile(e){this._activeProfileId.set(null),await B(e,L.ACTIVE_TOOL_PROFILE,null)}async deleteProfile(e,t){if(t===Ud.id)return;let n=this._profiles.get().filter(e=>e.id!==t);this._profiles.set(n),this._activeProfileId.get()===t&&(this._activeProfileId.set(null),await B(e,L.ACTIVE_TOOL_PROFILE,null)),await B(e,L.TOOL_PROFILES,n)}async importBackup(e,t){let n=JSON.parse(t);Array.isArray(n.enabledTools)&&(this._enabledToolNames.set(new Set(n.enabledTools)),await B(e,L.ENABLED_TOOLS,n.enabledTools)),Array.isArray(n.customTools)&&(this._customTools.set(n.customTools),await B(e,L.CUSTOM_TOOLS,n.customTools)),typeof n.systemPromptOverride==`string`&&(this._systemPromptOverride.set(n.systemPromptOverride),await B(e,L.SYSTEM_PROMPT_OVERRIDE,n.systemPromptOverride)),Array.isArray(n.profiles)&&(this._profiles.set(n.profiles),await B(e,L.TOOL_PROFILES,n.profiles)),(typeof n.activeProfileId==`string`||n.activeProfileId===null)&&(this._activeProfileId.set(n.activeProfileId),await B(e,L.ACTIVE_TOOL_PROFILE,n.activeProfileId)),typeof n.webSearchUseProxy==`boolean`&&(this._webSearchUseProxy.set(n.webSearchUseProxy),await B(e,L.WEB_SEARCH_USE_PROXY,n.webSearchUseProxy?`true`:`false`)),typeof n.webSearchProxyUrl==`string`&&(this._webSearchProxyUrl.set(n.webSearchProxyUrl),await B(e,L.WEB_SEARCH_PROXY_URL,n.webSearchProxyUrl)),typeof n.webSearchUrl==`string`&&(this._webSearchUrl.set(n.webSearchUrl),await B(e,L.WEB_SEARCH_URL,n.webSearchUrl)),typeof n.searchFilesMaxFileBytes==`number`&&n.searchFilesMaxFileBytes>0&&(this._searchFilesMaxFileBytes.set(n.searchFilesMaxFileBytes),await B(e,L.SEARCH_FILES_MAX_FILE_BYTES,String(n.searchFilesMaxFileBytes))),typeof n.searchFilesMaxFilesVisited==`number`&&n.searchFilesMaxFilesVisited>0&&(this._searchFilesMaxFilesVisited.set(n.searchFilesMaxFilesVisited),await B(e,L.SEARCH_FILES_MAX_FILES_VISITED,String(n.searchFilesMaxFilesVisited))),typeof n.searchFilesSkipDirs==`string`&&(this._searchFilesSkipDirs.set(n.searchFilesSkipDirs),await B(e,L.SEARCH_FILES_SKIP_DIRS,n.searchFilesSkipDirs)),Array.isArray(n.declarativeToolsEnabled)?(this._declarativeToolNamesEnabled.set(new Set(n.declarativeToolsEnabled)),await B(e,L.DECLARATIVE_TOOLS_ENABLED,n.declarativeToolsEnabled)):n.declarativeToolsEnabled===null&&(this._declarativeToolNamesEnabled.set(null),await B(e,L.DECLARATIVE_TOOLS_ENABLED,null))}async load(e){let[t,n,r,i,a,o,s,c,l,u,d,f]=await Promise.all([R(e,L.ENABLED_TOOLS),R(e,L.CUSTOM_TOOLS),R(e,L.SYSTEM_PROMPT_OVERRIDE),R(e,L.TOOL_PROFILES),R(e,L.ACTIVE_TOOL_PROFILE),R(e,L.WEB_SEARCH_USE_PROXY),R(e,L.WEB_SEARCH_PROXY_URL),R(e,L.WEB_SEARCH_URL),R(e,L.SEARCH_FILES_MAX_FILE_BYTES),R(e,L.SEARCH_FILES_MAX_FILES_VISITED),R(e,L.SEARCH_FILES_SKIP_DIRS),R(e,L.DECLARATIVE_TOOLS_ENABLED)]);if(Array.isArray(t)&&this._enabledToolNames.set(new Set(t)),Array.isArray(n)&&this._customTools.set(n),Array.isArray(f)&&this._declarativeToolNamesEnabled.set(new Set(f)),typeof r==`string`&&this._systemPromptOverride.set(r),Array.isArray(i)&&this._profiles.set(i),typeof a==`string`&&this._activeProfileId.set(a),o!=null){let e=String(o).toLowerCase();this._webSearchUseProxy.set(e===`true`||e===`1`)}if(typeof s==`string`&&s.trim().length>0&&this._webSearchProxyUrl.set(s.trim()),typeof c==`string`&&c.trim().length>0&&this._webSearchUrl.set(c.trim()),l!=null){let e=Number(l);Number.isFinite(e)&&e>0&&this._searchFilesMaxFileBytes.set(e)}if(u!=null){let e=Number(u);Number.isFinite(e)&&e>0&&this._searchFilesMaxFilesVisited.set(e)}typeof d==`string`&&d.trim().length>0&&this._searchFilesSkipDirs.set(d.trim())}async setWebSearchProxyUrl(e,t){let n=t.trim()||`/proxy`;this._webSearchProxyUrl.set(n),await B(e,L.WEB_SEARCH_PROXY_URL,n)}async setWebSearchUrl(e,t){let n=t.trim()||`https://html.duckduckgo.com/html/?q={query}`;this._webSearchUrl.set(n),await B(e,L.WEB_SEARCH_URL,n)}async setWebSearchUseProxy(e,t){let n=!!t;this._webSearchUseProxy.set(n),await B(e,L.WEB_SEARCH_USE_PROXY,n?`true`:`false`)}async setSearchFilesMaxFileBytes(e,t){let n=Math.max(1,Math.round(t));this._searchFilesMaxFileBytes.set(n),await B(e,L.SEARCH_FILES_MAX_FILE_BYTES,String(n))}async setSearchFilesMaxFilesVisited(e,t){let n=Math.max(1,Math.round(t));this._searchFilesMaxFilesVisited.set(n),await B(e,L.SEARCH_FILES_MAX_FILES_VISITED,String(n))}async setSearchFilesSkipDirs(e,t){let n=t.trim();this._searchFilesSkipDirs.set(n),await B(e,L.SEARCH_FILES_SKIP_DIRS,n)}async removeCustomTool(e,t){let n=this._customTools.get().filter(e=>e.name!==t);this._customTools.set(n);let r=new Set(this._enabledToolNames.get());r.delete(t),this._enabledToolNames.set(r),await Promise.all([B(e,L.CUSTOM_TOOLS,n),B(e,L.ENABLED_TOOLS,[...r])])}async saveToActiveProfile(e){let t=this._activeProfileId.get();if(!t)return;let n=this._profiles.get().find(e=>e.id===t);if(!n)return;let r={...n,enabledToolNames:[...this._enabledToolNames.get()],customTools:[...this._customTools.get()],systemPromptOverride:this._systemPromptOverride.get()};await this.updateProfile(e,r)}async setAllEnabled(e,t){this._enabledToolNames.set(new Set(t));let n=[B(e,L.ENABLED_TOOLS,t)];this._activeProfileId.get()&&(this._activeProfileId.set(null),n.push(B(e,L.ACTIVE_TOOL_PROFILE,null))),await Promise.all(n)}async setSystemPromptOverride(e,t){this._systemPromptOverride.set(t),await B(e,L.SYSTEM_PROMPT_OVERRIDE,t)}async setToolEnabled(e,t,n){let r=new Set(this._enabledToolNames.get());n?r.add(t):r.delete(t),this._enabledToolNames.set(r);let i=[B(e,L.ENABLED_TOOLS,[...r])];this._activeProfileId.get()&&(this._activeProfileId.set(null),i.push(B(e,L.ACTIVE_TOOL_PROFILE,null))),await Promise.all(i)}async updateProfile(e,t){let n=this._profiles.get().map(e=>e.id===t.id?t:e);this._profiles.set(n),await B(e,L.TOOL_PROFILES,n)}},Tf=new wf}));function Df(e,t,n){let r=(t||``).toLowerCase();return r?n&&(r.includes(`api key not configured`)||r.includes(`go to settings to add your api key`)||r.includes(`missing api key`)||r.includes(`no api key`))?`api-key-missing`:n&&(r.includes(`invalid api key`)||r.includes(`incorrect api key`)||r.includes(`authentication failed`)||r.includes(`401`)||r.includes(`403`)||r.includes(`unauthorized`)||r.includes(`forbidden`))?`api-key-invalid`:r.includes(`429`)||r.includes(`rate limit`)||r.includes(`too many requests`)?`rate-limited`:r.includes(`failed to fetch`)||r.includes(`networkerror`)||r.includes(`network error`)||r.includes(`econnrefused`)||r.includes(`connection refused`)||r.includes(`enotfound`)||r.includes(`timed out`)||r.includes(`timeout`)||r.includes(`503`)||r.includes(`502`)?`provider-unreachable`:null:null}var Of=k((()=>{Ot()}));function nte(e){if(typeof e.size==`number`&&e.size>0)return e.size;if(typeof e.data==`string`&&e.data.length>0){let t=e.data.endsWith(`==`)?2:+!!e.data.endsWith(`=`);return Math.max(0,Math.floor(e.data.length*3/4)-t)}return 0}function rte(e){return e?e.startsWith(`text/`)||e===`json`||e===`xml`||e===`javascript`||e===`csv`||e===`markdown`:!1}function ite(e){let t=nte(e);if(t===0)return 0;switch(e.mediaType){case`image`:return Nf;case`audio`:return Pf;case`video`:return Ff;default:return rte(e.mimeType)?Math.ceil(t/jf):Math.ceil(t/If)}}function kf(e){return e?Math.ceil(e.length/jf):0}function Af(e){let t=0;if(typeof e.content==`string`)t=kf(e.content);else if(Array.isArray(e.content))for(let n of e.content)if(n.type===`text`&&n.text)t+=kf(n.text);else if(n.type===`tool_use`)t+=kf(n.name),t+=kf(JSON.stringify(n.input));else if(n.type===`tool_result`){let e=n.content;t+=kf(typeof e==`string`?e:JSON.stringify(e))}else n.type===`attachment`&&(t+=kf(n.fileName),t+=kf(n.mimeType),t+=kf(n.path),t+=ite(n));return t+Mf}var jf,Mf,Nf,Pf,Ff,If,Lf=k((()=>{jf=4,Mf=4,Nf=1500,Pf=1500,Ff=2500,If=16}));function ate(e,t){if(!e)return``;if(e.length<=t)return e;let n=e.slice(0,t).lastIndexOf(`
|
|
250
|
-
`),r=n>t*.5?n:t;return`${e.slice(0,r)}\n[...truncated ${e.length-r} chars]`}var ote=k((()=>{}));function Rf(e,t){let{contextLimit:n,systemPromptTokens:r,maxOutputTokens:i,skimTop:a=!1}=t;if(e.length===0)return{messages:[],estimatedTokens:0,truncatedCount:0,contextLimit:n,usagePercent:0};let o=Math.max(0,n-r-i),s=Math.min(zf,Math.max(1e3,Math.floor(o*.6*4))),c=e.map(e=>ste(e,s)),l=0,u=c.length,d=null,f=0;if(a&&c.length>0){let e=c[0];(e.role===`user`||e.role===`system`)&&(f=Af(e),f<=o&&(d=e))}let p=o-f;for(let e=c.length-1;e>=+!!d;e--){let t=Af(c[e]),n=c[e],r=!1;if(n.role===`user`&&Array.isArray(n.content)&&n.content.some(e=>e.type===`tool_result`)){let n=c[e-1];n&&n.role===`assistant`&&Array.isArray(n.content)&&n.content.some(e=>e.type===`tool_use`)&&(r=!0,t+=Af(n))}if(l+t>p&&e<c.length-1)break;l+=t,r?(u=e-1,e--):u=e}let m=c.slice(u),h=u;d&&u>0&&(m=[d,...m],h=Math.max(0,u-1));let g=l+f,_=g+r,v=n>0?Math.round(_/n*100*10)/10:0;return{messages:m,estimatedTokens:g,truncatedCount:h,contextLimit:n,usagePercent:v}}function ste(e,t){if(!Array.isArray(e.content))return e;let n=e.content.map(e=>e.type===`tool_result`&&typeof e.content==`string`?{...e,content:ate(e.content,t)}:e);return{...e,content:n}}var zf,Bf=k((()=>{Lf(),ote(),zf=25e3}));function Vf(e){let t=``,n=32768;for(let r=0;r<e.length;r+=n){let i=e.subarray(r,r+n);t+=String.fromCharCode(...i)}return btoa(t)}function cte(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}var Hf=k((()=>{}));function Uf(e){return e&&(e.split(/[?#]/,1)[0].replace(/\\/g,`/`).split(`/`).pop()||``).toLowerCase().split(`.`).pop()||``}function Wf(e,t){let n=Uf(e);return qf[n]??t}function Gf(e){let t=Uf(e);return Kf[t]||null}function lte(e){return Gf(e)!==null}function ute(e){let t=Uf(e);if(t===`md`||t===`markdown`||t===`txt`)return`text/plain`;if(t===`pdf`)return`application/pdf`;if(Kf[t])return Kf[t]}var Kf,qf,Jf=k((()=>{Kf={apng:`image/apng`,avif:`image/avif`,bmp:`image/bmp`,gif:`image/gif`,heic:`image/heic`,heif:`image/heif`,ico:`image/x-icon`,jpeg:`image/jpeg`,jpg:`image/jpeg`,png:`image/png`,svg:`image/svg+xml`,tif:`image/tiff`,tiff:`image/tiff`,webp:`image/webp`},qf={...Kf,"3gp":`video/3gpp`,aac:`audio/aac`,avi:`video/x-msvideo`,bin:`application/octet-stream`,css:`text/css`,csv:`text/csv`,db:`application/vnd.sqlite3`,dll:`application/octet-stream`,dmg:`application/octet-stream`,dylib:`application/octet-stream`,exe:`application/vnd.microsoft.portable-executable`,flac:`audio/flac`,flv:`video/x-flv`,gz:`application/gzip`,htm:`text/html`,html:`text/html`,iso:`application/octet-stream`,js:`text/javascript`,json:`application/json`,m4a:`audio/mp4`,m4v:`video/mp4`,markdown:`text/markdown`,md:`text/markdown`,mjs:`text/javascript`,mkv:`video/x-matroska`,mov:`video/mp4`,mp3:`audio/mpeg`,mp4:`video/mp4`,oga:`audio/ogg`,ogg:`audio/ogg`,ogv:`video/ogg`,pdf:`application/pdf`,rar:`application/vnd.rar`,so:`application/octet-stream`,sqlite:`application/vnd.sqlite3`,sqlite3:`application/vnd.sqlite3`,tar:`application/x-tar`,ts:`text/typescript`,tsx:`text/typescript`,txt:`text/plain`,wasm:`application/wasm`,wav:`audio/wav`,weba:`audio/webm`,webm:`video/webm`,wmv:`video/x-ms-wmv`,xml:`application/xml`,yaml:`text/yaml`,yml:`text/yaml`,zip:`application/zip`}}));function dte(e=``,t=``){let n=(e&&e!==`application/octet-stream`?e:Wf(t)||e).toLowerCase(),r=t.toLowerCase();return n.startsWith(`text/`)||n.includes(`json`)||n.includes(`xml`)||r.endsWith(`.md`)||r.endsWith(`.txt`)?`text`:n.startsWith(`image/`)?`image`:n.startsWith(`audio/`)?`audio`:n.startsWith(`video/`)?`video`:n===`application/pdf`||r.endsWith(`.pdf`)?`document`:`file`}function Yf(e){let t=(e||``).toLowerCase(),n=je.getModelInfo(t);if(n){let e=n.supportsImageInput===!0||n.routesByRequestFeatures===!0,t=n.supportsAudioInput===!0||n.routesByRequestFeatures===!0,r=n.supportsVideoInput===!0||n.routesByRequestFeatures===!0,i=n.supportsDocumentInput===!0||n.routesByRequestFeatures===!0;if(n.supportsImageInput!==void 0||n.supportsAudioInput!==void 0||n.supportsVideoInput!==void 0||n.supportsDocumentInput!==void 0||n.routesByRequestFeatures)return{images:e,audio:t,video:r,documents:i,routerByFeatures:!!n.routesByRequestFeatures,source:`metadata`}}let r=t.includes(`no-vision`)||t.includes(`non-vision`)||t.includes(`text-only`),i=t===`openrouter/free`||t===`openrouter/auto`,a=!r&&[`gpt-4o`,`gpt-4.1`,`gpt-5`,`gpt-6`,`astra`,`claude-3`,`claude-4`,`claude-5`,`claude-sonnet`,`claude-haiku`,`claude-opus`,`claude-fable`,`claude-mythos`,`gemini`,`omni`,`llava`,`qwen-vl`,`-vl`,`vision`,`pixtral`].some(e=>t.includes(e)),o=!r&&(t.includes(`claude-3-5`)||t.includes(`claude-3.5`)||t.includes(`claude-3-7`)||t.includes(`claude-3.7`)||t.includes(`claude-4`)||t.includes(`claude-5`)||t.includes(`claude-fable`)||t.includes(`claude-mythos`)||t.includes(`gemini`)||t.includes(`gpt-4.1`)||t.includes(`gpt-5`)||t.includes(`gpt-6`)||t.includes(`astra`)||/claude-(?:sonnet|haiku|opus|fable|mythos)-\d/.test(t));return a?{images:!0,audio:t.includes(`omni`)||t.includes(`audio`),video:t.includes(`omni`)||t.includes(`video`)||t.includes(`gemini`),documents:o,routerByFeatures:i,source:`heuristic`}:{images:!1,audio:!1,video:!1,documents:!1,routerByFeatures:i,source:`unknown`}}var Xf=k((()=>{Me(),Jf()}));async function fte(e=[],t,n={}){let r=n.maxInlineTextBytes??102400,i=[];for(let n of e){let e=n.mimeType||`application/octet-stream`,
|
|
250
|
+
`),r=n>t*.5?n:t;return`${e.slice(0,r)}\n[...truncated ${e.length-r} chars]`}var ote=k((()=>{}));function Rf(e,t){let{contextLimit:n,systemPromptTokens:r,maxOutputTokens:i,skimTop:a=!1}=t;if(e.length===0)return{messages:[],estimatedTokens:0,truncatedCount:0,contextLimit:n,usagePercent:0};let o=Math.max(0,n-r-i),s=Math.min(zf,Math.max(1e3,Math.floor(o*.6*4))),c=e.map(e=>ste(e,s)),l=0,u=c.length,d=null,f=0;if(a&&c.length>0){let e=c[0];(e.role===`user`||e.role===`system`)&&(f=Af(e),f<=o&&(d=e))}let p=o-f;for(let e=c.length-1;e>=+!!d;e--){let t=Af(c[e]),n=c[e],r=!1;if(n.role===`user`&&Array.isArray(n.content)&&n.content.some(e=>e.type===`tool_result`)){let n=c[e-1];n&&n.role===`assistant`&&Array.isArray(n.content)&&n.content.some(e=>e.type===`tool_use`)&&(r=!0,t+=Af(n))}if(l+t>p&&e<c.length-1)break;l+=t,r?(u=e-1,e--):u=e}let m=c.slice(u),h=u;d&&u>0&&(m=[d,...m],h=Math.max(0,u-1));let g=l+f,_=g+r,v=n>0?Math.round(_/n*100*10)/10:0;return{messages:m,estimatedTokens:g,truncatedCount:h,contextLimit:n,usagePercent:v}}function ste(e,t){if(!Array.isArray(e.content))return e;let n=e.content.map(e=>e.type===`tool_result`&&typeof e.content==`string`?{...e,content:ate(e.content,t)}:e);return{...e,content:n}}var zf,Bf=k((()=>{Lf(),ote(),zf=25e3}));function Vf(e){let t=``,n=32768;for(let r=0;r<e.length;r+=n){let i=e.subarray(r,r+n);t+=String.fromCharCode(...i)}return btoa(t)}function cte(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}var Hf=k((()=>{}));function Uf(e){return e&&(e.split(/[?#]/,1)[0].replace(/\\/g,`/`).split(`/`).pop()||``).toLowerCase().split(`.`).pop()||``}function Wf(e,t){let n=Uf(e);return qf[n]??t}function Gf(e){let t=Uf(e);return Kf[t]||null}function lte(e){return Gf(e)!==null}function ute(e){let t=Uf(e);if(t===`md`||t===`markdown`||t===`txt`)return`text/plain`;if(t===`pdf`)return`application/pdf`;if(Kf[t])return Kf[t]}var Kf,qf,Jf=k((()=>{Kf={apng:`image/apng`,avif:`image/avif`,bmp:`image/bmp`,gif:`image/gif`,heic:`image/heic`,heif:`image/heif`,ico:`image/x-icon`,jpeg:`image/jpeg`,jpg:`image/jpeg`,png:`image/png`,svg:`image/svg+xml`,tif:`image/tiff`,tiff:`image/tiff`,webp:`image/webp`},qf={...Kf,"3gp":`video/3gpp`,aac:`audio/aac`,avi:`video/x-msvideo`,bin:`application/octet-stream`,css:`text/css`,csv:`text/csv`,db:`application/vnd.sqlite3`,dll:`application/octet-stream`,dmg:`application/octet-stream`,dylib:`application/octet-stream`,exe:`application/vnd.microsoft.portable-executable`,flac:`audio/flac`,flv:`video/x-flv`,gz:`application/gzip`,htm:`text/html`,html:`text/html`,iso:`application/octet-stream`,js:`text/javascript`,json:`application/json`,m4a:`audio/mp4`,m4v:`video/mp4`,markdown:`text/markdown`,md:`text/markdown`,mjs:`text/javascript`,mkv:`video/x-matroska`,mov:`video/mp4`,mp3:`audio/mpeg`,mp4:`video/mp4`,oga:`audio/ogg`,ogg:`audio/ogg`,ogv:`video/ogg`,pdf:`application/pdf`,rar:`application/vnd.rar`,so:`application/octet-stream`,sqlite:`application/vnd.sqlite3`,sqlite3:`application/vnd.sqlite3`,tar:`application/x-tar`,ts:`text/typescript`,tsx:`text/typescript`,txt:`text/plain`,wasm:`application/wasm`,wav:`audio/wav`,weba:`audio/webm`,webm:`video/webm`,wmv:`video/x-ms-wmv`,xml:`application/xml`,yaml:`text/yaml`,yml:`text/yaml`,zip:`application/zip`}}));function dte(e=``,t=``){let n=(e&&e!==`application/octet-stream`?e:Wf(t)||e).toLowerCase(),r=t.toLowerCase();return n.startsWith(`text/`)||n.includes(`json`)||n.includes(`xml`)||r.endsWith(`.md`)||r.endsWith(`.txt`)?`text`:n.startsWith(`image/`)?`image`:n.startsWith(`audio/`)?`audio`:n.startsWith(`video/`)?`video`:n===`application/pdf`||r.endsWith(`.pdf`)?`document`:`file`}function Yf(e){let t=(e||``).toLowerCase(),n=je.getModelInfo(t);if(n){let e=n.supportsImageInput===!0||n.routesByRequestFeatures===!0,t=n.supportsAudioInput===!0||n.routesByRequestFeatures===!0,r=n.supportsVideoInput===!0||n.routesByRequestFeatures===!0,i=n.supportsDocumentInput===!0||n.routesByRequestFeatures===!0;if(n.supportsImageInput!==void 0||n.supportsAudioInput!==void 0||n.supportsVideoInput!==void 0||n.supportsDocumentInput!==void 0||n.routesByRequestFeatures)return{images:e,audio:t,video:r,documents:i,routerByFeatures:!!n.routesByRequestFeatures,source:`metadata`}}let r=t.includes(`no-vision`)||t.includes(`non-vision`)||t.includes(`text-only`),i=t===`openrouter/free`||t===`openrouter/auto`,a=!r&&[`gpt-4o`,`gpt-4.1`,`gpt-5`,`gpt-6`,`astra`,`claude-3`,`claude-4`,`claude-5`,`claude-sonnet`,`claude-haiku`,`claude-opus`,`claude-fable`,`claude-mythos`,`gemini`,`omni`,`llava`,`qwen-vl`,`-vl`,`vision`,`pixtral`].some(e=>t.includes(e)),o=!r&&(t.includes(`claude-3-5`)||t.includes(`claude-3.5`)||t.includes(`claude-3-7`)||t.includes(`claude-3.7`)||t.includes(`claude-4`)||t.includes(`claude-5`)||t.includes(`claude-fable`)||t.includes(`claude-mythos`)||t.includes(`gemini`)||t.includes(`gpt-4.1`)||t.includes(`gpt-5`)||t.includes(`gpt-6`)||t.includes(`astra`)||/claude-(?:sonnet|haiku|opus|fable|mythos)-\d/.test(t));return a?{images:!0,audio:t.includes(`omni`)||t.includes(`audio`),video:t.includes(`omni`)||t.includes(`video`)||t.includes(`gemini`),documents:o,routerByFeatures:i,source:`heuristic`}:{images:!1,audio:!1,video:!1,documents:!1,routerByFeatures:i,source:`unknown`}}var Xf=k((()=>{Me(),Jf()}));async function fte(e=[],t,n={}){let r=n.maxInlineTextBytes??102400,i=n.maxImageBytes??3145728,a=[];for(let n of e){let e=n.mimeType||`application/octet-stream`,o=dte(e,n.fileName),s=o===`text`?`file`:o===`document`?`document`:o,c=null;try{c=await t(n)}catch{c=null}let l=c?.length??(typeof n.size==`number`?n.size:0);if(o===`text`&&c&&l<=r)try{let e=new TextDecoder(`utf-8`).decode(c),t=e.includes("```")?`~~~~`:"```";a.push({type:`text`,text:`Attachment: ${n.fileName}\n${t}\n${e}\n${t}`});continue}catch{}let u={type:`attachment`,mediaType:s,fileName:n.fileName,mimeType:e,size:n.size,path:n.path};c&&(s===`image`&&l<=i||s===`audio`&&l<=5242880||s===`document`&&l<=20971520)&&(u.data=Vf(c)),a.push(u)}return a}var pte=k((()=>{Hf(),Xf()}));async function mte(e,t){let n=await Tc(e,t),r=await At();return await Promise.all(n.map(async t=>{if(t.isFromMe)return{role:`assistant`,content:t.content};let n=`${t.sender}: ${t.content}`,i=t.attachments||[];if(i.length===0)return{role:`user`,content:n};let a=await fte(i,async t=>!r||!t.path?null:oi(r,e,t.path));return a.length===0?{role:`user`,content:n}:{role:`user`,content:[{type:`text`,text:n},...a]}}))}var hte=k((()=>{pte(),si(),It(),Dc()}));function gte(e){for(let t of Qf)if(t.test(e))return!0;return!1}function _te(e){let t=String(e||``),n=t;for(let e of Qf)t=t.replace(e,``);return t!==n&&(t=t.replace(/^[ \t]+$/gm,``),t=t.replace(/\n{3,}/g,`
|
|
251
251
|
|
|
252
252
|
`)),t}function Zf(e,t){let n=_te(e);return n!==e&>e(e)&&console.info(`[ShadowClaw] Chat-template control token(s) detected and stripped from "${t}" output. The provider or model may not be applying its chat template correctly. Original length: ${e.length}, cleaned length: ${n.length}.`),n}var Qf,$f=k((()=>{Qf=[/<\|start_header_id\|>\s*(?:system|user|assistant|tool)\s*<\|end_header_id\|>/gi,/<\|(?:begin_of_text|end_of_text|eot_id|im_start|im_end|end_of_message)\|>/gi,/<\|(?:startofturn|endofturn|start_of_turn|end_of_turn)\|>/gi,/<\|(?:image|audio|video|tool_call|tool_response|tool_result|function_call)\|>|<\|\/function_call\|>/gi,/<|(?:system|user|assistant|im_start|im_end)|>/g,/\[\s*INST\s*\]|\[\s*\/INST\s*\]|<<\s*SYS\s*>>|<<\s*\/SYS\s*>>/gi,/<\/?s>|<\/?bos>|<\/?eos>|<\|(?:bos|eos|pad|unk)\|>/gi,/<\|(?:START_OF_TURN_TOKEN|END_OF_TURN_TOKEN|CHATBOT_TOKEN|USER_TOKEN|SYSTEM_TOKEN)\|>/gi,/<\|(?:system|user|assistant|end|endoftext|placeholder\d*)\|>/gi,/<|(?:begin▁of▁sentence|end▁of▁sentence)|>/g,/<\|start\|>\s*(?:system|user|assistant|tool)\s*<\|message\|>/gi]}));function ep(e,t,n,r){return{type:`thinking-log`,payload:{groupId:e,level:t,timestamp:Date.now(),label:n,message:r||``}}}var tp=k((()=>{}));function np(e,t,n){return{type:`tool-activity`,payload:{groupId:e,tool:t,status:n}}}var rp=k((()=>{}));async function ip(e,t,n,r){let{dirs:i,filename:a}=ii(n);for(let n=0;n<2;n++)try{let n=await En(e,t);for(let e of i)n=await n.getDirectoryHandle(e,{create:!0});let o=await n.getFileHandle(a,{create:!0});try{await Ro(o,r);return}catch(t){if(!((t instanceof Error?t.message:String(t)).includes(`Writable file streams are not supported`)&&(await Cn(e)).type===`opfs`))throw t}let s=t.replace(/:/g,`-`);await zo([gn(),`groups`,s,...i,a],r);return}catch(e){if(n===0&&Sn(e)){xn();continue}throw e}}var vte=k((()=>{Dn(),ai(),Tn(),Vo()}));function yte(){return new Promise((e,t)=>{let n=indexedDB.open(cp,1);n.onupgradeneeded=()=>{n.result.createObjectStore(lp)},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}async function ap(){let e=await yte();if(!e)return null;let t=await new Promise((t,n)=>{let r=e.transaction(lp,`readonly`).objectStore(lp).get(up);r.onsuccess=()=>t(r.result),r.onerror=()=>n(r.error)});if(t)return e.close(),t;let n=await crypto.subtle.generateKey({name:`AES-GCM`,length:256},!1,[`encrypt`,`decrypt`]);try{await new Promise((t,r)=>{let i=e.transaction(lp,`readwrite`);i.objectStore(lp).put(n,up),i.oncomplete=()=>t(),i.onerror=()=>r(i.error)})}finally{e.close()}return n}async function op(e){let t=await ap();if(!t)return null;let n=crypto.getRandomValues(new Uint8Array(dp)),r=await crypto.subtle.encrypt({name:`AES-GCM`,iv:n},t,new TextEncoder().encode(e)),i=new Uint8Array(n.length+new Uint8Array(r).length);return i.set(n),i.set(new Uint8Array(r),n.length),btoa(String.fromCharCode(...i))}async function sp(e){let t=await ap();if(!t)return null;let n=Uint8Array.from(atob(e),e=>e.charCodeAt(0)),r=n.slice(0,dp),i=n.slice(dp),a=await crypto.subtle.decrypt({name:`AES-GCM`,iv:r},t,i);return new TextDecoder().decode(a)}var cp,lp,up,dp,fp=k((()=>{cp=`shadowclaw-keystore`,lp=`keys`,up=`api-key-encryption`,dp=12}));function pp(e){return!e||e.authMode===`token`||e.authMode===`pat`?`token`:e.authMode===`basic`?`basic`:e.authMode===`oauth`||e.oauthProviderId||e.oauthClientId||e.oauthClientSecret||e.refreshToken||e.accessTokenExpiresAt||e.tokenType||e.oauthReauthRequired?`oauth`:`token`}var mp=k((()=>{}));function hp(e){return pp(e)}function bte(e,t){return hp(e)!==`oauth`||e.oauthReauthRequired||!e.refreshToken||!e.oauthProviderId||!e.oauthClientId?!1:t.forceRefresh?!0:e.accessTokenExpiresAt?e.accessTokenExpiresAt<=Date.now()+yp:!1}async function xte(e,t,n){if(!n.refreshToken||!n.oauthProviderId||!n.oauthClientId)return n;let r=await sp(n.refreshToken);if(!r)return n;let i=n.oauthClientSecret?await sp(n.oauthClientSecret):void 0,a=async r=>{let i=t.findIndex(e=>e.id===n.id);i!==-1&&(t[i]=r,await B(e,L.SERVICE_ACCOUNTS,t))},o=async()=>{let e=(n.oauthRefreshFailureCount||0)+1,t=e>=bp,r={...n,oauthRefreshFailureCount:e,oauthReauthRequired:t,oauthReauthRequiredAt:t?n.oauthReauthRequiredAt||Date.now():void 0};return await a(r),r};try{let e=await fetch(`/oauth/refresh`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({providerId:n.oauthProviderId,clientId:n.oauthClientId,clientSecret:i,refreshToken:r,scope:n.scopes,tokenUrl:n.oauthCustomTokenUrl})});if(!e.ok)return o();let t=await e.json();if(!t.accessToken)return o();let s=await op(t.accessToken);if(!s)return o();let c=n.refreshToken;if(t.refreshToken){let e=await op(t.refreshToken);e&&(c=e)}let l={...n,token:s,refreshToken:c,accessTokenExpiresAt:t.expiresIn?Date.now()+t.expiresIn*1e3:n.accessTokenExpiresAt,tokenType:t.tokenType||n.tokenType,scopes:t.scope?t.scope.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean):n.scopes,oauthRefreshFailureCount:0,oauthReauthRequired:!1,oauthReauthRequiredAt:void 0};return await a(l),l}catch{return o()}}function gp(e,t){if(e.oauthProviderId){let t=nt(e.oauthProviderId);if(t)return t}let n=[e.service,e.hostPattern,t].filter(e=>!!e).map(e=>e.toLowerCase());for(let e of Object.values(I))if([e.providerId,...e.aliases||[]].map(e=>e.toLowerCase()).some(e=>n.some(t=>t.includes(e))))return e;return null}function Ste(e,t){let n=hp(e),r=gp(e,t);if(r){let e;return e=n===`oauth`?r.tokenAuth.oauth:n===`basic`&&r.tokenAuth.basic?r.tokenAuth.basic:r.tokenAuth.token,{headerName:e.headerName,headerPrefix:e.headerPrefix||``}}return{headerName:`Authorization`,headerPrefix:n===`basic`?`Basic `:`Bearer `}}function Cte(e,t){let n=[],r=-1,i=t.toLowerCase();for(let t of e){if(!t.hostPattern)continue;let e=t.hostPattern.toLowerCase();i.includes(e)&&(e.length>r?(r=e.length,n.length=0,n.push(t)):e.length===r&&n.push(t))}return n}function _p(e,t){return e.length?t&&e.find(e=>hp(e)===t)||e[0]:void 0}async function vp(e,t,n={}){let r=await R(e,L.SERVICE_ACCOUNTS),i=Array.isArray(r)?r:[];if(i.length===0)return;let a;if(n.accountId&&(a=i.find(e=>e.id===n.accountId)),!a&&t){let e=Cte(i,t);a=n.authMode?_p(e,n.authMode):_p(e,e[0]?gp(e[0],t)?.defaultMode:void 0)}if(!a){let t=await R(e,L.SERVICE_DEFAULT_ACCOUNT);t&&(a=i.find(e=>e.id===t))}if(!a&&n.authMode&&(a=_p(i,n.authMode)),a||=i[0],!a)return;if(bte(a,n)&&(a=await xte(e,i,a)),hp(a)===`oauth`&&a.oauthReauthRequired)return{token:``,service:a.service,hostPattern:a.hostPattern,headerName:`Authorization`,headerValue:``,accountId:a.id,authMode:`oauth`,reauthRequired:!0};let o=``;a.token&&(o=await sp(a.token)??``);let{headerName:s,headerPrefix:c}=Ste(a,t),l=o;hp(a)===`basic`&&a.basicUsername&&(l=btoa(`${a.basicUsername}:${o}`));let u=c?`${c}${l}`:l;return{token:o,service:a.service,hostPattern:a.hostPattern,headerName:s,headerValue:u,accountId:a.id,authMode:hp(a)}}var yp,bp,xp=k((()=>{Ot(),Gt(),Wo(),fp(),mp(),yp=6e4,bp=3}));function Sp(e){return pp(e)}function wte(e){switch(e){case`azure-devops`:return`azure_devops`;default:return e}}function Cp(e){if(!e)return`generic`;let t=e.toLowerCase();return t.includes(`github`)?`github`:t.includes(`dev.azure.com`)||t.includes(`visualstudio.com`)?`azure-devops`:t.includes(`gitlab`)?`gitlab`:`generic`}function wp(e){if(e.reauthRequired)return{};let t=e.provider||Cp(e.hostPattern||``),n=wte(t),r=e.authMode||`token`;if(e.token&&n===`azure_devops`&&rt(n,r,`git_remote`)?.headerPrefix===`Basic `)return{Authorization:`Basic ${btoa(`:`+e.token)}`};if(t===`azure-devops`&&e.username&&e.password)return{Authorization:`Basic ${btoa(e.username+`:`+e.password)}`};if(e.token){let t=rt(n,r,`git_remote`);return t?.headerName?{[t.headerName]:`${t.headerPrefix||``}${e.token}`}:{Authorization:`Bearer ${e.token}`}}return{}}function Tp(e){try{let t=new URL(e),n=t.pathname.replace(/\/+$/,``);return n?t.hostname+n:t.hostname}catch{return}}function Tte(e,t){let n=t.toLowerCase(),r=[],i=-1;for(let t of e){if(!t.hostPattern)continue;let e=t.hostPattern.toLowerCase();n.includes(e)&&(e.length>i?(i=e.length,r.length=0,r.push(t)):e.length===i&&r.push(t))}return r}function Ep(e,t){if(!e.length)return;if(!t)return e[0];let n=e.find(e=>Sp(e)===t);if(n)return n;if(t===`token`){let t=e.find(e=>Sp(e)===`token`&&!e.authMode);if(t)return t}return e[0]}async function Dp(e){if(e)return await sp(e)??void 0}function Ete(e,t){return Sp(e)!==`oauth`||e.oauthReauthRequired||!e.refreshToken||!e.oauthProviderId||!e.oauthClientId?!1:t.forceRefresh?!0:e.accessTokenExpiresAt?e.accessTokenExpiresAt<=Date.now()+kp:!1}async function Dte(e,t,n){if(!n.refreshToken||!n.oauthProviderId||!n.oauthClientId)return n;let r=await Dp(n.refreshToken);if(!r)return n;let i=n.oauthClientSecret?await Dp(n.oauthClientSecret):void 0,a=async r=>{let i=t.findIndex(e=>e.id===n.id);i!==-1&&(t[i]=r,await B(e,L.GIT_ACCOUNTS,t))},o=async()=>{let e=(n.oauthRefreshFailureCount||0)+1,t=e>=Ap,r={...n,oauthRefreshFailureCount:e,oauthReauthRequired:t,oauthReauthRequiredAt:t?n.oauthReauthRequiredAt||Date.now():void 0};return await a(r),r};try{let e=await fetch(`/oauth/refresh`,{body:JSON.stringify({clientId:n.oauthClientId,clientSecret:i,providerId:n.oauthProviderId,refreshToken:r,scope:n.scopes}),headers:{"content-type":`application/json`},method:`POST`});if(!e.ok)return o();let t=await e.json();if(!t.accessToken)return o();let s=await op(t.accessToken);if(!s)return o();let c=n.refreshToken;if(t.refreshToken){let e=await op(t.refreshToken);e&&(c=e)}let l={...n,token:s,refreshToken:c,accessTokenExpiresAt:t.expiresIn?Date.now()+t.expiresIn*1e3:n.accessTokenExpiresAt,tokenType:t.tokenType||n.tokenType,scopes:t.scope?t.scope.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean):n.scopes,oauthRefreshFailureCount:0,oauthReauthRequired:!1,oauthReauthRequiredAt:void 0};return await a(l),l}catch{return o()}}async function Op(e,t,n={}){let r=await R(e,L.GIT_ACCOUNTS);return Array.isArray(r)&&r.length>0?Ote(e,r,t,n):kte(e)}async function Ote(e,t,n,r={}){let i;if(r.accountId&&(i=t.find(e=>e.id===r.accountId)),!i&&n){let e=Tp(n);e&&(i=Ep(Tte(t,e),r.authMode))}if(!i){let r=await R(e,L.GIT_DEFAULT_ACCOUNT);if(r){let e=t.find(e=>e.id===r);if(e){if(!n)i=e;else{let t=Tp(n);if(t&&e.hostPattern){let n=t?.toLowerCase(),r=e.hostPattern.toLowerCase();n?.includes(r)&&(i=e)}}}}}if(!i&&!n&&r.authMode&&(i=Ep(t,r.authMode)),!i&&!n&&(i=t[0]),!i)return{authMode:`token`,authorEmail:void 0,authorName:void 0,password:void 0,provider:`generic`,token:void 0,username:void 0};Ete(i,r)&&(i=await Dte(e,t,i));let a=i.provider||Cp(i.hostPattern||``);return Sp(i)===`oauth`&&i.oauthReauthRequired?{accountId:i.id,authMode:`oauth`,authorEmail:i.authorEmail||void 0,authorName:i.authorName||void 0,hostPattern:i.hostPattern||void 0,password:void 0,provider:a,reauthRequired:!0,token:void 0,username:i.username||void 0}:{accountId:i.id,authMode:Sp(i),authorEmail:i.authorEmail||void 0,authorName:i.authorName||void 0,hostPattern:i.hostPattern||void 0,password:await Dp(i.password),provider:a,token:await Dp(i.token),username:i.username||void 0}}async function kte(e){let t=await R(e,L.GIT_TOKEN),n=await R(e,L.GIT_PASSWORD);return{authMode:`token`,authorEmail:await R(e,L.GIT_AUTHOR_EMAIL)||void 0,authorName:await R(e,L.GIT_AUTHOR_NAME)||void 0,password:n?await Dp(n):void 0,provider:`generic`,token:t?await Dp(t):void 0,username:await R(e,L.GIT_USERNAME)||void 0}}var kp,Ap,jp=k((()=>{Ot(),mp(),fp(),Gt(),Wo(),kp=6e4,Ap=3}));function Ate(e){if(typeof e!=`string`||!e.trim())return!1;try{let t=new URL(e);return t.protocol===`https:`||t.protocol===`http:`}catch{return!1}}function jte(e,t){if(!e||typeof e!=`object`)return null;let n=e;if(!n.serviceType||!n.authType)return null;if(n.serviceType!==t)throw Error(`Credential ref serviceType must match connection serviceType`);return{serviceType:n.serviceType,authType:n.authType,providerId:n.providerId||void 0,accountId:n.accountId||void 0,gitAccountId:n.gitAccountId||void 0,headerName:n.headerName||void 0,encryptedValue:n.encryptedValue||void 0}}function Mte(e){if(!e||typeof e!=`object`)return null;let t=e;return!t.id||!t.label||!t.serviceType||!t.transport||typeof t.enabled!=`boolean`||typeof t.createdAt!=`number`||typeof t.updatedAt!=`number`||!Ate(t.serverUrl)||t.serviceType!==`mcp_remote`&&t.serviceType!==`webmcp_local`||t.transport!==`streamable_http`&&t.transport!==`sse`&&t.transport!==`websocket`?null:{id:t.id,label:t.label,serviceType:t.serviceType,serverUrl:t.serverUrl,transport:t.transport,enabled:t.enabled,autoReconnectOAuth:t.autoReconnectOAuth===!0,createdAt:t.createdAt,updatedAt:t.updatedAt,credentialRef:jte(t.credentialRef,t.serviceType)}}async function Mp(e){let t=await R(e,L.REMOTE_MCP_CONNECTIONS);if(!Array.isArray(t))return[];let n=[];for(let e of t){let t=Mte(e);t&&n.push(t)}return n}async function Nte(e){return Mp(e)}async function Np(e,t){if(!t)return null;let n=await Mp(e);return n.find(e=>e.id===t)||n.find(e=>e.label.toLowerCase()===t.toLowerCase())||null}var Pp=k((()=>{Ot(),Gt(),Wo()}));function Pte(e){return e===`oauth`?`oauth`:`token`}async function Fp(e,t,n={}){let r=await Np(e,t);if(!r)return null;let i=r.credentialRef;if(!i||i.authType===`none`)return{connection:r,authType:`none`,headers:{}};if(i.authType===`custom_header`){if(!i.headerName||!i.encryptedValue)return{connection:r,authType:`custom_header`,headers:{}};let e=await sp(i.encryptedValue);return{connection:r,authType:`custom_header`,headers:e?{[i.headerName]:e}:{}}}let a=Pte(i.authType);if(i.accountId){let t=await vp(e,r.serverUrl,{accountId:i.accountId,authMode:a,forceRefresh:n.forceRefresh});return t?t.reauthRequired?{connection:r,authType:i.authType,headers:{},reauthRequired:!0}:{connection:r,authType:i.authType,headers:t.headerValue?{[t.headerName]:t.headerValue}:{}}:{connection:r,authType:i.authType,headers:{}}}if(i.gitAccountId){let t=await Op(e,r.serverUrl,{accountId:i.gitAccountId,authMode:a,forceRefresh:n.forceRefresh});return t.reauthRequired?{connection:r,authType:i.authType,headers:{},reauthRequired:!0}:{connection:r,authType:i.authType,headers:wp(t)}}return{connection:r,authType:i.authType,headers:{}}}var Fte=k((()=>{fp(),Pp(),xp(),jp()}));function Ip(e){return typeof e==`object`&&!!e&&`method`in e&&`id`in e&&!(`result`in e)&&!(`error`in e)}function Ite(e){let t=(e.requestedSchema||{}).properties||{},n={};for(let[e,r]of Object.entries(t))`default`in r?n[e]=r.default:r.type===`boolean`&&(n[e]=!0);return n}function Lp(e,t){return!e.headers||typeof e.headers.get!=`function`?null:e.headers.get(t)}function Rp(e){return/no valid session id provided/i.test(e)}function zp(e,t){let n=t&&`error`in t?t.error.message||`Remote MCP JSON-RPC error`:``;return Rp(n)?new Zp(n):e.ok?Error(n||`Remote MCP JSON-RPC error`):new Qp(e.status,n?`Remote MCP HTTP error: ${e.status} (${n})`:`Remote MCP HTTP error: ${e.status}`)}function Bp(e){if(!e)return null;let t=null,n=e.split(/\r?\n/);for(let e of n){let n=e.trim();if(!n.startsWith(`data:`))continue;let r=n.slice(5).trim();if(r&&r!==`[DONE]`)try{let e=JSON.parse(r);e&&typeof e==`object`&&`jsonrpc`in e&&(t=e)}catch{}}return t}function Vp(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}async function Hp(e,t,n){let r=await fetch(e,{method:`POST`,headers:{"content-type":`application/json`,accept:`application/json, text/event-stream`,...t},body:JSON.stringify(n)}),i=(Lp(r,`content-type`)||``).toLowerCase(),a=null;if(typeof r.text==`function`){let e=await r.text();a=i.includes(`text/event-stream`)?Bp(e):Vp(e)}else try{a=await r.json()}catch{a=null}return{response:r,payload:a}}async function Up(e,t,n){let{response:r,payload:i}=await Hp(e,{...t,"mcp-session-id":n},{jsonrpc:`2.0`,method:`notifications/initialized`,params:{}});if(!r.ok||i&&`error`in i)throw zp(r,i)}async function Wp(e,t,n){let r=Xp.get(e);if(r?.sessionId)return r;let{response:i,payload:a}=await Hp(t,n,{jsonrpc:`2.0`,id:`initialize-${Date.now().toString(36)}`,method:`initialize`,params:{protocolVersion:`2025-03-26`,capabilities:{elicitation:{}},clientInfo:{name:`shadowclaw-remote-mcp-client`,version:`1.0.0`}}});if(!i.ok||a&&`error`in a)throw zp(i,a);let o=Lp(i,`mcp-session-id`)||`local-${Date.now()}-${Math.random().toString(36).slice(2)}`,s={sessionId:o,protocolVersion:Lp(i,`mcp-protocol-version`)||a?.result?.protocolVersion,lastUsedAt:Date.now()};return await Up(t,n,o),Xp.set(e,s),s}async function Gp(e,t,n,r,i){let a=await Wp(e,t,n),o=async e=>{let a={jsonrpc:`2.0`,id:Date.now().toString(),method:r,params:i||{}},o={...n,"mcp-session-id":e},{response:s,payload:c}=await Hp(t,o,a),l=0;for(;Ip(c)&&l<5&&(l++,c.method===`elicitation/create`);){let e=Ite(c.params||{});({response:s,payload:c}=await Hp(t,o,{jsonrpc:`2.0`,id:c.id,result:{action:`accept`,content:e}}))}if(Ip(c))throw Error(`Unsupported server request: ${c.method}`);if(!s.ok||!c||`error`in c)throw zp(s,c);return c.result};try{let t=await o(a.sessionId);return a.lastUsedAt=Date.now(),Xp.set(e,a),t}catch(r){if(!(r instanceof Zp))throw r;Xp.delete(e),a=await Wp(e,t,n);let i=await o(a.sessionId);return a.lastUsedAt=Date.now(),Xp.set(e,a),i}}function Kp(e){e&&Xp.delete(e)}async function qp(e,t,n,r){let i=await Fp(e,t);if(!i)throw Error(`Remote MCP connection not found`);if(i.reauthRequired)throw new $p(t);let{connection:a,authType:o,headers:s}=i;if(a.transport!==`streamable_http`)throw Error(`Unsupported remote MCP transport`);try{return await Gp(t,a.serverUrl,s,n,r)}catch(i){if(!(i instanceof Qp)||i.status!==401||o!==`oauth`)throw i;Kp(t);let a=await Fp(e,t,{forceRefresh:!0});if(!a||a.reauthRequired)throw new $p(t);try{return await Gp(t,a.connection.serverUrl,a.headers,n,r)}catch(e){throw e instanceof Qp&&e.status===401?new $p(t):e}}}async function Jp(e,t){let n=await qp(e,t,`tools/list`);return Array.isArray(n.tools)?n.tools:[]}async function Yp(e,t,n,r={}){return qp(e,t,`tools/call`,{name:n,arguments:r})}var Xp,Zp,Qp,$p,em=k((()=>{Fte(),Xp=/* @__PURE__ */ new Map,Zp=class extends Error{constructor(e){super(e),this.name=`InvalidRemoteMcpSessionError`}},Qp=class extends Error{status;constructor(e,t){super(t),this.name=`HttpRemoteMcpError`,this.status=e}},$p=class extends Error{connectionId;constructor(e){super(`OAuth reconnect required for remote MCP connection`),this.name=`McpReauthRequiredError`,this.connectionId=e}}}));async function tm(e,t,n,r){let{dirs:i,filename:a}=ii(n);for(let n=0;n<2;n++)try{let n=await En(e,t);for(let e of i)n=await n.getDirectoryHandle(e,{create:!0});let o=await n.getFileHandle(a,{create:!0});try{await Ro(o,r);return}catch(t){if(!((t instanceof Error?t.message:String(t)).includes(`Writable file streams are not supported`)&&(await Cn(e)).type===`opfs`))throw t}let s=t.replace(/:/g,`-`);await zo([gn(),`groups`,s,...i,a],r);return}catch(e){if(n===0&&Sn(e)){xn();continue}throw e}}var nm=k((()=>{Dn(),ai(),Tn(),Vo()}));function rm(){return[...am].sort((e,t)=>e.id.localeCompare(t.id))}function im(e){return e&&am.find(t=>t.id===e)||null}var am,om=k((()=>{am=[{id:`imap`,name:`IMAP Mail`,protocol:`imap`,description:`Read mailboxes and fetch message metadata/content.`,version:`0.1.0`,actions:[`messages.read`,`messages.send`],authTypes:[`basic_userpass`,`oauth`],serviceTypes:[`http_api`],configurableFields:[`host`,`port`,`secure`,`mailboxPath`,`smtpHost`,`smtpPort`,`smtpSecure`,`fromAddress`,`executionMode`,`pollIntervalSec`]}]}));function sm(e){if(!e||typeof e!=`object`)return null;let t=e;return!t.serviceType||!t.authType?null:{serviceType:t.serviceType,authType:t.authType,providerId:t.providerId||void 0,accountId:t.accountId||void 0,username:t.username||void 0,headerName:t.headerName||void 0,encryptedSecret:t.encryptedSecret||void 0}}function cm(e){if(!e||typeof e!=`object`)return null;let t=e;return!t.id||!t.label||!t.pluginId||typeof t.enabled!=`boolean`||typeof t.createdAt!=`number`||typeof t.updatedAt!=`number`||!im(t.pluginId)?null:{id:t.id,label:t.label,pluginId:t.pluginId,enabled:t.enabled,config:t.config&&typeof t.config==`object`?{...t.config}:{},credentialRef:sm(t.credentialRef),createdAt:t.createdAt,updatedAt:t.updatedAt}}async function lm(e){let t=await R(e,L.INTEGRATION_CONNECTIONS);if(!Array.isArray(t))return[];let n=[];for(let e of t){let t=cm(e);t&&n.push(t)}return n}async function um(e,t){await B(e,L.INTEGRATION_CONNECTIONS,t)}async function dm(e){return lm(e)}async function fm(e,t){if(!t)return null;let n=await lm(e);return n.find(e=>e.id===t)||n.find(e=>e.label.toLowerCase()===t.toLowerCase())||null}async function pm(e,t){if(!t.label?.trim())throw Error(`Email connection label is required`);let n=im(t.pluginId);if(!n)throw Error(`Unknown email plugin: ${t.pluginId}`);let r=await lm(e),i=Date.now();if(t.id){let a=r.findIndex(e=>e.id===t.id);if(a!==-1){let o=r[a],s={...o,label:t.label.trim(),pluginId:n.id,enabled:t.enabled??o.enabled,config:t.config?{...t.config}:o.config,updatedAt:i};return r[a]=s,await um(e,r),s}}let a={id:t.id||cc(),label:t.label.trim(),pluginId:n.id,enabled:t.enabled??!0,config:t.config?{...t.config}:{},credentialRef:null,createdAt:i,updatedAt:i};return r.push(a),await um(e,r),a}async function mm(e,t,n){if(!t)return null;let r=await lm(e),i=r.findIndex(e=>e.id===t);if(i===-1)return null;let a={...r[i],credentialRef:n?sm(n):null,updatedAt:Date.now()};return r[i]=a,await um(e,r),a}async function hm(e,t){if(!t)return!1;let n=await lm(e),r=n.filter(e=>e.id!==t);return r.length!==n.length&&(await um(e,r),!0)}var gm=k((()=>{Ot(),Gt(),Wo(),hc(),om()}));function _m(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n==`string`){let e=n.trim();e&&t.push({path:e});continue}if(!n||typeof n!=`object`)continue;let e=typeof n.path==`string`?n.path.trim():``;if(!e)continue;let r=typeof n.filename==`string`?n.filename.trim():``,i=typeof n.content_type==`string`?n.content_type.trim():``;t.push({path:e,filename:r||void 0,contentType:i||void 0})}return t}var vm=k((()=>{}));function ym(e,t,n){if(e==null||e===``||typeof e==`boolean`)return t;let r=typeof e==`number`?e:Number(e);if(!Number.isFinite(r))return t;let i=r;return typeof n?.min==`number`&&(i=Math.max(n.min,i)),typeof n?.max==`number`&&(i=Math.min(n.max,i)),i}function bm(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(Boolean):[]}function xm(e){if(!Array.isArray(e))return[];let t=e.map(e=>typeof e==`number`?e:Number(e)).filter(e=>Number.isFinite(e)&&e>0).map(e=>Math.floor(e));return Array.from(new Set(t))}var Sm,Cm,wm,Tm=k((()=>{Sm=ym,Cm=bm,wm=xm}));function Em(e,t=`attachment.bin`){if(!e)return t;let n=e.replace(/\\/g,`/`).split(`/`).filter(Boolean);return n[n.length-1]||t}function Dm(e,t={}){let n=t.replacement??`_`,r=t.fallback??`attachment.bin`,i=e.trim();t.stripControlChars&&(i=i.replace(/[\u0000-\u001f\u007f]+/g,``)),t.stripLeadingDots&&(i=i.replace(/^\.+/,``));let a=t.stripControlChars?/[\\/:*?"<>|]/g:/[\\/:*?"<>|\x00-\x1f\u007f]/g;if(t.collapseReplacement&&n){let e=n.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);i=i.replace(t.stripControlChars?/[\\/:*?"<>|]+/g:/[\\/:*?"<>|\x00-\x1f\u007f]+/g,n),i=i.replace(RegExp(`${e}+`,`g`),n)}else i=i.replace(a,n);return i=i.trim(),t.stripLeadingDots&&(i=i.replace(/^\.+/,``).trim()),i||r}var Om=k((()=>{}));async function km(e,t,n,r=!1){let i=(typeof n.username==`string`?n.username.trim():``)||t.credentialRef?.username||(typeof t.config.username==`string`?t.config.username:``);if(!i)return`Error: Integration connection ${t.id} is missing username credentials.`;if(t.credentialRef?.authType===`oauth`){let n=t.credentialRef.accountId;if(!n)return`Error: Integration connection ${t.id} is missing linked OAuth account.`;let a=await vp(e,void 0,{accountId:n,authMode:`oauth`,forceRefresh:r});if(!a||a.reauthRequired||!a.token){let e=t.credentialRef?.providerId||`the configured`;return`Error: OAuth account reconnect required for integration ${t.id}.\nOpen Settings -> Integrations, edit this email connection, and click Connect OAuth for ${e} to re-authorize.`}return{authType:`oauth`,username:i,accessToken:a.token}}let a=(typeof n.password==`string`?n.password.trim():``)||t.credentialRef?.encryptedSecret&&await sp(t.credentialRef.encryptedSecret)||``;return a?{authType:`basic_userpass`,username:i,password:a}:`Error: Integration connection ${t.id} is missing password credentials.`}var Am=k((()=>{fp(),xp()}));async function jm(e,t,n,r){let i=Dm(r),a=i.lastIndexOf(`.`),o=a>0?i.slice(0,a):i,s=a>0?i.slice(a):``,c=n.trim().replace(/^\/+|\/+$/g,``);for(let n=0;n<1e3;n++){let r=n===0?i:`${o}-${n+1}${s}`,a=c?`${c}/${r}`:r;if(!await Yo(e,t,a))return a}return c?`${c}/${cc()}-${i}`:`${cc()}-${i}`}var Mm=k((()=>{Xo(),hc(),Om()}));async function Nm(e,t,n){let r=typeof t.action==`string`?t.action.trim():``;if(!r)return`Error: manage_email requires action.`;if(r===`list_plugins`){let e=rm();return e.length?e.map(e=>`- ${e.id} (${e.protocol})\n Name: ${e.name}\n Actions: ${e.actions.join(`, `)}\n Auth: ${e.authTypes.join(`, `)}\n Fields: ${e.configurableFields.join(`, `)||`(none)`}`).join(`
|
|
253
253
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as getConfig } from "./get-config-BWhs5HFF.js";
|
|
2
2
|
import { o as DEFAULT_GROUP_ID, r as CONFIG_KEYS } from "./config-BrHR97zt.js";
|
|
3
3
|
import { t as setConfig } from "./set-config-CUadvYZ1.js";
|
|
4
|
-
import { t as orchestratorStore } from "./orchestrator-
|
|
4
|
+
import { t as orchestratorStore } from "./orchestrator-cRBe3lhq.js";
|
|
5
5
|
import { normalizeStringList } from "./utils/normalize-string-list.js";
|
|
6
6
|
import { r as encryptValue } from "./crypto-Bikgpqfe.js";
|
|
7
7
|
|
|
@@ -138,4 +138,4 @@ async function configureTelegram(state, db, token, chatIds, useProxy = false, _s
|
|
|
138
138
|
|
|
139
139
|
//#endregion
|
|
140
140
|
export { getChannelEnabled as a, getPeerJsConfig as c, setChannelEnabled as d, submitMessage as f, configureTelegram as i, getTelegramConfig as l, clearPeerJsTypingState as n, getChannelTypeForGroup as o, configureIMessage as r, getIMessageConfig as s, applyAllChannelRunningStates as t, loadChannelEnabled as u };
|
|
141
|
-
//# sourceMappingURL=channel-
|
|
141
|
+
//# sourceMappingURL=channel-DB77spML.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel-mmdGzPkT.js","names":["_defaultGetConfig","_defaultSetConfig"],"sources":["../../src/core/orchestrator/utils/operations/channel.ts"],"sourcesContent":["import { CONFIG_KEYS, DEFAULT_GROUP_ID } from \"../../../../config/config.js\";\nimport { getConfig as _defaultGetConfig } from \"../../../../db/get-config.js\";\nimport { setConfig as _defaultSetConfig } from \"../../../../db/set-config.js\";\nimport { encryptValue } from \"../../../../security/crypto.js\";\nimport { orchestratorStore } from \"../../../../stores/orchestrator.js\";\nimport { normalizeStringList } from \"../../../../utils/normalize-string-list.js\";\n\nimport type { MessageAttachment } from \"../../../../content/types.js\";\nimport type { ShadowClawDatabase } from \"../../../../db/db.js\";\n\nimport type {\n Channel,\n ChannelType,\n} from \"../../../../subsystems/channels/types.js\";\n\nimport type { A2UIAction } from \"../../../../ui/a2ui/types.js\";\nimport type { OrchestratorState } from \"../../orchestrator-state.js\";\n\ntype SetConfigFn = (\n db: ShadowClawDatabase,\n key: string,\n value: string,\n) => Promise<void>;\n\ntype GetConfigFn = (\n db: ShadowClawDatabase,\n key: string,\n) => Promise<string | undefined>;\n\n// ── Pure channel lookups ────────────────────────────────────────────────────\n\nexport function getChannelTypeForGroup(\n state: {\n channelRegistry?: {\n getChannelType: (groupId: string) => ChannelType | null | undefined;\n };\n },\n groupId: string,\n): ChannelType {\n return state.channelRegistry?.getChannelType(groupId) ?? \"browser\";\n}\n\nexport function getChannelByType(\n state: Pick<\n OrchestratorState,\n \"browserChat\" | \"telegram\" | \"imessage\" | \"peerjs\"\n >,\n channelType: ChannelType,\n): Channel | null {\n switch (channelType) {\n case \"browser\":\n return state.browserChat;\n case \"telegram\":\n return state.telegram;\n case \"imessage\":\n return state.imessage;\n case \"peerjs\":\n return state.peerjs;\n default:\n return null;\n }\n}\n\nexport function getChannelEnabled(\n state: Pick<OrchestratorState, \"channelEnabledByType\">,\n channelType: ChannelType,\n): boolean {\n if (channelType === \"browser\") {\n return true;\n }\n\n return state.channelEnabledByType[channelType] !== false;\n}\n\nexport function getPeerJsConfig(state: {\n channelEnabledByType: Record<ChannelType, boolean>;\n peerjsMyAlias: string;\n peerjsMyPeerId: string;\n peerjsPeerAliases: Record<string, string>;\n peerjsServerHost: string;\n peerjsServerPath: string;\n peerjsServerPort: number;\n peerjsServerSecure: boolean;\n peerjsTrustedPeerIds: string[];\n}): {\n enabled: boolean;\n myAlias: string;\n myPeerId: string;\n peerAliases: Record<string, string>;\n serverHost: string;\n serverPath: string;\n serverPort: number;\n serverSecure: boolean;\n trustedPeerIds: string[];\n} {\n return {\n enabled: getChannelEnabled(state, \"peerjs\"),\n myAlias: state.peerjsMyAlias,\n myPeerId: state.peerjsMyPeerId,\n peerAliases: { ...state.peerjsPeerAliases },\n serverHost: state.peerjsServerHost,\n serverPath: state.peerjsServerPath,\n serverPort: state.peerjsServerPort,\n serverSecure: state.peerjsServerSecure,\n trustedPeerIds: [...state.peerjsTrustedPeerIds],\n };\n}\n\nexport function getTelegramConfig(state: {\n telegramBotToken: string;\n telegramChatIds: string[];\n channelEnabledByType: Record<ChannelType, boolean>;\n telegramUseProxy: boolean;\n}): {\n botToken: string;\n chatIds: string[];\n enabled: boolean;\n useProxy: boolean;\n} {\n return {\n botToken: state.telegramBotToken,\n chatIds: [...state.telegramChatIds],\n enabled: getChannelEnabled(state, \"telegram\"),\n useProxy: state.telegramUseProxy,\n };\n}\n\nexport function getIMessageConfig(state: {\n imessageApiKey: string;\n imessageChatIds: string[];\n channelEnabledByType: Record<ChannelType, boolean>;\n imessageServerUrl: string;\n}): {\n apiKey: string;\n chatIds: string[];\n enabled: boolean;\n serverUrl: string;\n} {\n return {\n apiKey: state.imessageApiKey,\n chatIds: [...state.imessageChatIds],\n enabled: getChannelEnabled(state, \"imessage\"),\n serverUrl: state.imessageServerUrl,\n };\n}\n\nexport function getChannelEnabledConfigKey(channelType: ChannelType): string {\n return `${CONFIG_KEYS.CHANNEL_ENABLED_PREFIX}${channelType}`;\n}\n\nexport function shouldRunChannel(\n state: Pick<\n OrchestratorState,\n | \"channelEnabledByType\"\n | \"telegramBotToken\"\n | \"imessageServerUrl\"\n | \"peerjsMyPeerId\"\n >,\n channelType: ChannelType,\n): boolean {\n if (channelType === \"browser\") {\n return true;\n }\n\n if (!getChannelEnabled(state, channelType)) {\n return false;\n }\n\n switch (channelType) {\n case \"telegram\":\n return state.telegramBotToken.length > 0;\n case \"imessage\":\n return state.imessageServerUrl.length > 0;\n case \"peerjs\":\n return state.peerjsMyPeerId.length > 0;\n default:\n return true;\n }\n}\n\nexport function applyChannelRunningState(\n state: Pick<\n OrchestratorState,\n | \"browserChat\"\n | \"telegram\"\n | \"imessage\"\n | \"peerjs\"\n | \"channelEnabledByType\"\n | \"telegramBotToken\"\n | \"imessageServerUrl\"\n | \"peerjsMyPeerId\"\n >,\n channelType: ChannelType,\n force: boolean = false,\n): void {\n const channel = getChannelByType(state, channelType);\n if (!channel) {\n return;\n }\n\n if (shouldRunChannel(state, channelType)) {\n if (!channel.running) {\n channel.start();\n } else if (typeof (channel as any).ensureConnected === \"function\") {\n (channel as any).ensureConnected(force);\n }\n\n return;\n }\n\n channel.stop();\n}\n\nexport function applyAllChannelRunningStates(\n state: Pick<\n OrchestratorState,\n | \"browserChat\"\n | \"telegram\"\n | \"imessage\"\n | \"peerjs\"\n | \"channelEnabledByType\"\n | \"telegramBotToken\"\n | \"imessageServerUrl\"\n | \"peerjsMyPeerId\"\n >,\n force: boolean = false,\n): void {\n applyChannelRunningState(state, \"browser\", force);\n applyChannelRunningState(state, \"telegram\", force);\n applyChannelRunningState(state, \"imessage\", force);\n applyChannelRunningState(state, \"peerjs\", force);\n}\n\nexport function clearPeerJsTypingState(groupId: string): void {\n orchestratorStore.setRemoteAgentTyping(groupId, false);\n}\n\n// ── Async channel operations ────────────────────────────────────────────────\n\nexport async function loadChannelEnabled(\n channelType: ChannelType,\n db: ShadowClawDatabase,\n _getConfig: GetConfigFn = _defaultGetConfig,\n): Promise<boolean> {\n const stored = await _getConfig(db, getChannelEnabledConfigKey(channelType));\n\n if (!stored) {\n return false;\n }\n\n return stored !== \"false\";\n}\n\nexport async function setChannelEnabled(\n state: Pick<\n OrchestratorState,\n | \"channelEnabledByType\"\n | \"browserChat\"\n | \"telegram\"\n | \"imessage\"\n | \"peerjs\"\n | \"telegramBotToken\"\n | \"imessageServerUrl\"\n | \"peerjsMyPeerId\"\n >,\n db: ShadowClawDatabase,\n channelType: ChannelType,\n enabled: boolean,\n _setConfig: SetConfigFn = _defaultSetConfig,\n): Promise<void> {\n if (channelType === \"browser\") {\n return;\n }\n\n const normalizedEnabled = !!enabled;\n state.channelEnabledByType[channelType] = normalizedEnabled;\n\n await _setConfig(\n db,\n getChannelEnabledConfigKey(channelType),\n normalizedEnabled ? \"true\" : \"false\",\n );\n\n applyChannelRunningState(state, channelType);\n}\n\nexport function submitMessage(\n state: {\n browserChat: {\n submit: (\n text: string,\n groupId?: string,\n attachments?: MessageAttachment[],\n a2uiAction?: A2UIAction,\n ) => void;\n };\n },\n text: string,\n groupId = DEFAULT_GROUP_ID,\n attachments: MessageAttachment[] = [],\n a2uiAction?: A2UIAction,\n): void {\n state.browserChat.submit(text, groupId, attachments, a2uiAction);\n}\n\nexport async function saveSecretConfig(\n db: ShadowClawDatabase,\n key: string,\n value: string,\n _setConfig: SetConfigFn = _defaultSetConfig,\n): Promise<void> {\n if (!value) {\n await _setConfig(db, key, \"\");\n\n return;\n }\n\n const encrypted = await encryptValue(value);\n if (!encrypted) {\n throw new Error(`Failed to encrypt secret config for ${key}`);\n }\n\n await _setConfig(db, key, encrypted);\n}\n\nexport async function configureIMessage(\n state: OrchestratorState,\n db: ShadowClawDatabase,\n serverUrl: string,\n apiKey: string,\n chatIds: string[],\n _setConfig: SetConfigFn = _defaultSetConfig,\n _saveSecretConfig: typeof saveSecretConfig = saveSecretConfig,\n): Promise<void> {\n const normalizedServerUrl = serverUrl.trim().replace(/\\/+$/, \"\");\n const normalizedApiKey = apiKey.trim();\n const normalizedChatIds = normalizeStringList(chatIds);\n\n state.imessageServerUrl = normalizedServerUrl;\n state.imessageApiKey = normalizedApiKey;\n state.imessageChatIds = normalizedChatIds;\n\n await _setConfig(db, CONFIG_KEYS.IMESSAGE_SERVER_URL, normalizedServerUrl);\n await _saveSecretConfig(db, CONFIG_KEYS.IMESSAGE_API_KEY, normalizedApiKey);\n\n await _setConfig(\n db,\n CONFIG_KEYS.IMESSAGE_CHAT_IDS,\n JSON.stringify(normalizedChatIds),\n );\n\n state.imessage.stop();\n state.imessage.configure(\n normalizedServerUrl,\n normalizedApiKey,\n normalizedChatIds,\n );\n\n if (normalizedServerUrl && getChannelEnabled(state, \"imessage\")) {\n state.imessage.start();\n }\n}\n\nexport async function configureTelegram(\n state: OrchestratorState,\n db: ShadowClawDatabase,\n token: string,\n chatIds: string[],\n useProxy = false,\n _setConfig: SetConfigFn = _defaultSetConfig,\n _saveSecretConfig: typeof saveSecretConfig = saveSecretConfig,\n): Promise<void> {\n const normalizedToken = token.trim();\n const normalizedChatIds = normalizeStringList(chatIds);\n const normalizedUseProxy = !!useProxy;\n\n state.telegramBotToken = normalizedToken;\n state.telegramChatIds = normalizedChatIds;\n state.telegramUseProxy = normalizedUseProxy;\n\n await _saveSecretConfig(db, CONFIG_KEYS.TELEGRAM_BOT_TOKEN, normalizedToken);\n\n await _setConfig(\n db,\n CONFIG_KEYS.TELEGRAM_CHAT_IDS,\n JSON.stringify(normalizedChatIds),\n );\n\n await _setConfig(\n db,\n CONFIG_KEYS.TELEGRAM_USE_PROXY,\n normalizedUseProxy ? \"true\" : \"false\",\n );\n\n state.telegram.stop();\n state.telegram.configure(\n normalizedToken,\n normalizedChatIds,\n normalizedUseProxy,\n );\n\n if (normalizedToken && getChannelEnabled(state, \"telegram\")) {\n state.telegram.start();\n }\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"channel-DB77spML.js","names":["_defaultGetConfig","_defaultSetConfig"],"sources":["../../src/core/orchestrator/utils/operations/channel.ts"],"sourcesContent":["import { CONFIG_KEYS, DEFAULT_GROUP_ID } from \"../../../../config/config.js\";\nimport { getConfig as _defaultGetConfig } from \"../../../../db/get-config.js\";\nimport { setConfig as _defaultSetConfig } from \"../../../../db/set-config.js\";\nimport { encryptValue } from \"../../../../security/crypto.js\";\nimport { orchestratorStore } from \"../../../../stores/orchestrator.js\";\nimport { normalizeStringList } from \"../../../../utils/normalize-string-list.js\";\n\nimport type { MessageAttachment } from \"../../../../content/types.js\";\nimport type { ShadowClawDatabase } from \"../../../../db/db.js\";\n\nimport type {\n Channel,\n ChannelType,\n} from \"../../../../subsystems/channels/types.js\";\n\nimport type { A2UIAction } from \"../../../../ui/a2ui/types.js\";\nimport type { OrchestratorState } from \"../../orchestrator-state.js\";\n\ntype SetConfigFn = (\n db: ShadowClawDatabase,\n key: string,\n value: string,\n) => Promise<void>;\n\ntype GetConfigFn = (\n db: ShadowClawDatabase,\n key: string,\n) => Promise<string | undefined>;\n\n// ── Pure channel lookups ────────────────────────────────────────────────────\n\nexport function getChannelTypeForGroup(\n state: {\n channelRegistry?: {\n getChannelType: (groupId: string) => ChannelType | null | undefined;\n };\n },\n groupId: string,\n): ChannelType {\n return state.channelRegistry?.getChannelType(groupId) ?? \"browser\";\n}\n\nexport function getChannelByType(\n state: Pick<\n OrchestratorState,\n \"browserChat\" | \"telegram\" | \"imessage\" | \"peerjs\"\n >,\n channelType: ChannelType,\n): Channel | null {\n switch (channelType) {\n case \"browser\":\n return state.browserChat;\n case \"telegram\":\n return state.telegram;\n case \"imessage\":\n return state.imessage;\n case \"peerjs\":\n return state.peerjs;\n default:\n return null;\n }\n}\n\nexport function getChannelEnabled(\n state: Pick<OrchestratorState, \"channelEnabledByType\">,\n channelType: ChannelType,\n): boolean {\n if (channelType === \"browser\") {\n return true;\n }\n\n return state.channelEnabledByType[channelType] !== false;\n}\n\nexport function getPeerJsConfig(state: {\n channelEnabledByType: Record<ChannelType, boolean>;\n peerjsMyAlias: string;\n peerjsMyPeerId: string;\n peerjsPeerAliases: Record<string, string>;\n peerjsServerHost: string;\n peerjsServerPath: string;\n peerjsServerPort: number;\n peerjsServerSecure: boolean;\n peerjsTrustedPeerIds: string[];\n}): {\n enabled: boolean;\n myAlias: string;\n myPeerId: string;\n peerAliases: Record<string, string>;\n serverHost: string;\n serverPath: string;\n serverPort: number;\n serverSecure: boolean;\n trustedPeerIds: string[];\n} {\n return {\n enabled: getChannelEnabled(state, \"peerjs\"),\n myAlias: state.peerjsMyAlias,\n myPeerId: state.peerjsMyPeerId,\n peerAliases: { ...state.peerjsPeerAliases },\n serverHost: state.peerjsServerHost,\n serverPath: state.peerjsServerPath,\n serverPort: state.peerjsServerPort,\n serverSecure: state.peerjsServerSecure,\n trustedPeerIds: [...state.peerjsTrustedPeerIds],\n };\n}\n\nexport function getTelegramConfig(state: {\n telegramBotToken: string;\n telegramChatIds: string[];\n channelEnabledByType: Record<ChannelType, boolean>;\n telegramUseProxy: boolean;\n}): {\n botToken: string;\n chatIds: string[];\n enabled: boolean;\n useProxy: boolean;\n} {\n return {\n botToken: state.telegramBotToken,\n chatIds: [...state.telegramChatIds],\n enabled: getChannelEnabled(state, \"telegram\"),\n useProxy: state.telegramUseProxy,\n };\n}\n\nexport function getIMessageConfig(state: {\n imessageApiKey: string;\n imessageChatIds: string[];\n channelEnabledByType: Record<ChannelType, boolean>;\n imessageServerUrl: string;\n}): {\n apiKey: string;\n chatIds: string[];\n enabled: boolean;\n serverUrl: string;\n} {\n return {\n apiKey: state.imessageApiKey,\n chatIds: [...state.imessageChatIds],\n enabled: getChannelEnabled(state, \"imessage\"),\n serverUrl: state.imessageServerUrl,\n };\n}\n\nexport function getChannelEnabledConfigKey(channelType: ChannelType): string {\n return `${CONFIG_KEYS.CHANNEL_ENABLED_PREFIX}${channelType}`;\n}\n\nexport function shouldRunChannel(\n state: Pick<\n OrchestratorState,\n | \"channelEnabledByType\"\n | \"telegramBotToken\"\n | \"imessageServerUrl\"\n | \"peerjsMyPeerId\"\n >,\n channelType: ChannelType,\n): boolean {\n if (channelType === \"browser\") {\n return true;\n }\n\n if (!getChannelEnabled(state, channelType)) {\n return false;\n }\n\n switch (channelType) {\n case \"telegram\":\n return state.telegramBotToken.length > 0;\n case \"imessage\":\n return state.imessageServerUrl.length > 0;\n case \"peerjs\":\n return state.peerjsMyPeerId.length > 0;\n default:\n return true;\n }\n}\n\nexport function applyChannelRunningState(\n state: Pick<\n OrchestratorState,\n | \"browserChat\"\n | \"telegram\"\n | \"imessage\"\n | \"peerjs\"\n | \"channelEnabledByType\"\n | \"telegramBotToken\"\n | \"imessageServerUrl\"\n | \"peerjsMyPeerId\"\n >,\n channelType: ChannelType,\n force: boolean = false,\n): void {\n const channel = getChannelByType(state, channelType);\n if (!channel) {\n return;\n }\n\n if (shouldRunChannel(state, channelType)) {\n if (!channel.running) {\n channel.start();\n } else if (typeof (channel as any).ensureConnected === \"function\") {\n (channel as any).ensureConnected(force);\n }\n\n return;\n }\n\n channel.stop();\n}\n\nexport function applyAllChannelRunningStates(\n state: Pick<\n OrchestratorState,\n | \"browserChat\"\n | \"telegram\"\n | \"imessage\"\n | \"peerjs\"\n | \"channelEnabledByType\"\n | \"telegramBotToken\"\n | \"imessageServerUrl\"\n | \"peerjsMyPeerId\"\n >,\n force: boolean = false,\n): void {\n applyChannelRunningState(state, \"browser\", force);\n applyChannelRunningState(state, \"telegram\", force);\n applyChannelRunningState(state, \"imessage\", force);\n applyChannelRunningState(state, \"peerjs\", force);\n}\n\nexport function clearPeerJsTypingState(groupId: string): void {\n orchestratorStore.setRemoteAgentTyping(groupId, false);\n}\n\n// ── Async channel operations ────────────────────────────────────────────────\n\nexport async function loadChannelEnabled(\n channelType: ChannelType,\n db: ShadowClawDatabase,\n _getConfig: GetConfigFn = _defaultGetConfig,\n): Promise<boolean> {\n const stored = await _getConfig(db, getChannelEnabledConfigKey(channelType));\n\n if (!stored) {\n return false;\n }\n\n return stored !== \"false\";\n}\n\nexport async function setChannelEnabled(\n state: Pick<\n OrchestratorState,\n | \"channelEnabledByType\"\n | \"browserChat\"\n | \"telegram\"\n | \"imessage\"\n | \"peerjs\"\n | \"telegramBotToken\"\n | \"imessageServerUrl\"\n | \"peerjsMyPeerId\"\n >,\n db: ShadowClawDatabase,\n channelType: ChannelType,\n enabled: boolean,\n _setConfig: SetConfigFn = _defaultSetConfig,\n): Promise<void> {\n if (channelType === \"browser\") {\n return;\n }\n\n const normalizedEnabled = !!enabled;\n state.channelEnabledByType[channelType] = normalizedEnabled;\n\n await _setConfig(\n db,\n getChannelEnabledConfigKey(channelType),\n normalizedEnabled ? \"true\" : \"false\",\n );\n\n applyChannelRunningState(state, channelType);\n}\n\nexport function submitMessage(\n state: {\n browserChat: {\n submit: (\n text: string,\n groupId?: string,\n attachments?: MessageAttachment[],\n a2uiAction?: A2UIAction,\n ) => void;\n };\n },\n text: string,\n groupId = DEFAULT_GROUP_ID,\n attachments: MessageAttachment[] = [],\n a2uiAction?: A2UIAction,\n): void {\n state.browserChat.submit(text, groupId, attachments, a2uiAction);\n}\n\nexport async function saveSecretConfig(\n db: ShadowClawDatabase,\n key: string,\n value: string,\n _setConfig: SetConfigFn = _defaultSetConfig,\n): Promise<void> {\n if (!value) {\n await _setConfig(db, key, \"\");\n\n return;\n }\n\n const encrypted = await encryptValue(value);\n if (!encrypted) {\n throw new Error(`Failed to encrypt secret config for ${key}`);\n }\n\n await _setConfig(db, key, encrypted);\n}\n\nexport async function configureIMessage(\n state: OrchestratorState,\n db: ShadowClawDatabase,\n serverUrl: string,\n apiKey: string,\n chatIds: string[],\n _setConfig: SetConfigFn = _defaultSetConfig,\n _saveSecretConfig: typeof saveSecretConfig = saveSecretConfig,\n): Promise<void> {\n const normalizedServerUrl = serverUrl.trim().replace(/\\/+$/, \"\");\n const normalizedApiKey = apiKey.trim();\n const normalizedChatIds = normalizeStringList(chatIds);\n\n state.imessageServerUrl = normalizedServerUrl;\n state.imessageApiKey = normalizedApiKey;\n state.imessageChatIds = normalizedChatIds;\n\n await _setConfig(db, CONFIG_KEYS.IMESSAGE_SERVER_URL, normalizedServerUrl);\n await _saveSecretConfig(db, CONFIG_KEYS.IMESSAGE_API_KEY, normalizedApiKey);\n\n await _setConfig(\n db,\n CONFIG_KEYS.IMESSAGE_CHAT_IDS,\n JSON.stringify(normalizedChatIds),\n );\n\n state.imessage.stop();\n state.imessage.configure(\n normalizedServerUrl,\n normalizedApiKey,\n normalizedChatIds,\n );\n\n if (normalizedServerUrl && getChannelEnabled(state, \"imessage\")) {\n state.imessage.start();\n }\n}\n\nexport async function configureTelegram(\n state: OrchestratorState,\n db: ShadowClawDatabase,\n token: string,\n chatIds: string[],\n useProxy = false,\n _setConfig: SetConfigFn = _defaultSetConfig,\n _saveSecretConfig: typeof saveSecretConfig = saveSecretConfig,\n): Promise<void> {\n const normalizedToken = token.trim();\n const normalizedChatIds = normalizeStringList(chatIds);\n const normalizedUseProxy = !!useProxy;\n\n state.telegramBotToken = normalizedToken;\n state.telegramChatIds = normalizedChatIds;\n state.telegramUseProxy = normalizedUseProxy;\n\n await _saveSecretConfig(db, CONFIG_KEYS.TELEGRAM_BOT_TOKEN, normalizedToken);\n\n await _setConfig(\n db,\n CONFIG_KEYS.TELEGRAM_CHAT_IDS,\n JSON.stringify(normalizedChatIds),\n );\n\n await _setConfig(\n db,\n CONFIG_KEYS.TELEGRAM_USE_PROXY,\n normalizedUseProxy ? \"true\" : \"false\",\n );\n\n state.telegram.stop();\n state.telegram.configure(\n normalizedToken,\n normalizedChatIds,\n normalizedUseProxy,\n );\n\n if (normalizedToken && getChannelEnabled(state, \"telegram\")) {\n state.telegram.start();\n }\n}\n"],"mappings":"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"}
|
|
@@ -5,7 +5,7 @@ import { t as require_browser } from "./browser-sqa-Vhnx.js";
|
|
|
5
5
|
import { F as getProvider, I as getProviderApiKeyConfigKey, P as getModelMaxTokens, c as DEFAULT_PROMPT_API_FALLBACK_MODEL, m as FETCH_MAX_RESPONSE, n as BASH_MAX_TIMEOUT_SEC, o as DEFAULT_GROUP_ID, p as DEFAULT_VM_NETWORK_RELAY_URL, r as CONFIG_KEYS, u as DEFAULT_SUBAGENT_WORKSPACE_MODE } from "./config-BrHR97zt.js";
|
|
6
6
|
import { a as DEFAULT_BUILTIN_PROFILE, d as readGroupFile, o as writeGroupFile, r as findDeclarativeTool, s as groupFileExists, t as toolsStore, u as getAllTasks } from "./tools-B8OJ4sMF.js";
|
|
7
7
|
import { t as readGroupFileBytes } from "./read-group-file-bytes-UQIk1eJG.js";
|
|
8
|
-
import { l as listGroupFiles, s as deleteGroupDirectory, t as orchestratorStore, y as listGroups } from "./orchestrator-
|
|
8
|
+
import { l as listGroupFiles, s as deleteGroupDirectory, t as orchestratorStore, y as listGroups } from "./orchestrator-cRBe3lhq.js";
|
|
9
9
|
import { ulid } from "./utils/ulid.js";
|
|
10
10
|
import { stripHtml } from "./utils/html.js";
|
|
11
11
|
import { parseBooleanConfig } from "./utils/parse-boolean-config.js";
|
|
@@ -17,14 +17,14 @@ import { getImageMimeType, guessMimeTypeFromFilename, isImagePath } from "./util
|
|
|
17
17
|
import { t as uploadGroupFile } from "./upload-group-file-CJpoNjEb.js";
|
|
18
18
|
import { basename, sanitizeFilename } from "./utils/filename.js";
|
|
19
19
|
import { t as writeGroupFileBytes } from "./write-group-file-bytes-CNT7DqOZ.js";
|
|
20
|
-
import { i as copyGroupEntry, n as deleteGroupFile, r as createGroupDirectory, t as moveGroupEntry } from "./move-group-entry-
|
|
20
|
+
import { i as copyGroupEntry, n as deleteGroupFile, r as createGroupDirectory, t as moveGroupEntry } from "./move-group-entry-D8dptMg0.js";
|
|
21
21
|
import { asNumber, asStringArray, asUidArray } from "./utils/coerce.js";
|
|
22
22
|
import { base64ToBytes, bytesToBase64 } from "./utils/base64.js";
|
|
23
23
|
import { n as decryptValue, r as encryptValue } from "./crypto-Bikgpqfe.js";
|
|
24
|
-
import { a as roomIdFromGroupId, r as getRoomMetadata, t as ROOM_PREFIX } from "./rooms-
|
|
24
|
+
import { a as roomIdFromGroupId, r as getRoomMetadata, t as ROOM_PREFIX } from "./rooms-Dzphx3rK.js";
|
|
25
25
|
import { i as listRemoteMcpTools, n as McpReauthRequiredError, o as resolveServiceCredentials, r as callRemoteMcpTool, u as listRemoteMcpConnections } from "./mcp-reconnect-BeqQvNWO.js";
|
|
26
26
|
import { r as resolveGitCredentials, t as buildAuthHeaders } from "./credentials-CZbngHXW.js";
|
|
27
|
-
import { _ as deliverResponse, c as ensureBuiltinAiPolyfills, g as sanitizeModelOutput, l as getPromptApiFallbackModel, n as loadSkill, o as executeNativeAiTask, p as getContextLimit, r as handleWorkerMessage, s as createTaskInstanceWithFallback, t as discoverSkills, u as summarizeText } from "./discover-skills-
|
|
27
|
+
import { _ as deliverResponse, c as ensureBuiltinAiPolyfills, g as sanitizeModelOutput, l as getPromptApiFallbackModel, n as loadSkill, o as executeNativeAiTask, p as getContextLimit, r as handleWorkerMessage, s as createTaskInstanceWithFallback, t as discoverSkills, u as summarizeText } from "./discover-skills-CXyaWHKi.js";
|
|
28
28
|
import { n as createModelCacheFetch, r as setModelCacheProgressHook, t as clearModelCacheProgressHook } from "./create-model-cache-fetch-D7Pm4xNT.js";
|
|
29
29
|
import { a as upsertEmailConnection, i as listEmailConnections, n as deleteEmailConnection, o as getEmailPluginManifest, r as getEmailConnection, s as listEmailPluginManifests, t as bindEmailCredentialRef } from "./connections-C1FWsBsE.js";
|
|
30
30
|
import { n as normalizeMessagesForChatTemplate } from "./chat-template-DPEKGJhB.js";
|
|
@@ -33,7 +33,7 @@ import { HttpError } from "./utils/http-error.js";
|
|
|
33
33
|
import { isBinaryContent, isBinaryContentType } from "./utils/is-binary.js";
|
|
34
34
|
import { RETRYABLE_STATUS_CODES, isRetryableFetchError, withRetry } from "./utils/retry.js";
|
|
35
35
|
import { a as require_has_property_descriptors, c as require_get_intrinsic, d as require_shams$1, f as require_gopd, h as require_stream_browserify, i as require_call_bind, l as require_hasown, m as require_type, n as require_which_typed_array, o as require_define_data_property, p as require_es_object_atoms, r as require_shams, s as require_call_bound, t as require_is_typed_array, u as require_get_proto, y as require_inherits_browser } from "./is-typed-array-C8DTZR-g.js";
|
|
36
|
-
import { i as estimateTokens, n as buildConversationMessages, r as buildDynamicContext, t as buildSystemPrompt } from "./system-prompt-
|
|
36
|
+
import { i as estimateTokens, n as buildConversationMessages, r as buildDynamicContext, t as buildSystemPrompt } from "./system-prompt-CxJ3Nx4c.js";
|
|
37
37
|
|
|
38
38
|
//#region src/worker/utils/create-log-message.ts
|
|
39
39
|
/**
|
|
@@ -81562,7 +81562,7 @@ async function executeDeclarativeTool(db, name, input, groupId, options = {}, de
|
|
|
81562
81562
|
//#region src/worker/utils/execute-tool.ts
|
|
81563
81563
|
let gitSubsystemPromise = null;
|
|
81564
81564
|
async function loadGitSubsystem() {
|
|
81565
|
-
if (!gitSubsystemPromise) gitSubsystemPromise = import("./git-
|
|
81565
|
+
if (!gitSubsystemPromise) gitSubsystemPromise = import("./git-CogDRlEz.js");
|
|
81566
81566
|
return gitSubsystemPromise;
|
|
81567
81567
|
}
|
|
81568
81568
|
async function executeGitToolDispatcher(db, name, input, groupId) {
|
|
@@ -82813,4 +82813,4 @@ async function compactContext(o, db, groupId = DEFAULT_GROUP_ID) {
|
|
|
82813
82813
|
|
|
82814
82814
|
//#endregion
|
|
82815
82815
|
export { require_deflate as a, require_zstream as c, compactContext, setPostHandler as d, unregisterSubagentCollector as f, require_inflate as i, post as l, createLogMessage as m, executeTool as n, require_messages as o, createToolActivityMessage as p, require_constants as r, require_common as s, invokeWithPromptApi as t, registerSubagentCollector as u };
|
|
82816
|
-
//# sourceMappingURL=compact-context-
|
|
82816
|
+
//# sourceMappingURL=compact-context-Q9t9aL1e.js.map
|