diff --git a/skills/claw-setup/README.md b/skills/claw-setup/README.md index 759edb3..f4641d2 100644 --- a/skills/claw-setup/README.md +++ b/skills/claw-setup/README.md @@ -126,53 +126,71 @@ ### Quick Start ```bash -# Step 1: Install Qwen Code +# Step 1: Install Qwen Code CLI npm install -g @qwen-code/qwen-code@latest -# Step 2: Get FREE OAuth -qwen -/auth # Select "Qwen OAuth" → Browser login with qwen.ai +# Step 2: Get FREE OAuth (opens browser for login) +qwen --auth-type qwen-oauth -p "test" +# Credentials saved to: ~/.qwen/oauth_creds.json # Step 3: Import to ANY platform -source ~/.qwen/.env && openclaw -source ~/.qwen/.env && nanobot gateway -source ~/.qwen/.env && picoclaw gateway -source ~/.qwen/.env && zeroclaw gateway + +# ZeroClaw (native provider - auto token refresh) +cat > ~/.zeroclaw/config.toml << EOF +default_provider = "qwen-oauth" +default_model = "qwen3-coder-plus" +EOF + +# Other platforms (OpenAI-compatible) +export OPENAI_API_KEY=$(cat ~/.qwen/oauth_creds.json | jq -r '.access_token') +export OPENAI_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1" ``` ### Platform-Specific Import -#### OpenClaw + FREE Qwen +#### OpenClaw + FREE Qwen (OpenAI-Compatible) ```bash git clone https://github.com/openclaw/openclaw.git cd openclaw && npm install -export OPENAI_API_KEY=$(cat ~/.qwen/oauth-token.json | jq -r '.access_token') -export OPENAI_BASE_URL="https://api.qwen.ai/v1" +# Extract token from Qwen OAuth credentials +export OPENAI_API_KEY=$(cat ~/.qwen/oauth_creds.json | jq -r '.access_token') +export OPENAI_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1" export OPENAI_MODEL="qwen3-coder-plus" npm run start ``` -#### NanoBot + FREE Qwen +#### NanoBot + FREE Qwen (OpenAI-Compatible) ```bash pip install nanobot-ai -cat > ~/.nanobot/config.json << CONFIG -{ - "providers": { - "qwen": { - "apiKey": "$(cat ~/.qwen/oauth-token.json | jq -r '.access_token')", - "baseURL": "https://api.qwen.ai/v1" - } - }, - "agents": { "defaults": { "model": "qwen/qwen3-coder-plus" } } -} -CONFIG +# Extract token and configure +export OPENAI_API_KEY=$(cat ~/.qwen/oauth_creds.json | jq -r '.access_token') +export OPENAI_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1" +export OPENAI_MODEL="qwen3-coder-plus" nanobot gateway ``` +#### PicoClaw + FREE Qwen (OpenAI-Compatible) +```bash +# Extract token and set environment +export OPENAI_API_KEY=$(cat ~/.qwen/oauth_creds.json | jq -r '.access_token') +export OPENAI_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1" + +picoclaw gateway +``` + +#### NanoClaw + FREE Qwen (OpenAI-Compatible) +```bash +# Extract token and set environment +export OPENAI_API_KEY=$(cat ~/.qwen/oauth_creds.json | jq -r '.access_token') +export OPENAI_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1" + +nanoclaw +``` + #### ZeroClaw + FREE Qwen (NATIVE Provider) ```bash # Install ZeroClaw @@ -213,7 +231,7 @@ zeroclaw gateway │ ───────────────────────────────────────────────────── │ │ • Treats Qwen API as OpenAI-compatible endpoint │ │ • Extract access_token and use as OPENAI_API_KEY │ -│ • Set OPENAI_BASE_URL=https://api.qwen.ai/v1 │ +│ • Set OPENAI_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1 │ │ • Manual re-export needed when token expires │ │ │ │ COMPARISON: │ @@ -249,6 +267,22 @@ Qwen Code stores OAuth credentials in `~/.qwen/oauth_creds.json`: | `refresh_token` | Used to get new access_token when expired | | `expiry_date` | Unix timestamp when access_token expires | +### API Endpoints + +| Endpoint | URL | +|----------|-----| +| **API Base** | `https://dashscope.aliyuncs.com/compatible-mode/v1` | +| **Chat Completions** | `https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions` | +| **Token Refresh** | `https://chat.qwen.ai/api/v1/oauth2/token` | + +### Available Models (FREE Tier) + +| Model | Best For | +|-------|----------| +| `qwen3-coder-plus` | Coding (recommended) | +| `qwen3-coder-flash` | Fast coding | +| `qwen-max` | Complex tasks | + --- ## 🤖 FEATURE 2: 25+ AI Providers @@ -475,10 +509,11 @@ zeroclaw gateway ```bash # ~/.qwen/.env or ~/.config/claw/.env -# Qwen OAuth (FREE - from qwen && /auth) -OPENAI_API_KEY=$(cat ~/.qwen/oauth-token.json | jq -r '.access_token') -OPENAI_BASE_URL=https://api.qwen.ai/v1 -OPENAI_MODEL=qwen3-coder-plus +# Qwen OAuth (FREE - from qwen --auth-type qwen-oauth) +# Credentials stored in: ~/.qwen/oauth_creds.json +export OPENAI_API_KEY=$(cat ~/.qwen/oauth_creds.json | jq -r '.access_token') +export OPENAI_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1" +export OPENAI_MODEL="qwen3-coder-plus" # Or use paid providers ANTHROPIC_API_KEY=sk-ant-xxx @@ -571,8 +606,11 @@ source ~/.qwen/.env ### API Errors ```bash # Verify token is valid -curl -H "Authorization: Bearer $OPENAI_API_KEY" \ - https://api.qwen.ai/v1/models +QWEN_TOKEN=$(cat ~/.qwen/oauth_creds.json | jq -r '.access_token') +curl -X POST "https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions" \ + -H "Authorization: Bearer $QWEN_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{"model": "qwen3-coder-plus", "messages": [{"role": "user", "content": "Hello"}]}' # Check rate limits # FREE tier: 60 req/min, 2000/day diff --git a/skills/claw-setup/SKILL.md b/skills/claw-setup/SKILL.md index b7e3448..e440c23 100644 --- a/skills/claw-setup/SKILL.md +++ b/skills/claw-setup/SKILL.md @@ -1,14 +1,14 @@ --- name: claw-setup description: Use this skill when the user asks to "setup openclaw", "install nanobot", "deploy zeroclaw", "configure picoclaw", "setup qwen code", "import qwen oauth", "use free qwen tier", "configure AI providers", "add openai provider", "AI agent setup", or mentions setting up AI platforms. -version: 1.3.0 +version: 2.0.0 --- # Claw Setup Skill End-to-end professional setup of AI Agent platforms with **25+ OpenCode-compatible providers** and **FREE Qwen OAuth cross-platform import**. -## ⭐ Two Key Features +## Two Key Features ``` ┌─────────────────────────────────────────────────────────────────┐ @@ -21,6 +21,7 @@ End-to-end professional setup of AI Agent platforms with **25+ OpenCode-compatib │ • Works with: OpenClaw, NanoBot, PicoClaw, ZeroClaw │ │ • Model: Qwen3-Coder (optimized for coding) │ │ • Auth: Browser OAuth via qwen.ai │ +│ • Token refresh: Automatic (ZeroClaw) / Manual (others) │ │ │ │ FEATURE 2: 25+ OpenCode-Compatible AI Providers │ │ ───────────────────────────────────────────────── │ @@ -38,10 +39,10 @@ End-to-end professional setup of AI Agent platforms with **25+ OpenCode-compatib | Platform | Language | Memory | Qwen OAuth | All Providers | Best For | |----------|----------|--------|------------|---------------|----------| | **Qwen Code** | TypeScript | ~200MB | ✅ Native | ✅ | FREE coding | +| **ZeroClaw** | Rust | <5MB | ✅ Native | ✅ | Max performance | +| **PicoClaw** | Go | <10MB | ✅ Import | ✅ | Embedded | | **OpenClaw** | TypeScript | >1GB | ✅ Import | ✅ | Full-featured | | **NanoBot** | Python | ~100MB | ✅ Import | ✅ | Research | -| **PicoClaw** | Go | <10MB | ✅ Import | ✅ | Embedded | -| **ZeroClaw** | Rust | <5MB | ✅ Import | ✅ | Performance | | **NanoClaw** | TypeScript | ~50MB | ✅ Import | ✅ | WhatsApp | --- @@ -51,32 +52,80 @@ End-to-end professional setup of AI Agent platforms with **25+ OpenCode-compatib ## Get FREE Qwen OAuth ```bash -# Install Qwen Code +# Install Qwen Code CLI npm install -g @qwen-code/qwen-code@latest -# Authenticate (FREE) -qwen -/auth # Select "Qwen OAuth" → Browser login with qwen.ai +# Authenticate (FREE - opens browser) +qwen --auth-type qwen-oauth -p "test" # FREE: 2,000 requests/day, 60 req/min +# Credentials saved to: ~/.qwen/oauth_creds.json ``` -## Import to Any Platform +## Credentials File Structure + +```json +{ + "access_token": "your-access-token", + "refresh_token": "your-refresh-token", + "token_type": "Bearer", + "resource_url": "portal.qwen.ai", + "expiry_date": 1771774796531 +} +``` + +## API Endpoints + +| Endpoint | URL | +|----------|-----| +| **API Base** | `https://dashscope.aliyuncs.com/compatible-mode/v1` | +| **Chat Completions** | `/chat/completions` | +| **Token Refresh** | `https://chat.qwen.ai/api/v1/oauth2/token` | + +## Available Models (FREE Tier) + +| Model | Best For | +|-------|----------| +| `qwen3-coder-plus` | Coding (recommended) | +| `qwen3-coder-flash` | Fast coding | +| `qwen-max` | Complex tasks | + +## Import Methods + +### ZeroClaw (Native Provider - Auto Token Refresh) + +ZeroClaw has **built-in qwen-oauth provider** that handles token refresh automatically: + +```bash +# Configure ZeroClaw to use native qwen-oauth provider +cat > ~/.zeroclaw/config.toml << EOF +default_provider = "qwen-oauth" +default_model = "qwen3-coder-plus" +default_temperature = 0.7 +EOF + +# ZeroClaw automatically: +# • Reads ~/.qwen/oauth_creds.json +# • Refreshes expired tokens using refresh_token +# • Uses correct DashScope API endpoint + +zeroclaw agent -m "Hello!" +``` + +### Other Platforms (OpenAI-Compatible Import) + +For OpenClaw, NanoBot, PicoClaw, NanoClaw - use OpenAI-compatible endpoint: ```bash # Extract token -export QWEN_TOKEN=$(cat ~/.qwen/oauth-token.json | jq -r '.access_token') +export OPENAI_API_KEY=$(cat ~/.qwen/oauth_creds.json | jq -r '.access_token') +export OPENAI_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1" -# Configure for any platform -export OPENAI_API_KEY="$QWEN_TOKEN" -export OPENAI_BASE_URL="https://api.qwen.ai/v1" -export OPENAI_MODEL="qwen3-coder-plus" - -# Use with any platform! +# Use with any platform openclaw # OpenClaw with FREE Qwen nanobot # NanoBot with FREE Qwen picoclaw # PicoClaw with FREE Qwen -zeroclaw # ZeroClaw with FREE Qwen +nanoclaw # NanoClaw with FREE Qwen ``` --- @@ -87,7 +136,7 @@ zeroclaw # ZeroClaw with FREE Qwen | Provider | Free Tier | Model | Setup | |----------|-----------|-------|-------| -| **Qwen OAuth** | 2,000/day | Qwen3-Coder | `qwen && /auth` | +| **Qwen OAuth** | 2,000/day | Qwen3-Coder | `qwen --auth-type qwen-oauth` | ## Tier 2: Major AI Labs @@ -143,126 +192,29 @@ zeroclaw # ZeroClaw with FREE Qwen --- -# Multi-Provider Configuration - -## Full Configuration Example - -```json -{ - "providers": { - "qwen_oauth": { - "type": "oauth", - "free": true, - "daily_limit": 2000, - "model": "qwen3-coder-plus" - }, - "anthropic": { - "apiKey": "${ANTHROPIC_API_KEY}", - "baseURL": "https://api.anthropic.com" - }, - "openai": { - "apiKey": "${OPENAI_API_KEY}", - "baseURL": "https://api.openai.com/v1" - }, - "google": { - "apiKey": "${GOOGLE_API_KEY}", - "baseURL": "https://generativelanguage.googleapis.com/v1" - }, - "azure": { - "apiKey": "${AZURE_OPENAI_API_KEY}", - "baseURL": "${AZURE_OPENAI_ENDPOINT}" - }, - "vertex": { - "projectId": "${GOOGLE_CLOUD_PROJECT}", - "location": "${GOOGLE_CLOUD_LOCATION}" - }, - "bedrock": { - "region": "us-east-1", - "accessKeyId": "${AWS_ACCESS_KEY_ID}", - "secretAccessKey": "${AWS_SECRET_ACCESS_KEY}" - }, - "openrouter": { - "apiKey": "${OPENROUTER_API_KEY}", - "baseURL": "https://openrouter.ai/api/v1" - }, - "xai": { - "apiKey": "${XAI_API_KEY}", - "baseURL": "https://api.x.ai/v1" - }, - "mistral": { - "apiKey": "${MISTRAL_API_KEY}", - "baseURL": "https://api.mistral.ai/v1" - }, - "groq": { - "apiKey": "${GROQ_API_KEY}", - "baseURL": "https://api.groq.com/openai/v1" - }, - "cerebras": { - "apiKey": "${CEREBRAS_API_KEY}", - "baseURL": "https://api.cerebras.ai/v1" - }, - "deepinfra": { - "apiKey": "${DEEPINFRA_API_KEY}", - "baseURL": "https://api.deepinfra.com/v1" - }, - "cohere": { - "apiKey": "${COHERE_API_KEY}", - "baseURL": "https://api.cohere.ai/v1" - }, - "together": { - "apiKey": "${TOGETHER_API_KEY}", - "baseURL": "https://api.together.xyz/v1" - }, - "perplexity": { - "apiKey": "${PERPLEXITY_API_KEY}", - "baseURL": "https://api.perplexity.ai" - }, - "ollama": { - "baseURL": "http://localhost:11434/v1", - "apiKey": "ollama" - } - }, - "agents": { - "defaults": { - "model": "anthropic/claude-sonnet-4-5", - "temperature": 0.7 - }, - "free": { - "model": "qwen/qwen3-coder-plus" - }, - "fast": { - "model": "groq/llama-3.3-70b-versatile" - }, - "local": { - "model": "ollama/llama3.2:70b" - } - } -} -``` - -## Fetch Available Models +# Quick Import Script ```bash -# OpenRouter - All 100+ models -curl -s https://openrouter.ai/api/v1/models \ - -H "Authorization: Bearer $OPENROUTER_API_KEY" | jq '.data[].id' +#!/bin/bash +# Usage: source import-qwen-oauth.sh [platform] -# OpenAI - GPT models -curl -s https://api.openai.com/v1/models \ - -H "Authorization: Bearer $OPENAI_API_KEY" | jq '.data[].id' +CREDS_FILE="$HOME/.qwen/oauth_creds.json" +PLATFORM="${1:-zeroclaw}" -# Groq - Fast inference models -curl -s https://api.groq.com/openai/v1/models \ - -H "Authorization: Bearer $GROQ_API_KEY" | jq '.data[].id' +QWEN_TOKEN=$(cat "$CREDS_FILE" | jq -r '.access_token') -# Ollama - Local models -curl -s http://localhost:11434/api/tags | jq '.models[].name' - -# Anthropic (static list) -# claude-opus-4-5-20250219, claude-sonnet-4-5-20250219, claude-3-5-sonnet-20241022 - -# Google Gemini -curl -s "https://generativelanguage.googleapis.com/v1/models?key=$GOOGLE_API_KEY" +case "$PLATFORM" in + zeroclaw) + # Native provider - just set config + sed -i 's/^default_provider = .*/default_provider = "qwen-oauth"/' ~/.zeroclaw/config.toml + sed -i 's/^default_model = .*/default_model = "qwen3-coder-plus"/' ~/.zeroclaw/config.toml + ;; + *) + # OpenAI-compatible + export OPENAI_API_KEY="$QWEN_TOKEN" + export OPENAI_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1" + ;; +esac ``` --- @@ -272,7 +224,7 @@ curl -s "https://generativelanguage.googleapis.com/v1/models?key=$GOOGLE_API_KEY ## Qwen Code (Native FREE OAuth) ```bash npm install -g @qwen-code/qwen-code@latest -qwen && /auth +qwen --auth-type qwen-oauth -p "test" ``` ## OpenClaw @@ -313,8 +265,24 @@ chmod +x zeroclaw-linux-amd64 && sudo mv zeroclaw-linux-amd64 /usr/local/bin/zer --- -# Automation Scripts +# Troubleshooting -See `scripts/` directory: -- `import-qwen-oauth.sh` - Import FREE Qwen OAuth to any platform -- `fetch-models.sh` - Fetch available models from all providers +## Token Expired + +```bash +# ZeroClaw: Automatic refresh (no action needed) + +# Other platforms: Re-authenticate and re-export +qwen --auth-type qwen-oauth -p "test" +export OPENAI_API_KEY=$(cat ~/.qwen/oauth_creds.json | jq -r '.access_token') +``` + +## API Test + +```bash +QWEN_TOKEN=$(cat ~/.qwen/oauth_creds.json | jq -r '.access_token') +curl -X POST "https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions" \ + -H "Authorization: Bearer $QWEN_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{"model": "qwen3-coder-plus", "messages": [{"role": "user", "content": "Hello"}]}' +``` diff --git a/skills/claw-setup/scripts/import-qwen-oauth.sh b/skills/claw-setup/scripts/import-qwen-oauth.sh index 125aa97..1045843 100755 --- a/skills/claw-setup/scripts/import-qwen-oauth.sh +++ b/skills/claw-setup/scripts/import-qwen-oauth.sh @@ -1,99 +1,202 @@ #!/bin/bash -# import-qwen-oauth.sh - Import Qwen OAuth to any platform -# Usage: source import-qwen-oauth.sh && +# Import FREE Qwen OAuth to any Claw platform +# Usage: source import-qwen-oauth.sh [platform] +# +# Platforms: +# zeroclaw - Native qwen-oauth provider (recommended, auto token refresh) +# picoclaw - OpenAI-compatible import +# openclaw - OpenAI-compatible import +# nanobot - OpenAI-compatible import +# nanoclaw - OpenAI-compatible import +# +# Requirements: +# - qwen-code CLI installed: npm install -g @qwen-code/qwen-code@latest +# - jq for JSON parsing +# - Authenticated: qwen --auth-type qwen-oauth -p "test" set -e -echo "╔═══════════════════════════════════════════════════════════════╗" -echo "║ QWEN OAUTH CROSS-PLATFORM IMPORTER ║" -echo "║ FREE: 2,000 requests/day, 60 req/min ║" -echo "╚═══════════════════════════════════════════════════════════════╝" +CREDS_FILE="$HOME/.qwen/oauth_creds.json" +PLATFORM="${1:-zeroclaw}" -# Check if Qwen Code is installed -if ! command -v qwen &> /dev/null; then - echo "📦 Qwen Code not found. Installing..." - npm install -g @qwen-code/qwen-code@latest -fi +# Colors +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' # No Color -# Check if Qwen Code is authenticated -if [ ! -d ~/.qwen ]; then +echo "🦞 Claw Setup - Qwen OAuth Import" +echo "==================================" +echo "" + +# Check for credentials file +if [ ! -f "$CREDS_FILE" ]; then + echo -e "${RED}Error: Qwen OAuth credentials not found${NC}" + echo "File expected at: $CREDS_FILE" echo "" - echo "❌ Qwen Code not authenticated." + echo "To authenticate, run:" + echo " npm install -g @qwen-code/qwen-code@latest" + echo " qwen --auth-type qwen-oauth -p 'test'" echo "" - echo "Please run:" - echo " qwen" - echo " /auth # Select 'Qwen OAuth'" - echo "" - echo "Then run this script again." + echo "This will open a browser for FREE OAuth login." exit 1 fi -# Find OAuth token file -TOKEN_FILES=$(find ~/.qwen -name "*.json" -type f 2>/dev/null) -if [ -z "$TOKEN_FILES" ]; then - echo "❌ No OAuth token found in ~/.qwen/" - echo " Please authenticate first: qwen && /auth" - exit 1 +# Check for jq +if ! command -v jq &> /dev/null; then + echo -e "${YELLOW}Warning: jq not found, using grep/sed fallback${NC}" + QWEN_TOKEN=$(cat "$CREDS_FILE" | grep -o '"access_token"[[:space:]]*:[[:space:]]*"[^"]*"' | sed 's/.*"access_token"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/') +else + QWEN_TOKEN=$(cat "$CREDS_FILE" | jq -r '.access_token') fi -# Try to extract token from various file formats -QWEN_TOKEN="" -for TOKEN_FILE in $TOKEN_FILES; do - # Try different JSON structures - QWEN_TOKEN=$(cat "$TOKEN_FILE" | jq -r '.access_token // .token // .accessToken // .credentials?.token // empty' 2>/dev/null) - if [ -n "$QWEN_TOKEN" ] && [ "$QWEN_TOKEN" != "null" ]; then - echo "✅ Found token in: $TOKEN_FILE" - break - fi -done - if [ -z "$QWEN_TOKEN" ] || [ "$QWEN_TOKEN" = "null" ]; then - echo "❌ Could not extract OAuth token" - echo " Token files found but no valid token structure" - echo " Try re-authenticating: qwen && /auth" + echo -e "${RED}Error: Could not extract access_token from credentials${NC}" + echo "Credentials file may be corrupted. Try re-authenticating:" + echo " qwen --auth-type qwen-oauth -p 'test'" exit 1 fi -# Export environment variables -export OPENAI_API_KEY="$QWEN_TOKEN" -export OPENAI_BASE_URL="https://api.qwen.ai/v1" -export OPENAI_MODEL="qwen3-coder-plus" +echo "Platform: $PLATFORM" +echo "Token: ${QWEN_TOKEN:0:20}..." +echo "" -# Save to .env for persistence -mkdir -p ~/.qwen -cat > ~/.qwen/.env << ENVEOF -# Qwen OAuth Configuration for Cross-Platform Use -# Generated: $(date) -OPENAI_API_KEY=$QWEN_TOKEN -OPENAI_BASE_URL=https://api.qwen.ai/v1 -OPENAI_MODEL=qwen3-coder-plus +case "$PLATFORM" in + zeroclaw) + # ZeroClaw uses native qwen-oauth provider + CONFIG_FILE="$HOME/.zeroclaw/config.toml" -# Usage: -# source ~/.qwen/.env && openclaw -# source ~/.qwen/.env && nanobot gateway -# source ~/.qwen/.env && picoclaw gateway -# source ~/.qwen/.env && zeroclaw gateway -ENVEOF + if [ ! -f "$CONFIG_FILE" ]; then + echo -e "${YELLOW}ZeroClaw config not found, creating...${NC}" + mkdir -p "$HOME/.zeroclaw" + cat > "$CONFIG_FILE" << 'EOF' +default_provider = "qwen-oauth" +default_model = "qwen3-coder-plus" +default_temperature = 0.7 -chmod 600 ~/.qwen/.env +[autonomy] +level = "supervised" +workspace_only = true + +[memory] +backend = "sqlite" +EOF + else + # Update existing config + sed -i 's/^default_provider = .*/default_provider = "qwen-oauth"/' "$CONFIG_FILE" + sed -i 's/^default_model = .*/default_model = "qwen3-coder-plus"/' "$CONFIG_FILE" + fi + + echo -e "${GREEN}✅ ZeroClaw configured with native qwen-oauth provider${NC}" + echo "" + echo "ZeroClaw automatically:" + echo " • Reads ~/.qwen/oauth_creds.json" + echo " • Refreshes expired tokens" + echo " • Uses correct DashScope API endpoint" + echo "" + echo "Test with:" + echo " zeroclaw agent -m 'Hello!'" + ;; + + picoclaw) + export OPENAI_API_KEY="$QWEN_TOKEN" + export OPENAI_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1" + + echo -e "${GREEN}✅ PicoClaw environment configured${NC}" + echo "" + echo "Environment variables set:" + echo " OPENAI_API_KEY=${QWEN_TOKEN:0:20}..." + echo " OPENAI_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1" + echo "" + echo "Test with:" + echo " picoclaw agent -m 'Hello!'" + ;; + + openclaw) + export OPENAI_API_KEY="$QWEN_TOKEN" + export OPENAI_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1" + + echo -e "${GREEN}✅ OpenClaw environment configured${NC}" + echo "" + echo "Environment variables set:" + echo " OPENAI_API_KEY=${QWEN_TOKEN:0:20}..." + echo " OPENAI_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1" + echo "" + echo "Test with:" + echo " openclaw" + ;; + + nanobot) + export OPENAI_API_KEY="$QWEN_TOKEN" + export OPENAI_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1" + export OPENAI_MODEL="qwen3-coder-plus" + + echo -e "${GREEN}✅ NanoBot environment configured${NC}" + echo "" + echo "Environment variables set:" + echo " OPENAI_API_KEY=${QWEN_TOKEN:0:20}..." + echo " OPENAI_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1" + echo " OPENAI_MODEL=qwen3-coder-plus" + echo "" + echo "Test with:" + echo " nanobot" + ;; + + nanoclaw) + export OPENAI_API_KEY="$QWEN_TOKEN" + export OPENAI_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1" + + echo -e "${GREEN}✅ NanoClaw environment configured${NC}" + echo "" + echo "Environment variables set:" + echo " OPENAI_API_KEY=${QWEN_TOKEN:0:20}..." + echo " OPENAI_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1" + echo "" + echo "Test with:" + echo " nanoclaw" + ;; + + all) + # Configure all platforms + echo "Configuring all platforms..." + echo "" + + # ZeroClaw + CONFIG_FILE="$HOME/.zeroclaw/config.toml" + if [ -f "$CONFIG_FILE" ]; then + sed -i 's/^default_provider = .*/default_provider = "qwen-oauth"/' "$CONFIG_FILE" + sed -i 's/^default_model = .*/default_model = "qwen3-coder-plus"/' "$CONFIG_FILE" + echo -e "${GREEN}✅ ZeroClaw${NC}" + fi + + # Set environment for other platforms + export OPENAI_API_KEY="$QWEN_TOKEN" + export OPENAI_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1" + + echo -e "${GREEN}✅ PicoClaw, OpenClaw, NanoBot, NanoClaw${NC}" + echo "" + echo "Environment exported for current session." + echo "Add to ~/.bashrc for persistence:" + echo "" + echo 'export OPENAI_API_KEY="$(cat ~/.qwen/oauth_creds.json | jq -r '\''.access_token'\'')"' >> ~/.bashrc + echo 'export OPENAI_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1"' >> ~/.bashrc + ;; + + *) + # Generic - set environment variables + export OPENAI_API_KEY="$QWEN_TOKEN" + export OPENAI_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1" + + echo -e "${GREEN}✅ Generic environment configured for $PLATFORM${NC}" + echo "" + echo "Environment variables set:" + echo " OPENAI_API_KEY=${QWEN_TOKEN:0:20}..." + echo " OPENAI_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1" + ;; +esac echo "" -echo "✅ Qwen OAuth imported successfully!" -echo "" -echo " OPENAI_API_KEY=***${QWEN_TOKEN: -8}" -echo " OPENAI_BASE_URL=$OPENAI_BASE_URL" -echo " OPENAI_MODEL=$OPENAI_MODEL" -echo "" -echo "✅ Configuration saved to ~/.qwen/.env" -echo "" -echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -echo "Usage with platforms:" -echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -echo "" -echo " source ~/.qwen/.env && openclaw" -echo " source ~/.qwen/.env && nanobot gateway" -echo " source ~/.qwen/.env && picoclaw gateway" -echo " source ~/.qwen/.env && zeroclaw gateway" -echo "" -echo "Free tier limits: 2,000 requests/day, 60 requests/minute" -echo "" +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" +echo "FREE Qwen OAuth: 2,000 requests/day, 60 req/min" +echo "API Endpoint: https://dashscope.aliyuncs.com/compatible-mode/v1" +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"