Safety-Ensured Control Framework for Robotic Endoscopic Task Automation