Skip to content

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

feat(desktop): add accessibility tree inspection and control ops

Steven Enamakelacd779967093
diff --git a/crates/openhuman-core/src/desktop/control/ops.rs b/crates/openhuman-core/src/desktop/control/ops.rs
index 5fea81e6b5..e4c5015d90 100644
--- a/crates/openhuman-core/src/desktop/control/ops.rs
+++ b/crates/openhuman-core/src/desktop/control/ops.rs
@@ -120,8 +120,13 @@ fn state_path(config: &Config) -> std::path::PathBuf {
.join("desktop-control.json")
}
+/// Effective desktop control: the `[components] computer` ceiling AND this
+/// machine's local consent. The flag can only remove access, never grant it.
/// Corrupt or unreadable local state fails closed, never enabling desktop access.
pub fn enabled(config: &Config) -> bool {
+ if !config.components.computer {
+ return false;
+ }
let _lock = STATE_LOCK
.lock()
.unwrap_or_else(std::sync::PoisonError::into_inner);
diff --git a/crates/openhuman-core/src/modules/accessibility.rs b/crates/openhuman-core/src/modules/accessibility.rs
index 0835a2f148..c184c590a1 100644
--- a/crates/openhuman-core/src/modules/accessibility.rs
+++ b/crates/openhuman-core/src/modules/accessibility.rs
@@ -34,12 +34,17 @@ impl std::error::Error for AccessibilityError {}
#[derive(Clone)]
pub struct AccessibilityClient {
client: ModuleClient,
+ /// `[components] computer`. Off refuses every call before the module is
+ /// touched; this client is compiled in unconditionally, so it carries the
+ /// ceiling itself.
+ computer_enabled: bool,
}
impl AccessibilityClient {
pub fn new(config: &Config) -> Self {
Self {
client: ModuleClient::new(config.clone()),
+ computer_enabled: config.components.computer,
}
}
@@ -47,6 +52,7 @@ impl AccessibilityClient {
pub(crate) fn fixture(proxy: tinybus::Proxy) -> Self {
Self {
client: ModuleClient::fixture(proxy),
+ computer_enabled: true,
}
}
@@ -56,6 +62,16 @@ impl AccessibilityClient {
args: impl Serialize,
confidential: bool,
) -> Result<T, AccessibilityError> {
+ if !self.computer_enabled {
+ log::debug!("[accessibility] {member} refused, component 'computer' disabled");
+ return Err(AccessibilityError::Operation(DesktopError::new(
+ crate::core::runtime::components::COMPONENT_DISABLED,
+ format!(
+ "{}:computer",
+ crate::core::runtime::components::COMPONENT_DISABLED
+ ),
+ )));
+ }
let raw: serde_json::Value = if confidential {
self.client.call_confidential(MODULE, member, args).await
} else {
@@ -65,6 +81,12 @@ impl AccessibilityClient {
decode(raw)
}
+ /// Whether `[components] computer` lets this client reach the module.
+ #[must_use]
+ pub fn computer_enabled(&self) -> bool {
+ self.computer_enabled
+ }
+
/// Read native states without requesting permission.
pub async fn permissions(&self) -> Result<PermissionStatus, AccessibilityError> {
self.call(methods::ACCESSIBILITY_PERMISSIONS, (), false)
diff --git a/crates/openhuman-core/src/tools/ops.rs b/crates/openhuman-core/src/tools/ops.rs
index 73a29c9114..0ec732fb89 100644
--- a/crates/openhuman-core/src/tools/ops.rs
+++ b/crates/openhuman-core/src/tools/ops.rs
@@ -189,10 +189,13 @@ pub fn all_tools_with_runtime(
tools.extend(crate::desktop::dashboard::tools::registered_tools(
config.clone(),
));
+ // `[components] computer = false` unregisters the desktop and browser tools.
#[cfg(feature = "modules")]
- tools.extend(crate::desktop::control::tools::registered_tools(
- config.clone(),
- ));
+ if config.components.computer {
+ tools.extend(crate::desktop::control::tools::registered_tools(
+ config.clone(),
+ ));
+ }
tools.extend(crate::security::tools::registered_tools(config.clone()));
tools.extend(crate::platform::service::tools::registered_tools(
config.clone(),
@@ -282,7 +285,7 @@ pub fn all_tools_with_runtime(
tools.extend(crate::agent::goals::goal_tools(&root_config.workspace_dir));
#[cfg(feature = "modules")]
- if browser_config.enabled {
+ if browser_config.enabled && config.components.computer {
// BrowserClient enforces the shared `http_request.allowed_domains`
// policy for both browser tools.
let browser_client = Arc::new(crate::modules::browser::BrowserClient::new(config.clone()));