Files
workphone-sdk/sdk/app/agent/start_agent.sh
卡若 9118df9eee
Some checks failed
SDK CI / python-compile (push) Has been cancelled
feat: sdk agent、Android 与文档同步至 Gitea
- 新增 sdk/app/agent(Hook/Skills/Anti-ban 等)及 NAS/ADB 脚本
- 更新 Android 端、unified、PHP SDK、Docker Compose
- Soul 文档迁移至 Soul调研/;移除资料目录内 APK
- .gitignore 排除 sdk/tmp、sdk/logs、sdk/tmp_rom

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-06 18:20:14 +08:00

63 lines
1.7 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/data/data/com.termux/files/usr/bin/bash
#
# 工作手机 Agent 启动脚本Termux 专用)
# 功能:自动启动 ATX 服务 → 等待就绪 → 启动 Agent
#
AGENT_DIR="$(cd "$(dirname "$0")" && pwd)"
ATX_PORT=9008
ATX_JAR="/data/local/tmp/u2.jar"
PYTHON="/data/data/com.termux/files/usr/bin/python3"
export PATH="/data/data/com.termux/files/usr/bin:$PATH"
export TMPDIR="/data/data/com.termux/files/usr/tmp"
export HOME="/data/data/com.termux/files/home"
cd "$AGENT_DIR"
start_atx() {
if curl -s "http://127.0.0.1:${ATX_PORT}/ping" >/dev/null 2>&1; then
echo "✅ ATX 服务已在运行 (端口 ${ATX_PORT})"
return 0
fi
if [ ! -f "$ATX_JAR" ]; then
echo "❌ ATX jar 不存在: $ATX_JAR"
echo " 请先从电脑运行: python3 -m uiautomator2 init --serial <设备>"
return 1
fi
echo "🚀 启动 ATX 服务..."
nohup sh -c "CLASSPATH=$ATX_JAR /system/bin/app_process / com.wetest.uia2.Main" \
> /data/local/tmp/atx.log 2>&1 &
ATX_PID=$!
echo " ATX PID: $ATX_PID"
for i in $(seq 1 20); do
sleep 1
if curl -s "http://127.0.0.1:${ATX_PORT}/ping" >/dev/null 2>&1; then
echo "✅ ATX 服务就绪 (${i}s)"
return 0
fi
echo " 等待 ATX... (${i}/20)"
done
echo "❌ ATX 服务启动超时"
return 1
}
echo "========================================="
echo " 工作手机 Agent 启动器"
echo " 目录: $AGENT_DIR"
echo "========================================="
if ! start_atx; then
echo ""
echo "⚠️ ATX 未就绪Agent 将以无 u2 模式启动"
echo " WebSocket 连接和心跳正常UI 操作不可用)"
fi
echo ""
echo "🤖 启动 Agent..."
exec $PYTHON agent.py "$@"