The problem with new Bucket Script Aggregation (6.0.0 - Beta 1) - Help Needed

Hi, I am trying new Bucket Script Aggregation Metric and I am pretty much lost.
I have records in “documents” index.
totalTime (long, can be 1 or 0, misleading name I know …), timestamp

I want to calculate sum(totalTime)/Count * 100 to get the percentage as the calculated value, but I see no way how to declare variables: var1 = sum, var2 = count in Bucket Script Options. There is only script field, but I guess I need to declare variables before the script.

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-bucket-script-aggregation.html#_syntax_12

How is this supposed to work?
I tried in Chrome and Safari, same result.

Please see the screenshot below.

there was a bug fixed in latest master / nightly (and upcoming beta2)

Ok, thanks for the info.