cua-computer 0.2.13__py3-none-any.whl → 0.3.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,8 +3,7 @@
3
3
  from abc import ABC, abstractmethod
4
4
  from typing import Optional, Dict, Any, Tuple, List
5
5
  from ..logger import Logger, LogLevel
6
- from .models import MouseButton
7
-
6
+ from .models import MouseButton, CommandResult
8
7
 
9
8
  class BaseComputerInterface(ABC):
10
9
  """Base class for computer control interfaces."""
@@ -209,8 +208,14 @@ class BaseComputerInterface(ABC):
209
208
  pass
210
209
 
211
210
  @abstractmethod
212
- async def read_bytes(self, path: str) -> bytes:
213
- """Read file binary contents."""
211
+ async def read_bytes(self, path: str, offset: int = 0, length: Optional[int] = None) -> bytes:
212
+ """Read file binary contents with optional seeking support.
213
+
214
+ Args:
215
+ path: Path to the file
216
+ offset: Byte offset to start reading from (default: 0)
217
+ length: Number of bytes to read (default: None for entire file)
218
+ """
214
219
  pass
215
220
 
216
221
  @abstractmethod
@@ -234,8 +239,36 @@ class BaseComputerInterface(ABC):
234
239
  pass
235
240
 
236
241
  @abstractmethod
237
- async def run_command(self, command: str) -> Tuple[str, str]:
238
- """Run shell command."""
242
+ async def get_file_size(self, path: str) -> int:
243
+ """Get the size of a file in bytes."""
244
+ pass
245
+
246
+ @abstractmethod
247
+ async def run_command(self, command: str) -> CommandResult:
248
+ """Run shell command and return structured result.
249
+
250
+ Executes a shell command using subprocess.run with shell=True and check=False.
251
+ The command is run in the target environment and captures both stdout and stderr.
252
+
253
+ Args:
254
+ command (str): The shell command to execute
255
+
256
+ Returns:
257
+ CommandResult: A structured result containing:
258
+ - stdout (str): Standard output from the command
259
+ - stderr (str): Standard error from the command
260
+ - returncode (int): Exit code from the command (0 indicates success)
261
+
262
+ Raises:
263
+ RuntimeError: If the command execution fails at the system level
264
+
265
+ Example:
266
+ result = await interface.run_command("ls -la")
267
+ if result.returncode == 0:
268
+ print(f"Output: {result.stdout}")
269
+ else:
270
+ print(f"Error: {result.stderr}, Exit code: {result.returncode}")
271
+ """
239
272
  pass
240
273
 
241
274
  # Accessibility Actions