openhands-ai 0.8.3__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.
- openhands_ai-0.8.3/LICENSE +25 -0
- openhands_ai-0.8.3/PKG-INFO +207 -0
- openhands_ai-0.8.3/README.md +159 -0
- openhands_ai-0.8.3/openhands/README.md +52 -0
- openhands_ai-0.8.3/openhands/__init__.py +0 -0
- openhands_ai-0.8.3/openhands/controller/__init__.py +5 -0
- openhands_ai-0.8.3/openhands/controller/action_parser.py +67 -0
- openhands_ai-0.8.3/openhands/controller/agent.py +109 -0
- openhands_ai-0.8.3/openhands/controller/agent_controller.py +562 -0
- openhands_ai-0.8.3/openhands/controller/state/state.py +172 -0
- openhands_ai-0.8.3/openhands/controller/state/task.py +226 -0
- openhands_ai-0.8.3/openhands/controller/stuck.py +237 -0
- openhands_ai-0.8.3/openhands/core/config.py +762 -0
- openhands_ai-0.8.3/openhands/core/const/guide_url.py +1 -0
- openhands_ai-0.8.3/openhands/core/download.py +2 -0
- openhands_ai-0.8.3/openhands/core/exceptions.py +74 -0
- openhands_ai-0.8.3/openhands/core/logger.py +255 -0
- openhands_ai-0.8.3/openhands/core/main.py +259 -0
- openhands_ai-0.8.3/openhands/core/message.py +59 -0
- openhands_ai-0.8.3/openhands/core/metrics.py +48 -0
- openhands_ai-0.8.3/openhands/core/schema/__init__.py +11 -0
- openhands_ai-0.8.3/openhands/core/schema/action.py +86 -0
- openhands_ai-0.8.3/openhands/core/schema/agent.py +51 -0
- openhands_ai-0.8.3/openhands/core/schema/config.py +47 -0
- openhands_ai-0.8.3/openhands/core/schema/observation.py +46 -0
- openhands_ai-0.8.3/openhands/core/utils/__init__.py +3 -0
- openhands_ai-0.8.3/openhands/core/utils/json.py +49 -0
- openhands_ai-0.8.3/openhands/core/utils/singleton.py +37 -0
- openhands_ai-0.8.3/openhands/events/__init__.py +9 -0
- openhands_ai-0.8.3/openhands/events/action/__init__.py +34 -0
- openhands_ai-0.8.3/openhands/events/action/action.py +23 -0
- openhands_ai-0.8.3/openhands/events/action/agent.py +81 -0
- openhands_ai-0.8.3/openhands/events/action/browse.py +47 -0
- openhands_ai-0.8.3/openhands/events/action/commands.py +57 -0
- openhands_ai-0.8.3/openhands/events/action/empty.py +16 -0
- openhands_ai-0.8.3/openhands/events/action/files.py +42 -0
- openhands_ai-0.8.3/openhands/events/action/message.py +26 -0
- openhands_ai-0.8.3/openhands/events/action/tasks.py +30 -0
- openhands_ai-0.8.3/openhands/events/event.py +51 -0
- openhands_ai-0.8.3/openhands/events/observation/__init__.py +25 -0
- openhands_ai-0.8.3/openhands/events/observation/agent.py +17 -0
- openhands_ai-0.8.3/openhands/events/observation/browse.py +44 -0
- openhands_ai-0.8.3/openhands/events/observation/commands.py +45 -0
- openhands_ai-0.8.3/openhands/events/observation/delegate.py +23 -0
- openhands_ai-0.8.3/openhands/events/observation/empty.py +18 -0
- openhands_ai-0.8.3/openhands/events/observation/error.py +16 -0
- openhands_ai-0.8.3/openhands/events/observation/files.py +29 -0
- openhands_ai-0.8.3/openhands/events/observation/observation.py +8 -0
- openhands_ai-0.8.3/openhands/events/observation/reject.py +16 -0
- openhands_ai-0.8.3/openhands/events/observation/success.py +16 -0
- openhands_ai-0.8.3/openhands/events/serialization/__init__.py +19 -0
- openhands_ai-0.8.3/openhands/events/serialization/action.py +61 -0
- openhands_ai-0.8.3/openhands/events/serialization/event.py +101 -0
- openhands_ai-0.8.3/openhands/events/serialization/observation.py +48 -0
- openhands_ai-0.8.3/openhands/events/serialization/utils.py +20 -0
- openhands_ai-0.8.3/openhands/events/stream.py +155 -0
- openhands_ai-0.8.3/openhands/llm/bedrock.py +32 -0
- openhands_ai-0.8.3/openhands/llm/llm.py +511 -0
- openhands_ai-0.8.3/openhands/memory/README.md +23 -0
- openhands_ai-0.8.3/openhands/memory/__init__.py +5 -0
- openhands_ai-0.8.3/openhands/memory/condenser.py +24 -0
- openhands_ai-0.8.3/openhands/memory/history.py +261 -0
- openhands_ai-0.8.3/openhands/memory/memory.py +184 -0
- openhands_ai-0.8.3/openhands/runtime/__init__.py +21 -0
- openhands_ai-0.8.3/openhands/runtime/browser/__init__.py +3 -0
- openhands_ai-0.8.3/openhands/runtime/browser/browser_env.py +231 -0
- openhands_ai-0.8.3/openhands/runtime/browser/utils.py +60 -0
- openhands_ai-0.8.3/openhands/runtime/builder/__init__.py +4 -0
- openhands_ai-0.8.3/openhands/runtime/builder/base.py +37 -0
- openhands_ai-0.8.3/openhands/runtime/builder/docker.py +83 -0
- openhands_ai-0.8.3/openhands/runtime/client/client.py +685 -0
- openhands_ai-0.8.3/openhands/runtime/client/runtime.py +386 -0
- openhands_ai-0.8.3/openhands/runtime/e2b/README.md +35 -0
- openhands_ai-0.8.3/openhands/runtime/e2b/filestore.py +18 -0
- openhands_ai-0.8.3/openhands/runtime/e2b/runtime.py +57 -0
- openhands_ai-0.8.3/openhands/runtime/e2b/sandbox.py +116 -0
- openhands_ai-0.8.3/openhands/runtime/plugins/__init__.py +18 -0
- openhands_ai-0.8.3/openhands/runtime/plugins/agent_skills/README.md +57 -0
- openhands_ai-0.8.3/openhands/runtime/plugins/agent_skills/__init__.py +15 -0
- openhands_ai-0.8.3/openhands/runtime/plugins/agent_skills/agentskills.py +25 -0
- openhands_ai-0.8.3/openhands/runtime/plugins/agent_skills/file_ops/__init__.py +7 -0
- openhands_ai-0.8.3/openhands/runtime/plugins/agent_skills/file_ops/file_ops.py +857 -0
- openhands_ai-0.8.3/openhands/runtime/plugins/agent_skills/file_reader/__init__.py +7 -0
- openhands_ai-0.8.3/openhands/runtime/plugins/agent_skills/file_reader/file_readers.py +244 -0
- openhands_ai-0.8.3/openhands/runtime/plugins/agent_skills/utils/aider/LICENSE.txt +202 -0
- openhands_ai-0.8.3/openhands/runtime/plugins/agent_skills/utils/aider/README.md +8 -0
- openhands_ai-0.8.3/openhands/runtime/plugins/agent_skills/utils/aider/__init__.py +6 -0
- openhands_ai-0.8.3/openhands/runtime/plugins/agent_skills/utils/aider/linter.py +223 -0
- openhands_ai-0.8.3/openhands/runtime/plugins/agent_skills/utils/config.py +30 -0
- openhands_ai-0.8.3/openhands/runtime/plugins/agent_skills/utils/dependency.py +11 -0
- openhands_ai-0.8.3/openhands/runtime/plugins/jupyter/__init__.py +76 -0
- openhands_ai-0.8.3/openhands/runtime/plugins/jupyter/execute_server.py +285 -0
- openhands_ai-0.8.3/openhands/runtime/plugins/requirement.py +31 -0
- openhands_ai-0.8.3/openhands/runtime/runtime.py +211 -0
- openhands_ai-0.8.3/openhands/runtime/utils/__init__.py +4 -0
- openhands_ai-0.8.3/openhands/runtime/utils/bash.py +52 -0
- openhands_ai-0.8.3/openhands/runtime/utils/files.py +145 -0
- openhands_ai-0.8.3/openhands/runtime/utils/runtime_build.py +442 -0
- openhands_ai-0.8.3/openhands/runtime/utils/runtime_templates/Dockerfile.j2 +68 -0
- openhands_ai-0.8.3/openhands/runtime/utils/singleton.py +0 -0
- openhands_ai-0.8.3/openhands/runtime/utils/system.py +14 -0
- openhands_ai-0.8.3/openhands/security/README.md +73 -0
- openhands_ai-0.8.3/openhands/security/__init__.py +7 -0
- openhands_ai-0.8.3/openhands/security/analyzer.py +60 -0
- openhands_ai-0.8.3/openhands/security/invariant/__init__.py +5 -0
- openhands_ai-0.8.3/openhands/security/invariant/analyzer.py +206 -0
- openhands_ai-0.8.3/openhands/security/invariant/client.py +137 -0
- openhands_ai-0.8.3/openhands/security/invariant/nodes.py +45 -0
- openhands_ai-0.8.3/openhands/security/invariant/parser.py +103 -0
- openhands_ai-0.8.3/openhands/security/invariant/policies.py +19 -0
- openhands_ai-0.8.3/openhands/security/options.py +5 -0
- openhands_ai-0.8.3/openhands/server/README.md +102 -0
- openhands_ai-0.8.3/openhands/server/__init__.py +0 -0
- openhands_ai-0.8.3/openhands/server/auth/__init__.py +3 -0
- openhands_ai-0.8.3/openhands/server/auth/auth.py +39 -0
- openhands_ai-0.8.3/openhands/server/data_models/feedback.py +42 -0
- openhands_ai-0.8.3/openhands/server/listen.py +736 -0
- openhands_ai-0.8.3/openhands/server/mock/README.md +10 -0
- openhands_ai-0.8.3/openhands/server/mock/listen.py +60 -0
- openhands_ai-0.8.3/openhands/server/session/__init__.py +4 -0
- openhands_ai-0.8.3/openhands/server/session/agent.py +138 -0
- openhands_ai-0.8.3/openhands/server/session/manager.py +70 -0
- openhands_ai-0.8.3/openhands/server/session/session.py +193 -0
- openhands_ai-0.8.3/openhands/storage/__init__.py +14 -0
- openhands_ai-0.8.3/openhands/storage/files.py +19 -0
- openhands_ai-0.8.3/openhands/storage/local.py +52 -0
- openhands_ai-0.8.3/openhands/storage/memory.py +48 -0
- openhands_ai-0.8.3/openhands/storage/s3.py +27 -0
- openhands_ai-0.8.3/openhands/utils/prompt.py +70 -0
- openhands_ai-0.8.3/poetry.lock +9230 -0
- openhands_ai-0.8.3/pyproject.toml +126 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
=====================
|
|
3
|
+
|
|
4
|
+
Copyright © 2023
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person
|
|
7
|
+
obtaining a copy of this software and associated documentation
|
|
8
|
+
files (the “Software”), to deal in the Software without
|
|
9
|
+
restriction, including without limitation the rights to use,
|
|
10
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the
|
|
12
|
+
Software is furnished to do so, subject to the following
|
|
13
|
+
conditions:
|
|
14
|
+
|
|
15
|
+
The above copyright notice and this permission notice shall be
|
|
16
|
+
included in all copies or substantial portions of the Software.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
|
19
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
20
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
21
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
22
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
23
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
24
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
25
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: openhands-ai
|
|
3
|
+
Version: 0.8.3
|
|
4
|
+
Summary: OpenHands: Code Less, Make More
|
|
5
|
+
Home-page: https://github.com/All-Hands-AI/OpenHands
|
|
6
|
+
License: MIT
|
|
7
|
+
Author: OpenHands
|
|
8
|
+
Requires-Python: >=3.11,<4.0
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Requires-Dist: bashlex (>=0.18,<0.19)
|
|
14
|
+
Requires-Dist: boto3
|
|
15
|
+
Requires-Dist: browsergym (==0.3.4)
|
|
16
|
+
Requires-Dist: datasets
|
|
17
|
+
Requires-Dist: dirhash
|
|
18
|
+
Requires-Dist: docker
|
|
19
|
+
Requires-Dist: e2b (>=0.17.1,<0.18.0)
|
|
20
|
+
Requires-Dist: fastapi
|
|
21
|
+
Requires-Dist: gevent (>=24.2.1,<25.0.0)
|
|
22
|
+
Requires-Dist: google-cloud-aiplatform
|
|
23
|
+
Requires-Dist: google-generativeai
|
|
24
|
+
Requires-Dist: grep-ast (==0.3.3)
|
|
25
|
+
Requires-Dist: html2text
|
|
26
|
+
Requires-Dist: jinja2 (>=3.1.3,<4.0.0)
|
|
27
|
+
Requires-Dist: json-repair
|
|
28
|
+
Requires-Dist: litellm
|
|
29
|
+
Requires-Dist: minio (>=7.2.8,<8.0.0)
|
|
30
|
+
Requires-Dist: numpy
|
|
31
|
+
Requires-Dist: pandas
|
|
32
|
+
Requires-Dist: pathspec (>=0.12.1,<0.13.0)
|
|
33
|
+
Requires-Dist: pexpect
|
|
34
|
+
Requires-Dist: pyarrow (==17.0.0)
|
|
35
|
+
Requires-Dist: pyjwt (>=2.9.0,<3.0.0)
|
|
36
|
+
Requires-Dist: python-multipart
|
|
37
|
+
Requires-Dist: seaborn
|
|
38
|
+
Requires-Dist: tenacity (>=8.5.0,<9.0.0)
|
|
39
|
+
Requires-Dist: termcolor
|
|
40
|
+
Requires-Dist: toml
|
|
41
|
+
Requires-Dist: tree-sitter (==0.21.3)
|
|
42
|
+
Requires-Dist: types-toml
|
|
43
|
+
Requires-Dist: uvicorn
|
|
44
|
+
Requires-Dist: zope-interface (==7.0.1)
|
|
45
|
+
Project-URL: Repository, https://github.com/All-Hands-AI/OpenHands
|
|
46
|
+
Description-Content-Type: text/markdown
|
|
47
|
+
|
|
48
|
+
<a name="readme-top"></a>
|
|
49
|
+
|
|
50
|
+
<!--
|
|
51
|
+
*** Thanks for checking out the Best-README-Template. If you have a suggestion
|
|
52
|
+
*** that would make this better, please fork the repo and create a pull request
|
|
53
|
+
*** or simply open an issue with the tag "enhancement".
|
|
54
|
+
*** Don't forget to give the project a star!
|
|
55
|
+
*** Thanks again! Now go create something AMAZING! :D
|
|
56
|
+
-->
|
|
57
|
+
|
|
58
|
+
<!-- PROJECT SHIELDS -->
|
|
59
|
+
<!--
|
|
60
|
+
*** I'm using markdown "reference style" links for readability.
|
|
61
|
+
*** Reference links are enclosed in brackets [ ] instead of parentheses ( ).
|
|
62
|
+
*** See the bottom of this document for the declaration of the reference variables
|
|
63
|
+
*** for contributors-url, forks-url, etc. This is an optional, concise syntax you may use.
|
|
64
|
+
*** https://www.markdownguide.org/basic-syntax/#reference-style-links
|
|
65
|
+
-->
|
|
66
|
+
|
|
67
|
+
<div align="center">
|
|
68
|
+
<a href="https://github.com/All-Hands-AI/OpenHands/graphs/contributors"><img src="https://img.shields.io/github/contributors/All-Hands-AI/OpenHands?style=for-the-badge&color=blue" alt="Contributors"></a>
|
|
69
|
+
<a href="https://github.com/All-Hands-AI/OpenHands/network/members"><img src="https://img.shields.io/github/forks/All-Hands-AI/OpenHands?style=for-the-badge&color=blue" alt="Forks"></a>
|
|
70
|
+
<a href="https://github.com/All-Hands-AI/OpenHands/stargazers"><img src="https://img.shields.io/github/stars/All-Hands-AI/OpenHands?style=for-the-badge&color=blue" alt="Stargazers"></a>
|
|
71
|
+
<a href="https://github.com/All-Hands-AI/OpenHands/issues"><img src="https://img.shields.io/github/issues/All-Hands-AI/OpenHands?style=for-the-badge&color=blue" alt="Issues"></a>
|
|
72
|
+
<a href="https://github.com/All-Hands-AI/OpenHands/blob/main/LICENSE"><img src="https://img.shields.io/github/license/All-Hands-AI/OpenHands?style=for-the-badge&color=blue" alt="MIT License"></a>
|
|
73
|
+
<a href="https://github.com/All-Hands-AI/OpenHands/blob/main/CREDITS.md"><img src="https://img.shields.io/badge/Project-Credits-blue?style=for-the-badge&color=blue" alt="Credits"></a>
|
|
74
|
+
<br/>
|
|
75
|
+
<a href="https://join.slack.com/t/openhands/shared_invite/zt-2ngejmfw6-9gW4APWOC9XUp1n~SiQ6iw"><img src="https://img.shields.io/badge/Slack-Join%20Us-red?logo=slack&logoColor=white&style=for-the-badge" alt="Join our Slack community"></a>
|
|
76
|
+
<a href="https://discord.gg/ESHStjSjD4"><img src="https://img.shields.io/badge/Discord-Join%20Us-purple?logo=discord&logoColor=white&style=for-the-badge" alt="Join our Discord community"></a>
|
|
77
|
+
<a href="https://codecov.io/github/All-Hands-AI/OpenHands?branch=main"><img alt="CodeCov" src="https://img.shields.io/codecov/c/github/All-Hands-AI/OpenHands?style=for-the-badge"></a>
|
|
78
|
+
</div>
|
|
79
|
+
|
|
80
|
+
<!-- PROJECT LOGO -->
|
|
81
|
+
<div align="center">
|
|
82
|
+
<img src="./docs/static/img/logo.png" alt="Logo" width="200" height="200">
|
|
83
|
+
<h1 align="center">OpenHands: Code Less, Make More</h1>
|
|
84
|
+
<a href="https://docs.all-hands.dev/modules/usage/intro"><img src="https://img.shields.io/badge/Documentation-OpenHands-blue?logo=googledocs&logoColor=white&style=for-the-badge" alt="Check out the documentation"></a>
|
|
85
|
+
<a href="https://arxiv.org/abs/2407.16741"><img src="https://img.shields.io/badge/Paper-%20on%20Arxiv-red?logo=arxiv&style=for-the-badge" alt="Paper on Arxiv"></a>
|
|
86
|
+
<br/>
|
|
87
|
+
<a href="https://huggingface.co/spaces/OpenHands/evaluation"><img src="https://img.shields.io/badge/Evaluation-Benchmark%20on%20HF%20Space-green?logo=huggingface&style=for-the-badge" alt="Evaluation Benchmark"></a>
|
|
88
|
+
</div>
|
|
89
|
+
<hr>
|
|
90
|
+
|
|
91
|
+
Welcome to OpenHands, a platform for autonomous software engineers, powered by AI and LLMs (previously called "OpenDevin").
|
|
92
|
+
|
|
93
|
+
OpenHands agents collaborate with human developers to write code, fix bugs, and ship features.
|
|
94
|
+
|
|
95
|
+

|
|
96
|
+
|
|
97
|
+
## ⚡ Getting Started
|
|
98
|
+
OpenHands works best with Docker version 26.0.0+ (Docker Desktop 4.31.0+).
|
|
99
|
+
You must be using Linux, Mac OS, or WSL on Windows.
|
|
100
|
+
|
|
101
|
+
To start OpenHands in a docker container, run the following commands in your terminal:
|
|
102
|
+
|
|
103
|
+
> [!WARNING]
|
|
104
|
+
> When you run the following command, files in `./workspace` may be modified or deleted.
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
WORKSPACE_BASE=$(pwd)/workspace
|
|
108
|
+
docker run -it \
|
|
109
|
+
--pull=always \
|
|
110
|
+
-e SANDBOX_USER_ID=$(id -u) \
|
|
111
|
+
-e WORKSPACE_MOUNT_PATH=$WORKSPACE_BASE \
|
|
112
|
+
-v $WORKSPACE_BASE:/opt/workspace_base \
|
|
113
|
+
-v /var/run/docker.sock:/var/run/docker.sock \
|
|
114
|
+
-p 3000:3000 \
|
|
115
|
+
--add-host host.docker.internal:host-gateway \
|
|
116
|
+
--name openhands-app-$(date +%Y%m%d%H%M%S) \
|
|
117
|
+
ghcr.io/opendevin/opendevin:0.8
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
> [!NOTE]
|
|
121
|
+
> By default, this command pulls the `latest` tag, which represents the most recent release of OpenHands. You have other options as well:
|
|
122
|
+
> - For a specific release version, use `ghcr.io/opendevin/opendevin:<OpenHands_version>` (replace <OpenHands_version> with the desired version number).
|
|
123
|
+
> - For the most up-to-date development version, use `ghcr.io/opendevin/opendevin:main`. This version may be **(unstable!)** and is recommended for testing or development purposes only.
|
|
124
|
+
>
|
|
125
|
+
> Choose the tag that best suits your needs based on stability requirements and desired features.
|
|
126
|
+
|
|
127
|
+
You'll find OpenHands running at [http://localhost:3000](http://localhost:3000) with access to `./workspace`. To have OpenHands operate on your code, place it in `./workspace`.
|
|
128
|
+
OpenHands will only have access to this workspace folder. The rest of your system will not be affected as it runs in a secured docker sandbox.
|
|
129
|
+
|
|
130
|
+
Upon opening OpenHands, you must select the appropriate `Model` and enter the `API Key` within the settings that should pop up automatically. These can be set at any time by selecting
|
|
131
|
+
the `Settings` button (gear icon) in the UI. If the required `Model` does not exist in the list, you can manually enter it in the text box.
|
|
132
|
+
|
|
133
|
+
For the development workflow, see [Development.md](https://github.com/All-Hands-AI/OpenHands/blob/main/Development.md).
|
|
134
|
+
|
|
135
|
+
Are you having trouble? Check out our [Troubleshooting Guide](https://docs.all-hands.dev/modules/usage/troubleshooting).
|
|
136
|
+
|
|
137
|
+
## 🚀 Documentation
|
|
138
|
+
|
|
139
|
+
To learn more about the project, and for tips on using OpenHands,
|
|
140
|
+
**check out our [documentation](https://docs.all-hands.dev/modules/usage/intro)**.
|
|
141
|
+
|
|
142
|
+
There you'll find resources on how to use different LLM providers (like ollama and Anthropic's Claude),
|
|
143
|
+
troubleshooting resources, and advanced configuration options.
|
|
144
|
+
|
|
145
|
+
## 🤝 How to Contribute
|
|
146
|
+
|
|
147
|
+
OpenHands is a community-driven project, and we welcome contributions from everyone.
|
|
148
|
+
Whether you're a developer, a researcher, or simply enthusiastic about advancing the field of
|
|
149
|
+
software engineering with AI, there are many ways to get involved:
|
|
150
|
+
|
|
151
|
+
- **Code Contributions:** Help us develop new agents, core functionality, the frontend and other interfaces, or sandboxing solutions.
|
|
152
|
+
- **Research and Evaluation:** Contribute to our understanding of LLMs in software engineering, participate in evaluating the models, or suggest improvements.
|
|
153
|
+
- **Feedback and Testing:** Use the OpenHands toolset, report bugs, suggest features, or provide feedback on usability.
|
|
154
|
+
|
|
155
|
+
For details, please check [CONTRIBUTING.md](./CONTRIBUTING.md).
|
|
156
|
+
|
|
157
|
+
## 🤖 Join Our Community
|
|
158
|
+
|
|
159
|
+
Whether you're a developer, a researcher, or simply enthusiastic about OpenHands, we'd love to have you in our community.
|
|
160
|
+
Let's make software engineering better together!
|
|
161
|
+
|
|
162
|
+
- [Slack workspace](https://join.slack.com/t/openhands/shared_invite/zt-2ngejmfw6-9gW4APWOC9XUp1n~SiQ6iw) - Here we talk about research, architecture, and future development.
|
|
163
|
+
- [Discord server](https://discord.gg/ESHStjSjD4) - This is a community-run server for general discussion, questions, and feedback.
|
|
164
|
+
|
|
165
|
+
## 📈 Progress
|
|
166
|
+
|
|
167
|
+
<p align="center">
|
|
168
|
+
<a href="https://star-history.com/#All-Hands-AI/OpenHands&Date">
|
|
169
|
+
<img src="https://api.star-history.com/svg?repos=All-Hands-AI/OpenHands&type=Date" width="500" alt="Star History Chart">
|
|
170
|
+
</a>
|
|
171
|
+
</p>
|
|
172
|
+
|
|
173
|
+
## 📜 License
|
|
174
|
+
|
|
175
|
+
Distributed under the MIT License. See [`LICENSE`](./LICENSE) for more information.
|
|
176
|
+
|
|
177
|
+
[contributors-shield]: https://img.shields.io/github/contributors/All-Hands-AI/OpenHands?style=for-the-badge
|
|
178
|
+
[contributors-url]: https://github.com/All-Hands-AI/OpenHands/graphs/contributors
|
|
179
|
+
[forks-shield]: https://img.shields.io/github/forks/All-Hands-AI/OpenHands?style=for-the-badge
|
|
180
|
+
[forks-url]: https://github.com/All-Hands-AI/OpenHands/network/members
|
|
181
|
+
[stars-shield]: https://img.shields.io/github/stars/All-Hands-AI/OpenHands?style=for-the-badge
|
|
182
|
+
[stars-url]: https://github.com/All-Hands-AI/OpenHands/stargazers
|
|
183
|
+
[issues-shield]: https://img.shields.io/github/issues/All-Hands-AI/OpenHands?style=for-the-badge
|
|
184
|
+
[issues-url]: https://github.com/All-Hands-AI/OpenHands/issues
|
|
185
|
+
[license-shield]: https://img.shields.io/github/license/All-Hands-AI/OpenHands?style=for-the-badge
|
|
186
|
+
[license-url]: https://github.com/All-Hands-AI/OpenHands/blob/main/LICENSE
|
|
187
|
+
|
|
188
|
+
## 🙏 Acknowledgements
|
|
189
|
+
|
|
190
|
+
OpenHands is built by a large number of contributors, and every contribution is greatly appreciated! We also build upon other open source projects, and we are deeply thankful for their work.
|
|
191
|
+
|
|
192
|
+
For a list of open source projects and licenses used in OpenHands, please see our [CREDITS.md](./CREDITS.md) file.
|
|
193
|
+
|
|
194
|
+
## 📚 Cite
|
|
195
|
+
|
|
196
|
+
```
|
|
197
|
+
@misc{opendevin,
|
|
198
|
+
title={{OpenDevin: An Open Platform for AI Software Developers as Generalist Agents}},
|
|
199
|
+
author={Xingyao Wang and Boxuan Li and Yufan Song and Frank F. Xu and Xiangru Tang and Mingchen Zhuge and Jiayi Pan and Yueqi Song and Bowen Li and Jaskirat Singh and Hoang H. Tran and Fuqiang Li and Ren Ma and Mingzhang Zheng and Bill Qian and Yanjun Shao and Niklas Muennighoff and Yizhe Zhang and Binyuan Hui and Junyang Lin and Robert Brennan and Hao Peng and Heng Ji and Graham Neubig},
|
|
200
|
+
year={2024},
|
|
201
|
+
eprint={2407.16741},
|
|
202
|
+
archivePrefix={arXiv},
|
|
203
|
+
primaryClass={cs.SE},
|
|
204
|
+
url={https://arxiv.org/abs/2407.16741},
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
<a name="readme-top"></a>
|
|
2
|
+
|
|
3
|
+
<!--
|
|
4
|
+
*** Thanks for checking out the Best-README-Template. If you have a suggestion
|
|
5
|
+
*** that would make this better, please fork the repo and create a pull request
|
|
6
|
+
*** or simply open an issue with the tag "enhancement".
|
|
7
|
+
*** Don't forget to give the project a star!
|
|
8
|
+
*** Thanks again! Now go create something AMAZING! :D
|
|
9
|
+
-->
|
|
10
|
+
|
|
11
|
+
<!-- PROJECT SHIELDS -->
|
|
12
|
+
<!--
|
|
13
|
+
*** I'm using markdown "reference style" links for readability.
|
|
14
|
+
*** Reference links are enclosed in brackets [ ] instead of parentheses ( ).
|
|
15
|
+
*** See the bottom of this document for the declaration of the reference variables
|
|
16
|
+
*** for contributors-url, forks-url, etc. This is an optional, concise syntax you may use.
|
|
17
|
+
*** https://www.markdownguide.org/basic-syntax/#reference-style-links
|
|
18
|
+
-->
|
|
19
|
+
|
|
20
|
+
<div align="center">
|
|
21
|
+
<a href="https://github.com/All-Hands-AI/OpenHands/graphs/contributors"><img src="https://img.shields.io/github/contributors/All-Hands-AI/OpenHands?style=for-the-badge&color=blue" alt="Contributors"></a>
|
|
22
|
+
<a href="https://github.com/All-Hands-AI/OpenHands/network/members"><img src="https://img.shields.io/github/forks/All-Hands-AI/OpenHands?style=for-the-badge&color=blue" alt="Forks"></a>
|
|
23
|
+
<a href="https://github.com/All-Hands-AI/OpenHands/stargazers"><img src="https://img.shields.io/github/stars/All-Hands-AI/OpenHands?style=for-the-badge&color=blue" alt="Stargazers"></a>
|
|
24
|
+
<a href="https://github.com/All-Hands-AI/OpenHands/issues"><img src="https://img.shields.io/github/issues/All-Hands-AI/OpenHands?style=for-the-badge&color=blue" alt="Issues"></a>
|
|
25
|
+
<a href="https://github.com/All-Hands-AI/OpenHands/blob/main/LICENSE"><img src="https://img.shields.io/github/license/All-Hands-AI/OpenHands?style=for-the-badge&color=blue" alt="MIT License"></a>
|
|
26
|
+
<a href="https://github.com/All-Hands-AI/OpenHands/blob/main/CREDITS.md"><img src="https://img.shields.io/badge/Project-Credits-blue?style=for-the-badge&color=blue" alt="Credits"></a>
|
|
27
|
+
<br/>
|
|
28
|
+
<a href="https://join.slack.com/t/openhands/shared_invite/zt-2ngejmfw6-9gW4APWOC9XUp1n~SiQ6iw"><img src="https://img.shields.io/badge/Slack-Join%20Us-red?logo=slack&logoColor=white&style=for-the-badge" alt="Join our Slack community"></a>
|
|
29
|
+
<a href="https://discord.gg/ESHStjSjD4"><img src="https://img.shields.io/badge/Discord-Join%20Us-purple?logo=discord&logoColor=white&style=for-the-badge" alt="Join our Discord community"></a>
|
|
30
|
+
<a href="https://codecov.io/github/All-Hands-AI/OpenHands?branch=main"><img alt="CodeCov" src="https://img.shields.io/codecov/c/github/All-Hands-AI/OpenHands?style=for-the-badge"></a>
|
|
31
|
+
</div>
|
|
32
|
+
|
|
33
|
+
<!-- PROJECT LOGO -->
|
|
34
|
+
<div align="center">
|
|
35
|
+
<img src="./docs/static/img/logo.png" alt="Logo" width="200" height="200">
|
|
36
|
+
<h1 align="center">OpenHands: Code Less, Make More</h1>
|
|
37
|
+
<a href="https://docs.all-hands.dev/modules/usage/intro"><img src="https://img.shields.io/badge/Documentation-OpenHands-blue?logo=googledocs&logoColor=white&style=for-the-badge" alt="Check out the documentation"></a>
|
|
38
|
+
<a href="https://arxiv.org/abs/2407.16741"><img src="https://img.shields.io/badge/Paper-%20on%20Arxiv-red?logo=arxiv&style=for-the-badge" alt="Paper on Arxiv"></a>
|
|
39
|
+
<br/>
|
|
40
|
+
<a href="https://huggingface.co/spaces/OpenHands/evaluation"><img src="https://img.shields.io/badge/Evaluation-Benchmark%20on%20HF%20Space-green?logo=huggingface&style=for-the-badge" alt="Evaluation Benchmark"></a>
|
|
41
|
+
</div>
|
|
42
|
+
<hr>
|
|
43
|
+
|
|
44
|
+
Welcome to OpenHands, a platform for autonomous software engineers, powered by AI and LLMs (previously called "OpenDevin").
|
|
45
|
+
|
|
46
|
+
OpenHands agents collaborate with human developers to write code, fix bugs, and ship features.
|
|
47
|
+
|
|
48
|
+

|
|
49
|
+
|
|
50
|
+
## ⚡ Getting Started
|
|
51
|
+
OpenHands works best with Docker version 26.0.0+ (Docker Desktop 4.31.0+).
|
|
52
|
+
You must be using Linux, Mac OS, or WSL on Windows.
|
|
53
|
+
|
|
54
|
+
To start OpenHands in a docker container, run the following commands in your terminal:
|
|
55
|
+
|
|
56
|
+
> [!WARNING]
|
|
57
|
+
> When you run the following command, files in `./workspace` may be modified or deleted.
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
WORKSPACE_BASE=$(pwd)/workspace
|
|
61
|
+
docker run -it \
|
|
62
|
+
--pull=always \
|
|
63
|
+
-e SANDBOX_USER_ID=$(id -u) \
|
|
64
|
+
-e WORKSPACE_MOUNT_PATH=$WORKSPACE_BASE \
|
|
65
|
+
-v $WORKSPACE_BASE:/opt/workspace_base \
|
|
66
|
+
-v /var/run/docker.sock:/var/run/docker.sock \
|
|
67
|
+
-p 3000:3000 \
|
|
68
|
+
--add-host host.docker.internal:host-gateway \
|
|
69
|
+
--name openhands-app-$(date +%Y%m%d%H%M%S) \
|
|
70
|
+
ghcr.io/opendevin/opendevin:0.8
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
> [!NOTE]
|
|
74
|
+
> By default, this command pulls the `latest` tag, which represents the most recent release of OpenHands. You have other options as well:
|
|
75
|
+
> - For a specific release version, use `ghcr.io/opendevin/opendevin:<OpenHands_version>` (replace <OpenHands_version> with the desired version number).
|
|
76
|
+
> - For the most up-to-date development version, use `ghcr.io/opendevin/opendevin:main`. This version may be **(unstable!)** and is recommended for testing or development purposes only.
|
|
77
|
+
>
|
|
78
|
+
> Choose the tag that best suits your needs based on stability requirements and desired features.
|
|
79
|
+
|
|
80
|
+
You'll find OpenHands running at [http://localhost:3000](http://localhost:3000) with access to `./workspace`. To have OpenHands operate on your code, place it in `./workspace`.
|
|
81
|
+
OpenHands will only have access to this workspace folder. The rest of your system will not be affected as it runs in a secured docker sandbox.
|
|
82
|
+
|
|
83
|
+
Upon opening OpenHands, you must select the appropriate `Model` and enter the `API Key` within the settings that should pop up automatically. These can be set at any time by selecting
|
|
84
|
+
the `Settings` button (gear icon) in the UI. If the required `Model` does not exist in the list, you can manually enter it in the text box.
|
|
85
|
+
|
|
86
|
+
For the development workflow, see [Development.md](https://github.com/All-Hands-AI/OpenHands/blob/main/Development.md).
|
|
87
|
+
|
|
88
|
+
Are you having trouble? Check out our [Troubleshooting Guide](https://docs.all-hands.dev/modules/usage/troubleshooting).
|
|
89
|
+
|
|
90
|
+
## 🚀 Documentation
|
|
91
|
+
|
|
92
|
+
To learn more about the project, and for tips on using OpenHands,
|
|
93
|
+
**check out our [documentation](https://docs.all-hands.dev/modules/usage/intro)**.
|
|
94
|
+
|
|
95
|
+
There you'll find resources on how to use different LLM providers (like ollama and Anthropic's Claude),
|
|
96
|
+
troubleshooting resources, and advanced configuration options.
|
|
97
|
+
|
|
98
|
+
## 🤝 How to Contribute
|
|
99
|
+
|
|
100
|
+
OpenHands is a community-driven project, and we welcome contributions from everyone.
|
|
101
|
+
Whether you're a developer, a researcher, or simply enthusiastic about advancing the field of
|
|
102
|
+
software engineering with AI, there are many ways to get involved:
|
|
103
|
+
|
|
104
|
+
- **Code Contributions:** Help us develop new agents, core functionality, the frontend and other interfaces, or sandboxing solutions.
|
|
105
|
+
- **Research and Evaluation:** Contribute to our understanding of LLMs in software engineering, participate in evaluating the models, or suggest improvements.
|
|
106
|
+
- **Feedback and Testing:** Use the OpenHands toolset, report bugs, suggest features, or provide feedback on usability.
|
|
107
|
+
|
|
108
|
+
For details, please check [CONTRIBUTING.md](./CONTRIBUTING.md).
|
|
109
|
+
|
|
110
|
+
## 🤖 Join Our Community
|
|
111
|
+
|
|
112
|
+
Whether you're a developer, a researcher, or simply enthusiastic about OpenHands, we'd love to have you in our community.
|
|
113
|
+
Let's make software engineering better together!
|
|
114
|
+
|
|
115
|
+
- [Slack workspace](https://join.slack.com/t/openhands/shared_invite/zt-2ngejmfw6-9gW4APWOC9XUp1n~SiQ6iw) - Here we talk about research, architecture, and future development.
|
|
116
|
+
- [Discord server](https://discord.gg/ESHStjSjD4) - This is a community-run server for general discussion, questions, and feedback.
|
|
117
|
+
|
|
118
|
+
## 📈 Progress
|
|
119
|
+
|
|
120
|
+
<p align="center">
|
|
121
|
+
<a href="https://star-history.com/#All-Hands-AI/OpenHands&Date">
|
|
122
|
+
<img src="https://api.star-history.com/svg?repos=All-Hands-AI/OpenHands&type=Date" width="500" alt="Star History Chart">
|
|
123
|
+
</a>
|
|
124
|
+
</p>
|
|
125
|
+
|
|
126
|
+
## 📜 License
|
|
127
|
+
|
|
128
|
+
Distributed under the MIT License. See [`LICENSE`](./LICENSE) for more information.
|
|
129
|
+
|
|
130
|
+
[contributors-shield]: https://img.shields.io/github/contributors/All-Hands-AI/OpenHands?style=for-the-badge
|
|
131
|
+
[contributors-url]: https://github.com/All-Hands-AI/OpenHands/graphs/contributors
|
|
132
|
+
[forks-shield]: https://img.shields.io/github/forks/All-Hands-AI/OpenHands?style=for-the-badge
|
|
133
|
+
[forks-url]: https://github.com/All-Hands-AI/OpenHands/network/members
|
|
134
|
+
[stars-shield]: https://img.shields.io/github/stars/All-Hands-AI/OpenHands?style=for-the-badge
|
|
135
|
+
[stars-url]: https://github.com/All-Hands-AI/OpenHands/stargazers
|
|
136
|
+
[issues-shield]: https://img.shields.io/github/issues/All-Hands-AI/OpenHands?style=for-the-badge
|
|
137
|
+
[issues-url]: https://github.com/All-Hands-AI/OpenHands/issues
|
|
138
|
+
[license-shield]: https://img.shields.io/github/license/All-Hands-AI/OpenHands?style=for-the-badge
|
|
139
|
+
[license-url]: https://github.com/All-Hands-AI/OpenHands/blob/main/LICENSE
|
|
140
|
+
|
|
141
|
+
## 🙏 Acknowledgements
|
|
142
|
+
|
|
143
|
+
OpenHands is built by a large number of contributors, and every contribution is greatly appreciated! We also build upon other open source projects, and we are deeply thankful for their work.
|
|
144
|
+
|
|
145
|
+
For a list of open source projects and licenses used in OpenHands, please see our [CREDITS.md](./CREDITS.md) file.
|
|
146
|
+
|
|
147
|
+
## 📚 Cite
|
|
148
|
+
|
|
149
|
+
```
|
|
150
|
+
@misc{opendevin,
|
|
151
|
+
title={{OpenDevin: An Open Platform for AI Software Developers as Generalist Agents}},
|
|
152
|
+
author={Xingyao Wang and Boxuan Li and Yufan Song and Frank F. Xu and Xiangru Tang and Mingchen Zhuge and Jiayi Pan and Yueqi Song and Bowen Li and Jaskirat Singh and Hoang H. Tran and Fuqiang Li and Ren Ma and Mingzhang Zheng and Bill Qian and Yanjun Shao and Niklas Muennighoff and Yizhe Zhang and Binyuan Hui and Junyang Lin and Robert Brennan and Hao Peng and Heng Ji and Graham Neubig},
|
|
153
|
+
year={2024},
|
|
154
|
+
eprint={2407.16741},
|
|
155
|
+
archivePrefix={arXiv},
|
|
156
|
+
primaryClass={cs.SE},
|
|
157
|
+
url={https://arxiv.org/abs/2407.16741},
|
|
158
|
+
}
|
|
159
|
+
```
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# OpenHands Architecture
|
|
2
|
+
|
|
3
|
+
This directory contains the core components of OpenHands.
|
|
4
|
+
|
|
5
|
+
This diagram provides an overview of the roles of each component and how they communicate and collaborate.
|
|
6
|
+

|
|
7
|
+
|
|
8
|
+
## Classes
|
|
9
|
+
The key classes in OpenHands are:
|
|
10
|
+
|
|
11
|
+
* LLM: brokers all interactions with large language models. Works with any underlying completion model, thanks to LiteLLM.
|
|
12
|
+
* Agent: responsible for looking at the current State, and producing an Action that moves one step closer toward the end-goal.
|
|
13
|
+
* AgentController: initializes the Agent, manages State, and drive the main loop that pushes the Agent forward, step by step
|
|
14
|
+
* State: represents the current state of the Agent's task. Includes things like the current step, a history of recent events, the Agent's long-term plan, etc
|
|
15
|
+
* EventStream: a central hub for Events, where any component can publish Events, or listen for Events published by other components
|
|
16
|
+
* Event: an Action or Observeration
|
|
17
|
+
* Action: represents a request to e.g. edit a file, run a command, or send a message
|
|
18
|
+
* Observation: represents information collected from the environment, e.g. file contents or command output
|
|
19
|
+
* Runtime: responsible for performing Actions, and sending back Observations
|
|
20
|
+
* Sandbox: the part of the runtime responsible for running commands, e.g. inside of Docker
|
|
21
|
+
* Server: brokers OpenHands sessions over HTTP, e.g. to drive the frontend
|
|
22
|
+
* Session: holds a single EventStream, a single AgentController, and a single Runtime. Generally represents a single task (but potentially including several user prompts)
|
|
23
|
+
* SessionManager: keeps a list of active sessions, and ensures requests are routed to the correct Session
|
|
24
|
+
|
|
25
|
+
## Control Flow
|
|
26
|
+
Here's the basic loop (in pseudocode) that drives agents.
|
|
27
|
+
```python
|
|
28
|
+
while True:
|
|
29
|
+
prompt = agent.generate_prompt(state)
|
|
30
|
+
response = llm.completion(prompt)
|
|
31
|
+
action = agent.parse_response(response)
|
|
32
|
+
observation = runtime.run(action)
|
|
33
|
+
state = state.update(action, observation)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
In reality, most of this is achieved through message passing, via the EventStream.
|
|
37
|
+
The EventStream serves as the backbone for all communication in OpenHands.
|
|
38
|
+
|
|
39
|
+
```mermaid
|
|
40
|
+
flowchart LR
|
|
41
|
+
Agent--Actions-->AgentController
|
|
42
|
+
AgentController--State-->Agent
|
|
43
|
+
AgentController--Actions-->EventStream
|
|
44
|
+
EventStream--Observations-->AgentController
|
|
45
|
+
Runtime--Observations-->EventStream
|
|
46
|
+
EventStream--Actions-->Runtime
|
|
47
|
+
Frontend--Actions-->EventStream
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Runtime
|
|
51
|
+
|
|
52
|
+
Please refer to the [documentation](https://docs.all-hands.dev/modules/usage/runtime) to learn more about `Runtime`.
|
|
File without changes
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
|
|
3
|
+
from openhands.events.action import Action
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ResponseParser(ABC):
|
|
7
|
+
"""This abstract base class is a general interface for an response parser dedicated to
|
|
8
|
+
parsing the action from the response from the LLM.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
def __init__(
|
|
12
|
+
self,
|
|
13
|
+
):
|
|
14
|
+
# Need pay attention to the item order in self.action_parsers
|
|
15
|
+
self.action_parsers = []
|
|
16
|
+
|
|
17
|
+
@abstractmethod
|
|
18
|
+
def parse(self, response: str) -> Action:
|
|
19
|
+
"""Parses the action from the response from the LLM.
|
|
20
|
+
|
|
21
|
+
Parameters:
|
|
22
|
+
- response (str): The response from the LLM.
|
|
23
|
+
|
|
24
|
+
Returns:
|
|
25
|
+
- action (Action): The action parsed from the response.
|
|
26
|
+
"""
|
|
27
|
+
pass
|
|
28
|
+
|
|
29
|
+
@abstractmethod
|
|
30
|
+
def parse_response(self, response) -> str:
|
|
31
|
+
"""Parses the action from the response from the LLM.
|
|
32
|
+
|
|
33
|
+
Parameters:
|
|
34
|
+
- response (str): The response from the LLM.
|
|
35
|
+
|
|
36
|
+
Returns:
|
|
37
|
+
- action_str (str): The action str parsed from the response.
|
|
38
|
+
"""
|
|
39
|
+
pass
|
|
40
|
+
|
|
41
|
+
@abstractmethod
|
|
42
|
+
def parse_action(self, action_str: str) -> Action:
|
|
43
|
+
"""Parses the action from the response from the LLM.
|
|
44
|
+
|
|
45
|
+
Parameters:
|
|
46
|
+
- action_str (str): The response from the LLM.
|
|
47
|
+
|
|
48
|
+
Returns:
|
|
49
|
+
- action (Action): The action parsed from the response.
|
|
50
|
+
"""
|
|
51
|
+
pass
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class ActionParser(ABC):
|
|
55
|
+
"""This abstract base class is a general interface for an action parser dedicated to
|
|
56
|
+
parsing the action from the action str from the LLM.
|
|
57
|
+
"""
|
|
58
|
+
|
|
59
|
+
@abstractmethod
|
|
60
|
+
def check_condition(self, action_str: str) -> bool:
|
|
61
|
+
"""Check if the action string can be parsed by this parser."""
|
|
62
|
+
pass
|
|
63
|
+
|
|
64
|
+
@abstractmethod
|
|
65
|
+
def parse(self, action_str: str) -> Action:
|
|
66
|
+
"""Parses the action from the action string from the LLM response."""
|
|
67
|
+
pass
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
from typing import TYPE_CHECKING, Type
|
|
3
|
+
|
|
4
|
+
if TYPE_CHECKING:
|
|
5
|
+
from openhands.controller.state.state import State
|
|
6
|
+
from openhands.core.config import AgentConfig
|
|
7
|
+
from openhands.events.action import Action
|
|
8
|
+
from openhands.core.exceptions import (
|
|
9
|
+
AgentAlreadyRegisteredError,
|
|
10
|
+
AgentNotRegisteredError,
|
|
11
|
+
)
|
|
12
|
+
from openhands.llm.llm import LLM
|
|
13
|
+
from openhands.runtime.plugins import PluginRequirement
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class Agent(ABC):
|
|
17
|
+
DEPRECATED = False
|
|
18
|
+
"""
|
|
19
|
+
This abstract base class is an general interface for an agent dedicated to
|
|
20
|
+
executing a specific instruction and allowing human interaction with the
|
|
21
|
+
agent during execution.
|
|
22
|
+
It tracks the execution status and maintains a history of interactions.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
_registry: dict[str, Type['Agent']] = {}
|
|
26
|
+
sandbox_plugins: list[PluginRequirement] = []
|
|
27
|
+
|
|
28
|
+
def __init__(
|
|
29
|
+
self,
|
|
30
|
+
llm: LLM,
|
|
31
|
+
config: 'AgentConfig',
|
|
32
|
+
):
|
|
33
|
+
self.llm = llm
|
|
34
|
+
self.config = config
|
|
35
|
+
self._complete = False
|
|
36
|
+
|
|
37
|
+
@property
|
|
38
|
+
def complete(self) -> bool:
|
|
39
|
+
"""Indicates whether the current instruction execution is complete.
|
|
40
|
+
|
|
41
|
+
Returns:
|
|
42
|
+
- complete (bool): True if execution is complete; False otherwise.
|
|
43
|
+
"""
|
|
44
|
+
return self._complete
|
|
45
|
+
|
|
46
|
+
@abstractmethod
|
|
47
|
+
def step(self, state: 'State') -> 'Action':
|
|
48
|
+
"""Starts the execution of the assigned instruction. This method should
|
|
49
|
+
be implemented by subclasses to define the specific execution logic.
|
|
50
|
+
"""
|
|
51
|
+
pass
|
|
52
|
+
|
|
53
|
+
def reset(self) -> None:
|
|
54
|
+
"""Resets the agent's execution status and clears the history. This method can be used
|
|
55
|
+
to prepare the agent for restarting the instruction or cleaning up before destruction.
|
|
56
|
+
|
|
57
|
+
"""
|
|
58
|
+
# TODO clear history
|
|
59
|
+
self._complete = False
|
|
60
|
+
|
|
61
|
+
if self.llm:
|
|
62
|
+
self.llm.reset()
|
|
63
|
+
|
|
64
|
+
@property
|
|
65
|
+
def name(self):
|
|
66
|
+
return self.__class__.__name__
|
|
67
|
+
|
|
68
|
+
@classmethod
|
|
69
|
+
def register(cls, name: str, agent_cls: Type['Agent']):
|
|
70
|
+
"""Registers an agent class in the registry.
|
|
71
|
+
|
|
72
|
+
Parameters:
|
|
73
|
+
- name (str): The name to register the class under.
|
|
74
|
+
- agent_cls (Type['Agent']): The class to register.
|
|
75
|
+
|
|
76
|
+
Raises:
|
|
77
|
+
- AgentAlreadyRegisteredError: If name already registered
|
|
78
|
+
"""
|
|
79
|
+
if name in cls._registry:
|
|
80
|
+
raise AgentAlreadyRegisteredError(name)
|
|
81
|
+
cls._registry[name] = agent_cls
|
|
82
|
+
|
|
83
|
+
@classmethod
|
|
84
|
+
def get_cls(cls, name: str) -> Type['Agent']:
|
|
85
|
+
"""Retrieves an agent class from the registry.
|
|
86
|
+
|
|
87
|
+
Parameters:
|
|
88
|
+
- name (str): The name of the class to retrieve
|
|
89
|
+
|
|
90
|
+
Returns:
|
|
91
|
+
- agent_cls (Type['Agent']): The class registered under the specified name.
|
|
92
|
+
|
|
93
|
+
Raises:
|
|
94
|
+
- AgentNotRegisteredError: If name not registered
|
|
95
|
+
"""
|
|
96
|
+
if name not in cls._registry:
|
|
97
|
+
raise AgentNotRegisteredError(name)
|
|
98
|
+
return cls._registry[name]
|
|
99
|
+
|
|
100
|
+
@classmethod
|
|
101
|
+
def list_agents(cls) -> list[str]:
|
|
102
|
+
"""Retrieves the list of all agent names from the registry.
|
|
103
|
+
|
|
104
|
+
Raises:
|
|
105
|
+
- AgentNotRegisteredError: If no agent is registered
|
|
106
|
+
"""
|
|
107
|
+
if not bool(cls._registry):
|
|
108
|
+
raise AgentNotRegisteredError()
|
|
109
|
+
return list(cls._registry.keys())
|