I wonder if that script targets an older version of TaskPaper, before the introduction of its JavaScript interface ?
It seems to be looking for a class which is not defined in the AppleScript scripting dictionary of TaskPaper 3.
The methods of documents which I see here are:
Have you looked at TaskPaper 3 scripts here ?

