A knowledge-based framework for task automation in surgery