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: suppress telemetry logs and redact passwords from CLI JSON output (#1053)

Francesco Bonacci72b20df8d40d
diff --git a/libs/python/cua-cli/cua_cli/commands/local_image.py b/libs/python/cua-cli/cua_cli/commands/local_image.py
index 7ce1ffcf6c..abb938b125 100644
--- a/libs/python/cua-cli/cua_cli/commands/local_image.py
+++ b/libs/python/cua-cli/cua_cli/commands/local_image.py
@@ -30,7 +30,13 @@ from cua_cli.commands.platform import (
check_lume,
)
from cua_cli.utils.docker import allocate_ports, create_overlay_copy
-from cua_cli.utils.output import print_error, print_info, print_success, print_warning
+from cua_cli.utils.output import (
+ console,
+ print_error,
+ print_info,
+ print_success,
+ print_warning,
+)
from cua_cli.utils.paths import get_data_dir
from cua_cli.utils.registry import (
auto_discover_images,
@@ -129,7 +135,7 @@ def cmd_local_list(args: argparse.Namespace) -> int:
auto_discover_images()
registry = load_image_registry()
- output_format = getattr(args, "format", "table")
+ output_format = "json" if getattr(args, "json", False) else getattr(args, "format", "table")
filter_platform = getattr(args, "platform", None)
if output_format == "json":
@@ -193,10 +199,9 @@ def cmd_local_list(args: argparse.Namespace) -> int:
if info.get("parent"):
status = f"ready (from {info['parent']})" if status == "ready" else status
- status_color = "\033[92m" if "ready" in status else "\033[91m"
- reset = "\033[0m"
+ style = "green" if "ready" in status else "red"
- print(f"{name:<20} {platform:<15} {size:<10} {created:<12} {status_color}{status}{reset}")
+ console.print(f"{name:<20} {platform:<15} {size:<10} {created:<12} [{style}]{status}[/{style}]")
print("\n" + "=" * 85)
print("\nCommands:")
diff --git a/libs/python/cua-cli/cua_cli/commands/platform.py b/libs/python/cua-cli/cua_cli/commands/platform.py
index c6c158aaf9..8f1f22af70 100644
--- a/libs/python/cua-cli/cua_cli/commands/platform.py
+++ b/libs/python/cua-cli/cua_cli/commands/platform.py
@@ -16,7 +16,7 @@ import platform as sys_platform
import subprocess
from typing import Any, Dict, Optional
-from cua_cli.utils.output import print_error, print_info
+from cua_cli.utils.output import console, print_error, print_info
# =============================================================================
# Platform Configurations
@@ -180,29 +180,28 @@ def cmd_list(args: argparse.Namespace) -> int:
if name == "macos-lume":
if not is_macos:
status = "macOS only"
- status_color = "\033[90m"
+ style = "dim"
elif not lume_ok:
status = "needs Lume"
- status_color = "\033[33m"
+ style = "yellow"
else:
status = "ready"
- status_color = "\033[92m"
+ style = "green"
elif config.get("requires_kvm") and not kvm_ok:
if is_linux:
status = "no KVM"
- status_color = "\033[33m"
+ style = "yellow"
else:
status = "Linux only"
- status_color = "\033[90m"
+ style = "dim"
elif not docker_ok:
status = "no Docker"
- status_color = "\033[91m"
+ style = "red"
else:
status = "ready"
- status_color = "\033[92m"
+ style = "green"
- reset = "\033[0m"
- print(f"{name:<18} {description:<45} {status_color}{status:<12}{reset}")
+ console.print(f"{name:<18} {description:<45} [{style}]{status:<12}[/{style}]")
print("\n" + "=" * 80)
print("\nCommands:")
diff --git a/libs/python/cua-cli/cua_cli/commands/sandbox.py b/libs/python/cua-cli/cua_cli/commands/sandbox.py
index a9e7b7b723..8257d651e2 100644
--- a/libs/python/cua-cli/cua_cli/commands/sandbox.py
+++ b/libs/python/cua-cli/cua_cli/commands/sandbox.py
@@ -238,6 +238,12 @@ def _get_provider():
return CloudProvider(api_key=api_key)
+def _redact_sensitive(vm: dict) -> dict:
+ """Remove password and VNC URL from a VM dict."""
+ redacted = {k: v for k, v in vm.items() if k not in ("password", "vnc_url")}
+ return redacted
+
+
def cmd_list(args: argparse.Namespace) -> int:
"""List all sandboxes."""
@@ -248,7 +254,8 @@ def cmd_list(args: argparse.Namespace) -> int:
vms = run_async(_list())
if args.json:
- print_json(vms)
+ data = vms if args.show_passwords else [_redact_sensitive(vm) for vm in vms]
+ print_json(data)
return 0
if not vms:
@@ -343,8 +350,10 @@ def cmd_get(args: argparse.Namespace) -> int:
status_info = await provider.get_vm(args.name)
if vm_info:
- # Merge status info
- vm_info["status"] = status_info.get("status", vm_info.get("status"))
+ # Merge status info (only if get_vm returned a real status)
+ probe_status = status_info.get("status")
+ if probe_status and probe_status != "not_found":
+ vm_info["status"] = probe_status
vm_info["os_type"] = status_info.get("os_type") or vm_info.get("os_type")
return vm_info
else:
@@ -353,8 +362,9 @@ def cmd_get(args: argparse.Namespace) -> int:
result = run_async(_get())
if args.json:
- print_json(result)
- return 0
+ data = result if args.show_passwords else _redact_sensitive(result)
+ print_json(data)
+ return 1 if result.get("status") == "not_found" else 0
if result.get("status") == "not_found":
print_error(f"Sandbox '{args.name}' not found.")
@@ -522,19 +532,16 @@ def cmd_vnc(args: argparse.Namespace) -> int:
print_error(f"Sandbox '{args.name}' not found.")
return 1
- vnc_url = vm_info.get("vnc_url")
+ # Always construct VNC URL from host (the API's vnc_url may use a stale domain)
+ host = vm_info.get("host")
+ password = vm_info.get("password")
- if not vnc_url:
- # Try to construct it manually
- host = vm_info.get("host")
- password = vm_info.get("password")
-
- if host and password:
- encoded_password = quote(password, safe="")
- vnc_url = f"https://{host}/vnc.html?autoconnect=true&password={encoded_password}&show_dot=true"
- else:
- print_error("Could not determine VNC URL. Sandbox may not be ready.")
- return 1
+ if host and password:
+ encoded_password = quote(password, safe="")
+ vnc_url = f"https://{host}/vnc.html?autoconnect=true&password={encoded_password}&show_dot=true"
+ else:
+ print_error("Could not determine VNC URL. Sandbox may not be ready.")
+ return 1
print_info(f"Opening VNC: {vnc_url}")
webbrowser.open(vnc_url)
diff --git a/libs/python/cua-cli/cua_cli/main.py b/libs/python/cua-cli/cua_cli/main.py
index 5c8d1bcc9f..3e86d91722 100644
--- a/libs/python/cua-cli/cua_cli/main.py
+++ b/libs/python/cua-cli/cua_cli/main.py
@@ -1,6 +1,7 @@
"""Main entry point for CUA CLI."""
import argparse
+import logging
import sys
from cua_cli import __version__
@@ -52,6 +53,12 @@ For more information, visit https://docs.trycua.com
def main() -> int:
"""Main entry point for the CLI."""
+ # Suppress noisy INFO logs from dependencies (computer, core.telemetry, etc.)
+ # Must set on specific loggers since they configure their own handlers at import time
+ logging.basicConfig(level=logging.WARNING)
+ for name in ("computer", "core", "core.telemetry"):
+ logging.getLogger(name).setLevel(logging.WARNING)
+
parser = create_parser()
args = parser.parse_args()