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
fix(cua-spaces): teleport_app moves only the selected items (#5504)
Francesco Bonaccid247bf36adb7
diff --git a/libs/cua/crates/cua-keyvault/src/broker.rs b/libs/cua/crates/cua-keyvault/src/broker.rsindex 399becc700..6f1373cc0c 100644--- a/libs/cua/crates/cua-keyvault/src/broker.rs+++ b/libs/cua/crates/cua-keyvault/src/broker.rs@@ -636,6 +636,49 @@ pub struct AccessRequest {/// authority: the grant is still bound to the verified caller.#[serde(default, skip_serializing_if = "Option::is_none")]pub agent: Option<String>,+ /// For a whole-app (`Selector::App`) request: the exact bundle-relative+ /// manifest paths the requester selected (the same `rel_path`s+ /// [`ImportSpec::paths`] takes). The request is then for THOSE parts of+ /// the app and nothing else: it never resolves to the items the vault+ /// already holds for the app (they are not keyed by manifest path), so+ /// approval always captures exactly these paths, and the grant covers+ /// only what that capture produced. `None` keeps the whole-app request.+ /// Only a single `Selector::App` may carry it.+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub paths: Option<Vec<String>>,+}++/// Most manifest paths one request may name.+const MAX_REQUEST_PATHS: usize = 256;+/// Longest manifest path a request may name, in bytes.+const MAX_REQUEST_PATH_LEN: usize = 1024;++/// Checks the `paths` a request carries: they narrow exactly one whole-app+/// selector, are plain non-empty relative names, and are bounded.+fn validate_request_paths(req: &AccessRequest) -> Result<()> {+ let Some(paths) = &req.paths else {+ return Ok(());+ };+ if paths.is_empty() {+ return Err(Error::Invalid(+ "an empty path selection is ambiguous: name the parts to send".into(),+ ));+ }+ if paths.len() > MAX_REQUEST_PATHS {+ return Err(Error::Invalid("request too large".into()));+ }+ if !matches!(req.selectors.as_slice(), [Selector::App { .. }]) {+ return Err(Error::Invalid(+ "a path selection narrows exactly one whole-app selector".into(),+ ));+ }+ for p in paths {+ if p.trim().is_empty() || p.len() > MAX_REQUEST_PATH_LEN || p.chars().any(char::is_control)+ {+ return Err(Error::Invalid("a selected path is not valid".into()));+ }+ }+ Ok(())}/// A pending request, as the consent UI sees it.@@ -681,13 +724,12 @@ pub struct ApproveOptions {#[serde(default)]pub include_storage: bool,/// For a whole-app (`Selector::App`) request: the exact bundle-relative- /// paths to capture, same meaning as [`ImportSpec::paths`]. `None` keeps- /// the existing default (a provider's login-only selection). This is- /// the approver's OWN choice, set when a human reviews and widens what- /// an agent's `teleport_app` request asked for (shown to them as- /// `would_send` when they decide) -- never the requester's own- /// unverified `include`, which only ever reaches this call as text on- /// the consent screen.+ /// paths to capture, same meaning as [`ImportSpec::paths`]. This is the+ /// approver's OWN choice, set when a human reviews and widens or narrows+ /// what an agent's `teleport_app` request asked for. `None` keeps what+ /// the request itself named ([`AccessRequest::paths`], the selection the+ /// requester made, which the daemon validated), and failing that the+ /// existing default (a provider's login-only selection).#[serde(default)]pub paths: Option<Vec<String>>,}@@ -2343,6 +2385,7 @@ impl Broker {if req.selectors.len() > 32 || req.targets.len() > 8 || req.reason.len() > 500 {return Err(Error::Invalid("request too large".into()));}+ validate_request_paths(&req)?;for t in &req.targets {validate_target(t)?;}@@ -2411,6 +2454,14 @@ impl Broker {let mut items: Vec<ItemMeta> = Vec::new();let mut needs_import = Vec::new();for s in &req.selectors {+ // A path selection never resolves to what the vault already+ // holds for the app: those items are not keyed by manifest path,+ // so the whole stored session would be granted. It is imported+ // on approval instead, exactly as selected.+ if req.paths.is_some() {+ needs_import.push(s.clone());+ continue;+ }let found: Vec<&ItemMeta> = meta.items.values().filter(|i| s.matches(i)).collect();if found.is_empty() {match s {@@ -2768,7 +2819,7 @@ impl Broker {// Import what the request named but the vault does not hold yet.let mut item_ids: Vec<String> = view.items.iter().map(|i| i.id.clone()).collect();- for spec in imports_for(&view.needs_import, &opts) {+ for spec in imports_for(&view.needs_import, &opts, view.request.paths.as_deref()) {for it in self.import_confirmed(caller, spec).await? {if !item_ids.contains(&it.id) {item_ids.push(it.id);@@ -3851,6 +3902,22 @@ fn describe_selection(view: &PendingView) -> String {for s in &view.needs_import {match s {Selector::Site { app, site } => parts.push(format!("{site} ({app}, import)")),+ // A path selection says which parts (the prompt is the only+ // place some platforms can show them).+ Selector::App { app } if view.request.paths.is_some() => {+ let paths = view.request.paths.as_deref().unwrap_or_default();+ let shown: Vec<&str> = paths.iter().take(3).map(String::as_str).collect();+ let more = paths.len().saturating_sub(shown.len());+ parts.push(format!(+ "only {app}: {}{} (import)",+ shown.join(", "),+ if more > 0 {+ format!(" and {more} more")+ } else {+ String::new()+ }+ ));+ }Selector::App { app } => parts.push(format!("the whole {app} session (import)")),Selector::Item { id } => parts.push(id.clone()),Selector::Login { site } => parts.push(format!("the saved password for {site}")),@@ -3892,7 +3959,14 @@ fn import_reason(spec: &ImportSpec, caller: &CallerIdentity) -> String {)}-fn imports_for(needs: &[Selector], opts: &ApproveOptions) -> Vec<ImportSpec> {+/// The imports approval runs for `needs`. A whole-app import captures the+/// approver's own `paths` when they set them, else exactly the `requested`+/// ones, else the provider's login-only default.+fn imports_for(+ needs: &[Selector],+ opts: &ApproveOptions,+ requested: Option<&[String]>,+) -> Vec<ImportSpec> {let mut by_app: BTreeMap<String, ImportSpec> = BTreeMap::new();for s in needs {match s {@@ -3914,7 +3988,10 @@ fn imports_for(needs: &[Selector], opts: &ApproveOptions) -> Vec<ImportSpec> {.or_insert_with(|| ImportSpec {app: app.clone(),whole_app: true,- paths: opts.paths.clone(),+ paths: opts+ .paths+ .clone()+ .or_else(|| requested.map(<[String]>::to_vec)),..Default::default()});}diff --git a/libs/cua/crates/cua-keyvault/tests/broker.rs b/libs/cua/crates/cua-keyvault/tests/broker.rsindex 44efaf64db..db40125fa6 100644--- a/libs/cua/crates/cua-keyvault/tests/broker.rs+++ b/libs/cua/crates/cua-keyvault/tests/broker.rs@@ -2116,11 +2116,9 @@ async fn import_and_teleport_refuses_when_nothing_was_captured() {assert!(r.backend.delivered.lock().unwrap().is_empty());}-/// A whole-app (`Selector::App`) request only ever captures the provider's-/// existing default (login-only) selection UNLESS the human's own approval-/// widens it with `ApproveOptions::paths` -- the requester's own `include`-/// (an MCP/automation caller, never authoritative, red-team E2) never-/// reaches the capture on its own.+/// A whole-app (`Selector::App`) request that names no parts only ever+/// captures the provider's existing default (login-only) selection UNLESS+/// the human's own approval widens it with `ApproveOptions::paths`.#[tokio::test]async fn approve_options_paths_widens_a_whole_app_capture_the_requester_cannot() {let r = rig().await;@@ -2197,3 +2195,205 @@ async fn approve_without_paths_leaves_the_whole_app_default_selection_alone() {.expect("a whole-app capture happened");assert_eq!(spec.paths, None);}++/// What the vault holds for an app is not keyed by manifest path, so a+/// request that names the parts it wants (`AccessRequest::paths`) never+/// resolves to the stored items: approval captures exactly those paths and+/// the grant covers only what that capture produced. Before this, the same+/// request resolved to every deliverable item the vault held for the app.+#[tokio::test]+async fn a_path_selection_grants_and_delivers_only_what_was_selected() {+ let r = rig().await;+ // The vault already holds a stored session for the app: a cookie and a+ // file, both deliverable.+ r.broker+ .import(+ &r.cua,+ ImportSpec {+ app: "chrome".into(),+ sites: vec![SiteChoice {+ site: "github.com".into(),+ include_storage: false,+ include_passwords: false,+ }],+ whole_app: true,+ ..Default::default()+ },+ )+ .await+ .unwrap();+ let stored: Vec<ItemMeta> = all_items(&r).await;+ assert!(+ stored.iter().any(|i| i.kind == ItemKind::Cookie),+ "the vault holds a stored cookie"+ );+ r.backend.captures.lock().unwrap().clear();++ let pending = r+ .broker+ .request_access(+ &r.koala,+ AccessRequest {+ selectors: vec![Selector::App {+ app: "chrome".into(),+ }],+ targets: vec!["dev-1".into()],+ reason: "teleport_app: move chrome's Preferences into dev-1".into(),+ paths: Some(vec!["Default/Preferences".into()]),+ uses: Some(0),+ ..Default::default()+ },+ )+ .await+ .unwrap();+ // It resolved to nothing stored: it is an import of the named path.+ assert!(pending.items.is_empty(), "{:?}", pending.items);+ assert_eq!(+ pending.needs_import,+ vec![Selector::App {+ app: "chrome".into()+ }]+ );++ r.broker+ .approve(&r.cua, &pending.id, ApproveOptions::default())+ .await+ .unwrap();+ // The capture was for exactly the requested path (the approver set none).+ {+ let captures = r.backend.captures.lock().unwrap();+ let spec = captures.iter().find(|s| s.whole_app).expect("a capture");+ assert_eq!(+ spec.paths.as_deref(),+ Some(&["Default/Preferences".to_string()][..])+ );+ }+ // The prompt the approver answers names what is selected.+ let asked = r.presence.asked.lock().unwrap().clone();+ assert!(+ asked.iter().any(|a| a.contains("Default/Preferences")),+ "{asked:?}"+ );++ let (token, items) = match r+ .broker+ .await_decision(&r.koala, &pending.id, Duration::from_millis(50))+ .await+ .unwrap()+ {+ Decision::Granted { token, items, .. } => (token, items),+ other => panic!("{other:?}"),+ };+ let all = all_items(&r).await;+ let granted: Vec<&ItemMeta> = all.iter().filter(|i| items.contains(&i.id)).collect();+ assert_eq!(granted.len(), 1, "{granted:?}");+ assert_eq!(granted[0].kind, ItemKind::File);+ assert_eq!(granted[0].key, "Default/Preferences");++ // Delivery moves that one file; the stored cookie stays in the vault.+ r.broker+ .teleport(+ &r.koala,+ TeleportRequest {+ token: Some(token),+ items,+ target: "dev-1".into(),+ include_passwords: false,+ launch: false,+ },+ )+ .await+ .unwrap();+ let delivered = r.backend.delivered.lock().unwrap();+ assert_eq!(delivered.len(), 1);+ assert_eq!(delivered[0].2, ["Default/Preferences"]);+ assert!(r.backend.delivered_hosts.lock().unwrap()[0].is_empty());+}++/// The approver's own `paths` still win over what the requester asked for+/// (the human may widen or narrow it).+#[tokio::test]+async fn the_approvers_paths_win_over_the_requested_ones() {+ let r = rig().await;+ let pending = r+ .broker+ .request_access(+ &r.koala,+ AccessRequest {+ selectors: vec![Selector::App {+ app: "chrome".into(),+ }],+ targets: vec!["dev-1".into()],+ paths: Some(vec!["Default/Preferences".into()]),+ ..Default::default()+ },+ )+ .await+ .unwrap();+ r.broker+ .approve(+ &r.cua,+ &pending.id,+ ApproveOptions {+ paths: Some(vec!["Default/Bookmarks".into()]),+ ..Default::default()+ },+ )+ .await+ .unwrap();+ let captures = r.backend.captures.lock().unwrap();+ let spec = captures.iter().find(|s| s.whole_app).expect("a capture");+ assert_eq!(+ spec.paths.as_deref(),+ Some(&["Default/Bookmarks".to_string()][..])+ );+}++/// A path selection must narrow exactly one whole-app selector and be plain,+/// non-empty and bounded; anything else is refused before it is filed.+#[tokio::test]+async fn a_malformed_path_selection_is_refused() {+ let r = rig().await;+ let app = || Selector::App {+ app: "chrome".into(),+ };+ let bad: Vec<(Vec<Selector>, Option<Vec<String>>)> = vec![+ // Empty selection: ambiguous.+ (vec![app()], Some(vec![])),+ // A blank path and one with control characters.+ (vec![app()], Some(vec![" ".into()])),+ (vec![app()], Some(vec!["a\nb".into()])),+ // Not a whole-app selector.+ (+ vec![Selector::Site {+ app: "chrome".into(),+ site: "github.com".into(),+ }],+ Some(vec!["Default/Preferences".into()]),+ ),+ // More than one selector: which one would it narrow?+ (vec![app(), app()], Some(vec!["Default/Preferences".into()])),+ // Too many paths.+ (+ vec![app()],+ Some((0..300).map(|n| format!("Default/f{n}")).collect()),+ ),+ ];+ for (selectors, paths) in bad {+ let err = r+ .broker+ .request_access(+ &r.koala,+ AccessRequest {+ selectors,+ targets: vec!["dev-1".into()],+ paths,+ ..Default::default()+ },+ )+ .await+ .unwrap_err();+ assert!(matches!(err, Error::Invalid(_)), "{err:?}");+ }+ assert!(r.broker.list_pending(&r.cua).await.unwrap().is_empty());+}diff --git a/libs/cua/crates/cua-spaces-cli/src/keyvault_cmd.rs b/libs/cua/crates/cua-spaces-cli/src/keyvault_cmd.rsindex 15e331c281..d3e7758240 100644--- a/libs/cua/crates/cua-spaces-cli/src/keyvault_cmd.rs+++ b/libs/cua/crates/cua-spaces-cli/src/keyvault_cmd.rs@@ -431,6 +431,7 @@ pub async fn run(cmd: KeyvaultCmd, json: bool, out: &mut dyn Write) -> Result<i3serde_json::json!({"id": p.id, "caller": p.caller_display,"agent": p.request.agent, "actions": p.request.actions,"targets": p.request.targets,+ "selected_paths": p.request.paths,"items": p.items.iter().map(|i| i.redacted().label()).collect::<Vec<_>>()})}).collect();@@ -469,11 +470,21 @@ pub async fn run(cmd: KeyvaultCmd, json: bool, out: &mut dyn Write) -> Result<i3p.request.targets.join(", ")),);+ if let Some(note) = selection_note(p) {+ line(out, format!(" {note}"));+ }}}}KeyvaultCmd::Approve { id } => {if !json {+ // The system prompt (polkit on Linux) cannot show what the+ // request is for, so say it here before asking.+ if let Ok(pending) = c.list_pending().await+ && let Some(p) = pending.iter().find(|p| p.id == id)+ {+ eprintln!("{}", describe_pending(p));+ }eprintln!("The Cua daemon asks for Touch ID or your login password to approve.");}let g = c.approve(&id, Default::default()).await.map_err(kv_error)?;@@ -498,6 +509,62 @@ pub async fn run(cmd: KeyvaultCmd, json: bool, out: &mut dyn Write) -> Result<i3Ok(0)}+/// The parts of an app a request is limited to, when its requester named+/// them (`teleport_app` with a selection), or what it would import.+fn selection_note(p: &cua_keyvault::broker::PendingView) -> Option<String> {+ let paths = p.request.paths.as_ref()?;+ let app = p.request.selectors.iter().find_map(|s| match s {+ cua_keyvault::broker::Selector::App { app } => Some(app.as_str()),+ _ => None,+ });+ Some(format!(+ "only these parts{}: {}",+ app.map(|a| format!(" of {a}")).unwrap_or_default(),+ paths.join(", ")+ ))+}++/// What approving `p` would allow, in plain words, for the approver to read+/// before the system prompt (which, on Linux, shows fixed text only).+fn describe_pending(p: &cua_keyvault::broker::PendingView) -> String {+ let who = match &p.request.agent {+ Some(a) => format!("agent {a} ({})", p.caller_display),+ None => p.caller_display.clone(),+ };+ let mut text = format!(+ "Request {}: {who} asks to move app data into {}.",+ p.id,+ p.request.targets.join(", ")+ );+ match selection_note(p) {+ Some(note) => text.push_str(&format!("\n Limited to {note}.")),+ None => {+ let whole: Vec<String> = p+ .request+ .selectors+ .iter()+ .filter_map(|s| match s {+ cua_keyvault::broker::Selector::App { app } => Some(app.clone()),+ _ => None,+ })+ .collect();+ if !whole.is_empty() {+ text.push_str(&format!(+ "\n Covers the stored session of {}.",+ whole.join(", ")+ ));+ }+ }+ }+ if !p.request.reason.is_empty() {+ text.push_str(&format!(+ "\n The app says (unverified): {}",+ p.request.reason+ ));+ }+ text+}+/// "Saved 4 items: 3 new, 1 updated" (counts only; never a name or a value).fn import_summary(r: &cua_keyvault::broker::ImportReport, noun: &str) -> String {let plural = if r.saved == 1 { "" } else { "s" };@@ -518,6 +585,38 @@ fn import_summary(r: &cua_keyvault::broker::ImportReport, noun: &str) -> Stringmod tests {use super::*;+ fn pending(paths: Option<Vec<String>>) -> cua_keyvault::broker::PendingView {+ cua_keyvault::broker::PendingView {+ id: "req-1".into(),+ caller: cua_keyvault::CallerIdentity::for_tests("com.example.bot", false),+ caller_fp: "fp".into(),+ caller_display: "Example bot".into(),+ request: cua_keyvault::broker::AccessRequest {+ selectors: vec![cua_keyvault::broker::Selector::App {+ app: "firefox".into(),+ }],+ targets: vec!["dev-1".into()],+ reason: "teleport_app: move firefox's Preferences into dev-1".into(),+ paths,+ ..Default::default()+ },+ items: vec![],+ needs_import: vec![],+ created_ms: 0,+ }+ }++ /// What the approver reads before a system prompt that cannot show it.+ #[test]+ fn approve_describes_the_selection_the_request_is_limited_to() {+ let narrow = describe_pending(&pending(Some(vec!["firefox/prefs.js".into()])));+ assert!(narrow.contains("Limited to only these parts of firefox: firefox/prefs.js"));+ assert!(narrow.contains("Example bot"), "{narrow}");+ let whole = describe_pending(&pending(None));+ assert!(whole.contains("stored session of firefox"), "{whole}");+ assert_eq!(selection_note(&pending(None)), None);+ }+#[test]fn only_the_line_ending_is_stripped() {let s = strip_newline(Zeroizing::new(" two spaces \r\n".into()));diff --git a/libs/cua/crates/cua-spaces-cli/src/teleport_session.rs b/libs/cua/crates/cua-spaces-cli/src/teleport_session.rsindex 1ad2a418ac..c034a0e26c 100644--- a/libs/cua/crates/cua-spaces-cli/src/teleport_session.rs+++ b/libs/cua/crates/cua-spaces-cli/src/teleport_session.rs@@ -104,6 +104,7 @@ fn to_kv_access_request(request: &AccessRequest) -> cua_keyvault::broker::Accessreason: request.reason.clone(),claimed_name: None,agent: None,+ paths: None,}}diff --git a/libs/cua/crates/cua-spaces-ext/src/daemon/keyvault.rs b/libs/cua/crates/cua-spaces-ext/src/daemon/keyvault.rsindex c144406c88..b9ddc28796 100644--- a/libs/cua/crates/cua-spaces-ext/src/daemon/keyvault.rs+++ b/libs/cua/crates/cua-spaces-ext/src/daemon/keyvault.rs@@ -1071,6 +1071,7 @@ impl SessionBroker for McpSessionBroker {&self,app: &str,target: &str,+ paths: &[String],duration_secs: u64,reason: &str,) -> Result<String, SessionBrokerError> {@@ -1084,6 +1085,10 @@ impl SessionBroker for McpSessionBroker {targets: vec![target.into()],duration_secs: Some(duration_secs),reason: reason.into(),+ // The caller's selection rides the request: approval+ // captures these paths, and the grant (and so the+ // delivery) covers only what that capture produced.+ paths: Some(paths.to_vec()),..Default::default()},)diff --git a/libs/cua/crates/cua-spaces-ext/src/teleport.rs b/libs/cua/crates/cua-spaces-ext/src/teleport.rsindex 40800a5bcc..cf2b2f9eeb 100644--- a/libs/cua/crates/cua-spaces-ext/src/teleport.rs+++ b/libs/cua/crates/cua-spaces-ext/src/teleport.rs@@ -894,24 +894,42 @@ pub(crate) async fn tool(// user approves in Cua (Touch ID) or the Keyvault matches an// unattended rule. The Keyvault broker performs the delivery over// the daemon's authenticated channel; it is never done here.+ //+ // What moves is exactly what the caller selected: the selection+ // is validated here (a path the manifest does not offer, an empty+ // list, a sensitive item without `acknowledge_sensitive`, a saved+ // password store are all refused BEFORE any request is filed) and+ // then rides the Keyvault request, so approval captures those+ // parts only and the grant covers nothing else. A retry carries+ // only the `request_id`: it collects what that request's grant+ // already covers and cannot change the selection.let a: i::TeleportApp = crate::args(tool, args)?;let scope = TeleportScope::parse(a.scope.as_deref())?;let s = spaces.space(&a.space).await?;let target = s.id().to_string();let manifest = sessions.manifest(&a.app, scope)?;- let selected = match &a.include {- Some(paths) => manifest.approving(&target, paths, false),- None => manifest.approving_default(&target, false),+ // The provider's catalog id (`chrome` for Microsoft Edge).+ let provider = sessions+ .provider_id(&a.app)+ .unwrap_or_else(|| manifest.app.clone());+ let selection = select_for_request(+ &manifest,+ &provider,+ &target,+ a.include.as_deref(),+ a.acknowledge_sensitive.unwrap_or(false),+ );+ let selection = if a.request_id.is_some() {+ selection.ok()+ } else {+ Some(selection?)};- // Report the selection (or why it is ambiguous) without moving it.- let would_send = serde_json::to_value(&manifest)?;teleport_app_broker(broker,- &manifest.app,+ &manifest,&target,a.request_id.as_deref(),- selected.is_ok(),- would_send,+ selection.as_ref(),).await}@@ -961,16 +979,23 @@ pub(crate) async fn tool(/// consent requirement and moves nothing.async fn teleport_app_broker(broker: Option<&std::sync::Arc<dyn cua_spaces::teleport_broker::SessionBroker>>,- app: &str,+ manifest: &TeleportManifest,target: &str,request_id: Option<&str>,- selection_ok: bool,- would_send: Value,+ selection: Option<&Approval>,) -> Result<ToolOutcome> {use cua_spaces::teleport_broker::{SessionBrokerError, SessionDelivery};const DURATION_SECS: u64 = 15 * 60;const WAIT: std::time::Duration = std::time::Duration::from_secs(20);+ let app = manifest.app.as_str();+ // What would move: the SELECTED items only, never the whole manifest.+ let would_send = match selection {+ Some(sel) => serde_json::to_value(selected_manifest(manifest, sel))?,+ None => Value::Null,+ };+ let selected_paths: Vec<String> = selection.map(|s| s.paths.clone()).unwrap_or_default();+let broker_error = |e: SessionBrokerError| -> ToolOutcome {let out = json!({"moved": false,@@ -992,7 +1017,8 @@ async fn teleport_app_broker("moved": false,"app": app,"space": target,- "selection_ok": selection_ok,+ "selection_ok": true,+ "selected_paths": selected_paths,"would_send": would_send,"message": format!("Teleporting {app}'s signed-in session moves a credential into Space {target}. \@@ -1000,7 +1026,7 @@ async fn teleport_app_broker(with Touch ID or your login password), or set an unattended rule for this app \and Space. The Keyvault delivers it; this tool cannot."),- "instructions": "Show the user what would move and ask them to approve it in Cua. \+ "instructions": "Show the user what would move (would_send) and ask them to approve it in Cua. \Do not retry expecting delivery: this tool is consent-gated by design.",});return Ok(ToolOutcome::json(&out));@@ -1008,9 +1034,23 @@ async fn teleport_app_broker(match request_id {None => {- let reason = format!("teleport_app: move {app}'s signed-in session into {target}");+ // Only reachable with a selection (the caller validated it and+ // refused otherwise); never file a request without one.+ let Some(sel) = selection else {+ return Err(Error::TeleportRefused(+ "teleport_app needs a valid selection to file a request".into(),+ ));+ };+ // The reason is bounded (the Keyvault refuses a long one).+ let reason: String = format!(+ "teleport_app: move {} into {target}",+ describe_selection(manifest, sel)+ )+ .chars()+ .take(400)+ .collect();match broker- .request_access(app, target, DURATION_SECS, &reason)+ .request_access(app, target, &selected_paths, DURATION_SECS, &reason).await{Ok(id) => {@@ -1020,15 +1060,17 @@ async fn teleport_app_broker("request_id": id,"app": app,"space": target,- "selection_ok": selection_ok,+ "selection_ok": true,+ "selected_paths": selected_paths,"would_send": would_send,"message": format!(- "Moving {app}'s signed-in session into Space {target} needs the user's approval."+ "Moving {} into Space {target} needs the user's approval.",+ describe_selection(manifest, sel)),"approve": format!(- "The user approves request {id} in Cua (Keyvault page), which asks for Touch ID or the login password."+ "The user approves request {id} in Cua (Keyvault page), which asks for Touch ID or the login password. Only the selected items in would_send move."),- "instructions": "Show the user what would move and ask them to approve it in Cua. Then call teleport_app again with the same app and space and this request_id. Do not retry without the user.",+ "instructions": "Show the user exactly what is in would_send (only those items move) and ask them to approve it in Cua. Then call teleport_app again with the same app and space and this request_id. Do not retry without the user.",});Ok(ToolOutcome::json(&out))}@@ -1074,6 +1116,78 @@ async fn teleport_app_broker(}}+/// Validates the selection a `teleport_app` call asks for, before anything is+/// filed: the explicit `include` (or the manifest's default-checked set), with+/// sensitive items only when acknowledged, and never a saved-password store+/// (those sign in through `request_site_login`; the Keyvault never delivers+/// them to an automation caller).+fn select_for_request(+ manifest: &TeleportManifest,+ provider: &str,+ target: &str,+ include: Option<&[String]>,+ acknowledge_sensitive: bool,+) -> Result<Approval> {+ let approval = match include {+ Some(paths) => manifest.approving(target, paths, acknowledge_sensitive)?,+ None => manifest.approving_default(target, acknowledge_sensitive)?,+ };+ let stores: Vec<&str> = approval+ .paths+ .iter()+ .filter(|p| {+ cua_teleport::ux::SensitiveGroup::of_item(provider, p)+ == Some(cua_teleport::ux::SensitiveGroup::Passwords)+ })+ .map(String::as_str)+ .collect();+ if !stores.is_empty() {+ return Err(Error::TeleportRefused(format!(+ "saved password stores are never moved by teleport_app ({}); use request_site_login \+ to sign in with a saved password",+ stores.join(", ")+ )));+ }+ Ok(approval)+}++/// The manifest narrowed to the selected items: what the user is shown, and+/// what the request moves.+fn selected_manifest(manifest: &TeleportManifest, selection: &Approval) -> TeleportManifest {+ let items: Vec<TeleportItem> = selection+ .paths+ .iter()+ .filter_map(|p| manifest.items.iter().find(|i| &i.relative_path == p))+ .cloned()+ .collect();+ TeleportManifest {+ total_estimated_bytes: items.iter().map(|i| i.estimated_bytes).sum(),+ items,+ ..manifest.clone()+ }+}++/// A short line naming the selected items, for the request's reason and the+/// reply (the Keyvault shows the reason to the person approving).+fn describe_selection(manifest: &TeleportManifest, selection: &Approval) -> String {+ let labels: Vec<&str> = selection+ .paths+ .iter()+ .filter_map(|p| manifest.items.iter().find(|i| &i.relative_path == p))+ .map(|i| i.label.as_str())+ .collect();+ let shown = labels+ .iter()+ .take(3)+ .copied()+ .collect::<Vec<_>>()+ .join(", ");+ match labels.len().saturating_sub(3) {+ 0 => format!("{}'s {shown}", manifest.app),+ more => format!("{}'s {shown} and {more} more", manifest.app),+ }+}+#[cfg(test)]mod tests {use super::*;@@ -1326,4 +1440,184 @@ mod tests {);assert!(TeleportScope::parse(Some("everything")).is_err());}++ /// A Firefox-shaped manifest: preferences, the cookie store and the saved+ /// logins.+ fn selection_manifest() -> TeleportManifest {+ let item = |path: &str, label: &str, sensitive: bool| TeleportItem {+ relative_path: path.into(),+ label: label.into(),+ estimated_bytes: 100,+ is_sensitive: sensitive,+ is_checked_by_default: !sensitive,+ count: None,+ count_noun: None,+ };+ TeleportManifest {+ app: "firefox".into(),+ display_name: "Firefox".into(),+ scope: TeleportScope::Full,+ total_estimated_bytes: 300,+ notes: vec![],+ items: vec![+ item("firefox/prefs.js", "Preferences", false),+ item("firefox/cookies.sqlite", "Cookies", true),+ item("firefox/logins.json", "Saved logins", true),+ ],+ }+ }++ /// A narrow, non-sensitive selection is accepted as asked, and what the+ /// reply says would move is that selection and nothing more.+ #[test]+ fn would_send_is_the_selection_not_the_whole_manifest() {+ let m = selection_manifest();+ let sel = select_for_request(+ &m,+ "firefox",+ "space-1",+ Some(&["firefox/prefs.js".to_string()]),+ false,+ )+ .unwrap();+ assert_eq!(sel.approved_paths(), ["firefox/prefs.js"]);+ let would = selected_manifest(&m, &sel);+ let paths: Vec<&str> = would+ .items+ .iter()+ .map(|i| i.relative_path.as_str())+ .collect();+ assert_eq!(paths, ["firefox/prefs.js"]);+ assert_eq!(would.total_estimated_bytes, 100);+ let said = describe_selection(&m, &sel);+ assert!(said.contains("Preferences"), "{said}");+ assert!(!said.contains("Cookies"), "{said}");+ }++ /// A sensitive item is refused unless the caller acknowledged it, for an+ /// explicit selection and for the default one alike.+ #[test]+ fn sensitive_items_need_the_acknowledgement_to_be_selected() {+ let m = selection_manifest();+ let cookies = ["firefox/cookies.sqlite".to_string()];+ let err = select_for_request(&m, "firefox", "space-1", Some(&cookies), false).unwrap_err();+ assert_eq!(err.tag(), "teleport_refused");+ assert!(err.to_string().contains("sensitive"), "{err}");+ assert!(select_for_request(&m, "firefox", "space-1", Some(&cookies), true).is_ok());+ // The Claude Code default set holds a credential: refused too.+ let cc = claude_code_manifest();+ assert!(select_for_request(&cc, "claude-code", "space-1", None, false).is_err());+ assert!(select_for_request(&cc, "claude-code", "space-1", None, true).is_ok());+ }++ /// Saved password stores are never moved by this tool, acknowledged or+ /// not; an unknown or empty selection is refused as before.+ #[test]+ fn password_stores_and_unknown_paths_are_refused() {+ let m = selection_manifest();+ let err = select_for_request(+ &m,+ "firefox",+ "space-1",+ Some(&["firefox/prefs.js".into(), "firefox/logins.json".into()]),+ true,+ )+ .unwrap_err();+ assert!(err.to_string().contains("request_site_login"), "{err}");+ assert!(+ select_for_request(&m, "firefox", "space-1", Some(&["nope".into()]), true).is_err()+ );+ assert!(select_for_request(&m, "firefox", "space-1", Some(&[]), true).is_err());+ }++ /// One access request as filed: app, target, paths, reason.+ type Filed = (String, String, Vec<String>, String);++ /// A Keyvault that records what it was asked for.+ #[derive(Default)]+ struct Recorder {+ filed: std::sync::Mutex<Vec<Filed>>,+ }++ #[async_trait::async_trait]+ impl cua_spaces::teleport_broker::SessionBroker for Recorder {+ async fn request_access(+ &self,+ app: &str,+ target: &str,+ paths: &[String],+ _duration_secs: u64,+ reason: &str,+ ) -> std::result::Result<String, cua_spaces::teleport_broker::SessionBrokerError> {+ self.filed.lock().unwrap().push((+ app.into(),+ target.into(),+ paths.to_vec(),+ reason.into(),+ ));+ Ok("req-1".into())+ }++ async fn await_and_deliver(+ &self,+ _app: &str,+ _target: &str,+ _request_id: &str,+ _timeout: std::time::Duration,+ ) -> std::result::Result<+ cua_spaces::teleport_broker::SessionDelivery,+ cua_spaces::teleport_broker::SessionBrokerError,+ > {+ Ok(cua_spaces::teleport_broker::SessionDelivery::Pending)+ }+ }++ /// The first call files the request with the selected paths, not the+ /// whole app, and says so in the reply and the reason.+ #[tokio::test]+ async fn the_request_filed_carries_the_selection() {+ let m = selection_manifest();+ let sel = select_for_request(+ &m,+ "firefox",+ "space-1",+ Some(&["firefox/prefs.js".to_string()]),+ false,+ )+ .unwrap();+ let rec = Arc::new(Recorder::default());+ let dynamic: Arc<dyn cua_spaces::teleport_broker::SessionBroker> = rec.clone();+ let out = teleport_app_broker(Some(&dynamic), &m, "space-1", None, Some(&sel))+ .await+ .unwrap();+ let filed = rec.filed.lock().unwrap().clone();+ assert_eq!(filed.len(), 1);+ assert_eq!(filed[0].0, "firefox");+ assert_eq!(filed[0].2, ["firefox/prefs.js"]);+ assert!(filed[0].3.contains("Preferences"), "{}", filed[0].3);+ let reply: Value =+ serde_json::from_str(out.content[0]["text"].as_str().expect("a text reply")).unwrap();+ assert_eq!(reply["request_id"], "req-1");+ assert_eq!(reply["selected_paths"], json!(["firefox/prefs.js"]));+ let sent: Vec<&str> = reply["would_send"]["items"]+ .as_array()+ .unwrap()+ .iter()+ .map(|i| i["relative_path"].as_str().unwrap())+ .collect();+ assert_eq!(sent, ["firefox/prefs.js"]);+ }++ /// Without a valid selection nothing is ever filed.+ #[tokio::test]+ async fn no_request_is_filed_without_a_selection() {+ let m = selection_manifest();+ let rec = Arc::new(Recorder::default());+ let dynamic: Arc<dyn cua_spaces::teleport_broker::SessionBroker> = rec.clone();+ let err = teleport_app_broker(Some(&dynamic), &m, "space-1", None, None)+ .await+ .unwrap_err();+ assert_eq!(err.tag(), "teleport_refused");+ assert!(rec.filed.lock().unwrap().is_empty());+ }}diff --git a/libs/cua/crates/cua-spaces-ext/tests/spaces_daemon_boundary.rs b/libs/cua/crates/cua-spaces-ext/tests/spaces_daemon_boundary.rsindex 64b8efa7a7..6a36700f78 100644--- a/libs/cua/crates/cua-spaces-ext/tests/spaces_daemon_boundary.rs+++ b/libs/cua/crates/cua-spaces-ext/tests/spaces_daemon_boundary.rs@@ -276,15 +276,11 @@ async fn scenario() {.unwrap();assert_eq!(manifest.app, "firefox");// The default-checked set withholds `cookies.sqlite` (a sensitive,- // signed-in-session item). The requester's own `include` is shown to- // the human as `would_send` but is never authoritative (red-team E2:- // an MCP/automation caller cannot dictate what moves); what actually- // gets captured for a whole-app request is the human's OWN choice at- // approval time (`ApproveOptions::paths`). Compute the same widened- // selection a human reviewing "would send: ..., cookies.sqlite" and- // choosing to include it would produce, and approve with it -- this is- // what makes a human's "yes, include the signed-in cookies" choice- // actually reach the capture.+ // signed-in-session item), so the selection names it and acknowledges+ // it. That selection rides the Keyvault request: it is what the human+ // is shown (`would_send`) and what approval captures and delivers, and+ // nothing else (red-team E2: the caller cannot widen it; the human's own+ // `ApproveOptions::paths` can still narrow or widen it).let cookies_path = manifest.items.iter()diff --git a/libs/cua/crates/cua-spaces-ext/tests/teleport_app_selection.rs b/libs/cua/crates/cua-spaces-ext/tests/teleport_app_selection.rsnew file mode 100644index 0000000000..683e4f2b69--- /dev/null+++ b/libs/cua/crates/cua-spaces-ext/tests/teleport_app_selection.rs@@ -0,0 +1,355 @@+// SPDX-License-Identifier: FSL-1.1-MIT+// Copyright (c) 2026 Cua AI, Inc.++//! `teleport_app` moves what the caller selected and nothing else.+//!+//! The real `teleport_app` tool, the real Keyvault broker and the daemon's+//! delivery `Backend` run against an in-process mock spacesd, with a fixed+//! export provider that offers three items. The vault already holds a stored+//! session for the app: a request for one non-sensitive item used to be+//! filed as "the whole app", and approving it delivered the stored session+//! instead of the selection.+//!+//! Host-safe: the vault lives in a temp dir with a passphrase protector, the+//! session is fixed in-memory bytes (no real profile, Keychain or biometric+//! prompt), and the target is a mock.+#![cfg(unix)]++use std::collections::HashSet;+use std::io::Write;+use std::sync::Arc;+use std::time::Duration;++use cua_keyvault::CallerIdentity;+use cua_keyvault::broker::{ApproveOptions, Broker, FakePresence, ImportSpec, InitRequest};+use cua_spaces::Spaces;+use cua_spaces::extension::{SpacesExtension, ToolCall};+use cua_spaces_ext::TeleportExtension;+use cua_spaces_ext::daemon::keyvault::{DaemonBackend, Keyvault};+use cua_spaces_ext::teleport::AppSessions;+use cua_spacesd_client::testing::{MockAuth, MockServer};+use cua_teleport::bundle::BundleWriter;+use cua_teleport::{+ AppRef, ExportProvider, ExportRegistry, FakeHost, HostEffects, ManifestItem, Platform,+ TransferManifest, TransferScope, WindowRef,+};+use serde_json::{Value, json};++const TOKEN_MOCK: &str = "t";+const PREFS: &[u8] = b"PREFS-CONTENT-aaaa";+const NOTES: &[u8] = b"NOTES-CONTENT-bbbb";+const SESSION: &[u8] = b"SESSION-SECRET-cccc";++const FILES: [(&str, &[u8]); 3] = [+ ("fixture/prefs.json", PREFS),+ ("fixture/notes.txt", NOTES),+ ("fixture/session.json", SESSION),+];++/// A provider with a harmless item, another harmless one, and a sensitive+/// session item that is checked by default (like a single-app provider's+/// signed-in state). Capture writes only what it was asked to include.+struct FixtureProvider {+ host: Arc<dyn HostEffects>,+}++impl ExportProvider for FixtureProvider {+ fn id(&self) -> &str {+ "fixture"+ }+ fn display_name(&self) -> &str {+ "Fixture"+ }+ fn host(&self) -> &dyn HostEffects {+ self.host.as_ref()+ }+ fn platform_supported(&self, _platform: Platform) -> bool {+ true+ }+ fn matches(&self, app: &AppRef) -> bool {+ app.app_id == "fixture"+ }+ fn app_ids(&self) -> &[&str] {+ &["fixture"]+ }+ fn manifest(+ &self,+ _app: &AppRef,+ _window: Option<&WindowRef>,+ scope: TransferScope,+ ) -> cua_teleport::Result<TransferManifest> {+ let item =+ |label: &str, rel: &str, bytes: &[u8], sensitive: bool, checked: bool| ManifestItem {+ label: label.into(),+ rel_path: rel.into(),+ est_bytes: bytes.len() as u64,+ count: None,+ count_noun: None,+ sensitive,+ default_checked: checked,+ };+ Ok(TransferManifest {+ provider_id: "fixture".into(),+ app_display_name: "Fixture".into(),+ scope,+ items: vec![+ item("Preferences", FILES[0].0, PREFS, false, true),+ item("Notes", FILES[1].0, NOTES, false, true),+ item("Signed-in session", FILES[2].0, SESSION, true, true),+ ],+ total_est_bytes: (PREFS.len() + NOTES.len() + SESSION.len()) as u64,+ notes: vec![],+ })+ }+ fn capture_selected(+ &self,+ _app: &AppRef,+ scope: TransferScope,+ include: Option<&HashSet<String>>,+ out: &mut dyn Write,+ ) -> cua_teleport::Result<()> {+ let mut writer = BundleWriter::new(out, "fixture", "Fixture", scope);+ for (rel, bytes) in FILES {+ if include.is_none_or(|set| set.contains(rel)) {+ writer.add_bytes(rel, 0o600, bytes)?;+ }+ }+ writer.finish()?;+ Ok(())+ }+}++struct Rig {+ _reg: tempfile::TempDir,+ _vault: tempfile::TempDir,+ mock: Arc<MockServer>,+ spaces: Spaces,+ tool: TeleportExtension,+ kv: Keyvault,+ broker: Arc<Broker>,+ cua: CallerIdentity,+}++async fn rig() -> Rig {+ let mock = Arc::new(+ MockServer::start(MockAuth {+ token: Some(TOKEN_MOCK.into()),+ ..Default::default()+ })+ .await,+ );+ let reg = tempfile::tempdir().unwrap();+ let spaces = Spaces::builder()+ .home(reg.path())+ .operator_display(Arc::new(cua_spaces::operator::NoDisplay))+ .probe_timeout(Duration::from_secs(20))+ .build();+ spaces+ .add(&mock.url(), Some(TOKEN_MOCK.into()), Some("target".into()))+ .await+ .unwrap();++ let mut registry = ExportRegistry::new();+ registry.register(Box::new(FixtureProvider {+ host: Arc::new(FakeHost::new()),+ }));+ let sessions = Arc::new(AppSessions::from_registry(registry));+ let backend = Arc::new(DaemonBackend::new(spaces.clone(), sessions.clone()));+ let presence = Arc::new(FakePresence::new(true));+ let vault = tempfile::tempdir().unwrap();+ let kv = Keyvault::new(vault.path().join("keyvault"), backend, presence, false).unwrap();+ let broker = kv.broker();+ let cua = CallerIdentity::for_tests("com.trycua.cua", true);+ broker+ .init(+ &cua,+ InitRequest {+ os_protector: false,+ passphrase: Some("correct horse battery".into()),+ recovery_key: true,+ },+ )+ .await+ .unwrap();+ // The user has already saved this app's signed-in session in the vault+ // (the normal state after using Teleport once).+ broker+ .import(+ &cua,+ ImportSpec {+ app: "fixture".into(),+ whole_app: true,+ ..Default::default()+ },+ )+ .await+ .unwrap();+ Rig {+ _reg: reg,+ _vault: vault,+ mock,+ spaces,+ tool: TeleportExtension::new(Some(sessions)),+ kv,+ broker,+ cua,+ }+}++impl Rig {+ /// One `teleport_app` call as the MCP tool serves it.+ async fn teleport_app(&self, args: Value) -> cua_spaces::Result<Value> {+ let broker = self.kv.session_broker();+ let out = self+ .tool+ .call_tool(ToolCall {+ spaces: &self.spaces,+ tool: "teleport_app",+ args,+ broker: Some(&broker),+ pinned: None,+ })+ .await?;+ Ok(out.structured.unwrap_or_else(|| reply_json(&out.content)))+ }++ /// The user approves `request_id` in Cua, with the default options (as the+ /// app and the CLI do).+ async fn approve(&self, request_id: &str) {+ self.broker+ .approve(&self.cua, request_id, ApproveOptions::default())+ .await+ .unwrap();+ }+}++/// The JSON a tool answered in its text content.+fn reply_json(content: &[Value]) -> Value {+ let text = content+ .iter()+ .filter_map(|c| c.get("text").and_then(Value::as_str))+ .collect::<String>();+ serde_json::from_str(&text).expect("the reply is JSON")+}++fn carries(haystack: &[u8], needle: &[u8]) -> bool {+ haystack.windows(needle.len()).any(|w| w == needle)+}++fn would_send_paths(reply: &Value) -> Vec<String> {+ reply["would_send"]["items"]+ .as_array()+ .expect("would_send lists items")+ .iter()+ .map(|i| i["relative_path"].as_str().unwrap().to_string())+ .collect()+}++/// A request for one harmless item moves that item, and neither the stored+/// session nor the other items. The retry carries only the `request_id`,+/// as the SDK's does.+#[tokio::test]+async fn a_narrow_selection_delivers_only_the_selected_items() {+ let r = rig().await;+ let filed = r+ .teleport_app(json!({+ "space": "target",+ "app": "fixture",+ "include": ["fixture/prefs.json"],+ "acknowledge_sensitive": false,+ }))+ .await+ .unwrap();+ assert_eq!(filed["consent_required"], true, "{filed}");+ // The reply says what will move: only the selection.+ assert_eq!(would_send_paths(&filed), ["fixture/prefs.json"]);+ assert_eq!(filed["selected_paths"], json!(["fixture/prefs.json"]));+ let id = filed["request_id"]+ .as_str()+ .expect("request id")+ .to_string();+ // The request on file is for that selection, and not for the stored+ // session the vault already holds.+ let pending = r.broker.list_pending(&r.cua).await.unwrap();+ assert_eq!(pending.len(), 1);+ assert_eq!(+ pending[0].request.paths.as_deref(),+ Some(&["fixture/prefs.json".to_string()][..])+ );+ assert!(pending[0].items.is_empty(), "{:?}", pending[0].items);+ assert!(+ r.mock.state.teleport_imports().is_empty(),+ "nothing moved yet"+ );++ r.approve(&id).await;+ let moved = r+ .teleport_app(json!({"space": "target", "app": "fixture", "request_id": id}))+ .await+ .unwrap();+ assert_eq!(moved["moved"], true, "{moved}");++ let imports = r.mock.state.teleport_imports();+ assert_eq!(imports.len(), 1);+ let bundle = &imports[0].bundle;+ assert!(carries(bundle, PREFS), "the selected item moved");+ assert!(!carries(bundle, SESSION), "the stored session did not move");+ assert!(!carries(bundle, NOTES), "an unselected item did not move");+}++/// A sensitive item is refused unless acknowledged, before any request is+/// filed; acknowledged, exactly that item moves.+#[tokio::test]+async fn a_sensitive_selection_needs_the_acknowledgement_and_is_refused_before_filing() {+ let r = rig().await;+ for args in [+ json!({"space": "target", "app": "fixture", "include": ["fixture/session.json"]}),+ json!({"space": "target", "app": "fixture", "include": ["fixture/session.json"],+ "acknowledge_sensitive": false}),+ // The default-checked set holds the signed-in session.+ json!({"space": "target", "app": "fixture"}),+ ] {+ let err = r.teleport_app(args).await.unwrap_err();+ assert!(err.to_string().contains("sensitive"), "{err}");+ }+ assert!(+ r.broker.list_pending(&r.cua).await.unwrap().is_empty(),+ "no request was filed"+ );++ let filed = r+ .teleport_app(json!({+ "space": "target",+ "app": "fixture",+ "include": ["fixture/session.json"],+ "acknowledge_sensitive": true,+ }))+ .await+ .unwrap();+ assert_eq!(would_send_paths(&filed), ["fixture/session.json"]);+ let id = filed["request_id"].as_str().unwrap().to_string();+ r.approve(&id).await;+ let moved = r+ .teleport_app(json!({"space": "target", "app": "fixture", "request_id": id}))+ .await+ .unwrap();+ assert_eq!(moved["moved"], true, "{moved}");+ let imports = r.mock.state.teleport_imports();+ assert!(carries(&imports[0].bundle, SESSION));+ assert!(!carries(&imports[0].bundle, PREFS));+ assert!(!carries(&imports[0].bundle, NOTES));+}++/// A path the manifest does not offer, and an empty list, are refused too.+#[tokio::test]+async fn an_unknown_or_empty_selection_files_nothing() {+ let r = rig().await;+ for include in [json!(["fixture/other.json"]), json!([])] {+ let err = r+ .teleport_app(json!({"space": "target", "app": "fixture", "include": include}))+ .await+ .unwrap_err();+ assert_eq!(err.tag(), "teleport_refused", "{err}");+ }+ assert!(r.broker.list_pending(&r.cua).await.unwrap().is_empty());+}diff --git a/libs/cua/crates/cua-spaces/src/teleport_broker.rs b/libs/cua/crates/cua-spaces/src/teleport_broker.rsindex 2068b85aef..97c38b8804 100644--- a/libs/cua/crates/cua-spaces/src/teleport_broker.rs+++ b/libs/cua/crates/cua-spaces/src/teleport_broker.rs@@ -52,18 +52,24 @@ pub enum SessionDelivery {/// consent or an audited unattended rule.#[async_trait::async_trait]pub trait SessionBroker: Send + Sync {- /// Files an access request for the whole app session into `target`.+ /// Files an access request into `target` for exactly the manifest+ /// `paths` of `app` the caller selected (already validated against the+ /// manifest, and acknowledged when sensitive). The Keyvault captures and+ /// grants those parts and nothing else, never the whole stored session./// Returns the request id. Moves nothing.async fn request_access(&self,app: &str,target: &str,+ paths: &[String],duration_secs: u64,reason: &str,) -> Result<String, SessionBrokerError>;/// Waits up to `timeout` for the decision on `request_id` and, when it is- /// granted, performs the delivery through the broker.+ /// granted, performs the delivery through the broker. What is delivered+ /// is what the grant covers (the selection the request was filed with),+ /// whatever the caller passes here.async fn await_and_deliver(&self,app: &str,