AS AgentScopeAPI 手册 / API Reference

AgentSpecCodec

public final class AgentSpecCodec
源码Source io/agentscope/builder/web/catalog/spec/AgentSpecCodec.java:34–357

智能体规格编解码器,承载智能体的部署、调度与服务化运行。位于 io.agentscope.builder.web.catalog.spec 包。核心成员包括 defaultToolsets、toToolsConfig、toPermissionPolicyMap、toHarnessToolName、toolsetsFromAllowList、workspaceSkills。

Converts Agent body tool/MCP/skills structures to harness ToolsConfig and policy maps.

方法摘要Method Summary

方法Method说明Description
public static List<AgentToolset> defaultToolsets()
static
返回 `defaultToolsets` 结果。
Default toolset: all builtins enabled, always_allow.
public static ToolsConfig toToolsConfig(List<AgentToolset> tools, List<McpServerSpec> mcpServers)
static
执行到工具配置相关操作。
Derives harness `tools.json` content from Agent body toolsets + mcpServers.
public static Map<String, String> toPermissionPolicyMap(List<AgentToolset> tools)
static
设置到权限策略映射。
Flattens per-tool permission policies for ToolConfirmationMiddleware.
public static String toHarnessToolName(String productName)
static
设置该参数。
Maps product catalog tool ids (Claude-aligned names and legacy aliases) to Harness tool names.
public static List<AgentToolset> toolsetsFromAllowList(List<String> allow)
static
设置该参数。
Builds agent_toolset from a flat allow list (e.g.
public static List<SkillRef> workspaceSkills(List<String> names)
static
设置工作区技能。
Performs the workspace skills operation.
public static List<String> workspaceSkillNames(List<SkillRef> skills)
static
设置该参数。
Performs the workspace skill names operation.
public static String writeJson(Object value)
static
设置写入 JSON。
Performs the write json operation.
public static T T readJson(String json, TypeReference<T> type)
static
执行读取 JSON相关操作。
Performs the read json operation.
public static List<AgentToolset> readTools(String json)
static
设置读取工具。
Performs the read tools operation.
public static List<McpServerSpec> readMcpServers(String json)
static
设置该参数。
Performs the read mcp servers operation.
public static List<SkillRef> readSkills(String json)
static
设置读取技能。
Performs the read skills operation.
public static AgentSpecTypes.MultiagentSpec readMultiagent(String json)
static
设置读取多智能体。
Performs the read multiagent operation.

方法详情Method Detail

defaultToolsets

public static List<AgentToolset> defaultToolsets()
static

返回 defaultToolsets 结果。

Default toolset: all builtins enabled, always_allow.

返回Returns List<AgentToolset>
返回列出。Returns list.
源码Source io/agentscope/builder/web/catalog/spec/AgentSpecCodec.java:41–49

toToolsConfig

public static ToolsConfig toToolsConfig(List<AgentToolset> tools, List<McpServerSpec> mcpServers)
static

执行到工具配置相关操作。

Derives harness tools.json content from Agent body toolsets + mcpServers.

参数Parameters
名称Name类型Type说明Description
toolsList<AgentToolset>工具列表(类型 `List`)。The tools.
mcpServersList<McpServerSpec>MCP Servers(类型 `List`)。The mcp servers.
返回Returns ToolsConfig
返回ToolsConfig。Returns tools config.
源码Source io/agentscope/builder/web/catalog/spec/AgentSpecCodec.java:52–157

toPermissionPolicyMap

public static Map<String, String> toPermissionPolicyMap(List<AgentToolset> tools)
static

设置到权限策略映射。

Flattens per-tool permission policies for ToolConfirmationMiddleware.

参数Parameters
名称Name类型Type说明Description
toolsList<AgentToolset>工具列表(类型 `List`)。The tools.
返回Returns Map<String, String>
返回映射。Returns map.
源码Source io/agentscope/builder/web/catalog/spec/AgentSpecCodec.java:160–199

toHarnessToolName

public static String toHarnessToolName(String productName)
static

设置该参数。

Maps product catalog tool ids (Claude-aligned names and legacy aliases) to Harness tool names.

参数Parameters
名称Name类型Type说明Description
productNameStringproduct 名称(类型 `String`)。The product name.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/builder/web/catalog/spec/AgentSpecCodec.java:205–219

toolsetsFromAllowList

public static List<AgentToolset> toolsetsFromAllowList(List<String> allow)
static

设置该参数。

Builds agent_toolset from a flat allow list (e.g.

参数Parameters
名称Name类型Type说明Description
allowList<String>allow(类型 `List`)。The allow.
返回Returns List<AgentToolset>
返回列出。Returns list.
源码Source io/agentscope/builder/web/catalog/spec/AgentSpecCodec.java:222–242

workspaceSkills

public static List<SkillRef> workspaceSkills(List<String> names)
static

设置工作区技能。

Performs the workspace skills operation.

参数Parameters
名称Name类型Type说明Description
namesList<String>names(类型 `List`)。The names.
返回Returns List<SkillRef>
返回列出。Returns list.
源码Source io/agentscope/builder/web/catalog/spec/AgentSpecCodec.java:244–256

workspaceSkillNames

public static List<String> workspaceSkillNames(List<SkillRef> skills)
static

设置该参数。

Performs the workspace skill names operation.

参数Parameters
名称Name类型Type说明Description
skillsList<SkillRef>技能(类型 `List`)。The skills.
返回Returns List<String>
返回列出。Returns list.
源码Source io/agentscope/builder/web/catalog/spec/AgentSpecCodec.java:258–279

writeJson

public static String writeJson(Object value)
static

设置写入 JSON。

Performs the write json operation.

参数Parameters
名称Name类型Type说明Description
valueObject值(类型 `Object`)。The value.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/builder/web/catalog/spec/AgentSpecCodec.java:281–290

readJson

public static T T readJson(String json, TypeReference<T> type)
static

执行读取 JSON相关操作。

Performs the read json operation.

参数Parameters
名称Name类型Type说明Description
jsonStringJSON(类型 `String`)。The json.
typeTypeReference<T>类型(类型 `TypeReference`)。The type.
返回Returns T
返回T。Returns t.
源码Source io/agentscope/builder/web/catalog/spec/AgentSpecCodec.java:292–301

readTools

public static List<AgentToolset> readTools(String json)
static

设置读取工具。

Performs the read tools operation.

参数Parameters
名称Name类型Type说明Description
jsonStringJSON(类型 `String`)。The json.
返回Returns List<AgentToolset>
返回列出。Returns list.
源码Source io/agentscope/builder/web/catalog/spec/AgentSpecCodec.java:303–306

readMcpServers

public static List<McpServerSpec> readMcpServers(String json)
static

设置该参数。

Performs the read mcp servers operation.

参数Parameters
名称Name类型Type说明Description
jsonStringJSON(类型 `String`)。The json.
返回Returns List<McpServerSpec>
返回列出。Returns list.
源码Source io/agentscope/builder/web/catalog/spec/AgentSpecCodec.java:308–311

readSkills

public static List<SkillRef> readSkills(String json)
static

设置读取技能。

Performs the read skills operation.

参数Parameters
名称Name类型Type说明Description
jsonStringJSON(类型 `String`)。The json.
返回Returns List<SkillRef>
返回列出。Returns list.
源码Source io/agentscope/builder/web/catalog/spec/AgentSpecCodec.java:313–316

readMultiagent

public static AgentSpecTypes.MultiagentSpec readMultiagent(String json)
static

设置读取多智能体。

Performs the read multiagent operation.

参数Parameters
名称Name类型Type说明Description
jsonStringJSON(类型 `String`)。The json.
返回Returns AgentSpecTypes.MultiagentSpec
返回AgentSpecTypes.MultiagentSpec。Returns agent spec types multiagent spec.
源码Source io/agentscope/builder/web/catalog/spec/AgentSpecCodec.java:318–320
基于官方固定版本源码静态生成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.