feat: initialisation Hermes Hub — interface multi-univers securisee (FastAPI, proxy async, design tokens)

This commit is contained in:
bolbol
2026-08-19 20:46:08 +01:00
commit d107d40a30
59 changed files with 1538 additions and 0 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+445
View File
@@ -0,0 +1,445 @@
/* Reset & Base Setup */
*, *::before, *::after {
box-sizing: border-box;
margin: 0;
padding: 0;
}
html, body {
width: 100%;
height: 100%;
overflow: hidden;
background-color: var(--hub-bg-canvas);
color: var(--hub-text-primary);
font-family: var(--hub-font-sans);
-webkit-font-smoothing: antialiased;
}
/* App Shell Container */
.hub-shell {
display: flex;
width: 100vw;
height: 100vh;
overflow: hidden;
}
/* Sidebar / Workspace Switcher */
.hub-sidebar {
width: var(--hub-sidebar-width);
height: 100%;
background-color: var(--hub-bg-sidebar);
border-right: 1px solid var(--hub-border-subtle);
display: flex;
flex-direction: column;
user-select: none;
z-index: 20;
transition: width 0.2s ease;
}
.hub-brand {
height: var(--hub-header-height);
padding: 0 1.25rem;
display: flex;
align-items: center;
gap: 0.75rem;
border-bottom: 1px solid var(--hub-border-subtle);
}
.hub-logo-icon {
width: 32px;
height: 32px;
border-radius: var(--hub-radius-md);
background: linear-gradient(135deg, var(--hub-accent-current), #4f46e5);
display: flex;
align-items: center;
justify-content: center;
font-weight: 700;
font-size: 1rem;
color: #ffffff;
box-shadow: 0 0 12px var(--hub-accent-glow-current);
}
.hub-brand-text {
font-size: 1.05rem;
font-weight: 600;
letter-spacing: -0.01em;
color: var(--hub-text-primary);
}
.hub-brand-badge {
font-size: 0.65rem;
font-weight: 700;
text-transform: uppercase;
background: var(--hub-bg-active);
padding: 2px 6px;
border-radius: var(--hub-radius-full);
color: var(--hub-text-secondary);
border: 1px solid var(--hub-border-subtle);
}
/* Universes Switcher List */
.hub-nav-section {
padding: 1rem 0.75rem 0.5rem;
font-size: 0.7rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.05em;
color: var(--hub-text-muted);
}
.hub-universes-list {
list-style: none;
padding: 0 0.5rem;
display: flex;
flex-direction: column;
gap: 0.35rem;
flex: 1;
overflow-y: auto;
}
.hub-universe-btn {
width: 100%;
display: flex;
align-items: center;
gap: 0.75rem;
padding: 0.65rem 0.75rem;
border-radius: var(--hub-radius-md);
background: transparent;
border: 1px solid transparent;
color: var(--hub-text-secondary);
cursor: pointer;
text-align: left;
transition: all 0.15s ease;
position: relative;
}
.hub-universe-btn:hover {
background-color: var(--hub-bg-card-hover);
color: var(--hub-text-primary);
}
.hub-universe-btn.active {
background-color: var(--hub-bg-card);
border-color: var(--hub-border-medium);
color: var(--hub-text-primary);
}
.hub-universe-btn.active::before {
content: "";
position: absolute;
left: -0.5rem;
top: 15%;
height: 70%;
width: 4px;
border-radius: var(--hub-radius-full);
background-color: var(--item-accent, var(--hub-accent-current));
box-shadow: 0 0 8px var(--item-accent, var(--hub-accent-current));
}
.hub-universe-avatar {
width: 32px;
height: 32px;
border-radius: var(--hub-radius-sm);
display: flex;
align-items: center;
justify-content: center;
font-weight: 700;
font-size: 0.85rem;
background-color: var(--hub-bg-canvas);
color: var(--item-accent, var(--hub-text-primary));
border: 1px solid var(--hub-border-subtle);
flex-shrink: 0;
}
.hub-universe-btn.active .hub-universe-avatar {
background-color: var(--item-accent, var(--hub-accent-current));
color: #ffffff;
border-color: transparent;
}
.hub-universe-info {
display: flex;
flex-direction: column;
overflow: hidden;
flex: 1;
}
.hub-universe-name {
font-size: 0.875rem;
font-weight: 600;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
.hub-universe-tagline {
font-size: 0.725rem;
color: var(--hub-text-muted);
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
.hub-status-dot {
width: 8px;
height: 8px;
border-radius: var(--hub-radius-full);
background-color: var(--hub-status-offline);
flex-shrink: 0;
}
.hub-status-dot.online {
background-color: var(--hub-status-online);
box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}
/* Sidebar Footer */
.hub-sidebar-footer {
padding: 0.75rem;
border-top: 1px solid var(--hub-border-subtle);
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.hub-tool-btn {
width: 100%;
display: flex;
align-items: center;
gap: 0.5rem;
padding: 0.5rem 0.75rem;
border-radius: var(--hub-radius-sm);
background: transparent;
border: 1px solid var(--hub-border-subtle);
color: var(--hub-text-secondary);
font-size: 0.8rem;
font-weight: 500;
cursor: pointer;
transition: all 0.15s ease;
}
.hub-tool-btn:hover {
background-color: var(--hub-bg-card-hover);
color: var(--hub-text-primary);
}
/* Main View Area */
.hub-main {
flex: 1;
display: flex;
flex-direction: column;
height: 100%;
overflow: hidden;
background-color: var(--hub-bg-canvas);
}
/* Universe Topbar */
.hub-topbar {
height: var(--hub-header-height);
background-color: var(--hub-bg-sidebar);
border-bottom: 1px solid var(--hub-border-subtle);
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 1.25rem;
z-index: 10;
}
.hub-topbar-left {
display: flex;
align-items: center;
gap: 1rem;
}
.hub-active-title {
font-size: 1rem;
font-weight: 600;
display: flex;
align-items: center;
gap: 0.5rem;
}
.hub-scope-pill {
font-size: 0.7rem;
font-weight: 600;
padding: 2px 8px;
border-radius: var(--hub-radius-full);
background-color: var(--hub-bg-card);
border: 1px solid var(--hub-border-medium);
color: var(--hub-accent-current);
}
.hub-topbar-right {
display: flex;
align-items: center;
gap: 0.75rem;
}
/* View Canvas (Iframe Workspace Container) */
.hub-canvas {
flex: 1;
width: 100%;
height: calc(100% - var(--hub-header-height));
position: relative;
background-color: var(--hub-bg-canvas);
}
.hub-workspace-iframe {
width: 100%;
height: 100%;
border: none;
background-color: transparent;
display: block;
}
/* Loading Overlay */
.hub-loader-overlay {
position: absolute;
inset: 0;
background-color: var(--hub-bg-canvas);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 1rem;
z-index: 5;
transition: opacity 0.2s ease;
}
.hub-loader-overlay.hidden {
opacity: 0;
pointer-events: none;
}
.hub-spinner {
width: 36px;
height: 36px;
border: 3px solid var(--hub-border-medium);
border-top-color: var(--hub-accent-current);
border-radius: 50%;
animation: spin 0.8s linear infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
/* Modal Overlay & Card */
.hub-modal-backdrop {
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.75);
backdrop-filter: blur(4px);
display: flex;
align-items: center;
justify-content: center;
z-index: 50;
opacity: 0;
pointer-events: none;
transition: opacity 0.2s ease;
}
.hub-modal-backdrop.open {
opacity: 1;
pointer-events: auto;
}
.hub-modal {
width: 90%;
max-width: 580px;
max-height: 85vh;
background-color: var(--hub-bg-card);
border: 1px solid var(--hub-border-medium);
border-radius: var(--hub-radius-lg);
display: flex;
flex-direction: column;
overflow: hidden;
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}
.hub-modal-header {
padding: 1.25rem;
border-bottom: 1px solid var(--hub-border-subtle);
display: flex;
align-items: center;
justify-content: space-between;
}
.hub-modal-body {
padding: 1.25rem;
overflow-y: auto;
display: flex;
flex-direction: column;
gap: 1rem;
}
.hub-modal-footer {
padding: 1rem 1.25rem;
border-top: 1px solid var(--hub-border-subtle);
display: flex;
align-items: center;
justify-content: flex-end;
gap: 0.75rem;
}
.hub-form-group {
display: flex;
flex-direction: column;
gap: 0.35rem;
}
.hub-form-label {
font-size: 0.8rem;
font-weight: 600;
color: var(--hub-text-secondary);
}
.hub-input, .hub-textarea {
width: 100%;
background-color: var(--hub-bg-canvas);
border: 1px solid var(--hub-border-medium);
border-radius: var(--hub-radius-sm);
padding: 0.6rem 0.75rem;
color: var(--hub-text-primary);
font-family: var(--hub-font-sans);
font-size: 0.875rem;
}
.hub-input:focus, .hub-textarea:focus {
outline: none;
border-color: var(--hub-accent-current);
}
.hub-textarea {
min-height: 90px;
resize: vertical;
}
.hub-btn {
padding: 0.5rem 1rem;
border-radius: var(--hub-radius-sm);
font-size: 0.85rem;
font-weight: 600;
cursor: pointer;
border: none;
transition: all 0.15s ease;
}
.hub-btn-primary {
background-color: var(--hub-accent-current);
color: #ffffff;
}
.hub-btn-primary:hover {
opacity: 0.9;
}
.hub-btn-secondary {
background-color: var(--hub-bg-active);
color: var(--hub-text-secondary);
}
.hub-btn-secondary:hover {
background-color: var(--hub-bg-card-hover);
color: var(--hub-text-primary);
}
+58
View File
@@ -0,0 +1,58 @@
/**
* Hermes Hub — Design Tokens System
* Variables CSS modifiables et substituables par Claude Design
*/
:root {
/* Surfaces & Backgrounds (Dark Mode par défaut) */
--hub-bg-canvas: #0c0e12;
--hub-bg-sidebar: #13161c;
--hub-bg-card: #1a1e26;
--hub-bg-card-hover: #222733;
--hub-bg-active: #2b3242;
--hub-bg-glass: rgba(19, 22, 28, 0.85);
/* Borders & Dividers */
--hub-border-subtle: #232833;
--hub-border-medium: #303746;
--hub-border-focus: #4b5563;
/* Typography Colors */
--hub-text-primary: #f3f4f6;
--hub-text-secondary: #9ca3af;
--hub-text-muted: #6b7280;
--hub-text-inverse: #030712;
/* Status Colors */
--hub-status-online: #10b981;
--hub-status-degraded: #f59e0b;
--hub-status-offline: #ef4444;
/* Universe Accent Tokens (Substituables) */
--accent-tt: #3b82f6; /* TT Blue */
--accent-tt-glow: rgba(59, 130, 246, 0.25);
--accent-nyora: #10b981; /* Nyora Emerald */
--accent-nyora-glow: rgba(16, 185, 129, 0.25);
--accent-perso: #f97316; /* Perso Warm Orange */
--accent-perso-glow: rgba(249, 115, 22, 0.25);
--accent-nabil: #8b5cf6; /* Nabil Purple / Gold */
--accent-nabil-glow: rgba(139, 92, 246, 0.25);
/* Current Active Accent (Dynamically mapped via JS) */
--hub-accent-current: var(--accent-tt);
--hub-accent-glow-current: var(--accent-tt-glow);
/* Typography & Layout Metrics */
--hub-font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
--hub-font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
--hub-radius-sm: 6px;
--hub-radius-md: 10px;
--hub-radius-lg: 14px;
--hub-radius-full: 9999px;
--hub-sidebar-width: 260px;
--hub-sidebar-collapsed-width: 72px;
--hub-header-height: 56px;
}
Binary file not shown.
+214
View File
@@ -0,0 +1,214 @@
/**
* Hermes Hub — Client-side Workspace Switcher & Context Manager
* Garantit l'isolation stricte du state front-end entre univers
*/
(function () {
let activeUniverse = "tt";
const iframe = document.getElementById("workspace-iframe");
const loader = document.getElementById("hub-loader");
const activeTitle = document.getElementById("active-universe-name");
const activeScope = document.getElementById("active-universe-scope");
const activeTagline = document.getElementById("active-universe-tagline");
// Accent mappings
const ACCENT_MAP = {
tt: "var(--accent-tt)",
nyora: "var(--accent-nyora)",
perso: "var(--accent-perso)",
nabil: "var(--accent-nabil)"
};
const ACCENT_GLOW_MAP = {
tt: "var(--accent-tt-glow)",
nyora: "var(--accent-nyora-glow)",
perso: "var(--accent-perso-glow)",
nabil: "var(--accent-nabil-glow)"
};
function applyThemeTokens(universeId) {
const accent = ACCENT_MAP[universeId] || "var(--accent-tt)";
const glow = ACCENT_GLOW_MAP[universeId] || "var(--accent-tt-glow)";
document.documentElement.style.setProperty("--hub-accent-current", accent);
document.documentElement.style.setProperty("--hub-accent-glow-current", glow);
}
function switchUniverse(universeId) {
if (!universeId || (activeUniverse === universeId && iframe.src !== "about:blank")) {
return;
}
const btn = document.querySelector(`.hub-universe-btn[data-universe="${universeId}"]`);
if (!btn) return;
// 1. ISOLATION TOTALE DU STATE CLIENT
// Forcer le déchargement de l'iframe précédente pour éliminer tout résidu JS en mémoire
loader.classList.remove("hidden");
iframe.src = "about:blank";
// 2. Mettre à jour l'univers actif
activeUniverse = universeId;
// 3. Mettre à jour la classe active sur la sidebar
document.querySelectorAll(".hub-universe-btn").forEach((el) => el.classList.remove("active"));
btn.classList.add("active");
// 4. Appliquer les Design Tokens dynamiques
applyThemeTokens(universeId);
// 5. Mettre à jour les informations du header
const name = btn.dataset.name || universeId.toUpperCase();
const scope = btn.dataset.scope || universeId;
const tagline = btn.dataset.tagline || "";
if (activeTitle) activeTitle.textContent = name;
if (activeScope) activeScope.textContent = `Scope: ${scope}`;
if (activeTagline) activeTagline.textContent = tagline;
// 6. Charger le nouvel univers via le proxy dédié
const targetProxyUrl = `/u/${universeId}/`;
setTimeout(() => {
iframe.src = targetProxyUrl;
}, 50);
}
// Écouter le chargement de l'iframe
if (iframe) {
iframe.addEventListener("load", () => {
if (iframe.src !== "about:blank") {
loader.classList.add("hidden");
}
});
}
// Polling de l'état de santé des univers
async function refreshHealthStatus() {
try {
const res = await fetch("/api/universes");
if (!res.ok) return;
const data = await res.json();
data.forEach((u) => {
const dot = document.getElementById(`status-dot-${u.id}`);
if (dot) {
if (u.health && u.health.status === "online") {
dot.className = "hub-status-dot online";
dot.title = `En ligne (${u.health.latency_ms}ms)`;
} else {
dot.className = "hub-status-dot";
dot.title = `Hors ligne ou dégradé (${u.health.status})`;
}
}
});
} catch (e) {
console.warn("Health check error:", e);
}
}
// Modal Personnalité
const personaModal = document.getElementById("persona-modal");
const cloneModal = document.getElementById("clone-modal");
async function openPersonaModal() {
try {
const res = await fetch(`/api/universes/${activeUniverse}/persona`);
if (!res.ok) throw new Error("Erreur de chargement de la persona");
const persona = await res.json();
document.getElementById("persona-modal-title").textContent = `Personnalité — ${activeUniverse.toUpperCase()}`;
document.getElementById("persona-name").value = persona.name || "";
document.getElementById("persona-tagline").value = persona.tagline || "";
document.getElementById("persona-tone").value = persona.tone || "";
document.getElementById("persona-style").value = persona.style || "";
document.getElementById("persona-principles").value = (persona.principles || []).join("\n");
document.getElementById("persona-prompt").value = persona.system_prompt || "";
personaModal.classList.add("open");
} catch (e) {
alert("Impossible de charger la personnalité : " + e.message);
}
}
async function savePersona() {
const principlesText = document.getElementById("persona-principles").value;
const payload = {
universe_id: activeUniverse,
name: document.getElementById("persona-name").value,
tagline: document.getElementById("persona-tagline").value,
tone: document.getElementById("persona-tone").value,
style: document.getElementById("persona-style").value,
principles: principlesText.split("\n").map(s => s.trim()).filter(Boolean),
system_prompt: document.getElementById("persona-prompt").value,
version: 1
};
try {
const res = await fetch(`/api/universes/${activeUniverse}/persona`, {
method: "PUT",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload)
});
if (!res.ok) throw new Error("Erreur de sauvegarde");
personaModal.classList.remove("open");
} catch (e) {
alert("Erreur lors de la sauvegarde : " + e.message);
}
}
function openCloneModal() {
document.getElementById("clone-source-name").textContent = activeUniverse.toUpperCase();
document.getElementById("clone-name").value = `Clone ${activeUniverse.toUpperCase()} - Test`;
cloneModal.classList.add("open");
}
async function submitClone() {
const cloneName = document.getElementById("clone-name").value;
if (!cloneName) return alert("Veuillez saisir un nom pour le clone.");
try {
const res = await fetch(`/api/universes/${activeUniverse}/clone`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ clone_name: cloneName })
});
if (!res.ok) throw new Error("Erreur lors du clonage");
const data = await res.json();
alert(`Profil cloné avec succès : ${data.clone.clone_id}`);
cloneModal.classList.remove("open");
} catch (e) {
alert("Erreur de clonage : " + e.message);
}
}
// Setup Event Listeners
document.addEventListener("DOMContentLoaded", () => {
// Boutons de changement d'univers
document.querySelectorAll(".hub-universe-btn").forEach((btn) => {
btn.addEventListener("click", () => {
const uId = btn.dataset.universe;
switchUniverse(uId);
});
});
// Outils Footer
document.getElementById("btn-edit-persona")?.addEventListener("click", openPersonaModal);
document.getElementById("btn-clone-universe")?.addEventListener("click", openCloneModal);
document.getElementById("btn-save-persona")?.addEventListener("click", savePersona);
document.getElementById("btn-submit-clone")?.addEventListener("click", submitClone);
// Boutons fermer modales
document.querySelectorAll(".hub-modal-close").forEach((btn) => {
btn.addEventListener("click", () => {
personaModal.classList.remove("open");
cloneModal.classList.remove("open");
});
});
// Démarrage : activer le premier univers (TT)
switchUniverse("tt");
// Lancer la vérification de santé
refreshHealthStatus();
setInterval(refreshHealthStatus, 15000);
});
})();