Skip to content

nodeTty

nodeTty(): NodeTtyHandle | undefined

Defined in: packages/runtime/src/adapters/node.ts:68

Wrap Node.js process.stdin/process.stdout as a fishnet TtyConfig stream pair with raw-mode enabled.

NodeTtyHandle | undefined

A NodeTtyHandle, or undefined when process.stdin.isTTY !== true.

ConsFS (the in-kernel line discipline) owns echo, canonicalization, and signal-char translation, so this adapter holds the physical TTY in raw mode for the whole session. Returns undefined when stdin is not a TTY (e.g. piped input, CI) — callers should fall back to their headless stdio strategy in that case.

Cleanup: dispose() is registered as a process.on('exit', ...) handler so raw mode is restored even on abnormal termination. Callers may also invoke it explicitly during an orderly shutdown.

import { nodeTty } from '@fishnet/runtime/adapters/node'
import { Unix } from '@fishnet/runtime'
const handle = nodeTty()
const builder = Unix()
const root = handle !== undefined
? await builder.tty(handle.tty, handle.getTermSize).start()
: await builder.start()

Sets process.stdin to raw mode and calls .resume() on it. If other code elsewhere relied on cooked-mode stdin, install this adapter last.