Skip to content

feat: add Brave Search as a web search provider#489

Merged
nashsu merged 1 commit into
nashsu:mainfrom
AndrewDongminYoo:feat/brave-search-provider
Jun 28, 2026
Merged

feat: add Brave Search as a web search provider#489
nashsu merged 1 commit into
nashsu:mainfrom
AndrewDongminYoo:feat/brave-search-provider

Conversation

@AndrewDongminYoo

Copy link
Copy Markdown
Contributor

What

Adds Brave Search API as a web search provider alongside Tavily, SerpApi, SearXNG, Ollama, and Firecrawl.

Changes

  • src/stores/wiki-store.ts — adds "brave" to SearchProvider union type
  • src/lib/web-search.ts — implements braveSearch(), routes the switch case, updates the API-key validation error to mention Brave
  • src/components/settings/sections/web-search-section.tsx — adds Brave Search entry to the provider list in Settings
  • src/lib/web-search.test.ts — three new tests: happy path with header/result normalization, 20-result count cap, 401 auth error surface

Implementation details

  • Auth: X-Subscription-Token: <api_key> (Brave's published scheme, distinct from Authorization: Bearer)
  • Endpoint: GET https://api.search.brave.com/res/v1/web/search
  • Result cap: count is clamped to [1, 20] — Brave silently caps higher values server-side; clamping client-side keeps the URL honest and avoids surprising callers
  • Response mapping: data.web.results[] → { title, url, snippet: description, source: hostnameFromUrl(url) } — same shape as existing providers
  • Error handling: dedicated 401/403 message ("check your subscription token"), network error via isFetchNetworkError(), generic HTTP error with status + body
  • No new dependencies

Test plan

  • TypeScript: npx tsc --noEmit passes
  • Unit tests: all 19 passing (3 new Brave tests + existing suite intact)
  • Manual: Settings → Web Search → Brave Search appears in provider list
  • Manual: configure Brave API key → run Deep Research → results render correctly

Add Brave Web Search API as a new search provider option.
Includes API key validation, 20-result ceiling clamping, auth error guidance, and full test coverage.
@nashsu nashsu merged commit a9f12c4 into nashsu:main Jun 28, 2026
3 checks passed
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.

2 participants