# Installs agentcloudctl and agentcloud-mcp from GitHub releases (Windows). # Env overrides: AGENTCLOUD_VERSION (e.g. v0.1.0), AGENTCLOUD_INSTALL_DIR, AGENTCLOUD_BINARIES. # Wrapped in a script block so `irm ... | iex` doesn't leak preferences into the caller's session. & { $ErrorActionPreference = 'Stop' $ProgressPreference = 'SilentlyContinue' [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 $repo = 'omid-zaman/agentcloud' $version = if ($env:AGENTCLOUD_VERSION) { $env:AGENTCLOUD_VERSION } else { 'latest' } $installDir = if ($env:AGENTCLOUD_INSTALL_DIR) { $env:AGENTCLOUD_INSTALL_DIR } else { Join-Path $env:LOCALAPPDATA 'AgentCloud\bin' } $binaries = if ($env:AGENTCLOUD_BINARIES) { $env:AGENTCLOUD_BINARIES -split '\s+' } else { @('agentcloudctl', 'agentcloud-mcp') } $arch = switch ($env:PROCESSOR_ARCHITECTURE) { 'AMD64' { 'amd64' } 'ARM64' { 'arm64' } default { throw "unsupported architecture '$env:PROCESSOR_ARCHITECTURE'" } } $base = if ($version -eq 'latest') { "https://github.com/$repo/releases/latest/download" } else { "https://github.com/$repo/releases/download/$version" } $tmp = Join-Path ([IO.Path]::GetTempPath()) ("agentcloud-" + [guid]::NewGuid()) New-Item -ItemType Directory -Path $tmp | Out-Null try { $sumsFile = Join-Path $tmp 'checksums.txt' Invoke-WebRequest "$base/checksums.txt" -OutFile $sumsFile -UseBasicParsing $sums = @{} foreach ($line in Get-Content $sumsFile) { $parts = $line.Trim() -split '\s+' if ($parts.Count -eq 2) { $sums[$parts[1].TrimStart('*')] = $parts[0].ToLowerInvariant() } } New-Item -ItemType Directory -Force -Path $installDir | Out-Null foreach ($bin in $binaries) { $asset = "$bin-windows-$arch.exe" $file = Join-Path $tmp $asset Invoke-WebRequest "$base/$asset" -OutFile $file -UseBasicParsing if (-not $sums.ContainsKey($asset)) { throw "no checksum listed for $asset" } $actual = (Get-FileHash $file -Algorithm SHA256).Hash.ToLowerInvariant() if ($actual -ne $sums[$asset]) { throw "checksum mismatch for $asset" } $target = Join-Path $installDir "$bin.exe" Copy-Item $file $target -Force Write-Host "installed $target" } } finally { Remove-Item $tmp -Recurse -Force -ErrorAction SilentlyContinue } $userPath = [string][Environment]::GetEnvironmentVariable('Path', 'User') if (($userPath -split ';') -notcontains $installDir) { $newPath = (($userPath.TrimEnd(';'), $installDir) | Where-Object { $_ }) -join ';' [Environment]::SetEnvironmentVariable('Path', $newPath, 'User') $env:Path = "$env:Path;$installDir" Write-Host "added $installDir to your user PATH (open a new terminal to pick it up)" } }