Skip to content

Commit dda2db9

Browse files
committed
fix(plugins): accept clawhub provider index installs
1 parent 11daaad commit dda2db9

3 files changed

Lines changed: 20 additions & 8 deletions

File tree

src/model-catalog/provider-index/normalize.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ describe("OpenClaw provider index", () => {
1313
id: "moonshot",
1414
package: " @openclaw/plugin-moonshot ",
1515
install: {
16+
clawhubSpec: " clawhub:openclaw/moonshot@2026.5.2 ",
1617
npmSpec: " @openclaw/plugin-moonshot@1.2.3 ",
17-
defaultChoice: "npm",
18+
defaultChoice: "clawhub",
1819
expectedIntegrity: " sha512-moonshot ",
1920
},
2021
},
@@ -63,8 +64,9 @@ describe("OpenClaw provider index", () => {
6364
id: "moonshot",
6465
package: "@openclaw/plugin-moonshot",
6566
install: {
67+
clawhubSpec: "clawhub:openclaw/moonshot@2026.5.2",
6668
npmSpec: "@openclaw/plugin-moonshot@1.2.3",
67-
defaultChoice: "npm",
69+
defaultChoice: "clawhub",
6870
expectedIntegrity: "sha512-moonshot",
6971
},
7072
},

src/model-catalog/provider-index/normalize.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { parseClawHubPluginSpec } from "../../infra/clawhub-spec.js";
12
import { parseRegistryNpmSpec } from "../../infra/npm-registry-spec.js";
23
import { isBlockedObjectKey } from "../../infra/prototype-keys.js";
34
import { normalizeOptionalString } from "../../shared/string-coerce.js";
@@ -25,16 +26,24 @@ function normalizeInstall(value: unknown): OpenClawProviderIndexPluginInstall |
2526
if (!isRecord(value)) {
2627
return undefined;
2728
}
29+
const clawhubSpec = normalizeOptionalString(value.clawhubSpec);
30+
const parsedClawHub = clawhubSpec ? parseClawHubPluginSpec(clawhubSpec) : null;
2831
const npmSpec = normalizeOptionalString(value.npmSpec);
29-
const parsed = npmSpec ? parseRegistryNpmSpec(npmSpec) : null;
30-
if (!parsed) {
32+
const parsedNpm = npmSpec ? parseRegistryNpmSpec(npmSpec) : null;
33+
if (!parsedClawHub && !parsedNpm) {
3134
return undefined;
3235
}
33-
const defaultChoice = value.defaultChoice === "npm" ? "npm" : undefined;
36+
const defaultChoice =
37+
value.defaultChoice === "clawhub" && parsedClawHub
38+
? "clawhub"
39+
: value.defaultChoice === "npm" && parsedNpm
40+
? "npm"
41+
: undefined;
3442
const minHostVersion = normalizeOptionalString(value.minHostVersion);
3543
const expectedIntegrity = normalizeOptionalString(value.expectedIntegrity);
3644
return {
37-
npmSpec: parsed.raw,
45+
...(parsedClawHub ? { clawhubSpec } : {}),
46+
...(parsedNpm ? { npmSpec: parsedNpm.raw } : {}),
3847
...(defaultChoice ? { defaultChoice } : {}),
3948
...(minHostVersion ? { minHostVersion } : {}),
4049
...(expectedIntegrity ? { expectedIntegrity } : {}),

src/model-catalog/provider-index/types.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import type { ModelCatalogProvider } from "../types.js";
22

33
export type OpenClawProviderIndexPluginInstall = {
4-
npmSpec: string;
5-
defaultChoice?: "npm";
4+
clawhubSpec?: string;
5+
npmSpec?: string;
6+
defaultChoice?: "clawhub" | "npm";
67
minHostVersion?: string;
78
expectedIntegrity?: string;
89
};

0 commit comments

Comments
 (0)