Not sure about detecting the capabilities of the user-agent, but Aptana did a quite interesting server-side Javascript implementation:
Interestingly enough, server-side Javascript is actually quite old. I remember one of the very first web apps I worked with was in SSJS (aka Server-Side JavaScript), on the Netscape Enterprise Server.