shadow-claw 1.59.6 → 1.59.7
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 +12 -4
- package/.well-known/mcp.json +12 -4
- package/dist/cli/build/build.js +1 -1
- package/dist/cli/{chunk-DM4xsTry.js → chunk-3vNYrs_L.js} +1 -1
- package/dist/cli/{chunk-Ctg5L55n.js → chunk-66BvqAV0.js} +1 -1
- package/dist/cli/{chunk-Bq38OubR.js → chunk-B0qusANw.js} +1 -1
- package/dist/cli/{chunk-yiVdvGCJ.js → chunk-B3TrWbca.js} +7 -7
- package/dist/cli/{chunk-C8DBACtx.js → chunk-B88Z8T_9.js} +1 -1
- package/dist/cli/chunk-BCjL0JXf.js +1 -0
- package/dist/cli/chunk-BNcu1oiT.js +1 -0
- package/dist/cli/{chunk-gvNsvav0.js → chunk-C5ypckWC.js} +7 -7
- package/dist/cli/{chunk-Dw8GndPD.js → chunk-CAAeGOdy.js} +1 -1
- package/dist/cli/chunk-CFxww5Yz.js +1 -0
- package/dist/cli/chunk-CGIgtL6R.js +1 -0
- package/dist/cli/{chunk-DJqHK-qS.js → chunk-CQaCgswD.js} +7 -7
- package/dist/cli/chunk-CZdCRqNe.js +7 -0
- package/dist/cli/chunk-CafdvLx-.js +1 -0
- package/dist/cli/{chunk-Bc_weULz.js → chunk-CncW6_WL.js} +1 -1
- package/dist/cli/chunk-DDvuLVfW.js +1 -0
- package/dist/cli/{chunk-Cq_kQohv.js → chunk-DMs7kREC.js} +1 -1
- package/dist/cli/{chunk-CX2itile.js → chunk-D_te8ufL.js} +1 -1
- package/dist/cli/{chunk-3wTukVof.js → chunk-DhOU6GYX.js} +1 -1
- package/dist/cli/chunk-Dhap1VwA.js +1 -0
- package/dist/cli/chunk-DwvavohW.js +1 -0
- package/dist/cli/{chunk-DLde6nuO.js → chunk-SRBRVorc.js} +1 -1
- package/dist/cli/{chunk-D3y7h9Xe.js → chunk-SxK79JmB.js} +1 -1
- package/dist/cli/chunk-_a0CkUNS.js +139 -0
- package/dist/cli/{chunk-C9o6lXP3.js → chunk-hVf839t7.js} +1 -1
- package/dist/cli/chunk-iB8OoMmW.js +7 -0
- package/dist/cli/cli.js +1 -1
- package/dist/headless-agent.js +1 -1
- package/dist/lib/{app-routes-DJdIjp2V.js → app-routes-BXiRvlNl.js} +7 -25
- package/dist/lib/{app-routes-DJdIjp2V.js.map → app-routes-BXiRvlNl.js.map} +1 -1
- package/dist/lib/{attachment-capabilities-Dbb-4ZP5.js → attachment-capabilities-BjkEPip8.js} +2 -2
- package/dist/lib/{attachment-capabilities-Dbb-4ZP5.js.map → attachment-capabilities-BjkEPip8.js.map} +1 -1
- package/dist/lib/{channel-Dlru5ofR.js → channel-mmdGzPkT.js} +3 -3
- package/dist/lib/{channel-Dlru5ofR.js.map → channel-mmdGzPkT.js.map} +1 -1
- package/dist/lib/{chat-template-BuuLY8l7.js → chat-template-DPEKGJhB.js} +2 -2
- package/dist/lib/{chat-template-BuuLY8l7.js.map → chat-template-DPEKGJhB.js.map} +1 -1
- package/dist/lib/{compact-context-BtR55YPU.js → compact-context-CY9BBlUQ.js} +19 -19
- package/dist/lib/{compact-context-BtR55YPU.js.map → compact-context-CY9BBlUQ.js.map} +1 -1
- package/dist/lib/components/common/shadow-claw-provider-model-picker.js +1 -1
- package/dist/lib/components/index.js +27 -27
- package/dist/lib/components/settings/shadow-claw-accounts.js +1 -1
- 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-integrations.js +1 -1
- package/dist/lib/components/settings/shadow-claw-llm.js +1 -1
- package/dist/lib/components/settings/shadow-claw-mcp-remote.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-a2ui.js +1 -1
- package/dist/lib/components/shadow-claw-accounts.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-integrations.js +1 -1
- package/dist/lib/components/shadow-claw-llm.js +1 -1
- package/dist/lib/components/shadow-claw-mcp-remote.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-page-header.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-provider-model-picker.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/{config-DxNI3TlW.js → config-BrHR97zt.js} +2 -2
- package/dist/lib/{config-DxNI3TlW.js.map → config-BrHR97zt.js.map} +1 -1
- package/dist/lib/{configure-peer-js-ChDhOZU4.js → configure-peer-js-ccNvax2N.js} +3 -3
- package/dist/lib/{configure-peer-js-ChDhOZU4.js.map → configure-peer-js-ccNvax2N.js.map} +1 -1
- package/dist/lib/{connections-DC4NZkJE.js → connections-C1FWsBsE.js} +2 -2
- package/dist/lib/{connections-DC4NZkJE.js.map → connections-C1FWsBsE.js.map} +1 -1
- package/dist/lib/{credentials-5vpz0XPk.js → credentials-CZbngHXW.js} +2 -2
- package/dist/lib/{credentials-5vpz0XPk.js.map → credentials-CZbngHXW.js.map} +1 -1
- package/dist/lib/{discover-skills-CD0sKvAI.js → discover-skills-OwlQ2sXA.js} +13 -13
- package/dist/lib/{discover-skills-CD0sKvAI.js.map → discover-skills-OwlQ2sXA.js.map} +1 -1
- package/dist/lib/{download-group-file-Dk3qaxhJ.js → download-group-file-D0wgg10Q.js} +2 -2
- package/dist/lib/{download-group-file-Dk3qaxhJ.js.map → download-group-file-D0wgg10Q.js.map} +1 -1
- package/dist/lib/{file-viewer-B4pRW-_G.js → file-viewer-DOfvX6yy.js} +5 -5
- package/dist/lib/{file-viewer-B4pRW-_G.js.map → file-viewer-DOfvX6yy.js.map} +1 -1
- package/dist/lib/{get-or-create-subscriber-id-HCcgDEPz.js → get-or-create-subscriber-id-wyzaML7Z.js} +2 -2
- package/dist/lib/{get-or-create-subscriber-id-HCcgDEPz.js.map → get-or-create-subscriber-id-wyzaML7Z.js.map} +1 -1
- package/dist/lib/{git-B3Q1euc5.js → git-D2J_j9X9.js} +5 -5
- package/dist/lib/{git-B3Q1euc5.js.map → git-D2J_j9X9.js.map} +1 -1
- package/dist/lib/{iframe-bridge-scripts-D8iuFhUk.js → iframe-bridge-scripts-Dx825LLG.js} +2 -2
- package/dist/lib/{iframe-bridge-scripts-D8iuFhUk.js.map → iframe-bridge-scripts-Dx825LLG.js.map} +1 -1
- package/dist/lib/index.js +28 -28
- package/dist/lib/{init-chat-split-resize-B0ODULx9.js → init-chat-split-resize-Cc0bd2z9.js} +2 -2
- package/dist/lib/{init-chat-split-resize-B0ODULx9.js.map → init-chat-split-resize-Cc0bd2z9.js.map} +1 -1
- package/dist/lib/{init-control-plane-C1FRRmjC.js → init-control-plane-B7blDVIE.js} +15 -15
- package/dist/lib/{init-control-plane-C1FRRmjC.js.map → init-control-plane-B7blDVIE.js.map} +1 -1
- package/dist/lib/{invoke-agent-CzN7sVh-.js → invoke-agent-SxvudiDT.js} +11 -11
- package/dist/lib/{invoke-agent-CzN7sVh-.js.map → invoke-agent-SxvudiDT.js.map} +1 -1
- package/dist/lib/{markdown-mbNo7cV3.js → markdown--6vTAPEH.js} +2 -2
- package/dist/lib/{markdown-mbNo7cV3.js.map → markdown--6vTAPEH.js.map} +1 -1
- package/dist/lib/{mcp-reconnect-3T7yWGEY.js → mcp-reconnect-BeqQvNWO.js} +3 -3
- package/dist/lib/{mcp-reconnect-3T7yWGEY.js.map → mcp-reconnect-BeqQvNWO.js.map} +1 -1
- package/dist/lib/{model-ranking-DGNSWYwN.js → model-ranking-BhsJV7vb.js} +2 -2
- package/dist/lib/{model-ranking-DGNSWYwN.js.map → model-ranking-BhsJV7vb.js.map} +1 -1
- package/dist/lib/{move-group-entry-NMTJ59M9.js → move-group-entry-DDpjxa10.js} +5 -5
- package/dist/lib/{move-group-entry-NMTJ59M9.js.map → move-group-entry-DDpjxa10.js.map} +1 -1
- package/dist/lib/{orchestrator-B8FV1V7x.js → orchestrator-C7fkh7T7.js} +24 -24
- package/dist/lib/{orchestrator-B8FV1V7x.js.map → orchestrator-C7fkh7T7.js.map} +1 -1
- package/dist/lib/{orchestrator-i_QJ-o22.js → orchestrator-CCARkxQC.js} +11 -11
- package/dist/lib/orchestrator-CCARkxQC.js.map +1 -0
- package/dist/lib/{parse-path-DPCn-HwI.js → parse-path-BOHQP_IQ.js} +3 -3
- package/dist/lib/{parse-path-DPCn-HwI.js.map → parse-path-BOHQP_IQ.js.map} +1 -1
- package/dist/lib/{peerjs-z5zeioPV.js → peerjs-Bfw_FWLB.js} +8 -8
- package/dist/lib/{peerjs-z5zeioPV.js.map → peerjs-Bfw_FWLB.js.map} +1 -1
- package/dist/lib/{process-peer-query-param-CJp7w7AU.js → process-peer-query-param-BxYiZNdf.js} +5 -5
- package/dist/lib/{process-peer-query-param-CJp7w7AU.js.map → process-peer-query-param-BxYiZNdf.js.map} +1 -1
- package/dist/lib/{process-pending-shared-payloads-B6_TlBFA.js → process-pending-shared-payloads-DPIbwRb3.js} +4 -4
- package/dist/lib/{process-pending-shared-payloads-B6_TlBFA.js.map → process-pending-shared-payloads-DPIbwRb3.js.map} +1 -1
- package/dist/lib/{process-room-query-param-C3FFGGn6.js → process-room-query-param-B2_d50nE.js} +4 -4
- package/dist/lib/{process-room-query-param-C3FFGGn6.js.map → process-room-query-param-B2_d50nE.js.map} +1 -1
- package/dist/lib/{provider-DcQZypu5.js → provider-BC9KPI14.js} +3 -3
- package/dist/lib/{provider-DcQZypu5.js.map → provider-BC9KPI14.js.map} +1 -1
- package/dist/lib/{push-client-Cx5rMs6J.js → push-client-rrjTdc-U.js} +5 -5
- package/dist/lib/{push-client-Cx5rMs6J.js.map → push-client-rrjTdc-U.js.map} +1 -1
- package/dist/lib/{read-group-file-bytes-CXOG_YyM.js → read-group-file-bytes-UQIk1eJG.js} +2 -2
- package/dist/lib/{read-group-file-bytes-CXOG_YyM.js.map → read-group-file-bytes-UQIk1eJG.js.map} +1 -1
- package/dist/lib/{rooms-CwlkYLDU.js → rooms-bwGoYb1q.js} +2 -2
- package/dist/lib/{rooms-CwlkYLDU.js.map → rooms-bwGoYb1q.js.map} +1 -1
- package/dist/lib/{shadow-claw-DoQ7fgl5.js → shadow-claw-CypGVlVO.js} +17 -20
- package/dist/lib/shadow-claw-CypGVlVO.js.map +1 -0
- package/dist/lib/{shadow-claw-a2ui-Br6qJMs1.js → shadow-claw-a2ui-lG0vQbW8.js} +2 -2
- package/dist/lib/{shadow-claw-a2ui-Br6qJMs1.js.map → shadow-claw-a2ui-lG0vQbW8.js.map} +1 -1
- package/dist/lib/{shadow-claw-accounts-BTDILfWw.js → shadow-claw-accounts-CkqyCxwp.js} +3 -3
- package/dist/lib/{shadow-claw-accounts-BTDILfWw.js.map → shadow-claw-accounts-CkqyCxwp.js.map} +1 -1
- package/dist/lib/{shadow-claw-channel-config-IKiL34tI.js → shadow-claw-channel-config-DJpDovkF.js} +4 -4
- package/dist/lib/{shadow-claw-channel-config-IKiL34tI.js.map → shadow-claw-channel-config-DJpDovkF.js.map} +1 -1
- package/dist/lib/{shadow-claw-channels-JgEzuHWK.js → shadow-claw-channels-DJLwRovH.js} +3 -3
- package/dist/lib/{shadow-claw-channels-JgEzuHWK.js.map → shadow-claw-channels-DJLwRovH.js.map} +1 -1
- package/dist/lib/{shadow-claw-chat-SGUDT31r.js → shadow-claw-chat-B92cPaft.js} +15 -15
- package/dist/lib/{shadow-claw-chat-SGUDT31r.js.map → shadow-claw-chat-B92cPaft.js.map} +1 -1
- package/dist/lib/{shadow-claw-control-plane-CRWFZ3vD.js → shadow-claw-control-plane-fvn-qyHj.js} +7 -7
- package/dist/lib/{shadow-claw-control-plane-CRWFZ3vD.js.map → shadow-claw-control-plane-fvn-qyHj.js.map} +1 -1
- package/dist/lib/{shadow-claw-conversations-D23GJ7qo.js → shadow-claw-conversations-CsVyDOny.js} +7 -7
- package/dist/lib/{shadow-claw-conversations-D23GJ7qo.js.map → shadow-claw-conversations-CsVyDOny.js.map} +1 -1
- package/dist/lib/{shadow-claw-file-viewer-C1V8WTiU.js → shadow-claw-file-viewer-DFfyP7s5.js} +10 -10
- package/dist/lib/{shadow-claw-file-viewer-C1V8WTiU.js.map → shadow-claw-file-viewer-DFfyP7s5.js.map} +1 -1
- package/dist/lib/{shadow-claw-files-DN7irmE1.js → shadow-claw-files-cT6HL7ye.js} +11 -11
- package/dist/lib/{shadow-claw-files-DN7irmE1.js.map → shadow-claw-files-cT6HL7ye.js.map} +1 -1
- package/dist/lib/{shadow-claw-git-D-1oIh65.js → shadow-claw-git-Cv9mQgTx.js} +6 -6
- package/dist/lib/{shadow-claw-git-D-1oIh65.js.map → shadow-claw-git-Cv9mQgTx.js.map} +1 -1
- package/dist/lib/{shadow-claw-integrations-CZjnm7cM.js → shadow-claw-integrations-RZZ-m-Id.js} +4 -4
- package/dist/lib/{shadow-claw-integrations-CZjnm7cM.js.map → shadow-claw-integrations-RZZ-m-Id.js.map} +1 -1
- package/dist/lib/{shadow-claw-llm-4Gefh5FN.js → shadow-claw-llm-CKOYzPDp.js} +9 -9
- package/dist/lib/{shadow-claw-llm-4Gefh5FN.js.map → shadow-claw-llm-CKOYzPDp.js.map} +1 -1
- package/dist/lib/{shadow-claw-mcp-remote-B9ssb3YV.js → shadow-claw-mcp-remote-BKFROurv.js} +4 -4
- package/dist/lib/{shadow-claw-mcp-remote-B9ssb3YV.js.map → shadow-claw-mcp-remote-BKFROurv.js.map} +1 -1
- package/dist/lib/{shadow-claw-networking-BN5BB4hb.js → shadow-claw-networking-DYfiUQaH.js} +2 -2
- package/dist/lib/{shadow-claw-networking-BN5BB4hb.js.map → shadow-claw-networking-DYfiUQaH.js.map} +1 -1
- package/dist/lib/{shadow-claw-notifications-71KARtkY.js → shadow-claw-notifications-JJlzriuX.js} +3 -3
- package/dist/lib/{shadow-claw-notifications-71KARtkY.js.map → shadow-claw-notifications-JJlzriuX.js.map} +1 -1
- package/dist/lib/{shadow-claw-page-header-DMGO-TSe.js → shadow-claw-page-header-C_Qr3xZM.js} +2 -2
- package/dist/lib/{shadow-claw-page-header-DMGO-TSe.js.map → shadow-claw-page-header-C_Qr3xZM.js.map} +1 -1
- package/dist/lib/{shadow-claw-pages-BiRM6qiA.js → shadow-claw-pages-BCo3ihZI.js} +11 -11
- package/dist/lib/{shadow-claw-pages-BiRM6qiA.js.map → shadow-claw-pages-BCo3ihZI.js.map} +1 -1
- package/dist/lib/{shadow-claw-peerjs-BZu7jNSe.js → shadow-claw-peerjs-CFNjfrY5.js} +6 -6
- package/dist/lib/{shadow-claw-peerjs-BZu7jNSe.js.map → shadow-claw-peerjs-CFNjfrY5.js.map} +1 -1
- package/dist/lib/{shadow-claw-provider-model-picker-BXYXEobD.js → shadow-claw-provider-model-picker-B-Ct4yW-.js} +2 -2
- package/dist/lib/{shadow-claw-provider-model-picker-BXYXEobD.js.map → shadow-claw-provider-model-picker-B-Ct4yW-.js.map} +1 -1
- package/dist/lib/{shadow-claw-settings-CcT5EK08.js → shadow-claw-settings-BMwne0bh.js} +7 -7
- package/dist/lib/{shadow-claw-settings-CcT5EK08.js.map → shadow-claw-settings-BMwne0bh.js.map} +1 -1
- package/dist/lib/{shadow-claw-storage-eTOpbvpi.js → shadow-claw-storage-DUY8B9m-.js} +5 -5
- package/dist/lib/{shadow-claw-storage-eTOpbvpi.js.map → shadow-claw-storage-DUY8B9m-.js.map} +1 -1
- package/dist/lib/{shadow-claw-task-server-DFImTUbw.js → shadow-claw-task-server-yWeoA3eL.js} +2 -2
- package/dist/lib/{shadow-claw-task-server-DFImTUbw.js.map → shadow-claw-task-server-yWeoA3eL.js.map} +1 -1
- package/dist/lib/{shadow-claw-tasks-BjaxsmUx.js → shadow-claw-tasks-Bg0uM15I.js} +9 -9
- package/dist/lib/{shadow-claw-tasks-BjaxsmUx.js.map → shadow-claw-tasks-Bg0uM15I.js.map} +1 -1
- package/dist/lib/{shadow-claw-terminal-C-4wreFe.js → shadow-claw-terminal-fyJPppY_.js} +2 -2
- package/dist/lib/{shadow-claw-terminal-C-4wreFe.js.map → shadow-claw-terminal-fyJPppY_.js.map} +1 -1
- package/dist/lib/{shadow-claw-tools-COdrGZJk.js → shadow-claw-tools-D0T8m3go.js} +7 -7
- package/dist/lib/{shadow-claw-tools-COdrGZJk.js.map → shadow-claw-tools-D0T8m3go.js.map} +1 -1
- package/dist/lib/{shadow-claw-webvm-sxqVjO0L.js → shadow-claw-webvm-CQvzJwKI.js} +3 -3
- package/dist/lib/{shadow-claw-webvm-sxqVjO0L.js.map → shadow-claw-webvm-CQvzJwKI.js.map} +1 -1
- package/dist/lib/{sync-web-mcp-registration-D4hdUwtv.js → sync-web-mcp-registration-BFtG_4kx.js} +6 -6
- package/dist/lib/{sync-web-mcp-registration-D4hdUwtv.js.map → sync-web-mcp-registration-BFtG_4kx.js.map} +1 -1
- package/dist/lib/{system-prompt-DT_KeYaL.js → system-prompt-bhGRLoL2.js} +7 -7
- package/dist/lib/{system-prompt-DT_KeYaL.js.map → system-prompt-bhGRLoL2.js.map} +1 -1
- package/dist/lib/{tools-Beuyh8y1.js → tools-B8OJ4sMF.js} +4 -4
- package/dist/lib/{tools-Beuyh8y1.js.map → tools-B8OJ4sMF.js.map} +1 -1
- package/dist/lib/{transformers-DydnReu4.js → transformers-BMURofG6.js} +2 -2
- package/dist/lib/{transformers-DydnReu4.js.map → transformers-BMURofG6.js.map} +1 -1
- package/dist/lib/{trusted-types-CfwZl_rr.js → trusted-types-HwsGS5Nj.js} +19 -17
- package/dist/lib/{trusted-types-CfwZl_rr.js.map → trusted-types-HwsGS5Nj.js.map} +1 -1
- package/dist/lib/{upload-group-file-BbBzjTcN.js → upload-group-file-CJpoNjEb.js} +3 -3
- package/dist/lib/{upload-group-file-BbBzjTcN.js.map → upload-group-file-CJpoNjEb.js.map} +1 -1
- package/dist/lib/utils/index.js +1 -1
- package/dist/lib/utils/namespaced-storage.js +1 -1
- package/dist/lib/utils/runtime-assets.js +1 -1
- package/dist/lib/utils/utils.js +1 -1
- package/dist/lib/{webmcp-DCfAFiIO.js → webmcp-BoMTvgmX.js} +3 -3
- package/dist/lib/{webmcp-DCfAFiIO.js.map → webmcp-BoMTvgmX.js.map} +1 -1
- package/dist/lib/{write-group-file-bytes-Ccn-VFUU.js → write-group-file-bytes-CNT7DqOZ.js} +3 -3
- package/dist/lib/{write-group-file-bytes-Ccn-VFUU.js.map → write-group-file-bytes-CNT7DqOZ.js.map} +1 -1
- package/dist/public/.well-known/mcp/server-card.json +12 -4
- package/dist/public/.well-known/mcp.json +12 -4
- package/dist/public/agent.worker.js +1 -1
- package/dist/public/attachment-capabilities-AdwXt3--.js +1 -0
- package/dist/public/{channel-BylT3rJC.js → channel-Dk7wl-Av.js} +1 -1
- package/dist/public/{chat-template-DPHJy7tr.js → chat-template-BwAnTFKf.js} +1 -1
- package/dist/public/{compact-context-BINQh64w.js → compact-context-fOTqwKF6.js} +2 -2
- package/dist/public/config-C16fFWtP.js +1 -0
- package/dist/public/{configure-peer-js-DChhcOfe.js → configure-peer-js-BOV0tR6G.js} +1 -1
- package/dist/public/{connections-CHaw0VqP.js → connections-Dxwj8yK_.js} +1 -1
- package/dist/public/{create-model-cache-fetch-DQebkoPL.js → create-model-cache-fetch-DSAFjOwc.js} +1 -1
- package/dist/public/{credentials-CgVqS119.js → credentials-CJUQ5Ep2.js} +1 -1
- package/dist/public/{custom-element-security-kiDhPfb8.js → custom-element-security-B2daIE5r.js} +2 -2
- package/dist/public/{discover-skills-Cvmx5I9V.js → discover-skills-D1sNTy2r.js} +6 -6
- package/dist/public/docs/example/article/index.html +28 -29
- package/dist/public/docs/example/article.html +28 -29
- package/dist/public/docs/publishing/index.html +28 -29
- package/dist/public/docs/publishing.html +28 -29
- package/dist/public/docs/skill-creator/index.html +28 -29
- package/dist/public/docs/skill-creator.html +28 -29
- package/dist/public/{download-group-file-BapoRgfU.js → download-group-file-BkMH-JKi.js} +1 -1
- package/dist/public/{e2e-bridge-C0g8vZKr.js → e2e-bridge-Cz95DLlb.js} +1 -1
- package/dist/public/get-group-dir-D--BiEyk.js +1 -0
- package/dist/public/{get-or-create-subscriber-id-GvRZYXwA.js → get-or-create-subscriber-id-jVHnQfbr.js} +1 -1
- package/dist/public/{git-CaAAZfVd.js → git-BmMlwIMP.js} +2 -2
- package/dist/public/{iframe-bridge-scripts-BnqtKhE4.js → iframe-bridge-scripts-Cibg0m6A.js} +1 -1
- package/dist/public/index.html +28 -29
- package/dist/public/index.js +1 -1
- package/dist/public/{init-chat-split-resize-Btonoy8u.js → init-chat-split-resize-C8AqCCiK.js} +1 -1
- package/dist/public/init-control-plane-Cb31yLTY.js +1 -0
- package/dist/public/{invoke-agent-B3Osw6K7.js → invoke-agent-CN7mSV0Z.js} +1 -1
- package/dist/public/main/index.html +28 -29
- package/dist/public/main/memory/index.html +28 -29
- package/dist/public/main/memory.html +28 -29
- package/dist/public/main.html +28 -29
- package/dist/public/{markdown-CPbU4r1U.js → markdown-CDSb5Hrl.js} +1 -1
- package/dist/public/{mcp-reconnect-CzROVsXG.js → mcp-reconnect-iPZPihwX.js} +1 -1
- package/dist/public/{memory-storage-BkoMlxOr.js → memory-storage-2m7KZ-aP.js} +1 -1
- package/dist/public/{model-ranking-CK0iBo3Z.js → model-ranking-BgOSaNIy.js} +1 -1
- package/dist/public/{move-group-entry-CTxoq7lw.js → move-group-entry-CXneuNVa.js} +1 -1
- package/dist/public/orchestrator-DBO4NZqd.js +63 -0
- package/dist/public/{orchestrator-BrDjQbGf.js → orchestrator-Dyylc8IU.js} +2 -2
- package/dist/public/{peerjs-CgF4Iz5W.js → peerjs-l0jiBoh6.js} +1 -1
- package/dist/public/{process-peer-query-param-BL2k0Hu-.js → process-peer-query-param-s-aSP1Rq.js} +1 -1
- package/dist/public/{process-pending-shared-payloads-C1AgGvn8.js → process-pending-shared-payloads-BN3GigPT.js} +1 -1
- package/dist/public/{process-room-query-param-DM0QCq3_.js → process-room-query-param-B2Qe0F0M.js} +1 -1
- package/dist/public/provider-YPZmsuHR.js +1 -0
- package/dist/public/{push-client-DJEOz7bi.js → push-client-B2LC8Qp9.js} +1 -1
- package/dist/public/{rooms-C6LXIJl4.js → rooms-ChCEOvkw.js} +1 -1
- package/dist/public/service-worker.js +1 -1
- package/dist/public/shadow-claw-Br8mWDUx.js +1176 -0
- package/dist/public/{shadow-claw-accounts--4hd_oCz.js → shadow-claw-accounts-Dm6G7KMP.js} +1 -1
- package/dist/public/{shadow-claw-card-IbNlZAdK.js → shadow-claw-card-CggS8uSa.js} +1 -1
- package/dist/public/{shadow-claw-channels-Vq_pPGa2.js → shadow-claw-channels-088vhuWO.js} +1 -1
- package/dist/public/{shadow-claw-chat-D7_GS25e.js → shadow-claw-chat-BRwRlq-n.js} +3 -3
- package/dist/public/{shadow-claw-control-plane-WTMEV8_p.js → shadow-claw-control-plane-rhKACK85.js} +2 -2
- package/dist/public/{shadow-claw-conversations-CLQgU1IT.js → shadow-claw-conversations-CF_yUfKl.js} +1 -1
- package/dist/public/{shadow-claw-empty-state-D4CrFGsN.js → shadow-claw-empty-state-CkpOSXCS.js} +1 -1
- package/dist/public/{shadow-claw-file-viewer-BhqiqLWQ.js → shadow-claw-file-viewer-DWCejuY3.js} +4 -4
- package/dist/public/{shadow-claw-files-senDiG9l.js → shadow-claw-files-L6_ioyzh.js} +2 -2
- package/dist/public/{shadow-claw-git-DOOCqY23.js → shadow-claw-git-DsdkwLqQ.js} +2 -2
- package/dist/public/{shadow-claw-integrations-Bsvc3Agq.js → shadow-claw-integrations-CSbRTOm3.js} +1 -1
- package/dist/public/{shadow-claw-llm-actYICAk.js → shadow-claw-llm-BitaeAVc.js} +2 -2
- package/dist/public/{shadow-claw-mcp-remote-BYUgrK3v.js → shadow-claw-mcp-remote-gSbV5riy.js} +1 -1
- package/dist/public/{shadow-claw-networking-Dk3p5Ny_.js → shadow-claw-networking-Dn_y6Cl9.js} +1 -1
- package/dist/public/{shadow-claw-notifications-CzPAlay8.js → shadow-claw-notifications-Cj4Lqx8U.js} +1 -1
- package/dist/public/{shadow-claw-page-header-CjJpVkyL.js → shadow-claw-page-header-DR4OZFt2.js} +1 -1
- package/dist/public/{shadow-claw-page-header-action-button-2DH5O1TD.js → shadow-claw-page-header-action-button-BnCV_2Kb.js} +1 -1
- package/dist/public/{shadow-claw-pages-3r5I-wI8.js → shadow-claw-pages-mpDOtNYj.js} +6 -6
- package/dist/public/{shadow-claw-pdf-viewer-BiCEwsoY.js → shadow-claw-pdf-viewer-DZ_84qJH.js} +1 -1
- package/dist/public/{shadow-claw-settings-DgB9RSZN.js → shadow-claw-settings-CfFTYTEy.js} +2 -2
- package/dist/public/{shadow-claw-storage-JB_43nd8.js → shadow-claw-storage-DLmiT4bG.js} +1 -1
- package/dist/public/{shadow-claw-task-server-oi5UIxdA.js → shadow-claw-task-server-BoMBCsiS.js} +1 -1
- package/dist/public/{shadow-claw-tasks-CnyiOt81.js → shadow-claw-tasks-ChEp1j7x.js} +3 -3
- package/dist/public/{shadow-claw-terminal-BC3RynHt.js → shadow-claw-terminal-BaoVbOda.js} +1 -1
- package/dist/public/{shadow-claw-toast-YjG--2Za.js → shadow-claw-toast-e8oz7z6Z.js} +1 -1
- package/dist/public/{shadow-claw-tools-Bbwk4vlT.js → shadow-claw-tools-BYjUBiJz.js} +1 -1
- package/dist/public/{shadow-claw-webvm-HZqzl2H5.js → shadow-claw-webvm-xGb13TME.js} +1 -1
- package/dist/public/{sync-web-mcp-registration-BaH2nAP0.js → sync-web-mcp-registration-CQluj-Kz.js} +1 -1
- package/dist/public/{system-prompt-Dck3N8T0.js → system-prompt-CTJn0tK-.js} +1 -1
- package/dist/public/{tools-DHA1dK2I.js → tools-D-52Zmfc.js} +1 -1
- package/dist/public/{transformers-C-DuTM2K.js → transformers-CQ9ss9rD.js} +1 -1
- package/dist/public/{upload-group-file-Cejr3zo1.js → upload-group-file-A8kB7lvO.js} +1 -1
- package/dist/public/{webmcp-CMRtu57-.js → webmcp-DIUZjVF5.js} +1 -1
- package/dist/public/{write-group-file-CmJuVQNO.js → write-group-file-R67DjJ-q.js} +1 -1
- package/dist/public/{write-group-file-bytes-Cejr3zo1.js → write-group-file-bytes-A8kB7lvO.js} +1 -1
- package/dist/public/{zip-reader-CuQ13eLe.js → zip-reader-DN7FB-Q0.js} +1 -1
- package/dist/server.js +1 -1
- package/package.json +1 -1
- package/dist/cli/chunk-BFziiMKt.js +0 -7
- package/dist/cli/chunk-BM3llsxb.js +0 -1
- package/dist/cli/chunk-Bj5qFsDi.js +0 -7
- package/dist/cli/chunk-Bj95zm-y.js +0 -1
- package/dist/cli/chunk-BpyP-esT.js +0 -1
- package/dist/cli/chunk-CX696s3_.js +0 -1
- package/dist/cli/chunk-DRxCrCAA.js +0 -139
- package/dist/cli/chunk-DjbCHa0h.js +0 -1
- package/dist/cli/chunk-DsQhAF31.js +0 -1
- package/dist/cli/chunk-VM-dECyG.js +0 -1
- package/dist/cli/chunk-heu2xRw1.js +0 -1
- package/dist/lib/orchestrator-i_QJ-o22.js.map +0 -1
- package/dist/lib/shadow-claw-DoQ7fgl5.js.map +0 -1
- package/dist/public/app-routes-V_-URXc5.js +0 -1
- package/dist/public/attachment-capabilities-B6ibLwQB.js +0 -1
- package/dist/public/config-C-YdSFZB.js +0 -1
- package/dist/public/get-group-dir-DL44kvqW.js +0 -1
- package/dist/public/init-control-plane-BoJijVtf.js +0 -1
- package/dist/public/orchestrator-CaUpEVkQ.js +0 -63
- package/dist/public/provider-DNIL4-Hw.js +0 -1
- package/dist/public/shadow-claw-DdgeYPg5.js +0 -1176
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-DBVvNlSN.js";import{t}from"./browser-B1SoUj6D.js";import{r as n}from"./config-C-YdSFZB.js";import{o as r}from"./app-routes-V_-URXc5.js";import{n as i}from"./db-BUuJo1Gf.js";import{t as a}from"./ulid-BSJxYh6W.js";import{c as o,t as s}from"./tools-DHA1dK2I.js";var c=/* @__PURE__ */ e(t(),1),l=class{_transport;_url;_httpUrl;_token;_clientId;_peerId;_deviceLabel;_capabilities;_version;_heartbeatIntervalMs;_reconnectDelayMs;_maxReconnectDelayMs;_handlers;_WebSocketClass;_EventSourceClass;_fetchFn;_ws=null;_es=null;_heartbeatTimer=null;_reconnectTimer=null;_currentReconnectDelay;_isDestroyed=!1;_state=`disconnected`;constructor(e){if(this._transport=e.transport||`sse`,this._clientId=e.clientId,this._peerId=e.peerId,this._deviceLabel=e.deviceLabel||`ShadowClaw Browser Client`,this._capabilities=e.capabilities||[`webmcp`,`opfs`,`push`],this._version=e.version||`1.27.1`,this._token=e.token,this._heartbeatIntervalMs=e.heartbeatIntervalMs||1e4,this._reconnectDelayMs=e.reconnectDelayMs||1e3,this._maxReconnectDelayMs=e.maxReconnectDelayMs||3e4,this._currentReconnectDelay=this._reconnectDelayMs,this._handlers=/* @__PURE__ */ new Map,this._WebSocketClass=e.WebSocketClass||(typeof WebSocket<`u`?WebSocket:null),this._EventSourceClass=e.EventSourceClass||(typeof EventSource<`u`?EventSource:null),this._fetchFn=e.fetchFn||(typeof fetch<`u`?fetch.bind(globalThis):(()=>Promise.reject(/* @__PURE__ */ Error(`fetch not available`)))),e.handlers)for(let[t,n]of Object.entries(e.handlers))this.registerHandler(t,n);let t=typeof location<`u`?location:null,n=t?`${t.protocol}//${t.host}`:`http://127.0.0.1:8888`,r=t?`${t.protocol===`https:`?`wss:`:`ws:`}//${t.host}`:`ws://127.0.0.1:8888`;this._url=e.url||`${r}/ws/control`,this._httpUrl=e.httpUrl||n}get transport(){return this._transport}get version(){return this._version}registerHandler(e,t){this._handlers.set(e,t)}unregisterHandler(e){this._handlers.delete(e)}getState(){return this._state}ensureConnected(e=!1){if(this._isDestroyed=!1,this._reconnectTimer&&=(clearTimeout(this._reconnectTimer),null),this._currentReconnectDelay=this._reconnectDelayMs,this._transport===`websocket`){let t=this._ws&&(this._ws.readyState===1||this._ws.readyState===this._WebSocketClass?.OPEN);(e||!t||this._state!==`connected`)&&(this._cleanupConnection(),this.connect())}else{let t=this._es&&(this._es.readyState===1||this._es.readyState===this._EventSourceClass?.OPEN);(e||!t||this._state!==`connected`)&&(this._cleanupConnection(),this.connect())}}connect(){this._isDestroyed||this._state===`connected`||this._state===`connecting`||(this._transport===`websocket`?this._connectWebSocket():this._connectSse())}_connectWebSocket(){if(!this._WebSocketClass){console.warn(`[ControlPlaneClient] WebSocket not supported in this environment`);return}this._state=`connecting`;let e=new URL(this._url,`ws://127.0.0.1:8888`);this._token&&e.searchParams.set(`token`,this._token);try{let t=new this._WebSocketClass(e.toString());this._ws=t,t.onopen=()=>{this._state=`connected`,this._currentReconnectDelay=this._reconnectDelayMs,this._sendRegister(),this._startHeartbeat()},t.onmessage=e=>{this._handleMessage(e.data)},t.onclose=()=>{this._cleanupConnection(),this._isDestroyed||this._scheduleReconnect()},t.onerror=e=>{console.warn(`[ControlPlaneClient] WebSocket error:`,e)}}catch(e){console.warn(`[ControlPlaneClient] Failed to establish WebSocket connection:`,e),this._cleanupConnection(),this._scheduleReconnect()}}_connectSse(){if(!this._EventSourceClass){(c.default===void 0||!c.default.env?.JEST_WORKER_ID)&&console.warn(`[ControlPlaneClient] EventSource not supported in this environment`);return}this._state=`connecting`;let e=new URL(`/api/control/events`,this._httpUrl);e.searchParams.set(`clientId`,this._clientId),this._token&&e.searchParams.set(`token`,this._token);try{let t=new this._EventSourceClass(e.toString());this._es=t,t.onopen=()=>{this._state=`connected`,this._currentReconnectDelay=this._reconnectDelayMs,this._sendRegister(),this._startHeartbeat()},typeof t.addEventListener==`function`&&t.addEventListener(`command:execute`,e=>{this._handleMessage(e.data)}),t.onmessage=e=>{this._handleMessage(e.data)},t.onerror=e=>{console.warn(`[ControlPlaneClient] SSE connection error:`,e),this._cleanupConnection(),this._isDestroyed||this._scheduleReconnect()}}catch(e){console.warn(`[ControlPlaneClient] Failed to establish SSE connection:`,e),this._cleanupConnection(),this._scheduleReconnect()}}disconnect(){this._isDestroyed=!0;try{this._sendUnregister()}catch{}this._cleanupConnection(),this._reconnectTimer&&=(clearTimeout(this._reconnectTimer),null)}_cleanupConnection(){if(this._state=`disconnected`,this._stopHeartbeat(),this._ws){try{this._ws.close()}catch{}this._ws=null}if(this._es){try{this._es.close()}catch{}this._es=null}}_scheduleReconnect(){this._reconnectTimer||this._isDestroyed||(this._reconnectTimer=setTimeout(()=>{this._reconnectTimer=null,this._isDestroyed||this.connect()},this._currentReconnectDelay),this._currentReconnectDelay=Math.min(this._currentReconnectDelay*1.5,this._maxReconnectDelayMs))}_startHeartbeat(){this._stopHeartbeat(),this._heartbeatTimer=setInterval(()=>{this._sendHeartbeat()},this._heartbeatIntervalMs)}_stopHeartbeat(){this._heartbeatTimer&&=(clearInterval(this._heartbeatTimer),null)}_sendRegister(){let e={clientId:this._clientId,deviceLabel:this._deviceLabel,capabilities:this._capabilities,version:this._version,transport:this._transport,peerId:this._peerId};this._sendMessage({id:a(),type:`client:register`,payload:e})}_sendHeartbeat(){let e={clientId:this._clientId,timestamp:Date.now()};this._sendMessage({id:a(),type:`client:heartbeat`,payload:e})}_sendUnregister(){if(!this._clientId)return;let e={clientId:this._clientId};this._sendMessage({id:a(),type:`client:unregister`,payload:e})}_sendMessage(e){if(this._transport===`websocket`){this._ws&&(this._ws.readyState===1||this._ws.readyState===this._WebSocketClass?.OPEN)&&this._ws.send(JSON.stringify(e));return}let t=new URL(`/api/control/messages`,this._httpUrl),n={"Content-Type":`application/json`};this._token&&(n[`x-control-token`]=this._token,n.Authorization=`Bearer ${this._token}`);let r={method:`POST`,headers:n,body:JSON.stringify(e)},i=t.hostname.toLowerCase(),a=i===`localhost`||i===`127.0.0.1`||i===`::1`||i===`[::1]`,o=/^(10\.|172\.(1[6-9]|2\d|3[01])\.|192\.168\.)/.test(i);a?r.targetAddressSpace=`loopback`:o&&(r.targetAddressSpace=`private`),this._fetchFn(t.toString(),r).catch(e=>{console.warn(`[ControlPlaneClient] Failed to send message via HTTP POST:`,e)})}async _handleMessage(e){if(!e||typeof e!=`string`)return;let t;try{t=JSON.parse(e)}catch{return}if(t.type===`command:execute`){let{commandId:e,action:n,args:r}=t.payload,i=this._handlers.get(n);if(!i){this._sendMessage({id:a(),type:`command:result`,replyTo:t.id,payload:{commandId:e,success:!1,error:`Unknown action: ${n}`}});return}try{let n=await i(r);this._sendMessage({id:a(),type:`command:result`,replyTo:t.id,payload:{commandId:e,success:!0,data:n}})}catch(n){this._sendMessage({id:a(),type:`command:result`,replyTo:t.id,payload:{commandId:e,success:!1,error:n.message||String(n)}})}}}};function u(){if(typeof localStorage<`u`)try{let e=localStorage.getItem(n.CONTROL_PLANE_CLIENT_ID);if(e&&e.trim())return e.trim()}catch{}let e=r(),t=e?`${e}-${a().toLowerCase()}`:`client-${a().toLowerCase()}`;if(typeof localStorage<`u`)try{localStorage.setItem(n.CONTROL_PLANE_CLIENT_ID,t)}catch{}return t}async function d(e){if(typeof localStorage<`u`)try{let e=localStorage.getItem(n.CONTROL_PLANE_ENABLED);if(e!==null)return e===`true`||e===`1`}catch{}if(e)try{let{getConfig:t}=await import(`./get-config-Bkvl__ZS.js`).then(e=>e.n),r=await t(e,n.CONTROL_PLANE_ENABLED);if(r!=null)return r===`true`||r===`1`}catch{}return!1}function f(e){if(typeof EventSource>`u`&&typeof WebSocket>`u`)return!1;let t=e||(typeof location<`u`?location:null);return!(!t||t.protocol===`file:`||typeof document<`u`&&document.querySelector(`meta[name="shadowclaw-static-only"]`))}function p(e){let t=``;if(typeof localStorage<`u`)try{t=(localStorage.getItem(n.CONTROL_PLANE_URL)||``).trim()}catch{}let r=e||(typeof location<`u`?location:null),i=r&&(r.protocol===`file:`||r.hostname&&(r.hostname.endsWith(`.github.io`)||r.hostname.endsWith(`.pages.dev`))),a=t;a||=i?`http://127.0.0.1:8888`:r&&r.host?`${r.protocol}//${r.host}`:`http://127.0.0.1:8888`,a=a.replace(/\/+$/,``);let o=a.replace(/^https?:/,e=>e===`https:`?`wss:`:`ws:`);return{httpUrl:a,wsUrl:`${o}/ws/control`}}function m(){let e=[];return typeof navigator<`u`&&(navigator.storage&&typeof navigator.storage.getDirectory==`function`&&e.push(`opfs`),`serviceWorker`in navigator&&typeof window<`u`&&`PushManager`in window&&e.push(`push`),(typeof document<`u`&&document.modelContext||navigator&&navigator.modelContext)&&e.push(`webmcp`)),typeof RTCPeerConnection<`u`&&e.push(`peerjs`),e}function h(){if(typeof navigator>`u`)return`ShadowClaw Node`;let e=navigator.userAgent,t=`Desktop`;/iPad/i.test(e)?t=`iPad`:/iPhone/i.test(e)?t=`iPhone`:/Android/i.test(e)?t=`Android`:/Macintosh/i.test(e)?t=`Mac`:/Windows/i.test(e)?t=`Windows`:/Linux/i.test(e)&&(t=`Linux`);let n=`Browser`;return/Chrome/i.test(e)&&!/Edg/i.test(e)?n=`Chrome`:/Safari/i.test(e)&&!/Chrome/i.test(e)?n=`Safari`:/Firefox/i.test(e)?n=`Firefox`:/Edg/i.test(e)&&(n=`Edge`),`${t} ${n}`}function g(){let e=``,t=``;typeof document<`u`&&(e=document.querySelector(`meta[name="version"]`)?.getAttribute(`content`)?.trim()||``,t=document.querySelector(`meta[name="revision"]`)?.getAttribute(`content`)?.trim()||``);let n=t.length>7?t.slice(0,7):t;return e&&n?`${e} (${n})`:e||n||`1.27.1`}let _=null;async function v(e,t={},n={}){let r=u(),a=h(),c=m();switch(e){case`send-message`:{if(!t.text)throw Error(`Missing text parameter`);let{orchestratorStore:e}=await import(`./orchestrator-CaUpEVkQ.js`).then(e=>e.n),r=n.orchestrator||e.orchestrator,i=t.groupId||e.activeGroupId||`br:main`;return r?.browserChat?.submit?(r.browserChat.submit(t.text,i),{queued:!0,groupId:i}):r?.submitMessage?(r.submitMessage(t.text,i),{queued:!0,groupId:i}):e.sendMessage?(e.sendMessage(t.text),{queued:!0,groupId:i}):{queued:!1,error:`Orchestrator not ready`}}case`list-tasks`:{let e=await i(),n=await o(e);return t?.groupId&&(n=n.filter(e=>e.groupId===t.groupId)),{tasks:n}}case`read-state`:{let{orchestratorStore:e}=await import(`./orchestrator-CaUpEVkQ.js`).then(e=>e.n),t=n.orchestrator||e.orchestrator;return{clientId:r,deviceLabel:a,capabilities:c,version:n.version||g(),activeGroupId:n.orchestrator?.activeGroupId||e.activeGroupId||t?.activeGroupId||`br:main`,state:n.orchestrator?.state||e.state||t?.state||`idle`}}case`list-tools`:{try{let{getWebMcpTools:e}=await import(`./webmcp-CMRtu57-.js`),t=await e();if(t&&t.length>0)return{tools:t.map(e=>({name:e.name,description:e.description,inputSchema:e.inputSchema,annotations:e.annotations}))}}catch{}try{let{orchestratorStore:e}=await import(`./orchestrator-CaUpEVkQ.js`).then(e=>e.n),r=n.orchestrator||e.orchestrator||(typeof document<`u`?document.querySelector(`shadow-claw`)?.orchestrator:null),i=t.groupId||r?.activeGroupId||e.activeGroupId||`br:main`,a=e.groups.find(e=>e.groupId===i);if(a?.toolTags&&a.toolTags.length>0){let{TOOL_DEFINITIONS:e}=await import(`./tools-CHxUdGxZ.js`).then(e=>e.n),{parseWebMcpInputSchema:t}=await import(`./webmcp-CMRtu57-.js`);return{tools:e.filter(e=>a.toolTags.includes(e.name)).map(e=>({name:e.name,description:e.description,inputSchema:t(e.input_schema)}))}}}catch{}let{TOOL_DEFINITIONS:e}=await import(`./tools-CHxUdGxZ.js`).then(e=>e.n),{parseWebMcpInputSchema:r}=await import(`./webmcp-CMRtu57-.js`);return{tools:e.map(e=>({name:e.name,description:e.description,inputSchema:r(e.input_schema)}))}}case`invoke-tool`:{if(!t.toolName)throw Error(`Missing toolName parameter`);try{let{orchestratorStore:e}=await import(`./orchestrator-CaUpEVkQ.js`).then(e=>e.n),r=n.orchestrator||e.orchestrator||(typeof document<`u`?document.querySelector(`shadow-claw`)?.orchestrator:null),i=t.groupId||r?.activeGroupId||e.activeGroupId||`br:main`,a=e.groups.find(e=>e.groupId===i);if(a?.toolTags&&a.toolTags.length>0){if(!a.toolTags.includes(t.toolName))throw Error(`Tool '${t.toolName}' is not enabled in the active conversation (${i}).`)}else if(s?.allTools&&s.allTools.some(e=>e.name===t.toolName)&&s?.enabledToolNames&&s.enabledToolNames.size>0){let e=s.enabledToolNames.has(t.toolName),n=s.isDeclarativeToolEnabled(t.toolName);if(!e&&!n)throw Error(`Tool '${t.toolName}' is not enabled on this client.`)}}catch(e){if(e.message&&e.message.includes(`is not enabled`))throw e}let e=typeof document<`u`&&document.modelContext||typeof navigator<`u`&&navigator.modelContext;if(e){let n;if(typeof e.getTools==`function`)try{let r=await e.getTools();if(Array.isArray(r)&&r.length>0){if(n=r.find(e=>e.name===t.toolName),!n)throw Error(`Tool '${t.toolName}' is not enabled or registered on this client.`)}else n=Array.isArray(r)?r.find(e=>e.name===t.toolName):void 0;if(n&&typeof n.execute==`function`)return{result:await n.execute(typeof t.input==`string`?JSON.parse(t.input):t.input||{})}}catch(e){if(e.message&&e.message.includes(`is not enabled`))throw e}let{executeWebMcpTool:r}=await import(`./webmcp-CMRtu57-.js`);if(typeof e.executeTool==`function`){if(n)try{return{result:await r(e,n,t.input)}}catch{}try{return{result:await r(e,{name:t.toolName},t.input)}}catch{}try{return{result:await r(e,t.toolName,t.input)}}catch{}}let i=typeof t.input==`string`?t.input:JSON.stringify(t.input||{});if(typeof navigator<`u`&&navigator.modelContextTesting&&typeof navigator.modelContextTesting.executeTool==`function`)try{return{result:await navigator.modelContextTesting.executeTool(t.toolName,i)}}catch{}if(typeof e.callTool==`function`)try{return{result:await e.callTool({name:t.toolName,arguments:typeof t.input==`string`?JSON.parse(t.input):t.input||{}})}}catch{}if(typeof e.invoke==`function`)try{return{result:await e.invoke(t.toolName,typeof t.input==`string`?JSON.parse(t.input):t.input||{})}}catch{}}let{orchestratorStore:r}=await import(`./orchestrator-CaUpEVkQ.js`).then(e=>e.n),i=n.orchestrator||r.orchestrator||(typeof document<`u`?document.querySelector(`shadow-claw`)?.orchestrator:null),a=i?.agentWorker;if(a&&typeof a.postMessage==`function`){let e=Date.now().toString(36)+Math.random().toString(36).slice(2),n=t.toolName===`ask_user`,r=t.timeoutMs||(n?3e5:6e4);return{result:await new Promise((n,o)=>{let s=setTimeout(()=>{a.removeEventListener(`message`,c),o(/* @__PURE__ */ Error(`Timeout waiting for tool execution`))},r),c=t=>{let r=t.data;r&&r.type===`execute-tool-result`&&r.callId===e&&(clearTimeout(s),a.removeEventListener(`message`,c),r.error?o(Error(r.error)):n(r.result))};a.addEventListener(`message`,c),a.postMessage({type:`execute-tool`,callId:e,payload:{name:t.toolName,input:typeof t.input==`string`?JSON.parse(t.input):t.input||{},groupId:t.groupId||i?.activeGroupId||`br:main`}})})}}throw Error(`Tool ${t.toolName} could not be executed (no context or worker available)`)}case`trigger-backup`:{let{orchestratorStore:e}=await import(`./orchestrator-CaUpEVkQ.js`).then(e=>e.n),a=t.groupId||n.orchestrator?.activeGroupId||e.activeGroupId||`br:main`,o=await i(),{getGroupDir:s}=await import(`./get-group-dir-DL44kvqW.js`).then(e=>e.n),c=await s(o,a);async function l(e,t=``){let n=[];for await(let[r,i]of e.entries()){let e=t?`${t}/${r}`:r;if(i.kind===`directory`){let t=await l(i,e);n.push(...t)}else n.push(e)}return n}async function u(e){try{let t=e.split(`/`),n=c;for(let e=0;e<t.length-1;e++)n=await n.getDirectoryHandle(t[e]);let r=await(await(await n.getFileHandle(t[t.length-1])).getFile()).arrayBuffer();return new Uint8Array(r)}catch{return null}}let{BackupController:d}=await import(`./backup-controller-B6GyG4vY.js`);return await new d({clientId:r,token:t.token,serverBaseUrl:p().httpUrl,fileEnumerator:()=>l(c),fileReader:e=>u(e)}).initiate()}default:throw Error(`Unknown action '${e}'`)}}function y(e={}){if(_){try{_.disconnect()}catch{}_=null}let t=e.clientId&&e.clientId.trim()||u(),r=m(),i=h(),a=e.version||g(),o=null;if(typeof localStorage<`u`)try{let e=localStorage.getItem(n.CONTROL_PLANE_TRANSPORT);(e===`sse`||e===`websocket`)&&(o=e)}catch{}let s=e.transport||o||`sse`,c;if(typeof localStorage<`u`)try{c=localStorage.getItem(n.PEERJS_MY_PEER_ID)||void 0}catch{}let{httpUrl:d,wsUrl:y}=p(),b=new l({clientId:t,deviceLabel:i,capabilities:r,version:a,peerId:c,transport:s,httpUrl:d,url:y,handlers:{"send-message":t=>v(`send-message`,t,e),"list-tasks":t=>v(`list-tasks`,t,e),"read-state":t=>v(`read-state`,t,e),"invoke-tool":t=>v(`invoke-tool`,t,e),"list-tools":t=>v(`list-tools`,t,e),"trigger-backup":t=>v(`trigger-backup`,t,e)}});return e.autoConnect!==!1&&f()&&b.connect(),_=b,b}function b(){return _}function x(){if(_){try{_.disconnect()}catch{}_=null}}async function S(e={}){let t=e.db;if(!t)try{t=await i()}catch{}if(!await d(t))return x(),null;if(!f())return null;if(typeof localStorage<`u`&&t)try{let{getConfig:e}=await import(`./get-config-Bkvl__ZS.js`).then(e=>e.n),[r,i]=await Promise.all([e(t,n.CONTROL_PLANE_URL),e(t,n.CONTROL_PLANE_TRANSPORT)]);r&&localStorage.setItem(n.CONTROL_PLANE_URL,r),i&&localStorage.setItem(n.CONTROL_PLANE_TRANSPORT,i),localStorage.setItem(n.CONTROL_PLANE_ENABLED,`true`)}catch{}let r=b();return r?(r.ensureConnected(e.force),r):y(e)}export{h as detectDeviceLabel,S as ensureControlPlaneConnected,v as executeClientControlCommand,u as getOrCreateControlPlaneClientId,d as isControlPlaneEnabled,f as shouldConnectControlPlane,x as stopControlPlaneClient};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-DBVvNlSN.js";import{C as t,S as n,l as r,t as i}from"./custom-element-security-kiDhPfb8.js";import{o as a,r as o}from"./config-C-YdSFZB.js";import{a as s,h as c,n as l,o as u}from"./app-routes-V_-URXc5.js";import{n as d}from"./db-BUuJo1Gf.js";import{n as f,t as p}from"./tx-promise-DNVEN3Wa.js";import{t as m}from"./get-config-Bkvl__ZS.js";import{t as h}from"./dist-CeFyqf9k.js";import{t as g}from"./set-config-DSiuMe0k.js";import{t as _}from"./ulid-BSJxYh6W.js";import{c as v,o as y,s as b,t as x}from"./tools-DHA1dK2I.js";import{t as S}from"./get-or-create-subscriber-id-GvRZYXwA.js";import{a as C,o as w,r as ee,s as te,t as T}from"./get-group-dir-DL44kvqW.js";import{i as E,n as ne,r as re,t as D}from"./write-group-file-CmJuVQNO.js";import{t as ie}from"./dedent-eld_mRQx.js";import{a as ae,r as O}from"./toast-CtIuHprH.js";import{t as oe}from"./parse-boolean-config-BigJ9U46.js";function se(e,t,n,r){let i=t*2**e,a=Math.min(i,n),o=a*r*Math.random();return Math.max(0,a-o)}function ce(e,t){return new Promise((n,r)=>{if(t?.aborted){r(t.reason??new DOMException(`Aborted`,`AbortError`));return}let i=setTimeout(n,e);if(t){let e=()=>{clearTimeout(i),r(t.reason??new DOMException(`Aborted`,`AbortError`))};t.addEventListener(`abort`,e,{once:!0});let a=n;n=(n=>{t.removeEventListener(`abort`,e),a(n)})}})}async function k(){let e=typeof globalThis<`u`?globalThis:void 0;e?.scheduler&&typeof e.scheduler.yield==`function`?await e.scheduler.yield():await new Promise(e=>setTimeout(e,0))}function le(e,t=a){e.agentWorker?.postMessage({payload:{groupId:t},type:`vm-terminal-open`})}function ue(e,t=a){e.agentWorker?.postMessage({payload:{groupId:t},type:`vm-terminal-close`})}function de(e,t){e.agentWorker?.postMessage({payload:{data:t},type:`vm-terminal-input`})}function fe(e,t=a){e.agentWorker?.postMessage({payload:{groupId:t},type:`vm-workspace-sync`})}function pe(e,t=a){e.agentWorker?.postMessage({payload:{groupId:t},type:`vm-workspace-flush`})}function me(e,t,n){e.agentWorker?.postMessage({payload:{id:t,response:n},type:`ask-user-response`})}async function he(e,t,n,r=g){let i=n===`disabled`||n===`9p`||n===`ext2`||n===`auto`?n:`disabled`;e.vmBootMode=i,await r(t,o.VM_BOOT_MODE,i),e.agentWorker?.postMessage({payload:{mode:i},type:`set-vm-mode`})}async function ge(e,t,n,r=g){let i=typeof n==`string`?n.trim():``;await r(t,o.VM_BOOT_HOST,i),e.agentWorker?.postMessage({payload:{bootHost:i},type:`set-vm-mode`})}async function _e(e,t,n,r=g){let i=typeof n==`string`?n.trim():``;await r(t,o.VM_NETWORK_RELAY_URL,i),e.agentWorker?.postMessage({payload:{networkRelayUrl:i},type:`set-vm-mode`})}function ve(e){`serviceWorker`in navigator&&navigator.serviceWorker?.controller&&navigator.serviceWorker.controller.postMessage({type:`set-proxy-config`,payload:{useProxy:e.useProxy,proxyUrl:e.proxyUrl}})}async function ye(e,t,n,r=g){e.contextCompressionEnabled=!!n,await r(t,o.CONTEXT_COMPRESSION_ENABLED,e.contextCompressionEnabled?`true`:`false`)}async function be(e,t,n,r=g){e.gitProxyUrl=n||`/git-proxy`,await r(t,o.GIT_PROXY_URL,e.gitProxyUrl)}async function xe(e,t,n,r=g){e.maxIterations=n,await r(t,o.MAX_ITERATIONS,String(n))}async function Se(e,t,n,r=g){let i=Math.max(1,n);e.maxTokens=i,await r(t,o.MAX_TOKENS,String(i))}async function Ce(e,t,n,r=g){e.proxyUrl=n||`/proxy`,await r(t,o.PROXY_URL,e.proxyUrl),ve(e)}async function we(e,t,n,r=g){e.rateLimitAutoAdapt=!!n,await r(t,o.RATE_LIMIT_AUTO_ADAPT,e.rateLimitAutoAdapt?`true`:`false`)}async function Te(e,t,n,r=g){let i=Number.isFinite(n)?Math.max(0,Math.floor(n)):0;e.rateLimitCallsPerMinute=i,await r(t,o.RATE_LIMIT_CALLS_PER_MINUTE,String(i))}async function Ee(e,t,n,r=g){e.reasoningEffort=(typeof n==`string`?n.trim().toLowerCase():`none`)||`none`,await r(t,o.REASONING_EFFORT,e.reasoningEffort)}async function De(e,t,n,r=g){e.streamingEnabled=!!n,await r(t,o.STREAMING_ENABLED,e.streamingEnabled?`true`:`false`)}async function Oe(e,t,n,r=g){e.taskServerEnabled=!!n,await r(t,o.TASK_SERVER_ENABLED,e.taskServerEnabled?`true`:`false`)}async function ke(e,t,n,r=g){e.taskServerUrl=n||`http://localhost:8888/schedule`,await r(t,o.TASK_SERVER_URL,e.taskServerUrl)}async function Ae(e,t,n,r=g){e.useProxy=!!n,await r(t,o.USE_PROXY,e.useProxy?`true`:`false`),ve(e)}async function je(e,t,n,r=g){e.vmBashFullInternetAccess=!!n,await r(t,o.VM_BASH_FULL_INTERNET_ACCESS,e.vmBashFullInternetAccess?`true`:`false`)}async function Me(e,t,n,r=g){let i=Math.min(Math.max(Math.floor(n),1),1800);await r(t,o.VM_BASH_TIMEOUT_SEC,String(i))}function Ne(e,t){let n=null,r;return typeof e==`string`?r=e:(n=e,r=t),n&&f(n)?(n.db.prepare(`DELETE FROM messages WHERE groupId = ?`).run(r),Promise.resolve()):new Promise((e,t)=>{try{let i=n?.transaction(`messages`,`readwrite`);if(!i)return t(/* @__PURE__ */ Error(`failed to get transaction, cannot clear group messages.`));let a=i.objectStore(`messages`).index(`by-group`).openCursor(r);a.onsuccess=()=>{let t=a.result;t?(t.delete(),t.continue()):e(void 0)},a.onerror=()=>t(a.error)}catch(e){t(e)}})}function Pe(e,t,n){if(e&&f(e)){let r=e.db,i=r.prepare(`SELECT * FROM messages WHERE groupId = ?`).all(t),a=r.prepare(`INSERT INTO messages
|
|
2
|
-
(id, groupId, timestamp, content, sender, channel, isFromMe, isTrigger, attachments, a2uiAction, a2uiEnvelopes, freshContext, subagent)
|
|
3
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`);for(let e of i)a.run(_(),n,e.timestamp,e.content,e.sender,e.channel??`chat`,e.isFromMe,e.isTrigger,e.attachments,e.a2uiAction,e.a2uiEnvelopes,e.freshContext,e.subagent);return Promise.resolve(i.length)}return new Promise((r,i)=>{let a=e?.transaction(`messages`,`readwrite`);if(!a)throw Error(`failed to get transaction, cannot clone messages.`);let o=a.objectStore(`messages`),s=o.index(`by-group`).openCursor(t),c=0;s.onsuccess=()=>{let e=s.result;if(e){let t={...e.value,id:_(),groupId:n};o.put(t),c++,e.continue()}else r(c)},s.onerror=()=>i(s.error)})}function Fe(e,t,n){if(e&&f(e)){let r=e.db,i=r.prepare(`SELECT * FROM tasks WHERE groupId = ?`).all(t),a=r.prepare(`INSERT INTO tasks
|
|
4
|
-
(id, groupId, enabled, schedule, prompt, tools, lastRun, createdAt, type, freshContext, subagent, name, task_order, pushNotifications)
|
|
5
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`);for(let e of i)a.run(_(),n,+!!e.enabled,e.schedule??null,e.prompt??``,e.tools??null,e.lastRun??null,e.createdAt,e.type??null,e.freshContext?1:null,e.subagent?1:null,e.name??null,e.task_order??null,e.pushNotifications?1:null);return Promise.resolve(i.length)}return new Promise((r,i)=>{let a=e?.transaction(`tasks`,`readwrite`);if(!a)throw Error(`failed to get transaction, cannot clone tasks.`);let o=a.objectStore(`tasks`),s=o.index(`by-group`).openCursor(t),c=0;s.onsuccess=()=>{let e=s.result;if(e){let t={...e.value,id:_(),groupId:n};o.put(t),c++,e.continue()}else r(c)},s.onerror=()=>i(s.error)})}function Ie(e,t){return p(e,`messages`,`readwrite`,e=>e.delete(t)).then(()=>void 0)}function Le(e,t){return t?p(e,`tasks`,`readwrite`,e=>e.delete(t)).then(()=>void 0):Promise.reject(/* @__PURE__ */ Error(`Task ID is required for deletion.`))}function Re(e,t,n){let r=null,i,a;return typeof e==`string`?(i=e,a=t):(r=e,i=t,a=n??50),r&&f(r)?Promise.resolve().then(()=>(r.db.prepare(`SELECT * FROM messages WHERE groupId = ? ORDER BY timestamp DESC LIMIT ?`).all(i,a)??[]).reverse().map(ze)):new Promise(async(e,t)=>{try{let n=r??await d();if(!n)return t(/* @__PURE__ */ Error(`failed to get transaction, cannot get recent messages.`));let o=n.transaction(`messages`,`readonly`);if(!o)return t(/* @__PURE__ */ Error(`failed to get transaction`));let s=o.objectStore(`messages`).index(`by-group-time`),c=IDBKeyRange.bound([i,0],[i,1/0]),l=s.openCursor(c,`prev`),u=[];l.onsuccess=()=>{let t=l.result;t&&u.length<a?(u.push(t.value),t.continue()):e(u.reverse())},l.onerror=()=>t(l.error)}catch(e){t(e)}})}function ze(e){return{...e,isFromMe:!!e.isFromMe,isTrigger:!!e.isTrigger,attachments:e.attachments?JSON.parse(e.attachments):void 0,a2uiAction:e.a2uiAction?JSON.parse(e.a2uiAction):void 0,a2uiEnvelopes:e.a2uiEnvelopes?JSON.parse(e.a2uiEnvelopes):void 0}}const Be=`group_metadata`;async function A(e){let t=await m(e,Be);if(!t)return[];try{return JSON.parse(t)}catch{return[]}}async function j(e,t){await g(e,Be,JSON.stringify(t))}async function Ve(e,t,n=`br:`,r){let i=await A(e),a={groupId:`${n}${r??_()}`,name:t,createdAt:Date.now()};return i.push(a),await j(e,i),a}async function He(e,t,n){let r=await A(e),i=r.find(e=>e.groupId===t);i&&(i.name=n),await j(e,r)}async function Ue(e,t,n){let r=await A(e),i=r.find(e=>e.groupId===t);i&&(n&&n.length>0?i.toolTags=n:delete i.toolTags),await j(e,r)}async function We(e,t){await j(e,(await A(e)).filter(e=>e.groupId!==t))}async function M(e){let t=await A(e);if(t.length===0){let t={groupId:a,name:`Main`,createdAt:0};return await j(e,[t]),[t]}return t}async function Ge(e,t){let n=await A(e),r=new Map(n.map(e=>[e.groupId,e])),i=[];for(let e of t){let t=r.get(e);t&&(i.push(t),r.delete(e))}for(let e of n)r.has(e.groupId)&&i.push(e);await j(e,i)}async function Ke(e,t){let n=await A(e),r=n.find(e=>e.groupId===t);if(!r)return null;let i=t.indexOf(`:`),a={groupId:`${i>=0?t.slice(0,i+1):`br:`}${_()}`,name:`${r.name} (copy)`,createdAt:Date.now(),pinnedMaxTokens:r.pinnedMaxTokens,providerRuntimeOverrides:r.providerRuntimeOverrides?JSON.parse(JSON.stringify(r.providerRuntimeOverrides)):void 0,subagentModelSelectionMode:r.subagentModelSelectionMode,subagentMaxTokens:r.subagentMaxTokens,subagentPinnedProvider:r.subagentPinnedProvider,subagentPinnedModel:r.subagentPinnedModel,subagentFastProvider:r.subagentFastProvider,subagentFastModel:r.subagentFastModel,subagentSmartProvider:r.subagentSmartProvider,subagentSmartModel:r.subagentSmartModel,subagentPowerfulProvider:r.subagentPowerfulProvider,subagentPowerfulModel:r.subagentPowerfulModel,toolTags:r.toolTags?[...r.toolTags]:void 0};return n.push(a),await j(e,n),a}async function qe(e,t,n,r,i){let a=await A(e),o=a.find(e=>e.groupId===t);o&&(n?o.pinnedProvider=n:delete o.pinnedProvider,r?o.pinnedModel=r:delete o.pinnedModel,typeof i==`number`&&Number.isFinite(i)&&i>0?o.pinnedMaxTokens=Math.floor(i):delete o.pinnedMaxTokens),await j(e,a)}async function Je(e,t,n,r,i,a){let o=await A(e),s=o.find(e=>e.groupId===t);s&&(s.subagentModelSelectionMode=n,n===`manual`?(r?s.subagentPinnedProvider=r:delete s.subagentPinnedProvider,i?s.subagentPinnedModel=i:delete s.subagentPinnedModel):(delete s.subagentPinnedProvider,delete s.subagentPinnedModel),typeof a==`number`&&Number.isFinite(a)&&a>0?s.subagentMaxTokens=Math.floor(a):delete s.subagentMaxTokens),await j(e,o)}async function Ye(e,t,n){let r=await A(e),i=r.find(e=>e.groupId===t);i&&(n&&Object.keys(n).length>0?i.providerRuntimeOverrides=JSON.parse(JSON.stringify(n)):delete i.providerRuntimeOverrides),await j(e,r)}function N(e,t){return p(e,`messages`,`readwrite`,e=>e.put(t)).then(()=>void 0)}function P(e,t){let n={...t,enabled:+!!t.enabled};return p(e,`tasks`,`readwrite`,e=>e.put(n)).then(()=>void 0)}function Xe(e,t,n){let r=null,i,a;return typeof e==`string`?(i=e,a=t):(r=e,i=t,a=n),r&&f(r)?Promise.resolve().then(()=>{r.db.prepare(`UPDATE tasks SET lastRun = ? WHERE id = ?`).run(a,i)}):new Promise(async(e,t)=>{try{let n=r??await d();if(!n)return t(/* @__PURE__ */ Error(`failed to get transaction, cannot update task last run.`));let o=n.transaction(`tasks`,`readwrite`);if(!o)return t(/* @__PURE__ */ Error(`failed to get transaction`));let s=o.objectStore(`tasks`),c=s.get(i);c.onsuccess=()=>{let n=c.result;if(!n){e();return}n.lastRun=a;let r=s.put(n);r.onsuccess=()=>e(),r.onerror=()=>t(r.error)},c.onerror=()=>t(c.error)}catch(e){t(e)}})}async function Ze(e,t,n){let r=(await v(e)).filter(e=>e.groupId===t),i=new Map(r.map(e=>[e.id,e])),a=[],o=0;for(let t of n){let n=i.get(t);n&&(n.order=o++,await P(e,n),a.push(n),i.delete(t))}let s=Array.from(i.values()).sort((e,t)=>{let n=e.order??0,r=t.order??0;return n===r?e.createdAt-t.createdAt:n-r});for(let t of s)t.order=o++,await P(e,t),a.push(t);return a}async function Qe(e,t,n,r){let i=await T(e,t),a=await T(e,n),o=r.replace(/\\/g,`/`).replace(/^\/+/,``).split(`/`).filter(Boolean),s=i,c=a;for(let e of o)s=await s.getDirectoryHandle(e),c=await c.getDirectoryHandle(e,{create:!0});let l=n.replace(/:/g,`-`),u=[ee(),`groups`,l,...o];try{await $e(e,n,s,c,u)}catch(e){throw o.length>0&&await a.removeEntry(o[0],{recursive:!0}).catch(()=>void 0),e}}async function $e(e,t,n,r,i){for await(let[a,o]of n.entries()){if(o.kind===`directory`){await $e(e,t,o,await r.getDirectoryHandle(a,{create:!0}),[...i,a]);continue}let n=await o.getFile(),s=await r.getFileHandle(a,{create:!0});try{await re(s,n)}catch(t){if(!((t instanceof Error?t.message:String(t)).includes(`Writable file streams are not supported`)&&(await C(e)).type===`opfs`))throw t;await E([...i,a],n)}}}const F=`---
|
|
6
|
-
title: "ShadowClaw Pages"
|
|
7
|
-
created: "1970-01-01T00:00:00Z"
|
|
8
|
-
updated: "1970-01-01T00:00:00Z"
|
|
9
|
-
slug: "shadow-claw-pages"
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
<article>
|
|
13
|
-
<h2>Welcome to ShadowClaw Pages</h2>
|
|
14
|
-
<p>This is the default static page for your workspace.</p>
|
|
15
|
-
<h2 id="getting-started-with-shadowclaw">Getting started with ShadowClaw</h2>
|
|
16
|
-
<h3 id="what-is-memorymd">What is MEMORY.md?</h3>
|
|
17
|
-
<ul>
|
|
18
|
-
<li>
|
|
19
|
-
"<a href="/files/main/MEMORY.md">MEMORY.md</a>" is a per conversation, per
|
|
20
|
-
invocation, auto-loaded, persistent agent memory file.
|
|
21
|
-
</li>
|
|
22
|
-
<li>
|
|
23
|
-
It is designed to be a helpful scratchpad for agents to store important
|
|
24
|
-
information, notes, and context about the conversation.
|
|
25
|
-
</li>
|
|
26
|
-
</ul>
|
|
27
|
-
<h3 id="how-to-use-files">How to use Files</h3>
|
|
28
|
-
<ul>
|
|
29
|
-
<li>Open "<a href="/files/main">Files</a>" to browse your workspace.</li>
|
|
30
|
-
<li>
|
|
31
|
-
Edit and preview files with the file viewer:
|
|
32
|
-
<ul>
|
|
33
|
-
<li><a href="/files/main/index.html">index.html</a></li>
|
|
34
|
-
</ul>
|
|
35
|
-
</li>
|
|
36
|
-
</ul>
|
|
37
|
-
<h3 id="how-to-use-pages">How to use Pages</h3>
|
|
38
|
-
<ul>
|
|
39
|
-
<li>Use Set as Page on any markdown or HTML file to add it to Pages.</li>
|
|
40
|
-
<li>Remove a page anytime from the "<a href="/pages">Pages</a>" view.</li>
|
|
41
|
-
</ul>
|
|
42
|
-
<h3 id="how-to-use-chat">How to use Chat</h3>
|
|
43
|
-
<ul>
|
|
44
|
-
<li>
|
|
45
|
-
Open "<a href="/settings">Settings</a>" to configure your agent's system
|
|
46
|
-
prompt, tools, and more.
|
|
47
|
-
</li>
|
|
48
|
-
<li>
|
|
49
|
-
Open "<a href="/chat/main">Chat</a>" to start a conversation with your
|
|
50
|
-
agent.
|
|
51
|
-
</li>
|
|
52
|
-
</ul>
|
|
53
|
-
<h2 id="further-information">Further information</h2>
|
|
54
|
-
<ul>
|
|
55
|
-
<li>
|
|
56
|
-
<a href="https://github.com/xt-ml/shadow-claw#-shadowclaw"
|
|
57
|
-
>ShadowClaw Project</a
|
|
58
|
-
>
|
|
59
|
-
</li>
|
|
60
|
-
<li><a href="https://deepwiki.com/xt-ml/shadow-claw">Deep Wiki</a></li>
|
|
61
|
-
</ul>
|
|
62
|
-
</article>`;function et(){let e=l(`/static-main/index.html`);if(typeof window<`u`&&window.location?.origin)try{return new URL(e,window.location.origin).toString()}catch{return e}return e}async function tt(e){let t=await m(e,o.MAIN_GROUP_INDEX_SUPPRESSED);return t===!0||t===`true`}async function nt(e,t){await g(e,o.MAIN_GROUP_INDEX_SUPPRESSED,t)}async function I(e,t=a,n){try{if(await y(e,t,`index.html`)){if(t===`br:main`)try{let r=await b(e,t,`index.html`);typeof r==`string`&&(r.includes(`<shadow-claw`)||r.includes(`data-shadow-claw-dsd`))&&await D(e,t,`index.html`,n??F)}catch{}return!0}if(t===`br:main`&&await tt(e))return!1;let r=n;if(r===void 0&&typeof fetch==`function`)try{let e=await fetch(et());if(e.ok){let t=await e.text();!t.includes(`<shadow-claw`)&&!t.includes(`data-shadow-claw-dsd`)&&(r=t)}}catch{}return r??=F,await D(e,t,`index.html`,r),!0}catch(e){return console.warn(`Failed to ensure main workspace Memory:`,e),!1}}const L='---\ntitle: "Agent Memory"\ncreated: "1970-01-01T00:00:00Z"\nupdated: "1970-01-01T00:00:00Z"\nslug: "agent-memory"\n---\n\n## Memory\n\n### Workspace Layout & Skills Conventions\n\n- **Skills**: `.agents/skills/<skill-name>/SKILL.md` (canonical flat layout; legacy `.agents/skills/main/` supported for backward-compatible reads)\n- **Declarative Tools**: `.agents/tools/<tool-name>.json` (canonical flat layout; legacy `.agents/tools/main/` supported for backward-compatible reads)\n- **Skill Format**: Markdown file with YAML frontmatter AND a Markdown body (frontmatter is metadata only; always include a `# <Skill Title>` heading and human-readable description in the Markdown body so it renders in document previews):\n\n ```yaml\n ---\n name: <skill-name>\n description: <clear summary for model and slash command>\n user-invocable: true\n metadata:\n allowed-tools: <tool1> <tool2>\n execution:\n type: tools\n tools:\n - name: <tool1>\n input: { ... }\n - name: <tool2>\n input: { "$pipe": "prev" }\n ---\n # <Skill Title>\n\n <Overview and description of what the skill does, parameters, and usage instructions.>\n ```\n\n- **Declarative Tool Format**: JSON with `"name"`, `"description"`, `"executor": "javascript"`, `"inputSchema"`, and `"code"`.\n- **Open Agent Skills & Discovery**: Install community skills from [skills.sh](https://skills.sh) via `npx shadow-claw skills add <owner/repo>` (or `npx skills add`), search via `npx shadow-claw skills find <term>`, and publish RFC v0.2.0 discovery indexes via `npx shadow-claw skills:index` (`.well-known/agent-skills/index.json`).\n- **Authoring**: Use `create_directory` before writing new directories, then `write_file`.',rt=`MEMORY.md`;function it(){let e=l(`/static-main/MEMORY.md`);if(typeof window<`u`&&window.location?.origin)try{return new URL(e,window.location.origin).toString()}catch{return e}return e}async function R(e){let t=await m(e,o.MAIN_GROUP_README_SUPPRESSED);return t===!0||t===`true`}async function z(e,t){await g(e,o.MAIN_GROUP_README_SUPPRESSED,t)}async function B(e,t=a,n){try{if(await y(e,t,`MEMORY.md`)){if(t===`br:main`)try{let r=await b(e,t,rt);typeof r==`string`&&(r.includes(`<shadow-claw`)||r.includes(`data-shadow-claw-dsd`))&&await D(e,t,rt,n??L)}catch{}return!0}if(t===`br:main`&&await R(e))return!1;let r=n;if(r===void 0&&typeof fetch==`function`)try{let e=await fetch(it());if(e.ok){let t=await e.text();!t.includes(`<shadow-claw`)&&!t.includes(`data-shadow-claw-dsd`)&&(r=t)}}catch{}return r??=L,await D(e,t,rt,r),!0}catch(e){return console.warn(`Failed to ensure main workspace Memory:`,e),!1}}async function at(e,t,n=`.`){for(let r=0;r<2;r++)try{let r=await T(e,t);if(n&&n!==`.`){let e=n.replace(/\\/g,`/`).replace(/^\/home\/user\//,`/`).replace(/^\/+/,``).split(`/`).filter(Boolean);for(let t of e){let e=await r.getDirectoryHandle(t);if(typeof r.isSameEntry==`function`&&await r.isSameEntry(e))throw Error(`Directory navigation stuck at "${r.name}" for segment "${t}" — the stored directory handle may be stale.`);r=e}}let i=[];for await(let[e,t]of r.entries())i.push(t.kind===`directory`?`${e}/`:e);return i.sort()}catch(e){if(r===0&&te(e)){w();continue}throw e}return[]}function ot(e){if(!e||typeof e!=`object`)return!1;let t=globalThis.FileSystemDirectoryHandle;return t!==void 0&&e instanceof t||typeof e.getDirectoryHandle==`function`&&typeof e.getFileHandle==`function`&&typeof e.requestPermission==`function`}async function st(e){let t=await m(e,o.STORAGE_HANDLE);return!ot(t)||await t.requestPermission({mode:`readwrite`})===`granted`}function V(e){let t=u();return t?`shadowclaw:${t}:${e}`:e}function ct(e){if(typeof localStorage>`u`)return null;let t=V(e);try{let n=localStorage.getItem(t);if(n!==null)return n;if(t===e)return null;let r=localStorage.getItem(e);if(r!==null)return localStorage.setItem(t,r),r}catch(e){console.warn(`Unable to read from localStorage:`,e)}return null}function H(e,t){if(typeof localStorage>`u`)return;let n=V(e);try{localStorage.setItem(n,t)}catch(e){console.warn(`Unable to write to localStorage:`,e)}}function lt(e){if(typeof localStorage>`u`)return;let t=V(e);try{localStorage.removeItem(t)}catch(e){console.warn(`Unable to remove from localStorage:`,e)}}async function U(e,t){let n=await T(e,t);for await(let[e]of n.entries())await n.removeEntry(e,{recursive:!0})}async function W(e,t,n){let r=await T(e,t),{dirs:i,filename:a}=ne(n.replace(/\/$/,``)),o=r;for(let e of i)o=await o.getDirectoryHandle(e);await o.removeEntry(a,{recursive:!0})}function G(e,t){return`${e}:${t}`}async function ut(e){let t=await m(e,o.SUPPRESSED_PAGES_LIST);if(!t||typeof t!=`string`)return[];try{let e=JSON.parse(t);if(Array.isArray(e))return e}catch{}return[]}async function dt(e,t,n){let r=await ut(e),i=G(t,n);return r.some(e=>G(e.groupId,e.path)===i)}async function ft(e,t,n){let r=await ut(e),i=G(t,n);if(!r.some(e=>G(e.groupId,e.path)===i)){let i=[...r,{groupId:t,path:n}];await g(e,o.SUPPRESSED_PAGES_LIST,JSON.stringify(i))}}async function pt(e,t,n){let r=await ut(e),i=G(t,n),a=r.filter(e=>G(e.groupId,e.path)!==i);a.length!==r.length&&await g(e,o.SUPPRESSED_PAGES_LIST,JSON.stringify(a))}function K(e){return Array.from(new Set(e.map(e=>e.trim()).filter(Boolean)))}function mt(e){let t=e.trim().replace(/\\/g,`/`);return t===`/`||/^\/+$/.test(t)?`/`:t.replace(/^\/+/,``).replace(/\/+$/,``)}const ht=/\.(md|markdown|html|xhtml|txt)$/i;function q(e){return e===`/`?`/`:e.replace(ht,``)}function gt(e){let t=e.trim().replace(/\\/g,`/`);return t===`/`||/^\/+$/.test(t)?`/`:t.replace(/^\/+/,``).replace(/\/+$/,``)}function _t(e){return e?e.replace(/^br:/i,``).replace(/^br-/i,``).trim():`main`}function J(e,t){let n=gt(t);if(!n)return;e.add(n);let r=q(n);r&&r!==n&&e.add(r)}function vt(e,t,n){let r=/* @__PURE__ */ new Set;if(!e)return r;let i=_t(t);if(e===`/`){if(r.add(`/`),J(r,`index.html`),n){let e=mt(n);e&&e!==`/`&&J(r,`${e}/index.html`)}return J(r,`pages/index.html`),J(r,`pages/${i}/index.html`),J(r,`${i}/index.html`),r}if(J(r,e),n){let t=mt(n);t&&t!==`/`&&J(r,`${t}/${e}`)}if(e.startsWith(`pages/`)){let t=e.slice(6);J(r,t),t.startsWith(`${i}/`)?J(r,t.slice(`${i}/`.length)):J(r,t.replace(/^[^/]+\//,``))}else J(r,`pages/${e}`),J(r,`pages/${i}/${e}`),J(r,`${i}/${e}`);for(let e of Array.from(r)){let t=q(e);if(e===`index.html`||t===`index`){r.add(`/`);break}}return r}function yt(e,t){let n=t.toLowerCase(),r=q(t).toLowerCase(),i=n===r?[n]:[n,r];for(let t of e){let e=t.toLowerCase(),n=q(e);for(let t of i)if(t&&(e===t||n===t||t!==`/`&&(e.startsWith(`${t}/`)||n.startsWith(`${t}/`)||e.endsWith(`/${t}`)||n.endsWith(`/${t}`)||e.includes(`/${t}/`)||n.includes(`/${t}/`))))return!0}return!1}function bt(e,t){for(let n of t){let t=mt(n);if(t&&yt(e,t))return!0}return!1}function xt(e,t,n,r){if(!e||typeof e!=`string`)return!1;let i=gt(e);if(!i)return!1;let a=[],o=[],s,c;if(t&&typeof t==`object`&&!Array.isArray(t)){let e=t,n=e.allowList??e.allowlist??[],r=e.denyList??e.denylist??[];a=K(Array.from(n||[])),o=K(Array.from(r||[])),s=e.groupId,c=e.basePathPrefix}else a=K(Array.from(t||[])),o=K(Array.from(n||[])),s=r?.groupId,c=r?.basePathPrefix;let l=vt(i,s,c);return o.length>0&&bt(l,o)?!1:a.length>0?bt(l,a):!0}function St(e=a){return e===`br:main`?o.STATIC_MAIN_SITE_SEEDED:`${o.STATIC_MAIN_SITE_SEEDED}:${e}`}async function Ct(e,t=a){let n=St(t),r=await m(e,n);return r===!0||r===`true`}async function wt(e,t=a,n=!0){let r=St(t);await g(e,r,n)}function Tt(){let e=l(`/static-main-manifest.json`);if(typeof window<`u`&&window.location?.origin)try{return new URL(e,window.location.origin).toString()}catch{return e}return e}function Et(e){let t=e.replace(/^\/+/,``),n=`static-main`;if(typeof document<`u`)try{let e=document.getElementById(`shadow-claw-site-config`);if(e?.textContent){let t=JSON.parse(e.textContent);typeof t?.pages?.baseUrl==`string`&&(n=t.pages.baseUrl.replace(/^\/+/,``).replace(/\/+$/,``))}}catch{}let r=l(n?`/${n}/${t}`:`/${t}`);if(typeof window<`u`&&window.location?.origin)try{return new URL(r,window.location.origin).toString()}catch{return r}return r}async function Dt(){if(typeof fetch!=`function`)return null;try{let e=Tt(),t=await fetch(e);if(t.ok){if((t.headers?.get?.(`content-type`)||``).includes(`text/html`))return null;let e=await t.json();if(e&&Array.isArray(e.pages))return e}}catch{}return null}async function Ot(e){if(typeof fetch!=`function`)return null;try{let t=Et(e),n=await fetch(t);if(n.ok){let t=n.headers?.get?.(`content-type`)||``;if((e.endsWith(`.md`)||e.endsWith(`.markdown`)||e.endsWith(`.json`))&&t.includes(`text/html`))return null;let r=await n.text();return r.includes(`<shadow-claw`)||r.includes(`data-shadow-claw-dsd`)?null:r}}catch{}return null}function kt(e){if(typeof document>`u`)return null;let t=t=>{if(!t||!(t instanceof HTMLElement))return!1;if(!e)return!0;let n=t.getAttribute(`data-initial-path`)?.trim();return!n||n===e},n=document.querySelector(e?`[data-pages-rendered][data-initial-path="${e}"]`:`[data-pages-rendered]`);if(t(n))return n;let r=document.querySelector(`shadow-claw`)?.shadowRoot,i=(r?.querySelector(`shadow-claw-pages`)?.shadowRoot)?.querySelector(e?`[data-pages-rendered][data-initial-path="${e}"]`:`[data-pages-rendered]`)||r?.querySelector(e?`[data-pages-rendered][data-initial-path="${e}"]`:`[data-pages-rendered]`);if(t(i))return i;let a=document.querySelectorAll(`template`);for(let n of Array.from(a)){let r=n.content?.querySelector(e?`[data-pages-rendered][data-initial-path="${e}"]`:`[data-pages-rendered]`);if(t(r))return r;let i=n.content?.querySelectorAll(`template`);if(i)for(let n of Array.from(i)){let r=n.content?.querySelector(e?`[data-pages-rendered][data-initial-path="${e}"]`:`[data-pages-rendered]`);if(t(r))return r}}return null}function Y(e=`index.html`){let t=kt(e);if(!t)return null;let n=t.getAttribute(`data-initial-path`)?.trim();if(n&&n!==e)return null;let r=t.querySelector(`[data-markdown-frontmatter]`),i=null;if(r){let e=r.getAttribute(`data-frontmatter`);if(e)try{i=JSON.parse(e)}catch{}}let a=t.cloneNode(!0),o=a.querySelector(`[data-markdown-frontmatter]`);o&&o.remove();let s=a.innerHTML.trim();if(!s&&!i)return null;if(i&&Object.keys(i).length>0){let e=[`---`];for(let[t,n]of Object.entries(i))typeof n==`string`?e.push(`${t}: ${JSON.stringify(n)}`):typeof n==`number`||typeof n==`boolean`?e.push(`${t}: ${n}`):e.push(`${t}: ${JSON.stringify(n)}`);return e.push(`---`,``),`${e.join(`
|
|
63
|
-
`)}\n${s}`}return s}async function At(e={}){let t=()=>{let e=null;if(typeof document<`u`){let t=document.getElementById(`shadow-claw-static-manifest`);if(t&&t.textContent)try{let n=JSON.parse(t.textContent);n&&Array.isArray(n.pages)&&(e={...n,pages:[...n.pages]})}catch(e){console.warn(`Failed to parse embedded static main manifest:`,e)}let n=document.querySelectorAll(`script[type="text/markdown"][data-shadow-claw-page]`);if(n.length>0){e||={pages:[]};for(let t of Array.from(n)){let n=t.getAttribute(`data-shadow-claw-page`)?.trim();if(n){let r=t.textContent||``;r=ie(r),!r.trim()&&/^memory\.(md|markdown)$/iu.test(n)&&(r=L),!r.trim()&&(n===`index.html`||/^index\.(html?|xhtml)$/iu.test(n))&&(r=Y(n)??F);let i=e.pages.findIndex(e=>e.displayPath===n);i>=0?e.pages[i].content=r:e.pages.push({displayPath:n,content:r})}}}let r=document.getElementById(`shadow-claw-site-config`);if(r?.textContent)try{let t=JSON.parse(r.textContent);if(Array.isArray(t?.pages?.files)){e||={pages:[]};for(let n of t.pages.files)if(typeof n==`string`&&n.trim()){let t=n.trim(),r=``;/^memory\.(md|markdown)$/iu.test(t)?r=L:(t===`index.html`||/^index\.(html?|xhtml)$/iu.test(t))&&(r=Y(t)??F),e.pages.some(e=>e.displayPath===t)||e.pages.push({displayPath:t,content:r})}}}catch{}let i=kt();if(i){e||={pages:[]};let t=i.getAttribute(`data-initial-path`)?.trim()||`index.html`;if(!e.pages.some(e=>e.displayPath===t)){let n=Y(t)??F;e.pages.push({displayPath:t,content:n})}e.pages.some(e=>/^memory\.(md|markdown)$/iu.test(e.displayPath))||e.pages.push({displayPath:`MEMORY.md`,content:L})}}return e};if(e.preferEmbedded!==!1){let e=t();if(e)return e}if(e.fetchFallback!==!1){let e=await Dt();if(e)return e}if(e.preferEmbedded===!1){let e=t();if(e)return e}return{pages:[{displayPath:`index.html`,content:F},{displayPath:`MEMORY.md`,content:L}]}}async function jt(e){if(typeof document<`u`){let t=document.getElementById(`shadow-claw-static-manifest`);if(t&&t.textContent)try{let n=JSON.parse(t.textContent);if(n&&Array.isArray(n.pages)){let t=n.pages.find(t=>t.displayPath===e);if(t&&typeof t.content==`string`&&t.content.trim())return t.content}}catch{}let n=document.querySelectorAll(`script[type="text/markdown"][data-shadow-claw-page]`);for(let t of Array.from(n))if(t.getAttribute(`data-shadow-claw-page`)?.trim()===e){let e=t.textContent||``;if(e.trim())return e}let r=Y(e);if(typeof r==`string`&&r.trim())return r;if(/^memory\.(md|markdown)$/iu.test(e))return L;if(e===`index.html`||/^index\.(html?|xhtml)$/iu.test(e))return F}let t=await Ot(e);if(typeof t==`string`)return t;let n=await Dt();if(n&&Array.isArray(n.pages)){let t=n.pages.find(t=>t.displayPath===e);if(t&&typeof t.content==`string`)return t.content}return null}async function Mt(e,t,n=[]){for(let[r,i]of Object.entries(t))if(r===`purgePreRenderedStaticPages`&&i===!0){if(n.length>0){let t=n[0],r=n.slice(1).join(`/`);try{r?await W(e,t,r):await U(e,t)}catch(e){console.warn(`Failed to purge pre-rendered static pages for ${t}/${r}:`,e)}}}else typeof i==`object`&&i&&await Mt(e,i,[...n,r])}function Nt(){if(typeof document<`u`)try{let e=document.getElementById(`shadow-claw-site-config`);if(e?.textContent){let t=JSON.parse(e.textContent);if(t?.pages?.sortOrder===`desc`)return`desc`;if(t?.pages?.sortOrder===`asc`)return`asc`}}catch{}return`desc`}function Pt(){if(typeof document<`u`)try{let e=document.getElementById(`shadow-claw-site-config`);if(e?.textContent){let t=JSON.parse(e.textContent)?.pages?.defaultPinnedPage;if(typeof t==`string`&&t.trim().length>0)return t.trim()}}catch{}return null}function Ft(){let e=`ShadowClaw`,t,n;if(typeof document<`u`){try{let r=document.getElementById(`shadow-claw-site-config`);if(r?.textContent){let i=JSON.parse(r.textContent);i?.site?.title&&(e=String(i.site.title).trim()),(i?.site?.titleSeparator??i?.site?.sep)&&(t=String(i.site.titleSeparator??i.site.sep)),i?.site?.titleTemplate&&(n=String(i.site.titleTemplate))}}catch{}if(e===`ShadowClaw`&&document.title){let t=document.title.split(/\s*[-|—•·]\s*/),n=t[t.length-1]?.trim();n&&(e=n)}}return{siteTitle:e,separator:t,titleTemplate:n}}function It(){if(typeof document<`u`)try{let e=document.getElementById(`shadow-claw-site-config`);if(e?.textContent){let t=JSON.parse(e.textContent);return{allowList:K(t?.pages?.allowList??t?.pages?.allowlist??t?.allowList??t?.allowlist??[]),denyList:K(t?.pages?.denyList??t?.pages?.denylist??t?.denyList??t?.denylist??[])}}}catch{}return{allowList:[],denyList:[]}}function Lt(e,t){let n=t??Nt();return[...e].sort((e,t)=>{let r=e.path,i=t.path,a=r.split(`/`).pop()||``,o=i.split(`/`).pop()||``,s=/^index\.(html?|xhtml)$/iu.test(a),c=/^index\.(html?|xhtml)$/iu.test(o);if(s&&!c)return-1;if(!s&&c)return 1;let l=/^memory\.(md|markdown)$/iu.test(a),u=/^memory\.(md|markdown)$/iu.test(o);return l&&!u?1:!l&&u?-1:n===`asc`?r.localeCompare(i,void 0,{numeric:!0,sensitivity:`base`}):i.localeCompare(r,void 0,{numeric:!0,sensitivity:`base`})})}async function Rt(e,t,n=`sc:purge-id`,r=`static_main_site_purge_id`){let i=t??`__legacy_purge_pages__`;try{if(ct(n)===i)return!0}catch{}try{if(await m(e,r)===i){try{H(n,i)}catch{}return!0}await g(e,r,i);try{H(n,i)}catch{}}catch{try{H(n,i)}catch{}}return!1}async function zt(e,t=a,n=[],r={}){await I(e,t);let i=await At(r),o=!1;i.preRenderedStaticPages&&(await Rt(e,i.purgeId)||(o=!0,await Mt(e,i.preRenderedStaticPages)));let s=!1;if(t===`br:main`&&i.skillsPurgeId!==void 0&&!await Rt(e,i.skillsPurgeId,`sc:skills-purge-id`,`static_main_skills_purge_id`)){s=!0;try{await W(e,t,`.agents/skills/main`)}catch(e){if(!(e&&typeof e==`object`&&`name`in e&&e.name===`NotFoundError`))throw e}try{await W(e,t,`.agents/tools/main`)}catch(e){if(!(e&&typeof e==`object`&&`name`in e&&e.name===`NotFoundError`))throw e}}for(let n of i.pages)if(n.content?.includes(`slug: "shadow-claw--purge-pages"`)){!o&&!await Rt(e,i.purgeId)&&(o=!0,await U(e,t));break}let c=t===`br:main`&&await R(e),l=new Set(i.pages.map(e=>G(t,e.displayPath))),u=o?n.filter(e=>e.groupId!==t||l.has(G(e.groupId,e.path))):[...n],{allowList:d,denyList:f}=It(),p=0;for(let n of i.pages)if(p++,p%5==0&&await new Promise(e=>setTimeout(e,0)),!n.content?.includes(`slug: "shadow-claw--purge-pages"`)&&xt(n.displayPath,{allowList:d,denyList:f,groupId:t})){if(/^memory\.(md|markdown)$/iu.test(n.displayPath)){if(c)continue;let r=typeof n.content==`string`&&n.content.trim().length>0&&n.content!==L?n.content:void 0;if(r===void 0?await B(e,t):await B(e,t,r)){let e=G(t,n.displayPath);u.some(t=>G(t.groupId,t.path)===e)||u.push({groupId:t,path:n.displayPath})}}else if(!await dt(e,t,n.displayPath))try{if(!await y(e,t,n.displayPath)){let r=n.content;(typeof r!=`string`||!r.trim())&&(r=n.displayPath===`index.html`?Y(`index.html`)??F:await Ot(n.displayPath)??``),await D(e,t,n.displayPath,r)}let r=G(t,n.displayPath);u.some(e=>G(e.groupId,e.path)===r)||u.push({groupId:t,path:n.displayPath})}catch(e){console.warn(`Failed to seed static page file ${n.displayPath}:`,e)}}if(t===`br:main`){for(let n of i.skills||[]){let r=`.agents/skills/main/${n.displayPath}`;try{await y(e,t,r)||await D(e,t,r,n.content)}catch(e){console.warn(`Failed to seed skill file ${r}:`,e)}}for(let n of i.tools||[]){let r=`.agents/tools/main/${n.displayPath}`;try{(s||!await y(e,t,r))&&await D(e,t,r,n.content)}catch(e){console.warn(`Failed to seed tool file ${r}:`,e)}}}let m=typeof document<`u`&&(document.getElementById(`shadow-claw-static-manifest`)!==null||document.querySelector(`script[type="text/markdown"][data-shadow-claw-page]`)!==null||kt()!==null);r.preferEmbedded!==!1&&m||await wt(e,t,!0);let h=u.filter(e=>xt(e.path,{allowList:d,denyList:f,groupId:e.groupId}));return Object.defineProperty(h,"didPurge",{value:o,enumerable:!1,writable:!0,configurable:!0}),Object.defineProperty(h,"didPurgeSkills",{value:s,enumerable:!1,writable:!0,configurable:!0}),Lt(h)}var Bt=class{_events;_handlers=[];_runs=/* @__PURE__ */ new Map;constructor(e){this._events=e}start(){this._listen(`streaming-start`,this._onStreamingStart),this._listen(`streaming-chunk`,this._onStreamingChunk),this._listen(`streaming-end`,this._onStreamingEnd),this._listen(`streaming-done`,this._onStreamingDone),this._listen(`streaming-error`,this._onStreamingError),this._listen(`tool-activity`,this._onToolActivity)}stop(){for(let{event:e,handler:t}of this._handlers)this._events.off(e,t);this._handlers=[],this._runs.clear()}_emit(e,t){window.dispatchEvent(new CustomEvent(`shadow-claw-agui-event`,{detail:{groupId:e,event:t}}))}_listen(e,t){this._events.on(e,t),this._handlers.push({event:e,handler:t})}_onStreamingChunk=({groupId:e,text:t})=>{let n=this._runs.get(e);n&&n.messageId&&this._emit(e,{type:`TEXT_MESSAGE_CONTENT`,messageId:n.messageId,delta:t,timestamp:Date.now()})};_onStreamingDone=({groupId:e})=>{let t=this._runs.get(e);t&&(t.messageId&&this._emit(e,{type:`TEXT_MESSAGE_END`,messageId:t.messageId,timestamp:Date.now()}),this._emit(e,{type:`RUN_FINISHED`,threadId:t.threadId,runId:t.runId,timestamp:Date.now()}),this._runs.delete(e))};_onStreamingEnd=({groupId:e})=>{let t=this._runs.get(e);t&&t.messageId&&(this._emit(e,{type:`TEXT_MESSAGE_END`,messageId:t.messageId,timestamp:Date.now()}),t.messageId=null)};_onStreamingError=({groupId:e,error:t})=>{let n=this._runs.get(e);n&&(n.messageId&&this._emit(e,{type:`TEXT_MESSAGE_END`,messageId:n.messageId,timestamp:Date.now()}),this._emit(e,{type:`RUN_ERROR`,message:t||`Unknown streaming error`,timestamp:Date.now()}),this._runs.delete(e))};_onStreamingStart=({groupId:e})=>{let t=_(),n=e,r=_();this._runs.set(e,{runId:t,threadId:n,messageId:r,activeToolCallIds:/* @__PURE__ */ new Set}),this._emit(e,{type:`RUN_STARTED`,threadId:n,runId:t,timestamp:Date.now()}),this._emit(e,{type:`TEXT_MESSAGE_START`,messageId:r,role:`assistant`,timestamp:Date.now()})};_onToolActivity=({groupId:e,tool:t,status:n})=>{let r=this._runs.get(e);if(r){if(n===`running`){let n=_();r.activeToolCallIds.add(n),this._emit(e,{type:`TOOL_CALL_START`,toolCallId:n,toolCallName:t,timestamp:Date.now()}),r._lastToolCallId=n}else if(n===`done`||n===`error`){let t=r._lastToolCallId;t&&(r.activeToolCallIds.delete(t),this._emit(e,{type:`TOOL_CALL_END`,toolCallId:t,timestamp:Date.now()}))}}}};function Vt(e,t){if(!e||typeof e!=`object`)return e;let n=JSON.parse(JSON.stringify(e));for(let e of t)Ht(n,e);return n}function Ht(e,t){let{op:n,path:r,value:i}=t;if(!r||!r.startsWith(`/`))return;let a=r.split(`/`).slice(1).map(e=>e.replace(/~1/g,`/`).replace(/~0/g,`~`)),o=a.pop();if(o===void 0)return;let s=e;for(let e of a){if(typeof s!=`object`||!s)return;s=s[e]}typeof s==`object`&&s&&(Array.isArray(s)?Ut(s,o,n,i):Wt(s,o,n,i))}function Ut(e,t,n,r){if(n===`add`){if(t===`-`)e.push(r);else{let n=parseInt(t,10);!isNaN(n)&&n>=0&&n<=e.length&&e.splice(n,0,r)}}else if(n===`replace`){let n=parseInt(t,10);!isNaN(n)&&n>=0&&n<e.length&&(e[n]=r)}else if(n===`remove`){let n=parseInt(t,10);!isNaN(n)&&n>=0&&n<e.length&&e.splice(n,1)}}function Wt(e,t,n,r){n===`add`||n===`replace`?e[t]=r:n===`remove`&&delete e[t]}function Gt(e){if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t))return K(t.map(e=>String(e)))}catch{}return K(e.split(`,`))}let X=/* @__PURE__ */ new Map;function Z(e){if(typeof document>`u`)return null;let t=`shadow-claw-site-config`;if(e){let n=e.getAttribute(`config`)?.trim();n&&(t=n.replace(/^#/,``))}let n=document.getElementById(t);if(!n?.textContent)return X.delete(t),null;let r=X.get(t);if(r&&r.rawText===n.textContent)return r.config;try{let e=JSON.parse(n.textContent);if(!e||typeof e!=`object`)return X.delete(t),null;let r={...e};return X.set(t,{rawText:n.textContent,config:r}),r}catch(e){return console.warn(`[ShadowClaw] Failed to parse site configuration from #${t}:`,e),null}}var Kt=/* @__PURE__ */ e({OrchestratorStore:()=>Qt,accumulateTokenUsage:()=>Zt,orchestratorStore:()=>$t});function qt(e){if(e){if(Array.isArray(e))return e;if(typeof e==`string`)try{let t=JSON.parse(e);return Array.isArray(t)?t:void 0}catch{return}}}function Jt(e){if(typeof e==`boolean`)return e;if(typeof e==`string`){let t=e.trim().toLowerCase();return t===`true`||t===`1`}return typeof e==`number`&&e===1}function Yt(e){return!!e}async function Q(e,t,n,r){if(!Yt(r))return!0;if(!e.schedule)return await $(e.id,t,n,r)!==`failed`;try{let r=t.replace(/\/$/,``);return(await fetch(`${r}/tasks`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...e,subscriberId:n})})).ok}catch{return!1}}async function $(e,t,n,r){if(!Yt(r))return`missing`;try{let r=t.replace(/\/$/,``),i=`subscriberId=${encodeURIComponent(n)}`,a=await fetch(`${r}/tasks/${encodeURIComponent(e)}?${i}`,{method:`DELETE`});return a.ok?`deleted`:a.status===404||a.status===405?`missing`:`failed`}catch{return`failed`}}async function Xt(e,t,n,r){if(!Yt(r))return null;try{let r=t.replace(/\/$/,``),i=await fetch(`${r}/tasks?groupId=${encodeURIComponent(e)}&subscriberId=${encodeURIComponent(n)}`,{method:`GET`});if(!i.ok||typeof i.json!=`function`)return null;let a=await i.json();return Array.isArray(a)?a.filter(e=>!!e&&typeof e==`object`&&typeof e.id==`string`&&typeof e.schedule==`string`&&typeof e.prompt==`string`).map(t=>({id:t.id,groupId:t.group_id||t.groupId||e,schedule:t.schedule,type:t.type,prompt:t.prompt,tools:qt(t.tools),channel:typeof t.channel==`string`?t.channel:void 0,enabled:t.enabled===!0||t.enabled===1,lastRun:typeof t.lastRun==`number`?t.lastRun:typeof t.last_run==`number`?t.last_run:null,createdAt:typeof t.createdAt==`number`?t.createdAt:typeof t.created_at==`number`?t.created_at:Date.now(),name:typeof t.name==`string`?t.name:void 0,order:typeof t.order==`number`?t.order:typeof t.task_order==`number`?t.task_order:void 0})):null}catch{return null}}function Zt(e,t){let n=(e?.inputTokens??0)+(t.inputTokens??0),r=(e?.outputTokens??0)+(t.outputTokens??0),i=(e?.cacheReadTokens??0)+(t.cacheReadTokens??0),a=(e?.cacheCreationTokens??0)+(t.cacheCreationTokens??0);return{groupId:t.groupId||e?.groupId||``,inputTokens:n,outputTokens:r,cacheReadTokens:i,cacheCreationTokens:a,totalTokens:n+r+i+a,contextLimit:t.contextLimit||e?.contextLimit||0}}var Qt=class e{static DEFAULT_PAGE_PATH=`MEMORY.md`;orchestrator;_activeGroupId;_activePage;_activePinnedPage;_defaultPinnedPage;_activityLog;_activityLogSessionStartedAtByGroup;_aguiAdapter;_aguiEvent;_contextUsage;_currentPath;_db;_error;_files;_gitProxyUrl;_groups;_hadPersistedActivePage;_initResolve;_isTyping;_lastOrchestratorDisplayState=`idle`;_messages;_modelDownloadProgress;_onlineReplayHandler;_pages;_pagesAllowList;_pagesDenyList;_peerStateByGroup;_proxyUrl;_ready;_remoteAgentStatusByGroup;_remoteAgentTypingByGroup;_replayingTaskSyncOutbox;_subscriberId;_sidebarDefaultPage;_state;_storageStatus;_streamingText;_tasks;_taskSyncOutbox;_tokenUsage;_tokenUsageAccumulator=null;_toolActivity;_unreadGroupIds;_useProxy;_vmBashFullInternetAccess;_whenInitialized;_whenReady;_readyResolve;constructor(){this._messages=new h.State([]),this._isTyping=new h.State(!1),this._storageStatus=new h.State(null),this._toolActivity=new h.State(null),this._modelDownloadProgress=new h.State(null),this._activityLog=new h.State([]),this._state=new h.State(`idle`),this._tokenUsage=new h.State(null),this._error=new h.State(null),this._activeGroupId=new h.State(a),this._ready=new h.State(!1),this._tasks=new h.State([]),this._files=new h.State([]),this._currentPath=new h.State(`.`),this._groups=new h.State([]),this._unreadGroupIds=new h.State(/* @__PURE__ */ new Set),this._streamingText=new h.State(null),this._aguiEvent=new h.State(null),this._contextUsage=new h.State(null),this._useProxy=new h.State(!1),this._proxyUrl=new h.State(`/proxy`),this._gitProxyUrl=new h.State(`/git-proxy`),this._vmBashFullInternetAccess=new h.State(!1),this._activePage=new h.State(`pages`);let e=Z()?.sidebar?.defaultPage,t=e===`pages`||e===`chat`||e===`tasks`||e===`files`?e:`chat`;this._sidebarDefaultPage=new h.State(t),this._pages=new h.State([]),this._pagesAllowList=new h.State([]),this._pagesDenyList=new h.State([]),this._activePinnedPage=new h.State(null),this._defaultPinnedPage=new h.State(null),this._remoteAgentStatusByGroup=new h.State(/* @__PURE__ */ new Map),this._remoteAgentTypingByGroup=new h.State(/* @__PURE__ */ new Map),this._peerStateByGroup=new h.State(/* @__PURE__ */ new Map),this._hadPersistedActivePage=!1,this._initResolve=null,this._whenInitialized=new Promise(e=>{this._initResolve=e}),this._readyResolve=null,this._whenReady=new Promise(e=>{this._readyResolve=e}),this.orchestrator=null,this._db=null,this._activityLogSessionStartedAtByGroup=/* @__PURE__ */ new Map,this._taskSyncOutbox=[],this._replayingTaskSyncOutbox=!1,this._subscriberId=null,this._onlineReplayHandler=null,this._aguiAdapter=null}get activeGroupId(){return this._activeGroupId.get()}get activePage(){return this._activePage.get()}get activePinnedPage(){return this._activePinnedPage.get()}get defaultPinnedPage(){return this._defaultPinnedPage.get()}get pagesAllowList(){return this._pagesAllowList.get()}get pagesDenyList(){return this._pagesDenyList.get()}isPageAllowed(e,t){return xt(e,{allowList:this._pagesAllowList.get(),denyList:this._pagesDenyList.get(),groupId:t??this._activeGroupId.get()})}get effectiveDefaultPage(){let e=this._defaultPinnedPage.get();return e&&this.isPageAllowed(e.path,e.groupId)?e:this._pages.get()[0]||null}get activityLog(){return this._activityLog.get()}get taskServerEnabled(){return this.orchestrator?.taskServerEnabled??!1}get aguiEvent(){return this._aguiEvent.get()}clearError(){this._error.set(null),this._state.get()===`error`&&this._state.set(`idle`)}get contextUsage(){return this._contextUsage.get()}get tokenUsageAccumulator(){return this._tokenUsageAccumulator}get currentPath(){return this._currentPath.get()}get error(){return this._error.get()}get files(){return this._files.get()}getPeerState(e){return this._peerStateByGroup.get().get(e)||null}getRemoteAgentStatus(e){return this._remoteAgentStatusByGroup.get().get(e)||`idle`}getState(){return{messages:this.messages,isTyping:this.isTyping,toolActivity:this.toolActivity,activityLog:this.activityLog,state:this.state,tokenUsage:this.tokenUsage,modelDownloadProgress:this.modelDownloadProgress,error:this.error,activeGroupId:this.activeGroupId,pages:this.pages,ready:this.ready,files:this.files,currentPath:this.currentPath,streamingText:this.streamingText,contextUsage:this.contextUsage}}getTasksForBackup(){return this._tasks.get()}get gitProxyUrl(){return this._gitProxyUrl.get()}get groups(){return this._groups.get()}get hadPersistedActivePage(){return this._hadPersistedActivePage}isRemoteAgentTyping(e){return this._remoteAgentTypingByGroup.get().get(e)||!1}get isTyping(){return this._isTyping.get()}get messages(){return this._messages.get()}get modelDownloadProgress(){return this._modelDownloadProgress.get()}get pages(){return this._pages.get()}get proxyUrl(){return this._proxyUrl.get()}get ready(){return this._ready.get()}sendMessage(e,t=[],n){n===void 0?this.orchestrator?.browserChat?.submit(e,this._activeGroupId.get(),t):this.orchestrator?.browserChat?.submit(e,this._activeGroupId.get(),t,n)}async sendFileToPeer(e,t=this._activeGroupId.get(),n){let r=t.startsWith(`peer:`),i=t.startsWith(`room:`);if(!r&&!i){let e=`Can only send files to peers in a peer or room conversation.`;throw O(e,4500),Error(e)}let a=this.orchestrator?.router;if(!a){let e=`Network router is not initialized.`;throw O(e,4500),Error(e)}let o=n?.fileName||e.split(`/`).pop()||e,s=n?.mimeType||`application/octet-stream`,c=n?.size||0;a.setTyping(t,!0);try{let n={path:e,fileName:o,mimeType:s,size:c};if(await a.send(t,``,[n]),this._db){let e={id:_(),groupId:t,sender:`You`,content:``,timestamp:Date.now(),channel:i?`room`:`peerjs`,attachments:[n],isFromMe:!1,isTrigger:!1};await N(this._db,e),this.orchestrator?.events.emit(`message`,e)}ae(`Sent ${o} to ${i?`room peers`:`peer`}`,2500)}catch(e){let t=e instanceof Error?e.message:String(e);throw console.error(`sendFileToPeer error:`,e),O(`Failed to send file: ${t}`,6e3),e}finally{a.setTyping(t,!1)}}setActiveGroup(e,t,n=this._activePage.get()===`chat`){if(this._activeGroupId.set(t),this._messages.set([]),this._activityLog.set([]),this._error.set(null),this._isTyping.set(!1),this._toolActivity.set(null),this._modelDownloadProgress.set(null),this._streamingText.set(null),this._currentPath.set(`.`),n){let e=new Set(this._unreadGroupIds.get());e.delete(t)&&this._unreadGroupIds.set(e)}this.loadHistory(),this.loadTasks(e),this.loadFiles(e)}setReady(e=!0){this._ready.set(e),e&&this._readyResolve&&this._readyResolve()}setRemoteAgentStatus(e,t){let n=this._remoteAgentStatusByGroup.get(),r=new Map(n);r.set(e,t),this._remoteAgentStatusByGroup.set(r)}setRemoteAgentTyping(e,t){let n=this._remoteAgentTypingByGroup.get(),r=new Map(n);t?r.set(e,!0):r.delete(e),this._remoteAgentTypingByGroup.set(r)}get sidebarDefaultPage(){return this._sidebarDefaultPage.get()}get state(){return this._state.get()}stopCurrentRequest(){this.orchestrator?.stopCurrentRequest?.(this._activeGroupId.get())}get storageStatus(){return this._storageStatus.get()}get streamingText(){return this._streamingText.get()}syncHostWorkspaceToVM(){fe(this.orchestrator,this._activeGroupId.get())}syncVMWorkspaceToHost(){pe(this.orchestrator,this._activeGroupId.get())}get tasks(){return this._tasks.get()}get tokenUsage(){return this._tokenUsage.get()}get toolActivity(){return this._toolActivity.get()}get unreadGroupIds(){return this._unreadGroupIds.get()}get useProxy(){return this._useProxy.get()}get vmBashFullInternetAccess(){return this._vmBashFullInternetAccess.get()}get whenInitialized(){return this._whenInitialized}async resetSiteConfigSeed(e){await g(e,o.SITE_CONFIG_SEEDED,!1)}get whenReady(){return this._whenReady}async addPage(e,t,n=this._activeGroupId.get()){let r=n===`br:main`?this.normalizePagePath(t):t.trim();if(!r||!this.isPageAllowed(r,n))return;let i=this._pages.get();i.some(e=>e.path===r&&e.groupId===n)||(this.setPages([...i,{groupId:n,path:r}]),await pt(e,n,r),n===`br:main`&&r===`MEMORY.md`&&await z(e,!1),await this.persistPages(e))}async clearAllTasks(e){let t=await v(e),n=this._activeGroupId.get(),r=t.filter(e=>e.groupId===n),i=await this.getSubscriberId(e);for(let t of r)await $(t.id,this.getTaskServerBaseUrl(),i,this.orchestrator?.taskServerEnabled??!1)===`failed`?(console.warn(`Failed to delete task "${t.id}" from server — queued for replay.`),await this.queueTaskSyncOutboxOperation(e,{type:`delete`,id:t.id,queuedAt:Date.now()})):await Le(e,t.id);await this.loadTasks(e)}async cloneConversation(e,t){let n=await Ke(e,t);if(!n)return null;await Pe(e,t,n.groupId),await Fe(e,t,n.groupId);try{let r=await b(e,t,`MEMORY.md`);r&&await D(e,n.groupId,`MEMORY.md`,r)}catch{}try{await Qe(e,t,n.groupId,`attachments`)}catch{}return this.setActiveGroup(e,n.groupId),await this.loadGroups(e),n}async compactContext(e){if(!this.orchestrator)return;let{compactContext:t}=await import(`./compact-context-BINQh64w.js`);return t(this.orchestrator,e,this._activeGroupId.get())}async createConversation(e,t){let n=await Ve(e,t);return this.setActiveGroup(e,n.groupId),await this.loadGroups(e),n}async deleteConversation(e,t){if(!(this._groups.get().length<=1)&&(await We(e,t),await Ne(e,t),await this.loadGroups(e),this._activeGroupId.get()===t)){let t=this._groups.get()[0]?.groupId||`br:main`;this.setActiveGroup(e,t)}}async deleteMessage(e,t){await Ie(e,t),await this.loadHistory(),this.orchestrator?.refreshContextUsage&&await this.orchestrator.refreshContextUsage(e,this._activeGroupId.get())}async deleteTask(e,t){let n=await this.getSubscriberId(e);if(await $(t,this.getTaskServerBaseUrl(),n,this.orchestrator?.taskServerEnabled??!1)===`failed`)throw console.warn(`Failed to delete task from server — queued for replay.`),await this.queueTaskSyncOutboxOperation(e,{type:`delete`,id:t,queuedAt:Date.now()}),Error(`Failed to delete scheduled task on server; task kept locally.`);await Le(e,t),await this.loadTasks(e)}async ensurePeerConversation(e,t){let n=`peer:${t}`,r=await M(e);if(!r.find(e=>e.groupId===n)){let i=[...r],a=``;if(this.orchestrator?.peerjsPeerAliases){for(let[e,n]of Object.entries(this.orchestrator.peerjsPeerAliases))if(n===t){a=e;break}}i.push({groupId:n,name:`Peer: ${a||t.substring(0,8)}`,createdAt:Date.now()}),await j(e,i),await this.loadGroups(e)}return n}async grantStorageAccess(e){try{await st(e),await this.loadFiles(e)}catch(e){console.error(`Failed to grant storage access:`,e)}}async init(e,i){this._db=e,this.orchestrator=i,this._taskSyncOutbox=this.parseTaskSyncOutbox(await m(e,o.TASK_SYNC_OUTBOX)),await this.replayTaskSyncOutbox(e),typeof window<`u`&&!this._onlineReplayHandler&&(this._onlineReplayHandler=()=>{this._db&&this.replayTaskSyncOutbox(this._db)},window.addEventListener(`online`,this._onlineReplayHandler)),i.events.on(`a2ui-surface`,async({groupId:t,envelope:n})=>{t&&this.ensureGroupExists(e,t);let r=this._messages.get(),i=r.findIndex(e=>e.a2uiEnvelopes?.some(e=>e.surfaceId===n.surfaceId));if(i!==-1){let t=r[i],a=[...t.a2uiEnvelopes||[],n],o={...t,a2uiEnvelopes:a},s=[...r];s[i]=o,this._messages.set(s),await N(e,o)}else{let i=!t.startsWith(`peer:`),a={id:_(),groupId:t,sender:i?`agent`:t.replace(/^peer:/,``),content:``,timestamp:Date.now(),channel:t.startsWith(`peer:`)?`peerjs`:`browser`,isFromMe:i,isTrigger:!1,a2uiEnvelopes:[n]};t===this._activeGroupId.get()&&this._messages.set([...r,a]),await N(e,a)}}),i.events.on(`message`,t=>{if(t.groupId&&this.ensureGroupExists(e,t.groupId,t.timestamp),t.groupId&&t.groupId!==this._activeGroupId.get()){let e=new Set(this._unreadGroupIds.get());e.add(t.groupId),this._unreadGroupIds.set(e)}else t.isFromMe&&this._streamingText.get()!==null&&this._streamingText.set(null),this._messages.set([...this._messages.get(),t])}),i.events.on(`typing`,({groupId:e,typing:t})=>{e&&e!==this._activeGroupId.get()||this._isTyping.set(t)}),i.events.on(`tool-activity`,({groupId:e,tool:t,status:n})=>{e&&e!==this._activeGroupId.get()||this._toolActivity.set(n===`running`?{tool:t,status:n}:null)}),i.events.on(`model-download-progress`,e=>{this._modelDownloadProgress.set(e.status===`done`?null:e)}),i.events.on(`thinking-log`,e=>{e.groupId&&e.groupId!==this._activeGroupId.get()||(e.level===`info`&&e.label===`Starting`?this._activityLog.set([e]):this._activityLog.set([...this._activityLog.get(),e]),this.forwardActivityLogEntryToServer(e))}),i.events.on(`state-change`,e=>{let t=typeof e==`string`?e:e.state,n=typeof e==`string`?void 0:e.groupId;if(n&&n!==this._activeGroupId.get())return;let r=this._lastOrchestratorDisplayState;this._lastOrchestratorDisplayState=t,this._state.set(t),t===`idle`&&(this._toolActivity.set(null),this._modelDownloadProgress.set(null),this._streamingText.set(null)),t===`thinking`&&r!==`thinking`&&r!==`responding`&&(this._tokenUsageAccumulator=null)}),i.events.on(`error`,({error:e})=>{console.error(`[Orchestrator Error Event]`,e),this._error.set(e),this._state.set(`error`)}),i.events.on(`session-reset`,()=>{this._messages.set([]),this._activityLog.set([]),this._tokenUsageAccumulator=null,this._tokenUsage.set(null),this._contextUsage.set(null),this._toolActivity.set(null),this._modelDownloadProgress.set(null),this._streamingText.set(null),this._isTyping.set(!1),this._state.set(`idle`)}),i.events.on(`context-compacted`,e=>{e?.groupId&&e.groupId!==this._activeGroupId.get()||(this._tokenUsage.set(null),this.loadHistory())}),i.events.on(`token-usage`,e=>{if(!e||e.groupId&&e.groupId!==this._activeGroupId.get())return;let t=Zt(this._tokenUsageAccumulator,e);this._tokenUsageAccumulator=t,this._tokenUsage.set(t),this.orchestrator?.refreshContextUsage&&this._db&&this.orchestrator.refreshContextUsage(this._db,this._activeGroupId.get())}),i.events.on(`context-usage`,e=>{this._contextUsage.set(e)}),i.events.on(`ready`,()=>{this._ready.set(!0)}),i.events.on(`task-change`,()=>{this.loadTasks(e)}),i.events.on(`file-change`,()=>{this.loadFiles(e)}),i.events.on(`streaming-start`,({groupId:e})=>{e===this._activeGroupId.get()&&this._streamingText.set(``)}),i.events.on(`streaming-chunk`,({groupId:e,text:t})=>{if(e!==this._activeGroupId.get())return;let n=this._streamingText.get();this._streamingText.set((n||``)+t)}),i.events.on(`streaming-end`,({groupId:e})=>{e===this._activeGroupId.get()&&this._streamingText.set(null)}),i.events.on(`streaming-done`,({groupId:e})=>{this._activeGroupId.get()}),i.events.on(`streaming-error`,({groupId:e})=>{this._activeGroupId.get()}),this._aguiAdapter=new Bt(i.events),this._aguiAdapter.start(),typeof window<`u`&&window.addEventListener(`shadow-claw-agui-event`,(e=>{e.detail.groupId===this._activeGroupId.get()&&this._aguiEvent.set(e.detail);let t=e.detail.event;if(t){if(t.type===`STATE_SNAPSHOT`){let n=new Map(this._peerStateByGroup.get());n.set(e.detail.groupId,t.snapshot||{}),this._peerStateByGroup.set(n)}else if(t.type===`STATE_DELTA`){let n=new Map(this._peerStateByGroup.get()),r=Vt(n.get(e.detail.groupId)||{},t.delta||[]);n.set(e.detail.groupId,r),this._peerStateByGroup.set(n)}}})),await r(e),t(),n(),await k();let l=await m(e,o.PAGES_ALLOW_LIST),u=await m(e,o.PAGES_DENY_LIST);l&&this._pagesAllowList.set(Gt(String(l))),u&&this._pagesDenyList.set(Gt(String(u))),await k();let d=typeof document<`u`&&document.getElementById(`shadow-claw-static-routing`)!==null,f=await m(e,o.PAGES_LIST),p=f==null?[]:this.parsePagesList(f),h=await zt(e,a,p);h.length>0?(this.setPages(h),await this.persistPages(e)):await this.ensureDefaultPage(e),await k(),await this.applySiteConfigDefaults(e),await k(),await this.loadGroups(e);let g=await m(e,o.LAST_ACTIVE_GROUP);g&&g!==this._activeGroupId.get()&&this._activeGroupId.set(g),await k();let v=await m(e,o.LAST_ACTIVE_PAGE);v&&(this._activePage.set(v),this._hadPersistedActivePage=!0);let y=await m(e,o.SIDEBAR_DEFAULT_PAGE);this._sidebarDefaultPage.set(this.normalizeSidebarDefaultPage(y));let b=Pt(),x=null;if(b&&(x=c(b)),!x){let t=await m(e,o.DEFAULT_PINNED_PAGE);t&&(x=c(t))}x&&this.isPageAllowed(x.path,x.groupId)&&this._defaultPinnedPage.set(x),await k();let S=typeof window<`u`&&window.history?window.history.state:null,C=!!(S?.inFeedScroll||S?.scrollSpy||S?.suppressRouter)||typeof window<`u`&&window.location&&(()=>{let e=window.location.pathname||`/`,t=s();t!==`/`&&e.startsWith(t)&&(e=`/`+e.slice(t.length));let n=e.split(`/`).filter(Boolean);return n.length===0||n.length===1&&n[0]===`index.html`})(),w=!1;if(C&&x&&this.isPageAllowed(x.path,x.groupId)&&(this._activePinnedPage.set(x),w=!0),!w){let t=await m(e,o.LAST_SELECTED_PINNED_PAGE);if(t)try{let e=JSON.parse(t);e&&typeof e.path==`string`&&typeof e.groupId==`string`&&this.isPageAllowed(e.path,e.groupId)&&(this._activePinnedPage.set(e),w=!0)}catch{}}!w&&C&&this.effectiveDefaultPage&&this.isPageAllowed(this.effectiveDefaultPage.path,this.effectiveDefaultPage.groupId)&&(this._activePinnedPage.set(this.effectiveDefaultPage),w=!0),this.orchestrator&&(this._useProxy.set(this.orchestrator.useProxy),this._proxyUrl.set(this.orchestrator.proxyUrl),this._gitProxyUrl.set(this.orchestrator.gitProxyUrl),this._vmBashFullInternetAccess.set(this.orchestrator.vmBashFullInternetAccess));let[ee,te,T]=await Promise.all([m(e,o.SIDEBAR_CHAT_HIDDEN),m(e,o.SIDEBAR_TASKS_HIDDEN),m(e,o.SIDEBAR_FILES_HIDDEN)]),E=Z(),ne=E?.sidebar?.chatHidden,re=E?.sidebar?.tasksHidden,D=E?.sidebar?.filesHidden,ie=ee==null?!!ne:oe(ee),ae=te==null?!!re:oe(te),O=T==null?!!D:oe(T),se=()=>{let t=[];(!ie||this.activePage===`chat`)&&t.push(this.loadHistory()),(!ae||this.activePage===`tasks`)&&t.push(this.loadTasks(e)),(!O||this.activePage===`files`)&&t.push(this.loadFiles(e)),Promise.all(t).catch(e=>{console.warn(`Secondary background store loads failed:`,e)})};if(d)typeof window.requestIdleCallback==`function`?window.requestIdleCallback(se,{timeout:2e3}):setTimeout(se,100);else{let t=[];(!ie||this.activePage===`chat`)&&t.push(this.loadHistory()),(!ae||this.activePage===`tasks`)&&t.push(this.loadTasks(e)),(!O||this.activePage===`files`)&&t.push(this.loadFiles(e)),await Promise.all(t)}await k(),this._initResolve?.(),this.scheduleBackgroundStaticMainSiteSeeding(e)}async loadFiles(e){let t=this._activeGroupId.get(),n=this._currentPath.get();try{this._storageStatus.set(await C(e));let r=await at(e,t,n);this._files.set(r)}catch(e){console.error(`Failed to load files in store:`,e)}}async loadGroups(e){let t=await M(e);this._groups.set(t)}async loadHistory(){let e=this._activeGroupId.get(),t=await Re(e,200);this._activeGroupId.get()===e&&this._messages.set(t)}async loadTasks(e){let t=this._activeGroupId.get(),n=await v(e),r=n.filter(e=>e.groupId===t);r.sort((e,t)=>{let n=e.order??0,r=t.order??0;return n===r?e.createdAt-t.createdAt:n-r}),this._tasks.set(r);let i=await this.getSubscriberId(e),a=await Xt(t,this.getTaskServerBaseUrl(),i,this.orchestrator?.taskServerEnabled??!1);if(!a)return;let o=new Set(n.map(e=>e.id)),s=a.filter(e=>!o.has(e.id));if(s.length===0)return;for(let t of s)await P(e,t);let c=[...r,...s];c.sort((e,t)=>{let n=e.order??0,r=t.order??0;return n===r?e.createdAt-t.createdAt:n-r}),this._tasks.set(c)}async navigateBackFolder(e){let t=this._currentPath.get();if(t===`.`)return;let n=t.split(`/`).filter(Boolean);n.pop();let r=n.length===0?`.`:n.join(`/`);await this.setCurrentPath(e,r)}async navigateIntoFolder(e,t){let n=this._currentPath.get(),r=n===`.`?t.replace(/\/$/,``):`${n}/${t.replace(/\/$/,``)}`;try{await this.setCurrentPath(e,r)}catch(t){console.error(`Failed to navigate into folder in store:`,t),O(`Folder not found: ${r}`,4500),await this.loadFiles(e)}}async newSession(e){await this.orchestrator?.newSession?.(e,this._activeGroupId.get()),await this.loadHistory()}async removePage(t,n,r=this._activeGroupId.get()){let i=this.normalizePagePath(n);if(!i)return;let o=this._pages.get();if(!o.some(e=>e.path===i&&e.groupId===r))return;let s=o.filter(e=>e.path!==i||e.groupId!==r);await ft(t,r,i);let c=r===`br:main`&&i===`MEMORY.md`;c&&await z(t,!0);let l=c||await R(t);if(s.length===0&&!l){if(await B(t,`br:main`))s.push({groupId:a,path:e.DEFAULT_PAGE_PATH});else return}this.setPages(s);let u=this._defaultPinnedPage.get();u&&u.path===i&&u.groupId===r&&await this.setDefaultPinnedPage(t,null),await this.persistPages(t)}async removeAllPages(e){let t=[...this._pages.get()];for(let n of t)await ft(e,n.groupId,n.path),n.groupId===`br:main`&&n.path===`MEMORY.md`&&await z(e,!0);this.setPages([]),await this.setDefaultPinnedPage(e,null),await this.setActivePinnedPage(e,null),await this.persistPages(e)}async renameConversation(e,t,n){await He(e,t,n),await this.loadGroups(e)}async reorderConversations(e,t){await Ge(e,t),await this.loadGroups(e)}async reorderTasks(e,t,n){let r=await Ze(e,t,n);await this.loadTasks(e);let i=await this.getSubscriberId(e);for(let t of r)await Q(t,this.getTaskServerBaseUrl(),i,this.orchestrator?.taskServerEnabled??!1)||(console.warn(`Failed to sync reordered task "${t.id}" to server — queued for replay.`),await this.queueTaskSyncOutboxOperation(e,{type:`upsert`,id:t.id,task:t,queuedAt:Date.now()}))}async replayTaskSyncOutbox(e){if(!(this._replayingTaskSyncOutbox||this._taskSyncOutbox.length===0)){this._replayingTaskSyncOutbox=!0;try{let t=await this.getSubscriberId(e),n=[];for(let e of this._taskSyncOutbox){let r=this.getTaskServerBaseUrl();(e.type===`upsert`?await Q(e.task,r,t,this.orchestrator?.taskServerEnabled??!1):await $(e.id,r,t,this.orchestrator?.taskServerEnabled??!1))||n.push(e)}this._taskSyncOutbox=this.compactTaskSyncOutbox(n),await this.persistTaskSyncOutbox(e)}finally{this._replayingTaskSyncOutbox=!1}}}async resetToRootFolder(e){await this.setCurrentPath(e,`.`)}async restartCurrentRequest(){return this.orchestrator?.restartCurrentRequest?this.orchestrator.restartCurrentRequest(this._activeGroupId.get()):!1}async restoreTasksFromBackup(e,t){await this.clearAllTasks(e);let n=this._activeGroupId.get();for(let r of t){let t={...r,groupId:n,id:crypto.randomUUID?crypto.randomUUID():`task-${Date.now()}-${Math.random()}`};await this.upsertTask(e,t,{reloadTasks:!1})}await this.loadTasks(e)}async runTask(e,t=!1){let n=this._db;if(t&&n&&(await Xe(e.id,Date.now()),await this.loadTasks(n)),e.type===`tools`&&Array.isArray(e.tools)&&e.tools.length>0){if(this.orchestrator?.agentWorker){let n=e.subagent?`subagent:${_()}`:e.groupId;this.orchestrator.agentWorker.postMessage({type:`execute-task-tools`,payload:{groupId:n,tools:e.tools,isManual:t}})}else console.error(`Agent worker not available to execute tool task.`)}else{if(!e.groupId){console.error(`Task ${e.id} has no groupId - refusing to execute in active conversation to prevent context pollution.`);return}this.orchestrator?.browserChat?.submit(e.prompt,e.groupId,[],void 0,e.freshContext,e.subagent)}}async setActivePage(e,t){this._activePage.set(t),await g(e,o.LAST_ACTIVE_PAGE,t);let n=this.resolveSidebarDefaultPageForActivePage(t);n!==this._sidebarDefaultPage.get()&&(this._sidebarDefaultPage.set(n),await g(e,o.SIDEBAR_DEFAULT_PAGE,n))}async setActivePinnedPage(e,t){t&&!this.isPageAllowed(t.path,t.groupId)&&(t=this.effectiveDefaultPage),this._activePinnedPage.set(t),t?await g(e,o.LAST_SELECTED_PINNED_PAGE,JSON.stringify(t)):await g(e,o.LAST_SELECTED_PINNED_PAGE,null)}async setDefaultPinnedPage(e,t){if(t&&!this.isPageAllowed(t.path,t.groupId))return;let n=this._defaultPinnedPage.get(),r=n&&t&&n.path===t.path&&n.groupId===t.groupId?null:t;this._defaultPinnedPage.set(r),r?await g(e,o.DEFAULT_PINNED_PAGE,JSON.stringify(r)):await g(e,o.DEFAULT_PINNED_PAGE,null)}async reorderPages(e,t){this.setPages(t),await this.persistPages(e)}async setCurrentPath(e,t){let n=t.replace(/^\/+|\/+$/g,``)||`.`,r=this._activeGroupId.get();this._storageStatus.set(await C(e));let i=await at(e,r,n);this._currentPath.set(n),this._files.set(i)}async setGitProxyUrl(e,t){this.orchestrator&&(await be(this.orchestrator,e,t),this._gitProxyUrl.set(this.orchestrator.gitProxyUrl))}async setProxyUrl(e,t){this.orchestrator&&(await Ce(this.orchestrator,e,t),this._proxyUrl.set(this.orchestrator.proxyUrl))}async setUseProxy(e,t){this.orchestrator&&(await Ae(this.orchestrator,e,t),this._useProxy.set(this.orchestrator.useProxy))}async setVMBashFullInternetAccess(e,t){this.orchestrator&&(await je(this.orchestrator,e,t),this._vmBashFullInternetAccess.set(this.orchestrator.vmBashFullInternetAccess))}async switchConversation(e,t,n){this.setActiveGroup(e,t,n??this._activePage.get()===`chat`),await g(e,o.LAST_ACTIVE_GROUP,t)}async toggleTask(e,t,n){let r={...t,enabled:n};await P(e,r),await this.loadTasks(e),await Q(r,this.getTaskServerBaseUrl(),await this.getSubscriberId(e),this.orchestrator?.taskServerEnabled??!1)||(console.warn(`Failed to update task on server — queued for replay.`),await this.queueTaskSyncOutboxOperation(e,{type:`upsert`,id:r.id,task:r,queuedAt:Date.now()}))}async updateConversationPinnedProvider(e,t,n,r,i){await qe(e,t,n,r,i),await this.loadGroups(e)}async updateConversationProviderRuntimeOverrides(e,t,n){await Ye(e,t,n),await this.loadGroups(e)}async updateConversationSubagentSettings(e,t,n,r,i,a){await Je(e,t,n,r,i,a),await this.loadGroups(e)}async updateConversationToolTags(e,t,n){await Ue(e,t,n),await this.loadGroups(e)}async upsertTask(e,t,n){let r=n?.reloadTasks!==!1;await P(e,t),r&&await this.loadTasks(e);let i=await this.getSubscriberId(e);await Q(t,this.getTaskServerBaseUrl(),i,this.orchestrator?.taskServerEnabled??!1)||(console.warn(`Failed to sync task to server — queued for replay.`),await this.queueTaskSyncOutboxOperation(e,{type:`upsert`,id:t.id,task:t,queuedAt:Date.now()}))}compactTaskSyncOutbox(e){let t=/* @__PURE__ */ new Map;return e.forEach((e,n)=>{t.set(e.id,n)}),e.filter((e,n)=>t.get(e.id)===n)}deriveGroupName(e){return e.startsWith(`tg:`)?`Telegram ${e.slice(3)}`:e.startsWith(`im:`)?`iMessage ${e.slice(3)}`:e.startsWith(`br:`)?e===`br:main`?`Main`:`Browser Conversation`:`Conversation`}getActivityLogSessionStartedAt(e){let t=this._activityLogSessionStartedAtByGroup.get(e);if(t)return t;let n=(/* @__PURE__ */ new Date()).toISOString();return this._activityLogSessionStartedAtByGroup.set(e,n),n}getTaskServerBaseUrl(){return this.orchestrator?.taskServerUrl??`/schedule`}async getSubscriberId(e){if(this._subscriberId)return this._subscriberId;let t=await S(e);return this._subscriberId=t,t}normalizePagePath(t){let n=t.trim().replace(/^\/+/,``).replace(/\/+/g,`/`);return n===`main/memory.md`?e.DEFAULT_PAGE_PATH:n}normalizeSidebarDefaultPage(e){return e===`pages`||e===`chat`||e===`tasks`||e===`files`?e:`chat`}parsePagesList(e){if(!e)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t.map(e=>{if(typeof e==`string`)return{groupId:a,path:this.normalizePagePath(e)};if(!e||typeof e!=`object`)return null;let t=e;if(typeof t.path!=`string`)return null;let n=typeof t.groupId==`string`&&t.groupId.trim().length>0?t.groupId:a,r=n===`br:main`?this.normalizePagePath(t.path):t.path.trim();return r?{groupId:n,path:r}:null}).filter(e=>!!e).filter((e,t,n)=>{let r=`${e.groupId}\u0000${e.path}`;return t===n.findIndex(e=>`${e.groupId}\u0000${e.path}`===r)}):[]}catch{return[]}}parseTaskSyncOutbox(e){if(!e)return[];try{let t=JSON.parse(e);if(!Array.isArray(t))return[];let n=t.filter(e=>!!e&&typeof e==`object`).filter(e=>e.type===`upsert`||e.type===`delete`).filter(e=>typeof e.id==`string`&&e.id.length>0).map(e=>({...e,queuedAt:typeof e.queuedAt==`number`?e.queuedAt:Date.now()}));return this.compactTaskSyncOutbox(n)}catch{return[]}}resolveSidebarDefaultPageForActivePage(e){return e===`pages`||e===`chat`||e===`tasks`||e===`files`?e:this._sidebarDefaultPage.get()}setPages(e){let t=e.filter(e=>this.isPageAllowed(e.path,e.groupId)),n=t.filter(e=>e.path.toLowerCase()===`memory.md`),r=t.filter(e=>e.path.toLowerCase()!==`memory.md`);this._pages.set([...r,...n])}async ensureDefaultPage(t){if(await R(t))return;let n=await B(t,a);await I(t,a),!(!n||this._pages.get().length>0)&&(this.setPages([{groupId:a,path:e.DEFAULT_PAGE_PATH}]),await this.persistPages(t))}async ensureGroupExists(e,t,n){let r=this._groups.get();if(r.some(e=>e.groupId===t))return;let i=[...r,{groupId:t,name:this.deriveGroupName(t),createdAt:n||Date.now()}];this._groups.set(i);try{await j(e,i)}catch(e){console.error(`Failed to persist new conversation metadata:`,e)}}async forwardActivityLogEntryToServer(e){if(!this._db||!Jt(await m(this._db,o.ACTIVITY_LOG_DISK_LOGGING_ENABLED)))return;let t=typeof e.groupId==`string`&&e.groupId?e.groupId:this._activeGroupId.get();if(!t)return;let n=typeof e.message==`string`?e.message.trim():``;if(!n)return;e.level===`info`&&e.label===`Starting`&&this._activityLogSessionStartedAtByGroup.set(t,(/* @__PURE__ */ new Date()).toISOString());let r=this.getActivityLogSessionStartedAt(t);try{await fetch(`/activity-log`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({groupId:t,level:e.level,label:e.label,message:n,timestamp:(/* @__PURE__ */ new Date()).toISOString(),sessionStartedAt:r})})}catch(e){console.warn(`Failed to persist activity log entry to server:`,e)}}scheduleBackgroundStaticMainSiteSeeding(e){if(typeof window>`u`)return;let t=async()=>{try{if(await Ct(e,`br:main`))return;let t=await m(e,o.PAGES_LIST),n=t==null?[]:this.parsePagesList(t),r=await zt(e,a,n,{preferEmbedded:!1});r&&r.length>0&&(this.setPages(r),await this.persistPages(e))}catch(e){console.warn(`Background static main site seeding failed:`,e)}};typeof window.requestIdleCallback==`function`?window.requestIdleCallback(()=>void t(),{timeout:3e3}):setTimeout(()=>void t(),100)}async persistPages(e){await g(e,o.PAGES_LIST,JSON.stringify(this._pages.get()))}async persistTaskSyncOutbox(e){await g(e,o.TASK_SYNC_OUTBOX,JSON.stringify(this._taskSyncOutbox))}async queueTaskSyncOutboxOperation(e,t){this._taskSyncOutbox=this.compactTaskSyncOutbox([...this._taskSyncOutbox,t]),await this.persistTaskSyncOutbox(e)}async applySiteConfigDefaults(e){if(typeof document<`u`)try{let r=Z();if(!r||typeof r!=`object`)return;i(r),t(),n();let s=r.customElements;if((await M(e)).find(e=>e.groupId===`br:main`)?.toolTags&&await Ue(e,a,void 0),(r.settings?.internetAccess??r.settings?.vm_bash_full_internet_access??r.settings?.fullInternetAccess??r.internetAccess)===!0&&await m(e,o.VM_BASH_FULL_INTERNET_ACCESS)!==`true`&&(await g(e,o.VM_BASH_FULL_INTERNET_ACCESS,`true`),this.orchestrator&&(this.orchestrator.vmBashFullInternetAccess=!0),this._vmBashFullInternetAccess.set(!0)),r.pages&&typeof r.pages==`object`){let{defaultPinnedPage:t}=r.pages;if(t&&typeof t==`string`){let n=c(t);n&&this.isPageAllowed(n.path,n.groupId)&&(this._defaultPinnedPage.set(n),await g(e,o.DEFAULT_PINNED_PAGE,JSON.stringify(n)))}}let l=r.allowedCustomElements||(typeof s==`object`&&!Array.isArray(s)?s.allowedElements:void 0);l!==void 0&&(await m(e,o.ALLOWED_CUSTOM_ELEMENTS)??await g(e,o.ALLOWED_CUSTOM_ELEMENTS,JSON.stringify(l)));let u=r.allowedCustomElementDomains||(typeof s==`object`&&!Array.isArray(s)?s.allowedDomains:void 0);if(u!==void 0&&(await m(e,o.ALLOWED_CUSTOM_ELEMENT_HOST_PATTERNS)??await g(e,o.ALLOWED_CUSTOM_ELEMENT_HOST_PATTERNS,JSON.stringify(u))),r.sidebar&&typeof r.sidebar==`object`){let{pagesHidden:t,chatHidden:n,tasksHidden:i,filesHidden:a,defaultPage:s}=r.sidebar;if(t!==void 0&&(await m(e,o.SIDEBAR_PAGES_HIDDEN)??await g(e,o.SIDEBAR_PAGES_HIDDEN,String(!!t))),n!==void 0&&(await m(e,o.SIDEBAR_CHAT_HIDDEN)??await g(e,o.SIDEBAR_CHAT_HIDDEN,String(!!n))),i!==void 0&&(await m(e,o.SIDEBAR_TASKS_HIDDEN)??await g(e,o.SIDEBAR_TASKS_HIDDEN,String(!!i))),a!==void 0&&(await m(e,o.SIDEBAR_FILES_HIDDEN)??await g(e,o.SIDEBAR_FILES_HIDDEN,String(!!a))),s&&typeof s==`string`){let t=this.normalizeSidebarDefaultPage(s);this._sidebarDefaultPage.set(t),await m(e,o.SIDEBAR_DEFAULT_PAGE)||await g(e,o.SIDEBAR_DEFAULT_PAGE,s)}}if(r.settings&&typeof r.settings==`object`){let{assistantName:t,defaultProvider:n,provider:i,defaultModel:a,model:s}=r.settings;t&&typeof t==`string`&&(await m(e,o.ASSISTANT_NAME)||await g(e,o.ASSISTANT_NAME,t));let c=n??i;if(typeof c==`string`&&c.trim().length>0&&!await m(e,o.PROVIDER)){let t=c.trim();await g(e,o.PROVIDER,t),this.orchestrator&&(this.orchestrator.provider=t)}let l=a??s;if(typeof l==`string`&&l.trim().length>0&&!await m(e,o.MODEL)){let t=l.trim();await g(e,o.MODEL,t),this.orchestrator&&(this.orchestrator.model=t)}let u=r.settings.internetAccess??r.settings.vm_bash_full_internet_access??r.settings.fullInternetAccess??r.internetAccess;typeof u==`boolean`&&(await m(e,o.VM_BASH_FULL_INTERNET_ACCESS)??(await g(e,o.VM_BASH_FULL_INTERNET_ACCESS,String(u)),this.orchestrator&&(this.orchestrator.vmBashFullInternetAccess=u),this._vmBashFullInternetAccess.set(u)))}let d=(r.settings&&typeof r.settings==`object`?r.settings.defaultToolsProfile:void 0)??r.defaultToolsProfile;if(typeof d==`string`&&d.trim().length>0&&!await m(e,o.ACTIVE_TOOL_PROFILE)){let t=d.trim();if(t.toLowerCase()===`none`)await x.deactivateProfile(e);else{let n=x.profiles.find(e=>e.id.toLowerCase()===t.toLowerCase()||e.name.toLowerCase()===t.toLowerCase());n?await x.activateProfile(e,n.id):console.warn(`Default tools profile "${t}" specified in site-config was not found.`)}}if(r.pages&&typeof r.pages==`object`){let{defaultPinnedPage:t}=r.pages;t&&typeof t==`string`&&(await m(e,o.DEFAULT_PINNED_PAGE)||await g(e,o.DEFAULT_PINNED_PAGE,t))}let f=r.pages?.allowList??r.pages?.allowlist??r.allowList??r.allowlist,p=r.pages?.denyList??r.pages?.denylist??r.denyList??r.denylist;if(Array.isArray(f)&&await m(e,o.PAGES_ALLOW_LIST)==null){let t=K(f.map(String));this._pagesAllowList.set(t),await g(e,o.PAGES_ALLOW_LIST,JSON.stringify(t))}if(Array.isArray(p)&&await m(e,o.PAGES_DENY_LIST)==null){let t=K(p.map(String));this._pagesDenyList.set(t),await g(e,o.PAGES_DENY_LIST,JSON.stringify(t))}await g(e,o.SITE_CONFIG_SEEDED,`true`);let h=this._pages.get(),_=h.filter(e=>this.isPageAllowed(e.path,e.groupId));_.length!==h.length&&(this.setPages(_),await this.persistPages(e));let v=this._activePinnedPage.get();v&&!this.isPageAllowed(v.path,v.groupId)&&await this.setActivePinnedPage(e,this.effectiveDefaultPage);let y=this._defaultPinnedPage.get();if(y&&!this.isPageAllowed(y.path,y.groupId)&&await this.setDefaultPinnedPage(e,null),Array.isArray(r.enabledTools)){let t=r.enabledTools.filter(e=>typeof e==`string`&&e.trim().length>0);await x.setAllEnabled(e,t),await x.setAllDeclarativeEnabled(e,t)}await g(e,o.SITE_CONFIG_SEEDED,`true`)}catch(e){console.warn(`Failed to apply site-config defaults:`,e)}}};const $t=new Qt;export{ye as A,Ae as B,N as C,Re as D,M as E,Te as F,le as G,ve as H,Ee as I,he as J,de as K,De as L,Se as M,Ce as N,Le as O,we as P,k as Q,Oe as R,P as S,A as T,me as U,Me as V,ue as W,se as X,_e as Y,ce as Z,B as _,Pt as a,nt as b,K as c,U as d,ct as f,at as g,H as h,Gt as i,xe as j,Ne as k,ft as l,lt as m,Kt as n,Ft as o,V as p,ge as q,Z as r,jt as s,$t as t,W as u,z as v,Ve as w,Xe as x,I as y,ke as z};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{C as e,I as t,O as n,P as r,r as i,y as a,z as o}from"./config-C-YdSFZB.js";import{t as s}from"./get-config-Bkvl__ZS.js";import{t as c}from"./set-config-DSiuMe0k.js";import{t as l}from"./tools-DHA1dK2I.js";function u(){let e=globalThis.LanguageModel;return!e||typeof e!=`function`||typeof e.availability!=`function`||typeof e.create!=`function`?null:e}function d(){return!!u()}async function f(e){return await e.getApiKey()||void 0}async function p(e){return await e.getApiKey()||``}function m(e){return{mode:e.llamafileMode,host:e.llamafileHost,port:e.llamafilePort,offline:e.llamafileOffline}}function h(e){return{authMode:e.bedrockAuthMode,profile:e.bedrockProfileFallback,region:e.bedrockRegionFallback}}function g(){return Object.entries(e).map(([e,t])=>({id:e,name:t.name,...!t.modelsUrl&&{models:Array.isArray(t.models)&&t.models.length>0?t.models:[t.defaultModel]},...t.modelsUrl&&{modelsUrl:t.modelsUrl},...t.headers&&{headers:t.headers},...t.apiKeyHeader&&{apiKeyHeader:t.apiKeyHeader},...t.apiKeyHeaderFormat&&{apiKeyHeaderFormat:t.apiKeyHeaderFormat},...typeof t.requiresApiKey==`boolean`&&{requiresApiKey:t.requiresApiKey}}))}function _(e){let t=typeof e.reasoningEffort==`string`?e.reasoningEffort.trim().toLowerCase():`none`;if(t&&t!==`none`)return{effort:t}}function v(e,t,n=``,r){if(t===`llamafile`){let t=r?.llamafile,i={"x-llamafile-mode":t?.mode===`server`||t?.mode===`cli`?t.mode:e.llamafileMode,"x-llamafile-host":t?.host||e.llamafileHost,"x-llamafile-port":String(t?.port||e.llamafilePort),"x-llamafile-offline":t?.offline??e.llamafileOffline?`true`:`false`};return n&&(i[`x-shadowclaw-request-id`]=n),i}if(t===`bedrock_proxy`){let t=r?.bedrock_proxy,n={};return(t?.region||e.bedrockRegionFallback)&&(n[`x-bedrock-region`]=t?.region||e.bedrockRegionFallback),(t?.profile||e.bedrockProfileFallback)&&(n[`x-bedrock-profile`]=t?.profile||e.bedrockProfileFallback),n[`x-bedrock-auth-mode`]=t?.authMode||e.bedrockAuthMode,n}return{}}function y(e){e.providerConfig?.id===`llamafile`&&(e.providerConfig={...e.providerConfig,headers:{...e.providerConfig.headers||{},"x-llamafile-mode":e.llamafileMode,"x-llamafile-host":e.llamafileHost,"x-llamafile-port":String(e.llamafilePort),"x-llamafile-offline":e.llamafileOffline?`true`:`false`}})}function b(e){e.providerConfig?.id===`mesh-llm`&&(e.providerConfig={...e.providerConfig,headers:{...e.providerConfig.headers||{},"x-mesh-llm-host":e.meshLlmHost}})}function x(e,n){if(n&&e.inFlightEffectiveProviderByGroup){let t=e.inFlightEffectiveProviderByGroup.get(n);if(t?.providerId===`transformers_js_local`){let e=t.providerConfig.baseUrl||``;if(e.includes(`/chat/completions`))return e.replace(`/chat/completions`,`/status`)}}let r=e.providerConfig;if(r&&(!r.id||r.id===`transformers_js_local`)){let e=r.baseUrl||``;if(e.includes(`/chat/completions`))return e.replace(`/chat/completions`,`/status`)}let i=t(`transformers_js_local`)?.baseUrl||``;return i.includes(`/chat/completions`)?i.replace(`/chat/completions`,`/status`):`http://localhost:8888/transformers-js-proxy/status`}async function S(e,t,r,a=c){e.assistantName=r,e.triggerPattern=n(r),await a(t,i.ASSISTANT_NAME,r)}async function C(e,t,n,r=c){let a=typeof n.region==`string`?n.region.trim():``,o=typeof n.profile==`string`?n.profile.trim():``,s=n.authMode===`sso`?`sso`:`provider_chain`;e.bedrockRegionFallback=a,e.bedrockProfileFallback=o,e.bedrockAuthMode=s,await r(t,i.BEDROCK_REGION_FALLBACK,a),await r(t,i.BEDROCK_PROFILE_FALLBACK,o),await r(t,i.BEDROCK_AUTH_MODE,s)}async function w(e,t,n,r=c){e.llamafileMode=n.mode,e.llamafileHost=n.host,e.llamafilePort=n.port,e.llamafileOffline=n.offline,await r(t,i.LLAMAFILE_MODE,n.mode),await r(t,i.LLAMAFILE_HOST,n.host),await r(t,i.LLAMAFILE_PORT,String(n.port)),await r(t,i.LLAMAFILE_OFFLINE,n.offline?`true`:`false`),y(e)}async function T(e,t,n,r=c){e.meshLlmHost=n.host,await r(t,i.MESH_LLM_HOST,n.host),b(e)}async function E(e,t,n,a=c){e.model=n;let o=n;e.provider===`prompt_api`&&!d()&&(n===`browser-built-in`||!n)&&(o=await s(t,i.PROMPT_API_FALLBACK_MODEL)||`onnx-community/Qwen3-0.6B-ONNX`),e.maxTokens=r(o),await a(t,i.MODEL,n),await k(e,t)}async function D(e,t,n,r=c){e.peerjsMyAlias=n.trim(),await r(t,i.PEERJS_MY_ALIAS,e.peerjsMyAlias)}async function O(e,t,n,r=c){e.peerjsPeerAliases={...n},await r(t,i.PEERJS_PEER_ALIASES,JSON.stringify(e.peerjsPeerAliases))}async function k(e,t){if(!l.activeProfileId&&l.enabledToolNames.size===0)return;let n=l.findProfilesForProvider(e.provider,e.model);if(n.length===0)return;let r=n.find(t=>t.providerId===e.provider&&t.model===e.model);if(r){await l.activateProfile(t,r.id);return}let i=n.find(t=>t.providerId===e.provider&&!t.model);i&&await l.activateProfile(t,i.id)}async function A(e,n,a,l,u=c){let f=t(a);if(!f)throw Error(`Unknown provider: ${a}`);e.provider=a,e.providerConfig=f,e.model=f.defaultModel,y(e),b(e),await l.loadApiKeyForProvider(n,a),await o.fetchModelInfo(f,await l.getApiKeyForHeaders()||void 0,v(e,a));let p=e.model;a===`prompt_api`&&!d()&&(e.model===`browser-built-in`||!e.model)&&(p=await s(n,i.PROMPT_API_FALLBACK_MODEL)||`onnx-community/Qwen3-0.6B-ONNX`),e.maxTokens=r(p),await u(n,i.PROVIDER,a),await u(n,i.MODEL,e.model),await k(e,n)}async function j(e,t,n,r){try{let i=x(e,n),a=await fetch(i,{headers:{Accept:`application/json`},method:`GET`});if(!a.ok)return;let o=await a.json(),s=Number(o?.progress),c=Number.isFinite(s)&&s>1?Math.max(0,Math.min(1,s/100)):Number.isFinite(s)?Math.max(0,Math.min(1,s)):null,l={groupId:n,message:typeof o?.message==`string`&&o.message?o.message:void 0,progress:c,status:o?.status===`done`||o?.status===`error`?o.status:`running`};t.emit(`model-download-progress`,l),(l.status===`done`||l.status===`error`)&&r(n)}catch{}}function M(e,t,n){N(e,n),t.emit(`model-download-progress`,{groupId:n,message:`Preparing local model download...`,progress:null,status:`running`}),j(e,t,n,t=>N(e,t));let r=setInterval(()=>{j(e,t,n,t=>N(e,t))},1e3);e.transformersProgressPollers.set(n,r)}function N(e,t){let n=e.transformersProgressPollers.get(t);typeof n==`number`&&(clearInterval(n),e.transformersProgressPollers.delete(t))}async function P(e){try{await fetch(a.replace(`/chat/completions`,`/cancel`),{body:JSON.stringify({requestId:e}),headers:{"Content-Type":`application/json`,"x-shadowclaw-request-id":e},keepalive:!0,method:`POST`})}catch{}}export{d as S,O as _,p as a,N as b,m as c,S as d,C as f,D as g,E as h,f as i,v as l,T as m,b as n,g as o,w as p,P as r,h as s,y as t,_ as u,A as v,u as x,M as y};
|