droidrun 0.2.0__py3-none-any.whl → 0.3.1__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 +16 -11
- droidrun/__main__.py +1 -1
- droidrun/adb/__init__.py +3 -3
- droidrun/adb/device.py +1 -1
- droidrun/adb/manager.py +2 -2
- droidrun/agent/__init__.py +6 -0
- droidrun/agent/codeact/__init__.py +2 -4
- droidrun/agent/codeact/codeact_agent.py +330 -235
- droidrun/agent/codeact/events.py +12 -20
- droidrun/agent/codeact/prompts.py +0 -52
- droidrun/agent/common/default.py +5 -0
- droidrun/agent/common/events.py +4 -0
- droidrun/agent/context/__init__.py +23 -0
- droidrun/agent/context/agent_persona.py +15 -0
- droidrun/agent/context/context_injection_manager.py +66 -0
- droidrun/agent/context/episodic_memory.py +15 -0
- droidrun/agent/context/personas/__init__.py +11 -0
- droidrun/agent/context/personas/app_starter.py +44 -0
- droidrun/agent/context/personas/default.py +95 -0
- droidrun/agent/context/personas/extractor.py +52 -0
- droidrun/agent/context/personas/ui_expert.py +107 -0
- droidrun/agent/context/reflection.py +20 -0
- droidrun/agent/context/task_manager.py +124 -0
- droidrun/agent/droid/__init__.py +2 -2
- droidrun/agent/droid/droid_agent.py +269 -325
- droidrun/agent/droid/events.py +28 -0
- droidrun/agent/oneflows/reflector.py +265 -0
- droidrun/agent/planner/__init__.py +2 -4
- droidrun/agent/planner/events.py +9 -13
- droidrun/agent/planner/planner_agent.py +288 -0
- droidrun/agent/planner/prompts.py +33 -53
- droidrun/agent/utils/__init__.py +3 -0
- droidrun/agent/utils/async_utils.py +1 -40
- droidrun/agent/utils/chat_utils.py +265 -48
- droidrun/agent/utils/executer.py +49 -14
- droidrun/agent/utils/llm_picker.py +14 -10
- droidrun/agent/utils/trajectory.py +184 -0
- droidrun/cli/__init__.py +1 -1
- droidrun/cli/logs.py +283 -0
- droidrun/cli/main.py +364 -441
- droidrun/tools/__init__.py +5 -10
- droidrun/tools/{actions.py → adb.py} +381 -412
- droidrun/tools/ios.py +596 -0
- droidrun/tools/tools.py +95 -0
- droidrun-0.3.1.dist-info/METADATA +150 -0
- droidrun-0.3.1.dist-info/RECORD +50 -0
- droidrun/agent/planner/task_manager.py +0 -355
- droidrun/agent/planner/workflow.py +0 -371
- droidrun/tools/device.py +0 -29
- droidrun/tools/loader.py +0 -60
- droidrun-0.2.0.dist-info/METADATA +0 -373
- droidrun-0.2.0.dist-info/RECORD +0 -32
- {droidrun-0.2.0.dist-info → droidrun-0.3.1.dist-info}/WHEEL +0 -0
- {droidrun-0.2.0.dist-info → droidrun-0.3.1.dist-info}/entry_points.txt +0 -0
- {droidrun-0.2.0.dist-info → droidrun-0.3.1.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,124 @@
|
|
1
|
+
import os
|
2
|
+
from typing import List, Dict
|
3
|
+
from dataclasses import dataclass
|
4
|
+
import copy
|
5
|
+
|
6
|
+
@dataclass
|
7
|
+
class Task:
|
8
|
+
"""
|
9
|
+
Represents a single task with its properties.
|
10
|
+
"""
|
11
|
+
description: str
|
12
|
+
status: str
|
13
|
+
agent_type: str
|
14
|
+
|
15
|
+
|
16
|
+
class TaskManager:
|
17
|
+
"""
|
18
|
+
Manages a list of tasks for an agent, each with a status and assigned specialized agent.
|
19
|
+
"""
|
20
|
+
STATUS_PENDING = "pending"
|
21
|
+
STATUS_COMPLETED = "completed"
|
22
|
+
STATUS_FAILED = "failed"
|
23
|
+
|
24
|
+
VALID_STATUSES = {
|
25
|
+
STATUS_PENDING,
|
26
|
+
STATUS_COMPLETED,
|
27
|
+
STATUS_FAILED
|
28
|
+
}
|
29
|
+
def __init__(self):
|
30
|
+
"""Initializes an empty task list."""
|
31
|
+
self.tasks: List[Task] = []
|
32
|
+
self.goal_completed = False
|
33
|
+
self.message = None
|
34
|
+
self.task_history = []
|
35
|
+
self.file_path = os.path.join(os.path.dirname(__file__), "todo.txt")
|
36
|
+
|
37
|
+
def get_all_tasks(self) -> List[Task]:
|
38
|
+
return self.tasks
|
39
|
+
|
40
|
+
def get_task_history(self):
|
41
|
+
return self.task_history
|
42
|
+
|
43
|
+
def complete_task(self, task: Task):
|
44
|
+
task = copy.deepcopy(task)
|
45
|
+
task.status = self.STATUS_COMPLETED
|
46
|
+
self.task_history.append(task)
|
47
|
+
|
48
|
+
def fail_task(self, task: Task):
|
49
|
+
task = copy.deepcopy(task)
|
50
|
+
task.status = self.STATUS_FAILED
|
51
|
+
self.task_history.append(task)
|
52
|
+
|
53
|
+
def get_completed_tasks(self) -> list[dict]:
|
54
|
+
return [task for task in self.task_history if task.status == self.STATUS_COMPLETED]
|
55
|
+
|
56
|
+
def get_failed_tasks(self) -> list[dict]:
|
57
|
+
return [task for task in self.task_history if task.status == self.STATUS_FAILED]
|
58
|
+
|
59
|
+
|
60
|
+
def save_to_file(self):
|
61
|
+
"""Saves the current task list to a Markdown file."""
|
62
|
+
try:
|
63
|
+
with open(self.file_path, 'w', encoding='utf-8') as f:
|
64
|
+
for i, task in enumerate(self.tasks, 1):
|
65
|
+
f.write(f"Task {i}: {task.description}\n")
|
66
|
+
f.write(f"Status: {task.status}\n")
|
67
|
+
f.write(f"Agent: {task.agent_type}\n")
|
68
|
+
f.write("-" * 40 + "\n")
|
69
|
+
except Exception as e:
|
70
|
+
print(f"Error saving tasks to file: {e}")
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
def set_tasks_with_agents(self, task_assignments: List[Dict[str, str]]):
|
75
|
+
"""
|
76
|
+
Clears the current task list and sets new tasks with their assigned agents.
|
77
|
+
|
78
|
+
Args:
|
79
|
+
task_assignments: A list of dictionaries, each containing:
|
80
|
+
- 'task': The task description string
|
81
|
+
- 'agent': The agent type
|
82
|
+
|
83
|
+
Example:
|
84
|
+
task_manager.set_tasks_with_agents([
|
85
|
+
{'task': 'Open Gmail app', 'agent': 'AppStarterExpert'},
|
86
|
+
{'task': 'Navigate to compose email', 'agent': 'UIExpert'}
|
87
|
+
])
|
88
|
+
"""
|
89
|
+
try:
|
90
|
+
self.tasks = []
|
91
|
+
for i, assignment in enumerate(task_assignments):
|
92
|
+
if not isinstance(assignment, dict) or 'task' not in assignment:
|
93
|
+
raise ValueError(f"Each task assignment must be a dictionary with 'task' key at index {i}.")
|
94
|
+
|
95
|
+
task_description = assignment['task']
|
96
|
+
if not isinstance(task_description, str) or not task_description.strip():
|
97
|
+
raise ValueError(f"Task description must be a non-empty string at index {i}.")
|
98
|
+
|
99
|
+
agent_type = assignment.get('agent', 'Default')
|
100
|
+
|
101
|
+
task_obj = Task(
|
102
|
+
description=task_description.strip(),
|
103
|
+
status=self.STATUS_PENDING,
|
104
|
+
agent_type=agent_type
|
105
|
+
)
|
106
|
+
|
107
|
+
self.tasks.append(task_obj)
|
108
|
+
|
109
|
+
print(f"Tasks set with agents: {len(self.tasks)} tasks added.")
|
110
|
+
self.save_to_file()
|
111
|
+
except Exception as e:
|
112
|
+
print(f"Error setting tasks with agents: {e}")
|
113
|
+
|
114
|
+
def complete_goal(self, message: str):
|
115
|
+
"""
|
116
|
+
Marks the goal as completed, use this whether the task completion was successful or on failure.
|
117
|
+
This method should be called when the task is finished, regardless of the outcome.
|
118
|
+
|
119
|
+
Args:
|
120
|
+
message: The message to be logged.
|
121
|
+
"""
|
122
|
+
self.goal_completed = True
|
123
|
+
self.message = message
|
124
|
+
print(f"Goal completed: {message}")
|
droidrun/agent/droid/__init__.py
CHANGED
@@ -4,8 +4,8 @@ Droidrun Agent Module.
|
|
4
4
|
This module provides a ReAct agent for automating Android devices using reasoning and acting.
|
5
5
|
"""
|
6
6
|
|
7
|
-
from
|
8
|
-
from .droid_agent import DroidAgent
|
7
|
+
from droidrun.agent.codeact.codeact_agent import CodeActAgent
|
8
|
+
from droidrun.agent.droid.droid_agent import DroidAgent
|
9
9
|
|
10
10
|
__all__ = [
|
11
11
|
"CodeActAgent",
|