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.
Parameters
Section titled “Parameters”{ allowPiped: true } accepts piped (non-TTY) stdin.
allowPiped?
Section titled “allowPiped?”boolean
Returns
Section titled “Returns”{ getTermSize: () => TerminalSize; tty: TtyConfig; } | undefined
{ tty, getTermSize } on Node with a usable stream, else undefined.
Remarks
Section titled “Remarks”Returns undefined in all of these cases:
- running outside Node.js (no
process.stdin) process.stdin.isTTY !== trueandallowPipedis 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.
Example
Section titled “Example”import { autoTty } from '@fishnet/runtime'
const detected = autoTty()if (detected === undefined) { // Headless — use nullReadable/nullWritable or a custom TtyConfig.}