Code actions
When the graph is not enough, the Code box runs a script.
Seven languages are available, all of them run inside an embedded WebAssembly sandbox: no interpreter is required on your machine, and the script has no access to your file system.
| Language | Engine |
|---|---|
| TypeScript | QuickJS (types stripped at compile time) |
| JavaScript | QuickJS |
| Python | Pyodide (CPython compiled to WebAssembly) |
| Lua | Lua 5.4 in WebAssembly |
| Ruby | CRuby in WebAssembly |
| R | WebR |
| C# | .NET in WebAssembly with Roslyn |
The default language is TypeScript.
The common contract
Section titled “The common contract”Whatever the language, the box exposes the same thing:
| Inputs | value (named input), code (string) |
| Outputs | result |
| Configuration | language, code, timeout, packages |
input— the value received on the input port.vars— the run variables.- The language’s standard output (
console.log,print,puts,cat,Console.WriteLine) feeds the execution log. - The value returned leaves on the
resultport. An error or a timeout leaves onerror.
The timeout
Section titled “The timeout”timeout, in seconds: 5 by default, 60 at most. A script that goes over is
interrupted and execution leaves via the error port.
External packages
Section titled “External packages”The packages field accepts a list of { name, version }. The exact versions
serve as the cache key: dependencies are resolved on the first run, cached,
then mounted offline on every subsequent run — CI included.
| Language | Source |
|---|---|
| TypeScript / JavaScript | npm (the whole set is bundled) |
| Python | Pure-Python wheels from PyPI |
| Lua | LuaRocks (pure-Lua sources) |
| Ruby | Pure-Ruby gems |
| R | CRAN, via WebR’s WebAssembly repository |
| C# | None — the .NET standard library only |
When not to write code
Section titled “When not to write code”Many needs are already covered by boxes, which are more readable and faster:
| Need | Box |
|---|---|
| Extract a value from a response | A link selector |
| Format a string | Transform template |
| Filter, sort, aggregate a list | Lists |
| Hash, encode, sign | Encoding |
| Check a structure | Schema validate |
Keep the Code box for logic that really is specific.