Skip to content

Sandbox

Execute JavaScript, Python, or shell commands in isolated environments.

3 modules

ModuleDescription
Execute JavaScriptExecute JavaScript code via Node.js with timeout
Execute PythonExecute Python code in a subprocess with timeout
Execute ShellExecute a shell command with timeout and environment control

Modules

Execute JavaScript

sandbox.execute_js

Execute JavaScript code via Node.js with timeout

Parameters:

NameTypeRequiredDefaultDescription
codestringYes-JavaScript code to execute via Node.js
timeoutnumberNo10Execution timeout in seconds

Output:

FieldTypeDescription
stdoutstringStandard output from the script
stderrstringStandard error from the script
exit_codenumberProcess exit code (0 = success)
execution_time_msnumberExecution time in milliseconds

Example: Simple console.log

yaml
code: console.log("Hello, World!");
timeout: 10

Example: JSON processing

yaml
code: const data = { name: "test", value: 42 };
console.log(JSON.stringify(data, null, 2));

Execute Python

sandbox.execute_python

Execute Python code in a subprocess with timeout

Parameters:

NameTypeRequiredDefaultDescription
codestringYes-Python code to execute
timeoutnumberNo10Execution timeout in seconds
allowed_modulesarrayNo-Whitelist of importable modules (leave empty to allow all)

Output:

FieldTypeDescription
stdoutstringStandard output from the script
stderrstringStandard error from the script
exit_codenumberProcess exit code (0 = success)
execution_time_msnumberExecution time in milliseconds

Example: Simple print

yaml
code: print("Hello, World!")
timeout: 10

Example: Math calculation

yaml
code: import math
print(math.pi)
allowed_modules: ["math"]

Execute Shell

sandbox.execute_shell

Execute a shell command with timeout and environment control

Parameters:

NameTypeRequiredDefaultDescription
commandstringYes-Shell command to execute
timeoutnumberNo10Execution timeout in seconds
working_dirstringNo-Working directory for the command
envobjectNo-Additional environment variables to set (merged with current env)

Output:

FieldTypeDescription
stdoutstringStandard output from the command
stderrstringStandard error from the command
exit_codenumberProcess exit code (0 = success)
execution_time_msnumberExecution time in milliseconds

Example: Simple echo

yaml
command: echo "Hello, World!"
timeout: 10

Example: List files with custom working directory

yaml
command: ls -la
working_dir: /tmp

Released under the Apache 2.0 License.