@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,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The persisted harness of a session — what the sidebar's mark reads.
|
|
8
|
+
*
|
|
9
|
+
* The bug this pins: EVERY row was reported as `omp-rpc`, because the sidebar
|
|
10
|
+
* filled the field from `DEFAULT_HARNESS_ID` and nothing ever wrote a record. A
|
|
11
|
+
* session run on `opencode2` therefore drew omp's mark beside its name, so the
|
|
12
|
+
* mark said nothing the reader could not already assume.
|
|
13
|
+
*
|
|
14
|
+
* The record has to survive what the live registry cannot: a restart, a closed
|
|
15
|
+
* tab, a second Kabmo instance on the same database. That is why it is a table
|
|
16
|
+
* and why every case here goes through the database rather than the `WeakMap`.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { afterAll, afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
20
|
+
import { isolateDb, releaseDb } from '@/test-support/isolated-db';
|
|
21
|
+
import { getDb } from '@/server/db.server';
|
|
22
|
+
import {
|
|
23
|
+
knownHarness,
|
|
24
|
+
loadAcpSessions,
|
|
25
|
+
loadHarnessBySession,
|
|
26
|
+
loadHarnessSession,
|
|
27
|
+
repointHarnessSession,
|
|
28
|
+
saveHarnessSession,
|
|
29
|
+
saveHarnessSessionTitle,
|
|
30
|
+
saveHarnessSessionTitleIfEmpty,
|
|
31
|
+
} from '@/server/lib/harness/session-store.server';
|
|
32
|
+
import { ensureHarnessSchema } from '@/server/lib/harness/schema.server';
|
|
33
|
+
import { HARNESS_IDS } from '@/shared/lib/harness/catalog';
|
|
34
|
+
|
|
35
|
+
beforeEach(async () => {
|
|
36
|
+
await isolateDb();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
afterEach(async () => {
|
|
40
|
+
await releaseDb();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
afterAll(async () => {
|
|
44
|
+
await releaseDb();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
describe('harness session store', () => {
|
|
48
|
+
test('a saved record is what the sidebar reads back', async () => {
|
|
49
|
+
await saveHarnessSession({
|
|
50
|
+
sessionId: 'sess-acp', harness: 'opencode', agentSessionId: 'agent-42', cwd: '/tmp/project',
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const byId = await loadHarnessBySession();
|
|
54
|
+
expect(byId.get('sess-acp')).toBe('opencode');
|
|
55
|
+
|
|
56
|
+
const one = await loadHarnessSession('sess-acp');
|
|
57
|
+
expect(one?.harness).toBe('opencode');
|
|
58
|
+
// ACP may answer a DIFFERENT id than the one asked for, and resuming has to
|
|
59
|
+
// send the AGENT's id — so it is stored beside ours, not instead of ours.
|
|
60
|
+
expect(one?.agentSessionId).toBe('agent-42');
|
|
61
|
+
expect(one?.cwd).toBe('/tmp/project');
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test('a re-spawn UPDATES the row instead of failing on the primary key', async () => {
|
|
65
|
+
await saveHarnessSession({ sessionId: 'sess-1', harness: 'claude', agentSessionId: '', cwd: '/a' });
|
|
66
|
+
await saveHarnessSession({ sessionId: 'sess-1', harness: 'codex', agentSessionId: 'x', cwd: '/b' });
|
|
67
|
+
|
|
68
|
+
const rows = (await (await getDb()).all('SELECT harness, cwd FROM harness_sessions WHERE session_id = ?', ['sess-1'])) as {
|
|
69
|
+
harness: string; cwd: string;
|
|
70
|
+
}[];
|
|
71
|
+
expect(rows).toHaveLength(1);
|
|
72
|
+
expect(rows[0].harness).toBe('codex');
|
|
73
|
+
expect(rows[0].cwd).toBe('/b');
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test('one read answers EVERY session, not one query per row', async () => {
|
|
77
|
+
// The sidebar assembles hundreds of rows in one pass; a per-row query is the
|
|
78
|
+
// difference between one read and one per session.
|
|
79
|
+
for (const id of ['a', 'b', 'c']) {
|
|
80
|
+
await saveHarnessSession({ sessionId: id, harness: 'omp-rpc', agentSessionId: '', cwd: '/p' });
|
|
81
|
+
}
|
|
82
|
+
const map = await loadHarnessBySession();
|
|
83
|
+
expect([...map.keys()].sort()).toEqual(['a', 'b', 'c']);
|
|
84
|
+
expect(map.get('b')).toBe('omp-rpc');
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test('an unknown session is absent from the map, never guessed', async () => {
|
|
88
|
+
await saveHarnessSession({ sessionId: 'known', harness: 'pi', agentSessionId: '', cwd: '/p' });
|
|
89
|
+
const map = await loadHarnessBySession();
|
|
90
|
+
expect(map.has('never-spawned')).toBe(false);
|
|
91
|
+
expect(await loadHarnessSession('never-spawned')).toBeNull();
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
test('a harness this build does not know is refused, not drawn', async () => {
|
|
95
|
+
// A row written by a newer build (an adapter since removed) would otherwise
|
|
96
|
+
// draw an empty box with no name.
|
|
97
|
+
expect(knownHarness('opencode', HARNESS_IDS)).toBe('opencode');
|
|
98
|
+
// A row naming a harness this build no longer lists — `opencode2`, retired when
|
|
99
|
+
// the preview became a shim for `opencode` — draws no mark rather than a wrong
|
|
100
|
+
// one. Both spellings of "unknown" are covered: a retired id and an invented one.
|
|
101
|
+
expect(knownHarness('opencode2', HARNESS_IDS)).toBeUndefined();
|
|
102
|
+
expect(knownHarness('some-future-agent', HARNESS_IDS)).toBeUndefined();
|
|
103
|
+
expect(knownHarness(undefined, HARNESS_IDS)).toBeUndefined();
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test('the schema is idempotent, so every database open can run it', async () => {
|
|
107
|
+
const db = await getDb();
|
|
108
|
+
await saveHarnessSession({ sessionId: 's', harness: 'omp-rpc', agentSessionId: '', cwd: '/p' });
|
|
109
|
+
// A second open re-runs `initSchema`; the row must survive it.
|
|
110
|
+
await ensureHarnessSchema(db);
|
|
111
|
+
expect((await loadHarnessBySession()).get('s')).toBe('omp-rpc');
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test('a title survives a re-spawn, which must not blank it', async () => {
|
|
115
|
+
await saveHarnessSession({ sessionId: 'titled', harness: 'claude', agentSessionId: '', cwd: '/p' });
|
|
116
|
+
await saveHarnessSessionTitleIfEmpty('titled', 'Plan the release');
|
|
117
|
+
// A re-spawn UPDATES the row; the name it already carries is not part of
|
|
118
|
+
// that write, so it must still be there afterwards.
|
|
119
|
+
await saveHarnessSession({ sessionId: 'titled', harness: 'claude', agentSessionId: 'agent-9', cwd: '/p' });
|
|
120
|
+
|
|
121
|
+
const [row] = await loadAcpSessions();
|
|
122
|
+
expect(row.title).toBe('Plan the release');
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
test('the first prompt names the chat, and a later one cannot rename it', async () => {
|
|
126
|
+
await saveHarnessSession({ sessionId: 'first', harness: 'opencode', agentSessionId: '', cwd: '/p' });
|
|
127
|
+
|
|
128
|
+
expect(await saveHarnessSessionTitleIfEmpty('first', 'First prompt')).toBe(true);
|
|
129
|
+
// A steering message, a queue delivery and a retry all reach this call with
|
|
130
|
+
// their own text; none of them may rename the chat.
|
|
131
|
+
expect(await saveHarnessSessionTitleIfEmpty('first', 'Second prompt')).toBe(false);
|
|
132
|
+
|
|
133
|
+
const [row] = await loadAcpSessions();
|
|
134
|
+
expect(row.title).toBe('First prompt');
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
test('the AGENT’s own title outranks the first prompt', async () => {
|
|
138
|
+
await saveHarnessSession({ sessionId: 'named', harness: 'claude', agentSessionId: '', cwd: '/p' });
|
|
139
|
+
await saveHarnessSessionTitleIfEmpty('named', 'raw first prompt');
|
|
140
|
+
|
|
141
|
+
expect(await saveHarnessSessionTitle('named', 'Release planning')).toBe(true);
|
|
142
|
+
// An agent that re-sends the same title must not republish the sidebar.
|
|
143
|
+
expect(await saveHarnessSessionTitle('named', 'Release planning')).toBe(false);
|
|
144
|
+
|
|
145
|
+
const [row] = await loadAcpSessions();
|
|
146
|
+
expect(row.title).toBe('Release planning');
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
test('a title for a session nobody recorded is a no-op, not a new row', async () => {
|
|
150
|
+
expect(await saveHarnessSessionTitleIfEmpty('ghost', 'anything')).toBe(false);
|
|
151
|
+
expect(await saveHarnessSessionTitle('ghost', 'anything')).toBe(false);
|
|
152
|
+
expect(await loadHarnessSession('ghost')).toBeNull();
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
test('a FORKING resume leaves one row: the chat keeps its id', async () => {
|
|
156
|
+
await saveHarnessSession({ sessionId: 'chat-1', harness: 'claude', agentSessionId: 'agent-1', cwd: '/p' });
|
|
157
|
+
// `session/load` answered a new id, and the spawn recorded it as its own row.
|
|
158
|
+
await saveHarnessSession({ sessionId: 'agent-2', harness: 'claude', agentSessionId: '', cwd: '/p' });
|
|
159
|
+
|
|
160
|
+
await repointHarnessSession('chat-1', 'agent-2');
|
|
161
|
+
|
|
162
|
+
const rows = await loadAcpSessions();
|
|
163
|
+
// Measured before this: a resumed claude chat drew TWO sidebar rows, an empty
|
|
164
|
+
// twin beside the conversation the tab and the transcript are keyed by.
|
|
165
|
+
expect(rows.map((row) => row.sessionId)).toEqual(['chat-1']);
|
|
166
|
+
// The agent's id is the one the NEXT load must send.
|
|
167
|
+
expect(rows[0].agentSessionId).toBe('agent-2');
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
test('a load that keeps the id changes nothing', async () => {
|
|
171
|
+
await saveHarnessSession({ sessionId: 'chat-2', harness: 'claude', agentSessionId: 'chat-2', cwd: '/p' });
|
|
172
|
+
await repointHarnessSession('chat-2', 'chat-2');
|
|
173
|
+
expect((await loadAcpSessions()).map((row) => row.sessionId)).toEqual(['chat-2']);
|
|
174
|
+
});
|
|
175
|
+
});
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Read and write the persisted harness of a session.
|
|
8
|
+
*
|
|
9
|
+
* `spawn` writes once; the sidebar reads every folder load. Both go through this
|
|
10
|
+
* module so the column names appear in one file — a second caller spelling them
|
|
11
|
+
* out is how a rename leaves one read returning null.
|
|
12
|
+
*
|
|
13
|
+
* A FAILED WRITE IS NOT SWALLOWED silently at the call site: the spawn logs it.
|
|
14
|
+
* The session still runs (the spawn must not fail because a label could not be
|
|
15
|
+
* stored), but a silently missing row is exactly the bug this table exists to
|
|
16
|
+
* fix, so the failure is reported where it can be seen.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { getDb } from '@/server/db.server';
|
|
20
|
+
import type { HarnessId } from '@/shared/lib/harness/catalog';
|
|
21
|
+
|
|
22
|
+
export interface HarnessSessionRecord {
|
|
23
|
+
sessionId: string;
|
|
24
|
+
harness: string;
|
|
25
|
+
/** The id the AGENT reported, when it differs from Kabmo's. */
|
|
26
|
+
agentSessionId: string;
|
|
27
|
+
cwd: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Record which harness owns a session. Idempotent: a re-spawn of the same id
|
|
31
|
+
* UPDATES the row rather than failing on the primary key. */
|
|
32
|
+
export async function saveHarnessSession(record: HarnessSessionRecord): Promise<void> {
|
|
33
|
+
const now = Date.now();
|
|
34
|
+
const db = await getDb();
|
|
35
|
+
await db.run(
|
|
36
|
+
`INSERT INTO harness_sessions (session_id, harness, agent_session_id, cwd, created_at, updated_at)
|
|
37
|
+
VALUES (?, ?, ?, ?, ?, ?)
|
|
38
|
+
ON CONFLICT(session_id) DO UPDATE SET
|
|
39
|
+
harness = excluded.harness,
|
|
40
|
+
agent_session_id = excluded.agent_session_id,
|
|
41
|
+
cwd = excluded.cwd,
|
|
42
|
+
updated_at = excluded.updated_at`,
|
|
43
|
+
[record.sessionId, record.harness, record.agentSessionId, record.cwd, now, now],
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Name a chat from its first prompt, and only if nothing named it yet.
|
|
49
|
+
*
|
|
50
|
+
* `IfEmpty` is the whole reason a steering message, a queue delivery or a retry
|
|
51
|
+
* cannot rename a chat to its own text: every prompt on an ACP session goes
|
|
52
|
+
* through the same call. Returns whether the row CHANGED, so the caller can
|
|
53
|
+
* publish the sidebar's structure once instead of on every prompt.
|
|
54
|
+
*/
|
|
55
|
+
export async function saveHarnessSessionTitleIfEmpty(sessionId: string, title: string): Promise<boolean> {
|
|
56
|
+
if (!sessionId || !title) return false;
|
|
57
|
+
const db = await getDb();
|
|
58
|
+
const result = await db.run(
|
|
59
|
+
`UPDATE harness_sessions SET title = ?, updated_at = ?
|
|
60
|
+
WHERE session_id = ? AND (title IS NULL OR title = '')`,
|
|
61
|
+
[title, Date.now(), sessionId],
|
|
62
|
+
);
|
|
63
|
+
return (result.changes ?? 0) > 0;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Adopt a title the AGENT published.
|
|
68
|
+
*
|
|
69
|
+
* Unconditional, and that is the point: the agent's own name for the chat
|
|
70
|
+
* outranks Kabmo's guess from the first prompt. The inequality guard keeps a
|
|
71
|
+
* repeat of the same title (an agent may re-send it) from republishing the
|
|
72
|
+
* sidebar's whole structure.
|
|
73
|
+
*/
|
|
74
|
+
export async function saveHarnessSessionTitle(sessionId: string, title: string): Promise<boolean> {
|
|
75
|
+
if (!sessionId || !title) return false;
|
|
76
|
+
const db = await getDb();
|
|
77
|
+
const result = await db.run(
|
|
78
|
+
`UPDATE harness_sessions SET title = ?, updated_at = ?
|
|
79
|
+
WHERE session_id = ? AND (title IS NULL OR title <> ?)`,
|
|
80
|
+
[title, Date.now(), sessionId, title],
|
|
81
|
+
);
|
|
82
|
+
return (result.changes ?? 0) > 0;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Move a chat's record onto the id the agent RESUMED into.
|
|
87
|
+
*
|
|
88
|
+
* `session/load` may FORK: both claude and omp answered a NEW id for a load
|
|
89
|
+
* (measured: `01a1b49f-…` → `01a1b4cc-…`, and a resumed claude chat answered
|
|
90
|
+
* `340f24a3-…` for `5c5e776e-…`). `startAcpSession` records whatever id came
|
|
91
|
+
* back, so the fork left TWO rows for one conversation — the chat's own (which
|
|
92
|
+
* the sidebar, the open tab and Kabmo's transcript are all keyed by) plus an
|
|
93
|
+
* empty twin. The chat keeps its id and adopts the agent's, because that is the
|
|
94
|
+
* id the next `session/load` must send.
|
|
95
|
+
*/
|
|
96
|
+
export async function repointHarnessSession(sessionId: string, agentSessionId: string): Promise<void> {
|
|
97
|
+
if (!sessionId || !agentSessionId || sessionId === agentSessionId) return;
|
|
98
|
+
const db = await getDb();
|
|
99
|
+
await db.run('DELETE FROM harness_sessions WHERE session_id = ?', [agentSessionId]);
|
|
100
|
+
await db.run('UPDATE harness_sessions SET agent_session_id = ?, updated_at = ? WHERE session_id = ?', [
|
|
101
|
+
agentSessionId,
|
|
102
|
+
Date.now(),
|
|
103
|
+
sessionId,
|
|
104
|
+
]);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface HarnessSessionRow {
|
|
108
|
+
sessionId: string;
|
|
109
|
+
harness: string;
|
|
110
|
+
agentSessionId: string;
|
|
111
|
+
cwd: string;
|
|
112
|
+
/** What the chat is called: the agent's own title, else the first prompt.
|
|
113
|
+
* Empty when neither exists yet. */
|
|
114
|
+
title: string;
|
|
115
|
+
createdAt: number;
|
|
116
|
+
updatedAt: number;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Every recorded session that did NOT come from omp's JSONL store.
|
|
121
|
+
*
|
|
122
|
+
* Those rows are the ones the sidebar cannot discover on its own: an ACP agent
|
|
123
|
+
* writes no session file, so a chat spawned on `opencode` existed in the
|
|
124
|
+
* registry and in no list at all — it vanished from the sidebar the moment its
|
|
125
|
+
* tab closed.
|
|
126
|
+
*
|
|
127
|
+
* `harness <> 'omp-rpc'` is a cheap PRE-FILTER, not the rule: an omp row is
|
|
128
|
+
* persisted here too (its resume id lives in this table), and loading one per
|
|
129
|
+
* discovered session only to discard it is work the scan already did.
|
|
130
|
+
*
|
|
131
|
+
* The rule that actually removes duplicates lives where the two lists MERGE
|
|
132
|
+
* (`sidebar-data.server.ts`), because the pre-filter cannot express it: `omp-acp`
|
|
133
|
+
* is omp itself over the Agent Client Protocol, so its chats are ordinary
|
|
134
|
+
* `.jsonl` files the scan finds — and, being neither `omp-rpc` nor an ACP
|
|
135
|
+
* adapter, they passed this filter and drew TWO rows carrying one id.
|
|
136
|
+
*/
|
|
137
|
+
export async function loadAcpSessions(): Promise<HarnessSessionRow[]> {
|
|
138
|
+
const db = await getDb();
|
|
139
|
+
const rows = (await db.all(
|
|
140
|
+
`SELECT session_id, harness, agent_session_id, cwd, title, created_at, updated_at
|
|
141
|
+
FROM harness_sessions
|
|
142
|
+
WHERE harness <> 'omp-rpc'
|
|
143
|
+
ORDER BY updated_at DESC`,
|
|
144
|
+
)) as {
|
|
145
|
+
session_id: string;
|
|
146
|
+
harness: string;
|
|
147
|
+
agent_session_id: string;
|
|
148
|
+
cwd: string;
|
|
149
|
+
title: string | null;
|
|
150
|
+
created_at: number;
|
|
151
|
+
updated_at: number;
|
|
152
|
+
}[];
|
|
153
|
+
return rows.map((row) => ({
|
|
154
|
+
sessionId: row.session_id,
|
|
155
|
+
harness: row.harness,
|
|
156
|
+
agentSessionId: row.agent_session_id,
|
|
157
|
+
cwd: row.cwd,
|
|
158
|
+
title: row.title ?? '',
|
|
159
|
+
createdAt: row.created_at,
|
|
160
|
+
updatedAt: row.updated_at,
|
|
161
|
+
}));
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** The agent's own id for a session, for resuming it. Null when the row has
|
|
165
|
+
* none (an RPC session) or the session was never recorded. */
|
|
166
|
+
export async function loadAgentSessionId(sessionId: string): Promise<string | null> {
|
|
167
|
+
const row = await loadHarnessSession(sessionId);
|
|
168
|
+
return row && row.agentSessionId ? row.agentSessionId : null;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** session id → harness id, for every session this database knows about.
|
|
172
|
+
*
|
|
173
|
+
* A Map rather than a per-row query: the sidebar assembles hundreds of rows in
|
|
174
|
+
* one pass, and one read for the whole answer is the difference between one
|
|
175
|
+
* query and one per session. */
|
|
176
|
+
export async function loadHarnessBySession(): Promise<Map<string, string>> {
|
|
177
|
+
const db = await getDb();
|
|
178
|
+
const rows = (await db.all('SELECT session_id, harness FROM harness_sessions')) as {
|
|
179
|
+
session_id: string;
|
|
180
|
+
harness: string;
|
|
181
|
+
}[];
|
|
182
|
+
return new Map(rows.map((row) => [row.session_id, row.harness]));
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** The row for one session, or null. */
|
|
186
|
+
export async function loadHarnessSession(sessionId: string): Promise<HarnessSessionRecord | null> {
|
|
187
|
+
const db = await getDb();
|
|
188
|
+
const row = (await db.get(
|
|
189
|
+
'SELECT session_id, harness, agent_session_id, cwd FROM harness_sessions WHERE session_id = ?',
|
|
190
|
+
[sessionId],
|
|
191
|
+
)) as { session_id: string; harness: string; agent_session_id: string; cwd: string } | null;
|
|
192
|
+
if (!row) return null;
|
|
193
|
+
return {
|
|
194
|
+
sessionId: row.session_id,
|
|
195
|
+
harness: row.harness,
|
|
196
|
+
agentSessionId: row.agent_session_id,
|
|
197
|
+
cwd: row.cwd,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** Narrow a stored value to a harness this build knows. A row written by a
|
|
202
|
+
* newer build (an adapter since removed) must not draw a mark that has no art
|
|
203
|
+
* and no name. */
|
|
204
|
+
export function knownHarness(value: string | undefined, ids: readonly HarnessId[]): HarnessId | undefined {
|
|
205
|
+
return value && (ids as readonly string[]).includes(value) ? (value as HarnessId) : undefined;
|
|
206
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Naming a chat that runs on another harness.
|
|
8
|
+
*
|
|
9
|
+
* The bug this pins: an ACP agent writes no session file, so the row the sidebar
|
|
10
|
+
* drew for its chat said `Untitled` for the whole life of the conversation —
|
|
11
|
+
* measured on a `claude` chat an hour after its first prompt, while the
|
|
12
|
+
* placeholder row it replaced had shown the user's own words.
|
|
13
|
+
*
|
|
14
|
+
* The rule is `deriveSessionTitle`'s, applied to the two facts Kabmo stores: the
|
|
15
|
+
* agent's own title when it publishes one, else the first prompt. Both writers
|
|
16
|
+
* return their write, so every case here awaits the real completion instead of
|
|
17
|
+
* sleeping on it.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
21
|
+
import { isolateDb, releaseDb } from '@/test-support/isolated-db';
|
|
22
|
+
import { loadAcpSessions, saveHarnessSession } from '@/server/lib/harness/session-store.server';
|
|
23
|
+
import { noteAgentTitle, notePromptTitle, titleFromPrompt } from '@/server/lib/harness/session-title.server';
|
|
24
|
+
import { onRealtimeSignal } from '@/server/lib/realtime/signals.server';
|
|
25
|
+
|
|
26
|
+
/** Run one write and report the signals it raised, in order. */
|
|
27
|
+
async function writeAndCollectSignals(write: () => Promise<boolean>): Promise<{ written: boolean; signals: string[] }> {
|
|
28
|
+
const signals: string[] = [];
|
|
29
|
+
const off = onRealtimeSignal((event) => signals.push(event.signal));
|
|
30
|
+
try {
|
|
31
|
+
return { written: await write(), signals };
|
|
32
|
+
} finally {
|
|
33
|
+
off();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
beforeEach(async () => {
|
|
38
|
+
await isolateDb();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
afterEach(async () => {
|
|
42
|
+
await releaseDb();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe('titleFromPrompt', () => {
|
|
46
|
+
test('one line, collapsed, bounded', () => {
|
|
47
|
+
expect(titleFromPrompt(' Hello\n\n world ')).toBe('Hello world');
|
|
48
|
+
// The bound matches the 120 `sessionTitleFor` keeps of an omp first message.
|
|
49
|
+
expect(titleFromPrompt('x'.repeat(500))).toHaveLength(120);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test('a message with nothing to show is no title at all', () => {
|
|
53
|
+
expect(titleFromPrompt(' \n ')).toBe('');
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
describe('naming an ACP chat', () => {
|
|
58
|
+
beforeEach(async () => {
|
|
59
|
+
await saveHarnessSession({ sessionId: 'chat', harness: 'claude', agentSessionId: '', cwd: '/p' });
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test('the first prompt names it and publishes the sidebar once', async () => {
|
|
63
|
+
const result = await writeAndCollectSignals(() => notePromptTitle('chat', 'Ship the release'));
|
|
64
|
+
|
|
65
|
+
expect(result).toEqual({ written: true, signals: ['sidebar-structure'] });
|
|
66
|
+
expect((await loadAcpSessions())[0].title).toBe('Ship the release');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test('a later prompt leaves the name alone, and publishes nothing', async () => {
|
|
70
|
+
await notePromptTitle('chat', 'Ship the release');
|
|
71
|
+
|
|
72
|
+
// A steering message or a queue delivery reaches the same call with its own
|
|
73
|
+
// text; renaming the chat to it is the defect this guard exists for.
|
|
74
|
+
const result = await writeAndCollectSignals(() => notePromptTitle('chat', 'and also do this'));
|
|
75
|
+
expect(result).toEqual({ written: false, signals: [] });
|
|
76
|
+
expect((await loadAcpSessions())[0].title).toBe('Ship the release');
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test('the agent’s own title replaces the prompt guess', async () => {
|
|
80
|
+
await notePromptTitle('chat', 'Ship the release');
|
|
81
|
+
|
|
82
|
+
const result = await writeAndCollectSignals(() => noteAgentTitle('chat', 'Release train'));
|
|
83
|
+
expect(result).toEqual({ written: true, signals: ['sidebar-structure'] });
|
|
84
|
+
expect((await loadAcpSessions())[0].title).toBe('Release train');
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test('a repeated agent title publishes nothing', async () => {
|
|
88
|
+
await noteAgentTitle('chat', 'Release train');
|
|
89
|
+
|
|
90
|
+
expect(await writeAndCollectSignals(() => noteAgentTitle('chat', 'Release train'))).toEqual({
|
|
91
|
+
written: false,
|
|
92
|
+
signals: [],
|
|
93
|
+
});
|
|
94
|
+
// An empty one is not a name, and must not blank the row either.
|
|
95
|
+
expect(await writeAndCollectSignals(() => noteAgentTitle('chat', ' '))).toEqual({
|
|
96
|
+
written: false,
|
|
97
|
+
signals: [],
|
|
98
|
+
});
|
|
99
|
+
expect((await loadAcpSessions())[0].title).toBe('Release train');
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
test('an empty prompt names nothing', async () => {
|
|
103
|
+
expect(await writeAndCollectSignals(() => notePromptTitle('chat', ' '))).toEqual({
|
|
104
|
+
written: false,
|
|
105
|
+
signals: [],
|
|
106
|
+
});
|
|
107
|
+
expect((await loadAcpSessions())[0].title).toBe('');
|
|
108
|
+
});
|
|
109
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The NAME of a chat that runs on another harness, persisted.
|
|
8
|
+
*
|
|
9
|
+
* An ACP agent writes no session file, so omp's JSONL discovery — the thing that
|
|
10
|
+
* names every omp row (`sessionTitleFor`) — has nothing to read: `acpRowsFor`
|
|
11
|
+
* drew `Untitled` for every recorded chat, forever, for a conversation whose
|
|
12
|
+
* first line was already in the database. Measured an hour after a `claude`
|
|
13
|
+
* chat's first prompt: the row still read `Untitled`, while the placeholder row
|
|
14
|
+
* it replaced had shown the user's own words.
|
|
15
|
+
*
|
|
16
|
+
* Two sources, and the ORDER is what names a chat:
|
|
17
|
+
*
|
|
18
|
+
* - the FIRST PROMPT, which Kabmo owns and which every other row source already
|
|
19
|
+
* uses to name a nameless chat;
|
|
20
|
+
* - the AGENT's own title (`session_info_update`), which overwrites the guess
|
|
21
|
+
* once the agent names the chat the way it sees it.
|
|
22
|
+
*
|
|
23
|
+
* A later prompt never overwrites anything — see
|
|
24
|
+
* `saveHarnessSessionTitleIfEmpty`, whose whole point is that a steering message
|
|
25
|
+
* or a queued follow-up cannot rename a chat to its own text.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
import { emitRealtimeSignal } from '@/server/lib/realtime/signals.server';
|
|
29
|
+
import {
|
|
30
|
+
saveHarnessSessionTitle,
|
|
31
|
+
saveHarnessSessionTitleIfEmpty,
|
|
32
|
+
} from '@/server/lib/harness/session-store.server';
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The most of a prompt a stored title keeps.
|
|
36
|
+
*
|
|
37
|
+
* Matches the 120 `sessionTitleFor` keeps of an omp session's first message, so
|
|
38
|
+
* the two row sources cut a long first line at the same place.
|
|
39
|
+
*/
|
|
40
|
+
const PROMPT_TITLE_MAX = 120;
|
|
41
|
+
|
|
42
|
+
/** A prompt as a title: one line, collapsed whitespace, bounded. */
|
|
43
|
+
export function titleFromPrompt(message: string): string {
|
|
44
|
+
return message.trim().replace(/\s+/g, ' ').slice(0, PROMPT_TITLE_MAX);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Remember the first prompt as this chat's title.
|
|
49
|
+
*
|
|
50
|
+
* Returns the write, so a caller that cares can await it (and so a test can
|
|
51
|
+
* assert on the publish without sleeping). The prompt path ignores it: a name is
|
|
52
|
+
* not worth failing a prompt over, and the structure publish is what makes an
|
|
53
|
+
* open sidebar draw the row with its new text.
|
|
54
|
+
*/
|
|
55
|
+
export async function notePromptTitle(sessionId: string, message: string): Promise<boolean> {
|
|
56
|
+
const title = titleFromPrompt(message);
|
|
57
|
+
if (!sessionId || !title) return false;
|
|
58
|
+
const written = await saveHarnessSessionTitleIfEmpty(sessionId, title).catch(() => false);
|
|
59
|
+
if (written) emitRealtimeSignal('sidebar-structure');
|
|
60
|
+
return written;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Adopt the title the AGENT published; it outranks the first-prompt guess. */
|
|
64
|
+
export async function noteAgentTitle(sessionId: string, title: string): Promise<boolean> {
|
|
65
|
+
const next = title.trim();
|
|
66
|
+
if (!sessionId || !next) return false;
|
|
67
|
+
const written = await saveHarnessSessionTitle(sessionId, next).catch(() => false);
|
|
68
|
+
if (written) emitRealtimeSignal('sidebar-structure');
|
|
69
|
+
return written;
|
|
70
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The contract every transport-backed session satisfies.
|
|
8
|
+
*
|
|
9
|
+
* `AgentSessionWrapper` (omp RPC) already had this shape; naming it lets the
|
|
10
|
+
* registry hold an ACP session and an omp session in ONE map, which is what the
|
|
11
|
+
* realtime topic, the sidebar, the queue and every route already read from.
|
|
12
|
+
*
|
|
13
|
+
* Deliberately narrow: only what a CALLER outside the driver uses. An omp-only
|
|
14
|
+
* member (`runSettle`, `subagents`, `modeMirror`) is not here because a
|
|
15
|
+
* harness without it must not pretend — the capability table says which
|
|
16
|
+
* surfaces exist.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import type { AgentEvent } from '@/server/lib/omp/rpc/constants';
|
|
20
|
+
import type { HarnessId } from '@/shared/lib/harness/catalog';
|
|
21
|
+
|
|
22
|
+
export interface HarnessEventSource {
|
|
23
|
+
onEvent(listener: (event: AgentEvent) => void): () => void;
|
|
24
|
+
emit(event: AgentEvent): void;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** What a session answers about itself without asking the agent. */
|
|
28
|
+
export interface HarnessSessionState {
|
|
29
|
+
/** The agent's own session id (omp: `get_state.sessionId`). */
|
|
30
|
+
readonly sessionId: string;
|
|
31
|
+
/** On-disk transcript, when the harness has one Kabmo can read. Empty for
|
|
32
|
+
* ACP sessions, whose history lives behind `session/load`. */
|
|
33
|
+
readonly sessionFile: string;
|
|
34
|
+
readonly cwd: string;
|
|
35
|
+
/** Which harness owns this session — the field every panel gates on. */
|
|
36
|
+
readonly harness: HarnessId;
|
|
37
|
+
readonly isStreaming: boolean;
|
|
38
|
+
readonly isPromptRunning: boolean;
|
|
39
|
+
/** The model serving the run, as the agent resolved it. */
|
|
40
|
+
readonly runModel: { provider: string; modelId: string } | null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** A live session: state, a control channel, and a frame stream. */
|
|
44
|
+
export interface HarnessSession extends HarnessEventSource, HarnessSessionState {
|
|
45
|
+
isAlive(): boolean;
|
|
46
|
+
isRunning(): boolean;
|
|
47
|
+
/** Anything a forced reset would destroy (a turn, a dialog, a subagent). */
|
|
48
|
+
isBusy(): boolean;
|
|
49
|
+
send(command: Record<string, unknown>): Promise<unknown>;
|
|
50
|
+
/** Blocking dialogs a reattaching client must replay. */
|
|
51
|
+
getPendingUiDialogs(): Record<string, unknown>[];
|
|
52
|
+
resolvePendingUiDialog(id: string): void;
|
|
53
|
+
destroy(): void;
|
|
54
|
+
destroyAndWait(): Promise<void>;
|
|
55
|
+
onDestroy(callback: () => void): void;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Spawn parameters shared by every driver. */
|
|
59
|
+
export interface HarnessSpawnRequest {
|
|
60
|
+
/** The id Kabmo asked for (a placeholder for a brand-new chat). */
|
|
61
|
+
sessionId: string;
|
|
62
|
+
/** On-disk transcript to resume, or '' for a new session. */
|
|
63
|
+
sessionFile: string;
|
|
64
|
+
cwd: string;
|
|
65
|
+
/** Extra environment (mode selection, approval mode). */
|
|
66
|
+
env?: Record<string, string>;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** A driver maps one harness onto `HarnessSession`s. */
|
|
70
|
+
export interface HarnessDriver {
|
|
71
|
+
readonly id: HarnessId;
|
|
72
|
+
/** Spawn (or resume) one session. */
|
|
73
|
+
open(request: HarnessSpawnRequest): Promise<{ session: HarnessSession; realSessionId: string }>;
|
|
74
|
+
}
|