The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
chore(desktop): drop four electron modules nothing imports
ethernet7f6ec2749e07
diff --git a/apps/desktop/electron/deep-link-route.test.ts b/apps/desktop/electron/deep-link-route.test.tsdeleted file mode 100644index 8c1c5135577..00000000000--- a/apps/desktop/electron/deep-link-route.test.ts+++ /dev/null@@ -1,14 +0,0 @@-import { expect, it } from 'vitest'--import { routeDeepLink } from './deep-link-route'--it.each([- ['copilot-key', 'start', 'quick-entry'],- ['copilot-key', 'stop', 'ignore'],- ['copilot-key', '', 'ignore'],- ['copilot-key', 'toggle', 'ignore'],- ['blueprint', 'morning-brief', 'renderer'],- ['', '', 'renderer']-] as const)('%s/%s → %s', (host: string, pathname: string, expected: string): void => {- expect(routeDeepLink(host, pathname)).toBe(expected)-})diff --git a/apps/desktop/electron/deep-link-route.ts b/apps/desktop/electron/deep-link-route.tsdeleted file mode 100644index 9cd83791eb4..00000000000--- a/apps/desktop/electron/deep-link-route.ts+++ /dev/null@@ -1,26 +0,0 @@-/**- * Where a hermes:// deep link is handled. Pure — main.ts routes on the- * result, tests assert the contract.- *- * 'quick-entry' — summon the ephemeral quick-entry popup in the main- * process. Used by the Windows Copilot hardware key: the MSIX manifest- * fragment (generated by electron-builder.config.cjs) registers the app- * as a copilotkeyprovider whose press activates- * <scheme>://copilot-key/start.- * A hardware key wants the lightweight composer, not the full window.- * 'ignore' — activation noise that must not reach the renderer. The- * Copilot key's press-and-hold RELEASE fires copilot-key/stop; a tap- * fires start+stop nearly together, so acting on stop would undo the- * summon. Unknown copilot-key paths land here too.- * 'renderer' — everything else: focus the main window and deliver the- * payload to the renderer's deep-link listener (blueprint links etc.).- */-export type DeepLinkRoute = 'ignore' | 'quick-entry' | 'renderer'--export function routeDeepLink(kind: string, name: string): DeepLinkRoute {- if (kind === 'copilot-key') {- return name === 'start' ? 'quick-entry' : 'ignore'- }-- return 'renderer'-}diff --git a/apps/desktop/electron/gitlock.test.ts b/apps/desktop/electron/gitlock.test.tsdeleted file mode 100644index 342a9cd4b14..00000000000--- a/apps/desktop/electron/gitlock.test.ts+++ /dev/null@@ -1,71 +0,0 @@-import assert from 'node:assert/strict'-import fs from 'node:fs'-import os from 'node:os'-import path from 'node:path'--import { test } from 'vitest'--import { clearStaleGitLocks, LOCK_NAMES, STALE_LOCK_MIN_AGE_MS } from './gitlock'--function makeRepo(): string {- const root = fs.mkdtempSync(path.join(os.tmpdir(), 'gitlock-test-'))- fs.mkdirSync(path.join(root, '.git'))-- return root-}--function writeLock(root: string, name: string, ageMs: number): string {- const p = path.join(root, '.git', name)- fs.writeFileSync(p, '')- const t = new Date(Date.now() - ageMs)- fs.utimesSync(p, t, t)-- return p-}--const noGit = async () => false-const gitRunning = async () => true--test('stale shallow.lock older than min age is removed', async () => {- const root = makeRepo()- const lock = writeLock(root, 'shallow.lock', STALE_LOCK_MIN_AGE_MS + 60_000)- const removed = await clearStaleGitLocks(root, { isGitRunning: noGit })- assert.deepEqual(removed, [lock])- assert.equal(fs.existsSync(lock), false)-})--test('fresh lock is presumed live and never removed', async () => {- const root = makeRepo()- const lock = writeLock(root, 'shallow.lock', 1_000)- const removed = await clearStaleGitLocks(root, { isGitRunning: noGit })- assert.deepEqual(removed, [])- assert.equal(fs.existsSync(lock), true)-})--test('running git process protects even ancient locks', async () => {- const root = makeRepo()- const lock = writeLock(root, 'shallow.lock', STALE_LOCK_MIN_AGE_MS * 10)- const removed = await clearStaleGitLocks(root, { isGitRunning: gitRunning })- assert.deepEqual(removed, [])- assert.equal(fs.existsSync(lock), true)-})--test('all known lock names are cleared when stale', async () => {- const root = makeRepo()- const locks = LOCK_NAMES.map(name => writeLock(root, name, STALE_LOCK_MIN_AGE_MS + 60_000))- const removed = await clearStaleGitLocks(root, { isGitRunning: noGit })- assert.deepEqual(removed.sort(), locks.sort())-})--test('unknown lock-like files are left alone', async () => {- const root = makeRepo()- const stray = writeLock(root, 'config.lock', STALE_LOCK_MIN_AGE_MS * 10)- await clearStaleGitLocks(root, { isGitRunning: noGit })- assert.equal(fs.existsSync(stray), true)-})--test('missing .git dir is a silent no-op', async () => {- const root = fs.mkdtempSync(path.join(os.tmpdir(), 'gitlock-nogit-'))- const removed = await clearStaleGitLocks(root, { isGitRunning: noGit })- assert.deepEqual(removed, [])-})diff --git a/apps/desktop/electron/gitlock.ts b/apps/desktop/electron/gitlock.tsdeleted file mode 100644index 6beab799ea5..00000000000--- a/apps/desktop/electron/gitlock.ts+++ /dev/null@@ -1,96 +0,0 @@-// Stale git lock-file recovery for the desktop update-check path.-//-// A crashed or killed `git fetch` on a shallow clone can leave-// `.git/shallow.lock` behind. Every later fetch then fails with-// "fatal: Unable to create '.git/shallow.lock': File exists", so the desktop-// update check reports 'fetch-failed' forever — git never self-heals these-// lock files. Mirrors hermes_cli/gitlock.py: a lock is removed only when it-// is older than the min age AND no git process is currently running.--import { execFile } from 'node:child_process'-import fs from 'node:fs'-import path from 'node:path'--// Lock files younger than this are presumed live (a fetch is in flight) and-// are never removed. git lock files live for seconds under normal operation;-// anything older than 10 minutes is abandoned.-export const STALE_LOCK_MIN_AGE_MS = 10 * 60 * 1000--// Same self-healable lock set as hermes_cli/gitlock.py.-export const LOCK_NAMES = ['shallow.lock', 'index.lock', 'HEAD.lock', 'MERGE_HEAD.lock']--function gitProcessRunning(): Promise<boolean> {- return new Promise(resolve => {- const [cmd, args] =- process.platform === 'win32'- ? ['tasklist', ['/FI', 'IMAGENAME eq git.exe', '/FO', 'CSV']]- : ['pgrep', ['-x', 'git']]-- execFile(cmd, args, { timeout: 10_000 }, (error, stdout) => {- if (process.platform === 'win32') {- // tasklist exits 0 either way; presence is signaled in stdout.- resolve(Boolean(stdout && stdout.toLowerCase().includes('git.exe')))-- return- }-- // pgrep: exit 0 = at least one match; 1 = none; other = probe failure.- // On probe failure stay conservative: report "running" so no lock is- // touched when we cannot tell.- if (error && (error as any).code === 1) {- resolve(false)-- return- }-- resolve(true)- })- })-}--// Remove abandoned .git lock files under repoRoot. Returns removed paths.-// Never throws: a lock we cannot stat or unlink is skipped.-export async function clearStaleGitLocks(- repoRoot: string,- {- minAgeMs = STALE_LOCK_MIN_AGE_MS,- isGitRunning = gitProcessRunning- }: {- minAgeMs?: number- isGitRunning?: () => Promise<boolean>- } = {}-): Promise<string[]> {- const gitDir = path.join(repoRoot, '.git')- const removed: string[] = []-- try {- if (!fs.statSync(gitDir).isDirectory()) {- return removed- }- } catch {- return removed- }-- if (await isGitRunning()) {- return removed- }-- const cutoff = Date.now() - minAgeMs-- for (const name of LOCK_NAMES) {- const lockPath = path.join(gitDir, name)-- try {- const st = fs.statSync(lockPath)-- if (st.isFile() && st.mtimeMs < cutoff) {- fs.unlinkSync(lockPath)- removed.push(lockPath)- }- } catch {- // Missing or concurrently removed — skipping is always safe.- }- }-- return removed-}diff --git a/apps/desktop/electron/pool-eviction.test.ts b/apps/desktop/electron/pool-eviction.test.tsdeleted file mode 100644index 486729114ef..00000000000--- a/apps/desktop/electron/pool-eviction.test.ts+++ /dev/null@@ -1,186 +0,0 @@-/**- * Tests for electron/pool-eviction.ts — LRU cap accounting for the desktop- * backend pool. The cap exists to bound SPAWNED local backends (real child- * processes); process-less descriptor entries (remote/cloud registry sources,- * per-profile remote overrides) must not count against it, or a roster- * refresh across N registered remote connections evicts a real local backend- * that was merely idle past the keepalive window.- */--import assert from 'node:assert/strict'--import { test } from 'vitest'--import { evictPoolEntries, selectPoolEvictions } from './pool-eviction'--const NOW = 1_000_000-// Mirrors main.ts POOL_KEEPALIVE_FRESH_MS (4 minutes — see #95189).-const FRESH_MS = 4 * 60_000--/** A spawned local backend entry (has a child process). */-const spawned = (idleMs: number) => ({ process: { pid: 123 }, lastActiveAt: NOW - idleMs })--/** A process-less remote/cloud descriptor entry. */-const descriptor = (idleMs: number) => ({ process: null, lastActiveAt: NOW - idleMs })--test('process-less descriptors do not count toward the cap', () => {- // 1 real spawned backend idle beyond the keepalive window + 3 remote- // descriptors: total size (4) exceeds keep (2), but only ONE entry holds a- // process, so nothing may be evicted. This is the roster-refresh regression:- // the old size-based accounting evicted the real local backend here.- const entries: [string, ReturnType<typeof spawned>][] = [- ['default', spawned(120_000)],- ['conn:homelab::default', descriptor(0)],- ['conn:office::default', descriptor(0)],- ['conn:cloud-a::default', descriptor(0)]- ]-- assert.deepEqual(selectPoolEvictions(entries, 2, NOW, FRESH_MS), [])-})--test('spawned backends over the cap are still LRU-evicted', () => {- const entries: [string, ReturnType<typeof spawned>][] = [- ['a', spawned(500_000)],- ['b', spawned(300_000)],- ['c', spawned(100_000)],- // Descriptors interleaved: must neither inflate the count nor be evicted.- ['conn:x::a', descriptor(999_000)]- ]-- // keep=2 → one spawned backend over; evict the least-recently-used ('a').- assert.deepEqual(selectPoolEvictions(entries, 2, NOW, FRESH_MS), ['a'])-})--test('fresh spawned backends are spared even over the cap', () => {- const entries: [string, ReturnType<typeof spawned>][] = [- ['a', spawned(1_000)],- ['b', spawned(2_000)],- ['c', spawned(3_000)]- ]-- // All within the keepalive window → the pool may exceed the soft cap.- assert.deepEqual(selectPoolEvictions(entries, 1, NOW, FRESH_MS), [])-})--test('evicts only enough stale spawned backends to reach the cap', () => {- const entries: [string, ReturnType<typeof spawned>][] = [- ['a', spawned(500_000)],- ['b', spawned(400_000)],- ['c', spawned(300_000)],- ['d', spawned(1_000)]- ]-- // 4 spawned, keep 2 → remove 2, oldest first.- assert.deepEqual(selectPoolEvictions(entries, 2, NOW, FRESH_MS), ['a', 'b'])-})--test('descriptor-only pools never evict', () => {- const entries: [string, ReturnType<typeof descriptor>][] = [- ['conn:a::p', descriptor(999_000)],- ['conn:b::p', descriptor(999_000)],- ['conn:c::p', descriptor(999_000)],- ['conn:d::p', descriptor(999_000)]- ]-- assert.deepEqual(selectPoolEvictions(entries, 2, NOW, FRESH_MS), [])-})--test('making room waits for every selected backend to finish stopping', async () => {- let releaseStop!: () => void-- const stopGate = new Promise<void>(resolve => {- releaseStop = resolve- })-- const stopped: string[] = []- let settled = false-- const entries: [string, ReturnType<typeof spawned>][] = [- ['oldest', spawned(500_000)],- ['fresh', spawned(1_000)]- ]-- const eviction = evictPoolEntries(entries, 1, NOW, FRESH_MS, async key => {- stopped.push(key)- await stopGate- }).then(keys => {- settled = true-- return keys- })-- await Promise.resolve()- assert.deepEqual(stopped, ['oldest'])- assert.equal(settled, false, 'a replacement must not race the exiting child for its slot')-- releaseStop()- assert.deepEqual(await eviction, ['oldest'])- assert.equal(settled, true)-})--// ── #95189 — Keepalive-fresh window must tolerate transient missed pings ──-// Symptom: gateway restarts every ~2 minutes on WSL2. Root cause: the renderer-// pings every 60s; the LRU cap declared a backend "stale" if `lastActiveAt`-// was > 90s ago — only 1.5× the ping interval. WSL2 IPC roundtrips (renderer-// → 9p → Electron main → ipcMain.handle) commonly stall several seconds; one-// delayed or missed ping pushed a live backend past the threshold and the-// cap-driven eviction killed the active profile's backend mid-session,-// forcing a restart loop that re-minted runtime ids and re-allocated pooled-// gateway secondaries ~700×/day (#95189, related #87906/#84716/#88054).-//-// These tests pin the new tolerance: the keepalive-fresh window is wide-// enough to absorb ≥1 missed ping (and the IPC stall headroom around it)-// without evicting an active backend. Truly stale backends (multiple lapses,-// minutes idle) are still evicted as before.--test('#95189: one missed keepalive ping must NOT make the most-recently-touched backend evictable', () => {- // Renderer's keepalive cadence is 60s. With the old freshMs=90s window,- // a backend last touched 95s ago — i.e. exactly ONE missed/delayed ping —- // was eligible for LRU eviction even though it had been actively- // touched the moment before and would be touched again imminently.- //- // Build a pool where the only entry over the cap is the active one (95s- // idle). With the old 90s window, it was evicted; with the widened window- // the cap must instead be honored by leaving the pool over-cap for one- // extra cycle — killing an active backend is far worse than briefly- // exceeding the soft cap.- const entries: [string, ReturnType<typeof spawned>][] = [- ['active', spawned(95_000)], // 1 missed ping on a 60s cadence- ['fresher', spawned(2_000)] // touched recently — must NOT be evicted- ]-- // keep=1 → pool over cap by one. Active backend must be spared; the cap- // may be exceeded rather than kill a live backend (the long-standing- // "spare fresh backends" rule from #94381 / earlier pool-eviction tests).- assert.deepEqual(selectPoolEvictions(entries, 1, NOW, FRESH_MS), [])-})--test('#95189: two missed keepalive pings (2-min IPC stall) must NOT evict an active backend', () => {- // The reported symptom: gateways exited ~80–90s after start with a clean- // disconnect (no stderr), recurring every ~2 min. Reproduce the boundary:- // 125s of silence = just over two missed pings at 60s. A backend in this- // state is still actively serving — the renderer is mid-reconnect, not- // gone — so eviction here was the trigger for the restart loop.- //- // The other entries are all FRESH (well within the keepalive window), so- // no eviction is correct even before any cap considerations.- const entries: [string, ReturnType<typeof spawned>][] = [- ['active', spawned(125_000)],- ['fresher', spawned(2_000)],- ['fresher-2', spawned(5_000)]- ]-- assert.deepEqual(selectPoolEvictions(entries, 1, NOW, FRESH_MS), [])-})--test('#95189: a backend genuinely idle for minutes IS evicted (#95189 long-window scenario)', () => {- // Sanity: the widening does NOT make the pool unbounded. 10 minutes of- // silence (the documented POOL_IDLE_MS) is still fair game.- const entries: [string, ReturnType<typeof spawned>][] = [- ['idle', spawned(10 * 60_000)],- ['fresh', spawned(5_000)]- ]-- // keep=1, idle is over the cap AND past the fresh window → evicted.- assert.deepEqual(selectPoolEvictions(entries, 1, NOW, FRESH_MS), ['idle'])-})diff --git a/apps/desktop/electron/pool-eviction.ts b/apps/desktop/electron/pool-eviction.tsdeleted file mode 100644index e17b17ffdca..00000000000--- a/apps/desktop/electron/pool-eviction.ts+++ /dev/null@@ -1,81 +0,0 @@-// LRU cap accounting for the desktop backend pool.-//-// The pool holds two very different kinds of entries under one Map:-// 1. SPAWNED local profile backends — a real child process each (the thing-// the POOL_MAX_BACKENDS cap exists to bound).-// 2. Process-less connection DESCRIPTORS — remote/cloud registry sources and-// per-profile remote overrides (`entry.process === null`). These hold no-// local process; their only cost is a cached descriptor.-//-// Counting both kinds against the cap meant a roster refresh across N-// registered remote connections could push the Map size over the cap and-// LRU-evict a REAL spawned backend that had merely been idle past the-// keepalive window. Cap accounting (and cap-driven eviction) therefore only-// considers entries with a live child process; descriptor entries remain-// subject to the idle reaper, just not to the process cap.--export interface PoolEvictionEntry {- lastActiveAt?: null | number- process?: unknown-}--/**- * Pick which pool keys the LRU cap should evict so that at most `keep`- * SPAWNED backends remain. Only entries with a live child process count- * toward the cap or are eligible for cap eviction, and — as before — only- * entries idle beyond `freshMs` may be evicted (an actively kept-alive pool- * may exceed the soft cap rather than kill a running session).- */-export function selectPoolEvictions<K>(- entries: Iterable<[K, PoolEvictionEntry]>,- keep: number,- now: number,- freshMs: number-): K[] {- const spawned = [...entries].filter(([, entry]) => Boolean(entry.process))-- if (spawned.length <= keep) {- return []- }-- const evictable = spawned- .filter(([, entry]) => now - (entry.lastActiveAt || 0) > freshMs)- .sort((a, b) => (a[1].lastActiveAt || 0) - (b[1].lastActiveAt || 0))-- let removable = spawned.length - Math.max(0, keep)- const evictions: K[] = []-- for (const [key] of evictable) {- if (removable <= 0) {- break- }-- evictions.push(key)- removable -= 1- }-- return evictions-}--/**- * Evict enough stale spawned backends to make room, and do not report the- * room as available until every selected child has actually exited.- *- * Selection and teardown deliberately live in one helper: callers that fire- * stopBackend() without awaiting it can enqueue a replacement while the old- * child still owns its hard spawn slot. Under a restore stampede that race- * turns successful LRU selection into a 30-second queue timeout.- */-export async function evictPoolEntries<K>(- entries: Iterable<[K, PoolEvictionEntry]>,- keep: number,- now: number,- freshMs: number,- stopBackend: (key: K) => Promise<void>-): Promise<K[]> {- const evictions = selectPoolEvictions(entries, keep, now, freshMs)-- await Promise.all(evictions.map(key => stopBackend(key)))-- return evictions-}diff --git a/apps/desktop/electron/pool-stop.ts b/apps/desktop/electron/pool-stop.tsindex 047974dcb68..dbbd8735fa4 100644--- a/apps/desktop/electron/pool-stop.ts+++ b/apps/desktop/electron/pool-stop.ts@@ -17,8 +17,8 @@* - spawn paths can await inFlight(key) so a fresh child never overlaps a* dying one on the same HERMES_HOME.*- * Extracted into a dependency-free module (same pattern as backend-child.ts /- * pool-eviction.ts) so the dedup and handle-retention semantics are asserted+ * Extracted into a dependency-free module (same pattern as backend-child.ts)+ * so the dedup and handle-retention semantics are asserted* directly instead of grepping main.ts source text.*/diff --git a/apps/desktop/electron/update-remote.test.ts b/apps/desktop/electron/update-remote.test.tsdeleted file mode 100644index 80dc8b1dd0b..00000000000--- a/apps/desktop/electron/update-remote.test.ts+++ /dev/null@@ -1,79 +0,0 @@-/**- * Tests for electron/update-remote.ts — the remote-detection helpers that- * keep passive update checks off the SSH origin for official installs.- *- * Run with: node --test electron/update-remote.test.ts- * (Wired into npm test:desktop:platforms in package.json.)- *- * Why this matters: a public install can carry- * [email protected]:NousResearch/hermes-agent.git. A background- * `git fetch origin` then authenticates over SSH and, with a FIDO2/passkey- * key, triggers an unexplained hardware-touch prompt. isOfficialSshRemote- * must reliably recognize the official SSH remote (in every URL form,- * case-insensitively) so the caller can swap in the anonymous HTTPS path —- * while NOT misclassifying forks, other hosts, or the HTTPS remote (which- * never prompts and should keep the normal fetch path).- */--import assert from 'node:assert/strict'--import { test } from 'vitest'--import {- canonicalGitHubRemote,- isOfficialSshRemote,- isSshRemote,- OFFICIAL_REPO_CANONICAL,- OFFICIAL_REPO_HTTPS_URL-} from './update-remote'--test('canonicalGitHubRemote normalizes SSH and HTTPS forms to the same value', () => {- assert.equal(canonicalGitHubRemote('[email protected]:NousResearch/hermes-agent.git'), OFFICIAL_REPO_CANONICAL)- assert.equal(canonicalGitHubRemote('[email protected]:NousResearch/hermes-agent'), OFFICIAL_REPO_CANONICAL)- assert.equal(canonicalGitHubRemote('ssh://[email protected]/NousResearch/hermes-agent.git'), OFFICIAL_REPO_CANONICAL)- assert.equal(canonicalGitHubRemote('https://github.com/NousResearch/hermes-agent.git'), OFFICIAL_REPO_CANONICAL)- // Case-insensitive: an uppercased owner still canonicalizes to the same repo.- assert.equal(canonicalGitHubRemote('[email protected]:nousresearch/hermes-agent.git'), OFFICIAL_REPO_CANONICAL)- // Trailing slashes are stripped.- assert.equal(canonicalGitHubRemote('https://github.com/NousResearch/hermes-agent/'), OFFICIAL_REPO_CANONICAL)-})--test('canonicalGitHubRemote is empty for falsy input', () => {- assert.equal(canonicalGitHubRemote(''), '')- assert.equal(canonicalGitHubRemote(null), '')- assert.equal(canonicalGitHubRemote(undefined), '')-})--test('isSshRemote detects scp-like and ssh:// forms only', () => {- assert.equal(isSshRemote('[email protected]:NousResearch/hermes-agent.git'), true)- assert.equal(isSshRemote('ssh://[email protected]/NousResearch/hermes-agent.git'), true)- assert.equal(isSshRemote('https://github.com/NousResearch/hermes-agent.git'), false)- assert.equal(isSshRemote(''), false)- assert.equal(isSshRemote(null), false)-})--test('isOfficialSshRemote is true only for the official repo over SSH', () => {- assert.equal(isOfficialSshRemote('[email protected]:NousResearch/hermes-agent.git'), true)- assert.equal(isOfficialSshRemote('[email protected]:NousResearch/hermes-agent'), true)- assert.equal(isOfficialSshRemote('ssh://[email protected]/NousResearch/hermes-agent.git'), true)- // Case-insensitive owner/repo match.- assert.equal(isOfficialSshRemote('[email protected]:nousresearch/hermes-agent.git'), true)-})--test('isOfficialSshRemote does NOT match forks, other hosts, or HTTPS', () => {- // A fork over SSH belongs to the user — fetching it is their own remote,- // not the official upstream, so the SSH-avoidance swap must not apply.- assert.equal(isOfficialSshRemote('[email protected]:someuser/hermes-agent.git'), false)- // Same repo name on a different host is not the official repo.- assert.equal(isOfficialSshRemote('[email protected]:NousResearch/hermes-agent.git'), false)- // HTTPS to the official repo never prompts for SSH/FIDO2, so it keeps the- // normal fetch path — must not be flagged as an official SSH remote.- assert.equal(isOfficialSshRemote('https://github.com/NousResearch/hermes-agent.git'), false)- assert.equal(isOfficialSshRemote(''), false)- assert.equal(isOfficialSshRemote(null), false)-})--test('OFFICIAL_REPO_HTTPS_URL canonicalizes to OFFICIAL_REPO_CANONICAL', () => {- // Invariant: the URL we substitute in must be the same repo we detect.- assert.equal(canonicalGitHubRemote(OFFICIAL_REPO_HTTPS_URL), OFFICIAL_REPO_CANONICAL)-})diff --git a/apps/desktop/electron/update-remote.ts b/apps/desktop/electron/update-remote.tsdeleted file mode 100644index 1c5a6d57c74..00000000000--- a/apps/desktop/electron/update-remote.ts+++ /dev/null@@ -1,65 +0,0 @@-/**- * Pure helpers for choosing a remote URL during passive update checks.- *- * A public install can end up with `[email protected]:NousResearch/hermes-agent.git`.- * If the user's GitHub SSH key is FIDO2/passkey-backed, a background `git fetch- * origin` triggers an unexplained hardware-touch prompt. For passive checks- * against the official repo we substitute the public HTTPS `ls-remote` path,- * which needs no auth and cannot prompt. Active update/apply flows are left- * unchanged.- *- * Extracted from main.ts so the security-critical remote detection is unit- * testable without booting Electron (main.ts requires('electron') at load).- */--const OFFICIAL_REPO_HTTPS_URL = 'https://github.com/NousResearch/hermes-agent.git'-const OFFICIAL_REPO_CANONICAL = 'github.com/nousresearch/hermes-agent'--// Normalize common GitHub remote URL forms to `host/owner/repo` (lowercased,-// no trailing slash, no .git suffix) so SSH and HTTPS forms of the same repo-// compare equal.-function canonicalGitHubRemote(url) {- if (!url) {- return ''- }-- let value = String(url).trim()-- if (value.startsWith('[email protected]:')) {- value = `github.com/${value.slice('[email protected]:'.length)}`- } else if (value.startsWith('ssh://[email protected]/')) {- value = `github.com/${value.slice('ssh://[email protected]/'.length)}`- } else {- try {- const parsed = new URL(value)-- if (parsed.hostname && parsed.pathname) {- value = `${parsed.hostname}${parsed.pathname}`- }- } catch {- // Leave non-URL forms unchanged.- }- }-- value = value.trim().replace(/\/+$/, '')-- if (value.endsWith('.git')) {- value = value.slice(0, -4)- }-- return value.toLowerCase()-}--function isSshRemote(url) {- const value = String(url || '')- .trim()- .toLowerCase()-- return value.startsWith('git@') || value.startsWith('ssh://')-}--function isOfficialSshRemote(url) {- return isSshRemote(url) && canonicalGitHubRemote(url) === OFFICIAL_REPO_CANONICAL-}--export { canonicalGitHubRemote, isOfficialSshRemote, isSshRemote, OFFICIAL_REPO_CANONICAL, OFFICIAL_REPO_HTTPS_URL }