@kabmo-labs/kabmo 0.11.1 → 0.12.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 +67 -421
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +426 -413
- package/dist/client/static/js/{index-amss8pge.js → index-0smc9gm2.js} +1123 -747
- package/dist/client/static/js/index-shexbk5f.css +1 -0
- package/marketplace/marketplace.json +13 -3
- package/marketplace/plugins/command-runner/package.json +4 -2
- package/marketplace/plugins/git-forge/README.md +219 -0
- package/marketplace/plugins/git-forge/icon.svg +20 -0
- package/marketplace/plugins/git-forge/package.json +56 -0
- package/marketplace/plugins/git-forge/src/app.tsx +82 -0
- package/marketplace/plugins/git-forge/src/command.test.ts +181 -0
- package/marketplace/plugins/git-forge/src/command.ts +119 -0
- package/marketplace/plugins/git-forge/src/header.tsx +87 -0
- package/marketplace/plugins/git-forge/src/panel/Badge.tsx +76 -0
- package/marketplace/plugins/git-forge/src/panel/Change.tsx +150 -0
- package/marketplace/plugins/git-forge/src/panel/CiBadge.tsx +51 -0
- package/marketplace/plugins/git-forge/src/panel/Credential.tsx +107 -0
- package/marketplace/plugins/git-forge/src/panel/Glyph.tsx +70 -0
- package/marketplace/plugins/git-forge/src/panel/Header.tsx +255 -0
- package/marketplace/plugins/git-forge/src/panel/ItemView.tsx +198 -0
- package/marketplace/plugins/git-forge/src/panel/List.tsx +89 -0
- package/marketplace/plugins/git-forge/src/panel/Row.tsx +68 -0
- package/marketplace/plugins/git-forge/src/panel/Sidebar.tsx +94 -0
- package/marketplace/plugins/git-forge/src/panel/Write.tsx +236 -0
- package/marketplace/plugins/git-forge/src/panel/format.ts +78 -0
- package/marketplace/plugins/git-forge/src/panel/index.test.tsx +344 -0
- package/marketplace/plugins/git-forge/src/panel/index.tsx +193 -0
- package/marketplace/plugins/git-forge/src/panel/use-forge.ts +250 -0
- package/marketplace/plugins/git-forge/src/panel/write.test.tsx +269 -0
- package/marketplace/plugins/git-forge/src/protocol.ts +308 -0
- package/marketplace/plugins/git-forge/src/server/adapters.test.ts +274 -0
- package/marketplace/plugins/git-forge/src/server/bitbucket.ts +307 -0
- package/marketplace/plugins/git-forge/src/server/capabilities.test.ts +116 -0
- package/marketplace/plugins/git-forge/src/server/capabilities.ts +105 -0
- package/marketplace/plugins/git-forge/src/server/ci.test.ts +88 -0
- package/marketplace/plugins/git-forge/src/server/ci.ts +118 -0
- package/marketplace/plugins/git-forge/src/server/context.ts +76 -0
- package/marketplace/plugins/git-forge/src/server/diff.test.ts +127 -0
- package/marketplace/plugins/git-forge/src/server/diff.ts +120 -0
- package/marketplace/plugins/git-forge/src/server/filters.test.ts +138 -0
- package/marketplace/plugins/git-forge/src/server/filters.ts +138 -0
- package/marketplace/plugins/git-forge/src/server/forges.test.ts +235 -0
- package/marketplace/plugins/git-forge/src/server/gitea.ts +296 -0
- package/marketplace/plugins/git-forge/src/server/github-extras.ts +92 -0
- package/marketplace/plugins/git-forge/src/server/github.ts +320 -0
- package/marketplace/plugins/git-forge/src/server/gitlab-detail.ts +207 -0
- package/marketplace/plugins/git-forge/src/server/gitlab.test.ts +195 -0
- package/marketplace/plugins/git-forge/src/server/gitlab.ts +176 -0
- package/marketplace/plugins/git-forge/src/server/http.test.ts +270 -0
- package/marketplace/plugins/git-forge/src/server/http.ts +329 -0
- package/marketplace/plugins/git-forge/src/server/map.ts +120 -0
- package/marketplace/plugins/git-forge/src/server/registry.ts +47 -0
- package/marketplace/plugins/git-forge/src/server/remote.test.ts +146 -0
- package/marketplace/plugins/git-forge/src/server/remote.ts +188 -0
- package/marketplace/plugins/git-forge/src/server/scope-probe.test.ts +98 -0
- package/marketplace/plugins/git-forge/src/server/scope-probe.ts +128 -0
- package/marketplace/plugins/git-forge/src/server/scope.ts +66 -0
- package/marketplace/plugins/git-forge/src/server/test-context.ts +67 -0
- package/marketplace/plugins/git-forge/src/server/test-host.ts +51 -0
- package/marketplace/plugins/git-forge/src/server/token.test.ts +107 -0
- package/marketplace/plugins/git-forge/src/server/token.ts +139 -0
- package/marketplace/plugins/git-forge/src/server/write-http.test.ts +127 -0
- package/marketplace/plugins/git-forge/src/server/write-http.ts +110 -0
- package/marketplace/plugins/git-forge/src/server/writes.test.ts +218 -0
- package/marketplace/plugins/git-forge/src/server/writes.ts +313 -0
- package/marketplace/plugins/git-forge/src/server.ts +284 -0
- package/marketplace/plugins/git-forge/tsconfig.json +16 -0
- package/marketplace/plugins/session-info/package.json +4 -2
- package/marketplace/plugins/stats/package.json +4 -2
- package/package.json +6 -1
- package/src/client/components/common/code-surface/blame-hover.ts +188 -0
- package/src/client/components/common/code-surface/blame-panel.test.ts +304 -0
- package/src/client/components/common/code-surface/blame-panel.ts +306 -0
- package/src/client/components/common/code-surface/blame.test.ts +303 -0
- package/src/client/components/common/code-surface/blame.ts +227 -0
- package/src/client/components/common/code-surface/conflict-markers.test.ts +135 -0
- package/src/client/components/common/code-surface/conflict-markers.ts +144 -0
- package/src/client/components/common/code-surface/documents.ts +48 -1
- package/src/client/components/common/code-surface/extensions.test.ts +4 -0
- package/src/client/components/common/code-surface/extensions.ts +44 -0
- package/src/client/components/common/code-surface/fold-stack.test.ts +4 -0
- package/src/client/components/common/code-surface/indent.test.ts +5 -0
- package/src/client/components/common/code-surface/index.tsx +16 -2
- package/src/client/components/common/code-surface/lint-parsers.test.ts +109 -0
- package/src/client/components/common/code-surface/lint-parsers.ts +134 -0
- package/src/client/components/common/code-surface/lint.test.ts +101 -0
- package/src/client/components/common/code-surface/lint.ts +85 -0
- package/src/client/components/common/code-surface/props.ts +17 -0
- package/src/client/components/common/code-surface/surface-failures.test.ts +132 -0
- package/src/client/components/common/code-surface/theme.ts +71 -0
- package/src/client/components/common/header-controls/index.test.tsx +1 -1
- package/src/client/components/common/header-controls/plugin-entry.test.tsx +1 -1
- package/src/client/components/common/header-controls/shell-chrome.test.tsx +1 -1
- package/src/client/components/common/provider-icon/Plate.tsx +88 -0
- package/src/client/components/common/provider-icon/index.tsx +55 -11
- package/src/client/components/layout/session-sidebar/SessionsView.tsx +5 -2
- package/src/client/components/mobile/SessionSidebar.tsx +2 -10
- package/src/client/components/mobile/mobile-right-sidebar/FullEditor.tsx +6 -0
- package/src/client/components/mobile/mobile-right-sidebar/StatusBar.tsx +8 -0
- package/src/client/components/settings/categories/AppearanceSettings.tsx +3 -0
- package/src/client/components/settings/categories/ProviderSettings.tsx +43 -41
- package/src/client/components/settings/categories/appearance-settings/EditorBlameSection.tsx +97 -0
- package/src/client/components/settings/categories/panel-plugins/AvailableList.tsx +106 -54
- package/src/client/components/settings/categories/panel-plugins/GitFreshness.tsx +14 -1
- package/src/client/components/settings/categories/panel-plugins/InstalledList.tsx +39 -150
- package/src/client/components/settings/categories/panel-plugins/Meta.test.tsx +143 -0
- package/src/client/components/settings/categories/panel-plugins/Meta.tsx +157 -0
- package/src/client/components/settings/categories/panel-plugins/Placement.test.tsx +149 -0
- package/src/client/components/settings/categories/panel-plugins/Placement.tsx +99 -0
- package/src/client/components/settings/categories/panel-plugins/PluginCard.tsx +270 -0
- package/src/client/components/settings/categories/panel-plugins/Section.tsx +11 -3
- package/src/client/components/settings/categories/provider-settings/AddModelModal.tsx +25 -0
- package/src/client/components/settings/categories/provider-settings/AuthSection.tsx +135 -80
- package/src/client/components/settings/categories/provider-settings/DeleteProviderModal.tsx +51 -21
- package/src/client/components/settings/categories/provider-settings/EntryAdvanced.tsx +175 -0
- package/src/client/components/settings/categories/provider-settings/EntryModal.tsx +275 -0
- package/src/client/components/settings/categories/provider-settings/Header.tsx +40 -9
- package/src/client/components/settings/categories/provider-settings/LoginModal.tsx +142 -160
- package/src/client/components/settings/categories/provider-settings/LogoutProviderModal.tsx +2 -2
- package/src/client/components/settings/categories/provider-settings/ModelCapabilitiesModal.tsx +84 -46
- package/src/client/components/settings/categories/provider-settings/ModelsList.tsx +217 -102
- package/src/client/components/settings/categories/provider-settings/PresetPicker.tsx +5 -2
- package/src/client/components/settings/categories/provider-settings/SidebarList.plugin.test.ts +3 -3
- package/src/client/components/settings/categories/provider-settings/SidebarList.tsx +158 -102
- package/src/client/components/settings/categories/provider-settings/auth-section.test.tsx +135 -0
- package/src/client/components/settings/categories/provider-settings/groups.test.ts +98 -0
- package/src/client/components/settings/categories/provider-settings/groups.ts +108 -0
- package/src/client/components/settings/categories/provider-settings/layout.test.tsx +325 -0
- package/src/client/components/settings/categories/provider-settings/model-dialogs.test.tsx +135 -0
- package/src/client/components/settings/categories/provider-settings/preset-picker.test.tsx +73 -0
- package/src/client/components/settings/categories/usage-settings/ProviderCard.tsx +22 -2
- package/src/client/components/settings/categories/usage-settings/ProviderDetail.tsx +2 -0
- package/src/client/components/settings/categories/usage-settings/SidebarList.tsx +16 -6
- package/src/client/components/settings/categories/usage-settings/providers.ts +3 -0
- package/src/client/components/settings/categories/usage-settings/usage-and-picker.test.ts +19 -0
- package/src/client/components/settings/categories/usage-settings/usage-icons.test.tsx +143 -0
- package/src/client/components/workspace/chat-timeline/MinimapShortcuts.test.ts +2 -1
- package/src/client/components/workspace/chat-timeline/chat-input/GoalBanner.test.ts +23 -19
- package/src/client/components/workspace/chat-timeline/chat-input/ModeToggles.test.ts +23 -19
- package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.test.ts +20 -18
- package/src/client/components/workspace/chat-timeline/chat-input/compact.test.tsx +19 -6
- package/src/client/components/workspace/chat-timeline/index.tsx +7 -16
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.missing.test.ts +100 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.test.ts +3 -47
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.tsx +8 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/wait-test-util.ts +62 -0
- package/src/client/components/workspace/diff-panel/HunkStepper.tsx +62 -0
- package/src/client/components/workspace/diff-panel/MergeDiffView.tsx +29 -0
- package/src/client/components/workspace/diff-panel/Toolbar.tsx +32 -1
- package/src/client/components/workspace/diff-panel/changes.ts +69 -0
- package/src/client/components/workspace/diff-panel/chunks.ts +85 -0
- package/src/client/components/workspace/diff-panel/index.tsx +21 -1
- package/src/client/components/workspace/diff-panel/merge.test.ts +145 -0
- package/src/client/components/workspace/diff-panel/merge.ts +63 -68
- package/src/client/components/workspace/editor/EditorDropOverlay.tsx +6 -1
- package/src/client/components/workspace/editor/FileDocument.tsx +51 -1
- package/src/client/components/workspace/editor/FilePane.tsx +25 -1
- package/src/client/components/workspace/editor/StatusBar.tsx +19 -0
- package/src/client/components/workspace/editor/Toolbar.tsx +29 -5
- package/src/client/components/workspace/editor/toolbar-clusters.test.ts +86 -0
- package/src/client/components/workspace/editor/toolbar-clusters.tsx +48 -16
- package/src/client/components/workspace/editor/viewers/bytes.ts +16 -0
- package/src/client/components/workspace/git-panel/index.test.ts +46 -1
- package/src/client/components/workspace/git-panel/index.tsx +11 -38
- package/src/client/components/workspace/model-dropdown/Item.plugin.test.ts +66 -0
- package/src/client/components/workspace/model-dropdown/Item.tsx +71 -62
- package/src/client/components/workspace/model-dropdown/Section.tsx +31 -14
- package/src/client/components/workspace/model-dropdown/collapsed.ts +72 -0
- package/src/client/components/workspace/model-dropdown/index.tsx +42 -19
- package/src/client/components/workspace/model-dropdown/refresh.test.tsx +260 -0
- package/src/client/components/workspace/model-dropdown/trigger.test.ts +34 -0
- package/src/client/components/workspace/model-dropdown/use-catalog.ts +13 -2
- package/src/client/components/workspace/usage-panel/ProviderSelect.tsx +19 -3
- package/src/client/hooks/chat/omp/folder-auto-expand.ts +113 -0
- package/src/client/hooks/chat/omp/index.ts +20 -0
- package/src/client/hooks/chat/omp/pending-rows.ts +21 -0
- package/src/client/hooks/chat/omp/pending-sessions.test.ts +16 -1
- package/src/client/hooks/chat/omp/session-sidebar-controller.test.ts +102 -0
- package/src/client/hooks/chat/omp/session-sidebar-controller.ts +21 -1
- package/src/client/hooks/chat/omp/stream.ts +8 -1
- package/src/client/hooks/chat/timeline/index.ts +1 -1
- package/src/client/hooks/chat/timeline/new-chat-open.ts +60 -0
- package/src/client/hooks/editor/blame-settings.ts +67 -0
- package/src/client/hooks/editor/blame.test.ts +272 -0
- package/src/client/hooks/editor/blame.ts +232 -0
- package/src/client/hooks/editor/file-editor-types.ts +23 -0
- package/src/client/hooks/editor/save-file.test.ts +20 -0
- package/src/client/hooks/editor/use-editor-drop.test-util.ts +198 -0
- package/src/client/hooks/editor/use-editor-drop.test.ts +70 -175
- package/src/client/hooks/editor/use-editor-drop.ts +19 -36
- package/src/client/hooks/editor/use-file-editor.ts +7 -1
- package/src/client/hooks/settings/providers/actions.ts +90 -194
- package/src/client/hooks/settings/providers/api.ts +7 -1
- package/src/client/hooks/settings/providers/index.ts +171 -59
- package/src/client/hooks/settings/providers/login.test.ts +79 -0
- package/src/client/hooks/settings/providers/login.ts +276 -0
- package/src/client/hooks/settings/providers/messages.ts +28 -0
- package/src/client/hooks/settings/providers/model-actions.ts +178 -0
- package/src/client/hooks/ui/editor-error-toast.ts +47 -0
- package/src/client/hooks/ui/open-file.ts +7 -0
- package/src/client/hooks/ui/toasts.ts +7 -0
- package/src/client/hooks/workspace/file-tabs.ts +4 -1
- package/src/client/hooks/workspace/folder-expansion.test.ts +62 -0
- package/src/client/hooks/workspace/folder-expansion.ts +33 -0
- package/src/client/hooks/workspace/git-action-outcome.ts +86 -0
- package/src/client/hooks/workspace/git-actions.ts +29 -2
- package/src/client/hooks/workspace/plugin-contributions.test.ts +117 -0
- package/src/client/hooks/workspace/plugin-contributions.ts +146 -0
- package/src/client/lib/editor-errors.test.ts +85 -0
- package/src/client/lib/editor-errors.ts +71 -0
- package/src/client/lib/fs/resolve-open.test.ts +125 -0
- package/src/client/lib/fs/resolve-open.ts +90 -0
- package/src/client/lib/git/action-message.test.ts +82 -0
- package/src/client/lib/git/action-message.ts +160 -0
- package/src/client/lib/launch/device-files.test.ts +160 -0
- package/src/client/lib/launch/device-files.ts +197 -0
- package/src/client/lib/native/open-paths.test.ts +140 -0
- package/src/client/lib/native/open-paths.ts +157 -0
- package/src/client/lib/plugins/bootstrap.test.ts +1 -1
- package/src/client/main.tsx +20 -0
- package/src/server/db.server.test.ts +39 -0
- package/src/server/db.server.ts +21 -2
- package/src/server/lib/db/schema.ts +2 -0
- package/src/server/lib/fs/external-roots.test.ts +100 -0
- package/src/server/lib/fs/external-roots.ts +101 -0
- package/src/server/lib/fs/git-actions-branch.ts +15 -2
- package/src/server/lib/fs/git-actions-shared.ts +24 -0
- package/src/server/lib/fs/git-actions-sync.test.ts +18 -7
- package/src/server/lib/fs/git-actions-worktree.ts +5 -1
- package/src/server/lib/fs/git-blame.test.ts +206 -0
- package/src/server/lib/fs/git-blame.ts +189 -0
- package/src/server/lib/fs/root.ts +14 -0
- package/src/server/lib/http/same-origin.ts +28 -7
- package/src/server/lib/models/catalog.server.ts +230 -0
- package/src/server/lib/models/catalog.test.ts +83 -0
- package/src/server/lib/models/credential-origin.server.ts +108 -0
- package/src/server/lib/models/credential-origin.test.ts +132 -0
- package/src/server/lib/models/provider-icon-fetch.ts +115 -0
- package/src/server/lib/models/provider-icon-parse.test.ts +134 -0
- package/src/server/lib/models/provider-icon-parse.ts +139 -0
- package/src/server/lib/models/provider-icon-store.server.ts +118 -0
- package/src/server/lib/models/provider-icon-store.test.ts +107 -0
- package/src/server/lib/models/provider-icon.server.ts +209 -0
- package/src/server/lib/models/provider-items.server.ts +211 -37
- package/src/server/lib/models/provider-items.test.ts +201 -0
- package/src/server/lib/models/provider-registry.server.test.ts +27 -9
- package/src/server/lib/models/provider-registry.server.ts +160 -67
- package/src/server/lib/models/registry.server.test.ts +3 -3
- package/src/server/lib/models/registry.server.ts +8 -0
- package/src/server/lib/omp/config/definitions.test.ts +5 -4
- package/src/server/lib/omp/config/models-config.ts +42 -0
- package/src/server/lib/omp/config/provider-entry.test.ts +205 -0
- package/src/server/lib/omp/config/provider-entry.ts +197 -0
- package/src/server/lib/omp/config/provider-seeds.ts +10 -0
- package/src/server/lib/omp/core/models-json.ts +69 -0
- package/src/server/lib/omp/session/messages.ts +17 -3
- package/src/server/lib/omp/session/sidebar-data.canonical.test.ts +13 -3
- package/src/server/lib/panels/bundled-catalog.server.ts +7 -0
- package/src/server/lib/panels/catalog-offers.server.ts +68 -0
- package/src/server/lib/panels/git-update.server.test.ts +14 -0
- package/src/server/lib/panels/git-update.server.ts +63 -1
- package/src/server/lib/panels/manifest.test.ts +65 -0
- package/src/server/lib/panels/manifest.ts +55 -1
- package/src/server/lib/panels/offers.server.test.ts +191 -0
- package/src/server/lib/panels/offers.server.ts +108 -0
- package/src/server/lib/panels/registry.server.test.ts +35 -1
- package/src/server/lib/panels/registry.server.ts +51 -142
- package/src/server/lib/panels/scan.server.ts +162 -0
- package/src/server/lib/route-adapter.ts +13 -2
- package/src/server/lib/tray/tray.test.ts +2 -1
- package/src/server/lib/usage/providers.server.ts +4 -1
- package/src/server/routes/chat/session.ts +7 -1
- package/src/server/routes/fs/git-blame-loader.test.ts +146 -0
- package/src/server/routes/fs/git.ts +17 -0
- package/src/server/routes/fs/grant.test.ts +135 -0
- package/src/server/routes/fs/grant.ts +79 -0
- package/src/server/routes/fs/index.ts +2 -0
- package/src/server/routes/fs/scope.ts +34 -17
- package/src/server/routes/omp/login.ts +41 -14
- package/src/server/routes/omp/routes.test.ts +23 -10
- package/src/server/routes/settings/index.ts +8 -0
- package/src/server/routes/settings/provider-entry.ts +108 -0
- package/src/server/routes/settings/provider-icon.ts +99 -0
- package/src/server/routes/settings/provider-model.ts +4 -1
- package/src/server/routes/settings/provider-refresh.ts +87 -0
- package/src/server/routes/settings/providers.ts +31 -2
- package/src/shared/lib/chat/omp/fold.test.ts +34 -0
- package/src/shared/lib/chat/omp/tool-frames.test.ts +20 -0
- package/src/shared/lib/chat/omp/tool-frames.ts +5 -1
- package/src/shared/lib/chat/omp/tool-results.ts +29 -3
- package/src/shared/lib/chat/tool/wait-facts.ts +4 -0
- package/src/shared/lib/fs/git-blame.test.ts +266 -0
- package/src/shared/lib/fs/git-blame.ts +246 -0
- package/src/shared/lib/git/url.ts +18 -0
- package/src/shared/lib/markdown/sanitize.test.ts +57 -0
- package/src/shared/lib/markdown/sanitize.ts +30 -7
- package/src/shared/lib/models/provider/connection.ts +135 -0
- package/src/shared/lib/models/provider/dialect.test.ts +4 -2
- package/src/shared/lib/models/provider/dialect.ts +76 -6
- package/src/shared/lib/models/provider/models.ts +2 -0
- package/src/shared/lib/models/provider/origin.ts +94 -0
- package/src/shared/lib/models/provider/provider-ui.test.ts +7 -0
- package/src/shared/lib/models/server-cache.ts +8 -3
- package/src/shared/lib/omp/session/messages-map-pending.test.ts +110 -0
- package/src/shared/lib/omp/session/messages-map.ts +34 -2
- package/src/shared/lib/omp/session/prewarm-misc.test.ts +7 -90
- package/src/shared/lib/omp/session/prewarm.test.ts +133 -0
- package/src/shared/lib/omp/session/prewarm.ts +23 -1
- package/src/shared/lib/omp/session/wait.test.ts +28 -0
- package/src/shared/lib/omp/session/wait.ts +38 -3
- package/src/shared/lib/panels/slot-labels.test.ts +61 -0
- package/src/shared/lib/panels/slot-labels.ts +133 -0
- package/src/shared/lib/workspace/panel-ids.ts +11 -0
- package/src/shared/types/fs.ts +6 -0
- package/src/shared/types/index.ts +1 -0
- package/src/shared/types/models.ts +12 -0
- package/src/shared/types/panels-registry.ts +277 -0
- package/src/shared/types/panels.ts +46 -213
- package/src/shared/types/settings/provider.ts +58 -0
- package/src/shared/types/settings/usage.ts +10 -0
- package/src/test-support/pristine-globals.ts +7 -0
- package/dist/client/static/js/index-bq6qeayr.css +0 -1
- package/src/client/components/settings/categories/provider-settings/ReconnectModal.tsx +0 -184
|
@@ -12,6 +12,11 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import type { ProviderItem } from '@/shared/types';
|
|
15
|
+
import type {
|
|
16
|
+
OmpProviderApi,
|
|
17
|
+
ProviderAuthMode,
|
|
18
|
+
ProviderDiscoveryType,
|
|
19
|
+
} from '@/shared/types/settings/provider';
|
|
15
20
|
import { notifyModelsUpdated } from '@/shared/lib/models/client';
|
|
16
21
|
|
|
17
22
|
const PROVIDERS_ENDPOINT = '/api/settings/providers';
|
|
@@ -40,6 +45,136 @@ export function setProviderEnabled(slug: string, enabled: boolean): Promise<Prov
|
|
|
40
45
|
return postProviders(enabled ? { enableProvider: slug } : { disableProvider: slug });
|
|
41
46
|
}
|
|
42
47
|
|
|
48
|
+
/** omp's discovery block: a type plus the knobs that type accepts. */
|
|
49
|
+
export interface ProviderDiscoveryConfig {
|
|
50
|
+
type: ProviderDiscoveryType;
|
|
51
|
+
timeoutMs?: number;
|
|
52
|
+
injectV1?: boolean;
|
|
53
|
+
advertisedReasoning?: boolean;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** One provider entry's editable fields; `null` removes the field. */
|
|
57
|
+
export interface ProviderEntryPatch {
|
|
58
|
+
baseUrl?: string | null;
|
|
59
|
+
apiKey?: string | null;
|
|
60
|
+
api?: OmpProviderApi | null;
|
|
61
|
+
auth?: ProviderAuthMode | null;
|
|
62
|
+
discovery?: ProviderDiscoveryConfig | null;
|
|
63
|
+
headers?: Record<string, string> | null;
|
|
64
|
+
authHeader?: boolean | null;
|
|
65
|
+
transport?: 'pi-native' | null;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface ProviderEntryResult {
|
|
69
|
+
ok: boolean;
|
|
70
|
+
changed?: string[];
|
|
71
|
+
reason?: string;
|
|
72
|
+
error?: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Write a provider's endpoint / credential / dialect into `models.yml`.
|
|
77
|
+
*
|
|
78
|
+
* The overlay POST above cannot do this: the registry merge discards an overlay
|
|
79
|
+
* row for any slug `models.yml` owns, so a rotated key saved there was never
|
|
80
|
+
* read by omp. This route edits the file itself.
|
|
81
|
+
*/
|
|
82
|
+
export async function saveProviderEntry(
|
|
83
|
+
slug: string,
|
|
84
|
+
patch: ProviderEntryPatch,
|
|
85
|
+
): Promise<ProviderEntryResult> {
|
|
86
|
+
try {
|
|
87
|
+
const response = await fetch('/api/settings/provider-entry', {
|
|
88
|
+
method: 'PUT',
|
|
89
|
+
headers: { 'Content-Type': 'application/json' },
|
|
90
|
+
body: JSON.stringify({ slug, ...patch }),
|
|
91
|
+
});
|
|
92
|
+
const data = await response.json() as ProviderEntryResult;
|
|
93
|
+
if (!response.ok) {
|
|
94
|
+
return { ok: false, error: data.error ?? data.reason ?? `HTTP ${response.status}` };
|
|
95
|
+
}
|
|
96
|
+
notifyModelsUpdated();
|
|
97
|
+
return { ...data, ok: true };
|
|
98
|
+
} catch (error) {
|
|
99
|
+
return { ok: false, error: error instanceof Error ? error.message : 'Network error while saving the provider' };
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export interface ProviderIconRefreshResult {
|
|
104
|
+
ok: boolean;
|
|
105
|
+
iconUrl?: string;
|
|
106
|
+
error?: string;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Refetch one provider's web icon from its own site.
|
|
111
|
+
*
|
|
112
|
+
* The stored icon is good for a week, which is right for a logo that rarely
|
|
113
|
+
* changes and wrong the moment the site ships a new one — this is the control
|
|
114
|
+
* that says "look again now".
|
|
115
|
+
*/
|
|
116
|
+
export async function refreshProviderIcon(slug: string, baseUrl: string): Promise<ProviderIconRefreshResult> {
|
|
117
|
+
try {
|
|
118
|
+
const response = await fetch('/api/provider-icon', {
|
|
119
|
+
method: 'POST',
|
|
120
|
+
headers: { 'Content-Type': 'application/json' },
|
|
121
|
+
body: JSON.stringify({ slug, baseUrl }),
|
|
122
|
+
});
|
|
123
|
+
const data = await response.json() as ProviderIconRefreshResult;
|
|
124
|
+
if (!response.ok) return { ok: false, error: data.error ?? `HTTP ${response.status}` };
|
|
125
|
+
return data;
|
|
126
|
+
} catch (error) {
|
|
127
|
+
return { ok: false, error: error instanceof Error ? error.message : 'Network error while fetching the icon' };
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export interface CatalogRefreshResult {
|
|
132
|
+
ok: boolean;
|
|
133
|
+
added: number;
|
|
134
|
+
removed: number;
|
|
135
|
+
changed: Array<{ slug: string; before: number; after: number }>;
|
|
136
|
+
providers?: ProviderItem[];
|
|
137
|
+
error?: string;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Ask omp to re-run model discovery (`omp models refresh`).
|
|
142
|
+
*
|
|
143
|
+
* This is omp's own refresh, not a Kabmo-side probe: the CLI re-mints
|
|
144
|
+
* `!command` credentials and updates the catalog cache the chat picker reads,
|
|
145
|
+
* so the panel and the agent cannot disagree about what a provider serves.
|
|
146
|
+
* `slug` only narrows the REPORT — omp offers no provider-scoped refresh.
|
|
147
|
+
*/
|
|
148
|
+
export async function refreshProviderCatalog(slug?: string): Promise<CatalogRefreshResult> {
|
|
149
|
+
try {
|
|
150
|
+
const response = await fetch('/api/settings/providers/refresh', {
|
|
151
|
+
method: 'POST',
|
|
152
|
+
headers: { 'Content-Type': 'application/json' },
|
|
153
|
+
body: JSON.stringify(slug ? { slug } : {}),
|
|
154
|
+
});
|
|
155
|
+
const data = await response.json() as CatalogRefreshResult;
|
|
156
|
+
if (!response.ok) {
|
|
157
|
+
return {
|
|
158
|
+
ok: false,
|
|
159
|
+
added: 0,
|
|
160
|
+
removed: 0,
|
|
161
|
+
changed: [],
|
|
162
|
+
error: data.error ?? `HTTP ${response.status}`,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
notifyModelsUpdated();
|
|
166
|
+
return data;
|
|
167
|
+
} catch (error) {
|
|
168
|
+
return {
|
|
169
|
+
ok: false,
|
|
170
|
+
added: 0,
|
|
171
|
+
removed: 0,
|
|
172
|
+
changed: [],
|
|
173
|
+
error: error instanceof Error ? error.message : 'Network error while refreshing models',
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
43
178
|
export interface ProviderDeleteResult {
|
|
44
179
|
ok: boolean;
|
|
45
180
|
providers?: ProviderItem[];
|
|
@@ -48,6 +48,8 @@ describe('dialect vocabulary', () => {
|
|
|
48
48
|
'google-gemini-cli',
|
|
49
49
|
'google-vertex',
|
|
50
50
|
'openrouter-decisions',
|
|
51
|
+
'openai-decisions',
|
|
52
|
+
'workers-ai-systemone',
|
|
51
53
|
'typesafe',
|
|
52
54
|
]);
|
|
53
55
|
});
|
|
@@ -237,13 +239,13 @@ describe('providerEmptyReason', () => {
|
|
|
237
239
|
describe('providerFetchBlockReason', () => {
|
|
238
240
|
test('a discovery provider is blocked even with an endpoint', () => {
|
|
239
241
|
const expected =
|
|
240
|
-
'omp lists this provider’s models itself —
|
|
242
|
+
'omp lists this provider’s models itself — importing would freeze a snapshot beside that live list. Use “refresh”.';
|
|
241
243
|
expect(providerFetchBlockReason({ baseUrl: 'http://localhost:11434', discovery: 'ollama' })).toBe(expected);
|
|
242
244
|
expect(providerFetchBlockReason({ baseUrl: 'http://x/v1', modelSource: 'discovery' })).toBe(expected);
|
|
243
245
|
});
|
|
244
246
|
|
|
245
247
|
test('a provider without an endpoint is blocked', () => {
|
|
246
|
-
const expected = 'This provider has no endpoint Kabmo can probe — omp owns its URL.';
|
|
248
|
+
const expected = 'This provider has no endpoint Kabmo can probe — omp owns its URL. Use “refresh” instead.';
|
|
247
249
|
expect(providerFetchBlockReason({})).toBe(expected);
|
|
248
250
|
expect(providerFetchBlockReason({ baseUrl: '' })).toBe(expected);
|
|
249
251
|
expect(providerFetchBlockReason({ baseUrl: undefined, modelSource: 'fetch' })).toBe(expected);
|
|
@@ -36,21 +36,25 @@ export const PROVIDER_APIS: readonly OmpProviderApi[] = [
|
|
|
36
36
|
'google-gemini-cli',
|
|
37
37
|
'google-vertex',
|
|
38
38
|
'openrouter-decisions',
|
|
39
|
+
'openai-decisions',
|
|
40
|
+
'workers-ai-systemone',
|
|
39
41
|
'typesafe',
|
|
40
42
|
];
|
|
41
43
|
|
|
42
44
|
/** One-line explanation of what each dialect is, for the picker. */
|
|
43
45
|
export const PROVIDER_API_LABELS: Readonly<Record<OmpProviderApi, string>> = {
|
|
44
|
-
'openai-completions': '
|
|
45
|
-
'openai-responses': '
|
|
46
|
-
'openai-codex-responses': '
|
|
47
|
-
'azure-openai-responses': 'Azure
|
|
46
|
+
'openai-completions': '[OI] Chat Completions — the default for gateways and local servers',
|
|
47
|
+
'openai-responses': '[OI] Responses API — newer [OI]-shaped endpoints',
|
|
48
|
+
'openai-codex-responses': '[OC] Responses — Codex-style endpoints',
|
|
49
|
+
'azure-openai-responses': 'Azure [OI] Responses — api-key header, api-version query',
|
|
48
50
|
'anthropic-messages': 'Anthropic Messages — Claude-shaped proxies (x-api-key)',
|
|
49
51
|
'bedrock-converse-stream': 'Amazon Bedrock Converse — AWS credential chain',
|
|
50
52
|
'google-generative-ai': 'Google Generative AI — Gemini API (x-goog-api-key)',
|
|
51
53
|
'google-gemini-cli': 'Google Gemini CLI — OAuth-backed Gemini route',
|
|
52
54
|
'google-vertex': 'Google Vertex AI — service-account / ADC route',
|
|
53
55
|
'openrouter-decisions': 'OpenRouter decisions — judge role only',
|
|
56
|
+
'openai-decisions': '[OI] decisions — judge role only',
|
|
57
|
+
'workers-ai-systemone': 'Workers AI System One — judge role only',
|
|
54
58
|
typesafe: 'Typesafe System One — judge role only',
|
|
55
59
|
};
|
|
56
60
|
|
|
@@ -83,6 +87,72 @@ export const PROVIDER_AUTH_MODES: ReadonlyArray<{
|
|
|
83
87
|
{ value: 'oauth', label: 'OAuth', hint: 'Claude-Code-style proxy expecting the cloaked request shape' },
|
|
84
88
|
];
|
|
85
89
|
|
|
90
|
+
/**
|
|
91
|
+
* omp's `ThinkingControlModeSchema` — how a model's effort selector is carried
|
|
92
|
+
* on the wire. A `thinking` block without a mode is a schema failure that takes
|
|
93
|
+
* every custom provider down with it, so the writer always states one.
|
|
94
|
+
*/
|
|
95
|
+
export const PROVIDER_THINKING_MODES = [
|
|
96
|
+
'effort',
|
|
97
|
+
'budget',
|
|
98
|
+
'google-level',
|
|
99
|
+
'anthropic-adaptive',
|
|
100
|
+
'anthropic-budget-effort',
|
|
101
|
+
] as const;
|
|
102
|
+
|
|
103
|
+
export type ProviderThinkingMode = (typeof PROVIDER_THINKING_MODES)[number];
|
|
104
|
+
|
|
105
|
+
/** True when `value` is a thinking mode omp accepts. */
|
|
106
|
+
export function isProviderThinkingMode(value: unknown): value is ProviderThinkingMode {
|
|
107
|
+
return typeof value === 'string' && (PROVIDER_THINKING_MODES as readonly string[]).includes(value);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* omp's `MODEL_KINDS`, in omp's own order, with the label the model list's
|
|
112
|
+
* kind tabs show.
|
|
113
|
+
*
|
|
114
|
+
* A provider routinely serves more than chat: an embedding model, an image
|
|
115
|
+
* model, a reranker. The RPC's `get_available_models` answers CHAT ONLY
|
|
116
|
+
* (`modelRegistry.getAvailable()` defaults to kind `chat`), which is why the
|
|
117
|
+
* panel used to be unable to show them at all — the listing has to come from
|
|
118
|
+
* `omp models --json --kind all`, the same source the role dropdowns read.
|
|
119
|
+
*/
|
|
120
|
+
export const MODEL_KINDS = [
|
|
121
|
+
'chat',
|
|
122
|
+
'tiny',
|
|
123
|
+
'image',
|
|
124
|
+
'tts',
|
|
125
|
+
'stt',
|
|
126
|
+
'search',
|
|
127
|
+
'judge',
|
|
128
|
+
'embedding',
|
|
129
|
+
'rerank',
|
|
130
|
+
'video',
|
|
131
|
+
] as const;
|
|
132
|
+
|
|
133
|
+
export type ProviderModelKind = (typeof MODEL_KINDS)[number];
|
|
134
|
+
|
|
135
|
+
/** Labels for the kind tabs. Absent means chat — omp's own default. */
|
|
136
|
+
export const MODEL_KIND_LABELS: Readonly<Record<ProviderModelKind, string>> = {
|
|
137
|
+
chat: 'Chat',
|
|
138
|
+
tiny: 'Tiny',
|
|
139
|
+
image: 'Image',
|
|
140
|
+
tts: 'Speech',
|
|
141
|
+
stt: 'Transcribe',
|
|
142
|
+
search: 'Search',
|
|
143
|
+
judge: 'Judge',
|
|
144
|
+
embedding: 'Embedding',
|
|
145
|
+
rerank: 'Rerank',
|
|
146
|
+
video: 'Video',
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
/** The kind a row belongs to, folded to omp's default when it declares none. */
|
|
150
|
+
export function modelKindOf(value: unknown): ProviderModelKind {
|
|
151
|
+
return typeof value === 'string' && (MODEL_KINDS as readonly string[]).includes(value)
|
|
152
|
+
? (value as ProviderModelKind)
|
|
153
|
+
: 'chat';
|
|
154
|
+
}
|
|
155
|
+
|
|
86
156
|
/** Discovery types omp can drive itself, with what each one probes. */
|
|
87
157
|
export const PROVIDER_DISCOVERY_TYPES: ReadonlyArray<{
|
|
88
158
|
value: ProviderDiscoveryType;
|
|
@@ -198,10 +268,10 @@ export function providerFetchBlockReason(provider: {
|
|
|
198
268
|
modelSource?: ProviderModelSource;
|
|
199
269
|
}): string | undefined {
|
|
200
270
|
if (provider.discovery !== undefined || provider.modelSource === 'discovery') {
|
|
201
|
-
return 'omp lists this provider’s models itself —
|
|
271
|
+
return 'omp lists this provider’s models itself — importing would freeze a snapshot beside that live list. Use “refresh”.';
|
|
202
272
|
}
|
|
203
273
|
if (!provider.baseUrl) {
|
|
204
|
-
return 'This provider has no endpoint Kabmo can probe — omp owns its URL.';
|
|
274
|
+
return 'This provider has no endpoint Kabmo can probe — omp owns its URL. Use “refresh” instead.';
|
|
205
275
|
}
|
|
206
276
|
return undefined;
|
|
207
277
|
}
|
|
@@ -87,6 +87,8 @@ export interface ProviderModelsReplaceResult {
|
|
|
87
87
|
export interface ManualModelRequest {
|
|
88
88
|
provider: string;
|
|
89
89
|
id: string;
|
|
90
|
+
/** omp's `ModelKind`; omitted means chat. */
|
|
91
|
+
kind?: string;
|
|
90
92
|
name?: string;
|
|
91
93
|
/** Token counts, not the compact labels a listing produces. */
|
|
92
94
|
contextWindow?: number;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* How the panel names a provider's credential origin.
|
|
8
|
+
*
|
|
9
|
+
* The four values mirror omp's own `/login` selector (`--api-key`, `config`,
|
|
10
|
+
* `login`, `api key`, `env`) folded to the ones that change what the panel may
|
|
11
|
+
* offer — and the fold is the point: `environment` and `models.yml` have
|
|
12
|
+
* NOTHING in omp's credential store, so `sign out` cannot remove them, while
|
|
13
|
+
* `login` and `api-key` are exactly what it removes. Offering the control
|
|
14
|
+
* everywhere made it a button whose only outcome was a failure on half the
|
|
15
|
+
* providers.
|
|
16
|
+
*
|
|
17
|
+
* Shared (not server-only) because the dialog labels and the registry both need
|
|
18
|
+
* the same words, and two copies is how one of them drifts.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import type { ProviderCredentialOrigin } from '@/shared/types/settings/provider';
|
|
22
|
+
|
|
23
|
+
/** The label a provider row prints. */
|
|
24
|
+
export function credentialOriginLabel(origin: ProviderCredentialOrigin | undefined): string {
|
|
25
|
+
switch (origin) {
|
|
26
|
+
case 'models.yml': return 'models.yml key';
|
|
27
|
+
case 'login': return 'OAuth login';
|
|
28
|
+
case 'api-key': return 'stored API key';
|
|
29
|
+
case 'environment': return 'environment variable';
|
|
30
|
+
default: return 'no credential';
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* True when `sign out` can do anything.
|
|
36
|
+
*
|
|
37
|
+
* `models.yml` is deliberately false: its key lives in the provider entry this
|
|
38
|
+
* panel edits, so removing it is the editor's job (clear the field), not a
|
|
39
|
+
* credential-store deletion. `environment` is false because there is nothing on
|
|
40
|
+
* disk to delete.
|
|
41
|
+
*/
|
|
42
|
+
export function canSignOut(origin: ProviderCredentialOrigin | undefined): boolean {
|
|
43
|
+
return origin === 'login' || origin === 'api-key';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Which connection controls a provider offers — and it can be BOTH.
|
|
48
|
+
*
|
|
49
|
+
* A provider is two independent facts, and the panel used to collapse them into
|
|
50
|
+
* one button:
|
|
51
|
+
*
|
|
52
|
+
* - **login** — omp's own `/login` flow can sign it in. Offered when it is an
|
|
53
|
+
* OAuth provider, is not declared keyless, and no `models.yml` key shadows the
|
|
54
|
+
* credential (a file entry with `auth: apiKey` is what omp uses, so a login
|
|
55
|
+
* there would be stored and then ignored).
|
|
56
|
+
* - **edit** — it has a `models.yml` entry, whose endpoint, credential and
|
|
57
|
+
* dialect are writable in place.
|
|
58
|
+
*
|
|
59
|
+
* A provider can be both: an Anthropic override pointing at a proxy carries an
|
|
60
|
+
* entry AND is signed in through OAuth. Offering only the editor made the sign-in
|
|
61
|
+
* flow unreachable for exactly those providers; offering only sign-in hid the
|
|
62
|
+
* entry. The panel draws one button per available control.
|
|
63
|
+
*
|
|
64
|
+
* Neither is offered for a provider omp DISCOVERED from an endpoint (a keyless
|
|
65
|
+
* local server, a search backend): no login flow, no entry. The editor used to
|
|
66
|
+
* open there and refuse with "add the provider first", so the button says why
|
|
67
|
+
* instead.
|
|
68
|
+
*/
|
|
69
|
+
export interface ConnectOffers {
|
|
70
|
+
login: boolean;
|
|
71
|
+
edit: boolean;
|
|
72
|
+
/** Why neither is available, when neither is. */
|
|
73
|
+
reason?: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function connectOffers(provider: {
|
|
77
|
+
oauth?: boolean;
|
|
78
|
+
inModelsYml?: boolean;
|
|
79
|
+
auth?: string;
|
|
80
|
+
credentialOrigin?: string;
|
|
81
|
+
}): ConnectOffers {
|
|
82
|
+
const login = provider.oauth === true
|
|
83
|
+
&& provider.auth !== 'none'
|
|
84
|
+
// A models.yml key wins over a stored login, so a login here would be
|
|
85
|
+
// written and then shadowed — a button whose effect nothing reads.
|
|
86
|
+
&& provider.credentialOrigin !== 'models.yml';
|
|
87
|
+
const edit = provider.inModelsYml === true;
|
|
88
|
+
if (login || edit) return { login, edit };
|
|
89
|
+
return {
|
|
90
|
+
login: false,
|
|
91
|
+
edit: false,
|
|
92
|
+
reason: 'omp discovers this provider itself — its models come from its own endpoint, so there is no login flow and no entry to edit.',
|
|
93
|
+
};
|
|
94
|
+
}
|
|
@@ -95,6 +95,13 @@ function model(overrides: Partial<ProviderModel> & { id: string }): ProviderMode
|
|
|
95
95
|
|
|
96
96
|
afterAll(() => {
|
|
97
97
|
globalThis.fetch = realFetch;
|
|
98
|
+
// `fetchModelsData` caches the answer for 60s on `globalThis`, so the stub
|
|
99
|
+
// above stays cached after this file ends. Measured: `model-dropdown/
|
|
100
|
+
// refresh.test.tsx` then read `{models:{}, modelList:[]}` from the cache on
|
|
101
|
+
// its FIRST render and failed "expected to contain Alpha Model" — a failure
|
|
102
|
+
// in a suite this file does not name, reproduced on the tree before this
|
|
103
|
+
// change. Dropping it is the whole hand-off.
|
|
104
|
+
invalidateModelsCache();
|
|
98
105
|
});
|
|
99
106
|
|
|
100
107
|
describe('titleCaseProviderSlug', () => {
|
|
@@ -11,15 +11,20 @@
|
|
|
11
11
|
* list from before the change until the TTL expires.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import type { ModelsData
|
|
14
|
+
import type { ModelsData } from '@/shared/types';
|
|
15
15
|
import type { ModelRoleCandidate } from '@/shared/types/model-roles';
|
|
16
16
|
import { emitRealtimeSignal } from '@/server/lib/realtime/signals.server';
|
|
17
17
|
|
|
18
18
|
declare global {
|
|
19
19
|
// eslint-disable-next-line no-var
|
|
20
20
|
var __kabmoModelsCache: { data: ModelsData; expiresAt: number } | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* The `get_login_providers` snapshot (`provider-registry.server.ts`). Declared
|
|
23
|
+
* there, because it holds omp's login-provider rows rather than ProviderItems
|
|
24
|
+
* — the panel's rows are assembled per request from these plus models.yml.
|
|
25
|
+
*/
|
|
21
26
|
// eslint-disable-next-line no-var
|
|
22
|
-
var
|
|
27
|
+
var __kabmoLoginProvidersCache: { data: unknown[]; expiresAt: number } | undefined;
|
|
23
28
|
/**
|
|
24
29
|
* The role dropdowns' candidate list (`lib/model-roles/catalog.server.ts`).
|
|
25
30
|
* Declared HERE because it is dropped by the same signal: a model removed
|
|
@@ -42,7 +47,7 @@ declare global {
|
|
|
42
47
|
*/
|
|
43
48
|
export function invalidateModelsCaches(): void {
|
|
44
49
|
globalThis.__kabmoModelsCache = undefined;
|
|
45
|
-
globalThis.
|
|
50
|
+
globalThis.__kabmoLoginProvidersCache = undefined;
|
|
46
51
|
globalThis.__kabmoRoleCandidatesCache = undefined;
|
|
47
52
|
emitRealtimeSignal('models-changed');
|
|
48
53
|
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A tool call the transcript has no RESULT for.
|
|
8
|
+
*
|
|
9
|
+
* This is the shape a page reloaded mid-call reads: omp writes the assistant
|
|
10
|
+
* turn's `toolCall` block and one `tool_execution_start` entry, then nothing
|
|
11
|
+
* until the call returns. The two facts that shape carries are the call's only
|
|
12
|
+
* clock and the fact that its output is UNKNOWN rather than empty — and both
|
|
13
|
+
* were missing, so a reloaded `wait` lost its stopwatch and read as a settled
|
|
14
|
+
* call with an empty body (the reported "wait renders as general after a
|
|
15
|
+
* reload").
|
|
16
|
+
*
|
|
17
|
+
* The `liveRun` gate is the other half: the same transcript is left behind by a
|
|
18
|
+
* run whose process DIED, and that call must not sit at `running` forever in
|
|
19
|
+
* scrollback. Only a run in flight right now settles the difference.
|
|
20
|
+
*
|
|
21
|
+
* Split from `messages-map.test.ts`, which is at the repo's per-file ceiling.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import { afterAll, describe, expect, test } from 'bun:test';
|
|
25
|
+
import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
26
|
+
import { tmpdir } from 'node:os';
|
|
27
|
+
import { join } from 'node:path';
|
|
28
|
+
|
|
29
|
+
import { collectToolOutputs } from '@/shared/lib/omp/session/messages-map';
|
|
30
|
+
import { loadSessionMessages } from '@/server/lib/omp/session/messages';
|
|
31
|
+
|
|
32
|
+
const AT = '2026-01-02T03:04:05.000Z';
|
|
33
|
+
|
|
34
|
+
function startEntry(callId: string, toolName = 'wait'): Record<string, unknown> {
|
|
35
|
+
return {
|
|
36
|
+
type: 'custom',
|
|
37
|
+
customType: 'tool_execution_start',
|
|
38
|
+
timestamp: AT,
|
|
39
|
+
data: { toolCallId: callId, toolName, startedAt: AT },
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function resultEntry(callId: string, text: string): Record<string, unknown> {
|
|
44
|
+
return {
|
|
45
|
+
type: 'message',
|
|
46
|
+
id: 'r1',
|
|
47
|
+
timestamp: AT,
|
|
48
|
+
message: { role: 'toolResult', toolCallId: callId, content: [{ type: 'text', text }] },
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
describe('collectToolOutputs — a call with no result', () => {
|
|
53
|
+
test('is PENDING, and keeps the start clock', () => {
|
|
54
|
+
const outputs = collectToolOutputs([startEntry('c')]);
|
|
55
|
+
expect(outputs.get('c')).toMatchObject({ output: '', pending: true });
|
|
56
|
+
expect(typeof outputs.get('c')?.startedAt).toBe('number');
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test('a call that did return is not pending', () => {
|
|
60
|
+
const outputs = collectToolOutputs([startEntry('c'), resultEntry('c', 'done')]);
|
|
61
|
+
expect(outputs.get('c')?.output).toBe('done');
|
|
62
|
+
expect(outputs.get('c')?.pending).toBeUndefined();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test('a resultless start followed by another result belongs to a DEAD run', () => {
|
|
66
|
+
// omp writes a result before the next turn, so a gap can only mean the
|
|
67
|
+
// process died mid-call. Marking that pending would leave a spinner in
|
|
68
|
+
// scrollback for the rest of the session.
|
|
69
|
+
const outputs = collectToolOutputs([
|
|
70
|
+
startEntry('dead'),
|
|
71
|
+
startEntry('next'),
|
|
72
|
+
resultEntry('next', 'done'),
|
|
73
|
+
]);
|
|
74
|
+
expect(outputs.get('dead')).toMatchObject({ output: '' });
|
|
75
|
+
expect(outputs.get('dead')?.pending).toBeUndefined();
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
describe('loadSessionMessages — a call in flight', () => {
|
|
80
|
+
const dir = mkdtempSync(join(tmpdir(), 'omp-pending-'));
|
|
81
|
+
const file = join(dir, 'inflight.jsonl');
|
|
82
|
+
writeFileSync(file, [
|
|
83
|
+
JSON.stringify({ type: 'session', version: 3, id: 's1', timestamp: AT, cwd: dir }),
|
|
84
|
+
JSON.stringify({
|
|
85
|
+
type: 'message',
|
|
86
|
+
id: 'a1',
|
|
87
|
+
timestamp: AT,
|
|
88
|
+
message: { role: 'assistant', content: [{ type: 'toolCall', id: 'c1', name: 'wait', arguments: { i: 'waiting' } }] },
|
|
89
|
+
}),
|
|
90
|
+
JSON.stringify(startEntry('c1')),
|
|
91
|
+
].join('\n'));
|
|
92
|
+
|
|
93
|
+
test('is running while the run is live', async () => {
|
|
94
|
+
const [message] = await loadSessionMessages(file, { liveRun: true });
|
|
95
|
+
expect(message?.toolCalls?.[0]).toMatchObject({ id: 'c1', status: 'running' });
|
|
96
|
+
// No output was written, so none is claimed — the empty string would read
|
|
97
|
+
// as "returned nothing".
|
|
98
|
+
expect(message?.toolCalls?.[0]?.output).toBeUndefined();
|
|
99
|
+
expect(typeof message?.toolCalls?.[0]?.startedAt).toBe('number');
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
test('is settled when no run is in flight, so a dead process leaves no spinner', async () => {
|
|
103
|
+
const [message] = await loadSessionMessages(file);
|
|
104
|
+
expect(message?.toolCalls?.[0]?.status).not.toBe('running');
|
|
105
|
+
// The clock is still known — the start entry is a fact either way.
|
|
106
|
+
expect(typeof message?.toolCalls?.[0]?.startedAt).toBe('number');
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
afterAll(() => rmSync(dir, { recursive: true, force: true }));
|
|
110
|
+
});
|
|
@@ -164,6 +164,12 @@ export interface CollectedToolResult {
|
|
|
164
164
|
durationMs?: number;
|
|
165
165
|
/** When the call started, from its `tool_execution_start` entry. */
|
|
166
166
|
startedAt?: number;
|
|
167
|
+
/**
|
|
168
|
+
* The call has no result entry in this file — it was still running when the
|
|
169
|
+
* transcript was read (a page reloaded mid-call). Its `output` and `details`
|
|
170
|
+
* are UNKNOWN, not empty, and its status is `running`, not `success`.
|
|
171
|
+
*/
|
|
172
|
+
pending?: boolean;
|
|
167
173
|
/** Pictures the result returned (a `read` of an image). */
|
|
168
174
|
images?: ToolImageRef[];
|
|
169
175
|
}
|
|
@@ -189,19 +195,25 @@ export function collectToolOutputs(records: Record<string, unknown>[]): Map<stri
|
|
|
189
195
|
// it blocked only from its own output prose. 114,642 such entries exist, so
|
|
190
196
|
// the map is cheap and the join is exact by call id.
|
|
191
197
|
const startedAt = new Map<string, number>();
|
|
192
|
-
|
|
198
|
+
/** The position of each start entry, so "no result" can be told from "a
|
|
199
|
+
* result that was never written while the run continued". */
|
|
200
|
+
const startIndex = new Map<string, number>();
|
|
201
|
+
for (const [index, record] of records.entries()) {
|
|
193
202
|
if (record?.type !== 'custom' || record.customType !== 'tool_execution_start') continue;
|
|
194
203
|
const data = isRecord(record.data) ? record.data : undefined;
|
|
195
204
|
const id = typeof data?.toolCallId === 'string' ? data.toolCallId : undefined;
|
|
196
205
|
if (!id) continue;
|
|
197
206
|
const at = toEpochMs(data?.startedAt) ?? toEpochMs(record.timestamp);
|
|
198
207
|
if (at !== undefined) startedAt.set(id, at);
|
|
208
|
+
startIndex.set(id, index);
|
|
199
209
|
}
|
|
200
210
|
|
|
201
|
-
|
|
211
|
+
let lastResultIndex = -1;
|
|
212
|
+
for (const [index, record] of records.entries()) {
|
|
202
213
|
if (record?.type !== 'message') continue;
|
|
203
214
|
const msg = (record as unknown as OmpMessageEntry).message;
|
|
204
215
|
if (!msg || msg.role !== 'toolResult') continue;
|
|
216
|
+
lastResultIndex = index;
|
|
205
217
|
const callId = typeof msg.toolCallId === 'string' ? msg.toolCallId : undefined;
|
|
206
218
|
if (!callId) continue;
|
|
207
219
|
const text = resultOutput(msg);
|
|
@@ -232,6 +244,26 @@ export function collectToolOutputs(records: Record<string, unknown>[]): Map<stri
|
|
|
232
244
|
...(images.length > 0 ? { images } : existing?.images ? { images: existing.images } : {}),
|
|
233
245
|
});
|
|
234
246
|
}
|
|
247
|
+
|
|
248
|
+
// A call whose `tool_execution_start` entry exists but whose result does not
|
|
249
|
+
// was still RUNNING when this file was read — the page was reloaded mid-call.
|
|
250
|
+
// Its clock is the start entry's, and it is the only thing such a call has:
|
|
251
|
+
// without this entry a reloaded `wait` lost its `startedAt` (the join above
|
|
252
|
+
// only ran for results) and the panel's stopwatch had no source at all. The
|
|
253
|
+
// empty output is a PLACEHOLDER, so `pending` is what says "unknown", not
|
|
254
|
+
// "returned nothing".
|
|
255
|
+
//
|
|
256
|
+
// Only a start that is the LAST thing in the file can be in flight: omp
|
|
257
|
+
// writes a result before the next turn, so a resultless start followed by
|
|
258
|
+
// any later result belongs to a run that DIED, and marking it pending would
|
|
259
|
+
// leave a spinner in scrollback for the rest of the session.
|
|
260
|
+
for (const [callId, started] of startedAt) {
|
|
261
|
+
if (outputs.has(callId)) continue;
|
|
262
|
+
const inFlight = (startIndex.get(callId) ?? -1) > lastResultIndex;
|
|
263
|
+
outputs.set(callId, inFlight
|
|
264
|
+
? { output: '', pending: true, startedAt: started }
|
|
265
|
+
: { output: '', startedAt: started });
|
|
266
|
+
}
|
|
235
267
|
return outputs;
|
|
236
268
|
}
|
|
237
269
|
|