oagi-core 0.9.0__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.
- oagi/__init__.py +108 -0
- oagi/agent/__init__.py +31 -0
- oagi/agent/default.py +75 -0
- oagi/agent/factories.py +50 -0
- oagi/agent/protocol.py +55 -0
- oagi/agent/registry.py +155 -0
- oagi/agent/tasker/__init__.py +35 -0
- oagi/agent/tasker/memory.py +184 -0
- oagi/agent/tasker/models.py +83 -0
- oagi/agent/tasker/planner.py +385 -0
- oagi/agent/tasker/taskee_agent.py +395 -0
- oagi/agent/tasker/tasker_agent.py +323 -0
- oagi/async_pyautogui_action_handler.py +44 -0
- oagi/async_screenshot_maker.py +47 -0
- oagi/async_single_step.py +85 -0
- oagi/cli/__init__.py +11 -0
- oagi/cli/agent.py +125 -0
- oagi/cli/main.py +77 -0
- oagi/cli/server.py +94 -0
- oagi/cli/utils.py +82 -0
- oagi/client/__init__.py +12 -0
- oagi/client/async_.py +293 -0
- oagi/client/base.py +465 -0
- oagi/client/sync.py +296 -0
- oagi/exceptions.py +118 -0
- oagi/logging.py +47 -0
- oagi/pil_image.py +102 -0
- oagi/pyautogui_action_handler.py +268 -0
- oagi/screenshot_maker.py +41 -0
- oagi/server/__init__.py +13 -0
- oagi/server/agent_wrappers.py +98 -0
- oagi/server/config.py +46 -0
- oagi/server/main.py +157 -0
- oagi/server/models.py +98 -0
- oagi/server/session_store.py +116 -0
- oagi/server/socketio_server.py +405 -0
- oagi/single_step.py +87 -0
- oagi/task/__init__.py +14 -0
- oagi/task/async_.py +97 -0
- oagi/task/async_short.py +64 -0
- oagi/task/base.py +121 -0
- oagi/task/short.py +64 -0
- oagi/task/sync.py +97 -0
- oagi/types/__init__.py +28 -0
- oagi/types/action_handler.py +30 -0
- oagi/types/async_action_handler.py +30 -0
- oagi/types/async_image_provider.py +37 -0
- oagi/types/image.py +17 -0
- oagi/types/image_provider.py +34 -0
- oagi/types/models/__init__.py +32 -0
- oagi/types/models/action.py +33 -0
- oagi/types/models/client.py +64 -0
- oagi/types/models/image_config.py +47 -0
- oagi/types/models/step.py +17 -0
- oagi/types/url_image.py +47 -0
- oagi_core-0.9.0.dist-info/METADATA +257 -0
- oagi_core-0.9.0.dist-info/RECORD +60 -0
- oagi_core-0.9.0.dist-info/WHEEL +4 -0
- oagi_core-0.9.0.dist-info/entry_points.txt +2 -0
- oagi_core-0.9.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# -----------------------------------------------------------------------------
|
|
2
|
+
# Copyright (c) OpenAGI Foundation
|
|
3
|
+
# All rights reserved.
|
|
4
|
+
#
|
|
5
|
+
# This file is part of the official API project.
|
|
6
|
+
# Licensed under the MIT License.
|
|
7
|
+
# -----------------------------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
from enum import Enum
|
|
10
|
+
|
|
11
|
+
from pydantic import BaseModel, Field
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ActionType(str, Enum):
|
|
15
|
+
CLICK = "click"
|
|
16
|
+
LEFT_DOUBLE = "left_double"
|
|
17
|
+
LEFT_TRIPLE = "left_triple"
|
|
18
|
+
RIGHT_SINGLE = "right_single"
|
|
19
|
+
DRAG = "drag"
|
|
20
|
+
HOTKEY = "hotkey"
|
|
21
|
+
TYPE = "type"
|
|
22
|
+
SCROLL = "scroll"
|
|
23
|
+
FINISH = "finish"
|
|
24
|
+
WAIT = "wait"
|
|
25
|
+
CALL_USER = "call_user"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class Action(BaseModel):
|
|
29
|
+
type: ActionType = Field(..., description="Type of action to perform")
|
|
30
|
+
argument: str = Field(..., description="Action argument in the specified format")
|
|
31
|
+
count: int | None = Field(
|
|
32
|
+
default=1, ge=1, description="Number of times to repeat the action"
|
|
33
|
+
)
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# -----------------------------------------------------------------------------
|
|
2
|
+
# Copyright (c) OpenAGI Foundation
|
|
3
|
+
# All rights reserved.
|
|
4
|
+
#
|
|
5
|
+
# This file is part of the official API project.
|
|
6
|
+
# Licensed under the MIT License.
|
|
7
|
+
# -----------------------------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
from pydantic import BaseModel
|
|
10
|
+
|
|
11
|
+
from .action import Action
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class Usage(BaseModel):
|
|
15
|
+
prompt_tokens: int
|
|
16
|
+
completion_tokens: int
|
|
17
|
+
total_tokens: int
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class ErrorDetail(BaseModel):
|
|
21
|
+
"""Detailed error information."""
|
|
22
|
+
|
|
23
|
+
code: str
|
|
24
|
+
message: str
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class ErrorResponse(BaseModel):
|
|
28
|
+
"""Standard error response format."""
|
|
29
|
+
|
|
30
|
+
error: ErrorDetail | None
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class LLMResponse(BaseModel):
|
|
34
|
+
id: str
|
|
35
|
+
task_id: str
|
|
36
|
+
object: str = "task.completion"
|
|
37
|
+
created: int
|
|
38
|
+
model: str
|
|
39
|
+
task_description: str
|
|
40
|
+
is_complete: bool
|
|
41
|
+
actions: list[Action]
|
|
42
|
+
reason: str | None = None
|
|
43
|
+
usage: Usage
|
|
44
|
+
error: ErrorDetail | None = None
|
|
45
|
+
raw_output: str | None = None
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class UploadFileResponse(BaseModel):
|
|
49
|
+
"""Response from S3 presigned URL upload."""
|
|
50
|
+
|
|
51
|
+
url: str
|
|
52
|
+
uuid: str
|
|
53
|
+
expires_at: int
|
|
54
|
+
file_expires_at: int
|
|
55
|
+
download_url: str
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class GenerateResponse(BaseModel):
|
|
59
|
+
"""Response from /v2/generate endpoint."""
|
|
60
|
+
|
|
61
|
+
response: str
|
|
62
|
+
prompt_tokens: int
|
|
63
|
+
completion_tokens: int
|
|
64
|
+
cost: float # in USD
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# -----------------------------------------------------------------------------
|
|
2
|
+
# Copyright (c) OpenAGI Foundation
|
|
3
|
+
# All rights reserved.
|
|
4
|
+
#
|
|
5
|
+
# This file is part of the official API project.
|
|
6
|
+
# Licensed under the MIT License.
|
|
7
|
+
# -----------------------------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
from typing import Literal
|
|
10
|
+
|
|
11
|
+
from pydantic import BaseModel, Field, field_validator
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ImageConfig(BaseModel):
|
|
15
|
+
"""Configuration for image capture and processing."""
|
|
16
|
+
|
|
17
|
+
format: Literal["PNG", "JPEG"] = Field(
|
|
18
|
+
default="JPEG", description="Image format for encoding"
|
|
19
|
+
)
|
|
20
|
+
quality: int = Field(
|
|
21
|
+
default=85,
|
|
22
|
+
ge=1,
|
|
23
|
+
le=100,
|
|
24
|
+
description="JPEG quality (1-100, only applies to JPEG format)",
|
|
25
|
+
)
|
|
26
|
+
width: int | None = Field(
|
|
27
|
+
default=1260, description="Target width in pixels (will resize to exact size)"
|
|
28
|
+
)
|
|
29
|
+
height: int | None = Field(
|
|
30
|
+
default=700, description="Target height in pixels (will resize to exact size)"
|
|
31
|
+
)
|
|
32
|
+
optimize: bool = Field(
|
|
33
|
+
default=False,
|
|
34
|
+
description="Enable PNG optimization (only applies to PNG format)",
|
|
35
|
+
)
|
|
36
|
+
resample: Literal["NEAREST", "BILINEAR", "BICUBIC", "LANCZOS"] = Field(
|
|
37
|
+
default="LANCZOS", description="Resampling filter for resizing"
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
@field_validator("quality")
|
|
41
|
+
@classmethod
|
|
42
|
+
def validate_quality(cls, v: int, info) -> int:
|
|
43
|
+
"""Validate quality parameter based on format."""
|
|
44
|
+
values = info.data
|
|
45
|
+
if values.get("format") == "PNG" and v != 85:
|
|
46
|
+
return 85
|
|
47
|
+
return v
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# -----------------------------------------------------------------------------
|
|
2
|
+
# Copyright (c) OpenAGI Foundation
|
|
3
|
+
# All rights reserved.
|
|
4
|
+
#
|
|
5
|
+
# This file is part of the official API project.
|
|
6
|
+
# Licensed under the MIT License.
|
|
7
|
+
# -----------------------------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
from pydantic import BaseModel
|
|
10
|
+
|
|
11
|
+
from .action import Action
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class Step(BaseModel):
|
|
15
|
+
reason: str | None = None
|
|
16
|
+
actions: list[Action]
|
|
17
|
+
stop: bool = False
|
oagi/types/url_image.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""URLImage implementation for handling images via URLs."""
|
|
2
|
+
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class URLImage:
|
|
7
|
+
"""Image implementation that supports URLs.
|
|
8
|
+
|
|
9
|
+
This is useful when the image is already uploaded to a URL (e.g., S3)
|
|
10
|
+
and we want to pass the URL reference instead of downloading bytes.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
def __init__(self, url: str, cached_bytes: Optional[bytes] = None):
|
|
14
|
+
"""Initialize URLImage with a URL.
|
|
15
|
+
|
|
16
|
+
Args:
|
|
17
|
+
url: URL of the image
|
|
18
|
+
cached_bytes: Optional cached bytes of the image
|
|
19
|
+
"""
|
|
20
|
+
self.url = url
|
|
21
|
+
self._cached_bytes = cached_bytes
|
|
22
|
+
|
|
23
|
+
def read(self) -> bytes:
|
|
24
|
+
"""Read the image data as bytes.
|
|
25
|
+
|
|
26
|
+
For URL-based images, this returns empty bytes by default since
|
|
27
|
+
the image is already uploaded. Subclasses can override to fetch
|
|
28
|
+
the actual bytes from the URL if needed.
|
|
29
|
+
|
|
30
|
+
Returns:
|
|
31
|
+
Image bytes (empty for URL-only images)
|
|
32
|
+
"""
|
|
33
|
+
if self._cached_bytes is not None:
|
|
34
|
+
return self._cached_bytes
|
|
35
|
+
return b""
|
|
36
|
+
|
|
37
|
+
def get_url(self) -> str:
|
|
38
|
+
"""Get the URL of the image.
|
|
39
|
+
|
|
40
|
+
Returns:
|
|
41
|
+
The image URL
|
|
42
|
+
"""
|
|
43
|
+
return self.url
|
|
44
|
+
|
|
45
|
+
def __repr__(self) -> str:
|
|
46
|
+
"""String representation of URLImage."""
|
|
47
|
+
return f"URLImage(url='{self.url}')"
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: oagi-core
|
|
3
|
+
Version: 0.9.0
|
|
4
|
+
Summary: Official API of OpenAGI Foundation
|
|
5
|
+
Project-URL: Homepage, https://github.com/agiopen-org/oagi
|
|
6
|
+
Author-email: OpenAGI Foundation <contact@agiopen.org>
|
|
7
|
+
License: MIT License
|
|
8
|
+
|
|
9
|
+
Copyright (c) 2025 OpenAGI Foundation
|
|
10
|
+
|
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
+
in the Software without restriction, including without limitation the rights
|
|
14
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
furnished to do so, subject to the following conditions:
|
|
17
|
+
|
|
18
|
+
The above copyright notice and this permission notice shall be included in all
|
|
19
|
+
copies or substantial portions of the Software.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
+
SOFTWARE.
|
|
28
|
+
Requires-Python: >=3.10
|
|
29
|
+
Requires-Dist: httpx>=0.28.0
|
|
30
|
+
Requires-Dist: pydantic>=2.0.0
|
|
31
|
+
Provides-Extra: desktop
|
|
32
|
+
Requires-Dist: pillow>=11.3.0; extra == 'desktop'
|
|
33
|
+
Requires-Dist: pyautogui>=0.9.54; extra == 'desktop'
|
|
34
|
+
Provides-Extra: server
|
|
35
|
+
Requires-Dist: fastapi[standard]>=0.115.0; extra == 'server'
|
|
36
|
+
Requires-Dist: pydantic-settings>=2.0.0; extra == 'server'
|
|
37
|
+
Requires-Dist: python-socketio>=5.11.0; extra == 'server'
|
|
38
|
+
Requires-Dist: uvicorn[standard]>=0.32.0; extra == 'server'
|
|
39
|
+
Description-Content-Type: text/markdown
|
|
40
|
+
|
|
41
|
+
# OAGI Python SDK
|
|
42
|
+
|
|
43
|
+
Python SDK for the OAGI API - vision-based task automation.
|
|
44
|
+
|
|
45
|
+
## Installation
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# Recommended: All features (desktop automation + server)
|
|
49
|
+
pip install oagi
|
|
50
|
+
|
|
51
|
+
# Or install core only (minimal dependencies)
|
|
52
|
+
pip install oagi-core
|
|
53
|
+
|
|
54
|
+
# Or install with specific features
|
|
55
|
+
pip install oagi-core[desktop] # Desktop automation support
|
|
56
|
+
pip install oagi-core[server] # Server support
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**Requires Python >= 3.10**
|
|
60
|
+
|
|
61
|
+
### Installation Options
|
|
62
|
+
|
|
63
|
+
- **`oagi`** (Recommended): Metapackage that includes all features (desktop + server). Equivalent to `oagi-core[desktop,server]`.
|
|
64
|
+
- **`oagi-core`**: Core SDK with minimal dependencies (httpx, pydantic). Suitable for server deployments or custom automation setups.
|
|
65
|
+
- **`oagi-core[desktop]`**: Adds `pyautogui` and `pillow` for desktop automation features like screenshot capture and GUI control.
|
|
66
|
+
- **`oagi-core[server]`**: Adds FastAPI and Socket.IO dependencies for running the real-time server for browser extensions.
|
|
67
|
+
|
|
68
|
+
**Note**: Features requiring desktop dependencies (like `PILImage.from_screenshot()`, `PyautoguiActionHandler`, `ScreenshotMaker`) will show helpful error messages if you try to use them without installing the `desktop` extra.
|
|
69
|
+
|
|
70
|
+
## Quick Start
|
|
71
|
+
|
|
72
|
+
Set your API credentials:
|
|
73
|
+
```bash
|
|
74
|
+
export OAGI_API_KEY="your-api-key"
|
|
75
|
+
export OAGI_BASE_URL="https://api.oagi.com" # or your server URL
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Single-Step Analysis
|
|
79
|
+
|
|
80
|
+
Analyze a screenshot and get recommended actions:
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
from oagi import single_step
|
|
84
|
+
|
|
85
|
+
step = single_step(
|
|
86
|
+
task_description="Click the submit button",
|
|
87
|
+
screenshot="screenshot.png" # or bytes, or Image object
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
print(f"Actions: {step.actions}")
|
|
91
|
+
print(f"Complete: {step.is_complete}")
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Automated Task Execution
|
|
95
|
+
|
|
96
|
+
Run tasks automatically with screenshot capture and action execution:
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
from oagi import ShortTask, ScreenshotMaker, PyautoguiActionHandler
|
|
100
|
+
|
|
101
|
+
task = ShortTask()
|
|
102
|
+
completed = task.auto_mode(
|
|
103
|
+
"Search weather on Google",
|
|
104
|
+
max_steps=10,
|
|
105
|
+
executor=PyautoguiActionHandler(), # Executes mouse/keyboard actions
|
|
106
|
+
image_provider=ScreenshotMaker(), # Captures screenshots
|
|
107
|
+
)
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Configure PyAutoGUI behavior with custom settings:
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
from oagi import PyautoguiActionHandler, PyautoguiConfig
|
|
114
|
+
|
|
115
|
+
# Customize action behavior
|
|
116
|
+
config = PyautoguiConfig(
|
|
117
|
+
drag_duration=1.0, # Slower drags for precision (default: 0.5)
|
|
118
|
+
scroll_amount=50, # Larger scroll steps (default: 30)
|
|
119
|
+
wait_duration=2.0, # Longer waits (default: 1.0)
|
|
120
|
+
action_pause=0.2, # More pause between actions (default: 0.1)
|
|
121
|
+
hotkey_interval=0.1, # Interval between keys in hotkey combinations (default: 0.1)
|
|
122
|
+
capslock_mode="session" # Caps lock mode: 'session' or 'system' (default: 'session')
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
executor = PyautoguiActionHandler(config=config)
|
|
126
|
+
task.auto_mode("Complete form", executor=executor, image_provider=ScreenshotMaker())
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Image Processing
|
|
130
|
+
|
|
131
|
+
Process and optimize images before sending to API:
|
|
132
|
+
|
|
133
|
+
```python
|
|
134
|
+
from oagi import PILImage, ImageConfig
|
|
135
|
+
|
|
136
|
+
# Load and compress an image
|
|
137
|
+
image = PILImage.from_file("large_screenshot.png")
|
|
138
|
+
config = ImageConfig(
|
|
139
|
+
format="JPEG",
|
|
140
|
+
quality=85,
|
|
141
|
+
width=1260,
|
|
142
|
+
height=700
|
|
143
|
+
)
|
|
144
|
+
compressed = image.transform(config)
|
|
145
|
+
|
|
146
|
+
# Use with single_step
|
|
147
|
+
step = single_step("Click button", screenshot=compressed)
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Async Support
|
|
151
|
+
|
|
152
|
+
Use async client for non-blocking operations and better concurrency:
|
|
153
|
+
|
|
154
|
+
```python
|
|
155
|
+
import asyncio
|
|
156
|
+
from oagi import async_single_step, AsyncShortTask
|
|
157
|
+
|
|
158
|
+
async def main():
|
|
159
|
+
# Single-step async analysis
|
|
160
|
+
step = await async_single_step(
|
|
161
|
+
"Find the search bar",
|
|
162
|
+
screenshot="screenshot.png"
|
|
163
|
+
)
|
|
164
|
+
print(f"Found {len(step.actions)} actions")
|
|
165
|
+
|
|
166
|
+
# Async task automation
|
|
167
|
+
task = AsyncShortTask()
|
|
168
|
+
async with task:
|
|
169
|
+
await task.init_task("Complete the form")
|
|
170
|
+
# ... continue with async operations
|
|
171
|
+
|
|
172
|
+
asyncio.run(main())
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Examples
|
|
176
|
+
|
|
177
|
+
See the [`examples/`](examples/) directory for more usage patterns:
|
|
178
|
+
- `google_weather.py` - Basic task execution with `ShortTask`
|
|
179
|
+
- `single_step.py` - Basic single-step inference
|
|
180
|
+
- `screenshot_with_config.py` - Image compression and optimization
|
|
181
|
+
- `execute_task_auto.py` - Automated task execution
|
|
182
|
+
- `socketio_server_basic.py` - Socket.IO server example
|
|
183
|
+
- `socketio_client_example.py` - Socket.IO client implementation
|
|
184
|
+
|
|
185
|
+
## Socket.IO Server (Optional)
|
|
186
|
+
|
|
187
|
+
The SDK includes an optional Socket.IO server for real-time bidirectional communication with browser extensions or custom clients.
|
|
188
|
+
|
|
189
|
+
### Installation
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
# Install with server support
|
|
193
|
+
pip install oagi # Includes server features
|
|
194
|
+
# Or
|
|
195
|
+
pip install oagi-core[server] # Core + server only
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Running the Server
|
|
199
|
+
|
|
200
|
+
```python
|
|
201
|
+
import uvicorn
|
|
202
|
+
from oagi.server import create_app, ServerConfig
|
|
203
|
+
|
|
204
|
+
# Create FastAPI app with Socket.IO
|
|
205
|
+
app = create_app()
|
|
206
|
+
|
|
207
|
+
# Run server
|
|
208
|
+
uvicorn.run(app, host="0.0.0.0", port=8000)
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Or use the example script:
|
|
212
|
+
```bash
|
|
213
|
+
export OAGI_API_KEY="your-api-key"
|
|
214
|
+
python examples/socketio_server_basic.py
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Server Features
|
|
218
|
+
|
|
219
|
+
- **Dynamic namespaces**: Each session gets its own namespace (`/session/{session_id}`)
|
|
220
|
+
- **Simplified events**: Single `init` event from client with instruction
|
|
221
|
+
- **Action execution**: Emit individual actions (click, type, scroll, etc.) to client
|
|
222
|
+
- **S3 integration**: Server sends presigned URLs for direct screenshot uploads
|
|
223
|
+
- **Session management**: In-memory session storage with timeout cleanup
|
|
224
|
+
- **REST API**: Health checks and session management endpoints
|
|
225
|
+
|
|
226
|
+
### Client Integration
|
|
227
|
+
|
|
228
|
+
Clients connect to a session namespace and handle action events:
|
|
229
|
+
|
|
230
|
+
```python
|
|
231
|
+
import socketio
|
|
232
|
+
|
|
233
|
+
sio = socketio.AsyncClient()
|
|
234
|
+
namespace = "/session/my_session_id"
|
|
235
|
+
|
|
236
|
+
@sio.on("request_screenshot", namespace=namespace)
|
|
237
|
+
async def on_screenshot(data):
|
|
238
|
+
# Upload screenshot to S3 using presigned URL
|
|
239
|
+
return {"success": True}
|
|
240
|
+
|
|
241
|
+
@sio.on("click", namespace=namespace)
|
|
242
|
+
async def on_click(data):
|
|
243
|
+
# Execute click at coordinates
|
|
244
|
+
return {"success": True}
|
|
245
|
+
|
|
246
|
+
await sio.connect("http://localhost:8000", namespaces=[namespace])
|
|
247
|
+
await sio.emit("init", {"instruction": "Click the button"}, namespace=namespace)
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
See [`examples/socketio_client_example.py`](examples/socketio_client_example.py) for a complete implementation.
|
|
251
|
+
|
|
252
|
+
## Documentation
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
## License
|
|
256
|
+
|
|
257
|
+
MIT
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
oagi/__init__.py,sha256=2yFfGqF5Ve2ZmQHYNHvlTQJIENUV2j5AV_fROsUrbyU,2998
|
|
2
|
+
oagi/async_pyautogui_action_handler.py,sha256=F-lKyePCONWI03WnSxpX_QwxONbvnfdQu51wTod6mdw,1614
|
|
3
|
+
oagi/async_screenshot_maker.py,sha256=pI-dbLcYOzcO1ffgTmozAdbYJQNBPKA7hmqj1RxEmIY,1688
|
|
4
|
+
oagi/async_single_step.py,sha256=FxOSoZKKegHx0by41a4qrJDPoYZV0qZKtdTNMU8Uqz4,2955
|
|
5
|
+
oagi/exceptions.py,sha256=Rco37GQTPYUfc2vRO3hozxPF_s8mKFDpFvBg2UKWo3Y,3066
|
|
6
|
+
oagi/logging.py,sha256=YaG-UQWjqXJTfk6MsxcX_xfPVeVCq2ryIH1zwgR2_fQ,1455
|
|
7
|
+
oagi/pil_image.py,sha256=xs6nDRyjTCaoeIMb3GV5d4U6dbG5M5jr2TdMc57eJMo,4078
|
|
8
|
+
oagi/pyautogui_action_handler.py,sha256=N-4XcCV8f92ViuwXnpgk3ILGrlhR_8L1CKkGq_ub5gQ,9952
|
|
9
|
+
oagi/screenshot_maker.py,sha256=sVuW7jn-K4FmLhmYI-akdNI-UVcTeBzh9P1_qJhoq1s,1282
|
|
10
|
+
oagi/single_step.py,sha256=62Zip4Uql6E-ZIX6vAlrBoveKqrnABzGqHdLCzju4ag,3138
|
|
11
|
+
oagi/agent/__init__.py,sha256=JU9zuWuDzpzitsVJB4z5ddvx8RMm5nbP-bjUCL1Sfvo,834
|
|
12
|
+
oagi/agent/default.py,sha256=XJXbltDOak3Wer92MXiocLgD9_y0OWJ88isWNOFhaLk,2397
|
|
13
|
+
oagi/agent/factories.py,sha256=JsOqzUWY2_MlL16XznLR8MrWUqgOQTmAyDOvtsA1zvY,1386
|
|
14
|
+
oagi/agent/protocol.py,sha256=IQJGiMN4yZIacrh5e9JQsoM9TyHb8wJRQR4LAk8dSA0,1615
|
|
15
|
+
oagi/agent/registry.py,sha256=4oG65E_bV47Xl6F-HX9KaVoV0pcoC1uRRDU4RT_m3uU,4841
|
|
16
|
+
oagi/agent/tasker/__init__.py,sha256=faOC5ONY8ZKr4CjofC6HYg1WKWc1UiaGB9VHy8W280M,800
|
|
17
|
+
oagi/agent/tasker/memory.py,sha256=JsJjUMpnJoKW4VFzd8FI4M-FhnEihTecL61KVgO_YBI,6051
|
|
18
|
+
oagi/agent/tasker/models.py,sha256=VzvHB5hLv6qyYcyNiojVIEDlTzeGE4Quswk4EVIbzoI,2180
|
|
19
|
+
oagi/agent/tasker/planner.py,sha256=j0Zhk6kw0LFtxkpjFhmeaTBxZfKLf3qqCNpGAuMuODw,13650
|
|
20
|
+
oagi/agent/tasker/taskee_agent.py,sha256=L_5JvWQLVeqY35Xclv7YBOb0gHnGMZ4tJdbskGLc-_o,12966
|
|
21
|
+
oagi/agent/tasker/tasker_agent.py,sha256=PzfsBZvMCH1QMRXDMPQtezw4rX_PfOj7sXSsDAH0U6g,10705
|
|
22
|
+
oagi/cli/__init__.py,sha256=aDnJViTseShpo5fdGPTj-ELysZhmdvB6Z8mEj2D-_N4,359
|
|
23
|
+
oagi/cli/agent.py,sha256=U7Yjmfi7aGt--iisuylg0C2-17bVB3tTBq2sXYU0Gtg,4020
|
|
24
|
+
oagi/cli/main.py,sha256=faHns0HaQCGyylDn2YZLpjQESuEiMYjoQVoMkt8FsH4,2292
|
|
25
|
+
oagi/cli/server.py,sha256=Z1ic8r55yaeQBFRCsMNZStC1jRiJdnDGqe9On9LmFzQ,3031
|
|
26
|
+
oagi/cli/utils.py,sha256=QvDyoP0nU9aq4ORjnvJJAGRECmjh9WAmilKuk6zOGM8,2615
|
|
27
|
+
oagi/client/__init__.py,sha256=F9DShPUdb6vZYmN1fpM1VYzp4MWqUao_e_R1KYmM4Q4,410
|
|
28
|
+
oagi/client/async_.py,sha256=t-GPHcz6xbHx_RPFv1V_hwZ1_f-O9ONH-Ahr0w-Nz8M,11046
|
|
29
|
+
oagi/client/base.py,sha256=TlZk4LaYFlOQFmTTgTDzZ1XRAixqNO0pCwgJ7VhZOSU,17101
|
|
30
|
+
oagi/client/sync.py,sha256=QKd6nTUXtyn1Am8YlFcpsoLh1KuHhQgbMemIkb7r39g,10882
|
|
31
|
+
oagi/server/__init__.py,sha256=uZx8u3vJUb87kkNzwmmVrgAgbqRu0WxyMIQCLSx56kk,452
|
|
32
|
+
oagi/server/agent_wrappers.py,sha256=4f6ZKvqy9TDA57QRHGjAQVhpHmPE5QNeewmmURg5Ajo,3288
|
|
33
|
+
oagi/server/config.py,sha256=RstTWbPwWCfW9ZRJcns3uCbdhXxuUnerKjxR1pCGbqY,1602
|
|
34
|
+
oagi/server/main.py,sha256=jnTxk7Prc5CzlsUnkBNJp4MOoYN-7HN_Be_m1d3COa8,4829
|
|
35
|
+
oagi/server/models.py,sha256=E0R80zIz-YLpwx4VQyADQEnM89ZY9bXmjuswfhCuqMc,2595
|
|
36
|
+
oagi/server/session_store.py,sha256=UI14NiApAwvZWmMOG4SvPE2WkbGkNTHToZhTXQjN2_U,3624
|
|
37
|
+
oagi/server/socketio_server.py,sha256=UeNm9bemYMZqtYWp3i09BLUyEWW6t8yTkl2pjpSeT_M,14359
|
|
38
|
+
oagi/task/__init__.py,sha256=kvB8ENQ3iII9Uzqa9SSIxBv5JFKv44j2T6J-_Qc8A-4,494
|
|
39
|
+
oagi/task/async_.py,sha256=QDXaw3wAI8Utbph_kB1a3Elv2aeZwPnv2R7wT16LDXo,3242
|
|
40
|
+
oagi/task/async_short.py,sha256=h7Kchl4opUjyKQd_0Vd7DHWoBOTcYqN1lPdGeyTjoq8,2324
|
|
41
|
+
oagi/task/base.py,sha256=gUpWWhgbkrN17pmZNISmyzxLedhWZ39wVt7fRhH6JDM,4378
|
|
42
|
+
oagi/task/short.py,sha256=pjhoYN_a5KS_cGKfXbB575wdw-nx9ZdzJTplMr3sgqs,2148
|
|
43
|
+
oagi/task/sync.py,sha256=_tMjw4Gjyk3wKCD_q7Pwvug0-DMD7DalXZocrREZogc,3135
|
|
44
|
+
oagi/types/__init__.py,sha256=j-ShAARBbz-fGgkaQj5j_xyhFGM4XWnUTp-h3xhm9Bo,814
|
|
45
|
+
oagi/types/action_handler.py,sha256=NH8E-m5qpGqWcXzTSWfF7W0Xdp8SkzJsbhCmQ0B96cg,1075
|
|
46
|
+
oagi/types/async_action_handler.py,sha256=k1AaqSkFcXlxwW8sn-w0WFHGsIqHFLbcOPrkknmSVug,1116
|
|
47
|
+
oagi/types/async_image_provider.py,sha256=wnhRyPtTmuALt45Qore74-RCkP5yxU9sZGjvOzFqzOk,1170
|
|
48
|
+
oagi/types/image.py,sha256=KgPCCTJ6D5vHIaGZdbTE7eQEa1WlT6G9tf59ZuUCV2U,537
|
|
49
|
+
oagi/types/image_provider.py,sha256=oYFdOYznrK_VOR9egzOjw5wFM5w8EY2sY01pH0ANAgU,1112
|
|
50
|
+
oagi/types/url_image.py,sha256=iOwtXj2uwY6dVtDP7uvQLPvK-aTxkdrzhw_R4C6GwBw,1334
|
|
51
|
+
oagi/types/models/__init__.py,sha256=I86Z2moM8hCog_1K1FG_uATcBmWFv_UFetLAjzPzWAY,742
|
|
52
|
+
oagi/types/models/action.py,sha256=hh6mRRSSWgrW4jpZo71zGMCOcZpV5_COu4148uG6G48,967
|
|
53
|
+
oagi/types/models/client.py,sha256=fCN18DBq5XDjNyYB8w-2dFeQ_K9ywwdyh-rXa0GToU4,1357
|
|
54
|
+
oagi/types/models/image_config.py,sha256=tl6abVg_-IAPLwpaWprgknXu7wRWriMg-AEVyUX73v0,1567
|
|
55
|
+
oagi/types/models/step.py,sha256=RSI4H_2rrUBq_xyCoWKaq7JHdJWNobtQppaKC1l0aWU,471
|
|
56
|
+
oagi_core-0.9.0.dist-info/METADATA,sha256=4GekQr0XrNc9sDArtojzQTS6SYXNJz9ax8jQtDW-hMY,8187
|
|
57
|
+
oagi_core-0.9.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
|
58
|
+
oagi_core-0.9.0.dist-info/entry_points.txt,sha256=zzgsOSWX6aN3KUB0Z1it8DMxFFBJBqmZVqMVAJRjYuw,44
|
|
59
|
+
oagi_core-0.9.0.dist-info/licenses/LICENSE,sha256=sy5DLA2M29jFT4UfWsuBF9BAr3FnRkYtnAu6oDZiIf8,1075
|
|
60
|
+
oagi_core-0.9.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 OpenAGI Foundation
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|