The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
chore: files changed crates/openhuman-core/src/config/schema/tools/browser.rs,crates/openhuman-core/
Steven Enamakel8efea6924d41
diff --git a/crates/openhuman-core/src/config/schema/tools/browser.rs b/crates/openhuman-core/src/config/schema/tools/browser.rsindex 37ace44cc1..ed93590d88 100644--- a/crates/openhuman-core/src/config/schema/tools/browser.rs+++ b/crates/openhuman-core/src/config/schema/tools/browser.rs@@ -118,16 +118,22 @@ impl BrowserConfig {/// Whether `kind` is a known gated action listed in `unattended_actions`./// Says nothing about the turn; callers check its origin separately.pub fn allows_unattended(&self, kind: &str) -> bool {- UNATTENDED_BROWSER_ACTIONS.contains(&kind)- && self- .unattended_actions- .iter()- .any(|listed| normalized_action(listed) == kind)+ self.unattended_kind(kind).is_some()}- /// The canonical name of `kind` when it is allowed unattended.- pub fn unattended_kind(&self, _kind: &str) -> Option<&'static str> {- None+ /// The canonical, static name of `kind` when it is a known gated action+ /// listed in `unattended_actions`. Both sides are trimmed and lowercased.+ /// Being static, it is safe to log whatever the caller passed in.+ pub fn unattended_kind(&self, kind: &str) -> Option<&'static str> {+ let kind = normalized_action(kind);+ let canonical = UNATTENDED_BROWSER_ACTIONS+ .iter()+ .copied()+ .find(|known| *known == kind)?;+ self.unattended_actions+ .iter()+ .any(|listed| normalized_action(listed) == canonical)+ .then_some(canonical)}/// Entries of `unattended_actions` that name no known action kind. Theydiff --git a/crates/openhuman-core/src/tools/impl/browser/browser_unattended.rs b/crates/openhuman-core/src/tools/impl/browser/browser_unattended.rsindex 3288a0e0ef..0df959d6b9 100644--- a/crates/openhuman-core/src/tools/impl/browser/browser_unattended.rs+++ b/crates/openhuman-core/src/tools/impl/browser/browser_unattended.rs@@ -26,35 +26,52 @@ fn is_unattended(origin: &AgentTurnOrigin) -> bool {)}+/// The canonical name of `kind` when a turn with `origin` may take it+/// without the approval gate.+fn unattended_kind(+ origin: Option<&AgentTurnOrigin>,+ browser: &BrowserConfig,+ kind: &str,+) -> Option<&'static str> {+ origin+ .is_some_and(is_unattended)+ .then(|| browser.unattended_kind(kind))+ .flatten()+}+/// Whether a turn with `origin` may take `kind` without the approval gate.pub(super) fn allowed_for(origin: Option<&AgentTurnOrigin>,browser: &BrowserConfig,kind: &str,) -> bool {- origin.is_some_and(is_unattended) && browser.allows_unattended(kind)+ unattended_kind(origin, browser, kind).is_some()}/// Decide for the turn `origin` the tool was called under (read once from the/// per-turn `CoreContext` in `BrowserTool::execute`), logging an allowed-/// action by kind and digest only: no selector, typed value or page content-/// reaches the log.+/// action by its canonical static kind and digest only: no caller-supplied+/// string, selector, typed value or page content reaches the log.pub(super) fn allow(origin: Option<&AgentTurnOrigin>,browser: &BrowserConfig,kind: &str,digest_hex: &str,) -> bool {- let allowed = allowed_for(origin, browser, kind);- if allowed {- tracing::info!(- action = kind,- action_digest = %digest_hex.get(..12).unwrap_or(digest_hex),- origin = %origin.map(AgentTurnOrigin::class).unwrap_or_default(),- "[browser] unattended action allowed by [browser] unattended_actions"- );- }- allowed+ let Some(canonical) = unattended_kind(origin, browser, kind) else {+ return false;+ };+ let digest = digest_hex+ .get(..12)+ .filter(|prefix| prefix.chars().all(|c| c.is_ascii_hexdigit()))+ .unwrap_or("invalid");+ tracing::info!(+ action = canonical,+ action_digest = digest,+ origin = %origin.map(AgentTurnOrigin::class).unwrap_or_default(),+ "[browser] unattended action allowed by [browser] unattended_actions"+ );+ true}#[cfg(test)]diff --git a/crates/openhuman-core/src/tools/impl/browser/browser_unattended_tests.rs b/crates/openhuman-core/src/tools/impl/browser/browser_unattended_tests.rsindex a9856d1ab0..f8f0495e43 100644--- a/crates/openhuman-core/src/tools/impl/browser/browser_unattended_tests.rs+++ b/crates/openhuman-core/src/tools/impl/browser/browser_unattended_tests.rs@@ -305,3 +305,28 @@ async fn the_tool_keeps_every_other_turn_and_action_behind_the_gate() {assert!(!output.is_empty(), "{origin:?}");}}++#[tokio::test]+async fn allow_logs_the_canonical_kind_not_the_callers_string() {+ let _serial = ALLOW_PATH.lock().await;+ let (logs, _guard) = Logs::capture();+ assert!(allow(+ Some(&cron()),+ &listing(&["click"]),+ " CLICK ",+ "not-hex-digest"+ ));+ let text = logs.text();+ let line = text+ .lines()+ .find(|line| line.contains(ALLOWED_LINE))+ .unwrap();+ assert!(+ line.contains("action=\"click\"") || line.contains("action=click"),+ "{line}"+ );+ assert!(+ !line.contains(" CLICK ") && !line.contains("not-hex"),+ "{line}"+ );+}