@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,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Per-harness config: what a user can change about ONE ACP agent.
|
|
8
|
+
*
|
|
9
|
+
* Four decisions are pinned here, each because the wrong one is silent:
|
|
10
|
+
*
|
|
11
|
+
* - **a quoted path survives `splitCommand`** — a command override exists
|
|
12
|
+
* mostly for a binary under a directory with a space, and a naive
|
|
13
|
+
* `split(' ')` would cut it in half and fail at spawn with no explanation;
|
|
14
|
+
* - **`VALUE=` with nothing after it is kept** — an empty env var is a real
|
|
15
|
+
* setting (some CLIs read its presence), while a line without `=` is a typo
|
|
16
|
+
* and is REPORTED rather than becoming a key with an empty value;
|
|
17
|
+
* - **a stale default model falls through** — writing a model the agent no
|
|
18
|
+
* longer lists fails the first prompt, so the config resolves against what
|
|
19
|
+
* the probe actually published;
|
|
20
|
+
* - **empty means the build's default**, in every field, so an install that
|
|
21
|
+
* never opened the form spawns exactly what it spawned before.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import { describe, expect, test } from 'bun:test';
|
|
25
|
+
import {
|
|
26
|
+
EMPTY_HARNESS_CONFIG,
|
|
27
|
+
harnessConfigKey,
|
|
28
|
+
isHarnessConfigured,
|
|
29
|
+
modelProvider,
|
|
30
|
+
parseEnvLines,
|
|
31
|
+
parseHarnessConfig,
|
|
32
|
+
providerChoices,
|
|
33
|
+
resolveDefaultModel,
|
|
34
|
+
splitCommand,
|
|
35
|
+
} from '@/shared/lib/harness/config';
|
|
36
|
+
|
|
37
|
+
describe('splitCommand', () => {
|
|
38
|
+
test('keeps a quoted path whole', () => {
|
|
39
|
+
expect(splitCommand('"/Users/me/My Tools/agy" acp')).toEqual(['/Users/me/My Tools/agy', 'acp']);
|
|
40
|
+
expect(splitCommand("'/Users/me/My Tools/agy' acp")).toEqual(['/Users/me/My Tools/agy', 'acp']);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('collapses whitespace and keeps every argument', () => {
|
|
44
|
+
expect(splitCommand(' cmd acp ')).toEqual(['cmd', 'acp']);
|
|
45
|
+
expect(splitCommand('npx -y pkg@1.0.0')).toEqual(['npx', '-y', 'pkg@1.0.0']);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test('an empty line is no command at all, which is what empty means', () => {
|
|
49
|
+
expect(splitCommand('')).toEqual([]);
|
|
50
|
+
expect(splitCommand(' ')).toEqual([]);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test('an unterminated quote keeps the rest instead of dropping it', () => {
|
|
54
|
+
// A half-typed line should fail at spawn with the agent's own error, not
|
|
55
|
+
// silently lose the argument.
|
|
56
|
+
expect(splitCommand('"/opt/my tool acp')).toEqual(['/opt/my tool acp']);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
describe('parseEnvLines', () => {
|
|
61
|
+
test('parses KEY=VALUE, keeps an empty value, skips comments', () => {
|
|
62
|
+
const { env, invalid } = parseEnvLines('A=1\n# a comment\n\nB=\nC=x=y');
|
|
63
|
+
expect(env).toEqual({ A: '1', B: '', C: 'x=y' });
|
|
64
|
+
expect(invalid).toEqual([]);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test('reports a line without `=` instead of inventing an empty value', () => {
|
|
68
|
+
const { env, invalid } = parseEnvLines('GOOD=1\nNOT_AN_ASSIGNMENT\n=noKey');
|
|
69
|
+
expect(env).toEqual({ GOOD: '1' });
|
|
70
|
+
expect(invalid).toEqual(['NOT_AN_ASSIGNMENT', '=noKey']);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test('rejects a key that is not an identifier', () => {
|
|
74
|
+
const { invalid } = parseEnvLines('1BAD=x\nwith-dash=x');
|
|
75
|
+
expect(invalid).toHaveLength(2);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
describe('resolveDefaultModel', () => {
|
|
80
|
+
const models = [
|
|
81
|
+
{ value: 'command-code/claude-sonnet-5' },
|
|
82
|
+
{ value: 'command-code/claude-opus-4-6' },
|
|
83
|
+
{ value: 'anthropic/claude-fable-5' },
|
|
84
|
+
];
|
|
85
|
+
|
|
86
|
+
test('an exact model wins when the agent still lists it', () => {
|
|
87
|
+
expect(resolveDefaultModel({ ...EMPTY_HARNESS_CONFIG, model: 'anthropic/claude-fable-5' }, models))
|
|
88
|
+
.toBe('anthropic/claude-fable-5');
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test('a stale model falls through instead of being written', () => {
|
|
92
|
+
// Writing a model the agent dropped is what fails the FIRST prompt.
|
|
93
|
+
expect(resolveDefaultModel({ ...EMPTY_HARNESS_CONFIG, model: 'gone/model' }, models)).toBeNull();
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test('the provider picks the first of its models', () => {
|
|
97
|
+
expect(resolveDefaultModel({ ...EMPTY_HARNESS_CONFIG, provider: 'anthropic' }, models))
|
|
98
|
+
.toBe('anthropic/claude-fable-5');
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
test('a stale model still yields the provider default, not nothing', () => {
|
|
102
|
+
expect(resolveDefaultModel({ ...EMPTY_HARNESS_CONFIG, model: 'gone/model', provider: 'command-code' }, models))
|
|
103
|
+
.toBe('command-code/claude-sonnet-5');
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test('no config is null: the agent keeps its own default', () => {
|
|
107
|
+
expect(resolveDefaultModel(EMPTY_HARNESS_CONFIG, models)).toBeNull();
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
describe('providerChoices', () => {
|
|
112
|
+
test('lists each provider once, in publication order', () => {
|
|
113
|
+
expect(providerChoices([
|
|
114
|
+
{ value: 'a/1' }, { value: 'b/1' }, { value: 'a/2' }, { value: 'c/1' },
|
|
115
|
+
])).toEqual(['a', 'b', 'c']);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test('a value with no slash contributes no provider', () => {
|
|
119
|
+
expect(providerChoices([{ value: 'bare-model' }, { value: 'p/m' }])).toEqual(['p']);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
test('modelProvider reads the FIRST slash, so nested ids keep their tail', () => {
|
|
123
|
+
expect(modelProvider('command-code/deepseek/deepseek-v4-flash')).toBe('command-code');
|
|
124
|
+
expect(modelProvider('bare')).toBe('');
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
describe('parseHarnessConfig', () => {
|
|
129
|
+
test('an absent or malformed row reads as empty, never as a partial', () => {
|
|
130
|
+
expect(parseHarnessConfig(null)).toEqual(EMPTY_HARNESS_CONFIG);
|
|
131
|
+
expect(parseHarnessConfig('nope')).toEqual(EMPTY_HARNESS_CONFIG);
|
|
132
|
+
expect(parseHarnessConfig([])).toEqual(EMPTY_HARNESS_CONFIG);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
test('a non-string field falls back on its own instead of poisoning the rest', () => {
|
|
136
|
+
const parsed = parseHarnessConfig({ command: '/opt/agy acp', provider: 42, model: 'a/b' });
|
|
137
|
+
expect(parsed.command).toBe('/opt/agy acp');
|
|
138
|
+
expect(parsed.provider).toBe('');
|
|
139
|
+
expect(parsed.model).toBe('a/b');
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
test('an all-empty config is "not configured", so saving it deletes the row', () => {
|
|
143
|
+
expect(isHarnessConfigured(EMPTY_HARNESS_CONFIG)).toBe(false);
|
|
144
|
+
expect(isHarnessConfigured({ ...EMPTY_HARNESS_CONFIG, env: 'A=1' })).toBe(true);
|
|
145
|
+
// Whitespace is not configuration.
|
|
146
|
+
expect(isHarnessConfigured({ ...EMPTY_HARNESS_CONFIG, command: ' ' })).toBe(false);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
test('the storage key is per harness', () => {
|
|
150
|
+
expect(harnessConfigKey('antigravity')).toBe('omp_harness_config:antigravity');
|
|
151
|
+
expect(harnessConfigKey('antigravity')).not.toBe(harnessConfigKey('claude'));
|
|
152
|
+
});
|
|
153
|
+
});
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Per-harness configuration: what a user may change about ONE ACP agent.
|
|
8
|
+
*
|
|
9
|
+
* The launch table is the build's knowledge of how to start an agent on a stock
|
|
10
|
+
* machine. It is wrong for anyone whose CLI lives elsewhere, who authenticates
|
|
11
|
+
* against their own provider, or who always wants the same model — and the only
|
|
12
|
+
* way to express that used to be editing the source. These four knobs cover the
|
|
13
|
+
* cases that came up, and each has a reason to exist:
|
|
14
|
+
*
|
|
15
|
+
* - **`command`** — the binary is not on PATH (`~/bin/agy`, a wrapper that
|
|
16
|
+
* signs in first). Empty means "use the table".
|
|
17
|
+
* - **`env`** — provider selection and credentials that the agent reads from
|
|
18
|
+
* its environment (`GEMINI_API_KEY`, `GOOGLE_GEMINI_BASE_URL`,
|
|
19
|
+
* `CODEX_PATH`). A real provider choice for an ACP agent IS an env or a
|
|
20
|
+
* config-selector value; there is no Kabmo-side routing for it.
|
|
21
|
+
* - **`provider`** — which provider's models this harness should start on. ACP
|
|
22
|
+
* publishes each model as `provider/model`, so a provider is a filter over
|
|
23
|
+
* that list, not a separate setting the agent understands.
|
|
24
|
+
* - **`model`, `thinking`, `mode`** — the defaults a new chat starts on, so the
|
|
25
|
+
* first prompt does not run on whatever the agent happens to prefer.
|
|
26
|
+
*
|
|
27
|
+
* Everything is a STRING or empty: absent means "the build's default", never a
|
|
28
|
+
* silent zero. `parseHarnessConfig` is pure so the merge and the validation can
|
|
29
|
+
* be asserted without a database.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
import type { HarnessId } from '@/shared/lib/harness/catalog';
|
|
33
|
+
|
|
34
|
+
export interface HarnessConfig {
|
|
35
|
+
/** Launch command, space-separated. Empty = the build's table. */
|
|
36
|
+
command: string;
|
|
37
|
+
/** `KEY=VALUE` lines, one per line. Empty = the build's env, if any. */
|
|
38
|
+
env: string;
|
|
39
|
+
/** Provider prefix the model list should start on (`command-code`, `anthropic`). */
|
|
40
|
+
provider: string;
|
|
41
|
+
/** Default model VALUE as the agent spells it (`command-code/claude-sonnet-5`). */
|
|
42
|
+
model: string;
|
|
43
|
+
/** Default thinking level / effort. */
|
|
44
|
+
thinking: string;
|
|
45
|
+
/** Default mode (`plan`, `auto-accept`, …). */
|
|
46
|
+
mode: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const EMPTY_HARNESS_CONFIG: HarnessConfig = {
|
|
50
|
+
command: '',
|
|
51
|
+
env: '',
|
|
52
|
+
provider: '',
|
|
53
|
+
model: '',
|
|
54
|
+
thinking: '',
|
|
55
|
+
mode: '',
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/** The stored shape is partial and untrusted: a database row from an older build,
|
|
59
|
+
* a hand-edited value, a plugin write. Every field falls back to empty. */
|
|
60
|
+
export function parseHarnessConfig(raw: unknown): HarnessConfig {
|
|
61
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return { ...EMPTY_HARNESS_CONFIG };
|
|
62
|
+
const source = raw as Record<string, unknown>;
|
|
63
|
+
const text = (key: keyof HarnessConfig): string => (
|
|
64
|
+
typeof source[key] === 'string' ? (source[key] as string) : ''
|
|
65
|
+
);
|
|
66
|
+
return {
|
|
67
|
+
command: text('command'),
|
|
68
|
+
env: text('env'),
|
|
69
|
+
provider: text('provider'),
|
|
70
|
+
model: text('model'),
|
|
71
|
+
thinking: text('thinking'),
|
|
72
|
+
mode: text('mode'),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Split a launch line into a command vector.
|
|
78
|
+
*
|
|
79
|
+
* Quoted segments survive (`"my tool" --acp` is two tokens, not three), because
|
|
80
|
+
* a path with a space is the most common reason someone overrides the command at
|
|
81
|
+
* all. An unterminated quote keeps the rest as one token rather than dropping it:
|
|
82
|
+
* a half-typed line should fail at spawn with the agent's own error, not
|
|
83
|
+
* silently lose the argument.
|
|
84
|
+
*/
|
|
85
|
+
export function splitCommand(line: string): string[] {
|
|
86
|
+
const out: string[] = [];
|
|
87
|
+
let current = '';
|
|
88
|
+
let quote: '"' | "'" | null = null;
|
|
89
|
+
for (const char of line.trim()) {
|
|
90
|
+
if (quote) {
|
|
91
|
+
if (char === quote) quote = null;
|
|
92
|
+
else current += char;
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if (char === '"' || char === "'") {
|
|
96
|
+
quote = char;
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
if (char === ' ' || char === '\t') {
|
|
100
|
+
if (current) out.push(current);
|
|
101
|
+
current = '';
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
current += char;
|
|
105
|
+
}
|
|
106
|
+
if (current) out.push(current);
|
|
107
|
+
return out;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Parse `KEY=VALUE` lines into an env map.
|
|
112
|
+
*
|
|
113
|
+
* A line without `=` is SKIPPED and reported, never treated as a key with an
|
|
114
|
+
* empty value: an empty env var is a real thing to set, and a typo should not
|
|
115
|
+
* quietly become one. `VALUE=` with nothing after it is kept for that reason.
|
|
116
|
+
*/
|
|
117
|
+
export function parseEnvLines(text: string): { env: Record<string, string>; invalid: string[] } {
|
|
118
|
+
const env: Record<string, string> = {};
|
|
119
|
+
const invalid: string[] = [];
|
|
120
|
+
for (const rawLine of text.split('\n')) {
|
|
121
|
+
const line = rawLine.trim();
|
|
122
|
+
if (!line || line.startsWith('#')) continue;
|
|
123
|
+
const equals = line.indexOf('=');
|
|
124
|
+
if (equals <= 0) {
|
|
125
|
+
invalid.push(line);
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
const key = line.slice(0, equals).trim();
|
|
129
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(key)) {
|
|
130
|
+
invalid.push(line);
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
env[key] = line.slice(equals + 1);
|
|
134
|
+
}
|
|
135
|
+
return { env, invalid };
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** The provider half of an ACP model selector (`provider/model`). */
|
|
139
|
+
export function modelProvider(value: string): string {
|
|
140
|
+
const slash = value.indexOf('/');
|
|
141
|
+
return slash <= 0 ? '' : value.slice(0, slash);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Set these variables in a config's env, replacing any the user already had.
|
|
146
|
+
*
|
|
147
|
+
* Importing a provider into a harness whose credential is an ENV var (codex's
|
|
148
|
+
* `env_key`, an `environment` harness) writes the value here, and appending the
|
|
149
|
+
* line would leave two lines for one key — the same variable set twice in one
|
|
150
|
+
* form, where a reader cannot tell which the spawn uses. The merge is by KEY,
|
|
151
|
+
* through the same parser the spawn uses, so a line the parser rejects cannot
|
|
152
|
+
* survive as a duplicate.
|
|
153
|
+
*/
|
|
154
|
+
export function withEnvValues(config: HarnessConfig, values: Record<string, string>): HarnessConfig {
|
|
155
|
+
if (Object.keys(values).length === 0) return config;
|
|
156
|
+
const { env } = parseEnvLines(config.env);
|
|
157
|
+
const merged = { ...env, ...values };
|
|
158
|
+
return {
|
|
159
|
+
...config,
|
|
160
|
+
env: Object.entries(merged).map(([key, value]) => `${key}=${value}`).join('\n'),
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Which model value a harness should start on, from its config and the models
|
|
166
|
+
* the agent published.
|
|
167
|
+
*
|
|
168
|
+
* Exact `model` wins when the agent still lists it — a model the agent dropped
|
|
169
|
+
* must not be written, so a stale default falls through instead of failing the
|
|
170
|
+
* spawn. Otherwise the first model of the configured PROVIDER. Otherwise null:
|
|
171
|
+
* the agent's own default, which is what an empty config means.
|
|
172
|
+
*/
|
|
173
|
+
export function resolveDefaultModel(
|
|
174
|
+
config: HarnessConfig,
|
|
175
|
+
models: readonly { value: string }[],
|
|
176
|
+
): string | null {
|
|
177
|
+
if (config.model && models.some((option) => option.value === config.model)) return config.model;
|
|
178
|
+
if (config.provider) {
|
|
179
|
+
const fromProvider = models.find((option) => modelProvider(option.value) === config.provider);
|
|
180
|
+
if (fromProvider) return fromProvider.value;
|
|
181
|
+
}
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** Every provider the agent's model list mentions, in the order it published. */
|
|
186
|
+
export function providerChoices(models: readonly { value: string }[]): string[] {
|
|
187
|
+
const seen = new Set<string>();
|
|
188
|
+
const out: string[] = [];
|
|
189
|
+
for (const option of models) {
|
|
190
|
+
const provider = modelProvider(option.value);
|
|
191
|
+
if (!provider || seen.has(provider)) continue;
|
|
192
|
+
seen.add(provider);
|
|
193
|
+
out.push(provider);
|
|
194
|
+
}
|
|
195
|
+
return out;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** A config with nothing set, for a harness the user never configured. */
|
|
199
|
+
export function isHarnessConfigured(config: HarnessConfig): boolean {
|
|
200
|
+
return Object.values(config).some((value) => value.trim() !== '');
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** The key a harness's config lives under in `app_settings`. */
|
|
204
|
+
export function harnessConfigKey(id: HarnessId): string {
|
|
205
|
+
return `omp_harness_config:${id}`;
|
|
206
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* One protocol vocabulary, six spellings — and the measured traps each row
|
|
8
|
+
* prevents.
|
|
9
|
+
*
|
|
10
|
+
* The failure this pins is silent in every direction: a dialect passed through
|
|
11
|
+
* from one registry to another is a value the target rejects, and codex now
|
|
12
|
+
* REJECTS `wire_api = "chat"` by failing to load its whole config. The base-URL
|
|
13
|
+
* rule is the other measured trap: Claude Code appends `/v1/messages` itself, so
|
|
14
|
+
* a base URL that still carries `/v1` requested `/v1/v1/messages` and answered
|
|
15
|
+
* an empty turn.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { describe, expect, test } from 'bun:test';
|
|
19
|
+
|
|
20
|
+
import {
|
|
21
|
+
adaptBaseUrl,
|
|
22
|
+
dialectFor,
|
|
23
|
+
planProtocol,
|
|
24
|
+
protocolOfSourceDialect,
|
|
25
|
+
protocolsFor,
|
|
26
|
+
supportedProtocols,
|
|
27
|
+
wireApiFor,
|
|
28
|
+
} from '@/shared/lib/harness/dialects';
|
|
29
|
+
|
|
30
|
+
describe('protocolOfSourceDialect', () => {
|
|
31
|
+
test('every registry vocabulary folds onto the same five protocols', () => {
|
|
32
|
+
// omp models.yml
|
|
33
|
+
expect(protocolOfSourceDialect('openai-completions')).toBe('openai-chat');
|
|
34
|
+
expect(protocolOfSourceDialect('openai-responses')).toBe('openai-responses');
|
|
35
|
+
expect(protocolOfSourceDialect('anthropic-messages')).toBe('anthropic-messages');
|
|
36
|
+
expect(protocolOfSourceDialect('google-generative-ai')).toBe('google-genai');
|
|
37
|
+
// opencode's npm package names
|
|
38
|
+
expect(protocolOfSourceDialect('@ai-sdk/openai-compatible')).toBe('openai-chat');
|
|
39
|
+
expect(protocolOfSourceDialect('@ai-sdk/anthropic')).toBe('anthropic-messages');
|
|
40
|
+
// kimi-code types
|
|
41
|
+
expect(protocolOfSourceDialect('openai_responses')).toBe('openai-responses');
|
|
42
|
+
expect(protocolOfSourceDialect('vertexai')).toBe('vertex-ai');
|
|
43
|
+
// codex wire_api, qwen bucket, pi api
|
|
44
|
+
expect(protocolOfSourceDialect('chat')).toBe('openai-chat');
|
|
45
|
+
expect(protocolOfSourceDialect('responses')).toBe('openai-responses');
|
|
46
|
+
expect(protocolOfSourceDialect('openai')).toBe('openai-chat');
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('a dialect with no portable route is UNKNOWN rather than guessed', () => {
|
|
50
|
+
// Bedrock signs with SigV4, Gemini CLI and the judge APIs have no `/models`;
|
|
51
|
+
// mapping any of them to a chat protocol would write a provider that 401s.
|
|
52
|
+
expect(protocolOfSourceDialect('bedrock-converse-stream')).toBeNull();
|
|
53
|
+
expect(protocolOfSourceDialect('google-gemini-cli')).toBeNull();
|
|
54
|
+
expect(protocolOfSourceDialect('openrouter-decisions')).toBeNull();
|
|
55
|
+
expect(protocolOfSourceDialect(undefined)).toBeNull();
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
describe('dialectFor', () => {
|
|
60
|
+
test('codex is Responses-only, so a Chat source has NO spelling there', () => {
|
|
61
|
+
// Measured: `wire_api = "chat"` makes codex refuse to load config at all.
|
|
62
|
+
expect(dialectFor('toml-model-providers', 'openai-responses')).toBe('responses');
|
|
63
|
+
expect(dialectFor('toml-model-providers', 'openai-chat')).toBeNull();
|
|
64
|
+
expect(dialectFor('toml-model-providers', 'anthropic-messages')).toBeNull();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test('kimi writes the types the CURRENT CLI documents', () => {
|
|
68
|
+
expect(dialectFor('toml-providers', 'openai-chat')).toBe('openai');
|
|
69
|
+
expect(dialectFor('toml-providers', 'google-genai')).toBe('google-genai');
|
|
70
|
+
// The retired CLI's spellings are gone rather than kept as aliases.
|
|
71
|
+
expect(dialectFor('toml-providers', 'openai-chat')).not.toBe('openai_legacy');
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test('qwen names its BUCKET, and its OpenAI bucket also carries the wire choice', () => {
|
|
75
|
+
expect(dialectFor('json-model-providers', 'openai-chat')).toBe('openai');
|
|
76
|
+
expect(dialectFor('json-model-providers', 'anthropic-messages')).toBe('anthropic');
|
|
77
|
+
expect(wireApiFor('openai-responses')).toBe('responses');
|
|
78
|
+
expect(wireApiFor('openai-chat')).toBe('chat-completions');
|
|
79
|
+
expect(wireApiFor('anthropic-messages')).toBeNull();
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test('omp and pi share one vocabulary because both are the vendor’s own names', () => {
|
|
83
|
+
for (const protocol of protocolsFor('yaml-providers')) {
|
|
84
|
+
expect(dialectFor('json-providers', protocol)).toBe(dialectFor('yaml-providers', protocol));
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
describe('planProtocol', () => {
|
|
90
|
+
test('the source protocol wins when the target speaks it', () => {
|
|
91
|
+
expect(planProtocol('anthropic-messages', ['anthropic-messages', 'openai-chat'])).toBe('anthropic-messages');
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
test('an unknown source still lands when the target has only one protocol', () => {
|
|
95
|
+
expect(planProtocol(null, ['anthropic-messages'])).toBe('anthropic-messages');
|
|
96
|
+
// With a real choice, "unknown" must not become a guess.
|
|
97
|
+
expect(planProtocol(null, ['anthropic-messages', 'openai-chat'])).toBeNull();
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test('no shared protocol means a refusal, not a substitution', () => {
|
|
101
|
+
expect(planProtocol('google-genai', ['anthropic-messages'])).toBeNull();
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
describe('adaptBaseUrl', () => {
|
|
106
|
+
test('a vendor SDK that appends /v1 gets the HOST ROOT', () => {
|
|
107
|
+
// Measured: `https://kenari.id/v1` in ANTHROPIC_BASE_URL made Claude Code
|
|
108
|
+
// request `/v1/v1/messages` and answer an empty turn; the root worked.
|
|
109
|
+
expect(adaptBaseUrl('https://kenari.id/v1', 'root')).toBe('https://kenari.id');
|
|
110
|
+
expect(adaptBaseUrl('https://kenari.id/v1/', 'root')).toBe('https://kenari.id');
|
|
111
|
+
expect(adaptBaseUrl('https://gw.example/v1beta', 'root')).toBe('https://gw.example');
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test('a registry client that appends only the route keeps its /v1', () => {
|
|
115
|
+
expect(adaptBaseUrl('https://kenari.id/v1', 'api-base')).toBe('https://kenari.id/v1');
|
|
116
|
+
expect(adaptBaseUrl('https://kenari.id/v1/', 'api-base')).toBe('https://kenari.id/v1');
|
|
117
|
+
// A base without a version segment is untouched either way.
|
|
118
|
+
expect(adaptBaseUrl('https://gw.example', 'api-base')).toBe('https://gw.example');
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
describe('supportedProtocols', () => {
|
|
123
|
+
test('an environment harness carries exactly one protocol', () => {
|
|
124
|
+
expect(supportedProtocols('env', 'anthropic-messages')).toEqual(['anthropic-messages']);
|
|
125
|
+
expect(supportedProtocols('env')).toEqual([]);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
test('a harness with no registry carries nothing', () => {
|
|
129
|
+
expect(supportedProtocols('none')).toEqual([]);
|
|
130
|
+
expect(supportedProtocols('agent-managed')).toEqual([]);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
test('zcode carries its three documented wire types, not Gemini', () => {
|
|
134
|
+
expect(supportedProtocols('zcode-provider-rules')).toEqual([
|
|
135
|
+
'openai-chat', 'openai-responses', 'anthropic-messages',
|
|
136
|
+
]);
|
|
137
|
+
// The registry has no Google route: an import must refuse, not mislabel.
|
|
138
|
+
expect(dialectFor('zcode-provider-rules', 'google-genai')).toBeNull();
|
|
139
|
+
});
|
|
140
|
+
});
|