# BRIMIND edition for Hermes - Windows installer. # irm https://router.brimind.pro/install.ps1 | iex # Env: BRIMIND_API_KEY, HERMES_HOME, BRIMIND_VERSION, BRIMIND_DRY_RUN=1, BRIMIND_NONINTERACTIVE=1, BRIMIND_NO_HERMES_INSTALL=1 # Idempotent; backs up the previous pack first; the key goes only to $HERMES_HOME\.env. $ErrorActionPreference = 'Stop' Set-StrictMode -Version 2 function Install-Brimind { [CmdletBinding()] param( [string]$Key = $env:BRIMIND_API_KEY, [string]$HermesHome = $(if ($env:HERMES_HOME) { $env:HERMES_HOME } else { Join-Path $HOME '.hermes' }), [string]$Version = $env:BRIMIND_VERSION, [switch]$DryRun = ($env:BRIMIND_DRY_RUN -eq '1'), [switch]$NonInteractive = ($env:BRIMIND_NONINTERACTIVE -eq '1'), [switch]$NoHermesInstall = ($env:BRIMIND_NO_HERMES_INSTALL -eq '1') ) $base = if ($env:BRIMIND_DL_BASE) { $env:BRIMIND_DL_BASE } else { 'https://router.brimind.pro' } $env:HERMES_HOME = $HermesHome function Step([string]$m) { Write-Host " $m" } function Ok([string]$m) { Write-Host "[ok] $m" -ForegroundColor Green } function Act([scriptblock]$b, [string]$what) { if ($DryRun) { Write-Host " [dry-run] $what" } else { & $b } } Write-Host 'BRIMIND edition for Hermes - https://router.brimind.pro' -ForegroundColor Yellow Step "HERMES_HOME: $HermesHome" try { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 } catch { Write-Verbose 'TLS default' } # 1. Hermes $hb = $null $cmd = Get-Command hermes -ErrorAction SilentlyContinue if ($cmd) { $hb = $cmd.Source } if (-not $hb) { foreach ($c in @((Join-Path $HOME '.local\bin\hermes.exe'), (Join-Path $HOME '.local\bin\hermes.cmd'), (Join-Path $HermesHome 'hermes-agent\.hermes\bin\hermes.cmd'))) { if (Test-Path $c) { $hb = $c; break } } } if (-not $hb) { if ($NoHermesInstall) { throw 'Hermes not found and BRIMIND_NO_HERMES_INSTALL=1' } Step 'Hermes not found: installing it with the official installer...' Act { Invoke-RestMethod 'https://hermes-agent.nousresearch.com/install.ps1' | Invoke-Expression } 'irm https://hermes-agent.nousresearch.com/install.ps1 | iex' $cmd = Get-Command hermes -ErrorAction SilentlyContinue if ($cmd) { $hb = $cmd.Source } elseif ($DryRun) { $hb = 'hermes' } else { throw 'Hermes install did not put hermes on PATH; open a new terminal and re-run.' } } Ok "Hermes: $hb" # 2. Download + verify $man = Invoke-RestMethod -Uri "$base/version.json" -TimeoutSec 20 if (-not $Version) { $Version = $man.latest } $name = "brimind-hermes-$Version.zip" $asset = $null foreach ($f in @($man.files)) { if ($f -and $f.name -eq $name) { $asset = $f } } if (-not $asset) { throw "version $Version not found in $base/version.json" } $tmp = Join-Path ([IO.Path]::GetTempPath()) ("brimind-" + [guid]::NewGuid().ToString('N')) New-Item -ItemType Directory -Path $tmp | Out-Null try { $zip = Join-Path $tmp $name Step "Downloading BRIMIND $Version..." Invoke-WebRequest -Uri "$base/dl/$name" -OutFile $zip -UseBasicParsing -TimeoutSec 120 $got = (Get-FileHash -Algorithm SHA256 -Path $zip).Hash.ToLowerInvariant() if ($got -ne $asset.sha256) { throw "sha256 mismatch (got $got, expected $($asset.sha256))" } Ok "sha256 $got" Expand-Archive -Path $zip -DestinationPath $tmp -Force $src = Join-Path $tmp 'brimind-hermes' if (-not (Test-Path (Join-Path $src 'plugins'))) { throw 'archive layout unexpected' } # 3. Backup + install $rels = @('plugins\model-providers\brimind', 'plugins\brimind-edition', 'desktop-plugins\brimind-edition', 'desktop-plugins\bot-context-lengths') $bk = Join-Path $HermesHome ('brimind\backups\install-' + (Get-Date -Format 'yyyyMMdd-HHmmss')) foreach ($r in $rels) { $p = Join-Path $HermesHome $r if (Test-Path $p) { Act { $d = Join-Path $bk $r; New-Item -ItemType Directory -Force -Path (Split-Path $d) | Out-Null; Copy-Item -Recurse -Force $p $d } "backup $r" } } $cfg = Join-Path $HermesHome 'config.yaml' if (Test-Path $cfg) { Act { New-Item -ItemType Directory -Force -Path $bk | Out-Null; Copy-Item $cfg (Join-Path $bk 'config.yaml') } 'backup config.yaml' } foreach ($r in $rels) { $s = Join-Path $src $r; $d = Join-Path $HermesHome $r if (Test-Path $s) { Act { New-Item -ItemType Directory -Force -Path (Split-Path $d) | Out-Null; if (Test-Path $d) { Remove-Item -Recurse -Force $d }; Copy-Item -Recurse -Force $s $d } "install $r" } } Ok 'pack files installed' } finally { Remove-Item -Recurse -Force $tmp -ErrorAction SilentlyContinue } # 4. Key $envf = Join-Path $HermesHome '.env' $have = $null if (Test-Path $envf) { $have = Select-String -Path $envf -Pattern '^BRIMIND_API_KEY=bk-' -ErrorAction SilentlyContinue | Select-Object -First 1 } if (-not $Key -and -not $have -and -not $NonInteractive) { Write-Host 'Your BRIMIND key (bk-...): https://ai.brimind.pro/developers' $sec = Read-Host -AsSecureString 'Paste your key' $Key = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($sec)) } if ($Key) { $Key = $Key.Trim() if (-not $Key.StartsWith('bk-')) { throw 'A BRIMIND key starts with bk-' } if (-not $DryRun) { try { Invoke-RestMethod -Uri 'https://api.brimind.pro/v1/models' -Headers @{ Authorization = "Bearer $Key" } -TimeoutSec 20 | Out-Null } catch { throw "key rejected by api.brimind.pro: $($_.Exception.Message)" } New-Item -ItemType Directory -Force -Path $HermesHome | Out-Null $lines = @(); if (Test-Path $envf) { $lines = @(Get-Content $envf | Where-Object { $_ -notmatch '^BRIMIND_API_KEY=' }) } $lines += "BRIMIND_API_KEY=$Key" Set-Content -Path $envf -Value $lines -Encoding ascii } Ok ("key saved to $envf (bk-..." + $Key.Substring([Math]::Max(0, $Key.Length - 4)) + ')') } elseif ($have) { Ok 'key already present (kept)' } else { Write-Host "! no key yet: run 'hermes model' -> BRIMIND later" -ForegroundColor Yellow } # 5. Enable, patch, default model on a fresh setup only Act { & $hb plugins enable brimind-edition *> $null } 'hermes plugins enable brimind-edition' Act { & $hb brimind repatch *> $null } 'hermes brimind repatch' $cur = $null if (Test-Path $cfg) { $m = Select-String -Path $cfg -Pattern '^\s{2}provider:\s*"?([^"\s]+)' | Select-Object -First 1; if ($m) { $cur = $m.Matches[0].Groups[1].Value } } if (($Key -or $have) -and (-not $cur -or $cur -eq 'auto')) { Act { & $hb config set model.provider brimind *> $null; & $hb config set model.default codex:medium *> $null; & $hb config set model.base_url https://api.brimind.pro/v1 *> $null } 'hermes config set model.provider brimind / model.default codex:medium' Ok 'default model: BRIMIND codex:medium' } Ok "BRIMIND $Version installed. Run 'hermes'. Update: hermes brimind update | Uninstall: irm $base/uninstall.ps1 | iex" } Install-Brimind