bot contesta con e2ee

This commit is contained in:
2026-03-04 00:59:10 +00:00
parent bd8e1432e5
commit 396fc39b90
12 changed files with 316 additions and 46 deletions
+49 -16
View File
@@ -146,7 +146,7 @@ tools:
matrix:
homeserver: "${MATRIX_HOMESERVER}"
user_id: "@$ID:${MATRIX_SERVER_NAME}"
access_token_env: MATRIX_TOKEN_$(echo "$ID" | tr '[:lower:]-' '[:upper:]_')
access_token_env: MATRIX_TOKEN_$(echo "$ID" | tr '[:lower:]-' '[:upper:]_' | sed 's/_BOT$//')
device_id: "$(echo "$ID" | tr '[:lower:]-' '[:upper:]_')01"
encryption:
@@ -338,21 +338,54 @@ MD
ok "Scaffold creado en $DIR/"
echo ""
# ── Pasos siguientes ──────────────────────────────────────────────────────
echo -e "${YLW}Quedan 2 pasos manuales:${RST}"
# ── Actualizar cmd/launcher/main.go ───────────────────────────────────────
LAUNCHER="cmd/launcher/main.go"
if grep -q "\"$ID\":" "$LAUNCHER" 2>/dev/null; then
warn "$ID ya está en rulesRegistry de $LAUNCHER — saltando"
else
TAB=$'\t'
IMPORT_LINE="${TAB}${PACKAGE}agent \"github.com/enmanuel/agents/agents/$ID\""
REGISTRY_LINE="${TAB}\"$ID\": ${PACKAGE}agent.Rules,"
# Insertar import después del último import agents/agents/*
if awk -v new_import="$IMPORT_LINE" '
{
lines[NR] = $0
if ($0 ~ /[a-z_]+agent "github\.com\/enmanuel\/agents\/agents\/[^"]+"/)
last_import = NR
}
END {
if (!last_import) { for (i=1;i<=NR;i++) print lines[i]; exit 1 }
for (i = 1; i <= NR; i++) {
print lines[i]
if (i == last_import) print new_import
}
}
' "$LAUNCHER" > /tmp/_launcher_tmp; then
mv /tmp/_launcher_tmp "$LAUNCHER"
ok "Import añadido en $LAUNCHER"
else
warn "No se pudo insertar el import automáticamente — añádelo manualmente:"
echo -e " ${GRN}${IMPORT_LINE}${RST}"
fi
# Insertar entry en rulesRegistry antes del cierre }
if awk -v new_entry="$REGISTRY_LINE" '
/^var rulesRegistry/ { in_reg = 1 }
in_reg && /^\}/ { print new_entry; in_reg = 0 }
{ print }
' "$LAUNCHER" > /tmp/_launcher_tmp; then
mv /tmp/_launcher_tmp "$LAUNCHER"
ok "Registry entry añadida en $LAUNCHER"
else
warn "No se pudo insertar el registry entry — añádelo manualmente:"
echo -e " ${GRN}${REGISTRY_LINE}${RST}"
fi
fi
echo ""
echo -e " ${BLU}1.${RST} Añade una línea en ${BLU}cmd/launcher/main.go${RST}:"
echo -e "${YLW}Queda 1 paso:${RST} registrar el bot en Matrix y añadir su token a .env:"
echo ""
echo -e ' import ('
echo -e " ${GRN}${PACKAGE}agent \"github.com/enmanuel/agents/agents/$ID\"${RST}"
echo -e ' )'
echo ""
echo -e ' var rulesRegistry = map[string]func() []decision.Rule{'
echo -e " ${GRN}\"$ID\": ${PACKAGE}agent.Rules,${RST}"
echo -e ' ...'
echo -e ' }'
echo ""
echo -e " ${BLU}2.${RST} Registra el bot en Matrix y añade el token a .env:"
echo ""
echo -e " ${DIM}./dev-scripts/register.sh $ID \"$DISPLAYNAME\"${RST}"
echo -e " ${DIM}./dev-scripts/register.sh $ID \"$DISPLAYNAME\"${RST}"
echo ""