























@@ -68,7 +68,7 @@ import {
6868type NormalizedPluginsConfig,
6969type PluginActivationState,
7070} from "./config-state.js";
71-import { discoverOpenClawPlugins } from "./discovery.js";
71+import { discoverOpenClawPlugins, type PluginCandidate } from "./discovery.js";
7272import { getGlobalHookRunner, initializeGlobalHookRunner } from "./hook-runner-global.js";
7373import { toSafeImportPath } from "./import-specifier.js";
7474import { loadInstalledPluginIndexInstallRecordsSync } from "./installed-plugin-index-records.js";
@@ -79,7 +79,11 @@ import {
7979} from "./interactive-registry.js";
8080import { getCachedPluginJitiLoader, type PluginJitiLoaderCache } from "./jiti-loader-cache.js";
8181import { PluginLoaderCacheState } from "./loader-cache-state.js";
82-import { loadPluginManifestRegistry, type PluginManifestRecord } from "./manifest-registry.js";
82+import {
83+loadPluginManifestRegistry,
84+type PluginManifestRecord,
85+type PluginManifestRegistry,
86+} from "./manifest-registry.js";
8387import type { PluginBundleFormat, PluginDiagnostic, PluginFormat } from "./manifest-types.js";
8488import type { PluginManifestContracts } from "./manifest.js";
8589import {
@@ -173,6 +177,7 @@ export type PluginLoadOptions = {
173177installBundledRuntimeDeps?: boolean;
174178throwOnLoadError?: boolean;
175179bundledRuntimeDepsInstaller?: (params: BundledRuntimeDepsInstallParams) => void;
180+manifestRegistry?: PluginManifestRegistry;
176181};
177182178183const CLI_METADATA_ENTRY_BASENAMES = [
@@ -253,6 +258,20 @@ const LAZY_RUNTIME_REFLECTION_KEYS = [
253258"modelAuth",
254259] as const satisfies readonly (keyof PluginRuntime)[];
255260261+function createPluginCandidatesFromManifestRegistry(
262+manifestRegistry: PluginManifestRegistry,
263+): PluginCandidate[] {
264+return manifestRegistry.plugins.map((record) => ({
265+idHint: record.id,
266+rootDir: record.rootDir,
267+source: record.source,
268+origin: record.origin,
269+ ...(record.workspaceDir !== undefined ? { workspaceDir: record.workspaceDir } : {}),
270+ ...(record.format !== undefined ? { format: record.format } : {}),
271+ ...(record.bundleFormat !== undefined ? { bundleFormat: record.bundleFormat } : {}),
272+}));
273+}
274+256275export function clearPluginLoaderCache(): void {
257276pluginLoaderCacheState.clear();
258277clearBundledRuntimeDependencyNodePaths();
@@ -2311,21 +2330,29 @@ export function loadOpenClawPlugins(options: PluginLoadOptions = {}): PluginRegi
23112330activateGlobalSideEffects: shouldActivate,
23122331});
231323322314-const discovery = discoverOpenClawPlugins({
2315-workspaceDir: options.workspaceDir,
2316-extraPaths: normalized.loadPaths,
2317-cache: options.cache,
2318- env,
2319-});
2320-const manifestRegistry = loadPluginManifestRegistry({
2321-config: cfg,
2322-workspaceDir: options.workspaceDir,
2323-cache: options.cache,
2324- env,
2325-candidates: discovery.candidates,
2326-diagnostics: discovery.diagnostics,
2327-installRecords: Object.keys(installRecords).length > 0 ? installRecords : undefined,
2328-});
2333+const suppliedManifestRegistry = options.manifestRegistry;
2334+const discovery = suppliedManifestRegistry
2335+ ? {
2336+candidates: createPluginCandidatesFromManifestRegistry(suppliedManifestRegistry),
2337+diagnostics: [] as PluginDiagnostic[],
2338+}
2339+ : discoverOpenClawPlugins({
2340+workspaceDir: options.workspaceDir,
2341+extraPaths: normalized.loadPaths,
2342+cache: options.cache,
2343+ env,
2344+});
2345+const manifestRegistry =
2346+suppliedManifestRegistry ??
2347+loadPluginManifestRegistry({
2348+config: cfg,
2349+workspaceDir: options.workspaceDir,
2350+cache: options.cache,
2351+ env,
2352+candidates: discovery.candidates,
2353+diagnostics: discovery.diagnostics,
2354+installRecords: Object.keys(installRecords).length > 0 ? installRecords : undefined,
2355+});
23292356pushDiagnostics(registry.diagnostics, manifestRegistry.diagnostics);
23302357warnWhenAllowlistIsOpen({
23312358emitWarning: shouldActivate,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。