node-pty
Native forkpty bindings that give Node.js real pseudoterminal processes
Repository Health
Technical Analysis
node-pty is Microsoft’s native addon that exposes forkpty(3)-style pseudoterminal bindings to Node.js, letting an application spawn a shell or any other process behind a real PTY instead of a plain pipe. Because the child believes it is talking to an actual terminal, programs that emit control sequences, resize themselves, or need line-discipline behavior work exactly as they would in a native terminal.
It powers the integrated terminal in Visual Studio Code as well as terminal emulators like Hyper, Theia, and Extraterm, and it bridges the platform gap by using conpty on modern Windows and native forkpty on Linux/macOS behind one consistent API.
What You Get
- A
pty.spawn()API that forks any executable behind a pseudoterminal and returns a terminal object withonData,write,resize, andkill - Cross-platform parity via native forkpty on Linux/macOS and the Windows ConPTY API on Windows 10 1809+
- TypeScript type declarations for the full public API (
typings/node-pty.d.ts) - Automatic flow control support (XON/XOFF or custom pause/resume sequences) to avoid overwhelming child processes
- Prebuilt native binaries fetched at install time, falling back to
node-gyp rebuildfrom source
Common Use Cases
- Building a terminal emulator UI in a desktop or web app (e.g. paired with xterm.js)
- Embedding an interactive shell inside an Electron or VS Code-style IDE
- Driving CLI tools that require an attached TTY to behave correctly (interactive prompts, progress bars, color output)
- Building browser-based terminal-over-HTTP tools like web SSH clients
Under The Hood
Architecture - node-pty splits into a thin TypeScript dispatch layer (src/index.ts) that picks UnixTerminal or WindowsTerminal at require-time based on process.platform, and a native binding compiled per-platform (C++ under src/unix/src/win) that actually calls forkpty(3) or the Windows ConPTY API; a worker subdirectory offloads the Windows console-list agent to a child process so the main thread stays responsive. Tech Stack - TypeScript for the public API and tests (mocha), C++ for the native addon built via node-gyp/binding.gyp and node-addon-api, with prebuilt binaries fetched by scripts/prebuild.js at install time and a node-gyp rebuild fallback. Code Quality - the repo carries real unit tests (terminal.test.ts, unixTerminal.test.ts, windowsTerminal.test.ts, eventEmitter2.test.ts) run via mocha plus ESLint enforced as a post-test step, and TypeScript typings are hand-maintained in typings/node-pty.d.ts as the API contract; native/platform code is comparatively harder to cover with automated tests and relies more on manual/CI verification across OSes. API Design - the public surface is deliberately small (spawn, deprecated fork/createTerminal aliases, and a returned terminal object exposing onData, write, resize, kill), which keeps the learning curve low, though Windows-vs-Unix option differences (e.g. IWindowsPtyForkOptions) leak into the typings and require platform awareness from consumers.
Used by 17 apps in this directory
melty
AI Code Assistants · Code Editors · Developer Tools
The AI code editor where every chat message is a git commit you can revert, branch, or squash
open-design
Design Tools
Local-first, open-source Claude Design alternative that turns your existing coding agent CLI into a full agentic design studio — with 259+ skills, 142+ design systems, and sandboxed artifact delivery across web, desktop, and mobile surfaces.
Orca
AI Agents · AI Code Assistants
An open-source Agent Development Environment that orchestrates fleets of parallel AI coding agents — Claude Code, Codex, Gemini and more — each running in its own isolated git worktree.
paseo
AI Agents · AI Code Assistants
One unified interface to orchestrate Claude Code, Codex, Copilot, OpenCode, and Pi agents in parallel from desktop, mobile, or the terminal.
rowboat
AI Assistants · AI Development
Build, test, and deploy multi-agent AI workflows with a visual editor, RAG data sources, MCP tool integration, and a production-ready REST API.
superset
AI Code Assistants · AI Development
Orchestrate an army of AI coding agents—Claude Code, Codex, Gemini CLI, and more—running simultaneously in isolated git worktrees from a single Electron desktop app.
Teleport
Authentication · Security
Zero-trust infrastructure access platform that replaces credentials and VPNs with short-lived certificates, SSO, and identity-aware proxies for SSH, Kubernetes, databases, RDP, and AI agents.
Void
AI Code Assistants · Automation · Code Editors
Open-source AI code editor with direct LLM integration and data privacy