@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,315 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The ACP <-> Kabmo translation, which is the whole adapter contract.
|
|
8
|
+
*
|
|
9
|
+
* Each case here is a measured agent behaviour, not a hypothetical:
|
|
10
|
+
*
|
|
11
|
+
* - `tool_call_update` arrives as a PATCH, so a `completed` update carrying
|
|
12
|
+
* only `status` must not blank the card it completes;
|
|
13
|
+
* - `messageId` is the ONLY message delimiter (ACP has no `message_end`), so a
|
|
14
|
+
* changed id must close the previous row instead of appending into it; an
|
|
15
|
+
* ABSENT id (antigravity 1.5.3) must still yield one stable row per turn;
|
|
16
|
+
* - `kind` must reach `ToolCallData.type`, because omp's `ToolType` is what the
|
|
17
|
+
* renderers switch on;
|
|
18
|
+
* - `usage_update` exists on some agents only, so its absence must emit
|
|
19
|
+
* nothing rather than a zero that reads like a measurement.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import { describe, expect, test } from 'bun:test';
|
|
23
|
+
import { AcpFrameMapper, turnEndFrame } from '@/server/lib/harness/acp/frames';
|
|
24
|
+
import {
|
|
25
|
+
acpContentText,
|
|
26
|
+
acpToolOutput,
|
|
27
|
+
acpToolTarget,
|
|
28
|
+
toolTypeFor,
|
|
29
|
+
} from '@/server/lib/harness/acp/mapper';
|
|
30
|
+
|
|
31
|
+
const textChunk = (text: string, messageId = 'm1') => ({
|
|
32
|
+
sessionUpdate: 'agent_message_chunk',
|
|
33
|
+
content: { type: 'text', text },
|
|
34
|
+
messageId,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
/** ACP v1 allows `messageId` to be absent; antigravity 1.5.3 sends none. */
|
|
38
|
+
const anonymousChunk = (text: string) => ({
|
|
39
|
+
sessionUpdate: 'agent_message_chunk',
|
|
40
|
+
content: { type: 'text', text },
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const messageIdOf = (frame: unknown): string | undefined => {
|
|
44
|
+
if (!frame || typeof frame !== 'object' || !('message' in frame)) return undefined;
|
|
45
|
+
const message = frame.message;
|
|
46
|
+
if (!message || typeof message !== 'object' || !('id' in message)) return undefined;
|
|
47
|
+
return typeof message.id === 'string' ? message.id : undefined;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
describe('acp frame mapper — assistant text', () => {
|
|
51
|
+
test('accumulates chunks into ONE message rather than one row per delta', () => {
|
|
52
|
+
const mapper = new AcpFrameMapper();
|
|
53
|
+
mapper.mapUpdate(textChunk('hello '));
|
|
54
|
+
const frames = mapper.mapUpdate(textChunk('world'));
|
|
55
|
+
expect(frames).toHaveLength(1);
|
|
56
|
+
const message = frames[0].message as { content: { type: string; text: string }[] };
|
|
57
|
+
expect(message.content[0]).toEqual({ type: 'text', text: 'hello world' });
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test('chunks without a messageId still update ONE row', () => {
|
|
61
|
+
const mapper = new AcpFrameMapper();
|
|
62
|
+
const first = mapper.mapUpdate(anonymousChunk('hello '));
|
|
63
|
+
const second = mapper.mapUpdate(anonymousChunk('world'));
|
|
64
|
+
const firstId = messageIdOf(first[0]);
|
|
65
|
+
expect(typeof firstId).toBe('string');
|
|
66
|
+
expect(messageIdOf(second[0])).toBe(firstId);
|
|
67
|
+
// The final frame must carry that SAME id, or the client appends the
|
|
68
|
+
// completed answer beside the streamed one.
|
|
69
|
+
const ended = mapper.closeMessage();
|
|
70
|
+
expect(messageIdOf(ended[0])).toBe(firstId);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test('a tool call before the first chunk keeps that identity too', () => {
|
|
74
|
+
const mapper = new AcpFrameMapper();
|
|
75
|
+
const opened = mapper.mapUpdate({
|
|
76
|
+
sessionUpdate: 'tool_call',
|
|
77
|
+
toolCallId: 't1',
|
|
78
|
+
title: 'Read',
|
|
79
|
+
status: 'in_progress',
|
|
80
|
+
});
|
|
81
|
+
const chunk = mapper.mapUpdate(anonymousChunk('done'));
|
|
82
|
+
const openedId = messageIdOf(opened[0]);
|
|
83
|
+
expect(typeof openedId).toBe('string');
|
|
84
|
+
expect(messageIdOf(chunk[0])).toBe(openedId);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test('a new turn gets a fresh identity when the agent sends no id', () => {
|
|
88
|
+
const mapper = new AcpFrameMapper();
|
|
89
|
+
const first = mapper.mapUpdate(anonymousChunk('one'));
|
|
90
|
+
mapper.reset();
|
|
91
|
+
const second = mapper.mapUpdate(anonymousChunk('two'));
|
|
92
|
+
expect(messageIdOf(second[0])).not.toBe(messageIdOf(first[0]));
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test('a changed messageId closes the previous row first', () => {
|
|
96
|
+
const mapper = new AcpFrameMapper();
|
|
97
|
+
mapper.mapUpdate(textChunk('first', 'm1'));
|
|
98
|
+
const frames = mapper.mapUpdate(textChunk('second', 'm2'));
|
|
99
|
+
expect(frames.map((frame) => frame.type)).toEqual(['message_end', 'message_update']);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
test('thinking chunks stay in their own block', () => {
|
|
103
|
+
const mapper = new AcpFrameMapper();
|
|
104
|
+
mapper.mapUpdate({ sessionUpdate: 'agent_thought_chunk', content: { type: 'text', text: 'hmm' }, messageId: 'm1' });
|
|
105
|
+
const frames = mapper.mapUpdate(textChunk('answer', 'm1'));
|
|
106
|
+
const message = frames[0].message as { content: { type: string }[] };
|
|
107
|
+
expect(message.content.map((block) => block.type)).toEqual(['thinking', 'text']);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
test('user chunks are receipts, not new rows', () => {
|
|
111
|
+
const mapper = new AcpFrameMapper();
|
|
112
|
+
expect(mapper.mapUpdate({ sessionUpdate: 'user_message_chunk', content: { type: 'text', text: 'hi' } })).toEqual([]);
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
describe('acp frame mapper — tool calls', () => {
|
|
117
|
+
const openTail = {
|
|
118
|
+
sessionUpdate: 'tool_call',
|
|
119
|
+
toolCallId: 'c1',
|
|
120
|
+
name: 'read',
|
|
121
|
+
title: 'Reading hello.txt',
|
|
122
|
+
kind: 'read',
|
|
123
|
+
status: 'pending',
|
|
124
|
+
rawInput: { path: 'hello.txt' },
|
|
125
|
+
locations: [{ path: '/tmp/hello.txt' }],
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
test('a tool call becomes a block on the message AND a start frame', () => {
|
|
129
|
+
const mapper = new AcpFrameMapper();
|
|
130
|
+
const frames = mapper.mapUpdate(openTail);
|
|
131
|
+
expect(frames.map((frame) => frame.type)).toEqual(['message_update', 'tool_execution_start']);
|
|
132
|
+
const message = frames[0].message as { content: { type: string; id: string; name: string }[] };
|
|
133
|
+
expect(message.content[0]).toMatchObject({ type: 'toolCall', id: 'c1', name: 'read' });
|
|
134
|
+
expect(frames[1]).toMatchObject({ toolCallId: 'c1', toolType: 'read', target: '/tmp/hello.txt' });
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
test('a completion PATCH keeps the card the opening frame drew', () => {
|
|
138
|
+
const mapper = new AcpFrameMapper();
|
|
139
|
+
mapper.mapUpdate(openTail);
|
|
140
|
+
const frames = mapper.mapUpdate({
|
|
141
|
+
sessionUpdate: 'tool_call_update',
|
|
142
|
+
toolCallId: 'c1',
|
|
143
|
+
status: 'completed',
|
|
144
|
+
rawOutput: { content: [{ type: 'text', text: '1|hello' }] },
|
|
145
|
+
});
|
|
146
|
+
expect(frames).toHaveLength(1);
|
|
147
|
+
expect(frames[0]).toMatchObject({ type: 'tool_execution_end', toolCallId: 'c1', isError: false });
|
|
148
|
+
expect(frames[0].output).toBe('1|hello');
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
test('an in-progress patch is an update, not an end', () => {
|
|
152
|
+
const mapper = new AcpFrameMapper();
|
|
153
|
+
mapper.mapUpdate(openTail);
|
|
154
|
+
const frames = mapper.mapUpdate({
|
|
155
|
+
sessionUpdate: 'tool_call_update',
|
|
156
|
+
toolCallId: 'c1',
|
|
157
|
+
status: 'in_progress',
|
|
158
|
+
rawOutput: { content: [{ type: 'text', text: 'reading…' }] },
|
|
159
|
+
});
|
|
160
|
+
expect(frames[0].type).toBe('tool_execution_update');
|
|
161
|
+
// The flattened read rides the frame: the client's generic walker does not
|
|
162
|
+
// know ACP's nested `{type:"content"}` envelope.
|
|
163
|
+
expect(frames[0].output).toBe('reading…');
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
test('a nested content envelope still yields output on the frame', () => {
|
|
167
|
+
const mapper = new AcpFrameMapper();
|
|
168
|
+
mapper.mapUpdate(openTail);
|
|
169
|
+
const frames = mapper.mapUpdate({
|
|
170
|
+
sessionUpdate: 'tool_call_update',
|
|
171
|
+
toolCallId: 'c1',
|
|
172
|
+
status: 'completed',
|
|
173
|
+
rawOutput: { content: [{ type: 'content', content: { type: 'text', text: 'nested' } }] },
|
|
174
|
+
});
|
|
175
|
+
expect(frames[0]).toMatchObject({ type: 'tool_execution_end', output: 'nested' });
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
test('a call announced already-completed is closed once, not left spinning', () => {
|
|
179
|
+
// Some agents send ONE `tool_call` with status completed and no update.
|
|
180
|
+
// The old mapper kept it open, so the turn's cleanup closed it as an error.
|
|
181
|
+
const mapper = new AcpFrameMapper();
|
|
182
|
+
const frames = mapper.mapUpdate({
|
|
183
|
+
sessionUpdate: 'tool_call',
|
|
184
|
+
toolCallId: 'c2',
|
|
185
|
+
name: 'Shell',
|
|
186
|
+
kind: 'execute',
|
|
187
|
+
status: 'completed',
|
|
188
|
+
rawInput: { command: 'ls' },
|
|
189
|
+
rawOutput: { content: [{ type: 'text', text: 'done' }], details: { exitCode: 0 } },
|
|
190
|
+
});
|
|
191
|
+
expect(frames.map((frame) => frame.type)).toEqual([
|
|
192
|
+
'message_update',
|
|
193
|
+
'tool_execution_start',
|
|
194
|
+
'tool_execution_end',
|
|
195
|
+
]);
|
|
196
|
+
expect(frames[1]).toMatchObject({ toolType: 'bash' });
|
|
197
|
+
expect(frames[2]).toMatchObject({ isError: false, output: 'done', details: { exitCode: 0 } });
|
|
198
|
+
expect(mapper.openCalls()).toEqual([]);
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
test('the message block carries the transport type for the renderer', () => {
|
|
202
|
+
const mapper = new AcpFrameMapper();
|
|
203
|
+
const frames = mapper.mapUpdate({
|
|
204
|
+
sessionUpdate: 'tool_call',
|
|
205
|
+
toolCallId: 'c3',
|
|
206
|
+
name: 'Shell',
|
|
207
|
+
kind: 'execute',
|
|
208
|
+
status: 'pending',
|
|
209
|
+
});
|
|
210
|
+
const message = frames[0].message as { content: { toolType?: string }[] };
|
|
211
|
+
expect(message.content[0]?.toolType).toBe('bash');
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
test('a diff content block becomes details.diff for the Edit panel', () => {
|
|
215
|
+
const mapper = new AcpFrameMapper();
|
|
216
|
+
mapper.mapUpdate(openTail);
|
|
217
|
+
const frames = mapper.mapUpdate({
|
|
218
|
+
sessionUpdate: 'tool_call_update',
|
|
219
|
+
toolCallId: 'c1',
|
|
220
|
+
status: 'completed',
|
|
221
|
+
content: [{ type: 'diff', path: 'src/a.ts', oldText: 'a\nb', newText: 'a\nc' }],
|
|
222
|
+
});
|
|
223
|
+
const details = frames[0].details as { diff?: string; path?: string };
|
|
224
|
+
expect(details.path).toBe('src/a.ts');
|
|
225
|
+
expect(details.diff).toContain('-b');
|
|
226
|
+
expect(details.diff).toContain('+c');
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
test('content-only output reaches the card', () => {
|
|
230
|
+
const mapper = new AcpFrameMapper();
|
|
231
|
+
mapper.mapUpdate(openTail);
|
|
232
|
+
const frames = mapper.mapUpdate({
|
|
233
|
+
sessionUpdate: 'tool_call_update',
|
|
234
|
+
toolCallId: 'c1',
|
|
235
|
+
status: 'completed',
|
|
236
|
+
content: [{ type: 'text', text: 'from content' }],
|
|
237
|
+
});
|
|
238
|
+
expect(frames[0].output).toBe('from content');
|
|
239
|
+
expect(frames[0].result).toEqual({ content: [{ type: 'text', text: 'from content' }] });
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
test('failed maps to isError, and openCalls drains', () => {
|
|
243
|
+
const mapper = new AcpFrameMapper();
|
|
244
|
+
mapper.mapUpdate(openTail);
|
|
245
|
+
expect(mapper.openCalls()).toEqual(['c1']);
|
|
246
|
+
const frames = mapper.mapUpdate({
|
|
247
|
+
sessionUpdate: 'tool_call_update',
|
|
248
|
+
toolCallId: 'c1',
|
|
249
|
+
status: 'failed',
|
|
250
|
+
rawOutput: { content: [{ type: 'text', text: 'boom' }] },
|
|
251
|
+
});
|
|
252
|
+
expect(frames[0].isError).toBe(true);
|
|
253
|
+
expect(mapper.openCalls()).toEqual([]);
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
test('kind decides the renderer type, and a real name wins over `other`', () => {
|
|
257
|
+
expect(toolTypeFor('execute', undefined)).toBe('bash');
|
|
258
|
+
expect(toolTypeFor('search', undefined)).toBe('grep');
|
|
259
|
+
expect(toolTypeFor('delete', 'rm')).toBe('edit');
|
|
260
|
+
expect(toolTypeFor('switch_mode', undefined)).toBe('todo');
|
|
261
|
+
expect(toolTypeFor('other', 'edit')).toBe('edit');
|
|
262
|
+
expect(toolTypeFor(undefined, 'view_file')).toBe('read');
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
describe('acp frame mapper — optional telemetry', () => {
|
|
267
|
+
test('usage_update forwards size/used/cost', () => {
|
|
268
|
+
const mapper = new AcpFrameMapper();
|
|
269
|
+
const frames = mapper.mapUpdate({ sessionUpdate: 'usage_update', size: 1_000_000, used: 5216, cost: { amount: 0.00004, currency: 'USD' } });
|
|
270
|
+
expect(frames[0]).toMatchObject({ type: 'usage_updated', size: 1_000_000, used: 5216 });
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
test('an agent that reports no usage emits nothing at all', () => {
|
|
274
|
+
const mapper = new AcpFrameMapper();
|
|
275
|
+
expect(mapper.mapUpdate({ sessionUpdate: 'usage_update' })).toEqual([]);
|
|
276
|
+
expect(mapper.mapUpdate({ sessionUpdate: 'plan', entries: [] })[0]).toMatchObject({ type: 'plan_updated' });
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
test('an unknown variant is ignored, never an error', () => {
|
|
280
|
+
const mapper = new AcpFrameMapper();
|
|
281
|
+
expect(mapper.mapUpdate({ sessionUpdate: 'brand_new_thing' })).toEqual([]);
|
|
282
|
+
});
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
describe('acp frame mapper — turn terminal', () => {
|
|
286
|
+
test('a cancelled stopReason reports cancellation', () => {
|
|
287
|
+
expect(turnEndFrame({ stopReason: 'cancelled' })).toMatchObject({ type: 'agent_end', isTerminal: true, cancelled: true });
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
test('a normal end is terminal without the cancelled flag', () => {
|
|
291
|
+
const frame = turnEndFrame({ stopReason: 'end_turn' });
|
|
292
|
+
expect(frame.isTerminal).toBe(true);
|
|
293
|
+
expect(frame.cancelled).toBeUndefined();
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
describe('acp mapper helpers', () => {
|
|
298
|
+
test('both measured content shapes yield text', () => {
|
|
299
|
+
expect(acpContentText([{ type: 'text', text: 'a' }, { type: 'text', text: 'b' }])).toBe('a\nb');
|
|
300
|
+
expect(acpContentText([{ type: 'content', content: { type: 'text', text: 'wrapped' } }])).toBe('wrapped');
|
|
301
|
+
expect(acpContentText('plain')).toBe('plain');
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
test('rawOutput keeps omp-shaped fallbacks', () => {
|
|
305
|
+
expect(acpToolOutput({ content: [{ type: 'text', text: 'x' }] })).toBe('x');
|
|
306
|
+
expect(acpToolOutput({ output: 'y' })).toBe('y');
|
|
307
|
+
expect(acpToolOutput(null)).toBe('');
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
test('target prefers locations, then the input bag', () => {
|
|
311
|
+
expect(acpToolTarget([{ path: '/a' }], { path: 'b' })).toBe('/a');
|
|
312
|
+
expect(acpToolTarget(undefined, { command: 'ls -la' })).toBe('ls -la');
|
|
313
|
+
expect(acpToolTarget(undefined, undefined)).toBeUndefined();
|
|
314
|
+
});
|
|
315
|
+
});
|
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The stateful half of the ACP adapter: one session's accumulated assistant
|
|
8
|
+
* message, turned into the frames `foldAgentEvent` already folds.
|
|
9
|
+
*
|
|
10
|
+
* It accumulates a WHOLE message and emits `message_update` carrying it, which
|
|
11
|
+
* is exactly the shape omp's `set_event_filter(messageUpdates:"full")` produces
|
|
12
|
+
* (see `rpc/child-config.ts`). That is not a shortcut: the fold's
|
|
13
|
+
* `toChatMessage` builds the card list from `content[]` blocks, so a frame that
|
|
14
|
+
* carried only a text delta would render prose and NOTHING else — no tool cards,
|
|
15
|
+
* no thinking accordion, and no `lastToolMessageRef` for a result to pair onto.
|
|
16
|
+
*
|
|
17
|
+
* Three ACP facts drive the state kept here:
|
|
18
|
+
*
|
|
19
|
+
* - **`messageId` delimits messages, but is OPTIONAL.** One answer is many
|
|
20
|
+
* chunks sharing an id (measured 6 chunks for a five-word answer, 168 for a
|
|
21
|
+
* long one); a changed id closes the row and opens the next. An agent that
|
|
22
|
+
* sends no id at all (measured on antigravity 1.5.3) gets one synthesized
|
|
23
|
+
* identity per turn, so its chunks still update ONE row.
|
|
24
|
+
* - **`tool_call_update` is a PATCH.** A `status:completed` update carries no
|
|
25
|
+
* `content`, so the card's body lives in the accumulated block; replacing it
|
|
26
|
+
* blanks the card at the exact moment it finishes.
|
|
27
|
+
* - **`kind` is the renderer key.** ACP's ten kinds do not all exist in
|
|
28
|
+
* `ToolType`, so `toolTypeFor` names the translation and the name is kept
|
|
29
|
+
* alongside it.
|
|
30
|
+
*
|
|
31
|
+
* No I/O: the driver feeds it, the tests feed it, and the same instance serves a
|
|
32
|
+
* live stream and a replay.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
import type { AgentEvent } from '@/server/lib/omp/rpc/constants';
|
|
36
|
+
import {
|
|
37
|
+
acpContentDetails,
|
|
38
|
+
acpContentText,
|
|
39
|
+
acpToolDetails,
|
|
40
|
+
acpToolOutput,
|
|
41
|
+
acpToolTarget,
|
|
42
|
+
isKnownToolName,
|
|
43
|
+
toolTypeFor,
|
|
44
|
+
} from '@/server/lib/harness/acp/mapper';
|
|
45
|
+
import type { AcpToolKind, AcpToolStatus } from '@/server/lib/harness/acp/protocol';
|
|
46
|
+
|
|
47
|
+
/** One block of the accumulated assistant message, in `parseMessageBlocks` shape. */
|
|
48
|
+
type MessageBlock =
|
|
49
|
+
| { type: 'text'; text: string }
|
|
50
|
+
| { type: 'thinking'; thinking: string }
|
|
51
|
+
| { type: 'toolCall'; id: string; name: string; arguments?: Record<string, unknown>; toolKind?: AcpToolKind; toolType?: string };
|
|
52
|
+
|
|
53
|
+
interface OpenTool {
|
|
54
|
+
id: string;
|
|
55
|
+
name: string;
|
|
56
|
+
kind?: AcpToolKind;
|
|
57
|
+
title?: string;
|
|
58
|
+
status: AcpToolStatus;
|
|
59
|
+
rawOutput?: unknown;
|
|
60
|
+
/** `tool_call(Update).content` — where some agents put the diff/output. */
|
|
61
|
+
content?: unknown;
|
|
62
|
+
locations?: unknown;
|
|
63
|
+
startedAt: number;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Per-session accumulator; one instance per live ACP session. */
|
|
67
|
+
export class AcpFrameMapper {
|
|
68
|
+
private blocks: MessageBlock[] = [];
|
|
69
|
+
private messageId: string | null = null;
|
|
70
|
+
private readonly open = new Map<string, OpenTool>();
|
|
71
|
+
|
|
72
|
+
/** Forget per-turn state (an aborted run, a fresh load). */
|
|
73
|
+
reset(): void {
|
|
74
|
+
this.blocks = [];
|
|
75
|
+
this.messageId = null;
|
|
76
|
+
this.open.clear();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Tool calls still running — the driver closes them if the agent exits
|
|
80
|
+
* mid-turn, so no card is left spinning forever. */
|
|
81
|
+
openCalls(): string[] {
|
|
82
|
+
return [...this.open.values()]
|
|
83
|
+
.filter((call) => call.status === 'pending' || call.status === 'in_progress')
|
|
84
|
+
.map((call) => call.id);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Turn one `session/update` payload into zero or more Kabmo frames.
|
|
89
|
+
*
|
|
90
|
+
* An array rather than emitting, so ordering is explicit: a changed
|
|
91
|
+
* `messageId` closes the previous row BEFORE the next chunk opens one, and a
|
|
92
|
+
* tool call emits both a message refresh and its start frame.
|
|
93
|
+
*/
|
|
94
|
+
mapUpdate(update: Record<string, unknown>): AgentEvent[] {
|
|
95
|
+
switch (typeof update.sessionUpdate === 'string' ? update.sessionUpdate : '') {
|
|
96
|
+
case 'agent_message_chunk':
|
|
97
|
+
return this.appendChunk(update, 'text');
|
|
98
|
+
case 'agent_thought_chunk':
|
|
99
|
+
return this.appendChunk(update, 'thinking');
|
|
100
|
+
case 'user_message_chunk':
|
|
101
|
+
// Live user chunks only arrive on replay/steering; the composer already
|
|
102
|
+
// drew the optimistic bubble, so this is a receipt, not a new row.
|
|
103
|
+
return [];
|
|
104
|
+
case 'tool_call':
|
|
105
|
+
return this.openTool(update);
|
|
106
|
+
case 'tool_call_update':
|
|
107
|
+
return this.patchTool(update);
|
|
108
|
+
case 'usage_update':
|
|
109
|
+
return this.usage(update);
|
|
110
|
+
case 'available_commands_update':
|
|
111
|
+
return [{ type: 'available_commands_update', commands: update.availableCommands ?? [] }];
|
|
112
|
+
case 'session_info_update':
|
|
113
|
+
return [{
|
|
114
|
+
type: 'session_info_update',
|
|
115
|
+
title: typeof update.title === 'string' ? update.title : undefined,
|
|
116
|
+
updatedAt: typeof update.updatedAt === 'string' ? update.updatedAt : undefined,
|
|
117
|
+
}];
|
|
118
|
+
case 'current_mode_update':
|
|
119
|
+
return [{ type: 'mode_changed', modeId: update.currentModeId }];
|
|
120
|
+
case 'config_option_update':
|
|
121
|
+
return [{ type: 'config_changed', configOptions: update.configOptions ?? [] }];
|
|
122
|
+
case 'plan':
|
|
123
|
+
// The spec defines it; no measured agent sends it. Forwarded so a future
|
|
124
|
+
// adapter lights the panel with no change here.
|
|
125
|
+
return [{ type: 'plan_updated', entries: update.entries ?? [] }];
|
|
126
|
+
case 'notice':
|
|
127
|
+
return [{
|
|
128
|
+
type: 'notice',
|
|
129
|
+
level: typeof update.severity === 'string' ? update.severity : 'info',
|
|
130
|
+
message: [update.title, update.description]
|
|
131
|
+
.filter((part) => typeof part === 'string' && part)
|
|
132
|
+
.join(' — '),
|
|
133
|
+
}];
|
|
134
|
+
default:
|
|
135
|
+
// An unknown variant is data, not an error: adapters add their own.
|
|
136
|
+
return [];
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** Close the open assistant row (turn end, abort, disconnect). */
|
|
141
|
+
closeMessage(): AgentEvent[] {
|
|
142
|
+
if (!this.messageId && this.blocks.length === 0) return [];
|
|
143
|
+
const message = this.snapshot();
|
|
144
|
+
this.blocks = [];
|
|
145
|
+
this.messageId = null;
|
|
146
|
+
return [{ type: 'message_end', message }];
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* The accumulated message in omp's wire shape.
|
|
151
|
+
*
|
|
152
|
+
* `messageId` is OPTIONAL in ACP v1, and an agent that omits it (measured on
|
|
153
|
+
* antigravity 1.5.3: every chunk carried only `sessionUpdate` + `content`)
|
|
154
|
+
* still needs one identity for the whole turn. Without it, `toChatMessage`
|
|
155
|
+
* minted `msg-<Date.now()>-ai` per frame, so every chunk after the first
|
|
156
|
+
* APPENDED a new row instead of updating the streaming one — the turn showed
|
|
157
|
+
* as duplicate bubbles and the final answer again at `message_end`.
|
|
158
|
+
*/
|
|
159
|
+
private snapshot(): Record<string, unknown> {
|
|
160
|
+
const id = this.messageId ??= `acp-${crypto.randomUUID()}`;
|
|
161
|
+
return {
|
|
162
|
+
role: 'assistant',
|
|
163
|
+
id,
|
|
164
|
+
content: this.blocks.map((block) => ({ ...block })),
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
private appendChunk(update: Record<string, unknown>, kind: 'text' | 'thinking'): AgentEvent[] {
|
|
169
|
+
const text = acpContentText(update.content);
|
|
170
|
+
if (!text) return [];
|
|
171
|
+
const frames: AgentEvent[] = [];
|
|
172
|
+
const messageId = typeof update.messageId === 'string' ? update.messageId : null;
|
|
173
|
+
if (messageId && this.messageId && messageId !== this.messageId) frames.push(...this.closeMessage());
|
|
174
|
+
if (messageId) this.messageId = messageId;
|
|
175
|
+
|
|
176
|
+
const last = this.blocks[this.blocks.length - 1];
|
|
177
|
+
if (kind === 'text') {
|
|
178
|
+
if (last?.type === 'text') last.text += text;
|
|
179
|
+
else this.blocks.push({ type: 'text', text });
|
|
180
|
+
} else if (last?.type === 'thinking') last.thinking += text;
|
|
181
|
+
else this.blocks.push({ type: 'thinking', thinking: text });
|
|
182
|
+
|
|
183
|
+
frames.push({
|
|
184
|
+
type: 'message_update',
|
|
185
|
+
message: this.snapshot(),
|
|
186
|
+
// The fold reads this only to name the activity phrase; the message above
|
|
187
|
+
// is what actually renders. `text_delta`/`thinking_delta` keep the
|
|
188
|
+
// existing "Writing…"/"Thinking…" wording.
|
|
189
|
+
assistantMessageEvent: {
|
|
190
|
+
type: kind === 'text' ? 'text_delta' : 'thinking_delta',
|
|
191
|
+
delta: text,
|
|
192
|
+
},
|
|
193
|
+
});
|
|
194
|
+
return frames;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
private openTool(update: Record<string, unknown>): AgentEvent[] {
|
|
198
|
+
const toolCallId = typeof update.toolCallId === 'string' ? update.toolCallId : '';
|
|
199
|
+
if (!toolCallId) return [];
|
|
200
|
+
const name = typeof update.name === 'string' && update.name
|
|
201
|
+
? update.name
|
|
202
|
+
: typeof update.title === 'string' && update.title
|
|
203
|
+
? update.title
|
|
204
|
+
: 'tool';
|
|
205
|
+
const kind = typeof update.kind === 'string' ? (update.kind as AcpToolKind) : undefined;
|
|
206
|
+
const status = typeof update.status === 'string' ? (update.status as AcpToolStatus) : 'pending';
|
|
207
|
+
// A specific kind is authoritative. `other`/absent is only an explicit type
|
|
208
|
+
// when the name is one the renderers know; otherwise the shared parser's
|
|
209
|
+
// own inference from the name is better informed than a forced `read`.
|
|
210
|
+
const toolType = kind !== undefined && kind !== 'other'
|
|
211
|
+
? toolTypeFor(kind, name)
|
|
212
|
+
: isKnownToolName(name) ? toolTypeFor(kind, name) : undefined;
|
|
213
|
+
const rawInput = update.rawInput;
|
|
214
|
+
const args = rawInput && typeof rawInput === 'object' && !Array.isArray(rawInput)
|
|
215
|
+
? Object.fromEntries(Object.entries(rawInput))
|
|
216
|
+
: undefined;
|
|
217
|
+
|
|
218
|
+
// The card is drawn from the message block, so opening a call means adding
|
|
219
|
+
// the block and re-emitting the message — not emitting a separate card row.
|
|
220
|
+
// `toolType` travels with the block: the shared parser's name inference
|
|
221
|
+
// cannot know that ACP `kind:"execute"` means bash when the name is `Shell`.
|
|
222
|
+
this.blocks.push({
|
|
223
|
+
type: 'toolCall',
|
|
224
|
+
id: toolCallId,
|
|
225
|
+
name,
|
|
226
|
+
...(args ? { arguments: args } : {}),
|
|
227
|
+
...(kind ? { toolKind: kind } : {}),
|
|
228
|
+
...(toolType ? { toolType } : {}),
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
const frames: AgentEvent[] = [
|
|
232
|
+
{ type: 'message_update', message: this.snapshot(), assistantMessageEvent: { type: 'toolcall_start' } },
|
|
233
|
+
{
|
|
234
|
+
type: 'tool_execution_start',
|
|
235
|
+
toolCallId,
|
|
236
|
+
toolName: name,
|
|
237
|
+
...(toolType ? { toolType } : {}),
|
|
238
|
+
...(args ? { args } : {}),
|
|
239
|
+
...(typeof update.title === 'string' ? { intent: update.title } : {}),
|
|
240
|
+
...(acpToolTarget(update.locations, rawInput) ? { target: acpToolTarget(update.locations, rawInput) } : {}),
|
|
241
|
+
},
|
|
242
|
+
];
|
|
243
|
+
|
|
244
|
+
// Some agents announce a call ONLY once it is finished (`tool_call` with
|
|
245
|
+
// `status:"completed"` and no later update). Leaving it in the open map
|
|
246
|
+
// meant the turn's cleanup closed it as an ERROR, overwriting a success.
|
|
247
|
+
if (status === 'completed' || status === 'failed') {
|
|
248
|
+
frames.push({
|
|
249
|
+
type: 'tool_execution_end',
|
|
250
|
+
toolCallId,
|
|
251
|
+
toolName: name,
|
|
252
|
+
result: update.rawOutput ?? (update.content === undefined ? undefined : { content: update.content }),
|
|
253
|
+
isError: status === 'failed',
|
|
254
|
+
details: acpToolDetails(update.rawOutput) ?? acpContentDetails(update.content),
|
|
255
|
+
output: acpToolOutput(update.rawOutput) || acpContentText(update.content),
|
|
256
|
+
});
|
|
257
|
+
} else {
|
|
258
|
+
this.open.set(toolCallId, {
|
|
259
|
+
id: toolCallId,
|
|
260
|
+
name,
|
|
261
|
+
kind,
|
|
262
|
+
title: typeof update.title === 'string' ? update.title : undefined,
|
|
263
|
+
status,
|
|
264
|
+
rawOutput: update.rawOutput,
|
|
265
|
+
content: update.content,
|
|
266
|
+
locations: update.locations,
|
|
267
|
+
startedAt: Date.now(),
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
return frames;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* `tool_call_update` is a PATCH: every field but `toolCallId` is optional and
|
|
275
|
+
* an omitted one means UNCHANGED. Merging is what keeps a completed card's
|
|
276
|
+
* body — measured, the completion update carries only `status` and
|
|
277
|
+
* `rawOutput.details`.
|
|
278
|
+
*/
|
|
279
|
+
private patchTool(update: Record<string, unknown>): AgentEvent[] {
|
|
280
|
+
const toolCallId = typeof update.toolCallId === 'string' ? update.toolCallId : '';
|
|
281
|
+
if (!toolCallId) return [];
|
|
282
|
+
const existing = this.open.get(toolCallId);
|
|
283
|
+
// An update for a call this mapper never saw (a replay window, a resumed
|
|
284
|
+
// session): treat it as an opening call rather than dropping the work.
|
|
285
|
+
if (!existing) return this.openTool(update);
|
|
286
|
+
|
|
287
|
+
if (update.rawOutput !== undefined) existing.rawOutput = update.rawOutput;
|
|
288
|
+
if (update.content !== undefined) existing.content = update.content;
|
|
289
|
+
if (update.locations !== undefined) existing.locations = update.locations;
|
|
290
|
+
if (typeof update.title === 'string') existing.title = update.title;
|
|
291
|
+
const status = typeof update.status === 'string' ? (update.status as AcpToolStatus) : existing.status;
|
|
292
|
+
existing.status = status;
|
|
293
|
+
|
|
294
|
+
// Some agents report the result as `content` blocks instead of `rawOutput`;
|
|
295
|
+
// the diff block only becomes visible through the details bridge.
|
|
296
|
+
const result = existing.rawOutput ?? (existing.content === undefined ? undefined : { content: existing.content });
|
|
297
|
+
const output = acpToolOutput(existing.rawOutput) || acpContentText(existing.content);
|
|
298
|
+
const details = acpToolDetails(existing.rawOutput) ?? acpContentDetails(existing.content);
|
|
299
|
+
|
|
300
|
+
if (status === 'completed' || status === 'failed') {
|
|
301
|
+
const failed = status === 'failed';
|
|
302
|
+
this.open.delete(toolCallId);
|
|
303
|
+
return [{
|
|
304
|
+
type: 'tool_execution_end',
|
|
305
|
+
toolCallId,
|
|
306
|
+
toolName: existing.name,
|
|
307
|
+
result,
|
|
308
|
+
isError: failed,
|
|
309
|
+
details,
|
|
310
|
+
durationMs: Math.max(0, Date.now() - existing.startedAt),
|
|
311
|
+
output,
|
|
312
|
+
}];
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
return [{
|
|
316
|
+
type: 'tool_execution_update',
|
|
317
|
+
toolCallId,
|
|
318
|
+
toolName: existing.name,
|
|
319
|
+
partialResult: result,
|
|
320
|
+
// The ACP output shape may nest text (`{type:"content", content:{…}}`),
|
|
321
|
+
// which `toolResultText` does not walk. The flattened read travels with
|
|
322
|
+
// the raw result so the card is not blank while the call is running.
|
|
323
|
+
output,
|
|
324
|
+
}];
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
private usage(update: Record<string, unknown>): AgentEvent[] {
|
|
328
|
+
const size = typeof update.size === 'number' ? update.size : undefined;
|
|
329
|
+
const used = typeof update.used === 'number' ? update.used : undefined;
|
|
330
|
+
const rawCost = update.cost;
|
|
331
|
+
const cost = rawCost && typeof rawCost === 'object' && 'amount' in rawCost && typeof rawCost.amount === 'number'
|
|
332
|
+
? rawCost.amount
|
|
333
|
+
: undefined;
|
|
334
|
+
if (size === undefined && used === undefined) return [];
|
|
335
|
+
return [{ type: 'usage_updated', size, used, cost }];
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/** Frame emitted when a `session/prompt` resolves: ACP's only turn terminal. */
|
|
340
|
+
export function turnEndFrame(result: { stopReason?: string } | undefined): AgentEvent {
|
|
341
|
+
const stopReason = result?.stopReason;
|
|
342
|
+
const cancelled = stopReason === 'cancelled' || stopReason === 'canceled';
|
|
343
|
+
return {
|
|
344
|
+
type: 'agent_end',
|
|
345
|
+
isTerminal: true,
|
|
346
|
+
...(stopReason ? { stopReason } : {}),
|
|
347
|
+
...(cancelled ? { cancelled: true } : {}),
|
|
348
|
+
};
|
|
349
|
+
}
|