Files
openclaw/scripts/package-source-dependencies.mjs
Peter Steinberger a732513745 fix(cloud-workers): build complete source runtime artifacts (#130735)
* fix(cloud-workers): build complete source runtime artifacts

Allow the canonical package builder to include explicitly selected source runtime plugins with exact target-installed dependencies and regenerated inventory. Preserve concise enrollment prerequisite errors without changing trust or normal core publication.

Fixes #130702. Complete source-built cloud worker packages now retain required runtime plugins; deployment artifacts must be rebuilt from the landed source.

* fix(packaging): reject stale selected plugin peer metadata
2026-08-26 23:54:25 -07:00

42 lines
1.4 KiB
JavaScript

const PRIVATE_WORKSPACE_VERSION = "0.0.0-private";
function dependenciesRecord(value, label) {
if (value === undefined) {
return {};
}
if (typeof value !== "object" || value === null || Array.isArray(value)) {
throw new Error(`${label} dependencies must be an object when present`);
}
return value;
}
export function validateBundledPackageDependencyAlignment({
bundledDependencies,
bundledPackageLabel,
rootDependencies,
rootPackageLabel = "root package.json",
}) {
const bundled = dependenciesRecord(bundledDependencies, bundledPackageLabel);
const root = dependenciesRecord(rootDependencies, rootPackageLabel);
const aligned = [];
for (const [name, version] of Object.entries(bundled)) {
if (typeof version !== "string") {
throw new Error(`${bundledPackageLabel} dependency ${name} must declare a string version`);
}
if (version === PRIVATE_WORKSPACE_VERSION) {
continue;
}
const rootVersion = root[name];
if (rootVersion !== undefined && typeof rootVersion !== "string") {
throw new Error(`${rootPackageLabel} dependency ${name} must declare a string version`);
}
if (rootVersion !== version && rootVersion !== `workspace:${version}`) {
throw new Error(
`${rootPackageLabel} must declare ${name}@${version} to bundle ${bundledPackageLabel} without duplicate dependencies`,
);
}
aligned.push([name, version]);
}
return aligned;
}