OverlayFilesystem
public class OverlayFilesystem implements AbstractFilesystem
io/agentscope/harness/agent/filesystem/OverlayFilesystem.java:56–302Overlay 文件系统,承载智能体的部署、调度与服务化运行。位于 io.agentscope.harness.agent.filesystem 包,实现 AbstractFilesystem。核心成员包括 upper、lower、of、ls、read、write。
A layered filesystem that overlays a user-specific "upper" layer on top of a shared "lower" layer, providing copy-on-write semantics.
Read operations check the upper layer first and fall back to the lower layer. Write operations always target the upper layer. This enables per-user customization of shared content (e.g. skills, subagents) without modifying the shared originals.
Merge semantics:
-
ls— union of both layers; upper entries take precedence on path collision -
read— upper first, then lower -
write/edit— always to upper (copy-on-write) -
delete— removes from upper only; shared-layer files cannot be deleted -
grep/glob— searches both layers; upper results override lower on path collision -
exists— true if present in either layer
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public OverlayFilesystem(AbstractFilesystem upper, AbstractFilesystem lower) | 初始化 `OverlayFilesystem` 实例。 Creates an overlay filesystem. |
方法摘要Method Summary
构造器详情Constructor Detail
OverlayFilesystem
public OverlayFilesystem(AbstractFilesystem upper, AbstractFilesystem lower)
初始化 OverlayFilesystem 实例。
Creates an overlay filesystem.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
upper | AbstractFilesystem | upper(类型 `AbstractFilesystem`)。the user-specific layer (read/write); takes precedence on conflicts |
lower | AbstractFilesystem | lower(类型 `AbstractFilesystem`)。the shared layer (read-only from the overlay's perspective) |
io/agentscope/harness/agent/filesystem/OverlayFilesystem.java:67–76方法详情Method Detail
upper
public AbstractFilesystem upper()
返回 upper 结果。
Returns the upper (writable) layer.
AbstractFilesystemio/agentscope/harness/agent/filesystem/OverlayFilesystem.java:79–81lower
public AbstractFilesystem lower()
返回 lower 结果。
Returns the lower (shared) layer.
AbstractFilesystemio/agentscope/harness/agent/filesystem/OverlayFilesystem.java:84–86of
public static AbstractFilesystem of(AbstractFilesystem upper, AbstractFilesystem lower)
创建并返回实例。
Builds an overlay that automatically exposes shell execution when upper supports it.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
upper | AbstractFilesystem | upper(类型 `AbstractFilesystem`)。user-specific layer (read/write); takes precedence on conflicts |
lower | AbstractFilesystem | lower(类型 `AbstractFilesystem`)。shared layer (read-only from the overlay's perspective) |
AbstractFilesystemio/agentscope/harness/agent/filesystem/OverlayFilesystem.java:104–109ls
public LsResult ls(RuntimeContext runtimeContext, String path)
执行 ls 方法。
Performs the ls operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
runtimeContext | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The runtime context. |
path | String | 路径(类型 `String`)。The path. |
LsResultio/agentscope/harness/agent/filesystem/OverlayFilesystem.java:138–159read
public ReadResult read(RuntimeContext runtimeContext, String filePath, int offset, int limit)
执行读取相关操作。
Performs the read operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
runtimeContext | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The runtime context. |
filePath | String | 文件路径(类型 `String`)。The file path. |
offset | int | 偏移量(类型 `int`)。The offset. |
limit | int | 数量上限(类型 `int`)。The limit. |
ReadResultio/agentscope/harness/agent/filesystem/OverlayFilesystem.java:161–167write
public WriteResult write(RuntimeContext runtimeContext, String filePath, String content)
执行写入相关操作。
Performs the write operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
runtimeContext | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The runtime context. |
filePath | String | 文件路径(类型 `String`)。The file path. |
content | String | 内容(类型 `String`)。The content. |
WriteResultio/agentscope/harness/agent/filesystem/OverlayFilesystem.java:169–172edit
public EditResult edit(RuntimeContext runtimeContext, String filePath, String oldString, String newString, boolean replaceAll)
执行 edit 方法。
Performs the edit operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
runtimeContext | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The runtime context. |
filePath | String | 文件路径(类型 `String`)。The file path. |
oldString | String | 旧的 String(类型 `String`)。The old string. |
newString | String | 新建 String(类型 `String`)。The new string. |
replaceAll | boolean | replace 所有(类型 `boolean`)。The replace all. |
EditResultio/agentscope/harness/agent/filesystem/OverlayFilesystem.java:174–193grep
public GrepResult grep(RuntimeContext runtimeContext, String pattern, String path, String glob)
执行 grep 方法。
Performs the grep operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
runtimeContext | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The runtime context. |
pattern | String | pattern(类型 `String`)。The pattern. |
path | String | 路径(类型 `String`)。The path. |
glob | String | glob(类型 `String`)。The glob. |
GrepResultio/agentscope/harness/agent/filesystem/OverlayFilesystem.java:195–217glob
public GlobResult glob(RuntimeContext runtimeContext, String pattern, String path)
执行 glob 方法。
Performs the glob operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
runtimeContext | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The runtime context. |
pattern | String | pattern(类型 `String`)。The pattern. |
path | String | 路径(类型 `String`)。The path. |
GlobResultio/agentscope/harness/agent/filesystem/OverlayFilesystem.java:219–240uploadFiles
public List<FileUploadResponse> uploadFiles(RuntimeContext runtimeContext, List<Map.Entry<String, byte[]>> files)
执行上传文件相关操作。
Performs the upload files operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
runtimeContext | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The runtime context. |
files | List<Map.Entry<String, byte[]>> | 文件(类型 `List >`)。The files. |
List<FileUploadResponse>io/agentscope/harness/agent/filesystem/OverlayFilesystem.java:242–246downloadFiles
public List<FileDownloadResponse> downloadFiles(RuntimeContext runtimeContext, List<String> paths)
执行下载文件相关操作。
Performs the download files operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
runtimeContext | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The runtime context. |
paths | List<String> | paths(类型 `List`)。The paths. |
List<FileDownloadResponse>io/agentscope/harness/agent/filesystem/OverlayFilesystem.java:248–260delete
public WriteResult delete(RuntimeContext runtimeContext, String path)
删除数据。
Performs the delete operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
runtimeContext | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The runtime context. |
path | String | 路径(类型 `String`)。The path. |
WriteResultio/agentscope/harness/agent/filesystem/OverlayFilesystem.java:262–271move
public WriteResult move(RuntimeContext runtimeContext, String fromPath, String toPath)
执行 move 方法。
Performs the move operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
runtimeContext | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The runtime context. |
fromPath | String | 来自路径(类型 `String`)。The from path. |
toPath | String | 到路径(类型 `String`)。The to path. |
WriteResultio/agentscope/harness/agent/filesystem/OverlayFilesystem.java:273–286exists
public boolean exists(RuntimeContext runtimeContext, String path)
判断数据是否存在。
Performs the exists operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
runtimeContext | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The runtime context. |
path | String | 路径(类型 `String`)。The path. |
booleanio/agentscope/harness/agent/filesystem/OverlayFilesystem.java:288–291getUpper
public AbstractFilesystem getUpper()
获取 getUpper。
Returns the user-specific (read/write) layer.
AbstractFilesystemio/agentscope/harness/agent/filesystem/OverlayFilesystem.java:294–296getLower
public AbstractFilesystem getLower()
获取 getLower。
Returns the shared (read-only-through-this-overlay) layer.
AbstractFilesystemio/agentscope/harness/agent/filesystem/OverlayFilesystem.java:299–301