refactor: route bundled capability providers through plugin runtime

This commit is contained in:
Peter Steinberger
2026-03-27 13:57:45 +00:00
parent 8d054e7892
commit f1503bd5c7
5 changed files with 26 additions and 56 deletions

View File

@@ -1,6 +1,6 @@
import { describe, expect, it } from "vitest";
import { listBundledWebSearchProviderEntries } from "../bundled-web-search.entries.js";
import type { OpenClawConfig } from "../config/config.js";
import { loadBundledCapabilityRuntimeRegistry } from "./bundled-capability-runtime.js";
import { BUNDLED_WEB_SEARCH_PLUGIN_IDS } from "./bundled-web-search-ids.js";
import { resolveBundledWebSearchPluginId } from "./bundled-web-search-provider-ids.js";
import {
@@ -105,7 +105,13 @@ describe("bundled web search metadata", () => {
it("keeps bundled provider metadata aligned with bundled plugin contracts", async () => {
const fastPathProviders = listBundledWebSearchProviders();
const bundledProviderEntries = listBundledWebSearchProviderEntries();
const bundledProviderEntries = loadBundledCapabilityRuntimeRegistry({
pluginIds: BUNDLED_WEB_SEARCH_PLUGIN_IDS,
pluginSdkResolution: "dist",
}).webSearchProviders.map((entry) => ({
pluginId: entry.pluginId,
...entry.provider,
}));
expect(
sortComparableEntries(

View File

@@ -1,5 +1,5 @@
import { listBundledWebSearchProviderEntries } from "../bundled-web-search.entries.js";
import { BUNDLED_WEB_SEARCH_PLUGIN_IDS } from "./bundled-capability-metadata.js";
import { loadBundledCapabilityRuntimeRegistry } from "./bundled-capability-runtime.js";
import { resolveBundledWebSearchPluginId as resolveBundledWebSearchPluginIdFromMap } from "./bundled-web-search-provider-ids.js";
import type { PluginLoadOptions } from "./loader.js";
import { loadPluginManifestRegistry } from "./manifest-registry.js";
@@ -11,7 +11,13 @@ let bundledWebSearchProvidersCache: BundledWebSearchProviderEntry[] | null = nul
function loadBundledWebSearchProviders(): BundledWebSearchProviderEntry[] {
if (!bundledWebSearchProvidersCache) {
bundledWebSearchProvidersCache = listBundledWebSearchProviderEntries();
bundledWebSearchProvidersCache = loadBundledCapabilityRuntimeRegistry({
pluginIds: BUNDLED_WEB_SEARCH_PLUGIN_IDS,
pluginSdkResolution: "dist",
}).webSearchProviders.map((entry) => ({
pluginId: entry.pluginId,
...entry.provider,
}));
}
return bundledWebSearchProvidersCache;
}

View File

@@ -1,4 +1,3 @@
import { listBundledImageGenerationProviderEntries } from "../../bundled-image-generation-providers.js";
import {
BUNDLED_IMAGE_GENERATION_PLUGIN_IDS,
BUNDLED_PLUGIN_CONTRACT_SNAPSHOTS,
@@ -226,10 +225,16 @@ function loadMediaUnderstandingProviderContractRegistry(): MediaUnderstandingPro
function loadImageGenerationProviderContractRegistry(): ImageGenerationProviderContractEntry[] {
if (!imageGenerationProviderContractRegistryCache) {
imageGenerationProviderContractRegistryCache =
listBundledImageGenerationProviderEntries().filter((entry) =>
BUNDLED_IMAGE_GENERATION_PLUGIN_IDS.includes(entry.pluginId),
);
const registry = loadBundledCapabilityRuntimeRegistry({
pluginIds: BUNDLED_IMAGE_GENERATION_PLUGIN_IDS,
pluginSdkResolution: "dist",
});
imageGenerationProviderContractRegistryCache = registry.imageGenerationProviders.map(
(entry) => ({
pluginId: entry.pluginId,
provider: entry.provider,
}),
);
}
return imageGenerationProviderContractRegistryCache;
}