diff --git a/hermes_cli/__main__.py b/hermes_cli/__main__.py new file mode 100644 index 0000000000000..3172ca91ca2bb --- /dev/null +++ b/hermes_cli/__main__.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python3 +""" +Hermes Agent CLI launcher. + +This wrapper should behave like the installed `hermes` command, including +subcommands such as `gateway`, `cron`, and `doctor`. +""" + +if __name__ == "__main__": + from hermes_cli.main import main + main() diff --git a/hermes_cli/pty_bridge.py b/hermes_cli/pty_bridge.py index 66fdb4ac720b4..8449ffd8ececb 100644 --- a/hermes_cli/pty_bridge.py +++ b/hermes_cli/pty_bridge.py @@ -26,16 +26,28 @@ from __future__ import annotations import errno -import fcntl import os import select import signal import struct import sys -import termios import time from typing import Optional, Sequence +# fcntl and termios are POSIX-only. The module guards PTY operations on +# `_PTY_AVAILABLE` and raises `PtyUnavailableError` at instantiation time, +# so the import just needs to succeed on Windows. Without this guard, any +# command that triggers web_server.py (which imports pty_bridge +# unconditionally) crashes at module-load time on native Windows Python. +try: + import fcntl + import termios + _UNIX_TERMIO_AVAILABLE = True +except ImportError: # Windows + fcntl = None # type: ignore + termios = None # type: ignore + _UNIX_TERMIO_AVAILABLE = False + try: import ptyprocess # type: ignore _PTY_AVAILABLE = not sys.platform.startswith("win")