$ErrorActionPreference = "Stop" $BaseUrl = if ($env:TEZZ_INSTALL_BASE) { $env:TEZZ_INSTALL_BASE } else { "https://tn.tezzcorp.com/download" } $InstallDir = if ($env:TEZZ_INSTALL_DIR) { $env:TEZZ_INSTALL_DIR } else { Join-Path $HOME "TezzNative" } $ZipPath = Join-Path $env:TEMP "tezznative-sdk.zip" $ApiBase = if ($env:TEZZ_API_BASE) { $env:TEZZ_API_BASE } else { ($BaseUrl -replace "/download/?$", "") + "/api" } $InstallId = if ($env:TEZZ_INSTALL_ID) { $env:TEZZ_INSTALL_ID } else { "win-" + [guid]::NewGuid().ToString() } function Send-InstallEvent { param( [string]$Status, [string]$Message ) try { Invoke-RestMethod -Method Post -Uri "$ApiBase/install_event" -Body @{ platform = "windows" version = "1.0.0" status = $Status install_id = $InstallId message = $Message } | Out-Null } catch { } } try { Write-Host "Downloading TezzNative SDK..." Invoke-WebRequest -Uri "$BaseUrl/tezznative-sdk.zip" -OutFile $ZipPath if (Test-Path $InstallDir) { Remove-Item -Recurse -Force $InstallDir } New-Item -ItemType Directory -Path $InstallDir | Out-Null Expand-Archive -Path $ZipPath -DestinationPath $InstallDir -Force Remove-Item $ZipPath -Force $SdkDir = Join-Path $InstallDir "sdk" $BinDir = Join-Path $HOME "bin" if (-not (Test-Path $BinDir)) { New-Item -ItemType Directory -Path $BinDir | Out-Null } $CmdShimPath = Join-Path $BinDir "tezz.cmd" $PsShimPath = Join-Path $BinDir "tezz.ps1" $TezzcShimPath = Join-Path $BinDir "tezzc.cmd" $TezzcExe = Join-Path $SdkDir "bin\\tezzc-windows-x64.exe" $CmdShim = "@echo off`r`n""$SdkDir\tezz.cmd"" %*`r`n" $PsShim = "& ""$SdkDir\tezz.ps1"" @args`r`n" Set-Content -Path $CmdShimPath -Value $CmdShim -Encoding ASCII Set-Content -Path $PsShimPath -Value $PsShim -Encoding ASCII if (Test-Path $TezzcExe) { $TezzcShim = "@echo off`r`n""$TezzcExe"" %*`r`n" Set-Content -Path $TezzcShimPath -Value $TezzcShim -Encoding ASCII } Write-Host "" Write-Host "TezzNative installed to $InstallDir" Write-Host "Add $BinDir to PATH, then run:" Write-Host " tezz doctor" Write-Host " tezz run hello.tn" Send-InstallEvent -Status "success" -Message "sdk installed" } catch { Send-InstallEvent -Status "failed" -Message $_.Exception.Message throw }