Files
agentic-mobile-control/apps/device-host-agent/host_agent/execution.py
T

49 lines
1.5 KiB
Python

from __future__ import annotations
from collections.abc import Callable
from dataclasses import dataclass
from device.manager import DeviceManager
from runtime.executor import Executor, default_tool_registry
from runtime.task import TaskRunner
from storage.task_metadata import TaskMetadataStore
from storage.timeline import Timeline
from workflow.runner import WorkflowRunner
from workflow.store import WorkflowStore
@dataclass(frozen=True)
class ExecutionFactories:
task_runner_factory: Callable[[], TaskRunner]
workflow_runner_factory: Callable[[], WorkflowRunner]
workflow_store: WorkflowStore
def create_execution_factories(
manager: DeviceManager,
*,
workflow_store: WorkflowStore | None = None,
metadata_store: TaskMetadataStore | None = None,
timeline: Timeline | None = None,
) -> ExecutionFactories:
shared_workflow_store = workflow_store or WorkflowStore()
def create_task_runner() -> TaskRunner:
return TaskRunner(
executor=Executor(tools=default_tool_registry(manager=manager)),
metadata_store=metadata_store,
timeline=timeline,
)
def create_workflow_runner() -> WorkflowRunner:
return WorkflowRunner(
shared_workflow_store,
task_runner_factory=create_task_runner,
)
return ExecutionFactories(
task_runner_factory=create_task_runner,
workflow_runner_factory=create_workflow_runner,
workflow_store=shared_workflow_store,
)