param( [Parameter(Mandatory = $true)] [string]$BootstrapPython, [string]$RuntimeDirectory = "$env:ProgramData\Zcbot\WindowsNode\runtimes\origin" ) $ErrorActionPreference = "Stop" $python = (Resolve-Path -LiteralPath $BootstrapPython).Path if ([IO.Path]::GetFileName($python) -ne "python.exe") { throw "BootstrapPython must point to python.exe." } $requirements = Join-Path $PSScriptRoot "origin-worker\requirements.txt" if (-not (Test-Path -LiteralPath $requirements -PathType Leaf)) { throw "Pinned Origin worker requirements are missing." } $runtime = [IO.Path]::GetFullPath($RuntimeDirectory) if ($runtime -eq [IO.Path]::GetPathRoot($runtime)) { throw "RuntimeDirectory cannot be a drive root." } if (-not (Test-Path -LiteralPath (Join-Path $runtime "python.exe"))) { & $python -m venv $runtime if ($LASTEXITCODE -ne 0) { throw "Failed to create the Origin runtime." } } $runtimePython = Join-Path $runtime "python.exe" & $runtimePython -m pip install --requirement $requirements if ($LASTEXITCODE -ne 0) { throw "Failed to install the pinned Origin runtime packages." } & $runtimePython -c "import originpro, openpyxl; print('[OK] Origin worker Python packages are available.')" if ($LASTEXITCODE -ne 0) { throw "Origin runtime import verification failed." } Write-Output "[OK] Fixed Origin runtime installed: $runtimePython" Write-Output "[INFO] Restart zcbot Windows Node to refresh runtime health."