Import AITURK IDE 1.0.0-beta.1 from Hermes 63279301; preserve MIT license
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
import type { MouseTrackingMode } from '@hermes/ink'
|
||||
|
||||
import { isTermuxTuiMode } from '../lib/termux.js'
|
||||
|
||||
const truthy = (v?: string) => /^(?:1|true|yes|on)$/i.test((v ?? '').trim())
|
||||
const falsy = (v?: string) => /^(?:0|false|no|off)$/i.test((v ?? '').trim())
|
||||
|
||||
const parseToggle = (v?: string): boolean | null => {
|
||||
const raw = (v ?? '').trim()
|
||||
|
||||
if (!raw) {
|
||||
return null
|
||||
}
|
||||
|
||||
if (truthy(raw)) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (falsy(raw)) {
|
||||
return false
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
export const TERMUX_TUI_MODE = isTermuxTuiMode()
|
||||
|
||||
export const STARTUP_RESUME_ID = (process.env.HERMES_TUI_RESUME ?? '').trim()
|
||||
export const STARTUP_QUERY = (process.env.HERMES_TUI_QUERY ?? '').trim()
|
||||
export const STARTUP_IMAGE = (process.env.HERMES_TUI_IMAGE ?? '').trim()
|
||||
|
||||
// Mouse tracking mode resolution at startup. Per-mode selection (off|wheel|
|
||||
// buttons|all) lives in display.mouse_tracking in config.yaml — these env
|
||||
// vars only set the boot-time default before that config is applied.
|
||||
//
|
||||
// Precedence (highest first):
|
||||
//
|
||||
// - HERMES_TUI_MOUSE_TRACKING (truthy/falsy) explicitly overrides everything.
|
||||
// This is the "force a value" knob and intentionally beats the legacy
|
||||
// kill-switch and the Termux default.
|
||||
// - HERMES_TUI_DISABLE_MOUSE=1 forces mouse off — the legacy kill switch.
|
||||
// - On Termux the default is mouse off so touch selection isn't intercepted
|
||||
// by terminal mouse protocols. Desktop defaults to 'all' to preserve prior
|
||||
// behavior.
|
||||
const mouseTrackingOverride = parseToggle(process.env.HERMES_TUI_MOUSE_TRACKING)
|
||||
const mouseTrackingDisabledLegacy = truthy(process.env.HERMES_TUI_DISABLE_MOUSE)
|
||||
|
||||
const resolvedBootMouseEnabled = mouseTrackingOverride ?? (TERMUX_TUI_MODE ? false : !mouseTrackingDisabledLegacy)
|
||||
|
||||
export const MOUSE_TRACKING: MouseTrackingMode = resolvedBootMouseEnabled ? 'all' : 'off'
|
||||
|
||||
export const NO_CONFIRM_DESTRUCTIVE = truthy(process.env.HERMES_TUI_NO_CONFIRM)
|
||||
|
||||
// Set by the dashboard PTY launcher. This is intentionally narrower than
|
||||
// INLINE_MODE: users can opt into inline terminal rendering locally, but the
|
||||
// browser-embedded TUI has no healthy restart path after an idle exit.
|
||||
export const DASHBOARD_TUI_MODE = truthy(process.env.HERMES_TUI_DASHBOARD)
|
||||
|
||||
// HERMES_DEV_CREDITS — dev-only live-spend readout (Δ status segment + "(dev credits)"
|
||||
// banner). Throwaway dev scaffolding; the whole readout gates on this one flag.
|
||||
export const DEV_CREDITS_MODE = truthy(process.env.HERMES_DEV_CREDITS)
|
||||
|
||||
const inlineOverride = parseToggle(process.env.HERMES_TUI_INLINE)
|
||||
|
||||
// Skip AlternateScreen — TUI renders into the primary buffer so the host
|
||||
// terminal's native scrollback captures whatever scrolls off the top.
|
||||
//
|
||||
// On Termux we default this on: users often background/foreground the app,
|
||||
// and primary-buffer rendering makes long-thread review and copy/paste much
|
||||
// less fragile. Override explicitly with HERMES_TUI_INLINE=0/1.
|
||||
export const INLINE_MODE = inlineOverride ?? TERMUX_TUI_MODE
|
||||
|
||||
// Live FPS counter overlay, fed by ink's onFrame (real render rate, not a
|
||||
// synthetic timer).
|
||||
export const SHOW_FPS = truthy(process.env.HERMES_TUI_FPS)
|
||||
@@ -0,0 +1,26 @@
|
||||
export const LARGE_PASTE = { lines: 5 }
|
||||
|
||||
export const LIVE_RENDER_MAX_CHARS = 16_000
|
||||
export const LIVE_RENDER_MAX_LINES = 240
|
||||
|
||||
// Persisted verbose tool-trail blocks (Args/Result embedded in a completed
|
||||
// tool line) are kept for the WHOLE session in transcript Msg.tools[] and
|
||||
// rendered expanded by default, so a render-node tree is built for every one
|
||||
// of up to MAX_HISTORY messages at once. Capping these to the live-render
|
||||
// budget (16KB) let a heavy browser/large-output session retain ~12MB of
|
||||
// strings that exploded into a few hundred MB of Ink nodes and silently OOM-
|
||||
// killed the Node parent (→ stdin EOF, gateway death; issue #34095). The live
|
||||
// streaming tail still uses the larger LIVE_RENDER budget — only the persisted
|
||||
// per-call block shrinks to a readable preview here. Full output remains in the
|
||||
// agent context and the SQLite session; the trail is a glance, not a log.
|
||||
export const VERBOSE_TRAIL_MAX_CHARS = 800
|
||||
export const VERBOSE_TRAIL_MAX_LINES = 12
|
||||
|
||||
export const LONG_MSG = 300
|
||||
export const MAX_HISTORY = 800
|
||||
export const THINKING_COT_MAX = 160
|
||||
|
||||
// Rows per wheel event (pre-accel). 1 keeps Ink's DECSTBM fast path live
|
||||
// (each scroll < viewport-1) and produces smooth motion. wheelAccel.ts
|
||||
// ramps this on sustained scrolls.
|
||||
export const WHEEL_SCROLL_STEP = 1
|
||||
@@ -0,0 +1,20 @@
|
||||
export const STREAM_BATCH_MS = 16
|
||||
export const STREAM_IDLE_BATCH_MS = 16
|
||||
export const STREAM_SCROLL_BATCH_MS = 96
|
||||
export const STREAM_TYPING_BATCH_MS = 80
|
||||
export const TYPING_IDLE_MS = 250
|
||||
export const REASONING_PULSE_MS = 700
|
||||
|
||||
// A drag-resize fires a burst of SIGWINCH events (one per pixel step in some
|
||||
// hosts). Each distinct terminal width remounts the visible transcript rows so
|
||||
// yoga re-measures off live geometry, so reflowing on every tick stutters the
|
||||
// drag. Coalesce the burst to at most one reflow per this window (~30fps):
|
||||
// responsive enough to track the drag, cheap enough to stay smooth, and the
|
||||
// trailing edge always lands the final width so the settled layout is exact.
|
||||
export const RESIZE_COALESCE_MS = 32
|
||||
|
||||
// Two Esc presses within this window discard the draft (Claude Code /
|
||||
// Gemini CLI parity). Long enough for a deliberate double-tap, short
|
||||
// enough that two unrelated Escs — dismissing a completion, then a
|
||||
// selection — don't silently clear the composer.
|
||||
export const DOUBLE_ESC_MS = 500
|
||||
Reference in New Issue
Block a user