Photoshop must be installed and open. By default, the Photoshop file that will be updated is the one that is open and focused on. This script requires Extend Script, which is accessible in VSCode through the vscode-to-Photoshop extension.
https://marketplace.visualstudio.com/items?itemName=bialikover.vscode-to-photoshop
The variables that you must customize are the identity of the Smart Object layer and location of your image to insert into the Smart Object layer. Looking at your Photoshop Layers pane, the index starts from the top of the stack (0 is at the top).
This script comes from many discussions on the Adobe forum, and a special thanks to JJMack for lending his time and expertise.