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.
- {orgo-0.0.12 → orgo-0.0.13}/PKG-INFO +1 -1
- {orgo-0.0.12 → orgo-0.0.13}/pyproject.toml +1 -1
- {orgo-0.0.12 → orgo-0.0.13}/src/orgo/computer.py +25 -30
- orgo-0.0.13/src/orgo/project.py +50 -0
- {orgo-0.0.12 → orgo-0.0.13}/src/orgo.egg-info/PKG-INFO +1 -1
- {orgo-0.0.12 → orgo-0.0.13}/src/orgo.egg-info/SOURCES.txt +1 -0
- {orgo-0.0.12 → orgo-0.0.13}/README.md +0 -0
- {orgo-0.0.12 → orgo-0.0.13}/setup.cfg +0 -0
- {orgo-0.0.12 → orgo-0.0.13}/src/orgo/__init__.py +0 -0
- {orgo-0.0.12 → orgo-0.0.13}/src/orgo/adapters/__init__.py +0 -0
- {orgo-0.0.12 → orgo-0.0.13}/src/orgo/adapters/anthropic.py +0 -0
- {orgo-0.0.12 → orgo-0.0.13}/src/orgo/adapters/base.py +0 -0
- {orgo-0.0.12 → orgo-0.0.13}/src/orgo/adapters/openai.py +0 -0
- {orgo-0.0.12 → orgo-0.0.13}/src/orgo/api/__init__.py +0 -0
- {orgo-0.0.12 → orgo-0.0.13}/src/orgo/api/client.py +0 -0
- {orgo-0.0.12 → orgo-0.0.13}/src/orgo/prompt.py +0 -0
- {orgo-0.0.12 → orgo-0.0.13}/src/orgo/utils/__init__.py +0 -0
- {orgo-0.0.12 → orgo-0.0.13}/src/orgo/utils/auth.py +0 -0
- {orgo-0.0.12 → orgo-0.0.13}/src/orgo.egg-info/dependency_links.txt +0 -0
- {orgo-0.0.12 → orgo-0.0.13}/src/orgo.egg-info/requires.txt +0 -0
- {orgo-0.0.12 → orgo-0.0.13}/src/orgo.egg-info/top_level.txt +0 -0
|
@@ -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
|
-
|
|
31
|
-
|
|
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
|
-
|
|
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")
|
|
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
|
|
File without changes
|
|
File without changes
|