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 Electron discovery and offline native MCP preflight (#5747)
injaneityb7e61f32354b
diff --git a/libs/cua-driver-bench/README.md b/libs/cua-driver-bench/README.mdindex b27528f028..2e67ffdde9 100644--- a/libs/cua-driver-bench/README.md+++ b/libs/cua-driver-bench/README.md@@ -145,10 +145,14 @@ cd "$CDB_BENCH_WORK/src/macos_bench"swift/build.sh "$CDB_BENCH_WORK/build" # BenchLab.app and BenchSentinel.app, ad-hoc signed```-Install the task apps' Electron dependency, pinned by each lockfile:+Install the task apps' Electron dependency, pinned by each lockfile. npm 12 may+skip Electron's postinstall; run its installer in each app if `dist` is missing:```bash-for app in "$CDB_BENCH_WORK"/taskpack/tasks/shared/*/apps/*; do (cd "$app" && npm ci); done+for app in "$CDB_BENCH_WORK"/taskpack/tasks/shared/*/apps/*; do+ (cd "$app" && npm ci &&+ { [ -d node_modules/electron/dist ] || node node_modules/electron/install.js; })+done```### 3. Install each setupdiff --git a/libs/cua-driver-bench/automated-eval/macos_bench/cdb_adapter.py b/libs/cua-driver-bench/automated-eval/macos_bench/cdb_adapter.pyindex aa77fa063f..f276bb340c 100644--- a/libs/cua-driver-bench/automated-eval/macos_bench/cdb_adapter.py+++ b/libs/cua-driver-bench/automated-eval/macos_bench/cdb_adapter.py@@ -41,6 +41,7 @@ import claude_arms as caSKIP_KINDS = {"terminal", "editor"}EVAL_ENTRY = "/usr/local/libexec/cdb-eval-run"APP_PATH = "/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"+ELECTRON_DIST = Path("node_modules/electron/dist")REPO_TASKPACK = Path(__file__).resolve().parents[2] / "taskpack"@@ -54,6 +55,14 @@ def pack_tasks_root() -> Path:return (work if work.is_dir() else REPO_TASKPACK) / "tasks"+def missing_electron_apps(root: Path | None = None) -> tuple[list[str], list[str]]:+ root = root if root is not None else pack_tasks_root()+ apps = [p.parent for p in sorted(root.glob("*/*/apps/*/package.json"))]+ expected = [str(app.relative_to(root)) for app in apps]+ missing = [name for app, name in zip(apps, expected) if not (app / ELECTRON_DIST).is_dir()]+ return expected, missing++def tree_sha256(path: Path) -> str:"""Digest of a directory tree: relative paths and file bytes, skipping node_modules and caches."""digest = hashlib.sha256()@@ -200,7 +209,7 @@ def electron_argv(argv: list[str], cwd: str, name: str) -> list[str]:at = next(i for i in range(len(argv) - 1) if argv[i] == "npx" and argv[i + 1] == "electron")except StopIteration:return argv- source = Path(cwd) / "node_modules/electron/dist/Electron.app"+ source = Path(cwd) / ELECTRON_DIST / "Electron.app"if not source.is_dir():raise RuntimeError(f"Electron.app missing for {name}: {source}")bundle = named_electron_app(source, name)diff --git a/libs/cua-driver-bench/automated-eval/macos_bench/run_bench.py b/libs/cua-driver-bench/automated-eval/macos_bench/run_bench.pyindex cf2a0f3150..34ca469e4e 100644--- a/libs/cua-driver-bench/automated-eval/macos_bench/run_bench.py+++ b/libs/cua-driver-bench/automated-eval/macos_bench/run_bench.py@@ -2037,29 +2037,30 @@ def preflight(ctx: Ctx, with_models: bool = True) -> list[tuple[str, str, str]]:if not cxn.CODEX_CLI.is_file():add("Codex CLI in the ChatGPT app", "fail", str(cxn.CODEX_CLI))continue- try:- path, server = ctx.mcp[native_arm]- entry = cxn.server_entry(path, native_arm)- source = cxn.SOURCE_ARM[native_arm]- if (- source in ca.CUA_ARMS and not offline- ): # A23: Cua Driver under Codex uses that build's daemon- ensure_agent_daemon(ctx, source)- tools = mcp_list_tools(entry["command"], entry["args"], entry["env"])- want = (- {"js", "js_reset"}- if server == cxn.SERVER- else set(ca.load_pins().get("claude_cu_helper", {}).get("tools") or ["app_click"])- if server == ca.CU_HELPER_SERVER- else {"list_apps", "run_script"}- )- add(- f"{native_arm} {server} MCP server lists {sorted(want)}",- "pass" if want <= set(tools) else "fail",- f"{len(tools)} tools",- )- except Exception as error: # noqa: BLE001- add(f"{native_arm} MCP server", "fail", f"{type(error).__name__}: {error}")+ if not offline:+ try:+ path, server = ctx.mcp[native_arm]+ entry = cxn.server_entry(path, native_arm)+ source = cxn.SOURCE_ARM[native_arm]+ if source in ca.CUA_ARMS: # A23: Cua Driver under Codex uses that build's daemon+ ensure_agent_daemon(ctx, source)+ tools = mcp_list_tools(entry["command"], entry["args"], entry["env"])+ want = (+ {"js", "js_reset"}+ if server == cxn.SERVER+ else set(+ ca.load_pins().get("claude_cu_helper", {}).get("tools") or ["app_click"]+ )+ if server == ca.CU_HELPER_SERVER+ else {"list_apps", "run_script"}+ )+ add(+ f"{native_arm} {server} MCP server lists {sorted(want)}",+ "pass" if want <= set(tools) else "fail",+ f"{len(tools)} tools",+ )+ except Exception as error: # noqa: BLE001+ add(f"{native_arm} MCP server", "fail", f"{type(error).__name__}: {error}")for name, status, detail in native_codex_checks(ctx, native_arm, with_models and not offline):@@ -2096,11 +2097,12 @@ def preflight(ctx: Ctx, with_models: bool = True) -> list[tuple[str, str, str]]:"pass" if Path(f"/Applications/{app}.app").is_dir() else "fail",f"/Applications/{app}.app",)- electron = list(cdb_adapter.pack_tasks_root().glob("*/*/apps/*/node_modules/electron/dist"))+ electron, missing = cdb_adapter.missing_electron_apps()add("CDB Electron apps installed (npm ci + install.js)",- "pass" if len(electron) >= 5 else "fail",- f"{len(electron)} of 5",+ "fail" if missing else "pass",+ f"{len(electron) - len(missing)} of {len(electron)}"+ + (f"; missing: {', '.join(missing)}" if missing else ""),)add("CDB evaluator isolation (pack unreadable by the agent's user)",diff --git a/libs/cua-driver-bench/automated-eval/macos_bench/tests/test_cdb_adapter.py b/libs/cua-driver-bench/automated-eval/macos_bench/tests/test_cdb_adapter.pyindex c75cb375dc..ef3ac3c5a7 100644--- a/libs/cua-driver-bench/automated-eval/macos_bench/tests/test_cdb_adapter.py+++ b/libs/cua-driver-bench/automated-eval/macos_bench/tests/test_cdb_adapter.py@@ -101,6 +101,18 @@ class AdapterTest(unittest.TestCase):self.assertEqual(task.sub("${workspace_uri}"), task.workspace.as_uri())self.assertTrue(task.sub("${workspace_uri}").startswith("file:///"))+ def test_missing_electron_apps_follow_manifests(self) -> None:+ root = Path(self.tmp.name) / "tasks"+ expected = ["shared/syn/apps/desk", "shared/syn/apps/mail"]+ for name in expected:+ app = root / name+ (app / "node_modules/electron/dist").mkdir(parents=True)+ (app / "package.json").write_text("{}")+ (root / "shared/syn/apps/unmanaged/node_modules/electron/dist").mkdir(parents=True)+ self.assertEqual(cdb_adapter.missing_electron_apps(root), (expected, []))+ (root / expected[1] / "node_modules/electron/dist").rmdir()+ self.assertEqual(cdb_adapter.missing_electron_apps(), (expected, [expected[1]]))+def test_electron_apps_get_their_own_name_and_bundle_id(self) -> None:import plistlibfrom unittest import mockdiff --git a/libs/cua-driver-bench/automated-eval/macos_bench/tests/test_runner_flow.py b/libs/cua-driver-bench/automated-eval/macos_bench/tests/test_runner_flow.pyindex de8c869b17..0e79fba955 100644--- a/libs/cua-driver-bench/automated-eval/macos_bench/tests/test_runner_flow.py+++ b/libs/cua-driver-bench/automated-eval/macos_bench/tests/test_runner_flow.py@@ -94,6 +94,81 @@ def attempt_row(return row+class PreflightTest(unittest.TestCase):+ def test_native_mcp_is_live_only_online(self) -> None:+ with tempfile.TemporaryDirectory() as tmp:+ ctx = make_ctx(tmp, offline=True, allow_non_terminal=True)+ ctx.task_ids = []+ cli = Path(tmp) / "codex"+ cli.touch()+ with (+ mock.patch.object(rb, "terminal_ancestor", return_value=True),+ mock.patch.object(rb.rec, "free_gb", return_value=1000),+ mock.patch.object(rb, "check_pins", return_value=[]),+ mock.patch.object(rb, "registered_bench_copies", return_value=[]),+ mock.patch.object(+ rb.subprocess, "run", return_value=mock.Mock(returncode=1, stdout="")+ ),+ mock.patch.object(rb.cxn, "CODEX_CLI", cli),+ mock.patch.object(+ rb.cxn,+ "server_entry",+ return_value={"command": "mcp", "args": [], "env": {}},+ ),+ mock.patch.object(rb.ca, "cu_helper_observed", return_value={}),+ mock.patch.object(rb.ca, "check_cu_helper_pins", return_value=[]),+ mock.patch.object(rb, "cu_helper_live_checks", return_value=[]),+ mock.patch.object(rb, "native_codex_checks", return_value=[]) as native,+ mock.patch.object(rb, "mcp_list_tools") as probe,+ mock.patch.object(rb, "ensure_agent_daemon") as daemon,+ ):+ for arm in rb.cxn.ARMS:+ with self.subTest(arm=arm):+ ctx.arm_names = [arm]+ ctx.mcp[arm] = (Path(tmp) / "mcp.json", rb.cxn.SERVER_OF[arm])+ ctx.args.offline = True+ probe.reset_mock()+ daemon.reset_mock()+ probe.side_effect = AssertionError("offline MCP probe")+ daemon.side_effect = AssertionError("offline daemon")+ rows = rb.preflight(ctx)+ probe.assert_not_called()+ daemon.assert_not_called()+ native.assert_called_with(ctx, arm, False)+ self.assertIn(+ (+ "daemons, MCP servers, recording, model calls",+ "warn",+ "skipped (--offline)",+ ),+ rows,+ )+ ctx.args.offline = False+ probe.side_effect = None+ probe.return_value = [+ "js",+ "js_reset",+ "list_apps",+ "run_script",+ ] + rb.ca.load_pins()["claude_cu_helper"]["tools"]+ daemon.side_effect = None+ rows = rb.preflight(ctx)+ probe.assert_called_once_with("mcp", [], {})+ source = rb.cxn.SOURCE_ARM[arm]+ if source in rb.ca.CUA_ARMS:+ daemon.assert_called_once_with(ctx, source)+ else:+ daemon.assert_not_called()+ self.assertTrue(+ any(+ name.startswith(f"{arm} ")+ and "MCP server lists" in name+ and status == "pass"+ for name, status, _ in rows+ )+ )++class ExecuteTrialTest(unittest.TestCase):def run_trial(self, ctx: rb.Ctx, rows: list[dict]