@kabmo-labs/kabmo 0.26.0 → 0.28.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/dist/client/index.html +1 -1
- package/dist/client/index.js +502 -474
- package/dist/client/static/js/index-81f7berm.css +1 -0
- package/dist/client/static/js/{index-95b3n20k.js → index-xzvyrxya.js} +799 -799
- package/marketplace/plugins/command-runner/package.json +3 -17
- package/marketplace/plugins/command-runner/settings-schema.json +14 -0
- package/marketplace/plugins/git-forge/README.md +17 -7
- package/marketplace/plugins/git-forge/package.json +4 -30
- package/marketplace/plugins/git-forge/panel.css +16 -0
- package/marketplace/plugins/git-forge/settings-schema.json +27 -0
- package/marketplace/plugins/git-forge/src/panel/Badge.tsx +35 -22
- package/marketplace/plugins/git-forge/src/panel/Change.tsx +20 -24
- package/marketplace/plugins/git-forge/src/panel/CiBadge.tsx +16 -7
- package/marketplace/plugins/git-forge/src/panel/Credential.tsx +31 -26
- package/marketplace/plugins/git-forge/src/panel/Glyph.tsx +18 -2
- package/marketplace/plugins/git-forge/src/panel/Header.tsx +160 -96
- package/marketplace/plugins/git-forge/src/panel/ItemView.tsx +60 -44
- package/marketplace/plugins/git-forge/src/panel/List.tsx +150 -22
- package/marketplace/plugins/git-forge/src/panel/Row.tsx +11 -5
- package/marketplace/plugins/git-forge/src/panel/Sidebar.tsx +17 -15
- package/marketplace/plugins/git-forge/src/panel/Write.tsx +84 -61
- package/marketplace/plugins/git-forge/src/panel/format.test.ts +99 -0
- package/marketplace/plugins/git-forge/src/panel/format.ts +59 -16
- package/marketplace/plugins/git-forge/src/panel/index.test.tsx +109 -5
- package/marketplace/plugins/git-forge/src/panel/index.tsx +37 -4
- package/marketplace/plugins/git-forge/src/panel/use-forge.ts +17 -0
- package/marketplace/plugins/git-forge/src/panel/write.test.tsx +31 -0
- package/marketplace/plugins/session-info/package.json +2 -10
- package/marketplace/plugins/session-info/settings-schema.json +8 -0
- package/marketplace/plugins/stats/README.md +17 -5
- package/marketplace/plugins/stats/package.json +3 -23
- package/marketplace/plugins/stats/settings-schema.json +20 -0
- package/marketplace/plugins/stats/src/app.tsx +1 -1
- package/marketplace/plugins/stats/src/groups.test.ts +46 -1
- package/marketplace/plugins/stats/src/groups.ts +22 -11
- package/marketplace/plugins/stats/src/harness-leases.test.ts +84 -0
- package/marketplace/plugins/stats/src/harness-leases.ts +132 -0
- package/marketplace/plugins/stats/src/labels.test.ts +54 -1
- package/marketplace/plugins/stats/src/labels.ts +33 -7
- package/marketplace/plugins/stats/src/sampler.test.ts +61 -0
- package/marketplace/plugins/stats/src/sampler.ts +39 -5
- package/marketplace/plugins/stats/src/snapshot.ts +6 -0
- package/package.json +2 -2
- package/src/client/components/common/Toast.test.tsx +28 -2
- package/src/client/components/common/Toast.tsx +21 -9
- package/src/client/components/common/harness-glyph/index.tsx +18 -1
- package/src/client/components/common/session-actions-menu/index.test.tsx +106 -0
- package/src/client/components/common/session-actions-menu/index.tsx +43 -1
- package/src/client/components/common/session-row/TrailingSlot.tsx +9 -4
- package/src/client/components/common/session-row/index.tsx +4 -0
- package/src/client/components/common/session-row/session-row.test.tsx +6 -0
- package/src/client/components/layout/desktop-layout/LeftColumn.tsx +2 -1
- package/src/client/components/layout/session-sidebar/CategoryItem.tsx +4 -2
- package/src/client/components/layout/session-sidebar/SessionItem.tsx +9 -1
- package/src/client/components/layout/session-sidebar/SessionList.tsx +2 -1
- package/src/client/components/layout/session-sidebar/about-modal/UpdateSection.tsx +3 -2
- package/src/client/components/layout/session-sidebar/about-modal/index.tsx +2 -1
- package/src/client/components/layout/session-sidebar/modern/RevealRow.tsx +56 -0
- package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +12 -29
- package/src/client/components/layout/session-sidebar/modern/reveal-row.test.tsx +104 -0
- package/src/client/components/layout/session-sidebar/scheduler-modal/ModelFields.tsx +202 -0
- package/src/client/components/layout/session-sidebar/scheduler-modal/TaskForm.tsx +80 -19
- package/src/client/components/layout/session-sidebar/scheduler-modal/TaskList.tsx +23 -3
- package/src/client/components/layout/session-sidebar/scheduler-modal/index.tsx +5 -1
- package/src/client/components/layout/session-sidebar/variant-props.ts +2 -1
- package/src/client/components/mobile/SessionSidebar.tsx +2 -1
- package/src/client/components/mobile/mobile-right-sidebar/EditorSurface.tsx +156 -0
- package/src/client/components/mobile/mobile-right-sidebar/FullEditor.tsx +41 -86
- package/src/client/components/mobile/mobile-session-sidebar/ClassicDrawer.tsx +2 -1
- package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +4 -2
- package/src/client/components/mobile/mobile-session-sidebar/List.tsx +2 -1
- package/src/client/components/mobile/mobile-session-sidebar/SessionRow.test.ts +6 -0
- package/src/client/components/mobile/mobile-session-sidebar/SessionRow.tsx +9 -1
- package/src/client/components/settings/Modal.tsx +7 -3
- package/src/client/components/settings/Sidebar.tsx +30 -3
- package/src/client/components/settings/categories/HarnessSettings.tsx +11 -7
- package/src/client/components/settings/categories/NotificationSettings.test.tsx +40 -15
- package/src/client/components/settings/categories/NotificationSettings.tsx +142 -64
- package/src/client/components/settings/categories/PanelPluginSettings.tsx +1 -1
- package/src/client/components/settings/categories/harness-settings/CustomHarnessForm.tsx +186 -0
- package/src/client/components/settings/categories/panel-plugins/InstalledList.tsx +11 -0
- package/src/client/components/settings/categories/panel-plugins/PluginCard.test.tsx +1 -0
- package/src/client/components/settings/categories/panel-plugins/PluginCard.tsx +15 -1
- package/src/client/components/settings/categories/panel-plugins/SettingsModal.test.tsx +165 -0
- package/src/client/components/settings/categories/panel-plugins/SettingsModal.tsx +260 -0
- package/src/client/components/settings/categories/project-settings/WorktreeSettings.tsx +2 -1
- package/src/client/components/settings/categories/usage-settings/LimitsSection.tsx +39 -19
- package/src/client/components/settings/categories/usage-settings/ProviderDetail.tsx +1 -0
- package/src/client/components/settings/categories/usage-settings/limit-groups.test.ts +94 -0
- package/src/client/components/settings/categories/usage-settings/limit-groups.ts +118 -0
- package/src/client/components/settings/categories/usage-settings/limits-section.test.tsx +118 -0
- package/src/client/components/workspace/chat-timeline/AiMessageFooter.fork.test.ts +24 -0
- package/src/client/components/workspace/chat-timeline/AiMessageFooter.tsx +8 -4
- package/src/client/components/workspace/chat-timeline/ComposerDock.tsx +34 -0
- package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +61 -56
- package/src/client/components/workspace/chat-timeline/MessageItem.fork.test.ts +80 -0
- package/src/client/components/workspace/chat-timeline/MessageItem.tsx +9 -3
- package/src/client/components/workspace/chat-timeline/MessageList.tsx +3 -1
- package/src/client/components/workspace/chat-timeline/PendingChatView.tsx +11 -1
- package/src/client/components/workspace/chat-timeline/PendingTranscript.tsx +130 -0
- package/src/client/components/workspace/chat-timeline/RunFooter.tsx +2 -1
- package/src/client/components/workspace/chat-timeline/TimelineBody.tsx +2 -1
- package/src/client/components/workspace/chat-timeline/chat-input/ComposerRows.tsx +8 -0
- package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.test.tsx +9 -0
- package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.tsx +4 -1
- package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +24 -0
- package/src/client/components/workspace/chat-timeline/chat-input/WaitingDependencyPicker.tsx +13 -20
- package/src/client/components/workspace/chat-timeline/chat-input/index.tsx +2 -0
- package/src/client/components/workspace/chat-timeline/chat-input/props.ts +5 -5
- package/src/client/components/workspace/chat-timeline/fork-preview.test.tsx +141 -0
- package/src/client/components/workspace/chat-timeline/index.tsx +17 -6
- package/src/client/components/workspace/chat-timeline/target-picker/DraftTargetRow.tsx +3 -10
- package/src/client/components/workspace/chat-timeline/target-picker/ParentSessionPicker.test.tsx +101 -0
- package/src/client/components/workspace/chat-timeline/target-picker/ParentSessionPicker.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/target-picker/WorktreePicker.tsx +5 -4
- package/src/client/components/workspace/editor/FilePane.tsx +9 -4
- package/src/client/components/workspace/editor/Notices.tsx +2 -2
- package/src/client/components/workspace/editor/Pane.tsx +2 -2
- package/src/client/components/workspace/editor/Toolbar.tsx +16 -10
- package/src/client/components/workspace/editor/index.tsx +6 -10
- package/src/client/components/workspace/editor/toolbar-clusters.test.ts +4 -3
- package/src/client/components/workspace/editor/toolbar-clusters.tsx +23 -14
- package/src/client/components/workspace/git-panel/index.tsx +2 -2
- package/src/client/components/workspace/terminal-panel/RealtimeTerminalView.tsx +17 -6
- package/src/client/components/workspace/terminal-panel/focus.test.ts +70 -0
- package/src/client/components/workspace/terminal-panel/focus.ts +46 -0
- package/src/client/components/workspace/terminal-panel/index.tsx +17 -1
- package/src/client/components/workspace/terminal-panel/mount.ts +17 -9
- package/src/client/components/workspace/terminal-panel/scroll-hold.test.ts +158 -0
- package/src/client/components/workspace/terminal-panel/scroll-hold.ts +136 -0
- package/src/client/hooks/chat/composer/use-draft.ts +45 -1
- package/src/client/hooks/chat/omp/pending-sessions.waiting.test.ts +11 -10
- package/src/client/hooks/chat/omp/pending-waiting.ts +15 -7
- package/src/client/hooks/chat/omp/prompt-send.test.ts +11 -0
- package/src/client/hooks/chat/omp/prompt-send.ts +3 -0
- package/src/client/hooks/chat/omp/session-list.tsx +5 -0
- package/src/client/hooks/chat/omp/sidebar-reload.test.ts +85 -0
- package/src/client/hooks/chat/omp/sidebar-reload.ts +30 -0
- package/src/client/hooks/chat/timeline/actions.ts +4 -4
- package/src/client/hooks/chat/timeline/composer-modes.ts +13 -2
- package/src/client/hooks/chat/timeline/fork-open.ts +52 -0
- package/src/client/hooks/chat/timeline/fork-preview.test.ts +148 -0
- package/src/client/hooks/chat/timeline/fork-preview.ts +104 -0
- package/src/client/hooks/chat/timeline/fork-send.test.ts +139 -0
- package/src/client/hooks/chat/timeline/index.ts +5 -2
- package/src/client/hooks/chat/timeline/mode-availability.ts +7 -0
- package/src/client/hooks/chat/timeline/modes-contract.ts +6 -0
- package/src/client/hooks/chat/timeline/modes-hydrate.ts +93 -0
- package/src/client/hooks/chat/timeline/modes.ts +32 -52
- package/src/client/hooks/chat/timeline/new-chat-open.ts +7 -6
- package/src/client/hooks/chat/timeline/new-chat.ts +10 -1
- package/src/client/hooks/chat/timeline/pending-branch.ts +9 -0
- package/src/client/hooks/chat/timeline/pending-dispatch.ts +53 -0
- package/src/client/hooks/chat/timeline/pending-session-mode.test.ts +136 -0
- package/src/client/hooks/chat/timeline/pending-session-mode.ts +69 -0
- package/src/client/hooks/chat/timeline/pending-warmup.test.ts +147 -0
- package/src/client/hooks/chat/timeline/pending-warmup.ts +62 -0
- package/src/client/hooks/chat/timeline/run-identity.test.ts +12 -0
- package/src/client/hooks/chat/timeline/run-identity.ts +4 -1
- package/src/client/hooks/chat/timeline/send-props.ts +2 -0
- package/src/client/hooks/chat/timeline/send-steer.test.ts +1 -0
- package/src/client/hooks/chat/timeline/send.test-util.ts +1 -0
- package/src/client/hooks/chat/timeline/send.test.ts +1 -0
- package/src/client/hooks/chat/timeline/session-harness.ts +4 -0
- package/src/client/hooks/chat/timeline/stop-with-queue.ts +1 -1
- package/src/client/hooks/chat/timeline/use-fork-session.ts +9 -22
- package/src/client/hooks/chat/waiting/cancel.ts +15 -7
- package/src/client/hooks/chat/waiting/choice.ts +13 -16
- package/src/client/hooks/chat/waiting/composer-wait.ts +70 -0
- package/src/client/hooks/chat/waiting/dispatch.ts +50 -29
- package/src/client/hooks/chat/waiting/held.ts +38 -13
- package/src/client/hooks/chat/waiting/hold.test.ts +22 -0
- package/src/client/hooks/chat/waiting/hold.ts +20 -11
- package/src/client/hooks/chat/waiting/restore.test.ts +69 -0
- package/src/client/hooks/chat/waiting/restore.ts +34 -0
- package/src/client/hooks/chat/waiting/store.ts +9 -3
- package/src/client/hooks/editor/file-editor-types.ts +21 -12
- package/src/client/hooks/editor/save-file.test.ts +1 -1
- package/src/client/hooks/editor/save-file.ts +35 -8
- package/src/client/hooks/editor/target-key.ts +17 -0
- package/src/client/hooks/editor/use-disk-digest.test.ts +82 -0
- package/src/client/hooks/editor/use-disk-digest.ts +164 -0
- package/src/client/hooks/editor/use-disk-sync.ts +212 -0
- package/src/client/hooks/editor/use-file-cache.ts +113 -0
- package/src/client/hooks/editor/use-file-editor.test.ts +90 -0
- package/src/client/hooks/editor/use-file-editor.ts +90 -52
- package/src/client/hooks/editor/use-file-read.ts +24 -10
- package/src/client/hooks/editor/use-file-writes.ts +4 -4
- package/src/client/hooks/models/harness-catalog.ts +15 -0
- package/src/client/hooks/settings/providers/actions.ts +3 -2
- package/src/client/hooks/settings/providers/messages.ts +9 -7
- package/src/client/hooks/settings/providers/model-actions.ts +2 -1
- package/src/client/hooks/ui/editor-error-toast.ts +2 -1
- package/src/client/hooks/ui/notifications.ts +17 -8
- package/src/client/hooks/workspace/batch-archive.test.ts +2 -2
- package/src/client/hooks/workspace/batch-archive.ts +4 -2
- package/src/client/hooks/workspace/git-action-outcome.ts +4 -3
- package/src/client/hooks/workspace/navbar-session-actions.ts +2 -1
- package/src/client/hooks/workspace/panel-registry.ts +1 -1
- package/src/client/hooks/workspace/scheduled-tasks.ts +26 -11
- package/src/client/hooks/workspace/session-actions.test.ts +2 -1
- package/src/client/hooks/workspace/session-actions.ts +2 -1
- package/src/client/hooks/workspace/terminal/connection.test.ts +63 -0
- package/src/client/hooks/workspace/terminal/connection.ts +47 -0
- package/src/client/hooks/workspace/terminal/index.ts +35 -4
- package/src/client/hooks/workspace/workspace-folder-actions.ts +2 -1
- package/src/client/lib/notifications/os.test.ts +1 -30
- package/src/client/lib/notifications/os.ts +0 -15
- package/src/client/lib/notifications/platform.test.ts +68 -0
- package/src/client/lib/notifications/platform.ts +36 -0
- package/src/server/index.ts +7 -0
- package/src/server/lib/harness/acp/client.ts +81 -87
- package/src/server/lib/harness/acp/prewarm.server.ts +237 -0
- package/src/server/lib/harness/acp/prewarm.test.ts +171 -0
- package/src/server/lib/harness/acp/prompt.test.ts +70 -1
- package/src/server/lib/harness/acp/prompt.ts +32 -1
- package/src/server/lib/harness/acp/protocol.ts +23 -0
- package/src/server/lib/harness/acp/session-handshake.test.ts +26 -0
- package/src/server/lib/harness/acp/session-handshake.ts +22 -20
- package/src/server/lib/harness/acp/session-options.ts +16 -0
- package/src/server/lib/harness/acp/session-process.ts +43 -0
- package/src/server/lib/harness/acp/session.ts +11 -12
- package/src/server/lib/harness/acp/stdio.ts +129 -0
- package/src/server/lib/harness/acp/verbs.test.ts +97 -0
- package/src/server/lib/harness/acp/verbs.ts +16 -6
- package/src/server/lib/harness/auto-probe.server.ts +4 -3
- package/src/server/lib/harness/capabilities.ts +8 -0
- package/src/server/lib/harness/config.server.ts +3 -2
- package/src/server/lib/harness/custom.server.ts +209 -0
- package/src/server/lib/harness/launch.ts +6 -1
- package/src/server/lib/harness/register.server.ts +8 -1
- package/src/server/lib/harness/schema.server.ts +21 -0
- package/src/server/lib/harness/session-lease.server.test.ts +99 -0
- package/src/server/lib/harness/session-lease.server.ts +193 -0
- package/src/server/lib/harness/session-store.server.test.ts +8 -8
- package/src/server/lib/harness/session-store.server.ts +25 -4
- package/src/server/lib/harness/session-title.server.ts +12 -2
- package/src/server/lib/harness/spawn.server.ts +123 -20
- package/src/server/lib/harness/update-queue.server.ts +3 -3
- package/src/server/lib/lifecycle/after-listen.ts +12 -1
- package/src/server/lib/lifecycle/paths.ts +19 -1
- package/src/server/lib/mcp/registry.server.ts +155 -0
- package/src/server/lib/mcp/registry.test.ts +169 -0
- package/src/server/lib/mcp/store.server.ts +38 -0
- package/src/server/lib/omp/rpc/frame-fold-contract.ts +59 -0
- package/src/server/lib/omp/rpc/frame-fold-frames.test.ts +64 -1
- package/src/server/lib/omp/rpc/frame-fold-host.test-util.ts +2 -1
- package/src/server/lib/omp/rpc/frame-fold.test.ts +2 -1
- package/src/server/lib/omp/rpc/frame-fold.ts +6 -45
- package/src/server/lib/omp/rpc/prewarm-pool.ts +19 -5
- package/src/server/lib/omp/rpc/run-model.test.ts +116 -0
- package/src/server/lib/omp/rpc/run-model.ts +4 -2
- package/src/server/lib/omp/session/sidebar-data.harness.test.ts +6 -3
- package/src/server/lib/omp/session/standby.server.ts +13 -2
- package/src/server/lib/panels/manifest.test.ts +47 -1
- package/src/server/lib/panels/manifest.ts +19 -0
- package/src/server/lib/panels/registry.server.ts +19 -2
- package/src/server/lib/panels/scan.server.ts +26 -2
- package/src/server/lib/panels/settings-schema.server.ts +72 -0
- package/src/server/lib/plugins/background.server.ts +21 -3
- package/src/server/lib/plugins/background.test.ts +13 -0
- package/src/server/lib/plugins/loader.server.ts +35 -51
- package/src/server/lib/plugins/mcp.server.ts +100 -0
- package/src/server/lib/plugins/mcp.test.ts +75 -0
- package/src/server/lib/plugins/schedule-runner.server.ts +153 -0
- package/src/server/lib/plugins/schedule-runner.test.ts +186 -0
- package/src/server/lib/plugins/schedule-store.server.ts +107 -0
- package/src/server/lib/plugins/schema.server.ts +8 -0
- package/src/server/lib/plugins/settings.server.ts +56 -19
- package/src/server/lib/plugins/shutdown.server.ts +58 -0
- package/src/server/lib/plugins/shutdown.test.ts +28 -3
- package/src/server/lib/realtime/topics/global.server.ts +5 -1
- package/src/server/lib/schedule/rows.server.ts +9 -0
- package/src/server/lib/schedule/runtime.server.test.ts +91 -0
- package/src/server/lib/schedule/runtime.server.ts +101 -23
- package/src/server/lib/schedule/schema.server.ts +15 -0
- package/src/server/lib/schedule/store.server.test.ts +34 -0
- package/src/server/lib/schedule/store.server.ts +33 -9
- package/src/server/lib/sessions/fork.server.test.ts +47 -0
- package/src/server/lib/sessions/fork.server.ts +17 -1
- package/src/server/lib/sessions/spawn.server.ts +2 -2
- package/src/server/lib/usage/report.server.ts +57 -0
- package/src/server/lib/waiting/runtime.server.test.ts +48 -0
- package/src/server/lib/waiting/runtime.server.ts +22 -0
- package/src/server/lib/waiting/schema.server.ts +8 -0
- package/src/server/lib/waiting/store.server.test.ts +14 -0
- package/src/server/lib/waiting/store.server.ts +6 -2
- package/src/server/routes/agent/command-resume.test.ts +9 -4
- package/src/server/routes/agent/new-mode.test.ts +40 -0
- package/src/server/routes/agent/new.ts +31 -10
- package/src/server/routes/agent/prewarm.ts +48 -7
- package/src/server/routes/fs/action.ts +9 -1
- package/src/server/routes/fs/digest.test.ts +100 -0
- package/src/server/routes/fs/digest.ts +106 -0
- package/src/server/routes/fs/index.ts +2 -0
- package/src/server/routes/fs/read.ts +6 -1
- package/src/server/routes/harness/custom.test.ts +131 -0
- package/src/server/routes/harness/import-action.ts +2 -2
- package/src/server/routes/harness/root.ts +41 -8
- package/src/server/routes/harness/update.ts +2 -2
- package/src/server/routes/panels/bindings.ts +2 -0
- package/src/server/routes/panels/settings.test.ts +165 -0
- package/src/server/routes/panels/settings.ts +106 -0
- package/src/server/routes/schedule/body.ts +14 -0
- package/src/server/routes/schedule/index.ts +28 -4
- package/src/server/routes/settings/mcp.ts +9 -26
- package/src/server/routes/waiting/index.ts +21 -2
- package/src/server/routes/waiting/routes.test.ts +21 -0
- package/src/shared/lib/chat/composer/delegation.ts +3 -3
- package/src/shared/lib/chat/timeline/fork-anchor.test.ts +97 -0
- package/src/shared/lib/chat/timeline/fork-anchor.ts +47 -0
- package/src/shared/lib/chat/timeline/fork-preview.test.ts +62 -0
- package/src/shared/lib/chat/timeline/fork-preview.ts +36 -0
- package/src/shared/lib/fs/content-hash.ts +29 -0
- package/src/shared/lib/harness/catalog.ts +48 -6
- package/src/shared/lib/harness/fork.ts +60 -0
- package/src/shared/lib/harness/mcp-facts.test.ts +30 -0
- package/src/shared/lib/harness/mcp-facts.ts +65 -0
- package/src/shared/lib/harness/menu.test.ts +16 -1
- package/src/shared/lib/harness/menu.ts +2 -2
- package/src/shared/lib/harness/rewind.ts +6 -6
- package/src/shared/lib/harness/session-modes.ts +31 -0
- package/src/shared/lib/harness/transcript.test.ts +29 -0
- package/src/shared/lib/harness/transcript.ts +19 -0
- package/src/shared/lib/notifications/settings.test.ts +21 -0
- package/src/shared/lib/notifications/settings.ts +24 -0
- package/src/shared/lib/omp/session/prewarm.test.ts +28 -4
- package/src/shared/lib/omp/session/prewarm.ts +25 -6
- package/src/shared/lib/omp/session/stream-state.server.test.ts +25 -0
- package/src/shared/lib/omp/session/stream-state.server.ts +8 -4
- package/src/shared/lib/panels/capabilities.test.ts +1 -1
- package/src/shared/lib/panels/capabilities.ts +3 -0
- package/src/shared/lib/plugins/settings.ts +22 -0
- package/src/shared/lib/schedule/parse.test.ts +48 -0
- package/src/shared/lib/schedule/parse.ts +69 -45
- package/src/shared/lib/schedule/timezone.ts +128 -0
- package/src/shared/lib/settings/defaults.ts +2 -0
- package/src/shared/lib/ui/toast-duration.test.ts +25 -1
- package/src/shared/lib/ui/toast-duration.ts +22 -4
- package/src/shared/lib/workspace/refresh-cadence.test.ts +25 -1
- package/src/shared/lib/workspace/relative-time.ts +16 -0
- package/src/shared/lib/workspace/session-state/store.ts +4 -0
- package/src/shared/types/harness.ts +7 -0
- package/src/shared/types/omp/agent.ts +6 -0
- package/src/shared/types/panels-registry.ts +3 -3
- package/src/shared/types/panels.ts +4 -2
- package/src/shared/types/schedule.ts +13 -0
- package/src/shared/types/settings/state.ts +12 -1
- package/src/shared/types/waiting.ts +9 -0
- package/src/test-support/file-editor.test-util.ts +70 -5
- package/dist/client/static/js/index-p2yw9ywf.css +0 -1
- package/src/client/hooks/editor/use-external-change-notice.ts +0 -71
- package/src/client/hooks/editor/use-external-change.test.ts +0 -88
- package/src/client/hooks/editor/use-external-change.ts +0 -146
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A harness the user adds, end to end through the route.
|
|
8
|
+
*
|
|
9
|
+
* The transport was already generic; what these tests pin is the registry the
|
|
10
|
+
* synchronous call sites read: a saved row must become a descriptor, a launch
|
|
11
|
+
* line, a catalog entry and a probe target, and a removal must take all four
|
|
12
|
+
* away without rewriting the chats that ran on it.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { afterAll, beforeEach, describe, expect, test } from 'bun:test';
|
|
16
|
+
import { isolateDb, releaseDb } from '@/test-support/isolated-db';
|
|
17
|
+
import { getDb } from '@/server/db.server';
|
|
18
|
+
import { action, loader } from '@/server/routes/harness/root';
|
|
19
|
+
import { loadHarnessConfig, resolveLaunch } from '@/server/lib/harness/config.server';
|
|
20
|
+
import { customHarness, refreshCustomHarnesses } from '@/server/lib/harness/custom.server';
|
|
21
|
+
import { harnessDescriptor } from '@/shared/lib/harness/catalog';
|
|
22
|
+
|
|
23
|
+
const API = 'http://localhost/api/harness';
|
|
24
|
+
|
|
25
|
+
type Handler = (args: never) => unknown;
|
|
26
|
+
|
|
27
|
+
function call(handler: Handler, request: Request): Promise<Response> {
|
|
28
|
+
return handler({ request, params: {} } as never) as Promise<Response>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function post(body: unknown): Request {
|
|
32
|
+
return new Request(API, {
|
|
33
|
+
method: 'POST',
|
|
34
|
+
body: JSON.stringify(body),
|
|
35
|
+
headers: { 'content-type': 'application/json' },
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** The route's refusal sentence, narrowed rather than cast. */
|
|
40
|
+
async function errorOf(response: Response): Promise<string> {
|
|
41
|
+
const payload: unknown = await response.json();
|
|
42
|
+
if (payload && typeof payload === 'object' && 'error' in payload && typeof payload.error === 'string') {
|
|
43
|
+
return payload.error;
|
|
44
|
+
}
|
|
45
|
+
return '';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function add(overrides: Record<string, unknown> = {}): Promise<Response> {
|
|
49
|
+
return call(action, post({
|
|
50
|
+
customHarness: {
|
|
51
|
+
id: 'my-agent',
|
|
52
|
+
label: 'My Agent',
|
|
53
|
+
command: 'npx -y my-agent acp',
|
|
54
|
+
...overrides,
|
|
55
|
+
},
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
beforeEach(async () => {
|
|
60
|
+
await isolateDb();
|
|
61
|
+
await (await getDb()).run('DELETE FROM custom_harnesses');
|
|
62
|
+
await refreshCustomHarnesses();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
afterAll(async () => {
|
|
66
|
+
await releaseDb();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
describe('custom harness route', () => {
|
|
70
|
+
test('a saved harness becomes a descriptor and a launch line', async () => {
|
|
71
|
+
const response = await add({ env: 'TOKEN=abc' });
|
|
72
|
+
expect(response.status).toBe(200);
|
|
73
|
+
|
|
74
|
+
expect(customHarness('my-agent')?.label).toBe('My Agent');
|
|
75
|
+
expect(harnessDescriptor('my-agent')).toMatchObject({
|
|
76
|
+
id: 'my-agent',
|
|
77
|
+
label: 'My Agent',
|
|
78
|
+
transport: 'acp',
|
|
79
|
+
glyph: 'custom',
|
|
80
|
+
});
|
|
81
|
+
const launch = resolveLaunch('my-agent', await loadHarnessConfig('my-agent'));
|
|
82
|
+
expect(launch.command).toEqual(['npx', '-y', 'my-agent', 'acp']);
|
|
83
|
+
expect(launch.env).toEqual({ TOKEN: 'abc' });
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test('the catalog lists it with custom and initial', async () => {
|
|
87
|
+
await add();
|
|
88
|
+
const response = await call(loader, new Request(API));
|
|
89
|
+
const payload = (await response.json()) as { harnesses: Array<Record<string, unknown>> };
|
|
90
|
+
const row = payload.harnesses.find((entry) => entry.id === 'my-agent');
|
|
91
|
+
expect(row).toMatchObject({ custom: true, label: 'My Agent', initial: 'M', transport: 'acp' });
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
test('a built-in id is refused by name', async () => {
|
|
95
|
+
const response = await add({ id: 'claude' });
|
|
96
|
+
expect(response.status).toBe(400);
|
|
97
|
+
expect(await errorOf(response)).toContain('already ships');
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test('a malformed id is refused', async () => {
|
|
101
|
+
const response = await add({ id: 'My Agent!' });
|
|
102
|
+
expect(response.status).toBe(400);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test('an empty command is refused', async () => {
|
|
106
|
+
const response = await add({ command: ' ' });
|
|
107
|
+
expect(response.status).toBe(400);
|
|
108
|
+
expect(await errorOf(response)).toContain('command is required');
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
test('an invalid env line is refused', async () => {
|
|
112
|
+
const response = await add({ env: 'NOT A LINE' });
|
|
113
|
+
expect(response.status).toBe(400);
|
|
114
|
+
expect(await errorOf(response)).toContain('invalid env line');
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
test('removal drops the descriptor and the launch line', async () => {
|
|
118
|
+
await add();
|
|
119
|
+
const response = await call(action, post({ removeHarness: 'my-agent' }));
|
|
120
|
+
expect(response.status).toBe(200);
|
|
121
|
+
expect(customHarness('my-agent')).toBeUndefined();
|
|
122
|
+
expect(harnessDescriptor('my-agent')).toBeUndefined();
|
|
123
|
+
expect(() => resolveLaunch('my-agent', { command: '', env: '', provider: '', model: '', thinking: '', mode: '' }))
|
|
124
|
+
.toThrow('No launch command is configured');
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
test('a built-in cannot be removed', async () => {
|
|
128
|
+
const response = await call(action, post({ removeHarness: 'claude' }));
|
|
129
|
+
expect(response.status).toBe(400);
|
|
130
|
+
});
|
|
131
|
+
});
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
26
|
import { json } from '@/server/lib/remix-compat';
|
|
27
|
-
import {
|
|
27
|
+
import { isBuiltinHarness, type HarnessId } from '@/shared/lib/harness/catalog';
|
|
28
28
|
import { adaptBaseUrl, planProtocol, supportedProtocols, type CanonicalProtocol } from '@/shared/lib/harness/dialects';
|
|
29
29
|
import { providerFacts } from '@/shared/lib/harness/provider-facts';
|
|
30
30
|
import { providerEnv, providerLevel, registryLabel } from '@/shared/lib/harness/providers';
|
|
@@ -270,7 +270,7 @@ export function isImportBody(value: unknown): boolean {
|
|
|
270
270
|
|
|
271
271
|
/** A source id the import may read from. Refuses before any file is touched. */
|
|
272
272
|
export function importSourceOf(value: unknown): HarnessId | null {
|
|
273
|
-
return typeof value === 'string' &&
|
|
273
|
+
return typeof value === 'string' && isBuiltinHarness(value)
|
|
274
274
|
? (value as HarnessId)
|
|
275
275
|
: null;
|
|
276
276
|
}
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
import { json } from '@/server/lib/remix-compat';
|
|
19
19
|
import type { ActionFunctionArgs, LoaderFunctionArgs } from '@/server/lib/remix-compat';
|
|
20
20
|
import { methodNotAllowed } from '@/server/lib/route-adapter';
|
|
21
|
-
import {
|
|
21
|
+
import { harnessDescriptor, harnessIds, isBuiltinHarness, type HarnessId } from '@/shared/lib/harness/catalog';
|
|
22
|
+
import { customLaunch, ensureCustomHarnesses, removeCustomHarness, saveCustomHarness, type CustomHarnessInput } from '@/server/lib/harness/custom.server';
|
|
22
23
|
import { HARNESS_LAUNCH } from '@/server/lib/harness/launch-table';
|
|
23
24
|
import type { HarnessProbe } from '@/server/lib/harness/capabilities';
|
|
24
25
|
import { forgetProbe, loadProbes, rememberProbe } from '@/server/lib/harness/probe-cache.server';
|
|
@@ -54,6 +55,10 @@ export interface HarnessSummary {
|
|
|
54
55
|
* choice, so the settings page omits it — see `installable` on the catalog
|
|
55
56
|
* descriptor. */
|
|
56
57
|
builtIn?: true;
|
|
58
|
+
/** True for a harness the user added, so the card can offer Remove. */
|
|
59
|
+
custom?: true;
|
|
60
|
+
/** The letter the UI draws when there is no vendor mark. */
|
|
61
|
+
initial: string;
|
|
57
62
|
install?: string;
|
|
58
63
|
note?: string;
|
|
59
64
|
probe: HarnessProbe | null;
|
|
@@ -62,6 +67,9 @@ export interface HarnessSummary {
|
|
|
62
67
|
}
|
|
63
68
|
|
|
64
69
|
export async function listHarnesses(): Promise<HarnessSummary[]> {
|
|
70
|
+
// A user-added harness is a database row; the synchronous launch resolver
|
|
71
|
+
// reads the registry this fills.
|
|
72
|
+
await ensureCustomHarnesses();
|
|
65
73
|
// ONE read for the whole catalog, from disk when memory is cold: the probe
|
|
66
74
|
// cache used to be process-only, so every restart — every `bun --hot` reload —
|
|
67
75
|
// turned a harness the user had just checked back into `not probed`.
|
|
@@ -72,10 +80,10 @@ export async function listHarnesses(): Promise<HarnessSummary[]> {
|
|
|
72
80
|
// above — this is the one catalog answer.
|
|
73
81
|
const disabled = await loadDisabledHarnesses();
|
|
74
82
|
const configs: Record<string, HarnessConfig> = {};
|
|
75
|
-
for (const id of
|
|
76
|
-
return
|
|
83
|
+
for (const id of harnessIds()) configs[id] = await loadHarnessConfig(id);
|
|
84
|
+
return harnessIds().map((id) => {
|
|
77
85
|
const descriptor = harnessDescriptor(id);
|
|
78
|
-
const launch = HARNESS_LAUNCH[id];
|
|
86
|
+
const launch = HARNESS_LAUNCH[id] ?? customLaunch(id);
|
|
79
87
|
const cached = stored.get(id) ?? null;
|
|
80
88
|
// A BUILT-IN transport is never represented by a probe. There is no agent to
|
|
81
89
|
// spawn, so `probeHarness` can only answer "no launch command is configured"
|
|
@@ -88,9 +96,11 @@ export async function listHarnesses(): Promise<HarnessSummary[]> {
|
|
|
88
96
|
id,
|
|
89
97
|
label: descriptor?.label ?? id,
|
|
90
98
|
transport: descriptor?.transport ?? 'acp',
|
|
99
|
+
initial: descriptor?.initial ?? id.charAt(0).toUpperCase(),
|
|
91
100
|
canLaunch: available,
|
|
92
101
|
enabled: harnessEnabled(id, disabled),
|
|
93
102
|
...(descriptor?.builtIn ? { builtIn: true as const } : {}),
|
|
103
|
+
...(isBuiltinHarness(id) ? {} : { custom: true as const }),
|
|
94
104
|
...(launch?.install ? { install: launch.install } : {}),
|
|
95
105
|
...(launch?.note ? { note: launch.note } : {}),
|
|
96
106
|
probe: fresh,
|
|
@@ -104,10 +114,11 @@ export async function listHarnesses(): Promise<HarnessSummary[]> {
|
|
|
104
114
|
}
|
|
105
115
|
|
|
106
116
|
export async function loader({ request }: LoaderFunctionArgs) {
|
|
117
|
+
await ensureCustomHarnesses();
|
|
107
118
|
const url = new URL(request.url);
|
|
108
119
|
const target = url.searchParams.get('probe');
|
|
109
120
|
if (target) {
|
|
110
|
-
if (!
|
|
121
|
+
if (!harnessDescriptor(target)) {
|
|
111
122
|
return json({ error: `Unknown harness: ${target}` }, { status: 400 });
|
|
112
123
|
}
|
|
113
124
|
// Refused, not probed: a built-in transport has nothing to spawn, and the
|
|
@@ -126,14 +137,14 @@ export async function loader({ request }: LoaderFunctionArgs) {
|
|
|
126
137
|
// card renders its form from this one payload, so opening a card cannot show a
|
|
127
138
|
// stale value the server would then refuse to save.
|
|
128
139
|
const configs: Record<string, HarnessConfig> = {};
|
|
129
|
-
for (const id of
|
|
140
|
+
for (const id of harnessIds()) configs[id] = await loadHarnessConfig(id);
|
|
130
141
|
|
|
131
142
|
// What each harness can do about OTHER providers, from the MEASURED table: the
|
|
132
143
|
// file, the field names, whether Kabmo may write it, and the credential-free
|
|
133
144
|
// list of entries a copy could take. No credential travels here — the key is
|
|
134
145
|
// read by the request that writes.
|
|
135
146
|
const providerSupportByHarness: Record<string, HarnessProviderSupport> = {};
|
|
136
|
-
for (const id of
|
|
147
|
+
for (const id of harnessIds()) {
|
|
137
148
|
const facts = providerFacts(id);
|
|
138
149
|
const level = providerLevel(id);
|
|
139
150
|
if (level === 'none') continue;
|
|
@@ -168,6 +179,9 @@ export async function loader({ request }: LoaderFunctionArgs) {
|
|
|
168
179
|
|
|
169
180
|
export async function action({ request, params }: ActionFunctionArgs) {
|
|
170
181
|
if (request.method !== 'POST') return methodNotAllowed({ request, params });
|
|
182
|
+
// A custom harness is a database row and the descriptor helpers are
|
|
183
|
+
// synchronous; load the registry before any branch reads one.
|
|
184
|
+
await ensureCustomHarnesses();
|
|
171
185
|
// The body is UNTRUSTED and every branch below reads a different field, so it
|
|
172
186
|
// is narrowed to a record ONCE. `record` is a real runtime check, not a cast:
|
|
173
187
|
// a request that is not a JSON object falls through to the probe validation
|
|
@@ -177,8 +191,27 @@ export async function action({ request, params }: ActionFunctionArgs) {
|
|
|
177
191
|
parsed && typeof parsed === 'object' && !Array.isArray(parsed)
|
|
178
192
|
? (parsed as Record<string, unknown>)
|
|
179
193
|
: {};
|
|
194
|
+
// A CUSTOM HARNESS write: `{ customHarness: { id, label, command, env? } }`.
|
|
195
|
+
// Handled before the probe validation because it names no probe.
|
|
196
|
+
if (body.customHarness !== undefined) {
|
|
197
|
+
try {
|
|
198
|
+
const saved = await saveCustomHarness(body.customHarness as CustomHarnessInput);
|
|
199
|
+
return json({ customHarness: saved });
|
|
200
|
+
} catch (cause) {
|
|
201
|
+
return json({ error: cause instanceof Error ? cause.message : 'Could not save this harness' }, { status: 400 });
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
// A REMOVAL: `{ removeHarness: id }`. Built-ins are refused by name.
|
|
205
|
+
if (typeof body.removeHarness === 'string') {
|
|
206
|
+
const target = body.removeHarness;
|
|
207
|
+
if (isBuiltinHarness(target)) {
|
|
208
|
+
return json({ error: `${target} is a harness this build ships and cannot be removed` }, { status: 400 });
|
|
209
|
+
}
|
|
210
|
+
await removeCustomHarness(target);
|
|
211
|
+
return json({ removed: target });
|
|
212
|
+
}
|
|
180
213
|
const id = typeof body.probe === 'string' ? body.probe : null;
|
|
181
|
-
if (!id || !
|
|
214
|
+
if (!id || !harnessDescriptor(id)) {
|
|
182
215
|
return json({ error: 'probe must name a known harness id' }, { status: 400 });
|
|
183
216
|
}
|
|
184
217
|
// A TOGGLE: `{ probe: id, enabled: boolean }`.
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
import { json, NO_STORE_HEADERS } from '@/server/lib/remix-compat';
|
|
39
39
|
import type { ActionFunctionArgs } from '@/server/lib/remix-compat';
|
|
40
40
|
import { methodNotAllowed } from '@/server/lib/route-adapter';
|
|
41
|
-
import {
|
|
41
|
+
import { harnessDescriptor, isBuiltinHarness, type HarnessId } from '@/shared/lib/harness/catalog';
|
|
42
42
|
import { harnessUpdateFacts, latestSourceFor } from '@/shared/lib/harness/updates';
|
|
43
43
|
import { loadProbes } from '@/server/lib/harness/probe-cache.server';
|
|
44
44
|
import { harnessVersionState, type HarnessVersionState } from '@/server/lib/harness/update-state.server';
|
|
@@ -92,7 +92,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
|
|
|
92
92
|
return json({ error: 'Request body is not valid JSON' }, { status: 400 });
|
|
93
93
|
}
|
|
94
94
|
const id = body && typeof body === 'object' && 'harness' in body ? body.harness : undefined;
|
|
95
|
-
if (typeof id !== 'string' || !
|
|
95
|
+
if (typeof id !== 'string' || !isBuiltinHarness(id)) {
|
|
96
96
|
return json({ error: 'Unknown harness' }, { status: 400 });
|
|
97
97
|
}
|
|
98
98
|
|
|
@@ -11,6 +11,7 @@ import * as panelsIcon from '@/server/routes/panels/icon';
|
|
|
11
11
|
import * as panelsReadme from '@/server/routes/panels/readme';
|
|
12
12
|
import * as panelsInstall from '@/server/routes/panels/install';
|
|
13
13
|
import * as panelsBuild from '@/server/routes/panels/build';
|
|
14
|
+
import * as panelsSettings from '@/server/routes/panels/settings';
|
|
14
15
|
|
|
15
16
|
export const panelsBindings: HandlerBinding[] = [
|
|
16
17
|
...bindingsFor(panelsRegistry, '/api/panels'),
|
|
@@ -20,4 +21,5 @@ export const panelsBindings: HandlerBinding[] = [
|
|
|
20
21
|
...bindingsFor(panelsReadme, '/api/panels/readme/:plugin/*'),
|
|
21
22
|
...bindingsFor(panelsInstall, '/api/panels/install'),
|
|
22
23
|
...bindingsFor(panelsBuild, '/api/panels/build'),
|
|
24
|
+
...bindingsFor(panelsSettings, '/api/panels/settings/:plugin'),
|
|
23
25
|
];
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A panel plugin's settings route: the schema it reads and the values it writes.
|
|
8
|
+
*
|
|
9
|
+
* Every case here is one a wrong answer hides: a disabled plugin must still be
|
|
10
|
+
* configurable (its form is server-rendered, not run by the plugin), a secret
|
|
11
|
+
* must never travel back to the browser, the mask the browser sends back when a
|
|
12
|
+
* field is untouched must not overwrite the credential, and an undeclared key
|
|
13
|
+
* must be refused rather than stored where the plugin would never read it.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { describe, expect, test } from 'bun:test';
|
|
17
|
+
import fs from 'node:fs';
|
|
18
|
+
import { join } from 'node:path';
|
|
19
|
+
|
|
20
|
+
import { action, loader } from '@/server/routes/panels/settings';
|
|
21
|
+
import { discoverPanelPlugins, getMarketplacePluginsDir, invalidatePanelScan } from '@/server/lib/panels/registry.server';
|
|
22
|
+
import { setPluginEnabled } from '@/server/lib/panels/state.server';
|
|
23
|
+
import { getDb } from '@/server/db.server';
|
|
24
|
+
import { readPluginSettings } from '@/server/lib/plugins/settings.server';
|
|
25
|
+
import { PLUGIN_SECRET_MASK } from '@/shared/lib/plugins/settings';
|
|
26
|
+
import type { PluginSettingDefinition } from '@kabmo-labs/kabmo-sdk';
|
|
27
|
+
import { call, dirs, usePanelRouteFixtures, writePlugin } from '@/server/routes/panels/panel-routes.test-util';
|
|
28
|
+
|
|
29
|
+
usePanelRouteFixtures();
|
|
30
|
+
|
|
31
|
+
const SCHEMA: Record<string, PluginSettingDefinition> = {
|
|
32
|
+
note: { type: 'string', label: 'Note', default: 'hello' },
|
|
33
|
+
retries: { type: 'number', label: 'Retries', default: 3 },
|
|
34
|
+
verbose: { type: 'boolean', label: 'Verbose', default: false },
|
|
35
|
+
token: { type: 'string', label: 'Token', secret: true, default: '' },
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/** A plugin whose settings come from `settings-schema.json`. */
|
|
39
|
+
function writeSettingsPlugin(dirName = 'demo'): string {
|
|
40
|
+
const dir = writePlugin(dirName, getMarketplacePluginsDir());
|
|
41
|
+
fs.writeFileSync(join(dir, 'settings-schema.json'), JSON.stringify(SCHEMA));
|
|
42
|
+
invalidatePanelScan();
|
|
43
|
+
return dir;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function put(plugin: string, body: unknown): Promise<Response> {
|
|
47
|
+
return action({
|
|
48
|
+
params: { plugin },
|
|
49
|
+
request: new Request(`http://local/api/panels/settings/${plugin}`, {
|
|
50
|
+
method: 'PUT',
|
|
51
|
+
headers: { 'content-type': 'application/json' },
|
|
52
|
+
body: JSON.stringify(body),
|
|
53
|
+
}),
|
|
54
|
+
} as never) as Promise<Response>;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function jsonBody(response: Response) {
|
|
58
|
+
return (await response.json()) as {
|
|
59
|
+
error?: string;
|
|
60
|
+
definitions?: Record<string, unknown>;
|
|
61
|
+
values?: Record<string, unknown>;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
describe('GET /api/panels/settings/:plugin', () => {
|
|
66
|
+
test('answers the definitions and the defaults they declare', async () => {
|
|
67
|
+
writeSettingsPlugin();
|
|
68
|
+
const response = await call(loader, { plugin: 'demo' });
|
|
69
|
+
expect(response.status).toBe(200);
|
|
70
|
+
const body = await jsonBody(response);
|
|
71
|
+
expect(Object.keys(body.definitions ?? {})).toEqual(['note', 'retries', 'verbose', 'token']);
|
|
72
|
+
// `token` declares a default, but a secret default is not a stored value:
|
|
73
|
+
// reporting it masked would tell the form a credential exists when none does.
|
|
74
|
+
expect(body.values).toEqual({ note: 'hello', retries: 3, verbose: false });
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test('404s a plugin that is not installed', async () => {
|
|
78
|
+
expect((await call(loader, { plugin: 'nope' })).status).toBe(404);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
test('still answers for a DISABLED plugin, whose form is not run by its code', async () => {
|
|
82
|
+
writeSettingsPlugin();
|
|
83
|
+
await setPluginEnabled('plugin:demo', false);
|
|
84
|
+
invalidatePanelScan();
|
|
85
|
+
|
|
86
|
+
const response = await call(loader, { plugin: 'demo' });
|
|
87
|
+
expect(response.status).toBe(200);
|
|
88
|
+
expect((await jsonBody(response)).definitions?.note).toBeDefined();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test('reports a schema that exists but does not parse', async () => {
|
|
92
|
+
const dir = writePlugin('broken', getMarketplacePluginsDir());
|
|
93
|
+
fs.writeFileSync(join(dir, 'settings-schema.json'), '{ nope');
|
|
94
|
+
invalidatePanelScan();
|
|
95
|
+
|
|
96
|
+
const payload = await discoverPanelPlugins();
|
|
97
|
+
expect(payload.plugins.some((plugin) => plugin.pluginId === 'broken')).toBe(false);
|
|
98
|
+
expect(payload.errors.some((error) => error.reason.includes('settings-schema.json'))).toBe(true);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
describe('PUT /api/panels/settings/:plugin', () => {
|
|
103
|
+
test('writes a value and answers the new state', async () => {
|
|
104
|
+
writeSettingsPlugin();
|
|
105
|
+
const response = await put('demo', { values: { note: 'changed', retries: 9, verbose: true } });
|
|
106
|
+
expect(response.status).toBe(200);
|
|
107
|
+
expect((await jsonBody(response)).values).toEqual({ note: 'changed', retries: 9, verbose: true });
|
|
108
|
+
|
|
109
|
+
expect((await jsonBody(await call(loader, { plugin: 'demo' }))).values).toEqual({
|
|
110
|
+
note: 'changed',
|
|
111
|
+
retries: 9,
|
|
112
|
+
verbose: true,
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
test('refuses an undeclared key instead of storing it', async () => {
|
|
117
|
+
writeSettingsPlugin();
|
|
118
|
+
const response = await put('demo', { values: { nope: 'x' } });
|
|
119
|
+
expect(response.status).toBe(400);
|
|
120
|
+
expect((await jsonBody(response)).error).toContain('not a declared setting');
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
test('refuses a value of the wrong type before writing any field', async () => {
|
|
124
|
+
writeSettingsPlugin();
|
|
125
|
+
const response = await put('demo', { values: { note: 'kept?', retries: 'many' } });
|
|
126
|
+
expect(response.status).toBe(400);
|
|
127
|
+
|
|
128
|
+
const db = await getDb();
|
|
129
|
+
expect(await readPluginSettings(db, 'demo', SCHEMA)).toMatchObject({ note: 'hello', retries: 3 });
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
test('never returns a secret, and the mask sent back does not overwrite it', async () => {
|
|
133
|
+
writeSettingsPlugin();
|
|
134
|
+
await put('demo', { values: { token: 'secret-token' } });
|
|
135
|
+
|
|
136
|
+
const read = await jsonBody(await call(loader, { plugin: 'demo' }));
|
|
137
|
+
expect(read.values?.token).toBe(PLUGIN_SECRET_MASK);
|
|
138
|
+
|
|
139
|
+
// What the form sends when the user did not touch the field.
|
|
140
|
+
const untouched = await put('demo', { values: { token: PLUGIN_SECRET_MASK } });
|
|
141
|
+
expect(untouched.status).toBe(200);
|
|
142
|
+
|
|
143
|
+
const db = await getDb();
|
|
144
|
+
expect((await readPluginSettings(db, 'demo', SCHEMA)).token).toBe('secret-token');
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
test('refuses a body that carries no values object', async () => {
|
|
148
|
+
writeSettingsPlugin();
|
|
149
|
+
expect((await put('demo', {})).status).toBe(400);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
test('405s a verb other than PUT', async () => {
|
|
153
|
+
writeSettingsPlugin();
|
|
154
|
+
const response = (await action({
|
|
155
|
+
params: { plugin: 'demo' },
|
|
156
|
+
request: new Request('http://local/api/panels/settings/demo', { method: 'POST' }),
|
|
157
|
+
} as never)) as Response;
|
|
158
|
+
expect(response.status).toBe(405);
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
/** The marketplace root the fixture created, asserted here so an empty scan is explainable. */
|
|
163
|
+
test('the fixture marketplace is the one the scan reads', () => {
|
|
164
|
+
expect(getMarketplacePluginsDir()).toBe(join(dirs.root, 'plugins'));
|
|
165
|
+
});
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A panel plugin's settings: its declared schema and the stored values.
|
|
8
|
+
*
|
|
9
|
+
* `GET` answers the form — every definition, with each stored secret replaced by
|
|
10
|
+
* a marker — and `PUT` writes a whole form in one change. Both are addressed by
|
|
11
|
+
* the plugin's manifest id rather than its directory: the pane knows the id, and
|
|
12
|
+
* the directory is a server-side detail the registry resolves.
|
|
13
|
+
*
|
|
14
|
+
* The plugin does NOT have to be running. Settings are declared in
|
|
15
|
+
* `settings-schema.json` and stored in `plugin_settings`, so a switched-off
|
|
16
|
+
* plugin still shows and saves its configuration — the reason the scan keeps a
|
|
17
|
+
* directory map for disabled installs at all.
|
|
18
|
+
*
|
|
19
|
+
* A plugin with no schema has nothing to answer: `GET` reports an empty
|
|
20
|
+
* definition map (the pane then draws no button), and `PUT` refuses every key
|
|
21
|
+
* because none is declared. Neither is an error — "no settings" is a normal
|
|
22
|
+
* plugin, and the pane distinguishes it from a schema that failed to parse,
|
|
23
|
+
* which the scan rejects at admission.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { getDb } from '@/server/db.server';
|
|
27
|
+
import { findInstalledPluginDir } from '@/server/lib/panels/registry.server';
|
|
28
|
+
import { pluginSettingsDefinitions } from '@/server/lib/panels/settings-schema.server';
|
|
29
|
+
import {
|
|
30
|
+
maskSecrets,
|
|
31
|
+
readPluginSettings,
|
|
32
|
+
writePluginSettings,
|
|
33
|
+
} from '@/server/lib/plugins/settings.server';
|
|
34
|
+
import { json, type ActionFunctionArgs, type LoaderFunctionArgs } from '@/server/lib/remix-compat';
|
|
35
|
+
import { methodNotAllowedResponse, parseJsonBody, requireParam } from '@/server/lib/route-adapter';
|
|
36
|
+
import { PLUGIN_SECRET_MASK } from '@/shared/lib/plugins/settings';
|
|
37
|
+
import { isRecord } from '@/shared/lib/util/guards';
|
|
38
|
+
|
|
39
|
+
const NO_STORE = { 'cache-control': 'no-store' } as const;
|
|
40
|
+
|
|
41
|
+
async function loadSettings(pluginId: string): Promise<Response> {
|
|
42
|
+
const dir = await findInstalledPluginDir(pluginId);
|
|
43
|
+
if (!dir) return json({ error: `no installed plugin with the id "${pluginId}"` }, { status: 404, headers: NO_STORE });
|
|
44
|
+
|
|
45
|
+
const resolved = await pluginSettingsDefinitions(dir);
|
|
46
|
+
if ('error' in resolved) return json({ error: resolved.error }, { status: 422, headers: NO_STORE });
|
|
47
|
+
|
|
48
|
+
const db = await getDb();
|
|
49
|
+
const values = await readPluginSettings(db, pluginId, resolved.definitions);
|
|
50
|
+
return json(
|
|
51
|
+
{
|
|
52
|
+
pluginId,
|
|
53
|
+
definitions: resolved.definitions,
|
|
54
|
+
values: maskSecrets(values, resolved.definitions),
|
|
55
|
+
},
|
|
56
|
+
{ headers: NO_STORE },
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export async function loader({ params }: LoaderFunctionArgs) {
|
|
61
|
+
const pluginId = requireParam(params, 'plugin');
|
|
62
|
+
if (!pluginId) return json({ error: 'the request did not name a plugin' }, { status: 400, headers: NO_STORE });
|
|
63
|
+
return loadSettings(pluginId);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export async function action({ request, params }: ActionFunctionArgs) {
|
|
67
|
+
if (request.method !== 'PUT') return methodNotAllowedResponse();
|
|
68
|
+
|
|
69
|
+
const pluginId = requireParam(params, 'plugin');
|
|
70
|
+
if (!pluginId) return json({ error: 'the request did not name a plugin' }, { status: 400, headers: NO_STORE });
|
|
71
|
+
|
|
72
|
+
const dir = await findInstalledPluginDir(pluginId);
|
|
73
|
+
if (!dir) return json({ error: `no installed plugin with the id "${pluginId}"` }, { status: 404, headers: NO_STORE });
|
|
74
|
+
|
|
75
|
+
const resolved = await pluginSettingsDefinitions(dir);
|
|
76
|
+
if ('error' in resolved) return json({ error: resolved.error }, { status: 422, headers: NO_STORE });
|
|
77
|
+
|
|
78
|
+
const parsed = await parseJsonBody<{ values?: unknown }>(request);
|
|
79
|
+
if (!parsed.ok) return json({ error: `the body is not JSON: ${parsed.error}` }, { status: 400, headers: NO_STORE });
|
|
80
|
+
const raw = parsed.body?.values;
|
|
81
|
+
if (!isRecord(raw)) {
|
|
82
|
+
return json({ error: 'the body must carry a "values" object' }, { status: 400, headers: NO_STORE });
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// A secret is sent back as the marker when the user did not touch the field.
|
|
86
|
+
// Writing that marker would replace the credential with eight dots, so it is
|
|
87
|
+
// dropped here — the field means "leave the stored value alone".
|
|
88
|
+
const values: Record<string, unknown> = {};
|
|
89
|
+
for (const [key, value] of Object.entries(raw)) {
|
|
90
|
+
if (resolved.definitions[key]?.secret && value === PLUGIN_SECRET_MASK) continue;
|
|
91
|
+
values[key] = value;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const db = await getDb();
|
|
95
|
+
const written = await writePluginSettings(db, pluginId, resolved.definitions, values);
|
|
96
|
+
if (!written.ok) return json({ error: written.error }, { status: 400, headers: NO_STORE });
|
|
97
|
+
|
|
98
|
+
return json(
|
|
99
|
+
{
|
|
100
|
+
pluginId,
|
|
101
|
+
definitions: resolved.definitions,
|
|
102
|
+
values: maskSecrets(written.values, resolved.definitions),
|
|
103
|
+
},
|
|
104
|
+
{ headers: NO_STORE },
|
|
105
|
+
);
|
|
106
|
+
}
|
|
@@ -18,6 +18,8 @@ import { getDb } from '@/server/db.server';
|
|
|
18
18
|
import { normalizeModel } from '@/server/lib/queue/store.server';
|
|
19
19
|
import { readSettingsJson } from '@/server/lib/db/settings-store';
|
|
20
20
|
import { loadPersistedAccessMode } from '@/shared/lib/omp/config/access-mode.server';
|
|
21
|
+
import { harnessDescriptor } from '@/shared/lib/harness/catalog';
|
|
22
|
+
import { isValidTimeZone, serverTimeZone } from '@/shared/lib/schedule/timezone';
|
|
21
23
|
import { isRecord } from '@/shared/lib/util/guards';
|
|
22
24
|
import type { ScheduleKind, ScheduledTaskModel } from '@/shared/types/schedule';
|
|
23
25
|
|
|
@@ -88,6 +90,8 @@ export function readTaskBody(body: unknown): {
|
|
|
88
90
|
prompt: string;
|
|
89
91
|
kind: ScheduleKind;
|
|
90
92
|
spec: string;
|
|
93
|
+
harness: string;
|
|
94
|
+
timezone: string;
|
|
91
95
|
folderId: number | null;
|
|
92
96
|
sessionId: string | null;
|
|
93
97
|
model: ScheduledTaskModel | null;
|
|
@@ -97,11 +101,21 @@ export function readTaskBody(body: unknown): {
|
|
|
97
101
|
if (typeof body.prompt !== 'string' || !body.prompt.trim()) return null;
|
|
98
102
|
if (!isScheduleKind(body.kind)) return null;
|
|
99
103
|
if (typeof body.spec !== 'string' || !body.spec.trim()) return null;
|
|
104
|
+
// Absent means the built-in transport; a value that is present but unknown is
|
|
105
|
+
// a client bug, not a default, so the whole body is refused.
|
|
106
|
+
const harness = body.harness === undefined ? 'omp-rpc' : optionalText(body.harness);
|
|
107
|
+
if (!harness || !harnessDescriptor(harness)) return null;
|
|
108
|
+
// Absent means "the server's zone"; a value that is present but unknown is a
|
|
109
|
+
// client bug, not a default, so the whole body is refused.
|
|
110
|
+
const timezone = body.timezone === undefined ? serverTimeZone() : optionalText(body.timezone);
|
|
111
|
+
if (!timezone || !isValidTimeZone(timezone)) return null;
|
|
100
112
|
return {
|
|
101
113
|
name: typeof body.name === 'string' ? body.name.trim() : '',
|
|
102
114
|
prompt: body.prompt.trim(),
|
|
103
115
|
kind: body.kind,
|
|
104
116
|
spec: body.spec.trim(),
|
|
117
|
+
harness,
|
|
118
|
+
timezone,
|
|
105
119
|
folderId: optionalNumber(body.folderId),
|
|
106
120
|
sessionId: optionalText(body.sessionId),
|
|
107
121
|
model: parseModelField(body),
|