feat(tools): add SearXNG web search provider#214
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add SearxngSearchTool to the public re-exports in src/tools/mod.rs and src/lib.rs so downstream users and the CLI wiring layer can import it. Also extend the module doc comment to document the new tool. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace the 2-way Brave/DDG branch in create_agent_with_template() with a 3-way resolver that checks an explicit `provider` config field first, then auto-detects: api_url present → SearXNG, api_key present → Brave, fallback → DuckDuckGo. Both SearXNG and Brave paths emit a clear error if the required URL/key is missing when that provider is selected. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds SearXNG as an additional web search provider: new SearxngSearchTool (validation, JSON parsing, execution), config fields and env overrides for provider/api_url, wiring in CLI/tool registration, and public re-exports; includes related tests and docs updates. (≤50 words) Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as CLI/Request
participant Config as Config
participant ToolReg as ToolRegistry
participant Searx as SearXNG API
CLI->>Config: read provider/api_url (env overrides)
Config-->>CLI: provider selection
CLI->>ToolReg: request web search tool
ToolReg-->>CLI: instantiate SearxngSearchTool(api_url)
CLI->>Searx: HTTP query (search term)
Searx-->>CLI: JSON results
CLI->>ToolReg: parse_searxng_json -> SearchResult[]
CLI-->>ToolReg: return formatted output
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/cli/common.rs`:
- Around line 755-817: The code currently treats any explicit provider string
(search_cfg.provider) as valid and silently falls back to DdgSearchTool when it
doesn't match known providers; change the provider-determination so that if
search_cfg.provider is Some(non-empty) you validate it (normalize case/trim) and
if it is not one of the known values ("searxng", "brave", "ddg") return an error
(e.g. Err(anyhow::anyhow!("Unknown search provider: {}", provider))) instead of
defaulting, otherwise keep the existing inference behavior (check
api_url/api_key) when provider is not specified; update the branch that uses
provider to rely on the validated string and keep
SearxngSearchTool::with_max_results, WebSearchTool::with_max_results and
DdgSearchTool::with_max_results usage unchanged.
In `@src/tools/web.rs`:
- Around line 458-470: Change the SearXNG constructors to return Result<Self,
Error> instead of calling expect(): replace pub fn new(api_url: &str) -> Self
and pub fn with_max_results(api_url: &str, max_results: usize) -> Self so they
call validate_searxng_url(api_url) and propagate the failure (e.g., ? or
map_err) returning an Err on invalid URL; update SearxngSearchTool construction
sites (notably the call in src/cli/common.rs that uses
.register_tool(Box::new(SearxngSearchTool::with_max_results(url, max)?))) to
handle the Result (propagate or map error) so startup no longer panics on bad
config.
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
CLAUDE.mdsrc/cli/common.rssrc/config/mod.rssrc/config/types.rssrc/lib.rssrc/tools/mod.rssrc/tools/web.rs
…agate parse errors, remove panics - Normalize explicit provider config to lowercase and reject unknown values with an actionable error message (brave, searxng, ddg) instead of silently falling back to DDG - Change parse_searxng_json to return Result<Vec<SearchResult>> and propagate JSON parse errors via ZeptoError::Tool instead of swallowing them with an empty vec - Change SearxngSearchTool::new and with_max_results to return Result<Self>, removing all expect() panics from the constructor path; update call sites with ? propagation - Update unit tests: constructor calls use .unwrap(), parse success paths use .unwrap(), and test_parse_searxng_results_invalid_json asserts is_err() instead of is_empty() Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
providerfield toWebSearchConfigfor user choice ("brave","searxng","ddg")api_urlfield for self-hosted SearXNG instance URLapi_urlset → SearXNG,api_keyset → Brave, else → DuckDuckGoZEPTOCLAW_TOOLS_WEB_SEARCH_PROVIDER,ZEPTOCLAW_TOOLS_WEB_SEARCH_API_URLCloses #196
Test plan
cargo clippy -- -D warningsclean🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
Configuration
ZEPTOCLAW_TOOLS_WEB_SEARCH_PROVIDERto select search provider (brave, searxng, ddg)ZEPTOCLAW_TOOLS_WEB_SEARCH_API_URLto specify custom search API endpoint