orgo 0.0.27__py3-none-any.whl → 0.0.29__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.
orgo/api/client.py CHANGED
@@ -2,9 +2,13 @@
2
2
 
3
3
  import requests
4
4
  from typing import Dict, Any, Optional, List
5
+ import logging
6
+ import sys
5
7
 
6
8
  from orgo.utils.auth import get_api_key
7
9
 
10
+ logger = logging.getLogger(__name__)
11
+
8
12
  class ApiClient:
9
13
  def __init__(self, api_key: Optional[str] = None, base_url: Optional[str] = None):
10
14
  self.api_key = get_api_key(api_key)
@@ -28,16 +32,20 @@ class ApiClient:
28
32
  response.raise_for_status()
29
33
  return response.json()
30
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
+
31
38
  if hasattr(e, 'response') and e.response is not None:
32
- error_message = f"API error: {e.response.status_code}"
33
39
  try:
34
40
  error_data = e.response.json()
35
41
  if 'error' in error_data:
36
- error_message += f" - {error_data['error']}"
37
- except ValueError:
42
+ raise Exception(error_data['error']) from None
43
+ except (ValueError, KeyError):
38
44
  pass
39
- raise Exception(error_message) from e
40
- raise Exception(f"Connection error: {str(e)}") from e
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
41
49
 
42
50
  # Project methods
43
51
  def create_project(self, name: str) -> Dict[str, Any]:
@@ -57,28 +65,17 @@ class ApiClient:
57
65
  response = self._request("GET", "projects")
58
66
  return response.get("projects", [])
59
67
 
60
- def start_project(self, project_id: str) -> Dict[str, Any]:
61
- """Start a project"""
62
- return self._request("POST", f"projects/{project_id}/start")
63
-
64
- def stop_project(self, project_id: str) -> Dict[str, Any]:
65
- """Stop a project"""
66
- return self._request("POST", f"projects/{project_id}/stop")
67
-
68
- def restart_project(self, project_id: str) -> Dict[str, Any]:
69
- """Restart a project"""
70
- return self._request("POST", f"projects/{project_id}/restart")
71
-
72
68
  def delete_project(self, project_id: str) -> Dict[str, Any]:
73
69
  """Delete a project and all its computers"""
74
- return self._request("POST", f"projects/{project_id}/delete")
70
+ return self._request("DELETE", f"projects/{project_id}")
75
71
 
76
72
  # Computer methods
77
- def create_computer(self, project_name: str, computer_name: str,
73
+ def create_computer(self, project_id: str, computer_name: str,
78
74
  os: str = "linux", ram: int = 2, cpu: int = 2,
79
75
  gpu: str = "none") -> Dict[str, Any]:
80
76
  """Create a new computer within a project"""
81
- return self._request("POST", f"projects/{project_name}/computers", {
77
+ return self._request("POST", "computers", {
78
+ "project_id": project_id,
82
79
  "name": computer_name,
83
80
  "os": os,
84
81
  "ram": ram,
@@ -86,10 +83,10 @@ class ApiClient:
86
83
  "gpu": gpu
87
84
  })
88
85
 
89
- def list_computers(self, project_name: str) -> List[Dict[str, Any]]:
86
+ def list_computers(self, project_id: str) -> List[Dict[str, Any]]:
90
87
  """List all computers in a project"""
91
- response = self._request("GET", f"projects/{project_name}/computers")
92
- return response.get("computers", [])
88
+ project = self.get_project(project_id)
89
+ return project.get("desktops", [])
93
90
 
94
91
  def get_computer(self, computer_id: str) -> Dict[str, Any]:
95
92
  """Get computer details"""
@@ -99,14 +96,6 @@ class ApiClient:
99
96
  """Delete a computer"""
100
97
  return self._request("DELETE", f"computers/{computer_id}")
101
98
 
102
- def start_computer(self, computer_id: str) -> Dict[str, Any]:
103
- """Start a computer"""
104
- return self._request("POST", f"computers/{computer_id}/start")
105
-
106
- def stop_computer(self, computer_id: str) -> Dict[str, Any]:
107
- """Stop a computer"""
108
- return self._request("POST", f"computers/{computer_id}/stop")
109
-
110
99
  def restart_computer(self, computer_id: str) -> Dict[str, Any]:
111
100
  """Restart a computer"""
112
101
  return self._request("POST", f"computers/{computer_id}/restart")
orgo/computer.py CHANGED
@@ -3,6 +3,7 @@ import os as operating_system
3
3
  import base64
4
4
  import logging
5
5
  import uuid
6
+ import io
6
7
  from typing import Dict, List, Any, Optional, Callable, Literal, Union
7
8
  from PIL import Image
8
9
  import requests
@@ -89,8 +90,12 @@ class Computer:
89
90
  """Connect to existing computer by ID"""
90
91
  self.computer_id = computer_id
91
92
  self._info = self.api.get_computer(computer_id)
92
- self.project_name = self._info.get("project_name")
93
+ self.project_id = self._info.get("project_id")
93
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")
94
99
 
95
100
  def _initialize_with_project_name(self, project_name: str, computer_name: Optional[str]):
96
101
  """Initialize with a project name (create project if needed)"""
@@ -100,7 +105,7 @@ class Computer:
100
105
  self.project_id = project.get("id")
101
106
 
102
107
  # Check for existing computers
103
- computers = self.api.list_computers(project_name)
108
+ computers = self.api.list_computers(self.project_id)
104
109
 
105
110
  if computer_name:
106
111
  # Look for specific computer
@@ -109,20 +114,20 @@ class Computer:
109
114
  self._connect_to_existing_computer(existing)
110
115
  else:
111
116
  # Create new computer with specified name
112
- self._create_computer(project_name, computer_name)
117
+ self._create_computer(self.project_id, computer_name)
113
118
  elif computers:
114
119
  # No name specified, use first available computer
115
120
  self._connect_to_existing_computer(computers[0])
116
121
  else:
117
122
  # No computers exist, create new one
118
- self._create_computer(project_name, computer_name)
123
+ self._create_computer(self.project_id, computer_name)
119
124
 
120
125
  except Exception:
121
126
  # Project doesn't exist, create it
122
127
  logger.info(f"Project {project_name} not found, creating new project")
123
128
  project = self.api.create_project(project_name)
124
129
  self.project_id = project.get("id")
125
- self._create_computer(project_name, computer_name)
130
+ self._create_computer(self.project_id, computer_name)
126
131
 
127
132
  def _initialize_with_project_instance(self, project: 'Project', computer_name: Optional[str]):
128
133
  """Initialize with a Project instance"""
@@ -135,13 +140,13 @@ class Computer:
135
140
  self._connect_to_existing_computer(existing)
136
141
  else:
137
142
  # Create new computer with specified name
138
- self._create_computer(project.name, computer_name)
143
+ self._create_computer(project.id, computer_name)
139
144
  elif computers:
140
145
  # No name specified, use first available computer
141
146
  self._connect_to_existing_computer(computers[0])
142
147
  else:
143
148
  # No computers exist, create new one
144
- self._create_computer(project.name, computer_name)
149
+ self._create_computer(project.id, computer_name)
145
150
 
146
151
  def _create_new_project_and_computer(self, computer_name: Optional[str]):
147
152
  """Create a new project and computer"""
@@ -154,7 +159,7 @@ class Computer:
154
159
  self.project_name = project_name
155
160
 
156
161
  # Create a computer in the new project
157
- self._create_computer(project_name, computer_name)
162
+ self._create_computer(self.project_id, computer_name)
158
163
 
159
164
  def _connect_to_existing_computer(self, computer_info: Dict[str, Any]):
160
165
  """Connect to an existing computer"""
@@ -163,7 +168,7 @@ class Computer:
163
168
  self._info = computer_info
164
169
  logger.info(f"Connected to existing computer {self.name} (ID: {self.computer_id})")
165
170
 
166
- def _create_computer(self, project_name: str, computer_name: Optional[str]):
171
+ def _create_computer(self, project_id: str, computer_name: Optional[str]):
167
172
  """Create a new computer in the project"""
168
173
  # Generate name if not provided
169
174
  if not computer_name:
@@ -182,7 +187,7 @@ class Computer:
182
187
  raise ValueError("gpu must be one of: 'none', 'a10', 'l40s', 'a100-40gb', 'a100-80gb'")
183
188
 
184
189
  computer = self.api.create_computer(
185
- project_name=project_name,
190
+ project_id=project_id,
186
191
  computer_name=computer_name,
187
192
  os=self.os,
188
193
  ram=self.ram,
@@ -197,14 +202,6 @@ class Computer:
197
202
  """Get current computer status"""
198
203
  return self.api.get_computer(self.computer_id)
199
204
 
200
- def start(self) -> Dict[str, Any]:
201
- """Start the computer"""
202
- return self.api.start_computer(self.computer_id)
203
-
204
- def stop(self) -> Dict[str, Any]:
205
- """Stop the computer"""
206
- return self.api.stop_computer(self.computer_id)
207
-
208
205
  def restart(self) -> Dict[str, Any]:
209
206
  """Restart the computer"""
210
207
  return self.api.restart_computer(self.computer_id)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: orgo
3
- Version: 0.0.27
3
+ Version: 0.0.29
4
4
  Summary: Computers for AI agents
5
5
  Author: Orgo Team
6
6
  License: MIT
@@ -1,12 +1,12 @@
1
1
  orgo/__init__.py,sha256=aw3BM7-Wy8jk-mvIWRG2gC4-nsc74s6ZFm1U21NyGeM,171
2
- orgo/computer.py,sha256=B3B0NQwpSHzadjbssxHzoXe3-A3A3cuUD1fXW18k_bU,14487
2
+ orgo/computer.py,sha256=Twe3cWlZGppAqeyQUGCghaAcjcJ41NFbEpJWgxLmqsg,14400
3
3
  orgo/project.py,sha256=uVDFa8iyn5OaHzTzjGQhxnF_nVzwkqkqUShiV3M0AWU,3150
4
4
  orgo/prompt.py,sha256=ynblwXPTDp_aF1MbGBsY0PIEr9naklDaKFcfSE_EZ6E,19781
5
5
  orgo/api/__init__.py,sha256=9Tzb_OPJ5DH7Cg7OrHzpZZUT4ip05alpa9RLDYmnId8,113
6
- orgo/api/client.py,sha256=JofBHTnks4nO60786vAmzJmECVFFf-Yff1qF0ir-YQ8,7958
6
+ orgo/api/client.py,sha256=sBvX1e1BSY_BB7N4Cnb7mhBt1JBn-EpIYc5KO5sf6m4,7406
7
7
  orgo/utils/__init__.py,sha256=W4G_nwGBf_7jy0w_mfcrkllurYHSRU4B5cMTVYH_uCc,123
8
8
  orgo/utils/auth.py,sha256=tPLBJY-6gdBQWLUjUbwIwxHphC3KoRT_XgP3Iykw3Mw,509
9
- orgo-0.0.27.dist-info/METADATA,sha256=Ty1vixQaj3ccyXNkTKFZEaZAEVYr-5O4zMGvKiQQZxo,822
10
- orgo-0.0.27.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
11
- orgo-0.0.27.dist-info/top_level.txt,sha256=q0rYtFji8GbYuhFW8A5Ab9e0j27761IKPhnL0E9xow4,5
12
- orgo-0.0.27.dist-info/RECORD,,
9
+ orgo-0.0.29.dist-info/METADATA,sha256=VpfFjfjyJAehx7VrARdyx_7Xyz8LC6tQegIaVB9oEs0,822
10
+ orgo-0.0.29.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
11
+ orgo-0.0.29.dist-info/top_level.txt,sha256=q0rYtFji8GbYuhFW8A5Ab9e0j27761IKPhnL0E9xow4,5
12
+ orgo-0.0.29.dist-info/RECORD,,
File without changes