feat: open WebUI after fresh desktop install
This commit is contained in:
+43
-4
@@ -42,7 +42,7 @@ function Show-Usage {
|
||||
Write-Host ""
|
||||
Write-Host "By default this installs or upgrades nanobot-ai from PyPI."
|
||||
Write-Host "Use --dev to install from the current main branch on GitHub."
|
||||
Write-Host "Use --dry-run to print what would happen without installing or starting the wizard."
|
||||
Write-Host "Use --dry-run to print what would happen without installing or starting setup."
|
||||
}
|
||||
|
||||
function Test-Python {
|
||||
@@ -133,6 +133,26 @@ function Get-NanobotCommand {
|
||||
}
|
||||
}
|
||||
|
||||
function Test-FreshNanobotInstall {
|
||||
$HomeDir = [Environment]::GetFolderPath([Environment+SpecialFolder]::UserProfile)
|
||||
if (-not $HomeDir) {
|
||||
return $false
|
||||
}
|
||||
return -not (Test-Path -LiteralPath (Join-Path $HomeDir ".nanobot\config.json"))
|
||||
}
|
||||
|
||||
function Test-BrowserSession {
|
||||
if ($env:SSH_CONNECTION -or $env:SSH_TTY -or -not [Environment]::UserInteractive) {
|
||||
return $false
|
||||
}
|
||||
|
||||
$CurrentSessionId = (Get-Process -Id $PID).SessionId
|
||||
return @(
|
||||
Get-Process -Name explorer -ErrorAction SilentlyContinue |
|
||||
Where-Object { $_.SessionId -eq $CurrentSessionId }
|
||||
).Count -gt 0
|
||||
}
|
||||
|
||||
function Install-WithActivePython {
|
||||
Write-Info "Detected an active virtual environment. Installing into it..."
|
||||
Ensure-Pip $Python
|
||||
@@ -252,7 +272,10 @@ if ($DryRun) {
|
||||
Write-Info "Dry run: would run nanobot as: $VenvDir\Scripts\python.exe -m nanobot"
|
||||
}
|
||||
if ($env:NANOBOT_SKIP_WIZARD -eq "1") {
|
||||
Write-Info "Dry run: would skip setup wizard because NANOBOT_SKIP_WIZARD=1."
|
||||
Write-Info "Dry run: would skip automatic setup because NANOBOT_SKIP_WIZARD=1."
|
||||
} elseif ((Test-FreshNanobotInstall) -and (Test-BrowserSession)) {
|
||||
Write-Info "Dry run: would start the WebUI for this fresh desktop install."
|
||||
Write-Info "Dry run: would fall back to the setup wizard for older releases."
|
||||
} else {
|
||||
Write-Info "Dry run: would run the setup wizard."
|
||||
}
|
||||
@@ -294,11 +317,27 @@ if ($LASTEXITCODE -ne 0) {
|
||||
}
|
||||
|
||||
if ($env:NANOBOT_SKIP_WIZARD -eq "1") {
|
||||
Write-Info "Skipping setup wizard because NANOBOT_SKIP_WIZARD=1."
|
||||
Write-Info "Run this later: $(Get-NanobotCommand) onboard --wizard"
|
||||
Write-Info "Skipping automatic setup because NANOBOT_SKIP_WIZARD=1."
|
||||
Write-Info "Run this later: $(Get-NanobotCommand) webui"
|
||||
return
|
||||
}
|
||||
|
||||
if ((Test-FreshNanobotInstall) -and (Test-BrowserSession)) {
|
||||
Invoke-Nanobot @("webui", "--help") *> $null
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Info "Starting nanobot WebUI..."
|
||||
Write-Info "Configure your first provider and model in Settings > Models."
|
||||
Write-Info "Run this later: $(Get-NanobotCommand) webui"
|
||||
Invoke-Nanobot @("webui", "--yes")
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Fail "WebUI did not start."
|
||||
}
|
||||
return
|
||||
}
|
||||
Write-Info "The installed release does not support nanobot webui yet."
|
||||
Write-Info "Falling back to the setup wizard..."
|
||||
}
|
||||
|
||||
Write-Info "Starting setup wizard..."
|
||||
Invoke-Nanobot @("onboard", "--wizard")
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
|
||||
Reference in New Issue
Block a user