droidrun 0.1.0__py3-none-any.whl → 0.2.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/tools/device.py CHANGED
@@ -3,7 +3,7 @@ Device Manager - Handles Android device connections and management.
3
3
  """
4
4
 
5
5
  from typing import Optional, List
6
- from droidrun.adb import Device, DeviceManager as ADBDeviceManager
6
+ from ..adb import Device, DeviceManager as ADBDeviceManager
7
7
 
8
8
  class DeviceManager:
9
9
  """Manages Android device connections and operations."""
@@ -0,0 +1,60 @@
1
+ import asyncio
2
+ import logging
3
+ from .actions import Tools
4
+ from .device import DeviceManager
5
+ from typing import Tuple, Dict, Callable, Any, Optional
6
+
7
+ # Get a logger for this module
8
+ logger = logging.getLogger(__name__)
9
+
10
+ async def load_tools(serial: Optional[str] = None) -> Tuple[Dict[str, Callable[..., Any]], Tools]:
11
+ """
12
+ Initializes the Tools class and returns a dictionary of available tool functions
13
+ and the Tools instance itself. If serial is not provided, it attempts to find
14
+ the first connected device.
15
+
16
+ Args:
17
+ serial: The device serial number. If None, finds the first available device.
18
+ vision: Whether to include vision-related tools. (Set to false if you want to always send screenshot)
19
+
20
+ Returns:
21
+ A tuple containing:
22
+ - A dictionary mapping tool names to their corresponding functions.
23
+ - The initialized Tools instance.
24
+
25
+ Raises:
26
+ ValueError: If no device serial is provided and no devices are found.
27
+ """
28
+ if serial is None:
29
+ logger.info("No device serial provided, attempting to find a connected device.")
30
+ # Attempt to find a device if none is specified
31
+ device_manager = DeviceManager()
32
+ devices = await device_manager.list_devices()
33
+ if not devices:
34
+ logger.error("Device discovery failed: No connected devices found.")
35
+ raise ValueError("No device serial provided and no connected devices found.")
36
+ serial = devices[0].serial
37
+ logger.info(f"Using auto-detected device: {serial}") # Use logger.info
38
+
39
+ logger.debug(f"Initializing Tools for device: {serial}")
40
+ tools_instance = Tools(serial=serial)
41
+
42
+ tool_list = {
43
+ # UI interaction
44
+ "swipe": tools_instance.swipe,
45
+ "input_text": tools_instance.input_text,
46
+ "press_key": tools_instance.press_key,
47
+ "tap_by_index": tools_instance.tap_by_index,
48
+ #"tap_by_coordinates": tools_instance.tap_by_coordinates,
49
+
50
+ # App management
51
+ "start_app": tools_instance.start_app,
52
+ "list_packages": tools_instance.list_packages,
53
+ "complete": tools_instance.complete
54
+ }
55
+ logger.debug("Base tools loaded.")
56
+
57
+
58
+ # Return both the dictionary and the instance, as the agent might need the instance
59
+ logger.info(f"Tools loaded successfully for device {serial}.")
60
+ return tool_list, tools_instance
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: droidrun
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: A framework for controlling Android devices through LLM agents
5
5
  Project-URL: Homepage, https://github.com/droidrun/droidrun
6
6
  Project-URL: Bug Tracker, https://github.com/droidrun/droidrun/issues
@@ -28,7 +28,15 @@ Classifier: Topic :: Utilities
28
28
  Requires-Python: >=3.10
29
29
  Requires-Dist: aiofiles>=23.0.0
30
30
  Requires-Dist: anthropic>=0.7.0
31
+ Requires-Dist: arize-phoenix
31
32
  Requires-Dist: click>=8.1.0
33
+ Requires-Dist: llama-index
34
+ Requires-Dist: llama-index-callbacks-arize-phoenix
35
+ Requires-Dist: llama-index-llms-anthropic
36
+ Requires-Dist: llama-index-llms-deepseek
37
+ Requires-Dist: llama-index-llms-gemini
38
+ Requires-Dist: llama-index-llms-ollama
39
+ Requires-Dist: llama-index-llms-openai
32
40
  Requires-Dist: openai>=1.0.0
33
41
  Requires-Dist: pillow>=10.0.0
34
42
  Requires-Dist: pydantic>=2.0.0
@@ -40,17 +48,31 @@ Requires-Dist: mypy>=1.0.0; extra == 'dev'
40
48
  Requires-Dist: ruff>=0.1.0; extra == 'dev'
41
49
  Description-Content-Type: text/markdown
42
50
 
43
- # 🤖 DroidRun
51
+
52
+ <picture>
53
+ <source media="(prefers-color-scheme: dark)" srcset="./static/droidrun-dark.png">
54
+ <source media="(prefers-color-scheme: light)" srcset="./static/droidrun.png">
55
+ <img src="./static/droidrun.png" width="full">
56
+ </picture>
57
+
58
+ [![GitHub stars](https://img.shields.io/github/stars/droidrun/droidrun?style=social)](https://github.com/droidrun/droidrun/stargazers)
59
+ [![Discord](https://img.shields.io/discord/1360219330318696488?color=7289DA&label=Discord&logo=discord&logoColor=white)](https://discord.gg/ZZbKEZZkwK)
60
+ [![Documentation](https://img.shields.io/badge/Documentation-📕-blue)](https://docs.droidrun.ai)
61
+ [![Twitter Follow](https://img.shields.io/twitter/follow/droid_run?style=social)](https://x.com/droid_run)
62
+
44
63
 
45
64
  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
65
 
47
66
  ## ✨ Features
48
67
 
49
68
  - Control Android devices with natural language commands
50
- - Supports multiple LLM providers (OpenAI, Anthropic, Gemini)
51
- - Easy to use CLI
69
+ - Supports multiple LLM providers (OpenAI, Anthropic, Gemini, Ollama, DeepSeek)
70
+ - Planning capabilities for complex multi-step tasks
71
+ - LlamaIndex integration for flexible LLM interactions
72
+ - Easy to use CLI with enhanced debugging features
52
73
  - Extendable Python API for custom automations
53
74
  - Screenshot analysis for visual understanding of the device
75
+ - Execution tracing with Arize Phoenix
54
76
 
55
77
  ## 📦 Installation
56
78
 
@@ -63,7 +85,7 @@ pip install droidrun
63
85
  ### 🔧 Option 2: Install from Source
64
86
 
65
87
  ```bash
66
- git clone https://github.com/yourusername/droidrun.git
88
+ git clone https://github.com/droidrun/droidrun.git
67
89
  cd droidrun
68
90
  pip install -e .
69
91
  ```
@@ -131,6 +153,8 @@ Create a `.env` file in your working directory or set environment variables:
131
153
  export OPENAI_API_KEY="your_openai_api_key_here"
132
154
  export ANTHROPIC_API_KEY="your_anthropic_api_key_here"
133
155
  export GEMINI_API_KEY="your_gemini_api_key_here"
156
+ export DEEPSEEK_API_KEY="your_deepseek_api_key_here"
157
+ # For Ollama, no API key is needed
134
158
  ```
135
159
 
136
160
  To load the environment variables from the `.env` file:
@@ -151,15 +175,6 @@ droidrun devices
151
175
  droidrun connect 192.168.1.100
152
176
  ```
153
177
 
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
178
  ## 💻 Using the CLI
164
179
 
165
180
  DroidRun's CLI is designed to be simple and intuitive. You can use it in two ways:
@@ -175,13 +190,16 @@ droidrun "Open the settings app"
175
190
 
176
191
  ```bash
177
192
  # Using OpenAI
178
- droidrun "Open the calculator app" --provider openai --model gpt-4o-mini
193
+ droidrun "Open the calculator app" --provider OpenAI --model gpt-4o-mini
179
194
 
180
195
  # Using Anthropic
181
- droidrun "Check the battery level" --provider anthropic --model claude-3-sonnet-20240229
196
+ droidrun "Check the battery level" --provider Anthropic --model claude-3-sonnet-20240229
182
197
 
183
198
  # Using Gemini
184
- droidrun "Install and open Instagram" --provider gemini --model gemini-2.0-flash
199
+ droidrun "Install and open Instagram" --provider Gemini --model models/gemini-2.5-pro-preview-05-06
200
+
201
+ # Using Ollama (local)
202
+ droidrun "Check battery level" --provider Ollama --model llama2
185
203
  ```
186
204
 
187
205
  ### ⚙️ Additional Options
@@ -190,6 +208,15 @@ droidrun "Install and open Instagram" --provider gemini --model gemini-2.0-flash
190
208
  # Specify a particular device
191
209
  droidrun "Open Chrome and search for weather" --device abc123
192
210
 
211
+ # Enable vision capabilities
212
+ droidrun "Analyze what's on the screen" --vision
213
+
214
+ # Enable planning for complex tasks
215
+ droidrun "Find and download a specific app" --reasoning
216
+
217
+ # Enable execution tracing (requires Phoenix server running)
218
+ droidrun "Debug this complex workflow" --tracing
219
+
193
220
  # Set maximum number of steps
194
221
  droidrun "Open settings and enable dark mode" --steps 20
195
222
  ```
@@ -201,40 +228,73 @@ If you want to use DroidRun in your Python code rather than via the CLI, you can
201
228
  ```python
202
229
  #!/usr/bin/env python3
203
230
  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()
231
+ from droidrun.agent.droid import DroidAgent
232
+ from droidrun.agent.utils.llm_picker import load_llm
233
+ from droidrun.tools import load_tools
211
234
 
212
235
  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
236
+ # Load tools
237
+ tool_list, tools_instance = await load_tools()
238
+
239
+ # Load LLM
240
+ llm = load_llm(
241
+ provider_name="Gemini", # Case sensitive: OpenAI, Ollama, Anthropic, Gemini, DeepSeek
242
+ model="models/gemini-2.5-pro-preview-05-06",
218
243
  temperature=0.2
219
244
  )
220
245
 
221
246
  # Create and run the agent
222
- agent = ReActAgent(
223
- task="Open the Settings app and check the Android version",
224
- llm=llm
247
+ agent = DroidAgent(
248
+ goal="Open the Settings app and check the Android version",
249
+ llm=llm,
250
+ tools_instance=tools_instance,
251
+ tool_list=tool_list,
252
+ vision=True, # Enable vision for screen analysis
253
+ reasoning=True # Enable planning for complex tasks
225
254
  )
226
255
 
227
- steps = await agent.run()
228
- print(f"Execution completed with {len(steps)} steps")
256
+ # Run the agent
257
+ result = await agent.run()
258
+ print(f"Success: {result['success']}")
259
+ if result.get('reason'):
260
+ print(f"Reason: {result['reason']}")
229
261
 
230
262
  if __name__ == "__main__":
231
263
  asyncio.run(main())
232
264
  ```
233
265
 
234
- Save this as `test_droidrun.py`, ensure your `.env` file has the appropriate API key, and run:
266
+ You can also use LlamaIndex directly:
235
267
 
236
- ```bash
237
- python test_droidrun.py
268
+ ```python
269
+ import asyncio
270
+ from llama_index.llms.gemini import Gemini
271
+ from droidrun.agent.droid import DroidAgent
272
+ from droidrun.tools import load_tools
273
+
274
+ async def main():
275
+ # Load tools
276
+ tool_list, tools_instance = await load_tools()
277
+
278
+ # Create LlamaIndex LLM directly
279
+ llm = Gemini(
280
+ model="models/gemini-2.5-pro-preview-05-06",
281
+ temperature=0.2
282
+ )
283
+
284
+ # Create and run the agent
285
+ agent = DroidAgent(
286
+ goal="Open the Settings app and check the Android version",
287
+ llm=llm,
288
+ tools_instance=tools_instance,
289
+ tool_list=tool_list
290
+ )
291
+
292
+ # Run the agent
293
+ result = await agent.run()
294
+ print(f"Success: {result['success']}")
295
+
296
+ if __name__ == "__main__":
297
+ asyncio.run(main())
238
298
  ```
239
299
 
240
300
  ## ❓ Troubleshooting
@@ -259,6 +319,27 @@ If DroidRun is using the wrong LLM provider:
259
319
  1. Explicitly specify the provider with `--provider` (in CLI) or `llm_provider=` (in code)
260
320
  2. When using Gemini, ensure you have set `GEMINI_API_KEY` and specified `--provider gemini`
261
321
 
322
+ ### 📊 Tracing Issues
323
+
324
+ If you're using the tracing feature:
325
+ 1. Make sure to install Arize Phoenix: `pip install "arize-phoenix[llama-index]"`
326
+ 2. Start the Phoenix server before running your command: `phoenix serve`
327
+ 3. Access the tracing UI at http://localhost:6006 after execution
328
+
329
+ ### 🎬 Demo Videos
330
+
331
+ 1. **Shopping Assistant**: Watch how DroidRun searches Amazon for headphones and sends the top 3 products to a colleague on WhatsApp.
332
+
333
+ Prompt: "Go to Amazon, search for headphones and write the top 3 products to my colleague on WhatsApp."
334
+
335
+ [![Shopping Assistant Demo](https://img.youtube.com/vi/VQK3JcifgwU/0.jpg)](https://www.youtube.com/watch?v=VQK3JcifgwU)
336
+
337
+ 2. **Social Media Automation**: See DroidRun open X (Twitter) and post "Hello World".
338
+
339
+ Prompt: "Open up X and post Hello World."
340
+
341
+ [![Social Media Automation Demo](https://img.youtube.com/vi/i4-sDQhzt_M/0.jpg)](https://www.youtube.com/watch?v=i4-sDQhzt_M)
342
+
262
343
  ## 💡 Example Use Cases
263
344
 
264
345
  - Automated UI testing of Android applications
@@ -267,6 +348,22 @@ If DroidRun is using the wrong LLM provider:
267
348
  - Remote assistance for less technical users
268
349
  - Exploring Android UI with natural language commands
269
350
 
351
+ ## 🗺️ Roadmap
352
+
353
+ ### 🤖 Agent:
354
+ - **Improve memory**: Enhance context retention for complex multi-step tasks
355
+ - **Expand planning capabilities**: Add support for more complex reasoning strategies
356
+ - **Add Integrations**: Support more LLM providers and agent frameworks (LangChain, Agno etc.)
357
+
358
+ ### ⚙️ Automations:
359
+ - **Create Automation Scripts**: Generate reusable scripts from agent actions that can be scheduled or shared
360
+
361
+ ### ☁️ Cloud:
362
+ - **Hosted version**: Remote device control via web interface without local setup
363
+ - **Add-Ons**: Marketplace for extensions serving specific use cases
364
+ - **Proxy Hours**: Cloud compute time with tiered pricing for running automations
365
+ - **Droidrun AppStore**: Simple installation of Apps on your hosted devices
366
+
270
367
  ## 👥 Contributing
271
368
 
272
369
  Contributions are welcome! Please feel free to submit a Pull Request.
@@ -0,0 +1,32 @@
1
+ droidrun/__init__.py,sha256=LhCCBKH9M1PJG3jAsCG84zyK2WkbTR3WI58LrzuSXMA,659
2
+ droidrun/__main__.py,sha256=ganC_pSTITSVwVmdEfd6qEkrHutt3UVoalXTBianP2w,97
3
+ droidrun/adb/__init__.py,sha256=tBhoSFmkevb_xQcCfdrigPut9zAU1J4bagpT-TgBj8c,221
4
+ droidrun/adb/device.py,sha256=yMndMpO-R0lPmLoZANr-aou8HldyD3TLCP9J5ZjJJao,10992
5
+ droidrun/adb/manager.py,sha256=9xohDCbw8XvWW2Esglpcnk9H24hKJG3e9SkCBiFWlDI,2704
6
+ droidrun/adb/wrapper.py,sha256=Yz3_JSIidq-5bf-t0UfawTutMaLrINS_1Y15m_Uss4g,7093
7
+ droidrun/agent/codeact/__init__.py,sha256=B1wskXGB-xeGCZnUIZxBaEXz1f0YSxAHRljKqMH6nXQ,308
8
+ droidrun/agent/codeact/codeact_agent.py,sha256=lyJfBmPshR50-k6wtrOBe3IwSJueiDBpuiGNaWxoagA,16015
9
+ droidrun/agent/codeact/events.py,sha256=4O0fJWu_DwJoJF8SqQr8CpALsaSKNOGKksVS9yWWBsY,934
10
+ droidrun/agent/codeact/prompts.py,sha256=vRt0z34ND-p1RGkfXbp96Q_-z8HbHmjVB9c2LHnzl7Q,4110
11
+ droidrun/agent/droid/__init__.py,sha256=wSuPd9wDEreFYlclfmXEqiqKq0wJQTT3v3PY-WhS6q0,264
12
+ droidrun/agent/droid/droid_agent.py,sha256=3JnCkusacpBYiWVFBnVRMGbFt61CJ2_bOn_QW-lFUTk,18576
13
+ droidrun/agent/planner/__init__.py,sha256=CWWEA9H6xM-il832tpTG19bMl0j9r4fYXMLikqUGNeU,372
14
+ droidrun/agent/planner/events.py,sha256=wWBz5F7_cyNQHJLZp-n-1ML89M82_chcdhUxXTj3k8M,381
15
+ droidrun/agent/planner/prompts.py,sha256=8kWudnq8dPuhVpugyT53Y-NPLZvlQadIrjUUrKgy5h4,7065
16
+ droidrun/agent/planner/task_manager.py,sha256=u70Syr9OiGKU4IOy9oqblLYjHfELBl-m5nmQc35RPqI,13348
17
+ droidrun/agent/planner/workflow.py,sha256=jRLVkEejQk1Rul6mxBXLDtReS8K0G1UFAJdH1JHtXOk,18797
18
+ droidrun/agent/utils/async_utils.py,sha256=Bf4J2TmT7Fbp4JKtvS1lfOYBmJ3lBUQ9D0lBYQfChus,2266
19
+ droidrun/agent/utils/chat_utils.py,sha256=lSp6snn15EhrZj4eGGN3De710Btub5jV_euSz9LYUu4,3891
20
+ droidrun/agent/utils/executer.py,sha256=PKgUwTer-IezZ-NecCGrgcRHjmRIm7RTmgwrUaXJSlQ,3535
21
+ droidrun/agent/utils/llm_picker.py,sha256=KSjbOw6oqKuIQUm8lKDEhY13PTd5U70vY9Bb150AvBE,5782
22
+ droidrun/cli/__init__.py,sha256=ra9bKoHTIkgRsVFRlWztROPPRswMv_A-wc2b2e0plmo,155
23
+ droidrun/cli/main.py,sha256=NQKjHSxMTDSjNyXLnv8KnUQgTw61RFWRVKpL2aukT3M,21197
24
+ droidrun/tools/__init__.py,sha256=_wTPn8jhAjtpMdHXc5LlCa2pokpCuM1kcEzxC94gpVg,237
25
+ droidrun/tools/actions.py,sha256=0KM-eyJnWx4kIttKG7MVA8gwn9DNoxQv8It0nCyV-GE,34002
26
+ droidrun/tools/device.py,sha256=Aq2NzERtFdPLiXXQ_km7DJbw2LAPgpCIf5DQB-VpzCA,1078
27
+ droidrun/tools/loader.py,sha256=Glpxz7t1IDlitxcUslmhwPTTpNpx8y_ivLN6JF3CDoE,2372
28
+ droidrun-0.2.0.dist-info/METADATA,sha256=mDCK2ij4tifCuew8zv8aii-6dRAyfv2ehs7GfvUknus,12479
29
+ droidrun-0.2.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
30
+ droidrun-0.2.0.dist-info/entry_points.txt,sha256=o259U66js8TIybQ7zs814Oe_LQ_GpZsp6a9Cr-xm5zE,51
31
+ droidrun-0.2.0.dist-info/licenses/LICENSE,sha256=s-uxn9qChu-kFdRXUp6v_0HhsaJ_5OANmfNOFVm2zdk,1069
32
+ droidrun-0.2.0.dist-info/RECORD,,
@@ -1,16 +0,0 @@
1
- """
2
- Droidrun Agent Module.
3
-
4
- This module provides a ReAct agent for automating Android devices using reasoning and acting.
5
- """
6
-
7
- from .react_agent import ReActAgent, ReActStep, ReActStepType, run_agent
8
- from .llm_reasoning import LLMReasoner
9
-
10
- __all__ = [
11
- "ReActAgent",
12
- "ReActStep",
13
- "ReActStepType",
14
- "run_agent",
15
- "LLMReasoner",
16
- ]