// SEIS+ Internals — main app. const { SectionHead, Pill } = window.SEIS_PRIM; const { LiteLLMBudget, ModelRanking, EC2Budget, ActiveServers, EC2History, Shortcuts, ActivityFeed, YourInstances } = window.SEIS_MODULES; const { EC2Launcher } = window.SEIS_LAUNCHER; const { InstancePanel } = window.SEIS_INSTANCE_PANEL; const { TweaksPanel, useTweaks, TweakSection, TweakRadio, TweakSelect, TweakToggle } = window; const { LoginScreen, RegisterScreen } = window.SEIS_LOGIN; const { useApi } = window.SEIS_API; const { SHORTCUTS } = window.SEIS_STATIC; const DEFAULTS = /*EDITMODE-BEGIN*/{ "density": "default", "theme": "light", "accent": "sky", "showGrain": true }/*EDITMODE-END*/; const ACCENTS = { sky: "oklch(58% .18 245)", flag: "oklch(70% .17 132)", amber: "oklch(70% .15 75)", ink: "var(--ink)", }; function SshKeyPanel({ user, onRefresh }) { const [pubKey, setPubKey] = React.useState(""); const [generating, setGenerating] = React.useState(false); const [msg, setMsg] = React.useState(""); const [replacing, setReplacing] = React.useState(false); const handleGenerate = async () => { setGenerating(true); setMsg(""); try { const r = await fetch("/api/auth/ssh-key/generate", { method: "POST", credentials: "include" }); if (!r.ok) { const b = await r.json().catch(() => ({})); setMsg(b.detail || "Generate failed"); return; } await r.json(); setMsg("Key generated. Download the private key below."); setReplacing(false); if (onRefresh) onRefresh(); } catch { setMsg("Network error"); } finally { setGenerating(false); } }; const handleUpload = async () => { if (!pubKey.trim()) { setMsg("Paste your public key first"); return; } setMsg(""); try { const r = await fetch("/api/auth/ssh-key", { method: "PUT", credentials: "include", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ publicKey: pubKey.trim() }) }); if (!r.ok) { const b = await r.json().catch(() => ({})); setMsg(b.detail || "Upload failed"); return; } setMsg("Key saved."); setReplacing(false); setPubKey(""); if (onRefresh) onRefresh(); } catch { setMsg("Network error"); } }; const handleDownload = async () => { try { const r = await fetch("/api/auth/ssh-key/download", { credentials: "include" }); if (!r.ok) { setMsg("No generated key on file. Generate one first."); return; } const blob = await r.blob(); const url = URL.createObjectURL(blob); const a = document.createElement("a"); a.href = url; a.download = `seis-${user.handle}-rsa.pem`; a.click(); URL.revokeObjectURL(url); } catch { setMsg("Download failed"); } }; const hasKey = user?.hasSshKey; return (
EC2-005 SSH ACCESS KEY {hasKey ? ● RSA-4096 : ⚠ NOT SET}
{hasKey && !replacing ? (
Key injected into instances via cloud-init. Connect with{" "} ssh ubuntu@<ip>.
) : (
{hasKey &&
Replace existing key:
}
OR PASTE PUBLIC KEY
setPubKey(e.target.value)} placeholder="ssh-rsa AAAA..." style={{ width: "100%", fontSize: 10 }} />
{replacing && }
)} {msg &&
{msg}
}
); } function InviteButton() { const [msg, setMsg] = React.useState(""); const generate = async () => { try { const r = await fetch("/api/auth/register-link", { method: "POST", credentials: "include" }); if (!r.ok) { setMsg("FAILED"); return; } const d = await r.json(); await navigator.clipboard.writeText(d.url); setMsg("LINK COPIED"); setTimeout(() => setMsg(""), 2000); } catch { setMsg("ERROR"); setTimeout(() => setMsg(""), 2000); } }; return ( {msg && {msg}} ); } function Topbar({ user, onSignOut, theme, onToggleTheme }) { return (
SEIS+ INTERNALS · STUDIO ONLY @{user.handle} {user.name || user.handle}
); } function Masthead() { return (
INTERNALS+ studio operations.
); } function Footer() { return ( ); } const PROBE_REGIONS = ["us-east-1", "us-east-2", "us-west-1", "us-west-2"]; const PROBE_SAMPLES = 10; const PROBE_INTERVAL = 2000; function App() { const [tweaks, setTweak] = useTweaks(DEFAULTS); const [launcherOpen, setLauncherOpen] = React.useState(false); const [instancePanelId, setInstancePanelId] = React.useState(null); const [user, setUser] = React.useState(null); const [authLoading, setAuthLoading] = React.useState(true); const [authMode, setAuthMode] = React.useState(window.location.pathname.startsWith("/register") ? "register" : "login"); const [regionLatency, setRegionLatency] = React.useState({}); // { region: [ms, ...] } // Session check on mount React.useEffect(() => { fetch("/api/auth/me", { credentials: "include" }) .then(r => r.ok ? r.json() : null) .then(u => { setUser(u); setAuthLoading(false); }) .catch(() => setAuthLoading(false)); }, []); // Sync auth mode with URL on popstate React.useEffect(() => { const handler = () => setAuthMode(window.location.pathname.startsWith("/register") ? "register" : "login"); window.addEventListener("popstate", handler); return () => window.removeEventListener("popstate", handler); }, []); // Latency probes — start on mount, 10 samples per region, every 2s React.useEffect(() => { const probe = async (reg) => { const t0 = performance.now(); try { await fetch(`https://dynamodb.${reg}.amazonaws.com`, { mode: "no-cors", cache: "no-cache" }); } catch {} const ms = Math.round(performance.now() - t0); setRegionLatency(prev => { const s = prev[reg] || []; if (s.length >= PROBE_SAMPLES) return prev; return { ...prev, [reg]: [...s, ms] }; }); }; // Stagger initial burst PROBE_REGIONS.forEach((reg, i) => setTimeout(() => probe(reg), i * 150)); const id = setInterval(() => { setRegionLatency(snap => { const allDone = PROBE_REGIONS.every(r => (snap[r] || []).length >= PROBE_SAMPLES); if (allDone) { clearInterval(id); return snap; } PROBE_REGIONS.forEach((reg, i) => { if ((snap[reg] || []).length < PROBE_SAMPLES) setTimeout(() => probe(reg), i * 150); }); return snap; }); }, PROBE_INTERVAL); return () => clearInterval(id); }, []); // Theme / density React.useEffect(() => { document.documentElement.dataset.theme = tweaks.theme; document.documentElement.dataset.density = tweaks.density; document.documentElement.style.setProperty("--accent", ACCENTS[tweaks.accent] || ACCENTS.sky); }, [tweaks]); React.useEffect(() => { const id = "grain-toggle-style"; let el = document.getElementById(id); if (!el) { el = document.createElement("style"); el.id = id; document.head.appendChild(el); } el.textContent = tweaks.showGrain ? "" : "body::before { display: none; }"; }, [tweaks.showGrain]); // Live data — only fetch when authenticated const [llmData, llmLoading] = useApi(user ? "/api/litellm/budgets" : null, 30000); const [ec2Budget, budgetLoading] = useApi(user ? "/api/ec2/budget" : null, 300000); const [ec2Instances, instLoading] = useApi(user ? "/api/ec2/instances" : null, 30000); const [ec2Types] = useApi(user ? "/api/ec2/types" : null, 300000); const [activity, actLoading] = useApi(user ? "/api/activity" : null, 30000); const [ec2History, histLoading] = useApi(user ? "/api/ec2/history" : null, 60000); if (authLoading) { return (
AUTHENTICATING...
); } const switchAuthMode = (mode) => { const path = mode === "register" ? "/register" : "/login"; window.history.pushState({}, "", path); setAuthMode(mode); }; const registerTokenMatch = window.location.pathname.match(/^\/register\/(.+)$/); const registerToken = registerTokenMatch ? registerTokenMatch[1] : ""; if (!user) { if (authMode === "register") { return setUser(m)} theme={tweaks.theme} onToggleTheme={() => setTweak("theme", tweaks.theme === "dark" ? "light" : "dark")} onSwitchMode={switchAuthMode} registerToken={registerToken} />; } return setUser(m)} theme={tweaks.theme} onToggleTheme={() => setTweak("theme", tweaks.theme === "dark" ? "light" : "dark")} onSwitchMode={switchAuthMode} />; } const signOut = () => { fetch("/api/auth/logout", { method: "POST", credentials: "include" }) .finally(() => setUser(null)); }; const budgets = llmData?.budgets || []; const models = llmData?.models || []; return (
setTweak("theme", tweaks.theme === "dark" ? "light" : "dark")} /> {/* §01 — AI & GPUs */}
setLauncherOpen(true)} /> { fetch("/api/auth/me", { credentials: "include" }).then(r => r.ok ? r.json() : null).then(u => u && setUser(u)); }} /> setInstancePanelId(id)} hasSshKey={user?.hasSshKey} />
{/* §02 — MODELS */}
{/* §03 — SERVERS */}
setInstancePanelId(id)} hasSshKey={user?.hasSshKey} />
{/* §04 — EC2 HISTORY */}
{/* §05 — SHORTCUTS */}
{/* §06 — ACTIVITY */}
setLauncherOpen(false)} instanceTypes={ec2Types || []} budget={ec2Budget} regionLatency={regionLatency} /> {instancePanelId && ( setInstancePanelId(null)} hasSshKey={user?.hasSshKey} user={user} /> )} setTweak("density", v)} options={[ { value: "compact", label: "Compact" }, { value: "default", label: "Default" }, { value: "spacious", label: "Spacious" }, ]} /> setTweak("theme", v)} options={[ { value: "light", label: "Cream" }, { value: "dark", label: "Dark" }, ]} /> setTweak("accent", v)} options={[ { value: "sky", label: "Sky (brand)" }, { value: "flag", label: "Flag green" }, { value: "amber", label: "Amber" }, { value: "ink", label: "Ink (mono)" }, ]} /> setTweak("showGrain", v)} label="Paper grain overlay" />
); } const root = ReactDOM.createRoot(document.getElementById("root")); root.render();