WorkspaceSandbox
public final class WorkspaceSandbox implements Sandbox
io/agentscope/builder/web/managed/WorkspaceSandbox.java:40–168工作区沙箱,承载智能体的部署、调度与服务化运行。位于 io.agentscope.builder.web.managed 包,实现 Sandbox。核心成员包括 workDir、start、stop、shutdown、close、isRunning。
Docker-less Sandbox backed by a plain host directory, registered by an Environment
Worker (via the worker REST API) as the
Priority-1 externalSandbox for a self_hosted managed session.
The harness never calls #stop()/#shutdown() on a Priority-1 sandbox (see
SandboxManager.release) — the registering worker owns the full lifecycle, including
deleting #workDir() once the session is done with it. #start() is called once
per turn by SandboxLifecycleMiddleware and is idempotent.
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public WorkspaceSandbox(String sessionId, Path workDir) | 初始化 `WorkspaceSandbox` 实例。 Creates a new instance. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public Path workDir() | 返回 `workDir` 结果。 Host directory backing this sandbox's shell execution and (indirectly) its filesystem. |
public void start() throws Exception | 执行启动相关操作。 Returns the start. |
public void stop() throws Exception | 执行停止相关操作。 Returns the stop. |
public void shutdown() throws Exception | 关闭资源并释放连接。 Releases resources and connections. |
public void close() throws Exception | 关闭连接并释放相关资源。 Releases resources and connections. |
public boolean isRunning() | 判断是否运行中。 Returns whether the running. |
public SandboxState getState() | 获取状态。 Returns the state. |
public ExecResult exec(RuntimeContext runtimeContext, String command, Integer timeoutSeconds) throws Exception | 执行 `exec` 方法。 Performs the exec operation. |
public InputStream persistWorkspace() throws Exception | 返回 `persistWorkspace` 结果。 Returns the persist workspace. |
public void hydrateWorkspace(InputStream archive) throws Exception | 设置该参数。 Performs the hydrate workspace operation. |
构造器详情Constructor Detail
WorkspaceSandbox
public WorkspaceSandbox(String sessionId, Path workDir)
初始化 WorkspaceSandbox 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sessionId | String | 会话标识(类型 `String`)。The session id. |
workDir | Path | work 目录(类型 `Path`)。The work dir. |
io/agentscope/builder/web/managed/WorkspaceSandbox.java:49–53方法详情Method Detail
workDir
public Path workDir()
返回 workDir 结果。
Host directory backing this sandbox's shell execution and (indirectly) its filesystem.
Pathio/agentscope/builder/web/managed/WorkspaceSandbox.java:56–58start
public void start() throws Exception
执行启动相关操作。
Returns the start.
Exception可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/builder/web/managed/WorkspaceSandbox.java:60–64stop
public void stop() throws Exception
执行停止相关操作。
Returns the stop.
Exception可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/builder/web/managed/WorkspaceSandbox.java:66–69shutdown
public void shutdown() throws Exception
关闭资源并释放连接。
Releases resources and connections.
Exception可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/builder/web/managed/WorkspaceSandbox.java:71–74close
public void close() throws Exception
关闭连接并释放相关资源。
Releases resources and connections.
Exception可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/builder/web/managed/WorkspaceSandbox.java:76–79isRunning
public boolean isRunning()
判断是否运行中。
Returns whether the running.
booleanio/agentscope/builder/web/managed/WorkspaceSandbox.java:81–84getState
public SandboxState getState()
获取状态。
Returns the state.
SandboxStateio/agentscope/builder/web/managed/WorkspaceSandbox.java:86–89exec
public ExecResult exec(RuntimeContext runtimeContext, String command, Integer timeoutSeconds) throws Exception
执行 exec 方法。
Performs the exec operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
runtimeContext | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The runtime context. |
command | String | 命令(类型 `String`)。The command. |
timeoutSeconds | Integer | 超时秒(类型 `Integer`)。The timeout seconds. |
ExecResultException可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/builder/web/managed/WorkspaceSandbox.java:91–126persistWorkspace
public InputStream persistWorkspace() throws Exception
返回 persistWorkspace 结果。
Returns the persist workspace.
InputStreamException可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/builder/web/managed/WorkspaceSandbox.java:152–157hydrateWorkspace
public void hydrateWorkspace(InputStream archive) throws Exception
设置该参数。
Performs the hydrate workspace operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
archive | InputStream | 归档(类型 `InputStream`)。The archive. |
Exception可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/builder/web/managed/WorkspaceSandbox.java:159–164