ai-computer-client 0.1.1__tar.gz → 0.2.0__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {ai_computer_client-0.1.1 → ai_computer_client-0.2.0}/PKG-INFO +1 -1
- {ai_computer_client-0.1.1 → ai_computer_client-0.2.0}/ai_computer/client.py +54 -1
- {ai_computer_client-0.1.1 → ai_computer_client-0.2.0}/pyproject.toml +1 -1
- {ai_computer_client-0.1.1 → ai_computer_client-0.2.0}/.gitignore +0 -0
- {ai_computer_client-0.1.1 → ai_computer_client-0.2.0}/LICENSE +0 -0
- {ai_computer_client-0.1.1 → ai_computer_client-0.2.0}/README.md +0 -0
- {ai_computer_client-0.1.1 → ai_computer_client-0.2.0}/ai_computer/__init__.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: ai-computer-client
|
3
|
-
Version: 0.
|
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
|
@@ -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
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|