Expand description
Web interface handlers and routes. Web Browser Interface Trait for ReasonKit Core
This module defines the abstraction layer for reasonkit-core to interact with reasonkit-web’s browser automation and content extraction capabilities.
§Architecture
ReasonKit Core --> WebBrowserAdapter --> ReasonKit Web
(trait interface)
|- navigate()
|- extract_content()
`- capture_screenshot()§Design Principles
- Async-First: All operations use
async-traitfor future compatibility - Type-Safe: Strong types for URLs, content, and capture formats
- Error Handling: Comprehensive error types via
thiserror - Flexible Implementations: Support local MCP server, FFI, or HTTP bindings
- Performance: Connection pooling and caching by default
§Example
use reasonkit::web_interface::{WebBrowserAdapter, NavigateOptions, CaptureFormat};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Implementation will use concrete adapter (e.g., McpWebAdapter, HttpWebAdapter)
// let adapter = McpWebAdapter::new(config).await?;
// Navigate to URL
// let page = adapter.navigate(
// "https://example.com",
// NavigateOptions::default(),
// ).await?;
// Extract main content
// let content = adapter.extract_content(
// &page,
// ExtractOptions::default(),
// ).await?;
// Capture screenshot
// let screenshot = adapter.capture_screenshot(
// &page,
// CaptureOptions::default().format(CaptureFormat::Png),
// ).await?;
Ok(())
}Structs§
- Capture
Metadata - Capture metadata
- Capture
Options - Options for page capture/screenshot
- Captured
Page - Captured page content/screenshot
- Content
Metadata - Content metadata
- Extract
Options - Options for content extraction
- Extracted
Content - Extracted content from a page
- Extracted
Image - Extracted image from content
- Extracted
Link - Extracted link from content
- Navigate
Options - Options for page navigation
- Page
Handle - Represents a page/tab in the browser
Enums§
- Capture
Format - Screenshot/capture format
- Navigate
Wait Event - Page load wait event
- WebAdapter
Error - Web browser adapter error types
Traits§
- WebBrowser
Adapter - Web browser adapter trait for reasonkit-core
Type Aliases§
- WebAdapter
Result - Result type alias for web adapter operations