





























@@ -29,6 +29,7 @@ import {
2929resolvePackageRuntimeExtensionSources,
3030resolvePackageSetupSource,
3131} from "./package-entry-resolution.js";
32+import { shouldRejectHardlinkedPluginFiles } from "./hardlink-policy.js";
3233import { formatPosixMode, isPathInside, safeRealpathSync, safeStatSync } from "./path-safety.js";
3334import { tracePluginLifecyclePhase } from "./plugin-lifecycle-trace.js";
3435import type { PluginOrigin } from "./plugin-origin.types.js";
@@ -571,6 +572,7 @@ function addCandidate(params: {
571572function discoverBundleInRoot(params: {
572573rootDir: string;
573574origin: PluginOrigin;
575+env: NodeJS.ProcessEnv;
574576ownershipUid?: number | null;
575577workspaceDir?: string;
576578manifest?: PackageManifest | null;
@@ -584,11 +586,17 @@ function discoverBundleInRoot(params: {
584586return "none";
585587}
586588const rootRealPath = safeRealpathSync(params.rootDir, params.realpathCache) ?? undefined;
589+const rejectHardlinks = shouldRejectHardlinkedPluginFiles({
590+origin: params.origin,
591+rootDir: params.rootDir,
592+env: params.env,
593+realpathCache: params.realpathCache,
594+});
587595const bundleManifest = loadBundleManifest({
588596rootDir: params.rootDir,
589597 ...(rootRealPath !== undefined ? { rootRealPath } : {}),
590598 bundleFormat,
591-rejectHardlinks: params.origin !== "bundled",
599+ rejectHardlinks,
592600});
593601if (!bundleManifest.ok) {
594602params.diagnostics.push({
@@ -620,6 +628,7 @@ function discoverBundleInRoot(params: {
620628function discoverInDirectory(params: {
621629dir: string;
622630origin: PluginOrigin;
631+env: NodeJS.ProcessEnv;
623632ownershipUid?: number | null;
624633workspaceDir?: string;
625634candidates: PluginCandidate[];
@@ -684,8 +693,13 @@ function discoverInDirectory(params: {
684693continue;
685694}
686695687-const rejectHardlinks = params.origin !== "bundled";
688696const fullPathRealPath = safeRealpathSync(fullPath, params.realpathCache) ?? undefined;
697+const rejectHardlinks = shouldRejectHardlinkedPluginFiles({
698+origin: params.origin,
699+rootDir: fullPath,
700+env: params.env,
701+realpathCache: params.realpathCache,
702+});
689703const manifest = readCandidatePackageManifest({
690704dir: fullPath,
691705origin: params.origin,
@@ -745,6 +759,7 @@ function discoverInDirectory(params: {
745759const bundleDiscovery = discoverBundleInRoot({
746760rootDir: fullPath,
747761origin: params.origin,
762+env: params.env,
748763ownershipUid: params.ownershipUid,
749764workspaceDir: params.workspaceDir,
750765 manifest,
@@ -890,8 +905,13 @@ function discoverFromPath(params: {
890905}
891906892907if (stat.isDirectory()) {
893-const rejectHardlinks = params.origin !== "bundled";
894908const resolvedRealPath = safeRealpathSync(resolved, params.realpathCache) ?? undefined;
909+const rejectHardlinks = shouldRejectHardlinkedPluginFiles({
910+origin: params.origin,
911+rootDir: resolved,
912+env: params.env,
913+realpathCache: params.realpathCache,
914+});
895915const manifest = readCandidatePackageManifest({
896916dir: resolved,
897917origin: params.origin,
@@ -951,6 +971,7 @@ function discoverFromPath(params: {
951971const bundleDiscovery = discoverBundleInRoot({
952972rootDir: resolved,
953973origin: params.origin,
974+env: params.env,
954975ownershipUid: params.ownershipUid,
955976workspaceDir: params.workspaceDir,
956977 manifest,
@@ -989,6 +1010,7 @@ function discoverFromPath(params: {
9891010discoverInDirectory({
9901011dir: resolved,
9911012origin: params.origin,
1013+env: params.env,
9921014ownershipUid: params.ownershipUid,
9931015workspaceDir: params.workspaceDir,
9941016candidates: params.candidates,
@@ -1062,6 +1084,7 @@ export function discoverOpenClawPlugins(params: {
10621084discoverInDirectory({
10631085dir: roots.workspace,
10641086origin: "workspace",
1087+ env,
10651088ownershipUid: params.ownershipUid,
10661089workspaceDir: workspaceRoot,
10671090candidates: result.candidates,
@@ -1114,6 +1137,7 @@ export function discoverOpenClawPlugins(params: {
11141137discoverInDirectory({
11151138dir: roots.stock,
11161139origin: "bundled",
1140+ env,
11171141ownershipUid: params.ownershipUid,
11181142candidates: result.candidates,
11191143diagnostics: result.diagnostics,
@@ -1131,6 +1155,7 @@ export function discoverOpenClawPlugins(params: {
11311155discoverInDirectory({
11321156dir: sourceCheckoutExtensionsDir,
11331157origin: "bundled",
1158+ env,
11341159ownershipUid: params.ownershipUid,
11351160candidates: result.candidates,
11361161diagnostics: result.diagnostics,
@@ -1157,6 +1182,7 @@ export function discoverOpenClawPlugins(params: {
11571182discoverInDirectory({
11581183dir: roots.global,
11591184origin: "global",
1185+ env,
11601186ownershipUid: params.ownershipUid,
11611187candidates: result.candidates,
11621188diagnostics: result.diagnostics,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。