refactor(startup): simplify stack to Tauri-managed OpenFang + optional ChromeDriver

- Remove OpenFang CLI dependency from startup scripts
- OpenFang now bundled with Tauri and managed via gateway_start/gateway_status commands
- Add bootstrap screen in App.tsx to auto-start local gateway before UI loads
- Update Makefile: replace start-no-gateway with start-desktop-only
- Fix gateway config endpoints: use /api/config instead of /api/config/quick
- Add Playwright dependencies for future E2E testing
This commit is contained in:
iven
2026-03-17 14:08:03 +08:00
parent 6c6d21400c
commit 74dbf42644
81 changed files with 5729 additions and 128 deletions

View File

@@ -1,7 +1,13 @@
#!/bin/bash
# ZCLAW Unified Start Script for macOS/Linux
# Usage: ./start.sh [--no-browser] [--no-gateway] [--dev] [--help]
# Starts: ChromeDriver (optional) -> Tauri Desktop (manages OpenFang internally)
#
# NOTE: OpenFang is bundled with Tauri and managed internally.
# The frontend uses Tauri commands (gateway_start/gateway_status) to control OpenFang.
# No external OpenFang CLI installation is required.
#
# Usage: ./start.sh [--no-browser] [--dev] [--help]
set -e
@@ -15,7 +21,6 @@ NC='\033[0m' # No Color
# Parse arguments
NO_BROWSER=false
NO_GATEWAY=false
DEV_MODE=false
while [[ $# -gt 0 ]]; do
@@ -24,10 +29,6 @@ while [[ $# -gt 0 ]]; do
NO_BROWSER=true
shift
;;
--no-gateway|-ng)
NO_GATEWAY=true
shift
;;
--dev|-d)
DEV_MODE=true
shift
@@ -39,10 +40,13 @@ while [[ $# -gt 0 ]]; do
echo ""
echo "Options:"
echo " --no-browser, -nb Skip starting ChromeDriver"
echo " --no-gateway, -ng Skip starting OpenFang gateway"
echo " --dev, -d Start in development mode"
echo " --help, -h Show this help message"
echo ""
echo "Note:"
echo " OpenFang is bundled with the Tauri app and managed internally."
echo " No external OpenFang CLI installation required."
echo ""
echo "Examples:"
echo " ./start.sh # Start all services"
echo " ./start.sh --no-browser # Start without ChromeDriver"
@@ -73,7 +77,7 @@ trap cleanup EXIT INT TERM
echo ""
echo -e "${MAGENTA}═══════════════════════════════════════════${NC}"
echo -e "${MAGENTA} 🦞 ZCLAW - OpenFang Desktop Client${NC}"
echo -e "${MAGENTA} ZCLAW - OpenFang Desktop Client${NC}"
echo -e "${MAGENTA}═══════════════════════════════════════════${NC}"
echo ""
@@ -110,49 +114,16 @@ fi
echo ""
# 2. Check OpenFang Gateway
if [ "$NO_GATEWAY" = false ]; then
echo -e "${CYAN}[INFO]${NC} Checking OpenFang Gateway..."
# 2. Check OpenFang Runtime
echo -e "${CYAN}[INFO]${NC} Checking OpenFang runtime..."
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
RUNTIME_PATH="$SCRIPT_DIR/desktop/src-tauri/resources/openfang-runtime"
GATEWAY_RUNNING=false
# Check if gateway is already running
if curl -s --connect-timeout 2 http://127.0.0.1:4200/health > /dev/null 2>&1; then
GATEWAY_RUNNING=true
echo -e "${GREEN}[OK]${NC} OpenFang Gateway already running on port 4200"
fi
if [ "$GATEWAY_RUNNING" = false ]; then
if command -v openfang &> /dev/null; then
echo -e "${CYAN}[INFO]${NC} Starting OpenFang Gateway..."
openfang gateway start &
PIDS+=($!)
echo -e "${CYAN}[INFO]${NC} Waiting for gateway to be ready..."
MAX_WAIT=30
WAITED=0
while [ $WAITED -lt $MAX_WAIT ]; do
if curl -s --connect-timeout 1 http://127.0.0.1:4200/health > /dev/null 2>&1; then
echo -e "${GREEN}[OK]${NC} OpenFang Gateway started on port 4200"
break
fi
sleep 1
WAITED=$((WAITED + 1))
printf "."
done
echo ""
if [ $WAITED -ge $MAX_WAIT ]; then
echo -e "${YELLOW}[WARN]${NC} Gateway did not respond within ${MAX_WAIT}s"
fi
else
echo -e "${YELLOW}[WARN]${NC} OpenFang CLI not found. Gateway not started."
echo -e "${CYAN}[INFO]${NC} Install OpenFang: https://github.com/openfang/openfang"
fi
fi
if [ -f "$RUNTIME_PATH/openfang" ] || [ -f "$RUNTIME_PATH/openfang-x86_64-unknown-linux-gnu" ] || [ -f "$RUNTIME_PATH/openfang-aarch64-apple-darwin" ]; then
echo -e "${GREEN}[OK]${NC} OpenFang runtime found (bundled)"
else
echo -e "${CYAN}[INFO]${NC} Skipping OpenFang Gateway (--no-gateway)"
echo -e "${YELLOW}[WARN]${NC} OpenFang runtime not found at $RUNTIME_PATH"
echo -e "${CYAN}[INFO]${NC} Run: cd desktop && pnpm prepare:openfang-runtime"
fi
echo ""
@@ -163,6 +134,7 @@ cd desktop
if [ "$DEV_MODE" = true ]; then
echo -e "${CYAN}[INFO]${NC} Starting in development mode..."
echo -e "${CYAN}[INFO]${NC} OpenFang will be started by the app via Tauri commands"
pnpm tauri dev
else
# Check if built version exists