hermes-agent/apps/desktop/electron/updater/index.ts
ethernet 00a9dbc60b fix(desktop): eslint import order + padding after the origin/main merge
The merge landed main's `minimize-to-tray` and `hud-modifier-types` modules next to
ours, leaving two `perfectionist/sort-imports` errors — the only blocking failures in
the `JS & TS checks` job (`apps/desktop :: check:lint`):

  electron/main.ts:321      ./minimize-to-tray before ./native-auth-decisions
  src/global.d.ts:6         ../electron/hud-modifier-types before ../electron/machine-profile

Resolved with the workspace's own `npm run fix` (eslint --fix + prettier), which also
pads the `padding-line-between-statements` warnings it can. Lint is 0 errors after.
2026-09-21 17:50:44 -04:00

91 lines
3.1 KiB
TypeScript

// updater/index.ts — the desktop update strategy surface.
//
// Every install shape updates through a different owner:
// app-installer out-of-store MSIX on win32 — the OS App Installer owns
// the apply (the .appinstaller feed registered at install).
// microsoft-store StoreContext checks and requests the package update.
// external Steward-owned deployments with no in-app updater.
// windows-handoff git checkout on win32 — detached updater binary or the
// repo hand-off script owns the swap.
// posix-handoff git checkout on macOS/Linux — the repo posix hand-off
// script owns the swap.
// manual checkout with no staged updater — the user runs
// `hermes update` themselves.
//
// The build stamp declares the owner. Runtime dispatch needs no payload probe
// 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 =
'app-installer' | 'electron-updater' | 'external' | 'microsoft-store' | 'windows-handoff' | 'posix-handoff' | 'manual'
/** The facts the mechanism dispatch keys on. Pure data — injectable for tests. */
export interface MechanismFacts {
platform: NodeJS.Platform
source?: InstallStamp['source']
updateMechanism: InstallStamp['updateMechanism'] | undefined
}
/**
* The stamp names the artifact owner. A missing payload must never turn a
* packaged app into a checkout, and Light needs no payload to update itself.
*/
export function resolveUpdaterMechanism(facts: MechanismFacts): UpdaterMechanism {
if (facts.source === 'commit-build') {
return 'external'
}
if (facts.updateMechanism && facts.updateMechanism !== 'self') {
return facts.updateMechanism
}
return facts.platform === 'win32' ? 'windows-handoff' : 'posix-handoff'
}
/** The status shape main.ts already sends over `hermes:updates:check`. */
export interface UpdaterStatusWire {
supported: boolean
mechanism?: UpdaterMechanism
updateAvailable?: boolean
branch?: string
currentBranch?: string
reason?: string
message?: string
advice?: string
error?: string
behind?: number | null
currentSha?: string
currentVersion?: string
channel?: string
retirement?: ChannelRetirementStatus
latestTag?: string | null
targetSha?: string
commits?: { sha: string; summary: string; author: string; at: number }[]
dirty?: boolean
hermesRoot?: string
fetchedAt?: number
}
/** The result shape main.ts already sends over `hermes:updates:apply`. */
export interface UpdaterApplyResultWire {
ok: boolean
mechanism?: UpdaterMechanism
error?: string
message?: string
manual?: boolean
bundled?: boolean
command?: string
hermesRoot?: string
handedOff?: boolean
updater?: string
[key: string]: unknown
}
export interface UpdaterStrategy {
readonly mechanism: UpdaterMechanism
check(opts?: { force?: boolean }): Promise<UpdaterStatusWire>
apply(): Promise<UpdaterApplyResultWire>
}