This is my code. It can activate layers. Maybe it can help you.
await ActiveLayer()
async function ActiveLayer() {
let cl = await app.activeDocument.activeLayers[0];
if (cl == undefined) {
let layers = await require("photoshop").app.activeDocument.layers;
await require("photoshop").core.executeAsModal(async () => {
try {
await require("photoshop").action.batchPlay([{
"_obj": "select",
"_target": [{
"_ref": "layer",
"_id": layers[0]._id
}],
"_isCommand": true
}, ], {
"synchronousExecution": false
});
} catch (e) {
console.error(e);
}
}, {
commandName: "Test"
});
}
}