LocalSandboxSnapshot
@JsonIgnoreProperties(ignoreUnknown = true) public class LocalSandboxSnapshot implements SandboxSnapshot
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.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
basePath | String | 基类路径(类型 `String`)。directory where snapshot tar files are stored |
id | String | 标识(类型 `String`)。unique identifier for this snapshot (must be a safe single path segment) |
IllegalArgumentException可能抛出 `IllegalArgumentException`。if `id` contains unsafe characters
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.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
workspaceArchive | InputStream | 工作区归档(类型 `InputStream`)。The workspace archive. |
Exception可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/harness/agent/sandbox/snapshot/LocalSandboxSnapshot.java:68–95restore
public InputStream restore() throws Exception
返回 restore 结果。
{@inheritDoc} Opens the snapshot tar file at {basePath}/{id}.tar for reading.
InputStreamException可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/harness/agent/sandbox/snapshot/LocalSandboxSnapshot.java:102–113isRestorable
public boolean isRestorable()
判断是否 isRestorable。
{@inheritDoc}
booleanio/agentscope/harness/agent/sandbox/snapshot/LocalSandboxSnapshot.java:120–123getId
public String getId()
获取标识。
Returns the id.
Stringio/agentscope/harness/agent/sandbox/snapshot/LocalSandboxSnapshot.java:125–128getType
public String getType()
获取类型。
Returns the type.
Stringio/agentscope/harness/agent/sandbox/snapshot/LocalSandboxSnapshot.java:130–133getBasePath
public String getBasePath()
获取基类路径。
Returns the base directory where snapshot tar files are stored.
Stringio/agentscope/harness/agent/sandbox/snapshot/LocalSandboxSnapshot.java:140–142