AS AgentScopeAPI 手册 / API Reference

LocalSandboxSnapshot

@JsonIgnoreProperties(ignoreUnknown = true) public class LocalSandboxSnapshot implements SandboxSnapshot
源码Source io/agentscope/harness/agent/sandbox/snapshot/LocalSandboxSnapshot.java:42–154

本地沙箱快照,承载智能体的部署、调度与服务化运行。位于 io.agentscope.harness.agent.sandbox.snapshot 包,实现 SandboxSnapshot。核心成员包括 persist、restore、isRestorable、getId、getType、getBasePath。

Snapshot that persists workspace archives as tar files on the local filesystem.

Archives are written atomically: the data is first written to a temporary file (prefixed with .) in the same directory, then moved to the final path using StandardCopyOption#ATOMIC_MOVE. This ensures the snapshot is either fully written or not present — never partially written.

Security: id must be a single path segment with no / or .. characters to prevent path traversal attacks.

构造器摘要Constructor Summary

构造器Constructor说明Description
public LocalSandboxSnapshot(String basePath, String id)
创建本地快照。
Creates a local snapshot.

方法摘要Method Summary

方法Method说明Description
public void persist(InputStream workspaceArchive) throws Exception
设置该参数。
{@inheritDoc}
public InputStream restore() throws Exception
返回 `restore` 结果。
{@inheritDoc}
public boolean isRestorable()
判断是否 `isRestorable`。
{@inheritDoc}
public String getId()
获取标识。
Returns the id.
public String getType()
获取类型。
Returns the type.
public String getBasePath()
获取基类路径。
Returns the base directory where snapshot tar files are stored.

构造器详情Constructor Detail

LocalSandboxSnapshot

public LocalSandboxSnapshot(String basePath, String id)

创建本地快照。

Creates a local snapshot.

参数Parameters
名称Name类型Type说明Description
basePathString基类路径(类型 `String`)。directory where snapshot tar files are stored
idString标识(类型 `String`)。unique identifier for this snapshot (must be a safe single path segment)
抛出Throws
  • IllegalArgumentException 可能抛出 `IllegalArgumentException`。if `id` contains unsafe characters
源码Source io/agentscope/harness/agent/sandbox/snapshot/LocalSandboxSnapshot.java:55–61

方法详情Method Detail

persist

public void persist(InputStream workspaceArchive) throws Exception

设置该参数。

{@inheritDoc} Writes the archive atomically to {basePath}/{id}.tar.

参数Parameters
名称Name类型Type说明Description
workspaceArchiveInputStream工作区归档(类型 `InputStream`)。The workspace archive.
抛出Throws
  • Exception 可能抛出 `Exception`。Thrown when the operation cannot be completed.
源码Source io/agentscope/harness/agent/sandbox/snapshot/LocalSandboxSnapshot.java:68–95

restore

public InputStream restore() throws Exception

返回 restore 结果。

{@inheritDoc} Opens the snapshot tar file at {basePath}/{id}.tar for reading.

返回Returns InputStream
返回InputStream。Returns input stream.
抛出Throws
  • Exception 可能抛出 `Exception`。Thrown when the operation cannot be completed.
源码Source io/agentscope/harness/agent/sandbox/snapshot/LocalSandboxSnapshot.java:102–113

isRestorable

public boolean isRestorable()

判断是否 isRestorable。

{@inheritDoc}

返回Returns boolean
返回布尔值,表示判断结果。`true` if the snapshot tar file exists
源码Source io/agentscope/harness/agent/sandbox/snapshot/LocalSandboxSnapshot.java:120–123

getId

public String getId()

获取标识。

Returns the id.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/harness/agent/sandbox/snapshot/LocalSandboxSnapshot.java:125–128

getType

public String getType()

获取类型。

Returns the type.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/harness/agent/sandbox/snapshot/LocalSandboxSnapshot.java:130–133

getBasePath

public String getBasePath()

获取基类路径。

Returns the base directory where snapshot tar files are stored.

返回Returns String
返回字符串结果。base path string
源码Source io/agentscope/harness/agent/sandbox/snapshot/LocalSandboxSnapshot.java:140–142

继承成员Inherited Members

继承自Methods inherited from SandboxSnapshot
基于官方固定版本源码静态生成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.