The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { detectCapabilities } from "@alchemy.run/sigil/capabilities"; |
| 2 | import type { TerminalCapabilities, TerminalOptions } from "../../Interaction.ts"; |
| 3 | import { isNonInteractive } from "../../Util/interactive.ts"; |
| 4 | |
| 5 | /** Detect what the terminal behind the given streams supports. */ |
| 6 | export const resolveCapabilities = (options: TerminalOptions = {}): TerminalCapabilities => { |
| 7 | const stdout = options.stdout ?? process.stdout; |
| 8 | const stdin = options.stdin ?? process.stdin; |
| 9 | const detected = detectCapabilities({ stdout }); |
| 10 | const input = |
| 11 | options.input ?? (stdin.isTTY === true && stdout.isTTY === true && !isNonInteractive()); |
| 12 | return { |
| 13 | input, |
| 14 | columns: detected.size.columns, |
| 15 | rows: detected.size.rows, |
| 16 | colors: options.colors ?? detected.supports.color, |
| 17 | unicode: options.unicode ?? detected.supports.unicode, |
| 18 | alternateScreen: detected.supports.alternateScreen, |
| 19 | }; |
| 20 | }; |