droidrun 0.1.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.
- droidrun/__init__.py +19 -0
- droidrun/__main__.py +8 -0
- droidrun/adb/__init__.py +13 -0
- droidrun/adb/device.py +315 -0
- droidrun/adb/manager.py +93 -0
- droidrun/adb/wrapper.py +226 -0
- droidrun/agent/__init__.py +16 -0
- droidrun/agent/llm_reasoning.py +567 -0
- droidrun/agent/react_agent.py +556 -0
- droidrun/cli/__init__.py +9 -0
- droidrun/cli/main.py +265 -0
- droidrun/llm/__init__.py +24 -0
- droidrun/tools/__init__.py +35 -0
- droidrun/tools/actions.py +854 -0
- droidrun/tools/device.py +29 -0
- droidrun-0.1.0.dist-info/METADATA +276 -0
- droidrun-0.1.0.dist-info/RECORD +20 -0
- droidrun-0.1.0.dist-info/WHEEL +4 -0
- droidrun-0.1.0.dist-info/entry_points.txt +2 -0
- droidrun-0.1.0.dist-info/licenses/LICENSE +21 -0
droidrun/tools/device.py
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
"""
|
2
|
+
Device Manager - Handles Android device connections and management.
|
3
|
+
"""
|
4
|
+
|
5
|
+
from typing import Optional, List
|
6
|
+
from droidrun.adb import Device, DeviceManager as ADBDeviceManager
|
7
|
+
|
8
|
+
class DeviceManager:
|
9
|
+
"""Manages Android device connections and operations."""
|
10
|
+
|
11
|
+
def __init__(self):
|
12
|
+
"""Initialize the device manager."""
|
13
|
+
self._manager = ADBDeviceManager()
|
14
|
+
|
15
|
+
async def connect(self, ip_address: str, port: int = 5555) -> Optional[Device]:
|
16
|
+
"""Connect to an Android device over TCP/IP."""
|
17
|
+
return await self._manager.connect(ip_address, port)
|
18
|
+
|
19
|
+
async def disconnect(self, serial: str) -> bool:
|
20
|
+
"""Disconnect from an Android device."""
|
21
|
+
return await self._manager.disconnect(serial)
|
22
|
+
|
23
|
+
async def list_devices(self) -> List[Device]:
|
24
|
+
"""List all connected devices."""
|
25
|
+
return await self._manager.list_devices()
|
26
|
+
|
27
|
+
async def get_device(self, serial: str) -> Optional[Device]:
|
28
|
+
"""Get a specific device by serial number."""
|
29
|
+
return await self._manager.get_device(serial)
|
@@ -0,0 +1,276 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: droidrun
|
3
|
+
Version: 0.1.0
|
4
|
+
Summary: A framework for controlling Android devices through LLM agents
|
5
|
+
Project-URL: Homepage, https://github.com/droidrun/droidrun
|
6
|
+
Project-URL: Bug Tracker, https://github.com/droidrun/droidrun/issues
|
7
|
+
Project-URL: Documentation, https://docs.droidrun.ai/
|
8
|
+
Author-email: Niels Schmidt <niels.schmidt@droidrun.ai>
|
9
|
+
License: MIT
|
10
|
+
License-File: LICENSE
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
12
|
+
Classifier: Intended Audience :: Developers
|
13
|
+
Classifier: Intended Audience :: Information Technology
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
19
|
+
Classifier: Topic :: Communications :: Chat
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
23
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
24
|
+
Classifier: Topic :: Software Development :: Testing
|
25
|
+
Classifier: Topic :: Software Development :: Testing :: Acceptance
|
26
|
+
Classifier: Topic :: System :: Emulators
|
27
|
+
Classifier: Topic :: Utilities
|
28
|
+
Requires-Python: >=3.10
|
29
|
+
Requires-Dist: aiofiles>=23.0.0
|
30
|
+
Requires-Dist: anthropic>=0.7.0
|
31
|
+
Requires-Dist: click>=8.1.0
|
32
|
+
Requires-Dist: openai>=1.0.0
|
33
|
+
Requires-Dist: pillow>=10.0.0
|
34
|
+
Requires-Dist: pydantic>=2.0.0
|
35
|
+
Requires-Dist: python-dotenv>=1.0.0
|
36
|
+
Requires-Dist: rich>=13.0.0
|
37
|
+
Provides-Extra: dev
|
38
|
+
Requires-Dist: black>=23.0.0; extra == 'dev'
|
39
|
+
Requires-Dist: mypy>=1.0.0; extra == 'dev'
|
40
|
+
Requires-Dist: ruff>=0.1.0; extra == 'dev'
|
41
|
+
Description-Content-Type: text/markdown
|
42
|
+
|
43
|
+
# 🤖 DroidRun
|
44
|
+
|
45
|
+
DroidRun is a powerful framework for controlling Android devices through LLM agents. It allows you to automate Android device interactions using natural language commands.
|
46
|
+
|
47
|
+
## ✨ Features
|
48
|
+
|
49
|
+
- Control Android devices with natural language commands
|
50
|
+
- Supports multiple LLM providers (OpenAI, Anthropic, Gemini)
|
51
|
+
- Easy to use CLI
|
52
|
+
- Extendable Python API for custom automations
|
53
|
+
- Screenshot analysis for visual understanding of the device
|
54
|
+
|
55
|
+
## 📦 Installation
|
56
|
+
|
57
|
+
### 🚀 Option 1: Install from PyPI (Recommended)
|
58
|
+
|
59
|
+
```bash
|
60
|
+
pip install droidrun
|
61
|
+
```
|
62
|
+
|
63
|
+
### 🔧 Option 2: Install from Source
|
64
|
+
|
65
|
+
```bash
|
66
|
+
git clone https://github.com/yourusername/droidrun.git
|
67
|
+
cd droidrun
|
68
|
+
pip install -e .
|
69
|
+
```
|
70
|
+
|
71
|
+
## 📋 Prerequisites
|
72
|
+
|
73
|
+
1. An Android device connected via USB or ADB over TCP/IP
|
74
|
+
2. ADB (Android Debug Bridge) installed and configured
|
75
|
+
3. DroidRun Portal app installed on your Android device
|
76
|
+
4. API key for at least one of the supported LLM providers:
|
77
|
+
- OpenAI
|
78
|
+
- Anthropic
|
79
|
+
- Google Gemini
|
80
|
+
|
81
|
+
### 🔧 Setting up ADB
|
82
|
+
|
83
|
+
ADB (Android Debug Bridge) is required for DroidRun to communicate with your Android device:
|
84
|
+
|
85
|
+
1. **Install ADB**:
|
86
|
+
- **Windows**: Download [Android SDK Platform Tools](https://developer.android.com/studio/releases/platform-tools) and extract the ZIP file
|
87
|
+
- **macOS**: `brew install android-platform-tools`
|
88
|
+
- **Linux**: `sudo apt install adb` (Ubuntu/Debian) or `sudo pacman -S android-tools` (Arch)
|
89
|
+
|
90
|
+
2. **Add ADB to your PATH**:
|
91
|
+
- **Windows**: Add the path to the extracted platform-tools folder to your system's PATH environment variable
|
92
|
+
- **macOS/Linux**: Add the following to your ~/.bashrc or ~/.zshrc:
|
93
|
+
```bash
|
94
|
+
export PATH=$PATH:/path/to/platform-tools
|
95
|
+
```
|
96
|
+
|
97
|
+
3. **Verify ADB installation**:
|
98
|
+
```bash
|
99
|
+
adb version
|
100
|
+
```
|
101
|
+
|
102
|
+
4. **Enable USB debugging on your Android device**:
|
103
|
+
- Go to **Settings → About phone**
|
104
|
+
- Tap **Build number** 7 times to enable Developer options
|
105
|
+
- Go to **Settings → System → Developer options** (location may vary by device)
|
106
|
+
- Enable **USB debugging**
|
107
|
+
|
108
|
+
## 🛠️ Setup
|
109
|
+
|
110
|
+
### 📱 1. Install DroidRun Portal App
|
111
|
+
|
112
|
+
DroidRun requires the DroidRun Portal app to be installed on your Android device:
|
113
|
+
|
114
|
+
1. Download the DroidRun Portal APK from the [DroidRun Portal repository](https://github.com/droidrun/droidrun-portal)
|
115
|
+
2. Use DroidRun to install the portal app:
|
116
|
+
```bash
|
117
|
+
droidrun setup --path=/path/to/droidrun-portal.apk
|
118
|
+
```
|
119
|
+
|
120
|
+
Alternatively, you can use ADB to install it manually:
|
121
|
+
```bash
|
122
|
+
adb install -r /path/to/droidrun-portal.apk
|
123
|
+
```
|
124
|
+
|
125
|
+
### 🔑 2. Set up API keys
|
126
|
+
|
127
|
+
Create a `.env` file in your working directory or set environment variables:
|
128
|
+
|
129
|
+
```bash
|
130
|
+
# Choose at least one of these based on your preferred provider
|
131
|
+
export OPENAI_API_KEY="your_openai_api_key_here"
|
132
|
+
export ANTHROPIC_API_KEY="your_anthropic_api_key_here"
|
133
|
+
export GEMINI_API_KEY="your_gemini_api_key_here"
|
134
|
+
```
|
135
|
+
|
136
|
+
To load the environment variables from the `.env` file:
|
137
|
+
|
138
|
+
```bash
|
139
|
+
source .env
|
140
|
+
```
|
141
|
+
|
142
|
+
### 📱 3. Connect to an Android device
|
143
|
+
|
144
|
+
Connect your device via USB or set up wireless ADB:
|
145
|
+
|
146
|
+
```bash
|
147
|
+
# List connected devices
|
148
|
+
droidrun devices
|
149
|
+
|
150
|
+
# Connect to a device over Wi-Fi
|
151
|
+
droidrun connect 192.168.1.100
|
152
|
+
```
|
153
|
+
|
154
|
+
### 🔄 4. Verify the setup
|
155
|
+
|
156
|
+
Verify that everything is set up correctly:
|
157
|
+
|
158
|
+
```bash
|
159
|
+
# Should list your connected device and show portal status
|
160
|
+
droidrun status
|
161
|
+
```
|
162
|
+
|
163
|
+
## 💻 Using the CLI
|
164
|
+
|
165
|
+
DroidRun's CLI is designed to be simple and intuitive. You can use it in two ways:
|
166
|
+
|
167
|
+
### 🚀 Basic Usage
|
168
|
+
|
169
|
+
```bash
|
170
|
+
# Format: droidrun "task description" [options]
|
171
|
+
droidrun "Open the settings app"
|
172
|
+
```
|
173
|
+
|
174
|
+
### 🔌 With Provider Options
|
175
|
+
|
176
|
+
```bash
|
177
|
+
# Using OpenAI
|
178
|
+
droidrun "Open the calculator app" --provider openai --model gpt-4o-mini
|
179
|
+
|
180
|
+
# Using Anthropic
|
181
|
+
droidrun "Check the battery level" --provider anthropic --model claude-3-sonnet-20240229
|
182
|
+
|
183
|
+
# Using Gemini
|
184
|
+
droidrun "Install and open Instagram" --provider gemini --model gemini-2.0-flash
|
185
|
+
```
|
186
|
+
|
187
|
+
### ⚙️ Additional Options
|
188
|
+
|
189
|
+
```bash
|
190
|
+
# Specify a particular device
|
191
|
+
droidrun "Open Chrome and search for weather" --device abc123
|
192
|
+
|
193
|
+
# Set maximum number of steps
|
194
|
+
droidrun "Open settings and enable dark mode" --steps 20
|
195
|
+
```
|
196
|
+
|
197
|
+
## 📝 Creating a Minimal Test Script
|
198
|
+
|
199
|
+
If you want to use DroidRun in your Python code rather than via the CLI, you can create a minimal test script:
|
200
|
+
|
201
|
+
```python
|
202
|
+
#!/usr/bin/env python3
|
203
|
+
import asyncio
|
204
|
+
import os
|
205
|
+
from droidrun.agent.react_agent import ReActAgent
|
206
|
+
from droidrun.agent.llm_reasoning import LLMReasoner
|
207
|
+
from dotenv import load_dotenv
|
208
|
+
|
209
|
+
# Load environment variables from .env file
|
210
|
+
load_dotenv()
|
211
|
+
|
212
|
+
async def main():
|
213
|
+
# Create an LLM instance (choose your preferred provider)
|
214
|
+
llm = LLMReasoner(
|
215
|
+
llm_provider="gemini", # Can be "openai", "anthropic", or "gemini"
|
216
|
+
model_name="gemini-2.0-flash", # Choose appropriate model for your provider
|
217
|
+
api_key=os.environ.get("GEMINI_API_KEY"), # Get API key from environment
|
218
|
+
temperature=0.2
|
219
|
+
)
|
220
|
+
|
221
|
+
# Create and run the agent
|
222
|
+
agent = ReActAgent(
|
223
|
+
task="Open the Settings app and check the Android version",
|
224
|
+
llm=llm
|
225
|
+
)
|
226
|
+
|
227
|
+
steps = await agent.run()
|
228
|
+
print(f"Execution completed with {len(steps)} steps")
|
229
|
+
|
230
|
+
if __name__ == "__main__":
|
231
|
+
asyncio.run(main())
|
232
|
+
```
|
233
|
+
|
234
|
+
Save this as `test_droidrun.py`, ensure your `.env` file has the appropriate API key, and run:
|
235
|
+
|
236
|
+
```bash
|
237
|
+
python test_droidrun.py
|
238
|
+
```
|
239
|
+
|
240
|
+
## ❓ Troubleshooting
|
241
|
+
|
242
|
+
### 🔑 API Key Issues
|
243
|
+
|
244
|
+
If you encounter errors about missing API keys, ensure:
|
245
|
+
1. You've set the correct environment variable for your chosen provider
|
246
|
+
2. The API key is valid and has appropriate permissions
|
247
|
+
3. You've correctly sourced your `.env` file or exported the variables manually
|
248
|
+
|
249
|
+
### 📱 Device Connection Issues
|
250
|
+
|
251
|
+
If you have trouble connecting to your device:
|
252
|
+
1. Ensure USB debugging is enabled on your Android device
|
253
|
+
2. Check that your device is recognized by ADB: `adb devices`
|
254
|
+
3. For wireless connections, make sure your device and computer are on the same network
|
255
|
+
|
256
|
+
### 🤖 LLM Provider Selection
|
257
|
+
|
258
|
+
If DroidRun is using the wrong LLM provider:
|
259
|
+
1. Explicitly specify the provider with `--provider` (in CLI) or `llm_provider=` (in code)
|
260
|
+
2. When using Gemini, ensure you have set `GEMINI_API_KEY` and specified `--provider gemini`
|
261
|
+
|
262
|
+
## 💡 Example Use Cases
|
263
|
+
|
264
|
+
- Automated UI testing of Android applications
|
265
|
+
- Creating guided workflows for non-technical users
|
266
|
+
- Automating repetitive tasks on Android devices
|
267
|
+
- Remote assistance for less technical users
|
268
|
+
- Exploring Android UI with natural language commands
|
269
|
+
|
270
|
+
## 👥 Contributing
|
271
|
+
|
272
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
273
|
+
|
274
|
+
## 📄 License
|
275
|
+
|
276
|
+
This project is licensed under the MIT License - see the LICENSE file for details.
|
@@ -0,0 +1,20 @@
|
|
1
|
+
droidrun/__init__.py,sha256=DPbx6xuxtowuPuPnfWH-XnksAWxxvG4b4cPbqxtlhB8,472
|
2
|
+
droidrun/__main__.py,sha256=BOXhRBIDmfRJ4LKm3fw4ZNAT6L_IGP0EC4uU-WI_QVU,107
|
3
|
+
droidrun/adb/__init__.py,sha256=tBhoSFmkevb_xQcCfdrigPut9zAU1J4bagpT-TgBj8c,221
|
4
|
+
droidrun/adb/device.py,sha256=4dvK2oN-lyaXElBvqVHCeCX2ZLRZl3o4y6z2vy05enk,10991
|
5
|
+
droidrun/adb/manager.py,sha256=9xohDCbw8XvWW2Esglpcnk9H24hKJG3e9SkCBiFWlDI,2704
|
6
|
+
droidrun/adb/wrapper.py,sha256=Yz3_JSIidq-5bf-t0UfawTutMaLrINS_1Y15m_Uss4g,7093
|
7
|
+
droidrun/agent/__init__.py,sha256=BWfZFZPBJeWMCaZEv7A_EDnEa2ibWDcqWnl_Z8NxNMA,346
|
8
|
+
droidrun/agent/llm_reasoning.py,sha256=POCszMmr-bn2aKG8Cduk4BIZCO38ZytIDLyLMP2cXwk,24383
|
9
|
+
droidrun/agent/react_agent.py,sha256=Nx3Qc4E8h_IHn5fwNQblmslEMaJD6nciehjcQ2dmVnQ,20857
|
10
|
+
droidrun/cli/__init__.py,sha256=ra9bKoHTIkgRsVFRlWztROPPRswMv_A-wc2b2e0plmo,155
|
11
|
+
droidrun/cli/main.py,sha256=phd8UEKOYdS8OYcX1d6iLwd-afez1ueatjLBAvbOS8U,10920
|
12
|
+
droidrun/llm/__init__.py,sha256=5v6Bw0904ihmyvFPgDwd8hROUVjWz3Re5JDOQfziIMY,687
|
13
|
+
droidrun/tools/__init__.py,sha256=vKcI1qP8yzdq3mNQ53EFgBJILikQz3GDPZJyoxnDOa0,569
|
14
|
+
droidrun/tools/actions.py,sha256=GC4hVXw-OjENphDahGEHKKbRAIONxPtMBFZEUAmS4ms,32963
|
15
|
+
droidrun/tools/device.py,sha256=5y2FAfhJIRksb40HGo6ENe9krozz0MwFykaoclLZw5Y,1085
|
16
|
+
droidrun-0.1.0.dist-info/METADATA,sha256=UIZUdp3fZg7fweI1Or1zoUZu-k-T9VgbvDv25IXO8wI,8450
|
17
|
+
droidrun-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
18
|
+
droidrun-0.1.0.dist-info/entry_points.txt,sha256=o259U66js8TIybQ7zs814Oe_LQ_GpZsp6a9Cr-xm5zE,51
|
19
|
+
droidrun-0.1.0.dist-info/licenses/LICENSE,sha256=s-uxn9qChu-kFdRXUp6v_0HhsaJ_5OANmfNOFVm2zdk,1069
|
20
|
+
droidrun-0.1.0.dist-info/RECORD,,
|
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2025 Niels Schmidt
|
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.
|