fix(plugins): accept clawhub provider index installs · openclaw/openclaw@dda2db9
vincentkoc
·
2026-05-02
·
via Recent Commits to openclaw:main
File tree
src/model-catalog/provider-index
| Original file line number | Diff line number | Diff line change |
|---|
@@ -13,8 +13,9 @@ describe("OpenClaw provider index", () => {
|
13 | 13 | id: "moonshot", |
14 | 14 | package: " @openclaw/plugin-moonshot ", |
15 | 15 | install: { |
| 16 | +clawhubSpec: " clawhub:openclaw/moonshot@2026.5.2 ", |
16 | 17 | npmSpec: " @openclaw/plugin-moonshot@1.2.3 ", |
17 | | -defaultChoice: "npm", |
| 18 | +defaultChoice: "clawhub", |
18 | 19 | expectedIntegrity: " sha512-moonshot ", |
19 | 20 | }, |
20 | 21 | }, |
@@ -63,8 +64,9 @@ describe("OpenClaw provider index", () => {
|
63 | 64 | id: "moonshot", |
64 | 65 | package: "@openclaw/plugin-moonshot", |
65 | 66 | install: { |
| 67 | +clawhubSpec: "clawhub:openclaw/moonshot@2026.5.2", |
66 | 68 | npmSpec: "@openclaw/plugin-moonshot@1.2.3", |
67 | | -defaultChoice: "npm", |
| 69 | +defaultChoice: "clawhub", |
68 | 70 | expectedIntegrity: "sha512-moonshot", |
69 | 71 | }, |
70 | 72 | }, |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +import { parseClawHubPluginSpec } from "../../infra/clawhub-spec.js"; |
1 | 2 | import { parseRegistryNpmSpec } from "../../infra/npm-registry-spec.js"; |
2 | 3 | import { isBlockedObjectKey } from "../../infra/prototype-keys.js"; |
3 | 4 | import { normalizeOptionalString } from "../../shared/string-coerce.js"; |
@@ -25,16 +26,24 @@ function normalizeInstall(value: unknown): OpenClawProviderIndexPluginInstall |
|
25 | 26 | if (!isRecord(value)) { |
26 | 27 | return undefined; |
27 | 28 | } |
| 29 | +const clawhubSpec = normalizeOptionalString(value.clawhubSpec); |
| 30 | +const parsedClawHub = clawhubSpec ? parseClawHubPluginSpec(clawhubSpec) : null; |
28 | 31 | 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) { |
31 | 34 | return undefined; |
32 | 35 | } |
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; |
34 | 42 | const minHostVersion = normalizeOptionalString(value.minHostVersion); |
35 | 43 | const expectedIntegrity = normalizeOptionalString(value.expectedIntegrity); |
36 | 44 | return { |
37 | | -npmSpec: parsed.raw, |
| 45 | + ...(parsedClawHub ? { clawhubSpec } : {}), |
| 46 | + ...(parsedNpm ? { npmSpec: parsedNpm.raw } : {}), |
38 | 47 | ...(defaultChoice ? { defaultChoice } : {}), |
39 | 48 | ...(minHostVersion ? { minHostVersion } : {}), |
40 | 49 | ...(expectedIntegrity ? { expectedIntegrity } : {}), |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import type { ModelCatalogProvider } from "../types.js"; |
2 | 2 | |
3 | 3 | export type OpenClawProviderIndexPluginInstall = { |
4 | | -npmSpec: string; |
5 | | -defaultChoice?: "npm"; |
| 4 | +clawhubSpec?: string; |
| 5 | +npmSpec?: string; |
| 6 | +defaultChoice?: "clawhub" | "npm"; |
6 | 7 | minHostVersion?: string; |
7 | 8 | expectedIntegrity?: string; |
8 | 9 | }; |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。