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(teleport): say what macOS permission is missing before a teleport fails (CUA-2854) (#6183)
ddupontf4c3516d6b9e
diff --git a/docs/content/docs/cua-cli/reference/cli/files-teleport-and-keys.mdx b/docs/content/docs/cua-cli/reference/cli/files-teleport-and-keys.mdxindex 94082732e3..992e7789d3 100644--- a/docs/content/docs/cua-cli/reference/cli/files-teleport-and-keys.mdx+++ b/docs/content/docs/cua-cli/reference/cli/files-teleport-and-keys.mdx@@ -41,6 +41,7 @@ description: "Cua Volume files and sharing, moving an app session into a sandbox| [`cua teleport providers`](#cua-teleport-providers) | List the apps this computer can teleport (JSON). || [`cua teleport manifest`](#cua-teleport-manifest) | Describe what teleporting an app would move (JSON). || [`cua teleport push`](#cua-teleport-push) | Teleport an app session into a sandbox. |+| [`cua teleport doctor`](#cua-teleport-doctor) | Check, in plain words, that a teleport can work now: the Keyvault, permission to read the browser's files and tabs, and the profile. || [`cua keyvault`](#cua-keyvault) | The Cua Keyvault the daemon hosts: status, init, unlock, lock, saved passwords and approvals. || [`cua keyvault status`](#cua-keyvault-status) | Whether the Keyvault exists and is unlocked, and which protectors (Touch ID with the OS key store, a passphrase) the daemon can use. || [`cua keyvault init`](#cua-keyvault-init) | Create the Keyvault and print its recovery key once. |@@ -602,6 +603,26 @@ cua teleport push --app com.google.Chrome --scope tabs --sandbox devcua teleport push --app Slack --sandbox dev --all```+### `cua teleport doctor`++Check, in plain words, that a teleport can work now: the Keyvault, permission to read the browser's files and tabs, and the profile.++```text output+cua teleport doctor [OPTIONS]+```++| Flag | Type | Default | Description |+| --- | --- | --- | --- |+| <span id="cua-teleport-doctor--app"></span>`--app` | string | `chrome` | Browser to check (`chrome` or `edge`). |+| <span id="cua-teleport-doctor--profile"></span>`--profile` | string | | Profile to check: a name ("Profile 1"). Default: the one used last. |++**Examples**++```bash test="cli-shape" id="ref-cua-teleport-doctor"+cua teleport doctor+cua teleport doctor --app chrome --profile "Profile 1"+```+## `cua keyvault`The Cua Keyvault the daemon hosts: status, init, unlock, lock, saved passwords and approvals. Passphrases are prompted for (or read from stdin), never arguments.diff --git a/docs/content/docs/cua-cli/reference/cli/index.mdx b/docs/content/docs/cua-cli/reference/cli/index.mdxindex 819eec1bbd..af20acab92 100644--- a/docs/content/docs/cua-cli/reference/cli/index.mdx+++ b/docs/content/docs/cua-cli/reference/cli/index.mdx@@ -40,7 +40,7 @@ Cua Volume files and sharing, moving an app session into a sandbox, and the Cua| Command | Description | Subcommands || --- | --- | --- || <span id="cua-volume"></span><span id="cua-volume-ls"></span><span id="cua-volume-cat"></span><span id="cua-volume-put"></span><span id="cua-volume-rm"></span><span id="cua-volume-history"></span><span id="cua-volume-restore"></span><span id="cua-volume-grant"></span><span id="cua-volume-revoke"></span><span id="cua-volume-grants"></span><span id="cua-volume-requests"></span><span id="cua-volume-approve"></span><span id="cua-volume-deny"></span><span id="cua-volume-audit"></span><span id="cua-volume-mount"></span><span id="cua-volume-unmount"></span><span id="cua-volume-status"></span><span id="cua-volume-config"></span><span id="cua-volume-config-show"></span><span id="cua-volume-config-set"></span><span id="cua-volume-config-set-keys"></span><span id="cua-volume-named"></span><span id="cua-volume-named-ls"></span><span id="cua-volume-named-create"></span><span id="cua-volume-named-rm"></span>[`cua volume`](/cua-cli/reference/cli/files-teleport-and-keys#cua-volume) | Cua Volume: the versioned volume every Space and agent shares (public/, agents/<agent>/, spaces/<space>/), its grants and audit. | [`ls`](/cua-cli/reference/cli/files-teleport-and-keys#cua-volume-ls), [`cat`](/cua-cli/reference/cli/files-teleport-and-keys#cua-volume-cat), [`put`](/cua-cli/reference/cli/files-teleport-and-keys#cua-volume-put), [`rm`](/cua-cli/reference/cli/files-teleport-and-keys#cua-volume-rm), [`history`](/cua-cli/reference/cli/files-teleport-and-keys#cua-volume-history), [`restore`](/cua-cli/reference/cli/files-teleport-and-keys#cua-volume-restore), [`grant`](/cua-cli/reference/cli/files-teleport-and-keys#cua-volume-grant), [`revoke`](/cua-cli/reference/cli/files-teleport-and-keys#cua-volume-revoke), [`grants`](/cua-cli/reference/cli/files-teleport-and-keys#cua-volume-grants), [`requests`](/cua-cli/reference/cli/files-teleport-and-keys#cua-volume-requests), [`approve`](/cua-cli/reference/cli/files-teleport-and-keys#cua-volume-approve), [`deny`](/cua-cli/reference/cli/files-teleport-and-keys#cua-volume-deny), [`audit`](/cua-cli/reference/cli/files-teleport-and-keys#cua-volume-audit), [`mount`](/cua-cli/reference/cli/files-teleport-and-keys#cua-volume-mount), [`unmount`](/cua-cli/reference/cli/files-teleport-and-keys#cua-volume-unmount), [`status`](/cua-cli/reference/cli/files-teleport-and-keys#cua-volume-status), [`config`](/cua-cli/reference/cli/files-teleport-and-keys#cua-volume-config), [`config show`](/cua-cli/reference/cli/files-teleport-and-keys#cua-volume-config-show), [`config set`](/cua-cli/reference/cli/files-teleport-and-keys#cua-volume-config-set), [`config set-keys`](/cua-cli/reference/cli/files-teleport-and-keys#cua-volume-config-set-keys), [`named`](/cua-cli/reference/cli/files-teleport-and-keys#cua-volume-named), [`named ls`](/cua-cli/reference/cli/files-teleport-and-keys#cua-volume-named-ls), [`named create`](/cua-cli/reference/cli/files-teleport-and-keys#cua-volume-named-create), [`named rm`](/cua-cli/reference/cli/files-teleport-and-keys#cua-volume-named-rm) |-| <span id="cua-teleport"></span><span id="cua-teleport-providers"></span><span id="cua-teleport-manifest"></span><span id="cua-teleport-push"></span>[`cua teleport`](/cua-cli/reference/cli/files-teleport-and-keys#cua-teleport) | Move a desktop app session (tabs, profile, sign-in) into a sandbox. | [`providers`](/cua-cli/reference/cli/files-teleport-and-keys#cua-teleport-providers), [`manifest`](/cua-cli/reference/cli/files-teleport-and-keys#cua-teleport-manifest), [`push`](/cua-cli/reference/cli/files-teleport-and-keys#cua-teleport-push) |+| <span id="cua-teleport"></span><span id="cua-teleport-providers"></span><span id="cua-teleport-manifest"></span><span id="cua-teleport-push"></span><span id="cua-teleport-doctor"></span>[`cua teleport`](/cua-cli/reference/cli/files-teleport-and-keys#cua-teleport) | Move a desktop app session (tabs, profile, sign-in) into a sandbox. | [`providers`](/cua-cli/reference/cli/files-teleport-and-keys#cua-teleport-providers), [`manifest`](/cua-cli/reference/cli/files-teleport-and-keys#cua-teleport-manifest), [`push`](/cua-cli/reference/cli/files-teleport-and-keys#cua-teleport-push), [`doctor`](/cua-cli/reference/cli/files-teleport-and-keys#cua-teleport-doctor) || <span id="cua-keyvault"></span><span id="cua-keyvault-status"></span><span id="cua-keyvault-init"></span><span id="cua-keyvault-unlock"></span><span id="cua-keyvault-lock"></span><span id="cua-keyvault-import-passwords"></span><span id="cua-keyvault-import-session"></span><span id="cua-keyvault-requests"></span><span id="cua-keyvault-approve"></span><span id="cua-keyvault-deny"></span>[`cua keyvault`](/cua-cli/reference/cli/files-teleport-and-keys#cua-keyvault) | The Cua Keyvault the daemon hosts: status, init, unlock, lock, saved passwords and approvals. | [`status`](/cua-cli/reference/cli/files-teleport-and-keys#cua-keyvault-status), [`init`](/cua-cli/reference/cli/files-teleport-and-keys#cua-keyvault-init), [`unlock`](/cua-cli/reference/cli/files-teleport-and-keys#cua-keyvault-unlock), [`lock`](/cua-cli/reference/cli/files-teleport-and-keys#cua-keyvault-lock), [`import-passwords`](/cua-cli/reference/cli/files-teleport-and-keys#cua-keyvault-import-passwords), [`import-session`](/cua-cli/reference/cli/files-teleport-and-keys#cua-keyvault-import-session), [`requests`](/cua-cli/reference/cli/files-teleport-and-keys#cua-keyvault-requests), [`approve`](/cua-cli/reference/cli/files-teleport-and-keys#cua-keyvault-approve), [`deny`](/cua-cli/reference/cli/files-teleport-and-keys#cua-keyvault-deny) |### Sandboxesdiff --git a/docs/content/docs/spaces/guides/teleport-an-app.mdx b/docs/content/docs/spaces/guides/teleport-an-app.mdxindex c659b89869..67dc021729 100644--- a/docs/content/docs/spaces/guides/teleport-an-app.mdx+++ b/docs/content/docs/spaces/guides/teleport-an-app.mdx@@ -249,6 +249,26 @@ only. `--sandbox NAME` routes through your own [Cua Keyvault](/spaces/guides/keyraw ever leaves it); `--url` uploads a bundle straight to a spacesd endpointthe Keyvault does not manage as a Space, so it never goes through the vault.+### When macOS asks for permission++Sending a browser's signed-in sites reads its files, and macOS decides whether+Cua may do that. Teleport checks first and says what is missing, in words,+before it asks for Touch ID or reads anything:++```bash test="cli-shape" id="cua-teleport-doctor"+cua teleport doctor+cua teleport doctor --app chrome --profile "Profile 1"+```++It reports whether the Keyvault is set up, whether macOS lets Cua read the+browser's files (Full Disk Access) and its open tabs (Automation), and which+browser profiles exist, with the account signed in to each and the one used+last. Cua cannot grant these for you: macOS only lets you, in System Settings,+under Privacy and Security. macOS applies Full Disk Access to a program when it+starts, so after turning it on, restart the Cua daemon. Without Full Disk+Access you can still teleport open tabs only. Without a `--profile`, a push+reads the `Default` profile, so pick the one you are signed in to.+<Callout type="warn">A teleported session is a live sign-in that anyone controlling the Space canuse. Teleport only into Spaces you own, and prefer `tabs`.diff --git a/libs/cua/crates/cua-cli/src/lib.rs b/libs/cua/crates/cua-cli/src/lib.rsindex 116a46d149..86bf0956f3 100644--- a/libs/cua/crates/cua-cli/src/lib.rs+++ b/libs/cua/crates/cua-cli/src/lib.rs@@ -1704,7 +1704,9 @@ async fn run(cli: Cli, out: &mut dyn Write) -> Result<i32, CuaError> {return Ok(i32::from(ended.iter().any(|e| e.error.is_some())));}Command::Teleport(- cmd @ (teleport::TeleportCmd::Providers | teleport::TeleportCmd::Manifest(_)),+ cmd @ (teleport::TeleportCmd::Providers+ | teleport::TeleportCmd::Manifest(_)+ | teleport::TeleportCmd::Doctor(_)),) => {return extension::teleport(None, cmd.clone(), json, out).await;}diff --git a/libs/cua/crates/cua-cli/src/teleport.rs b/libs/cua/crates/cua-cli/src/teleport.rsindex 796478a988..4fcd00d69f 100644--- a/libs/cua/crates/cua-cli/src/teleport.rs+++ b/libs/cua/crates/cua-cli/src/teleport.rs@@ -28,6 +28,22 @@ pub enum TeleportCmd {# The whole Slack profile, every itemcua teleport push --app Slack --sandbox dev --all")]Push(PushArgs),+ /// Check, in plain words, that a teleport can work now: the Keyvault,+ /// permission to read the browser's files and tabs, and the profile.+ #[command(after_help = "Examples:+ cua teleport doctor+ cua teleport doctor --app chrome --profile \"Profile 1\"")]+ Doctor(DoctorArgs),+}++#[derive(Args, Debug, Clone)]+pub struct DoctorArgs {+ /// Browser to check (`chrome` or `edge`).+ #[arg(long, default_value = "chrome")]+ pub app: String,+ /// Profile to check: a name ("Profile 1"). Default: the one used last.+ #[arg(long)]+ pub profile: Option<String>,}#[derive(Args, Debug, Clone)]diff --git a/libs/cua/crates/cua-keyvault/src/broker.rs b/libs/cua/crates/cua-keyvault/src/broker.rsindex 29a60acb24..b87cbf22a1 100644--- a/libs/cua/crates/cua-keyvault/src/broker.rs+++ b/libs/cua/crates/cua-keyvault/src/broker.rs@@ -280,6 +280,76 @@ pub struct DomainInventory {pub unavailable_reason: String,}+/// Whether the OS lets Cua do one thing a teleport needs.+#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]+#[serde(rename_all = "snake_case")]+pub enum Access {+ /// Allowed, or not needed.+ Granted,+ /// The OS refused it.+ Denied,+ /// Only known by trying (macOS decides Automation on first use).+ #[default]+ Unknown,+}++/// One check of a [`Readiness`]: the state and a sentence a person can act on+/// (empty when there is nothing to do).+#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]+pub struct ReadinessCheck {+ /// The state.+ #[serde(default)]+ pub state: Access,+ /// What it means and what to do, in plain words.+ #[serde(default)]+ pub say: String,+}++/// A browser profile, for the picker.+#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]+pub struct BrowserProfile {+ /// Directory name (`Default`, `Profile 1`): what `profile` takes.+ pub dir: String,+ /// The name the person gave it, or the directory name.+ pub name: String,+ /// The account signed in to it, when the browser knows.+ #[serde(default)]+ pub account: Option<String>,+ /// The browser used it last.+ #[serde(default)]+ pub last_used: bool,+}++/// Whether a teleport of an app can work now, checked without reading any+/// secret and without asking for presence: what the OS allows, and which+/// profiles exist. The checks run in the daemon, the process that reads the+/// app, because OS permissions belong to it.+#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]+pub struct Readiness {+ /// Provider id.+ pub provider_id: String,+ /// App display name.+ pub app_display: String,+ /// The profile checked: the one asked for, else the last used.+ #[serde(default)]+ pub profile: Option<String>,+ /// The profile a teleport reads when none is named.+ #[serde(default)]+ pub default_profile: Option<String>,+ /// Every profile, `Default` first (empty for an app without profiles).+ #[serde(default)]+ pub profiles: Vec<BrowserProfile>,+ /// Reading the app's files (Full Disk Access on macOS).+ #[serde(default)]+ pub files: ReadinessCheck,+ /// Reading the app's open tabs (Automation on macOS).+ #[serde(default)]+ pub tabs: ReadinessCheck,+ /// The checked profile has no sign-in data (empty or wrong profile).+ #[serde(default)]+ pub profile_empty: bool,+}+/// What a host app offers.#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]pub struct Inventory {@@ -372,6 +442,16 @@ pub trait Backend: Send + Sync {}/// Lists what `app` offers (read-only; never values). Blocking.fn inventory(&self, app: &str, profile: Option<&str>) -> Result<Inventory>;+ /// Whether a teleport of `app` can work now: OS permissions and profiles,+ /// looked at only (no value is read). Blocking. The default knows+ /// nothing, which reads as "nothing to report".+ fn readiness(&self, app: &str, profile: Option<&str>) -> Result<Readiness> {+ Ok(Readiness {+ provider_id: app.to_string(),+ profile: profile.map(str::to_string),+ ..Default::default()+ })+ }/// Captures the chosen items. Blocking. Called only after user presence.fn capture(&self, spec: &ImportSpec) -> Result<Vec<Captured>>;/// Builds one bundle from the entries a codec made of same-provider@@ -1778,6 +1858,22 @@ impl Broker {.map_err(|e| Error::Backend(e.to_string()))?}+ /// Whether a teleport of `app` can work now (first party; no presence,+ /// no secret is read): the OS permissions and the profiles to choose from.+ pub async fn readiness(+ &self,+ caller: &CallerIdentity,+ app: &str,+ profile: Option<&str>,+ ) -> Result<Readiness> {+ policy::require_first_party(caller, "checking a host app")?;+ let b = self.backend.clone();+ let (app, profile) = (app.to_string(), profile.map(str::to_string));+ tokio::task::spawn_blocking(move || b.readiness(&app, profile.as_deref()))+ .await+ .map_err(|e| Error::Backend(e.to_string()))?+ }+/// Imports sites or an app session into the vault (first party +/// presence). Each site becomes its own item.pub async fn import(&self, caller: &CallerIdentity, spec: ImportSpec) -> Result<ImportReport> {diff --git a/libs/cua/crates/cua-keyvault/src/ipc.rs b/libs/cua/crates/cua-keyvault/src/ipc.rsindex 1fd6f75b41..83b849de50 100644--- a/libs/cua/crates/cua-keyvault/src/ipc.rs+++ b/libs/cua/crates/cua-keyvault/src/ipc.rs@@ -100,6 +100,15 @@ pub enum Request {#[serde(default)]profile: Option<String>,},+ /// Whether a teleport of a host app can work now (OS permissions and+ /// profiles; reads no secret, asks for no presence).+ Readiness {+ /// Provider id.+ app: String,+ /// Profile to check; the last used one when omitted.+ #[serde(default)]+ profile: Option<String>,+ },/// Import into the vault.Import(ImportSpec),/// Import a browser's saved passwords (sealed; used only to sign in).@@ -378,6 +387,9 @@ pub async fn dispatch(broker: &Broker, caller: &CallerIdentity, req: Request) ->Request::Inventory { app, profile } => {reply!(broker.inventory(caller, &app, profile.as_deref()).await)}+ Request::Readiness { app, profile } => {+ reply!(broker.readiness(caller, &app, profile.as_deref()).await)+ }Request::Import(spec) => reply!(broker.import(caller, spec).await),Request::ImportPasswords(spec) => reply!(broker.import_passwords(caller, spec).await),Request::Login(r) => reply!(broker.login(caller, r).await),@@ -1059,6 +1071,18 @@ impl KeyvaultClient {}).await}+ /// Whether a teleport of `app` can work now.+ pub async fn readiness(+ &mut self,+ app: &str,+ profile: Option<&str>,+ ) -> Result<crate::broker::Readiness> {+ self.typed(&Request::Readiness {+ app: app.into(),+ profile: profile.map(Into::into),+ })+ .await+ }/// Import.pub async fn import(&mut self, spec: ImportSpec) -> Result<ImportReport> {self.typed(&Request::Import(spec)).awaitdiff --git a/libs/cua/crates/cua-keyvault/tests/broker.rs b/libs/cua/crates/cua-keyvault/tests/broker.rsindex db40125fa6..3caeb696c6 100644--- a/libs/cua/crates/cua-keyvault/tests/broker.rs+++ b/libs/cua/crates/cua-keyvault/tests/broker.rs@@ -2397,3 +2397,20 @@ async fn a_malformed_path_selection_is_refused() {}assert!(r.broker.list_pending(&r.cua).await.unwrap().is_empty());}++/// The readiness check is for the first-party app only, and it needs no+/// presence: it reads no secret and shows no name from the vault.+#[tokio::test]+async fn readiness_is_first_party_and_asks_for_no_presence() {+ let r = rig().await;+ r.presence.set(false);+ let ready = r+ .broker+ .readiness(&r.cua, "chrome", Some("Profile 1"))+ .await+ .unwrap();+ assert_eq!(ready.provider_id, "chrome");+ assert_eq!(ready.profile.as_deref(), Some("Profile 1"));+ assert!(r.broker.readiness(&r.koala, "chrome", None).await.is_err());+ assert!(r.broker.readiness(&r.evil, "chrome", None).await.is_err());+}diff --git a/libs/cua/crates/cua-spaces-cli/src/keyvault_cmd.rs b/libs/cua/crates/cua-spaces-cli/src/keyvault_cmd.rsindex 9b31565754..317faa6f2e 100644--- a/libs/cua/crates/cua-spaces-cli/src/keyvault_cmd.rs+++ b/libs/cua/crates/cua-spaces-cli/src/keyvault_cmd.rs@@ -375,6 +375,7 @@ pub async fn run(cmd: KeyvaultCmd, json: bool, out: &mut dyn Write) -> Result<i3}}KeyvaultCmd::ImportPasswords(a) => {+ crate::teleport::preflight(&mut c, &a.browser, a.profile.as_deref()).await?;if !json {eprintln!("The Cua daemon asks for Touch ID or your login password to import saved passwords."@@ -397,6 +398,7 @@ pub async fn run(cmd: KeyvaultCmd, json: bool, out: &mut dyn Write) -> Result<i3}}KeyvaultCmd::ImportSession(a) => {+ crate::teleport::preflight(&mut c, &a.app, a.profile.as_deref()).await?;if !json {eprintln!("The Cua daemon asks for Touch ID or your login password to import a session."diff --git a/libs/cua/crates/cua-spaces-cli/src/teleport.rs b/libs/cua/crates/cua-spaces-cli/src/teleport.rsindex 0cf2100844..e90238a0d4 100644--- a/libs/cua/crates/cua-spaces-cli/src/teleport.rs+++ b/libs/cua/crates/cua-spaces-cli/src/teleport.rs@@ -27,6 +27,7 @@ pub async fn run(match cmd {TeleportCmd::Providers => providers(&host, out),TeleportCmd::Manifest(args) => manifest(&host, args, out).await,+ TeleportCmd::Doctor(args) => doctor(args, json, out).await,TeleportCmd::Push(args) => {let cua =cua.ok_or_else(|| CuaError::Internal("teleport push needs the SDK".into()))?;@@ -35,6 +36,133 @@ pub async fn run(}}+/// Says, before a teleport reads or asks anything, what stops it: the+/// Keyvault not set up, macOS refusing to let the daemon read the browser, or+/// a profile with no sign-in data. Each is a plain sentence with the next+/// step; none of them is routed around. An app without profiles passes.+pub async fn preflight(+ client: &mut cua_keyvault::client::KeyvaultClient,+ app: &str,+ profile: Option<&str>,+) -> Result<(), CuaError> {+ use cua_keyvault::broker::Access;+ let status = client.status().await.map_err(kv_err)?;+ if !status.initialized {+ return Err(CuaError::PermissionDenied(+ "The Keyvault is not set up yet. Open Cua and create it; teleport keeps what it moves in it.".into(),+ ));+ }+ let ready = client.readiness(app, profile).await.map_err(kv_err)?;+ if ready.files.state == Access::Denied {+ return Err(CuaError::PermissionDenied(ready.files.say));+ }+ if ready.profile_empty {+ return Err(CuaError::InvalidArgument(ready.files.say));+ }+ Ok(())+}++/// `cua teleport doctor`: what a teleport needs, checked now, in plain words.+/// Nothing is read from the browser and no presence is asked; the checks run+/// in the daemon, the process whose permissions matter.+async fn doctor(+ args: cua_cli::teleport::DoctorArgs,+ json: bool,+ out: &mut dyn Write,+) -> Result<i32, CuaError> {+ use cua_keyvault::broker::Access;+ let mut client = cua_keyvault::client::KeyvaultClient::connect_default()+ .await+ .map_err(|e| {+ CuaError::Unsupported(format!(+ "The Cua daemon is not reachable ({e}). Open Cua, or start it with `cua daemon start`, then try again."+ ))+ })?;+ let status = client.status().await.map_err(kv_err)?;+ let ready = client+ .readiness(&args.app, args.profile.as_deref())+ .await+ .map_err(kv_err)?;+ let keyvault = if !status.initialized {+ "The Keyvault is not set up yet. Open Cua and create it; teleport keeps what it moves in it."+ } else {+ ""+ };+ let ok = keyvault.is_empty() && ready.files.state != Access::Denied && !ready.profile_empty;+ if json {+ util_json(+ out,+ serde_json::json!({+ "ready": ok,+ "keyvault": { "initialized": status.initialized, "unlocked": status.unlocked, "say": keyvault },+ "readiness": ready,+ }),+ );+ return Ok(i32::from(!ok));+ }+ let word = |ok: bool| if ok { "ready" } else { "needs attention" };+ line(out, format!("Keyvault {}", word(status.initialized)));+ if !keyvault.is_empty() {+ line(out, format!(" {keyvault}"));+ }+ line(+ out,+ format!(+ "{:<15} {}",+ format!("{} files", ready.app_display),+ word(ready.files.state != Access::Denied && !ready.profile_empty)+ ),+ );+ if !ready.files.say.is_empty() {+ line(out, format!(" {}", ready.files.say));+ }+ let tabs = match ready.tabs.state {+ Access::Granted => "ready",+ Access::Denied => "needs attention",+ Access::Unknown => "asked the first time",+ };+ line(+ out,+ format!("{:<15} {tabs}", format!("{} tabs", ready.app_display)),+ );+ if !ready.tabs.say.is_empty() {+ line(out, format!(" {}", ready.tabs.say));+ }+ if let Some(p) = &ready.profile {+ let shown = ready+ .profiles+ .iter()+ .find(|x| &x.dir == p)+ .map(|x| match &x.account {+ Some(a) => format!("{} ({a})", x.name),+ None => x.name.clone(),+ })+ .unwrap_or_else(|| p.clone());+ line(out, format!("Profile {shown}"));+ }+ if ready.profiles.len() > 1 {+ let all: Vec<String> = ready+ .profiles+ .iter()+ .map(|x| format!("{}{}", x.dir, if x.last_used { " (used last)" } else { "" }))+ .collect();+ line(out, format!("Profiles {}", all.join(", ")));+ line(+ out,+ "Pick one with --profile; without it a push reads Default.",+ );+ }+ Ok(i32::from(!ok))+}++fn util_json(out: &mut dyn Write, v: serde_json::Value) {+ line(out, v.to_string());+}++fn kv_err(e: cua_keyvault::Error) -> CuaError {+ CuaError::PermissionDenied(e.to_string())+}+fn scope(args: &AppArgs) -> Result<TransferScope, CuaError> {TransferScope::from_cli(&args.scope).ok_or_else(|| {CuaError::InvalidArgument(format!("invalid scope {:?}; use tabs or full", args.scope))@@ -54,7 +182,11 @@ pub fn teleport_err(e: cua_teleport::Error) -> CuaError {CuaError::Unsupported(m)}E::Teleport(T::UnsupportedScope { .. }) => CuaError::Unsupported(m),- E::Teleport(T::Provider(p)) if p.contains("not authorized") => {+ E::Teleport(T::Provider(p))+ if p.contains("not authorized")+ || p.contains("Full Disk Access")+ || p.contains("Automation") =>+ {CuaError::PermissionDenied(m)}// S1: refused because the destination is a relay: Space and@@ -157,6 +289,16 @@ async fn push_through_keyvault(json: bool,out: &mut dyn Write,) -> Result<i32, CuaError> {+ let mut client = cua_keyvault::client::KeyvaultClient::connect_default()+ .await+ .map_err(|e| {+ CuaError::Unsupported(format!(+ "teleport push goes through the Cua Keyvault, and it is not reachable ({e}); \+ install or open Cua, or run this as the signed `cua` app/CLI"+ ))+ })?;+ // Before anything is read or any prompt shown: can this work at all?+ preflight(&mut client, &args.app.app, args.app.profile.as_deref()).await?;let t = teleporter(host, &args.app);let app_ref = app_ref(&args.app);let scope_v = scope(&args.app)?;@@ -205,14 +347,6 @@ async fn push_through_keyvault(passwords: false,password_domains: None,};- let mut client = cua_keyvault::client::KeyvaultClient::connect_default()- .await- .map_err(|e| {- CuaError::Unsupported(format!(- "teleport push goes through the Cua Keyvault, and it is not reachable ({e}); \- install or open Cua, or run this as the signed `cua` app/CLI"- ))- })?;let outcome = client.import_and_teleport_launching(spec, sandbox.to_string(), false, !args.no_launch, |_| {}).awaitdiff --git a/libs/cua/crates/cua-spaces-ext/src/daemon/keyvault.rs b/libs/cua/crates/cua-spaces-ext/src/daemon/keyvault.rsindex e3fb488f9f..2fb00e6e23 100644--- a/libs/cua/crates/cua-spaces-ext/src/daemon/keyvault.rs+++ b/libs/cua/crates/cua-spaces-ext/src/daemon/keyvault.rs@@ -29,8 +29,8 @@ use crate::teleport::{AppSessions, TeleportScope};use base64::Engine as _;use cua_keyvault::broker::{AccessRequest, Backend, Broker, BrokerConfig, Captured, CookieFilter, DeliveryOutcome,- DomainInventory, ImportSpec, Inventory, LoginFill, LoginFilled, PasswordImportSpec, Selector,- TeleportRequest, TeleportStage, UserPresence,+ DomainInventory, ImportSpec, Inventory, LoginFill, LoginFilled, PasswordImportSpec, Readiness,+ Selector, TeleportRequest, TeleportStage, UserPresence,};use cua_keyvault::caller::{CallerIdentity, Signing};use cua_keyvault::model::{ItemKind, LoginRecord, PayloadEntry};@@ -597,6 +597,99 @@ impl Backend for DaemonBackend {})}+ fn readiness(&self, app: &str, profile: Option<&str>) -> KvResult<Readiness> {+ use cua_keyvault::broker::{Access, BrowserProfile, ReadinessCheck};+ use cua_teleport::privacy as px;+ let mut out = Readiness {+ provider_id: self+ .sessions+ .provider_id(app)+ .unwrap_or_else(|| app.to_string()),+ app_display: self.app_display(app),+ profile: profile.map(str::to_string),+ ..Default::default()+ };+ // Only a Chromium-family browser has profiles and a cookie store to+ // look at; the other apps have nothing to report here.+ if app != "chrome" && app != "edge" && app != "chromium" {+ out.files.state = Access::Granted;+ out.tabs.state = Access::Granted;+ return Ok(out);+ }+ let named = profile.map(str::trim).filter(|p| !p.is_empty());+ let default_dir = self+ .cookie_reader(None)+ .profile_dir()+ .map_err(|e| backend_err("find the browser profile", e))?;+ let root = px::user_data_dir_of(&default_dir);+ let profiles = root+ .as_deref()+ .map(px::browser_profiles)+ .unwrap_or_default();+ out.default_profile = default_dir+ .file_name()+ .map(|n| n.to_string_lossy().into_owned());+ // The profile to check: the one named, else the last used.+ let checked = named+ .map(str::to_string)+ .or_else(|| profiles.iter().find(|p| p.last_used).map(|p| p.dir.clone()))+ .or_else(|| out.default_profile.clone());+ out.profile = checked.clone();+ out.profiles = profiles+ .iter()+ .map(|p| BrowserProfile {+ dir: p.dir.clone(),+ name: p.name.clone(),+ account: p.account.clone(),+ last_used: p.last_used,+ })+ .collect();+ let dir = self+ .cookie_reader(checked.clone())+ .profile_dir()+ .map_err(|e| backend_err("find the browser profile", e))?;+ match px::probe_profile(&dir) {+ px::Probe::Readable => out.files.state = Access::Granted,+ px::Probe::Denied => {+ out.files = ReadinessCheck {+ state: Access::Denied,+ say: px::FULL_DISK_ACCESS_SAY.into(),+ };+ }+ px::Probe::Missing => {+ out.profile_empty = true;+ out.files = ReadinessCheck {+ state: Access::Granted,+ say: px::missing_profile_say(+ checked.as_deref().unwrap_or("Default"),+ &profiles,+ ),+ };+ }+ px::Probe::Other(e) => {+ out.files = ReadinessCheck {+ state: Access::Unknown,+ say: format!("The browser's files could not be checked: {e}"),+ };+ }+ }+ // Open tabs are read by asking the running browser, which macOS only+ // decides the first time it is asked: it cannot be checked without+ // that prompt, so it is reported as unknown, with the step to take.+ out.tabs = ReadinessCheck {+ state: Access::Unknown,+ say: if cfg!(target_os = "macos") {+ px::AUTOMATION_SAY.into()+ } else {+ String::new()+ },+ };+ if !cfg!(target_os = "macos") {+ out.tabs.state = Access::Granted;+ }+ Ok(out)+ }+fn capture(&self, spec: &ImportSpec) -> KvResult<Vec<Captured>> {let source = spec.profile.clone().unwrap_or_else(|| "default".into());let mut out: Vec<Captured> = Vec::new();diff --git a/libs/cua/crates/cua-spaces-ext/tests/keyvault_items.rs b/libs/cua/crates/cua-spaces-ext/tests/keyvault_items.rsindex 6e4dbd9733..adbaf5d81f 100644--- a/libs/cua/crates/cua-spaces-ext/tests/keyvault_items.rs+++ b/libs/cua/crates/cua-spaces-ext/tests/keyvault_items.rs@@ -432,3 +432,85 @@ fn a_named_browser_profile_is_the_one_captured() {assert!(!default[0].contains("Profile 1"), "{default:?}");assert!(named[0].contains("Profile 1"), "{named:?}");}++/// The readiness check names the profiles (with the account of each and the+/// last used one), checks the profile a teleport would read without reading+/// any value, and says so when a profile has no sign-in data.+#[test]+fn readiness_lists_profiles_and_checks_the_chosen_one_without_reading_values() {+ use cua_keyvault::broker::Access;+ use cua_teleport::browser_cookies::{TestCookieRow, write_cookies_db_for_tests};+ let home = tempfile::tempdir().unwrap();+ let root = home+ .path()+ .join(cua_teleport::layout::chrome::user_data_dir_for(+ Platform::current(),+ ));+ for p in ["Default", "Profile 1"] {+ std::fs::create_dir_all(root.join(p)).unwrap();+ std::fs::write(root.join(p).join("Preferences"), "{}").unwrap();+ }+ write_cookies_db_for_tests(+ &root.join("Profile 1"),+ &[TestCookieRow {+ host_key: ".github.com",+ name: "user_session",+ encrypted_value: b"v10-not-decryptable".to_vec(),+ path: "/",+ expires_utc: 0,+ is_secure: true,+ is_httponly: true,+ samesite: 1,+ }],+ )+ .unwrap();+ std::fs::write(+ root.join("Local State"),+ r#"{"profile":{"last_used":"Profile 1","info_cache":{+ "Default":{"name":"Personal"},+ "Profile 1":{"name":"Work","user_name":"[email protected]"}}}}"#,+ )+ .unwrap();+ let reg = tempfile::tempdir().unwrap();+ let spaces = Spaces::builder()+ .home(reg.path())+ .operator_display(Arc::new(cua_spaces::operator::NoDisplay))+ .build();+ let host: Arc<dyn HostEffects> = Arc::new(FakeHost::new().with_home(home.path()));+ let mut registry = ExportRegistry::new();+ registry.register(Box::new(Browser {+ host: host.clone(),+ profile: None,+ }));+ let b = DaemonBackend::new(spaces, Arc::new(AppSessions::from_registry(registry)))+ .with_host(host)+ .with_platform(Platform::current());+ // No profile named: the last used one is checked; Default is what a+ // push reads without one.+ let r = b.readiness("chrome", None).unwrap();+ assert_eq!(r.profile.as_deref(), Some("Profile 1"));+ assert_eq!(r.default_profile.as_deref(), Some("Default"));+ assert_eq!(r.files.state, Access::Granted);+ assert!(!r.profile_empty);+ let names: Vec<(&str, &str, bool)> = r+ .profiles+ .iter()+ .map(|p| (p.dir.as_str(), p.name.as_str(), p.last_used))+ .collect();+ assert_eq!(+ names,+ [("Default", "Personal", false), ("Profile 1", "Work", true)]+ );+ assert_eq!(r.profiles[1].account.as_deref(), Some("[email protected]"));+ // A profile with no cookie store says so and lists the real ones.+ let r = b.readiness("chrome", Some("Default")).unwrap();+ assert!(r.profile_empty, "{r:?}");+ assert!(+ r.files.say.contains("Default") && r.files.say.contains("Profile 1"),+ "{r:?}"+ );+ // An app that has no profiles has nothing to report.+ let r = b.readiness("firefox", None).unwrap();+ assert_eq!(r.files.state, Access::Granted);+ assert!(r.profiles.is_empty());+}diff --git a/libs/cua/crates/cua-telemetry/src/cli_commands.in b/libs/cua/crates/cua-telemetry/src/cli_commands.inindex 07d8e25f46..692ab253e6 100644--- a/libs/cua/crates/cua-telemetry/src/cli_commands.in+++ b/libs/cua/crates/cua-telemetry/src/cli_commands.in@@ -250,6 +250,7 @@"telemetry.schema","telemetry.show-last","telemetry.status",+ "teleport.doctor","teleport.manifest","teleport.providers","teleport.push",diff --git a/libs/cua/crates/cua-teleport/src/browser_cookies.rs b/libs/cua/crates/cua-teleport/src/browser_cookies.rsindex 425b248aa0..1fd2514f16 100644--- a/libs/cua/crates/cua-teleport/src/browser_cookies.rs+++ b/libs/cua/crates/cua-teleport/src/browser_cookies.rs@@ -390,7 +390,7 @@ impl ChromeCookies {// libsecret application); Windows is refused before it matters.Platform::Linux | Platform::Windows => "",};- let rows = read_rows(&db)?;+ let rows = read_rows(&db).map_err(plain)?;let wanted: Vec<String> = sites.iter().map(|s| s.trim().to_ascii_lowercase())@@ -460,7 +460,8 @@ impl ChromeCookies {if !db.is_file() {return Err(self.missing_store(&dir));}- Ok(read_rows(&db)?+ Ok(read_rows(&db)+ .map_err(plain)?.into_iter().map(|r| CookieHostRow {host_key: r.host_key,@@ -620,6 +621,18 @@ fn tempfile_copy(src: &Path) -> Result<TempCopy, TeleportError> {Ok(TempCopy(dst))}+/// A macOS privacy refusal in `e` said in plain words (what to turn on and+/// that the daemon must restart); any other error as it was.+fn plain(e: TeleportError) -> TeleportError {+ match &e {+ TeleportError::Provider(m) => match crate::privacy::plain_words(m) {+ Some(say) => TeleportError::Provider(say),+ None => e,+ },+ _ => e,+ }+}+/// One row for [`write_cookies_db_for_tests`] (tests and e2e fixtures).pub struct TestCookieRow<'a> {pub host_key: &'a str,diff --git a/libs/cua/crates/cua-teleport/src/lib.rs b/libs/cua/crates/cua-teleport/src/lib.rsindex 38c516bea6..66c1623158 100644--- a/libs/cua/crates/cua-teleport/src/lib.rs+++ b/libs/cua/crates/cua-teleport/src/lib.rs@@ -33,6 +33,7 @@ pub mod firefox_store;pub mod host;pub mod keychain;pub mod passwords;+pub mod privacy;pub mod providers;mod registry;pub mod safe_storage;diff --git a/libs/cua/crates/cua-teleport/src/privacy.rs b/libs/cua/crates/cua-teleport/src/privacy.rsnew file mode 100644index 0000000000..303a08b40c--- /dev/null+++ b/libs/cua/crates/cua-teleport/src/privacy.rs@@ -0,0 +1,280 @@+// SPDX-License-Identifier: FSL-1.1-MIT+// Copyright (c) 2026 Cua AI, Inc.++//! What macOS privacy settings do to a teleport, said in plain words before+//! it fails.+//!+//! Reading a browser's files can need Full Disk Access, and reading its open+//! tabs needs Automation. Neither can be granted by Cua: macOS only lets the+//! person grant them, and applies Full Disk Access to a process when it+//! starts. This module only *looks*: it opens the same files a teleport+//! reads (no content is read, nothing is decrypted) and turns the operating+//! system's refusal into a sentence with a next step. It never reads around a+//! refusal.++use std::path::{Path, PathBuf};++use serde::{Deserialize, Serialize};++/// Whether a read is allowed.+#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]+#[serde(rename_all = "snake_case")]+pub enum Access {+ /// Allowed (or not needed).+ Granted,+ /// macOS refused it.+ Denied,+ /// Cannot be known without asking (Automation is only decided when it is+ /// first used).+ #[default]+ Unknown,+}++/// One browser profile, as the picker shows it.+#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]+pub struct ProfileInfo {+ /// The directory name (`Default`, `Profile 1`): what `--profile` takes.+ pub dir: String,+ /// The name the person gave it (`Work`), or the directory name.+ pub name: String,+ /// The account signed in to it (an email), when the browser knows.+ #[serde(default)]+ pub account: Option<String>,+ /// The profile the browser used last.+ #[serde(default)]+ pub last_used: bool,+}++/// The profiles under a Chromium-family user-data directory, `Default` first+/// then the rest by name, with the names and accounts from `Local State` and+/// the last-used one marked. `Local State` holds no secret (names, emails),+/// and a missing or unreadable one just leaves the directory names.+pub fn browser_profiles(user_data_dir: &Path) -> Vec<ProfileInfo> {+ let state: serde_json::Value = std::fs::read(user_data_dir.join("Local State"))+ .ok()+ .and_then(|b| serde_json::from_slice(&b).ok())+ .unwrap_or_default();+ let cache = state.pointer("/profile/info_cache");+ let last_used = state+ .pointer("/profile/last_used")+ .and_then(|v| v.as_str())+ .map(str::to_string);+ let mut dirs: Vec<String> = std::fs::read_dir(user_data_dir)+ .map(|rd| {+ rd.flatten()+ .filter(|e| e.path().join("Preferences").is_file())+ .filter_map(|e| e.file_name().into_string().ok())+ .collect()+ })+ .unwrap_or_default();+ dirs.sort_by_key(|n| (n != "Default", n.clone()));+ let text = |dir: &str, key: &str| {+ cache+ .and_then(|c| c.get(dir))+ .and_then(|p| p.get(key))+ .and_then(|v| v.as_str())+ .map(str::trim)+ .filter(|s| !s.is_empty())+ .map(str::to_string)+ };+ dirs.into_iter()+ .map(|dir| ProfileInfo {+ name: text(&dir, "name").unwrap_or_else(|| dir.clone()),+ account: text(&dir, "user_name"),+ last_used: last_used.as_deref() == Some(dir.as_str()),+ dir,+ })+ .collect()+}++/// How reading a profile's files went when only looked at.+#[derive(Clone, Debug, PartialEq, Eq)]+pub enum Probe {+ /// The cookie store can be opened.+ Readable,+ /// macOS refused (Operation not permitted).+ Denied,+ /// There is no such store (a wrong or empty profile).+ Missing,+ /// Something else went wrong.+ Other(String),+}++/// Opens (does not read) the profile directory and its cookie store.+pub fn probe_profile(profile_dir: &Path) -> Probe {+ if let Err(e) = std::fs::read_dir(profile_dir) {+ return match e.kind() {+ std::io::ErrorKind::PermissionDenied => Probe::Denied,+ std::io::ErrorKind::NotFound => Probe::Missing,+ _ => Probe::Other(e.to_string()),+ };+ }+ let store = cua_teleport_bundle::layout::chrome::cookies_store(profile_dir);+ match std::fs::File::open(&store) {+ Ok(_) => Probe::Readable,+ Err(e) if e.kind() == std::io::ErrorKind::PermissionDenied => Probe::Denied,+ Err(e) if e.kind() == std::io::ErrorKind::NotFound => Probe::Missing,+ Err(e) => Probe::Other(e.to_string()),+ }+}++/// What to do about Full Disk Access, in words a person can follow.+pub const FULL_DISK_ACCESS_SAY: &str = "macOS is not letting Cua read this browser's files. \+Teleporting sign-ins needs Full Disk Access for Cua: open System Settings, Privacy & Security, \+Full Disk Access, and turn on Cua. Then restart the Cua daemon, because macOS only applies the \+setting to programs that start after it is on. Without it you can still teleport open tabs only.";++/// The Automation step, in plain words.+pub const AUTOMATION_SAY: &str = "macOS is not letting Cua ask the browser for its open tabs. \+Open System Settings, Privacy & Security, Automation, and allow Cua to control the browser. \+Without it you can still teleport signed-in sites, but not open tabs.";++/// The sentence for a profile that has no cookie store.+pub fn missing_profile_say(profile: &str, others: &[ProfileInfo]) -> String {+ if others.is_empty() {+ format!(+ "The browser profile {profile:?} has no sign-in data, and no other profiles were found."+ )+ } else {+ let names: Vec<&str> = others.iter().map(|p| p.dir.as_str()).collect();+ format!(+ "The browser profile {profile:?} has no sign-in data. Profiles found: {}.",+ names.join(", ")+ )+ }+}++/// Turns a raw failure message into a plain sentence when it is a macOS+/// privacy refusal, `None` when it is something else. Covers a refused file+/// read ("Operation not permitted") and a refused Apple event (-1743).+pub fn plain_words(raw: &str) -> Option<String> {+ let lower = raw.to_ascii_lowercase();+ if lower.contains("-1743") || lower.contains("not authorized to send apple events") {+ return Some(AUTOMATION_SAY.to_string());+ }+ if lower.contains("operation not permitted") || lower.contains("os error 1)") {+ return Some(FULL_DISK_ACCESS_SAY.to_string());+ }+ None+}++/// The user-data directory a profile directory sits in.+pub fn user_data_dir_of(profile_dir: &Path) -> Option<PathBuf> {+ profile_dir.parent().map(Path::to_path_buf)+}++#[cfg(test)]+mod tests {+ use super::*;++ fn profile(root: &Path, dir: &str) {+ std::fs::create_dir_all(root.join(dir)).unwrap();+ std::fs::write(root.join(dir).join("Preferences"), "{}").unwrap();+ }++ #[test]+ fn profiles_carry_names_accounts_and_the_last_used_one() {+ let root = tempfile::tempdir().unwrap();+ for d in ["Profile 2", "Default", "Profile 1"] {+ profile(root.path(), d);+ }+ std::fs::create_dir_all(root.path().join("Crashpad")).unwrap();+ std::fs::write(+ root.path().join("Local State"),+ r#"{"profile":{"last_used":"Profile 1","info_cache":{+ "Default":{"name":"Personal","user_name":"[email protected]"},+ "Profile 1":{"name":"Work","user_name":"[email protected]"}}}}"#,+ )+ .unwrap();+ let got = browser_profiles(root.path());+ let dirs: Vec<&str> = got.iter().map(|p| p.dir.as_str()).collect();+ assert_eq!(dirs, ["Default", "Profile 1", "Profile 2"]);+ assert_eq!(got[0].name, "Personal");+ assert_eq!(got[1].account.as_deref(), Some("[email protected]"));+ assert!(got[1].last_used && !got[0].last_used && !got[2].last_used);+ // No Local State entry: the directory name stands in.+ assert_eq!(got[2].name, "Profile 2");+ assert_eq!(got[2].account, None);+ }++ #[test]+ fn a_missing_local_state_leaves_directory_names() {+ let root = tempfile::tempdir().unwrap();+ profile(root.path(), "Default");+ let got = browser_profiles(root.path());+ assert_eq!(got.len(), 1);+ assert_eq!(got[0].name, "Default");+ assert!(!got[0].last_used);+ }++ #[test]+ fn probing_distinguishes_readable_and_missing_profiles() {+ let root = tempfile::tempdir().unwrap();+ let p = root.path().join("Default");+ std::fs::create_dir_all(&p).unwrap();+ assert_eq!(probe_profile(&p), Probe::Missing, "no cookie store yet");+ std::fs::write(p.join("Cookies"), b"x").unwrap();+ assert_eq!(probe_profile(&p), Probe::Readable);+ assert_eq!(probe_profile(&root.path().join("nope")), Probe::Missing);+ }++ #[cfg(unix)]+ #[test]+ fn a_refused_read_is_denied_not_missing() {+ use std::os::unix::fs::PermissionsExt;+ let root = tempfile::tempdir().unwrap();+ let p = root.path().join("Default");+ std::fs::create_dir_all(&p).unwrap();+ std::fs::write(p.join("Cookies"), b"x").unwrap();+ std::fs::set_permissions(p.join("Cookies"), std::fs::Permissions::from_mode(0o000))+ .unwrap();+ // Root ignores file modes: nothing is refused, so nothing to check.+ if std::fs::File::open(p.join("Cookies")).is_ok() {+ return;+ }+ assert_eq!(probe_profile(&p), Probe::Denied);+ std::fs::set_permissions(&p, std::fs::Permissions::from_mode(0o000)).unwrap();+ assert_eq!(probe_profile(&p), Probe::Denied);+ std::fs::set_permissions(&p, std::fs::Permissions::from_mode(0o755)).unwrap();+ }++ #[test]+ fn privacy_refusals_become_plain_sentences_and_other_errors_do_not() {+ let fda =+ plain_words("copying Cookies failed: Operation not permitted (os error 1)").unwrap();+ assert!(fda.contains("Full Disk Access") && fda.contains("restart the Cua daemon"));+ assert!(fda.contains("open tabs only"));+ let auto = plain_words(+ "Google Chrome is running but its open tabs could not be read: Not authorized to send Apple events to Google Chrome. (-1743)",+ )+ .unwrap();+ assert!(auto.contains("Automation"));+ assert_eq!(plain_words("no such file"), None);+ // Words, not codes, and no middle dot.+ for s in [fda, auto] {+ assert!(!s.contains('\u{b7}') && !s.contains("EPERM"), "{s}");+ }+ }++ #[test]+ fn a_missing_profile_lists_the_others() {+ let others = vec![+ ProfileInfo {+ dir: "Default".into(),+ name: "A".into(),+ ..Default::default()+ },+ ProfileInfo {+ dir: "Profile 1".into(),+ name: "B".into(),+ ..Default::default()+ },+ ];+ let s = missing_profile_say("Profile 9", &others);+ assert!(+ s.contains("Profile 9") && s.contains("Default, Profile 1"),+ "{s}"+ );+ assert!(missing_profile_say("X", &[]).contains("no other profiles"));+ }+}diff --git a/libs/cua/crates/cua-teleport/src/providers/chrome.rs b/libs/cua/crates/cua-teleport/src/providers/chrome.rsindex d6027050a3..b43c05e735 100644--- a/libs/cua/crates/cua-teleport/src/providers/chrome.rs+++ b/libs/cua/crates/cua-teleport/src/providers/chrome.rs@@ -313,12 +313,11 @@ return outend tell"#;match run_osascript_bounded(host, SCRIPT, APPLESCRIPT_BUDGET) {Ok(raw) => Ok(reorder_active_tab_first(&raw)),- Err(why) => Err(TeleportError::Provider(format!(- "Google Chrome is running but its open tabs could not be read: {why}. \- If this mentions Apple events or -1743, grant Automation control of \- Google Chrome to the process running the teleport (for example `cua`) in System Settings > \- Privacy & Security > Automation."- ))),+ Err(why) => Err(TeleportError::Provider(+ crate::privacy::plain_words(&why).unwrap_or_else(|| {+ format!("Google Chrome is running but its open tabs could not be read: {why}")+ }),+ )),}}diff --git a/scripts/docs-generators/cli-specs/cua.json b/scripts/docs-generators/cli-specs/cua.jsonindex 927cc4b54e..5b58d37e37 100644--- a/scripts/docs-generators/cli-specs/cua.json+++ b/scripts/docs-generators/cli-specs/cua.json@@ -18013,6 +18013,53 @@"subcommand_optional": false,"subcommands": [],"usage": "cua teleport push [OPTIONS] --app <APP>"+ },+ {+ "abstract": "Check, in plain words, that a teleport can work now: the Keyvault, permission to read the browser's files and tabs, and the profile",+ "after_help": "Examples:\n cua teleport doctor\n cua teleport doctor --app chrome --profile \"Profile 1\"",+ "aliases": [],+ "arguments": [],+ "flags": [],+ "hidden": false,+ "hidden_aliases": [],+ "name": "doctor",+ "options": [+ {+ "aliases": [],+ "default_value": "chrome",+ "env": null,+ "help": "Browser to check (`chrome` or `edge`)",+ "hidden": false,+ "is_optional": true,+ "multiple_values": false,+ "name": "app",+ "possible_values": [],+ "repeatable": false,+ "short_name": null,+ "takes_value": true,+ "type": "string",+ "value_name": "APP"+ },+ {+ "aliases": [],+ "default_value": null,+ "env": null,+ "help": "Profile to check: a name (\"Profile 1\"). Default: the one used last",+ "hidden": false,+ "is_optional": true,+ "multiple_values": false,+ "name": "profile",+ "possible_values": [],+ "repeatable": false,+ "short_name": null,+ "takes_value": true,+ "type": "string",+ "value_name": "PROFILE"+ }+ ],+ "subcommand_optional": false,+ "subcommands": [],+ "usage": "cua teleport doctor [OPTIONS]"}],"usage": "cua teleport [OPTIONS] <COMMAND>"