-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
164 lines (142 loc) · 7.45 KB
/
Copy pathinstall.ps1
File metadata and controls
164 lines (142 loc) · 7.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# ┌─────────────────────────────────────────────────────┐
# │ latebra v0.2.0 — Single-Command Windows Installer │
# │ irm https://latebra.evandro.app/install.ps1 | iex │
# │ Autor: Evandro Fonseca Junior │
# │ Licença: MIT │
# └─────────────────────────────────────────────────────┘
#Requires -Version 7.0
param(
[string]$InstallDir = "$env:USERPROFILE\.latebra",
[string]$Version = "0.2.0",
[switch]$NoBrowser = $false,
[string]$RepoUrl = "https://github.com/evandrodevbr/latebra.git"
)
$ErrorActionPreference = "Stop"
$ProgressPreference = "SilentlyContinue"
# ── Banner ───────────────────────────────────────
Write-Host ""
Write-Host "╔════════════════════════════════════════╗" -ForegroundColor Cyan
Write-Host "║ 🕶️ latebra anti-bot MCP installer ║" -ForegroundColor Cyan
Write-Host "╚════════════════════════════════════════╝" -ForegroundColor Cyan
Write-Host ""
# ── Helpers ──────────────────────────────────────
function Write-Info { Write-Host "→ $args" -ForegroundColor Cyan }
function Write-OK { Write-Host "✓ $args" -ForegroundColor Green }
function Write-Warn { Write-Host "⚠ $args" -ForegroundColor Yellow }
function Write-Err { Write-Host "✗ $args" -ForegroundColor Red; exit 1 }
# ── Pre-flight checks ────────────────────────────
Write-Info "Verificando requisitos..."
$python = Get-Command python -ErrorAction SilentlyContinue
if (-not $python) {
$python = Get-Command python3 -ErrorAction SilentlyContinue
}
if (-not $python) {
Write-Err "Python não encontrado. Instale: winget install Python.Python.3.12"
}
$pyVersion = & $python.Source -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')"
$pyMajor = [int]($pyVersion -split '\.')[0]
$pyMinor = [int]($pyVersion -split '\.')[1]
if ($pyMajor -lt 3 -or ($pyMajor -eq 3 -and $pyMinor -lt 12)) {
Write-Err "Python 3.12+ é necessário (atual: $pyVersion). Instale via winget: winget install Python.Python.3.12"
}
if (-not (Get-Command git -ErrorAction SilentlyContinue)) {
Write-Err "Git não encontrado. Instale: winget install Git.Git"
}
Write-OK "Python $pyVersion encontrado"
# ── Criar diretório ──────────────────────────────
New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null
# ── Virtual environment ──────────────────────────
$VenvDir = Join-Path $InstallDir "venv"
if (-not (Test-Path $VenvDir)) {
Write-Info "Criando ambiente virtual em $VenvDir..."
& $python.Source -m venv $VenvDir
Write-OK "Ambiente virtual criado"
} else {
Write-Info "Ambiente virtual existente em $VenvDir"
}
# ── Activar venv ─────────────────────────────────
$VenvPython = Join-Path $VenvDir "Scripts" "python.exe"
$VenvPip = Join-Path $VenvDir "Scripts" "pip.exe"
# ── Instalar latebra ─────────────────────────────
$RepoDir = Join-Path $InstallDir "repo"
if (Test-Path (Join-Path $RepoDir "pyproject.toml")) {
Write-Info "Repositório existente, atualizando via git pull..."
Push-Location $RepoDir
git pull --ff-only origin main 2>$null
Pop-Location
} else {
Write-Info "Clonando latebra v$Version..."
git clone --branch main $RepoUrl $RepoDir 2>$null
if (-not (Test-Path (Join-Path $RepoDir "pyproject.toml"))) {
Write-Info "Repo não disponível, instalando via pip..."
$RepoDir = $null
}
}
Push-Location (if ($RepoDir) { $RepoDir } else { $InstallDir })
Write-Info "Instalando latebra..."
& $VenvPip install --upgrade pip --quiet 2>$null
if ($RepoDir) {
& $VenvPip install -e ".[all]" --quiet 2>$null
} else {
& $VenvPip install "latebra[all]>=${Version}" --quiet 2>$null
}
Write-OK "latebra $Version instalado"
Pop-Location
# ── Post-install: navegadores + verificação ──────
Write-Info "Executando latebra install (browsers)..."
$LatebraInstall = & $VenvPython -m latebra install 2>&1
if ($LASTEXITCODE -eq 0) {
Write-OK "latebra install concluído"
} else {
Write-Warn "latebra install reportou erros (browsers opcionais)"
}
# ── Verificar latebra-mcp.exe ────────────────────
$LatebraMcpExe = Join-Path $VenvDir "Scripts" "latebra-mcp.exe"
if (Test-Path $LatebraMcpExe) {
Write-OK "latebra-mcp.exe disponível em: $LatebraMcpExe"
} else {
Write-Warn "latebra-mcp.exe não encontrado — usando python -m latebra run"
$LatebraMcpExe = $VenvPython
$LatebraMcpArgs = @("-m", "latebra", "run")
}
# ── Configurar MCP (Claude Desktop) ──────────────
$ClaudeConfigPath = Join-Path $env:APPDATA "Claude" "claude_desktop_config.json"
if (Test-Path $ClaudeConfigPath) {
$config = Get-Content $ClaudeConfigPath -Raw -Encoding utf8 | ConvertFrom-Json -AsHashtable
if (-not $config.mcpServers) { $config.mcpServers = @{} }
if (-not $config.mcpServers.latebra) {
Write-Info "Configurando MCP no Claude Desktop..."
$config.mcpServers.latebra = @{
command = $LatebraMcpExe
args = @()
env = @{
LATEBRA_PROXIES = $env:LATEBRA_PROXIES ?? ""
LATEBRA_2CAPTCHA_KEY = $env:LATEBRA_2CAPTCHA_KEY ?? ""
PYTHONUTF8 = "1"
PYTHONIOENCODING = "utf-8"
}
}
$config | ConvertTo-Json -Depth 10 | Set-Content $ClaudeConfigPath -Encoding UTF8
Write-OK "MCP configurado em: $ClaudeConfigPath"
} else {
Write-Info "MCP já configurado"
}
} else {
Write-Warn "Claude Desktop não encontrado. Adicione manualmente ao seu cliente MCP:"
Write-Host " Comando: $LatebraMcpExe $($LatebraMcpArgs -join ' ')"
}
# ── Wrap-up ──────────────────────────────────────
Write-Host ""
Write-Host "╔══════════════════════════════════════════════╗" -ForegroundColor Green
Write-Host "║ 🕶️ latebra instalado com sucesso! ║" -ForegroundColor Green
Write-Host "╚══════════════════════════════════════════════╝" -ForegroundColor Green
Write-Host ""
Write-Host " Shell: $VenvDir\Scripts\Activate.ps1"
Write-Host " Testar: latebra-mcp --version"
Write-Host " Atualizar: python -m latebra install"
Write-Host " Diretório: $InstallDir"
Write-Host ""
Write-Host " Variáveis de ambiente opcionais:" -ForegroundColor Yellow
Write-Host " `$env:LATEBRA_PROXIES — proxy1,proxy2,..."
Write-Host " `$env:LATEBRA_2CAPTCHA_KEY — chave API 2Captcha"
Write-Host ""