Skip to content

Sandbox

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

3 modules

ModuleDescription
JavaScript 実行Node.jsでタイムアウト付きのJavaScriptコードを実行
Python 実行サブプロセスでタイムアウト付きのPythonコードを実行
シェル実行タイムアウトと環境制御付きでシェルコマンドを実行

Modules

JavaScript 実行

sandbox.execute_js

Node.jsでタイムアウト付きのJavaScriptコードを実行

Parameters:

NameTypeRequiredDefaultDescription
codestringYes-Node.jsで実行するJavaScriptコード
timeoutnumberNo10実行タイムアウト(秒)

Output:

FieldTypeDescription
stdoutstringスクリプトの標準出力
stderrstringスクリプトの標準エラー
exit_codenumberプロセスの終了コード(0 = 成功)
execution_time_msnumber実行時間(ミリ秒)

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));

Python 実行

sandbox.execute_python

サブプロセスでタイムアウト付きのPythonコードを実行

Parameters:

NameTypeRequiredDefaultDescription
codestringYes-実行するPythonコード
timeoutnumberNo10実行タイムアウト(秒)
allowed_modulesarrayNo-インポート可能なモジュールのホワイトリスト(すべて許可する場合は空のまま)

Output:

FieldTypeDescription
stdoutstringスクリプトの標準出力
stderrstringスクリプトの標準エラー
exit_codenumberプロセスの終了コード(0 = 成功)
execution_time_msnumber実行時間(ミリ秒)

Example: Simple print

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

Example: Math calculation

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

シェル実行

sandbox.execute_shell

タイムアウトと環境制御付きでシェルコマンドを実行

Parameters:

NameTypeRequiredDefaultDescription
commandstringYes-実行するシェルコマンド
timeoutnumberNo10実行タイムアウト(秒)
working_dirstringNo-コマンドの作業ディレクトリ
envobjectNo-設定する追加の環境変数(現在の環境とマージ)

Output:

FieldTypeDescription
stdoutstringコマンドの標準出力
stderrstringコマンドの標準エラー
exit_codenumberプロセスの終了コード(0 = 成功)
execution_time_msnumber実行時間(ミリ秒)

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.