SandboxProtocol
Defined in the protocols module.Protocol for sandbox implementations. Sandboxes provide isolated environments for safe code execution. Implementations can use Docker, subprocess isolation, or other containerization technologies. Example usage (implementation in praisonai wrapper): from praisonai.sandbox import DockerSandbox sandbox = DockerSandbox(image=“python:3.11-slim”) result = await sandbox.execute(“print(‘Hello, World!’)”) print(result.stdout)
Methods
is_available()
Whether the sandbox backend is available.
sandbox_type()
Type of sandbox (docker, subprocess, etc.).
start()
Start/initialize the sandbox environment.
stop()
Stop/cleanup the sandbox environment.
execute()
Execute code in the sandbox.
execute_file()
Execute a file in the sandbox.
run_command()
Run a shell command in the sandbox.
write_file()
Write a file to the sandbox.
read_file()
Read a file from the sandbox.
list_files()
List files in a sandbox directory.
get_status()
Get sandbox status information.
cleanup()
Clean up sandbox resources (files, processes, etc.).
reset()
Reset sandbox to initial state.

