The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): find a Windows launcher that is .cmd-only or off the SSH PATH
yoniebansac3b8d62a446
diff --git a/apps/desktop/electron/windows-remote-inventory.test.ts b/apps/desktop/electron/windows-remote-inventory.test.tsindex 5ea50d6fa91..e01f991afa5 100644--- a/apps/desktop/electron/windows-remote-inventory.test.ts+++ b/apps/desktop/electron/windows-remote-inventory.test.ts@@ -56,7 +56,7 @@ test('PATH bin launcher is resolved independently of its absent sibling Python,const script = streamed(command, options)calls.push(script)- if (script.includes('Get-Command hermes.exe')) {+ if (script.includes('Get-Command hermes -CommandType Application')) {return JSON.stringify({ ...runtime, python: '', launcherPath: runtime.hermesPath })}@@ -84,7 +84,7 @@ test('held marker stops launcher imports and unrecognized runtime capabilities fconst blocked = { exec: async (command: string, options: { stdinData?: string }) => {const script = streamed(command, options)- if (script.includes('Get-Command hermes.exe')) {return JSON.stringify({ ...runtime, launcherPath: runtime.hermesPath })}+ if (script.includes('Get-Command hermes -CommandType Application')) {return JSON.stringify({ ...runtime, launcherPath: runtime.hermesPath })}if (script.includes('.hermes-update-in-progress')) {return 'HELD'}imported = true@@ -98,7 +98,7 @@ test('held marker stops launcher imports and unrecognized runtime capabilities fconst invalid = { exec: async (command: string, options: { stdinData?: string }) => {const script = streamed(command, options)- if (script.includes('Get-Command hermes.exe')) {return JSON.stringify({ ...runtime, launcherPath: runtime.hermesPath })}+ if (script.includes('Get-Command hermes -CommandType Application')) {return JSON.stringify({ ...runtime, launcherPath: runtime.hermesPath })}if (script.includes('.hermes-update-in-progress')) {return 'CLEAR'}@@ -136,7 +136,7 @@ test('Connect refuses an older helper before token upload or backend spawn on aconst ssh = { exec: async (command: string, options: { stdinData?: string }) => {const script = streamed(command, options)- if (script.includes('Get-Command hermes.exe')) {return JSON.stringify({ ...runtime, launcherPath: runtime.hermesPath })}+ if (script.includes('Get-Command hermes -CommandType Application')) {return JSON.stringify({ ...runtime, launcherPath: runtime.hermesPath })}if (script.includes('.hermes-update-in-progress')) {return 'CLEAR'}diff --git a/apps/desktop/electron/windows-remote-lifecycle.test.ts b/apps/desktop/electron/windows-remote-lifecycle.test.tsindex 188edd41a61..395ae4d9574 100644--- a/apps/desktop/electron/windows-remote-lifecycle.test.ts+++ b/apps/desktop/electron/windows-remote-lifecycle.test.ts@@ -204,7 +204,7 @@ test('Windows relaunch gate refuses live and uncertain markers before executingconst script = scriptFromInvocation(command, options)scripts.push(script)- if (script.includes('Get-Command hermes.exe')) {+ if (script.includes('Get-Command hermes -CommandType Application')) {return JSON.stringify({os: 'Windows',arch: 'AMD64',diff --git a/apps/desktop/electron/windows-remote-lifecycle.ts b/apps/desktop/electron/windows-remote-lifecycle.tsindex 9ccd37e4f8d..568ce065459 100644--- a/apps/desktop/electron/windows-remote-lifecycle.ts+++ b/apps/desktop/electron/windows-remote-lifecycle.ts@@ -83,8 +83,12 @@ async function probeWindowsFiles(ssh, explicitHermesPath = '') {'$fallbackProfileCandidate=Join-Path $HOME "hermes-agent\\.venv\\Scripts\\hermes.exe"','$candidates=@()','if($explicit){$candidates+=$explicit}',- '$cmd=Get-Command hermes.exe -ErrorAction SilentlyContinue',+ // A bare `hermes` resolves through PATHEXT, so a published hermes.cmd counts as well as hermes.exe.+ '$cmd=@(Get-Command hermes -CommandType Application -ErrorAction SilentlyContinue)|Select-Object -First 1','if($cmd){Assert-NoReparse $cmd.Source $true;$cmdPython=[IO.Path]::Combine([IO.Path]::GetDirectoryName($cmd.Source), "python.exe");Assert-NoReparse $cmdPython $true;$candidates+=$cmd.Source}',+ // The installer's launchers, for an SSH session whose PATH lacks the user PATH entry.+ '$candidates+=Join-Path $hermesHome "bin\\hermes.exe"',+ '$candidates+=Join-Path $hermesHome "bin\\hermes.cmd"','$candidates+=$fallbackHomeCandidate','$candidates+=$fallbackProfileCandidate','$hermes=$null',diff --git a/apps/desktop/electron/windows-ssh-repair.test.ts b/apps/desktop/electron/windows-ssh-repair.test.tsindex a7e0afb373a..e644e943dda 100644--- a/apps/desktop/electron/windows-ssh-repair.test.ts+++ b/apps/desktop/electron/windows-ssh-repair.test.ts@@ -1,9 +1,13 @@import assert from 'node:assert/strict'+import { spawnSync } from 'node:child_process'+import fs from 'node:fs'+import os from 'node:os'+import path from 'node:path'import { test } from 'vitest'import { listRemoteHermesProfiles, readRemoteInstallId } from './remote-lifecycle'-import { assertWindowsRemoteInstallUpdateClear, connectWindowsRemote, probeWindowsRemote, windowsHelperOwnsRuntime } from './windows-remote-lifecycle'+import { assertWindowsRemoteInstallUpdateClear, connectWindowsRemote, probeWindowsFiles, probeWindowsRemote, windowsHelperOwnsRuntime } from './windows-remote-lifecycle'const runtime = {os: 'Windows', arch: 'AMD64', hermesHome: 'C:\\Users\\A\\AppData\\Local\\hermes',@@ -76,7 +80,7 @@ test('a bin launcher does not require a nonexistent sibling Python and resolvesconst ssh = { exec: async (command: string, options: { stdinData?: string }) => {const script = Buffer.from(String(options?.stdinData || '').trim(), 'base64').toString('utf16le')- if (script.includes('Get-Command hermes.exe')) {return JSON.stringify({ ...runtime, python: '', launcherPath: runtime.hermesPath })}+ if (script.includes('Get-Command hermes -CommandType Application')) {return JSON.stringify({ ...runtime, python: '', launcherPath: runtime.hermesPath })}if (script.includes('.hermes-update-in-progress')) {return 'CLEAR'}@@ -98,7 +102,7 @@ test('the complete connect path keeps atomic spawn off argv and delivers the expif (!token || script.includes('ReadToEnd')) {script = Buffer.from(String(options.stdinData || '').trim(), 'base64').toString('utf16le')}- if (script.includes('Get-Command hermes.exe')) {return JSON.stringify(runtime)}+ if (script.includes('Get-Command hermes -CommandType Application')) {return JSON.stringify(runtime)}if (script.includes("'spawn'")) {assert.ok(command.length < 8191, 'Connect must not inline its atomic spawn script')@@ -138,3 +142,29 @@ test('Test and Connect share one verdict on a helper too old for a boot-selectedassert.equal(windowsHelperOwnsRuntime(selected, { supported: true, runtimeBootstrapOwnership: 1 }), true)assert.equal(windowsHelperOwnsRuntime(runtime, { supported: true }), true)})++test.runIf(process.platform === 'win32')('the real Windows probe finds a .cmd-only launcher in the Hermes home off PATH', async () => {+ const home = fs.mkdtempSync(path.join(os.tmpdir(), 'hermes-probe-home-'))+ fs.mkdirSync(path.join(home, 'bin'))+ fs.writeFileSync(path.join(home, 'bin', 'hermes.cmd'), '@echo off\r\n')+ const system = process.env.SystemRoot || 'C:\\Windows'+ const env = { ...process.env, HERMES_HOME: home, PATH: [path.join(system, 'System32'), system, path.join(system, 'System32', 'WindowsPowerShell', 'v1.0')].join(';') }++ const ssh = {+ exec: async (command: string, options: { stdinData?: string } = {}) => {+ const [exe, ...args] = command.split(' ')+ const result = spawnSync(exe, args, { input: options.stdinData, encoding: 'utf8', env })++ if (result.status !== 0) {throw new Error(result.stderr)}++ return result.stdout+ }+ }++ try {+ const parsed = await probeWindowsFiles(ssh, '')+ assert.equal(parsed.hermesPath.toLowerCase(), path.join(home, 'bin', 'hermes.cmd').toLowerCase())+ } finally {+ fs.rmSync(home, { recursive: true, force: true })+ }+})