mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-18 14:52:04 +00:00
Bring apps/desktop and ui-tui to a clean state for typecheck, eslint,
and prettier:
- Run prettier across both trees (printWidth/wrap drift; prettier is not
CI-enforced for these JS projects, so main had accumulated drift).
- Apply eslint --fix for padding-line-between-statements and perfectionist
import/export sorting.
- Manual fixes for non-auto-fixable rules:
- remove unused node:net import in electron/main.cjs (uses Electron net)
- replace inline `typeof import(...)` annotations with top-level
`import type * as EnvModule` in two ui-tui test files
- scoped eslint-disable no-control-regex on intentional sentinel/ANSI
regexes (mathUnicode.ts, text.ts)
- resolve react-hooks/exhaustive-deps per-case: correct swapped/missing
deps, collapse redundant session.* members, and justified disables on
settings mount-only data-load effects to preserve run-once behavior
No behavior changes; test pass/fail counts are unchanged from the main
baseline.
52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
import { writeSync } from 'node:fs'
|
|
|
|
export const TERMINAL_MODE_RESET =
|
|
"\x1b[0'z" + // DEC locator reporting
|
|
"\x1b[0'{" + // selectable locator events
|
|
'\x1b[?2029l' + // passive mouse
|
|
'\x1b[?1016l' + // SGR-pixels mouse
|
|
'\x1b[?1015l' + // urxvt decimal mouse
|
|
'\x1b[?1006l' + // SGR mouse
|
|
'\x1b[?1005l' + // UTF-8 extended mouse
|
|
'\x1b[?1003l' + // any-motion mouse
|
|
'\x1b[?1002l' + // button-motion mouse
|
|
'\x1b[?1001l' + // highlight mouse
|
|
'\x1b[?1000l' + // click mouse
|
|
'\x1b[?9l' + // X10 mouse
|
|
'\x1b[?1004l' + // focus events
|
|
'\x1b[?2004l' + // bracketed paste
|
|
'\x1b[?1049l' + // alternate screen
|
|
'\x1b[<u' + // kitty keyboard
|
|
'\x1b[>4m' + // modifyOtherKeys
|
|
'\x1b[0m' + // attributes
|
|
'\x1b[?25h' // cursor visible
|
|
|
|
type ResettableStream = Pick<NodeJS.WriteStream, 'isTTY' | 'write'> & {
|
|
fd?: number
|
|
}
|
|
|
|
export function resetTerminalModes(stream: ResettableStream = process.stdout): boolean {
|
|
if (!stream.isTTY) {
|
|
return false
|
|
}
|
|
|
|
const fd = typeof stream.fd === 'number' ? stream.fd : stream === process.stdout ? 1 : undefined
|
|
|
|
if (fd !== undefined) {
|
|
try {
|
|
writeSync(fd, TERMINAL_MODE_RESET)
|
|
|
|
return true
|
|
} catch {
|
|
// Fall through to stream.write for mocked or unusual TTY streams.
|
|
}
|
|
}
|
|
|
|
try {
|
|
stream.write(TERMINAL_MODE_RESET)
|
|
|
|
return true
|
|
} catch {
|
|
return false
|
|
}
|
|
}
|