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 = """ SOURCE SYNC AGENTS OUTPUTS Zorin CLI Hermes Agent Supermemory API hosted VPS Pi Workspace Agent Swarm 10 Workers Outputs Slack Telegram Cursor IDE Hermes MCP Pi Agent coding agent Bitbucket CI/CD sync Hostinger 314 MCP tools VPS hostinger 100.115.96.51 Traefik Chat UI 9Router Mongo HF Space binarydoc/binarykernel Gradio zero-a10g OAuth VM 1806872 hermes.binarydoc 9Router Headroom Bitbucket Config Sync Slack Publishing Telegram @binaryzorin_bot HF Space You are here LEGEND Core Sync Infra Output Dest """ 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"""

BinaryKernel Hub

Operator hub · cross-device AI agent pipeline

""" ) with gr.Row(): with gr.Column(scale=1): login_btn = gr.LoginButton() greeting = gr.Markdown(greet(None)) login_btn.change(fn=greet, inputs=login_btn, outputs=greeting) with gr.Column(scale=2): gr.Markdown("### Quick Links") for label, url in LINKS.items(): gr.Markdown(f"- [{label}]({url})") with gr.Tab("Pipeline Dashboard"): gr.Markdown("## BinaryKernel Infrastructure") gr.HTML(PIPELINE_SVG) status = gr.Markdown(get_pipeline_status()) refresh_btn = gr.Button("Refresh status", variant="secondary", size="sm") refresh_btn.click(fn=get_pipeline_status, outputs=status) gr.Markdown( "---\n" "*Pipeline visual · click Refresh to update timestamp*" ) with gr.Tab("System Status"): gr.Markdown( "### System Status\n\n" f"- **Space ID:** `binarydoc/binarykernel`\n" f"- **Host:** https://binarydoc-binarykernel.hf.space\n" f"- **Hardware:** zero-a10g (dedicated GPU)\n" f"- **Gradio:** {gr.__version__}\n" f"- **Region:** us\n" f"- **Dev mode:** active\n" ) with gr.Tab("Organisations"): org_btn = gr.Button("List organisations", variant="primary") org_output = gr.Markdown() org_btn.click(fn=list_organizations, inputs=login_btn, outputs=org_output) with gr.Tab("Repositories"): repo_btn = gr.Button("List repositories", variant="primary") repo_output = gr.Markdown() repo_btn.click(fn=list_repos, inputs=login_btn, outputs=repo_output) with gr.Tab("Supermemory Sync"): gr.Markdown( "### Cross-Device Sync Pipeline\n\n" "All Hermes nodes share a supermemory hosted API with `container_tag: hermes`.\n" "Memory limits: 20000/6000. Health check runs every 4 hours.\n\n" "- **Zorin CLI** — `provider: supermemory`, SDK active\n" "- **VPS Workspace Agent** — `provider: supermemory`, SDK v3.57.0\n" "- **Cursor IDE** — Hermes MCP server wired\n" "- **Pi Agent** — `@earendil-works/pi-coding-agent` running\n" "- **Tailscale serve** — `hermes-zorin.tail455136.ts.net`\n" "- **Backups** — Bitbucket push/pull every 2h, session snapshot every 2h\n" ) gr.Markdown( "\n---\n" "
" "Built with Gradio · Source on " f"Hugging Face Spaces" " · Powered by zero-a10g
" ) if __name__ == "__main__": demo.launch()