SandboxBackedFilesystem
public class SandboxBackedFilesystem extends BaseSandboxFilesystem implements SandboxAware
io/agentscope/harness/agent/filesystem/sandbox/SandboxBackedFilesystem.java:60–345沙箱 Backed 文件系统,承载智能体的部署、调度与服务化运行。位于 io.agentscope.harness.agent.filesystem.sandbox 包,继承自 BaseSandboxFilesystem,实现 SandboxAware。核心成员包括 setSandbox、getSandbox、clearSandboxIfCurrent、id、execute、uploadFiles。
A BaseSandboxFilesystem that delegates execution to a live Sandbox.
Stable proxy created once per agent bean. The live Sandbox for a call is bound
per-call on the invocation's RuntimeContext by io.agentscope.harness.agent.middleware.SandboxLifecycleMiddleware and resolved here via #requireSandbox(RuntimeContext) — this per-call binding takes precedence and is what keeps
concurrent distinct-session calls on the same agent bean isolated (issue #2490). The legacy
volatile sandbox field is retained only as a best-effort fallback for context-free
internal callers that resolve the filesystem with a shared empty RuntimeContext (e.g.
io.agentscope.harness.agent.bus.WorkspaceMessageBus, which carries no per-call binding).
The middleware still maintains that field via #setSandbox on acquire and #clearSandboxIfCurrent on release, so it remains last-writer-wins under concurrency and must not
be relied on for isolation.
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public SandboxBackedFilesystem() | 初始化 `SandboxBackedFilesystem` 实例。 Creates a new instance. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public synchronized void setSandbox(Sandbox sandbox)synchronized | 设置沙箱。 Sets the sandbox. |
public Sandbox getSandbox() | 获取沙箱。 Returns the sandbox. |
public synchronized void clearSandboxIfCurrent(Sandbox expected)synchronized | 清空沙箱 If 当前。 Clears the fallback `sandbox` field only if it still points at `expected`. |
public String id() | 返回标识。 Returns the id. |
public ExecuteResponse execute(RuntimeContext runtimeContext, String command, Integer timeoutSeconds) | 执行执行相关操作。 Performs the execute operation. |
public List<FileUploadResponse> uploadFiles(RuntimeContext runtimeContext, List<Map.Entry<String, byte[]>> files) | 执行上传文件相关操作。 Performs the upload files operation. |
public List<FileDownloadResponse> downloadFiles(RuntimeContext runtimeContext, List<String> paths) | 执行下载文件相关操作。 Performs the download files operation. |
构造器详情Constructor Detail
SandboxBackedFilesystem
public SandboxBackedFilesystem()
初始化 SandboxBackedFilesystem 实例。
Creates a new instance.
io/agentscope/harness/agent/filesystem/sandbox/SandboxBackedFilesystem.java:67–69方法详情Method Detail
setSandbox
public synchronized void setSandbox(Sandbox sandbox)
设置沙箱。
Sets the sandbox.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sandbox | Sandbox | 沙箱(类型 `Sandbox`)。The sandbox. |
io/agentscope/harness/agent/filesystem/sandbox/SandboxBackedFilesystem.java:71–74getSandbox
public Sandbox getSandbox()
获取沙箱。
Returns the sandbox.
Sandboxio/agentscope/harness/agent/filesystem/sandbox/SandboxBackedFilesystem.java:76–79clearSandboxIfCurrent
public synchronized void clearSandboxIfCurrent(Sandbox expected)
清空沙箱 If 当前。
Clears the fallback sandbox field only if it still points at expected.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
expected | Sandbox | expected(类型 `Sandbox`)。the sandbox this call bound at acquire time |
io/agentscope/harness/agent/filesystem/sandbox/SandboxBackedFilesystem.java:88–92id
public String id()
返回标识。
Returns the id.
Stringio/agentscope/harness/agent/filesystem/sandbox/SandboxBackedFilesystem.java:94–97execute
public ExecuteResponse execute(RuntimeContext runtimeContext, String command, Integer timeoutSeconds)
执行执行相关操作。
Performs the execute operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
runtimeContext | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The runtime context. |
command | String | 命令(类型 `String`)。The command. |
timeoutSeconds | Integer | 超时秒(类型 `Integer`)。The timeout seconds. |
ExecuteResponseio/agentscope/harness/agent/filesystem/sandbox/SandboxBackedFilesystem.java:99–120uploadFiles
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/sandbox/SandboxBackedFilesystem.java:122–175downloadFiles
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/sandbox/SandboxBackedFilesystem.java:177–231