Files
openclaw/scripts/lib/optional-bundled-clusters.mjs
Peter Steinberger ed8f50f240 refactor: simplify plugin dependency handling
Simplify plugin installation and runtime loading around package-manager-owned dependencies, with Jiti reserved for local/TS fallback paths.

Also scans npm plugin install roots so hoisted transitive dependencies are covered by dependency denylist and node_modules symlink checks.
2026-05-01 21:32:22 +01:00

51 lines
1.4 KiB
JavaScript

export const optionalBundledClusters = [
"acpx",
"diagnostics-otel",
"diffs",
"googlechat",
"matrix",
"memory-lancedb",
"msteams",
"nostr",
"tlon",
"twitch",
"ui",
"whatsapp",
"zalouser",
];
export const optionalBundledClusterSet = new Set(optionalBundledClusters);
export const OPTIONAL_BUNDLED_BUILD_ENV = "OPENCLAW_INCLUDE_OPTIONAL_BUNDLED";
export function isOptionalBundledCluster(cluster) {
return optionalBundledClusterSet.has(cluster);
}
export function shouldIncludeOptionalBundledClusters(env = process.env) {
// Release artifacts should preserve the last shipped upgrade surface by
// default. Specific size-sensitive lanes can still opt out explicitly.
return env[OPTIONAL_BUNDLED_BUILD_ENV] !== "0";
}
export function hasReleasedBundledInstall(packageJson) {
return (
typeof packageJson?.openclaw?.install?.npmSpec === "string" &&
packageJson.openclaw.install.npmSpec.trim().length > 0
);
}
export function isExplicitlyDownloadablePlugin(packageJson) {
return packageJson?.openclaw?.bundle?.includeInCore === false;
}
export function shouldBuildBundledCluster(cluster, env = process.env, options = {}) {
if (isExplicitlyDownloadablePlugin(options.packageJson)) {
return false;
}
if (hasReleasedBundledInstall(options.packageJson)) {
return true;
}
return shouldIncludeOptionalBundledClusters(env) || !isOptionalBundledCluster(cluster);
}