@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,273 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Goal mode without omp's `/kabmo-mode` extension.
|
|
8
|
+
*
|
|
9
|
+
* A non-omp ACP agent has no extension to hold a goal record, and `omp-acp`'s
|
|
10
|
+
* extension lives in a transcript this transport cannot re-read reliably. So
|
|
11
|
+
* Kabmo owns the record here: the composer's actions write this row, the goal
|
|
12
|
+
* driver reads it after every turn, and the modes route answers from it when
|
|
13
|
+
* the process is gone.
|
|
14
|
+
*
|
|
15
|
+
* This is the SAME record shape omp publishes, which is what lets the existing
|
|
16
|
+
* composer strip, markers and reload logic work unchanged. What differs is who
|
|
17
|
+
* opens the continuation turn: the extension's hidden custom message is not
|
|
18
|
+
* available on another agent, so the driver sends a visible prompt.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import {
|
|
22
|
+
KABMO_GOAL_CONTINUATION_MARKER,
|
|
23
|
+
KABMO_GOAL_STATE_MARKER,
|
|
24
|
+
KABMO_MODE_ERROR_MARKER,
|
|
25
|
+
type GoalContinuation,
|
|
26
|
+
type GoalContinuationStop,
|
|
27
|
+
type GoalRecord,
|
|
28
|
+
} from '@/shared/lib/omp/mode/types';
|
|
29
|
+
import type { ModeRequest } from '@/server/lib/omp/mode/request';
|
|
30
|
+
import {
|
|
31
|
+
DEFAULT_GOAL_MAX_TURNS,
|
|
32
|
+
loadAcpGoalState,
|
|
33
|
+
saveAcpGoalState,
|
|
34
|
+
type AcpGoalState,
|
|
35
|
+
} from '@/server/lib/harness/acp/acp-goal-state.server';
|
|
36
|
+
import { notePromptTitle } from '@/server/lib/harness/session-title.server';
|
|
37
|
+
import type { HarnessId } from '@/shared/lib/harness/catalog';
|
|
38
|
+
|
|
39
|
+
/** The process surface these actions drive. `AcpSession` satisfies it. */
|
|
40
|
+
export interface AcpGoalHost {
|
|
41
|
+
readonly sessionId: string;
|
|
42
|
+
readonly harness: HarnessId;
|
|
43
|
+
readonly cwd: string;
|
|
44
|
+
readonly runModel: { provider: string; modelId: string } | null;
|
|
45
|
+
/** Context tokens completed turns measured, when the driver can know them. */
|
|
46
|
+
readonly usageTokens?: number;
|
|
47
|
+
/** A new goal starts its budget from zero. */
|
|
48
|
+
resetUsageTokens?: () => void;
|
|
49
|
+
isAlive(): boolean;
|
|
50
|
+
isBusy(): boolean;
|
|
51
|
+
send(command: Record<string, unknown>): Promise<unknown>;
|
|
52
|
+
emit(event: Record<string, unknown> & { type: string }): void;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Send one mode marker through the session's own frame stream. The client's
|
|
56
|
+
* fold parses `extension_ui_request`/`notify` exactly as it does for omp. */
|
|
57
|
+
export function emitModeMarker(host: AcpGoalHost, marker: string, payload: unknown): void {
|
|
58
|
+
host.emit({ type: 'extension_ui_request', method: 'notify', message: `${marker}${JSON.stringify(payload)}` });
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Publish the goal record (and its loop verdict) to the composer. */
|
|
62
|
+
export function emitGoalState(host: AcpGoalHost, state: AcpGoalState): void {
|
|
63
|
+
emitModeMarker(host, KABMO_GOAL_STATE_MARKER, {
|
|
64
|
+
goal: state.record,
|
|
65
|
+
enabled: state.record?.status === 'active',
|
|
66
|
+
...(state.continuation ? { continuation: state.continuation } : {}),
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function emitError(host: AcpGoalHost, reason: string): void {
|
|
71
|
+
emitModeMarker(host, KABMO_MODE_ERROR_MARKER, { scope: 'goal', reason });
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** The first turn of a goal created by Kabmo itself. */
|
|
75
|
+
export function goalKickoffPrompt(objective: string): string {
|
|
76
|
+
return [
|
|
77
|
+
'You are now working toward a goal that Kabmo will track across turns.',
|
|
78
|
+
'',
|
|
79
|
+
`Goal: ${objective}`,
|
|
80
|
+
'',
|
|
81
|
+
'Start now. Work until every part of the goal is done, then end with a short report of what you completed and what remains (if anything).',
|
|
82
|
+
].join('\n');
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** The instruction the driver sends after the auditor says "keep going". */
|
|
86
|
+
export function goalContinuationPrompt(objective: string): string {
|
|
87
|
+
return [
|
|
88
|
+
'Continue working toward the active goal.',
|
|
89
|
+
'',
|
|
90
|
+
`Goal: ${objective}`,
|
|
91
|
+
'',
|
|
92
|
+
'Pick up where you left off. Do not repeat finished work. End with a short report of what you completed and what remains.',
|
|
93
|
+
].join('\n');
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function freshRecord(objective: string, tokenBudget?: number): GoalRecord {
|
|
97
|
+
const now = Date.now();
|
|
98
|
+
return {
|
|
99
|
+
id: `acp-goal-${crypto.randomUUID()}`,
|
|
100
|
+
objective,
|
|
101
|
+
status: 'active',
|
|
102
|
+
...(tokenBudget === undefined ? {} : { tokenBudget }),
|
|
103
|
+
tokensUsed: 0,
|
|
104
|
+
timeUsedSeconds: 0,
|
|
105
|
+
createdAt: now,
|
|
106
|
+
updatedAt: now,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** A goal whose status still blocks a new one (omp refuses these too). */
|
|
111
|
+
function blocksCreate(status: GoalRecord['status']): boolean {
|
|
112
|
+
return status === 'active' || status === 'paused' || status === 'budget-limited';
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
async function sendContinuation(host: AcpGoalHost, state: AcpGoalState): Promise<void> {
|
|
116
|
+
if (!state.record || state.record.status !== 'active') return;
|
|
117
|
+
if (host.isBusy()) return;
|
|
118
|
+
const used = host.usageTokens ?? state.record.tokensUsed;
|
|
119
|
+
if (state.record.tokenBudget !== undefined && used >= state.record.tokenBudget) {
|
|
120
|
+
await finishAcpGoal(host, 'budget');
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const maxTurns = state.maxTurns ?? DEFAULT_GOAL_MAX_TURNS;
|
|
124
|
+
if (state.turns >= maxTurns) {
|
|
125
|
+
await finishAcpGoal(host, 'max-turns');
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const turns = state.turns + 1;
|
|
129
|
+
const record = state.record
|
|
130
|
+
? {
|
|
131
|
+
...state.record,
|
|
132
|
+
tokensUsed: host.usageTokens ?? state.record.tokensUsed,
|
|
133
|
+
updatedAt: Date.now(),
|
|
134
|
+
timeUsedSeconds: Math.max(0, Math.round((Date.now() - state.record.createdAt) / 1000)),
|
|
135
|
+
}
|
|
136
|
+
: state.record;
|
|
137
|
+
const next = { ...state, record, turns, continuation: { turn: turns, maxTurns } };
|
|
138
|
+
await saveAcpGoalState(host.sessionId, next);
|
|
139
|
+
emitModeMarker(host, KABMO_GOAL_CONTINUATION_MARKER, { turn: turns, maxTurns });
|
|
140
|
+
try {
|
|
141
|
+
await host.send({ type: 'prompt', message: goalContinuationPrompt(state.record.objective), synthetic: true });
|
|
142
|
+
} catch (error) {
|
|
143
|
+
// A queued delivery or a dialog took the slot between the check and the
|
|
144
|
+
// send. The next turn end drives again, so this is not a stopped goal.
|
|
145
|
+
if (!host.isAlive()) return;
|
|
146
|
+
emitError(host, error instanceof Error ? error.message : String(error));
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** Continue the active goal from whatever row is on disk now. */
|
|
151
|
+
export async function continueAcpGoal(host: AcpGoalHost): Promise<void> {
|
|
152
|
+
const state = await loadAcpGoalState(host.sessionId);
|
|
153
|
+
await sendContinuation(host, state);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** Close the loop with a verdict; every stop but `complete` stays resumable. */
|
|
157
|
+
export async function finishAcpGoal(host: AcpGoalHost, stopped: GoalContinuationStop): Promise<void> {
|
|
158
|
+
const state = await loadAcpGoalState(host.sessionId);
|
|
159
|
+
if (!state.record) return;
|
|
160
|
+
const maxTurns = state.maxTurns ?? DEFAULT_GOAL_MAX_TURNS;
|
|
161
|
+
const continuation: GoalContinuation = { turn: Math.max(1, state.turns), maxTurns, stopped };
|
|
162
|
+
const record: GoalRecord = {
|
|
163
|
+
...state.record,
|
|
164
|
+
status: stopped === 'complete' ? 'complete' : stopped === 'budget' ? 'budget-limited' : 'paused',
|
|
165
|
+
tokensUsed: host.usageTokens ?? state.record.tokensUsed,
|
|
166
|
+
updatedAt: Date.now(),
|
|
167
|
+
timeUsedSeconds: Math.max(0, Math.round((Date.now() - state.record.createdAt) / 1000)),
|
|
168
|
+
};
|
|
169
|
+
const next = { ...state, record, continuation };
|
|
170
|
+
await saveAcpGoalState(host.sessionId, next);
|
|
171
|
+
emitModeMarker(host, KABMO_GOAL_CONTINUATION_MARKER, continuation);
|
|
172
|
+
emitGoalState(host, next);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** Apply one goal action from the composer's mode channel. */
|
|
176
|
+
export async function applyAcpGoalAction(
|
|
177
|
+
host: AcpGoalHost,
|
|
178
|
+
request: ModeRequest,
|
|
179
|
+
): Promise<{ ok: true; data: unknown } | { ok: false; error: string }> {
|
|
180
|
+
const payload = request.payload ?? {};
|
|
181
|
+
const state = await loadAcpGoalState(host.sessionId);
|
|
182
|
+
|
|
183
|
+
if (request.action === 'state') {
|
|
184
|
+
return { ok: true, data: { enabled: state.record?.status === 'active', goal: state.record } };
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (request.action === 'create' || request.action === 'guided') {
|
|
188
|
+
const guided = request.action === 'guided';
|
|
189
|
+
const objective = guided
|
|
190
|
+
? String(payload.message ?? payload.rough ?? '').trim()
|
|
191
|
+
: String(payload.objective ?? '').trim();
|
|
192
|
+
if (!objective) return { ok: false, error: 'an objective is required' };
|
|
193
|
+
if (state.record && blocksCreate(state.record.status)) {
|
|
194
|
+
if (state.record.status === 'paused') {
|
|
195
|
+
const resumed = { ...state, record: { ...state.record, status: 'active' as const, updatedAt: Date.now() }, continuation: null, turns: 0 };
|
|
196
|
+
await saveAcpGoalState(host.sessionId, resumed);
|
|
197
|
+
emitGoalState(host, resumed);
|
|
198
|
+
if (payload.startTurn !== false) setTimeout(() => void continueAcpGoal(host), 250);
|
|
199
|
+
return { ok: true, data: { goal: resumed.record, enabled: true } };
|
|
200
|
+
}
|
|
201
|
+
return { ok: false, error: 'this session already has a goal' };
|
|
202
|
+
}
|
|
203
|
+
const budget = typeof payload.tokenBudget === 'number' && Number.isInteger(payload.tokenBudget) && payload.tokenBudget > 0
|
|
204
|
+
? payload.tokenBudget
|
|
205
|
+
: undefined;
|
|
206
|
+
const maxTurns = typeof payload.maxTurns === 'number' && Number.isInteger(payload.maxTurns) && payload.maxTurns > 0
|
|
207
|
+
? payload.maxTurns
|
|
208
|
+
: null;
|
|
209
|
+
host.resetUsageTokens?.();
|
|
210
|
+
const record = freshRecord(objective, budget);
|
|
211
|
+
const next: AcpGoalState = { ...state, record, continuation: null, maxTurns, turns: 0 };
|
|
212
|
+
await saveAcpGoalState(host.sessionId, next);
|
|
213
|
+
// The goal's own name is a better chat title than the kickoff boilerplate.
|
|
214
|
+
void notePromptTitle(host.sessionId, objective);
|
|
215
|
+
emitGoalState(host, next);
|
|
216
|
+
if (payload.startTurn !== false) {
|
|
217
|
+
await host.send({ type: 'prompt', message: goalKickoffPrompt(objective), synthetic: true });
|
|
218
|
+
}
|
|
219
|
+
return { ok: true, data: { goal: record, enabled: true } };
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (!state.record) return { ok: false, error: 'there is no goal in this chat' };
|
|
223
|
+
|
|
224
|
+
switch (request.action) {
|
|
225
|
+
case 'pause': {
|
|
226
|
+
const next = { ...state, record: { ...state.record, status: 'paused' as const, updatedAt: Date.now() } };
|
|
227
|
+
await saveAcpGoalState(host.sessionId, next);
|
|
228
|
+
emitGoalState(host, next);
|
|
229
|
+
return { ok: true, data: { goal: next.record, enabled: false } };
|
|
230
|
+
}
|
|
231
|
+
case 'resume': {
|
|
232
|
+
const next = {
|
|
233
|
+
...state,
|
|
234
|
+
record: { ...state.record, status: 'active' as const, updatedAt: Date.now() },
|
|
235
|
+
continuation: null,
|
|
236
|
+
turns: 0,
|
|
237
|
+
};
|
|
238
|
+
await saveAcpGoalState(host.sessionId, next);
|
|
239
|
+
emitGoalState(host, next);
|
|
240
|
+
setTimeout(() => void continueAcpGoal(host), 250);
|
|
241
|
+
return { ok: true, data: { goal: next.record, enabled: true } };
|
|
242
|
+
}
|
|
243
|
+
case 'drop': {
|
|
244
|
+
const next = { ...state, record: { ...state.record, status: 'dropped' as const, updatedAt: Date.now() }, continuation: null };
|
|
245
|
+
await saveAcpGoalState(host.sessionId, next);
|
|
246
|
+
emitGoalState(host, next);
|
|
247
|
+
return { ok: true, data: { goal: next.record, enabled: false } };
|
|
248
|
+
}
|
|
249
|
+
case 'budget': {
|
|
250
|
+
const value = payload.value;
|
|
251
|
+
const tokenBudget = typeof value === 'number' && Number.isInteger(value) && value > 0 ? value : undefined;
|
|
252
|
+
const record = { ...state.record, tokenBudget, updatedAt: Date.now() };
|
|
253
|
+
if (tokenBudget === undefined) delete (record as { tokenBudget?: number }).tokenBudget;
|
|
254
|
+
const next = { ...state, record };
|
|
255
|
+
await saveAcpGoalState(host.sessionId, next);
|
|
256
|
+
emitGoalState(host, next);
|
|
257
|
+
return { ok: true, data: { goal: next.record, enabled: record.status === 'active' } };
|
|
258
|
+
}
|
|
259
|
+
case 'done': {
|
|
260
|
+
const stopped = payload.stopped;
|
|
261
|
+
const reason = stopped === 'budget' || stopped === 'max-turns' || stopped === 'blocked' || stopped === 'complete' || stopped === 'audit-failed'
|
|
262
|
+
? stopped
|
|
263
|
+
: 'complete';
|
|
264
|
+
await finishAcpGoal(host, reason);
|
|
265
|
+
return { ok: true, data: { goal: (await loadAcpGoalState(host.sessionId)).record } };
|
|
266
|
+
}
|
|
267
|
+
case 'continue':
|
|
268
|
+
await continueAcpGoal(host);
|
|
269
|
+
return { ok: true, data: { goal: (await loadAcpGoalState(host.sessionId)).record } };
|
|
270
|
+
default:
|
|
271
|
+
return { ok: false, error: `unknown goal action: ${request.action}` };
|
|
272
|
+
}
|
|
273
|
+
}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Goal mode on an ACP transport.
|
|
8
|
+
*
|
|
9
|
+
* Kabmo owns the record because the agent has no `/kabmo-mode` extension; the
|
|
10
|
+
* driver audits the closed turn and opens the next one itself. These cases pin
|
|
11
|
+
* the state machine the composer reads: create/pause/resume/drop, the turn
|
|
12
|
+
* ceiling, and the terminal verdicts.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
16
|
+
import { isolateDb, releaseDb } from '@/test-support/isolated-db';
|
|
17
|
+
import {
|
|
18
|
+
applyAcpGoalAction,
|
|
19
|
+
finishAcpGoal,
|
|
20
|
+
type AcpGoalHost,
|
|
21
|
+
} from '@/server/lib/harness/acp/acp-goal.server';
|
|
22
|
+
import { loadAcpGoalState, loadAcpGoalState as load } from '@/server/lib/harness/acp/acp-goal-state.server';
|
|
23
|
+
import { driveAcpGoalAfterTurn } from '@/server/lib/harness/acp/acp-goal-driver.server';
|
|
24
|
+
import type { GoalAuditAnswers } from '@/server/lib/omp/session/goal-auditor.server';
|
|
25
|
+
|
|
26
|
+
interface TestHost extends AcpGoalHost {
|
|
27
|
+
sent: string[];
|
|
28
|
+
events: { type: string; [key: string]: unknown }[];
|
|
29
|
+
busy: boolean;
|
|
30
|
+
usageTokens: number;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function makeHost(id = 'acp-goal-test'): TestHost {
|
|
34
|
+
const host: TestHost = {
|
|
35
|
+
sessionId: id,
|
|
36
|
+
harness: 'claude',
|
|
37
|
+
cwd: '/tmp',
|
|
38
|
+
runModel: null,
|
|
39
|
+
busy: false,
|
|
40
|
+
usageTokens: 0,
|
|
41
|
+
sent: [],
|
|
42
|
+
events: [],
|
|
43
|
+
isAlive: () => true,
|
|
44
|
+
isBusy: () => host.busy,
|
|
45
|
+
send: async (command) => {
|
|
46
|
+
host.sent.push(String(command.message ?? ''));
|
|
47
|
+
return {};
|
|
48
|
+
},
|
|
49
|
+
emit: (event) => {
|
|
50
|
+
host.events.push(event);
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
return host;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const ASSISTANT_DONE = {
|
|
57
|
+
role: 'assistant',
|
|
58
|
+
content: [{ type: 'text', text: 'All done: the importer is implemented and tested.' }],
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const audit = (answers: GoalAuditAnswers) => async () => answers;
|
|
62
|
+
const settings = async () => ({ auditEnabled: true, auditModel: '' });
|
|
63
|
+
|
|
64
|
+
beforeEach(async () => {
|
|
65
|
+
await isolateDb();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
afterEach(async () => {
|
|
69
|
+
await releaseDb();
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
describe('ACP goal actions', () => {
|
|
73
|
+
test('create stores an active record without opening a turn when armed', async () => {
|
|
74
|
+
const host = makeHost();
|
|
75
|
+
const result = await applyAcpGoalAction(host, {
|
|
76
|
+
scope: 'goal',
|
|
77
|
+
action: 'create',
|
|
78
|
+
payload: { objective: 'ship the importer', startTurn: false },
|
|
79
|
+
});
|
|
80
|
+
expect(result.ok).toBe(true);
|
|
81
|
+
const state = await load(host.sessionId);
|
|
82
|
+
expect(state.record).toMatchObject({ objective: 'ship the importer', status: 'active' });
|
|
83
|
+
expect(host.sent).toEqual([]);
|
|
84
|
+
expect(host.events.some((event) => String(event.message).startsWith('KABMO_GOAL_STATE:'))).toBe(true);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test('create with a start turn sends the objective', async () => {
|
|
88
|
+
const host = makeHost();
|
|
89
|
+
await applyAcpGoalAction(host, {
|
|
90
|
+
scope: 'goal',
|
|
91
|
+
action: 'create',
|
|
92
|
+
payload: { objective: 'fix the build' },
|
|
93
|
+
});
|
|
94
|
+
expect(host.sent).toHaveLength(1);
|
|
95
|
+
expect(host.sent[0]).toContain('fix the build');
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test('pause and resume move the record, and resume starts the loop', async () => {
|
|
99
|
+
const host = makeHost();
|
|
100
|
+
await applyAcpGoalAction(host, { scope: 'goal', action: 'create', payload: { objective: 'x', startTurn: false } });
|
|
101
|
+
await applyAcpGoalAction(host, { scope: 'goal', action: 'pause' });
|
|
102
|
+
expect((await load(host.sessionId)).record?.status).toBe('paused');
|
|
103
|
+
|
|
104
|
+
host.busy = true; // the scheduled continuation defer to the next turn end
|
|
105
|
+
await applyAcpGoalAction(host, { scope: 'goal', action: 'resume' });
|
|
106
|
+
const state = await load(host.sessionId);
|
|
107
|
+
expect(state.record?.status).toBe('active');
|
|
108
|
+
expect(state.turns).toBe(0);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
test('drop closes the goal', async () => {
|
|
112
|
+
const host = makeHost();
|
|
113
|
+
await applyAcpGoalAction(host, { scope: 'goal', action: 'create', payload: { objective: 'x', startTurn: false } });
|
|
114
|
+
await applyAcpGoalAction(host, { scope: 'goal', action: 'drop' });
|
|
115
|
+
expect((await load(host.sessionId)).record?.status).toBe('dropped');
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test('a completed goal is terminal, and every other stop stays resumable', async () => {
|
|
119
|
+
const host = makeHost();
|
|
120
|
+
await applyAcpGoalAction(host, { scope: 'goal', action: 'create', payload: { objective: 'x', startTurn: false } });
|
|
121
|
+
await finishAcpGoal(host, 'complete');
|
|
122
|
+
let state = await loadAcpGoalState(host.sessionId);
|
|
123
|
+
expect(state.record?.status).toBe('complete');
|
|
124
|
+
expect(state.continuation?.stopped).toBe('complete');
|
|
125
|
+
|
|
126
|
+
const second = makeHost('acp-goal-blocked');
|
|
127
|
+
await applyAcpGoalAction(second, { scope: 'goal', action: 'create', payload: { objective: 'y', startTurn: false } });
|
|
128
|
+
await finishAcpGoal(second, 'blocked');
|
|
129
|
+
state = await loadAcpGoalState(second.sessionId);
|
|
130
|
+
expect(state.record?.status).toBe('paused');
|
|
131
|
+
expect(state.continuation?.stopped).toBe('blocked');
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
test('state answers without touching the agent', async () => {
|
|
135
|
+
const host = makeHost();
|
|
136
|
+
await applyAcpGoalAction(host, { scope: 'goal', action: 'create', payload: { objective: 'x', startTurn: false } });
|
|
137
|
+
const result = await applyAcpGoalAction(host, { scope: 'goal', action: 'state' });
|
|
138
|
+
expect(result).toMatchObject({ ok: true, data: { enabled: true } });
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
describe('ACP goal driver', () => {
|
|
143
|
+
test('an audit that reports completion closes the goal and sends nothing', async () => {
|
|
144
|
+
const host = makeHost();
|
|
145
|
+
await applyAcpGoalAction(host, { scope: 'goal', action: 'create', payload: { objective: 'ship', startTurn: false } });
|
|
146
|
+
await driveAcpGoalAfterTurn(host, ASSISTANT_DONE, {
|
|
147
|
+
deps: { audit: audit({ allDone: true, remaining: false, needsUser: false }), settings },
|
|
148
|
+
});
|
|
149
|
+
const state = await load(host.sessionId);
|
|
150
|
+
expect(state.record?.status).toBe('complete');
|
|
151
|
+
expect(host.sent).toEqual([]);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
test('an audit that says keep going opens the next turn and counts it', async () => {
|
|
155
|
+
const host = makeHost();
|
|
156
|
+
await applyAcpGoalAction(host, { scope: 'goal', action: 'create', payload: { objective: 'ship', startTurn: false } });
|
|
157
|
+
await driveAcpGoalAfterTurn(host, ASSISTANT_DONE, {
|
|
158
|
+
deps: { audit: audit({ allDone: false, remaining: true, needsUser: false }), settings },
|
|
159
|
+
});
|
|
160
|
+
const state = await load(host.sessionId);
|
|
161
|
+
expect(state.turns).toBe(1);
|
|
162
|
+
expect(state.continuation).toMatchObject({ turn: 1, maxTurns: 25 });
|
|
163
|
+
expect(host.sent[0]).toContain('Continue working toward the active goal');
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
test('the goal ceiling closes the loop instead of driving forever', async () => {
|
|
167
|
+
const host = makeHost();
|
|
168
|
+
await applyAcpGoalAction(host, {
|
|
169
|
+
scope: 'goal',
|
|
170
|
+
action: 'create',
|
|
171
|
+
payload: { objective: 'ship', maxTurns: 1, startTurn: false },
|
|
172
|
+
});
|
|
173
|
+
const continueAudit = audit({ allDone: false, remaining: true, needsUser: false });
|
|
174
|
+
await driveAcpGoalAfterTurn(host, ASSISTANT_DONE, { deps: { audit: continueAudit, settings } });
|
|
175
|
+
let state = await load(host.sessionId);
|
|
176
|
+
// The first decision opens turn 1; the ceiling is read before the NEXT one.
|
|
177
|
+
expect(state.turns).toBe(1);
|
|
178
|
+
expect(host.sent).toHaveLength(1);
|
|
179
|
+
|
|
180
|
+
await driveAcpGoalAfterTurn(host, ASSISTANT_DONE, { deps: { audit: continueAudit, settings } });
|
|
181
|
+
state = await load(host.sessionId);
|
|
182
|
+
expect(state.record?.status).toBe('paused');
|
|
183
|
+
expect(state.continuation).toMatchObject({ turn: 1, maxTurns: 1, stopped: 'max-turns' });
|
|
184
|
+
expect(host.sent).toHaveLength(1);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
test('a cancelled turn is never audited', async () => {
|
|
188
|
+
const host = makeHost();
|
|
189
|
+
await applyAcpGoalAction(host, { scope: 'goal', action: 'create', payload: { objective: 'x', startTurn: false } });
|
|
190
|
+
let audited = false;
|
|
191
|
+
await driveAcpGoalAfterTurn(host, ASSISTANT_DONE, {
|
|
192
|
+
cancelled: true,
|
|
193
|
+
deps: {
|
|
194
|
+
audit: async () => {
|
|
195
|
+
audited = true;
|
|
196
|
+
return { allDone: false, remaining: true, needsUser: false };
|
|
197
|
+
},
|
|
198
|
+
settings,
|
|
199
|
+
},
|
|
200
|
+
});
|
|
201
|
+
expect(audited).toBe(false);
|
|
202
|
+
expect(host.sent).toEqual([]);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
test('a measured budget stops the loop before the next audit', async () => {
|
|
206
|
+
const host = makeHost();
|
|
207
|
+
await applyAcpGoalAction(host, {
|
|
208
|
+
scope: 'goal',
|
|
209
|
+
action: 'create',
|
|
210
|
+
payload: { objective: 'x', tokenBudget: 100, startTurn: false },
|
|
211
|
+
});
|
|
212
|
+
host.usageTokens = 180;
|
|
213
|
+
let audited = false;
|
|
214
|
+
await driveAcpGoalAfterTurn(host, ASSISTANT_DONE, {
|
|
215
|
+
deps: {
|
|
216
|
+
audit: async () => {
|
|
217
|
+
audited = true;
|
|
218
|
+
return { allDone: false, remaining: true, needsUser: false };
|
|
219
|
+
},
|
|
220
|
+
settings,
|
|
221
|
+
},
|
|
222
|
+
});
|
|
223
|
+
const state = await load(host.sessionId);
|
|
224
|
+
expect(audited).toBe(false);
|
|
225
|
+
expect(state.record?.status).toBe('budget-limited');
|
|
226
|
+
expect(state.record?.tokensUsed).toBe(180);
|
|
227
|
+
expect(host.sent).toEqual([]);
|
|
228
|
+
});
|
|
229
|
+
});
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The context panel's numbers for an ACP chat.
|
|
8
|
+
*
|
|
9
|
+
* omp computes telemetry from its transcript; another agent writes no file and
|
|
10
|
+
* only reports `usage_update` — context size, tokens in use and a cost. Those
|
|
11
|
+
* are exactly the figures the ring and the panel open on, so the live session is
|
|
12
|
+
* the source and the panel reads the same shape it always has.
|
|
13
|
+
*
|
|
14
|
+
* Fields ACP does not report (per-turn cache split, the token distribution, the
|
|
15
|
+
* last message's input/output) stay ZERO rather than invented. The panel draws
|
|
16
|
+
* its empty state from `messagesCount`, so a chat with usage still shows the
|
|
17
|
+
* window and the cost, and a chat with neither says it is not started.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import type { SessionContextTelemetry } from '@/shared/types/context';
|
|
21
|
+
import { getDb } from '@/server/db.server';
|
|
22
|
+
|
|
23
|
+
/** What the live session exposes for this bridge. */
|
|
24
|
+
export interface AcpTelemetrySession {
|
|
25
|
+
sessionId: string;
|
|
26
|
+
messageCount: number;
|
|
27
|
+
promptCount: number;
|
|
28
|
+
assistantCount: number;
|
|
29
|
+
contextUsage: { tokens: number; contextWindow: number; percent: number } | null;
|
|
30
|
+
totalCost: number;
|
|
31
|
+
runModel: { provider: string; modelId: string } | null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const ZERO_LAST = { input: 0, output: 0, reasoning: 0, cacheRead: 0, cacheWrite: 0, cacheHitPercent: 0 };
|
|
35
|
+
|
|
36
|
+
const ZERO_DISTRIBUTION = {
|
|
37
|
+
userTokens: 0,
|
|
38
|
+
userPercent: 0,
|
|
39
|
+
assistantTokens: 0,
|
|
40
|
+
assistantPercent: 0,
|
|
41
|
+
toolTokens: 0,
|
|
42
|
+
toolPercent: 0,
|
|
43
|
+
otherTokens: 0,
|
|
44
|
+
otherPercent: 0,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/** The last usage an ACP session reported, for a chat whose process is gone. */
|
|
48
|
+
export interface StoredAcpUsage extends AcpTelemetrySession {}
|
|
49
|
+
|
|
50
|
+
export async function saveAcpUsage(session: AcpTelemetrySession): Promise<void> {
|
|
51
|
+
try {
|
|
52
|
+
const db = await getDb();
|
|
53
|
+
await db.run(
|
|
54
|
+
`INSERT INTO harness_usage_state
|
|
55
|
+
(session_id, used, size, cost, messages, prompts, assistants, model_provider, model_id, updated_at)
|
|
56
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
57
|
+
ON CONFLICT(session_id) DO UPDATE SET
|
|
58
|
+
used = excluded.used,
|
|
59
|
+
size = excluded.size,
|
|
60
|
+
cost = excluded.cost,
|
|
61
|
+
messages = excluded.messages,
|
|
62
|
+
prompts = excluded.prompts,
|
|
63
|
+
assistants = excluded.assistants,
|
|
64
|
+
model_provider = excluded.model_provider,
|
|
65
|
+
model_id = excluded.model_id,
|
|
66
|
+
updated_at = excluded.updated_at`,
|
|
67
|
+
[
|
|
68
|
+
session.sessionId,
|
|
69
|
+
session.contextUsage?.tokens ?? 0,
|
|
70
|
+
session.contextUsage?.contextWindow ?? 0,
|
|
71
|
+
session.totalCost,
|
|
72
|
+
session.messageCount,
|
|
73
|
+
session.promptCount,
|
|
74
|
+
session.assistantCount,
|
|
75
|
+
session.runModel?.provider ?? '',
|
|
76
|
+
session.runModel?.modelId ?? '',
|
|
77
|
+
Date.now(),
|
|
78
|
+
],
|
|
79
|
+
);
|
|
80
|
+
} catch {
|
|
81
|
+
// Best-effort: a write failure must not break a turn's settle.
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export async function loadAcpUsage(sessionId: string): Promise<StoredAcpUsage | null> {
|
|
86
|
+
try {
|
|
87
|
+
const db = await getDb();
|
|
88
|
+
const row = await db.get('SELECT * FROM harness_usage_state WHERE session_id = ?', [sessionId]);
|
|
89
|
+
if (!row) return null;
|
|
90
|
+
const used = typeof row.used === 'number' ? row.used : 0;
|
|
91
|
+
const size = typeof row.size === 'number' ? row.size : 0;
|
|
92
|
+
return {
|
|
93
|
+
sessionId,
|
|
94
|
+
messageCount: typeof row.messages === 'number' ? row.messages : 0,
|
|
95
|
+
promptCount: typeof row.prompts === 'number' ? row.prompts : 0,
|
|
96
|
+
assistantCount: typeof row.assistants === 'number' ? row.assistants : 0,
|
|
97
|
+
contextUsage: size > 0 ? { tokens: used, contextWindow: size, percent: Math.min(100, Math.round((used / size) * 100)) } : null,
|
|
98
|
+
totalCost: typeof row.cost === 'number' ? row.cost : 0,
|
|
99
|
+
runModel: row.model_provider && row.model_id
|
|
100
|
+
? { provider: String(row.model_provider), modelId: String(row.model_id) }
|
|
101
|
+
: null,
|
|
102
|
+
};
|
|
103
|
+
} catch {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** A snapshot in the shape `SessionContextTelemetry` already defines. */
|
|
109
|
+
export function buildAcpTelemetry(
|
|
110
|
+
session: AcpTelemetrySession,
|
|
111
|
+
title: string | null | undefined,
|
|
112
|
+
): SessionContextTelemetry {
|
|
113
|
+
const usage = session.contextUsage;
|
|
114
|
+
const model = session.runModel;
|
|
115
|
+
return {
|
|
116
|
+
sessionId: session.sessionId,
|
|
117
|
+
sessionTitle: title?.trim() || 'Session',
|
|
118
|
+
modelId: model ? `${model.provider}/${model.modelId}` : '',
|
|
119
|
+
modelName: model?.modelId ?? '',
|
|
120
|
+
timestamp: new Date().toISOString(),
|
|
121
|
+
contextUsed: usage?.tokens ?? 0,
|
|
122
|
+
contextLimit: usage?.contextWindow ?? 0,
|
|
123
|
+
contextPercent: usage?.percent ?? 0,
|
|
124
|
+
messagesCount: session.messageCount,
|
|
125
|
+
userCount: session.promptCount,
|
|
126
|
+
assistantCount: session.assistantCount,
|
|
127
|
+
totalCost: session.totalCost,
|
|
128
|
+
costFormatted: `$${session.totalCost.toFixed(4)}`,
|
|
129
|
+
lastMessage: { ...ZERO_LAST },
|
|
130
|
+
distribution: { ...ZERO_DISTRIBUTION },
|
|
131
|
+
rawMessages: [],
|
|
132
|
+
};
|
|
133
|
+
}
|