mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 08:30:42 +00:00
fix(plugins): derive bundled relocation from registry
This commit is contained in:
35
src/cli/plugins-location-bridges.ts
Normal file
35
src/cli/plugins-location-bridges.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import type { ExternalizedBundledPluginBridge } from "../plugins/externalized-bundled-plugins.js";
|
||||
import { readPersistedInstalledPluginIndex } from "../plugins/installed-plugin-index-store.js";
|
||||
import type { InstalledPluginIndexRecord } from "../plugins/installed-plugin-index.js";
|
||||
|
||||
function buildBridgeFromPersistedBundledRecord(
|
||||
record: InstalledPluginIndexRecord,
|
||||
): ExternalizedBundledPluginBridge | null {
|
||||
if (record.origin !== "bundled" || record.enabled === false) {
|
||||
return null;
|
||||
}
|
||||
const npmSpec = record.packageInstall?.npm?.spec;
|
||||
if (!npmSpec) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
bundledPluginId: record.pluginId,
|
||||
pluginId: record.pluginId,
|
||||
npmSpec,
|
||||
channelIds: record.contributions.channels,
|
||||
};
|
||||
}
|
||||
|
||||
export async function listPersistedBundledPluginLocationBridges(options: {
|
||||
workspaceDir?: string;
|
||||
env?: NodeJS.ProcessEnv;
|
||||
}): Promise<readonly ExternalizedBundledPluginBridge[]> {
|
||||
const index = await readPersistedInstalledPluginIndex(options);
|
||||
if (!index) {
|
||||
return [];
|
||||
}
|
||||
return index.plugins.flatMap((record) => {
|
||||
const bridge = buildBridgeFromPersistedBundledRecord(record);
|
||||
return bridge ? [bridge] : [];
|
||||
});
|
||||
}
|
||||
@@ -57,6 +57,7 @@ import {
|
||||
terminateStaleGatewayPids,
|
||||
waitForGatewayHealthyRestart,
|
||||
} from "../daemon-cli/restart-health.js";
|
||||
import { listPersistedBundledPluginLocationBridges } from "../plugins-location-bridges.js";
|
||||
import { refreshPluginRegistryAfterConfigMutation } from "../plugins-registry-refresh.js";
|
||||
import { createUpdateProgress, printResult } from "./progress.js";
|
||||
import { prepareRestartScript, runRestartScript } from "./restart-helper.js";
|
||||
@@ -580,6 +581,9 @@ async function updatePluginsAfterCoreUpdate(params: {
|
||||
config: params.configSnapshot.sourceConfig,
|
||||
channel: params.channel,
|
||||
workspaceDir: params.root,
|
||||
externalizedBundledPluginBridges: await listPersistedBundledPluginLocationBridges({
|
||||
workspaceDir: params.root,
|
||||
}),
|
||||
logger: pluginLogger,
|
||||
});
|
||||
let pluginConfig = syncResult.config;
|
||||
|
||||
@@ -15,25 +15,6 @@ export type ExternalizedBundledPluginBridge = {
|
||||
preferOver?: readonly string[];
|
||||
};
|
||||
|
||||
const EXTERNALIZED_BUNDLED_PLUGIN_BRIDGES: readonly ExternalizedBundledPluginBridge[] = [
|
||||
{
|
||||
bundledPluginId: "tlon",
|
||||
npmSpec: "@openclaw/tlon",
|
||||
channelIds: ["tlon"],
|
||||
},
|
||||
{
|
||||
bundledPluginId: "twitch",
|
||||
npmSpec: "@openclaw/twitch",
|
||||
channelIds: ["twitch", "twitch-chat"],
|
||||
legacyPluginIds: ["twitch-chat"],
|
||||
},
|
||||
{
|
||||
bundledPluginId: "synology-chat",
|
||||
npmSpec: "@openclaw/synology-chat",
|
||||
channelIds: ["synology-chat"],
|
||||
},
|
||||
];
|
||||
|
||||
function normalizePluginId(value: string | undefined): string {
|
||||
return value?.trim() ?? "";
|
||||
}
|
||||
@@ -60,7 +41,3 @@ export function getExternalizedBundledPluginLookupIds(
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export function listExternalizedBundledPluginBridges(): readonly ExternalizedBundledPluginBridge[] {
|
||||
return EXTERNALIZED_BUNDLED_PLUGIN_BRIDGES;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ import { normalizePluginsConfig, resolveEffectiveEnableState } from "./config-st
|
||||
import {
|
||||
getExternalizedBundledPluginLookupIds,
|
||||
getExternalizedBundledPluginTargetId,
|
||||
listExternalizedBundledPluginBridges,
|
||||
type ExternalizedBundledPluginBridge,
|
||||
} from "./externalized-bundled-plugins.js";
|
||||
import {
|
||||
@@ -863,8 +862,7 @@ export async function syncPluginsForUpdateChannel(params: {
|
||||
changed = true;
|
||||
}
|
||||
} else {
|
||||
const bridges =
|
||||
params.externalizedBundledPluginBridges ?? listExternalizedBundledPluginBridges();
|
||||
const bridges = params.externalizedBundledPluginBridges ?? [];
|
||||
for (const bridge of bridges) {
|
||||
const targetPluginId = getExternalizedBundledPluginTargetId(bridge);
|
||||
const bundledInfo = bundled.get(bridge.bundledPluginId);
|
||||
|
||||
Reference in New Issue
Block a user