SandboxSnapshot
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type") @JsonSubTypes({ @JsonSubTypes.Type(value = NoopSandboxSnapshot.class, name = "noop"), @JsonSubTypes.Type(value = LocalSandboxSnapshot.class, name = "local"), @JsonSubTypes.Type(value = RemoteSandboxSnapshot.class, name = "remote"), }) public interface SandboxSnapshot
io/agentscope/harness/agent/sandbox/snapshot/SandboxSnapshot.java:31–92定义沙箱快照契约的接口。位于 io.agentscope.harness.agent.sandbox.snapshot 包。核心成员包括 persist、restore、isRestorable、getId、getType、isPersistenceEnabled。
Represents a persisted snapshot of a sandbox workspace.
Snapshots allow workspace state to be preserved between session stops and restored on
subsequent session starts. Implementations determine where and how the snapshot is stored:
local disk (LocalSandboxSnapshot), remote storage (RemoteSandboxSnapshot),
or not at all (NoopSandboxSnapshot).
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public void persist(InputStream workspaceArchive) throws Exception | 设置该参数。 Persists the workspace archive to this snapshot. |
public InputStream restore() throws Exception | 返回 `restore` 结果。 Restores the workspace archive from this snapshot. |
public boolean isRestorable() throws Exception | 判断是否 `isRestorable`。 Returns whether this snapshot can currently be restored. |
public String getId() | 获取标识。 Returns the unique identifier for this snapshot. |
public String getType() | 获取类型。 Returns the snapshot type discriminator used in JSON serialization. |
default public boolean isPersistenceEnabled()default | 判断是否持久化已启用。 Returns whether this snapshot actually persists data. |
方法详情Method Detail
persist
public void persist(InputStream workspaceArchive) throws Exception
设置该参数。
Persists the workspace archive to this snapshot.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
workspaceArchive | InputStream | 工作区归档(类型 `InputStream`)。tar stream of the workspace to persist; caller is responsible for closing the stream after this call |
Exception可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/harness/agent/sandbox/snapshot/SandboxSnapshot.java:46restore
public InputStream restore() throws Exception
返回 restore 结果。
Restores the workspace archive from this snapshot.
InputStreamException可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/harness/agent/sandbox/snapshot/SandboxSnapshot.java:54isRestorable
public boolean isRestorable() throws Exception
判断是否 isRestorable。
Returns whether this snapshot can currently be restored.
booleanException可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/harness/agent/sandbox/snapshot/SandboxSnapshot.java:62–63getId
public String getId()
获取标识。
Returns the unique identifier for this snapshot.
Stringio/agentscope/harness/agent/sandbox/snapshot/SandboxSnapshot.java:70getType
public String getType()
获取类型。
Returns the snapshot type discriminator used in JSON serialization.
Stringio/agentscope/harness/agent/sandbox/snapshot/SandboxSnapshot.java:77–78isPersistenceEnabled
default public boolean isPersistenceEnabled()
判断是否持久化已启用。
Returns whether this snapshot actually persists data.
booleanio/agentscope/harness/agent/sandbox/snapshot/SandboxSnapshot.java:88–91