mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-16 15:43:57 -06:00
c7e7ac2728
* docs(secrets): remove retired web credential paths * refactor(web): remove retired provider compatibility paths * refactor(providers): delete retired compatibility routes * refactor(secrets): remove retired credential aliases * refactor(plugin-sdk): delete retired compatibility surfaces * docs(plugin-sdk): remove retired migration guidance * chore(plugin-sdk): refresh rebased surface budgets * chore(plugin-sdk): refresh API removal baseline * refactor(compat): migrate retired internal callers * chore(plugin-sdk): refresh current-main baselines * test(config): migrate plugin-owned secret assertions * test(gateway): narrow plugin secret refs * fix(plugin-sdk): preserve private boundary type identity * chore(compat): remove stale sweep references * chore(lint): lower max-lines budget * refactor(secrets): remove unused web helper * build(plugin-sdk): drop removed compat entries * chore(plugin-sdk): refresh rebased API baseline * chore(plugin-sdk): use Linux API baseline hash * fix(plugin-sdk): preserve private bundled build entries * fix(plugin-sdk): package private runtime facades * fix(plugins): preserve external credential contracts
52 lines
2.1 KiB
TypeScript
52 lines
2.1 KiB
TypeScript
/**
|
|
* Shared Brave Search provider metadata and credential lookup. Contract tests
|
|
* and runtime provider creation both use this lightweight descriptor.
|
|
*/
|
|
import {
|
|
createWebSearchProviderContractFields,
|
|
type WebSearchProviderPlugin,
|
|
} from "openclaw/plugin-sdk/provider-web-search-config-contract";
|
|
import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
|
|
/** Canonical config path for the Brave Search API key. */
|
|
const BRAVE_CREDENTIAL_PATH = "plugins.entries.brave.config.webSearch.apiKey";
|
|
|
|
function resolveBraveWebSearchPluginConfig(config: unknown): Record<string, unknown> | undefined {
|
|
if (!isRecord(config)) {
|
|
return undefined;
|
|
}
|
|
const plugins = isRecord(config.plugins) ? config.plugins : undefined;
|
|
const entries = isRecord(plugins?.entries) ? plugins.entries : undefined;
|
|
const entry = isRecord(entries?.brave) ? entries.brave : undefined;
|
|
const pluginConfig = isRecord(entry?.config) ? entry.config : undefined;
|
|
return isRecord(pluginConfig?.webSearch) ? pluginConfig.webSearch : undefined;
|
|
}
|
|
|
|
/** Resolve Brave credentials from current plugin config. */
|
|
function resolveConfiguredBraveCredential(config: unknown): unknown {
|
|
return resolveBraveWebSearchPluginConfig(config)?.apiKey;
|
|
}
|
|
|
|
/** Build the common Brave provider metadata without the runtime tool executor. */
|
|
export function buildBraveWebSearchProviderBase(): Omit<WebSearchProviderPlugin, "createTool"> {
|
|
return {
|
|
id: "brave",
|
|
label: "Brave Search",
|
|
hint: "Structured results · country/language/time filters",
|
|
onboardingScopes: ["text-inference"],
|
|
credentialLabel: "Brave Search API key",
|
|
envVars: ["BRAVE_API_KEY"],
|
|
placeholder: "BSA...",
|
|
signupUrl: "https://brave.com/search/api/",
|
|
docsUrl: "https://docs.openclaw.ai/tools/brave-search",
|
|
autoDetectOrder: 10,
|
|
credentialPath: BRAVE_CREDENTIAL_PATH,
|
|
...createWebSearchProviderContractFields({
|
|
credentialPath: BRAVE_CREDENTIAL_PATH,
|
|
searchCredential: { type: "top-level" },
|
|
configuredCredential: { pluginId: "brave" },
|
|
}),
|
|
getConfiguredCredentialValue: resolveConfiguredBraveCredential,
|
|
};
|
|
}
|