AS AgentScopeAPI 手册 / API Reference

NacosSkillRepository

public class NacosSkillRepository implements AgentSkillRepository
源码Source io/agentscope/core/nacos/skill/NacosSkillRepository.java:74–549

Nacos 技能仓库,负责持久化与读取数据。位于 io.agentscope.core.nacos.skill 包,实现 AgentSkillRepository。核心成员包括 getSkill、skillExists、getRepositoryInfo、getSource、setWriteable、isWriteable。

AgentSkillRepository backed by Nacos AI skill packages.

Loading: Downloads the skill ZIP through AiService, then builds AgentSkill from it (including SKILL.md). Indented YAML frontmatter in Nacos exports is normalized so AgentScope's flat key: value parser can read it. API choice: AiService#downloadSkillZipByVersion(String, String) if a version is set; else AiService#downloadSkillZipByLabel(String, String) if only a label is set; else AiService#downloadSkillZip(String). When both version and label resolve, version wins and the label is not used for download.

Capabilities: Read operations work: #getSkill(String), #skillExists(String), #getRepositoryInfo(), #getSource(), #isWriteable() (always false). Writes are unsupported: #save(List, boolean) and #delete(String) do nothing; #setWriteable(boolean) is ignored. These paths log a warning.

Listing: Nacos AI Service has no "list all skills" API. When constructed without knownSkillNames, #getAllSkillNames() and #getAllSkills() return empty results and log a warning. Pass a non-empty knownSkillNames list to the #NacosSkillRepository(AiService, String, Properties, List) constructor to enable enumeration — #getAllSkills() will then fetch each skill via #getSkill(String) in sequence (one network call per skill; prefer MysqlSkillRepository for large catalogues).

Version and label resolution: Independently for version and for label, the first non-blank value wins, in order: (1) Properties from #NacosSkillRepository(AiService, String, Properties), (2) JVM system property #SKILL_VERSION_PATH or #SKILL_LABEL_PATH, (3) environment variable #ENV_SKILL_VERSION_PATH or #ENV_SKILL_LABEL_PATH.

字段摘要Field Summary

字段Field类型Type说明Description
SKILL_VERSION_PATH
staticfinal
String
技能版本路径字段。
Key for skill version in `Properties`, JVM `System#getProperty(String)`, etc.
SKILL_LABEL_PATH
staticfinal
String
技能标签路径字段。
Key for skill label in `Properties`, JVM `System#getProperty(String)`, etc.
ENV_SKILL_VERSION_PATH
staticfinal
String
ENV 技能版本路径字段。
Environment variable name for skill version (fallback after properties and JVM).
ENV_SKILL_LABEL_PATH
staticfinal
String
ENV 技能标签路径字段。
Environment variable name for skill label (fallback after properties and JVM).

构造器摘要Constructor Summary

构造器Constructor说明Description
public NacosSkillRepository(AiService aiService, String namespaceId)
初始化 `NacosSkillRepository` 实例。
Same as `#NacosSkillRepository(AiService, String, Properties)` with `properties == null`.
public NacosSkillRepository(AiService aiService, String namespaceId, Properties properties)
初始化 `NacosSkillRepository` 实例。
Same as `#NacosSkillRepository(AiService, String, Properties, List)` with an empty `knownSkillNames`.
public NacosSkillRepository(AiService aiService, String namespaceId, Properties properties, List<String> knownSkillNames)
初始化 `NacosSkillRepository` 实例。
Creates a repository for the given Nacos namespace; resolves skill version and label once (see class Javadoc for precedence).

方法摘要Method Summary

方法Method说明Description
public AgentSkill getSkill(String name)
获取技能。
Returns the skill.
public boolean skillExists(String skillName)
设置该参数。
Performs the skill exists operation.
public AgentSkillRepositoryInfo getRepositoryInfo()
获取仓库信息。
Returns the repository info.
public String getSource()
获取来源。
Returns the source.
public void setWriteable(boolean writeable)
设置 `setWriteable`。
Sets the writeable.
public boolean isWriteable()
判断是否 `isWriteable`。
Returns whether the writeable.
public List<String> getAllSkillNames()
获取 `getAllSkillNames`。
Returns the all skill names.
public List<AgentSkill> getAllSkills()
获取所有技能。
Returns the all skills.
public boolean save(List<AgentSkill> skills, boolean force)
保存数据到持久化存储。
Performs the save operation.
public boolean delete(String skillName)
删除数据。
Performs the delete operation.
public void close()
关闭连接并释放相关资源。
Releases resources and connections.

字段详情Field Detail

SKILL_VERSION_PATH

public static final String SKILL_VERSION_PATH
staticfinal

技能版本路径字段。声明为 public static final String SKILL_VERSION_PATH。

Key for skill version in Properties, JVM System#getProperty(String), etc.

源码Source io/agentscope/core/nacos/skill/NacosSkillRepository.java:91

SKILL_LABEL_PATH

public static final String SKILL_LABEL_PATH
staticfinal

技能标签路径字段。声明为 public static final String SKILL_LABEL_PATH。

Key for skill label in Properties, JVM System#getProperty(String), etc.

源码Source io/agentscope/core/nacos/skill/NacosSkillRepository.java:94

ENV_SKILL_VERSION_PATH

public static final String ENV_SKILL_VERSION_PATH
staticfinal

ENV 技能版本路径字段。声明为 public static final String ENV_SKILL_VERSION_PATH。

Environment variable name for skill version (fallback after properties and JVM).

源码Source io/agentscope/core/nacos/skill/NacosSkillRepository.java:97

ENV_SKILL_LABEL_PATH

public static final String ENV_SKILL_LABEL_PATH
staticfinal

ENV 技能标签路径字段。声明为 public static final String ENV_SKILL_LABEL_PATH。

Environment variable name for skill label (fallback after properties and JVM).

源码Source io/agentscope/core/nacos/skill/NacosSkillRepository.java:100

构造器详情Constructor Detail

NacosSkillRepository

public NacosSkillRepository(AiService aiService, String namespaceId)

初始化 NacosSkillRepository 实例。

Same as #NacosSkillRepository(AiService, String, Properties) with properties == null.

参数Parameters
名称Name类型Type说明Description
aiServiceAiServiceai 服务(类型 `AiService`)。The ai service.
namespaceIdString命名空间标识(类型 `String`)。The namespace id.
源码Source io/agentscope/core/nacos/skill/NacosSkillRepository.java:114–116

NacosSkillRepository

public NacosSkillRepository(AiService aiService, String namespaceId, Properties properties)

初始化 NacosSkillRepository 实例。

Same as #NacosSkillRepository(AiService, String, Properties, List) with an empty knownSkillNames.

参数Parameters
名称Name类型Type说明Description
aiServiceAiServiceai 服务(类型 `AiService`)。The ai service.
namespaceIdString命名空间标识(类型 `String`)。The namespace id.
propertiesProperties属性(类型 `Properties`)。The properties.
源码Source io/agentscope/core/nacos/skill/NacosSkillRepository.java:122–124

NacosSkillRepository

public NacosSkillRepository(AiService aiService, String namespaceId, Properties properties, List<String> knownSkillNames)

初始化 NacosSkillRepository 实例。

Creates a repository for the given Nacos namespace; resolves skill version and label once (see class Javadoc for precedence).

参数Parameters
名称Name类型Type说明Description
aiServiceAiServiceai 服务(类型 `AiService`)。the Nacos AI service (must not be null)
namespaceIdString命名空间标识(类型 `String`)。the Nacos namespace id (blank treated as `public`)
propertiesProperties属性(类型 `Properties`)。optional application properties; may be `null`
knownSkillNamesList<String>known 技能 Names(类型 `List`)。skill names to expose via `#getAllSkillNames()` and `#getAllSkills()`; pass empty list to keep the no-op behaviour
源码Source io/agentscope/core/nacos/skill/NacosSkillRepository.java:136–168

方法详情Method Detail

getSkill

public AgentSkill getSkill(String name)

获取技能。

Returns the skill.

参数Parameters
名称Name类型Type说明Description
nameString名称(类型 `String`)。The name.
返回Returns AgentSkill
返回AgentSkill。Returns agent skill.
源码Source io/agentscope/core/nacos/skill/NacosSkillRepository.java:170–188

skillExists

public boolean skillExists(String skillName)

设置该参数。

Performs the skill exists operation.

参数Parameters
名称Name类型Type说明Description
skillNameString技能名称(类型 `String`)。The skill name.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/core/nacos/skill/NacosSkillRepository.java:190–205

getRepositoryInfo

public AgentSkillRepositoryInfo getRepositoryInfo()

获取仓库信息。

Returns the repository info.

返回Returns AgentSkillRepositoryInfo
返回AgentSkillRepositoryInfo。Returns agent skill repository info.
源码Source io/agentscope/core/nacos/skill/NacosSkillRepository.java:207–210

getSource

public String getSource()

获取来源。

Returns the source.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/core/nacos/skill/NacosSkillRepository.java:212–215

setWriteable

public void setWriteable(boolean writeable)

设置 setWriteable。

Sets the writeable.

参数Parameters
名称Name类型Type说明Description
writeablebooleanwriteable(类型 `boolean`)。The writeable.
源码Source io/agentscope/core/nacos/skill/NacosSkillRepository.java:217–220

isWriteable

public boolean isWriteable()

判断是否 isWriteable。

Returns whether the writeable.

返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/core/nacos/skill/NacosSkillRepository.java:222–225

getAllSkillNames

public List<String> getAllSkillNames()

获取 getAllSkillNames。

Returns the all skill names.

返回Returns List<String>
返回列出。Returns list.
源码Source io/agentscope/core/nacos/skill/NacosSkillRepository.java:229–238

getAllSkills

public List<AgentSkill> getAllSkills()

获取所有技能。

Returns the all skills.

返回Returns List<AgentSkill>
返回列出。Returns list.
源码Source io/agentscope/core/nacos/skill/NacosSkillRepository.java:240–258

save

public boolean save(List<AgentSkill> skills, boolean force)

保存数据到持久化存储。

Performs the save operation.

参数Parameters
名称Name类型Type说明Description
skillsList<AgentSkill>技能(类型 `List`)。The skills.
forcebooleanforce(类型 `boolean`)。The force.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/core/nacos/skill/NacosSkillRepository.java:260–264

delete

public boolean delete(String skillName)

删除数据。

Performs the delete operation.

参数Parameters
名称Name类型Type说明Description
skillNameString技能名称(类型 `String`)。The skill name.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/core/nacos/skill/NacosSkillRepository.java:266–270

close

public void close()

关闭连接并释放相关资源。

Releases resources and connections.

源码Source io/agentscope/core/nacos/skill/NacosSkillRepository.java:272–275
基于官方固定版本源码静态生成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.