shadow-claw 1.23.4 → 1.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -5
- package/bin/cli.mjs +166 -0
- package/bin/cli.test.mjs +60 -0
- package/bin/commands/backup.mjs +70 -0
- package/bin/commands/clients.mjs +41 -0
- package/bin/commands/peer-id.mjs +76 -0
- package/bin/commands/peer-id.test.mjs +104 -0
- package/bin/commands/send.mjs +51 -0
- package/bin/commands/tasks.mjs +59 -0
- package/bin/commands/webrtc-listen.mjs +254 -0
- package/bin/prerender-dsd-shell/prerender-dsd-shell.test.mjs +46 -0
- package/bin/rolldown.config.test.mjs +401 -8
- package/bin/utils/control-client.mjs +243 -0
- package/bin/utils/control-client.test.mjs +83 -0
- package/bin/utils/ulid.mjs +45 -0
- package/bin/utils/webrtc-control-client.mjs +699 -0
- package/bin/utils/webrtc-control-client.test.mjs +318 -0
- package/dist/electron/main.cjs +1 -1
- package/dist/public/AGENTS.md +5 -3
- package/dist/public/README.md +42 -5
- package/dist/public/agent.worker.js +1 -1
- package/dist/public/backup-controller-C_s9in2t.js +1 -0
- package/dist/public/components/settings/shadow-claw-control-plane/shadow-claw-control-plane.css +1 -0
- package/dist/public/components/settings/shadow-claw-control-plane/shadow-claw-control-plane.html +1 -0
- package/dist/public/components/settings/shadow-claw-task-server/shadow-claw-task-server.css +1 -1
- package/dist/public/components/settings/shadow-claw-task-server/shadow-claw-task-server.html +1 -1
- package/dist/public/components/shadow-claw-settings/shadow-claw-settings.html +1 -1
- package/dist/public/config-CrHchneq.js +1 -0
- package/dist/public/{configurePeerJs-B4Ym9VMj.js → configurePeerJs-CxpZeDJJ.js} +1 -1
- package/dist/public/{connections-BEn6JYdu.js → connections-DvbgdkaB.js} +1 -1
- package/dist/public/{custom-element-security-DdYlUozq.js → custom-element-security-NCqQ5lmC.js} +1 -1
- package/dist/public/docs/README.md +3 -1
- package/dist/public/docs/architecture/overview.md +12 -12
- package/dist/public/docs/decisions/bundled-typescript-architecture.md +1 -1
- package/dist/public/docs/decisions/indexeddb-and-opfs-storage.md +2 -2
- package/dist/public/docs/decisions/native-web-components-and-signals.md +1 -1
- package/dist/public/docs/example/article/index.html +1 -1
- package/dist/public/docs/guides/configuring-messaging-channels.md +41 -6
- package/dist/public/docs/guides/server-development-configuration.md +24 -0
- package/dist/public/docs/publishing/index.html +1 -1
- package/dist/public/docs/skill-creator/index.html +1 -1
- package/dist/public/docs/subsystems/backup.md +56 -0
- package/dist/public/docs/subsystems/cli.md +124 -0
- package/dist/public/docs/subsystems/control-plane.md +158 -0
- package/dist/public/docs/subsystems/notifications.md +54 -2
- package/dist/public/docs/subsystems/reactive-ui.md +1 -0
- package/dist/public/downloadGroupFile-By0GR6eV.js +1 -0
- package/dist/public/e2e/README.md +5 -1
- package/dist/public/{e2e-bridge-BQ4KzUt5.js → e2e-bridge-IGWsRl4i.js} +1 -1
- package/dist/public/file-viewer-D0eflgt6.js +1 -0
- package/dist/public/getAllTasks-vpBlgGsc.js +1 -0
- package/dist/public/getGroupDir-P1h9wl6S.js +1 -0
- package/dist/public/{git-DEUvQTUA.js → git-7Vq_SJSp.js} +2 -2
- package/dist/public/{iframe-sanitizer-0NS4XLOd.js → iframe-sanitizer-y2Z1pPwY.js} +1 -1
- package/dist/public/index.html +1 -1
- package/dist/public/index.js +1 -1
- package/dist/public/{initChatSplitResize-llGkSJXg.js → initChatSplitResize-CzV2E7Ul.js} +1 -1
- package/dist/public/initControlPlane-C9jpnWev.js +1 -0
- package/dist/public/llms.txt +1 -1
- package/dist/public/main/index.html +1 -1
- package/dist/public/main/memory/index.html +1 -1
- package/dist/public/{markdown-CyYR4App.js → markdown-BnpKxSxl.js} +1 -1
- package/dist/public/{mcp-reconnect-CSx4aMwy.js → mcp-reconnect-9emsqGRe.js} +1 -1
- package/dist/public/{memoryStorage-Dwg8NhAZ.js → memoryStorage-C0KvLNUp.js} +1 -1
- package/dist/public/{orchestrator-DRfEudXk.js → orchestrator-3h9xxHUm.js} +676 -676
- package/dist/public/orchestrator-nJj59RqD.js +15 -0
- package/dist/public/{peerjs-CurBuKvk.js → peerjs-BP4laMXj.js} +1 -1
- package/dist/public/{push-client-Dii-vPEh.js → push-client-CrjEXK3U.js} +1 -1
- package/dist/public/service-worker/push-handler.js +1 -1
- package/dist/public/service-worker.js +1 -1
- package/dist/public/{shadow-claw-5IHaDDMJ.js → shadow-claw-CbwETBWf.js} +2 -2
- package/dist/public/{shadow-claw-accounts-CZvz4iQz.js → shadow-claw-accounts-B4sBTQEj.js} +1 -1
- package/dist/public/{shadow-claw-channels-BKXFyRS3.js → shadow-claw-channels-BDWG5Qa3.js} +1 -1
- package/dist/public/{shadow-claw-chat-CCLuhWdI.js → shadow-claw-chat-Crv0DTCY.js} +6 -6
- package/dist/public/shadow-claw-control-plane-CX1IGbh9.js +199 -0
- package/dist/public/{shadow-claw-conversations-DV-87UUh.js → shadow-claw-conversations-_9qAaRXk.js} +1 -1
- package/dist/public/shadow-claw-dialog-BrOwAOdk.js +1 -0
- package/dist/public/{shadow-claw-file-viewer-Dk2dbAUd.js → shadow-claw-file-viewer-Blf6yGVD.js} +1 -1
- package/dist/public/shadow-claw-files-CYySBDCl.js +840 -0
- package/dist/public/{shadow-claw-git-DRA7_qck.js → shadow-claw-git-v8S0JjuR.js} +2 -2
- package/dist/public/{shadow-claw-integrations-1Xu5snuV.js → shadow-claw-integrations-D7ufpwhX.js} +1 -1
- package/dist/public/{shadow-claw-llm-6Aci1BDP.js → shadow-claw-llm-GWgoVfhI.js} +2 -2
- package/dist/public/{shadow-claw-mcp-remote-BUjAeVXC.js → shadow-claw-mcp-remote-kY4LMFNN.js} +1 -1
- package/dist/public/{shadow-claw-networking-FQe4nCp3.js → shadow-claw-networking-qHbP95z9.js} +1 -1
- package/dist/public/{shadow-claw-notifications-DV2wibL3.js → shadow-claw-notifications-YyHOK2Fr.js} +1 -1
- package/dist/public/{shadow-claw-page-header-B63S4HTU.js → shadow-claw-page-header-DMKbkv3s.js} +1 -1
- package/dist/public/{shadow-claw-pages-DE3jWj5K.js → shadow-claw-pages-DFZHhzFZ.js} +1 -1
- package/dist/public/{shadow-claw-settings-S6DAKfYx.js → shadow-claw-settings-DhxrKIfA.js} +10 -3
- package/dist/public/{shadow-claw-storage-DaacA3_K.js → shadow-claw-storage-BFynbP0j.js} +2 -2
- package/dist/public/{shadow-claw-task-server-IjKX042p.js → shadow-claw-task-server-3BIeb5oZ.js} +25 -4
- package/dist/public/{shadow-claw-tasks-Cy0JYmGU.js → shadow-claw-tasks-Caxc9atL.js} +1 -1
- package/dist/public/{shadow-claw-terminal-znAt7HyP.js → shadow-claw-terminal-Beb5qF-U.js} +1 -1
- package/dist/public/{shadow-claw-tools-Cutv9Si5.js → shadow-claw-tools-BfJx3A9W.js} +1 -1
- package/dist/public/{shadow-claw-webvm-BH8mPDEu.js → shadow-claw-webvm-BCS8ykeP.js} +1 -1
- package/dist/public/{syncWebMcpRegistration-BqJxaMGR.js → syncWebMcpRegistration-B_M2fCjH.js} +1 -1
- package/dist/server.js +286 -189
- package/package.json +2 -1
- package/src/__mocks__/jszip.cjs +15 -5
- package/src/components/settings/shadow-claw-accounts/shadow-claw-accounts.test.ts +35 -0
- package/src/components/settings/shadow-claw-control-plane/shadow-claw-control-plane.css +117 -0
- package/src/components/settings/shadow-claw-control-plane/shadow-claw-control-plane.html +81 -0
- package/src/components/settings/shadow-claw-control-plane/shadow-claw-control-plane.test.ts +127 -0
- package/src/components/settings/shadow-claw-control-plane/shadow-claw-control-plane.ts +292 -0
- package/src/components/settings/shadow-claw-git/shadow-claw-git.test.ts +72 -0
- package/src/components/settings/shadow-claw-integrations/connection-test-auth.test.ts +20 -30
- package/src/components/settings/shadow-claw-integrations/shadow-claw-integrations.test.ts +116 -0
- package/src/components/settings/shadow-claw-llm/model-ranking.test.ts +143 -51
- package/src/components/settings/shadow-claw-llm/shadow-claw-llm.test.ts +307 -4
- package/src/components/settings/shadow-claw-llm/shadow-claw-llm.ts +8 -8
- package/src/components/settings/shadow-claw-mcp-remote/shadow-claw-mcp-remote.test.ts +31 -0
- package/src/components/settings/shadow-claw-peerjs/shadow-claw-peerjs.test.ts +186 -0
- package/src/components/settings/shadow-claw-storage/shadow-claw-storage.test.ts +76 -0
- package/src/components/settings/shadow-claw-task-server/shadow-claw-task-server.css +23 -2
- package/src/components/settings/shadow-claw-task-server/shadow-claw-task-server.html +1 -1
- package/src/components/settings/shadow-claw-task-server/shadow-claw-task-server.test.ts +19 -0
- package/src/components/settings/shadow-claw-task-server/shadow-claw-task-server.ts +2 -1
- package/src/components/shadow-claw/utils/initChatSplitResize.test.ts +180 -13
- package/src/components/shadow-claw/utils/setupEffects.test.ts +39 -0
- package/src/components/shadow-claw-a2ui/catalog/basic/shared.test.ts +117 -0
- package/src/components/shadow-claw-a2ui/shadow-claw-a2ui.test.ts +1159 -1
- package/src/components/shadow-claw-chat/shadow-claw-chat.test.ts +1523 -19
- package/src/components/shadow-claw-chat/utils/escapeHtml.test.ts +13 -0
- package/src/components/shadow-claw-chat/utils/getPeerChatDisplayStatus.test.ts +20 -0
- package/src/components/shadow-claw-conversations/shadow-claw-conversations.test.ts +494 -0
- package/src/components/shadow-claw-dialog/shadow-claw-dialog.ts +13 -2
- package/src/components/shadow-claw-file-viewer/shadow-claw-file-viewer.test.ts +273 -0
- package/src/components/shadow-claw-files/shadow-claw-files.test.ts +408 -1
- package/src/components/shadow-claw-pdf-viewer/utils/installGetOrInsertComputedPolyfill.test.ts +65 -0
- package/src/components/shadow-claw-settings/shadow-claw-settings.html +7 -0
- package/src/components/shadow-claw-settings/shadow-claw-settings.test.ts +221 -0
- package/src/components/shadow-claw-settings/shadow-claw-settings.ts +2 -0
- package/src/components/shadow-claw-tasks/shadow-claw-tasks.test.ts +407 -0
- package/src/components/shadow-claw-terminal/utils/consumeEscapeSequence.test.ts +58 -0
- package/src/components/shadow-claw-tools/shadow-claw-tools.test.ts +80 -0
- package/src/config/config.ts +10 -0
- package/src/core/backup-controller.test.ts +101 -0
- package/src/core/backup-controller.ts +137 -0
- package/src/core/control-plane-client.test.ts +408 -0
- package/src/core/control-plane-client.ts +425 -0
- package/src/core/orchestrator/orchestrator.ts +4 -0
- package/src/core/orchestrator/utils/compactContext.test.ts +78 -0
- package/src/core/orchestrator/utils/operations/channel.test.ts +254 -9
- package/src/core/orchestrator/utils/operations/provider.test.ts +326 -34
- package/src/core/orchestrator/utils/operations/vm.test.ts +114 -2
- package/src/core/orchestrator/utils/syncProxyConfigToServiceWorker.test.ts +60 -0
- package/src/core/utils/initControlPlane.test.ts +276 -0
- package/src/core/utils/initControlPlane.ts +437 -0
- package/src/core/utils/initializeApp.ts +18 -0
- package/src/db/getSession.test.ts +13 -1
- package/src/server/app.test.ts +12 -0
- package/src/server/app.ts +18 -8
- package/src/server/client-registry.test.ts +250 -0
- package/src/server/client-registry.ts +477 -0
- package/src/server/config.ts +15 -0
- package/src/server/control-plane-types.ts +120 -0
- package/src/server/control-plane.test.ts +472 -0
- package/src/server/control-plane.ts +581 -0
- package/src/server/routes/backup.test.ts +263 -0
- package/src/server/routes/backup.ts +262 -0
- package/src/server/routes/integrations-email.test.ts +532 -0
- package/src/server/routes/llamafile.test.ts +172 -48
- package/src/server/routes/mesh-llm.test.ts +192 -0
- package/src/server/routes/ollama.test.ts +49 -0
- package/src/server/server-peer.test.ts +86 -0
- package/src/server/server-peer.ts +330 -0
- package/src/server/server.ts +35 -0
- package/src/server/services/llamafile-manager.test.ts +230 -6
- package/src/server/services/transformers-runtime.test.ts +186 -18
- package/src/server/webrtc.test.ts +21 -0
- package/src/server/webrtc.ts +72 -0
- package/src/service-worker/fetch-proxy.test.ts +64 -1
- package/src/service-worker/push-handler.ts +39 -0
- package/src/shell/vm.test.ts +744 -12
- package/src/storage/ensureMainGroupIndex.test.ts +153 -0
- package/src/storage/getGroupFile.test.ts +66 -0
- package/src/storage/memoryStorage.test.ts +82 -2
- package/src/storage/writeGroupFileBytes.test.ts +143 -0
- package/src/stores/chat-ui.test.ts +20 -0
- package/src/stores/orchestrator.test.ts +134 -0
- package/src/stores/toast.test.ts +50 -0
- package/src/stores/tools.test.ts +147 -10
- package/src/subsystems/channels/imessage.test.ts +59 -0
- package/src/subsystems/channels/peerjs.test.ts +500 -62
- package/src/subsystems/channels/peerjs.ts +71 -4
- package/src/subsystems/channels/telegram.test.ts +177 -0
- package/src/subsystems/email/catalog.test.ts +1 -0
- package/src/subsystems/email/connections.test.ts +39 -1
- package/src/subsystems/git/credentials.test.ts +160 -825
- package/src/subsystems/git/git.test.ts +463 -0
- package/src/subsystems/notifications/__mocks__/node-sqlite.cjs +12 -1
- package/src/subsystems/notifications/push-routes.test.ts +33 -0
- package/src/subsystems/notifications/push-routes.ts +23 -0
- package/src/subsystems/notifications/push-store.ts +1 -1
- package/src/subsystems/providers/builtin-ai-tasks.test.ts +74 -0
- package/src/subsystems/providers/litert-lm-provider.test.ts +212 -51
- package/src/subsystems/providers/model-registry.test.ts +115 -0
- package/src/subsystems/providers/providers.test.ts +94 -1
- package/src/subsystems/providers/transformers-js-provider.test.ts +279 -0
- package/src/subsystems/providers/utils/createModelCacheFetch.test.ts +2 -2
- package/src/subsystems/providers/utils/downloadModelToCache.test.ts +2 -2
- package/src/subsystems/providers/utils/loadModelStream.test.ts +2 -2
- package/src/subsystems/skills/activateSkill.test.ts +101 -0
- package/src/subsystems/skills/discoverSkills.test.ts +251 -0
- package/src/subsystems/tools/cron.test.ts +64 -0
- package/src/subsystems/tools/declarative.test.ts +255 -89
- package/src/testing/assets/v86.9pfs/libv86.mjs +63 -0
- package/src/testing/assets/v86.ext2/libv86.mjs +3 -0
- package/src/testing/assets_missing_v86/assets/v86.9pfs/libv86.mjs +1 -0
- package/src/testing/jest-setup.ts +328 -40
- package/src/testing/mock-v86.mjs +49 -0
- package/src/ui/a2ui/types.ts +4 -3
- package/src/ui/a2ui/utils/normaliseComponentsToMap.test.ts +102 -0
- package/src/ui/a2ui/utils/resolveChildIds.test.ts +63 -0
- package/src/ui/a2ui/utils/resolveDynamicNumber.test.ts +13 -1
- package/src/worker/tools/bash/utils/waitForVMReady.test.ts +40 -0
- package/src/worker/tools/email/email.test.ts +193 -8
- package/src/worker/tools/email/utils/asEmailAttachmentInputs.test.ts +47 -0
- package/src/worker/tools/git/git.test.ts +214 -3
- package/src/worker/tools/rooms/invite-to-room.test.ts +54 -0
- package/src/worker/tools/rooms/leave-room.test.ts +40 -0
- package/src/worker/tools/rooms/list-room-members.test.ts +75 -0
- package/src/worker/tools/tasks/tasks-utils.test.ts +22 -0
- package/src/worker/tools/ui/ask-user.test.ts +50 -0
- package/src/worker/tools/ui/clear-chat.test.ts +19 -0
- package/src/worker/tools/ui/get-current-time.test.ts +19 -0
- package/src/worker/tools/ui/javascript.test.ts +116 -0
- package/src/worker/tools/ui/list-components.test.ts +10 -0
- package/src/worker/tools/ui/list-tool-profiles.test.ts +42 -0
- package/src/worker/tools/ui/manage-tools.test.ts +34 -0
- package/src/worker/tools/ui/render-component.test.ts +346 -0
- package/src/worker/tools/ui/send-notification.test.ts +40 -0
- package/src/worker/tools/ui/utils/getAllowFullInternetAccess.test.ts +31 -0
- package/src/worker/tools/ui/utils/parseBooleanConfig.test.ts +25 -0
- package/src/worker/tools/workspace/attach-file.test.ts +84 -0
- package/src/worker/tools/workspace/copy-file.test.ts +69 -0
- package/src/worker/tools/workspace/create-directory.test.ts +40 -0
- package/src/worker/tools/workspace/delete-file.test.ts +73 -0
- package/src/worker/tools/workspace/diff-files.test.ts +94 -0
- package/src/worker/tools/workspace/list-files.test.ts +36 -0
- package/src/worker/tools/workspace/move-file.test.ts +66 -0
- package/src/worker/tools/workspace/open-file.test.ts +57 -0
- package/src/worker/tools/workspace/patch-file.test.ts +81 -0
- package/src/worker/tools/workspace/read-file.test.ts +116 -0
- package/src/worker/tools/workspace/send-file.test.ts +82 -0
- package/src/worker/tools/workspace/update-memory.test.ts +29 -0
- package/src/worker/tools/workspace/write-file.test.ts +28 -0
- package/src/worker/utils/rate-limit.test.ts +199 -0
- package/src/worker/utils/tool-state.test.ts +29 -0
- package/src/worker/utils/transformers-js-utils.test.ts +59 -0
- package/dist/public/config-BYAuxx3j.js +0 -1
- package/dist/public/downloadGroupFile-Drdvg1Ev.js +0 -1
- package/dist/public/file-viewer-CcZYw-PS.js +0 -1
- package/dist/public/orchestrator-o9Fj67BN.js +0 -15
- package/dist/public/shadow-claw-dialog-ByyHgxM9.js +0 -1
- package/dist/public/shadow-claw-files-BpfpJIuP.js +0 -840
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as e,r as t}from"./config-
|
|
1
|
+
import{b as e,r as t}from"./config-CrHchneq.js";import{n}from"./txPromise-EBECky1b.js";import{t as r}from"./getConfig-D89uJgo5.js";import{m as i,u as a}from"./custom-element-security-NCqQ5lmC.js";import{t as o}from"./orchestrator-3h9xxHUm.js";import{f as s,h as c}from"./mcp-reconnect-9emsqGRe.js";import{r as l,t as u}from"./toast-D3gxhZpN.js";import{t as d}from"./shadow-claw-element-DIrv3P6A.js";import"./shadow-claw-card-DCxWEHgX.js";import"./shadow-claw-empty-state-obMInUIf.js";const f=new CSSStyleSheet;f.replaceSync(`*,
|
|
2
2
|
*::before,
|
|
3
3
|
*::after {
|
|
4
4
|
font-family: var(--shadow-claw-font-sans);
|
|
@@ -444,4 +444,4 @@ import{b as e,r as t}from"./config-BYAuxx3j.js";import{n}from"./txPromise-EBECky
|
|
|
444
444
|
</button>
|
|
445
445
|
<button class="cancel-btn" data-action="cancel-account-form">Cancel</button>
|
|
446
446
|
</div>
|
|
447
|
-
</div>`),p.querySelector(`[data-action="save-account"]`)?.addEventListener(`click`,()=>this.saveAccountForm()),p.querySelector(`[data-action="cancel-account-form"]`)?.addEventListener(`click`,()=>this.hideAccountForm()),p.querySelector(`[data-field="acct-auth-mode"]`)?.addEventListener(`change`,()=>this.updateAuthModeVisibility(p)),p.querySelector(`[data-action="connect-oauth"]`)?.addEventListener(`click`,()=>void this.connectOAuthFromForm(p)),this.updateAuthModeVisibility(p))}updateAuthModeVisibility(e){let t=e.querySelector(`[data-field="acct-auth-mode"]`)?.value===`oauth`,n=e.querySelector(`[data-region="oauth-fields"]`),r=e.querySelector(`[data-region="pat-fields"]`);n instanceof HTMLElement&&(n.style.display=t?`block`:`none`),r instanceof HTMLElement&&(r.style.display=t?`none`:`block`)}updateCustomProxyVisibility(){let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="git-proxy-custom"]`),n=e.querySelector(`[data-region="git-custom-proxy-field"]`);n instanceof HTMLElement&&(n.style.display=t?.checked?`block`:`none`)}async connectOAuthFromForm(e){let t=e.querySelector(`[data-field="acct-oauth-provider"]`)?.value,n=e.querySelector(`[data-field="acct-oauth-client-id"]`)?.value.trim(),r=e.querySelector(`[data-field="acct-oauth-client-secret"]`)?.value.trim(),i=e.querySelector(`[data-field="acct-oauth-scope"]`)?.value.trim();if(!t){u(`OAuth provider is required.`,4e3);return}if(!n){u(`OAuth client ID is required.`,4e3);return}let a=e.querySelector(`[data-region="oauth-status"]`),o=e.querySelector(`[data-action="connect-oauth"]`);a&&(a.textContent=`Starting OAuth...`),o&&(o.disabled=!0);try{let e=i?i.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean):void 0,o=await fetch(`/oauth/authorize`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({providerId:t,clientId:n,clientSecret:r||void 0,redirectUri:`${window.location.origin}/oauth/callback`,scope:e})}),s=await o.json();if(!o.ok||!s.state||!s.authorizeUrl)throw Error(s.error||`OAuth authorize failed`);window.open(s.authorizeUrl,`shadowclaw-oauth`,`popup=yes,width=540,height=720`);let c=s.state,u=`pending`;for(let e=0;e<60;e++){let e=await fetch(`/oauth/session/${encodeURIComponent(c)}`),t=await e.json();if(!e.ok)throw Error(t.error||`OAuth session not found`);if(u=t.status||`pending`,u===`authorized`)break;if(u===`error`)throw Error(t.error||`OAuth authorization failed`);await new Promise(e=>setTimeout(e,1e3))}if(u!==`authorized`)throw Error(`OAuth authorization timed out`);let d=await fetch(`/oauth/token`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({state:c})}),f=await d.json();if(!d.ok||!f.accessToken)throw Error(f.error||`OAuth token exchange failed`);this.pendingOauthResult={providerId:t,accessToken:f.accessToken,refreshToken:f.refreshToken,expiresAt:f.expiresIn?Date.now()+f.expiresIn*1e3:void 0,scope:f.scope,tokenType:f.tokenType},a&&(a.textContent=`OAuth connected`),l(`OAuth connected`,3e3)}catch(e){let t=e instanceof Error?e.message:String(e);a&&(a.textContent=`OAuth failed`),u(`OAuth connect failed: ${t}`,6e3)}finally{o&&(o.disabled=!1)}}async deleteAccount(e){if(this.db){this.accounts=this.accounts.filter(t=>t.id!==e),this.defaultAccountId===e&&(this.defaultAccountId=this.accounts[0]?.id||``);try{let{setConfig:e}=await import(`./setConfig-DFMYnYLE.js`).then(e=>e.n);await e(this.db,t.GIT_ACCOUNTS,this.accounts),await e(this.db,t.GIT_DEFAULT_ACCOUNT,this.defaultAccountId)}catch(e){console.warn(`Error persisting account deletion:`,e)}this.renderAccountList(),this.updateGitWarning(),l(`Account deleted`,3e3)}}async migrateLegacyAccount(){if(!this.db)return;let e=await r(this.db,t.GIT_TOKEN),n=await r(this.db,t.GIT_USERNAME);if(!e&&!n)return;let i=await r(this.db,t.GIT_PASSWORD)||``,a={id:`legacy-migrated`,label:`GitHub`,hostPattern:`github.com`,token:e||``,username:n||``,password:i,authorName:``,authorEmail:``};this.accounts=[a],this.defaultAccountId=a.id;let{setConfig:o}=await import(`./setConfig-DFMYnYLE.js`).then(e=>e.n);await o(this.db,t.GIT_ACCOUNTS,this.accounts),await o(this.db,t.GIT_DEFAULT_ACCOUNT,a.id)}async render(){let e=this.shadowRoot;if(e)try{let n=await r(this.db,t.GIT_CORS_PROXY)||`local`,i=e.querySelector(`[data-setting="git-proxy-local"]`),a=e.querySelector(`[data-setting="git-proxy-public"]`),s=e.querySelector(`[data-setting="git-proxy-custom"]`),c=e.querySelector(`[data-setting="git-proxy-url-input"]`);i&&a&&s&&(i.checked=n===`local`,a.checked=n===`public`,s.checked=n===`custom`),c&&(c.value=o.gitProxyUrl||`/git-proxy`),this.updateCustomProxyVisibility();let l=e.querySelector(`[data-setting="git-author-name-input"]`);l&&(l.value=await r(this.db,t.GIT_AUTHOR_NAME)||`ShadowClaw`);let u=e.querySelector(`[data-setting="git-author-email-input"]`);u&&(u.value=await r(this.db,t.GIT_AUTHOR_EMAIL)||`agent@example.com`);let d=await r(this.db,t.GIT_ACCOUNTS);this.accounts=Array.isArray(d)?d:[],this.defaultAccountId=await r(this.db,t.GIT_DEFAULT_ACCOUNT)||``,this.accounts.length===0&&await this.migrateLegacyAccount(),this.renderAccountList(),this.updateGitWarning()}catch(e){console.warn(`Could not load git settings:`,e)}}async saveAccountForm(){if(!this.db)return;let e=this.shadowRoot;if(!e)return;let n=e.querySelector(`[data-region="account-form-slot"]`);if(!n)return;let r=n.querySelector(`[data-field="acct-label"]`)?.value.trim(),i=n.querySelector(`[data-field="acct-host"]`)?.value.trim(),a=n.querySelector(`[data-field="acct-auth-mode"]`)?.value;if(!r||!i){u(`Label and Host Pattern are required.`,4e3);return}try{let{encryptValue:e}=await import(`./crypto-C8c5wMzN.js`).then(e=>e.t),{setConfig:o}=await import(`./setConfig-DFMYnYLE.js`).then(e=>e.n),s=n.querySelector(`[data-field="acct-token"]`)?.value.trim(),c=n.querySelector(`[data-field="acct-password"]`)?.value.trim(),d=n.querySelector(`[data-field="acct-username"]`)?.value.trim()||``,f=n.querySelector(`[data-field="acct-author-name"]`)?.value.trim()||``,p=n.querySelector(`[data-field="acct-author-email"]`)?.value.trim()||``,m=this.editingAccountId===`new`,h=m?null:this.accounts.find(e=>e.id===this.editingAccountId),g=h?.token||``,_=h?.password||``,v=h?.oauthProviderId,y=h?.oauthClientId,b=h?.oauthClientSecret,x=h?.accessTokenExpiresAt,S=h?.refreshToken,C=h?.scopes,w=h?.tokenType,T=h?.oauthRefreshFailureCount,E=h?.oauthReauthRequired,D=h?.oauthReauthRequiredAt;if(a===`oauth`){v=n.querySelector(`[data-field="acct-oauth-provider"]`)?.value,y=n.querySelector(`[data-field="acct-oauth-client-id"]`)?.value.trim();let t=n.querySelector(`[data-field="acct-oauth-client-secret"]`)?.value.trim(),r=n.querySelector(`[data-field="acct-oauth-scope"]`)?.value.trim(),i=r?r.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean):void 0;if(!v){u(`OAuth provider is required for OAuth mode.`,4e3);return}if(!y){u(`OAuth client ID is required for OAuth mode.`,4e3);return}if(t){let n=await e(t);n&&(b=n)}if(this.pendingOauthResult?.accessToken){let t=await e(this.pendingOauthResult.accessToken);if(t&&(g=t),this.pendingOauthResult.refreshToken){let t=await e(this.pendingOauthResult.refreshToken);t&&(S=t)}x=this.pendingOauthResult.expiresAt,C=this.pendingOauthResult.scope?this.pendingOauthResult.scope.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean):i||C,w=this.pendingOauthResult.tokenType,T=0,E=!1,D=void 0}else C=i||C;if(!g){u(`Connect OAuth first to obtain an access token for this account.`,5e3);return}_=``}else{if(s){let t=await e(s);t&&(g=t)}if(c){let t=await e(c);t&&(_=t)}v=void 0,y=void 0,b=void 0,x=void 0,S=void 0,C=void 0,w=void 0,T=void 0,E=void 0,D=void 0}if(m){let{ulid:e}=await import(`./ulid-BY7rQVLN.js`).then(e=>e.n),n={id:e(),label:r,hostPattern:i,token:g,username:a===`oauth`?``:d,password:_,authorName:f,authorEmail:p,authMode:a||`token`,oauthProviderId:v,oauthClientId:y,oauthClientSecret:b,accessTokenExpiresAt:x,refreshToken:S,scopes:C,tokenType:w,oauthRefreshFailureCount:T,oauthReauthRequired:E,oauthReauthRequiredAt:D};this.accounts.push(n),this.accounts.length===1&&(this.defaultAccountId=n.id,await o(this.db,t.GIT_DEFAULT_ACCOUNT,n.id))}else h&&(h.label=r,h.hostPattern=i,h.token=g,h.username=a===`oauth`?``:d,h.password=_,h.authorName=f,h.authorEmail=p,h.authMode=a||`token`,h.oauthProviderId=v,h.oauthClientId=y,h.oauthClientSecret=b,h.accessTokenExpiresAt=x,h.refreshToken=S,h.scopes=C,h.tokenType=w,h.oauthRefreshFailureCount=T,h.oauthReauthRequired=E,h.oauthReauthRequiredAt=D);await o(this.db,t.GIT_ACCOUNTS,this.accounts),this.hideAccountForm(),this.renderAccountList(),this.updateGitWarning(),l(m?`Account added`:`Account updated`,3e3)}catch(e){u(`Error saving account: `+(e instanceof Error?e.message:String(e)),6e3)}}async saveGitSettings(){if(!this.db)return;let e=this.shadowRoot;if(e)try{let{setConfig:n}=await import(`./setConfig-DFMYnYLE.js`).then(e=>e.n),r=e.querySelector(`[data-setting="git-proxy-public"]`),i=e.querySelector(`[data-setting="git-proxy-custom"]`),a=r?.checked?`public`:i?.checked?`custom`:`local`;if(await n(this.db,t.GIT_CORS_PROXY,a),a===`custom`){let t=e.querySelector(`[data-setting="git-proxy-url-input"]`)?.value.trim()||`/git-proxy`,{orchestratorStore:n}=await import(`./orchestrator-DRfEudXk.js`).then(e=>e.n);await n.setGitProxyUrl(this.db,t)}let o=e.querySelector(`[data-setting="git-author-name-input"]`);o&&await n(this.db,t.GIT_AUTHOR_NAME,o.value.trim()||`ShadowClaw`);let s=e.querySelector(`[data-setting="git-author-email-input"]`);s&&await n(this.db,t.GIT_AUTHOR_EMAIL,s.value.trim()||`agent@example.com`),l(`Git settings saved`,3e3),this.updateGitWarning()}catch(e){u(`Error saving Git settings: `+(e instanceof Error?e.message:String(e)),6e3)}}async setDefaultAccount(e){if(this.db){this.defaultAccountId=e;try{let{setConfig:n}=await import(`./setConfig-DFMYnYLE.js`).then(e=>e.n);await n(this.db,t.GIT_DEFAULT_ACCOUNT,e)}catch(e){console.warn(`Error setting default account:`,e)}this.renderAccountList(),l(`Default account updated`,3e3)}}async updateGitWarning(){let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="git-proxy-warning"]`);if(!t)return;let n=e.querySelector(`[data-setting="git-proxy-public"]`),r=this.accounts.some(e=>!!e.token);t.style.display=n?.checked&&r?`block`:`none`}};customElements.get(_)||customElements.define(_,x);export{x as ShadowClawGit};
|
|
447
|
+
</div>`),p.querySelector(`[data-action="save-account"]`)?.addEventListener(`click`,()=>this.saveAccountForm()),p.querySelector(`[data-action="cancel-account-form"]`)?.addEventListener(`click`,()=>this.hideAccountForm()),p.querySelector(`[data-field="acct-auth-mode"]`)?.addEventListener(`change`,()=>this.updateAuthModeVisibility(p)),p.querySelector(`[data-action="connect-oauth"]`)?.addEventListener(`click`,()=>void this.connectOAuthFromForm(p)),this.updateAuthModeVisibility(p))}updateAuthModeVisibility(e){let t=e.querySelector(`[data-field="acct-auth-mode"]`)?.value===`oauth`,n=e.querySelector(`[data-region="oauth-fields"]`),r=e.querySelector(`[data-region="pat-fields"]`);n instanceof HTMLElement&&(n.style.display=t?`block`:`none`),r instanceof HTMLElement&&(r.style.display=t?`none`:`block`)}updateCustomProxyVisibility(){let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="git-proxy-custom"]`),n=e.querySelector(`[data-region="git-custom-proxy-field"]`);n instanceof HTMLElement&&(n.style.display=t?.checked?`block`:`none`)}async connectOAuthFromForm(e){let t=e.querySelector(`[data-field="acct-oauth-provider"]`)?.value,n=e.querySelector(`[data-field="acct-oauth-client-id"]`)?.value.trim(),r=e.querySelector(`[data-field="acct-oauth-client-secret"]`)?.value.trim(),i=e.querySelector(`[data-field="acct-oauth-scope"]`)?.value.trim();if(!t){u(`OAuth provider is required.`,4e3);return}if(!n){u(`OAuth client ID is required.`,4e3);return}let a=e.querySelector(`[data-region="oauth-status"]`),o=e.querySelector(`[data-action="connect-oauth"]`);a&&(a.textContent=`Starting OAuth...`),o&&(o.disabled=!0);try{let e=i?i.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean):void 0,o=await fetch(`/oauth/authorize`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({providerId:t,clientId:n,clientSecret:r||void 0,redirectUri:`${window.location.origin}/oauth/callback`,scope:e})}),s=await o.json();if(!o.ok||!s.state||!s.authorizeUrl)throw Error(s.error||`OAuth authorize failed`);window.open(s.authorizeUrl,`shadowclaw-oauth`,`popup=yes,width=540,height=720`);let c=s.state,u=`pending`;for(let e=0;e<60;e++){let e=await fetch(`/oauth/session/${encodeURIComponent(c)}`),t=await e.json();if(!e.ok)throw Error(t.error||`OAuth session not found`);if(u=t.status||`pending`,u===`authorized`)break;if(u===`error`)throw Error(t.error||`OAuth authorization failed`);await new Promise(e=>setTimeout(e,1e3))}if(u!==`authorized`)throw Error(`OAuth authorization timed out`);let d=await fetch(`/oauth/token`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({state:c})}),f=await d.json();if(!d.ok||!f.accessToken)throw Error(f.error||`OAuth token exchange failed`);this.pendingOauthResult={providerId:t,accessToken:f.accessToken,refreshToken:f.refreshToken,expiresAt:f.expiresIn?Date.now()+f.expiresIn*1e3:void 0,scope:f.scope,tokenType:f.tokenType},a&&(a.textContent=`OAuth connected`),l(`OAuth connected`,3e3)}catch(e){let t=e instanceof Error?e.message:String(e);a&&(a.textContent=`OAuth failed`),u(`OAuth connect failed: ${t}`,6e3)}finally{o&&(o.disabled=!1)}}async deleteAccount(e){if(this.db){this.accounts=this.accounts.filter(t=>t.id!==e),this.defaultAccountId===e&&(this.defaultAccountId=this.accounts[0]?.id||``);try{let{setConfig:e}=await import(`./setConfig-DFMYnYLE.js`).then(e=>e.n);await e(this.db,t.GIT_ACCOUNTS,this.accounts),await e(this.db,t.GIT_DEFAULT_ACCOUNT,this.defaultAccountId)}catch(e){console.warn(`Error persisting account deletion:`,e)}this.renderAccountList(),this.updateGitWarning(),l(`Account deleted`,3e3)}}async migrateLegacyAccount(){if(!this.db)return;let e=await r(this.db,t.GIT_TOKEN),n=await r(this.db,t.GIT_USERNAME);if(!e&&!n)return;let i=await r(this.db,t.GIT_PASSWORD)||``,a={id:`legacy-migrated`,label:`GitHub`,hostPattern:`github.com`,token:e||``,username:n||``,password:i,authorName:``,authorEmail:``};this.accounts=[a],this.defaultAccountId=a.id;let{setConfig:o}=await import(`./setConfig-DFMYnYLE.js`).then(e=>e.n);await o(this.db,t.GIT_ACCOUNTS,this.accounts),await o(this.db,t.GIT_DEFAULT_ACCOUNT,a.id)}async render(){let e=this.shadowRoot;if(e)try{let n=await r(this.db,t.GIT_CORS_PROXY)||`local`,i=e.querySelector(`[data-setting="git-proxy-local"]`),a=e.querySelector(`[data-setting="git-proxy-public"]`),s=e.querySelector(`[data-setting="git-proxy-custom"]`),c=e.querySelector(`[data-setting="git-proxy-url-input"]`);i&&a&&s&&(i.checked=n===`local`,a.checked=n===`public`,s.checked=n===`custom`),c&&(c.value=o.gitProxyUrl||`/git-proxy`),this.updateCustomProxyVisibility();let l=e.querySelector(`[data-setting="git-author-name-input"]`);l&&(l.value=await r(this.db,t.GIT_AUTHOR_NAME)||`ShadowClaw`);let u=e.querySelector(`[data-setting="git-author-email-input"]`);u&&(u.value=await r(this.db,t.GIT_AUTHOR_EMAIL)||`agent@example.com`);let d=await r(this.db,t.GIT_ACCOUNTS);this.accounts=Array.isArray(d)?d:[],this.defaultAccountId=await r(this.db,t.GIT_DEFAULT_ACCOUNT)||``,this.accounts.length===0&&await this.migrateLegacyAccount(),this.renderAccountList(),this.updateGitWarning()}catch(e){console.warn(`Could not load git settings:`,e)}}async saveAccountForm(){if(!this.db)return;let e=this.shadowRoot;if(!e)return;let n=e.querySelector(`[data-region="account-form-slot"]`);if(!n)return;let r=n.querySelector(`[data-field="acct-label"]`)?.value.trim(),i=n.querySelector(`[data-field="acct-host"]`)?.value.trim(),a=n.querySelector(`[data-field="acct-auth-mode"]`)?.value;if(!r||!i){u(`Label and Host Pattern are required.`,4e3);return}try{let{encryptValue:e}=await import(`./crypto-C8c5wMzN.js`).then(e=>e.t),{setConfig:o}=await import(`./setConfig-DFMYnYLE.js`).then(e=>e.n),s=n.querySelector(`[data-field="acct-token"]`)?.value.trim(),c=n.querySelector(`[data-field="acct-password"]`)?.value.trim(),d=n.querySelector(`[data-field="acct-username"]`)?.value.trim()||``,f=n.querySelector(`[data-field="acct-author-name"]`)?.value.trim()||``,p=n.querySelector(`[data-field="acct-author-email"]`)?.value.trim()||``,m=this.editingAccountId===`new`,h=m?null:this.accounts.find(e=>e.id===this.editingAccountId),g=h?.token||``,_=h?.password||``,v=h?.oauthProviderId,y=h?.oauthClientId,b=h?.oauthClientSecret,x=h?.accessTokenExpiresAt,S=h?.refreshToken,C=h?.scopes,w=h?.tokenType,T=h?.oauthRefreshFailureCount,E=h?.oauthReauthRequired,D=h?.oauthReauthRequiredAt;if(a===`oauth`){v=n.querySelector(`[data-field="acct-oauth-provider"]`)?.value,y=n.querySelector(`[data-field="acct-oauth-client-id"]`)?.value.trim();let t=n.querySelector(`[data-field="acct-oauth-client-secret"]`)?.value.trim(),r=n.querySelector(`[data-field="acct-oauth-scope"]`)?.value.trim(),i=r?r.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean):void 0;if(!v){u(`OAuth provider is required for OAuth mode.`,4e3);return}if(!y){u(`OAuth client ID is required for OAuth mode.`,4e3);return}if(t){let n=await e(t);n&&(b=n)}if(this.pendingOauthResult?.accessToken){let t=await e(this.pendingOauthResult.accessToken);if(t&&(g=t),this.pendingOauthResult.refreshToken){let t=await e(this.pendingOauthResult.refreshToken);t&&(S=t)}x=this.pendingOauthResult.expiresAt,C=this.pendingOauthResult.scope?this.pendingOauthResult.scope.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean):i||C,w=this.pendingOauthResult.tokenType,T=0,E=!1,D=void 0}else C=i||C;if(!g){u(`Connect OAuth first to obtain an access token for this account.`,5e3);return}_=``}else{if(s){let t=await e(s);t&&(g=t)}if(c){let t=await e(c);t&&(_=t)}v=void 0,y=void 0,b=void 0,x=void 0,S=void 0,C=void 0,w=void 0,T=void 0,E=void 0,D=void 0}if(m){let{ulid:e}=await import(`./ulid-BY7rQVLN.js`).then(e=>e.n),n={id:e(),label:r,hostPattern:i,token:g,username:a===`oauth`?``:d,password:_,authorName:f,authorEmail:p,authMode:a||`token`,oauthProviderId:v,oauthClientId:y,oauthClientSecret:b,accessTokenExpiresAt:x,refreshToken:S,scopes:C,tokenType:w,oauthRefreshFailureCount:T,oauthReauthRequired:E,oauthReauthRequiredAt:D};this.accounts.push(n),this.accounts.length===1&&(this.defaultAccountId=n.id,await o(this.db,t.GIT_DEFAULT_ACCOUNT,n.id))}else h&&(h.label=r,h.hostPattern=i,h.token=g,h.username=a===`oauth`?``:d,h.password=_,h.authorName=f,h.authorEmail=p,h.authMode=a||`token`,h.oauthProviderId=v,h.oauthClientId=y,h.oauthClientSecret=b,h.accessTokenExpiresAt=x,h.refreshToken=S,h.scopes=C,h.tokenType=w,h.oauthRefreshFailureCount=T,h.oauthReauthRequired=E,h.oauthReauthRequiredAt=D);await o(this.db,t.GIT_ACCOUNTS,this.accounts),this.hideAccountForm(),this.renderAccountList(),this.updateGitWarning(),l(m?`Account added`:`Account updated`,3e3)}catch(e){u(`Error saving account: `+(e instanceof Error?e.message:String(e)),6e3)}}async saveGitSettings(){if(!this.db)return;let e=this.shadowRoot;if(e)try{let{setConfig:n}=await import(`./setConfig-DFMYnYLE.js`).then(e=>e.n),r=e.querySelector(`[data-setting="git-proxy-public"]`),i=e.querySelector(`[data-setting="git-proxy-custom"]`),a=r?.checked?`public`:i?.checked?`custom`:`local`;if(await n(this.db,t.GIT_CORS_PROXY,a),a===`custom`){let t=e.querySelector(`[data-setting="git-proxy-url-input"]`)?.value.trim()||`/git-proxy`,{orchestratorStore:n}=await import(`./orchestrator-3h9xxHUm.js`).then(e=>e.n);await n.setGitProxyUrl(this.db,t)}let o=e.querySelector(`[data-setting="git-author-name-input"]`);o&&await n(this.db,t.GIT_AUTHOR_NAME,o.value.trim()||`ShadowClaw`);let s=e.querySelector(`[data-setting="git-author-email-input"]`);s&&await n(this.db,t.GIT_AUTHOR_EMAIL,s.value.trim()||`agent@example.com`),l(`Git settings saved`,3e3),this.updateGitWarning()}catch(e){u(`Error saving Git settings: `+(e instanceof Error?e.message:String(e)),6e3)}}async setDefaultAccount(e){if(this.db){this.defaultAccountId=e;try{let{setConfig:n}=await import(`./setConfig-DFMYnYLE.js`).then(e=>e.n);await n(this.db,t.GIT_DEFAULT_ACCOUNT,e)}catch(e){console.warn(`Error setting default account:`,e)}this.renderAccountList(),l(`Default account updated`,3e3)}}async updateGitWarning(){let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="git-proxy-warning"]`);if(!t)return;let n=e.querySelector(`[data-setting="git-proxy-public"]`),r=this.accounts.some(e=>!!e.token);t.style.display=n?.checked&&r?`block`:`none`}};customElements.get(_)||customElements.define(_,x);export{x as ShadowClawGit};
|
package/dist/public/{shadow-claw-integrations-1Xu5snuV.js → shadow-claw-integrations-D7ufpwhX.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./config-
|
|
1
|
+
import{r as e}from"./config-CrHchneq.js";import{n as t}from"./txPromise-EBECky1b.js";import{t as n}from"./getConfig-D89uJgo5.js";import{u as r}from"./custom-element-security-NCqQ5lmC.js";import{t as i}from"./setConfig-DFMYnYLE.js";import{t as a}from"./ulid-BY7rQVLN.js";import{r as o}from"./crypto-C8c5wMzN.js";import{a as s,i as c,n as l,o as u,s as d,t as f}from"./connections-DvbgdkaB.js";import{r as p,t as m}from"./toast-D3gxhZpN.js";import{t as h}from"./shadow-claw-element-DIrv3P6A.js";function g(e){if(e.authMode===`oauth`){let t=(e.pendingOauthAccessToken||``).trim();return t?{authType:`oauth`,accessToken:t}:{error:`OAuth access token is missing. Click Connect OAuth first (or save and reconnect).`}}let t=(e.passwordInput||``).trim();return t?{authType:`basic_userpass`,password:t}:{error:`Password/app password is missing. Enter it to test this connection.`}}const _=new CSSStyleSheet;_.replaceSync(`*,
|
|
2
2
|
*::before,
|
|
3
3
|
*::after {
|
|
4
4
|
font-family: var(--shadow-claw-font-sans);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{P as e,R as t,c as n,r,u as i}from"./config-
|
|
1
|
+
import{P as e,R as t,c as n,r,u as i}from"./config-CrHchneq.js";import{n as a}from"./txPromise-EBECky1b.js";import{t as o}from"./getConfig-D89uJgo5.js";import{u as s}from"./custom-element-security-NCqQ5lmC.js";import{$ as c,J as l,K as u,Nt as d,Q as f,Ut as p,W as m,_ as h,ct as g,d as _,et as v,f as y,g as b,h as x,it as S,lt as C,p as w,q as T,t as E,tt as D,v as O}from"./orchestrator-3h9xxHUm.js";import{t as k}from"./setConfig-DFMYnYLE.js";import{a as A,r as j,t as M}from"./toast-D3gxhZpN.js";import{t as N}from"./shadow-claw-element-DIrv3P6A.js";import{t as P}from"./effect-BEsuusE8.js";import{n as F,r as I}from"./prompt-api-OUOP-B-R.js";import{n as L,t as R}from"./model-ranking-C60HgQ2c.js";const z=[{pattern:`gemma-3-1b-it-ONNX-GQA`,contextWindow:128e3},{pattern:`gemma-3-1b-it-ONNX`,contextWindow:128e3},{pattern:`Qwen3-0.6B-ONNX`,contextWindow:131072},{pattern:`Qwen3.5`,contextWindow:32768},{pattern:`Llama-3.2`,contextWindow:128e3},{pattern:`Phi-4`,contextWindow:128e3},{pattern:`Phi-3.5`,contextWindow:128e3},{pattern:`SmolLM`,contextWindow:8192},{pattern:`DeepSeek-R1`,contextWindow:128e3},{pattern:`LFM2`,contextWindow:32768},{pattern:`gpt-oss`,contextWindow:32768},{pattern:`gemma-4`,contextWindow:128e3},{pattern:`browser-built-in`,contextWindow:4096}];function B(e){let n=t.getModelInfo(e);if(n&&typeof n.contextWindow==`number`&&n.contextWindow>0)return n.contextWindow;for(let{pattern:t,contextWindow:n}of z)if(e.includes(t))return n;return null}function V(t,r,i){let a=r;t===`prompt_api`&&(r===`browser-built-in`||!r)&&(i?a=i:d()||(a=n));let o=e(a),s=typeof navigator>`u`?null:navigator,c=typeof s?.deviceMemory==`number`?s.deviceMemory:null,l=typeof s?.hardwareConcurrency==`number`?s.hardwareConcurrency:null;if(t===`prompt_api`||t===`transformers_js_browser`||t===`litert_lm_browser`||t===`ollama`){let e=B(a),t=o;c!==null&&(t=c>=32?Math.min(t,16384):c>=16?Math.min(t,8192):c>=8?Math.min(t,4096):Math.min(t,2048)),l!==null&&(l<=4?t=Math.min(t,2048):l>=16?t=Math.min(o,Math.max(t,8192)):l>=8&&(t=Math.min(o,Math.max(t,4096)))),/thinking|reasoning/i.test(a)&&(t=Math.min(t,4096)),t=Math.max(512,Math.min(t,o));let n=[];return e!==null&&n.push(`native context: ${e.toLocaleString()} tokens`),c!==null&&n.push(`${c} GB browser-reported memory`),l!==null&&n.push(`${l} CPU threads`),/thinking|reasoning/i.test(a)&&n.push(`reasoning model`),{recommended:t,detail:n.length>0?`Recommended for this device: ${t.toLocaleString()} tokens (${n.join(`, `)}). Model ceiling: ${o.toLocaleString()}.`:`Recommended for local inference: ${t.toLocaleString()} tokens. Model ceiling: ${o.toLocaleString()}.`}}return{recommended:o,detail:`Model-aware ceiling: ${o.toLocaleString()} tokens.`}}const H=new CSSStyleSheet;H.replaceSync(`*,
|
|
2
2
|
*::before,
|
|
3
3
|
*::after {
|
|
4
4
|
font-family: var(--shadow-claw-font-sans);
|
|
@@ -663,4 +663,4 @@ import{P as e,R as t,c as n,r,u as i}from"./config-BYAuxx3j.js";import{n as a}fr
|
|
|
663
663
|
</button>
|
|
664
664
|
</div>
|
|
665
665
|
</template>
|
|
666
|
-
`,`text/html`),W=U.querySelector(`template`);let G=[];G=W?Array.from(W.content.children):Array.from(U.head.children).concat(Array.from(U.body.children));var K=G;const q=`shadow-claw-llm`;var J=class extends N{static styles=H;static template=K;db;lastLlamafileHelpKey;llamafileDiscoveredModelIds;llamafileModelLoadError;modelFetchToken;orchestrator;constructor(){super(),this.db=null,this.orchestrator=null,this.llamafileDiscoveredModelIds=[],this.llamafileModelLoadError=null,this.lastLlamafileHelpKey=``,this.modelFetchToken=0}async connectedCallback(){if(!this.shadowRoot)throw Error(`shadowRoot not found`);this.db=await a(),this.orchestrator=E.orchestrator,this.bindEventListeners(),this.setupEffects()}applyRecommendedMaxTokens(){if(!this.orchestrator)return;let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="max-tokens-input"]`);if(!t)return;let n=this.orchestrator.provider,r=this.orchestrator.model,i;n===`prompt_api`&&(i=e.querySelector(`[data-setting="prompt-api-fallback-select"]`)?.value||`onnx-community/Qwen3-0.6B-ONNX`);let a=V(n,r,i);t.value=String(a.recommended)}bindEventListeners(){let e=this.shadowRoot;e&&(e.querySelector(`[data-setting="provider-select"]`)?.addEventListener(`change`,()=>this.onProviderChange()),e.querySelector(`[data-setting="prompt-api-fallback-select"]`)?.addEventListener(`change`,e=>{let t=e.target;t?.value&&p(t.value).then(()=>this.updateMaxTokensUI()).catch(()=>{}),this.updateMaxTokensUI()}),e.querySelector(`[data-action="save-llm-provider"]`)?.addEventListener(`click`,()=>this.saveApiKey()),e.querySelector(`[data-action="save-model"]`)?.addEventListener(`click`,()=>this.saveModel()),e.querySelector(`[data-action="refresh-models"]`)?.addEventListener(`click`,()=>this.updateModelSelector()),e.querySelector(`[data-setting="model-select"]`)?.addEventListener(`change`,t=>{let n=e.querySelector(`[data-setting="custom-model-input"]`),r=t.target;n&&r&&(n.style.display=r.value===`__custom__`?`block`:`none`)}),e.querySelector(`[data-setting="streaming-toggle"]`)?.addEventListener(`change`,e=>{e.target instanceof HTMLInputElement&&this.onStreamingToggle(e.target.checked)}),e.querySelector(`[data-setting="context-compression-toggle"]`)?.addEventListener(`change`,e=>{e.target instanceof HTMLInputElement&&this.onContextCompressionToggle(e.target.checked)}),e.querySelector(`[data-action="save-max-iterations"]`)?.addEventListener(`click`,()=>this.saveMaxIterations()),e.querySelector(`[data-action="save-subagent-max-parallel"]`)?.addEventListener(`click`,()=>this.saveSubagentMaxParallel()),e.querySelector(`[data-action="save-subagent-workspace-mode"]`)?.addEventListener(`click`,()=>this.saveSubagentWorkspaceMode()),e.querySelector(`[data-action="save-rate-limit-settings"]`)?.addEventListener(`click`,()=>this.saveRateLimitSettings()),e.querySelector(`[data-action="save-max-tokens"]`)?.addEventListener(`click`,()=>this.saveMaxTokens()),e.querySelector(`[data-action="save-reasoning-effort"]`)?.addEventListener(`click`,()=>this.saveReasoningEffort()),e.querySelector(`[data-action="apply-recommended-max-tokens"]`)?.addEventListener(`click`,()=>this.applyRecommendedMaxTokens()),e.querySelector(`[data-action="save-llamafile-settings"]`)?.addEventListener(`click`,()=>this.saveLlamafileSettings()),e.querySelector(`[data-action="save-bedrock-settings"]`)?.addEventListener(`click`,()=>this.saveBedrockSettings()),e.querySelector(`[data-action="save-mesh-llm-settings"]`)?.addEventListener(`click`,()=>this.saveMeshLlmSettings()),e.querySelector(`[data-action="save-transformers-js-settings"]`)?.addEventListener(`click`,()=>this.saveTransformersJsSettings()),e.querySelector(`[data-action="save-builtin-ai-settings"]`)?.addEventListener(`click`,()=>this.saveBuiltinAiSettings()),e.querySelector(`[data-setting="llamafile-mode"]`)?.addEventListener(`change`,()=>{this.updateLlamafileModeVisibility(),this.updateLlamafileModelSectionVisibility(),this.updateModelSelector()}))}renderBedrockSettings(){if(!this.orchestrator)return;let e=this.shadowRoot;if(!e)return;let t=this.orchestrator?T(this.orchestrator):null,n=e.querySelector(`[data-setting="bedrock-region-input"]`),r=e.querySelector(`[data-setting="bedrock-profile-input"]`),i=e.querySelector(`[data-setting="bedrock-auth-mode"]`);n&&(n.value=t?.region||``),r&&(r.value=t?.profile||``),i&&(i.value=t?.authMode||`provider_chain`)}renderLlamafileSettings(){if(!this.orchestrator)return;let e=this.shadowRoot;if(!e)return;let t=l(this.orchestrator);if(!t)return;let n=e.querySelector(`[data-setting="llamafile-mode"]`),r=e.querySelector(`[data-setting="llamafile-host"]`),i=e.querySelector(`[data-setting="llamafile-port"]`),a=e.querySelector(`[data-setting="llamafile-offline"]`);n&&(n.value=t.mode),r&&(r.value=t.host),i&&(i.value=String(t.port)),a&&(a.checked=t.offline)}renderMeshLlmSettings(){if(!this.orchestrator)return;let e=this.shadowRoot;if(!e)return;let t=this.orchestrator.getMeshLlmSettings?.(),n=e.querySelector(`[data-setting="mesh-llm-host-input"]`);n&&(n.value=t?.host||``)}setupEffects(){P(()=>{E.ready&&(this.orchestrator=E.orchestrator,this.render())})}updateBedrockSettingsVisibility(e){let t=this.shadowRoot;if(!t)return;let n=t.querySelector(`[data-setting="bedrock-settings"]`);n&&(n.style.display=e===`bedrock_proxy`?`block`:`none`)}updateLlamafileModelSectionVisibility(){if(!this.orchestrator)return;let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="model-settings"]`);if(!t)return;let n=l(this.orchestrator);t.style.display=n?.mode===`server`?`none`:`block`}updateLlamafileModeVisibility(){if(!this.orchestrator)return;let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="llamafile-server-only"]`),n=e.querySelector(`[data-setting="llamafile-cli-only"]`);if(!t&&!n)return;let r=this.orchestrator.provider===`llamafile`&&l(this.orchestrator)?.mode===`server`;t&&(t.style.display=r?`block`:`none`),n&&(n.style.display=r?`none`:`block`)}updateLlamafileSettingsVisibility(e){let t=this.shadowRoot;if(!t)return;let n=t.querySelector(`[data-setting="llamafile-settings"]`);n&&(n.style.display=e===`llamafile`?`block`:`none`)}updateMaxTokensUI(){if(!this.orchestrator)return;let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="max-tokens-input"]`),n=e.querySelector(`[data-setting="max-tokens-helper"]`),r=this.orchestrator.provider,i=this.orchestrator.model,a;r===`prompt_api`&&(a=e.querySelector(`[data-setting="prompt-api-fallback-select"]`)?.value||`onnx-community/Qwen3-0.6B-ONNX`);let o=this.orchestrator.maxTokens,s=V(r,i,a);t&&(t.value=String(o),t.removeAttribute(`max`)),n&&(n.textContent=`${s.detail} Current value: ${o.toLocaleString()}.`)}updateMeshLlmSettingsVisibility(e){let t=this.shadowRoot;if(!t)return;let n=t.querySelector(`[data-setting="mesh-llm-settings"]`);n&&(n.style.display=e===`mesh-llm`?`block`:`none`)}updateModelProviderHelperText(){let e=this.shadowRoot;if(!e||!this.orchestrator)return;let t=e.querySelector(`[data-setting="model-provider-helper"]`);if(!t)return;let n=this.orchestrator.provider,r=l(this.orchestrator);if(n!==`llamafile`||r?.mode===`server`){t.hidden=!0,t.textContent=``;return}if(t.hidden=!1,this.llamafileDiscoveredModelIds.length>0){t.textContent=`Discovered ${this.llamafileDiscoveredModelIds.length} *.llamafile model${this.llamafileDiscoveredModelIds.length===1?``:`s`} in ${g}. Choose Custom Model ID to target a file name that is not listed yet.`;return}if(this.llamafileModelLoadError){t.textContent=`Could not load llamafile models from ${g}. You can still enter a custom model id, but the file must exist there.`;return}t.textContent=`ShadowClaw looks for *.llamafile binaries in ${g}.`}updateModelSelector(){if(!this.orchestrator)return;let e=this.shadowRoot;if(!e)return;let t=u(),n=this.orchestrator.provider,r=t.find(e=>e.id===n),i=++this.modelFetchToken;n!==`llamafile`&&(this.llamafileDiscoveredModelIds=[],this.llamafileModelLoadError=null);let a=!1;if(n===`llamafile`&&l(this.orchestrator)?.mode===`server`){let t=e.querySelector(`[data-setting="model-select"]`);t&&(s(t,`<option value="">Model is served by local llamafile server</option>`),t.disabled=!0),a=!0}this.updateModelProviderHelperText();let o=e.querySelector(`[data-setting="prompt-api-fallback-group"]`);if(o){let e=F()||I();o.style.display=n===`prompt_api`&&!e?`block`:`none`}let c=e.querySelector(`[data-setting="model-select"]`),d=e.querySelector(`[data-setting="custom-model-input"]`),f=this.orchestrator.model,p=new Set([`transformers_js_local`,`transformers_js_browser`,`ollama`,`llamafile`,`prompt_api`]),h=e=>e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/\"/g,`"`).replace(/'/g,`'`),_=e=>p.has(n)||n===`mesh-llm`?!0:typeof e==`string`?!1:Array.isArray(e.providers)?e.providers.some(e=>e.provider===`hf-inference`||!e.pricing||parseFloat(String(e.pricing.input||e.pricing.prompt||0))===0&&parseFloat(String(e.pricing.output||e.pricing.completion||0))===0):e.pricing?parseFloat(String(e.pricing.prompt||0))===0&&parseFloat(String(e.pricing.completion||0))===0:!1,v=e=>{let t=typeof e==`string`?e:e.id||e.name;return p.has(n)?L(t):typeof e==`string`?!1:e.supports_tools===!0||e.supportsTools===!0?!0:Array.isArray(e.providers)?e.providers.some(e=>e.supports_tools===!0):Array.isArray(e.supported_parameters)?e.supported_parameters.includes(`tools`):!1},y=e=>{let t=typeof e==`string`?e:e.id||e.name;if(p.has(n))return L(t)?` 🛠️`:` ❔🛠️`;if(typeof e==`string`)return` ❔🛠️`;if(e.supports_tools===!0||e.supportsTools===!0)return` 🛠️`;if(e.supports_tools===!1||e.supportsTools===!1)return` 🚫🛠️`;if(Array.isArray(e.providers)){let t=e.providers.some(e=>e.supports_tools===!0),n=e.providers.some(e=>e.supports_tools===!1);if(t)return` 🛠️`;if(n)return` 🚫🛠️`}return Array.isArray(e.supported_parameters)?e.supported_parameters.includes(`tools`)?` 🛠️`:` 🚫🛠️`:` ❔🛠️`},b=e=>typeof e==`string`?0:typeof e.context_length==`number`?e.context_length:typeof e.context_window==`number`?e.context_window:Array.isArray(e.providers)?Math.max(...e.providers.map(e=>e.context_length||0),0):0,x=e=>{if(!c||!d)return;if(!Array.isArray(e)||e.length===0){let e=this.orchestrator?.model||``,t=n===`llamafile`?`No *.llamafile models found in ${g}`:`No models available`;s(c,[`<option value="" ${e?``:`selected`}>${h(t)}</option>`,`<option value="__custom__">-- Custom Model ID --</option>`].join(``)),e?(c.value=`__custom__`,d.value=e,d.style.display=`block`):(c.value=``,d.value=``,d.style.display=`none`),n===`llamafile`&&!e&&this.showLlamafileHelpDialog(this.llamafileModelLoadError?`Failed to load *.llamafile models: ${this.llamafileModelLoadError}`:`No *.llamafile files were found in ${g}.`),this.updateModelProviderHelperText();return}let t=[],r=[];for(let n of e)!n||typeof n!=`string`&&!n.id||(_(n)?t.push(n):r.push(n));let i=(e,t)=>{if(p.has(n)){let r=typeof e==`string`?e:e.id||e.name,i=typeof t==`string`?t:t.id||t.name;return R({id:r,supportsTools:v(e),contextLength:b(e)},{id:i,supportsTools:v(t),contextLength:b(t)},n)}let r=v(e),i=v(t);if(r!==i)return i?1:-1;let a=b(e),o=b(t);if(a!==o)return o-a;let s=typeof e==`string`?e:e.id||e.name,c=typeof t==`string`?t:t.id||t.name;return s.localeCompare(c)};t.sort(i),r.sort(i);let a=e=>{let t=typeof e==`string`?e:e.id||e.name,n=typeof e==`string`?t:typeof e.displayName==`string`&&e.displayName.trim()?e.displayName.trim():typeof e.name==`string`&&e.name.trim()?e.name.trim():t,r=y(e),i=b(e),a=``;i>=1e6?a=` (${(i/1e6).toFixed(1)}M)`:i>=1e3?a=` (${Math.round(i/1024)}k)`:i>0&&(a=` (${i})`);let o=n===t?t:`${n} - ${t}`;return`<option value="${h(t)}">${h(o)}${a}${r}</option>`},o=``;if(p.has(n)){let e=[...t,...r].sort(i);e.length>0&&(o+=`<optgroup label="${n===`prompt_api`?`Built-in`:`Local / Self-hosted`}">`,o+=e.map(a).join(``),o+=`</optgroup>`)}else t.length>0&&(o+=`<optgroup label="Free / Included">`,o+=t.map(a).join(``),o+=`</optgroup>`),r.length>0&&(o+=`<optgroup label="Paid / Pro">`,o+=r.map(a).join(``),o+=`</optgroup>`);o+=`<option value="__custom__">-- Custom Model ID --</option>`,s(c,o),e.map(e=>typeof e==`string`?e:e.id||e.name).includes(f)?(c.value=f,d.style.display=`none`):(c.value=`__custom__`,d.value=f||``,d.style.display=`block`),this.updateModelProviderHelperText()};if(!a)if(r?.modelsUrl&&c){let e=i;s(c,`<option>Loading models…</option>`),c.disabled=!0;let t={...r.headers};if(n===`llamafile`){let e=l(this.orchestrator);e&&(t[`x-llamafile-mode`]=e.mode,t[`x-llamafile-host`]=e.host,t[`x-llamafile-port`]=String(e.port),t[`x-llamafile-offline`]=e.offline?`true`:`false`)}else if(n===`bedrock_proxy`){let e=this.orchestrator?T(this.orchestrator):null;e?.region&&(t[`x-bedrock-region`]=e.region),e?.profile&&(t[`x-bedrock-profile`]=e.profile),e?.authMode&&(t[`x-bedrock-auth-mode`]=e.authMode)}m(this.orchestrator).then(i=>{if(i&&r.apiKeyHeader){let e=(r.apiKeyHeaderFormat||`{key}`).replace(`{key}`,i);t[r.apiKeyHeader]=e}r.modelsUrl&&fetch(r.modelsUrl,{headers:t}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(t=>{if(e!==this.modelFetchToken||this.orchestrator?.provider!==n)return;let i=[];if(Array.isArray(t))i=t;else if(t&&typeof t==`object`){if(i=t.models||t.data||[],i.length===0){for(let e in t)if(Array.isArray(t[e])&&t[e].length>0){i=t[e];break}}i.length===0&&t.id&&(i=[t])}if(Array.isArray(r.models)){let e=new Set(i.map(e=>typeof e==`string`?e:e.id||e.name));i=[...r.models.filter(t=>{let n=typeof t==`string`?t:t.id||t.name;return!e.has(n)}),...i]}n===`llamafile`&&(this.llamafileModelLoadError=null,this.llamafileDiscoveredModelIds=i.map(e=>typeof e==`string`?e:String(e?.id||e?.name||``)).filter(Boolean)),c.disabled=!1,x(i)}).catch(t=>{if(e!==this.modelFetchToken||this.orchestrator?.provider!==n)return;console.error(`[ShadowClaw] Failed to load models from`,r.modelsUrl,t);let i=t instanceof Error?t.message:String(t);if(n===`llamafile`){this.llamafileDiscoveredModelIds=[],this.llamafileModelLoadError=i,c.disabled=!1,x([]);return}s(c,`<option>Failed to load models</option>`),r?.models?(console.warn(`Falling back to statically configured models due to fetch failure.`),c.disabled=!1,x(r.models)):M(`Could not reach the model server — or proxy configuration is wrong`,5e3)})})}else r?.models&&c?(c.disabled=!1,x(r.models)):c&&(c.disabled=!1,x([]));let S=e.querySelector(`[data-setting="api-key-helper"]`),C=e.querySelector(`[data-setting="provider-select"]`);if(S&&C){let e=C.selectedOptions[0]?.text||`Provider`,t=r?.requiresApiKey!==!1;S.textContent=n===`llamafile`?`Runs local .llamafile binaries through the local proxy. No API key required.`:t?`Enter your ${e} API key. It is encrypted and stored locally.`:`This provider does not require an API key.`}let w=e.querySelector(`[data-setting="api-key-input"]`);if(w){let e=r?.requiresApiKey===!1;w.disabled=e,w.placeholder=e?`No API key required`:`sk-...`}}updateTransformersJsSettingsVisibility(e){let t=this.shadowRoot;if(!t)return;let n=t.querySelector(`[data-setting="transformers-js-settings"]`);n&&(n.style.display=e===`transformers_js_browser`?`block`:`none`)}async onContextCompressionToggle(e){if(!(!this.orchestrator||!this.db))try{await _(this.orchestrator,this.db,e),j(e?`Context compression enabled`:`Context compression disabled`,2500)}catch(e){M(`Error saving context compression setting: `+(e instanceof Error?e.message:String(e)),6e3)}}async onProviderChange(){if(!this.orchestrator||!this.db)return;let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="provider-select"]`);if(!t)return;let n=t.value,r=this.orchestrator.provider;if(n!==r)try{await S(this.orchestrator,this.db,n,{loadApiKeyForProvider:this.orchestrator.loadApiKeyForProvider.bind(this.orchestrator),getApiKeyForHeaders:()=>m(this.orchestrator)}),this.updateModelSelector(),this.updateMaxTokensUI(),this.updateLlamafileSettingsVisibility(n),this.renderLlamafileSettings(),this.updateLlamafileModeVisibility(),this.updateLlamafileModelSectionVisibility(),this.updateBedrockSettingsVisibility(n),this.updateBedrockSettingsVisibility(n),this.updateMeshLlmSettingsVisibility(n),this.updateTransformersJsSettingsVisibility(n),await this.renderTransformersJsSettings(),j(`Switched to ${t.selectedOptions[0]?.text||n}`,3e3)}catch(e){M(`Error switching provider: `+(e instanceof Error?e.message:String(e)),6e3),t.value=r}}async onStreamingToggle(e){if(!(!this.orchestrator||!this.db))try{await O(this.orchestrator,this.db,e),j(e?`Streaming enabled`:`Streaming disabled`,2500)}catch(e){M(`Error saving streaming setting: `+(e instanceof Error?e.message:String(e)),6e3)}}async render(){let e=this.shadowRoot;if(!e||!this.orchestrator||!this.db)return;this.bindEventListeners();let t=u(),n=this.orchestrator.provider,a=e.querySelector(`[data-setting="provider-select"]`);a&&s(a,t.map(e=>`<option value="${e.id}" ${e.id===n?`selected`:``}>${e.name}</option>`).join(``)),this.updateModelSelector(),this.updateLlamafileSettingsVisibility(n),this.renderLlamafileSettings(),this.updateLlamafileModeVisibility(),this.updateLlamafileModelSectionVisibility(),this.updateModelProviderHelperText(),this.updateBedrockSettingsVisibility(n),this.renderBedrockSettings(),this.updateMeshLlmSettingsVisibility(n),this.renderMeshLlmSettings(),this.updateTransformersJsSettingsVisibility(n),await this.renderTransformersJsSettings(),this.renderBuiltinAiSettings();let c=e.querySelector(`[data-setting="prompt-api-fallback-select"]`);c&&(c.value=await o(this.db,r.PROMPT_API_FALLBACK_MODEL)||`onnx-community/Qwen3-0.6B-ONNX`,this.updateMaxTokensUI(),c.value&&p(c.value).then(()=>{this.updateMaxTokensUI()}).catch(()=>{}));let l=e.querySelector(`[data-setting="prompt-api-device-select"]`);l&&(l.value=await o(this.db,r.PROMPT_API_BACKEND)||`auto`);let d=e.querySelector(`[data-setting="prompt-api-dtype-select"]`);d&&(d.value=await o(this.db,r.PROMPT_API_DTYPE_STRATEGY)||`auto`);let f=e.querySelector(`[data-setting="streaming-toggle"]`);f&&(f.checked=this.orchestrator.streamingEnabled);let m=e.querySelector(`[data-setting="context-compression-toggle"]`);m&&(m.checked=this.orchestrator.contextCompressionEnabled);let h=e.querySelector(`[data-setting="reasoning-effort-select"]`);h&&(h.value=this.orchestrator.reasoningEffort||`none`);let g=e.querySelector(`[data-setting="max-iterations-input"]`);g&&this.orchestrator&&(g.value=String(this.orchestrator.maxIterations));let _=e.querySelector(`[data-setting="subagent-max-parallel-input"]`);if(_){let e=await o(this.db,r.SUBAGENT_MAX_PARALLEL),t=Number(e);_.value=String(Number.isFinite(t)&&t>0?t:5)}let v=e.querySelector(`[data-setting="subagent-workspace-mode-select"]`);if(v){let e=await o(this.db,r.SUBAGENT_WORKSPACE_MODE);v.value=e===`parent`||e===`isolated`||e===`automatic`?e:i}let y=e.querySelector(`[data-setting="rate-limit-calls-per-minute-input"]`);y&&this.orchestrator&&(y.value=String(this.orchestrator.rateLimitCallsPerMinute||0));let b=e.querySelector(`[data-setting="rate-limit-auto-adapt-toggle"]`);b&&this.orchestrator&&(b.checked=this.orchestrator.rateLimitAutoAdapt!==!1),this.updateMaxTokensUI()}async renderBuiltinAiSettings(){if(!this.db)return;let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="compaction-engine-select"]`),n=e.querySelector(`[data-setting="builtin-ai-tools-backend-select"]`),i=await o(this.db,r.COMPACTION_ENGINE_PREFERENCE),a=await o(this.db,r.BUILTIN_AI_TOOLS_BACKEND);t&&(t.value=i||`auto`),n&&(n.value=a||`active_provider`)}async renderTransformersJsSettings(){if(!this.db)return;let e=this.shadowRoot;if(!e)return;let{getConfig:t}=await import(`./getConfig-D89uJgo5.js`).then(e=>e.n),{CONFIG_KEYS:n}=await import(`./config-BYAuxx3j.js`).then(e=>e.k),r=await t(this.db,n.TRANSFORMERS_JS_BACKEND)||`auto`,i=await t(this.db,n.TRANSFORMERS_JS_DTYPE_STRATEGY)||`auto`,a=e.querySelector(`[data-setting="transformers-js-backend"], [data-setting="transformers-js-device-select"]`);a&&(a.value=r);let o=e.querySelector(`[data-setting="transformers-js-dtype-strategy"], [data-setting="transformers-js-dtype-select"]`);o&&(o.value=i)}async requestAppDialog(e){let t=document.querySelector(`shadow-claw`);return t&&typeof t.requestDialog==`function`?await t.requestDialog(e):!1}async saveApiKey(){if(!this.orchestrator||!this.db){M(`Orchestrator not initialized`,5e3);return}let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="api-key-input"]`),n=e.querySelector(`[data-setting="provider-select"]`);if(!t||!n)return;let r=t.value.trim(),i=n.value;if(u().find(e=>e.id===i)?.requiresApiKey===!1){try{await S(this.orchestrator,this.db,i,{loadApiKeyForProvider:this.orchestrator.loadApiKeyForProvider.bind(this.orchestrator),getApiKeyForHeaders:()=>m(this.orchestrator)}),t.value=``,j(`Provider saved (no API key required)`,3e3)}catch(e){M(`Error saving provider: `+(e instanceof Error?e.message:String(e)),6e3)}return}if(!r){A(`Please enter an API key`,3e3);return}try{await this.orchestrator.setApiKey(this.db,r),t.value=``,j(`API key and provider saved`,3e3)}catch(e){M(`Error saving API key: `+(e instanceof Error?e.message:String(e)),6e3)}}async saveBedrockSettings(){if(!this.orchestrator||!this.db)return;let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="bedrock-region-input"]`),n=e.querySelector(`[data-setting="bedrock-profile-input"]`),r=e.querySelector(`[data-setting="bedrock-auth-mode"]`);if(!t||!n)return;let i=t.value.trim(),a=n.value.trim(),o=r?.value||`provider_chain`;if(i&&!a||!i&&a){A(`Enter both Bedrock region and profile (or leave both blank to rely on environment variables)`,4e3);return}try{await f(this.orchestrator,this.db,{region:i,profile:a,authMode:o}),j(`Bedrock fallback settings saved`,3e3),this.orchestrator.provider===`bedrock_proxy`&&this.updateModelSelector()}catch(e){M(`Error saving Bedrock fallback settings: `+(e instanceof Error?e.message:String(e)),6e3)}}async saveBuiltinAiSettings(){if(!this.db)return;let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="compaction-engine-select"]`),n=e.querySelector(`[data-setting="builtin-ai-tools-backend-select"]`);try{t&&await k(this.db,r.COMPACTION_ENGINE_PREFERENCE,t.value),n&&await k(this.db,r.BUILTIN_AI_TOOLS_BACKEND,n.value),j(`Built-in AI settings saved successfully`,2500)}catch(e){M(`Error saving Built-in AI settings: `+(e instanceof Error?e.message:String(e)),5e3)}}async saveLlamafileSettings(){if(!this.orchestrator||!this.db)return;let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="llamafile-mode"]`),n=e.querySelector(`[data-setting="llamafile-host"]`),r=e.querySelector(`[data-setting="llamafile-port"]`),i=e.querySelector(`[data-setting="llamafile-offline"]`);if(!t||!n||!r||!i)return;let a=t.value===`cli`?`cli`:`server`,o=n.value.trim(),s=parseInt(r.value,10);if(!o){A(`Please enter a host`,3e3);return}if(!Number.isFinite(s)||s<1||s>65535){A(`Please enter a valid port (1-65535)`,3e3);return}try{if(await c(this.orchestrator,this.db,{mode:a,host:o,port:s,offline:i.checked}),this.updateLlamafileModeVisibility(),this.updateLlamafileModelSectionVisibility(),this.updateModelSelector(),this.orchestrator.provider===`llamafile`){j(await E.restartCurrentRequest()?`Llamafile settings saved, request restarted`:`Llamafile settings saved`,3e3);return}j(`Llamafile settings saved`,3e3)}catch(e){M(`Error saving llamafile settings: `+(e instanceof Error?e.message:String(e)),6e3)}}async saveMaxIterations(){if(!this.orchestrator||!this.db)return;let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="max-iterations-input"]`);if(!t)return;let n=parseInt(t.value,10);if(!n||n<1){A(`Please enter a valid number (1 or higher)`,3e3);return}try{await y(this.orchestrator,this.db,n),j(`Max iterations saved`,3e3)}catch(e){M(`Error saving max iterations: `+(e instanceof Error?e.message:String(e)),6e3)}}async saveMaxTokens(){if(!this.orchestrator||!this.db)return;let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="max-tokens-input"]`);if(!t)return;let n=parseInt(t.value,10);if(!n||n<1){A(`Please enter a valid number (1 or higher)`,3e3);return}try{await w(this.orchestrator,this.db,n),this.updateMaxTokensUI(),j(`Max tokens saved`,3e3)}catch(e){M(`Error saving max tokens: `+(e instanceof Error?e.message:String(e)),6e3)}}async saveMeshLlmSettings(){if(!this.orchestrator||!this.db)return;let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="mesh-llm-host-input"]`);if(!t)return;let n=t.value.trim();try{this.orchestrator&&(await v(this.orchestrator,this.db,{host:n}),j(`Mesh LLM settings saved`,3e3),this.orchestrator.provider===`mesh-llm`&&this.updateModelSelector())}catch(e){M(`Error saving Mesh LLM settings: `+(e instanceof Error?e.message:String(e)),6e3)}}async saveModel(){if(!this.orchestrator||!this.db)return;let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="model-select"]`),n=e.querySelector(`[data-setting="custom-model-input"]`);if(!t||!n)return;let i=t.value;if(i===`__custom__`&&(i=n.value.trim()),this.orchestrator.provider===`llamafile`&&l(this.orchestrator).mode===`cli`&&!i){await this.showLlamafileHelpDialog(`Select a discovered *.llamafile model or enter a custom model id that matches a file in the ${g} folder.`);return}if(this.orchestrator.provider===`prompt_api`){let t=e.querySelector(`[data-setting="prompt-api-fallback-select"]`);if(t)try{await k(this.db,r.PROMPT_API_FALLBACK_MODEL,t.value)}catch(e){console.warn(`Error saving prompt api fallback model`,e)}let n=e.querySelector(`[data-setting="prompt-api-device-select"]`);if(n)try{await k(this.db,r.PROMPT_API_BACKEND,n.value)}catch(e){console.warn(`Error saving prompt api backend`,e)}let i=e.querySelector(`[data-setting="prompt-api-dtype-select"]`);if(i)try{await k(this.db,r.PROMPT_API_DTYPE_STRATEGY,i.value)}catch(e){console.warn(`Error saving prompt api dtype strategy`,e)}}try{if(await D(this.orchestrator,this.db,i),this.updateMaxTokensUI(),this.orchestrator.provider===`llamafile`){j(await E.restartCurrentRequest()?`Model saved, request restarted`:`Model saved`,3e3);return}j(`Model saved`,3e3)}catch(e){M(`Error saving model: `+(e instanceof Error?e.message:String(e)),6e3)}}async saveRateLimitSettings(){if(!this.orchestrator||!this.db)return;let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="rate-limit-calls-per-minute-input"]`),n=e.querySelector(`[data-setting="rate-limit-auto-adapt-toggle"]`);if(!t||!n)return;let r=parseInt(t.value,10);if(!Number.isFinite(r)||r<0){A(`Please enter a valid non-negative calls-per-minute value`,3e3);return}try{await b(this.orchestrator,this.db,r),await x(this.orchestrator,this.db,n.checked),j(`Rate limit settings saved`,3e3)}catch(e){M(`Error saving rate limit settings: `+(e instanceof Error?e.message:String(e)),6e3)}}async saveReasoningEffort(){if(!this.orchestrator||!this.db)return;let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="reasoning-effort-select"]`);if(t)try{await h(this.orchestrator,this.db,t.value||`none`),j(`Reasoning effort saved`,3e3)}catch(e){M(`Error saving reasoning effort: `+(e instanceof Error?e.message:String(e)),6e3)}}async saveSubagentMaxParallel(){if(!this.db){M(`Database not initialized`,3e3);return}let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="subagent-max-parallel-input"]`);if(!t)return;let n=parseInt(t.value,10);if(!n||n<1){A(`Please enter a valid number (1 or higher)`,3e3);return}try{await k(this.db,r.SUBAGENT_MAX_PARALLEL,String(n)),j(`Subagent limit saved`,3e3)}catch(e){M(`Error saving subagent limit: `+(e instanceof Error?e.message:String(e)),6e3)}}async saveSubagentWorkspaceMode(){if(!this.db){M(`Database not initialized`,3e3);return}let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="subagent-workspace-mode-select"]`);if(!t)return;let n=t.value;if(n!==`automatic`&&n!==`parent`&&n!==`isolated`){A(`Please select a valid subagent workspace mode`,3e3);return}try{await k(this.db,r.SUBAGENT_WORKSPACE_MODE,n),j(`Subagent workspace mode saved`,3e3)}catch(e){M(`Error saving subagent workspace mode: `+(e instanceof Error?e.message:String(e)),6e3)}}async saveTransformersJsSettings(){if(!this.db)return;let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="transformers-js-backend"], [data-setting="transformers-js-device-select"]`)?.value||`auto`,n=e.querySelector(`[data-setting="transformers-js-dtype-strategy"], [data-setting="transformers-js-dtype-select"]`)?.value||`auto`,{setConfig:r}=await import(`./setConfig-DFMYnYLE.js`).then(e=>e.n),{CONFIG_KEYS:i}=await import(`./config-BYAuxx3j.js`).then(e=>e.k);await r(this.db,i.TRANSFORMERS_JS_BACKEND,t),await r(this.db,i.TRANSFORMERS_JS_DTYPE_STRATEGY,n),j(`Transformers.js settings saved.`)}async showLlamafileHelpDialog(e){let t=`${e||``}|${this.orchestrator?.model||``}`;this.lastLlamafileHelpKey!==t&&(this.lastLlamafileHelpKey=t,await this.requestAppDialog(C(e)))}};customElements.get(q)||customElements.define(q,J);export{J as ShadowClawLlm};
|
|
666
|
+
`,`text/html`),W=U.querySelector(`template`);let G=[];G=W?Array.from(W.content.children):Array.from(U.head.children).concat(Array.from(U.body.children));var K=G;const q=`shadow-claw-llm`;var J=class extends N{static styles=H;static template=K;db;lastLlamafileHelpKey;llamafileDiscoveredModelIds;llamafileModelLoadError;modelFetchToken;orchestrator;constructor(){super(),this.db=null,this.orchestrator=null,this.llamafileDiscoveredModelIds=[],this.llamafileModelLoadError=null,this.lastLlamafileHelpKey=``,this.modelFetchToken=0}async connectedCallback(){if(!this.shadowRoot)throw Error(`shadowRoot not found`);this.db=await a(),this.orchestrator=E.orchestrator,this.bindEventListeners(),this.setupEffects()}applyRecommendedMaxTokens(){if(!this.orchestrator)return;let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="max-tokens-input"]`);if(!t)return;let n=this.orchestrator.provider,r=this.orchestrator.model,i;n===`prompt_api`&&(i=e.querySelector(`[data-setting="prompt-api-fallback-select"]`)?.value||`onnx-community/Qwen3-0.6B-ONNX`);let a=V(n,r,i);t.value=String(a.recommended)}bindEventListeners(){let e=this.shadowRoot;e&&(e.querySelector(`[data-setting="provider-select"]`)?.addEventListener(`change`,()=>this.onProviderChange()),e.querySelector(`[data-setting="prompt-api-fallback-select"]`)?.addEventListener(`change`,e=>{let t=e.target;t?.value&&p(t.value).then(()=>this.updateMaxTokensUI()).catch(()=>{}),this.updateMaxTokensUI()}),e.querySelector(`[data-action="save-llm-provider"]`)?.addEventListener(`click`,()=>this.saveApiKey()),e.querySelector(`[data-action="save-model"]`)?.addEventListener(`click`,()=>this.saveModel()),e.querySelector(`[data-action="refresh-models"]`)?.addEventListener(`click`,()=>this.updateModelSelector()),e.querySelector(`[data-setting="model-select"]`)?.addEventListener(`change`,t=>{let n=e.querySelector(`[data-setting="custom-model-input"]`),r=t.target;n&&r&&(n.style.display=r.value===`__custom__`?`block`:`none`)}),e.querySelector(`[data-setting="streaming-toggle"]`)?.addEventListener(`change`,e=>{e.target instanceof HTMLInputElement&&this.onStreamingToggle(e.target.checked)}),e.querySelector(`[data-setting="context-compression-toggle"]`)?.addEventListener(`change`,e=>{e.target instanceof HTMLInputElement&&this.onContextCompressionToggle(e.target.checked)}),e.querySelector(`[data-action="save-max-iterations"]`)?.addEventListener(`click`,()=>this.saveMaxIterations()),e.querySelector(`[data-action="save-subagent-max-parallel"]`)?.addEventListener(`click`,()=>this.saveSubagentMaxParallel()),e.querySelector(`[data-action="save-subagent-workspace-mode"]`)?.addEventListener(`click`,()=>this.saveSubagentWorkspaceMode()),e.querySelector(`[data-action="save-rate-limit-settings"]`)?.addEventListener(`click`,()=>this.saveRateLimitSettings()),e.querySelector(`[data-action="save-max-tokens"]`)?.addEventListener(`click`,()=>this.saveMaxTokens()),e.querySelector(`[data-action="save-reasoning-effort"]`)?.addEventListener(`click`,()=>this.saveReasoningEffort()),e.querySelector(`[data-action="apply-recommended-max-tokens"]`)?.addEventListener(`click`,()=>this.applyRecommendedMaxTokens()),e.querySelector(`[data-action="save-llamafile-settings"]`)?.addEventListener(`click`,()=>this.saveLlamafileSettings()),e.querySelector(`[data-action="save-bedrock-settings"]`)?.addEventListener(`click`,()=>this.saveBedrockSettings()),e.querySelector(`[data-action="save-mesh-llm-settings"]`)?.addEventListener(`click`,()=>this.saveMeshLlmSettings()),e.querySelector(`[data-action="save-transformers-js-settings"]`)?.addEventListener(`click`,()=>this.saveTransformersJsSettings()),e.querySelector(`[data-action="save-builtin-ai-settings"]`)?.addEventListener(`click`,()=>this.saveBuiltinAiSettings()),e.querySelector(`[data-setting="llamafile-mode"]`)?.addEventListener(`change`,()=>{this.updateLlamafileModeVisibility(),this.updateLlamafileModelSectionVisibility(),this.updateModelSelector()}))}renderBedrockSettings(){if(!this.orchestrator)return;let e=this.shadowRoot;if(!e)return;let t=this.orchestrator?T(this.orchestrator):null,n=e.querySelector(`[data-setting="bedrock-region-input"]`),r=e.querySelector(`[data-setting="bedrock-profile-input"]`),i=e.querySelector(`[data-setting="bedrock-auth-mode"]`);n&&(n.value=t?.region||``),r&&(r.value=t?.profile||``),i&&(i.value=t?.authMode||`provider_chain`)}renderLlamafileSettings(){if(!this.orchestrator)return;let e=this.shadowRoot;if(!e)return;let t=l(this.orchestrator);if(!t)return;let n=e.querySelector(`[data-setting="llamafile-mode"], [data-setting="llamafile-mode-select"]`),r=e.querySelector(`[data-setting="llamafile-host"], [data-setting="llamafile-host-input"]`),i=e.querySelector(`[data-setting="llamafile-port"], [data-setting="llamafile-port-input"]`),a=e.querySelector(`[data-setting="llamafile-offline"], [data-setting="llamafile-offline-toggle"]`);n&&(n.value=t.mode),r&&(r.value=t.host),i&&(i.value=String(t.port)),a&&(a.checked=t.offline)}renderMeshLlmSettings(){if(!this.orchestrator)return;let e=this.shadowRoot;if(!e)return;let t=this.orchestrator.getMeshLlmSettings?.(),n=e.querySelector(`[data-setting="mesh-llm-host-input"]`);n&&(n.value=t?.host||``)}setupEffects(){P(()=>{E.ready&&(this.orchestrator=E.orchestrator,this.render())})}updateBedrockSettingsVisibility(e){let t=this.shadowRoot;if(!t)return;let n=t.querySelector(`[data-setting="bedrock-settings"]`);n&&(n.style.display=e===`bedrock_proxy`?`block`:`none`)}updateLlamafileModelSectionVisibility(){if(!this.orchestrator)return;let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="model-settings"]`);if(!t)return;let n=l(this.orchestrator);t.style.display=n?.mode===`server`?`none`:`block`}updateLlamafileModeVisibility(){if(!this.orchestrator)return;let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="llamafile-server-only"]`),n=e.querySelector(`[data-setting="llamafile-cli-only"]`);if(!t&&!n)return;let r=this.orchestrator.provider===`llamafile`&&l(this.orchestrator)?.mode===`server`;t&&(t.style.display=r?`block`:`none`),n&&(n.style.display=r?`none`:`block`)}updateLlamafileSettingsVisibility(e){let t=this.shadowRoot;if(!t)return;let n=t.querySelector(`[data-setting="llamafile-settings"]`);n&&(n.style.display=e===`llamafile`?`block`:`none`)}updateMaxTokensUI(){if(!this.orchestrator)return;let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="max-tokens-input"]`),n=e.querySelector(`[data-setting="max-tokens-helper"]`),r=this.orchestrator.provider,i=this.orchestrator.model,a;r===`prompt_api`&&(a=e.querySelector(`[data-setting="prompt-api-fallback-select"]`)?.value||`onnx-community/Qwen3-0.6B-ONNX`);let o=this.orchestrator.maxTokens,s=V(r,i,a);t&&(t.value=String(o),t.removeAttribute(`max`)),n&&(n.textContent=`${s.detail} Current value: ${o.toLocaleString()}.`)}updateMeshLlmSettingsVisibility(e){let t=this.shadowRoot;if(!t)return;let n=t.querySelector(`[data-setting="mesh-llm-settings"]`);n&&(n.style.display=e===`mesh-llm`?`block`:`none`)}updateModelProviderHelperText(){let e=this.shadowRoot;if(!e||!this.orchestrator)return;let t=e.querySelector(`[data-setting="model-provider-helper"]`);if(!t)return;let n=this.orchestrator.provider,r=l(this.orchestrator);if(n!==`llamafile`||r?.mode===`server`){t.hidden=!0,t.textContent=``;return}if(t.hidden=!1,this.llamafileDiscoveredModelIds.length>0){t.textContent=`Discovered ${this.llamafileDiscoveredModelIds.length} *.llamafile model${this.llamafileDiscoveredModelIds.length===1?``:`s`} in ${g}. Choose Custom Model ID to target a file name that is not listed yet.`;return}if(this.llamafileModelLoadError){t.textContent=`Could not load llamafile models from ${g}. You can still enter a custom model id, but the file must exist there.`;return}t.textContent=`ShadowClaw looks for *.llamafile binaries in ${g}.`}updateModelSelector(){if(!this.orchestrator)return;let e=this.shadowRoot;if(!e)return;let t=u(),n=this.orchestrator.provider,r=t.find(e=>e.id===n),i=++this.modelFetchToken;n!==`llamafile`&&(this.llamafileDiscoveredModelIds=[],this.llamafileModelLoadError=null);let a=!1;if(n===`llamafile`&&l(this.orchestrator)?.mode===`server`){let t=e.querySelector(`[data-setting="model-select"]`);t&&(s(t,`<option value="">Model is served by local llamafile server</option>`),t.disabled=!0),a=!0}this.updateModelProviderHelperText();let o=e.querySelector(`[data-setting="prompt-api-fallback-group"]`);if(o){let e=F()||I();o.style.display=n===`prompt_api`&&!e?`block`:`none`}let c=e.querySelector(`[data-setting="model-select"]`),d=e.querySelector(`[data-setting="custom-model-input"]`),f=this.orchestrator.model,p=new Set([`transformers_js_local`,`transformers_js_browser`,`ollama`,`llamafile`,`prompt_api`]),h=e=>e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/\"/g,`"`).replace(/'/g,`'`),_=e=>p.has(n)||n===`mesh-llm`?!0:typeof e==`string`?!1:Array.isArray(e.providers)?e.providers.some(e=>e.provider===`hf-inference`||!e.pricing||parseFloat(String(e.pricing.input||e.pricing.prompt||0))===0&&parseFloat(String(e.pricing.output||e.pricing.completion||0))===0):e.pricing?parseFloat(String(e.pricing.prompt||0))===0&&parseFloat(String(e.pricing.completion||0))===0:!1,v=e=>{let t=typeof e==`string`?e:e.id||e.name;return p.has(n)?L(t):typeof e==`string`?!1:e.supports_tools===!0||e.supportsTools===!0?!0:Array.isArray(e.providers)?e.providers.some(e=>e.supports_tools===!0):Array.isArray(e.supported_parameters)?e.supported_parameters.includes(`tools`):!1},y=e=>{let t=typeof e==`string`?e:e.id||e.name;if(p.has(n))return L(t)?` 🛠️`:` ❔🛠️`;if(typeof e==`string`)return` ❔🛠️`;if(e.supports_tools===!0||e.supportsTools===!0)return` 🛠️`;if(e.supports_tools===!1||e.supportsTools===!1)return` 🚫🛠️`;if(Array.isArray(e.providers)){let t=e.providers.some(e=>e.supports_tools===!0),n=e.providers.some(e=>e.supports_tools===!1);if(t)return` 🛠️`;if(n)return` 🚫🛠️`}return Array.isArray(e.supported_parameters)?e.supported_parameters.includes(`tools`)?` 🛠️`:` 🚫🛠️`:` ❔🛠️`},b=e=>typeof e==`string`?0:typeof e.context_length==`number`?e.context_length:typeof e.context_window==`number`?e.context_window:Array.isArray(e.providers)?Math.max(...e.providers.map(e=>e.context_length||0),0):0,x=e=>{if(!c||!d)return;if(!Array.isArray(e)||e.length===0){let e=this.orchestrator?.model||``,t=n===`llamafile`?`No *.llamafile models found in ${g}`:`No models available`;s(c,[`<option value="" ${e?``:`selected`}>${h(t)}</option>`,`<option value="__custom__">-- Custom Model ID --</option>`].join(``)),e?(c.value=`__custom__`,d.value=e,d.style.display=`block`):(c.value=``,d.value=``,d.style.display=`none`),n===`llamafile`&&!e&&this.showLlamafileHelpDialog(this.llamafileModelLoadError?`Failed to load *.llamafile models: ${this.llamafileModelLoadError}`:`No *.llamafile files were found in ${g}.`),this.updateModelProviderHelperText();return}let t=[],r=[];for(let n of e)!n||typeof n!=`string`&&!n.id||(_(n)?t.push(n):r.push(n));let i=(e,t)=>{if(p.has(n)){let r=typeof e==`string`?e:e.id||e.name,i=typeof t==`string`?t:t.id||t.name;return R({id:r,supportsTools:v(e),contextLength:b(e)},{id:i,supportsTools:v(t),contextLength:b(t)},n)}let r=v(e),i=v(t);if(r!==i)return i?1:-1;let a=b(e),o=b(t);if(a!==o)return o-a;let s=typeof e==`string`?e:e.id||e.name,c=typeof t==`string`?t:t.id||t.name;return s.localeCompare(c)};t.sort(i),r.sort(i);let a=e=>{let t=typeof e==`string`?e:e.id||e.name,n=typeof e==`string`?t:typeof e.displayName==`string`&&e.displayName.trim()?e.displayName.trim():typeof e.name==`string`&&e.name.trim()?e.name.trim():t,r=y(e),i=b(e),a=``;i>=1e6?a=` (${(i/1e6).toFixed(1)}M)`:i>=1e3?a=` (${Math.round(i/1024)}k)`:i>0&&(a=` (${i})`);let o=n===t?t:`${n} - ${t}`;return`<option value="${h(t)}">${h(o)}${a}${r}</option>`},o=``;if(p.has(n)){let e=[...t,...r].sort(i);e.length>0&&(o+=`<optgroup label="${n===`prompt_api`?`Built-in`:`Local / Self-hosted`}">`,o+=e.map(a).join(``),o+=`</optgroup>`)}else t.length>0&&(o+=`<optgroup label="Free / Included">`,o+=t.map(a).join(``),o+=`</optgroup>`),r.length>0&&(o+=`<optgroup label="Paid / Pro">`,o+=r.map(a).join(``),o+=`</optgroup>`);o+=`<option value="__custom__">-- Custom Model ID --</option>`,s(c,o),e.map(e=>typeof e==`string`?e:e.id||e.name).includes(f)?(c.value=f,d.style.display=`none`):(c.value=`__custom__`,d.value=f||``,d.style.display=`block`),this.updateModelProviderHelperText()};if(!a)if(r?.modelsUrl&&c){let e=i;s(c,`<option>Loading models…</option>`),c.disabled=!0;let t={...r.headers};if(n===`llamafile`){let e=l(this.orchestrator);e&&(t[`x-llamafile-mode`]=e.mode,t[`x-llamafile-host`]=e.host,t[`x-llamafile-port`]=String(e.port),t[`x-llamafile-offline`]=e.offline?`true`:`false`)}else if(n===`bedrock_proxy`){let e=this.orchestrator?T(this.orchestrator):null;e?.region&&(t[`x-bedrock-region`]=e.region),e?.profile&&(t[`x-bedrock-profile`]=e.profile),e?.authMode&&(t[`x-bedrock-auth-mode`]=e.authMode)}m(this.orchestrator).then(i=>{if(i&&r.apiKeyHeader){let e=(r.apiKeyHeaderFormat||`{key}`).replace(`{key}`,i);t[r.apiKeyHeader]=e}r.modelsUrl&&fetch(r.modelsUrl,{headers:t}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(t=>{if(e!==this.modelFetchToken||this.orchestrator?.provider!==n)return;let i=[];if(Array.isArray(t))i=t;else if(t&&typeof t==`object`){if(i=t.models||t.data||[],i.length===0){for(let e in t)if(Array.isArray(t[e])&&t[e].length>0){i=t[e];break}}i.length===0&&t.id&&(i=[t])}if(Array.isArray(r.models)){let e=new Set(i.map(e=>typeof e==`string`?e:e.id||e.name));i=[...r.models.filter(t=>{let n=typeof t==`string`?t:t.id||t.name;return!e.has(n)}),...i]}n===`llamafile`&&(this.llamafileModelLoadError=null,this.llamafileDiscoveredModelIds=i.map(e=>typeof e==`string`?e:String(e?.id||e?.name||``)).filter(Boolean)),c.disabled=!1,x(i)}).catch(t=>{if(e!==this.modelFetchToken||this.orchestrator?.provider!==n)return;console.error(`[ShadowClaw] Failed to load models from`,r.modelsUrl,t);let i=t instanceof Error?t.message:String(t);if(n===`llamafile`){this.llamafileDiscoveredModelIds=[],this.llamafileModelLoadError=i,c.disabled=!1,x([]);return}s(c,`<option>Failed to load models</option>`),r?.models?(console.warn(`Falling back to statically configured models due to fetch failure.`),c.disabled=!1,x(r.models)):M(`Could not reach the model server — or proxy configuration is wrong`,5e3)})})}else r?.models&&c?(c.disabled=!1,x(r.models)):c&&(c.disabled=!1,x([]));let S=e.querySelector(`[data-setting="api-key-helper"]`),C=e.querySelector(`[data-setting="provider-select"]`);if(S&&C){let e=C.selectedOptions[0]?.text||`Provider`,t=r?.requiresApiKey!==!1;S.textContent=n===`llamafile`?`Runs local .llamafile binaries through the local proxy. No API key required.`:t?`Enter your ${e} API key. It is encrypted and stored locally.`:`This provider does not require an API key.`}let w=e.querySelector(`[data-setting="api-key-input"]`);if(w){let e=r?.requiresApiKey===!1;w.disabled=e,w.placeholder=e?`No API key required`:`sk-...`}}updateTransformersJsSettingsVisibility(e){let t=this.shadowRoot;if(!t)return;let n=t.querySelector(`[data-setting="transformers-js-settings"]`);n&&(n.style.display=e===`transformers_js_browser`?`block`:`none`)}async onContextCompressionToggle(e){if(!(!this.orchestrator||!this.db))try{await _(this.orchestrator,this.db,e),j(e?`Context compression enabled`:`Context compression disabled`,2500)}catch(e){M(`Error saving context compression setting: `+(e instanceof Error?e.message:String(e)),6e3)}}async onProviderChange(){if(!this.orchestrator||!this.db)return;let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="provider-select"]`);if(!t)return;let n=t.value,r=this.orchestrator.provider;if(n!==r)try{await S(this.orchestrator,this.db,n,{loadApiKeyForProvider:this.orchestrator.loadApiKeyForProvider.bind(this.orchestrator),getApiKeyForHeaders:()=>m(this.orchestrator)}),this.updateModelSelector(),this.updateMaxTokensUI(),this.updateLlamafileSettingsVisibility(n),this.renderLlamafileSettings(),this.updateLlamafileModeVisibility(),this.updateLlamafileModelSectionVisibility(),this.updateBedrockSettingsVisibility(n),this.updateBedrockSettingsVisibility(n),this.updateMeshLlmSettingsVisibility(n),this.updateTransformersJsSettingsVisibility(n),await this.renderTransformersJsSettings(),j(`Switched to ${t.selectedOptions[0]?.text||n}`,3e3)}catch(e){M(`Error switching provider: `+(e instanceof Error?e.message:String(e)),6e3),t.value=r}}async onStreamingToggle(e){if(!(!this.orchestrator||!this.db))try{await O(this.orchestrator,this.db,e),j(e?`Streaming enabled`:`Streaming disabled`,2500)}catch(e){M(`Error saving streaming setting: `+(e instanceof Error?e.message:String(e)),6e3)}}async render(){let e=this.shadowRoot;if(!e||!this.orchestrator||!this.db)return;this.bindEventListeners();let t=u(),n=this.orchestrator.provider,a=e.querySelector(`[data-setting="provider-select"]`);a&&s(a,t.map(e=>`<option value="${e.id}" ${e.id===n?`selected`:``}>${e.name}</option>`).join(``)),this.updateModelSelector(),this.updateLlamafileSettingsVisibility(n),this.renderLlamafileSettings(),this.updateLlamafileModeVisibility(),this.updateLlamafileModelSectionVisibility(),this.updateModelProviderHelperText(),this.updateBedrockSettingsVisibility(n),this.renderBedrockSettings(),this.updateMeshLlmSettingsVisibility(n),this.renderMeshLlmSettings(),this.updateTransformersJsSettingsVisibility(n),await this.renderTransformersJsSettings(),this.renderBuiltinAiSettings();let c=e.querySelector(`[data-setting="prompt-api-fallback-select"]`);c&&(c.value=await o(this.db,r.PROMPT_API_FALLBACK_MODEL)||`onnx-community/Qwen3-0.6B-ONNX`,this.updateMaxTokensUI(),c.value&&p(c.value).then(()=>{this.updateMaxTokensUI()}).catch(()=>{}));let l=e.querySelector(`[data-setting="prompt-api-device-select"]`);l&&(l.value=await o(this.db,r.PROMPT_API_BACKEND)||`auto`);let d=e.querySelector(`[data-setting="prompt-api-dtype-select"]`);d&&(d.value=await o(this.db,r.PROMPT_API_DTYPE_STRATEGY)||`auto`);let f=e.querySelector(`[data-setting="streaming-toggle"]`);f&&(f.checked=this.orchestrator.streamingEnabled);let m=e.querySelector(`[data-setting="context-compression-toggle"]`);m&&(m.checked=this.orchestrator.contextCompressionEnabled);let h=e.querySelector(`[data-setting="reasoning-effort-select"]`);h&&(h.value=this.orchestrator.reasoningEffort||`none`);let g=e.querySelector(`[data-setting="max-iterations-input"]`);g&&this.orchestrator&&(g.value=String(this.orchestrator.maxIterations));let _=e.querySelector(`[data-setting="subagent-max-parallel-input"]`);if(_){let e=await o(this.db,r.SUBAGENT_MAX_PARALLEL),t=Number(e);_.value=String(Number.isFinite(t)&&t>0?t:5)}let v=e.querySelector(`[data-setting="subagent-workspace-mode-select"]`);if(v){let e=await o(this.db,r.SUBAGENT_WORKSPACE_MODE);v.value=e===`parent`||e===`isolated`||e===`automatic`?e:i}let y=e.querySelector(`[data-setting="rate-limit-calls-per-minute-input"]`);y&&this.orchestrator&&(y.value=String(this.orchestrator.rateLimitCallsPerMinute||0));let b=e.querySelector(`[data-setting="rate-limit-auto-adapt-toggle"]`);b&&this.orchestrator&&(b.checked=this.orchestrator.rateLimitAutoAdapt!==!1),this.updateMaxTokensUI()}async renderBuiltinAiSettings(){if(!this.db)return;let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="compaction-engine-select"]`),n=e.querySelector(`[data-setting="builtin-ai-tools-backend-select"]`),i=await o(this.db,r.COMPACTION_ENGINE_PREFERENCE),a=await o(this.db,r.BUILTIN_AI_TOOLS_BACKEND);t&&(t.value=i||`auto`),n&&(n.value=a||`active_provider`)}async renderTransformersJsSettings(){if(!this.db)return;let e=this.shadowRoot;if(!e)return;let{getConfig:t}=await import(`./getConfig-D89uJgo5.js`).then(e=>e.n),{CONFIG_KEYS:n}=await import(`./config-CrHchneq.js`).then(e=>e.k),r=await t(this.db,n.TRANSFORMERS_JS_BACKEND)||`auto`,i=await t(this.db,n.TRANSFORMERS_JS_DTYPE_STRATEGY)||`auto`,a=e.querySelector(`[data-setting="transformers-js-backend"], [data-setting="transformers-js-device-select"]`);a&&(a.value=r);let o=e.querySelector(`[data-setting="transformers-js-dtype-strategy"], [data-setting="transformers-js-dtype-select"]`);o&&(o.value=i)}async requestAppDialog(e){let t=document.querySelector(`shadow-claw`);return t&&typeof t.requestDialog==`function`?await t.requestDialog(e):!1}async saveApiKey(){if(!this.orchestrator||!this.db){M(`Orchestrator not initialized`,5e3);return}let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="api-key-input"]`),n=e.querySelector(`[data-setting="provider-select"]`);if(!t||!n)return;let r=t.value.trim(),i=n.value;if(u().find(e=>e.id===i)?.requiresApiKey===!1){try{await S(this.orchestrator,this.db,i,{loadApiKeyForProvider:this.orchestrator.loadApiKeyForProvider.bind(this.orchestrator),getApiKeyForHeaders:()=>m(this.orchestrator)}),t.value=``,j(`Provider saved (no API key required)`,3e3)}catch(e){M(`Error saving provider: `+(e instanceof Error?e.message:String(e)),6e3)}return}if(!r){A(`Please enter an API key`,3e3);return}try{await this.orchestrator.setApiKey(this.db,r),t.value=``,j(`API key and provider saved`,3e3)}catch(e){M(`Error saving API key: `+(e instanceof Error?e.message:String(e)),6e3)}}async saveBedrockSettings(){if(!this.orchestrator||!this.db)return;let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="bedrock-region-input"]`),n=e.querySelector(`[data-setting="bedrock-profile-input"]`),r=e.querySelector(`[data-setting="bedrock-auth-mode"]`);if(!t||!n)return;let i=t.value.trim(),a=n.value.trim(),o=r?.value||`provider_chain`;if(i&&!a||!i&&a){A(`Enter both Bedrock region and profile (or leave both blank to rely on environment variables)`,4e3);return}try{await f(this.orchestrator,this.db,{region:i,profile:a,authMode:o}),j(`Bedrock fallback settings saved`,3e3),this.orchestrator.provider===`bedrock_proxy`&&this.updateModelSelector()}catch(e){M(`Error saving Bedrock fallback settings: `+(e instanceof Error?e.message:String(e)),6e3)}}async saveBuiltinAiSettings(){if(!this.db)return;let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="compaction-engine-select"]`),n=e.querySelector(`[data-setting="builtin-ai-tools-backend-select"]`);try{t&&await k(this.db,r.COMPACTION_ENGINE_PREFERENCE,t.value),n&&await k(this.db,r.BUILTIN_AI_TOOLS_BACKEND,n.value),j(`Built-in AI settings saved successfully`,2500)}catch(e){M(`Error saving Built-in AI settings: `+(e instanceof Error?e.message:String(e)),5e3)}}async saveLlamafileSettings(){if(!this.orchestrator||!this.db)return;let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="llamafile-mode"], [data-setting="llamafile-mode-select"]`),n=e.querySelector(`[data-setting="llamafile-host"], [data-setting="llamafile-host-input"]`),r=e.querySelector(`[data-setting="llamafile-port"], [data-setting="llamafile-port-input"]`),i=e.querySelector(`[data-setting="llamafile-offline"], [data-setting="llamafile-offline-toggle"]`);if(!t||!n||!r||!i)return;let a=t.value===`cli`?`cli`:`server`,o=n.value.trim(),s=parseInt(r.value,10);if(!o){A(`Please enter a host`,3e3);return}if(!Number.isFinite(s)||s<1||s>65535){A(`Please enter a valid port (1-65535)`,3e3);return}try{if(await c(this.orchestrator,this.db,{mode:a,host:o,port:s,offline:i.checked}),this.updateLlamafileModeVisibility(),this.updateLlamafileModelSectionVisibility(),this.updateModelSelector(),this.orchestrator.provider===`llamafile`){j(await E.restartCurrentRequest()?`Llamafile settings saved, request restarted`:`Llamafile settings saved`,3e3);return}j(`Llamafile settings saved`,3e3)}catch(e){M(`Error saving llamafile settings: `+(e instanceof Error?e.message:String(e)),6e3)}}async saveMaxIterations(){if(!this.orchestrator||!this.db)return;let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="max-iterations-input"]`);if(!t)return;let n=parseInt(t.value,10);if(!n||n<1){A(`Please enter a valid number (1 or higher)`,3e3);return}try{await y(this.orchestrator,this.db,n),j(`Max iterations saved`,3e3)}catch(e){M(`Error saving max iterations: `+(e instanceof Error?e.message:String(e)),6e3)}}async saveMaxTokens(){if(!this.orchestrator||!this.db)return;let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="max-tokens-input"]`);if(!t)return;let n=parseInt(t.value,10);if(!n||n<1){A(`Please enter a valid number (1 or higher)`,3e3);return}try{await w(this.orchestrator,this.db,n),this.updateMaxTokensUI(),j(`Max tokens saved`,3e3)}catch(e){M(`Error saving max tokens: `+(e instanceof Error?e.message:String(e)),6e3)}}async saveMeshLlmSettings(){if(!this.orchestrator||!this.db)return;let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="mesh-llm-host-input"]`);if(!t)return;let n=t.value.trim();try{this.orchestrator&&(await v(this.orchestrator,this.db,{host:n}),j(`Mesh LLM settings saved`,3e3),this.orchestrator.provider===`mesh-llm`&&this.updateModelSelector())}catch(e){M(`Error saving Mesh LLM settings: `+(e instanceof Error?e.message:String(e)),6e3)}}async saveModel(){if(!this.orchestrator||!this.db)return;let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="model-select"]`),n=e.querySelector(`[data-setting="custom-model-input"]`);if(!t||!n)return;let i=t.value;if(i===`__custom__`&&(i=n.value.trim()),this.orchestrator.provider===`llamafile`&&l(this.orchestrator).mode===`cli`&&!i){await this.showLlamafileHelpDialog(`Select a discovered *.llamafile model or enter a custom model id that matches a file in the ${g} folder.`);return}if(this.orchestrator.provider===`prompt_api`){let t=e.querySelector(`[data-setting="prompt-api-fallback-select"]`);if(t)try{await k(this.db,r.PROMPT_API_FALLBACK_MODEL,t.value)}catch(e){console.warn(`Error saving prompt api fallback model`,e)}let n=e.querySelector(`[data-setting="prompt-api-device-select"]`);if(n)try{await k(this.db,r.PROMPT_API_BACKEND,n.value)}catch(e){console.warn(`Error saving prompt api backend`,e)}let i=e.querySelector(`[data-setting="prompt-api-dtype-select"]`);if(i)try{await k(this.db,r.PROMPT_API_DTYPE_STRATEGY,i.value)}catch(e){console.warn(`Error saving prompt api dtype strategy`,e)}}try{if(await D(this.orchestrator,this.db,i),this.updateMaxTokensUI(),this.orchestrator.provider===`llamafile`){j(await E.restartCurrentRequest()?`Model saved, request restarted`:`Model saved`,3e3);return}j(`Model saved`,3e3)}catch(e){M(`Error saving model: `+(e instanceof Error?e.message:String(e)),6e3)}}async saveRateLimitSettings(){if(!this.orchestrator||!this.db)return;let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="rate-limit-calls-per-minute-input"]`),n=e.querySelector(`[data-setting="rate-limit-auto-adapt-toggle"]`);if(!t||!n)return;let r=parseInt(t.value,10);if(!Number.isFinite(r)||r<0){A(`Please enter a valid non-negative calls-per-minute value`,3e3);return}try{await b(this.orchestrator,this.db,r),await x(this.orchestrator,this.db,n.checked),j(`Rate limit settings saved`,3e3)}catch(e){M(`Error saving rate limit settings: `+(e instanceof Error?e.message:String(e)),6e3)}}async saveReasoningEffort(){if(!this.orchestrator||!this.db)return;let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="reasoning-effort-select"]`);if(t)try{await h(this.orchestrator,this.db,t.value||`none`),j(`Reasoning effort saved`,3e3)}catch(e){M(`Error saving reasoning effort: `+(e instanceof Error?e.message:String(e)),6e3)}}async saveSubagentMaxParallel(){if(!this.db){M(`Database not initialized`,3e3);return}let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="subagent-max-parallel-input"]`);if(!t)return;let n=parseInt(t.value,10);if(!n||n<1){A(`Please enter a valid number (1 or higher)`,3e3);return}try{await k(this.db,r.SUBAGENT_MAX_PARALLEL,String(n)),j(`Subagent limit saved`,3e3)}catch(e){M(`Error saving subagent limit: `+(e instanceof Error?e.message:String(e)),6e3)}}async saveSubagentWorkspaceMode(){if(!this.db){M(`Database not initialized`,3e3);return}let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="subagent-workspace-mode-select"]`);if(!t)return;let n=t.value;if(n!==`automatic`&&n!==`parent`&&n!==`isolated`){A(`Please select a valid subagent workspace mode`,3e3);return}try{await k(this.db,r.SUBAGENT_WORKSPACE_MODE,n),j(`Subagent workspace mode saved`,3e3)}catch(e){M(`Error saving subagent workspace mode: `+(e instanceof Error?e.message:String(e)),6e3)}}async saveTransformersJsSettings(){if(!this.db)return;let e=this.shadowRoot;if(!e)return;let t=e.querySelector(`[data-setting="transformers-js-backend"], [data-setting="transformers-js-device-select"]`)?.value||`auto`,n=e.querySelector(`[data-setting="transformers-js-dtype-strategy"], [data-setting="transformers-js-dtype-select"]`)?.value||`auto`,{setConfig:r}=await import(`./setConfig-DFMYnYLE.js`).then(e=>e.n),{CONFIG_KEYS:i}=await import(`./config-CrHchneq.js`).then(e=>e.k);await r(this.db,i.TRANSFORMERS_JS_BACKEND,t),await r(this.db,i.TRANSFORMERS_JS_DTYPE_STRATEGY,n),j(`Transformers.js settings saved.`)}async showLlamafileHelpDialog(e){let t=`${e||``}|${this.orchestrator?.model||``}`;this.lastLlamafileHelpKey!==t&&(this.lastLlamafileHelpKey=t,await this.requestAppDialog(C(e)))}};customElements.get(q)||customElements.define(q,J);export{J as ShadowClawLlm};
|
package/dist/public/{shadow-claw-mcp-remote-BUjAeVXC.js → shadow-claw-mcp-remote-kY4LMFNN.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./config-
|
|
1
|
+
import{r as e}from"./config-CrHchneq.js";import{n as t}from"./txPromise-EBECky1b.js";import{t as n}from"./getConfig-D89uJgo5.js";import{m as r,u as i}from"./custom-element-security-NCqQ5lmC.js";import{r as a}from"./crypto-C8c5wMzN.js";import{a as o,l as s,o as c,s as l,t as u,u as d}from"./mcp-reconnect-9emsqGRe.js";import{r as f,t as p}from"./toast-D3gxhZpN.js";import{t as m}from"./shadow-claw-element-DIrv3P6A.js";import"./shadow-claw-card-DCxWEHgX.js";import"./shadow-claw-empty-state-obMInUIf.js";const h=new CSSStyleSheet;h.replaceSync(`*,
|
|
2
2
|
*::before,
|
|
3
3
|
*::after {
|
|
4
4
|
font-family: var(--shadow-claw-font-sans);
|
package/dist/public/{shadow-claw-networking-FQe4nCp3.js → shadow-claw-networking-qHbP95z9.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e}from"./txPromise-EBECky1b.js";import{m as t,t as n,x as r}from"./orchestrator-
|
|
1
|
+
import{n as e}from"./txPromise-EBECky1b.js";import{m as t,t as n,x as r}from"./orchestrator-3h9xxHUm.js";import{a as i,r as a,t as o}from"./toast-D3gxhZpN.js";import{t as s}from"./shadow-claw-element-DIrv3P6A.js";import{t as c}from"./effect-BEsuusE8.js";const l=new CSSStyleSheet;l.replaceSync(`*,
|
|
2
2
|
*::before,
|
|
3
3
|
*::after {
|
|
4
4
|
font-family: var(--shadow-claw-font-sans);
|
package/dist/public/{shadow-claw-notifications-DV2wibL3.js → shadow-claw-notifications-YyHOK2Fr.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./config-
|
|
1
|
+
import{r as e}from"./config-CrHchneq.js";import{n as t}from"./txPromise-EBECky1b.js";import{t as n}from"./getConfig-D89uJgo5.js";import{t as r}from"./setConfig-DFMYnYLE.js";import{i,n as a,r as o,t as s}from"./push-client-CrjEXK3U.js";import{r as c,t as l}from"./toast-D3gxhZpN.js";import{t as u}from"./shadow-claw-element-DIrv3P6A.js";import"./shadow-claw-empty-state-obMInUIf.js";const d=new CSSStyleSheet;d.replaceSync(`*,
|
|
2
2
|
*::before,
|
|
3
3
|
*::after {
|
|
4
4
|
font-family: var(--shadow-claw-font-sans);
|
package/dist/public/{shadow-claw-page-header-B63S4HTU.js → shadow-claw-page-header-DMKbkv3s.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{u as e}from"./custom-element-security-
|
|
1
|
+
import{u as e}from"./custom-element-security-NCqQ5lmC.js";import{t}from"./shadow-claw-element-DIrv3P6A.js";const n=new CSSStyleSheet;n.replaceSync(`*,
|
|
2
2
|
*::before,
|
|
3
3
|
*::after {
|
|
4
4
|
box-sizing: border-box;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./config-
|
|
1
|
+
import{r as e}from"./config-CrHchneq.js";import{a as t,n,o as r,r as i,s as a,u as o}from"./app-routes-Bs-riIvr.js";import{n as s}from"./txPromise-EBECky1b.js";import{t as c}from"./getConfig-D89uJgo5.js";import{d as l,i as u,l as d,n as f,r as p,s as m,u as h}from"./custom-element-security-NCqQ5lmC.js";import{n as g}from"./toast-60iDlgiH.js";import{_n as _,a as v,bn as y,c as b,mn as x,r as S,s as C,sn as w,t as T}from"./orchestrator-3h9xxHUm.js";import{t as ee}from"./buffer-9oRIc-5Z.js";import{a as te,r as E,t as D}from"./toast-D3gxhZpN.js";import{t as ne}from"./shadow-claw-element-DIrv3P6A.js";import{t as O}from"./effect-BEsuusE8.js";import{t as re}from"./config-value-oBfKgLT4.js";import"./shadow-claw-page-header-action-button-Bmua3mAb.js";import"./shadow-claw-page-header-DMKbkv3s.js";import{n as k,t as ie}from"./markdown-BnpKxSxl.js";import{t as ae}from"./file-viewer-D0eflgt6.js";import{a as A,c as oe,i as se,n as ce,o as le,r as ue,s as de,t as fe}from"./iframe-storage-proxy-B9Zt-vJ2.js";function pe(e,t,n){n&&(n.textContent=`Navigated to page: ${t||e.path}`)}function j(e,t){if(e===t||e===`main`&&t===`br:main`||e===`br:main`&&t===`main`)return!0;if(!e.includes(`:`)&&!t.includes(`:`))return!1;let n=e=>e.trim().replace(/:/g,`-`);return n(e)===n(t)}function M(e,i,a,s=typeof window<`u`?window.location.origin:``){let c=e.trim();if(!c||c.startsWith(`#`))return null;let l=c.split(/[?#]/,1)[0],u=l.replace(/^(?:\.\/)+/u,``),d=[];if(u.startsWith(`files/`)&&d.push(`/${u}`),l.startsWith(`/`)){let e=l.lastIndexOf(`/files/`);e>0&&d.push(l.slice(e)),d.push(l)}for(let e of d){let t=r(e);if(t&&j(t.groupId,a))return t.path}let f=o(c,n(t(a,i)),s||(typeof window<`u`?window.location.origin:``));if(!f||s&&f.origin!==s)return null;let p=r(f.pathname);return!p||!j(p.groupId,a)?null:p.path}function N(e,t,n,r,i=typeof window<`u`?window.location.origin:``){if(!e)return e;let s=i||(typeof window<`u`?window.location.origin:``),c=new DOMParser().parseFromString(e,`text/html`),l=(e,i)=>{let l=Array.from(c.querySelectorAll(e));for(let e of l){let c=(e.getAttribute(i)||``).trim();if(!c||c.startsWith(`#`)||c.startsWith(`javascript:`))continue;let l=o(c,n,s);!l||s&&l.origin!==s||i===`href`&&!(a(l.pathname)||M(c,t,r,s))||e.setAttribute(i,`${l.pathname}${l.search}${l.hash}`)}};return l(`a[href]`,`href`),l(`img[src]`,`src`),l(`audio[src]`,`src`),l(`video[src]`,`src`),l(`source[src]`,`src`),c.body.innerHTML}const me={ALLOWED_URI_REGEXP:/^(?:(?:https?|mailto|ftp|tel|file|blob|data):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,ADD_TAGS:[`iframe`,`figure`,`figcaption`],CUSTOM_ELEMENT_HANDLING:{tagNameCheck:e=>m(e),attributeNameCheck:()=>!0,allowCustomizedBuiltInElements:!1},ADD_ATTR:[`allow`,`allowfullscreen`,`frameborder`,`scrolling`,`referrerpolicy`,`loading`]};async function he({content:e,filePath:r,searchParams:i=``,groupId:a,origin:o=typeof window<`u`?window.location?.origin:``,sanitizeOptions:s=me,resolveRelativeImagesInHtmlFn:c}){let l=n(t(a,r)),u=N(e,r,l,a,o),m=d(c?await c(u,r,a):u,s),h=crypto.randomUUID().replace(/-/g,``),g=n(`/assets/file-viewer-preview-bridge.js`),_=n(`/assets/iframe-storage-bridge.js`),v=f(),y=p(h),b=typeof document<`u`?document.getElementById(`shadow-claw-site-config`):null,x=b&&b.textContent?`<script id="shadow-claw-site-config" type="application/json">${b.textContent}<\/script>`:``,S=i?`<script nonce="${h}">(function(){try{Object.defineProperty(window.location,"search",{get:function(){return ${JSON.stringify(i)};},configurable:true});}catch(e){}})();<\/script>`:``,C=v.map(e=>`<script type="module" src="${e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`//`)?e:n(e.startsWith(`/`)?e:`/${e.replace(/^pages\/main\//,``)}`)}" nonce="${h}"><\/script>`).join(`
|
|
2
2
|
`),w=`<link rel="stylesheet" href="${n(`/theme.css`)}">`;return[`<!doctype html>`,`<html class="${de()}"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">`,`<meta http-equiv="Content-Security-Policy" content="${y}">`,`<base href="${l}" target="_blank">`,S,x,`<script src="${_}" nonce="${h}"><\/script>`,`<script src="${g}" nonce="${h}"><\/script>`,oe(),w,C,`</head><body>`,m,`</body></html>`].join(``)}function ge(e,t){return t===0?{isPrevDisabled:!0,isNextDisabled:!0}:{isPrevDisabled:e<=0,isNextDisabled:e<0||e>=t-1}}async function _e(e,t,n=e=>T.removeAllPages(e)){return!e||!await t({title:`Remove All Pages`,message:`Remove ALL saved pages from Pages? This cannot be undone!`,confirmLabel:`Remove All`,cancelLabel:`Cancel`})?!1:(await n(e),!0)}const P={setItem:A,deleteItem:ce,clear:fe,getAll:se,getItem:ue,putItem:A};async function F(e,t,n,r=P){switch(e){case`setItem`:await r.setItem(n,String(t.key||``),t.value);return;case`removeItem`:await r.deleteItem(n,String(t.key||``));return;case`clear`:await r.clear(n);return;case`getAllItems`:return await r.getAll(n);case`idb-get`:return await r.getItem(`${n}::idb::${t.dbName}::${t.storeName}`,String(t.key||``));case`idb-getAll`:return await r.getAll(`${n}::idb::${t.dbName}::${t.storeName}`);case`idb-put`:{let e=t.key==null?`__auto_${Date.now()}`:String(t.key);return await r.putItem(`${n}::idb::${t.dbName}::${t.storeName}`,e,t.value),e}case`idb-delete`:await r.deleteItem(`${n}::idb::${t.dbName}::${t.storeName}`,String(t.key||``));return;case`idb-clear`:await r.clear(`${n}::idb::${t.dbName}::${t.storeName}`);return;case`idb-deleteDatabase`:await r.clear(`${n}::idb::${t.dbName}::__default__`);return;case`idb-count`:{let e=await r.getAll(`${n}::idb::${t.dbName}::${t.storeName}`);return Object.keys(e).length}default:throw Error(`Unknown storage proxy method: ${e}`)}}async function I(e,t,n,r,i,a=P){if(t)try{let o=await F(n,r,i,a);e.postMessage({type:`shadow-claw-storage-proxy-result`,requestId:t,result:o??null},`*`)}catch(n){e.postMessage({type:`shadow-claw-storage-proxy-result`,requestId:t,error:n instanceof Error?n.message:String(n)},`*`)}}function ve({root:e,rendered:t,selectedPath:n,onIframeLoad:r}){let i=e.querySelector(`[data-pages-iframe]`);if(i instanceof HTMLIFrameElement)return i;let a=document.createElement(`iframe`);return a.className=`pages__iframe`,a.setAttribute(`data-pages-iframe`,``),a.setAttribute(`title`,n?`Preview: ${n}`:`Page preview`),a.setAttribute(`sandbox`,u()),a.setAttribute(`allow`,`fullscreen`),a.hidden=!0,r&&a.addEventListener(`load`,()=>{r(a.contentWindow)}),t.before(a),a}function L(e){if(typeof e==`string`||typeof e==`number`){let t=parseInt(String(e),10);if(!isNaN(t)&&t>=0)return Math.min(t,86400)}return 0}async function ye(t,n=c){if(!t)return 0;try{return L(await n(t,e.PAGES_AUTO_REFRESH_INTERVAL))}catch{return 0}}function R(e){if(!e)return``;let t=e.groupId;return t===`main`&&(t=`br:main`),`${t}\u0000${e.path}`}function z(e,t=[]){if(!e)return-1;let n=R(e);return t.findIndex(e=>R(e)===n)}function be(e=[]){let t=new Map;return e.forEach(e=>{let n=t.get(e.groupId)||[];n.push(e),t.set(e.groupId,n)}),t}function xe(e,t){if(!t||t.hidden)return!1;let n=e.replace(/^#/,``),r=t.querySelector(`[id="${n}"]`)||t.querySelector(`a[name="${n}"]`);return r?(r.scrollIntoView({behavior:`smooth`,block:`start`}),!0):!1}function Se(e){let t=e.detail;return t&&t.interval!==void 0?L(t.interval):null}function Ce(e,t){return!e||!t||!e.groupId||!e.path||e.path!==t.path?!1:e.groupId===t.groupId||j(e.groupId,t.groupId)}function we(e,t){let n=e.detail;return Ce(n,t)}function B(e,t){let n=[`data-no-nav`,`data-no-swipe`,`data-no-page-nav`,`data-prevent-nav`,`data-prevent-page-nav`,`data-isolate-input`,`data-isolate-navigation`,`data-game-controls`],r=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase();return!!(t===`input`||t===`textarea`||t===`select`||t===`option`||t===`iframe`||e.classList.contains(`pages__preview-frame`)||e.isContentEditable||e.contentEditable===`true`||e.getAttribute(`contenteditable`)===`true`||e.hasAttribute(`contenteditable`)||e.closest(`[data-pages-list]`)||e.closest(`[data-pages-dropdown]`)||e.closest(`.pages__sidebar`)||e.closest(`.pages__preview-frame`)||e.closest(`iframe`)||n.some(t=>e.closest(`[${t}]`)))};if(t&&r(t))return!0;if(e){let t=typeof e.composedPath==`function`?e.composedPath():[];for(let e of t)if(e instanceof HTMLElement){let t=e.tagName.toLowerCase();if(n.some(t=>e.hasAttribute(t))||t===`input`||t===`textarea`||t===`select`||t===`option`||t===`iframe`||e.classList.contains(`pages__preview-frame`)||e.isContentEditable||e.contentEditable===`true`||e.getAttribute(`contenteditable`)===`true`||e.hasAttribute(`contenteditable`))return!0}if(e.target&&r(e.target))return!0}return!1}function Te(e,t){return t||e.key!==`ArrowLeft`&&e.key!==`ArrowRight`||e.ctrlKey||e.altKey||e.metaKey?null:e.key===`ArrowLeft`?`previous`:`next`}function Ee(e,t,n,r){if(!t)return;let i=n?.activeElement||document.activeElement,a=Te(e,B(e,e.target||null)||B(void 0,i));a&&(e.preventDefault(),r(a))}function De(e,t,n=Date.now()){return e.button!==0||t?{mouseStartX:0,mouseStartY:0,mouseStartTime:0,isMouseDown:!1}:{mouseStartX:e.clientX,mouseStartY:e.clientY,mouseStartTime:n,isMouseDown:!0}}function V(e,t,n,r,i,a=Date.now(),o=50,s=600){let c=n-e,l=r-t,u=a-i;return Math.abs(c)>=o&&Math.abs(c)>Math.abs(l)&&u<=s?c<0?`next`:`previous`:null}function Oe(e,t,n,r,i=Date.now()){return!t.isMouseDown||n||r?null:V(t.mouseStartX,t.mouseStartY,e.clientX,e.clientY,t.mouseStartTime,i)}function ke(e,t,n){if(t===n||t<0||t>=e.length||n<0||n>=e.length)return e;let r=[...e],[i]=r.splice(t,1);return r.splice(n,0,i),r}async function Ae({db:e,currentPages:t,fromIndex:n,toIndex:r,reorderStoreFn:i=(e,t)=>T.reorderPages(e,t)}){if(!e||n===r)return{reordered:!1,reorderedPages:t,movedToFirst:null};let a=ke(t,n,r);if(a===t)return{reordered:!1,reorderedPages:t,movedToFirst:null};await i(e,a);let o=a[r]||null;return{reordered:!0,reorderedPages:a,movedToFirst:r===0?o:null}}function je(e,t,n,r=Date.now()){if(!t.touchStartTime||n)return null;if(e.changedTouches&&e.changedTouches.length===1){let n=e.changedTouches[0].clientX,i=e.changedTouches[0].clientY;return V(t.touchStartX,t.touchStartY,n,i,t.touchStartTime,r)}return null}function Me(e,t,n=Date.now()){return t?{touchStartX:0,touchStartY:0,touchStartTime:0}:e.touches&&e.touches.length===1?{touchStartX:e.touches[0].clientX,touchStartY:e.touches[0].clientY,touchStartTime:n}:null}function Ne(e,t,n){return!e&&t?`render-and-timer`:e&&n?`clear-timer`:`noop`}function Pe(e,t){return!e&&t}function Fe(e){return/\.(html?|xhtml)$/iu.test(e)}function Ie(e){return/\.(md|markdown)$/iu.test(e)}function Le(e){if(!e||typeof e!=`object`)return null;let t=e;return t.type===`shadow-claw-broadcast-result`&&typeof t.channel==`string`?{kind:`broadcast-result`,channel:t.channel,payload:t.payload}:t.type===`shadow-claw-storage-proxy`?{kind:`storage-proxy`,requestId:String(t.requestId||``),method:String(t.method||``),args:t.args&&typeof t.args==`object`?t.args:{}}:t.type===`shadow-claw-swipe`&&typeof t.direction==`string`?{kind:`swipe`,direction:t.direction}:t.type===`shadow-claw-iframe-resize`&&typeof t.height==`number`?{kind:`iframe-resize`,height:t.height}:t.type===`shadow-claw-file-viewer-link`&&typeof t.href==`string`?{kind:`file-viewer-link`,href:t.href}:null}var H=ee();function U(e){return{apng:`image/apng`,avif:`image/avif`,gif:`image/gif`,jpg:`image/jpeg`,jpeg:`image/jpeg`,png:`image/png`,svg:`image/svg+xml`,webp:`image/webp`}[e]??`image/jpeg`}async function Re({db:e,groupId:t,workspacePath:r,readGroupFileBytesFn:i=y,writeGroupFileFn:a=w,fetchFn:o=typeof fetch<`u`?fetch:void 0}){if(e)try{let n=await i(e,t,r),a=U(r.split(`.`).pop()?.toLowerCase()||``),o=new Uint8Array(n.byteLength);return o.set(new Uint8Array(n)),`data:${a};base64,${H.Buffer.from(o).toString(`base64`)}`}catch{}if(!o)return null;try{let i=r.replace(/^\/+/,``),s=[n(`/files/main/${i}`),n(`/static-main/${i}`),n(`/pages/main/${i}`)];for(let n of s)try{let i=await o(typeof window<`u`&&window.location?.origin?new URL(n,window.location.origin).toString():n);if(i.ok){let n=await i.blob();if(e)try{let i=await n.arrayBuffer();await a(e,t,r,new Uint8Array(i))}catch{}if(typeof FileReader<`u`)return await new Promise((e,t)=>{let r=new FileReader;r.onload=()=>e(r.result),r.onerror=t,r.readAsDataURL(n)});let o=await n.arrayBuffer(),s=H.Buffer.from(o).toString(`base64`);return`data:${n.type||U(r.split(`.`).pop()||``)};base64,${s}`}}catch{}}catch{}return null}function W(e){let t=e.querySelector(`[data-pages-iframe]`);t instanceof HTMLIFrameElement&&(t.removeAttribute(`srcdoc`),t.remove())}async function G(e,t=typeof document<`u`?document.querySelector(`shadow-claw`):null,n=te){return t&&typeof t.requestDialog==`function`?await t.requestDialog({mode:`confirm`,...e}):(n(e.message,4500),!1)}async function ze(e,t,n=c){if(!e||typeof e.transaction!=`function`)return!0;try{return re(await n(e,t),!0)}catch{return!0}}function Be(e,t,n=[]){if(e===t||j(e,t))return t;let r=n.find(t=>t.groupId===e);if(r)return r.groupId;let i=n.find(t=>j(e,t.groupId));return i?i.groupId:e||null}function Ve(e,t,n,i=[],a=typeof window<`u`?window.location.origin:``){let o=e.trim();if(!o||o.startsWith(`#`))return null;let s=[],c=o.split(/[?#]/,1)[0];if(/^[a-zA-Z][a-zA-Z\d+.-]*:/u.test(c)||c.startsWith(`//`)){let e;try{e=new URL(c,a||(typeof window<`u`?window.location.origin:``))}catch{return null}if(a&&e.origin!==a)return null;c=e.pathname}let l=c.replace(/^(?:\.\/)+/u,``);if(l.startsWith(`files/`)&&s.push(`/${l}`),c.startsWith(`/`)){let e=c.lastIndexOf(`/files/`);e>0&&s.push(c.slice(e)),s.push(c)}for(let e of s){let t=r(e);if(!t)continue;let a=Be(t.groupId,n,i);if(a)return{groupId:a,path:t.path}}let u=M(o,t,n,a);return u?{groupId:n,path:u}:null}async function He({container:e,groupId:t,filePath:n,groups:r,readImageAsDataUrlFn:i}){let a=Array.from(e.querySelectorAll(`img[src]`));a.length!==0&&await Promise.all(a.map(async e=>{let a=e.getAttribute(`src`)||``;if(!a||/^(?:blob:|data:|#)/u.test(a))return;let o=Ve(a,n,t,r);if(!o)return;let s=await i(o.groupId,o.path);s&&e.setAttribute(`src`,s)}))}function K(e,t,n){return e>0&&!t&&n}function Ue(e){if(!e)return;let t=typeof document<`u`&&document.documentElement.classList.contains(`dark-mode`),n={};if(typeof document<`u`&&typeof getComputedStyle<`u`){let e=getComputedStyle(document.documentElement);for(let t=0;t<e.length;t++){let r=e[t];r.startsWith(`--`)&&(n[r]=e.getPropertyValue(r))}}e.postMessage({type:`shadow-claw-theme-update`,theme:t?`dark`:`light`,customProperties:n},`*`)}function q({root:e,currentOpen:t,force:n}){if(!e)return t;let r=e.querySelector(`[data-pages-dropdown]`),i=r instanceof HTMLDetailsElement&&r.open,a;a=n===void 0?!(i||t):n;let o=e.querySelector(`.pages__sidebar`),s=e.querySelector(`.pages__content`);return o&&o.classList.toggle(`collapsed`,!a),s&&s.classList.toggle(`pages__content--sidebar-collapsed`,!a),r instanceof HTMLDetailsElement&&(a?r.setAttribute(`open`,``):r.removeAttribute(`open`)),a}const J=new CSSStyleSheet;J.replaceSync(`* {
|
|
3
3
|
box-sizing: border-box;
|
|
4
4
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./config-
|
|
1
|
+
import{r as e}from"./config-CrHchneq.js";import{n as t}from"./txPromise-EBECky1b.js";import{h as n}from"./custom-element-security-NCqQ5lmC.js";import{Z as r,a as i,c as a,ln as o,t as s}from"./orchestrator-3h9xxHUm.js";import{n as c,r as l}from"./crypto-C8c5wMzN.js";import{n as u,r as d,t as f}from"./toast-D3gxhZpN.js";import{t as p}from"./shadow-claw-element-DIrv3P6A.js";import{t as m}from"./config-value-oBfKgLT4.js";import"./shadow-claw-page-header-DMKbkv3s.js";import"./shadow-claw-dialog-BrOwAOdk.js";function h(e){try{return JSON.parse(JSON.stringify(e))}catch{return null}}async function g(t,n){let r=[],i=[];for(let a of t){let t=a.key;if(t===e.STORAGE_HANDLE)continue;if(t===e.GIT_PASSWORD||t===e.API_KEY||t.startsWith(`api_key:`)||t===e.IMESSAGE_API_KEY||t===e.TELEGRAM_BOT_TOKEN){if(n&&typeof a.value==`string`){let e=await c(a.value);e&&i.push({key:t,path:[],value:e})}continue}let o=h(a.value);if(t===e.GIT_ACCOUNTS&&Array.isArray(o))for(let e=0;e<o.length;e+=1){let r=o[e];if(!r||typeof r!=`object`)continue;let a=r.password;if(typeof a==`string`&&a){if(n){let n=await c(a);n&&i.push({key:t,path:[e,`password`],value:n})}delete r.password}}if(t===e.INTEGRATION_CONNECTIONS&&Array.isArray(o))for(let e=0;e<o.length;e+=1){let r=o[e]?.credentialRef,a=r?.encryptedSecret;if(typeof a==`string`&&a){if(n){let n=await c(a);n&&i.push({key:t,path:[e,`credentialRef`,`encryptedSecret`],value:n})}delete r.encryptedSecret}}if(t===e.REMOTE_MCP_CONNECTIONS&&Array.isArray(o))for(let e=0;e<o.length;e+=1){let r=o[e]?.credentialRef,a=r?.encryptedValue;if(typeof a==`string`&&a){if(n){let n=await c(a);n&&i.push({key:t,path:[e,`credentialRef`,`encryptedValue`],value:n})}delete r.encryptedValue}}r.push({key:t,value:o})}return{configEntries:r,plaintextPasswords:i}}function _(e,t,n){if(t.length===0)return n;let r=e;for(let n=0;n<t.length-1;n+=1){let i=t[n];if(typeof i==`number`){if(!Array.isArray(r)||!r[i])return e;r=r[i]}else{if(!r||typeof r!=`object`)return e;let t=r[i];if(!t||typeof t!=`object`)return e;r=t}}let i=t[t.length-1];if(typeof i==`number`){if(!Array.isArray(r))return e;r[i]=n}else{if(!r||typeof r!=`object`)return e;r[i]=n}return e}async function v(e,t){let n=await g(e,t);return{kind:`shadowclaw-settings-backup`,version:1,exportedAt:Date.now(),includePlaintextPasswords:t,configEntries:n.configEntries,plaintextPasswords:t?n.plaintextPasswords:void 0}}async function y(e,t){let n=await v(e,t);return new Blob([JSON.stringify(n,null,2)],{type:`application/json`})}async function b(e,t,n){let r=await v(t,n);await o(e,JSON.stringify(r,null,2))}async function x(e,t){if(!t.length)return e;let n=e.map(e=>({key:e.key,value:h(e.value)}));for(let e of t){let t=await l(e.value);if(!t)continue;let r=n.find(t=>t.key===e.key);r?r.value=_(r.value,e.path,t):e.path.length===0&&n.push({key:e.key,value:t})}return n}function S(e){let t=JSON.parse(e);if(t?.kind!==`shadowclaw-settings-backup`||t.version!==1||!Array.isArray(t.configEntries))throw Error(`Invalid settings backup file`);let n=Array.isArray(t.plaintextPasswords)?t.plaintextPasswords.filter(e=>e&&typeof e.key==`string`&&Array.isArray(e.path)&&typeof e.value==`string`):[];return{kind:`shadowclaw-settings-backup`,version:1,exportedAt:typeof t.exportedAt==`number`?t.exportedAt:Date.now(),includePlaintextPasswords:!!t.includePlaintextPasswords,configEntries:t.configEntries.filter(e=>e&&typeof e.key==`string`).map(e=>({key:e.key,value:e.value})),plaintextPasswords:n}}const C=new CSSStyleSheet;C.replaceSync(`*,
|
|
2
2
|
*::before,
|
|
3
3
|
*::after {
|
|
4
4
|
font-family: var(--shadow-claw-font-sans);
|
|
@@ -833,6 +833,13 @@ import{r as e}from"./config-BYAuxx3j.js";import{n as t}from"./txPromise-EBECky1b
|
|
|
833
833
|
</div>
|
|
834
834
|
</details>
|
|
835
835
|
|
|
836
|
+
<details class="settings-collapsible">
|
|
837
|
+
<summary>🎛️ Control Plane</summary>
|
|
838
|
+
<div class="settings-collapsible-content">
|
|
839
|
+
<shadow-claw-control-plane></shadow-claw-control-plane>
|
|
840
|
+
</div>
|
|
841
|
+
</details>
|
|
842
|
+
|
|
836
843
|
<details class="settings-collapsible">
|
|
837
844
|
<summary>📧 Email</summary>
|
|
838
845
|
<div class="settings-collapsible-content">
|
|
@@ -878,7 +885,7 @@ import{r as e}from"./config-BYAuxx3j.js";import{n as t}from"./txPromise-EBECky1b
|
|
|
878
885
|
</div>
|
|
879
886
|
</div>
|
|
880
887
|
</template>
|
|
881
|
-
`,`text/html`),T=w.querySelector(`template`);let E=[];E=T?Array.from(T.content.children):Array.from(w.head.children).concat(Array.from(w.body.children));var D=E;const O={ai:[()=>import(`./shadow-claw-llm-6Aci1BDP.js`)],environment:[()=>import(`./shadow-claw-networking-FQe4nCp3.js`),()=>import(`./shadow-claw-webvm-BH8mPDEu.js`),()=>import(`./shadow-claw-storage-DaacA3_K.js`)],integrations:[()=>import(`./shadow-claw-git-DRA7_qck.js`),()=>import(`./shadow-claw-accounts-CZvz4iQz.js`),()=>import(`./shadow-claw-mcp-remote-BUjAeVXC.js`),()=>import(`./shadow-claw-integrations-1Xu5snuV.js`),()=>import(`./shadow-claw-task-server-IjKX042p.js`),()=>import(`./shadow-claw-notifications-DV2wibL3.js`)]},k=new Set;async function A(e){if(k.has(e))return;let t=O[e];t&&(k.add(e),await Promise.all(t.map(e=>e())))}const j=`shadow-claw-settings`;var M=class extends p{static styles=C;static template=D;activeTab=`ai`;db=null;orchestrator=null;pendingRestoreFile=null;constructor(){super()}async connectedCallback(){if(!this.shadowRoot)throw Error(`shadowRoot not found`);this.db=await t(),this.orchestrator=s.orchestrator,await this.render()}activateTab(e){!e||this.activeTab===e||(this.activeTab=e,this.applyTabState())}applyTabState(){A(this.activeTab).catch(console.error);let e=this.shadowRoot;e&&(e.querySelectorAll(`[data-tab-target]`).forEach(e=>{let t=e.dataset.tabTarget===this.activeTab;e.classList.toggle(`active`,t),e.setAttribute(`aria-selected`,String(t)),e.tabIndex=t?0:-1}),e.querySelectorAll(`[data-tab-panel]`).forEach(e=>{e.hidden=e.dataset.tabPanel!==this.activeTab}))}bindSettingsActions(){let e=this.shadowRoot;if(!e)return;e.querySelector(`[data-action="backup-settings"]`)?.addEventListener(`click`,()=>this.openBackupDialog());let t=e.querySelector(`.settings__restore-input`);e.querySelector(`[data-action="restore-settings"]`)?.addEventListener(`click`,()=>{t instanceof HTMLInputElement&&(t.value=``,t.click())}),t?.addEventListener(`change`,e=>{let t=e.target;if(!(t instanceof HTMLInputElement))return;let n=t.files?.[0]||null;n&&(this.pendingRestoreFile=n,this.openRestoreDialog(n.name))}),e.querySelector(`[data-action="clear-settings"]`)?.addEventListener(`click`,()=>this.openClearDialog()),e.querySelector(`[data-action="cancel-backup-settings"]`)?.addEventListener(`click`,()=>this.closeDialog(`.settings__backup-dialog`)),e.querySelector(`[data-action="confirm-backup-settings"]`)?.addEventListener(`click`,()=>{this.confirmBackup()}),e.querySelector(`[data-action="cancel-restore-settings"]`)?.addEventListener(`click`,()=>{this.pendingRestoreFile=null,this.closeDialog(`.settings__restore-dialog`)}),e.querySelector(`[data-action="confirm-restore-settings"]`)?.addEventListener(`click`,()=>{this.confirmRestore()}),e.querySelector(`[data-action="cancel-clear-settings"]`)?.addEventListener(`click`,()=>this.closeDialog(`.settings__clear-dialog`)),e.querySelector(`[data-action="confirm-clear-settings"]`)?.addEventListener(`click`,()=>{this.confirmClear()}),e.querySelector(`[data-action="save-assistant-name"]`)?.addEventListener(`click`,()=>this.saveAssistantName()),e.querySelector(`[data-setting="activity-log-disk-logging-toggle"]`)?.addEventListener(`change`,e=>{let t=e.target;t&&this.onActivityLogDiskLoggingToggle(t.checked)}),e.querySelector(`[data-setting="sidebar-hide-pages-toggle"]`)?.addEventListener(`change`,e=>{let t=e.target;t&&this.onSidebarHidePagesToggle(t.checked)}),e.querySelector(`[data-setting="sidebar-hide-chat-toggle"]`)?.addEventListener(`change`,e=>{let t=e.target;t&&this.onSidebarHideChatToggle(t.checked)}),e.querySelector(`[data-setting="sidebar-hide-tasks-toggle"]`)?.addEventListener(`change`,e=>{let t=e.target;t&&this.onSidebarHideTasksToggle(t.checked)}),e.querySelector(`[data-setting="sidebar-hide-files-toggle"]`)?.addEventListener(`change`,e=>{let t=e.target;t&&this.onSidebarHideFilesToggle(t.checked)}),e.querySelector(`[data-setting="chat-split-view-toggle"]`)?.addEventListener(`change`,e=>{let t=e.target;t&&this.onChatSplitViewToggle(t.checked)}),e.querySelector(`[data-setting="pages-auto-refresh-input"]`)?.addEventListener(`change`,e=>{let t=e.target;if(t){let e=parseInt(t.value,10);this.onPagesAutoRefreshInputChange(isNaN(e)?0:e)}}),e.querySelector(`[data-setting="override-prerender-skeleton-toggle"]`)?.addEventListener(`change`,e=>{let t=e.target;t&&this.onOverridePrerenderSkeletonToggle(t.checked)}),e.querySelector(`[data-action="save-dom-allowed-iframe-hosts"]`)?.addEventListener(`click`,()=>{this.saveDomAllowedIframeHosts()})}closeDialog(e){this.getDialog(e)?.close()}getDialog(e){let t=this.shadowRoot;if(!t)return null;let n=t.querySelector(e);return n instanceof HTMLDialogElement?n:null}handleTabKeydown(e,t){let n=this.shadowRoot;if(!n)return;let r=Array.from(n.querySelectorAll(`[data-tab-target]`)),i=r.indexOf(t);if(i<0)return;let a=-1;switch(e.key){case`ArrowRight`:case`ArrowDown`:a=(i+1)%r.length;break;case`ArrowLeft`:case`ArrowUp`:a=(i-1+r.length)%r.length;break;case`Home`:a=0;break;case`End`:a=r.length-1;break;default:return}e.preventDefault();let o=r[a];o.focus(),this.activateTab(o.dataset.tabTarget)}openBackupDialog(){let e=this.shadowRoot?.querySelector(`[data-setting="include-plaintext-passwords"]`);e instanceof HTMLInputElement&&(e.checked=!1),this.showDialog(`.settings__backup-dialog`)}openClearDialog(){this.showDialog(`.settings__clear-dialog`)}openRestoreDialog(e){let t=this.shadowRoot?.querySelector(`[data-info="restore-filename"]`);t instanceof HTMLElement&&(t.textContent=`Selected file: ${e}`),this.showDialog(`.settings__restore-dialog`)}showDialog(e){let t=this.getDialog(e);if(t){if(typeof t.showModal==`function`){t.showModal();return}t.setAttribute(`open`,``)}}async confirmBackup(){if(!this.db){f(`Settings database is unavailable`,5e3);return}let e=this.shadowRoot?.querySelector(`[data-setting="include-plaintext-passwords"]`),t=e instanceof HTMLInputElement&&e.checked;try{if(t){let e=await this.promptForPlaintextBackupHandle();if(!e)return;await b(e,await this.getAllConfigEntries(),t),this.closeDialog(`.settings__backup-dialog`),d(`Settings backup saved`,3e3);return}let e=await y(await this.getAllConfigEntries(),t),n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=`shadowclaw-settings-backup-${Date.now()}.json`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n),this.closeDialog(`.settings__backup-dialog`),d(`Settings backup downloaded`,3e3)}catch(e){f(`Failed to backup settings: ${e instanceof Error?e.message:String(e)}`,6e3)}}async confirmClear(){if(!this.db){f(`Settings database is unavailable`,5e3);return}try{await this.replaceConfigEntries([]),this.closeDialog(`.settings__clear-dialog`),u(`Settings cleared. Reloading app...`,3200),setTimeout(()=>{window.location.reload()},250)}catch(e){f(`Failed to clear settings: ${e instanceof Error?e.message:String(e)}`,6e3)}}async confirmRestore(){if(!this.db){f(`Settings database is unavailable`,5e3);return}let e=this.pendingRestoreFile;if(!e){f(`No backup file selected`,4e3);return}try{let t=S(await e.text()),n=await x(t.configEntries,t.plaintextPasswords||[]);await this.replaceConfigEntries(n),this.pendingRestoreFile=null,this.closeDialog(`.settings__restore-dialog`),d(`Settings restored. Reloading app...`,3200),setTimeout(()=>{window.location.reload()},250)}catch(e){f(`Failed to restore settings: ${e instanceof Error?e.message:String(e)}`,6e3)}}async getAllConfigEntries(){if(!this.db)throw Error(`Database is unavailable`);return await new Promise((e,t)=>{try{let n=this.db?.transaction(`config`,`readonly`);if(!n){t(Error(`Failed to open read transaction`));return}let r=n.objectStore(`config`).getAll();r.onsuccess=()=>{e((Array.isArray(r.result)?r.result:[]).filter(e=>e&&typeof e.key==`string`).map(e=>({key:e.key,value:e.value})))},r.onerror=()=>{t(r.error||Error(`Failed to read settings config`))}}catch(e){t(e)}})}async onActivityLogDiskLoggingToggle(t){if(this.db)try{let{setConfig:n}=await import(`./setConfig-DFMYnYLE.js`).then(e=>e.n);await n(this.db,e.ACTIVITY_LOG_DISK_LOGGING_ENABLED,t?`true`:`false`),d(t?`Activity log disk logging enabled`:`Activity log disk logging disabled`,2500)}catch(e){f(`Error saving activity log disk logging setting: `+(e instanceof Error?e.message:String(e)),6e3)}}async onChatSplitViewToggle(t){if(this.db)try{let{setConfig:n}=await import(`./setConfig-DFMYnYLE.js`).then(e=>e.n);await n(this.db,e.CHAT_SPLIT_VIEW_ENABLED,t?`true`:`false`),this.dispatchEvent(new CustomEvent(`chat-split-view-change`,{detail:{enabled:t},bubbles:!0,composed:!0})),d(t?`Horizontal Chat split view enabled`:`Horizontal Chat split view disabled`,2500)}catch(e){f(`Error saving Chat split view setting: `+(e instanceof Error?e.message:String(e)),6e3)}}async onOverridePrerenderSkeletonToggle(t){try{a(`shadow-claw-override-prerender-skeleton`,t?`true`:`false`)}catch(e){console.warn(`Unable to save setting to localStorage:`,e)}if(this.db)try{let{setConfig:n}=await import(`./setConfig-DFMYnYLE.js`).then(e=>e.n);await n(this.db,e.OVERRIDE_PRERENDER_SKELETON,t?`true`:`false`),d(t?`Pre-rendered content override enabled`:`Pre-rendered content override disabled`,2500)}catch(e){f(`Error saving pre-rendered content override setting: `+(e instanceof Error?e.message:String(e)),6e3)}}async onPagesAutoRefreshInputChange(t){if(!this.db)return;let n=Math.max(0,Math.min(t,86400));try{let{setConfig:t}=await import(`./setConfig-DFMYnYLE.js`).then(e=>e.n);await t(this.db,e.PAGES_AUTO_REFRESH_INTERVAL,String(n)),window.dispatchEvent(new CustomEvent(`shadow-claw-pages-auto-refresh-change`,{detail:{interval:n}})),d(n>0?`Pages auto refresh set to ${n}s`:`Pages auto refresh disabled`,2500)}catch(e){f(`Error saving Pages auto refresh interval: `+(e instanceof Error?e.message:String(e)),6e3)}}async onSidebarHideChatToggle(t){if(this.db)try{let{setConfig:n}=await import(`./setConfig-DFMYnYLE.js`).then(e=>e.n);await n(this.db,e.SIDEBAR_CHAT_HIDDEN,t?`true`:`false`),this.dispatchEvent(new CustomEvent(`sidebar-chat-visibility-change`,{detail:{hidden:t},bubbles:!0,composed:!0})),d(t?`Chat hidden in sidebar`:`Chat shown in sidebar`,2500)}catch(e){f(`Error saving sidebar Chat visibility: `+(e instanceof Error?e.message:String(e)),6e3)}}async onSidebarHideFilesToggle(t){if(this.db)try{let{setConfig:n}=await import(`./setConfig-DFMYnYLE.js`).then(e=>e.n);await n(this.db,e.SIDEBAR_FILES_HIDDEN,t?`true`:`false`),this.dispatchEvent(new CustomEvent(`sidebar-files-visibility-change`,{detail:{hidden:t},bubbles:!0,composed:!0})),d(t?`Files hidden in sidebar`:`Files shown in sidebar`,2500)}catch(e){f(`Error saving sidebar Files visibility: `+(e instanceof Error?e.message:String(e)),6e3)}}async onSidebarHidePagesToggle(t){if(this.db)try{let{setConfig:n}=await import(`./setConfig-DFMYnYLE.js`).then(e=>e.n);await n(this.db,e.SIDEBAR_PAGES_HIDDEN,t?`true`:`false`),this.dispatchEvent(new CustomEvent(`sidebar-pages-visibility-change`,{detail:{hidden:t},bubbles:!0,composed:!0})),d(t?`Pages hidden in sidebar`:`Pages shown in sidebar`,2500)}catch(e){f(`Error saving sidebar Pages visibility: `+(e instanceof Error?e.message:String(e)),6e3)}}async onSidebarHideTasksToggle(t){if(this.db)try{let{setConfig:n}=await import(`./setConfig-DFMYnYLE.js`).then(e=>e.n);await n(this.db,e.SIDEBAR_TASKS_HIDDEN,t?`true`:`false`),this.dispatchEvent(new CustomEvent(`sidebar-tasks-visibility-change`,{detail:{hidden:t},bubbles:!0,composed:!0})),d(t?`Tasks hidden in sidebar`:`Tasks shown in sidebar`,2500)}catch(e){f(`Error saving sidebar Tasks visibility: `+(e instanceof Error?e.message:String(e)),6e3)}}async populateAssistantSettings(){let t=this.shadowRoot;if(!t||!this.db)return;let n=t.querySelector(`[data-setting="assistant-name-input"]`);if(n){let{getConfig:t}=await import(`./getConfig-D89uJgo5.js`).then(e=>e.n),r=await t(this.db,e.ASSISTANT_NAME),i=this.orchestrator?.assistantName||s.orchestrator?.assistantName;n.value=typeof r==`string`&&r||i||`ShadowClaw`}let{getConfig:r}=await import(`./getConfig-D89uJgo5.js`).then(e=>e.n),o=await r(this.db,e.ACTIVITY_LOG_DISK_LOGGING_ENABLED),c=o===!0||o===`true`||o===1||o===`1`,l=t.querySelector(`[data-setting="activity-log-disk-logging-toggle"]`);l&&(l.checked=c);let u=await r(this.db,e.SIDEBAR_PAGES_HIDDEN),d=u===!0||u===`true`||u===1||u===`1`,f=t.querySelector(`[data-setting="sidebar-hide-pages-toggle"]`);f&&(f.checked=d);let p=await r(this.db,e.SIDEBAR_CHAT_HIDDEN),h=p===!0||p===`true`||p===1||p===`1`,g=t.querySelector(`[data-setting="sidebar-hide-chat-toggle"]`);g&&(g.checked=h);let _=await r(this.db,e.SIDEBAR_TASKS_HIDDEN),v=_===!0||_===`true`||_===1||_===`1`,y=t.querySelector(`[data-setting="sidebar-hide-tasks-toggle"]`);y&&(y.checked=v);let b=await r(this.db,e.SIDEBAR_FILES_HIDDEN),x=b===!0||b===`true`||b===1||b===`1`,S=t.querySelector(`[data-setting="sidebar-hide-files-toggle"]`);S&&(S.checked=x);let C=m(await r(this.db,e.CHAT_SPLIT_VIEW_ENABLED),!1),w=t.querySelector(`[data-setting="chat-split-view-toggle"]`);w&&(w.checked=C);let T=t.querySelector(`[data-setting="pages-auto-refresh-input"]`);if(T){let t=await r(this.db,e.PAGES_AUTO_REFRESH_INTERVAL);if(typeof t==`string`||typeof t==`number`){let e=parseInt(String(t),10);T.value=!isNaN(e)&&e>=0?String(e):`0`}else T.value=`0`}let E=await r(this.db,e.OVERRIDE_PRERENDER_SKELETON),D=null;try{D=i(`shadow-claw-override-prerender-skeleton`)}catch{}let O=!0;if(E==null?D!==null&&(O=D===`true`):O=m(E),O)try{a(`shadow-claw-override-prerender-skeleton`,`true`)}catch{}let k=t.querySelector(`[data-setting="override-prerender-skeleton-toggle"]`);k&&(k.checked=O);let A=t.querySelector(`[data-setting="dom-allowed-iframe-hosts"]`);if(A){let t=await r(this.db,e.ALLOWED_IFRAME_HOST_PATTERNS);if(typeof t==`string`&&t.trim().length>0){A.value=t;let{setAllowedIframeHostPatterns:e}=await import(`./iframe-sanitizer-0NS4XLOd.js`).then(e=>e.r);e(t)}else{let{DEFAULT_ALLOWED_IFRAME_HOST_PATTERNS:e}=await import(`./iframe-sanitizer-0NS4XLOd.js`).then(e=>e.r);A.value=e.join(`
|
|
888
|
+
`,`text/html`),T=w.querySelector(`template`);let E=[];E=T?Array.from(T.content.children):Array.from(w.head.children).concat(Array.from(w.body.children));var D=E;const O={ai:[()=>import(`./shadow-claw-llm-GWgoVfhI.js`)],environment:[()=>import(`./shadow-claw-networking-qHbP95z9.js`),()=>import(`./shadow-claw-webvm-BCS8ykeP.js`),()=>import(`./shadow-claw-storage-BFynbP0j.js`)],integrations:[()=>import(`./shadow-claw-git-v8S0JjuR.js`),()=>import(`./shadow-claw-accounts-B4sBTQEj.js`),()=>import(`./shadow-claw-mcp-remote-kY4LMFNN.js`),()=>import(`./shadow-claw-control-plane-CX1IGbh9.js`),()=>import(`./shadow-claw-integrations-D7ufpwhX.js`),()=>import(`./shadow-claw-task-server-3BIeb5oZ.js`),()=>import(`./shadow-claw-notifications-YyHOK2Fr.js`)]},k=new Set;async function A(e){if(k.has(e))return;let t=O[e];t&&(k.add(e),await Promise.all(t.map(e=>e())))}const j=`shadow-claw-settings`;var M=class extends p{static styles=C;static template=D;activeTab=`ai`;db=null;orchestrator=null;pendingRestoreFile=null;constructor(){super()}async connectedCallback(){if(!this.shadowRoot)throw Error(`shadowRoot not found`);this.db=await t(),this.orchestrator=s.orchestrator,await this.render()}activateTab(e){!e||this.activeTab===e||(this.activeTab=e,this.applyTabState())}applyTabState(){A(this.activeTab).catch(console.error);let e=this.shadowRoot;e&&(e.querySelectorAll(`[data-tab-target]`).forEach(e=>{let t=e.dataset.tabTarget===this.activeTab;e.classList.toggle(`active`,t),e.setAttribute(`aria-selected`,String(t)),e.tabIndex=t?0:-1}),e.querySelectorAll(`[data-tab-panel]`).forEach(e=>{e.hidden=e.dataset.tabPanel!==this.activeTab}))}bindSettingsActions(){let e=this.shadowRoot;if(!e)return;e.querySelector(`[data-action="backup-settings"]`)?.addEventListener(`click`,()=>this.openBackupDialog());let t=e.querySelector(`.settings__restore-input`);e.querySelector(`[data-action="restore-settings"]`)?.addEventListener(`click`,()=>{t instanceof HTMLInputElement&&(t.value=``,t.click())}),t?.addEventListener(`change`,e=>{let t=e.target;if(!(t instanceof HTMLInputElement))return;let n=t.files?.[0]||null;n&&(this.pendingRestoreFile=n,this.openRestoreDialog(n.name))}),e.querySelector(`[data-action="clear-settings"]`)?.addEventListener(`click`,()=>this.openClearDialog()),e.querySelector(`[data-action="cancel-backup-settings"]`)?.addEventListener(`click`,()=>this.closeDialog(`.settings__backup-dialog`)),e.querySelector(`[data-action="confirm-backup-settings"]`)?.addEventListener(`click`,()=>{this.confirmBackup()}),e.querySelector(`[data-action="cancel-restore-settings"]`)?.addEventListener(`click`,()=>{this.pendingRestoreFile=null,this.closeDialog(`.settings__restore-dialog`)}),e.querySelector(`[data-action="confirm-restore-settings"]`)?.addEventListener(`click`,()=>{this.confirmRestore()}),e.querySelector(`[data-action="cancel-clear-settings"]`)?.addEventListener(`click`,()=>this.closeDialog(`.settings__clear-dialog`)),e.querySelector(`[data-action="confirm-clear-settings"]`)?.addEventListener(`click`,()=>{this.confirmClear()}),e.querySelector(`[data-action="save-assistant-name"]`)?.addEventListener(`click`,()=>this.saveAssistantName()),e.querySelector(`[data-setting="activity-log-disk-logging-toggle"]`)?.addEventListener(`change`,e=>{let t=e.target;t&&this.onActivityLogDiskLoggingToggle(t.checked)}),e.querySelector(`[data-setting="sidebar-hide-pages-toggle"]`)?.addEventListener(`change`,e=>{let t=e.target;t&&this.onSidebarHidePagesToggle(t.checked)}),e.querySelector(`[data-setting="sidebar-hide-chat-toggle"]`)?.addEventListener(`change`,e=>{let t=e.target;t&&this.onSidebarHideChatToggle(t.checked)}),e.querySelector(`[data-setting="sidebar-hide-tasks-toggle"]`)?.addEventListener(`change`,e=>{let t=e.target;t&&this.onSidebarHideTasksToggle(t.checked)}),e.querySelector(`[data-setting="sidebar-hide-files-toggle"]`)?.addEventListener(`change`,e=>{let t=e.target;t&&this.onSidebarHideFilesToggle(t.checked)}),e.querySelector(`[data-setting="chat-split-view-toggle"]`)?.addEventListener(`change`,e=>{let t=e.target;t&&this.onChatSplitViewToggle(t.checked)}),e.querySelector(`[data-setting="pages-auto-refresh-input"]`)?.addEventListener(`change`,e=>{let t=e.target;if(t){let e=parseInt(t.value,10);this.onPagesAutoRefreshInputChange(isNaN(e)?0:e)}}),e.querySelector(`[data-setting="override-prerender-skeleton-toggle"]`)?.addEventListener(`change`,e=>{let t=e.target;t&&this.onOverridePrerenderSkeletonToggle(t.checked)}),e.querySelector(`[data-action="save-dom-allowed-iframe-hosts"]`)?.addEventListener(`click`,()=>{this.saveDomAllowedIframeHosts()})}closeDialog(e){this.getDialog(e)?.close()}getDialog(e){let t=this.shadowRoot;if(!t)return null;let n=t.querySelector(e);return n instanceof HTMLDialogElement?n:null}handleTabKeydown(e,t){let n=this.shadowRoot;if(!n)return;let r=Array.from(n.querySelectorAll(`[data-tab-target]`)),i=r.indexOf(t);if(i<0)return;let a=-1;switch(e.key){case`ArrowRight`:case`ArrowDown`:a=(i+1)%r.length;break;case`ArrowLeft`:case`ArrowUp`:a=(i-1+r.length)%r.length;break;case`Home`:a=0;break;case`End`:a=r.length-1;break;default:return}e.preventDefault();let o=r[a];o.focus(),this.activateTab(o.dataset.tabTarget)}openBackupDialog(){let e=this.shadowRoot?.querySelector(`[data-setting="include-plaintext-passwords"]`);e instanceof HTMLInputElement&&(e.checked=!1),this.showDialog(`.settings__backup-dialog`)}openClearDialog(){this.showDialog(`.settings__clear-dialog`)}openRestoreDialog(e){let t=this.shadowRoot?.querySelector(`[data-info="restore-filename"]`);t instanceof HTMLElement&&(t.textContent=`Selected file: ${e}`),this.showDialog(`.settings__restore-dialog`)}showDialog(e){let t=this.getDialog(e);if(t){if(typeof t.showModal==`function`){t.showModal();return}t.setAttribute(`open`,``)}}async confirmBackup(){if(!this.db){f(`Settings database is unavailable`,5e3);return}let e=this.shadowRoot?.querySelector(`[data-setting="include-plaintext-passwords"]`),t=e instanceof HTMLInputElement&&e.checked;try{if(t){let e=await this.promptForPlaintextBackupHandle();if(!e)return;await b(e,await this.getAllConfigEntries(),t),this.closeDialog(`.settings__backup-dialog`),d(`Settings backup saved`,3e3);return}let e=await y(await this.getAllConfigEntries(),t),n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=`shadowclaw-settings-backup-${Date.now()}.json`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n),this.closeDialog(`.settings__backup-dialog`),d(`Settings backup downloaded`,3e3)}catch(e){f(`Failed to backup settings: ${e instanceof Error?e.message:String(e)}`,6e3)}}async confirmClear(){if(!this.db){f(`Settings database is unavailable`,5e3);return}try{await this.replaceConfigEntries([]),this.closeDialog(`.settings__clear-dialog`),u(`Settings cleared. Reloading app...`,3200),setTimeout(()=>{window.location.reload()},250)}catch(e){f(`Failed to clear settings: ${e instanceof Error?e.message:String(e)}`,6e3)}}async confirmRestore(){if(!this.db){f(`Settings database is unavailable`,5e3);return}let e=this.pendingRestoreFile;if(!e){f(`No backup file selected`,4e3);return}try{let t=S(await e.text()),n=await x(t.configEntries,t.plaintextPasswords||[]);await this.replaceConfigEntries(n),this.pendingRestoreFile=null,this.closeDialog(`.settings__restore-dialog`),d(`Settings restored. Reloading app...`,3200),setTimeout(()=>{window.location.reload()},250)}catch(e){f(`Failed to restore settings: ${e instanceof Error?e.message:String(e)}`,6e3)}}async getAllConfigEntries(){if(!this.db)throw Error(`Database is unavailable`);return await new Promise((e,t)=>{try{let n=this.db?.transaction(`config`,`readonly`);if(!n){t(Error(`Failed to open read transaction`));return}let r=n.objectStore(`config`).getAll();r.onsuccess=()=>{e((Array.isArray(r.result)?r.result:[]).filter(e=>e&&typeof e.key==`string`).map(e=>({key:e.key,value:e.value})))},r.onerror=()=>{t(r.error||Error(`Failed to read settings config`))}}catch(e){t(e)}})}async onActivityLogDiskLoggingToggle(t){if(this.db)try{let{setConfig:n}=await import(`./setConfig-DFMYnYLE.js`).then(e=>e.n);await n(this.db,e.ACTIVITY_LOG_DISK_LOGGING_ENABLED,t?`true`:`false`),d(t?`Activity log disk logging enabled`:`Activity log disk logging disabled`,2500)}catch(e){f(`Error saving activity log disk logging setting: `+(e instanceof Error?e.message:String(e)),6e3)}}async onChatSplitViewToggle(t){if(this.db)try{let{setConfig:n}=await import(`./setConfig-DFMYnYLE.js`).then(e=>e.n);await n(this.db,e.CHAT_SPLIT_VIEW_ENABLED,t?`true`:`false`),this.dispatchEvent(new CustomEvent(`chat-split-view-change`,{detail:{enabled:t},bubbles:!0,composed:!0})),d(t?`Horizontal Chat split view enabled`:`Horizontal Chat split view disabled`,2500)}catch(e){f(`Error saving Chat split view setting: `+(e instanceof Error?e.message:String(e)),6e3)}}async onOverridePrerenderSkeletonToggle(t){try{a(`shadow-claw-override-prerender-skeleton`,t?`true`:`false`)}catch(e){console.warn(`Unable to save setting to localStorage:`,e)}if(this.db)try{let{setConfig:n}=await import(`./setConfig-DFMYnYLE.js`).then(e=>e.n);await n(this.db,e.OVERRIDE_PRERENDER_SKELETON,t?`true`:`false`),d(t?`Pre-rendered content override enabled`:`Pre-rendered content override disabled`,2500)}catch(e){f(`Error saving pre-rendered content override setting: `+(e instanceof Error?e.message:String(e)),6e3)}}async onPagesAutoRefreshInputChange(t){if(!this.db)return;let n=Math.max(0,Math.min(t,86400));try{let{setConfig:t}=await import(`./setConfig-DFMYnYLE.js`).then(e=>e.n);await t(this.db,e.PAGES_AUTO_REFRESH_INTERVAL,String(n)),window.dispatchEvent(new CustomEvent(`shadow-claw-pages-auto-refresh-change`,{detail:{interval:n}})),d(n>0?`Pages auto refresh set to ${n}s`:`Pages auto refresh disabled`,2500)}catch(e){f(`Error saving Pages auto refresh interval: `+(e instanceof Error?e.message:String(e)),6e3)}}async onSidebarHideChatToggle(t){if(this.db)try{let{setConfig:n}=await import(`./setConfig-DFMYnYLE.js`).then(e=>e.n);await n(this.db,e.SIDEBAR_CHAT_HIDDEN,t?`true`:`false`),this.dispatchEvent(new CustomEvent(`sidebar-chat-visibility-change`,{detail:{hidden:t},bubbles:!0,composed:!0})),d(t?`Chat hidden in sidebar`:`Chat shown in sidebar`,2500)}catch(e){f(`Error saving sidebar Chat visibility: `+(e instanceof Error?e.message:String(e)),6e3)}}async onSidebarHideFilesToggle(t){if(this.db)try{let{setConfig:n}=await import(`./setConfig-DFMYnYLE.js`).then(e=>e.n);await n(this.db,e.SIDEBAR_FILES_HIDDEN,t?`true`:`false`),this.dispatchEvent(new CustomEvent(`sidebar-files-visibility-change`,{detail:{hidden:t},bubbles:!0,composed:!0})),d(t?`Files hidden in sidebar`:`Files shown in sidebar`,2500)}catch(e){f(`Error saving sidebar Files visibility: `+(e instanceof Error?e.message:String(e)),6e3)}}async onSidebarHidePagesToggle(t){if(this.db)try{let{setConfig:n}=await import(`./setConfig-DFMYnYLE.js`).then(e=>e.n);await n(this.db,e.SIDEBAR_PAGES_HIDDEN,t?`true`:`false`),this.dispatchEvent(new CustomEvent(`sidebar-pages-visibility-change`,{detail:{hidden:t},bubbles:!0,composed:!0})),d(t?`Pages hidden in sidebar`:`Pages shown in sidebar`,2500)}catch(e){f(`Error saving sidebar Pages visibility: `+(e instanceof Error?e.message:String(e)),6e3)}}async onSidebarHideTasksToggle(t){if(this.db)try{let{setConfig:n}=await import(`./setConfig-DFMYnYLE.js`).then(e=>e.n);await n(this.db,e.SIDEBAR_TASKS_HIDDEN,t?`true`:`false`),this.dispatchEvent(new CustomEvent(`sidebar-tasks-visibility-change`,{detail:{hidden:t},bubbles:!0,composed:!0})),d(t?`Tasks hidden in sidebar`:`Tasks shown in sidebar`,2500)}catch(e){f(`Error saving sidebar Tasks visibility: `+(e instanceof Error?e.message:String(e)),6e3)}}async populateAssistantSettings(){let t=this.shadowRoot;if(!t||!this.db)return;let n=t.querySelector(`[data-setting="assistant-name-input"]`);if(n){let{getConfig:t}=await import(`./getConfig-D89uJgo5.js`).then(e=>e.n),r=await t(this.db,e.ASSISTANT_NAME),i=this.orchestrator?.assistantName||s.orchestrator?.assistantName;n.value=typeof r==`string`&&r||i||`ShadowClaw`}let{getConfig:r}=await import(`./getConfig-D89uJgo5.js`).then(e=>e.n),o=await r(this.db,e.ACTIVITY_LOG_DISK_LOGGING_ENABLED),c=o===!0||o===`true`||o===1||o===`1`,l=t.querySelector(`[data-setting="activity-log-disk-logging-toggle"]`);l&&(l.checked=c);let u=await r(this.db,e.SIDEBAR_PAGES_HIDDEN),d=u===!0||u===`true`||u===1||u===`1`,f=t.querySelector(`[data-setting="sidebar-hide-pages-toggle"]`);f&&(f.checked=d);let p=await r(this.db,e.SIDEBAR_CHAT_HIDDEN),h=p===!0||p===`true`||p===1||p===`1`,g=t.querySelector(`[data-setting="sidebar-hide-chat-toggle"]`);g&&(g.checked=h);let _=await r(this.db,e.SIDEBAR_TASKS_HIDDEN),v=_===!0||_===`true`||_===1||_===`1`,y=t.querySelector(`[data-setting="sidebar-hide-tasks-toggle"]`);y&&(y.checked=v);let b=await r(this.db,e.SIDEBAR_FILES_HIDDEN),x=b===!0||b===`true`||b===1||b===`1`,S=t.querySelector(`[data-setting="sidebar-hide-files-toggle"]`);S&&(S.checked=x);let C=m(await r(this.db,e.CHAT_SPLIT_VIEW_ENABLED),!1),w=t.querySelector(`[data-setting="chat-split-view-toggle"]`);w&&(w.checked=C);let T=t.querySelector(`[data-setting="pages-auto-refresh-input"]`);if(T){let t=await r(this.db,e.PAGES_AUTO_REFRESH_INTERVAL);if(typeof t==`string`||typeof t==`number`){let e=parseInt(String(t),10);T.value=!isNaN(e)&&e>=0?String(e):`0`}else T.value=`0`}let E=await r(this.db,e.OVERRIDE_PRERENDER_SKELETON),D=null;try{D=i(`shadow-claw-override-prerender-skeleton`)}catch{}let O=!0;if(E==null?D!==null&&(O=D===`true`):O=m(E),O)try{a(`shadow-claw-override-prerender-skeleton`,`true`)}catch{}let k=t.querySelector(`[data-setting="override-prerender-skeleton-toggle"]`);k&&(k.checked=O);let A=t.querySelector(`[data-setting="dom-allowed-iframe-hosts"]`);if(A){let t=await r(this.db,e.ALLOWED_IFRAME_HOST_PATTERNS);if(typeof t==`string`&&t.trim().length>0){A.value=t;let{setAllowedIframeHostPatterns:e}=await import(`./iframe-sanitizer-y2Z1pPwY.js`).then(e=>e.r);e(t)}else{let{DEFAULT_ALLOWED_IFRAME_HOST_PATTERNS:e}=await import(`./iframe-sanitizer-y2Z1pPwY.js`).then(e=>e.r);A.value=e.join(`
|
|
882
889
|
`)}}let j=t.querySelector(`[data-setting="markdown-frontmatter-pages-toggle"]`);j&&(j.checked=m(await r(this.db,e.MARKDOWN_FRONTMATTER_PAGES),!0));let M=t.querySelector(`[data-setting="markdown-frontmatter-file-viewer-toggle"]`);M&&(M.checked=m(await r(this.db,e.MARKDOWN_FRONTMATTER_FILE_VIEWER),!0));let N=t.querySelector(`[data-setting="markdown-frontmatter-chat-toggle"]`);N&&(N.checked=m(await r(this.db,e.MARKDOWN_FRONTMATTER_CHAT),!0));let P=t.querySelector(`[data-setting="markdown-frontmatter-tasks-toggle"]`);P&&(P.checked=m(await r(this.db,e.MARKDOWN_FRONTMATTER_TASKS),!0))}async promptForPlaintextBackupHandle(){let e=Reflect.get(globalThis,`showSaveFilePicker`),t=typeof e==`function`?e.bind(globalThis):null;if(!t)throw Error(`Plaintext settings backup requires the File System Access API.`);try{return await t({id:`shadowclaw-settings-backup`,suggestedName:`shadowclaw-settings-backup-${n()}.json`,types:[{description:`JSON Files`,accept:{"application/json":[`.json`]}}]})}catch(e){if(e instanceof Error&&e.name===`AbortError`)return null;throw e}}async render(){let e=this.shadowRoot;if(!e)return;e.querySelector(`[data-action="show-channels-config"]`)?.addEventListener(`click`,()=>{this.dispatchEvent(new CustomEvent(`navigate`,{detail:{page:`channels`},bubbles:!0,composed:!0}))}),e.querySelector(`[data-action="show-tools-config"]`)?.addEventListener(`click`,()=>{this.dispatchEvent(new CustomEvent(`navigate`,{detail:{page:`tools`},bubbles:!0,composed:!0}))}),e.querySelectorAll(`[data-tab-target]`).forEach(e=>{e.addEventListener(`click`,()=>{this.activateTab(e.dataset.tabTarget)}),e.addEventListener(`keydown`,t=>{this.handleTabKeydown(t,e)})}),this.applyTabState(),this.bindSettingsActions();let t=e.querySelector(`[data-info="deployed-revision"]`);t&&(t.textContent=`Deployed revision: ${document.querySelector(`meta[name="revision"]`)?.getAttribute(`content`)?.trim()||`unknown`}`),await this.populateAssistantSettings()}async replaceConfigEntries(e){if(!this.db)throw Error(`Database is unavailable`);await new Promise((t,n)=>{try{let r=this.db?.transaction(`config`,`readwrite`);if(!r){n(Error(`Failed to open write transaction`));return}let i=r.objectStore(`config`);i.clear();for(let t of e)i.put({key:t.key,value:t.value});r.oncomplete=()=>t(),r.onerror=()=>n(r.error||Error(`Failed to update config`)),r.onabort=()=>n(r.error||Error(`Config update aborted`))}catch(e){n(e)}})}async saveAssistantName(){if(!this.db)return;let t=this.shadowRoot;if(!t)return;let n=t.querySelector(`[data-setting="assistant-name-input"]`);if(!n)return;let i=n.value.trim();if(!i){let{showWarning:e}=await import(`./toast-D3gxhZpN.js`).then(e=>e.o);e(`Please enter a name`,3e3);return}a(`assistantName`,i);try{let t=this.orchestrator||s.orchestrator;if(t)this.orchestrator=t,await r(t,this.db,i);else{let{setConfig:t}=await import(`./setConfig-DFMYnYLE.js`).then(e=>e.n);await t(this.db,e.ASSISTANT_NAME,i)}}catch(e){console.warn(`Could not update orchestrator:`,e)}d(`Assistant name saved`,3e3)}async saveDomAllowedIframeHosts(){let t=this.shadowRoot;if(!t||!this.db)return;let n=t.querySelector(`[data-setting="dom-allowed-iframe-hosts"]`);if(!n)return;let r=n.value.split(`
|
|
883
890
|
`).map(e=>e.trim()).filter(e=>e.length>0),i=t.querySelector(`[data-setting="markdown-frontmatter-pages-toggle"]`),a=t.querySelector(`[data-setting="markdown-frontmatter-file-viewer-toggle"]`),o=t.querySelector(`[data-setting="markdown-frontmatter-chat-toggle"]`),s=t.querySelector(`[data-setting="markdown-frontmatter-tasks-toggle"]`);try{let{setConfig:t}=await import(`./setConfig-DFMYnYLE.js`).then(e=>e.n),n=r.join(`
|
|
884
|
-
`);await t(this.db,e.ALLOWED_IFRAME_HOST_PATTERNS,n),await t(this.db,e.MARKDOWN_FRONTMATTER_PAGES,String(i?.checked??!0)),await t(this.db,e.MARKDOWN_FRONTMATTER_FILE_VIEWER,String(a?.checked??!0)),await t(this.db,e.MARKDOWN_FRONTMATTER_CHAT,String(o?.checked??!0)),await t(this.db,e.MARKDOWN_FRONTMATTER_TASKS,String(s?.checked??!0));let{setAllowedIframeHostPatterns:c}=await import(`./iframe-sanitizer-
|
|
891
|
+
`);await t(this.db,e.ALLOWED_IFRAME_HOST_PATTERNS,n),await t(this.db,e.MARKDOWN_FRONTMATTER_PAGES,String(i?.checked??!0)),await t(this.db,e.MARKDOWN_FRONTMATTER_FILE_VIEWER,String(a?.checked??!0)),await t(this.db,e.MARKDOWN_FRONTMATTER_CHAT,String(o?.checked??!0)),await t(this.db,e.MARKDOWN_FRONTMATTER_TASKS,String(s?.checked??!0));let{setAllowedIframeHostPatterns:c}=await import(`./iframe-sanitizer-y2Z1pPwY.js`).then(e=>e.r);c(r),d(`DOM iframe embed settings saved`,2500)}catch(e){f(`Error saving DOM iframe embed settings: `+(e instanceof Error?e.message:String(e)),6e3)}}};customElements.get(j)||customElements.define(j,M);export{M as ShadowClawSettings};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./config-
|
|
1
|
+
import{r as e}from"./config-CrHchneq.js";import{n as t}from"./txPromise-EBECky1b.js";import{t as n}from"./getConfig-D89uJgo5.js";import{u as r}from"./custom-element-security-NCqQ5lmC.js";import{en as i,t as a,tn as o}from"./orchestrator-3h9xxHUm.js";import{c as s}from"./getGroupDir-P1h9wl6S.js";import{t as c}from"./setConfig-DFMYnYLE.js";import{a as l,r as u,t as d}from"./toast-D3gxhZpN.js";import{t as f}from"./shadow-claw-element-DIrv3P6A.js";import{t as p}from"./effect-BEsuusE8.js";import{t as m}from"./config-value-oBfKgLT4.js";async function h(){try{if(typeof navigator<`u`&&navigator.storage&&navigator.storage.estimate){let e=await navigator.storage.estimate();return{usage:e.usage||0,quota:e.quota||0}}}catch(e){console.warn(`Failed to get storage estimate:`,e)}return{usage:0,quota:0}}async function g(){try{if(typeof navigator<`u`&&navigator.storage&&navigator.storage.persisted)return await navigator.storage.persisted()}catch(e){console.warn(`Failed to check persistent storage:`,e)}return!1}async function _(){try{if(typeof navigator<`u`&&navigator.storage&&navigator.storage.persist)return await navigator.storage.persist()}catch(e){console.warn(`Failed to request persistent storage:`,e)}return!1}async function v(t){let n=Reflect.get(globalThis,`showDirectoryPicker`),r=typeof n==`function`?n.bind(globalThis):null;if(!r)throw Error(`Local folder picker is unavailable in this browser/context.`);try{let n=await r({mode:`readwrite`,id:`shadowclaw-storage`});return await c(t,e.STORAGE_HANDLE,n),await o(t),await i(t),!0}catch(e){if(e instanceof Error&&e.name===`AbortError`)return!1;throw e}}const y=new CSSStyleSheet;y.replaceSync(`*,
|
|
2
2
|
*::before,
|
|
3
3
|
*::after {
|
|
4
4
|
font-family: var(--shadow-claw-font-sans);
|
|
@@ -212,7 +212,7 @@ import{r as e}from"./config-BYAuxx3j.js";import{n as t}from"./txPromise-EBECky1b
|
|
|
212
212
|
</div>
|
|
213
213
|
</div>
|
|
214
214
|
</template>
|
|
215
|
-
`,`text/html`),x=b.querySelector(`template`);let S=[];S=x?Array.from(x.content.children):Array.from(b.head.children).concat(Array.from(b.body.children));var C=S;const w=`shadow-claw-storage`;var T=class extends f{static styles=y;static template=C;db=null;constructor(){super()}async connectedCallback(){if(!this.shadowRoot)throw Error(`shadowRoot not found`);this.db=await t(),this.bindEventListeners(),this.setupEffects(),await this.updateStorageInfo()}disconnectedCallback(){super.disconnectedCallback()}bindEventListeners(){let e=this.shadowRoot;e&&(e.querySelector(`[data-action="request-persistent"]`)?.addEventListener(`click`,()=>this.handleRequestPersistent()),e.querySelector(`[data-action="change-storage-dir"]`)?.addEventListener(`click`,()=>this.handleChangeStorageDir()),e.querySelector(`[data-action="reset-storage-dir"]`)?.addEventListener(`click`,()=>this.handleResetStorageDir()),e.querySelector(`[data-action="reset-site-config"]`)?.addEventListener(`click`,()=>this.handleResetSiteConfig()),e.querySelector(`[data-action="grant-storage-permission"]`)?.addEventListener(`click`,()=>{this.db&&
|
|
215
|
+
`,`text/html`),x=b.querySelector(`template`);let S=[];S=x?Array.from(x.content.children):Array.from(b.head.children).concat(Array.from(b.body.children));var C=S;const w=`shadow-claw-storage`;var T=class extends f{static styles=y;static template=C;db=null;constructor(){super()}async connectedCallback(){if(!this.shadowRoot)throw Error(`shadowRoot not found`);this.db=await t(),this.bindEventListeners(),this.setupEffects(),await this.updateStorageInfo()}disconnectedCallback(){super.disconnectedCallback()}bindEventListeners(){let e=this.shadowRoot;e&&(e.querySelector(`[data-action="request-persistent"]`)?.addEventListener(`click`,()=>this.handleRequestPersistent()),e.querySelector(`[data-action="change-storage-dir"]`)?.addEventListener(`click`,()=>this.handleChangeStorageDir()),e.querySelector(`[data-action="reset-storage-dir"]`)?.addEventListener(`click`,()=>this.handleResetStorageDir()),e.querySelector(`[data-action="reset-site-config"]`)?.addEventListener(`click`,()=>this.handleResetSiteConfig()),e.querySelector(`[data-action="grant-storage-permission"]`)?.addEventListener(`click`,()=>{this.db&&a.grantStorageAccess(this.db)}),e.querySelector(`[data-setting="files-upload-append-ulid-toggle"]`)?.addEventListener(`change`,e=>{let t=e.target;t&&this.onUploadAppendUlidToggle(t.checked)}))}formatBytes(e){if(e===0)return`0 B`;let t=1024,n=[`B`,`KB`,`MB`,`GB`,`TB`],r=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/t**r).toFixed(1))+` `+n[r]}setupEffects(){let e=this.shadowRoot;e&&this.addCleanup(p(()=>{let t=a.storageStatus;if(!t)return;let n=e.querySelector(`[data-info="storage-type"]`),r=e.querySelector(`[data-info="storage-status-badge"]`),i=e.querySelector(`[data-action="grant-storage-permission"]`);n&&(n.textContent=t.type===`local`?`Local Directory`:`Browser Internal (OPFS)`),r&&(r.style.display=t.type===`local`?`inline-block`:`none`,t.type===`local`&&(r.textContent=t.permission===`granted`?`CONNECTED`:`NEEDS PERMISSION`,r.style.backgroundColor=t.permission===`granted`?`var(--shadow-claw-success-color)`:`var(--shadow-claw-error-color)`,r.style.color=`white`)),i&&(i.style.display=t.type===`local`&&t.permission!==`granted`?`inline-block`:`none`)}))}async handleChangeStorageDir(){if(this.db)try{await v(this.db)&&(u(`Storage location changed. Existing OPFS files were not moved.`,4500),await this.updateStorageInfo(),await a.loadFiles(this.db))}catch(e){d(`Failed to change storage location: ${e instanceof Error?e.message:String(e)}`,6e3)}}async handleRequestPersistent(){if(this.db)try{await _()?u(`Persistent storage granted`,3500):l(`Persistent storage was not granted. Browsers may deny this based on site usage.`,5500),await this.updateStorageInfo()}catch(e){d(`Storage request failed: ${e instanceof Error?e.message:String(e)}`,6e3)}}async handleResetSiteConfig(){if(this.db&&await this.requestConfirmation({title:`Reset Site Config`,message:`Allow embedded site-config.json defaults to apply again after the next reload?`,confirmLabel:`Reset`,cancelLabel:`Cancel`}))try{await a.resetSiteConfigSeed(this.db),u(`Site config reset. Reload to apply its defaults again.`,5e3)}catch(e){d(`Failed to reset site config: ${e instanceof Error?e.message:String(e)}`,6e3)}}async onUploadAppendUlidToggle(t){if(this.db)try{let{setConfig:n}=await import(`./setConfig-DFMYnYLE.js`).then(e=>e.n);await n(this.db,e.FILES_UPLOAD_APPEND_ULID,t?`true`:`false`),u(t?`Unique ID prefix on file upload enabled`:`Unique ID prefix on file upload disabled`,2500)}catch(e){d(`Error saving unique ID file upload setting: `+(e instanceof Error?e.message:String(e)),6e3)}}async handleResetStorageDir(){if(this.db&&await this.requestConfirmation({title:`Reset Storage Location`,message:`Revert storage to browser-internal (OPFS)?`,confirmLabel:`Revert`,cancelLabel:`Cancel`}))try{await s(this.db),u(`Reverted to browser-internal storage`,3500),await this.updateStorageInfo(),await a.loadFiles(this.db)}catch(e){d(`Failed to reset storage location: ${e instanceof Error?e.message:String(e)}`,6e3)}}async requestConfirmation(e){let t=document.querySelector(`shadow-claw`);return t&&typeof t.requestDialog==`function`?await t.requestDialog({mode:`confirm`,...e}):(l(e.message,4500),!1)}async updateStorageInfo(){if(!this.db)return;let t=this.shadowRoot;if(t)try{let i=await h(),a=this.formatBytes(i.usage),o=this.formatBytes(i.quota),s=i.quota>0?i.usage/i.quota*100:0,c=t.querySelector(`[data-info="storage-usage"]`),l=t.querySelector(`[data-info="storage-quota"]`),u=t.querySelector(`[data-info="storage-progress"]`),d=t.querySelector(`[data-info="storage-type"]`),f=t.querySelector(`[data-info="storage-persistent-badge"]`);c&&(c.textContent=`${a} used`),l&&(l.textContent=`of ${o}`),u&&(u.style.width=`${s}%`);let p=await n(this.db,e.STORAGE_HANDLE);d&&(d.textContent=p?`Local Directory`:`Browser Internal (OPFS)`);let _=await g();f&&(f.style.display=_?`inline-block`:`none`);let v=t.querySelector(`[data-info="storage-help-general"]`),y=t.querySelector(`[data-info="storage-help-local"]`);v&&r(v,p?`Persistent storage protects your <b>chat history, tasks, and settings</b> in the browser database.
|
|
216
216
|
Without it, the browser might clear this data if your disk is almost full.`:`Persistent storage protects your <b>files, chat history, and settings</b> in the browser.
|
|
217
217
|
Without it, the browser might clear your data if your disk is almost full.`),y&&r(y,p?`ShadowClaw is currently <b>connected to a local folder</b>. Your files are safe on your disk,
|
|
218
218
|
but browser persistence is still recommended for your chat history.`:`You can use a local folder on your computer for storage. This makes files directly accessible
|
package/dist/public/{shadow-claw-task-server-IjKX042p.js → shadow-claw-task-server-3BIeb5oZ.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e}from"./txPromise-EBECky1b.js";import{b as t,t as n,y as r}from"./orchestrator-
|
|
1
|
+
import{n as e}from"./txPromise-EBECky1b.js";import{b as t,t as n,y as r}from"./orchestrator-3h9xxHUm.js";import{r as i,t as a}from"./toast-D3gxhZpN.js";import{t as o}from"./shadow-claw-element-DIrv3P6A.js";import{t as s}from"./effect-BEsuusE8.js";const c=new CSSStyleSheet;c.replaceSync(`*,
|
|
2
2
|
*::before,
|
|
3
3
|
*::after {
|
|
4
4
|
font-family: var(--shadow-claw-font-sans);
|
|
@@ -33,7 +33,8 @@ import{n as e}from"./txPromise-EBECky1b.js";import{b as t,t as n,y as r}from"./o
|
|
|
33
33
|
margin-bottom: 0.375rem;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
.form-input
|
|
36
|
+
.form-input,
|
|
37
|
+
.form-select {
|
|
37
38
|
background-color: var(--shadow-claw-bg-primary);
|
|
38
39
|
border: 0.0625rem solid var(--shadow-claw-border-color);
|
|
39
40
|
border-radius: var(--shadow-claw-radius-s, 0.625rem);
|
|
@@ -48,12 +49,32 @@ import{n as e}from"./txPromise-EBECky1b.js";import{b as t,t as n,y as r}from"./o
|
|
|
48
49
|
width: 100%;
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
.form-input:focus
|
|
52
|
+
.form-input:focus,
|
|
53
|
+
.form-select:focus {
|
|
52
54
|
border-color: var(--shadow-claw-accent-primary);
|
|
53
55
|
box-shadow: 0 0 0 0.125rem rgba(0, 0, 0, 0.06);
|
|
54
56
|
outline: none;
|
|
55
57
|
}
|
|
56
58
|
|
|
59
|
+
.form-toggle {
|
|
60
|
+
align-items: center;
|
|
61
|
+
display: flex;
|
|
62
|
+
gap: 0.75rem;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.form-toggle input[type="checkbox"] {
|
|
66
|
+
accent-color: var(--shadow-claw-accent-primary);
|
|
67
|
+
cursor: pointer;
|
|
68
|
+
height: 1.125rem;
|
|
69
|
+
width: 1.125rem;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.form-toggle .form-label {
|
|
73
|
+
cursor: pointer;
|
|
74
|
+
display: inline;
|
|
75
|
+
margin-bottom: 0;
|
|
76
|
+
}
|
|
77
|
+
|
|
57
78
|
.form-helper {
|
|
58
79
|
color: var(--shadow-claw-text-tertiary);
|
|
59
80
|
font-size: 0.75rem;
|
|
@@ -140,7 +161,7 @@ import{n as e}from"./txPromise-EBECky1b.js";import{b as t,t as n,y as r}from"./o
|
|
|
140
161
|
site, and task scheduling runs on a separate backend.
|
|
141
162
|
</div>
|
|
142
163
|
<button class="save-btn" data-action="save-task-server-url">
|
|
143
|
-
💾 Save
|
|
164
|
+
💾 Save URL
|
|
144
165
|
</button>
|
|
145
166
|
</div>
|
|
146
167
|
</div>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./config-
|
|
1
|
+
import{r as e}from"./config-CrHchneq.js";import{n as t}from"./txPromise-EBECky1b.js";import{t as n}from"./getConfig-D89uJgo5.js";import{m as r,u as i}from"./custom-element-security-NCqQ5lmC.js";import{t as a}from"./orchestrator-3h9xxHUm.js";import{n as o,r as s,t as c}from"./toast-D3gxhZpN.js";import{t as l}from"./shadow-claw-element-DIrv3P6A.js";import"./shadow-claw-empty-state-obMInUIf.js";import{t as u}from"./effect-BEsuusE8.js";import{t as d}from"./config-value-oBfKgLT4.js";import"./shadow-claw-page-header-action-button-Bmua3mAb.js";import"./shadow-claw-page-header-DMKbkv3s.js";import{t as f}from"./markdown-BnpKxSxl.js";import{t as p}from"./file-viewer-D0eflgt6.js";import"./shadow-claw-dialog-BrOwAOdk.js";const m=new CSSStyleSheet;m.replaceSync(`*,
|
|
2
2
|
*::before,
|
|
3
3
|
*::after {
|
|
4
4
|
font-family: var(--shadow-claw-font-sans);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{D as e,E as t,T as n,t as r}from"./orchestrator-
|
|
1
|
+
import{D as e,E as t,T as n,t as r}from"./orchestrator-3h9xxHUm.js";import{t as i}from"./shadow-claw-element-DIrv3P6A.js";function a(e){if(!e)return``;let t=e.split(`
|
|
2
2
|
`);for(let e=t.length-1;e>=0;--e){let n=t[e]||``;if(/[#$](?:\s|$)/.test(n))return n}return``}function o(e){return e.scrollHeight-(e.scrollTop+e.clientHeight)<=12}function s(e,t){let n=e[t+1];if(n===void 0)return{action:`ignore`,nextIndex:t+1,incomplete:!0};if(n===`[`){let n=t+2;for(;n<e.length;){let t=e.charCodeAt(n);if(t>=64&&t<=126){let t=e[n];return t===`J`?{action:`clear-screen`,nextIndex:n+1}:t===`K`?{action:`clear-line`,nextIndex:n+1}:{action:`ignore`,nextIndex:n+1}}n+=1}return{action:`ignore`,nextIndex:e.length,incomplete:!0}}if(n===`]`){let n=t+2;for(;n<e.length;){let t=e[n];if(t===`\x07`)return{action:`ignore`,nextIndex:n+1};if(t===`\x1B`&&e[n+1]===`\\`)return{action:`ignore`,nextIndex:n+2};n+=1}return{action:`ignore`,nextIndex:e.length,incomplete:!0}}return{action:`ignore`,nextIndex:Math.min(t+2,e.length)}}function c(e){return e.replace(/(?:^|\n)[^\n]*mkdir -p \/home\/user 2>&1; echo "?__BCDONE_\d+__\$\?"?[^\n]*(?:\n|$)/g,`
|
|
3
3
|
`).replace(/(?:^|\n)\s*__BCDONE_\d+__(?:\d+|\$\?)?\s*(?:\n|$)/g,`
|
|
4
4
|
`).replace(/^\n+(?=\S)/,``)}function l(e,t,n=``,r){let i=r?.respectEraseSequences??!0,a=n+t,o=e;for(let e=0;e<a.length;e++){let t=a[e];if(t===`\x1B`){let t=s(a,e);if(t.incomplete)return{text:o,pending:a.slice(e)};if(t.action===`clear-screen`&&i&&(o=``),t.action===`clear-line`&&i){let e=o.lastIndexOf(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{A as e,F as t}from"./config-
|
|
1
|
+
import{A as e,F as t}from"./config-CrHchneq.js";import{n}from"./txPromise-EBECky1b.js";import{gn as r,mn as i,t as a}from"./orchestrator-3h9xxHUm.js";import{t as o}from"./ulid-BY7rQVLN.js";import{i as s,n as c,t as l}from"./syncWebMcpRegistration-B_M2fCjH.js";import{n as u,r as d,t as f}from"./toast-D3gxhZpN.js";import{t as p}from"./shadow-claw-element-DIrv3P6A.js";import{t as m}from"./effect-BEsuusE8.js";import"./shadow-claw-page-header-action-button-Bmua3mAb.js";import"./shadow-claw-page-header-DMKbkv3s.js";import"./shadow-claw-dialog-BrOwAOdk.js";const h=new CSSStyleSheet;h.replaceSync(`*,
|
|
2
2
|
*::before,
|
|
3
3
|
*::after {
|
|
4
4
|
font-family: var(--shadow-claw-font-sans);
|