@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,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* What the catalogs OFFER, and where each install came from.
|
|
8
|
+
*
|
|
9
|
+
* Two questions that must be answered together, which is why they live in one
|
|
10
|
+
* module: the offer list says which plugin ids a store or a curated catalog
|
|
11
|
+
* publishes, and the origin of an install is a property of THAT list — a
|
|
12
|
+
* directory on disk cannot say whether it arrived from Kabmo's store, from a
|
|
13
|
+
* clone, or from a folder someone dropped in.
|
|
14
|
+
*
|
|
15
|
+
* Three sources merge into one list, because to a reader they are one store:
|
|
16
|
+
*
|
|
17
|
+
* - the bundled marketplace (plugins shipped inside the package),
|
|
18
|
+
* - the user's own `marketplace.json` (a curated list), and
|
|
19
|
+
* - remote git offers from either catalog — entries whose `source` is a URL.
|
|
20
|
+
*
|
|
21
|
+
* A store offer wins over a remote one for the same id: its directory is on
|
|
22
|
+
* disk, so it can draw an icon and a README, and both rows would install the
|
|
23
|
+
* same id.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { join } from 'path';
|
|
27
|
+
import type {
|
|
28
|
+
PanelCatalogEntry,
|
|
29
|
+
PanelGitStatus,
|
|
30
|
+
PanelPluginStatus,
|
|
31
|
+
} from '@/shared/types';
|
|
32
|
+
import { readBundledCatalog } from '@/server/lib/panels/bundled-catalog.server';
|
|
33
|
+
import { readRemoteOffers } from '@/server/lib/panels/catalog-offers.server';
|
|
34
|
+
|
|
35
|
+
/** The catalog payload: every offer, from every source, de-duplicated. */
|
|
36
|
+
export async function assembleCatalog(options: {
|
|
37
|
+
/** The working marketplace's `marketplace.json`. */
|
|
38
|
+
workingCatalogPath: string;
|
|
39
|
+
/** The store shipped inside the package. */
|
|
40
|
+
bundledRoot: string;
|
|
41
|
+
/** Every plugin id already on disk, in any scope. */
|
|
42
|
+
installed: ReadonlySet<string>;
|
|
43
|
+
}): Promise<PanelCatalogEntry[]> {
|
|
44
|
+
const catalog = await readBundledCatalog(options.bundledRoot, options.installed);
|
|
45
|
+
const remoteOffers = [
|
|
46
|
+
...(await readRemoteOffers(options.workingCatalogPath, options.installed)),
|
|
47
|
+
...(await readRemoteOffers(join(options.bundledRoot, 'marketplace.json'), options.installed)),
|
|
48
|
+
];
|
|
49
|
+
const held = new Set(catalog.map((entry) => entry.pluginId));
|
|
50
|
+
for (const offer of remoteOffers) {
|
|
51
|
+
if (held.has(offer.pluginId)) continue;
|
|
52
|
+
held.add(offer.pluginId);
|
|
53
|
+
catalog.push(offer);
|
|
54
|
+
}
|
|
55
|
+
return catalog;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Fill in what each install's SOURCE says about it: `bundled`, `origin`, and the
|
|
60
|
+
* newer version when one is known.
|
|
61
|
+
*
|
|
62
|
+
* Mutates the rows rather than returning copies, because these are the payload's
|
|
63
|
+
* own objects and a second list would be a second answer to the same question.
|
|
64
|
+
*
|
|
65
|
+
* The two version sources are different facts and both are read:
|
|
66
|
+
*
|
|
67
|
+
* - a BUNDLED install's source is the store, whose manifest is on disk — so its
|
|
68
|
+
* version is known without a network call;
|
|
69
|
+
* - a GIT clone's source is its remote, which only a freshness probe can answer;
|
|
70
|
+
* `git-update.server.ts` writes that back onto the status cache, so it arrives
|
|
71
|
+
* here as `latestVersion` on the status row.
|
|
72
|
+
*
|
|
73
|
+
* A `latestVersion` is never invented: absent means "unknown", which the card
|
|
74
|
+
* renders as the installed version alone.
|
|
75
|
+
*/
|
|
76
|
+
export function applySources(
|
|
77
|
+
plugins: PanelPluginStatus[],
|
|
78
|
+
catalog: readonly PanelCatalogEntry[],
|
|
79
|
+
gitStatus: Readonly<Record<string, PanelGitStatus>>,
|
|
80
|
+
): void {
|
|
81
|
+
const bundledIds = new Set(
|
|
82
|
+
catalog.filter((entry) => entry.origin === 'bundled').map((entry) => entry.pluginId),
|
|
83
|
+
);
|
|
84
|
+
const storeVersions = new Map(
|
|
85
|
+
catalog
|
|
86
|
+
.filter((entry) => entry.origin === 'bundled' && entry.version)
|
|
87
|
+
.map((entry) => [entry.pluginId, entry.version]),
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
for (const plugin of plugins) {
|
|
91
|
+
// `bundled` is a property of the SOURCE, not of the install, and a git CLONE
|
|
92
|
+
// is excluded however its id reads: the store offers a plugin under that id,
|
|
93
|
+
// but the directory on disk is the user's own repository — and the sync that
|
|
94
|
+
// keeps bundled installs current selects on this same flag, so attributing a
|
|
95
|
+
// clone to the store would overwrite it on the next boot.
|
|
96
|
+
plugin.bundled = bundledIds.has(plugin.pluginId) && plugin.gitOrigin === null;
|
|
97
|
+
// The origin the card names is the same derivation, so a plugin cannot be
|
|
98
|
+
// "bundled" on one line of its card and "git" on another.
|
|
99
|
+
plugin.origin = plugin.gitOrigin ? 'git' : plugin.bundled ? 'bundled' : 'local';
|
|
100
|
+
|
|
101
|
+
if (plugin.bundled) {
|
|
102
|
+
const store = storeVersions.get(plugin.pluginId);
|
|
103
|
+
if (store) plugin.latestVersion = store;
|
|
104
|
+
}
|
|
105
|
+
const probed = gitStatus[plugin.pluginId]?.latestVersion;
|
|
106
|
+
if (probed && !plugin.latestVersion) plugin.latestVersion = probed;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* BY NAME, with both sides of the comparison in the reason.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
25
|
+
import { afterEach, beforeEach, describe, expect, setDefaultTimeout, test } from 'bun:test';
|
|
26
26
|
import fs from 'node:fs';
|
|
27
27
|
import { tmpdir } from 'node:os';
|
|
28
28
|
import { join } from 'node:path';
|
|
@@ -38,6 +38,20 @@ import {
|
|
|
38
38
|
import { setPluginEnabled } from '@/server/lib/panels/state.server';
|
|
39
39
|
import { isolateDb, releaseDb } from '@/test-support/isolated-db';
|
|
40
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Every case here opens a FRESH database (`isolateDb`) and then scans, because
|
|
43
|
+
* the scan reads the disabled set — so each test pays a `bun:sqlite` open plus
|
|
44
|
+
* the whole schema bootstrap. On `windows-latest` that pair is several times a
|
|
45
|
+
* POSIX runner's, and Bun's default 5s budget is not enough: measured on the
|
|
46
|
+
* Release gate, `a plugin loads with no catalog at all` timed out at 5042ms
|
|
47
|
+
* (the run reported 1 fail plus "Unhandled error between tests" from the
|
|
48
|
+
* retired open's own rejection), while the same suite finishes in ~200ms here.
|
|
49
|
+
*
|
|
50
|
+
* A budget, not a skip: the rules under test are identical on both platforms.
|
|
51
|
+
*/
|
|
52
|
+
const PANEL_SCAN_TIMEOUT_MS = 30_000;
|
|
53
|
+
setDefaultTimeout(PANEL_SCAN_TIMEOUT_MS);
|
|
54
|
+
|
|
41
55
|
let root = '';
|
|
42
56
|
|
|
43
57
|
const VALID = {
|
|
@@ -149,6 +163,26 @@ describe('discoverPanelPlugins', () => {
|
|
|
149
163
|
expect(errors[0].source).toBe('plugins/ghost');
|
|
150
164
|
});
|
|
151
165
|
|
|
166
|
+
test('a REMOTE catalog entry is an offer, never a dangling directory', async () => {
|
|
167
|
+
// The entry names a repository, not a folder here — so the scan must list
|
|
168
|
+
// it as installable and must NOT report it as "listed but not found".
|
|
169
|
+
writeCatalog({
|
|
170
|
+
plugins: [
|
|
171
|
+
{ name: 'acme-panels', source: 'https://github.com/acme/panels.git', description: 'Acme panels' },
|
|
172
|
+
],
|
|
173
|
+
});
|
|
174
|
+
invalidatePanelScan();
|
|
175
|
+
const { errors, catalog } = await discoverPanelPlugins();
|
|
176
|
+
expect(errors).toEqual([]);
|
|
177
|
+
const offer = catalog.find((entry) => entry.pluginId === 'acme-panels');
|
|
178
|
+
expect(offer).toMatchObject({
|
|
179
|
+
origin: 'git',
|
|
180
|
+
url: 'https://github.com/acme/panels.git',
|
|
181
|
+
description: 'Acme panels',
|
|
182
|
+
installed: false,
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
|
|
152
186
|
test('a rejection that is not a dangling entry carries no source', async () => {
|
|
153
187
|
// Nothing to forget: the fault is in a manifest that will not parse, and a
|
|
154
188
|
// button that dropped the record would hide it rather than fix it.
|
|
@@ -6,47 +6,40 @@
|
|
|
6
6
|
/**
|
|
7
7
|
* Panel-plugin discovery.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
9
|
+
* One bundled marketplace, read from disk: the store inside the package is what
|
|
10
|
+
* the pane offers, and the working copy under the data directory is what is
|
|
11
|
+
* installed. This module owns the ROOTS, the scan CACHE and the PAYLOAD SHAPE;
|
|
12
|
+
* the per-directory reading lives in `scan.server.ts` and the catalog/offer
|
|
13
|
+
* merge in `offers.server.ts`.
|
|
10
14
|
*
|
|
11
|
-
*
|
|
12
|
-
* plugins/session-info/ an offer, not an install
|
|
15
|
+
* What it deliberately does NOT do:
|
|
13
16
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
17
|
+
* - copy or build the bundled plugins (that is `install.server.ts`, which makes
|
|
18
|
+
* a bundled install and a git install the same thing afterwards),
|
|
19
|
+
* - probe a remote for freshness (that is a network round trip and lives in
|
|
20
|
+
* `git-update.server.ts`, whose result rides on the status cache),
|
|
21
|
+
* - validate a manifest (`manifest.ts` owns the rules, so the scan, the
|
|
22
|
+
* installer and the builder cannot disagree about what a plugin is).
|
|
19
23
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* The catalog and the directory are independent, and both directions matter: a
|
|
25
|
-
* plugin present under `plugins/` but absent from the catalog still loads (that
|
|
26
|
-
* is what makes a hand-copied folder work), and a catalog entry naming a
|
|
27
|
-
* directory that holds no plugin is REPORTED (that is what makes a failed
|
|
28
|
-
* install visible instead of silent).
|
|
29
|
-
*
|
|
30
|
-
* Nothing here executes plugin code: the scan reads manifests, validates them
|
|
31
|
-
* and reports every rejection with its reason, and the browser imports the
|
|
32
|
-
* bundle later from the bundle route.
|
|
24
|
+
* A plugin directory that is broken is REPORTED, never hidden: a plugin that
|
|
25
|
+
* fails to load with no reason reads as a plugin that was never installed, which
|
|
26
|
+
* is the single most confusing failure this surface can have.
|
|
33
27
|
*/
|
|
34
28
|
|
|
35
29
|
import { join, resolve } from 'path';
|
|
36
|
-
import type {
|
|
30
|
+
import type { PanelRegistryPayload } from '@/shared/types';
|
|
37
31
|
import { pathExists } from '@/server/lib/omp/core/paths';
|
|
38
32
|
import { packageDir } from '@/server/lib/fs/package-root';
|
|
39
33
|
import { getDataDir } from '@/server/lib/lifecycle/paths';
|
|
40
34
|
import { readDisabledPlugins, readPluginAutoUpdate } from '@/server/lib/panels/state.server';
|
|
41
35
|
import { readAllGitStatuses } from '@/server/lib/panels/git-status.server';
|
|
42
36
|
import { readBlockedSyncs } from '@/server/lib/panels/baseline.server';
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
46
|
-
import {
|
|
47
|
-
import {
|
|
48
|
-
import {
|
|
49
|
-
import { pluginEnablementKey } from '@/shared/lib/workspace/panel-ids';
|
|
37
|
+
import { readJsonBody, subdirectories } from '@/server/lib/panels/files.server';
|
|
38
|
+
import { toMarketplaceCatalog } from '@/server/lib/panels/manifest';
|
|
39
|
+
import { basenameOf } from '@/server/lib/panels/assets.server';
|
|
40
|
+
import { runningVersions } from '@/server/lib/panels/compat.server';
|
|
41
|
+
import { scanInstalledPlugins } from '@/server/lib/panels/scan.server';
|
|
42
|
+
import { applySources, assembleCatalog } from '@/server/lib/panels/offers.server';
|
|
50
43
|
|
|
51
44
|
/** The marketplace root: `<data>/marketplace`, overridable for tests. */
|
|
52
45
|
export function getMarketplaceDir(): string {
|
|
@@ -112,7 +105,6 @@ export function invalidatePanelScan(): void {
|
|
|
112
105
|
|
|
113
106
|
async function runPanelScan(): Promise<PanelScan> {
|
|
114
107
|
const root = getMarketplaceDir();
|
|
115
|
-
const pluginsRoot = getMarketplacePluginsDir();
|
|
116
108
|
const scan: PanelScan = {
|
|
117
109
|
panels: [],
|
|
118
110
|
marketplaces: [],
|
|
@@ -150,6 +142,10 @@ async function runPanelScan(): Promise<PanelScan> {
|
|
|
150
142
|
// load. The entry's own `source` rides along so the pane can drop that one
|
|
151
143
|
// entry — the row is otherwise a dead end the user cannot clear.
|
|
152
144
|
for (const entry of catalog.plugins ?? []) {
|
|
145
|
+
// A REMOTE source names no directory here — it is an offer the pane
|
|
146
|
+
// lists and `install` clones, so checking for a folder would report
|
|
147
|
+
// every curated git plugin as a dangling entry.
|
|
148
|
+
if (entry.remote) continue;
|
|
153
149
|
const source = resolve(root, entry.source);
|
|
154
150
|
if (!(await pathExists(source))) {
|
|
155
151
|
fail(source, `listed in marketplace.json but no plugin was found there (${entry.name})`, entry.source);
|
|
@@ -161,124 +157,37 @@ async function runPanelScan(): Promise<PanelScan> {
|
|
|
161
157
|
// Read once, before the loop: whether a plugin is ON decides whether its
|
|
162
158
|
// bundle is published, and the flag is stored rather than derived.
|
|
163
159
|
const disabledList = await readDisabledPlugins();
|
|
164
|
-
const disabled = new Set(disabledList);
|
|
165
160
|
// The raw list travels with the payload: a BUILT-IN view is named by its bare
|
|
166
161
|
// id and the server has no built-in list to resolve it against, so the client
|
|
167
162
|
// is what filters its own views. The scan itself only ever asks about plugin
|
|
168
|
-
// ids, which is why the membership test
|
|
163
|
+
// ids, which is why the membership test is a `Set`.
|
|
169
164
|
scan.disabledPanels = disabledList;
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
fail(pluginDir, refusal);
|
|
195
|
-
continue;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// A plugin is served from its build output, so every entry its manifest
|
|
199
|
-
// declares must already exist. A plugin whose build has not run is reported
|
|
200
|
-
// as UNBUILT rather than as broken — the manifest is fine, and the pane
|
|
201
|
-
// offers to run the build — which is why this is a separate list from
|
|
202
|
-
// `errors`. A plugin with BOTH an app and a server needs both.
|
|
203
|
-
const isPackage = await pathExists(join(pluginDir, 'package.json'));
|
|
204
|
-
// A plugin's enablement key carries the SAME prefix the client uses for its
|
|
205
|
-
// panel id (`plugin:<id>`), so one stored list answers for both kinds. Testing
|
|
206
|
-
// the bare manifest id here made a disabled plugin still report `enabled:
|
|
207
|
-
// true` while its panel stayed hidden — two answers for one question.
|
|
208
|
-
const enabled = !disabled.has(pluginEnablementKey(manifest.id));
|
|
209
|
-
const entries = [manifest.app, manifest.server].filter((entry): entry is string => Boolean(entry));
|
|
210
|
-
let missingEntry: string | undefined;
|
|
211
|
-
for (const entry of entries) {
|
|
212
|
-
if (!(await pathExists(join(pluginDir, entry)))) {
|
|
213
|
-
missingEntry = entry;
|
|
214
|
-
break;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
const built = missingEntry === undefined;
|
|
218
|
-
// The clone's own origin is what makes a plugin updatable. Read here rather
|
|
219
|
-
// than stored at install time: the directory is the install, so a URL kept
|
|
220
|
-
// beside it could disagree with it.
|
|
221
|
-
const gitOrigin = await readGitOrigin(pluginDir);
|
|
222
|
-
pluginStatus.push({
|
|
223
|
-
pluginId: manifest.id,
|
|
224
|
-
name: manifest.name,
|
|
225
|
-
version: manifest.version,
|
|
226
|
-
isPackage,
|
|
227
|
-
built,
|
|
228
|
-
enabled,
|
|
229
|
-
bundled: false,
|
|
230
|
-
gitOrigin,
|
|
231
|
-
...(missingEntry ? { reason: `the build produced no ${missingEntry}` } : {}),
|
|
232
|
-
});
|
|
233
|
-
// A switched-off plugin contributes NOTHING: no button, no tab, and no
|
|
234
|
-
// bundle for the route to serve. Its files stay on disk, which is the whole
|
|
235
|
-
// difference between disabling and removing.
|
|
236
|
-
if (!enabled || !built) continue;
|
|
237
|
-
// The directory map is the asset routes' root, so it is filled even for a
|
|
238
|
-
// server-only plugin: its README and icon are still served.
|
|
239
|
-
scan.dirs[manifest.id] = pluginDir;
|
|
240
|
-
// `panels` is the list of UI bundles the host IMPORTS, so a plugin with no
|
|
241
|
-
// `app` contributes none — its work happens on the server, not in the page.
|
|
242
|
-
if (!manifest.app) continue;
|
|
243
|
-
|
|
244
|
-
scan.panels.push({
|
|
245
|
-
pluginId: manifest.id,
|
|
246
|
-
name: manifest.name,
|
|
247
|
-
version: manifest.version,
|
|
248
|
-
appUrl: await bundleUrl(pluginDir, manifest.app),
|
|
249
|
-
// Only when the plugin DECLARED a stylesheet and the file is actually
|
|
250
|
-
// there. A manifest that names a `css` the build did not emit would
|
|
251
|
-
// otherwise put a 404 URL in the payload and a console error on every
|
|
252
|
-
// load, for a stylesheet the plugin does not have.
|
|
253
|
-
...(manifest.css && (await pathExists(join(pluginDir, manifest.css)))
|
|
254
|
-
? { cssUrl: await cssUrl(pluginDir, manifest.css) }
|
|
255
|
-
: {}),
|
|
256
|
-
...(manifest.icon ? { iconUrl: await iconUrl(pluginDir, manifest.icon) } : {}),
|
|
257
|
-
...(await readmeUrlFor(pluginDir, manifest)),
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
// The bundled marketplace is a STORE, so its plugins are listed whether or
|
|
262
|
-
// not they are installed — that is what gives the pane something to install
|
|
263
|
-
// FROM. They are never scanned as contributions and never built: installing
|
|
264
|
-
// copies one into the working marketplace, where the loop above picks it up.
|
|
265
|
-
const installed = new Set(pluginStatus.map((plugin) => plugin.pluginId));
|
|
266
|
-
scan.catalog = await readBundledCatalog(getBundledMarketplaceDir(), installed);
|
|
267
|
-
// `bundled` is a property of the SOURCE, not of the install: it is what makes
|
|
268
|
-
// the pane offer "Remove" for a bundled plugin rather than "Uninstall", and
|
|
269
|
-
// it is read off the store's own list so a plugin id that exists in both
|
|
270
|
-
// places cannot report the wrong one.
|
|
271
|
-
//
|
|
272
|
-
// A git CLONE is excluded however its id reads: the store offers a plugin
|
|
273
|
-
// under that id, but the directory on disk is the user's own repository — and
|
|
274
|
-
// the sync that keeps bundled installs current selects on this same flag, so
|
|
275
|
-
// attributing a clone to the store would overwrite it on the next boot.
|
|
276
|
-
const bundledIds = new Set(scan.catalog.map((entry) => entry.pluginId));
|
|
277
|
-
for (const plugin of pluginStatus) plugin.bundled = bundledIds.has(plugin.pluginId) && plugin.gitOrigin === null;
|
|
165
|
+
const scanned = await scanInstalledPlugins({
|
|
166
|
+
pluginsRoot: getMarketplacePluginsDir(),
|
|
167
|
+
disabled: new Set(disabledList),
|
|
168
|
+
// Resolved ONCE per scan: a plugin's `engines` is compared against what is
|
|
169
|
+
// running HERE, never a constant.
|
|
170
|
+
running: await runningVersions(),
|
|
171
|
+
marketplace: MARKETPLACE_ID,
|
|
172
|
+
});
|
|
173
|
+
scan.plugins = scanned.pluginStatus;
|
|
174
|
+
scan.panels = scanned.panels;
|
|
175
|
+
scan.dirs = scanned.dirs;
|
|
176
|
+
scan.errors.push(...scanned.errors);
|
|
177
|
+
|
|
178
|
+
// The status cache is read BEFORE the offers are folded in, because a git
|
|
179
|
+
// clone's `latestVersion` comes from the freshness probe and the fold is what
|
|
180
|
+
// copies it onto the row.
|
|
181
|
+
scan.gitStatus = readAllGitStatuses();
|
|
182
|
+
const installed = new Set(scanned.pluginStatus.map((plugin) => plugin.pluginId));
|
|
183
|
+
scan.catalog = await assembleCatalog({
|
|
184
|
+
workingCatalogPath: getMarketplaceCatalogPath(),
|
|
185
|
+
bundledRoot: getBundledMarketplaceDir(),
|
|
186
|
+
installed,
|
|
187
|
+
});
|
|
188
|
+
applySources(scan.plugins, scan.catalog, scan.gitStatus);
|
|
278
189
|
|
|
279
190
|
scan.marketplaces.push({ id: MARKETPLACE_ID, name, description, panelCount: scan.panels.length, errors: [] });
|
|
280
|
-
scan.plugins = pluginStatus;
|
|
281
|
-
scan.gitStatus = readAllGitStatuses();
|
|
282
191
|
scan.autoUpdate = await readPluginAutoUpdate();
|
|
283
192
|
scan.syncBlocked = await readBlockedSyncs();
|
|
284
193
|
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* One pass over the working marketplace's `plugins/` directory.
|
|
8
|
+
*
|
|
9
|
+
* Split out of `registry.server.ts` because that file also owns the marketplace
|
|
10
|
+
* roots, the scan cache and the payload assembly, and the loop alone is a third
|
|
11
|
+
* of it. The boundary is a fact about the loop: everything here reads ONE plugin
|
|
12
|
+
* directory and answers what it is, while nothing here decides which
|
|
13
|
+
* directories exist, what the payload looks like, or whether a scan is cached.
|
|
14
|
+
*
|
|
15
|
+
* A rejection is pushed through `fail` rather than thrown, because a plugin that
|
|
16
|
+
* cannot load must not stop the scan — the pane reports it by name and the other
|
|
17
|
+
* plugins keep working.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { join } from 'path';
|
|
21
|
+
import type {
|
|
22
|
+
PanelPluginError,
|
|
23
|
+
PanelPluginStatus,
|
|
24
|
+
PanelRegistryEntry,
|
|
25
|
+
} from '@/shared/types';
|
|
26
|
+
import { pathExists } from '@/server/lib/omp/core/paths';
|
|
27
|
+
import { pluginEnablementKey } from '@/shared/lib/workspace/panel-ids';
|
|
28
|
+
import { readPluginManifest, subdirectories } from '@/server/lib/panels/files.server';
|
|
29
|
+
import { toManifest } from '@/server/lib/panels/manifest';
|
|
30
|
+
import { bundleUrl, cssUrl, iconUrl, readmeUrlFor } from '@/server/lib/panels/assets.server';
|
|
31
|
+
import { readGitOrigin } from '@/server/lib/panels/git-clone.server';
|
|
32
|
+
import { describeIncompatibility, type RunningVersions } from '@/server/lib/panels/compat.server';
|
|
33
|
+
|
|
34
|
+
/** What one pass produced, in the four shapes the payload needs. */
|
|
35
|
+
export interface ScannedPlugins {
|
|
36
|
+
/** Every plugin whose manifest parsed, enabled or not, built or not. */
|
|
37
|
+
pluginStatus: PanelPluginStatus[];
|
|
38
|
+
/** The bundles the host should import — enabled, built, and with an `app`. */
|
|
39
|
+
panels: PanelRegistryEntry[];
|
|
40
|
+
/** Plugin id → its directory, for the asset routes. */
|
|
41
|
+
dirs: Record<string, string>;
|
|
42
|
+
errors: PanelPluginError[];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Read every plugin directory, in one pass.
|
|
47
|
+
*
|
|
48
|
+
* `disabled` is a `Set` of ENABLEMENT keys (`plugin:<id>`) and `running` is the
|
|
49
|
+
* versions this host actually runs, resolved once by the caller — a plugin's
|
|
50
|
+
* `engines` is compared against what is running HERE, never a constant.
|
|
51
|
+
*/
|
|
52
|
+
export async function scanInstalledPlugins(options: {
|
|
53
|
+
pluginsRoot: string;
|
|
54
|
+
disabled: ReadonlySet<string>;
|
|
55
|
+
running: RunningVersions;
|
|
56
|
+
/** The marketplace every rejection is attributed to. */
|
|
57
|
+
marketplace: string;
|
|
58
|
+
}): Promise<ScannedPlugins> {
|
|
59
|
+
const { pluginsRoot, disabled, running, marketplace } = options;
|
|
60
|
+
const scanned: ScannedPlugins = { pluginStatus: [], panels: [], dirs: {}, errors: [] };
|
|
61
|
+
const fail = (dir: string, reason: string) =>
|
|
62
|
+
scanned.errors.push({ dir, reason, marketplace });
|
|
63
|
+
|
|
64
|
+
for (const pluginName of await subdirectories(pluginsRoot)) {
|
|
65
|
+
const pluginDir = join(pluginsRoot, pluginName);
|
|
66
|
+
const read = await readPluginManifest(pluginDir);
|
|
67
|
+
if (read.kind === 'none') continue;
|
|
68
|
+
if (read.kind === 'error') {
|
|
69
|
+
fail(pluginDir, read.reason);
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
const manifest = toManifest(read.value, pluginDir);
|
|
73
|
+
if ('error' in manifest) {
|
|
74
|
+
fail(pluginDir, manifest.error);
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Refused BEFORE it is admitted: an incompatible plugin must contribute
|
|
79
|
+
// nothing — no panel, no bundle, no directory for the route to resolve.
|
|
80
|
+
// The reason names both sides, because the pane's only repair is the author
|
|
81
|
+
// editing the range.
|
|
82
|
+
const refusal = describeIncompatibility(manifest, running);
|
|
83
|
+
if (refusal) {
|
|
84
|
+
fail(pluginDir, refusal);
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// A plugin is served from its build output, so every entry its manifest
|
|
89
|
+
// declares must already exist. A plugin whose build has not run is reported
|
|
90
|
+
// as UNBUILT rather than as broken — the manifest is fine, and the pane
|
|
91
|
+
// offers to run the build — which is why this is a separate list from
|
|
92
|
+
// `errors`. A plugin with BOTH an app and a server needs both.
|
|
93
|
+
const isPackage = await pathExists(join(pluginDir, 'package.json'));
|
|
94
|
+
// A plugin's enablement key carries the SAME prefix the client uses for its
|
|
95
|
+
// panel id (`plugin:<id>`), so one stored list answers for both kinds. Testing
|
|
96
|
+
// the bare manifest id here made a disabled plugin still report `enabled:
|
|
97
|
+
// true` while its panel stayed hidden — two answers for one question.
|
|
98
|
+
const enabled = !disabled.has(pluginEnablementKey(manifest.id));
|
|
99
|
+
const entries = [manifest.app, manifest.server].filter((entry): entry is string => Boolean(entry));
|
|
100
|
+
let missingEntry: string | undefined;
|
|
101
|
+
for (const entry of entries) {
|
|
102
|
+
if (!(await pathExists(join(pluginDir, entry)))) {
|
|
103
|
+
missingEntry = entry;
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const built = missingEntry === undefined;
|
|
108
|
+
// The clone's own origin is what makes a plugin updatable. Read here rather
|
|
109
|
+
// than stored at install time: the directory is the install, so a URL kept
|
|
110
|
+
// beside it could disagree with it.
|
|
111
|
+
const gitOrigin = await readGitOrigin(pluginDir);
|
|
112
|
+
scanned.pluginStatus.push({
|
|
113
|
+
pluginId: manifest.id,
|
|
114
|
+
name: manifest.name,
|
|
115
|
+
version: manifest.version,
|
|
116
|
+
isPackage,
|
|
117
|
+
built,
|
|
118
|
+
enabled,
|
|
119
|
+
// Both are corrected by `applySources` once the catalogs have been read:
|
|
120
|
+
// whether this install came from the store is a property of the SOURCE,
|
|
121
|
+
// which is not knowable from the directory alone.
|
|
122
|
+
bundled: false,
|
|
123
|
+
origin: gitOrigin ? 'git' : 'local',
|
|
124
|
+
gitOrigin,
|
|
125
|
+
settingsCount: Object.keys(manifest.settings ?? {}).length,
|
|
126
|
+
...(manifest.description ? { description: manifest.description } : {}),
|
|
127
|
+
...(manifest.author ? { author: manifest.author } : {}),
|
|
128
|
+
...(manifest.homepage ? { homepage: manifest.homepage } : {}),
|
|
129
|
+
...(manifest.slots ? { slots: manifest.slots } : {}),
|
|
130
|
+
...(manifest.capabilities ? { capabilities: manifest.capabilities } : {}),
|
|
131
|
+
...(missingEntry ? { reason: `the build produced no ${missingEntry}` } : {}),
|
|
132
|
+
});
|
|
133
|
+
// A switched-off plugin contributes NOTHING: no button, no tab, and no
|
|
134
|
+
// bundle for the route to serve. Its files stay on disk, which is the whole
|
|
135
|
+
// difference between disabling and removing.
|
|
136
|
+
if (!enabled || !built) continue;
|
|
137
|
+
// The directory map is the asset routes' root, so it is filled even for a
|
|
138
|
+
// server-only plugin: its README and icon are still served.
|
|
139
|
+
scanned.dirs[manifest.id] = pluginDir;
|
|
140
|
+
// `panels` is the list of UI bundles the host IMPORTS, so a plugin with no
|
|
141
|
+
// `app` contributes none — its work happens on the server, not in the page.
|
|
142
|
+
if (!manifest.app) continue;
|
|
143
|
+
|
|
144
|
+
scanned.panels.push({
|
|
145
|
+
pluginId: manifest.id,
|
|
146
|
+
name: manifest.name,
|
|
147
|
+
version: manifest.version,
|
|
148
|
+
appUrl: await bundleUrl(pluginDir, manifest.app),
|
|
149
|
+
// Only when the plugin DECLARED a stylesheet and the file is actually
|
|
150
|
+
// there. A manifest that names a `css` the build did not emit would
|
|
151
|
+
// otherwise put a 404 URL in the payload and a console error on every
|
|
152
|
+
// load, for a stylesheet the plugin does not have.
|
|
153
|
+
...(manifest.css && (await pathExists(join(pluginDir, manifest.css)))
|
|
154
|
+
? { cssUrl: await cssUrl(pluginDir, manifest.css) }
|
|
155
|
+
: {}),
|
|
156
|
+
...(manifest.icon ? { iconUrl: await iconUrl(pluginDir, manifest.icon) } : {}),
|
|
157
|
+
...(await readmeUrlFor(pluginDir, manifest)),
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return scanned;
|
|
162
|
+
}
|
|
@@ -51,11 +51,22 @@ export function bindingsFor(module: RouteModule, path: string, options: MountOpt
|
|
|
51
51
|
* exists, the verb does not. Keeping that shape means a mistyped client call
|
|
52
52
|
* reports the real problem instead of looking like a missing endpoint.
|
|
53
53
|
*/
|
|
54
|
-
export const methodNotAllowed: RouteHandler = () =>
|
|
55
|
-
|
|
54
|
+
export const methodNotAllowed: RouteHandler = () => methodNotAllowedResponse();
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The same answer, typed as a `Response`.
|
|
58
|
+
*
|
|
59
|
+
* `RouteHandler` returns `unknown` because a handler may answer anything, and a
|
|
60
|
+
* route that declares `Promise<Response>` cannot return that: the widening is
|
|
61
|
+
* where a 405 would silently become "not a response". One function, so the two
|
|
62
|
+
* spellings cannot word the refusal differently.
|
|
63
|
+
*/
|
|
64
|
+
export function methodNotAllowedResponse(): Response {
|
|
65
|
+
return new Response(JSON.stringify({ error: 'Method not allowed' }), {
|
|
56
66
|
status: 405,
|
|
57
67
|
headers: { 'content-type': 'application/json; charset=utf-8' },
|
|
58
68
|
});
|
|
69
|
+
}
|
|
59
70
|
|
|
60
71
|
/** Parse a JSON request body without throwing. Caller decides the status code. */
|
|
61
72
|
export async function parseJsonBody<T = unknown>(
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
// `.desktop` file a freedesktop session reads and the Run value Windows stores
|
|
6
6
|
// are all strings, so they can be asserted without touching a real
|
|
7
7
|
// `~/Library/LaunchAgents`, a real `reg.exe` or a real session. What IS verified
|
|
8
|
-
// against the OS lives in the smoke runs recorded in
|
|
8
|
+
// against the OS lives in the smoke runs recorded in the wiki's Desktop
|
|
9
|
+
// integration page.
|
|
9
10
|
|
|
10
11
|
import { describe, expect, test } from 'bun:test';
|
|
11
12
|
import { existsSync } from 'node:fs';
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
22
|
import { fetchOmpRegistrySnapshot } from '@/server/lib/models/provider-registry.server';
|
|
23
|
+
import { readProviderIconUrls } from '@/server/lib/models/provider-icon.server';
|
|
23
24
|
import { buildDeepSeekReport } from '@/server/lib/usage/deepseek';
|
|
24
25
|
import { buildKenariReport } from '@/server/lib/usage/kenari';
|
|
25
26
|
import { fetchOmpUsageSnapshot, type OmpUsageSnapshot } from '@/server/lib/usage/omp-usage.server';
|
|
@@ -158,10 +159,11 @@ export function resolveUsageTracking(
|
|
|
158
159
|
* `force` bypasses the provider-quota cache (see `fetchOmpUsageSnapshot`).
|
|
159
160
|
*/
|
|
160
161
|
export async function buildUsageProviders(options: { force?: boolean } = {}): Promise<UsageProviderSummary[]> {
|
|
161
|
-
const [credentialed, snapshot, names] = await Promise.all([
|
|
162
|
+
const [credentialed, snapshot, names, iconUrls] = await Promise.all([
|
|
162
163
|
listCredentialedProviders(),
|
|
163
164
|
fetchOmpUsageSnapshot({ force: options.force }),
|
|
164
165
|
loadProviderNames(),
|
|
166
|
+
readProviderIconUrls(),
|
|
165
167
|
]);
|
|
166
168
|
|
|
167
169
|
const credentials = mergeCredentials(credentialed);
|
|
@@ -188,6 +190,7 @@ export async function buildUsageProviders(options: { force?: boolean } = {}): Pr
|
|
|
188
190
|
const summary: UsageProviderSummary = {
|
|
189
191
|
id: slug,
|
|
190
192
|
name: names[slug] ?? displayName(slug),
|
|
193
|
+
...(iconUrls.get(slug) ? { iconUrl: iconUrls.get(slug) } : {}),
|
|
191
194
|
credentialSources: sources,
|
|
192
195
|
// A vendor balance is real quota data even when omp has no adapter for it.
|
|
193
196
|
tracked: tracked || Boolean(balance && balance.limits.length > 0),
|
|
@@ -9,6 +9,7 @@ import { loadSessionMessages, loadSessionModel, loadSessionThinkingLevel, loadSe
|
|
|
9
9
|
import { mergeOmpAttachments, overlayRowsForOmpSession } from '@/server/lib/omp/session/merge-stored';
|
|
10
10
|
import { readRawHeaderLine } from '@/server/lib/omp/session/files';
|
|
11
11
|
import { formatNewSessionTitle } from '@/shared/lib/omp/session/default-title';
|
|
12
|
+
import { getLiveRunSessionIds } from '@/server/lib/omp/rpc/session-registry';
|
|
12
13
|
|
|
13
14
|
/** Newest-message window served by default for omp JSONL sessions; the client
|
|
14
15
|
* pages further back via `?before=` when the user scrolls to the top. Large
|
|
@@ -64,7 +65,12 @@ export async function loader({ params, request }: LoaderFunctionArgs) {
|
|
|
64
65
|
if (!mock) {
|
|
65
66
|
const filePath = await findSessionFileById(sessionId);
|
|
66
67
|
if (filePath) {
|
|
67
|
-
|
|
68
|
+
// A run in flight is what makes a resultless tool call "still running"
|
|
69
|
+
// rather than "finished with nothing": a page reloaded mid-call reads
|
|
70
|
+
// the transcript, which cannot tell the two apart on its own.
|
|
71
|
+
const messages = await loadSessionMessages(filePath, {
|
|
72
|
+
liveRun: getLiveRunSessionIds().has(sessionId),
|
|
73
|
+
});
|
|
68
74
|
// Real omp JSONL only records image blocks — text/pdf attachments
|
|
69
75
|
// never reach the file. The Kabmo's DB copy (written by the chat
|
|
70
76
|
// timeline) carries the full attachment metadata, so merge it back
|