Functions
Versioned JavaScript and Starlark functions with live validation
When a flow node is not enough, PNeX exposes a functions registry: per-organization user functions in JavaScript (QuickJS sandbox) or Starlark, with append-only versioning and live validation. It lives under Automation › Functions.
Lifecycle
- Create a function and pick its language.
- Edit with live validation — the platform spawns the real runtime binary to check syntax and run a test payload before you save.
- Version: every save appends a version; deployed flows pin an exact version, inlined at deploy time.
- Test run executes the code in the editor (no save needed) with input values or an incoming message, and shows the console, the duration and the output of each port.
A function used by a deployed flow cannot be deleted.


Inputs and outputs: @input / @output directives
A function's signature lives in its code, as comments versioned with it (// or #
prefix in both languages):
// @input temperature number "Measured temperature"
// @input mode string="auto"
// @output heating number
function handle(inputs, msg) {
return { heating: inputs.temperature < 19 ? 1 : 0 };
}The editor's Inputs / Outputs panel reads and rewrites these directives (Add
an input, Add an output, name, type, default). The code defines
handle(inputs, msg) (def handle(inputs, msg): in Starlark).
In a flow, the Function node shows one input anchor per @input (one wire per
input) and one output port per @output:
- Per-wire routing: a bare payload wired to the
temperatureanchor arrives ininputs.temperature— deploying tags each wire with the input name (msg.topic). A JSON Split can therefore feed the anchors directly (topic = key). Without a dedicated wire, the input is read frompayload.<name>, then falls back to its default. - Return: an object whose keys are the
@outputnames emits each key on its port (missing key ornull= muted port). Without@output, the returned value replaces the payload on port 0;nulldrops the message.
Sandboxing
JavaScript runs in a QuickJS sandbox with an interrupt handler as the single reliable bound on runaway code. Starlark offers a deterministic, Python-flavoured alternative. Functions have no access to the organization's secrets. The function replaces the incoming message payload with its return value — it does not merge into it. A new version does not change deployed flows: select it in the node, then redeploy.

AI-assisted authoring
The integrated AI assistant can draft, validate, test and fix functions on request (see AI Assistant), and the editor offers quick-fixes for common validation errors.



