Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 46 additions & 1 deletion crates/openhuman-core/src/modules/browser_egress_host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,56 @@ pub(crate) fn browser_dial_alias(config: &crate::config::Config) -> Value {
alias
}

/// The `browser.egress` section TinyComputer's callback-bound load admitted.
/// TinyBus refuses that module any later config with different bytes
/// ("scoped callback configuration is immutable"), so an edited or rotated
/// `[browser] upstream_proxies` must not reach a refresh: it would fail every
/// browser call until restart. Refreshes reuse what was admitted instead, and
/// the edit takes effect at the next load.
fn admitted_alias() -> &'static parking_lot::Mutex<Option<Value>> {
static ADMITTED: std::sync::OnceLock<parking_lot::Mutex<Option<Value>>> =
std::sync::OnceLock::new();
ADMITTED.get_or_init(|| parking_lot::Mutex::new(None))
}

/// Build the alias for a callback-bound load and record it as admitted.
pub(crate) fn admit_browser_dial_alias(config: &crate::config::Config) -> Value {
admit_in(admitted_alias(), config)
}

fn admit_in(slot: &parking_lot::Mutex<Option<Value>>, config: &crate::config::Config) -> Value {
let alias = browser_dial_alias(config);
*slot.lock() = Some(alias.clone());
alias
}

/// The alias a refresh pushes: the admitted one when a load recorded it, so a
/// changed proxy list never makes TinyBus refuse the refresh.
fn refresh_alias_in(
slot: &parking_lot::Mutex<Option<Value>>,
config: &crate::config::Config,
) -> Value {
let current = browser_dial_alias(config);
match slot.lock().as_ref() {
Some(admitted) => {
if *admitted != current {
// Never the URLs: they carry credentials.
tracing::warn!(
"[computer] [browser] upstream_proxies changed since TinyComputer loaded; \
the change takes effect at the next core start"
);
}
admitted.clone()
}
None => current,
}
}

/// Make sure the browser's destination-only policy is registered for this
/// host context, then return the stable alias for TinyComputer config.
pub(crate) async fn browser_dial_config(config: &crate::config::Config) -> Result<Value, String> {
current_browser_policy(config).await?;
Ok(browser_dial_alias(config))
Ok(refresh_alias_in(admitted_alias(), config))
}

/// The id and generation of the current browser policy, registering a new one
Expand Down
34 changes: 34 additions & 0 deletions crates/openhuman-core/src/modules/browser_egress_host_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,40 @@ fn the_config_names_a_stable_alias_not_the_rotating_policy() {
assert_eq!(alias.as_object().unwrap().len(), 2);
}

#[test]
fn a_refresh_keeps_the_upstream_proxies_admitted_at_load() {
// TinyBus refuses a callback-bound refresh whose bytes differ from the
// load's, so an edited or rotated proxy list must wait for the next load.
let slot = parking_lot::Mutex::new(None);
let mut loaded = crate::config::Config::default();
loaded.browser.upstream_proxies = vec![crate::config::schema::BrowserUpstreamProxy {
domains: vec!["reddit.com".into()],
url: "http://resi:old@gate.example:7000".into(),
}];
let admitted = admit_in(&slot, &loaded);

let mut edited = loaded.clone();
edited.browser.upstream_proxies[0].url = "http://resi:rotated@gate.example:7000".into();
assert_eq!(refresh_alias_in(&slot, &edited), admitted);
let mut removed = loaded.clone();
removed.browser.upstream_proxies.clear();
assert_eq!(refresh_alias_in(&slot, &removed), admitted);
assert_eq!(refresh_alias_in(&slot, &loaded), admitted);

// Before any load, a refresh builds from the current config.
let empty = parking_lot::Mutex::new(None);
assert_eq!(
refresh_alias_in(&empty, &edited),
browser_dial_alias(&edited)
);
// The next load admits the edit.
assert_eq!(admit_in(&slot, &edited), browser_dial_alias(&edited));
assert_eq!(
refresh_alias_in(&slot, &edited),
browser_dial_alias(&edited)
);
}

#[test]
fn configured_upstream_proxies_ride_in_the_private_egress_section() {
let mut config = crate::config::Config::default();
Expand Down
2 changes: 1 addition & 1 deletion crates/openhuman-core/src/modules/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ pub(super) async fn computer_callback_config(
let mut module_config = module_config(config, id).await;
super::desktop::inject_security_browser_config(
&mut module_config,
super::browser_egress_host::browser_dial_alias(config),
super::browser_egress_host::admit_browser_dial_alias(config),
callback_destination,
);
module_config
Expand Down
16 changes: 16 additions & 0 deletions crates/openhuman-core/src/platform/about_app/catalog_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,3 +573,19 @@ fn computer_capabilities_disclose_the_components_ceiling() {
);
}
}

#[test]
fn browser_automation_discloses_the_optional_upstream_proxy() {
let capability =
lookup("workflows.computer_browser_automation").expect("browser automation is listed");
assert!(capability
.description
.contains("[browser] upstream_proxies"));
let privacy = capability.privacy.expect("browser automation has privacy");
assert!(privacy
.destinations
.iter()
.any(|destination| destination.contains("upstream HTTP proxy")
&& destination.contains("[browser] upstream_proxies")
&& destination.contains("next core start")));
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ Capability {
name: "Browser Automation",
domain: "workflows",
category: CapabilityCategory::Workflows,
description: "Inspect pages and run bounded browser tasks in Chrome through TinyComputer, with a rescue model for failed steps. A finished task's plan and the page elements it found are kept per site in the core's workspace, so the next task there starts sooner. Switched off by [components] computer = false, which unregisters the browser tools and answers the browser RPCs with COMPONENT_DISABLED:computer.",
description: "Inspect pages and run bounded browser tasks in Chrome through TinyComputer, with a rescue model for failed steps. A finished task's plan and the page elements it found are kept per site in the core's workspace, so the next task there starts sooner. An operator can route chosen domains through an upstream HTTP proxy ([browser] upstream_proxies) for sites that block this machine’s own address; TinySecurity still authorizes every routed page and the proxy itself. Switched off by [components] computer = false, which unregisters the browser tools and answers the browser RPCs with COMPONENT_DISABLED:computer.",
how_to: "Connections > Computer > Browser, then ask the assistant to use the browser; What tasks learn turns learning off or forgets learned sites",
status: CapabilityStatus::Beta,
privacy: Some(CapabilityPrivacy {
leaves_device: true,
data_kind: PrivacyDataKind::Raw,
destinations: &["Visited websites", "OpenRouter, OpenHuman backend, OpenJev or Sage for task decisions", "TypeSafe or Surplus Intelligence for captcha images, only when the captcha solver is on (captcha_provider)"],
destinations: &["Visited websites", "OpenRouter, OpenHuman backend, OpenJev or Sage for task decisions", "TypeSafe or Surplus Intelligence for captcha images, only when the captcha solver is on (captcha_provider)", "The operator’s upstream HTTP proxy, for the domains in [browser] upstream_proxies, only when set; adding, changing or removing it takes effect at the next core start"],
}),
},
Capability {
Expand Down
10 changes: 10 additions & 0 deletions scripts/ci/process-statics.json
Original file line number Diff line number Diff line change
Expand Up @@ -958,5 +958,15 @@
"category": "B",
"reason": "Prepared program quotes are partitioned by QuoteBinding (workspace path, a hash of the encrypted phrase, account index and Solana endpoint). A take is refused, and the quote stays in the map, unless all four match the context that takes it.",
"verification": "web3/wallet/program/ops_tests.rs: a_quote_is_taken_only_in_the_context_it_was_prepared_in"
},
{
"file": "crates/openhuman-core/src/modules/browser_egress_host.rs",
"scope": "",
"name": "ADMITTED",
"type": "std::sync::OnceLock<parking_lot::Mutex<Option<Value>>>",
"count": 1,
"category": "A",
"reason": "The browser.egress section TinyComputer's callback-bound load admitted. TinyComputer is one module per process with one host config, and TinyBus refuses a refresh that differs from what was loaded, so this mirrors the module's own process-wide config. It holds the operator's [browser] upstream_proxies (process configuration), never tenant data.",
"verification": "modules/browser_egress_host_tests.rs: a_refresh_keeps_the_upstream_proxies_admitted_at_load"
}
]
Loading