AS AgentScopeAPI 手册 / API Reference

SandboxBackedFilesystem

public class SandboxBackedFilesystem extends BaseSandboxFilesystem implements SandboxAware
源码Source 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.

源码Source io/agentscope/harness/agent/filesystem/sandbox/SandboxBackedFilesystem.java:67–69

方法详情Method Detail

setSandbox

public synchronized void setSandbox(Sandbox sandbox)
synchronized

设置沙箱。

Sets the sandbox.

参数Parameters
名称Name类型Type说明Description
sandboxSandbox沙箱(类型 `Sandbox`)。The sandbox.
源码Source io/agentscope/harness/agent/filesystem/sandbox/SandboxBackedFilesystem.java:71–74

getSandbox

public Sandbox getSandbox()

获取沙箱。

Returns the sandbox.

返回Returns Sandbox
返回沙箱。Returns sandbox.
源码Source io/agentscope/harness/agent/filesystem/sandbox/SandboxBackedFilesystem.java:76–79

clearSandboxIfCurrent

public synchronized void clearSandboxIfCurrent(Sandbox expected)
synchronized

清空沙箱 If 当前。

Clears the fallback sandbox field only if it still points at expected.

参数Parameters
名称Name类型Type说明Description
expectedSandboxexpected(类型 `Sandbox`)。the sandbox this call bound at acquire time
源码Source io/agentscope/harness/agent/filesystem/sandbox/SandboxBackedFilesystem.java:88–92

id

public String id()

返回标识。

Returns the id.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/harness/agent/filesystem/sandbox/SandboxBackedFilesystem.java:94–97

execute

public ExecuteResponse execute(RuntimeContext runtimeContext, String command, Integer timeoutSeconds)

执行执行相关操作。

Performs the execute operation.

参数Parameters
名称Name类型Type说明Description
runtimeContextRuntimeContext运行时上下文(类型 `RuntimeContext`)。The runtime context.
commandString命令(类型 `String`)。The command.
timeoutSecondsInteger超时秒(类型 `Integer`)。The timeout seconds.
返回Returns ExecuteResponse
返回ExecuteResponse。Returns execute response.
源码Source io/agentscope/harness/agent/filesystem/sandbox/SandboxBackedFilesystem.java:99–120

uploadFiles

public List<FileUploadResponse> uploadFiles(RuntimeContext runtimeContext, List<Map.Entry<String, byte[]>> files)

执行上传文件相关操作。

Performs the upload files operation.

参数Parameters
名称Name类型Type说明Description
runtimeContextRuntimeContext运行时上下文(类型 `RuntimeContext`)。The runtime context.
filesList<Map.Entry<String, byte[]>>文件(类型 `List >`)。The files.
返回Returns List<FileUploadResponse>
返回列出。Returns list.
源码Source io/agentscope/harness/agent/filesystem/sandbox/SandboxBackedFilesystem.java:122–175

downloadFiles

public List<FileDownloadResponse> downloadFiles(RuntimeContext runtimeContext, List<String> paths)

执行下载文件相关操作。

Performs the download files operation.

参数Parameters
名称Name类型Type说明Description
runtimeContextRuntimeContext运行时上下文(类型 `RuntimeContext`)。The runtime context.
pathsList<String>paths(类型 `List`)。The paths.
返回Returns List<FileDownloadResponse>
返回列出。Returns list.
源码Source io/agentscope/harness/agent/filesystem/sandbox/SandboxBackedFilesystem.java:177–231

继承成员Inherited Members

继承自Methods inherited from BaseSandboxFilesystem
继承自Methods inherited from AbstractFilesystem
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.