Plugins: fix bundled web search compat registry
This commit is contained in:
parent
5625cf4724
commit
7ac23ae7c2
13
src/plugins/bundled-web-search.test.ts
Normal file
13
src/plugins/bundled-web-search.test.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { expect, it } from "vitest";
|
||||
import { resolveBundledWebSearchPluginIds } from "./bundled-web-search.js";
|
||||
|
||||
it("keeps bundled web search compat ids aligned with bundled manifests", () => {
|
||||
expect(resolveBundledWebSearchPluginIds({})).toEqual([
|
||||
"brave",
|
||||
"firecrawl",
|
||||
"google",
|
||||
"moonshot",
|
||||
"perplexity",
|
||||
"xai",
|
||||
]);
|
||||
});
|
||||
29
src/plugins/bundled-web-search.ts
Normal file
29
src/plugins/bundled-web-search.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import type { PluginLoadOptions } from "./loader.js";
|
||||
import { loadPluginManifestRegistry } from "./manifest-registry.js";
|
||||
|
||||
export const BUNDLED_WEB_SEARCH_PLUGIN_IDS = [
|
||||
"brave",
|
||||
"firecrawl",
|
||||
"google",
|
||||
"moonshot",
|
||||
"perplexity",
|
||||
"xai",
|
||||
] as const;
|
||||
|
||||
const bundledWebSearchPluginIdSet = new Set<string>(BUNDLED_WEB_SEARCH_PLUGIN_IDS);
|
||||
|
||||
export function resolveBundledWebSearchPluginIds(params: {
|
||||
config?: PluginLoadOptions["config"];
|
||||
workspaceDir?: string;
|
||||
env?: PluginLoadOptions["env"];
|
||||
}): string[] {
|
||||
const registry = loadPluginManifestRegistry({
|
||||
config: params.config,
|
||||
workspaceDir: params.workspaceDir,
|
||||
env: params.env,
|
||||
});
|
||||
return registry.plugins
|
||||
.filter((plugin) => plugin.origin === "bundled" && bundledWebSearchPluginIdSet.has(plugin.id))
|
||||
.map((plugin) => plugin.id)
|
||||
.toSorted((left, right) => left.localeCompare(right));
|
||||
}
|
||||
@ -3,6 +3,7 @@ import {
|
||||
withBundledPluginAllowlistCompat,
|
||||
withBundledPluginEnablementCompat,
|
||||
} from "./bundled-compat.js";
|
||||
import { resolveBundledWebSearchPluginIds } from "./bundled-web-search.js";
|
||||
import { loadOpenClawPlugins, type PluginLoadOptions } from "./loader.js";
|
||||
import { createPluginLoaderLogger } from "./logger.js";
|
||||
import { getActivePluginRegistry } from "./runtime.js";
|
||||
@ -41,25 +42,11 @@ function resolveBundledWebSearchCompatPluginIds(params: {
|
||||
workspaceDir?: string;
|
||||
env?: PluginLoadOptions["env"];
|
||||
}): string[] {
|
||||
const registry = loadOpenClawPlugins({
|
||||
config: {
|
||||
...params.config,
|
||||
plugins: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
return resolveBundledWebSearchPluginIds({
|
||||
config: params.config,
|
||||
workspaceDir: params.workspaceDir,
|
||||
env: params.env,
|
||||
cache: false,
|
||||
activate: false,
|
||||
logger: createPluginLoaderLogger(log),
|
||||
});
|
||||
const bundledPluginIds = new Set(
|
||||
registry.plugins.filter((plugin) => plugin.origin === "bundled").map((plugin) => plugin.id),
|
||||
);
|
||||
return [...new Set(registry.webSearchProviders.map((entry) => entry.pluginId))]
|
||||
.filter((pluginId) => bundledPluginIds.has(pluginId))
|
||||
.toSorted((left, right) => left.localeCompare(right));
|
||||
}
|
||||
|
||||
function withBundledWebSearchVitestCompat(params: {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user