pty-daemon
v0.10.1
Published
PTY daemon helper for Monolex terminal functionality
Downloads
4
Maintainers
Readme
@monolex/pty-daemon
PTY daemon helper for Monolex terminal functionality. This package provides a standalone PTY daemon that can be used by the Monolex app to create terminal sessions even when the main app's spawn-helper has Hardened Runtime restrictions.
Installation
npm install -g @monolex/pty-daemonWhat's New in v0.10.0
- Pre-built binaries for macOS arm64 - No Python or Xcode required!
- Automatic Hardened Runtime removal - Works in production apps
- Faster installation - Skip compilation on supported platforms
The postinstall script will automatically:
- Use pre-built binaries if available (macOS arm64)
- Otherwise compile node-pty for your system
- Fix spawn-helper permissions and signature
- Find and save Electron path for daemon usage
- Test the spawn-helper functionality
How It Works
This daemon runs as a separate process using Electron's Node.js runtime (ELECTRON_RUN_AS_NODE=1) and provides PTY functionality through Unix domain sockets.
Architecture
Monolex App (Production)
↓
IPC Handler
↓
Daemon Process (this package)
├─ node-pty (without Hardened Runtime)
├─ Unix domain sockets
└─ PTY sessionsUsage
Automatic (via Monolex app)
The Monolex app will automatically detect and use this daemon when installed globally.
Manual Start
# With Electron (recommended)
ELECTRON_RUN_AS_NODE=1 /path/to/electron monolex-pty-daemon
# With system Node.js (if ABI compatible)
monolex-pty-daemonControl Commands
The daemon exposes a control socket at ~/.monolex/sockets/daemon-control.sock for management:
create-session- Create a new PTY sessionremove-session- Remove a PTY sessionlist-sessions- List all active sessionsresize-session- Resize terminal dimensionsstatus- Get daemon statusshutdown- Gracefully shut down daemon
Configuration
Create a config file and pass it to the daemon:
{
"sessionPrefix": "daemon",
"maxSessions": 10,
"defaultShell": "bash",
"defaultCols": 120,
"defaultRows": 40,
"socketDir": "~/.monolex/sockets",
"logFile": "/tmp/monolex-pty-daemon.log"
}monolex-pty-daemon --config /path/to/config.jsonTroubleshooting
spawn-helper Issues
If you see posix_spawnp failed errors:
- Check spawn-helper signature:
codesign -dvvv node_modules/node-pty/build/Release/spawn-helperIf it has "Runtime Version", the postinstall script should fix it automatically.
Manual fix if needed:
# Remove Hardened Runtime
codesign --remove-signature node_modules/node-pty/build/Release/spawn-helper
codesign --force --sign - node_modules/node-pty/build/Release/spawn-helperLogs
Check daemon logs at:
/tmp/monolex-pty-daemon.log- Daemon runtime logs/tmp/pty-daemon.log- PTY process logs
Testing
Run the test script:
npm testThis will verify that spawn-helper can create PTY processes correctly.
Requirements
- macOS, Linux, or Windows
- Node.js 18+ or Electron 20+
- Build tools (only if pre-built binaries not available):
- macOS:
xcode-select --install(not needed for Apple Silicon) - Linux:
apt-get install build-essential - Windows:
npm install -g windows-build-tools
- macOS:
License
MIT
Support
Report issues at: https://github.com/monolex/pty-daemon/issues
