from __future__ import annotations from pathlib import Path from datetime import datetime, timezone import gradio as gr from huggingface_hub import whoami ROOT = Path(__file__).resolve().parent LOGO_AVATAR = ROOT / "assets" / "logo-avatar.png" LOGO_MARK = ROOT / "assets" / "logo.png" LOGO_LOCKUP = ROOT / "assets" / "logo-lockup.png" FAVICON = next((p for p in (LOGO_AVATAR, LOGO_MARK) if p.is_file()), None) SITE_URL = "https://binarykernel-site.vercel.app" SPACE_URL = "https://huggingface.co/spaces/binarydoc/binarykernel" LINKS = { "Landing page": SITE_URL, "Jira": "https://binarykernel.atlassian.net/jira/projects", "Slack": "https://slack.com", "Hermes docs": "https://hermes-agent.nousresearch.com/docs/", "HF profile": "https://huggingface.co/binarydoc", } # ====== SVG Pipeline Visual ====== PIPELINE_SVG = """""" def greet(profile: gr.OAuthProfile | None) -> str: if profile is None: return ( "### Welcome to BinaryKernel\n\n" "Browse the hub freely. Sign in with Hugging Face to unlock your " "operator profile and organisation memberships.\n\n" f"[Open the BinaryKernel landing page]({SITE_URL})" ) name = profile.name or profile.username or "operator" username = profile.username or "" suffix = f" (`@{username}`)" if username else "" return ( f"### Hello, {name}{suffix}\n\n" "You are signed in. Use the surfaces below — LoginButton does **not** " "gate the app; unsigned visitors can still use public features." ) def list_organizations(oauth_token: gr.OAuthToken | None) -> str: if oauth_token is None: return "### Organisations\n\nSign in with Hugging Face to list organisations." try: info = whoami(oauth_token.token) orgs = info.get("orgs") or [] if not orgs: return "### Organisations\n\nNo organisation memberships returned." names = [org.get("name") or org.get("fullname") or "?" for org in orgs] return "### Organisations\n\n" + "\n".join(f"- `{name}`" for name in names) except Exception as exc: return f"### Organisations\n\nCould not fetch organisations:\n\n```\n{exc}\n```" def list_repos(oauth_token: gr.OAuthToken | None) -> str: if oauth_token is None: return "### Repositories\n\nSign in with Hugging Face to list your repositories." try: info = whoami(oauth_token.token) repos = info.get("repos") or info.get("orgRepos") or [] bullets = "\n".join( f"- [`{r.get('name', '?')}`](https://huggingface.co/{r.get('name', '')})" for r in repos[:20] ) return f"### Repositories\n\n{bullets}" except Exception as exc: return f"### Repositories\n\nError: {exc}" if exc else "### Repositories\n\nNone found." def get_pipeline_status() -> str: now = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M UTC") return ( f"**Pipeline Dashboard** · last updated {now}\n\n" "This diagram shows the live cross-device infrastructure. " "All nodes share memory through supermemory with `container_tag: hermes`.\n\n" "| Node | Status |\n" "|------|--------|\n" "| **Zorin CLI** | `provider: supermemory` active ✓ |\n" "| **Supermemory** | Hosted API — cross-device sync live ✓ |\n" "| **VPS Pi** | ⚠️ **OFFLINE** (last seen 14h ago) |\n" "| **Forgejo** | ⚠️ UNKNOWN (VPS offline) |\n" "| **Traefik** | ⚠️ UNKNOWN (VPS offline) |\n" "| **Swarm** | ⚠️ UNREACHABLE (VPS offline) |\n" "| **Cursor** | Hermes MCP server wired ✓ |\n" "| **Bitbucket** | Push/pull sync every 2h |\n" "| **Tailscale** | `hermes-zorin.tail455136.ts.net` — endpoint unreachable |\n" "| **HF Space** | zero-a10g · Gradio 5.49.1 · OAuth ✓ |\n\n" "**Memory limits:** 20,000 chars · Health check: every 4h\n\n" "⚠️ **ALERT:** VPS workspace agent (100.115.96.51) is offline. SSH and Tailscale serve endpoints are unreachable. " "Pipeline is in DEGRADED state. Local supermemory is connected and functional." ) with gr.Blocks(theme=gr.themes.Soft(), title="BinaryKernel Hub", favicon=str(FAVICON)) as demo: gr.HTML( f"""
Operator hub · cross-device AI agent pipeline