KubernetesSandbox
public class KubernetesSandbox extends AbstractBaseSandbox implements SandboxFileTransfer
io/agentscope/extensions/sandbox/kubernetes/KubernetesSandbox.java:48–354Kubernetes 沙箱,在隔离环境中安全执行代码和工具。位于 io.agentscope.extensions.sandbox.kubernetes 包,继承自 AbstractBaseSandbox,实现 SandboxFileTransfer。核心成员包括 shutdown、doExec、doPersistWorkspace、doHydrateWorkspace、doSetupWorkspace、doDestroyWorkspace。
Harness io.agentscope.harness.agent.sandbox.Sandbox backed by an
agent-sandbox CRD via the Java client SDK.
Assumes the runtime image conforms to the AgentScope runtime contract (see the sandbox
documentation): POST /execute interprets the command with a POSIX shell, and the
file API (/upload / /download) is rooted at a known base directory.
Workspace archives (persist / hydrate) are transferred through the runtime file API
(files().read() / files().write()) when fileApiBaseDir is
configured; when it is blank, transfers fall back to base64 payloads over exec.
Single-file transfers requested by the harness filesystem (SandboxFileTransfer)
also go through the file API for paths under fileApiBaseDir.
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public KubernetesSandbox(KubernetesSandboxState state, Sandbox sdkSandbox) | 初始化 `KubernetesSandbox` 实例。 Creates a new instance. |
方法摘要Method Summary
构造器详情Constructor Detail
KubernetesSandbox
public KubernetesSandbox(KubernetesSandboxState state, Sandbox sdkSandbox)
初始化 KubernetesSandbox 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
state | KubernetesSandboxState | 状态对象(类型 `KubernetesSandboxState`)。The state. |
sdkSandbox | Sandbox | sdk 沙箱(类型 `Sandbox`)。The sdk sandbox. |
io/agentscope/extensions/sandbox/kubernetes/KubernetesSandbox.java:58–62方法详情Method Detail
shutdown
public void shutdown() throws Exception
关闭资源并释放连接。
Releases resources and connections.
Exception可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/extensions/sandbox/kubernetes/KubernetesSandbox.java:64–86doExec
protected ExecResult doExec(RuntimeContext runtimeContext, String command, int timeoutSeconds) throws Exception
执行 doExec 回调。
Performs the do exec operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
runtimeContext | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The runtime context. |
command | String | 命令(类型 `String`)。The command. |
timeoutSeconds | int | 超时秒(类型 `int`)。The timeout seconds. |
ExecResultException可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/extensions/sandbox/kubernetes/KubernetesSandbox.java:88–109doPersistWorkspace
protected InputStream doPersistWorkspace() throws Exception
执行 doPersistWorkspace 回调。
Returns the do persist workspace.
InputStreamException可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/extensions/sandbox/kubernetes/KubernetesSandbox.java:111–127doHydrateWorkspace
protected void doHydrateWorkspace(InputStream archive) throws Exception
执行 doHydrateWorkspace 回调。
Performs the do hydrate workspace operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
archive | InputStream | 归档(类型 `InputStream`)。The archive. |
Exception可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/extensions/sandbox/kubernetes/KubernetesSandbox.java:169–180doSetupWorkspace
protected void doSetupWorkspace() throws Exception
执行 doSetupWorkspace 回调。
Returns the do setup workspace.
Exception可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/extensions/sandbox/kubernetes/KubernetesSandbox.java:232–235doDestroyWorkspace
protected void doDestroyWorkspace() throws Exception
执行 doDestroyWorkspace 回调。
Returns the do destroy workspace.
Exception可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/extensions/sandbox/kubernetes/KubernetesSandbox.java:237–247getWorkspaceRoot
protected String getWorkspaceRoot()
获取工作区根。
Returns the workspace root.
Stringio/agentscope/extensions/sandbox/kubernetes/KubernetesSandbox.java:249–252getSdkSandbox
public Sandbox getSdkSandbox()
获取 getSdkSandbox。
Returns the underlying SDK sandbox handle.
Sandboxio/agentscope/extensions/sandbox/kubernetes/KubernetesSandbox.java:259–261supportsFileTransfer
public boolean supportsFileTransfer(String absolutePath)
设置该参数。
Performs the supports file transfer operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
absolutePath | String | absolute 路径(类型 `String`)。The absolute path. |
booleanio/agentscope/extensions/sandbox/kubernetes/KubernetesSandbox.java:263–266uploadFile
public void uploadFile(String absolutePath, byte[] content) throws Exception
执行上传文件相关操作。
Performs the upload file operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
absolutePath | String | absolute 路径(类型 `String`)。The absolute path. |
content | byte[] | 内容(类型 `byte[]`)。The content. |
Exception可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/extensions/sandbox/kubernetes/KubernetesSandbox.java:268–285downloadFile
public byte[] downloadFile(String absolutePath) throws Exception
设置下载文件。
Performs the download file operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
absolutePath | String | absolute 路径(类型 `String`)。The absolute path. |
byte[]Exception可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/extensions/sandbox/kubernetes/KubernetesSandbox.java:287–290