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(computer-server): accept SDK-supplied timeout in write_bytes (#1347)
r33drichards8e8a879784dd
diff --git a/libs/python/computer-server/computer_server/handlers/android.py b/libs/python/computer-server/computer_server/handlers/android.pyindex 7cb24ccac1..0a310720e8 100644--- a/libs/python/computer-server/computer_server/handlers/android.py+++ b/libs/python/computer-server/computer_server/handlers/android.py@@ -797,22 +797,27 @@ class AndroidFileHandler(BaseFileHandler):else:raise RuntimeError(f"Failed to write file: {output}")- async def write_bytes(self, path: str, content_b64: str) -> Dict[str, Any]:- """Write binary content to file."""- # Decode base64 and write to temp file, then push to device+ async def write_bytes(+ self, path: str, content_b64: str, timeout: Optional[float] = None+ ) -> Dict[str, Any]:+ """Write binary content to file.++ ``timeout`` (seconds) is forwarded to the underlying ``adb push``+ when set; otherwise the ``CommandExecutor`` default applies.+ """import osimport tempfilecontent_bytes = base64.b64decode(content_b64)-- # Create temp filewith tempfile.NamedTemporaryFile(delete=False) as tmp:tmp.write(content_bytes)tmp_path = tmp.nametry:- # Push file to device- success, output = await adb_exec.run("push", tmp_path, path, decode=True)+ run_kwargs: Dict[str, Any] = {"decode": True}+ if timeout is not None:+ run_kwargs["timeout"] = timeout+ success, output = await adb_exec.run("push", tmp_path, path, **run_kwargs)if success:return {}else:diff --git a/libs/python/cua-sandbox/cua_sandbox/image.py b/libs/python/cua-sandbox/cua_sandbox/image.pyindex e56692f926..727cc4ac8f 100644--- a/libs/python/cua-sandbox/cua_sandbox/image.py+++ b/libs/python/cua-sandbox/cua_sandbox/image.py@@ -292,6 +292,7 @@ class Image:keystore_alias: str = "android",keystore_password: str = "android",builder: str = "pwa2apk",+ push_timeout: Optional[float] = None,) -> "Image":"""Build an APK from a PWA manifest URL and install it (Android only).@@ -319,6 +320,9 @@ class Image:keystore_password: Password for both the store and the key(default ``"android"``).builder: ``"pwa2apk"`` (default) or ``"bubblewrap"``.+ push_timeout: Optional seconds for the ``write_bytes`` ``adb push``+ of the built APK. When ``None`` the server default+ applies."""if builder not in ("pwa2apk", "bubblewrap"):raise ValueError(f"builder must be 'pwa2apk' or 'bubblewrap', got {builder!r}")@@ -330,6 +334,8 @@ class Image:layer["keystore"] = keystorelayer["keystore_alias"] = keystore_aliaslayer["keystore_password"] = keystore_password+ if push_timeout is not None:+ layer["push_timeout"] = push_timeoutreturn self._add_layer(layer)def uv_install(self, *packages: str) -> Image:diff --git a/libs/python/cua-sandbox/cua_sandbox/transport/cloud.py b/libs/python/cua-sandbox/cua_sandbox/transport/cloud.pyindex 97214de4dc..9bb9209cf4 100644--- a/libs/python/cua-sandbox/cua_sandbox/transport/cloud.py+++ b/libs/python/cua-sandbox/cua_sandbox/transport/cloud.py@@ -549,11 +549,13 @@ class CloudTransport(Transport):apk_bytes = Path(apk_path).read_bytes()dest = "/data/local/tmp/cua_pwa.apk"- await self._inner.send(- "write_bytes",- path=dest,- content_b64=base64.b64encode(apk_bytes).decode(),- )+ write_kwargs: dict = {+ "path": dest,+ "content_b64": base64.b64encode(apk_bytes).decode(),+ }+ if "push_timeout" in layer:+ write_kwargs["timeout"] = layer["push_timeout"]+ await self._inner.send("write_bytes", **write_kwargs)logger.debug(f"[cloud] installing APK: pm install -r {dest}")await self._inner.send("run_command",