pub struct WebScrapeExecutor { /* private fields */ }Expand description
Extracts data from web pages via CSS selectors.
Handles two invocation paths:
- Legacy fenced blocks — detects
```scrapeblocks in the LLM response, each containing a JSON scrape instruction object. Dispatched viaToolExecutor::execute. - Structured tool calls — dispatched via
ToolExecutor::execute_tool_callfor tool IDs"web_scrape"and"fetch".
§Security
- Only HTTPS URLs are accepted. HTTP and other schemes return
ToolError::InvalidParams. - DNS is resolved synchronously and each resolved address is checked against
is_private_ip. Private addresses are rejected to prevent SSRF. - HTTP redirects are disabled (
Policy::none()) to prevent open-redirect bypasses. - Domain allowlists and denylists from config are enforced before DNS resolution.
§Example
use zeph_tools::{WebScrapeExecutor, ToolExecutor, ToolCall, config::ScrapeConfig};
use zeph_common::ToolName;
let executor = WebScrapeExecutor::new(&ScrapeConfig::default());
let call = ToolCall {
tool_id: ToolName::new("fetch"),
params: {
let mut m = serde_json::Map::new();
m.insert("url".to_owned(), serde_json::json!("https://example.com"));
m
},
caller_id: None,
};
let _ = executor.execute_tool_call(&call).await;Implementations§
Source§impl WebScrapeExecutor
impl WebScrapeExecutor
Sourcepub fn new(config: &ScrapeConfig) -> Self
pub fn new(config: &ScrapeConfig) -> Self
Create a new WebScrapeExecutor from configuration.
No network connections are made at construction time.
Sourcepub fn with_audit(self, logger: Arc<AuditLogger>) -> Self
pub fn with_audit(self, logger: Arc<AuditLogger>) -> Self
Attach an audit logger. Each tool invocation will emit an AuditEntry.
Trait Implementations§
Source§impl Debug for WebScrapeExecutor
impl Debug for WebScrapeExecutor
Source§impl ToolExecutor for WebScrapeExecutor
impl ToolExecutor for WebScrapeExecutor
Source§fn tool_definitions(&self) -> Vec<ToolDef>
fn tool_definitions(&self) -> Vec<ToolDef>
Return the tool definitions this executor can handle. Read more
Source§async fn execute(&self, response: &str) -> Result<Option<ToolOutput>, ToolError>
async fn execute(&self, response: &str) -> Result<Option<ToolOutput>, ToolError>
Parse
response for fenced tool blocks and execute them. Read moreSource§async fn execute_tool_call(
&self,
call: &ToolCall,
) -> Result<Option<ToolOutput>, ToolError>
async fn execute_tool_call( &self, call: &ToolCall, ) -> Result<Option<ToolOutput>, ToolError>
Source§fn is_tool_retryable(&self, tool_id: &str) -> bool
fn is_tool_retryable(&self, tool_id: &str) -> bool
Whether the executor can safely retry this tool call on a transient error. Read more
Source§fn execute_confirmed(
&self,
response: &str,
) -> impl Future<Output = Result<Option<ToolOutput>, ToolError>> + Send
fn execute_confirmed( &self, response: &str, ) -> impl Future<Output = Result<Option<ToolOutput>, ToolError>> + Send
Execute bypassing confirmation checks (called after user approves). Read more
Source§fn execute_tool_call_confirmed(
&self,
call: &ToolCall,
) -> impl Future<Output = Result<Option<ToolOutput>, ToolError>> + Send
fn execute_tool_call_confirmed( &self, call: &ToolCall, ) -> impl Future<Output = Result<Option<ToolOutput>, ToolError>> + Send
Execute a structured tool call bypassing confirmation checks. Read more
Source§fn set_skill_env(&self, _env: Option<HashMap<String, String>>)
fn set_skill_env(&self, _env: Option<HashMap<String, String>>)
Inject environment variables for the currently active skill. No-op by default. Read more
Source§fn set_effective_trust(&self, _level: SkillTrustLevel)
fn set_effective_trust(&self, _level: SkillTrustLevel)
Set the effective trust level for the currently active skill. No-op by default. Read more
Auto Trait Implementations§
impl Freeze for WebScrapeExecutor
impl !RefUnwindSafe for WebScrapeExecutor
impl Send for WebScrapeExecutor
impl Sync for WebScrapeExecutor
impl Unpin for WebScrapeExecutor
impl UnsafeUnpin for WebScrapeExecutor
impl !UnwindSafe for WebScrapeExecutor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> ErasedToolExecutor for Twhere
T: ToolExecutor,
impl<T> ErasedToolExecutor for Twhere
T: ToolExecutor,
fn execute_erased<'a>( &'a self, response: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Option<ToolOutput>, ToolError>> + Send + 'a>>
fn execute_confirmed_erased<'a>( &'a self, response: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Option<ToolOutput>, ToolError>> + Send + 'a>>
fn tool_definitions_erased(&self) -> Vec<ToolDef>
fn execute_tool_call_erased<'a>( &'a self, call: &'a ToolCall, ) -> Pin<Box<dyn Future<Output = Result<Option<ToolOutput>, ToolError>> + Send + 'a>>
fn execute_tool_call_confirmed_erased<'a>( &'a self, call: &'a ToolCall, ) -> Pin<Box<dyn Future<Output = Result<Option<ToolOutput>, ToolError>> + Send + 'a>>
Source§fn set_skill_env(&self, env: Option<HashMap<String, String>>)
fn set_skill_env(&self, env: Option<HashMap<String, String>>)
Inject environment variables for the currently active skill. No-op by default.
Source§fn set_effective_trust(&self, level: SkillTrustLevel)
fn set_effective_trust(&self, level: SkillTrustLevel)
Set the effective trust level for the currently active skill. No-op by default.
Source§fn is_tool_retryable_erased(&self, tool_id: &str) -> bool
fn is_tool_retryable_erased(&self, tool_id: &str) -> bool
Whether the executor can safely retry this tool call on a transient error.