R6 class providing computer abstraction with atomic tools for file operations, bash execution, and R code execution.
working_dirCurrent working directory
sandbox_modeSandbox mode: "strict", "permissive", or "none"
execution_logLog of executed commands
new()Initialize computer abstraction
Computer$new(working_dir = tempdir(), sandbox_mode = "permissive")working_dirWorking directory. Defaults to tempdir().
sandbox_modeSandbox mode: "strict", "permissive", or "none"
bash()Execute bash command
Computer$bash(command, timeout_ms = 30000, capture_output = TRUE)commandBash command to execute
timeout_msTimeout in milliseconds (default: 30000)
capture_outputWhether to capture output (default: TRUE)
List with stdout, stderr, exit_code
read_file()Read file contents
Computer$read_file(path, encoding = "UTF-8")pathFile path (relative to working_dir or absolute)
encodingFile encoding (default: "UTF-8")
File contents as character string
write_file()Write file contents
Computer$write_file(path, content, encoding = "UTF-8")pathFile path (relative to working_dir or absolute)
contentContent to write
encodingFile encoding (default: "UTF-8")
Success status
execute_r_code()Execute R code
Computer$execute_r_code(code, timeout_ms = 30000, capture_output = TRUE)codeR code to execute
timeout_msTimeout in milliseconds (default: 30000)
capture_outputWhether to capture output (default: TRUE)
List with result, output, error
get_log()Get execution log
Computer$get_log()List of logged executions
clear_log()Clear execution log Check bash command for sandbox violations Log execution Resolve path (relative to working_dir or absolute) Check write path for sandbox violations Check R code for sandbox violations
Computer$clear_log()
clone()The objects of this class are cloneable with this method.
Computer$clone(deep = FALSE)deepWhether to make a deep clone.