"""
Hermes Web UI — Operator Cockpit.
Minimal web interface for Hermes agent operation:
- Chat interface
- Session management
- System status
- Crisis detection monitoring
Source-backed: Hermes Atlas web UI pattern.
"""
import json
import logging
import os
from pathlib import Path
from typing import Optional, Dict, Any
logger = logging.getLogger(__name__)
# HTML template for the operator cockpit
COCKPIT_HTML = """
Hermes Operator Cockpit
📊 System Status
Uptime--
Sessions--
Memory--
Tokens (24h)--
Crisis Detections0
🚨 Crisis Monitor
No crisis detected
"""
class WebCockpit:
"""Operator web cockpit for Hermes agent."""
def __init__(self, port: int = 8642):
self.port = port
self.html_path = Path.home() / ".hermes" / "cockpit.html"
def generate_html(self) -> str:
"""Generate cockpit HTML."""
return COCKPIT_HTML
def save_html(self):
"""Save cockpit HTML to file."""
self.html_path.parent.mkdir(parents=True, exist_ok=True)
with open(self.html_path, "w") as f:
f.write(self.generate_html())
logger.info("Cockpit saved to %s", self.html_path)
def get_url(self) -> str:
"""Get cockpit URL."""
return f"http://localhost:{self.port}"