BaseSandbox¶
BaseSandbox
¶
Bases: SandboxBackendProtocol, ABC
Base sandbox implementation with execute() as abstract method.
This class provides default implementations for all protocol methods using shell commands. Subclasses only need to implement execute().
| METHOD | DESCRIPTION |
|---|---|
execute |
Execute a command in the sandbox and return ExecuteResponse. |
ls_info |
Structured listing with file metadata using os.scandir. |
read |
Read file content with line numbers using a single shell command. |
write |
Create a new file. Returns WriteResult; error populated on failure. |
edit |
Edit a file by replacing string occurrences. Returns EditResult. |
grep_raw |
Structured search results or error string for invalid input. |
glob_info |
Structured glob matching returning FileInfo dicts. |
upload_files |
Upload multiple files to the sandbox. |
download_files |
Download multiple files from the sandbox. |
als_info |
Async version of ls_info. |
aread |
Async version of read. |
agrep_raw |
Async version of grep_raw. |
aglob_info |
Async version of glob_info. |
awrite |
Async version of write. |
aedit |
Async version of edit. |
aupload_files |
Async version of upload_files. |
adownload_files |
Async version of download_files. |
aexecute |
Async version of execute. |
execute
abstractmethod
¶
execute(command: str) -> ExecuteResponse
Execute a command in the sandbox and return ExecuteResponse.
| PARAMETER | DESCRIPTION |
|---|---|
command
|
Full shell command string to execute.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ExecuteResponse
|
ExecuteResponse with combined output, exit code, optional signal, and truncation flag. |
ls_info
¶
Structured listing with file metadata using os.scandir.
read
¶
Read file content with line numbers using a single shell command.
write
¶
Create a new file. Returns WriteResult; error populated on failure.
edit
¶
Edit a file by replacing string occurrences. Returns EditResult.
grep_raw
¶
Structured search results or error string for invalid input.
glob_info
¶
Structured glob matching returning FileInfo dicts.
upload_files
abstractmethod
¶
Upload multiple files to the sandbox.
Implementations must support partial success - catch exceptions per-file and return errors in FileUploadResponse objects rather than raising.
download_files
abstractmethod
¶
Download multiple files from the sandbox.
Implementations must support partial success - catch exceptions per-file and return errors in FileDownloadResponse objects rather than raising.
aread
async
¶
Async version of read.
agrep_raw
async
¶
agrep_raw(
pattern: str, path: str | None = None, glob: str | None = None
) -> list[GrepMatch] | str
Async version of grep_raw.
aglob_info
async
¶
Async version of glob_info.
aedit
async
¶
Async version of edit.
aupload_files
async
¶
Async version of upload_files.
adownload_files
async
¶
Async version of download_files.