droidrun 0.3.10.dev6__py3-none-any.whl → 0.3.10.dev8__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.
@@ -3,7 +3,7 @@ import json
3
3
  import logging
4
4
  import re
5
5
  import time
6
- from typing import List, Union, Optional, TYPE_CHECKING
6
+ from typing import TYPE_CHECKING, List, Optional, Union
7
7
 
8
8
  from llama_index.core.base.llms.types import ChatMessage, ChatResponse
9
9
  from llama_index.core.llms.llm import LLM
@@ -23,9 +23,8 @@ from droidrun.agent.common.events import RecordUIStateEvent, ScreenshotEvent
23
23
  from droidrun.agent.context.episodic_memory import EpisodicMemory, EpisodicMemoryStep
24
24
  from droidrun.agent.usage import get_usage_from_response
25
25
  from droidrun.agent.utils import chat_utils
26
- from droidrun.agent.utils.executer import SimpleCodeExecutor, ExecuterState
27
26
  from droidrun.agent.utils.device_state_formatter import format_device_state
28
-
27
+ from droidrun.agent.utils.executer import ExecuterState, SimpleCodeExecutor
29
28
  from droidrun.agent.utils.tools import (
30
29
  ATOMIC_ACTION_SIGNATURES,
31
30
  build_custom_tool_descriptions,
@@ -489,7 +488,7 @@ Now, describe the next step you will take to address the original goal: {goal}""
489
488
  try:
490
489
  state = self.tools.get_state()
491
490
  a11y_tree = state.get("a11y_tree", "")
492
- phone_state = state.get("phone_state", "")
491
+ phone_state = state.get("phone_state", "") # noqa: F841
493
492
  except Exception as e:
494
493
  raise Exception(f"Failed to capture final UI state: {e}") from e
495
494
 
@@ -1,5 +1,4 @@
1
1
  import copy
2
- import os
3
2
  from dataclasses import dataclass
4
3
  from typing import Dict, List, Optional
5
4
 
@@ -32,7 +32,7 @@ from droidrun.agent.droid.events import (
32
32
  )
33
33
  from droidrun.agent.executor import ExecutorAgent
34
34
  from droidrun.agent.manager import ManagerAgent
35
- from droidrun.agent.utils.tools import ATOMIC_ACTION_SIGNATURES
35
+ from droidrun.agent.utils.tools import ATOMIC_ACTION_SIGNATURES, open_app
36
36
  from droidrun.agent.utils.trajectory import Trajectory
37
37
  from droidrun.config_manager.config_manager import (
38
38
  AgentConfig,
@@ -43,8 +43,6 @@ from droidrun.config_manager.config_manager import (
43
43
  ToolsConfig,
44
44
  TracingConfig,
45
45
  )
46
-
47
- from droidrun.agent.utils.tools import open_app
48
46
  from droidrun.telemetry import (
49
47
  DroidAgentFinalizeEvent,
50
48
  DroidAgentInitEvent,
@@ -14,7 +14,7 @@ import asyncio
14
14
  from typing import Dict, List
15
15
 
16
16
  from llama_index.core.workflow import Event
17
- from pydantic import BaseModel, Field
17
+ from pydantic import BaseModel, ConfigDict, Field
18
18
 
19
19
  from droidrun.agent.context import Task
20
20
 
@@ -47,7 +47,7 @@ class DroidAgentState(BaseModel):
47
47
  """
48
48
  State model for DroidAgent workflow - shared across parent and child workflows.
49
49
  """
50
-
50
+ model_config = ConfigDict(arbitrary_types_allowed=True)
51
51
  # Task context
52
52
  instruction: str = ""
53
53
  # App Cards
@@ -3,7 +3,7 @@ Manager Agent - Planning and reasoning workflow.
3
3
  """
4
4
 
5
5
  from droidrun.agent.droid.events import ManagerInputEvent, ManagerPlanEvent
6
- from droidrun.agent.manager.events import ManagerThinkingEvent, ManagerInternalPlanEvent
6
+ from droidrun.agent.manager.events import ManagerInternalPlanEvent, ManagerThinkingEvent
7
7
  from droidrun.agent.manager.manager_agent import ManagerAgent
8
8
  from droidrun.agent.manager.prompts import parse_manager_response
9
9
 
@@ -10,6 +10,7 @@ This agent is responsible for:
10
10
 
11
11
  from __future__ import annotations
12
12
 
13
+ import asyncio
13
14
  import logging
14
15
  from typing import TYPE_CHECKING
15
16
 
@@ -23,19 +24,18 @@ from droidrun.agent.utils.chat_utils import remove_empty_messages
23
24
  from droidrun.agent.utils.device_state_formatter import format_device_state
24
25
  from droidrun.agent.utils.inference import acall_with_retries
25
26
  from droidrun.agent.utils.tools import build_custom_tool_descriptions
26
- from droidrun.config_manager.prompt_loader import PromptLoader
27
27
  from droidrun.app_cards.app_card_provider import AppCardProvider
28
28
  from droidrun.app_cards.providers import (
29
+ CompositeAppCardProvider,
29
30
  LocalAppCardProvider,
30
31
  ServerAppCardProvider,
31
- CompositeAppCardProvider,
32
32
  )
33
+ from droidrun.config_manager.prompt_loader import PromptLoader
33
34
 
34
- import asyncio
35
35
  if TYPE_CHECKING:
36
36
  from droidrun.agent.droid.events import DroidAgentState
37
- from droidrun.tools import Tools
38
37
  from droidrun.config_manager.config_manager import AgentConfig
38
+ from droidrun.tools import Tools
39
39
 
40
40
 
41
41
  logger = logging.getLogger("droidrun")
@@ -1,9 +1,10 @@
1
- import io
2
1
  import contextlib
3
- import traceback
2
+ import io
4
3
  import logging
5
- from typing import Any, Dict, Optional
4
+ import traceback
6
5
  from asyncio import AbstractEventLoop
6
+ from typing import Any, Dict, Optional
7
+
7
8
  from pydantic import BaseModel
8
9
 
9
10
  logger = logging.getLogger("droidrun")
@@ -11,7 +12,7 @@ logger = logging.getLogger("droidrun")
11
12
  class ExecuterState(BaseModel):
12
13
  """State object for the code executor."""
13
14
  ui_state: Optional[Any] = None
14
-
15
+
15
16
  class Config:
16
17
  arbitrary_types_allowed = True
17
18
 
@@ -70,7 +71,7 @@ class SimpleCodeExecutor:
70
71
  self.locals = locals
71
72
  self.loop = loop
72
73
  self.use_same_scope = use_same_scope
73
-
74
+
74
75
  if self.use_same_scope:
75
76
  # If using the same scope, merge globals and locals
76
77
  self.globals = self.locals = {
@@ -85,7 +86,7 @@ class SimpleCodeExecutor:
85
86
  """
86
87
  # Update UI state
87
88
  self.globals['ui_state'] = ui_state
88
-
89
+
89
90
  # Capture stdout and stderr
90
91
  stdout = io.StringIO()
91
92
  stderr = io.StringIO()
@@ -111,7 +112,7 @@ class SimpleCodeExecutor:
111
112
  async def execute(self, state: ExecuterState, code: str) -> str:
112
113
  """
113
114
  Execute Python code and capture output and return values.
114
-
115
+
115
116
  Runs the code in a separate thread to prevent blocking.
116
117
 
117
118
  Args:
@@ -123,7 +124,7 @@ class SimpleCodeExecutor:
123
124
  """
124
125
  # Get UI state from the state object
125
126
  ui_state = state.ui_state
126
-
127
+
127
128
  # Run the execution in a thread pool executor
128
129
  output = await self.loop.run_in_executor(
129
130
  None,
@@ -131,5 +132,5 @@ class SimpleCodeExecutor:
131
132
  code,
132
133
  ui_state
133
134
  )
134
-
135
- return output
135
+
136
+ return output
@@ -1,6 +1,6 @@
1
1
  import importlib
2
2
  import logging
3
- from typing import Any, TYPE_CHECKING
3
+ from typing import TYPE_CHECKING, Any
4
4
 
5
5
  from llama_index.core.llms.llm import LLM
6
6
 
@@ -1,5 +1,5 @@
1
- from typing import TYPE_CHECKING, List
2
1
  import time
2
+ from typing import TYPE_CHECKING, List
3
3
 
4
4
  if TYPE_CHECKING:
5
5
  from droidrun.tools import Tools
@@ -8,7 +8,6 @@ Supports multiple backends: local files, remote servers, or composite strategies
8
8
  from abc import ABC, abstractmethod
9
9
 
10
10
 
11
-
12
11
  class AppCardProvider(ABC):
13
12
  """Abstract interface for loading app-specific instruction cards."""
14
13
 
@@ -1,7 +1,7 @@
1
1
  """App card provider implementations."""
2
2
 
3
+ from droidrun.app_cards.providers.composite_provider import CompositeAppCardProvider
3
4
  from droidrun.app_cards.providers.local_provider import LocalAppCardProvider
4
5
  from droidrun.app_cards.providers.server_provider import ServerAppCardProvider
5
- from droidrun.app_cards.providers.composite_provider import CompositeAppCardProvider
6
6
 
7
7
  __all__ = ["LocalAppCardProvider", "ServerAppCardProvider", "CompositeAppCardProvider"]
@@ -7,9 +7,9 @@ Tries server first, falls back to local if server fails or returns empty.
7
7
  import logging
8
8
  from typing import Dict
9
9
 
10
- from droidrun.config_manager.app_card_provider import AppCardProvider
11
- from droidrun.config_manager.providers.local_provider import LocalAppCardProvider
12
- from droidrun.config_manager.providers.server_provider import ServerAppCardProvider
10
+ from droidrun.app_cards.app_card_provider import AppCardProvider
11
+ from droidrun.app_cards.providers.local_provider import LocalAppCardProvider
12
+ from droidrun.app_cards.providers.server_provider import ServerAppCardProvider
13
13
 
14
14
  logger = logging.getLogger("droidrun")
15
15
 
@@ -65,7 +65,7 @@ class CompositeAppCardProvider(AppCardProvider):
65
65
  server_result = await self.server_provider.load_app_card(package_name, instruction)
66
66
 
67
67
  if server_result:
68
- return server_result
68
+ return server_result
69
69
 
70
70
  # Server failed or returned empty, try local
71
71
  logger.debug(f"Composite provider: falling back to local for {package_name}")
@@ -6,10 +6,9 @@ Loads app cards from local filesystem using app_cards.json mapping.
6
6
 
7
7
  import json
8
8
  import logging
9
- from pathlib import Path
10
9
  from typing import Dict
11
10
 
12
- from droidrun.config_manager.app_card_provider import AppCardProvider
11
+ from droidrun.app_cards.app_card_provider import AppCardProvider
13
12
  from droidrun.config_manager.path_resolver import PathResolver
14
13
 
15
14
  logger = logging.getLogger("droidrun")
@@ -9,7 +9,7 @@ from typing import Dict
9
9
 
10
10
  import httpx
11
11
 
12
- from droidrun.config_manager.app_card_provider import AppCardProvider
12
+ from droidrun.app_cards.app_card_provider import AppCardProvider
13
13
 
14
14
  logger = logging.getLogger("droidrun")
15
15
 
droidrun/cli/logs.py CHANGED
@@ -21,14 +21,14 @@ from droidrun.agent.droid.events import (
21
21
  FinalizeEvent,
22
22
  TaskRunnerEvent,
23
23
  )
24
- from droidrun.agent.manager.events import (
25
- ManagerInternalPlanEvent,
26
- ManagerThinkingEvent,
27
- )
28
24
  from droidrun.agent.executor.events import (
29
25
  ExecutorInternalActionEvent,
30
26
  ExecutorInternalResultEvent,
31
27
  )
28
+ from droidrun.agent.manager.events import (
29
+ ManagerInternalPlanEvent,
30
+ ManagerThinkingEvent,
31
+ )
32
32
 
33
33
 
34
34
  class LogHandler(logging.Handler):
droidrun/cli/main.py CHANGED
@@ -16,13 +16,14 @@ from rich.console import Console
16
16
  from droidrun.agent.droid import DroidAgent
17
17
  from droidrun.agent.utils.llm_picker import load_llm, load_llms_from_profiles
18
18
  from droidrun.cli.logs import LogHandler
19
+ from droidrun.config_manager import ConfigManager
19
20
  from droidrun.config_manager.config_manager import (
20
21
  AgentConfig,
21
22
  CodeActConfig,
22
- ManagerConfig,
23
- ExecutorConfig,
24
23
  DeviceConfig,
24
+ ExecutorConfig,
25
25
  LoggingConfig,
26
+ ManagerConfig,
26
27
  ToolsConfig,
27
28
  TracingConfig,
28
29
  )
@@ -37,8 +38,6 @@ from droidrun.portal import (
37
38
  )
38
39
  from droidrun.telemetry import print_telemetry_message
39
40
  from droidrun.tools import AdbTools, IOSTools
40
- from droidrun.config_manager import ConfigManager
41
-
42
41
 
43
42
  # Suppress all warnings
44
43
  warnings.filterwarnings("ignore")
@@ -556,18 +555,15 @@ def run(
556
555
  )
557
556
  finally:
558
557
  # Disable DroidRun keyboard after execution
558
+ # Note: Port forwards are managed automatically and persist until device disconnect
559
559
  try:
560
560
  if not (ios if ios is not None else False):
561
- device_serial = adb.device().serial
562
- if device_serial:
563
- tools = AdbTools(serial=device, use_tcp=use_tcp if use_tcp is not None else False)
564
- if hasattr(tools, 'device') and tools.device:
565
- tools.device.shell("ime disable com.droidrun.portal/.DroidrunKeyboardIME")
566
- click.echo("DroidRun keyboard disabled successfully")
567
- # Cleanup tools
568
- del tools
569
- except Exception as disable_e:
570
- click.echo(f"Warning: Failed to disable DroidRun keyboard: {disable_e}")
561
+ device_obj = adb.device(device)
562
+ if device_obj:
563
+ device_obj.shell("ime disable com.droidrun.portal/.DroidrunKeyboardIME")
564
+ except Exception:
565
+ click.echo("Failed to disable DroidRun keyboard")
566
+ pass
571
567
 
572
568
 
573
569
  @cli.command()
@@ -3,7 +3,6 @@ from __future__ import annotations
3
3
  import os
4
4
  import threading
5
5
  from dataclasses import asdict, dataclass, field
6
- from pathlib import Path
7
6
  from typing import Any, Callable, Dict, List, Optional
8
7
 
9
8
  import yaml
droidrun/macro/cli.py CHANGED
@@ -4,7 +4,6 @@ Command-line interface for DroidRun macro replay.
4
4
 
5
5
  import asyncio
6
6
  import logging
7
- import os
8
7
  from typing import Optional
9
8
 
10
9
  import click