[eric] windows: prewarm Defender on install (exp.1)

This commit is contained in:
ciregenz
2026-05-21 11:57:36 -07:00
parent 0b32266be7
commit 47c8f8f2a9
4 changed files with 43 additions and 3 deletions
+24
View File
@@ -54,6 +54,30 @@
Sleep 1500
!macroend
!macro customInstall
; ---- Defender prewarm: scan the heavy binaries while user is still watching the installer, not on first launch ----
;
; Right after extraction we spawn OpenSwarm.exe --prewarm, which loads
; python.exe and node.exe just enough to trigger Windows Defender's
; on-execute scan against them. Defender then has a cached verdict by
; the time the user double-clicks the app, dropping cold-start by
; 3-7 seconds on default-Defender Windows installs.
;
; --prewarm in main.js: no windows, no single-instance lock, no
; backend spawn, no UI side effects. Touches binaries via
; execFileSync('--version') and process.exit(0). 15s internal timeout
; per binary; outer nsExec call adds no further bound, so worst case
; this adds ~30-45s to install on a truly pathological machine.
; Standard machines: 3-8s.
;
; Failure here is silent and non-fatal. If --prewarm itself errors,
; the install still completes; user just pays the cold-start tax on
; first launch, same as before this macro existed.
nsExec::Exec '"$INSTDIR\OpenSwarm.exe" --prewarm'
Pop $0 ; discard exit code; prewarm is best-effort
!macroend
!macro customRemoveFiles
; ---- Layer B: bulk-delete heavy dirs with REBOOTOK fallback ----
;
+16
View File
@@ -9,6 +9,22 @@ const getPort = require('get-port');
const http = require('http');
const affiliateTracking = require('./affiliateTracking');
// Defender warmup: NSIS runs us with --prewarm right after install so Windows scans the bundled binaries while the user is already watching the installer instead of staring at a slow first launch.
if (process.argv.includes('--prewarm') && process.platform === 'win32') {
const touchExe = (rel) => {
const full = path.join(process.resourcesPath, rel);
try {
if (fs.existsSync(full)) {
execFileSync(full, ['--version'], { timeout: 15000, stdio: 'ignore', windowsHide: true });
}
} catch (_) {}
};
touchExe(path.join('python-env', 'python.exe'));
touchExe(path.join('node', 'x64', 'node.exe'));
touchExe(path.join('node', 'arm64', 'node.exe'));
process.exit(0);
}
// Prevent duplicate instances. Without this, double-clicking the app icon
// (or macOS auto-launch + manual launch overlapping) spawns two independent
// processes — each with its own backend on a different port — resulting in
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "openswarm",
"version": "1.1.40",
"version": "1.1.41-exp.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "openswarm",
"version": "1.1.40",
"version": "1.1.41-exp.1",
"hasInstallScript": true,
"dependencies": {
"electron-updater": "^6.3.0",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "openswarm",
"version": "1.1.40",
"version": "1.1.41-exp.1",
"description": "OpenSwarm — AI Agent Orchestrator",
"main": "main.js",
"scripts": {