Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

desktop: Windows node.exe in the Tauri shell, hidden host console, and fetch-node.ps1 (win-x64, same SHA-256 pin as fetch-node.sh)

Niko12218a11d125dbf8
diff --git a/apps/desktop/scripts/fetch-node.ps1 b/apps/desktop/scripts/fetch-node.ps1
new file mode 100644
index 000000000..2d833a9bf
--- /dev/null
+++ b/apps/desktop/scripts/fetch-node.ps1
@@ -0,0 +1,72 @@
+# Fetch and verify the private Node runtime the Windows desktop bundle ships (win-x64).
+#
+# The PowerShell twin of fetch-node.sh: same pinned version, same SHA-256 pin, same refusal to
+# install anything whose digest does not match. Not committed output: node.exe is a ~90 MB binary.
+#
+# Usage:
+# powershell -NoProfile -ExecutionPolicy Bypass -File apps\desktop\scripts\fetch-node.ps1
+# ... -File fetch-node.ps1 -Check # verify what is already installed
+# ... -File fetch-node.ps1 -FromFile node.zip # verify and install a zip you already have (offline)
+#
+# The Node version must satisfy the App Host's own engines.node (>= 24.12.0).
+[CmdletBinding()]
+param(
+ [switch]$Check,
+ [string]$FromFile = '',
+ [string]$Dest = ''
+)
+$ErrorActionPreference = 'Stop'
+
+$NodeVersion = if ($env:STRATA_NODE_VERSION) { $env:STRATA_NODE_VERSION } else { '24.12.0' }
+$Target = 'win-x64'
+# SHA-256 of node-v24.12.0-win-x64.zip from nodejs.org's SHASUMS256.txt; keep equal to fetch-node.sh.
+$Expected = '9c125f61ae947b52e779095830f9cac267846a043ef7192183c84016aaad2812'
+if (-not $Dest) { $Dest = Join-Path $PSScriptRoot '..\src-tauri\resources\node' }
+$Installed = Join-Path $Dest 'node.exe'
+
+function Fail([string]$Message) { [Console]::Error.WriteLine("fetch-node: $Message"); exit 1 }
+
+if ($Check) {
+ if (-not (Test-Path -LiteralPath $Installed)) { Fail "not installed at $Installed" }
+ $got = (& $Installed --version).Trim()
+ Write-Output "fetch-node: $Installed is $got"
+ if ($got -ne "v$NodeVersion") { Fail "expected v$NodeVersion" }
+ exit 0
+}
+
+$Archive = "node-v$NodeVersion-$Target.zip"
+$Work = Join-Path ([IO.Path]::GetTempPath()) ("strata-node-" + [Guid]::NewGuid().ToString('N'))
+New-Item -ItemType Directory -Path $Work | Out-Null
+try {
+ $Zip = Join-Path $Work $Archive
+ if ($FromFile) {
+ Copy-Item -LiteralPath $FromFile -Destination $Zip
+ } else {
+ $Url = "https://nodejs.org/dist/v$NodeVersion/$Archive"
+ Write-Output "fetch-node: $Url"
+ [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
+ $ProgressPreference = 'SilentlyContinue'
+ Invoke-WebRequest -UseBasicParsing -Uri $Url -OutFile $Zip
+ }
+ $Actual = (Get-FileHash -Algorithm SHA256 -LiteralPath $Zip).Hash.ToLowerInvariant()
+ if ($NodeVersion -ne '24.12.0') {
+ # another version has no recorded digest: say so rather than implying a verification
+ [Console]::Error.WriteLine("fetch-node: WARNING - no recorded digest for v$NodeVersion; this download is NOT authenticated.")
+ [Console]::Error.WriteLine("fetch-node: computed sha256 $Actual - record it in this script and fetch-node.sh.")
+ } elseif ($Actual -ne $Expected) {
+ Fail "REFUSING - $Archive hashes $Actual, expected $Expected"
+ } else {
+ Write-Output 'fetch-node: sha256 verified against the recorded digest'
+ }
+ Add-Type -AssemblyName System.IO.Compression.FileSystem
+ $zipFile = [IO.Compression.ZipFile]::OpenRead($Zip)
+ try {
+ $entry = $zipFile.GetEntry("node-v$NodeVersion-$Target/node.exe")
+ if (-not $entry) { Fail "node.exe is not inside $Archive" }
+ New-Item -ItemType Directory -Force -Path $Dest | Out-Null
+ [IO.Compression.ZipFileExtensions]::ExtractToFile($entry, $Installed, $true)
+ } finally { $zipFile.Dispose() }
+ Write-Output "fetch-node: installed at $Installed"
+} finally {
+ Remove-Item -LiteralPath $Work -Recurse -Force -ErrorAction SilentlyContinue
+}
diff --git a/apps/desktop/src-tauri/src/main.rs b/apps/desktop/src-tauri/src/main.rs
index 9bdb6ffee..b06e4fe0e 100644
--- a/apps/desktop/src-tauri/src/main.rs
+++ b/apps/desktop/src-tauri/src/main.rs
@@ -58,22 +58,28 @@ fn resource_dir(app: &tauri::AppHandle) -> Result<PathBuf, String> {
Ok(manifest)
}
+/// File name of the bundled Node runtime: `node.exe` on Windows, `node` elsewhere.
+const NODE_EXE: &str = if cfg!(windows) { "node.exe" } else { "node" };
+
+/// Where `tauri dev` finds a Node sidecar prepared next to the checkout (`toolchain/node`).
+fn dev_node_candidate(res: &Path) -> PathBuf {
+ let root = res.join("..").join("..").join("..").join("toolchain").join("node");
+ if cfg!(windows) {
+ // the Windows zip has node.exe at the top of the folder, not under bin/
+ root.join("node-v24.12.0-win-x64").join("node.exe")
+ } else {
+ root.join("node-v24.12.0-darwin-arm64").join("bin").join("node")
+ }
+}
+
/// The private Node runtime that ships with the bundle.
fn node_binary(res: &Path) -> Result<PathBuf, String> {
- let bundled = res.join("node").join("node");
+ let bundled = res.join("node").join(NODE_EXE);
if bundled.exists() {
return Ok(bundled);
}
// development fallback: the sidecar prepared alongside the checkout
- let dev = res
- .join("..")
- .join("..")
- .join("..")
- .join("toolchain")
- .join("node")
- .join("node-v24.12.0-darwin-arm64")
- .join("bin")
- .join("node");
+ let dev = dev_node_candidate(res);
if dev.exists() {
return Ok(dev);
}
@@ -84,6 +90,17 @@ fn node_binary(res: &Path) -> Result<PathBuf, String> {
))
}
+/// A packaged GUI app must not flash a console window for the host process on Windows.
+#[cfg(windows)]
+fn hide_console(cmd: &mut Command) {
+ use std::os::windows::process::CommandExt;
+ const CREATE_NO_WINDOW: u32 = 0x0800_0000;
+ cmd.creation_flags(CREATE_NO_WINDOW);
+}
+
+#[cfg(not(windows))]
+fn hide_console(_cmd: &mut Command) {}
+
/// Wait until the host answers `/api/health`, or give up.
fn wait_for_health(port: u16, timeout: Duration) -> Result<(), String> {
let deadline = Instant::now() + timeout;
@@ -164,6 +181,7 @@ fn start_host(app: &tauri::AppHandle) -> Result<u16, String> {
.stdin(Stdio::null())
.stdout(Stdio::inherit())
.stderr(Stdio::inherit());
+ hide_console(&mut cmd);
// A user with the Strata API worker on a different port sets this; unset means the worker's
// documented loopback default.
if let Ok(url) = std::env::var("STRATA_SERVER_URL") {
@@ -256,8 +274,10 @@ fn run_self_test(report_path: &str) -> i32 {
let node = match node_binary(&res) {
Ok(n) => {
- let version_ok = Command::new(&n)
- .arg("--version")
+ let mut probe = Command::new(&n);
+ probe.arg("--version");
+ hide_console(&mut probe);
+ let version_ok = probe
.output()
.map(|o| o.status.success())
.unwrap_or(false);
@@ -285,6 +305,7 @@ fn run_self_test(report_path: &str) -> i32 {
.stdin(Stdio::null())
.stdout(Stdio::null())
.stderr(Stdio::null());
+ hide_console(&mut cmd);
let mut child = match cmd.spawn() {
Ok(c) => {
record("host-spawned", true, format!("pid {}", c.id()));
@@ -401,3 +422,40 @@ fn main() {
}
});
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ fn scratch(name: &str) -> PathBuf {
+ let dir = std::env::temp_dir().join(format!("strata-desktop-{name}-{}", std::process::id()));
+ let _ = std::fs::remove_dir_all(&dir);
+ std::fs::create_dir_all(&dir).unwrap();
+ dir
+ }
+
+ #[test]
+ fn bundled_node_uses_the_platform_file_name() {
+ let res = scratch("node");
+ assert!(node_binary(&res).is_err());
+ let dir = res.join("node");
+ std::fs::create_dir_all(&dir).unwrap();
+ std::fs::write(dir.join(NODE_EXE), b"").unwrap();
+ assert_eq!(node_binary(&res).unwrap(), dir.join(NODE_EXE));
+ assert_eq!(NODE_EXE, if cfg!(windows) { "node.exe" } else { "node" });
+ let _ = std::fs::remove_dir_all(&res);
+ }
+
+ #[test]
+ fn a_bare_node_is_not_taken_for_the_windows_runtime() {
+ if !cfg!(windows) {
+ return;
+ }
+ let res = scratch("bare");
+ let dir = res.join("node");
+ std::fs::create_dir_all(&dir).unwrap();
+ std::fs::write(dir.join("node"), b"").unwrap();
+ assert!(node_binary(&res).is_err());
+ let _ = std::fs::remove_dir_all(&res);
+ }
+}
diff --git a/tests/desktop/test_fetch_node.py b/tests/desktop/test_fetch_node.py
new file mode 100644
index 000000000..b67c359ef
--- /dev/null
+++ b/tests/desktop/test_fetch_node.py
@@ -0,0 +1,56 @@
+"""fetch-node.ps1 (Windows) and fetch-node.sh pin the same Node archive digest, and the PowerShell
+script refuses a download that does not match it."""
+
+from __future__ import annotations
+
+import os
+import re
+import shutil
+import subprocess
+import tempfile
+import unittest
+import zipfile
+from pathlib import Path
+
+SCRIPTS = Path(__file__).resolve().parents[2] / "apps" / "desktop" / "scripts"
+POWERSHELL = shutil.which("powershell") or shutil.which("pwsh")
+
+
+class PinTests(unittest.TestCase):
+ def test_both_scripts_pin_the_same_windows_digest_and_version(self):
+ sh = (SCRIPTS / "fetch-node.sh").read_text()
+ ps = (SCRIPTS / "fetch-node.ps1").read_text()
+ sh_digest = re.search(r'win-x64\)\s+echo "([0-9a-f]{64})"', sh).group(1)
+ ps_digest = re.search(r"\$Expected = '([0-9a-f]{64})'", ps).group(1)
+ self.assertEqual(sh_digest, ps_digest)
+ self.assertEqual(re.search(r'STRATA_NODE_VERSION:-([\d.]+)', sh).group(1),
+ re.search(r"else \{ '([\d.]+)' \}", ps).group(1))
+
+
[email protected](os.name == "nt" and POWERSHELL, "Windows PowerShell")
+class PowerShellTests(unittest.TestCase):
+ def run_script(self, *args):
+ return subprocess.run([POWERSHELL, "-NoProfile", "-ExecutionPolicy", "Bypass", "-File",
+ str(SCRIPTS / "fetch-node.ps1"), *args],
+ capture_output=True, text=True, timeout=120)
+
+ def test_a_zip_with_the_wrong_digest_is_refused_and_nothing_is_installed(self):
+ with tempfile.TemporaryDirectory() as directory:
+ archive = Path(directory) / "node.zip"
+ with zipfile.ZipFile(archive, "w") as bundle:
+ bundle.writestr("node-v24.12.0-win-x64/node.exe", b"not node")
+ dest = Path(directory) / "out"
+ result = self.run_script("-FromFile", str(archive), "-Dest", str(dest))
+ self.assertEqual(result.returncode, 1, result.stdout + result.stderr)
+ self.assertIn("REFUSING", result.stderr)
+ self.assertFalse((dest / "node.exe").exists())
+
+ def test_check_reports_a_missing_runtime(self):
+ with tempfile.TemporaryDirectory() as directory:
+ result = self.run_script("-Check", "-Dest", directory)
+ self.assertEqual(result.returncode, 1)
+ self.assertIn("not installed", result.stderr)
+
+
+if __name__ == "__main__":
+ unittest.main()