Add notifier configuration management for Sentinel and LLM

This commit is contained in:
infinition
2026-03-16 21:54:31 +01:00
parent b759ab6d4b
commit df83cd2e92
7 changed files with 81 additions and 10 deletions

View File

@@ -154,9 +154,12 @@ class LLMUtils:
"llm_orchestrator_mode", "llm_orchestrator_interval_s",
"llm_orchestrator_max_actions", "llm_orchestrator_allowed_actions",
"llm_orchestrator_skip_if_no_change", "llm_orchestrator_log_reasoning",
"llm_orchestrator_skip_scheduler",
# Personality & prompt keys
"llm_system_prompt_chat", "llm_system_prompt_comment",
"llm_user_name", "llm_user_bio",
# EPD
"epd_buttons_enabled",
}
_int_keys = {
"llm_timeout_s", "llm_max_tokens", "llm_comment_max_tokens",
@@ -167,6 +170,7 @@ class LLMUtils:
"llm_enabled", "llm_comments_enabled", "llm_comments_log", "llm_chat_enabled",
"llm_laruche_discovery", "llm_chat_tools_enabled",
"llm_orchestrator_skip_if_no_change", "llm_orchestrator_log_reasoning",
"llm_orchestrator_skip_scheduler", "epd_buttons_enabled",
}
try:
cfg = self.shared_data.config
@@ -299,7 +303,9 @@ class LLMUtils:
# Orchestrator
"llm_orchestrator_mode", "llm_orchestrator_interval_s",
"llm_orchestrator_max_actions", "llm_orchestrator_skip_if_no_change",
"llm_orchestrator_log_reasoning",
"llm_orchestrator_log_reasoning", "llm_orchestrator_skip_scheduler",
# EPD
"epd_buttons_enabled",
# Personality & prompts
"llm_system_prompt_chat", "llm_system_prompt_comment",
"llm_user_name", "llm_user_bio",

View File

@@ -219,12 +219,40 @@ class SentinelUtils:
except Exception as e:
return {"status": "error", "message": str(e)}
# Mapping from frontend notifier keys to config keys
_NOTIFIER_KEY_MAP = {
"discord_webhook": "sentinel_discord_webhook",
"webhook_url": "sentinel_webhook_url",
"email_smtp_host": "sentinel_email_smtp_host",
"email_smtp_port": "sentinel_email_smtp_port",
"email_username": "sentinel_email_username",
"email_password": "sentinel_email_password",
"email_from": "sentinel_email_from",
"email_to": "sentinel_email_to",
}
def get_notifier_config(self, handler) -> None:
"""GET /api/sentinel/notifiers — return current notifier config."""
cfg = self.shared_data.config
notifiers = {}
for frontend_key, cfg_key in self._NOTIFIER_KEY_MAP.items():
val = cfg.get(cfg_key, "")
if val:
notifiers[frontend_key] = val
self._send_json(handler, {"status": "ok", "notifiers": notifiers})
def save_notifier_config(self, data: Dict) -> Dict:
"""POST /api/sentinel/notifiers — save notification channel config."""
try:
# Store notifier configs in shared_data for persistence
notifiers = data.get("notifiers", {})
self.shared_data.sentinel_notifiers = notifiers
cfg = self.shared_data.config
# Map frontend keys to config keys and persist
for frontend_key, cfg_key in self._NOTIFIER_KEY_MAP.items():
cfg[cfg_key] = notifiers.get(frontend_key, "")
self.shared_data.config = cfg
self.shared_data.save_config()
# Re-register notifiers on the engine
engine = self._engine