Polyglot script
Run a script in your language of choice on an agent.
The script runs on an agent with the polyglot capability. The managed environments have one,
with bash, Python, JavaScript and Go.
- Kind:
code - Palette: Activities
- Run it on its own: yes
When to use
Section titled “When to use”- Logic that reads better in a programming language: parsing, calling an SDK, a loop that keeps state.
- A script you already have, dropped into a graph unchanged.
To reshape a value between two steps (rename fields, filter a list, join it into a string), a
transform is lighter: it runs in the engine and needs no agent. A command line
or two is a shell step.
Configuration
Section titled “Configuration”| Field | Type | Required | Description |
|---|---|---|---|
script |
string | yes | The script source to run. |
credentials |
object | no | Named credentials injected as env vars: {ENV_VAR: credential_name}. |
env |
object | no | Extra environment variables, as a JSON object. |
interpreter |
array | no | Interpreter argv, e.g. [“python3”] (default bash). |
optional_when_untrusted |
boolean | no | Run without the credential when the run is untrusted (a fork pull request), instead of failing. The credential is still withheld. |
outputs |
object | no | Rename what comes out: {output_name: key_in_the_raw_output}. Absent passes the raw output through. |
Output
Section titled “Output”An object whose keys depend on the configuration.
Example
Section titled “Example”version: hyperspool-graph/v1nodes: - id: stats type: code config: interpreter: [python3] env: REPO: { $expr: "input.repo" } script: | import json, os, subprocess, urllib.request repo = json.load(urllib.request.urlopen(f"https://api.github.com/repos/{os.environ['REPO']}")) out = {"stars": repo["stargazers_count"], "open_issues": repo["open_issues_count"]} subprocess.run(["spool", "output", "set", "--values", json.dumps(out)], check=True) - id: report type: shell config: run: { $template: "echo {{ nodes.stats.output.stars }} stars" }edges: - { from: stats, to: report }The script sets its output with spool output set, and the next step reads
nodes.stats.output.stars. Without interpreter the script runs in bash, under bash -eu. See
Polyglot scripts for the durable calls a script can make.
See the node reference for every other node.