Skip to content

chore: Add Brave as a search provider#241

Open
casewalker wants to merge 1 commit into
danny-avila:mainfrom
casewalker:main
Open

chore: Add Brave as a search provider#241
casewalker wants to merge 1 commit into
danny-avila:mainfrom
casewalker:main

Conversation

@casewalker

Copy link
Copy Markdown

Summary

Adds Brave Search as a search provider. Wires up four of the documented Brave endpoints into the existing createSearchAPI/createSearchTool flow so that searchProvider: 'brave' is supported:

Changes

New provider: src/tools/search/brave-search.ts

  • createBraveAPI(apiKey, apiUrl?, options?) exposes the getSources interface
  • Supports the generic web-search which returns web, news, and video results, and also routes by type (images, videos, news) to hit dedicated endpoints
  • Country normalization: Filtered based on Brave's supported countries
  • Exposes various Brave API options

Configuration:

  • New SearchConfig fields: braveApiKey, braveApiUrl, braveSearchOptions
  • BraveSearchOptions:

Wiring: (src/tools/search/search.ts, src/tools/search/tool.ts)

  • createSearchAPI dispatches 'brave' to createBraveAPI

Refactor: (src/tools/search/utils.ts)

  • Extracted the getHostname helper out of tavily-search.ts and brave-search.ts

Testing

  • Unit tests in src/tools/search/brave.test.ts cover provider construction, error handling, response mapping, country/freshness/safesearch normalization, options precedence, per-endpoint count capping, and result-field fallbacks
  • Smoke-tested end-to-end against the live Brave API

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant