refactor: clean up ClawHub compatibility validation

This commit is contained in:
Peter Steinberger
2026-03-23 18:51:06 -07:00
parent 9dd0530b97
commit 85ed1a8986
4 changed files with 24 additions and 35 deletions

View File

@@ -77,6 +77,8 @@ describe("clawhub helpers", () => {
expect(satisfiesPluginApiRange("1.9.0", ">=1.2.0 <2.0.0")).toBe(true);
expect(satisfiesPluginApiRange("2.0.0", "^1.2.0")).toBe(false);
expect(satisfiesPluginApiRange("1.1.9", ">=1.2.0")).toBe(false);
expect(satisfiesPluginApiRange("2026.3.22", ">=2026.3.22")).toBe(true);
expect(satisfiesPluginApiRange("2026.3.21", ">=2026.3.22")).toBe(false);
expect(satisfiesPluginApiRange("invalid", "^1.2.0")).toBe(false);
});

View File

@@ -9,6 +9,11 @@ const DEFAULT_FETCH_TIMEOUT_MS = 30_000;
export type ClawHubPackageFamily = "skill" | "code-plugin" | "bundle-plugin";
export type ClawHubPackageChannel = "official" | "community" | "private";
export type ClawHubPackageCompatibility = {
pluginApiRange?: string;
builtWithOpenClawVersion?: string;
minGatewayVersion?: string;
};
export type ClawHubPackageListItem = {
name: string;
@@ -31,11 +36,7 @@ export type ClawHubPackageDetail = {
package:
| (ClawHubPackageListItem & {
tags?: Record<string, string>;
compatibility?: {
pluginApiRange?: string;
builtWithOpenClawVersion?: string;
minGatewayVersion?: string;
} | null;
compatibility?: ClawHubPackageCompatibility | null;
capabilities?: {
executesCode?: boolean;
runtimeId?: string;
@@ -78,11 +79,7 @@ export type ClawHubPackageVersion = {
changelog: string;
distTags?: string[];
files?: unknown;
compatibility?: ClawHubPackageDetail["package"] extends infer T
? T extends { compatibility?: infer C }
? C
: never
: never;
compatibility?: ClawHubPackageCompatibility | null;
capabilities?: ClawHubPackageDetail["package"] extends infer T
? T extends { capabilities?: infer C }
? C