hermes-agent/apps/desktop/electron/windows-runtime-command.ts
yoniebans 7f72db17af fix(desktop): read the Windows SSH inventory through the runtime helper
The roster and install-id reads ran Python by rewriting the launcher's bootstrap source, behind their own PowerShell link scan and install-root rule. A link inside any profile directory aborted the whole roster, and a home nested under the install root read its install id from a different directory than the profile list.

Both reads now come from one read-only `inventory` operation of the runtime helper, reached through `--run-module` like every other helper call. It uses the install's own root resolution, profile predicate and identity reader, and creates nothing. The source rewrite and the launcher gate that required its spelling are gone.
2026-10-24 10:28:47 +02:00

30 lines
1.6 KiB
TypeScript

// The published launcher owns PM activation. A Python guessed beside bin/hermes.exe does not.
export interface WindowsRuntime {
os?: string
arch?: string
hermesHome: string
hermesPath: string
python: string
launcherPath?: string
runtimeCommand?: string[]
}
// Helpers enter through the launcher's own module dispatch, which owns PM activation;
// every caller then needs only the launcher path it already carries.
export function windowsHelperArgv(runtime: WindowsRuntime, operation: string, args: string[] = []): string[] {
return [runtime.hermesPath, '--run-module', 'hermes_cli.windows_ssh_runtime', operation, ...args]
}
// Same ancestor/leaf guard as the existing platform and marker probes.
export const WINDOWS_NO_REPARSE_PS = [
'function Assert-NoReparse([string]$candidate,[bool]$allowMissing=$false){',
'if([string]::IsNullOrWhiteSpace($candidate)){throw "Empty Windows path"}',
'$current=[IO.Path]::GetFullPath($candidate);$first=$true',
'while($true){',
'try{$item=Get-Item -LiteralPath $current -Force -ErrorAction Stop}catch [Management.Automation.ItemNotFoundException]{if(-not $allowMissing -and $first){throw "Path was not found: $candidate"};$parent=[IO.Path]::GetDirectoryName($current);if(-not $parent -or $parent -eq $current){break};$current=$parent;$first=$false;continue}',
'if(($item.Attributes -band [IO.FileAttributes]::ReparsePoint) -ne 0){throw "Path contains a link or reparse point: $current"}',
'$parent=[IO.Path]::GetDirectoryName($current);if(-not $parent -or $parent -eq $current){break};$current=$parent;$first=$false',
'}',
'}'
].join('\r\n')