Launchd calls my script daily but stalls on keyboard input if woken from sleep but runs ok other times

I have a script app (exported as ScriptDebugger run-only) that I run each morning at 7:15am via launchd. This works fine if the MacBook is not in sleep mode, i.e. I have woken it and am using it, but if it needs to wake itself it stalls when it needs to make keyboard input. I use a call to ‘caffeinate -u’ at the start of the script to tell the computer that the user is active.

I have tried giving a bunch of system permissions to overcome this but nothing has worked, including:
System Settings → Privacy & Security
→ Full Disk Access
→ Automation
→ Input Monitoring
→ Accessibility
→ /System/Library/CoreServices/System Events.app

Does anyone have any suggestions that I have missed?

You can have launchd wake the Mac when it needs to run the script, I believe.
If you can’t, then use pmset to set a recurring wake event 5 seconds before your script runs