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(sandbox): report directory types in file listings (#5175)
injaneity1e53b1cef43a
diff --git a/libs/python/cua-sandbox/cua_sandbox/interfaces/files.py b/libs/python/cua-sandbox/cua_sandbox/interfaces/files.pyindex 467637b0ed..0a2c87ae1d 100644--- a/libs/python/cua-sandbox/cua_sandbox/interfaces/files.py+++ b/libs/python/cua-sandbox/cua_sandbox/interfaces/files.py@@ -63,7 +63,10 @@ class Files:out: list[FileEntry] = []for item in raw:if isinstance(item, str):- out.append(FileEntry(name=item, path=f"{path.rstrip('/')}/{item}", is_dir=False))+ entry_path = f"{path.rstrip('/')}/{item}"+ out.append(+ FileEntry(name=item, path=entry_path, is_dir=await self.is_dir(entry_path))+ )elif isinstance(item, dict):out.append(FileEntry(diff --git a/libs/python/cua-sandbox/tests/test_files.py b/libs/python/cua-sandbox/tests/test_files.pynew file mode 100644index 0000000000..37caf87e02--- /dev/null+++ b/libs/python/cua-sandbox/tests/test_files.py@@ -0,0 +1,43 @@+"""File listing metadata from computer-server responses."""++from unittest.mock import AsyncMock, call++import pytest+from cua_sandbox.interfaces.files import FileEntry, Files+from cua_sandbox.transport.base import Transport++pytestmark = pytest.mark.asyncio++[email protected]("path", ["/work", "/work/", "/", "work"])+async def test_list_classifies_name_only_entries(path):+ transport = AsyncMock(spec=Transport)+ transport.send.side_effect = [+ {"success": True, "files": ["subdir", "note.txt"]},+ {"success": True, "exists": True},+ {"success": True, "exists": False},+ ]+ prefix = path.rstrip("/")++ entries = await Files(transport).list(path)++ assert entries == [+ FileEntry("subdir", f"{prefix}/subdir", True),+ FileEntry("note.txt", f"{prefix}/note.txt", False),+ ]+ assert transport.send.await_args_list == [+ call("list_dir", path=path),+ call("directory_exists", path=f"{prefix}/subdir"),+ call("directory_exists", path=f"{prefix}/note.txt"),+ ]+++async def test_list_propagates_directory_lookup_failure():+ transport = AsyncMock(spec=Transport)+ transport.send.side_effect = [+ {"success": True, "files": ["subdir"]},+ RuntimeError("connection closed"),+ ]++ with pytest.raises(RuntimeError, match="connection closed"):+ await Files(transport).list("/work")