Code Execution Nodes

Applies to: ChengOS v0.2.0+ | Last verified: 2026-09-25 | Source: crates/cheng-nodes/src/nodes/builtin/tools, crates/cheng-runtime/src

Script execution, sandboxed. tools/code_shell is available by default; tools/code_python and tools/code_js are gated by the CHENG_ENABLE_CODE_PYTHON and CHENG_ENABLE_CODE_JS environment variables and simply do not register when those are unset. Anything the script needs from outside the sandbox goes through the read-path request field, and each requested path needs human approval for that execution. tools/runtime is not a script node: it expands a configured tool bundle for an agent and executes one call from it.

Shell Executor — tools/code_shell

Run shell scripts in a bubblewrap sandbox (OS-namespace isolation: PID/IPC/UTS/network). FAIL-CLOSED: errors if bubblewrap is unavailable — no silent downgrade. Use for: curl, wget, system commands, file operations, pipeline processing, any external process. Do NOT use for pure computation (→ JS) or data transformation (→ Python). Requires allow_network=true for outbound HTTP. Example: {"script":"curl -s 'wttr.in/Tokyo?format=3'","allow_network":true}

Inputs

FieldTypeRequiredDefaultDescription
inputany—nullInput data (any JSON), accessible via $INPUT environment variable in script
scriptstring—null[Required] Shell script. Example: curl -s 'wttr.in/Tokyo?format=3'. Control: code-editor
working_subdirstring—nullRelative working subdirectory inside the execution boundary (e.g. project-alpha). Selects the process cwd only; cannot widen filesystem access.
allow_filesystemboolean—falseWhether to allow script to write files to workspace. Control: switch
allow_full_disk_readonlyboolean—falseWhether to allow read-only access to entire disk (for disk-wide search/file finding). Writing still requires allow_filesystem. Control: switch
request_read_pathsarray<string>—[]Absolute host paths to request READ-ONLY access to, outside the sandbox (e.g. /home/me/project). Each one needs human approval for this execution; approved paths are mounted read-only. Use only when the script must read files the sandbox cannot see.
allow_networkboolean—falseWhether to allow network access (curl, HTTP requests etc. need to be true). Control: switch
timeout_msinteger—5000Timeout in milliseconds. Default 5000ms, max 300000ms. Control: number
memory_mbinteger—128Memory limit in MB. Enforced via prlimit under Bubblewrap. Default 128MB. Control: number
disable_sandboxboolean—falseRequest to run on the host WITHOUT any sandbox: full filesystem, network and command access as the ChengFlow system account. Requires human approval for this execution. Use only for host troubleshooting. Control: switch

Outputs

FieldTypeDescription
resultanyResult returned by the script
isolation_levelstringActual isolation level used by the runtime: bubblewrap, quickjs, python, shell, or container
metricsobjectRuntime execution metrics
stdoutstringStandard output stream
stderrstringStandard error stream
warningsarray<string>Validation warnings generated before execution

Python Executor — tools/code_python

Run Python 3 scripts in a bubblewrap sandbox (OS-namespace isolation shared with the Shell node). FAIL-CLOSED: errors if the secure launcher or python3 is unavailable — never downgrades to native host execution. Use for algorithms, text processing, data transformation, and scientific computing. Do not use it for network requests (use Shell) or simple JSON/string transformations (use JavaScript). Network access is disabled by design. The JSON input is available as the input variable.

Inputs

FieldTypeRequiredDefaultDescription
inputany—nullJSON input exposed to the script as input
scriptstring—null[Required] Python 3 script. Example: result = sum(input['values']). Control: code-editor
working_subdirstring—nullRelative working subdirectory inside the execution boundary (e.g. project-alpha). Selects the process cwd only; cannot widen filesystem access.
allow_filesystemboolean—falseWhether to allow the script to write files to the workspace. Control: switch
allow_full_disk_readonlyboolean—falseWhether to allow read-only access to the entire disk for disk-wide search and file finding. Control: switch
request_read_pathsarray<string>—[]Absolute host paths to request READ-ONLY access to, outside the sandbox (e.g. /home/me/project). Each one needs human approval for this execution; approved paths are mounted read-only. Use only when the script must read files the sandbox cannot see.
timeout_msinteger—5000Timeout in milliseconds. Default: 5000 ms. Maximum: 300000 ms. Control: number
memory_mbinteger—128Memory limit in MB. Hard-enforced via cgroup v2 when available, prlimit fallback otherwise. Default: 128 MB. Control: number

Outputs

FieldTypeDescription
resultanyResult returned by the script
isolation_levelstringActual isolation level used by the runtime: bubblewrap, quickjs, python, shell, or container
metricsobjectRuntime execution metrics
stdoutstringStandard output stream
stderrstringStandard error stream
warningsarray<string>Validation warnings generated before execution

JavaScript Executor — tools/code_js

Run JavaScript in a QuickJS sandbox with no syscalls, network, or filesystem access. Fail closed if QuickJS is unavailable. Use this node for pure computation, JSON/object transformation, string manipulation, and math. Do not use it for network requests (use Shell) or library-heavy data processing (use Python).

Inputs

FieldTypeRequiredDefaultDescription
inputany—nullJSON input exposed to the script as input
scriptstring—null[Required] JavaScript script. The value of the final expression is returned as result. Control: code-editor
timeout_msinteger—5000Timeout in milliseconds. Default: 5000 ms. Maximum: 300000 ms. Control: number
memory_mbinteger—128Memory limit in MB. QuickJS enforces this as an internal soft limit. Default: 128 MB. Control: number

Outputs

FieldTypeDescription
resultanyResult returned by the script
isolation_levelstringActual isolation level used by the runtime: bubblewrap, quickjs, python, shell, or container
metricsobjectRuntime execution metrics
stdoutstringStandard output stream
stderrstringStandard error stream
warningsarray<string>Validation warnings generated before execution

Tool Runtime — tools/runtime

A configurable tool bundle: connect once to an LLM/Agent and expose a curated, policy-bounded set of tools.

Inputs

FieldTypeRequiredDefaultDescription
actionenum—list_toolslist_tools | execute | validate_config. Options: list_tools (Expand the bundle into LLM function definitions.), execute (Execute a single tool call through the runtime.), validate_config (Statically validate the configured bundle.)
tool_callobject——Tool call for action=execute
exposed_toolsarray<object>—[]Curated tool bundle
dry_runboolean—falseValidate without dispatching

Outputs

FieldTypeDescription
statusstringRuntime action status
functionsarray<any>Expanded LLM functions
resultanyTool execution result
errorsarray<string>Configuration errors
warningsarray<string>Configuration warnings

Next steps