Code
Type ID: core.code · Kind: Action · Trace: CHAIN
Runs user-supplied code whose default export is a function. The function receives an args object and its return value becomes the node output. Currently only the JavaScript runtime is wired up.
Credentials
None
Properties
| Property | Key | Type | Required | Default | Possible values | Shown when |
|---|---|---|---|---|---|---|
| Code | code | string | Yes | export default async function main(args) { return { hello: "world", args }; } | Source with a default-export function | Always |
| Code Type | codeType | options | No | js | js — javascript; py — python | Always |
| Custom Parameters | codeParams | object | No | {} | Key/value object, accessed via args.{paramValue} in the code | Always |
| Global Parameters | globalParams | object | No | {} | Key/value object, injected as globals and accessed via {paramValue} directly | Always |
Notes
- Runtime/language: although
codeTypeoffersjsandpy, the node always resolves thejsruntime (// for now default is js); Python is not executed. - Execution happens in a Node.js
worker_thread(js-runner). User code runs inside avmcontext with a 5000 ms script-compile timeout. The optional execute-leveltimeoutMsis currently commented out in the node, so no outer kill-timer is applied. - Bindings available to user code:
module,exports,require, a capturedconsole(log/error/warn are recorded and echoed with a[user]prefix), and every key ofglobalParamsspread into the sandbox as a global.argsis passed as the function's first argument and is populated fromcodeParams. requireis reachable, and the runner declares anALLOWED_MODULESset ofaxiosandcrypto(note: this set is declared but not enforced in the current code).- The code is transformed by replacing the first
export defaultwithmodule.exports =, then wrapped as(function (exports, require, module) { ... }). The default export (ormodule.exports) is taken; if it is a function it is called withargsand awaited if it returns a thenable, otherwise the value itself is used as the result. - Output shaping: if the user result is a plain object containing a
jsonand/orbinarykey, the node emits{ __kind: 'json', json: <result.json|{}> , binary?: <normalized binary> }. Binary entries are validated to require base64dataandmimeType(missing either throws);fileSizedefaults to the decoded byte length. Otherwise the entire result object ({ result, logs }) is emitted underjson. - Errors thrown by user code propagate as an
Errorcarrying the originalmessage,stack, and capturedlogs; a non-zero worker exit code rejects withUser code worker exited with code <n>.