Molecular circuits for activity-guided optogenetics