mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
Use pywinpty instead of ptyprocess on Windows for PTY support
ptyprocess depends on Unix-only APIs (fork, openpty) and cannot work on Windows at all. pywinpty provides a compatible PtyProcess interface using the Windows ConPTY API. This conditionally imports winpty.PtyProcess on Windows and ptyprocess.PtyProcess on Unix. The pyproject.toml pty extra now uses platform markers so the correct package is installed automatically.
This commit is contained in:
parent
21d61bdd71
commit
dcba291d45
2 changed files with 9 additions and 3 deletions
|
|
@ -148,11 +148,14 @@ class ProcessRegistry:
|
|||
if use_pty:
|
||||
# Try PTY mode for interactive CLI tools
|
||||
try:
|
||||
import ptyprocess
|
||||
if _IS_WINDOWS:
|
||||
from winpty import PtyProcess as _PtyProcessCls
|
||||
else:
|
||||
from ptyprocess import PtyProcess as _PtyProcessCls
|
||||
user_shell = _find_shell()
|
||||
pty_env = os.environ | (env_vars or {})
|
||||
pty_env["PYTHONUNBUFFERED"] = "1"
|
||||
pty_proc = ptyprocess.PtyProcess.spawn(
|
||||
pty_proc = _PtyProcessCls.spawn(
|
||||
[user_shell, "-lic", command],
|
||||
cwd=session.cwd,
|
||||
env=pty_env,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue