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.
Files changed (169) hide show
  1. mobilerun/__init__.py +102 -0
  2. mobilerun/__main__.py +8 -0
  3. mobilerun/agent/__init__.py +3 -0
  4. mobilerun/agent/action_context.py +41 -0
  5. mobilerun/agent/action_result.py +16 -0
  6. mobilerun/agent/common/__init__.py +0 -0
  7. mobilerun/agent/common/constants.py +3 -0
  8. mobilerun/agent/common/events.py +20 -0
  9. mobilerun/agent/droid/__init__.py +30 -0
  10. mobilerun/agent/droid/droid_agent.py +1058 -0
  11. mobilerun/agent/droid/events.py +108 -0
  12. mobilerun/agent/droid/state.py +199 -0
  13. mobilerun/agent/executor/__init__.py +22 -0
  14. mobilerun/agent/executor/events.py +45 -0
  15. mobilerun/agent/executor/executor_agent.py +288 -0
  16. mobilerun/agent/executor/prompts.py +51 -0
  17. mobilerun/agent/external/README.md +131 -0
  18. mobilerun/agent/external/__init__.py +91 -0
  19. mobilerun/agent/fast_agent/__init__.py +3 -0
  20. mobilerun/agent/fast_agent/events.py +45 -0
  21. mobilerun/agent/fast_agent/fast_agent.py +568 -0
  22. mobilerun/agent/fast_agent/xml_parser.py +258 -0
  23. mobilerun/agent/manager/__init__.py +28 -0
  24. mobilerun/agent/manager/events.py +38 -0
  25. mobilerun/agent/manager/manager_agent.py +570 -0
  26. mobilerun/agent/manager/prompts.py +114 -0
  27. mobilerun/agent/manager/stateless_manager_agent.py +306 -0
  28. mobilerun/agent/oneflows/__init__.py +0 -0
  29. mobilerun/agent/oneflows/app_starter_workflow.py +141 -0
  30. mobilerun/agent/oneflows/structured_output_agent.py +80 -0
  31. mobilerun/agent/providers/__init__.py +23 -0
  32. mobilerun/agent/providers/registry.py +268 -0
  33. mobilerun/agent/providers/setup_service.py +215 -0
  34. mobilerun/agent/providers/types.py +29 -0
  35. mobilerun/agent/tool_registry.py +267 -0
  36. mobilerun/agent/trajectory/__init__.py +3 -0
  37. mobilerun/agent/trajectory/writer.py +454 -0
  38. mobilerun/agent/usage.py +254 -0
  39. mobilerun/agent/utils/__init__.py +27 -0
  40. mobilerun/agent/utils/actions.py +523 -0
  41. mobilerun/agent/utils/chat_utils.py +90 -0
  42. mobilerun/agent/utils/inference.py +276 -0
  43. mobilerun/agent/utils/llm_loader.py +256 -0
  44. mobilerun/agent/utils/llm_picker.py +267 -0
  45. mobilerun/agent/utils/oauth/anthropic_oauth_llm.py +805 -0
  46. mobilerun/agent/utils/oauth/gemini_oauth_code_assist_llm.py +1032 -0
  47. mobilerun/agent/utils/oauth/openai_oauth_llm.py +1091 -0
  48. mobilerun/agent/utils/prompt_resolver.py +66 -0
  49. mobilerun/agent/utils/signatures.py +323 -0
  50. mobilerun/agent/utils/tracing_setup.py +290 -0
  51. mobilerun/agent/utils/trajectory.py +373 -0
  52. mobilerun/app_cards/__init__.py +0 -0
  53. mobilerun/app_cards/app_card_provider.py +26 -0
  54. mobilerun/app_cards/providers/__init__.py +7 -0
  55. mobilerun/app_cards/providers/composite_provider.py +101 -0
  56. mobilerun/app_cards/providers/local_provider.py +114 -0
  57. mobilerun/app_cards/providers/server_provider.py +120 -0
  58. mobilerun/cli/__init__.py +9 -0
  59. mobilerun/cli/configure_prompts.py +77 -0
  60. mobilerun/cli/configure_wizard.py +652 -0
  61. mobilerun/cli/device_commands.py +283 -0
  62. mobilerun/cli/doctor.py +795 -0
  63. mobilerun/cli/event_handler.py +178 -0
  64. mobilerun/cli/logs.py +9 -0
  65. mobilerun/cli/main.py +1259 -0
  66. mobilerun/cli/oauth_actions.py +119 -0
  67. mobilerun/cli/tui/__init__.py +12 -0
  68. mobilerun/cli/tui/app.py +931 -0
  69. mobilerun/cli/tui/commands.py +71 -0
  70. mobilerun/cli/tui/css/advanced_tab.tcss +3 -0
  71. mobilerun/cli/tui/css/app.tcss +306 -0
  72. mobilerun/cli/tui/css/models_tab.tcss +44 -0
  73. mobilerun/cli/tui/css/settings_screen.tcss +56 -0
  74. mobilerun/cli/tui/settings/__init__.py +6 -0
  75. mobilerun/cli/tui/settings/advanced_tab.py +168 -0
  76. mobilerun/cli/tui/settings/agent_tab.py +70 -0
  77. mobilerun/cli/tui/settings/data.py +286 -0
  78. mobilerun/cli/tui/settings/models_tab.py +281 -0
  79. mobilerun/cli/tui/settings/section.py +49 -0
  80. mobilerun/cli/tui/settings/settings_screen.py +86 -0
  81. mobilerun/cli/tui/widgets/__init__.py +7 -0
  82. mobilerun/cli/tui/widgets/command_dropdown.py +79 -0
  83. mobilerun/cli/tui/widgets/device_picker.py +218 -0
  84. mobilerun/cli/tui/widgets/input_bar.py +138 -0
  85. mobilerun/cli/tui/widgets/log_view.py +47 -0
  86. mobilerun/cli/tui/widgets/status_bar.py +56 -0
  87. mobilerun/config/app_cards/README.md +159 -0
  88. mobilerun/config/app_cards/app_cards.json +3 -0
  89. mobilerun/config/app_cards/gmail.md +35 -0
  90. mobilerun/config/credentials_example.yaml +106 -0
  91. mobilerun/config/prompts/executor/rev1.jinja2 +78 -0
  92. mobilerun/config/prompts/executor/system.jinja2 +109 -0
  93. mobilerun/config/prompts/fast_agent/system.jinja2 +163 -0
  94. mobilerun/config/prompts/fast_agent/user.jinja2 +5 -0
  95. mobilerun/config/prompts/manager/rev1.jinja2 +131 -0
  96. mobilerun/config/prompts/manager/stateless.jinja2 +125 -0
  97. mobilerun/config/prompts/manager/system.jinja2 +138 -0
  98. mobilerun/config/prompts/manager/trained.jinja2 +50 -0
  99. mobilerun/config_example.yaml +237 -0
  100. mobilerun/config_manager/__init__.py +40 -0
  101. mobilerun/config_manager/config_manager.py +394 -0
  102. mobilerun/config_manager/credential_paths.py +17 -0
  103. mobilerun/config_manager/env_keys.py +133 -0
  104. mobilerun/config_manager/loader.py +110 -0
  105. mobilerun/config_manager/migrations/__init__.py +39 -0
  106. mobilerun/config_manager/migrations/v002_add_code_exec.py +43 -0
  107. mobilerun/config_manager/migrations/v003_add_auto_setup.py +12 -0
  108. mobilerun/config_manager/migrations/v004_remove_deprecated_agents.py +41 -0
  109. mobilerun/config_manager/migrations/v005_remove_external_agents.py +15 -0
  110. mobilerun/config_manager/migrations/v006_disabled_tools_default_sentinel.py +33 -0
  111. mobilerun/config_manager/path_resolver.py +112 -0
  112. mobilerun/config_manager/prompt_loader.py +94 -0
  113. mobilerun/credential_manager/__init__.py +13 -0
  114. mobilerun/credential_manager/credential_manager.py +38 -0
  115. mobilerun/credential_manager/file_credential_manager.py +137 -0
  116. mobilerun/log_handlers.py +88 -0
  117. mobilerun/macro/__init__.py +11 -0
  118. mobilerun/macro/__main__.py +10 -0
  119. mobilerun/macro/cli.py +398 -0
  120. mobilerun/macro/handoff.py +30 -0
  121. mobilerun/macro/matcher.py +67 -0
  122. mobilerun/macro/recorder.py +51 -0
  123. mobilerun/macro/replay.py +502 -0
  124. mobilerun/macro/state.py +209 -0
  125. mobilerun/mcp/__init__.py +13 -0
  126. mobilerun/mcp/adapter.py +76 -0
  127. mobilerun/mcp/client.py +162 -0
  128. mobilerun/mcp/config.py +25 -0
  129. mobilerun/portal.py +798 -0
  130. mobilerun/telemetry/__init__.py +19 -0
  131. mobilerun/telemetry/events.py +58 -0
  132. mobilerun/telemetry/langfuse_processor.py +795 -0
  133. mobilerun/telemetry/phoenix.py +223 -0
  134. mobilerun/telemetry/tracker.py +155 -0
  135. mobilerun/tools/__init__.py +17 -0
  136. mobilerun/tools/android/__init__.py +5 -0
  137. mobilerun/tools/android/portal_client.py +744 -0
  138. mobilerun/tools/driver/__init__.py +20 -0
  139. mobilerun/tools/driver/android.py +194 -0
  140. mobilerun/tools/driver/base.py +140 -0
  141. mobilerun/tools/driver/cloud.py +274 -0
  142. mobilerun/tools/driver/ios.py +322 -0
  143. mobilerun/tools/driver/recording.py +106 -0
  144. mobilerun/tools/driver/stealth.py +180 -0
  145. mobilerun/tools/driver/visual_remote.py +294 -0
  146. mobilerun/tools/filters/__init__.py +22 -0
  147. mobilerun/tools/filters/base.py +20 -0
  148. mobilerun/tools/filters/concise_filter.py +68 -0
  149. mobilerun/tools/filters/detailed_filter.py +160 -0
  150. mobilerun/tools/formatters/__init__.py +6 -0
  151. mobilerun/tools/formatters/base.py +27 -0
  152. mobilerun/tools/formatters/indexed_formatter.py +202 -0
  153. mobilerun/tools/helpers/__init__.py +20 -0
  154. mobilerun/tools/helpers/coordinate.py +25 -0
  155. mobilerun/tools/helpers/element_search.py +635 -0
  156. mobilerun/tools/helpers/geometry.py +49 -0
  157. mobilerun/tools/helpers/images.py +196 -0
  158. mobilerun/tools/ios/__init__.py +5 -0
  159. mobilerun/tools/ui/__init__.py +16 -0
  160. mobilerun/tools/ui/ios_provider.py +269 -0
  161. mobilerun/tools/ui/provider.py +252 -0
  162. mobilerun/tools/ui/screenshot_provider.py +71 -0
  163. mobilerun/tools/ui/state.py +175 -0
  164. mobilerun/tools/ui/stealth_state.py +104 -0
  165. mobilerun-0.6.0.dist-info/METADATA +300 -0
  166. mobilerun-0.6.0.dist-info/RECORD +169 -0
  167. mobilerun-0.6.0.dist-info/WHEEL +4 -0
  168. mobilerun-0.6.0.dist-info/entry_points.txt +2 -0
  169. 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,8 @@
1
+ """
2
+ Mobilerun main entry point
3
+ """
4
+
5
+ from mobilerun.cli.main import cli
6
+
7
+ if __name__ == "__main__":
8
+ cli()
@@ -0,0 +1,3 @@
1
+ from mobilerun.agent.droid.events import ResultEvent
2
+
3
+ __all__ = ["ResultEvent"]
@@ -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,3 @@
1
+ """Max number of recent conversation steps to include in LLM prompt"""
2
+
3
+ LLM_HISTORY_LIMIT = 100
@@ -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"]