Skip to main content

Crate graphrt_code

Crate graphrt_code 

Source
Expand description

§graphrt-code

The code node: runs user-supplied code over workflow variables.

  • JavaScript runs in an embedded QuickJS engine (feature js, on by default). The engine has no file system, network, timers or module loader; memory, stack and execution time are capped.
  • Other languages (e.g. python3) run in a host-provided RemoteSandbox service. The optional remote feature provides HttpSandbox, a client for an HTTP sandbox service. The optional python feature provides SubprocessPython, which runs a local python3 with resource limits — not a security sandbox, for trusted code only.

User code defines main(args), which receives an object with the configured input variables and returns an object (or a promise of one):

function main({ a, b }) {
  return { sum: a + b };
}

Inputs are passed with secrets revealed: code nodes frequently need API keys from env.*. Returned strings that contain one of those secrets (alone or inside a larger string) become secrets again, so they are masked in events and records; captured stdout is scrubbed the same way. A script can still leak a transformed secret (reversed, encoded), so do not give untrusted code keys.

Structs§

CodeLimits
Resource limits for one code execution.
CodeNode
The code node.
SandboxRun
Result of RemoteSandbox::execute_detailed.

Enums§

SandboxChoice
Where code runs.

Constants§

KIND
Node kind handled by this crate.

Traits§

RemoteSandbox
A sandbox that executes code out of process (for languages without an embedded engine).

Functions§

descriptor
Catalog descriptor of the code node.
register
Register the code node kind.