mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-23 16:36:23 +00:00
The SSH modules predate the stricter lint config that landed on main (curly, no-empty, perfectionist sorting, prettier). Mechanical lint:fix + fmt pass, empty catch blocks filled with the codebase's void-0 convention, and inline no-control-regex disables on the three deliberate control-char patterns (same pattern as lib/ansi.ts).
50 lines
864 B
TypeScript
50 lines
864 B
TypeScript
async function applyConnectionChange({
|
|
cancelAndWait,
|
|
isPrimary,
|
|
scope,
|
|
sendApplied,
|
|
stopPool,
|
|
teardownPrimary,
|
|
teardownSsh
|
|
}) {
|
|
await cancelAndWait(scope)
|
|
await teardownSsh(scope)
|
|
|
|
if (!isPrimary) {
|
|
stopPool(scope)
|
|
|
|
return
|
|
}
|
|
|
|
await teardownPrimary()
|
|
sendApplied()
|
|
}
|
|
|
|
function commitConnectionFailure(current, starting, commit) {
|
|
if (current !== starting) {
|
|
return false
|
|
}
|
|
|
|
commit()
|
|
|
|
return true
|
|
}
|
|
|
|
async function resolveTerminalConnection(getTarget, ensureBackend) {
|
|
let target = getTarget()
|
|
|
|
if (target !== 'pending') {
|
|
return target
|
|
}
|
|
|
|
await ensureBackend()
|
|
target = getTarget()
|
|
|
|
if (target === 'pending') {
|
|
throw new Error('Remote connection is not ready yet. Try again in a moment.')
|
|
}
|
|
|
|
return target
|
|
}
|
|
|
|
export { applyConnectionChange, commitConnectionFailure, resolveTerminalConnection }
|