oagi 0.0.0__tar.gz → 0.1.0__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.

Potentially problematic release.


This version of oagi might be problematic. Click here for more details.

Files changed (46) hide show
  1. oagi-0.1.0/.claude/settings.local.json +19 -0
  2. oagi-0.1.0/.github/workflows/ci.yml +45 -0
  3. oagi-0.1.0/.gitignore +207 -0
  4. oagi-0.1.0/.python-version +1 -0
  5. oagi-0.1.0/CLAUDE.md +105 -0
  6. oagi-0.1.0/CONTRIBUTING.md +1 -0
  7. {oagi-0.0.0 → oagi-0.1.0}/LICENSE +21 -21
  8. oagi-0.1.0/Makefile +31 -0
  9. {oagi-0.0.0 → oagi-0.1.0}/PKG-INFO +35 -31
  10. oagi-0.1.0/README.md +1 -0
  11. oagi-0.1.0/examples/execute_task_auto.py +23 -0
  12. oagi-0.1.0/examples/execute_task_manual.py +42 -0
  13. oagi-0.1.0/examples/google_weather.py +15 -0
  14. oagi-0.1.0/examples/hotel_booking.py +52 -0
  15. oagi-0.1.0/examples/screenshot.png +0 -0
  16. oagi-0.1.0/examples/test.py +20 -0
  17. oagi-0.1.0/examples/test_screenshot.py +41 -0
  18. oagi-0.1.0/pyproject.toml +35 -0
  19. oagi-0.1.0/src/oagi/__init__.py +13 -0
  20. oagi-0.1.0/src/oagi/logging.py +45 -0
  21. oagi-0.1.0/src/oagi/pyautogui_action_handler.py +146 -0
  22. oagi-0.1.0/src/oagi/screenshot_maker.py +73 -0
  23. oagi-0.1.0/src/oagi/short_task.py +122 -0
  24. oagi-0.1.0/src/oagi/sync_client.py +183 -0
  25. oagi-0.1.0/src/oagi/types/__init__.py +14 -0
  26. oagi-0.1.0/src/oagi/types/action_handler.py +30 -0
  27. oagi-0.1.0/src/oagi/types/image.py +16 -0
  28. oagi-0.1.0/src/oagi/types/image_provider.py +34 -0
  29. oagi-0.1.0/src/oagi/types/models/__init__.py +12 -0
  30. oagi-0.1.0/src/oagi/types/models/action.py +32 -0
  31. oagi-0.1.0/src/oagi/types/models/step.py +17 -0
  32. oagi-0.1.0/tests/__init__.py +9 -0
  33. oagi-0.1.0/tests/conftest.py +189 -0
  34. oagi-0.1.0/tests/test_logging.py +321 -0
  35. oagi-0.1.0/tests/test_pyautogui_action_handler.py +147 -0
  36. oagi-0.1.0/tests/test_screenshot_maker.py +149 -0
  37. oagi-0.1.0/tests/test_sync_client.py +331 -0
  38. oagi-0.1.0/uv.lock +642 -0
  39. oagi-0.0.0/oagi/__init__.py +0 -1
  40. oagi-0.0.0/oagi/core.py +0 -2
  41. oagi-0.0.0/oagi.egg-info/PKG-INFO +0 -31
  42. oagi-0.0.0/oagi.egg-info/SOURCES.txt +0 -8
  43. oagi-0.0.0/oagi.egg-info/dependency_links.txt +0 -1
  44. oagi-0.0.0/oagi.egg-info/top_level.txt +0 -1
  45. oagi-0.0.0/pyproject.toml +0 -17
  46. oagi-0.0.0/setup.cfg +0 -4
@@ -0,0 +1,19 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(uv run ruff:*)",
5
+ "Bash(python3:*)",
6
+ "Bash(uv run:*)",
7
+ "Bash(OAGI_BASE_URL=\"https://env.example.com\" OAGI_API_KEY=\"env-key\" uv run python -c \"\nimport os\nfrom oagi.sync_client import SyncClient\nfrom oagi.short_task import ShortTask\n\n# Test SyncClient with env vars\nclient = SyncClient()\nprint(''✓ SyncClient created from environment variables'')\nprint(f'' base_url: {client.base_url}'')\nprint(f'' api_key: {client.api_key}'')\nclient.close()\n\n# Test ShortTask with env vars\ntask = ShortTask()\nprint(''✓ ShortTask created from environment variables'')\nprint(f'' base_url: {task.base_url}'')\nprint(f'' api_key: {task.api_key}'')\ntask.close()\n\n# Test parameter override\ntask_override = ShortTask(base_url=''https://override.example.com'', api_key=''override-key'')\nprint(''✓ ShortTask created with parameter override'')\nprint(f'' base_url: {task_override.base_url}'')\nprint(f'' api_key: {task_override.api_key}'')\ntask_override.close()\n\")",
8
+ "Bash(OAGI_LOG=ERROR OAGI_BASE_URL=\"https://test.example.com\" OAGI_API_KEY=\"test-key\" uv run python -c \"\nfrom oagi.sync_client import SyncClient \nfrom oagi.short_task import ShortTask\n\nprint(''=== Testing ERROR level logging ==='')\nclient = SyncClient()\ntask = ShortTask()\ntask.init_task(''Error test task'')\nprint(''ERROR logging test completed\\n'')\n\")",
9
+ "Bash(OAGI_LOG=DEBUG OAGI_BASE_URL=\"https://test.example.com\" OAGI_API_KEY=\"test-key\" uv run python -c \"\nfrom oagi.sync_client import SyncClient\nfrom oagi.short_task import ShortTask\n\nprint(''=== Testing DEBUG level logging ==='')\nclient = SyncClient()\ntask = ShortTask()\ntask.init_task(''Debug test task'')\nprint(''DEBUG logging test completed\\n'')\n\")",
10
+ "Bash(OAGI_LOG=DEBUG OAGI_BASE_URL=\"https://test.example.com\" OAGI_API_KEY=\"test-key\" uv run python -c \"\nfrom oagi.short_task import ShortTask\nfrom oagi.screenshot_maker import MockImage\n\nprint(''=== Testing DEBUG with step execution ==='')\ntask = ShortTask()\ntask.init_task(''Debug step test'')\n\n# This should trigger DEBUG logs\nprint(''About to call step...'')\ntry:\n result = task.step(MockImage())\n print(''Step completed successfully'') \nexcept Exception as e:\n print(f''Step failed: {e}'')\n\")",
11
+ "Bash(OAGI_LOG=WARNING OAGI_BASE_URL=\"https://test.example.com\" OAGI_API_KEY=\"test-key\" uv run python -c \"\nfrom oagi.short_task import ShortTask\nfrom oagi.screenshot_maker import MockImage\n\nprint(''=== Testing WARNING level logging ==='')\ntask = ShortTask()\ntask.init_task(''Warning test'')\n\n# This should only show WARNING and ERROR, not INFO or DEBUG\ntry:\n result = task.step(MockImage()) \nexcept Exception:\n pass\n \nprint(''WARNING level test completed'')\n\")",
12
+ "Bash(OAGI_LOG=ERROR uv run pytest tests/test_sync_client.py -q)",
13
+ "Bash(make lint:*)",
14
+ "Bash(make:*)"
15
+ ],
16
+ "deny": [],
17
+ "ask": []
18
+ }
19
+ }
@@ -0,0 +1,45 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+ branches: ["main"]
7
+
8
+ jobs:
9
+ lint:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+
14
+ - name: Install uv
15
+ uses: astral-sh/setup-uv@v3
16
+
17
+ - name: Install dependencies
18
+ run: make install
19
+
20
+ - name: Run lint
21
+ run: make lint
22
+
23
+ build:
24
+ runs-on: ubuntu-latest
25
+ steps:
26
+ - uses: actions/checkout@v4
27
+ - uses: astral-sh/setup-uv@v3
28
+ - run: make install
29
+ - run: make build
30
+
31
+ test:
32
+ runs-on: ubuntu-latest
33
+ steps:
34
+ - uses: actions/checkout@v4
35
+ - uses: astral-sh/setup-uv@v3
36
+
37
+ - name: Install system dependencies
38
+ run: |
39
+ sudo apt-get update
40
+ sudo apt-get install -y xvfb
41
+
42
+ - run: make install
43
+
44
+ - name: Run tests with virtual display
45
+ run: xvfb-run -a make test-verbose
oagi-0.1.0/.gitignore ADDED
@@ -0,0 +1,207 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+ #poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ #pdm.lock
116
+ #pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ #pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # SageMath parsed files
135
+ *.sage.py
136
+
137
+ # Environments
138
+ .env
139
+ .envrc
140
+ .venv
141
+ env/
142
+ venv/
143
+ ENV/
144
+ env.bak/
145
+ venv.bak/
146
+
147
+ # Spyder project settings
148
+ .spyderproject
149
+ .spyproject
150
+
151
+ # Rope project settings
152
+ .ropeproject
153
+
154
+ # mkdocs documentation
155
+ /site
156
+
157
+ # mypy
158
+ .mypy_cache/
159
+ .dmypy.json
160
+ dmypy.json
161
+
162
+ # Pyre type checker
163
+ .pyre/
164
+
165
+ # pytype static type analyzer
166
+ .pytype/
167
+
168
+ # Cython debug symbols
169
+ cython_debug/
170
+
171
+ # PyCharm
172
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
173
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
174
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
175
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
176
+ .idea/
177
+
178
+ # Abstra
179
+ # Abstra is an AI-powered process automation framework.
180
+ # Ignore directories containing user credentials, local state, and settings.
181
+ # Learn more at https://abstra.io/docs
182
+ .abstra/
183
+
184
+ # Visual Studio Code
185
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
186
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
187
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
188
+ # you could uncomment the following to ignore the entire vscode folder
189
+ # .vscode/
190
+
191
+ # Ruff stuff:
192
+ .ruff_cache/
193
+
194
+ # PyPI configuration file
195
+ .pypirc
196
+
197
+ # Cursor
198
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
199
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
200
+ # refer to https://docs.cursor.com/context/ignore-files
201
+ .cursorignore
202
+ .cursorindexingignore
203
+
204
+ # Marimo
205
+ marimo/_static/
206
+ marimo/_lsp/
207
+ __marimo__/
@@ -0,0 +1 @@
1
+ 3.10.18
oagi-0.1.0/CLAUDE.md ADDED
@@ -0,0 +1,105 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Code style
6
+ - Use modern python syntax (eg. `|` instead of `Optional` and pattern matching)
7
+ - For tests, don't write redundant docstrings
8
+ - Use relative imports as the repo is a python library
9
+
10
+ ## Development Commands
11
+
12
+ **Setup and Installation:**
13
+ ```bash
14
+ make install # Install all dependencies and extras using uv
15
+ ```
16
+
17
+ **Code Quality:**
18
+ ```bash
19
+ make lint # Run ruff check and format --check
20
+ make format # Run ruff check --fix and format
21
+ ```
22
+
23
+ **Testing:**
24
+ ```bash
25
+ make test # Run all tests
26
+ make test-verbose # Run tests with verbose output
27
+ ```
28
+
29
+ **Build:**
30
+ ```bash
31
+ make build # Build the package using uv
32
+ ```
33
+
34
+ ## Architecture Overview
35
+
36
+ This is the **OAGI Python SDK** - a client library for interacting with the OAGI API Gateway that provides vision-based task automation capabilities.
37
+
38
+ ### Core Architecture
39
+
40
+ **Three-Layer Design:**
41
+ 1. **API Client Layer** (`sync_client.py`) - HTTP client wrapping the OAGI API Gateway
42
+ 2. **Task Orchestration** (`short_task.py`) - High-level task management and workflow
43
+ 3. **Execution Layer** - Action handlers and image providers for automation
44
+
45
+ ### Key Components
46
+
47
+ **SyncClient** (`src/oagi/sync_client.py`):
48
+ - httpx-based HTTP client with persistent connections
49
+ - Wraps `/v1/message` endpoint for vision-based task analysis
50
+ - Handles task initialization and continuation via task_id management
51
+ - Manages API authentication and error handling
52
+
53
+ **ShortTask** (`src/oagi/short_task.py`):
54
+ - Main orchestration class that coordinates the task execution workflow
55
+ - `init_task()` - starts new task with description
56
+ - `step()` - sends screenshots to API and gets action recommendations
57
+ - `auto_mode()` - fully automated execution with action handlers
58
+ - Maintains task state across multiple API calls
59
+
60
+ **Type System** (`src/oagi/types/`):
61
+ - **Action** - Represents executable actions (click, type, scroll, etc.)
62
+ - **Step** - Contains reasoning, actions, and completion status
63
+ - **ActionHandler Protocol** - Interface for executing actions
64
+ - **ImageProvider Protocol** - Interface for capturing screenshots
65
+
66
+ **Default Implementations:**
67
+ - **PyautoguiActionHandler** - Stub implementation for PyAutoGUI-based automation
68
+ - **ScreenshotMaker** - Stub implementation for screen capture
69
+
70
+ ### API Integration Pattern
71
+
72
+ The SDK follows a stateful conversation pattern with the OAGI API:
73
+
74
+ 1. **Task Initialization**: First call to `/v1/message` with `task_description`, receives `task_id`
75
+ 2. **Task Continuation**: Subsequent calls use `task_id` with new screenshots
76
+ 3. **Action Execution**: API returns recommended actions based on screenshot analysis
77
+ 4. **Completion Detection**: API indicates when task is complete via `is_complete` flag
78
+
79
+ ### Usage Patterns
80
+
81
+ **Manual Control** (step-by-step):
82
+ ```python
83
+ task = ShortTask(api_key="...", base_url="...")
84
+ task.init_task("Go to website and login")
85
+ screenshot = image_provider()
86
+ step = task.step(screenshot) # Returns actions to take
87
+ executor(step.actions) # Execute the actions
88
+ ```
89
+
90
+ **Automated Mode**:
91
+ ```python
92
+ task.auto_mode(
93
+ "Complete booking process",
94
+ executor=PyautoguiActionHandler(),
95
+ image_provider=ScreenshotMaker()
96
+ )
97
+ ```
98
+
99
+ ### Important Implementation Details
100
+
101
+ - **HTTP Connection Reuse**: SyncClient uses a single httpx.Client instance for keep-alive connections
102
+ - **Task State Management**: task_id is automatically managed between API calls
103
+ - **Resource Cleanup**: Both SyncClient and ShortTask support context managers and explicit close() methods
104
+ - **Error Handling**: Custom exceptions for API errors with detailed error information
105
+ - **Type Safety**: Full Pydantic models for all API request/response structures
@@ -0,0 +1 @@
1
+ ## Development
@@ -1,21 +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.
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.
oagi-0.1.0/Makefile ADDED
@@ -0,0 +1,31 @@
1
+ .PHONY: .uv
2
+ .uv:
3
+ @uv -V || echo 'Please install uv: https://docs.astral.sh/uv/getting-started/installation/'
4
+
5
+ .PHONY: install-dev
6
+ install-dev: .uv
7
+ uv sync --frozen --all-groups --all-extras
8
+
9
+ .PHONY: install
10
+ install: install-dev
11
+
12
+ .PHONY: format
13
+ format: .uv
14
+ uv run ruff check --fix
15
+ uv run ruff format
16
+
17
+ .PHONY: lint
18
+ lint: .uv
19
+ uv run ruff check
20
+ uv run ruff format --check
21
+
22
+ build: .uv
23
+ uv build
24
+
25
+ .PHONY: test
26
+ test: .uv
27
+ uv run pytest
28
+
29
+ .PHONY: test-verbose
30
+ test-verbose: .uv
31
+ uv run pytest -v
@@ -1,31 +1,35 @@
1
- Metadata-Version: 2.4
2
- Name: oagi
3
- Version: 0.0.0
4
- Summary: Official API of OpenAGI Foundation
5
- Author-email: OpenAGI Foundation <contact@agiopen.org>
6
- License: MIT License
7
-
8
- Copyright (c) 2025 OpenAGI Foundation
9
-
10
- Permission is hereby granted, free of charge, to any person obtaining a copy
11
- of this software and associated documentation files (the "Software"), to deal
12
- in the Software without restriction, including without limitation the rights
13
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
- copies of the Software, and to permit persons to whom the Software is
15
- furnished to do so, subject to the following conditions:
16
-
17
- The above copyright notice and this permission notice shall be included in all
18
- copies or substantial portions of the Software.
19
-
20
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
- SOFTWARE.
27
-
28
- Project-URL: Homepage, https://github.com/agiopen-org/oagi
29
- Description-Content-Type: text/markdown
30
- License-File: LICENSE
31
- Dynamic: license-file
1
+ Metadata-Version: 2.3
2
+ Name: oagi
3
+ Version: 0.1.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: pillow>=11.3.0
31
+ Requires-Dist: pyautogui>=0.9.54
32
+ Requires-Dist: pydantic>=2.0.0
33
+ Description-Content-Type: text/markdown
34
+
35
+ # OAGI Python SDK
oagi-0.1.0/README.md ADDED
@@ -0,0 +1 @@
1
+ # OAGI Python SDK
@@ -0,0 +1,23 @@
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
+ from oagi import PyautoguiActionHandler, ScreenshotMaker, ShortTask
9
+
10
+
11
+ def execute_task_auto(task_desc, max_steps=5):
12
+ # set OAGI_API_KEY and OAGI_BASE_URL
13
+ # or ShortTask(api_key="your_api_key", base_url="your_base_url")
14
+ short_task = ShortTask()
15
+
16
+ is_completed = short_task.auto_mode(
17
+ task_desc,
18
+ max_steps=max_steps,
19
+ executor=PyautoguiActionHandler(), # or executor = lambda actions: print(actions) for debugging
20
+ image_provider=(sm := ScreenshotMaker()),
21
+ )
22
+
23
+ return is_completed, sm.last_image()
@@ -0,0 +1,42 @@
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 oagi import PyautoguiActionHandler, ScreenshotMaker, ShortTask
10
+
11
+
12
+ def execute_task_manual(task_desc, max_steps=5):
13
+ # set OAGI_API_KEY and OAGI_BASE_URL
14
+ # or ShortTask(api_key="your_api_key", base_url="your_base_url")
15
+ short_task = ShortTask()
16
+ short_task.init_task(task_desc, max_steps=max_steps)
17
+ executor = (
18
+ PyautoguiActionHandler()
19
+ ) # executor = lambda actions: print(actions) for debugging
20
+ image_provider = ScreenshotMaker()
21
+
22
+ for i in range(max_steps):
23
+ image = image_provider()
24
+ # do something with image, maybe save it or OCR then break
25
+ step = short_task.step(image)
26
+ # do something with step, maybe print to debug
27
+ print(f"Step {i}: {step.reason=}")
28
+
29
+ if step.stop:
30
+ print(f"Task completed after {i} steps.")
31
+ is_completed = True
32
+ screenshot = image_provider.last_image()
33
+ break
34
+
35
+ executor(step.actions)
36
+ else:
37
+ # If we didn't break out of the loop, we used up all our steps
38
+ is_completed = False
39
+ screenshot = image_provider()
40
+
41
+ print(f"manual execution completed: {is_completed=}, {task_desc=}\n")
42
+ return is_completed, screenshot
@@ -0,0 +1,15 @@
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 examples.execute_task_manual import execute_task_manual
10
+
11
+ is_completed, screenshot = execute_task_manual(
12
+ desc := "Search weather with Google", max_steps=5
13
+ )
14
+
15
+ print(f"is_completed: {is_completed}, desc: {desc}")
@@ -0,0 +1,52 @@
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
+ from datetime import date
9
+
10
+ from examples.execute_task_auto import execute_task_auto
11
+ from examples.execute_task_manual import execute_task_manual
12
+
13
+
14
+ def get_date():
15
+ today = date.today()
16
+ # move to first day of this month
17
+ first_day_this_month = today.replace(day=1)
18
+ # move to first day of next month
19
+ if first_day_this_month.month == 12:
20
+ first_day_next_month = first_day_this_month.replace(
21
+ year=first_day_this_month.year + 1, month=1
22
+ )
23
+ else:
24
+ first_day_next_month = first_day_this_month.replace(
25
+ month=first_day_this_month.month + 1
26
+ )
27
+
28
+ start_date = str(first_day_this_month)
29
+ end_date = str(first_day_next_month.replace(day=3))
30
+ return start_date, end_date
31
+
32
+
33
+ def main():
34
+ """Task decomposition
35
+ 1. Go to expedia.com
36
+ 2. Click where to and enter Foster City
37
+ 3. Click dates and click start date
38
+ 4. Click end date and hit search
39
+ """
40
+ start_date, end_date = get_date()
41
+
42
+ is_completed, screenshot = execute_task_auto(desc := "Go to expedia.com")
43
+ print(f"auto execution completed: {is_completed=}, {desc=}\n")
44
+
45
+ execute_task = execute_task_manual # or execute_task_auto
46
+ execute_task("Click where to and enter Foster City")
47
+ execute_task(f"Click dates and click {start_date}")
48
+ execute_task(f"Click {end_date} and hit search")
49
+
50
+
51
+ if __name__ == "__main__":
52
+ main()
Binary file