Sandbox
public class Sandbox
io/agentscope/extensions/sandbox/kubernetes/client/Sandbox.java:35–247处理用于运行中沙箱实例。位于 io.agentscope.extensions.sandbox.kubernetes.client 包。核心成员包括 claimName、sandboxId、namespace、commands、files、isActive。
Handle for a running Sandbox instance. Provides command execution and file I/O
via #commands() and #files().
Mirrors the Python SDK's Sandbox class.
构造器摘要Constructor Summary
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public String claimName() | 返回 `claimName` 结果。 Returns the claim name. |
public String sandboxId() | 返回沙箱标识。 Returns the sandbox id. |
public String namespace() | 返回命名空间。 Returns the namespace. |
public CommandExecutor commands() | 返回 `commands` 结果。 Returns the command executor, or null if the connection has been closed. |
public Filesystem files() | 返回文件。 Returns the filesystem API, or null if the connection has been closed. |
public boolean isActive() | 判断是否 `isActive`。 Whether the client-side connection is still active. |
public String getPodName() | 获取 `getPodName`。 Fetches the Sandbox object from Kubernetes and retrieves its current pod name. |
public String getPodIp() | 获取 `getPodIp`。 Selects a pod IP from the Sandbox status (prefers IPv4). |
public String getSandboxNameHash() | 获取 `getSandboxNameHash`。 Fetches the sandbox name hash from the status selector label. |
public SandboxStatus status() | 返回状态。 Retrieves the current status of the Sandbox. |
public void closeConnection() | 关闭连接。 Closes the client-side connection but leaves the remote Kubernetes resources running. |
public void terminate() | 执行 `terminate` 方法。 Permanently deletes the SandboxClaim and closes the client-side connection. |
构造器详情Constructor Detail
Sandbox
public Sandbox(String claimName, String sandboxId, String namespace, SandboxConnectionConfig connectionConfig, K8sHelper k8sHelper)
初始化 Sandbox 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
claimName | String | claim 名称(类型 `String`)。The claim name. |
sandboxId | String | 沙箱标识(类型 `String`)。The sandbox id. |
namespace | String | 命名空间(类型 `String`)。The namespace. |
connectionConfig | SandboxConnectionConfig | 连接配置(类型 `SandboxConnectionConfig`)。The connection config. |
k8sHelper | K8sHelper | k 8 s Helper(类型 `K8sHelper`)。The k 8 s helper. |
io/agentscope/extensions/sandbox/kubernetes/client/Sandbox.java:52–59Sandbox
public Sandbox(String claimName, String sandboxId, String namespace, SandboxConnectionConfig connectionConfig, K8sHelper k8sHelper, Duration requestTimeout, Duration perAttemptTimeout)
初始化 Sandbox 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
claimName | String | claim 名称(类型 `String`)。The claim name. |
sandboxId | String | 沙箱标识(类型 `String`)。The sandbox id. |
namespace | String | 命名空间(类型 `String`)。The namespace. |
connectionConfig | SandboxConnectionConfig | 连接配置(类型 `SandboxConnectionConfig`)。The connection config. |
k8sHelper | K8sHelper | k 8 s Helper(类型 `K8sHelper`)。The k 8 s helper. |
requestTimeout | Duration | 请求超时(类型 `Duration`)。The request timeout. |
perAttemptTimeout | Duration | 每个尝试超时(类型 `Duration`)。The per attempt timeout. |
io/agentscope/extensions/sandbox/kubernetes/client/Sandbox.java:61–86方法详情Method Detail
claimName
public String claimName()
返回 claimName 结果。
Returns the claim name.
Stringio/agentscope/extensions/sandbox/kubernetes/client/Sandbox.java:88–90sandboxId
public String sandboxId()
返回沙箱标识。
Returns the sandbox id.
Stringio/agentscope/extensions/sandbox/kubernetes/client/Sandbox.java:92–94namespace
public String namespace()
返回命名空间。
Returns the namespace.
Stringio/agentscope/extensions/sandbox/kubernetes/client/Sandbox.java:96–98commands
public CommandExecutor commands()
返回 commands 结果。
Returns the command executor, or null if the connection has been closed.
CommandExecutorio/agentscope/extensions/sandbox/kubernetes/client/Sandbox.java:105–107files
public Filesystem files()
返回文件。
Returns the filesystem API, or null if the connection has been closed.
Filesystemio/agentscope/extensions/sandbox/kubernetes/client/Sandbox.java:114–116isActive
public boolean isActive()
判断是否 isActive。
Whether the client-side connection is still active.
booleanio/agentscope/extensions/sandbox/kubernetes/client/Sandbox.java:123–125getPodName
public String getPodName()
获取 getPodName。
Fetches the Sandbox object from Kubernetes and retrieves its current pod name.
Stringio/agentscope/extensions/sandbox/kubernetes/client/Sandbox.java:132–148getPodIp
public String getPodIp()
获取 getPodIp。
Selects a pod IP from the Sandbox status (prefers IPv4).
Stringio/agentscope/extensions/sandbox/kubernetes/client/Sandbox.java:155–161getSandboxNameHash
public String getSandboxNameHash()
获取 getSandboxNameHash。
Fetches the sandbox name hash from the status selector label.
Stringio/agentscope/extensions/sandbox/kubernetes/client/Sandbox.java:168–189status
public SandboxStatus status()
返回状态。
Retrieves the current status of the Sandbox.
SandboxStatusio/agentscope/extensions/sandbox/kubernetes/client/Sandbox.java:196–215closeConnection
public void closeConnection()
关闭连接。
Closes the client-side connection but leaves the remote Kubernetes resources running.
io/agentscope/extensions/sandbox/kubernetes/client/Sandbox.java:220–229terminate
public void terminate()
执行 terminate 方法。
Permanently deletes the SandboxClaim and closes the client-side connection.
io/agentscope/extensions/sandbox/kubernetes/client/Sandbox.java:235–242