In your original question on Stack Overflow you never mentioned that two SOs are nested. In this case I suggest to open a SO as a document with
function editSmartObject()
{
var desc = new ActionDescriptor();
executeAction(sTID('placedLayerEditContents'), desc, DialogModes.NO);
}
If you're using only this particular file as an input your algorithm should be something like this I imagine in pseudocode:
var originaldocument = activeDocument,
files = File.openDialog(...);
for file in files
activeDocument = originaldocument; //selecting the original document
editSmartObject() //opening SO for editing
editSmartObject() //opening the second SO for editing
// optionally remove a layer from previous iteration: activeDocument.activeLayer.remove()
placeImage(file) //placing image to SO
activeDocument.activeLayer.resize() //resize the placed layer if you need to
activeDocument.close(SaveOptions.SAVECHANGES) //closing the second SO and saving changes
activeDocument.close(SaveOptions.SAVECHANGES) //closing the first SO and saving changes
saveJPG(); //save jpg with all the SO updated
function placeImage(imageFile)
{
alert(imageFile);
var desc554 = new ActionDescriptor();
desc554.putPath(cTID('null'), imageFile);
desc554.putEnumerated(cTID('FTcs'), cTID('QCSt'), cTID('Qcsa'));
var desc555 = new ActionDescriptor();
desc555.putUnitDouble(cTID('Hrzn'), cTID('#Pxl'), 0.000000);
desc555.putUnitDouble(cTID('Vrtc'), cTID('#Pxl'), 0.000000);
desc554.putObject(cTID('Ofst'), cTID('Ofst'), desc555);
executeAction(cTID('Plc '), desc554, DialogModes.NO);
};
function editSmartObject()
{
var desc = new ActionDescriptor();
executeAction(sTID('placedLayerEditContents'), desc, DialogModes.NO);
}