mirror of
https://github.com/bunny-lab-io/Borealis.git
synced 2025-12-15 01:55:48 -07:00
Fixed VSCode Tasks and Simplified Borealis.ps1
This commit is contained in:
57
.vscode/tasks.json
vendored
57
.vscode/tasks.json
vendored
@@ -1,43 +1,15 @@
|
|||||||
{
|
{
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"tasks": [
|
"tasks": [
|
||||||
{
|
|
||||||
"label": "Borealis - Legacy Server (Production)",
|
|
||||||
"type": "shell",
|
|
||||||
"command": "powershell.exe",
|
|
||||||
"args": [
|
|
||||||
"-ExecutionPolicy", "Bypass",
|
|
||||||
"-File", "${workspaceFolder}/Borealis.ps1",
|
|
||||||
"-Server", "-Flask"
|
|
||||||
],
|
|
||||||
"presentation": {
|
|
||||||
"reveal": "always",
|
|
||||||
"panel": "shared"
|
|
||||||
},
|
|
||||||
"problemMatcher": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "Borealis - Legacy Server (Dev)",
|
|
||||||
"type": "shell",
|
|
||||||
"command": "powershell.exe",
|
|
||||||
"args": [
|
|
||||||
"-ExecutionPolicy", "Bypass",
|
|
||||||
"-File", "${workspaceFolder}/Borealis.ps1",
|
|
||||||
"-Server", "-Vite"
|
|
||||||
],
|
|
||||||
"presentation": {
|
|
||||||
"reveal": "always",
|
|
||||||
"panel": "shared"
|
|
||||||
},
|
|
||||||
"problemMatcher": []
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"label": "Borealis - Engine (Production)",
|
"label": "Borealis - Engine (Production)",
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"command": "powershell.exe",
|
"command": "powershell.exe",
|
||||||
"args": [
|
"args": [
|
||||||
|
"-NoLogo",
|
||||||
|
"-NoProfile",
|
||||||
"-ExecutionPolicy", "Bypass",
|
"-ExecutionPolicy", "Bypass",
|
||||||
"-File", "${workspaceFolder}/Borealis.ps1",
|
"-File", "${workspaceFolder}\\Borealis.ps1",
|
||||||
"-EngineProduction"
|
"-EngineProduction"
|
||||||
],
|
],
|
||||||
"presentation": {
|
"presentation": {
|
||||||
@@ -51,8 +23,10 @@
|
|||||||
"type": "shell",
|
"type": "shell",
|
||||||
"command": "powershell.exe",
|
"command": "powershell.exe",
|
||||||
"args": [
|
"args": [
|
||||||
|
"-NoLogo",
|
||||||
|
"-NoProfile",
|
||||||
"-ExecutionPolicy", "Bypass",
|
"-ExecutionPolicy", "Bypass",
|
||||||
"-File", "${workspaceFolder}/Borealis.ps1",
|
"-File", "${workspaceFolder}\\Borealis.ps1",
|
||||||
"-EngineDev"
|
"-EngineDev"
|
||||||
],
|
],
|
||||||
"presentation": {
|
"presentation": {
|
||||||
@@ -65,27 +39,12 @@
|
|||||||
"label": "Borealis - Agent",
|
"label": "Borealis - Agent",
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"command": "powershell.exe",
|
"command": "powershell.exe",
|
||||||
"args": [
|
|
||||||
"-ExecutionPolicy", "Bypass",
|
|
||||||
"-File", "${workspaceFolder}/Borealis.ps1",
|
|
||||||
"-Agent"
|
|
||||||
],
|
|
||||||
"presentation": {
|
|
||||||
"reveal": "always",
|
|
||||||
"panel": "shared"
|
|
||||||
},
|
|
||||||
"problemMatcher": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "Borealis - Kill All Component Processes",
|
|
||||||
"type": "shell",
|
|
||||||
"command": "powershell.exe",
|
|
||||||
"args": [
|
"args": [
|
||||||
"-NoLogo",
|
"-NoLogo",
|
||||||
"-NoProfile",
|
"-NoProfile",
|
||||||
"-ExecutionPolicy", "Bypass",
|
"-ExecutionPolicy", "Bypass",
|
||||||
"-Command",
|
"-File", "${workspaceFolder}\\Borealis.ps1",
|
||||||
"taskkill.exe /IM node.exe /IM pythonw.exe /IM python.exe /F"
|
"-Agent"
|
||||||
],
|
],
|
||||||
"presentation": {
|
"presentation": {
|
||||||
"reveal": "always",
|
"reveal": "always",
|
||||||
|
|||||||
73
Borealis.ps1
73
Borealis.ps1
@@ -4,8 +4,6 @@
|
|||||||
param(
|
param(
|
||||||
[switch]$Server,
|
[switch]$Server,
|
||||||
[switch]$Agent,
|
[switch]$Agent,
|
||||||
[ValidateSet('install','repair','remove','launch','')]
|
|
||||||
[string]$AgentAction = '',
|
|
||||||
[switch]$Vite,
|
[switch]$Vite,
|
||||||
[switch]$Flask,
|
[switch]$Flask,
|
||||||
[switch]$Quick,
|
[switch]$Quick,
|
||||||
@@ -18,7 +16,6 @@ param(
|
|||||||
# Preselect menu choices from CLI args (optional)
|
# Preselect menu choices from CLI args (optional)
|
||||||
$choice = $null
|
$choice = $null
|
||||||
$modeChoice = $null
|
$modeChoice = $null
|
||||||
$agentSubChoice = $null
|
|
||||||
$engineModeChoice = $null
|
$engineModeChoice = $null
|
||||||
|
|
||||||
$scriptDir = Split-Path $MyInvocation.MyCommand.Path -Parent
|
$scriptDir = Split-Path $MyInvocation.MyCommand.Path -Parent
|
||||||
@@ -66,15 +63,8 @@ if ($Server) {
|
|||||||
$choice = '1'
|
$choice = '1'
|
||||||
} elseif ($Agent) {
|
} elseif ($Agent) {
|
||||||
$choice = '2'
|
$choice = '2'
|
||||||
switch ($AgentAction) {
|
|
||||||
'install' { $agentSubChoice = '1' }
|
|
||||||
'repair' { $agentSubChoice = '2' }
|
|
||||||
'remove' { $agentSubChoice = '3' }
|
|
||||||
'launch' { $agentSubChoice = '4' }
|
|
||||||
default { $agentSubChoice = '1' }
|
|
||||||
}
|
|
||||||
} elseif ($EngineProduction -or $EngineDev) {
|
} elseif ($EngineProduction -or $EngineDev) {
|
||||||
$choice = '5'
|
$choice = '1'
|
||||||
if ($EngineProduction) { $engineModeChoice = '1' }
|
if ($EngineProduction) { $engineModeChoice = '1' }
|
||||||
if ($EngineDev) { $engineModeChoice = '3' }
|
if ($EngineDev) { $engineModeChoice = '3' }
|
||||||
}
|
}
|
||||||
@@ -137,7 +127,6 @@ function Test-IsAdmin {
|
|||||||
function Request-AgentElevation {
|
function Request-AgentElevation {
|
||||||
param(
|
param(
|
||||||
[string]$ScriptPath,
|
[string]$ScriptPath,
|
||||||
[string]$AgentActionParam,
|
|
||||||
[switch]$Auto
|
[switch]$Auto
|
||||||
)
|
)
|
||||||
if (Test-IsAdmin) { return $true }
|
if (Test-IsAdmin) { return $true }
|
||||||
@@ -151,9 +140,6 @@ function Request-AgentElevation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$args = @('-NoProfile','-ExecutionPolicy','Bypass','-File', '"' + $ScriptPath + '"', '-Agent')
|
$args = @('-NoProfile','-ExecutionPolicy','Bypass','-File', '"' + $ScriptPath + '"', '-Agent')
|
||||||
if ($AgentActionParam -and $AgentActionParam.Trim()) {
|
|
||||||
$args += @('-AgentAction', $AgentActionParam)
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
Start-Process -FilePath 'powershell.exe' -Verb RunAs -ArgumentList $args -WindowStyle Normal | Out-Null
|
Start-Process -FilePath 'powershell.exe' -Verb RunAs -ArgumentList $args -WindowStyle Normal | Out-Null
|
||||||
return $false # stop current non-elevated instance
|
return $false # stop current non-elevated instance
|
||||||
@@ -355,31 +341,6 @@ function Remove-BorealisServicesAndTasks {
|
|||||||
try { Remove-Item -Force -ErrorAction SilentlyContinue (Join-Path $env:ProgramData 'Borealis\watchdog.ps1') } catch {}
|
try { Remove-Item -Force -ErrorAction SilentlyContinue (Join-Path $env:ProgramData 'Borealis\watchdog.ps1') } catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Repair routine: cleans services, ensures venv files, reinstalls and starts BorealisAgent
|
|
||||||
function Repair-BorealisAgent {
|
|
||||||
$logName = 'Repair.log'
|
|
||||||
Write-AgentLog -FileName $logName -Message "=== Repair start ==="
|
|
||||||
Remove-BorealisServicesAndTasks -LogName $logName
|
|
||||||
InstallOrUpdate-BorealisAgent
|
|
||||||
Write-AgentLog -FileName $logName -Message "=== Repair end ==="
|
|
||||||
}
|
|
||||||
|
|
||||||
function Remove-BorealisAgent {
|
|
||||||
$logName = 'Removal.log'
|
|
||||||
Write-AgentLog -FileName $logName -Message "=== Removal start ==="
|
|
||||||
Remove-BorealisServicesAndTasks -LogName $logName
|
|
||||||
# Kill stray helpers
|
|
||||||
Write-AgentLog -FileName $logName -Message "Terminating stray helper processes"
|
|
||||||
Get-Process python,pythonw -ErrorAction SilentlyContinue | Where-Object { $_.Path -like (Join-Path $scriptDir 'Agent\*') } | ForEach-Object {
|
|
||||||
try { $_ | Stop-Process -Force } catch {}
|
|
||||||
}
|
|
||||||
# Remove venv folder
|
|
||||||
$venvFolder = Join-Path $scriptDir 'Agent'
|
|
||||||
Write-AgentLog -FileName $logName -Message "Removing folder: $venvFolder"
|
|
||||||
try { Remove-Item $venvFolder -Recurse -Force -ErrorAction SilentlyContinue } catch {}
|
|
||||||
Write-AgentLog -FileName $logName -Message "=== Removal end ==="
|
|
||||||
}
|
|
||||||
|
|
||||||
function Write-ProgressStep {
|
function Write-ProgressStep {
|
||||||
param (
|
param (
|
||||||
[string]$Message,
|
[string]$Message,
|
||||||
@@ -1395,40 +1356,18 @@ switch ($choice) {
|
|||||||
"2" {
|
"2" {
|
||||||
$host.UI.RawUI.WindowTitle = "Borealis Agent"
|
$host.UI.RawUI.WindowTitle = "Borealis Agent"
|
||||||
Write-Host " "
|
Write-Host " "
|
||||||
# Ensure elevation before showing Agent menu
|
# Ensure elevation before performing Agent deployment
|
||||||
$scriptPath = $PSCommandPath
|
$scriptPath = $PSCommandPath
|
||||||
if (-not $scriptPath -or $scriptPath -eq '') { $scriptPath = $MyInvocation.MyCommand.Definition }
|
if (-not $scriptPath -or $scriptPath -eq '') { $scriptPath = $MyInvocation.MyCommand.Definition }
|
||||||
# If already elevated, skip prompt; otherwise prompt, then relaunch directly to the Agent menu via -Agent
|
# If already elevated, skip prompt; otherwise prompt, then relaunch directly to the Agent deploy flow via -Agent
|
||||||
$cont = Request-AgentElevation -ScriptPath $scriptPath -AgentActionParam $AgentAction
|
$cont = Request-AgentElevation -ScriptPath $scriptPath
|
||||||
if (-not $cont -and -not (Test-IsAdmin)) { return }
|
if (-not $cont -and -not (Test-IsAdmin)) { return }
|
||||||
if (Test-IsAdmin) {
|
if (Test-IsAdmin) {
|
||||||
Write-Host "Escalated Permissions Granted > Agent is Eligible for Deployment." -ForegroundColor Green
|
Write-Host "Escalated Permissions Granted > Agent is Eligible for Deployment." -ForegroundColor Green
|
||||||
}
|
}
|
||||||
Write-Host "Agent Menu:" -ForegroundColor Cyan
|
Write-Host "Deploying Borealis Agent (fresh install/update path)..." -ForegroundColor Cyan
|
||||||
Write-Host " 1) Install/Update Agent"
|
InstallOrUpdate-BorealisAgent
|
||||||
Write-Host " 2) Repair Borealis Agent"
|
|
||||||
Write-Host " 3) Remove Agent"
|
|
||||||
Write-Host " 4) Launch UserSession Helper (current session)"
|
|
||||||
Write-Host " 5) Back"
|
|
||||||
if (-not $agentSubChoice) { $agentSubChoice = Read-Host "Select an option" }
|
|
||||||
|
|
||||||
switch ($agentSubChoice) {
|
|
||||||
'1' { InstallOrUpdate-BorealisAgent; break }
|
|
||||||
'2' { Repair-BorealisAgent; break }
|
|
||||||
'3' { Remove-BorealisAgent; break }
|
|
||||||
'4' {
|
|
||||||
$venvPythonw = Join-Path $scriptDir 'Agent\Scripts\pythonw.exe'
|
|
||||||
$helper = Join-Path $scriptDir 'Agent\Borealis\agent.py'
|
|
||||||
if (-not (Test-Path $venvPythonw)) { Write-Host "pythonw.exe not found under Agent\Scripts" -ForegroundColor Yellow }
|
|
||||||
if (-not (Test-Path $helper)) { Write-Host "Helper not found under Agent\Borealis" -ForegroundColor Yellow }
|
|
||||||
if ((Test-Path $venvPythonw) -and (Test-Path $helper)) {
|
|
||||||
Start-Process -FilePath $venvPythonw -ArgumentList @('-W','ignore::SyntaxWarning', $helper) -WorkingDirectory (Split-Path $helper -Parent)
|
|
||||||
Write-Host "Launched user-session helper." -ForegroundColor Green
|
|
||||||
}
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
default { break }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
default { Write-Host "Invalid selection. Exiting..." -ForegroundColor Red; exit 1 }
|
default { Write-Host "Invalid selection. Exiting..." -ForegroundColor Red; exit 1 }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1206,7 +1206,7 @@ function Invoke-BorealisAgentUpdate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (-not ($gitExe) -or -not (Test-Path $gitExe -PathType Leaf)) {
|
if (-not ($gitExe) -or -not (Test-Path $gitExe -PathType Leaf)) {
|
||||||
Write-Host "Bundled Git dependency not found. Run '.\\Borealis.ps1 -Agent -AgentAction repair' to bootstrap dependencies and try again." -ForegroundColor Yellow
|
Write-Host "Bundled Git dependency not found. Run '.\\Borealis.ps1 -Agent' to redeploy the agent dependencies and try again." -ForegroundColor Yellow
|
||||||
Write-Host "⚠️ Borealis update aborted."
|
Write-Host "⚠️ Borealis update aborted."
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user