@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,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The context ring's numbers for an ACP chat.
|
|
8
|
+
*
|
|
9
|
+
* ACP reports context size/used and a cost; everything else is unknown. Those
|
|
10
|
+
* fields must reach the panel, and the unknown ones must stay zero rather than
|
|
11
|
+
* be invented from a transcript that does not exist.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
15
|
+
import { buildAcpTelemetry, loadAcpUsage, saveAcpUsage, type AcpTelemetrySession } from '@/server/lib/harness/acp/acp-telemetry.server';
|
|
16
|
+
import { isolateDb, releaseDb } from '@/test-support/isolated-db';
|
|
17
|
+
|
|
18
|
+
beforeEach(async () => {
|
|
19
|
+
await isolateDb();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
afterEach(async () => {
|
|
23
|
+
await releaseDb();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const session = {
|
|
27
|
+
sessionId: 'acp-1',
|
|
28
|
+
messageCount: 7,
|
|
29
|
+
promptCount: 3,
|
|
30
|
+
assistantCount: 4,
|
|
31
|
+
contextUsage: { tokens: 12_000, contextWindow: 100_000, percent: 12 },
|
|
32
|
+
totalCost: 0.0123,
|
|
33
|
+
runModel: { provider: 'claude', modelId: 'opus' },
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
describe('buildAcpTelemetry', () => {
|
|
37
|
+
test('maps the usage ACP reports and the counts the session tracks', () => {
|
|
38
|
+
const telemetry = buildAcpTelemetry(session, 'Fix the importer');
|
|
39
|
+
expect(telemetry).toMatchObject({
|
|
40
|
+
sessionId: 'acp-1',
|
|
41
|
+
sessionTitle: 'Fix the importer',
|
|
42
|
+
modelId: 'claude/opus',
|
|
43
|
+
modelName: 'opus',
|
|
44
|
+
contextUsed: 12_000,
|
|
45
|
+
contextLimit: 100_000,
|
|
46
|
+
contextPercent: 12,
|
|
47
|
+
messagesCount: 7,
|
|
48
|
+
userCount: 3,
|
|
49
|
+
assistantCount: 4,
|
|
50
|
+
totalCost: 0.0123,
|
|
51
|
+
costFormatted: '$0.0123',
|
|
52
|
+
});
|
|
53
|
+
expect(telemetry.rawMessages).toEqual([]);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test('a session that has not reported usage shows zero, never a fake split', () => {
|
|
57
|
+
const telemetry = buildAcpTelemetry(
|
|
58
|
+
{ ...session, contextUsage: null, totalCost: 0, messageCount: 1, promptCount: 1, assistantCount: 0 },
|
|
59
|
+
null,
|
|
60
|
+
);
|
|
61
|
+
expect(telemetry).toMatchObject({
|
|
62
|
+
sessionTitle: 'Session',
|
|
63
|
+
contextUsed: 0,
|
|
64
|
+
contextLimit: 0,
|
|
65
|
+
contextPercent: 0,
|
|
66
|
+
totalCost: 0,
|
|
67
|
+
});
|
|
68
|
+
expect(telemetry.lastMessage.input).toBe(0);
|
|
69
|
+
expect(telemetry.distribution.userTokens).toBe(0);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test('the last usage snapshot survives the process', async () => {
|
|
73
|
+
await saveAcpUsage(session as AcpTelemetrySession);
|
|
74
|
+
const stored = await loadAcpUsage('acp-1');
|
|
75
|
+
expect(stored).toMatchObject({
|
|
76
|
+
sessionId: 'acp-1',
|
|
77
|
+
messageCount: 7,
|
|
78
|
+
promptCount: 3,
|
|
79
|
+
assistantCount: 4,
|
|
80
|
+
contextUsage: { tokens: 12_000, contextWindow: 100_000, percent: 12 },
|
|
81
|
+
totalCost: 0.0123,
|
|
82
|
+
runModel: { provider: 'claude', modelId: 'opus' },
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The Todos panel for an ACP chat.
|
|
8
|
+
*
|
|
9
|
+
* ACP's `plan` update is the agent's own task list — the same idea omp stores in
|
|
10
|
+
* a `todo` tool result, which the panel reads from a transcript this transport
|
|
11
|
+
* does not write. Mapping it here means the same panel renders both transports
|
|
12
|
+
* instead of saying "the agent never used todos" over a full plan.
|
|
13
|
+
*
|
|
14
|
+
* The spec's entries carry `content` + `status`; priority and unknown statuses
|
|
15
|
+
* are ignored rather than guessed.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import type { SessionTodoState, TodoItem, TodoPhase, TodoStatus } from '@/shared/types/todo';
|
|
19
|
+
import { todoProgress } from '@/shared/lib/chat/todo/snapshot';
|
|
20
|
+
|
|
21
|
+
function statusOf(value: unknown): TodoStatus {
|
|
22
|
+
return value === 'completed' || value === 'in_progress' || value === 'pending' ? value : 'pending';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Map the agent's plan entries into the payload the Todos panel consumes. */
|
|
26
|
+
export function buildAcpTodos(entries: readonly unknown[]): SessionTodoState {
|
|
27
|
+
const tasks: TodoItem[] = [];
|
|
28
|
+
for (const entry of entries) {
|
|
29
|
+
if (!entry || typeof entry !== 'object') continue;
|
|
30
|
+
const record = entry as Record<string, unknown>;
|
|
31
|
+
if (typeof record.content !== 'string' || !record.content.trim()) continue;
|
|
32
|
+
tasks.push({ content: record.content, status: statusOf(record.status) });
|
|
33
|
+
}
|
|
34
|
+
if (tasks.length === 0) return { snapshot: null, progress: todoProgress([]) };
|
|
35
|
+
const phases: TodoPhase[] = [{ name: 'Plan', tasks }];
|
|
36
|
+
return {
|
|
37
|
+
snapshot: {
|
|
38
|
+
phases,
|
|
39
|
+
sourceEntryId: 'acp-plan',
|
|
40
|
+
source: 'custom',
|
|
41
|
+
updatedAt: new Date().toISOString(),
|
|
42
|
+
},
|
|
43
|
+
progress: todoProgress(phases),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* ACP `plan` entries as the Todos panel reads them.
|
|
8
|
+
*
|
|
9
|
+
* The panel has one payload shape for both transports; an entry it cannot
|
|
10
|
+
* classify is pending, never dropped or invented as done.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { describe, expect, test } from 'bun:test';
|
|
14
|
+
import { buildAcpTodos } from '@/server/lib/harness/acp/acp-todos.server';
|
|
15
|
+
|
|
16
|
+
describe('buildAcpTodos', () => {
|
|
17
|
+
test('maps content and status into one phase with a real roll-up', () => {
|
|
18
|
+
const state = buildAcpTodos([
|
|
19
|
+
{ content: 'Read the loader', status: 'completed' },
|
|
20
|
+
{ content: 'Extract the parser', status: 'in_progress' },
|
|
21
|
+
{ content: 'Run the suite', status: 'pending' },
|
|
22
|
+
]);
|
|
23
|
+
expect(state.snapshot?.phases).toEqual([{
|
|
24
|
+
name: 'Plan',
|
|
25
|
+
tasks: [
|
|
26
|
+
{ content: 'Read the loader', status: 'completed' },
|
|
27
|
+
{ content: 'Extract the parser', status: 'in_progress' },
|
|
28
|
+
{ content: 'Run the suite', status: 'pending' },
|
|
29
|
+
],
|
|
30
|
+
}]);
|
|
31
|
+
expect(state.progress).toMatchObject({ total: 3, completed: 1, inProgress: 1, pending: 1 });
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test('an empty or malformed plan is no snapshot, not an empty phase', () => {
|
|
35
|
+
expect(buildAcpTodos([]).snapshot).toBeNull();
|
|
36
|
+
expect(buildAcpTodos([{ status: 'completed' }, null, 7]).snapshot).toBeNull();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test('an unknown status reads pending rather than completed', () => {
|
|
40
|
+
const state = buildAcpTodos([{ content: 'Do it', status: 'weird' }]);
|
|
41
|
+
expect(state.snapshot?.phases[0]?.tasks[0]?.status).toBe('pending');
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The wait that turns opencode's five-second plugin-activation refusal into a
|
|
8
|
+
* session, without turning a real refusal into a two-minute hang.
|
|
9
|
+
*
|
|
10
|
+
* Measured on 2.2.5: `session/new` answered `ServiceUnavailableError` at +6 s
|
|
11
|
+
* while the Claude-bridge plugin list was still activating, and the same
|
|
12
|
+
* process answered a real session at +80 s.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { describe, expect, test } from 'bun:test';
|
|
16
|
+
import {
|
|
17
|
+
newSessionAfterActivation,
|
|
18
|
+
pluginActivationPending,
|
|
19
|
+
} from '@/server/lib/harness/acp/activation';
|
|
20
|
+
|
|
21
|
+
const pending = () => new Error(
|
|
22
|
+
'Internal error: Internal service failure: {"errorName":"ServiceUnavailableError"}',
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
describe('pluginActivationPending', () => {
|
|
26
|
+
test('names the wire error the transport folds into the message', () => {
|
|
27
|
+
expect(pluginActivationPending(pending())).toBe(true);
|
|
28
|
+
expect(pluginActivationPending(new Error('Authentication required'))).toBe(false);
|
|
29
|
+
expect(pluginActivationPending('ServiceUnavailableError')).toBe(true);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
describe('newSessionAfterActivation', () => {
|
|
34
|
+
test('retries the same process while opencode activates its plugins', async () => {
|
|
35
|
+
let calls = 0;
|
|
36
|
+
const result = await newSessionAfterActivation(
|
|
37
|
+
'opencode',
|
|
38
|
+
'/tmp/work',
|
|
39
|
+
async (cwd, timeoutMs) => {
|
|
40
|
+
calls += 1;
|
|
41
|
+
expect(cwd).toBe('/tmp/work');
|
|
42
|
+
expect(timeoutMs).toBe(120_000);
|
|
43
|
+
if (calls < 3) throw pending();
|
|
44
|
+
return { sessionId: 'ses_1' };
|
|
45
|
+
},
|
|
46
|
+
{ retryMs: 1 },
|
|
47
|
+
);
|
|
48
|
+
expect(result.sessionId).toBe('ses_1');
|
|
49
|
+
expect(calls).toBe(3);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test('a non-activation refusal is final', async () => {
|
|
53
|
+
let calls = 0;
|
|
54
|
+
const failure = newSessionAfterActivation('opencode', '/tmp/work', async () => {
|
|
55
|
+
calls += 1;
|
|
56
|
+
throw new Error('Authentication required');
|
|
57
|
+
});
|
|
58
|
+
await expect(failure).rejects.toThrow('Authentication required');
|
|
59
|
+
expect(calls).toBe(1);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test('other harnesses are never retried', async () => {
|
|
63
|
+
let calls = 0;
|
|
64
|
+
const failure = newSessionAfterActivation('omp-acp', '/tmp/work', async () => {
|
|
65
|
+
calls += 1;
|
|
66
|
+
throw pending();
|
|
67
|
+
}, { retryMs: 1 });
|
|
68
|
+
await expect(failure).rejects.toThrow('ServiceUnavailableError');
|
|
69
|
+
expect(calls).toBe(1);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test('a plugin that never activates still ends in a stated refusal', async () => {
|
|
73
|
+
let calls = 0;
|
|
74
|
+
const failure = newSessionAfterActivation('opencode', '/tmp/work', async () => {
|
|
75
|
+
calls += 1;
|
|
76
|
+
throw pending();
|
|
77
|
+
}, { retryMs: 1, totalMs: 0 });
|
|
78
|
+
await expect(failure).rejects.toThrow('plugin activation did not finish within 0s');
|
|
79
|
+
expect(calls).toBe(1);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Wait out opencode's plugin activation before asking it for a session.
|
|
8
|
+
*
|
|
9
|
+
* opencode 2.x boots "Location plugins" per directory asynchronously and guards
|
|
10
|
+
* every request that needs them with a HARD five-second wait
|
|
11
|
+
* (`Location plugins did not finish activating` -> `ServiceUnavailableError`).
|
|
12
|
+
* The activation itself is unbounded: measured 2.2.5 on a real config, one
|
|
13
|
+
* Claude-bridge plugin finished at ~30 s and the full plugin list at ~80 s, so a
|
|
14
|
+
* single `session/new` answered at +6 s with `ServiceUnavailableError` and the
|
|
15
|
+
* probe card read as blocked while the agent was still booting.
|
|
16
|
+
*
|
|
17
|
+
* Retrying the SAME process is the fix, not respawning: the activation is
|
|
18
|
+
* per-process state, and a fresh agent restarts the clock. The wait is bounded
|
|
19
|
+
* because a plugin that never settles must still end in a refusal, with a
|
|
20
|
+
* reason the settings card can show.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import type { AcpSessionNewResult } from '@/server/lib/harness/acp/protocol';
|
|
24
|
+
import type { HarnessId } from '@/shared/lib/harness/catalog';
|
|
25
|
+
|
|
26
|
+
/** Enough headroom over the measured 80 s, not an open-ended probe. */
|
|
27
|
+
export const ACTIVATION_TIMEOUT_MS = 150_000;
|
|
28
|
+
/** Each retry only needs to let the five-second gate expire. */
|
|
29
|
+
const ACTIVATION_RETRY_MS = 3_000;
|
|
30
|
+
|
|
31
|
+
/** Is this the agent's "plugins are still activating" refusal? The ACP error
|
|
32
|
+
* carries the name in `data`, which the transport folds into the message. */
|
|
33
|
+
export function pluginActivationPending(error: unknown): boolean {
|
|
34
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
35
|
+
return message.includes('ServiceUnavailableError');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface ActivationWait {
|
|
39
|
+
totalMs?: number;
|
|
40
|
+
retryMs?: number;
|
|
41
|
+
perAttemptMs?: number;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* `session/new`, retried while opencode reports pending plugin activation.
|
|
46
|
+
*
|
|
47
|
+
* Only opencode has this gate. Every other harness's first refusal is final —
|
|
48
|
+
* retrying an `Authentication required` would hide it behind a two-minute wait.
|
|
49
|
+
*/
|
|
50
|
+
export async function newSessionAfterActivation(
|
|
51
|
+
harness: HarnessId,
|
|
52
|
+
cwd: string,
|
|
53
|
+
newSession: (cwd: string, timeoutMs?: number) => Promise<AcpSessionNewResult>,
|
|
54
|
+
wait: ActivationWait = {},
|
|
55
|
+
): Promise<AcpSessionNewResult> {
|
|
56
|
+
const { totalMs = ACTIVATION_TIMEOUT_MS, retryMs = ACTIVATION_RETRY_MS, perAttemptMs = 120_000 } = wait;
|
|
57
|
+
if (harness !== 'opencode') return newSession(cwd, perAttemptMs);
|
|
58
|
+
|
|
59
|
+
const giveUpAt = Date.now() + totalMs;
|
|
60
|
+
for (;;) {
|
|
61
|
+
try {
|
|
62
|
+
return await newSession(cwd, perAttemptMs);
|
|
63
|
+
} catch (error) {
|
|
64
|
+
if (!pluginActivationPending(error)) throw error;
|
|
65
|
+
if (Date.now() >= giveUpAt) {
|
|
66
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
67
|
+
throw new Error(`${reason} (plugin activation did not finish within ${Math.round(totalMs / 1000)}s)`);
|
|
68
|
+
}
|
|
69
|
+
await Bun.sleep(retryMs);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The client→agent calls that are waiting for an answer.
|
|
8
|
+
*
|
|
9
|
+
* Split out of `AcpProcess` because a request that is never answered is its own
|
|
10
|
+
* subject — it is the difference between a Stop that works and one that does
|
|
11
|
+
* not:
|
|
12
|
+
*
|
|
13
|
+
* - a `session/prompt` runs for minutes, so its timer is disabled entirely;
|
|
14
|
+
* - `session/cancel` is a notification, so an agent may end a turn and never
|
|
15
|
+
* answer the prompt it was given, and `abandonPrompt` settles that call
|
|
16
|
+
* locally instead of leaving it open for the life of the process.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import type { AcpId, AcpResponse } from '@/server/lib/harness/acp/protocol';
|
|
20
|
+
|
|
21
|
+
export interface Pending {
|
|
22
|
+
resolve: (value: unknown) => void;
|
|
23
|
+
reject: (error: Error) => void;
|
|
24
|
+
timer?: NodeJS.Timeout;
|
|
25
|
+
/** What was asked, so `abandonPrompt` can find the one prompt a session has
|
|
26
|
+
* open without guessing an id. */
|
|
27
|
+
method: string;
|
|
28
|
+
params: Record<string, unknown>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export class PendingCalls {
|
|
32
|
+
private readonly map = new Map<AcpId, Pending>();
|
|
33
|
+
|
|
34
|
+
/** Track one call. `budgetMs` of 0 means "no timer" — a whole turn. */
|
|
35
|
+
begin<T>(id: AcpId, method: string, params: unknown, budgetMs: number): Promise<T> {
|
|
36
|
+
const { promise, resolve, reject } = Promise.withResolvers<T>();
|
|
37
|
+
const entry: Pending = {
|
|
38
|
+
resolve: resolve as (value: unknown) => void,
|
|
39
|
+
reject,
|
|
40
|
+
method,
|
|
41
|
+
params: (params ?? {}) as Record<string, unknown>,
|
|
42
|
+
};
|
|
43
|
+
if (budgetMs > 0) {
|
|
44
|
+
entry.timer = setTimeout(() => {
|
|
45
|
+
if (this.map.get(id) !== entry) return;
|
|
46
|
+
this.map.delete(id);
|
|
47
|
+
reject(new Error(`ACP ${method} timed out after ${budgetMs}ms`));
|
|
48
|
+
}, budgetMs);
|
|
49
|
+
entry.timer.unref?.();
|
|
50
|
+
}
|
|
51
|
+
this.map.set(id, entry);
|
|
52
|
+
return promise;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Answer an incoming frame. False when nobody is waiting on that id, which is
|
|
56
|
+
* the normal fate of a reply to a call that was abandoned. */
|
|
57
|
+
settle(response: AcpResponse): boolean {
|
|
58
|
+
const entry = this.map.get(response.id);
|
|
59
|
+
if (!entry) return false;
|
|
60
|
+
this.map.delete(response.id);
|
|
61
|
+
clearTimeout(entry.timer);
|
|
62
|
+
if (response.error) {
|
|
63
|
+
entry.reject(new Error(
|
|
64
|
+
`${response.error.message}${response.error.data ? `: ${JSON.stringify(response.error.data)}` : ''}`,
|
|
65
|
+
));
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
entry.resolve(response.result);
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Settle a session's open `session/prompt`, as cancelled.
|
|
74
|
+
*
|
|
75
|
+
* The ACP spec asks the agent to answer a cancelled prompt with
|
|
76
|
+
* `stopReason: "cancelled"`, and omp does not always: the request stayed open
|
|
77
|
+
* for the life of the process, so every later turn — chained behind it — was
|
|
78
|
+
* refused as "already processing".
|
|
79
|
+
*/
|
|
80
|
+
abandonPrompt(sessionId: string): void {
|
|
81
|
+
for (const [id, entry] of this.map) {
|
|
82
|
+
if (entry.method !== 'session/prompt') continue;
|
|
83
|
+
if (String(entry.params.sessionId ?? '') !== sessionId) continue;
|
|
84
|
+
this.map.delete(id);
|
|
85
|
+
clearTimeout(entry.timer);
|
|
86
|
+
entry.resolve({ stopReason: 'cancelled' });
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
rejectAll(error: Error): void {
|
|
91
|
+
for (const [id, entry] of this.map) {
|
|
92
|
+
this.map.delete(id);
|
|
93
|
+
clearTimeout(entry.timer);
|
|
94
|
+
entry.reject(error);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* What `cancel` puts ON THE WIRE.
|
|
8
|
+
*
|
|
9
|
+
* `session/cancel` is a JSON-RPC NOTIFICATION, so nothing awaits it and a
|
|
10
|
+
* failure to write it is invisible: the Stop button answered 500 from inside
|
|
11
|
+
* `notify` (`undefined is not an object (evaluating 'this.write')`, because the
|
|
12
|
+
* method reference lost its receiver) and the turn kept running. The transport
|
|
13
|
+
* here is a real child that ECHOES every frame back, so the assertion is made
|
|
14
|
+
* on what actually crossed the pipe — a stubbed `write` would have hidden the
|
|
15
|
+
* defect, and a timer would have turned a missing frame into a flake.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { afterEach, expect, test } from 'bun:test';
|
|
19
|
+
import { mkdtemp, rm } from 'node:fs/promises';
|
|
20
|
+
import { tmpdir } from 'node:os';
|
|
21
|
+
import { join } from 'node:path';
|
|
22
|
+
import { AcpProcess } from '@/server/lib/harness/acp/client';
|
|
23
|
+
import { describePosix } from '@/test-support/platform';
|
|
24
|
+
|
|
25
|
+
const launched: AcpProcess[] = [];
|
|
26
|
+
const scratch: string[] = [];
|
|
27
|
+
|
|
28
|
+
interface Mounted {
|
|
29
|
+
proc: AcpProcess;
|
|
30
|
+
/** Resolves with the params of the first notification of `method`. */
|
|
31
|
+
seen: (method: string) => Promise<Record<string, unknown>>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async function mountProcess(): Promise<Mounted> {
|
|
35
|
+
const dir = await mkdtemp(join(tmpdir(), 'kabmo-acp-cancel-'));
|
|
36
|
+
scratch.push(dir);
|
|
37
|
+
const waiting = new Map<string, (params: Record<string, unknown>) => void>();
|
|
38
|
+
const proc = new AcpProcess({
|
|
39
|
+
// Echo each frame verbatim, so a notification comes back as one.
|
|
40
|
+
command: ['/bin/sh', '-c', 'while IFS= read -r line; do printf "%s\\n" "$line"; done'],
|
|
41
|
+
cwd: dir,
|
|
42
|
+
onNotification: (method, params) => waiting.get(method)?.(params),
|
|
43
|
+
});
|
|
44
|
+
launched.push(proc);
|
|
45
|
+
return {
|
|
46
|
+
proc,
|
|
47
|
+
seen: (method) =>
|
|
48
|
+
new Promise((resolve) => {
|
|
49
|
+
waiting.set(method, resolve);
|
|
50
|
+
}),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
afterEach(async () => {
|
|
55
|
+
await Promise.all(launched.splice(0).map((proc) => proc.dispose(0)));
|
|
56
|
+
await Promise.all(scratch.splice(0).map((dir) => rm(dir, { recursive: true, force: true })));
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// POSIX only: the transport below is a real `/bin/sh` echo loop, and Windows
|
|
60
|
+
// has no `/bin/sh` — the suite died at `new AcpProcess` with
|
|
61
|
+
// `ENOENT: uv_spawn '/bin/sh'` on the Windows gate. A Windows-shaped echo child
|
|
62
|
+
// would be a different program asserting the same frames.
|
|
63
|
+
describePosix('ACP cancel', () => {
|
|
64
|
+
test('writes session/cancel for the session it was given', async () => {
|
|
65
|
+
const { proc, seen } = await mountProcess();
|
|
66
|
+
const echoed = seen('session/cancel');
|
|
67
|
+
proc.cancel('acp-cancel-1');
|
|
68
|
+
|
|
69
|
+
// The frame carries no `id`: a cancel is a notification, and one carrying an
|
|
70
|
+
// id would leave a pending reply nobody consumes.
|
|
71
|
+
expect(await echoed).toEqual({ sessionId: 'acp-cancel-1' });
|
|
72
|
+
});
|
|
73
|
+
});
|