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>
53 lines
1.5 KiB
Python
53 lines
1.5 KiB
Python
"""
|
|
Dashboard configuration settings.
|
|
"""
|
|
|
|
import os
|
|
from typing import List
|
|
|
|
from dotenv import load_dotenv
|
|
|
|
# Load .env file
|
|
load_dotenv()
|
|
|
|
|
|
class DashboardConfig:
|
|
"""Dashboard configuration."""
|
|
|
|
# Server settings
|
|
HOST: str = os.getenv("DASHBOARD_HOST", "0.0.0.0")
|
|
PORT: int = int(os.getenv("DASHBOARD_PORT", "8080"))
|
|
DEBUG: bool = os.getenv("DASHBOARD_DEBUG", "false").lower() == "true"
|
|
|
|
# CORS settings
|
|
CORS_ORIGINS: List[str] = os.getenv(
|
|
"DASHBOARD_CORS_ORIGINS", "*"
|
|
).split(",") if os.getenv("DASHBOARD_CORS_ORIGINS") else ["*"]
|
|
|
|
# Device settings
|
|
DEFAULT_DEVICE_TYPE: str = os.getenv("DEFAULT_DEVICE_TYPE", "adb")
|
|
|
|
# Task settings
|
|
MAX_CONCURRENT_TASKS: int = int(os.getenv("MAX_CONCURRENT_TASKS", "10"))
|
|
TASK_TIMEOUT_SECONDS: int = int(os.getenv("TASK_TIMEOUT_SECONDS", "300"))
|
|
|
|
# Screenshot settings
|
|
SCREENSHOT_QUALITY: int = int(os.getenv("SCREENSHOT_QUALITY", "80"))
|
|
SCREENSHOT_THROTTLE_MS: int = int(os.getenv("SCREENSHOT_THROTTLE_MS", "500"))
|
|
|
|
# Model settings (defaults from environment)
|
|
MODEL_BASE_URL: str = os.getenv("PHONE_AGENT_BASE_URL", "http://localhost:8000/v1")
|
|
MODEL_NAME: str = os.getenv("PHONE_AGENT_MODEL", "autoglm-phone-9b")
|
|
MODEL_API_KEY: str = os.getenv("PHONE_AGENT_API_KEY", "EMPTY")
|
|
|
|
# Task history
|
|
MAX_TASK_HISTORY: int = int(os.getenv("MAX_TASK_HISTORY", "100"))
|
|
|
|
class Config:
|
|
env_file = ".env"
|
|
env_file_encoding = "utf-8"
|
|
|
|
|
|
# Global config instance
|
|
config = DashboardConfig()
|