Skip to content

autoTty

autoTty(opts?): { getTermSize: () => TerminalSize; tty: TtyConfig; } | undefined

Defined in: packages/runtime/src/root/detect.ts:145

Auto-detect a host terminal on Node.js and return a TtyConfig plus a size probe, or undefined when no terminal is available.

{ allowPiped: true } accepts piped (non-TTY) stdin.

boolean

{ getTermSize: () => TerminalSize; tty: TtyConfig; } | undefined

{ tty, getTermSize } on Node with a usable stream, else undefined.

Returns undefined in all of these cases:

  • running outside Node.js (no process.stdin)
  • process.stdin.isTTY !== true and allowPiped is not set

Pass { allowPiped: true } to opt into piped stdin — required for boot() to accept shell scripts fed through a pipe. Even then, detection still short-circuits on non-Node hosts.

Node stdin/stdout streams are bridged to Web Streams so they satisfy the TtyConfig contract; errors on stdin propagate via the ReadableStream controller.

import { autoTty } from '@fishnet/runtime'
const detected = autoTty()
if (detected === undefined) {
// Headless — use nullReadable/nullWritable or a custom TtyConfig.
}