"""Konfiguration für Hermes Memory Next Level. Lädt aus ~/.hermes/profiles//memory/config.json mit Fallback auf DEFAULT_CONFIG. """ import json import os from pathlib import Path from typing import Any, Dict DEFAULT_CONFIG: Dict[str, Any] = { "profile": "default", "tier2": { "enabled": True, "db_path": "{HERMES_HOME}/{profile}/memory/tier2.db", "wal_mode": True, "max_facts": 100_000, "max_entities": 10_000, "auto_dedupe": True, }, "tier3": { "enabled": True, "backend": "chroma", "path": "{HERMES_HOME}/{profile}/memory/tier3", "embedding_model": "local", "embedding_dim": 384, "chunk_size": 512, "chunk_overlap": 64, "min_score": 0.7, }, "graph": { "enabled": True, "path": "{HERMES_HOME}/{profile}/memory/graph", "auto_rebuild_interval_hours": 24, "max_nodes": 50_000, "centrality_algorithm": "betweenness", }, "cron": { "consolidate_schedule": "0 3 * * *", "embed_schedule": "*/5 * * * *", "graph_rebuild_schedule": "0 4 * * 0", "prune_schedule": "0 2 1 * *", }, "limits": { "fact_ttl_days": 365, "session_index_max_age_days": 90, "max_embedding_queue": 1000, }, } def _resolve_path(template: str, profile: str) -> Path: """Ersetzt {HERMES_HOME} und {profile} im Pfad-Template.""" hermes_home = Path(os.environ.get("HERMES_HOME", Path.home() / ".hermes")) raw = template.replace("{HERMES_HOME}", str(hermes_home)).replace("{profile}", profile) return Path(raw) def load_config(profile: str = "default") -> Dict[str, Any]: """Lade Konfiguration mit Profil-Auflösung.""" config_path = _resolve_path("{HERMES_HOME}/profiles/{profile}/memory/config.json", profile) config = DEFAULT_CONFIG.copy() if config_path.exists(): with open(config_path, "r", encoding="utf-8") as f: user_config = json.load(f) config.update(user_config) config["profile"] = profile return config