This is a bit of cross post from Excellent presentation of Kai at jPrime conference: Recording somewhere? because that has the best example I have found to start with these types of scripts.
It would be good to have some basic API/debug starting points to get us started on using this more effectively.