#!/bin/bash
for INST in friend-71967808 friend-065f5488 friend-abc1d454 friend-043bd076 friend-4f864178; do
  echo "--- DELETE $INST ---"
  curl -sS -X DELETE -H "Authorization: Bearer dev-admin-token" \
    "http://127.0.0.1:19088/api/v1/instances/$INST" | head -c 200
  echo
done
sleep 5
echo "=== 剩余实例 ==="
curl -sS -H "Authorization: Bearer dev-admin-token" "http://127.0.0.1:19088/api/v1/instances" | python3 -c "
import sys,json
d=json.load(sys.stdin)
items = d if isinstance(d,list) else d.get('instances') or d.get('items') or []
print('remaining:', [i.get('id') for i in items])
"
echo "=== 清空运幄绑定表 ==="
docker exec postgres_db psql -U knowledge -d yunwoai -c "DELETE FROM user_friend_agents;"
docker exec postgres_db psql -U knowledge -d yunwoai -t -A -c "SELECT COUNT(*) FROM user_friend_agents;" | xargs echo "binding rows left:"
echo "=== 残留容器 ==="
docker ps --format "{{.Names}}" | grep -E "friend-deploy" || echo "(none)"
