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:
let5sne.win10
2026-01-09 02:20:06 +08:00
parent 9fe189a8f8
commit 3552df23d6
31 changed files with 4221 additions and 8 deletions

28
scripts/run_dashboard.bat Normal file
View File

@@ -0,0 +1,28 @@
@echo off
REM AutoGLM Dashboard - Run Script for Windows
REM Change to project root
cd /d "%~dp0.."
REM Load .env file if it exists (use set command to parse)
if exist .env (
for /f "tokens=*" %%a in ('type .env ^| findstr /v "^#"') do set %%a
)
REM Set defaults
if not defined DASHBOARD_HOST set DASHBOARD_HOST=0.0.0.0
if not defined DASHBOARD_PORT set DASHBOARD_PORT=8080
if not defined DASHBOARD_DEBUG set DASHBOARD_DEBUG=false
REM Print configuration
echo ==========================================
echo AutoGLM Dashboard
echo ==========================================
echo Host: %DASHBOARD_HOST%
echo Port: %DASHBOARD_PORT%
echo Debug: %DASHBOARD_DEBUG%
echo ==========================================
echo.
REM Run the dashboard
python -m uvicorn dashboard.main:app --host %DASHBOARD_HOST% --port %DASHBOARD_PORT% --reload

34
scripts/run_dashboard.sh Normal file
View File

@@ -0,0 +1,34 @@
#!/bin/bash
# AutoGLM Dashboard - Run Script
# Get the directory where this script is located
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
# Change to project root
cd "$PROJECT_ROOT"
# Load .env file if it exists
if [ -f .env ]; then
export $(grep -v '^#' .env | xargs)
fi
# Set defaults
DASHBOARD_HOST=${DASHBOARD_HOST:-0.0.0.0}
DASHBOARD_PORT=${DASHBOARD_PORT:-8080}
DASHBOARD_DEBUG=${DASHBOARD_DEBUG:-false}
# Print configuration
echo "=========================================="
echo " AutoGLM Dashboard"
echo "=========================================="
echo "Host: $DASHBOARD_HOST"
echo "Port: $DASHBOARD_PORT"
echo "Debug: $DASHBOARD_DEBUG"
echo "=========================================="
# Run the dashboard
python -m uvicorn dashboard.main:app \
--host "$DASHBOARD_HOST" \
--port "$DASHBOARD_PORT" \
--reload