Define a class that extends org.springframework.extensions.webscripts.processor.BaseProcessorExtension, define a bean with a parent of "baseScriptExtension", and you're done. That bean will be exposed as a javascript object in your webscripts.
Although no longer used, take a look at the class org.alfresco.wcm.client.service.CollectionService in the WQS API and its commented-out bean definition in wcmqs-api-context.xml for an example.