fix: restore ci gates on main

This commit is contained in:
Peter Steinberger
2026-04-28 19:42:50 +01:00
parent bb0461b682
commit f2f34e5f35
11 changed files with 136 additions and 35 deletions

View File

@@ -203,6 +203,23 @@ describe("resolveBundledRuntimeDepsNpmRunner", () => {
});
});
it("uses the Node-adjacent POSIX npm shim when npm-cli.js is unavailable", () => {
const execPath = "/opt/node/bin/node";
const npmPath = "/opt/node/bin/npm";
const runner = resolveBundledRuntimeDepsNpmRunner({
env: {},
execPath,
existsSync: (candidate) => candidate === npmPath,
npmArgs: ["install", "acpx@0.5.3"],
platform: "linux",
});
expect(runner).toEqual({
command: npmPath,
args: ["install", "acpx@0.5.3"],
});
});
it("refuses Windows shell fallback when no safe npm executable is available", () => {
expect(() =>
resolveBundledRuntimeDepsNpmRunner({
@@ -222,7 +239,7 @@ describe("resolveBundledRuntimeDepsNpmRunner", () => {
PATH: "/repo/evil/bin:/usr/bin:/bin",
},
execPath: "/opt/node/bin/node",
existsSync: (candidate) => candidate === "/opt/node/bin/npm",
existsSync: (candidate) => candidate === "/usr/bin/npm",
npmArgs: ["install"],
platform: "linux",
}),

View File

@@ -1325,6 +1325,14 @@ export function resolveBundledRuntimeDepsNpmRunner(params: {
throw new Error("Unable to resolve a safe npm executable on Windows");
}
const npmExePath = pathImpl.resolve(nodeDir, "npm");
if (existsSync(npmExePath)) {
return {
command: npmExePath,
args: params.npmArgs,
};
}
throw new Error("Unable to resolve a safe npm executable");
}
type BundledPluginRuntimeDepsManifest = {

View File

@@ -45,6 +45,7 @@ function collectBundledChannelOwnerPluginIds(params: {
config: OpenClawConfig;
channelIds: readonly string[];
env: NodeJS.ProcessEnv;
bundledPluginsDir?: string;
}): string[] {
const plugins = normalizePluginsConfig(params.config.plugins);
const channelIds = new Set(
@@ -55,7 +56,7 @@ function collectBundledChannelOwnerPluginIds(params: {
if (channelIds.size === 0) {
return [];
}
const bundledDir = resolveBundledPluginsDir(params.env);
const bundledDir = params.bundledPluginsDir ?? resolveBundledPluginsDir(params.env);
if (!bundledDir) {
return [];
}
@@ -126,6 +127,7 @@ export function resolveEffectivePluginIds(params: {
config: OpenClawConfig;
env: NodeJS.ProcessEnv;
workspaceDir?: string;
bundledPluginsDir?: string;
}): string[] {
const autoEnabled = applyPluginAutoEnable({
config: params.config,
@@ -150,6 +152,7 @@ export function resolveEffectivePluginIds(params: {
config: effectiveConfig,
channelIds: configuredChannelIds,
env: params.env,
...(params.bundledPluginsDir ? { bundledPluginsDir: params.bundledPluginsDir } : {}),
})) {
ids.add(pluginId);
}