Can I make scripts I run in Kibana tools into Kibana objects

The "add a filter" dialog only supports filters/queries, not other parts of an Elasticsearch _search request (such as aggs, size, etc.).

The only way to turn a generic query into an "object" is to use a "custom visualization" (e.g. Vega):