droidrun 0.3.2__py3-none-any.whl → 0.3.4__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 +6 -2
- droidrun/agent/codeact/codeact_agent.py +20 -14
- droidrun/agent/common/events.py +44 -1
- droidrun/agent/context/personas/__init__.py +2 -0
- droidrun/agent/context/personas/big_agent.py +96 -0
- droidrun/agent/context/personas/ui_expert.py +1 -0
- droidrun/agent/context/task_manager.py +8 -3
- droidrun/agent/droid/droid_agent.py +50 -16
- droidrun/agent/droid/events.py +1 -0
- droidrun/agent/planner/planner_agent.py +19 -14
- droidrun/agent/utils/chat_utils.py +1 -1
- droidrun/agent/utils/executer.py +17 -1
- droidrun/agent/utils/trajectory.py +258 -11
- droidrun/cli/main.py +108 -44
- droidrun/macro/__init__.py +14 -0
- droidrun/macro/__main__.py +10 -0
- droidrun/macro/cli.py +228 -0
- droidrun/macro/replay.py +309 -0
- droidrun/portal.py +37 -22
- droidrun/telemetry/events.py +1 -1
- droidrun/telemetry/tracker.py +3 -2
- droidrun/tools/adb.py +641 -185
- droidrun/tools/ios.py +163 -163
- droidrun/tools/tools.py +60 -14
- {droidrun-0.3.2.dist-info → droidrun-0.3.4.dist-info}/METADATA +20 -8
- droidrun-0.3.4.dist-info/RECORD +54 -0
- droidrun/adb/__init__.py +0 -13
- droidrun/adb/device.py +0 -345
- droidrun/adb/manager.py +0 -93
- droidrun/adb/wrapper.py +0 -226
- droidrun-0.3.2.dist-info/RECORD +0 -53
- {droidrun-0.3.2.dist-info → droidrun-0.3.4.dist-info}/WHEEL +0 -0
- {droidrun-0.3.2.dist-info → droidrun-0.3.4.dist-info}/entry_points.txt +0 -0
- {droidrun-0.3.2.dist-info → droidrun-0.3.4.dist-info}/licenses/LICENSE +0 -0
droidrun/portal.py
CHANGED
@@ -2,8 +2,9 @@ import requests
|
|
2
2
|
import tempfile
|
3
3
|
import os
|
4
4
|
import contextlib
|
5
|
-
from
|
6
|
-
import
|
5
|
+
from adbutils import adb, AdbDevice
|
6
|
+
from droidrun.tools import AdbTools
|
7
|
+
from rich.console import Console
|
7
8
|
|
8
9
|
REPO = "droidrun/droidrun-portal"
|
9
10
|
ASSET_NAME = "droidrun-portal"
|
@@ -37,8 +38,10 @@ def get_latest_release_assets(debug: bool = False):
|
|
37
38
|
|
38
39
|
@contextlib.contextmanager
|
39
40
|
def download_portal_apk(debug: bool = False):
|
41
|
+
console = Console()
|
40
42
|
assets = get_latest_release_assets(debug)
|
41
43
|
|
44
|
+
asset_version = None
|
42
45
|
asset_url = None
|
43
46
|
for asset in assets:
|
44
47
|
if (
|
@@ -47,11 +50,15 @@ def download_portal_apk(debug: bool = False):
|
|
47
50
|
and asset["name"].startswith(ASSET_NAME)
|
48
51
|
):
|
49
52
|
asset_url = asset["browser_download_url"]
|
53
|
+
asset_version = asset["name"].split("-")[-1]
|
54
|
+
asset_version = asset_version.removesuffix(".apk")
|
50
55
|
break
|
51
56
|
elif "downloadUrl" in asset and os.path.basename(
|
52
57
|
asset["downloadUrl"]
|
53
58
|
).startswith(ASSET_NAME):
|
54
59
|
asset_url = asset["downloadUrl"]
|
60
|
+
asset_version: str = asset["name"].split("-")[-1]
|
61
|
+
asset_version = asset_version.removesuffix(".apk")
|
55
62
|
break
|
56
63
|
else:
|
57
64
|
if debug:
|
@@ -60,6 +67,10 @@ def download_portal_apk(debug: bool = False):
|
|
60
67
|
if not asset_url:
|
61
68
|
raise Exception(f"Asset named '{ASSET_NAME}' not found in the latest release.")
|
62
69
|
|
70
|
+
console.print(f"Found Portal APK [bold]{asset_version}[/bold]")
|
71
|
+
if debug:
|
72
|
+
console.print(f"Asset URL: {asset_url}")
|
73
|
+
|
63
74
|
tmp = tempfile.NamedTemporaryFile(delete=False, suffix=".apk")
|
64
75
|
try:
|
65
76
|
r = requests.get(asset_url, stream=True)
|
@@ -74,23 +85,21 @@ def download_portal_apk(debug: bool = False):
|
|
74
85
|
os.unlink(tmp.name)
|
75
86
|
|
76
87
|
|
77
|
-
|
78
|
-
|
88
|
+
def enable_portal_accessibility(device: AdbDevice):
|
89
|
+
device.shell(
|
79
90
|
f"settings put secure enabled_accessibility_services {A11Y_SERVICE_NAME}"
|
80
91
|
)
|
81
|
-
|
92
|
+
device.shell("settings put secure accessibility_enabled 1")
|
82
93
|
|
83
94
|
|
84
|
-
|
85
|
-
a11y_services =
|
86
|
-
"settings get secure enabled_accessibility_services"
|
87
|
-
)
|
95
|
+
def check_portal_accessibility(device: AdbDevice, debug: bool = False) -> bool:
|
96
|
+
a11y_services = device.shell("settings get secure enabled_accessibility_services")
|
88
97
|
if not A11Y_SERVICE_NAME in a11y_services:
|
89
98
|
if debug:
|
90
99
|
print(a11y_services)
|
91
100
|
return False
|
92
101
|
|
93
|
-
a11y_enabled =
|
102
|
+
a11y_enabled = device.shell("settings get secure accessibility_enabled")
|
94
103
|
if a11y_enabled != "1":
|
95
104
|
if debug:
|
96
105
|
print(a11y_enabled)
|
@@ -99,12 +108,12 @@ async def check_portal_accessibility(device: Device, debug: bool = False) -> boo
|
|
99
108
|
return True
|
100
109
|
|
101
110
|
|
102
|
-
|
111
|
+
def ping_portal(device: AdbDevice, debug: bool = False):
|
103
112
|
"""
|
104
113
|
Ping the Droidrun Portal to check if it is installed and accessible.
|
105
114
|
"""
|
106
115
|
try:
|
107
|
-
packages =
|
116
|
+
packages = device.list_packages()
|
108
117
|
except Exception as e:
|
109
118
|
raise Exception(f"Failed to list packages: {e}")
|
110
119
|
|
@@ -113,27 +122,33 @@ async def ping_portal(device: Device, debug: bool = False):
|
|
113
122
|
print(packages)
|
114
123
|
raise Exception("Portal is not installed on the device")
|
115
124
|
|
116
|
-
if not
|
117
|
-
|
125
|
+
if not check_portal_accessibility(device, debug):
|
126
|
+
device.shell("am start -a android.settings.ACCESSIBILITY_SETTINGS")
|
118
127
|
raise Exception(
|
119
128
|
"Droidrun Portal is not enabled as an accessibility service on the device"
|
120
129
|
)
|
121
130
|
|
131
|
+
|
132
|
+
def ping_portal_content(device: AdbDevice, debug: bool = False):
|
122
133
|
try:
|
123
|
-
state =
|
124
|
-
"content query --uri content://com.droidrun.portal/state"
|
125
|
-
)
|
134
|
+
state = device.shell("content query --uri content://com.droidrun.portal/state")
|
126
135
|
if not "Row: 0 result=" in state:
|
127
136
|
raise Exception("Failed to get state from Droidrun Portal")
|
128
|
-
|
129
137
|
except Exception as e:
|
130
138
|
raise Exception(f"Droidrun Portal is not reachable: {e}")
|
131
139
|
|
132
140
|
|
133
|
-
|
134
|
-
|
135
|
-
|
141
|
+
def ping_portal_tcp(device: AdbDevice, debug: bool = False):
|
142
|
+
try:
|
143
|
+
tools = AdbTools(serial=device.serial, use_tcp=True)
|
144
|
+
except Exception as e:
|
145
|
+
raise Exception(f"Failed to setup TCP forwarding: {e}")
|
146
|
+
|
147
|
+
|
148
|
+
def test():
|
149
|
+
device = adb.device()
|
150
|
+
ping_portal(device, debug=False)
|
136
151
|
|
137
152
|
|
138
153
|
if __name__ == "__main__":
|
139
|
-
|
154
|
+
test()
|
droidrun/telemetry/events.py
CHANGED
droidrun/telemetry/tracker.py
CHANGED
@@ -45,6 +45,7 @@ print_telemetry_message()
|
|
45
45
|
def get_user_id() -> str:
|
46
46
|
try:
|
47
47
|
if not USER_ID_PATH.exists():
|
48
|
+
USER_ID_PATH.parent.mkdir(parents=True, exist_ok=True)
|
48
49
|
USER_ID_PATH.touch()
|
49
50
|
USER_ID_PATH.write_text(str(uuid4()))
|
50
51
|
logger.debug(f"User ID: {USER_ID_PATH.read_text()}")
|
@@ -54,7 +55,7 @@ def get_user_id() -> str:
|
|
54
55
|
return "unknown"
|
55
56
|
|
56
57
|
|
57
|
-
def capture(event: TelemetryEvent):
|
58
|
+
def capture(event: TelemetryEvent, user_id: str | None = None):
|
58
59
|
try:
|
59
60
|
if not is_telemetry_enabled():
|
60
61
|
logger.debug(f"Telemetry disabled, skipping capture of {event}")
|
@@ -66,7 +67,7 @@ def capture(event: TelemetryEvent):
|
|
66
67
|
**event_data,
|
67
68
|
}
|
68
69
|
|
69
|
-
posthog.capture(event_name, distinct_id=get_user_id(), properties=properties)
|
70
|
+
posthog.capture(event_name, distinct_id=user_id or get_user_id(), properties=properties)
|
70
71
|
logger.debug(f"Captured event: {event_name} with properties: {event}")
|
71
72
|
except Exception as e:
|
72
73
|
logger.error(f"Error capturing event: {e}")
|