@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,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* `POST /api/harness { importProvider }` — the one action the user asked for:
|
|
8
|
+
* "claude pakai import provider kenari dari omp".
|
|
9
|
+
*
|
|
10
|
+
* Three facts make it honest, and each is asserted against a REAL registry file
|
|
11
|
+
* in a temp HOME rather than a hand-built payload:
|
|
12
|
+
*
|
|
13
|
+
* - the row the browser sends carries no credential; the route reads the key out
|
|
14
|
+
* of the SOURCE file in the same request that writes the target;
|
|
15
|
+
* - the endpoint is PROBED, and a protocol the target cannot speak is refused by
|
|
16
|
+
* name instead of being written as a guess (codex rejects `wire_api = "chat"`
|
|
17
|
+
* at config load, and Anthropic written as Chat fails every request);
|
|
18
|
+
* - an env target gets the vendor's own variables at the HOST ROOT, because the
|
|
19
|
+
* SDK appends `/v1/messages` itself — measured on Claude Code, which answered
|
|
20
|
+
* an empty turn against `https://kenari.id/v1`.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test } from 'bun:test';
|
|
24
|
+
import fs from 'node:fs';
|
|
25
|
+
import os from 'node:os';
|
|
26
|
+
import path from 'node:path';
|
|
27
|
+
|
|
28
|
+
import { isolateDb, releaseDb } from '@/test-support/isolated-db';
|
|
29
|
+
import { restoreEnv } from '@/test-support/env';
|
|
30
|
+
import { action, loader } from '@/server/routes/harness/root';
|
|
31
|
+
import { loadHarnessConfig } from '@/server/lib/harness/config.server';
|
|
32
|
+
|
|
33
|
+
const ROOT = path.join(os.tmpdir(), 'kabmo-harness-import-route');
|
|
34
|
+
const API = 'http://localhost/api/harness';
|
|
35
|
+
|
|
36
|
+
type Handler = (args: never) => unknown;
|
|
37
|
+
|
|
38
|
+
function call(handler: Handler, request: Request): Promise<Response> {
|
|
39
|
+
return handler({ request, params: {} } as never) as Promise<Response>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function post(body: unknown): Request {
|
|
43
|
+
return new Request(API, {
|
|
44
|
+
method: 'POST',
|
|
45
|
+
body: JSON.stringify(body),
|
|
46
|
+
headers: { 'content-type': 'application/json' },
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const MODELS_YML = `providers:
|
|
51
|
+
kenari:
|
|
52
|
+
baseUrl: https://kenari.id/v1
|
|
53
|
+
apiKey: kn-route-test
|
|
54
|
+
api: openai-completions
|
|
55
|
+
models:
|
|
56
|
+
- id: claude-sonnet-5
|
|
57
|
+
contextWindow: 1000000
|
|
58
|
+
anthropic:
|
|
59
|
+
baseUrl: https://api.anthropic.com/v1
|
|
60
|
+
api: anthropic-messages
|
|
61
|
+
models: []
|
|
62
|
+
`;
|
|
63
|
+
|
|
64
|
+
const savedHome = Bun.env.HOME;
|
|
65
|
+
let stub: { port?: number; stop(force?: boolean): void } | null = null;
|
|
66
|
+
let baseUrl = '';
|
|
67
|
+
|
|
68
|
+
beforeAll(() => {
|
|
69
|
+
fs.mkdirSync(path.join(ROOT, '.omp/agent'), { recursive: true });
|
|
70
|
+
Bun.env.HOME = ROOT;
|
|
71
|
+
Bun.env.KABMO_TEST_HOME = ROOT;
|
|
72
|
+
fs.writeFileSync(path.join(ROOT, '.omp/agent/models.yml'), MODELS_YML);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
beforeEach(async () => {
|
|
76
|
+
await isolateDb();
|
|
77
|
+
// A stub host shaped like the measured one: Anthropic Messages and OpenAI Chat
|
|
78
|
+
// answer a malformed body, the Gemini listing and `/v1/responses` do not.
|
|
79
|
+
stub = Bun.serve({
|
|
80
|
+
port: 0,
|
|
81
|
+
fetch(request) {
|
|
82
|
+
const { pathname } = new URL(request.url);
|
|
83
|
+
if (pathname === '/v1/messages') {
|
|
84
|
+
return Response.json({ error: { message: 'invalid Anthropic request JSON: missing field `model`' } }, { status: 400 });
|
|
85
|
+
}
|
|
86
|
+
if (pathname === '/v1/chat/completions') {
|
|
87
|
+
return Response.json({ error: { message: 'invalid JSON: missing field `model`' } }, { status: 400 });
|
|
88
|
+
}
|
|
89
|
+
return new Response('<!DOCTYPE html><html></html>', {
|
|
90
|
+
status: 404,
|
|
91
|
+
headers: { 'content-type': 'text/html' },
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
baseUrl = `http://127.0.0.1:${stub.port ?? 0}/v1`;
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
afterEach(async () => {
|
|
99
|
+
stub?.stop(true);
|
|
100
|
+
stub = null;
|
|
101
|
+
await releaseDb();
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
afterAll(() => {
|
|
105
|
+
restoreEnv('HOME', savedHome);
|
|
106
|
+
delete Bun.env.KABMO_TEST_HOME;
|
|
107
|
+
fs.rmSync(ROOT, { recursive: true, force: true });
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
describe('importing a custom provider into claude', () => {
|
|
111
|
+
test('the vendor’s own variables are written at the HOST ROOT, and the key is read server-side', async () => {
|
|
112
|
+
const entry = {
|
|
113
|
+
name: 'Kenari',
|
|
114
|
+
// The stub stands in for the host; its shape is what the probe measures.
|
|
115
|
+
baseUrl,
|
|
116
|
+
protocol: 'openai-chat',
|
|
117
|
+
models: ['claude-sonnet-5'],
|
|
118
|
+
contextWindow: { 'claude-sonnet-5': 1_000_000 },
|
|
119
|
+
};
|
|
120
|
+
const response = await call(action, post({
|
|
121
|
+
probe: 'claude',
|
|
122
|
+
importProvider: { from: 'omp-rpc', id: 'kenari', entry },
|
|
123
|
+
}));
|
|
124
|
+
const payload = await response.json() as {
|
|
125
|
+
config?: { env: string };
|
|
126
|
+
envWritten?: string[];
|
|
127
|
+
protocol?: string;
|
|
128
|
+
error?: string;
|
|
129
|
+
};
|
|
130
|
+
expect(payload.error).toBeUndefined();
|
|
131
|
+
// The probe found Anthropic Messages on the host and Claude Code speaks it,
|
|
132
|
+
// even though the source declares openai-completions.
|
|
133
|
+
expect(payload.protocol).toBe('anthropic-messages');
|
|
134
|
+
expect(payload.envWritten).toEqual(
|
|
135
|
+
['ANTHROPIC_BASE_URL', 'ANTHROPIC_AUTH_TOKEN', 'ANTHROPIC_MODEL'],
|
|
136
|
+
);
|
|
137
|
+
// The stub's `/v1` is stripped: the SDK appends `/v1/messages` itself.
|
|
138
|
+
expect(payload.config?.env).toContain(`ANTHROPIC_BASE_URL=${baseUrl.replace(/\/v1$/, '')}`);
|
|
139
|
+
// The credential came from the SOURCE file, never from the request body.
|
|
140
|
+
expect(payload.config?.env).toContain('ANTHROPIC_AUTH_TOKEN=kn-route-test');
|
|
141
|
+
// A Sonnet id, not the source's first row: measured, kenari lists
|
|
142
|
+
// `agnes-2-5-flash:free` first and Claude Code logged `unrecognized_model`.
|
|
143
|
+
expect(payload.config?.env).toMatch(/ANTHROPIC_MODEL=claude-sonnet-5/);
|
|
144
|
+
// And it is what the spawn will read, not a value only the response held.
|
|
145
|
+
const saved = await loadHarnessConfig('claude');
|
|
146
|
+
expect(saved.env).toBe(payload.config?.env ?? '');
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
test('a host that speaks nothing this target speaks is refused BY NAME', async () => {
|
|
150
|
+
const response = await call(action, post({
|
|
151
|
+
probe: 'antigravity',
|
|
152
|
+
importProvider: {
|
|
153
|
+
from: 'omp-rpc',
|
|
154
|
+
id: 'kenari',
|
|
155
|
+
entry: { name: 'Kenari', baseUrl, protocol: 'openai-chat', models: ['m'] },
|
|
156
|
+
},
|
|
157
|
+
}));
|
|
158
|
+
const payload = await response.json() as { error?: string; code?: string; probe?: { protocols: string[] } };
|
|
159
|
+
expect(response.status).toBe(400);
|
|
160
|
+
expect(payload.code).toBe('no_shared_protocol');
|
|
161
|
+
// The refusal names what the endpoint DOES answer, so the reader can see why.
|
|
162
|
+
expect(payload.error).toContain('anthropic-messages');
|
|
163
|
+
expect(payload.error).toContain('openai-chat');
|
|
164
|
+
expect(payload.probe?.protocols).toEqual(['openai-chat', 'anthropic-messages']);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
test('a VENDOR provider is not in the import list at all', async () => {
|
|
168
|
+
const response = await call(loader, new Request(API));
|
|
169
|
+
const payload = await response.json() as {
|
|
170
|
+
providerSupport: Record<string, { importable: Array<{ id: string; source: string }> }>;
|
|
171
|
+
};
|
|
172
|
+
const ids = payload.providerSupport.claude?.importable.map((row) => row.id) ?? [];
|
|
173
|
+
expect(ids).toContain('kenari');
|
|
174
|
+
// `anthropic` is in the same models.yml and must never be offered: copying it
|
|
175
|
+
// into another agent overrides that agent's own built-in provider.
|
|
176
|
+
expect(ids).not.toContain('anthropic');
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
test('the card is told the target’s protocols and the source’s, not a guess', async () => {
|
|
180
|
+
// The row is offered even though its DECLARED protocol is not one claude
|
|
181
|
+
// speaks: the probe is what decides, and it is the route's job — the loader
|
|
182
|
+
// refusing here would have hidden the one import that works.
|
|
183
|
+
const response = await call(loader, new Request(API));
|
|
184
|
+
const payload = await response.json() as {
|
|
185
|
+
providerSupport: Record<string, {
|
|
186
|
+
protocols: string[];
|
|
187
|
+
importable: Array<{ id: string; protocol?: string }>;
|
|
188
|
+
}>;
|
|
189
|
+
};
|
|
190
|
+
const claude = payload.providerSupport.claude!;
|
|
191
|
+
expect(claude.protocols).toEqual(['anthropic-messages']);
|
|
192
|
+
expect(claude.importable.find((row) => row.id === 'kenari')?.protocol).toBe('openai-chat');
|
|
193
|
+
// codex stores Responses only, so its list says so.
|
|
194
|
+
expect(payload.providerSupport.codex?.protocols).toEqual(['openai-responses']);
|
|
195
|
+
});
|
|
196
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { actionBindings, type HandlerBinding } from '@/server/lib/route-adapter';
|
|
2
|
+
import * as harnessRoot from '@/server/routes/harness/root';
|
|
3
|
+
import * as harnessUpdate from '@/server/routes/harness/update';
|
|
4
|
+
import * as harnessVersions from '@/server/routes/harness/versions';
|
|
5
|
+
|
|
6
|
+
export const harnessBindings: HandlerBinding[] = [
|
|
7
|
+
...actionBindings(harnessRoot.action, '/api/harness', harnessRoot.loader),
|
|
8
|
+
// Static paths registered as their own routes. A `/api/harness/:id` parameter
|
|
9
|
+
// route sharing this position is the shape that makes the parameter win the
|
|
10
|
+
// match and hide the real handler behind a 405.
|
|
11
|
+
...actionBindings(harnessUpdate.action, '/api/harness/update', harnessVersions.loader),
|
|
12
|
+
...actionBindings(harnessRoot.action, '/api/harness/versions', harnessVersions.loader),
|
|
13
|
+
];
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Harness discovery: which harnesses can run here, and what each one offers.
|
|
8
|
+
*
|
|
9
|
+
* Split from the spawn route because the two answer different questions on
|
|
10
|
+
* different cadences — this one is read by the composer's tab strip and the
|
|
11
|
+
* settings page (cached for the process), while a spawn happens once per chat.
|
|
12
|
+
*
|
|
13
|
+
* Probing spawns agents, so it NEVER runs on a page load: `GET` without
|
|
14
|
+
* `?probe=` answers from the cache (and from the static launch table for
|
|
15
|
+
* anything never probed), and `?probe=<id>` spawns exactly one.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { json } from '@/server/lib/remix-compat';
|
|
19
|
+
import type { ActionFunctionArgs, LoaderFunctionArgs } from '@/server/lib/remix-compat';
|
|
20
|
+
import { methodNotAllowed } from '@/server/lib/route-adapter';
|
|
21
|
+
import { HARNESS_IDS, harnessDescriptor, type HarnessId } from '@/shared/lib/harness/catalog';
|
|
22
|
+
import { HARNESS_LAUNCH } from '@/server/lib/harness/launch-table';
|
|
23
|
+
import type { HarnessProbe } from '@/server/lib/harness/capabilities';
|
|
24
|
+
import { forgetProbe, loadProbes, rememberProbe } from '@/server/lib/harness/probe-cache.server';
|
|
25
|
+
import { loadDisabledHarnesses, saveHarnessEnabled } from '@/server/lib/harness/enabled.server';
|
|
26
|
+
import { harnessEnabled } from '@/shared/lib/harness/enabled';
|
|
27
|
+
import { commandAvailable, probeWithConfig } from '@/server/lib/harness/auto-probe.server';
|
|
28
|
+
import { loadHarnessConfig, probeInvalidatedBy, saveHarnessConfig } from '@/server/lib/harness/config.server';
|
|
29
|
+
import { importableProvidersFor, readRegistryProviders } from '@/server/lib/harness/provider-sources.server';
|
|
30
|
+
import { addProviderAction, importProviderAction, importSourceOf, isImportBody } from '@/server/routes/harness/import-action';
|
|
31
|
+
import { supportedProtocols } from '@/shared/lib/harness/dialects';
|
|
32
|
+
import {
|
|
33
|
+
credentialFieldLabel,
|
|
34
|
+
providerLevel,
|
|
35
|
+
registryLabel,
|
|
36
|
+
} from '@/shared/lib/harness/providers';
|
|
37
|
+
import { providerFacts } from '@/shared/lib/harness/provider-facts';
|
|
38
|
+
import type { HarnessProviderSupport } from '@/shared/types/harness';
|
|
39
|
+
import { parseHarnessConfig, type HarnessConfig } from '@/shared/lib/harness/config';
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The probe cache lives in `probe-cache.server.ts`: the SPAWN reads it too, to
|
|
43
|
+
* resolve a harness's configured default model against what that agent
|
|
44
|
+
* published, and a route must not be an import of the spawn path.
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
export interface HarnessSummary {
|
|
48
|
+
id: HarnessId;
|
|
49
|
+
label: string;
|
|
50
|
+
transport: 'rpc' | 'acp';
|
|
51
|
+
/** False for `omp-rpc`, which is the built-in path and is always present. */
|
|
52
|
+
canLaunch: boolean;
|
|
53
|
+
/** True for the transport Kabmo itself provides (`omp-rpc`). It is not a
|
|
54
|
+
* choice, so the settings page omits it — see `installable` on the catalog
|
|
55
|
+
* descriptor. */
|
|
56
|
+
builtIn?: true;
|
|
57
|
+
install?: string;
|
|
58
|
+
note?: string;
|
|
59
|
+
probe: HarnessProbe | null;
|
|
60
|
+
/** Why it cannot run, without probing: the launch command is missing. */
|
|
61
|
+
unavailable?: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export async function listHarnesses(): Promise<HarnessSummary[]> {
|
|
65
|
+
// ONE read for the whole catalog, from disk when memory is cold: the probe
|
|
66
|
+
// cache used to be process-only, so every restart — every `bun --hot` reload —
|
|
67
|
+
// turned a harness the user had just checked back into `not probed`.
|
|
68
|
+
const stored = await loadProbes();
|
|
69
|
+
// The user's roster: a switched-off harness keeps its row here (so
|
|
70
|
+
// `enabled: false` can be read) but is filtered out by the settings menu and
|
|
71
|
+
// the composer's picker. Read in the same pass as the probes for the reason
|
|
72
|
+
// above — this is the one catalog answer.
|
|
73
|
+
const disabled = await loadDisabledHarnesses();
|
|
74
|
+
const configs: Record<string, HarnessConfig> = {};
|
|
75
|
+
for (const id of HARNESS_IDS) configs[id] = await loadHarnessConfig(id);
|
|
76
|
+
return HARNESS_IDS.map((id) => {
|
|
77
|
+
const descriptor = harnessDescriptor(id);
|
|
78
|
+
const launch = HARNESS_LAUNCH[id];
|
|
79
|
+
const cached = stored.get(id) ?? null;
|
|
80
|
+
// A BUILT-IN transport is never represented by a probe. There is no agent to
|
|
81
|
+
// spawn, so `probeHarness` can only answer "no launch command is configured"
|
|
82
|
+
// — and that answer, cached, came back as `capabilities.blocked` and painted
|
|
83
|
+
// a ⚠ over the `omp` tab while DISABLING it, so the default harness could not
|
|
84
|
+
// be selected at all. Measured: `?probe=omp-rpc` wrote exactly that record.
|
|
85
|
+
const fresh = descriptor?.builtIn ? null : cached;
|
|
86
|
+
const available = id === 'omp-rpc' ? true : commandAvailable(id, configs[id]);
|
|
87
|
+
return {
|
|
88
|
+
id,
|
|
89
|
+
label: descriptor?.label ?? id,
|
|
90
|
+
transport: descriptor?.transport ?? 'acp',
|
|
91
|
+
canLaunch: available,
|
|
92
|
+
enabled: harnessEnabled(id, disabled),
|
|
93
|
+
...(descriptor?.builtIn ? { builtIn: true as const } : {}),
|
|
94
|
+
...(launch?.install ? { install: launch.install } : {}),
|
|
95
|
+
...(launch?.note ? { note: launch.note } : {}),
|
|
96
|
+
probe: fresh,
|
|
97
|
+
...(available ? {} : {
|
|
98
|
+
unavailable: launch?.requires
|
|
99
|
+
? `${launch.requires.label} is not installed`
|
|
100
|
+
: `\`${launch?.command[0] ?? id}\` is not installed`,
|
|
101
|
+
}),
|
|
102
|
+
};
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export async function loader({ request }: LoaderFunctionArgs) {
|
|
107
|
+
const url = new URL(request.url);
|
|
108
|
+
const target = url.searchParams.get('probe');
|
|
109
|
+
if (target) {
|
|
110
|
+
if (!HARNESS_IDS.includes(target as HarnessId)) {
|
|
111
|
+
return json({ error: `Unknown harness: ${target}` }, { status: 400 });
|
|
112
|
+
}
|
|
113
|
+
// Refused, not probed: a built-in transport has nothing to spawn, and the
|
|
114
|
+
// only answer a probe could produce ("no launch command is configured") is a
|
|
115
|
+
// fact about this route, not about omp. Probing it used to mark the DEFAULT
|
|
116
|
+
// tab blocked, which disabled it in the picker.
|
|
117
|
+
if (harnessDescriptor(target)?.builtIn) {
|
|
118
|
+
return json({ error: `${target} is built in and has no agent to probe`, code: 'builtin_not_probeable' }, { status: 400 });
|
|
119
|
+
}
|
|
120
|
+
const cwd = url.searchParams.get('cwd') || process.cwd();
|
|
121
|
+
const probe = await probeWithConfig(target as HarnessId, cwd);
|
|
122
|
+
await rememberProbe(target as HarnessId, probe);
|
|
123
|
+
return json({ probe });
|
|
124
|
+
}
|
|
125
|
+
// Every harness's per-harness config travels WITH the catalog: the settings
|
|
126
|
+
// card renders its form from this one payload, so opening a card cannot show a
|
|
127
|
+
// stale value the server would then refuse to save.
|
|
128
|
+
const configs: Record<string, HarnessConfig> = {};
|
|
129
|
+
for (const id of HARNESS_IDS) configs[id] = await loadHarnessConfig(id);
|
|
130
|
+
|
|
131
|
+
// What each harness can do about OTHER providers, from the MEASURED table: the
|
|
132
|
+
// file, the field names, whether Kabmo may write it, and the credential-free
|
|
133
|
+
// list of entries a copy could take. No credential travels here — the key is
|
|
134
|
+
// read by the request that writes.
|
|
135
|
+
const providerSupportByHarness: Record<string, HarnessProviderSupport> = {};
|
|
136
|
+
for (const id of HARNESS_IDS) {
|
|
137
|
+
const facts = providerFacts(id);
|
|
138
|
+
const level = providerLevel(id);
|
|
139
|
+
if (level === 'none') continue;
|
|
140
|
+
// CUSTOM providers only, and each row names the protocol its SOURCE declares.
|
|
141
|
+
// Whether it can land in THIS harness is not guessed here: it depends on what
|
|
142
|
+
// the endpoint answers, which the import measures at write time. The card
|
|
143
|
+
// states the target's own list once and lets the route refuse by name.
|
|
144
|
+
const targetProtocols = supportedProtocols(facts.registry.kind, facts.envProtocol);
|
|
145
|
+
const importable = await importableProvidersFor(id);
|
|
146
|
+
// The harness's OWN custom providers, so the card lists what is already
|
|
147
|
+
// there: without it an "Add provider" that worked and a form that silently
|
|
148
|
+
// wrote nothing looked identical.
|
|
149
|
+
const configured = await readRegistryProviders(id);
|
|
150
|
+
providerSupportByHarness[id] = {
|
|
151
|
+
level,
|
|
152
|
+
file: facts.registry.file ?? '',
|
|
153
|
+
fileLabel: registryLabel(id),
|
|
154
|
+
summary: facts.summary,
|
|
155
|
+
createsChoice: facts.createsChoice,
|
|
156
|
+
pointer: facts.registry.pointer,
|
|
157
|
+
credentialLabel: credentialFieldLabel(id),
|
|
158
|
+
...(facts.env ? { env: facts.env } : {}),
|
|
159
|
+
...(facts.envProtocol ? { envProtocol: facts.envProtocol } : {}),
|
|
160
|
+
protocols: targetProtocols,
|
|
161
|
+
importable,
|
|
162
|
+
configured,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return json({ harnesses: await listHarnesses(), configs, providerSupport: providerSupportByHarness });
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export async function action({ request, params }: ActionFunctionArgs) {
|
|
170
|
+
if (request.method !== 'POST') return methodNotAllowed({ request, params });
|
|
171
|
+
// The body is UNTRUSTED and every branch below reads a different field, so it
|
|
172
|
+
// is narrowed to a record ONCE. `record` is a real runtime check, not a cast:
|
|
173
|
+
// a request that is not a JSON object falls through to the probe validation
|
|
174
|
+
// and is refused there, which is the same answer it got before.
|
|
175
|
+
const parsed: unknown = await request.json().catch(() => null);
|
|
176
|
+
const body: Record<string, unknown> =
|
|
177
|
+
parsed && typeof parsed === 'object' && !Array.isArray(parsed)
|
|
178
|
+
? (parsed as Record<string, unknown>)
|
|
179
|
+
: {};
|
|
180
|
+
const id = typeof body.probe === 'string' ? body.probe : null;
|
|
181
|
+
if (!id || !HARNESS_IDS.includes(id as HarnessId)) {
|
|
182
|
+
return json({ error: 'probe must name a known harness id' }, { status: 400 });
|
|
183
|
+
}
|
|
184
|
+
// A TOGGLE: `{ probe: id, enabled: boolean }`.
|
|
185
|
+
//
|
|
186
|
+
// The roster, not the probe: this is the one write that decides whether the
|
|
187
|
+
// harness appears in Settings and in the composer's picker at all. It sits
|
|
188
|
+
// BEFORE the built-in refusal because that refusal talks about probing, which
|
|
189
|
+
// is not what this request is doing — the built-in transport has its own
|
|
190
|
+
// answer below ("cannot be switched off").
|
|
191
|
+
//
|
|
192
|
+
// **Switching on is a ROSTER decision and always succeeds**, including for an
|
|
193
|
+
// agent that is not installed: the user may want the tab there now and install
|
|
194
|
+
// the binary afterwards, and refusing would make the switch look broken. The
|
|
195
|
+
// probe is therefore a BONUS, attempted only for a launchable harness and never
|
|
196
|
+
// able to fail the request — see below.
|
|
197
|
+
if (typeof body.enabled === 'boolean') {
|
|
198
|
+
const enabled = body.enabled;
|
|
199
|
+
try {
|
|
200
|
+
const disabled = await saveHarnessEnabled(id, enabled);
|
|
201
|
+
// Turning a harness ON probes it once so the composer has its models right
|
|
202
|
+
// away. Two guards, both measured concerns:
|
|
203
|
+
//
|
|
204
|
+
// - a harness whose binary is not on PATH is NOT probed: spawning it can
|
|
205
|
+
// only fail, and the card already says "not installed" with the install
|
|
206
|
+
// line. Nothing is learned and an agent process is started for nothing.
|
|
207
|
+
// - a probe that fails for any OTHER reason (no login, a timeout, a broken
|
|
208
|
+
// adapter) must not undo the switch. The roster write already happened,
|
|
209
|
+
// and the card explains the refusal; reporting a 400 here would leave the
|
|
210
|
+
// UI showing the previous value for a state the database holds.
|
|
211
|
+
let probe: HarnessProbe | null = null;
|
|
212
|
+
if (enabled && commandAvailable(id as HarnessId, await loadHarnessConfig(id as HarnessId))) {
|
|
213
|
+
const cwd = typeof body.cwd === 'string' ? body.cwd : process.cwd();
|
|
214
|
+
probe = await probeWithConfig(id as HarnessId, cwd).catch(() => null);
|
|
215
|
+
if (probe) await rememberProbe(id as HarnessId, probe);
|
|
216
|
+
}
|
|
217
|
+
return json({
|
|
218
|
+
enabled,
|
|
219
|
+
disabled,
|
|
220
|
+
// The switch is what this request means; `probed` says whether the bonus
|
|
221
|
+
// ran, so the UI can tell "on, not checked" from "on, and here is its
|
|
222
|
+
// answer" without inferring it from an absent probe.
|
|
223
|
+
probed: probe !== null,
|
|
224
|
+
...(probe ? { probe } : {}),
|
|
225
|
+
});
|
|
226
|
+
} catch (cause) {
|
|
227
|
+
return json(
|
|
228
|
+
{ error: cause instanceof Error ? cause.message : 'Could not switch this harness' },
|
|
229
|
+
{ status: 400 },
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
// Same refusal as the loader: no agent exists behind a built-in transport, so
|
|
234
|
+
// its "probe" would only cache a `blocked` record over the default tab.
|
|
235
|
+
if (harnessDescriptor(id)?.builtIn) {
|
|
236
|
+
return json({ error: `${id} is built in and has no agent to probe`, code: 'builtin_not_probeable' }, { status: 400 });
|
|
237
|
+
}
|
|
238
|
+
// An IMPORT: copy one provider out of another registry into this harness's.
|
|
239
|
+
// `{ importProvider: { from, id, env? } }`. The credential is read HERE, from
|
|
240
|
+
// the source file, so the list the browser holds never carries one.
|
|
241
|
+
const importBody = body.importProvider;
|
|
242
|
+
if (isImportBody(importBody)) {
|
|
243
|
+
const requestBody = importBody as Record<string, unknown>;
|
|
244
|
+
const sourceId = typeof requestBody.id === 'string' ? requestBody.id : '';
|
|
245
|
+
if (!sourceId) return json({ error: 'importProvider.id is required' }, { status: 400 });
|
|
246
|
+
const source = importSourceOf(requestBody.from);
|
|
247
|
+
if (!source) {
|
|
248
|
+
return json({ error: `No import source named "${String(requestBody.from)}"`, code: 'unknown_source' }, { status: 400 });
|
|
249
|
+
}
|
|
250
|
+
return importProviderAction(id as HarnessId, source, sourceId, requestBody.entry);
|
|
251
|
+
}
|
|
252
|
+
// AN ADD: the same landing path, with the endpoint typed here instead of
|
|
253
|
+
// copied — `{ addProvider: { name, baseUrl, apiKey, protocol?, models? } }`.
|
|
254
|
+
// Both actions go through `applyProvider`: the probe, the protocol choice, the
|
|
255
|
+
// refusal and the env flattening cannot drift between "copy" and "type".
|
|
256
|
+
const addBody = body.addProvider;
|
|
257
|
+
if (isImportBody(addBody)) {
|
|
258
|
+
return addProviderAction(id as HarnessId, addBody);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// A CONFIG write rides the same route: `{ config: { harness, ...fields } }`.
|
|
262
|
+
// One endpoint for one subject, and the answer carries the saved shape so the
|
|
263
|
+
// card re-renders from what the server actually holds.
|
|
264
|
+
const configBody = body.config;
|
|
265
|
+
if (configBody !== undefined) {
|
|
266
|
+
const saved = parseHarnessConfig(configBody);
|
|
267
|
+
const previous = await loadHarnessConfig(id as HarnessId);
|
|
268
|
+
await saveHarnessConfig(id as HarnessId, saved);
|
|
269
|
+
const probeInvalidated = probeInvalidatedBy(previous, saved);
|
|
270
|
+
if (probeInvalidated) await forgetProbe(id as HarnessId);
|
|
271
|
+
return json({ config: saved, harness: id, probeInvalidated });
|
|
272
|
+
}
|
|
273
|
+
const probe = await probeWithConfig(
|
|
274
|
+
id as HarnessId,
|
|
275
|
+
typeof body.cwd === 'string' ? body.cwd : process.cwd(),
|
|
276
|
+
);
|
|
277
|
+
await rememberProbe(id as HarnessId, probe);
|
|
278
|
+
return json({ probe });
|
|
279
|
+
}
|
|
280
|
+
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Switching a harness on, through the route the UI calls.
|
|
8
|
+
*
|
|
9
|
+
* The user's correction, as an assertion: **enable must work for an agent that is
|
|
10
|
+
* not installed.** The switch is a roster decision — the user may want the tab
|
|
11
|
+
* present before they install the binary — so a missing executable must not
|
|
12
|
+
* refuse it, and must not spawn anything either. Spawning a binary that is not
|
|
13
|
+
* there produces an error report in place of a switch, which is exactly the
|
|
14
|
+
* "enable failed" the user saw.
|
|
15
|
+
*
|
|
16
|
+
* So the cases below hold two facts:
|
|
17
|
+
*
|
|
18
|
+
* - the roster write succeeds and is reported, installed or not;
|
|
19
|
+
* - no probe was attempted when the binary is absent.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import { afterAll, afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
23
|
+
import { mkdtempSync, rmSync } from 'node:fs';
|
|
24
|
+
import { tmpdir } from 'node:os';
|
|
25
|
+
import { join } from 'node:path';
|
|
26
|
+
import { isolateDb, releaseDb } from '@/test-support/isolated-db';
|
|
27
|
+
import { probes } from '@/server/lib/harness/probe-cache.server';
|
|
28
|
+
import { loadDisabledHarnesses } from '@/server/lib/harness/enabled.server';
|
|
29
|
+
import { action } from '@/server/routes/harness/root';
|
|
30
|
+
|
|
31
|
+
type Handler = (args: never) => unknown;
|
|
32
|
+
|
|
33
|
+
function call(request: Request): Promise<Response> {
|
|
34
|
+
return (action as Handler)({ request, params: {} } as never) as Promise<Response>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function toggle(id: string, enabled: boolean): Request {
|
|
38
|
+
return new Request('http://localhost/api/harness', {
|
|
39
|
+
method: 'POST',
|
|
40
|
+
body: JSON.stringify({ probe: id, enabled }),
|
|
41
|
+
headers: { 'content-type': 'application/json' },
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The probe below is REAL: when `omp` is installed, enabling `omp-acp` spawns
|
|
47
|
+
* `omp acp`, and that child writes a session file into the agent directory it
|
|
48
|
+
* resolves — `~/.omp/agent/sessions/-projects-kabmo/` when this suite runs from
|
|
49
|
+
* the repo. The file has no title, so Kabmo's sidebar draws it as
|
|
50
|
+
* `New Session - <timestamp>`: every `bun test` left one more row behind in the
|
|
51
|
+
* developer's own install (observed at 11:47 and 11:50, matching this suite's
|
|
52
|
+
* `acp` spawns in the process table). Point the child's agent dir at a throwaway
|
|
53
|
+
* tree so the probe still measures the real binary without touching real state.
|
|
54
|
+
*/
|
|
55
|
+
const AGENT_DIR = mkdtempSync(join(tmpdir(), 'kabmo-toggle-agent-'));
|
|
56
|
+
const savedAgentDir = Bun.env.PI_CODING_AGENT_DIR;
|
|
57
|
+
|
|
58
|
+
beforeEach(async () => {
|
|
59
|
+
Bun.env.PI_CODING_AGENT_DIR = AGENT_DIR;
|
|
60
|
+
await isolateDb();
|
|
61
|
+
probes().clear();
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
afterEach(async () => {
|
|
65
|
+
await releaseDb();
|
|
66
|
+
probes().clear();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
afterAll(async () => {
|
|
70
|
+
await releaseDb();
|
|
71
|
+
if (savedAgentDir === undefined) delete Bun.env.PI_CODING_AGENT_DIR;
|
|
72
|
+
else Bun.env.PI_CODING_AGENT_DIR = savedAgentDir;
|
|
73
|
+
rmSync(AGENT_DIR, { recursive: true, force: true });
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
describe('switching a harness on', () => {
|
|
77
|
+
test('an agent whose binary is NOT installed still switches on', async () => {
|
|
78
|
+
// `cursor` is launched by `cursor-agent`, which this machine does not have —
|
|
79
|
+
// the harness the user tried and watched fail. The switch is about the roster.
|
|
80
|
+
const response = await call(toggle('cursor', true));
|
|
81
|
+
expect(response.status).toBe(200);
|
|
82
|
+
const payload = (await response.json()) as { enabled?: boolean; disabled?: string[]; probed?: boolean };
|
|
83
|
+
expect(payload.enabled).toBe(true);
|
|
84
|
+
// Nothing was spawned, because there is nothing to spawn.
|
|
85
|
+
expect(payload.probed).toBe(false);
|
|
86
|
+
expect(await loadDisabledHarnesses()).toEqual([]);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
test('switching off an uninstalled agent works too', async () => {
|
|
90
|
+
const response = await call(toggle('cursor', false));
|
|
91
|
+
expect(response.status).toBe(200);
|
|
92
|
+
expect(await loadDisabledHarnesses()).toEqual(['cursor']);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test('a launcher that exists is probed, and the answer rides the response', async () => {
|
|
96
|
+
// `omp-acp` is launched by the `omp` binary this machine has, so the bonus
|
|
97
|
+
// probe runs. Its capabilities are the agent's own; the assertion is merely
|
|
98
|
+
// that one was attempted and reported.
|
|
99
|
+
//
|
|
100
|
+
// Guarded, because "exists" is the premise: a clean runner has no `omp`, so
|
|
101
|
+
// `probed` is legitimately `false` there. Measured on both CI gates, where
|
|
102
|
+
// this case alone failed with `Expected: true, Received: false` while the
|
|
103
|
+
// same file passed locally — the enable half of the contract still runs.
|
|
104
|
+
const response = await call(toggle('omp-acp', true));
|
|
105
|
+
expect(response.status).toBe(200);
|
|
106
|
+
const payload = (await response.json()) as { enabled?: boolean; probed?: boolean };
|
|
107
|
+
// The roster half always holds: enabling works whether or not the binary is
|
|
108
|
+
// here, which is the user's correction this suite exists for.
|
|
109
|
+
expect(payload.enabled).toBe(true);
|
|
110
|
+
// The probe half is conditional on the machine, so what is asserted is the
|
|
111
|
+
// CONTRACT between the flag and the cache rather than the flag's value: a
|
|
112
|
+
// reported probe left a record, a skipped one left none.
|
|
113
|
+
expect(payload.probed).toBe(probes().has('omp-acp'));
|
|
114
|
+
}, 120_000);
|
|
115
|
+
|
|
116
|
+
test('the built-in transport is still refused, and leaves the roster alone', async () => {
|
|
117
|
+
const response = await call(toggle('omp-rpc', false));
|
|
118
|
+
expect(response.status).toBe(400);
|
|
119
|
+
expect(await loadDisabledHarnesses()).toEqual([]);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
test('an unknown harness id is refused', async () => {
|
|
123
|
+
const response = await call(toggle('not-an-agent', true));
|
|
124
|
+
expect(response.status).toBe(400);
|
|
125
|
+
expect(await loadDisabledHarnesses()).toEqual([]);
|
|
126
|
+
});
|
|
127
|
+
});
|