mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-27 17:58:07 +00:00
Marker presence was the launch gate, but the marker is provenance about who ran the install -- not proof the runtime works. A CLI-installed repo+venv, or a healthy install whose marker a repair deleted, both read as "never installed" and dropped the user into first-run bootstrap on every launch. Split the two questions: classifyActiveRuntime() reports marker validity and runtime usability separately, and the resolver launches whenever the runtime is usable, logging when it proceeds without a marker. An unusable runtime still falls through to bootstrap even with a valid marker, so an interrupted install can't spawn a dead backend. Drops isBootstrapComplete(), which had no callers left once the gate moved. Co-authored-by: iveywest <iveywest@users.noreply.github.com> Co-authored-by: lihengming <lihengming@users.noreply.github.com>
58 lines
1.6 KiB
TypeScript
58 lines
1.6 KiB
TypeScript
export interface BootstrapMarkerLike {
|
|
pinnedCommit?: unknown
|
|
schemaVersion?: unknown
|
|
}
|
|
|
|
export interface ActiveRuntimeState {
|
|
hasValidMarker: boolean
|
|
shouldUseActiveRuntime: boolean
|
|
usabilityReason: 'usable' | 'unusable'
|
|
}
|
|
|
|
export function hasValidBootstrapMarker(
|
|
marker: BootstrapMarkerLike | null | undefined,
|
|
schemaVersion: number
|
|
): boolean {
|
|
if (!marker || typeof marker !== 'object') {
|
|
return false
|
|
}
|
|
|
|
if (marker.schemaVersion !== schemaVersion) {
|
|
return false
|
|
}
|
|
|
|
if (typeof marker.pinnedCommit !== 'string' || marker.pinnedCommit.length < 7) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// The active install at ~/.hermes/hermes-agent can be real and runnable even if
|
|
// Desktop never wrote its first-run bootstrap marker (for example when Hermes
|
|
// was installed by the CLI first, or when a past desktop build forgot the
|
|
// marker). Runtime usability is authoritative for "can we launch local Hermes
|
|
// right now?"; the marker is only provenance about how that install was
|
|
// created. A missing/stale marker must never force a healthy local install into
|
|
// the first-run bootstrap UI.
|
|
export function classifyActiveRuntime(
|
|
marker: BootstrapMarkerLike | null | undefined,
|
|
schemaVersion: number,
|
|
runtimeUsable: boolean
|
|
): ActiveRuntimeState {
|
|
const hasValidMarker = hasValidBootstrapMarker(marker, schemaVersion)
|
|
|
|
if (!runtimeUsable) {
|
|
return {
|
|
hasValidMarker,
|
|
shouldUseActiveRuntime: false,
|
|
usabilityReason: 'unusable'
|
|
}
|
|
}
|
|
|
|
return {
|
|
hasValidMarker,
|
|
shouldUseActiveRuntime: true,
|
|
usabilityReason: 'usable'
|
|
}
|
|
}
|