| Computer | R Documentation |
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
edit_file()Edit a file by replacing an exact text pattern.
Computer$edit_file(path, pattern, replacement, all = FALSE, encoding = "UTF-8")
pathFile path (relative to working_dir or absolute)
patternExact text to replace
replacementReplacement text
allWhether to replace all occurrences. Default FALSE.
encodingFile encoding (default: "UTF-8")
Success status
execute_r_code()Execute R code in an isolated callr process
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, and execution_mode.
execution_mode is always "sandbox_exec" for this computer-layer path,
which does not persist values into a live ChatSession$get_envir().
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.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.