Please have a look at Retrieving decision instance id.
As you mentioned, you could have a literal expression to collect the results. The easiest would be to just reference the decision results. For example:
{
minMaxImpairment: minMaxImpairment,
maxMaxImpairment: maxMaxImpairment,
...
}
Providing a generic script is a bit complicated because you don’t have access to the current decision and tree.
I think it would be more convenient to handle this in the backend and provide a just REST API.
And also, feel free to create a pull request: https://app.camunda.com/jira/browse/CAM
Best regards,
Philipp