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import datetime, timezone
|
| 5 |
+
|
| 6 |
+
import gradio as gr
|
| 7 |
+
from huggingface_hub import whoami
|
| 8 |
+
|
| 9 |
+
ROOT = Path(__file__).resolve().parent
|
| 10 |
+
LOGO_AVATAR = ROOT / "assets" / "logo-avatar.png"
|
| 11 |
+
LOGO_MARK = ROOT / "assets" / "logo.png"
|
| 12 |
+
LOGO_LOCKUP = ROOT / "assets" / "logo-lockup.png"
|
| 13 |
+
FAVICON = next((p for p in (LOGO_AVATAR, LOGO_MARK) if p.is_file()), None)
|
| 14 |
+
|
| 15 |
+
SITE_URL = "https://binarykernel-site.vercel.app"
|
| 16 |
+
SPACE_URL = "https://huggingface.co/spaces/binarydoc/binarykernel"
|
| 17 |
+
|
| 18 |
+
LINKS = {
|
| 19 |
+
"Landing page": SITE_URL,
|
| 20 |
+
"Jira": "https://binarykernel.atlassian.net/jira/projects",
|
| 21 |
+
"Slack": "https://slack.com",
|
| 22 |
+
"Hermes docs": "https://hermes-agent.nousresearch.com/docs/",
|
| 23 |
+
"HF profile": "https://huggingface.co/binarydoc",
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
# ====== SVG Pipeline Visual ======
|
| 27 |
+
PIPELINE_SVG = """<svg viewBox="0 0 920 520" xmlns="http://www.w3.org/2000/svg" style="width:100%;height:auto;display:block;font-family:system-ui,-apple-system,sans-serif;">
|
| 28 |
+
<defs>
|
| 29 |
+
<linearGradient id="g-purple" x1="0%" y1="0%" x2="100%" y2="100%">
|
| 30 |
+
<stop offset="0%" stop-color="#6C63FF"/><stop offset="100%" stop-color="#4A44CC"/>
|
| 31 |
+
</linearGradient>
|
| 32 |
+
<linearGradient id="g-pink" x1="0%" y1="0%" x2="100%" y2="100%">
|
| 33 |
+
<stop offset="0%" stop-color="#FF6B6B"/><stop offset="100%" stop-color="#CC4444"/>
|
| 34 |
+
</linearGradient>
|
| 35 |
+
<linearGradient id="g-amber" x1="0%" y1="0%" x2="100%" y2="100%">
|
| 36 |
+
<stop offset="0%" stop-color="#FFD93D"/><stop offset="100%" stop-color="#CCA500"/>
|
| 37 |
+
</linearGradient>
|
| 38 |
+
<linearGradient id="g-teal" x1="0%" y1="0%" x2="100%" y2="100%">
|
| 39 |
+
<stop offset="0%" stop-color="#00E6C8"/><stop offset="100%" stop-color="#00B39A"/>
|
| 40 |
+
</linearGradient>
|
| 41 |
+
<linearGradient id="g-coral" x1="0%" y1="0%" x2="100%" y2="100%">
|
| 42 |
+
<stop offset="0%" stop-color="#FF8A65"/><stop offset="100%" stop-color="#CC6B47"/>
|
| 43 |
+
</linearGradient>
|
| 44 |
+
<marker id="arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto">
|
| 45 |
+
<path d="M0,1 L9,5 L0,9" fill="none" stroke="rgba(255,255,255,0.3)" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
| 46 |
+
</marker>
|
| 47 |
+
<pattern id="grid" width="30" height="30" patternUnits="userSpaceOnUse">
|
| 48 |
+
<circle cx="15" cy="15" r="0.6" fill="rgba(255,255,255,0.04)"/>
|
| 49 |
+
</pattern>
|
| 50 |
+
</defs>
|
| 51 |
+
<rect width="100%" height="100%" fill="#0a0a12"/>
|
| 52 |
+
<rect width="100%" height="100%" fill="url(#grid)"/>
|
| 53 |
+
<ellipse cx="460" cy="300" rx="350" ry="180" fill="rgba(108,99,255,0.06)"/>
|
| 54 |
+
|
| 55 |
+
<!-- Labels -->
|
| 56 |
+
<text x="40" y="35" fill="rgba(255,255,255,0.15)" font-size="10" font-weight="700" letter-spacing="2">SOURCE</text>
|
| 57 |
+
<line x1="40" y1="42" x2="110" y2="42" stroke="rgba(255,255,255,0.08)" stroke-width="1"/>
|
| 58 |
+
<text x="250" y="35" fill="rgba(255,255,255,0.15)" font-size="10" font-weight="700" letter-spacing="2">SYNC</text>
|
| 59 |
+
<text x="480" y="35" fill="rgba(255,255,255,0.15)" font-size="10" font-weight="700" letter-spacing="2">AGENTS</text>
|
| 60 |
+
<text x="720" y="35" fill="rgba(255,255,255,0.15)" font-size="10" font-weight="700" letter-spacing="2">OUTPUTS</text>
|
| 61 |
+
|
| 62 |
+
<!-- Flow arrows -->
|
| 63 |
+
<line x1="155" y1="130" x2="220" y2="130" stroke="#6C63FF" stroke-width="2" marker-end="url(#arrow)" opacity="0.5"/>
|
| 64 |
+
<line x1="310" y1="130" x2="370" y2="130" stroke="#6C63FF" stroke-width="2" marker-end="url(#arrow)" opacity="0.5"/>
|
| 65 |
+
<line x1="460" y1="130" x2="520" y2="130" stroke="#6C63FF" stroke-width="2" marker-end="url(#arrow)" opacity="0.5"/>
|
| 66 |
+
<line x1="610" y1="130" x2="670" y2="130" stroke="#6C63FF" stroke-width="2" marker-end="url(#arrow)" opacity="0.5"/>
|
| 67 |
+
<line x1="460" y1="370" x2="460" y2="400" stroke="rgba(255,255,255,0.1)" stroke-width="1.5" marker-end="url(#arrow)"/>
|
| 68 |
+
<line x1="460" y1="400" x2="250" y2="400" stroke="rgba(255,255,255,0.1)" stroke-width="1.5" marker-end="url(#arrow)"/>
|
| 69 |
+
<line x1="460" y1="400" x2="670" y2="400" stroke="rgba(255,255,255,0.1)" stroke-width="1.5" marker-end="url(#arrow)"/>
|
| 70 |
+
|
| 71 |
+
<!-- Row 1 — Core flow -->
|
| 72 |
+
<rect x="40" y="100" width="115" height="60" rx="14" fill="url(#g-purple)"/>
|
| 73 |
+
<text x="97" y="127" fill="white" font-size="14" font-weight="700" text-anchor="middle">Zorin CLI</text>
|
| 74 |
+
<text x="97" y="145" fill="rgba(255,255,255,0.6)" font-size="10" text-anchor="middle">Hermes Agent</text>
|
| 75 |
+
|
| 76 |
+
<rect x="220" y="100" width="90" height="60" rx="14" fill="url(#g-amber)"/>
|
| 77 |
+
<text x="265" y="127" fill="#1a1a0a" font-size="14" font-weight="700" text-anchor="middle">Supermemory</text>
|
| 78 |
+
<text x="265" y="145" fill="rgba(0,0,0,0.5)" font-size="10" text-anchor="middle">API hosted</text>
|
| 79 |
+
|
| 80 |
+
<rect x="370" y="100" width="90" height="60" rx="14" fill="url(#g-teal)"/>
|
| 81 |
+
<text x="415" y="127" fill="#0a1a14" font-size="14" font-weight="700" text-anchor="middle">VPS Pi</text>
|
| 82 |
+
<text x="415" y="145" fill="rgba(0,0,0,0.5)" font-size="10" text-anchor="middle">Workspace Agent</text>
|
| 83 |
+
|
| 84 |
+
<rect x="520" y="100" width="90" height="60" rx="14" fill="url(#g-pink)"/>
|
| 85 |
+
<text x="565" y="127" fill="white" font-size="14" font-weight="700" text-anchor="middle">Swarm</text>
|
| 86 |
+
<text x="565" y="145" fill="rgba(255,255,255,0.6)" font-size="10" text-anchor="middle">10 Workers</text>
|
| 87 |
+
|
| 88 |
+
<rect x="670" y="100" width="90" height="60" rx="14" fill="url(#g-coral)"/>
|
| 89 |
+
<text x="715" y="127" fill="white" font-size="14" font-weight="700" text-anchor="middle">Outputs</text>
|
| 90 |
+
<text x="715" y="145" fill="rgba(255,255,255,0.6)" font-size="10" text-anchor="middle">Slack Telegram</text>
|
| 91 |
+
|
| 92 |
+
<!-- Row 2 — Tools -->
|
| 93 |
+
<rect x="40" y="175" width="115" height="46" rx="10" fill="rgba(255,255,255,0.03)" stroke="rgba(255,255,255,0.08)" stroke-width="1"/>
|
| 94 |
+
<text x="97" y="196" fill="rgba(255,255,255,0.5)" font-size="11" font-weight="500" text-anchor="middle">Cursor IDE</text>
|
| 95 |
+
<text x="97" y="210" fill="rgba(255,255,255,0.25)" font-size="9" text-anchor="middle">Hermes MCP</text>
|
| 96 |
+
|
| 97 |
+
<rect x="220" y="175" width="90" height="46" rx="10" fill="rgba(255,255,255,0.03)" stroke="rgba(255,255,255,0.08)" stroke-width="1"/>
|
| 98 |
+
<text x="265" y="196" fill="rgba(255,255,255,0.5)" font-size="11" font-weight="500" text-anchor="middle">Pi Agent</text>
|
| 99 |
+
<text x="265" y="210" fill="rgba(255,255,255,0.25)" font-size="9" text-anchor="middle">coding agent</text>
|
| 100 |
+
|
| 101 |
+
<rect x="370" y="175" width="90" height="46" rx="10" fill="rgba(255,255,255,0.03)" stroke="rgba(255,255,255,0.08)" stroke-width="1"/>
|
| 102 |
+
<text x="415" y="196" fill="rgba(255,255,255,0.5)" font-size="11" font-weight="500" text-anchor="middle">Bitbucket</text>
|
| 103 |
+
<text x="415" y="210" fill="rgba(255,255,255,0.25)" font-size="9" text-anchor="middle">CI/CD sync</text>
|
| 104 |
+
|
| 105 |
+
<rect x="520" y="175" width="90" height="46" rx="10" fill="rgba(255,255,255,0.03)" stroke="rgba(255,255,255,0.08)" stroke-width="1"/>
|
| 106 |
+
<text x="565" y="196" fill="rgba(255,255,255,0.5)" font-size="11" font-weight="500" text-anchor="middle">Hostinger</text>
|
| 107 |
+
<text x="565" y="210" fill="rgba(255,255,255,0.25)" font-size="9" text-anchor="middle">314 MCP tools</text>
|
| 108 |
+
|
| 109 |
+
<!-- Row 3 — Infra boxes -->
|
| 110 |
+
<rect x="40" y="245" width="290" height="60" rx="14" fill="rgba(0,230,200,0.04)" stroke="rgba(0,230,200,0.12)" stroke-width="1" stroke-dasharray="4,4"/>
|
| 111 |
+
<text x="58" y="262" fill="rgba(0,230,200,0.45)" font-size="9" font-weight="600">VPS hostinger 100.115.96.51</text>
|
| 112 |
+
<rect x="58" y="273" width="62" height="22" rx="6" fill="rgba(0,230,200,0.08)" stroke="rgba(0,230,200,0.15)" stroke-width="0.5"/>
|
| 113 |
+
<text x="89" y="288" fill="rgba(0,230,200,0.5)" font-size="8" text-anchor="middle">Traefik</text>
|
| 114 |
+
<rect x="128" y="273" width="62" height="22" rx="6" fill="rgba(0,230,200,0.08)" stroke="rgba(0,230,200,0.15)" stroke-width="0.5"/>
|
| 115 |
+
<text x="159" y="288" fill="rgba(0,230,200,0.5)" font-size="8" text-anchor="middle">Chat UI</text>
|
| 116 |
+
<rect x="198" y="273" width="62" height="22" rx="6" fill="rgba(0,230,200,0.08)" stroke="rgba(0,230,200,0.15)" stroke-width="0.5"/>
|
| 117 |
+
<text x="229" y="288" fill="rgba(0,230,200,0.5)" font-size="8" text-anchor="middle">9Router</text>
|
| 118 |
+
<rect x="268" y="273" width="52" height="22" rx="6" fill="rgba(0,230,200,0.08)" stroke="rgba(0,230,200,0.15)" stroke-width="0.5"/>
|
| 119 |
+
<text x="294" y="288" fill="rgba(0,230,200,0.5)" font-size="8" text-anchor="middle">Mongo</text>
|
| 120 |
+
|
| 121 |
+
<rect x="350" y="245" width="220" height="60" rx="14" fill="rgba(108,99,255,0.04)" stroke="rgba(108,99,255,0.12)" stroke-width="1" stroke-dasharray="4,4"/>
|
| 122 |
+
<text x="368" y="262" fill="rgba(108,99,255,0.45)" font-size="9" font-weight="600">HF Space binarydoc/binarykernel</text>
|
| 123 |
+
<rect x="368" y="273" width="62" height="22" rx="6" fill="rgba(108,99,255,0.08)" stroke="rgba(108,99,255,0.15)" stroke-width="0.5"/>
|
| 124 |
+
<text x="399" y="288" fill="rgba(108,99,255,0.5)" font-size="8" text-anchor="middle">Gradio</text>
|
| 125 |
+
<rect x="438" y="273" width="62" height="22" rx="6" fill="rgba(108,99,255,0.08)" stroke="rgba(108,99,255,0.15)" stroke-width="0.5"/>
|
| 126 |
+
<text x="469" y="288" fill="rgba(108,99,255,0.5)" font-size="8" text-anchor="middle">zero-a10g</text>
|
| 127 |
+
<rect x="508" y="273" width="52" height="22" rx="6" fill="rgba(108,99,255,0.08)" stroke="rgba(108,99,255,0.15)" stroke-width="0.5"/>
|
| 128 |
+
<text x="534" y="288" fill="rgba(108,99,255,0.5)" font-size="8" text-anchor="middle">OAuth</text>
|
| 129 |
+
|
| 130 |
+
<rect x="590" y="245" width="170" height="60" rx="14" fill="rgba(255,107,107,0.04)" stroke="rgba(255,107,107,0.12)" stroke-width="1" stroke-dasharray="4,4"/>
|
| 131 |
+
<text x="608" y="262" fill="rgba(255,107,107,0.45)" font-size="9" font-weight="600">VM 1806872 hermes.binarydoc</text>
|
| 132 |
+
<rect x="608" y="273" width="70" height="22" rx="6" fill="rgba(255,107,107,0.08)" stroke="rgba(255,107,107,0.15)" stroke-width="0.5"/>
|
| 133 |
+
<text x="643" y="288" fill="rgba(255,107,107,0.5)" font-size="8" text-anchor="middle">9Router</text>
|
| 134 |
+
<rect x="686" y="273" width="64" height="22" rx="6" fill="rgba(255,107,107,0.08)" stroke="rgba(255,107,107,0.15)" stroke-width="0.5"/>
|
| 135 |
+
<text x="718" y="288" fill="rgba(255,107,107,0.5)" font-size="8" text-anchor="middle">Headroom</text>
|
| 136 |
+
|
| 137 |
+
<!-- Row 4 — Destinations -->
|
| 138 |
+
<rect x="60" y="380" width="130" height="48" rx="12" fill="url(#g-amber)"/>
|
| 139 |
+
<text x="125" y="404" fill="#1a1a0a" font-size="13" font-weight="700" text-anchor="middle">Bitbucket</text>
|
| 140 |
+
<text x="125" y="418" fill="rgba(0,0,0,0.5)" font-size="9" text-anchor="middle">Config Sync</text>
|
| 141 |
+
|
| 142 |
+
<rect x="250" y="380" width="130" height="48" rx="12" fill="url(#g-pink)"/>
|
| 143 |
+
<text x="315" y="404" fill="white" font-size="13" font-weight="700" text-anchor="middle">Slack</text>
|
| 144 |
+
<text x="315" y="418" fill="rgba(255,255,255,0.6)" font-size="9" text-anchor="middle">Publishing</text>
|
| 145 |
+
|
| 146 |
+
<rect x="440" y="380" width="130" height="48" rx="12" fill="url(#g-teal)"/>
|
| 147 |
+
<text x="505" y="404" fill="#0a1a14" font-size="13" font-weight="700" text-anchor="middle">Telegram</text>
|
| 148 |
+
<text x="505" y="418" fill="rgba(0,0,0,0.5)" font-size="9" text-anchor="middle">@binaryzorin_bot</text>
|
| 149 |
+
|
| 150 |
+
<rect x="630" y="380" width="130" height="48" rx="12" fill="url(#g-purple)"/>
|
| 151 |
+
<text x="695" y="404" fill="white" font-size="13" font-weight="700" text-anchor="middle">HF Space</text>
|
| 152 |
+
<text x="695" y="418" fill="rgba(255,255,255,0.6)" font-size="9" text-anchor="middle">You are here</text>
|
| 153 |
+
|
| 154 |
+
<!-- Legend -->
|
| 155 |
+
<g transform="translate(40, 455)">
|
| 156 |
+
<text x="0" y="0" fill="rgba(255,255,255,0.2)" font-size="9" font-weight="600" letter-spacing="1">LEGEND</text>
|
| 157 |
+
<rect x="0" y="12" width="10" height="7" rx="2" fill="url(#g-purple)"/>
|
| 158 |
+
<text x="15" y="19" fill="rgba(255,255,255,0.35)" font-size="8">Core</text>
|
| 159 |
+
<rect x="60" y="12" width="10" height="7" rx="2" fill="url(#g-amber)"/>
|
| 160 |
+
<text x="75" y="19" fill="rgba(255,255,255,0.35)" font-size="8">Sync</text>
|
| 161 |
+
<rect x="115" y="12" width="10" height="7" rx="2" fill="url(#g-teal)"/>
|
| 162 |
+
<text x="130" y="19" fill="rgba(255,255,255,0.35)" font-size="8">Infra</text>
|
| 163 |
+
<rect x="170" y="12" width="10" height="7" rx="2" fill="url(#g-pink)"/>
|
| 164 |
+
<text x="185" y="19" fill="rgba(255,255,255,0.35)" font-size="8">Output</text>
|
| 165 |
+
<rect x="225" y="12" width="10" height="7" rx="2" fill="url(#g-coral)"/>
|
| 166 |
+
<text x="240" y="19" fill="rgba(255,255,255,0.35)" font-size="8">Dest</text>
|
| 167 |
+
</g>
|
| 168 |
+
</svg>"""
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
def greet(profile: gr.OAuthProfile | None) -> str:
|
| 172 |
+
if profile is None:
|
| 173 |
+
return (
|
| 174 |
+
"### Welcome to BinaryKernel\n\n"
|
| 175 |
+
"Browse the hub freely. Sign in with Hugging Face to unlock your "
|
| 176 |
+
"operator profile and organisation memberships.\n\n"
|
| 177 |
+
f"[Open the BinaryKernel landing page]({SITE_URL})"
|
| 178 |
+
)
|
| 179 |
+
name = profile.name or profile.username or "operator"
|
| 180 |
+
username = profile.username or ""
|
| 181 |
+
suffix = f" (`@{username}`)" if username else ""
|
| 182 |
+
return (
|
| 183 |
+
f"### Hello, {name}{suffix}\n\n"
|
| 184 |
+
"You are signed in. Use the surfaces below — LoginButton does **not** "
|
| 185 |
+
"gate the app; unsigned visitors can still use public features."
|
| 186 |
+
)
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
def list_organizations(oauth_token: gr.OAuthToken | None) -> str:
|
| 190 |
+
if oauth_token is None:
|
| 191 |
+
return "### Organisations\n\nSign in with Hugging Face to list organisations."
|
| 192 |
+
try:
|
| 193 |
+
info = whoami(oauth_token.token)
|
| 194 |
+
orgs = info.get("orgs") or []
|
| 195 |
+
if not orgs:
|
| 196 |
+
return "### Organisations\n\nNo organisation memberships returned."
|
| 197 |
+
names = [org.get("name") or org.get("fullname") or "?" for org in orgs]
|
| 198 |
+
return "### Organisations\n\n" + "\n".join(f"- `{name}`" for name in names)
|
| 199 |
+
except Exception as exc:
|
| 200 |
+
return f"### Organisations\n\nCould not fetch organisations:\n\n```\n{exc}\n```"
|
| 201 |
+
|
| 202 |
+
|
| 203 |
+
def list_repos(oauth_token: gr.OAuthToken | None) -> str:
|
| 204 |
+
if oauth_token is None:
|
| 205 |
+
return "### Repositories\n\nSign in with Hugging Face to list your repositories."
|
| 206 |
+
try:
|
| 207 |
+
info = whoami(oauth_token.token)
|
| 208 |
+
repos = info.get("repos") or info.get("orgRepos") or []
|
| 209 |
+
bullets = "\n".join(
|
| 210 |
+
f"- [`{r.get('name', '?')}`](https://huggingface.co/{r.get('name', '')})"
|
| 211 |
+
for r in repos[:20]
|
| 212 |
+
)
|
| 213 |
+
return f"### Repositories\n\n{bullets}"
|
| 214 |
+
except Exception as exc:
|
| 215 |
+
return f"### Repositories\n\nError: {exc}" if exc else "### Repositories\n\nNone found."
|
| 216 |
+
|
| 217 |
+
|
| 218 |
+
def get_pipeline_status() -> str:
|
| 219 |
+
now = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M UTC")
|
| 220 |
+
return (
|
| 221 |
+
f"**Pipeline Dashboard** · last updated {now}\n\n"
|
| 222 |
+
"This diagram shows the live cross-device infrastructure. "
|
| 223 |
+
"All nodes share memory through supermemory with `container_tag: hermes`.\n\n"
|
| 224 |
+
"| Node | Status |\n"
|
| 225 |
+
"|------|--------|\n"
|
| 226 |
+
"| **Zorin CLI** | `provider: supermemory` active ✓ |\n"
|
| 227 |
+
"| **Supermemory** | Hosted API — cross-device sync live ✓ |\n"
|
| 228 |
+
"| **VPS Pi** | ⚠️ **OFFLINE** (last seen 14h ago) |\n"
|
| 229 |
+
"| **Forgejo** | ⚠️ UNKNOWN (VPS offline) |\n"
|
| 230 |
+
"| **Traefik** | ⚠️ UNKNOWN (VPS offline) |\n"
|
| 231 |
+
"| **Swarm** | ⚠️ UNREACHABLE (VPS offline) |\n"
|
| 232 |
+
"| **Cursor** | Hermes MCP server wired ✓ |\n"
|
| 233 |
+
"| **Bitbucket** | Push/pull sync every 2h |\n"
|
| 234 |
+
"| **Tailscale** | `hermes-zorin.tail455136.ts.net` — endpoint unreachable |\n"
|
| 235 |
+
"| **HF Space** | zero-a10g · Gradio 5.49.1 · OAuth ✓ |\n\n"
|
| 236 |
+
"**Memory limits:** 20,000 chars · Health check: every 4h\n\n"
|
| 237 |
+
"⚠️ **ALERT:** VPS workspace agent (100.115.96.51) is offline. SSH and Tailscale serve endpoints are unreachable. "
|
| 238 |
+
"Pipeline is in DEGRADED state. Local supermemory is connected and functional."
|
| 239 |
+
)
|
| 240 |
+
|
| 241 |
+
|
| 242 |
+
with gr.Blocks(theme=gr.themes.Soft(), title="BinaryKernel Hub", favicon=str(FAVICON)) as demo:
|
| 243 |
+
gr.HTML(
|
| 244 |
+
f"""
|
| 245 |
+
<div style="display:flex;align-items:center;gap:12px;margin-bottom:8px">
|
| 246 |
+
<img src="file={LOGO_AVATAR}" width="40" height="40" style="border-radius:50%">
|
| 247 |
+
<div>
|
| 248 |
+
<h1 style="margin:0;font-size:20px">BinaryKernel Hub</h1>
|
| 249 |
+
<p style="margin:0;color:var(--body-text-color-subdued);font-size:13px">
|
| 250 |
+
Operator hub · cross-device AI agent pipeline
|
| 251 |
+
</p>
|
| 252 |
+
</div>
|
| 253 |
+
</div>
|
| 254 |
+
"""
|
| 255 |
+
)
|
| 256 |
+
|
| 257 |
+
with gr.Row():
|
| 258 |
+
with gr.Column(scale=1):
|
| 259 |
+
login_btn = gr.LoginButton()
|
| 260 |
+
greeting = gr.Markdown(greet(None))
|
| 261 |
+
login_btn.change(fn=greet, inputs=login_btn, outputs=greeting)
|
| 262 |
+
with gr.Column(scale=2):
|
| 263 |
+
gr.Markdown("### Quick Links")
|
| 264 |
+
for label, url in LINKS.items():
|
| 265 |
+
gr.Markdown(f"- [{label}]({url})")
|
| 266 |
+
|
| 267 |
+
with gr.Tab("Pipeline Dashboard"):
|
| 268 |
+
gr.Markdown("## BinaryKernel Infrastructure")
|
| 269 |
+
gr.HTML(PIPELINE_SVG)
|
| 270 |
+
status = gr.Markdown(get_pipeline_status())
|
| 271 |
+
refresh_btn = gr.Button("Refresh status", variant="secondary", size="sm")
|
| 272 |
+
refresh_btn.click(fn=get_pipeline_status, outputs=status)
|
| 273 |
+
gr.Markdown(
|
| 274 |
+
"---\n"
|
| 275 |
+
"*Pipeline visual · click Refresh to update timestamp*"
|
| 276 |
+
)
|
| 277 |
+
|
| 278 |
+
with gr.Tab("System Status"):
|
| 279 |
+
gr.Markdown(
|
| 280 |
+
"### System Status\n\n"
|
| 281 |
+
f"- **Space ID:** `binarydoc/binarykernel`\n"
|
| 282 |
+
f"- **Host:** https://binarydoc-binarykernel.hf.space\n"
|
| 283 |
+
f"- **Hardware:** zero-a10g (dedicated GPU)\n"
|
| 284 |
+
f"- **Gradio:** {gr.__version__}\n"
|
| 285 |
+
f"- **Region:** us\n"
|
| 286 |
+
f"- **Dev mode:** active\n"
|
| 287 |
+
)
|
| 288 |
+
|
| 289 |
+
with gr.Tab("Organisations"):
|
| 290 |
+
org_btn = gr.Button("List organisations", variant="primary")
|
| 291 |
+
org_output = gr.Markdown()
|
| 292 |
+
org_btn.click(fn=list_organizations, inputs=login_btn, outputs=org_output)
|
| 293 |
+
|
| 294 |
+
with gr.Tab("Repositories"):
|
| 295 |
+
repo_btn = gr.Button("List repositories", variant="primary")
|
| 296 |
+
repo_output = gr.Markdown()
|
| 297 |
+
repo_btn.click(fn=list_repos, inputs=login_btn, outputs=repo_output)
|
| 298 |
+
|
| 299 |
+
with gr.Tab("Supermemory Sync"):
|
| 300 |
+
gr.Markdown(
|
| 301 |
+
"### Cross-Device Sync Pipeline\n\n"
|
| 302 |
+
"All Hermes nodes share a supermemory hosted API with `container_tag: hermes`.\n"
|
| 303 |
+
"Memory limits: 20000/6000. Health check runs every 4 hours.\n\n"
|
| 304 |
+
"- **Zorin CLI** — `provider: supermemory`, SDK active\n"
|
| 305 |
+
"- **VPS Workspace Agent** — `provider: supermemory`, SDK v3.57.0\n"
|
| 306 |
+
"- **Cursor IDE** — Hermes MCP server wired\n"
|
| 307 |
+
"- **Pi Agent** — `@earendil-works/pi-coding-agent` running\n"
|
| 308 |
+
"- **Tailscale serve** — `hermes-zorin.tail455136.ts.net`\n"
|
| 309 |
+
"- **Backups** — Bitbucket push/pull every 2h, session snapshot every 2h\n"
|
| 310 |
+
)
|
| 311 |
+
|
| 312 |
+
gr.Markdown(
|
| 313 |
+
"\n---\n"
|
| 314 |
+
"<div style='text-align:center;color:var(--body-text-color-subdued);font-size:0.8em'>"
|
| 315 |
+
"Built with Gradio · Source on "
|
| 316 |
+
f"<a href='{SPACE_URL}'>Hugging Face Spaces</a>"
|
| 317 |
+
" · Powered by zero-a10g</div>"
|
| 318 |
+
)
|
| 319 |
+
|
| 320 |
+
|
| 321 |
+
if __name__ == "__main__":
|
| 322 |
+
demo.launch()
|