hermes-agent/tui_gateway/render.py
alt-glitch 4b16341975 refactor(restructure): rewrite all imports for hermes_agent package
Rewrite all import statements, patch() targets, sys.modules keys,
importlib.import_module() strings, and subprocess -m references to use
hermes_agent.* paths.

Strip sys.path.insert hacks from production code (rely on editable install).
Update COMPONENT_PREFIXES for logger filtering.
Fix 3 hardcoded getLogger() calls to use __name__.
Update transport and tool registry discovery paths.
Update plugin module path strings.
Add legacy process-name patterns for gateway PID detection.
Add main() to skills_sync for console_script entry point.
Fix _get_bundled_dir() path traversal after move.

Part of #14182, #14183
2026-04-23 08:35:34 +05:30

49 lines
1.2 KiB
Python

"""Rendering bridge — routes TUI content through Python-side renderers.
When agent.rich_output exists, its functions are used. When it doesn't,
everything returns None and the TUI falls back to its own markdown.tsx.
"""
from __future__ import annotations
def render_message(text: str, cols: int = 80) -> str | None:
try:
from hermes_agent.agent.rich_output import format_response
except ImportError:
return None
try:
return format_response(text, cols=cols)
except TypeError:
return format_response(text)
except Exception:
return None
def render_diff(text: str, cols: int = 80) -> str | None:
try:
from hermes_agent.agent.rich_output import render_diff as _rd
except ImportError:
return None
try:
return _rd(text, cols=cols)
except TypeError:
return _rd(text)
except Exception:
return None
def make_stream_renderer(cols: int = 80):
try:
from hermes_agent.agent.rich_output import StreamingRenderer
except ImportError:
return None
try:
return StreamingRenderer(cols=cols)
except TypeError:
return StreamingRenderer()
except Exception:
return None