ai-computer-client 0.3.0__py3-none-any.whl → 0.3.2__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.
ai_computer/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
1
  from .client import SandboxClient, SandboxResponse, StreamEvent, FileOperationResponse
2
2
 
3
- __version__ = "0.3.0"
3
+ __version__ = "0.3.2"
4
4
  __all__ = ["SandboxClient", "SandboxResponse", "StreamEvent", "FileOperationResponse"]
ai_computer/client.py CHANGED
@@ -63,7 +63,7 @@ class SandboxClient:
63
63
 
64
64
  def __init__(
65
65
  self,
66
- base_url: str = "http://aicomputer.dev",
66
+ base_url: str = "http://api.aicomputer.dev",
67
67
  token: Optional[str] = None
68
68
  ):
69
69
  self.base_url = base_url.rstrip('/')
@@ -350,7 +350,7 @@ class SandboxClient:
350
350
 
351
351
  Args:
352
352
  file_path: Path to the file to upload
353
- destination: Destination path in the sandbox (default: /workspace)
353
+ destination: Destination path in the sandbox (absolute path starting with /)
354
354
  chunk_size: Size of chunks for reading large files
355
355
  timeout: Maximum upload time in seconds
356
356
 
@@ -405,7 +405,7 @@ class SandboxClient:
405
405
  # Prepare multipart form data
406
406
  data = aiohttp.FormData()
407
407
  data.add_field('file',
408
- open(file_path, 'rb'),
408
+ open(file_path, 'rb').read(),
409
409
  filename=file_path.name,
410
410
  content_type=content_type)
411
411
  data.add_field('path', destination)
@@ -460,7 +460,8 @@ class SandboxClient:
460
460
  """Download a file from the sandbox environment.
461
461
 
462
462
  Args:
463
- sandbox_path: Path to the file in the sandbox
463
+ sandbox_path: Path to the file in the sandbox (must be an absolute path starting with /).
464
+ Any double slashes in the path will be normalized.
464
465
  local_path: Local path to save the file (default: current directory with original filename)
465
466
  chunk_size: Size of chunks for downloading large files
466
467
  timeout: Maximum download time in seconds
@@ -482,8 +483,11 @@ class SandboxClient:
482
483
  error=ready.error or "Sandbox not ready"
483
484
  )
484
485
 
485
- # Normalize sandbox path
486
- sandbox_path = sandbox_path.lstrip('/')
486
+ # Ensure path is absolute and normalize any double slashes
487
+ if not sandbox_path.startswith('/'):
488
+ sandbox_path = f"/{sandbox_path}"
489
+ clean_path = '/'.join(part for part in sandbox_path.split('/') if part)
490
+ clean_path = f"/{clean_path}"
487
491
 
488
492
  # Determine local path
489
493
  if local_path is None:
@@ -508,7 +512,7 @@ class SandboxClient:
508
512
 
509
513
  async with aiohttp.ClientSession(timeout=timeout_settings) as session:
510
514
  async with session.get(
511
- f"{self.base_url}/api/v1/sandbox/{self.sandbox_id}/files/download/{sandbox_path}",
515
+ f"{self.base_url}/api/v1/sandbox/{self.sandbox_id}/files/download{clean_path}",
512
516
  headers=headers
513
517
  ) as response:
514
518
  if response.status != 200:
@@ -572,7 +576,7 @@ class SandboxClient:
572
576
  Args:
573
577
  content: Bytes or file-like object to upload
574
578
  filename: Name to give the file in the sandbox
575
- destination: Destination path in the sandbox (default: /workspace)
579
+ destination: Destination path in the sandbox (absolute path starting with /)
576
580
  content_type: Optional MIME type (will be guessed from filename if not provided)
577
581
  timeout: Maximum upload time in seconds
578
582
 
@@ -687,7 +691,8 @@ class SandboxClient:
687
691
  """Download a file from the sandbox environment into memory.
688
692
 
689
693
  Args:
690
- sandbox_path: Path to the file in the sandbox
694
+ sandbox_path: Path to the file in the sandbox (must be an absolute path starting with /).
695
+ Any double slashes in the path will be normalized.
691
696
  chunk_size: Size of chunks for downloading large files
692
697
  timeout: Maximum download time in seconds
693
698
 
@@ -709,8 +714,11 @@ class SandboxClient:
709
714
  error=ready.error or "Sandbox not ready"
710
715
  )
711
716
 
712
- # Normalize sandbox path
713
- sandbox_path = sandbox_path.lstrip('/')
717
+ # Ensure path is absolute and normalize any double slashes
718
+ if not sandbox_path.startswith('/'):
719
+ sandbox_path = f"/{sandbox_path}"
720
+ clean_path = '/'.join(part for part in sandbox_path.split('/') if part)
721
+ clean_path = f"/{clean_path}"
714
722
 
715
723
  try:
716
724
  timeout_settings = aiohttp.ClientTimeout(
@@ -726,7 +734,7 @@ class SandboxClient:
726
734
 
727
735
  async with aiohttp.ClientSession(timeout=timeout_settings) as session:
728
736
  async with session.get(
729
- f"{self.base_url}/api/v1/sandbox/{self.sandbox_id}/files/download/{sandbox_path}",
737
+ f"{self.base_url}/api/v1/sandbox/{self.sandbox_id}/files/download{clean_path}",
730
738
  headers=headers
731
739
  ) as response:
732
740
  if response.status != 200:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ai-computer-client
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
4
  Summary: Python client for interacting with the AI Computer service
5
5
  Project-URL: Homepage, https://github.com/ColeMurray/ai-computer-client-python
6
6
  Project-URL: Documentation, https://github.com/ColeMurray/ai-computer-client-python#readme
@@ -130,7 +130,7 @@ Execution completed
130
130
  The main client class for interacting with the AI Computer service.
131
131
 
132
132
  ```python
133
- client = SandboxClient(base_url="http://aicomputer.dev")
133
+ client = SandboxClient(base_url="http://api.aicomputer.dev")
134
134
  ```
135
135
 
136
136
  #### Methods
@@ -0,0 +1,6 @@
1
+ ai_computer/__init__.py,sha256=GlAloQ10Yg8fIBKNj9HXovNHWAq9PsazLtYCIS1jOig,197
2
+ ai_computer/client.py,sha256=fo0OxmbZPYsSCWeYWkBzEGGDQ7bvx0qqvijDkr8zO8M,28733
3
+ ai_computer_client-0.3.2.dist-info/METADATA,sha256=aFEKdik1aa7F2hBhhWImmdewJgekuXnqDU5QJoPKzpU,5658
4
+ ai_computer_client-0.3.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
5
+ ai_computer_client-0.3.2.dist-info/licenses/LICENSE,sha256=N_0S5G1Wik2LWVDViJMAM0Z-6vTBX1bvDjb8vouBA-c,1068
6
+ ai_computer_client-0.3.2.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- ai_computer/__init__.py,sha256=41ibex5hg-OZ28VsmhU2RqxzzV6YEUD6vLbuNSddRsk,197
2
- ai_computer/client.py,sha256=--gmDUzABePoV7XWvo-zMH69Jg3JQR1vbotwEoAHtSg,28080
3
- ai_computer_client-0.3.0.dist-info/METADATA,sha256=rhUG0es12ZwHZApMsT8CBna_BB_2VJSrpMVr9Kc3wcs,5654
4
- ai_computer_client-0.3.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
5
- ai_computer_client-0.3.0.dist-info/licenses/LICENSE,sha256=N_0S5G1Wik2LWVDViJMAM0Z-6vTBX1bvDjb8vouBA-c,1068
6
- ai_computer_client-0.3.0.dist-info/RECORD,,