Error "Missing field: commands" when running trigger

I’m somewhat guessing here but I believe that cmds is probably empty. The ledger API does not accept empty list of commands. If that is the issue you can simply wrap it in when:

when (not (null cmds)) (emitCommands cmds pendings)

Might make sense to modify emitCommands to handle this automatically.