For aircraft to aircraft there’s a automatic advisory which coordinates this between aircraft.
https://www.skybrary.aero/index.php/Airborne_Collision_Avoid...
I’ve heard some Airbus have it tied into their auto pilot too.
When all else fails, the rule is “turn right”.