mobilerun 0.6.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.
- mobilerun/__init__.py +102 -0
- mobilerun/__main__.py +8 -0
- mobilerun/agent/__init__.py +3 -0
- mobilerun/agent/action_context.py +41 -0
- mobilerun/agent/action_result.py +16 -0
- mobilerun/agent/common/__init__.py +0 -0
- mobilerun/agent/common/constants.py +3 -0
- mobilerun/agent/common/events.py +20 -0
- mobilerun/agent/droid/__init__.py +30 -0
- mobilerun/agent/droid/droid_agent.py +1058 -0
- mobilerun/agent/droid/events.py +108 -0
- mobilerun/agent/droid/state.py +199 -0
- mobilerun/agent/executor/__init__.py +22 -0
- mobilerun/agent/executor/events.py +45 -0
- mobilerun/agent/executor/executor_agent.py +288 -0
- mobilerun/agent/executor/prompts.py +51 -0
- mobilerun/agent/external/README.md +131 -0
- mobilerun/agent/external/__init__.py +91 -0
- mobilerun/agent/fast_agent/__init__.py +3 -0
- mobilerun/agent/fast_agent/events.py +45 -0
- mobilerun/agent/fast_agent/fast_agent.py +568 -0
- mobilerun/agent/fast_agent/xml_parser.py +258 -0
- mobilerun/agent/manager/__init__.py +28 -0
- mobilerun/agent/manager/events.py +38 -0
- mobilerun/agent/manager/manager_agent.py +570 -0
- mobilerun/agent/manager/prompts.py +114 -0
- mobilerun/agent/manager/stateless_manager_agent.py +306 -0
- mobilerun/agent/oneflows/__init__.py +0 -0
- mobilerun/agent/oneflows/app_starter_workflow.py +141 -0
- mobilerun/agent/oneflows/structured_output_agent.py +80 -0
- mobilerun/agent/providers/__init__.py +23 -0
- mobilerun/agent/providers/registry.py +268 -0
- mobilerun/agent/providers/setup_service.py +215 -0
- mobilerun/agent/providers/types.py +29 -0
- mobilerun/agent/tool_registry.py +267 -0
- mobilerun/agent/trajectory/__init__.py +3 -0
- mobilerun/agent/trajectory/writer.py +454 -0
- mobilerun/agent/usage.py +254 -0
- mobilerun/agent/utils/__init__.py +27 -0
- mobilerun/agent/utils/actions.py +523 -0
- mobilerun/agent/utils/chat_utils.py +90 -0
- mobilerun/agent/utils/inference.py +276 -0
- mobilerun/agent/utils/llm_loader.py +256 -0
- mobilerun/agent/utils/llm_picker.py +267 -0
- mobilerun/agent/utils/oauth/anthropic_oauth_llm.py +805 -0
- mobilerun/agent/utils/oauth/gemini_oauth_code_assist_llm.py +1032 -0
- mobilerun/agent/utils/oauth/openai_oauth_llm.py +1091 -0
- mobilerun/agent/utils/prompt_resolver.py +66 -0
- mobilerun/agent/utils/signatures.py +323 -0
- mobilerun/agent/utils/tracing_setup.py +290 -0
- mobilerun/agent/utils/trajectory.py +373 -0
- mobilerun/app_cards/__init__.py +0 -0
- mobilerun/app_cards/app_card_provider.py +26 -0
- mobilerun/app_cards/providers/__init__.py +7 -0
- mobilerun/app_cards/providers/composite_provider.py +101 -0
- mobilerun/app_cards/providers/local_provider.py +114 -0
- mobilerun/app_cards/providers/server_provider.py +120 -0
- mobilerun/cli/__init__.py +9 -0
- mobilerun/cli/configure_prompts.py +77 -0
- mobilerun/cli/configure_wizard.py +652 -0
- mobilerun/cli/device_commands.py +283 -0
- mobilerun/cli/doctor.py +795 -0
- mobilerun/cli/event_handler.py +178 -0
- mobilerun/cli/logs.py +9 -0
- mobilerun/cli/main.py +1259 -0
- mobilerun/cli/oauth_actions.py +119 -0
- mobilerun/cli/tui/__init__.py +12 -0
- mobilerun/cli/tui/app.py +931 -0
- mobilerun/cli/tui/commands.py +71 -0
- mobilerun/cli/tui/css/advanced_tab.tcss +3 -0
- mobilerun/cli/tui/css/app.tcss +306 -0
- mobilerun/cli/tui/css/models_tab.tcss +44 -0
- mobilerun/cli/tui/css/settings_screen.tcss +56 -0
- mobilerun/cli/tui/settings/__init__.py +6 -0
- mobilerun/cli/tui/settings/advanced_tab.py +168 -0
- mobilerun/cli/tui/settings/agent_tab.py +70 -0
- mobilerun/cli/tui/settings/data.py +286 -0
- mobilerun/cli/tui/settings/models_tab.py +281 -0
- mobilerun/cli/tui/settings/section.py +49 -0
- mobilerun/cli/tui/settings/settings_screen.py +86 -0
- mobilerun/cli/tui/widgets/__init__.py +7 -0
- mobilerun/cli/tui/widgets/command_dropdown.py +79 -0
- mobilerun/cli/tui/widgets/device_picker.py +218 -0
- mobilerun/cli/tui/widgets/input_bar.py +138 -0
- mobilerun/cli/tui/widgets/log_view.py +47 -0
- mobilerun/cli/tui/widgets/status_bar.py +56 -0
- mobilerun/config/app_cards/README.md +159 -0
- mobilerun/config/app_cards/app_cards.json +3 -0
- mobilerun/config/app_cards/gmail.md +35 -0
- mobilerun/config/credentials_example.yaml +106 -0
- mobilerun/config/prompts/executor/rev1.jinja2 +78 -0
- mobilerun/config/prompts/executor/system.jinja2 +109 -0
- mobilerun/config/prompts/fast_agent/system.jinja2 +163 -0
- mobilerun/config/prompts/fast_agent/user.jinja2 +5 -0
- mobilerun/config/prompts/manager/rev1.jinja2 +131 -0
- mobilerun/config/prompts/manager/stateless.jinja2 +125 -0
- mobilerun/config/prompts/manager/system.jinja2 +138 -0
- mobilerun/config/prompts/manager/trained.jinja2 +50 -0
- mobilerun/config_example.yaml +237 -0
- mobilerun/config_manager/__init__.py +40 -0
- mobilerun/config_manager/config_manager.py +394 -0
- mobilerun/config_manager/credential_paths.py +17 -0
- mobilerun/config_manager/env_keys.py +133 -0
- mobilerun/config_manager/loader.py +110 -0
- mobilerun/config_manager/migrations/__init__.py +39 -0
- mobilerun/config_manager/migrations/v002_add_code_exec.py +43 -0
- mobilerun/config_manager/migrations/v003_add_auto_setup.py +12 -0
- mobilerun/config_manager/migrations/v004_remove_deprecated_agents.py +41 -0
- mobilerun/config_manager/migrations/v005_remove_external_agents.py +15 -0
- mobilerun/config_manager/migrations/v006_disabled_tools_default_sentinel.py +33 -0
- mobilerun/config_manager/path_resolver.py +112 -0
- mobilerun/config_manager/prompt_loader.py +94 -0
- mobilerun/credential_manager/__init__.py +13 -0
- mobilerun/credential_manager/credential_manager.py +38 -0
- mobilerun/credential_manager/file_credential_manager.py +137 -0
- mobilerun/log_handlers.py +88 -0
- mobilerun/macro/__init__.py +11 -0
- mobilerun/macro/__main__.py +10 -0
- mobilerun/macro/cli.py +398 -0
- mobilerun/macro/handoff.py +30 -0
- mobilerun/macro/matcher.py +67 -0
- mobilerun/macro/recorder.py +51 -0
- mobilerun/macro/replay.py +502 -0
- mobilerun/macro/state.py +209 -0
- mobilerun/mcp/__init__.py +13 -0
- mobilerun/mcp/adapter.py +76 -0
- mobilerun/mcp/client.py +162 -0
- mobilerun/mcp/config.py +25 -0
- mobilerun/portal.py +798 -0
- mobilerun/telemetry/__init__.py +19 -0
- mobilerun/telemetry/events.py +58 -0
- mobilerun/telemetry/langfuse_processor.py +795 -0
- mobilerun/telemetry/phoenix.py +223 -0
- mobilerun/telemetry/tracker.py +155 -0
- mobilerun/tools/__init__.py +17 -0
- mobilerun/tools/android/__init__.py +5 -0
- mobilerun/tools/android/portal_client.py +744 -0
- mobilerun/tools/driver/__init__.py +20 -0
- mobilerun/tools/driver/android.py +194 -0
- mobilerun/tools/driver/base.py +140 -0
- mobilerun/tools/driver/cloud.py +274 -0
- mobilerun/tools/driver/ios.py +322 -0
- mobilerun/tools/driver/recording.py +106 -0
- mobilerun/tools/driver/stealth.py +180 -0
- mobilerun/tools/driver/visual_remote.py +294 -0
- mobilerun/tools/filters/__init__.py +22 -0
- mobilerun/tools/filters/base.py +20 -0
- mobilerun/tools/filters/concise_filter.py +68 -0
- mobilerun/tools/filters/detailed_filter.py +160 -0
- mobilerun/tools/formatters/__init__.py +6 -0
- mobilerun/tools/formatters/base.py +27 -0
- mobilerun/tools/formatters/indexed_formatter.py +202 -0
- mobilerun/tools/helpers/__init__.py +20 -0
- mobilerun/tools/helpers/coordinate.py +25 -0
- mobilerun/tools/helpers/element_search.py +635 -0
- mobilerun/tools/helpers/geometry.py +49 -0
- mobilerun/tools/helpers/images.py +196 -0
- mobilerun/tools/ios/__init__.py +5 -0
- mobilerun/tools/ui/__init__.py +16 -0
- mobilerun/tools/ui/ios_provider.py +269 -0
- mobilerun/tools/ui/provider.py +252 -0
- mobilerun/tools/ui/screenshot_provider.py +71 -0
- mobilerun/tools/ui/state.py +175 -0
- mobilerun/tools/ui/stealth_state.py +104 -0
- mobilerun-0.6.0.dist-info/METADATA +300 -0
- mobilerun-0.6.0.dist-info/RECORD +169 -0
- mobilerun-0.6.0.dist-info/WHEEL +4 -0
- mobilerun-0.6.0.dist-info/entry_points.txt +2 -0
- mobilerun-0.6.0.dist-info/licenses/LICENSE +21 -0
mobilerun/__init__.py
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Mobilerun - A framework for controlling Android devices through LLM agents.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
from importlib.metadata import version
|
|
7
|
+
|
|
8
|
+
__version__ = version("mobilerun")
|
|
9
|
+
|
|
10
|
+
# Attach a default CLILogHandler so that every consumer (CLI, TUI, SDK,
|
|
11
|
+
# tools-only) gets visible output without explicit setup. CLI and TUI
|
|
12
|
+
# replace this with their own handler via ``configure_logging()``.
|
|
13
|
+
from mobilerun.log_handlers import CLILogHandler
|
|
14
|
+
|
|
15
|
+
_logger = logging.getLogger("mobilerun")
|
|
16
|
+
_logger.addHandler(CLILogHandler())
|
|
17
|
+
_logger.setLevel(logging.INFO)
|
|
18
|
+
_logger.propagate = False
|
|
19
|
+
|
|
20
|
+
# Import main classes for easier access
|
|
21
|
+
from mobilerun.agent import ResultEvent # noqa: E402
|
|
22
|
+
from mobilerun.agent.droid import MobileAgent # noqa: E402
|
|
23
|
+
from mobilerun.agent.utils.llm_picker import load_llm # noqa: E402
|
|
24
|
+
|
|
25
|
+
# Import configuration classes
|
|
26
|
+
from mobilerun.config_manager import ( # noqa: E402
|
|
27
|
+
# Agent configs
|
|
28
|
+
AgentConfig,
|
|
29
|
+
AppCardConfig,
|
|
30
|
+
CredentialsConfig,
|
|
31
|
+
# Feature configs
|
|
32
|
+
DeviceConfig,
|
|
33
|
+
ExecutorConfig,
|
|
34
|
+
FastAgentConfig,
|
|
35
|
+
LLMProfile,
|
|
36
|
+
LoggingConfig,
|
|
37
|
+
ManagerConfig,
|
|
38
|
+
MobileConfig,
|
|
39
|
+
TelemetryConfig,
|
|
40
|
+
ToolsConfig,
|
|
41
|
+
TracingConfig,
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
# Import macro functionality
|
|
45
|
+
from mobilerun.macro import ( # noqa: E402
|
|
46
|
+
MacroPlayer,
|
|
47
|
+
replay_macro_file,
|
|
48
|
+
replay_macro_folder,
|
|
49
|
+
)
|
|
50
|
+
from mobilerun.tools import AndroidDriver, DeviceDriver, RecordingDriver # noqa: E402
|
|
51
|
+
|
|
52
|
+
# Make main components available at package level
|
|
53
|
+
__all__ = [
|
|
54
|
+
# Agent
|
|
55
|
+
"MobileAgent",
|
|
56
|
+
"load_llm",
|
|
57
|
+
"ResultEvent",
|
|
58
|
+
# Tools / Drivers
|
|
59
|
+
"DeviceDriver",
|
|
60
|
+
"AndroidDriver",
|
|
61
|
+
"RecordingDriver",
|
|
62
|
+
# Macro
|
|
63
|
+
"MacroPlayer",
|
|
64
|
+
"replay_macro_file",
|
|
65
|
+
"replay_macro_folder",
|
|
66
|
+
# Configuration
|
|
67
|
+
"MobileConfig",
|
|
68
|
+
"AgentConfig",
|
|
69
|
+
"FastAgentConfig",
|
|
70
|
+
"ManagerConfig",
|
|
71
|
+
"ExecutorConfig",
|
|
72
|
+
"AppCardConfig",
|
|
73
|
+
"DeviceConfig",
|
|
74
|
+
"LoggingConfig",
|
|
75
|
+
"TracingConfig",
|
|
76
|
+
"TelemetryConfig",
|
|
77
|
+
"ToolsConfig",
|
|
78
|
+
"CredentialsConfig",
|
|
79
|
+
"LLMProfile",
|
|
80
|
+
]
|
|
81
|
+
|
|
82
|
+
# Legacy aliases — deprecated, will be removed in v0.8.0
|
|
83
|
+
_LEGACY_ALIASES = {
|
|
84
|
+
"DroidAgent": "MobileAgent",
|
|
85
|
+
"DroidAgentState": "MobileAgentState",
|
|
86
|
+
"DroidConfig": "MobileConfig",
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def __getattr__(name):
|
|
91
|
+
if name in _LEGACY_ALIASES:
|
|
92
|
+
import warnings
|
|
93
|
+
|
|
94
|
+
new_name = _LEGACY_ALIASES[name]
|
|
95
|
+
warnings.warn(
|
|
96
|
+
f"{name} has been renamed to {new_name}. "
|
|
97
|
+
f"Update your code to use {new_name}.",
|
|
98
|
+
DeprecationWarning,
|
|
99
|
+
stacklevel=2,
|
|
100
|
+
)
|
|
101
|
+
return globals()[new_name]
|
|
102
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
mobilerun/__main__.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"""ActionContext — composed bag of dependencies for action functions.
|
|
2
|
+
|
|
3
|
+
Replaces the ``tools=tools_instance`` parameter that action functions
|
|
4
|
+
previously received.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from typing import TYPE_CHECKING, Optional
|
|
10
|
+
|
|
11
|
+
if TYPE_CHECKING:
|
|
12
|
+
from mobilerun.agent.droid.state import MobileAgentState
|
|
13
|
+
from mobilerun.credential_manager import CredentialManager
|
|
14
|
+
from mobilerun.macro.recorder import MacroRecorder
|
|
15
|
+
from mobilerun.tools.driver.base import DeviceDriver
|
|
16
|
+
from mobilerun.tools.ui.provider import StateProvider
|
|
17
|
+
from mobilerun.tools.ui.state import UIState
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class ActionContext:
|
|
21
|
+
"""Everything an action function needs to interact with the device."""
|
|
22
|
+
|
|
23
|
+
def __init__(
|
|
24
|
+
self,
|
|
25
|
+
driver: "DeviceDriver",
|
|
26
|
+
ui: "Optional[UIState]",
|
|
27
|
+
shared_state: "MobileAgentState",
|
|
28
|
+
state_provider: "StateProvider",
|
|
29
|
+
app_opener_llm=None,
|
|
30
|
+
credential_manager: "Optional[CredentialManager]" = None,
|
|
31
|
+
streaming: bool = False,
|
|
32
|
+
macro_recorder: "Optional[MacroRecorder]" = None,
|
|
33
|
+
) -> None:
|
|
34
|
+
self.driver = driver
|
|
35
|
+
self.ui = ui # refreshed each step before tool execution
|
|
36
|
+
self.shared_state = shared_state
|
|
37
|
+
self.state_provider = state_provider
|
|
38
|
+
self.app_opener_llm = app_opener_llm
|
|
39
|
+
self.credential_manager = credential_manager
|
|
40
|
+
self.streaming = streaming
|
|
41
|
+
self.macro_recorder = macro_recorder
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""ActionResult — structured return type from action functions."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclass
|
|
9
|
+
class ActionResult:
|
|
10
|
+
"""What the agent sees after an action runs."""
|
|
11
|
+
|
|
12
|
+
success: bool
|
|
13
|
+
summary: str
|
|
14
|
+
|
|
15
|
+
def __str__(self) -> str:
|
|
16
|
+
return self.summary
|
|
File without changes
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from typing import Any, Dict
|
|
2
|
+
|
|
3
|
+
from llama_index.core.workflow import Event
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ScreenshotEvent(Event):
|
|
7
|
+
screenshot: bytes
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class RecordUIStateEvent(Event):
|
|
11
|
+
ui_state: list[Dict[str, Any]]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ToolExecutionEvent(Event):
|
|
15
|
+
"""Emitted after every tool call dispatched through ToolRegistry."""
|
|
16
|
+
|
|
17
|
+
tool_name: str
|
|
18
|
+
tool_args: Dict[str, Any]
|
|
19
|
+
success: bool
|
|
20
|
+
summary: str
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Mobilerun Agent Module.
|
|
3
|
+
|
|
4
|
+
This module provides a ReAct agent for automating Android devices using reasoning and acting.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from mobilerun.agent.droid.droid_agent import MobileAgent
|
|
8
|
+
from mobilerun.agent.droid.state import MobileAgentState
|
|
9
|
+
|
|
10
|
+
# Legacy aliases for backward compatibility
|
|
11
|
+
_LEGACY_ALIASES = {
|
|
12
|
+
"DroidAgent": MobileAgent,
|
|
13
|
+
"DroidAgentState": MobileAgentState,
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def __getattr__(name):
|
|
18
|
+
if name in _LEGACY_ALIASES:
|
|
19
|
+
import warnings
|
|
20
|
+
|
|
21
|
+
warnings.warn(
|
|
22
|
+
f"{name} has been renamed. Update your imports.",
|
|
23
|
+
DeprecationWarning,
|
|
24
|
+
stacklevel=2,
|
|
25
|
+
)
|
|
26
|
+
return _LEGACY_ALIASES[name]
|
|
27
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
__all__ = ["MobileAgent", "MobileAgentState", "DroidAgent", "DroidAgentState"]
|