tools: add DASH-001 TOOL-001 TOOL-002 TOOL-003 and RUNNER-001 utilities

This commit is contained in:
2026-08-16 16:59:18 -04:00
parent 83d25cb2cd
commit 0a2106a7a6
24 changed files with 5440 additions and 0 deletions

52
tools/dashboard/notify.py Normal file
View File

@@ -0,0 +1,52 @@
"""Outbound notifications for the dashboard server."""
from __future__ import annotations
import json
import sys
from typing import Any, Dict, List
class AppriseNotifier:
def __init__(self, config: Dict[str, Any]) -> None:
notifications = config.get("notifications", {}) if isinstance(config.get("notifications", {}), dict) else {}
self.enabled = bool(notifications.get("enabled", False))
self.targets: List[str] = [str(item) for item in notifications.get("targets", [])]
self.available = False
self._apprise = None
if not self.enabled:
return
if not self.targets:
sys.stderr.write("dashboard notify: enabled but no Apprise targets configured; notifications disabled\n")
self.enabled = False
return
try:
import apprise # type: ignore
except ImportError:
sys.stderr.write("dashboard notify: Apprise is not installed; run pip install -r tools/dashboard/requirements.txt\n")
self.enabled = False
return
app = apprise.Apprise()
for target in self.targets:
app.add(target)
self._apprise = app
self.available = True
def send(self, event: Dict[str, Any]) -> None:
if not self.enabled or not self.available or self._apprise is None:
return
title = "NT8 {0}".format(event.get("type", "event"))
body = json.dumps(event, sort_keys=True)
try:
self._apprise.notify(title=title, body=body)
except Exception as ex: # best-effort notifier boundary
sys.stderr.write("dashboard notify: Apprise send failed; continuing: {0}\n".format(ex))
def status(self) -> Dict[str, Any]:
return {
"enabled": self.enabled,
"available": self.available,
"target_count": len(self.targets),
}