fix: align bundled provider contracts with externalized plugins · openclaw/openclaw@78161e1
steipete
·
2026-05-02
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -5,7 +5,13 @@ import {
|
5 | 5 | normalizeBundledPluginStringList, |
6 | 6 | resolveBundledPluginScanDir, |
7 | 7 | } from "../../bundled-plugin-scan.js"; |
8 | | -import { PLUGIN_MANIFEST_FILENAME, type PluginManifest } from "../../manifest.js"; |
| 8 | +import { |
| 9 | +getPackageManifestMetadata, |
| 10 | +isPackageIncludedInCoreBundle, |
| 11 | +PLUGIN_MANIFEST_FILENAME, |
| 12 | +type PackageManifest, |
| 13 | +type PluginManifest, |
| 14 | +} from "../../manifest.js"; |
9 | 15 | import { resolveLoaderPackageRoot } from "../../sdk-alias.js"; |
10 | 16 | import { uniqueStrings } from "../shared.js"; |
11 | 17 | |
@@ -65,17 +71,7 @@ function readJsonRecord(filePath: string): Record<string, unknown> | undefined {
|
65 | 71 | } |
66 | 72 | |
67 | 73 | function isExplicitlyDownloadablePlugin(packageJson: Record<string, unknown> | undefined): boolean { |
68 | | -const openclaw = packageJson?.openclaw; |
69 | | -if (!openclaw || typeof openclaw !== "object" || Array.isArray(openclaw)) { |
70 | | -return false; |
71 | | -} |
72 | | -const bundle = (openclaw as { bundle?: unknown }).bundle; |
73 | | -return ( |
74 | | -bundle !== null && |
75 | | -typeof bundle === "object" && |
76 | | -!Array.isArray(bundle) && |
77 | | -(bundle as { includeInCore?: unknown }).includeInCore === false |
78 | | -); |
| 74 | +return !isPackageIncludedInCoreBundle(getPackageManifestMetadata(packageJson as PackageManifest)); |
79 | 75 | } |
80 | 76 | |
81 | 77 | function readBundledCapabilityManifest(pluginDir: string): BundledCapabilityManifest | undefined { |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import { describe, expect, it } from "vitest"; |
2 | 2 | import { uniqueSortedStrings } from "../../plugin-sdk/test-helpers/string-utils.js"; |
3 | 3 | import { loadPluginManifestRegistry } from "../manifest-registry.js"; |
| 4 | +import { isPackageIncludedInCoreBundle } from "../manifest.js"; |
4 | 5 | import { resolveManifestContractPluginIds } from "../plugin-registry.js"; |
5 | 6 | import { |
6 | 7 | pluginRegistrationContractRegistry, |
@@ -44,7 +45,11 @@ describe("plugin contract registry", () => {
|
44 | 45 | }) => boolean, |
45 | 46 | ) { |
46 | 47 | return loadPluginManifestRegistry({}) |
47 | | -.plugins.filter(predicate) |
| 48 | +.plugins.filter( |
| 49 | +(plugin) => |
| 50 | +(plugin.origin !== "bundled" || isPackageIncludedInCoreBundle(plugin.packageManifest)) && |
| 51 | +predicate(plugin), |
| 52 | +) |
48 | 53 | .map((plugin) => plugin.id) |
49 | 54 | .toSorted((left, right) => left.localeCompare(right)); |
50 | 55 | } |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1530,6 +1530,10 @@ export type OpenClawPackageSetupFeatures = {
|
1530 | 1530 | legacySessionSurfaces?: boolean; |
1531 | 1531 | }; |
1532 | 1532 | |
| 1533 | +export type OpenClawPackageBundle = { |
| 1534 | +includeInCore?: boolean; |
| 1535 | +}; |
| 1536 | + |
1533 | 1537 | export type OpenClawPackageManifest = { |
1534 | 1538 | extensions?: string[]; |
1535 | 1539 | runtimeExtensions?: string[]; |
@@ -1538,6 +1542,7 @@ export type OpenClawPackageManifest = {
|
1538 | 1542 | setupFeatures?: OpenClawPackageSetupFeatures; |
1539 | 1543 | channel?: PluginPackageChannel; |
1540 | 1544 | install?: PluginPackageInstall; |
| 1545 | +bundle?: OpenClawPackageBundle; |
1541 | 1546 | startup?: OpenClawPackageStartup; |
1542 | 1547 | }; |
1543 | 1548 | |
@@ -1570,6 +1575,12 @@ export function getPackageManifestMetadata(
|
1570 | 1575 | return manifest[MANIFEST_KEY]; |
1571 | 1576 | } |
1572 | 1577 | |
| 1578 | +export function isPackageIncludedInCoreBundle( |
| 1579 | +manifest: OpenClawPackageManifest | undefined, |
| 1580 | +): boolean { |
| 1581 | +return manifest?.bundle?.includeInCore !== false; |
| 1582 | +} |
| 1583 | + |
1573 | 1584 | export function resolvePackageExtensionEntries( |
1574 | 1585 | manifest: PackageManifest | undefined, |
1575 | 1586 | ): PackageExtensionResolution { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -12,6 +12,7 @@ import type {
|
12 | 12 | PluginManifestRecord, |
13 | 13 | PluginManifestRegistry, |
14 | 14 | } from "./manifest-registry.js"; |
| 15 | +import { isPackageIncludedInCoreBundle } from "./manifest.js"; |
15 | 16 | import type { PluginOrigin } from "./plugin-origin.types.js"; |
16 | 17 | import { |
17 | 18 | createPluginRegistryIdNormalizer, |
@@ -119,6 +120,10 @@ function sortUnique(values: Iterable<string>): string[] {
|
119 | 120 | ); |
120 | 121 | } |
121 | 122 | |
| 123 | +function isCoreBundledManifestSurface(plugin: PluginManifestRecord): boolean { |
| 124 | +return plugin.origin !== "bundled" || isPackageIncludedInCoreBundle(plugin.packageManifest); |
| 125 | +} |
| 126 | + |
122 | 127 | function collectObjectKeys(value: Record<string, unknown> | undefined): readonly string[] { |
123 | 128 | return value ? Object.keys(value) : []; |
124 | 129 | } |
@@ -415,6 +420,7 @@ export function resolveManifestContractPluginIds(
|
415 | 420 | .plugins.filter( |
416 | 421 | (plugin) => |
417 | 422 | (!params.origin || plugin.origin === params.origin) && |
| 423 | +isCoreBundledManifestSurface(plugin) && |
418 | 424 | listManifestContractValues(plugin, params.contract).length > 0, |
419 | 425 | ) |
420 | 426 | .map((plugin) => plugin.id) |
@@ -432,6 +438,7 @@ export function resolveManifestContractPluginIdsByCompatibilityRuntimePath(
|
432 | 438 | .plugins.filter( |
433 | 439 | (plugin) => |
434 | 440 | (!params.origin || plugin.origin === params.origin) && |
| 441 | +isCoreBundledManifestSurface(plugin) && |
435 | 442 | listManifestContractValues(plugin, params.contract).length > 0 && |
436 | 443 | (plugin.configContracts?.compatibilityRuntimePaths ?? []).includes(normalizedPath), |
437 | 444 | ) |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -9,6 +9,7 @@ import {
|
9 | 9 | } from "./manifest-owner-policy.js"; |
10 | 10 | import { loadPluginManifestRegistryForInstalledIndex } from "./manifest-registry-installed.js"; |
11 | 11 | import { type PluginManifestRecord, type PluginManifestRegistry } from "./manifest-registry.js"; |
| 12 | +import { isPackageIncludedInCoreBundle } from "./manifest.js"; |
12 | 13 | import { |
13 | 14 | loadPluginRegistrySnapshot, |
14 | 15 | normalizePluginsConfigWithRegistry, |
@@ -71,10 +72,16 @@ function resolveProviderSurfacePluginIdSet(
|
71 | 72 | resolveManifestRegistry({ |
72 | 73 | ...params, |
73 | 74 | includeDisabled: true, |
74 | | -}).plugins.flatMap((plugin) => (plugin.providers.length > 0 ? [plugin.id] : [])), |
| 75 | +}).plugins.flatMap((plugin) => |
| 76 | +plugin.providers.length > 0 && isCoreBundledManifestSurface(plugin) ? [plugin.id] : [], |
| 77 | +), |
75 | 78 | ); |
76 | 79 | } |
77 | 80 | |
| 81 | +function isCoreBundledManifestSurface(plugin: PluginManifestRecord): boolean { |
| 82 | +return plugin.origin !== "bundled" || isPackageIncludedInCoreBundle(plugin.packageManifest); |
| 83 | +} |
| 84 | + |
78 | 85 | function resolveProviderOwnerPluginIds( |
79 | 86 | params: ProviderRegistryLoadParams & { |
80 | 87 | pluginIds: readonly string[]; |
@@ -139,6 +146,7 @@ export function resolveBundledProviderCompatPluginIds(params: {
|
139 | 146 | .filter( |
140 | 147 | (plugin) => |
141 | 148 | plugin.origin === "bundled" && |
| 149 | +isCoreBundledManifestSurface(plugin) && |
142 | 150 | plugin.providers.length > 0 && |
143 | 151 | (!onlyPluginIdSet || onlyPluginIdSet.has(plugin.id)), |
144 | 152 | ) |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。