Class ProjectAwareOverlay
- All Implemented Interfaces:
AbstractFilesystem,AbstractSandboxFilesystem
Produced exclusively by LocalFilesystemSpec
when projectWritable(true) is set. Other filesystem specs (RemoteFilesystemSpec,
SandboxFilesystemSpec) are not affected.
Every routed path is first normalized to its agent-visible relative form: a workspace-rooted
absolute path (e.g. <workspace>/src/Foo.java) has the workspace root and, when namespace
scoping is configured, the caller's namespace prefix stripped, so the absolute and the relative
spelling of the same path behave identically in every operation. Absolute paths outside the
workspace root pass through unchanged and are never classified as workspace metadata.
Read operations retain standard overlay semantics: check upper (workspace) first, fall back
to lower (project). Shell execute() delegates to the upper layer as before.
-
Constructor Summary
ConstructorsConstructorDescriptionProjectAwareOverlay(AbstractSandboxFilesystem upper, AbstractFilesystem lower, LocalFilesystem projectFs, Path workspaceRoot) Deprecated.ProjectAwareOverlay(AbstractSandboxFilesystem upper, AbstractFilesystem lower, LocalFilesystem projectFs, Path workspaceRoot, NamespaceFactory namespaceFactory) -
Method Summary
Modifier and TypeMethodDescriptionDelete a file or directory (recursive for directories).downloadFiles(io.agentscope.core.agent.RuntimeContext runtimeContext, List<String> paths) Download multiple files.edit(io.agentscope.core.agent.RuntimeContext runtimeContext, String filePath, String oldString, String newString, boolean replaceAll) Perform exact string replacements in an existing file.execute(io.agentscope.core.agent.RuntimeContext runtimeContext, String command, Integer timeoutSeconds) Execute a shell command in the environment backing this filesystem.booleanCheck whether a file or directory exists.Find files matching a glob pattern.grep(io.agentscope.core.agent.RuntimeContext runtimeContext, String pattern, String path, String glob) Search for a literal text pattern in files.id()Unique identifier for this filesystem/sandbox instance.List all files in a directory with metadata.Move (rename) a file or directory fromfromPathtotoPath.read(io.agentscope.core.agent.RuntimeContext runtimeContext, String filePath, int offset, int limit) Read file content with optional line-based pagination.uploadFiles(io.agentscope.core.agent.RuntimeContext runtimeContext, List<Map.Entry<String, byte[]>> files) Upload multiple files.Write content to a new file, error if file already exists.
-
Constructor Details
-
ProjectAwareOverlay
public ProjectAwareOverlay(AbstractSandboxFilesystem upper, AbstractFilesystem lower, LocalFilesystem projectFs, Path workspaceRoot, NamespaceFactory namespaceFactory) - Parameters:
upper- shell-capable workspace filesystem (read-write, workspace root)lower- read-only project filesystem (overlay fallback)projectFs- writable project filesystem for non-workspace writesworkspaceRoot- absolute path of the workspace, used to classify absolute pathsnamespaceFactory- namespace factory scoping the workspace and project filesystems; used to strip the caller's namespace prefix from workspace-rooted absolute paths;nullwhen no namespace scoping is configured
-
ProjectAwareOverlay
@Deprecated public ProjectAwareOverlay(AbstractSandboxFilesystem upper, AbstractFilesystem lower, LocalFilesystem projectFs, Path workspaceRoot) Deprecated.useProjectAwareOverlay(AbstractSandboxFilesystem, AbstractFilesystem, LocalFilesystem, Path, NamespaceFactory)so workspace-rooted absolute paths resolve identically to their relative spelling under namespace scopingNamespace-unaware variant: workspace-rooted absolute paths keep their namespace segment and may misroute under namespace scoping.- Parameters:
upper- shell-capable workspace filesystem (read-write, workspace root)lower- read-only project filesystem (overlay fallback)projectFs- writable project filesystem for non-workspace writesworkspaceRoot- absolute path of the workspace, used to classify absolute paths
-
-
Method Details
-
id
Description copied from interface:AbstractSandboxFilesystemUnique identifier for this filesystem/sandbox instance.- Specified by:
idin interfaceAbstractSandboxFilesystem- Returns:
- id string
-
execute
public ExecuteResponse execute(io.agentscope.core.agent.RuntimeContext runtimeContext, String command, Integer timeoutSeconds) Description copied from interface:AbstractSandboxFilesystemExecute a shell command in the environment backing this filesystem.- Specified by:
executein interfaceAbstractSandboxFilesystem- Parameters:
runtimeContext- per-call agent context; may benullwhen unavailablecommand- full shell command string to executetimeoutSeconds- maximum time in seconds to wait for the command to complete;nulluses the filesystem's default timeout- Returns:
- ExecuteResponse with combined output, exit code, and truncation flag; a
non-successful response (see
ExecuteResponse.isSuccess()) means the command did not complete successfully, sooutputmust not be parsed as normal command output
-
write
public WriteResult write(io.agentscope.core.agent.RuntimeContext runtimeContext, String filePath, String content) Description copied from interface:AbstractFilesystemWrite content to a new file, error if file already exists.- Specified by:
writein interfaceAbstractFilesystem- Overrides:
writein classOverlayFilesystem- Parameters:
runtimeContext- per-call agent runtime;RuntimeContext.empty()when nonefilePath- absolute path where the file should be createdcontent- string content to write to the file- Returns:
- WriteResult with path on success, or error if the file already exists or write fails
-
edit
public EditResult edit(io.agentscope.core.agent.RuntimeContext runtimeContext, String filePath, String oldString, String newString, boolean replaceAll) Description copied from interface:AbstractFilesystemPerform exact string replacements in an existing file.- Specified by:
editin interfaceAbstractFilesystem- Overrides:
editin classOverlayFilesystem- Parameters:
runtimeContext- per-call agent runtime;RuntimeContext.empty()when nonefilePath- absolute path to the file to editoldString- exact string to search for and replacenewString- string to replace oldString with (must be different from oldString)replaceAll- if true, replace all occurrences; if false, oldString must be unique- Returns:
- EditResult with path and occurrence count on success, or error on failure
-
delete
Description copied from interface:AbstractFilesystemDelete a file or directory (recursive for directories).Idempotent: deleting a path that does not exist is treated as success.
- Specified by:
deletein interfaceAbstractFilesystem- Overrides:
deletein classOverlayFilesystem- Parameters:
runtimeContext- per-call agent runtime;RuntimeContext.empty()when nonepath- absolute path to the file or directory to delete- Returns:
- WriteResult success when deleted (or already absent), failure on I/O error
-
uploadFiles
public List<FileUploadResponse> uploadFiles(io.agentscope.core.agent.RuntimeContext runtimeContext, List<Map.Entry<String, byte[]>> files) Description copied from interface:AbstractFilesystemUpload multiple files.- Specified by:
uploadFilesin interfaceAbstractFilesystem- Overrides:
uploadFilesin classOverlayFilesystem- Parameters:
runtimeContext- per-call agent runtime;RuntimeContext.empty()when nonefiles- list of path-to-content mappings to upload- Returns:
- list of FileUploadResponse objects, one per input file (order matches input order)
-
read
public ReadResult read(io.agentscope.core.agent.RuntimeContext runtimeContext, String filePath, int offset, int limit) Description copied from interface:AbstractFilesystemRead file content with optional line-based pagination.- Specified by:
readin interfaceAbstractFilesystem- Overrides:
readin classOverlayFilesystem- Parameters:
runtimeContext- per-call agent runtime;RuntimeContext.empty()when nonefilePath- absolute path to the file to read (must start with '/')offset- line number to start reading from (0-indexed). Default: 0limit- maximum number of lines to read. Default: 2000- Returns:
- ReadResult with file data on success or error on failure
-
exists
Description copied from interface:AbstractFilesystemCheck whether a file or directory exists.Implementations may approximate this with a lightweight read probe where a dedicated
existsAPI is unavailable, but should avoid reading full file content.- Specified by:
existsin interfaceAbstractFilesystem- Overrides:
existsin classOverlayFilesystem- Parameters:
runtimeContext- per-call agent runtime;RuntimeContext.empty()when nonepath- absolute path to check- Returns:
trueif the path exists,falseotherwise
-
downloadFiles
public List<FileDownloadResponse> downloadFiles(io.agentscope.core.agent.RuntimeContext runtimeContext, List<String> paths) Description copied from interface:AbstractFilesystemDownload multiple files.- Specified by:
downloadFilesin interfaceAbstractFilesystem- Overrides:
downloadFilesin classOverlayFilesystem- Parameters:
runtimeContext- per-call agent runtime;RuntimeContext.empty()when nonepaths- list of file paths to download- Returns:
- list of FileDownloadResponse objects, one per input path (order matches input order)
-
ls
Description copied from interface:AbstractFilesystemList all files in a directory with metadata.- Specified by:
lsin interfaceAbstractFilesystem- Overrides:
lsin classOverlayFilesystem- Parameters:
runtimeContext- per-call agent runtime;RuntimeContext.empty()when nonepath- absolute path to the directory to list (must start with '/')- Returns:
- LsResult with directory entries or error
-
grep
public GrepResult grep(io.agentscope.core.agent.RuntimeContext runtimeContext, String pattern, String path, String glob) Description copied from interface:AbstractFilesystemSearch for a literal text pattern in files.- Specified by:
grepin interfaceAbstractFilesystem- Overrides:
grepin classOverlayFilesystem- Parameters:
runtimeContext- per-call agent runtime;RuntimeContext.empty()when nonepattern- literal string to search for (not regex)path- optional directory path to search in (null searches current working directory)glob- optional glob pattern to filter which files to search (e.g., "*.java")- Returns:
- GrepResult with matches or error
-
glob
public GlobResult glob(io.agentscope.core.agent.RuntimeContext runtimeContext, String pattern, String path) Description copied from interface:AbstractFilesystemFind files matching a glob pattern.- Specified by:
globin interfaceAbstractFilesystem- Overrides:
globin classOverlayFilesystem- Parameters:
runtimeContext- per-call agent runtime;RuntimeContext.empty()when nonepattern- glob pattern with wildcards to match file pathspath- base directory to search from (default: "/")- Returns:
- GlobResult with matching files or error
-
move
public WriteResult move(io.agentscope.core.agent.RuntimeContext runtimeContext, String fromPath, String toPath) Description copied from interface:AbstractFilesystemMove (rename) a file or directory fromfromPathtotoPath.Implementations that span multiple stores (e.g.
CompositeFilesystem) may fall back to a read + write + delete sequence when source and destination live in different backend filesystems.- Specified by:
movein interfaceAbstractFilesystem- Overrides:
movein classOverlayFilesystem- Parameters:
runtimeContext- per-call agent runtime;RuntimeContext.empty()when nonefromPath- absolute source pathtoPath- absolute destination path- Returns:
- WriteResult success on completion, failure on I/O error or missing source
-
ProjectAwareOverlay(AbstractSandboxFilesystem, AbstractFilesystem, LocalFilesystem, Path, NamespaceFactory)so workspace-rooted absolute paths resolve identically to their relative spelling under namespace scoping