Skip to content

The agent that grows with you

style(desktop): sort imports and drop unused ones (eslint errors)

ethernet3f4064199e93
diff --git a/apps/desktop/electron/backend-probes.test.ts b/apps/desktop/electron/backend-probes.test.ts
index 14ab37efbfe..aceb596757c 100644
--- a/apps/desktop/electron/backend-probes.test.ts
+++ b/apps/desktop/electron/backend-probes.test.ts
@@ -6,7 +6,6 @@
*/
import assert from 'node:assert/strict'
-import fs from 'node:fs'
import net from 'node:net'
import os from 'node:os'
import path from 'node:path'
diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.ts
index ddd6604e8a7..ae48f8eb368 100644
--- a/apps/desktop/electron/main.ts
+++ b/apps/desktop/electron/main.ts
@@ -35,12 +35,9 @@ import type { Session } from 'electron'
import { type ActiveRuntimeState, classifyActiveRuntime } from './active-runtime-state'
import {
destroyKeepaliveAgents,
- downloadAgentFor,
htmlResponseError,
- httpStatusError,
jsonAgentFor,
readJsonErrorBody,
- readStatusCode,
withRetry
} from './api-transport'
import { appIconCandidates, resolveAppIcon } from './app-icon'
@@ -67,8 +64,6 @@ import { buildDesktopBackendEnv } from './backend-env'
import { createBackendExitRecoveryLatch } from './backend-exit-recovery'
import {
isReauthRequiredError,
- makeNousCloudBackendDownError,
- makeUnsignedOauthError,
waitForHermesReady
} from './backend-health'
import { backendCommandMatches, type BackendOwnershipEntry, createBackendOwnership, createBackendShutdownCoordinator } from './backend-ownership'
@@ -89,7 +84,7 @@ import {
shouldLatchHostKeyChangedFailure,
shouldLatchRemoteReauthFailure
} from './backend-start-failure'
-import { describeBootstrapFailure, missingInstallPartMessage } from './bootstrap-failure-copy'
+import { describeBootstrapFailure } from './bootstrap-failure-copy'
import {
detectRemoteDisplay,
isWindowsBinaryPathInWsl,
@@ -109,8 +104,8 @@ import {
import { detectBundleSkew } from './bundle-skew'
import { detectBundleSwap, readBundleSwapStamp } from './bundle-swap'
import { registerChatOnboardingWindow } from './chat-onboarding-window'
-import { discoverWithTeamFallback } from './cloud-discovery'
import { provisionCliLinks } from './cli-provision'
+import { discoverWithTeamFallback } from './cloud-discovery'
import { installCommandScreenshot } from './command-screenshot'
import { writeComposerPaste } from './composer-paste'
import { applyConnectionChange, teardownSshState } from './connection-apply'
@@ -122,7 +117,6 @@ import {
connectionScopeKey,
cookiesHaveLiveSession,
cookiesHaveSession,
- gatewayTicketFailure,
gatewayWsUrlIpcResult,
hostLabelFromBaseUrl,
localProfileEntry,
@@ -180,7 +174,6 @@ import type { RosterProfileMetadata } from './connection-registry'
import { describeCrashReason, installCrashForensics } from './crash-forensics'
import { adoptServedDashboardToken } from './dashboard-token'
import { resolveDesktopHermesHome, resolveDesktopUserData } from './data-paths'
-import { writeDesktopProfile } from './desktop-boot-preference'
import { loadOrCreateInstallationId, sshOwnershipId } from './desktop-installation'
import { formatDesktopLogLine } from './desktop-log-line'
import {
@@ -242,13 +235,6 @@ import { stopGatewayBeforeUpdate } from './gateway-stop-before-update'
import { resolveGatewayVersion } from './gateway-version'
import { probeGatewayWebSocket } from './gateway-ws-probe'
import { registerGitIpc } from './git-ipc'
-import {
- describeGitHubCredentialSource,
- forgetGhCliToken,
- githubApiHeaders,
- githubTokenRejected,
- resolveGitHubCredential
-} from './github-api-auth'
import { desktopBackendSpawnEnv, guestOnboardingEnabled, skipIntroEnabled } from './guest-onboarding'
import { readAndConsumeHandoffResult } from './handoff-result'
import {
@@ -269,13 +255,11 @@ import {
tightenSecretFileMode,
writeSecretFileAtomic
} from './hardening'
+import { requestHudClose } from './hud-close'
import { cursorPointInWindow } from './hud-cursor'
import { startHudGameOverlayWatch } from './hud-game-overlay'
import { applyHudResetBounds, defaultHudBounds } from './hud-geometry'
-import { requestHudClose } from './hud-close'
import { registerHudIpc } from './hud-ipc'
-import { resolveRemoteOauthTicket, rosterSourceEnumerationTimeoutMs } from './remote-oauth-ticket'
-import { PrimaryProfilePin } from './primary-profile-pin'
import { applyHudElectronOverlay, promoteHudOverlay } from './hud-overlay'
import { snapHudBounds } from './hud-snap'
import { createHudSnapShortcut } from './hud-snap-shortcut'
@@ -311,9 +295,7 @@ import { createMediaProtocolHandler, MEDIA_PROTOCOL } from './media-protocol'
import { fetchLocalMedia } from './media-range'
import type { GatedDownloadAuth } from './native-auth-decisions'
import {
- oauthGuardMayHardFail,
oauthSessionIsLive,
- oauthTicketFailureAuthMessage,
resolveGatedDownloadAuth,
resolveJsonBody,
resolveOauthRestAuth,
@@ -357,9 +339,8 @@ import {
isBackgroundSlotWaitTimeout,
LocalBackendSpawnCoordinator,
type LocalBackendSpawnPriority,
- releaseLocalBackendSlot,
- type LocalBackendSpawnRequest,
registerLocalBackendExitFinalizer,
+ releaseLocalBackendSlot,
releaseLocalBackendSlotAfterExit
} from './pool-spawn-coordinator'
import { createPoolStopper } from './pool-stop'
@@ -374,6 +355,7 @@ import {
runPrimaryBackendStartup
} from './primary-backend-startup'
import { rehomePrimaryConnection } from './primary-connection-rehome'
+import { PrimaryProfilePin } from './primary-profile-pin'
import { applyDesktopIdentity, PRODUCT_IDENTITY } from './product-identity'
import {
assertLocalProfileCanStart,
@@ -410,6 +392,7 @@ import {
revalidateRemoteConnection,
revalidateSuspectPooledRemoteBackends
} from './remote-liveness'
+import { resolveRemoteOauthTicket, rosterSourceEnumerationTimeoutMs } from './remote-oauth-ticket'
import {
attachRemoteRequestHeaderListener,
collectRemoteHeaderSources,
@@ -471,26 +454,26 @@ import {
type UpdaterStrategy
} from './updater'
import {
- resolveVenvDir,
observeUpdaterHandoff,
resolveStagedUpdaterBinary,
+ resolveVenvDir,
spawnUpdaterProcess,
stagedUpdaterSupportsPrewrittenMarker
} from './updater-process'
import { AppInstallerStrategy } from './updater/app-installer'
+import { createChannelAppInstallerStrategy } from './updater/app-installer'
+import { ChannelResolver, type ChannelTarget } from './updater/channel'
+import { inspectRunningChannelApp } from './updater/channel-native'
+import { ChannelStrategy } from './updater/channel-strategy'
+import { verifyPreparedChannelInstaller } from './updater/channel-windows-host'
import {
createCheckoutStrategy
} from './updater/checkout'
import { readSourceUpdate, type SourceUpdate } from './updater/checkout-source'
import { ExternalStrategy } from './updater/external'
import { readUpdatesFeedBaseFromConfig } from './updater/feed-config'
-import { createMacStrategy, createChannelMacStrategy } from './updater/mac-client'
-import { createChannelAppInstallerStrategy } from './updater/app-installer'
-import { ChannelResolver, type ChannelTarget } from './updater/channel'
-import { ChannelStrategy } from './updater/channel-strategy'
+import { createChannelMacStrategy, createMacStrategy } from './updater/mac-client'
import { UpdateOperation } from './updater/operation'
-import { inspectRunningChannelApp } from './updater/channel-native'
-import { verifyPreparedChannelInstaller } from './updater/channel-windows-host'
import { type ConsumedRelaunch, consumePendingRelaunch, registerUpdateRelaunch, type RelaunchRegistration } from './updater/relaunch'
import { startRelaunchWaiter } from './updater/relaunch-waiter'
import { preflightStateDb } from './updater/state-db-preflight'
@@ -795,7 +778,9 @@ if (INSTALL_STAMP) {
const DESKTOP_PROFILE_CONFIG_PATH: string = path.join(app.getPath('userData'), 'active-profile.json')
// Only the lock-owning destination may adopt a workspace or start a backend.
const isPrimaryInstance: boolean = app.requestSingleInstanceLock()
+
if (!isPrimaryInstance) { app.exit(0) }
+
const HERMES_HOME: string = resolveDesktopHermesHome({
home: app.getPath('home'),
directoryExists,
@@ -3106,9 +3091,11 @@ async function createPackagedUpdateStrategy(): Promise<UpdaterStrategy | null> {
const build = INSTALL_STAMP.channelBuild
const installed = await inspectRunningChannelApp(build)
const payload = bundledPayload(process.resourcesPath)
+
if (!payload || (process.platform !== 'darwin' && process.platform !== 'win32') || (process.arch !== 'arm64' && process.arch !== 'x64')) {
throw new Error('Channel updates require a supported bundled application')
}
+
return new ChannelStrategy({
build, mechanism,
resolver: new ChannelResolver({ build, platform: process.platform, arch: process.arch, signer: installed.signer }),
@@ -3132,6 +3119,7 @@ function createNativePackagedStrategy(mechanism: UpdaterStrategy['mechanism'], t
beforeInstall: teardownBundledBackend,
onInstallFailure: restoreBundledBackend
}
+
return target ? createChannelMacStrategy(deps, target) : createMacStrategy(deps)
}
@@ -3184,11 +3172,13 @@ function createNativePackagedStrategy(mechanism: UpdaterStrategy['mechanism'], t
})
})
}
+
return target ? createChannelAppInstallerStrategy(deps, target, verifyPreparedChannelInstaller) : new AppInstallerStrategy(deps)
}
if (mechanism === 'microsoft-store') {
const payload = bundledPayload(process.resourcesPath)!
+
return createStoreStrategy({
python: payload.storePython,
script: path.join(payload.repoDir, 'apps', 'desktop', 'scripts', 'check-store-update.py'),
@@ -8932,9 +8922,11 @@ async function buildRemoteConnection(
}
const sshConnections = new Map<string, any>()
+
const sshIsolatedKeepalives = createSshIsolatedKeepaliveRegistry({
log: chunk => sshRememberLog(chunk)
})
+
const desktopInstallationId = loadOrCreateInstallationId(DESKTOP_INSTALLATION_PATH)
// Managed SSH update lifecycle (#93042): while an update owns a registered
@@ -11209,6 +11201,7 @@ function startPoolIdleReaper() {
const retiring = entry.process
? poolRetirer.retireIdle(profile, poolIdleMs())
: stopPoolBackend(profile)
+
void retiring.catch(error => rememberLog(`Pool idle retirement failed: ${String(error)}`))
}
}
@@ -11455,6 +11448,7 @@ async function spawnPoolBackend(
const startFailed = new Promise((_resolve, reject) => {
rejectStart = reject
})
+
// Exit/error can now arrive while the ownership claim is still pending.
startFailed.catch(() => {})
@@ -11490,6 +11484,7 @@ async function spawnPoolBackend(
describeOutputTail: () => outputTail.describe(),
readyFile
})
+
portAnnouncement.catch(() => {})
await claimBackendChild(child, `${backend.command} ${backend.args.join(' ')}`, profile, backendNonce, outputTail)
assertPoolEntryStillOwned(poolKey, entry, backendPool, localBackendLifecycle.signal)
@@ -11577,10 +11572,12 @@ const poolStopper = createPoolStopper({
function stopPoolBackend(profile: string): Promise<void> {
const entry = backendPool.get(profile)
+
const stopping = releaseLocalBackendSlotAfterExit(
() => releaseLocalBackendSlot(entry),
() => poolStopper.stop(profile)
)
+
// Fire-and-forget callers still need diagnostics; awaiters receive the
// rejection, while physical ownership and the exit finalizer remain live.
void stopping.catch(error => {
@@ -11611,6 +11608,7 @@ const poolRetirer = createPoolRetirer({
onRetiring: broadcastPoolBackendRetiring,
log: rememberLog
})
+
localBackendLifecycle.signal.addEventListener('abort', poolRetirer.dispose, { once: true })
async function teardownPoolBackendAndWait(profile) {
@@ -11777,6 +11775,7 @@ function scheduleUnexpectedPrimaryRecovery({ code = null, signal = null, error =
if (primaryExitRecovery.isCrashLooping()) {
const message: string =
'Hermes backend keeps crashing right after it restarts; not restarting it again. Relaunch Hermes Desktop.'
+
rememberLog(`[supervisor] ${message}`)
sendBackendExit({ code, signal, error: message })
@@ -12609,6 +12608,7 @@ function createInstanceWindow(
source && !source.isDestroyed() ? windowConnectionRoutes.get(source.webContents.id) : null,
{ connectionId: null, profile: primaryProfileKey() }
)
+
validateDesktopProfileRoute(route)
const icon = getAppIconPath()
@@ -15627,6 +15627,7 @@ async function dispatchRegistryApiRequest(
// OUT of the claim: an interactive open coalescing onto an in-flight
// passive read would otherwise inherit its "no warm backend" rejection.
const spawnPriority: LocalBackendSpawnPriority = spawnPriorityFrom(request?.priority)
+
// A passive read never dials, so it stays OUT of the claim: an interactive open
// coalescing onto an in-flight passive read would otherwise inherit its
// "no warm backend" rejection.
@@ -16783,6 +16784,7 @@ function canonicalizeInstallPath(p: string): string {
* installer-created. */
export function isInstallerCreatedCheckout(root: string | null = ACTIVE_HERMES_ROOT): boolean {
if (!root) { return false }
+
try {
return fs.existsSync(path.join(root, path.basename(BOOTSTRAP_COMPLETE_MARKER)))
} catch {
diff --git a/apps/desktop/electron/updater/app-installer.ts b/apps/desktop/electron/updater/app-installer.ts
index 2ce430cd407..d2c90cc1f9e 100644
--- a/apps/desktop/electron/updater/app-installer.ts
+++ b/apps/desktop/electron/updater/app-installer.ts
@@ -19,9 +19,9 @@ import {
win32AppInstallerFeedPath
} from '../app-updater'
-import { applyPackagedHandoff } from './packaged-handoff'
-import { channelPublicBase } from './channel-protocol'
import type { ChannelTarget } from './channel'
+import { channelPublicBase } from './channel-protocol'
+import { applyPackagedHandoff } from './packaged-handoff'
import type { RelaunchRegistration } from './relaunch'
import type { UpdaterApplyResultWire, UpdaterStatusWire } from './index'
@@ -80,6 +80,7 @@ export function createChannelAppInstallerStrategy(
verifyPrepared: (file: string, target: ChannelTarget) => Promise<void>
): AppInstallerStrategy {
if (target.package.platform !== 'win32') { throw new Error('Expected Windows channel target') }
+
return new AppInstallerStrategy({
...deps, channel: target.channel.name, feedBaseUrl: target.manifest.request.publicBase,
feed: { url: target.feedUrl, version: target.package.version,
@@ -97,6 +98,7 @@ export class AppInstallerStrategy {
return { supported: true, mechanism: this.mechanism, currentVersion: this.deps.appVersion,
updateAvailable: newerWindowsVersion(this.deps.feed.version, this.deps.appVersion), fetchedAt: Date.now() }
}
+
const { code, stdout } = await this.deps.run(this.deps.python, this.deps.script)
const check = parseCheckOutput(code, stdout)
@@ -106,10 +108,13 @@ export class AppInstallerStrategy {
async apply(): Promise<UpdaterApplyResultWire> {
const feedBaseUrl = this.deps.feedBaseUrl
let sourceUri: string | undefined = this.deps.feed?.url
+
if (sourceUri) {
channelPublicBase(sourceUri)
const base = channelPublicBase(feedBaseUrl)
+
if (!sourceUri.startsWith(`${base}/`) || new URL(sourceUri).origin !== new URL(base).origin) { throw new Error('Native feed authority mismatch') }
+
if (!newerWindowsVersion(this.deps.feed!.version, this.deps.appVersion)) { return { ok: true, mechanism: this.mechanism } }
}
@@ -158,6 +163,7 @@ export class AppInstallerStrategy {
prepare: async (url: string): Promise<string> => {
const file = await this.deps.installer.prepare(url)
await this.deps.feed?.verifyPrepared(file)
+
return file
},
open: this.deps.installer.open
@@ -177,14 +183,19 @@ function newerWindowsVersion(target: string, current: string): boolean {
const parse = (version: string): number[] => {
if (!/^\d+\.\d+\.\d+\.\d+$/.test(version)) { throw new Error('Windows channel updates require native numeric versions') }
const parts = version.split('.').map(Number)
+
if (parts.some((part: number): boolean => part > 65535)) { throw new Error('Invalid Windows native version') }
+
return parts
}
+
const left = parse(target)
const right = parse(current)
+
for (let index = 0; index < 4; index += 1) {
if (left[index] !== right[index]) { return left[index] > right[index] }
}
+
return false
}
diff --git a/apps/desktop/electron/updater/channel-artifact-lifetime.test.ts b/apps/desktop/electron/updater/channel-artifact-lifetime.test.ts
index 426f9611bf1..ab5e4745cf8 100644
--- a/apps/desktop/electron/updater/channel-artifact-lifetime.test.ts
+++ b/apps/desktop/electron/updater/channel-artifact-lifetime.test.ts
@@ -1,16 +1,16 @@
import { createHash } from 'node:crypto'
+import { once } from 'node:events'
import { mkdir, mkdtemp, readdir, readFile, rm, writeFile } from 'node:fs/promises'
import { createServer } from 'node:http'
-import { once } from 'node:events'
import os from 'node:os'
import path from 'node:path'
import { afterEach, expect, test } from 'vitest'
import { downloadPinnedArtifact } from './artifact'
-import { verifyPreparedChannelInstaller } from './channel-windows-host'
import type { ChannelTarget } from './channel'
import type { NativeCommandResult } from './channel-native'
+import { verifyPreparedChannelInstaller } from './channel-windows-host'
const directories: string[] = []
afterEach(async (): Promise<void> => {
@@ -27,10 +27,13 @@ test('ordinary Windows preparation owns temporary bytes while a resumable downlo
server.listen(0, '127.0.0.1')
await once(server, 'listening')
const address = server.address()
+
if (!address || !(address instanceof Object)) { throw new Error('Expected TCP server') }
const url: string = `http://127.0.0.1:${address.port}/stable.msixbundle`
+
const identity = { token: 'a'.repeat(16), displayName: 'Preview', appId: 'chat.nous.preview', appNamePascal: 'Preview',
artifactNamePascal: 'Preview', cliName: 'preview', windowsExecutableName: 'preview', msixAppIdWithOrg: 'NousResearch.Preview' }
+
const target: ChannelTarget = {
channel: { schema: 1, state: 'active', name: 'preview', repository: 'NousResearch/hermes-agent', policy: 'preview',
revision: 1, nextSequence: 2, head: null, identity },
@@ -42,14 +45,18 @@ test('ordinary Windows preparation owns temporary bytes while a resumable downlo
feed: { key: 'stable.appinstaller', channel: 'stable' } },
artifactUrl: url, feedUrl: 'https://example.com/stable.appinstaller', manifestSha256: 'd'.repeat(64)
}
+
try {
const file: string = path.join(directory, 'stable.appinstaller')
await writeFile(file, 'native descriptor checked by command')
+
const command = async (_script: string, input: string): Promise<NativeCommandResult> => {
const payload: { artifact: string } = JSON.parse(input)
expect(await readFile(payload.artifact)).toEqual(bytes)
+
return { stdout: '', stderr: '' }
}
+
await verifyPreparedChannelInstaller(file, target, command)
expect(await readdir(directory)).toEqual(['stable.appinstaller'])
await expect(verifyPreparedChannelInstaller(file, target, async (): Promise<never> => {
diff --git a/apps/desktop/electron/updater/channel-native.test.ts b/apps/desktop/electron/updater/channel-native.test.ts
index 1e2b8a0945e..2990e868cb7 100644
--- a/apps/desktop/electron/updater/channel-native.test.ts
+++ b/apps/desktop/electron/updater/channel-native.test.ts
@@ -1,13 +1,16 @@
-import { mkdtemp, rm, writeFile } from 'node:fs/promises'
import { createHash } from 'node:crypto'
+import { mkdtemp, rm, writeFile } from 'node:fs/promises'
import os from 'node:os'
import path from 'node:path'
+
import { expect, test } from 'vitest'
+
import { verifyChannelDownload } from './channel-native'
test('download verification binds native bytes to the manifest size and digest before signature preparation', async (): Promise<void> => {
const directory = await mkdtemp(path.join(os.tmpdir(), 'channel-artifact-'))
const file = path.join(directory, 'update.zip')
+
try {
const content = Buffer.from('real local archive fixture bytes')
await writeFile(file, content)
diff --git a/apps/desktop/electron/updater/channel-windows-host.ts b/apps/desktop/electron/updater/channel-windows-host.ts
index 7dcc0a9aa93..f30e036674b 100644
--- a/apps/desktop/electron/updater/channel-windows-host.ts
+++ b/apps/desktop/electron/updater/channel-windows-host.ts
@@ -1,9 +1,9 @@
-import path from 'node:path'
import { mkdtemp, rm } from 'node:fs/promises'
+import path from 'node:path'
-import type { ChannelTarget } from './channel'
-import { runChannelPowerShell, type NativeCommandResult } from './channel-native'
import { downloadPinnedArtifact } from './artifact'
+import type { ChannelTarget } from './channel'
+import { type NativeCommandResult, runChannelPowerShell } from './channel-native'
/** Verify downloaded bytes and native metadata before App Installer can stop the backend. */
export async function verifyPreparedChannelInstaller(
@@ -11,13 +11,16 @@ export async function verifyPreparedChannelInstaller(
command: (script: string, input: string) => Promise<NativeCommandResult> = runChannelPowerShell
): Promise<void> {
const pkg = target.package
+
if (pkg.platform !== 'win32' || !pkg.publisher) { throw new Error('Expected a publisher-bound Windows package') }
const directory: string = await mkdtemp(path.join(path.dirname(file), '.channel-artifact-'))
+
try {
const artifact: string = await downloadPinnedArtifact(directory,
{ url: target.artifactUrl, sha256: pkg.artifact.sha256, size: pkg.artifact.size,
format: pkg.artifact.key.endsWith('.msixbundle') ? 'msixbundle' : 'msix' }
)
+
await command(String.raw`
$ErrorActionPreference='Stop'
$p=[Console]::In.ReadToEnd() | ConvertFrom-Json
diff --git a/apps/desktop/electron/updater/index.ts b/apps/desktop/electron/updater/index.ts
index fbc591353da..4f7f8e79cb3 100644
--- a/apps/desktop/electron/updater/index.ts
+++ b/apps/desktop/electron/updater/index.ts
@@ -16,6 +16,7 @@
// or Store inference; the strategy reports its mechanism to the renderer.
import type { InstallStamp } from '../install-stamp'
+
import type { ChannelRetirementStatus } from './channel-strategy'
export type UpdaterMechanism =
diff --git a/apps/desktop/electron/updater/mac-client.ts b/apps/desktop/electron/updater/mac-client.ts
index b9460676e32..7f1296914d9 100644
--- a/apps/desktop/electron/updater/mac-client.ts
+++ b/apps/desktop/electron/updater/mac-client.ts
@@ -2,10 +2,10 @@ import { autoUpdater as nativeUpdater } from 'electron'
import electronUpdater from 'electron-updater'
import feedContract from '../../update-feed.cjs'
-import { channelPublicBase } from './channel-protocol'
+
import type { ChannelTarget } from './channel'
import { verifyChannelDownload } from './channel-native'
-
+import { channelPublicBase } from './channel-protocol'
import { MacStrategy, type MacStrategyDeps, prepareMacInstall } from './mac'
export interface MacClientDeps extends Omit<MacStrategyDeps, 'updater' | 'prepareInstall'> {
@@ -18,6 +18,7 @@ export interface MacClientDeps extends Omit<MacStrategyDeps, 'updater' | 'prepar
export function createChannelMacStrategy(deps: MacClientDeps, target: ChannelTarget): MacStrategy {
if (target.package.platform !== 'darwin') { throw new Error('Expected macOS channel target') }
+
return createMacStrategy({
...deps, channel: target.channel.name, feedBaseUrl: target.manifest.request.publicBase,
feed: { url: target.feedUrl, channel: target.package.feed.channel },
@@ -42,7 +43,9 @@ export function createMacStrategy(deps: MacClientDeps): MacStrategy {
if (deps.feed) {
const base = channelPublicBase(deps.feedBaseUrl)
const url = new URL(channelPublicBase(deps.feed.url))
+
if (!deps.feed.url.startsWith(`${base}/`) || url.origin !== new URL(base).origin) { throw new Error('Native feed authority mismatch') }
+
if (!/^[a-z][a-z0-9-]*$/.test(channel) || !url.pathname.endsWith(`/${channel}-mac.yml`)) { throw new Error('Invalid macOS feed descriptor') }
updater.setFeedURL({ provider: 'generic', url: new URL('./', url).href, channel })
} else if (deps.feedBaseUrl) {
diff --git a/apps/desktop/src/app/settings/gateway-settings.tsx b/apps/desktop/src/app/settings/gateway-settings.tsx
index ab6ce8ca050..0ec2fd588a8 100644
--- a/apps/desktop/src/app/settings/gateway-settings.tsx
+++ b/apps/desktop/src/app/settings/gateway-settings.tsx
@@ -12,7 +12,6 @@ import type {
DesktopCloudAgent,
DesktopCloudOrg,
DesktopConnectionConfigInput,
- DesktopConnectionProbeResult,
DesktopRegistryConnection
} from '@/global'
import { useI18n } from '@/i18n'
diff --git a/apps/desktop/src/app/settings/local-models-settings.tsx b/apps/desktop/src/app/settings/local-models-settings.tsx
index 64ac398bc5e..cc34e49939a 100644
--- a/apps/desktop/src/app/settings/local-models-settings.tsx
+++ b/apps/desktop/src/app/settings/local-models-settings.tsx
@@ -1,4 +1,4 @@
-import { type QueryClient, useQuery, useQueryClient, useIsMutating } from '@tanstack/react-query'
+import { type QueryClient, useIsMutating, useQuery, useQueryClient } from '@tanstack/react-query'
import { type ReactElement, useCallback, useEffect, useRef, useState } from 'react'
import { useNavigate } from 'react-router'
@@ -48,10 +48,10 @@ import {
refreshLocalModels,
runningDownloadFor,
runningRuntimeInstall,
+ startLocalRuntimeInstall,
useLocalModelsOwner,
useLocalModelsStatus,
useLocalRuntimeJobs,
- startLocalRuntimeInstall,
watchLocalRuntimeJobs
} from '@/store/local-runtime-jobs'
import { notify, notifyError } from '@/store/notifications'
diff --git a/apps/desktop/src/app/updates-overlay.tsx b/apps/desktop/src/app/updates-overlay.tsx
index b8a66fb0c65..e465d1c6a3f 100644
--- a/apps/desktop/src/app/updates-overlay.tsx
+++ b/apps/desktop/src/app/updates-overlay.tsx
@@ -27,11 +27,9 @@ import type {
} from '@/global'
import { useI18n } from '@/i18n'
import { buildCommitChangelog, type CommitGroup } from '@/lib/commit-changelog'
-import { openExternalLink } from '@/lib/external-link'
import { AlertCircle, Check, Copy, Terminal } from '@/lib/icons'
import { resolveUpdateCopy, type UpdateTarget } from '@/lib/update-copy'
import { cn } from '@/lib/utils'
-import { requestRoute } from '@/store/recovery-requests'
import {
$backendUpdateApply,
$backendUpdateChecking,
diff --git a/apps/desktop/src/components/tips/local-runtime-update-offer.test.tsx b/apps/desktop/src/components/tips/local-runtime-update-offer.test.tsx
index 702c4ca4eca..2c249fdceec 100644
--- a/apps/desktop/src/components/tips/local-runtime-update-offer.test.tsx
+++ b/apps/desktop/src/components/tips/local-runtime-update-offer.test.tsx
@@ -6,10 +6,10 @@ import { afterEach, beforeEach, expect, it, vi } from 'vitest'
import { SETTINGS_ROUTE } from '@/app/routes'
import { I18nProvider } from '@/i18n'
import { en } from '@/i18n/en'
+import { queryClient } from '@/lib/query-client'
import { $activeGatewayRoute } from '@/store/gateway'
import { $localModelsEnabled } from '@/store/local-models-flag'
import { localModelsKey, localModelsOwner } from '@/store/local-runtime-jobs'
-import { queryClient } from '@/lib/query-client'
import { $connection } from '@/store/session'
import { $activeTip, $nextTipAt, $retiredTips, $tipsEnabled, $tipShownAt, retireActiveTip } from '@/store/tips'
diff --git a/apps/desktop/src/components/tips/local-runtime-update-offer.ts b/apps/desktop/src/components/tips/local-runtime-update-offer.ts
index 9d06fc348b6..20d8bce141f 100644
--- a/apps/desktop/src/components/tips/local-runtime-update-offer.ts
+++ b/apps/desktop/src/components/tips/local-runtime-update-offer.ts
@@ -1,6 +1,6 @@
import { getLocalModelsJobs, getLocalModelsStatus } from '@/hermes'
-import { queryClient } from '@/lib/query-client'
import type { Translations } from '@/i18n/types'
+import { queryClient } from '@/lib/query-client'
import { localSetupDue } from '@/lib/tips/local-cta'
import { $activeGatewayRoute } from '@/store/gateway'
import { $localModelsEnabled } from '@/store/local-models-flag'
@@ -36,11 +36,13 @@ $tipsEnabled.listen(enabled => {
reset()
}
})
+
const closeWhenBusy = (): void => {
if (localRuntimeInstallBusy()) {
reset()
}
}
+
queryClient.getQueryCache().subscribe(closeWhenBusy)
queryClient.getMutationCache().subscribe(closeWhenBusy)
diff --git a/apps/desktop/src/components/version-details.tsx b/apps/desktop/src/components/version-details.tsx
index 3189ffd0daf..70d32023b44 100644
--- a/apps/desktop/src/components/version-details.tsx
+++ b/apps/desktop/src/components/version-details.tsx
@@ -1,7 +1,7 @@
import type { DesktopVersionInfo, RuntimeSource } from '@/global'
import { useI18n } from '@/i18n'
-import { ExternalLink } from '@/lib/external-link'
import { distributionLabelKey } from '@/lib/distribution-label'
+import { ExternalLink } from '@/lib/external-link'
/**
* Human label for an external build's runtime source: the resolution rung
@@ -31,6 +31,7 @@ export function VersionDetails({ version }: { version: DesktopVersionInfo }) {
// distribution-label.ts. Nix and Docker are product names, rendered
// verbatim; every other shape comes from the stamp via i18n.
const distributionKey = distributionLabelKey(version)
+
const distribution =
version.distribution === 'nix'
? 'Nix'
diff --git a/apps/desktop/src/global.d.ts b/apps/desktop/src/global.d.ts
index 6d5aac8b3e2..d99fed5ef78 100644
--- a/apps/desktop/src/global.d.ts
+++ b/apps/desktop/src/global.d.ts
@@ -1,8 +1,8 @@
import type { GatewayWsUrlResult } from '@hermes/shared'
import type { TranslucencyState } from '@hermes/shared/translucency'
-import type { MachineProfile } from '../electron/machine-profile'
import type { ScreenshotApi } from '../electron/command-screenshot-types'
+import type { MachineProfile } from '../electron/machine-profile'
import type { HermesNotification } from '../electron/notification-types'
import type { PoolLimits } from '../electron/pool-limits'
import type { GrowRequest } from '../electron/window-growth'
diff --git a/apps/desktop/src/store/local-models-surfaces.test.tsx b/apps/desktop/src/store/local-models-surfaces.test.tsx
index 00f9acd5cc1..704805ab350 100644
--- a/apps/desktop/src/store/local-models-surfaces.test.tsx
+++ b/apps/desktop/src/store/local-models-surfaces.test.tsx
@@ -1,10 +1,10 @@
+import type { ModelOptionsResult } from '@hermes/shared'
import { QueryClientProvider } from '@tanstack/react-query'
import { act, cleanup, fireEvent, render, renderHook, type RenderResult, screen } from '@testing-library/react'
import { MemoryRouter } from 'react-router'
import { afterEach, beforeEach, expect, it, vi } from 'vitest'
import type { HermesApiRequest, HermesConnection } from '@/global'
-import type { ModelOptionsResult } from '@hermes/shared'
import type { LocalCatalogModel, LocalModelsStatus, LocalRuntimeJob } from '@/types/hermes'
vi.mock('@/hermes', async (): Promise<object> => ({
diff --git a/apps/desktop/src/store/local-runtime-jobs.ts b/apps/desktop/src/store/local-runtime-jobs.ts
index cacebf8eebd..1dbadc9d33b 100644
--- a/apps/desktop/src/store/local-runtime-jobs.ts
+++ b/apps/desktop/src/store/local-runtime-jobs.ts
@@ -1,12 +1,12 @@
import type { QueryClient } from '@tanstack/react-query'
import {
+ MutationObserver,
type Query,
type QueryCacheNotifyEvent,
type QueryKey,
QueryObserver,
type QueryObserverResult,
queryOptions,
- MutationObserver,
useQuery,
useQueryClient,
type UseQueryOptions,