pub struct BrowserToolset { /* private fields */ }Expand description
A toolset that provides all browser automation tools.
Use this to add all browser tools to an agent at once, or use individual tools for more control.
Two defaults limit what a model can reach through the browser:
browser_evaluate_js, which runs model-written JavaScript in the page, is off untilwith_evaluate_jsorwith_jsenables it.- Navigation accepts only
httpandhttpsURLs untilwith_allowed_schemessays otherwise, sofile:,javascript:,data:, and browser-internal URLs are refused.
Implementations§
Source§impl BrowserToolset
impl BrowserToolset
Sourcepub fn new(browser: Arc<BrowserSession>) -> Self
pub fn new(browser: Arc<BrowserSession>) -> Self
Create a new toolset with every tool enabled except browser_evaluate_js.
Equivalent to with_profile with BrowserProfile::Full.
Sourcepub fn with_pool(pool: Arc<BrowserSessionPool>) -> Self
pub fn with_pool(pool: Arc<BrowserSessionPool>) -> Self
Create a pool-backed toolset with every tool enabled except browser_evaluate_js.
Sessions are resolved per-user at runtime via Toolset::tools(ctx).
The pool calls get_or_create(ctx.user_id()) to obtain an isolated
browser session for each user.
§Example
use adk_browser::{BrowserToolset, BrowserSessionPool, BrowserConfig};
use std::sync::Arc;
let pool = Arc::new(BrowserSessionPool::new(BrowserConfig::default()));
let toolset = BrowserToolset::with_pool(pool);Sourcepub fn with_pool_and_profile(
pool: Arc<BrowserSessionPool>,
profile: BrowserProfile,
) -> Self
pub fn with_pool_and_profile( pool: Arc<BrowserSessionPool>, profile: BrowserProfile, ) -> Self
Create a pool-backed toolset with a pre-configured profile.
Combines pool-backed session resolution with profile-based tool category selection.
§Example
use adk_browser::{BrowserToolset, BrowserProfile, BrowserSessionPool, BrowserConfig};
use std::sync::Arc;
let pool = Arc::new(BrowserSessionPool::new(BrowserConfig::default()));
let toolset = BrowserToolset::with_pool_and_profile(pool, BrowserProfile::Minimal);Sourcepub fn with_profile(
browser: Arc<BrowserSession>,
profile: BrowserProfile,
) -> Self
pub fn with_profile( browser: Arc<BrowserSession>, profile: BrowserProfile, ) -> Self
Create a toolset with a pre-configured profile.
This is the recommended way to create a toolset for most agents.
Using BrowserProfile::Full is equivalent to BrowserToolset::new().
Enable or disable navigation tools.
Sourcepub fn with_interaction(self, enabled: bool) -> Self
pub fn with_interaction(self, enabled: bool) -> Self
Enable or disable interaction tools.
Sourcepub fn with_extraction(self, enabled: bool) -> Self
pub fn with_extraction(self, enabled: bool) -> Self
Enable or disable extraction tools.
Sourcepub fn with_screenshot(self, enabled: bool) -> Self
pub fn with_screenshot(self, enabled: bool) -> Self
Enable or disable screenshot tool.
Sourcepub fn with_js(self, enabled: bool) -> Self
pub fn with_js(self, enabled: bool) -> Self
Enable or disable every JavaScript tool: scroll, hover, alert handling, and
browser_evaluate_js.
with_js(true) is an explicit opt-in to browser_evaluate_js, which runs
model-written JavaScript in the page. To keep the helpers without it, follow
with .with_evaluate_js(false).
Sourcepub fn with_evaluate_js(self, enabled: bool) -> Self
pub fn with_evaluate_js(self, enabled: bool) -> Self
Enable or disable browser_evaluate_js.
Off by default. The tool runs arbitrary model-written JavaScript in the current page, with the page’s cookies and session, so a prompt-injected page can steer it. Enable it only for agents that need it.
§Example
use adk_browser::{BrowserConfig, BrowserSession, BrowserToolset};
use std::sync::Arc;
let browser = Arc::new(BrowserSession::new(BrowserConfig::default()));
let toolset = BrowserToolset::new(browser).with_evaluate_js(true);Sourcepub fn with_allowed_schemes<I, S>(self, schemes: I) -> Self
pub fn with_allowed_schemes<I, S>(self, schemes: I) -> Self
Replace the URL schemes browser_navigate, browser_new_tab, and
browser_new_window accept.
Defaults to DEFAULT_ALLOWED_SCHEMES
(http, https). Schemes are compared case-insensitively. Allowing file
exposes the host filesystem to the model, and allowing javascript or data
lets it run script without browser_evaluate_js.
§Example
use adk_browser::{BrowserConfig, BrowserSession, BrowserToolset};
use std::sync::Arc;
let browser = Arc::new(BrowserSession::new(BrowserConfig::default()));
// HTTPS only.
let toolset = BrowserToolset::new(browser).with_allowed_schemes(["https"]);Enable or disable cookie management tools.
Sourcepub fn with_windows(self, enabled: bool) -> Self
pub fn with_windows(self, enabled: bool) -> Self
Enable or disable window/tab management tools.
Sourcepub fn with_frames(self, enabled: bool) -> Self
pub fn with_frames(self, enabled: bool) -> Self
Enable or disable frame/iframe management tools.
Sourcepub fn with_actions(self, enabled: bool) -> Self
pub fn with_actions(self, enabled: bool) -> Self
Enable or disable advanced action tools.