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
|
@@ -33,7 +33,8 @@
|
|
|
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 @@
|
|
|
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;
|
|
@@ -25,6 +25,7 @@ jest.unstable_mockModule("../../../stores/orchestrator.js", () => ({
|
|
|
25
25
|
orchestratorStore: {
|
|
26
26
|
orchestrator: {
|
|
27
27
|
taskServerUrl: "/test-schedule",
|
|
28
|
+
taskServerEnabled: true,
|
|
28
29
|
},
|
|
29
30
|
ready: true,
|
|
30
31
|
},
|
|
@@ -56,6 +57,10 @@ describe("shadow-claw-task-server", () => {
|
|
|
56
57
|
'[data-setting="task-server-url-input"]',
|
|
57
58
|
) as HTMLInputElement;
|
|
58
59
|
expect(input.value).toBe("/test-schedule");
|
|
60
|
+
const enabledToggle = el.shadowRoot?.querySelector(
|
|
61
|
+
'[data-setting="task-server-enabled-toggle"]',
|
|
62
|
+
) as HTMLInputElement;
|
|
63
|
+
expect(enabledToggle.checked).toBe(true);
|
|
59
64
|
});
|
|
60
65
|
|
|
61
66
|
it("should save task server url", async () => {
|
|
@@ -77,4 +82,18 @@ describe("shadow-claw-task-server", () => {
|
|
|
77
82
|
);
|
|
78
83
|
expect(showSuccess).toHaveBeenCalled();
|
|
79
84
|
});
|
|
85
|
+
|
|
86
|
+
it("should save task server enabled toggle", async () => {
|
|
87
|
+
const el = new ShadowClawTaskServer();
|
|
88
|
+
document.body.appendChild(el);
|
|
89
|
+
await el.connectedCallback();
|
|
90
|
+
|
|
91
|
+
await el.saveTaskServerEnabled(false);
|
|
92
|
+
|
|
93
|
+
expect(mockSetTaskServerEnabled).toHaveBeenCalledWith(
|
|
94
|
+
orchestratorStore.orchestrator,
|
|
95
|
+
expect.anything(),
|
|
96
|
+
false,
|
|
97
|
+
);
|
|
98
|
+
});
|
|
80
99
|
});
|
|
@@ -17,7 +17,7 @@ import shadowClawTaskServerTemplate from "./shadow-claw-task-server.html" with {
|
|
|
17
17
|
const elementName = "shadow-claw-task-server";
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
* Settings sub-component for Task Server URL configuration.
|
|
20
|
+
* Settings sub-component for Task Server URL and server-side task scheduling configuration.
|
|
21
21
|
*/
|
|
22
22
|
export class ShadowClawTaskServer extends ShadowClawElement {
|
|
23
23
|
static styles = shadowClawTaskServerStyles;
|
|
@@ -100,6 +100,7 @@ export class ShadowClawTaskServer extends ShadowClawElement {
|
|
|
100
100
|
enabledToggle.checked = this.orchestrator.taskServerEnabled;
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
+
|
|
103
104
|
async saveTaskServerEnabled(enabled: boolean) {
|
|
104
105
|
if (!this.orchestrator || !this.db) {
|
|
105
106
|
return;
|
|
@@ -1,27 +1,88 @@
|
|
|
1
1
|
import { jest } from "@jest/globals";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
DEFAULT_CHAT_SPLIT_HEIGHT_PX,
|
|
4
|
+
MIN_CHAT_SPLIT_HEIGHT_PX,
|
|
5
|
+
} from "../constants.js";
|
|
6
|
+
|
|
7
|
+
const mockGetConfig = jest.fn() as any;
|
|
8
|
+
const mockSetConfig = jest.fn() as any;
|
|
9
|
+
|
|
10
|
+
jest.unstable_mockModule("../../../db/getConfig.js", () => ({
|
|
11
|
+
getConfig: mockGetConfig,
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
jest.unstable_mockModule("../../../db/setConfig.js", () => ({
|
|
15
|
+
setConfig: mockSetConfig,
|
|
16
|
+
}));
|
|
17
|
+
|
|
18
|
+
const { initChatSplitResize } = await import("./initChatSplitResize.js");
|
|
3
19
|
|
|
4
20
|
describe("initChatSplitResize", () => {
|
|
5
21
|
let shadowRoot: ShadowRoot;
|
|
6
22
|
let mainContent: HTMLElement;
|
|
23
|
+
let chatPage: HTMLElement;
|
|
7
24
|
let handle: HTMLElement;
|
|
8
25
|
let shadowClaw: any;
|
|
26
|
+
let cleanups: Array<() => void>;
|
|
9
27
|
|
|
10
28
|
beforeEach(() => {
|
|
29
|
+
jest.clearAllMocks();
|
|
30
|
+
cleanups = [];
|
|
31
|
+
|
|
32
|
+
// Mock desktop window dimensions
|
|
33
|
+
Object.defineProperty(window, "innerWidth", {
|
|
34
|
+
writable: true,
|
|
35
|
+
configurable: true,
|
|
36
|
+
value: 1200,
|
|
37
|
+
});
|
|
38
|
+
Object.defineProperty(window, "innerHeight", {
|
|
39
|
+
writable: true,
|
|
40
|
+
configurable: true,
|
|
41
|
+
value: 900,
|
|
42
|
+
});
|
|
43
|
+
|
|
11
44
|
const host = document.createElement("div");
|
|
12
45
|
shadowRoot = host.attachShadow({ mode: "open" });
|
|
13
46
|
|
|
14
47
|
mainContent = document.createElement("div");
|
|
15
48
|
mainContent.classList.add("main-content");
|
|
49
|
+
mainContent.getBoundingClientRect = () => ({
|
|
50
|
+
height: 900,
|
|
51
|
+
width: 1200,
|
|
52
|
+
top: 0,
|
|
53
|
+
left: 0,
|
|
54
|
+
bottom: 900,
|
|
55
|
+
right: 1200,
|
|
56
|
+
x: 0,
|
|
57
|
+
y: 0,
|
|
58
|
+
toJSON: () => {},
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
chatPage = document.createElement("div");
|
|
62
|
+
chatPage.classList.add("chat-page");
|
|
63
|
+
chatPage.getBoundingClientRect = () => ({
|
|
64
|
+
height: 300,
|
|
65
|
+
width: 400,
|
|
66
|
+
top: 0,
|
|
67
|
+
left: 0,
|
|
68
|
+
bottom: 300,
|
|
69
|
+
right: 400,
|
|
70
|
+
x: 0,
|
|
71
|
+
y: 0,
|
|
72
|
+
toJSON: () => {},
|
|
73
|
+
});
|
|
16
74
|
|
|
17
75
|
handle = document.createElement("div");
|
|
18
76
|
handle.classList.add("chat-split-resize-handle");
|
|
19
77
|
|
|
20
78
|
mainContent.appendChild(handle);
|
|
79
|
+
mainContent.appendChild(chatPage);
|
|
21
80
|
shadowRoot.appendChild(mainContent);
|
|
22
81
|
|
|
23
82
|
shadowClaw = {
|
|
24
|
-
addCleanup: jest.fn()
|
|
83
|
+
addCleanup: jest.fn((fn: () => void) => {
|
|
84
|
+
cleanups.push(fn);
|
|
85
|
+
}),
|
|
25
86
|
};
|
|
26
87
|
|
|
27
88
|
if (!Element.prototype.setPointerCapture) {
|
|
@@ -29,31 +90,137 @@ describe("initChatSplitResize", () => {
|
|
|
29
90
|
}
|
|
30
91
|
});
|
|
31
92
|
|
|
32
|
-
|
|
33
|
-
|
|
93
|
+
afterEach(() => {
|
|
94
|
+
for (const fn of cleanups) {
|
|
95
|
+
fn();
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("handles null shadow or null handle safely", async () => {
|
|
100
|
+
await initChatSplitResize(null, shadowClaw, handle, undefined);
|
|
101
|
+
expect(shadowClaw.addCleanup).not.toHaveBeenCalled();
|
|
34
102
|
|
|
35
|
-
|
|
36
|
-
expect(
|
|
37
|
-
expect(handle.getAttribute("aria-orientation")).toBe("horizontal");
|
|
38
|
-
expect(handle.getAttribute("aria-label")).toBe("Resize chat panel height");
|
|
39
|
-
expect(shadowClaw.addCleanup).toHaveBeenCalled();
|
|
103
|
+
await initChatSplitResize(shadowRoot, shadowClaw, null as any, undefined);
|
|
104
|
+
expect(shadowClaw.addCleanup).not.toHaveBeenCalled();
|
|
40
105
|
});
|
|
41
106
|
|
|
42
|
-
it("
|
|
43
|
-
|
|
107
|
+
it("loads saved height from db or defaults", async () => {
|
|
108
|
+
const mockDb: any = {};
|
|
109
|
+
mockGetConfig.mockResolvedValueOnce(450);
|
|
110
|
+
|
|
111
|
+
await initChatSplitResize(shadowRoot, shadowClaw, handle, mockDb);
|
|
112
|
+
expect(mainContent.style.getPropertyValue("--chat-split-height")).toBe(
|
|
113
|
+
"450px",
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
// String saved value
|
|
117
|
+
mockGetConfig.mockResolvedValueOnce("350");
|
|
118
|
+
await initChatSplitResize(shadowRoot, shadowClaw, handle, mockDb);
|
|
119
|
+
expect(mainContent.style.getPropertyValue("--chat-split-height")).toBe(
|
|
120
|
+
"350px",
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
// Fallback on error
|
|
124
|
+
mockGetConfig.mockRejectedValueOnce(new Error("DB error"));
|
|
125
|
+
await initChatSplitResize(shadowRoot, shadowClaw, handle, mockDb);
|
|
126
|
+
expect(mainContent.style.getPropertyValue("--chat-split-height")).toBe(
|
|
127
|
+
`${DEFAULT_CHAT_SPLIT_HEIGHT_PX}px`,
|
|
128
|
+
);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it("handles pointer drag resize workflow", async () => {
|
|
132
|
+
const mockDb: any = {};
|
|
133
|
+
await initChatSplitResize(shadowRoot, shadowClaw, handle, mockDb);
|
|
134
|
+
|
|
135
|
+
// Pointer down to start drag
|
|
136
|
+
const pointerDownEvent = new Event("pointerdown", { bubbles: true }) as any;
|
|
137
|
+
pointerDownEvent.pointerId = 1;
|
|
138
|
+
pointerDownEvent.pointerType = "mouse";
|
|
139
|
+
pointerDownEvent.button = 0;
|
|
140
|
+
pointerDownEvent.clientY = 500;
|
|
141
|
+
pointerDownEvent.preventDefault = jest.fn();
|
|
142
|
+
|
|
143
|
+
handle.dispatchEvent(pointerDownEvent);
|
|
144
|
+
expect(handle.classList.contains("active")).toBe(true);
|
|
145
|
+
|
|
146
|
+
// Pointer move dragging upward (delta = 500 - 400 = 100 increase)
|
|
147
|
+
const pointerMoveEvent = new Event("pointermove", { bubbles: true }) as any;
|
|
148
|
+
pointerMoveEvent.pointerId = 1;
|
|
149
|
+
pointerMoveEvent.clientY = 400;
|
|
150
|
+
document.dispatchEvent(pointerMoveEvent);
|
|
151
|
+
|
|
152
|
+
// Pointer up to finish drag
|
|
153
|
+
const pointerUpEvent = new Event("pointerup", { bubbles: true }) as any;
|
|
154
|
+
pointerUpEvent.pointerId = 1;
|
|
155
|
+
handle.dispatchEvent(pointerUpEvent);
|
|
44
156
|
|
|
157
|
+
expect(handle.classList.contains("active")).toBe(false);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it("handles dblclick to reset to default height", async () => {
|
|
161
|
+
const mockDb: any = {};
|
|
162
|
+
await initChatSplitResize(shadowRoot, shadowClaw, handle, mockDb);
|
|
163
|
+
|
|
164
|
+
mainContent.style.setProperty("--chat-split-height", "600px");
|
|
165
|
+
handle.dispatchEvent(new MouseEvent("dblclick", { bubbles: true }));
|
|
166
|
+
|
|
167
|
+
expect(mainContent.style.getPropertyValue("--chat-split-height")).toBe(
|
|
168
|
+
`${DEFAULT_CHAT_SPLIT_HEIGHT_PX}px`,
|
|
169
|
+
);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it("handles keyboard navigation with Home, End, Shift+Arrow", async () => {
|
|
173
|
+
const mockDb: any = {};
|
|
174
|
+
await initChatSplitResize(shadowRoot, shadowClaw, handle, mockDb);
|
|
175
|
+
|
|
176
|
+
// Home key sets to min height
|
|
45
177
|
handle.dispatchEvent(
|
|
46
|
-
new KeyboardEvent("keydown", { key: "
|
|
178
|
+
new KeyboardEvent("keydown", { key: "Home", bubbles: true }),
|
|
179
|
+
);
|
|
180
|
+
expect(mainContent.style.getPropertyValue("--chat-split-height")).toBe(
|
|
181
|
+
`${MIN_CHAT_SPLIT_HEIGHT_PX}px`,
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
// End key sets to max clamped height
|
|
185
|
+
handle.dispatchEvent(
|
|
186
|
+
new KeyboardEvent("keydown", { key: "End", bubbles: true }),
|
|
47
187
|
);
|
|
48
188
|
expect(
|
|
49
189
|
mainContent.style.getPropertyValue("--chat-split-height"),
|
|
50
190
|
).toBeTruthy();
|
|
51
191
|
|
|
192
|
+
// Shift + ArrowUp increases by 32
|
|
52
193
|
handle.dispatchEvent(
|
|
53
|
-
new KeyboardEvent("keydown", {
|
|
194
|
+
new KeyboardEvent("keydown", {
|
|
195
|
+
key: "ArrowUp",
|
|
196
|
+
shiftKey: true,
|
|
197
|
+
bubbles: true,
|
|
198
|
+
}),
|
|
54
199
|
);
|
|
55
200
|
expect(
|
|
56
201
|
mainContent.style.getPropertyValue("--chat-split-height"),
|
|
57
202
|
).toBeTruthy();
|
|
58
203
|
});
|
|
204
|
+
|
|
205
|
+
it("ignores resize events on mobile screen width (< 896px)", async () => {
|
|
206
|
+
Object.defineProperty(window, "innerWidth", {
|
|
207
|
+
writable: true,
|
|
208
|
+
configurable: true,
|
|
209
|
+
value: 600,
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
await initChatSplitResize(shadowRoot, shadowClaw, handle, undefined);
|
|
213
|
+
|
|
214
|
+
const pointerDownEvent = new Event("pointerdown", { bubbles: true }) as any;
|
|
215
|
+
pointerDownEvent.pointerId = 1;
|
|
216
|
+
pointerDownEvent.clientY = 500;
|
|
217
|
+
pointerDownEvent.button = 0;
|
|
218
|
+
|
|
219
|
+
handle.dispatchEvent(pointerDownEvent);
|
|
220
|
+
expect(handle.classList.contains("active")).toBe(false);
|
|
221
|
+
|
|
222
|
+
handle.dispatchEvent(
|
|
223
|
+
new KeyboardEvent("keydown", { key: "ArrowUp", bubbles: true }),
|
|
224
|
+
);
|
|
225
|
+
});
|
|
59
226
|
});
|
|
@@ -10,6 +10,8 @@ describe("setupEffects", () => {
|
|
|
10
10
|
let mockShowSuccess: any;
|
|
11
11
|
let mockShowPage: any;
|
|
12
12
|
let mockUpdateActivityLogToggleVisibility: any;
|
|
13
|
+
let mockEnsureComponentLoaded: any;
|
|
14
|
+
let mockFileViewerStore: any;
|
|
13
15
|
let setupEffects: any;
|
|
14
16
|
|
|
15
17
|
let effectCallbacks: Array<() => void>;
|
|
@@ -25,6 +27,8 @@ describe("setupEffects", () => {
|
|
|
25
27
|
mockShowSuccess = jest.fn();
|
|
26
28
|
mockShowPage = jest.fn();
|
|
27
29
|
mockUpdateActivityLogToggleVisibility = jest.fn();
|
|
30
|
+
mockEnsureComponentLoaded = jest.fn().mockResolvedValue(undefined as never);
|
|
31
|
+
mockFileViewerStore = { file: null };
|
|
28
32
|
|
|
29
33
|
jest.unstable_mockModule("../../../core/effect.js", () => ({
|
|
30
34
|
effect: mockEffect,
|
|
@@ -42,7 +46,19 @@ describe("setupEffects", () => {
|
|
|
42
46
|
updateActivityLogToggleVisibility: mockUpdateActivityLogToggleVisibility,
|
|
43
47
|
}));
|
|
44
48
|
|
|
49
|
+
jest.unstable_mockModule("./loadComponent.js", () => ({
|
|
50
|
+
ensureComponentLoaded: mockEnsureComponentLoaded,
|
|
51
|
+
}));
|
|
52
|
+
|
|
53
|
+
jest.unstable_mockModule("../../../stores/file-viewer.js", () => ({
|
|
54
|
+
fileViewerStore: mockFileViewerStore,
|
|
55
|
+
}));
|
|
56
|
+
|
|
45
57
|
shadowRoot = document.createElement("div").attachShadow({ mode: "open" });
|
|
58
|
+
const main = document.createElement("div");
|
|
59
|
+
main.classList.add("main-content");
|
|
60
|
+
shadowRoot.appendChild(main);
|
|
61
|
+
|
|
46
62
|
shadowClaw = { previousOrchestratorState: "idle", currentPage: "chat" };
|
|
47
63
|
db = {};
|
|
48
64
|
oStore = { state: "idle", activePage: "chat", activityLog: [] };
|
|
@@ -65,6 +81,29 @@ describe("setupEffects", () => {
|
|
|
65
81
|
expect(mockEffect).toHaveBeenCalledTimes(4);
|
|
66
82
|
});
|
|
67
83
|
|
|
84
|
+
it("fileViewerStore effect should load file-viewer and pdf-viewer and stamp DOM", async () => {
|
|
85
|
+
setupEffects(shadowRoot, shadowClaw, db, oStore);
|
|
86
|
+
const cb = effectCallbacks[0];
|
|
87
|
+
|
|
88
|
+
// When file is null, do nothing
|
|
89
|
+
mockFileViewerStore.file = null;
|
|
90
|
+
cb();
|
|
91
|
+
expect(mockEnsureComponentLoaded).not.toHaveBeenCalled();
|
|
92
|
+
|
|
93
|
+
// When file is a text file
|
|
94
|
+
mockFileViewerStore.file = { name: "doc.txt", kind: "text" };
|
|
95
|
+
cb();
|
|
96
|
+
expect(mockEnsureComponentLoaded).toHaveBeenCalledWith("file-viewer");
|
|
97
|
+
|
|
98
|
+
await Promise.resolve();
|
|
99
|
+
expect(shadowRoot.querySelector("shadow-claw-file-viewer")).not.toBeNull();
|
|
100
|
+
|
|
101
|
+
// When file is a PDF
|
|
102
|
+
mockFileViewerStore.file = { name: "manual.pdf", kind: "pdf" };
|
|
103
|
+
cb();
|
|
104
|
+
expect(mockEnsureComponentLoaded).toHaveBeenCalledWith("pdf-viewer");
|
|
105
|
+
});
|
|
106
|
+
|
|
68
107
|
it("orchestrator state effect should showSuccess when transitioning to idle from thinking/responding", () => {
|
|
69
108
|
setupEffects(shadowRoot, shadowClaw, db, oStore);
|
|
70
109
|
const cb = effectCallbacks[1];
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { applyWeight, renderChildrenList, variantToTag } from "./shared.js";
|
|
2
|
+
|
|
3
|
+
describe("catalog/basic/shared", () => {
|
|
4
|
+
describe("variantToTag", () => {
|
|
5
|
+
it("maps header variants to appropriate tags", () => {
|
|
6
|
+
expect(variantToTag("h1")).toBe("h1");
|
|
7
|
+
expect(variantToTag("h2")).toBe("h2");
|
|
8
|
+
expect(variantToTag("h3")).toBe("h3");
|
|
9
|
+
expect(variantToTag("h4")).toBe("h4");
|
|
10
|
+
expect(variantToTag("h5")).toBe("h5");
|
|
11
|
+
expect(variantToTag("body" as any)).toBe("span");
|
|
12
|
+
expect(variantToTag("caption" as any)).toBe("span");
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
describe("applyWeight", () => {
|
|
17
|
+
it("applies flexGrow when weight is defined", () => {
|
|
18
|
+
const el = document.createElement("div");
|
|
19
|
+
applyWeight(el, 2);
|
|
20
|
+
expect(el.style.flexGrow).toBe("2");
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("does nothing when weight is undefined", () => {
|
|
24
|
+
const el = document.createElement("div");
|
|
25
|
+
applyWeight(el, undefined);
|
|
26
|
+
expect(el.style.flexGrow).toBe("");
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
describe("renderChildrenList", () => {
|
|
31
|
+
it("renders array of component IDs", () => {
|
|
32
|
+
const rendered: HTMLElement[] = [];
|
|
33
|
+
const ctx = {
|
|
34
|
+
renderComponent: (id: string) => {
|
|
35
|
+
const div = document.createElement("div");
|
|
36
|
+
div.id = id;
|
|
37
|
+
return div;
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
renderChildrenList(
|
|
42
|
+
["comp-1", "comp-2"],
|
|
43
|
+
{ dataModel: {} } as any,
|
|
44
|
+
ctx,
|
|
45
|
+
(el) => rendered.push(el),
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
expect(rendered).toHaveLength(2);
|
|
49
|
+
expect(rendered[0].id).toBe("comp-1");
|
|
50
|
+
expect(rendered[1].id).toBe("comp-2");
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("renders array of objects with id property", () => {
|
|
54
|
+
const rendered: HTMLElement[] = [];
|
|
55
|
+
const ctx = {
|
|
56
|
+
renderComponent: (id: string) => {
|
|
57
|
+
const div = document.createElement("div");
|
|
58
|
+
div.id = id;
|
|
59
|
+
return div;
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
renderChildrenList(
|
|
64
|
+
[{ id: "item-a" }, { id: "item-b" }] as any,
|
|
65
|
+
{ dataModel: {} } as any,
|
|
66
|
+
ctx,
|
|
67
|
+
(el) => rendered.push(el),
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
expect(rendered).toHaveLength(2);
|
|
71
|
+
expect(rendered[0].id).toBe("item-a");
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("renders template bound to dataModel array", () => {
|
|
75
|
+
const rendered: HTMLElement[] = [];
|
|
76
|
+
const surface = {
|
|
77
|
+
dataModel: {
|
|
78
|
+
tasks: ["Task 1", "Task 2"],
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
const ctx = {
|
|
82
|
+
renderComponent: (id: string, scope?: any) => {
|
|
83
|
+
const div = document.createElement("div");
|
|
84
|
+
div.id = `${id}-${scope?.index}`;
|
|
85
|
+
div.textContent = String(scope?.itemValue);
|
|
86
|
+
return div;
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
renderChildrenList(
|
|
91
|
+
{ path: "/tasks", componentId: "task-item" },
|
|
92
|
+
surface as any,
|
|
93
|
+
ctx,
|
|
94
|
+
(el) => rendered.push(el),
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
expect(rendered).toHaveLength(2);
|
|
98
|
+
expect(rendered[0].textContent).toBe("Task 1");
|
|
99
|
+
expect(rendered[1].textContent).toBe("Task 2");
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("handles non-array template target gracefully", () => {
|
|
103
|
+
const rendered: HTMLElement[] = [];
|
|
104
|
+
const surface = { dataModel: { count: 42 } };
|
|
105
|
+
const ctx = { renderComponent: () => document.createElement("div") };
|
|
106
|
+
|
|
107
|
+
renderChildrenList(
|
|
108
|
+
{ path: "/count", componentId: "item" },
|
|
109
|
+
surface as any,
|
|
110
|
+
ctx,
|
|
111
|
+
(el) => rendered.push(el),
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
expect(rendered).toHaveLength(0);
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
});
|