@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
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Keeping a provider's web icon fresh: fetch once, store the bytes, stamp a
|
|
8
|
+
* version onto the provider item.
|
|
9
|
+
*
|
|
10
|
+
* The panel must never wait on a third party. `GET /api/settings/providers` is
|
|
11
|
+
* the settings screen's first paint and it lists ~100 providers, so a fetch per
|
|
12
|
+
* provider inside the request would make opening the panel depend on 100
|
|
13
|
+
* foreign hosts. Instead:
|
|
14
|
+
*
|
|
15
|
+
* - the LOADER reads the stored stamps (one query, no bytes) and puts
|
|
16
|
+
* `iconUrl` on the items whose icon is already known;
|
|
17
|
+
* - a background pass fetches the ones that are missing or stale, deduped per
|
|
18
|
+
* slug and capped in concurrency, and drops the registry cache when it stored
|
|
19
|
+
* something — so the next publish carries the new URLs.
|
|
20
|
+
*
|
|
21
|
+
* Freshness is asymmetric on purpose: a HIT is good for a week (a site's logo
|
|
22
|
+
* changes rarely), a MISS for a day (a gateway that was down at 09:00 may be up
|
|
23
|
+
* at 17:00, but retrying a 4s timeout on every panel open is not a cost worth
|
|
24
|
+
* paying).
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import { getDb } from '@/server/db.server';
|
|
28
|
+
import { invalidateModelsCaches } from '@/shared/lib/models/server-cache';
|
|
29
|
+
import type { ProviderItem } from '@/shared/types';
|
|
30
|
+
import { fetchProviderIcon } from '@/server/lib/models/provider-icon-fetch';
|
|
31
|
+
import {
|
|
32
|
+
readProviderIcon,
|
|
33
|
+
readProviderIconStamps,
|
|
34
|
+
writeProviderIcon,
|
|
35
|
+
type StoredProviderIcon,
|
|
36
|
+
} from '@/server/lib/models/provider-icon-store.server';
|
|
37
|
+
import { isMockMode } from '@/server/mock.server';
|
|
38
|
+
|
|
39
|
+
const HIT_TTL_MS = 7 * 24 * 60 * 60 * 1000;
|
|
40
|
+
const MISS_TTL_MS = 24 * 60 * 60 * 1000;
|
|
41
|
+
/** Concurrent fetches across all providers: enough to fill a panel quickly. */
|
|
42
|
+
const CONCURRENCY = 4;
|
|
43
|
+
|
|
44
|
+
/** Slugs a fetch is in flight for, so a re-render cannot start a second one. */
|
|
45
|
+
const inFlight = new Set<string>();
|
|
46
|
+
|
|
47
|
+
export interface ProviderIconTarget {
|
|
48
|
+
slug: string;
|
|
49
|
+
baseUrl?: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function isFresh(icon: StoredProviderIcon, now: number): boolean {
|
|
53
|
+
const ttl = icon.status === 'ok' ? HIT_TTL_MS : MISS_TTL_MS;
|
|
54
|
+
return now - icon.fetchedAt < ttl;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The URL a provider's icon is served from, versioned by its fetch time.
|
|
59
|
+
*
|
|
60
|
+
* The version is in the QUERY, not in an ETag alone, because the item travels
|
|
61
|
+
* through several caches (the realtime topic, the panel's own state) and a
|
|
62
|
+
* changed icon at an unchanged URL is a stale picture with no way to notice.
|
|
63
|
+
*/
|
|
64
|
+
export function providerIconUrl(slug: string, fetchedAt: number): string {
|
|
65
|
+
return `/api/provider-icon?slug=${encodeURIComponent(slug)}&v=${fetchedAt}`;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Slug → the URL its stored icon is served from, for providers that have one. */
|
|
69
|
+
export async function readProviderIconUrls(): Promise<Map<string, string>> {
|
|
70
|
+
if (isMockMode()) return new Map();
|
|
71
|
+
try {
|
|
72
|
+
const db = await getDb();
|
|
73
|
+
const stamps = await readProviderIconStamps(db);
|
|
74
|
+
const urls = new Map<string, string>();
|
|
75
|
+
for (const [slug, stamp] of stamps) {
|
|
76
|
+
if (stamp.status !== 'ok') continue;
|
|
77
|
+
urls.set(slug, providerIconUrl(slug, stamp.fetchedAt));
|
|
78
|
+
}
|
|
79
|
+
return urls;
|
|
80
|
+
} catch {
|
|
81
|
+
// no-excuse-ok: catch — the icon is decoration; a read failure must not stop
|
|
82
|
+
// the provider list from loading.
|
|
83
|
+
return new Map();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Fetch and store one provider's icon when it is missing or stale.
|
|
89
|
+
*
|
|
90
|
+
* Returns true when something was WRITTEN, so the caller knows whether the
|
|
91
|
+
* registry cache has to be dropped. Never throws.
|
|
92
|
+
*/
|
|
93
|
+
export async function ensureProviderIcon(target: ProviderIconTarget): Promise<boolean> {
|
|
94
|
+
const slug = target.slug.trim();
|
|
95
|
+
if (!slug || !target.baseUrl || isMockMode()) return false;
|
|
96
|
+
if (inFlight.has(slug)) return false;
|
|
97
|
+
inFlight.add(slug);
|
|
98
|
+
try {
|
|
99
|
+
const db = await getDb();
|
|
100
|
+
const stored = await readProviderIcon(db, slug);
|
|
101
|
+
if (stored && isFresh(stored, Date.now())) return false;
|
|
102
|
+
|
|
103
|
+
const icon = await fetchProviderIcon(target.baseUrl);
|
|
104
|
+
await writeProviderIcon(db, icon
|
|
105
|
+
? {
|
|
106
|
+
slug,
|
|
107
|
+
status: 'ok',
|
|
108
|
+
mime: icon.mime,
|
|
109
|
+
bytes: icon.bytes,
|
|
110
|
+
source: icon.source,
|
|
111
|
+
fetchedAt: Date.now(),
|
|
112
|
+
}
|
|
113
|
+
: {
|
|
114
|
+
slug,
|
|
115
|
+
status: 'missing',
|
|
116
|
+
error: 'no usable icon on the endpoint host',
|
|
117
|
+
fetchedAt: Date.now(),
|
|
118
|
+
});
|
|
119
|
+
return true;
|
|
120
|
+
} catch (error) {
|
|
121
|
+
// no-excuse-ok: catch — a failed icon is a fallback mark, never an error the
|
|
122
|
+
// provider list reports.
|
|
123
|
+
console.error(`[kabmo] provider icon failed for ${slug}:`, error instanceof Error ? error.message : error);
|
|
124
|
+
return false;
|
|
125
|
+
} finally {
|
|
126
|
+
inFlight.delete(slug);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Refresh every target that needs it, at most {@link CONCURRENCY} at a time.
|
|
132
|
+
* Resolves to how many rows were written.
|
|
133
|
+
*/
|
|
134
|
+
export async function ensureProviderIcons(targets: ProviderIconTarget[]): Promise<number> {
|
|
135
|
+
if (isMockMode() || targets.length === 0) return 0;
|
|
136
|
+
const queue = targets.filter((target) => target.baseUrl);
|
|
137
|
+
let written = 0;
|
|
138
|
+
let cursor = 0;
|
|
139
|
+
const workers = Array.from({ length: Math.min(CONCURRENCY, queue.length) }, async () => {
|
|
140
|
+
for (;;) {
|
|
141
|
+
const index = cursor;
|
|
142
|
+
cursor += 1;
|
|
143
|
+
const target = queue[index];
|
|
144
|
+
if (!target) return;
|
|
145
|
+
if (await ensureProviderIcon(target)) written += 1;
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
await Promise.all(workers);
|
|
149
|
+
return written;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** The stored bytes for one provider, or null. */
|
|
153
|
+
export async function readProviderIconBytes(slug: string): Promise<StoredProviderIcon | null> {
|
|
154
|
+
if (isMockMode()) return null;
|
|
155
|
+
const db = await getDb();
|
|
156
|
+
const icon = await readProviderIcon(db, slug);
|
|
157
|
+
return icon && icon.status === 'ok' && icon.bytes ? icon : null;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Stamp `iconUrl` onto every provider whose icon is already stored, and kick off
|
|
162
|
+
* the fetch for the ones that are not.
|
|
163
|
+
*
|
|
164
|
+
* The caller is the registry merge, which runs on the panel's first paint and
|
|
165
|
+
* on every publish. Two rules make that affordable:
|
|
166
|
+
*
|
|
167
|
+
* - the READ is one query of stored STAMPS, never the bytes, so the payload
|
|
168
|
+
* stays small and the request never waits on a third-party host;
|
|
169
|
+
* - the FETCH is a background pass that drops the registry cache when it stored
|
|
170
|
+
* something, so the next publish carries the new URLs (the panel subscribes
|
|
171
|
+
* to that signal).
|
|
172
|
+
*/
|
|
173
|
+
export async function stampProviderIcons(providers: ProviderItem[]): Promise<ProviderItem[]> {
|
|
174
|
+
if (providers.length === 0) return providers;
|
|
175
|
+
const urls = await readProviderIconUrls();
|
|
176
|
+
if (urls.size === 0) {
|
|
177
|
+
scheduleIconFetch(providers);
|
|
178
|
+
return providers;
|
|
179
|
+
}
|
|
180
|
+
const stamped = providers.map((provider) => {
|
|
181
|
+
const url = urls.get(provider.slug.trim().toLowerCase());
|
|
182
|
+
return url ? { ...provider, iconUrl: url } : provider;
|
|
183
|
+
});
|
|
184
|
+
scheduleIconFetch(stamped);
|
|
185
|
+
return stamped;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Fetch the icons the list does not have yet, without making the caller wait.
|
|
190
|
+
*
|
|
191
|
+
* A `models.yml` provider whose favicon has never been read is exactly the case
|
|
192
|
+
* this exists for — but a request that blocks on a third-party host is a
|
|
193
|
+
* settings panel that hangs when that host is down. The pass is deduped per
|
|
194
|
+
* slug inside `ensureProviderIcons`.
|
|
195
|
+
*/
|
|
196
|
+
function scheduleIconFetch(providers: ProviderItem[]): void {
|
|
197
|
+
const targets = providers
|
|
198
|
+
.filter((provider) => provider.inModelsYml === true && Boolean(provider.baseUrl) && !provider.iconUrl)
|
|
199
|
+
.map((provider) => ({ slug: provider.slug, baseUrl: provider.baseUrl as string }));
|
|
200
|
+
if (targets.length === 0) return;
|
|
201
|
+
void ensureProviderIcons(targets)
|
|
202
|
+
.then((written) => {
|
|
203
|
+
if (written > 0) invalidateModelsCaches();
|
|
204
|
+
})
|
|
205
|
+
.catch(() => {
|
|
206
|
+
// no-excuse-ok: catch — an icon is decoration; a background failure must
|
|
207
|
+
// not surface as an unhandled rejection.
|
|
208
|
+
});
|
|
209
|
+
}
|
|
@@ -4,14 +4,20 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* The
|
|
8
|
-
*
|
|
9
|
-
* reports as disabled in config.yml
|
|
7
|
+
* The ProviderItem shapes the registry builds from omp's own state rather than
|
|
8
|
+
* from a Kabmo-side guess: a login provider omp knows, a `models.yml` entry,
|
|
9
|
+
* and a provider omp reports as disabled in `config.yml`.
|
|
10
10
|
*
|
|
11
11
|
* Split from `provider-registry.server.ts` because these are the payload the
|
|
12
12
|
* settings UI actually reads — a field dropped here is invisible until the
|
|
13
13
|
* control it gates stops working, which is how a missing `baseUrl` disabled
|
|
14
14
|
* "fetch models" for every models.yml provider without an error anywhere.
|
|
15
|
+
*
|
|
16
|
+
* Models come from the CLI catalog (`omp models --json --kind all`), not from
|
|
17
|
+
* `get_available_models`: that RPC answers CHAT models only, so an embedding,
|
|
18
|
+
* image, judge or rerank model could not be shown at all, and the row's own
|
|
19
|
+
* `kind`, `thinking`, `input` and `cost` were dropped — every model read
|
|
20
|
+
* `hasVision: false` / `hasTools: true` whatever omp actually knew.
|
|
15
21
|
*/
|
|
16
22
|
|
|
17
23
|
import {
|
|
@@ -21,24 +27,152 @@ import {
|
|
|
21
27
|
} from '@/shared/lib/models/provider/dialect';
|
|
22
28
|
import { removeLegacyKenariModels } from '@/shared/lib/models/provider/cleanup';
|
|
23
29
|
import { formatContextWindow } from '@/shared/lib/code/format';
|
|
24
|
-
import type { NativeProviderInfo } from '@/server/lib/omp/config/models-config';
|
|
25
|
-
import type {
|
|
30
|
+
import type { NativeProviderInfo, NativeModelInfo } from '@/server/lib/omp/config/models-config';
|
|
31
|
+
import type { CatalogModel } from '@/server/lib/models/catalog.server';
|
|
32
|
+
import type { OmpLoginProvider } from '@/server/lib/omp/rpc/utility';
|
|
33
|
+
import type { ProviderCredentialOrigin, ProviderItem, ProviderModel } from '@/shared/types';
|
|
34
|
+
|
|
35
|
+
/** The per-model display state Kabmo owns (visibility + saved sampling knobs). */
|
|
36
|
+
export interface ModelOverlayEntry {
|
|
37
|
+
isVisible: boolean;
|
|
38
|
+
temperature?: number;
|
|
39
|
+
maxTokens?: number;
|
|
40
|
+
topP?: number;
|
|
41
|
+
reasoningEffort?: ProviderModel['reasoningEffort'];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** A provider's overlay rows, keyed by model id. */
|
|
45
|
+
export type ModelOverlay = Map<string, ModelOverlayEntry>;
|
|
46
|
+
|
|
47
|
+
/** One catalog row → the panel's model shape, with the user's overlay applied. */
|
|
48
|
+
export function catalogModelToProviderModel(model: CatalogModel, overlay?: ModelOverlay): ProviderModel {
|
|
49
|
+
const saved = overlay?.get(model.id);
|
|
50
|
+
const efforts = model.thinking?.efforts ?? [];
|
|
51
|
+
return {
|
|
52
|
+
id: model.id,
|
|
53
|
+
name: model.name,
|
|
54
|
+
contextWindow: contextLabel(model.contextWindow, model.maxTokens),
|
|
55
|
+
hasTools: true,
|
|
56
|
+
hasVision: model.input.includes('image'),
|
|
57
|
+
...(model.reasoning ? { hasReasoning: true } : {}),
|
|
58
|
+
isVisible: saved ? saved.isVisible !== false : true,
|
|
59
|
+
...(model.kind && model.kind !== 'chat' ? { kind: model.kind } : {}),
|
|
60
|
+
...(efforts.length > 0 ? { thinkingEfforts: efforts } : {}),
|
|
61
|
+
...(model.thinking?.mode ? { thinkingMode: model.thinking.mode } : {}),
|
|
62
|
+
...(model.pricingStatus ? { pricingStatus: model.pricingStatus } : {}),
|
|
63
|
+
...(model.cost?.input !== undefined ? { priceInput: model.cost.input } : {}),
|
|
64
|
+
...(model.cost?.output !== undefined ? { priceOutput: model.cost.output } : {}),
|
|
65
|
+
...(model.cost?.cacheRead !== undefined ? { priceCacheRead: model.cost.cacheRead } : {}),
|
|
66
|
+
...(model.cost?.cacheWrite !== undefined ? { priceCacheWrite: model.cost.cacheWrite } : {}),
|
|
67
|
+
...(saved?.temperature !== undefined ? { temperature: saved.temperature } : {}),
|
|
68
|
+
...(saved?.maxTokens !== undefined ? { maxTokens: saved.maxTokens } : {}),
|
|
69
|
+
...(saved?.topP !== undefined ? { topP: saved.topP } : {}),
|
|
70
|
+
...(saved?.reasoningEffort !== undefined ? { reasoningEffort: saved.reasoningEffort } : {}),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** `1M ctx · 384K out` — the badge the model rows print. */
|
|
75
|
+
function contextLabel(contextWindow?: number, maxTokens?: number): string {
|
|
76
|
+
const context = contextWindow ? formatContextWindow(contextWindow) : '';
|
|
77
|
+
const out = maxTokens ? formatContextWindow(maxTokens) : '';
|
|
78
|
+
if (context && out) return `${context} ctx · ${out} out`;
|
|
79
|
+
if (context) return `${context} ctx`;
|
|
80
|
+
return '';
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** A models.yml model entry → the panel's shape (catalog rows win when both exist). */
|
|
84
|
+
function nativeModelToProviderModel(model: NativeModelInfo, overlay?: ModelOverlay): ProviderModel {
|
|
85
|
+
const saved = overlay?.get(model.id);
|
|
86
|
+
return {
|
|
87
|
+
id: model.id,
|
|
88
|
+
name: model.name || model.id,
|
|
89
|
+
contextWindow: contextLabel(model.contextWindow, model.maxTokens),
|
|
90
|
+
hasTools: model.supportsTools !== false,
|
|
91
|
+
hasVision: model.imageInput === true,
|
|
92
|
+
...(model.reasoning ? { hasReasoning: true } : {}),
|
|
93
|
+
isVisible: saved ? saved.isVisible !== false : true,
|
|
94
|
+
...(model.kind && model.kind !== 'chat' ? { kind: model.kind } : {}),
|
|
95
|
+
...(model.thinkingEfforts && model.thinkingEfforts.length > 0
|
|
96
|
+
? { thinkingEfforts: model.thinkingEfforts }
|
|
97
|
+
: {}),
|
|
98
|
+
...(model.thinkingMode ? { thinkingMode: model.thinkingMode } : {}),
|
|
99
|
+
...(model.cost?.input !== undefined ? { priceInput: model.cost.input } : {}),
|
|
100
|
+
...(model.cost?.output !== undefined ? { priceOutput: model.cost.output } : {}),
|
|
101
|
+
...(saved?.temperature !== undefined ? { temperature: saved.temperature } : {}),
|
|
102
|
+
...(saved?.maxTokens !== undefined ? { maxTokens: saved.maxTokens } : {}),
|
|
103
|
+
...(saved?.topP !== undefined ? { topP: saved.topP } : {}),
|
|
104
|
+
...(saved?.reasoningEffort !== undefined ? { reasoningEffort: saved.reasoningEffort } : {}),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
26
107
|
|
|
27
108
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
109
|
+
* A provider's models: every catalog row, then any `models.yml` id the catalog
|
|
110
|
+
* does not serve (a model whose credential has lapsed, or one omp filters out
|
|
111
|
+
* of the listing). The union is what makes the panel's count honest in both
|
|
112
|
+
* directions — a catalog-only row was invisible before, and a registered id
|
|
113
|
+
* missing from the listing looked deleted.
|
|
31
114
|
*/
|
|
32
|
-
export function
|
|
115
|
+
export function providerModels(
|
|
116
|
+
identity: Pick<ProviderItem, 'name' | 'slug' | 'baseUrl'>,
|
|
117
|
+
catalog: CatalogModel[] | undefined,
|
|
118
|
+
nativeModels: NativeModelInfo[] | undefined,
|
|
119
|
+
overlay?: ModelOverlay,
|
|
120
|
+
): ProviderModel[] {
|
|
121
|
+
const models = (catalog ?? []).map((model) => catalogModelToProviderModel(model, overlay));
|
|
122
|
+
const seen = new Set(models.map((model) => model.id));
|
|
123
|
+
for (const native of nativeModels ?? []) {
|
|
124
|
+
if (seen.has(native.id)) continue;
|
|
125
|
+
models.push(nativeModelToProviderModel(native, overlay));
|
|
126
|
+
seen.add(native.id);
|
|
127
|
+
}
|
|
128
|
+
return removeLegacyKenariModels(identity, models);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** Facts about the credential stores, shared by every provider row. */
|
|
132
|
+
export interface CredentialContext {
|
|
133
|
+
originOf: (slug: string) => ProviderCredentialOrigin | undefined;
|
|
134
|
+
/** Slugs that carry an `apiKey` in models.yml. */
|
|
135
|
+
modelsYmlKeys: Set<string>;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* A provider omp knows from `get_login_providers`.
|
|
140
|
+
*
|
|
141
|
+
* Unauthenticated providers are included ON PURPOSE: omp's own `/models` hub
|
|
142
|
+
* lists them (dimmed, under "Not signed in") and forwards a pick to `/login`.
|
|
143
|
+
* Filtering them out — which this panel did — made an OAuth provider that had
|
|
144
|
+
* never been signed in unreachable, with nothing on screen to say it existed.
|
|
145
|
+
*/
|
|
146
|
+
export function loginProviderItem(
|
|
147
|
+
provider: OmpLoginProvider,
|
|
148
|
+
options: {
|
|
149
|
+
disabled: boolean;
|
|
150
|
+
catalog?: CatalogModel[];
|
|
151
|
+
nativeModels?: NativeModelInfo[];
|
|
152
|
+
overlay?: ModelOverlay;
|
|
153
|
+
credentials: CredentialContext;
|
|
154
|
+
},
|
|
155
|
+
): ProviderItem {
|
|
156
|
+
const origin = options.credentials.originOf(provider.id);
|
|
157
|
+
const authenticated = provider.authenticated && !options.disabled;
|
|
33
158
|
return {
|
|
34
|
-
id: `omp-
|
|
35
|
-
name:
|
|
36
|
-
slug,
|
|
37
|
-
icon:
|
|
38
|
-
status: 'disconnected',
|
|
39
|
-
disabled:
|
|
40
|
-
configuredIn: 'omp
|
|
41
|
-
|
|
159
|
+
id: `omp-auth-${provider.id}`,
|
|
160
|
+
name: provider.name,
|
|
161
|
+
slug: provider.id,
|
|
162
|
+
icon: provider.id,
|
|
163
|
+
status: authenticated ? 'connected' : 'disconnected',
|
|
164
|
+
disabled: options.disabled,
|
|
165
|
+
configuredIn: origin === 'environment' ? 'environment' : 'omp auth credentials',
|
|
166
|
+
credentialSource: 'omp-auth' as const,
|
|
167
|
+
...(origin ? { credentialOrigin: origin } : {}),
|
|
168
|
+
oauth: true,
|
|
169
|
+
available: provider.available,
|
|
170
|
+
models: providerModels(
|
|
171
|
+
{ name: provider.name, slug: provider.id },
|
|
172
|
+
options.catalog,
|
|
173
|
+
options.nativeModels,
|
|
174
|
+
options.overlay,
|
|
175
|
+
),
|
|
42
176
|
};
|
|
43
177
|
}
|
|
44
178
|
|
|
@@ -46,20 +180,14 @@ export function disabledProviderItem(slug: string): ProviderItem {
|
|
|
46
180
|
* Native provider entry discovered from models.yml. Credentials never leave
|
|
47
181
|
* omp's own stores — Kabmo only surfaces registration info.
|
|
48
182
|
*/
|
|
49
|
-
export function nativeProviderItem(
|
|
183
|
+
export function nativeProviderItem(
|
|
184
|
+
info: NativeProviderInfo,
|
|
185
|
+
isDisabled: boolean,
|
|
186
|
+
catalog: CatalogModel[] | undefined,
|
|
187
|
+
overlay: ModelOverlay | undefined,
|
|
188
|
+
credentials: CredentialContext,
|
|
189
|
+
): ProviderItem {
|
|
50
190
|
const { slug, baseUrl } = info;
|
|
51
|
-
const models = info.models.map((model) => ({
|
|
52
|
-
id: model.id,
|
|
53
|
-
name: model.name || model.id,
|
|
54
|
-
contextWindow: model.contextWindow
|
|
55
|
-
? `${formatContextWindow(model.contextWindow) || Math.round(model.contextWindow / 1000)} ctx`
|
|
56
|
-
: '',
|
|
57
|
-
hasTools: true,
|
|
58
|
-
hasVision: model.imageInput === true,
|
|
59
|
-
hasReasoning: model.reasoning,
|
|
60
|
-
isVisible: true,
|
|
61
|
-
maxTokens: model.maxTokens,
|
|
62
|
-
}));
|
|
63
191
|
return {
|
|
64
192
|
id: `omp-native-${slug}`,
|
|
65
193
|
name: slug,
|
|
@@ -69,28 +197,74 @@ export function nativeProviderItem(info: NativeProviderInfo, isDisabled = false)
|
|
|
69
197
|
disabled: isDisabled,
|
|
70
198
|
configuredIn: baseUrl ? `models.yml · ${baseUrl}` : 'models.yml',
|
|
71
199
|
credentialSource: 'models.yml' as const,
|
|
200
|
+
credentialOrigin: credentials.originOf(slug),
|
|
201
|
+
available: true,
|
|
72
202
|
// The endpoint travels on the item, not only inside `configuredIn`'s label.
|
|
73
203
|
// It is what the models list gates "fetch models" on, so leaving it out of
|
|
74
204
|
// the payload disabled the button for every models.yml provider — the one
|
|
75
|
-
// set of providers whose endpoint is actually known to Kabmo. The
|
|
76
|
-
//
|
|
205
|
+
// set of providers whose endpoint is actually known to Kabmo. The URL is
|
|
206
|
+
// not a secret: `configuredIn` already prints it.
|
|
77
207
|
...(baseUrl ? { baseUrl } : {}),
|
|
78
208
|
// This entry was built FROM models.yml, so the file holds it by definition.
|
|
79
209
|
inModelsYml: true,
|
|
80
210
|
// The dialect is what makes a native entry legible in the settings UI: an
|
|
81
|
-
// Anthropic-shaped proxy and an
|
|
211
|
+
// Anthropic-shaped proxy and an [OI] one look identical without it, and
|
|
82
212
|
// the keyless/auth choice decides whether a missing credential is a bug.
|
|
83
213
|
...(isOmpProviderApi(info.api) ? { api: info.api } : {}),
|
|
84
214
|
...(isProviderAuthMode(info.auth) ? { auth: info.auth } : {}),
|
|
85
215
|
...(isProviderDiscoveryType(info.discovery) ? { discovery: info.discovery } : {}),
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
216
|
+
...(info.headers ? { headers: info.headers } : {}),
|
|
217
|
+
...(info.authHeader ? { authHeader: true } : {}),
|
|
218
|
+
...(info.transport ? { transport: info.transport } : {}),
|
|
219
|
+
// The registry can tell the two shapes apart without guessing: a discovery
|
|
220
|
+
// block means omp owns the list, and no models at all under a configured
|
|
221
|
+
// endpoint means this is an override for a bundled provider.
|
|
89
222
|
modelSource: isProviderDiscoveryType(info.discovery)
|
|
90
223
|
? 'discovery'
|
|
91
224
|
: info.models.length === 0 && Boolean(baseUrl)
|
|
92
225
|
? 'override'
|
|
93
226
|
: 'fetch',
|
|
94
|
-
models:
|
|
227
|
+
models: providerModels({ name: slug, slug, ...(baseUrl ? { baseUrl } : {}) }, catalog, info.models, overlay),
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* A provider that serves models but appears in neither `get_login_providers`
|
|
233
|
+
* nor models.yml — a keyless local endpoint (ollama, LM Studio, llama.cpp) omp
|
|
234
|
+
* discovers on its own. Without this row its models existed in the chat picker
|
|
235
|
+
* and nowhere in the panel that is supposed to manage them.
|
|
236
|
+
*/
|
|
237
|
+
export function catalogProviderItem(
|
|
238
|
+
slug: string,
|
|
239
|
+
catalog: CatalogModel[],
|
|
240
|
+
overlay: ModelOverlay | undefined,
|
|
241
|
+
): ProviderItem {
|
|
242
|
+
return {
|
|
243
|
+
id: `omp-catalog-${slug}`,
|
|
244
|
+
name: slug,
|
|
245
|
+
slug,
|
|
246
|
+
icon: slug,
|
|
247
|
+
status: 'connected',
|
|
248
|
+
configuredIn: 'discovered by omp',
|
|
249
|
+
available: true,
|
|
250
|
+
models: providerModels({ name: slug, slug }, catalog, [], overlay),
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Build a disabled-native ProviderItem for a provider the omp agent reports as
|
|
256
|
+
* disabled (config.yml disabledProviders). The UI treats these as
|
|
257
|
+
* "disconnected" — re-enabling via POST { enableProvider } flips config.yml.
|
|
258
|
+
*/
|
|
259
|
+
export function disabledProviderItem(slug: string): ProviderItem {
|
|
260
|
+
return {
|
|
261
|
+
id: `omp-disabled-${slug}`,
|
|
262
|
+
name: slug,
|
|
263
|
+
slug,
|
|
264
|
+
icon: slug,
|
|
265
|
+
status: 'disconnected',
|
|
266
|
+
disabled: true,
|
|
267
|
+
configuredIn: 'omp disabledProviders',
|
|
268
|
+
models: [],
|
|
95
269
|
};
|
|
96
270
|
}
|