Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

fix(qemu): update setup orchestration to use scheduled tasks

[email protected]b92e1791d48f
diff --git a/libs/qemu/src/vm/setup/on-logon.ps1 b/libs/qemu/src/vm/setup/on-logon.ps1
index 1968c4f2a6..61d68d5500 100644
--- a/libs/qemu/src/vm/setup/on-logon.ps1
+++ b/libs/qemu/src/vm/setup/on-logon.ps1
@@ -1,10 +1,7 @@
-$scriptFolder = "\\host.lan\Data"
-$pythonServerPort = 5000
+# Start the Caddy Reverse Proxy scheduled task (runs in background, hidden)
+Write-Host "Starting Caddy Reverse Proxy task..."
+Start-ScheduledTask -TaskName "Caddy-Reverse-Proxy"
-# Start the Caddy reverse proxy in a non-blocking manner
-Write-Host "Running the Caddy reverse proxy from port 9222 to port 1337"
-Start-Process -NoNewWindow -FilePath "powershell" -ArgumentList "-Command", "caddy reverse-proxy --from :9222 --to :1337"
-
-# Start the CUA Computer Server
-Write-Host "Running the CUA Computer Server on port $pythonServerPort..."
-python -m computer_server --port $pythonServerPort
+# Start the CUA Computer Server scheduled task (runs in background, hidden)
+Write-Host "Starting CUA Computer Server task..."
+Start-ScheduledTask -TaskName "CUA-Computer-Server"
diff --git a/libs/qemu/src/vm/setup/setup.ps1 b/libs/qemu/src/vm/setup/setup.ps1
index e23f05ea37..252e104042 100644
--- a/libs/qemu/src/vm/setup/setup.ps1
+++ b/libs/qemu/src/vm/setup/setup.ps1
@@ -377,40 +377,38 @@ if (Test-Path $caddyProxyExecutablePath) {
}
}
-# - CUA Computer Server Setup
-
-$pythonServerPort = 5000
-$onLogonTaskName = "WindowsArena_OnLogon"
-
-# Ensure pip is updated to the latest version
-Install-PythonPackages -Package "pip" -Arguments "--upgrade"
-
-Install-PythonPackages -Package "wheel"
-
-# Install CUA computer-server
-Write-Host "Installing cua-computer-server..."
-Install-PythonPackages -Package "cua-computer-server"
-
-# Add a firewall rule to allow incoming connections on the specified port for the Python executable
-$pythonServerRuleName = "PythonHTTPServer-$pythonServerPort"
-if (-not (Get-NetFirewallRule -Name $pythonServerRuleName -ErrorAction SilentlyContinue)) {
- New-NetFirewallRule -DisplayName $pythonServerRuleName -Direction Inbound -Program $pythonExecutablePath -Protocol TCP -LocalPort $pythonServerPort -Action Allow -Profile Any
- Write-Host "Firewall rule added to allow traffic on port $pythonServerPort for Python"
+# - Caddy Reverse Proxy Setup
+Write-Host "Setting up Caddy Reverse Proxy..."
+$caddySetupScript = Join-Path $scriptFolder -ChildPath "setup-caddy-proxy.ps1"
+if (Test-Path $caddySetupScript) {
+ & $caddySetupScript
+ Write-Host "Caddy Reverse Proxy setup completed."
} else {
- Write-Host "Firewall rule already exists. $pythonServerRuleName "
+ Write-Host "ERROR: setup-caddy-proxy.ps1 not found at $caddySetupScript"
}
-# Add a firewall rule to allow incoming connections on the specified port for the Python executable
+# Add a firewall rule for Caddy Proxy if needed
$caddyProxyRuleName = "Allow-Caddy-Proxy"
if (-not (Get-NetFirewallRule -Name $caddyProxyRuleName -ErrorAction SilentlyContinue)) {
New-NetFirewallRule -DisplayName $caddyProxyRuleName -Direction Inbound -Program $caddyProxyExecutablePath -Action Allow -Profile Any
- Write-Host "Firewall rule added to allow traffic on port $caddyProxyRuleName"
+ Write-Host "Firewall rule added to allow traffic for $caddyProxyRuleName"
} else {
- Write-Host "Firewall rule already exists. $caddyProxyRuleName "
+ Write-Host "Firewall rule already exists. $caddyProxyRuleName"
}
+# - CUA Computer Server Setup
+Write-Host "Setting up CUA Computer Server..."
+$cuaServerSetupScript = Join-Path $scriptFolder -ChildPath "setup-cua-server.ps1"
+if (Test-Path $cuaServerSetupScript) {
+ & $cuaServerSetupScript
+ Write-Host "CUA Computer Server setup completed."
+} else {
+ Write-Host "ERROR: setup-cua-server.ps1 not found at $cuaServerSetupScript"
+}
+
+# Register on-logon task (required for base image shutdown detection)
+$onLogonTaskName = "WindowsArena_OnLogon"
$onLogonScriptPath = "$scriptFolder\on-logon.ps1"
-# Check if the scheduled task exists before unregistering it
if (Get-ScheduledTask -TaskName $onLogonTaskName -ErrorAction SilentlyContinue) {
Write-Host "Scheduled task $onLogonTaskName already exists."
} else {
@@ -419,4 +417,7 @@ if (Get-ScheduledTask -TaskName $onLogonTaskName -ErrorAction SilentlyContinue)
}
Start-Sleep -Seconds 10
-Start-ScheduledTask -TaskName $onLogonTaskName
\ No newline at end of file
+
+# Start the on-logon task asynchronously (non-blocking) so setup can complete
+Write-Host "Starting $onLogonTaskName task in background..."
+Start-Process -WindowStyle Hidden -FilePath "powershell.exe" -ArgumentList "-Command", "Start-ScheduledTask -TaskName '$onLogonTaskName'"