Module lua_runtime

Module lua_runtime 

Source
Expand description

Shared Lua 5.4 VM runtime for connectors and tools.

Provides a sandboxed Lua environment with host APIs that both crate::connector_script and crate::tool_script use. The Lua VM runs on a blocking thread (via [tokio::task::spawn_blocking]), so all host functions use synchronous I/O (reqwest::blocking, std::thread::sleep).

ยงHost APIs

ModuleFunctions
httpget, post, put
jsonparse, encode
envget
loginfo, warn, error, debug
fsread, list (sandboxed to script directory)
base64encode, decode
cryptosha256, hmac_sha256
sleepsleep(seconds)

ยงSandboxing

Dangerous Lua standard libraries (os, io, debug, loadfile, dofile) are removed. Filesystem access is restricted to a configurable sandbox root directory.

Functionsยง

do_http_request ๐Ÿ”’
Execute an HTTP request and return a Lua table with the response.
expand_env_vars ๐Ÿ”’
Expand ${VAR_NAME} patterns in a string from the process environment.
json_value_to_lua ๐Ÿ”’
Convert a JSON value to a Lua value.
lua_value_to_json ๐Ÿ”’
Convert a Lua value to a JSON value.
register_all_host_apis ๐Ÿ”’
Register all standard host APIs on a Lua VM instance.
register_base64_api ๐Ÿ”’
register_crypto_api ๐Ÿ”’
register_env_api ๐Ÿ”’
register_fs_api ๐Ÿ”’
register_http_api ๐Ÿ”’
register_json_api ๐Ÿ”’
register_log_api ๐Ÿ”’
register_sleep ๐Ÿ”’
sandbox_globals ๐Ÿ”’
Remove dangerous standard library functions from the Lua globals.
toml_table_to_lua ๐Ÿ”’
Convert a TOML table to a Lua table.
toml_value_to_lua ๐Ÿ”’
Convert a TOML value to a Lua value, expanding ${VAR} in strings.