Skip to content

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

feat(browser): add module for browser automation

Steven Enamakel46eed9c2e266
diff --git a/crates/openhuman-core/src/modules/browser.rs b/crates/openhuman-core/src/modules/browser.rs
index 3b50f07c30..c1e4ab98da 100644
--- a/crates/openhuman-core/src/modules/browser.rs
+++ b/crates/openhuman-core/src/modules/browser.rs
@@ -394,7 +394,42 @@ impl BrowserClient {
if raw.eq_ignore_ascii_case("about:blank") {
return Ok(());
}
- self.check_url(raw)
+ // A navigation that failed (DNS, a refused or reset connection, a
+ // certificate) leaves Chrome on its own error page. Refusing it as
+ // a policy breach hid the failure: an agent read "only HTTPS URLs"
+ // and kept clicking. Say the page did not load.
+ if raw
+ .get(..CHROME_ERROR_SCHEME.len())
+ .is_some_and(|s| s.eq_ignore_ascii_case(CHROME_ERROR_SCHEME))
+ {
+ return Err(BrowserCallError::Bus {
+ name: "PageLoadFailed".into(),
+ message: "the page failed to load (Chrome showed its error page); \
+ the site or the network refused it"
+ .into(),
+ });
+ }
+ // Name the scheme the page is on, never the rest of its address: a
+ // log then says what it was without keeping what was in it.
+ self.check_url(raw).map_err(|error| match error {
+ BrowserCallError::Policy(reason) if reason == "only HTTPS URLs are allowed" => {
+ let scheme = raw.split_once(':').map_or("", |(scheme, _)| scheme);
+ let scheme = if !scheme.is_empty()
+ && scheme.len() <= 32
+ && scheme
+ .chars()
+ .all(|c| c.is_ascii_alphanumeric() || matches!(c, '+' | '-' | '.'))
+ {
+ format!("{}:", scheme.to_ascii_lowercase())
+ } else {
+ "an unknown scheme".into()
+ };
+ BrowserCallError::Policy(format!(
+ "only HTTPS URLs are allowed (the page is on {scheme})"
+ ))
+ }
+ other => other,
+ })
}
/// Whether the allowed websites are "Allow all" (`*`): the browser may