mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-03 03:03:24 -04:00
refactor(core): dedupe shared config and runtime helpers
This commit is contained in:
@@ -97,3 +97,43 @@ export function resolveOpenClawManifestInstall<T>(
|
||||
export function resolveOpenClawManifestOs(metadataObj: Record<string, unknown>): string[] {
|
||||
return normalizeStringList(metadataObj.os);
|
||||
}
|
||||
|
||||
export type ParsedOpenClawManifestInstallBase = {
|
||||
raw: Record<string, unknown>;
|
||||
kind: string;
|
||||
id?: string;
|
||||
label?: string;
|
||||
bins?: string[];
|
||||
};
|
||||
|
||||
export function parseOpenClawManifestInstallBase(
|
||||
input: unknown,
|
||||
allowedKinds: readonly string[],
|
||||
): ParsedOpenClawManifestInstallBase | undefined {
|
||||
if (!input || typeof input !== "object") {
|
||||
return undefined;
|
||||
}
|
||||
const raw = input as Record<string, unknown>;
|
||||
const kindRaw =
|
||||
typeof raw.kind === "string" ? raw.kind : typeof raw.type === "string" ? raw.type : "";
|
||||
const kind = kindRaw.trim().toLowerCase();
|
||||
if (!allowedKinds.includes(kind)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const spec: ParsedOpenClawManifestInstallBase = {
|
||||
raw,
|
||||
kind,
|
||||
};
|
||||
if (typeof raw.id === "string") {
|
||||
spec.id = raw.id;
|
||||
}
|
||||
if (typeof raw.label === "string") {
|
||||
spec.label = raw.label;
|
||||
}
|
||||
const bins = normalizeStringList(raw.bins);
|
||||
if (bins.length > 0) {
|
||||
spec.bins = bins;
|
||||
}
|
||||
return spec;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user