



























@@ -1,6 +1,7 @@
11import fs from "node:fs";
22import path from "node:path";
33import type { OpenClawConfig } from "../config/types.js";
4+import type { PluginInstallRecord } from "../config/types.plugins.js";
45import { isBlockedObjectKey } from "../infra/prototype-keys.js";
56import {
67normalizeOptionalLowercaseString,
@@ -534,11 +535,12 @@ function matchesInstalledPluginRecord(params: {
534535candidate: PluginCandidate;
535536config?: OpenClawConfig;
536537env: NodeJS.ProcessEnv;
538+installRecords: Record<string, PluginInstallRecord>;
537539}): boolean {
538540if (params.candidate.origin !== "global") {
539541return false;
540542}
541-const record = loadInstalledPluginIndexInstallRecordsSync({ env: params.env })[params.pluginId];
543+const record = params.installRecords[params.pluginId];
542544if (!record) {
543545return false;
544546}
@@ -559,6 +561,7 @@ function resolveDuplicatePrecedenceRank(params: {
559561candidate: PluginCandidate;
560562config?: OpenClawConfig;
561563env: NodeJS.ProcessEnv;
564+installRecords: Record<string, PluginInstallRecord>;
562565}): number {
563566if (params.candidate.origin === "config") {
564567return 0;
@@ -570,6 +573,7 @@ function resolveDuplicatePrecedenceRank(params: {
570573candidate: params.candidate,
571574config: params.config,
572575env: params.env,
576+installRecords: params.installRecords,
573577})
574578) {
575579return 1;
@@ -592,13 +596,15 @@ export function loadPluginManifestRegistry(
592596env?: NodeJS.ProcessEnv;
593597candidates?: PluginCandidate[];
594598diagnostics?: PluginDiagnostic[];
599+installRecords?: Record<string, PluginInstallRecord>;
595600} = {},
596601): PluginManifestRegistry {
597602const config = params.config ?? {};
598603const normalized = normalizePluginsConfigWithResolver(config.plugins);
599604const env = params.env ?? process.env;
600605const cacheKey = buildCacheKey({ workspaceDir: params.workspaceDir, plugins: normalized, env });
601-const cacheEnabled = params.cache !== false && shouldUseManifestCache(env);
606+const cacheEnabled =
607+params.cache !== false && !params.installRecords && shouldUseManifestCache(env);
602608if (cacheEnabled) {
603609const cached = registryCache.get(cacheKey);
604610if (cached && cached.expiresAt > Date.now()) {
@@ -623,6 +629,15 @@ export function loadPluginManifestRegistry(
623629const seenIds = new Map<string, SeenIdEntry>();
624630const realpathCache = new Map<string, string>();
625631const currentHostVersion = resolveCompatibilityHostVersion(env);
632+let installRecords = params.installRecords;
633+let installRecordsLoaded = Boolean(params.installRecords);
634+const getInstallRecords = (): Record<string, PluginInstallRecord> => {
635+if (!installRecordsLoaded) {
636+installRecords = loadInstalledPluginIndexInstallRecordsSync({ env });
637+installRecordsLoaded = true;
638+}
639+return installRecords ?? {};
640+};
626641627642for (const candidate of candidates) {
628643const rejectHardlinks = candidate.origin !== "bundled";
@@ -731,12 +746,14 @@ export function loadPluginManifestRegistry(
731746 candidate,
732747 config,
733748 env,
749+installRecords: getInstallRecords(),
734750});
735751const existingRank = resolveDuplicatePrecedenceRank({
736752pluginId: manifest.id,
737753candidate: existing.candidate,
738754 config,
739755 env,
756+installRecords: getInstallRecords(),
740757});
741758const candidateWins = candidateRank < existingRank;
742759const winnerCandidate = candidateWins ? candidate : existing.candidate;
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。