

























@@ -1,6 +1,9 @@
1-import path from "node:path";
21import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../../../agents/agent-scope.js";
32import type { OpenClawConfig } from "../../../config/types.openclaw.js";
3+import {
4+buildBundledPluginLoadPathAliases,
5+normalizeBundledLookupPath,
6+} from "../../../plugins/bundled-load-path-aliases.js";
47import { resolveBundledPluginSources } from "../../../plugins/bundled-sources.js";
58import { sanitizeForLog } from "../../../terminal/ansi.js";
69import { resolveUserPath } from "../../../utils.js";
@@ -17,37 +20,6 @@ function resolveBundledWorkspaceDir(cfg: OpenClawConfig): string | undefined {
1720return resolveAgentWorkspaceDir(cfg, resolveDefaultAgentId(cfg)) ?? undefined;
1821}
192220-function normalizeBundledLookupPath(targetPath: string): string {
21-const normalized = path.normalize(targetPath);
22-const root = path.parse(normalized).root;
23-let trimmed = normalized;
24-while (trimmed.length > root.length && (trimmed.endsWith(path.sep) || trimmed.endsWith("/"))) {
25-trimmed = trimmed.slice(0, -1);
26-}
27-return trimmed;
28-}
29-30-function buildLegacyBundledPath(localPath: string): string | null {
31-const normalized = normalizeBundledLookupPath(localPath);
32-for (const bundledRoot of [
33-path.join("dist", "extensions"),
34-path.join("dist-runtime", "extensions"),
35-]) {
36-const marker = `${bundledRoot}${path.sep}`;
37-const markerIndex = normalized.lastIndexOf(marker);
38-if (markerIndex === -1) {
39-continue;
40-}
41-const packageRoot = normalized.slice(0, markerIndex);
42-const bundledLeaf = normalized.slice(markerIndex + marker.length);
43-if (!bundledLeaf) {
44-continue;
45-}
46-return path.join(packageRoot, "extensions", bundledLeaf);
47-}
48-return null;
49-}
50-5123export function scanBundledPluginLoadPathMigrations(
5224cfg: OpenClawConfig,
5325env: NodeJS.ProcessEnv = process.env,
@@ -67,16 +39,14 @@ export function scanBundledPluginLoadPathMigrations(
6739return [];
6840}
694170-const legacyPathMap = new Map<string, { pluginId: string; toPath: string }>();
42+const bundledPathMap = new Map<string, { pluginId: string; toPath: string }>();
7143for (const source of bundled.values()) {
72-const legacyPath = buildLegacyBundledPath(source.localPath);
73-if (!legacyPath) {
74-continue;
44+for (const alias of buildBundledPluginLoadPathAliases(source.localPath)) {
45+bundledPathMap.set(normalizeBundledLookupPath(alias.path), {
46+pluginId: source.pluginId,
47+toPath: source.localPath,
48+});
7549}
76-legacyPathMap.set(normalizeBundledLookupPath(legacyPath), {
77-pluginId: source.pluginId,
78-toPath: source.localPath,
79-});
8050}
81518252const hits: BundledPluginLoadPathHit[] = [];
@@ -85,7 +55,7 @@ export function scanBundledPluginLoadPathMigrations(
8555continue;
8656}
8757const normalized = normalizeBundledLookupPath(resolveUserPath(rawPath, env));
88-const match = legacyPathMap.get(normalized);
58+const match = bundledPathMap.get(normalized);
8959if (!match) {
9060continue;
9161}
@@ -109,9 +79,9 @@ export function collectBundledPluginLoadPathWarnings(params: {
10979}
11080const lines = params.hits.map(
11181(hit) =>
112-`- ${hit.pathLabel}: legacy bundled plugin path "${hit.fromPath}" still points at ${hit.pluginId}; current packaged path is "${hit.toPath}".`,
82+`- ${hit.pathLabel}: bundled plugin path "${hit.fromPath}" still aliases ${hit.pluginId}; OpenClaw loads the packaged bundled plugin from "${hit.toPath}".`,
11383);
114-lines.push(`- Run "${params.doctorFixCommand}" to rewrite these bundled plugin paths.`);
84+lines.push(`- Run "${params.doctorFixCommand}" to remove these redundant bundled plugin paths.`);
11585return lines.map((line) => sanitizeForLog(line));
11686}
11787@@ -133,8 +103,8 @@ export function maybeRepairBundledPluginLoadPaths(
133103return { config: cfg, changes: [] };
134104}
135105136-const replacements = new Map(
137-hits.map((hit) => [normalizeBundledLookupPath(resolveUserPath(hit.fromPath, env)), hit]),
106+const removable = new Set(
107+hits.map((hit) => normalizeBundledLookupPath(resolveUserPath(hit.fromPath, env))),
138108);
139109const seen = new Set<string>();
140110const rewritten: Array<(typeof paths)[number]> = [];
@@ -144,13 +114,14 @@ export function maybeRepairBundledPluginLoadPaths(
144114continue;
145115}
146116const resolved = normalizeBundledLookupPath(resolveUserPath(entry, env));
147-const replacement = replacements.get(resolved)?.toPath ?? entry;
148-const replacementResolved = normalizeBundledLookupPath(resolveUserPath(replacement, env));
149-if (seen.has(replacementResolved)) {
117+if (removable.has(resolved)) {
118+continue;
119+}
120+if (seen.has(resolved)) {
150121continue;
151122}
152-seen.add(replacementResolved);
153-rewritten.push(replacement);
123+seen.add(resolved);
124+rewritten.push(entry);
154125}
155126156127next.plugins = {
@@ -164,8 +135,7 @@ export function maybeRepairBundledPluginLoadPaths(
164135return {
165136config: next,
166137changes: hits.map(
167-(hit) =>
168-`- plugins.load.paths: rewrote bundled ${hit.pluginId} path from ${hit.fromPath} to ${hit.toPath}`,
138+(hit) => `- plugins.load.paths: removed bundled ${hit.pluginId} path alias ${hit.fromPath}`,
169139),
170140};
171141}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。