Files
Open-AutoGLM/dashboard/dependencies.py
let5sne.win10 3552df23d6 Add Web Dashboard with multi-device control and callback hooks
Features:
- Web Dashboard: FastAPI-based dashboard with Vue.js frontend
  - Multi-device support (ADB, HDC, iOS)
  - Real-time WebSocket updates for task progress
  - Device management with status tracking
  - Task queue with execution controls (start/stop/re-execute)
  - Detailed task information display (thinking, actions, completion messages)
  - Screenshot viewing per device
  - LAN deployment support with configurable CORS

- Callback Hooks: Interrupt and modify task execution
  - step_callback: Called after each step with StepResult
  - before_action_callback: Called before executing action
  - Support for task interruption and dynamic task switching
  - Example scripts demonstrating callback usage

- Configuration: Environment-based configuration
  - .env file support for all settings
  - .env.example template with documentation
  - Model API configuration (base URL, model name, API key)
  - Dashboard configuration (host, port, CORS, device type)
  - Phone agent configuration (delays, max steps, language)

Technical improvements:
- Fixed forward reference issue with StepResult
- Added package exports for callback types and configs
- Enhanced dependencies with FastAPI, WebSocket support
- Thread-safe task execution with device locking
- Async WebSocket broadcasting from sync thread pool

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-09 02:20:06 +08:00

40 lines
1.1 KiB
Python

"""
Dependency injection for the dashboard.
"""
from typing import AsyncGenerator
from dashboard.config import config
from dashboard.services.device_manager import DeviceManager
from dashboard.services.task_executor import TaskExecutor
from dashboard.services.websocket_manager import WebSocketManager
# Global service instances
_device_manager: DeviceManager | None = None
_task_executor: TaskExecutor | None = None
_ws_manager: WebSocketManager | None = None
def get_device_manager() -> DeviceManager:
"""Get the device manager instance."""
global _device_manager
if _device_manager is None:
_device_manager = DeviceManager(device_type=config.DEFAULT_DEVICE_TYPE)
return _device_manager
def get_task_executor() -> TaskExecutor:
"""Get the task executor instance."""
global _task_executor
if _task_executor is None:
_task_executor = TaskExecutor(get_device_manager())
return _task_executor
def get_ws_manager() -> WebSocketManager:
"""Get the WebSocket manager instance."""
global _ws_manager
if _ws_manager is None:
_ws_manager = WebSocketManager()
return _ws_manager