mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 00:20:43 +00:00
Simplify plugin installation and runtime loading around package-manager-owned dependencies, with Jiti reserved for local/TS fallback paths. Also scans npm plugin install roots so hoisted transitive dependencies are covered by dependency denylist and node_modules symlink checks.
46 lines
1.6 KiB
TypeScript
46 lines
1.6 KiB
TypeScript
import { normalizePluginsConfig } from "./config-state.js";
|
|
import { discoverOpenClawPlugins, type PluginCandidate } from "./discovery.js";
|
|
import { loadInstalledPluginIndexInstallRecordsSync } from "./installed-plugin-index-record-reader.js";
|
|
import type { LoadInstalledPluginIndexParams } from "./installed-plugin-index-types.js";
|
|
import { loadPluginManifestRegistry, type PluginManifestRegistry } from "./manifest-registry.js";
|
|
|
|
export function resolveInstalledPluginIndexRegistry(params: LoadInstalledPluginIndexParams): {
|
|
registry: PluginManifestRegistry;
|
|
candidates: readonly PluginCandidate[];
|
|
} {
|
|
if (params.candidates) {
|
|
return {
|
|
candidates: params.candidates,
|
|
registry: loadPluginManifestRegistry({
|
|
config: params.config,
|
|
workspaceDir: params.workspaceDir,
|
|
env: params.env,
|
|
candidates: params.candidates,
|
|
diagnostics: params.diagnostics,
|
|
installRecords: params.installRecords,
|
|
}),
|
|
};
|
|
}
|
|
|
|
const normalized = normalizePluginsConfig(params.config?.plugins);
|
|
const installRecords =
|
|
params.installRecords ?? loadInstalledPluginIndexInstallRecordsSync({ env: params.env });
|
|
const discovery = discoverOpenClawPlugins({
|
|
workspaceDir: params.workspaceDir,
|
|
extraPaths: normalized.loadPaths,
|
|
env: params.env,
|
|
installRecords,
|
|
});
|
|
return {
|
|
candidates: discovery.candidates,
|
|
registry: loadPluginManifestRegistry({
|
|
config: params.config,
|
|
workspaceDir: params.workspaceDir,
|
|
env: params.env,
|
|
candidates: discovery.candidates,
|
|
diagnostics: discovery.diagnostics,
|
|
installRecords,
|
|
}),
|
|
};
|
|
}
|