Runtimes, eval, and Dynamic Scripts
Fire can evaluate JavaScript/TypeScript (node or deno) and Python snippets directly from your YAML config. Define runtimes once, then reference them from eval expressions and compute entries.
Defining runtimes
runtimes:
ts:
sdk: deno
runner: deno
check: deno --version
fallback_runner:
image: denoland/deno:latest
paths:
- scripts/*.ts
- scripts/helpers/*.ts
js:
sdk: node
paths:
- scripts/*.mjs
py:
sdk: python
runner: python3.13
paths:
- scripts/*.py
Fields:
sdk: one ofnode,deno,python.runner: the sdk’s executable, or a command that ends in it (default:node,denoorpython). See Runtime runners.check: optional probe; if it fails,fallback_runneris used.fallback_runner: alternative runner (often a container) whencheckfails. Same rule asrunner.runnerandfallback_runneralso take a container object.paths: glob patterns to pre-load modules/functions into the runtime session.- Absolute paths are supported.
- Relative paths are resolved from the directory of the YAML file that defines that runtime.
- This only affects runtime file loading; runtime execution directory still follows normal command
dirresolution.
Runtime runners
A runtime runner is the sdk’s executable, or a command that ends in it. Fire appends the sdk’s own arguments to start its bootstrap (eval '<bootstrap>' for deno, -e '<bootstrap>' for node, -u -c '<bootstrap>' for python) and never rewrites the string. {fire.exec} only works in command runners. stdin stays with your code.
runner: deno
runner: uv run python
runner: docker run --rm -i denoland/deno:latest # the image's entrypoint is deno
runner: docker run --rm -i my-image deno # otherwise, name it at the end
The runner and its check are launched through the command’s shell.
The bootstrap connects back to Fire over TCP, using FIRE_RUNTIME_RPC_ADDR (127.0.0.1:<port>). Fire also exports FIRE_RUNTIME_RPC_PORT. A container doesn’t inherit the host environment, and 127.0.0.1 inside it is the container, so pass the address yourself. On Docker Desktop, host.docker.internal reaches the host:
fallback_runner: docker run --rm -i -v "$PWD:$PWD" -e FIRE_RUNTIME_RPC_ADDR=host.docker.internal:$FIRE_RUNTIME_RPC_PORT denoland/deno:latest
With native Docker on Linux (no Docker Desktop), host.docker.internal points at the bridge, where Fire’s loopback listener isn’t reachable. Share the host network instead, so 127.0.0.1 inside the container is the host:
fallback_runner: docker run --rm -i --network host -v "$PWD:$PWD" -e FIRE_RUNTIME_RPC_ADDR=127.0.0.1:$FIRE_RUNTIME_RPC_PORT denoland/deno:latest
Files in paths are loaded by their absolute path on the host, so mount their directory at the same path (-v "$PWD:$PWD" when the config is in the current directory). If the runtime can’t connect, it prints why (Missing FIRE_RUNTIME_RPC_ADDR, Cannot connect to fire at …).
Container object
The container object builds that string for you:
runtimes:
ts:
sdk: deno
fallback_runner:
image: denoland/deno:latest
generates
docker run --rm -i -v /project:/project -w /project --add-host=host.docker.internal:host-gateway -e FIRE_RUNTIME_RPC_ADDR=host.docker.internal:$FIRE_RUNTIME_RPC_PORT denoland/deno:latest deno
commanddefaults to the sdk’s executable (deno,node,python); a custom one must end in it.- The project directory and the directories of
pathsoutside it are mounted at the same absolute path, sopathsload unchanged. Explicitvolumesreplace these mounts. - How the runtime reaches Fire depends only on the object’s keys, never on your OS, so the same file generates the same string on every machine:
| Keys | Flags | FIRE_RUNTIME_RPC_ADDR |
|---|---|---|
network_mode: host | --network host | 127.0.0.1:$FIRE_RUNTIME_RPC_PORT |
default, engine: docker | --add-host=host.docker.internal:host-gateway | host.docker.internal:$FIRE_RUNTIME_RPC_PORT |
default, engine: podman | host.containers.internal:$FIRE_RUNTIME_RPC_PORT |
The default works with Docker Desktop and podman machine. With native Docker on Linux, add network_mode: host.
eval expressions
Syntax: <runtimeKey>:<code>
- Runtime key must match
runtimes(e.g.,py,ts,js). - Placeholders inside code are replaced only if the command defines
placeholder; the pattern controls all forms ({1},...{{n}},[{{n}}]). on_unused_argsapplies only here; default isignore.
Examples:
computed:
<<: *arg-config
eval: py:sayHello("{1}", "{2}", ...{{n}})
computed2:
<<: *arg-config
eval: ts:makeHash("{1}", "sha256")
computed3:
<<: *arg-config
eval: js:getCurrentTimestamp()
Library loading and sessions
For each runtime key, Fire starts a session, loads files matching paths, and reuses the same process for multiple eval statements.
Runtime sessions keep stdin/stdout interactive. This means runtime code can prompt/read user input (for example input(), prompt(), readline) while still being reused within the same Fire invocation.
eval return handling:
void/undefined/None: no implicit output.string: printed as command output (same behavior as today).string[](array/list of strings): each item is executed as a shell command, in order.- Those commands run in the same shell session (state carries across items).
- Any other return type: converted to string and printed.
Notes:
- This applies only to the return value of
eval. - Regular
print/console.logoutput from your runtime code is still forwarded as-is.
Compute + eval
compute entries can also use runtime prefixes. These run before command rendering and define reusable literal tokens:
compute:
"{hash}": ts:makeHash("{1}", "sha256")
"{label}": echo "build-{2}"
exec: echo "Hello {1}, hash={hash}, label={label}"
Error handling
- Invalid runtime key → Fire exits with an error.
- Runtime
checkfailure → usesfallback_runnerif configured; otherwise exits. on_unused_args: error→ aborts before running the runtime if extra args weren’t consumed by placeholders.