@geekbeer/minion 3.6.1 → 3.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/win/minion-cli.ps1 +66 -21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geekbeer/minion",
3
- "version": "3.6.1",
3
+ "version": "3.6.2",
4
4
  "description": "AI Agent runtime for Minion - manages status and skill deployment on VPS",
5
5
  "main": "linux/server.js",
6
6
  "bin": {
@@ -451,7 +451,7 @@ function Restart-MinionService {
451
451
  # ============================================================
452
452
 
453
453
  function Invoke-Setup {
454
- $totalSteps = 11
454
+ $totalSteps = 12
455
455
 
456
456
  # Minionization warning
457
457
  Write-Host ""
@@ -877,8 +877,52 @@ function Invoke-Setup {
877
877
  Write-Warn "websockify not available, VNC WebSocket proxy will not be registered"
878
878
  }
879
879
 
880
+ # Step 10: Download and register cloudflared
881
+ Write-Step 10 $totalSteps "Setting up Cloudflare Tunnel (cloudflared)..."
882
+ $cfExe = $null
883
+ if (Get-Command cloudflared -ErrorAction SilentlyContinue) {
884
+ $cfExe = (Get-Command cloudflared).Source
885
+ Write-Detail "cloudflared already installed: $cfExe"
886
+ } else {
887
+ Write-Host " Downloading cloudflared..."
888
+ try {
889
+ $cfUrl = 'https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-windows-amd64.exe'
890
+ $cfPath = Join-Path $DataDir 'cloudflared.exe'
891
+ Invoke-WebRequest -Uri $cfUrl -OutFile $cfPath -UseBasicParsing
892
+ $cfExe = $cfPath
893
+ Write-Detail "cloudflared downloaded to $cfExe"
894
+ }
895
+ catch {
896
+ Write-Warn "Failed to download cloudflared: $_"
897
+ Write-Host " You can install manually or re-run setup later." -ForegroundColor Gray
898
+ }
899
+ }
900
+ if ($cfExe) {
901
+ # Register cloudflared as NSSM service (config will be set by 'configure --setup-tunnel')
902
+ Invoke-Nssm stop minion-cloudflared
903
+ Invoke-Nssm remove minion-cloudflared confirm
904
+ $cfConfigDir = Join-Path $TargetUserProfile '.cloudflared'
905
+ $cfConfigPath = Join-Path $cfConfigDir 'config.yml'
906
+ Invoke-Nssm install minion-cloudflared $cfExe "tunnel run --config `"$cfConfigPath`""
907
+ Invoke-Nssm set minion-cloudflared Start SERVICE_DEMAND_START
908
+ Invoke-Nssm set minion-cloudflared DisplayName "Minion Cloudflared"
909
+ Invoke-Nssm set minion-cloudflared Description "Cloudflare Tunnel for Minion"
910
+ Invoke-Nssm set minion-cloudflared AppRestartDelay 5000
911
+ Invoke-Nssm set minion-cloudflared AppStdout (Join-Path $LogDir 'cloudflared-stdout.log')
912
+ Invoke-Nssm set minion-cloudflared AppStderr (Join-Path $LogDir 'cloudflared-stderr.log')
913
+ Invoke-Nssm set minion-cloudflared AppStdoutCreationDisposition 4
914
+ Invoke-Nssm set minion-cloudflared AppStderrCreationDisposition 4
915
+ Invoke-Nssm set minion-cloudflared AppRotateFiles 1
916
+ Invoke-Nssm set minion-cloudflared AppRotateBytes 10485760
917
+ Grant-ServiceControlToUser 'minion-cloudflared' $setupUserSid
918
+ if ($targetUserSid -and $targetUserSid -ne $setupUserSid) {
919
+ Grant-ServiceControlToUser 'minion-cloudflared' $targetUserSid
920
+ }
921
+ Write-Detail "minion-cloudflared service registered (starts via 'configure --setup-tunnel')"
922
+ }
923
+
880
924
  # Step 11: Disable screensaver, lock screen, and sleep
881
- Write-Step 10 $totalSteps "Disabling screensaver, lock screen, and sleep..."
925
+ Write-Step 11 $totalSteps "Disabling screensaver, lock screen, and sleep..."
882
926
  Set-ItemProperty -Path 'HKCU:\Control Panel\Desktop' -Name ScreenSaveActive -Value '0'
883
927
  Set-ItemProperty -Path 'HKCU:\Control Panel\Desktop' -Name ScreenSaveTimeOut -Value '0'
884
928
  Set-ItemProperty -Path 'HKCU:\Control Panel\Desktop' -Name SCRNSAVE.EXE -Value ''
@@ -892,7 +936,7 @@ function Invoke-Setup {
892
936
  Write-Detail "Sleep and monitor timeout disabled"
893
937
 
894
938
  # Configure firewall rules
895
- Write-Step 11 $totalSteps "Configuring firewall rules..."
939
+ Write-Step 12 $totalSteps "Configuring firewall rules..."
896
940
  $fwRules = @(
897
941
  @{ Name = 'Minion Agent'; Port = 8080 },
898
942
  @{ Name = 'Minion Terminal'; Port = 7681 },
@@ -985,6 +1029,7 @@ function Invoke-Setup {
985
1029
  Write-Host "Services registered (not yet started):"
986
1030
  Write-Host " minion-agent - AI Agent (port 8080)"
987
1031
  Write-Host " minion-websockify - WebSocket proxy (port 6080)"
1032
+ Write-Host " minion-cloudflared - Cloudflare Tunnel (starts via configure --setup-tunnel)"
988
1033
  Write-Host " MinionVNC (task) - TightVNC (port 5900, starts at logon)"
989
1034
  Write-Host ""
990
1035
  Write-Host "Next step: Connect to HQ (run as regular user):" -ForegroundColor Yellow
@@ -1303,22 +1348,25 @@ function Invoke-Configure {
1303
1348
  [System.IO.File]::WriteAllText((Join-Path $cfConfigDir 'config.yml'), $tunnelData.config_yml, [System.Text.UTF8Encoding]::new($false))
1304
1349
  Write-Detail "Tunnel config saved"
1305
1350
 
1306
- # Register cloudflared as NSSM service (requires admin — will be skipped if non-admin)
1307
- $cfExe = $null
1308
- if (Get-Command cloudflared -ErrorAction SilentlyContinue) {
1309
- $cfExe = (Get-Command cloudflared).Source
1310
- } elseif (Test-Path (Join-Path $DataDir 'cloudflared.exe')) {
1311
- $cfExe = Join-Path $DataDir 'cloudflared.exe'
1312
- }
1313
- if ($cfExe) {
1314
- $cfState = Get-ServiceState 'minion-cloudflared'
1315
- if (-not $cfState) {
1316
- # Service not registered try to register via NSSM (requires admin)
1351
+ # Start cloudflared service (registered during setup)
1352
+ $cfState = Get-ServiceState 'minion-cloudflared'
1353
+ if ($cfState) {
1354
+ # Enable auto-start now that tunnel config is in place
1355
+ Invoke-Nssm set minion-cloudflared Start SERVICE_AUTO_START 2>&1 | Out-Null
1356
+ sc.exe start minion-cloudflared 2>&1 | Out-Null
1357
+ Write-Detail "minion-cloudflared started"
1358
+ } else {
1359
+ # Fallback: service not registered (e.g. setup was run before v3.6.2)
1360
+ $cfExe = $null
1361
+ if (Get-Command cloudflared -ErrorAction SilentlyContinue) {
1362
+ $cfExe = (Get-Command cloudflared).Source
1363
+ } elseif (Test-Path (Join-Path $DataDir 'cloudflared.exe')) {
1364
+ $cfExe = Join-Path $DataDir 'cloudflared.exe'
1365
+ }
1366
+ if ($cfExe) {
1317
1367
  $isAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
1318
1368
  if ($isAdmin) {
1319
1369
  $cfConfigPath = Join-Path $cfConfigDir 'config.yml'
1320
- Invoke-Nssm stop minion-cloudflared
1321
- Invoke-Nssm remove minion-cloudflared confirm
1322
1370
  Invoke-Nssm install minion-cloudflared $cfExe "tunnel run --config `"$cfConfigPath`""
1323
1371
  Invoke-Nssm set minion-cloudflared Start SERVICE_AUTO_START
1324
1372
  Invoke-Nssm set minion-cloudflared DisplayName "Minion Cloudflared"
@@ -1332,15 +1380,12 @@ function Invoke-Configure {
1332
1380
  Invoke-Nssm set minion-cloudflared AppRotateBytes 10485760
1333
1381
  $setupUserSid = Get-SetupUserSid
1334
1382
  Grant-ServiceControlToUser 'minion-cloudflared' $setupUserSid
1335
- Write-Detail "minion-cloudflared service registered"
1383
+ Write-Detail "minion-cloudflared service registered (fallback)"
1336
1384
  sc.exe start minion-cloudflared 2>&1 | Out-Null
1337
1385
  Write-Detail "minion-cloudflared started"
1338
1386
  } else {
1339
- Write-Warn "minion-cloudflared service not registered. Run 'configure --setup-tunnel' as admin to register tunnel service."
1387
+ Write-Warn "minion-cloudflared service not registered. Run 'setup' as admin to register, or run 'configure --setup-tunnel' as admin."
1340
1388
  }
1341
- } else {
1342
- sc.exe start minion-cloudflared 2>&1 | Out-Null
1343
- Write-Detail "minion-cloudflared started"
1344
1389
  }
1345
1390
  }
1346
1391
  }