mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-23 16:01:17 +00:00
fix(plugins): enforce minimum host versions for installable plugins (#52094)
* fix(plugins): enforce min host versions * fix(plugins): tighten min host version validation * chore(plugins): trim dead min host version code * fix(plugins): handle malformed min host metadata * fix(plugins): key manifest cache by host version
This commit is contained in:
@@ -1,12 +1,16 @@
|
||||
import { validateMinHostVersion } from "../../src/plugins/min-host-version.ts";
|
||||
|
||||
function isRecord(value: unknown): value is Record<string, unknown> {
|
||||
return typeof value === "object" && value !== null;
|
||||
}
|
||||
|
||||
export type ExtensionPackageJson = {
|
||||
name?: string;
|
||||
version?: string;
|
||||
dependencies?: Record<string, string>;
|
||||
optionalDependencies?: Record<string, string>;
|
||||
openclaw?: {
|
||||
install?: {
|
||||
npmSpec?: string;
|
||||
};
|
||||
install?: unknown;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -17,14 +21,25 @@ export function collectBundledExtensionManifestErrors(extensions: BundledExtensi
|
||||
|
||||
for (const extension of extensions) {
|
||||
const install = extension.packageJson.openclaw?.install;
|
||||
if (install !== undefined && !isRecord(install)) {
|
||||
errors.push(
|
||||
`bundled extension '${extension.id}' manifest invalid | openclaw.install must be an object`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
const hasNpmSpec = isRecord(install) && "npmSpec" in install;
|
||||
if (
|
||||
install &&
|
||||
hasNpmSpec &&
|
||||
(!install.npmSpec || typeof install.npmSpec !== "string" || !install.npmSpec.trim())
|
||||
) {
|
||||
errors.push(
|
||||
`bundled extension '${extension.id}' manifest invalid | openclaw.install.npmSpec must be a non-empty string`,
|
||||
);
|
||||
}
|
||||
const minHostVersionError = validateMinHostVersion(install?.minHostVersion);
|
||||
if (minHostVersionError) {
|
||||
errors.push(`bundled extension '${extension.id}' manifest invalid | ${minHostVersionError}`);
|
||||
}
|
||||
}
|
||||
|
||||
return errors;
|
||||
|
||||
Reference in New Issue
Block a user