Ukraine and Russia have agreed to a ceasefire deal involving the Black Sea and strikes on energy infrastructure.