How to automatically adjust the levels of a grayscale
Sure just grab a Normalise node from the Vector node category.



And you can apply this to colour images by separating out the value component.
In this example I have intentionally underexposed the source using a colour curve node. You can compare the results in the split viewer node.



A useful application would be to smooth out exposure of time-lapse recordings. Where lighting conditions and therefore exposure, change radical during a recording.