I believe this'll do it -- this is Go running another Go program, but the target program could be written in any language, so long as you have the right runtime installed. (So for a TypeScript you'd, you'd need Node installed as well.) Hopefully serves as a decent reference -- let me know if you're asking something totally different, though. 🙂
https://github.com/pulumi/automation-api-examples/tree/main/go/local_program