AS AgentScopeAPI 手册 / API Reference

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
源码Source 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.

参数Parameters
名称Name类型Type说明Description
workspaceArchiveInputStream工作区归档(类型 `InputStream`)。tar stream of the workspace to persist; caller is responsible for closing the stream after this call
抛出Throws
  • Exception 可能抛出 `Exception`。Thrown when the operation cannot be completed.
源码Source io/agentscope/harness/agent/sandbox/snapshot/SandboxSnapshot.java:46

restore

public InputStream restore() throws Exception

返回 restore 结果。

Restores the workspace archive from this snapshot.

返回Returns InputStream
返回InputStream。tar stream of the workspace; caller is responsible for closing
抛出Throws
  • Exception 可能抛出 `Exception`。Thrown when the operation cannot be completed.
源码Source io/agentscope/harness/agent/sandbox/snapshot/SandboxSnapshot.java:54

isRestorable

public boolean isRestorable() throws Exception

判断是否 isRestorable。

Returns whether this snapshot can currently be restored.

返回Returns boolean
返回布尔值,表示判断结果。true if `#restore()` would succeed
抛出Throws
  • Exception 可能抛出 `Exception`。Thrown when the operation cannot be completed.
源码Source io/agentscope/harness/agent/sandbox/snapshot/SandboxSnapshot.java:62–63

getId

public String getId()

获取标识。

Returns the unique identifier for this snapshot.

返回Returns String
返回字符串结果。snapshot id
源码Source io/agentscope/harness/agent/sandbox/snapshot/SandboxSnapshot.java:70

getType

public String getType()

获取类型。

Returns the snapshot type discriminator used in JSON serialization.

返回Returns String
返回字符串结果。type string (e.g. "noop", "local", "remote")
源码Source io/agentscope/harness/agent/sandbox/snapshot/SandboxSnapshot.java:77–78

isPersistenceEnabled

default public boolean isPersistenceEnabled()
default

判断是否持久化已启用。

Returns whether this snapshot actually persists data.

返回Returns boolean
返回布尔值,表示判断结果。false only for no-op implementations that discard all archive data
源码Source io/agentscope/harness/agent/sandbox/snapshot/SandboxSnapshot.java:88–91
基于官方固定版本源码静态生成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.