diff --git a/extensions/exa/src/exa-web-search-provider.shared.ts b/extensions/exa/src/exa-web-search-provider.shared.ts new file mode 100644 index 00000000000..54ec7ed8340 --- /dev/null +++ b/extensions/exa/src/exa-web-search-provider.shared.ts @@ -0,0 +1,25 @@ +import { createWebSearchProviderContractFields } from "openclaw/plugin-sdk/provider-web-search-contract"; + +const EXA_CREDENTIAL_PATH = "plugins.entries.exa.config.webSearch.apiKey"; + +export function createExaWebSearchProviderBase() { + return { + id: "exa", + label: "Exa Search", + hint: "Neural + keyword search with date filters and content extraction", + onboardingScopes: ["text-inference"], + credentialLabel: "Exa API key", + envVars: ["EXA_API_KEY"], + placeholder: "exa-...", + signupUrl: "https://exa.ai/", + docsUrl: "https://docs.openclaw.ai/tools/web", + autoDetectOrder: 65, + credentialPath: EXA_CREDENTIAL_PATH, + ...createWebSearchProviderContractFields({ + credentialPath: EXA_CREDENTIAL_PATH, + searchCredential: { type: "scoped", scopeId: "exa" }, + configuredCredential: { pluginId: "exa" }, + selectionPluginId: "exa", + }), + }; +} diff --git a/extensions/exa/src/exa-web-search-provider.ts b/extensions/exa/src/exa-web-search-provider.ts index a59d8a3d742..802bc6ed8cd 100644 --- a/extensions/exa/src/exa-web-search-provider.ts +++ b/extensions/exa/src/exa-web-search-provider.ts @@ -1,9 +1,6 @@ -import { - createWebSearchProviderContractFields, - type WebSearchProviderPlugin, -} from "openclaw/plugin-sdk/provider-web-search-contract"; +import type { WebSearchProviderPlugin } from "openclaw/plugin-sdk/provider-web-search-contract"; +import { createExaWebSearchProviderBase } from "./exa-web-search-provider.shared.js"; -const EXA_CREDENTIAL_PATH = "plugins.entries.exa.config.webSearch.apiKey"; const EXA_SEARCH_TYPES = ["auto", "neural", "fast", "deep", "deep-reasoning", "instant"] as const; const EXA_FRESHNESS_VALUES = ["day", "week", "month", "year"] as const; const EXA_MAX_SEARCH_COUNT = 100; @@ -68,23 +65,7 @@ const ExaSearchSchema = { export function createExaWebSearchProvider(): WebSearchProviderPlugin { return { - id: "exa", - label: "Exa Search", - hint: "Neural + keyword search with date filters and content extraction", - onboardingScopes: ["text-inference"], - credentialLabel: "Exa API key", - envVars: ["EXA_API_KEY"], - placeholder: "exa-...", - signupUrl: "https://exa.ai/", - docsUrl: "https://docs.openclaw.ai/tools/web", - autoDetectOrder: 65, - credentialPath: EXA_CREDENTIAL_PATH, - ...createWebSearchProviderContractFields({ - credentialPath: EXA_CREDENTIAL_PATH, - searchCredential: { type: "scoped", scopeId: "exa" }, - configuredCredential: { pluginId: "exa" }, - selectionPluginId: "exa", - }), + ...createExaWebSearchProviderBase(), createTool: (ctx) => ({ description: "Search the web using Exa AI. Supports neural or keyword search, publication date filters, and optional highlights or text extraction.", diff --git a/extensions/exa/web-search-contract-api.ts b/extensions/exa/web-search-contract-api.ts index bfda3901e63..a71d47455f0 100644 --- a/extensions/exa/web-search-contract-api.ts +++ b/extensions/exa/web-search-contract-api.ts @@ -1,29 +1,9 @@ -import { - createWebSearchProviderContractFields, - type WebSearchProviderPlugin, -} from "openclaw/plugin-sdk/provider-web-search-contract"; +import type { WebSearchProviderPlugin } from "openclaw/plugin-sdk/provider-web-search-contract"; +import { createExaWebSearchProviderBase } from "./src/exa-web-search-provider.shared.js"; export function createExaWebSearchProvider(): WebSearchProviderPlugin { - const credentialPath = "plugins.entries.exa.config.webSearch.apiKey"; - return { - id: "exa", - label: "Exa Search", - hint: "Neural + keyword search with date filters and content extraction", - onboardingScopes: ["text-inference"], - credentialLabel: "Exa API key", - envVars: ["EXA_API_KEY"], - placeholder: "exa-...", - signupUrl: "https://exa.ai/", - docsUrl: "https://docs.openclaw.ai/tools/web", - autoDetectOrder: 65, - credentialPath, - ...createWebSearchProviderContractFields({ - credentialPath, - searchCredential: { type: "scoped", scopeId: "exa" }, - configuredCredential: { pluginId: "exa" }, - selectionPluginId: "exa", - }), + ...createExaWebSearchProviderBase(), createTool: () => null, }; }