diff --git a/hermes_cli/dashboard_auth/middleware.py b/hermes_cli/dashboard_auth/middleware.py index f3ad42a61860c..4b50e365bd215 100644 --- a/hermes_cli/dashboard_auth/middleware.py +++ b/hermes_cli/dashboard_auth/middleware.py @@ -47,6 +47,12 @@ "/ds-assets/", "/fonts/", "/fonts-terminal/", + # PWA assets — must be fetchable without a cookie so the OS can load the + # home-screen icon / manifest during "Add to Home Screen" (that fetch + # carries no session cookie). Non-sensitive static files. + "/icons/", + "/manifest.webmanifest", + "/sw.js", ) diff --git a/tui_gateway/server.py b/tui_gateway/server.py index 87de2bb490ec3..291c49d9cbfd3 100644 --- a/tui_gateway/server.py +++ b/tui_gateway/server.py @@ -7058,8 +7058,14 @@ def _(rid, params: dict) -> dict: if err: return err - if shutil.which("pdftoppm") is None: - return _err(rid, 5028, "pdftoppm not installed (poppler-utils package required)") + _have_pdftoppm = shutil.which("pdftoppm") is not None + if not _have_pdftoppm: + # Fall back to PyMuPDF (pure-python wheel, no system deps) when + # poppler isn't installed — e.g. macOS without Homebrew. + try: + import fitz # noqa: F401 (PyMuPDF) + except Exception: + return _err(rid, 5028, "pdftoppm not installed and PyMuPDF unavailable (install poppler-utils or `pip install pymupdf`)") raw_path = str(params.get("path", "") or "").strip() raw_b64 = str(params.get("content_base64") or params.get("data") or "").strip() @@ -7116,22 +7122,35 @@ def _(rid, params: dict) -> dict: return _err(rid, 4019, f"page range exceeds cap of {_PDF_ATTACH_MAX_PAGES} pages per attach call") out_prefix = td_path / "page" - argv = [ - "pdftoppm", "-png", "-r", "150", - "-f", str(first_page), "-l", str(last_page), - str(pdf_path), str(out_prefix), - ] - try: - res = subprocess.run(argv, capture_output=True, text=True, timeout=120, stdin=subprocess.DEVNULL) - except subprocess.TimeoutExpired: - return _err(rid, 5028, "pdftoppm timed out (>120s)") - if res.returncode != 0: - tail = (res.stderr or res.stdout or "").strip().splitlines()[-3:] - return _err(rid, 5028, "pdftoppm failed: " + " | ".join(tail)) + if _have_pdftoppm: + argv = [ + "pdftoppm", "-png", "-r", "150", + "-f", str(first_page), "-l", str(last_page), + str(pdf_path), str(out_prefix), + ] + try: + res = subprocess.run(argv, capture_output=True, text=True, timeout=120, stdin=subprocess.DEVNULL) + except subprocess.TimeoutExpired: + return _err(rid, 5028, "pdftoppm timed out (>120s)") + if res.returncode != 0: + tail = (res.stderr or res.stdout or "").strip().splitlines()[-3:] + return _err(rid, 5028, "pdftoppm failed: " + " | ".join(tail)) + else: + # PyMuPDF fallback: render the page range to PNGs using the same + # ``page-NNN.png`` naming the glob below expects. + try: + import fitz + doc = fitz.open(str(pdf_path)) + hi = min(last_page, doc.page_count) + for pno in range(first_page, hi + 1): + doc[pno - 1].get_pixmap(dpi=150).save(str(td_path / f"page-{pno:03d}.png")) + doc.close() + except Exception as exc: + return _err(rid, 5028, f"PyMuPDF render failed: {exc}") rendered = sorted(td_path.glob("page-*.png")) if not rendered: - return _err(rid, 5028, "pdftoppm produced no pages (corrupt PDF?)") + return _err(rid, 5028, "no pages rendered (corrupt PDF?)") attached_pages = [] for src in rendered: diff --git a/web/index.html b/web/index.html index fe7cda519d2e6..11512082a7a3c 100644 --- a/web/index.html +++ b/web/index.html @@ -5,8 +5,15 @@ + + + + + + + Hermes Agent - Dashboard diff --git a/web/public/icons/apple-touch-icon.png b/web/public/icons/apple-touch-icon.png new file mode 100644 index 0000000000000..1185f061d2496 Binary files /dev/null and b/web/public/icons/apple-touch-icon.png differ diff --git a/web/public/icons/icon-192.png b/web/public/icons/icon-192.png new file mode 100644 index 0000000000000..3d1bed9227830 Binary files /dev/null and b/web/public/icons/icon-192.png differ diff --git a/web/public/icons/icon-512.png b/web/public/icons/icon-512.png new file mode 100644 index 0000000000000..161b4b17ee132 Binary files /dev/null and b/web/public/icons/icon-512.png differ diff --git a/web/public/manifest.webmanifest b/web/public/manifest.webmanifest new file mode 100644 index 0000000000000..d977bed56948d --- /dev/null +++ b/web/public/manifest.webmanifest @@ -0,0 +1,16 @@ +{ + "name": "Hermes Agent", + "short_name": "Hermes", + "description": "Your personal Hermes AI agent.", + "start_url": "/chat", + "scope": "/", + "display": "standalone", + "background_color": "#0b0f0d", + "theme_color": "#0b0f0d", + "orientation": "portrait-primary", + "icons": [ + { "src": "/icons/icon-192.png", "sizes": "192x192", "type": "image/png", "purpose": "any" }, + { "src": "/icons/icon-512.png", "sizes": "512x512", "type": "image/png", "purpose": "any" }, + { "src": "/icons/icon-512.png", "sizes": "512x512", "type": "image/png", "purpose": "maskable" } + ] +} diff --git a/web/public/sw.js b/web/public/sw.js new file mode 100644 index 0000000000000..7434484fb0d55 --- /dev/null +++ b/web/public/sw.js @@ -0,0 +1,7 @@ +// Minimal service worker — makes Hermes installable as a PWA without caching +// application code, so dashboard updates (new build hashes after `hermes +// update`) are never served stale. Network requests pass straight through. +self.addEventListener("install", () => self.skipWaiting()); +self.addEventListener("activate", (event) => event.waitUntil(self.clients.claim())); +// A fetch handler is required for installability; pass through to the network. +self.addEventListener("fetch", () => {}); diff --git a/web/src/App.tsx b/web/src/App.tsx index 8bf6f4ee96e7c..38cb01f6f88d2 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -483,7 +483,7 @@ export default function App() {
@@ -492,7 +492,10 @@ export default function App() {
-
+