We've got to use actions or menu commands.
The pathfinder operations are recordable, but you can also use the menu commands on paths which you have to first ensure are in a group. Then apply a pathfinder EFFECT from the menu commands and follow up with "Expand Style" menu command to destructively fix the changes in place.

Thanks to Ten A and his new intuitively-compiled catalogue of execute menu command strings, this block is our dictionary for pathfinder commands to be used with the app.executeMenuCommand() function.
Beware though, as I have discovered some inconsistencies with expectation/reality when it comes to using the menu commands as alternatives to comparable scripting methods or actions. They are not easy to describe, but once you come across a few examples you can generally get the idea.
For example, having a placed item selected and going "Edit Original" can open the file but waits to do so after the script has been ran - while the app.open command does it in sync.
In the context of your usage though, I believe it has been proven to work just fine on these forums for years now.
This is [ANN] Adding AiMenu class. from Ten A
| "pathfinder" : { |
| "add" : "Live Pathfinder Add", |
| "intersect" : "Live Pathfinder Intersect", |
| "exclude" : "Live Pathfinder Exclude", |
| "subtract" : "Live Pathfinder Subtract", |
| "minusBack" : "Live Pathfinder Minus Back", |
| "divide" : "Live Pathfinder Divide", |
| "trim" : "Live Pathfinder Trim", |
| "merge" : "Live Pathfinder Merge", |
| "crop" : "Live Pathfinder Crop", |
| "outline" : "Live Pathfinder Outline", |
| "hardMix" : "Live Pathfinder Hard Mix", |
| "softMix" : "Live Pathfinder Soft Mix", |
| "trap" : "Live Pathfinder Trap" |
| }, |