[feat-003] Brave web search with globe-icon toggle

↗ view on GitHub · Nick Whitehouse · 2026-05-04 · 00e1dd66

Adds a `web_search` tool backed by the Brave Search API, gated by a
globe-icon toggle on the right side of the chat input (Ruli pattern).
Hard-gated: globe off → tool not in the model's schema. Same shape as
the legal-sources picker, distinct UI surface because web search is a
binary toggle vs the legal sources' per-source multi-select.

Backend
- backend/src/lib/webSearch.ts (new): Brave Search client with 12s
  AbortController timeout. Returns the same shape as legalSearch
  results so feat-004 references-inline can render either source with
  one card component. Graceful degradation when BRAVE_SEARCH_API_KEY
  is missing.
- chatTools.ts: WEB_TOOLS array (kept separate from always-on TOOLS
  so it can be conditionally appended). Dispatch case for web_search
  in runToolCalls. runLLMStream accepts sources.web boolean; when
  true → append WEB_TOOLS + system-prompt line steering the model
  toward web for current/news/commentary.
- routes/chat.ts: extends sources type to { legal?, web? }.
- .env.example: documents BRAVE_SEARCH_API_KEY.

Frontend
- ChatInput.tsx: globe icon button between ModelToggle and send.
  Filled blue when on, gray when off. Per-message state (resets
  after submit, matches legal-sources behaviour). Click toggles.
- MikeMessage.sources extended to include web?: boolean.
- mikeApi.streamChat passes sources through unchanged.

Also writes detailed feat-004 (references inline) and feat-005
(multi-pass research orchestrator) plans into backlog.md so the
direction is documented before implementation.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Repository nwhitehouse/mike
Author Nick Whitehouse <nick.whitehouse@mccarthyfinch.com>
Authored
Parents e772ac55
Stats 8 files changed , +355 , -22
Part of Brave web-search tool + globe-icon toggle

Capture this commit into my fork

Download a Markdown prompt that tells Claude how to port this exact commit into your working tree. Run it via claude -p < capture-commit-00e1dd66.md from inside the repo you want the change in.

⬇ Download capture-commit-00e1dd66.md