Files
openclaw/src/plugins/web-search-providers.ts
Vincent Koc f911bbc353 refactor(plugins): separate activation from enablement (#59844)
* refactor(plugins): separate activation from enablement

* fix(cli): sanitize verbose plugin activation reasons
2026-04-03 03:22:37 +09:00

37 lines
1.4 KiB
TypeScript

import { listBundledWebSearchProviders as listBundledWebSearchProviderEntries } from "./bundled-web-search.js";
import { resolveEffectivePluginActivationState } from "./config-state.js";
import type { PluginLoadOptions } from "./loader.js";
import type { PluginWebSearchProviderEntry } from "./types.js";
import {
resolveBundledWebSearchResolutionConfig,
sortWebSearchProviders,
} from "./web-search-providers.shared.js";
function listBundledWebSearchProviders(): PluginWebSearchProviderEntry[] {
return sortWebSearchProviders(listBundledWebSearchProviderEntries());
}
export function resolveBundledPluginWebSearchProviders(params: {
config?: PluginLoadOptions["config"];
workspaceDir?: string;
env?: PluginLoadOptions["env"];
bundledAllowlistCompat?: boolean;
onlyPluginIds?: readonly string[];
}): PluginWebSearchProviderEntry[] {
const { config, normalized } = resolveBundledWebSearchResolutionConfig(params);
const onlyPluginIdSet =
params.onlyPluginIds && params.onlyPluginIds.length > 0 ? new Set(params.onlyPluginIds) : null;
return listBundledWebSearchProviders().filter((provider) => {
if (onlyPluginIdSet && !onlyPluginIdSet.has(provider.pluginId)) {
return false;
}
return resolveEffectivePluginActivationState({
id: provider.pluginId,
origin: "bundled",
config: normalized,
rootConfig: config,
}).activated;
});
}