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>
This commit is contained in:
110
.env.example
Normal file
110
.env.example
Normal file
@@ -0,0 +1,110 @@
|
||||
# Phone Agent Environment Configuration
|
||||
# Copy this file to .env and fill in your values
|
||||
|
||||
# ============================================================================
|
||||
# Model Configuration / 模型配置
|
||||
# ============================================================================
|
||||
|
||||
# Model API base URL / 模型 API 地址
|
||||
# Default: http://localhost:8000/v1
|
||||
# For BigModel (智谱AI): https://open.bigmodel.cn/api/paas/v4
|
||||
# For ModelScope: https://api-inference.modelscope.cn/v1
|
||||
PHONE_AGENT_BASE_URL=http://localhost:8000/v1
|
||||
|
||||
# Model name / 模型名称
|
||||
# Default: autoglm-phone-9b
|
||||
PHONE_AGENT_MODEL=autoglm-phone-9b
|
||||
|
||||
# API key for authentication / API 密钥
|
||||
# Default: EMPTY (no authentication)
|
||||
# For BigModel: your actual API key
|
||||
PHONE_AGENT_API_KEY=EMPTY
|
||||
|
||||
# ============================================================================
|
||||
# Agent Configuration / Agent 配置
|
||||
# ============================================================================
|
||||
|
||||
# Maximum steps per task / 每个任务的最大步数
|
||||
PHONE_AGENT_MAX_STEPS=100
|
||||
|
||||
# Language for system prompt / 系统提示词语言
|
||||
# Options: cn (Chinese), en (English)
|
||||
PHONE_AGENT_LANG=cn
|
||||
|
||||
# Verbose output / 详细输出
|
||||
# Options: true, false
|
||||
PHONE_AGENT_VERBOSE=true
|
||||
|
||||
# ============================================================================
|
||||
# Device Configuration / 设备配置
|
||||
# ============================================================================
|
||||
|
||||
# Device ID (for multi-device setups) / 设备 ID(多设备时使用)
|
||||
# Leave empty to auto-detect / 留空则自动检测
|
||||
PHONE_AGENT_DEVICE_ID=
|
||||
|
||||
# Device type / 设备类型
|
||||
# Options: adb (Android), hdc (HarmonyOS), ios (iPhone)
|
||||
PHONE_AGENT_DEVICE_TYPE=adb
|
||||
|
||||
# ============================================================================
|
||||
# iOS Specific Configuration / iOS 专用配置
|
||||
# ============================================================================
|
||||
|
||||
# WebDriverAgent URL for iOS / iOS WebDriverAgent 地址
|
||||
PHONE_AGENT_WDA_URL=http://localhost:8100
|
||||
|
||||
# ============================================================================
|
||||
# Timing Configuration (Optional) / 时序配置(可选)
|
||||
# ============================================================================
|
||||
|
||||
# Action delays in seconds / 动作延迟(秒)
|
||||
PHONE_AGENT_KEYBOARD_SWITCH_DELAY=1.0
|
||||
PHONE_AGENT_TEXT_INPUT_DELAY=1.0
|
||||
|
||||
# Device delays in seconds / 设备延迟(秒)
|
||||
PHONE_AGENT_TAP_DELAY=1.0
|
||||
PHONE_AGENT_SWIPE_DELAY=1.0
|
||||
PHONE_AGENT_LAUNCH_DELAY=1.0
|
||||
|
||||
# Connection delays in seconds / 连接延迟(秒)
|
||||
PHONE_AGENT_ADB_RESTART_DELAY=2.0
|
||||
|
||||
# ============================================================================
|
||||
# Web Dashboard Configuration / Web 仪表板配置
|
||||
# ============================================================================
|
||||
|
||||
# Dashboard server host / 仪表板服务器主机
|
||||
# Use 0.0.0.0 for LAN access / 使用 0.0.0.0 以支持局域网访问
|
||||
DASHBOARD_HOST=0.0.0.0
|
||||
|
||||
# Dashboard server port / 仪表板服务器端口
|
||||
DASHBOARD_PORT=8080
|
||||
|
||||
# Dashboard debug mode / 仪表板调试模式
|
||||
# Options: true, false
|
||||
DASHBOARD_DEBUG=false
|
||||
|
||||
# CORS allowed origins / CORS 允许的来源
|
||||
# Comma-separated list, use * for all / 逗号分隔列表,使用 * 表示全部
|
||||
# Examples: http://localhost:3000,http://192.168.1.*
|
||||
DASHBOARD_CORS_ORIGINS=*
|
||||
|
||||
# Default device type for dashboard / 仪表板默认设备类型
|
||||
# Options: adb, hdc, ios
|
||||
DEFAULT_DEVICE_TYPE=adb
|
||||
|
||||
# Maximum concurrent tasks / 最大并发任务数
|
||||
MAX_CONCURRENT_TASKS=10
|
||||
|
||||
# Task timeout in seconds / 任务超时时间(秒)
|
||||
TASK_TIMEOUT_SECONDS=300
|
||||
|
||||
# Screenshot quality (1-100) / 截图质量 (1-100)
|
||||
SCREENSHOT_QUALITY=80
|
||||
|
||||
# Screenshot throttle delay in milliseconds / 截图节流延迟(毫秒)
|
||||
SCREENSHOT_THROTTLE_MS=500
|
||||
|
||||
# Maximum task history to keep / 保留的最大任务历史数
|
||||
MAX_TASK_HISTORY=100
|
||||
Reference in New Issue
Block a user