mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-30 11:50:22 +00:00
refactor: clean plugin capability boundaries
This commit is contained in:
@@ -120,6 +120,53 @@ describe("plugin contract registry", () => {
|
||||
expect(providerContractPluginIds).toEqual(bundledProviderPluginIds);
|
||||
});
|
||||
|
||||
it("covers every bundled speech plugin discovered from manifests", () => {
|
||||
const bundledSpeechPluginIds = loadPluginManifestRegistry({})
|
||||
.plugins.filter(
|
||||
(plugin) => plugin.origin === "bundled" && (plugin.speechProviders?.length ?? 0) > 0,
|
||||
)
|
||||
.map((plugin) => plugin.id)
|
||||
.toSorted((left, right) => left.localeCompare(right));
|
||||
|
||||
expect(
|
||||
[...new Set(speechProviderContractRegistry.map((entry) => entry.pluginId))].toSorted(
|
||||
(left, right) => left.localeCompare(right),
|
||||
),
|
||||
).toEqual(bundledSpeechPluginIds);
|
||||
});
|
||||
|
||||
it("covers every bundled media-understanding plugin discovered from manifests", () => {
|
||||
const bundledMediaPluginIds = loadPluginManifestRegistry({})
|
||||
.plugins.filter(
|
||||
(plugin) =>
|
||||
plugin.origin === "bundled" && (plugin.mediaUnderstandingProviders?.length ?? 0) > 0,
|
||||
)
|
||||
.map((plugin) => plugin.id)
|
||||
.toSorted((left, right) => left.localeCompare(right));
|
||||
|
||||
expect(
|
||||
[
|
||||
...new Set(mediaUnderstandingProviderContractRegistry.map((entry) => entry.pluginId)),
|
||||
].toSorted((left, right) => left.localeCompare(right)),
|
||||
).toEqual(bundledMediaPluginIds);
|
||||
});
|
||||
|
||||
it("covers every bundled image-generation plugin discovered from manifests", () => {
|
||||
const bundledImagePluginIds = loadPluginManifestRegistry({})
|
||||
.plugins.filter(
|
||||
(plugin) =>
|
||||
plugin.origin === "bundled" && (plugin.imageGenerationProviders?.length ?? 0) > 0,
|
||||
)
|
||||
.map((plugin) => plugin.id)
|
||||
.toSorted((left, right) => left.localeCompare(right));
|
||||
|
||||
expect(
|
||||
[...new Set(imageGenerationProviderContractRegistry.map((entry) => entry.pluginId))].toSorted(
|
||||
(left, right) => left.localeCompare(right),
|
||||
),
|
||||
).toEqual(bundledImagePluginIds);
|
||||
});
|
||||
|
||||
it("covers every bundled web search plugin from the shared resolver", () => {
|
||||
const bundledWebSearchPluginIds = resolveBundledWebSearchPluginIds({});
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ import xiaomiPlugin from "../../../extensions/xiaomi/index.js";
|
||||
import zaiPlugin from "../../../extensions/zai/index.js";
|
||||
import { bundledWebSearchPluginRegistrations } from "../../bundled-web-search-registry.js";
|
||||
import { createCapturedPluginRegistration } from "../captured-registration.js";
|
||||
import { loadPluginManifestRegistry } from "../manifest-registry.js";
|
||||
import { resolvePluginProviders } from "../provider-auth-choice.runtime.js";
|
||||
import type {
|
||||
ImageGenerationProviderPlugin,
|
||||
@@ -85,21 +86,6 @@ const bundledWebSearchPlugins: Array<RegistrablePlugin & { credentialValue: unkn
|
||||
...plugin,
|
||||
credentialValue,
|
||||
}));
|
||||
const bundledSpeechPlugins: RegistrablePlugin[] = [elevenLabsPlugin, microsoftPlugin, openAIPlugin];
|
||||
|
||||
const bundledMediaUnderstandingPlugins: RegistrablePlugin[] = [
|
||||
anthropicPlugin,
|
||||
deepgramPlugin,
|
||||
googlePlugin,
|
||||
groqPlugin,
|
||||
minimaxPlugin,
|
||||
mistralPlugin,
|
||||
moonshotPlugin,
|
||||
openAIPlugin,
|
||||
zaiPlugin,
|
||||
];
|
||||
|
||||
const bundledImageGenerationPlugins: RegistrablePlugin[] = [falPlugin, googlePlugin, openAIPlugin];
|
||||
|
||||
function captureRegistrations(plugin: RegistrablePlugin) {
|
||||
const captured = createCapturedPluginRegistration();
|
||||
@@ -390,6 +376,43 @@ const bundledProviderPlugins = dedupePlugins([
|
||||
zaiPlugin,
|
||||
]);
|
||||
|
||||
const bundledRegistrablePluginsById = new Map(
|
||||
dedupePlugins([
|
||||
...bundledProviderPlugins,
|
||||
elevenLabsPlugin,
|
||||
microsoftPlugin,
|
||||
deepgramPlugin,
|
||||
groqPlugin,
|
||||
...bundledWebSearchPlugins,
|
||||
]).map((plugin) => [plugin.id, plugin]),
|
||||
);
|
||||
|
||||
function resolveBundledCapabilityPluginIds(
|
||||
capability: "speechProviders" | "mediaUnderstandingProviders" | "imageGenerationProviders",
|
||||
): string[] {
|
||||
return loadPluginManifestRegistry({})
|
||||
.plugins.filter(
|
||||
(plugin) => plugin.origin === "bundled" && (plugin[capability]?.length ?? 0) > 0,
|
||||
)
|
||||
.map((plugin) => plugin.id)
|
||||
.toSorted((left, right) => left.localeCompare(right));
|
||||
}
|
||||
|
||||
function resolveBundledCapabilityPlugins(
|
||||
capability: "speechProviders" | "mediaUnderstandingProviders" | "imageGenerationProviders",
|
||||
): RegistrablePlugin[] {
|
||||
return resolveBundledCapabilityPluginIds(capability).flatMap((pluginId) => {
|
||||
const plugin = bundledRegistrablePluginsById.get(pluginId);
|
||||
return plugin ? [plugin] : [];
|
||||
});
|
||||
}
|
||||
|
||||
const bundledSpeechPlugins = resolveBundledCapabilityPlugins("speechProviders");
|
||||
const bundledMediaUnderstandingPlugins = resolveBundledCapabilityPlugins(
|
||||
"mediaUnderstandingProviders",
|
||||
);
|
||||
const bundledImageGenerationPlugins = resolveBundledCapabilityPlugins("imageGenerationProviders");
|
||||
|
||||
const bundledPluginRegistrationList = dedupePlugins([
|
||||
...bundledSpeechPlugins,
|
||||
...bundledMediaUnderstandingPlugins,
|
||||
|
||||
Reference in New Issue
Block a user