-
Notifications
You must be signed in to change notification settings - Fork 138
feat: add --tty flag for interactive terminal applications #77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Add -t/--tty CLI flag to enable pseudo-terminal (PTY) passthrough, which is required for interactive terminal applications like vim, htop, or any TUI application. The flag sets allowPty: true in the sandbox config, enabling: - Master PTY permissions (pseudo-tty) - Ioctl operations on /dev/ptmx and /dev/ttys* - Read/write access to PTY devices This is macOS-only; Linux handles PTY access differently. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Detailed Technical AnalysisRoot Cause InvestigationWhen running interactive terminal applications (like Claude Code) inside This occurs because:
Code Path AnalysisThe sandbox profile generation in // Lines 585-598
if (allowPty) {
profile.push('(allow pseudo-tty)') // Master PTY permission
profile.push('(allow file-ioctl')
profile.push(' (literal "/dev/ptmx")')
profile.push(' (regex #"^/dev/ttys")') // Slave TTYs
profile.push(')')
profile.push('(allow file-read* file-write*')
profile.push(' (literal "/dev/ptmx")')
profile.push(' (regex #"^/dev/ttys")')
profile.push(')')
}The const allowPty = customConfig?.allowPty ?? config?.allowPtyHowever, there was no CLI flag to enable this option for one-off interactive commands. Why This Matters
Security ConsiderationsPTY access does NOT bypass the core sandbox restrictions:
PTY access does allow:
Alternative Solutions Considered
The CLI flag approach was chosen because:
Testing Notes
For full interactive testing, users should test with actual TUI applications like |
|
we are running into an issue using the https://www.npmjs.com/package/@anthropic-ai/claude-agent-sdk where when sandbox mode is enabled (on mac and windows users) the agent just seems to freeze up. We had to turn off sandbox mode because of it. Hopefully this PR fixes that issue and it can get merge upstream to the claude-agent-sdk |
|
Would love to see this get merged! |

Summary
Add
-t/--ttyCLI flag to enable pseudo-terminal (PTY) passthrough for interactive terminal applications.Problem
Interactive terminal applications (like
vim,htop, Claude Code, or any TUI app) fail withsetRawMode EPERMwhen run inside the sandbox because PTY operations are blocked by default.Solution
This PR exposes the existing
allowPtyfunctionality (which already exists inmacos-sandbox-utils.ts) via a new CLI flag:Changes
-t/--ttyflag that setsallowPty: truein the sandbox configallowPtyconfig optionTechnical Details
When
--ttyis enabled, the macOS Seatbelt profile adds:(allow pseudo-tty)- Master PTY permission(allow file-ioctl (literal "/dev/ptmx") (regex #"^/dev/ttys"))- Ioctl operations on PTY devices/dev/ptmxand/dev/ttys*Testing
npm run build)--helpshows new flag--ttyflag works with--debugto confirm option is setNotes
Related issue: #76
🤖 Generated with Claude Code