orgo 0.0.12__tar.gz → 0.0.13__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: orgo
3
- Version: 0.0.12
3
+ Version: 0.0.13
4
4
  Summary: Computers for AI agents
5
5
  Author: Orgo Team
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "orgo"
7
- version = "0.0.12"
7
+ version = "0.0.13"
8
8
  description = "Computers for AI agents"
9
9
  authors = [{name = "Orgo Team"}]
10
10
  license = {text = "MIT"}
@@ -1,15 +1,17 @@
1
1
  """Computer class for interacting with Orgo virtual environments"""
2
- # src/orgo/computer.py
3
-
4
2
  import os
5
3
  import io
6
4
  import base64
5
+ import logging
7
6
  from typing import Dict, List, Any, Optional, Callable, Union
8
7
  from PIL import Image
8
+ from requests.exceptions import RequestException
9
9
 
10
10
  from .api.client import ApiClient
11
11
  from .prompt import get_provider
12
+ from .project import ProjectManager
12
13
 
14
+ logger = logging.getLogger(__name__)
13
15
 
14
16
  class Computer:
15
17
  def __init__(self, project_id=None, api_key=None, config=None, base_api_url=None):
@@ -26,16 +28,31 @@ class Computer:
26
28
  self.base_api_url = base_api_url
27
29
  self.api = ApiClient(self.api_key, self.base_api_url)
28
30
 
31
+ # Look for a saved project ID if none was provided
32
+ if project_id is None:
33
+ project_id = ProjectManager.load_project_id()
34
+
29
35
  if project_id:
30
- self.project_id = project_id
31
- self._info = self.api.connect_computer(project_id)
36
+ try:
37
+ self.project_id = project_id
38
+ self._info = self.api.connect_computer(project_id)
39
+ except (RequestException, ValueError) as e:
40
+ logger.warning(f"Could not connect to saved project {project_id}: {e}")
41
+ self._create_new_computer(config)
32
42
  else:
33
- response = self.api.create_computer(config)
34
- self.project_id = response.get("name")
35
- self._info = response
43
+ self._create_new_computer(config)
36
44
 
45
+ def _create_new_computer(self, config=None):
46
+ """Create a new computer instance and save its ID"""
47
+ response = self.api.create_computer(config)
48
+ self.project_id = response.get("name")
49
+ self._info = response
50
+
37
51
  if not self.project_id:
38
52
  raise ValueError("Failed to initialize computer: No project ID returned")
53
+
54
+ # Save the project ID for future use
55
+ ProjectManager.save_project_id(self.project_id)
39
56
 
40
57
  def status(self) -> Dict[str, Any]:
41
58
  """Get current computer status"""
@@ -130,28 +147,6 @@ class Computer:
130
147
 
131
148
  Returns:
132
149
  List of messages from the conversation
133
-
134
- Examples:
135
- # Simple usage with environment variables
136
- computer.prompt("Open Firefox and search for Python tutorials")
137
-
138
- # With explicit API key
139
- computer.prompt("Open Terminal and list files", api_key="your-anthropic-key")
140
-
141
- # With callback for progress updates
142
- computer.prompt("Create a new text file", callback=my_callback_function)
143
-
144
- # With thinking enabled (Claude 3.7 Sonnet)
145
- computer.prompt(
146
- "Analyze a complex webpage",
147
- thinking_enabled=True
148
- )
149
-
150
- # With custom screenshot management
151
- computer.prompt(
152
- "Perform a complex multi-step task",
153
- max_saved_screenshots=10 # Keep more screenshots for complex tasks
154
- )
155
150
  """
156
151
  # Get the provider instance
157
152
  provider_instance = get_provider(provider)
@@ -173,4 +168,4 @@ class Computer:
173
168
  # Pass through the Orgo API client configuration
174
169
  orgo_api_key=self.api_key,
175
170
  orgo_base_url=self.base_api_url
176
- )
171
+ )
@@ -0,0 +1,50 @@
1
+ """Project management for Orgo virtual environments"""
2
+ import os
3
+ import json
4
+ import logging
5
+ from typing import Optional
6
+
7
+ logger = logging.getLogger(__name__)
8
+
9
+ class ProjectManager:
10
+ """Manages project persistence for Orgo computers"""
11
+
12
+ @staticmethod
13
+ def load_project_id() -> Optional[str]:
14
+ """Load project ID from local config file"""
15
+ config_path = ProjectManager._get_config_path()
16
+
17
+ if not os.path.exists(config_path):
18
+ return None
19
+
20
+ try:
21
+ with open(config_path, 'r') as f:
22
+ data = json.load(f)
23
+ return data.get('project_id')
24
+ except (json.JSONDecodeError, IOError, OSError) as e:
25
+ logger.warning(f"Error loading project config: {str(e)}")
26
+ return None
27
+
28
+ @staticmethod
29
+ def save_project_id(project_id: str) -> None:
30
+ """Save project ID to local config file"""
31
+ config_dir = ProjectManager._get_project_dir()
32
+ config_path = ProjectManager._get_config_path()
33
+
34
+ try:
35
+ os.makedirs(config_dir, exist_ok=True)
36
+ with open(config_path, 'w') as f:
37
+ json.dump({'project_id': project_id}, f, indent=2)
38
+ except (IOError, OSError) as e:
39
+ logger.error(f"Failed to save project ID: {str(e)}")
40
+ raise RuntimeError(f"Failed to save project configuration: {str(e)}") from e
41
+
42
+ @staticmethod
43
+ def _get_project_dir() -> str:
44
+ """Get the project directory path"""
45
+ return os.path.join(os.getcwd(), ".orgo")
46
+
47
+ @staticmethod
48
+ def _get_config_path() -> str:
49
+ """Get the full path to the config file"""
50
+ 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.12
3
+ Version: 0.0.13
4
4
  Summary: Computers for AI agents
5
5
  Author: Orgo Team
6
6
  License: MIT
@@ -2,6 +2,7 @@ README.md
2
2
  pyproject.toml
3
3
  src/orgo/__init__.py
4
4
  src/orgo/computer.py
5
+ src/orgo/project.py
5
6
  src/orgo/prompt.py
6
7
  src/orgo.egg-info/PKG-INFO
7
8
  src/orgo.egg-info/SOURCES.txt
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