|
| 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 } : {}), |
|
0 commit comments