mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-24 19:35:28 -06:00
98e3f729bc
* refactor(plugins): trim activation and contract exports * test(plugins): restore fixture cleanup * refactor(plugins): trim install and loader exports * test(plugins): fully reset loader caches * refactor(plugins): trim metadata and catalog exports * test(plugins): preserve catalog trust coverage * refactor(plugins): trim provider and plugin exports * refactor(plugins): trim runtime and tool exports * test(plugins): update dead-export consumers * test(plugins): remove empty dead-export suites * refactor(plugins): align exports with split registry * refactor(plugins): trim drifted loader exports * style(plugins): format test fixtures * refactor(scripts): use supported plugin APIs * refactor(plugins): finish dead export cleanup * chore(deadcode): refresh export baseline * test(cli): mock production memory state * chore(deadcode): sync latest export baseline * fix(tests): keep plugin fixtures inside core * chore(deadcode): refresh rebased export baseline * chore(deadcode): sync current ratchets * fix(plugins): retain reserved slot invariant * fix(plugins): preserve dead-export invariants * test(plugins): use neutral catalog query fixture * test(plugins): satisfy catalog lint * test(plugins): preserve integrity drift coverage * fix(ci): register skill experience live proof
40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
// Checks package compatibility metadata for plugin manifests.
|
|
import { isRecord } from "@openclaw/normalization-core/record-coerce";
|
|
|
|
/** Result of reading package.json openclaw.compat.pluginApi metadata. */
|
|
type PackagePluginApiRangeResult = { ok: true; range?: string } | { ok: false; error: string };
|
|
|
|
/** Resolves the plugin API compatibility range declared by package metadata. */
|
|
export function resolvePackagePluginApiRange(
|
|
packageMetadata: unknown,
|
|
): PackagePluginApiRangeResult {
|
|
if (packageMetadata === undefined || packageMetadata === null) {
|
|
return { ok: true };
|
|
}
|
|
if (!isRecord(packageMetadata)) {
|
|
return { ok: true };
|
|
}
|
|
if (!("compat" in packageMetadata)) {
|
|
return { ok: true };
|
|
}
|
|
const compat = packageMetadata.compat;
|
|
if (compat === undefined || compat === null) {
|
|
return { ok: true };
|
|
}
|
|
if (!isRecord(compat)) {
|
|
return { ok: false, error: "package.json openclaw.compat must be an object" };
|
|
}
|
|
if (!("pluginApi" in compat)) {
|
|
return { ok: true };
|
|
}
|
|
const pluginApi = compat.pluginApi;
|
|
if (typeof pluginApi !== "string") {
|
|
return { ok: false, error: "package.json openclaw.compat.pluginApi must be a string" };
|
|
}
|
|
const range = pluginApi.trim();
|
|
if (!range) {
|
|
return { ok: false, error: "package.json openclaw.compat.pluginApi must not be empty" };
|
|
}
|
|
return { ok: true, range };
|
|
}
|