




















@@ -5,6 +5,7 @@ import {
55existsSync,
66mkdtempSync,
77mkdirSync,
8+realpathSync,
89readdirSync,
910readFileSync,
1011rmSync,
@@ -17,6 +18,10 @@ import {
1718PACKAGE_DIST_INVENTORY_RELATIVE_PATH,
1819writePackageDistInventory,
1920} from "../src/infra/package-dist-inventory.ts";
21+import {
22+resolveBundledRuntimeDependencyInstallRoot,
23+resolveBundledRuntimeDependencyPackageInstallRoot,
24+} from "../src/plugins/bundled-runtime-deps.ts";
2025import {
2126collectBundledExtensionManifestErrors,
2227type BundledExtension,
@@ -317,28 +322,48 @@ function bundledRuntimeDependencySentinelPath(
317322);
318323}
319324320-function bundledRuntimeDependencySentinelCandidates(
325+export function bundledRuntimeDependencySentinelCandidates(
321326packageRoot: string,
322327pluginId: string,
323328dependencyName: string,
329+env: NodeJS.ProcessEnv = process.env,
324330): string[] {
325331const dependencyParts = dependencyName.split("/");
332+const packageRoots = [
333+packageRoot,
334+(() => {
335+try {
336+return realpathSync(packageRoot);
337+} catch {
338+return packageRoot;
339+}
340+})(),
341+];
342+const runtimeRoots = packageRoots.flatMap((root) => [
343+resolveBundledRuntimeDependencyPackageInstallRoot(root, { env }),
344+resolveBundledRuntimeDependencyInstallRoot(join(root, "dist", "extensions", pluginId), {
345+ env,
346+}),
347+]);
326348return [
327349bundledRuntimeDependencySentinelPath(packageRoot, pluginId, dependencyName),
328350join(packageRoot, "dist", "extensions", "node_modules", ...dependencyParts, "package.json"),
329351join(packageRoot, "node_modules", ...dependencyParts, "package.json"),
330-];
352+ ...runtimeRoots.map((root) => join(root, "node_modules", ...dependencyParts, "package.json")),
353+].filter((candidate, index, candidates) => candidates.indexOf(candidate) === index);
331354}
332355333356function assertBundledRuntimeDependencyAbsent(params: {
334357packageRoot: string;
335358pluginId: string;
336359dependencyName: string;
360+env?: NodeJS.ProcessEnv;
337361}): void {
338362const sentinelPath = bundledRuntimeDependencySentinelCandidates(
339363params.packageRoot,
340364params.pluginId,
341365params.dependencyName,
366+params.env,
342367).find((candidate) => existsSync(candidate));
343368if (sentinelPath) {
344369throw new Error(
@@ -351,11 +376,13 @@ function assertBundledRuntimeDependencyPresent(params: {
351376packageRoot: string;
352377pluginId: string;
353378dependencyName: string;
379+env?: NodeJS.ProcessEnv;
354380}): void {
355381const sentinelPath = bundledRuntimeDependencySentinelCandidates(
356382params.packageRoot,
357383params.pluginId,
358384params.dependencyName,
385+params.env,
359386).find((candidate) => existsSync(candidate));
360387if (sentinelPath) {
361388return;
@@ -413,24 +440,25 @@ function runPackedBundledPluginActivationSmoke(packageRoot: string, tmpRoot: str
413440{ pluginId: "feishu", dependencyName: "@larksuiteoapi/node-sdk" },
414441] as const;
415442443+const homeDir = join(tmpRoot, "activation-home");
444+mkdirSync(homeDir, { recursive: true });
445+const env = createPackedCliSmokeEnv(process.env, {
446+HOME: homeDir,
447+OPENAI_API_KEY: "sk-openclaw-release-check",
448+});
416449for (const dep of lazyDeps) {
417-assertBundledRuntimeDependencyAbsent({ packageRoot, ...dep });
450+assertBundledRuntimeDependencyAbsent({ packageRoot, env, ...dep });
418451}
419452420-const homeDir = join(tmpRoot, "activation-home");
421-mkdirSync(homeDir, { recursive: true });
422453writePackedBundledPluginActivationConfig(homeDir);
423454execFileSync(process.execPath, [join(packageRoot, "openclaw.mjs"), "plugins", "doctor"], {
424455cwd: packageRoot,
425456stdio: "inherit",
426-env: createPackedCliSmokeEnv(process.env, {
427-HOME: homeDir,
428-OPENAI_API_KEY: "sk-openclaw-release-check",
429-}),
457+ env,
430458});
431459432460for (const dep of lazyDeps) {
433-assertBundledRuntimeDependencyPresent({ packageRoot, ...dep });
461+assertBundledRuntimeDependencyPresent({ packageRoot, env, ...dep });
434462}
435463}
436464此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。