@kabmo-labs/kabmo 0.22.0 → 0.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 +1 -1
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +873 -524
- package/dist/client/static/js/{index-297dck9a.js → index-jcr5twtp.js} +799 -795
- package/dist/client/static/js/index-z3w7n85q.css +1 -0
- package/marketplace/plugins/stats/package.json +2 -2
- package/marketplace/plugins/stats/src/groups.test.ts +14 -0
- package/marketplace/plugins/stats/src/groups.ts +20 -0
- package/marketplace/plugins/stats/src/labels.test.ts +9 -0
- package/marketplace/plugins/stats/src/labels.ts +7 -0
- package/marketplace/plugins/stats/src/server.ts +1 -1
- package/package.json +1 -1
- package/src/client/App.tsx +20 -19
- package/src/client/components/common/ComposerTextarea.tsx +10 -1
- package/src/client/components/common/Modal.tsx +2 -6
- package/src/client/components/common/PWAInstallButton.tsx +3 -2
- package/src/client/components/common/Toast.test.tsx +298 -0
- package/src/client/components/common/Toast.tsx +103 -37
- package/src/client/components/common/ToastStack.tsx +33 -12
- package/src/client/components/common/ViewportSelector.tsx +122 -114
- package/src/client/components/common/context-usage-button/Ring.tsx +38 -1
- package/src/client/components/common/context-usage-button/index.test.tsx +19 -3
- package/src/client/components/common/context-usage-button/index.tsx +5 -2
- package/src/client/components/common/harness-glyph/brands.ts +65 -0
- package/src/client/components/common/harness-glyph/harness-glyph.test.ts +185 -0
- package/src/client/components/common/harness-glyph/index.tsx +131 -0
- package/src/client/components/common/header-controls/MoreMenu.tsx +2 -1
- package/src/client/components/common/header-controls/index.tsx +16 -8
- package/src/client/components/common/header-panel-buttons/index.tsx +4 -3
- package/src/client/components/common/panel-mark/index.test.tsx +2 -2
- package/src/client/components/common/panel-mark/index.tsx +11 -2
- package/src/client/components/common/search-select/index.tsx +305 -0
- package/src/client/components/common/search-select/search-select.test.tsx +217 -0
- package/src/client/components/common/server-control/index.tsx +3 -2
- package/src/client/components/common/session-row/index.tsx +18 -1
- package/src/client/components/common/toolbar-row/index.tsx +57 -20
- package/src/client/components/layout/desktop-layout/LeftColumn.tsx +1 -3
- package/src/client/components/layout/desktop-layout/TopNavbar.tsx +3 -2
- package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +7 -1
- package/src/client/components/layout/desktop-layout/index.tsx +1 -3
- package/src/client/components/layout/session-sidebar/CategoryItem.tsx +1 -0
- package/src/client/components/layout/session-sidebar/SessionItem.tsx +18 -1
- package/src/client/components/layout/session-sidebar/SessionsView.tsx +1 -3
- package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.test.tsx +332 -0
- package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.tsx +310 -0
- package/src/client/components/layout/session-sidebar/about-modal/SocialLinks.tsx +63 -51
- package/src/client/components/layout/session-sidebar/about-modal/UpdateSection.tsx +4 -2
- package/src/client/components/layout/session-sidebar/about-modal/index.test.tsx +122 -0
- package/src/client/components/layout/session-sidebar/about-modal/index.tsx +136 -35
- package/src/client/components/layout/session-sidebar/harness-mark.test.tsx +126 -0
- package/src/client/components/layout/session-sidebar/modern/ActionRow.tsx +4 -3
- package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +1 -0
- package/src/client/components/mobile/LayoutWrapper.tsx +1 -7
- package/src/client/components/mobile/SessionSidebar.tsx +1 -3
- package/src/client/components/mobile/mobile-main-view/Header.tsx +3 -2
- package/src/client/components/mobile/mobile-session-sidebar/Dialogs.tsx +0 -8
- package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +1 -0
- package/src/client/components/mobile/mobile-session-sidebar/SessionRow.tsx +17 -1
- package/src/client/components/settings/Modal.tsx +26 -22
- package/src/client/components/settings/Sidebar.tsx +45 -5
- package/src/client/components/settings/categories/HarnessSettings.tsx +207 -0
- package/src/client/components/settings/categories/ProjectSettings.tsx +1 -3
- package/src/client/components/settings/categories/ProviderSettings.tsx +0 -4
- package/src/client/components/settings/categories/SkillCatalogSettings.tsx +13 -23
- package/src/client/components/settings/categories/agent-settings/ModelPicker.tsx +23 -30
- package/src/client/components/settings/categories/appearance-settings/IconStyleSection.tsx +20 -11
- package/src/client/components/settings/categories/chat-settings/GoalSection.tsx +16 -16
- package/src/client/components/settings/categories/harness-settings/AddProviderForm.tsx +219 -0
- package/src/client/components/settings/categories/harness-settings/ConfigForm.tsx +268 -0
- package/src/client/components/settings/categories/harness-settings/EnvProviderForm.tsx +146 -0
- package/src/client/components/settings/categories/harness-settings/HarnessCard.tsx +278 -0
- package/src/client/components/settings/categories/harness-settings/ImportSection.tsx +195 -0
- package/src/client/components/settings/categories/harness-settings/ProviderPanel.tsx +152 -0
- package/src/client/components/settings/categories/harness-settings/ToggleList.tsx +147 -0
- package/src/client/components/settings/categories/harness-settings/parts.test.tsx +97 -0
- package/src/client/components/settings/categories/harness-settings/parts.tsx +84 -0
- package/src/client/components/settings/categories/harness-settings/provider-panel.test.tsx +313 -0
- package/src/client/components/settings/categories/omp-settings/RoleEditor.test.ts +60 -39
- package/src/client/components/settings/categories/omp-settings/RoleRow.tsx +32 -41
- package/src/client/components/settings/categories/omp-settings/role-picker.test-util.ts +45 -0
- package/src/client/components/settings/categories/panel-plugins/PluginMark.test.ts +1 -1
- package/src/client/components/settings/categories/panel-plugins/PluginMark.tsx +11 -4
- package/src/client/components/settings/groups.test.tsx +160 -0
- package/src/client/components/settings/harness-icons.test.tsx +134 -0
- package/src/client/components/workspace/browser-panel/AddressBar.tsx +3 -13
- package/src/client/components/workspace/browser-toolbar/clusters.tsx +237 -0
- package/src/client/components/workspace/browser-toolbar/index.test.tsx +167 -0
- package/src/client/components/workspace/browser-toolbar/index.tsx +99 -100
- package/src/client/components/workspace/btw-panel/Messages.tsx +4 -1
- package/src/client/components/workspace/btw-panel/index.tsx +2 -0
- package/src/client/components/workspace/chat-timeline/AiMessageFooter.tsx +11 -7
- package/src/client/components/workspace/chat-timeline/ChatOverlays.tsx +5 -2
- package/src/client/components/workspace/chat-timeline/ComposerDock.tsx +13 -0
- package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +13 -0
- package/src/client/components/workspace/chat-timeline/GeneratingIndicator.test.ts +41 -0
- package/src/client/components/workspace/chat-timeline/GeneratingIndicator.tsx +19 -14
- package/src/client/components/workspace/chat-timeline/MessageList.test.ts +14 -0
- package/src/client/components/workspace/chat-timeline/MessageList.tsx +6 -0
- package/src/client/components/workspace/chat-timeline/PendingChatView.tsx +14 -0
- package/src/client/components/workspace/chat-timeline/RunFooter.tsx +4 -0
- package/src/client/components/workspace/chat-timeline/RunMark.tsx +58 -0
- package/src/client/components/workspace/chat-timeline/SubagentView.tsx +4 -1
- package/src/client/components/workspace/chat-timeline/TimelineBody.tsx +4 -0
- package/src/client/components/workspace/chat-timeline/chat-input/AttachmentToolbar.tsx +1 -0
- package/src/client/components/workspace/chat-timeline/chat-input/ComposerRows.tsx +11 -0
- package/src/client/components/workspace/chat-timeline/chat-input/ModeToggles.test.ts +13 -0
- package/src/client/components/workspace/chat-timeline/chat-input/ModeToggles.tsx +8 -1
- package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.test.ts +27 -1
- package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +48 -23
- package/src/client/components/workspace/chat-timeline/chat-input/composer-portal.test.tsx +1 -0
- package/src/client/components/workspace/chat-timeline/chat-input/index.tsx +21 -1
- package/src/client/components/workspace/chat-timeline/chat-input/modes-props.ts +7 -0
- package/src/client/components/workspace/chat-timeline/chat-input/props.ts +13 -0
- package/src/client/components/workspace/chat-timeline/chat-input/selection.ts +11 -2
- package/src/client/components/workspace/chat-timeline/chat-input/styles.test.tsx +1 -0
- package/src/client/components/workspace/chat-timeline/index.tsx +17 -15
- package/src/client/components/workspace/chat-timeline/pending-harness.test.tsx +157 -0
- package/src/client/components/workspace/chat-timeline/run-mark.test.ts +104 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FrameControl.tsx +11 -20
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/GroupedAsk.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/QuestionBlock.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/drafts.ts +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/index.tsx +2 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.test.ts +31 -3
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.tsx +5 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.test.ts +56 -45
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.tsx +38 -94
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/wait-parts.tsx +76 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/card-header.ts +2 -1
- package/src/client/components/workspace/file-explorer/index.test.ts +25 -0
- package/src/client/components/workspace/file-explorer/index.tsx +10 -6
- package/src/client/components/workspace/git-panel/index.test.ts +13 -3
- package/src/client/components/workspace/git-panel/index.tsx +1 -3
- package/src/client/components/workspace/model-dropdown/Fullscreen.tsx +92 -0
- package/src/client/components/workspace/model-dropdown/HarnessTabs.tsx +290 -0
- package/src/client/components/workspace/model-dropdown/Item.tsx +11 -0
- package/src/client/components/workspace/model-dropdown/Panel.tsx +119 -8
- package/src/client/components/workspace/model-dropdown/Section.tsx +4 -0
- package/src/client/components/workspace/model-dropdown/fullscreen-picker.ts +51 -0
- package/src/client/components/workspace/model-dropdown/harness-models.test.ts +177 -0
- package/src/client/components/workspace/model-dropdown/harness-models.ts +148 -0
- package/src/client/components/workspace/model-dropdown/harness-tabs.test.tsx +336 -0
- package/src/client/components/workspace/model-dropdown/index.tsx +114 -85
- package/src/client/components/workspace/model-dropdown/placement.test.tsx +127 -0
- package/src/client/components/workspace/model-dropdown/popover-metrics.test.ts +107 -0
- package/src/client/components/workspace/model-dropdown/popover-metrics.ts +118 -0
- package/src/client/components/workspace/model-dropdown/row-mutations.ts +106 -0
- package/src/client/components/workspace/model-dropdown/trigger.test.ts +22 -2
- package/src/client/components/workspace/model-dropdown/use-popover-size.ts +89 -0
- package/src/client/data/settings/omp-schema.json +224 -17
- package/src/client/hooks/chat/composer/index.ts +11 -2
- package/src/client/hooks/chat/composer/items.test.ts +11 -0
- package/src/client/hooks/chat/composer/items.ts +4 -2
- package/src/client/hooks/chat/composer/model-selection.test.ts +110 -0
- package/src/client/hooks/chat/composer/model-selection.ts +45 -4
- package/src/client/hooks/chat/omp/prompt-send.ts +4 -2
- package/src/client/hooks/chat/timeline/actions.ts +10 -5
- package/src/client/hooks/chat/timeline/ask-frames.ts +5 -4
- package/src/client/hooks/chat/timeline/composer-local-actions.test.ts +19 -81
- package/src/client/hooks/chat/timeline/composer-modes.ts +11 -2
- package/src/client/hooks/chat/timeline/composer-refs.ts +16 -1
- package/src/client/hooks/chat/timeline/index.ts +27 -35
- package/src/client/hooks/chat/timeline/mode-availability.test.ts +51 -0
- package/src/client/hooks/chat/timeline/modes-contract.ts +6 -0
- package/src/client/hooks/chat/timeline/modes.ts +41 -2
- package/src/client/hooks/chat/timeline/new-chat-open.test.ts +86 -0
- package/src/client/hooks/chat/timeline/new-chat-open.ts +23 -5
- package/src/client/hooks/chat/timeline/new-chat.test.ts +32 -4
- package/src/client/hooks/chat/timeline/new-chat.ts +18 -6
- package/src/client/hooks/chat/timeline/prompt-text.test.ts +7 -0
- package/src/client/hooks/chat/timeline/prompt-text.ts +15 -6
- package/src/client/hooks/chat/timeline/rewind-actions.test.ts +51 -1
- package/src/client/hooks/chat/timeline/rewind-actions.ts +23 -1
- package/src/client/hooks/chat/timeline/run-identity.test.ts +52 -0
- package/src/client/hooks/chat/timeline/run-identity.ts +23 -11
- package/src/client/hooks/chat/timeline/send-execute.test.ts +55 -0
- package/src/client/hooks/chat/timeline/send-props.ts +11 -3
- package/src/client/hooks/chat/timeline/send-steer.test.ts +2 -3
- package/src/client/hooks/chat/timeline/send.test-util.ts +3 -2
- package/src/client/hooks/chat/timeline/send.test.ts +2 -3
- package/src/client/hooks/chat/timeline/send.ts +34 -8
- package/src/client/hooks/chat/timeline/session-harness.test.ts +163 -0
- package/src/client/hooks/chat/timeline/session-harness.ts +164 -0
- package/src/client/hooks/chat/timeline/session-load.test-util.ts +6 -2
- package/src/client/hooks/chat/timeline/session-load.test.ts +31 -0
- package/src/client/hooks/chat/timeline/session-load.ts +6 -14
- package/src/client/hooks/chat/timeline/session-shapes.ts +32 -0
- package/src/client/hooks/chat/timeline/spawn-harness.ts +41 -0
- package/src/client/hooks/chat/timeline/timeline-running.ts +55 -0
- package/src/client/hooks/chat/timeline/tui-only-guard.ts +9 -0
- package/src/client/hooks/chat/timeline/undo-confirmation.test.ts +131 -0
- package/src/client/hooks/models/harness-catalog.ts +114 -0
- package/src/client/hooks/models/provider-writes.test.ts +81 -0
- package/src/client/hooks/models/provider-writes.ts +144 -0
- package/src/client/hooks/models/use-harness-versions.test.ts +152 -0
- package/src/client/hooks/models/use-harness-versions.ts +136 -0
- package/src/client/hooks/models/use-harnesses-controller.ts +57 -0
- package/src/client/hooks/models/use-harnesses-signal.test.ts +128 -0
- package/src/client/hooks/models/use-harnesses.test.ts +187 -0
- package/src/client/hooks/models/use-harnesses.ts +215 -0
- package/src/client/hooks/settings/providers/index.ts +1 -3
- package/src/client/hooks/ui/editor-error-toast.ts +10 -3
- package/src/client/hooks/ui/icon-style.ts +28 -0
- package/src/client/hooks/ui/on-click-outside.test.ts +104 -0
- package/src/client/hooks/ui/on-click-outside.ts +14 -2
- package/src/client/hooks/ui/theme.ts +6 -0
- package/src/client/hooks/ui/toast-queue.test.ts +126 -0
- package/src/client/hooks/ui/toasts.ts +132 -27
- package/src/client/hooks/ui/ui-feedback.test.ts +4 -91
- package/src/client/lib/ui/control-plate.test.ts +76 -0
- package/src/client/lib/ui/control-plate.ts +65 -0
- package/src/client/tailwind.css +47 -1
- package/src/server/lib/assets/shell-attributes.server.ts +9 -2
- package/src/server/lib/assets/shell-attributes.test.ts +22 -6
- package/src/server/lib/db/schema.ts +4 -0
- package/src/server/lib/harness/acp/acp-audit.server.ts +107 -0
- package/src/server/lib/harness/acp/acp-goal-driver.server.ts +153 -0
- package/src/server/lib/harness/acp/acp-goal-state.server.ts +136 -0
- package/src/server/lib/harness/acp/acp-goal.server.ts +273 -0
- package/src/server/lib/harness/acp/acp-goal.test.ts +229 -0
- package/src/server/lib/harness/acp/acp-telemetry.server.ts +133 -0
- package/src/server/lib/harness/acp/acp-telemetry.test.ts +85 -0
- package/src/server/lib/harness/acp/acp-todos.server.ts +45 -0
- package/src/server/lib/harness/acp/acp-todos.test.ts +43 -0
- package/src/server/lib/harness/acp/activation.test.ts +81 -0
- package/src/server/lib/harness/acp/activation.ts +72 -0
- package/src/server/lib/harness/acp/calls.ts +97 -0
- package/src/server/lib/harness/acp/client.test.ts +73 -0
- package/src/server/lib/harness/acp/client.ts +339 -0
- package/src/server/lib/harness/acp/commands.test.ts +92 -0
- package/src/server/lib/harness/acp/commands.ts +165 -0
- package/src/server/lib/harness/acp/frames.test.ts +315 -0
- package/src/server/lib/harness/acp/frames.ts +349 -0
- package/src/server/lib/harness/acp/mapper.ts +204 -0
- package/src/server/lib/harness/acp/permissions.test.ts +66 -0
- package/src/server/lib/harness/acp/permissions.ts +155 -0
- package/src/server/lib/harness/acp/prompt.test.ts +130 -0
- package/src/server/lib/harness/acp/prompt.ts +134 -0
- package/src/server/lib/harness/acp/protocol.ts +162 -0
- package/src/server/lib/harness/acp/session-config.test.ts +73 -0
- package/src/server/lib/harness/acp/session-config.ts +148 -0
- package/src/server/lib/harness/acp/session-facts.ts +71 -0
- package/src/server/lib/harness/acp/session-handshake.ts +89 -0
- package/src/server/lib/harness/acp/session-idle.ts +51 -0
- package/src/server/lib/harness/acp/session-notifications.ts +95 -0
- package/src/server/lib/harness/acp/session-observers.test.ts +193 -0
- package/src/server/lib/harness/acp/session-options.ts +33 -0
- package/src/server/lib/harness/acp/session-permissions.test.ts +105 -0
- package/src/server/lib/harness/acp/session-permissions.ts +74 -0
- package/src/server/lib/harness/acp/session-reaper.test.ts +96 -0
- package/src/server/lib/harness/acp/session-turns.ts +95 -0
- package/src/server/lib/harness/acp/session-usage.ts +60 -0
- package/src/server/lib/harness/acp/session-web-state.ts +61 -0
- package/src/server/lib/harness/acp/session.test-util.ts +160 -0
- package/src/server/lib/harness/acp/session.test.ts +233 -0
- package/src/server/lib/harness/acp/session.ts +350 -0
- package/src/server/lib/harness/acp/turn.ts +199 -0
- package/src/server/lib/harness/acp/verbs.ts +87 -0
- package/src/server/lib/harness/auto-probe.server.test.ts +121 -0
- package/src/server/lib/harness/auto-probe.server.ts +178 -0
- package/src/server/lib/harness/capabilities.ts +67 -0
- package/src/server/lib/harness/config-invalidation.test.ts +91 -0
- package/src/server/lib/harness/config.server.test.ts +105 -0
- package/src/server/lib/harness/config.server.ts +98 -0
- package/src/server/lib/harness/enabled.server.test.ts +87 -0
- package/src/server/lib/harness/enabled.server.ts +61 -0
- package/src/server/lib/harness/launch-table.ts +195 -0
- package/src/server/lib/harness/launch.test.ts +220 -0
- package/src/server/lib/harness/launch.ts +216 -0
- package/src/server/lib/harness/probe-cache.server.test.ts +154 -0
- package/src/server/lib/harness/probe-cache.server.ts +177 -0
- package/src/server/lib/harness/provider-entry.ts +212 -0
- package/src/server/lib/harness/provider-file.server.ts +67 -0
- package/src/server/lib/harness/provider-import.test.ts +191 -0
- package/src/server/lib/harness/provider-probe.server.ts +123 -0
- package/src/server/lib/harness/provider-sources.server.test.ts +45 -0
- package/src/server/lib/harness/provider-sources.server.ts +308 -0
- package/src/server/lib/harness/provider-write-error.ts +19 -0
- package/src/server/lib/harness/provider-write.server.test.ts +308 -0
- package/src/server/lib/harness/provider-write.server.ts +339 -0
- package/src/server/lib/harness/provider-zcode.server.test.ts +270 -0
- package/src/server/lib/harness/provider-zcode.server.ts +324 -0
- package/src/server/lib/harness/register.server.ts +36 -0
- package/src/server/lib/harness/registry.ts +58 -0
- package/src/server/lib/harness/schema.server.ts +129 -0
- package/src/server/lib/harness/session-store.server.test.ts +175 -0
- package/src/server/lib/harness/session-store.server.ts +206 -0
- package/src/server/lib/harness/session-title.server.test.ts +109 -0
- package/src/server/lib/harness/session-title.server.ts +70 -0
- package/src/server/lib/harness/session.ts +74 -0
- package/src/server/lib/harness/spawn.server.ts +133 -0
- package/src/server/lib/harness/update-state.server.ts +185 -0
- package/src/server/lib/lifecycle/after-listen.ts +7 -0
- package/src/server/lib/models/provider-items.server.ts +1 -1
- package/src/server/lib/models/registry-refresh.server.test.ts +87 -0
- package/src/server/lib/models/registry-refresh.server.ts +98 -0
- package/src/server/lib/omp/config/models-config.ts +4 -0
- package/src/server/lib/omp/core/cli.ts +13 -0
- package/src/server/lib/omp/core/host-resolution.test.ts +6 -3
- package/src/server/lib/omp/rpc/child-config.ts +5 -4
- package/src/server/lib/omp/rpc/constants.test.ts +2 -1
- package/src/server/lib/omp/rpc/event-fanout.ts +9 -0
- package/src/server/lib/omp/rpc/forked-resume.test.ts +14 -3
- package/src/server/lib/omp/rpc/rpc-primitives.test.ts +11 -0
- package/src/server/lib/omp/rpc/session-registration.ts +7 -2
- package/src/server/lib/omp/rpc/session-registry.test.ts +2 -1
- package/src/server/lib/omp/rpc/session-registry.ts +74 -5
- package/src/server/lib/omp/session/acp-rows.server.ts +79 -0
- package/src/server/lib/omp/session/delete-flow.server.ts +15 -8
- package/src/server/lib/omp/session/delete.server.ts +12 -0
- package/src/server/lib/omp/session/sidebar-data.harness.test.ts +247 -0
- package/src/server/lib/omp/session/sidebar-data.server.ts +56 -3
- package/src/server/lib/queue/delivery.server.test.ts +4 -2
- package/src/server/lib/queue/payload.test.ts +67 -0
- package/src/server/lib/queue/payload.ts +9 -3
- package/src/server/lib/realtime/signals.server.test.ts +99 -0
- package/src/server/lib/realtime/signals.server.ts +25 -5
- package/src/server/lib/realtime/topics/session-data.server.ts +29 -0
- package/src/server/lib/realtime/topics/session.server.ts +3 -3
- package/src/server/routes/agent/command-resume.test.ts +77 -0
- package/src/server/routes/agent/command.test.ts +243 -2
- package/src/server/routes/agent/command.ts +78 -15
- package/src/server/routes/agent/harness-command.ts +133 -0
- package/src/server/routes/agent/new.ts +63 -1
- package/src/server/routes/chat/rewind.test.ts +147 -0
- package/src/server/routes/chat/rewind.ts +29 -7
- package/src/server/routes/chat/session.test.ts +240 -0
- package/src/server/routes/chat/session.ts +96 -4
- package/src/server/routes/harness/add-provider.test.ts +233 -0
- package/src/server/routes/harness/import-action.ts +272 -0
- package/src/server/routes/harness/import.test.ts +196 -0
- package/src/server/routes/harness/index.ts +13 -0
- package/src/server/routes/harness/root.ts +280 -0
- package/src/server/routes/harness/toggle.test.ts +127 -0
- package/src/server/routes/harness/update.ts +259 -0
- package/src/server/routes/harness/versions.test.ts +148 -0
- package/src/server/routes/harness/versions.ts +105 -0
- package/src/server/routes/index.ts +2 -0
- package/src/server/routes/sessions/delete-acp.test.ts +227 -0
- package/src/server/routes/sessions/queue.ts +7 -2
- package/src/server/routes/sessions/routes-queue.test.ts +52 -0
- package/src/server/routes/sessions/routes.test.ts +47 -13
- package/src/server/routes/sessions/session.ts +35 -0
- package/src/server/routes/settings/commands-harness.test.ts +92 -0
- package/src/server/routes/settings/commands.ts +26 -0
- package/src/server/routes/settings/model-override.ts +5 -2
- package/src/server/routes/settings/provider-entry.ts +2 -2
- package/src/server/routes/settings/provider-model.ts +2 -2
- package/src/server/routes/settings/provider-models.ts +2 -2
- package/src/server/routes/settings/provider-refresh.ts +6 -4
- package/src/server/routes/settings/providers.ts +3 -1
- package/src/server/routes/settings/settings-config-routes.test.ts +10 -2
- package/src/server/routes/settings/skills.ts +12 -0
- package/src/shared/lib/chat/ask-form/fields.ts +76 -0
- package/src/shared/lib/chat/ask-form/index.ts +323 -0
- package/src/shared/lib/chat/ask-form/tokens.ts +199 -0
- package/src/shared/lib/chat/ask-form/types.ts +43 -0
- package/src/shared/lib/chat/ask-form.test.ts +137 -0
- package/src/shared/lib/chat/ask-questions.test.ts +65 -1
- package/src/shared/lib/chat/ask-questions.ts +51 -145
- package/src/shared/lib/chat/ask-results.ts +198 -0
- package/src/shared/lib/chat/composer/client.ts +20 -8
- package/src/shared/lib/chat/context/usage.test.ts +8 -4
- package/src/shared/lib/chat/context/usage.ts +17 -3
- package/src/shared/lib/chat/omp/abort.test.ts +61 -0
- package/src/shared/lib/chat/omp/abort.ts +8 -2
- package/src/shared/lib/chat/omp/tool-frames.test.ts +23 -0
- package/src/shared/lib/chat/omp/tool-frames.ts +12 -2
- package/src/shared/lib/chat/timeline/omp-callbacks.ts +13 -1
- package/src/shared/lib/chat/timeline/prompt-error.test.ts +146 -0
- package/src/shared/lib/chat/timeline/prompt-error.ts +88 -0
- package/src/shared/lib/chat/tool/summary-wait.test.ts +18 -8
- package/src/shared/lib/chat/tool/wait-facts.ts +14 -8
- package/src/shared/lib/harness/brand-color.test.ts +66 -0
- package/src/shared/lib/harness/brand-color.ts +96 -0
- package/src/shared/lib/harness/catalog.test.ts +88 -0
- package/src/shared/lib/harness/catalog.ts +169 -0
- package/src/shared/lib/harness/config-fields.test.ts +139 -0
- package/src/shared/lib/harness/config-fields.ts +168 -0
- package/src/shared/lib/harness/config.test.ts +153 -0
- package/src/shared/lib/harness/config.ts +206 -0
- package/src/shared/lib/harness/dialects.test.ts +140 -0
- package/src/shared/lib/harness/dialects.ts +249 -0
- package/src/shared/lib/harness/enabled.test.ts +79 -0
- package/src/shared/lib/harness/enabled.ts +72 -0
- package/src/shared/lib/harness/menu.test.ts +94 -0
- package/src/shared/lib/harness/menu.ts +88 -0
- package/src/shared/lib/harness/provider-facts.test.ts +199 -0
- package/src/shared/lib/harness/provider-facts.ts +349 -0
- package/src/shared/lib/harness/provider-slug.ts +46 -0
- package/src/shared/lib/harness/providers.ts +175 -0
- package/src/shared/lib/harness/rewind.ts +24 -0
- package/src/shared/lib/harness/status.test.ts +158 -0
- package/src/shared/lib/harness/status.ts +112 -0
- package/src/shared/lib/harness/update-plan.test.ts +163 -0
- package/src/shared/lib/harness/update-plan.ts +140 -0
- package/src/shared/lib/harness/updates.test.ts +106 -0
- package/src/shared/lib/harness/updates.ts +177 -0
- package/src/shared/lib/icons/icon-paint-authority.test.ts +16 -4
- package/src/shared/lib/icons/icon-paint-authority.ts +57 -12
- package/src/shared/lib/icons/icon-paint-bucket.test.ts +84 -0
- package/src/shared/lib/icons/icon-paint-css.test.ts +23 -25
- package/src/shared/lib/icons/icon-paint-css.ts +69 -55
- package/src/shared/lib/icons/icon-paint-harness.test.ts +73 -0
- package/src/shared/lib/icons/icon-paint-harness.ts +75 -0
- package/src/shared/lib/icons/icon-paint-ink.ts +108 -0
- package/src/shared/lib/icons/icon-paint-panel.ts +19 -4
- package/src/shared/lib/icons/icon-paint-weight.ts +21 -2
- package/src/shared/lib/icons/icon-tone.ts +118 -21
- package/src/shared/lib/icons/tint-hues.generated.ts +100 -284
- package/src/shared/lib/icons/tint-tones.test.ts +79 -25
- package/src/shared/lib/icons/tint.ts +66 -6
- package/src/shared/lib/models/client.ts +10 -1
- package/src/shared/lib/models/provider/vendors.ts +72 -0
- package/src/shared/lib/omp/config/schema.test.ts +36 -0
- package/src/shared/lib/omp/dialog-methods.ts +4 -3
- package/src/shared/lib/omp/session/messages-map-trace.test.ts +42 -0
- package/src/shared/lib/omp/session/messages-map.ts +6 -1
- package/src/shared/lib/omp/session/parse-message-blocks-toolcall.test.ts +8 -0
- package/src/shared/lib/omp/session/parse-message-blocks.ts +6 -1
- package/src/shared/lib/omp/session/shell-trace.test.ts +69 -0
- package/src/shared/lib/omp/session/shell-trace.ts +63 -0
- package/src/shared/lib/omp/session/sidebar.ts +37 -10
- package/src/shared/lib/omp/session/wait-idle.test.ts +47 -0
- package/src/shared/lib/omp/session/wait-idle.ts +93 -0
- package/src/shared/lib/omp/session/wait.test.ts +34 -33
- package/src/shared/lib/omp/session/wait.ts +25 -39
- package/src/shared/lib/settings/sections.ts +24 -0
- package/src/shared/lib/theme/css.ts +2 -0
- package/src/shared/lib/theme/ink-scale.ts +21 -1
- package/src/shared/lib/theme/theme.test.ts +25 -9
- package/src/shared/lib/ui/safe-area.test.ts +28 -0
- package/src/shared/lib/ui/safe-area.ts +42 -0
- package/src/shared/lib/ui/toast-duration.test.ts +74 -0
- package/src/shared/lib/ui/toast-duration.ts +70 -0
- package/src/shared/types/harness-version.ts +59 -0
- package/src/shared/types/harness.ts +201 -0
- package/src/shared/types/index.ts +2 -0
- package/src/shared/types/omp/agent.ts +13 -0
- package/src/shared/types/settings/state.ts +10 -1
- package/src/shared/types/workspace.ts +10 -0
- package/src/test-support/env.ts +38 -0
- package/src/test-support/file-explorer-render.test-util.ts +37 -0
- package/src/test-support/file-explorer.test-util.ts +20 -18
- package/src/test-support/harness-table.test-util.ts +108 -0
- package/dist/client/static/js/index-7ppta1pb.css +0 -1
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The two ways a provider gets INTO a harness, from the browser's side.
|
|
8
|
+
*
|
|
9
|
+
* They are one module because they are one problem: the route funnels both
|
|
10
|
+
* through `applyProvider`, and the evidence they answer with is the SAME shape —
|
|
11
|
+
* so a single formatter turns either into what the card repeats. Two copies would
|
|
12
|
+
* drift the moment one learned a new note, and the reader would see two different
|
|
13
|
+
* accounts of the same kind of write.
|
|
14
|
+
*
|
|
15
|
+
* The credential rule differs, and that difference is the module's whole point:
|
|
16
|
+
*
|
|
17
|
+
* - an **import** never carries a key — the route reads it from the SOURCE file
|
|
18
|
+
* inside the request that writes, so no browser tab ever holds it;
|
|
19
|
+
* - an **add** does, because it was typed here and exists nowhere else.
|
|
20
|
+
*
|
|
21
|
+
* Either way the caller supplies `announce`, which folds the server's answer back
|
|
22
|
+
* into the shared harness store: the write landed in a FILE, so the list has to be
|
|
23
|
+
* re-read for the card to show it.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import type { HarnessConfig, HarnessImportOutcome, HarnessProviderSupport } from '@/shared/types/harness';
|
|
27
|
+
import type { AddProviderInput } from '@/client/components/settings/categories/harness-settings/AddProviderForm';
|
|
28
|
+
|
|
29
|
+
/** The answer both provider writes share. */
|
|
30
|
+
interface ProviderWritePayload {
|
|
31
|
+
imported?: { id: string; replaced: boolean; path: string; dialect: string; notes: string[] };
|
|
32
|
+
config?: HarnessConfig;
|
|
33
|
+
envWritten?: string[];
|
|
34
|
+
target?: string;
|
|
35
|
+
protocol?: string;
|
|
36
|
+
probe?: { protocols: string[]; error?: string };
|
|
37
|
+
/** Harness tabs whose cached probe no longer describes the registry. */
|
|
38
|
+
probeInvalidated?: string[];
|
|
39
|
+
error?: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* What `announce` does with a landed write: save the config the server answered
|
|
44
|
+
* with, when there is one, re-read the catalog, and re-probe the harness tabs
|
|
45
|
+
* whose cached answer the write invalidated.
|
|
46
|
+
*/
|
|
47
|
+
export type ProviderWriteAnnouncer = (
|
|
48
|
+
id: string,
|
|
49
|
+
config?: HarnessConfig,
|
|
50
|
+
probeInvalidated?: readonly string[],
|
|
51
|
+
) => void;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Turn one provider-write answer into what the card repeats.
|
|
55
|
+
*
|
|
56
|
+
* `detail` is the EVIDENCE — the protocol the probe chose, where it was written,
|
|
57
|
+
* and the env lines a variable-name format needed. "Copied"/"Added" alone was a
|
|
58
|
+
* claim the reader could not check, and measured imports differ in exactly that
|
|
59
|
+
* detail.
|
|
60
|
+
*/
|
|
61
|
+
function outcomeOf(
|
|
62
|
+
id: string,
|
|
63
|
+
response: Response,
|
|
64
|
+
payload: ProviderWritePayload,
|
|
65
|
+
verb: string,
|
|
66
|
+
announce: ProviderWriteAnnouncer,
|
|
67
|
+
): HarnessImportOutcome {
|
|
68
|
+
if (!response.ok) {
|
|
69
|
+
return { problem: payload.error ?? `${verb} failed (HTTP ${response.status})`, detail: null };
|
|
70
|
+
}
|
|
71
|
+
// An env-style target answered with a CONFIG; a registry target with what it
|
|
72
|
+
// wrote. Both change what the card shows, so both are folded back in.
|
|
73
|
+
announce(id, payload.config, payload.probeInvalidated);
|
|
74
|
+
const imported = payload.imported;
|
|
75
|
+
const parts = [
|
|
76
|
+
payload.protocol ? `${payload.protocol} → ${payload.target ?? imported?.path ?? 'the agent'}` : null,
|
|
77
|
+
payload.envWritten?.length ? `set ${payload.envWritten.join(', ')}` : null,
|
|
78
|
+
...(imported?.notes ?? []),
|
|
79
|
+
payload.probe?.protocols.length ? `endpoint answered ${payload.probe.protocols.join(', ')}` : null,
|
|
80
|
+
].filter(Boolean);
|
|
81
|
+
return { problem: null, detail: parts.join(' · ') || null };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** POST one provider request and frame its answer. */
|
|
85
|
+
async function postProvider(
|
|
86
|
+
id: string,
|
|
87
|
+
body: Record<string, unknown>,
|
|
88
|
+
verb: string,
|
|
89
|
+
announce: ProviderWriteAnnouncer,
|
|
90
|
+
): Promise<HarnessImportOutcome> {
|
|
91
|
+
try {
|
|
92
|
+
const response = await fetch('/api/harness', {
|
|
93
|
+
method: 'POST',
|
|
94
|
+
headers: { 'Content-Type': 'application/json' },
|
|
95
|
+
body: JSON.stringify({ probe: id, ...body }),
|
|
96
|
+
});
|
|
97
|
+
return outcomeOf(id, response, await response.json() as ProviderWritePayload, verb, announce);
|
|
98
|
+
} catch (cause) {
|
|
99
|
+
return { problem: cause instanceof Error ? cause.message : `${verb} failed`, detail: null };
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Copy one provider out of a source registry into a harness.
|
|
105
|
+
*
|
|
106
|
+
* The ROW travels with the id because the writer needs the endpoint, protocol and
|
|
107
|
+
* model list; the credential does not, and the route reads it from the source
|
|
108
|
+
* file in the same request.
|
|
109
|
+
*/
|
|
110
|
+
export function importProvider(
|
|
111
|
+
id: string,
|
|
112
|
+
sourceId: string,
|
|
113
|
+
entry: HarnessProviderSupport['importable'][number],
|
|
114
|
+
announce: ProviderWriteAnnouncer,
|
|
115
|
+
): Promise<HarnessImportOutcome> {
|
|
116
|
+
return postProvider(id, {
|
|
117
|
+
importProvider: {
|
|
118
|
+
from: entry.source,
|
|
119
|
+
id: sourceId,
|
|
120
|
+
entry: {
|
|
121
|
+
name: entry.name,
|
|
122
|
+
baseUrl: entry.baseUrl,
|
|
123
|
+
protocol: entry.protocol,
|
|
124
|
+
models: entry.models,
|
|
125
|
+
contextWindow: entry.contextWindow,
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
}, 'Import', announce);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Type a provider in instead of copying one.
|
|
133
|
+
*
|
|
134
|
+
* The key travels — it was typed in this tab — and the route stores it exactly
|
|
135
|
+
* where the target reads it: the entry for a registry, the harness env for a
|
|
136
|
+
* variable-name format, the vendor's own variables for an environment harness.
|
|
137
|
+
*/
|
|
138
|
+
export function addProvider(
|
|
139
|
+
id: string,
|
|
140
|
+
input: AddProviderInput,
|
|
141
|
+
announce: ProviderWriteAnnouncer,
|
|
142
|
+
): Promise<HarnessImportOutcome> {
|
|
143
|
+
return postProvider(id, { addProvider: input }, 'Add', announce);
|
|
144
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The versions store must RE-READ after an update.
|
|
8
|
+
*
|
|
9
|
+
* The reported bug: press Update, the install runs, and the button is still
|
|
10
|
+
* there — plus the row still shows the old version. The cause was one early
|
|
11
|
+
* return: `loadVersions(false)` skipped the whole read when `loaded` was already
|
|
12
|
+
* true, so the update's own refresh did nothing.
|
|
13
|
+
*
|
|
14
|
+
* `refresh()` is therefore a DIFFERENT operation from `reload(force)`:
|
|
15
|
+
*
|
|
16
|
+
* - `refresh` re-reads the rows (an update already knows the new number);
|
|
17
|
+
* - `reload(true)` also bypasses the server's registry cache, which costs one
|
|
18
|
+
* request per npm harness and belongs to the explicit "Check" button.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
22
|
+
import { Window } from 'happy-dom';
|
|
23
|
+
import { h, render } from 'preact';
|
|
24
|
+
import { act } from 'preact/test-utils';
|
|
25
|
+
|
|
26
|
+
import {
|
|
27
|
+
resetHarnessVersions,
|
|
28
|
+
useHarnessVersions,
|
|
29
|
+
} from '@/client/hooks/models/use-harness-versions';
|
|
30
|
+
import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
|
|
31
|
+
|
|
32
|
+
const realFetch = Bun.fetch;
|
|
33
|
+
let container: HTMLElement;
|
|
34
|
+
let calls: string[] = [];
|
|
35
|
+
let payload: { harnesses: unknown[] } = { harnesses: [] };
|
|
36
|
+
|
|
37
|
+
beforeEach(() => {
|
|
38
|
+
installDomGlobals(new Window({ url: 'http://localhost' }));
|
|
39
|
+
resetHarnessVersions();
|
|
40
|
+
container = document.createElement('div');
|
|
41
|
+
document.body.appendChild(container);
|
|
42
|
+
calls = [];
|
|
43
|
+
payload = { harnesses: [] };
|
|
44
|
+
(globalThis as unknown as Record<string, unknown>).fetch = async (input: unknown) => {
|
|
45
|
+
calls.push(String(input));
|
|
46
|
+
return new Response(JSON.stringify(payload), { status: 200 });
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
afterEach(() => {
|
|
51
|
+
render(null, container);
|
|
52
|
+
container.remove();
|
|
53
|
+
restoreDomGlobals();
|
|
54
|
+
(globalThis as unknown as Record<string, unknown>).fetch = realFetch;
|
|
55
|
+
resetHarnessVersions();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
/** Mount a consumer and hand back what it last rendered. */
|
|
59
|
+
function mountConsumer(): { read: () => ReturnType<typeof useHarnessVersions> } {
|
|
60
|
+
const box = { latest: null as ReturnType<typeof useHarnessVersions> | null };
|
|
61
|
+
function Consumer() {
|
|
62
|
+
box.latest = useHarnessVersions();
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
const host = document.createElement('div');
|
|
66
|
+
container.appendChild(host);
|
|
67
|
+
act(() => render(h(Consumer, {}), host));
|
|
68
|
+
return {
|
|
69
|
+
read: () => {
|
|
70
|
+
if (!box.latest) throw new Error('consumer did not render');
|
|
71
|
+
return box.latest;
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Let the stub's promise chain settle — microtasks, not a timer. */
|
|
77
|
+
async function flush(): Promise<void> {
|
|
78
|
+
await act(async () => {
|
|
79
|
+
await Promise.resolve();
|
|
80
|
+
await Promise.resolve();
|
|
81
|
+
await Promise.resolve();
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* One row as the route answers it. The parts are per-install — the adapter and the
|
|
87
|
+
* CLI move independently — so the store is handed the same shape the wire carries.
|
|
88
|
+
*/
|
|
89
|
+
function row(updateAvailable: boolean) {
|
|
90
|
+
return {
|
|
91
|
+
id: 'claude', label: 'claude', kind: 'npm', installed: true,
|
|
92
|
+
agent: { version: updateAvailable ? '0.100.0' : '0.101.0', latest: '0.101.0', updateAvailable },
|
|
93
|
+
cli: null,
|
|
94
|
+
updateAvailable, note: null, command: null,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
describe('versions store refresh', () => {
|
|
99
|
+
test('refresh() re-reads after an update instead of doing nothing', async () => {
|
|
100
|
+
payload = { harnesses: [row(true)] };
|
|
101
|
+
const consumer = mountConsumer();
|
|
102
|
+
await flush();
|
|
103
|
+
expect(consumer.read().rows[0].updateAvailable).toBe(true);
|
|
104
|
+
|
|
105
|
+
// What the server answers once the install landed.
|
|
106
|
+
payload = { harnesses: [row(false)] };
|
|
107
|
+
await act(async () => {
|
|
108
|
+
consumer.read().refresh();
|
|
109
|
+
});
|
|
110
|
+
await flush();
|
|
111
|
+
|
|
112
|
+
// The reported defect: without this the row kept offering Update.
|
|
113
|
+
expect(consumer.read().rows[0].updateAvailable).toBe(false);
|
|
114
|
+
expect(calls.filter((url) => url.includes('/api/harness/versions'))).toHaveLength(2);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
test('refresh() does NOT force the registry cache', async () => {
|
|
118
|
+
payload = { harnesses: [row(true)] };
|
|
119
|
+
const consumer = mountConsumer();
|
|
120
|
+
await flush();
|
|
121
|
+
await act(async () => {
|
|
122
|
+
consumer.read().refresh();
|
|
123
|
+
});
|
|
124
|
+
await flush();
|
|
125
|
+
|
|
126
|
+
// Only `reload(true)` may spend the extra registry read.
|
|
127
|
+
expect(calls.some((url) => url.includes('force=1'))).toBe(false);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test('reload(true) is the one that asks the registry again', async () => {
|
|
131
|
+
payload = { harnesses: [row(true)] };
|
|
132
|
+
const consumer = mountConsumer();
|
|
133
|
+
await flush();
|
|
134
|
+
await act(async () => {
|
|
135
|
+
consumer.read().reload(true);
|
|
136
|
+
});
|
|
137
|
+
await flush();
|
|
138
|
+
|
|
139
|
+
expect(calls.some((url) => url.includes('force=1'))).toBe(true);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
test('a second mount joins the first read rather than asking twice', async () => {
|
|
143
|
+
payload = { harnesses: [row(true)] };
|
|
144
|
+
const first = mountConsumer();
|
|
145
|
+
const second = mountConsumer();
|
|
146
|
+
await flush();
|
|
147
|
+
|
|
148
|
+
expect(first.read().rows).toHaveLength(1);
|
|
149
|
+
expect(second.read().rows).toHaveLength(1);
|
|
150
|
+
expect(calls.filter((url) => url.includes('/api/harness/versions'))).toHaveLength(1);
|
|
151
|
+
});
|
|
152
|
+
});
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Version + update state for every harness, as ONE shared store.
|
|
8
|
+
*
|
|
9
|
+
* Shared for the reason the harness catalog is (`use-harnesses.ts`): the About
|
|
10
|
+
* modal and any future surface must not each hold their own copy, or a
|
|
11
|
+
* "Check again" in one would leave the other showing yesterday's number.
|
|
12
|
+
*
|
|
13
|
+
* The read is CACHED until something forces it. `fetchNpmLatest` is one registry
|
|
14
|
+
* request per `npm` harness — nine of them — and About is a dialog a reader opens
|
|
15
|
+
* on a whim. Only the explicit "Check again" bypasses the cache.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { useCallback, useEffect, useState } from 'preact/hooks';
|
|
19
|
+
import type { HarnessVersionRow } from '@/shared/types/harness-version';
|
|
20
|
+
|
|
21
|
+
interface VersionStore {
|
|
22
|
+
rows: HarnessVersionRow[];
|
|
23
|
+
isLoading: boolean;
|
|
24
|
+
error: string | null;
|
|
25
|
+
checkedAt: number | null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const store: VersionStore = { rows: [], isLoading: true, error: null, checkedAt: null };
|
|
29
|
+
const listeners = new Set<() => void>();
|
|
30
|
+
let inflight: Promise<void> | null = null;
|
|
31
|
+
/** Has a read happened? A second mount joins the answer instead of re-asking. */
|
|
32
|
+
let loaded = false;
|
|
33
|
+
/** Set by `refresh()`, cleared once the read starts. */
|
|
34
|
+
let refreshRequested = false;
|
|
35
|
+
|
|
36
|
+
function emit(patch: Partial<VersionStore>): void {
|
|
37
|
+
Object.assign(store, patch);
|
|
38
|
+
for (const listener of listeners) listener();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function loadVersions(force: boolean): Promise<void> {
|
|
42
|
+
if (inflight) return inflight;
|
|
43
|
+
// `force` means "re-read the REGISTRY" (the Check button). A plain reload is
|
|
44
|
+
// what an UPDATE asks for: the rows must be re-read, but the registry answers
|
|
45
|
+
// inside its own cache window, so it is not forced. Skipping it because
|
|
46
|
+
// `loaded` was already true is how an update left the row showing its old
|
|
47
|
+
// version AND the button still enabled.
|
|
48
|
+
if (loaded && !force && !refreshRequested) return;
|
|
49
|
+
refreshRequested = false;
|
|
50
|
+
emit({ isLoading: true });
|
|
51
|
+
inflight = fetch(`/api/harness/versions${force ? '?force=1' : ''}`)
|
|
52
|
+
.then(async (response) => {
|
|
53
|
+
if (!response.ok) throw new Error(`GET /api/harness/versions answered ${response.status}`);
|
|
54
|
+
return (await response.json()) as { harnesses?: HarnessVersionRow[]; error?: string };
|
|
55
|
+
})
|
|
56
|
+
.then((payload) => {
|
|
57
|
+
loaded = true;
|
|
58
|
+
emit({
|
|
59
|
+
rows: Array.isArray(payload.harnesses) ? payload.harnesses : [],
|
|
60
|
+
checkedAt: Date.now(),
|
|
61
|
+
error: null,
|
|
62
|
+
isLoading: false,
|
|
63
|
+
});
|
|
64
|
+
})
|
|
65
|
+
.catch((cause: unknown) => {
|
|
66
|
+
emit({
|
|
67
|
+
error: cause instanceof Error ? cause.message : 'Could not read the harness versions',
|
|
68
|
+
isLoading: false,
|
|
69
|
+
});
|
|
70
|
+
})
|
|
71
|
+
.finally(() => {
|
|
72
|
+
inflight = null;
|
|
73
|
+
});
|
|
74
|
+
return inflight;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface HarnessVersionsController {
|
|
78
|
+
rows: HarnessVersionRow[];
|
|
79
|
+
isLoading: boolean;
|
|
80
|
+
error: string | null;
|
|
81
|
+
checkedAt: number | null;
|
|
82
|
+
/** `true` bypasses the registry cache — the "Check again" path. */
|
|
83
|
+
reload: (force?: boolean) => void;
|
|
84
|
+
/** Re-read the ROWS without forcing the registry: what an update asks for.
|
|
85
|
+
* Distinct from `reload` because that one spends a registry request per
|
|
86
|
+
* `npm` harness, and an update has already paid for the number it needs. */
|
|
87
|
+
refresh: () => void;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function useHarnessVersions(): HarnessVersionsController {
|
|
91
|
+
const [snapshot, setSnapshot] = useState(() => ({ ...store }));
|
|
92
|
+
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
const sync = () => setSnapshot({ ...store });
|
|
95
|
+
listeners.add(sync);
|
|
96
|
+
sync();
|
|
97
|
+
// A harness that has never been probed has no version to report, so reading
|
|
98
|
+
// this on mount is what turns a dash into a number after a Check status.
|
|
99
|
+
void loadVersions(false);
|
|
100
|
+
return () => {
|
|
101
|
+
listeners.delete(sync);
|
|
102
|
+
};
|
|
103
|
+
}, []);
|
|
104
|
+
|
|
105
|
+
return {
|
|
106
|
+
rows: snapshot.rows,
|
|
107
|
+
isLoading: snapshot.isLoading,
|
|
108
|
+
error: snapshot.error,
|
|
109
|
+
checkedAt: snapshot.checkedAt,
|
|
110
|
+
reload: useCallback((force = true) => {
|
|
111
|
+
void loadVersions(force);
|
|
112
|
+
}, []),
|
|
113
|
+
refresh: useCallback(() => {
|
|
114
|
+
refreshRequested = true;
|
|
115
|
+
void loadVersions(false);
|
|
116
|
+
}, []),
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Forget the store. Two callers, one meaning: a test starts cold, and a probe
|
|
122
|
+
* that just learned a version must not be hidden behind a stale row.
|
|
123
|
+
*/
|
|
124
|
+
export function resetHarnessVersions(): void {
|
|
125
|
+
inflight = null;
|
|
126
|
+
loaded = false;
|
|
127
|
+
refreshRequested = false;
|
|
128
|
+
Object.assign(store, { rows: [], isLoading: true, error: null, checkedAt: null });
|
|
129
|
+
for (const listener of listeners) listener();
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** Re-read the rows after a probe, WITHOUT forcing a registry request. */
|
|
133
|
+
export function invalidateHarnessVersions(): void {
|
|
134
|
+
refreshRequested = true;
|
|
135
|
+
void loadVersions(false);
|
|
136
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The `useHarnesses()` contract, named where a consumer can import it.
|
|
8
|
+
*
|
|
9
|
+
* The store's implementation file is at the 350-line ceiling; the type earns its
|
|
10
|
+
* own module and keeps every consumer off `ReturnType<typeof useHarnesses>`.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type {
|
|
14
|
+
HarnessConfig, HarnessImportOutcome, HarnessProviderSupport, HarnessSummary, LiveHarnessModels,
|
|
15
|
+
} from '@/shared/types/harness';
|
|
16
|
+
import type { AddProviderInput } from '@/client/components/settings/categories/harness-settings/AddProviderForm';
|
|
17
|
+
|
|
18
|
+
export interface HarnessesController {
|
|
19
|
+
harnesses: HarnessSummary[];
|
|
20
|
+
/** Per-harness config, keyed by id. Empty until the catalog is read. */
|
|
21
|
+
configs: Record<string, HarnessConfig>;
|
|
22
|
+
/** Persist one harness's config; resolves to the server's refusal, or null. */
|
|
23
|
+
saveConfig: (id: string, config: HarnessConfig) => Promise<string | null>;
|
|
24
|
+
/** What each harness can do about other providers, keyed by id. */
|
|
25
|
+
providerSupport: Record<string, HarnessProviderSupport>;
|
|
26
|
+
/**
|
|
27
|
+
* The model/thinking selectors a harness's LIVE chat published, keyed by id.
|
|
28
|
+
*
|
|
29
|
+
* A probe is one throwaway spawn, and it can be refused (`codex` answers
|
|
30
|
+
* "Authentication required" to the probe while the chat the user is running
|
|
31
|
+
* lists its models) or aged. The open session's own selectors are the truth
|
|
32
|
+
* for that harness, so the picker reads them first; absent means "only the
|
|
33
|
+
* probe has spoken".
|
|
34
|
+
*/
|
|
35
|
+
liveModels: Record<string, LiveHarnessModels>;
|
|
36
|
+
/** Copy one provider from a source registry into a harness.
|
|
37
|
+
*
|
|
38
|
+
* The ROW travels with the id: the writer needs the endpoint, dialect and
|
|
39
|
+
* model list, and the server would otherwise have to look them up again. The
|
|
40
|
+
* credential is not in the row — the server reads that from the source file. */
|
|
41
|
+
importProvider: (
|
|
42
|
+
id: string,
|
|
43
|
+
sourceId: string,
|
|
44
|
+
entry: HarnessProviderSupport['importable'][number],
|
|
45
|
+
) => Promise<HarnessImportOutcome>;
|
|
46
|
+
/** Add a provider by typing its endpoint and key. */
|
|
47
|
+
addProvider: (id: string, input: AddProviderInput) => Promise<HarnessImportOutcome>;
|
|
48
|
+
isLoading: boolean;
|
|
49
|
+
error: string | null;
|
|
50
|
+
/** Re-read the catalog. */
|
|
51
|
+
reload: () => void;
|
|
52
|
+
/** Probe one harness (spawns that agent once) and merge the answer in. */
|
|
53
|
+
probe: (id: string, cwd?: string) => Promise<string | null>;
|
|
54
|
+
/** Switch one harness on or off. Switching ON also probes it once, server-side,
|
|
55
|
+
* so its models are ready for the composer. Resolves to the refusal, or null. */
|
|
56
|
+
setEnabled: (id: string, enabled: boolean) => Promise<string | null>;
|
|
57
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A provider write republishes the `models` topic, and the harness catalog is
|
|
8
|
+
* stale in exactly the same way: the server re-probed the ACP harnesses on that
|
|
9
|
+
* write. The hook therefore re-reads `GET /api/harness` when the topic fires —
|
|
10
|
+
* without this, the composer picker kept the pre-write probe until a reload.
|
|
11
|
+
*
|
|
12
|
+
* A real listener on a real socket, because the bug is frame delivery, not the
|
|
13
|
+
* fetch: a stubbed socket would only prove the fake's timing.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
17
|
+
import { Window } from 'happy-dom';
|
|
18
|
+
import { h, render } from 'preact';
|
|
19
|
+
import { act } from 'preact/test-utils';
|
|
20
|
+
|
|
21
|
+
import { resetHarnessesStore } from '@/client/hooks/models/harness-catalog';
|
|
22
|
+
import { useHarnesses } from '@/client/hooks/models/use-harnesses';
|
|
23
|
+
import type { HarnessesController } from '@/client/hooks/models/use-harnesses-controller';
|
|
24
|
+
import { TOPIC_MODELS } from '@/shared/lib/realtime/protocol';
|
|
25
|
+
import { resetRealtimeClient } from '@/shared/lib/realtime/client';
|
|
26
|
+
import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
|
|
27
|
+
import { startRealtimeTestServer, type RealtimeTestServer } from '@/test-support/realtime-server';
|
|
28
|
+
|
|
29
|
+
const UNPROBED = { id: 'omp-acp', label: 'omp ACP', transport: 'acp', canLaunch: true, probe: null };
|
|
30
|
+
const PROBED = {
|
|
31
|
+
id: 'omp-acp',
|
|
32
|
+
label: 'omp ACP',
|
|
33
|
+
transport: 'acp',
|
|
34
|
+
canLaunch: true,
|
|
35
|
+
probe: {
|
|
36
|
+
harness: 'omp-acp',
|
|
37
|
+
capabilities: {
|
|
38
|
+
configModel: 2, configThinking: 0, configMode: 0, modeValues: [],
|
|
39
|
+
loadSession: true, listSessions: true, forkSession: true, deleteSession: true,
|
|
40
|
+
resumeSession: true, closeSession: true, hasUsage: false, hasPlan: false, steerMode: null,
|
|
41
|
+
},
|
|
42
|
+
models: [
|
|
43
|
+
{ value: 'minimax/MiniMax-M2', name: 'MiniMax M2' },
|
|
44
|
+
{ value: 'kimi/kimi-k2', name: 'Kimi K2' },
|
|
45
|
+
],
|
|
46
|
+
thinking: [],
|
|
47
|
+
modes: [],
|
|
48
|
+
probedAt: Date.now(),
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const realFetch = Bun.fetch;
|
|
53
|
+
let server: RealtimeTestServer;
|
|
54
|
+
let container: HTMLElement;
|
|
55
|
+
let catalogReads = 0;
|
|
56
|
+
/** The server's answer changed only when the write lands. */
|
|
57
|
+
let written = false;
|
|
58
|
+
|
|
59
|
+
beforeEach(async () => {
|
|
60
|
+
server = await startRealtimeTestServer(new Map([[TOPIC_MODELS, async () => ({ modelList: [] })]]));
|
|
61
|
+
installDomGlobals(new Window({ url: `http://127.0.0.1:${server.port}` }));
|
|
62
|
+
resetHarnessesStore();
|
|
63
|
+
catalogReads = 0;
|
|
64
|
+
written = false;
|
|
65
|
+
(globalThis as unknown as Record<string, unknown>).fetch = async (input: unknown) => {
|
|
66
|
+
const url = String(input);
|
|
67
|
+
if (!url.includes('/api/harness')) return new Response('{}', { status: 200 });
|
|
68
|
+
catalogReads += 1;
|
|
69
|
+
const body = { harnesses: [written ? PROBED : UNPROBED], configs: {}, providerSupport: {} };
|
|
70
|
+
return new Response(JSON.stringify(body), { status: 200, headers: { 'content-type': 'application/json' } });
|
|
71
|
+
};
|
|
72
|
+
container = document.createElement('div');
|
|
73
|
+
document.body.append(container);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
afterEach(() => {
|
|
77
|
+
render(null, container);
|
|
78
|
+
container.remove();
|
|
79
|
+
resetRealtimeClient();
|
|
80
|
+
server.stop();
|
|
81
|
+
restoreDomGlobals();
|
|
82
|
+
(globalThis as unknown as Record<string, unknown>).fetch = realFetch;
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
function mount(): { read: () => HarnessesController } {
|
|
86
|
+
const box = { latest: null as HarnessesController | null };
|
|
87
|
+
function Consumer() {
|
|
88
|
+
box.latest = useHarnesses();
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
const host = document.createElement('div');
|
|
92
|
+
container.appendChild(host);
|
|
93
|
+
act(() => render(h(Consumer, {}), host));
|
|
94
|
+
return {
|
|
95
|
+
read: () => {
|
|
96
|
+
if (!box.latest) throw new Error('consumer did not render');
|
|
97
|
+
return box.latest;
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
describe('the harness catalog follows the models topic', () => {
|
|
103
|
+
test('a models-changed frame re-reads the catalog and shows the new probe', async () => {
|
|
104
|
+
const consumer = mount();
|
|
105
|
+
await act(async () => {});
|
|
106
|
+
await server.waitForTopic(TOPIC_MODELS, (value) => value !== null);
|
|
107
|
+
expect(consumer.read().harnesses[0]?.probe).toBeNull();
|
|
108
|
+
// Mounting costs one read; the subscription's opening snapshot costs the
|
|
109
|
+
// second. That snapshot is the same catalog, so the probe is still absent.
|
|
110
|
+
expect(catalogReads).toBe(2);
|
|
111
|
+
|
|
112
|
+
written = true;
|
|
113
|
+
server.publish(TOPIC_MODELS, { modelList: [{ value: 'minimax/MiniMax-M2' }] });
|
|
114
|
+
// Wait on the client's own notification: the delta is a socket task, so a
|
|
115
|
+
// microtask drain alone could assert before the frame is even decoded.
|
|
116
|
+
await server.waitForTopic<{ modelList: { value: string }[] }>(
|
|
117
|
+
TOPIC_MODELS,
|
|
118
|
+
(value) => value?.modelList.length === 1,
|
|
119
|
+
);
|
|
120
|
+
// The subscriber's fetch starts from that notification; drain until the
|
|
121
|
+
// store's render reflects the post-write answer.
|
|
122
|
+
for (let i = 0; i < 20 && !consumer.read().harnesses[0]?.probe; i += 1) await act(async () => {});
|
|
123
|
+
await act(async () => {});
|
|
124
|
+
|
|
125
|
+
expect(catalogReads).toBeGreaterThan(2);
|
|
126
|
+
expect(consumer.read().harnesses[0]?.probe?.models).toHaveLength(2);
|
|
127
|
+
});
|
|
128
|
+
});
|