Files
openclaw/extensions/perplexity/web-search-contract-api.ts
Gustavo Madeira Santana 2482e70fb8 test: narrow web search contract runtime loads
Honor targeted includes in the contracts Vitest lane and compare bundled
web-search fast-path artifacts against plugin-owned runtime artifacts instead
of loading whole plugin entries. Split Google and Firecrawl runtime-only work
behind lazy seams so provider registration stays metadata-light.

Also keep Perplexity contract metadata aligned by sharing its runtime transport
resolution with the contract artifact.
2026-04-17 17:26:46 -04:00

44 lines
1.6 KiB
TypeScript

import {
createWebSearchProviderContractFields,
mergeScopedSearchConfig,
resolveProviderWebSearchPluginConfig,
type WebSearchProviderPlugin,
} from "openclaw/plugin-sdk/provider-web-search-config-contract";
import { resolvePerplexityRuntimeTransport } from "./src/perplexity-web-search-provider.shared.js";
export function createPerplexityWebSearchProvider(): WebSearchProviderPlugin {
const credentialPath = "plugins.entries.perplexity.config.webSearch.apiKey";
return {
id: "perplexity",
label: "Perplexity Search",
hint: "Requires Perplexity API key or OpenRouter API key · structured results",
onboardingScopes: ["text-inference"],
credentialLabel: "Perplexity API key",
envVars: ["PERPLEXITY_API_KEY", "OPENROUTER_API_KEY"],
placeholder: "pplx-...",
signupUrl: "https://www.perplexity.ai/settings/api",
docsUrl: "https://docs.openclaw.ai/perplexity",
autoDetectOrder: 50,
credentialPath,
...createWebSearchProviderContractFields({
credentialPath,
searchCredential: { type: "scoped", scopeId: "perplexity" },
configuredCredential: { pluginId: "perplexity" },
}),
resolveRuntimeMetadata: (ctx) => ({
perplexityTransport: resolvePerplexityRuntimeTransport({
searchConfig: mergeScopedSearchConfig(
ctx.searchConfig,
"perplexity",
resolveProviderWebSearchPluginConfig(ctx.config, "perplexity"),
),
resolvedKey: ctx.resolvedCredential?.value,
keySource: ctx.resolvedCredential?.source ?? "missing",
fallbackEnvVar: ctx.resolvedCredential?.fallbackEnvVar,
}),
}),
createTool: () => null,
};
}