ai-computer-client 0.1.1__py3-none-any.whl → 0.2.0__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/client.py CHANGED
@@ -1,7 +1,7 @@
1
1
  import aiohttp
2
2
  import json
3
3
  import asyncio
4
- from typing import Optional, Dict, AsyncGenerator, Union
4
+ from typing import Optional, Dict, AsyncGenerator, Union, List
5
5
  from dataclasses import dataclass
6
6
 
7
7
  @dataclass
@@ -241,6 +241,59 @@ class SandboxClient:
241
241
  except Exception as e:
242
242
  yield StreamEvent(type="error", data=f"Connection error: {str(e)}")
243
243
 
244
+ async def execute_shell(
245
+ self,
246
+ command: str,
247
+ args: Optional[List[str]] = None,
248
+ timeout: int = 30
249
+ ) -> SandboxResponse:
250
+ """Execute a shell command in the sandbox.
251
+
252
+ Args:
253
+ command: The shell command to execute
254
+ args: Optional list of arguments for the command
255
+ timeout: Maximum execution time in seconds
256
+
257
+ Returns:
258
+ SandboxResponse containing execution results
259
+ """
260
+ if not self.token or not self.sandbox_id:
261
+ return SandboxResponse(success=False, error="Client not properly initialized. Call setup() first")
262
+
263
+ # Ensure sandbox is ready
264
+ ready = await self.wait_for_ready()
265
+ if not ready.success:
266
+ return ready
267
+
268
+ headers = {
269
+ "Authorization": f"Bearer {self.token}",
270
+ "Content-Type": "application/json"
271
+ }
272
+
273
+ data = {
274
+ "command": command,
275
+ "args": args or [],
276
+ "timeout": timeout
277
+ }
278
+
279
+ try:
280
+ async with aiohttp.ClientSession() as session:
281
+ async with session.post(
282
+ f"{self.base_url}/api/v1/sandbox/{self.sandbox_id}/execute/shell",
283
+ headers=headers,
284
+ json=data
285
+ ) as response:
286
+ if response.status != 200:
287
+ error_text = await response.text()
288
+ return SandboxResponse(success=False, error=error_text)
289
+
290
+ # Parse the response
291
+ result = await response.json()
292
+ return SandboxResponse(success=True, data=result)
293
+
294
+ except Exception as e:
295
+ return SandboxResponse(success=False, error=f"Connection error: {str(e)}")
296
+
244
297
  async def cleanup(self) -> SandboxResponse:
245
298
  """Delete the sandbox.
246
299
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ai-computer-client
3
- Version: 0.1.1
3
+ Version: 0.2.0
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
@@ -0,0 +1,6 @@
1
+ ai_computer/__init__.py,sha256=g2yDiDT6i24MV3Y2JNfk2ZFkYvxvrN6NXywjZPslXDY,149
2
+ ai_computer/client.py,sha256=8LgOSO0AD3R8lljblzktIwPLwoAdmX4n-JG58ebd5xY,12119
3
+ ai_computer_client-0.2.0.dist-info/METADATA,sha256=3XRPWBjdJTIiErS_Kqnoc7iIOOO8LC2QIzc4k3AVHAc,5654
4
+ ai_computer_client-0.2.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
5
+ ai_computer_client-0.2.0.dist-info/licenses/LICENSE,sha256=N_0S5G1Wik2LWVDViJMAM0Z-6vTBX1bvDjb8vouBA-c,1068
6
+ ai_computer_client-0.2.0.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- ai_computer/__init__.py,sha256=g2yDiDT6i24MV3Y2JNfk2ZFkYvxvrN6NXywjZPslXDY,149
2
- ai_computer/client.py,sha256=PaBRmSFzgOXNxxQAd3zSCaqzZ8rcvUOhsnFulu40uhc,10214
3
- ai_computer_client-0.1.1.dist-info/METADATA,sha256=DZpD89o215WIDWe213XGNFOhEMUQ61P5kUzzLSr0eaE,5654
4
- ai_computer_client-0.1.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
5
- ai_computer_client-0.1.1.dist-info/licenses/LICENSE,sha256=N_0S5G1Wik2LWVDViJMAM0Z-6vTBX1bvDjb8vouBA-c,1068
6
- ai_computer_client-0.1.1.dist-info/RECORD,,