mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 15:40:44 +00:00
fix(plugins): catalog externalized npm installs
This commit is contained in:
@@ -117,12 +117,13 @@ describe("listPersistedBundledPluginLocationBridges", () => {
|
||||
pluginId: "diagnostics-otel",
|
||||
preferredSource: "npm",
|
||||
npmSpec: "@openclaw/diagnostics-otel",
|
||||
clawhubSpec: "clawhub:@openclaw/diagnostics-otel",
|
||||
channelIds: ["diagnostics-otel"],
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("does not create a relocation bridge without npm metadata", async () => {
|
||||
it("uses official external catalog metadata when the persisted bundled row lacks npm metadata", async () => {
|
||||
readPersistedInstalledPluginIndexMock.mockResolvedValue(
|
||||
makeIndex({
|
||||
pluginId: "diagnostics-otel",
|
||||
@@ -149,6 +150,37 @@ describe("listPersistedBundledPluginLocationBridges", () => {
|
||||
makeRegistry("diagnostics-otel"),
|
||||
);
|
||||
|
||||
await expect(listPersistedBundledPluginLocationBridges({})).resolves.toEqual([
|
||||
{
|
||||
bundledPluginId: "diagnostics-otel",
|
||||
pluginId: "diagnostics-otel",
|
||||
preferredSource: "npm",
|
||||
npmSpec: "@openclaw/diagnostics-otel",
|
||||
clawhubSpec: "clawhub:@openclaw/diagnostics-otel",
|
||||
channelIds: ["diagnostics-otel"],
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("does not create a relocation bridge without persisted or official install metadata", async () => {
|
||||
readPersistedInstalledPluginIndexMock.mockResolvedValue(
|
||||
makeIndex({
|
||||
pluginId: "local-only",
|
||||
manifestPath: "/app/dist/extensions/local-only/openclaw.plugin.json",
|
||||
manifestHash: "hash",
|
||||
source: "/app/dist/extensions/local-only/index.js",
|
||||
rootDir: "/app/dist/extensions/local-only",
|
||||
origin: "bundled",
|
||||
enabled: true,
|
||||
startup: startupInfo,
|
||||
compat: [],
|
||||
packageInstall: {
|
||||
warnings: [],
|
||||
},
|
||||
}),
|
||||
);
|
||||
loadPluginManifestRegistryForInstalledIndexMock.mockReturnValue(makeRegistry("local-only"));
|
||||
|
||||
await expect(listPersistedBundledPluginLocationBridges({})).resolves.toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,6 +3,11 @@ import { readPersistedInstalledPluginIndex } from "../plugins/installed-plugin-i
|
||||
import type { InstalledPluginIndexRecord } from "../plugins/installed-plugin-index.js";
|
||||
import { loadPluginManifestRegistryForInstalledIndex } from "../plugins/manifest-registry-installed.js";
|
||||
import type { PluginManifestRecord } from "../plugins/manifest-registry.js";
|
||||
import {
|
||||
getOfficialExternalPluginCatalogEntry,
|
||||
getOfficialExternalPluginCatalogManifest,
|
||||
resolveOfficialExternalPluginInstall,
|
||||
} from "../plugins/official-external-plugin-catalog.js";
|
||||
|
||||
function buildBridgeFromPersistedBundledRecord(
|
||||
record: InstalledPluginIndexRecord,
|
||||
@@ -14,17 +19,32 @@ function buildBridgeFromPersistedBundledRecord(
|
||||
if (record.origin !== "bundled" || !record.enabled) {
|
||||
return null;
|
||||
}
|
||||
const npmSpec = record.packageInstall?.npm?.spec;
|
||||
if (!npmSpec) {
|
||||
const officialEntry = getOfficialExternalPluginCatalogEntry(record.pluginId);
|
||||
const officialInstall = officialEntry
|
||||
? resolveOfficialExternalPluginInstall(officialEntry)
|
||||
: null;
|
||||
const npmSpec = officialInstall?.npmSpec?.trim() ?? record.packageInstall?.npm?.spec;
|
||||
const clawhubSpec = officialInstall?.clawhubSpec?.trim();
|
||||
if (!npmSpec && !clawhubSpec) {
|
||||
return null;
|
||||
}
|
||||
const officialChannelId = officialEntry
|
||||
? getOfficialExternalPluginCatalogManifest(officialEntry)?.channel?.id?.trim()
|
||||
: undefined;
|
||||
const channelIds = manifest?.channels.length
|
||||
? manifest.channels
|
||||
: officialChannelId
|
||||
? [officialChannelId]
|
||||
: [];
|
||||
return {
|
||||
bundledPluginId: record.pluginId,
|
||||
pluginId: record.pluginId,
|
||||
preferredSource: "npm",
|
||||
npmSpec,
|
||||
preferredSource:
|
||||
officialInstall?.defaultChoice === "clawhub" && clawhubSpec ? "clawhub" : "npm",
|
||||
...(npmSpec ? { npmSpec } : {}),
|
||||
...(clawhubSpec ? { clawhubSpec } : {}),
|
||||
...(record.enabledByDefault ? { enabledByDefault: true } : {}),
|
||||
...(manifest?.channels.length ? { channelIds: manifest.channels } : {}),
|
||||
...(channelIds.length ? { channelIds } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user