mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-05 07:41:39 +00:00
Adds a Termux runtime detection helper and gates three TUI defaults on it: - Skip the startup scrollback clear on Termux so users can review/copy earlier output after reopening the app. Desktop keeps the existing \x1b[2J\x1b[H\x1b[3J slate (AlternateScreen takes over there anyway). - Default INLINE_MODE on under Termux: primary-buffer rendering makes long-thread review and copy/paste much less fragile when users background/foreground the app. Override with HERMES_TUI_INLINE=0/1. - Default mouse tracking off under Termux so touch selection isn't intercepted by terminal mouse protocols. Explicit override via HERMES_TUI_MOUSE_TRACKING=0/1; legacy HERMES_TUI_DISABLE_MOUSE still works on desktop. Detection is purely env-based (TERMUX_VERSION or PREFIX path) with an explicit opt-out HERMES_TUI_TERMUX_MODE=0 for debugging. Non-Termux platforms keep every existing default. Co-authored-by: adybag14-cyber <252811164+adybag14-cyber@users.noreply.github.com>
29 lines
808 B
TypeScript
29 lines
808 B
TypeScript
const TERMUX_PREFIX = '/data/data/com.termux/files/usr'
|
|
|
|
const truthy = (value?: string) => /^(?:1|true|yes|on)$/i.test(String(value ?? '').trim())
|
|
|
|
export const isTermuxEnv = (env: NodeJS.ProcessEnv = process.env): boolean => {
|
|
const prefix = String(env.PREFIX ?? '')
|
|
|
|
return Boolean(env.TERMUX_VERSION) || prefix.includes(TERMUX_PREFIX)
|
|
}
|
|
|
|
/**
|
|
* Return true when Hermes should enable Termux-focused TUI defaults.
|
|
*
|
|
* Defaults to on in Termux, with an explicit opt-out for debugging:
|
|
* HERMES_TUI_TERMUX_MODE=0
|
|
*/
|
|
export const isTermuxTuiMode = (env: NodeJS.ProcessEnv = process.env): boolean => {
|
|
if (!isTermuxEnv(env)) {
|
|
return false
|
|
}
|
|
|
|
const override = String(env.HERMES_TUI_TERMUX_MODE ?? '').trim().toLowerCase()
|
|
|
|
if (override) {
|
|
return truthy(override)
|
|
}
|
|
|
|
return true
|
|
}
|