There are some common algorithms for sleep/wake classification from accelerometer input, but sleep stages algorithms are all proprietary as far as I know.
Not true, anyone could take them to a sleep lab and compare to Polysomnograph-based sleep scoring. I'd love to see a large, independent study on this for a couple of the leading trackers.