Labor has struck an 11th-hour deal with the Greens to pass a tranche of laws amid a dramatic last sitting day in Canberra.