AS AgentScopeAPI 手册 / API Reference

SandboxRegistry

public class SandboxRegistry
源码Source io/agentscope/runtime/sandbox/manager/registry/SandboxRegistry.java:31–354

沙箱注册表,承载智能体的部署、调度与服务化运行。位于 io.agentscope.runtime.sandbox.manager.registry 包。核心成员包括 register、getConfig、getConfigByType、getImage、getImageByType、getClassesByType。

Sandbox registry for managing sandbox configurations

方法摘要Method Summary

方法Method说明Description
public static void register(Class<?> targetClass, SandboxConfig config)
static
用于特定类和类型的注册沙箱配置。
Register a sandbox configuration for a specific class and type
public static void register(SandboxType sandboxType, String imageName)
static
执行注册相关操作。
Register a sandbox configuration by type This is a simplified registration method that doesn't require a class
public static void register(SandboxType sandboxType, String imageName, Map<String, Object> resourceLimits, String securityLevel, int timeout, String description, Map<String, String> environment, Map<String, Object> runtimeConfig)
static
执行注册相关操作。
Register a sandbox with full configuration
public static Optional<SandboxConfig> getConfig(Class<?> targetClass)
static
获取沙箱配置通过。
Get sandbox configuration by class
public static Optional<SandboxConfig> getConfigByType(SandboxType sandboxType)
static
获取沙箱配置通过类型。
Get sandbox configuration by type
public static Optional<String> getImage(Class<?> targetClass)
static
获取图像。
Get Docker image name by class
public static Optional<String> getImageByType(SandboxType sandboxType)
static
获取图像通过类型。
Get Docker image name by sandbox type
public static Optional<Class<?>> getClassesByType(SandboxType sandboxType)
static
获取类通过沙箱类型。
Get class by sandbox type
public static Map<Class<?>, SandboxConfig> listAllSandboxes()
static
列出 `listAllSandboxes`。
List all registered sandboxes (class-based registrations)
public static Map<SandboxType, SandboxConfig> listAllSandboxesByType()
static
列出 `listAllSandboxesByType`。
List all registered sandbox configurations by type
public static boolean isRegistered(SandboxType sandboxType)
static
检查if 沙箱类型是已注册。
Check if a sandbox type is registered
public static boolean unregister(SandboxType sandboxType)
static
设置注销。
Unregister a sandbox type
public static void clear()
static
清空或重置内部状态。
Clear all registrations
public static int getRegisteredCount()
static
获取已注册数量。
Get the count of registered sandboxes
public static void registerCustomType(String typeName, String imageName)
static
注册自定义类型。
Register a custom sandbox type by string name This supports dynamic type registration.
public static void registerCustomType(String typeName, String imageName, Map<String, Object> resourceLimits, String securityLevel, int timeout, String description, Map<String, String> environment, Map<String, Object> runtimeConfig)
static
注册自定义类型。
Register a custom sandbox type with full configuration
public static Optional<SandboxConfig> getCustomTypeConfig(String typeName)
static
获取配置用于自定义沙箱类型通过名称。
Get configuration for a custom sandbox type by name
public static Optional<String> getCustomTypeImage(String typeName)
static
获取图像名称用于自定义沙箱类型。
Get image name for a custom sandbox type
public static boolean isCustomTypeRegistered(String typeName)
static
检查if 自定义类型是已注册。
Check if a custom type is registered
public static Map<String, SandboxConfig> listAllCustomTypes()
static
列出所有自定义类型。
List all registered custom sandbox types

方法详情Method Detail

register

public static void register(Class<?> targetClass, SandboxConfig config)
static

用于特定类和类型的注册沙箱配置。

Register a sandbox configuration for a specific class and type

参数Parameters
名称Name类型Type说明Description
targetClassClass<?>类到注册。The class to register
configSandboxConfig沙箱配置。The sandbox configuration
源码Source io/agentscope/runtime/sandbox/manager/registry/SandboxRegistry.java:55–72

register

public static void register(SandboxType sandboxType, String imageName)
static

执行注册相关操作。

Register a sandbox configuration by type This is a simplified registration method that doesn't require a class

参数Parameters
名称Name类型Type说明Description
sandboxTypeSandboxType沙箱类型。The sandbox type
imageNameString图像名称(类型 `String`)。The Docker image name
源码Source io/agentscope/runtime/sandbox/manager/registry/SandboxRegistry.java:81–89

register

public static void register(SandboxType sandboxType, String imageName, Map<String, Object> resourceLimits, String securityLevel, int timeout, String description, Map<String, String> environment, Map<String, Object> runtimeConfig)
static

执行注册相关操作。

Register a sandbox with full configuration

参数Parameters
名称Name类型Type说明Description
sandboxTypeSandboxType沙箱类型。The sandbox type
imageNameString图像名称(类型 `String`)。The Docker image name
resourceLimitsMap<String, Object>资源 Limits(类型 `Map`)。Resource limits
securityLevelStringsecurity 级别(类型 `String`)。Security level
timeoutint超时时间(类型 `int`)。Timeout in seconds
descriptionString描述(类型 `String`)。Description
environmentMap<String, String>环境(类型 `Map`)。Environment variables
runtimeConfigMap<String, Object>运行时配置(类型 `Map`)。Runtime configuration
源码Source io/agentscope/runtime/sandbox/manager/registry/SandboxRegistry.java:103–129

getConfig

public static Optional<SandboxConfig> getConfig(Class<?> targetClass)
static

获取沙箱配置通过。

Get sandbox configuration by class

参数Parameters
名称Name类型Type说明Description
targetClassClass<?>目标类。The target class
返回Returns Optional<SandboxConfig>
返回可选。Optional containing the configuration if found
源码Source io/agentscope/runtime/sandbox/manager/registry/SandboxRegistry.java:137–139

getConfigByType

public static Optional<SandboxConfig> getConfigByType(SandboxType sandboxType)
static

获取沙箱配置通过类型。

Get sandbox configuration by type

参数Parameters
名称Name类型Type说明Description
sandboxTypeSandboxType沙箱类型。The sandbox type
返回Returns Optional<SandboxConfig>
返回可选。Optional containing the configuration if found
源码Source io/agentscope/runtime/sandbox/manager/registry/SandboxRegistry.java:147–149

getImage

public static Optional<String> getImage(Class<?> targetClass)
static

获取图像。

Get Docker image name by class

参数Parameters
名称Name类型Type说明Description
targetClassClass<?>目标类。The target class
返回Returns Optional<String>
返回可选。Optional containing the image name if found
源码Source io/agentscope/runtime/sandbox/manager/registry/SandboxRegistry.java:157–159

getImageByType

public static Optional<String> getImageByType(SandboxType sandboxType)
static

获取图像通过类型。

Get Docker image name by sandbox type

参数Parameters
名称Name类型Type说明Description
sandboxTypeSandboxType沙箱类型。The sandbox type
返回Returns Optional<String>
返回可选。Optional containing the image name if found
源码Source io/agentscope/runtime/sandbox/manager/registry/SandboxRegistry.java:167–169

getClassesByType

public static Optional<Class<?>> getClassesByType(SandboxType sandboxType)
static

获取类通过沙箱类型。

Get class by sandbox type

参数Parameters
名称Name类型Type说明Description
sandboxTypeSandboxType沙箱类型。The sandbox type
返回Returns Optional<Class<?>>
返回可选>。Optional containing the class if found
源码Source io/agentscope/runtime/sandbox/manager/registry/SandboxRegistry.java:177–179

listAllSandboxes

public static Map<Class<?>, SandboxConfig> listAllSandboxes()
static

列出 listAllSandboxes。

List all registered sandboxes (class-based registrations)

返回Returns Map<Class<?>, SandboxConfig>
返回映射,SandboxConfig>。A copy of the registry
源码Source io/agentscope/runtime/sandbox/manager/registry/SandboxRegistry.java:186–188

listAllSandboxesByType

public static Map<SandboxType, SandboxConfig> listAllSandboxesByType()
static

列出 listAllSandboxesByType。

List all registered sandbox configurations by type

返回Returns Map<SandboxType, SandboxConfig>
返回映射。A copy of the type-based registry
源码Source io/agentscope/runtime/sandbox/manager/registry/SandboxRegistry.java:195–197

isRegistered

public static boolean isRegistered(SandboxType sandboxType)
static

检查if 沙箱类型是已注册。

Check if a sandbox type is registered

参数Parameters
名称Name类型Type说明Description
sandboxTypeSandboxType沙箱类型到检查。The sandbox type to check
返回Returns boolean
返回布尔值,表示判断结果。true if registered, false otherwise
源码Source io/agentscope/runtime/sandbox/manager/registry/SandboxRegistry.java:205–207

unregister

public static boolean unregister(SandboxType sandboxType)
static

设置注销。

Unregister a sandbox type

参数Parameters
名称Name类型Type说明Description
sandboxTypeSandboxType沙箱类型到注销。The sandbox type to unregister
返回Returns boolean
返回布尔值,表示判断结果。true if unregistered successfully, false if not found
源码Source io/agentscope/runtime/sandbox/manager/registry/SandboxRegistry.java:215–227

clear

public static void clear()
static

清空或重置内部状态。

Clear all registrations

源码Source io/agentscope/runtime/sandbox/manager/registry/SandboxRegistry.java:232–238

getRegisteredCount

public static int getRegisteredCount()
static

获取已注册数量。

Get the count of registered sandboxes

返回Returns int
已注册沙箱类型的数量。Number of registered sandbox types
源码Source io/agentscope/runtime/sandbox/manager/registry/SandboxRegistry.java:245–247

registerCustomType

public static void registerCustomType(String typeName, String imageName)
static

注册自定义类型。

Register a custom sandbox type by string name This supports dynamic type registration.

参数Parameters
名称Name类型Type说明Description
typeNameString自定义类型名称。The custom type name
imageNameString图像名称(类型 `String`)。The Docker image name
源码Source io/agentscope/runtime/sandbox/manager/registry/SandboxRegistry.java:256–266

registerCustomType

public static void registerCustomType(String typeName, String imageName, Map<String, Object> resourceLimits, String securityLevel, int timeout, String description, Map<String, String> environment, Map<String, Object> runtimeConfig)
static

注册自定义类型。

Register a custom sandbox type with full configuration

参数Parameters
名称Name类型Type说明Description
typeNameString自定义类型名称。The custom type name
imageNameString图像名称(类型 `String`)。The Docker image name
resourceLimitsMap<String, Object>资源 Limits(类型 `Map`)。Resource limits
securityLevelStringsecurity 级别(类型 `String`)。Security level
timeoutint超时时间(类型 `int`)。Timeout in seconds
descriptionString描述(类型 `String`)。Description
environmentMap<String, String>环境(类型 `Map`)。Environment variables
runtimeConfigMap<String, Object>运行时配置(类型 `Map`)。Runtime configuration
源码Source io/agentscope/runtime/sandbox/manager/registry/SandboxRegistry.java:280–308

getCustomTypeConfig

public static Optional<SandboxConfig> getCustomTypeConfig(String typeName)
static

获取配置用于自定义沙箱类型通过名称。

Get configuration for a custom sandbox type by name

参数Parameters
名称Name类型Type说明Description
typeNameString自定义类型名称。The custom type name
返回Returns Optional<SandboxConfig>
返回可选。Optional containing the configuration if found
源码Source io/agentscope/runtime/sandbox/manager/registry/SandboxRegistry.java:316–321

getCustomTypeImage

public static Optional<String> getCustomTypeImage(String typeName)
static

获取图像名称用于自定义沙箱类型。

Get image name for a custom sandbox type

参数Parameters
名称Name类型Type说明Description
typeNameString自定义类型名称。The custom type name
返回Returns Optional<String>
返回可选。Optional containing the image name if found
源码Source io/agentscope/runtime/sandbox/manager/registry/SandboxRegistry.java:329–331

isCustomTypeRegistered

public static boolean isCustomTypeRegistered(String typeName)
static

检查if 自定义类型是已注册。

Check if a custom type is registered

参数Parameters
名称Name类型Type说明Description
typeNameString自定义类型名称。The custom type name
返回Returns boolean
返回布尔值,表示判断结果。true if registered, false otherwise
源码Source io/agentscope/runtime/sandbox/manager/registry/SandboxRegistry.java:339–344

listAllCustomTypes

public static Map<String, SandboxConfig> listAllCustomTypes()
static

列出所有自定义类型。

List all registered custom sandbox types

返回Returns Map<String, SandboxConfig>
返回映射。A copy of the custom type registry
源码Source io/agentscope/runtime/sandbox/manager/registry/SandboxRegistry.java:351–353
基于官方固定版本源码静态生成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.