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:
2026-04-09 22:38:41 +00:00
parent ca2c5c5275
commit 40710b924d
3 changed files with 256 additions and 53 deletions
+60 -15
View File
@@ -1,8 +1,21 @@
#!/usr/bin/env bash
# create-full.sh — pipeline completo para crear un agente o robot funcional
#
# Ejecuta en orden: scaffold → build → register → verify E2EE → [convert robot] → [notify dev]
# NO arranca el agente — primero personalizar agent.go, config.yaml y prompts/system.md
# Pipeline de 7 pasos:
# 1. SCAFFOLD → crear archivos base desde template
# 2. BUILD → go build -tags goolm ./...
# 3. REGISTER → crear usuario Matrix + token
# 4. VERIFY E2EE → cross-signing + recovery key
# 5. CONVERT (robot) → eliminar LLM/prompts si type=robot
# 6. AUTO-AVATAR → generar y aplicar foto de perfil
# 7. DISPLAY NAME → configurar nombre visible en Matrix
#
# Pasos posteriores (manuales o via father-bot):
# 8. PERSONALIZE → config.yaml, agent.go, system prompt
# 9. REBUILD → recompilar tras personalizacion
# 10. START/RESTART → arrancar el launcher con el bot
# 11. HEALTH CHECK → ./dev-scripts/agent/health-check.sh <id>
# 12. SELF-INTRODUCE → ./dev-scripts/agent/notify-developer.sh <id>
#
# Uso:
# ./dev-scripts/agent/create-full.sh <agent-id> "Display Name" # agente (default)
@@ -56,8 +69,8 @@ echo -e "${BLU}═════════════════════
echo ""
# ── Paso 1: Scaffold ─────────────────────────────────────────────────────
TOTAL_STEPS=6
[[ "$TYPE" == "robot" ]] && TOTAL_STEPS=7
TOTAL_STEPS=7
[[ "$TYPE" == "robot" ]] && TOTAL_STEPS=8
info "Paso 1/${TOTAL_STEPS} — Scaffold (agent.go, config.yaml, prompts, launcher)"
echo ""
@@ -115,7 +128,7 @@ if [[ "$TYPE" == "robot" ]]; then
fi
# ── Paso auto-avatar: Generar avatar automatico ─────────────────────────
AVATAR_STEP=$((TOTAL_STEPS - 1))
AVATAR_STEP=$((TOTAL_STEPS - 2))
info "Paso ${AVATAR_STEP}/${TOTAL_STEPS} — Generando avatar automatico..."
echo ""
@@ -134,14 +147,39 @@ fi
echo ""
# ── Paso display name: Configurar nombre visible en Matrix ──────────────
DISPLAYNAME_STEP=$((TOTAL_STEPS - 1))
info "Paso ${DISPLAYNAME_STEP}/${TOTAL_STEPS} — Configurando display name en Matrix..."
echo ""
# Reload .env to pick up token from register.sh
load_env
TOKEN_VAR="MATRIX_TOKEN_${NORM}"
BOT_TOKEN="${!TOKEN_VAR:-}"
if [[ -n "$BOT_TOKEN" ]]; then
USER_ID="@${ID}:${MATRIX_SERVER_NAME}"
if curl -sf -X PUT \
"${MATRIX_HOMESERVER}/_matrix/client/v3/profile/${USER_ID}/displayname" \
-H "Authorization: Bearer $BOT_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"displayname\": \"${DISPLAYNAME}\"}" >/dev/null 2>&1; then
ok "Display name configurado: $DISPLAYNAME"
else
warn "No se pudo configurar display name (se puede hacer despues manualmente)"
fi
else
warn "Token del bot no encontrado — display name no configurado"
fi
echo ""
# ── Paso final: Notificar al developer ───────────────────────────────────
NOTIFY_STEP=$TOTAL_STEPS
info "Paso ${NOTIFY_STEP}/${TOTAL_STEPS} — Notificando a desarrolladores..."
echo ""
# Reload .env (verify.sh may have added recovery key)
load_env
"$SCRIPT_DIR/notify-developer.sh" "$ID" "$TYPE" "$DISPLAYNAME" || true
echo ""
@@ -167,21 +205,28 @@ echo ""
echo -e " ${BLU}Launcher actualizado:${RST}"
echo -e " cmd/launcher/main.go (import)"
echo ""
echo -e "${YLW}Siguiente paso:${RST}"
echo -e "${YLW}Siguientes pasos (8-12 del pipeline):${RST}"
echo ""
if [[ "$TYPE" == "robot" ]]; then
echo -e " 1. Añadir comandos custom:"
echo -e " ${BLU}8. PERSONALIZE${RST} — añadir comandos custom:"
echo -e " ${DIM}agents/$ID/commands.go${RST}"
echo ""
echo -e " 2. Registrar comandos en el launcher:"
echo -e " ${DIM}cmd/launcher/main.go${RST}"
echo -e " ${DIM}cmd/launcher/main.go${RST} (registrar comandos)"
else
echo -e " 1. Personalizar los archivos del agente:"
echo -e " ${BLU}8. PERSONALIZE${RST} — personalizar los archivos del agente:"
echo -e " ${DIM}agents/$ID/agent.go${RST} — reglas de decisión"
echo -e " ${DIM}agents/$ID/config.yaml${RST} — LLM, tools, personalidad"
echo -e " ${DIM}agents/$ID/prompts/system.md${RST} — system prompt"
fi
echo ""
echo -e " Arrancar:"
echo -e " ${BLU}9. REBUILD${RST}:"
echo -e " ${DIM}go build -tags goolm ./...${RST}"
echo ""
echo -e " ${BLU}10. START${RST}:"
echo -e " ${DIM}./dev-scripts/server/start.sh${RST}"
echo ""
echo -e " ${BLU}11. HEALTH CHECK${RST}:"
echo -e " ${DIM}./dev-scripts/agent/health-check.sh $ID${RST}"
echo ""
echo -e " ${BLU}12. SELF-INTRODUCE${RST} (tras health check ok):"
echo -e " ${DIM}./dev-scripts/agent/notify-developer.sh $ID $TYPE \"$DISPLAYNAME\"${RST}"
echo ""