Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

fix(cua-driver): check_permissions prompts by default (#1396)

Francesco Bonacci9db8d6c1130b
diff --git a/docs/content/docs/cua-driver/reference/mcp-tools.mdx b/docs/content/docs/cua-driver/reference/mcp-tools.mdx
index 9234e7e7ea..9ad7d8c293 100644
--- a/docs/content/docs/cua-driver/reference/mcp-tools.mdx
+++ b/docs/content/docs/cua-driver/reference/mcp-tools.mdx
@@ -120,14 +120,14 @@ Launch an app hidden (no focus steal) and return its pid plus the initial `windo
### check_permissions
-Report TCC permission status for Accessibility and Screen Recording.
+Report TCC permission status for Accessibility and Screen Recording. By default also raises the system permission dialogs for any missing grants — Apple's request APIs no-op when the grant is already active, so the call is safe to repeat.
**Arguments:**
-- `prompt` (boolean, optional): If true, raise the system permission prompts for any missing grants. Otherwise the call is purely read-only.
+- `prompt` (boolean, optional): Raise the system permission prompts for missing grants. Default `true`. Pass `false` for a purely read-only status check.
```json
-{"prompt": true}
+{"prompt": false}
```
## Mouse
diff --git a/libs/cua-driver/Skills/cua-driver/SKILL.md b/libs/cua-driver/Skills/cua-driver/SKILL.md
index 7dbcd67391..092d808254 100644
--- a/libs/cua-driver/Skills/cua-driver/SKILL.md
+++ b/libs/cua-driver/Skills/cua-driver/SKILL.md
@@ -214,11 +214,14 @@ editor state.
1. `cua-driver` is on `$PATH` (`which cua-driver`). If not, point the
user at `scripts/install-local.sh` and stop.
-2. Run `cua-driver check_permissions`. If either grant is `false`, tell
- the user to open System Settings → Privacy & Security and grant
+2. Run `cua-driver check_permissions` (with the daemon up — see step 3).
+ The default behavior also raises the system permission dialogs for
+ any missing grants, so the user can grant on the spot. If either
+ grant still reads `false` after that (user dismissed the dialog),
+ tell them to open System Settings → Privacy & Security and grant
Accessibility and Screen Recording to `CuaDriver.app`, then stop.
- (`cua-driver check_permissions '{"prompt":true}'` raises the system
- dialogs, but only do that if the user asks — it steals focus.)
+ Pass `'{"prompt":false}'` for a purely read-only status check that
+ won't steal focus.
3. Start the daemon with `open -n -g -a CuaDriver --args serve` (the
recommended form — goes through LaunchServices so TCC attributes
the process to CuaDriver.app). `cua-driver serve &` also works;
diff --git a/libs/cua-driver/Sources/CuaDriverCLI/CallCommand.swift b/libs/cua-driver/Sources/CuaDriverCLI/CallCommand.swift
index 51d8134186..1f09722339 100644
--- a/libs/cua-driver/Sources/CuaDriverCLI/CallCommand.swift
+++ b/libs/cua-driver/Sources/CuaDriverCLI/CallCommand.swift
@@ -124,6 +124,7 @@ struct CallCommand: AsyncParsableCommand {
private func runInProcess(arguments: [String: Value]?) async throws {
let registry = ToolRegistry.default
+ var arguments = arguments
guard let handler = registry.handlers[toolName] else {
printUnknownTool(toolName, registry: registry)
@@ -152,7 +153,10 @@ struct CallCommand: AsyncParsableCommand {
// "NOT granted" even when the user has granted both permissions
// to CuaDriver.app. If the daemon were up we'd already have
// forwarded in run(); reaching this branch means no daemon is
- // listening. Warn the user that the fallback answer is unreliable.
+ // listening. Warn the user that the fallback answer is unreliable,
+ // and force `prompt: false` — the tool's default would otherwise
+ // raise a TCC dialog attributed to the calling shell/IDE bundle,
+ // not CuaDriver.app, so the user would grant the wrong identity.
if toolName == "check_permissions" {
printToStderr(
"""
@@ -160,6 +164,9 @@ struct CallCommand: AsyncParsableCommand {
For authoritative results, start the daemon first: `open -n -g -a CuaDriver --args serve`, then re-run this check.
"""
)
+ var coerced = arguments ?? [:]
+ coerced["prompt"] = .bool(false)
+ arguments = coerced
}
let result: CallTool.Result
diff --git a/libs/cua-driver/Sources/CuaDriverServer/Tools/CheckPermissionsTool.swift b/libs/cua-driver/Sources/CuaDriverServer/Tools/CheckPermissionsTool.swift
index 2d67f1fed5..77096b38ea 100644
--- a/libs/cua-driver/Sources/CuaDriverServer/Tools/CheckPermissionsTool.swift
+++ b/libs/cua-driver/Sources/CuaDriverServer/Tools/CheckPermissionsTool.swift
@@ -8,8 +8,10 @@ public enum CheckPermissionsTool {
name: "check_permissions",
description: """
Report TCC permission status for Accessibility and Screen Recording.
- Pass {"prompt": true} to raise the system permission dialogs for any
- missing grants — otherwise the call is purely read-only.
+ By default also raises the system permission dialogs for any missing
+ grants — Apple's request APIs are no-ops when the grant is already
+ active, so this is safe to call repeatedly. Pass {"prompt": false}
+ for a purely read-only status check.
""",
inputSchema: [
"type": "object",
@@ -17,13 +19,13 @@ public enum CheckPermissionsTool {
"prompt": [
"type": "boolean",
"description":
- "If true, raise the system permission prompts for missing grants.",
+ "Raise the system permission prompts for missing grants. Default true.",
]
],
"additionalProperties": false,
],
annotations: .init(
- // Not readOnly when prompt=true (it may raise a modal dialog).
+ // Not readOnly because the default path may raise a modal dialog.
readOnlyHint: false,
destructiveHint: false,
idempotentHint: true,
@@ -31,7 +33,13 @@ public enum CheckPermissionsTool {
)
),
invoke: { arguments in
- if arguments?["prompt"]?.boolValue == true {
+ // Default to prompting. The point of `check_permissions` is to
+ // surface and resolve missing grants — a read-only status check
+ // that leaves the user hunting for `CuaDriver.app` in System
+ // Settings is the wrong default. Apple's request APIs no-op
+ // when the grant is already active, so prompting is safe.
+ let shouldPrompt = arguments?["prompt"]?.boolValue ?? true
+ if shouldPrompt {
_ = Permissions.requestAccessibility()
_ = Permissions.requestScreenRecording()
}