11import { readPositiveIntegerParam } from "openclaw/plugin-sdk/param-readers" ;
2- import {
3- createWebSearchProviderContractFields ,
4- type WebSearchProviderPlugin ,
5- } from "openclaw/plugin-sdk/provider-web-search-contract" ;
6-
7- const FIRECRAWL_CREDENTIAL_PATH = "plugins.entries.firecrawl.config.webSearch.apiKey" ;
8- const FIRECRAWL_FETCH_CREDENTIAL_PATH = "plugins.entries.firecrawl.config.webFetch.apiKey" ;
2+ import { type WebSearchProviderPlugin } from "openclaw/plugin-sdk/provider-web-search-contract" ;
3+ import { buildFirecrawlWebSearchProviderBase } from "../web-search-shared.js" ;
94
105type FirecrawlClientModule = typeof import ( "./firecrawl-client.js" ) ;
116
@@ -16,20 +11,6 @@ function loadFirecrawlClientModule(): Promise<FirecrawlClientModule> {
1611 return firecrawlClientModulePromise ;
1712}
1813
19- function getConfiguredFetchCredentialFallback ( config ?: {
20- plugins ?: { entries ?: { firecrawl ?: { config ?: unknown } } } ;
21- } ) {
22- const apiKey = (
23- config ?. plugins ?. entries ?. firecrawl ?. config as { webFetch ?: { apiKey ?: unknown } } | undefined
24- ) ?. webFetch ?. apiKey ;
25- return apiKey === undefined
26- ? undefined
27- : {
28- path : FIRECRAWL_FETCH_CREDENTIAL_PATH ,
29- value : apiKey ,
30- } ;
31- }
32-
3314const GenericFirecrawlSearchSchema = {
3415 type : "object" ,
3516 properties : {
@@ -46,24 +27,7 @@ const GenericFirecrawlSearchSchema = {
4627
4728export function createFirecrawlWebSearchProvider ( ) : WebSearchProviderPlugin {
4829 return {
49- id : "firecrawl" ,
50- label : "Firecrawl Search" ,
51- hint : "Structured results with optional result scraping" ,
52- onboardingScopes : [ "text-inference" ] ,
53- credentialLabel : "Firecrawl API key" ,
54- envVars : [ "FIRECRAWL_API_KEY" ] ,
55- placeholder : "fc-..." ,
56- signupUrl : "https://www.firecrawl.dev/" ,
57- docsUrl : "https://docs.openclaw.ai/tools/firecrawl" ,
58- autoDetectOrder : 60 ,
59- credentialPath : FIRECRAWL_CREDENTIAL_PATH ,
60- ...createWebSearchProviderContractFields ( {
61- credentialPath : FIRECRAWL_CREDENTIAL_PATH ,
62- searchCredential : { type : "scoped" , scopeId : "firecrawl" } ,
63- configuredCredential : { pluginId : "firecrawl" } ,
64- selectionPluginId : "firecrawl" ,
65- } ) ,
66- getConfiguredCredentialFallback : getConfiguredFetchCredentialFallback ,
30+ ...buildFirecrawlWebSearchProviderBase ( ) ,
6731 createTool : ( ctx ) => ( {
6832 description :
6933 "Search the web using Firecrawl. Returns structured results with snippets from Firecrawl Search. Use firecrawl_search for Firecrawl-specific knobs like sources or categories." ,
0 commit comments