feat: add HTTP request tool for API interactions
Implements #210 - Add http_request tool that enables the agent to make HTTP requests to external APIs. Features: - Supports GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS methods - JSON request/response handling - Configurable timeout (default: 30s) - Configurable max response size (default: 1MB) - Security: domain allowlist, blocks local/private IPs (SSRF protection) - Headers support with auth token redaction Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
9bdbc1287c
commit
1140a7887d
6 changed files with 875 additions and 8 deletions
|
|
@ -62,6 +62,9 @@ pub struct Config {
|
|||
#[serde(default)]
|
||||
pub browser: BrowserConfig,
|
||||
|
||||
#[serde(default)]
|
||||
pub http_request: HttpRequestConfig,
|
||||
|
||||
#[serde(default)]
|
||||
pub identity: IdentityConfig,
|
||||
|
||||
|
|
@ -272,6 +275,32 @@ pub struct BrowserConfig {
|
|||
pub session_name: Option<String>,
|
||||
}
|
||||
|
||||
// ── HTTP request tool ───────────────────────────────────────────
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||||
pub struct HttpRequestConfig {
|
||||
/// Enable `http_request` tool for API interactions
|
||||
#[serde(default)]
|
||||
pub enabled: bool,
|
||||
/// Allowed domains for HTTP requests (exact or subdomain match)
|
||||
#[serde(default)]
|
||||
pub allowed_domains: Vec<String>,
|
||||
/// Maximum response size in bytes (default: 1MB)
|
||||
#[serde(default = "default_http_max_response_size")]
|
||||
pub max_response_size: usize,
|
||||
/// Request timeout in seconds (default: 30)
|
||||
#[serde(default = "default_http_timeout_secs")]
|
||||
pub timeout_secs: u64,
|
||||
}
|
||||
|
||||
fn default_http_max_response_size() -> usize {
|
||||
1_000_000 // 1MB
|
||||
}
|
||||
|
||||
fn default_http_timeout_secs() -> u64 {
|
||||
30
|
||||
}
|
||||
|
||||
// ── Memory ───────────────────────────────────────────────────
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
|
|
@ -906,6 +935,7 @@ impl Default for Config {
|
|||
composio: ComposioConfig::default(),
|
||||
secrets: SecretsConfig::default(),
|
||||
browser: BrowserConfig::default(),
|
||||
http_request: HttpRequestConfig::default(),
|
||||
identity: IdentityConfig::default(),
|
||||
agents: HashMap::new(),
|
||||
}
|
||||
|
|
@ -1257,6 +1287,7 @@ mod tests {
|
|||
composio: ComposioConfig::default(),
|
||||
secrets: SecretsConfig::default(),
|
||||
browser: BrowserConfig::default(),
|
||||
http_request: HttpRequestConfig::default(),
|
||||
identity: IdentityConfig::default(),
|
||||
agents: HashMap::new(),
|
||||
};
|
||||
|
|
@ -1329,6 +1360,7 @@ default_temperature = 0.7
|
|||
composio: ComposioConfig::default(),
|
||||
secrets: SecretsConfig::default(),
|
||||
browser: BrowserConfig::default(),
|
||||
http_request: HttpRequestConfig::default(),
|
||||
identity: IdentityConfig::default(),
|
||||
agents: HashMap::new(),
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue