feat: agregar display name, health check y mejorar notificacion — issue 0044
Pipeline de creacion formalizado con 3 mejoras:
1. Display name automatico (paso 7): create-full.sh ahora configura
el display name en Matrix via PUT al profile API con el token
del bot recien creado. Evita que los bots aparezcan como @id:server.
2. Health check post-arranque: nuevo script health-check.sh que busca
en los logs del launcher mensajes de arranque exitoso ("e2ee ready",
"runner started", etc.) con timeout configurable (default 30s).
3. Notificacion enriquecida: notify-developer.sh ahora incluye
descripcion del agente (leida de config.yaml), tools habilitadas,
formato markdown con estructura clara, y reintentos con backoff
(hasta 3 intentos) si el envio de DM falla.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Executable
+69
@@ -0,0 +1,69 @@
|
||||
#!/usr/bin/env bash
|
||||
# health-check.sh — verifica que un agente/robot esta activo tras arrancar
|
||||
#
|
||||
# Busca en los logs del launcher mensajes que indiquen arranque exitoso:
|
||||
# - "e2ee ready" o "starting matrix sync"
|
||||
# - "runner started" o "agent running"
|
||||
#
|
||||
# Uso:
|
||||
# ./dev-scripts/agent/health-check.sh <agent-id> [timeout_secs]
|
||||
#
|
||||
# Exit codes:
|
||||
# 0 — agente activo y saludable
|
||||
# 1 — agente no encontrado o no arranco en el timeout
|
||||
|
||||
source "$(dirname "$0")/../_common.sh"
|
||||
|
||||
need_arg "${1:-}"
|
||||
|
||||
ID="$1"
|
||||
TIMEOUT="${2:-30}"
|
||||
LOG_FILE="$REPO_ROOT/run/launcher.log"
|
||||
|
||||
[[ -f "$LOG_FILE" ]] || fail "Log del launcher no encontrado: $LOG_FILE"
|
||||
|
||||
info "Verificando salud de $ID (timeout: ${TIMEOUT}s)..."
|
||||
|
||||
# Buscar mensajes de arranque exitoso del agente en los logs
|
||||
# Los mensajes contienen el agent ID en el campo "agent" del JSON
|
||||
check_health() {
|
||||
local found_sync=false
|
||||
local found_running=false
|
||||
|
||||
# Buscar en las ultimas 200 lineas del log (suficiente para un arranque reciente)
|
||||
local recent_logs
|
||||
recent_logs="$(tail -200 "$LOG_FILE" 2>/dev/null || true)"
|
||||
|
||||
# Buscar mensajes especificos del agente
|
||||
if echo "$recent_logs" | grep -q "\"agent\":\"${ID}\".*starting matrix sync\|\"agent\":\"${ID}\".*e2ee ready"; then
|
||||
found_sync=true
|
||||
fi
|
||||
|
||||
if echo "$recent_logs" | grep -q "\"agent\":\"${ID}\".*runner started\|\"agent\":\"${ID}\".*agent running"; then
|
||||
found_running=true
|
||||
fi
|
||||
|
||||
if $found_sync || $found_running; then
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
# Esperar hasta timeout
|
||||
elapsed=0
|
||||
while [[ $elapsed -lt $TIMEOUT ]]; do
|
||||
if check_health; then
|
||||
ok "Agente $ID esta activo y saludable"
|
||||
exit 0
|
||||
fi
|
||||
sleep 2
|
||||
elapsed=$((elapsed + 2))
|
||||
done
|
||||
|
||||
# Timeout — mostrar ultimas lineas relevantes del log para diagnostico
|
||||
warn "Agente $ID no confirmo arranque exitoso en ${TIMEOUT}s"
|
||||
echo ""
|
||||
echo "Ultimas lineas del log con $ID:"
|
||||
tail -50 "$LOG_FILE" 2>/dev/null | grep "$ID" | tail -10 || echo " (sin mensajes del agente)"
|
||||
echo ""
|
||||
exit 1
|
||||
Reference in New Issue
Block a user