[Feature] web_search: support SearXNG and other engines besides the Brave API
Description
Let web_search use more than the Brave API: a keyless option and a self-hosted option (SearXNG), selectable in config.
Use Case
web_search only works after the user creates a Brave Search API key (nanocoderTools.webSearch.apiKey), and the formatter hard codes "Engine: Brave Search API". Nanocoder is local-first: many users run fully local or on a restricted network and will not sign up for a third party key, and some already run a SearXNG instance. Without a key the tool just throws "Brave Search API key not configured", so the model loses web access completely.
Proposed Solution
Add nanocoderTools.webSearch.engine with values brave (default), searxng (needs baseUrl, uses its JSON API) and optionally a keyless HTML endpoint. Keep the same result format so the formatter and token estimate work unchanged, show the real engine name in the preview, and make /doctor report which engine is configured. Apply the existing SSRF guard rules to a user supplied baseUrl only where it should not reach private addresses (a local SearXNG is a legitimate private target, so make that an explicit setting).
Alternatives Considered
Using the fetch_url tool on a search results page (fragile, often blocked) or configuring a search MCP server (works, but needs a separate setup per user).
Additional Context
- [x] I have searched existing issues to ensure this is not a duplicate
- [x] This feature aligns with the project's goals (local-first AI assistance)
Implementation Notes (optional)
executeWebSearch in source/tools/web-search.tsx is a single function; an engine map keyed by name with a shared result shape would keep it small.
I'd like to pick this up, if nobody else has it. Here's the plan:
- Add
nanocoderTools.webSearch.engine(braveby default, orsearxng) andbaseUrlfor SearXNG.executeWebSearchkeeps one result shape and looks up the engine in a small map, so the markdown output and the formatter stay the same. The SearXNG request isGET {baseUrl}/search?q=...&format=json, with results capped atmax_results. - The preview shows the configured engine, not the hard-coded "Brave Search API".
tool-manager.tsregistersweb_searchwhen the selected engine is usable: a key for Brave, abaseUrlfor SearXNG. Today it only checks for the Brave key./doctorand the settings panel show which engine is configured.
Two things I'd like your view on first:
- Private addresses.
baseUrlcomes from the user's config, not from the model, and a SearXNG onlocalhostor the LAN is the main use. My plan is to runassertPublicHttpUrlfromfetch-url-guard.tson it unlessallowPrivateNetwork: trueis set next to it. Does that match what you meant by an explicit setting, or would you rather trust a configuredbaseUrlas it is? - The keyless HTML endpoint. Scraping something like DuckDuckGo's HTML page breaks whenever their markup changes. I'd leave it out of this PR and do Brave and SearXNG only, unless you'd like it included.
#2025 also touches web_search (it clamps max_results). I'll rebase on it if it lands first.