gestura_core_tools/config.rs
1//! Tool-related configuration types.
2//!
3//! These types are owned by the tools domain because they primarily configure
4//! built-in tools (e.g. web search). The `gestura-core` facade re-exports them
5//! from its `config` module for backwards compatibility.
6
7use serde::{Deserialize, Serialize};
8
9// ============================================================================
10// Web Search Configuration
11// ============================================================================
12
13/// Web search provider selection.
14#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Default)]
15#[serde(rename_all = "lowercase")]
16pub enum WebSearchProvider {
17 /// Local HTTP-based search (no API key required) - DEFAULT.
18 ///
19 /// Uses DuckDuckGo HTML scraping with smart content extraction.
20 #[default]
21 Local,
22 /// SerpAPI provider (requires API key).
23 SerpApi,
24 /// DuckDuckGo Instant Answer API (no API key, limited results).
25 DuckDuckGo,
26 /// Brave Search API (requires API key).
27 Brave,
28}
29
30/// Web search configuration.
31#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
32#[serde(default)]
33pub struct WebSearchConfig {
34 /// Primary search provider.
35 pub provider: WebSearchProvider,
36 /// SerpAPI API key (optional).
37 pub serpapi_key: Option<String>,
38 /// Brave Search API key (optional).
39 pub brave_key: Option<String>,
40 /// Maximum number of search results to return.
41 pub max_results: usize,
42 /// Request timeout in seconds.
43 pub timeout_secs: u64,
44 /// User agent string for HTTP requests.
45 pub user_agent: String,
46 /// Enable content extraction from search result pages.
47 pub extract_content: bool,
48 /// Maximum content length per page (in characters).
49 pub max_content_length: usize,
50 /// Fallback providers if primary fails (in order).
51 pub fallback_providers: Vec<WebSearchProvider>,
52}
53
54impl Default for WebSearchConfig {
55 fn default() -> Self {
56 Self {
57 provider: WebSearchProvider::Local,
58 serpapi_key: None,
59 brave_key: None,
60 max_results: 5,
61 timeout_secs: 30,
62 user_agent: format!(
63 "Gestura/{} (+https://gestura.ai)",
64 env!("CARGO_PKG_VERSION")
65 ),
66 extract_content: true,
67 max_content_length: 10_000,
68 fallback_providers: vec![WebSearchProvider::DuckDuckGo],
69 }
70 }
71}