mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 05:20:43 +00:00
fix(plugins): accept clawhub provider index installs
This commit is contained in:
@@ -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",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -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 } : {}),
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user