S7 class for tool definitions.
Defines a named tool with a function implementation and typed argument
metadata. Tool objects are passed to SecureSession or execute_r() so
that code running in the sandboxed child process can call the tool by name
and the parent process executes the actual function.
Arguments
- name
Character, the tool name (must be non-empty).
- description
Character, description of what the tool does.
- fn
Function that implements the tool.
- args
Named list mapping argument names to type strings (e.g.
list(city = "character")). Used to generate wrapper functions in the child process with the correct formal arguments.
Examples
tool <- securer_tool(
"add", "Add two numbers",
fn = function(a, b) a + b,
args = list(a = "numeric", b = "numeric")
)
tool@name
#> [1] "add"
# "add"