@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,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The in-place rewind endpoint, driven against a real session file.
|
|
8
|
+
*
|
|
9
|
+
* Two rules are pinned here, both of which the ACP transport made visible:
|
|
10
|
+
*
|
|
11
|
+
* - the live child is torn down BEFORE the file is touched. `omp-acp` writes
|
|
12
|
+
* the same JSONL and flushes it on shutdown, so a rewind that rewrote the
|
|
13
|
+
* file first raced the child and could be overwritten by its final flush;
|
|
14
|
+
* - a harness whose agent keeps its own transcript is refused BEFORE its child
|
|
15
|
+
* is destroyed. `claude` has no omp file to truncate, so the old shape would
|
|
16
|
+
* have killed a working chat and then answered 404.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
20
|
+
import { mkdirSync, mkdtempSync, readFileSync, writeFileSync } from 'node:fs';
|
|
21
|
+
import { tmpdir } from 'node:os';
|
|
22
|
+
import { join } from 'node:path';
|
|
23
|
+
import { isolateDb, releaseDb } from '@/test-support/isolated-db';
|
|
24
|
+
import { removeDir } from '@/test-support/remove-dir';
|
|
25
|
+
import { registerAcpSession } from '@/server/lib/harness/register.server';
|
|
26
|
+
import { claimHarness } from '@/server/lib/harness/registry';
|
|
27
|
+
import { clearSessionFileCaches } from '@/server/lib/omp/session/files';
|
|
28
|
+
import { action } from '@/server/routes/chat/rewind';
|
|
29
|
+
import type { HarnessSession } from '@/server/lib/harness/session';
|
|
30
|
+
import type { HarnessId } from '@/shared/lib/harness/catalog';
|
|
31
|
+
|
|
32
|
+
const SESSION_ID = '01a1b49f-0000-7000-8000-000000000001';
|
|
33
|
+
|
|
34
|
+
const FIXTURE = [
|
|
35
|
+
JSON.stringify({ type: 'session', id: SESSION_ID, cwd: '/tmp/project' }),
|
|
36
|
+
JSON.stringify({ type: 'message', id: 'u1', timestamp: 1_000, message: { role: 'user', content: 'first ask' } }),
|
|
37
|
+
JSON.stringify({ type: 'message', id: 'a1', timestamp: 2_000, message: { role: 'assistant', content: 'answer' } }),
|
|
38
|
+
'',
|
|
39
|
+
].join('\n');
|
|
40
|
+
|
|
41
|
+
let root = '';
|
|
42
|
+
let filePath = '';
|
|
43
|
+
let previousAgentDir: string | undefined;
|
|
44
|
+
|
|
45
|
+
/** Register a fake ACP session the route's `getLiveSession` lookup will find. */
|
|
46
|
+
function registerLive(id: string, harness: HarnessId, onDestroy?: () => void): () => void {
|
|
47
|
+
let release: (() => void) | null = null;
|
|
48
|
+
const session = {
|
|
49
|
+
sessionId: id,
|
|
50
|
+
harness,
|
|
51
|
+
sessionFile: '',
|
|
52
|
+
cwd: '/tmp/project',
|
|
53
|
+
isStreaming: false,
|
|
54
|
+
isPromptRunning: false,
|
|
55
|
+
runModel: null,
|
|
56
|
+
isAlive: () => true,
|
|
57
|
+
isRunning: () => false,
|
|
58
|
+
isBusy: () => false,
|
|
59
|
+
send: async () => ({}),
|
|
60
|
+
getPendingUiDialogs: () => [],
|
|
61
|
+
resolvePendingUiDialog: () => {},
|
|
62
|
+
onEvent: () => () => {},
|
|
63
|
+
emit: () => {},
|
|
64
|
+
destroy: () => {},
|
|
65
|
+
destroyAndWait: async () => {
|
|
66
|
+
onDestroy?.();
|
|
67
|
+
release?.();
|
|
68
|
+
},
|
|
69
|
+
onDestroy: (callback: () => void) => {
|
|
70
|
+
release = callback;
|
|
71
|
+
},
|
|
72
|
+
} as unknown as HarnessSession;
|
|
73
|
+
registerAcpSession(session, id);
|
|
74
|
+
claimHarness(session, harness);
|
|
75
|
+
return () => release?.();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function rewind(entryId = 'u1'): Promise<Response> {
|
|
79
|
+
return action({
|
|
80
|
+
params: { sessionId: SESSION_ID },
|
|
81
|
+
request: new Request(`http://localhost/api/chat/${SESSION_ID}/rewind`, {
|
|
82
|
+
method: 'POST',
|
|
83
|
+
headers: { 'Content-Type': 'application/json' },
|
|
84
|
+
body: JSON.stringify({ entryId }),
|
|
85
|
+
}),
|
|
86
|
+
} as never) as Promise<Response>;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
beforeEach(async () => {
|
|
90
|
+
previousAgentDir = Bun.env.PI_CODING_AGENT_DIR;
|
|
91
|
+
root = mkdtempSync(join(tmpdir(), 'kabmo-rewind-'));
|
|
92
|
+
Bun.env.PI_CODING_AGENT_DIR = root;
|
|
93
|
+
const project = join(root, 'sessions', 'project');
|
|
94
|
+
mkdirSync(project, { recursive: true });
|
|
95
|
+
filePath = join(project, `${SESSION_ID}.jsonl`);
|
|
96
|
+
writeFileSync(filePath, FIXTURE);
|
|
97
|
+
clearSessionFileCaches();
|
|
98
|
+
await isolateDb();
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
afterEach(async () => {
|
|
102
|
+
await releaseDb();
|
|
103
|
+
clearSessionFileCaches();
|
|
104
|
+
if (previousAgentDir === undefined) delete Bun.env.PI_CODING_AGENT_DIR;
|
|
105
|
+
else Bun.env.PI_CODING_AGENT_DIR = previousAgentDir;
|
|
106
|
+
if (root) removeDir(root);
|
|
107
|
+
root = '';
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
describe('POST /api/chat/:id/rewind', () => {
|
|
111
|
+
test('an omp-acp chat is torn down BEFORE its shared JSONL is rewritten', async () => {
|
|
112
|
+
const atTeardown: string[] = [];
|
|
113
|
+
const release = registerLive(SESSION_ID, 'omp-acp', () => atTeardown.push(readFileSync(filePath, 'utf8')));
|
|
114
|
+
try {
|
|
115
|
+
const response = await rewind();
|
|
116
|
+
expect(response.status).toBe(200);
|
|
117
|
+
// The child still had the abandoned turn when it was destroyed — proof the
|
|
118
|
+
// teardown ran first, not after the rewrite.
|
|
119
|
+
expect(atTeardown).toHaveLength(1);
|
|
120
|
+
expect(atTeardown[0]).toContain('"id":"a1"');
|
|
121
|
+
|
|
122
|
+
const next = readFileSync(filePath, 'utf8');
|
|
123
|
+
expect(next).not.toContain('"id":"u1"');
|
|
124
|
+
expect(next).not.toContain('"id":"a1"');
|
|
125
|
+
expect(next).toContain('"type":"session"');
|
|
126
|
+
} finally {
|
|
127
|
+
release();
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test('another ACP agent is refused without destroying its live child', async () => {
|
|
132
|
+
let destroyed = 0;
|
|
133
|
+
const release = registerLive(SESSION_ID, 'claude', () => { destroyed += 1; });
|
|
134
|
+
try {
|
|
135
|
+
const response = await rewind();
|
|
136
|
+
expect(response.status).toBe(400);
|
|
137
|
+
const body = (await response.json()) as { code?: string; error?: string };
|
|
138
|
+
expect(body.code).toBe('harness_not_rewindable');
|
|
139
|
+
expect(body.error).toContain('claude');
|
|
140
|
+
expect(destroyed).toBe(0);
|
|
141
|
+
// Its file — when it has one Kabmo can find — is untouched.
|
|
142
|
+
expect(readFileSync(filePath, 'utf8')).toContain('"id":"u1"');
|
|
143
|
+
} finally {
|
|
144
|
+
release();
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
});
|
|
@@ -2,10 +2,11 @@ import { json } from '@/server/lib/remix-compat';
|
|
|
2
2
|
import type { ActionFunctionArgs } from '@/server/lib/remix-compat';
|
|
3
3
|
import { getDb } from '@/server/db.server';
|
|
4
4
|
import { resolveSessionFileOr404 } from '@/server/lib/omp/session/locator';
|
|
5
|
-
import {
|
|
5
|
+
import { getLiveSession, harnessOfSession } from '@/server/lib/omp/rpc/session-registry';
|
|
6
6
|
import { clearSessionFileCaches } from '@/server/lib/omp/session/files';
|
|
7
7
|
import { pruneStoredAfterCut, survivingUserTexts, truncateSessionBody } from '@/server/lib/omp/session/rewind-file';
|
|
8
8
|
import { userTurnsRelate } from '@/shared/lib/chat/timeline/turns';
|
|
9
|
+
import { harnessSupportsRewind } from '@/shared/lib/harness/rewind';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* In-place rewind (undo) for an omp session: truncate the session JSONL back
|
|
@@ -16,9 +17,18 @@ import { userTurnsRelate } from '@/shared/lib/chat/timeline/turns';
|
|
|
16
17
|
* file in place for equivalent operations (`rewriteEntries`), and its JSONL
|
|
17
18
|
* readers walk entries in order, so a prefix-preserving truncation is faithful.
|
|
18
19
|
*
|
|
20
|
+
* Both omp transports reach this endpoint. `omp-acp` writes the SAME JSONL as
|
|
21
|
+
* `omp-rpc`, so a chat that ran over ACP is rewound the same way — the ACP
|
|
22
|
+
* child is torn down first, because it holds the old context in memory and is
|
|
23
|
+
* the only other writer of the file; the next prompt resumes the truncated
|
|
24
|
+
* transcript over RPC (`resumeRecordedHarnessSession` deliberately excludes
|
|
25
|
+
* `omp-acp`, whose `session/load` forks). Every other ACP agent stores its own
|
|
26
|
+
* history and offers no truncation, so it is refused in words instead of
|
|
27
|
+
* truncating a file it does not read.
|
|
28
|
+
*
|
|
19
29
|
* Safety contract:
|
|
20
|
-
* - the live
|
|
21
|
-
*
|
|
30
|
+
* - the live child for this session is destroyed first (it flushes pending
|
|
31
|
+
* state on shutdown and is the only other writer of this file);
|
|
22
32
|
* - the original file is kept as `<name>.bak-<timestamp>` (omp's session
|
|
23
33
|
* listing ignores names containing `.bak`, so it never becomes a phantom
|
|
24
34
|
* session).
|
|
@@ -54,10 +64,22 @@ export async function action({ params, request }: ActionFunctionArgs) {
|
|
|
54
64
|
if ('response' in resolved) return resolved.response;
|
|
55
65
|
const { filePath } = resolved;
|
|
56
66
|
|
|
57
|
-
// Tear down the live
|
|
58
|
-
//
|
|
59
|
-
//
|
|
60
|
-
|
|
67
|
+
// Tear down the live child FIRST, whichever transport runs it: it flushes
|
|
68
|
+
// pending writes on shutdown, it is the only other writer of the file, and
|
|
69
|
+
// the file's CONTENT is read below. Best-effort: the session may already be
|
|
70
|
+
// gone or mid-restart. A harness whose agent keeps its own transcript is
|
|
71
|
+
// refused BEFORE its child is touched — truncating a file it does not read
|
|
72
|
+
// would kill a working chat to no effect.
|
|
73
|
+
const live = getLiveSession(sessionId);
|
|
74
|
+
if (live && !harnessSupportsRewind(harnessOfSession(live))) {
|
|
75
|
+
return json(
|
|
76
|
+
{
|
|
77
|
+
error: `${harnessOfSession(live)} cannot rewind this chat: its agent keeps its own transcript and offers no truncation.`,
|
|
78
|
+
code: 'harness_not_rewindable',
|
|
79
|
+
},
|
|
80
|
+
{ status: 400 },
|
|
81
|
+
);
|
|
82
|
+
}
|
|
61
83
|
if (live?.isAlive()) {
|
|
62
84
|
await live.destroyAndWait();
|
|
63
85
|
}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A reopened ACP chat must name the model it is ACTUALLY running.
|
|
8
|
+
*
|
|
9
|
+
* A non-omp ACP agent writes no transcript Kabmo can read, and its stored row
|
|
10
|
+
* carries no model. Before this, the composer fell back to omp's catalog and
|
|
11
|
+
* claimed a model the agent had never heard of; the live session's own selector
|
|
12
|
+
* (or, after a restart, the last run's stream row) is the only truthful source.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { afterAll, afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
16
|
+
import fs from 'node:fs';
|
|
17
|
+
import { tmpdir } from 'node:os';
|
|
18
|
+
import { join } from 'node:path';
|
|
19
|
+
import { isolateDb, releaseDb } from '@/test-support/isolated-db';
|
|
20
|
+
import { loader } from '@/server/routes/chat/session';
|
|
21
|
+
import { registerAcpSession } from '@/server/lib/harness/register.server';
|
|
22
|
+
import { claimHarness } from '@/server/lib/harness/registry';
|
|
23
|
+
import { clearSessionFileCaches } from '@/server/lib/omp/session/files';
|
|
24
|
+
import type { HarnessSession } from '@/server/lib/harness/session';
|
|
25
|
+
|
|
26
|
+
/** The temp agent dir an on-disk transcript needs, since `findSessionFileById`
|
|
27
|
+
* resolves through the real sessions root. */
|
|
28
|
+
const previousAgentDir = Bun.env.PI_CODING_AGENT_DIR;
|
|
29
|
+
const previousXdg = Bun.env.XDG_DATA_HOME;
|
|
30
|
+
let agentRoot = '';
|
|
31
|
+
let sessionsRoot = '';
|
|
32
|
+
|
|
33
|
+
beforeEach(async () => {
|
|
34
|
+
agentRoot = await fs.promises.mkdtemp(join(tmpdir(), 'kabmo-acp-session-'));
|
|
35
|
+
sessionsRoot = join(agentRoot, 'sessions');
|
|
36
|
+
await fs.promises.mkdir(sessionsRoot, { recursive: true });
|
|
37
|
+
Bun.env.PI_CODING_AGENT_DIR = agentRoot;
|
|
38
|
+
// An existing XDG root redirects the sessions dir away from the temp one.
|
|
39
|
+
delete Bun.env.XDG_DATA_HOME;
|
|
40
|
+
clearSessionFileCaches();
|
|
41
|
+
delete Bun.env.MOCK;
|
|
42
|
+
await isolateDb();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
afterEach(async () => {
|
|
46
|
+
clearSessionFileCaches();
|
|
47
|
+
await fs.promises.rm(agentRoot, { recursive: true, force: true });
|
|
48
|
+
await releaseDb();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
afterAll(() => {
|
|
52
|
+
if (previousAgentDir === undefined) delete Bun.env.PI_CODING_AGENT_DIR;
|
|
53
|
+
else Bun.env.PI_CODING_AGENT_DIR = previousAgentDir;
|
|
54
|
+
if (previousXdg === undefined) delete Bun.env.XDG_DATA_HOME;
|
|
55
|
+
else Bun.env.XDG_DATA_HOME = previousXdg;
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
/** Write `<id>.jsonl` under the sessions root, with omp's own header line. */
|
|
59
|
+
async function writeSessionFile(id: string, entries: Array<Record<string, unknown>>): Promise<string> {
|
|
60
|
+
const dir = join(sessionsRoot, 'project');
|
|
61
|
+
await fs.promises.mkdir(dir, { recursive: true });
|
|
62
|
+
const path = join(dir, `${id}.jsonl`);
|
|
63
|
+
const lines = [
|
|
64
|
+
JSON.stringify({ type: 'session', id, cwd: '/work', timestamp: '2026-11-09T00:00:00.000Z' }),
|
|
65
|
+
...entries.map((entry) => JSON.stringify(entry)),
|
|
66
|
+
];
|
|
67
|
+
await Bun.write(path, `${lines.join('\n')}\n`);
|
|
68
|
+
clearSessionFileCaches();
|
|
69
|
+
return path;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function registerAgent(id: string, state: Record<string, unknown>): () => void {
|
|
73
|
+
let release: (() => void) | null = null;
|
|
74
|
+
const session = {
|
|
75
|
+
sessionId: id,
|
|
76
|
+
harness: 'claude',
|
|
77
|
+
sessionFile: '',
|
|
78
|
+
cwd: '/tmp',
|
|
79
|
+
isStreaming: false,
|
|
80
|
+
isPromptRunning: false,
|
|
81
|
+
runModel: null,
|
|
82
|
+
capabilities: {},
|
|
83
|
+
configOptions: [],
|
|
84
|
+
isAlive: () => true,
|
|
85
|
+
isRunning: () => false,
|
|
86
|
+
isBusy: () => false,
|
|
87
|
+
send: async (command: Record<string, unknown>) => (command.type === 'get_state' ? state : {}),
|
|
88
|
+
getPendingUiDialogs: () => [],
|
|
89
|
+
resolvePendingUiDialog: () => {},
|
|
90
|
+
onEvent: () => () => {},
|
|
91
|
+
emit: () => {},
|
|
92
|
+
destroy: () => {},
|
|
93
|
+
destroyAndWait: async () => {},
|
|
94
|
+
onDestroy: (callback: () => void) => {
|
|
95
|
+
release = callback;
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
registerAcpSession(session as unknown as HarnessSession, id);
|
|
99
|
+
claimHarness(session as unknown as HarnessSession, 'claude');
|
|
100
|
+
return () => release?.();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function load(sessionId: string): Promise<Response> {
|
|
104
|
+
return loader({
|
|
105
|
+
request: new Request(`http://localhost/api/chat/${sessionId}`),
|
|
106
|
+
params: { sessionId },
|
|
107
|
+
} as never) as Promise<Response>;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
describe('chat session loader on a live ACP chat', () => {
|
|
111
|
+
test('reports the session model and thinking level from get_state', async () => {
|
|
112
|
+
const release = registerAgent('acp-live-chat', {
|
|
113
|
+
model: { provider: 'claude', id: 'opus' },
|
|
114
|
+
thinkingLevel: 'high',
|
|
115
|
+
});
|
|
116
|
+
try {
|
|
117
|
+
const body = (await (await load('acp-live-chat')).json()) as {
|
|
118
|
+
session: { model?: { provider: string; modelId: string }; thinkingLevel?: string };
|
|
119
|
+
};
|
|
120
|
+
expect(body.session.model).toEqual({ provider: 'claude', modelId: 'opus' });
|
|
121
|
+
expect(body.session.thinkingLevel).toBe('high');
|
|
122
|
+
} finally {
|
|
123
|
+
release();
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
test('reports the selectors the LIVE session published, not a probe', async () => {
|
|
128
|
+
// codex refuses a probe spawn while a chat is already running, yet that chat
|
|
129
|
+
// offers its models — so the session's own lists are the only honest ones.
|
|
130
|
+
const release = registerAgent('acp-live-selectors', {
|
|
131
|
+
model: { provider: 'openai', id: 'gpt-5' },
|
|
132
|
+
thinkingLevel: 'medium',
|
|
133
|
+
configOptions: [
|
|
134
|
+
{
|
|
135
|
+
id: 'model',
|
|
136
|
+
name: 'Model',
|
|
137
|
+
category: 'model',
|
|
138
|
+
currentValue: 'gpt-5',
|
|
139
|
+
options: [
|
|
140
|
+
{ value: 'gpt-5', name: 'GPT-5' },
|
|
141
|
+
{ value: 'gpt-5-mini', name: 'GPT-5 mini' },
|
|
142
|
+
],
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
id: 'thought_level',
|
|
146
|
+
name: 'Thinking',
|
|
147
|
+
category: 'thought_level',
|
|
148
|
+
currentValue: 'medium',
|
|
149
|
+
options: [{ value: 'medium', name: 'Medium' }],
|
|
150
|
+
},
|
|
151
|
+
],
|
|
152
|
+
});
|
|
153
|
+
try {
|
|
154
|
+
const body = (await (await load('acp-live-selectors')).json()) as {
|
|
155
|
+
session: {
|
|
156
|
+
harness?: string;
|
|
157
|
+
liveModels?: {
|
|
158
|
+
models: { value: string; name: string }[];
|
|
159
|
+
thinking?: { value: string; name: string }[];
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
expect(body.session.harness).toBe('claude');
|
|
164
|
+
expect(body.session.liveModels).toEqual({
|
|
165
|
+
models: [
|
|
166
|
+
{ value: 'gpt-5', name: 'GPT-5' },
|
|
167
|
+
{ value: 'gpt-5-mini', name: 'GPT-5 mini' },
|
|
168
|
+
],
|
|
169
|
+
thinking: [{ value: 'medium', name: 'Medium' }],
|
|
170
|
+
});
|
|
171
|
+
} finally {
|
|
172
|
+
release();
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* An ACP harness can own an on-disk transcript: omp's own ACP server writes
|
|
178
|
+
* the same JSONL omp RPC does. The file branch used to return without the live
|
|
179
|
+
* session's fields, so that tab published NO selectors — the picker for it
|
|
180
|
+
* could only ever list a probe snapshot instead of the list the running agent
|
|
181
|
+
* offers, and the composer named whatever model the file last recorded.
|
|
182
|
+
*/
|
|
183
|
+
test('a live ACP chat with an on-disk transcript still publishes its own selectors', async () => {
|
|
184
|
+
const id = 'acp-live-on-disk';
|
|
185
|
+
const release = registerAgent(id, {
|
|
186
|
+
model: { provider: 'claude', id: 'opus' },
|
|
187
|
+
thinkingLevel: 'high',
|
|
188
|
+
configOptions: [
|
|
189
|
+
{
|
|
190
|
+
id: 'model',
|
|
191
|
+
name: 'Model',
|
|
192
|
+
category: 'model',
|
|
193
|
+
currentValue: 'opus',
|
|
194
|
+
options: [{ value: 'opus', name: 'Opus 5.5' }],
|
|
195
|
+
},
|
|
196
|
+
],
|
|
197
|
+
});
|
|
198
|
+
try {
|
|
199
|
+
await writeSessionFile(id, [
|
|
200
|
+
{ id: 'm1', parentId: null, type: 'model_change', model: 'omp/deepseek-v4.1-flash' },
|
|
201
|
+
{ id: 'm2', parentId: 'm1', type: 'thinking_level_change', thinkingLevel: 'low' },
|
|
202
|
+
{ id: 'm3', parentId: 'm2', type: 'message', message: { role: 'user', content: 'halo' } },
|
|
203
|
+
]);
|
|
204
|
+
|
|
205
|
+
const body = (await (await load(id)).json()) as {
|
|
206
|
+
session: {
|
|
207
|
+
harness?: string;
|
|
208
|
+
model?: { provider: string; modelId: string };
|
|
209
|
+
thinkingLevel?: string;
|
|
210
|
+
liveModels?: { models: { value: string; name: string }[] };
|
|
211
|
+
};
|
|
212
|
+
source?: string;
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
// The file-backed branch, and the live halves still win over the file's.
|
|
216
|
+
expect(body.source).toBe('omp-jsonl');
|
|
217
|
+
expect(body.session.harness).toBe('claude');
|
|
218
|
+
expect(body.session.model).toEqual({ provider: 'claude', modelId: 'opus' });
|
|
219
|
+
expect(body.session.thinkingLevel).toBe('high');
|
|
220
|
+
expect(body.session.liveModels?.models).toEqual([{ value: 'opus', name: 'Opus 5.5' }]);
|
|
221
|
+
} finally {
|
|
222
|
+
release();
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
test('once the live session is gone the file answers for it', async () => {
|
|
227
|
+
const id = 'acp-dead-on-disk';
|
|
228
|
+
await writeSessionFile(id, [
|
|
229
|
+
{ id: 'm1', parentId: null, type: 'model_change', model: 'claude/sonnet' },
|
|
230
|
+
{ id: 'm2', parentId: 'm1', type: 'thinking_level_change', thinkingLevel: 'medium' },
|
|
231
|
+
]);
|
|
232
|
+
|
|
233
|
+
const body = (await (await load(id)).json()) as {
|
|
234
|
+
session: { harness?: string; model?: { provider: string; modelId: string }; liveModels?: unknown };
|
|
235
|
+
};
|
|
236
|
+
expect(body.session.harness).toBeUndefined();
|
|
237
|
+
expect(body.session.liveModels).toBeUndefined();
|
|
238
|
+
expect(body.session.model).toEqual({ provider: 'claude', modelId: 'sonnet' });
|
|
239
|
+
});
|
|
240
|
+
});
|
|
@@ -9,7 +9,11 @@ import { loadSessionMessages, loadSessionModel, loadSessionThinkingLevel, loadSe
|
|
|
9
9
|
import { mergeOmpAttachments, overlayRowsForOmpSession } from '@/server/lib/omp/session/merge-stored';
|
|
10
10
|
import { readRawHeaderLine } from '@/server/lib/omp/session/files';
|
|
11
11
|
import { formatNewSessionTitle } from '@/shared/lib/omp/session/default-title';
|
|
12
|
-
import { getLiveRunSessionIds } from '@/server/lib/omp/rpc/session-registry';
|
|
12
|
+
import { getLiveRunSessionIds, getLiveSession, harnessOfSession } from '@/server/lib/omp/rpc/session-registry';
|
|
13
|
+
import { loadStreamStates } from '@/shared/lib/omp/session/stream-state.server';
|
|
14
|
+
import { configByCategory, selectValues } from '@/server/lib/harness/launch';
|
|
15
|
+
import type { AcpConfigOption } from '@/server/lib/harness/acp/protocol';
|
|
16
|
+
import type { LiveHarnessModels } from '@/shared/types/harness';
|
|
13
17
|
|
|
14
18
|
/** Newest-message window served by default for omp JSONL sessions; the client
|
|
15
19
|
* pages further back via `?before=` when the user scrolls to the top. Large
|
|
@@ -35,6 +39,33 @@ function windowMessages<T>(
|
|
|
35
39
|
return { messages: messages.slice(start, end), total, hasMore: start > 0, oldestIndex: start };
|
|
36
40
|
}
|
|
37
41
|
|
|
42
|
+
/** What a LIVE non-omp session adds to the session payload: its resolved model,
|
|
43
|
+
* its thinking level, and the selector lists it published. */
|
|
44
|
+
interface LiveSessionMeta {
|
|
45
|
+
model?: { provider: string; modelId: string };
|
|
46
|
+
thinkingLevel?: string;
|
|
47
|
+
harness?: string;
|
|
48
|
+
liveModels?: LiveHarnessModels;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Spread into the `session` payload so every branch states these fields once.
|
|
52
|
+
* `recorded` is the last run's model from `session_stream_state`, used only
|
|
53
|
+
* when no live session can answer. */
|
|
54
|
+
function liveMetaFields(
|
|
55
|
+
liveMeta: LiveSessionMeta | null,
|
|
56
|
+
recorded?: { provider: string; modelId: string },
|
|
57
|
+
recordedThinkingLevel?: string,
|
|
58
|
+
): Record<string, unknown> {
|
|
59
|
+
const model = liveMeta?.model ?? recorded;
|
|
60
|
+
const thinkingLevel = liveMeta?.thinkingLevel ?? recordedThinkingLevel;
|
|
61
|
+
return {
|
|
62
|
+
...(model ? { model } : {}),
|
|
63
|
+
...(thinkingLevel ? { thinkingLevel } : {}),
|
|
64
|
+
...(liveMeta?.harness ? { harness: liveMeta.harness } : {}),
|
|
65
|
+
...(liveMeta?.liveModels?.models.length ? { liveModels: liveMeta.liveModels } : {}),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
38
69
|
export async function loader({ params, request }: LoaderFunctionArgs) {
|
|
39
70
|
const { sessionId } = params;
|
|
40
71
|
if (!sessionId) {
|
|
@@ -58,6 +89,44 @@ export async function loader({ params, request }: LoaderFunctionArgs) {
|
|
|
58
89
|
const limit = limitParam === 'all' ? null : (parseCount(limitParam) ?? DEFAULT_MESSAGE_WINDOW);
|
|
59
90
|
|
|
60
91
|
try {
|
|
92
|
+
// A non-omp ACP chat has no JSONL for this loader to read, and its stored
|
|
93
|
+
// row carries no model. Reopening that tab made the composer fall back to
|
|
94
|
+
// omp's catalog and name a model the agent never ran. The LIVE session's
|
|
95
|
+
// own selector is the only honest source — and `get_state` on the ACP
|
|
96
|
+
// driver is an in-process read, not a round trip to the agent.
|
|
97
|
+
let liveMeta: LiveSessionMeta | null = null;
|
|
98
|
+
if (!mock) {
|
|
99
|
+
const live = getLiveSession(sessionId);
|
|
100
|
+
if (live?.isAlive() && harnessOfSession(live) !== 'omp-rpc') {
|
|
101
|
+
const harness = harnessOfSession(live);
|
|
102
|
+
const state = (await live.send({ type: 'get_state' }).catch(() => null)) as {
|
|
103
|
+
model?: { provider?: unknown; id?: unknown };
|
|
104
|
+
thinkingLevel?: unknown;
|
|
105
|
+
configOptions?: unknown;
|
|
106
|
+
} | null;
|
|
107
|
+
const provider = typeof state?.model?.provider === 'string' ? state.model.provider : '';
|
|
108
|
+
const modelId = typeof state?.model?.id === 'string' ? state.model.id : '';
|
|
109
|
+
const selectors: AcpConfigOption[] = Array.isArray(state?.configOptions)
|
|
110
|
+
? (state.configOptions as AcpConfigOption[])
|
|
111
|
+
: [];
|
|
112
|
+
// The session's OWN selector lists, so the picker lists exactly what
|
|
113
|
+
// this agent offers — a probe is one throwaway spawn that a chat already
|
|
114
|
+
// running can contradict (codex refuses the probe while offering models).
|
|
115
|
+
const models = selectValues(configByCategory(selectors, 'model'));
|
|
116
|
+
const thinking = selectValues(configByCategory(selectors, 'thought_level'));
|
|
117
|
+
liveMeta = {
|
|
118
|
+
...(provider && modelId ? { model: { provider, modelId } } : {}),
|
|
119
|
+
...(typeof state?.thinkingLevel === 'string' && state.thinkingLevel
|
|
120
|
+
? { thinkingLevel: state.thinkingLevel }
|
|
121
|
+
: {}),
|
|
122
|
+
harness,
|
|
123
|
+
liveModels: {
|
|
124
|
+
models,
|
|
125
|
+
...(thinking.length > 0 ? { thinking } : {}),
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
}
|
|
61
130
|
// Real mode: an omp session UUID found on disk is authoritative — load its
|
|
62
131
|
// messages straight from the session JSONL file (rich timeline). The
|
|
63
132
|
// chat_sessions overlay is only for Kabmo-created sessions (mock or
|
|
@@ -93,13 +162,23 @@ export async function loader({ params, request }: LoaderFunctionArgs) {
|
|
|
93
162
|
|| (headerTimestamp ? formatNewSessionTitle(new Date(headerTimestamp)) : undefined)
|
|
94
163
|
|| `Session ${sessionId}`;
|
|
95
164
|
const win = windowMessages(overlaid, limit, before);
|
|
165
|
+
// An ACP harness can own an on-disk transcript too — omp's own ACP server
|
|
166
|
+
// writes the same JSONL — and this branch used to return without the live
|
|
167
|
+
// session's own fields. The tab then published no selectors at all, so the
|
|
168
|
+
// picker for that harness could only ever list a probe snapshot instead of
|
|
169
|
+
// the list the RUNNING agent offers (`get_state` → `configOptions`), and
|
|
170
|
+
// the composer named the file's model rather than the one in force. The
|
|
171
|
+
// live halves win; the file answers once the session is gone.
|
|
96
172
|
return json({
|
|
97
173
|
session: {
|
|
98
174
|
id: sessionId,
|
|
99
175
|
title,
|
|
100
176
|
messages: win.messages,
|
|
101
|
-
|
|
102
|
-
|
|
177
|
+
...liveMetaFields(
|
|
178
|
+
liveMeta,
|
|
179
|
+
await loadSessionModel(filePath),
|
|
180
|
+
await loadSessionThinkingLevel(filePath),
|
|
181
|
+
),
|
|
103
182
|
},
|
|
104
183
|
isMock: false,
|
|
105
184
|
source: 'omp-jsonl',
|
|
@@ -111,6 +190,12 @@ export async function loader({ params, request }: LoaderFunctionArgs) {
|
|
|
111
190
|
}
|
|
112
191
|
|
|
113
192
|
const db = await getDb();
|
|
193
|
+
// No live session (a restart, a closed tab): the last run's model is still
|
|
194
|
+
// in `session_stream_state`, and it is the only truthful identity for an
|
|
195
|
+
// ACP chat — its agent stores no model in the transcript.
|
|
196
|
+
const recordedModel = !mock && !liveMeta?.model
|
|
197
|
+
? (await loadStreamStates())[sessionId]?.model
|
|
198
|
+
: undefined;
|
|
114
199
|
let existing = await db.get('SELECT * FROM chat_sessions WHERE session_id = ?', [sessionId]);
|
|
115
200
|
|
|
116
201
|
if (!existing && mock) {
|
|
@@ -142,6 +227,7 @@ export async function loader({ params, request }: LoaderFunctionArgs) {
|
|
|
142
227
|
id: existing.session_id,
|
|
143
228
|
title: (hasDefaultTitle && firstUserContent ? firstUserContent.slice(0, 120) : existing.title) || `Session ${sessionId}`,
|
|
144
229
|
messages: parsedMessages,
|
|
230
|
+
...liveMetaFields(liveMeta, recordedModel),
|
|
145
231
|
},
|
|
146
232
|
isMock: mock,
|
|
147
233
|
});
|
|
@@ -159,7 +245,13 @@ export async function loader({ params, request }: LoaderFunctionArgs) {
|
|
|
159
245
|
[sessionId, initial.title, JSON.stringify(initial.messages)]
|
|
160
246
|
);
|
|
161
247
|
|
|
162
|
-
return json({
|
|
248
|
+
return json({
|
|
249
|
+
session: {
|
|
250
|
+
...initial,
|
|
251
|
+
...liveMetaFields(liveMeta, recordedModel),
|
|
252
|
+
},
|
|
253
|
+
isMock: mock,
|
|
254
|
+
});
|
|
163
255
|
} catch (error: any) {
|
|
164
256
|
console.error('Chat session loader error:', error);
|
|
165
257
|
return json({ error: error.message, isMock: mock }, { status: 500 });
|