I don't know if I have a great answer to this yet. I will say that:
print() is your friend!
Since print() writes to the Notes Log it's almost like debugging a server/web agent.
TaskJam has something in it to hook into OpenLog. I've not tried that yet but that might be something to check out.
I've not heard of anything that will allow stepping through the code....