Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
feat(cua-driver): centralize protected resource grants per runtime (#2577)
Francesco Bonaccidfb3781460f0
diff --git a/libs/cua-driver/rust/crates/cua-driver-core/src/authorization.rs b/libs/cua-driver/rust/crates/cua-driver-core/src/authorization.rsindex afc7bf1a94..02cc3107fc 100644--- a/libs/cua-driver/rust/crates/cua-driver-core/src/authorization.rs+++ b/libs/cua-driver/rust/crates/cua-driver-core/src/authorization.rs@@ -1059,6 +1059,16 @@ pub fn validate_startup_authorization() -> anyhow::Result<()> {/// Content-free authorization state suitable for status/health output.pub fn status_json() -> serde_json::Value {+ status_json_with_provider(None)+}++/// Content-free authorization state for one runtime-owned provider.+///+/// Provider identity is runtime state, never a process-global first-writer+/// value: multiple direct runtimes may install different trusted hosts.+pub fn status_json_with_provider(+ protected_consent_collector: Option<&'static str>,+) -> serde_json::Value {let mode = configured_permission_mode();let policy = crate::policy::configured_policy();let managed_policy = crate::policy::configured_managed_policy();@@ -1119,7 +1129,7 @@ pub fn status_json() -> serde_json::Value {"effective_metadata_only_risk_enforcement": effective_metadata_only_risk_enforcement,"effective_not_exposed_risk_enforcement": effective_not_exposed_risk_enforcement,"enforcement_adapters": enforcement_adapter_inventory_json(),- "protected_consent_collector": crate::consent::configured_provider_id(),+ "protected_consent_collector": protected_consent_collector,"session_policy_configured": std::env::var_os(crate::session_manifest::SESSION_POLICY_FILE_ENV).is_some(),"session_policy_approved_at_startup": env_flag(crate::session_manifest::SESSION_POLICY_APPROVED_ENV),"session_policy_valid": session_policy.is_ok(),diff --git a/libs/cua-driver/rust/crates/cua-driver-core/src/browser/engine.rs b/libs/cua-driver/rust/crates/cua-driver-core/src/browser/engine.rsindex 43c8e7cb3b..72613e259d 100644--- a/libs/cua-driver/rust/crates/cua-driver-core/src/browser/engine.rs+++ b/libs/cua-driver/rust/crates/cua-driver-core/src/browser/engine.rs@@ -77,7 +77,7 @@ pub struct BrowserEngine {pub(crate) pool: CdpPool,pub(crate) managed_browsers: ManagedBrowsers,pub(crate) existing_profile_grants: ExistingProfileGrants,- pub(crate) approval_broker: crate::consent::ApprovalBroker,+ pub(crate) approval_broker: Arc<crate::consent::ApprovalBroker>,mutation_gates: MutationGates,reconnect_gates: ReconnectGates,session_end_hook: Mutex<Option<crate::session::SessionEndHookRegistration>>,@@ -525,7 +525,10 @@ impl BrowserEngine {/// capability store. Platform crates call this once and register/// the five tools via `register_browser_tools`.pub fn new(platform: Arc<dyn BrowserPlatform>) -> Arc<Self> {- Self::new_with_protected_consent_provider(platform, None)+ Self::new_with_approval_broker(+ platform,+ Arc::new(crate::consent::ApprovalBroker::unavailable()),+ )}/// Create an engine with a provider installed by a trusted embedding host@@ -534,6 +537,18 @@ impl BrowserEngine {pub fn new_with_protected_consent_provider(platform: Arc<dyn BrowserPlatform>,provider: Option<Arc<dyn crate::consent::ProtectedConsentProvider>>,+ ) -> Arc<Self> {+ Self::new_with_approval_broker(+ platform,+ Arc::new(crate::consent::ApprovalBroker::new(provider)),+ )+ }++ /// Create an engine using the runtime-owned broker shared by every+ /// protected resource adapter.+ pub fn new_with_approval_broker(+ platform: Arc<dyn BrowserPlatform>,+ approval_broker: Arc<crate::consent::ApprovalBroker>,) -> Arc<Self> {let engine = Arc::new(Self {platform,@@ -541,7 +556,7 @@ impl BrowserEngine {pool: CdpPool::new(),managed_browsers: Default::default(),existing_profile_grants: ExistingProfileGrants::new(),- approval_broker: crate::consent::ApprovalBroker::new(provider),+ approval_broker,mutation_gates: MutationGates::new(),reconnect_gates: ReconnectGates::new(),session_end_hook: Mutex::new(None),diff --git a/libs/cua-driver/rust/crates/cua-driver-core/src/consent.rs b/libs/cua-driver/rust/crates/cua-driver-core/src/consent.rsindex 30b2567281..e94eba00e0 100644--- a/libs/cua-driver/rust/crates/cua-driver-core/src/consent.rs+++ b/libs/cua-driver/rust/crates/cua-driver-core/src/consent.rs@@ -7,9 +7,10 @@//! implementations must authenticate their private channel before adapting it//! to this interface.+use std::collections::HashMap;use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};-use std::sync::{Arc, OnceLock};-use std::time::{Duration, SystemTime, UNIX_EPOCH};+use std::sync::{Arc, Mutex};+use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};use async_trait::async_trait;use serde::{Deserialize, Serialize};@@ -20,11 +21,6 @@ use uuid::Uuid;use crate::authorization::{PermissionMode, RiskClass};const DEFAULT_REQUEST_TTL: Duration = Duration::from_secs(2 * 60);-static CONFIGURED_PROVIDER_ID: OnceLock<&'static str> = OnceLock::new();--pub fn configured_provider_id() -> Option<&'static str> {- CONFIGURED_PROVIDER_ID.get().copied()-}#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "snake_case")]@@ -147,9 +143,6 @@ impl ApprovalBroker {}pub fn new(provider: Option<Arc<dyn ProtectedConsentProvider>>) -> Self {- if let Some(provider) = provider.as_ref() {- let _ = CONFIGURED_PROVIDER_ID.set(provider.provider_id());- }Self {daemon_instance: Arc::from(Uuid::new_v4().to_string()),next_generation: Arc::new(AtomicU64::new(1)),@@ -173,6 +166,32 @@ impl ApprovalBroker {transport_session: impl Into<String>,resource: Value,human_summary: impl Into<String>,+ ) -> ConsentRequest {+ self.request_bound(+ permission_mode,+ operation,+ risk_class,+ public_session,+ transport_session,+ resource,+ human_summary,+ crate::policy::managed_policy_sha256().ok().flatten(),+ crate::policy::user_policy_sha256().ok().flatten(),+ )+ }++ #[allow(clippy::too_many_arguments)]+ pub fn request_bound(+ &self,+ permission_mode: PermissionMode,+ operation: impl Into<String>,+ risk_class: RiskClass,+ public_session: impl Into<String>,+ transport_session: impl Into<String>,+ resource: Value,+ human_summary: impl Into<String>,+ managed_policy_sha256: Option<String>,+ user_policy_sha256: Option<String>,) -> ConsentRequest {let expires_unix_ms = now_unix_ms() + DEFAULT_REQUEST_TTL.as_millis();let mut request = ConsentRequest {@@ -181,8 +200,8 @@ impl ApprovalBroker {generation: self.next_generation.fetch_add(1, Ordering::Relaxed),daemon_instance: self.daemon_instance.to_string(),permission_mode,- managed_policy_sha256: crate::policy::managed_policy_sha256().ok().flatten(),- user_policy_sha256: crate::policy::user_policy_sha256().ok().flatten(),+ managed_policy_sha256,+ user_policy_sha256,operation: operation.into(),risk_class,public_session: public_session.into(),@@ -280,6 +299,219 @@ impl ApprovalBroker {}}+#[derive(Debug, Clone, PartialEq, Eq, Hash)]+struct ResourceGrantKey {+ runtime_scope: String,+ public_session: String,+ transport_session: String,+ adapter_id: String,+ resource_digest: String,+}++#[derive(Debug, Clone)]+pub struct ResourceGrant {+ pub adapter_id: String,+ pub resource_digest: String,+ pub protected: ProtectedGrant,+ mode: PermissionMode,+ managed_policy_sha256: Option<String>,+ user_policy_sha256: Option<String>,+ created_at: Instant,+ last_used_at: Instant,+ idle_ttl: Duration,+ absolute_ttl: Duration,+}++impl ResourceGrant {+ pub fn is_live(&self) -> bool {+ self.protected.is_live()+ }++ fn expired(&self, now: Instant) -> bool {+ !self.is_live()+ || now.duration_since(self.last_used_at) >= self.idle_ttl+ || now.duration_since(self.created_at) >= self.absolute_ttl+ }+}++/// Per-runtime store and admission coordinator for every protected resource+/// adapter beyond existing-profile attachment.+///+/// Only canonical resource digests become map keys. Raw paths, text, page+/// content, selectors, and typed input are never retained by this store.+pub struct ProtectedResourceGrants {+ broker: Arc<ApprovalBroker>,+ grants: Mutex<HashMap<ResourceGrantKey, ResourceGrant>>,+ admission: tokio::sync::Mutex<()>,+}++impl ProtectedResourceGrants {+ pub fn new(broker: Arc<ApprovalBroker>) -> Self {+ Self {+ broker,+ grants: Mutex::new(HashMap::new()),+ admission: tokio::sync::Mutex::new(()),+ }+ }++ #[allow(clippy::too_many_arguments)]+ pub async fn authorize(+ &self,+ context: &crate::session_authorization::EffectiveAuthorizationContext,+ adapter_id: &str,+ risk_class: RiskClass,+ lifecycle_session: Option<&str>,+ resource: Value,+ human_summary: &str,+ idle_ttl: Duration,+ absolute_ttl: Duration,+ ) -> Result<Option<ResourceGrant>, ConsentError> {+ if context.mode() == PermissionMode::Unrestricted {+ return Ok(None);+ }+ let resource_digest = digest_resource(adapter_id, &resource);+ let key = resource_grant_key(context, lifecycle_session, adapter_id, &resource_digest);+ if let Some(grant) = self.lookup(&key, context) {+ return Ok(Some(grant));+ }++ // Collapse concurrent requests for the same or different protected+ // resources into a single provider turn. Re-check after waiting so a+ // peer that just approved the same exact scope supplies the grant.+ let _admission = self.admission.lock().await;+ if let Some(grant) = self.lookup(&key, context) {+ return Ok(Some(grant));+ }++ let public_session = context+ .public_session()+ .or(lifecycle_session)+ .unwrap_or("compatibility");+ let transport_session = context.transport_session().unwrap_or(public_session);+ let request = self.broker.request_bound(+ context.mode(),+ adapter_id,+ risk_class,+ public_session,+ transport_session,+ resource,+ human_summary,+ context.managed_policy_sha256().map(str::to_owned),+ context.user_policy_sha256().map(str::to_owned),+ );+ let protected = match context.mode() {+ PermissionMode::Standard => self.broker.approve(&request).await?,+ PermissionMode::Bounded => self.broker.activate_preapproved(&request).await?,+ PermissionMode::Unrestricted => unreachable!("handled before protected admission"),+ };+ let now = Instant::now();+ let grant = ResourceGrant {+ adapter_id: adapter_id.to_owned(),+ resource_digest,+ protected,+ mode: context.mode(),+ managed_policy_sha256: context.managed_policy_sha256().map(str::to_owned),+ user_policy_sha256: context.user_policy_sha256().map(str::to_owned),+ created_at: now,+ last_used_at: now,+ idle_ttl,+ absolute_ttl,+ };+ self.grants.lock().unwrap().insert(key, grant.clone());+ Ok(Some(grant))+ }++ fn lookup(+ &self,+ key: &ResourceGrantKey,+ context: &crate::session_authorization::EffectiveAuthorizationContext,+ ) -> Option<ResourceGrant> {+ let now = Instant::now();+ let mut grants = self.grants.lock().unwrap();+ let grant = grants.get_mut(key)?;+ if grant.expired(now)+ || grant.mode != context.mode()+ || grant.managed_policy_sha256.as_deref() != context.managed_policy_sha256()+ || grant.user_policy_sha256.as_deref() != context.user_policy_sha256()+ {+ if let Some(expired) = grants.remove(key) {+ expired.protected.indicator.revoke();+ }+ return None;+ }+ grant.last_used_at = now;+ Some(grant.clone())+ }++ pub fn revoke_session(&self, session: &str) -> Vec<ProtectedGrant> {+ let mut removed = Vec::new();+ self.grants.lock().unwrap().retain(|key, grant| {+ let keep = key.public_session != session && key.transport_session != session;+ if !keep {+ grant.protected.indicator.revoke();+ removed.push(grant.protected.clone());+ }+ keep+ });+ removed+ }++ pub fn revoke_all(&self) -> Vec<ProtectedGrant> {+ let mut grants = self.grants.lock().unwrap();+ let removed = grants+ .drain()+ .map(|(_, grant)| {+ grant.protected.indicator.revoke();+ grant.protected+ })+ .collect();+ removed+ }++ pub fn broker(&self) -> &Arc<ApprovalBroker> {+ &self.broker+ }+}++impl Drop for ProtectedResourceGrants {+ fn drop(&mut self) {+ for (_, grant) in self.grants.get_mut().unwrap().drain() {+ grant.protected.indicator.revoke();+ }+ }+}++fn resource_grant_key(+ context: &crate::session_authorization::EffectiveAuthorizationContext,+ lifecycle_session: Option<&str>,+ adapter_id: &str,+ resource_digest: &str,+) -> ResourceGrantKey {+ let public_session = context+ .public_session()+ .or(lifecycle_session)+ .unwrap_or("compatibility");+ ResourceGrantKey {+ runtime_scope: context.runtime_scope_key(),+ public_session: context.runtime_session_key(public_session),+ transport_session: context+ .transport_session()+ .unwrap_or(public_session)+ .to_owned(),+ adapter_id: adapter_id.to_owned(),+ resource_digest: resource_digest.to_owned(),+ }+}++fn digest_resource(adapter_id: &str, resource: &Value) -> String {+ let canonical = serde_json::json!({+ "adapter_id": adapter_id,+ "resource": resource,+ });+ let bytes = serde_json::to_vec(&canonical).expect("serialize protected resource");+ format!("{:x}", Sha256::digest(bytes))+}+fn now_unix_ms() -> u128 {SystemTime::now().duration_since(UNIX_EPOCH)@@ -323,7 +555,6 @@ fn digest_request(request: &ConsentRequest) -> String {#[cfg(test)]mod tests {use super::*;- use std::sync::Mutex;struct FakeProvider {action: ConsentAction,@@ -399,6 +630,134 @@ mod tests {)}+ fn authorization_context(+ mode: PermissionMode,+ ) -> Arc<crate::session_authorization::EffectiveAuthorizationContext> {+ let ceiling = crate::session_authorization::SessionModeCeiling::for_trusted_sessions(+ [mode],+ mode == PermissionMode::Unrestricted,+ Duration::from_secs(60),+ Duration::from_secs(30),+ )+ .unwrap();+ crate::session_authorization::SessionAuthorizationRegistry::with_ceiling(ceiling)+ .compatibility_context(mode, None)+ .unwrap()+ }++ #[test]+ fn provider_identity_is_runtime_scoped() {+ let with_provider = crate::tool::ToolRegistry::new_with_protected_consent_provider(Some(+ provider(ConsentAction::Accept),+ ));+ let without_provider = crate::tool::ToolRegistry::new();++ assert_eq!(+ with_provider.authorization_status_json()["protected_consent_collector"],+ "test.protected-provider"+ );+ assert_eq!(+ without_provider.authorization_status_json()["protected_consent_collector"],+ serde_json::Value::Null+ );+ }++ #[tokio::test]+ async fn exact_resource_grants_are_reused_and_scope_changes_reprompt() {+ let provider = provider(ConsentAction::Accept);+ let broker = Arc::new(ApprovalBroker::new(Some(provider.clone())));+ let grants = ProtectedResourceGrants::new(broker);+ let context = authorization_context(PermissionMode::Standard);++ let first = grants+ .authorize(+ &context,+ "private_observation",+ RiskClass::R2,+ Some("public-a"),+ serde_json::json!({"pid": 42, "window_id": 7}),+ "Observe app window 7",+ Duration::from_secs(30),+ Duration::from_secs(60),+ )+ .await+ .unwrap()+ .unwrap();+ let reused = grants+ .authorize(+ &context,+ "private_observation",+ RiskClass::R2,+ Some("public-a"),+ serde_json::json!({"pid": 42, "window_id": 7}),+ "Observe app window 7",+ Duration::from_secs(30),+ Duration::from_secs(60),+ )+ .await+ .unwrap()+ .unwrap();+ assert_eq!(first.protected.id, reused.protected.id);+ assert_eq!(provider.requests.load(Ordering::SeqCst), 1);++ grants+ .authorize(+ &context,+ "private_observation",+ RiskClass::R2,+ Some("public-a"),+ serde_json::json!({"pid": 42, "window_id": 8}),+ "Observe app window 8",+ Duration::from_secs(30),+ Duration::from_secs(60),+ )+ .await+ .unwrap();+ assert_eq!(provider.requests.load(Ordering::SeqCst), 2);+ }++ #[tokio::test]+ async fn revocation_is_immediate_and_unrestricted_skips_the_broker() {+ let provider = provider(ConsentAction::Accept);+ let broker = Arc::new(ApprovalBroker::new(Some(provider.clone())));+ let grants = ProtectedResourceGrants::new(broker);+ let standard = authorization_context(PermissionMode::Standard);+ let live = grants+ .authorize(+ &standard,+ "desktop_input",+ RiskClass::R1,+ Some("public-a"),+ serde_json::json!({"pid": 42, "window_id": 7}),+ "Control app window 7",+ Duration::from_secs(30),+ Duration::from_secs(60),+ )+ .await+ .unwrap()+ .unwrap();+ let revoked = grants.revoke_session(&standard.runtime_session_key("public-a"));+ assert_eq!(revoked.len(), 1);+ assert!(!live.is_live());++ let unrestricted = authorization_context(PermissionMode::Unrestricted);+ assert!(grants+ .authorize(+ &unrestricted,+ "desktop_input",+ RiskClass::R1,+ Some("public-b"),+ serde_json::json!({"pid": 9, "window_id": 2}),+ "Control app window 2",+ Duration::from_secs(30),+ Duration::from_secs(60),+ )+ .await+ .unwrap()+ .is_none());+ assert_eq!(provider.requests.load(Ordering::SeqCst), 1);+ }+#[tokio::test]async fn exact_accept_activates_a_revocable_indicator() {let provider = provider(ConsentAction::Accept);diff --git a/libs/cua-driver/rust/crates/cua-driver-core/src/session_authorization.rs b/libs/cua-driver/rust/crates/cua-driver-core/src/session_authorization.rsindex 83673716be..d97783a3ac 100644--- a/libs/cua-driver/rust/crates/cua-driver-core/src/session_authorization.rs+++ b/libs/cua-driver/rust/crates/cua-driver-core/src/session_authorization.rs@@ -232,6 +232,21 @@ impl EffectiveAuthorizationContext {self.public_session.as_deref()}+ #[doc(hidden)]+ pub fn transport_session(&self) -> Option<&str> {+ self.transport_session.as_deref()+ }++ #[doc(hidden)]+ pub fn user_policy_sha256(&self) -> Option<&str> {+ self.user_policy_sha256.as_deref()+ }++ #[doc(hidden)]+ pub fn managed_policy_sha256(&self) -> Option<&str> {+ self.managed_policy_sha256.as_deref()+ }+pub fn is_expired(&self) -> bool {if self.revoked.load(Ordering::Acquire) {return true;diff --git a/libs/cua-driver/rust/crates/cua-driver-core/src/tool.rs b/libs/cua-driver/rust/crates/cua-driver-core/src/tool.rsindex 04151d8aef..bf78e822e9 100644--- a/libs/cua-driver/rust/crates/cua-driver-core/src/tool.rs+++ b/libs/cua-driver/rust/crates/cua-driver-core/src/tool.rs@@ -374,21 +374,77 @@ pub struct ToolRegistry {session_end_hooks: Vec<crate::session::SessionEndHookRegistration>,cursor_outcome_readers: Vec<crate::session::CursorOutcomeReaderRegistration>,runtime_cleanups: Vec<RuntimeCleanup>,+ /// Runtime-owned protected-consent broker shared by every resource+ /// adapter. Keeping it at the canonical dispatch boundary prevents+ /// browser, desktop, and file adapters from growing independent provider+ /// identities or grant lifecycles.+ approval_broker: Arc<crate::consent::ApprovalBroker>,+ protected_resource_grants: Arc<crate::consent::ProtectedResourceGrants>,}impl ToolRegistry {pub fn new() -> Self {+ Self::new_with_protected_consent_provider(None)+ }++ /// Construct a registry with a provider installed by a trusted embedding+ /// host. Public tool calls and transport metadata cannot replace it.+ pub fn new_with_protected_consent_provider(+ provider: Option<Arc<dyn crate::consent::ProtectedConsentProvider>>,+ ) -> Self {+ let approval_broker = Arc::new(crate::consent::ApprovalBroker::new(provider));+ let protected_resource_grants = Arc::new(crate::consent::ProtectedResourceGrants::new(+ approval_broker.clone(),+ ));+ let weak_grants = Arc::downgrade(&protected_resource_grants);+ let session_end_hook =+ crate::session::register_scoped_session_end_hook(move |session_id| {+ let Some(grants) = weak_grants.upgrade() else {+ return;+ };+ let revoked = grants.revoke_session(session_id);+ if revoked.is_empty() {+ return;+ }+ if let Ok(runtime) = tokio::runtime::Handle::try_current() {+ runtime.spawn(async move {+ for grant in revoked {+ grants.broker().revoke(&grant).await;+ }+ });+ }+ });Self {tools: HashMap::new(),order: Vec::new(),recording: Arc::new(RecordingSession::new()),replay_registry: Arc::new(std::sync::Mutex::new(std::sync::Weak::new())),- session_end_hooks: Vec::new(),+ session_end_hooks: vec![session_end_hook],cursor_outcome_readers: Vec::new(),runtime_cleanups: Vec::new(),+ approval_broker,+ protected_resource_grants,}}+ /// Return the runtime-owned broker for adapter construction.+ ///+ /// This is intentionally not exposed through MCP/CLI arguments. Platform+ /// registries pass the clone to resource adapters while assembling one+ /// trusted runtime.+ pub fn approval_broker(&self) -> Arc<crate::consent::ApprovalBroker> {+ self.approval_broker.clone()+ }++ pub fn protected_resource_grants(&self) -> Arc<crate::consent::ProtectedResourceGrants> {+ self.protected_resource_grants.clone()+ }++ /// Content-free authorization status for this exact runtime.+ pub fn authorization_status_json(&self) -> Value {+ crate::authorization::status_json_with_provider(self.approval_broker.provider_id())+ }+pub fn register(&mut self, tool: Box<dyn Tool>) {let name = tool.def().name.clone();self.order.push(name.clone());diff --git a/libs/cua-driver/rust/crates/platform-linux/src/tools/impl_.rs b/libs/cua-driver/rust/crates/platform-linux/src/tools/impl_.rsindex 6fb4d9b6a3..b78bf32e04 100644--- a/libs/cua-driver/rust/crates/platform-linux/src/tools/impl_.rs+++ b/libs/cua-driver/rust/crates/platform-linux/src/tools/impl_.rs@@ -7119,9 +7119,10 @@ pub fn build_registry(compat: bool) -> ToolRegistry {r.register(Box::new(cua_driver_core::page::PageTool::new(Arc::new(super::page::LinuxPageBackend::new(),))));- let browser_engine = cua_driver_core::browser::BrowserEngine::new(Arc::new(- crate::browser_platform::LinuxBrowserPlatform,- ));+ let browser_engine = cua_driver_core::browser::BrowserEngine::new_with_approval_broker(+ Arc::new(crate::browser_platform::LinuxBrowserPlatform),+ r.approval_broker(),+ );cua_driver_core::browser::register_browser_tools(&browser_engine, &mut r);r.register_recording_tools();r.register_session_tools();diff --git a/libs/cua-driver/rust/crates/platform-macos/src/tools/mod.rs b/libs/cua-driver/rust/crates/platform-macos/src/tools/mod.rsindex 8a8c09b0c9..2162dcb381 100644--- a/libs/cua-driver/rust/crates/platform-macos/src/tools/mod.rs+++ b/libs/cua-driver/rust/crates/platform-macos/src/tools/mod.rs@@ -682,9 +682,12 @@ pub fn register_all(registry.register(Box::new(cua_driver_core::page::PageTool::new(Arc::new(page::MacOsPageBackend::new(state.clone()),))));- let browser_engine = cua_driver_core::browser::BrowserEngine::new(Arc::new(- crate::browser::MacOsBrowserPlatform::new(state.cursor_registry.clone()),- ));+ let browser_engine = cua_driver_core::browser::BrowserEngine::new_with_approval_broker(+ Arc::new(crate::browser::MacOsBrowserPlatform::new(+ state.cursor_registry.clone(),+ )),+ registry.approval_broker(),+ );cua_driver_core::browser::register_browser_tools(&browser_engine, registry);// Recording / replay + session-lifecycle tools are platform-independent.registry.register_recording_tools();diff --git a/libs/cua-driver/rust/crates/platform-windows/src/tools/impl_.rs b/libs/cua-driver/rust/crates/platform-windows/src/tools/impl_.rsindex 95d0d5318c..348df2f18b 100644--- a/libs/cua-driver/rust/crates/platform-windows/src/tools/impl_.rs+++ b/libs/cua-driver/rust/crates/platform-windows/src/tools/impl_.rs@@ -8715,9 +8715,12 @@ pub fn build_registry(compat: bool) -> ToolRegistry {r.register(Box::new(cua_driver_core::page::PageTool::new(std::sync::Arc::new(super::page::WindowsPageBackend::new()),)));- let browser_engine = cua_driver_core::browser::BrowserEngine::new(std::sync::Arc::new(- crate::browser_platform::WindowsBrowserPlatform::new(state.cursor_registry.clone()),- ));+ let browser_engine = cua_driver_core::browser::BrowserEngine::new_with_approval_broker(+ std::sync::Arc::new(crate::browser_platform::WindowsBrowserPlatform::new(+ state.cursor_registry.clone(),+ )),+ r.approval_broker(),+ );cua_driver_core::browser::register_browser_tools(&browser_engine, &mut r);r.register_recording_tools();r.register_session_tools();