@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,216 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Launch lines for every ACP harness, and the probe that reads their
|
|
8
|
+
* capabilities.
|
|
9
|
+
*
|
|
10
|
+
* A launch line is DATA (a command vector), because a harness is added by the
|
|
11
|
+
* settings page or by `@agentclientprotocol/registry` without touching code. The
|
|
12
|
+
* vectors below were each run on this machine and answered `initialize`; the
|
|
13
|
+
* comment names what that run measured.
|
|
14
|
+
*
|
|
15
|
+
* A probe spawns ONE agent, creates ONE session, reads `configOptions` and the
|
|
16
|
+
* capability flags, then disposes. That is deliberately not done for all
|
|
17
|
+
* harnesses at once: seven agents cost ~6 s and seven processes, which is why
|
|
18
|
+
* the sidebar reads Kabmo's own index and this runs on an explicit action.
|
|
19
|
+
*
|
|
20
|
+
* The launch TABLE itself lives in `launch-table.ts` so this module is the probe
|
|
21
|
+
* and the session argv, both under the file ceiling.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import { AcpProcess } from '@/server/lib/harness/acp/client';
|
|
25
|
+
import { newSessionAfterActivation } from '@/server/lib/harness/acp/activation';
|
|
26
|
+
import type { AcpConfigOption, AcpInitializeResult } from '@/server/lib/harness/acp/protocol';
|
|
27
|
+
import { acpOptionValues } from '@/server/lib/harness/acp/protocol';
|
|
28
|
+
import { UNPROBED_CAPABILITIES, type HarnessCapabilities, type HarnessProbe } from '@/server/lib/harness/capabilities';
|
|
29
|
+
import { HARNESS_LAUNCH, type HarnessLaunch } from '@/server/lib/harness/launch-table';
|
|
30
|
+
import { kabmoExtensionArgs } from '@/server/lib/omp/extensions/locator';
|
|
31
|
+
import type { HarnessId } from '@/shared/lib/harness/catalog';
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The argv a SESSION spawns with, as opposed to the one a probe runs.
|
|
35
|
+
*
|
|
36
|
+
* `omp-acp` is omp itself over the Agent Client Protocol, so it gets the same
|
|
37
|
+
* mode extension the `--mode rpc-ui` child gets. Kabmo's plan/goal controls are
|
|
38
|
+
* extension commands (`/kabmo-mode …`), and omp's ACP path dispatches extension
|
|
39
|
+
* commands locally inside `session.prompt()` — without `-e` the command is just
|
|
40
|
+
* a string, so the client's republish on attach reached the MODEL as a prompt
|
|
41
|
+
* and started a turn on an `omp (ACP)` chat.
|
|
42
|
+
*
|
|
43
|
+
* Every other ACP agent is a different program with no `-e` flag, so its
|
|
44
|
+
* vector passes through untouched. A pruned install resolves no extension at
|
|
45
|
+
* all and also passes through (see `kabmoExtensionArgs`).
|
|
46
|
+
*/
|
|
47
|
+
export function sessionLaunchCommand(id: HarnessId, command: readonly string[]): string[] {
|
|
48
|
+
return id === 'omp-acp' ? [...command, ...kabmoExtensionArgs()] : [...command];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Which config category a `configOptions` entry belongs to. */
|
|
52
|
+
export function configByCategory(options: AcpConfigOption[], category: string): AcpConfigOption | undefined {
|
|
53
|
+
return options.find((option) => option.category === category);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Read one `session/new` result into the capability record every panel gates on. */
|
|
57
|
+
export function capabilitiesFrom(
|
|
58
|
+
init: AcpInitializeResult,
|
|
59
|
+
configOptions: AcpConfigOption[] | undefined,
|
|
60
|
+
observed: { usage: boolean; plan: boolean },
|
|
61
|
+
): HarnessCapabilities {
|
|
62
|
+
const caps = init.agentCapabilities ?? {};
|
|
63
|
+
const sessionCaps = caps.sessionCapabilities ?? {};
|
|
64
|
+
const model = configByCategory(configOptions ?? [], 'model');
|
|
65
|
+
const thinking = configByCategory(configOptions ?? [], 'thought_level');
|
|
66
|
+
const mode = configByCategory(configOptions ?? [], 'mode');
|
|
67
|
+
// omp advertises steering at the RESULT root (`_meta.steering`), a sibling of
|
|
68
|
+
// `agentCapabilities` — measured on 18.16.0. Reading it from inside
|
|
69
|
+
// `agentCapabilities` found nothing, so the capability record said "no
|
|
70
|
+
// steering" for the one agent that has an extension for it.
|
|
71
|
+
const steering = init._meta?.steering ?? caps._meta?.steering;
|
|
72
|
+
const steeringSupported = Boolean(
|
|
73
|
+
steering && typeof steering === 'object' && 'supported' in steering && steering.supported === true,
|
|
74
|
+
);
|
|
75
|
+
return {
|
|
76
|
+
...UNPROBED_CAPABILITIES,
|
|
77
|
+
configModel: model ? acpOptionValues(model).length : 0,
|
|
78
|
+
configThinking: thinking ? acpOptionValues(thinking).length : 0,
|
|
79
|
+
configMode: mode ? acpOptionValues(mode).length : 0,
|
|
80
|
+
modeValues: mode ? acpOptionValues(mode) : [],
|
|
81
|
+
loadSession: caps.loadSession === true,
|
|
82
|
+
listSessions: 'list' in sessionCaps,
|
|
83
|
+
forkSession: 'fork' in sessionCaps,
|
|
84
|
+
deleteSession: 'delete' in sessionCaps,
|
|
85
|
+
resumeSession: 'resume' in sessionCaps,
|
|
86
|
+
closeSession: 'close' in sessionCaps,
|
|
87
|
+
hasUsage: observed.usage,
|
|
88
|
+
hasPlan: observed.plan,
|
|
89
|
+
steerMode: steeringSupported ? 'steer' : null,
|
|
90
|
+
...(init.agentInfo?.name ? { agentName: init.agentInfo.name } : {}),
|
|
91
|
+
...(init.agentInfo?.version ? { agentVersion: init.agentInfo.version } : {}),
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Select values with their display names, for the composer's pickers. */
|
|
96
|
+
export function selectValues(option: AcpConfigOption | undefined): { value: string; name: string }[] {
|
|
97
|
+
if (!option?.options) return [];
|
|
98
|
+
const out: { value: string; name: string }[] = [];
|
|
99
|
+
for (const entry of option.options) {
|
|
100
|
+
if ('value' in entry) {
|
|
101
|
+
out.push({ value: entry.value, name: entry.name ?? entry.value });
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
for (const nested of entry.options) out.push({ value: nested.value, name: nested.name ?? nested.value });
|
|
105
|
+
}
|
|
106
|
+
return out;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Probe one harness: one agent, one session, then dispose.
|
|
111
|
+
*
|
|
112
|
+
* Errors are reported as `blocked` instead of thrown, because "this harness
|
|
113
|
+
* cannot run here" is the normal state the settings page and the tab strip both
|
|
114
|
+
* have to render — and the agent's own words are the only useful explanation
|
|
115
|
+
* (`Authentication required`, `executable not found (command: pi)`).
|
|
116
|
+
*
|
|
117
|
+
* `launchOverride` is the USER's launch line (command + env), so the probe
|
|
118
|
+
* measures what a spawn would actually start. Without it a harness that only
|
|
119
|
+
* works with a configured env — `CODEX_HOME`, a provider base URL — read as
|
|
120
|
+
* "Authentication required" in Settings while its chats ran fine.
|
|
121
|
+
*/
|
|
122
|
+
export async function probeHarness(
|
|
123
|
+
id: HarnessId,
|
|
124
|
+
cwd: string,
|
|
125
|
+
launchOverride?: HarnessLaunch,
|
|
126
|
+
): Promise<HarnessProbe> {
|
|
127
|
+
const launch = launchOverride ?? HARNESS_LAUNCH[id];
|
|
128
|
+
if (!launch) {
|
|
129
|
+
return blockedProbe(id, 'No launch command is configured for this harness');
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const observed = { usage: false, plan: false };
|
|
133
|
+
/** The agent's own last words. A probe that fails usually fails with a reason
|
|
134
|
+
* the transport never prints (a corrupt plugin, a missing login, a wrapper
|
|
135
|
+
* that exits): without this tail the card can only say "exited (code 1)". */
|
|
136
|
+
let stderrTail = '';
|
|
137
|
+
// Constructed INSIDE the guarded block: a binary that is not on PATH makes the
|
|
138
|
+
// constructor throw, and a throw here answered the probe route with a 500
|
|
139
|
+
// instead of the `blocked` record the settings card renders. "This harness
|
|
140
|
+
// cannot run here" is the normal state that card exists to show.
|
|
141
|
+
let proc: AcpProcess | null = null;
|
|
142
|
+
/** `agentInfo` from a handshake that succeeded before a later step failed. */
|
|
143
|
+
let agent: AcpInitializeResult['agentInfo'] | undefined;
|
|
144
|
+
|
|
145
|
+
try {
|
|
146
|
+
const agentProcess = new AcpProcess({
|
|
147
|
+
command: launch.command,
|
|
148
|
+
cwd,
|
|
149
|
+
...(launch.env ? { env: launch.env } : {}),
|
|
150
|
+
onStderr: (line) => {
|
|
151
|
+
stderrTail = `${stderrTail}${line}\n`.slice(-2_000);
|
|
152
|
+
},
|
|
153
|
+
onExit: (info) => {
|
|
154
|
+
stderrTail = info.stderrTail;
|
|
155
|
+
},
|
|
156
|
+
onNotification: (_method, params) => {
|
|
157
|
+
const update = params.update;
|
|
158
|
+
if (!update || typeof update !== 'object') return;
|
|
159
|
+
if (!('sessionUpdate' in update)) return;
|
|
160
|
+
if (update.sessionUpdate === 'usage_update') observed.usage = true;
|
|
161
|
+
if (update.sessionUpdate === 'plan') observed.plan = true;
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
proc = agentProcess;
|
|
165
|
+
const init = await agentProcess.initialize();
|
|
166
|
+
// Kept for the failure path below: an agent that answers `initialize` and
|
|
167
|
+
// then refuses `session/new` ("Authentication required") still told us who
|
|
168
|
+
// it is, and the card can name it beside the refusal.
|
|
169
|
+
agent = init.agentInfo;
|
|
170
|
+
// opencode gates `session/new` on its own plugin activation; a probe that
|
|
171
|
+
// read the five-second refusal as final reported a booting agent as blocked.
|
|
172
|
+
const session = await newSessionAfterActivation(id, cwd, (dir, timeoutMs) =>
|
|
173
|
+
agentProcess.newSession(dir, timeoutMs),
|
|
174
|
+
);
|
|
175
|
+
const options = session.configOptions ?? [];
|
|
176
|
+
return {
|
|
177
|
+
harness: id,
|
|
178
|
+
capabilities: capabilitiesFrom(init, options, observed),
|
|
179
|
+
models: selectValues(configByCategory(options, 'model')),
|
|
180
|
+
thinking: selectValues(configByCategory(options, 'thought_level')),
|
|
181
|
+
modes: selectValues(configByCategory(options, 'mode')),
|
|
182
|
+
probedAt: Date.now(),
|
|
183
|
+
};
|
|
184
|
+
} catch (error) {
|
|
185
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
186
|
+
// The agent's own last lines, when it left any: `exited (code 1)` tells a
|
|
187
|
+
// reader nothing, while the stderr tail names the corrupt plugin or the
|
|
188
|
+
// refused login that caused it.
|
|
189
|
+
const lastLines = stderrTail.trim().split('\n').slice(-3).join(' · ');
|
|
190
|
+
return blockedProbe(id, lastLines ? `${reason} — ${lastLines}` : reason, agent);
|
|
191
|
+
} finally {
|
|
192
|
+
await proc?.dispose(1_000).catch(() => {});
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** One `blocked` probe record. The route uses it when the launch line itself is
|
|
197
|
+
* unusable (an invalid env line) — the same shape every other refusal has. */
|
|
198
|
+
export function blockedProbe(
|
|
199
|
+
id: HarnessId,
|
|
200
|
+
reason: string,
|
|
201
|
+
agent?: AcpInitializeResult['agentInfo'],
|
|
202
|
+
): HarnessProbe {
|
|
203
|
+
return {
|
|
204
|
+
harness: id,
|
|
205
|
+
capabilities: {
|
|
206
|
+
...UNPROBED_CAPABILITIES,
|
|
207
|
+
...(agent?.name ? { agentName: agent.name } : {}),
|
|
208
|
+
...(agent?.version ? { agentVersion: agent.version } : {}),
|
|
209
|
+
blocked: reason,
|
|
210
|
+
},
|
|
211
|
+
models: [],
|
|
212
|
+
thinking: [],
|
|
213
|
+
modes: [],
|
|
214
|
+
probedAt: Date.now(),
|
|
215
|
+
};
|
|
216
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A probe must SURVIVE A RESTART.
|
|
8
|
+
*
|
|
9
|
+
* The bug this pins, reported by a user and reproducible in one step: press
|
|
10
|
+
* **Check status** on a harness, watch it turn `ready`, restart Kabmo (or let
|
|
11
|
+
* `bun --hot` reload during development), open Settings again — `not probed`.
|
|
12
|
+
*
|
|
13
|
+
* The cause was that the cache was process-scoped: a `Map` on `globalThis` and
|
|
14
|
+
* nothing else. A probe is a fact about the INSTALLED BINARY, not about the
|
|
15
|
+
* process that asked, so the record now lives in `harness_probes` and memory is
|
|
16
|
+
* only the fast layer in front of it.
|
|
17
|
+
*
|
|
18
|
+
* The cases here EMPTY the memory map to simulate a restart — that is the whole
|
|
19
|
+
* difference, so clearing it is what the assertions turn on.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import { afterAll, afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
23
|
+
import { isolateDb, releaseDb } from '@/test-support/isolated-db';
|
|
24
|
+
import type { HarnessProbe } from '@/server/lib/harness/capabilities';
|
|
25
|
+
import {
|
|
26
|
+
forgetProbe,
|
|
27
|
+
freshProbe,
|
|
28
|
+
harnessProbeModels,
|
|
29
|
+
loadProbes,
|
|
30
|
+
PROBE_TTL_MS,
|
|
31
|
+
probes,
|
|
32
|
+
rememberProbe,
|
|
33
|
+
} from '@/server/lib/harness/probe-cache.server';
|
|
34
|
+
|
|
35
|
+
beforeEach(async () => {
|
|
36
|
+
await isolateDb();
|
|
37
|
+
probes().clear();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
afterEach(async () => {
|
|
41
|
+
await releaseDb();
|
|
42
|
+
probes().clear();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
afterAll(async () => {
|
|
46
|
+
await releaseDb();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
function probe(overrides: Partial<HarnessProbe> = {}): HarnessProbe {
|
|
50
|
+
return {
|
|
51
|
+
harness: 'claude',
|
|
52
|
+
capabilities: {
|
|
53
|
+
configModel: 5, configThinking: 6, configMode: 5, modeValues: ['plan'],
|
|
54
|
+
loadSession: true, listSessions: true, forkSession: true, deleteSession: false,
|
|
55
|
+
resumeSession: true, closeSession: true, hasUsage: false, hasPlan: false, steerMode: null,
|
|
56
|
+
agentVersion: '0.100.0',
|
|
57
|
+
},
|
|
58
|
+
models: [{ value: 'opus', name: 'Opus' }, { value: 'sonnet', name: 'Sonnet' }],
|
|
59
|
+
thinking: [], modes: [], probedAt: Date.now(),
|
|
60
|
+
...overrides,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** The only thing a restart changes: the in-memory layer. */
|
|
65
|
+
function simulateRestart(): void {
|
|
66
|
+
probes().clear();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
describe('a probe survives a restart', () => {
|
|
70
|
+
test('a remembered probe is still there after the memory cache is emptied', async () => {
|
|
71
|
+
await rememberProbe('claude', probe());
|
|
72
|
+
expect((await freshProbe('claude'))?.capabilities.configModel).toBe(5);
|
|
73
|
+
|
|
74
|
+
simulateRestart();
|
|
75
|
+
const after = await freshProbe('claude');
|
|
76
|
+
expect(after?.capabilities.configModel).toBe(5);
|
|
77
|
+
expect(after?.capabilities.agentVersion).toBe('0.100.0');
|
|
78
|
+
expect(after?.models.map((model) => model.value)).toEqual(['opus', 'sonnet']);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
test('the whole catalog is read back in ONE call', async () => {
|
|
82
|
+
await rememberProbe('claude', probe());
|
|
83
|
+
await rememberProbe('codex', probe({ harness: 'codex', models: [{ value: 'gpt', name: 'GPT' }] }));
|
|
84
|
+
simulateRestart();
|
|
85
|
+
|
|
86
|
+
const all = await loadProbes();
|
|
87
|
+
expect([...all.keys()].sort()).toEqual(['claude', 'codex']);
|
|
88
|
+
expect(all.get('codex')?.models[0].value).toBe('gpt');
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test('a spawn resolves its configured default model from the stored probe', async () => {
|
|
92
|
+
// The other half of the bug: the spawn used to read an empty memory map after
|
|
93
|
+
// a restart, so a harness's configured default model silently fell through to
|
|
94
|
+
// the agent's own preference.
|
|
95
|
+
await rememberProbe('claude', probe());
|
|
96
|
+
simulateRestart();
|
|
97
|
+
expect(await harnessProbeModels('claude')).toHaveLength(2);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test('forgetting removes it from disk, so a changed launch line cannot reuse it', async () => {
|
|
101
|
+
await rememberProbe('claude', probe());
|
|
102
|
+
await forgetProbe('claude');
|
|
103
|
+
simulateRestart();
|
|
104
|
+
expect(await freshProbe('claude')).toBeNull();
|
|
105
|
+
expect(await harnessProbeModels('claude')).toEqual([]);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
test('an aged probe is still returned, labelled, never reported as absent', async () => {
|
|
109
|
+
// The reported bug, one route round: probe a harness, come back later, and
|
|
110
|
+
// the card said `not probed` while the row was still on disk. Measured on a
|
|
111
|
+
// cold process against the real database — `omp-acp` (17 min) answered and
|
|
112
|
+
// `claude` (61 min) read as absent.
|
|
113
|
+
await rememberProbe('claude', probe({ probedAt: Date.now() - PROBE_TTL_MS - 1 }));
|
|
114
|
+
simulateRestart();
|
|
115
|
+
|
|
116
|
+
const aged = await freshProbe('claude');
|
|
117
|
+
expect(aged).not.toBeNull();
|
|
118
|
+
expect(aged?.stale).toBe(true);
|
|
119
|
+
expect(aged?.capabilities.agentVersion).toBe('0.100.0');
|
|
120
|
+
expect((await loadProbes()).has('claude')).toBe(true);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
test('a current probe carries no stale flag', async () => {
|
|
124
|
+
await rememberProbe('claude', probe());
|
|
125
|
+
simulateRestart();
|
|
126
|
+
expect((await freshProbe('claude'))?.stale).toBeUndefined();
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
test('an aged probe is NOT used to choose a spawn model', async () => {
|
|
130
|
+
// Showing an old answer on a card is honest; ACTING on one is not — a model
|
|
131
|
+
// the agent dropped in the meantime would fail at the first prompt.
|
|
132
|
+
await rememberProbe('claude', probe({ probedAt: Date.now() - PROBE_TTL_MS - 1 }));
|
|
133
|
+
simulateRestart();
|
|
134
|
+
expect(await harnessProbeModels('claude')).toEqual([]);
|
|
135
|
+
// And the record is still there for the card to draw.
|
|
136
|
+
expect(await freshProbe('claude')).not.toBeNull();
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
test('re-probing REPLACES the row rather than piling up', async () => {
|
|
140
|
+
await rememberProbe('claude', probe());
|
|
141
|
+
await rememberProbe('claude', probe({ models: [{ value: 'haiku', name: 'Haiku' }] }));
|
|
142
|
+
simulateRestart();
|
|
143
|
+
|
|
144
|
+
expect((await harnessProbeModels('claude')).map((model) => model.value)).toEqual(['haiku']);
|
|
145
|
+
expect((await loadProbes()).size).toBe(1);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
test('a harness never probed stays absent, not empty-but-present', async () => {
|
|
149
|
+
await rememberProbe('claude', probe());
|
|
150
|
+
simulateRestart();
|
|
151
|
+
expect(await freshProbe('cursor')).toBeNull();
|
|
152
|
+
expect((await loadProbes()).has('cursor')).toBe(false);
|
|
153
|
+
});
|
|
154
|
+
});
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The probe cache: what each agent reported, kept for the process AND for disk.
|
|
8
|
+
*
|
|
9
|
+
* Two callers need the answer: the settings page's "Check status", and the SPAWN,
|
|
10
|
+
* which resolves a harness's configured default model against the models that
|
|
11
|
+
* agent actually published. Reading the cache from `routes/harness/root.ts` would
|
|
12
|
+
* have made the spawn import a route, so it lives here.
|
|
13
|
+
*
|
|
14
|
+
* **Memory alone was the bug.** The map was process-scoped, so every restart —
|
|
15
|
+
* including a `bun --hot` reload, which is every edit during development —
|
|
16
|
+
* emptied it and every harness fell back to `not probed` while the user was
|
|
17
|
+
* looking at a card that had said `ready` a minute earlier. A probe is a fact
|
|
18
|
+
* about the INSTALLED BINARY, not about this process, so it is now written to
|
|
19
|
+
* `harness_probes` and read back on the first miss. The memory map stays in front
|
|
20
|
+
* of it: the settings page and the composer's tab strip both ask on every mount,
|
|
21
|
+
* and a database round trip per row would be the cost this cache exists to avoid.
|
|
22
|
+
*
|
|
23
|
+
* **`probedAt` ages a probe; it must not DELETE it.** A row older than
|
|
24
|
+
* `PROBE_TTL_MS` used to be read as absent, which reproduced the reported bug by
|
|
25
|
+
* another route: probe a harness, come back an hour later (or restart the app),
|
|
26
|
+
* and the card said `not probed` while `harness_probes` still held the answer.
|
|
27
|
+
* Measured on a cold process against this database: `omp-acp` (17 min old)
|
|
28
|
+
* answered, `claude` (61 min old) read as absent. So a stored record is now
|
|
29
|
+
* always returned and carries `stale: true` once it is past the TTL, and the
|
|
30
|
+
* card says when it was last checked instead of forgetting it. The real
|
|
31
|
+
* invalidators are the ones that change what was measured: a launch line or env
|
|
32
|
+
* edit (`forgetProbe` from `probeInvalidatedBy`) and an install (`update.ts`).
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
import { getDb } from '@/server/db.server';
|
|
36
|
+
import type { HarnessProbe } from '@/server/lib/harness/capabilities';
|
|
37
|
+
import type { HarnessId } from '@/shared/lib/harness/catalog';
|
|
38
|
+
|
|
39
|
+
declare global {
|
|
40
|
+
// eslint-disable-next-line no-var
|
|
41
|
+
var __kabmoHarnessProbes: Map<string, HarnessProbe> | undefined;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** How long a probe is reported as CURRENT. Past it the record is still
|
|
45
|
+
* returned — see the header — and only flagged, never discarded. */
|
|
46
|
+
export const PROBE_TTL_MS = 30 * 60_000;
|
|
47
|
+
|
|
48
|
+
export function probes(): Map<string, HarnessProbe> {
|
|
49
|
+
globalThis.__kabmoHarnessProbes ??= new Map();
|
|
50
|
+
return globalThis.__kabmoHarnessProbes;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** True when the record is young enough to be reported without an age. */
|
|
54
|
+
export function isFresh(probe: HarnessProbe): boolean {
|
|
55
|
+
return Date.now() - probe.probedAt < PROBE_TTL_MS;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** The probe as the wire reports it: the record plus whether it has aged past
|
|
59
|
+
* the TTL. `stale` is a LABEL, not a filter — the card shows the answer with
|
|
60
|
+
* its age instead of pretending the harness was never asked. */
|
|
61
|
+
export type StoredProbe = HarnessProbe & { stale?: true };
|
|
62
|
+
|
|
63
|
+
/** Attach the ageing label to a live record. */
|
|
64
|
+
function labelled(probe: HarnessProbe): StoredProbe {
|
|
65
|
+
return isFresh(probe) ? probe : { ...probe, stale: true };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Store a probe in memory and on disk.
|
|
70
|
+
*
|
|
71
|
+
* The write is awaited by the routes that call it: a probe the user just
|
|
72
|
+
* triggered must survive a reload of the page — and of the server — or the button
|
|
73
|
+
* reports success while the next read disagrees.
|
|
74
|
+
*/
|
|
75
|
+
export async function rememberProbe(id: HarnessId, probe: HarnessProbe): Promise<void> {
|
|
76
|
+
probes().set(id, probe);
|
|
77
|
+
try {
|
|
78
|
+
const db = await getDb();
|
|
79
|
+
await db.run(
|
|
80
|
+
`INSERT INTO harness_probes (harness, payload, probed_at) VALUES (?, ?, ?)
|
|
81
|
+
ON CONFLICT(harness) DO UPDATE SET payload = excluded.payload, probed_at = excluded.probed_at`,
|
|
82
|
+
[id, JSON.stringify(probe), probe.probedAt],
|
|
83
|
+
);
|
|
84
|
+
} catch {
|
|
85
|
+
// no-excuse-ok: catch — the probe still answers THIS process from memory; a
|
|
86
|
+
// database that cannot take the row must not fail the user's Check status.
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Forget a probe in memory and on disk (a launch line or env changed, so what
|
|
91
|
+
* the last probe measured no longer describes this harness). */
|
|
92
|
+
export async function forgetProbe(id: HarnessId): Promise<void> {
|
|
93
|
+
probes().delete(id);
|
|
94
|
+
try {
|
|
95
|
+
const db = await getDb();
|
|
96
|
+
await db.run('DELETE FROM harness_probes WHERE harness = ?', [id]);
|
|
97
|
+
} catch {
|
|
98
|
+
// no-excuse-ok: catch — forgetting from memory is enough for this process.
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** The stored record for a harness, from memory or from disk.
|
|
103
|
+
*
|
|
104
|
+
* An AGED record is returned, never dropped: the user asked for it once, so a
|
|
105
|
+
* card that says `not probed` an hour later is the bug this file exists to
|
|
106
|
+
* fix. `labelled` marks how old it is; `harnessProbeModels` is the strict read
|
|
107
|
+
* that refuses to act on a record past the TTL. */
|
|
108
|
+
async function readProbe(id: HarnessId): Promise<StoredProbe | null> {
|
|
109
|
+
const cached = probes().get(id);
|
|
110
|
+
if (cached) return labelled(cached);
|
|
111
|
+
try {
|
|
112
|
+
const db = await getDb();
|
|
113
|
+
const row = (await db.get('SELECT payload FROM harness_probes WHERE harness = ?', [id])) as
|
|
114
|
+
| { payload?: string }
|
|
115
|
+
| null;
|
|
116
|
+
if (!row?.payload) return null;
|
|
117
|
+
const parsed = JSON.parse(row.payload) as HarnessProbe;
|
|
118
|
+
if (!parsed || typeof parsed.probedAt !== 'number') return null;
|
|
119
|
+
probes().set(id, parsed);
|
|
120
|
+
return labelled(parsed);
|
|
121
|
+
} catch {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Every stored probe, keyed by harness, aged rows included.
|
|
128
|
+
*
|
|
129
|
+
* `listHarnesses` builds the whole catalog in one pass, so it asks for all of
|
|
130
|
+
* them at once rather than one await per row.
|
|
131
|
+
*/
|
|
132
|
+
export async function loadProbes(): Promise<Map<string, StoredProbe>> {
|
|
133
|
+
const out = new Map<string, StoredProbe>();
|
|
134
|
+
try {
|
|
135
|
+
const db = await getDb();
|
|
136
|
+
const rows = (await db.all('SELECT harness, payload FROM harness_probes')) as {
|
|
137
|
+
harness: string;
|
|
138
|
+
payload: string;
|
|
139
|
+
}[];
|
|
140
|
+
for (const row of rows) {
|
|
141
|
+
try {
|
|
142
|
+
const parsed = JSON.parse(row.payload) as HarnessProbe;
|
|
143
|
+
if (!parsed || typeof parsed.probedAt !== 'number') continue;
|
|
144
|
+
out.set(row.harness, labelled(parsed));
|
|
145
|
+
probes().set(row.harness, parsed);
|
|
146
|
+
} catch {
|
|
147
|
+
// A row written by an older build with a different shape: skip it rather
|
|
148
|
+
// than fail the whole catalog.
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
} catch {
|
|
153
|
+
// No database yet: memory is the whole answer for this process.
|
|
154
|
+
}
|
|
155
|
+
// Anything in MEMORY but not yet flushed wins, so a probe in flight is never
|
|
156
|
+
// hidden by a slower disk.
|
|
157
|
+
for (const [id, probe] of probes()) {
|
|
158
|
+
if (!out.has(id)) out.set(id, labelled(probe));
|
|
159
|
+
}
|
|
160
|
+
return out;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** The models a harness published, if its probe is still CURRENT; else none.
|
|
164
|
+
*
|
|
165
|
+
* The strict read, deliberately: a spawn that inherited a model from an aged
|
|
166
|
+
* probe could write a selector the agent no longer offers. Showing an old
|
|
167
|
+
* answer on a card is honest; ACTING on one is not. */
|
|
168
|
+
export async function harnessProbeModels(id: HarnessId): Promise<{ value: string; name: string }[]> {
|
|
169
|
+
const probe = await readProbe(id);
|
|
170
|
+
return probe && !probe.stale ? probe.models : [];
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** The stored probe for a harness, aged or not, or null when it was never
|
|
174
|
+
* recorded. */
|
|
175
|
+
export async function freshProbe(id: HarnessId): Promise<StoredProbe | null> {
|
|
176
|
+
return readProbe(id);
|
|
177
|
+
}
|