fix(plugins): accept clawhub provider index installs

This commit is contained in:
Vincent Koc
2026-05-02 07:24:10 -07:00
parent 11daaad3d0
commit dda2db97d4
3 changed files with 20 additions and 8 deletions

View File

@@ -13,8 +13,9 @@ describe("OpenClaw provider index", () => {
id: "moonshot",
package: " @openclaw/plugin-moonshot ",
install: {
clawhubSpec: " clawhub:openclaw/moonshot@2026.5.2 ",
npmSpec: " @openclaw/plugin-moonshot@1.2.3 ",
defaultChoice: "npm",
defaultChoice: "clawhub",
expectedIntegrity: " sha512-moonshot ",
},
},
@@ -63,8 +64,9 @@ describe("OpenClaw provider index", () => {
id: "moonshot",
package: "@openclaw/plugin-moonshot",
install: {
clawhubSpec: "clawhub:openclaw/moonshot@2026.5.2",
npmSpec: "@openclaw/plugin-moonshot@1.2.3",
defaultChoice: "npm",
defaultChoice: "clawhub",
expectedIntegrity: "sha512-moonshot",
},
},

View File

@@ -1,3 +1,4 @@
import { parseClawHubPluginSpec } from "../../infra/clawhub-spec.js";
import { parseRegistryNpmSpec } from "../../infra/npm-registry-spec.js";
import { isBlockedObjectKey } from "../../infra/prototype-keys.js";
import { normalizeOptionalString } from "../../shared/string-coerce.js";
@@ -25,16 +26,24 @@ function normalizeInstall(value: unknown): OpenClawProviderIndexPluginInstall |
if (!isRecord(value)) {
return undefined;
}
const clawhubSpec = normalizeOptionalString(value.clawhubSpec);
const parsedClawHub = clawhubSpec ? parseClawHubPluginSpec(clawhubSpec) : null;
const npmSpec = normalizeOptionalString(value.npmSpec);
const parsed = npmSpec ? parseRegistryNpmSpec(npmSpec) : null;
if (!parsed) {
const parsedNpm = npmSpec ? parseRegistryNpmSpec(npmSpec) : null;
if (!parsedClawHub && !parsedNpm) {
return undefined;
}
const defaultChoice = value.defaultChoice === "npm" ? "npm" : undefined;
const defaultChoice =
value.defaultChoice === "clawhub" && parsedClawHub
? "clawhub"
: value.defaultChoice === "npm" && parsedNpm
? "npm"
: undefined;
const minHostVersion = normalizeOptionalString(value.minHostVersion);
const expectedIntegrity = normalizeOptionalString(value.expectedIntegrity);
return {
npmSpec: parsed.raw,
...(parsedClawHub ? { clawhubSpec } : {}),
...(parsedNpm ? { npmSpec: parsedNpm.raw } : {}),
...(defaultChoice ? { defaultChoice } : {}),
...(minHostVersion ? { minHostVersion } : {}),
...(expectedIntegrity ? { expectedIntegrity } : {}),

View File

@@ -1,8 +1,9 @@
import type { ModelCatalogProvider } from "../types.js";
export type OpenClawProviderIndexPluginInstall = {
npmSpec: string;
defaultChoice?: "npm";
clawhubSpec?: string;
npmSpec?: string;
defaultChoice?: "clawhub" | "npm";
minHostVersion?: string;
expectedIntegrity?: string;
};