Sandbox
public class Sandbox implements AutoCloseable
io/agentscope/runtime/sandbox/box/Sandbox.java:33–207沙箱,承载智能体的部署、调度与服务化运行。位于 io.agentscope.runtime.sandbox.box 包,实现 AutoCloseable。核心成员包括 getSandboxId、getUserId、getSessionId、getSandboxType、getEnvironment、getFileSystemStarter。
A class in io.agentscope.runtime.sandbox.box that deploys, schedules and serves agents. Declared in io.agentscope.runtime.sandbox.box. Implements AutoCloseable.
字段摘要Field Summary
| 字段Field | 类型Type | 说明Description |
|---|---|---|
managerApi | SandboxService | 管理器 API字段。 The manager api field. |
sandboxId | String | 沙箱标识字段。 The sandbox id field. |
userId | String | 用户标识字段。 The user id field. |
sessionId | String | 会话标识字段。 The session id field. |
sandboxType | String | 沙箱类型字段。 The sandbox type field. |
closed | boolean | 已关闭字段。 The closed field. |
environment | Map<String, String> | 环境字段。 The environment field. |
fileSystemConfig | FileSystemConfig | 文件系统配置字段。 The file system config field. |
构造器摘要Constructor Summary
方法摘要Method Summary
字段详情Field Detail
managerApi
protected SandboxService managerApi
管理器 API字段。声明为 protected SandboxService managerApi。
The manager api field.
io/agentscope/runtime/sandbox/box/Sandbox.java:36sandboxId
protected String sandboxId
沙箱标识字段。声明为 protected String sandboxId。
The sandbox id field.
io/agentscope/runtime/sandbox/box/Sandbox.java:37userId
protected String userId
用户标识字段。声明为 protected String userId。
The user id field.
io/agentscope/runtime/sandbox/box/Sandbox.java:38sessionId
protected String sessionId
会话标识字段。声明为 protected String sessionId。
The session id field.
io/agentscope/runtime/sandbox/box/Sandbox.java:39sandboxType
protected String sandboxType
沙箱类型字段。声明为 protected String sandboxType。
The sandbox type field.
io/agentscope/runtime/sandbox/box/Sandbox.java:40closed
protected boolean closed
已关闭字段。声明为 protected boolean closed。
The closed field.
io/agentscope/runtime/sandbox/box/Sandbox.java:41environment
protected Map<String, String> environment
环境字段。声明为 protected Map environment。
The environment field.
io/agentscope/runtime/sandbox/box/Sandbox.java:42fileSystemConfig
protected FileSystemConfig fileSystemConfig
文件系统配置字段。声明为 protected FileSystemConfig fileSystemConfig。
The file system config field.
io/agentscope/runtime/sandbox/box/Sandbox.java:43构造器详情Constructor Detail
Sandbox
public Sandbox(String sandboxId, String userId, String sessionId, String sandboxType, FileSystemConfig fileSystemConfig, Map<String, String> environment, boolean closed)
初始化 Sandbox 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sandboxId | String | 沙箱标识(类型 `String`)。The sandbox id. |
userId | String | 用户标识(类型 `String`)。The user id. |
sessionId | String | 会话标识(类型 `String`)。The session id. |
sandboxType | String | 沙箱类型(类型 `String`)。The sandbox type. |
fileSystemConfig | FileSystemConfig | 文件系统配置(类型 `FileSystemConfig`)。The file system config. |
environment | Map<String, String> | 环境(类型 `Map`)。The environment. |
closed | boolean | 已关闭(类型 `boolean`)。The closed. |
io/agentscope/runtime/sandbox/box/Sandbox.java:45–62Sandbox
public Sandbox(SandboxService managerApi, String userId, String sessionId, String sandboxType)
初始化 Sandbox 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
managerApi | SandboxService | 管理器 API(类型 `SandboxService`)。The manager api. |
userId | String | 用户标识(类型 `String`)。The user id. |
sessionId | String | 会话标识(类型 `String`)。The session id. |
sandboxType | String | 沙箱类型(类型 `String`)。The sandbox type. |
io/agentscope/runtime/sandbox/box/Sandbox.java:64–70Sandbox
public Sandbox(SandboxService managerApi, String userId, String sessionId, String sandboxType, FileSystemConfig fileSystemConfig)
初始化 Sandbox 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
managerApi | SandboxService | 管理器 API(类型 `SandboxService`)。The manager api. |
userId | String | 用户标识(类型 `String`)。The user id. |
sessionId | String | 会话标识(类型 `String`)。The session id. |
sandboxType | String | 沙箱类型(类型 `String`)。The sandbox type. |
fileSystemConfig | FileSystemConfig | 文件系统配置(类型 `FileSystemConfig`)。The file system config. |
io/agentscope/runtime/sandbox/box/Sandbox.java:72–79Sandbox
public Sandbox(SandboxService managerApi, String userId, String sessionId, String sandboxType, Map<String, String> environment)
初始化 Sandbox 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
managerApi | SandboxService | 管理器 API(类型 `SandboxService`)。The manager api. |
userId | String | 用户标识(类型 `String`)。The user id. |
sessionId | String | 会话标识(类型 `String`)。The session id. |
sandboxType | String | 沙箱类型(类型 `String`)。The sandbox type. |
environment | Map<String, String> | 环境(类型 `Map`)。The environment. |
io/agentscope/runtime/sandbox/box/Sandbox.java:81–89Sandbox
public Sandbox(SandboxService managerApi, String userId, String sessionId, String sandboxType, FileSystemConfig fileSystemConfig, Map<String, String> environment)
初始化 Sandbox 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
managerApi | SandboxService | 管理器 API(类型 `SandboxService`)。The manager api. |
userId | String | 用户标识(类型 `String`)。The user id. |
sessionId | String | 会话标识(类型 `String`)。The session id. |
sandboxType | String | 沙箱类型(类型 `String`)。The sandbox type. |
fileSystemConfig | FileSystemConfig | 文件系统配置(类型 `FileSystemConfig`)。The file system config. |
environment | Map<String, String> | 环境(类型 `Map`)。The environment. |
io/agentscope/runtime/sandbox/box/Sandbox.java:91–105方法详情Method Detail
getSandboxId
public String getSandboxId()
获取沙箱标识。
Returns the sandbox id.
Stringio/agentscope/runtime/sandbox/box/Sandbox.java:107–109getUserId
public String getUserId()
获取用户标识。
Returns the user id.
Stringio/agentscope/runtime/sandbox/box/Sandbox.java:111–113getSessionId
public String getSessionId()
获取会话标识。
Returns the session id.
Stringio/agentscope/runtime/sandbox/box/Sandbox.java:115–117getSandboxType
public String getSandboxType()
获取沙箱类型。
Returns the sandbox type.
Stringio/agentscope/runtime/sandbox/box/Sandbox.java:119–121getEnvironment
public Map<String, String> getEnvironment()
获取环境。
Returns the environment.
Map<String, String>io/agentscope/runtime/sandbox/box/Sandbox.java:123–125getFileSystemStarter
public FileSystemConfig getFileSystemStarter()
获取文件系统启动器。
Returns the file system starter.
FileSystemConfigio/agentscope/runtime/sandbox/box/Sandbox.java:127–129getInfo
public ContainerModel getInfo()
获取信息。
Returns the info.
ContainerModelio/agentscope/runtime/sandbox/box/Sandbox.java:149–153listTools
public Map<String, Object> listTools()
列出工具。
Lists the tools.
Map<String, Object>io/agentscope/runtime/sandbox/box/Sandbox.java:155–157listTools
public Map<String, Object> listTools(String toolType)
列出工具。
Lists the tools.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
toolType | String | 工具类型(类型 `String`)。The tool type. |
Map<String, Object>io/agentscope/runtime/sandbox/box/Sandbox.java:159–162callTool
public String callTool(String name, Map<String, Object> arguments)
调用工具。
Calls the tool.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
name | String | 名称(类型 `String`)。The name. |
arguments | Map<String, Object> | 参数(类型 `Map`)。The arguments. |
Stringio/agentscope/runtime/sandbox/box/Sandbox.java:164–167addMcpServers
public Map<String, Object> addMcpServers(Map<String, Object> serverConfigs)
添加 addMcpServers。
Adds the mcp servers.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
serverConfigs | Map<String, Object> | 服务端 Configs(类型 `Map`)。The server configs. |
Map<String, Object>io/agentscope/runtime/sandbox/box/Sandbox.java:169–171addMcpServers
public Map<String, Object> addMcpServers(Map<String, Object> serverConfigs, boolean overwrite)
添加 addMcpServers。
Adds the mcp servers.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
serverConfigs | Map<String, Object> | 服务端 Configs(类型 `Map`)。The server configs. |
overwrite | boolean | overwrite(类型 `boolean`)。The overwrite. |
Map<String, Object>io/agentscope/runtime/sandbox/box/Sandbox.java:173–176close
public void close()
关闭连接并释放相关资源。
Releases resources and connections.
io/agentscope/runtime/sandbox/box/Sandbox.java:178–194release
public void release()
关闭资源并释放连接。
Manually release sandbox resources Forces release of underlying container regardless of autoRelease setting
io/agentscope/runtime/sandbox/box/Sandbox.java:200–202isClosed
public boolean isClosed()
判断是否已关闭。
Returns whether the closed.
booleanio/agentscope/runtime/sandbox/box/Sandbox.java:204–206