<#
.SYNOPSIS
Setup and run PraisonAI OpenClaw on Windows
.DESCRIPTION
Creates venv, installs dependencies, and launches OpenClaw daemon
.PARAMETER ProjectPath
Directory to create/use for the project (default: current directory)
.PARAMETER VenvPath
Virtual environment path (default: .venv)
.PARAMETER LaunchDashboard
Whether to launch the dashboard after setup
#>
param(
[string]$ProjectPath = ".",
[string]$VenvPath = ".venv",
[switch]$LaunchDashboard = $true
)
$ErrorActionPreference = "Stop"
# Resolve absolute paths
$ProjectDir = Resolve-Path $ProjectPath
$VenvDir = Join-Path $ProjectDir $VenvPath
Write-Host "🦞 PraisonAI OpenClaw Windows Setup" -ForegroundColor Cyan
Write-Host "Project: $ProjectDir" -ForegroundColor Green
# Check Python availability
try {
$PythonCmd = Get-Command python -ErrorAction Stop
Write-Host "Python found: $($PythonCmd.Source)" -ForegroundColor Green
} catch {
Write-Error "Python not found. Install Python 3.8+ and add to PATH"
}
# Create venv if it doesn't exist
if (!(Test-Path $VenvDir)) {
Write-Host "Creating virtual environment..." -ForegroundColor Yellow
python -m venv $VenvDir
}
# Activate venv
$ActivateScript = Join-Path $VenvDir "Scripts\Activate.ps1"
if (Test-Path $ActivateScript) {
Write-Host "Activating virtual environment..." -ForegroundColor Yellow
& $ActivateScript
} else {
Write-Error "Virtual environment activation script not found: $ActivateScript"
}
# Verify we're in venv
$VenvPython = Join-Path $VenvDir "Scripts\python.exe"
if (Test-Path $VenvPython) {
Write-Host "Using venv Python: $VenvPython" -ForegroundColor Green
} else {
Write-Error "Virtual environment Python not found"
}
# Install PraisonAI with extras
Write-Host "Installing PraisonAI with OpenClaw..." -ForegroundColor Yellow
& $VenvPython -m pip install --upgrade pip
& $VenvPython -m pip install "praisonai[agents,tools,claw]"
# Verify installation
Write-Host "Verifying installation..." -ForegroundColor Yellow
$PraisonCmd = Join-Path $VenvDir "Scripts\praisonai.exe"
if (Test-Path $PraisonCmd) {
& $PraisonCmd --version
Write-Host "Installation verified: $PraisonCmd" -ForegroundColor Green
} else {
Write-Error "PraisonAI command not found in venv"
}
# Create .env if it doesn't exist
$EnvFile = Join-Path $ProjectDir ".env"
if (!(Test-Path $EnvFile)) {
Write-Host "Creating .env template..." -ForegroundColor Yellow
@'
# OpenAI API Key (required)
OPENAI_API_KEY=your-api-key-here
# Optional: Other LLM providers
# ANTHROPIC_API_KEY=your-anthropic-key
# GOOGLE_API_KEY=your-google-key
# Python path
PYTHONPATH=.
'@ | Out-File -FilePath $EnvFile -Encoding utf8
Write-Host "Created $EnvFile - Please add your API keys" -ForegroundColor Yellow
}
# Print diagnostics
Write-Host "`n📊 Environment Diagnostics:" -ForegroundColor Cyan
Write-Host "Working Directory: $(Get-Location)"
Write-Host "Python Path: $VenvPython"
Write-Host "PraisonAI Path: $PraisonCmd"
Write-Host "Environment File: $EnvFile"
# Launch dashboard if requested
if ($LaunchDashboard -and (Test-Path $EnvFile)) {
Write-Host "`n🚀 Launching OpenClaw Dashboard..." -ForegroundColor Cyan
Write-Host "Dashboard will open at http://localhost:8082" -ForegroundColor Green
& $PraisonCmd claw
}