Setup

From IPADS-SAI/MobiClaw · View interactive version

Setup is an AI agent skill from the GitHub repository IPADS-SAI/MobiClaw. Run initial MobiClaw setup. Use when user wants to install dependencies, configure environment variables, or start the gateway server. Triggers on "setup", "install", "configure", "start gateway", or first-time setup requests.

How to use this skill

Skill file

MobiClaw Setup

Run setup steps automatically. Only pause when user action is required (providing API keys, choosing configuration options). Verbose logs go to logs/.

Principle: When something is broken or missing, fix it. Don't tell the user to go fix it themselves unless it genuinely requires their manual action (e.g. obtaining an API key, connecting a real device). If a dependency is missing, install it. If a service won't start, diagnose and repair. Ask the user for permission when needed, then do the work.

UX Note: Use AskUserQuestion for all user-facing questions. Do NOT collect secrets (API keys, tokens, app IDs/secrets) in chat. Instead, tell the user to add them to .env manually.

0. Prerequisites Check

Verify the essential tools are available.

Run:

If uv is missing: Install it automatically:

curl -LsSf https://astral.sh/uv/install.sh | sh

Then verify with uv --version. If still not found, add ~/.local/bin to PATH and retry.

If git is missing: Tell user to install git (sudo apt-get install -y git on Debian/Ubuntu, sudo dnf install -y git on Fedora).

1. Submodule Sync

Run:

git submodule update --init --recursive

If it fails, warn the user and continue — submodule issues are non-fatal for basic gateway operation.

2. Install Python Dependencies

Run:

uv sync

If uv sync fails:

Optional: Tesseract OCR (for Chinese document OCR)

AskUserQuestion: "Install Tesseract OCR with Chinese language support? (Needed only if you plan to use OCR features)"

3. Configure Environment

Check if .env already exists at the project root.

If .env exists: Read it and parse existing variables. AskUserQuestion: "An existing .env file was found. How would you like to proceed?"

If .env does not exist: Copy the template:

cp .env-example .env

3a. LLM Provider (Required)

This is the only required configuration. AskUserQuestion: "Which LLM provider do you want to use?"

OpenRouter path:

OpenAI-compatible path:

3b. Web Search (Optional)

AskUserQuestion: "Configure Brave Search for web search capabilities?"

3c. Mobile Executor (Optional)

AskUserQuestion: "Configure mobile device executor?"

If yes:

AskUserQuestion: "Which mobile execution provider?"

Write MOBILE_PROVIDER to .env.

AskUserQuestion: "What device type are you connecting to?"

AskUserQuestion: "Do you want to manually set device ID (e.g., serial number or IP:port) to specify the device to control?"

For MobiAgent provider, AskUserQuestion: "Use the default MobiAgent service, or configure it manually?"

Write MOBILE_MOBIAGENT_SERVER_IP, MOBILE_MOBIAGENT_DECIDER_PORT, etc. to .env

For other providers, tell user to add export MOBILE_<PROVIDER>_API_BASE=<api-base> and export MOBILE_<PROVIDER>_MODEL=<model> in .env.

3d. Feishu Integration (Optional)

AskUserQuestion: "Configure Feishu (Lark) bot integration?"

If yes:

Tell user: "You need a Feishu app with bot capability enabled. Create one at https://open.feishu.cn/app"

Tell user to add export FEISHU_APP_ID=<app-id> and export FEISHU_APP_SECRET=<app-secret> to .env. Do NOT collect these in chat.

AskUserQuestion: "Which Feishu event transport mode?"

Write FEISHU_EVENT_TRANSPORT to .env.

3e. Advanced Options (Optional)

AskUserQuestion: "Configure advanced options? (routing, scheduling, memory, RAG)"

If yes, present each category:

Routing:

Scheduling:

Memory:

RAG:

Write any user-modified values to .env.

4. Create Required Directories

Ensure working directories exist:

mkdir -p logs tmp outputs
mkdir -p ~/.mobiclaw

5. Start Gateway Server

Check if the gateway port is already in use:

ss -lnt "( sport = :8090 )" 2>/dev/null || lsof -iTCP:8090 -sTCP:LISTEN 2>/dev/null

Read MOBICLAW_GATEWAY_PORT from .env (default 8090).

If port is occupied: AskUserQuestion: "Port <port> is already in use. What should we do?"

Start the gateway in background:

nohup uv run python -m mobiclaw.gateway_server > logs/gateway-server.log 2>&1 &
echo $! > tmp/gateway-server.pid

Wait for health check — poll the gateway until it responds:

curl -sf http://127.0.0.1:<port>/docs > /dev/null

Retry up to 30 times with 2-second intervals. If it doesn't come up:

6. Verify

After the gateway is running, verify the setup:

Check gateway health:

curl -sf http://127.0.0.1:<port>/docs | head -c 100

Check .env completeness: Verify at minimum OPENROUTER_API_KEY or OPENAI_API_KEY is set and non-empty.

Print summary:

Stopping the Gateway

To stop the gateway server later:

kill $(cat tmp/gateway-server.pid 2>/dev/null) 2>/dev/null; rm -f tmp/gateway-server.pid

Troubleshooting

Gateway not starting: Check logs/gateway-server.log. Common causes:

uv sync fails: Ensure Python 3.12+ is the active interpreter. Check python3 --version. Install missing system dev packages if native builds fail.

Mobile executor errors: If MOBILE_DEVICE_TYPE is not mock, ensure the target device is connected and reachable. For Android: adb devices should list the device. For MobiAgent: verify the server is running at the configured IP/port.

Feishu bot not responding: Verify FEISHU_APP_ID and FEISHU_APP_SECRET are correct. Check logs/gateway-server.log for connection errors. For long connection mode, no public IP is needed. For webhook mode, ensure the public URL is reachable.

Task execution fails with timeout: Increase MOBICLAW_<AGENT>_TOOL_TIMEOUT_S for individual tool call timeouts for each agent (worker, steward, custom), or MOBICLAW_ROUTER_TIMEOUT_S (default 120s) for routing decisions, in .env. Restart the gateway after changes.

Out of memory or slow responses: Try a lighter model (e.g. google/gemini-3-flash-preview). Reduce MOBICLAW_ROUTING_MAX_SUBTASKS to limit parallel work.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.