Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access. Runs 24/7 from CLI, Telegram or More.
fix(installer): Windows PowerShell 5.1 — decode checksums.txt bytes, ASCII-only script, readable failures (1.3.5)
Salman Qureshicdc72508bfed
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 1a43267d..e998efb2 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -392,6 +392,67 @@ jobs:grep -q 'Checksum mismatch' "$RUNNER_TEMP/tampered.log"test ! -e "$MERCURY_INSTALL/bin/mercury"+ installer-windows:+ name: Installer dry run (install.ps1, Windows PowerShell 5.1, local release dir)+ runs-on: windows-latest+ steps:+ - uses: actions/checkout@v4++ - name: Build a fake release directory (real stub exe) and serve it as application/octet-stream+ shell: powershell+ run: |+ $ErrorActionPreference = 'Stop'+ $rel = Join-Path $env:RUNNER_TEMP 'fake-release\v9.9.9'+ New-Item -ItemType Directory -Force -Path (Join-Path $rel 'web') | Out-Null+ # A real .exe for the post-install smoke (--version). csc ships with the .NET Framework on every Windows runner.+ $src = Join-Path $env:RUNNER_TEMP 'stub.cs'+ 'class P { static int Main(string[] a) { System.Console.WriteLine("9.9.9"); return 0; } }' | Set-Content -Path $src -Encoding ASCII+ $csc = Join-Path $env:WINDIR 'Microsoft.NET\Framework64\v4.0.30319\csc.exe'+ & $csc /nologo /out:(Join-Path $rel 'mercury-win-x64.exe') $src+ '<!doctype html><title>stub dashboard</title>' | Set-Content -Path (Join-Path $rel 'web\index.html') -Encoding ASCII+ tar -C $rel -czf (Join-Path $rel 'web.tar.gz') web+ $lines = foreach ($a in 'mercury-win-x64.exe', 'web.tar.gz') { "{0} {1}" -f (Get-FileHash -Algorithm SHA256 (Join-Path $rel $a)).Hash.ToLower(), $a }+ # LF line endings, no BOM: what the release pipeline publishes.+ [IO.File]::WriteAllText((Join-Path $rel 'checksums.txt'), (($lines -join "`n") + "`n"), (New-Object System.Text.UTF8Encoding($false)))+ Get-Content (Join-Path $rel 'checksums.txt')+ # Serve everything as application/octet-stream — GitHub's content type for release assets,+ # which makes Windows PowerShell 5.1 return byte[] from Invoke-WebRequest (#155 follow-up).+ $server = Join-Path $env:RUNNER_TEMP 'serve.py'+ @'+ import http.server, os, sys+ class H(http.server.SimpleHTTPRequestHandler):+ def guess_type(self, path):+ return 'application/octet-stream'+ os.chdir(sys.argv[1])+ http.server.ThreadingHTTPServer(('127.0.0.1', 8765), H).serve_forever()+ '@ -replace '^ ', '' | Set-Content -Path $server -Encoding ASCII+ Start-Process -FilePath python -ArgumentList $server, (Join-Path $env:RUNNER_TEMP 'fake-release') -WindowStyle Hidden+ $ok = $false+ foreach ($i in 1..30) { try { Invoke-WebRequest -Uri http://127.0.0.1:8765/v9.9.9/checksums.txt -UseBasicParsing | Out-Null; $ok = $true; break } catch { Start-Sleep -Milliseconds 500 } }+ if (-not $ok) { throw 'fake release server did not come up' }++ - name: Run install.ps1 from disk under Windows PowerShell 5.1+ shell: powershell+ env:+ MERCURY_VERSION: 9.9.9+ MERCURY_DOWNLOAD_BASE: http://127.0.0.1:8765+ MERCURY_INSTALL: ${{ runner.temp }}\mercury-prefix+ MERCURY_NO_PATH: '1'+ MERCURY_NO_PAUSE: '1'+ run: |+ $ErrorActionPreference = 'Stop'+ "PSVersion: $($PSVersionTable.PSVersion)"+ $log = Join-Path $env:RUNNER_TEMP 'install.log'+ # From disk (not irm | iex): also proves the file parses without a BOM under the ANSI code page.+ powershell -NoProfile -ExecutionPolicy Bypass -File scripts\install.ps1 2>&1 | Tee-Object -FilePath $log+ if ($LASTEXITCODE -ne 0) { throw "install.ps1 exited $LASTEXITCODE" }+ if (-not (Select-String -Path $log -Pattern 'Checksums verified' -Quiet)) { throw 'no "Checksums verified" in output' }+ if (-not (Select-String -Path $log -Pattern 'Smoke test passed' -Quiet)) { throw 'no "Smoke test passed" in output' }+ $exe = Join-Path $env:MERCURY_INSTALL 'bin\mercury.exe'+ if (-not (Test-Path $exe)) { throw "missing $exe" }+ if ((& $exe --version) -ne '9.9.9') { throw 'installed exe does not report 9.9.9' }+ if (-not (Test-Path (Join-Path $env:MERCURY_INSTALL 'bin\web\index.html'))) { throw 'web assets missing' }+termux:name: Termux (Android, x86_64)runs-on: ubuntu-latestdiff --git a/CHANGELOG.md b/CHANGELOG.mdindex a4006dba..79235846 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -1,5 +1,11 @@# Changelog+## 1.3.5 — hotfix: the Windows installer on Windows PowerShell 5.1++- **`irm mercuryagent.sh/install.ps1 | iex` failed with "checksums.txt must contain exactly one checksum for mercury-win-x64.exe"** on stock Windows PowerShell 5.1 — and the window closed before you could read it. GitHub serves `checksums.txt` as `application/octet-stream`, for which PowerShell 5.1 returns a `byte[]` from `Invoke-WebRequest`; the installer now decodes it (PowerShell 7 was unaffected). A failure now waits for Enter before closing the window (`MERCURY_NO_PAUSE=1` for automation).+- **Running the saved script (`powershell -File install.ps1`) failed to parse** under PowerShell 5.1: the file had UTF-8 characters and no BOM, so the ANSI code page turned a `✓` into a quote. The installers are ASCII-only now.+- CI runs the Windows installer under PowerShell 5.1 against a local release served as `application/octet-stream`.+## 1.3.4 — hotfix: binaries for CPUs without AVX2 (#155)- **"Illegal instruction (core dumped)" on older x86-64.** Bun's default x64 build uses AVX2; Intel CPUs before Haswell (2013) and some VMs crash at start. Releases now also ship **`mercury-linux-x64-baseline`** and **`mercury-win-x64-baseline.exe`**. The installers pick the baseline build when `/proc/cpuinfo` has no `avx2`, and switch to it automatically if the default build dies with an illegal instruction during the post-install smoke test. `MERCURY_ASSET=<asset name>` forces a build.diff --git a/README.md b/README.mdindex 4641b555..2d9640ff 100644--- a/README.md+++ b/README.md@@ -21,7 +21,7 @@</p><p align="center">- <strong>🔖 Current Stable: v1.3.4 — Steady Mercury</strong>+ <strong>🔖 Current Stable: v1.3.5 — Steady Mercury</strong></p><p align="center">diff --git a/docs/install-dev.ps1 b/docs/install-dev.ps1old mode 100644new mode 100755index 88b28eeb..1991cf7d--- a/docs/install-dev.ps1+++ b/docs/install-dev.ps1@@ -3,7 +3,7 @@# irm https://mercuryagent.sh/install-dev.ps1 | iex## Installs the rolling `mercury-dev-latest` GitHub pre-release as-# mercury-dev.exe under ~\.mercury-dev — it coexists with a stable install+# mercury-dev.exe under ~\.mercury-dev - it coexists with a stable install# (mercury.exe under ~\.mercury) on the same machine. Re-run to update.## This is a thin wrapper around the stable installer withdiff --git a/docs/install.ps1 b/docs/install.ps1index 7df9f590..f89b06d1 100644--- a/docs/install.ps1+++ b/docs/install.ps1@@ -4,7 +4,7 @@## Environment variables:# $env:MERCURY_VERSION Version to install (e.g. "1.1.9"). Default: latest.-# (Stable channel only — dev tracks the latest dev+# (Stable channel only - dev tracks the latest dev# build.)# $env:MERCURY_CHANNEL Distribution channel: "stable" (default) or "dev".# $env:MERCURY_INSTALL Install prefix. Default: $HOME\.mercury@@ -12,18 +12,29 @@# Binary lands at $env:MERCURY_INSTALL\bin\mercury.exe.# (mercury-dev.exe on the dev channel.)# $env:MERCURY_NO_PATH If "1", skip modifying user PATH.+# $env:MERCURY_DOWNLOAD_BASE Base URL the release assets are fetched from+# (default: GitHub Releases). Used by CI.+# $env:MERCURY_NO_PAUSE If "1", a failure exits without waiting for Enter.#Requires -Version 5$ErrorActionPreference = 'Stop'$Repo = 'cosmicstack-labs/mercury-agent'-$GhDl = "https://github.com/$Repo/releases/download"+$GhDl = if ($env:MERCURY_DOWNLOAD_BASE) { $env:MERCURY_DOWNLOAD_BASE.TrimEnd('/') } else { "https://github.com/$Repo/releases/download" }# ----- helpers ----------------------------------------------------------------function Write-Info ([string]$msg) { Write-Host "→ $msg" -ForegroundColor Green }+function Write-Info ([string]$msg) { Write-Host "-> $msg" -ForegroundColor Green }function Write-Warn2 ([string]$msg) { Write-Host "! $msg" -ForegroundColor Yellow }-function Die ([string]$msg) { Write-Host "x $msg" -ForegroundColor Red; exit 1 }+function Die ([string]$msg) {+ Write-Host "x $msg" -ForegroundColor Red+ # "irm ... | iex" from a fresh console closes the window on exit, so the+ # error was unreadable. Wait for Enter when a person is watching.+ if ($env:MERCURY_NO_PAUSE -ne '1' -and [Environment]::UserInteractive -and $Host.Name -eq 'ConsoleHost') {+ try { $null = Read-Host 'Press Enter to close' } catch { }+ }+ exit 1+}function Get-MercuryArch {$arch = $env:PROCESSOR_ARCHITECTURE@@ -117,11 +128,11 @@ function Update-UserPath ([string]$BinDir) {$IsDev = ($env:MERCURY_CHANNEL -eq 'dev')Write-Host ''-Write-Host '☿ Mercury installer' -ForegroundColor White-Write-Host ' Soul-driven AI agent · https://mercuryagent.sh'+Write-Host 'Mercury installer' -ForegroundColor White+Write-Host ' Soul-driven AI agent - https://mercuryagent.sh'Write-Host ''if ($IsDev) {- Write-Warn2 'Dev channel — unstable preview builds.'+ Write-Warn2 'Dev channel - unstable preview builds.'Write-Host (" Installs as {0}\bin\mercury-dev.exe (coexists with stable)." -f (Join-Path $HOME '.mercury-dev'))Write-Host ''}@@ -171,7 +182,12 @@ try {$checksumsUrl = "$releaseDir/checksums.txt"Write-Info 'Downloading checksums.txt ...'try {- $checksums = (Invoke-WebRequest -Uri $checksumsUrl -UseBasicParsing).Content+ # Windows PowerShell 5.1 returns a byte[] in .Content for+ # application/octet-stream (what GitHub serves checksums.txt as);+ # splitting that yields the literal "System.Byte[]" and no checksum+ # ever matches. Decode it ourselves; PowerShell 7 already hands a string.+ $raw = (Invoke-WebRequest -Uri $checksumsUrl -UseBasicParsing).Content+ $checksums = if ($raw -is [byte[]]) { [System.Text.Encoding]::UTF8.GetString($raw) } else { [string]$raw }} catch {Die "Failed to download required checksums from $checksumsUrl"}@@ -189,7 +205,7 @@ try {$archiveEntries = @(tar -tzf $webTmp)if ($LASTEXITCODE -ne 0) { Die 'Failed to inspect web.tar.gz' }foreach ($entry in $archiveEntries) {- # AppleDouble sidecars (._*, macOS tar's xattr artifact — invisible to+ # AppleDouble sidecars (._*, macOS tar's xattr artifact - invisible to# bsdtar, listed by GNU tar) are inert; the extraction stage discards# them. Traversal attempts stay fatal.if (($entry -notmatch '^web(/|$)' -and $entry -notmatch '^\._') -or $entry -match '(^|/)\.\.(/|$)') {@@ -270,7 +286,7 @@ Write-Info "Smoke test passed: $binName --version -> $smoke"$pathUpdated = Update-UserPath -BinDir $binDirWrite-Host ''-Write-Host "✓ Mercury $versionLabel is ready." -ForegroundColor Green+Write-Host "OK Mercury $versionLabel is ready." -ForegroundColor GreenWrite-Host ''if ($pathUpdated) {@@ -286,6 +302,6 @@ if ($pathUpdated) {Write-Host " $binPath # first run launches setup wizard"}if ($IsDev) {- Write-Warn2 'Dev channel — preview builds, may break. Re-run this script to update.'+ Write-Warn2 'Dev channel - preview builds, may break. Re-run this script to update.'}Write-Host ''diff --git a/package.json b/package.jsonindex 7034f0ad..a88fcc37 100644--- a/package.json+++ b/package.json@@ -1,6 +1,6 @@{"name": "@cosmicstack/mercury-agent",- "version": "1.3.4",+ "version": "1.3.5","description": "Soul-driven AI agent with Second Brain memory, permission-hardened tools, token budgets, and multi-channel access. Runs 24/7 from CLI or Telegram.","type": "module","main": "dist/index.js",diff --git a/scripts/install-dev.ps1 b/scripts/install-dev.ps1index 88b28eeb..1991cf7d 100755--- a/scripts/install-dev.ps1+++ b/scripts/install-dev.ps1@@ -3,7 +3,7 @@# irm https://mercuryagent.sh/install-dev.ps1 | iex## Installs the rolling `mercury-dev-latest` GitHub pre-release as-# mercury-dev.exe under ~\.mercury-dev — it coexists with a stable install+# mercury-dev.exe under ~\.mercury-dev - it coexists with a stable install# (mercury.exe under ~\.mercury) on the same machine. Re-run to update.## This is a thin wrapper around the stable installer withdiff --git a/scripts/install.ps1 b/scripts/install.ps1index 7df9f590..f89b06d1 100644--- a/scripts/install.ps1+++ b/scripts/install.ps1@@ -4,7 +4,7 @@## Environment variables:# $env:MERCURY_VERSION Version to install (e.g. "1.1.9"). Default: latest.-# (Stable channel only — dev tracks the latest dev+# (Stable channel only - dev tracks the latest dev# build.)# $env:MERCURY_CHANNEL Distribution channel: "stable" (default) or "dev".# $env:MERCURY_INSTALL Install prefix. Default: $HOME\.mercury@@ -12,18 +12,29 @@# Binary lands at $env:MERCURY_INSTALL\bin\mercury.exe.# (mercury-dev.exe on the dev channel.)# $env:MERCURY_NO_PATH If "1", skip modifying user PATH.+# $env:MERCURY_DOWNLOAD_BASE Base URL the release assets are fetched from+# (default: GitHub Releases). Used by CI.+# $env:MERCURY_NO_PAUSE If "1", a failure exits without waiting for Enter.#Requires -Version 5$ErrorActionPreference = 'Stop'$Repo = 'cosmicstack-labs/mercury-agent'-$GhDl = "https://github.com/$Repo/releases/download"+$GhDl = if ($env:MERCURY_DOWNLOAD_BASE) { $env:MERCURY_DOWNLOAD_BASE.TrimEnd('/') } else { "https://github.com/$Repo/releases/download" }# ----- helpers ----------------------------------------------------------------function Write-Info ([string]$msg) { Write-Host "→ $msg" -ForegroundColor Green }+function Write-Info ([string]$msg) { Write-Host "-> $msg" -ForegroundColor Green }function Write-Warn2 ([string]$msg) { Write-Host "! $msg" -ForegroundColor Yellow }-function Die ([string]$msg) { Write-Host "x $msg" -ForegroundColor Red; exit 1 }+function Die ([string]$msg) {+ Write-Host "x $msg" -ForegroundColor Red+ # "irm ... | iex" from a fresh console closes the window on exit, so the+ # error was unreadable. Wait for Enter when a person is watching.+ if ($env:MERCURY_NO_PAUSE -ne '1' -and [Environment]::UserInteractive -and $Host.Name -eq 'ConsoleHost') {+ try { $null = Read-Host 'Press Enter to close' } catch { }+ }+ exit 1+}function Get-MercuryArch {$arch = $env:PROCESSOR_ARCHITECTURE@@ -117,11 +128,11 @@ function Update-UserPath ([string]$BinDir) {$IsDev = ($env:MERCURY_CHANNEL -eq 'dev')Write-Host ''-Write-Host '☿ Mercury installer' -ForegroundColor White-Write-Host ' Soul-driven AI agent · https://mercuryagent.sh'+Write-Host 'Mercury installer' -ForegroundColor White+Write-Host ' Soul-driven AI agent - https://mercuryagent.sh'Write-Host ''if ($IsDev) {- Write-Warn2 'Dev channel — unstable preview builds.'+ Write-Warn2 'Dev channel - unstable preview builds.'Write-Host (" Installs as {0}\bin\mercury-dev.exe (coexists with stable)." -f (Join-Path $HOME '.mercury-dev'))Write-Host ''}@@ -171,7 +182,12 @@ try {$checksumsUrl = "$releaseDir/checksums.txt"Write-Info 'Downloading checksums.txt ...'try {- $checksums = (Invoke-WebRequest -Uri $checksumsUrl -UseBasicParsing).Content+ # Windows PowerShell 5.1 returns a byte[] in .Content for+ # application/octet-stream (what GitHub serves checksums.txt as);+ # splitting that yields the literal "System.Byte[]" and no checksum+ # ever matches. Decode it ourselves; PowerShell 7 already hands a string.+ $raw = (Invoke-WebRequest -Uri $checksumsUrl -UseBasicParsing).Content+ $checksums = if ($raw -is [byte[]]) { [System.Text.Encoding]::UTF8.GetString($raw) } else { [string]$raw }} catch {Die "Failed to download required checksums from $checksumsUrl"}@@ -189,7 +205,7 @@ try {$archiveEntries = @(tar -tzf $webTmp)if ($LASTEXITCODE -ne 0) { Die 'Failed to inspect web.tar.gz' }foreach ($entry in $archiveEntries) {- # AppleDouble sidecars (._*, macOS tar's xattr artifact — invisible to+ # AppleDouble sidecars (._*, macOS tar's xattr artifact - invisible to# bsdtar, listed by GNU tar) are inert; the extraction stage discards# them. Traversal attempts stay fatal.if (($entry -notmatch '^web(/|$)' -and $entry -notmatch '^\._') -or $entry -match '(^|/)\.\.(/|$)') {@@ -270,7 +286,7 @@ Write-Info "Smoke test passed: $binName --version -> $smoke"$pathUpdated = Update-UserPath -BinDir $binDirWrite-Host ''-Write-Host "✓ Mercury $versionLabel is ready." -ForegroundColor Green+Write-Host "OK Mercury $versionLabel is ready." -ForegroundColor GreenWrite-Host ''if ($pathUpdated) {@@ -286,6 +302,6 @@ if ($pathUpdated) {Write-Host " $binPath # first run launches setup wizard"}if ($IsDev) {- Write-Warn2 'Dev channel — preview builds, may break. Re-run this script to update.'+ Write-Warn2 'Dev channel - preview builds, may break. Re-run this script to update.'}Write-Host ''diff --git a/website/static/install-dev.ps1 b/website/static/install-dev.ps1index 88b28eeb..1991cf7d 100755--- a/website/static/install-dev.ps1+++ b/website/static/install-dev.ps1@@ -3,7 +3,7 @@# irm https://mercuryagent.sh/install-dev.ps1 | iex## Installs the rolling `mercury-dev-latest` GitHub pre-release as-# mercury-dev.exe under ~\.mercury-dev — it coexists with a stable install+# mercury-dev.exe under ~\.mercury-dev - it coexists with a stable install# (mercury.exe under ~\.mercury) on the same machine. Re-run to update.## This is a thin wrapper around the stable installer with