# LyDos Universal Installer — Windows PowerShell # # Usage: # irm https://lydos.ailydian.com/install.ps1 | iex # # Requirements: PowerShell 5.1+, Python 3.9+, Git # Mock/demo YASAK. param( [string]$Locale = "", [switch]$Quiet = $false, [switch]$NoLogin = $false, [string]$Prefix = "$env:LOCALAPPDATA\lydos" ) $ErrorActionPreference = "Stop" $ProgressPreference = "SilentlyContinue" $LYDOS_API = if ($env:LYDOS_API) { $env:LYDOS_API } else { "https://lydos.ailydian.com" } $REPO = "https://github.com/lydianai/AILYDIAN-AGENT-ORCHESTRATOR.git" $StateDir = Join-Path $env:USERPROFILE ".lydos" $BinDir = Join-Path $Prefix "bin" $Workspace = Join-Path $Prefix "checkout" $LydosBin = Join-Path $BinDir "lydos.cmd" $LydosPy = Join-Path $BinDir "lydos.py" # ─── Locale auto-detect ──────────────────────────────────────────────────── function Detect-Locale { if ($Locale) { return $Locale } try { $culture = (Get-Culture).TwoLetterISOLanguageName $supported = @("tr","en","de","fr","es","ar","zh","ja","pt","ru","it","ko") if ($supported -contains $culture) { return $culture } } catch { } return "en" } $Lang = Detect-Locale function Msg($key) { $m = @{ "tr_start" = "LyDos kurulumu başlıyor…" "en_start" = "LyDos installation starting…" "tr_os_detect" = "Sistem tespit ediliyor…" "en_os_detect" = "Detecting system…" "tr_deps_check" = "Bağımlılıklar kontrol ediliyor…" "en_deps_check" = "Checking dependencies…" "tr_installing" = "LyDos kopyalanıyor…" "en_installing" = "Copying LyDos…" "tr_task" = "Arka plan görevi kuruluyor…" "en_task" = "Setting up background task…" "tr_done" = "✓ Kurulum tamamlandı." "en_done" = "✓ Installation complete." "tr_login_prompt" = "Giriş yapmak için: lydos login" "en_login_prompt" = "Run 'lydos login' to authenticate" } $k = "${Lang}_${key}" if ($m.ContainsKey($k)) { return $m[$k] } if ($m.ContainsKey("en_${key}")) { return $m["en_${key}"] } return $key } function Log($msg) { if (-not $Quiet) { Write-Host " [lydos] $msg" } } Log (Msg "start") # ─── Dependency check ────────────────────────────────────────────────────── Log (Msg "deps_check") $missing = @() foreach ($cmd in @("git","python","python3")) { $ok = Get-Command $cmd -ErrorAction SilentlyContinue if (-not $ok -and $cmd -eq "git") { $missing += "git" } } # Python3 vs python discovery $PythonExe = $null foreach ($p in @("python3","python","py")) { $found = Get-Command $p -ErrorAction SilentlyContinue if ($found) { $ver = & $p -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')" 2>$null if ($ver -and [version]$ver -ge [version]"3.9") { $PythonExe = $found.Source break } } } if (-not $PythonExe) { Write-Host "[lydos] ERROR: Python 3.9+ required." -ForegroundColor Red Write-Host "[lydos] Install: winget install Python.Python.3.12" -ForegroundColor Yellow exit 4 } if ($missing.Count -gt 0) { Write-Host "[lydos] MISSING: $($missing -join ', ')" -ForegroundColor Red Write-Host "[lydos] Install: winget install Git.Git" -ForegroundColor Yellow exit 3 } Log "Python: $PythonExe" Log "$(Msg 'os_detect'): Windows ($([System.Environment]::OSVersion.Version)) (lang=$Lang)" # ─── Workspace ───────────────────────────────────────────────────────────── Log (Msg "installing") New-Item -ItemType Directory -Force -Path $BinDir, $StateDir, $Prefix | Out-Null if (Test-Path (Join-Path $Workspace ".git")) { Push-Location $Workspace try { git pull --ff-only --quiet 2>$null } catch { Log "(update skipped)" } Pop-Location } else { if (Test-Path $Workspace) { Remove-Item -Recurse -Force $Workspace } git clone --depth 1 --quiet $REPO $Workspace 2>$null if ($LASTEXITCODE -ne 0) { Write-Host "[lydos] ERROR: git clone failed" -ForegroundColor Red exit 5 } } # ─── Create lydos.cmd wrapper ────────────────────────────────────────────── Copy-Item -Force (Join-Path $Workspace "scripts\lydos") $LydosPy $cmdContent = @" @echo off "$PythonExe" "$LydosPy" %* "@ Set-Content -Path $LydosBin -Value $cmdContent -Encoding ASCII # Add to PATH (user) $userPath = [Environment]::GetEnvironmentVariable("Path", "User") if ($userPath -notlike "*$BinDir*") { $newPath = if ($userPath) { "$userPath;$BinDir" } else { $BinDir } [Environment]::SetEnvironmentVariable("Path", $newPath, "User") Log "PATH updated (user scope) — restart shell to apply" } # ─── Scheduled Task for Q158 background ──────────────────────────────────── Log (Msg "task") try { $taskName = "LyDosQ158Autonomous" $existing = Get-ScheduledTask -TaskName $taskName -ErrorAction SilentlyContinue if ($existing) { Unregister-ScheduledTask -TaskName $taskName -Confirm:$false -ErrorAction SilentlyContinue } $action = New-ScheduledTaskAction -Execute $PythonExe -Argument "`"$LydosPy`" status" $trigger = New-ScheduledTaskTrigger -Once -At (Get-Date).AddMinutes(1) ` -RepetitionInterval (New-TimeSpan -Minutes 5) $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries ` -DontStopIfGoingOnBatteries -StartWhenAvailable Register-ScheduledTask -TaskName $taskName -Action $action -Trigger $trigger ` -Settings $settings -Description "LyDos 47 autonomous engineers (KURAL 28)" ` -Force | Out-Null Log "Scheduled Task: $taskName (every 5 min)" } catch { Log "(scheduled task setup skipped: $_)" } Log (Msg "done") Log "Binary : $LydosBin" Log "Workspace : $Workspace" Log "State : $StateDir" Log "" Log (Msg "login_prompt") if (-not $NoLogin) { try { & $LydosBin login 2>$null } catch { } } exit 0