2026-02-02 19:01:51 -08:00
|
|
|
"""
|
|
|
|
|
Hermes CLI - Unified command-line interface for Hermes Agent.
|
|
|
|
|
|
|
|
|
|
Provides subcommands for:
|
|
|
|
|
- hermes chat - Interactive chat (same as ./hermes)
|
|
|
|
|
- hermes gateway - Run gateway in foreground
|
|
|
|
|
- hermes gateway start - Start gateway service
|
2026-05-03 22:40:34 +08:00
|
|
|
- hermes gateway stop - Stop gateway service
|
2026-02-02 19:01:51 -08:00
|
|
|
- hermes setup - Interactive setup wizard
|
|
|
|
|
- hermes status - Show status of all components
|
|
|
|
|
- hermes cron - Manage cron jobs
|
|
|
|
|
"""
|
|
|
|
|
|
2026-05-03 22:40:34 +08:00
|
|
|
import os
|
|
|
|
|
import sys
|
|
|
|
|
|
2026-04-30 11:31:01 -07:00
|
|
|
__version__ = "0.12.0"
|
|
|
|
|
__release_date__ = "2026.4.30"
|
2026-05-03 22:40:34 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def _ensure_utf8():
|
|
|
|
|
"""Force UTF-8 stdout/stderr on Windows to prevent UnicodeEncodeError.
|
|
|
|
|
|
|
|
|
|
Windows services and terminals default to cp1252, which cannot encode
|
|
|
|
|
box-drawing characters used in CLI output. This causes unhandled
|
|
|
|
|
UnicodeEncodeError crashes on gateway startup.
|
|
|
|
|
"""
|
|
|
|
|
if sys.platform != "win32":
|
|
|
|
|
return
|
|
|
|
|
os.environ.setdefault("PYTHONUTF8", "1")
|
|
|
|
|
os.environ.setdefault("PYTHONIOENCODING", "utf-8")
|
|
|
|
|
for stream_name in ("stdout", "stderr"):
|
|
|
|
|
stream = getattr(sys, stream_name, None)
|
|
|
|
|
if stream is None:
|
|
|
|
|
continue
|
|
|
|
|
try:
|
|
|
|
|
if getattr(stream, "encoding", "").lower().replace("-", "") != "utf8":
|
|
|
|
|
new_stream = open(
|
|
|
|
|
stream.fileno(), "w", encoding="utf-8",
|
|
|
|
|
buffering=1, closefd=False,
|
|
|
|
|
)
|
|
|
|
|
setattr(sys, stream_name, new_stream)
|
|
|
|
|
except (AttributeError, OSError):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_ensure_utf8()
|