@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,308 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Read the providers OTHER harnesses already have, so a user can copy one
|
|
8
|
+
* instead of retyping an endpoint and a key.
|
|
9
|
+
*
|
|
10
|
+
* One reader per FORMAT, not per harness: three harnesses write TOML, three write
|
|
11
|
+
* JSON with a providers map, one writes JSON with a `modelProviders` array, and
|
|
12
|
+
* omp writes YAML. `HARNESS_PROVIDER_FACTS` names the file, the pointer and the
|
|
13
|
+
* field names, so a reader never guesses — and a harness added later is a row in
|
|
14
|
+
* that table, not a new branch here.
|
|
15
|
+
*
|
|
16
|
+
* Two rules decide what a row IS:
|
|
17
|
+
*
|
|
18
|
+
* - **CUSTOM only.** A registry ships its own providers, and one of those
|
|
19
|
+
* copied into another agent writes an override of the TARGET's vendor entry
|
|
20
|
+
* instead of adding a gateway — which is why the census in `vendors.ts`
|
|
21
|
+
* filters the list here and the writer refuses one that arrives anyway.
|
|
22
|
+
* - **A protocol, not a spelling.** Every id carries the canonical protocol its
|
|
23
|
+
* entry declares (`protocolOfSourceDialect`), so the card can say which
|
|
24
|
+
* targets can take it before the user presses Import.
|
|
25
|
+
*
|
|
26
|
+
* What is NEVER returned is the API KEY. A list is for CHOOSING a provider; the
|
|
27
|
+
* key is read only by the request that writes the target, from the source file.
|
|
28
|
+
* A list that carried keys would put them in every browser tab that opens
|
|
29
|
+
* Settings, which is what the masked-key rule in `dialect.ts` exists to prevent.
|
|
30
|
+
*
|
|
31
|
+
* `minimax` is read for display and never used as an import SOURCE: its BYOK
|
|
32
|
+
* store belongs to `mcode`'s writer, and copying a shape Kabmo cannot vouch for is
|
|
33
|
+
* how an import writes something the agent then refuses.
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
import { join } from 'path';
|
|
37
|
+
import YAML from 'yaml';
|
|
38
|
+
import { parse as parseToml } from 'smol-toml';
|
|
39
|
+
|
|
40
|
+
import { providerFacts, type ProviderRegistryKind } from '@/shared/lib/harness/provider-facts';
|
|
41
|
+
import { protocolOfSourceDialect, type CanonicalProtocol } from '@/shared/lib/harness/dialects';
|
|
42
|
+
import { isVendorProviderId } from '@/shared/lib/models/provider/vendors';
|
|
43
|
+
import { HARNESS_IDS, type HarnessId } from '@/shared/lib/harness/catalog';
|
|
44
|
+
import { canonicalize } from '@/server/lib/omp/core/paths';
|
|
45
|
+
import { readZcodeProviderKey, readZcodeProviders } from '@/server/lib/harness/provider-zcode.server';
|
|
46
|
+
|
|
47
|
+
/** One provider as a source registry holds it, minus its credential. */
|
|
48
|
+
export interface ImportableProvider {
|
|
49
|
+
id: string;
|
|
50
|
+
name: string;
|
|
51
|
+
baseUrl?: string;
|
|
52
|
+
/** The dialect/SDK/wire value the source declares, verbatim. */
|
|
53
|
+
dialect?: string;
|
|
54
|
+
/** That dialect folded onto the shared protocol vocabulary. */
|
|
55
|
+
protocol?: CanonicalProtocol;
|
|
56
|
+
models: string[];
|
|
57
|
+
/** Context window per model id, when the source declared one (kimi requires it). */
|
|
58
|
+
contextWindow?: Record<string, number>;
|
|
59
|
+
/** The harness the entry came from — two sources can share an id. */
|
|
60
|
+
source: HarnessId;
|
|
61
|
+
/** True when the source has a credential stored. NOT the credential. */
|
|
62
|
+
hasKey: boolean;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** A record, or an empty one. Imported YAML/JSON/TOML is untrusted. */
|
|
66
|
+
function asRecord(value: unknown): Record<string, unknown> {
|
|
67
|
+
return value && typeof value === 'object' && !Array.isArray(value) ? (value as Record<string, unknown>) : {};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The user's home, read from the ENVIRONMENT rather than `os.homedir()`.
|
|
72
|
+
*
|
|
73
|
+
* `os.homedir()` resolves against the passwd entry on some platforms, so it
|
|
74
|
+
* ignores a `HOME` set after the process started — which made every test that
|
|
75
|
+
* points `HOME` at a temp directory write into the developer's real `~/.codex`.
|
|
76
|
+
* `Bun.env.HOME` is the value the agents themselves read, so the paths Kabmo
|
|
77
|
+
* writes and the paths they read cannot disagree.
|
|
78
|
+
*/
|
|
79
|
+
export function homeDir(): string {
|
|
80
|
+
return Bun.env.HOME || Bun.env.USERPROFILE || '/';
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** The absolute path for a registry's `~`-relative file, or null. */
|
|
84
|
+
export function registryFilePath(id: HarnessId): string | null {
|
|
85
|
+
const file = providerFacts(id).registry.file;
|
|
86
|
+
return file ? join(homeDir(), file) : null;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Every harness that reads the SAME registry file.
|
|
91
|
+
*
|
|
92
|
+
* `omp-rpc` and `omp-acp` are two transports over one `models.yml`, so a
|
|
93
|
+
* provider written through either must invalidate the other's cached model
|
|
94
|
+
* list. The comparison is the file itself, not a hand-written pair, so a future
|
|
95
|
+
* harness that shares a registry inherits the rule for free.
|
|
96
|
+
*/
|
|
97
|
+
export function harnessesSharingRegistry(path: string): HarnessId[] {
|
|
98
|
+
const key = canonicalize(path);
|
|
99
|
+
return HARNESS_IDS.filter((id) => {
|
|
100
|
+
const file = registryFilePath(id);
|
|
101
|
+
return file !== null && canonicalize(file) === key;
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** A value at a dot-path (`options.baseURL`), or undefined. */
|
|
106
|
+
function atPointer(root: Record<string, unknown>, pointer: string): unknown {
|
|
107
|
+
let node: unknown = root;
|
|
108
|
+
for (const key of pointer.split('.')) {
|
|
109
|
+
const record = asRecord(node);
|
|
110
|
+
if (!(key in record)) return undefined;
|
|
111
|
+
node = record[key];
|
|
112
|
+
}
|
|
113
|
+
return node;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** Read a file as text, or null when it is absent or unreadable. */
|
|
117
|
+
async function readText(path: string | null): Promise<string | null> {
|
|
118
|
+
if (!path) return null;
|
|
119
|
+
try {
|
|
120
|
+
const file = Bun.file(path);
|
|
121
|
+
return (await file.exists()) ? await file.text() : null;
|
|
122
|
+
} catch {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** Parse a document by its registry format, or null when it will not parse. */
|
|
128
|
+
function parseByKind(kind: ProviderRegistryKind, text: string): Record<string, unknown> | null {
|
|
129
|
+
try {
|
|
130
|
+
switch (kind) {
|
|
131
|
+
case 'yaml-providers': return asRecord(YAML.parse(text));
|
|
132
|
+
case 'toml-model-providers':
|
|
133
|
+
case 'toml-providers': return asRecord(parseToml(text));
|
|
134
|
+
case 'json-provider':
|
|
135
|
+
case 'json-providers':
|
|
136
|
+
case 'json-model-providers':
|
|
137
|
+
case 'zcode-provider-rules': return asRecord(JSON.parse(text));
|
|
138
|
+
default: return null;
|
|
139
|
+
}
|
|
140
|
+
} catch {
|
|
141
|
+
// A malformed file is the AGENT's config, not Kabmo's: the reader returns no
|
|
142
|
+
// rows rather than failing the settings page over a file it did not write.
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** Model ids from a per-format model collection: an array of objects, or a map. */
|
|
148
|
+
function modelIds(value: unknown): string[] {
|
|
149
|
+
if (Array.isArray(value)) {
|
|
150
|
+
return value
|
|
151
|
+
.map((entry) => (typeof entry === 'string' ? entry : String(asRecord(entry).id ?? '')))
|
|
152
|
+
.filter(Boolean);
|
|
153
|
+
}
|
|
154
|
+
return Object.keys(asRecord(value));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Context windows from a per-format model collection.
|
|
159
|
+
*
|
|
160
|
+
* kimi's `[models.<alias>]` table requires `max_context_size`, and models.yml /
|
|
161
|
+
* pi declare `contextWindow` per model — both spellings are read here so an
|
|
162
|
+
* import can carry the number the target needs instead of inventing one.
|
|
163
|
+
*/
|
|
164
|
+
function contextWindows(value: unknown): Record<string, number> {
|
|
165
|
+
const out: Record<string, number> = {};
|
|
166
|
+
const entries = Array.isArray(value)
|
|
167
|
+
? value.map((entry) => asRecord(entry))
|
|
168
|
+
: Object.values(asRecord(value)).map((entry) => asRecord(entry));
|
|
169
|
+
for (const entry of entries) {
|
|
170
|
+
const id = typeof entry.id === 'string' ? entry.id : '';
|
|
171
|
+
const window = entry.contextWindow ?? entry.max_context_size ?? entry.limit;
|
|
172
|
+
const number = typeof window === 'number'
|
|
173
|
+
? window
|
|
174
|
+
: typeof asRecord(window).context === 'number'
|
|
175
|
+
? (asRecord(window).context as number)
|
|
176
|
+
: undefined;
|
|
177
|
+
if (id && number && number > 0) out[id] = number;
|
|
178
|
+
}
|
|
179
|
+
return out;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Every CUSTOM provider `id`'s own registry holds.
|
|
184
|
+
*
|
|
185
|
+
* A kind this build cannot read (`env`, `agent-managed`, `none`) yields nothing:
|
|
186
|
+
* there is no file, so there is nothing to list. Vendor ids are dropped for the
|
|
187
|
+
* reason at the top of this file.
|
|
188
|
+
*/
|
|
189
|
+
export async function readRegistryProviders(id: HarnessId): Promise<ImportableProvider[]> {
|
|
190
|
+
const facts = providerFacts(id);
|
|
191
|
+
const { kind, pointer, bundledIds } = facts.registry;
|
|
192
|
+
if (kind === 'env' || kind === 'agent-managed' || kind === 'none') return [];
|
|
193
|
+
|
|
194
|
+
const text = await readText(registryFilePath(id));
|
|
195
|
+
if (!text) return [];
|
|
196
|
+
const doc = parseByKind(kind, text);
|
|
197
|
+
if (!doc) return [];
|
|
198
|
+
|
|
199
|
+
// ZCode's registry is a rule GRAPH, not a providers map: one provider rule
|
|
200
|
+
// plus one rule per model. Its reader lives beside its writer.
|
|
201
|
+
if (kind === 'zcode-provider-rules') return readZcodeProviders(text, id);
|
|
202
|
+
|
|
203
|
+
// `modelProviders` is an ARRAY per protocol (qwen), so its rows are the models
|
|
204
|
+
// themselves and the provider id is the protocol key.
|
|
205
|
+
if (kind === 'json-model-providers') {
|
|
206
|
+
const groups = asRecord(atPointer(doc, pointer));
|
|
207
|
+
const rows: ImportableProvider[] = [];
|
|
208
|
+
for (const [protocol, entries] of Object.entries(groups)) {
|
|
209
|
+
const canonical = protocolOfSourceDialect(protocol);
|
|
210
|
+
for (const entry of Array.isArray(entries) ? entries : []) {
|
|
211
|
+
const model = asRecord(entry);
|
|
212
|
+
const modelId = typeof model.id === 'string' ? model.id : '';
|
|
213
|
+
if (!modelId) continue;
|
|
214
|
+
if (isVendorProviderId(modelId, bundledIds)) continue;
|
|
215
|
+
const size = asRecord(model.generationConfig).contextWindowSize;
|
|
216
|
+
rows.push({
|
|
217
|
+
id: modelId,
|
|
218
|
+
name: typeof model.name === 'string' ? model.name : modelId,
|
|
219
|
+
...(typeof model.baseUrl === 'string' ? { baseUrl: model.baseUrl } : {}),
|
|
220
|
+
dialect: protocol,
|
|
221
|
+
...(canonical ? { protocol: canonical } : {}),
|
|
222
|
+
models: [modelId],
|
|
223
|
+
...(typeof size === 'number' && size > 0 ? { contextWindow: { [modelId]: size } } : {}),
|
|
224
|
+
source: id,
|
|
225
|
+
hasKey: typeof model.envKey === 'string' && model.envKey.length > 0,
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return rows;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const providers = asRecord(atPointer(doc, pointer));
|
|
233
|
+
return Object.entries(providers)
|
|
234
|
+
.filter(([slug]) => !isVendorProviderId(slug, bundledIds))
|
|
235
|
+
.map(([slug, raw]) => {
|
|
236
|
+
const entry = asRecord(raw);
|
|
237
|
+
const baseUrl = facts.registry.baseUrlField ? atPointer(entry, facts.registry.baseUrlField) : undefined;
|
|
238
|
+
const keyValue = facts.registry.apiKeyField ? atPointer(entry, facts.registry.apiKeyField) : undefined;
|
|
239
|
+
const dialect = facts.registry.dialectField ? atPointer(entry, facts.registry.dialectField) : undefined;
|
|
240
|
+
const rawModels = facts.registry.modelsField ? atPointer(entry, facts.registry.modelsField) : undefined;
|
|
241
|
+
// kimi's provider entry declares no models at all; its aliases live in a
|
|
242
|
+
// sibling table keyed by alias, each naming the provider it belongs to.
|
|
243
|
+
const aliasModels = kind === 'toml-providers'
|
|
244
|
+
? Object.entries(asRecord(doc.models ?? {}))
|
|
245
|
+
.filter(([, row]) => asRecord(row).provider === slug)
|
|
246
|
+
.map(([alias, row]) => ({ alias, row: asRecord(row) }))
|
|
247
|
+
: [];
|
|
248
|
+
const models = aliasModels.length > 0
|
|
249
|
+
? aliasModels.map(({ row }) => String(row.model ?? ''))
|
|
250
|
+
: modelIds(rawModels);
|
|
251
|
+
const windows = kind === 'toml-providers'
|
|
252
|
+
? Object.fromEntries(aliasModels.map(({ row }) => [String(row.model ?? ''), Number(row.max_context_size)]))
|
|
253
|
+
: contextWindows(rawModels);
|
|
254
|
+
const protocol = protocolOfSourceDialect(typeof dialect === 'string' ? dialect : undefined);
|
|
255
|
+
return {
|
|
256
|
+
id: slug,
|
|
257
|
+
// The entry's own `name` when it declares one — an "Add provider" row
|
|
258
|
+
// stored the display name for exactly this, and printing the slug back
|
|
259
|
+
// makes the card look like it lost what the form asked for.
|
|
260
|
+
name: typeof entry.name === 'string' && entry.name.trim() ? entry.name : slug,
|
|
261
|
+
...(typeof baseUrl === 'string' ? { baseUrl } : {}),
|
|
262
|
+
...(typeof dialect === 'string' ? { dialect } : {}),
|
|
263
|
+
...(protocol ? { protocol } : {}),
|
|
264
|
+
models,
|
|
265
|
+
...(Object.keys(windows).length > 0 ? { contextWindow: windows } : {}),
|
|
266
|
+
source: id,
|
|
267
|
+
hasKey: typeof keyValue === 'string' && keyValue.length > 0,
|
|
268
|
+
};
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Every CUSTOM provider importable INTO `target`, from the sources its facts allow.
|
|
274
|
+
*
|
|
275
|
+
* The list is per-target (`importFrom`), so a harness that cannot take a registry
|
|
276
|
+
* offers none, and the rows carry the SOURCE because two entries can share an id
|
|
277
|
+
* (`kenari` in both omp and opencode).
|
|
278
|
+
*/
|
|
279
|
+
export async function importableProvidersFor(target: HarnessId): Promise<ImportableProvider[]> {
|
|
280
|
+
const sources = providerFacts(target).importFrom;
|
|
281
|
+
if (sources.length === 0) return [];
|
|
282
|
+
const lists = await Promise.all(sources.map((source) => readRegistryProviders(source)));
|
|
283
|
+
const seen = new Set<string>();
|
|
284
|
+
return lists.flat().filter((entry) => {
|
|
285
|
+
const key = entry.id.trim().toLowerCase();
|
|
286
|
+
if (!key || seen.has(key)) return false;
|
|
287
|
+
seen.add(key);
|
|
288
|
+
return true;
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* The KEY for one provider, read at import time.
|
|
294
|
+
*
|
|
295
|
+
* Deliberately separate from the list above: this is the only function that
|
|
296
|
+
* touches a credential, and its single caller is the request that writes.
|
|
297
|
+
*/
|
|
298
|
+
export async function readProviderKey(source: HarnessId, providerId: string): Promise<string | null> {
|
|
299
|
+
const facts = providerFacts(source);
|
|
300
|
+
const text = await readText(registryFilePath(source));
|
|
301
|
+
if (!text || !facts.registry.apiKeyField) return null;
|
|
302
|
+
const doc = parseByKind(facts.registry.kind, text);
|
|
303
|
+
if (!doc) return null;
|
|
304
|
+
if (facts.registry.kind === 'zcode-provider-rules') return readZcodeProviderKey(text, providerId);
|
|
305
|
+
const entry = asRecord(asRecord(atPointer(doc, facts.registry.pointer))[providerId]);
|
|
306
|
+
const value = atPointer(entry, facts.registry.apiKeyField);
|
|
307
|
+
return typeof value === 'string' && value.length > 0 ? value : null;
|
|
308
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The refusal a provider write throws, in its own module.
|
|
8
|
+
*
|
|
9
|
+
* Shared because TWO modules raise it — the entry builder (a dialect the target
|
|
10
|
+
* cannot speak) and the writer (an unparseable file, a bad id) — and importing one
|
|
11
|
+
* from the other would make the dependency circular for a class definition.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export class ProviderWriteError extends Error {
|
|
15
|
+
constructor(message: string) {
|
|
16
|
+
super(message);
|
|
17
|
+
this.name = 'ProviderWriteError';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Writing a provider into a harness's OWN registry, in that harness's format.
|
|
8
|
+
*
|
|
9
|
+
* Six formats, and every case here is about what the writer must NOT destroy —
|
|
10
|
+
* because these files are the AGENT's whole config, not a provider list:
|
|
11
|
+
* `opencode.json` carries plugins, agents, MCP and permissions; `config.toml`
|
|
12
|
+
* carries the model, approval policy and hooks; `settings.json` (qwen) carries
|
|
13
|
+
* the user's whole CLI configuration.
|
|
14
|
+
*
|
|
15
|
+
* Three rules are pinned across formats:
|
|
16
|
+
*
|
|
17
|
+
* - an unparseable file is REFUSED and left byte-identical;
|
|
18
|
+
* - a stored credential and the user's own dialect are KEPT when an entry is
|
|
19
|
+
* updated — an import brings an endpoint, not a reason to replace a key;
|
|
20
|
+
* - codex and qwen store a VARIABLE NAME (`env_key`/`envKey`), never the secret,
|
|
21
|
+
* which is what their own docs say and what a form must not get wrong.
|
|
22
|
+
*
|
|
23
|
+
* Every case writes to a TEMP `~`, by pointing HOME at one: a suite that touched
|
|
24
|
+
* the developer's real `~/.codex` or `~/.config/opencode` would corrupt a working
|
|
25
|
+
* install.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
import { afterAll, beforeAll, beforeEach, describe, expect, test } from 'bun:test';
|
|
29
|
+
import fs from 'node:fs';
|
|
30
|
+
import { tmpdir } from 'node:os';
|
|
31
|
+
import { join } from 'node:path';
|
|
32
|
+
|
|
33
|
+
import { providerEntryFor, ProviderWriteError, writeProvider } from '@/server/lib/harness/provider-write.server';
|
|
34
|
+
import { registryFilePath } from '@/server/lib/harness/provider-sources.server';
|
|
35
|
+
import { removeDir } from '@/test-support/remove-dir';
|
|
36
|
+
import { testPosix } from '@/test-support/platform';
|
|
37
|
+
|
|
38
|
+
const savedHome = Bun.env.HOME;
|
|
39
|
+
let root = '';
|
|
40
|
+
|
|
41
|
+
beforeAll(async () => {
|
|
42
|
+
root = await fs.promises.mkdtemp(join(tmpdir(), 'omc-provider-'));
|
|
43
|
+
// Every path in this module is home-relative, and the writer REFUSES to leave
|
|
44
|
+
// `KABMO_TEST_HOME` under test — that guard exists because an earlier run of
|
|
45
|
+
// this feature wrote into the developer's real `~/.codex` and `~/.omp` while
|
|
46
|
+
// the scripted checks were passing.
|
|
47
|
+
Bun.env.HOME = root;
|
|
48
|
+
Bun.env.KABMO_TEST_HOME = root;
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
afterAll(() => {
|
|
52
|
+
if (savedHome === undefined) delete Bun.env.HOME;
|
|
53
|
+
else Bun.env.HOME = savedHome;
|
|
54
|
+
delete Bun.env.KABMO_TEST_HOME;
|
|
55
|
+
removeDir(root);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
beforeEach(async () => {
|
|
59
|
+
for (const dir of ['.config/opencode', '.codex', '.kimi', '.qwen', '.pi/agent', '.omp/agent']) {
|
|
60
|
+
await fs.promises.rm(join(root, dir), { recursive: true, force: true });
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const DRAFT = {
|
|
65
|
+
id: 'gateway',
|
|
66
|
+
name: 'My gateway',
|
|
67
|
+
baseUrl: 'https://api.example.com/v1',
|
|
68
|
+
protocol: 'openai-chat' as const,
|
|
69
|
+
models: ['m-1', 'm-2'],
|
|
70
|
+
apiKey: 'sk-test',
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/** Write a seed file into the temp HOME, creating its directory. */
|
|
74
|
+
async function seed(relative: string, content: string): Promise<void> {
|
|
75
|
+
const path = join(root, relative);
|
|
76
|
+
await fs.promises.mkdir(join(path, '..'), { recursive: true });
|
|
77
|
+
await Bun.write(path, content);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async function read(relative: string): Promise<string> {
|
|
81
|
+
return Bun.file(join(root, relative)).text();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
describe('opencode (JSON provider map)', () => {
|
|
85
|
+
test('adds a provider and keeps every other section', async () => {
|
|
86
|
+
await seed('.config/opencode/opencode.json', JSON.stringify({
|
|
87
|
+
$schema: 'https://opencode.ai/config.json',
|
|
88
|
+
plugin: ['a@1'],
|
|
89
|
+
agent: { build: { model: 'x/y' } },
|
|
90
|
+
provider: { existing: { npm: '@ai-sdk/openai', models: {} } },
|
|
91
|
+
}, null, 2));
|
|
92
|
+
|
|
93
|
+
await writeProvider('opencode', DRAFT);
|
|
94
|
+
const doc = JSON.parse(await read('.config/opencode/opencode.json'));
|
|
95
|
+
expect(doc.plugin).toEqual(['a@1']);
|
|
96
|
+
expect(doc.agent).toEqual({ build: { model: 'x/y' } });
|
|
97
|
+
expect(doc.provider.existing).toBeDefined();
|
|
98
|
+
expect(doc.provider.gateway.npm).toBe('@ai-sdk/openai-compatible');
|
|
99
|
+
expect(doc.provider.gateway.options.baseURL).toBe('https://api.example.com/v1');
|
|
100
|
+
expect(Object.keys(doc.provider.gateway.models)).toEqual(['m-1', 'm-2']);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test('one opencode registry, now that the 2.x preview IS the 1.x binary', async () => {
|
|
104
|
+
// `opencode2` used to be a separate binary with its own beta line; it is now a
|
|
105
|
+
// shim that execs `opencode` (measured: both report v2.2.5). There is no second
|
|
106
|
+
// registry to keep in step, so the catalog has one opencode entry.
|
|
107
|
+
expect(registryFilePath('opencode')).toBeTruthy();
|
|
108
|
+
await writeProvider('opencode', DRAFT);
|
|
109
|
+
const doc = JSON.parse(await read('.config/opencode/opencode.json'));
|
|
110
|
+
expect(doc.provider.gateway).toBeDefined();
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
test('an update keeps a stored key and the user’s own dialect', async () => {
|
|
114
|
+
await seed('.config/opencode/opencode.json', JSON.stringify({
|
|
115
|
+
provider: { gateway: { npm: '@ai-sdk/anthropic', name: 'Hand named', options: { apiKey: 'old-key', whitelist: 'x' }, models: {} } },
|
|
116
|
+
}, null, 2));
|
|
117
|
+
|
|
118
|
+
const result = await writeProvider('opencode', DRAFT);
|
|
119
|
+
expect(result.replaced).toBe(true);
|
|
120
|
+
|
|
121
|
+
const entry = JSON.parse(await read('.config/opencode/opencode.json')).provider.gateway;
|
|
122
|
+
expect(entry.npm).toBe('@ai-sdk/anthropic');
|
|
123
|
+
expect(entry.name).toBe('Hand named');
|
|
124
|
+
expect(entry.options.apiKey).toBe('old-key');
|
|
125
|
+
expect(entry.options.whitelist).toBe('x');
|
|
126
|
+
expect(entry.options.baseURL).toBe('https://api.example.com/v1');
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
test('a file that is not JSON is refused and left untouched', async () => {
|
|
130
|
+
await seed('.config/opencode/opencode.json', '{ not json');
|
|
131
|
+
await expect(writeProvider('opencode', DRAFT)).rejects.toThrow(ProviderWriteError);
|
|
132
|
+
expect(await read('.config/opencode/opencode.json')).toBe('{ not json');
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
describe('omp (YAML providers map)', () => {
|
|
137
|
+
test('adds a provider with the fields omp reads', async () => {
|
|
138
|
+
await seed('.omp/agent/models.yml', 'providers:\n existing:\n baseUrl: https://x/v1\n api: openai-completions\n');
|
|
139
|
+
await writeProvider('omp-rpc', DRAFT);
|
|
140
|
+
|
|
141
|
+
const text = await read('.omp/agent/models.yml');
|
|
142
|
+
// YAML, and the key names omp's own schema uses.
|
|
143
|
+
expect(text).toContain('gateway:');
|
|
144
|
+
expect(text).toContain('baseUrl: https://api.example.com/v1');
|
|
145
|
+
expect(text).toContain('api: openai-completions');
|
|
146
|
+
expect(text).toContain('- id: m-1');
|
|
147
|
+
// The pre-existing provider survives the merge.
|
|
148
|
+
expect(text).toContain('existing:');
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
describe('codex (TOML model_providers)', () => {
|
|
153
|
+
test('stores a VARIABLE NAME, never the secret, and answers with the env it needs', async () => {
|
|
154
|
+
// codex reads `env_key`, which names an env var. Writing `sk-test` into
|
|
155
|
+
// config.toml would put the credential in a file its docs keep it out of —
|
|
156
|
+
// so the value is handed back for the harness env instead.
|
|
157
|
+
const result = await writeProvider('codex', { ...DRAFT, protocol: 'openai-responses' });
|
|
158
|
+
const text = await read('.codex/config.toml');
|
|
159
|
+
expect(text).toContain('[model_providers.gateway]');
|
|
160
|
+
expect(text).toContain('base_url = "https://api.example.com/v1"');
|
|
161
|
+
expect(text).toContain('env_key = "GATEWAY_API_KEY"');
|
|
162
|
+
expect(text).not.toContain('sk-test');
|
|
163
|
+
// codex accepts ONE wire format now; `chat` makes every command fail.
|
|
164
|
+
expect(text).toContain('wire_api = "responses"');
|
|
165
|
+
expect(result.env).toEqual({ GATEWAY_API_KEY: 'sk-test' });
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
test('a protocol codex cannot speak is REFUSED, not mislabelled', async () => {
|
|
169
|
+
// An Anthropic endpoint written as `wire_api = "chat"` would fail on the
|
|
170
|
+
// first request against a gateway that never agreed to that protocol, and
|
|
171
|
+
// codex rejects `chat` outright at config load.
|
|
172
|
+
await expect(writeProvider('codex', { ...DRAFT, protocol: 'anthropic-messages' }))
|
|
173
|
+
.rejects.toThrow(/no protocol|cannot speak/);
|
|
174
|
+
expect(await fs.promises.stat(join(root, '.codex/config.toml')).catch(() => null)).toBeNull();
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
test('a Chat-Completions source is refused by name, not relabelled', async () => {
|
|
178
|
+
await expect(writeProvider('codex', DRAFT)).rejects.toThrow(/no protocol that matches/);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
test('a Responses source becomes wire_api = "responses"', async () => {
|
|
182
|
+
const entry = providerEntryFor('toml-model-providers', { ...DRAFT, protocol: 'openai-responses' }, 'codex');
|
|
183
|
+
expect(entry.wire_api).toBe('responses');
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
test('the rest of config.toml survives', async () => {
|
|
187
|
+
await seed('.codex/config.toml', 'model = "gpt-6"\napproval_policy = "on-request"\n');
|
|
188
|
+
await writeProvider('codex', { ...DRAFT, protocol: 'openai-responses' });
|
|
189
|
+
const text = await read('.codex/config.toml');
|
|
190
|
+
expect(text).toContain('model = "gpt-6"');
|
|
191
|
+
expect(text).toContain('approval_policy = "on-request"');
|
|
192
|
+
expect(text).toContain('[model_providers.gateway]');
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
describe('pi (JSON providers map)', () => {
|
|
197
|
+
test('adds a provider with baseUrl, api and models', async () => {
|
|
198
|
+
await writeProvider('pi', DRAFT);
|
|
199
|
+
const doc = JSON.parse(await read('.pi/agent/models.json'));
|
|
200
|
+
expect(doc.providers.gateway.baseUrl).toBe('https://api.example.com/v1');
|
|
201
|
+
expect(doc.providers.gateway.api).toBe('openai-completions');
|
|
202
|
+
expect(doc.providers.gateway.models).toEqual([{ id: 'm-1' }, { id: 'm-2' }]);
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
describe('kimi (TOML providers table)', () => {
|
|
207
|
+
test('maps the protocol onto kimi-code’s `type` and writes the model aliases it needs', async () => {
|
|
208
|
+
// kimi-code replaced the retired CLI's `openai_legacy`/`gemini` spellings,
|
|
209
|
+
// and a provider with no `[models.<alias>]` serves nothing at all.
|
|
210
|
+
await writeProvider('kimi', { ...DRAFT, protocol: 'anthropic-messages' });
|
|
211
|
+
const text = await read('.kimi-code/config.toml');
|
|
212
|
+
expect(text).toContain('[providers.gateway]');
|
|
213
|
+
expect(text).toContain('type = "anthropic"');
|
|
214
|
+
expect(text).toContain('base_url = "https://api.example.com/v1"');
|
|
215
|
+
expect(text).toContain('api_key = "sk-test"');
|
|
216
|
+
expect(text).toContain('[models."gateway/m-1"]');
|
|
217
|
+
expect(text).toContain('provider = "gateway"');
|
|
218
|
+
expect(text).toContain('max_context_size = 128000');
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
test('writes a declared context window rather than the default', async () => {
|
|
222
|
+
await writeProvider('kimi', {
|
|
223
|
+
...DRAFT, protocol: 'openai-chat', models: ['m-1'], contextWindow: { 'm-1': 1_048_576 },
|
|
224
|
+
});
|
|
225
|
+
expect(await read('.kimi-code/config.toml')).toContain('max_context_size = 1048576');
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
describe('qwen (JSON modelProviders, array per protocol)', () => {
|
|
230
|
+
test('a route is a MODEL row under the BUCKET its protocol names, with envKey', async () => {
|
|
231
|
+
await writeProvider('qwen', DRAFT);
|
|
232
|
+
const doc = JSON.parse(await read('.qwen/settings.json'));
|
|
233
|
+
const openai = doc.modelProviders.openai as { id: string; baseUrl: string; envKey: string }[];
|
|
234
|
+
// One row PER MODEL: qwen's rows are model routes, so two ids are two rows.
|
|
235
|
+
expect(openai.map((row) => row.id)).toEqual(['m-1', 'm-2']);
|
|
236
|
+
expect(openai[0]!.baseUrl).toBe('https://api.example.com/v1');
|
|
237
|
+
expect(openai[0]!.envKey).toBe('GATEWAY_API_KEY');
|
|
238
|
+
// The secret stays out of the ROW, as its docs require; qwen reads the value
|
|
239
|
+
// from `env`, so that is where the writer puts it.
|
|
240
|
+
expect(JSON.stringify(doc.modelProviders)).not.toContain('sk-test');
|
|
241
|
+
expect(doc.env.GATEWAY_API_KEY).toBe('sk-test');
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
test('TWO providers keep two credentials, not one shared variable name', async () => {
|
|
245
|
+
// Measured before the fix: both rows wrote `OPENAI_API_KEY`, so adding the
|
|
246
|
+
// second provider silently re-pointed the first at a different key.
|
|
247
|
+
// Distinct models, because qwen identifies a row by PROTOCOL + id + baseUrl:
|
|
248
|
+
// two providers serving the same model at the same endpoint ARE one route.
|
|
249
|
+
await writeProvider('qwen', { ...DRAFT, id: 'gateway-one', models: ['m-1'], apiKey: 'sk-one' });
|
|
250
|
+
await writeProvider('qwen', { ...DRAFT, id: 'gateway-two', models: ['m-2'], apiKey: 'sk-two' });
|
|
251
|
+
const doc = JSON.parse(await read('.qwen/settings.json'));
|
|
252
|
+
const rows = doc.modelProviders.openai as { id: string; envKey: string }[];
|
|
253
|
+
expect(rows.map((row) => row.envKey)).toEqual(['GATEWAY_ONE_API_KEY', 'GATEWAY_TWO_API_KEY']);
|
|
254
|
+
expect(doc.env).toEqual({ GATEWAY_ONE_API_KEY: 'sk-one', GATEWAY_TWO_API_KEY: 'sk-two' });
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
test('an Anthropic route lands in the anthropic bucket, not under the provider id', async () => {
|
|
258
|
+
await writeProvider('qwen', { ...DRAFT, protocol: 'anthropic-messages' });
|
|
259
|
+
const doc = JSON.parse(await read('.qwen/settings.json'));
|
|
260
|
+
expect(doc.modelProviders.anthropic[0].id).toBe('m-1');
|
|
261
|
+
expect(doc.modelProviders.openai).toBeUndefined();
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
describe('vendor ids are never imported over', () => {
|
|
266
|
+
test('a provider the agent ships is refused by name', async () => {
|
|
267
|
+
await expect(writeProvider('codex', { ...DRAFT, id: 'openai', protocol: 'openai-responses' }))
|
|
268
|
+
.rejects.toThrow(/ships itself/);
|
|
269
|
+
await expect(writeProvider('qwen', { ...DRAFT, id: 'qwen-oauth' }))
|
|
270
|
+
.rejects.toThrow(/ships itself/);
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
describe('refusals', () => {
|
|
275
|
+
test('a harness with no writable registry is refused, naming it', async () => {
|
|
276
|
+
await expect(writeProvider('minimax', DRAFT)).rejects.toThrow(/keeps its providers itself/);
|
|
277
|
+
await expect(writeProvider('cursor', DRAFT)).rejects.toThrow(/no provider registry/);
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
test('an id the agent would reject is refused before anything is written', async () => {
|
|
281
|
+
await expect(writeProvider('opencode', { ...DRAFT, id: 'Not Valid!' })).rejects.toThrow(/not a provider id/);
|
|
282
|
+
// A colon is legal in kimi's own provider names, so it must survive.
|
|
283
|
+
await expect(writeProvider('kimi', { ...DRAFT, id: 'managed:test' })).resolves.toBeTruthy();
|
|
284
|
+
expect(await fs.promises.stat(join(root, '.config/opencode/opencode.json')).catch(() => null)).toBeNull();
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
test('a write outside the test home is REFUSED', async () => {
|
|
288
|
+
// The guard that exists because an earlier run wrote into a real `~/.codex`.
|
|
289
|
+
const saved = Bun.env.KABMO_TEST_HOME;
|
|
290
|
+
Bun.env.KABMO_TEST_HOME = join(root, 'elsewhere');
|
|
291
|
+
try {
|
|
292
|
+
await expect(writeProvider('opencode', DRAFT)).rejects.toThrow(/refusing to write/);
|
|
293
|
+
} finally {
|
|
294
|
+
Bun.env.KABMO_TEST_HOME = saved;
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
// POSIX only: Windows has no permission bits, and `statSync().mode` there
|
|
299
|
+
// reports a synthesised 0o666 for every file — measured on the Windows gate as
|
|
300
|
+
// `Expected: 384, Received: 438` (0o600 vs 0o666) for a write that had set the
|
|
301
|
+
// mode correctly on the host. `chmod` is a no-op there, so there is nothing to
|
|
302
|
+
// assert; the POSIX legs keep this case.
|
|
303
|
+
testPosix('the file is written 0600: it holds a credential', async () => {
|
|
304
|
+
await writeProvider('opencode', DRAFT);
|
|
305
|
+
const mode = (await fs.promises.stat(join(root, '.config/opencode/opencode.json'))).mode & 0o777;
|
|
306
|
+
expect(mode).toBe(0o600);
|
|
307
|
+
});
|
|
308
|
+
});
|