orgo 0.0.19__py3-none-any.whl → 0.0.21__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
@@ -1,4 +1,3 @@
1
- # src/orgo/api/client.py
2
1
  """API client for Orgo service"""
3
2
 
4
3
  import requests
@@ -43,7 +42,10 @@ class ApiClient:
43
42
  # Computer lifecycle methods
44
43
  def create_computer(self, config: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
45
44
  """Create a new project with desktop instance"""
46
- return self._request("POST", "projects", {"config": config} if config else None)
45
+ payload = {}
46
+ if config:
47
+ payload["config"] = config
48
+ return self._request("POST", "projects", payload if payload else None)
47
49
 
48
50
  def connect_computer(self, project_id: str) -> Dict[str, Any]:
49
51
  return self._request("GET", f"projects/by-name/{project_id}")
orgo/computer.py CHANGED
@@ -1,10 +1,9 @@
1
- # src/orgo/computer.py
2
1
  """Computer class for interacting with Orgo virtual environments"""
3
2
  import os
4
3
  import io
5
4
  import base64
6
5
  import logging
7
- from typing import Dict, List, Any, Optional, Callable
6
+ from typing import Dict, List, Any, Optional, Callable, Literal
8
7
  from PIL import Image
9
8
  import requests
10
9
  from requests.exceptions import RequestException
@@ -16,7 +15,13 @@ from .project import ProjectManager
16
15
  logger = logging.getLogger(__name__)
17
16
 
18
17
  class Computer:
19
- def __init__(self, project_id=None, api_key=None, config=None, base_api_url=None):
18
+ def __init__(self,
19
+ project_id: Optional[str] = None,
20
+ api_key: Optional[str] = None,
21
+ config: Optional[Dict[str, Any]] = None,
22
+ base_api_url: Optional[str] = None,
23
+ ram: Optional[Literal[2, 4]] = None,
24
+ cpu: Optional[Literal[2, 4]] = None):
20
25
  """
21
26
  Initialize an Orgo virtual computer.
22
27
 
@@ -25,6 +30,8 @@ class Computer:
25
30
  api_key: Orgo API key (defaults to ORGO_API_KEY env var)
26
31
  config: Configuration for new computer (optional)
27
32
  base_api_url: Custom API URL (optional)
33
+ ram: RAM in GB for new computer (2 or 4) - only used when creating
34
+ cpu: CPU cores for new computer (2 or 4) - only used when creating
28
35
  """
29
36
  self.api_key = api_key or os.environ.get("ORGO_API_KEY")
30
37
  self.base_api_url = base_api_url
@@ -38,14 +45,39 @@ class Computer:
38
45
  try:
39
46
  self.project_id = project_id
40
47
  self._info = self.api.connect_computer(project_id)
48
+ # Log if ram/cpu were provided but ignored
49
+ if ram is not None or cpu is not None:
50
+ logger.info("Note: ram and cpu parameters are ignored when connecting to existing computer")
41
51
  except (RequestException, ValueError) as e:
42
52
  logger.warning(f"Could not connect to saved project {project_id}: {e}")
43
- self._create_new_computer(config)
53
+ self._create_new_computer(config, ram, cpu)
44
54
  else:
45
- self._create_new_computer(config)
55
+ self._create_new_computer(config, ram, cpu)
46
56
 
47
- def _create_new_computer(self, config=None):
57
+ def _create_new_computer(self, config: Optional[Dict[str, Any]] = None,
58
+ ram: Optional[Literal[2, 4]] = None,
59
+ cpu: Optional[Literal[2, 4]] = None):
48
60
  """Create a new computer instance and save its ID"""
61
+ # Validate ram and cpu values if provided
62
+ if ram is not None and ram not in [2, 4]:
63
+ raise ValueError("ram must be either 2 or 4 GB")
64
+ if cpu is not None and cpu not in [2, 4]:
65
+ raise ValueError("cpu must be either 2 or 4 cores")
66
+
67
+ # Build the config with ram and cpu if provided
68
+ if ram is not None or cpu is not None:
69
+ if config is None:
70
+ config = {}
71
+ else:
72
+ # Make a copy to avoid modifying the original
73
+ config = config.copy()
74
+
75
+ # Add ram and cpu to config
76
+ if ram is not None:
77
+ config['ram'] = ram
78
+ if cpu is not None:
79
+ config['cpu'] = cpu
80
+
49
81
  response = self.api.create_computer(config)
50
82
  self.project_id = response.get("name")
51
83
  self._info = response
@@ -74,7 +106,10 @@ class Computer:
74
106
 
75
107
  def destroy(self) -> Dict[str, Any]:
76
108
  """Terminate and delete the computer instance"""
77
- return self.api.delete_computer(self.project_id)
109
+ result = self.api.delete_computer(self.project_id)
110
+ # Clear the local project cache after destroying
111
+ ProjectManager.clear_project_cache()
112
+ return result
78
113
 
79
114
  # Navigation methods
80
115
  def left_click(self, x: int, y: int) -> Dict[str, Any]:
orgo/project.py CHANGED
@@ -2,6 +2,7 @@
2
2
  """Project management for Orgo virtual environments"""
3
3
  import os
4
4
  import json
5
+ import shutil
5
6
  import logging
6
7
  from typing import Optional
7
8
 
@@ -40,6 +41,18 @@ class ProjectManager:
40
41
  logger.error(f"Failed to save project ID: {str(e)}")
41
42
  raise RuntimeError(f"Failed to save project configuration: {str(e)}") from e
42
43
 
44
+ @staticmethod
45
+ def clear_project_cache() -> None:
46
+ """Clear the .orgo folder and all its contents"""
47
+ project_dir = ProjectManager._get_project_dir()
48
+
49
+ if os.path.exists(project_dir):
50
+ try:
51
+ shutil.rmtree(project_dir)
52
+ logger.info(f"Cleared project cache at {project_dir}")
53
+ except (IOError, OSError) as e:
54
+ logger.warning(f"Failed to clear project cache: {str(e)}")
55
+
43
56
  @staticmethod
44
57
  def _get_project_dir() -> str:
45
58
  """Get the project directory path"""
@@ -48,4 +61,4 @@ class ProjectManager:
48
61
  @staticmethod
49
62
  def _get_config_path() -> str:
50
63
  """Get the full path to the config file"""
51
- return os.path.join(ProjectManager._get_project_dir(), "project.json")
64
+ return os.path.join(ProjectManager._get_project_dir(), "project.json")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: orgo
3
- Version: 0.0.19
3
+ Version: 0.0.21
4
4
  Summary: Computers for AI agents
5
5
  Author: Orgo Team
6
6
  License: MIT
@@ -0,0 +1,12 @@
1
+ orgo/__init__.py,sha256=TlOzDJqRKotAam631MdZcz8ypAqyWrLo-Px8HWLkrD0,131
2
+ orgo/computer.py,sha256=83TGP1O1ED5xbdcdl3QbP0BEjRpav75TUnqGNlo4hnA,10980
3
+ orgo/project.py,sha256=F90mYJKRZAoFSFw8HVAiosMoLyzVlf0QaKJgTyXoJ4A,2267
4
+ orgo/prompt.py,sha256=ynblwXPTDp_aF1MbGBsY0PIEr9naklDaKFcfSE_EZ6E,19781
5
+ orgo/api/__init__.py,sha256=9Tzb_OPJ5DH7Cg7OrHzpZZUT4ip05alpa9RLDYmnId8,113
6
+ orgo/api/client.py,sha256=0pXH69jVwNvtmw2VdFcqkgFpkZANt8O5BjewULOcmJc,5843
7
+ orgo/utils/__init__.py,sha256=W4G_nwGBf_7jy0w_mfcrkllurYHSRU4B5cMTVYH_uCc,123
8
+ orgo/utils/auth.py,sha256=tPLBJY-6gdBQWLUjUbwIwxHphC3KoRT_XgP3Iykw3Mw,509
9
+ orgo-0.0.21.dist-info/METADATA,sha256=JGYppMUYQ4pCdMoHqdFXJsjYxjPGiPXLKAjEsBgYGmQ,822
10
+ orgo-0.0.21.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
11
+ orgo-0.0.21.dist-info/top_level.txt,sha256=q0rYtFji8GbYuhFW8A5Ab9e0j27761IKPhnL0E9xow4,5
12
+ orgo-0.0.21.dist-info/RECORD,,
@@ -1,12 +0,0 @@
1
- orgo/__init__.py,sha256=TlOzDJqRKotAam631MdZcz8ypAqyWrLo-Px8HWLkrD0,131
2
- orgo/computer.py,sha256=iX4KUzsCljT-F5m-ZlrUAs43wy8zlJIEQfvN-ghiKMM,9284
3
- orgo/project.py,sha256=0rcii4AKLWP4GSbUzfnP4G7TMgmzjm6bj2n-22NIjmk,1779
4
- orgo/prompt.py,sha256=ynblwXPTDp_aF1MbGBsY0PIEr9naklDaKFcfSE_EZ6E,19781
5
- orgo/api/__init__.py,sha256=9Tzb_OPJ5DH7Cg7OrHzpZZUT4ip05alpa9RLDYmnId8,113
6
- orgo/api/client.py,sha256=mCm1m_8k3DCCYSM0JvY29BI6HHlH0PjVXNnENHhvMvU,5799
7
- orgo/utils/__init__.py,sha256=W4G_nwGBf_7jy0w_mfcrkllurYHSRU4B5cMTVYH_uCc,123
8
- orgo/utils/auth.py,sha256=tPLBJY-6gdBQWLUjUbwIwxHphC3KoRT_XgP3Iykw3Mw,509
9
- orgo-0.0.19.dist-info/METADATA,sha256=Bs6WzId6JoTU0e93BMkvfceVKo8bN9GJzMNTig7TAy4,822
10
- orgo-0.0.19.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
11
- orgo-0.0.19.dist-info/top_level.txt,sha256=q0rYtFji8GbYuhFW8A5Ab9e0j27761IKPhnL0E9xow4,5
12
- orgo-0.0.19.dist-info/RECORD,,
File without changes