You should take a look at this photoshop-dom-event npm module by Antonio. It lets you listen to an event and run a callback function when that event is triggered. He even has a CEP panel example.
https://github.com/antonio-gomez/photoshop-dom-event
• the example above takles the opening of a document but not the creation of a new one;
The event triggered when making a new document is "Mk ". But it is also the same for making new layers. So you'll have to read the contents of the received data to determine if the user made a new document.
• how do I effectively reload/restart the extension?
You can refresh the panel like you would refresh a browser. It's not ideal, since you'll see a flash when reloading, but it's a decent solution.