SandboxFs
Filesystem handle for a running sandbox. Obtained via thesandbox.fs property. All operations go through the same host-guest channel as command execution - no SSH, no network involved. For bulk file operations, consider using volumes instead.
copy()
| Name | Type | Description |
|---|---|---|
| src | str | Source path |
| dst | str | Destination path |
copy_from_host()
| Name | Type | Description |
|---|---|---|
| host_path | str | Path on the host filesystem |
| guest_path | str | Destination path inside the sandbox |
copy_to_host()
| Name | Type | Description |
|---|---|---|
| guest_path | str | Path inside the sandbox |
| host_path | str | Destination path on the host |
exists()
| Name | Type | Description |
|---|---|---|
| path | str | Absolute path inside the guest |
| Type | Description |
|---|---|
bool | True if the path exists |
list()
| Name | Type | Description |
|---|---|---|
| path | str | Absolute directory path inside the guest |
| Type | Description |
|---|---|
list[FsEntry] | Directory entries |
mkdir()
| Name | Type | Description |
|---|---|---|
| path | str | Absolute directory path |
read()
| Name | Type | Description |
|---|---|---|
| path | str | Absolute path inside the guest (e.g. "/app/config.json") |
| Type | Description |
|---|---|
bytes | File contents as raw bytes |
read_stream()
| Name | Type | Description |
|---|---|---|
| path | str | Absolute path inside the guest |
| Type | Description |
|---|---|
FsReadStream | Async iterator that yields chunks of file data |
read_text()
| Name | Type | Description |
|---|---|---|
| path | str | Absolute path inside the guest |
| Type | Description |
|---|---|
str | File contents as a string |
remove()
| Name | Type | Description |
|---|---|---|
| path | str | Absolute file path |
remove_dir()
| Name | Type | Description |
|---|---|---|
| path | str | Absolute directory path |
rename()
| Name | Type | Description |
|---|---|---|
| src | str | Current path |
| dst | str | New path |
stat()
| Name | Type | Description |
|---|---|---|
| path | str | Absolute path inside the guest |
| Type | Description |
|---|---|
FsMetadata | File metadata |
write()
| Name | Type | Description |
|---|---|---|
| path | str | Absolute path inside the guest |
| data | bytes | File content |
write_stream()
| Name | Type | Description |
|---|---|---|
| path | str | Absolute path inside the guest |
| Type | Description |
|---|---|
FsWriteSink | Async writer that accepts chunks of data |
Types
FsEntry
Metadata for a single directory entry, returned bylist().
| Property | Type | Description |
|---|---|---|
| kind | str | Type of entry ("file", "directory", "symlink", "other") |
| mode | int | Unix permission bits |
| modified | float | None | Last modified timestamp (ms since epoch) |
| path | str | File path |
| size | int | File size in bytes |
FsEntryKind
String enum (StrEnum) representing the type of a filesystem entry.
| Value | Description |
|---|---|
"directory" | Directory |
"file" | Regular file |
"other" | Other entry type |
"symlink" | Symbolic link |
FsMetadata
Detailed file metadata, returned bystat().
| Property | Type | Description |
|---|---|---|
| created | float | None | Creation timestamp (ms since epoch) |
| kind | str | Type of entry ("file", "directory", "symlink", "other") |
| mode | int | Unix permission bits |
| modified | float | None | Last modified timestamp (ms since epoch) |
| readonly | bool | Whether the file is read-only |
| size | int | File size in bytes |
FsReadStream
Async stream for reading a file in chunks. Obtained viaread_stream().
| Method / Protocol | Returns | Description |
|---|---|---|
__aiter__ / __anext__ | bytes | Async iterator - use with async for chunk in stream: |
collect() | bytes | Collect all remaining data into a single bytes object |
FsWriteSink
Async writer for streaming data into a file. Obtained viawrite_stream(). Supports the async context manager protocol (async with).
| Method / Protocol | Returns | Description |
|---|---|---|
write(data) | None | Write a chunk of bytes to the file |
close() | None | Send EOF and finalize the file |
__aenter__ / __aexit__ | FsWriteSink | Use with async with for automatic close on exit |