feat: publish workphone SDK deployment and API docs

This commit is contained in:
Manus AI
2026-07-14 18:10:52 +08:00
commit 021d633cc1
534 changed files with 122391 additions and 0 deletions

62
sdk/agent/start_agent.sh Normal file
View File

@@ -0,0 +1,62 @@
#!/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 "$@"