feat: lifecycle telegram_via routing and lifecycle details 1.2.12-SAC

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
PTah
2026-05-31 12:25:52 +10:00
parent e1a37b8f89
commit cf4e3b2e90
3 changed files with 35 additions and 4 deletions
+29
View File
@@ -333,6 +333,27 @@ sac_is_heartbeat_only_event() {
[ "${1:-}" = "agent.heartbeat" ]
}
# Добавляет generated_by / telegram_via в JSON details для ingest.
sac_merge_notify_details() {
local details_json="${1:-}"
local telegram_via="${2:-}"
DETAILS_IN="$details_json" TG_VIA="$telegram_via" python3 <<'PY'
import json, os
d = {}
raw = os.environ.get("DETAILS_IN", "").strip()
if raw:
try:
d = json.loads(raw)
except Exception:
d = {}
d.setdefault("generated_by", "agent")
via = os.environ.get("TG_VIA", "").strip()
if via:
d.setdefault("telegram_via", via)
print(json.dumps(d, ensure_ascii=False))
PY
}
# notify_or_sac type severity title summary telegram_message [details_json]
notify_or_sac() {
local event_type="$1"
@@ -347,6 +368,14 @@ notify_or_sac() {
unset SAC_D_USER SAC_D_IP SAC_D_COMMAND SAC_D_ATTEMPT SAC_D_MAX SAC_D_RUN_AS SAC_D_PWD 2>/dev/null || true
local mode
mode="$(sac_normalize_mode "${UseSAC:-off}")"
local tg_via=""
case "$mode" in
exclusive|fallback) tg_via="sac" ;;
dual) tg_via="agent" ;;
esac
if [ -n "$tg_via" ]; then
details_json="$(sac_merge_notify_details "$details_json" "$tg_via")"
fi
# Периодический heartbeat — только SAC (браузер), без Telegram/email в любом режиме.
if sac_is_heartbeat_only_event "$event_type"; then