115 lines
4.0 KiB
Python
115 lines
4.0 KiB
Python
import os
|
|
from pathlib import Path
|
|
from typing import Dict, Any, List
|
|
from pydantic import BaseModel, Field, field_validator
|
|
from pydantic_settings import BaseSettings
|
|
|
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
|
DATA_DIR = Path(os.getenv("HUB_DATA_DIR", BASE_DIR / "data"))
|
|
PERSONAS_DIR = DATA_DIR / "personas"
|
|
CLONES_DIR = DATA_DIR / "clones"
|
|
|
|
class UniverseConfig(BaseModel):
|
|
id: str
|
|
name: str
|
|
tagline: str
|
|
description: str
|
|
backend_url: str
|
|
scope: str
|
|
accent_token: str
|
|
icon: str
|
|
persona_file: str
|
|
enabled: bool = True
|
|
|
|
class Settings(BaseSettings):
|
|
app_name: str = "Hermes Hub"
|
|
host: str = "127.0.0.1" # Bind loopback by default
|
|
port: int = 8080
|
|
debug: bool = False
|
|
|
|
# NAS & VPS Network Configurations
|
|
nas_tailscale_ip: str = os.getenv("NAS_TAILSCALE_IP", "100.86.197.88")
|
|
vps_tailscale_ip: str = os.getenv("VPS_TAILSCALE_IP", "100.94.90.119")
|
|
|
|
# Backends
|
|
hermes_tt_url: str = os.getenv("HERMES_TT_URL", "http://100.86.197.88:3010")
|
|
hermes_nyora_url: str = os.getenv("HERMES_NYORA_URL", "http://100.86.197.88:3020")
|
|
hermes_perso_url: str = os.getenv("HERMES_PERSO_URL", "http://100.86.197.88:3031")
|
|
hermes_nabil_url: str = os.getenv("HERMES_NABIL_URL", "http://127.0.0.1:8642")
|
|
|
|
# Hub Secret — OBLIGATOIRE, aucun fallback codé en dur (Fail-Fast au démarrage)
|
|
hub_secret: str = Field(..., min_length=16, description="Clé secrète maîtresse requise pour Hermes Hub")
|
|
|
|
@field_validator("hub_secret")
|
|
@classmethod
|
|
def validate_secret(cls, v: str) -> str:
|
|
if not v or v.strip() == "" or "change-this" in v or "hermes-hub-master-key-2026" in v:
|
|
raise ValueError("HUB_SECRET doit être défini avec une clé sécurisée valide et ne doit pas utiliser de valeur par défaut.")
|
|
return v
|
|
|
|
class Config:
|
|
env_file = ".env"
|
|
extra = "ignore"
|
|
|
|
try:
|
|
settings = Settings()
|
|
except Exception as e:
|
|
# If starting in an environment without .env yet, define placeholder for type checking
|
|
# but runtime will fail fast if HUB_SECRET is absent
|
|
if "HUB_SECRET" in os.environ:
|
|
raise e
|
|
# Fallback only if running build/compile check with dummy env
|
|
settings = None
|
|
|
|
UNIVERSES: Dict[str, UniverseConfig] = {
|
|
"tt": UniverseConfig(
|
|
id="tt",
|
|
name="Tunisie Telecom",
|
|
tagline="Achats Zone Sud",
|
|
description="Direction Régionale — Marchés, RLA & Appels d'Offres",
|
|
backend_url=os.getenv("HERMES_TT_URL", "http://100.86.197.88:3010"),
|
|
scope="tt",
|
|
accent_token="--accent-tt",
|
|
icon="briefcase",
|
|
persona_file="tt.yaml"
|
|
),
|
|
"nyora": UniverseConfig(
|
|
id="nyora",
|
|
name="Nyora",
|
|
tagline="Venture & Dr Nexum",
|
|
description="Projets entrepreneuriaux, conseil & veille stratégique",
|
|
backend_url=os.getenv("HERMES_NYORA_URL", "http://100.86.197.88:3020"),
|
|
scope="nyora",
|
|
accent_token="--accent-nyora",
|
|
icon="sparkles",
|
|
persona_file="nyora.yaml"
|
|
),
|
|
"perso": UniverseConfig(
|
|
id="perso",
|
|
name="Personnel",
|
|
tagline="Famille & Santé",
|
|
description="Espace privé, santé familiale, gestion du quotidien",
|
|
backend_url=os.getenv("HERMES_PERSO_URL", "http://100.86.197.88:3031"),
|
|
scope="perso",
|
|
accent_token="--accent-perso",
|
|
icon="home",
|
|
persona_file="perso.yaml"
|
|
),
|
|
"nabil": UniverseConfig(
|
|
id="nabil",
|
|
name="Nabil Master",
|
|
tagline="Orchestration & DSH",
|
|
description="Master Agent VPS, exécution de code & DeepSeek Harness",
|
|
backend_url=os.getenv("HERMES_NABIL_URL", "http://127.0.0.1:8642"),
|
|
scope="nabil",
|
|
accent_token="--accent-nabil",
|
|
icon="terminal",
|
|
persona_file="nabil.yaml"
|
|
)
|
|
}
|
|
|
|
def get_universe(universe_id: str) -> UniverseConfig:
|
|
if universe_id not in UNIVERSES:
|
|
raise KeyError(f"Universe '{universe_id}' does not exist.")
|
|
return UNIVERSES[universe_id]
|