Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(browser): handle empty browser history gracefully

Steven Enamakele26e079776f2
diff --git a/crates/openhuman-core/src/tools/impl/browser/browser.rs b/crates/openhuman-core/src/tools/impl/browser/browser.rs
index b1016899f6..5b4a0e3576 100644
--- a/crates/openhuman-core/src/tools/impl/browser/browser.rs
+++ b/crates/openhuman-core/src/tools/impl/browser/browser.rs
@@ -19,6 +19,55 @@ mod types;
#[cfg(test)]
#[path = "browser_tests.rs"]
mod tests;
-include!("browser_part_01.rs");
-include!("browser_part_02.rs");
-include!("browser_part_03.rs");
+
+#[path = "browser_backend_resolution.rs"]
+mod backend_resolution;
+#[path = "browser_computer_use.rs"]
+mod computer_use_actions;
+#[path = "browser_construction.rs"]
+mod construction;
+#[path = "browser_execution.rs"]
+mod execution;
+#[path = "browser_tool_impl.rs"]
+mod tool_impl;
+
+use super::playwright_backend;
+#[allow(unused_imports)]
+pub(super) use action_parser::{
+ backend_name, is_computer_use_only_action, is_supported_browser_action, parse_browser_action,
+ unavailable_action_for_backend_error,
+};
+pub(super) use security::{
+ allow_all_browser_domains, endpoint_reachable, extract_host, host_matches_allowlist,
+ is_private_host, normalize_domains,
+};
+pub(super) use types::{
+ AgentBrowserResponse, BrowserBackendKind, ComputerUseResponse, ResolvedBackend,
+};
+pub use types::{BrowserAction, ComputerUseConfig};
+
+use crate::security::SecurityPolicy;
+use crate::tools::traits::{Tool, ToolResult};
+use anyhow::Context;
+use async_trait::async_trait;
+use serde_json::{json, Value};
+use std::process::Stdio;
+use std::sync::Arc;
+use std::time::Duration;
+use tokio::process::Command;
+use tracing::debug;
+
+/// Browser automation tool using pluggable backends.
+pub struct BrowserTool {
+ security: Arc<SecurityPolicy>,
+ allowed_domains: Vec<String>,
+ session_name: Option<String>,
+ backend: String,
+ native_headless: bool,
+ native_webdriver_url: String,
+ native_chrome_path: Option<String>,
+ computer_use: ComputerUseConfig,
+ playwright_state: tokio::sync::Mutex<playwright_backend::PlaywrightBrowserState>,
+ #[cfg(feature = "browser-native")]
+ native_state: tokio::sync::Mutex<native_backend::NativeBrowserState>,
+}