orgo 0.0.30__tar.gz → 0.0.31__tar.gz
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.
- {orgo-0.0.30 → orgo-0.0.31}/PKG-INFO +1 -1
- {orgo-0.0.30 → orgo-0.0.31}/pyproject.toml +1 -1
- orgo-0.0.31/src/orgo/computer.py +333 -0
- {orgo-0.0.30 → orgo-0.0.31}/src/orgo.egg-info/PKG-INFO +1 -1
- orgo-0.0.30/src/orgo/api/client.py +0 -180
- {orgo-0.0.30 → orgo-0.0.31}/README.md +0 -0
- {orgo-0.0.30 → orgo-0.0.31}/setup.cfg +0 -0
- {orgo-0.0.30 → orgo-0.0.31}/src/orgo/__init__.py +0 -0
- {orgo-0.0.30 → orgo-0.0.31}/src/orgo/api/__init__.py +0 -0
- /orgo-0.0.30/src/orgo/computer.py → /orgo-0.0.31/src/orgo/api/client.py +0 -0
- {orgo-0.0.30 → orgo-0.0.31}/src/orgo/project.py +0 -0
- {orgo-0.0.30 → orgo-0.0.31}/src/orgo/prompt.py +0 -0
- {orgo-0.0.30 → orgo-0.0.31}/src/orgo/utils/__init__.py +0 -0
- {orgo-0.0.30 → orgo-0.0.31}/src/orgo/utils/auth.py +0 -0
- {orgo-0.0.30 → orgo-0.0.31}/src/orgo.egg-info/SOURCES.txt +0 -0
- {orgo-0.0.30 → orgo-0.0.31}/src/orgo.egg-info/dependency_links.txt +0 -0
- {orgo-0.0.30 → orgo-0.0.31}/src/orgo.egg-info/requires.txt +0 -0
- {orgo-0.0.30 → orgo-0.0.31}/src/orgo.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
"""Computer class for interacting with Orgo virtual environments"""
|
|
2
|
+
import os as operating_system
|
|
3
|
+
import base64
|
|
4
|
+
import logging
|
|
5
|
+
import uuid
|
|
6
|
+
import io
|
|
7
|
+
from typing import Dict, List, Any, Optional, Callable, Literal, Union
|
|
8
|
+
from PIL import Image
|
|
9
|
+
import requests
|
|
10
|
+
from requests.exceptions import RequestException
|
|
11
|
+
|
|
12
|
+
from .api.client import ApiClient
|
|
13
|
+
from .prompt import get_provider
|
|
14
|
+
|
|
15
|
+
logger = logging.getLogger(__name__)
|
|
16
|
+
|
|
17
|
+
class Computer:
|
|
18
|
+
def __init__(self,
|
|
19
|
+
project: Optional[Union[str, 'Project']] = None,
|
|
20
|
+
name: Optional[str] = None,
|
|
21
|
+
computer_id: Optional[str] = None,
|
|
22
|
+
api_key: Optional[str] = None,
|
|
23
|
+
base_api_url: Optional[str] = None,
|
|
24
|
+
ram: Optional[Literal[1, 2, 4, 8, 16, 32, 64]] = None,
|
|
25
|
+
memory: Optional[Literal[1, 2, 4, 8, 16, 32, 64]] = None,
|
|
26
|
+
cpu: Optional[Literal[1, 2, 4, 8, 16]] = None,
|
|
27
|
+
os: Optional[Literal["linux", "windows"]] = None,
|
|
28
|
+
gpu: Optional[Literal["none", "a10", "l40s", "a100-40gb", "a100-80gb"]] = None):
|
|
29
|
+
"""
|
|
30
|
+
Initialize an Orgo virtual computer.
|
|
31
|
+
|
|
32
|
+
Args:
|
|
33
|
+
project: Project name (str) or Project instance. If not provided, creates a new project.
|
|
34
|
+
name: Computer name within the project (optional, auto-generated if not provided)
|
|
35
|
+
computer_id: Existing computer ID to connect to (optional)
|
|
36
|
+
api_key: Orgo API key (defaults to ORGO_API_KEY env var)
|
|
37
|
+
base_api_url: Custom API URL (optional)
|
|
38
|
+
ram/memory: RAM in GB (1, 2, 4, 8, 16, 32, or 64) - only used when creating
|
|
39
|
+
cpu: CPU cores (1, 2, 4, 8, or 16) - only used when creating
|
|
40
|
+
os: Operating system ("linux" or "windows") - only used when creating
|
|
41
|
+
gpu: GPU type - only used when creating
|
|
42
|
+
|
|
43
|
+
Examples:
|
|
44
|
+
# Create computer in new project
|
|
45
|
+
computer = Computer(ram=4, cpu=2)
|
|
46
|
+
|
|
47
|
+
# Create computer in existing project
|
|
48
|
+
computer = Computer(project="manus", ram=4, cpu=2)
|
|
49
|
+
|
|
50
|
+
# Connect to existing computer in project
|
|
51
|
+
computer = Computer(project="manus")
|
|
52
|
+
"""
|
|
53
|
+
self.api_key = api_key or operating_system.environ.get("ORGO_API_KEY")
|
|
54
|
+
self.base_api_url = base_api_url
|
|
55
|
+
self.api = ApiClient(self.api_key, self.base_api_url)
|
|
56
|
+
|
|
57
|
+
# Handle memory parameter as an alias for ram
|
|
58
|
+
if ram is None and memory is not None:
|
|
59
|
+
ram = memory
|
|
60
|
+
|
|
61
|
+
# Store configuration
|
|
62
|
+
self.os = os or "linux"
|
|
63
|
+
self.ram = ram or 2
|
|
64
|
+
self.cpu = cpu or 2
|
|
65
|
+
self.gpu = gpu or "none"
|
|
66
|
+
|
|
67
|
+
if computer_id:
|
|
68
|
+
# Connect to existing computer by ID
|
|
69
|
+
self._connect_by_id(computer_id)
|
|
70
|
+
elif project:
|
|
71
|
+
# Work with specified project
|
|
72
|
+
if isinstance(project, str):
|
|
73
|
+
# Project name provided
|
|
74
|
+
self.project_name = project
|
|
75
|
+
self._initialize_with_project_name(project, name)
|
|
76
|
+
else:
|
|
77
|
+
# Project instance provided
|
|
78
|
+
from .project import Project as ProjectClass
|
|
79
|
+
if isinstance(project, ProjectClass):
|
|
80
|
+
self.project_name = project.name
|
|
81
|
+
self.project_id = project.id
|
|
82
|
+
self._initialize_with_project_instance(project, name)
|
|
83
|
+
else:
|
|
84
|
+
raise ValueError("project must be a string (project name) or Project instance")
|
|
85
|
+
else:
|
|
86
|
+
# No project specified, create a new one
|
|
87
|
+
self._create_new_project_and_computer(name)
|
|
88
|
+
|
|
89
|
+
def _connect_by_id(self, computer_id: str):
|
|
90
|
+
"""Connect to existing computer by ID"""
|
|
91
|
+
self.computer_id = computer_id
|
|
92
|
+
self._info = self.api.get_computer(computer_id)
|
|
93
|
+
self.project_id = self._info.get("project_id")
|
|
94
|
+
self.name = self._info.get("name")
|
|
95
|
+
# Get project name
|
|
96
|
+
if self.project_id:
|
|
97
|
+
project = self.api.get_project(self.project_id)
|
|
98
|
+
self.project_name = project.get("name")
|
|
99
|
+
|
|
100
|
+
def _initialize_with_project_name(self, project_name: str, computer_name: Optional[str]):
|
|
101
|
+
"""Initialize with a project name (create project if needed)"""
|
|
102
|
+
try:
|
|
103
|
+
# Try to get existing project
|
|
104
|
+
project = self.api.get_project_by_name(project_name)
|
|
105
|
+
self.project_id = project.get("id")
|
|
106
|
+
|
|
107
|
+
# Check for existing computers
|
|
108
|
+
computers = self.api.list_computers(self.project_id)
|
|
109
|
+
|
|
110
|
+
if computer_name:
|
|
111
|
+
# Look for specific computer
|
|
112
|
+
existing = next((c for c in computers if c.get("name") == computer_name), None)
|
|
113
|
+
if existing:
|
|
114
|
+
self._connect_to_existing_computer(existing)
|
|
115
|
+
else:
|
|
116
|
+
# Create new computer with specified name
|
|
117
|
+
self._create_computer(self.project_id, computer_name)
|
|
118
|
+
elif computers:
|
|
119
|
+
# No name specified, use first available computer
|
|
120
|
+
self._connect_to_existing_computer(computers[0])
|
|
121
|
+
else:
|
|
122
|
+
# No computers exist, create new one
|
|
123
|
+
self._create_computer(self.project_id, computer_name)
|
|
124
|
+
|
|
125
|
+
except Exception:
|
|
126
|
+
# Project doesn't exist, create it
|
|
127
|
+
logger.info(f"Project {project_name} not found, creating new project")
|
|
128
|
+
project = self.api.create_project(project_name)
|
|
129
|
+
self.project_id = project.get("id")
|
|
130
|
+
self._create_computer(self.project_id, computer_name)
|
|
131
|
+
|
|
132
|
+
def _initialize_with_project_instance(self, project: 'Project', computer_name: Optional[str]):
|
|
133
|
+
"""Initialize with a Project instance"""
|
|
134
|
+
computers = project.list_computers()
|
|
135
|
+
|
|
136
|
+
if computer_name:
|
|
137
|
+
# Look for specific computer
|
|
138
|
+
existing = next((c for c in computers if c.get("name") == computer_name), None)
|
|
139
|
+
if existing:
|
|
140
|
+
self._connect_to_existing_computer(existing)
|
|
141
|
+
else:
|
|
142
|
+
# Create new computer with specified name
|
|
143
|
+
self._create_computer(project.id, computer_name)
|
|
144
|
+
elif computers:
|
|
145
|
+
# No name specified, use first available computer
|
|
146
|
+
self._connect_to_existing_computer(computers[0])
|
|
147
|
+
else:
|
|
148
|
+
# No computers exist, create new one
|
|
149
|
+
self._create_computer(project.id, computer_name)
|
|
150
|
+
|
|
151
|
+
def _create_new_project_and_computer(self, computer_name: Optional[str]):
|
|
152
|
+
"""Create a new project and computer"""
|
|
153
|
+
# Generate a unique project name
|
|
154
|
+
project_name = f"project-{uuid.uuid4().hex[:8]}"
|
|
155
|
+
|
|
156
|
+
# Create the project
|
|
157
|
+
project = self.api.create_project(project_name)
|
|
158
|
+
self.project_id = project.get("id")
|
|
159
|
+
self.project_name = project_name
|
|
160
|
+
|
|
161
|
+
# Create a computer in the new project
|
|
162
|
+
self._create_computer(self.project_id, computer_name)
|
|
163
|
+
|
|
164
|
+
def _connect_to_existing_computer(self, computer_info: Dict[str, Any]):
|
|
165
|
+
"""Connect to an existing computer"""
|
|
166
|
+
self.computer_id = computer_info.get("id")
|
|
167
|
+
self.name = computer_info.get("name")
|
|
168
|
+
self._info = computer_info
|
|
169
|
+
logger.info(f"Connected to existing computer {self.name} (ID: {self.computer_id})")
|
|
170
|
+
|
|
171
|
+
def _create_computer(self, project_id: str, computer_name: Optional[str]):
|
|
172
|
+
"""Create a new computer in the project"""
|
|
173
|
+
# Generate name if not provided
|
|
174
|
+
if not computer_name:
|
|
175
|
+
computer_name = f"desktop-{uuid.uuid4().hex[:8]}"
|
|
176
|
+
|
|
177
|
+
self.name = computer_name
|
|
178
|
+
|
|
179
|
+
# Validate parameters
|
|
180
|
+
if self.ram not in [1, 2, 4, 8, 16, 32, 64]:
|
|
181
|
+
raise ValueError("ram must be one of: 1, 2, 4, 8, 16, 32, 64 GB")
|
|
182
|
+
if self.cpu not in [1, 2, 4, 8, 16]:
|
|
183
|
+
raise ValueError("cpu must be one of: 1, 2, 4, 8, 16 cores")
|
|
184
|
+
if self.os not in ["linux", "windows"]:
|
|
185
|
+
raise ValueError("os must be either 'linux' or 'windows'")
|
|
186
|
+
if self.gpu not in ["none", "a10", "l40s", "a100-40gb", "a100-80gb"]:
|
|
187
|
+
raise ValueError("gpu must be one of: 'none', 'a10', 'l40s', 'a100-40gb', 'a100-80gb'")
|
|
188
|
+
|
|
189
|
+
computer = self.api.create_computer(
|
|
190
|
+
project_id=project_id,
|
|
191
|
+
computer_name=computer_name,
|
|
192
|
+
os=self.os,
|
|
193
|
+
ram=self.ram,
|
|
194
|
+
cpu=self.cpu,
|
|
195
|
+
gpu=self.gpu
|
|
196
|
+
)
|
|
197
|
+
self.computer_id = computer.get("id")
|
|
198
|
+
self._info = computer
|
|
199
|
+
logger.info(f"Created new computer {self.name} (ID: {self.computer_id})")
|
|
200
|
+
|
|
201
|
+
def status(self) -> Dict[str, Any]:
|
|
202
|
+
"""Get current computer status"""
|
|
203
|
+
return self.api.get_computer(self.computer_id)
|
|
204
|
+
|
|
205
|
+
def restart(self) -> Dict[str, Any]:
|
|
206
|
+
"""Restart the computer"""
|
|
207
|
+
return self.api.restart_computer(self.computer_id)
|
|
208
|
+
|
|
209
|
+
def destroy(self) -> Dict[str, Any]:
|
|
210
|
+
"""Terminate and delete the computer instance"""
|
|
211
|
+
return self.api.delete_computer(self.computer_id)
|
|
212
|
+
|
|
213
|
+
# Navigation methods
|
|
214
|
+
def left_click(self, x: int, y: int) -> Dict[str, Any]:
|
|
215
|
+
"""Perform left mouse click at specified coordinates"""
|
|
216
|
+
return self.api.left_click(self.computer_id, x, y)
|
|
217
|
+
|
|
218
|
+
def right_click(self, x: int, y: int) -> Dict[str, Any]:
|
|
219
|
+
"""Perform right mouse click at specified coordinates"""
|
|
220
|
+
return self.api.right_click(self.computer_id, x, y)
|
|
221
|
+
|
|
222
|
+
def double_click(self, x: int, y: int) -> Dict[str, Any]:
|
|
223
|
+
"""Perform double click at specified coordinates"""
|
|
224
|
+
return self.api.double_click(self.computer_id, x, y)
|
|
225
|
+
|
|
226
|
+
def drag(self, start_x: int, start_y: int, end_x: int, end_y: int,
|
|
227
|
+
button: str = "left", duration: float = 0.5) -> Dict[str, Any]:
|
|
228
|
+
"""Perform a smooth drag operation from start to end coordinates"""
|
|
229
|
+
return self.api.drag(self.computer_id, start_x, start_y, end_x, end_y, button, duration)
|
|
230
|
+
|
|
231
|
+
def scroll(self, direction: str = "down", amount: int = 3) -> Dict[str, Any]:
|
|
232
|
+
"""Scroll in specified direction and amount"""
|
|
233
|
+
return self.api.scroll(self.computer_id, direction, amount)
|
|
234
|
+
|
|
235
|
+
# Input methods
|
|
236
|
+
def type(self, text: str) -> Dict[str, Any]:
|
|
237
|
+
"""Type the specified text"""
|
|
238
|
+
return self.api.type_text(self.computer_id, text)
|
|
239
|
+
|
|
240
|
+
def key(self, key: str) -> Dict[str, Any]:
|
|
241
|
+
"""Press a key or key combination (e.g., "Enter", "ctrl+c")"""
|
|
242
|
+
return self.api.key_press(self.computer_id, key)
|
|
243
|
+
|
|
244
|
+
# View methods
|
|
245
|
+
def screenshot(self) -> Image.Image:
|
|
246
|
+
"""Capture screenshot and return as PIL Image"""
|
|
247
|
+
response = self.api.get_screenshot(self.computer_id)
|
|
248
|
+
image_data = response.get("image", "")
|
|
249
|
+
|
|
250
|
+
if image_data.startswith(('http://', 'https://')):
|
|
251
|
+
img_response = requests.get(image_data)
|
|
252
|
+
img_response.raise_for_status()
|
|
253
|
+
return Image.open(io.BytesIO(img_response.content))
|
|
254
|
+
else:
|
|
255
|
+
img_data = base64.b64decode(image_data)
|
|
256
|
+
return Image.open(io.BytesIO(img_data))
|
|
257
|
+
|
|
258
|
+
def screenshot_base64(self) -> str:
|
|
259
|
+
"""Capture screenshot and return as base64 string"""
|
|
260
|
+
response = self.api.get_screenshot(self.computer_id)
|
|
261
|
+
image_data = response.get("image", "")
|
|
262
|
+
|
|
263
|
+
if image_data.startswith(('http://', 'https://')):
|
|
264
|
+
img_response = requests.get(image_data)
|
|
265
|
+
img_response.raise_for_status()
|
|
266
|
+
return base64.b64encode(img_response.content).decode('utf-8')
|
|
267
|
+
else:
|
|
268
|
+
return image_data
|
|
269
|
+
|
|
270
|
+
# Execution methods
|
|
271
|
+
def bash(self, command: str) -> str:
|
|
272
|
+
"""Execute a bash command and return output"""
|
|
273
|
+
response = self.api.execute_bash(self.computer_id, command)
|
|
274
|
+
return response.get("output", "")
|
|
275
|
+
|
|
276
|
+
def exec(self, code: str, timeout: int = 10) -> Dict[str, Any]:
|
|
277
|
+
"""Execute Python code on the remote computer"""
|
|
278
|
+
response = self.api.execute_python(self.computer_id, code, timeout)
|
|
279
|
+
return response
|
|
280
|
+
|
|
281
|
+
def wait(self, seconds: float) -> Dict[str, Any]:
|
|
282
|
+
"""Wait for specified number of seconds"""
|
|
283
|
+
return self.api.wait(self.computer_id, seconds)
|
|
284
|
+
|
|
285
|
+
# Streaming methods
|
|
286
|
+
def start_stream(self, connection: str) -> Dict[str, Any]:
|
|
287
|
+
"""Start streaming the computer screen to an RTMP server"""
|
|
288
|
+
return self.api.start_stream(self.computer_id, connection)
|
|
289
|
+
|
|
290
|
+
def stop_stream(self) -> Dict[str, Any]:
|
|
291
|
+
"""Stop the active stream"""
|
|
292
|
+
return self.api.stop_stream(self.computer_id)
|
|
293
|
+
|
|
294
|
+
def stream_status(self) -> Dict[str, Any]:
|
|
295
|
+
"""Get the current streaming status"""
|
|
296
|
+
return self.api.get_stream_status(self.computer_id)
|
|
297
|
+
|
|
298
|
+
# AI control method
|
|
299
|
+
def prompt(self,
|
|
300
|
+
instruction: str,
|
|
301
|
+
provider: str = "anthropic",
|
|
302
|
+
model: str = "claude-3-7-sonnet-20250219",
|
|
303
|
+
display_width: int = 1024,
|
|
304
|
+
display_height: int = 768,
|
|
305
|
+
callback: Optional[Callable[[str, Any], None]] = None,
|
|
306
|
+
thinking_enabled: bool = False,
|
|
307
|
+
thinking_budget: int = 1024,
|
|
308
|
+
max_tokens: int = 4096,
|
|
309
|
+
max_iterations: int = 20,
|
|
310
|
+
max_saved_screenshots: int = 5,
|
|
311
|
+
api_key: Optional[str] = None) -> List[Dict[str, Any]]:
|
|
312
|
+
"""Control the computer with natural language instructions using an AI assistant"""
|
|
313
|
+
provider_instance = get_provider(provider)
|
|
314
|
+
|
|
315
|
+
return provider_instance.execute(
|
|
316
|
+
computer_id=self.computer_id,
|
|
317
|
+
instruction=instruction,
|
|
318
|
+
callback=callback,
|
|
319
|
+
api_key=api_key,
|
|
320
|
+
model=model,
|
|
321
|
+
display_width=display_width,
|
|
322
|
+
display_height=display_height,
|
|
323
|
+
thinking_enabled=thinking_enabled,
|
|
324
|
+
thinking_budget=thinking_budget,
|
|
325
|
+
max_tokens=max_tokens,
|
|
326
|
+
max_iterations=max_iterations,
|
|
327
|
+
max_saved_screenshots=max_saved_screenshots,
|
|
328
|
+
orgo_api_key=self.api_key,
|
|
329
|
+
orgo_base_url=self.base_api_url
|
|
330
|
+
)
|
|
331
|
+
|
|
332
|
+
def __repr__(self):
|
|
333
|
+
return f"Computer(name='{self.name}', project='{self.project_name}', id='{self.computer_id}')"
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
"""API client for Orgo service"""
|
|
2
|
-
|
|
3
|
-
import requests
|
|
4
|
-
from typing import Dict, Any, Optional, List
|
|
5
|
-
import logging
|
|
6
|
-
import sys
|
|
7
|
-
|
|
8
|
-
from orgo.utils.auth import get_api_key
|
|
9
|
-
|
|
10
|
-
logger = logging.getLogger(__name__)
|
|
11
|
-
|
|
12
|
-
class ApiClient:
|
|
13
|
-
def __init__(self, api_key: Optional[str] = None, base_url: Optional[str] = None):
|
|
14
|
-
self.api_key = get_api_key(api_key)
|
|
15
|
-
self.base_url = base_url or "https://www.orgo.ai/api"
|
|
16
|
-
self.session = requests.Session()
|
|
17
|
-
self.session.headers.update({
|
|
18
|
-
"Authorization": f"Bearer {self.api_key}",
|
|
19
|
-
"Content-Type": "application/json",
|
|
20
|
-
"Accept": "application/json"
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
def _request(self, method: str, endpoint: str, data: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
|
|
24
|
-
url = f"{self.base_url}/{endpoint}"
|
|
25
|
-
|
|
26
|
-
try:
|
|
27
|
-
if method.upper() == "GET":
|
|
28
|
-
response = self.session.get(url, params=data)
|
|
29
|
-
else:
|
|
30
|
-
response = self.session.request(method, url, json=data)
|
|
31
|
-
|
|
32
|
-
response.raise_for_status()
|
|
33
|
-
return response.json()
|
|
34
|
-
except requests.exceptions.RequestException as e:
|
|
35
|
-
# Log the full error for debugging
|
|
36
|
-
logger.debug(f"API request failed: {method} {url}", exc_info=True)
|
|
37
|
-
|
|
38
|
-
if hasattr(e, 'response') and e.response is not None:
|
|
39
|
-
try:
|
|
40
|
-
error_data = e.response.json()
|
|
41
|
-
if 'error' in error_data:
|
|
42
|
-
raise Exception(error_data['error']) from None
|
|
43
|
-
except (ValueError, KeyError):
|
|
44
|
-
pass
|
|
45
|
-
raise Exception(f"Request failed with status {e.response.status_code}") from None
|
|
46
|
-
|
|
47
|
-
# Generic error message without exposing internal details
|
|
48
|
-
raise Exception("Failed to connect to Orgo service. Please check your connection and try again.") from None
|
|
49
|
-
|
|
50
|
-
# Project methods
|
|
51
|
-
def create_project(self, name: str) -> Dict[str, Any]:
|
|
52
|
-
"""Create a new named project"""
|
|
53
|
-
return self._request("POST", "projects", {"name": name})
|
|
54
|
-
|
|
55
|
-
def get_project_by_name(self, name: str) -> Dict[str, Any]:
|
|
56
|
-
"""Get project details by name"""
|
|
57
|
-
return self._request("GET", f"projects/by-name/{name}")
|
|
58
|
-
|
|
59
|
-
def get_project(self, project_id: str) -> Dict[str, Any]:
|
|
60
|
-
"""Get project details by ID"""
|
|
61
|
-
return self._request("GET", f"projects/{project_id}")
|
|
62
|
-
|
|
63
|
-
def list_projects(self) -> List[Dict[str, Any]]:
|
|
64
|
-
"""List all projects"""
|
|
65
|
-
response = self._request("GET", "projects")
|
|
66
|
-
return response.get("projects", [])
|
|
67
|
-
|
|
68
|
-
def delete_project(self, project_id: str) -> Dict[str, Any]:
|
|
69
|
-
"""Delete a project and all its computers"""
|
|
70
|
-
return self._request("DELETE", f"projects/{project_id}")
|
|
71
|
-
|
|
72
|
-
# Computer methods
|
|
73
|
-
def create_computer(self, project_id: str, computer_name: str,
|
|
74
|
-
os: str = "linux", ram: int = 2, cpu: int = 2,
|
|
75
|
-
gpu: str = "none") -> Dict[str, Any]:
|
|
76
|
-
"""Create a new computer within a project"""
|
|
77
|
-
return self._request("POST", "computers", {
|
|
78
|
-
"project_id": project_id,
|
|
79
|
-
"name": computer_name,
|
|
80
|
-
"os": os,
|
|
81
|
-
"ram": ram,
|
|
82
|
-
"cpu": cpu,
|
|
83
|
-
"gpu": gpu
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
def list_computers(self, project_id: str) -> List[Dict[str, Any]]:
|
|
87
|
-
"""List all computers in a project"""
|
|
88
|
-
project = self.get_project(project_id)
|
|
89
|
-
return project.get("desktops", [])
|
|
90
|
-
|
|
91
|
-
def get_computer(self, computer_id: str) -> Dict[str, Any]:
|
|
92
|
-
"""Get computer details"""
|
|
93
|
-
return self._request("GET", f"computers/{computer_id}")
|
|
94
|
-
|
|
95
|
-
def delete_computer(self, computer_id: str) -> Dict[str, Any]:
|
|
96
|
-
"""Delete a computer"""
|
|
97
|
-
return self._request("DELETE", f"computers/{computer_id}")
|
|
98
|
-
|
|
99
|
-
def restart_computer(self, computer_id: str) -> Dict[str, Any]:
|
|
100
|
-
"""Restart a computer"""
|
|
101
|
-
return self._request("POST", f"computers/{computer_id}/restart")
|
|
102
|
-
|
|
103
|
-
# Computer control methods
|
|
104
|
-
def left_click(self, computer_id: str, x: int, y: int) -> Dict[str, Any]:
|
|
105
|
-
return self._request("POST", f"computers/{computer_id}/click", {
|
|
106
|
-
"button": "left", "x": x, "y": y
|
|
107
|
-
})
|
|
108
|
-
|
|
109
|
-
def right_click(self, computer_id: str, x: int, y: int) -> Dict[str, Any]:
|
|
110
|
-
return self._request("POST", f"computers/{computer_id}/click", {
|
|
111
|
-
"button": "right", "x": x, "y": y
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
def double_click(self, computer_id: str, x: int, y: int) -> Dict[str, Any]:
|
|
115
|
-
return self._request("POST", f"computers/{computer_id}/click", {
|
|
116
|
-
"button": "left", "x": x, "y": y, "double": True
|
|
117
|
-
})
|
|
118
|
-
|
|
119
|
-
def drag(self, computer_id: str, start_x: int, start_y: int,
|
|
120
|
-
end_x: int, end_y: int, button: str = "left",
|
|
121
|
-
duration: float = 0.5) -> Dict[str, Any]:
|
|
122
|
-
"""Perform a drag operation from start to end coordinates"""
|
|
123
|
-
return self._request("POST", f"computers/{computer_id}/drag", {
|
|
124
|
-
"start_x": start_x,
|
|
125
|
-
"start_y": start_y,
|
|
126
|
-
"end_x": end_x,
|
|
127
|
-
"end_y": end_y,
|
|
128
|
-
"button": button,
|
|
129
|
-
"duration": duration
|
|
130
|
-
})
|
|
131
|
-
|
|
132
|
-
def scroll(self, computer_id: str, direction: str, amount: int = 3) -> Dict[str, Any]:
|
|
133
|
-
return self._request("POST", f"computers/{computer_id}/scroll", {
|
|
134
|
-
"direction": direction, "amount": amount
|
|
135
|
-
})
|
|
136
|
-
|
|
137
|
-
def type_text(self, computer_id: str, text: str) -> Dict[str, Any]:
|
|
138
|
-
return self._request("POST", f"computers/{computer_id}/type", {
|
|
139
|
-
"text": text
|
|
140
|
-
})
|
|
141
|
-
|
|
142
|
-
def key_press(self, computer_id: str, key: str) -> Dict[str, Any]:
|
|
143
|
-
return self._request("POST", f"computers/{computer_id}/key", {
|
|
144
|
-
"key": key
|
|
145
|
-
})
|
|
146
|
-
|
|
147
|
-
def get_screenshot(self, computer_id: str) -> Dict[str, Any]:
|
|
148
|
-
return self._request("GET", f"computers/{computer_id}/screenshot")
|
|
149
|
-
|
|
150
|
-
def execute_bash(self, computer_id: str, command: str) -> Dict[str, Any]:
|
|
151
|
-
return self._request("POST", f"computers/{computer_id}/bash", {
|
|
152
|
-
"command": command
|
|
153
|
-
})
|
|
154
|
-
|
|
155
|
-
def execute_python(self, computer_id: str, code: str, timeout: int = 10) -> Dict[str, Any]:
|
|
156
|
-
"""Execute Python code on the computer"""
|
|
157
|
-
return self._request("POST", f"computers/{computer_id}/exec", {
|
|
158
|
-
"code": code,
|
|
159
|
-
"timeout": timeout
|
|
160
|
-
})
|
|
161
|
-
|
|
162
|
-
def wait(self, computer_id: str, duration: float) -> Dict[str, Any]:
|
|
163
|
-
return self._request("POST", f"computers/{computer_id}/wait", {
|
|
164
|
-
"duration": duration
|
|
165
|
-
})
|
|
166
|
-
|
|
167
|
-
# Streaming methods
|
|
168
|
-
def start_stream(self, computer_id: str, connection_name: str) -> Dict[str, Any]:
|
|
169
|
-
"""Start streaming to a configured RTMP connection"""
|
|
170
|
-
return self._request("POST", f"computers/{computer_id}/stream/start", {
|
|
171
|
-
"connection_name": connection_name
|
|
172
|
-
})
|
|
173
|
-
|
|
174
|
-
def stop_stream(self, computer_id: str) -> Dict[str, Any]:
|
|
175
|
-
"""Stop the active stream"""
|
|
176
|
-
return self._request("POST", f"computers/{computer_id}/stream/stop")
|
|
177
|
-
|
|
178
|
-
def get_stream_status(self, computer_id: str) -> Dict[str, Any]:
|
|
179
|
-
"""Get current stream status"""
|
|
180
|
-
return self._request("GET", f"computers/{computer_id}/stream/status")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|